[
  {
    "path": ".envrc",
    "content": "if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then\n    source_url \"https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc\" \"sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=\"\nfi\nuse flake\n# vi: ft=sh\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: mhogrefe\n\n"
  },
  {
    "path": ".github/workflows/rust.yml",
    "content": "name: Rust\n\non:\n  push:\n    branches: [ \"master\" ]\n  pull_request:\n    branches: [ \"master\" ]\n\nenv:\n  CARGO_TERM_COLOR: always\n\njobs:\n  build:\n\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v4\n    - name: Build\n      run: cargo build --verbose\n    - name: Run tests\n      run: cargo test --release --verbose\n"
  },
  {
    "path": ".gitignore",
    "content": "target\n*.bk\n.idea*\n*.iml\nsrc/integer_old.rs\n*.DS_Store\n*/.vscode/*\n*.history/*\n*/.history/*\n\n.direnv/\n"
  },
  {
    "path": ".vscode/launch.json",
    "content": "{\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"name\": \"malachite-nz-test-util\",\n            \"type\": \"lldb\",\n            \"request\": \"launch\",\n            \"program\": \"${workspaceRoot}/malachite-nz-test-util/target/debug/malachite_nz_test_util_main\",\n            \"args\": [\"-l 10000 -m exhaustive -d demo_natural_mul\"],\n            \"cwd\": \"${workspaceRoot}\",\n            \"stopOnEntry\": false,\n        }\n    ]\n}"
  },
  {
    "path": ".vscode/tasks.json",
    "content": "{\n    // See https://go.microsoft.com/fwlink/?LinkId=733558\n    // for the documentation about the tasks.json format\n    \"version\": \"2.0.0\",\n    \"tasks\": [\n        {\n            \"label\": \"malachite-base: check\",\n            \"type\": \"shell\",\n            \"command\": \"cargo check --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base\"\n            }\n        },\n        {\n            \"label\": \"malachite-base: clippy\",\n            \"type\": \"shell\",\n            \"command\": \"cargo clippy --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base\"\n            }\n        },\n        {\n            \"label\": \"malachite-base: fmt\",\n            \"type\": \"shell\",\n            \"command\": \"cargo fmt\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base\"\n            }\n        },\n        {\n            \"label\": \"malachite-base: doc\",\n            \"type\": \"shell\",\n            \"command\": \"cargo doc --no-deps\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base\",\n                \"env\": {\n                    \"RUSTDOCFLAGS\": \"--html-in-header katex-header.html\"\n                }\n            }\n        },\n        {\n            \"label\": \"malachite-base: open docs\",\n            \"type\": \"shell\",\n            \"command\": \"open target/doc/malachite_base/index.html\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base\",\n            }\n        },\n\n        {\n            \"label\": \"malachite-base-test-util: check\",\n            \"type\": \"shell\",\n            \"command\": \"cargo check --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base-test-util\"\n            }\n        },\n        {\n            \"label\": \"malachite-base-test-util: clippy\",\n            \"type\": \"shell\",\n            \"command\": \"cargo clippy --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base-test-util\"\n            }\n        },\n        {\n            \"label\": \"malachite-base-test-util: fmt\",\n            \"type\": \"shell\",\n            \"command\": \"cargo fmt\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-base-test-util\"\n            }\n        },\n\n        {\n            \"label\": \"malachite-nz 32: check\",\n            \"type\": \"shell\",\n            \"command\": \"cargo check --all-targets --features 32_bit_limbs\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz\"\n            }\n        },\n        {\n            \"label\": \"malachite-nz 32: clippy\",\n            \"type\": \"shell\",\n            \"command\": \"cargo clippy --all-targets --features 32_bit_limbs\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz\"\n            }\n        },\n        {\n            \"label\": \"malachite-nz 64: check\",\n            \"type\": \"shell\",\n            \"command\": \"cargo check --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz\"\n            }\n        },\n        {\n            \"label\": \"malachite-nz 64: clippy\",\n            \"type\": \"shell\",\n            \"command\": \"cargo clippy --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz\"\n            }\n        },\n        {\n            \"label\": \"malachite-nz: fmt\",\n            \"type\": \"shell\",\n            \"command\": \"cargo fmt\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz\"\n            }\n        },\n        {\n            \"label\": \"malachite-nz: doc\",\n            \"type\": \"shell\",\n            \"command\": \"cargo doc --no-deps\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz\",\n                \"env\": {\n                    \"RUSTDOCFLAGS\": \"--html-in-header katex-header.html\"\n                }\n            }\n        },\n        {\n            \"label\": \"malachite-nz: open docs\",\n            \"type\": \"shell\",\n            \"command\": \"open target/doc/malachite_nz/index.html\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz\",\n            }\n        },\n\n        {\n            \"label\": \"malachite-nz-test-util: check\",\n            \"type\": \"shell\",\n            \"command\": \"cargo check --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz-test-util\"\n            }\n        },\n        {\n            \"label\": \"malachite-nz-test-util: clippy\",\n            \"type\": \"shell\",\n            \"command\": \"cargo clippy --all-targets\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz-test-util\"\n            }\n        },\n        {\n            \"label\": \"malachite-nz-test-util: fmt\",\n            \"type\": \"shell\",\n            \"command\": \"cargo fmt\",\n            \"options\": {\n                \"cwd\": \"${workspaceFolder}/malachite-nz-test-util\"\n            }\n        },\n    ]\n}"
  },
  {
    "path": "COPYING",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "COPYING.LESSER",
    "content": "                   GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\n  This version of the GNU Lesser General Public License incorporates\nthe terms and conditions of version 3 of the GNU General Public\nLicense, supplemented by the additional permissions listed below.\n\n  0. Additional Definitions.\n\n  As used herein, \"this License\" refers to version 3 of the GNU Lesser\nGeneral Public License, and the \"GNU GPL\" refers to version 3 of the GNU\nGeneral Public License.\n\n  \"The Library\" refers to a covered work governed by this License,\nother than an Application or a Combined Work as defined below.\n\n  An \"Application\" is any work that makes use of an interface provided\nby the Library, but which is not otherwise based on the Library.\nDefining a subclass of a class defined by the Library is deemed a mode\nof using an interface provided by the Library.\n\n  A \"Combined Work\" is a work produced by combining or linking an\nApplication with the Library.  The particular version of the Library\nwith which the Combined Work was made is also called the \"Linked\nVersion\".\n\n  The \"Minimal Corresponding Source\" for a Combined Work means the\nCorresponding Source for the Combined Work, excluding any source code\nfor portions of the Combined Work that, considered in isolation, are\nbased on the Application, and not on the Linked Version.\n\n  The \"Corresponding Application Code\" for a Combined Work means the\nobject code and/or source code for the Application, including any data\nand utility programs needed for reproducing the Combined Work from the\nApplication, but excluding the System Libraries of the Combined Work.\n\n  1. Exception to Section 3 of the GNU GPL.\n\n  You may convey a covered work under sections 3 and 4 of this License\nwithout being bound by section 3 of the GNU GPL.\n\n  2. Conveying Modified Versions.\n\n  If you modify a copy of the Library, and, in your modifications, a\nfacility refers to a function or data to be supplied by an Application\nthat uses the facility (other than as an argument passed when the\nfacility is invoked), then you may convey a copy of the modified\nversion:\n\n   a) under this License, provided that you make a good faith effort to\n   ensure that, in the event an Application does not supply the\n   function or data, the facility still operates, and performs\n   whatever part of its purpose remains meaningful, or\n\n   b) under the GNU GPL, with none of the additional permissions of\n   this License applicable to that copy.\n\n  3. Object Code Incorporating Material from Library Header Files.\n\n  The object code form of an Application may incorporate material from\na header file that is part of the Library.  You may convey such object\ncode under terms of your choice, provided that, if the incorporated\nmaterial is not limited to numerical parameters, data structure\nlayouts and accessors, or small macros, inline functions and templates\n(ten or fewer lines in length), you do both of the following:\n\n   a) Give prominent notice with each copy of the object code that the\n   Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the object code with a copy of the GNU GPL and this license\n   document.\n\n  4. Combined Works.\n\n  You may convey a Combined Work under terms of your choice that,\ntaken together, effectively do not restrict modification of the\nportions of the Library contained in the Combined Work and reverse\nengineering for debugging such modifications, if you also do each of\nthe following:\n\n   a) Give prominent notice with each copy of the Combined Work that\n   the Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the Combined Work with a copy of the GNU GPL and this license\n   document.\n\n   c) For a Combined Work that displays copyright notices during\n   execution, include the copyright notice for the Library among\n   these notices, as well as a reference directing the user to the\n   copies of the GNU GPL and this license document.\n\n   d) Do one of the following:\n\n       0) Convey the Minimal Corresponding Source under the terms of this\n       License, and the Corresponding Application Code in a form\n       suitable for, and under terms that permit, the user to\n       recombine or relink the Application with a modified version of\n       the Linked Version to produce a modified Combined Work, in the\n       manner specified by section 6 of the GNU GPL for conveying\n       Corresponding Source.\n\n       1) Use a suitable shared library mechanism for linking with the\n       Library.  A suitable mechanism is one that (a) uses at run time\n       a copy of the Library already present on the user's computer\n       system, and (b) will operate properly with a modified version\n       of the Library that is interface-compatible with the Linked\n       Version.\n\n   e) Provide Installation Information, but only if you would otherwise\n   be required to provide such information under section 6 of the\n   GNU GPL, and only to the extent that such information is\n   necessary to install and execute a modified version of the\n   Combined Work produced by recombining or relinking the\n   Application with a modified version of the Linked Version. (If\n   you use option 4d0, the Installation Information must accompany\n   the Minimal Corresponding Source and Corresponding Application\n   Code. If you use option 4d1, you must provide the Installation\n   Information in the manner specified by section 6 of the GNU GPL\n   for conveying Corresponding Source.)\n\n  5. Combined Libraries.\n\n  You may place library facilities that are a work based on the\nLibrary side by side in a single library together with other library\nfacilities that are not Applications and are not covered by this\nLicense, and convey such a combined library under terms of your\nchoice, if you do both of the following:\n\n   a) Accompany the combined library with a copy of the same work based\n   on the Library, uncombined with any other library facilities,\n   conveyed under the terms of this License.\n\n   b) Give prominent notice with the combined library that part of it\n   is a work based on the Library, and explaining where to find the\n   accompanying uncombined form of the same work.\n\n  6. Revised Versions of the GNU Lesser General Public License.\n\n  The Free Software Foundation may publish revised and/or new versions\nof the GNU Lesser General Public License from time to time. Such new\nversions will be similar in spirit to the present version, but may\ndiffer in detail to address new problems or concerns.\n\n  Each version is given a distinguishing version number. If the\nLibrary as you received it specifies that a certain numbered version\nof the GNU Lesser General Public License \"or any later version\"\napplies to it, you have the option of following the terms and\nconditions either of that published version or of any later version\npublished by the Free Software Foundation. If the Library as you\nreceived it does not specify a version number of the GNU Lesser\nGeneral Public License, you may choose any version of the GNU Lesser\nGeneral Public License ever published by the Free Software Foundation.\n\n  If the Library as you received it specifies that a proxy can decide\nwhether future versions of the GNU Lesser General Public License shall\napply, that proxy's public statement of acceptance of any version is\npermanent authorization for you to choose that version for the\nLibrary.\n"
  },
  {
    "path": "Cargo.toml",
    "content": "[workspace]\nmembers = ['malachite', 'malachite-base', 'malachite-bigint', 'malachite-float', 'malachite-nz', 'malachite-q', 'malachite-criterion-bench']\nresolver = \"2\"\n\n[workspace.package]\nedition = \"2024\"\nrust-version = \"1.90.0\"\n\n[workspace.dependencies]\nmalachite-base = { version = \"0.9.1\", path = 'malachite-base', default-features = false }\nmalachite-nz = { version = \"0.9.1\", path = 'malachite-nz', default-features = false }\nmalachite-q = { version = \"0.9.1\", path = 'malachite-q', default-features = false }\nmalachite-float = { version = \"0.9.1\", path = 'malachite-float', default-features = false }\n\n[profile.release]\nlto = \"fat\"\nstrip = true\ncodegen-units = 1\n"
  },
  {
    "path": "LICENSE",
    "content": "                   GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\n  This version of the GNU Lesser General Public License incorporates\nthe terms and conditions of version 3 of the GNU General Public\nLicense, supplemented by the additional permissions listed below.\n\n  0. Additional Definitions.\n\n  As used herein, \"this License\" refers to version 3 of the GNU Lesser\nGeneral Public License, and the \"GNU GPL\" refers to version 3 of the GNU\nGeneral Public License.\n\n  \"The Library\" refers to a covered work governed by this License,\nother than an Application or a Combined Work as defined below.\n\n  An \"Application\" is any work that makes use of an interface provided\nby the Library, but which is not otherwise based on the Library.\nDefining a subclass of a class defined by the Library is deemed a mode\nof using an interface provided by the Library.\n\n  A \"Combined Work\" is a work produced by combining or linking an\nApplication with the Library.  The particular version of the Library\nwith which the Combined Work was made is also called the \"Linked\nVersion\".\n\n  The \"Minimal Corresponding Source\" for a Combined Work means the\nCorresponding Source for the Combined Work, excluding any source code\nfor portions of the Combined Work that, considered in isolation, are\nbased on the Application, and not on the Linked Version.\n\n  The \"Corresponding Application Code\" for a Combined Work means the\nobject code and/or source code for the Application, including any data\nand utility programs needed for reproducing the Combined Work from the\nApplication, but excluding the System Libraries of the Combined Work.\n\n  1. Exception to Section 3 of the GNU GPL.\n\n  You may convey a covered work under sections 3 and 4 of this License\nwithout being bound by section 3 of the GNU GPL.\n\n  2. Conveying Modified Versions.\n\n  If you modify a copy of the Library, and, in your modifications, a\nfacility refers to a function or data to be supplied by an Application\nthat uses the facility (other than as an argument passed when the\nfacility is invoked), then you may convey a copy of the modified\nversion:\n\n   a) under this License, provided that you make a good faith effort to\n   ensure that, in the event an Application does not supply the\n   function or data, the facility still operates, and performs\n   whatever part of its purpose remains meaningful, or\n\n   b) under the GNU GPL, with none of the additional permissions of\n   this License applicable to that copy.\n\n  3. Object Code Incorporating Material from Library Header Files.\n\n  The object code form of an Application may incorporate material from\na header file that is part of the Library.  You may convey such object\ncode under terms of your choice, provided that, if the incorporated\nmaterial is not limited to numerical parameters, data structure\nlayouts and accessors, or small macros, inline functions and templates\n(ten or fewer lines in length), you do both of the following:\n\n   a) Give prominent notice with each copy of the object code that the\n   Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the object code with a copy of the GNU GPL and this license\n   document.\n\n  4. Combined Works.\n\n  You may convey a Combined Work under terms of your choice that,\ntaken together, effectively do not restrict modification of the\nportions of the Library contained in the Combined Work and reverse\nengineering for debugging such modifications, if you also do each of\nthe following:\n\n   a) Give prominent notice with each copy of the Combined Work that\n   the Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the Combined Work with a copy of the GNU GPL and this license\n   document.\n\n   c) For a Combined Work that displays copyright notices during\n   execution, include the copyright notice for the Library among\n   these notices, as well as a reference directing the user to the\n   copies of the GNU GPL and this license document.\n\n   d) Do one of the following:\n\n       0) Convey the Minimal Corresponding Source under the terms of this\n       License, and the Corresponding Application Code in a form\n       suitable for, and under terms that permit, the user to\n       recombine or relink the Application with a modified version of\n       the Linked Version to produce a modified Combined Work, in the\n       manner specified by section 6 of the GNU GPL for conveying\n       Corresponding Source.\n\n       1) Use a suitable shared library mechanism for linking with the\n       Library.  A suitable mechanism is one that (a) uses at run time\n       a copy of the Library already present on the user's computer\n       system, and (b) will operate properly with a modified version\n       of the Library that is interface-compatible with the Linked\n       Version.\n\n   e) Provide Installation Information, but only if you would otherwise\n   be required to provide such information under section 6 of the\n   GNU GPL, and only to the extent that such information is\n   necessary to install and execute a modified version of the\n   Combined Work produced by recombining or relinking the\n   Application with a modified version of the Linked Version. (If\n   you use option 4d0, the Installation Information must accompany\n   the Minimal Corresponding Source and Corresponding Application\n   Code. If you use option 4d1, you must provide the Installation\n   Information in the manner specified by section 6 of the GNU GPL\n   for conveying Corresponding Source.)\n\n  5. Combined Libraries.\n\n  You may place library facilities that are a work based on the\nLibrary side by side in a single library together with other library\nfacilities that are not Applications and are not covered by this\nLicense, and convey such a combined library under terms of your\nchoice, if you do both of the following:\n\n   a) Accompany the combined library with a copy of the same work based\n   on the Library, uncombined with any other library facilities,\n   conveyed under the terms of this License.\n\n   b) Give prominent notice with the combined library that part of it\n   is a work based on the Library, and explaining where to find the\n   accompanying uncombined form of the same work.\n\n  6. Revised Versions of the GNU Lesser General Public License.\n\n  The Free Software Foundation may publish revised and/or new versions\nof the GNU Lesser General Public License from time to time. Such new\nversions will be similar in spirit to the present version, but may\ndiffer in detail to address new problems or concerns.\n\n  Each version is given a distinguishing version number. If the\nLibrary as you received it specifies that a certain numbered version\nof the GNU Lesser General Public License \"or any later version\"\napplies to it, you have the option of following the terms and\nconditions either of that published version or of any later version\npublished by the Free Software Foundation. If the Library as you\nreceived it does not specify a version number of the GNU Lesser\nGeneral Public License, you may choose any version of the GNU Lesser\nGeneral Public License ever published by the Free Software Foundation.\n\n  If the Library as you received it specifies that a proxy can decide\nwhether future versions of the GNU Lesser General Public License shall\napply, that proxy's public statement of acceptance of any version is\npermanent authorization for you to choose that version for the\nLibrary.\n"
  },
  {
    "path": "README.md",
    "content": "<img width=\"500\" src=\"docs/assets/logo-and-name.svg\" alt=\"Logo\">\n\nAn arbitrary-precision arithmetic library for Rust.\n\nParts of Malachite are derived from [GMP](https://gmplib.org/),\n[FLINT](https://www.flintlib.org/), and [MPFR](https://www.mpfr.org/).\n\nThe documentation for Malachite is [here](https://docs.rs/malachite/latest/malachite/), and its crate is [here](https://crates.io/crates/malachite).\n\nFloats (arbitrary-precision floating-point numbers) are in development and are currently experimental. They are missing many important functions. However, the floating-point functions that *are* currently implemented are thoroughly tested and documented, with the exception of string conversion functions. The current floating-point string conversion functions are incomplete and will be changed in the future to match MPFR's behavior.\n\nMalachite is developed by Mikhail Hogrefe. Thanks to 43615, b4D8, coolreader18, Dasaav-dsv, Duncan Freeman, florian1345, konstin, Rowan Hart, YunWon Jeong, Park Joon-Kyu, Antonio Mamić, OliverNChalk, Kevin Phoenix, probablykasper, shekohex, skycloudd, John Vandenberg, Brandon Weeks, and Will Youmans for additional contributions.\n\n<https://malachite.rs/>\n\nCopyright © 2026 Mikhail Hogrefe\n"
  },
  {
    "path": "_config.yml",
    "content": "theme: jekyll-theme-cayman"
  },
  {
    "path": "additional-lints.py",
    "content": "import os\n\nMAX_LINE_LENGTH = 100\n\nline_length_exceptions = set((\n    # long Markdown table rows and/or links\n    ('./malachite-base/src/lib.rs', 65),\n    ('./malachite-base/src/num/arithmetic/mod.rs', 339),\n    ('./malachite-base/src/num/arithmetic/mod.rs', 340),\n    ('./malachite-base/src/num/arithmetic/mod.rs', 1340),\n    ('./malachite-base/src/num/arithmetic/mod.rs', 1580),\n    ('./malachite-base/src/num/arithmetic/mod.rs', 1581),\n    ('./malachite-base/src/num/arithmetic/mod.rs', 1582),\n    ('./malachite-base/src/num/arithmetic/mod.rs', 1583),\n    ('./malachite-base/src/num/arithmetic/primorial.rs', 85),\n    ('./malachite-base/src/num/arithmetic/primorial.rs', 244),\n    ('./malachite-base/src/num/arithmetic/round_to_multiple_of_power_of_2.rs', 118),\n    ('./malachite-base/src/num/conversion/digits/power_of_2_digit_iterable.rs', 153),\n    ('./malachite-base/src/num/conversion/digits/power_of_2_digit_iterable.rs', 155),\n    ('./malachite-base/src/num/exhaustive/mod.rs', 1074),\n    ('./malachite-float/src/conversion/mantissa_and_exponent.rs', 478),\n    ('./malachite-float/src/conversion/mantissa_and_exponent.rs', 682),\n    ('./malachite-float/src/conversion/mod.rs', 227),\n    ('./malachite-float/src/lib.rs', 24),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 39),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 40),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 41),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 76),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 77),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 88),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 89),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 90),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 119),\n    ('./malachite-nz/src/integer/arithmetic/mod.rs', 121),\n    ('./malachite-nz/src/lib.rs', 36),\n    ('./malachite-nz/src/lib.rs', 103),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 46),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 47),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 48),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 162),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 163),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 186),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 187),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 188),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 571),\n    ('./malachite-nz/src/natural/arithmetic/mod.rs', 573),\n    ('./malachite-nz/src/natural/conversion/digits/power_of_2_digit_iterable.rs', 526),\n    ('./malachite-nz/src/natural/conversion/digits/power_of_2_digit_iterable.rs', 528),\n    ('./malachite-nz/src/natural/conversion/digits/power_of_2_digit_iterable.rs', 827),\n    ('./malachite-nz/src/natural/conversion/digits/power_of_2_digit_iterable.rs', 829),\n    ('./malachite-nz/src/natural/conversion/mantissa_and_exponent.rs', 323),\n    ('./malachite-nz/src/natural/conversion/mantissa_and_exponent.rs', 508),\n    ('./malachite-nz/src/natural/conversion/mod.rs', 257),\n    ('./malachite-q/src/arithmetic/mod.rs', 63),\n    ('./malachite-q/src/arithmetic/mod.rs', 64),\n    ('./malachite-q/src/arithmetic/mod.rs', 95),\n    ('./malachite-q/src/arithmetic/mod.rs', 97),\n    ('./malachite-q/src/conversion/string/from_sci_string.rs', 145),\n    ('./malachite-q/src/conversion/string/from_sci_string.rs', 232),\n    ('./malachite-q/src/lib.rs', 54),\n))\n\ndef lint(filename):\n    i = 1\n    with open(filename) as f:\n        for line in f.readlines():\n            line = line.rstrip()\n            is_exception = (filename, i) in line_length_exceptions\n            if is_exception:\n                if len(line) <= MAX_LINE_LENGTH:\n                    raise ValueError(f'line not too long: {filename}: {i} {line}')\n            elif len(line) > MAX_LINE_LENGTH:\n                raise ValueError(f'line too long: {filename}: {i} {line}')\n            i += 1\n    return i - 1\n\nfilename_list = []\nfor root, directories, filenames in os.walk('.'):\n    for filename in filenames: \n        filename = os.path.join(root, filename) \n        if '/target/' not in filename and '.history' not in filename and filename.endswith('.rs'):\n            filename_list.append(filename)\nfilename_list.sort()\n\nline_count = 0\nfor filename in filename_list:\n    line_count += lint(filename)\nprint(f'{line_count} lines checked')\n"
  },
  {
    "path": "build.sh",
    "content": "#!/bin/bash\necho \"Step 1. Checking for updates\" &&\nrustup update &&\necho \"Step 2. Updating headers\" &&\ncd ../fix-headers &&\ncargo test --release &&\ncd ../malachite/malachite-base &&\necho \"Step 3. Formatting malachite-base\" &&\nbash ../superfmt.sh &&\necho \"Step 4. Checking malachite-base lib\" &&\ncargo check --lib &&\necho \"Step 5. Checking malachite-base lib with random\" &&\ncargo check --lib --features random &&\necho \"Step 6. Checking all malachite-base targets with bin_build\" &&\ncargo check --all-targets --features bin_build &&\necho \"Step 7. Checking malachite-base lib with no std\" &&\ncargo check --lib --no-default-features &&\necho \"Step 8. Checking malachite-base lib with random and no std\" &&\ncargo check --lib --features random --no-default-features &&\necho \"Step 9. Checking all malachite-base targets with bin_build and no std\" &&\ncargo check --all-targets --features bin_build --no-default-features &&\ncd ../malachite-nz &&\necho \"Step 10. Formatting malachite-nz\" &&\nbash ../superfmt.sh &&\necho \"Step 11. Checking malachite-nz lib with 32_bit_limbs\" &&\ncargo check --lib --features 32_bit_limbs &&\necho \"Step 12. Checking malachite-nz lib\" &&\ncargo check --lib &&\necho \"Step 13. Checking malachite-nz lib with 32_bit_limbs and random\" &&\ncargo check --lib --features 32_bit_limbs --features random &&\necho \"Step 14. Checking malachite-nz lib with random\" &&\ncargo check --lib --features random &&\necho \"Step 15. Checking malachite-nz lib with 32_bit_limbs and serde\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde &&\necho \"Step 16. Checking malachite-nz lib with serde\" &&\ncargo check --lib --features enable_serde &&\necho \"Step 17. Checking malachite-nz lib with 32_bit_limbs, serde, and random\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --features random &&\necho \"Step 18. Checking malachite-nz lib with serde and random\" &&\ncargo check --lib --features enable_serde --features random &&\necho \"Step 19. Checking all malachite-nz targets with bin_build, 32_bit_limbs, and serde\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde &&\necho \"Step 20. Checking all malachite-nz targets with bin_build and serde\" &&\ncargo check --all-targets --features bin_build --features enable_serde &&\necho \"Step 21. Checking all malachite-nz targets with bin_build, 32_bit_limbs, serde, and random\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --features random &&\necho \"Step 22. Checking all malachite-nz targets with bin_build, serde, and random\" &&\ncargo check --all-targets --features bin_build --features enable_serde --features random &&\necho \"Step 23. Checking malachite-nz lib with 32_bit_limbs and no std\" &&\ncargo check --lib --features 32_bit_limbs --no-default-features &&\necho \"Step 24. Checking malachite-nz lib with no std\" &&\ncargo check --lib --no-default-features &&\necho \"Step 25. Checking malachite-nz lib with 32_bit_limbs and random and no std\" &&\ncargo check --lib --features 32_bit_limbs --features random --no-default-features &&\necho \"Step 26. Checking malachite-nz lib with random and no std\" &&\ncargo check --lib --features random --no-default-features &&\necho \"Step 27. Checking malachite-nz lib with 32_bit_limbs and serde and no std\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 28. Checking malachite-nz lib with serde and no std\" &&\ncargo check --lib --features enable_serde --no-default-features &&\necho \"Step 29. Checking malachite-nz lib with 32_bit_limbs, serde, and random and no std\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --features random --no-default-features &&\necho \"Step 30. Checking malachite-nz lib with serde and random and no std\" &&\ncargo check --lib --features enable_serde --features random --no-default-features &&\necho \"Step 31. Checking all malachite-nz targets with bin_build, 32_bit_limbs, and serde and no std\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 32. Checking all malachite-nz targets with bin_build and serde and no std\" &&\ncargo check --all-targets --features bin_build --features enable_serde --no-default-features &&\necho \"Step 33. Checking all malachite-nz targets with bin_build, 32_bit_limbs, serde, and random and no std\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --features random --no-default-features &&\necho \"Step 34. Checking all malachite-nz targets with bin_build, serde, and random and no std\" &&\ncargo check --all-targets --features bin_build --features enable_serde --features random --no-default-features &&\ncd ../malachite-q &&\necho \"Step 35. Formatting malachite-q\" &&\nbash ../superfmt.sh &&\necho \"Step 36. Checking malachite-q lib with 32_bit_limbs\" &&\ncargo check --lib --features 32_bit_limbs &&\necho \"Step 37. Checking malachite-q lib\" &&\ncargo check --lib &&\necho \"Step 38. Checking malachite-q lib with 32_bit_limbs and random\" &&\ncargo check --lib --features 32_bit_limbs --features random &&\necho \"Step 39. Checking malachite-q lib with random\" &&\ncargo check --lib --features random &&\necho \"Step 40. Checking malachite-q lib with 32_bit_limbs and serde\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde &&\necho \"Step 41. Checking malachite-q lib with serde\" &&\ncargo check --lib --features enable_serde &&\necho \"Step 42. Checking malachite-q lib with 32_bit_limbs, serde, and random\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --features random &&\necho \"Step 43. Checking malachite-q lib with serde and random\" &&\ncargo check --lib --features enable_serde --features random &&\necho \"Step 44. Checking all malachite-q targets with bin_build, 32_bit_limbs, and serde\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde &&\necho \"Step 45. Checking all malachite-q targets with bin_build and serde\" &&\ncargo check --all-targets --features bin_build --features enable_serde &&\necho \"Step 46. Checking all malachite-q targets with bin_build, 32_bit_limbs, serde, and random\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --features random &&\necho \"Step 47. Checking all malachite-q targets with bin_build, serde, and random\" &&\ncargo check --all-targets --features bin_build --features enable_serde --features random &&\necho \"Step 48. Checking malachite-q lib with 32_bit_limbs and no std\" &&\ncargo check --lib --features 32_bit_limbs --no-default-features &&\necho \"Step 49. Checking malachite-q lib with no std\" &&\ncargo check --lib --no-default-features &&\necho \"Step 50. Checking malachite-q lib with 32_bit_limbs and random and no std\" &&\ncargo check --lib --features 32_bit_limbs --features random --no-default-features &&\necho \"Step 51. Checking malachite-q lib with random and no std\" &&\ncargo check --lib --features random --no-default-features &&\necho \"Step 52. Checking malachite-q lib with 32_bit_limbs and serde and no std\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 53. Checking malachite-q lib with serde and no std\" &&\ncargo check --lib --features enable_serde --no-default-features &&\necho \"Step 54. Checking malachite-q lib with 32_bit_limbs, serde, and random and no std\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --features random --no-default-features &&\necho \"Step 55. Checking malachite-q lib with serde and random and no std\" &&\ncargo check --lib --features enable_serde --features random --no-default-features &&\necho \"Step 56. Checking all malachite-q targets with bin_build, 32_bit_limbs, and serde and no std\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 57. Checking all malachite-q targets with bin_build and serde and no std\" &&\ncargo check --all-targets --features bin_build --features enable_serde --no-default-features &&\necho \"Step 58. Checking all malachite-q targets with bin_build, 32_bit_limbs, serde, and random and no std\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --features random --no-default-features &&\necho \"Step 59. Checking all malachite-q targets with bin_build, serde, and random and no std\" &&\ncargo check --all-targets --features bin_build --features enable_serde --features random --no-default-features &&\ncd ../malachite-float &&\necho \"Step 60. Formatting malachite-float\" &&\nbash ../superfmt.sh &&\necho \"Step 61. Checking malachite-float lib with 32_bit_limbs\" &&\ncargo check --lib --features 32_bit_limbs &&\necho \"Step 62. Checking malachite-float lib\" &&\ncargo check --lib &&\necho \"Step 63. Checking malachite-float lib with 32_bit_limbs and random\" &&\ncargo check --lib --features 32_bit_limbs --features random &&\necho \"Step 64. Checking malachite-float lib with random\" &&\ncargo check --lib --features random &&\necho \"Step 65. Checking malachite-float lib with 32_bit_limbs and serde\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde &&\necho \"Step 66. Checking malachite-float lib with serde\" &&\ncargo check --lib --features enable_serde &&\necho \"Step 67. Checking malachite-float lib with 32_bit_limbs, serde, and random\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --features random &&\necho \"Step 68. Checking malachite-float lib with serde and random\" &&\ncargo check --lib --features enable_serde --features random &&\necho \"Step 69. Checking all malachite-float targets with bin_build, 32_bit_limbs, and serde\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde &&\necho \"Step 70. Checking all malachite-float targets with bin_build and serde\" &&\ncargo check --all-targets --features bin_build --features enable_serde &&\necho \"Step 71. Checking all malachite-float targets with bin_build, 32_bit_limbs, serde, and random\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --features random &&\necho \"Step 72. Checking all malachite-float targets with bin_build, serde, and random\" &&\ncargo check --all-targets --features bin_build --features enable_serde --features random &&\necho \"Step 73. Checking malachite-float lib with 32_bit_limbs and no std\" &&\ncargo check --lib --features 32_bit_limbs --no-default-features &&\necho \"Step 74. Checking malachite-float lib with no std\" &&\ncargo check --lib --no-default-features &&\necho \"Step 75. Checking malachite-float lib with 32_bit_limbs and random and no std\" &&\ncargo check --lib --features 32_bit_limbs --features random --no-default-features &&\necho \"Step 76. Checking malachite-float lib with random and no std\" &&\ncargo check --lib --features random --no-default-features &&\necho \"Step 77. Checking malachite-float lib with 32_bit_limbs and serde and no std\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 78. Checking malachite-float lib with serde and no std\" &&\ncargo check --lib --features enable_serde --no-default-features &&\necho \"Step 79. Checking malachite-float lib with 32_bit_limbs, serde, and random and no std\" &&\ncargo check --lib --features 32_bit_limbs --features enable_serde --features random --no-default-features &&\necho \"Step 80. Checking malachite-float lib with serde and random and no std\" &&\ncargo check --lib --features enable_serde --features random --no-default-features &&\necho \"Step 81. Checking all malachite-float targets with bin_build, 32_bit_limbs, and serde no std\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 82. Checking all malachite-float targets with bin_build and serde and no std\" &&\ncargo check --all-targets --features bin_build --features enable_serde --no-default-features &&\necho \"Step 83. Checking all malachite-float targets with bin_build, 32_bit_limbs, serde, and random and no std\" &&\ncargo check --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --features random --no-default-features &&\necho \"Step 84. Checking all malachite-float targets with bin_build, serde, and random and no std\" &&\ncargo check --all-targets --features bin_build --features enable_serde --features random --no-default-features &&\ncd ../malachite-criterion-bench &&\necho \"Step 85. Formatting malachite-criterion-bench\" &&\nbash ../superfmt.sh &&\necho \"Step 86. Checking malachite-criterion-bench\" &&\ncargo check &&\ncd ../malachite-bigint &&\necho \"Step 87. Formatting malachite-bigint\" &&\nbash ../superfmt.sh &&\necho \"Step 88. Checking all malachite-bigint targets\" &&\ncargo check --all-targets &&\necho \"Step 89. Checking all malachite-bigint targets with no std\" &&\ncargo check --all-targets --no-default-features &&\necho \"Step 90. Checking the malachite meta-crate\" &&\ncd ../malachite &&\ncargo check --all-targets &&\necho \"Step 91. Checking the malachite meta-crate with serde\" &&\ncargo check --all-targets --features enable_serde &&\ncd .. &&\necho \"Step 92. Running additional-lints\" &&\npython3 additional-lints.py &&\ncd malachite-base &&\necho \"Step 93. Updating malachite-base\" &&\ncargo update &&\necho \"Step 94. Formatting malachite-base\" &&\nbash ../superfmt.sh &&\necho \"Step 95. Running clippy on malachite-base\" &&\ncargo clippy --all-targets --features bin_build &&\necho \"Step 96. Running clippy on malachite-base with no std\" &&\ncargo clippy --all-targets --features bin_build --no-default-features &&\necho \"Step 97. Testing malachite-base\" &&\ncargo test --release --tests --features bin_build &&\necho \"Step 98. Testing malachite-base with no std\" &&\ncargo test --release --tests --features bin_build --no-default-features &&\necho \"Step 99. Testing malachite-base doctests\" &&\nbash ../rundoc.sh --features test_build &&\necho \"Step 100. Testing malachite-base doctests with random\" &&\nbash ../rundoc.sh --features test_build --features random &&\necho \"Step 101. Documenting malachite-base\" &&\nRUSTDOCFLAGS=\"--html-in-header katex-header.html\" cargo doc --lib --no-deps --features random &&\necho \"Step 102. Building malachite-base lib for wasm\" &&\ncargo build --lib --release --target wasm32-unknown-unknown &&\ncd ../malachite-nz &&\necho \"Step 103. Updating malachite-nz\" &&\ncargo update &&\necho \"Step 104. Formatting malachite-nz\" &&\nbash ../superfmt.sh &&\necho \"Step 105. Running clippy on malachite-nz\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde &&\necho \"Step 106. Running clippy on malachite-nz with 32_bit_limbs\" &&\ncargo clippy --all-targets --features bin_build --features 32_bit_limbs --features enable_serde &&\necho \"Step 107. Running clippy on malachite-nz with no std\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde --no-default-features &&\necho \"Step 108. Running clippy on malachite-nz with 32_bit_limbs and no std\" &&\ncargo clippy --all-targets --features bin_build --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 109. Testing malachite-nz\" &&\ncargo test --release --tests --features test_build --features enable_serde &&\necho \"Step 110. Testing malachite-nz with no std\" &&\ncargo test --release --tests --features test_build --features enable_serde --no-default-features &&\necho \"Step 111. Testing malachite-nz doctests\" &&\nbash ../rundoc.sh --features test_build &&\necho \"Step 112. Testing malachite-nz with 32_bit_limbs\" &&\ncargo test --release --tests --features test_build --features 32_bit_limbs --features enable_serde &&\necho \"Step 113. Testing malachite-nz with 32_bit_limbs and no std\" &&\ncargo test --release --tests --features test_build --features 32_bit_limbs --features enable_serde --no-default-features &&\necho \"Step 114. Testing malachite-nz doctests with 32_bit_limbs\" &&\nbash ../rundoc.sh --features test_build --features 32_bit_limbs&&\necho \"Step 115. Testing malachite-nz doctests with 32_bit_limbs and random\" &&\nbash ../rundoc.sh --features test_build --features 32_bit_limbs --features random &&\necho \"Step 116. Running extra tests for malachite-nz\" &&\npython3 extra-tests.py &&\necho \"Step 117. Documenting malachite-nz\" &&\nRUSTDOCFLAGS=\"--html-in-header katex-header.html\" cargo doc --lib --no-deps --features doc-images --features random &&\necho \"Step 118. Building malachite-nz lib for wasm with 32_bit_limbs\" &&\ncargo build --lib --release --features 32_bit_limbs --target wasm32-unknown-unknown &&\necho \"Step 119. Building malachite-nz lib for wasm\" &&\ncargo build --lib --release --target wasm32-unknown-unknown &&\ncd ../malachite-q &&\necho \"Step 120. Updating malachite-q\" &&\ncargo update &&\necho \"Step 121. Formatting malachite-q\" &&\nbash ../superfmt.sh &&\necho \"Step 122. Running clippy on malachite-q\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde &&\necho \"Step 123. Running clippy on malachite-q with 32_bit_limbs\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde --features 32_bit_limbs &&\necho \"Step 124. Running clippy on malachite-q with no std\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde --no-default-features &&\necho \"Step 125. Running clippy on malachite-q with 32_bit_limbs and no std\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde --features 32_bit_limbs --no-default-features &&\necho \"Step 126. Testing malachite-q\" &&\ncargo test --release --tests --features bin_build --features enable_serde &&\necho \"Step 127. Testing malachite-q with no std\" &&\ncargo test --release --tests --features bin_build --features enable_serde --no-default-features &&\necho \"Step 128. Testing malachite-q doctests\" &&\nbash ../rundoc.sh --features test_build &&\necho \"Step 129. Testing malachite-q with 32_bit_limbs\" &&\ncargo test --release --tests --features bin_build --features enable_serde --features 32_bit_limbs &&\necho \"Step 130. Testing malachite-q with 32_bit_limbs and no std\" &&\ncargo test --release --tests --features bin_build --features enable_serde --features 32_bit_limbs --no-default-features &&\necho \"Step 131. Testing malachite-q doctests with 32_bit_limbs\" &&\nbash ../rundoc.sh --features test_build --features 32_bit_limbs &&\necho \"Step 132. Testing malachite-q doctests with random\" &&\nbash ../rundoc.sh --features test_build --features random &&\necho \"Step 133. Testing malachite-q doctests with random and 32_bit_limbs\" &&\nbash ../rundoc.sh --features test_build --features random --features 32_bit_limbs &&\necho \"Step 134. Documenting malachite-q\" &&\nRUSTDOCFLAGS=\"--html-in-header katex-header.html\" cargo doc --lib --no-deps --features random &&\necho \"Step 135. Building malachite-q lib for wasm\" &&\ncargo build --lib --release --target wasm32-unknown-unknown &&\necho \"Step 136. Building malachite-q lib for wasm with 32_bit_limbs\" &&\ncargo build --lib --release --features 32_bit_limbs --target wasm32-unknown-unknown &&\ncd ../malachite-float &&\necho \"Step 137. Updating malachite-float\" &&\ncargo update &&\necho \"Step 138. Formatting malachite-float\" &&\nbash ../superfmt.sh &&\necho \"Step 139. Running clippy on malachite-float\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde &&\necho \"Step 140. Running clippy on malachite-float with 32_bit_limbs\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde --features 32_bit_limbs &&\necho \"Step 141. Running clippy on malachite-float with no std\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde --no-default-features &&\necho \"Step 142. Running clippy on malachite-float with 32_bit_limbs and no std\" &&\ncargo clippy --all-targets --features bin_build --features enable_serde --features 32_bit_limbs --no-default-features &&\necho \"Step 143. Testing malachite-float\" &&\ncargo test --release --tests --features bin_build --features enable_serde &&\necho \"Step 144. Testing malachite-float with no std\" &&\ncargo test --release --tests --features bin_build --features enable_serde --no-default-features &&\necho \"Step 145. Testing malachite-float doctests\" &&\nbash ../rundoc.sh --features test_build &&\necho \"Step 146. Testing malachite-float with 32_bit_limbs\" &&\ncargo test --release --tests --features bin_build --features 32_bit_limbs &&\necho \"Step 147. Testing malachite-float with 32_bit_limbs and no std\" &&\ncargo test --release --tests --features bin_build --features 32_bit_limbs --no-default-features &&\necho \"Step 148. Testing malachite-float doctests with 32_bit_limbs\" &&\nbash ../rundoc.sh --features test_build --features 32_bit_limbs &&\necho \"Step 149. Testing malachite-float doctests with random\" &&\nbash ../rundoc.sh --features test_build --features random &&\necho \"Step 150. Testing malachite-float doctests with random and 32_bit_limbs\" &&\nbash ../rundoc.sh --features test_build --features random --features 32_bit_limbs &&\necho \"Step 151. Documenting malachite-float\" &&\nRUSTDOCFLAGS=\"--html-in-header katex-header.html\" cargo doc --lib --no-deps --features random &&\necho \"Step 152. Building malachite-float lib for wasm\" &&\ncargo build --lib --release --target wasm32-unknown-unknown &&\necho \"Step 153. Building malachite-float lib for wasm with 32_bit_limbs\" &&\ncargo build --lib --release --features 32_bit_limbs --target wasm32-unknown-unknown &&\ncd ../malachite-bigint &&\necho \"Step 154. Updating malachite-bigint\" &&\ncargo update &&\necho \"Step 155. Formatting malachite-bigint\" &&\nbash ../superfmt.sh &&\necho \"Step 156. Running clippy on malachite-bigint\" &&\ncargo clippy --all-targets &&\necho \"Step 157. Running clippy on malachite-bigint with no std\" &&\ncargo clippy --all-targets --no-default-features &&\necho \"Step 158. Testing malachite-bigint\" &&\ncargo test --release &&\necho \"Step 159. Testing malachite-bigint with no std\" &&\ncargo test --release --no-default-features &&\necho \"Step 160. Documenting malachite-bigint\" &&\ncargo doc --lib --no-deps &&\necho \"Step 161. Building malachite-bigint lib for wasm\" &&\ncargo build --lib --release --target wasm32-unknown-unknown &&\ncd ../malachite &&\necho \"Step 162. Documenting malachite\" &&\nRUSTDOCFLAGS=\"--html-in-header katex-header.html\" cargo doc --lib --no-deps --features random &&\ncd ../malachite-criterion-bench &&\necho \"Step 163. Updating malachite-criterion-bench\" &&\ncargo update &&\necho \"Step 164. Formatting malachite-criterion-bench\" &&\nbash ../superfmt.sh &&\ncd .. &&\necho \"Step 165. Running additional-lints\" &&\npython3 additional-lints.py &&\necho \"Step 166. Testing against FLINT\" &&\ncd ../malachite-cpp-test/malachite-test-cpp &&\ncargo run --release &&\necho \"Step 167. Checking links\" &&\ncd ../../check-malachite-links &&\ncargo run --release\n"
  },
  {
    "path": "docs/CNAME",
    "content": "www.malachite.rs"
  },
  {
    "path": "docs/_config.yml",
    "content": "theme: jekyll-theme-slate"
  },
  {
    "path": "docs/_includes/head-custom.html",
    "content": "<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"{{ \"/assets/favicon.ico\"  | absolute_url }}\">\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.15.6/dist/katex.min.css\" integrity=\"sha384-ZPe7yZ91iWxYumsBEOn7ieg8q/o+qh/hQpSaPow8T6BwALcXSCS6C6fSRPIAnTQs\" crossorigin=\"anonymous\">\n<script defer src=\"https://cdn.jsdelivr.net/npm/katex@0.15.6/dist/katex.min.js\" integrity=\"sha384-ljao5I1l+8KYFXG7LNEA7DyaFvuvSCmedUf6Y6JI7LJqiu8q5dEivP2nDdFH31V4\" crossorigin=\"anonymous\"></script>\n<script defer src=\"https://cdn.jsdelivr.net/npm/katex@0.15.6/dist/contrib/auto-render.min.js\" integrity=\"sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR\" crossorigin=\"anonymous\"\n    onload=\"renderMathInElement(document.body);\"></script>\n\n"
  },
  {
    "path": "docs/_layouts/post.html",
    "content": "---\nlayout: default\ntheme: jekyll-theme-slate\n---\n<h1>{{ page.title }}</h1>\n<p><b>{{ page.date | date_to_string }}</b> — {{ page.author }}</p>\n\n{{ content }}\n\n<hr>\n\nCopyright © 2026 Mikhail Hogrefe\n"
  },
  {
    "path": "docs/_posts/2022-06-05-1-intro.md",
    "content": "---\nlayout: post\ntitle: Intro\nauthor: Mikhail Hogrefe\n---\n\nWelcome to the Malachite blog!\n\nAfter 5 years and over 600,000 lines of code, I'm finally releasing Malachite, a high-performance\narbitrary-precison arithmetic library for Rust. There's a lot of stuff in this library, and while\nit's well-documented on docs.rs, I think it's a good idea to publish some long-form explanations of\nwhat it can do and what the ideas behind it are.\n"
  },
  {
    "path": "docs/_posts/2022-06-05-2-exhaustive.md",
    "content": "---\nlayout: post\ntitle: Iterators that generate everything, part 1\nauthor: Mikhail Hogrefe\n---\n\n## Iterators\n\nIf you've ever used a modern programming language, you're probably familiar with iterators. For example,\nif you've got a `Vec<u64>` called `xs` in Rust, you can write this:\n```rust\nfor x in &xs {\n    println!(\"{}\", x);\n}\n```\nThis code takes `xs` and produces an iterator, a thing that knows how to spit out elements. Iterators\nare very flexible: you can filter them, map them, zip them, and collect them into concrete\ncollections like `Vec`s or sets. In Haskell, the basic aggregate type, `List`, _is_ an iterator.\n\nIterators are also very general. An iterator doesn't have to be backed by anything in memory. You can\neasily write this:\n```rust\nfor x: u16 in 0..10 {\n    println!(\"{}\", x);\n}\n```\nor even\n```rust\nfor x: u16 in 0.. {\n    println!(\"{}\", x);\n}\n```\n\nThere's something compelling about an iterator that generates EVERY `u16`. If you were testing a\nfunction that takes a `u16`, you could test it on every possible input! If we were dealing with\nwith `u64`s instead, you'd want to cut it off after some number of values using `take`.\n\n# Some simple examples\n\nThe `malachite_base` crate provides lots of exhaustive iterators. Let me show you:\n```rust\nfor b in exhaustive_bools() {\n    println!(\"{}\", b);\n}\n```\n```\nfalse\ntrue\n```\nI mentioned `0..` earlier. Malachite provides an iterator that does the same thing but more\nexplicitly:\n```rust\nfor u in exhaustive_unsigneds::<u16>().take(10) {\n    println!(\"{}\", u);\n}\n```\n```\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n```\nOk, this isn't very interesting so far. How about signed integers?\n```rust\nfor u in exhaustive_signeds::<i16>().take(10) {\n    println!(\"{}\", u);\n}\n```\n```\n0\n1\n-1\n2\n-2\n3\n-3\n4\n-4\n5\n```\nThe philosophy behind exhaustive iterators in Malachite is that simpler values should come first.\nThat's why the `i16`s are sorted by absolute value rather than by their usual order. If you _do_ want\nto start at -65536 and go up from there, you can use\n`primitive_int_increasing_inclusive_range(i16::MIN, i16::MAX)` instead.\n\nBy the way, there are lots of other iterators I'm skipping over, like `exhaustive_nonzero_integers`. You can find them by going\n[here](https://docs.rs/malachite-base/latest/malachite_base/all.html) and Ctrl-F'ing \"exhaustive\".\n\nHow about `char`s?\n```rust\nfor c in exhaustive_chars().take(10) {\n    println!(\"{}\", c);\n}\n```\n```\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\n```\nAgain, these are not in their usual order. Thanks to various historical circumstances, the `char`s\nthat are usually ordered first are mostly unprintable useless characters like \"vertical tab\" and\n\"unit separator\". `exhaustive_chars` pushes these to the back of the line; see its\n[documentation](https://docs.rs/malachite-base/latest/malachite_base/chars/exhaustive/fn.exhaustive_chars.html)\nfor details.\n\n## Combining iterators\nWe've touched on most of Rust's primitive types, except for floats; those are more\ncomplicated and I'll discuss them later. But now, let's see how to create iterators for\ncomposite types, like `Option<i32>`:\n```rust\nfor ox in exhaustive_options(exhaustive_signeds::<i32>()).take(10) {\n    println!(\"{:?}\", ox);\n}\n```\n```\nNone\nSome(0)\nSome(1)\nSome(-1)\nSome(2)\nSome(-2)\nSome(3)\nSome(-3)\nSome(4)\nSome(-4)\n```\nReasonable.\n\nNext, I want to talk about `Union`s. These don't exist in the standard library, so I've defined them in\nMalachite. (Since variadic generics aren't a thing in Rust yet, what I've _actually_\ndefined are `Union2`s and a macro to define unions of higher arity.)\n\nA union (specifically a tagged union, also called a variant or a sum type) is essentially a generic enum. For\nexample, a value of type `Union2<u16, char>` might be `Union2::A(12)` or `Union2::B('d')`.\nIt's usually better to use a purpose-built enum than a union, but it's very handy to have\nexhaustive iterators for unions. If you want to create an exhaustive iterator for a 2-variant enum,\nyou can just do `exhaustive_union2s(...).map(|u| match u { ... })`.\n\nActually, before `exhaustive_union2s`, let me show you `lex_union2s`:\n```rust\nfor b_or_u in lex_union2s(exhaustive_bools(), 1..=3) {\n    println!(\"{}\", b_or_u);\n}\n```\n```\nA(false)\nA(true)\nB(1)\nB(2)\nB(3)\n```\nIt's very simple; it just produces all the values of the first variant, then all the values of\nthe second variant. I've called it `lex` because it returns its elements in lexicographic, or\n\"dictionary\", order (with respect to the order of the input iterators' elements). It's only\nsuitable when the first iterator is short. You don't want to use\n`lex_union2s(exhaustive_unsigneds::<u64>(), ...)` because you'll be waiting forever\nbefore you see the second variant. In general, `exhaustive_union2s` is the better choice:\n```rust\nfor u_or_b in exhaustive_union2s(\n    exhaustive_unsigneds::<u64>(),\n    exhaustive_bools()\n).take(10) {\n    println!(\"{}\", u_or_b);\n}\n```\n```\nA(0),\nB(false),\nA(1),\nB(true),\nA(2),\nA(3),\nA(4),\nA(5),\nA(6),\nA(7),\n```\nand now the `B` variant gets to see the light of day. `exhaustive_union3s`, etc., work in the same\nway, selecting between their variants in a round-robin fashion.\n\n# Intermission\n\nWe haven't gotten to the really interesting bits, which have to do with generating\ntuples (and after that, lists, sets, and floats). I'll talk about those in future posts.\n\n[Part 2: Generating tuples](/2022/07/03/exhaustive)\n"
  },
  {
    "path": "docs/_posts/2022-07-03-exhaustive.md",
    "content": "---\nlayout: post\ntitle: Iterators that generate everything, part 2\nauthor: Mikhail Hogrefe\n---\n\n## Introduction\n\nIn [Part 1](/2022/06/05/2-exhaustive) of this series, I described how Malachite provides iterators that generate all values of a type, or all values satisfying some condition. Now I'm going to show you how to generate tuples.\n\nIt's not immediately obvious how to do this. One thing you might try is generating the tuples in lexicographic order. Malachite lets you do this:\n\n```rust\nfor p in lex_pairs_from_single(exhaustive_unsigneds::<u64>()).take(10) {\n    println!(\"{}\", p);\n}\n```\n```\n(0, 0)\n(0, 1)\n(0, 2)\n(0, 3)\n(0, 4)\n(0, 5)\n(0, 6)\n(0, 7)\n(0, 8)\n(0, 9)\n```\n\n(The \"from_single\" in [`lex_pairs_from_single`](https://docs.rs/malachite-base/latest/malachite_base/tuples/exhaustive/fn.lex_pairs_from_single.html) indicates that both elements of the output pairs come from the same iterator. There's also a [`lex_pairs`](https://docs.rs/malachite-base/latest/malachite_base/tuples/exhaustive/fn.lex_pairs.html) function that accepts two iterators.)\n\nAs you can see, lexicographic generation only makes sense if the input iterator has a small number of elements, like `exhaustive_bools`. It doesn't work so well for `exhaustive_unsigneds::<u64>`, since you'd have to wait forever to get to any pair that doesn't start with 0. But Malachite does provide [`exhaustive_pairs`](https://docs.rs/malachite-base/latest/malachite_base/tuples/exhaustive/fn.exhaustive_pairs.html) and [`exhaustive_pairs_from_single`](https://docs.rs/malachite-base/latest/malachite_base/tuples/exhaustive/fn.exhaustive_pairs_from_single.html), that work well for any input iterators. How do these functions work?\n\n## First attempt: the Cantor pairing function\n\nFor simplicity, let's first consider `exhaustive_pairs_from_single(exhaustive_naturals())`. To think about generating every pair of `Natural`s, it helps to visualize a path through an infinite grid. One such path is this:\n\n<p align=\"center\">\n  <img width=\"300\" src=\"/assets/exhaustive-part-2/cantor-grid.svg\" alt=\"The path defined by the Cantor pairing function\">\n</p>\n\nYou can think of it as first generating (0, 0), whose sum is 0; then (1, 0) and (0, 1), whose sum is 1; then (2, 0), (1, 1), and (0, 2), whose sum is 2; and so on. This path describes a bijection between the indices 0, 1, 2, ..., and all pairs of natural numbers. The opposite direction of this bijection, that takes pairs to indices, is known as the Cantor pairing function.\n\nThis bijection has some nice properties; for example, the function from pairs to indices is a polynomial in the elements of the pair: the pair $$(x, y)$$ corresponds to index $$\\tfrac{1}{2}(x + y)(x + y + 1)$$. We can also look at the two functions from sequence index to the first and second elements of the pairs. These functions look like this:\n\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/exhaustive-part-2/cantor-graph.svg\" alt=\"The inverses of the Cantor pairing function\">\n</p>\n\nAlthough the functions jump around a lot (they have to, since they must evaluate to every natural number infinitely many times), there's a sense in which they are nicely balanced. Both are $$O(\\sqrt n)$$, and if you take evaluate them at a random large input, they're generally about the same size:\n\n<p align=\"center\">\n  <img height=\"150\" src=\"/assets/exhaustive-part-2/cantor-large.svg\" alt=\"The Cantor unpairing of powers of 3\">\n</p>\n\nHowever, it isn't obvious how generalize the Cantor pairing function to triples in a balanced way. The standard way to create a tripling function from a pairing function is $$g(x, y, z) = f(x, f(y, z))$$, but this is no longer balanced. If $$f$$ is the Cantor pairing function, then the three outputs of $$g^{-1}$$ are $$O(\\sqrt n)$$, $$O(\\sqrt[4] n)$$, and $$O(\\sqrt[4]n)$$. Here's what the corresponding table looks like:\n\n<p align=\"center\">\n  <img height=\"150\" src=\"/assets/exhaustive-part-2/cantor-triples-large.svg\" alt=\"An unbalanced Cantor untripling of powers of 3\">\n</p>\n\n## More balance and flexibility with bit interleaving\n\nInstead of the Cantor pairing function, Malachite uses bit interleaving. This idea is not new; it has been described by [Steven Pigeon](https://hbfs.wordpress.com/2011/09/27/pairing-functions/) and others.\n\nTo generate the pairs corresponding to index 0, 1, 2, and so on, first write the indices in binary, with infinitely many leading zeros:\n\n<p align=\"center\">\n  <img height=\"200\" src=\"/assets/exhaustive-part-2/interleave-bits-1.svg\" alt=\"First step in un-interleaving bits\">\n</p>\n\nAnd then distribute the bits of each index into the two slots of the corresponding pair. The even-indexed bits (counting from the right) end up in the second slot, and the odd-indexed bits in the first:\n\n<p align=\"center\">\n  <img height=\"200\" src=\"/assets/exhaustive-part-2/interleave-bits-2.svg\" alt=\"Final steps in un-interleaving bits\">\n</p>\n\nI've color-coded the bits according to which slot they end up in. Malachite keeps track of this using an explicit bit map that looks like $$[1, 0, 1, 0, 1, 0, \\ldots]$$, indicating that bit 0 goes to slot 1, bit 1 goes to slot 0, bit 2 goes to slot 1, and so on.\n\nThis is how this method walks through the grid of pairs of natural numbers:\n\n<p align=\"center\">\n  <img width=\"400\" src=\"/assets/exhaustive-part-2/interleave-grid.svg\" alt=\"The path defined by the bit-interleaving pairing function\">\n</p>\n\nThis path is called a [Z-order curve](https://en.wikipedia.org/wiki/Z-order_curve), although with this choice of coordinates it looks like it's made up of N's rather than Z's.\n\nAnd here's what the functions from the index to the first and second elements of the pairs look like:\n\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/exhaustive-part-2/interleave-pairs-graph.svg\" alt=\"The inverses of the bit interleaving pairing function\">\n</p>\n\nLike the inverses of the Cantor pairing function, these functions are balanced in the sense that both are $$O(\\sqrt n)$$, although here the first element lags noticeably behind the second. And here's a table showing them evaluated at large indices:\n\n<p align=\"center\">\n  <img height=\"150\" src=\"/assets/exhaustive-part-2/interleave-large.svg\" alt=\"Bit un-interleaving of powers of 3\">\n</p>\n\nThe advantage that this approach has over the Cantor pairing approach is flexibility. We can generate triples in a balanced way simply by changing the bit map to $$[2, 1, 0, 2, 1, 0, 2, 1, 0, \\ldots]$$:\n\n<p align=\"center\">\n  <img height=\"400\" src=\"/assets/exhaustive-part-2/interleave-triples-bits.svg\" alt=\"un-interleaving bits to form triples\">\n</p>\n\nHere are the three functions from index to output. They each are $$O(\\sqrt[3]n)$$.\n\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/exhaustive-part-2/interleave-triples-graph.svg\" alt=\"The inverses of the bit interleaving tripling function\">\n</p>\n\nHere they are evaluated at large indices:\n\n<p align=\"center\">\n  <img height=\"150\" src=\"/assets/exhaustive-part-2/interleave-triples-large.svg\" alt=\"Bit un-interleaving of powers of 3 to form triples\">\n</p>\n\nThis generalizes straightforwardly to $$k$$-tuples for any $$k$$. Notice that the first $$2^{ka}$$ tuples are all the tuples with elements less than $$2^a$$.\n\n## Customized balancing\n\nBy changing the bit map further, we can deliberately unbalance the tuples. For example, if we want to produce pairs where the second element of the pair is $$O(\\sqrt[3]n)$$ and the first element is $$O(n^{2/3})$$, we can use the bit map $$[1, 0, 0, 1, 0, 0, 1, 0, 0, \\ldots]$$. If we want the the first element to be exponentially larger than the second, we can use $$[0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, \\ldots]$$, where there is a 1 at the $$2^i$$th position and 0 elsewhere.\n\nTo actually generate the pair sequences in the two preceding examples, you can use\n\n```rust\nexhaustive_pairs_custom_output(\n    exhaustive_naturals(),\n    exhaustive_naturals(),\n    BitDistributorOutputType::normal(2),\n    BitDistributorOutputType::normal(1),\n)\n```\nand\n```rust\nexhaustive_pairs_custom_output(\n    exhaustive_naturals(),\n    exhaustive_naturals(),\n    BitDistributorOutputType::normal(1),\n    BitDistributorOutputType::tiny(),\n)\n```\nrespectively. See the documentation of [exhaustive_pairs_custom_output](https://docs.rs/malachite-base/0.2.4/malachite_base/tuples/exhaustive/fn.exhaustive_pairs_custom_output.html) and [BitDistributorOutputType](https://docs.rs/malachite-base/latest/malachite_base/iterators/bit_distributor/struct.BitDistributorOutputType.html) for more details.\n\n## Generating tuples of other iterators\n\nSo far I've only talked about generating tuples of `Natural`s. What about tuples of elements from some other iterator `xs`? If `xs` is infinitely long, then the process is straightforward. Instead of generating, say, (8, 3), generate the pair consisting of the 8th and 3rd elements of `xs` (indexing from 0, of course). Internally, Malachite uses a structure called [`IteratorCache`](https://docs.rs/malachite-base/latest/malachite_base/iterators/iterator_cache/struct.IteratorCache.html), which stores the values produced by `xs` into a `Vec` for easy access.\n\nFor example, here's how to generate all pairs of the characters `'a'` to `'z'` (in this case, there are additional complications due to `xs` being finite, but we'll address those in a moment):\n\n```rust\nfor p in exhaustive_pairs_from_single('a'..='z').take(10) {\n    println!(\"{:?}\", p);\n}\n```\n```\n(a, a)\n(a, b)\n(b, a)\n(b, b)\n(a, c)\n(a, d)\n(b, c)\n(b, d)\n(c, a)\n(c, b)\n```\n\n## Dealing with finite iterators\n\nFinite iterators are a bit of a problem. You can't generate the (8th, 3rd) pair if the input iterator has no 8th element. To take an extreme case, consider `exhaustive_pairs(exhaustive_naturals(), exhaustive_bools())`. There are only two bools, so any index pair $$(i, j)$$ where $$j \\geq 2$$ can't be used for indexing. Here's our grid of indices again, with valid indices green and invalid indices red:\n\n<p align=\"center\">\n  <img width=\"400\" src=\"/assets/exhaustive-part-2/interleave-grid-filtered.svg\" alt=\"Valid indices when one iterator has length 2\">\n</p>\n\nMy original solution was just to skip over the invalid indices, with a bit of extra logic to determine when both input iterators are finished. This was very slow: out of the first $$n$$ pairs, only about $$2 \\sqrt n$$ are valid, and the situation gets worse for higher-arity tuples. So what does `exhaustive_pairs` do instead?\n\nAgain, we can leverage the bit map! This scenario is actually what led me to make the bit map an explicit object in memory. What `exhaustive_pairs` does is notice when one of its iterators has completed, and then adjusts the bit map on the fly. In this particular case, it realizes that since `exhaustive_bools` produces two elements, it only needs a single bit for indexing; and then bit map is modified from $$[1, 0, 1, 0, 1, 0, 1, 0, \\ldots]$$, to $$[1, 0, 0, 0, 0, 0, 0, \\ldots]$$. In general, modifying the bit map on the fly is dangerous because you might end up repeating some output that you've already produced, but `exhaustive_pairs` only modifies the part of the map that hasn't been used yet.\n\nIf the finite iterator's length is a power of 2, as it was in this example, then updating the bit map results in all indices being valid. If it isn't a power of 2, then some indices will remain invalid; for example, in `exhaustive_pairs(exhaustive_naturals(), 0..6)` the bit map will be updated from $$[1, 0, 1, 0, 1, 0, 1, 0, \\ldots]$$, to $$[1, 0, 1, 0, 1, 0, 0, 0, \\ldots]$$, so that the index of the second pair slot will vary from 0 to 7, and only $$3/4$$ of all the indices will be valid. But this is a constant proportion; it's much better than the earlier example where only $$(2 \\sqrt n)/n$$ were valid.\n\n(In this particular case, the best thing to do would be to use `lex_pairs(exhaustive_naturals(), exhaustive_bools())`, which would produce (0, false), (0, true), (1, false), (1, true), and so on. But in general, when you call `exhaustive_pairs(xs, ys)` you might not know ahead of time whether `ys` is short, long, or infinite.)\n\nIn the next part, I will discuss how Malachite generates all `Vec`s containing elements from some iterator.\n"
  },
  {
    "path": "docs/_posts/2022-07-30-denominators.md",
    "content": "---\nlayout: post\ntitle: Which denominators does an interval contain?\nauthor: Mikhail Hogrefe\n---\n\n## Introduction\n\nIn this post I'm going to talk a bit about a problem that came up when I was figuring out how to generate rational numbers exhaustively. Malachite generates all positive rationals using the [Calkin-Wilf sequence](https://en.wikipedia.org/wiki/Calkin%E2%80%93Wilf_tree#Breadth_first_traversal):\n\n1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, 4, 1/5, 5/4, 4/7, 7/3, 3/8, ...,\n\nand by manipulating this sequence a bit it can also generate all rationals, all negative rationals, and so on. How about generating all rationals in a specified interval? This has many uses: for example, when testing conversion from rationals to floats, we might want to generate rationals that fall into the 64-bit subnormal float range.\n\nFor the remainder of this post I'm going to consider closed intervals only.\n\n## First try\n\nThe most straightforward approach is this:\n1. Generate all rationals in $$[0, 1]$$.\n2. Scale those rationals to bring them into the target interval.\n\nStep 1 is easy: we can generate 0 and 1, and then select every other rational from the above sequence:\n\n0, 1, 1/2, 1/3, 2/3, 1/4, 3/5, 2/5, 3/4, 1/5, 4/7, 3/8, 5/7, 2/7, 5/8, 3/7, 4/5, 1/6, 5/9, 4/11, ... .\n\nStep 2 is also easy. If our target interval is $$[a, b]$$, we transform each rational using $$x \\to (b - a)x + a$$. For example, here are the rationals in $$[1/3, 1/2]$$:\n\n1/3, 1/2, 5/12, 7/18, 4/9, 3/8, 13/30, 2/5, 11/24, 11/30, 3/7, 19/48, 19/42, 8/21, 7/16, 17/42, 7/15, 13/36, 23/54, 13/33, ... .\n\nFor a simple interval this approach works fine. But what if we generate intervals in $$[268876667/98914198, 245850922/78256779]$$? The endpoints of this interval are the simplest rationals that round to the best 64-bit float representations of $$e$$ and $$\\pi$$, respectively. Our algorithm gives us\n\n268876667/98914198, 245850922/78256779, 45359568684866149/15481413065696484, 33200495296270871/11611059799272363, 69677715462056705/23222119598544726, 87442412500217335/30962826131392968, 19172880691153809/6450588777373535, 111760559277407891/38703532664241210, 31331954079749087/10320942043797656, 54241917203946464/19351766332120605, ... .\n\nThis is not so nice. Our interval contains nice rationals like 3, 11/4, 14/5, and 17/6, but they are nowhere to be seen (they will appear eventually, but much later in the sequence). We want an algorithm that gives preferential treatment to rationals with small denominators. Here's what Malachite does:\n\nAn improved algorithm\n---------------------\n\nMalachite's algorithm needs to be able to do three things:\n1. Determine which denominators occur in an interval;\n2. Generate all rationals with a given denominator in an interval;\n3. Given infinitely many iterators, each generating rationals with different denominators, interleave the iterators into a single iterator.\n\nNumber 2 is easy to do and not very interesting. You can see the details [here](https://docs.rs/malachite-q/latest/malachite_q/exhaustive/fn.exhaustive_rationals_with_denominator_inclusive_range.html). Number 3 is more interesting, but already solved. I'll post about it in the future, but for now I'll just leave a link to the relevant function [here](https://docs.rs/malachite-base/latest/malachite_base/tuples/exhaustive/fn.exhaustive_dependent_pairs.html). That leaves number 1.\n\n## Finding all denominators in an interval\n\nLet's define the problem more explicitly.\n\n**Problem:** Given a closed interval $$[a, b]$$ with $$a, b \\in \\mathbb{Q}$$ and $$a < b$$, for which $$d \\in \\N^+$$ does there exist an $$n \\in \\Z$$ with $$\\gcd(n, d) = 1$$ and $$n/d \\in [a, b]$$?\n\nThe simplest algorithm is to consider each denominator 1, 2, 3, ... in turn and determine whether some rational with the denominator exists in the interval. This works fine unless the diameter $$b - a$$ is very small. If the interval is $$[0, 2^{-100}]$$, it would take a very long time to find an admissible denominator greater than 1.\n\nLuckily, Malachite knows how to find the simplest rational in an interval (\"simplest\" meaning \"having the lowest denominator\"). It uses the continued fractions of the endpoints and follows the algorithm sketched out [here](https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations). This gives us the lowest denominator in the interval in $$O(n^2 \\log n \\log\\log n)$$ time, $$n$$ being the maximum bit-length of the numerators and denominators of both endpoints. Once we've found the lowest denominator, we can find the $$m$$ rationals with that denominator in $$[a, b]$$ and then partition $$[a, b]$$ into $$m + 1$$ smaller intervals. Then we can repeat the process to get the second-lowest denominator, and so on.\n\nThis algorithm is efficient enough to be useful, but it's still a bit cumbersome. Our intuition suggests that $$[a, b]$$ contains every denominator in $$\\N^+$$ except for finitely many exceptions: in other words, that for every interval $$[a, b]$$ there exists a threshold $$D$$ such that for all $$d \\geq D$$, $$[a, b]$$ contains a rational with denominator $$d$$. If we knew what $$D$$ was, then we could find start finding denominators using our cumbersome continued-fraction method, but once we reached $$D$$ we could simply generate $$D, D + 1, D + 2, \\ldots$$ forever.\n\nFor the remainder of this post, I'll prove that a $$D$$ exists for any interval and give an efficient algorithm for finding it (though it generally won't be the lowest possible $$D$$).\n\n## The relationship between an interval's diameter and the denominators it contains\n\nLet $$s = b - a$$ be the diameter of $$[a, b]$$. If $$s \\geq 1$$, then we can take $$D = 1$$: $$[a, b]$$ contains all denominators in $$\\N^+$$. (For any denominator $$d$$, $$k + 1/d$$ is in $$[a, b]$$ for some integer $$k$$.)\n\nWhat if $$s < 1$$? We might think that if $$s \\geq 1/d$$ then $$[a, b]$$ must contain some rational with denominator $$d$$, but this is not the case. For example, an interval with $$s > 1/6$$ might not contain any sixths:\n\n<p align=\"center\">\n  <img width=\"500\" src=\"/assets/denominators/sixths.svg\" alt=\"The largest gap between sixths\">\n</p>\n\nThe largest gap between sixths is $$2/3$$. Let's define $$f(d)$$ to be the largest gap between fractions with denominator $$d$$:\n\n<p align=\"center\">\n  <img width=\"600\" src=\"/assets/denominators/gaps.svg\" alt=\"The largest gap between rationals with denominators 1 through 10\">\n</p>\n\n<p align=\"center\">\n  <img width=\"600\" src=\"/assets/denominators/gap-graph.svg\" alt=\"A graph of the largest-gap function\">\n</p>\n\nAny interval with $$s \\geq f(d)$$ is, by definition, guaranteed to contain some rational with denominator $$d$$. If $$f$$ were monotonically decreasing, then we could use that to prove that $$D$$ exists. We'd simply need to find a $$D$$ such that $$f(D) \\leq s$$, and then any $$f(d)$$ for $$d \\geq D$$ would also be less than or equal to $$s$$. But $$f$$ does not monotonically decrease.\n\n## The Jacobsthal function and primorials\n\nI couldn't find any reference to $$f(n)$$ in the literature, but fortunately $$g(n) = n f(n)$$ has been studied: it's called the [Jacobsthal function](http://oeis.org/A048669) (not to be confused with the Jacobsthal numbers, which are something unrelated). $$g(n)$$ is the size of the maximal gap in the list of all integers relatively prime to $$n$$.\n\n<p align=\"center\">\n  <img width=\"600\" src=\"/assets/denominators/j-graph.svg\" alt=\"A graph of the Jacobsthal function\">\n</p>\n\nWe can make use of the bound ([^1]) $$g(n) \\leq 2^w$$, where $$w$$ is the number of distinct prime factors of $$n$$.\n\n| constraint on $$n$$   | bound on $$w$$ | bound on $$g$$   | bound on $$f$$       |\n|-----------------------|----------------|------------------|----------------------|\n| $$1 \\leq n < 2$$      | $$w \\leq 0$$   | $$g(n) \\leq 1$$  | $$f(n) \\leq 1$$      |\n| $$2 \\leq n < 6$$      | $$w \\leq 1$$   | $$g(n) \\leq 2$$  | $$f(n) \\leq 1$$      |\n| $$6 \\leq n < 30$$     | $$w \\leq 2$$   | $$g(n) \\leq 4$$  | $$f(n) \\leq 2/3$$    |\n| $$30 \\leq n < 210$$   | $$w \\leq 3$$   | $$g(n) \\leq 8$$  | $$f(n) \\leq 4/15$$   |\n| $$210 \\leq n < 2310$$ | $$w \\leq 4$$   | $$g(n) \\leq 16$$ | $$f(n)  \\leq 8/105$$ |\n| $$\\ldots$$            | $$\\ldots$$     | $$\\ldots$$       | $$\\ldots$$           |\n\nThe sequence in the leftmost column, 1, 2, 6, 30, 210, ..., is the sequence of [primorials](https://en.wikipedia.org/wiki/Primorial): they are the products of the first 0, 1, 2, ... primes and therefore the smallest integers with 0, 1, 2, ... distinct prime factors. The $$n$$th primorial is denoted $$p_n\\#$$. The sequence of bounds in the rightmost column, 1, 1, 2/3, 4/15, 8/105, ... is $$2^n/p_n\\#$$ and is weakly monotonically decreasing. This allows us to construct a weakly monotonically decreasing function $$h$$ that bounds $$f$$ from above:\n\n$$h(n) = 2^k/p_k\\# \\ \\text{where} \\ p_k\\# \\leq n < p_{k+1}\\#$$.\n\nHere are $$f$$ and $$h$$ plotted together:\n\n<p align=\"center\">\n  <img width=\"600\" src=\"/assets/denominators/gap-and-bound-graph.svg\" alt=\"A graph of the largest-gap function and an upper bound\">\n</p>\n\n$$h$$ is not a very tight bound. With more careful analysis, we could come up with a better one, perhaps by interpolating between the primorials or by making use of the bound ([^1]) $$g(h) \\leq 2k^{2+2e\\log k}$$.\n\nWe now have an algorithm or determining a threshold $$D$$ for an interval $$[a, b]$$:\n1. Find the diameter $$s = b - a$$.\n2. Compute the sequence $$2^n/p_n\\#$$ until it is less than or equal to $$s$$: the sequence decreases as $$O((2/n)^n)$$, so this step doesn't take long.\n3. Let $$n$$ be the value at which $$2^n/p_n\\# \\leq s$$. Then take $$D$$ to be $$p_n\\#$$.\n\n## Results\n\nLet's go back to our example interval, $$[268876667/98914198, 245850922/78256779]$$. Its diameter is about 0.42, so its $$D$$ is 30, meaning that it's guaranteed to contain all denominators greater than or equal to 30. This threshold is low enough that we can just test all the denominators 1 through 29, and after doing this we find that the denominators 1, 4, and all denominators greater than 4 are present.\n\nMalachite generates the rationals contained in the interval in this order:\n\n3, 11/4, 14/5, 20/7, 17/6, 23/8, 25/8, 30/11, 25/9, 29/10, 26/9, 31/11, 28/9, 31/10, 32/11, 41/15, 34/11, 35/12, 37/12, 39/14, ... .\n\n[^1]: Hans-Joachim Kanold, *Über eine zahlentheoretische Funktion von Jacobsthal*, Mathematische Annalen 170.4 (1967): 314-326\n"
  },
  {
    "path": "docs/assets/denominators/gap-and-bound-graph.asy",
    "content": "import graph;\n\nsize(600,400,IgnoreAspect);\n\nint gcd(int a, int b) {\n  while (b != 0) {\n    int t = b;\n    b = a % b;\n    a = t;\n  }\n  return a;\n}\n\nint jacobsthal(int n) {\n  int previous = 0;\n  int largest_gap = 0;\n  for (int i = 0; i <= 2 * n; ++i) {\n    if (gcd(i, n) == 1) {\n      int gap = i - previous;\n      if (gap > largest_gap) {\n        largest_gap = gap;\n      }\n      previous = i;\n    }\n  }\n  return largest_gap;\n}\n\nscale(Linear,Log);\nreal[] x={};\nreal[] y1={};\nreal[] y2={};\nfor (int i = 1; i < 500; ++i) {\n  x.push(i);\n  y1.push(jacobsthal(i)/i);\n  if (i < 6) {\n    y2.push(1);\n  } else if (i < 30) {\n    y2.push(2/3);\n  } else if (i < 210) {\n    y2.push(4/15);\n  } else if (i < 2310) {\n    y2.push(8/105);\n  }\n}\n\ndraw(graph(x,y1),black,\"$f(n)$\");\ndraw(graph(x,y2),red,\"$h(n)$\");\n\nxaxis(BottomTop,LeftTicks);\nyaxis(LeftRight, RightTicks);\nadd(legend(),point(NW),(50,-25),UnFill);\n"
  },
  {
    "path": "docs/assets/denominators/gap-graph.asy",
    "content": "import graph;\n\nsize(600,400,IgnoreAspect);\n\nint gcd(int a, int b) {\n  while (b != 0) {\n    int t = b;\n    b = a % b;\n    a = t;\n  }\n  return a;\n}\n\nint jacobsthal(int n) {\n  int previous = 0;\n  int largest_gap = 0;\n  for (int i = 0; i <= 2 * n; ++i) {\n    if (gcd(i, n) == 1) {\n      int gap = i - previous;\n      if (gap > largest_gap) {\n        largest_gap = gap;\n      }\n      previous = i;\n    }\n  }\n  return largest_gap;\n}\n\nscale(Linear,Log);\nreal[] x={};\nreal[] y={};\nfor (int i = 1; i < 500; ++i) {\n  x.push(i);\n  y.push(jacobsthal(i)/i);\n}\n\ndraw(graph(x,y),black,\"$f(n)$\");\n\nxaxis(BottomTop,LeftTicks);\nyaxis(LeftRight, RightTicks);\nadd(legend(),point(NW),(25,-25),UnFill);\n"
  },
  {
    "path": "docs/assets/denominators/gaps.asy",
    "content": "import graph;\nsize(15cm);\npen small=fontcommand(\"\\scriptsize\");\n\nint gcd(int a, int b) {\n  while (b != 0) {\n    int t = b;\n    b = a % b;\n    a = t;\n  }\n  return a;\n}\n\nint jacobsthal(int n) {\n  int previous = 0;\n  int largest_gap = 0;\n  for (int i = 0; i <= 2 * n; ++i) {\n    if (gcd(i, n) == 1) {\n      int gap = i - previous;\n      if (gap > largest_gap) {\n        largest_gap = gap;\n      }\n      previous = i;\n    }\n  }\n  return largest_gap;\n}\n\nstring gap_function(int d) {\n  int n = jacobsthal(d);\n  int g = gcd(n, d);\n  n = n#g;\n  d = d#g;\n  if (d == 1) {\n    return string(n);\n  } else {\n    return string(n) + \"/\" + string(d);\n  }\n}\n\nvoid draw_rationals(int d, real offset) {\n  guide gaxis=(0,offset)--(20,offset);\n  draw(gaxis);\n  for(int i = 0; i < 3; ++i){\n    tick(relpoint(gaxis,i/2),-plain.I*reldir(gaxis,i/2),ticksize*2);\n  }\n  for(int i = 0; i < 20; ++i){\n    tick(relpoint(gaxis,i/20),-plain.I*reldir(gaxis,i/20),ticksize);\n  }\n  label(\"$0$\",relpoint(gaxis,0),-3*plain.I*reldir(gaxis,0));\n  label(\"$1$\",relpoint(gaxis,0.5),-3*plain.I*reldir(gaxis,0.5));\n  label(\"$2$\",relpoint(gaxis,1),-3*plain.I*reldir(gaxis,1));\n  \n  for (int i= 0; i <= 2 * d; ++i) {\n    if (gcd(i, d) == 1) {\n      dot((i*10/d, offset), red);\n      if (d != 1) {\n        label(\"$\" + string(i) + \"/\" + string(d) + \"$\",relpoint(gaxis,i/(2*d)),-2*plain.I*reldir(gaxis,0.5), red+small);\n      }\n    }\n  }\n  \n  label(\"$f(\" + string(d) + \") = \" + gap_function(d) + \"$\",(24.5, offset), align=LeftSide);\n}\n\nreal offset = 0;\nfor (int d = 1; d <= 10; ++d) {\n  draw_rationals(d, offset);\n    offset -= 2;\n}\n\n// Force bottom margin to expand\ndraw(box((-1,1),(-0.5, -20)),white);\n"
  },
  {
    "path": "docs/assets/denominators/j-graph.asy",
    "content": "import graph;\n\nsize(600,400,IgnoreAspect);\n\nint gcd(int a, int b) {\n  while (b != 0) {\n    int t = b;\n    b = a % b;\n    a = t;\n  }\n  return a;\n}\n\nint jacobsthal(int n) {\n  int previous = 0;\n  int largest_gap = 0;\n  for (int i = 0; i <= 2 * n; ++i) {\n    if (gcd(i, n) == 1) {\n      int gap = i - previous;\n      if (gap > largest_gap) {\n        largest_gap = gap;\n      }\n      previous = i;\n    }\n  }\n  return largest_gap;\n}\n\n//scale(Linear,Log);\nreal[] x={};\nreal[] y={};\nfor (int i = 1; i < 500; ++i) {\n  x.push(i);\n  y.push(jacobsthal(i));\n}\n\ndraw(graph(x,y),black,\"$g(n)$\");\n\nxaxis(BottomTop,LeftTicks);\nyaxis(LeftRight, RightTicks);\nadd(legend(),point(NW),(25,-25),UnFill);\n"
  },
  {
    "path": "docs/assets/denominators/sixths.asy",
    "content": "import graph;\nsize(10cm);\nguide gaxis=(0,0)--(20,0);\npen small=fontcommand(\"\\footnotesize\");\ndraw(gaxis);\n\nfor(int i = 0; i < 3; ++i){\n  tick(relpoint(gaxis,i/2),-plain.I*reldir(gaxis,i/2),ticksize*2);\n}\nfor(int i = 0; i < 20; ++i){\n  tick(relpoint(gaxis,i/20),-plain.I*reldir(gaxis,i/20),ticksize);\n}\nlabel(\"$0$\",relpoint(gaxis,0),-3*plain.I*reldir(gaxis,0));\nlabel(\"$1$\",relpoint(gaxis,0.5),-3*plain.I*reldir(gaxis,0.5));\nlabel(\"$2$\",relpoint(gaxis,1),-3*plain.I*reldir(gaxis,1));\n\nint gcd(int a, int b) {\n  while (b != 0) {\n    int t = b;\n    b = a % b;\n    a = t;\n  }\n  return a;\n}\n\nfor (int i= 0; i <= 12; ++i) {\n  if (gcd(i, 6) == 1) {\n    dot((i*10/6, 0), red);\n    label(\"$\" + string(i) + \"/6$\",relpoint(gaxis,i/(2*6)),-2*plain.I*reldir(gaxis,0.5), red+small);\n  }\n}\n\ndraw((1.8, 0.2)--(1.8, -0.2),blue+linewidth(0.5mm));\ndraw((1.8, 0)--(8.2, 0),blue+linewidth(0.5mm));\ndraw((8.2, 0.2)--(8.2, -0.2),blue+linewidth(0.5mm));\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/cantor-graph.asy",
    "content": "import graph;\n\nsize(600,400,IgnoreAspect);\n\npair unpair(int i) {\n  int j = 0;\n  int r = i;\n  while (r >= j) {\n    r -= j;\n    j += 1;\n  }\n  j -= 1;\n  return (j - r, r);\n}\n\nreal[] x={};\nreal[] y1={};\nreal[] y2={};\nfor (int i = 0; i < 500; ++i) {\n  x.push(i);\n  y1.push(unpair(i).x);\n  y2.push(unpair(i).y);\n}\nreal[] z=sqrt(2x);\n\ndraw(graph(x,y1),red,\"first element\");\ndraw(graph(x,y2),blue,\"second element\");\ndraw(graph(x,z),black,\"$\\sqrt{2x}$\");\n\nxaxis(BottomTop,LeftTicks);\nyaxis(LeftRight, RightTicks);\nadd(legend(),point(NW),(25,-25),UnFill);\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/cantor-grid.asy",
    "content": "unitsize(1cm);\nint size = 5;\nfor (int x = 0; x < size; ++x) {\n  for (int y = 0; y < size; ++y) {\n    dot((x, y));\n  }\n}\n\npair unpair(int i) {\n  int j = 0;\n  int r = i;\n  while (r >= j) {\n    r -= j;\n    j += 1;\n  }\n  j -= 1;\n  return (j - r, r);\n}\n\npath boundary = box((-0.5, -0.5), (size + 0.5, size + 0.5));\npair previous = (0, 0);\nfor (int i = 1; i < 15; ++i) {\n  pair next = unpair(i);\n  bool previous_in_range = previous.x < size && previous.y < size;\n  bool next_in_range = next.x < size && next.y < size;\n  if (previous_in_range && next_in_range) {\n      draw(previous -- next, arrow=Arrow, gray);\n  } else {\n      draw(previous -- next, gray+Dotted());\n  }\n  previous = next;\n}\nclip(boundary);"
  },
  {
    "path": "docs/assets/exhaustive-part-2/cantor-large.tex",
    "content": "\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\n\\begin{document}\n\n\\begin{equation*}\n\\begin{split}\n3^{20}  &\\rightarrow (33123, 50384) \\\\\n3^{40}  &\\rightarrow (2293673435, 2637384353) \\\\\n3^{60}  &\\rightarrow (158808187801698, 132365843578904) \\\\\n3^{80}  &\\rightarrow (12105097562203174223, 5088437816790055004) \\\\\n3^{100}  &\\rightarrow (416864661676079910029691, 598396408918091282666529) \\\\\n\\end{split}\n\\end{equation*}\n\n\\end{document}"
  },
  {
    "path": "docs/assets/exhaustive-part-2/cantor-triples-large.tex",
    "content": "\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\n\\begin{document}\n\n\\begin{equation*}\n\\begin{split}\n3^{20}  &\\rightarrow (33123, 298, 18) \\\\\n3^{40}  &\\rightarrow (2293673435, 7475, 65152) \\\\\n3^{60}  &\\rightarrow (158808187801698, 13757728, 2512848) \\\\\n3^{80}  &\\rightarrow (12105097562203174223, 2695483339, 494638230) \\\\\n3^{100}  &\\rightarrow (416864661676079910029691, 871747234874, 222233029040) \\\\\n\\end{split}\n\\end{equation*}\n\n\\end{document}\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-bits-1.tex",
    "content": "\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\n\\begin{document}\n\n\\begin{tabular}{rcr}\n0 & $\\rightarrow$ & \\ldots 000000 \\\\\n1 & $\\rightarrow$ & \\ldots 000001 \\\\\n2 & $\\rightarrow$ & \\ldots 000010 \\\\\n3 & $\\rightarrow$ & \\ldots 000011 \\\\\n4 & $\\rightarrow$ & \\ldots 000100 \\\\\n5 & $\\rightarrow$ & \\ldots 000101 \\\\\n6 & $\\rightarrow$ & \\ldots 000110 \\\\\n7 & $\\rightarrow$ & \\ldots 000111 \\\\\n\\end{tabular}\n\n\\end{document}\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-bits-2.tex",
    "content": "\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\\usepackage{xcolor}\n\n\\begin{document}\n\n\\begin{tabular}{rcrcrcr}\n0 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}0\\color{red}0\\color{blue}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00000 \\color{black})$ & $\\rightarrow$ & $(0, 0)$ \\\\\n1 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}0\\color{red}0\\color{blue}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00001 \\color{black})$ & $\\rightarrow$ & $(0, 1)$ \\\\\n2 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}0\\color{red}1\\color{blue}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00000 \\color{black})$ & $\\rightarrow$ & $(1, 0)$ \\\\\n3 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}0\\color{red}1\\color{blue}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00001 \\color{black})$ & $\\rightarrow$ & $(1, 1)$ \\\\\n4 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}1\\color{red}0\\color{blue}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00010 \\color{black})$ & $\\rightarrow$ & $(0, 2)$ \\\\\n5 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}1\\color{red}0\\color{blue}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00011 \\color{black})$ & $\\rightarrow$ & $(0, 3)$ \\\\\n6 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}1\\color{red}1\\color{blue}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00010 \\color{black})$ & $\\rightarrow$ & $(1, 2)$ \\\\\n7 & $\\rightarrow$ & \\ldots \\color{red}0\\color{blue}0\\color{red}0\\color{blue}1\\color{red}1\\color{blue}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00011 \\color{black})$ & $\\rightarrow$ & $(1, 3)$ \\\\\n\\end{tabular}\n\n\\end{document}\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-grid-filtered.asy",
    "content": "unitsize(1cm);\nint size = 8;\nfor (int x = 0; x < size; ++x) {\n  for (int y = 0; y < size; ++y) {\n    if (y < 2) {\n    \tdot((x, y), green);\n    } else {\n        dot((x, y), red);\n    }\n  }\n}\n\npair unpair(int i) {\n  int x = 0;\n  int y = 0;\n  bool on_x = false;\n  int out_mask = 1;\n  while (i != 0) {\n    if (i % 2 != 0) {\n      if (on_x) {\n        x += out_mask;\n      } else {\n        y += out_mask;\n      }\n    }\n    if (on_x) {\n      on_x = false;\n      out_mask *= 2;\n    } else {\n      on_x = true;\n    }\n    i #= 2;\n  }\n  return (x, y);\n}\n\npath boundary = box((-0.5, -0.5), (size + 0.5, size + 0.5));\npair previous = (0, 0);\nfor (int i = 1; i < size * size; ++i) {\n  pair next = unpair(i);\n  bool previous_in_range = previous.x <= size && previous.y <= size;\n  bool next_in_range = next.x <= size && next.y <= size;\n  if (previous_in_range && next_in_range) {\n      draw(previous -- next, arrow=Arrow, gray);\n  } else {\n      draw(previous -- next, gray+Dotted());\n  }\n  previous = next;\n}\nclip(boundary);"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-grid.asy",
    "content": "unitsize(1cm);\nint size = 8;\nfor (int x = 0; x < size; ++x) {\n  for (int y = 0; y < size; ++y) {\n    dot((x, y));\n  }\n}\n\npair unpair(int i) {\n  int x = 0;\n  int y = 0;\n  bool on_x = false;\n  int out_mask = 1;\n  while (i != 0) {\n    if (i % 2 != 0) {\n      if (on_x) {\n        x += out_mask;\n      } else {\n        y += out_mask;\n      }\n    }\n    if (on_x) {\n      on_x = false;\n      out_mask *= 2;\n    } else {\n      on_x = true;\n    }\n    i #= 2;\n  }\n  return (x, y);\n}\n\npath boundary = box((-0.5, -0.5), (size + 0.5, size + 0.5));\npair previous = (0, 0);\nfor (int i = 1; i < size * size; ++i) {\n  pair next = unpair(i);\n  bool previous_in_range = previous.x <= size && previous.y <= size;\n  bool next_in_range = next.x <= size && next.y <= size;\n  if (previous_in_range && next_in_range) {\n      draw(previous -- next, arrow=Arrow, gray);\n  } else {\n      draw(previous -- next, gray+Dotted());\n  }\n  previous = next;\n}\nclip(boundary);"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-large.tex",
    "content": "\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\n\\begin{document}\n\n\\begin{equation*}\n\\begin{split}\n3^{20}  &\\rightarrow (47160, 48725) \\\\\n3^{40}  &\\rightarrow (4005651428, 74192769) \\\\\n3^{60}  &\\rightarrow (191657527975116, 14476912773621) \\\\\n3^{80}  &\\rightarrow (8489200491033962112, 13032031964488297961) \\\\\n3^{100}  &\\rightarrow (231900172002858385847832, 957915753008438345446493) \\\\\n\\end{split}\n\\end{equation*}\n\n\\end{document}\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-pairs-graph.asy",
    "content": "import graph;\n\nsize(600,400,IgnoreAspect);\n\npair unpair(int i) {\n  int x = 0;\n  int y = 0;\n  bool on_x = false;\n  int out_mask = 1;\n  while (i != 0) {\n    if (i % 2 != 0) {\n      if (on_x) {\n        x += out_mask;\n      } else {\n        y += out_mask;\n      }\n    }\n    if (on_x) {\n      on_x = false;\n      out_mask *= 2;\n    } else {\n      on_x = true;\n    }\n    i #= 2;\n  }\n  return (x, y);\n}\n\nreal[] x={};\nreal[] y1={};\nreal[] y2={};\nfor (int i = 0; i < 10000; ++i) {\n  x.push(i);\n  y1.push(unpair(i).x);\n  y2.push(unpair(i).y);\n}\nreal[] z=sqrt(3*x);\n\ndraw(graph(x,y1),red,\"first element\");\ndraw(graph(x,y2),blue,\"second element\");\ndraw(graph(x,z),black,\"$\\sqrt{3x}$\");\n\nxaxis(BottomTop,LeftTicks);\nyaxis(LeftRight, RightTicks);\nadd(legend(),point(NW),(25,-25),UnFill);\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-triples-bits.tex",
    "content": "\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\\usepackage{xcolor}\n\n\\begin{document}\n\n\\begin{tabular}{rcrcrcr}\n0 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}0\\color{blue}0\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00000 \\color{black})$ & $\\rightarrow$ & $(0, 0, 0)$ \\\\\n1 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}0\\color{blue}0\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00001 \\color{black})$ & $\\rightarrow$ & $(0, 0, 1)$ \\\\\n2 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}0\\color{blue}1\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00000 \\color{black})$ & $\\rightarrow$ & $(0, 1, 0)$ \\\\\n3 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}0\\color{blue}1\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00001 \\color{black})$ & $\\rightarrow$ & $(0, 1, 1)$ \\\\\n4 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}1\\color{blue}0\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00000 \\color{black})$ & $\\rightarrow$ & $(1, 0, 0)$ \\\\\n5 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}1\\color{blue}0\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00001 \\color{black})$ & $\\rightarrow$ & $(1, 0, 1)$ \\\\\n6 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}1\\color{blue}1\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00000 \\color{black})$ & $\\rightarrow$ & $(1, 1, 0)$ \\\\\n7 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}0\\color{red}1\\color{blue}1\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00001 \\color{black})$ & $\\rightarrow$ & $(1, 1, 1)$ \\\\\n8 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}0\\color{blue}0\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00010 \\color{black})$ & $\\rightarrow$ & $(0, 0, 2)$ \\\\\n9 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}0\\color{blue}0\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00011 \\color{black})$ & $\\rightarrow$ & $(0, 0, 3)$ \\\\\n10 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}0\\color{blue}1\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00010 \\color{black})$ & $\\rightarrow$ & $(0, 1, 2)$ \\\\\n11 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}0\\color{blue}1\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00000, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00011 \\color{black})$ & $\\rightarrow$ & $(0, 1, 3)$ \\\\\n12 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}1\\color{blue}0\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00010 \\color{black})$ & $\\rightarrow$ & $(1, 0, 2)$ \\\\\n13 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}1\\color{blue}0\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00000, \\ \\color{green} \\ldots 00011 \\color{black})$ & $\\rightarrow$ & $(1, 0, 3)$ \\\\\n14 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}1\\color{blue}1\\color{green}0 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00010 \\color{black})$ & $\\rightarrow$ & $(1, 1, 2)$ \\\\\n15 & $\\rightarrow$ & \\ldots \\color{green}0\\color{red}0\\color{blue}0\\color{green}1\\color{red}1\\color{blue}1\\color{green}1 & $\\rightarrow$ & $(\\color{red} \\ldots 00001, \\ \\color{blue} \\ldots 00001, \\ \\color{green} \\ldots 00011 \\color{black})$ & $\\rightarrow$ & $(1, 1, 3)$ \\\\\n\\end{tabular}\n\n\\end{document}\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-triples-graph.asy",
    "content": "import graph;\n\nsize(600,400,IgnoreAspect);\n\ntriple untriple(int i) {\n  int x = 0;\n  int y = 0;\n  int z = 0;\n  int j = 2;\n  int out_mask = 1;\n  while (i != 0) {\n    if (i % 2 != 0) {\n      if (j == 0) {\n        x += out_mask;\n      } else if (j == 1) {\n        y += out_mask;\n      } else {\n        z += out_mask;\n      }\n    }\n    if (j == 0) {\n      j = 2;\n      out_mask *= 2;\n    } else if (j == 1) {\n      j = 0;\n    } else {\n      j = 1;\n    }\n    i #= 2;\n  }\n  return (x, y, z);\n}\n\nreal[] x={};\nreal[] y1={};\nreal[] y2={};\nreal[] y3={};\nfor (int i = 0; i < 10000; ++i) {\n  x.push(i);\n  y1.push(untriple(i).x);\n  y2.push(untriple(i).y);\n  y3.push(untriple(i).z);\n}\nreal[] z=(7*x)^(1/3);\n\ndraw(graph(x,y1),red,\"first element\");\ndraw(graph(x,y2),blue,\"second element\");\ndraw(graph(x,y3),green,\"third element\");\ndraw(graph(x,z),black,\"$\\sqrt[3]{7x}$\");\n\nxaxis(BottomTop,LeftTicks);\nyaxis(LeftRight, RightTicks);\nadd(legend(),point(NW),(25,-25),UnFill);\n"
  },
  {
    "path": "docs/assets/exhaustive-part-2/interleave-triples-large.tex",
    "content": "\\documentclass[11pt]{article}\n\\usepackage{amsmath}\n\n\\begin{document}\n\n\\begin{equation*}\n\\begin{split}\n3^{20}  &\\rightarrow (460, 1414, 1881) \\\\\n3^{40}  &\\rightarrow (709242, 1441904, 2284385) \\\\\n3^{60}  &\\rightarrow (2679879830, 1355562942, 821033137) \\\\\n3^{80}  &\\rightarrow (3812501379408, 1191406597864, 8482842874549) \\\\\n3^{100}  &\\rightarrow (7172636040844612, 458719279115590, 7931619284932509) \\\\\n\\end{split}\n\\end{equation*}\n\n\\end{document}\n"
  },
  {
    "path": "docs/assets/logo.asy",
    "content": "unitsize(1mm);\n\npair p1 = (25.0, -279.5970461708813);\npair p2 = (73.21397343575165, -453.91200545461675);\npair p3 = (87.46591514137958, -478.59709259527415);\npair p4 = (135.6798885771313, -87.89385577922775);\npair p5 = (139.89273037187124, -171.40290740472582);\npair p6 = (202.35864551325085, -370.4029538291187);\npair p7 = (214.32011142286873, -607.5090980498909);\npair p8 = (284.53465067912623, -562.1061442207722);\npair p9 = (310.7480582943721, -42.490901950109105);\npair p10 = (339.2519417056279, -42.490901950109105);\npair p11 = (347.00056582050587, -196.08799454538328);\npair p12 = (425.6407886662433, -408.50905162549805);\npair p13 = (435.67988857713124, -607.5090980498909);\npair p14 = (514.3201114228686, -87.89385577922775);\npair p15 = (550.5726189490025, -241.49094837450195);\npair p16 = (562.5340848586204, -478.59709259527415);\npair p17 = (576.7860265642483, -453.91200545461675);\npair p18 = (625.0, -279.5970461708813);\n\npair a = (0.5, sqrt(3)/2);\npair b = (0, 0);\npair c = (1, 0);\n\npair center = (0.5, sqrt(3)/6);\n\npen[] colors = new pen [] {\n    RGB(115, 209, 160),\n    RGB(86,158,118),\n    RGB(56,106,76),\n    RGB(27, 44, 34)\n};\n\nfill(p1 -- p3 -- p6 -- p5 -- cycle, colors[2]);\nfill(p12 -- p17 -- p13 -- p8 -- cycle, colors[2]);\nfill(p9 -- p14 -- p15 -- p11 -- cycle, colors[2]);\n\nfill(p6 -- p12 -- p11 -- cycle, colors[2]);\nfill(p3 -- p8 -- p7 -- cycle, colors[2]);\nfill(p9 -- p5 -- p4 -- cycle, colors[2]);\nfill(p17 -- p15 -- p18 -- cycle, colors[2]);\n\nfill(p1 -- p2 -- p3 -- cycle, colors[1]);\nfill(p3 -- p6 -- p8 -- cycle, colors[1]);\nfill(p6 -- p8 -- p12 -- cycle, colors[0]);\nfill(p6 -- p5 -- p11 -- cycle, colors[0]);\nfill(p13 -- p8 -- p7 -- cycle, colors[1]);\nfill(p13 -- p16 -- p17 -- cycle, colors[1]);\nfill(p12 -- p17 -- p15 -- cycle, colors[1]);\nfill(p12 -- p11 -- p15 -- cycle, colors[0]);\nfill(p1 -- p5 -- p4 -- cycle, colors[1]);\nfill(p9 -- p5 -- p11 -- cycle, colors[1]);\nfill(p9 -- p10 -- p14 -- cycle, colors[1]);\nfill(p14 -- p15 -- p18 -- cycle, colors[1]);\n"
  },
  {
    "path": "docs/index.md",
    "content": "<p align=\"center\">\r\n  <img width=\"650\" src=\"/assets/logo-and-name.svg\" alt=\"Logo\">\r\n</p>\r\n\r\nMalachite is an arbitrary-precision arithmetic library for [Rust](https://www.rust-lang.org/). It\r\nachieves high performance in part by using algorithms derived from [GMP](https://gmplib.org/),\r\n[FLINT](https://www.flintlib.org/), and [MPFR](https://www.mpfr.org/).\r\n\r\nThe documentation for Malachite is [here](https://docs.rs/malachite/latest/malachite/), and its crate is [here](https://crates.io/crates/malachite).\r\n\r\n```rust\r\nuse malachite::num::arithmetic::traits::Factorial;\r\nuse malachite::Natural;\r\n\r\nfn main() {\r\n    println!(\"{}\", Natural::factorial(100));\r\n}\r\n```\r\nThe code above outputs the following:\r\n```\r\n93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000\r\n```\r\nYou have to scroll to see the entire output.\r\n\r\nHere's a more complex example, calculating the negative-one-millionth power of 3 and displaying the\r\nresult with 30 digits of precision.\r\n\r\n```rust\r\nuse malachite::num::arithmetic::traits::Pow;\r\nuse malachite::num::conversion::string::options::ToSciOptions;\r\nuse malachite::num::conversion::traits::ToSci;\r\nuse malachite::Rational;\r\n\r\nfn main() {\r\n    let mut options = ToSciOptions::default();\r\n    options.set_precision(30);\r\n    println!(\"{}\", Rational::from(3).pow(-1_000_000i64).to_sci_with_options(options));\r\n}\r\n```\r\nThe output is this:\r\n```\r\n5.56263209915712886588211486263e-477122\r\n```\r\nEvery digit is correct, except that the least-significant digit was rounded up from 2. The default\r\nrounding mode,\r\n[`Nearest`](https://docs.rs/malachite-base/latest/malachite_base/rounding_modes/enum.RoundingMode.html#variant.Nearest),\r\nuses [bankers' rounding](https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even), but you may\r\nspecify different rounding behavior via the options parameter.\r\n\r\nMalachite is designed to work with very large numbers efficiently. See [here](/performance) for a\r\nperformance comparison against other libraries.\r\n\r\nMalachite uses `no_std`, unless the `random`, `test_build`, or `bin_build` features are enabled.\r\n\r\nTo use Malachite, add the following to your project's `Cargo.toml` file:\r\n```yaml\r\n[dependencies.malachite]\r\nversion = \"0.9.1\"\r\n```\r\n\r\nBy default, all of Malachite's features are included, but you can opt out of some of them. For\r\nexample, if you want to use `Natural` and `Integer` but not `Rational`, you can instead use\r\n```yaml\r\n[dependencies.malachite]\r\nversion = \"0.9.1\"\r\ndefault-features = false\r\nfeatures = [ \"naturals_and_integers\" ]\r\n```\r\n\r\nThe `malachite` crate re-exports three sub-crates.\r\n- **malachite-base** ([crates.io](https://crates.io/crates/malachite-base)) is a collection of utilities\r\n  supporting the other crates. It includes\r\n  - Traits that wrap functions from the standard library, like\r\n  [`CheckedAdd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.CheckedAdd.html);\r\n  - Traits that give extra functionality to primitive types, like\r\n    [`Gcd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.Gcd.html),\r\n    [`FloorSqrt`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.FloorSqrt.html),\r\n    and\r\n    [`BitAccess`](https://docs.rs/malachite-base/latest/malachite_base/num/logic/traits/trait.BitAccess.html);\r\n  - Iterator-producing functions that let you generate values for testing.\r\n- **malachite-nz** ([crates.io](https://crates.io/crates/malachite-nz)) defines two bignum types,\r\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s and\r\n  [`Integer`](https://docs.rs/malachite-nz/latest/malachite_nz/integer/struct.Integer.html)s. The\r\n  functions defined on these types include\r\n  - All the ones you'd expect, like addition, subtraction, multiplication, and integer division;\r\n  - Implementations of\r\n    [`DivRound`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.DivRound.html),\r\n    which provides division that rounds according to a specified\r\n    [`RoundingMode`](https://docs.rs/malachite-base/latest/malachite_base/rounding_modes/enum.RoundingMode.html);\r\n  - Various mathematical functions, like implementations of\r\n    [`FloorSqrt`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.FloorSqrt.html)\r\n    and\r\n    [`Gcd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.Gcd.html);\r\n  - Modular arithmetic functions, like implementations of\r\n    [`ModAdd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModAdd.html)\r\n    and\r\n    [`ModPow`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPow.html),\r\n    and of traits for arithmetic modulo a power of 2, like\r\n    [`ModPowerOf2Add`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPowerOf2Add.html)\r\n    and\r\n    [`ModPowerOf2Pow`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPowerOf2Pow.html);\r\n  - Various functions for logic and bit manipulation, like\r\n    [`BitAnd`](https://doc.rust-lang.org/nightly/core/ops/trait.BitAnd.html) and\r\n    [`BitAccess`](https://docs.rs/malachite-base/latest/malachite_base/num/logic/traits/trait.BitAccess.html).\r\n\r\n  If you need to explicitly include this crate as a dependency of the `malachite` crate, use the\r\n  `naturals_and_integers` or `malachite-nz` feature.\r\n- **malachite-q** ([crates.io](https://crates.io/crates/malachite-q)) defines\r\n  [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s. The\r\n  functions defined on this type include\r\n  - All the ones you'd expect, like addition, subtraction, multiplication, and division;\r\n  - Functions related to conversion between\r\n    [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s and other\r\n    kinds of numbers, including primitive floats;\r\n  - Functions for Diophantine approximation;\r\n  - Functions for expressing\r\n    [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s in\r\n    scientific notation.\r\n\r\n  If you need to explicitly include this crate as a dependency of the `malachite` crate, use the\r\n  `rationals` or `malachite-q` feature.\r\n\r\n- **malachite-float** Arbitrary-precision floating-point numbers. These are in development, and\r\n  most features are missing.\r\n\r\nMalachite is under active development, with many more types and features planned for the future.\r\nNonetheless, it is extensively tested and documented, and ready for use today. Just be aware that\r\nits API is not stable yet, and that Malachite is licensed under LGPL 3.0.\r\n\r\nMalachite is developed by Mikhail Hogrefe. `malachite-bigint`, a drop-in num-bigint replacement based on Malachite, was created by Steve Shi and is now maintained by Mikhail Hogrefe. Thanks to b4D8, florian1345, konstin, Rowan Hart, YunWon Jeong, Park Joon-Kyu, Antonio Mamić, OliverNChalk, shekohex, and skycloudd for additional contributions.\r\n\r\n# FAQ\r\n**How is \"Malachite\" pronounced, and what does it mean?**\r\n\"Malachite\" is pronounced MA-luh-kite, or /ˈmæl.əˌkaɪt/. It is the name of\r\n[a green gemstone](https://en.wikipedia.org/wiki/Malachite). Unfortunately, malachite does not\r\ncontain iron, which would have made it a particularly good namesake for a Rust library.\r\n\r\nMalachite's logo is an image of a [snub cube](https://en.wikipedia.org/wiki/Snub_cube).\r\n\r\n**When does Malachite allocate memory?**\r\nAny `Natural` less than $$2^{64}$$ is represented inline, without allocating memory. Any `Integer`\r\nwhose absolute value is less than $$2^{64}$$ doesn't allocate either, and neither does any\r\n`Rational` whose absolute numerator and denominator are both less than $$2^{64}$$. If you're using\r\na build with `--features 32_bit_limbs`, then the threshold is $$2^{32}$$ instead.\r\n\r\n**Can I build Malachite for WebAssembly?**\r\nYes. If, in the future, Malachite includes code incompatible with Wasm (for example, code that uses\r\n[rayon](https://docs.rs/rayon/latest/rayon/)), it will be possible to disable that code with cargo\r\nflags.\r\n\r\n# Blog Posts\r\n<ul>\r\n  {% for post in site.posts %}\r\n    <li>\r\n      <a href=\"{{ post.url }}\">{{ post.title }}</a>\r\n    </li>\r\n  {% endfor %}\r\n</ul>\r\n\r\nCopyright © 2026 Mikhail Hogrefe\r\n"
  },
  {
    "path": "docs/performance.md",
    "content": "---\nlayout: default\ntitle: \"Malachite Performance\"\npermalink: /performance/\ntheme: jekyll-theme-slate\n---\n\n# Performance\nHere are some benchmarks comparing the Malachite to two other libraries:\n- [`num`](https://crates.io/crates/num), the de facto standard bignum library for Rust.\n- [`rug`](https://crates.io/crates/rug), a library that calls GMP, a widely used, highly-optimized\nbignum library written in C.\n\nThe `num` version that is compared against is 0.4.0, and the `rug` version is 1.16.0.\n\nThe general trend is that Malachite is faster than `num` due to better algorithms, and slower than\n`rug`. My guess is that the better performance of `rug` is due partly to GMP's use of inline\nassembly (Malachite has none, being written entirely in safe Rust), and possibly due to operations\non Rust's slices being a little slower than C's raw pointers.\n\nThe following is just a small sample of the benchmarks that are available in Malachite. For each\nbenchmark, I've included the command that you can use to run it yourself. You can specify the\noutput file using `-o benchfile.gp`, and then use [gnuplot](http://www.gnuplot.info/) to convert\nthe `.gp` to your format of choice. I like SVG:\n\n`gnuplot -e \"set terminal svg; l \\\"benchfile.gp\\\"\" > benchfile.svg`\n\n## Rational addition\n`cargo run --features bin_build --release -- -l 100000 -m random -b benchmark_rational_add_library_comparison -c \"mean_bits_n 256\"`\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/benchmarks/2022-06-04-q-add.svg\" alt=\"Rational addition\">\n</p>\n\nThe most significant operations involved in adding two rational numbers (fractions) are GCD\ncomputation and division.\n\nFor GCD computation, `num` uses the\n[binary GCD algorithm](https://en.wikipedia.org/wiki/Binary_GCD_algorithm), a quadratic algorithm.\nMalachite follows GMP in using\n[Lehmer's GCD algorithm](https://en.wikipedia.org/wiki/Lehmer%27s_GCD_algorithm), which takes\nadvantage of fast multiplication algorithms to achieve $$O(n (\\log n)^2 \\log \\log n)$$ time.\n\nFor division, `num` uses Knuth's\n[Algorithm D](https://ridiculousfish.com/blog/posts/labor-of-division-episode-iv.html), which is\nalso quadratic. Malachite, again following GMP, uses several division algorithms depending on the\ninput size. For the largest inputs, it uses a kind of\n[Barrett reduction](https://en.wikipedia.org/wiki/Barrett_reduction), which takes\n$$O(n \\log n \\log \\log n)$$ time.\n\n## Converting a Natural to a string\n`cargo run --features bin_build --release -- -l 100000 -m random -b benchmark_natural_to_string_library_comparison -c \"mean_bits_n 1024\"`\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/benchmarks/2022-06-04-n-to_string.svg\" alt=\"Natural to string\">\n</p>\n\nWhen converting a natural number to a string, `num` seems to use an $$O(n^{3/2})$$ algorithm.\nMalachite uses a divide-and-conquer algorithm that takes $$O(n (\\log n)^2 \\log \\log n)$$ time.\n\n## Natural multiplication\n`cargo run --features bin_build --release -- -l 20000 -m random -b benchmark_natural_mul_library_comparison -c \"mean_bits_n 16384\"`\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/benchmarks/2022-06-04-n-mul.svg\" alt=\"Natural multiplication\">\n</p>\n\nFor multiplying two natural numbers, `num` uses a basecase quadratic algorithm for small inputs,\nthen [Toom-22](https://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication) (Karatsuba)\nmultiplication for larger inputs, and finally Toom-33 for the largest ones. This means that\nmultiplication takes $$O(n^{\\log_3 5}) \\approx O(n^{1.465})$$ time.\n\nMalachite also uses a basecase quadratic algorithm, then 13 variants of Toom-Cook multiplication,\nand finally [Schönhage-Strassen (FFT) multiplication](https://en.wikipedia.org/wiki/Schonhage-Strassen_algorithm) for the largest inputs, achieving $$O(n \\log n \\log \\log n)$$\ntime.\n\nGiven all of this machinery, it's a little disappointing that Malachite isn't much faster at\nmultiplying than `num` is, in practice. I have a few improvements in mind that should boost\nMalachite's multiplication performance further.\n\nFor numbers of up to 1000 bits, all three libraries are about equally fast:\n\n`cargo run --features bin_build --release -- -l 100000 -m random -b benchmark_natural_mul_library_comparison -c \"mean_bits_n 64\"`\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/benchmarks/2022-06-04-n-mul-small.svg\" alt=\"Natural multiplication\">\n</p>\n\n## Natural addition\n`cargo run --features bin_build --release -- -l 100000 -m random -b benchmark_natural_add_library_comparison -c \"mean_bits_n 1024\"`\n<p align=\"center\">\n  <img width=\"650\" src=\"/assets/benchmarks/2022-06-04-n-add.svg\" alt=\"Natural addition\">\n</p>\n\nAddition of natural numbers is fast for all three libraries, being a straightforward and\nlinear-time affair. Interestingly, `rug` is the slowest of the bunch. I find it hard to\nbelieve that GMP is slower than `num` or Malachite, so maybe there's some overhead\nassociated with FFI.\n\nCopyright © 2026 Mikhail Hogrefe\n"
  },
  {
    "path": "find_replace.py",
    "content": "import os\nimport sys\n\ndef search_replace(filename, old, new):\n    with open(filename) as f:\n        new_lines = []\n        replaced = False\n        for line in f.readlines():\n            line = line.rstrip()\n            if old in line:\n                replaced = True\n                new_lines.append(line.replace(old, new))\n            else:\n                new_lines.append(line)\n    if replaced:\n        with open(filename, 'w') as out_f:\n            for line in new_lines:\n                out_f.write(line + '\\n')\n    return replaced\n\nold = sys.argv[1]\nnew = sys.argv[2]\n\nfilename_list = []\nfor root, directories, filenames in os.walk('.'):\n    for filename in filenames: \n        filename = os.path.join(root, filename) \n        if '/target/' not in filename and filename.endswith('.rs'):\n            filename_list.append(filename)\nfor root, directories, filenames in os.walk('../rust-wheels'):\n    for filename in filenames: \n        filename = os.path.join(root, filename) \n        if '/target/' not in filename and filename.endswith('.rs'):\n            filename_list.append(filename)\nfilename_list.sort()\n\nline_count = 0\nfor filename in filename_list:\n    if search_replace(filename, old, new):\n        print(filename)\n"
  },
  {
    "path": "flake.nix",
    "content": "{\n  description = \"malachite development environment\";\n  inputs = {\n    nixpkgs.url = \"github:NixOS/nixpkgs/nixpkgs-unstable\";\n    flake-utils.url = \"github:numtide/flake-utils\";\n    # Rust\n    rust-overlay = {\n      url = \"github:oxalica/rust-overlay\";\n      inputs = {\n        nixpkgs.follows = \"nixpkgs\";\n        flake-utils.follows = \"flake-utils\";\n      };\n    };\n  };\n\n  outputs = { self, nixpkgs, rust-overlay, flake-utils }:\n    flake-utils.lib.eachDefaultSystem (system:\n      let\n        overlays = [ (import rust-overlay) ];\n        pkgs = import nixpkgs {\n          inherit system overlays;\n        };\n        lib = pkgs.lib;\n        toolchain = pkgs.rust-bin.stable.latest.default.override {\n          extensions = [ \"rust-src\" ];\n          targets = [ \"wasm32-unknown-unknown\" ];\n        };\n      in\n      {\n        devShells.default = pkgs.mkShell {\n          name = \"malachite\";\n          nativeBuildInputs = [\n            pkgs.pkg-config\n            pkgs.clang\n            # Mold Linker for faster builds (only on Linux)\n            (lib.optionals pkgs.stdenv.isLinux pkgs.mold)\n            (lib.optionals pkgs.stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.Security)\n            (lib.optionals pkgs.stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.SystemConfiguration)\n          ];\n          buildInputs = [\n            # We want the unwrapped version, wrapped comes with nixpkgs' toolchain\n            pkgs.rust-analyzer-unwrapped\n            # Finally the toolchain\n            toolchain\n          ];\n          packages = [\n            pkgs.cargo-nextest\n          ];\n          # Environment variables\n          RUST_SRC_PATH = \"${toolchain}/lib/rustlib/src/rust/library\";\n          # Needed for testing rug\n          LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.gmp ];\n        };\n      });\n}\n"
  },
  {
    "path": "katex-header.html",
    "content": "<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css\" integrity=\"sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y\" crossorigin=\"anonymous\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js\"                  integrity=\"sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js\"    integrity=\"sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe\" crossorigin=\"anonymous\"></script>\n<script>\n    document.addEventListener(\"DOMContentLoaded\", function() {\n        renderMathInElement(document.body, {\n            delimiters: [\n                {left: \"$$\", right: \"$$\", display: true},\n                {left: \"\\\\(\", right: \"\\\\)\", display: false},\n                {left: \"$\", right: \"$\", display: false},\n                {left: \"\\\\[\", right: \"\\\\]\", display: true}\n            ]\n        });\n    });\n</script>\n"
  },
  {
    "path": "malachite/Cargo.toml",
    "content": "[package]\nname = \"malachite\"\nversion = \"0.9.1\"\nauthors = [\"Mikhail Hogrefe <mikhailhogrefe@gmail.com>\"]\nrust-version.workspace = true\nedition.workspace = true\ndescription = \"Arbitrary-precision arithmetic, with efficient algorithms partially derived from GMP, FLINT, and MPFR.\"\nreadme = \"../README.md\"\nhomepage = \"https://malachite.rs/\"\nrepository = \"https://github.com/mhogrefe/malachite\"\nlicense = \"LGPL-3.0-only\"\nkeywords = [\"mathematics\", \"math\", \"numerics\", \"bignum\"]\ncategories = [\"mathematics\"]\n\n[dependencies]\nmalachite-base = { version = \"0.9.1\", default-features = false, path = \"../malachite-base\" }\nmalachite-nz = { version = \"0.9.1\", default-features = false, optional = true, path = \"../malachite-nz\" }\nmalachite-q = { version = \"0.9.1\", default-features = false, optional = true, path = \"../malachite-q\" }\nmalachite-float = { version = \"0.9.1\", default-features = false, optional = true, path = \"../malachite-float\" }\nserde = { version = \"1.0.188\", optional = true, features = [\"derive\"] }\nembed-doc-image = { version = \"0.1.4\", optional = true }\n\n[features]\ndefault = [ \"std\", \"naturals_and_integers\", \"rationals\" ]\nstd = [ \"malachite-base/std\", \"malachite-nz/std\", \"malachite-q/std\", \"malachite-float/std\" ]\nenable_pyo3 = [ \"malachite-nz/enable_pyo3\" ]\nenable_serde = [ \"malachite-nz/enable_serde\", \"malachite-q/enable_serde\", \"malachite-float/enable_serde\" ]\nrandom = [\"malachite-base/random\", \"malachite-nz/random\", \"malachite-q/random\", \"malachite-float/random\"]\n32_bit_limbs = [\"malachite-nz/32_bit_limbs\", \"malachite-q/32_bit_limbs\", \"malachite-float/32_bit_limbs\"]\n\nnaturals_and_integers = [ \"malachite-nz\" ]\nrationals = [ \"malachite-q\" ]\nfloats = [ \"malachite-float\" ]\n\n[package.metadata.docs.rs]\n# docs.rs uses a nightly compiler, so by instructing it to use our `doc-images` feature we\n# ensure that it will render any images that we may have in inner attribute documentation.\nfeatures = [\"embed-doc-image\", \"random\"]\nrustdoc-args = [ \"--html-in-header\", \"katex-header.html\" ]\n"
  },
  {
    "path": "malachite/katex-header.html",
    "content": "<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css\" integrity=\"sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y\" crossorigin=\"anonymous\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js\"                  integrity=\"sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js\"    integrity=\"sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe\" crossorigin=\"anonymous\"></script>\n<script>\n    document.addEventListener(\"DOMContentLoaded\", function() {\n        renderMathInElement(document.body, {\n            delimiters: [\n                {left: \"$$\", right: \"$$\", display: true},\n                {left: \"\\\\(\", right: \"\\\\)\", display: false},\n                {left: \"$\", right: \"$\", display: false},\n                {left: \"\\\\[\", right: \"\\\\]\", display: true}\n            ]\n        });\n    });\n</script>\n"
  },
  {
    "path": "malachite/src/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![cfg_attr(not(any(feature = \"random\", feature = \"std\")), no_std)]\n\n/// This module contains various functions that support the other crates. This includes many\n/// numeric traits and their implementation for primitive numeric types, as well as many functions\n/// for exhaustively and randomly generating values of many types.\npub mod base {\n    pub use malachite_base::*;\n}\n\n#[cfg(feature = \"naturals_and_integers\")]\n#[cfg(feature = \"rationals\")]\n#[cfg(feature = \"floats\")]\npub use malachite_float::Float;\n#[cfg(feature = \"naturals_and_integers\")]\npub use malachite_nz::integer::Integer;\n#[cfg(feature = \"naturals_and_integers\")]\npub use malachite_nz::natural::Natural;\n#[cfg(feature = \"naturals_and_integers\")]\npub use malachite_nz::*;\n#[cfg(feature = \"naturals_and_integers\")]\n#[cfg(feature = \"rationals\")]\n/// [`Rational`], a type representing rational numbers with arbitrarily large numerators and\n/// denominators.\npub mod rational {\n    pub use malachite_q::*;\n}\n#[cfg(feature = \"naturals_and_integers\")]\n#[cfg(feature = \"rationals\")]\npub use malachite_q::Rational;\n\n/// Various types and constants dependent on whether Malachite is built using 32-bit limbs or\n/// 64-bit limbs. `Limb` is the type such that `Vec`s of limbs are used to represent the bits of a\n/// [`Natural`].\npub mod platform {\n    #[cfg(feature = \"32_bit_limbs\")]\n    pub use malachite_nz::platform_32::*;\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    pub use malachite_nz::platform_64::*;\n}\n"
  },
  {
    "path": "malachite-base/.gitignore",
    "content": "target\n*.bk\n.idea*\n*.iml\n"
  },
  {
    "path": "malachite-base/Cargo.toml",
    "content": "[package]\nname = \"malachite-base\"\nversion = \"0.9.1\"\nauthors = [\"Mikhail Hogrefe <mikhailhogrefe@gmail.com>\"]\nrust-version.workspace = true\nedition.workspace = true\ndescription = \"A collection of utilities, including new arithmetic traits and iterators that generate all values of a type.\"\nreadme = \"README.md\"\nhomepage = \"https://malachite.rs/\"\nrepository = \"https://github.com/mhogrefe/malachite\"\nlicense = \"LGPL-3.0-only\"\nkeywords = [\"mathematics\", \"math\", \"numerics\", \"testing\"]\ncategories = [\"mathematics\", \"development-tools::testing\"]\n\n[lib]\nname = \"malachite_base\"\npath = \"src/lib.rs\"\n\n[[bin]]\nname = \"malachite_base_main\"\npath = \"src/bin.rs\"\ntest = false\n\n[dependencies]\nitertools = { version = \"0.14.0\", default-features = false, features = [\"use_alloc\"] }\nryu = { version = \"1.0.22\", default-features = false }\nhashbrown = { version = \"0.16.1\", default-features = false, features = [\"default-hasher\", \"inline-more\"] }\nlibm = { version = \"0.2.16\", default-features = false }\n\nsha3 = { version = \"0.10.8\", optional = true, default-features = false }\nrand = { version = \"0.9.2\", optional = true, default-features = false }\nrand_chacha = { version = \"0.9.0\", optional = true, default-features = false }\ngetrandom = { version = \"0.2\", default-features = false, features = [\"js\"], optional = true }\n\nclap = { version = \"2.33.1\", optional = true }\ngnuplot = { version = \"0.0.46\", optional = true }\ntime = { version = \"0.3.47\", optional = true }\nwalkdir = { version = \"2.5.0\", optional = true }\n\n[features]\ndefault = [\"std\"]\nstd = [\"itertools/use_std\"]\nrandom = [\"sha3\", \"rand\", \"rand_chacha\", \"getrandom\"]\ntest_build = [\"gnuplot\", \"time\", \"clap\", \"random\", \"itertools/use_std\"]\nbin_build = [\"walkdir\", \"test_build\"]\n\n[dev-dependencies]\nmalachite-base = { workspace = true, features = [\"test_build\"] }\nmaplit = \"1.0.2\"\n\n[package.metadata.docs.rs]\nrustdoc-args = [ \"--html-in-header\", \"katex-header.html\" ]\n"
  },
  {
    "path": "malachite-base/README.md",
    "content": "- [crates.io](https://crates.io/crates/malachite-base)\n- [docs.rs](https://docs.rs/malachite-base/latest/malachite_base/)\n\nRather than using this crate directly, use the\n[`malachite`](https://crates.io/crates/malachite) meta-crate. It re-exports all of this crate's\npublic members.\n\nIn `malachite-base`'s doctests you will frequently see import paths beginning with\n`malachite_base::`. When using the `malachite` crate, replace this part of the paths with\n`malachite::`.\n\n# malachite-base\nThis crate contains many utilities that are used by the\n[`malachite-nz`](https://crates.io/crates/malachite-nz) and\n[`malachite-q`](https://crates.io/crates/malachite-q) crates. These utilities include\n- Traits that wrap functions from the standard library, like\n  [`CheckedAdd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.CheckedAdd.html).\n- Traits that give extra functionality to primitive types, like\n  [`Gcd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.Gcd.html),\n  [`FloorSqrt`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.FloorSqrt.html),\n  and\n  [`BitAccess`](https://docs.rs/malachite-base/latest/malachite_base/num/logic/traits/trait.BitAccess.html).\n- Iterator-producing functions that let you generate values for testing. Here's an example of\n  an iterator that produces all pairs of\n  [`u32`](https://doc.rust-lang.org/nightly/std/primitive.u32.html)s:\n  ```\n  use malachite_base::num::exhaustive::exhaustive_unsigneds;\n  use malachite_base::tuples::exhaustive::exhaustive_pairs_from_single;\n\n  let mut pairs = exhaustive_pairs_from_single(exhaustive_unsigneds::<u32>());\n  assert_eq!(\n      pairs.take(20).collect::<Vec<_>>(),\n      &[\n          (0, 0), (0, 1), (1, 0), (1, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 0), (2, 1),\n          (3, 0), (3, 1), (2, 2), (2, 3), (3, 2), (3, 3), (0, 4), (0, 5), (1, 4), (1, 5)\n      ]\n  );\n  ```\n- The\n  [`RoundingMode`](https://docs.rs/malachite-base/latest/malachite_base/rounding_modes/enum.RoundingMode.html)\n  enum, which allows you to specify the rounding behavior of various functions.\n- The\n  [`NiceFloat`](https://docs.rs/malachite-base/latest/malachite_base/num/float/struct.NiceFloat.html) wrapper, which provides alternative implementations of\n  [`Eq`](https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html),\n  [`Ord`](https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html), and\n  [`Display`](https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html)\n  for floating-point values which are in some ways nicer than the defaults.\n\n# Demos and benchmarks\nThis crate comes with a `bin` target that can be used for running demos and benchmarks.\n- Almost all of the public functions in this crate have an associated demo. Running a demo\n  shows you a function's behavior on a large number of inputs. For example, to demo the\n  [`mod_pow`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPow.html#tymethod.mod_pow)\n  function on [`u32`](https://doc.rust-lang.org/nightly/std/primitive.u32.html)s, you can use the\n  following command:\n  ```\n  cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_mod_pow_u32\n  ```\n  This command uses the `exhaustive` mode, which generates every possible input, generally\n  starting with the simplest input and progressing to more complex ones. Another mode is\n  `random`. The `-l` flag specifies how many inputs should be generated.\n- You can use a similar command to run benchmarks. The following command benchmarks various\n  GCD algorithms for [`u64`](https://doc.rust-lang.org/nightly/std/primitive.u64.html)s:\n  ```text\n  cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n      benchmark_gcd_algorithms_u64 -o gcd-bench.gp\n  ```\n  This creates a file called gcd-bench.gp. You can use gnuplot to create an SVG from it like\n  so:\n  ```text\n  gnuplot -e \"set terminal svg; l \\\"gcd-bench.gp\\\"\" > gcd-bench.svg\n  ```\n\nThe list of available demos and benchmarks is not documented anywhere; you must find them by\nbrowsing through\n[`bin_util/demo_and_bench`](https://github.com/mhogrefe/malachite/tree/master/malachite-base/src/bin_util/demo_and_bench).\n\n# Features\n- `random`: This feature provides some functions for randomly generating values. It is off by\n  default to avoid pulling in some extra dependencies.\n- `test_build`: A large proportion of the code in this crate is only used for testing. For a\n  typical user, building this code would result in an unnecessarily long compilation time and\n  an unnecessarily large binary. Much of it is also used for testing\n  [`malachite-nz`](https://crates.io/crates/malachite-nz) and\n  [`malachite-q`](https://crates.io/crates/malachite-q), so it can't just be confined to the\n  `tests` directory. My solution is to only build this code when the `test_build` feature is\n  enabled. If you want to run unit tests, you must enable `test_build`. However, doctests don't\n  require it, since they only test the public interface. Enabling this feature also enables\n  `random`.\n- `bin_build`: This feature is used to build the code for demos and benchmarks, which also\n  takes a long time to build. Enabling this feature also enables `test_build` and `random`.\n\nMalachite is developed by Mikhail Hogrefe. Thanks to b4D8, florian1345, konstin, Rowan Hart, YunWon Jeong, Park Joon-Kyu, Antonio Mamić, OliverNChalk, shekohex, and skycloudd for additional contributions.\n\nCopyright © 2026 Mikhail Hogrefe\n"
  },
  {
    "path": "malachite-base/katex-header.html",
    "content": "<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css\" integrity=\"sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y\" crossorigin=\"anonymous\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js\"                  integrity=\"sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js\"    integrity=\"sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe\" crossorigin=\"anonymous\"></script>\n<script>\n    document.addEventListener(\"DOMContentLoaded\", function() {\n        renderMathInElement(document.body, {\n            delimiters: [\n                {left: \"$$\", right: \"$$\", display: true},\n                {left: \"\\\\(\", right: \"\\\\)\", display: false},\n                {left: \"$\", right: \"$\", display: false},\n                {left: \"\\\\[\", right: \"\\\\]\", display: true}\n            ]\n        });\n    });\n</script>\n"
  },
  {
    "path": "malachite-base/rustfmt.toml",
    "content": "max_width = 100\narray_width = 100\n"
  },
  {
    "path": "malachite-base/src/bin.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n\n#[cfg(feature = \"bin_build\")]\nextern crate itertools;\n#[cfg(feature = \"bin_build\")]\n#[macro_use]\nextern crate malachite_base;\n#[cfg(feature = \"bin_build\")]\nextern crate walkdir;\n\n#[cfg(feature = \"bin_build\")]\nuse bin_util::demo_and_bench::register;\n#[cfg(feature = \"bin_build\")]\nuse bin_util::generate::max_base::generate_max_base;\n#[cfg(feature = \"bin_build\")]\nuse bin_util::generate::rle::generate_rle_encoding;\n#[cfg(feature = \"bin_build\")]\nuse bin_util::generate::tuning_manager::{build_reference_data, test};\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::Runner;\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::cmd::read_command_line_arguments;\n\n// Examples:\n//\n// ```\n// cargo run --features bin_build -- -g max_base\n// cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_mod_pow_u32\n// ```\n#[cfg(feature = \"bin_build\")]\nfn main() {\n    let args = read_command_line_arguments(\"malachite-base\");\n    let mut runner = Runner::new();\n    register(&mut runner);\n    if let Some(demo_key) = args.demo_key {\n        runner.run_demo(&demo_key, args.generation_mode, &args.config, args.limit);\n    } else if let Some(bench_key) = args.bench_key {\n        runner.run_bench(\n            &bench_key,\n            args.generation_mode,\n            &args.config,\n            args.limit,\n            &args.out,\n        );\n    } else {\n        let codegen_key = args.codegen_key.unwrap();\n        match codegen_key.as_str() {\n            \"max_base\" => generate_max_base(),\n            \"rle_encode\" => generate_rle_encoding(),\n            \"tm_build_reference_data\" => build_reference_data(),\n            \"tm_test\" => test(),\n            _ => panic!(\"Invalid codegen key: {codegen_key}\"),\n        }\n    }\n}\n\n#[cfg(not(feature = \"bin_build\"))]\nconst fn main() {}\n\n#[cfg(feature = \"bin_build\")]\npub mod bin_util {\n    pub mod demo_and_bench;\n    pub mod generate;\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/bools/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    not_assign::register(runner);\n}\n\nmod not_assign;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/bools/not_assign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::NotAssign;\nuse malachite_base::test_util::generators::bool_gen;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_bool_not_assign);\n}\n\nfn demo_bool_not_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut b in bool_gen().get(gm, config).take(limit) {\n        let b_old = b;\n        b.not_assign();\n        println!(\"b := {b_old}; b.not_assign(); b = {b}\");\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/chars/crement/char_to_contiguous_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::crement::char_to_contiguous_range;\nuse malachite_base::test_util::bench::bucketers::char_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::char_gen;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_char_to_contiguous_range);\n    register_bench!(runner, benchmark_char_to_contiguous_range);\n}\n\nfn demo_char_to_contiguous_range(gm: GenMode, config: &GenConfig, limit: usize) {\n    for c in char_gen().get(gm, config).take(limit) {\n        println!(\n            \"char_to_contiguous_range({:?}) = {}\",\n            c,\n            char_to_contiguous_range(c)\n        );\n    }\n}\n\nfn benchmark_char_to_contiguous_range(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"char_to_contiguous_range(char)\",\n        BenchmarkType::Single,\n        char_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &char_bucketer(),\n        &mut [(\"Malachite\", &mut |c| no_out!(char_to_contiguous_range(c)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/chars/crement/contiguous_range_to_char.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::crement::contiguous_range_to_char;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_contiguous_range_to_char);\n    register_bench!(runner, benchmark_contiguous_range_to_char);\n}\n\nfn demo_contiguous_range_to_char(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"contiguous_range_to_char({}) = {:?}\",\n            u,\n            contiguous_range_to_char(u)\n        );\n    }\n}\n\nfn benchmark_contiguous_range_to_char(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"contiguous_range_to_char(u32)\",\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(contiguous_range_to_char(u)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/chars/crement/crement.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::crement::{decrement_char, increment_char};\nuse malachite_base::test_util::bench::bucketers::char_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{char_gen_var_1, char_gen_var_2};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_increment_char);\n    register_demo!(runner, demo_decrement_char);\n    register_bench!(runner, benchmark_increment_char);\n    register_bench!(runner, benchmark_decrement_char);\n}\n\nfn demo_increment_char(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut c in char_gen_var_1().get(gm, config).take(limit) {\n        let c_old = c;\n        increment_char(&mut c);\n        println!(\"c := {c_old:?}; increment_char(&mut c); c = {c:?}\");\n    }\n}\n\nfn demo_decrement_char(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut c in char_gen_var_2().get(gm, config).take(limit) {\n        let c_old = c;\n        increment_char(&mut c);\n        println!(\"c := {c_old:?}; decrement_char(&mut c); c = {c:?}\");\n    }\n}\n\nfn benchmark_increment_char(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"increment_char(&mut char)\",\n        BenchmarkType::Single,\n        char_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &char_bucketer(),\n        &mut [(\"Malachite\", &mut |mut c| increment_char(&mut c))],\n    );\n}\n\nfn benchmark_decrement_char(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"decrement_char(&mut char)\",\n        BenchmarkType::Single,\n        char_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &char_bucketer(),\n        &mut [(\"Malachite\", &mut |mut c| decrement_char(&mut c))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/chars/crement/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    char_to_contiguous_range::register(runner);\n    contiguous_range_to_char::register(runner);\n    crement::register(runner);\n}\n\npub mod char_to_contiguous_range;\npub mod contiguous_range_to_char;\n#[allow(clippy::module_inception)]\npub mod crement;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/chars/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    crement::register(runner);\n}\n\nmod crement;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/comparison/macros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_max_bit_bucketer, triple_max_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_max_1);\n    register_demo!(runner, demo_max_2);\n    register_demo!(runner, demo_max_3);\n    register_demo!(runner, demo_min_1);\n    register_demo!(runner, demo_min_2);\n    register_demo!(runner, demo_min_3);\n    register_bench!(runner, benchmark_max_1);\n    register_bench!(runner, benchmark_max_2);\n    register_bench!(runner, benchmark_max_3);\n    register_bench!(runner, benchmark_min_1);\n    register_bench!(runner, benchmark_min_2);\n    register_bench!(runner, benchmark_min_3);\n}\n\nfn demo_max_1(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen::<u8>().get(gm, config).take(limit) {\n        println!(\"max!({}) = {}\", x, max!(x));\n    }\n}\n\nfn demo_max_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<u8>().get(gm, config).take(limit) {\n        println!(\"max!({}, {}) = {}\", x, y, max!(x, y));\n    }\n}\n\nfn demo_max_3(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"max!({}, {}, {}) = {}\", x, y, z, max!(x, y, z));\n    }\n}\n\nfn demo_min_1(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen::<u8>().get(gm, config).take(limit) {\n        println!(\"min!({}) = {}\", x, min!(x));\n    }\n}\n\nfn demo_min_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<u8>().get(gm, config).take(limit) {\n        println!(\"min!({}, {}) = {}\", x, y, min!(x, y));\n    }\n}\n\nfn demo_min_3(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"min!({}, {}, {}) = {}\", x, y, z, min!(x, y, z));\n    }\n}\n\nfn benchmark_max_1(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"max!(T)\",\n        BenchmarkType::Single,\n        unsigned_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(max!(x)))],\n    );\n}\n\nfn benchmark_max_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"max!(T, T)\",\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(max!(x, y)))],\n    );\n}\n\nfn benchmark_max_3(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"max!(T, T, T)\",\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(max!(x, y, z)))],\n    );\n}\n\nfn benchmark_min_1(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"min!(T)\",\n        BenchmarkType::Single,\n        unsigned_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(min!(x)))],\n    );\n}\n\nfn benchmark_min_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"min!(T, T)\",\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(min!(x, y)))],\n    );\n}\n\nfn benchmark_min_3(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"min!(T, T, T)\",\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(min!(x, y, z)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    macros::register(runner);\n}\n\nmod macros;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\nmacro_rules! unsigned_single_arg_demo {\n    ($name: ident, $f: ident) => {\n        fn $name<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n            for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n                println!(concat!(\"{}.\", stringify!($f), \"() = {}\"), u, u.$f());\n            }\n        }\n    };\n}\n\nmacro_rules! signed_single_arg_demo {\n    ($name: ident, $f: ident) => {\n        fn $name<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n            for i in signed_gen::<T>().get(gm, config).take(limit) {\n                println!(concat!(\"({}).\", stringify!($f), \"() = {}\"), i, i.$f());\n            }\n        }\n    };\n}\n\nmacro_rules! unsigned_single_arg_bench {\n    ($name: ident, $f: ident) => {\n        fn $name<T: PrimitiveUnsigned>(\n            gm: GenMode,\n            config: &GenConfig,\n            limit: usize,\n            file_name: &str,\n        ) {\n            run_benchmark(\n                &format!(concat!(\"{}.\", stringify!($f), \"()\"), T::NAME),\n                BenchmarkType::Single,\n                unsigned_gen::<T>().get(gm, config),\n                gm.name(),\n                limit,\n                file_name,\n                &unsigned_bit_bucketer(),\n                &mut [(\"Malachite\", &mut |u| no_out!(u.$f()))],\n            );\n        }\n    };\n}\n\nmacro_rules! signed_single_arg_bench {\n    ($name: ident, $f: ident) => {\n        fn $name<T: PrimitiveSigned>(\n            gm: GenMode,\n            config: &GenConfig,\n            limit: usize,\n            file_name: &str,\n        ) {\n            run_benchmark(\n                &format!(concat!(\"{}.\", stringify!($f), \"()\"), T::NAME),\n                BenchmarkType::Single,\n                signed_gen::<T>().get(gm, config),\n                gm.name(),\n                limit,\n                file_name,\n                &signed_bit_bucketer(),\n                &mut [(\"Malachite\", &mut |i| no_out!(i.$f()))],\n            );\n        }\n    };\n}\n\npub(crate) fn register(runner: &mut Runner) {\n    bools::register(runner);\n    chars::register(runner);\n    comparison::register(runner);\n    num::register(runner);\n    rational_sequences::register(runner);\n    rounding_modes::register(runner);\n    slices::register(runner);\n    strings::register(runner);\n    vecs::register(runner);\n}\n\nmod bools;\nmod chars;\nmod comparison;\nmod num;\nmod rational_sequences;\nmod rounding_modes;\nmod slices;\nmod strings;\nmod vecs;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{primitive_float_bucketer, signed_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen_var_1};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_abs_assign_signed);\n    register_primitive_float_demos!(runner, demo_abs_assign_primitive_float);\n    register_signed_benches!(runner, benchmark_abs_assign_signed);\n    register_primitive_float_benches!(runner, benchmark_abs_assign_primitive_float);\n}\n\nfn demo_abs_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut i in signed_gen_var_1::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.abs_assign();\n        println!(\"i := {old_i}; i.abs_assign(); i = {i}\");\n    }\n}\n\nfn demo_abs_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_f = f;\n        f.abs_assign();\n        println!(\n            \"i := {}; i.abs_assign(); i = {}\",\n            NiceFloat(old_f),\n            NiceFloat(f)\n        );\n    }\n}\n\nfn benchmark_abs_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.abs_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.abs_assign())],\n    );\n}\n\nfn benchmark_abs_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.abs_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |mut f| f.abs_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_abs_diff_assign);\n    register_unsigned_benches!(runner, benchmark_abs_diff_assign);\n}\n\nfn demo_abs_diff_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.abs_diff_assign(y);\n        println!(\"x := {old_x}; x.abs_diff_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_abs_diff_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.abs_diff_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.abs_diff_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    triple_max_bit_bucketer, triple_max_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_triple_gen, signed_triple_gen_var_1, unsigned_triple_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_add_mul_unsigned);\n    register_signed_demos!(runner, demo_add_mul_signed);\n    register_primitive_float_demos!(runner, demo_add_mul_primitive_float);\n    register_unsigned_demos!(runner, demo_add_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_add_mul_assign_signed);\n    register_primitive_float_demos!(runner, demo_add_mul_assign_primitive_float);\n\n    register_unsigned_benches!(runner, benchmark_add_mul_unsigned);\n    register_signed_benches!(runner, benchmark_add_mul_signed);\n    register_primitive_float_benches!(runner, benchmark_add_mul_primitive_float);\n    register_unsigned_benches!(runner, benchmark_add_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_add_mul_assign_signed);\n    register_primitive_float_benches!(runner, benchmark_add_mul_assign_primitive_float);\n}\n\nfn demo_add_mul_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in unsigned_triple_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\"{}.add_mul({}, {}) = {}\", x, y, z, x.add_mul(y, z));\n    }\n}\n\nfn demo_add_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in signed_triple_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\"({}).add_mul({}, {}) = {}\", x, y, z, x.add_mul(y, z));\n    }\n}\n\nfn demo_add_mul_primitive_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in primitive_float_triple_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).add_mul({}, {}) = {}\",\n            NiceFloat(x),\n            NiceFloat(y),\n            NiceFloat(z),\n            NiceFloat(x.add_mul(y, z))\n        );\n    }\n}\n\nfn demo_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_1::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.add_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_add_mul_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in signed_triple_gen_var_1::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.add_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_add_mul_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in primitive_float_triple_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.add_mul_assign(y, z);\n        println!(\n            \"x := {}; x.add_mul_assign({}, {}); x = {}\",\n            NiceFloat(old_x),\n            NiceFloat(y),\n            NiceFloat(z),\n            NiceFloat(x)\n        );\n    }\n}\n\nfn benchmark_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.add_mul(y, z)))],\n    );\n}\n\nfn benchmark_add_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.add_mul(y, z)))],\n    );\n}\n\nfn benchmark_add_mul_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        primitive_float_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_primitive_float_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.add_mul(y, z)))],\n    );\n}\n\nfn benchmark_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.add_mul_assign({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| x.add_mul_assign(y, z))],\n    );\n}\n\nfn benchmark_add_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.add_mul_assign({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| x.add_mul_assign(y, z))],\n    );\n}\n\nfn benchmark_add_mul_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.add_mul_assign({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        primitive_float_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_primitive_float_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| x.add_mul_assign(y, z))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/arithmetic_checked_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShl, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{pair_2_bucketer, pair_2_unsigned_abs_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_pair_gen_var_2, signed_unsigned_pair_gen_var_1, unsigned_pair_gen_var_2,\n    unsigned_signed_pair_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_arithmetic_checked_shl_unsigned_unsigned);\n    register_unsigned_signed_demos!(runner, demo_arithmetic_checked_shl_unsigned_signed);\n    register_signed_unsigned_demos!(runner, demo_arithmetic_checked_shl_signed_unsigned);\n    register_signed_signed_demos!(runner, demo_arithmetic_checked_shl_signed_signed);\n    register_unsigned_unsigned_benches!(runner, benchmark_arithmetic_checked_shl_unsigned_unsigned);\n    register_unsigned_signed_benches!(runner, benchmark_arithmetic_checked_shl_unsigned_signed);\n    register_signed_unsigned_benches!(runner, benchmark_arithmetic_checked_shl_signed_unsigned);\n    register_signed_signed_benches!(runner, benchmark_arithmetic_checked_shl_signed_signed);\n}\n\nfn demo_arithmetic_checked_shl_unsigned_unsigned<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in unsigned_pair_gen_var_2::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.arithmetic_checked_shl({}) = {:?}\",\n            n,\n            u,\n            n.arithmetic_checked_shl(u)\n        );\n    }\n}\n\nfn demo_arithmetic_checked_shl_unsigned_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in unsigned_signed_pair_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.arithmetic_checked_shl({}) = {:?}\",\n            n,\n            i,\n            n.arithmetic_checked_shl(i)\n        );\n    }\n}\n\nfn demo_arithmetic_checked_shl_signed_unsigned<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in signed_unsigned_pair_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).arithmetic_checked_shl({}) = {:?}\",\n            n,\n            u,\n            n.arithmetic_checked_shl(u)\n        );\n    }\n}\n\nfn demo_arithmetic_checked_shl_signed_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in signed_pair_gen_var_2::<T, U>().get(gm, config).take(limit) {\n        println!(\n            \"({}).arithmetic_checked_shl({}) = {:?}\",\n            n,\n            i,\n            n.arithmetic_checked_shl(i)\n        );\n    }\n}\n\nfn benchmark_arithmetic_checked_shl_unsigned_unsigned<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.arithmetic_checked_shl({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"other\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.arithmetic_checked_shl(y));\n        })],\n    );\n}\n\nfn benchmark_arithmetic_checked_shl_unsigned_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.arithmetic_checked_shl({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_pair_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_unsigned_abs_bucketer(\"other\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.arithmetic_checked_shl(y));\n        })],\n    );\n}\n\nfn benchmark_arithmetic_checked_shl_signed_unsigned<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.arithmetic_checked_shl({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"other\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.arithmetic_checked_shl(y));\n        })],\n    );\n}\n\nfn benchmark_arithmetic_checked_shl_signed_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.arithmetic_checked_shl({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_unsigned_abs_bucketer(\"other\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.arithmetic_checked_shl(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/arithmetic_checked_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShr, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_unsigned_abs_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_pair_gen_var_2, unsigned_signed_pair_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_signed_demos!(runner, demo_arithmetic_checked_shr_unsigned_signed);\n    register_signed_signed_demos!(runner, demo_arithmetic_checked_shr_signed_signed);\n    register_unsigned_signed_benches!(runner, benchmark_arithmetic_checked_shr_unsigned_signed);\n    register_signed_signed_benches!(runner, benchmark_arithmetic_checked_shr_signed_signed);\n}\n\nfn demo_arithmetic_checked_shr_unsigned_signed<\n    T: ArithmeticCheckedShr<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in unsigned_signed_pair_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.arithmetic_checked_shr({}) = {:?}\",\n            n,\n            i,\n            n.arithmetic_checked_shr(i)\n        );\n    }\n}\n\nfn demo_arithmetic_checked_shr_signed_signed<\n    T: ArithmeticCheckedShr<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in signed_pair_gen_var_2::<T, U>().get(gm, config).take(limit) {\n        println!(\n            \"({}).arithmetic_checked_shr({}) = {:?}\",\n            n,\n            i,\n            n.arithmetic_checked_shr(i)\n        );\n    }\n}\n\nfn benchmark_arithmetic_checked_shr_unsigned_signed<\n    T: ArithmeticCheckedShr<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.arithmetic_checked_shr({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_pair_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_unsigned_abs_bucketer(\"other\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.arithmetic_checked_shr(y));\n        })],\n    );\n}\n\nfn benchmark_arithmetic_checked_shr_signed_signed<\n    T: ArithmeticCheckedShr<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.arithmetic_checked_shr({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_unsigned_abs_bucketer(\"other\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.arithmetic_checked_shr(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    abs_usize_convertible_pair_max_bucketer, usize_convertible_pair_max_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_pair_gen_var_11, signed_pair_gen_var_12, unsigned_pair_gen_var_28,\n    unsigned_pair_gen_var_44,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_binomial_coefficient_unsigned);\n    register_signed_demos!(runner, demo_binomial_coefficient_signed);\n    register_unsigned_demos!(runner, demo_checked_binomial_coefficient_unsigned);\n    register_signed_demos!(runner, demo_checked_binomial_coefficient_signed);\n\n    register_unsigned_benches!(runner, benchmark_binomial_coefficient_unsigned);\n    register_signed_benches!(runner, benchmark_binomial_coefficient_signed);\n    register_unsigned_benches!(runner, benchmark_checked_binomial_coefficient_unsigned);\n    register_signed_benches!(runner, benchmark_checked_binomial_coefficient_signed);\n}\n\nfn demo_binomial_coefficient_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in unsigned_pair_gen_var_44().get(gm, config).take(limit) {\n        println!(\"C({}, {}) = {}\", n, k, T::binomial_coefficient(n, k));\n    }\n}\n\nfn demo_binomial_coefficient_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in signed_pair_gen_var_12().get(gm, config).take(limit) {\n        println!(\"C({}, {}) = {}\", n, k, T::binomial_coefficient(n, k));\n    }\n}\n\nfn demo_checked_binomial_coefficient_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in unsigned_pair_gen_var_28().get(gm, config).take(limit) {\n        println!(\n            \"C({}, {}) = {:?}\",\n            n,\n            k,\n            T::checked_binomial_coefficient(n, k)\n        );\n    }\n}\n\nfn demo_checked_binomial_coefficient_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in signed_pair_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"C({}, {}) = {:?}\",\n            n,\n            k,\n            T::checked_binomial_coefficient(n, k)\n        );\n    }\n}\n\nfn benchmark_binomial_coefficient_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\n            \"{}::binomial_coefficient({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_44().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &usize_convertible_pair_max_bucketer(\"n\", \"k\"),\n        &mut [(\"Malachite\", &mut |(n, k)| {\n            no_out!(T::binomial_coefficient(n, k));\n        })],\n    );\n}\n\nfn benchmark_binomial_coefficient_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<T as UnsignedAbs>::Output>,\n    <T as UnsignedAbs>::Output: Ord,\n{\n    run_benchmark(\n        &format!(\n            \"{}::binomial_coefficient({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_pair_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &abs_usize_convertible_pair_max_bucketer(\"n\", \"k\"),\n        &mut [(\"Malachite\", &mut |(n, k)| {\n            no_out!(T::binomial_coefficient(n, k));\n        })],\n    );\n}\n\nfn benchmark_checked_binomial_coefficient_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\n            \"{}::checked_binomial_coefficient({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_28().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &usize_convertible_pair_max_bucketer(\"n\", \"k\"),\n        &mut [(\"Malachite\", &mut |(n, k)| {\n            no_out!(T::checked_binomial_coefficient(n, k));\n        })],\n    );\n}\n\nfn benchmark_checked_binomial_coefficient_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<T as UnsignedAbs>::Output>,\n    <T as UnsignedAbs>::Output: Ord,\n{\n    run_benchmark(\n        &format!(\n            \"{}::checked_binomial_coefficient({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &abs_usize_convertible_pair_max_bucketer(\"n\", \"k\"),\n        &mut [(\"Malachite\", &mut |(n, k)| {\n            no_out!(T::checked_binomial_coefficient(n, k));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/ceiling.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_ceiling_assign);\n    register_primitive_float_benches!(runner, benchmark_ceiling_assign);\n}\n\nfn demo_ceiling_assign<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_f = f;\n        f.ceiling_assign();\n        println!(\n            \"i := {}; i.ceiling_assign(); i = {}\",\n            NiceFloat(old_f),\n            NiceFloat(f)\n        );\n    }\n}\n\nfn benchmark_ceiling_assign<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |mut f| f.ceiling_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/checked_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_checked_add_mul_unsigned);\n    register_signed_demos!(runner, demo_checked_add_mul_signed);\n\n    register_unsigned_benches!(runner, benchmark_checked_add_mul_unsigned);\n    register_signed_benches!(runner, benchmark_checked_add_mul_signed);\n}\n\nfn demo_checked_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.checked_add_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.checked_add_mul(y, z)\n        );\n    }\n}\n\nfn demo_checked_add_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).checked_add_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.checked_add_mul(y, z)\n        );\n    }\n}\n\nfn benchmark_checked_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.checked_add_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_checked_add_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.checked_add_mul(y, z));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/checked_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_checked_square_unsigned);\n    register_signed_demos!(runner, demo_checked_square_signed);\n    register_unsigned_benches!(runner, benchmark_checked_square_unsigned);\n    register_signed_benches!(runner, benchmark_checked_square_signed);\n}\n\nfn demo_checked_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.checked_square() = {:?}\", x, x.checked_square());\n    }\n}\n\nfn demo_checked_square_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).checked_square() = {:?}\", x, x.checked_square());\n    }\n}\n\nfn benchmark_checked_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_square()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.checked_square()))],\n    );\n}\n\nfn benchmark_checked_square_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_square()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.checked_square()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/checked_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_checked_sub_mul_unsigned);\n    register_signed_demos!(runner, demo_checked_sub_mul_signed);\n\n    register_unsigned_benches!(runner, benchmark_checked_sub_mul_unsigned);\n    register_signed_benches!(runner, benchmark_checked_sub_mul_signed);\n}\n\nfn demo_checked_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.checked_sub_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.checked_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_checked_sub_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).checked_sub_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.checked_sub_mul(y, z)\n        );\n    }\n}\n\nfn benchmark_checked_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.checked_sub_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_checked_sub_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.checked_sub_mul(y, z));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/coprime_with.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::coprime_with::{\n    coprime_with_check_2, coprime_with_check_2_3, coprime_with_check_2_3_5,\n};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_coprime_with);\n    register_unsigned_benches!(runner, benchmark_coprime_with_algorithms);\n}\n\nfn demo_coprime_with<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        if x.coprime_with(y) {\n            println!(\"{x} is coprime with {y}\");\n        } else {\n            println!(\"{x} is not coprime with {y}\");\n        }\n    }\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_coprime_with_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.coprime_with({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.coprime_with(y))),\n            (\"no divisibility check\", &mut |(x, y)| {\n                no_out!(x.gcd(y) == T::ONE);\n            }),\n            (\"check divisibility by 2\", &mut |(x, y)| {\n                no_out!(coprime_with_check_2(x, y));\n            }),\n            (\"check divisibility by 2 and 3\", &mut |(x, y)| {\n                no_out!(coprime_with_check_2_3(x, y));\n            }),\n            (\"check divisibility by 2, 3, and 5\", &mut |(x, y)| {\n                no_out!(coprime_with_check_2_3_5(x, y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen_var_3, unsigned_pair_gen_var_11};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_div_exact_unsigned);\n    register_signed_demos!(runner, demo_div_exact_signed);\n    register_unsigned_demos!(runner, demo_div_exact_assign_unsigned);\n    register_signed_demos!(runner, demo_div_exact_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_div_exact_unsigned);\n    register_signed_benches!(runner, benchmark_div_exact_signed);\n    register_unsigned_benches!(runner, benchmark_div_exact_assign_unsigned);\n    register_signed_benches!(runner, benchmark_div_exact_assign_signed);\n}\n\nfn demo_div_exact_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_11::<T>().get(gm, config).take(limit) {\n        println!(\"{}.div_exact({}) = {}\", x, y, x.div_exact(y));\n    }\n}\n\nfn demo_div_exact_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_3::<T>().get(gm, config).take(limit) {\n        println!(\"({}).div_exact({}) = {}\", x, y, x.div_exact(y));\n    }\n}\n\nfn demo_div_exact_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_11::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.div_exact_assign(y);\n        println!(\"x := {old_x}; x.div_exact_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_div_exact_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in signed_pair_gen_var_3::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.div_exact_assign(y);\n        println!(\"x := {old_x}; x.div_exact_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_div_exact_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_exact({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.div_exact(y)))],\n    );\n}\n\nfn benchmark_div_exact_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_exact({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.div_exact(y)))],\n    );\n}\n\nfn benchmark_div_exact_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_exact_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.div_exact_assign(y))],\n    );\n}\n\nfn benchmark_div_exact_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_exact_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.div_exact_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen_var_4, unsigned_pair_gen_var_12};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_div_mod_unsigned);\n    register_signed_demos!(runner, demo_div_mod_signed);\n    register_unsigned_demos!(runner, demo_div_assign_mod_unsigned);\n    register_signed_demos!(runner, demo_div_assign_mod_signed);\n    register_unsigned_demos!(runner, demo_div_rem_unsigned);\n    register_signed_demos!(runner, demo_div_rem_signed);\n    register_unsigned_demos!(runner, demo_div_assign_rem_unsigned);\n    register_signed_demos!(runner, demo_div_assign_rem_signed);\n    register_unsigned_demos!(runner, demo_ceiling_div_neg_mod);\n    register_unsigned_demos!(runner, demo_ceiling_div_assign_neg_mod);\n    register_signed_demos!(runner, demo_ceiling_div_mod);\n    register_signed_demos!(runner, demo_ceiling_div_assign_mod);\n\n    register_unsigned_benches!(runner, benchmark_div_mod_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_div_mod_signed_algorithms);\n    register_unsigned_benches!(runner, benchmark_div_assign_mod_unsigned);\n    register_signed_benches!(runner, benchmark_div_assign_mod_signed);\n    register_unsigned_benches!(runner, benchmark_div_rem_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_div_rem_signed_algorithms);\n    register_unsigned_benches!(runner, benchmark_div_assign_rem_unsigned);\n    register_signed_benches!(runner, benchmark_div_assign_rem_signed);\n    register_unsigned_benches!(runner, benchmark_ceiling_div_neg_mod_algorithms);\n    register_unsigned_benches!(runner, benchmark_ceiling_div_assign_neg_mod);\n    register_signed_benches!(runner, benchmark_ceiling_div_mod_algorithms);\n    register_signed_benches!(runner, benchmark_ceiling_div_assign_mod);\n}\n\nfn demo_div_mod_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.div_mod({}) = {:?}\", x, y, x.div_mod(y));\n    }\n}\n\nfn demo_div_mod_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_4::<T>().get(gm, config).take(limit) {\n        println!(\"({}).div_mod({}) = {:?}\", x, y, x.div_mod(y));\n    }\n}\n\nfn demo_div_assign_mod_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let r = x.div_assign_mod(y);\n        println!(\"x := {old_x}; x.div_assign_mod({y}) = {r}; x = {x}\");\n    }\n}\n\nfn demo_div_assign_mod_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in signed_pair_gen_var_4::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let r = x.div_assign_mod(y);\n        println!(\"x := {old_x}; x.div_assign_mod({y}) = {r}; x = {x}\");\n    }\n}\n\nfn demo_div_rem_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.div_rem({}) = {:?}\", x, y, x.div_rem(y));\n    }\n}\n\nfn demo_div_rem_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_4::<T>().get(gm, config).take(limit) {\n        println!(\"({}).div_rem({}) = {:?}\", x, y, x.div_rem(y));\n    }\n}\n\nfn demo_div_assign_rem_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let r = x.div_assign_rem(y);\n        println!(\"x := {old_x}; x.div_assign_rem({y}) = {r}; x = {x}\");\n    }\n}\n\nfn demo_div_assign_rem_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in signed_pair_gen_var_4::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let r = x.div_assign_rem(y);\n        println!(\"x := {old_x}; x.div_assign_rem({y}) = {r}; x = {x}\");\n    }\n}\n\nfn demo_ceiling_div_neg_mod<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.ceiling_div_neg_mod({}) = {:?}\",\n            x,\n            y,\n            x.ceiling_div_neg_mod(y)\n        );\n    }\n}\n\nfn demo_ceiling_div_assign_neg_mod<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let r = x.ceiling_div_assign_neg_mod(y);\n        println!(\"x := {old_x}; x.ceiling_div_assign_neg_mod({y}) = {r}; x = {x}\");\n    }\n}\n\nfn demo_ceiling_div_mod<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_4::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).ceiling_div_mod({}) = {:?}\",\n            x,\n            y,\n            x.ceiling_div_mod(y)\n        );\n    }\n}\n\nfn demo_ceiling_div_assign_mod<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in signed_pair_gen_var_4::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let r = x.ceiling_div_assign_mod(y);\n        println!(\"x := {old_x}; x.ceiling_div_assign_mod({y}) = {r}; x = {x}\");\n    }\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_div_mod_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using div_mod\", &mut |(x, y)| no_out!(x.div_mod(y))),\n            (\"using / and %\", &mut |(x, y)| no_out!((x / y, x % y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_div_mod_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using div_mod\", &mut |(x, y)| no_out!(x.div_mod(y))),\n            (\"using div_round and mod_op\", &mut |(x, y)| {\n                no_out!((x.div_round(y, Floor), x.mod_op(y)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_div_assign_mod_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_assign_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x.div_assign_mod(y)))],\n    );\n}\n\nfn benchmark_div_assign_mod_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_assign_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x.div_assign_mod(y)))],\n    );\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_div_rem_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_rem({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using div_rem\", &mut |(x, y)| no_out!(x.div_rem(y))),\n            (\"using / and %\", &mut |(x, y)| no_out!((x / y, x % y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_div_rem_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_rem({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using div_rem\", &mut |(x, y)| no_out!(x.div_rem(y))),\n            (\"using / and %\", &mut |(x, y)| no_out!((x / y, x % y))),\n        ],\n    );\n}\n\nfn benchmark_div_assign_rem_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_assign_rem({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x.div_assign_rem(y)))],\n    );\n}\n\nfn benchmark_div_assign_rem_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_assign_rem({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x.div_assign_rem(y)))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_ceiling_div_neg_mod_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_div_neg_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using ceiling_div_neg_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_neg_mod(y));\n            }),\n            (\"using div_round and neg_mod\", &mut |(x, y)| {\n                no_out!((x.div_round(y, Ceiling), x.neg_mod(y)));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_ceiling_div_mod_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_div_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using ceiling_div_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_mod(y));\n            }),\n            (\"using div_round and ceiling_mod\", &mut |(x, y)| {\n                no_out!((x.div_round(y, Ceiling), x.ceiling_mod(y)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_ceiling_div_assign_neg_mod<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_div_assign_neg_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.ceiling_div_assign_neg_mod(y));\n        })],\n    );\n}\n\nfn benchmark_ceiling_div_assign_mod<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_div_assign_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.ceiling_div_assign_mod(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_1_2_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_signed_rounding_mode_triple_gen_var_1, unsigned_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_div_round_unsigned);\n    register_signed_demos!(runner, demo_div_round_signed);\n    register_unsigned_demos!(runner, demo_div_round_assign_unsigned);\n    register_signed_demos!(runner, demo_div_round_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_div_round_unsigned);\n    register_signed_benches!(runner, benchmark_div_round_signed);\n    register_unsigned_benches!(runner, benchmark_div_round_assign_unsigned);\n    register_signed_benches!(runner, benchmark_div_round_assign_signed);\n}\n\nfn demo_div_round_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.div_round({}, {}) = {:?}\", x, y, rm, x.div_round(y, rm));\n    }\n}\n\nfn demo_div_round_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in signed_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).div_round({}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.div_round(y, rm)\n        );\n    }\n}\n\nfn demo_div_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let o = x.div_round_assign(y, rm);\n        println!(\"x := {old_x}; x.div_round_assign({y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_div_round_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in signed_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let o = x.div_round_assign(y, rm);\n        println!(\"x := {old_x}; x.div_round_assign({y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn benchmark_div_round_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_round({}, RoundingMode)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y, rm)| no_out!(x.div_round(y, rm)))],\n    );\n}\n\nfn benchmark_div_round_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_round({}, RoundingMode)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y, rm)| no_out!(x.div_round(y, rm)))],\n    );\n}\n\nfn benchmark_div_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_round_assign({}, RoundingMode)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.div_round_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_div_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.div_round_assign({}, RoundingMode)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.div_round_assign(y, rm));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_divisible_by_unsigned);\n    register_signed_demos!(runner, demo_divisible_by_signed);\n\n    register_unsigned_benches!(runner, benchmark_divisible_by_unsigned);\n    register_signed_benches!(runner, benchmark_divisible_by_signed);\n}\n\nfn demo_divisible_by_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        if x.divisible_by(y) {\n            println!(\"{x} is divisible by {y}\");\n        } else {\n            println!(\"{x} is not divisible by {y}\");\n        }\n    }\n}\n\nfn demo_divisible_by_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if x.divisible_by(y) {\n            println!(\"{x} is divisible by {y}\");\n        } else {\n            println!(\"{x} is not divisible by {y}\");\n        }\n    }\n}\n\nfn benchmark_divisible_by_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.divisible_by({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.divisible_by(y)))],\n    );\n}\n\nfn benchmark_divisible_by_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.divisible_by({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.divisible_by(y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_1_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_divisible_by_power_of_2_unsigned);\n    register_signed_demos!(runner, demo_divisible_by_power_of_2_signed);\n\n    register_unsigned_benches!(runner, benchmark_divisible_by_power_of_2_unsigned);\n    register_signed_benches!(runner, benchmark_divisible_by_power_of_2_signed);\n}\n\nfn demo_divisible_by_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (u, pow) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if u.divisible_by_power_of_2(pow) {\n            println!(\"{u} is divisible by 2^{pow}\");\n        } else {\n            println!(\"{u} is not divisible by 2^{pow}\");\n        }\n    }\n}\n\nfn demo_divisible_by_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (i, pow) in signed_unsigned_pair_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if i.divisible_by_power_of_2(pow) {\n            println!(\"{i} is divisible by 2^{pow}\");\n        } else {\n            println!(\"{i} is not divisible by 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_divisible_by_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.divisible_by_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.divisible_by_power_of_2(y));\n        })],\n    );\n}\n\nfn benchmark_divisible_by_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.divisible_by_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.divisible_by_power_of_2(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_eq_mod_unsigned);\n    register_signed_demos!(runner, demo_eq_mod_signed);\n\n    register_unsigned_benches!(runner, benchmark_eq_mod_unsigned);\n    register_signed_benches!(runner, benchmark_eq_mod_signed);\n}\n\nfn demo_eq_mod_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_mod(y, z) {\n            println!(\"{x} is equal to {y} mod {z}\");\n        } else {\n            println!(\"{x} is not equal to {y} mod {z}\");\n        }\n    }\n}\n\nfn demo_eq_mod_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        if x.eq_mod(y, z) {\n            println!(\"{x} is equal to {y} mod {z}\");\n        } else {\n            println!(\"{x} is not equal to {y} mod {z}\");\n        }\n    }\n}\n\nfn benchmark_eq_mod_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_mod({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.eq_mod(y, z)))],\n    );\n}\n\nfn benchmark_eq_mod_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_mod({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.eq_mod(y, z)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_1_2_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_signed_unsigned_triple_gen_var_2, unsigned_triple_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_eq_mod_power_of_2_unsigned);\n    register_signed_demos!(runner, demo_eq_mod_power_of_2_signed);\n\n    register_unsigned_benches!(runner, benchmark_eq_mod_power_of_2_unsigned);\n    register_signed_benches!(runner, benchmark_eq_mod_power_of_2_signed);\n}\n\nfn demo_eq_mod_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, pow) in unsigned_triple_gen_var_4::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_mod_power_of_2(y, pow) {\n            println!(\"{x} is equal to {y} mod 2^{pow}\");\n        } else {\n            println!(\"{x} is not equal to {y} mod 2^{pow}\");\n        }\n    }\n}\n\nfn demo_eq_mod_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, pow) in signed_signed_unsigned_triple_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_mod_power_of_2(y, pow) {\n            println!(\"{x} is equal to {y} mod 2^{pow}\");\n        } else {\n            println!(\"{x} is not equal to {y} mod 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_eq_mod_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_mod_power_of_2({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_4::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.eq_mod_power_of_2(y, pow));\n        })],\n    );\n}\n\nfn benchmark_eq_mod_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_mod_power_of_2({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_signed_unsigned_triple_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.eq_mod_power_of_2(y, pow));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::extended_gcd::extended_gcd_unsigned_binary;\nuse malachite_base::num::arithmetic::traits::ExtendedGcd;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::num::arithmetic::extended_gcd::extended_gcd_unsigned_euclidean;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_signed_match_demos!(runner, demo_extended_gcd_unsigned);\n    register_unsigned_signed_match_demos!(runner, demo_extended_gcd_signed);\n\n    register_unsigned_signed_match_benches!(runner, benchmark_extended_gcd_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_extended_gcd_signed);\n}\n\nfn demo_extended_gcd_unsigned<\n    U: ExtendedGcd<Cofactor = S> + PrimitiveUnsigned,\n    S: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<U>().get(gm, config).take(limit) {\n        println!(\"{}.extended_gcd({}) = {:?}\", x, y, x.extended_gcd(y));\n    }\n}\n\nfn demo_extended_gcd_signed<U: PrimitiveUnsigned, S: ExtendedGcd<Gcd = U> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in signed_pair_gen::<S>().get(gm, config).take(limit) {\n        println!(\"{}.extended_gcd({}) = {:?}\", x, y, x.extended_gcd(y));\n    }\n}\n\nfn benchmark_extended_gcd_algorithms_unsigned<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.extended_gcd({})\", U::NAME, U::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_27::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.extended_gcd(y))),\n            (\"Euclidean\", &mut |(x, y)| {\n                no_out!(extended_gcd_unsigned_euclidean::<U, S>(x, y));\n            }),\n            (\"binary\", &mut |(x, y)| {\n                no_out!(extended_gcd_unsigned_binary::<U, S>(x, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_extended_gcd_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.extended_gcd({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"default\", &mut |(x, y)| no_out!(x.extended_gcd(y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::factorial::checked_multifactorial_naive;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    unsigned_direct_bucketer, usize_convertible_pair_max_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_23, unsigned_gen_var_24, unsigned_gen_var_25,\n    unsigned_pair_gen_var_12, unsigned_pair_gen_var_43,\n};\nuse malachite_base::test_util::num::arithmetic::factorial::{\n    checked_double_factorial_naive, checked_factorial_naive, checked_subfactorial_naive,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_factorial);\n    register_unsigned_demos!(runner, demo_checked_factorial);\n    register_unsigned_demos!(runner, demo_double_factorial);\n    register_unsigned_demos!(runner, demo_checked_double_factorial);\n    register_unsigned_demos!(runner, demo_multifactorial);\n    register_unsigned_demos!(runner, demo_checked_multifactorial);\n    register_unsigned_demos!(runner, demo_subfactorial);\n    register_unsigned_demos!(runner, demo_checked_subfactorial);\n\n    register_unsigned_benches!(runner, benchmark_factorial_algorithms);\n    register_unsigned_benches!(runner, benchmark_checked_factorial);\n    register_unsigned_benches!(runner, benchmark_double_factorial_algorithms);\n    register_unsigned_benches!(runner, benchmark_checked_double_factorial);\n    register_unsigned_benches!(runner, benchmark_multifactorial_algorithms);\n    register_unsigned_benches!(runner, benchmark_checked_multifactorial);\n    register_unsigned_benches!(runner, benchmark_subfactorial_algorithms);\n    register_unsigned_benches!(runner, benchmark_checked_subfactorial);\n}\n\nfn demo_factorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_23::<T>().get(gm, config).take(limit) {\n        println!(\"{}! = {}\", n, T::factorial(n));\n    }\n}\n\nfn demo_checked_factorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen().get(gm, config).take(limit) {\n        println!(\"{}! = {:?}\", n, T::checked_factorial(n));\n    }\n}\n\nfn demo_double_factorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_24::<T>().get(gm, config).take(limit) {\n        println!(\"{}!! = {}\", n, T::double_factorial(n));\n    }\n}\n\nfn demo_checked_double_factorial<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen().get(gm, config).take(limit) {\n        println!(\"{}!! = {:?}\", n, T::checked_double_factorial(n));\n    }\n}\n\nfn demo_multifactorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in unsigned_pair_gen_var_43::<T>().get(gm, config).take(limit) {\n        if m <= 5 {\n            print!(\"{n}\");\n            for _ in 0..m {\n                print!(\"!\");\n            }\n            println!(\" = {}\", T::multifactorial(n, m));\n        } else {\n            println!(\"{}[!^{}] = {}\", n, m, T::multifactorial(n, m));\n        }\n    }\n}\n\nfn demo_checked_multifactorial<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, m) in unsigned_pair_gen_var_12::<u64, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if m <= 5 {\n            print!(\"{n}\");\n            for _ in 0..m {\n                print!(\"!\");\n            }\n            println!(\" = {:?}\", T::checked_multifactorial(n, m));\n        } else {\n            println!(\"{}[!^{}] = {:?}\", n, m, T::checked_multifactorial(n, m));\n        }\n    }\n}\n\nfn demo_subfactorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_25::<T>().get(gm, config).take(limit) {\n        println!(\"!{} = {}\", n, T::subfactorial(n));\n    }\n}\n\nfn demo_checked_subfactorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen().get(gm, config).take(limit) {\n        println!(\"!{} = {:?}\", n, T::checked_subfactorial(n));\n    }\n}\n\nfn benchmark_factorial_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::factorial(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_23::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(T::factorial(n))),\n            (\"naive\", &mut |n| {\n                no_out!(checked_factorial_naive::<T>(n).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_factorial<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::checked_factorial(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::checked_factorial(n)))],\n    );\n}\n\nfn benchmark_double_factorial_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::double_factorial(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_24::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(T::double_factorial(n))),\n            (\"naive\", &mut |n| {\n                no_out!(checked_double_factorial_naive::<T>(n).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_double_factorial<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::checked_double_factorial(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(T::checked_double_factorial(n));\n        })],\n    );\n}\n\nfn benchmark_multifactorial_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::multifactorial(u64, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_43::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &usize_convertible_pair_max_bucketer(\"n\", \"m\"),\n        &mut [\n            (\"default\", &mut |(n, m)| no_out!(T::multifactorial(n, m))),\n            (\"naive\", &mut |(n, m)| {\n                no_out!(checked_multifactorial_naive::<T>(n, m).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_multifactorial<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::checked_multifactorial(u64, u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &usize_convertible_pair_max_bucketer(\"n\", \"m\"),\n        &mut [(\"Malachite\", &mut |(n, m)| {\n            no_out!(T::checked_multifactorial(n, m));\n        })],\n    );\n}\n\nfn benchmark_subfactorial_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::subfactorial(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_25::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(T::subfactorial(n))),\n            (\"naive\", &mut |n| {\n                no_out!(checked_subfactorial_naive::<T>(n).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_subfactorial<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::checked_subfactorial(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::checked_subfactorial(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/floor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_floor_assign);\n    register_primitive_float_benches!(runner, benchmark_floor_assign);\n}\n\nfn demo_floor_assign<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_f = f;\n        f.floor_assign();\n        println!(\n            \"i := {}; i.floor_assign(); i = {}\",\n            NiceFloat(old_f),\n            NiceFloat(f)\n        );\n    }\n}\n\nfn benchmark_floor_assign<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |mut f| f.floor_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::gcd::{gcd_binary, gcd_euclidean, gcd_fast_a, gcd_fast_b};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_gcd);\n    register_unsigned_demos!(runner, demo_gcd_assign);\n\n    register_unsigned_benches!(runner, benchmark_gcd_algorithms);\n    register_unsigned_benches!(runner, benchmark_gcd_assign);\n}\n\nfn demo_gcd<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.gcd({}) = {}\", x, y, x.gcd(y));\n    }\n}\n\nfn demo_gcd_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.gcd_assign(y);\n        println!(\"x := {old_x}; x.gcd_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_gcd_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gcd({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.gcd(y))),\n            (\"Euclidean\", &mut |(x, y)| no_out!(gcd_euclidean(x, y))),\n            (\"binary\", &mut |(x, y)| no_out!(gcd_binary(x, y))),\n            (\"fast A\", &mut |(x, y)| no_out!(gcd_fast_a(x, y))),\n            (\"fast B\", &mut |(x, y)| no_out!(gcd_fast_b(x, y))),\n        ],\n    );\n}\n\nfn benchmark_gcd_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gcd_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.gcd_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_is_power_of_2);\n    register_primitive_float_benches!(runner, benchmark_is_power_of_2);\n}\n\nfn demo_is_power_of_2<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        if f.is_power_of_2() {\n            println!(\"{} is a power of 2\", NiceFloat(f));\n        } else {\n            println!(\"{} is not a power of 2\", NiceFloat(f));\n        }\n    }\n}\n\nfn benchmark_is_power_of_2<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_power_of_2()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(f.is_power_of_2()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::kronecker_symbol::{\n    jacobi_symbol_unsigned_double_fast_2, jacobi_symbol_unsigned_simple,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{HasHalf, JoinHalves, WrappingFrom};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_max_bit_bucketer, quadruple_max_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_pair_gen_var_8, unsigned_pair_gen_var_27, unsigned_pair_gen_var_40,\n    unsigned_quadruple_gen_var_12,\n};\nuse malachite_base::test_util::num::arithmetic::kronecker_symbol::{\n    jacobi_symbol_unsigned_double_fast_1, jacobi_symbol_unsigned_double_simple,\n    jacobi_symbol_unsigned_fast_1, jacobi_symbol_unsigned_fast_2_1,\n    jacobi_symbol_unsigned_fast_2_2, jacobi_symbol_unsigned_fast_2_3,\n    jacobi_symbol_unsigned_fast_2_4,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_jacobi_symbol_unsigned_double_fast_1);\n    register_unsigned_demos!(runner, demo_jacobi_symbol_unsigned_double_fast_2);\n    register_unsigned_demos!(runner, demo_jacobi_symbol_unsigned);\n    register_unsigned_signed_match_demos!(runner, demo_jacobi_symbol_signed);\n    register_unsigned_demos!(runner, demo_kronecker_symbol_unsigned);\n    register_signed_demos!(runner, demo_kronecker_symbol_signed);\n\n    register_generic_benches_2!(\n        runner,\n        benchmark_jacobi_symbol_unsigned_double_algorithms,\n        [u8, u16],\n        [u16, u32],\n        [u32, u64],\n        [u64, u128]\n    );\n    register_unsigned_benches!(runner, benchmark_jacobi_symbol_unsigned_algorithms);\n    register_unsigned_signed_match_benches!(runner, benchmark_jacobi_symbol_signed);\n    register_unsigned_benches!(runner, benchmark_kronecker_symbol_unsigned);\n    register_signed_benches!(runner, benchmark_kronecker_symbol_signed);\n}\n\nfn demo_jacobi_symbol_unsigned_double_fast_1<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x1, x0, y1, y0) in unsigned_quadruple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"jacobi_symbol_unsigned_double_fast_1({}, {}, {}, {}) = {}\",\n            x1,\n            x0,\n            y1,\n            y0,\n            jacobi_symbol_unsigned_double_fast_1(x1, x0, y1, y0)\n        );\n    }\n}\n\nfn demo_jacobi_symbol_unsigned_double_fast_2<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x1, x0, y1, y0) in unsigned_quadruple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"jacobi_symbol_unsigned_double_fast_1({}, {}, {}, {}) = {}\",\n            x1,\n            x0,\n            y1,\n            y0,\n            jacobi_symbol_unsigned_double_fast_2(x1, x0, y1, y0)\n        );\n    }\n}\n\nfn demo_jacobi_symbol_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_40::<T>().get(gm, config).take(limit) {\n        println!(\"{}.jacobi_symbol({}) = {}\", x, y, x.jacobi_symbol(y));\n    }\n}\n\nfn demo_jacobi_symbol_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in signed_pair_gen_var_8::<U, S>().get(gm, config).take(limit) {\n        println!(\"({}).jacobi_symbol({}) = {}\", x, y, x.jacobi_symbol(y));\n    }\n}\n\nfn demo_kronecker_symbol_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.kronecker_symbol({}) = {}\", x, y, x.kronecker_symbol(y));\n    }\n}\n\nfn demo_kronecker_symbol_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).kronecker_symbol({}) = {}\",\n            x,\n            y,\n            x.kronecker_symbol(y)\n        );\n    }\n}\n\nfn benchmark_jacobi_symbol_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.jacobi_symbol({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_40::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.jacobi_symbol(y))),\n            (\"simple\", &mut |(x, y)| {\n                no_out!(jacobi_symbol_unsigned_simple(x, y));\n            }),\n            (\"fast 1\", &mut |(x, y)| {\n                no_out!(jacobi_symbol_unsigned_fast_1(x, y));\n            }),\n            (\"fast 2.1\", &mut |(x, y)| {\n                no_out!(jacobi_symbol_unsigned_fast_2_1(x, y));\n            }),\n            (\"fast 2.2\", &mut |(x, y)| {\n                no_out!(jacobi_symbol_unsigned_fast_2_2(x, y));\n            }),\n            (\"fast 2.3\", &mut |(x, y)| {\n                no_out!(jacobi_symbol_unsigned_fast_2_3(x, y));\n            }),\n            (\"fast 2.4\", &mut |(x, y)| {\n                no_out!(jacobi_symbol_unsigned_fast_2_4(x, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_jacobi_symbol_unsigned_double_algorithms<\n    T: PrimitiveUnsigned,\n    D: HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"jacobi_symbol_unsigned_double({}, {}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_quadruple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_max_bit_bucketer(\"x1\", \"x0\", \"y1\", \"y0\"),\n        &mut [\n            (\"simple\", &mut |(x1, x0, y1, y0)| {\n                no_out!(jacobi_symbol_unsigned_double_simple::<T, D>(x1, x0, y1, y0));\n            }),\n            (\"fast 1\", &mut |(x1, x0, y1, y0)| {\n                no_out!(jacobi_symbol_unsigned_double_fast_1(x1, x0, y1, y0));\n            }),\n            (\"fast 2\", &mut |(x1, x0, y1, y0)| {\n                no_out!(jacobi_symbol_unsigned_double_fast_2(x1, x0, y1, y0));\n            }),\n        ],\n    );\n}\n\nfn benchmark_jacobi_symbol_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.jacobi_symbol({})\", S::NAME, S::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_8::<U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"default\", &mut |(x, y)| no_out!(x.jacobi_symbol(y)))],\n    );\n}\n\nfn benchmark_kronecker_symbol_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.kronecker_symbol({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.kronecker_symbol(y)))],\n    );\n}\n\nfn benchmark_kronecker_symbol_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.kronecker_symbol({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"default\", &mut |(x, y)| no_out!(x.kronecker_symbol(y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/lcm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{unsigned_pair_gen_var_33, unsigned_pair_gen_var_34};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_lcm);\n    register_unsigned_demos!(runner, demo_lcm_assign);\n    register_unsigned_demos!(runner, demo_checked_lcm);\n\n    register_unsigned_benches!(runner, benchmark_lcm);\n    register_unsigned_benches!(runner, benchmark_lcm_assign);\n    register_unsigned_benches!(runner, benchmark_checked_lcm);\n}\n\nfn demo_lcm<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_34::<T>().get(gm, config).take(limit) {\n        println!(\"{}.lcm({}) = {}\", x, y, x.lcm(y));\n    }\n}\n\nfn demo_lcm_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in unsigned_pair_gen_var_34::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.lcm_assign(y);\n        println!(\"x := {old_x}; x.lcm_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_checked_lcm<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_33::<T>().get(gm, config).take(limit) {\n        println!(\"{}.checked_lcm({}) = {:?}\", x, y, x.checked_lcm(y));\n    }\n}\n\nfn benchmark_lcm<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lcm({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_34::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lcm(y)))],\n    );\n}\n\nfn benchmark_lcm_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lcm_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_34::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.lcm_assign(y))],\n    );\n}\n\nfn benchmark_checked_lcm<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_lcm({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_33::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.checked_lcm(y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::log_base::{ceiling_log_base_naive, checked_log_base_naive};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_1_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_24;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_floor_log_base);\n    register_unsigned_demos!(runner, demo_ceiling_log_base);\n    register_unsigned_demos!(runner, demo_checked_log_base);\n    register_unsigned_benches!(runner, benchmark_floor_log_base);\n    register_unsigned_benches!(runner, benchmark_ceiling_log_base_algorithms);\n    register_unsigned_benches!(runner, benchmark_checked_log_base_algorithms);\n}\n\nfn demo_floor_log_base<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, b) in unsigned_pair_gen_var_24::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.floor_log_base({}) = {}\", n, b, n.floor_log_base(b));\n    }\n}\n\nfn demo_ceiling_log_base<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, b) in unsigned_pair_gen_var_24::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.ceiling_log_base({}) = {}\", n, b, n.ceiling_log_base(b));\n    }\n}\n\nfn demo_checked_log_base<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, b) in unsigned_pair_gen_var_24::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.checked_log_base({}) = {:?}\",\n            n,\n            b,\n            n.checked_log_base(b)\n        );\n    }\n}\n\nfn benchmark_floor_log_base<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_log_base({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_24::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, base)| {\n            no_out!(n.floor_log_base(base));\n        })],\n    );\n}\n\nfn benchmark_ceiling_log_base_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_log_base({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_24::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, base)| {\n                no_out!(n.ceiling_log_base(base));\n            }),\n            (\"naive\", &mut |(n, base)| {\n                no_out!(ceiling_log_base_naive(n, base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_log_base_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_log_base({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_24::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, base)| {\n                no_out!(n.checked_log_base(base));\n            }),\n            (\"naive\", &mut |(n, base)| {\n                no_out!(checked_log_base_naive(n, base));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, primitive_int_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen_var_18, unsigned_gen_var_1};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_floor_log_base_2_unsigned);\n    register_unsigned_demos!(runner, demo_ceiling_log_base_2_unsigned);\n    register_unsigned_demos!(runner, demo_checked_log_base_2_unsigned);\n    register_primitive_float_demos!(runner, demo_floor_log_base_2_primitive_float);\n    register_primitive_float_demos!(runner, demo_ceiling_log_base_2_primitive_float);\n    register_primitive_float_demos!(runner, demo_checked_log_base_2_primitive_float);\n    register_unsigned_benches!(runner, benchmark_floor_log_base_2_unsigned);\n    register_unsigned_benches!(runner, benchmark_ceiling_log_base_2_unsigned);\n    register_unsigned_benches!(runner, benchmark_checked_log_base_2_unsigned);\n    register_primitive_float_benches!(runner, benchmark_floor_log_base_2_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_ceiling_log_base_2_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_checked_log_base_2_primitive_float);\n}\n\nfn demo_floor_log_base_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\"{}.floor_log_base_2() = {}\", n, n.floor_log_base_2());\n    }\n}\n\nfn demo_ceiling_log_base_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\"{}.ceiling_log_base_2() = {}\", n, n.ceiling_log_base_2());\n    }\n}\n\nfn demo_checked_log_base_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\"{}.checked_log_base_2() = {:?}\", n, n.checked_log_base_2());\n    }\n}\n\nfn demo_floor_log_base_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in primitive_float_gen_var_18::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.floor_log_base_2() = {}\",\n            NiceFloat(n),\n            n.floor_log_base_2()\n        );\n    }\n}\n\nfn demo_ceiling_log_base_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in primitive_float_gen_var_18::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.ceiling_log_base_2() = {}\",\n            NiceFloat(n),\n            n.ceiling_log_base_2()\n        );\n    }\n}\n\nfn demo_checked_log_base_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in primitive_float_gen_var_18::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.checked_log_base_2() = {:?}\",\n            NiceFloat(n),\n            n.checked_log_base_2()\n        );\n    }\n}\n\nfn benchmark_floor_log_base_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_log_base_2()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.floor_log_base_2()))],\n    );\n}\n\nfn benchmark_ceiling_log_base_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_log_base_2()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.ceiling_log_base_2()))],\n    );\n}\n\nfn benchmark_checked_log_base_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_log_base_2()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.checked_log_base_2()))],\n    );\n}\n\nfn benchmark_floor_log_base_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_log_base_2()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_18::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.floor_log_base_2()))],\n    );\n}\n\nfn benchmark_ceiling_log_base_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_log_base_2()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_18::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.ceiling_log_base_2()))],\n    );\n}\n\nfn benchmark_checked_log_base_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_log_base_2()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_18::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.checked_log_base_2()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::log_base_power_of_2::ceiling_log_base_power_of_2_naive;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bit_bucketer, pair_1_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_unsigned_pair_gen_var_3, unsigned_pair_gen_var_21,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_floor_log_base_power_of_2_unsigned);\n    register_primitive_float_demos!(runner, demo_floor_log_base_power_of_2_primitive_float);\n    register_unsigned_demos!(runner, demo_ceiling_log_base_power_of_2_unsigned);\n    register_primitive_float_demos!(runner, demo_ceiling_log_base_power_of_2_primitive_float);\n    register_unsigned_demos!(runner, demo_checked_log_base_power_of_2_unsigned);\n    register_primitive_float_demos!(runner, demo_checked_log_base_power_of_2_primitive_float);\n\n    register_unsigned_benches!(runner, benchmark_floor_log_base_power_of_2_unsigned);\n    register_primitive_float_benches!(runner, benchmark_floor_log_base_power_of_2_primitive_float);\n    register_unsigned_benches!(\n        runner,\n        benchmark_ceiling_log_base_power_of_2_algorithms_unsigned\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_ceiling_log_base_power_of_2_primitive_float\n    );\n    register_unsigned_benches!(runner, benchmark_checked_log_base_power_of_2_unsigned);\n    register_primitive_float_benches!(\n        runner,\n        benchmark_checked_log_base_power_of_2_primitive_float\n    );\n}\n\nfn demo_floor_log_base_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_pair_gen_var_21::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.floor_log_base_power_of_2({}) = {}\",\n            n,\n            pow,\n            n.floor_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_floor_log_base_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in primitive_float_unsigned_pair_gen_var_3::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.floor_log_base_power_of_2({}) = {}\",\n            NiceFloat(n),\n            pow,\n            n.floor_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_ceiling_log_base_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_pair_gen_var_21::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.ceiling_log_base_power_of_2({}) = {}\",\n            n,\n            pow,\n            n.ceiling_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_ceiling_log_base_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in primitive_float_unsigned_pair_gen_var_3::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.ceiling_log_base_power_of_2({}) = {}\",\n            NiceFloat(n),\n            pow,\n            n.ceiling_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_checked_log_base_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_pair_gen_var_21::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.checked_log_base_power_of_2({}) = {:?}\",\n            n,\n            pow,\n            n.checked_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_checked_log_base_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in primitive_float_unsigned_pair_gen_var_3::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.checked_log_base_power_of_2({}) = {:?}\",\n            NiceFloat(n),\n            pow,\n            n.checked_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn benchmark_floor_log_base_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_log_base_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_21::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.floor_log_base_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_floor_log_base_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_log_base_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_unsigned_pair_gen_var_3::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.floor_log_base_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_ceiling_log_base_power_of_2_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_log_base_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_21::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, pow)| {\n                no_out!(n.ceiling_log_base_power_of_2(pow));\n            }),\n            (\"naive\", &mut |(n, pow)| {\n                no_out!(ceiling_log_base_power_of_2_naive(n, pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_ceiling_log_base_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_log_base_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_unsigned_pair_gen_var_3::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.ceiling_log_base_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_checked_log_base_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_log_base_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_21::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.checked_log_base_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_checked_log_base_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_log_base_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_unsigned_pair_gen_var_3::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.checked_log_base_power_of_2(pow));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    abs::register(runner);\n    abs_diff::register(runner);\n    add_mul::register(runner);\n    arithmetic_checked_shl::register(runner);\n    arithmetic_checked_shr::register(runner);\n    binomial_coefficient::register(runner);\n    ceiling::register(runner);\n    checked_add_mul::register(runner);\n    checked_square::register(runner);\n    checked_sub_mul::register(runner);\n    coprime_with::register(runner);\n    div_exact::register(runner);\n    div_mod::register(runner);\n    div_round::register(runner);\n    divisible_by::register(runner);\n    divisible_by_power_of_2::register(runner);\n    eq_mod::register(runner);\n    eq_mod_power_of_2::register(runner);\n    extended_gcd::register(runner);\n    factorial::register(runner);\n    floor::register(runner);\n    gcd::register(runner);\n    is_power_of_2::register(runner);\n    kronecker_symbol::register(runner);\n    lcm::register(runner);\n    log_base::register(runner);\n    log_base_2::register(runner);\n    log_base_power_of_2::register(runner);\n    mod_inverse::register(runner);\n    mod_is_reduced::register(runner);\n    mod_add::register(runner);\n    mod_mul::register(runner);\n    mod_neg::register(runner);\n    mod_op::register(runner);\n    mod_pow::register(runner);\n    mod_power_of_2::register(runner);\n    mod_power_of_2_add::register(runner);\n    mod_power_of_2_inverse::register(runner);\n    mod_power_of_2_is_reduced::register(runner);\n    mod_power_of_2_mul::register(runner);\n    mod_power_of_2_pow::register(runner);\n    mod_power_of_2_shl::register(runner);\n    mod_power_of_2_shr::register(runner);\n    mod_power_of_2_square::register(runner);\n    mod_power_of_2_neg::register(runner);\n    mod_power_of_2_sub::register(runner);\n    mod_shl::register(runner);\n    mod_shr::register(runner);\n    mod_square::register(runner);\n    mod_sub::register(runner);\n    neg::register(runner);\n    next_power_of_2::register(runner);\n    overflowing_abs::register(runner);\n    overflowing_add::register(runner);\n    overflowing_add_mul::register(runner);\n    overflowing_div::register(runner);\n    overflowing_mul::register(runner);\n    overflowing_neg::register(runner);\n    overflowing_pow::register(runner);\n    overflowing_square::register(runner);\n    overflowing_sub::register(runner);\n    overflowing_sub_mul::register(runner);\n    parity::register(runner);\n    pow::register(runner);\n    power_of_2::register(runner);\n    primorial::register(runner);\n    reciprocal::register(runner);\n    root::register(runner);\n    rotate::register(runner);\n    round_to_multiple::register(runner);\n    round_to_multiple_of_power_of_2::register(runner);\n    saturating_abs::register(runner);\n    saturating_add::register(runner);\n    saturating_add_mul::register(runner);\n    saturating_mul::register(runner);\n    saturating_neg::register(runner);\n    saturating_pow::register(runner);\n    saturating_square::register(runner);\n    saturating_sub::register(runner);\n    saturating_sub_mul::register(runner);\n    shl_round::register(runner);\n    shr_round::register(runner);\n    sign::register(runner);\n    sqrt::register(runner);\n    square::register(runner);\n    sub_mul::register(runner);\n    wrapping_abs::register(runner);\n    wrapping_add::register(runner);\n    wrapping_add_mul::register(runner);\n    wrapping_div::register(runner);\n    wrapping_mul::register(runner);\n    wrapping_neg::register(runner);\n    wrapping_pow::register(runner);\n    wrapping_square::register(runner);\n    wrapping_sub::register(runner);\n    wrapping_sub_mul::register(runner);\n    x_mul_y_to_zz::register(runner);\n    xx_add_yy_to_zz::register(runner);\n    xx_div_mod_y_to_qr::register(runner);\n    xx_sub_yy_to_zz::register(runner);\n    xxx_add_yyy_to_zzz::register(runner);\n    xxx_sub_yyy_to_zzz::register(runner);\n    xxxx_add_yyyy_to_zzzz::register(runner);\n}\n\nmod abs;\nmod abs_diff;\nmod add_mul;\nmod arithmetic_checked_shl;\nmod arithmetic_checked_shr;\nmod binomial_coefficient;\nmod ceiling;\nmod checked_add_mul;\nmod checked_square;\nmod checked_sub_mul;\nmod coprime_with;\nmod div_exact;\nmod div_mod;\nmod div_round;\nmod divisible_by;\nmod divisible_by_power_of_2;\nmod eq_mod;\nmod eq_mod_power_of_2;\nmod extended_gcd;\nmod factorial;\nmod floor;\nmod gcd;\nmod is_power_of_2;\nmod kronecker_symbol;\nmod lcm;\nmod log_base;\nmod log_base_2;\nmod log_base_power_of_2;\nmod mod_add;\nmod mod_inverse;\nmod mod_is_reduced;\nmod mod_mul;\nmod mod_neg;\nmod mod_op;\nmod mod_pow;\nmod mod_power_of_2;\nmod mod_power_of_2_add;\nmod mod_power_of_2_inverse;\nmod mod_power_of_2_is_reduced;\nmod mod_power_of_2_mul;\nmod mod_power_of_2_neg;\nmod mod_power_of_2_pow;\nmod mod_power_of_2_shl;\nmod mod_power_of_2_shr;\nmod mod_power_of_2_square;\nmod mod_power_of_2_sub;\nmod mod_shl;\nmod mod_shr;\nmod mod_square;\nmod mod_sub;\nmod neg;\nmod next_power_of_2;\nmod overflowing_abs;\nmod overflowing_add;\nmod overflowing_add_mul;\nmod overflowing_div;\nmod overflowing_mul;\nmod overflowing_neg;\nmod overflowing_pow;\nmod overflowing_square;\nmod overflowing_sub;\nmod overflowing_sub_mul;\nmod parity;\nmod pow;\nmod power_of_2;\nmod primorial;\nmod reciprocal;\nmod root;\nmod rotate;\nmod round_to_multiple;\nmod round_to_multiple_of_power_of_2;\nmod saturating_abs;\nmod saturating_add;\nmod saturating_add_mul;\nmod saturating_mul;\nmod saturating_neg;\nmod saturating_pow;\nmod saturating_square;\nmod saturating_sub;\nmod saturating_sub_mul;\nmod shl_round;\nmod shr_round;\nmod sign;\nmod sqrt;\nmod square;\nmod sub_mul;\nmod wrapping_abs;\nmod wrapping_add;\nmod wrapping_add_mul;\nmod wrapping_div;\nmod wrapping_mul;\nmod wrapping_neg;\nmod wrapping_pow;\nmod wrapping_square;\nmod wrapping_sub;\nmod wrapping_sub_mul;\nmod x_mul_y_to_zz;\nmod xx_add_yy_to_zz;\nmod xx_div_mod_y_to_qr;\nmod xx_sub_yy_to_zz;\nmod xxx_add_yyy_to_zzz;\nmod xxx_sub_yyy_to_zzz;\nmod xxxx_add_yyyy_to_zzzz;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_12;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_add);\n    register_unsigned_demos!(runner, demo_mod_add_assign);\n    register_unsigned_benches!(runner, benchmark_mod_add);\n    register_unsigned_benches!(runner, benchmark_mod_add_assign);\n}\n\nfn demo_mod_add<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in unsigned_triple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} + {} ≡ {} mod {}\", x, y, x.mod_add(y, m), m);\n    }\n}\n\nfn demo_mod_add_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in unsigned_triple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_add_assign(y, m);\n        println!(\"x := {old_x}; x.mod_add_assign({y}, {m}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_add<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_add({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(x, y, m)| no_out!(x.mod_add(y, m)))],\n    );\n}\n\nfn benchmark_mod_add_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_add({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, m)| x.mod_add_assign(y, m))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_inverse::mod_inverse_binary;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::pair_2_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_38;\nuse malachite_base::test_util::num::arithmetic::mod_inverse::mod_inverse_euclidean;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_inverse);\n    register_unsigned_signed_match_benches!(runner, benchmark_mod_inverse_algorithms);\n}\n\nfn demo_mod_inverse<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in unsigned_pair_gen_var_38::<T>().get(gm, config).take(limit) {\n        if let Some(inverse) = n.mod_inverse(m) {\n            println!(\"{n}⁻¹ ≡ {inverse} mod {m}\");\n        } else {\n            println!(\"{n} is not invertible mod {m}\");\n        }\n    }\n}\n\nfn benchmark_mod_inverse_algorithms<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_inverse({})\", U::NAME, U::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_38::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(n, m)| no_out!(n.mod_inverse(m))),\n            (\"Euclidean\", &mut |(n, m)| {\n                no_out!(mod_inverse_euclidean::<U, S>(n, m));\n            }),\n            (\"binary\", &mut |(n, m)| {\n                no_out!(mod_inverse_binary::<U, S>(n, m));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_12;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_is_reduced);\n    register_unsigned_benches!(runner, benchmark_mod_is_reduced);\n}\n\nfn demo_mod_is_reduced<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.mod_is_reduced(&m) {\n            println!(\"{n} is reduced mod {m}\");\n        } else {\n            println!(\"{n} is not reduced mod {m}\");\n        }\n    }\n}\n\nfn benchmark_mod_is_reduced<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_is_reduced(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(n, m)| no_out!(n.mod_is_reduced(&m)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_mul::{\n    fast_mod_mul, limbs_invert_limb_u32, limbs_invert_limb_u64, mod_preinverted_double,\n    naive_mod_mul,\n};\nuse malachite_base::num::arithmetic::traits::ModMulPrecomputed;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf};\nuse malachite_base::test_util::bench::bucketers::{\n    ignore_highest_bit_unsigned_bit_bucketer, quadruple_1_2_bit_bucketer, triple_3_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_12, unsigned_quadruple_gen_var_5, unsigned_triple_gen_var_12,\n};\nuse malachite_base::test_util::num::arithmetic::mod_mul::limbs_invert_limb_naive;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_invert_limb_u32);\n    register_demo!(runner, demo_limbs_invert_limb_u64);\n    register_generic_demos_2!(\n        runner,\n        demo_mod_preinverted_double,\n        [u8, u16],\n        [u16, u32],\n        [u32, u64],\n        [u64, u128]\n    );\n    register_unsigned_demos!(runner, demo_mod_mul);\n    register_unsigned_demos!(runner, demo_mod_mul_assign);\n\n    register_bench!(runner, benchmark_limbs_invert_limb_u32_algorithms);\n    register_bench!(runner, benchmark_limbs_invert_limb_u64_algorithms);\n    register_generic_benches_2!(\n        runner,\n        benchmark_mod_preinverted_double_algorithms,\n        [u8, u16],\n        [u16, u32],\n        [u32, u64],\n        [u64, u128]\n    );\n    register_generic_benches!(runner, benchmark_mod_mul_algorithms, u8, u16, u128, usize);\n    register_generic_benches_2!(\n        runner,\n        benchmark_mod_mul_algorithms_with_fast,\n        [u32, u64],\n        [u64, u128]\n    );\n    register_unsigned_benches!(runner, benchmark_mod_mul_assign);\n    register_unsigned_benches!(runner, benchmark_mod_mul_precomputed_algorithms);\n}\n\nfn demo_limbs_invert_limb_u32(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"limbs_invert_limb_u32({}) = {}\",\n            x,\n            limbs_invert_limb_u32(x)\n        );\n    }\n}\n\nfn demo_limbs_invert_limb_u64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"limbs_invert_limb_u64({}) = {}\",\n            x,\n            limbs_invert_limb_u64(x)\n        );\n    }\n}\n\nfn demo_mod_preinverted_double<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x_1, x_0, m, inv) in unsigned_quadruple_gen_var_5::<T, DT>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"mod_preinverted_double({}, {}, {}, {}) = {}\",\n            x_1,\n            x_0,\n            m,\n            inv,\n            mod_preinverted_double::<T, DT>(x_1, x_0, m, inv)\n        );\n    }\n}\n\nfn demo_mod_mul<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in unsigned_triple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} * {} ≡ {} mod {}\", x, y, x.mod_mul(y, m), m);\n    }\n}\n\nfn demo_mod_mul_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in unsigned_triple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_mul_assign(y, m);\n        println!(\"x := {old_x}; x.mod_mul_assign({y}, {m}); x = {x}\");\n    }\n}\n\nfn benchmark_limbs_invert_limb_u32_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_invert_limb_u32(u32)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &ignore_highest_bit_unsigned_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(limbs_invert_limb_u32(x))),\n            (\"naive\", &mut |x| {\n                no_out!(limbs_invert_limb_naive::<u32, u64>(x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_invert_limb_u64_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_invert_limb_u64(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &ignore_highest_bit_unsigned_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(limbs_invert_limb_u64(x))),\n            (\"naive\", &mut |x| {\n                no_out!(limbs_invert_limb_naive::<u64, u128>(x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_mod_preinverted_double_algorithms<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"mod_preinverted_double({}, {}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_quadruple_gen_var_5::<T, DT>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x_1, x_0, d, d_inv)| {\n                no_out!(mod_preinverted_double::<T, DT>(x_1, x_0, d, d_inv));\n            }),\n            (\"naive\", &mut |(x_1, x_0, d, _)| {\n                no_out!(T::exact_from(DT::join_halves(x_1, x_0) % DT::from(d)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_mod_mul_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, y, m)| no_out!(x.mod_mul(y, m))),\n            (\"naive\", &mut |(x, y, m)| no_out!(naive_mod_mul(x, y, m))),\n        ],\n    );\n}\n\nfn benchmark_mod_mul_algorithms_with_fast<\n    T: ModMulPrecomputed<Data = T> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, y, m)| no_out!(x.mod_mul(y, m))),\n            (\"naive\", &mut |(x, y, m)| no_out!(naive_mod_mul(x, y, m))),\n            (\"fast\", &mut |(x, y, m)| {\n                no_out!(fast_mod_mul::<T, DT>(\n                    x,\n                    y,\n                    m,\n                    T::precompute_mod_mul_data(&m)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_mod_mul_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, m)| x.mod_mul_assign(y, m))],\n    );\n}\n\nfn benchmark_mod_mul_precomputed_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, y, m)| {\n                for _ in 0..10 {\n                    x.mod_mul(y, m);\n                }\n            }),\n            (\"precomputed\", &mut |(x, y, m)| {\n                let data = T::precompute_mod_mul_data(&m);\n                for _ in 0..10 {\n                    x.mod_mul_precomputed(y, m, &data);\n                }\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_neg);\n    register_unsigned_demos!(runner, demo_mod_neg_assign);\n    register_unsigned_benches!(runner, benchmark_mod_neg);\n    register_unsigned_benches!(runner, benchmark_mod_neg_assign);\n}\n\nfn demo_mod_neg<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in unsigned_pair_gen_var_16::<T>().get(gm, config).take(limit) {\n        println!(\"-{} ≡ {} mod {}\", n, n.mod_neg(m), m);\n    }\n}\n\nfn demo_mod_neg_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, m) in unsigned_pair_gen_var_16::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.mod_neg_assign(m);\n        println!(\"n := {old_n}; n.mod_neg_assign({m}); n = {n}\");\n    }\n}\n\nfn benchmark_mod_neg<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_neg({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_16::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(n, m)| no_out!(n.mod_neg(m)))],\n    );\n}\n\nfn benchmark_mod_neg_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_neg({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_16::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(mut n, m)| n.mod_neg_assign(m))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_pair_gen_var_4, signed_pair_gen_var_6, unsigned_pair_gen_var_12,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_unsigned);\n    register_signed_demos!(runner, demo_mod_signed);\n    register_unsigned_demos!(runner, demo_mod_assign_unsigned);\n    register_signed_demos!(runner, demo_mod_assign_signed);\n    register_unsigned_demos!(runner, demo_neg_mod);\n    register_unsigned_demos!(runner, demo_neg_mod_assign);\n    register_signed_demos!(runner, demo_ceiling_mod);\n    register_signed_demos!(runner, demo_ceiling_mod_assign);\n\n    register_unsigned_benches!(runner, benchmark_mod_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_mod_signed_algorithms);\n    register_unsigned_benches!(runner, benchmark_mod_assign_unsigned);\n    register_signed_benches!(runner, benchmark_mod_assign_signed);\n    register_unsigned_benches!(runner, benchmark_neg_mod_algorithms);\n    register_unsigned_benches!(runner, benchmark_neg_mod_assign);\n    register_signed_benches!(runner, benchmark_ceiling_mod_algorithms);\n    register_signed_benches!(runner, benchmark_ceiling_mod_assign);\n}\n\nfn demo_mod_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.mod_op({}) = {}\", x, y, x.mod_op(y));\n    }\n}\n\nfn demo_mod_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        println!(\"({}).mod_op({}) = {}\", x, y, x.mod_op(y));\n    }\n}\n\nfn demo_mod_assign_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_assign(y);\n        println!(\"x := {old_x}; x.mod_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_mod_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.mod_assign(y);\n        println!(\"x := {old_x}; x.mod_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_neg_mod<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.neg_mod({}) = {}\", x, y, x.neg_mod(y));\n    }\n}\n\nfn demo_neg_mod_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.neg_mod_assign(y);\n        println!(\"x := {old_x}; x.neg_mod_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_ceiling_mod<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        println!(\"({}).ceiling_mod({}) = {}\", x, y, x.ceiling_mod(y));\n    }\n}\n\nfn demo_ceiling_mod_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.ceiling_mod_assign(y);\n        println!(\"x := {old_x}; x.ceiling_mod_assign({y}); x = {x}\");\n    }\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_mod_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using mod\", &mut |(x, y)| no_out!(x.mod_op(y))),\n            (\"using div_mod\", &mut |(x, y)| no_out!(x.div_mod(y).1)),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_mod_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using mod\", &mut |(x, y)| no_out!(x.mod_op(y))),\n            (\"using div_mod\", &mut |(x, y)| no_out!(x.div_mod(y).1)),\n        ],\n    );\n}\n\nfn benchmark_mod_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.mod_assign(y))],\n    );\n}\n\nfn benchmark_mod_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.mod_assign(y))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_neg_mod_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.neg_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using neg_mod\", &mut |(x, y)| no_out!(x.neg_mod(y))),\n            (\"using ceiling_div_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_neg_mod(y).1);\n            }),\n        ],\n    );\n}\n\nfn benchmark_neg_mod_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.neg_mod_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.neg_mod_assign(y))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_ceiling_mod_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_mod({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        signed_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"using ceiling_mod\", &mut |(x, y)| no_out!(x.ceiling_mod(y))),\n            (\"using ceiling_div_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_mod(y).1);\n            }),\n        ],\n    );\n}\n\nfn benchmark_ceiling_mod_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_mod_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.ceiling_mod_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_pow::simple_binary_mod_pow;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_2_3_product_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_14, unsigned_triple_gen_var_15,\n};\nuse malachite_base::test_util::num::arithmetic::mod_pow::naive_mod_pow;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_pow);\n    register_unsigned_demos!(runner, demo_mod_pow_assign);\n    register_unsigned_benches!(runner, benchmark_mod_pow_algorithms);\n    register_unsigned_benches!(runner, benchmark_mod_pow_naive_algorithms);\n    register_unsigned_benches!(runner, benchmark_mod_pow_assign);\n    register_unsigned_benches!(runner, benchmark_mod_pow_precomputed_algorithms);\n}\n\nfn demo_mod_pow<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in unsigned_triple_gen_var_15::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.pow({}) ≡ {} mod {}\", x, exp, x.mod_pow(exp, m), m);\n    }\n}\n\nfn demo_mod_pow_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp, m) in unsigned_triple_gen_var_15::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_pow_assign(exp, m);\n        println!(\"x := {old_x}; x.mod_pow_assign({exp}, {m}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_pow_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_pow(u64, {})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_15::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"exp\", \"m\"),\n        &mut [\n            (\"default\", &mut |(x, exp, m)| no_out!(x.mod_pow(exp, m))),\n            (\"simple binary\", &mut |(x, exp, m)| {\n                no_out!(simple_binary_mod_pow(x, exp, m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_mod_pow_naive_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_pow(u64, {})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_14::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"exp\", \"m\"),\n        &mut [\n            (\"default\", &mut |(x, exp, m)| no_out!(x.mod_pow(exp, m))),\n            (\"naive\", &mut |(x, exp, m)| {\n                no_out!(naive_mod_pow(x, exp, m));\n            }),\n            (\"simple binary\", &mut |(x, exp, m)| {\n                no_out!(simple_binary_mod_pow(x, exp, m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_mod_pow_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_pow_assign(u64, {})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_15::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"exp\", \"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp, m)| x.mod_pow_assign(exp, m))],\n    );\n}\n\nfn benchmark_mod_pow_precomputed_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_pow(u64, {})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_15::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"exp\", \"m\"),\n        &mut [\n            (\"default\", &mut |(x, exp, m)| {\n                for _ in 0..10 {\n                    x.mod_pow(exp, m);\n                }\n            }),\n            (\"precomputed\", &mut |(x, exp, m)| {\n                let data = T::precompute_mod_pow_data(&m);\n                for _ in 0..10 {\n                    x.mod_pow_precomputed(exp, m, &data);\n                }\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ModPowerOf2;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::pair_1_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, signed_unsigned_pair_gen_var_4,\n    signed_unsigned_pair_gen_var_10, signed_unsigned_pair_gen_var_11, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_20,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_unsigned);\n    register_signed_demos!(runner, demo_mod_power_of_2_signed);\n    register_unsigned_demos!(runner, demo_mod_power_of_2_assign_unsigned);\n    register_signed_demos!(runner, demo_mod_power_of_2_assign_signed);\n    register_unsigned_demos!(runner, demo_rem_power_of_2_unsigned);\n    register_signed_demos!(runner, demo_rem_power_of_2_signed);\n    register_unsigned_demos!(runner, demo_rem_power_of_2_assign_unsigned);\n    register_signed_demos!(runner, demo_rem_power_of_2_assign_signed);\n    register_unsigned_demos!(runner, demo_neg_mod_power_of_2);\n    register_unsigned_demos!(runner, demo_neg_mod_power_of_2_assign);\n    register_unsigned_signed_match_demos!(runner, demo_ceiling_mod_power_of_2);\n    register_unsigned_signed_match_demos!(runner, demo_ceiling_mod_power_of_2_assign);\n\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_unsigned);\n    register_signed_benches!(runner, benchmark_mod_power_of_2_signed);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_assign_unsigned);\n    register_signed_benches!(runner, benchmark_mod_power_of_2_assign_signed);\n    register_unsigned_benches!(runner, benchmark_rem_power_of_2_unsigned);\n    register_signed_benches!(runner, benchmark_rem_power_of_2_signed);\n    register_unsigned_benches!(runner, benchmark_rem_power_of_2_assign_unsigned);\n    register_signed_benches!(runner, benchmark_rem_power_of_2_assign_signed);\n    register_unsigned_benches!(runner, benchmark_neg_mod_power_of_2);\n    register_unsigned_benches!(runner, benchmark_neg_mod_power_of_2_assign);\n    register_unsigned_signed_match_benches!(runner, benchmark_ceiling_mod_power_of_2);\n    register_unsigned_signed_match_benches!(runner, benchmark_ceiling_mod_power_of_2_assign);\n}\n\nfn demo_mod_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} ≡ {} mod 2^{}\", n, n.mod_power_of_2(pow), pow);\n    }\n}\n\nfn demo_mod_power_of_2_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    <T as ModPowerOf2>::Output: PrimitiveUnsigned,\n{\n    for (n, pow) in signed_unsigned_pair_gen_var_10::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} ≡ {} mod 2^{}\", n, n.mod_power_of_2(pow), pow);\n    }\n}\n\nfn demo_mod_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.mod_power_of_2_assign(pow);\n        println!(\"n := {old_n}; n.mod_power_of_2_assign({pow}); n = {n}\");\n    }\n}\n\nfn demo_mod_power_of_2_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    <T as ModPowerOf2>::Output: PrimitiveUnsigned,\n{\n    for (mut n, pow) in signed_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.mod_power_of_2_assign(pow);\n        println!(\"n := {old_n}; n.mod_power_of_2_assign({pow}); n = {n}\");\n    }\n}\n\nfn demo_rem_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.rem_power_of_2({}) = {}\", n, pow, n.rem_power_of_2(pow));\n    }\n}\n\nfn demo_rem_power_of_2_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in signed_unsigned_pair_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.rem_power_of_2({}) = {}\", n, pow, n.rem_power_of_2(pow));\n    }\n}\n\nfn demo_rem_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.rem_power_of_2_assign(pow);\n        println!(\"n := {old_n}; n.rem_power_of_2_assign({pow}); n = {n}\");\n    }\n}\n\nfn demo_rem_power_of_2_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow) in signed_unsigned_pair_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.rem_power_of_2_assign(pow);\n        println!(\"n := {old_n}; n.rem_power_of_2_assign({pow}); n = {n}\");\n    }\n}\n\nfn demo_neg_mod_power_of_2<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in unsigned_pair_gen_var_20::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.neg_mod_power_of_2({}) = {}\",\n            n,\n            pow,\n            n.neg_mod_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_neg_mod_power_of_2_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow) in unsigned_pair_gen_var_20::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.neg_mod_power_of_2_assign(pow);\n        println!(\"n := {old_n}; n.neg_mod_power_of_2_assign({pow}); n = {n}\");\n    }\n}\n\nfn demo_ceiling_mod_power_of_2<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in signed_unsigned_pair_gen_var_11::<U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).ceiling_mod_power_of_2({}) = {}\",\n            n,\n            pow,\n            n.ceiling_mod_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_ceiling_mod_power_of_2_assign<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow) in signed_unsigned_pair_gen_var_11::<U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.ceiling_mod_power_of_2_assign(pow);\n        println!(\"n := {old_n}; n.ceiling_mod_power_of_2_assign({pow}); n = {n}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| no_out!(n.mod_power_of_2(pow)))],\n    );\n}\n\nfn benchmark_mod_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as ModPowerOf2>::Output: PrimitiveUnsigned,\n{\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_10::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| no_out!(n.mod_power_of_2(pow)))],\n    );\n}\n\nfn benchmark_mod_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.mod_power_of_2_assign(pow);\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.mod_power_of_2_assign(pow);\n        })],\n    );\n}\n\nfn benchmark_rem_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rem_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| no_out!(n.rem_power_of_2(pow)))],\n    );\n}\n\nfn benchmark_rem_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as ModPowerOf2>::Output: PrimitiveUnsigned,\n{\n    run_benchmark(\n        &format!(\"{}.rem_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| no_out!(n.rem_power_of_2(pow)))],\n    );\n}\n\nfn benchmark_rem_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rem_power_of_2_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.rem_power_of_2_assign(pow);\n        })],\n    );\n}\n\nfn benchmark_rem_power_of_2_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rem_power_of_2_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.rem_power_of_2_assign(pow);\n        })],\n    );\n}\n\nfn benchmark_neg_mod_power_of_2<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.neg_mod_power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_20::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.neg_mod_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_neg_mod_power_of_2_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.neg_mod_power_of_2_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_20::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.neg_mod_power_of_2_assign(pow);\n        })],\n    );\n}\n\nfn benchmark_ceiling_mod_power_of_2<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_mod_power_of_2(u64)\", S::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_11::<U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.ceiling_mod_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_ceiling_mod_power_of_2_assign<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_mod_power_of_2_assign(u64)\", S::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_11::<U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.ceiling_mod_power_of_2_assign(pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_11;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_add);\n    register_unsigned_demos!(runner, demo_mod_power_of_2_add_assign);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_add);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_add_assign);\n}\n\nfn demo_mod_power_of_2_add<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in unsigned_triple_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{} + {} ≡ {} mod 2^{}\",\n            x,\n            y,\n            x.mod_power_of_2_add(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_mod_power_of_2_add_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, pow) in unsigned_triple_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_power_of_2_add_assign(y, pow);\n        println!(\"x := {old_x}; x.mod_power_of_2_add_assign({y}, {pow}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_add<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_add({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.mod_power_of_2_add(y, pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_add_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_add_assign({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_add_assign(y, pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_power_of_2_inverse::mod_power_of_2_inverse_fast;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_39;\nuse malachite_base::test_util::num::arithmetic::mod_power_of_2_inverse::*;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_inverse);\n    register_unsigned_signed_match_benches!(runner, benchmark_mod_power_of_2_inverse_algorithms);\n}\n\nfn demo_mod_power_of_2_inverse<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_pair_gen_var_39::<T>().get(gm, config).take(limit) {\n        if let Some(inverse) = n.mod_power_of_2_inverse(pow) {\n            println!(\"{n}⁻¹ ≡ {inverse} mod 2^{pow}\");\n        } else {\n            println!(\"{n} is not invertible mod 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_mod_power_of_2_inverse_algorithms<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_inverse(u64)\", U::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_39::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(n, pow)| {\n                no_out!(n.mod_power_of_2_inverse(pow));\n            }),\n            (\"Euclidean\", &mut |(n, pow)| {\n                no_out!(mod_power_of_2_inverse_euclidean::<U, S>(n, pow));\n            }),\n            (\"fast\", &mut |(n, pow)| {\n                no_out!(mod_power_of_2_inverse_fast(n, pow));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_2;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_is_reduced);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_is_reduced);\n}\n\nfn demo_mod_power_of_2_is_reduced<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.mod_power_of_2_is_reduced(pow) {\n            println!(\"{n} is reduced mod 2^{pow}\");\n        } else {\n            println!(\"{n} is not reduced mod 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_mod_power_of_2_is_reduced<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_is_reduced(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.mod_power_of_2_is_reduced(pow));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_11;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_mul);\n    register_unsigned_demos!(runner, demo_mod_power_of_2_mul_assign);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_mul);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_mul_assign);\n}\n\nfn demo_mod_power_of_2_mul<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in unsigned_triple_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{} * {} ≡ {} mod 2^{}\",\n            x,\n            y,\n            x.mod_power_of_2_mul(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_mod_power_of_2_mul_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, pow) in unsigned_triple_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_power_of_2_mul_assign(y, pow);\n        println!(\"x := {old_x}; x.mod_power_of_2_mul_assign({y}, {pow}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_mul<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_mul({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.mod_power_of_2_mul(y, pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_mul_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_mul_assign({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_mul_assign(y, pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_17;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_neg);\n    register_unsigned_demos!(runner, demo_mod_power_of_2_neg_assign);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_neg);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_neg_assign);\n}\n\nfn demo_mod_power_of_2_neg<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in unsigned_pair_gen_var_17::<T>().get(gm, config).take(limit) {\n        println!(\"-{} ≡ {} mod 2^{}\", n, n.mod_power_of_2_neg(pow), pow);\n    }\n}\n\nfn demo_mod_power_of_2_neg_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow) in unsigned_pair_gen_var_17::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.mod_power_of_2_neg_assign(pow);\n        println!(\"n := {old_n}; n.mod_power_of_2_neg_assign({pow}); n = {n}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_neg<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_neg(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_17::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.mod_power_of_2_neg(pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_neg_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_neg_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_17::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.mod_power_of_2_neg_assign(pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_pow);\n    register_unsigned_demos!(runner, demo_mod_power_of_2_pow_assign);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_pow);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_pow_assign);\n}\n\nfn demo_mod_power_of_2_pow<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, pow) in unsigned_triple_gen_var_16::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.pow({}) ≡ {} mod 2^{}\",\n            x,\n            exp,\n            x.mod_power_of_2_pow(exp, pow),\n            pow\n        );\n    }\n}\n\nfn demo_mod_power_of_2_pow_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, exp, pow) in unsigned_triple_gen_var_16::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_power_of_2_pow_assign(exp, pow);\n        println!(\"x := {old_x}; x.mod_power_of_2_pow_assign({exp}, {pow}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_pow<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_pow(u64, u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_16::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(x, exp, pow)| {\n            no_out!(x.mod_power_of_2_pow(exp, pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_pow_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_pow_assign({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_16::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp, pow)| {\n            x.mod_power_of_2_pow_assign(exp, pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2Shl, ModPowerOf2ShlAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_signed_unsigned_triple_gen_var_1, unsigned_triple_gen_var_17,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_mod_power_of_2_shl_unsigned_unsigned);\n    register_unsigned_signed_demos!(runner, demo_mod_power_of_2_shl_unsigned_signed);\n    register_unsigned_unsigned_demos!(runner, demo_mod_power_of_2_shl_assign_unsigned_unsigned);\n    register_unsigned_signed_demos!(runner, demo_mod_power_of_2_shl_assign_unsigned_signed);\n\n    register_unsigned_unsigned_benches!(runner, benchmark_mod_power_of_2_shl_unsigned_unsigned);\n    register_unsigned_signed_benches!(runner, benchmark_mod_power_of_2_shl_unsigned_signed);\n    register_unsigned_unsigned_benches!(\n        runner,\n        benchmark_mod_power_of_2_shl_assign_unsigned_unsigned\n    );\n    register_unsigned_signed_benches!(runner, benchmark_mod_power_of_2_shl_assign_unsigned_signed);\n}\n\nfn demo_mod_power_of_2_shl_unsigned_unsigned<\n    T: ModPowerOf2Shl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, pow) in unsigned_triple_gen_var_17::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.mod_power_of_2_shl({}, {}) = {}\",\n            n,\n            u,\n            pow,\n            n.mod_power_of_2_shl(u, pow)\n        );\n    }\n}\n\nfn demo_mod_power_of_2_shl_unsigned_signed<\n    T: ModPowerOf2Shl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, pow) in unsigned_signed_unsigned_triple_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.mod_power_of_2_shl({}, {}) = {}\",\n            n,\n            u,\n            pow,\n            n.mod_power_of_2_shl(u, pow)\n        );\n    }\n}\n\nfn demo_mod_power_of_2_shl_assign_unsigned_unsigned<\n    T: ModPowerOf2ShlAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, pow) in unsigned_triple_gen_var_17::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.mod_power_of_2_shl_assign(u, pow);\n        println!(\"x := {old_n}; x.mod_power_of_2_shl_assign({u}, {pow}); x = {n}\");\n    }\n}\n\nfn demo_mod_power_of_2_shl_assign_unsigned_signed<\n    T: ModPowerOf2ShlAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, pow) in unsigned_signed_unsigned_triple_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.mod_power_of_2_shl_assign(u, pow);\n        println!(\"x := {old_n}; x.mod_power_of_2_shl_assign({u}, {pow}); x = {n}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_shl_unsigned_unsigned<\n    T: ModPowerOf2Shl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_shl({}, u64)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_17::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.mod_power_of_2_shl(y, pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_shl_unsigned_signed<\n    T: ModPowerOf2Shl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_shl({}, u64)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.mod_power_of_2_shl(y, pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_shl_assign_unsigned_unsigned<\n    T: ModPowerOf2ShlAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_shl_assign({}, u64)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_17::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_shl_assign(y, pow);\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_shl_assign_unsigned_signed<\n    T: ModPowerOf2ShlAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_shl_assign({}, u64)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_shl_assign(y, pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2Shr, ModPowerOf2ShrAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_signed_unsigned_triple_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_signed_demos!(runner, demo_mod_power_of_2_shr);\n    register_unsigned_signed_demos!(runner, demo_mod_power_of_2_shr_assign);\n\n    register_unsigned_signed_benches!(runner, benchmark_mod_power_of_2_shr);\n    register_unsigned_signed_benches!(runner, benchmark_mod_power_of_2_shr_assign);\n}\n\nfn demo_mod_power_of_2_shr<\n    T: ModPowerOf2Shr<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, pow) in unsigned_signed_unsigned_triple_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.mod_power_of_2_shr({}, {}) = {}\",\n            n,\n            u,\n            pow,\n            n.mod_power_of_2_shr(u, pow)\n        );\n    }\n}\n\nfn demo_mod_power_of_2_shr_assign<\n    T: ModPowerOf2ShrAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, pow) in unsigned_signed_unsigned_triple_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.mod_power_of_2_shr_assign(u, pow);\n        println!(\"x := {old_n}; x.mod_power_of_2_shr_assign({u}, {pow}); x = {n}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_shr<\n    T: ModPowerOf2Shr<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_shr({}, u64)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.mod_power_of_2_shr(y, pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_shr_assign<\n    T: ModPowerOf2ShrAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_shr_assign({}, u64)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_shr_assign(y, pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_17;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_square);\n    register_unsigned_demos!(runner, demo_mod_power_of_2_square_assign);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_square);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_square_assign);\n}\n\nfn demo_mod_power_of_2_square<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in unsigned_pair_gen_var_17::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.square() ≡ {} mod 2^{}\",\n            n,\n            n.mod_power_of_2_square(pow),\n            pow\n        );\n    }\n}\n\nfn demo_mod_power_of_2_square_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow) in unsigned_pair_gen_var_17::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.mod_power_of_2_square_assign(pow);\n        println!(\"n := {old_n}; n.mod_power_of_2_square_assign({pow}); n = {n}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_square<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_square(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_17::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.mod_power_of_2_square(pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_square_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_square_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_17::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut n, pow)| {\n            n.mod_power_of_2_square_assign(pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_power_of_2_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_11;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_power_of_2_sub);\n    register_unsigned_demos!(runner, demo_mod_power_of_2_sub_assign);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_sub);\n    register_unsigned_benches!(runner, benchmark_mod_power_of_2_sub_assign);\n}\n\nfn demo_mod_power_of_2_sub<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in unsigned_triple_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{} - {} ≡ {} mod 2^{}\",\n            x,\n            y,\n            x.mod_power_of_2_sub(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_mod_power_of_2_sub_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, pow) in unsigned_triple_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_power_of_2_sub_assign(y, pow);\n        println!(\"x := {old_x}; x.mod_power_of_2_sub_assign({y}, {pow}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_power_of_2_sub<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_sub({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(x, y, pow)| {\n            no_out!(x.mod_power_of_2_sub(y, pow));\n        })],\n    );\n}\n\nfn benchmark_mod_power_of_2_sub_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_power_of_2_sub_assign({}, u64)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_sub_assign(y, pow);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModShl, ModShlAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::triple_2_3_product_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_signed_unsigned_triple_gen_var_2, unsigned_triple_gen_var_18,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_mod_shl_unsigned_unsigned);\n    register_unsigned_unsigned_signed_match_demos!(runner, demo_mod_shl_unsigned_signed);\n    register_unsigned_unsigned_demos!(runner, demo_mod_shl_assign_unsigned_unsigned);\n    register_unsigned_unsigned_signed_match_demos!(runner, demo_mod_shl_assign_unsigned_signed);\n\n    register_unsigned_unsigned_benches!(runner, benchmark_mod_shl_unsigned_unsigned);\n    register_unsigned_unsigned_signed_match_benches!(runner, benchmark_mod_shl_unsigned_signed);\n    register_unsigned_unsigned_benches!(runner, benchmark_mod_shl_assign_unsigned_unsigned);\n    register_unsigned_unsigned_signed_match_benches!(\n        runner,\n        benchmark_mod_shl_assign_unsigned_signed\n    );\n}\n\nfn demo_mod_shl_unsigned_unsigned<\n    T: ModShl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, u, m) in unsigned_triple_gen_var_18::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} << {} ≡ {} mod {}\", x, u, x.mod_shl(u, m), m);\n    }\n}\n\nfn demo_mod_shl_unsigned_signed<\n    T: ModShl<S, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, u, m) in unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} << {} ≡ {} mod {}\", x, u, x.mod_shl(u, m), m);\n    }\n}\n\nfn demo_mod_shl_assign_unsigned_unsigned<\n    T: ModShlAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, u, m) in unsigned_triple_gen_var_18::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_shl_assign(u, m);\n        println!(\"x := {old_x}; x.mod_shl_assign({u}, {m}); x = {x}\");\n    }\n}\n\nfn demo_mod_shl_assign_unsigned_signed<\n    T: ModShlAssign<S> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, u, m) in unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_shl_assign(u, m);\n        println!(\"x := {old_x}; x.mod_shl_assign({u}, {m}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_shl_unsigned_unsigned<\n    T: ModShl<U, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_shl({}, {})\", T::NAME, U::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_18::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"u\", \"m\"),\n        &mut [(\"Malachite\", &mut |(x, pow, m)| no_out!(x.mod_shl(pow, m)))],\n    );\n}\n\nfn benchmark_mod_shl_unsigned_signed<\n    T: ModShl<S, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_shl({}, {})\", T::NAME, S::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"u\", \"m\"),\n        &mut [(\"Malachite\", &mut |(x, u, m)| no_out!(x.mod_shl(u, m)))],\n    );\n}\n\nfn benchmark_mod_shl_assign_unsigned_unsigned<\n    T: ModShlAssign<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_shl_assign({}, u64)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_18::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"u\", \"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, u, m)| x.mod_shl_assign(u, m))],\n    );\n}\n\nfn benchmark_mod_shl_assign_unsigned_signed<\n    T: ModShlAssign<S> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_shl_assign({}, u64)\", T::NAME, S::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"u\", \"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, u, m)| x.mod_shl_assign(u, m))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModShr, ModShrAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::triple_2_3_product_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_signed_unsigned_triple_gen_var_2;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_signed_match_demos!(runner, demo_mod_shr);\n    register_unsigned_unsigned_signed_match_demos!(runner, demo_mod_shr_assign);\n\n    register_unsigned_unsigned_signed_match_benches!(runner, benchmark_mod_shr);\n    register_unsigned_unsigned_signed_match_benches!(runner, benchmark_mod_shr_assign);\n}\n\nfn demo_mod_shr<\n    T: ModShr<S, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, u, m) in unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} >> {} ≡ {} mod {}\", x, u, x.mod_shr(u, m), m);\n    }\n}\n\nfn demo_mod_shr_assign<\n    T: ModShrAssign<S> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, u, m) in unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_shr_assign(u, m);\n        println!(\"x := {old_x}; x.mod_shr_assign({u}, {m}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_shr<\n    T: ModShr<S, Output = T> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_shr({}, {})\", T::NAME, S::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"u\", \"m\"),\n        &mut [(\"Malachite\", &mut |(x, u, m)| no_out!(x.mod_shr(u, m)))],\n    );\n}\n\nfn benchmark_mod_shr_assign<\n    T: ModShrAssign<S> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_shr_assign({}, u64)\", T::NAME, S::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_product_bit_bucketer(\"u\", \"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, u, m)| x.mod_shr_assign(u, m))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_square);\n    register_unsigned_demos!(runner, demo_mod_square_assign);\n    register_unsigned_benches!(runner, benchmark_mod_square);\n    register_unsigned_benches!(runner, benchmark_mod_square_assign);\n    register_unsigned_benches!(runner, benchmark_mod_square_precomputed_algorithms);\n}\n\nfn demo_mod_square<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, m) in unsigned_pair_gen_var_16::<T>().get(gm, config).take(limit) {\n        println!(\"{}.square() ≡ {} mod {}\", x, x.mod_square(m), m);\n    }\n}\n\nfn demo_mod_square_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, m) in unsigned_pair_gen_var_16::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.mod_square_assign(m);\n        println!(\"x := {old_x}; x.mod_square_assign({m}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_square<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_square({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_16::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(x, m)| no_out!(x.mod_square(m)))],\n    );\n}\n\nfn benchmark_mod_square_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_square({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_16::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, m)| x.mod_square_assign(m))],\n    );\n}\n\nfn benchmark_mod_square_precomputed_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_square({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_16::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, m)| {\n                for _ in 0..10 {\n                    x.mod_square(m);\n                }\n            }),\n            (\"precomputed\", &mut |(x, m)| {\n                let data = T::precompute_mod_pow_data(&m);\n                for _ in 0..10 {\n                    x.mod_square_precomputed(m, &data);\n                }\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/mod_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_12;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_mod_sub);\n    register_unsigned_demos!(runner, demo_mod_sub_assign);\n    register_unsigned_benches!(runner, benchmark_mod_sub);\n    register_unsigned_benches!(runner, benchmark_mod_sub_assign);\n}\n\nfn demo_mod_sub<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in unsigned_triple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} - {} ≡ {} mod {}\", x, y, x.mod_sub(y, m), m);\n    }\n}\n\nfn demo_mod_sub_assign<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in unsigned_triple_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.mod_sub_assign(y, m);\n        println!(\"x := {old_x}; x.mod_sub_assign({y}, {m}); x = {x}\");\n    }\n}\n\nfn benchmark_mod_sub<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_sub({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(x, y, m)| no_out!(x.mod_sub(y, m)))],\n    );\n}\n\nfn benchmark_mod_sub_assign<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.mod_sub({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, m)| x.mod_sub_assign(y, m))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{primitive_float_bucketer, signed_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen_var_1};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_neg_assign_signed);\n    register_primitive_float_demos!(runner, demo_neg_assign_primitive_float);\n\n    register_signed_benches!(runner, benchmark_neg_assign_signed);\n    register_primitive_float_benches!(runner, benchmark_neg_assign_primitive_float);\n}\n\nfn demo_neg_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut i in signed_gen_var_1::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.neg_assign();\n        println!(\"i := {old_i}; i.neg_assign(); i = {i}\");\n    }\n}\n\nfn demo_neg_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.neg_assign();\n        println!(\n            \"x := {}; x.neg_assign(); x = {}\",\n            NiceFloat(old_x),\n            NiceFloat(x)\n        );\n    }\n}\n\nfn benchmark_neg_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.neg_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.neg_assign())],\n    );\n}\n\nfn benchmark_neg_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.neg_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.neg_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen_var_19, unsigned_gen_var_14};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_next_power_of_2_primitive_float);\n    register_unsigned_demos!(runner, demo_next_power_of_2_assign_unsigned);\n    register_primitive_float_demos!(runner, demo_next_power_of_2_assign_primitive_float);\n\n    register_primitive_float_benches!(runner, benchmark_next_power_of_2_primitive_float);\n    register_unsigned_benches!(runner, benchmark_next_power_of_2_assign_unsigned);\n    register_primitive_float_benches!(runner, benchmark_next_power_of_2_assign_primitive_float);\n}\n\nfn demo_next_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in primitive_float_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.next_power_of_2() = {}\",\n            NiceFloat(n),\n            NiceFloat(n.next_power_of_2())\n        );\n    }\n}\n\nfn demo_next_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in unsigned_gen_var_14::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.next_power_of_2_assign();\n        println!(\"n := {old_n}; n.next_power_of_2_assign(); n = {n}\");\n    }\n}\n\nfn demo_next_power_of_2_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in primitive_float_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.next_power_of_2_assign();\n        println!(\n            \"n := {}; n.next_power_of_2_assign(); n = {}\",\n            NiceFloat(old_n),\n            NiceFloat(n)\n        );\n    }\n}\n\nfn benchmark_next_power_of_2_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.next_power_of_2()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.next_power_of_2()))],\n    );\n}\n\nfn benchmark_next_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.next_power_of_2_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_14::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.next_power_of_2_assign())],\n    );\n}\n\nfn benchmark_next_power_of_2_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.next_power_of_2_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.next_power_of_2_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::bucketers::signed_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_overflowing_abs_assign);\n    register_signed_benches!(runner, benchmark_overflowing_abs_assign);\n}\n\nfn demo_overflowing_abs_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut i in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        let overflow = i.overflowing_abs_assign();\n        println!(\"i := {old_i}; i.overflowing_abs_assign() = {overflow}; i = {i}\");\n    }\n}\n\nfn benchmark_overflowing_abs_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_abs_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| {\n            no_out!(i.overflowing_abs_assign());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_add_unsigned);\n    register_signed_demos!(runner, demo_overflowing_add_signed);\n    register_unsigned_demos!(runner, demo_overflowing_add_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_add_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_overflowing_add_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_add_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_add_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_add_assign_signed);\n}\n\nfn demo_overflowing_add_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.overflowing_add({}) = {:?}\", x, y, x.overflowing_add(y));\n    }\n}\n\nfn demo_overflowing_add_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).overflowing_add({}) = {:?}\",\n            x,\n            y,\n            x.overflowing_add(y)\n        );\n    }\n}\n\nfn demo_overflowing_add_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_add_assign(y);\n        println!(\"x := {old_x}; x.overflowing_add_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_add_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_add_assign(y);\n        println!(\"x := {old_x}; x.overflowing_add_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_add_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_add({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_add(y)))],\n    );\n}\n\nfn benchmark_overflowing_add_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_add({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_add(y)))],\n    );\n}\n\nfn benchmark_overflowing_add_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_add_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_add_assign(y));\n        })],\n    );\n}\n\nfn benchmark_overflowing_add_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_add_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_add_assign(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_add_mul_unsigned);\n    register_signed_demos!(runner, demo_overflowing_add_mul_signed);\n    register_unsigned_demos!(runner, demo_overflowing_add_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_add_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_overflowing_add_mul_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_add_mul_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_add_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_add_mul_assign_signed);\n}\n\nfn demo_overflowing_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.overflowing_add_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.overflowing_add_mul(y, z)\n        );\n    }\n}\n\nfn demo_overflowing_add_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.overflowing_add_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.overflowing_add_mul(y, z)\n        );\n    }\n}\n\nfn demo_overflowing_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let overflow = x.overflowing_add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.overflowing_add_mul_assign({y}, {z}) = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_add_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.overflowing_add_mul_assign({y}, {z}) = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.overflowing_add_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_overflowing_add_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.overflowing_add_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_overflowing_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.overflowing_add_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            no_out!(x.overflowing_add_mul_assign(y, z));\n        })],\n    );\n}\n\nfn benchmark_overflowing_add_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.overflowing_add_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            no_out!(x.overflowing_add_mul_assign(y, z));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen_var_6, unsigned_pair_gen_var_12};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_div_unsigned);\n    register_signed_demos!(runner, demo_overflowing_div_signed);\n    register_unsigned_demos!(runner, demo_overflowing_div_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_div_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_overflowing_div_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_div_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_div_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_div_assign_signed);\n}\n\nfn demo_overflowing_div_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.overflowing_div({}) = {:?}\", x, y, x.overflowing_div(y));\n    }\n}\n\nfn demo_overflowing_div_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).overflowing_div({}) = {:?}\",\n            x,\n            y,\n            x.overflowing_div(y)\n        );\n    }\n}\n\nfn demo_overflowing_div_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let overflow = x.overflowing_div_assign(y);\n        println!(\"x := {old_x}; x.overflowing_div_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_div_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_div_assign(y);\n        println!(\"x := {old_x}; x.overflowing_div_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_div_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_div({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_div(y)))],\n    );\n}\n\nfn benchmark_overflowing_div_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_div({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_div(y)))],\n    );\n}\n\nfn benchmark_overflowing_div_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_div_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_div_assign(y));\n        })],\n    );\n}\n\nfn benchmark_overflowing_div_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_div_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_div_assign(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_mul_unsigned);\n    register_signed_demos!(runner, demo_overflowing_mul_signed);\n    register_unsigned_demos!(runner, demo_overflowing_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_overflowing_mul_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_mul_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_mul_assign_signed);\n}\n\nfn demo_overflowing_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.overflowing_mul({}) = {:?}\", x, y, x.overflowing_mul(y));\n    }\n}\n\nfn demo_overflowing_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).overflowing_mul({}) = {:?}\",\n            x,\n            y,\n            x.overflowing_mul(y)\n        );\n    }\n}\n\nfn demo_overflowing_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_mul_assign(y);\n        println!(\"x := {old_x}; x.overflowing_mul_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_mul_assign(y);\n        println!(\"x := {old_x}; x.overflowing_mul_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_mul({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_mul(y)))],\n    );\n}\n\nfn benchmark_overflowing_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_mul({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_mul(y)))],\n    );\n}\n\nfn benchmark_overflowing_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_mul_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_mul_assign(y));\n        })],\n    );\n}\n\nfn benchmark_overflowing_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_mul_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_mul_assign(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_neg_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_neg_assign_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_neg_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_neg_assign_signed);\n}\n\nfn demo_overflowing_neg_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_u = u;\n        let overflow = u.overflowing_neg_assign();\n        println!(\"u := {old_u}; u.overflowing_neg_assign() = {overflow}; u = {u}\");\n    }\n}\n\nfn demo_overflowing_neg_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut i in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        let overflow = i.overflowing_neg_assign();\n        println!(\"i := {old_i}; i.overflowing_neg_assign() = {overflow}; i = {i}\");\n    }\n}\n\nfn benchmark_overflowing_neg_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_neg_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| {\n            no_out!(i.overflowing_neg_assign());\n        })],\n    );\n}\n\nfn benchmark_overflowing_neg_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_neg_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| {\n            no_out!(i.overflowing_neg_assign());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_pow_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_pow_assign_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_pow_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_pow_assign_signed);\n}\n\nfn demo_overflowing_pow_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen::<T, u64>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_pow_assign(y);\n        println!(\"x := {old_x}; x.overflowing_pow_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_pow_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_unsigned_pair_gen::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let overflow = x.overflowing_pow_assign(y);\n        println!(\"x := {old_x}; x.overflowing_pow_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_pow_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_pow_assign(y));\n        })],\n    );\n}\n\nfn benchmark_overflowing_pow_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_pow_assign(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_square_unsigned);\n    register_signed_demos!(runner, demo_overflowing_square_signed);\n    register_unsigned_demos!(runner, demo_overflowing_square_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_square_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_overflowing_square_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_square_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_square_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_square_assign_signed);\n}\n\nfn demo_overflowing_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.overflowing_square() = {:?}\", x, x.overflowing_square());\n    }\n}\n\nfn demo_overflowing_square_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.overflowing_square() = {:?}\", x, x.overflowing_square());\n    }\n}\n\nfn demo_overflowing_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_square_assign();\n        println!(\"x := {old_x}; x.overflowing_square_assign() = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_square_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut x in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_square_assign();\n        println!(\"x := {old_x}; x.overflowing_square_assign() = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_square()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.overflowing_square()))],\n    );\n}\n\nfn benchmark_overflowing_square_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_square()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.overflowing_square()))],\n    );\n}\n\nfn benchmark_overflowing_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut x| {\n            no_out!(x.overflowing_square_assign());\n        })],\n    );\n}\n\nfn benchmark_overflowing_square_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut x| {\n            no_out!(x.overflowing_square_assign());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_sub_unsigned);\n    register_signed_demos!(runner, demo_overflowing_sub_signed);\n    register_unsigned_demos!(runner, demo_overflowing_sub_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_sub_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_overflowing_sub_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_sub_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_sub_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_sub_assign_signed);\n}\n\nfn demo_overflowing_sub_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.overflowing_sub({}) = {:?}\", x, y, x.overflowing_sub(y));\n    }\n}\n\nfn demo_overflowing_sub_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).overflowing_sub({}) = {:?}\",\n            x,\n            y,\n            x.overflowing_sub(y)\n        );\n    }\n}\n\nfn demo_overflowing_sub_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_sub_assign(y);\n        println!(\"x := {old_x}; x.overflowing_sub_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_sub_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_sub_assign(y);\n        println!(\"x := {old_x}; x.overflowing_sub_assign({y}) = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_sub_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_sub({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_sub(y)))],\n    );\n}\n\nfn benchmark_overflowing_sub_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_sub({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.overflowing_sub(y)))],\n    );\n}\n\nfn benchmark_overflowing_sub_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_sub_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_sub_assign(y));\n        })],\n    );\n}\n\nfn benchmark_overflowing_sub_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_sub_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| {\n            no_out!(x.overflowing_sub_assign(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/overflowing_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_overflowing_sub_mul_unsigned);\n    register_signed_demos!(runner, demo_overflowing_sub_mul_signed);\n    register_unsigned_demos!(runner, demo_overflowing_sub_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_overflowing_sub_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_overflowing_sub_mul_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_sub_mul_signed);\n    register_unsigned_benches!(runner, benchmark_overflowing_sub_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_overflowing_sub_mul_assign_signed);\n}\n\nfn demo_overflowing_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.overflowing_sub_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.overflowing_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_overflowing_sub_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.overflowing_sub_mul({}, {}) = {:?}\",\n            x,\n            y,\n            z,\n            x.overflowing_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_overflowing_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let overflow = x.overflowing_sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.overflowing_sub_mul_assign({y}, {z}) = {overflow}; x = {x}\");\n    }\n}\n\nfn demo_overflowing_sub_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        let overflow = x.overflowing_sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.overflowing_sub_mul_assign({y}, {z}) = {overflow}; x = {x}\");\n    }\n}\n\nfn benchmark_overflowing_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.overflowing_sub_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_overflowing_sub_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.overflowing_sub_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_overflowing_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.overflowing_sub_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            no_out!(x.overflowing_sub_mul_assign(y, z));\n        })],\n    );\n}\n\nfn benchmark_overflowing_sub_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.overflowing_sub_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            no_out!(x.overflowing_sub_mul_assign(y, z));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_even_unsigned);\n    register_signed_demos!(runner, demo_even_signed);\n    register_unsigned_demos!(runner, demo_odd_unsigned);\n    register_signed_demos!(runner, demo_odd_signed);\n\n    register_unsigned_benches!(runner, benchmark_even_unsigned);\n    register_signed_benches!(runner, benchmark_even_signed);\n    register_unsigned_benches!(runner, benchmark_odd_unsigned);\n    register_signed_benches!(runner, benchmark_odd_signed);\n}\n\nfn demo_even_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        if u.even() {\n            println!(\"{u} is even\");\n        } else {\n            println!(\"{u} is not even\");\n        }\n    }\n}\n\nfn demo_even_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        if i.even() {\n            println!(\"{i} is even\");\n        } else {\n            println!(\"{i} is not even\");\n        }\n    }\n}\n\nfn demo_odd_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        if u.odd() {\n            println!(\"{u} is odd\");\n        } else {\n            println!(\"{u} is not odd\");\n        }\n    }\n}\n\nfn demo_odd_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        if i.odd() {\n            println!(\"{i} is odd\");\n        } else {\n            println!(\"{i} is not odd\");\n        }\n    }\n}\n\nfn benchmark_even_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.even()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.even()))],\n    );\n}\n\nfn benchmark_even_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.even()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |i| no_out!(i.even()))],\n    );\n}\n\nfn benchmark_odd_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.odd()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.odd()))],\n    );\n}\n\nfn benchmark_odd_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.odd()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |i| no_out!(i.odd()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bit_bucketer, pair_1_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_pair_gen, primitive_float_signed_pair_gen, signed_unsigned_pair_gen_var_15,\n    unsigned_pair_gen_var_29,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_pow_assign_unsigned);\n    register_signed_demos!(runner, demo_pow_assign_signed);\n    register_primitive_float_demos!(runner, demo_pow_assign_i64_primitive_float);\n    register_primitive_float_demos!(runner, demo_pow_assign_primitive_float_primitive_float);\n\n    register_unsigned_benches!(runner, benchmark_pow_assign_unsigned);\n    register_signed_benches!(runner, benchmark_pow_assign_signed);\n    register_primitive_float_benches!(runner, benchmark_pow_assign_i64_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_pow_assign_primitive_float_primitive_float);\n}\n\nfn demo_pow_assign_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in unsigned_pair_gen_var_29::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.pow_assign(y);\n        println!(\"x := {old_x}; x.pow_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_pow_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in signed_unsigned_pair_gen_var_15::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.pow_assign(y);\n        println!(\"x := {old_x}; x.pow_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_pow_assign_i64_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in primitive_float_signed_pair_gen::<T, i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.pow_assign(y);\n        println!(\n            \"x := {}; x.pow_assign({}); x = {}\",\n            NiceFloat(old_x),\n            y,\n            NiceFloat(x)\n        );\n    }\n}\n\nfn demo_pow_assign_primitive_float_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.pow_assign(y);\n        println!(\n            \"x := {}; x.pow_assign({}); x = {}\",\n            NiceFloat(old_x),\n            NiceFloat(y),\n            NiceFloat(x)\n        );\n    }\n}\n\nfn benchmark_pow_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_29::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.pow_assign(y))],\n    );\n}\n\nfn benchmark_pow_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_15::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.pow_assign(y))],\n    );\n}\n\nfn benchmark_pow_assign_i64_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.pow_assign(i64)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_signed_pair_gen::<T, i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.pow_assign(y))],\n    );\n}\n\nfn benchmark_pow_assign_primitive_float_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.pow_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.pow_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{signed_abs_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_gen_var_11, unsigned_gen_var_15, unsigned_gen_var_16, unsigned_gen_var_30,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_power_of_2_unsigned);\n    register_signed_demos!(runner, demo_power_of_2_signed);\n    register_primitive_float_demos!(runner, demo_power_of_2_primitive_float_unsigned);\n    register_primitive_float_demos!(runner, demo_power_of_2_primitive_float_signed);\n    register_unsigned_benches!(runner, benchmark_power_of_2_unsigned);\n    register_signed_benches!(runner, benchmark_power_of_2_signed);\n    register_primitive_float_benches!(runner, benchmark_power_of_2_primitive_float_unsigned);\n    register_primitive_float_benches!(runner, benchmark_power_of_2_primitive_float_signed);\n}\n\nfn demo_power_of_2_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for pow in unsigned_gen_var_15::<T>().get(gm, config).take(limit) {\n        println!(\"2^{} = {}\", pow, T::power_of_2(pow));\n    }\n}\n\nfn demo_power_of_2_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for pow in unsigned_gen_var_16::<T>().get(gm, config).take(limit) {\n        println!(\"2^{} = {}\", pow, T::power_of_2(pow));\n    }\n}\n\nfn demo_power_of_2_primitive_float_unsigned<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for pow in unsigned_gen_var_30::<T>().get(gm, config).take(limit) {\n        println!(\"2^({}) = {}\", pow, NiceFloat(T::power_of_2(pow)));\n    }\n}\n\nfn demo_power_of_2_primitive_float_signed<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for pow in signed_gen_var_11::<T>().get(gm, config).take(limit) {\n        println!(\"2^({}) = {}\", pow, NiceFloat(T::power_of_2(pow)));\n    }\n}\n\nfn benchmark_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_15::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |pow| no_out!(T::power_of_2(pow)))],\n    );\n}\n\nfn benchmark_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.power_of_2(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_16::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |pow| no_out!(T::power_of_2(pow)))],\n    );\n}\n\nfn benchmark_power_of_2_primitive_float_unsigned<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.power_of_2(i64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_30::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |pow| no_out!(T::power_of_2(pow)))],\n    );\n}\n\nfn benchmark_power_of_2_primitive_float_signed<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.power_of_2(i64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_abs_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |pow| no_out!(T::power_of_2(pow)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_27, unsigned_gen_var_28,\n};\nuse malachite_base::test_util::num::arithmetic::primorial::{\n    checked_primorial_naive, checked_product_of_first_n_primes_naive,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_primorial);\n    register_unsigned_demos!(runner, demo_checked_primorial);\n    register_unsigned_demos!(runner, demo_product_of_first_n_primes);\n    register_unsigned_demos!(runner, demo_checked_product_of_first_n_primes);\n\n    register_unsigned_benches!(runner, benchmark_primorial_algorithms);\n    register_unsigned_benches!(runner, benchmark_checked_primorial);\n    register_unsigned_benches!(runner, benchmark_product_of_first_n_primes_algorithms);\n    register_unsigned_benches!(runner, benchmark_checked_product_of_first_n_primes);\n}\n\nfn demo_primorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}# = {}\", n, T::primorial(n));\n    }\n}\n\nfn demo_checked_primorial<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen().get(gm, config).take(limit) {\n        println!(\"{}# = {:?}\", n, T::checked_primorial(n));\n    }\n}\n\nfn demo_product_of_first_n_primes<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen_var_28::<T>().get(gm, config).take(limit) {\n        println!(\"p_{}# = {}\", n, T::product_of_first_n_primes(n));\n    }\n}\n\nfn demo_checked_product_of_first_n_primes<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen().get(gm, config).take(limit) {\n        println!(\"p_{}# = {:?}\", n, T::checked_product_of_first_n_primes(n));\n    }\n}\n\nfn benchmark_primorial_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::primorial(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(T::primorial(n))),\n            (\"naive\", &mut |n| {\n                no_out!(checked_primorial_naive::<T>(n).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_primorial<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::checked_primorial(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::checked_primorial(n)))],\n    );\n}\n\nfn benchmark_product_of_first_n_primes_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::product_of_first_n_primes(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_28::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(T::product_of_first_n_primes(n))),\n            (\"naive\", &mut |n| {\n                no_out!(checked_product_of_first_n_primes_naive::<T>(n).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_product_of_first_n_primes<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::checked_product_of_first_n_primes(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(T::checked_product_of_first_n_primes(n));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_reciprocal_primitive_float);\n    register_primitive_float_demos!(runner, demo_reciprocal_assign_primitive_float);\n\n    register_primitive_float_benches!(runner, benchmark_reciprocal_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_reciprocal_assign_primitive_float);\n}\n\nfn demo_reciprocal_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).reciprocal() = {}\",\n            NiceFloat(f),\n            NiceFloat(f.reciprocal())\n        );\n    }\n}\n\nfn demo_reciprocal_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_f = f;\n        f.reciprocal_assign();\n        println!(\n            \"f := {}; f.reciprocal_assign(); x = {}\",\n            NiceFloat(old_f),\n            NiceFloat(f)\n        );\n    }\n}\n\nfn benchmark_reciprocal_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.reciprocal()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(f.reciprocal()))],\n    );\n}\n\nfn benchmark_reciprocal_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.reciprocal_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |mut f| f.reciprocal_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::arithmetic::root::{\n    cbrt_chebyshev_approx_u32, cbrt_chebyshev_approx_u64, fast_ceiling_root_u32,\n    fast_ceiling_root_u64, fast_checked_root_u32, fast_checked_root_u64, fast_floor_cbrt_u32,\n    fast_floor_cbrt_u64, fast_floor_root_u32, fast_floor_root_u64, fast_root_rem_u32,\n    fast_root_rem_u64, floor_root_approx_and_refine,\n};\nuse malachite_base::num::arithmetic::root::{\n    ceiling_root_binary, checked_root_binary, floor_root_binary, root_rem_binary,\n};\nuse malachite_base::num::arithmetic::traits::{CeilingRoot, CheckedRoot, FloorRoot, RootRem};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bit_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen_var_18, unsigned_gen, unsigned_gen_var_1,\n    unsigned_pair_gen_var_32,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_floor_cbrt_unsigned);\n    register_signed_demos!(runner, demo_floor_cbrt_signed);\n    register_unsigned_demos!(runner, demo_floor_cbrt_assign_unsigned);\n    register_signed_demos!(runner, demo_floor_cbrt_assign_signed);\n    register_unsigned_demos!(runner, demo_ceiling_cbrt_unsigned);\n    register_signed_demos!(runner, demo_ceiling_cbrt_signed);\n    register_unsigned_demos!(runner, demo_ceiling_cbrt_assign_unsigned);\n    register_signed_demos!(runner, demo_ceiling_cbrt_assign_signed);\n    register_unsigned_demos!(runner, demo_checked_cbrt_unsigned);\n    register_signed_demos!(runner, demo_checked_cbrt_signed);\n    register_unsigned_demos!(runner, demo_cbrt_rem);\n    register_unsigned_demos!(runner, demo_cbrt_assign_rem);\n\n    register_unsigned_demos!(runner, demo_floor_root_unsigned);\n    register_signed_demos!(runner, demo_floor_root_signed);\n    register_unsigned_demos!(runner, demo_floor_root_assign_unsigned);\n    register_signed_demos!(runner, demo_floor_root_assign_signed);\n    register_unsigned_demos!(runner, demo_ceiling_root_unsigned);\n    register_signed_demos!(runner, demo_ceiling_root_signed);\n    register_unsigned_demos!(runner, demo_ceiling_root_assign_unsigned);\n    register_signed_demos!(runner, demo_ceiling_root_assign_signed);\n    register_unsigned_demos!(runner, demo_checked_root_unsigned);\n    register_signed_demos!(runner, demo_checked_root_signed);\n    register_unsigned_demos!(runner, demo_root_rem);\n    register_unsigned_demos!(runner, demo_root_assign_rem);\n\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_unsigned_u8);\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_unsigned_u16);\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_unsigned_u32);\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_unsigned_u64);\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_unsigned_u128);\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_unsigned_usize);\n\n    register_signed_benches!(runner, benchmark_floor_cbrt_signed);\n    register_unsigned_benches!(runner, benchmark_floor_cbrt_assign_unsigned);\n    register_signed_benches!(runner, benchmark_floor_cbrt_assign_signed);\n    register_unsigned_benches!(runner, benchmark_ceiling_cbrt_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_ceiling_cbrt_signed);\n    register_unsigned_benches!(runner, benchmark_ceiling_cbrt_assign_unsigned);\n    register_signed_benches!(runner, benchmark_ceiling_cbrt_assign_signed);\n    register_unsigned_benches!(runner, benchmark_checked_cbrt_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_checked_cbrt_signed);\n    register_unsigned_benches!(runner, benchmark_cbrt_rem_algorithms);\n    register_unsigned_benches!(runner, benchmark_cbrt_assign_rem);\n\n    register_bench!(runner, benchmark_floor_root_algorithms_unsigned_u8);\n    register_bench!(runner, benchmark_floor_root_algorithms_unsigned_u16);\n    register_bench!(runner, benchmark_floor_root_algorithms_unsigned_u32);\n    register_bench!(runner, benchmark_floor_root_algorithms_unsigned_u64);\n    register_bench!(runner, benchmark_floor_root_algorithms_unsigned_u128);\n    register_bench!(runner, benchmark_floor_root_algorithms_unsigned_usize);\n\n    register_signed_benches!(runner, benchmark_floor_root_signed);\n    register_unsigned_benches!(runner, benchmark_floor_root_assign_unsigned);\n    register_signed_benches!(runner, benchmark_floor_root_assign_signed);\n    register_unsigned_benches!(runner, benchmark_ceiling_root_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_ceiling_root_signed);\n    register_unsigned_benches!(runner, benchmark_ceiling_root_assign_unsigned);\n    register_signed_benches!(runner, benchmark_ceiling_root_assign_signed);\n    register_unsigned_benches!(runner, benchmark_checked_root_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_checked_root_signed);\n    register_unsigned_benches!(runner, benchmark_root_rem_algorithms);\n    register_unsigned_benches!(runner, benchmark_root_assign_rem);\n\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_2_u32);\n    register_bench!(runner, benchmark_floor_cbrt_algorithms_2_u64);\n    register_bench!(runner, benchmark_floor_root_algorithms_2_u32);\n    register_bench!(runner, benchmark_floor_root_algorithms_2_u64);\n    register_bench!(runner, benchmark_ceiling_root_algorithms_2_u32);\n    register_bench!(runner, benchmark_ceiling_root_algorithms_2_u64);\n    register_bench!(runner, benchmark_checked_root_algorithms_2_u32);\n    register_bench!(runner, benchmark_checked_root_algorithms_2_u64);\n    register_bench!(runner, benchmark_root_rem_algorithms_2_u32);\n    register_bench!(runner, benchmark_root_rem_algorithms_2_u64);\n}\n\nfn demo_floor_cbrt_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"floor_root({}, 3) = {}\", n, n.floor_root(3));\n    }\n}\n\nfn demo_floor_cbrt_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"floor_root({}, 3) = {}\", n, n.floor_root(3));\n    }\n}\n\nfn demo_floor_cbrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.floor_root_assign(3);\n        println!(\"n := {old_n}; n.floor_root_assign(3); n = {n}\");\n    }\n}\n\nfn demo_floor_cbrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.floor_root_assign(3);\n        println!(\"n := {old_n}; n.floor_root_assign(3); n = {n}\");\n    }\n}\n\nfn demo_ceiling_cbrt_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"ceiling_root({}, 3) = {}\", n, n.ceiling_root(3));\n    }\n}\n\nfn demo_ceiling_cbrt_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"ceiling_root({}, 3) = {}\", n, n.ceiling_root(3));\n    }\n}\n\nfn demo_ceiling_cbrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.ceiling_root_assign(3);\n        println!(\"n := {old_n}; n.ceiling_root_assign(3); n = {n}\");\n    }\n}\n\nfn demo_ceiling_cbrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.ceiling_root_assign(3);\n        println!(\"n := {old_n}; n.ceiling_root_assign(3); n = {n}\");\n    }\n}\n\nfn demo_checked_cbrt_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"checked_root({}, 3) = {:?}\", n, n.checked_root(3));\n    }\n}\n\nfn demo_checked_cbrt_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"checked_root({}, 3) = {:?}\", n, n.checked_root(3));\n    }\n}\n\nfn demo_cbrt_rem<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"root_rem({}, 3) = {:?}\", n, n.root_rem(3));\n    }\n}\n\nfn demo_cbrt_assign_rem<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        let rem = n.root_assign_rem(3);\n        println!(\"n := {old_n}; n.root_assign_rem(3) = {rem}; n = {n}\");\n    }\n}\n\nfn demo_floor_root_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"floor_root({}, {}) = {}\", n, exp, n.floor_root(exp));\n    }\n}\n\nfn demo_floor_root_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in signed_unsigned_pair_gen_var_18::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"floor_root({}, {}) = {}\", n, exp, n.floor_root(exp));\n    }\n}\n\nfn demo_floor_root_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, exp) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.floor_root_assign(exp);\n        println!(\"n := {old_n}; n.floor_root_assign({exp}); n = {n}\");\n    }\n}\n\nfn demo_floor_root_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, exp) in signed_unsigned_pair_gen_var_18::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.floor_root_assign(exp);\n        println!(\"n := {old_n}; n.floor_root_assign({exp}); n = {n}\");\n    }\n}\n\nfn demo_ceiling_root_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"ceiling_root({}, {}) = {}\", n, exp, n.ceiling_root(exp));\n    }\n}\n\nfn demo_ceiling_root_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in signed_unsigned_pair_gen_var_18::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"ceiling_root({}, {}) = {}\", n, exp, n.ceiling_root(exp));\n    }\n}\n\nfn demo_ceiling_root_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, exp) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.floor_root_assign(exp);\n        println!(\"n := {old_n}; n.ceiling_root_assign({exp}); n = {n}\");\n    }\n}\n\nfn demo_ceiling_root_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, exp) in signed_unsigned_pair_gen_var_18::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.floor_root_assign(exp);\n        println!(\"n := {old_n}; n.ceiling_root_assign({exp}); n = {n}\");\n    }\n}\n\nfn demo_checked_root_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"checked_root({}, {}) = {:?}\", n, exp, n.checked_root(exp));\n    }\n}\n\nfn demo_checked_root_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in signed_unsigned_pair_gen_var_18::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"checked_root({}, {}) = {:?}\", n, exp, n.checked_root(exp));\n    }\n}\n\nfn demo_root_rem<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"root_rem({}, {}) = {:?}\", n, exp, n.root_rem(exp));\n    }\n}\n\nfn demo_root_assign_rem<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, exp) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        let rem = n.root_assign_rem(exp);\n        println!(\"n := {old_n}; n.root_assign_rem({exp}) = {rem}; n = {n}\");\n    }\n}\n\nmacro_rules! benchmark_floor_cbrt_algorithms_unsigned {\n    ($t:ident, $f:ident) => {\n        fn $f(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n            #[allow(clippy::cast_lossless)]\n            run_benchmark(\n                &format!(\"{}.floor_root(3)\", $t::NAME),\n                BenchmarkType::Algorithms,\n                unsigned_gen::<$t>().get(gm, config),\n                gm.name(),\n                limit,\n                file_name,\n                &unsigned_bit_bucketer(),\n                &mut [\n                    (\"default\", &mut |n| no_out!(n.floor_root(3))),\n                    (\"binary\", &mut |n| no_out!(floor_root_binary(n, 3))),\n                    (\"approx and refine\", &mut |n| {\n                        no_out!(floor_root_approx_and_refine(\n                            |x| x as f64,\n                            |f| f as $t,\n                            n,\n                            3\n                        ))\n                    }),\n                ],\n            );\n        }\n    };\n}\nbenchmark_floor_cbrt_algorithms_unsigned!(u8, benchmark_floor_cbrt_algorithms_unsigned_u8);\nbenchmark_floor_cbrt_algorithms_unsigned!(u16, benchmark_floor_cbrt_algorithms_unsigned_u16);\nbenchmark_floor_cbrt_algorithms_unsigned!(u32, benchmark_floor_cbrt_algorithms_unsigned_u32);\nbenchmark_floor_cbrt_algorithms_unsigned!(u64, benchmark_floor_cbrt_algorithms_unsigned_u64);\nbenchmark_floor_cbrt_algorithms_unsigned!(u128, benchmark_floor_cbrt_algorithms_unsigned_u128);\nbenchmark_floor_cbrt_algorithms_unsigned!(usize, benchmark_floor_cbrt_algorithms_unsigned_usize);\n\nfn benchmark_floor_cbrt_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_root(3)\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.floor_root(3)))],\n    );\n}\n\nfn benchmark_floor_cbrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_root_assign(3)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.floor_root_assign(3))],\n    );\n}\n\nfn benchmark_floor_cbrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_cbrt_assign(3)\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.floor_root_assign(3))],\n    );\n}\n\nfn benchmark_ceiling_cbrt_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_root(3)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.ceiling_root(3))),\n            (\"binary\", &mut |n| no_out!(ceiling_root_binary(n, 3))),\n        ],\n    );\n}\n\nfn benchmark_ceiling_cbrt_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_root(3)\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.ceiling_root(3)))],\n    );\n}\n\nfn benchmark_ceiling_cbrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_root_assign(3)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.ceiling_root_assign(3))],\n    );\n}\n\nfn benchmark_ceiling_cbrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_cbrt_assign(3)\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.ceiling_root_assign(3))],\n    );\n}\n\nfn benchmark_checked_cbrt_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_root(3)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.checked_root(3))),\n            (\"binary\", &mut |n| no_out!(checked_root_binary(n, 3))),\n        ],\n    );\n}\n\nfn benchmark_checked_cbrt_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_roor(3)\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.checked_root(3)))],\n    );\n}\n\nfn benchmark_cbrt_rem_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.root_rem(3)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.root_rem(3))),\n            (\"binary\", &mut |n| no_out!(root_rem_binary(n, 3))),\n        ],\n    );\n}\n\nfn benchmark_cbrt_assign_rem<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.root_assign_rem(3)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| no_out!(n.root_assign_rem(3)))],\n    );\n}\n\nmacro_rules! benchmark_floor_root_algorithms_unsigned {\n    ($t:ident, $f:ident) => {\n        fn $f(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n            #[allow(clippy::cast_lossless)]\n            run_benchmark(\n                &format!(\"{}.floor_root(u64)\", $t::NAME),\n                BenchmarkType::Algorithms,\n                unsigned_pair_gen_var_32::<$t, u64>().get(gm, config),\n                gm.name(),\n                limit,\n                file_name,\n                &pair_1_bit_bucketer(\"x\"),\n                &mut [\n                    (\"default\", &mut |(n, exp)| no_out!(n.floor_root(exp))),\n                    (\"binary\", &mut |(n, exp)| no_out!(floor_root_binary(n, exp))),\n                    (\"approx and refine\", &mut |(n, exp)| {\n                        no_out!(floor_root_approx_and_refine(\n                            |x| x as f64,\n                            |f| f as $t,\n                            n,\n                            exp\n                        ))\n                    }),\n                ],\n            );\n        }\n    };\n}\nbenchmark_floor_root_algorithms_unsigned!(u8, benchmark_floor_root_algorithms_unsigned_u8);\nbenchmark_floor_root_algorithms_unsigned!(u16, benchmark_floor_root_algorithms_unsigned_u16);\nbenchmark_floor_root_algorithms_unsigned!(u32, benchmark_floor_root_algorithms_unsigned_u32);\nbenchmark_floor_root_algorithms_unsigned!(u64, benchmark_floor_root_algorithms_unsigned_u64);\nbenchmark_floor_root_algorithms_unsigned!(u128, benchmark_floor_root_algorithms_unsigned_u128);\nbenchmark_floor_root_algorithms_unsigned!(usize, benchmark_floor_root_algorithms_unsigned_usize);\n\nfn benchmark_floor_root_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_root(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_18::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, exp)| no_out!(n.floor_root(exp)))],\n    );\n}\n\nfn benchmark_floor_root_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_root_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_32::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, exp)| n.floor_root_assign(exp))],\n    );\n}\n\nfn benchmark_floor_root_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_root_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_18::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, exp)| n.floor_root_assign(exp))],\n    );\n}\n\nfn benchmark_ceiling_root_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_root(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.ceiling_root(exp))),\n            (\"binary\", &mut |(n, exp)| {\n                no_out!(ceiling_root_binary(n, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_ceiling_root_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_root(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_18::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, exp)| no_out!(n.ceiling_root(exp)))],\n    );\n}\n\nfn benchmark_ceiling_root_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_root_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_32::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, exp)| n.ceiling_root_assign(exp))],\n    );\n}\n\nfn benchmark_ceiling_root_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_root_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_18::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, exp)| n.ceiling_root_assign(exp))],\n    );\n}\n\nfn benchmark_checked_root_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_root(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.checked_root(exp))),\n            (\"binary\", &mut |(n, exp)| {\n                no_out!(checked_root_binary(n, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_root_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_root(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_18::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, exp)| no_out!(n.checked_root(exp)))],\n    );\n}\n\nfn benchmark_root_rem_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.root_rem(u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.root_rem(exp))),\n            (\"binary\", &mut |(n, exp)| no_out!(root_rem_binary(n, exp))),\n        ],\n    );\n}\n\nfn benchmark_root_assign_rem<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.root_assign_rem(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_32::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, exp)| {\n            no_out!(n.root_assign_rem(exp));\n        })],\n    );\n}\n\nfn benchmark_floor_cbrt_algorithms_2_u32(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32.floor_root(3)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.floor_root(3))),\n            (\"binary\", &mut |n| no_out!(floor_root_binary(n, 3))),\n            (\"fast\", &mut |n| no_out!(fast_floor_cbrt_u32(n))),\n            (\"Chebyshev\", &mut |n| no_out!(cbrt_chebyshev_approx_u32(n))),\n            (\"approx and refine\", &mut |n| {\n                no_out!(floor_root_approx_and_refine(f64::from, |f| f as u32, n, 3));\n            }),\n        ],\n    );\n}\n\nfn benchmark_floor_cbrt_algorithms_2_u64(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64.floor_root(3)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.floor_root(3))),\n            (\"binary\", &mut |n| no_out!(floor_root_binary(n, 3))),\n            (\"fast\", &mut |n| no_out!(fast_floor_cbrt_u64(n))),\n            (\"Chebyshev\", &mut |n| no_out!(cbrt_chebyshev_approx_u64(n))),\n            (\"approx and refine\", &mut |n| {\n                no_out!(floor_root_approx_and_refine(\n                    |x| x as f64,\n                    |f| f as u64,\n                    n,\n                    3\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_floor_root_algorithms_2_u32(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32.floor_root(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u32, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.floor_root(exp))),\n            (\"binary\", &mut |(n, exp)| no_out!(floor_root_binary(n, exp))),\n            (\"fast\", &mut |(n, exp)| no_out!(fast_floor_root_u32(n, exp))),\n            (\"approx and refine\", &mut |(n, exp)| {\n                no_out!(floor_root_approx_and_refine(\n                    f64::from,\n                    |f| f as u32,\n                    n,\n                    exp\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_floor_root_algorithms_2_u64(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64.floor_root(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u64, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.floor_root(exp))),\n            (\"binary\", &mut |(n, exp)| no_out!(floor_root_binary(n, exp))),\n            (\"fast\", &mut |(n, exp)| no_out!(fast_floor_root_u64(n, exp))),\n            (\"approx and refine\", &mut |(n, exp)| {\n                no_out!(floor_root_approx_and_refine(\n                    |x| x as f64,\n                    |f| f as u64,\n                    n,\n                    exp\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_ceiling_root_algorithms_2_u32(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32.ceiling_root(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u32, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.ceiling_root(exp))),\n            (\"binary\", &mut |(n, exp)| {\n                no_out!(ceiling_root_binary(n, exp));\n            }),\n            (\"fast\", &mut |(n, exp)| {\n                no_out!(fast_ceiling_root_u32(n, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_ceiling_root_algorithms_2_u64(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64.ceiling_root(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u64, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.ceiling_root(exp))),\n            (\"binary\", &mut |(n, exp)| {\n                no_out!(ceiling_root_binary(n, exp));\n            }),\n            (\"fast\", &mut |(n, exp)| {\n                no_out!(fast_ceiling_root_u64(n, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_root_algorithms_2_u32(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32.checked_root(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u32, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.checked_root(exp))),\n            (\"binary\", &mut |(n, exp)| {\n                no_out!(checked_root_binary(n, exp));\n            }),\n            (\"fast\", &mut |(n, exp)| {\n                no_out!(fast_checked_root_u32(n, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_checked_root_algorithms_2_u64(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64.checked_root(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u64, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.checked_root(exp))),\n            (\"binary\", &mut |(n, exp)| {\n                no_out!(checked_root_binary(n, exp));\n            }),\n            (\"fast\", &mut |(n, exp)| {\n                no_out!(fast_checked_root_u64(n, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_root_rem_algorithms_2_u32(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32.root_rem(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u32, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.root_rem(exp))),\n            (\"binary\", &mut |(n, exp)| no_out!(root_rem_binary(n, exp))),\n            (\"fast\", &mut |(n, exp)| no_out!(fast_root_rem_u32(n, exp))),\n        ],\n    );\n}\n\nfn benchmark_root_rem_algorithms_2_u64(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64.root_rem(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_32::<u64, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, exp)| no_out!(n.root_rem(exp))),\n            (\"binary\", &mut |(n, exp)| no_out!(root_rem_binary(n, exp))),\n            (\"fast\", &mut |(n, exp)| no_out!(fast_root_rem_u64(n, exp))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/rotate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_1_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rotate_left_assign_unsigned);\n    register_signed_demos!(runner, demo_rotate_left_assign_signed);\n    register_unsigned_demos!(runner, demo_rotate_right_assign_unsigned);\n    register_signed_demos!(runner, demo_rotate_right_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_rotate_left_assign_unsigned);\n    register_signed_benches!(runner, benchmark_rotate_left_assign_signed);\n    register_unsigned_benches!(runner, benchmark_rotate_right_assign_unsigned);\n    register_signed_benches!(runner, benchmark_rotate_right_assign_signed);\n}\n\nfn demo_rotate_left_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut u, n) in unsigned_pair_gen::<T, u64>().get(gm, config).take(limit) {\n        let old_u = u;\n        u.rotate_left_assign(n);\n        println!(\"u := {old_u}; u.rotate_left_assign({n}); u = {u}\");\n    }\n}\n\nfn demo_rotate_left_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut i, n) in signed_unsigned_pair_gen::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_i = i;\n        i.rotate_left_assign(n);\n        println!(\"i := {old_i}; i.rotate_left_assign({n}); i = {i}\");\n    }\n}\n\nfn demo_rotate_right_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut u, n) in unsigned_pair_gen::<T, u64>().get(gm, config).take(limit) {\n        let old_u = u;\n        u.rotate_right_assign(n);\n        println!(\"u := {old_u}; u.rotate_right_assign({n}); u = {u}\");\n    }\n}\n\nfn demo_rotate_right_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut i, n) in signed_unsigned_pair_gen::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_i = i;\n        i.rotate_right_assign(n);\n        println!(\"i := {old_i}; i.rotate_right_assign({n}); i = {i}\");\n    }\n}\n\nfn benchmark_rotate_left_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rotate_left_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(mut u, n)| u.rotate_left_assign(n))],\n    );\n}\n\nfn benchmark_rotate_left_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rotate_left_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(mut i, n)| i.rotate_left_assign(n))],\n    );\n}\n\nfn benchmark_rotate_right_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rotate_right_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(mut u, n)| u.rotate_right_assign(n))],\n    );\n}\n\nfn benchmark_rotate_right_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rotate_right_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(mut i, n)| i.rotate_right_assign(n))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::test_util::bench::bucketers::triple_1_2_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_signed_rounding_mode_triple_gen_var_2, unsigned_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_round_to_multiple_unsigned);\n    register_unsigned_demos!(runner, demo_round_to_multiple_assign_unsigned);\n    register_signed_unsigned_match_demos!(runner, demo_round_to_multiple_signed);\n    register_signed_unsigned_match_demos!(runner, demo_round_to_multiple_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_round_to_multiple_unsigned);\n    register_unsigned_benches!(runner, benchmark_round_to_multiple_assign_unsigned);\n    register_signed_unsigned_match_benches!(runner, benchmark_round_to_multiple_signed);\n    register_signed_unsigned_match_benches!(runner, benchmark_round_to_multiple_assign_signed);\n}\n\nfn demo_round_to_multiple_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.round_to_multiple({}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_round_to_multiple_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let o = x.round_to_multiple_assign(y, rm);\n        println!(\"x := {old_x}; x.round_to_multiple_assign({y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_round_to_multiple_signed<\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, rm) in signed_signed_rounding_mode_triple_gen_var_2::<U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).round_to_multiple({}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_round_to_multiple_assign_signed<\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, rm) in signed_signed_rounding_mode_triple_gen_var_2::<U, S>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let o = x.round_to_multiple_assign(y, rm);\n        println!(\"x := {old_x}; x.round_to_multiple_assign({y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn benchmark_round_to_multiple_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.round_to_multiple({}, RoundingMode)\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y, rm)| {\n            no_out!(x.round_to_multiple(y, rm));\n        })],\n    );\n}\n\nfn benchmark_round_to_multiple_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.round_to_multiple_assign({}, RoundingMode)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.round_to_multiple_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_round_to_multiple_signed<\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.round_to_multiple({}, RoundingMode)\", S::NAME, S::NAME),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_2::<U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y, rm)| {\n            no_out!(x.round_to_multiple(y, rm));\n        })],\n    );\n}\n\nfn benchmark_round_to_multiple_assign_signed<\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.round_to_multiple_assign({}, RoundingMode)\",\n            S::NAME,\n            S::NAME\n        ),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_2::<U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.round_to_multiple_assign(y, rm));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_1_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_rounding_mode_triple_gen_var_1,\n    unsigned_unsigned_rounding_mode_triple_gen_var_3,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_round_to_multiple_of_power_of_2_unsigned);\n    register_unsigned_demos!(runner, demo_round_to_multiple_of_power_of_2_assign_unsigned);\n    register_signed_demos!(runner, demo_round_to_multiple_of_power_of_2_signed);\n    register_signed_demos!(runner, demo_round_to_multiple_of_power_of_2_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_round_to_multiple_of_power_of_2_unsigned);\n    register_unsigned_benches!(\n        runner,\n        benchmark_round_to_multiple_of_power_of_2_assign_unsigned\n    );\n    register_signed_benches!(runner, benchmark_round_to_multiple_of_power_of_2_signed);\n    register_signed_benches!(\n        runner,\n        benchmark_round_to_multiple_of_power_of_2_assign_signed\n    );\n}\n\nfn demo_round_to_multiple_of_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, pow, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            x,\n            pow,\n            rm,\n            x.round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn demo_round_to_multiple_of_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, pow, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let o = x.round_to_multiple_of_power_of_2_assign(pow, rm);\n        println!(\n            \"x := {old_x}; x.round_to_multiple_of_power_of_2_assign({pow}, {rm}) = {o:?}; x = {x}\"\n        );\n    }\n}\n\nfn demo_round_to_multiple_of_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, pow, rm) in signed_unsigned_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            x,\n            pow,\n            rm,\n            x.round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn demo_round_to_multiple_of_power_of_2_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, pow, rm) in signed_unsigned_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        let o = x.round_to_multiple_of_power_of_2_assign(pow, rm);\n        println!(\n            \"x := {old_x}; x.round_to_multiple_of_power_of_2_assign({pow}, {rm}) = {o:?}; x = {x}\"\n        );\n    }\n}\n\nfn benchmark_round_to_multiple_of_power_of_2_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.round_to_multiple_of_power_of_2({}, RoundingMode)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y, rm)| {\n            no_out!(x.round_to_multiple_of_power_of_2(y, rm));\n        })],\n    );\n}\n\nfn benchmark_round_to_multiple_of_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.round_to_multiple_of_power_of_2_assign({}, RoundingMode)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.round_to_multiple_of_power_of_2_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_round_to_multiple_of_power_of_2_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.round_to_multiple_of_power_of_2({}, RoundingMode)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_unsigned_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y, rm)| {\n            no_out!(x.round_to_multiple_of_power_of_2(y, rm));\n        })],\n    );\n}\n\nfn benchmark_round_to_multiple_of_power_of_2_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.round_to_multiple_of_power_of_2_assign({}, RoundingMode)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_unsigned_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.round_to_multiple_of_power_of_2_assign(y, rm));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::bucketers::signed_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_saturating_abs_assign);\n    register_signed_benches!(runner, benchmark_saturating_abs_assign);\n}\n\nfn demo_saturating_abs_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut i in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.saturating_abs_assign();\n        println!(\"i := {old_i}; i.saturating_abs_assign(); i = {i}\");\n    }\n}\n\nfn benchmark_saturating_abs_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_abs_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.saturating_abs_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_saturating_add_unsigned);\n    register_signed_demos!(runner, demo_saturating_add_signed);\n    register_unsigned_demos!(runner, demo_saturating_add_assign_unsigned);\n    register_signed_demos!(runner, demo_saturating_add_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_saturating_add_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_add_signed);\n    register_unsigned_benches!(runner, benchmark_saturating_add_assign_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_add_assign_signed);\n}\n\nfn demo_saturating_add_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.saturating_add({}) = {}\", x, y, x.saturating_add(y));\n    }\n}\n\nfn demo_saturating_add_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).saturating_add({}) = {}\", x, y, x.saturating_add(y));\n    }\n}\n\nfn demo_saturating_add_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_add_assign(y);\n        println!(\"x := {old_x}; x.saturating_add_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_saturating_add_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_add_assign(y);\n        println!(\"x := {old_x}; x.saturating_add_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_saturating_add_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_add({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.saturating_add(y)))],\n    );\n}\n\nfn benchmark_saturating_add_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_add({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.saturating_add(y)))],\n    );\n}\n\nfn benchmark_saturating_add_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_add_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_add_assign(y))],\n    );\n}\n\nfn benchmark_saturating_add_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_add_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_add_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_saturating_add_mul_unsigned);\n    register_signed_demos!(runner, demo_saturating_add_mul_signed);\n    register_unsigned_demos!(runner, demo_saturating_add_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_saturating_add_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_saturating_add_mul_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_add_mul_signed);\n    register_unsigned_benches!(runner, benchmark_saturating_add_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_add_mul_assign_signed);\n}\n\nfn demo_saturating_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.saturating_add_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.saturating_add_mul(y, z)\n        );\n    }\n}\n\nfn demo_saturating_add_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.saturating_add_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.saturating_add_mul(y, z)\n        );\n    }\n}\n\nfn demo_saturating_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.saturating_add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.saturating_add_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_saturating_add_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.saturating_add_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn benchmark_saturating_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.saturating_add_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_saturating_add_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.saturating_add_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_saturating_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.saturating_add_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.saturating_add_mul_assign(y, z);\n        })],\n    );\n}\n\nfn benchmark_saturating_add_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.saturating_add_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.saturating_add_mul_assign(y, z);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_saturating_mul_unsigned);\n    register_signed_demos!(runner, demo_saturating_mul_signed);\n    register_unsigned_demos!(runner, demo_saturating_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_saturating_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_saturating_mul_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_mul_signed);\n    register_unsigned_benches!(runner, benchmark_saturating_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_mul_assign_signed);\n}\n\nfn demo_saturating_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.saturating_mul({}) = {}\", x, y, x.saturating_mul(y));\n    }\n}\n\nfn demo_saturating_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).saturating_mul({}) = {}\", x, y, x.saturating_mul(y));\n    }\n}\n\nfn demo_saturating_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_mul_assign(y);\n        println!(\"x := {old_x}; x.saturating_mul_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_saturating_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_mul_assign(y);\n        println!(\"x := {old_x}; x.saturating_mul_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_saturating_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_mul({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.saturating_mul(y)))],\n    );\n}\n\nfn benchmark_saturating_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_mul({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.saturating_mul(y)))],\n    );\n}\n\nfn benchmark_saturating_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_mul_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_mul_assign(y))],\n    );\n}\n\nfn benchmark_saturating_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_mul_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_mul_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::bucketers::signed_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_saturating_neg_assign);\n    register_signed_benches!(runner, benchmark_saturating_neg_assign);\n}\n\nfn demo_saturating_neg_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut i in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.saturating_neg_assign();\n        println!(\"i := {old_i}; i.saturating_neg_assign(); i = {i}\");\n    }\n}\n\nfn benchmark_saturating_neg_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_neg_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.saturating_neg_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_saturating_pow_assign_unsigned);\n    register_signed_demos!(runner, demo_saturating_pow_assign_signed);\n    register_unsigned_benches!(runner, benchmark_saturating_pow_assign_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_pow_assign_signed);\n}\n\nfn demo_saturating_pow_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen::<T, u64>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_pow_assign(y);\n        println!(\"x := {old_x}; x.saturating_pow_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_saturating_pow_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_unsigned_pair_gen::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.saturating_pow_assign(y);\n        println!(\"x := {old_x}; x.saturating_pow_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_saturating_pow_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_pow_assign(y))],\n    );\n}\n\nfn benchmark_saturating_pow_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_pow_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_saturating_square_unsigned);\n    register_signed_demos!(runner, demo_saturating_square_signed);\n    register_unsigned_demos!(runner, demo_saturating_square_assign_unsigned);\n    register_signed_demos!(runner, demo_saturating_square_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_saturating_square_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_square_signed);\n    register_unsigned_benches!(runner, benchmark_saturating_square_assign_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_square_assign_signed);\n}\n\nfn demo_saturating_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.saturating_square() = {}\", x, x.saturating_square());\n    }\n}\n\nfn demo_saturating_square_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.saturating_square() = {}\", x, x.saturating_square());\n    }\n}\n\nfn demo_saturating_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_square_assign();\n        println!(\"x := {old_x}; x.saturating_square_assign(); x = {x}\");\n    }\n}\n\nfn demo_saturating_square_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut x in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_square_assign();\n        println!(\"x := {old_x}; x.saturating_square_assign(); x = {x}\");\n    }\n}\n\nfn benchmark_saturating_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_square()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.saturating_square()))],\n    );\n}\n\nfn benchmark_saturating_square_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_square()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.saturating_square()))],\n    );\n}\n\nfn benchmark_saturating_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut x| x.saturating_square_assign())],\n    );\n}\n\nfn benchmark_saturating_square_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut x| x.saturating_square_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_saturating_sub_unsigned);\n    register_signed_demos!(runner, demo_saturating_sub_signed);\n    register_unsigned_demos!(runner, demo_saturating_sub_assign_unsigned);\n    register_signed_demos!(runner, demo_saturating_sub_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_saturating_sub_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_sub_signed);\n    register_unsigned_benches!(runner, benchmark_saturating_sub_assign_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_sub_assign_signed);\n}\n\nfn demo_saturating_sub_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.saturating_sub({}) = {}\", x, y, x.saturating_sub(y));\n    }\n}\n\nfn demo_saturating_sub_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).saturating_sub({}) = {}\", x, y, x.saturating_sub(y));\n    }\n}\n\nfn demo_saturating_sub_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_sub_assign(y);\n        println!(\"x := {old_x}; x.saturating_sub_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_saturating_sub_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_sub_assign(y);\n        println!(\"x := {old_x}; x.saturating_sub_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_saturating_sub_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_sub({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.saturating_sub(y)))],\n    );\n}\n\nfn benchmark_saturating_sub_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_sub({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.saturating_sub(y)))],\n    );\n}\n\nfn benchmark_saturating_sub_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_sub_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_sub_assign(y))],\n    );\n}\n\nfn benchmark_saturating_sub_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_sub_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.saturating_sub_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/saturating_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_saturating_sub_mul_unsigned);\n    register_signed_demos!(runner, demo_saturating_sub_mul_signed);\n    register_unsigned_demos!(runner, demo_saturating_sub_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_saturating_sub_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_saturating_sub_mul_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_sub_mul_signed);\n    register_unsigned_benches!(runner, benchmark_saturating_sub_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_saturating_sub_mul_assign_signed);\n}\n\nfn demo_saturating_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.saturating_sub_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.saturating_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_saturating_sub_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.saturating_sub_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.saturating_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_saturating_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.saturating_sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.saturating_sub_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_saturating_sub_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.saturating_sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.saturating_sub_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn benchmark_saturating_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.saturating_sub_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_saturating_sub_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.saturating_sub_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_saturating_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.saturating_sub_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.saturating_sub_mul_assign(y, z);\n        })],\n    );\n}\n\nfn benchmark_saturating_sub_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.saturating_sub_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.saturating_sub_mul_assign(y, z);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShlRound, ShlRoundAssign, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_2_unsigned_abs_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_signed_rounding_mode_triple_gen_var_4, unsigned_signed_rounding_mode_triple_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_signed_demos!(runner, demo_shl_round_unsigned_signed);\n    register_signed_signed_demos!(runner, demo_shl_round_signed_signed);\n    register_unsigned_signed_demos!(runner, demo_shl_round_assign_unsigned_signed);\n    register_signed_signed_demos!(runner, demo_shl_round_assign_signed_signed);\n\n    register_unsigned_signed_benches!(runner, benchmark_shl_round_unsigned_signed);\n    register_signed_signed_benches!(runner, benchmark_shl_round_signed_signed);\n    register_unsigned_signed_benches!(runner, benchmark_shl_round_assign_unsigned_signed);\n    register_signed_signed_benches!(runner, benchmark_shl_round_assign_signed_signed);\n}\n\nfn demo_shl_round_unsigned_signed<\n    T: PrimitiveUnsigned + ShlRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i, rm) in unsigned_signed_rounding_mode_triple_gen_var_2::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.shl_round({}, {}) = {:?}\", n, i, rm, n.shl_round(i, rm));\n    }\n}\n\nfn demo_shl_round_signed_signed<\n    T: PrimitiveSigned + ShlRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i, rm) in signed_signed_rounding_mode_triple_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).shl_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            n.shl_round(i, rm)\n        );\n    }\n}\n\nfn demo_shl_round_assign_unsigned_signed<\n    T: PrimitiveUnsigned + ShlRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, i, rm) in unsigned_signed_rounding_mode_triple_gen_var_2::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        let o = n.shl_round_assign(i, rm);\n        println!(\"x := {old_n}; x.shl_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_shl_round_assign_signed_signed<\n    T: PrimitiveSigned + ShlRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, i, rm) in signed_signed_rounding_mode_triple_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        let o = n.shl_round_assign(i, rm);\n        println!(\"x := {old_n}; x.shl_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn benchmark_shl_round_unsigned_signed<\n    T: PrimitiveUnsigned + ShlRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shl_round({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_rounding_mode_triple_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(n, i, rm)| no_out!(n.shl_round(i, rm)))],\n    );\n}\n\nfn benchmark_shl_round_signed_signed<\n    T: PrimitiveSigned + ShlRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shl_round({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_4::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(n, i, rm)| no_out!(n.shl_round(i, rm)))],\n    );\n}\n\nfn benchmark_shl_round_assign_unsigned_signed<\n    T: PrimitiveUnsigned + ShlRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shl_round_assign({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_rounding_mode_triple_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(mut n, i, rm)| {\n            no_out!(n.shl_round_assign(i, rm));\n        })],\n    );\n}\n\nfn benchmark_shl_round_assign_signed_signed<\n    T: PrimitiveSigned + ShlRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shl_round_assign({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_4::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(mut n, i, rm)| {\n            no_out!(n.shl_round_assign(i, rm));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShrRound, ShrRoundAssign, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    triple_2_bucketer, triple_2_unsigned_abs_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_signed_rounding_mode_triple_gen_var_3, signed_unsigned_rounding_mode_triple_gen_var_2,\n    unsigned_signed_rounding_mode_triple_gen_var_1,\n    unsigned_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_shr_round_unsigned_unsigned);\n    register_unsigned_signed_demos!(runner, demo_shr_round_unsigned_signed);\n    register_signed_unsigned_demos!(runner, demo_shr_round_signed_unsigned);\n    register_signed_signed_demos!(runner, demo_shr_round_signed_signed);\n    register_unsigned_unsigned_demos!(runner, demo_shr_round_assign_unsigned_unsigned);\n    register_unsigned_signed_demos!(runner, demo_shr_round_assign_unsigned_signed);\n    register_signed_unsigned_demos!(runner, demo_shr_round_assign_signed_unsigned);\n    register_signed_signed_demos!(runner, demo_shr_round_assign_signed_signed);\n\n    register_unsigned_unsigned_benches!(runner, benchmark_shr_round_unsigned_unsigned);\n    register_unsigned_signed_benches!(runner, benchmark_shr_round_unsigned_signed);\n    register_signed_unsigned_benches!(runner, benchmark_shr_round_signed_unsigned);\n    register_signed_signed_benches!(runner, benchmark_shr_round_signed_signed);\n    register_unsigned_unsigned_benches!(runner, benchmark_shr_round_assign_unsigned_unsigned);\n    register_unsigned_signed_benches!(runner, benchmark_shr_round_assign_unsigned_signed);\n    register_signed_unsigned_benches!(runner, benchmark_shr_round_assign_signed_unsigned);\n    register_signed_signed_benches!(runner, benchmark_shr_round_assign_signed_signed);\n}\n\nfn demo_shr_round_unsigned_unsigned<\n    T: PrimitiveUnsigned + ShrRound<U, Output = T>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.shr_round({}, {}) = {:?}\", n, u, rm, n.shr_round(u, rm));\n    }\n}\n\nfn demo_shr_round_unsigned_signed<\n    T: PrimitiveUnsigned + ShrRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i, rm) in unsigned_signed_rounding_mode_triple_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.shr_round({}, {}) = {:?}\", n, i, rm, n.shr_round(i, rm));\n    }\n}\n\nfn demo_shr_round_signed_unsigned<\n    T: PrimitiveSigned + ShrRound<U, Output = T>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, rm) in signed_unsigned_rounding_mode_triple_gen_var_2::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).shr_round({}, {}) = {:?}\",\n            n,\n            u,\n            rm,\n            n.shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_shr_round_signed_signed<\n    T: PrimitiveSigned + ShrRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i, rm) in signed_signed_rounding_mode_triple_gen_var_3::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).shr_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            n.shr_round(i, rm)\n        );\n    }\n}\n\nfn demo_shr_round_assign_unsigned_unsigned<\n    T: PrimitiveUnsigned + ShrRoundAssign<U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        let o = n.shr_round_assign(u, rm);\n        println!(\"x := {old_n}; x.shr_round_assign({u}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_shr_round_assign_unsigned_signed<\n    T: PrimitiveUnsigned + ShrRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, i, rm) in unsigned_signed_rounding_mode_triple_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        let o = n.shr_round_assign(i, rm);\n        println!(\"x := {old_n}; x.shr_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_shr_round_assign_signed_unsigned<\n    T: PrimitiveSigned + ShrRoundAssign<U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, rm) in signed_unsigned_rounding_mode_triple_gen_var_2::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        let o = n.shr_round_assign(u, rm);\n        println!(\"x := {old_n}; x.shr_round_assign({u}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_shr_round_assign_signed_signed<\n    T: PrimitiveSigned + ShrRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, i, rm) in signed_signed_rounding_mode_triple_gen_var_3::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        let o = n.shr_round_assign(i, rm);\n        println!(\"x := {old_n}; x.shr_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn benchmark_shr_round_unsigned_unsigned<\n    T: PrimitiveUnsigned + ShrRound<U, Output = T>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_4::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(n, u, rm)| no_out!(n.shr_round(u, rm)))],\n    );\n}\n\nfn benchmark_shr_round_unsigned_signed<\n    T: PrimitiveUnsigned + ShrRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_rounding_mode_triple_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(n, i, rm)| no_out!(n.shr_round(i, rm)))],\n    );\n}\n\nfn benchmark_shr_round_signed_unsigned<\n    T: PrimitiveSigned + ShrRound<U, Output = T>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_rounding_mode_triple_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(n, u, rm)| no_out!(n.shr_round(u, rm)))],\n    );\n}\n\nfn benchmark_shr_round_signed_signed<\n    T: PrimitiveSigned + ShrRound<U, Output = T>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_3::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(n, i, rm)| no_out!(n.shr_round(i, rm)))],\n    );\n}\n\nfn benchmark_shr_round_assign_unsigned_unsigned<\n    T: PrimitiveUnsigned + ShrRoundAssign<U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round_assign({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_unsigned_rounding_mode_triple_gen_var_4::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, rm)| {\n            no_out!(n.shr_round_assign(u, rm));\n        })],\n    );\n}\n\nfn benchmark_shr_round_assign_unsigned_signed<\n    T: PrimitiveUnsigned + ShrRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round_assign({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_rounding_mode_triple_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(mut n, i, rm)| {\n            no_out!(n.shr_round_assign(i, rm));\n        })],\n    );\n}\n\nfn benchmark_shr_round_assign_signed_unsigned<\n    T: PrimitiveSigned + ShrRoundAssign<U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round_assign({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_rounding_mode_triple_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, rm)| {\n            no_out!(n.shr_round_assign(u, rm));\n        })],\n    );\n}\n\nfn benchmark_shr_round_assign_signed_signed<\n    T: PrimitiveSigned + ShrRoundAssign<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"{}.shr_round_assign({}, RoundingMode)\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_signed_rounding_mode_triple_gen_var_3::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_unsigned_abs_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(mut n, i, rm)| {\n            no_out!(n.shr_round_assign(i, rm));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_sign_unsigned);\n    register_signed_demos!(runner, demo_sign_signed);\n    register_primitive_float_demos!(runner, demo_sign_primitive_float);\n\n    register_unsigned_benches!(runner, benchmark_sign_unsigned);\n    register_signed_benches!(runner, benchmark_sign_signed);\n    register_primitive_float_benches!(runner, benchmark_sign_primitive_float);\n}\n\nfn demo_sign_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.sign() = {:?}\", u, u.sign());\n    }\n}\n\nfn demo_sign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.sign() = {:?}\", i, i.sign());\n    }\n}\n\nfn demo_sign_primitive_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).sign() = {:?}\", NiceFloat(f), f.sign());\n    }\n}\n\nfn benchmark_sign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.sign()))],\n    );\n}\n\nfn benchmark_sign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |i| no_out!(i.sign()))],\n    );\n}\n\nfn benchmark_sign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(f.sign()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::sqrt::{\n    ceiling_sqrt_binary, checked_sqrt_binary, floor_sqrt_binary, sqrt_rem_binary, sqrt_rem_newton,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, signed_gen_var_2, unsigned_gen, unsigned_gen_var_17,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_floor_sqrt_unsigned);\n    register_signed_demos!(runner, demo_floor_sqrt_signed);\n    register_unsigned_demos!(runner, demo_floor_sqrt_assign_unsigned);\n    register_signed_demos!(runner, demo_floor_sqrt_assign_signed);\n    register_unsigned_demos!(runner, demo_ceiling_sqrt_unsigned);\n    register_signed_demos!(runner, demo_ceiling_sqrt_signed);\n    register_unsigned_demos!(runner, demo_ceiling_sqrt_assign_unsigned);\n    register_signed_demos!(runner, demo_ceiling_sqrt_assign_signed);\n    register_unsigned_demos!(runner, demo_checked_sqrt_unsigned);\n    register_signed_demos!(runner, demo_checked_sqrt_signed);\n    register_unsigned_demos!(runner, demo_sqrt_rem);\n    register_unsigned_demos!(runner, demo_sqrt_assign_rem);\n    register_primitive_float_demos!(runner, demo_sqrt_assign);\n\n    register_unsigned_benches!(runner, benchmark_floor_sqrt_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_floor_sqrt_signed);\n    register_unsigned_benches!(runner, benchmark_floor_sqrt_assign_unsigned);\n    register_signed_benches!(runner, benchmark_floor_sqrt_assign_signed);\n    register_unsigned_benches!(runner, benchmark_ceiling_sqrt_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_ceiling_sqrt_signed);\n    register_unsigned_benches!(runner, benchmark_ceiling_sqrt_assign_unsigned);\n    register_signed_benches!(runner, benchmark_ceiling_sqrt_assign_signed);\n    register_unsigned_benches!(runner, benchmark_checked_sqrt_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_checked_sqrt_signed);\n    register_unsigned_benches!(runner, benchmark_sqrt_rem_algorithms);\n    register_generic_benches_2_only_first_in_key!(\n        runner,\n        benchmark_sqrt_rem_algorithms_2,\n        [u32, i32],\n        [u64, i64]\n    );\n    register_unsigned_benches!(runner, benchmark_sqrt_assign_rem);\n    register_primitive_float_benches!(runner, benchmark_sqrt_assign);\n}\n\nfn demo_floor_sqrt_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"floor_sqrt({}) = {}\", n, n.floor_sqrt());\n    }\n}\n\nfn demo_floor_sqrt_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen_var_2::<T>().get(gm, config).take(limit) {\n        println!(\"floor_sqrt({}) = {}\", n, n.floor_sqrt());\n    }\n}\n\nfn demo_floor_sqrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.floor_sqrt_assign();\n        println!(\"n := {old_n}; n.floor_sqrt_assign(); n = {n}\");\n    }\n}\n\nfn demo_floor_sqrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in signed_gen_var_2::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.floor_sqrt_assign();\n        println!(\"n := {old_n}; n.floor_sqrt_assign(); n = {n}\");\n    }\n}\n\nfn demo_ceiling_sqrt_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"ceiling_sqrt({}) = {}\", n, n.ceiling_sqrt());\n    }\n}\n\nfn demo_ceiling_sqrt_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen_var_2::<T>().get(gm, config).take(limit) {\n        println!(\"ceiling_sqrt({}) = {}\", n, n.ceiling_sqrt());\n    }\n}\n\nfn demo_ceiling_sqrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.ceiling_sqrt_assign();\n        println!(\"n := {old_n}; n.ceiling_sqrt_assign(); n = {n}\");\n    }\n}\n\nfn demo_ceiling_sqrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut n in signed_gen_var_2::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        n.ceiling_sqrt_assign();\n        println!(\"n := {old_n}; n.ceiling_sqrt_assign(); n = {n}\");\n    }\n}\n\nfn demo_checked_sqrt_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"checked_sqrt({}) = {:?}\", n, n.checked_sqrt());\n    }\n}\n\nfn demo_checked_sqrt_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen_var_2::<T>().get(gm, config).take(limit) {\n        println!(\"checked_sqrt({}) = {:?}\", n, n.checked_sqrt());\n    }\n}\n\nfn demo_sqrt_rem<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let (sqrt, rem) = n.sqrt_rem();\n        println!(\"{n} = {sqrt} ^ 2 + {rem}\");\n    }\n}\n\nfn demo_sqrt_assign_rem<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_n = n;\n        let rem = n.sqrt_assign_rem();\n        println!(\"n := {old_n}; n.sqrt_assign() = {rem}; n = {n}\");\n    }\n}\n\nfn demo_sqrt_assign<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_f = f;\n        f.sqrt_assign();\n        println!(\n            \"i := {}; i.sqrt_assign(); i = {}\",\n            NiceFloat(old_f),\n            NiceFloat(f)\n        );\n    }\n}\n\nfn benchmark_floor_sqrt_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_sqrt()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.floor_sqrt())),\n            (\"binary\", &mut |n| no_out!(floor_sqrt_binary(n))),\n        ],\n    );\n}\n\nfn benchmark_floor_sqrt_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_sqrt()\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.floor_sqrt()))],\n    );\n}\n\nfn benchmark_floor_sqrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_sqrt_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.floor_sqrt_assign())],\n    );\n}\n\nfn benchmark_floor_sqrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.floor_sqrt_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.floor_sqrt_assign())],\n    );\n}\n\nfn benchmark_ceiling_sqrt_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_sqrt()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.ceiling_sqrt())),\n            (\"binary\", &mut |n| no_out!(ceiling_sqrt_binary(n))),\n        ],\n    );\n}\n\nfn benchmark_ceiling_sqrt_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_sqrt()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.ceiling_sqrt()))],\n    );\n}\n\nfn benchmark_ceiling_sqrt_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_sqrt_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.ceiling_sqrt_assign())],\n    );\n}\n\nfn benchmark_ceiling_sqrt_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ceiling_sqrt_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| n.ceiling_sqrt_assign())],\n    );\n}\n\nfn benchmark_checked_sqrt_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_sqrt()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.checked_sqrt())),\n            (\"binary\", &mut |n| no_out!(checked_sqrt_binary(n))),\n        ],\n    );\n}\n\nfn benchmark_checked_sqrt_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_sqrt()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.checked_sqrt()))],\n    );\n}\n\nfn benchmark_sqrt_rem_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sqrt_rem()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.sqrt_rem())),\n            (\"binary\", &mut |n| no_out!(sqrt_rem_binary(n))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_sqrt_rem_algorithms_2<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sqrt_assign_rem()\", U::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_17::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |n| {\n                for _ in 0..10 {\n                    n.sqrt_rem().0;\n                }\n            }),\n            (\"Newton's method\", &mut |n| {\n                for _ in 0..10 {\n                    sqrt_rem_newton::<U, S>(n).0;\n                }\n            }),\n        ],\n    );\n}\n\nfn benchmark_sqrt_assign_rem<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sqrt_assign_rem()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut n| no_out!(n.sqrt_assign_rem()))],\n    );\n}\n\nfn benchmark_sqrt_assign<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sqrt_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |mut f| f.sqrt_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, signed_gen_var_10, unsigned_gen_var_21,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_square_unsigned);\n    register_unsigned_demos!(runner, demo_square_assign_unsigned);\n    register_signed_unsigned_match_demos!(runner, demo_square_signed);\n    register_signed_unsigned_match_demos!(runner, demo_square_assign_signed);\n    register_primitive_float_demos!(runner, demo_square_primitive_float);\n    register_primitive_float_demos!(runner, demo_square_assign_primitive_float);\n\n    register_unsigned_benches!(runner, benchmark_square_unsigned);\n    register_unsigned_benches!(runner, benchmark_square_assign_unsigned);\n    register_signed_unsigned_match_benches!(runner, benchmark_square_signed);\n    register_signed_unsigned_match_benches!(runner, benchmark_square_assign_signed);\n    register_primitive_float_benches!(runner, benchmark_square_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_square_assign_primitive_float);\n}\n\nfn demo_square_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_21::<T>().get(gm, config).take(limit) {\n        println!(\"{}.square() = {}\", u, u.square());\n    }\n}\n\nfn demo_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut u in unsigned_gen_var_21::<T>().get(gm, config).take(limit) {\n        let old_u = u;\n        u.square_assign();\n        println!(\"u := {old_u}; u.square_assign(); u = {u}\");\n    }\n}\n\nfn demo_square_signed<\n    S: PrimitiveSigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for i in signed_gen_var_10::<U, S>().get(gm, config).take(limit) {\n        println!(\"{}.square() = {}\", i, i.square());\n    }\n}\n\nfn demo_square_assign_signed<\n    S: PrimitiveSigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut i in signed_gen_var_10::<U, S>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.square_assign();\n        println!(\"i := {old_i}; i.square_assign(); i = {i}\");\n    }\n}\n\nfn demo_square_primitive_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).square() = {}\", NiceFloat(f), NiceFloat(f.square()));\n    }\n}\n\nfn demo_square_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_f = f;\n        f.square_assign();\n        println!(\n            \"f := {}; f.square_assign(); x = {}\",\n            NiceFloat(old_f),\n            NiceFloat(f)\n        );\n    }\n}\n\nfn benchmark_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.square()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_21::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.square()))],\n    );\n}\n\nfn benchmark_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_21::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut u| u.square_assign())],\n    );\n}\n\nfn benchmark_square_signed<\n    S: PrimitiveSigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.square()\", S::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_10::<U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |i| no_out!(i.square()))],\n    );\n}\n\nfn benchmark_square_assign_signed<\n    S: PrimitiveSigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.square_assign()\", S::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_10::<U, S>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.square_assign())],\n    );\n}\n\nfn benchmark_square_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.square()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(f.square()))],\n    );\n}\n\nfn benchmark_square_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |mut f| f.square_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    triple_max_bit_bucketer, triple_max_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_triple_gen, signed_triple_gen_var_2, unsigned_triple_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_sub_mul_unsigned);\n    register_signed_demos!(runner, demo_sub_mul_signed);\n    register_primitive_float_demos!(runner, demo_sub_mul_primitive_float);\n    register_unsigned_demos!(runner, demo_sub_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_sub_mul_assign_signed);\n    register_primitive_float_demos!(runner, demo_sub_mul_assign_primitive_float);\n\n    register_unsigned_benches!(runner, benchmark_sub_mul_unsigned);\n    register_signed_benches!(runner, benchmark_sub_mul_signed);\n    register_primitive_float_benches!(runner, benchmark_sub_mul_primitive_float);\n    register_unsigned_benches!(runner, benchmark_sub_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_sub_mul_assign_signed);\n    register_primitive_float_benches!(runner, benchmark_sub_mul_assign_primitive_float);\n}\n\nfn demo_sub_mul_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in unsigned_triple_gen_var_2::<T>().get(gm, config).take(limit) {\n        println!(\"{}.sub_mul({}, {}) = {}\", x, y, z, x.sub_mul(y, z));\n    }\n}\n\nfn demo_sub_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in signed_triple_gen_var_2::<T>().get(gm, config).take(limit) {\n        println!(\"({}).sub_mul({}, {}) = {}\", x, y, z, x.sub_mul(y, z));\n    }\n}\n\nfn demo_sub_mul_primitive_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in primitive_float_triple_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).sub_mul({}, {}) = {}\",\n            NiceFloat(x),\n            NiceFloat(y),\n            NiceFloat(z),\n            NiceFloat(x.sub_mul(y, z))\n        );\n    }\n}\n\nfn demo_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_2::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.sub_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_sub_mul_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in signed_triple_gen_var_2::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.sub_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_sub_mul_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in primitive_float_triple_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.sub_mul_assign(y, z);\n        println!(\n            \"x := {}; x.sub_mul_assign({}, {}); x = {}\",\n            NiceFloat(old_x),\n            NiceFloat(y),\n            NiceFloat(z),\n            NiceFloat(x)\n        );\n    }\n}\n\nfn benchmark_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.sub_mul(y, z)))],\n    );\n}\n\nfn benchmark_sub_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.sub_mul(y, z)))],\n    );\n}\n\nfn benchmark_sub_mul_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        primitive_float_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_primitive_float_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| no_out!(x.sub_mul(y, z)))],\n    );\n}\n\nfn benchmark_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sub_mul_assign({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| x.sub_mul_assign(y, z))],\n    );\n}\n\nfn benchmark_sub_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sub_mul_assign({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| x.sub_mul_assign(y, z))],\n    );\n}\n\nfn benchmark_sub_mul_assign_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sub_mul_assign({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        primitive_float_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_primitive_float_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| x.sub_mul_assign(y, z))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::bucketers::signed_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_wrapping_abs_assign);\n    register_signed_benches!(runner, benchmark_wrapping_abs_assign);\n}\n\nfn demo_wrapping_abs_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut i in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.wrapping_abs_assign();\n        println!(\"i := {old_i}; i.wrapping_abs_assign(); i = {i}\");\n    }\n}\n\nfn benchmark_wrapping_abs_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_abs_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.wrapping_abs_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_add_unsigned);\n    register_signed_demos!(runner, demo_wrapping_add_signed);\n    register_unsigned_demos!(runner, demo_wrapping_add_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_add_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_wrapping_add_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_add_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_add_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_add_assign_signed);\n}\n\nfn demo_wrapping_add_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.wrapping_add({}) = {}\", x, y, x.wrapping_add(y));\n    }\n}\n\nfn demo_wrapping_add_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).wrapping_add({}) = {}\", x, y, x.wrapping_add(y));\n    }\n}\n\nfn demo_wrapping_add_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_add_assign(y);\n        println!(\"x := {old_x}; x.wrapping_add_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_wrapping_add_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_add_assign(y);\n        println!(\"x := {old_x}; x.wrapping_add_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_add_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_add({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_add(y)))],\n    );\n}\n\nfn benchmark_wrapping_add_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_add({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_add(y)))],\n    );\n}\n\nfn benchmark_wrapping_add_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_add_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_add_assign(y))],\n    );\n}\n\nfn benchmark_wrapping_add_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_add_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_add_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_add_mul_unsigned);\n    register_signed_demos!(runner, demo_wrapping_add_mul_signed);\n    register_unsigned_demos!(runner, demo_wrapping_add_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_add_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_wrapping_add_mul_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_add_mul_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_add_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_add_mul_assign_signed);\n}\n\nfn demo_wrapping_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.wrapping_add_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.wrapping_add_mul(y, z)\n        );\n    }\n}\n\nfn demo_wrapping_add_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.wrapping_add_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.wrapping_add_mul(y, z)\n        );\n    }\n}\n\nfn demo_wrapping_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.wrapping_add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.wrapping_add_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_wrapping_add_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_add_mul_assign(y, z);\n        println!(\"x := {old_x}; x.wrapping_add_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_add_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.wrapping_add_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_wrapping_add_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_add_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.wrapping_add_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_wrapping_add_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.wrapping_add_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.wrapping_add_mul_assign(y, z);\n        })],\n    );\n}\n\nfn benchmark_wrapping_add_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.wrapping_add_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.wrapping_add_mul_assign(y, z);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen_var_6, unsigned_pair_gen_var_12};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_div_unsigned);\n    register_signed_demos!(runner, demo_wrapping_div_signed);\n    register_unsigned_demos!(runner, demo_wrapping_div_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_div_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_wrapping_div_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_div_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_div_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_div_assign_signed);\n}\n\nfn demo_wrapping_div_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.wrapping_div({}) = {}\", x, y, x.wrapping_div(y));\n    }\n}\n\nfn demo_wrapping_div_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        println!(\"({}).wrapping_div({}) = {}\", x, y, x.wrapping_div(y));\n    }\n}\n\nfn demo_wrapping_div_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.wrapping_div_assign(y);\n        println!(\"x := {old_x}; x.wrapping_div_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_wrapping_div_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_div_assign(y);\n        println!(\"x := {old_x}; x.wrapping_div_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_div_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_div({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_div(y)))],\n    );\n}\n\nfn benchmark_wrapping_div_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_div({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_div(y)))],\n    );\n}\n\nfn benchmark_wrapping_div_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_div_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_div_assign(y))],\n    );\n}\n\nfn benchmark_wrapping_div_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_div_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_div_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_mul_unsigned);\n    register_signed_demos!(runner, demo_wrapping_mul_signed);\n    register_unsigned_demos!(runner, demo_wrapping_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_wrapping_mul_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_mul_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_mul_assign_signed);\n}\n\nfn demo_wrapping_mul_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.wrapping_mul({}) = {}\", x, y, x.wrapping_mul(y));\n    }\n}\n\nfn demo_wrapping_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).wrapping_mul({}) = {}\", x, y, x.wrapping_mul(y));\n    }\n}\n\nfn demo_wrapping_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_mul_assign(y);\n        println!(\"x := {old_x}; x.wrapping_mul_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_wrapping_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_mul_assign(y);\n        println!(\"x := {old_x}; x.wrapping_mul_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_mul({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_mul(y)))],\n    );\n}\n\nfn benchmark_wrapping_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_mul({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_mul(y)))],\n    );\n}\n\nfn benchmark_wrapping_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_mul_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_mul_assign(y))],\n    );\n}\n\nfn benchmark_wrapping_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_mul_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_mul_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_neg_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_neg_assign_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_neg_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_neg_assign_signed);\n}\n\nfn demo_wrapping_neg_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_u = u;\n        u.wrapping_neg_assign();\n        println!(\"u := {old_u}; u.wrapping_neg_assign(); u = {u}\");\n    }\n}\n\nfn demo_wrapping_neg_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut i in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.wrapping_neg_assign();\n        println!(\"i := {old_i}; i.wrapping_neg_assign(); i = {i}\");\n    }\n}\n\nfn benchmark_wrapping_neg_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_neg_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.wrapping_neg_assign())],\n    );\n}\n\nfn benchmark_wrapping_neg_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_neg_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.wrapping_neg_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_pow_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_pow_assign_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_pow_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_pow_assign_signed);\n}\n\nfn demo_wrapping_pow_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen::<T, u64>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_pow_assign(y);\n        println!(\"x := {old_x}; x.wrapping_pow_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_wrapping_pow_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_unsigned_pair_gen::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.wrapping_pow_assign(y);\n        println!(\"x := {old_x}; x.wrapping_pow_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_pow_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_pow_assign(y))],\n    );\n}\n\nfn benchmark_wrapping_pow_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_pow_assign(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_pow_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_square_unsigned);\n    register_signed_demos!(runner, demo_wrapping_square_signed);\n    register_unsigned_demos!(runner, demo_wrapping_square_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_square_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_wrapping_square_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_square_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_square_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_square_assign_signed);\n}\n\nfn demo_wrapping_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.wrapping_square() = {}\", x, x.wrapping_square());\n    }\n}\n\nfn demo_wrapping_square_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.wrapping_square() = {}\", x, x.wrapping_square());\n    }\n}\n\nfn demo_wrapping_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_square_assign();\n        println!(\"x := {old_x}; x.wrapping_square_assign(); x = {x}\");\n    }\n}\n\nfn demo_wrapping_square_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for mut x in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_square_assign();\n        println!(\"x := {old_x}; x.wrapping_square_assign(); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_square_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_square()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.wrapping_square()))],\n    );\n}\n\nfn benchmark_wrapping_square_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_square()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.wrapping_square()))],\n    );\n}\n\nfn benchmark_wrapping_square_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut x| x.wrapping_square_assign())],\n    );\n}\n\nfn benchmark_wrapping_square_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_square_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut x| x.wrapping_square_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_sub_unsigned);\n    register_signed_demos!(runner, demo_wrapping_sub_signed);\n    register_unsigned_demos!(runner, demo_wrapping_sub_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_sub_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_wrapping_sub_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_sub_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_sub_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_sub_assign_signed);\n}\n\nfn demo_wrapping_sub_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.wrapping_sub({}) = {}\", x, y, x.wrapping_sub(y));\n    }\n}\n\nfn demo_wrapping_sub_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).wrapping_sub({}) = {}\", x, y, x.wrapping_sub(y));\n    }\n}\n\nfn demo_wrapping_sub_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_sub_assign(y);\n        println!(\"x := {old_x}; x.wrapping_sub_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_wrapping_sub_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_sub_assign(y);\n        println!(\"x := {old_x}; x.wrapping_sub_assign({y}); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_sub_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_sub({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_sub(y)))],\n    );\n}\n\nfn benchmark_wrapping_sub_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_sub({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.wrapping_sub(y)))],\n    );\n}\n\nfn benchmark_wrapping_sub_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_sub_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_sub_assign(y))],\n    );\n}\n\nfn benchmark_wrapping_sub_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_sub_assign({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.wrapping_sub_assign(y))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/wrapping_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_triple_gen, unsigned_triple_gen_var_19};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_wrapping_sub_mul_unsigned);\n    register_signed_demos!(runner, demo_wrapping_sub_mul_signed);\n    register_unsigned_demos!(runner, demo_wrapping_sub_mul_assign_unsigned);\n    register_signed_demos!(runner, demo_wrapping_sub_mul_assign_signed);\n\n    register_unsigned_benches!(runner, benchmark_wrapping_sub_mul_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_sub_mul_signed);\n    register_unsigned_benches!(runner, benchmark_wrapping_sub_mul_assign_unsigned);\n    register_signed_benches!(runner, benchmark_wrapping_sub_mul_assign_signed);\n}\n\nfn demo_wrapping_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.wrapping_sub_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.wrapping_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_wrapping_sub_mul_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.wrapping_sub_mul({}, {}) = {}\",\n            x,\n            y,\n            z,\n            x.wrapping_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_wrapping_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in unsigned_triple_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x;\n        x.wrapping_sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.wrapping_sub_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn demo_wrapping_sub_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, z) in signed_triple_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.wrapping_sub_mul_assign(y, z);\n        println!(\"x := {old_x}; x.wrapping_sub_mul_assign({y}, {z}); x = {x}\");\n    }\n}\n\nfn benchmark_wrapping_sub_mul_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.wrapping_sub_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_wrapping_sub_mul_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_sub_mul({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(x, y, z)| {\n            no_out!(x.wrapping_sub_mul(y, z));\n        })],\n    );\n}\n\nfn benchmark_wrapping_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.wrapping_sub_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_19::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.wrapping_sub_mul_assign(y, z);\n        })],\n    );\n}\n\nfn benchmark_wrapping_sub_mul_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.wrapping_sub_mul_assign({}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_triple_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, z)| {\n            x.wrapping_sub_mul_assign(y, z);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/x_mul_y_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::x_mul_y_to_zz::explicit_x_mul_y_to_zz;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_x_mul_y_to_zz);\n    register_unsigned_benches!(runner, benchmark_x_mul_y_to_zz_algorithms);\n}\n\nfn demo_x_mul_y_to_zz<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{} * {} = {:?}\", x, y, T::x_mul_y_to_zz(x, y));\n    }\n}\n\nfn benchmark_x_mul_y_to_zz_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::x_mul_y_to_zz({}, {})\", T::NAME, T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(T::x_mul_y_to_zz(x, y))),\n            (\"explicit\", &mut |(x, y)| {\n                no_out!(explicit_x_mul_y_to_zz(x, y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/xx_add_yy_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::xx_add_yy_to_zz::explicit_xx_add_yy_to_zz;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::quadruple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_quadruple_gen_var_10;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_xx_add_yy_to_zz);\n    register_unsigned_benches!(runner, benchmark_xx_add_yy_to_zz_algorithms);\n}\n\nfn demo_xx_add_yy_to_zz<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_1, x_0, y_1, y_0) in unsigned_quadruple_gen_var_10::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"[{}, {}] + [{}, {}] = {:?}\",\n            x_1,\n            x_0,\n            y_1,\n            y_0,\n            T::xx_add_yy_to_zz(x_1, x_0, y_1, y_0)\n        );\n    }\n}\n\nfn benchmark_xx_add_yy_to_zz_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::xx_add_yy_to_zz({}, {}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_quadruple_gen_var_10::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_max_bit_bucketer(\"x_1\", \"x_0\", \"y_1\", \"y_0\"),\n        &mut [\n            (\"default\", &mut |(x_1, x_0, y_1, y_0)| {\n                no_out!(T::xx_add_yy_to_zz(x_1, x_0, y_1, y_0));\n            }),\n            (\"explicit\", &mut |(x_1, x_0, y_1, y_0)| {\n                no_out!(explicit_xx_add_yy_to_zz(x_1, x_0, y_1, y_0));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/xx_div_mod_y_to_qr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::xx_div_mod_y_to_qr::explicit_xx_div_mod_y_to_qr;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_15;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_xx_div_mod_y_to_qr);\n    register_unsigned_benches!(runner, benchmark_xx_div_mod_y_to_qr_algorithms);\n}\n\nfn demo_xx_div_mod_y_to_qr<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_1, x_0, y) in unsigned_triple_gen_var_15::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"[{}, {}].div_mod({}) = {:?}\",\n            x_1,\n            x_0,\n            y,\n            T::xx_div_mod_y_to_qr(x_1, x_0, y)\n        );\n    }\n}\n\nfn benchmark_xx_div_mod_y_to_qr_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::xx_div_mod_y_to_qr({}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_15::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_max_bit_bucketer(\"x_1\", \"x_0\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x_1, x_0, y)| {\n                no_out!(T::xx_div_mod_y_to_qr(x_1, x_0, y));\n            }),\n            (\"explicit\", &mut |(x_1, x_0, y)| {\n                no_out!(explicit_xx_div_mod_y_to_qr(x_1, x_0, y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/xx_sub_yy_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::xx_sub_yy_to_zz::explicit_xx_sub_yy_to_zz;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::quadruple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_quadruple_gen_var_10;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_xx_sub_yy_to_zz);\n    register_unsigned_benches!(runner, benchmark_xx_sub_yy_to_zz_algorithms);\n}\n\nfn demo_xx_sub_yy_to_zz<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_1, x_0, y_1, y_0) in unsigned_quadruple_gen_var_10::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"[{}, {}] - [{}, {}] = {:?}\",\n            x_1,\n            x_0,\n            y_1,\n            y_0,\n            T::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0)\n        );\n    }\n}\n\nfn benchmark_xx_sub_yy_to_zz_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::xx_sub_yy_to_zz({}, {}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_quadruple_gen_var_10::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_max_bit_bucketer(\"x_1\", \"x_0\", \"y_1\", \"y_0\"),\n        &mut [\n            (\"default\", &mut |(x_1, x_0, y_1, y_0)| {\n                no_out!(T::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0));\n            }),\n            (\"explicit\", &mut |(x_1, x_0, y_1, y_0)| {\n                no_out!(explicit_xx_sub_yy_to_zz(x_1, x_0, y_1, y_0));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/xxx_add_yyy_to_zzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::sextuple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_sextuple_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_xxx_add_yyy_to_zzz);\n    register_unsigned_benches!(runner, benchmark_xxx_add_yyy_to_zzz);\n}\n\nfn demo_xxx_add_yyy_to_zzz<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_2, x_1, x_0, y_2, y_1, y_0) in unsigned_sextuple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"[{}, {}, {}] + [{}, {}, {}] = {:?}\",\n            x_2,\n            x_1,\n            x_0,\n            y_2,\n            y_1,\n            y_0,\n            T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0)\n        );\n    }\n}\n\nfn benchmark_xxx_add_yyy_to_zzz<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::xxx_add_yyy_to_zzz({}, {}, {}, {}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_sextuple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &sextuple_max_bit_bucketer(\"x_2\", \"x_1\", \"x_0\", \"y_2\", \"y_1\", \"y_0\"),\n        &mut [(\"default\", &mut |(x_2, x_1, x_0, y_2, y_1, y_0)| {\n            no_out!(T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/xxx_sub_yyy_to_zzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::sextuple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_sextuple_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_xxx_sub_yyy_to_zzz);\n    register_unsigned_benches!(runner, benchmark_xxx_sub_yyy_to_zzz);\n}\n\nfn demo_xxx_sub_yyy_to_zzz<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_2, x_1, x_0, y_2, y_1, y_0) in unsigned_sextuple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"[{}, {}, {}] - [{}, {}, {}] = {:?}\",\n            x_2,\n            x_1,\n            x_0,\n            y_2,\n            y_1,\n            y_0,\n            T::xxx_sub_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0)\n        );\n    }\n}\n\nfn benchmark_xxx_sub_yyy_to_zzz<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::xxx_sub_yyy_to_zzz({}, {}, {}, {}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_sextuple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &sextuple_max_bit_bucketer(\"x_2\", \"x_1\", \"x_0\", \"y_2\", \"y_1\", \"y_0\"),\n        &mut [(\"default\", &mut |(x_2, x_1, x_0, y_2, y_1, y_0)| {\n            no_out!(T::xxx_sub_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/arithmetic/xxxx_add_yyyy_to_zzzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::octuple_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_octuple_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_xxxx_add_yyyy_to_zzzz);\n    register_unsigned_benches!(runner, benchmark_xxxx_add_yyyy_to_zzzz);\n}\n\nfn demo_xxxx_add_yyyy_to_zzzz<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0) in unsigned_octuple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"[{}, {}, {}, {}] + [{}, {}, {}, {}] = {:?}\",\n            x_3,\n            x_2,\n            x_1,\n            x_0,\n            y_3,\n            y_2,\n            y_1,\n            y_0,\n            T::xxxx_add_yyyy_to_zzzz(x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0)\n        );\n    }\n}\n\nfn benchmark_xxxx_add_yyyy_to_zzzz<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::xxxx_add_yyyy_to_zzzz({}, {}, {}, {}, {}, {}, {}, {})\",\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_octuple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &octuple_max_bit_bucketer(\"x_3\", \"x_2\", \"x_1\", \"x_0\", \"y_3\", \"y_2\", \"y_1\", \"y_0\"),\n        &mut [(\"default\", &mut |(\n            x_3,\n            x_2,\n            x_1,\n            x_0,\n            y_3,\n            y_2,\n            y_1,\n            y_0,\n        )| {\n            no_out!(T::xxxx_add_yyyy_to_zzzz(\n                x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0\n            ));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_max_bit_bucketer, pair_max_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_pair_gen, signed_pair_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_cmp_abs_signed);\n    register_signed_demos!(runner, demo_partial_cmp_abs_signed);\n    register_primitive_float_demos!(runner, demo_partial_cmp_abs_primitive_float);\n\n    register_signed_benches!(runner, benchmark_cmp_abs_signed_algorithms);\n    register_signed_benches!(runner, benchmark_partial_cmp_abs_signed);\n    register_primitive_float_benches!(runner, benchmark_partial_cmp_abs_primitive_float_algorithms);\n}\n\nfn demo_cmp_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).cmp_abs(&{}) = {:?}\", x, y, x.cmp_abs(&y));\n    }\n}\n\nfn demo_partial_cmp_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).partial_cmp_abs(&{}) = {:?}\",\n            x,\n            y,\n            x.partial_cmp_abs(&y)\n        );\n    }\n}\n\nfn demo_partial_cmp_abs_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).partial_cmp_abs(&{}) = {:?}\",\n            NiceFloat(x),\n            NiceFloat(y),\n            x.partial_cmp_abs(&y)\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_cmp_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: Ord,\n{\n    run_benchmark(\n        &format!(\"{}.cmp_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.cmp_abs(&y))),\n            (\"default\", &mut |(x, y)| {\n                no_out!(x.unsigned_abs().cmp(&y.unsigned_abs()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_partial_cmp_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_partial_cmp_abs_primitive_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_primitive_float_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"default\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_max_bit_bucketer, pair_max_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_pair_gen, signed_pair_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_eq_abs_signed);\n    register_primitive_float_demos!(runner, demo_eq_abs_primitive_float);\n\n    register_signed_benches!(runner, benchmark_eq_abs_signed_algorithms);\n    register_primitive_float_benches!(runner, benchmark_eq_abs_primitive_float_algorithms);\n}\n\nfn demo_eq_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_eq_abs_primitive_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_eq_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    run_benchmark(\n        &format!(\"{}.eq_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.unsigned_abs() == y.unsigned_abs());\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_eq_abs_primitive_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_primitive_float_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    eq_abs::register(runner);\n    cmp_abs::register(runner);\n    ord_abs_comparators::register(runner);\n}\n\nmod cmp_abs;\nmod eq_abs;\nmod ord_abs_comparators;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/comparison/ord_abs_comparators.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_lt_abs_signed);\n    register_signed_demos!(runner, demo_gt_abs_signed);\n    register_signed_demos!(runner, demo_le_abs_signed);\n    register_signed_demos!(runner, demo_ge_abs_signed);\n\n    register_signed_benches!(runner, benchmark_lt_abs_signed);\n    register_signed_benches!(runner, benchmark_gt_abs_signed);\n    register_signed_benches!(runner, benchmark_le_abs_signed);\n    register_signed_benches!(runner, benchmark_ge_abs_signed);\n}\n\nfn demo_lt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).lt_abs(&{}) = {}\", x, y, x.lt_abs(&y));\n    }\n}\n\nfn demo_gt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).gt_abs(&{}) = {}\", x, y, x.gt_abs(&y));\n    }\n}\n\nfn demo_le_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).le_abs(&{}) = {}\", x, y, x.le_abs(&y));\n    }\n}\n\nfn demo_ge_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).ge_abs(&{}) = {}\", x, y, x.ge_abs(&y));\n    }\n}\n\nfn benchmark_lt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lt_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_gt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gt_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_le_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.le_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_ge_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ge_abs(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/general_digits/from_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{Digits, SaturatingFrom};\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_7, unsigned_vec_unsigned_pair_gen_var_8,\n    unsigned_vec_unsigned_pair_gen_var_9,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_from_digits_asc);\n    register_unsigned_unsigned_demos!(runner, demo_from_digits_desc);\n    register_unsigned_unsigned_demos!(runner, demo_from_digits_asc_targeted);\n    register_unsigned_unsigned_demos!(runner, demo_from_digits_desc_targeted);\n    register_unsigned_unsigned_benches!(runner, benchmark_from_digits_asc);\n    register_unsigned_unsigned_benches!(runner, benchmark_from_digits_desc);\n}\n\nfn demo_from_digits_asc<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_9::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.from_digits_asc({}, {:?}) = {:?}\",\n            U::NAME,\n            base,\n            xs,\n            U::from_digits_asc(&base, xs.iter().copied())\n        );\n    }\n}\n\nfn demo_from_digits_desc<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_9::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.from_digits_desc({}, {:?}) = {:?}\",\n            U::NAME,\n            base,\n            xs,\n            U::from_digits_desc(&base, xs.iter().copied())\n        );\n    }\n}\n\nfn demo_from_digits_asc_targeted<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_8::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.from_digits_asc({}, {:?}) = {}\",\n            U::NAME,\n            base,\n            xs,\n            U::from_digits_asc(&base, xs.iter().copied()).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_desc_targeted<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_7::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.from_digits_desc({}, {:?}) = {}\",\n            U::NAME,\n            base,\n            xs,\n            U::from_digits_desc(&base, xs.iter().copied()).unwrap()\n        );\n    }\n}\n\nfn benchmark_from_digits_asc<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.from_digits_asc({}, Iterator<Item={}>)\",\n            U::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_8::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"digits\"),\n        &mut [(\"Malachite\", &mut |(xs, base)| {\n            no_out!(U::from_digits_asc(&base, xs.iter().copied()));\n        })],\n    );\n}\n\nfn benchmark_from_digits_desc<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}.from_digits_desc({}, Iterator<Item={}>)\",\n            U::NAME,\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_7::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"digits\"),\n        &mut [(\"Malachite\", &mut |(xs, base)| {\n            no_out!(U::from_digits_desc(&base, xs.iter().copied()));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/general_digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_digits::register(runner);\n    to_digits::register(runner);\n}\n\nmod from_digits;\nmod to_digits;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/general_digits/to_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{Digits, SaturatingFrom};\nuse malachite_base::test_util::bench::bucketers::pair_1_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_6;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_to_digits_asc);\n    register_unsigned_unsigned_demos!(runner, demo_to_digits_desc);\n    register_unsigned_unsigned_benches!(runner, benchmark_to_digits_asc);\n    register_unsigned_unsigned_benches!(runner, benchmark_to_digits_desc);\n}\n\nfn demo_to_digits_asc<\n    T: Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, base) in unsigned_pair_gen_var_6::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_digits_asc({}) = {:?}\",\n            x,\n            base,\n            x.to_digits_asc(&base)\n        );\n    }\n}\n\nfn demo_to_digits_desc<\n    T: Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, base) in unsigned_pair_gen_var_6::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_digits_desc({}) = {:?}\",\n            x,\n            base,\n            x.to_digits_desc(&base)\n        );\n    }\n}\n\nfn benchmark_to_digits_asc<\n    T: Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_digits_asc({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_6::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            no_out!(x.to_digits_asc(&base));\n        })],\n    );\n}\n\nfn benchmark_to_digits_desc<\n    T: Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_digits_desc({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_6::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            no_out!(x.to_digits_desc(&base));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    general_digits::register(runner);\n    power_of_2_digits::register(runner);\n}\n\nmod general_digits;\nmod power_of_2_digits;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/power_of_2_digits/from_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::PowerOf2Digits;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_3,\n    unsigned_vec_unsigned_pair_gen_var_6,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_from_power_of_2_digits_asc);\n    register_unsigned_unsigned_demos!(runner, demo_from_power_of_2_digits_desc);\n    register_unsigned_unsigned_demos!(runner, demo_from_power_of_2_digits_asc_targeted);\n    register_unsigned_unsigned_demos!(runner, demo_from_power_of_2_digits_desc_targeted);\n    register_unsigned_unsigned_benches!(runner, benchmark_from_power_of_2_digits_asc);\n    register_unsigned_unsigned_benches!(runner, benchmark_from_power_of_2_digits_desc);\n}\n\nfn demo_from_power_of_2_digits_asc<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, log_base) in unsigned_vec_unsigned_pair_gen_var_6::<U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_power_of_2_digits_asc({}, {:?}) = {:?}\",\n            T::NAME,\n            log_base,\n            xs,\n            T::from_power_of_2_digits_asc(log_base, xs.iter().copied())\n        );\n    }\n}\n\nfn demo_from_power_of_2_digits_desc<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, log_base) in unsigned_vec_unsigned_pair_gen_var_6::<U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_power_of_2_digits_desc({}, {:?}) = {:?}\",\n            T::NAME,\n            log_base,\n            xs,\n            T::from_power_of_2_digits_desc(log_base, xs.iter().copied())\n        );\n    }\n}\n\nfn demo_from_power_of_2_digits_asc_targeted<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, log_base) in unsigned_vec_unsigned_pair_gen_var_2::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_power_of_2_digits_asc({}, {:?}) = {}\",\n            T::NAME,\n            log_base,\n            xs,\n            T::from_power_of_2_digits_asc(log_base, xs.iter().copied()).unwrap()\n        );\n    }\n}\n\nfn demo_from_power_of_2_digits_desc_targeted<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, log_base) in unsigned_vec_unsigned_pair_gen_var_3::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_power_of_2_digits_desc({}, {:?}) = {}\",\n            T::NAME,\n            log_base,\n            xs,\n            T::from_power_of_2_digits_desc(log_base, xs.iter().copied()).unwrap()\n        );\n    }\n}\n\nfn benchmark_from_power_of_2_digits_asc<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_power_of_2_digits_asc<I: Iterator<Item={}>>(u64, I)\",\n            T::NAME,\n            U::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_2::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, log_base)| {\n            no_out!(T::from_power_of_2_digits_asc(log_base, xs.into_iter()));\n        })],\n    );\n}\n\nfn benchmark_from_power_of_2_digits_desc<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_power_of_2_digits_asc<I: Iterator<Item={}>>(u64, I)\",\n            T::NAME,\n            U::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_3::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, log_base)| {\n            no_out!(T::from_power_of_2_digits_desc(log_base, xs.into_iter()));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/power_of_2_digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_power_of_2_digits::register(runner);\n    power_of_2_digit_iterable::register(runner);\n    to_power_of_2_digits::register(runner);\n}\n\nmod from_power_of_2_digits;\nmod power_of_2_digit_iterable;\nmod to_power_of_2_digits;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/power_of_2_digits/power_of_2_digit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, PowerOf2DigitIterable, PowerOf2DigitIterator, PowerOf2Digits,\n};\nuse malachite_base::test_util::bench::bucketers::{pair_1_bit_bucketer, triple_1_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{unsigned_pair_gen_var_4, unsigned_triple_gen_var_3};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_power_of_2_digits);\n    register_unsigned_unsigned_demos!(runner, demo_power_of_2_digits_rev);\n    register_unsigned_unsigned_demos!(runner, demo_power_of_2_digits_size_hint);\n    register_unsigned_unsigned_demos!(runner, demo_power_of_2_digits_get_digit);\n    register_unsigned_unsigned_benches!(runner, benchmark_power_of_2_digits_size_hint);\n    register_unsigned_unsigned_benches!(runner, benchmark_power_of_2_digits_get_digit_algorithms);\n}\n\nfn demo_power_of_2_digits<T: PowerOf2DigitIterable<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, log_base) in unsigned_pair_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}) = {:?}\",\n            x,\n            log_base,\n            PowerOf2DigitIterable::<U>::power_of_2_digits(x, log_base).collect_vec()\n        );\n    }\n}\n\nfn demo_power_of_2_digits_rev<\n    T: PowerOf2DigitIterable<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, log_base) in unsigned_pair_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).rev() = {:?}\",\n            x,\n            log_base,\n            PowerOf2DigitIterable::<U>::power_of_2_digits(x, log_base)\n                .rev()\n                .collect_vec()\n        );\n    }\n}\n\nfn demo_power_of_2_digits_size_hint<\n    T: PowerOf2DigitIterable<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, log_base) in unsigned_pair_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).size_hint() = {:?}\",\n            x,\n            log_base,\n            PowerOf2DigitIterable::<U>::power_of_2_digits(x, log_base).size_hint()\n        );\n    }\n}\n\nfn demo_power_of_2_digits_get_digit<\n    T: PowerOf2DigitIterable<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, log_base, i) in unsigned_triple_gen_var_3::<T, U, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).get_digit({}) = {:?}\",\n            x,\n            log_base,\n            i,\n            PowerOf2DigitIterable::<U>::power_of_2_digits(x, log_base).get_digit(i)\n        );\n    }\n}\n\nfn benchmark_power_of_2_digits_size_hint<\n    T: PowerOf2DigitIterable<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"PowerOf2DigitIterable::<{}>::power_of_2_digits(&{}, u64).size_hint()\",\n            U::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_4::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, log_base)| {\n            no_out!(PowerOf2DigitIterable::<U>::power_of_2_digits(x, log_base).size_hint());\n        })],\n    );\n}\n\nfn benchmark_power_of_2_digits_get_digit_algorithms<\n    T: PowerOf2DigitIterable<U> + PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"PowerOf2DigitIterable::<{}>::power_of_2_digits(&{}, u64).size_hint()\",\n            U::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_3::<T, U, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [\n            (\n                &format!(\"power_of_2_digits({}, u64).get_digit(u64)\", T::NAME),\n                &mut |(u, log_base, i)| {\n                    no_out!(\n                        PowerOf2DigitIterable::<U>::power_of_2_digits(u, log_base).get_digit(i)\n                    );\n                },\n            ),\n            (\n                &format!(\"{}.to_power_of_2_digits_asc(u64)[usize]\", T::NAME),\n                &mut |(x, log_base, i)| {\n                    let digits = PowerOf2Digits::<U>::to_power_of_2_digits_asc(&x, log_base);\n                    let i = usize::exact_from(i);\n                    if i >= digits.len() {\n                        U::ZERO\n                    } else {\n                        digits[i]\n                    };\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/digits/power_of_2_digits/to_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{PowerOf2DigitIterable, PowerOf2Digits};\nuse malachite_base::test_util::bench::bucketers::pair_1_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_4;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_to_power_of_2_digits_asc);\n    register_unsigned_unsigned_demos!(runner, demo_to_power_of_2_digits_desc);\n    register_unsigned_unsigned_benches!(\n        runner,\n        benchmark_to_power_of_2_digits_asc_evaluation_strategy\n    );\n    register_unsigned_unsigned_benches!(\n        runner,\n        benchmark_to_power_of_2_digits_desc_evaluation_strategy\n    );\n}\n\nfn demo_to_power_of_2_digits_asc<T: PowerOf2Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, log_base) in unsigned_pair_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_power_of_2_digits_asc({}) = {:?}\",\n            x,\n            log_base,\n            PowerOf2Digits::<U>::to_power_of_2_digits_asc(&x, log_base)\n        );\n    }\n}\n\nfn demo_to_power_of_2_digits_desc<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, log_base) in unsigned_pair_gen_var_4::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_power_of_2_digits_desc({}) = {:?}\",\n            x,\n            log_base,\n            PowerOf2Digits::<U>::to_power_of_2_digits_desc(&x, log_base)\n        );\n    }\n}\n\nfn benchmark_to_power_of_2_digits_asc_evaluation_strategy<\n    T: PowerOf2Digits<U> + PowerOf2DigitIterable<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"PowerOf2Digits::<{}>::to_power_of_2_digits_asc({}, u64)\",\n            U::NAME,\n            T::NAME\n        ),\n        BenchmarkType::EvaluationStrategy,\n        unsigned_pair_gen_var_4::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(x, log_base)| {\n                no_out!(PowerOf2Digits::<U>::to_power_of_2_digits_asc(&x, log_base));\n            }),\n            (\n                &format!(\"{}.power_of_2_digits(u64).collect_vec()\", T::NAME),\n                &mut |(x, log_base)| {\n                    PowerOf2DigitIterable::<U>::power_of_2_digits(x, log_base).collect_vec();\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_to_power_of_2_digits_desc_evaluation_strategy<\n    T: PowerOf2Digits<U> + PowerOf2DigitIterable<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"PowerOf2Digits::<{}>::to_power_of_2_digits_desc({}, u64)\",\n            U::NAME,\n            T::NAME\n        ),\n        BenchmarkType::EvaluationStrategy,\n        unsigned_pair_gen_var_4::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(x, log_base)| {\n                no_out!(PowerOf2Digits::<U>::to_power_of_2_digits_desc(&x, log_base));\n            }),\n            (\n                &format!(\"{}.power_of_2_digits(u64).rev().collect_vec()\", T::NAME),\n                &mut |(x, log_base)| {\n                    no_out!(\n                        PowerOf2DigitIterable::<U>::power_of_2_digits(x, log_base)\n                            .rev()\n                            .collect_vec()\n                    );\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/from/convertible_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_unsigned_demos!(runner, demo_primitive_int_convertible_from_unsigned);\n    register_primitive_int_signed_demos!(runner, demo_primitive_int_convertible_from_signed);\n    register_primitive_int_primitive_float_demos!(\n        runner,\n        demo_primitive_int_convertible_from_primitive_float\n    );\n    register_primitive_float_unsigned_demos!(\n        runner,\n        demo_primitive_float_convertible_from_unsigned\n    );\n    register_primitive_float_signed_demos!(runner, demo_primitive_float_convertible_from_signed);\n\n    register_primitive_int_unsigned_benches!(\n        runner,\n        benchmark_primitive_int_convertible_from_unsigned\n    );\n    register_primitive_int_signed_benches!(runner, benchmark_primitive_int_convertible_from_signed);\n    register_primitive_int_primitive_float_benches!(\n        runner,\n        benchmark_primitive_int_convertible_from_primitive_float\n    );\n    register_primitive_float_unsigned_benches!(\n        runner,\n        benchmark_primitive_float_convertible_from_unsigned\n    );\n    register_primitive_float_signed_benches!(\n        runner,\n        benchmark_primitive_float_convertible_from_signed\n    );\n}\n\nfn demo_primitive_int_convertible_from_unsigned<\n    T: ConvertibleFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            u,\n            if T::convertible_from(u) { \"\" } else { \"not \" },\n            T::NAME,\n        );\n    }\n}\n\nfn demo_primitive_int_convertible_from_signed<T: ConvertibleFrom<U> + Named, U: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for i in signed_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            i,\n            if T::convertible_from(i) { \"\" } else { \"not \" },\n            T::NAME,\n        );\n    }\n}\n\nfn demo_primitive_int_convertible_from_primitive_float<\n    T: ConvertibleFrom<U> + PrimitiveInt,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            NiceFloat(x),\n            if T::convertible_from(x) { \"\" } else { \"not \" },\n            T::NAME,\n        );\n    }\n}\n\nfn demo_primitive_float_convertible_from_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            u,\n            if T::convertible_from(u) { \"\" } else { \"not \" },\n            T::NAME,\n        );\n    }\n}\n\nfn demo_primitive_float_convertible_from_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for i in signed_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            i,\n            if T::convertible_from(i) { \"\" } else { \"not \" },\n            T::NAME,\n        );\n    }\n}\n\nfn benchmark_primitive_int_convertible_from_unsigned<\n    T: ConvertibleFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.convertible_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::convertible_from(n)))],\n    );\n}\n\nfn benchmark_primitive_int_convertible_from_signed<\n    T: ConvertibleFrom<U> + Named,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.convertible_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::convertible_from(n)))],\n    );\n}\n\nfn benchmark_primitive_int_convertible_from_primitive_float<\n    T: ConvertibleFrom<U> + PrimitiveInt,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.convertible_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::convertible_from(n)))],\n    );\n}\n\nfn benchmark_primitive_float_convertible_from_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.convertible_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::convertible_from(n)))],\n    );\n}\n\nfn benchmark_primitive_float_convertible_from_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.convertible_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::convertible_from(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/from/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    convertible_from::register(runner);\n    overflowing_from::register(runner);\n    rounding_from::register(runner);\n    saturating_from::register(runner);\n    try_from_and_exact_from::register(runner);\n    wrapping_from::register(runner);\n}\n\nmod convertible_from;\nmod overflowing_from;\nmod rounding_from;\nmod saturating_from;\nmod try_from_and_exact_from;\nmod wrapping_from;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/from/overflowing_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::OverflowingFrom;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Debug;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_unsigned_demos!(runner, demo_primitive_int_overflowing_from_unsigned);\n    register_primitive_int_signed_demos!(runner, demo_primitive_int_overflowing_from_signed);\n    register_primitive_int_unsigned_benches!(\n        runner,\n        benchmark_primitive_int_overflowing_from_unsigned\n    );\n    register_primitive_int_signed_benches!(runner, benchmark_primitive_int_overflowing_from_signed);\n}\n\nfn demo_primitive_int_overflowing_from_unsigned<\n    T: Debug + OverflowingFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::overflowing_from({}) = {:?}\",\n            T::NAME,\n            u,\n            T::overflowing_from(u)\n        );\n    }\n}\n\nfn demo_primitive_int_overflowing_from_signed<\n    T: Debug + OverflowingFrom<U> + Named,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for i in signed_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::overflowing_from({}) = {:?}\",\n            T::NAME,\n            i,\n            T::overflowing_from(i)\n        );\n    }\n}\n\nfn benchmark_primitive_int_overflowing_from_unsigned<\n    T: OverflowingFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::overflowing_from(n)))],\n    );\n}\n\nfn benchmark_primitive_int_overflowing_from_signed<\n    T: OverflowingFrom<U> + Named,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.overflowing_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::overflowing_from(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/from/rounding_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bit_bucketer, pair_1_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_rounding_mode_pair_gen_var_3, signed_rounding_mode_pair_gen_var_4,\n    unsigned_rounding_mode_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_primitive_float_demos!(\n        runner,\n        demo_primitive_int_rounding_from_primitive_float\n    );\n    register_primitive_float_unsigned_demos!(runner, demo_primitive_float_rounding_from_unsigned);\n    register_primitive_float_signed_demos!(runner, demo_primitive_float_rounding_from_signed);\n\n    register_primitive_int_primitive_float_benches!(\n        runner,\n        benchmark_primitive_int_rounding_from_primitive_float\n    );\n    register_primitive_float_unsigned_benches!(\n        runner,\n        benchmark_primitive_float_rounding_from_unsigned\n    );\n    register_primitive_float_signed_benches!(\n        runner,\n        benchmark_primitive_float_rounding_from_signed\n    );\n}\n\nfn demo_primitive_int_rounding_from_primitive_float<\n    T: ConvertibleFrom<U> + PrimitiveInt + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (f, rm) in primitive_float_rounding_mode_pair_gen_var_3::<U, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            NiceFloat(f),\n            rm,\n            T::rounding_from(f, rm)\n        );\n    }\n}\n\nfn demo_primitive_float_rounding_from_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (u, rm) in unsigned_rounding_mode_pair_gen_var_2::<U, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x, o) = T::rounding_from(u, rm);\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            u,\n            rm,\n            (NiceFloat(x), o)\n        );\n    }\n}\n\nfn demo_primitive_float_rounding_from_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (i, rm) in signed_rounding_mode_pair_gen_var_4::<U, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x, o) = T::rounding_from(i, rm);\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            i,\n            rm,\n            (NiceFloat(x), o)\n        );\n    }\n}\n\nfn benchmark_primitive_int_rounding_from_primitive_float<\n    T: ConvertibleFrom<U> + PrimitiveInt + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rounding_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        primitive_float_rounding_mode_pair_gen_var_3::<U, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(f, rm)| no_out!(T::rounding_from(f, rm)))],\n    );\n}\n\nfn benchmark_primitive_float_rounding_from_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rounding_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_2::<U, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(u, rm)| no_out!(T::rounding_from(u, rm)))],\n    );\n}\n\nfn benchmark_primitive_float_rounding_from_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.rounding_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_rounding_mode_pair_gen_var_4::<U, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(i, rm)| no_out!(T::rounding_from(i, rm)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/from/saturating_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::SaturatingFrom;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Display;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_unsigned_demos!(runner, demo_primitive_int_saturating_from_unsigned);\n    register_primitive_int_signed_demos!(runner, demo_primitive_int_saturating_from_signed);\n    register_primitive_int_unsigned_benches!(\n        runner,\n        benchmark_primitive_int_saturating_from_unsigned\n    );\n    register_primitive_int_signed_benches!(runner, benchmark_primitive_int_saturating_from_signed);\n}\n\nfn demo_primitive_int_saturating_from_unsigned<\n    T: Display + SaturatingFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::saturating_from({}) = {}\",\n            T::NAME,\n            u,\n            T::saturating_from(u)\n        );\n    }\n}\n\nfn demo_primitive_int_saturating_from_signed<\n    T: Display + SaturatingFrom<U> + Named,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for i in signed_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::saturating_from({}) = {}\",\n            T::NAME,\n            i,\n            T::saturating_from(i)\n        );\n    }\n}\n\nfn benchmark_primitive_int_saturating_from_unsigned<\n    T: SaturatingFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::saturating_from(n)))],\n    );\n}\n\nfn benchmark_primitive_int_saturating_from_signed<\n    T: SaturatingFrom<U> + Named,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.saturating_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::saturating_from(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/from/try_from_and_exact_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_gen_var_13, primitive_float_gen_var_14, signed_gen,\n    signed_gen_var_2, signed_gen_var_7, unsigned_gen, unsigned_gen_var_18,\n};\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::{Debug, Display};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_primitive_float_demos!(\n        runner,\n        demo_primitive_int_try_from_primitive_float\n    );\n    register_unsigned_primitive_float_demos!(runner, demo_primitive_float_try_from_unsigned);\n    register_signed_primitive_float_demos!(runner, demo_primitive_float_try_from_signed);\n\n    register_primitive_int_unsigned_demos!(runner, demo_primitive_int_exact_from_unsigned);\n    register_primitive_int_signed_demos!(runner, demo_primitive_int_exact_from_signed);\n    register_unsigned_primitive_float_demos!(runner, demo_unsigned_exact_from_primitive_float);\n    register_signed_primitive_float_demos!(runner, demo_signed_exact_from_primitive_float);\n    register_primitive_float_unsigned_demos!(runner, demo_primitive_float_exact_from_unsigned);\n    register_primitive_float_signed_demos!(runner, demo_primitive_float_exact_from_signed);\n\n    register_primitive_int_primitive_float_benches!(\n        runner,\n        benchmark_primitive_int_try_from_primitive_float\n    );\n    register_primitive_float_unsigned_benches!(runner, benchmark_primitive_float_try_from_unsigned);\n    register_primitive_float_signed_benches!(runner, benchmark_primitive_float_try_from_signed);\n\n    register_primitive_int_unsigned_benches!(runner, benchmark_primitive_int_exact_from_unsigned);\n    register_primitive_int_signed_benches!(runner, benchmark_primitive_int_exact_from_signed);\n    register_unsigned_primitive_float_benches!(\n        runner,\n        benchmark_unsigned_exact_from_primitive_float\n    );\n    register_signed_primitive_float_benches!(runner, benchmark_signed_exact_from_primitive_float);\n    register_primitive_float_unsigned_benches!(\n        runner,\n        benchmark_primitive_float_exact_from_unsigned\n    );\n    register_primitive_float_signed_benches!(runner, benchmark_primitive_float_exact_from_signed);\n}\n\nfn demo_primitive_int_try_from_primitive_float<\n    T: TryFrom<NiceFloat<U>> + Debug + Named,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    <T as TryFrom<NiceFloat<U>>>::Error: Debug,\n{\n    for f in primitive_float_gen::<U>().get(gm, config).take(limit) {\n        let f = NiceFloat(f);\n        println!(\"{}::try_from({}) = {:?}\", T::NAME, f, T::try_from(f));\n    }\n}\n\nfn demo_primitive_float_try_from_unsigned<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    NiceFloat<U>: TryFrom<T>,\n    <NiceFloat<U> as TryFrom<T>>::Error: Debug,\n{\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            U::NAME,\n            u,\n            NiceFloat::<U>::try_from(u)\n        );\n    }\n}\n\nfn demo_primitive_float_try_from_signed<T: PrimitiveSigned, U: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    NiceFloat<U>: TryFrom<T>,\n    <NiceFloat<U> as TryFrom<T>>::Error: Debug,\n{\n    for u in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            U::NAME,\n            u,\n            NiceFloat::<U>::try_from(u)\n        );\n    }\n}\n\nfn demo_primitive_int_exact_from_unsigned<T: TryFrom<U> + Display + Named, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<U>().get(gm, config).take(limit) {\n        println!(\"{}::exact_from({}) = {}\", T::NAME, u, T::exact_from(u));\n    }\n}\n\nfn demo_primitive_int_exact_from_signed<T: TryFrom<U> + Display + Named, U: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for i in signed_gen_var_2::<U>().get(gm, config).take(limit) {\n        println!(\"{}::exact_from({}) = {}\", T::NAME, i, T::exact_from(i));\n    }\n}\n\nfn demo_unsigned_exact_from_primitive_float<\n    T: TryFrom<NiceFloat<U>> + PrimitiveUnsigned,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    NiceFloat<U>: TryFrom<T>,\n{\n    for f in primitive_float_gen_var_13::<U, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let f = NiceFloat(f);\n        println!(\"{}::exact_from({}) = {}\", T::NAME, f, T::exact_from(f));\n    }\n}\n\nfn demo_signed_exact_from_primitive_float<\n    T: TryFrom<NiceFloat<U>> + PrimitiveSigned + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    NiceFloat<U>: TryFrom<T>,\n{\n    for f in primitive_float_gen_var_14::<U, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let f = NiceFloat(f);\n        println!(\"{}::exact_from({}) = {}\", T::NAME, f, T::exact_from(f));\n    }\n}\n\nfn demo_primitive_float_exact_from_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    NiceFloat<T>: TryFrom<U>,\n{\n    for u in unsigned_gen_var_18::<U, T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::exact_from({}) = {}\",\n            T::NAME,\n            u,\n            NiceFloat::<T>::exact_from(u)\n        );\n    }\n}\n\nfn demo_primitive_float_exact_from_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    NiceFloat<T>: TryFrom<U>,\n{\n    for i in signed_gen_var_7::<U, T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::exact_from({}) = {}\",\n            T::NAME,\n            i,\n            NiceFloat::<T>::exact_from(i)\n        );\n    }\n}\n\nfn benchmark_primitive_int_try_from_primitive_float<\n    T: TryFrom<NiceFloat<U>> + Named,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.try_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(T::try_from(NiceFloat(n)).ok());\n        })],\n    );\n}\n\nfn benchmark_primitive_float_try_from_unsigned<T: PrimitiveFloat, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    NiceFloat<T>: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.try_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(NiceFloat::<T>::try_from(n).ok());\n        })],\n    );\n}\n\nfn benchmark_primitive_float_try_from_signed<T: PrimitiveFloat, U: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    NiceFloat<T>: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.try_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(NiceFloat::<T>::try_from(n).ok());\n        })],\n    );\n}\n\nfn benchmark_primitive_int_exact_from_unsigned<T: TryFrom<U> + Named, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.exact_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(n)))],\n    );\n}\n\nfn benchmark_primitive_int_exact_from_signed<T: TryFrom<U> + Named, U: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.exact_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_2::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(n)))],\n    );\n}\n\nfn benchmark_unsigned_exact_from_primitive_float<\n    T: TryFrom<NiceFloat<U>> + PrimitiveUnsigned,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    NiceFloat<U>: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}.exact_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_13::<U, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(NiceFloat(n))))],\n    );\n}\n\nfn benchmark_signed_exact_from_primitive_float<\n    T: TryFrom<NiceFloat<U>> + PrimitiveSigned,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    NiceFloat<U>: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}.exact_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_14::<U, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(NiceFloat(n))))],\n    );\n}\n\nfn benchmark_primitive_float_exact_from_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    NiceFloat<T>: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.exact_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_18::<U, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(NiceFloat::<T>::exact_from(n)))],\n    );\n}\n\nfn benchmark_primitive_float_exact_from_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned + RoundingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    NiceFloat<T>: TryFrom<U>,\n{\n    run_benchmark(\n        &format!(\"{}.exact_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_7::<U, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(NiceFloat::<T>::exact_from(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/from/wrapping_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Display;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_unsigned_demos!(runner, demo_primitive_int_wrapping_from_unsigned);\n    register_primitive_int_signed_demos!(runner, demo_primitive_int_wrapping_from_signed);\n    register_primitive_int_unsigned_benches!(\n        runner,\n        benchmark_primitive_int_wrapping_from_unsigned\n    );\n    register_primitive_int_signed_benches!(runner, benchmark_primitive_int_wrapping_from_signed);\n}\n\nfn demo_primitive_int_wrapping_from_unsigned<\n    T: Display + WrappingFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::wrapping_from({}) = {}\",\n            T::NAME,\n            u,\n            T::wrapping_from(u)\n        );\n    }\n}\n\nfn demo_primitive_int_wrapping_from_signed<\n    T: Display + WrappingFrom<U> + Named,\n    U: PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for i in signed_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::wrapping_from({}) = {}\",\n            T::NAME,\n            i,\n            T::wrapping_from(i)\n        );\n    }\n}\n\nfn benchmark_primitive_int_wrapping_from_unsigned<\n    T: WrappingFrom<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::wrapping_from(n)))],\n    );\n}\n\nfn benchmark_primitive_int_wrapping_from_signed<T: WrappingFrom<U> + Named, U: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.wrapping_from({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        signed_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::wrapping_from(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/half/join_halves.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::JoinHalves;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_generic_demos!(runner, demo_join_halves, u16, u32, u64, u128);\n    register_generic_benches!(runner, benchmark_join_halves, u16, u32, u64, u128);\n}\n\nfn demo_join_halves<T: JoinHalves + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    T::Half: PrimitiveUnsigned,\n{\n    for (x, y) in unsigned_pair_gen_var_27::<T::Half>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::join_halves({}, {}) = {}\",\n            T::NAME,\n            x,\n            y,\n            T::join_halves(x, y)\n        );\n    }\n}\n\nfn benchmark_join_halves<T: JoinHalves + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    T::Half: PrimitiveUnsigned,\n{\n    run_benchmark(\n        &format!(\n            \"{}::join_halves({}, {})\",\n            T::NAME,\n            T::Half::NAME,\n            T::Half::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T::Half>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(T::join_halves(x, y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/half/lower_half.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::SplitInHalf;\nuse malachite_base::test_util::bench::bucketers::unsigned_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_generic_demos!(runner, demo_lower_half, u16, u32, u64, u128);\n    register_generic_benches!(runner, benchmark_lower_half, u16, u32, u64, u128);\n}\n\nfn demo_lower_half<T: PrimitiveUnsigned + SplitInHalf>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    T::Half: PrimitiveUnsigned,\n{\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.lower_half() = {}\", u, u.lower_half());\n    }\n}\n\nfn benchmark_lower_half<T: PrimitiveUnsigned + SplitInHalf>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lower_half()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.lower_half()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/half/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    join_halves::register(runner);\n    lower_half::register(runner);\n    split_in_half::register(runner);\n    upper_half::register(runner);\n}\n\nmod join_halves;\nmod lower_half;\nmod split_in_half;\nmod upper_half;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/half/split_in_half.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::SplitInHalf;\nuse malachite_base::test_util::bench::bucketers::unsigned_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_generic_demos!(runner, demo_split_in_half, u16, u32, u64, u128);\n    register_generic_benches!(runner, benchmark_split_in_half, u16, u32, u64, u128);\n}\n\nfn demo_split_in_half<T: PrimitiveUnsigned + SplitInHalf>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    T::Half: PrimitiveUnsigned,\n{\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.split_in_half() = {:?}\", u, u.split_in_half());\n    }\n}\n\nfn benchmark_split_in_half<T: PrimitiveUnsigned + SplitInHalf>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.split_in_half()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.split_in_half()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/half/upper_half.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::SplitInHalf;\nuse malachite_base::test_util::bench::bucketers::unsigned_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_generic_demos!(runner, demo_upper_half, u16, u32, u64, u128);\n    register_generic_benches!(runner, benchmark_upper_half, u16, u32, u64, u128);\n}\n\nfn demo_upper_half<T: PrimitiveUnsigned + SplitInHalf>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    T::Half: PrimitiveUnsigned,\n{\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.upper_half() = {}\", u, u.upper_half());\n    }\n}\n\nfn benchmark_upper_half<T: PrimitiveUnsigned + SplitInHalf>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.upper_half()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.upper_half()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    primitive_float_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_is_integer_unsigned);\n    register_signed_demos!(runner, demo_is_integer_signed);\n    register_primitive_float_demos!(runner, demo_is_integer_primitive_float);\n    register_unsigned_benches!(runner, benchmark_is_integer_unsigned);\n    register_signed_benches!(runner, benchmark_is_integer_signed);\n    register_primitive_float_benches!(runner, benchmark_is_integer_primitive_float);\n}\n\nfn demo_is_integer_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        if x.is_integer() {\n            println!(\"{} is an integer\", NiceFloat(x));\n        } else {\n            println!(\"{} is not an integer\", NiceFloat(x));\n        }\n    }\n}\n\nfn demo_is_integer_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        if x.is_integer() {\n            println!(\"{x} is an integer\");\n        } else {\n            println!(\"{x} is not an integer\");\n        }\n    }\n}\n\nfn demo_is_integer_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in signed_gen::<T>().get(gm, config).take(limit) {\n        if x.is_integer() {\n            println!(\"{x} is an integer\");\n        } else {\n            println!(\"{x} is not an integer\");\n        }\n    }\n}\n\nfn benchmark_is_integer_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_integer()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_integer()))],\n    );\n}\n\nfn benchmark_is_integer_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_integer()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_integer()))],\n    );\n}\n\nfn benchmark_is_integer_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_integer()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_integer()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/mantissa_and_exponent/integer_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bit_bucketer, primitive_float_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_12, unsigned_gen_var_1, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_30, unsigned_signed_pair_gen_var_1, unsigned_signed_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_mantissa_and_exponent_unsigned);\n    register_unsigned_demos!(runner, demo_integer_mantissa_unsigned);\n    register_unsigned_demos!(runner, demo_integer_exponent_unsigned);\n    register_unsigned_demos!(runner, demo_from_integer_mantissa_and_exponent_unsigned);\n    register_unsigned_demos!(\n        runner,\n        demo_from_integer_mantissa_and_exponent_targeted_unsigned\n    );\n\n    register_primitive_float_demos!(runner, demo_integer_mantissa_and_exponent_primitive_float);\n    register_primitive_float_demos!(runner, demo_integer_mantissa_primitive_float);\n    register_primitive_float_demos!(runner, demo_integer_exponent_primitive_float);\n    register_primitive_float_demos!(\n        runner,\n        demo_from_integer_mantissa_and_exponent_primitive_float\n    );\n    register_primitive_float_demos!(\n        runner,\n        demo_from_integer_mantissa_and_exponent_targeted_primitive_float\n    );\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_integer_mantissa_and_exponent_algorithms_unsigned\n    );\n    register_unsigned_benches!(runner, benchmark_integer_mantissa_algorithms_unsigned);\n    register_unsigned_benches!(runner, benchmark_integer_exponent_algorithms_unsigned);\n    register_unsigned_benches!(\n        runner,\n        benchmark_from_integer_mantissa_and_exponent_unsigned\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_from_integer_mantissa_and_exponent_targeted_unsigned\n    );\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_integer_mantissa_and_exponent_algorithms_primitive_float\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_integer_mantissa_algorithms_primitive_float\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_integer_exponent_algorithms_primitive_float\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_from_integer_mantissa_and_exponent_primitive_float\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_from_integer_mantissa_and_exponent_targeted_primitive_float\n    );\n}\n\nfn demo_integer_mantissa_and_exponent_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\n            \"integer_mantissa_and_exponent({}) = {:?}\",\n            x,\n            x.integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_integer_mantissa_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\"integer_mantissa({}) = {}\", x, x.integer_mantissa());\n    }\n}\n\nfn demo_integer_exponent_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\"integer_exponent({}) = {}\", x, x.integer_exponent());\n    }\n}\n\nfn demo_from_integer_mantissa_and_exponent_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_integer_mantissa_and_exponent({}, {}) = {:?}\",\n            T::NAME,\n            mantissa,\n            exponent,\n            T::from_integer_mantissa_and_exponent(mantissa, exponent)\n        );\n    }\n}\n\nfn demo_from_integer_mantissa_and_exponent_targeted_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in unsigned_pair_gen_var_30::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_integer_mantissa_and_exponent({}, {}) = {}\",\n            T::NAME,\n            mantissa,\n            exponent,\n            T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap()\n        );\n    }\n}\n\nfn demo_integer_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"integer_mantissa_and_exponent({}) = {:?}\",\n            NiceFloat(x),\n            x.integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_integer_mantissa_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"integer_mantissa({}) = {}\",\n            NiceFloat(x),\n            x.integer_mantissa()\n        );\n    }\n}\n\nfn demo_integer_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"integer_exponent({}) = {}\",\n            NiceFloat(x),\n            x.integer_exponent()\n        );\n    }\n}\n\nfn demo_from_integer_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in unsigned_signed_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_integer_mantissa_and_exponent({}, {}) = {:?}\",\n            T::NAME,\n            mantissa,\n            exponent,\n            T::from_integer_mantissa_and_exponent(mantissa, exponent).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_from_integer_mantissa_and_exponent_targeted_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in unsigned_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_integer_mantissa_and_exponent({}, {}) = {}\",\n            T::NAME,\n            mantissa,\n            exponent,\n            NiceFloat(T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap())\n        );\n    }\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_mantissa_and_exponent_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.integer_mantissa_and_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |x| {\n                no_out!(x.integer_mantissa_and_exponent());\n            }),\n            (\"alt\", &mut |x| {\n                no_out!((x.integer_mantissa(), x.integer_exponent()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_mantissa_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.integer_mantissa()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.integer_mantissa())),\n            (\"alt\", &mut |x| no_out!(x.integer_mantissa_and_exponent().0)),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_exponent_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.integer_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.integer_exponent())),\n            (\"alt\", &mut |x| no_out!(x.integer_mantissa_and_exponent().1)),\n        ],\n    );\n}\n\nfn benchmark_from_integer_mantissa_and_exponent_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_integer_mantissa_and_exponent({}, u64)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_integer_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n\nfn benchmark_from_integer_mantissa_and_exponent_targeted_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_integer_mantissa_and_exponent({}, u64)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_30::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_integer_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_mantissa_and_exponent_algorithms_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.integer_mantissa_and_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| {\n                no_out!(x.integer_mantissa_and_exponent());\n            }),\n            (\"alt\", &mut |x| {\n                no_out!((x.integer_mantissa(), x.integer_exponent()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_mantissa_algorithms_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.integer_mantissa()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.integer_mantissa())),\n            (\"alt\", &mut |x| no_out!(x.integer_mantissa_and_exponent().0)),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_exponent_algorithms_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.integer_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.integer_exponent())),\n            (\"alt\", &mut |x| no_out!(x.integer_mantissa_and_exponent().1)),\n        ],\n    );\n}\n\nfn benchmark_from_integer_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_integer_mantissa_and_exponent(u64, u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_integer_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n\nfn benchmark_from_integer_mantissa_and_exponent_targeted_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_integer_mantissa_and_exponent(u64, u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_integer_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/mantissa_and_exponent/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    integer_mantissa_and_exponent::register(runner);\n    raw_mantissa_and_exponent::register(runner);\n    sci_mantissa_and_exponent::register(runner);\n}\n\nmod integer_mantissa_and_exponent;\nmod raw_mantissa_and_exponent;\nmod sci_mantissa_and_exponent;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/mantissa_and_exponent/raw_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bit_bucketer, primitive_float_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{primitive_float_gen, unsigned_pair_gen_var_26};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_raw_mantissa_and_exponent);\n    register_primitive_float_demos!(runner, demo_raw_mantissa);\n    register_primitive_float_demos!(runner, demo_raw_exponent);\n    register_primitive_float_demos!(runner, demo_from_raw_mantissa_and_exponent);\n    register_primitive_float_benches!(runner, benchmark_raw_mantissa_and_exponent_algorithms);\n    register_primitive_float_benches!(runner, benchmark_raw_mantissa_algorithms);\n    register_primitive_float_benches!(runner, benchmark_raw_exponent_algorithms);\n    register_primitive_float_benches!(runner, benchmark_from_raw_mantissa_and_exponent);\n}\n\nfn demo_raw_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"raw_mantissa_and_exponent({}) = {:?}\",\n            NiceFloat(x),\n            x.raw_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_raw_mantissa<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\"raw_mantissa({}) = {}\", NiceFloat(x), x.raw_mantissa());\n    }\n}\n\nfn demo_raw_exponent<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\"raw_exponent({}) = {}\", NiceFloat(x), x.raw_exponent());\n    }\n}\n\nfn demo_from_raw_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in unsigned_pair_gen_var_26::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_raw_mantissa_and_exponent({}, {}) = {}\",\n            T::NAME,\n            mantissa,\n            exponent,\n            NiceFloat(T::from_raw_mantissa_and_exponent(mantissa, exponent))\n        );\n    }\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_raw_mantissa_and_exponent_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.raw_mantissa_and_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.raw_mantissa_and_exponent())),\n            (\"alt\", &mut |x| {\n                no_out!((x.raw_mantissa(), x.raw_exponent()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_raw_mantissa_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.raw_mantissa()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.raw_mantissa())),\n            (\"alt\", &mut |x| no_out!(x.raw_mantissa_and_exponent().0)),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_raw_exponent_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.raw_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.raw_exponent())),\n            (\"alt\", &mut |x| no_out!(x.raw_mantissa_and_exponent().1)),\n        ],\n    );\n}\n\nfn benchmark_from_raw_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_raw_mantissa_and_exponent(u64, u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_26::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_raw_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/mantissa_and_exponent/sci_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::mantissa_and_exponent::{\n    from_sci_mantissa_and_exponent_round, sci_mantissa_and_exponent_round,\n};\nuse malachite_base::num::conversion::traits::SciMantissaAndExponent;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_primitive_float_bucketer, primitive_float_bucketer, triple_1_primitive_float_bucketer,\n    unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_12, primitive_float_signed_pair_gen_var_1,\n    primitive_float_signed_pair_gen_var_2, primitive_float_unsigned_pair_gen_var_1,\n    primitive_float_unsigned_pair_gen_var_2,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_1,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_2, unsigned_gen_var_1,\n    unsigned_rounding_mode_pair_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_primitive_float_demos!(runner, demo_sci_mantissa_and_exponent_unsigned);\n    register_unsigned_primitive_float_demos!(runner, demo_sci_mantissa_unsigned);\n    register_unsigned_primitive_float_demos!(runner, demo_sci_exponent_unsigned);\n    register_unsigned_primitive_float_demos!(runner, demo_sci_mantissa_and_exponent_round);\n    register_unsigned_primitive_float_demos!(runner, demo_from_sci_mantissa_and_exponent_unsigned);\n    register_unsigned_primitive_float_demos!(\n        runner,\n        demo_from_sci_mantissa_and_exponent_targeted_unsigned\n    );\n    register_unsigned_primitive_float_demos!(runner, demo_from_sci_mantissa_and_exponent_round);\n    register_unsigned_primitive_float_demos!(\n        runner,\n        demo_from_sci_mantissa_and_exponent_round_targeted\n    );\n\n    register_primitive_float_demos!(runner, demo_sci_mantissa_and_exponent_primitive_float);\n    register_primitive_float_demos!(runner, demo_sci_mantissa_primitive_float);\n    register_primitive_float_demos!(runner, demo_sci_exponent_primitive_float);\n    register_primitive_float_demos!(runner, demo_from_sci_mantissa_and_exponent_primitive_float);\n    register_primitive_float_demos!(\n        runner,\n        demo_from_sci_mantissa_and_exponent_targeted_primitive_float\n    );\n\n    register_unsigned_primitive_float_benches!(\n        runner,\n        benchmark_sci_mantissa_and_exponent_algorithms_unsigned\n    );\n    register_unsigned_primitive_float_benches!(runner, benchmark_sci_mantissa_algorithms_unsigned);\n    register_unsigned_primitive_float_benches!(runner, benchmark_sci_exponent_algorithms_unsigned);\n    register_unsigned_primitive_float_benches!(\n        runner,\n        benchmark_from_sci_mantissa_and_exponent_unsigned\n    );\n    register_unsigned_primitive_float_benches!(\n        runner,\n        benchmark_from_sci_mantissa_and_exponent_targeted_unsigned\n    );\n    register_unsigned_primitive_float_benches!(\n        runner,\n        benchmark_from_sci_mantissa_and_exponent_round\n    );\n    register_unsigned_primitive_float_benches!(\n        runner,\n        benchmark_from_sci_mantissa_and_exponent_round_targeted\n    );\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_sci_mantissa_and_exponent_algorithms_primitive_float\n    );\n    register_primitive_float_benches!(runner, benchmark_sci_mantissa_algorithms_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_sci_exponent_algorithms_primitive_float);\n    register_primitive_float_benches!(\n        runner,\n        benchmark_from_sci_mantissa_and_exponent_primitive_float\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_from_sci_mantissa_and_exponent_targeted_primitive_float\n    );\n}\n\nfn demo_sci_mantissa_and_exponent_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        let (m, e): (U, u64) = x.sci_mantissa_and_exponent();\n        println!(\"sci_mantissa_and_exponent({}) = {:?}\", x, (NiceFloat(m), e));\n    }\n}\n\nfn demo_sci_mantissa_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        let m: U = x.sci_mantissa();\n        println!(\"sci_mantissa({}) = {}\", x, NiceFloat(m));\n    }\n}\n\nfn demo_sci_exponent_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\n            \"sci_exponent({}) = {}\",\n            x,\n            SciMantissaAndExponent::<U, u64>::sci_exponent(x)\n        );\n    }\n}\n\nfn demo_sci_mantissa_and_exponent_round<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, rm) in unsigned_rounding_mode_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let o =\n            sci_mantissa_and_exponent_round::<T, U>(x, rm).map(|(m, e, o)| (NiceFloat(m), e, o));\n        println!(\"sci_mantissa_and_exponent_round({x}, {rm}) = {o:?}\");\n    }\n}\n\nfn demo_from_sci_mantissa_and_exponent_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in primitive_float_unsigned_pair_gen_var_1::<U, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_sci_mantissa_and_exponent({}, {}) = {:?}\",\n            T::NAME,\n            NiceFloat(mantissa),\n            exponent,\n            T::from_sci_mantissa_and_exponent(mantissa, exponent)\n        );\n    }\n}\n\nfn demo_from_sci_mantissa_and_exponent_targeted_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in primitive_float_unsigned_pair_gen_var_2::<U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_sci_mantissa_and_exponent({}, {}) = {:?}\",\n            T::NAME,\n            NiceFloat(mantissa),\n            exponent,\n            T::from_sci_mantissa_and_exponent(mantissa, exponent)\n        );\n    }\n}\n\nfn demo_from_sci_mantissa_and_exponent_round<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent, rm) in\n        primitive_float_unsigned_rounding_mode_triple_gen_var_1::<U, u64>()\n            .get(gm, config)\n            .take(limit)\n    {\n        println!(\n            \"from_sci_mantissa_and_exponent_round({}, {}, {}) = {:?}\",\n            NiceFloat(mantissa),\n            exponent,\n            rm,\n            from_sci_mantissa_and_exponent_round::<T, U>(mantissa, exponent, rm)\n        );\n    }\n}\n\nfn demo_from_sci_mantissa_and_exponent_round_targeted<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent, rm) in primitive_float_unsigned_rounding_mode_triple_gen_var_2::<U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_sci_mantissa_and_exponent_round({}, {}, {}) = {:?}\",\n            NiceFloat(mantissa),\n            exponent,\n            rm,\n            from_sci_mantissa_and_exponent_round::<T, U>(mantissa, exponent, rm)\n        );\n    }\n}\n\nfn demo_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (m, e) = x.sci_mantissa_and_exponent();\n        println!(\n            \"sci_mantissa_and_exponent({}) = {:?}\",\n            NiceFloat(x),\n            (NiceFloat(m), e)\n        );\n    }\n}\n\nfn demo_sci_mantissa_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sci_mantissa({}) = {}\",\n            NiceFloat(x),\n            NiceFloat(x.sci_mantissa())\n        );\n    }\n}\n\nfn demo_sci_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"sci_exponent({}) = {}\", NiceFloat(x), x.sci_exponent());\n    }\n}\n\nfn demo_from_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in primitive_float_signed_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_sci_mantissa_and_exponent({}, {}) = {:?}\",\n            T::NAME,\n            NiceFloat(mantissa),\n            exponent,\n            T::from_sci_mantissa_and_exponent(mantissa, exponent).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_from_sci_mantissa_and_exponent_targeted_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in primitive_float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_sci_mantissa_and_exponent({}, {}) = {}\",\n            T::NAME,\n            NiceFloat(mantissa),\n            exponent,\n            NiceFloat(T::from_sci_mantissa_and_exponent(mantissa, exponent).unwrap())\n        );\n    }\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_sci_mantissa_and_exponent_algorithms_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sci_mantissa_and_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<U, u64>::sci_mantissa_and_exponent(\n                    x\n                ));\n            }),\n            (\"alt\", &mut |x| {\n                no_out!((\n                    SciMantissaAndExponent::<U, u64>::sci_mantissa(x),\n                    SciMantissaAndExponent::<U, u64>::sci_exponent(x)\n                ));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_sci_mantissa_algorithms_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sci_mantissa()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<U, u64>::sci_mantissa(x));\n            }),\n            (\"alt\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<U, u64>::sci_mantissa_and_exponent(x).0);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_sci_exponent_algorithms_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sci_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<U, u64>::sci_exponent(x));\n            }),\n            (\"alt\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<U, u64>::sci_mantissa_and_exponent(x).1);\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_sci_mantissa_and_exponent_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_sci_mantissa_and_exponent({}, u64)\",\n            U::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        primitive_float_unsigned_pair_gen_var_1::<U, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_sci_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n\nfn benchmark_from_sci_mantissa_and_exponent_targeted_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_sci_mantissa_and_exponent({}, u64)\",\n            U::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        primitive_float_unsigned_pair_gen_var_2::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_sci_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n\nfn benchmark_from_sci_mantissa_and_exponent_round<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"from_sci_mantissa_and_exponent_round({}, u64, RoundingMode)\",\n            U::NAME\n        ),\n        BenchmarkType::Single,\n        primitive_float_unsigned_rounding_mode_triple_gen_var_1::<U, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent, rm)| {\n            no_out!(from_sci_mantissa_and_exponent_round::<T, U>(\n                mantissa, exponent, rm\n            ));\n        })],\n    );\n}\n\nfn benchmark_from_sci_mantissa_and_exponent_round_targeted<\n    T: PrimitiveUnsigned,\n    U: PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"from_sci_mantissa_and_exponent_round({}, u64, RoundingMode)\",\n            U::NAME\n        ),\n        BenchmarkType::Single,\n        primitive_float_unsigned_rounding_mode_triple_gen_var_2::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent, rm)| {\n            no_out!(from_sci_mantissa_and_exponent_round::<T, U>(\n                mantissa, exponent, rm\n            ));\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_sci_mantissa_and_exponent_algorithms_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sci_mantissa_and_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.sci_mantissa_and_exponent())),\n            (\"alt\", &mut |x| {\n                no_out!((x.sci_mantissa(), x.sci_exponent()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_sci_mantissa_algorithms_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sci_mantissa()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.sci_mantissa())),\n            (\"alt\", &mut |x| no_out!(x.sci_mantissa_and_exponent().0)),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_sci_exponent_algorithms_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.sci_exponent()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.sci_exponent())),\n            (\"alt\", &mut |x| no_out!(x.sci_mantissa_and_exponent().1)),\n        ],\n    );\n}\n\nfn benchmark_from_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_sci_mantissa_and_exponent({}, u64)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        primitive_float_signed_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_sci_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n\nfn benchmark_from_sci_mantissa_and_exponent_targeted_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_sci_mantissa_and_exponent({}, u64)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        primitive_float_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(T::from_sci_mantissa_and_exponent(mantissa, exponent));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    digits::register(runner);\n    from::register(runner);\n    half::register(runner);\n    is_integer::register(runner);\n    mantissa_and_exponent::register(runner);\n    slice::register(runner);\n    string::register(runner);\n}\n\nmod digits;\nmod from;\nmod half;\nmod is_integer;\nmod mantissa_and_exponent;\nmod slice;\nmod string;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/slice/from_other_type_slice.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::FromOtherTypeSlice;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Display;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_from_other_type_slice);\n    register_unsigned_unsigned_benches!(runner, benchmark_from_other_type_slice);\n}\n\nfn demo_from_other_type_slice<T: Display + FromOtherTypeSlice<U> + Named, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for xs in unsigned_vec_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_other_type_slice({:?}) = {}\",\n            T::NAME,\n            xs,\n            T::from_other_type_slice(&xs)\n        );\n    }\n}\n\nfn benchmark_from_other_type_slice<T: FromOtherTypeSlice<U> + Named, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.from_other_type_slice(&[{}])\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_vec_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| {\n            no_out!(T::from_other_type_slice(&xs));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/slice/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_other_type_slice::register(runner);\n    vec_from_other_type::register(runner);\n    vec_from_other_type_slice::register(runner);\n}\n\nmod from_other_type_slice;\nmod vec_from_other_type;\nmod vec_from_other_type_slice;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/slice/vec_from_other_type.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::VecFromOtherType;\nuse malachite_base::test_util::bench::bucketers::unsigned_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Debug;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_vec_from_other_type);\n    register_unsigned_unsigned_benches!(runner, benchmark_vec_from_other_type);\n}\n\nfn demo_vec_from_other_type<T: Debug + VecFromOtherType<U> + Named, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::vec_from_other_type({}) = {:?}\",\n            T::NAME,\n            u,\n            T::vec_from_other_type(u)\n        );\n    }\n}\n\nfn benchmark_vec_from_other_type<T: VecFromOtherType<U> + Named, U: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.vec_from_other_type({})\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::vec_from_other_type(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/slice/vec_from_other_type_slice.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::VecFromOtherTypeSlice;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Debug;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_unsigned_demos!(runner, demo_vec_from_other_type_slice);\n    register_unsigned_unsigned_benches!(runner, benchmark_vec_from_other_type_slice);\n}\n\nfn demo_vec_from_other_type_slice<\n    T: Debug + VecFromOtherTypeSlice<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for xs in unsigned_vec_gen::<U>().get(gm, config).take(limit) {\n        println!(\n            \"{}::vec_from_other_type_slice({:?}) = {:?}\",\n            T::NAME,\n            xs,\n            T::vec_from_other_type_slice(&xs)\n        );\n    }\n}\n\nfn benchmark_vec_from_other_type_slice<\n    T: VecFromOtherTypeSlice<U> + Named,\n    U: PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.vec_from_other_type_slice(&[{}])\", T::NAME, U::NAME),\n        BenchmarkType::Single,\n        unsigned_vec_gen::<U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| {\n            no_out!(T::vec_from_other_type_slice(&xs));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_string_len_bucketer, string_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    string_from_sci_string_options_pair_gen, string_from_sci_string_options_pair_gen_var_1,\n    string_gen, string_gen_var_13,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_demos!(runner, demo_primitive_int_from_sci_string);\n    register_primitive_int_demos!(runner, demo_primitive_int_from_sci_string_targeted);\n    register_primitive_int_demos!(runner, demo_primitive_int_from_sci_string_with_options);\n    register_primitive_int_demos!(\n        runner,\n        demo_primitive_int_from_sci_string_with_options_targeted\n    );\n\n    register_primitive_int_benches!(runner, benchmark_primitive_int_from_sci_string);\n    register_primitive_int_benches!(runner, benchmark_primitive_int_from_sci_string_with_options);\n}\n\nfn demo_primitive_int_from_sci_string<T: PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_sci_string({}) = {:?}\",\n            T::NAME,\n            s,\n            T::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_primitive_int_from_sci_string_targeted<T: PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for s in string_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_sci_string({}) = {:?}\",\n            T::NAME,\n            s,\n            T::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_primitive_int_from_sci_string_with_options<T: PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (s, options) in string_from_sci_string_options_pair_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_sci_string_with_options({}, {:?}) = {:?}\",\n            T::NAME,\n            s,\n            options,\n            T::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn demo_primitive_int_from_sci_string_with_options_targeted<T: PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (s, options) in string_from_sci_string_options_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::from_sci_string_with_options({}, {:?}) = {:?}\",\n            T::NAME,\n            s,\n            options,\n            T::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn benchmark_primitive_int_from_sci_string<T: PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_sci_string(&str)\", T::NAME),\n        BenchmarkType::Single,\n        string_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(T::from_sci_string(&s)))],\n    );\n}\n\nfn benchmark_primitive_int_from_sci_string_with_options<T: PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"{}::from_sci_string_with_options(&str, FromSciStringOptions)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        string_from_sci_string_options_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_string_len_bucketer(\"s\"),\n        &mut [(\"Malachite\", &mut |(s, options)| {\n            no_out!(T::from_sci_string_with_options(&s, options));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::string::from_string::digit_from_display_byte;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_gen_var_10};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_digit_from_display_byte);\n    register_demo!(runner, demo_digit_from_display_byte_targeted);\n}\n\nfn demo_digit_from_display_byte(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"digit_from_display_byte({}) = {:?}\",\n            b,\n            digit_from_display_byte(b)\n        );\n    }\n}\n\nfn demo_digit_from_display_byte_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in unsigned_gen_var_10().get(gm, config).take(limit) {\n        println!(\n            \"digit_from_display_byte({}) = {}\",\n            b,\n            digit_from_display_byte(b).unwrap()\n        );\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_sci_string::register(runner);\n    from_string::register(runner);\n    options::register(runner);\n    to_sci::register(runner);\n    to_string::register(runner);\n}\n\nmod from_sci_string;\nmod from_string;\nmod options;\nmod to_sci;\nmod to_string;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/options/from_sci_string_options.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    from_sci_string_options_gen, from_sci_string_options_rounding_mode_pair_gen,\n    from_sci_string_options_unsigned_pair_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_from_sci_string_options_to_debug_string);\n    register_demo!(runner, demo_from_sci_string_options_get_base);\n    register_demo!(runner, demo_from_sci_string_options_get_rounding_mode);\n    register_demo!(runner, demo_from_sci_string_options_set_base);\n    register_demo!(runner, demo_from_sci_string_options_set_rounding_mode);\n}\n\nfn demo_from_sci_string_options_to_debug_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in from_sci_string_options_gen().get(gm, config).take(limit) {\n        println!(\"{options:?}\");\n    }\n}\n\nfn demo_from_sci_string_options_get_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in from_sci_string_options_gen().get(gm, config).take(limit) {\n        println!(\"get_base({:?}) = {}\", options, options.get_base());\n    }\n}\n\nfn demo_from_sci_string_options_get_rounding_mode(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in from_sci_string_options_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_rounding_mode({:?}) = {}\",\n            options,\n            options.get_rounding_mode()\n        );\n    }\n}\n\nfn demo_from_sci_string_options_set_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, base) in from_sci_string_options_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_options = options;\n        options.set_base(base);\n        println!(\"options := {old_options:?}; options.set_base({base}); options = {options:?}\");\n    }\n}\n\nfn demo_from_sci_string_options_set_rounding_mode(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, rm) in from_sci_string_options_rounding_mode_pair_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_options = options;\n        options.set_rounding_mode(rm);\n        println!(\n            \"options := {old_options:?}; options.set_rounding_mode({rm}); options = {options:?}\",\n        );\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/options/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_sci_string_options::register(runner);\n    sci_size_options::register(runner);\n    to_sci_options::register(runner);\n}\n\nmod from_sci_string_options;\nmod sci_size_options;\nmod to_sci_options;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/options/sci_size_options.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::sci_size_options_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_sci_size_options_to_debug_string);\n}\n\nfn demo_sci_size_options_to_debug_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in sci_size_options_gen().get(gm, config).take(limit) {\n        println!(\"{options:?}\");\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/options/to_sci_options.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    to_sci_options_bool_pair_gen, to_sci_options_gen, to_sci_options_rounding_mode_pair_gen,\n    to_sci_options_signed_pair_gen_var_1, to_sci_options_unsigned_pair_gen_var_1,\n    to_sci_options_unsigned_pair_gen_var_2, to_sci_options_unsigned_pair_gen_var_3,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_to_sci_options_to_debug_string);\n    register_demo!(runner, demo_to_sci_options_get_base);\n    register_demo!(runner, demo_to_sci_options_get_rounding_mode);\n    register_demo!(runner, demo_to_sci_options_get_size_options);\n    register_demo!(runner, demo_to_sci_options_get_neg_exp_threshold);\n    register_demo!(runner, demo_to_sci_options_get_lowercase);\n    register_demo!(runner, demo_to_sci_options_get_e_lowercase);\n    register_demo!(runner, demo_to_sci_options_get_force_exponent_plus_sign);\n    register_demo!(runner, demo_to_sci_options_get_include_trailing_zeros);\n    register_demo!(runner, demo_to_sci_options_set_base);\n    register_demo!(runner, demo_to_sci_options_set_rounding_mode);\n    register_demo!(runner, demo_to_sci_options_set_size_complete);\n    register_demo!(runner, demo_to_sci_options_set_precision);\n    register_demo!(runner, demo_to_sci_options_set_scale);\n    register_demo!(runner, demo_to_sci_options_set_neg_exp_threshold);\n    register_demo!(runner, demo_to_sci_options_set_lowercase);\n    register_demo!(runner, demo_to_sci_options_set_uppercase);\n    register_demo!(runner, demo_to_sci_options_set_e_lowercase);\n    register_demo!(runner, demo_to_sci_options_set_e_uppercase);\n    register_demo!(runner, demo_to_sci_options_set_force_exponent_plus_sign);\n    register_demo!(runner, demo_to_sci_options_set_include_trailing_zeros);\n}\n\nfn demo_to_sci_options_to_debug_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\"{options:?}\");\n    }\n}\n\nfn demo_to_sci_options_get_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\"get_base({:?}) = {}\", options, options.get_base());\n    }\n}\n\nfn demo_to_sci_options_get_rounding_mode(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_rounding_mode({:?}) = {}\",\n            options,\n            options.get_rounding_mode()\n        );\n    }\n}\n\nfn demo_to_sci_options_get_size_options(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_size_options({:?}) = {:?}\",\n            options,\n            options.get_size_options()\n        );\n    }\n}\n\nfn demo_to_sci_options_get_neg_exp_threshold(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_neg_exp_threshold({:?}) = {}\",\n            options,\n            options.get_neg_exp_threshold()\n        );\n    }\n}\n\nfn demo_to_sci_options_get_lowercase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\"get_lowercase({:?}) = {}\", options, options.get_lowercase());\n    }\n}\n\nfn demo_to_sci_options_get_e_lowercase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_e_lowercase({:?}) = {}\",\n            options,\n            options.get_e_lowercase()\n        );\n    }\n}\n\nfn demo_to_sci_options_get_force_exponent_plus_sign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_force_exponent_plus_sign({:?}) = {}\",\n            options,\n            options.get_force_exponent_plus_sign()\n        );\n    }\n}\n\nfn demo_to_sci_options_get_include_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for options in to_sci_options_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_include_trailing_zeros({:?}) = {}\",\n            options,\n            options.get_include_trailing_zeros()\n        );\n    }\n}\n\nfn demo_to_sci_options_set_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, base) in to_sci_options_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_options = options;\n        options.set_base(base);\n        println!(\"options := {old_options:?}; options.set_base({base}); options = {options:?}\");\n    }\n}\n\nfn demo_to_sci_options_set_rounding_mode(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, rm) in to_sci_options_rounding_mode_pair_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_options = options;\n        options.set_rounding_mode(rm);\n        println!(\n            \"options := {old_options:?}; options.set_rounding_mode({rm}); options = {options:?}\",\n        );\n    }\n}\n\nfn demo_to_sci_options_set_size_complete(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut options in to_sci_options_gen().get(gm, config).take(limit) {\n        let old_options = options;\n        options.set_size_complete();\n        println!(\"options := {old_options:?}; options.set_size_complete(); options = {options:?}\");\n    }\n}\n\nfn demo_to_sci_options_set_precision(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, precision) in to_sci_options_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_options = options;\n        options.set_precision(precision);\n        println!(\n            \"options := {old_options:?}; options.set_precision({precision}); options = {options:?}\",\n        );\n    }\n}\n\nfn demo_to_sci_options_set_scale(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, scale) in to_sci_options_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_options = options;\n        options.set_scale(scale);\n        println!(\"options := {old_options:?}; options.set_scale({scale}); options = {options:?}\");\n    }\n}\n\nfn demo_to_sci_options_set_neg_exp_threshold(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, neg_exp_threshold) in to_sci_options_signed_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_options = options;\n        options.set_neg_exp_threshold(neg_exp_threshold);\n        println!(\n            \"options := {old_options:?}; options.set_neg_exp_threshold({neg_exp_threshold}); \\\n            options = {options:?}\",\n        );\n    }\n}\n\nfn demo_to_sci_options_set_lowercase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut options in to_sci_options_gen().get(gm, config).take(limit) {\n        let old_options = options;\n        options.set_lowercase();\n        println!(\"options := {old_options:?}; options.set_lowercase(); options = {options:?}\");\n    }\n}\n\nfn demo_to_sci_options_set_uppercase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut options in to_sci_options_gen().get(gm, config).take(limit) {\n        let old_options = options;\n        options.set_uppercase();\n        println!(\"options := {old_options:?}; options.set_uppercase(); options = {options:?}\");\n    }\n}\n\nfn demo_to_sci_options_set_e_lowercase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut options in to_sci_options_gen().get(gm, config).take(limit) {\n        let old_options = options;\n        options.set_e_lowercase();\n        println!(\"options := {old_options:?}; options.set_e_lowercase(); options = {options:?}\");\n    }\n}\n\nfn demo_to_sci_options_set_e_uppercase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut options in to_sci_options_gen().get(gm, config).take(limit) {\n        let old_options = options;\n        options.set_e_uppercase();\n        println!(\"options := {old_options:?}; options.set_e_uppercase(); options = {options:?}\");\n    }\n}\n\nfn demo_to_sci_options_set_force_exponent_plus_sign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, force_exponent_plus_sign) in\n        to_sci_options_bool_pair_gen().get(gm, config).take(limit)\n    {\n        let old_options = options;\n        options.set_force_exponent_plus_sign(force_exponent_plus_sign);\n        println!(\n            \"options := {old_options:?}; \\\n            options.set_force_exponent_plus_sign({force_exponent_plus_sign}); \\\n            options = {options:?}\",\n        );\n    }\n}\n\nfn demo_to_sci_options_set_include_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut options, include_trailing_zeros) in\n        to_sci_options_bool_pair_gen().get(gm, config).take(limit)\n    {\n        let old_options = options;\n        options.set_include_trailing_zeros(include_trailing_zeros);\n        println!(\n            \"options := {old_options:?}; \\\n            options.set_include_trailing_zeros({include_trailing_zeros}); options = {options:?}\",\n        );\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bit_bucketer, signed_bit_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_to_sci_options_pair_gen, signed_to_sci_options_pair_gen_var_1, unsigned_gen,\n    unsigned_to_sci_options_pair_gen, unsigned_to_sci_options_pair_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_to_sci_unsigned);\n    register_signed_demos!(runner, demo_to_sci_signed);\n    register_unsigned_demos!(runner, demo_fmt_sci_valid_unsigned);\n    register_signed_demos!(runner, demo_fmt_sci_valid_signed);\n    register_unsigned_demos!(runner, demo_to_sci_with_options_unsigned);\n    register_signed_demos!(runner, demo_to_sci_with_options_signed);\n\n    register_unsigned_benches!(runner, benchmark_to_sci_unsigned);\n    register_signed_benches!(runner, benchmark_to_sci_signed);\n    register_unsigned_benches!(runner, benchmark_fmt_sci_valid_unsigned);\n    register_signed_benches!(runner, benchmark_fmt_sci_valid_signed);\n    register_unsigned_benches!(runner, benchmark_to_sci_with_options_unsigned);\n    register_signed_benches!(runner, benchmark_to_sci_with_options_signed);\n}\n\nfn demo_to_sci_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.to_sci() = {}\", x, x.to_sci());\n    }\n}\n\nfn demo_to_sci_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.to_sci() = {}\", x, x.to_sci());\n    }\n}\n\nfn demo_fmt_sci_valid_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, options) in unsigned_to_sci_options_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.fmt_sci_valid(options) {\n            println!(\"{x} can be converted to sci using {options:?}\");\n        } else {\n            println!(\"{x} cannot be converted to sci using {options:?}\");\n        }\n    }\n}\n\nfn demo_fmt_sci_valid_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, options) in signed_to_sci_options_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.fmt_sci_valid(options) {\n            println!(\"{x} can be converted to sci using {options:?}\");\n        } else {\n            println!(\"{x} cannot be converted to sci using {options:?}\");\n        }\n    }\n}\n\nfn demo_to_sci_with_options_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, options) in unsigned_to_sci_options_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_sci_with_options({}, {:?}) = {}\",\n            x,\n            options,\n            x.to_sci_with_options(options)\n        );\n    }\n}\n\nfn demo_to_sci_with_options_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, options) in signed_to_sci_options_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_sci_with_options({}, {:?}) = {}\",\n            x,\n            options,\n            x.to_sci_with_options(options)\n        );\n    }\n}\n\nfn benchmark_to_sci_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_sci()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.to_sci().to_string()))],\n    );\n}\n\nfn benchmark_to_sci_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_sci()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.to_sci().to_string()))],\n    );\n}\n\nfn benchmark_fmt_sci_valid_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.fmt_sci_valid(ToSciOptions)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_to_sci_options_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.fmt_sci_valid(options));\n        })],\n    );\n}\n\nfn benchmark_fmt_sci_valid_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.fmt_sci_valid(ToSciOptions)\", T::NAME),\n        BenchmarkType::Single,\n        signed_to_sci_options_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"i\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.fmt_sci_valid(options));\n        })],\n    );\n}\n\nfn benchmark_to_sci_with_options_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_sci_with_options(ToSciOptions)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_to_sci_options_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.to_sci_with_options(options).to_string());\n        })],\n    );\n}\n\nfn benchmark_to_sci_with_options_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_sci_with_options(ToSciOptions)\", T::NAME),\n        BenchmarkType::Single,\n        signed_to_sci_options_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"u\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.to_sci_with_options(options).to_string());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::to_string::{\n    BaseFmtWrapper, digit_to_display_byte_lower, digit_to_display_byte_upper,\n};\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bit_bucketer, triple_1_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_5, signed_unsigned_unsigned_triple_gen_var_3, unsigned_gen,\n    unsigned_gen_var_7, unsigned_pair_gen_var_8, unsigned_triple_gen_var_6,\n};\nuse malachite_base::test_util::num::conversion::string::to_string::{\n    to_string_base_signed_naive, to_string_base_unsigned_naive,\n};\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Display;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_digit_to_display_byte_lower);\n    register_demo!(runner, demo_digit_to_display_byte_upper);\n    register_demo!(runner, demo_digit_to_display_byte_lower_targeted);\n    register_demo!(runner, demo_digit_to_display_byte_upper_targeted);\n    register_unsigned_demos!(runner, demo_to_string_base_unsigned);\n    register_signed_demos!(runner, demo_to_string_base_signed);\n    register_unsigned_demos!(runner, demo_to_string_base_upper_unsigned);\n    register_signed_demos!(runner, demo_to_string_base_upper_signed);\n    register_unsigned_demos!(runner, demo_base_fmt_wrapper_fmt_unsigned);\n    register_unsigned_demos!(runner, demo_base_fmt_wrapper_fmt_with_width_unsigned);\n    register_signed_demos!(runner, demo_base_fmt_wrapper_fmt_signed);\n    register_signed_demos!(runner, demo_base_fmt_wrapper_fmt_with_width_signed);\n    register_unsigned_demos!(runner, demo_base_fmt_wrapper_fmt_upper_unsigned);\n    register_unsigned_demos!(runner, demo_base_fmt_wrapper_fmt_upper_with_width_unsigned);\n    register_signed_demos!(runner, demo_base_fmt_wrapper_fmt_upper_signed);\n    register_signed_demos!(runner, demo_base_fmt_wrapper_fmt_upper_with_width_signed);\n\n    register_unsigned_benches!(runner, benchmark_to_string_base_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_to_string_base_algorithms_signed);\n    register_unsigned_benches!(runner, benchmark_to_string_base_upper_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_to_string_base_upper_algorithms_signed);\n    register_unsigned_benches!(runner, benchmark_base_fmt_wrapper_fmt_with_width_unsigned);\n    register_signed_benches!(runner, benchmark_base_fmt_wrapper_fmt_with_width_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_base_fmt_wrapper_fmt_upper_with_width_unsigned\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_base_fmt_wrapper_fmt_upper_with_width_signed\n    );\n}\n\nfn demo_digit_to_display_byte_lower(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"digit_to_display_byte_lower({}) = {:?}\",\n            b,\n            digit_to_display_byte_lower(b)\n        );\n    }\n}\n\nfn demo_digit_to_display_byte_upper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"digit_to_display_byte_upper({}) = {:?}\",\n            b,\n            digit_to_display_byte_upper(b)\n        );\n    }\n}\n\nfn demo_digit_to_display_byte_lower_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in unsigned_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"digit_to_display_byte_lower({}) = {}\",\n            b,\n            digit_to_display_byte_lower(b).unwrap()\n        );\n    }\n}\n\nfn demo_digit_to_display_byte_upper_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in unsigned_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"digit_to_display_byte_upper({}) = {}\",\n            b,\n            digit_to_display_byte_upper(b).unwrap()\n        );\n    }\n}\n\nfn demo_to_string_base_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, base) in unsigned_pair_gen_var_8::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_string_base({}) = {}\",\n            x,\n            base,\n            x.to_string_base(base)\n        );\n    }\n}\n\nfn demo_to_string_base_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in signed_unsigned_pair_gen_var_5::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).to_string_base({}) = {}\",\n            x,\n            base,\n            x.to_string_base(base)\n        );\n    }\n}\n\nfn demo_to_string_base_upper_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, base) in unsigned_pair_gen_var_8::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_string_base_upper({}) = {}\",\n            x,\n            base,\n            x.to_string_base_upper(base)\n        );\n    }\n}\n\nfn demo_to_string_base_upper_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, base) in signed_unsigned_pair_gen_var_5::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).to_string_base_upper({}) = {}\",\n            x,\n            base,\n            x.to_string_base_upper(base)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base) in unsigned_pair_gen_var_8::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{}\", BaseFmtWrapper::new(x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_with_width_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base, width) in unsigned_triple_gen_var_6::<T, u8, usize>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, base), width = width)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base) in signed_unsigned_pair_gen_var_5::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{}\", BaseFmtWrapper::new(x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_with_width_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base, width) in signed_unsigned_unsigned_triple_gen_var_3::<T, u8, usize>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, base), width = width)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_upper_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base) in unsigned_pair_gen_var_8::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{:#}\", BaseFmtWrapper::new(x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_upper_with_width_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base, width) in unsigned_triple_gen_var_6::<T, u8, usize>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, base), width = width)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_upper_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base) in signed_unsigned_pair_gen_var_5::<T, u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{:#}\", BaseFmtWrapper::new(x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_base_fmt_wrapper_fmt_upper_with_width_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    for (x, base, width) in signed_unsigned_unsigned_triple_gen_var_3::<T, u8, usize>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, base), width = width)\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_string_base_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n    u8: WrappingFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}.to_string_base(u8)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_8::<T, u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_string\", &mut |(x, base)| {\n                no_out!(x.to_string_base(base));\n            }),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{}\", BaseFmtWrapper::new(x, base)));\n            }),\n            (\"naive\", &mut |(x, base)| {\n                no_out!(to_string_base_unsigned_naive(x, base));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_string_base_algorithms_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n    u8: WrappingFrom<<T as UnsignedAbs>::Output>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    run_benchmark(\n        &format!(\"{}.to_string_base(u8)\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_unsigned_pair_gen_var_5::<T, u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_string\", &mut |(x, base)| {\n                no_out!(x.to_string_base(base));\n            }),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{}\", BaseFmtWrapper::new(x, base)));\n            }),\n            (\"naive\", &mut |(x, base)| {\n                no_out!(to_string_base_signed_naive(x, base));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_string_base_upper_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    run_benchmark(\n        &format!(\"{}.to_string_base_upper(u8)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_8::<T, u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_string\", &mut |(x, base)| {\n                no_out!(x.to_string_base_upper(base));\n            }),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{:#}\", BaseFmtWrapper::new(x, base)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_string_base_upper_algorithms_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    run_benchmark(\n        &format!(\"{}.to_string_base_upper(u8)\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_unsigned_pair_gen_var_5::<T, u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_string\", &mut |(x, base)| {\n                no_out!(x.to_string_base(base));\n            }),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{}\", BaseFmtWrapper::new(x, base)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_base_fmt_wrapper_fmt_with_width_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    run_benchmark(\n        &format!(\n            \"format!(\\\"{{:0usize}}\\\", BaseFmtWrapper::new({}, u8))\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_6::<T, u8, usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:0width$}\",\n                BaseFmtWrapper::new(x, base),\n                width = width\n            ));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_base_fmt_wrapper_fmt_with_width_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    run_benchmark(\n        &format!(\n            \"format!(\\\"{{:0usize}}\\\", BaseFmtWrapper::new({}, u8))\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_unsigned_unsigned_triple_gen_var_3::<T, u8, usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:0width$}\",\n                BaseFmtWrapper::new(x, base),\n                width = width\n            ));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_base_fmt_wrapper_fmt_upper_with_width_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    run_benchmark(\n        &format!(\n            \"format!(\\\"{{:#0usize}}\\\", BaseFmtWrapper::new({}, u8))\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_6::<T, u8, usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:#0width$}\",\n                BaseFmtWrapper::new(x, base),\n                width = width\n            ));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_base_fmt_wrapper_fmt_upper_with_width_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BaseFmtWrapper<T>: Display,\n{\n    run_benchmark(\n        &format!(\n            \"format!(\\\"{{:#0usize}}\\\", BaseFmtWrapper::new({}, u8))\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        signed_unsigned_unsigned_triple_gen_var_3::<T, u8, usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:#0width$}\",\n                BaseFmtWrapper::new(x, base),\n                width = width\n            ));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/factor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::factorization::traits::Factor;\nuse malachite_base::test_util::bench::bucketers::primitive_int_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_1;\nuse malachite_base::test_util::num::factorization::factor::factor_naive;\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Write;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_u8_factor);\n    register_demo!(runner, demo_u16_factor);\n    register_demo!(runner, demo_u32_factor);\n    register_demo!(runner, demo_u64_factor);\n    register_demo!(runner, demo_usize_factor);\n\n    register_bench!(runner, benchmark_u8_factor_algorithms);\n    register_bench!(runner, benchmark_u16_factor_algorithms);\n    register_bench!(runner, benchmark_u32_factor);\n    register_bench!(runner, benchmark_u32_factor_algorithms);\n    register_bench!(runner, benchmark_u64_factor);\n    register_bench!(runner, benchmark_u64_factor_algorithms);\n    register_bench!(runner, benchmark_usize_factor_algorithms);\n}\n\nfn demo_factor_helper<T: Factor + PrimitiveUnsigned>(u: T)\nwhere\n    <T as Factor>::FACTORS: IntoIterator<Item = (T, u8)>,\n{\n    let mut s = String::new();\n    for (p, e) in u.factor() {\n        if !s.is_empty() {\n            write!(s, \"×\").ok();\n        }\n        if e == 1 {\n            write!(s, \"{p}\").ok();\n        } else {\n            write!(s, \"{p}^{e}\").ok();\n        }\n    }\n    if s.is_empty() {\n        s = \"1\".to_string();\n    }\n    println!(\"factor({u}) = {s}\");\n}\n\nfn demo_u8_factor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_1::<u8>().get(gm, config).take(limit) {\n        demo_factor_helper(u);\n    }\n}\n\nfn demo_u16_factor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_1::<u16>().get(gm, config).take(limit) {\n        demo_factor_helper(u);\n    }\n}\n\nfn demo_u32_factor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_1::<u32>().get(gm, config).take(limit) {\n        demo_factor_helper(u);\n    }\n}\n\nfn demo_u64_factor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_1::<u64>().get(gm, config).take(limit) {\n        demo_factor_helper(u);\n    }\n}\n\nfn demo_usize_factor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_1::<usize>().get(gm, config).take(limit) {\n        demo_factor_helper(u);\n    }\n}\n\nfn benchmark_u8_factor_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u8.factor()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| {\n                let fs = u.factor();\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n            (\"naive\", &mut |u| {\n                let fs = factor_naive(u);\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n        ],\n    );\n}\n\nfn benchmark_u16_factor_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u16.factor()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<u16>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| {\n                let fs = u.factor();\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n            (\"naive\", &mut |u| {\n                let fs = factor_naive(u);\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n        ],\n    );\n}\n\nfn benchmark_u32_factor(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u32.factor()\",\n        BenchmarkType::Single,\n        unsigned_gen_var_1::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| {\n            let fs = u.factor();\n            unsafe {\n                std::ptr::read_volatile(&fs);\n            }\n        })],\n    );\n}\n\nfn benchmark_u32_factor_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u32.factor()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| {\n                let fs = u.factor();\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n            (\"naive\", &mut |u| {\n                let fs = factor_naive(u);\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n        ],\n    );\n}\n\nfn benchmark_u64_factor(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u64.factor()\",\n        BenchmarkType::Single,\n        unsigned_gen_var_1::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| {\n            let fs = u.factor();\n            unsafe {\n                std::ptr::read_volatile(&fs);\n            }\n        })],\n    );\n}\n\nfn benchmark_u64_factor_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u64.factor()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| {\n                let fs = u.factor();\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n            (\"naive\", &mut |u| {\n                let fs = factor_naive(u);\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n        ],\n    );\n}\n\nfn benchmark_usize_factor_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"usize.factor()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_1::<usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| {\n                let fs = u.factor();\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n            (\"naive\", &mut |u| {\n                let fs = factor_naive(u);\n                unsafe {\n                    std::ptr::read_volatile(&fs);\n                }\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/is_power.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_express_as_power_unsigned);\n    register_signed_demos!(runner, demo_express_as_power_signed);\n    register_unsigned_demos!(runner, demo_is_power_unsigned);\n    register_signed_demos!(runner, demo_is_power_signed);\n\n    register_unsigned_benches!(runner, benchmark_express_as_power_unsigned);\n    register_signed_benches!(runner, benchmark_express_as_power_signed);\n    register_unsigned_benches!(runner, benchmark_is_power_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_is_power_signed_algorithms);\n}\n\nfn demo_express_as_power_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.express_as_power() = {:?}\", u, u.express_as_power());\n    }\n}\n\nfn demo_express_as_power_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"({}).express_as_power() = {:?}\", i, i.express_as_power());\n    }\n}\n\nfn demo_is_power_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        if u.is_power() {\n            println!(\"{u} is a perfect power\");\n        } else {\n            println!(\"{u} is not a perfect power\");\n        }\n    }\n}\n\nfn demo_is_power_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        if i.is_power() {\n            println!(\"{i} is a perfect power\");\n        } else {\n            println!(\"{i} is not a perfect power\");\n        }\n    }\n}\n\nfn benchmark_express_as_power_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.express_as_power()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.express_as_power()))],\n    );\n}\n\nfn benchmark_express_as_power_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.express_as_power()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |i| no_out!(i.express_as_power()))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_is_power_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_power()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |u| no_out!(u.is_power())),\n            (\"using express_as_power\", &mut |u| {\n                no_out!(u.express_as_power().is_some());\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_is_power_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_power()\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |i| no_out!(i.is_power())),\n            (\"using express_as_power\", &mut |i| {\n                no_out!(i.express_as_power().is_some());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/is_prime.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::factorization::traits::IsPrime;\nuse malachite_base::test_util::bench::bucketers::primitive_int_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_base::test_util::num::factorization::is_prime::is_prime_naive;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_u8_is_prime);\n    register_demo!(runner, demo_u16_is_prime);\n    register_demo!(runner, demo_u32_is_prime);\n    register_demo!(runner, demo_u64_is_prime);\n    register_demo!(runner, demo_usize_is_prime);\n\n    register_bench!(runner, benchmark_u8_is_prime_algorithms);\n    register_bench!(runner, benchmark_u16_is_prime_algorithms);\n    register_bench!(runner, benchmark_u32_is_prime);\n    register_bench!(runner, benchmark_u32_is_prime_algorithms);\n    register_bench!(runner, benchmark_u64_is_prime);\n    register_bench!(runner, benchmark_u64_is_prime_algorithms);\n    register_bench!(runner, benchmark_usize_is_prime_algorithms);\n}\n\nfn demo_u8_is_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<u8>().get(gm, config).take(limit) {\n        if u.is_prime() {\n            println!(\"{u} is prime\");\n        } else {\n            println!(\"{u} is not prime\");\n        }\n    }\n}\n\nfn demo_u16_is_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<u16>().get(gm, config).take(limit) {\n        if u.is_prime() {\n            println!(\"{u} is prime\");\n        } else {\n            println!(\"{u} is not prime\");\n        }\n    }\n}\n\nfn demo_u32_is_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<u32>().get(gm, config).take(limit) {\n        if u.is_prime() {\n            println!(\"{u} is prime\");\n        } else {\n            println!(\"{u} is not prime\");\n        }\n    }\n}\n\nfn demo_u64_is_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<u64>().get(gm, config).take(limit) {\n        if u.is_prime() {\n            println!(\"{u} is prime\");\n        } else {\n            println!(\"{u} is not prime\");\n        }\n    }\n}\n\nfn demo_usize_is_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<usize>().get(gm, config).take(limit) {\n        if u.is_prime() {\n            println!(\"{u} is prime\");\n        } else {\n            println!(\"{u} is not prime\");\n        }\n    }\n}\n\nfn benchmark_u8_is_prime_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u8.is_prime()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| no_out!(u.is_prime())),\n            (\"naive\", &mut |u| no_out!(is_prime_naive(u))),\n        ],\n    );\n}\n\nfn benchmark_u16_is_prime_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u16.is_prime()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen::<u16>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| no_out!(u.is_prime())),\n            (\"naive\", &mut |u| no_out!(is_prime_naive(u))),\n        ],\n    );\n}\n\nfn benchmark_u32_is_prime(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u32.is_prime()\",\n        BenchmarkType::Single,\n        unsigned_gen::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| {\n            let b = u.is_prime();\n            unsafe {\n                std::ptr::read_volatile(&b);\n            }\n        })],\n    );\n}\n\nfn benchmark_u32_is_prime_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32.is_prime()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| {\n                let b = u.is_prime();\n                unsafe {\n                    std::ptr::read_volatile(&b);\n                }\n            }),\n            (\"naive\", &mut |u| {\n                let b = is_prime_naive(u);\n                unsafe {\n                    std::ptr::read_volatile(&b);\n                }\n            }),\n        ],\n    );\n}\n\nfn benchmark_u64_is_prime(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"u64.is_prime()\",\n        BenchmarkType::Single,\n        unsigned_gen::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| {\n            let b = u.is_prime();\n            unsafe {\n                std::ptr::read_volatile(&b);\n            }\n        })],\n    );\n}\n\nfn benchmark_u64_is_prime_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64.is_prime()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| {\n                let b = u.is_prime();\n                unsafe {\n                    std::ptr::read_volatile(&b);\n                }\n            }),\n            (\"naive\", &mut |u| {\n                let b = is_prime_naive(u);\n                unsafe {\n                    std::ptr::read_volatile(&b);\n                }\n            }),\n        ],\n    );\n}\n\nfn benchmark_usize_is_prime_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"usize.is_prime()\",\n        BenchmarkType::Algorithms,\n        unsigned_gen::<usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| no_out!(u.is_prime())),\n            (\"naive\", &mut |u| no_out!(is_prime_naive(u))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/is_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_is_square_unsigned);\n    register_signed_demos!(runner, demo_is_square_signed);\n\n    register_unsigned_benches!(runner, benchmark_is_square_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_is_square_signed_algorithms);\n}\n\nfn demo_is_square_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        if u.is_square() {\n            println!(\"{u} is a perfect square\");\n        } else {\n            println!(\"{u} is not a perfect square\");\n        }\n    }\n}\n\nfn demo_is_square_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        if i.is_square() {\n            println!(\"{i} is a perfect square\");\n        } else {\n            println!(\"{i} is not a perfect square\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_is_square_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_square()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |u| no_out!(u.is_square())),\n            (\"naive\", &mut |u| no_out!(u.checked_sqrt().is_some())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_is_square_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_square()\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"default\", &mut |i| no_out!(i.is_square())),\n            (\"naive\", &mut |i| no_out!(i.checked_sqrt().is_some())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    factor::register(runner);\n    is_power::register(runner);\n    is_prime::register(runner);\n    is_square::register(runner);\n    primes::register(runner);\n    prime_sieve::register(runner);\n    primitive_root_prime::register(runner);\n}\n\nmod factor;\nmod is_power;\nmod is_prime;\nmod is_square;\nmod prime_sieve;\nmod primes;\nmod primitive_root_prime;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/prime_sieve.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::factorization::prime_sieve::{\n    limbs_prime_sieve_size, limbs_prime_sieve_u32, limbs_prime_sieve_u64,\n};\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_26;\nuse malachite_base::test_util::num::factorization::prime_sieve::{\n    limbs_prime_sieve_naive_1, limbs_prime_sieve_naive_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_prime_sieve_u32);\n    register_demo!(runner, demo_limbs_prime_sieve_u64);\n    register_bench!(runner, benchmark_limbs_prime_sieve_u32_algorithms);\n    register_bench!(runner, benchmark_limbs_prime_sieve_u64_algorithms);\n}\n\nfn demo_limbs_prime_sieve_u32(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_26().get(gm, config).take(limit) {\n        let len = limbs_prime_sieve_size::<u32>(n);\n        let mut sieve = vec![0; len];\n        limbs_prime_sieve_u32(&mut sieve, n);\n        print!(\"limbs_prime_sieve_u32({n}): \");\n        let mut first = true;\n        for s in sieve {\n            if first {\n                first = false;\n            } else {\n                print!(\", \");\n            }\n            print!(\"{s:b}\");\n        }\n        println!();\n    }\n}\n\nfn demo_limbs_prime_sieve_u64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_26().get(gm, config).take(limit) {\n        let len = limbs_prime_sieve_size::<u64>(n);\n        let mut sieve = vec![0; len];\n        limbs_prime_sieve_u64(&mut sieve, n);\n        print!(\"limbs_prime_sieve_u64({n}): \");\n        let mut first = true;\n        for s in sieve {\n            if first {\n                first = false;\n            } else {\n                print!(\", \");\n            }\n            print!(\"{s:b}\");\n        }\n        println!();\n    }\n}\n\nfn benchmark_limbs_prime_sieve_u32_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_prime_sieve_u32(&mut [Limb], u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_26().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| {\n                let len = limbs_prime_sieve_size::<u32>(n);\n                let mut sieve = vec![0; len];\n                limbs_prime_sieve_u32(&mut sieve, n);\n            }),\n            (\"test each prime separately\", &mut |n| {\n                let len = limbs_prime_sieve_size::<u32>(n);\n                let mut sieve = vec![0; len];\n                limbs_prime_sieve_naive_1::<u32>(&mut sieve, n);\n            }),\n            (\"naive sieve\", &mut |n| {\n                let len = limbs_prime_sieve_size::<u32>(n);\n                let mut sieve = vec![0; len];\n                limbs_prime_sieve_naive_2::<u32>(&mut sieve, n);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_prime_sieve_u64_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_prime_sieve_u64(&mut [Limb], u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_26().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| {\n                let len = limbs_prime_sieve_size::<u64>(n);\n                let mut sieve = vec![0; len];\n                limbs_prime_sieve_u64(&mut sieve, n);\n            }),\n            (\"test each prime separately\", &mut |n| {\n                let len = limbs_prime_sieve_size::<u64>(n);\n                let mut sieve = vec![0; len];\n                limbs_prime_sieve_naive_1::<u64>(&mut sieve, n);\n            }),\n            (\"naive sieve\", &mut |n| {\n                let len = limbs_prime_sieve_size::<u64>(n);\n                let mut sieve = vec![0; len];\n                limbs_prime_sieve_naive_2::<u64>(&mut sieve, n);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/primes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::factorization::primes::{\n    prime_indicator_sequence, prime_indicator_sequence_less_than,\n    prime_indicator_sequence_less_than_or_equal_to,\n};\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_5, unsigned_pair_gen_var_28, unsigned_triple_gen_var_24,\n};\nuse malachite_base::test_util::num::factorization::primes::primes_naive;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_primes_less_than);\n    register_unsigned_demos!(runner, demo_primes_less_than_or_equal_to);\n    register_unsigned_demos!(runner, demo_primes);\n    register_demo!(runner, demo_prime_indicator_sequence_less_than);\n    register_demo!(runner, demo_prime_indicator_sequence_less_than_or_equal_to);\n    register_demo!(runner, demo_prime_indicator_sequence);\n    runner.register_demo(\n        \"demo_primes_less_than_jump_after_u8\",\n        &demo_primes_less_than_jump_after::<u8>,\n    );\n    runner.register_demo(\n        \"demo_primes_less_than_jump_after_u16\",\n        &demo_primes_less_than_jump_after::<u16>,\n    );\n    runner.register_demo(\n        \"demo_primes_less_than_jump_after_u32\",\n        &demo_primes_less_than_jump_after::<u32>,\n    );\n    runner.register_demo(\n        \"demo_primes_less_than_jump_after_u64\",\n        &demo_primes_less_than_jump_after::<u64>,\n    );\n    runner.register_demo(\n        \"demo_primes_less_than_jump_after_u128\",\n        &demo_primes_less_than_jump_after::<u128>,\n    );\n    runner.register_demo(\n        \"demo_primes_less_than_jump_after_usize\",\n        &demo_primes_less_than_jump_after::<usize>,\n    );\n    runner.register_demo(\"demo_primes_jump_after_u8\", &demo_primes_jump_after::<u8>);\n    runner.register_demo(\"demo_primes_jump_after_u16\", &demo_primes_jump_after::<u16>);\n    runner.register_demo(\"demo_primes_jump_after_u32\", &demo_primes_jump_after::<u32>);\n    runner.register_demo(\"demo_primes_jump_after_u64\", &demo_primes_jump_after::<u64>);\n    runner.register_demo(\n        \"demo_primes_jump_after_u128\",\n        &demo_primes_jump_after::<u128>,\n    );\n    runner.register_demo(\n        \"demo_primes_jump_after_usize\",\n        &demo_primes_jump_after::<usize>,\n    );\n\n    register_unsigned_benches!(runner, benchmark_primes_less_than_algorithms);\n    register_unsigned_benches!(runner, benchmark_primes_less_than_algorithms_2);\n    register_unsigned_benches!(runner, benchmark_primes_less_than_or_equal_to_algorithms);\n    register_unsigned_benches!(runner, benchmark_primes_less_than_or_equal_to_algorithms_2);\n    register_bench!(runner, benchmark_prime_indicator_sequence_less_than);\n    register_bench!(\n        runner,\n        benchmark_prime_indicator_sequence_less_than_or_equal_to\n    );\n}\n\nfn demo_primes_less_than<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_5::<T>().get(gm, config).take(limit) {\n        println!(\n            \"primes_less_than({}) = {:?}\",\n            n,\n            T::primes_less_than(&n).collect_vec()\n        );\n    }\n}\n\nfn demo_primes_less_than_or_equal_to<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen_var_5::<T>().get(gm, config).take(limit) {\n        println!(\n            \"primes_less_than_or_equal_to({}) = {:?}\",\n            n,\n            T::primes_less_than_or_equal_to(&n).collect_vec()\n        );\n    }\n}\n\nfn demo_primes<T: PrimitiveUnsigned>(_gm: GenMode, _config: &GenConfig, limit: usize) {\n    for p in T::primes().take(limit) {\n        println!(\"{p}\");\n    }\n}\n\nfn demo_prime_indicator_sequence_less_than(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\n            \"prime_indicator_sequence_less_than({}) = {:?}\",\n            n,\n            prime_indicator_sequence_less_than(n).collect_vec()\n        );\n    }\n}\n\nfn demo_prime_indicator_sequence_less_than_or_equal_to(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\n            \"prime_indicator_sequence_less_than_or_equal_to({}) = {:?}\",\n            n,\n            prime_indicator_sequence_less_than_or_equal_to(n).collect_vec()\n        );\n    }\n}\n\nfn demo_prime_indicator_sequence(_gm: GenMode, _config: &GenConfig, limit: usize) {\n    for b in prime_indicator_sequence().take(limit) {\n        println!(\"{b}\");\n    }\n}\n\nfn demo_primes_less_than_jump_after<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    let mut config = config.clone();\n    config.insert(\"mean_small_n\", 10000);\n    for (size, jump, skip) in unsigned_triple_gen_var_24::<T, usize>()\n        .get(gm, &config)\n        .take(limit)\n    {\n        let mut ps = T::primes_less_than(&size);\n        for _ in 0..skip {\n            ps.next();\n        }\n        if ps.jump_after(jump) {\n            let next = ps.next().unwrap();\n            println!(\n                \"Created iterator less than {size}, skipped {skip}, jumped after {jump}, \\\n                then returned {next}\"\n            );\n        } else {\n            println!(\n                \"Created iterator less than {size}, skipped {skip}, and jumped after {jump}, \\\n                which was too far\"\n            );\n        }\n    }\n}\n\nfn demo_primes_jump_after<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    let mut config = config.clone();\n    config.insert(\"mean_small_n\", 10000);\n    for (jump, skip) in unsigned_pair_gen_var_28::<T, usize>()\n        .get(gm, &config)\n        .take(limit)\n    {\n        let mut ps = T::primes();\n        for _ in 0..skip {\n            ps.next();\n        }\n        if ps.jump_after(jump) {\n            let next = ps.next().unwrap();\n            println!(\"Created iterator, skipped {skip}, jumped after {jump}, then returned {next}\");\n        } else {\n            println!(\n                \"Created iterator, skipped {skip}, and jumped after {jump}, which was too far\"\n            );\n        }\n    }\n}\n\nfn benchmark_primes_less_than_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}::primes_less_than({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(T::primes_less_than(&n).count())),\n            (\"using primes\", &mut |n| {\n                no_out!(T::primes().take_while(|&p| p < n).count());\n            }),\n            (\"naive\", &mut |n| {\n                no_out!(primes_naive::<T>().take_while(|&p| p < n).count());\n            }),\n        ],\n    );\n}\n\nfn benchmark_primes_less_than_algorithms_2<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}::primes_less_than(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(T::primes_less_than(&n).count())),\n            (\"using primes\", &mut |n| {\n                no_out!(T::primes().take_while(|&p| p < n).count());\n            }),\n        ],\n    );\n}\n\nfn benchmark_primes_less_than_or_equal_to_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}::primes_less_than_or_equal_to(&{})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| {\n                no_out!(T::primes_less_than_or_equal_to(&n).count());\n            }),\n            (\"using primes\", &mut |n| {\n                no_out!(T::primes().take_while(|&p| p <= n).count());\n            }),\n            (\"naive\", &mut |n| {\n                no_out!(primes_naive::<T>().take_while(|&p| p <= n).count());\n            }),\n        ],\n    );\n}\n\nfn benchmark_primes_less_than_or_equal_to_algorithms_2<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    usize: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}::primes_less_than_or_equal_to({})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| {\n                no_out!(T::primes_less_than_or_equal_to(&n).count());\n            }),\n            (\"using primes\", &mut |n| {\n                no_out!(T::primes().take_while(|&p| p <= n).count());\n            }),\n        ],\n    );\n}\n\nfn benchmark_prime_indicator_sequence_less_than(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"prime_indicator_sequence_less_than(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(prime_indicator_sequence_less_than(n).count());\n        })],\n    );\n}\n\nfn benchmark_prime_indicator_sequence_less_than_or_equal_to(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"prime_indicator_sequence_less_than_or_equal_to(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(prime_indicator_sequence_less_than_or_equal_to(n).count());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/factorization/primitive_root_prime.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::factorization::traits::PrimitiveRootPrime;\nuse malachite_base::test_util::bench::bucketers::primitive_int_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_29;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_u8_primitive_root_prime);\n    register_demo!(runner, demo_u16_primitive_root_prime);\n    register_demo!(runner, demo_u32_primitive_root_prime);\n    register_demo!(runner, demo_u64_primitive_root_prime);\n    register_demo!(runner, demo_usize_primitive_root_prime);\n\n    register_bench!(runner, benchmark_u8_primitive_root_prime);\n    register_bench!(runner, benchmark_u16_primitive_root_prime);\n    register_bench!(runner, benchmark_u32_primitive_root_prime);\n    register_bench!(runner, benchmark_u64_primitive_root_prime);\n    register_bench!(runner, benchmark_usize_primitive_root_prime);\n}\n\nfn demo_u8_primitive_root_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_29::<u8>().get(gm, config).take(limit) {\n        println!(\"primitive_root_prime({}) = {}\", u, u.primitive_root_prime());\n    }\n}\n\nfn demo_u16_primitive_root_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_29::<u16>().get(gm, config).take(limit) {\n        println!(\"primitive_root_prime({}) = {}\", u, u.primitive_root_prime());\n    }\n}\n\nfn demo_u32_primitive_root_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_29::<u32>().get(gm, config).take(limit) {\n        println!(\"primitive_root_prime({}) = {}\", u, u.primitive_root_prime());\n    }\n}\n\nfn demo_u64_primitive_root_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_29::<u64>().get(gm, config).take(limit) {\n        println!(\"primitive_root_prime({}) = {}\", u, u.primitive_root_prime());\n    }\n}\n\nfn demo_usize_primitive_root_prime(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen_var_29::<usize>().get(gm, config).take(limit) {\n        println!(\"primitive_root_prime({}) = {}\", u, u.primitive_root_prime());\n    }\n}\n\nfn benchmark_u8_primitive_root_prime(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u8.primitive_root_prime()\",\n        BenchmarkType::Single,\n        unsigned_gen_var_29::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.primitive_root_prime()))],\n    );\n}\n\nfn benchmark_u16_primitive_root_prime(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u16.primitive_root_prime()\",\n        BenchmarkType::Single,\n        unsigned_gen_var_29::<u16>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.primitive_root_prime()))],\n    );\n}\n\nfn benchmark_u32_primitive_root_prime(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32.primitive_root_prime()\",\n        BenchmarkType::Single,\n        unsigned_gen_var_29::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.primitive_root_prime()))],\n    );\n}\n\nfn benchmark_u64_primitive_root_prime(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64.primitive_root_prime()\",\n        BenchmarkType::Single,\n        unsigned_gen_var_29::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.primitive_root_prime()))],\n    );\n}\n\nfn benchmark_usize_primitive_root_prime(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"usize.primitive_root_prime()\",\n        BenchmarkType::Single,\n        unsigned_gen_var_29::<usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(u.primitive_root_prime()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/abs_negative_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_abs_negative_zero);\n    register_primitive_float_demos!(runner, demo_abs_negative_zero_assign);\n    register_primitive_float_benches!(runner, benchmark_abs_negative_zero);\n    register_primitive_float_benches!(runner, benchmark_abs_negative_zero_assign);\n}\n\nfn demo_abs_negative_zero<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"abs_negative_zero({}) = {}\",\n            NiceFloat(x),\n            NiceFloat(x.abs_negative_zero())\n        );\n    }\n}\n\nfn demo_abs_negative_zero_assign<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let old_x = x;\n        x.abs_negative_zero_assign();\n        println!(\n            \"x := {}; x.abs_negative_zero_assign(); x = {}\",\n            NiceFloat(old_x),\n            NiceFloat(x)\n        );\n    }\n}\n\nfn benchmark_abs_negative_zero<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.abs_negative_zero()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.abs_negative_zero()))],\n    );\n}\n\nfn benchmark_abs_negative_zero_assign<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.abs_negative_zero_assign()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |mut x| {\n            no_out!(x.abs_negative_zero_assign());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/from_ordered_representation.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::unsigned_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_13;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_from_ordered_representation);\n    register_primitive_float_benches!(runner, benchmark_from_ordered_representation);\n}\n\nfn demo_from_ordered_representation<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in unsigned_gen_var_13::<T>().get(gm, config).take(limit) {\n        println!(\n            \"from_ordered_representation({}) = {}\",\n            x,\n            NiceFloat(T::from_ordered_representation(x))\n        );\n    }\n}\n\nfn benchmark_from_ordered_representation<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_ordered_representation(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_13::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(T::from_ordered_representation(x));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/is_negative_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_is_negative_zero);\n    register_primitive_float_benches!(runner, benchmark_is_negative_zero);\n}\n\nfn demo_is_negative_zero<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        if x.is_negative_zero() {\n            println!(\"{} is negative zero\", NiceFloat(x));\n        } else {\n            println!(\"{} is not negative zero\", NiceFloat(x));\n        }\n    }\n}\n\nfn benchmark_is_negative_zero<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.is_negative_zero()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_negative_zero()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/max_precision_for_sci_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::test_util::bench::bucketers::signed_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::signed_gen_var_11;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_max_precision_for_sci_exponent);\n    register_primitive_float_benches!(runner, benchmark_max_precision_for_sci_exponent);\n}\n\nfn demo_max_precision_for_sci_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for exp in signed_gen_var_11::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}.max_precision_for_sci_exponent() = {}\",\n            exp,\n            T::max_precision_for_sci_exponent(exp)\n        );\n    }\n}\n\nfn benchmark_max_precision_for_sci_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::max_precision_for_sci_exponent(i64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |exp| {\n            no_out!(T::max_precision_for_sci_exponent(exp));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    abs_negative_zero::register(runner);\n    from_ordered_representation::register(runner);\n    is_negative_zero::register(runner);\n    max_precision_for_sci_exponent::register(runner);\n    next_higher::register(runner);\n    next_lower::register(runner);\n    precision::register(runner);\n    to_ordered_representation::register(runner);\n}\n\nmod abs_negative_zero;\nmod from_ordered_representation;\nmod is_negative_zero;\nmod max_precision_for_sci_exponent;\nmod next_higher;\nmod next_lower;\nmod precision;\nmod to_ordered_representation;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/next_higher.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen_var_9;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_next_higher);\n    register_primitive_float_benches!(runner, benchmark_next_higher);\n}\n\nfn demo_next_higher<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen_var_9::<T>().get(gm, config).take(limit) {\n        println!(\n            \"next_higher({}) = {}\",\n            NiceFloat(x),\n            NiceFloat(x.next_higher())\n        );\n    }\n}\n\nfn benchmark_next_higher<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.next_higher()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_9::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.next_higher()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/next_lower.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen_var_10;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_next_lower);\n    register_primitive_float_benches!(runner, benchmark_next_lower);\n}\n\nfn demo_next_lower<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen_var_10::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"next_lower({}) = {}\",\n            NiceFloat(x),\n            NiceFloat(x.next_lower())\n        );\n    }\n}\n\nfn benchmark_next_lower<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.next_lower()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_10::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.next_lower()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen_var_12;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_precision);\n    register_primitive_float_benches!(runner, benchmark_precision);\n}\n\nfn demo_precision<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen_var_12::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"({}).precision() = {}\", NiceFloat(x), x.precision());\n    }\n}\n\nfn benchmark_precision<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.precision()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_12::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.precision()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/basic/to_ordered_representation.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen_var_11;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_to_ordered_representation);\n    register_primitive_float_benches!(runner, benchmark_to_ordered_representation);\n}\n\nfn demo_to_ordered_representation<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in primitive_float_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_ordered_representation({}) = {}\",\n            NiceFloat(x),\n            x.to_ordered_representation()\n        );\n    }\n}\n\nfn benchmark_to_ordered_representation<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_ordered_representation()\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_11::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.to_ordered_representation()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    basic::register(runner);\n    nice_float::register(runner);\n}\n\nmod basic;\nmod nice_float;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::pair_max_primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_base::test_util::runner::Runner;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_nice_float_cmp);\n\n    register_primitive_float_benches!(runner, benchmark_nice_float_cmp_algorithms);\n}\n\nfn demo_nice_float_cmp<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        match x.cmp(&y) {\n            Less => println!(\"{x} < {y}\"),\n            Equal => println!(\"{x} = {y}\"),\n            Greater => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_nice_float_cmp_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"NiceFloat<{}>.cmp(&NiceFloat<{}>)\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_primitive_float_bucketer(\"f\", \"g\"),\n        &mut [\n            (\"Malachite\", &mut |(x, y)| {\n                no_out!(NiceFloat(x).cmp(&NiceFloat(y)));\n            }),\n            (\"Rust default\", &mut |(x, y)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::OrdAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::pair_max_primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_base::test_util::runner::Runner;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_nice_float_cmp_abs);\n    register_primitive_float_benches!(runner, benchmark_nice_float_cmp_abs_algorithms);\n}\n\nfn demo_nice_float_cmp_abs<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        match x.cmp_abs(&y) {\n            Less => println!(\"|{x}| < |{y}|\"),\n            Equal => println!(\"|{x}| = |{y}|\"),\n            Greater => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_nice_float_cmp_abs_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"NiceFloat<{}>.cmp_abs(&NiceFloat<{}>)\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_primitive_float_bucketer(\"f\", \"g\"),\n        &mut [\n            (\"Malachite\", &mut |(x, y)| {\n                no_out!(NiceFloat(x).cmp_abs(&NiceFloat(y)));\n            }),\n            (\"without NiceFloat\", &mut |(x, y)| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(NiceFloat(x.abs()).cmp(&NiceFloat(y.abs())));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::pair_max_primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_nice_float_eq);\n    register_primitive_float_benches!(runner, benchmark_nice_float_eq_algorithms);\n}\n\nfn demo_nice_float_eq<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_nice_float_eq_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"NiceFloat<{}> == NiceFloat<{}>\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_primitive_float_bucketer(\"f\", \"g\"),\n        &mut [\n            (\"Malachite\", &mut |(x, y)| {\n                no_out!(NiceFloat(x) == NiceFloat(y));\n            }),\n            (\"Rust default\", &mut |(x, y)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::pair_max_primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_nice_float_eq_abs);\n    register_primitive_float_benches!(runner, benchmark_nice_float_eq_abs_algorithms);\n}\n\nfn demo_nice_float_eq_abs<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_nice_float_eq_abs_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"NiceFloat<{}>.eq_abs(&NiceFloat<{}>)\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_primitive_float_bucketer(\"f\", \"g\"),\n        &mut [\n            (\"Malachite\", &mut |(x, y)| {\n                no_out!(NiceFloat(x).eq_abs(&NiceFloat(y)));\n            }),\n            (\"without NiceFloat\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(NiceFloat(x.abs()) == NiceFloat(y.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_10};\nuse malachite_base::test_util::runner::Runner;\nuse std::fmt::Debug;\nuse std::str::FromStr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_nice_float_from_str);\n    register_primitive_float_demos!(runner, demo_nice_float_from_str_targeted);\n    register_primitive_float_benches!(runner, benchmark_nice_float_from_str);\n}\n\nfn demo_nice_float_from_str<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    <T as FromStr>::Err: Debug,\n{\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\n            \"NiceFloat::from_str({:?}) = {:?}\",\n            s,\n            NiceFloat::<T>::from_str(&s)\n        );\n    }\n}\n\nfn demo_nice_float_from_str_targeted<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    <T as FromStr>::Err: Debug,\n{\n    for s in string_gen_var_10().get(gm, config).take(limit) {\n        println!(\n            \"NiceFloat::from_str({:?}) = {:?}\",\n            s,\n            NiceFloat::<T>::from_str(&s)\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_nice_float_from_str<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"NiceFloat::<{}>::from_str(&str)\", T::NAME),\n        BenchmarkType::Single,\n        string_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(NiceFloat::<T>::from_str(&s)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::hash::hash;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_nice_float_hash);\n    register_primitive_float_benches!(runner, benchmark_nice_float_hash);\n}\n\nfn demo_nice_float_hash<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        let x = NiceFloat(x);\n        println!(\"hash({}) = {}\", x, hash(&x));\n    }\n}\n\nfn benchmark_nice_float_hash<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"hash(&NiceFloat<{}>())\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(hash(&NiceFloat(x))))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    cmp::register(runner);\n    cmp_abs::register(runner);\n    eq::register(runner);\n    eq_abs::register(runner);\n    from_str::register(runner);\n    hash::register(runner);\n    to_string::register(runner);\n}\n\nmod cmp;\nmod cmp_abs;\nmod eq;\nmod eq_abs;\nmod from_str;\nmod hash;\nmod to_string;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/float/nice_float/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_nice_float_to_string);\n    register_primitive_float_benches!(runner, benchmark_nice_float_to_string_algorithms);\n}\n\nfn demo_nice_float_to_string<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}\", NiceFloat(f));\n    }\n}\n\nfn benchmark_nice_float_to_string_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"NiceFloat::<{}>.to_string()\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"Malachite\", &mut |f| no_out!(NiceFloat(f).to_string())),\n            (\"Rust default\", &mut |f| no_out!(f.to_string())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_access/assign_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_bool_triple_gen_var_1, unsigned_unsigned_bool_triple_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_assign_bit_unsigned);\n    register_signed_demos!(runner, demo_assign_bit_signed);\n    register_unsigned_benches!(runner, benchmark_assign_bit_unsigned);\n    register_signed_benches!(runner, benchmark_assign_bit_signed);\n}\n\nfn demo_assign_bit_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index, bit) in unsigned_unsigned_bool_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n;\n        n.assign_bit(index, bit);\n        println!(\"x := {n_old}; x.assign_bit({index}, {bit}); x = {n}\");\n    }\n}\n\nfn demo_assign_bit_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index, bit) in signed_unsigned_bool_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n;\n        n.assign_bit(index, bit);\n        println!(\"x := {n_old}; x.assign_bit({index}, {bit}); x = {n}\");\n    }\n}\n\nfn benchmark_assign_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.assign_bit(u64, bool)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_unsigned_bool_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index, bit)| {\n            n.assign_bit(index, bit);\n        })],\n    );\n}\n\nfn benchmark_assign_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.assign_bit(u64, bool)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_bool_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index, bit)| {\n            n.assign_bit(index, bit);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_access/clear_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_4, unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_clear_bit_unsigned);\n    register_signed_demos!(runner, demo_clear_bit_signed);\n    register_unsigned_benches!(runner, benchmark_clear_bit_unsigned);\n    register_signed_benches!(runner, benchmark_clear_bit_signed);\n}\n\nfn demo_clear_bit_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n;\n        n.clear_bit(index);\n        println!(\"x := {n_old}; x.clear_bit({index}); x = {n}\");\n    }\n}\n\nfn demo_clear_bit_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in signed_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n;\n        n.clear_bit(index);\n        println!(\"x := {n_old}; x.clear_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_clear_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.clear_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.clear_bit(index))],\n    );\n}\n\nfn benchmark_clear_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.clear_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.clear_bit(index))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_access/flip_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_2, unsigned_pair_gen_var_3,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_flip_bit_unsigned);\n    register_signed_demos!(runner, demo_flip_bit_signed);\n    register_unsigned_benches!(runner, benchmark_flip_bit_unsigned);\n    register_signed_benches!(runner, benchmark_flip_bit_signed);\n}\n\nfn demo_flip_bit_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in unsigned_pair_gen_var_3::<T>().get(gm, config).take(limit) {\n        let n_old = n;\n        n.flip_bit(index);\n        println!(\"x := {n_old}; x.flip_bit({index}); x = {n}\");\n    }\n}\n\nfn demo_flip_bit_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in signed_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n;\n        n.flip_bit(index);\n        println!(\"x := {n_old}; x.flip_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_flip_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.flip_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.flip_bit(index))],\n    );\n}\n\nfn benchmark_flip_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.flip_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.flip_bit(index))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_access/get_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_get_bit_unsigned);\n    register_signed_demos!(runner, demo_get_bit_signed);\n    register_unsigned_benches!(runner, benchmark_get_bit_unsigned);\n    register_signed_benches!(runner, benchmark_get_bit_signed);\n}\n\nfn demo_get_bit_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, index) in unsigned_pair_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"get_bit({}, {}) = {}\", n, index, n.get_bit(index));\n    }\n}\n\nfn demo_get_bit_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, index) in signed_unsigned_pair_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"get_bit({}, {}) = {}\", n, index, n.get_bit(index));\n    }\n}\n\nfn benchmark_get_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.get_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(n, index)| no_out!(n.get_bit(index)))],\n    );\n}\n\nfn benchmark_get_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.get_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(n, index)| no_out!(n.get_bit(index)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_access/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    assign_bit::register(runner);\n    clear_bit::register(runner);\n    flip_bit::register(runner);\n    get_bit::register(runner);\n    set_bit::register(runner);\n}\n\nmod assign_bit;\nmod clear_bit;\nmod flip_bit;\nmod get_bit;\nmod set_bit;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_access/set_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_3, unsigned_pair_gen_var_3,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_set_bit_unsigned);\n    register_signed_demos!(runner, demo_set_bit_signed);\n    register_unsigned_benches!(runner, benchmark_set_bit_unsigned);\n    register_signed_benches!(runner, benchmark_set_bit_signed);\n}\n\nfn demo_set_bit_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in unsigned_pair_gen_var_3::<T>().get(gm, config).take(limit) {\n        let n_old = n;\n        n.set_bit(index);\n        println!(\"x := {n_old}; x.set_bit({index}); x = {n}\");\n    }\n}\n\nfn demo_set_bit_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in signed_unsigned_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n;\n        n.set_bit(index);\n        println!(\"x := {n_old}; x.set_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_set_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.set_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.set_bit(index))],\n    );\n}\n\nfn benchmark_set_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.set_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.set_bit(index))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_block_access/assign_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::bench::bucketers::assign_bits_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_unsigned_unsigned_quadruple_gen_var_1, unsigned_quadruple_gen_var_1,\n};\nuse malachite_base::test_util::num::logic::bit_block_access::assign_bits_naive;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_assign_bits_unsigned);\n    register_signed_unsigned_match_demos!(runner, demo_assign_bits_signed);\n    register_unsigned_benches!(runner, benchmark_assign_bits_algorithms_unsigned);\n    register_signed_unsigned_match_benches!(runner, benchmark_assign_bits_algorithms_signed);\n}\n\nfn demo_assign_bits_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    T::Bits: PrimitiveUnsigned,\n{\n    for (mut n, start, end, bits) in unsigned_quadruple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.assign_bits(start, end, &bits);\n        println!(\"n := {old_n}; n.assign_bits({start}, {end}, &{bits}); n = {n}\");\n    }\n}\n\nfn demo_assign_bits_signed<\n    T: BitBlockAccess<Bits = U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, start, end, bits) in signed_unsigned_unsigned_unsigned_quadruple_gen_var_1::<T, U>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n;\n        n.assign_bits(start, end, &bits);\n        println!(\"n := {old_n}; n.assign_bits({start}, {end}, &{bits}); n = {n}\");\n    }\n}\n\nfn benchmark_assign_bits_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    T::Bits: PrimitiveUnsigned,\n{\n    run_benchmark(\n        &format!(\"{}.assign_bits(u64, u64, {})\", T::NAME, T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_quadruple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &assign_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |(mut n, start, end, bits)| {\n                no_out!(n.assign_bits(start, end, &bits));\n            }),\n            (\"naive\", &mut |(mut n, start, end, bits)| {\n                no_out!(assign_bits_naive::<T, T::Bits>(&mut n, start, end, &bits));\n            }),\n        ],\n    );\n}\n\nfn benchmark_assign_bits_algorithms_signed<\n    T: BitBlockAccess<Bits = U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.assign_bits(u64, u64, {})\", T::NAME, U::NAME),\n        BenchmarkType::Algorithms,\n        signed_unsigned_unsigned_unsigned_quadruple_gen_var_1::<T, U>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &assign_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |(mut n, start, end, bits)| {\n                no_out!(n.assign_bits(start, end, &bits));\n            }),\n            (\"naive\", &mut |(mut n, start, end, bits)| {\n                no_out!(assign_bits_naive::<T, U>(&mut n, start, end, &bits));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_block_access/get_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::bench::bucketers::get_bits_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_unsigned_triple_gen_var_2, unsigned_triple_gen_var_5,\n};\nuse malachite_base::test_util::num::logic::bit_block_access::get_bits_naive;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_get_bits_unsigned);\n    register_unsigned_signed_match_demos!(runner, demo_get_bits_signed);\n    register_unsigned_benches!(runner, benchmark_get_bits_algorithms_unsigned);\n    register_unsigned_signed_match_benches!(runner, benchmark_get_bits_algorithms_signed);\n}\n\nfn demo_get_bits_unsigned<T: BitBlockAccess<Bits = T> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, start, end) in unsigned_triple_gen_var_5::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.get_bits({}, {}) = {}\",\n            n,\n            start,\n            end,\n            n.get_bits(start, end)\n        );\n    }\n}\n\nfn demo_get_bits_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    S::Bits: PrimitiveUnsigned,\n{\n    for (n, start, end) in signed_unsigned_unsigned_triple_gen_var_2::<U, S, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).get_bits({}, {}) = {}\",\n            n,\n            start,\n            end,\n            n.get_bits(start, end)\n        );\n    }\n}\n\nfn benchmark_get_bits_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.get_bits(u64, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_triple_gen_var_5::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &get_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |(n, start, end)| {\n                no_out!(n.get_bits(start, end));\n            }),\n            (\"naive\", &mut |(n, start, end)| {\n                no_out!(get_bits_naive::<T, T>(&n, start, end));\n            }),\n        ],\n    );\n}\n\nfn benchmark_get_bits_algorithms_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.get_bits(u64, u64)\", S::NAME),\n        BenchmarkType::Algorithms,\n        signed_unsigned_unsigned_triple_gen_var_2::<U, S, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &get_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |(n, start, end)| {\n                no_out!(n.get_bits(start, end));\n            }),\n            (\"naive\", &mut |(n, start, end)| {\n                no_out!(get_bits_naive::<S, U>(&n, start, end));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_block_access/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    assign_bits::register(runner);\n    get_bits::register(runner);\n}\n\nmod assign_bits;\nmod get_bits;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_convertible/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    bool_vec_gen_var_1, bool_vec_gen_var_2, bool_vec_gen_var_3, bool_vec_gen_var_4,\n};\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    from_bits_asc_alt, from_bits_asc_signed_naive, from_bits_asc_unsigned_naive, from_bits_desc_alt,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_from_bits_asc_unsigned);\n    register_signed_demos!(runner, demo_from_bits_asc_signed);\n    register_unsigned_demos!(runner, demo_from_bits_desc_unsigned);\n    register_signed_demos!(runner, demo_from_bits_desc_signed);\n\n    register_unsigned_benches!(runner, benchmark_from_bits_asc_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_from_bits_asc_algorithms_signed);\n    register_unsigned_benches!(runner, benchmark_from_bits_desc_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_from_bits_desc_algorithms_signed);\n}\n\nfn demo_from_bits_asc_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for bs in bool_vec_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_bits_asc({:?}) = {}\",\n            T::NAME,\n            bs,\n            T::from_bits_asc(bs.iter().copied())\n        );\n    }\n}\n\nfn demo_from_bits_asc_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bs in bool_vec_gen_var_2::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_bits_asc({:?}) = {}\",\n            T::NAME,\n            bs,\n            T::from_bits_asc(bs.iter().copied())\n        );\n    }\n}\n\nfn demo_from_bits_desc_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for bs in bool_vec_gen_var_3::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_bits_desc({:?}) = {}\",\n            T::NAME,\n            bs,\n            T::from_bits_desc(bs.iter().copied())\n        );\n    }\n}\n\nfn demo_from_bits_desc_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bs in bool_vec_gen_var_4::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::from_bits_desc({:?}) = {}\",\n            T::NAME,\n            bs,\n            T::from_bits_desc(bs.iter().copied())\n        );\n    }\n}\n\nfn benchmark_from_bits_asc_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_bits_asc<I: Iterator<Item=bool>>(I)\", T::NAME),\n        BenchmarkType::Algorithms,\n        bool_vec_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |ref bs| {\n                no_out!(T::from_bits_asc(bs.iter().copied()));\n            }),\n            (\"alt\", &mut |ref bs| {\n                no_out!(from_bits_asc_alt::<T, _>(bs.iter().copied()));\n            }),\n            (\"naive\", &mut |ref bs| {\n                no_out!(from_bits_asc_unsigned_naive::<T, _>(bs.iter().copied()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_bits_asc_algorithms_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_bits_asc<I: Iterator<Item=bool>>(I)\", T::NAME),\n        BenchmarkType::Algorithms,\n        bool_vec_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |ref bs| {\n                no_out!(T::from_bits_asc(bs.iter().copied()));\n            }),\n            (\"alt\", &mut |ref bs| {\n                no_out!(from_bits_asc_alt::<T, _>(bs.iter().copied()));\n            }),\n            (\"naive\", &mut |ref bs| {\n                no_out!(from_bits_asc_signed_naive::<T, _>(bs.iter().copied()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_bits_desc_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_bits_desc<I: Iterator<Item=bool>>(I)\", T::NAME),\n        BenchmarkType::Algorithms,\n        bool_vec_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |ref bs| {\n                no_out!(T::from_bits_desc(bs.iter().copied()));\n            }),\n            (\"alt\", &mut |ref bs| {\n                no_out!(from_bits_desc_alt::<T, _>(bs.iter().copied()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_bits_desc_algorithms_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::from_bits_desc<I: Iterator<Item=bool>>(I)\", T::NAME),\n        BenchmarkType::Algorithms,\n        bool_vec_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |ref bs| {\n                no_out!(T::from_bits_desc(bs.iter().copied()));\n            }),\n            (\"alt\", &mut |ref bs| {\n                no_out!(from_bits_desc_alt::<T, _>(bs.iter().copied()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_convertible/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_bits::register(runner);\n    to_bits::register(runner);\n}\n\nmod from_bits;\nmod to_bits;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_convertible/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    to_bits_asc_alt, to_bits_asc_signed_naive, to_bits_asc_unsigned_naive, to_bits_desc_alt,\n    to_bits_desc_signed_naive, to_bits_desc_unsigned_naive,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_to_bits_asc_unsigned);\n    register_signed_demos!(runner, demo_to_bits_asc_signed);\n    register_unsigned_demos!(runner, demo_to_bits_desc_unsigned);\n    register_signed_demos!(runner, demo_to_bits_desc_signed);\n\n    register_unsigned_benches!(runner, benchmark_to_bits_asc_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_to_bits_asc_algorithms_signed);\n    register_unsigned_benches!(runner, benchmark_to_bits_asc_evaluation_strategy_unsigned);\n    register_signed_benches!(runner, benchmark_to_bits_asc_evaluation_strategy_signed);\n    register_unsigned_benches!(runner, benchmark_to_bits_desc_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_to_bits_desc_algorithms_signed);\n    register_unsigned_benches!(runner, benchmark_to_bits_desc_evaluation_strategy_unsigned);\n    register_signed_benches!(runner, benchmark_to_bits_desc_evaluation_strategy_signed);\n}\n\nfn demo_to_bits_asc_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.to_bits_asc() = {:?}\", u, u.to_bits_asc());\n    }\n}\n\nfn demo_to_bits_asc_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.to_bits_asc() = {:?}\", i, i.to_bits_asc());\n    }\n}\n\nfn demo_to_bits_desc_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.to_bits_desc() = {:?}\", u, u.to_bits_desc());\n    }\n}\n\nfn demo_to_bits_desc_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"{}.to_bits_desc() = {:?}\", i, i.to_bits_desc());\n    }\n}\n\nfn benchmark_to_bits_asc_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_asc()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |u| no_out!(u.to_bits_asc())),\n            (\"alt\", &mut |u| no_out!(to_bits_asc_alt(&u))),\n            (\"naive\", &mut |u| no_out!(to_bits_asc_unsigned_naive(u))),\n        ],\n    );\n}\n\nfn benchmark_to_bits_asc_algorithms_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_asc()\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |i| no_out!(i.to_bits_asc())),\n            (\"alt\", &mut |i| no_out!(to_bits_asc_alt(&i))),\n            (\"naive\", &mut |i| no_out!(to_bits_asc_signed_naive(i))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_bits_asc_evaluation_strategy_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_asc()\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (&format!(\"{}.to_bits_asc()\", T::NAME), &mut |n| {\n                no_out!(n.to_bits_asc());\n            }),\n            (&format!(\"{}.bits().collect_vec()\", T::NAME), &mut |n| {\n                no_out!(n.bits().collect_vec());\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_bits_asc_evaluation_strategy_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_asc()\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (&format!(\"{}.to_bits_asc()\", T::NAME), &mut |n| {\n                no_out!(n.to_bits_asc());\n            }),\n            (&format!(\"{}.bits().collect_vec()\", T::NAME), &mut |n| {\n                no_out!(n.bits().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_to_bits_desc_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_desc()\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |u| no_out!(u.to_bits_desc())),\n            (\"alt\", &mut |u| no_out!(to_bits_desc_alt(&u))),\n            (\"naive\", &mut |u| no_out!(to_bits_desc_unsigned_naive(u))),\n        ],\n    );\n}\n\nfn benchmark_to_bits_desc_algorithms_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_desc()\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |i| no_out!(i.to_bits_desc())),\n            (\"alt\", &mut |i| no_out!(to_bits_desc_alt(&i))),\n            (\"naive\", &mut |i| no_out!(to_bits_desc_signed_naive(i))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_bits_desc_evaluation_strategy_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_desc()\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (&format!(\"{}.to_bits_desc()\", T::NAME), &mut |n| {\n                no_out!(n.to_bits_desc());\n            }),\n            (\n                &format!(\"{}.bits().rev().collect_vec()\", T::NAME),\n                &mut |n| no_out!(n.bits().rev().collect_vec()),\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_to_bits_desc_evaluation_strategy_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.to_bits_desc()\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (&format!(\"{}.to_bits_desc()\", T::NAME), &mut |n| {\n                no_out!(n.to_bits_desc());\n            }),\n            (\n                &format!(\"{}.bits().rev().collect_vec()\", T::NAME),\n                &mut |n| no_out!(n.bits().rev().collect_vec()),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen_var_1, unsigned_gen, unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse std::ops::Index;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_bits_unsigned);\n    register_signed_demos!(runner, demo_bits_signed);\n    register_unsigned_demos!(runner, demo_bits_rev_unsigned);\n    register_signed_demos!(runner, demo_bits_rev_signed);\n    register_unsigned_demos!(runner, demo_bits_size_hint_unsigned);\n    register_signed_demos!(runner, demo_bits_index_signed);\n\n    register_unsigned_benches!(runner, benchmark_bits_size_hint_unsigned);\n    register_unsigned_benches!(runner, benchmark_bits_get_algorithms_unsigned);\n    register_signed_benches!(runner, benchmark_bits_get_algorithms_signed);\n}\n\nfn demo_bits_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"bits({}) = {:?}\", u, u.bits().collect_vec());\n    }\n}\n\nfn demo_bits_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"bits({}) = {:?}\", i, i.bits().collect_vec());\n    }\n}\n\nfn demo_bits_rev_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"bits({}).rev() = {:?}\", u, u.bits().rev().collect_vec());\n    }\n}\n\nfn demo_bits_rev_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"bits({}).rev() = {:?}\", i, i.bits().rev().collect_vec());\n    }\n}\n\nfn demo_bits_size_hint_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"bits({}).size_hint() = {:?}\", u, u.bits().size_hint());\n    }\n}\n\nfn demo_bits_index_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    T::BitIterator: Index<u64, Output = bool>,\n{\n    for (n, i) in signed_unsigned_pair_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"bits({})[{}] = {:?}\", n, i, n.bits()[i]);\n    }\n}\n\nfn benchmark_bits_size_hint_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.bits().size_hint()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(&format!(\"{}.bits().size_hint()\", T::NAME), &mut |n| {\n            no_out!(n.bits().size_hint());\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_bits_get_algorithms_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    T::BitIterator: Index<u64, Output = bool>,\n{\n    run_benchmark(\n        &format!(\"{}.bits()[u64]\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"{}.bits()[u]\", T::NAME), &mut |(n, u)| {\n                no_out!(n.bits()[u]);\n            }),\n            (&format!(\"{}.to_bits_asc()[u]\", T::NAME), &mut |(n, u)| {\n                let bits = n.to_bits_asc();\n                let u = usize::exact_from(u);\n                if u >= bits.len() {\n                    n < T::ZERO\n                } else {\n                    bits[u]\n                };\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_bits_get_algorithms_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    T::BitIterator: Index<u64, Output = bool>,\n{\n    run_benchmark(\n        &format!(\"{}.bits()[u64]\", T::NAME),\n        BenchmarkType::Algorithms,\n        signed_unsigned_pair_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"{}.bits()[u]\", T::NAME), &mut |(n, u)| {\n                no_out!(n.bits()[u]);\n            }),\n            (&format!(\"{}.to_bits_asc()[u]\", T::NAME), &mut |(n, u)| {\n                let bits = n.to_bits_asc();\n                let u = usize::exact_from(u);\n                if u >= bits.len() {\n                    n < T::ZERO\n                } else {\n                    bits[u]\n                };\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_scan/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_index_of_next_false_bit_unsigned);\n    register_signed_demos!(runner, demo_index_of_next_false_bit_signed);\n    register_unsigned_benches!(runner, benchmark_index_of_next_false_bit_unsigned);\n    register_signed_benches!(runner, benchmark_index_of_next_false_bit_signed);\n}\n\nfn demo_index_of_next_false_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, start) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.index_of_next_false_bit({}) = {:?}\",\n            n,\n            start,\n            n.index_of_next_false_bit(start)\n        );\n    }\n}\n\nfn demo_index_of_next_false_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, start) in signed_unsigned_pair_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.index_of_next_false_bit({}) = {:?}\",\n            n,\n            start,\n            n.index_of_next_false_bit(start)\n        );\n    }\n}\n\nfn benchmark_index_of_next_false_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.index_of_next_false_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"start\"),\n        &mut [(\"Malachite\", &mut |(n, start)| {\n            no_out!(n.index_of_next_false_bit(start));\n        })],\n    );\n}\n\nfn benchmark_index_of_next_false_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.index_of_next_false_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(n, start)| {\n            no_out!(n.index_of_next_false_bit(start));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_scan/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_index_of_next_true_bit_unsigned);\n    register_signed_demos!(runner, demo_index_of_next_true_bit_signed);\n    register_unsigned_benches!(runner, benchmark_index_of_next_true_bit_unsigned);\n    register_signed_benches!(runner, benchmark_index_of_next_true_bit_signed);\n}\n\nfn demo_index_of_next_true_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, start) in unsigned_pair_gen_var_2::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.index_of_next_true_bit({}) = {:?}\",\n            n,\n            start,\n            n.index_of_next_true_bit(start)\n        );\n    }\n}\n\nfn demo_index_of_next_true_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, start) in signed_unsigned_pair_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.index_of_next_true_bit({}) = {:?}\",\n            n,\n            start,\n            n.index_of_next_true_bit(start)\n        );\n    }\n}\n\nfn benchmark_index_of_next_true_bit_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.index_of_next_true_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_2::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"start\"),\n        &mut [(\"Malachite\", &mut |(n, start)| {\n            no_out!(n.index_of_next_true_bit(start));\n        })],\n    );\n}\n\nfn benchmark_index_of_next_true_bit_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.index_of_next_true_bit(u64)\", T::NAME),\n        BenchmarkType::Single,\n        signed_unsigned_pair_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(n, start)| {\n            no_out!(n.index_of_next_true_bit(start));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/bit_scan/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    index_of_next_false_bit::register(runner);\n    index_of_next_true_bit::register(runner);\n}\n\nmod index_of_next_false_bit;\nmod index_of_next_true_bit;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/get_highest_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_get_highest_bit_unsigned);\n    register_signed_demos!(runner, demo_get_highest_bit_signed);\n    register_unsigned_benches!(runner, benchmark_get_highest_bit_unsigned);\n    register_signed_benches!(runner, benchmark_get_highest_bit_signed);\n}\n\nunsigned_single_arg_demo!(demo_get_highest_bit_unsigned, get_highest_bit);\nsigned_single_arg_demo!(demo_get_highest_bit_signed, get_highest_bit);\n\nunsigned_single_arg_bench!(benchmark_get_highest_bit_unsigned, get_highest_bit);\nsigned_single_arg_bench!(benchmark_get_highest_bit_signed, get_highest_bit);\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::pair_max_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_hamming_distance_unsigned);\n    register_signed_demos!(runner, demo_checked_hamming_distance_signed);\n    register_unsigned_benches!(runner, benchmark_hamming_distance_unsigned);\n    register_signed_benches!(runner, benchmark_checked_hamming_distance_signed);\n}\n\nfn demo_hamming_distance_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27::<T>().get(gm, config).take(limit) {\n        println!(\"{}.hamming_distance({}) = {}\", x, y, x.hamming_distance(y));\n    }\n}\n\nfn demo_checked_hamming_distance_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in signed_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"({}).checked_hamming_distance({}) = {:?}\",\n            x,\n            y,\n            x.checked_hamming_distance(y)\n        );\n    }\n}\n\nfn benchmark_hamming_distance_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.hamming_distance({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.hamming_distance(y)))],\n    );\n}\n\nfn benchmark_checked_hamming_distance_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.checked_hamming_distance({})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(x.checked_hamming_distance(y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::test_util::bench::bucketers::primitive_int_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_9;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_demos!(runner, demo_low_mask);\n    register_primitive_int_benches!(runner, benchmark_low_mask);\n}\n\nfn demo_low_mask<T: PrimitiveInt>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in unsigned_gen_var_9::<T>().get(gm, config).take(limit) {\n        println!(\"{}::low_mask({}) = {}\", T::NAME, bits, T::low_mask(bits));\n    }\n}\n\nfn benchmark_low_mask<T: PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.low_mask(u64)\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen_var_9::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_int_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |bits| no_out!(T::low_mask(bits)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    bit_access::register(runner);\n    bit_block_access::register(runner);\n    bit_convertible::register(runner);\n    bit_iterable::register(runner);\n    bit_scan::register(runner);\n    get_highest_bit::register(runner);\n    hamming_distance::register(runner);\n    low_mask::register(runner);\n    not_assign::register(runner);\n    significant_bits::register(runner);\n}\n\nmod bit_access;\nmod bit_block_access;\nmod bit_convertible;\nmod bit_iterable;\nmod bit_scan;\nmod get_highest_bit;\nmod hamming_distance;\nmod low_mask;\nmod not_assign;\nmod significant_bits;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/not_assign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_not_assign_unsigned);\n    register_signed_demos!(runner, demo_not_assign_signed);\n    register_unsigned_benches!(runner, benchmark_not_assign_unsigned);\n    register_signed_benches!(runner, benchmark_not_assign_signed);\n}\n\nfn demo_not_assign_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        let old_u = u;\n        u.not_assign();\n        println!(\"u := {old_u}; u.not_assign(); u = {u}\");\n    }\n}\n\nfn demo_not_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut i in signed_gen::<T>().get(gm, config).take(limit) {\n        let old_i = i;\n        i.not_assign();\n        println!(\"i := {old_i}; i.not_assign(); i = {i}\");\n    }\n}\n\nfn benchmark_not_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.not_assign()\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut u| u.not_assign())],\n    );\n}\n\nfn benchmark_not_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.not_assign()\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |mut i| i.not_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_significant_bits_unsigned);\n    register_signed_demos!(runner, demo_significant_bits_signed);\n    register_unsigned_benches!(runner, benchmark_significant_bits_unsigned);\n    register_signed_benches!(runner, benchmark_significant_bits_signed);\n}\n\nunsigned_single_arg_demo!(demo_significant_bits_unsigned, significant_bits);\nsigned_single_arg_demo!(demo_significant_bits_signed, significant_bits);\n\nunsigned_single_arg_bench!(benchmark_significant_bits_unsigned, significant_bits);\nsigned_single_arg_bench!(benchmark_significant_bits_signed, significant_bits);\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/num/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    arithmetic::register(runner);\n    comparison::register(runner);\n    conversion::register(runner);\n    factorization::register(runner);\n    float::register(runner);\n    logic::register(runner);\n}\n\nmod arithmetic;\nmod comparison;\nmod conversion;\nmod factorization;\nmod float;\nmod logic;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/access/get.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::pair_1_rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_rational_sequence_unsigned_pair_gen_var_1,\n    unsigned_rational_sequence_unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_get);\n    register_demo!(runner, demo_rational_sequence_index);\n\n    register_bench!(runner, benchmark_rational_sequence_get);\n    register_bench!(runner, benchmark_rational_sequence_index);\n}\n\nfn demo_rational_sequence_get(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, index) in unsigned_rational_sequence_unsigned_pair_gen_var_1::<u8, usize>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.get({}) = {:?}\", xs, index, xs.get(index));\n    }\n}\n\nfn demo_rational_sequence_index(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, index) in unsigned_rational_sequence_unsigned_pair_gen_var_2::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}[{}] = {}\", xs, index, xs[index]);\n    }\n}\n\nfn benchmark_rational_sequence_get(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"RationalSequence.get(usize)\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_unsigned_pair_gen_var_1::<u8, usize>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, index)| no_out!(xs.get(index)))],\n    );\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_rational_sequence_index(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence[usize]\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_unsigned_pair_gen_var_2::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, index)| no_out!(xs[index]))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/access/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    get::register(runner);\n    mutate::register(runner);\n}\n\nmod get;\nmod mutate;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/access/mutate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::quadruple_1_rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::large_type_gen_var_22;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_mutate);\n    register_bench!(runner, benchmark_rational_sequence_mutate);\n}\n\nfn demo_rational_sequence_mutate(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, index, y, z) in large_type_gen_var_22::<u8>().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let out = xs.mutate(index, |x| {\n            *x = y;\n            z\n        });\n        println!(\"xs := {xs_old}; xs.mutate({index}, |x| {{ *x = {y}; {z} }}) = {out}; xs = {xs}\");\n    }\n}\n\nfn benchmark_rational_sequence_mutate(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.mutate(usize, FnOnce(&mut T) -> U)\",\n        BenchmarkType::Single,\n        large_type_gen_var_22::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, index, y, z)| {\n            no_out!(xs.mutate(index, |x| {\n                *x = y;\n                z\n            }));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/basic/component_len.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_component_len);\n    register_bench!(runner, benchmark_rational_sequence_component_len);\n}\n\nfn demo_rational_sequence_component_len(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"component_len({}) = {}\", xs, xs.component_len());\n    }\n}\n\nfn benchmark_rational_sequence_component_len(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.component_len()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(xs.component_len()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/basic/is_empty.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_is_empty);\n    register_bench!(runner, benchmark_rational_sequence_is_empty);\n}\n\nfn demo_rational_sequence_is_empty(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if xs.is_empty() {\n            println!(\"{xs} is empty\");\n        } else {\n            println!(\"{xs} is not empty\");\n        }\n    }\n}\n\nfn benchmark_rational_sequence_is_empty(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.is_empty()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(xs.is_empty()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/basic/is_finite.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_is_finite);\n    register_bench!(runner, benchmark_rational_sequence_is_finite);\n}\n\nfn demo_rational_sequence_is_finite(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if xs.is_finite() {\n            println!(\"{xs} is finite\");\n        } else {\n            println!(\"{xs} is not finite\");\n        }\n    }\n}\n\nfn benchmark_rational_sequence_is_finite(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.is_finite()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(xs.is_finite()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/basic/iter.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::prefix_to_string;\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_iter);\n    register_bench!(runner, benchmark_rational_sequence_iter);\n}\n\nfn demo_rational_sequence_iter(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{} = {}\", xs, prefix_to_string(xs.iter(), 20));\n    }\n}\n\nfn benchmark_rational_sequence_iter(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.iter()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\n            \"RationalSequence.iter().take(20).collect_vec()\",\n            &mut |xs| no_out!(xs.iter().take(20).collect_vec()),\n        )],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/basic/len.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_len);\n    register_bench!(runner, benchmark_rational_sequence_len);\n}\n\nfn demo_rational_sequence_len(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"len({}) = {:?}\", xs, xs.len());\n    }\n}\n\nfn benchmark_rational_sequence_len(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"RationalSequence.len()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(xs.len()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/basic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    component_len::register(runner);\n    is_empty::register(runner);\n    is_finite::register(runner);\n    iter::register(runner);\n    len::register(runner);\n}\n\nmod component_len;\nmod is_empty;\nmod is_finite;\nmod iter;\nmod len;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::pair_rational_sequence_max_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_pair_gen;\nuse malachite_base::test_util::runner::Runner;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_cmp);\n    register_bench!(runner, benchmark_rational_sequence_cmp);\n}\n\nfn demo_rational_sequence_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_rational_sequence_pair_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match xs.cmp(&ys) {\n            Less => println!(\"{xs} < {ys}\"),\n            Equal => println!(\"{xs} = {ys}\"),\n            Greater => println!(\"{xs} > {ys}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_sequence_cmp(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"RationalSequence.cmp(&RationalSequence)\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_pair_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_sequence_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(xs.cmp(&ys)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::pair_rational_sequence_max_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_pair_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_eq);\n    register_bench!(runner, benchmark_rational_sequence_eq);\n}\n\nfn demo_rational_sequence_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_rational_sequence_pair_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if xs == ys {\n            println!(\"{xs} = {ys}\");\n        } else {\n            println!(\"{xs} ≠ {ys}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_sequence_eq(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"RationalSequence == RationalSequence\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_pair_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_sequence_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(xs == ys))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::hash::hash;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_hash);\n    register_bench!(runner, benchmark_rational_sequence_hash);\n}\n\nfn demo_rational_sequence_hash(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"hash({}) = {}\", xs, hash(&xs));\n    }\n}\n\nfn benchmark_rational_sequence_hash(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational hash\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(hash(&xs)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    cmp::register(runner);\n    eq::register(runner);\n    hash::register(runner);\n}\n\nmod cmp;\nmod eq;\nmod hash;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_rational_sequence_max_len_bucketer, rational_sequence_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_rational_sequence_gen, unsigned_rational_sequence_pair_gen,\n};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_clone);\n    register_demo!(runner, demo_rational_sequence_clone_from);\n    register_bench!(runner, benchmark_rational_sequence_clone);\n    register_bench!(runner, benchmark_rational_sequence_clone_from);\n}\n\nfn demo_rational_sequence_clone(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"clone({}) = {}\", xs, xs.clone());\n    }\n}\n\nfn demo_rational_sequence_clone_from(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_rational_sequence_pair_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        xs.clone_from(&ys);\n        println!(\"xs := {xs_old}; xs.clone_from({ys}); xs = {xs}\");\n    }\n}\n\n#[allow(clippy::redundant_clone, unused_must_use)]\nfn benchmark_rational_sequence_clone(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.clone()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(xs.clone()))],\n    );\n}\n\nfn benchmark_rational_sequence_clone_from(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.clone_from(&RationalSequence)\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_pair_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_sequence_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| xs.clone_from(&ys))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/conversion/from_vec.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_from_vec);\n    register_demo!(runner, demo_rational_sequence_from_slice);\n\n    register_bench!(\n        runner,\n        benchmark_rational_sequence_from_vec_evaluation_strategy\n    );\n}\n\nfn demo_rational_sequence_from_vec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen::<u8>().get(gm, config).take(limit) {\n        println!(\n            \"from_vec({:?}) = {}\",\n            xs.clone(),\n            RationalSequence::from_vec(xs)\n        );\n    }\n}\n\nfn demo_rational_sequence_from_slice(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen::<u8>().get(gm, config).take(limit) {\n        println!(\n            \"from_slice(&{:?}) = {}\",\n            xs,\n            RationalSequence::from_slice(&xs)\n        );\n    }\n}\n\nfn benchmark_rational_sequence_from_vec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence::from_vec(Vec<T>)\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"from_vec\", &mut |xs| {\n                no_out!(RationalSequence::from_vec(xs));\n            }),\n            (\"from_slice\", &mut |xs| {\n                no_out!(RationalSequence::from_slice(&xs));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/conversion/from_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::bench::bucketers::pair_sum_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_pair_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_from_vecs);\n    register_demo!(runner, demo_rational_sequence_from_slices);\n\n    register_bench!(\n        runner,\n        benchmark_rational_sequence_from_vecs_evaluation_strategy\n    );\n}\n\nfn demo_rational_sequence_from_vecs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen::<u8>().get(gm, config).take(limit) {\n        println!(\n            \"from_vecs({:?}, {:?}) = {}\",\n            xs.clone(),\n            ys.clone(),\n            RationalSequence::from_vecs(xs, ys)\n        );\n    }\n}\n\nfn demo_rational_sequence_from_slices(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen::<u8>().get(gm, config).take(limit) {\n        println!(\n            \"from_slices(&{:?}, &{:?}) = {}\",\n            xs,\n            ys,\n            RationalSequence::from_slices(&xs, &ys)\n        );\n    }\n}\n\nfn benchmark_rational_sequence_from_vecs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence::from_vecs(Vec<T>, Vec<T>)\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_pair_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"from_vecs\", &mut |(xs, ys)| {\n                no_out!(RationalSequence::from_vecs(xs, ys));\n            }),\n            (\"from_slices\", &mut |(xs, ys)| {\n                no_out!(RationalSequence::from_slices(&xs, &ys));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    clone::register(runner);\n    from_vec::register(runner);\n    from_vecs::register(runner);\n    to_vecs::register(runner);\n}\n\nmod clone;\nmod from_vec;\nmod from_vecs;\nmod to_vecs;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/conversion/to_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_to_vecs);\n    register_demo!(runner, demo_rational_sequence_into_vecs);\n    register_demo!(runner, demo_rational_sequence_slices_ref);\n\n    register_bench!(\n        runner,\n        benchmark_rational_sequence_to_vecs_evaluation_strategy\n    );\n}\n\nfn demo_rational_sequence_to_vecs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"to_vecs(&{}) = {:?}\", xs, xs.to_vecs());\n    }\n}\n\nfn demo_rational_sequence_into_vecs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"into_vecs({}) = {:?}\", xs.clone(), xs.into_vecs());\n    }\n}\n\nfn demo_rational_sequence_slices_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"slices_ref(&{}) = {:?}\", xs, xs.slices_ref());\n    }\n}\n\nfn benchmark_rational_sequence_to_vecs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.to_vecs()\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [\n            (\"to_vecs\", &mut |xs| no_out!(xs.to_vecs())),\n            (\"into_vecs\", &mut |xs| no_out!(xs.into_vecs())),\n            (\"slices_ref\", &mut |xs| no_out!(xs.slices_ref())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    access::register(runner);\n    basic::register(runner);\n    comparison::register(runner);\n    conversion::register(runner);\n    to_string::register(runner);\n}\n\nmod access;\nmod basic;\nmod comparison;\nmod conversion;\nmod to_string;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rational_sequences/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::bench::bucketers::rational_sequence_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sequence_to_string);\n    register_demo!(runner, demo_rational_sequence_to_debug_string);\n\n    register_bench!(runner, benchmark_rational_sequence_to_string);\n    register_bench!(runner, benchmark_rational_sequence_to_debug_string);\n}\n\nfn demo_rational_sequence_to_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{xs}\");\n    }\n}\n\nfn demo_rational_sequence_to_debug_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_rational_sequence_gen::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{xs:?}\");\n    }\n}\n\nfn benchmark_rational_sequence_to_string(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.to_string()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(xs.to_string()))],\n    );\n}\n\nfn benchmark_rational_sequence_to_debug_string(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"RationalSequence.to_debug_string()\",\n        BenchmarkType::Single,\n        unsigned_rational_sequence_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_sequence_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |xs| no_out!(xs.to_debug_string()))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rounding_modes/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{rounding_mode_gen, rounding_mode_pair_gen};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rounding_mode_clone);\n    register_demo!(runner, demo_rounding_mode_clone_from);\n}\n\nfn demo_rounding_mode_clone(gm: GenMode, config: &GenConfig, limit: usize) {\n    for rm in rounding_mode_gen().get(gm, config).take(limit) {\n        println!(\"clone({}) = {}\", rm, rm.clone());\n    }\n}\n\nfn demo_rounding_mode_clone_from(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rounding_mode_pair_gen().get(gm, config).take(limit) {\n        let x_old = x;\n        x.clone_from(&y);\n        println!(\"x := {x_old}; x.clone_from({y}); x = {x}\");\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rounding_modes/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::rounding_mode_pair_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rounding_mode_eq);\n}\n\nfn demo_rounding_mode_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rounding_mode_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rounding_modes/from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_2};\nuse malachite_base::test_util::runner::Runner;\nuse std::str::FromStr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rounding_mode_from_str);\n    register_demo!(runner, demo_rounding_mode_from_str_targeted);\n    register_bench!(runner, benchmark_rounding_mode_from_str);\n}\n\nfn demo_rounding_mode_from_str(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\n            \"RoundingMode::from_str({:?}) = {:?}\",\n            s,\n            RoundingMode::from_str(&s)\n        );\n    }\n}\n\nfn demo_rounding_mode_from_str_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"RoundingMode::from_str({:?}) = {:?}\",\n            s,\n            RoundingMode::from_str(&s)\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rounding_mode_from_str(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"from_str(&str)\",\n        BenchmarkType::Single,\n        string_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(RoundingMode::from_str(&s)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rounding_modes/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::rounding_mode_gen;\nuse malachite_base::test_util::hash::hash;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rounding_mode_hash);\n}\n\nfn demo_rounding_mode_hash(gm: GenMode, config: &GenConfig, limit: usize) {\n    for rm in rounding_mode_gen().get(gm, config).take(limit) {\n        println!(\"hash({}) = {}\", rm, hash(&rm));\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rounding_modes/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    clone::register(runner);\n    eq::register(runner);\n    from_str::register(runner);\n    hash::register(runner);\n    neg::register(runner);\n    to_string::register(runner);\n}\n\nmod clone;\nmod eq;\nmod from_str;\nmod hash;\nmod neg;\nmod to_string;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rounding_modes/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::rounding_mode_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rounding_mode_neg_assign);\n    register_demo!(runner, demo_rounding_mode_neg);\n}\n\nfn demo_rounding_mode_neg_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut rm in rounding_mode_gen().get(gm, config).take(limit) {\n        let rm_old = rm;\n        rm.neg_assign();\n        println!(\"rm := {rm_old}; r.neg_assign(); rm = {rm}\");\n    }\n}\n\nfn demo_rounding_mode_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for rm in rounding_mode_gen().get(gm, config).take(limit) {\n        println!(\"-{} = {}\", rm, -rm);\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/rounding_modes/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::rounding_mode_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rounding_mode_to_string);\n}\n\nfn demo_rounding_mode_to_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for rm in rounding_mode_gen().get(gm, config).take(limit) {\n        println!(\"{rm}\");\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/min_repeating_len.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::slices::min_repeating_len;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_4;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_min_repeating_len);\n    register_bench!(runner, benchmark_min_repeating_len);\n}\n\nfn demo_min_repeating_len(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_4::<u8>().get(gm, config).take(limit) {\n        println!(\"min_repeating_len({:?}) = {}\", xs, min_repeating_len(&xs));\n    }\n}\n\nfn benchmark_min_repeating_len(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"min_repeating_len(&[T])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_4::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(min_repeating_len(&xs)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    min_repeating_len::register(runner);\n    slice_leading_zeros::register(runner);\n    slice_move_left::register(runner);\n    slice_set_zero::register(runner);\n    slice_test_zero::register(runner);\n    slice_trailing_zeros::register(runner);\n    split_into_chunks::register(runner);\n}\n\nmod min_repeating_len;\nmod slice_leading_zeros;\nmod slice_move_left;\nmod slice_set_zero;\nmod slice_test_zero;\nmod slice_trailing_zeros;\nmod split_into_chunks;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/slice_leading_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::slices::slice_leading_zeros;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_slice_leading_zeros);\n    register_bench!(runner, benchmark_slice_leading_zeros);\n}\n\nfn demo_slice_leading_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen::<u8>().get(gm, config).take(limit) {\n        println!(\n            \"slice_leading_zeros({:?}) = {}\",\n            xs,\n            slice_leading_zeros(&xs)\n        );\n    }\n}\n\nfn benchmark_slice_leading_zeros(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"slice_leading_zeros(&[T])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(slice_leading_zeros(&xs)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/slice_move_left.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::slices::slice_move_left;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_slice_move_left);\n    register_bench!(runner, benchmark_slice_move_left);\n}\n\nfn demo_slice_move_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, amount) in unsigned_vec_unsigned_pair_gen_var_1::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        slice_move_left(&mut xs, amount);\n        println!(\"xs := {old_xs:?}; slice_move_left(&mut xs, {amount}); xs = {xs:?}\");\n    }\n}\n\nfn benchmark_slice_move_left(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"slice_move_left(&mut [T], usize)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_1::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, amount)| {\n            slice_move_left(&mut xs, amount);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/slice_set_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::slices::slice_set_zero;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_slice_set_zero);\n    register_bench!(runner, benchmark_slice_set_zero);\n}\n\nfn demo_slice_set_zero(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut xs in unsigned_vec_gen::<u8>().get(gm, config).take(limit) {\n        let old_xs = xs.clone();\n        slice_set_zero(&mut xs);\n        println!(\"xs := {old_xs:?}; slice_set_zero(&mut xs); xs = {xs:?}\");\n    }\n}\n\nfn benchmark_slice_set_zero(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"slice_set_zero(&mut [T])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |mut xs| slice_set_zero(&mut xs))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/slice_test_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::slices::slice_test_zero;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_slice_test_zero);\n    register_bench!(runner, benchmark_slice_test_zero);\n}\n\nfn demo_slice_test_zero(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen::<u8>().get(gm, config).take(limit) {\n        println!(\"slice_test_zero({:?}) = {:?}\", xs, slice_test_zero(&xs));\n    }\n}\n\nfn benchmark_slice_test_zero(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"slice_test_zero(&[T])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(slice_test_zero(&xs)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/slice_trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::slices::slice_trailing_zeros;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_slice_trailing_zeros);\n    register_bench!(runner, benchmark_slice_trailing_zeros);\n}\n\nfn demo_slice_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen::<u8>().get(gm, config).take(limit) {\n        println!(\n            \"slice_trailing_zeros({:?}) = {}\",\n            xs,\n            slice_trailing_zeros(&xs)\n        );\n    }\n}\n\nfn benchmark_slice_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"slice_trailing_zeros(&[T])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(slice_trailing_zeros(&xs)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/slices/split_into_chunks.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_unsigned_triple_gen_var_2;\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_split_into_chunks);\n    register_demo!(runner, demo_split_into_chunks_mut);\n}\n\nmacro_rules! split_into_chunks_helper {\n    ($xs: expr, $len: expr, $n: expr, [$($xs_i: ident),*], $xs_last: ident) => {{\n        split_into_chunks!($xs, $len, [$($xs_i),*], $xs_last);\n        let xss = &[$($xs_i,)* $xs_last];\n        let mut message = \"xs := \".to_string();\n        message.push_str(&$xs.to_debug_string());\n        message.push_str(\"; split_into_chunks!(xs, \");\n        message.push_str(&$len.to_string());\n        message.push_str(\", [\");\n        message.push_str(&(1..$n).map(|i| format!(\"xs_{}\", i)).join(\", \"));\n        message.push_str(\"], xs_\");\n        message.push_str(&$n.to_string());\n        message.push_str(\"); \");\n        message.push_str(&(1..=$n).zip(xss)\n            .map(|(i, xs)| format!(\"xs_{} = {:?}\", i, xs)).join(\"; \"));\n        println!(\"{}\", message);\n   }}\n}\n\nfn demo_split_into_chunks(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, len, n) in unsigned_vec_unsigned_unsigned_triple_gen_var_2::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n {\n            0 => split_into_chunks_helper!(xs, len, 1, [], xs_1),\n            1 => split_into_chunks_helper!(xs, len, 2, [xs_1], xs_2),\n            2 => split_into_chunks_helper!(xs, len, 3, [xs_1, xs_2], xs_3),\n            3 => split_into_chunks_helper!(xs, len, 4, [xs_1, xs_2, xs_3], xs_4),\n            4 => split_into_chunks_helper!(xs, len, 5, [xs_1, xs_2, xs_3, xs_4], xs_5),\n            5 => split_into_chunks_helper!(xs, len, 6, [xs_1, xs_2, xs_3, xs_4, xs_5], xs_6),\n            6 => split_into_chunks_helper!(xs, len, 7, [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6], xs_7),\n            7 => split_into_chunks_helper!(\n                xs,\n                len,\n                8,\n                [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6, xs_7],\n                xs_8\n            ),\n            _ => println!(\"Large number of chunks\"),\n        }\n    }\n}\n\nmacro_rules! split_into_chunks_mut_helper {\n    ($xs: expr, $len: expr, $n: expr, [$($xs_i: ident),*], $xs_last: ident) => {{\n        split_into_chunks_mut!($xs, $len, [$($xs_i),*], $xs_last);\n        let xss = &[$($xs_i.to_vec(),)* $xs_last.to_vec()];\n        let mut message = \"xs := \".to_string();\n        message.push_str(&$xs.to_debug_string());\n        message.push_str(\"; split_into_chunks_mut!(xs, \");\n        message.push_str(&$len.to_string());\n        message.push_str(\", [\");\n        message.push_str(&(1..$n).map(|i| format!(\"xs_{}\", i)).join(\", \"));\n        message.push_str(\"], xs_\");\n        message.push_str(&$n.to_string());\n        message.push_str(\"); \");\n        message.push_str(&(1..=$n).zip(xss)\n            .map(|(i, xs)| format!(\"xs_{} = {:?}\", i, xs)).join(\"; \"));\n        println!(\"{}\", message);\n   }}\n}\n\nfn demo_split_into_chunks_mut(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, len, n) in unsigned_vec_unsigned_unsigned_triple_gen_var_2::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n {\n            0 => split_into_chunks_mut_helper!(xs, len, 1, [], xs_1),\n            1 => split_into_chunks_mut_helper!(xs, len, 2, [xs_1], xs_2),\n            2 => split_into_chunks_mut_helper!(xs, len, 3, [xs_1, xs_2], xs_3),\n            3 => split_into_chunks_mut_helper!(xs, len, 4, [xs_1, xs_2, xs_3], xs_4),\n            4 => split_into_chunks_mut_helper!(xs, len, 5, [xs_1, xs_2, xs_3, xs_4], xs_5),\n            5 => split_into_chunks_mut_helper!(xs, len, 6, [xs_1, xs_2, xs_3, xs_4, xs_5], xs_6),\n            6 => split_into_chunks_mut_helper!(\n                xs,\n                len,\n                7,\n                [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6],\n                xs_7\n            ),\n            7 => split_into_chunks_mut_helper!(\n                xs,\n                len,\n                8,\n                [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6, xs_7],\n                xs_8\n            ),\n            _ => println!(\"Large number of chunks\"),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/strings/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    string_is_subset::register(runner);\n    string_sort::register(runner);\n    string_unique::register(runner);\n}\n\nmod string_is_subset;\nmod string_sort;\nmod string_unique;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/strings/string_is_subset.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::bench::bucketers::pair_string_max_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{string_pair_gen, string_pair_gen_var_1};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_string_is_subset);\n    register_demo!(runner, demo_string_is_subset_ascii);\n    register_bench!(runner, benchmark_string_is_subset);\n}\n\nfn demo_string_is_subset(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (s, t) in string_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:?} is {}a subset of {:?}\",\n            s,\n            if string_is_subset(&s, &t) { \"\" } else { \"not \" },\n            t\n        );\n    }\n}\n\nfn demo_string_is_subset_ascii(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (s, t) in string_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"{:?} is {}a subset of {:?}\",\n            s,\n            if string_is_subset(&s, &t) { \"\" } else { \"not \" },\n            t\n        );\n    }\n}\n\nfn benchmark_string_is_subset(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"string_is_subset(&str, &str)\",\n        BenchmarkType::Single,\n        string_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_string_max_len_bucketer(\"s\", \"t\"),\n        &mut [(\"Malachite\", &mut |(s, t)| no_out!(string_is_subset(&s, &t)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/strings/string_sort.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::string_sort;\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_1};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_string_sort);\n    register_demo!(runner, demo_string_sort_ascii);\n    register_bench!(runner, benchmark_string_sort);\n}\n\nfn demo_string_sort(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\"string_sort({:?}) = {:?}\", s, string_sort(&s));\n    }\n}\n\nfn demo_string_sort_ascii(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_1().get(gm, config).take(limit) {\n        println!(\"string_sort({:?}) = {:?}\", s, string_sort(&s));\n    }\n}\n\nfn benchmark_string_sort(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"string_sort(&str)\",\n        BenchmarkType::Single,\n        string_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(string_sort(&s)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/strings/string_unique.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::string_unique;\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_1};\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_string_unique);\n    register_demo!(runner, demo_string_unique_ascii);\n\n    register_bench!(runner, benchmark_string_unique);\n}\n\nfn demo_string_unique(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\"string_unique({:?}) = {:?}\", s, string_unique(&s));\n    }\n}\n\nfn demo_string_unique_ascii(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_1().get(gm, config).take(limit) {\n        println!(\"string_unique({:?}) = {:?}\", s, string_unique(&s));\n    }\n}\n\nfn benchmark_string_unique(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"string_unique(&str)\",\n        BenchmarkType::Single,\n        string_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(string_unique(&s)))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/vecs/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    vec_delete_left::register(runner);\n    vec_pad_left::register(runner);\n}\n\nmod vec_delete_left;\nmod vec_pad_left;\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/vecs/vec_delete_left.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_base::vecs::vec_delete_left;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_vec_delete_left);\n    register_bench!(runner, benchmark_vec_delete_left);\n}\n\nfn demo_vec_delete_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, amount) in unsigned_vec_unsigned_pair_gen_var_1::<u8>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        vec_delete_left(&mut xs, amount);\n        println!(\"xs := {old_xs:?}; vec_delete_left(&mut xs, {amount}); xs = {xs:?}\");\n    }\n}\n\nfn benchmark_vec_delete_left(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"vec_delete_left(&mut [T], usize)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_1::<u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, amount)| {\n            vec_delete_left(&mut xs, amount);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/demo_and_bench/vecs/vec_pad_left.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::triple_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_unsigned_triple_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_base::vecs::vec_pad_left;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_vec_pad_left);\n    register_bench!(runner, benchmark_vec_pad_left);\n}\n\nfn demo_vec_pad_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, pad_size, pad_value) in\n        unsigned_vec_unsigned_unsigned_triple_gen_var_1::<u8, usize, u8>()\n            .get(gm, config)\n            .take(limit)\n    {\n        let old_xs = xs.clone();\n        vec_pad_left(&mut xs, pad_size, pad_value);\n        println!(\"xs := {old_xs:?}; vec_pad_left(&mut xs, {pad_size}, {pad_value}); xs = {xs:?}\");\n    }\n}\n\nfn benchmark_vec_pad_left(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"vec_pad_left(&mut [T], usize, T)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_1::<u8, usize, u8>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pad_size, pad_value)| {\n            vec_pad_left(&mut xs, pad_size, pad_value);\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/generate/max_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn max_base_helper<T: PrimitiveUnsigned>() {\n    if T::NAME == \"usize\" {\n        return;\n    }\n    print!(\n        \"const MAX_BASE_{}: [{}; {}] = [0\",\n        T::WIDTH,\n        T::NAME,\n        T::WIDTH\n    );\n    for exp in 1..T::WIDTH {\n        print!(\", {}\", T::MAX.floor_root(exp));\n    }\n    println!(\"];\");\n    println!();\n    print!(\n        \"const MAX_POWER_{}: [{}; {}] = [0\",\n        T::WIDTH,\n        T::NAME,\n        T::WIDTH\n    );\n    for exp in 1..T::WIDTH {\n        print!(\", {}\", T::MAX.floor_root(exp).pow(exp));\n    }\n    println!(\"];\");\n    println!();\n}\n\npub(crate) fn generate_max_base() {\n    println!(\"// This section is created by max_base.rs.\");\n    apply_fn_to_unsigneds!(max_base_helper);\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/generate/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod max_base;\npub mod rle;\npub mod tuning_manager;\n"
  },
  {
    "path": "malachite-base/src/bin_util/generate/rle.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::common::rle_encode;\n\npub(crate) fn generate_rle_encoding() {\n    // Example xs\n    let xs = &[1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2];\n    println!(\"{:?}\", rle_encode(xs.iter()));\n}\n"
  },
  {
    "path": "malachite-base/src/bin_util/generate/tuning_manager.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse std::collections::{BTreeMap, BTreeSet, HashSet};\nuse std::fs::File;\nuse std::io::{BufRead, BufReader};\nuse walkdir::WalkDir;\n\nconst PARENT_PATHS: [&str; 2] = [\"../malachite-base/src\", \"../malachite-nz/src\"];\n\nfn find_all_file_paths() -> BTreeSet<String> {\n    let mut paths = BTreeSet::new();\n    for &parent_path in &PARENT_PATHS {\n        for entry in WalkDir::new(parent_path) {\n            let name = entry.unwrap().path().display().to_string();\n            // Exclude platform_64 as we'll get all the same info from _32\n            if name.ends_with(\".rs\") && !name.ends_with(\"/platform_64.rs\") {\n                paths.insert(name);\n            }\n        }\n    }\n    paths\n}\n\nfn primitive_tokenize(s: &str) -> Vec<String> {\n    let chars = s.chars().collect_vec();\n    let mut tokens = Vec::new();\n    let mut token = String::new();\n    for &c in &chars {\n        if c.is_alphanumeric() || c == '_' {\n            token.push(c);\n        } else if !token.is_empty() {\n            tokens.push(token);\n            token = String::new();\n        }\n    }\n    if !token.is_empty() {\n        tokens.push(token);\n    }\n    tokens\n}\n\nconst FN_PREFIXES: [&str; 6] =\n    [\"pub fn \", \"pub(crate) fn \", \"fn \", \"pub const fn \", \"pub(crate) const fn \", \"const fn \"];\n\nconst ALLOWED_DOUBLE_NAMES: [&str; 3] = [\"limbs_mod_limb\", \"oz_fmt\", \"fail_on_untested_path\"];\n\n#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]\nstruct FunctionRecord {\n    name: String,\n    file_path: String,\n    line_number: usize,\n}\n\nfn get_all_top_level_functions() -> BTreeMap<String, FunctionRecord> {\n    let allowed_double_names: HashSet<&str> = ALLOWED_DOUBLE_NAMES.iter().copied().collect();\n    let mut fns = BTreeMap::new();\n    let file_paths = find_all_file_paths();\n    for path in &file_paths {\n        let input = File::open(path).unwrap();\n        let buffered = BufReader::new(input);\n        for (i, line) in buffered.lines().enumerate() {\n            let line = line.unwrap();\n            for &prefix in &FN_PREFIXES {\n                if let Some(fn_string) = line.strip_prefix(prefix) {\n                    let fn_name = primitive_tokenize(fn_string).swap_remove(0);\n                    if !allowed_double_names.contains(&fn_name.as_str())\n                        && fns.contains_key(&fn_name)\n                    {\n                        panic!(\"Duplicate top-level function name: {fn_name}\");\n                    }\n                    fns.insert(\n                        fn_name.clone(),\n                        FunctionRecord {\n                            name: fn_name,\n                            file_path: path.to_string(),\n                            line_number: i,\n                        },\n                    );\n                }\n            }\n        }\n    }\n    fns\n}\n\nconst CONST_PREFIXES: [&str; 3] = [\"pub const \", \"pub(crate) const \", \"const \"];\n\nfn get_all_tuneable_constants() -> BTreeMap<String, FunctionRecord> {\n    let file_paths = find_all_file_paths();\n    let mut constants = BTreeMap::new();\n    let mut expecting_constant = false;\n    for path in &file_paths {\n        let input = File::open(path).unwrap();\n        let buffered = BufReader::new(input);\n        for (i, line) in buffered.lines().enumerate() {\n            let line = line.unwrap();\n            if expecting_constant {\n                if line.starts_with(\"//\") || line.starts_with(\"#[\") {\n                    // do nothing\n                } else {\n                    let mut p = None;\n                    for &prefix in &CONST_PREFIXES {\n                        if line.starts_with(prefix) {\n                            p = Some(prefix);\n                            break;\n                        }\n                    }\n                    assert!(p.is_some(), \"Bad const. line {i} in {path}\");\n                    let p = p.unwrap();\n                    let name = &line[p.len()..];\n                    let colon_index = name.chars().position(|c| c == ':').unwrap();\n                    let name = &name[..colon_index];\n                    assert!(\n                        !constants.contains_key(name),\n                        \"Duplicate constant name: {name}\"\n                    );\n                    constants.insert(\n                        name.to_string(),\n                        FunctionRecord {\n                            name: name.to_string(),\n                            file_path: path.to_string(),\n                            line_number: i,\n                        },\n                    );\n                    expecting_constant = false;\n                }\n            } else if line == \"//TODO tune\" {\n                expecting_constant = true;\n            }\n        }\n    }\n    assert!(!expecting_constant);\n    constants\n}\n\nfn extract_functions_and_constants(\n    name: &str,\n    lines: &[String],\n    fns: &BTreeMap<String, FunctionRecord>,\n    cs: &BTreeMap<String, FunctionRecord>,\n) -> (BTreeSet<String>, BTreeSet<String>) {\n    let mut matched_fns = BTreeSet::new();\n    let mut matched_cs = BTreeSet::new();\n    let mut first = true;\n    for line in lines {\n        for token in primitive_tokenize(line) {\n            if fns.contains_key(&token) {\n                if first {\n                    assert_eq!(token, name);\n                    first = false;\n                } else {\n                    matched_fns.insert(token.clone());\n                }\n            } else if cs.contains_key(&token) {\n                if first {\n                    assert_eq!(token, name);\n                    first = false;\n                } else {\n                    matched_cs.insert(token.clone());\n                }\n            }\n        }\n    }\n    (matched_fns, matched_cs)\n}\n\nfn get_referenced_items_for_constant(\n    constant: &FunctionRecord,\n    fns: &BTreeMap<String, FunctionRecord>,\n    cs: &BTreeMap<String, FunctionRecord>,\n) -> (BTreeSet<String>, BTreeSet<String>) {\n    let input = File::open(&constant.file_path).unwrap();\n    let buffered = BufReader::new(input);\n    let mut lines = Vec::new();\n    let mut brace_index = 0;\n    for (i, line) in buffered.lines().enumerate() {\n        if i < constant.line_number {\n            continue;\n        }\n        let line = line.unwrap();\n        let mut done = false;\n        for c in line.chars() {\n            match c {\n                '{' => brace_index += 1,\n                '}' => {\n                    assert_ne!(brace_index, 0);\n                    brace_index -= 1;\n                }\n                ';' => {\n                    if brace_index == 0 {\n                        done = true;\n                        break;\n                    }\n                }\n                _ => {}\n            }\n        }\n        lines.push(line);\n        if done {\n            break;\n        }\n    }\n    extract_functions_and_constants(&constant.name, &lines, fns, cs)\n}\n\nfn get_referenced_items_for_function(\n    function: &FunctionRecord,\n    fns: &BTreeMap<String, FunctionRecord>,\n    cs: &BTreeMap<String, FunctionRecord>,\n) -> (BTreeSet<String>, BTreeSet<String>) {\n    let input = File::open(&function.file_path).unwrap();\n    let buffered = BufReader::new(input);\n    let mut lines = Vec::new();\n    let mut brace_index = 0;\n    for (i, line) in buffered.lines().enumerate() {\n        if i < function.line_number {\n            continue;\n        }\n        let line = line.unwrap();\n        let mut done = false;\n        for c in line.chars() {\n            match c {\n                '{' => brace_index += 1,\n                '}' => {\n                    assert_ne!(brace_index, 0);\n                    brace_index -= 1;\n                    if brace_index == 0 {\n                        done = true;\n                        break;\n                    }\n                }\n                _ => {}\n            }\n        }\n        lines.push(line);\n        if done {\n            break;\n        }\n    }\n    extract_functions_and_constants(&function.name, &lines, fns, cs)\n}\n\npub struct ReferenceData {\n    functions: BTreeMap<String, FunctionRecord>,\n    constants: BTreeMap<String, FunctionRecord>,\n    pub constants_referencing_constants: BTreeMap<String, BTreeSet<String>>,\n    pub constants_referencing_functions: BTreeMap<String, BTreeSet<String>>,\n    functions_referencing_constants: BTreeMap<String, BTreeSet<String>>,\n    pub functions_referencing_functions: BTreeMap<String, BTreeSet<String>>,\n}\n\nfn parse_and_get_references() -> ReferenceData {\n    let fns = get_all_top_level_functions();\n    let cs = get_all_tuneable_constants();\n    let mut crc = BTreeMap::new();\n    let mut crf = BTreeMap::new();\n    for c in cs.values() {\n        let (rf, rc) = get_referenced_items_for_constant(c, &fns, &cs);\n        crc.insert(c.name.clone(), rc);\n        crf.insert(c.name.clone(), rf);\n    }\n    let mut frc = BTreeMap::new();\n    let mut frf = BTreeMap::new();\n    for f in fns.values() {\n        let (rf, rc) = get_referenced_items_for_function(f, &fns, &cs);\n        frc.insert(f.name.clone(), rc);\n        frf.insert(f.name.clone(), rf);\n    }\n    ReferenceData {\n        functions: fns,\n        constants: cs,\n        constants_referencing_constants: crc,\n        constants_referencing_functions: crf,\n        functions_referencing_constants: frc,\n        functions_referencing_functions: frf,\n    }\n}\n\nfn invert_map(m: &BTreeMap<String, BTreeSet<String>>) -> BTreeMap<String, BTreeSet<String>> {\n    let mut inverse = BTreeMap::new();\n    for (k, vs) in m {\n        for v in vs {\n            inverse\n                .entry(v.clone())\n                .or_insert_with(BTreeSet::new)\n                .insert(k.clone());\n        }\n    }\n    inverse\n}\n\npub fn build_reference_data() {\n    parse_and_get_references();\n}\n\nfn hfdm_helper(map: &mut BTreeMap<String, String>, k: &str, v: &str) {\n    map.insert(k.to_string(), v.to_string());\n}\n\nfn hardcoded_defining_function_map() -> BTreeMap<String, String> {\n    let mut m = BTreeMap::new();\n    hfdm_helper(&mut m, \"BMOD_1_TO_MOD_1_THRESHOLD\", \"limbs_mod_limb_helper\");\n    hfdm_helper(\n        &mut m,\n        \"DC_BDIV_QR_THRESHOLD\",\n        \"limbs_modular_div_mod_helper\",\n    );\n    hfdm_helper(&mut m, \"DC_BDIV_Q_THRESHOLD\", \"limbs_modular_invert_small\");\n    hfdm_helper(&mut m, \"DC_DIVAPPR_Q_THRESHOLD\", \"limbs_div_approx_helper\");\n    hfdm_helper(&mut m, \"DC_DIV_QR_THRESHOLD\", \"limbs_div_dc_helper\");\n    hfdm_helper(&mut m, \"DC_DIV_Q_THRESHOLD\", \"limbs_div_q_dc_helper\");\n    m\n}\n\nfn generate_defining_function_map(data: &ReferenceData) -> BTreeMap<String, String> {\n    let mut defining_functions = hardcoded_defining_function_map();\n    for (k, v) in &defining_functions {\n        assert!(data.constants.contains_key(k));\n        assert!(data.functions.contains_key(v));\n        assert!(data.functions_referencing_constants[v].contains(k));\n    }\n    for (c, fs) in invert_map(&data.functions_referencing_constants) {\n        if defining_functions.contains_key(&c) {\n            continue;\n        }\n        if fs.len() == 1 {\n            defining_functions.insert(c.clone(), fs.iter().next().unwrap().clone());\n        } else {\n            panic!(\"Must specify defining function for {c}. Possibilities are {fs:?}\");\n        }\n    }\n    defining_functions\n}\n\npub fn test() {\n    let data = parse_and_get_references();\n    generate_defining_function_map(&data);\n}\n"
  },
  {
    "path": "malachite-base/src/bools/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::comparison::traits::{Max, Min};\nuse crate::named::Named;\n\nimpl Min for bool {\n    /// The minimum value of a [`bool`]: `false`.\n    const MIN: Self = false;\n}\n\nimpl Max for bool {\n    /// The maximum value of a [`bool`]: `true`.\n    const MAX: Self = true;\n}\n\nimpl_named!(bool);\n"
  },
  {
    "path": "malachite-base/src/bools/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::iter::Copied;\nuse core::slice::Iter;\n\n/// An iterator that generates both [`bool`]s.\n///\n/// This `struct` is created by [`exhaustive_bools`]; see its documentation for more.\npub type ExhaustiveBools = Copied<Iter<'static, bool>>;\n\n/// Generates both [`bool`]s.\n///\n/// The output length is 2.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n///\n/// assert_eq!(exhaustive_bools().collect_vec(), &[false, true]);\n/// ```\n#[inline]\npub fn exhaustive_bools() -> ExhaustiveBools {\n    [false, true].iter().copied()\n}\n"
  },
  {
    "path": "malachite-base/src/bools/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Constants associated with [`bool`]s.\n///\n/// The constants [`MIN`](crate::comparison::traits::Min::MIN) and\n/// [`MAX`](crate::comparison::traits::Max::MAX) are defined as for [`bool`]s as `false` and `true`,\n/// respectively. The constant [`NAME`](crate::named::Named::NAME) is defined as \"bool\".\npub mod constants;\n/// An iterator that generates [`bool`]s without repetition.\npub mod exhaustive;\n/// The implementation of [`NotAssign`](crate::num::logic::traits::NotAssign) for [`bool`].\npub mod not_assign;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`bool`]s randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/bools/not_assign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::logic::traits::NotAssign;\n\nimpl NotAssign for bool {\n    /// Replaces a [`bool`] by its opposite.\n    ///\n    /// $b \\gets \\lnot b$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::NotAssign;\n    ///\n    /// let mut b = false;\n    /// b.not_assign();\n    /// assert_eq!(b, true);\n    ///\n    /// let mut b = true;\n    /// b.not_assign();\n    /// assert_eq!(b, false);\n    /// ```\n    #[inline]\n    fn not_assign(&mut self) {\n        *self = !*self;\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/bools/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::Parity;\nuse crate::num::random::geometric::SimpleRational;\nuse crate::num::random::{\n    RandomUnsignedsLessThan, VariableRangeGenerator, random_unsigneds_less_than,\n};\nuse crate::random::Seed;\nuse rand::Rng;\nuse rand_chacha::ChaCha20Rng;\n\n/// Uniformly generates random [`bool`]s.\n///\n/// This `struct` is created by [`random_bools`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomBools {\n    rng: ChaCha20Rng,\n    x: u32,\n    bits_left: u8,\n}\n\nimpl Iterator for RandomBools {\n    type Item = bool;\n\n    #[inline]\n    fn next(&mut self) -> Option<bool> {\n        if self.bits_left == 0 {\n            self.x = self.rng.random();\n            self.bits_left = 31;\n        } else {\n            self.x >>= 1;\n            self.bits_left -= 1;\n        }\n        Some(self.x.odd())\n    }\n}\n\n/// Uniformly generates random [`bool`]s.\n///\n/// $P(\\text{false}) = P(\\text{true}) = \\frac{1}{2}$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::bools::random::random_bools;\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_bools(EXAMPLE_SEED), 10),\n///     \"[true, false, false, false, true, true, true, false, true, true, ...]\"\n/// )\n/// ```\n///\n/// # Notes\n/// The resulting iterator uses every random bit generated by the PRNG, unlike some implementations\n/// which only use one bit out of 32 or 64.\n#[inline]\npub fn random_bools(seed: Seed) -> RandomBools {\n    RandomBools {\n        rng: seed.get_rng(),\n        x: 0,\n        bits_left: 0,\n    }\n}\n\n/// Generates random [`bool`]s, with a fixed probability of generating `true`.\n///\n/// This `struct` is created by [`weighted_random_bools`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct WeightedRandomBools {\n    numerator: u64,\n    xs: RandomUnsignedsLessThan<u64>,\n}\n\nimpl Iterator for WeightedRandomBools {\n    type Item = bool;\n\n    #[inline]\n    fn next(&mut self) -> Option<bool> {\n        Some(self.xs.next().unwrap() < self.numerator)\n    }\n}\n\n/// Generates random [`bool`]s, with a fixed probability of generating `true`.\n///\n/// Let $n_p$ be `p_numerator`, $d_p$ be `p_denominator`, and let $p=n_p/d_p$. Then\n///\n/// $P(\\text{true}) = p$,\n///\n/// $P(\\text{false}) = 1-p$.\n///\n/// The output length is infinite.\n///\n/// # Panics\n/// Panics if `p_denominator` is 0 or `p_numerator > p_denominator`.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `p_denominator.significant_bits()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::bools::random::weighted_random_bools;\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(weighted_random_bools(EXAMPLE_SEED, 3, 4), 10),\n///     \"[true, true, false, true, false, false, true, false, true, true, ...]\"\n/// )\n/// ```\npub fn weighted_random_bools(\n    seed: Seed,\n    p_numerator: u64,\n    p_denominator: u64,\n) -> WeightedRandomBools {\n    assert!(p_numerator <= p_denominator);\n    let p = SimpleRational::new(p_numerator, p_denominator);\n    WeightedRandomBools {\n        numerator: p.n,\n        xs: random_unsigneds_less_than(seed, p.d),\n    }\n}\n\n/// Generates a random [`bool`] with a particular probability of being `true`.\n///\n/// Let $n_p$ be `p_numerator`, $d_p$ be `p_denominator`, and let $p=n_p/d_p$. Then\n///\n/// $P(\\text{true}) = p$,\n///\n/// $P(\\text{false}) = 1-p$.\n///\n/// # Panics\n/// Panics if `p_denominator` is 0 or `p_numerator > p_denominator`.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `p_denominator.significant_bits()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::bools::random::get_weighted_random_bool;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     get_weighted_random_bool(&mut VariableRangeGenerator::new(EXAMPLE_SEED), 1, 10),\n///     false\n/// );\n/// ```\npub fn get_weighted_random_bool(\n    range_generator: &mut VariableRangeGenerator,\n    p_numerator: u64,\n    p_denominator: u64,\n) -> bool {\n    assert_ne!(p_denominator, 0);\n    assert!(p_numerator <= p_denominator);\n    if p_numerator == 0 {\n        return false;\n    } else if p_numerator == p_denominator {\n        return true;\n    }\n    let p = SimpleRational::new(p_numerator, p_denominator);\n    range_generator.next_less_than(p.d) < p.n\n}\n"
  },
  {
    "path": "malachite-base/src/chars/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::comparison::traits::{Max, Min};\nuse crate::named::Named;\n\n/// The number of [Unicode scalar values](https://www.unicode.org/glossary/#unicode_scalar_value).\n/// $2^{20}+2^{16}-2^{11} = \\mathrm{0x10\\\\,f800} = 1,\\\\!112,\\\\!064$.\npub const NUMBER_OF_CHARS: u32 = (1 << 20) + (1 << 16) - NUMBER_OF_SURROGATE_CODE_POINTS;\n\n/// The number of [surrogate code points](https://www.unicode.org/glossary/#surrogate_code_point);\n/// these are code points that do not correspond to any valid [`char`].\n///\n/// $2^{11} = 2,\\\\!048$.\npub const NUMBER_OF_SURROGATE_CODE_POINTS: u32 = 1 << 11;\n\n/// The first [surrogate code point](https://www.unicode.org/glossary/#surrogate_code_point).\npub const FIRST_SURROGATE_CODE_POINT: u32 = 0xd800;\n\n/// The [`char`] that comes just before the surrogate range.\n///\n/// This happens to be an unassigned (as of Unicode 14.0) character in the [Hangul Jamo Extended-B\n/// block](https://www.unicode.org/charts/PDF/UD7B0.pdf).\npub const CHAR_JUST_BELOW_SURROGATES: char = '\\u{d7ff}';\n\n/// The [`char`] that comes just after the surrogate range.\n///\n/// This is a character in the [Private Use Area](https://www.unicode.org/charts/PDF/UE000.pdf).\npub const CHAR_JUST_ABOVE_SURROGATES: char = '\\u{e000}';\n\nimpl Min for char {\n    /// The minimum value of a [`char`]: `'\\u{0}'`.\n    ///\n    /// This is the famous NUL character, a [C0\n    /// control](https://www.unicode.org/charts/PDF/U0000.pdf).\n    const MIN: Self = '\\u{0}';\n}\n\nimpl Max for char {\n    /// The maximum value of a [`char`]: `'\\u{10ffff}'`.\n    ///\n    /// This is a character in [Supplementary Private Use\n    /// Area-B](https://www.unicode.org/charts/PDF/U10FF80.pdf).\n    const MAX: Self = core::char::MAX;\n}\nimpl_named!(char);\n"
  },
  {
    "path": "malachite-base/src/chars/crement.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::chars::constants::{\n    CHAR_JUST_BELOW_SURROGATES, FIRST_SURROGATE_CODE_POINT, NUMBER_OF_CHARS,\n    NUMBER_OF_SURROGATE_CODE_POINTS,\n};\n\n/// Converts a [`char`] to a [`u32`].\n///\n/// The conversion is done in such a way that if the next largest [`char`] after $x$ is $y$, then\n/// $\\mathrm{char\\\\_to\\\\_contiguous\\\\_range(x)}+1 = \\mathrm{char\\\\_to\\\\_contiguous\\\\_range(y)}$.\n/// This can't be accomplished just through casting, because there is a range of [`u32`]s (the\n/// [surrogate code points](https://www.unicode.org/glossary/#surrogate_code_point)) that do not\n/// correspond to any [`char`].\n///\n/// The inverse of this function is [`contiguous_range_to_char`].\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::crement::char_to_contiguous_range;\n/// use std::char;\n///\n/// assert_eq!(char_to_contiguous_range('\\u{0}'), 0);\n/// assert_eq!(char_to_contiguous_range('a'), 97);\n/// assert_eq!(char_to_contiguous_range(char::MAX), 1112063);\n/// ```\npub const fn char_to_contiguous_range(c: char) -> u32 {\n    match c {\n        '\\u{0}'..=CHAR_JUST_BELOW_SURROGATES => c as u32,\n        _ => c as u32 - NUMBER_OF_SURROGATE_CODE_POINTS,\n    }\n}\n\n/// Converts a [`u32`] to a [`char`]; if all [`char`]s were arranged in ascending order, passing $u$\n/// to this function would return the $u$th [`char`].\n///\n/// This function is the inverse of [`char_to_contiguous_range`]. Every [`u32`] between 0 and\n/// $\\mathrm{NUMBER\\\\_OF\\\\_CHARS} - 1$, inclusive, is mapped to a distinct [`char`]. Passing a\n/// larger [`u32`] yields `None`.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::crement::contiguous_range_to_char;\n/// use std::char;\n///\n/// assert_eq!(contiguous_range_to_char(0), Some('\\u{0}'));\n/// assert_eq!(contiguous_range_to_char(97), Some('a'));\n/// assert_eq!(contiguous_range_to_char(1112063), Some(char::MAX));\n/// ```\npub const fn contiguous_range_to_char(u: u32) -> Option<char> {\n    const ONE_BELOW_FIRST_SURROGATE_CODE_POINT: u32 = FIRST_SURROGATE_CODE_POINT - 1;\n    const ONE_BELOW_NUMBER_OF_CHARS: u32 = NUMBER_OF_CHARS - 1;\n    match u {\n        0..=ONE_BELOW_FIRST_SURROGATE_CODE_POINT => core::char::from_u32(u),\n        FIRST_SURROGATE_CODE_POINT..=ONE_BELOW_NUMBER_OF_CHARS => {\n            core::char::from_u32(u + NUMBER_OF_SURROGATE_CODE_POINTS)\n        }\n        _ => None,\n    }\n}\n\n/// Increments this [`char`], skipping over the [surrogate code\n/// points](https://www.unicode.org/glossary/#surrogate_code_point).\n///\n/// # Panics\n/// Panics if `self` is `char::MAX`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::crement::increment_char;\n///\n/// let mut c = '\\u{0}';\n/// increment_char(&mut c);\n/// assert_eq!(c, '\\u{1}');\n///\n/// let mut c = 'a';\n/// increment_char(&mut c);\n/// assert_eq!(c, 'b');\n/// ```\n#[inline]\npub const fn increment_char(c: &mut char) {\n    *c = contiguous_range_to_char(char_to_contiguous_range(*c) + 1)\n        .expect(\"Cannot increment char::MAX\");\n}\n\n/// Decrements this [`char`], skipping over the [surrogate code\n/// points](https://www.unicode.org/glossary/#surrogate_code_point).\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `self` is `'\\u{0}'`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::crement::decrement_char;\n///\n/// let mut c = '\\u{1}';\n/// decrement_char(&mut c);\n/// assert_eq!(c, '\\u{0}');\n///\n/// let mut c = 'b';\n/// decrement_char(&mut c);\n/// assert_eq!(c, 'a');\n/// ```\n#[inline]\npub fn decrement_char(c: &mut char) {\n    if *c == char::MIN {\n        panic!(\"Cannot decrement char '{}'\", *c);\n    } else {\n        *c = contiguous_range_to_char(char_to_contiguous_range(*c) - 1).unwrap();\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/chars/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::chars::CharType;\nuse crate::chars::crement::increment_char;\nuse core::ops::RangeInclusive;\n\n/// Generates all ASCII [`char`]s, in ascending order.\n///\n/// For a friendlier order (_e.g_. nonprintable [`char`]s coming last), try\n/// [`exhaustive_ascii_chars`].\n///\n/// The output length is 128.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::exhaustive::ascii_chars_increasing;\n///\n/// assert_eq!(\n///     ascii_chars_increasing().collect::<String>(),\n///     \"\\u{0}\\u{1}\\u{2}\\u{3}\\u{4}\\u{5}\\u{6}\\u{7}\\u{8}\\t\\n\\u{b}\\u{c}\\r\\u{e}\\u{f}\\u{10}\\u{11}\\u{12}\\\n///     \\u{13}\\u{14}\\u{15}\\u{16}\\u{17}\\u{18}\\u{19}\\u{1a}\\u{1b}\\u{1c}\\u{1d}\\u{1e}\\u{1f} !\\\"#$%&\\'()*\\\n///     +,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u{7f}\"\n/// );\n/// ```\npub const fn ascii_chars_increasing() -> RangeInclusive<char> {\n    char::MIN..='\\u{7f}'\n}\n\n/// Generates all [`char`]s, in ascending order.\n///\n/// For a friendlier order (_e.g_. nonprintable [`char`]s coming last), try [`exhaustive_chars`].\n///\n/// The output length is 1,112,064.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::exhaustive::chars_increasing;\n///\n/// assert_eq!(\n///     chars_increasing().take(200).collect::<String>(),\n///     \"\\u{0}\\u{1}\\u{2}\\u{3}\\u{4}\\u{5}\\u{6}\\u{7}\\u{8}\\t\\n\\u{b}\\u{c}\\r\\u{e}\\u{f}\\u{10}\\u{11}\\u{12}\\\n///     \\u{13}\\u{14}\\u{15}\\u{16}\\u{17}\\u{18}\\u{19}\\u{1a}\\u{1b}\\u{1c}\\u{1d}\\u{1e}\\u{1f} !\\\"#$%&\\'()*\\\n///     +,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u{7f}\\\n///     \\u{80}\\u{81}\\u{82}\\u{83}\\u{84}\\u{85}\\u{86}\\u{87}\\u{88}\\u{89}\\u{8a}\\u{8b}\\u{8c}\\u{8d}\\u{8e}\\\n///     \\u{8f}\\u{90}\\u{91}\\u{92}\\u{93}\\u{94}\\u{95}\\u{96}\\u{97}\\u{98}\\u{99}\\u{9a}\\u{9b}\\u{9c}\\u{9d}\\\n///     \\u{9e}\\u{9f}\\u{a0}¡¢£¤¥¦§¨©ª«¬\\u{ad}®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇ\"\n/// );\n/// ```\npub const fn chars_increasing() -> RangeInclusive<char> {\n    char::MIN..=char::MAX\n}\n\n/// Generates all [`char`]s, in a friendly order, so that more familiar [`char`]s come first.\n///\n/// The order is\n/// - Lowercase ASCII letters,\n/// - Uppercase ASCII letters,\n/// - ASCII digits,\n/// - Graphic ASCII [`char`]s (not alphanumeric and not control), including `' '` but no other\n///   whitespace,\n/// - (only if `ascii_only` is false) Graphic Non-ASCII [`char`]s; all non-ASCII [`char`]s whose\n///   [`Debug`](std::fmt::Debug) representations don't start with `'\\'`,\n/// - All remaining [`char`]s.\n///\n/// This `struct` is created by [`exhaustive_chars`] and [`exhaustive_ascii_chars`]; see their\n/// documentation for more.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct ExhaustiveChars {\n    ascii_only: bool,\n    first: bool,\n    c: char,\n    current_type: CharType,\n}\n\nimpl Iterator for ExhaustiveChars {\n    type Item = char;\n\n    fn next(&mut self) -> Option<char> {\n        if self.first {\n            self.first = false;\n        } else {\n            match self.current_type {\n                CharType::AsciiLower => {\n                    if self.c == 'z' {\n                        self.current_type = CharType::AsciiUpper;\n                        self.c = 'A';\n                    } else {\n                        increment_char(&mut self.c);\n                    }\n                }\n                CharType::AsciiUpper => {\n                    if self.c == 'Z' {\n                        self.current_type = CharType::AsciiNumeric;\n                        self.c = '0';\n                    } else {\n                        increment_char(&mut self.c);\n                    }\n                }\n                CharType::AsciiNumeric => {\n                    if self.c == '9' {\n                        self.current_type = CharType::AsciiNonAlphanumericGraphic;\n                        self.c = ' ';\n                    } else {\n                        increment_char(&mut self.c);\n                    }\n                }\n                CharType::AsciiNonAlphanumericGraphic => {\n                    if self.c == '~' {\n                        if self.ascii_only {\n                            self.current_type = CharType::NonGraphic;\n                            self.c = '\\0';\n                        } else {\n                            self.current_type = CharType::NonAsciiGraphic;\n                            self.c = '\\u{a1}';\n                        };\n                    } else {\n                        increment_char(&mut self.c);\n                        // No control chars between ' ' and '~'\n                        while self.c.is_ascii_alphanumeric() {\n                            increment_char(&mut self.c);\n                        }\n                    }\n                }\n                CharType::NonAsciiGraphic => {\n                    if self.c == '\\u{33479}' {\n                        self.current_type = CharType::NonGraphic;\n                        self.c = '\\0';\n                    } else {\n                        increment_char(&mut self.c);\n                        while !CharType::NonAsciiGraphic.contains(self.c) {\n                            increment_char(&mut self.c);\n                        }\n                    }\n                }\n                CharType::NonGraphic => {\n                    let limit = if self.ascii_only { '\\u{7f}' } else { char::MAX };\n                    if self.c == limit {\n                        return None;\n                    }\n                    increment_char(&mut self.c);\n                    while !self.c.is_ascii_control()\n                        && (self.c.is_ascii() || CharType::NonAsciiGraphic.contains(self.c))\n                    {\n                        increment_char(&mut self.c);\n                    }\n                }\n            }\n        }\n        Some(self.c)\n    }\n}\n\n/// Generates all ASCII [`char`]s, in a friendly order, so that more familiar [`char`]s come first.\n///\n/// The order is\n/// - Lowercase ASCII letters,\n/// - Uppercase ASCII letters,\n/// - ASCII digits,\n/// - Graphic ASCII [`char`]s (not alphanumeric and not control), including `' '` but no other\n///   whitespace,\n/// - All remaining ASCII [`char`]s.\n///\n/// Within each group, the [`char`]s are ordered according to their usual order.\n///\n/// If you want to generate ASCII [`char`]s in their usual order, try [`ascii_chars_increasing`].\n///\n/// The output length is 128.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n///\n/// assert_eq!(\n///     exhaustive_ascii_chars().collect::<String>(),\n///     \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !\\\"#$%&\\'()*+,-./:;<=>?@[\\\\\\\n///     ]^_`{|}~\\u{0}\\u{1}\\u{2}\\u{3}\\u{4}\\u{5}\\u{6}\\u{7}\\u{8}\\t\\n\\u{b}\\u{c}\\r\\u{e}\\u{f}\\u{10}\\u{11}\\\n///     \\u{12}\\u{13}\\u{14}\\u{15}\\u{16}\\u{17}\\u{18}\\u{19}\\u{1a}\\u{1b}\\u{1c}\\u{1d}\\u{1e}\\u{1f}\\u{7f}\"\n/// );\n/// ```\npub const fn exhaustive_ascii_chars() -> ExhaustiveChars {\n    ExhaustiveChars {\n        ascii_only: true,\n        first: true,\n        c: 'a',\n        current_type: CharType::AsciiLower,\n    }\n}\n\n/// Generates all [`char`]s, in a friendly order, so that more familiar [`char`]s come first.\n///\n/// The order is\n/// - Lowercase ASCII letters,\n/// - Uppercase ASCII letters,\n/// - ASCII digits,\n/// - Graphic ASCII [`char`] (not alphanumeric and not control), including `' '` but no other\n///   whitespace,\n/// - Graphic Non-ASCII [`char`]s; all non-ASCII [`char`]s whose [`Debug`](std::fmt::Debug)\n///   representations don't start with `'\\'`,\n/// - All remaining [`char`]s.\n///\n/// Within each group, the [`char`]s are ordered according to their usual order.\n///\n/// If you want to generate [`char`]s in their usual order, try [`chars_increasing`].\n///\n/// The output length is 1,112,064.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::exhaustive::exhaustive_chars;\n///\n/// assert_eq!(\n///     exhaustive_chars().take(200).collect::<String>(),\n///     \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !\\\"#$%&\\'()*+,-./:;<=>?@[\\\\\\\n///     ]^_`{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóô\\\n///     õö÷øùúûüýþÿĀāĂăĄąĆćĈĉĊ\"\n/// );\n/// ```\npub const fn exhaustive_chars() -> ExhaustiveChars {\n    ExhaustiveChars {\n        ascii_only: false,\n        first: true,\n        c: 'a',\n        current_type: CharType::AsciiLower,\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/chars/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::strings::ToDebugString;\n\n#[cfg(feature = \"test_build\")]\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub enum CharType {\n    AsciiLower,\n    AsciiUpper,\n    AsciiNumeric,\n    AsciiNonAlphanumericGraphic,\n    NonAsciiGraphic,\n    NonGraphic,\n}\n\n#[cfg(not(feature = \"test_build\"))]\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\nenum CharType {\n    AsciiLower,\n    AsciiUpper,\n    AsciiNumeric,\n    AsciiNonAlphanumericGraphic,\n    NonAsciiGraphic,\n    NonGraphic,\n}\n\nfn debug_starts_with_slash(c: char) -> bool {\n    // Skip the first `char`, which is always a single quote\n    c.to_debug_string().chars().nth(1) == Some('\\\\')\n}\n\n/// Determines whether a [`char`] is graphic.\n///\n/// There is an [official Unicode\n/// definition](https://www.unicode.org/versions/Unicode14.0.0/ch03.pdf#G30602) of _graphic\n/// character_, but that definition is not followed here. In Malachite, a [`char`] is considered\n/// graphic if it is ASCII and not a [C0 control](https://www.unicode.org/charts/PDF/U0000.pdf), or\n/// non-ASCII and its debug string does not begin with a backslash. This function can be used as a\n/// guide to whether a [`char`] can be displayed on a screen without resorting to some sort of\n/// escape sequence. Of course, many typefaces will not be able to render many graphic [`char`]s.\n///\n/// The ASCII space `' '` is the only graphic whitespace [`char`].\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::char_is_graphic;\n///\n/// assert_eq!(char_is_graphic('a'), true);\n/// assert_eq!(char_is_graphic(' '), true);\n/// assert_eq!(char_is_graphic('\\n'), false);\n/// assert_eq!(char_is_graphic('ñ'), true);\n/// assert_eq!(char_is_graphic('\\u{5f771}'), false);\n/// ```\npub fn char_is_graphic(c: char) -> bool {\n    if c.is_ascii() {\n        !c.is_ascii_control()\n    } else {\n        !debug_starts_with_slash(c)\n    }\n}\n\nimpl CharType {\n    pub_crate_test! {contains(self, c: char) -> bool {\n        match self {\n            Self::AsciiLower => c.is_ascii_lowercase(),\n            Self::AsciiUpper => c.is_ascii_uppercase(),\n            Self::AsciiNumeric => c.is_ascii_digit(),\n            Self::AsciiNonAlphanumericGraphic => {\n                c.is_ascii() && !c.is_ascii_alphanumeric() && !c.is_ascii_control()\n            }\n            Self::NonAsciiGraphic => !c.is_ascii() && !debug_starts_with_slash(c),\n            Self::NonGraphic => {\n                c.is_ascii_control() || !c.is_ascii() && debug_starts_with_slash(c)\n            }\n        }\n    }}\n}\n\n/// Constants associated with [`char`]s.\n///\n/// Apart from the constants visibile on this page, the trait-based constants\n/// [`MIN`](crate::comparison::traits::Min::MIN), [`MAX`](crate::comparison::traits::Max::MAX), and\n/// [`NAME`](crate::named::Named::NAME) are also defined.\npub mod constants;\n/// Functions for incrementing and decrementing [`char`]s.\npub mod crement;\n/// Iterators that generate [`char`]s without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`char`]s randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/chars/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::{WeightedRandomBools, weighted_random_bools};\nuse crate::chars::char_is_graphic;\nuse crate::chars::crement::{char_to_contiguous_range, contiguous_range_to_char, decrement_char};\nuse crate::num::random::{RandomUnsignedInclusiveRange, random_unsigned_inclusive_range};\nuse crate::random::Seed;\nuse crate::vecs::{RandomValuesFromVec, random_values_from_vec};\n\n/// Uniformly generates random [`char`]s in a closed interval.\n///\n/// This `struct` is created by [`random_char_range`] and [`random_char_inclusive_range`]; see their\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomCharRange {\n    chunks: RandomUnsignedInclusiveRange<u32>,\n}\n\nimpl Iterator for RandomCharRange {\n    type Item = char;\n\n    #[inline]\n    fn next(&mut self) -> Option<char> {\n        contiguous_range_to_char(self.chunks.next().unwrap())\n    }\n}\n\n/// Uniformly generates random [`char`]s in a closed interval, weighting graphic and non-graphic\n/// [`char`]s separately.\n///\n/// This `struct` is created by [`graphic_weighted_random_char_range`] and\n/// [`graphic_weighted_random_char_inclusive_range`]; see their documentation for more.\n#[derive(Clone, Debug)]\npub struct WeightedGraphicRandomCharRange {\n    xs: WeightedRandomBools,\n    graphic: RandomValuesFromVec<char>,\n    non_graphic: RandomValuesFromVec<char>,\n}\n\nimpl Iterator for WeightedGraphicRandomCharRange {\n    type Item = char;\n\n    fn next(&mut self) -> Option<char> {\n        if self.xs.next().unwrap() {\n            self.graphic.next()\n        } else {\n            self.non_graphic.next()\n        }\n    }\n}\n\n/// Uniformly generates random [`char`]s.\n///\n/// $P(c) = \\frac{1}{2^{20}+2^{16}-2^{11}}$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::random_chars;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     random_chars(EXAMPLE_SEED)\n///         .take(10)\n///         .collect::<String>()\n///         .as_str(),\n///     \"\\u{5f771}\\u{87234}\\u{bcd36}\\u{9e195}\\u{5da07}\\u{36553}\\u{45028}\\u{1cdfd}\\u{d8530}\\u{c7f2e}\"\n/// )\n/// ```\n#[inline]\npub fn random_chars(seed: Seed) -> RandomCharRange {\n    random_char_inclusive_range(seed, char::MIN, char::MAX)\n}\n\n/// Uniformly generates random ASCII [`char`]s.\n///\n/// $$\n/// P(c) = \\\\begin{cases}\n///     2^{-7} & \\text{if} \\\\quad c < \\\\backslash\\\\text{u\\\\{0x80\\\\}} \\\\\\\\\n///     0 & \\\\text{otherwise}\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::random_ascii_chars;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     random_ascii_chars(EXAMPLE_SEED)\n///         .take(20)\n///         .collect::<String>()\n///         .as_str(),\n///     \"q^\\u{17}bF\\\\4T!/\\u{1}q6\\n/\\u{11}Y\\\\wB\"\n/// )\n/// ```\n#[inline]\npub fn random_ascii_chars(seed: Seed) -> RandomCharRange {\n    random_char_inclusive_range(seed, char::MIN, '\\u{7f}')\n}\n\n/// Uniformly generates random [`char`]s in the half-open interval $[a, b)$.\n///\n/// $a$ must be less than $b$. This function cannot create a range that includes `char::MAX`; for\n/// that, use [`random_char_inclusive_range`].\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}\n///     {\\mathrm{char\\\\_to\\\\_contiguous\\\\_range(b)}-\\mathrm{char\\\\_to\\\\_contiguous\\\\_range(a)}} &\n///         \\text{if} \\\\quad a \\leq x < b \\\\\\\\\n///     0 & \\\\text{otherwise}\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::random_char_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     random_char_range(EXAMPLE_SEED, 'a', 'z')\n///         .take(50)\n///         .collect::<String>()\n///         .as_str(),\n///     \"rlewrsgkdlbeouylrelopxqkoonftexoshqulgvonioatekqes\"\n/// )\n/// ```\n#[inline]\npub fn random_char_range(seed: Seed, a: char, mut b: char) -> RandomCharRange {\n    assert!(a < b, \"a must be less than b. a: {a}, b: {b}\");\n    decrement_char(&mut b);\n    random_char_inclusive_range(seed, a, b)\n}\n\n/// Uniformly generates random [`char`]s in the closed interval $[a, b]$.\n///\n/// $a$ must be less than or equal to $b$.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}\n///         {\\mathrm{char\\\\_to\\\\_contiguous\\\\_range(b)}-\\mathrm{char\\\\_to\\\\_contiguous\\\\_range(a)}\n///         +1} &\n///         \\text{if} \\\\quad a \\leq x < b \\\\\\\\\n///     0 & \\\\text{otherwise}\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::random_char_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     random_char_inclusive_range(EXAMPLE_SEED, 'a', 'z')\n///         .take(50)\n///         .collect::<String>()\n///         .as_str(),\n///     \"rlewrsgkdlbeouylrelopxqkoonftexoshqulgvonioatekqes\"\n/// )\n/// ```\n#[inline]\npub fn random_char_inclusive_range(seed: Seed, a: char, b: char) -> RandomCharRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    RandomCharRange {\n        chunks: random_unsigned_inclusive_range(\n            seed,\n            char_to_contiguous_range(a),\n            char_to_contiguous_range(b),\n        ),\n    }\n}\n\n/// Generates random [`char`]s, weighting graphic and non-graphic [`char`]s separately.\n///\n/// See [`char_is_graphic`] for the definition of a graphic [`char`].\n///\n/// Let $n_p$ be `p_numerator` and $d_p$ be `p_denominator`, and let $p = p_n/p_d$.\n///\n/// The set of graphic [`char`]s is selected with probability $p$, and the set of non-graphic\n/// [`char`]s with probability $1-p$. Then, a [`char`] is selected uniformly from the appropriate\n/// set. There are 142,523 graphic [`char`]s out of 1,112,064, so we have\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{p}{142523} & \\text{if} \\\\quad x \\\\ \\\\text{is} \\\\ \\\\text{graphic} \\\\\\\\\n///     \\frac{1-p}{969541} & \\\\text{otherwise}\n/// \\\\end{cases}\n/// $$\n///\n/// To recover the uniform distribution, use $p = 142523/1112064$, which is roughly $1/8$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `p_denominator` is zero or `p_denominator > p_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::graphic_weighted_random_chars;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     graphic_weighted_random_chars(EXAMPLE_SEED, 10, 11)\n///         .take(20)\n///         .collect::<String>()\n///         .as_str(),\n///     \"𗄡𭼭礜깬ꅉ杼쭗𫆬╳𲐕𡺽⢏𲣍\\u{90141}𮛊瀊𰥶\\u{3a6f5}\\u{d9ae0}𲛂\"\n/// )\n/// ```\n#[inline]\npub fn graphic_weighted_random_chars(\n    seed: Seed,\n    p_numerator: u64,\n    p_denominator: u64,\n) -> WeightedGraphicRandomCharRange {\n    graphic_weighted_random_char_inclusive_range(\n        seed,\n        char::MIN,\n        char::MAX,\n        p_numerator,\n        p_denominator,\n    )\n}\n\n/// Generates random ASCII [`char`]s, weighting graphic and non-graphic [`char`]s separately.\n///\n/// See [`char_is_graphic`] for the definition of a graphic [`char`].\n///\n/// Let $n_p$ be `p_numerator` and $d_p$ be `p_denominator`, and let $p = p_n/p_d$.\n///\n/// The set of graphic ASCII [`char`]s is selected with probability $p$, and the set of non-graphic\n/// ASCII [`char`]s with probability $1-p$. Then, a [`char`] is selected uniformly from the\n/// appropriate set. There are 95 graphic ASCII [`char`]s out of 128, so we have\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{p}{95} & \\text{if} \\\\quad\n///     x < \\\\backslash\\\\text{u\\\\{0x80\\\\}} \\\\ \\\\text{and} \\\\ x \\\\ \\\\text{is graphic} \\\\\\\\\n///     \\frac{1-p}{33} & \\text{if} \\\\quad\n///     x < \\\\backslash\\\\text{u\\\\{0x80\\\\}} \\\\ \\\\text{and} \\\\ x \\\\ \\\\text{is not graphic} \\\\\\\\\n///     0 & \\\\text{otherwise}\n/// \\\\end{cases}\n/// $$\n///\n/// To recover the uniform distribution, use $p = 95/128$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `p_denominator` is zero or `p_denominator > p_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::graphic_weighted_random_ascii_chars;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     graphic_weighted_random_ascii_chars(EXAMPLE_SEED, 10, 11)\n///         .take(40)\n///         .collect::<String>()\n///         .as_str(),\n///     \"x14N(bcXr$g)7\\u{1b}/E+\\u{8}\\rf\\u{2}\\u{11}Y\\u{11}Poo.$V2R.$V=6\\u{13}\\t\\u{11}\"\n/// )\n/// ```\n#[inline]\npub fn graphic_weighted_random_ascii_chars(\n    seed: Seed,\n    p_numerator: u64,\n    p_denominator: u64,\n) -> WeightedGraphicRandomCharRange {\n    graphic_weighted_random_char_inclusive_range(\n        seed,\n        char::MIN,\n        '\\u{7f}',\n        p_numerator,\n        p_denominator,\n    )\n}\n\n/// Generates random [`char`]s in the half-open interval $[a, b)$, weighting graphic and non-graphic\n/// [`char`]s separately.\n///\n/// See [`char_is_graphic`] for the definition of a graphic [`char`].\n///\n/// Let $n_p$ be `p_numerator` and $d_p$ be `p_denominator`, and let $p = p_n/p_d$.\n///\n/// The set of graphic [`char`]s in the specified range is selected with probability $p$, and the\n/// set of non-graphic [`char`]s in the range with probability $1-p$. Then, a [`char`] is selected\n/// uniformly from the appropriate set.\n///\n/// $a$ must be less than $b$. Furthermore, $[a, b)$ must contain both graphic and non-graphic\n/// [`char`]s. This function cannot create a range that includes `char::MAX`; for that, use\n/// [`graphic_weighted_random_char_inclusive_range`].\n///\n/// Let $g$ be the number of graphic [`char`]s in $[a, b)$. Then we have\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{p}{g} & a \\leq x < b \\\\ \\\\text{and} \\\\ x \\\\ \\\\text{is graphic} \\\\\\\\\n///     \\frac{1-p}{b-a-g} & a \\leq x < b \\\\ \\\\text{and} \\\\ x \\\\ \\\\text{is not graphic} \\\\\\\\\n///     0 & \\\\text{otherwise}\n/// \\\\end{cases}\n/// $$\n///\n/// To recover the uniform distribution, use $p = g/(b-a)$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `p_denominator` is zero or `p_denominator > p_denominator`, if $a \\geq b$, if $[a, b)$\n/// contains no graphic [`char`]s, or if $[a, b)$ contains only graphic [`char`]s.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::graphic_weighted_random_char_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     graphic_weighted_random_char_range(EXAMPLE_SEED, '\\u{100}', '\\u{400}', 10, 11)\n///         .take(30)\n///         .collect::<String>()\n///         .as_str(),\n///     \"ǘɂŜȢΙƘƣʅΰǟ˳ˊȇ\\u{31b}ʰɥΈ\\u{324}\\u{35a}Ϟ\\u{367}\\u{337}ƃ\\u{342}ʌμƢϳϪǰ\"\n/// )\n/// ```\n#[inline]\npub fn graphic_weighted_random_char_range(\n    seed: Seed,\n    a: char,\n    mut b: char,\n    p_numerator: u64,\n    p_denominator: u64,\n) -> WeightedGraphicRandomCharRange {\n    assert!(a < b, \"a must be less than b. a: {a}, b: {b}\");\n    decrement_char(&mut b);\n    graphic_weighted_random_char_inclusive_range(seed, a, b, p_numerator, p_denominator)\n}\n\n/// Generates random [`char`]s in the closed interval $[a, b]$, weighting graphic and non-graphic\n/// [`char`]s separately.\n///\n/// See [`char_is_graphic`] for the definition of a graphic [`char`].\n///\n/// Let $n_p$ be `p_numerator` and $d_p$ be `p_denominator`, and let $p = p_n/p_d$.\n///\n/// The set of graphic [`char`]s in the specified range is selected with probability $p$, and the\n/// set of non-graphic [`char`]s in the range with probability $1-p$. Then, a [`char`] is selected\n/// uniformly from the appropriate set.\n///\n/// $a$ must be less than $b$. Furthermore, $[a, b]$ must contain both graphic and non-graphic\n/// [`char`]s. This function cannot create a range that includes `char::MAX`; for that, use\n/// [`graphic_weighted_random_char_inclusive_range`].\n///\n/// Let $g$ be the number of graphic [`char`]s in $[a, b]$. Then we have\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{p}{g} & a \\leq x < b \\\\ \\\\text{and} \\\\ x \\\\ \\\\text{is graphic} \\\\\\\\\n///     \\frac{1-p}{b-a-g+1} & a \\leq x < b \\\\ \\\\text{and} \\\\ x \\\\ \\\\text{is not graphic} \\\\\\\\\n///     0 & \\\\text{otherwise}\n/// \\\\end{cases}\n/// $$\n///\n/// To recover the uniform distribution, use $p = g/(b-a+1)$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `p_denominator` is zero or `p_denominator > p_denominator`, if $a > b$, if $[a, b]$\n/// contains no graphic [`char`]s, or if $[a, b]$ contains only graphic [`char`]s.\n///\n/// # Examples\n/// ```\n/// use malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     graphic_weighted_random_char_inclusive_range(EXAMPLE_SEED, '\\u{100}', '\\u{3ff}', 10, 11)\n///         .take(30)\n///         .collect::<String>()\n///         .as_str(),\n///     \"ǘɂŜȢΙƘƣʅΰǟ˳ˊȇ\\u{31b}ʰɥΈ\\u{324}\\u{35a}Ϟ\\u{367}\\u{337}ƃ\\u{342}ʌμƢϳϪǰ\"\n/// )\n/// ```\npub fn graphic_weighted_random_char_inclusive_range(\n    seed: Seed,\n    a: char,\n    b: char,\n    p_numerator: u64,\n    p_denominator: u64,\n) -> WeightedGraphicRandomCharRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    let (graphic_chars, non_graphic_chars): (Vec<_>, Vec<_>) =\n        (a..=b).partition(|&c| char_is_graphic(c));\n    assert!(\n        !graphic_chars.is_empty(),\n        \"The range {a:?}..={b:?} contains no graphic chars\"\n    );\n    assert!(\n        !non_graphic_chars.is_empty(),\n        \"The range {a:?}..={b:?} only contains graphic chars\"\n    );\n    WeightedGraphicRandomCharRange {\n        xs: weighted_random_bools(seed.fork(\"xs\"), p_numerator, p_denominator),\n        graphic: random_values_from_vec(seed.fork(\"graphic\"), graphic_chars),\n        non_graphic: random_values_from_vec(seed.fork(\"non_graphic\"), non_graphic_chars),\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/comparison/macros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Computes the minimum of a list of expressions.\n///\n/// The list must be nonempty, the expressions must all have the same type, and that type must\n/// implement [`Ord`]. Each expression is only evaluated once.\n///\n/// # Examples\n/// ```\n/// use malachite_base::min;\n///\n/// assert_eq!(min!(3), 3);\n/// assert_eq!(min!(3, 1), 1);\n/// assert_eq!(min!(3, 1, 4), 1);\n/// ```\n#[macro_export]\nmacro_rules! min {\n    ($first: expr $(,$next: expr)*) => {\n        {\n            let mut min = $first;\n            $(\n                let next = $next;\n                if next < min {\n                    min = next;\n                }\n            )*\n            min\n        }\n    };\n}\n\n/// Computes the maximum of a list of expressions.\n///\n/// The list must be nonempty, the expressions must all have the same type, and that type must\n/// implement [`Ord`]. Each expression is only evaluated once.\n///\n/// # Examples\n/// ```\n/// use malachite_base::max;\n///\n/// assert_eq!(max!(3), 3);\n/// assert_eq!(max!(3, 1), 3);\n/// assert_eq!(max!(3, 1, 4), 4);\n/// ```\n#[macro_export]\nmacro_rules! max {\n    ($first: expr $(,$next: expr)*) => {\n        {\n            let mut max = $first;\n            $(\n                let next = $next;\n                if next > max {\n                    max = next;\n                }\n            )*\n            max\n        }\n    };\n}\n"
  },
  {
    "path": "malachite-base/src/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Macros related to comparing values.\n///\n/// This module defines the `min` and `max` macros.\n#[macro_use]\npub mod macros;\n/// Traits related to comparing values.\npub mod traits;\n"
  },
  {
    "path": "malachite-base/src/comparison/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Defines the minimum value of a type.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait Min {\n    /// The minimum value of `Self`.\n    const MIN: Self;\n}\n\n/// Defines the maximum value of a type.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait Max {\n    /// The maximum value of `Self`.\n    const MAX: Self;\n}\n"
  },
  {
    "path": "malachite-base/src/iterators/bit_distributor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::logic::traits::{BitConvertible, NotAssign};\nuse alloc::vec::Vec;\nuse core::fmt::Debug;\n\nconst COUNTER_WIDTH: usize = u64::WIDTH as usize;\n\n/// This struct is used to configure [`BitDistributor`]s.\n///\n/// See the [`BitDistributor`] documentation for more.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct BitDistributorOutputType {\n    weight: usize, // 0 means a tiny output_type\n    max_bits: Option<usize>,\n}\n\nimpl BitDistributorOutputType {\n    /// Creates a normal output with a specified weight.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `weight` is zero.\n    ///\n    /// The corresponding element grows as a power of $i$. See the [`BitDistributor`] documentation\n    /// for more.\n    pub const fn normal(weight: usize) -> Self {\n        assert!(weight != 0);\n        Self {\n            weight,\n            max_bits: None,\n        }\n    }\n\n    /// Creates a tiny output.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// The corresponding element grows logarithmically. See the [`BitDistributor`] documentation\n    /// for more.\n    pub const fn tiny() -> Self {\n        Self {\n            weight: 0,\n            max_bits: None,\n        }\n    }\n}\n\n/// Helps generate tuples exhaustively.\n///\n/// Think of `counter` as the bits of an integer. It's initialized to zero (all `false`s), and as\n/// it's repeatedly incremented, it eventually takes on every 64-bit value.\n///\n/// `output_types` is a list of $n$ configuration structs that, together, specify how to generate an\n/// n-element tuple of unsigned integers. Calling `get_output` repeatedly, passing in 0 through $n -\n/// 1$ as `index`, distributes the bits of `counter` into a tuple.\n///\n/// This is best shown with an example. If `output_types` is set to\n/// `[BitDistributorOutputType::normal(1); 2]`, the distributor will generate all pairs of unsigned\n/// integers. A pair may be extracted by calling `get_output(0)` and `get_output(1)`; then `counter`\n/// may be incremented to create the next pair. In this case, the pairs will be $(0, 0), (0, 1), (1,\n/// 0), (1, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 0), (2, 1), \\ldots$.\n///\n/// If you think of these pairs as coordinates in the $xy$-plane, they are traversed along a\n/// [Z-order curve](https://en.wikipedia.org/wiki/Z-order_curve). Every pair of unsigned integers\n/// will be generated exactly once.\n///\n/// In general, setting `output_types` to `[BitDistributorOutputType::normal(1); n]` will generate\n/// $n$-tuples. The elements of the tuples will be very roughly the same size, in the sense that\n/// each element will grow as $O(\\sqrt\\[n\\]{i})$, where $i$ is the counter. Sometimes we want the\n/// elements to grow at different rates. To accomplish this, we can change the weights of the output\n/// types. For example, if we set `output_types` to `[BitDistributorOutputType::normal(1),\n/// BitDistributorOutputType::normal(2)]`, the first element of the generated pairs will grow as\n/// $O(\\sqrt\\[3\\]{i})$ and the second as $O(i^{2/3})$. In general, if the weights are $w_0, w_1,\n/// \\\\ldots, w_{n-1}$, then the $k$th element of the output tuples will grow as\n/// $O(i^{w_i/\\sum_{j=0}^{n-1}w_j})$.\n///\n/// Apart from creating _normal_ output types with different weights, we can create _tiny_ output\n/// types, which indicate that the corresponding tuple element should grow especially slowly. If\n/// `output_types` contains $m$ tiny output types, each tiny tuple element grows as\n/// $O(\\sqrt\\[m\\]{\\log i})$. The growth of the other elements is unaffected. Having only tiny types\n/// in `output_types` is disallowed.\n///\n/// The above discussion of growth rates assumes that `max_bits` is not specified for any output\n/// type. But if `max_bits` is set to $b$, then the corresponding element will start growing just as\n/// if `max_bits` wasn't specified, but will stop growing once it reaches $2^b-1$.\n#[derive(Clone, Debug, Eq, PartialEq, Hash)]\npub struct BitDistributor {\n    #[cfg(feature = \"test_build\")]\n    pub output_types: Vec<BitDistributorOutputType>,\n    #[cfg(not(feature = \"test_build\"))]\n    output_types: Vec<BitDistributorOutputType>,\n    bit_map: [usize; COUNTER_WIDTH],\n    counter: [bool; COUNTER_WIDTH],\n}\n\nimpl BitDistributor {\n    fn new_without_init(output_types: &[BitDistributorOutputType]) -> Self {\n        if output_types\n            .iter()\n            .all(|output_type| output_type.weight == 0)\n        {\n            panic!(\"All output_types cannot be tiny\");\n        }\n        Self {\n            output_types: output_types.to_vec(),\n            bit_map: [0; COUNTER_WIDTH],\n            counter: [false; COUNTER_WIDTH],\n        }\n    }\n\n    /// Creates a new [`BitDistributor`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `output_types.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::bit_distributor::{\n    ///     BitDistributor, BitDistributorOutputType,\n    /// };\n    ///\n    /// BitDistributor::new(&[\n    ///     BitDistributorOutputType::normal(2),\n    ///     BitDistributorOutputType::tiny(),\n    /// ]);\n    /// ```\n    pub fn new(output_types: &[BitDistributorOutputType]) -> Self {\n        let mut distributor = Self::new_without_init(output_types);\n        distributor.update_bit_map();\n        distributor\n    }\n\n    /// Returns a reference to the internal bit map as a slice.\n    ///\n    /// The bit map determines which output gets each bit of the counter. For example, if the bit\n    /// map is $[0, 1, 0, 1, 0, 1, \\ldots]$, then the first element of the output pair gets the bits\n    /// with indices $0, 2, 4, \\ldots$ and the second element gets the bits with indices $1, 3, 5,\n    /// \\ldots$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::bit_distributor::{\n    ///     BitDistributor, BitDistributorOutputType,\n    /// };\n    ///\n    /// let bd = BitDistributor::new(&[\n    ///     BitDistributorOutputType::normal(2),\n    ///     BitDistributorOutputType::tiny(),\n    /// ]);\n    /// assert_eq!(\n    ///     bd.bit_map_as_slice(),\n    ///     &[\n    ///         1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    ///         0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    ///         0, 0, 0, 0, 0, 0, 0, 1\n    ///     ][..]\n    /// );\n    /// ```\n    pub fn bit_map_as_slice(&self) -> &[usize] {\n        self.bit_map.as_ref()\n    }\n\n    fn update_bit_map(&mut self) {\n        let (mut normal_output_type_indices, mut tiny_output_type_indices): (\n            Vec<usize>,\n            Vec<usize>,\n        ) = (0..self.output_types.len()).partition(|&i| self.output_types[i].weight != 0);\n        let mut normal_output_types_bits_used = vec![0; normal_output_type_indices.len()];\n        let mut tiny_output_types_bits_used = vec![0; tiny_output_type_indices.len()];\n        let mut ni = normal_output_type_indices.len() - 1;\n        let mut ti = tiny_output_type_indices.len().saturating_sub(1);\n        let mut weight_counter = self.output_types[normal_output_type_indices[ni]].weight;\n        for i in 0..COUNTER_WIDTH {\n            let use_normal_output_type = !normal_output_type_indices.is_empty()\n                && (tiny_output_type_indices.is_empty() || !usize::is_power_of_two(i + 1));\n            if use_normal_output_type {\n                self.bit_map[i] = normal_output_type_indices[ni];\n                let output_type = self.output_types[normal_output_type_indices[ni]];\n                normal_output_types_bits_used[ni] += 1;\n                weight_counter -= 1;\n                if output_type.max_bits == Some(normal_output_types_bits_used[ni]) {\n                    normal_output_type_indices.remove(ni);\n                    normal_output_types_bits_used.remove(ni);\n                    if normal_output_type_indices.is_empty() {\n                        continue;\n                    }\n                    weight_counter = 0;\n                }\n                if weight_counter == 0 {\n                    if ni == 0 {\n                        ni = normal_output_type_indices.len() - 1;\n                    } else {\n                        ni -= 1;\n                    }\n                    weight_counter = self.output_types[normal_output_type_indices[ni]].weight;\n                }\n            } else {\n                if tiny_output_type_indices.is_empty() {\n                    self.bit_map[i] = usize::MAX;\n                    continue;\n                }\n                self.bit_map[i] = tiny_output_type_indices[ti];\n                let output_type = self.output_types[tiny_output_type_indices[ti]];\n                tiny_output_types_bits_used[ti] += 1;\n                if output_type.max_bits == Some(tiny_output_types_bits_used[ti]) {\n                    tiny_output_type_indices.remove(ti);\n                    tiny_output_types_bits_used.remove(ti);\n                    if tiny_output_type_indices.is_empty() {\n                        continue;\n                    }\n                }\n                if ti == 0 {\n                    ti = tiny_output_type_indices.len() - 1;\n                } else {\n                    ti -= 1;\n                }\n            }\n        }\n    }\n\n    /// Sets the maximum bits for several outputs.\n    ///\n    /// Given slice of output indices, sets the maximum bits for each of the outputs and rebuilds\n    /// the bit map.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `output_type_indices.len()`.\n    ///\n    /// # Panics\n    /// Panics if `max_bits` is 0 or if any index is greater than or equal to\n    /// `self.output_types.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::bit_distributor::{\n    ///     BitDistributor, BitDistributorOutputType,\n    /// };\n    ///\n    /// let mut bd = BitDistributor::new(&[BitDistributorOutputType::normal(2); 3]);\n    /// assert_eq!(\n    ///     bd.bit_map_as_slice(),\n    ///     &[\n    ///         2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1,\n    ///         0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2,\n    ///         1, 1, 0, 0, 2, 2, 1, 1\n    ///     ][..]\n    /// );\n    ///\n    /// bd.set_max_bits(&[0, 2], 5);\n    /// assert_eq!(\n    ///     bd.bit_map_as_slice(),\n    ///     &[\n    ///         2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n    ///         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n    ///         1, 1, 1, 1, 1, 1, 1, 1\n    ///     ][..]\n    /// );\n    /// ```\n    pub fn set_max_bits(&mut self, output_type_indices: &[usize], max_bits: usize) {\n        assert_ne!(max_bits, 0);\n        for &index in output_type_indices {\n            self.output_types[index].max_bits = Some(max_bits);\n        }\n        self.update_bit_map();\n    }\n\n    /// Increments the counter in preparation for a new set of outputs.\n    ///\n    /// If the counter is incremented $2^{64}$ times, it rolls back to 0.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::bit_distributor::{\n    ///     BitDistributor, BitDistributorOutputType,\n    /// };\n    ///\n    /// let mut bd = BitDistributor::new(&[BitDistributorOutputType::normal(1)]);\n    /// let mut outputs = Vec::new();\n    /// for _ in 0..20 {\n    ///     outputs.push(bd.get_output(0));\n    ///     bd.increment_counter();\n    /// }\n    /// assert_eq!(\n    ///     outputs,\n    ///     &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    /// );\n    /// ```\n    pub fn increment_counter(&mut self) {\n        for b in &mut self.counter {\n            b.not_assign();\n            if *b {\n                break;\n            }\n        }\n    }\n\n    /// Gets the output at a specified index.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `index` is greater than or equal to `self.output_types.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::iterators::bit_distributor::{\n    ///     BitDistributor, BitDistributorOutputType,\n    /// };\n    ///\n    /// let mut bd = BitDistributor::new(&[BitDistributorOutputType::normal(1); 2]);\n    /// let mut outputs = Vec::new();\n    /// for _ in 0..10 {\n    ///     outputs.push((0..2).map(|i| bd.get_output(i)).collect_vec());\n    ///     bd.increment_counter();\n    /// }\n    /// let expected_outputs: &[&[usize]] = &[\n    ///     &[0, 0],\n    ///     &[0, 1],\n    ///     &[1, 0],\n    ///     &[1, 1],\n    ///     &[0, 2],\n    ///     &[0, 3],\n    ///     &[1, 2],\n    ///     &[1, 3],\n    ///     &[2, 0],\n    ///     &[2, 1],\n    /// ];\n    /// assert_eq!(outputs, expected_outputs);\n    /// ```\n    pub fn get_output(&self, index: usize) -> usize {\n        assert!(index < self.output_types.len());\n        usize::from_bits_asc(\n            self.bit_map\n                .iter()\n                .zip(self.counter.iter())\n                .filter_map(|(&m, &c)| if m == index { Some(c) } else { None }),\n        )\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/iterators/comparison.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\n\n/// An iterator that generates the [`Ordering`]s of adjacent elements of a given iterator.\n///\n/// This `struct` is created by [`delta_directions`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct DeltaDirections<I: Iterator>\nwhere\n    I::Item: Ord,\n{\n    previous: Option<I::Item>,\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for DeltaDirections<I>\nwhere\n    I::Item: Ord,\n{\n    type Item = Ordering;\n\n    fn next(&mut self) -> Option<Ordering> {\n        if self.previous.is_none() {\n            if let Some(x) = self.xs.next() {\n                self.previous = Some(x);\n            } else {\n                return None;\n            }\n        }\n        self.xs.next().and_then(|x| {\n            let result = Some(x.cmp(self.previous.as_ref().unwrap()));\n            self.previous = Some(x);\n            result\n        })\n    }\n}\n\n/// Returns an iterator that generates the [`Ordering`]s of adjacent pairs of elements of a given\n/// iterator.\n///\n/// To put it another way (at least for types where subtraction is defined), the returned iterator\n/// produces the signs of the finite differences of the input iterator.\n///\n/// $f((x_k)_{k=0}^N) = (\\\\operatorname{cmp}(x_k, x\\_{k-1}))\\_{k=1}^N$, where $N$ may be $\\infty$.\n///\n/// The output length is infinite if `xs` is infinite, or $\\max(n - 1, 0)$ otherwise, where $n$ is\n/// `xs.count()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::comparison::delta_directions;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(\n///     delta_directions([3, 1, 4, 1, 5, 9].into_iter()).collect_vec(),\n///     &[Less, Greater, Less, Greater, Greater]\n/// )\n/// ```\n#[inline]\npub const fn delta_directions<I: Iterator>(xs: I) -> DeltaDirections<I>\nwhere\n    I::Item: Ord,\n{\n    DeltaDirections { previous: None, xs }\n}\n\n/// Determines whether each element of an iterator is greater than the preceding one.\n///\n/// This function will hang if given an infinite strictly ascending iterator.\n///\n/// $$\n/// f((x_k)\\_{k=0}^N) = \\\\bigwedge\\_{k=1}^N{x\\_k > x\\_{k-1}},\n/// $$\n/// where $N$ may be $\\infty$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::comparison::is_strictly_ascending;\n///\n/// assert_eq!(is_strictly_ascending([1, 2, 3, 4].into_iter()), true);\n/// assert_eq!(is_strictly_ascending([1, 2, 2, 4].into_iter()), false);\n/// ```\n#[inline]\npub fn is_strictly_ascending<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Ord,\n{\n    delta_directions(xs).all(|x| x == Greater)\n}\n\n/// Determines whether each element of an iterator is less than the preceding one.\n///\n/// This function will hang if given an infinite strictly descending iterator.\n///\n/// $$\n/// f((x_k)\\_{k=0}^N) = \\\\bigwedge\\_{k=1}^N{x\\_k < x\\_{k-1}},\n/// $$\n/// where $N$ may be $\\infty$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::comparison::is_strictly_descending;\n///\n/// assert_eq!(is_strictly_descending([4, 3, 2, 1].into_iter()), true);\n/// assert_eq!(is_strictly_descending([4, 2, 2, 1].into_iter()), false);\n/// ```\n#[inline]\npub fn is_strictly_descending<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Ord,\n{\n    delta_directions(xs).all(|x| x == Less)\n}\n\n/// Determines whether each element of an iterator is greater than or equal to the preceding one.\n///\n/// This function will hang if given an infinite weakly ascending iterator.\n///\n/// $$\n/// f((x_k)\\_{k=0}^N) = \\\\bigwedge\\_{k=1}^N{x\\_k \\geq x\\_{k-1}},\n/// $$\n/// where $N$ may be $\\infty$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::comparison::is_weakly_ascending;\n///\n/// assert_eq!(is_weakly_ascending([1, 2, 3, 4].into_iter()), true);\n/// assert_eq!(is_weakly_ascending([1, 2, 2, 4].into_iter()), true);\n/// assert_eq!(is_weakly_ascending([1, 3, 2, 4].into_iter()), false);\n/// ```\n#[inline]\npub fn is_weakly_ascending<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Ord,\n{\n    delta_directions(xs).all(|x| x != Less)\n}\n\n/// Determines whether each element of an iterator is less than or equal to the preceding one.\n///\n/// This function will hang if given an infinite weakly descending iterator.\n///\n/// $$\n/// f((x_k)\\_{k=0}^N) = \\\\bigwedge\\_{k=1}^N{x\\_k \\leq x\\_{k-1}},\n/// $$\n/// where $N$ may be $\\infty$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::comparison::is_weakly_descending;\n///\n/// assert_eq!(is_weakly_descending([4, 3, 2, 1].into_iter()), true);\n/// assert_eq!(is_weakly_descending([4, 2, 2, 1].into_iter()), true);\n/// assert_eq!(is_weakly_descending([4, 2, 3, 1].into_iter()), false);\n/// ```\n#[inline]\npub fn is_weakly_descending<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Ord,\n{\n    delta_directions(xs).all(|x| x != Greater)\n}\n\n/// Determines whether the sequence strictly zigzags.\n///\n/// A strictly zigzagging sequence is one where every odd-indexed element is greater than its\n/// even-indexed neighbors, or one where every odd-indexed element is less than its even-indexed\n/// neighbors.\n///\n/// This function will hang if given an infinite strictly zigzagging iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::comparison::is_strictly_zigzagging;\n///\n/// assert_eq!(is_strictly_zigzagging([1, 2, 3, 4].into_iter()), false);\n/// assert_eq!(is_strictly_zigzagging([4, 3, 2, 1].into_iter()), false);\n/// assert_eq!(is_strictly_zigzagging([1, 3, 2, 4].into_iter()), true);\n/// assert_eq!(is_strictly_zigzagging([1, 2, 2, 4].into_iter()), false);\n/// ```\npub fn is_strictly_zigzagging<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Ord,\n{\n    let mut previous = None;\n    for direction in delta_directions(xs) {\n        if direction == Equal {\n            return false;\n        }\n        if let Some(previous) = previous\n            && direction == previous\n        {\n            return false;\n        }\n        previous = Some(direction);\n    }\n    true\n}\n\n/// Determines whether the sequence weakly zigzags.\n///\n/// A weakly zigzagging sequence is one where every odd-indexed element is greater than or equal to\n/// its even-indexed neighbors, or one where every odd-indexed element is less than or equal to its\n/// even-indexed neighbors.\n///\n/// This function will hang if given an infinite strictly zigzagging iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::comparison::is_weakly_zigzagging;\n///\n/// assert_eq!(is_weakly_zigzagging([1, 2, 3, 4].into_iter()), false);\n/// assert_eq!(is_weakly_zigzagging([4, 3, 2, 1].into_iter()), false);\n/// assert_eq!(is_weakly_zigzagging([1, 3, 2, 4].into_iter()), true);\n/// assert_eq!(is_weakly_zigzagging([1, 2, 2, 4].into_iter()), true);\n/// ```\npub fn is_weakly_zigzagging<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Ord,\n{\n    let mut previous = None;\n    for direction in delta_directions(xs) {\n        if let Some(previous) = &mut previous {\n            if direction == *previous {\n                return false;\n            }\n            *previous = previous.reverse();\n        } else if direction != Equal {\n            previous = Some(direction);\n        }\n    }\n    true\n}\n"
  },
  {
    "path": "malachite-base/src/iterators/iterator_cache.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse alloc::vec::Vec;\n\n/// Remembers values produced by an iterator.\n///\n/// After wrapping an iterator with an `IteratorCache`, you can retrieve a reference to the $n$th\n/// element of an iterator, and then retrieve a reference to the $m$th element in constant time for\n/// any $m \\leq n$ (not counting the time it took to first get the $n$th element).\n#[derive(Clone, Debug)]\npub struct IteratorCache<I: Iterator> {\n    xs: I,\n    cache: Vec<I::Item>,\n    done: bool,\n}\n\nimpl<I: Iterator> IteratorCache<I> {\n    /// Creates a new `IteratorCache`.\n    ///\n    /// This function does not allocate any memory or advance the iterator.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::iterator_cache::IteratorCache;\n    ///\n    /// IteratorCache::new([1, 2, 3].iter());\n    /// ```\n    pub const fn new(xs: I) -> Self {\n        Self {\n            xs,\n            cache: Vec::new(),\n            done: false,\n        }\n    }\n\n    /// Retrieves the $n$th element of an iterator. Indexing starts at 0.\n    ///\n    /// If the index is higher than any other previously-requested index, the iterator is advanced\n    /// to that index, or until it runs out. If the iterator has previously been advanced past the\n    /// index, the requested element is returned from the cache in constant time. If the iterator is\n    /// too short to have an element at the index, `None` is returned.\n    ///\n    /// If you know that the element is present, and want to only take an immutable reference to\n    /// `self`, consider using [`assert_get`](Self::assert_get) instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is 1 if `get` has previously been\n    /// called with an index at least this large, or `index` otherwise.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::iterator_cache::IteratorCache;\n    ///\n    /// let mut xs = IteratorCache::new([1, 2, 3].iter().cloned());\n    /// assert_eq!(xs.get(1), Some(&2));\n    /// assert_eq!(xs.get(0), Some(&1));\n    /// assert_eq!(xs.get(3), None);\n    /// assert_eq!(xs.get(2), Some(&3));\n    /// ```\n    pub fn get(&mut self, index: usize) -> Option<&I::Item> {\n        if !self.done && index >= self.cache.len() {\n            self.cache\n                .extend((&mut self.xs).take(index - self.cache.len() + 1));\n            if index >= self.cache.len() {\n                self.done = true;\n                return None;\n            }\n        }\n        self.cache.get(index)\n    }\n\n    /// Retrieves the $n$th element of an iterator, while asserting that the iterator has already\n    /// reached that element. Indexing starts at 0.\n    ///\n    /// If the iterator has not advanced that far, or if it has fewer than $n + 1$ elements, this\n    /// function panics.\n    ///\n    /// The purpose of this function is to allow the caller to get an element immutably, assuming\n    /// that the caller knows that the element is present. The [`get`](Self::get) function has to\n    /// take a mutable reference.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::iterator_cache::IteratorCache;\n    ///\n    /// let mut xs = IteratorCache::new([1, 2, 3].iter().cloned());\n    /// // Force the iterator to iterate to completion\n    /// xs.get(3);\n    /// assert_eq!(xs.assert_get(1), &2);\n    /// assert_eq!(xs.assert_get(0), &1);\n    /// assert_eq!(xs.assert_get(2), &3);\n    /// ```\n    pub fn assert_get(&self, index: usize) -> &I::Item {\n        self.cache.get(index).unwrap()\n    }\n\n    /// Returns the total number of elements in the iterator, if the iterator has been completely\n    /// consumed.\n    ///\n    /// If the iterator has not been completely consumed yet, returns `None`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::iterator_cache::IteratorCache;\n    ///\n    /// let mut xs = IteratorCache::new([1, 2, 3].iter().cloned());\n    /// assert_eq!(xs.known_len(), None);\n    /// assert_eq!(xs.get(1), Some(&2));\n    /// assert_eq!(xs.known_len(), None);\n    /// assert_eq!(xs.get(0), Some(&1));\n    /// assert_eq!(xs.get(3), None);\n    /// assert_eq!(xs.known_len(), Some(3));\n    /// assert_eq!(xs.get(2), Some(&3));\n    /// ```\n    pub const fn known_len(&self) -> Option<usize> {\n        if self.done {\n            Some(self.cache.len())\n        } else {\n            None\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/iterators/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(feature = \"random\")]\nuse crate::bools::random::{WeightedRandomBools, weighted_random_bools};\nuse crate::num::arithmetic::traits::Parity;\nuse crate::num::basic::traits::Zero;\n#[cfg(feature = \"random\")]\nuse crate::random::Seed;\n#[cfg(feature = \"random\")]\nuse crate::vecs::{RandomValuesFromVec, random_values_from_vec};\nuse alloc::collections::VecDeque;\nuse alloc::string::{String, ToString};\nuse alloc::vec::Vec;\nuse core::fmt::Display;\nuse core::hash::Hash;\nuse hashbrown::HashSet;\nuse itertools::Itertools;\n\n/// Generates all the nonzero values of a provided iterator.\n///\n/// This `struct` is created by [`nonzero_values`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct NonzeroValues<I: Iterator>(I)\nwhere\n    I::Item: PartialEq<I::Item> + Zero;\n\nimpl<I: Iterator> Iterator for NonzeroValues<I>\nwhere\n    I::Item: PartialEq<I::Item> + Zero,\n{\n    type Item = I::Item;\n\n    #[inline]\n    fn next(&mut self) -> Option<I::Item> {\n        loop {\n            let x = self.0.next();\n            if x != Some(I::Item::ZERO) {\n                return x;\n            }\n        }\n    }\n}\n\nimpl<I: DoubleEndedIterator> DoubleEndedIterator for NonzeroValues<I>\nwhere\n    I::Item: PartialEq<I::Item> + Zero,\n{\n    #[inline]\n    fn next_back(&mut self) -> Option<I::Item> {\n        loop {\n            let x = self.0.next_back();\n            if x != Some(I::Item::ZERO) {\n                return x;\n            }\n        }\n    }\n}\n\n/// Returns an iterator that generates all the nonzero values of a provided iterator.\n///\n/// `nonzero_values(xs)` generates the same values as `xs.filter(|x| x != I::Item::ZERO)`, but its\n/// type is easier to work with.\n///\n/// This iterator will hang if given an iterator that produces an infinite suffix of zeros.\n///\n/// The output length is the number of nonzero values produced by `xs`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::nonzero_values;\n///\n/// assert_eq!(\n///     nonzero_values([-3i8, -2, -1, 0, 1, 2, 3].iter().cloned()).collect_vec(),\n///     &[-3, -2, -1, 1, 2, 3]\n/// )\n/// ```\n#[inline]\npub const fn nonzero_values<I: Iterator>(xs: I) -> NonzeroValues<I>\nwhere\n    I::Item: PartialEq<I::Item> + Zero,\n{\n    NonzeroValues(xs)\n}\n\n/// Returns whether all of the values generated by an iterator are equal.\n///\n/// `is_constant(xs)` is equivalent to `xs.unique().count() == 1` for finite nonempty iterators, but\n/// is more efficient, doesn't require [`Clone`] or [`Hash`] implementations, and doesn't hang if\n/// provided an infinite non-constant iterator.\n///\n/// This function will hang if given an infinite constant iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::is_constant;\n///\n/// assert_eq!(is_constant([1; 4].iter()), true);\n/// assert_eq!(is_constant([1, 2, 3, 4].iter()), false);\n/// assert_eq!(is_constant(0..), false);\n/// ```\npub fn is_constant<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Eq,\n{\n    let mut first = None;\n    for x in xs {\n        if let Some(ref first) = first {\n            if x != *first {\n                return false;\n            }\n        } else {\n            first = Some(x);\n        }\n    }\n    true\n}\n\n/// Returns whether an iterator returns at least some number of values.\n///\n/// `count_is_at_least(xs, n)` is equivalent to `xs.count() >= n` for finite iterators, but doesn't\n/// hang if provided an infinite iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::count_is_at_least;\n///\n/// assert_eq!(count_is_at_least([1, 2, 3, 4].iter(), 3), true);\n/// assert_eq!(count_is_at_least([1, 2, 3, 4].iter(), 4), true);\n/// assert_eq!(count_is_at_least([1, 2, 3, 4].iter(), 5), false);\n/// assert_eq!(count_is_at_least(0.., 5), true);\n/// ```\n#[inline]\npub fn count_is_at_least<I: Iterator>(xs: I, n: usize) -> bool {\n    xs.take(n).count() == n\n}\n\n/// Returns whether an iterator returns at most some number of values.\n///\n/// `count_is_at_most(xs, n)` is equivalent to `xs.count() <= n` for finite iterators, but doesn't\n/// hang if provided an infinite iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::count_is_at_most;\n///\n/// assert_eq!(count_is_at_most([1, 2, 3, 4].iter(), 3), false);\n/// assert_eq!(count_is_at_most([1, 2, 3, 4].iter(), 4), true);\n/// assert_eq!(count_is_at_most([1, 2, 3, 4].iter(), 5), true);\n/// assert_eq!(count_is_at_most(0.., 5), false);\n/// ```\n#[inline]\npub fn count_is_at_most<I: Iterator>(xs: I, n: usize) -> bool {\n    xs.take(n + 1).count() <= n\n}\n\n/// Returns whether an iterator never returns the same value twice.\n///\n/// `is_unique(xs)` is equivalent to `xs.unique().count() <= 1` for finite iterators, but is more\n/// efficient and doesn't hang if provided a non-unique infinite iterator.\n///\n/// This iterator will hang if given an infinite unique iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::is_unique;\n///\n/// let empty: [u32; 0] = [];\n/// assert_eq!(is_unique(empty.iter()), true);\n/// assert_eq!(is_unique([1, 2, 3, 4].iter()), true);\n/// assert_eq!(is_unique([1, 2, 3, 1].iter()), false);\n/// assert_eq!(is_unique((0..).map(|i| i / 2)), false);\n/// ```\n#[inline]\npub fn is_unique<I: Iterator>(xs: I) -> bool\nwhere\n    I::Item: Eq + Hash,\n{\n    let mut set = HashSet::new();\n    for x in xs {\n        if !set.insert(x) {\n            return false;\n        }\n    }\n    true\n}\n\n/// Returns the first and last elements of an iterator, or `None` if it is empty.\n///\n/// The iterator's elements must be cloneable, since if the iterator consists of a single element\n/// `x`, the result will be `(x, x)`.\n///\n/// This iterator will hang if given an infinite iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::first_and_last;\n///\n/// let empty: [u32; 0] = [];\n/// assert_eq!(first_and_last(&mut empty.iter()), None);\n/// assert_eq!(first_and_last(&mut [1].iter().cloned()), Some((1, 1)));\n/// assert_eq!(first_and_last(&mut [1, 2, 3].iter().cloned()), Some((1, 3)));\n/// ```\npub fn first_and_last<I: Iterator>(xs: &mut I) -> Option<(I::Item, I::Item)>\nwhere\n    I::Item: Clone,\n{\n    xs.next().map(|first| {\n        if let Some(last) = xs.last() {\n            (first, last)\n        } else {\n            (first.clone(), first)\n        }\n    })\n}\n\n/// Groups elements of an iterator into intervals of adjacent elements that match a predicate. The\n/// endpoints of each interval are returned.\n///\n/// The intervals are inclusive.\n///\n/// This iterator will hang if given an infinite iterator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::matching_intervals_in_iterator;\n///\n/// let xs = &[1, 2, 10, 11, 12, 7, 8, 16, 5];\n/// assert_eq!(\n///     matching_intervals_in_iterator(xs.iter().cloned(), |&x| x >= 10).as_slice(),\n///     &[(10, 12), (16, 16)]\n/// );\n/// assert_eq!(\n///     matching_intervals_in_iterator(xs.iter().cloned(), |&x| x < 10).as_slice(),\n///     &[(1, 2), (7, 8), (5, 5)]\n/// );\n/// ```\npub fn matching_intervals_in_iterator<I: Iterator, F: Fn(&I::Item) -> bool>(\n    xs: I,\n    predicate: F,\n) -> Vec<(I::Item, I::Item)>\nwhere\n    I::Item: Clone,\n{\n    xs.chunk_by(predicate)\n        .into_iter()\n        .filter_map(|(b, mut group)| if b { first_and_last(&mut group) } else { None })\n        .collect()\n}\n\n#[cfg(feature = \"random\")]\n/// An iterator that randomly produces another iterator's values, or produces a special value.\n///\n/// This `struct` is created by [`with_special_value`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct WithSpecialValue<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    bs: WeightedRandomBools,\n    special_value: I::Item,\n    xs: I,\n}\n\n#[cfg(feature = \"random\")]\nimpl<I: Iterator> Iterator for WithSpecialValue<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = I::Item;\n\n    fn next(&mut self) -> Option<I::Item> {\n        if self.bs.next().unwrap() {\n            Some(self.special_value.clone())\n        } else {\n            self.xs.next()\n        }\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// An iterator that randomly produces another iterator's values, or produces a special value.\n///\n/// Let $n_p$ be `p_numerator`, $d_p$ be `p_denominator`, and let $p=n_p/d_p$.\n///\n/// Every time a value is to be generated, the iterator returns the special value with probability\n/// $p$, or else returns a value from the inner iterator.\n///\n/// If $p > 0$, the output length is infinite. Otherwise, it is the same as the length of `xs`.\n///\n/// # Panics\n/// Panics if `p_denominator` is 0 or `p_numerator` is greater than `p_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::{prefix_to_string, with_special_value};\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         with_special_value(EXAMPLE_SEED, -1i16, 1, 2, &random_primitive_ints::<i16>),\n///         20\n///     ),\n///     \"[-1, -1, -1, 2901, -1, -14200, -1, -1, -1, -30997, -8245, -5338, -1, -1, -20007, -1, -1, \\\n///     -1, -1, -1, ...]\"\n/// );\n/// ```\npub fn with_special_value<I: Iterator>(\n    seed: Seed,\n    special_value: I::Item,\n    p_numerator: u64,\n    p_denominator: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> WithSpecialValue<I>\nwhere\n    I::Item: Clone,\n{\n    WithSpecialValue {\n        bs: weighted_random_bools(seed.fork(\"bs\"), p_numerator, p_denominator),\n        special_value,\n        xs: xs_gen(seed.fork(\"xs\")),\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// An iterator that randomly produces another iterator's values, or samples from a [`Vec`] of\n/// special values.\n///\n/// This `struct` is created by [`with_special_values`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct WithSpecialValues<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    bs: WeightedRandomBools,\n    special_values: RandomValuesFromVec<I::Item>,\n    xs: I,\n}\n\n#[cfg(feature = \"random\")]\nimpl<I: Iterator> Iterator for WithSpecialValues<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = I::Item;\n\n    fn next(&mut self) -> Option<I::Item> {\n        if self.bs.next().unwrap() {\n            self.special_values.next()\n        } else {\n            self.xs.next()\n        }\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// An iterator that randomly produces another iterator's values, or produces a random special value\n/// from a [`Vec`].\n///\n/// Let $n_p$ be `p_numerator`, $d_p$ be `p_denominator`, and let $p=n_p/d_p$.\n///\n/// Every time a value is to be generated, the iterator uniformly samples the special values [`Vec`]\n/// with probability $p$, or else returns a value from the inner iterator.\n///\n/// If $p > 0$, the output length is infinite. Otherwise, it is the same as the length of `xs`.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `special_values` is empty, `p_denominator` is 0, or if `p_numerator` is greater than\n/// `p_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::{prefix_to_string, with_special_values};\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         with_special_values(\n///             EXAMPLE_SEED,\n///             vec![1, 2, 3],\n///             1,\n///             2,\n///             &random_primitive_ints::<i16>\n///         ),\n///         20,\n///     ),\n///     \"[3, 1, 3, 2901, 1, -14200, 2, 3, 1, -30997, -8245, -5338, 1, 1, -20007, 3, 1, 1, 1, 1, \\\n///     ...]\"\n/// );\n/// ```\npub fn with_special_values<I: Iterator>(\n    seed: Seed,\n    special_values: Vec<I::Item>,\n    p_numerator: u64,\n    p_denominator: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> WithSpecialValues<I>\nwhere\n    I::Item: Clone,\n{\n    WithSpecialValues {\n        bs: weighted_random_bools(seed.fork(\"bs\"), p_numerator, p_denominator),\n        special_values: random_values_from_vec(seed.fork(\"special_values\"), special_values),\n        xs: xs_gen(seed.fork(\"xs\")),\n    }\n}\n\n/// Generates sliding windows of elements from an iterator.\n///\n/// This `struct` is created by [`iter_windows`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct IterWindows<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    xs: I,\n    window: VecDeque<I::Item>,\n    window_size: usize,\n}\n\nimpl<I: Iterator> Iterator for IterWindows<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = VecDeque<I::Item>;\n\n    fn next(&mut self) -> Option<VecDeque<I::Item>> {\n        if self.window.len() < self.window_size {\n            self.window = (&mut self.xs).take(self.window_size).collect();\n            if self.window.len() < self.window_size {\n                None\n            } else {\n                Some(self.window.clone())\n            }\n        } else {\n            let x = self.xs.next()?;\n            self.window.pop_front();\n            self.window.push_back(x);\n            Some(self.window.clone())\n        }\n    }\n}\n\n/// Returns windows of $n$ adjacent elements of an iterator, advancing the window by 1 in each\n/// iteration. The values are cloned each time a new window is generated.\n///\n/// The output length is $n - k + 1$, where $n$ is `xs.count()` and $k$ is `window_size`.\n///\n/// # Panics\n/// Panics if `window_size` is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::iter_windows;\n///\n/// let xs = 0..=5;\n/// let windows = iter_windows(3, xs)\n///     .map(|ws| ws.iter().cloned().collect_vec())\n///     .collect_vec();\n/// assert_eq!(\n///     windows.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[&[0, 1, 2], &[1, 2, 3], &[2, 3, 4], &[3, 4, 5]]\n/// );\n/// ```\npub fn iter_windows<I: Iterator>(window_size: usize, xs: I) -> IterWindows<I>\nwhere\n    I::Item: Clone,\n{\n    assert_ne!(window_size, 0);\n    IterWindows {\n        xs,\n        window: VecDeque::with_capacity(window_size),\n        window_size,\n    }\n}\n\n/// Converts a prefix of an iterator to a string.\n///\n/// Suppose the iterator generates $(a, b, c, d)$. If `max_len` is 3, this function will return the\n/// string `\"[a, b, c, ...]\"`. If `max_len` is 4 or more, this function will return `[a, b, c, d]`.\n///\n/// This function will attempt to advance the iterator `max_len + 1` times. The extra time is used\n/// determine whether the output string should contain an ellipsis.\n///\n/// # Panics\n/// Panics if `max_len` is 0.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n///\n/// assert_eq!(prefix_to_string(0..10, 3), \"[0, 1, 2, ...]\");\n/// assert_eq!(prefix_to_string(0..4, 5), \"[0, 1, 2, 3]\");\n/// ```\npub fn prefix_to_string<I: Iterator>(mut xs: I, max_len: usize) -> String\nwhere\n    I::Item: Display,\n{\n    assert_ne!(max_len, 0);\n    let mut s = String::new();\n    s.push('[');\n    let mut first = true;\n    let mut done = false;\n    for _ in 0..max_len {\n        if let Some(x) = xs.next() {\n            if first {\n                first = false;\n            } else {\n                s.push_str(\", \");\n            }\n            s.push_str(&x.to_string());\n        } else {\n            done = true;\n            break;\n        }\n    }\n    if !done && xs.next().is_some() {\n        s.push_str(\", ...\");\n    }\n    s.push(']');\n    s\n}\n\n/// An iterator that generates the Thue-Morse sequence. See [`thue_morse_sequence`] for more\n/// information.\n#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]\npub struct ThueMorseSequence(u64);\n\nimpl Iterator for ThueMorseSequence {\n    type Item = bool;\n\n    fn next(&mut self) -> Option<bool> {\n        let b = self.0.count_ones().odd();\n        self.0 += 1;\n        Some(b)\n    }\n}\n\n/// Returns an iterator that generates the Thue-Morse sequence.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::thue_morse_sequence;\n///\n/// let s: String = thue_morse_sequence()\n///     .take(100)\n///     .map(|b| if b { '1' } else { '0' })\n///     .collect();\n/// assert_eq!(\n///     s,\n///     \"01101001100101101001011001101001100101100110100101101001100101101001011001101001011010011\\\n///     00101100110\"\n/// )\n/// ```\n#[inline]\npub const fn thue_morse_sequence() -> ThueMorseSequence {\n    ThueMorseSequence(0)\n}\n\n/// Contains [`BitDistributor`](bit_distributor::BitDistributor), which helps generate tuples\n/// exhaustively.\npub mod bit_distributor;\n/// Functions that compare adjacent iterator elements.\npub mod comparison;\n/// Contains [`IteratorCache`](iterator_cache::IteratorCache), which remembers values produced by an\n/// iterator.\npub mod iterator_cache;\n"
  },
  {
    "path": "malachite-base/src/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n//! This crate contains many utilities that are used by the\n//! [`malachite-nz`](https://docs.rs/malachite-nz/latest/malachite_nz/) and\n//! [`malachite-q`]((https://docs.rs/malachite-q/latest/malachite_q/)) crates. These utilities\n//! include\n//! - Traits that wrap functions from the standard library, like\n//!   [`CheckedAdd`](num::arithmetic::traits::CheckedAdd).\n//! - Traits that give extra functionality to primitive types, like\n//!   [`Gcd`](num::arithmetic::traits::Gcd), [`FloorSqrt`](num::arithmetic::traits::FloorSqrt), and\n//!   [`BitAccess`](num::logic::traits::BitAccess).\n//! - Iterator-producing functions that let you generate values for testing. Here's an example of\n//!   an iterator that produces all pairs of [`u32`]s:\n//!   ```\n//!   use malachite_base::num::exhaustive::exhaustive_unsigneds;\n//!   use malachite_base::tuples::exhaustive::exhaustive_pairs_from_single;\n//!\n//!   let mut pairs = exhaustive_pairs_from_single(exhaustive_unsigneds::<u32>());\n//!   assert_eq!(\n//!       pairs.take(20).collect::<Vec<_>>(),\n//!       &[\n//!           (0, 0), (0, 1), (1, 0), (1, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 0), (2, 1),\n//!           (3, 0), (3, 1), (2, 2), (2, 3), (3, 2), (3, 3), (0, 4), (0, 5), (1, 4), (1, 5)\n//!       ]\n//!   );\n//!   ```\n//! - The [`RoundingMode`](rounding_modes::RoundingMode) enum, which allows you to specify the\n//!   rounding behavior of various functions.\n//! - The [`NiceFloat`](num::float::NiceFloat) wrapper, which provides alternative implementations\n//!   of [`Eq`], [`Ord`], and [`Display`](std::fmt::Display) for floating-point values which are in\n//!   some ways nicer than the defaults.\n//!\n//! # Demos and benchmarks\n//! This crate comes with a `bin` target that can be used for running demos and benchmarks.\n//! - Almost all of the public functions in this crate have an associated demo. Running a demo\n//!   shows you a function's behavior on a large number of inputs. For example, to demo the\n//!   [`mod_pow`](num::arithmetic::traits::ModPow::mod_pow) function on [`u32`]s, you can use the\n//!   following command:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_mod_pow_u32\n//!   ```\n//!   This command uses the `exhaustive` mode, which generates every possible input, generally\n//!   starting with the simplest input and progressing to more complex ones. Another mode is\n//!   `random`. The `-l` flag specifies how many inputs should be generated.\n//! - You can use a similar command to run benchmarks. The following command benchmarks various\n//!   GCD algorithms for [`u64`]s:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n//!       benchmark_gcd_algorithms_u64 -o gcd-bench.gp\n//!   ```\n//!   This creates a file called gcd-bench.gp. You can use gnuplot to create an SVG from it like\n//!   so:\n//!   ```text\n//!   gnuplot -e \"set terminal svg; l \\\"gcd-bench.gp\\\"\" > gcd-bench.svg\n//!   ```\n//!\n//! The list of available demos and benchmarks is not documented anywhere; you must find them by\n//! browsing through\n//! [`bin_util/demo_and_bench`](https://github.com/mhogrefe/malachite/tree/master/malachite-base/src/bin_util/demo_and_bench).\n//!\n//! # Features\n//! - `test_build`: A large proportion of the code in this crate is only used for testing. For a\n//!   typical user, building this code would result in an unnecessarily long compilation time and\n//!   an unnecessarily large binary. Much of it is also used for testing\n//!   [`malachite-nz`](https://docs.rs/malachite-nz/latest/malachite_nz/) and\n//!   [`malachite-q`](https://docs.rs/malachite-q/latest/malachite_q/), so it can't just be\n//!   confined to the `tests` directory. My solution is to only build this code when the\n//!   `test_build` feature is enabled. If you want to run unit tests, you must enable `test_build`.\n//!   However, doctests don't require it, since they only test the public interface.\n//! - `bin_build`: This feature is used to build the code for demos and benchmarks, which also\n//!   takes a long time to build. Enabling this feature also enables `test_build`.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n#![cfg_attr(\n    not(any(feature = \"test_build\", feature = \"random\", feature = \"std\")),\n    no_std\n)]\n\n#[macro_use]\nextern crate alloc;\n\n#[cfg(feature = \"test_build\")]\n#[doc(hidden)]\n#[inline]\npub fn fail_on_untested_path(message: &str) {\n    panic!(\"Untested path. {message}\");\n}\n\n#[cfg(not(feature = \"test_build\"))]\n#[doc(hidden)]\n#[inline]\npub const fn fail_on_untested_path(_message: &str) {}\n\n// TODO links for malachite-nz and malachite-q\n\n/// The [`Named`](named::Named) trait, for getting a type's name.\n#[macro_use]\npub mod named;\n\n#[doc(hidden)]\n#[macro_use]\npub mod macros;\n\n/// Functions for working with [`bool`]s.\n#[macro_use]\npub mod bools;\n/// Functions for working with [`char`]s.\n#[macro_use]\npub mod chars;\n/// Macros and traits related to comparing values.\npub mod comparison;\n/// Functions and adaptors for iterators.\npub mod iterators;\n/// [`Never`](nevers::Never), a type that cannot be instantiated.\npub mod nevers;\n/// Functions for working with primitive integers and floats.\n#[macro_use]\npub mod num;\n/// Functions for working with [`Ordering`](std::cmp::Ordering)s.\npub mod options;\n/// Functions for working with [`Option`]s.\npub mod orderings;\n#[cfg(feature = \"random\")]\n/// Functions for generating random values.\npub mod random;\n/// [`RationalSequence`](rational_sequences::RationalSequence), a type representing a sequence that\n/// is finite or eventually repeating, just like the digits of a rational number.\npub mod rational_sequences;\n/// [`RoundingMode`](rounding_modes::RoundingMode), an enum used to specify rounding behavior.\npub mod rounding_modes;\n/// Functions for working with [`HashSet`](std::collections::HashSet)s and\n/// [`BTreeSet`](std::collections::BTreeSet)s.\npub mod sets;\n/// Functions for working with slices.\n#[macro_use]\npub mod slices;\n/// Functions for working with [`String`]s.\npub mod strings;\n/// Functions for working with tuples.\npub mod tuples;\n/// Unions (sum types). These are essentially generic enums.\n///\n/// # unwrap\n/// ```\n/// use malachite_base::union_struct;\n/// use malachite_base::unions::UnionFromStrError;\n/// use std::fmt::{self, Display, Formatter};\n/// use std::str::FromStr;\n///\n/// union_struct!(\n///     (pub(crate)),\n///     Union3,\n///     Union3<T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c]\n/// );\n///\n/// let mut u: Union3<char, char, char>;\n///\n/// u = Union3::A('a');\n/// assert_eq!(u.unwrap(), 'a');\n///\n/// u = Union3::B('b');\n/// assert_eq!(u.unwrap(), 'b');\n///\n/// u = Union3::C('c');\n/// assert_eq!(u.unwrap(), 'c');\n/// ```\n///\n/// # fmt\n/// ```\n/// use malachite_base::union_struct;\n/// use malachite_base::unions::UnionFromStrError;\n/// use std::fmt::{self, Display, Formatter};\n/// use std::str::FromStr;\n///\n/// union_struct!(\n///     (pub(crate)),\n///     Union3,\n///     Union3<T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c]\n/// );\n///\n/// let mut u: Union3<char, u32, bool>;\n///\n/// u = Union3::A('a');\n/// assert_eq!(u.to_string(), \"A(a)\");\n///\n/// u = Union3::B(5);\n/// assert_eq!(u.to_string(), \"B(5)\");\n///\n/// u = Union3::C(false);\n/// assert_eq!(u.to_string(), \"C(false)\");\n/// ```\n///\n/// # from_str\n/// ```\n/// use malachite_base::union_struct;\n/// use malachite_base::unions::UnionFromStrError;\n/// use std::fmt::{self, Display, Formatter};\n/// use std::str::FromStr;\n///\n/// union_struct!(\n///     (pub(crate)),\n///     Union3,\n///     Union3<T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c]\n/// );\n///\n/// let u3: Union3<bool, u32, char> = Union3::from_str(\"B(5)\").unwrap();\n/// assert_eq!(u3, Union3::B(5));\n///\n/// let result: Result<Union3<char, u32, bool>, _> = Union3::from_str(\"xyz\");\n/// assert_eq!(result, Err(UnionFromStrError::Generic(\"xyz\".to_string())));\n///\n/// let result: Result<Union3<char, u32, bool>, _> = Union3::from_str(\"A(ab)\");\n/// if let Err(UnionFromStrError::Specific(Union3::A(_e))) = result {\n/// } else {\n///     panic!(\"wrong error variant\")\n/// }\n/// ```\npub mod unions;\n/// Functions for working with [`Vec`]s.\npub mod vecs;\n\n#[cfg(feature = \"test_build\")]\npub mod test_util;\n\npub mod platform;\n"
  },
  {
    "path": "malachite-base/src/macros/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[doc(hidden)]\n#[cfg(feature = \"test_build\")]\n#[macro_export]\nmacro_rules! pub_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(not(feature = \"test_build\"))]\n#[macro_export]\nmacro_rules! pub_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(feature = \"test_build\")]\n#[macro_export]\nmacro_rules! pub_crate_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(not(feature = \"test_build\"))]\n#[macro_export]\nmacro_rules! pub_crate_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub(crate) fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(feature = \"test_build\")]\n#[macro_export]\nmacro_rules! pub_test_struct {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub struct $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(not(feature = \"test_build\"))]\n#[macro_export]\nmacro_rules! pub_test_struct {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub struct $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(feature = \"test_build\")]\n#[macro_export]\nmacro_rules! pub_crate_test_struct {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub struct $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(not(feature = \"test_build\"))]\n#[macro_export]\nmacro_rules! pub_crate_test_struct {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub(crate) struct $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(feature = \"test_build\")]\n#[macro_export]\nmacro_rules! pub_const_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub const fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(not(feature = \"test_build\"))]\n#[macro_export]\nmacro_rules! pub_const_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        const fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(feature = \"test_build\")]\n#[macro_export]\nmacro_rules! pub_const_crate_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub const fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(not(feature = \"test_build\"))]\n#[macro_export]\nmacro_rules! pub_const_crate_test {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub(crate) const fn $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(feature = \"test_build\")]\n#[macro_export]\nmacro_rules! pub_const_crate_test_const {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub const $name $( $body )*\n    };\n}\n\n#[doc(hidden)]\n#[cfg(not(feature = \"test_build\"))]\n#[macro_export]\nmacro_rules! pub_const_crate_test_const {\n    ($( #[$meta:meta] )* $name:ident $( $body:tt )*) => {\n        $( #[$meta] )*\n        pub(crate) const $name $( $body )*\n    };\n}\n"
  },
  {
    "path": "malachite-base/src/named/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Defines the name of a type. This is useful for constructing error messages in a generic\n/// function.\npub trait Named {\n    /// The name of `Self`.\n    const NAME: &'static str;\n}\n\n/// Automatically implements [`Named`] for a type.\n///\n/// It doesn't work very well for types whose names contain several tokens, like `(u8, u8)`, `&str`,\n/// or `Vec<bool>`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::named::Named;\n///\n/// assert_eq!(u8::NAME, \"u8\");\n/// assert_eq!(String::NAME, \"String\");\n/// ```\n#[macro_export]\nmacro_rules! impl_named {\n    ($t:ident) => {\n        impl Named for $t {\n            /// The name of this type, as given by the [`stringify`] macro.\n            ///\n            /// See the documentation for [`impl_named`] for more details.\n            const NAME: &'static str = stringify!($t);\n        }\n    };\n}\n"
  },
  {
    "path": "malachite-base/src/nevers/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::fmt::{Display, Formatter};\nuse core::iter::{Empty, empty};\nuse core::str::FromStr;\n\n/// `Never` is a type that cannot be instantiated.\n///\n/// This is a [bottom type](https://en.wikipedia.org/wiki/Bottom_type).\n///\n/// # Examples\n/// ```\n/// use malachite_base::nevers::Never;\n///\n/// let _x: Option<Never> = None;\n/// ```\n#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)]\npub enum Never {}\n\nimpl Display for Never {\n    /// Would convert a [`Never`] to a [`String`].\n    fn fmt(&self, _f: &mut Formatter) -> core::fmt::Result {\n        unreachable!()\n    }\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct NeverError;\n\nimpl FromStr for Never {\n    type Err = NeverError;\n\n    /// Would convert a [`String`] to a [`Never`].\n    ///\n    /// Since a [`Never`] can never be instantiated, `from_str` never succeeds.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::nevers::{Never, NeverError};\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Never::from_str(\"abc\"), Err(NeverError));\n    /// ```\n    #[inline]\n    fn from_str(_: &str) -> Result<Self, NeverError> {\n        Err(NeverError)\n    }\n}\n\n/// Generates all (none) of the [`Never`]s.\n///\n/// The output length is 0.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::nevers::nevers;\n///\n/// assert_eq!(nevers().collect_vec(), &[]);\n/// ```\npub const fn nevers() -> Empty<Never> {\n    empty()\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Abs, AbsAssign, UnsignedAbs};\n\nmacro_rules! impl_abs_primitive_int {\n    ($u:ident, $s:ident) => {\n        impl Abs for $s {\n            type Output = $s;\n\n            /// This is a wrapper over the `abs` functions in the standard library, for example\n            /// [this one](i32::abs).\n            #[inline]\n            fn abs(self) -> $s {\n                $s::abs(self)\n            }\n        }\n\n        impl AbsAssign for $s {\n            /// Replaces a number with its absolute value.\n            ///\n            /// $x \\gets |x|$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::abs#abs_assign).\n            #[inline]\n            fn abs_assign(&mut self) {\n                *self = self.abs();\n            }\n        }\n\n        impl UnsignedAbs for $s {\n            type Output = $u;\n\n            /// This is a wrapper over the `unsigned_abs` functions in the standard library, for\n            /// example [this one](i32::unsigned_abs).\n            #[inline]\n            fn unsigned_abs(self) -> $u {\n                self.unsigned_abs()\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_abs_primitive_int);\n\nmacro_rules! impl_abs_primitive_float {\n    ($f:ident) => {\n        impl Abs for $f {\n            type Output = $f;\n\n            /// This is a wrapper over the `fabs` functions from [`libm`].\n            #[inline]\n            fn abs(self) -> $f {\n                libm::Libm::<$f>::fabs(self)\n            }\n        }\n\n        impl AbsAssign for $f {\n            /// Replaces a number with its absolute value.\n            ///\n            /// $x \\gets |x|$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::abs#abs_assign).\n            #[inline]\n            fn abs_assign(&mut self) {\n                *self = self.abs();\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_abs_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{AbsDiff, AbsDiffAssign};\n\nmacro_rules! impl_abs_diff_unsigned {\n    ($t:ident) => {\n        impl AbsDiff for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `abs_diff` functions in the standard library, for example\n            /// [this one](u32::abs_diff).\n            #[inline]\n            fn abs_diff(self, other: $t) -> $t {\n                self.abs_diff(other)\n            }\n        }\n\n        impl AbsDiffAssign for $t {\n            /// Subtracts a number by another and takes the absolute value, in place. The output\n            /// type is the unsigned type with the same width.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::abs_diff#abs_diff_assign).\n            #[inline]\n            fn abs_diff_assign(&mut self, other: $t) {\n                *self = self.abs_diff(other);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_abs_diff_unsigned);\n\nmacro_rules! impl_abs_diff_signed {\n    ($u:ident, $s:ident) => {\n        impl AbsDiff for $s {\n            type Output = $u;\n\n            /// This is a wrapper over the `abs_diff` functions in the standard library, for example\n            /// [this one](i32::abs_diff).\n            #[inline]\n            fn abs_diff(self, other: $s) -> $u {\n                self.abs_diff(other)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_abs_diff_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{AddMul, AddMulAssign, WrappingAddMul, WrappingAddMulAssign};\n\nmacro_rules! impl_add_mul_primitive_int {\n    ($t:ident) => {\n        impl AddMul for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers.\n            ///\n            /// $f(x, y, z) = x + yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::add_mul#add_mul).\n            #[inline]\n            fn add_mul(self, y: $t, z: $t) -> $t {\n                self.wrapping_add_mul(y, z)\n            }\n        }\n\n        impl AddMulAssign<$t> for $t {\n            /// Adds the product of two other numbers to a number in place.\n            ///\n            /// $x \\gets x + yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::add_mul#add_mul_assign).\n            #[inline]\n            fn add_mul_assign(&mut self, y: $t, z: $t) {\n                self.wrapping_add_mul_assign(y, z)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_add_mul_primitive_int);\n\nmacro_rules! impl_add_mul_primitive_float {\n    ($t:ident) => {\n        impl AddMul for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers.\n            ///\n            /// $f(x, y, z) = x + yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::add_mul#add_mul).\n            #[inline]\n            fn add_mul(self, y: $t, z: $t) -> $t {\n                self + y * z\n            }\n        }\n\n        impl AddMulAssign<$t> for $t {\n            /// Adds the product of two other numbers to a number in place.\n            ///\n            /// $x \\gets x + yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::add_mul#add_mul_assign).\n            #[inline]\n            fn add_mul_assign(&mut self, y: $t, z: $t) {\n                *self += y * z;\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_add_mul_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/arithmetic_checked_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ArithmeticCheckedShl, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse core::ops::{Shl, Shr};\n\nfn arithmetic_checked_shl_unsigned_unsigned<\n    T: PrimitiveUnsigned + Shl<U, Output = T> + Shr<U, Output = T>,\n    U: Copy + Ord + WrappingFrom<u64>,\n>(\n    x: T,\n    bits: U,\n) -> Option<T> {\n    if x == T::ZERO {\n        Some(x)\n    } else if bits >= U::wrapping_from(T::WIDTH) {\n        None\n    } else {\n        let result = x << bits;\n        if result >> bits == x {\n            Some(result)\n        } else {\n            None\n        }\n    }\n}\n\nmacro_rules! impl_arithmetic_checked_shl_unsigned_unsigned {\n    ($t:ident) => {\n        macro_rules! impl_arithmetic_checked_shl_unsigned_unsigned_inner {\n            ($u:ident) => {\n                impl ArithmeticCheckedShl<$u> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2). If the result is too\n                    /// large to be represented, `None` is returned.\n                    ///\n                    /// Zero may be shifted by any amount.\n                    ///\n                    /// $$\n                    /// f(x, b) = \\\\begin{cases}\n                    ///     \\operatorname{Some}(2^b x) & \\text{if} \\\\quad 2^b x < 2^W, \\\\\\\\\n                    ///     \\operatorname{None} & \\text{if} \\\\quad 2^b x \\geq 2^W,\n                    /// \\\\end{cases}\n                    /// $$\n                    /// where $W$ is `Self::WIDTH`.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::arithmetic_checked_shl#arithmetic_checked_shl).\n                    #[inline]\n                    fn arithmetic_checked_shl(self, bits: $u) -> Option<$t> {\n                        arithmetic_checked_shl_unsigned_unsigned(self, bits)\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_arithmetic_checked_shl_unsigned_unsigned_inner);\n    };\n}\napply_to_unsigneds!(impl_arithmetic_checked_shl_unsigned_unsigned);\n\nfn arithmetic_checked_shl_unsigned_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveUnsigned + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    bits: S,\n) -> Option<T> {\n    if bits >= S::ZERO {\n        x.arithmetic_checked_shl(bits.unsigned_abs())\n    } else {\n        let abs_bits = bits.unsigned_abs();\n        Some(if abs_bits >= U::wrapping_from(T::WIDTH) {\n            T::ZERO\n        } else {\n            x >> abs_bits\n        })\n    }\n}\n\nmacro_rules! impl_arithmetic_checked_shl_unsigned_signed {\n    ($t:ident) => {\n        macro_rules! impl_arithmetic_checked_shl_unsigned_signed_inner {\n            ($u:ident) => {\n                impl ArithmeticCheckedShl<$u> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2). If the result is too\n                    /// large to be represented, `None` is returned.\n                    ///\n                    /// Zero may be shifted by any amount, and any number may be shifted by any\n                    /// negative amount; shifting by a negative amount with a high absolute value\n                    /// returns `Some(0)`.\n                    ///\n                    /// $$\n                    /// f(x, b) = \\\\begin{cases}\n                    ///     \\operatorname{Some}(2^b x) &\n                    ///         \\text{if} \\\\quad b \\geq 0 \\\\ \\mathrm{and}\\\\ 2^b x < 2^W, \\\\\\\\\n                    ///     \\operatorname{None} &\n                    ///         \\text{if} \\\\quad b \\geq 0 \\\\ \\mathrm{and} \\\\ 2^b x \\geq 2^W, \\\\\\\\\n                    ///     \\operatorname{Some}(\\lfloor x/2^{-b} \\rfloor) &\n                    ///         \\text{if} \\\\quad b < 0,\n                    /// \\\\end{cases}\n                    /// $$\n                    /// where $W$ is `Self::WIDTH`.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::arithmetic_checked_shl#arithmetic_checked_shl).\n                    #[inline]\n                    fn arithmetic_checked_shl(self, bits: $u) -> Option<$t> {\n                        arithmetic_checked_shl_unsigned_signed(self, bits)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_arithmetic_checked_shl_unsigned_signed_inner);\n    };\n}\napply_to_unsigneds!(impl_arithmetic_checked_shl_unsigned_signed);\n\nfn arithmetic_checked_shl_signed_unsigned<\n    U: ArithmeticCheckedShl<B, Output = U> + PrimitiveUnsigned,\n    S: TryFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    B,\n>(\n    x: S,\n    bits: B,\n) -> Option<S> {\n    let abs = x.unsigned_abs();\n    if x >= S::ZERO {\n        abs.arithmetic_checked_shl(bits)\n            .and_then(|x| S::try_from(x).ok())\n    } else {\n        abs.arithmetic_checked_shl(bits).and_then(|x| {\n            if x == S::MIN.unsigned_abs() {\n                Some(S::MIN)\n            } else {\n                S::try_from(x).ok().map(|y| -y)\n            }\n        })\n    }\n}\n\nmacro_rules! impl_arithmetic_checked_shl_signed_unsigned {\n    ($t:ident) => {\n        macro_rules! impl_arithmetic_checked_shl_signed_unsigned_inner {\n            ($u:ident) => {\n                impl ArithmeticCheckedShl<$u> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2). If the result is too\n                    /// large to be represented, `None` is returned.\n                    ///\n                    /// Zero may be shifted by any amount.\n                    ///\n                    /// $$\n                    /// f(x, b) = \\\\begin{cases}\n                    ///     \\operatorname{Some}(2^b x) &\n                    ///         \\text{if} \\\\quad -2^{W-1} \\leq 2^b x < 2^{W-1}, \\\\\\\\\n                    ///     \\operatorname{None} &\n                    ///         \\text{if} \\\\quad 2^b x < -2^{W-1} \\\\ \\mathrm{or}\n                    ///         \\\\ 2^b x \\geq 2^{W-1}, \\\\\\\\\n                    /// \\\\end{cases}\n                    /// $$\n                    /// where $W$ is `Self::WIDTH`.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::arithmetic_checked_shl#arithmetic_checked_shl).\n                    #[inline]\n                    fn arithmetic_checked_shl(self, bits: $u) -> Option<$t> {\n                        arithmetic_checked_shl_signed_unsigned(self, bits)\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_arithmetic_checked_shl_signed_unsigned_inner);\n    };\n}\napply_to_signeds!(impl_arithmetic_checked_shl_signed_unsigned);\n\nfn arithmetic_checked_shl_signed_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveSigned + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    bits: S,\n) -> Option<T> {\n    if bits >= S::ZERO {\n        x.arithmetic_checked_shl(bits.unsigned_abs())\n    } else {\n        let width = U::wrapping_from(T::WIDTH);\n        let abs_bits = bits.unsigned_abs();\n        Some(if width != U::ZERO && abs_bits >= width {\n            -T::from(x < T::ZERO)\n        } else {\n            x >> abs_bits\n        })\n    }\n}\n\nmacro_rules! impl_arithmetic_checked_shl_signed_signed {\n    ($t:ident) => {\n        macro_rules! impl_arithmetic_checked_shl_signed_signed_inner {\n            ($u:ident) => {\n                impl ArithmeticCheckedShl<$u> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2). If the result is too\n                    /// large to be represented, `None` is returned.\n                    ///\n                    /// Zero may be shifted by any amount, and any number may be shifted by any\n                    /// negative amount; shifting by a negative amount with a high absolute value\n                    /// returns `Some(0)` if `self` is positive, and `Some(-1)` if `self` is\n                    /// negative.\n                    ///\n                    /// $$\n                    /// f(x, b) = \\\\begin{cases}\n                    ///     \\operatorname{Some}(2^b x) &\n                    ///         \\text{if} \\\\quad b \\geq 0 \\\\ \\mathrm{and}\n                    ///         \\\\ -2^{W-1} \\leq 2^b x < 2^{W-1}, \\\\\\\\\n                    ///     \\operatorname{None} &\n                    ///         \\text{if} \\\\quad b \\geq 0 \\\\ \\mathrm{and}\n                    ///         \\\\ (2^b x < -2^{W-1} \\\\ \\mathrm{or} \\\\ 2^b x \\geq 2^{W-1}), \\\\\\\\\n                    ///     \\operatorname{Some}(\\lfloor x/2^{-b} \\rfloor) & \\text{if} \\\\quad b < 0,\n                    /// \\\\end{cases}\n                    /// $$\n                    /// where $W$ is `Self::WIDTH`.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::arithmetic_checked_shl#arithmetic_checked_shl).\n                    fn arithmetic_checked_shl(self, bits: $u) -> Option<$t> {\n                        arithmetic_checked_shl_signed_signed(self, bits)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_arithmetic_checked_shl_signed_signed_inner);\n    };\n}\napply_to_signeds!(impl_arithmetic_checked_shl_signed_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/arithmetic_checked_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ArithmeticCheckedShl, ArithmeticCheckedShr, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse core::ops::Shr;\n\nfn arithmetic_checked_shr_unsigned_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveUnsigned + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    bits: S,\n) -> Option<T> {\n    if bits < S::ZERO {\n        x.arithmetic_checked_shl(bits.unsigned_abs())\n    } else {\n        let abs_bits = bits.unsigned_abs();\n        Some(if abs_bits >= U::wrapping_from(T::WIDTH) {\n            T::ZERO\n        } else {\n            x >> abs_bits\n        })\n    }\n}\n\nmacro_rules! impl_arithmetic_checked_shr_unsigned_signed {\n    ($t:ident) => {\n        macro_rules! impl_arithmetic_checked_shr_unsigned_signed_inner {\n            ($u:ident) => {\n                impl ArithmeticCheckedShr<$u> for $t {\n                    type Output = $t;\n\n                    /// Shifts a number right (divides it by a power of 2). If the result is too\n                    /// large to be represented, `None` is returned.\n                    ///\n                    /// Zero may be shifted by any amount, and any number may be shifted by any\n                    /// non-negative amount; shifting by a large amount returns `Some(0)`.\n                    ///\n                    /// $$\n                    /// f(x, b) = \\\\begin{cases}\n                    ///     \\operatorname{Some}(\\lfloor x/2^b \\rfloor) &\n                    ///         \\text{if} \\\\quad b \\geq 0, \\\\\\\\\n                    ///     \\operatorname{Some}(2^{-b} x) &\n                    ///         \\text{if} \\\\quad b < 0 \\\\ \\mathrm{and} \\\\ 2^{-b} x < 2^W, \\\\\\\\\n                    ///     \\operatorname{None} &\n                    ///         \\text{if} \\\\quad b < 0 \\\\ \\mathrm{and} \\\\ 2^{-b} x \\geq 2^W, \\\\\\\\\n                    /// \\\\end{cases}\n                    /// $$\n                    /// where $W$ is `Self::WIDTH`.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::arithmetic_checked_shr#arithmetic_checked_shr).\n                    #[inline]\n                    fn arithmetic_checked_shr(self, bits: $u) -> Option<$t> {\n                        arithmetic_checked_shr_unsigned_signed(self, bits)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_arithmetic_checked_shr_unsigned_signed_inner);\n    };\n}\napply_to_unsigneds!(impl_arithmetic_checked_shr_unsigned_signed);\n\nfn arithmetic_checked_shr_signed_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveSigned + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    bits: S,\n) -> Option<T> {\n    if bits < S::ZERO {\n        x.arithmetic_checked_shl(bits.unsigned_abs())\n    } else {\n        let width = U::wrapping_from(T::WIDTH);\n        let abs_bits = bits.unsigned_abs();\n        Some(if width != U::ZERO && abs_bits >= width {\n            -T::from(x < T::ZERO)\n        } else {\n            x >> abs_bits\n        })\n    }\n}\n\nmacro_rules! impl_arithmetic_checked_shr_signed_signed {\n    ($t:ident) => {\n        macro_rules! impl_arithmetic_checked_shr_signed_signed_inner {\n            ($u:ident) => {\n                impl ArithmeticCheckedShr<$u> for $t {\n                    type Output = $t;\n\n                    /// Shifts a number right (divides it by a power of 2). If the result is too\n                    /// large to be represented, `None` is returned.\n                    ///\n                    /// Zero may be shifted by any amount, and any number may be shifted by any\n                    /// non-negative amount; shifting by a large amount returns `Some(0)` if `self`\n                    /// is positive, and `Some(-1)` if `self` is negative.\n                    ///\n                    /// $$\n                    /// f(x, b) = \\\\begin{cases}\n                    ///     \\operatorname{Some}(\\lfloor x/2^b \\rfloor) &\n                    ///         \\text{if} \\\\quad b \\geq 0, \\\\\\\\\n                    ///     \\operatorname{Some}(2^{-b} x) &\n                    ///         \\text{if} \\\\quad b < 0 \\\\ \\mathrm{and}\n                    ///         \\\\ -2^{W-1} \\leq 2^{-b} x < 2^{W-1}, \\\\\\\\\n                    ///     \\operatorname{None} &\n                    ///         \\text{if} \\\\quad b < 0 \\\\ \\mathrm{and}\n                    ///         \\\\ (2^{-b} x < -2^{W-1} \\\\ \\mathrm{or}\n                    ///         \\\\ 2^{-b} x \\geq 2^{W-1}), \\\\\\\\\n                    /// \\\\end{cases}\n                    /// $$\n                    /// where $W$ is `Self::WIDTH`.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::arithmetic_checked_shr#arithmetic_checked_shr).\n                    #[inline]\n                    fn arithmetic_checked_shr(self, bits: $u) -> Option<$t> {\n                        arithmetic_checked_shr_signed_signed(self, bits)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_arithmetic_checked_shr_signed_signed_inner);\n    };\n}\napply_to_signeds!(impl_arithmetic_checked_shr_signed_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    BinomialCoefficient, CheckedBinomialCoefficient, UnsignedAbs,\n};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::OverflowingFrom;\nuse crate::num::exhaustive::primitive_int_increasing_inclusive_range;\nuse core::cmp::min;\n\nfn checked_binomial_coefficient_unsigned<T: PrimitiveUnsigned>(n: T, mut k: T) -> Option<T> {\n    if k > n {\n        return Some(T::ZERO);\n    }\n    k = min(k, n - k);\n    if k == T::ZERO {\n        Some(T::ONE)\n    } else if k == T::ONE {\n        Some(n)\n    } else if k == T::TWO {\n        (if n.even() { n - T::ONE } else { n }).checked_mul(n >> 1)\n    } else {\n        // Some binomial coefficient algorithms have intermediate results greater than the final\n        // result, risking overflow. This one does not.\n        let mut product = n - k + T::ONE;\n        let mut numerator = product;\n        for i in primitive_int_increasing_inclusive_range(T::TWO, k) {\n            numerator += T::ONE;\n            let gcd = numerator.gcd(i);\n            product /= i / gcd;\n            product = product.checked_mul(numerator / gcd)?;\n        }\n        Some(product)\n    }\n}\n\nfn checked_binomial_coefficient_signed<\n    U: PrimitiveUnsigned,\n    S: OverflowingFrom<U> + PrimitiveSigned + TryFrom<U> + UnsignedAbs<Output = U>,\n>(\n    n: S,\n    k: S,\n) -> Option<S> {\n    if k < S::ZERO {\n        return None;\n    }\n    if n >= S::ZERO {\n        S::try_from(U::checked_binomial_coefficient(\n            n.unsigned_abs(),\n            k.unsigned_abs(),\n        )?)\n        .ok()\n    } else {\n        let k = k.unsigned_abs();\n        let b = U::checked_binomial_coefficient(n.unsigned_abs() + k - U::ONE, k)?;\n        if k.even() {\n            S::try_from(b).ok()\n        } else {\n            let (b, overflow) = S::overflowing_from(b);\n            if overflow {\n                if b == S::MIN { Some(S::MIN) } else { None }\n            } else {\n                Some(-b)\n            }\n        }\n    }\n}\n\nmacro_rules! impl_binomial_coefficient_unsigned {\n    ($t:ident) => {\n        impl CheckedBinomialCoefficient for $t {\n            /// Computes the binomial coefficient of two numbers. If the inputs are too large, the\n            /// function returns `None`.\n            ///\n            /// $$\n            /// f(n, k) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\binom{n}{k}) & \\text{if} \\\\quad \\binom{n}{k} < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad \\binom{n}{k} \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// $T(k) = O(k)$\n            ///\n            /// $M(k) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $k$ is `k`.\n            ///\n            /// # Examples\n            /// See [here](super::binomial_coefficient#checked_binomial_coefficient).\n            #[inline]\n            fn checked_binomial_coefficient(n: $t, k: $t) -> Option<$t> {\n                checked_binomial_coefficient_unsigned(n, k)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_binomial_coefficient_unsigned);\n\nmacro_rules! impl_binomial_coefficient_signed {\n    ($t:ident) => {\n        impl CheckedBinomialCoefficient for $t {\n            /// Computes the binomial coefficient of two numbers. If the inputs are too large, the\n            /// function returns `None`.\n            ///\n            /// The second argument must be non-negative, but the first may be negative. If it is,\n            /// the identity $\\binom{-n}{k} = (-1)^k \\binom{n+k-1}{k}$ is used.\n            ///\n            /// $$\n            /// f(n, k) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\binom{n}{k}) & \\text{if} \\\\quad n \\geq 0 \\\\ \\text{and}\n            ///         \\\\ -2^{W-1} \\leq \\binom{n}{k} < 2^{W-1}, \\\\\\\\\n            ///     \\operatorname{Some}((-1)^k \\binom{-n+k-1}{k}) & \\text{if} \\\\quad n < 0\n            ///         \\\\ \\text{and} \\\\ -2^{W-1} \\leq \\binom{n}{k} < 2^{W-1}, \\\\\\\\\n            ///     \\operatorname{None} & \\\\quad \\\\text{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// $T(k) = O(k)$\n            ///\n            /// $M(k) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $k$ is `k.abs()`.\n            ///\n            /// # Examples\n            /// See [here](super::binomial_coefficient#checked_binomial_coefficient).\n            #[inline]\n            fn checked_binomial_coefficient(n: $t, k: $t) -> Option<$t> {\n                checked_binomial_coefficient_signed(n, k)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_binomial_coefficient_signed);\n\nmacro_rules! impl_binomial_coefficient_primitive_int {\n    ($t:ident) => {\n        impl BinomialCoefficient for $t {\n            /// Computes the binomial coefficient of two numbers. If the inputs are too large, the\n            /// function panics.\n            ///\n            /// The second argument must be non-negative, but the first may be negative. If it is,\n            /// the identity $\\binom{-n}{k} = (-1)^k \\binom{n+k-1}{k}$ is used.\n            ///\n            /// $$\n            /// f(n, k) = \\\\begin{cases}\n            ///     \\binom{n}{k} & \\text{if} \\\\quad n \\geq 0, \\\\\\\\\n            ///     (-1)^k \\binom{-n+k-1}{k} & \\text{if} \\\\quad n < 0.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(k) = O(k)$\n            ///\n            /// $M(k) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $k$ is `k.abs()`.\n            ///\n            /// # Panics\n            /// Panics if the result is not representable by this type, or if $k$ is negative.\n            ///\n            /// # Examples\n            /// See [here](super::binomial_coefficient#binomial_coefficient).\n            #[inline]\n            fn binomial_coefficient(n: $t, k: $t) -> $t {\n                $t::checked_binomial_coefficient(n, k).unwrap()\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_binomial_coefficient_primitive_int);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/ceiling.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Ceiling, CeilingAssign};\n\nmacro_rules! impl_ceiling {\n    ($f:ident) => {\n        impl Ceiling for $f {\n            type Output = $f;\n\n            /// This is a wrapper over the `ceil` functions in [`libm`]\n            #[inline]\n            fn ceiling(self) -> $f {\n                libm::Libm::<$f>::ceil(self)\n            }\n        }\n\n        impl CeilingAssign for $f {\n            /// Replaces a number with its ceiling.\n            ///\n            /// A number's ceiling is the smallest integer greater than or equal to the number.\n            ///\n            /// $x \\gets \\lceil x \\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::ceiling#ceiling_assign).\n            #[inline]\n            fn ceiling_assign(&mut self) {\n                *self = self.ceiling();\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_ceiling);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedAbs;\n\nmacro_rules! impl_checked_abs {\n    ($t:ident) => {\n        impl CheckedAbs for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_abs` functions in the standard library, for\n            /// example [this one](i32::checked_abs).\n            #[inline]\n            fn checked_abs(self) -> Option<$t> {\n                $t::checked_abs(self)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_checked_abs);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedAdd;\n\nmacro_rules! impl_checked_add {\n    ($t:ident) => {\n        impl CheckedAdd<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_add` functions in the standard library, for\n            /// example [this one](u32::checked_add).\n            #[inline]\n            fn checked_add(self, other: $t) -> Option<$t> {\n                $t::checked_add(self, other)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_checked_add);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedAddMul, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\nfn checked_add_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> Option<T> {\n    y.checked_mul(z).and_then(|yz| x.checked_add(yz))\n}\n\nmacro_rules! impl_checked_add_mul_unsigned {\n    ($t:ident) => {\n        impl CheckedAddMul<$t> for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers, returning `None` if the result\n            /// cannot be represented.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     \\operatorname{Some}(x + yz) & \\text{if} \\\\quad x + yz < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad x + yz \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::checked_add_mul#checked_add_mul).\n            #[inline]\n            fn checked_add_mul(self, y: $t, z: $t) -> Option<$t> {\n                checked_add_mul_unsigned(self, y, z)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_checked_add_mul_unsigned);\n\nfn checked_add_mul_signed<\n    U: PrimitiveUnsigned,\n    T: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: T,\n    y: T,\n    z: T,\n) -> Option<T> {\n    if y == T::ZERO || z == T::ZERO {\n        return Some(x);\n    }\n    let x_sign = x >= T::ZERO;\n    if x_sign == ((y >= T::ZERO) == (z >= T::ZERO)) {\n        x.checked_add(y.checked_mul(z)?)\n    } else {\n        let x = x.unsigned_abs();\n        let product = y.unsigned_abs().checked_mul(z.unsigned_abs())?;\n        let result = T::wrapping_from(if x_sign {\n            x.wrapping_sub(product)\n        } else {\n            product.wrapping_sub(x)\n        });\n        if x >= product || (x_sign == (result < T::ZERO)) {\n            Some(result)\n        } else {\n            None\n        }\n    }\n}\n\nmacro_rules! impl_checked_add_mul_signed {\n    ($t:ident) => {\n        impl CheckedAddMul<$t> for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers, returning `None` if the result\n            /// cannot be represented.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     \\operatorname{Some}(x + yz) &\n            ///         \\text{if} \\\\quad -2^{W-1} \\leq x + yz < 2^{W-1}, \\\\\\\\\n            ///     \\operatorname{None} &\n            ///         \\text{if} \\\\quad x + yz < -2^{W-1} \\\\ \\mathrm{or}\n            ///         \\\\ x + yz \\geq 2^{W-1}, \\\\\\\\\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::checked_add_mul#checked_add_mul).\n            #[inline]\n            fn checked_add_mul(self, y: $t, z: $t) -> Option<$t> {\n                checked_add_mul_signed(self, y, z)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_checked_add_mul_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedDiv;\n\nmacro_rules! impl_checked_div {\n    ($t:ident) => {\n        impl CheckedDiv<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_div` functions in the standard library, for\n            /// example [this one](u32::checked_div).\n            #[inline]\n            fn checked_div(self, other: $t) -> Option<$t> {\n                $t::checked_div(self, other)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_checked_div);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedMul;\n\nmacro_rules! impl_checked_mul {\n    ($t:ident) => {\n        impl CheckedMul<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_mul` functions in the standard library, for\n            /// example [this one](u32::checked_mul).\n            #[inline]\n            fn checked_mul(self, other: $t) -> Option<$t> {\n                $t::checked_mul(self, other)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_checked_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedNeg;\n\nmacro_rules! impl_checked_neg {\n    ($t:ident) => {\n        impl CheckedNeg for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_neg` functions in the standard library, for\n            /// example [this one](u32::checked_neg).\n            #[inline]\n            fn checked_neg(self) -> Option<$t> {\n                $t::checked_neg(self)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_checked_neg);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedNextPowerOf2;\n\nmacro_rules! impl_checked_next_power_of_2 {\n    ($t:ident) => {\n        impl CheckedNextPowerOf2 for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_next_power_of_two` functions in the standard\n            /// library, for example [this one](u32::checked_next_power_of_two).\n            #[inline]\n            fn checked_next_power_of_2(self) -> Option<$t> {\n                $t::checked_next_power_of_two(self)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_checked_next_power_of_2);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedPow, Parity};\n\nmacro_rules! impl_checked_pow_unsigned {\n    ($t:ident) => {\n        impl CheckedPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_pow` functions in the standard library, for\n            /// example [this one](u32::checked_pow).\n            #[inline]\n            fn checked_pow(self, exp: u64) -> Option<$t> {\n                if exp == 0 {\n                    Some(1)\n                } else if self < 2 {\n                    Some(self)\n                } else {\n                    self.checked_pow(u32::try_from(exp).ok()?)\n                }\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_checked_pow_unsigned);\n\nmacro_rules! impl_checked_pow_signed {\n    ($t:ident) => {\n        impl CheckedPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_pow` functions in the standard library, for\n            /// example [this one](i32::checked_pow).\n            #[inline]\n            fn checked_pow(self, exp: u64) -> Option<$t> {\n                if exp == 0 {\n                    Some(1)\n                } else if self == 0 || self == 1 {\n                    Some(self)\n                } else if self == -1 {\n                    Some(if exp.even() { 1 } else { -1 })\n                } else {\n                    self.checked_pow(u32::try_from(exp).ok()?)\n                }\n            }\n        }\n    };\n}\napply_to_signeds!(impl_checked_pow_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedSquare;\n\nmacro_rules! impl_checked_square {\n    ($t:ident) => {\n        impl CheckedSquare for $t {\n            type Output = $t;\n\n            /// Squares a number, returning `None` if the result cannot be represented.\n            ///\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     \\operatorname{Some}(x^2) & \\text{if} \\\\quad x^2 < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad x^2 \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::checked_square#checked_square).\n            #[inline]\n            fn checked_square(self) -> Option<$t> {\n                self.checked_mul(self)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_checked_square);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CheckedSub;\n\nmacro_rules! impl_checked_sub {\n    ($t:ident) => {\n        impl CheckedSub<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `checked_sub` functions in the standard library, for\n            /// example [this one](u32::checked_sub).\n            #[inline]\n            fn checked_sub(self, other: $t) -> Option<$t> {\n                $t::checked_sub(self, other)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_checked_sub);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/checked_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedSubMul, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\nfn checked_sub_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> Option<T> {\n    y.checked_mul(z).and_then(|yz| x.checked_sub(yz))\n}\n\nmacro_rules! impl_checked_sub_mul_unsigned {\n    ($t:ident) => {\n        impl CheckedSubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers, returning `None` if the\n            /// result cannot be represented.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     \\operatorname{Some}(x - yz) & \\text{if} \\\\quad x \\geq yz, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad x < yz,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::checked_sub_mul#checked_sub_mul).\n            #[inline]\n            fn checked_sub_mul(self, y: $t, z: $t) -> Option<$t> {\n                checked_sub_mul_unsigned(self, y, z)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_checked_sub_mul_unsigned);\n\nfn checked_sub_mul_signed<\n    U: Ord + PrimitiveUnsigned,\n    T: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: T,\n    y: T,\n    z: T,\n) -> Option<T> {\n    if y == T::ZERO || z == T::ZERO {\n        return Some(x);\n    }\n    let x_sign = x >= T::ZERO;\n    if x_sign == ((y >= T::ZERO) != (z >= T::ZERO)) {\n        x.checked_sub(y.checked_mul(z)?)\n    } else {\n        let x = x.unsigned_abs();\n        let product = y.unsigned_abs().checked_mul(z.unsigned_abs())?;\n        let result = T::wrapping_from(if x_sign {\n            x.wrapping_sub(product)\n        } else {\n            product.wrapping_sub(x)\n        });\n        if x >= product || (x_sign == (result < T::ZERO)) {\n            Some(result)\n        } else {\n            None\n        }\n    }\n}\n\nmacro_rules! impl_checked_sub_mul_signed {\n    ($t:ident) => {\n        impl CheckedSubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers, returning `None` if the\n            /// result cannot be represented.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     \\operatorname{Some}(x - yz) &\n            ///         \\text{if} \\\\quad -2^{W-1} \\leq x - yz < 2^{W-1}, \\\\\\\\\n            ///     \\operatorname{None} &\n            ///         \\text{if} \\\\quad x - yz < -2^{W-1} \\\\ \\mathrm{or}\n            ///         \\\\ xy - z \\geq 2^{W-1}, \\\\\\\\\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::checked_sub_mul#checked_sub_mul).\n            #[inline]\n            fn checked_sub_mul(self, y: $t, z: $t) -> Option<$t> {\n                checked_sub_mul_signed(self, y, z)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_checked_sub_mul_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/coprime_with.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::CoprimeWith;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\npub_test! {coprime_with_check_2<T: PrimitiveUnsigned>(x: T, y: T) -> bool {\n    (x.odd() || y.odd()) && x.gcd(y) == T::ONE\n}}\n\n#[cfg(feature = \"test_build\")]\npub fn coprime_with_check_2_3<T: PrimitiveUnsigned>(x: T, y: T) -> bool {\n    (x.odd() || y.odd())\n        && (!x.divisible_by(T::from(3u8)) || !y.divisible_by(T::from(3u8)))\n        && x.gcd(y) == T::ONE\n}\n\n#[cfg(feature = \"test_build\")]\npub fn coprime_with_check_2_3_5<T: PrimitiveUnsigned>(x: T, y: T) -> bool {\n    if x.even() && y.even() {\n        false\n    } else {\n        let c15 = T::from(15u8);\n        let c3 = T::from(3u8);\n        let c6 = T::from(6u8);\n        let c9 = T::from(9u8);\n        let c12 = T::from(12u8);\n        let c5 = T::from(5u8);\n        let c10 = T::from(10u8);\n        let x15 = x % c15;\n        let y15 = y % c15;\n        if (x15 == T::ZERO || x15 == c3 || x15 == c6 || x15 == c9 || x15 == c12)\n            && (y15 == T::ZERO || y15 == c3 || y15 == c6 || y15 == c9 || y15 == c12)\n        {\n            return false;\n        }\n        if (x15 == T::ZERO || x15 == c5 || x15 == c10)\n            && (y15 == T::ZERO || y15 == c5 || y15 == c10)\n        {\n            return false;\n        }\n        x.gcd(y) == T::ONE\n    }\n}\n\nmacro_rules! impl_coprime_with {\n    ($t:ident) => {\n        impl CoprimeWith<$t> for $t {\n            /// Returns whether two numbers are coprime; that is, whether they have no common factor\n            /// other than 1.\n            ///\n            /// Every number is coprime with 1. No number is coprime with 0, except 1.\n            ///\n            /// $f(x, y) = (\\gcd(x, y) = 1)$.\n            ///\n            /// $f(x, y) = ((k,m,n \\in \\N \\land x=km \\land y=kn) \\implies k=1)$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::coprime_with#coprime_with).\n            #[inline]\n            fn coprime_with(self, other: $t) -> bool {\n                coprime_with_check_2(self, other)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_coprime_with);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{DivExact, DivExactAssign};\n\nmacro_rules! impl_div_exact {\n    ($t:ident) => {\n        impl DivExact<$t> for $t {\n            type Output = $t;\n\n            /// Divides a value by another value. The first value must be exactly divisible by the\n            /// second.\n            ///\n            /// If `self` is not exactly divisible by `other`, this function may panic or return a\n            /// meaningless result.\n            ///\n            /// $$\n            /// f(x, y) = \\frac{x}{y}.\n            /// $$\n            ///\n            /// If you are unsure whether the division will be exact, use `self / other` instead. If\n            /// you're unsure and you want to know, use `self.div_mod(other)` and check whether the\n            /// remainder is zero. If you want a function that panics if the division is not exact,\n            /// use `self.div_round(other, Exact)`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is zero or if `self` is `Self::MIN` and other is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_exact#div_exact).\n            #[inline]\n            fn div_exact(self, other: $t) -> $t {\n                self / other\n            }\n        }\n\n        impl DivExactAssign<$t> for $t {\n            /// Divides a value by another value in place. The value being assigned to must be\n            /// exactly divisible by the value on the right-hand side.\n            ///\n            /// If `self` is not exactly divisible by `other`, this function may panic or return a\n            /// meaningless result.\n            ///\n            /// $$\n            /// x \\gets \\frac{x}{y}.\n            /// $$\n            ///\n            /// If you are unsure whether the division will be exact, use `self /= other` instead.\n            /// If you're unsure and you want to know, use `self.div_assign_mod(other)` and check\n            /// whether the remainder is zero. If you want a function that panics if the division is\n            /// not exact, use `self.div_round_assign(other, Exact)`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is zero or if `self` is `Self::MIN` and other is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_exact#div_exact_assign).\n            #[inline]\n            fn div_exact_assign(&mut self, other: $t) {\n                *self /= other;\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_div_exact);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    CeilingDivAssignMod, CeilingDivAssignNegMod, CeilingDivMod, CeilingDivNegMod, DivAssignMod,\n    DivAssignRem, DivMod, DivRem, UnsignedAbs,\n};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\n\nfn div_mod_unsigned<T: PrimitiveUnsigned>(x: T, other: T) -> (T, T) {\n    let q = x / other;\n    (q, x - q * other)\n}\n\nfn div_assign_mod_unsigned<T: PrimitiveUnsigned>(x: &mut T, other: T) -> T {\n    let original = *x;\n    *x /= other;\n    original - *x * other\n}\n\nfn ceiling_div_neg_mod_unsigned<T: PrimitiveUnsigned>(x: T, other: T) -> (T, T) {\n    let (quotient, remainder) = x.div_mod(other);\n    if remainder == T::ZERO {\n        (quotient, T::ZERO)\n    } else {\n        // Here remainder != 0, so other > 1, so quotient < T::MAX.\n        (quotient + T::ONE, other - remainder)\n    }\n}\n\nfn ceiling_div_assign_neg_mod_unsigned<T: PrimitiveUnsigned>(x: &mut T, other: T) -> T {\n    let remainder = x.div_assign_mod(other);\n    if remainder == T::ZERO {\n        T::ZERO\n    } else {\n        // Here remainder != 0, so other > 1, so self < T::MAX.\n        *x += T::ONE;\n        other - remainder\n    }\n}\n\nmacro_rules! impl_div_mod_unsigned {\n    ($t:ident) => {\n        impl DivMod<$t> for $t {\n            type DivOutput = $t;\n            type ModOutput = $t;\n\n            /// Divides a number by another number, returning the quotient and remainder. The\n            /// quotient is rounded towards negative infinity.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n            /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_mod).\n            #[inline]\n            fn div_mod(self, other: $t) -> ($t, $t) {\n                div_mod_unsigned(self, other)\n            }\n        }\n\n        impl DivAssignMod<$t> for $t {\n            type ModOutput = $t;\n\n            /// Divides a number by another number in place, returning the remainder. The quotient\n            /// is rounded towards negative infinity.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n            /// $$\n            /// $$\n            /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_assign_mod).\n            #[inline]\n            fn div_assign_mod(&mut self, other: $t) -> $t {\n                div_assign_mod_unsigned(self, other)\n            }\n        }\n\n        impl DivRem<$t> for $t {\n            type DivOutput = $t;\n            type RemOutput = $t;\n\n            /// Divides a number by another number, returning the quotient and remainder. The\n            /// quotient is rounded towards zero.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n            /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n            /// $$\n            ///\n            /// For unsigned integers, `div_rem` is equivalent to `div_mod`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_rem).\n            #[inline]\n            fn div_rem(self, other: $t) -> ($t, $t) {\n                self.div_mod(other)\n            }\n        }\n\n        impl DivAssignRem<$t> for $t {\n            type RemOutput = $t;\n\n            /// Divides a number by another number in place, returning the remainder. The quotient\n            /// is rounded towards zero.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n            /// $$\n            /// $$\n            /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n            /// $$\n            ///\n            /// For unsigned integers, `div_assign_rem` is equivalent to `div_assign_mod`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_assign_rem).\n            #[inline]\n            fn div_assign_rem(&mut self, other: $t) -> $t {\n                self.div_assign_mod(other)\n            }\n        }\n\n        impl CeilingDivNegMod<$t> for $t {\n            type DivOutput = $t;\n            type ModOutput = $t;\n\n            /// Divides a number by another number, returning the ceiling of the quotient and the\n            /// remainder of the negative of the first number divided by the second.\n            ///\n            /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n            /// y\\left \\lceil \\frac{x}{y} \\right \\rceil - x \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#ceiling_div_neg_mod).\n            #[inline]\n            fn ceiling_div_neg_mod(self, other: $t) -> ($t, $t) {\n                ceiling_div_neg_mod_unsigned(self, other)\n            }\n        }\n\n        impl CeilingDivAssignNegMod<$t> for $t {\n            type ModOutput = $t;\n\n            /// Divides a number by another number in place, returning the remainder of the negative\n            /// of the first number divided by the second.\n            ///\n            /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x,\n            /// $$\n            /// $$\n            /// x \\gets \\left \\lceil \\frac{x}{y} \\right \\rceil.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#ceiling_div_assign_neg_mod).\n            #[inline]\n            fn ceiling_div_assign_neg_mod(&mut self, other: $t) -> $t {\n                ceiling_div_assign_neg_mod_unsigned(self, other)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_div_mod_unsigned);\n\nfn div_mod_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + ExactFrom<U> + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: S,\n    other: S,\n) -> (S, S) {\n    let (quotient, remainder) = if (x >= S::ZERO) == (other >= S::ZERO) {\n        let (quotient, remainder) = x.unsigned_abs().div_mod(other.unsigned_abs());\n        (S::exact_from(quotient), remainder)\n    } else {\n        let (quotient, remainder) = x.unsigned_abs().ceiling_div_neg_mod(other.unsigned_abs());\n        (S::wrapping_from(quotient).wrapping_neg(), remainder)\n    };\n    (\n        quotient,\n        if other >= S::ZERO {\n            S::exact_from(remainder)\n        } else {\n            -S::exact_from(remainder)\n        },\n    )\n}\n\nfn div_rem_signed<T: PrimitiveSigned>(x: T, other: T) -> (T, T) {\n    let q = x.checked_div(other).unwrap();\n    (q, x - q * other)\n}\n\nfn div_assign_rem_signed<T: PrimitiveSigned>(x: &mut T, other: T) -> T {\n    let original = *x;\n    *x = x.checked_div(other).unwrap();\n    original - *x * other\n}\n\nfn ceiling_div_mod_signed<\n    U: PrimitiveUnsigned,\n    T: PrimitiveSigned + ExactFrom<U> + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: T,\n    other: T,\n) -> (T, T) {\n    let (quotient, remainder) = if (x >= T::ZERO) == (other >= T::ZERO) {\n        let (quotient, remainder) = x.unsigned_abs().ceiling_div_neg_mod(other.unsigned_abs());\n        (T::exact_from(quotient), remainder)\n    } else {\n        let (quotient, remainder) = x.unsigned_abs().div_mod(other.unsigned_abs());\n        (T::wrapping_from(quotient).wrapping_neg(), remainder)\n    };\n    (\n        quotient,\n        if other >= T::ZERO {\n            -T::exact_from(remainder)\n        } else {\n            T::exact_from(remainder)\n        },\n    )\n}\n\nmacro_rules! impl_div_mod_signed {\n    ($t:ident) => {\n        impl DivMod<$t> for $t {\n            type DivOutput = $t;\n            type ModOutput = $t;\n\n            /// Divides a number by another number, returning the quotient and remainder. The\n            /// quotient is rounded towards negative infinity, and the remainder has the same sign\n            /// as the second number.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n            /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0, or if `self` is `$t::MIN` and `other` is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_mod).\n            #[inline]\n            fn div_mod(self, other: $t) -> ($t, $t) {\n                div_mod_signed(self, other)\n            }\n        }\n\n        impl DivAssignMod<$t> for $t {\n            type ModOutput = $t;\n\n            /// Divides a number by another number in place, returning the remainder. The quotient\n            /// is rounded towards negative infinity, and the remainder has the same sign as the\n            /// second number.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n            /// $$\n            /// $$\n            /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0, or if `self` is `$t::MIN` and `other` is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_assign_mod).\n            #[inline]\n            fn div_assign_mod(&mut self, other: $t) -> $t {\n                let (q, r) = self.div_mod(other);\n                *self = q;\n                r\n            }\n        }\n\n        impl DivRem<$t> for $t {\n            type DivOutput = $t;\n            type RemOutput = $t;\n\n            /// Divides a number by another number, returning the quotient and remainder. The\n            /// quotient is rounded towards zero and the remainder has the same sign as the\n            /// dividend.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n            /// \\right \\rfloor, \\space\n            /// x - y \\operatorname{sgn}(xy)\n            /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0, or if `self` is `$t::MIN` and `other` is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_rem).\n            #[inline]\n            fn div_rem(self, other: $t) -> ($t, $t) {\n                div_rem_signed(self, other)\n            }\n        }\n\n        impl DivAssignRem<$t> for $t {\n            type RemOutput = $t;\n\n            /// Divides a number by another number in place, returning the remainder. The quotient\n            /// is rounded towards zero and the remainder has the same sign as the dividend.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) = x - y \\operatorname{sgn}(xy)\n            /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor,\n            /// $$\n            /// $$\n            /// x \\gets \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n            /// \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0, or if `self` is `$t::MIN` and `other` is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#div_assign_rem).\n            #[inline]\n            fn div_assign_rem(&mut self, other: $t) -> $t {\n                div_assign_rem_signed(self, other)\n            }\n        }\n\n        impl CeilingDivMod<$t> for $t {\n            type DivOutput = $t;\n            type ModOutput = $t;\n\n            /// Divides a number by another number, returning the quotient and remainder. The\n            /// quotient is rounded towards positive infinity and the remainder has the opposite\n            /// sign as the second number.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n            /// x - y\\left \\lceil \\frac{x}{y} \\right \\rceil \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0, or if `self` is `$t::MIN` and `other` is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#ceiling_div_mod).\n            #[inline]\n            fn ceiling_div_mod(self, other: $t) -> ($t, $t) {\n                ceiling_div_mod_signed(self, other)\n            }\n        }\n\n        impl CeilingDivAssignMod<$t> for $t {\n            type ModOutput = $t;\n\n            /// Divides a number by another number in place, returning the remainder. The quotient\n            /// is rounded towards positive infinity and the remainder has the opposite sign as the\n            /// second number.\n            ///\n            /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) = x - y\\left \\lceil\\frac{x}{y} \\right \\rceil,\n            /// $$\n            /// $$\n            /// x \\gets \\left \\lceil \\frac{x}{y} \\right \\rceil.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0, or if `self` is `$t::MIN` and `other` is -1.\n            ///\n            /// # Examples\n            /// See [here](super::div_mod#ceiling_div_assign_mod).\n            #[inline]\n            fn ceiling_div_assign_mod(&mut self, other: $t) -> $t {\n                let (q, r) = self.ceiling_div_mod(other);\n                *self = q;\n                r\n            }\n        }\n    };\n}\napply_to_signeds!(impl_div_mod_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{DivRound, DivRoundAssign, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse core::cmp::Ordering::{self, *};\n\nfn div_round_unsigned<T: PrimitiveUnsigned>(x: T, other: T, rm: RoundingMode) -> (T, Ordering) {\n    let quotient = x / other;\n    let remainder = x - quotient * other;\n    match rm {\n        _ if remainder == T::ZERO => (quotient, Equal),\n        Down | Floor => (quotient, Less),\n        Up | Ceiling => (quotient + T::ONE, Greater),\n        Nearest => {\n            let shifted_other = other >> 1;\n            if remainder > shifted_other\n                || remainder == shifted_other && other.even() && quotient.odd()\n            {\n                (quotient + T::ONE, Greater)\n            } else {\n                (quotient, Less)\n            }\n        }\n        Exact => {\n            panic!(\"Division is not exact: {x} / {other}\");\n        }\n    }\n}\n\nmacro_rules! impl_div_round_unsigned {\n    ($t:ident) => {\n        impl DivRound<$t> for $t {\n            type Output = $t;\n\n            /// Divides a value by another value and rounds according to a specified rounding mode.\n            /// An [`Ordering`] is also returned, indicating whether the returned value is less\n            /// than, equal to, or greater than the exact value.\n            ///\n            /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n            /// $$\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n            /// $$\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if} \\\\quad  q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor &\n            ///     \\text{if} \\\\quad  q - \\lfloor q \\rfloor = \\frac{1}{2}\n            ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n            ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by\n            /// `other`.\n            ///\n            /// # Examples\n            /// See [here](super::div_round#div_round).\n            #[inline]\n            fn div_round(self, other: $t, rm: RoundingMode) -> ($t, Ordering) {\n                div_round_unsigned(self, other, rm)\n            }\n        }\n\n        impl DivRoundAssign<$t> for $t {\n            /// Divides a value by another value in place and rounds according to a specified\n            /// rounding mode. An [`Ordering`] is returned, indicating whether the assigned value is\n            /// less than, equal to, or greater than the exact value.\n            ///\n            /// See the [`DivRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by\n            /// `other`.\n            ///\n            /// # Examples\n            /// See [here](super::div_round#div_round_assign).\n            #[inline]\n            fn div_round_assign(&mut self, other: $t, rm: RoundingMode) -> Ordering {\n                let o;\n                (*self, o) = self.div_round(other, rm);\n                o\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_div_round_unsigned);\n\nfn div_round_signed<\n    U: PrimitiveUnsigned,\n    S: ExactFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: S,\n    other: S,\n    rm: RoundingMode,\n) -> (S, Ordering) {\n    if (x >= S::ZERO) == (other >= S::ZERO) {\n        let (q, o) = x.unsigned_abs().div_round(other.unsigned_abs(), rm);\n        (S::exact_from(q), o)\n    } else {\n        // Has to be wrapping so that (self, other) == (T::MIN, 1) works\n        let (q, o) = x.unsigned_abs().div_round(other.unsigned_abs(), -rm);\n        (S::wrapping_from(q).wrapping_neg(), o.reverse())\n    }\n}\n\nmacro_rules! impl_div_round_signed {\n    ($t:ident) => {\n        impl DivRound<$t> for $t {\n            type Output = $t;\n\n            /// Divides a value by another value and rounds according to a specified rounding mode.\n            /// An [`Ordering`] is also returned, indicating whether the returned value is less\n            /// than, equal to, or greater than the exact value.\n            ///\n            /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.\n            /// $$\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.\n            /// $$\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n            /// $$\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n            /// $$\n            ///\n            /// $$\n            /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n            ///\n            /// Then\n            ///\n            /// $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is zero, if `self` is `Self::MIN` and `other` is `-1`, or if `rm`\n            /// is `Exact` but `self` is not divisible by `other`.\n            ///\n            /// # Examples\n            /// See [here](super::div_round#div_round).\n            fn div_round(self, other: $t, rm: RoundingMode) -> ($t, Ordering) {\n                div_round_signed(self, other, rm)\n            }\n        }\n\n        impl DivRoundAssign<$t> for $t {\n            /// Divides a value by another value in place and rounds according to a specified\n            /// rounding mode. An [`Ordering`] is returned, indicating whether the assigned value is\n            /// less than, equal to, or greater than the exact value.\n            ///\n            /// See the [`DivRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is zero, if `self` is `Self::MIN` and `other` is `-1`, or if `rm`\n            /// is `Exact` but `self` is not divisible by `other`.\n            ///\n            /// # Examples\n            /// See [here](super::div_round#div_round_assign).\n            #[inline]\n            fn div_round_assign(&mut self, other: $t, rm: RoundingMode) -> Ordering {\n                let o;\n                (*self, o) = self.div_round(other, rm);\n                o\n            }\n        }\n    };\n}\napply_to_signeds!(impl_div_round_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::DivisibleBy;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn divisible_by_unsigned<T: PrimitiveUnsigned>(x: T, other: T) -> bool {\n    x == T::ZERO || other != T::ZERO && x % other == T::ZERO\n}\n\nmacro_rules! impl_divisible_by_unsigned {\n    ($t:ident) => {\n        impl DivisibleBy<$t> for $t {\n            /// Returns whether a number is divisible by another number; in other words, whether the\n            /// first number is a multiple of the second.\n            ///\n            /// This means that zero is divisible by any number, including zero; but a nonzero\n            /// number is never divisible by zero.\n            ///\n            /// $f(x, m) = (m|x)$.\n            ///\n            /// $f(x, m) = (\\exists k \\in \\N : x = km)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::divisible_by#divisible_by).\n            #[inline]\n            fn divisible_by(self, other: $t) -> bool {\n                divisible_by_unsigned(self, other)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_divisible_by_unsigned);\n\nfn divisible_by_signed<T: PrimitiveSigned>(x: T, other: T) -> bool {\n    x == T::ZERO\n        || x == T::MIN && other == T::NEGATIVE_ONE\n        || other != T::ZERO && x % other == T::ZERO\n}\n\nmacro_rules! impl_divisible_by_signed {\n    ($t:ident) => {\n        impl DivisibleBy<$t> for $t {\n            /// Returns whether a number is divisible by another number; in other words, whether the\n            /// first number is a multiple of the second.\n            ///\n            /// This means that zero is divisible by any number, including zero; but a nonzero\n            /// number is never divisible by zero.\n            ///\n            /// $f(x, m) = (m|x)$.\n            ///\n            /// $f(x, m) = (\\exists k \\in \\Z : \\ x = km)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::divisible_by#divisible_by).\n            #[inline]\n            fn divisible_by(self, other: $t) -> bool {\n                divisible_by_signed(self, other)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_divisible_by_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{DivisibleByPowerOf2, ModPowerOf2};\nuse crate::num::conversion::traits::WrappingFrom;\n\nmacro_rules! impl_divisible_by_power_of_2_unsigned {\n    ($t:ident) => {\n        impl DivisibleByPowerOf2 for $t {\n            /// Returns whether a number is divisible by $2^k$.\n            ///\n            /// $f(x, k) = (2^k|x)$.\n            ///\n            /// $f(x, k) = (\\exists n \\in \\N : \\ x = n2^k)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::divisible_by_power_of_2#divisible_by_power_of_2).\n            #[inline]\n            fn divisible_by_power_of_2(self, pow: u64) -> bool {\n                self.mod_power_of_2(pow) == 0\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_divisible_by_power_of_2_unsigned);\n\nmacro_rules! impl_divisible_by_power_of_2_signed {\n    ($u:ident, $s:ident) => {\n        impl DivisibleByPowerOf2 for $s {\n            /// Returns whether a number is divisible by $2^k$.\n            ///\n            /// $f(x, k) = (2^k|x)$.\n            ///\n            /// $f(x, k) = (\\exists n \\in \\N : x = n2^k)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::divisible_by_power_of_2#divisible_by_power_of_2).\n            #[inline]\n            fn divisible_by_power_of_2(self, pow: u64) -> bool {\n                $u::wrapping_from(self).divisible_by_power_of_2(pow)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_divisible_by_power_of_2_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{EqMod, Mod};\nuse crate::num::basic::traits::Zero;\n\nfn eq_mod<U: Eq, S: Copy + Eq + Mod<S, Output = U> + Zero>(x: S, other: S, m: S) -> bool {\n    x == other || m != S::ZERO && x.mod_op(m) == other.mod_op(m)\n}\n\nmacro_rules! impl_eq_mod {\n    ($t:ident) => {\n        impl EqMod<$t> for $t {\n            /// Returns whether a number is equivalent to another number modulo a third; that is,\n            /// whether the difference between the first two is a multiple of the third.\n            ///\n            /// Two numbers are equal to each other modulo 0 iff they are equal.\n            ///\n            /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n            ///\n            /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::eq_mod#eq_mod).\n            #[inline]\n            fn eq_mod(self, other: $t, m: $t) -> bool {\n                eq_mod(self, other, m)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_eq_mod);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{DivisibleByPowerOf2, EqModPowerOf2};\n\nmacro_rules! impl_eq_mod_power_of_2 {\n    ($t:ident) => {\n        impl EqModPowerOf2<$t> for $t {\n            /// Returns whether one number is equal to another modulo $2^k$.\n            ///\n            /// $f(x, y, k) = (x \\equiv y \\mod 2^k)$.\n            ///\n            /// $f(x, y, k) = (\\exists n \\in \\Z : x - y = n2^k)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::eq_mod_power_of_2#eq_mod_power_of_2).\n            #[inline]\n            fn eq_mod_power_of_2(self, other: $t, pow: u64) -> bool {\n                (self ^ other).divisible_by_power_of_2(pow)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_eq_mod_power_of_2);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009, 2016 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::ExtendedGcd;\nuse crate::num::arithmetic::traits::UnsignedAbs;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::rounding_modes::RoundingMode::*;\nuse core::mem::swap;\n\nfn extended_gcd_signed<\n    U: ExtendedGcd<Cofactor = S> + PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    a: S,\n    b: S,\n) -> (U, S, S) {\n    let (gcd, mut x, mut y) = a.unsigned_abs().extended_gcd(b.unsigned_abs());\n    if a < S::ZERO {\n        x = x.checked_neg().unwrap();\n    }\n    if b < S::ZERO {\n        y = y.checked_neg().unwrap();\n    }\n    (gcd, x, y)\n}\n\n// This is equivalent to `n_xgcd` from `ulong_extras/xgcd.c`, FLINT 2.7.1, with an adjustment to\n// find the minimal cofactors.\npub_test! {extended_gcd_unsigned_binary<\n    U: WrappingFrom<S> + PrimitiveUnsigned,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    mut a: U,\n    mut b: U,\n) -> (U, S, S) {\n    if a == U::ZERO && b == U::ZERO {\n        return (U::ZERO, S::ZERO, S::ZERO);\n    } else if a == b || a == U::ZERO {\n        return (b, S::ZERO, S::ONE);\n    } else if b == U::ZERO {\n        return (a, S::ONE, S::ZERO);\n    }\n    let mut swapped = false;\n    if a < b {\n        swap(&mut a, &mut b);\n        swapped = true;\n    }\n    let mut u1 = S::ONE;\n    let mut v2 = S::ONE;\n    let mut u2 = S::ZERO;\n    let mut v1 = S::ZERO;\n    let mut u3 = a;\n    let mut v3 = b;\n    let mut d;\n    let mut t2;\n    let mut t1;\n    if (a & b).get_highest_bit() {\n        d = u3 - v3;\n        t2 = v2;\n        t1 = u2;\n        u2 = u1 - u2;\n        u1 = t1;\n        u3 = v3;\n        v2 = v1 - v2;\n        v1 = t2;\n        v3 = d;\n    }\n    while v3.get_bit(U::WIDTH - 2) {\n        d = u3 - v3;\n        if d < v3 {\n            // quot = 1\n            t2 = v2;\n            t1 = u2;\n            u2 = u1 - u2;\n            u1 = t1;\n            u3 = v3;\n            v2 = v1 - v2;\n            v1 = t2;\n            v3 = d;\n        } else if d < (v3 << 1) {\n            // quot = 2\n            t1 = u2;\n            u2 = u1 - (u2 << 1);\n            u1 = t1;\n            u3 = v3;\n            t2 = v2;\n            v2 = v1 - (v2 << 1);\n            v1 = t2;\n            v3 = d - u3;\n        } else {\n            // quot = 3\n            t1 = u2;\n            u2 = u1 - S::wrapping_from(3) * u2;\n            u1 = t1;\n            u3 = v3;\n            t2 = v2;\n            v2 = v1 - S::wrapping_from(3) * v2;\n            v1 = t2;\n            v3 = d - (u3 << 1);\n        }\n    }\n    while v3 != U::ZERO {\n        d = u3 - v3;\n        // overflow not possible, top 2 bits of v3 not set\n        if u3 < (v3 << 2) {\n            if d < v3 {\n                // quot = 1\n                t2 = v2;\n                t1 = u2;\n                u2 = u1 - u2;\n                u1 = t1;\n                u3 = v3;\n                v2 = v1 - v2;\n                v1 = t2;\n                v3 = d;\n            } else if d < (v3 << 1) {\n                // quot = 2\n                t1 = u2;\n                u2 = u1.wrapping_sub(u2 << 1);\n                u1 = t1;\n                u3 = v3;\n                t2 = v2;\n                v2 = v1.wrapping_sub(v2 << 1);\n                v1 = t2;\n                v3 = d - u3;\n            } else {\n                // quot = 3\n                t1 = u2;\n                u2 = u1.wrapping_sub(S::wrapping_from(3).wrapping_mul(u2));\n                u1 = t1;\n                u3 = v3;\n                t2 = v2;\n                v2 = v1.wrapping_sub(S::wrapping_from(3).wrapping_mul(v2));\n                v1 = t2;\n                v3 = d.wrapping_sub(u3 << 1);\n            }\n        } else {\n            let (quot, rem) = u3.div_rem(v3);\n            t1 = u2;\n            u2 = u1.wrapping_sub(S::wrapping_from(quot).wrapping_mul(u2));\n            u1 = t1;\n            u3 = v3;\n            t2 = v2;\n            v2 = v1.wrapping_sub(S::wrapping_from(quot).wrapping_mul(v2));\n            v1 = t2;\n            v3 = rem;\n        }\n    }\n    // Remarkably, |u1| < x/2, thus comparison with 0 is valid\n    if u1 <= S::ZERO {\n        u1.wrapping_add_assign(S::wrapping_from(b));\n        v1.wrapping_sub_assign(S::wrapping_from(a));\n    }\n    // The cofactors at this point are not necessarily minimal, so we may need to adjust.\n    let gcd = u3;\n    let mut x = U::wrapping_from(u1);\n    let mut y = U::wrapping_from(v1);\n    let two_limit_a = a / gcd;\n    let two_limit_b = b / gcd;\n    let limit_b = two_limit_b >> 1;\n    if x > limit_b {\n        let k = (x - limit_b).div_round(two_limit_b, Ceiling).0;\n        x.wrapping_sub_assign(two_limit_b.wrapping_mul(k));\n        y.wrapping_add_assign(two_limit_a.wrapping_mul(k));\n    }\n    if swapped {\n        swap(&mut x, &mut y);\n    }\n    (gcd, S::wrapping_from(x), S::wrapping_from(y))\n}}\n\nmacro_rules! impl_extended_gcd {\n    ($u:ident, $s:ident) => {\n        impl ExtendedGcd<$u> for $u {\n            type Gcd = $u;\n            type Cofactor = $s;\n\n            /// Computes the GCD (greatest common divisor) of two numbers $a$ and $b$, and also the\n            /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$.\n            ///\n            /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the\n            /// full specification is more detailed:\n            ///\n            /// - $f(0, 0) = (0, 0, 0)$.\n            /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n            /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n            /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(a,\n            ///   b)$, where $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$,\n            ///   and $y \\leq \\lfloor a/g \\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::extended_gcd#extended_gcd).\n            #[inline]\n            fn extended_gcd(self, other: $u) -> ($u, $s, $s) {\n                extended_gcd_unsigned_binary(self, other)\n            }\n        }\n\n        impl ExtendedGcd<$s> for $s {\n            type Gcd = $u;\n            type Cofactor = $s;\n\n            /// Computes the GCD (greatest common divisor) of two numbers $a$ and $b$, and also the\n            /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$.\n            ///\n            /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the\n            /// full specification is more detailed:\n            ///\n            /// - $f(0, 0) = (0, 0, 0)$.\n            /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n            /// - $f(a, ak) = (-a, -1, 0)$ if $a < 0$ and $k \\neq 1$.\n            /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n            /// - $f(bk, b) = (-b, 0, -1)$ if $b < 0$.\n            /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(|a|,\n            ///   |b|)$, where $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$,\n            ///   and $y \\leq \\lfloor a/g \\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::extended_gcd#extended_gcd).\n            #[inline]\n            fn extended_gcd(self, other: $s) -> ($u, $s, $s) {\n                extended_gcd_signed(self, other)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_extended_gcd);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    CheckedDoubleFactorial, CheckedFactorial, CheckedMultifactorial, CheckedSubfactorial,\n    DoubleFactorial, Factorial, Multifactorial, Parity, Subfactorial,\n};\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\npub_test! {checked_multifactorial_naive<T: PrimitiveUnsigned>(n: u64, m: u64) -> Option<T> {\n    assert_ne!(m, 0);\n    let mut f = T::ONE;\n    let mut n = T::try_from(n).ok()?;\n    let m = T::saturating_from(m);\n    while n != T::ZERO {\n        f = f.checked_mul(n)?;\n        n.saturating_sub_assign(m);\n    }\n    Some(f)\n}}\n\nconst FACTORIALS_U8: [u8; 6] = [1, 1, 2, 6, 24, 120];\nconst FACTORIALS_U16: [u16; 9] = [1, 1, 2, 6, 24, 120, 720, 5040, 40320];\nconst FACTORIALS_U32: [u32; 13] =\n    [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600];\nconst FACTORIALS_U64: [u64; 21] = [\n    1,\n    1,\n    2,\n    6,\n    24,\n    120,\n    720,\n    5040,\n    40320,\n    362880,\n    3628800,\n    39916800,\n    479001600,\n    6227020800,\n    87178291200,\n    1307674368000,\n    20922789888000,\n    355687428096000,\n    6402373705728000,\n    121645100408832000,\n    2432902008176640000,\n];\nconst FACTORIALS_U128: [u128; 35] = [\n    1,\n    1,\n    2,\n    6,\n    24,\n    120,\n    720,\n    5040,\n    40320,\n    362880,\n    3628800,\n    39916800,\n    479001600,\n    6227020800,\n    87178291200,\n    1307674368000,\n    20922789888000,\n    355687428096000,\n    6402373705728000,\n    121645100408832000,\n    2432902008176640000,\n    51090942171709440000,\n    1124000727777607680000,\n    25852016738884976640000,\n    620448401733239439360000,\n    15511210043330985984000000,\n    403291461126605635584000000,\n    10888869450418352160768000000,\n    304888344611713860501504000000,\n    8841761993739701954543616000000,\n    265252859812191058636308480000000,\n    8222838654177922817725562880000000,\n    263130836933693530167218012160000000,\n    8683317618811886495518194401280000000,\n    295232799039604140847618609643520000000,\n];\n\nconst ODD_DOUBLE_FACTORIALS_U8: [u8; 4] = [1, 3, 15, 105];\nconst ODD_DOUBLE_FACTORIALS_U16: [u16; 6] = [1, 3, 15, 105, 945, 10395];\nconst ODD_DOUBLE_FACTORIALS_U32: [u32; 10] =\n    [1, 3, 15, 105, 945, 10395, 135135, 2027025, 34459425, 654729075];\nconst ODD_DOUBLE_FACTORIALS_U64: [u64; 17] = [\n    1,\n    3,\n    15,\n    105,\n    945,\n    10395,\n    135135,\n    2027025,\n    34459425,\n    654729075,\n    13749310575,\n    316234143225,\n    7905853580625,\n    213458046676875,\n    6190283353629375,\n    191898783962510625,\n    6332659870762850625,\n];\nconst ODD_DOUBLE_FACTORIALS_U128: [u128; 28] = [\n    1,\n    3,\n    15,\n    105,\n    945,\n    10395,\n    135135,\n    2027025,\n    34459425,\n    654729075,\n    13749310575,\n    316234143225,\n    7905853580625,\n    213458046676875,\n    6190283353629375,\n    191898783962510625,\n    6332659870762850625,\n    221643095476699771875,\n    8200794532637891559375,\n    319830986772877770815625,\n    13113070457687988603440625,\n    563862029680583509947946875,\n    25373791335626257947657609375,\n    1192568192774434123539907640625,\n    58435841445947272053455474390625,\n    2980227913743310874726229193921875,\n    157952079428395476360490147277859375,\n    8687364368561751199826958100282265625,\n];\n\nconst SUBFACTORIALS_U8: [u8; 6] = [1, 0, 1, 2, 9, 44];\nconst SUBFACTORIALS_U16: [u16; 9] = [1, 0, 1, 2, 9, 44, 265, 1854, 14833];\nconst SUBFACTORIALS_U32: [u32; 14] =\n    [1, 0, 1, 2, 9, 44, 265, 1854, 14833, 133496, 1334961, 14684570, 176214841, 2290792932];\nconst SUBFACTORIALS_U64: [u64; 21] = [\n    1,\n    0,\n    1,\n    2,\n    9,\n    44,\n    265,\n    1854,\n    14833,\n    133496,\n    1334961,\n    14684570,\n    176214841,\n    2290792932,\n    32071101049,\n    481066515734,\n    7697064251745,\n    130850092279664,\n    2355301661033953,\n    44750731559645106,\n    895014631192902121,\n];\nconst SUBFACTORIALS_U128: [u128; 35] = [\n    1,\n    0,\n    1,\n    2,\n    9,\n    44,\n    265,\n    1854,\n    14833,\n    133496,\n    1334961,\n    14684570,\n    176214841,\n    2290792932,\n    32071101049,\n    481066515734,\n    7697064251745,\n    130850092279664,\n    2355301661033953,\n    44750731559645106,\n    895014631192902121,\n    18795307255050944540,\n    413496759611120779881,\n    9510425471055777937262,\n    228250211305338670494289,\n    5706255282633466762357224,\n    148362637348470135821287825,\n    4005791208408693667174771274,\n    112162153835443422680893595673,\n    3252702461227859257745914274516,\n    97581073836835777732377428235481,\n    3025013288941909109703700275299910,\n    96800425246141091510518408809597121,\n    3194414033122656019847107490716704992,\n    108610077126170304674801654684367969729,\n];\n\nmacro_rules! impl_factorials_a {\n    ($t:ident, $fs:ident, $odfs:ident, $sfs:ident, $df_limit:expr) => {\n        impl CheckedFactorial for $t {\n            /// Computes the factorial of a number.\n            ///\n            /// If the input is too large, the function returns `None`.\n            ///\n            /// $$\n            /// f(n) = \\\\begin{cases}\n            ///     \\operatorname{Some}(n!) & \\text{if} \\\\quad n! < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad n! \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// $n! = O(\\sqrt{n}(n/e)^n)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#checked_factorial).\n            #[inline]\n            fn checked_factorial(n: u64) -> Option<$t> {\n                $fs.get(usize::try_from(n).ok()?).copied()\n            }\n        }\n\n        impl CheckedDoubleFactorial for $t {\n            /// Computes the double factorial of a number.\n            ///\n            /// If the input is too large, the function returns `None`.\n            ///\n            /// $$\n            /// f(n) = \\\\begin{cases}\n            ///     \\operatorname{Some}(n!!) & \\text{if} \\\\quad n!! < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad n!! \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// $n!! = O(\\sqrt{n}(n/e)^{n/2})$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#checked_double_factorial).\n            #[inline]\n            fn checked_double_factorial(n: u64) -> Option<$t> {\n                if n > $df_limit {\n                    None\n                } else if n.odd() {\n                    $odfs.get(usize::try_from(n >> 1).ok()?).copied()\n                } else {\n                    let half = n >> 1;\n                    $fs.get(usize::try_from(half).ok()?).map(|&f| f << half)\n                }\n            }\n        }\n\n        impl CheckedSubfactorial for $t {\n            /// Computes the subfactorial of a number.\n            ///\n            /// The subfactorial of $n$ counts the number of derangements of a set of size $n$; a\n            /// derangement is a permutation with no fixed points.\n            ///\n            /// If the input is too large, the function returns `None`.\n            ///\n            /// $$\n            /// f(n) = \\\\begin{cases}\n            ///     \\operatorname{Some}(!n) & \\text{if} \\\\quad !n < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad !n \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// $!n = O(n!) = O(\\sqrt{n}(n/e)^n)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#checked_subfactorial).\n            #[inline]\n            fn checked_subfactorial(n: u64) -> Option<$t> {\n                $sfs.get(usize::try_from(n).ok()?).copied()\n            }\n        }\n    };\n}\nimpl_factorials_a!(\n    u8,\n    FACTORIALS_U8,\n    ODD_DOUBLE_FACTORIALS_U8,\n    SUBFACTORIALS_U8,\n    7\n);\nimpl_factorials_a!(\n    u16,\n    FACTORIALS_U16,\n    ODD_DOUBLE_FACTORIALS_U16,\n    SUBFACTORIALS_U16,\n    12\n);\nimpl_factorials_a!(\n    u32,\n    FACTORIALS_U32,\n    ODD_DOUBLE_FACTORIALS_U32,\n    SUBFACTORIALS_U32,\n    20\n);\nimpl_factorials_a!(\n    u64,\n    FACTORIALS_U64,\n    ODD_DOUBLE_FACTORIALS_U64,\n    SUBFACTORIALS_U64,\n    33\n);\nimpl_factorials_a!(\n    u128,\n    FACTORIALS_U128,\n    ODD_DOUBLE_FACTORIALS_U128,\n    SUBFACTORIALS_U128,\n    56\n);\n\nimpl CheckedFactorial for usize {\n    /// Computes the factorial of a [`usize`].\n    ///\n    /// If the input is too large, the function returns `None`.\n    ///\n    /// $$\n    /// f(n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(n!) & \\text{if} \\\\quad n! < 2^W, \\\\\\\\\n    ///     \\operatorname{None} & \\text{if} \\\\quad n! \\geq 2^W,\n    /// \\\\end{cases}\n    /// $$\n    /// where $W$ is `usize::WIDTH`.\n    ///\n    /// $n! = O(\\sqrt{n}(n/e)^n)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::factorial#checked_factorial).\n    #[inline]\n    fn checked_factorial(n: u64) -> Option<Self> {\n        FACTORIALS_U64\n            .get(Self::try_from(n).ok()?)\n            .and_then(|&f| Self::try_from(f).ok())\n    }\n}\n\nimpl CheckedSubfactorial for usize {\n    /// Computes the subfactorial of a [`usize`].\n    ///\n    /// The subfactorial of $n$ counts the number of derangements of a set of size $n$; a\n    /// derangement is a permutation with no fixed points.\n    ///\n    /// If the input is too large, the function returns `None`.\n    ///\n    /// $$\n    /// f(n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(!n) & \\text{if} \\\\quad !n < 2^W, \\\\\\\\\n    ///     \\operatorname{None} & \\text{if} \\\\quad !n \\geq 2^W,\n    /// \\\\end{cases}\n    /// $$\n    /// where $W$ is `usize::WIDTH`.\n    ///\n    /// $!n = O(n!) = O(\\sqrt{n}(n/e)^n)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::factorial#checked_subfactorial).\n    #[inline]\n    fn checked_subfactorial(n: u64) -> Option<Self> {\n        SUBFACTORIALS_U64\n            .get(Self::try_from(n).ok()?)\n            .and_then(|&f| Self::try_from(f).ok())\n    }\n}\n\nimpl CheckedDoubleFactorial for usize {\n    /// Computes the double factorial of a [`usize`].\n    ///\n    /// If the input is too large, the function returns `None`.\n    ///\n    /// $$\n    /// f(n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(n!!) & \\text{if} \\\\quad n!! < 2^W, \\\\\\\\\n    ///     \\operatorname{None} & \\text{if} \\\\quad n!! \\geq 2^W,\n    /// \\\\end{cases}\n    /// $$\n    /// where $W$ is `usize::WIDTH`.\n    ///\n    /// $n!! = O(\\sqrt{n}(n/e)^{n/2})$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::factorial#checked_double_factorial).\n    #[inline]\n    fn checked_double_factorial(n: u64) -> Option<Self> {\n        if USIZE_IS_U32 {\n            u32::checked_double_factorial(n).map(Self::wrapping_from)\n        } else {\n            u64::checked_double_factorial(n).map(Self::wrapping_from)\n        }\n    }\n}\n\nmacro_rules! impl_factorials_b {\n    ($t:ident) => {\n        impl Factorial for $t {\n            /// Computes the factorial of a number.\n            ///\n            /// If the input is too large, the function panics. For a function that returns `None`\n            /// instead, try [`checked_factorial`](CheckedFactorial::checked_factorial).\n            ///\n            /// $$\n            /// f(n) = n! = 1 \\times 2 \\times 3 \\times \\cdots \\times n.\n            /// $$\n            ///\n            /// $n! = O(\\sqrt{n}(n/e)^n)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the output is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#factorial).\n            #[inline]\n            fn factorial(n: u64) -> $t {\n                $t::checked_factorial(n).unwrap()\n            }\n        }\n\n        impl DoubleFactorial for $t {\n            /// Computes the double factorial of a number.\n            ///\n            /// If the input is too large, the function panics. For a function that returns `None`\n            /// instead, try\n            /// [`checked_double_factorial`](CheckedDoubleFactorial::checked_double_factorial).\n            ///\n            /// $$\n            /// f(n) = n!! = n \\times (n - 2) \\times (n - 4) \\times \\cdots \\times i,\n            /// $$\n            /// where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.\n            ///\n            /// $n!! = O(\\sqrt{n}(n/e)^{n/2})$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the output is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#double_factorial).\n            #[inline]\n            fn double_factorial(n: u64) -> $t {\n                $t::checked_double_factorial(n).unwrap()\n            }\n        }\n\n        impl Multifactorial for $t {\n            /// Computes a multifactorial of a number.\n            ///\n            /// If the input is too large, the function panics. For a function that returns `None`\n            /// instead, try\n            /// [`checked_multifactorial`](CheckedMultifactorial::checked_multifactorial).\n            ///\n            /// $$\n            /// f(n, m) = n!^{(m)} = n \\times (n - m) \\times (n - 2m) \\times \\cdots \\times i.\n            /// $$\n            /// If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when\n            /// $n$ is divided by $m$.\n            ///\n            /// $n!^{(m)} = O(\\sqrt{n}(n/e)^{n/m})$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the output is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#multifactorial).\n            #[inline]\n            fn multifactorial(n: u64, m: u64) -> $t {\n                $t::checked_multifactorial(n, m).unwrap()\n            }\n        }\n\n        impl CheckedMultifactorial for $t {\n            /// Computes a multifactorial of a number.\n            ///\n            /// If the input is too large, the function returns `None`.\n            ///\n            /// $$\n            /// f(n, m) = \\\\begin{cases}\n            ///     \\operatorname{Some}(n!^{(m)}) & \\text{if} \\\\quad n!^{(m)} < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad n!^{(m)} \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// $n!^{(m)} = O(\\sqrt{n}(n/e)^{n/m})$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#checked_multifactorial).\n            #[inline]\n            fn checked_multifactorial(n: u64, m: u64) -> Option<$t> {\n                assert_ne!(m, 0);\n                if m == 1 {\n                    $t::checked_factorial(n)\n                } else if m == 2 {\n                    $t::checked_double_factorial(n)\n                } else {\n                    checked_multifactorial_naive(n, m)\n                }\n            }\n        }\n\n        impl Subfactorial for $t {\n            /// Computes the subfactorial of a number.\n            ///\n            /// The subfactorial of $n$ counts the number of derangements of a set of size $n$; a\n            /// derangement is a permutation with no fixed points.\n            ///\n            /// If the input is too large, the function panics. For a function that returns `None`\n            /// instead, try [`checked_subfactorial`](CheckedSubfactorial::checked_subfactorial).\n            ///\n            /// $$\n            /// f(n) = \\\\ !n = \\lfloor n!/e \\rfloor.\n            /// $$\n            ///\n            /// $!n = O(n!) = O(\\sqrt{n}(n/e)^n)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the output is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::factorial#subfactorial).\n            #[inline]\n            fn subfactorial(n: u64) -> $t {\n                $t::checked_subfactorial(n).unwrap()\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_factorials_b);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/floor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Floor, FloorAssign};\n\nmacro_rules! impl_floor {\n    ($f:ident) => {\n        impl Floor for $f {\n            type Output = $f;\n\n            /// This is a wrapper over the `floor` functions in [`libm`].\n            #[inline]\n            fn floor(self) -> $f {\n                libm::Libm::<$f>::floor(self)\n            }\n        }\n\n        impl FloorAssign for $f {\n            /// Replaces a number with its floor.\n            ///\n            /// A number's floor is the largest integer less than or equal to the number.\n            ///\n            /// $x \\gets \\lfloor x \\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::floor#floor_assign).\n            #[inline]\n            fn floor_assign(&mut self) {\n                *self = self.floor();\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_floor);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009, 2016 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Gcd, GcdAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse core::cmp::min;\n\n#[cfg(feature = \"test_build\")]\npub fn gcd_euclidean<T: PrimitiveUnsigned>(x: T, y: T) -> T {\n    if y == T::ZERO {\n        x\n    } else {\n        gcd_euclidean(y, x % y)\n    }\n}\n\n#[cfg(feature = \"test_build\")]\npub fn gcd_binary<T: PrimitiveUnsigned>(x: T, y: T) -> T {\n    if x == y {\n        x\n    } else if x == T::ZERO {\n        y\n    } else if y == T::ZERO {\n        x\n    } else if x.even() {\n        if y.odd() {\n            gcd_binary(x >> 1, y)\n        } else {\n            gcd_binary(x >> 1, y >> 1) << 1\n        }\n    } else if y.even() {\n        gcd_binary(x, y >> 1)\n    } else if x > y {\n        gcd_binary((x - y) >> 1, y)\n    } else {\n        gcd_binary((y - x) >> 1, x)\n    }\n}\n\npub_test! {gcd_fast_a<T: PrimitiveUnsigned>(mut x: T, mut y: T) -> T {\n    if x == T::ZERO {\n        return y;\n    }\n    if y == T::ZERO {\n        return x;\n    }\n    let x_zeros = x.trailing_zeros();\n    let y_zeros = y.trailing_zeros();\n    let f = min(x_zeros, y_zeros);\n    x >>= x_zeros;\n    y >>= y_zeros;\n    while x != y {\n        if x < y {\n            y -= x;\n            y >>= y.trailing_zeros();\n        } else {\n            x -= y;\n            x >>= x.trailing_zeros();\n        }\n    }\n    x << f\n}}\n\n#[cfg(feature = \"test_build\")]\n// This is a modified version of `n_xgcd` from `ulong_extras/xgcd.c`, FLINT 2.7.1.\npub fn gcd_fast_b<T: PrimitiveUnsigned>(mut x: T, y: T) -> T {\n    let mut v;\n    if x >= y {\n        v = y;\n    } else {\n        v = x;\n        x = y;\n    }\n    let mut d;\n    // x and y both have their top bit set.\n    if (x & v).get_highest_bit() {\n        d = x - v;\n        x = v;\n        v = d;\n    }\n    // The second value has its second-highest set.\n    while (v << 1u32).get_highest_bit() {\n        d = x - v;\n        x = v;\n        if d < v {\n            v = d;\n        } else if d < (v << 1) {\n            v = d - x;\n        } else {\n            v = d - (x << 1);\n        }\n    }\n    while v != T::ZERO {\n        // Overflow is not possible due to top 2 bits of v not being set. Avoid divisions when\n        // quotient < 4.\n        if x < (v << 2) {\n            d = x - v;\n            x = v;\n            if d < v {\n                v = d;\n            } else if d < (v << 1) {\n                v = d - x;\n            } else {\n                v = d - (x << 1);\n            }\n        } else {\n            let rem = x % v;\n            x = v;\n            v = rem;\n        }\n    }\n    x\n}\n\nmacro_rules! impl_gcd {\n    ($t:ident) => {\n        impl Gcd<$t> for $t {\n            type Output = $t;\n\n            /// Computes the GCD (greatest common divisor) of two numbers.\n            ///\n            /// The GCD of 0 and $n$, for any $n$, is 0. In particular, $\\gcd(0, 0) = 0$, which\n            /// makes sense if we interpret \"greatest\" to mean \"greatest by the divisibility order\".\n            ///\n            /// $$\n            /// f(x, y) = \\gcd(x, y).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::gcd#gcd).\n            #[inline]\n            fn gcd(self, other: $t) -> $t {\n                gcd_fast_a(self, other)\n            }\n        }\n\n        impl GcdAssign<$t> for $t {\n            /// Replaces another with the GCD (greatest common divisor) of it and another number.\n            ///\n            /// The GCD of 0 and $n$, for any $n$, is 0. In particular, $\\gcd(0, 0) = 0$, which\n            /// makes sense if we interpret \"greatest\" to mean \"greatest by the divisibility order\".\n            ///\n            /// $$\n            /// x \\gets \\gcd(x, y).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::gcd#gcd_assign).\n            #[inline]\n            fn gcd_assign(&mut self, other: $t) {\n                *self = gcd_fast_a(*self, other);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_gcd);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::IsPowerOf2;\nuse crate::num::conversion::traits::IntegerMantissaAndExponent;\n\nmacro_rules! impl_is_power_of_2_unsigned {\n    ($t:ident) => {\n        impl IsPowerOf2 for $t {\n            /// This is a wrapper over the `is_power_of_two` functions in the standard library, for\n            /// example [this one](u32::is_power_of_two).\n            #[inline]\n            fn is_power_of_2(&self) -> bool {\n                $t::is_power_of_two(*self)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_is_power_of_2_unsigned);\n\nmacro_rules! impl_is_power_of_2_primitive_float {\n    ($t:ident) => {\n        impl IsPowerOf2 for $t {\n            /// Determines whether a number is an integer power of 2.\n            ///\n            /// $f(x) = (\\exists n \\in \\Z : 2^n = x)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_power_of_2#is_power_of_2).\n            #[inline]\n            fn is_power_of_2(&self) -> bool {\n                self.is_finite() && *self > 0.0 && self.integer_mantissa() == 1\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_is_power_of_2_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1996, 1998, 2000-2004, 2008, 2010 Free Software Foundation, Inc.\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2008 Peter Shrimpton\n//\n//      Copyright © 2009 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::fail_on_untested_path;\nuse crate::num::arithmetic::traits::{\n    JacobiSymbol, KroneckerSymbol, LegendreSymbol, ModPowerOf2, NegAssign, Parity, UnsignedAbs,\n};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::SplitInHalf;\nuse crate::num::logic::traits::NotAssign;\nuse core::mem::swap;\n\npub_test! {jacobi_symbol_unsigned_simple<T: PrimitiveUnsigned>(mut a: T, mut n: T) -> i8 {\n    assert_ne!(n, T::ZERO);\n    assert!(n.odd());\n    a %= n;\n    let mut t = 1i8;\n    while a != T::ZERO {\n        while a.even() {\n            a >>= 1;\n            let r: u8 = n.mod_power_of_2(3).wrapping_into();\n            if r == 3 || r == 5 {\n                t.neg_assign();\n            }\n        }\n        swap(&mut a, &mut n);\n        if (a & n).get_bit(1) {\n            t.neg_assign();\n        }\n        a %= n;\n    }\n    if n == T::ONE {\n        t\n    } else {\n        0\n    }\n}}\n\n// Computes (a / b) where b is odd, and a and b are otherwise arbitrary two-limb numbers.\n//\n// This is equivalent to `mpn_jacobi_2` from `mpn/jacobi_2.c`, GMP 6.2.1, where `JACOBI_2_METHOD ==\n// 2` and `bit` is 0.\npub_test! {jacobi_symbol_unsigned_double_fast_2<T: PrimitiveUnsigned>(\n    mut x_1: T,\n    mut x_0: T,\n    mut y_1: T,\n    mut y_0: T,\n) -> i8 {\n    assert!(y_0.odd());\n    if y_1 == T::ZERO && y_0 == T::ONE {\n        // (x|1) = 1\n        return 1;\n    }\n    let mut bit = false;\n    if x_0 == T::ZERO {\n        if x_1 == T::ZERO {\n            // (0|y) = 0, y > 1\n            return 0;\n        }\n        let c = x_1.trailing_zeros();\n        if c.odd() && (y_0 ^ (y_0 >> 1)).get_bit(1) {\n            bit.not_assign();\n        }\n        x_0 = y_0;\n        y_0 = x_1 >> c;\n        if y_0 == T::ONE {\n            // (1|y) = 1\n            return if bit { -1 } else { 1 };\n        }\n        x_1 = y_1;\n        if (x_0 & y_0).get_bit(1) {\n            bit.not_assign();\n        }\n    } else {\n        if x_0.even() {\n            let c = x_0.trailing_zeros();\n            x_0 = (x_1 << (T::WIDTH - c)) | (x_0 >> c);\n            x_1 >>= c;\n            if c.odd() && (y_0 ^ (y_0 >> 1)).get_bit(1) {\n                bit.not_assign();\n            }\n        }\n        let mut skip_loop = false;\n        if x_1 == T::ZERO {\n            if y_1 == T::ZERO {\n                assert!(y_0.odd());\n                assert!(y_0 > T::ONE);\n                let j = x_0.jacobi_symbol(y_0);\n                return if bit { -j } else { j };\n            }\n                if (x_0 & y_0).get_bit(1) {\n                    bit.not_assign();\n                }\n                swap(&mut x_0, &mut y_0);\n                x_1 = y_1;\n                skip_loop = true;\n        }\n        if !skip_loop {\n            'outer: while y_1 != T::ZERO {\n                // Compute (x|y)\n                while x_1 > y_1 {\n                    (x_1, x_0) = T::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0);\n                    if x_0 == T::ZERO {\n                        let c = x_1.trailing_zeros();\n                        if c.odd() && (y_0 ^ (y_0 >> 1)).get_bit(1) {\n                            bit.not_assign();\n                        }\n                        x_0 = y_0;\n                        y_0 = x_1 >> c;\n                        x_1 = y_1;\n                        if (x_0 & y_0).get_bit(1) {\n                            bit.not_assign();\n                        }\n                        break 'outer;\n                    }\n                        let c = x_0.trailing_zeros();\n                        if c.odd() && (y_0 ^ (y_0 >> 1)).get_bit(1) {\n                            bit.not_assign();\n                        }\n                        x_0 = (x_1 << (T::WIDTH - c)) | (x_0 >> c);\n                        x_1 >>= c;\n                }\n                if x_1 != y_1 {\n                    if x_1 == T::ZERO {\n                        if (x_0 & y_0).get_bit(1) {\n                            bit.not_assign();\n                        }\n                        swap(&mut x_0, &mut y_0);\n                        x_1 = y_1;\n                        break;\n                    }\n                    if (x_0 & y_0).get_bit(1) {\n                        bit.not_assign();\n                    }\n                    // Compute (y|x)\n                    while y_1 > x_1 {\n                        (y_1, y_0) = T::xx_sub_yy_to_zz(y_1, y_0, x_1, x_0);\n                        if y_0 == T::ZERO {\n                            let c = y_1.trailing_zeros();\n                            if c.odd() & (x_0 ^ (x_0 >> 1)).get_bit(1) {\n                                bit.not_assign();\n                            }\n                            y_0 = y_1 >> c;\n                            if (x_0 & y_0).get_bit(1) {\n                                bit.not_assign();\n                            }\n                            break 'outer;\n                        }\n                        let c = y_0.trailing_zeros();\n                        if c.odd() & (x_0 ^ (x_0 >> 1)).get_bit(1) {\n                            bit.not_assign();\n                        }\n                        y_0 = (y_1 << (T::WIDTH - c)) | (y_0 >> c);\n                        y_1 >>= c;\n                    }\n                    if (x_0 & y_0).get_bit(1) {\n                        bit.not_assign();\n                    }\n                }\n                // Compute (x|y)\n                if x_1 == y_1 {\n                    if x_0 < y_0 {\n                        swap(&mut x_0, &mut y_0);\n                        if (x_0 & y_0).get_bit(1) {\n                            bit.not_assign();\n                        }\n                    }\n                    x_0 -= y_0;\n                    if x_0 == T::ZERO {\n                        return 0;\n                    }\n                    let c = x_0.trailing_zeros();\n                    if c.odd() & (y_0 ^ (y_0 >> 1)).get_bit(1) {\n                        bit.not_assign();\n                    }\n                    x_0 >>= c;\n                    if x_0 == T::ONE {\n                        return if bit { -1 } else { 1 };\n                    }\n                    swap(&mut x_0, &mut y_0);\n                    if (x_0 & y_0).get_bit(1) {\n                        bit.not_assign();\n                    }\n                    break;\n                }\n            }\n        }\n    }\n    // Compute (x|y), with y a single limb.\n    assert!(y_0.odd());\n    if y_0 == T::ONE {\n        // (x|1) = 1\n        return if bit { -1 } else { 1 };\n    }\n    while x_1 != T::ZERO {\n        x_1 -= if x_0 < y_0 { T::ONE } else { T::ZERO };\n        x_0.wrapping_sub_assign(y_0);\n        if x_0 == T::ZERO {\n            if x_1 == T::ZERO {\n                fail_on_untested_path(\n                    \"jacobi_symbol_unsigned_double_fast_2, x_1 == T::ZERO fourth time\",\n                );\n                return 0;\n            }\n            let c = x_1.trailing_zeros();\n            if c.odd() && (y_0 ^ (y_0 >> 1)).get_bit(1) {\n                bit.not_assign();\n            }\n            x_0 = x_1 >> c;\n            break;\n        }\n        let c = x_0.trailing_zeros();\n        x_0 = (x_1 << (T::WIDTH - c)) | (x_0 >> c);\n        x_1 >>= c;\n        if c.odd() && (y_0 ^ (y_0 >> 1)).get_bit(1) {\n            bit.not_assign();\n        }\n    }\n    assert!(y_0.odd());\n    assert!(y_0 > T::ONE);\n    let j = x_0.jacobi_symbol(y_0);\n    if bit {\n        -j\n    } else {\n        j\n    }\n}}\n\nfn jacobi_symbol_signed<\n    U: PrimitiveUnsigned,\n    S: ModPowerOf2<Output = U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    a: S,\n    n: S,\n) -> i8 {\n    assert!(n > S::ZERO);\n    assert!(n.odd());\n    let s = a.unsigned_abs().jacobi_symbol(n.unsigned_abs());\n    if a < S::ZERO && n.get_bit(1) { -s } else { s }\n}\n\nfn kronecker_symbol_unsigned<T: PrimitiveUnsigned>(a: T, b: T) -> i8 {\n    if b == T::ZERO {\n        i8::from(a == T::ONE)\n    } else if a.even() && b.even() {\n        0\n    } else {\n        let b_twos = b.trailing_zeros();\n        let mut s = a.jacobi_symbol(b >> b_twos);\n        if b_twos.odd() {\n            let m: u32 = a.mod_power_of_2(3).wrapping_into();\n            if m == 3 || m == 5 {\n                s.neg_assign();\n            }\n        }\n        s\n    }\n}\n\nfn kronecker_symbol_signed<U: PrimitiveUnsigned, S: ModPowerOf2<Output = U> + PrimitiveSigned>(\n    a: S,\n    b: S,\n) -> i8 {\n    if b == S::ZERO {\n        i8::from(a == S::ONE || a == S::NEGATIVE_ONE)\n    } else if a.even() && b.even() {\n        0\n    } else {\n        let b_twos = b.trailing_zeros();\n        let mut s = a.jacobi_symbol((b >> b_twos).abs());\n        if a < S::ZERO && b < S::ZERO {\n            s.neg_assign();\n        }\n        if b_twos.odd() {\n            let m: u32 = a.mod_power_of_2(3).wrapping_into();\n            if m == 3 || m == 5 {\n                s.neg_assign();\n            }\n        }\n        s\n    }\n}\n\nmacro_rules! impl_symbols {\n    ($u:ident, $s:ident) => {\n        impl LegendreSymbol<$u> for $u {\n            /// Computes the Legendre symbol of two numbers.\n            ///\n            /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n            /// computational benefit to requiring that the denominator be prime.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Panics\n            /// Panics if `n` is even.\n            ///\n            /// # Examples\n            /// See [here](super::kronecker_symbol#legendre_symbol).\n            #[inline]\n            fn legendre_symbol(self, n: $u) -> i8 {\n                self.jacobi_symbol(n)\n            }\n        }\n\n        impl LegendreSymbol<$s> for $s {\n            /// Computes the Legendre symbol of two numbers.\n            ///\n            /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n            /// computational benefit to requiring that the denominator be prime.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Panics\n            /// Panics if `n` is even or negative.\n            ///\n            /// # Examples\n            /// See [here](super::kronecker_symbol#legendre_symbol).\n            #[inline]\n            fn legendre_symbol(self, n: $s) -> i8 {\n                self.jacobi_symbol(n)\n            }\n        }\n\n        impl JacobiSymbol<$s> for $s {\n            /// Computes the Jacobi symbol of two numbers.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Panics\n            /// Panics if `n` is even.\n            ///\n            /// # Examples\n            /// See [here](super::kronecker_symbol#jacobi_symbol).\n            #[inline]\n            fn jacobi_symbol(self, n: $s) -> i8 {\n                jacobi_symbol_signed::<$u, $s>(self, n)\n            }\n        }\n\n        impl KroneckerSymbol<$u> for $u {\n            /// Computes the Kronecker symbol of two numbers.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::kronecker_symbol#kronecker_symbol).\n            #[inline]\n            fn kronecker_symbol(self, n: $u) -> i8 {\n                kronecker_symbol_unsigned(self, n)\n            }\n        }\n\n        impl KroneckerSymbol<$s> for $s {\n            /// Computes the Kronecker symbol of two numbers.\n            ///\n            /// $$\n            /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::kronecker_symbol#kronecker_symbol).\n            #[inline]\n            fn kronecker_symbol(self, n: $s) -> i8 {\n                kronecker_symbol_signed::<$u, $s>(self, n)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_symbols);\n\nmacro_rules! impl_jacobi_symbol_unsigned {\n    ($u:ident) => {\n        /// Computes the Jacobi symbol of two numbers.\n        ///\n        /// $$\n        /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n        /// $$\n        ///\n        /// # Worst-case complexity\n        /// $T(n) = O(n^2)$\n        ///\n        /// $M(n) = O(n)$\n        ///\n        /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n        /// other.significant_bits())`.\n        ///\n        /// # Panics\n        /// Panics if `n` is even or negative.\n        ///\n        /// # Examples\n        /// See [here](super::kronecker_symbol#jacobi_symbol).\n        impl JacobiSymbol<$u> for $u {\n            #[inline]\n            fn jacobi_symbol(self, n: $u) -> i8 {\n                jacobi_symbol_unsigned_simple(self, n)\n            }\n        }\n    };\n}\nimpl_jacobi_symbol_unsigned!(u8);\nimpl_jacobi_symbol_unsigned!(u16);\nimpl_jacobi_symbol_unsigned!(u32);\nimpl_jacobi_symbol_unsigned!(u64);\nimpl_jacobi_symbol_unsigned!(usize);\n\nimpl JacobiSymbol<Self> for u128 {\n    /// Computes the Jacobi symbol of two `u128`s.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// See [here](super::kronecker_symbol#jacobi_symbol).\n    #[inline]\n    fn jacobi_symbol(self, n: Self) -> i8 {\n        let (x_1, x_0) = self.split_in_half();\n        let (y_1, y_0) = n.split_in_half();\n        jacobi_symbol_unsigned_double_fast_2(x_1, x_0, y_1, y_0)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/lcm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedLcm, Lcm, LcmAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\n#[inline]\nfn lcm<T: PrimitiveUnsigned>(x: T, y: T) -> T {\n    checked_lcm(x, y).unwrap()\n}\n\nfn checked_lcm<T: PrimitiveUnsigned>(x: T, y: T) -> Option<T> {\n    if x == T::ZERO && y == T::ZERO {\n        Some(T::ZERO)\n    } else {\n        (x / x.gcd(y)).checked_mul(y)\n    }\n}\n\nmacro_rules! impl_lcm {\n    ($t:ident) => {\n        impl Lcm<$t> for $t {\n            type Output = $t;\n\n            /// Computes the LCM (least common multiple) of two numbers.\n            ///\n            /// $$\n            /// f(x, y) = \\operatorname{lcm}(x, y).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Panics\n            /// Panics if the result is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::lcm#lcm).\n            #[inline]\n            fn lcm(self, other: $t) -> $t {\n                lcm(self, other)\n            }\n        }\n\n        impl LcmAssign<$t> for $t {\n            /// Replaces a number with the LCM (least common multiple) of it and another number.\n            ///\n            /// $$\n            /// x \\gets \\operatorname{lcm}(x, y).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Panics\n            /// Panics if the result is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::lcm#lcm_assign).\n            #[inline]\n            fn lcm_assign(&mut self, other: $t) {\n                *self = lcm(*self, other);\n            }\n        }\n\n        impl CheckedLcm<$t> for $t {\n            type Output = $t;\n\n            /// Computes the LCM (least common multiple) of two numbers, returning `None` if the\n            /// result is too large to represent.\n            ///\n            /// $$\n            /// f(x, y) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\operatorname{lcm}(x, y)) &\n            ///         \\text{if} \\\\quad \\operatorname{lcm}(x, y) < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad \\operatorname{lcm}(x, y) \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::lcm#checked_lcm).\n            #[inline]\n            fn checked_lcm(self, other: $t) -> Option<$t> {\n                checked_lcm(self, other)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_lcm);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CeilingLogBase, CheckedLogBase, FloorLogBase};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn floor_log_base_naive<T: PrimitiveUnsigned>(x: T, base: T) -> u64 {\n    assert_ne!(x, T::ZERO);\n    assert!(base > T::ONE);\n    let mut result = 0;\n    let mut p = T::ONE;\n    // loop always executes at least once\n    while p <= x {\n        result += 1;\n        if let Some(next_p) = p.checked_mul(base) {\n            p = next_p;\n        } else {\n            break;\n        }\n    }\n    result - 1\n}\n\npub_test! {ceiling_log_base_naive<T: PrimitiveUnsigned>(x: T, base: T) -> u64 {\n    assert_ne!(x, T::ZERO);\n    assert!(base > T::ONE);\n    let mut result = 0;\n    let mut p = T::ONE;\n    while p < x {\n        result += 1;\n        if let Some(next_p) = p.checked_mul(base) {\n            p = next_p;\n        } else {\n            break;\n        }\n    }\n    result\n}}\n\npub_test! {checked_log_base_naive<T: PrimitiveUnsigned>(x: T, base: T) -> Option<u64> {\n    assert_ne!(x, T::ZERO);\n    assert!(base > T::ONE);\n    let mut result = 0;\n    let mut p = T::ONE;\n    while p < x {\n        result += 1;\n        if let Some(next_p) = p.checked_mul(base) {\n            p = next_p;\n        } else {\n            return None;\n        }\n    }\n    if p == x {\n        Some(result)\n    } else {\n        None\n    }\n}}\n\nfn floor_log_base<T: PrimitiveUnsigned>(x: T, base: T) -> u64 {\n    if let Some(log_base) = base.checked_log_base_2() {\n        x.floor_log_base_power_of_2(log_base)\n    } else {\n        floor_log_base_naive(x, base)\n    }\n}\n\nfn ceiling_log_base<T: PrimitiveUnsigned>(x: T, base: T) -> u64 {\n    if let Some(log_base) = base.checked_log_base_2() {\n        x.ceiling_log_base_power_of_2(log_base)\n    } else {\n        ceiling_log_base_naive(x, base)\n    }\n}\n\nfn checked_log_base<T: PrimitiveUnsigned>(x: T, base: T) -> Option<u64> {\n    if let Some(log_base) = base.checked_log_base_2() {\n        x.checked_log_base_power_of_2(log_base)\n    } else {\n        checked_log_base_naive(x, base)\n    }\n}\n\nmacro_rules! impl_log_base_unsigned {\n    ($t:ident) => {\n        impl FloorLogBase for $t {\n            type Output = u64;\n\n            /// Returns the floor of the base-$b$ logarithm of a positive integer.\n            ///\n            /// $f(x, b) = \\lfloor\\log_b x\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits() /\n            /// base.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is 0 or `base` is less than 2.\n            ///\n            /// # Examples\n            /// See [here](super::log_base#floor_log_base).\n            #[inline]\n            fn floor_log_base(self, base: $t) -> u64 {\n                // TODO use ilog once stabilized\n                floor_log_base(self, base)\n            }\n        }\n\n        impl CeilingLogBase for $t {\n            type Output = u64;\n\n            /// Returns the ceiling of the base-$b$ logarithm of a positive integer.\n            ///\n            /// $f(x, b) = \\lceil\\log_b x\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits() /\n            /// base.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is 0 or `base` is less than 2.\n            ///\n            /// # Examples\n            /// See [here](super::log_base#ceiling_log_base).\n            #[inline]\n            fn ceiling_log_base(self, base: $t) -> u64 {\n                ceiling_log_base(self, base)\n            }\n        }\n\n        impl CheckedLogBase for $t {\n            type Output = u64;\n\n            /// Returns the base-$b$ logarithm of a positive integer. If the integer is not a power\n            /// of $b$, `None` is returned.\n            ///\n            /// $$\n            /// f(x, b) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\log_b x) & \\text{if} \\\\quad \\log_b x \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits() /\n            /// base.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is 0 or `base` is less than 2.\n            ///\n            /// # Examples\n            /// See [here](super::log_base#checked_log_base).\n            #[inline]\n            fn checked_log_base(self, base: $t) -> Option<u64> {\n                checked_log_base(self, base)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_log_base_unsigned);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CeilingLogBase2, CheckedLogBase2, FloorLogBase2};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::SciMantissaAndExponent;\nuse crate::num::logic::traits::{LeadingZeros, TrailingZeros};\n\nfn floor_log_base_2<T: PrimitiveUnsigned>(x: T) -> u64 {\n    assert!(x != T::ZERO, \"Cannot take the base-2 logarithm of 0.\");\n    x.significant_bits() - 1\n}\n\nfn ceiling_log_base_2<T: PrimitiveUnsigned>(x: T) -> u64 {\n    let floor_log_base_2 = x.floor_log_base_2();\n    if x.is_power_of_2() {\n        floor_log_base_2\n    } else {\n        floor_log_base_2 + 1\n    }\n}\n\nfn checked_log_base_2<T: PrimitiveInt>(x: T) -> Option<u64> {\n    assert!(x != T::ZERO, \"Cannot take the base-2 logarithm of 0.\");\n    let leading_zeros = LeadingZeros::leading_zeros(x);\n    let trailing_zeros = TrailingZeros::trailing_zeros(x);\n    if leading_zeros + trailing_zeros == T::WIDTH - 1 {\n        Some(trailing_zeros)\n    } else {\n        None\n    }\n}\n\nmacro_rules! impl_log_base_2_unsigned {\n    ($t:ident) => {\n        impl FloorLogBase2 for $t {\n            type Output = u64;\n\n            /// Returns the floor of the base-2 logarithm of a positive integer.\n            ///\n            /// $f(x) = \\lfloor\\log_2 x\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_2#floor_log_base_2).\n            #[inline]\n            fn floor_log_base_2(self) -> u64 {\n                // TODO use ilog2 once stabilized\n                floor_log_base_2(self)\n            }\n        }\n\n        impl CeilingLogBase2 for $t {\n            type Output = u64;\n\n            /// Returns the ceiling of the base-2 logarithm of a positive integer.\n            ///\n            /// $f(x) = \\lceil\\log_2 x\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_2#ceiling_log_base_2).\n            #[inline]\n            fn ceiling_log_base_2(self) -> u64 {\n                ceiling_log_base_2(self)\n            }\n        }\n\n        impl CheckedLogBase2 for $t {\n            type Output = u64;\n\n            /// Returns the base-2 logarithm of a positive integer. If the integer is not a power of\n            /// 2, `None` is returned.\n            ///\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\log_2 x) & \\text{if} \\\\quad \\log_2 x \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_2#checked_log_base_2).\n            #[inline]\n            fn checked_log_base_2(self) -> Option<u64> {\n                checked_log_base_2(self)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_log_base_2_unsigned);\n\nmacro_rules! impl_log_base_2_primitive_float {\n    ($t:ident) => {\n        impl FloorLogBase2 for $t {\n            type Output = i64;\n\n            /// Returns the floor of the base-2 logarithm of a positive float.\n            ///\n            /// $f(x) = \\lfloor\\log_2 x\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is infinite, `NaN`, or less than or equal to zero.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_2#floor_log_base_2).\n            #[inline]\n            fn floor_log_base_2(self) -> i64 {\n                assert!(self > 0.0);\n                self.sci_exponent()\n            }\n        }\n\n        impl CeilingLogBase2 for $t {\n            type Output = i64;\n\n            /// Returns the ceiling of the base-2 logarithm of a positive float.\n            ///\n            /// $f(x) = \\lceil\\log_2 x\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is infinite, `NaN`, or less than or equal to zero.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_2#ceiling_log_base_2).\n            #[inline]\n            fn ceiling_log_base_2(self) -> i64 {\n                assert!(self > 0.0);\n                let (mantissa, exponent) = self.sci_mantissa_and_exponent();\n                if mantissa == 1.0 {\n                    exponent\n                } else {\n                    exponent + 1\n                }\n            }\n        }\n\n        impl CheckedLogBase2 for $t {\n            type Output = i64;\n\n            /// Returns the base-2 logarithm of a positive float If the float is not a power of 2,\n            /// `None` is returned.\n            ///\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\log_2 x) & \\text{if} \\\\quad \\log_2 x \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is infinite, `NaN`, or less than or equal to zero.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_2#checked_log_base_2).\n            #[inline]\n            fn checked_log_base_2(self) -> Option<i64> {\n                assert!(self > 0.0);\n                let (mantissa, exponent) = self.sci_mantissa_and_exponent();\n                if mantissa == 1.0 {\n                    Some(exponent)\n                } else {\n                    None\n                }\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_log_base_2_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    CeilingLogBasePowerOf2, CheckedLogBasePowerOf2, DivMod, DivRound, FloorLogBasePowerOf2,\n};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\nuse crate::rounding_modes::RoundingMode::*;\n\n#[cfg(feature = \"test_build\")]\npub fn ceiling_log_base_power_of_2_naive<T: PrimitiveUnsigned>(x: T, pow: u64) -> u64 {\n    assert_ne!(x, T::ZERO);\n    assert_ne!(pow, 0);\n    if pow >= T::WIDTH {\n        return u64::from(x != T::ONE);\n    }\n    let mut result = 0;\n    let mut p = T::ONE;\n    while p < x {\n        let highest_possible = p.leading_zeros() < pow;\n        result += 1;\n        if highest_possible {\n            break;\n        }\n        p <<= pow;\n    }\n    result\n}\n\nfn floor_log_base_power_of_2<T: PrimitiveUnsigned>(x: T, pow: u64) -> u64 {\n    assert!(x != T::ZERO, \"Cannot take the base-2 logarithm of 0.\");\n    assert_ne!(pow, 0);\n    (x.significant_bits() - 1) / pow\n}\n\nfn ceiling_log_base_power_of_2<T: PrimitiveUnsigned>(x: T, pow: u64) -> u64 {\n    assert!(x != T::ZERO, \"Cannot take the base-2 logarithm of 0.\");\n    assert_ne!(pow, 0);\n    let (floor_log, rem) = (x.significant_bits() - 1).div_mod(pow);\n    if rem == 0 && T::is_power_of_2(&x) {\n        floor_log\n    } else {\n        floor_log + 1\n    }\n}\n\nfn checked_log_base_power_of_2<T: PrimitiveUnsigned>(x: T, pow: u64) -> Option<u64> {\n    assert!(x != T::ZERO, \"Cannot take the base-2 logarithm of 0.\");\n    assert_ne!(pow, 0);\n    let (floor_log, rem) = (x.significant_bits() - 1).div_mod(pow);\n    if rem == 0 && T::is_power_of_2(&x) {\n        Some(floor_log)\n    } else {\n        None\n    }\n}\n\nmacro_rules! impl_log_base_power_of_2_unsigned {\n    ($t:ident) => {\n        impl FloorLogBasePowerOf2<u64> for $t {\n            type Output = u64;\n\n            /// Returns the floor of the base-$2^k$ logarithm of a positive integer.\n            ///\n            /// $f(x, k) = \\lfloor\\log_{2^k} x\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is infinite, `NaN`, or less than or equal to zero, or if `pow` is\n            /// zero.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_power_of_2#floor_log_base_power_of_2).\n            #[inline]\n            fn floor_log_base_power_of_2(self, pow: u64) -> u64 {\n                floor_log_base_power_of_2(self, pow)\n            }\n        }\n\n        impl CeilingLogBasePowerOf2<u64> for $t {\n            type Output = u64;\n\n            /// Returns the ceiling of the base-$2^k$ logarithm of a positive integer.\n            ///\n            /// $f(x, k) = \\lceil\\log_{2^k} x\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is infinite, `NaN`, or less than or equal to zero, or if `pow` is\n            /// zero.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_power_of_2#ceiling_log_base_power_of_2).\n            #[inline]\n            fn ceiling_log_base_power_of_2(self, pow: u64) -> u64 {\n                ceiling_log_base_power_of_2(self, pow)\n            }\n        }\n\n        impl CheckedLogBasePowerOf2<u64> for $t {\n            type Output = u64;\n\n            /// Returns the base-$2^k$ logarithm of a positive integer. If the integer is not a\n            /// power of $2^k$, `None` is returned.\n            ///\n            /// $$\n            /// f(x, k) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\log_{2^k} x) & \\text{if} \\\\quad \\log_{2^k} x \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is infinite, `NaN`, or less than or equal to zero, or if `pow` is\n            /// zero.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_power_of_2#ceiling_log_base_power_of_2).\n            #[inline]\n            fn checked_log_base_power_of_2(self, pow: u64) -> Option<u64> {\n                checked_log_base_power_of_2(self, pow)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_log_base_power_of_2_unsigned);\n\nmacro_rules! impl_log_base_power_of_2_primitive_float {\n    ($t:ident) => {\n        impl FloorLogBasePowerOf2<u64> for $t {\n            type Output = i64;\n\n            /// Returns the floor of the base-$2^k$ logarithm of a positive float.\n            ///\n            /// $f(x, k) = \\lfloor\\log_{2^k} x\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `pow` are 0.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_power_of_2#floor_log_base_power_of_2).\n            #[inline]\n            fn floor_log_base_power_of_2(self, pow: u64) -> i64 {\n                assert!(self > 0.0);\n                self.sci_exponent().div_round(i64::exact_from(pow), Floor).0\n            }\n        }\n\n        impl CeilingLogBasePowerOf2<u64> for $t {\n            type Output = i64;\n\n            /// Returns the ceiling of the base-$2^k$ logarithm of a positive float.\n            ///\n            /// $f(x, k) = \\lceil\\log_{2^k} x\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `pow` are 0.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_power_of_2#ceiling_log_base_power_of_2).\n            #[inline]\n            fn ceiling_log_base_power_of_2(self, pow: u64) -> i64 {\n                assert!(self > 0.0);\n                let (mantissa, exponent) = self.sci_mantissa_and_exponent();\n                let exact = mantissa == 1.0;\n                let (q, r) = exponent.div_mod(i64::exact_from(pow));\n                if exact && r == 0 { q } else { q + 1 }\n            }\n        }\n\n        impl CheckedLogBasePowerOf2<u64> for $t {\n            type Output = i64;\n\n            /// Returns the base-$2^k$ logarithm of a positive float. If the float is not a power of\n            /// $2^k$, `None` is returned.\n            ///\n            /// $$\n            /// f(x, k) = \\\\begin{cases}\n            ///     \\operatorname{Some}(\\log_{2^k} x) & \\text{if} \\\\quad \\log_{2^k} x \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `pow` are 0.\n            ///\n            /// # Examples\n            /// See [here](super::log_base_power_of_2#checked_log_base_power_of_2).\n            #[inline]\n            fn checked_log_base_power_of_2(self, pow: u64) -> Option<i64> {\n                assert!(self > 0.0);\n                let (mantissa, exponent) = self.sci_mantissa_and_exponent();\n                if mantissa != 1.0 {\n                    return None;\n                }\n                let (q, r) = exponent.div_mod(i64::exact_from(pow));\n                if r == 0 { Some(q) } else { None }\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_log_base_power_of_2_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// [`Abs`](traits::Abs), [`AbsAssign`](traits::AbsAssign), and\n/// [`UnsignedAbs`](traits::UnsignedAbs), traits for getting the absolute value of a number.\n///\n/// # abs_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::AbsAssign;\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// let mut x = 0i8;\n/// x.abs_assign();\n/// assert_eq!(x, 0i8);\n///\n/// let mut x = 100i64;\n/// x.abs_assign();\n/// assert_eq!(x, 100i64);\n///\n/// let mut x = -100i64;\n/// x.abs_assign();\n/// assert_eq!(x, 100i64);\n///\n/// let mut x = -0.0;\n/// x.abs_assign();\n/// assert_eq!(NiceFloat(x), NiceFloat(0.0));\n///\n/// let mut x = f64::NEGATIVE_INFINITY;\n/// x.abs_assign();\n/// assert_eq!(NiceFloat(x), NiceFloat(f64::INFINITY));\n///\n/// let mut x = 100.0;\n/// x.abs_assign();\n/// assert_eq!(NiceFloat(x), NiceFloat(100.0));\n///\n/// let mut x = -100.0;\n/// x.abs_assign();\n/// assert_eq!(NiceFloat(x), NiceFloat(100.0));\n/// ```\npub mod abs;\n/// [`AbsDiff`](traits::AbsDiff) and [`AbsDiffAssign`](traits::AbsDiffAssign), traits for getting\n/// the absolute value of the difference between two numbers.\n///\n/// # abs_diff\n/// ```\n/// assert_eq!(10u8.abs_diff(20u8), 10u8);\n/// assert_eq!(10i8.abs_diff(-10i8), 20u8);\n/// ```\n///\n/// # abs_diff_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::AbsDiffAssign;\n///\n/// let mut x = 10u8;\n/// x.abs_diff_assign(20u8);\n/// assert_eq!(x, 10);\n/// ```\npub mod abs_diff;\n/// [`AddMul`](traits::AddMul) and [`AddMulAssign`](traits::AddMulAssign), traits for adding a\n/// number and the product of two other numbers.\n///\n/// # add_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::AddMul;\n///\n/// assert_eq!(2u8.add_mul(3, 7), 23);\n/// assert_eq!(127i8.add_mul(-2, 100), -73);\n/// assert_eq!(1.0f32.add_mul(2.0, 3.0), 7.0);\n/// ```\n///\n/// # add_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::AddMulAssign;\n///\n/// let mut x = 2u8;\n/// x.add_mul_assign(3, 7);\n/// assert_eq!(x, 23);\n///\n/// let mut x = 127i8;\n/// x.add_mul_assign(-2, 100);\n/// assert_eq!(x, -73);\n///\n/// let mut x = 1.0f32;\n/// x.add_mul_assign(2.0, 3.0);\n/// assert_eq!(x, 7.0);\n/// ```\npub mod add_mul;\n/// [`ArithmeticCheckedShl`](traits::ArithmeticCheckedShl), a trait for left-shifting a number and\n/// checking whether the result is representable.\n///\n/// # arithmetic_checked_shl\n/// ```\n/// use malachite_base::num::arithmetic::traits::ArithmeticCheckedShl;\n///\n/// assert_eq!(3u8.arithmetic_checked_shl(6), Some(192u8));\n/// assert_eq!(3u8.arithmetic_checked_shl(7), None);\n/// assert_eq!(3u8.arithmetic_checked_shl(100), None);\n/// assert_eq!(0u8.arithmetic_checked_shl(100), Some(0u8));\n///\n/// assert_eq!(3u8.arithmetic_checked_shl(6), Some(192u8));\n/// assert_eq!(3u8.arithmetic_checked_shl(7), None);\n/// assert_eq!(3u8.arithmetic_checked_shl(100), None);\n/// assert_eq!(0u8.arithmetic_checked_shl(100), Some(0u8));\n/// assert_eq!(100u8.arithmetic_checked_shl(-3), Some(12u8));\n/// assert_eq!(100u8.arithmetic_checked_shl(-100), Some(0u8));\n///\n/// assert_eq!(3i8.arithmetic_checked_shl(5), Some(96i8));\n/// assert_eq!(3i8.arithmetic_checked_shl(6), None);\n/// assert_eq!((-3i8).arithmetic_checked_shl(5), Some(-96i8));\n/// assert_eq!((-3i8).arithmetic_checked_shl(6), None);\n/// assert_eq!(3i8.arithmetic_checked_shl(100), None);\n/// assert_eq!((-3i8).arithmetic_checked_shl(100), None);\n/// assert_eq!(0i8.arithmetic_checked_shl(100), Some(0i8));\n///\n/// assert_eq!(3i8.arithmetic_checked_shl(5), Some(96i8));\n/// assert_eq!(3i8.arithmetic_checked_shl(6), None);\n/// assert_eq!((-3i8).arithmetic_checked_shl(5), Some(-96i8));\n/// assert_eq!((-3i8).arithmetic_checked_shl(6), None);\n/// assert_eq!(3i8.arithmetic_checked_shl(100), None);\n/// assert_eq!((-3i8).arithmetic_checked_shl(100), None);\n/// assert_eq!(0i8.arithmetic_checked_shl(100), Some(0i8));\n/// assert_eq!(100i8.arithmetic_checked_shl(-3), Some(12i8));\n/// assert_eq!((-100i8).arithmetic_checked_shl(-3), Some(-13i8));\n/// assert_eq!(100i8.arithmetic_checked_shl(-100), Some(0i8));\n/// assert_eq!((-100i8).arithmetic_checked_shl(-100), Some(-1i8));\n/// ```\npub mod arithmetic_checked_shl;\n/// [`ArithmeticCheckedShr`](traits::ArithmeticCheckedShr), a trait for right-shifting a number and\n/// checking whether the result is representable.\n///\n/// # arithmetic_checked_shr\n/// ```\n/// use malachite_base::num::arithmetic::traits::ArithmeticCheckedShr;\n///\n/// assert_eq!(100u8.arithmetic_checked_shr(3), Some(12u8));\n/// assert_eq!(100u8.arithmetic_checked_shr(100), Some(0u8));\n/// assert_eq!(3u8.arithmetic_checked_shr(-6), Some(192u8));\n/// assert_eq!(3u8.arithmetic_checked_shr(-7), None);\n/// assert_eq!(3u8.arithmetic_checked_shr(-100), None);\n/// assert_eq!(0u8.arithmetic_checked_shr(-100), Some(0u8));\n///\n/// assert_eq!(100i8.arithmetic_checked_shr(3), Some(12i8));\n/// assert_eq!((-100i8).arithmetic_checked_shr(3), Some(-13i8));\n/// assert_eq!(100i8.arithmetic_checked_shr(100), Some(0i8));\n/// assert_eq!((-100i8).arithmetic_checked_shr(100), Some(-1i8));\n/// assert_eq!(3i8.arithmetic_checked_shr(-5), Some(96i8));\n/// assert_eq!(3i8.arithmetic_checked_shr(-6), None);\n/// assert_eq!((-3i8).arithmetic_checked_shr(-5), Some(-96i8));\n/// assert_eq!((-3i8).arithmetic_checked_shr(-6), None);\n/// assert_eq!(3i8.arithmetic_checked_shr(-100), None);\n/// assert_eq!((-3i8).arithmetic_checked_shr(-100), None);\n/// assert_eq!(0i8.arithmetic_checked_shr(-100), Some(0i8));\n/// ```\npub mod arithmetic_checked_shr;\n/// Traits for computing the binomial coefficient of two numbers. There is a trait whose\n/// implementations panic if the result cannot be represented, and a checked trait whose\n/// implementations return `None` in that case: [`BinomialCoefficient`](traits::BinomialCoefficient)\n/// and [`CheckedBinomialCoefficient`](traits::CheckedBinomialCoefficient).\n///\n/// # binomial_coefficient\n/// ```\n/// use malachite_base::num::arithmetic::traits::BinomialCoefficient;\n///\n/// assert_eq!(u8::binomial_coefficient(3, 0), 1);\n/// assert_eq!(u8::binomial_coefficient(3, 1), 3);\n/// assert_eq!(u8::binomial_coefficient(3, 2), 3);\n/// assert_eq!(u8::binomial_coefficient(3, 3), 1);\n/// assert_eq!(u8::binomial_coefficient(10, 5), 252);\n///\n/// assert_eq!(i8::binomial_coefficient(-3, 0), 1);\n/// assert_eq!(i8::binomial_coefficient(-3, 1), -3);\n/// assert_eq!(i8::binomial_coefficient(-3, 2), 6);\n/// assert_eq!(i8::binomial_coefficient(-3, 3), -10);\n/// ```\n///\n/// # checked_binomial_coefficient\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedBinomialCoefficient;\n///\n/// assert_eq!(u8::checked_binomial_coefficient(3, 0), Some(1));\n/// assert_eq!(u8::checked_binomial_coefficient(3, 1), Some(3));\n/// assert_eq!(u8::checked_binomial_coefficient(3, 2), Some(3));\n/// assert_eq!(u8::checked_binomial_coefficient(3, 3), Some(1));\n/// assert_eq!(u8::checked_binomial_coefficient(10, 5), Some(252));\n/// assert_eq!(u8::checked_binomial_coefficient(11, 5), None);\n///\n/// assert_eq!(i8::checked_binomial_coefficient(-3, 0), Some(1));\n/// assert_eq!(i8::checked_binomial_coefficient(-3, 1), Some(-3));\n/// assert_eq!(i8::checked_binomial_coefficient(-3, 2), Some(6));\n/// assert_eq!(i8::checked_binomial_coefficient(-3, 3), Some(-10));\n/// assert_eq!(i8::checked_binomial_coefficient(-3, -3), None);\n/// assert_eq!(i8::checked_binomial_coefficient(11, 5), None);\n/// ```\npub mod binomial_coefficient;\n/// [`Ceiling`](traits::Ceiling) and [`CeilingAssign`](traits::CeilingAssign), traits for computing\n/// the ceiling of a number.\n///\n/// # ceiling\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingAssign;\n///\n/// let mut x = 1.5f32;\n/// x.ceiling_assign();\n/// assert_eq!(x, 2.0);\n///\n/// let mut x = -1.5f32;\n/// x.ceiling_assign();\n/// assert_eq!(x, -1.0);\n/// ```\npub mod ceiling;\n/// [`CheckedAbs`](traits::CheckedAbs), a trait for computing the absolute value of number and\n/// checking whether the result is representable.\npub mod checked_abs;\n/// [`CheckedAdd`](traits::CheckedAdd), a trait for adding two numbers and checking whether the\n/// result is representable.\npub mod checked_add;\n/// [`CheckedAddMul`](traits::CheckedAddMul), a trait for adding a number and the product of two\n/// other numbers, and checking whether the result is representable.\n///\n/// # checked_add_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedAddMul;\n///\n/// assert_eq!(2u8.checked_add_mul(3, 7), Some(23));\n/// assert_eq!(2u8.checked_add_mul(20, 20), None);\n///\n/// assert_eq!(127i8.checked_add_mul(-2, 100), Some(-73));\n/// assert_eq!((-127i8).checked_add_mul(-2, 100), None);\n/// ```\npub mod checked_add_mul;\n/// [`CheckedDiv`](traits::CheckedDiv), a trait for dividing two numbers and checking whether the\n/// result is representable.\npub mod checked_div;\n/// [`CheckedMul`](traits::CheckedMul), a trait for multiplying two numbers and checking whether the\n/// result is representable.\npub mod checked_mul;\n/// [`CheckedNeg`](traits::CheckedNeg), a trait for negating a number and checking whether the\n/// result is representable.\npub mod checked_neg;\n/// [`CheckedNextPowerOf2`](traits::CheckedNextPowerOf2), a trait for getting the next-highest power\n/// of 2, if it's representable.\npub mod checked_next_power_of_2;\n/// [`CheckedPow`](traits::CheckedPow), a trait for raising a number to the power of a [`u64`] and\n/// checking whether the result is representable.\npub mod checked_pow;\n/// [`CheckedSquare`](traits::CheckedSquare), a trait for squaring a number and checking whether the\n/// result is representable.\n///\n/// # checked_square\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedSquare;\n///\n/// assert_eq!(3u8.checked_square(), Some(9));\n/// assert_eq!((-1000i32).checked_square(), Some(1000000));\n/// assert_eq!((1000u16).checked_square(), None);\n/// ```\npub mod checked_square;\n/// [`CheckedSub`](traits::CheckedSub), a trait for subtracting two numbers and checking whether the\n/// result is representable.\npub mod checked_sub;\n/// [`CheckedSubMul`](traits::CheckedSubMul), a trait for subtracting the product of two numbers\n/// from another number, and checking whether the result is representable.\n///\n/// # checked_sub_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedSubMul;\n///\n/// assert_eq!(60u8.checked_sub_mul(5, 10), Some(10));\n/// assert_eq!(2u8.checked_sub_mul(10, 5), None);\n///\n/// assert_eq!(127i8.checked_sub_mul(2, 100), Some(-73));\n/// assert_eq!((-127i8).checked_sub_mul(2, 100), None);\n/// ```\npub mod checked_sub_mul;\n/// [`CoprimeWith`](traits::CoprimeWith), a trait for determining whether two numbers are coprime.\n///\n/// # coprime_with\n/// ```\n/// use malachite_base::num::arithmetic::traits::CoprimeWith;\n///\n/// assert_eq!(0u8.coprime_with(0), false);\n/// assert_eq!(0u8.coprime_with(1), true);\n/// assert_eq!(6u8.coprime_with(1), true);\n/// assert_eq!(3u8.coprime_with(5), true);\n/// assert_eq!(6u8.coprime_with(4), false);\n/// assert_eq!(6u8.coprime_with(35), true);\n/// ```\npub mod coprime_with;\n/// [`DivExact`](traits::DivExact) and [`DivExactAssign`](traits::DivExactAssign), traits for\n/// dividing two numbers when it's known that the division is exact.\n///\n/// # div_exact\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivExact;\n///\n/// // 123 * 456 = 56088\n/// #[allow(unstable_name_collisions)]\n/// {\n///     assert_eq!(56088u32.div_exact(456), 123);\n/// }\n///\n/// // -123 * -456 = 56088\n/// #[allow(unstable_name_collisions)]\n/// {\n///     assert_eq!(56088i64.div_exact(-456), -123);\n/// }\n/// ```\n///\n/// # div_exact_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivExactAssign;\n///\n/// // 123 * 456 = 56088\n/// let mut x = 56088u32;\n/// x.div_exact_assign(456);\n/// assert_eq!(x, 123);\n///\n/// // -123 * -456 = 56088\n/// let mut x = 56088i64;\n/// x.div_exact_assign(-456);\n/// assert_eq!(x, -123);\n/// ```\npub mod div_exact;\n/// Traits for simultaneously finding the quotient and remainder of two numbers, subject to various\n/// rounding rules.\n///\n/// These are the traits:\n///\n/// | rounding     | by value or reference           | by mutable reference (assignment)      |\n/// |--------------|---------------------------------|----------------------------------------|\n/// | towards $-\\infty$ | [`DivMod`](traits::DivMod) | [`DivAssignMod`](traits::DivAssignMod) |\n/// | towards 0         | [`DivRem`](traits::DivRem) | [`DivAssignRem`](traits::DivAssignRem) |\n/// | towards $\\infty$  | [`CeilingDivMod`](traits::CeilingDivMod) | [`CeilingDivAssignMod`](traits::CeilingDivAssignMod) |\n/// | towards $\\infty$  | [`CeilingDivNegMod`](traits::CeilingDivNegMod) | [`CeilingDivAssignNegMod`](traits::CeilingDivAssignNegMod) |\n///\n/// [`CeilingDivMod`](traits::CeilingDivMod) and [`CeilingDivNegMod`](traits::CeilingDivNegMod) are\n/// similar. The difference is that [`CeilingDivMod`](traits::CeilingDivMod) returns a remainder\n/// less than or equal to 0, so that the usual relation $x = qy + r$ is satisfied, while\n/// [`CeilingDivNegMod`](traits::CeilingDivNegMod) returns a remainder greater than or equal to\n/// zero. This allows the remainder to have an unsigned type, but modifies the relation to $x = qy\n/// - r$.\n///\n/// # div_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivMod;\n///\n/// // 2 * 10 + 3 = 23\n/// assert_eq!(23u8.div_mod(10), (2, 3));\n///\n/// // 9 * 5 + 0 = 45\n/// assert_eq!(45u32.div_mod(5), (9, 0));\n///\n/// // 2 * 10 + 3 = 23\n/// assert_eq!(23i8.div_mod(10), (2, 3));\n///\n/// // -3 * -10 + -7 = 23\n/// assert_eq!(23i16.div_mod(-10), (-3, -7));\n///\n/// // -3 * 10 + 7 = -23\n/// assert_eq!((-23i32).div_mod(10), (-3, 7));\n///\n/// // 2 * -10 + -3 = -23\n/// assert_eq!((-23i64).div_mod(-10), (2, -3));\n/// ```\n///\n/// # div_assign_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivAssignMod;\n///\n/// // 2 * 10 + 3 = 23\n/// let mut x = 23u8;\n/// assert_eq!(x.div_assign_mod(10), 3);\n/// assert_eq!(x, 2);\n///\n/// // 9 * 5 + 0 = 45\n/// let mut x = 45u32;\n/// assert_eq!(x.div_assign_mod(5), 0);\n/// assert_eq!(x, 9);\n///\n/// // 2 * 10 + 3 = 23\n/// let mut x = 23i8;\n/// assert_eq!(x.div_assign_mod(10), 3);\n/// assert_eq!(x, 2);\n///\n/// // -3 * -10 + -7 = 23\n/// let mut x = 23i16;\n/// assert_eq!(x.div_assign_mod(-10), -7);\n/// assert_eq!(x, -3);\n///\n/// // -3 * 10 + 7 = -23\n/// let mut x = -23i32;\n/// assert_eq!(x.div_assign_mod(10), 7);\n/// assert_eq!(x, -3);\n///\n/// // 2 * -10 + -3 = -23\n/// let mut x = -23i64;\n/// assert_eq!(x.div_assign_mod(-10), -3);\n/// assert_eq!(x, 2);\n/// ```\n///\n/// # div_rem\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivRem;\n///\n/// // 2 * 10 + 3 = 23\n/// assert_eq!(23u8.div_rem(10), (2, 3));\n///\n/// // 9 * 5 + 0 = 45\n/// assert_eq!(45u32.div_rem(5), (9, 0));\n///\n/// // 2 * 10 + 3 = 23\n/// assert_eq!(23i8.div_rem(10), (2, 3));\n///\n/// // -2 * -10 + 3 = 23\n/// assert_eq!(23i16.div_rem(-10), (-2, 3));\n///\n/// // -2 * 10 + -3 = -23\n/// assert_eq!((-23i32).div_rem(10), (-2, -3));\n///\n/// // 2 * -10 + -3 = -23\n/// assert_eq!((-23i64).div_rem(-10), (2, -3));\n/// ```\n///\n/// # div_assign_rem\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivAssignRem;\n///\n/// // 2 * 10 + 3 = 23\n/// let mut x = 23u8;\n/// assert_eq!(x.div_assign_rem(10), 3);\n/// assert_eq!(x, 2);\n///\n/// // 9 * 5 + 0 = 45\n/// let mut x = 45u32;\n/// assert_eq!(x.div_assign_rem(5), 0);\n/// assert_eq!(x, 9);\n///\n/// // 2 * 10 + 3 = 23\n/// let mut x = 23i8;\n/// assert_eq!(x.div_assign_rem(10), 3);\n/// assert_eq!(x, 2);\n///\n/// // -2 * -10 + 3 = 23\n/// let mut x = 23i16;\n/// assert_eq!(x.div_assign_rem(-10), 3);\n/// assert_eq!(x, -2);\n///\n/// // -2 * 10 + -3 = -23\n/// let mut x = -23i32;\n/// assert_eq!(x.div_assign_rem(10), -3);\n/// assert_eq!(x, -2);\n///\n/// // 2 * -10 + -3 = -23\n/// let mut x = -23i64;\n/// assert_eq!(x.div_assign_rem(-10), -3);\n/// assert_eq!(x, 2);\n/// ```\n///\n/// # ceiling_div_neg_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingDivNegMod;\n///\n/// // 3 * 10 - 7 = 23\n/// assert_eq!(23u8.ceiling_div_neg_mod(10), (3, 7));\n///\n/// // 9 * 5 + 0 = 45\n/// assert_eq!(45u32.ceiling_div_neg_mod(5), (9, 0));\n/// ```\n///\n/// # ceiling_div_assign_neg_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingDivAssignNegMod;\n///\n/// // 3 * 10 - 7 = 23\n/// let mut x = 23u8;\n/// assert_eq!(x.ceiling_div_assign_neg_mod(10), 7);\n/// assert_eq!(x, 3);\n///\n/// // 9 * 5 + 0 = 45\n/// let mut x = 45u32;\n/// assert_eq!(x.ceiling_div_assign_neg_mod(5), 0);\n/// assert_eq!(x, 9);\n/// ```\n///\n/// # ceiling_div_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingDivMod;\n///\n/// // 3 * 10 + -7 = 23\n/// assert_eq!(23i8.ceiling_div_mod(10), (3, -7));\n///\n/// // -2 * -10 + 3 = 23\n/// assert_eq!(23i16.ceiling_div_mod(-10), (-2, 3));\n///\n/// // -2 * 10 + -3 = -23\n/// assert_eq!((-23i32).ceiling_div_mod(10), (-2, -3));\n///\n/// // 3 * -10 + 7 = -23\n/// assert_eq!((-23i64).ceiling_div_mod(-10), (3, 7));\n/// ```\n///\n/// # ceiling_div_assign_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingDivAssignMod;\n///\n/// // 3 * 10 + -7 = 23\n/// let mut x = 23i8;\n/// assert_eq!(x.ceiling_div_assign_mod(10), -7);\n/// assert_eq!(x, 3);\n///\n/// // -2 * -10 + 3 = 23\n/// let mut x = 23i16;\n/// assert_eq!(x.ceiling_div_assign_mod(-10), 3);\n/// assert_eq!(x, -2);\n///\n/// // -2 * 10 + -3 = -23\n/// let mut x = -23i32;\n/// assert_eq!(x.ceiling_div_assign_mod(10), -3);\n/// assert_eq!(x, -2);\n///\n/// // 3 * -10 + 7 = -23\n/// let mut x = -23i64;\n/// assert_eq!(x.ceiling_div_assign_mod(-10), 7);\n/// assert_eq!(x, 3);\n/// ```\npub mod div_mod;\n/// [`DivRound`](traits::DivRound) and [`DivExactAssign`](traits::DivRoundAssign), traits for\n/// dividing two numbers according to a specified\n/// [`RoundingMode`](crate::rounding_modes::RoundingMode).\n///\n/// # div_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivRound;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(10u8.div_round(4, Down), (2, Less));\n/// assert_eq!(10u16.div_round(4, Up), (3, Greater));\n/// assert_eq!(10u32.div_round(5, Exact), (2, Equal));\n/// assert_eq!(10u64.div_round(3, Nearest), (3, Less));\n/// assert_eq!(20u128.div_round(3, Nearest), (7, Greater));\n/// assert_eq!(10usize.div_round(4, Nearest), (2, Less));\n/// assert_eq!(14u8.div_round(4, Nearest), (4, Greater));\n///\n/// assert_eq!((-10i8).div_round(4, Down), (-2, Greater));\n/// assert_eq!((-10i16).div_round(4, Up), (-3, Less));\n/// assert_eq!((-10i32).div_round(5, Exact), (-2, Equal));\n/// assert_eq!((-10i64).div_round(3, Nearest), (-3, Greater));\n/// assert_eq!((-20i128).div_round(3, Nearest), (-7, Less));\n/// assert_eq!((-10isize).div_round(4, Nearest), (-2, Greater));\n/// assert_eq!((-14i8).div_round(4, Nearest), (-4, Less));\n///\n/// assert_eq!((-10i16).div_round(-4, Down), (2, Less));\n/// assert_eq!((-10i32).div_round(-4, Up), (3, Greater));\n/// assert_eq!((-10i64).div_round(-5, Exact), (2, Equal));\n/// assert_eq!((-10i128).div_round(-3, Nearest), (3, Less));\n/// assert_eq!((-20isize).div_round(-3, Nearest), (7, Greater));\n/// assert_eq!((-10i8).div_round(-4, Nearest), (2, Less));\n/// assert_eq!((-14i16).div_round(-4, Nearest), (4, Greater));\n/// ```\n///\n/// # div_round_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivRoundAssign;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = 10u8;\n/// assert_eq!(x.div_round_assign(4, Down), Less);\n/// assert_eq!(x, 2);\n///\n/// let mut x = 10u16;\n/// assert_eq!(x.div_round_assign(4, Up), Greater);\n/// assert_eq!(x, 3);\n///\n/// let mut x = 10u32;\n/// assert_eq!(x.div_round_assign(5, Exact), Equal);\n/// assert_eq!(x, 2);\n///\n/// let mut x = 10u64;\n/// assert_eq!(x.div_round_assign(3, Nearest), Less);\n/// assert_eq!(x, 3);\n///\n/// let mut x = 20u128;\n/// assert_eq!(x.div_round_assign(3, Nearest), Greater);\n/// assert_eq!(x, 7);\n///\n/// let mut x = 10usize;\n/// assert_eq!(x.div_round_assign(4, Nearest), Less);\n/// assert_eq!(x, 2);\n///\n/// let mut x = 14u8;\n/// assert_eq!(x.div_round_assign(4, Nearest), Greater);\n/// assert_eq!(x, 4);\n///\n/// let mut x = -10i8;\n/// assert_eq!(x.div_round_assign(4, Down), Greater);\n/// assert_eq!(x, -2);\n///\n/// let mut x = -10i16;\n/// assert_eq!(x.div_round_assign(4, Up), Less);\n/// assert_eq!(x, -3);\n///\n/// let mut x = -10i32;\n/// assert_eq!(x.div_round_assign(5, Exact), Equal);\n/// assert_eq!(x, -2);\n///\n/// let mut x = -10i64;\n/// assert_eq!(x.div_round_assign(3, Nearest), Greater);\n/// assert_eq!(x, -3);\n///\n/// let mut x = -20i128;\n/// assert_eq!(x.div_round_assign(3, Nearest), Less);\n/// assert_eq!(x, -7);\n///\n/// let mut x = -10isize;\n/// assert_eq!(x.div_round_assign(4, Nearest), Greater);\n/// assert_eq!(x, -2);\n///\n/// let mut x = -14i8;\n/// assert_eq!(x.div_round_assign(4, Nearest), Less);\n/// assert_eq!(x, -4);\n///\n/// let mut x = -10i16;\n/// assert_eq!(x.div_round_assign(-4, Down), Less);\n/// assert_eq!(x, 2);\n///\n/// let mut x = -10i32;\n/// assert_eq!(x.div_round_assign(-4, Up), Greater);\n/// assert_eq!(x, 3);\n///\n/// let mut x = -10i64;\n/// assert_eq!(x.div_round_assign(-5, Exact), Equal);\n/// assert_eq!(x, 2);\n///\n/// let mut x = -10i128;\n/// assert_eq!(x.div_round_assign(-3, Nearest), Less);\n/// assert_eq!(x, 3);\n///\n/// let mut x = -20isize;\n/// assert_eq!(x.div_round_assign(-3, Nearest), Greater);\n/// assert_eq!(x, 7);\n///\n/// let mut x = -10i8;\n/// assert_eq!(x.div_round_assign(-4, Nearest), Less);\n/// assert_eq!(x, 2);\n///\n/// let mut x = -14i16;\n/// assert_eq!(x.div_round_assign(-4, Nearest), Greater);\n/// assert_eq!(x, 4);\n/// ```\npub mod div_round;\n/// [`DivisibleBy`](traits::DivisibleBy), a trait for determining whether one number is divisible by\n/// another.\n///\n/// # divisible_by\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivisibleBy;\n///\n/// assert_eq!(0u8.divisible_by(0), true);\n/// assert_eq!(100u16.divisible_by(3), false);\n/// assert_eq!(102u32.divisible_by(3), true);\n///\n/// assert_eq!(0i8.divisible_by(0), true);\n/// assert_eq!((-100i16).divisible_by(-3), false);\n/// assert_eq!(102i32.divisible_by(-3), true);\n/// ```\npub mod divisible_by;\n/// [`DivisibleByPowerOf2`](traits::DivisibleByPowerOf2), a trait for determining whether a number\n/// is divisible by $2^k$.\n///\n/// # divisible_by_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\n///\n/// assert_eq!(0u8.divisible_by_power_of_2(100), true);\n/// assert_eq!(96u16.divisible_by_power_of_2(5), true);\n/// assert_eq!(96u32.divisible_by_power_of_2(6), false);\n///\n/// assert_eq!(0i8.divisible_by_power_of_2(100), true);\n/// assert_eq!((-96i16).divisible_by_power_of_2(5), true);\n/// assert_eq!(96i32.divisible_by_power_of_2(6), false);\n/// ```\npub mod divisible_by_power_of_2;\n/// [`EqMod`](traits::EqMod), a trait for determining whether one number is equal by another modulo\n/// a third.\n///\n/// # eq_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::EqMod;\n///\n/// assert_eq!(123u16.eq_mod(223, 100), true);\n/// assert_eq!((-123i32).eq_mod(277, 100), true);\n/// assert_eq!((-123i64).eq_mod(278, 100), false);\n/// ```\npub mod eq_mod;\n/// [`EqModPowerOf2`](traits::EqModPowerOf2), a trait for determining whether one number is equal to\n/// another modulo $2^k$.\n///\n/// # eq_mod_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::EqModPowerOf2;\n///\n/// assert_eq!(0u16.eq_mod_power_of_2(256, 8), true);\n/// assert_eq!((-0b1101i32).eq_mod_power_of_2(0b11011, 3), true);\n/// assert_eq!((-0b1101i64).eq_mod_power_of_2(0b11011, 4), false);\n/// ```\npub mod eq_mod_power_of_2;\n/// [`ExtendedGcd`](traits::ExtendedGcd), a trait for computing the GCD (greatest common divisor) of\n/// two numbers as well as the coefficients of Bézout's identity $ax+by=\\gcd(a,b)$.\n///\n/// # extended_gcd\n/// ```\n/// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n///\n/// assert_eq!(3u8.extended_gcd(5), (1, 2, -1));\n/// assert_eq!(240u16.extended_gcd(46), (2, -9, 47));\n/// assert_eq!((-111i16).extended_gcd(300), (3, 27, 10));\n/// ```\npub mod extended_gcd;\n/// Traits for computing the factorial, double factorial, multifactorial, and subfactorial. Each\n/// function has a trait whose implementations panic if the result cannot be represented, and a\n/// checked trait whose implementations return `None` in that case. The traits are\n/// [`Factorial`](traits::Factorial), [`DoubleFactorial`](traits::DoubleFactorial),\n/// [`Multifactorial`](traits::Multifactorial), [`Subfactorial`](traits::Subfactorial),\n/// [`CheckedFactorial`](traits::CheckedFactorial),\n/// [`CheckedDoubleFactorial`](traits::CheckedDoubleFactorial),\n/// [`CheckedMultifactorial`](traits::CheckedMultifactorial), and\n/// [`CheckedSubfactorial`](traits::CheckedSubfactorial).\n///\n/// # factorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::Factorial;\n///\n/// assert_eq!(u8::factorial(0), 1);\n/// assert_eq!(u8::factorial(1), 1);\n/// assert_eq!(u8::factorial(2), 2);\n/// assert_eq!(u8::factorial(3), 6);\n/// assert_eq!(u8::factorial(4), 24);\n/// assert_eq!(u8::factorial(5), 120);\n/// assert_eq!(u32::factorial(10), 3628800);\n/// ```\n///\n/// # checked_factorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedFactorial;\n///\n/// assert_eq!(u8::checked_factorial(0), Some(1));\n/// assert_eq!(u8::checked_factorial(1), Some(1));\n/// assert_eq!(u8::checked_factorial(2), Some(2));\n/// assert_eq!(u8::checked_factorial(3), Some(6));\n/// assert_eq!(u8::checked_factorial(4), Some(24));\n/// assert_eq!(u8::checked_factorial(5), Some(120));\n/// assert_eq!(u8::checked_factorial(6), None);\n/// assert_eq!(u32::checked_factorial(10), Some(3628800));\n/// assert_eq!(u32::checked_factorial(100), None);\n/// ```\n///\n/// # double_factorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::DoubleFactorial;\n///\n/// assert_eq!(u8::double_factorial(0), 1);\n/// assert_eq!(u8::double_factorial(1), 1);\n/// assert_eq!(u8::double_factorial(2), 2);\n/// assert_eq!(u8::double_factorial(3), 3);\n/// assert_eq!(u8::double_factorial(4), 8);\n/// assert_eq!(u8::double_factorial(5), 15);\n/// assert_eq!(u8::double_factorial(6), 48);\n/// assert_eq!(u8::double_factorial(7), 105);\n/// assert_eq!(u32::double_factorial(19), 654729075);\n/// assert_eq!(u32::double_factorial(20), 3715891200);\n/// ```\n///\n/// # checked_double_factorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedDoubleFactorial;\n///\n/// assert_eq!(u8::checked_double_factorial(0), Some(1));\n/// assert_eq!(u8::checked_double_factorial(1), Some(1));\n/// assert_eq!(u8::checked_double_factorial(2), Some(2));\n/// assert_eq!(u8::checked_double_factorial(3), Some(3));\n/// assert_eq!(u8::checked_double_factorial(4), Some(8));\n/// assert_eq!(u8::checked_double_factorial(5), Some(15));\n/// assert_eq!(u8::checked_double_factorial(6), Some(48));\n/// assert_eq!(u8::checked_double_factorial(7), Some(105));\n/// assert_eq!(u8::checked_double_factorial(8), None);\n/// assert_eq!(u32::checked_double_factorial(19), Some(654729075));\n/// assert_eq!(u32::checked_double_factorial(20), Some(3715891200));\n/// assert_eq!(u32::checked_double_factorial(100), None);\n/// ```\n///\n/// # multifactorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::Multifactorial;\n///\n/// assert_eq!(u8::multifactorial(0, 1), 1);\n/// assert_eq!(u8::multifactorial(1, 1), 1);\n/// assert_eq!(u8::multifactorial(2, 1), 2);\n/// assert_eq!(u8::multifactorial(3, 1), 6);\n/// assert_eq!(u8::multifactorial(4, 1), 24);\n/// assert_eq!(u8::multifactorial(5, 1), 120);\n///\n/// assert_eq!(u8::multifactorial(0, 2), 1);\n/// assert_eq!(u8::multifactorial(1, 2), 1);\n/// assert_eq!(u8::multifactorial(2, 2), 2);\n/// assert_eq!(u8::multifactorial(3, 2), 3);\n/// assert_eq!(u8::multifactorial(4, 2), 8);\n/// assert_eq!(u8::multifactorial(5, 2), 15);\n/// assert_eq!(u8::multifactorial(6, 2), 48);\n/// assert_eq!(u8::multifactorial(7, 2), 105);\n///\n/// assert_eq!(u8::multifactorial(0, 3), 1);\n/// assert_eq!(u8::multifactorial(1, 3), 1);\n/// assert_eq!(u8::multifactorial(2, 3), 2);\n/// assert_eq!(u8::multifactorial(3, 3), 3);\n/// assert_eq!(u8::multifactorial(4, 3), 4);\n/// assert_eq!(u8::multifactorial(5, 3), 10);\n/// assert_eq!(u8::multifactorial(6, 3), 18);\n/// assert_eq!(u8::multifactorial(7, 3), 28);\n/// assert_eq!(u8::multifactorial(8, 3), 80);\n/// assert_eq!(u8::multifactorial(9, 3), 162);\n///\n/// assert_eq!(u32::multifactorial(10, 1), 3628800);\n/// assert_eq!(u32::multifactorial(20, 2), 3715891200);\n/// assert_eq!(u32::multifactorial(25, 3), 608608000);\n/// ```\n///\n/// # checked_multifactorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedMultifactorial;\n///\n/// assert_eq!(u8::checked_multifactorial(0, 1), Some(1));\n/// assert_eq!(u8::checked_multifactorial(1, 1), Some(1));\n/// assert_eq!(u8::checked_multifactorial(2, 1), Some(2));\n/// assert_eq!(u8::checked_multifactorial(3, 1), Some(6));\n/// assert_eq!(u8::checked_multifactorial(4, 1), Some(24));\n/// assert_eq!(u8::checked_multifactorial(5, 1), Some(120));\n/// assert_eq!(u8::checked_multifactorial(6, 1), None);\n///\n/// assert_eq!(u8::checked_multifactorial(0, 2), Some(1));\n/// assert_eq!(u8::checked_multifactorial(1, 2), Some(1));\n/// assert_eq!(u8::checked_multifactorial(2, 2), Some(2));\n/// assert_eq!(u8::checked_multifactorial(3, 2), Some(3));\n/// assert_eq!(u8::checked_multifactorial(4, 2), Some(8));\n/// assert_eq!(u8::checked_multifactorial(5, 2), Some(15));\n/// assert_eq!(u8::checked_multifactorial(6, 2), Some(48));\n/// assert_eq!(u8::checked_multifactorial(7, 2), Some(105));\n/// assert_eq!(u8::checked_multifactorial(8, 2), None);\n///\n/// assert_eq!(u8::checked_multifactorial(0, 3), Some(1));\n/// assert_eq!(u8::checked_multifactorial(1, 3), Some(1));\n/// assert_eq!(u8::checked_multifactorial(2, 3), Some(2));\n/// assert_eq!(u8::checked_multifactorial(3, 3), Some(3));\n/// assert_eq!(u8::checked_multifactorial(4, 3), Some(4));\n/// assert_eq!(u8::checked_multifactorial(5, 3), Some(10));\n/// assert_eq!(u8::checked_multifactorial(6, 3), Some(18));\n/// assert_eq!(u8::checked_multifactorial(7, 3), Some(28));\n/// assert_eq!(u8::checked_multifactorial(8, 3), Some(80));\n/// assert_eq!(u8::checked_multifactorial(9, 3), Some(162));\n/// assert_eq!(u8::checked_multifactorial(10, 3), None);\n///\n/// assert_eq!(u32::checked_multifactorial(10, 1), Some(3628800));\n/// assert_eq!(u32::checked_multifactorial(20, 2), Some(3715891200));\n/// assert_eq!(u32::checked_multifactorial(25, 3), Some(608608000));\n/// assert_eq!(u32::checked_multifactorial(100, 1), None);\n/// assert_eq!(u32::checked_multifactorial(100, 2), None);\n/// assert_eq!(u32::checked_multifactorial(100, 3), None);\n/// ```\n///\n/// # subfactorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::Subfactorial;\n///\n/// assert_eq!(u8::subfactorial(0), 1);\n/// assert_eq!(u8::subfactorial(1), 0);\n/// assert_eq!(u8::subfactorial(2), 1);\n/// assert_eq!(u8::subfactorial(3), 2);\n/// assert_eq!(u8::subfactorial(4), 9);\n/// assert_eq!(u8::subfactorial(5), 44);\n/// assert_eq!(u32::subfactorial(10), 1334961);\n/// ```\n///\n/// # checked_subfactorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedSubfactorial;\n///\n/// assert_eq!(u8::checked_subfactorial(0), Some(1));\n/// assert_eq!(u8::checked_subfactorial(1), Some(0));\n/// assert_eq!(u8::checked_subfactorial(2), Some(1));\n/// assert_eq!(u8::checked_subfactorial(3), Some(2));\n/// assert_eq!(u8::checked_subfactorial(4), Some(9));\n/// assert_eq!(u8::checked_subfactorial(5), Some(44));\n/// assert_eq!(u8::checked_subfactorial(6), None);\n/// assert_eq!(u32::checked_subfactorial(10), Some(1334961));\n/// assert_eq!(u32::checked_subfactorial(100), None);\n/// ```\npub mod factorial;\n/// [`Floor`](traits::Floor) and [`FloorAssign`](traits::FloorAssign), traits for computing the\n/// floor of a number.\n///\n/// # floor_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorAssign;\n///\n/// let mut x = 1.5f32;\n/// x.floor_assign();\n/// assert_eq!(x, 1.0);\n///\n/// let mut x = -1.5f32;\n/// x.floor_assign();\n/// assert_eq!(x, -2.0);\n/// ```\npub mod floor;\n/// [`Gcd`](traits::Gcd) and [`GcdAssign`](traits::GcdAssign), traits for computing the GCD\n/// (greatest common divisor) of two numbers.\n///\n/// # gcd\n/// ```\n/// use malachite_base::num::arithmetic::traits::Gcd;\n///\n/// assert_eq!(3u8.gcd(5), 1);\n/// assert_eq!(12u16.gcd(90), 6);\n/// ```\n///\n/// # gcd_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::GcdAssign;\n///\n/// let mut x = 3u8;\n/// x.gcd_assign(5);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 12u16;\n/// x.gcd_assign(90);\n/// assert_eq!(x, 6);\n/// ```\npub mod gcd;\n/// [`IsPowerOf2`](traits::IsPowerOf2), a trait for determining whether a number is an integer power\n/// of 2.\n///\n/// # is_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::IsPowerOf2;\n///\n/// assert_eq!(4.0.is_power_of_2(), true);\n/// assert_eq!(0.25.is_power_of_2(), true);\n/// assert_eq!(0.2.is_power_of_2(), false);\n/// assert_eq!((-4.0).is_power_of_2(), false);\n/// ```\npub mod is_power_of_2;\n/// [`LegendreSymbol`](traits::LegendreSymbol), [`JacobiSymbol`](traits::JacobiSymbol), and\n/// [`KroneckerSymbol`](traits::KroneckerSymbol), traits for computing the Legendre, Jacobi, and\n/// Kronecker symbols of two numbers.\n///\n/// # legendre_symbol\n/// ```\n/// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n///\n/// assert_eq!(10u8.legendre_symbol(5), 0);\n/// assert_eq!(7u8.legendre_symbol(5), -1);\n/// assert_eq!(11u8.legendre_symbol(5), 1);\n///\n/// assert_eq!((-7i8).legendre_symbol(5), -1);\n/// assert_eq!((-11i8).legendre_symbol(5), 1);\n/// ```\n///\n/// # jacobi_symbol\n/// ```\n/// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n///\n/// assert_eq!(10u8.jacobi_symbol(5), 0);\n/// assert_eq!(7u8.jacobi_symbol(5), -1);\n/// assert_eq!(11u8.jacobi_symbol(5), 1);\n/// assert_eq!(11u8.jacobi_symbol(9), 1);\n///\n/// assert_eq!((-7i8).jacobi_symbol(5), -1);\n/// assert_eq!((-11i8).jacobi_symbol(5), 1);\n/// assert_eq!((-11i8).jacobi_symbol(9), 1);\n/// ```\n///\n/// # kronecker_symbol\n/// ```\n/// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n///\n/// assert_eq!(10u8.kronecker_symbol(5), 0);\n/// assert_eq!(7u8.kronecker_symbol(5), -1);\n/// assert_eq!(11u8.kronecker_symbol(5), 1);\n/// assert_eq!(11u8.kronecker_symbol(9), 1);\n/// assert_eq!(11u8.kronecker_symbol(8), -1);\n///\n/// assert_eq!((-7i8).kronecker_symbol(5), -1);\n/// assert_eq!((-11i8).kronecker_symbol(5), 1);\n/// assert_eq!((-11i8).kronecker_symbol(9), 1);\n/// assert_eq!((-11i8).kronecker_symbol(8), -1);\n/// assert_eq!((-11i8).kronecker_symbol(-8), 1);\n/// ```\npub mod kronecker_symbol;\n/// [`Lcm`](traits::Lcm), [`LcmAssign`](traits::LcmAssign), and [`CheckedLcm`](traits::CheckedLcm),\n/// traits for computing the LCM (least common multiple) of two numbers.\n///\n/// # lcm\n/// ```\n/// use malachite_base::num::arithmetic::traits::Lcm;\n///\n/// assert_eq!(3u8.lcm(5), 15);\n/// assert_eq!(12u16.lcm(90), 180);\n/// ```\n///\n/// # lcm_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::LcmAssign;\n///\n/// let mut x = 3u8;\n/// x.lcm_assign(5);\n/// assert_eq!(x, 15);\n///\n/// let mut x = 12u16;\n/// x.lcm_assign(90);\n/// assert_eq!(x, 180);\n/// ```\n///\n/// # checked_lcm\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedLcm;\n///\n/// assert_eq!(3u8.checked_lcm(5), Some(15));\n/// assert_eq!(12u16.checked_lcm(90), Some(180));\n/// assert_eq!(120u8.checked_lcm(90), None);\n/// ```\npub mod lcm;\n/// Traits for taking the base-$b$ logarithm of a number.\n///\n/// The traits are [`FloorLogBase`](traits::FloorLogBase),\n/// [`CeilingLogBase`](traits::CeilingLogBase), and [`CheckedLogBase`](traits::CheckedLogBase).\n///\n/// # floor_log_base\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorLogBase;\n///\n/// assert_eq!(1u8.floor_log_base(5), 0);\n/// assert_eq!(125u8.floor_log_base(5), 3);\n/// assert_eq!(99u64.floor_log_base(10), 1);\n/// assert_eq!(100u64.floor_log_base(10), 2);\n/// assert_eq!(101u64.floor_log_base(10), 2);\n/// ```\n///\n/// # ceiling_log_base\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingLogBase;\n///\n/// assert_eq!(1u8.ceiling_log_base(5), 0);\n/// assert_eq!(125u8.ceiling_log_base(5), 3);\n/// assert_eq!(99u64.ceiling_log_base(10), 2);\n/// assert_eq!(100u64.ceiling_log_base(10), 2);\n/// assert_eq!(101u64.ceiling_log_base(10), 3);\n/// ```\n///\n/// # checked_log_base\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedLogBase;\n///\n/// assert_eq!(1u8.checked_log_base(5), Some(0));\n/// assert_eq!(125u8.checked_log_base(5), Some(3));\n/// assert_eq!(99u64.checked_log_base(10), None);\n/// assert_eq!(100u64.checked_log_base(10), Some(2));\n/// assert_eq!(101u64.checked_log_base(10), None);\n/// ```\npub mod log_base;\n/// Traits for taking the base-2 logarithm of a number.\n///\n/// The traits are [`FloorLogBase2`](traits::FloorLogBase2),\n/// [`CeilingLogBase2`](traits::CeilingLogBase2), and [`CheckedLogBase2`](traits::CheckedLogBase2).\n///\n/// # floor_log_base_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorLogBase2;\n///\n/// assert_eq!(1u8.floor_log_base_2(), 0);\n/// assert_eq!(100u64.floor_log_base_2(), 6);\n///\n/// assert_eq!(1.0f32.floor_log_base_2(), 0);\n/// assert_eq!(100.0f32.floor_log_base_2(), 6);\n/// assert_eq!(0.1f32.floor_log_base_2(), -4);\n/// ```\n///\n/// # ceiling_log_base_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingLogBase2;\n///\n/// assert_eq!(1u8.ceiling_log_base_2(), 0);\n/// assert_eq!(100u64.ceiling_log_base_2(), 7);\n///\n/// assert_eq!(1.0f32.ceiling_log_base_2(), 0);\n/// assert_eq!(100.0f32.ceiling_log_base_2(), 7);\n/// assert_eq!(0.1f32.ceiling_log_base_2(), -3);\n/// ```\n///\n/// # checked_log_base_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedLogBase2;\n///\n/// assert_eq!(1u8.checked_log_base_2(), Some(0));\n/// assert_eq!(100u64.checked_log_base_2(), None);\n/// assert_eq!(128u64.checked_log_base_2(), Some(7));\n///\n/// assert_eq!(1.0f32.checked_log_base_2(), Some(0));\n/// assert_eq!(100.0f32.checked_log_base_2(), None);\n/// assert_eq!(128.0f32.checked_log_base_2(), Some(7));\n/// assert_eq!(0.1f32.checked_log_base_2(), None);\n/// assert_eq!(0.0625f32.checked_log_base_2(), Some(-4));\n/// ```\npub mod log_base_2;\n/// Traits for taking the base-$2^k$ logarithm of a number.\n///\n/// The traits are [`FloorLogBasePowerOf2`](traits::FloorLogBasePowerOf2),\n/// [`CeilingLogBasePowerOf2`](traits::CeilingLogBasePowerOf2), and\n/// [`CheckedLogBasePowerOf2`](traits::CheckedLogBasePowerOf2).\n///\n/// # floor_log_base_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorLogBasePowerOf2;\n///\n/// assert_eq!(1u8.floor_log_base_power_of_2(4), 0);\n/// assert_eq!(100u64.floor_log_base_power_of_2(2), 3);\n///\n/// assert_eq!(0.1f32.floor_log_base_power_of_2(2), -2);\n/// ```\n///\n/// # ceiling_log_base_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingLogBasePowerOf2;\n///\n/// assert_eq!(1u8.ceiling_log_base_power_of_2(4), 0);\n/// assert_eq!(100u64.ceiling_log_base_power_of_2(2), 4);\n///\n/// assert_eq!(0.1f32.ceiling_log_base_power_of_2(2), -1);\n/// ```\n///\n/// # checked_log_base_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedLogBasePowerOf2;\n///\n/// assert_eq!(1u8.checked_log_base_power_of_2(4), Some(0));\n/// assert_eq!(100u64.checked_log_base_power_of_2(4), None);\n/// assert_eq!(256u64.checked_log_base_power_of_2(4), Some(2));\n///\n/// assert_eq!(0.1f32.checked_log_base_power_of_2(2), None);\n/// assert_eq!(0.0625f32.checked_log_base_power_of_2(2), Some(-2));\n/// ```\npub mod log_base_power_of_2;\n/// [`ModAdd`](traits::ModAdd) and [`ModAddAssign`](traits::ModAddAssign), traits for adding two\n/// numbers modulo another number.\n///\n/// # mod_add\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModAdd;\n///\n/// assert_eq!(0u8.mod_add(3, 5), 3);\n/// assert_eq!(7u32.mod_add(5, 10), 2);\n/// ```\n///\n/// # mod_add_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModAddAssign;\n///\n/// let mut n = 0u8;\n/// n.mod_add_assign(3, 5);\n/// assert_eq!(n, 3);\n///\n/// let mut n = 7u32;\n/// n.mod_add_assign(5, 10);\n/// assert_eq!(n, 2);\n/// ```\npub mod mod_add;\n/// [`ModInverse`](traits::ModInverse), a trait for finding the multiplicative inverse of a number\n/// modulo another number.\n///\n/// # mod_inverse\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModInverse;\n///\n/// assert_eq!(7u8.mod_inverse(10), Some(3));\n/// assert_eq!(8u8.mod_inverse(10), None);\n/// assert_eq!(123u32.mod_inverse(4567), Some(854));\n/// ```\npub mod mod_inverse;\n/// [`ModIsReduced`](traits::ModIsReduced), a trait for checking whether a number is reduced modulo\n/// another number.\n///\n/// # mod_is_reduced\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModIsReduced;\n///\n/// assert_eq!(0u8.mod_is_reduced(&5), true);\n/// assert_eq!(100u64.mod_is_reduced(&100), false);\n/// assert_eq!(100u16.mod_is_reduced(&101), true);\n/// ```\npub mod mod_is_reduced;\n/// Traits for multiplying two numbers modulo another number.\n///\n/// The traits are [`ModMul`](traits::ModMul), [`ModMulAssign`](traits::ModMulAssign),\n/// [`ModMulPrecomputed`](traits::ModMulPrecomputed), and\n/// [`ModMulPrecomputedAssign`](traits::ModMulPrecomputedAssign).\n/// [`ModMulPrecomputed`](traits::ModMulPrecomputed) and\n/// [`ModMulPrecomputedAssign`](traits::ModMulPrecomputedAssign) are useful when having to make\n/// several multiplications modulo the same modulus.\n///\n/// # mod_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModMul;\n///\n/// assert_eq!(2u8.mod_mul(3, 7), 6);\n/// assert_eq!(7u32.mod_mul(3, 10), 1);\n/// ```\n///\n/// # mod_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModMulAssign;\n///\n/// let mut n = 2u8;\n/// n.mod_mul_assign(3, 7);\n/// assert_eq!(n, 6);\n///\n/// let mut n = 7u32;\n/// n.mod_mul_assign(3, 10);\n/// assert_eq!(n, 1);\n/// ```\n///\n/// # mod_mul_precomputed\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n///\n/// let data = u32::precompute_mod_mul_data(&7);\n/// assert_eq!(2u32.mod_mul_precomputed(3, 7, &data), 6);\n/// assert_eq!(5u32.mod_mul_precomputed(3, 7, &data), 1);\n/// assert_eq!(4u32.mod_mul_precomputed(4, 7, &data), 2);\n///\n/// let data = u64::precompute_mod_mul_data(&10);\n/// assert_eq!(7u64.mod_mul_precomputed(3, 10, &data), 1);\n/// assert_eq!(4u64.mod_mul_precomputed(9, 10, &data), 6);\n/// assert_eq!(5u64.mod_mul_precomputed(8, 10, &data), 0);\n///\n/// let data = u8::precompute_mod_mul_data(&7);\n/// assert_eq!(2u8.mod_mul_precomputed(3, 7, &data), 6);\n/// assert_eq!(5u8.mod_mul_precomputed(3, 7, &data), 1);\n/// assert_eq!(4u8.mod_mul_precomputed(4, 7, &data), 2);\n///\n/// let data = u16::precompute_mod_mul_data(&10);\n/// assert_eq!(7u16.mod_mul_precomputed(3, 10, &data), 1);\n/// assert_eq!(4u16.mod_mul_precomputed(9, 10, &data), 6);\n/// assert_eq!(5u16.mod_mul_precomputed(8, 10, &data), 0);\n///\n/// let data = u128::precompute_mod_mul_data(&7);\n/// assert_eq!(2u128.mod_mul_precomputed(3, 7, &data), 6);\n/// assert_eq!(5u128.mod_mul_precomputed(3, 7, &data), 1);\n/// assert_eq!(4u128.mod_mul_precomputed(4, 7, &data), 2);\n///\n/// let data = u128::precompute_mod_mul_data(&10);\n/// assert_eq!(7u128.mod_mul_precomputed(3, 10, &data), 1);\n/// assert_eq!(4u128.mod_mul_precomputed(9, 10, &data), 6);\n/// assert_eq!(5u128.mod_mul_precomputed(8, 10, &data), 0);\n/// ```\n///\n/// # mod_mul_precomputed_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::{ModMulPrecomputed, ModMulPrecomputedAssign};\n///\n/// let data = u8::precompute_mod_mul_data(&7);\n///\n/// let mut x = 2u8;\n/// x.mod_mul_precomputed_assign(3, 7, &data);\n/// assert_eq!(x, 6);\n///\n/// let mut x = 5u8;\n/// x.mod_mul_precomputed_assign(3, 7, &data);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 4u8;\n/// x.mod_mul_precomputed_assign(4, 7, &data);\n/// assert_eq!(x, 2);\n///\n/// let data = u32::precompute_mod_mul_data(&10);\n///\n/// let mut x = 7u32;\n/// x.mod_mul_precomputed_assign(3, 10, &data);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 4u32;\n/// x.mod_mul_precomputed_assign(9, 10, &data);\n/// assert_eq!(x, 6);\n///\n/// let mut x = 5u32;\n/// x.mod_mul_precomputed_assign(8, 10, &data);\n/// assert_eq!(x, 0);\n/// ```\npub mod mod_mul;\n/// [`ModNeg`](traits::ModNeg) and [`ModNegAssign`](traits::ModNegAssign), traits for negating a\n/// number modulo another number.\n///\n/// # mod_neg\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModNeg;\n///\n/// assert_eq!(0u8.mod_neg(5), 0);\n/// assert_eq!(7u32.mod_neg(10), 3);\n/// assert_eq!(100u16.mod_neg(101), 1);\n/// ```\n///\n/// # mod_neg_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModNegAssign;\n///\n/// let mut n = 0u8;\n/// n.mod_neg_assign(5);\n/// assert_eq!(n, 0);\n///\n/// let mut n = 7u32;\n/// n.mod_neg_assign(10);\n/// assert_eq!(n, 3);\n///\n/// let mut n = 100u16;\n/// n.mod_neg_assign(101);\n/// assert_eq!(n, 1);\n/// ```\npub mod mod_neg;\n/// Traits for finding the remainder of two numbers, subject to various rounding rules.\n///\n/// These are the traits:\n///\n/// | rounding          | by value or reference      | by mutable reference (assignment)      |\n/// |-------------------|----------------------------|----------------------------------------|\n/// | towards $-\\infty$ | [`Mod`](traits::Mod)       | [`ModAssign`](traits::ModAssign)       |\n/// | towards $\\infty$  | [`CeilingMod`](traits::CeilingMod) | [`CeilingModAssign`](traits::CeilingModAssign) |\n/// | towards $\\infty$  | [`NegMod`](traits::NegMod) | [`NegModAssign`](traits::NegModAssign) |\n///\n/// [`CeilingMod`](traits::CeilingMod) and [`NegMod`](traits::NegMod) are similar. The difference is\n/// that [`CeilingMod`](traits::CeilingMod) returns a remainder less than or equal to 0, so that the\n/// usual relation $x = qy + r$ is satisfied, while [`NegMod`](traits::NegMod) returns a remainder\n/// greater than or equal to zero. This allows the remainder to have an unsigned type, but modifies\n/// the relation to $x = qy - r$.\n///\n/// The [`Rem`](std::ops::Rem) trait in the standard library rounds towards 0.\n///\n/// # mod_op\n/// ```\n/// use malachite_base::num::arithmetic::traits::Mod;\n///\n/// // 2 * 10 + 3 = 23\n/// assert_eq!(23u8.mod_op(10), 3);\n///\n/// // 9 * 5 + 0 = 45\n/// assert_eq!(45u32.mod_op(5), 0);\n///\n/// // 2 * 10 + 3 = 23\n/// assert_eq!(23i8.mod_op(10), 3);\n///\n/// // -3 * -10 + -7 = 23\n/// assert_eq!(23i16.mod_op(-10), -7);\n///\n/// // -3 * 10 + 7 = -23\n/// assert_eq!((-23i32).mod_op(10), 7);\n///\n/// // 2 * -10 + -3 = -23\n/// assert_eq!((-23i64).mod_op(-10), -3);\n/// ```\n///\n/// # mod_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModAssign;\n///\n/// // 2 * 10 + 3 = 23\n/// let mut x = 23u8;\n/// x.mod_assign(10);\n/// assert_eq!(x, 3);\n///\n/// // 9 * 5 + 0 = 45\n/// let mut x = 45u32;\n/// x.mod_assign(5);\n/// assert_eq!(x, 0);\n///\n/// // 2 * 10 + 3 = 23\n/// let mut x = 23i8;\n/// x.mod_assign(10);\n/// assert_eq!(x, 3);\n///\n/// // -3 * -10 + -7 = 23\n/// let mut x = 23i16;\n/// x.mod_assign(-10);\n/// assert_eq!(x, -7);\n///\n/// // -3 * 10 + 7 = -23\n/// let mut x = -23i32;\n/// x.mod_assign(10);\n/// assert_eq!(x, 7);\n///\n/// // 2 * -10 + -3 = -23\n/// let mut x = -23i64;\n/// x.mod_assign(-10);\n/// assert_eq!(x, -3);\n/// ```\n///\n/// # neg_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::NegMod;\n///\n/// // 3 * 10 - 7 = 23\n/// assert_eq!(23u8.neg_mod(10), 7);\n///\n/// // 9 * 5 + 0 = 45\n/// assert_eq!(45u32.neg_mod(5), 0);\n/// ```\n///\n/// # neg_mod_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::NegModAssign;\n///\n/// // 3 * 10 - 7 = 23\n/// let mut x = 23u8;\n/// x.neg_mod_assign(10);\n/// assert_eq!(x, 7);\n///\n/// // 9 * 5 + 0 = 45\n/// let mut x = 45u32;\n/// x.neg_mod_assign(5);\n/// assert_eq!(x, 0);\n/// ```\n///\n/// # ceiling_mod\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingMod;\n///\n/// // 3 * 10 + -7 = 23\n/// assert_eq!(23i8.ceiling_mod(10), -7);\n///\n/// // -2 * -10 + 3 = 23\n/// assert_eq!(23i16.ceiling_mod(-10), 3);\n///\n/// // -2 * 10 + -3 = -23\n/// assert_eq!((-23i32).ceiling_mod(10), -3);\n///\n/// // 3 * -10 + 7 = -23\n/// assert_eq!((-23i64).ceiling_mod(-10), 7);\n/// ```\n///\n/// # ceiling_mod_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingModAssign;\n///\n/// // 3 * 10 + -7 = 23\n/// let mut x = 23i8;\n/// x.ceiling_mod_assign(10);\n/// assert_eq!(x, -7);\n///\n/// // -2 * -10 + 3 = 23\n/// let mut x = 23i16;\n/// x.ceiling_mod_assign(-10);\n/// assert_eq!(x, 3);\n///\n/// // -2 * 10 + -3 = -23\n/// let mut x = -23i32;\n/// x.ceiling_mod_assign(10);\n/// assert_eq!(x, -3);\n///\n/// // 3 * -10 + 7 = -23\n/// let mut x = -23i64;\n/// x.ceiling_mod_assign(-10);\n/// assert_eq!(x, 7);\n/// ```\npub mod mod_op;\n/// Traits for raising a number to a power modulo another number.\n///\n/// The traits are [`ModPow`](traits::ModPow), [`ModPowAssign`](traits::ModPowAssign), and\n/// [`ModPowPrecomputed`](traits::ModPowPrecomputed).\n/// [`ModPowPrecomputed`](traits::ModPowPrecomputed) is useful when having to make several\n/// exponentiations modulo the same modulus.\n///\n/// # mod_pow\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPow;\n///\n/// assert_eq!(4u16.mod_pow(13, 497), 445);\n/// assert_eq!(10u32.mod_pow(1000, 30), 10);\n/// ```\n///\n/// # mod_pow_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowAssign;\n///\n/// let mut n = 4u16;\n/// n.mod_pow_assign(13, 497);\n/// assert_eq!(n, 445);\n///\n/// let mut n = 10u32;\n/// n.mod_pow_assign(1000, 30);\n/// assert_eq!(n, 10);\n/// ```\n///\n/// # mod_pow_precomputed\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowPrecomputed;\n///\n/// let data = u32::precompute_mod_pow_data(&497);\n/// assert_eq!(4u32.mod_pow_precomputed(13, 497, &data), 445);\n/// assert_eq!(5u32.mod_pow_precomputed(3, 497, &data), 125);\n/// assert_eq!(4u32.mod_pow_precomputed(100, 497, &data), 116);\n///\n/// let data = u64::precompute_mod_pow_data(&30);\n/// assert_eq!(10u64.mod_pow_precomputed(1000, 30, &data), 10);\n/// assert_eq!(4u64.mod_pow_precomputed(9, 30, &data), 4);\n/// assert_eq!(5u64.mod_pow_precomputed(8, 30, &data), 25);\n///\n/// let data = u16::precompute_mod_pow_data(&497);\n/// assert_eq!(4u16.mod_pow_precomputed(13, 497, &data), 445);\n/// assert_eq!(5u16.mod_pow_precomputed(3, 497, &data), 125);\n/// assert_eq!(4u16.mod_pow_precomputed(100, 497, &data), 116);\n///\n/// let data = u8::precompute_mod_pow_data(&30);\n/// assert_eq!(10u8.mod_pow_precomputed(1000, 30, &data), 10);\n/// assert_eq!(4u8.mod_pow_precomputed(9, 30, &data), 4);\n/// assert_eq!(5u8.mod_pow_precomputed(8, 30, &data), 25);\n///\n/// let data = u128::precompute_mod_pow_data(&497);\n/// assert_eq!(4u128.mod_pow_precomputed(13, 497, &data), 445);\n/// assert_eq!(5u128.mod_pow_precomputed(3, 497, &data), 125);\n/// assert_eq!(4u128.mod_pow_precomputed(100, 497, &data), 116);\n///\n/// let data = u128::precompute_mod_pow_data(&30);\n/// assert_eq!(10u128.mod_pow_precomputed(1000, 30, &data), 10);\n/// assert_eq!(4u128.mod_pow_precomputed(9, 30, &data), 4);\n/// assert_eq!(5u128.mod_pow_precomputed(8, 30, &data), 25);\n/// ```\n///\n/// # mod_pow_precomputed_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::{ModPowPrecomputed, ModPowPrecomputedAssign};\n///\n/// let data = u32::precompute_mod_pow_data(&497);\n///\n/// let mut x = 4u32;\n/// x.mod_pow_precomputed_assign(13, 497, &data);\n/// assert_eq!(x, 445);\n///\n/// let mut x = 5u32;\n/// x.mod_pow_precomputed_assign(3, 497, &data);\n/// assert_eq!(x, 125);\n///\n/// let mut x = 4u32;\n/// x.mod_pow_precomputed_assign(100, 497, &data);\n/// assert_eq!(x, 116);\n///\n/// let data = u64::precompute_mod_pow_data(&30);\n///\n/// let mut x = 10u64;\n/// x.mod_pow_precomputed_assign(1000, 30, &data);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 4u64;\n/// x.mod_pow_precomputed_assign(9, 30, &data);\n/// assert_eq!(x, 4);\n///\n/// let mut x = 5u64;\n/// x.mod_pow_precomputed_assign(8, 30, &data);\n/// assert_eq!(x, 25);\n/// ```\npub mod mod_pow;\n/// Traits for finding the remainder of a number divided by $2^k$, subject to various rounding\n/// rules.\n///\n/// These are the traits:\n///\n/// | rounding | by value or reference | by mutable reference (assignment) |\n/// |----------|-----------------------|-----------------------------------|\n/// | towards $-\\infty$ | [`ModPowerOf2`](traits::ModPowerOf2) | [`ModPowerOf2Assign`](traits::ModPowerOf2Assign)       |\n/// | towards 0 | [`RemPowerOf2`](traits::RemPowerOf2) | [`RemPowerOf2Assign`](traits::RemPowerOf2Assign)       |\n/// | towards $\\infty$  | [`CeilingModPowerOf2`](traits::CeilingModPowerOf2) | [`CeilingModPowerOf2Assign`](traits::CeilingModPowerOf2Assign) |\n/// | towards $\\infty$  | [`NegModPowerOf2`](traits::NegModPowerOf2) | [`NegModPowerOf2Assign`](traits::NegModPowerOf2Assign) |\n///\n/// [`CeilingModPowerOf2`](traits::CeilingModPowerOf2) and\n/// [`NegModPowerOf2`](traits::NegModPowerOf2) are similar. The difference is that\n/// [`CeilingModPowerOf2`](traits::CeilingModPowerOf2) returns a remainder less than or equal to 0,\n/// so that the usual relation $x = q2^k + r$ is satisfied, while\n/// [`NegModPowerOf2`](traits::NegModPowerOf2) returns a remainder greater than or equal to zero.\n/// This allows the remainder to have an unsigned type, but modifies the relation to $x = q2^k - r$.\n///\n/// # mod_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2;\n///\n/// // 1 * 2^8 + 4 = 260\n/// assert_eq!(260u16.mod_power_of_2(8), 4);\n///\n/// // 100 * 2^4 + 11 = 1611\n/// assert_eq!(1611u32.mod_power_of_2(4), 11);\n///\n/// // 1 * 2^8 + 4 = 260\n/// assert_eq!(260i16.mod_power_of_2(8), 4);\n///\n/// // -101 * 2^4 + 5 = -1611\n/// assert_eq!((-1611i32).mod_power_of_2(4), 5);\n/// ```\n///\n/// # mod_power_of_2_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Assign;\n///\n/// // 1 * 2^8 + 4 = 260\n/// let mut x = 260u16;\n/// x.mod_power_of_2_assign(8);\n/// assert_eq!(x, 4);\n///\n/// // 100 * 2^4 + 11 = 1611\n/// let mut x = 1611u32;\n/// x.mod_power_of_2_assign(4);\n/// assert_eq!(x, 11);\n///\n/// // 1 * 2^8 + 4 = 260\n/// let mut x = 260i16;\n/// x.mod_power_of_2_assign(8);\n/// assert_eq!(x, 4);\n///\n/// // -101 * 2^4 + 5 = -1611\n/// let mut x = -1611i32;\n/// x.mod_power_of_2_assign(4);\n/// assert_eq!(x, 5);\n/// ```\n///\n/// # rem_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::RemPowerOf2;\n///\n/// // 1 * 2^8 + 4 = 260\n/// assert_eq!(260u16.rem_power_of_2(8), 4);\n///\n/// // 100 * 2^4 + 11 = 1611\n/// assert_eq!(1611u32.rem_power_of_2(4), 11);\n///\n/// // 1 * 2^8 + 4 = 260\n/// assert_eq!(260i16.rem_power_of_2(8), 4);\n///\n/// // -100 * 2^4 + -11 = -1611\n/// assert_eq!((-1611i32).rem_power_of_2(4), -11);\n/// ```\n///\n/// # rem_power_of_2_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::RemPowerOf2Assign;\n///\n/// // 1 * 2^8 + 4 = 260\n/// let mut x = 260u16;\n/// x.rem_power_of_2_assign(8);\n/// assert_eq!(x, 4);\n///\n/// // 100 * 2^4 + 11 = 1611\n/// let mut x = 1611u32;\n/// x.rem_power_of_2_assign(4);\n/// assert_eq!(x, 11);\n///\n/// // 1 * 2^8 + 4 = 260\n/// let mut x = 260i16;\n/// x.rem_power_of_2_assign(8);\n/// assert_eq!(x, 4);\n///\n/// // -100 * 2^4 + -11 = -1611\n/// let mut x = -1611i32;\n/// x.rem_power_of_2_assign(4);\n/// assert_eq!(x, -11);\n/// ```\n///\n/// # neg_mod_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::NegModPowerOf2;\n///\n/// // 2 * 2^8 - 252 = 260\n/// assert_eq!(260u16.neg_mod_power_of_2(8), 252);\n///\n/// // 101 * 2^4 - 5 = 1611\n/// assert_eq!(1611u32.neg_mod_power_of_2(4), 5);\n/// ```\n///\n/// # neg_mod_power_of_2_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::NegModPowerOf2Assign;\n///\n/// // 2 * 2^8 - 252 = 260\n/// let mut x = 260u16;\n/// x.neg_mod_power_of_2_assign(8);\n/// assert_eq!(x, 252);\n///\n/// // 101 * 2^4 - 5 = 1611\n/// let mut x = 1611u32;\n/// x.neg_mod_power_of_2_assign(4);\n/// assert_eq!(x, 5);\n/// ```\n///\n/// # ceiling_mod_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingModPowerOf2;\n///\n/// // 2 * 2^8 + -252 = 260\n/// assert_eq!(260i16.ceiling_mod_power_of_2(8), -252);\n///\n/// // -100 * 2^4 + -11 = -1611\n/// assert_eq!((-1611i32).ceiling_mod_power_of_2(4), -11);\n/// ```\n///\n/// # ceiling_mod_power_of_2_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingModPowerOf2Assign;\n///\n/// // 2 * 2^8 + -252 = 260\n/// let mut x = 260i16;\n/// x.ceiling_mod_power_of_2_assign(8);\n/// assert_eq!(x, -252);\n///\n/// // -100 * 2^4 + -11 = -1611\n/// let mut x = -1611i32;\n/// x.ceiling_mod_power_of_2_assign(4);\n/// assert_eq!(x, -11);\n/// ```\npub mod mod_power_of_2;\n/// [`ModPowerOf2Add`](traits::ModPowerOf2Add) and\n/// [`ModPowerOf2AddAssign`](traits::ModPowerOf2AddAssign), traits for adding two numbers modulo\n/// $2^k$.\n///\n/// # mod_power_of_2_add\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Add;\n///\n/// assert_eq!(0u8.mod_power_of_2_add(2, 5), 2);\n/// assert_eq!(10u32.mod_power_of_2_add(14, 4), 8);\n/// ```\n///\n/// # mod_power_of_2_add_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2AddAssign;\n///\n/// let mut n = 0u8;\n/// n.mod_power_of_2_add_assign(2, 5);\n/// assert_eq!(n, 2);\n///\n/// let mut n = 10u32;\n/// n.mod_power_of_2_add_assign(14, 4);\n/// assert_eq!(n, 8);\n/// ```\npub mod mod_power_of_2_add;\n/// [`ModPowerOf2Inverse`](traits::ModPowerOf2Inverse), a trait for finding the multiplicative\n/// inverse of a number modulo $2^k$.\n///\n/// # mod_inverse\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Inverse;\n///\n/// assert_eq!(7u8.mod_power_of_2_inverse(4), Some(7));\n/// assert_eq!(8u8.mod_power_of_2_inverse(4), None);\n/// assert_eq!(123u32.mod_power_of_2_inverse(7), Some(51));\n/// ```\npub mod mod_power_of_2_inverse;\n/// [`ModPowerOf2IsReduced`](traits::ModPowerOf2IsReduced), a trait for checking whether a number is\n/// reduced modulo $2^k$.\n///\n/// # mod_power_of_2_is_reduced\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2IsReduced;\n///\n/// assert_eq!(0u8.mod_power_of_2_is_reduced(5), true);\n/// assert_eq!(100u64.mod_power_of_2_is_reduced(5), false);\n/// assert_eq!(100u16.mod_power_of_2_is_reduced(8), true);\n/// ```\npub mod mod_power_of_2_is_reduced;\n/// [`ModPowerOf2Mul`](traits::ModPowerOf2Mul) and\n/// [`ModPowerOf2MulAssign`](traits::ModPowerOf2MulAssign), traits for multiplying two numbers\n/// modulo $2^k$.\n///\n/// # mod_power_of_2_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Mul;\n///\n/// assert_eq!(3u8.mod_power_of_2_mul(2, 5), 6);\n/// assert_eq!(10u32.mod_power_of_2_mul(14, 4), 12);\n/// ```\n///\n/// # mod_power_of_2_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2MulAssign;\n///\n/// let mut n = 3u8;\n/// n.mod_power_of_2_mul_assign(2, 5);\n/// assert_eq!(n, 6);\n///\n/// let mut n = 10u32;\n/// n.mod_power_of_2_mul_assign(14, 4);\n/// assert_eq!(n, 12);\n/// ```\npub mod mod_power_of_2_mul;\n/// [`ModPowerOf2Neg`](traits::ModPowerOf2Neg) and\n/// [`ModPowerOf2NegAssign`](traits::ModPowerOf2NegAssign), traits for negating a number modulo\n/// $2^k$.\n///\n/// # mod_power_of_2_neg\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Neg;\n///\n/// assert_eq!(0u8.mod_power_of_2_neg(5), 0);\n/// assert_eq!(10u32.mod_power_of_2_neg(4), 6);\n/// assert_eq!(100u16.mod_power_of_2_neg(8), 156);\n/// ```\n///\n/// # mod_power_of_2_neg_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2NegAssign;\n///\n/// let mut n = 0u8;\n/// n.mod_power_of_2_neg_assign(5);\n/// assert_eq!(n, 0);\n///\n/// let mut n = 10u32;\n/// n.mod_power_of_2_neg_assign(4);\n/// assert_eq!(n, 6);\n///\n/// let mut n = 100u16;\n/// n.mod_power_of_2_neg_assign(8);\n/// assert_eq!(n, 156);\n/// ```\npub mod mod_power_of_2_neg;\n/// [`ModPowerOf2Pow`](traits::ModPowerOf2Pow) and\n/// [`ModPowerOf2PowAssign`](traits::ModPowerOf2PowAssign), traits for raising a number to a power\n/// modulo $2^k$.\n///\n/// # mod_power_of_2_pow\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Pow;\n///\n/// assert_eq!(5u8.mod_power_of_2_pow(13, 3), 5);\n/// assert_eq!(7u32.mod_power_of_2_pow(1000, 6), 1);\n/// ```\n///\n/// # mod_power_of_2_pow_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2PowAssign;\n///\n/// let mut n = 5u8;\n/// n.mod_power_of_2_pow_assign(13, 3);\n/// assert_eq!(n, 5);\n///\n/// let mut n = 7u32;\n/// n.mod_power_of_2_pow_assign(1000, 6);\n/// assert_eq!(n, 1);\n/// ```\npub mod mod_power_of_2_pow;\n/// [`ModPowerOf2Shl`](traits::ModPowerOf2Shl) and\n/// [`ModPowerOf2ShlAssign`](traits::ModPowerOf2ShlAssign), traits for left-shifting a number modulo\n/// $2^k$.\n///\n/// # mod_power_of_2_shl\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Shl;\n///\n/// assert_eq!(12u32.mod_power_of_2_shl(2u8, 5), 16);\n/// assert_eq!(10u8.mod_power_of_2_shl(100u64, 4), 0);\n///\n/// assert_eq!(12u32.mod_power_of_2_shl(2i8, 5), 16);\n/// assert_eq!(10u8.mod_power_of_2_shl(-2i64, 4), 2);\n/// ```\n///\n/// # mod_power_of_2_shl_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShlAssign;\n///\n/// let mut n = 12u32;\n/// n.mod_power_of_2_shl_assign(2u8, 5);\n/// assert_eq!(n, 16);\n///\n/// let mut n = 10u8;\n/// n.mod_power_of_2_shl_assign(100u64, 4);\n/// assert_eq!(n, 0);\n///\n/// let mut n = 12u32;\n/// n.mod_power_of_2_shl_assign(2i8, 5);\n/// assert_eq!(n, 16);\n///\n/// let mut n = 10u8;\n/// n.mod_power_of_2_shl_assign(-2i64, 4);\n/// assert_eq!(n, 2);\n/// ```\npub mod mod_power_of_2_shl;\n/// [`ModPowerOf2Shr`](traits::ModPowerOf2Shr) and\n/// [`ModPowerOf2ShrAssign`](traits::ModPowerOf2ShrAssign), traits for right-shifting a number\n/// modulo $2^k$.\n///\n/// # mod_power_of_2_shr\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Shr;\n///\n/// assert_eq!(10u8.mod_power_of_2_shr(2i64, 4), 2);\n/// assert_eq!(12u32.mod_power_of_2_shr(-2i8, 5), 16);\n/// ```\n///\n/// # mod_power_of_2_shr_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShrAssign;\n///\n/// let mut n = 10u8;\n/// n.mod_power_of_2_shr_assign(2i64, 4);\n/// assert_eq!(n, 2);\n///\n/// let mut n = 12u32;\n/// n.mod_power_of_2_shr_assign(-2i8, 5);\n/// assert_eq!(n, 16);\n/// ```\npub mod mod_power_of_2_shr;\n/// [`ModPowerOf2Square`](traits::ModPowerOf2Square) and\n/// [`ModPowerOf2SquareAssign`](traits::ModPowerOf2SquareAssign), traits for squaring a number\n/// modulo $2^k$.\n///\n/// # mod_power_of_2_square\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Square;\n///\n/// assert_eq!(5u8.mod_power_of_2_square(3), 1);\n/// assert_eq!(100u32.mod_power_of_2_square(8), 16);\n/// ```\n///\n/// # mod_power_of_2_square_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2SquareAssign;\n///\n/// let mut n = 5u8;\n/// n.mod_power_of_2_square_assign(3);\n/// assert_eq!(n, 1);\n///\n/// let mut n = 100u32;\n/// n.mod_power_of_2_square_assign(8);\n/// assert_eq!(n, 16);\n/// ```\npub mod mod_power_of_2_square;\n/// [`ModPowerOf2Sub`](traits::ModPowerOf2Sub) and\n/// [`ModPowerOf2SubAssign`](traits::ModPowerOf2SubAssign), traits for subtracting one number by\n/// another modulo $2^k$.\n///\n/// # mod_power_of_2_sub\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Sub;\n///\n/// assert_eq!(5u8.mod_power_of_2_sub(2, 5), 3);\n/// assert_eq!(10u32.mod_power_of_2_sub(14, 4), 12);\n/// ```\n///\n/// # mod_power_of_2_sub_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2SubAssign;\n///\n/// let mut n = 5u8;\n/// n.mod_power_of_2_sub_assign(2, 5);\n/// assert_eq!(n, 3);\n///\n/// let mut n = 10u32;\n/// n.mod_power_of_2_sub_assign(14, 4);\n/// assert_eq!(n, 12);\n/// ```\npub mod mod_power_of_2_sub;\n/// [`ModShl`](traits::ModShl) and [`ModShlAssign`](traits::ModShlAssign), traits for left-shifting\n/// a number modulo another number.\n///\n/// # mod_shl\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModShl;\n///\n/// assert_eq!(8u32.mod_shl(2u8, 10), 2);\n/// assert_eq!(10u8.mod_shl(100u64, 17), 7);\n///\n/// assert_eq!(8u32.mod_shl(2i8, 10), 2);\n/// assert_eq!(10u8.mod_shl(-2i64, 15), 2);\n/// ```\n///\n/// # mod_shl_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModShlAssign;\n///\n/// let mut n = 8u32;\n/// n.mod_shl_assign(2u8, 10);\n/// assert_eq!(n, 2);\n///\n/// let mut n = 10u8;\n/// n.mod_shl_assign(100u64, 17);\n/// assert_eq!(n, 7);\n///\n/// let mut n = 8u32;\n/// n.mod_shl_assign(2i8, 10);\n/// assert_eq!(n, 2);\n///\n/// let mut n = 10u8;\n/// n.mod_shl_assign(-2i64, 15);\n/// assert_eq!(n, 2);\n/// ```\npub mod mod_shl;\n/// [`ModShr`](traits::ModShr) and [`ModShrAssign`](traits::ModShrAssign), traits for right-shifting\n/// a number modulo another number.\n///\n/// # mod_shr\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModShr;\n///\n/// assert_eq!(10u8.mod_shr(2i64, 15), 2);\n/// assert_eq!(8u32.mod_shr(-2i8, 10), 2);\n/// ```\n///\n/// # mod_shr_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModShrAssign;\n///\n/// let mut n = 10u8;\n/// n.mod_shr_assign(2i64, 15);\n/// assert_eq!(n, 2);\n///\n/// let mut n = 8u32;\n/// n.mod_shr_assign(-2i8, 10);\n/// assert_eq!(n, 2);\n/// ```\npub mod mod_shr;\n/// Traits for squaring a number modulo another number.\n///\n/// The traits are [`ModSquare`](traits::ModSquare), [`ModSquareAssign`](traits::ModSquareAssign),\n/// and [`ModSquarePrecomputed`](traits::ModSquarePrecomputed).\n/// [`ModSquarePrecomputed`](traits::ModSquarePrecomputed) is useful when having to make several\n/// squarings modulo the same modulus.\n///\n/// # mod_square\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModSquare;\n///\n/// assert_eq!(2u8.mod_square(10), 4);\n/// assert_eq!(100u32.mod_square(497), 60);\n/// ```\n///\n/// # mod_square_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModSquareAssign;\n///\n/// let mut n = 2u8;\n/// n.mod_square_assign(10);\n/// assert_eq!(n, 4);\n///\n/// let mut n = 100u32;\n/// n.mod_square_assign(497);\n/// assert_eq!(n, 60);\n/// ```\n///\n/// # mod_square_precomputed\n/// ```\n/// use malachite_base::num::arithmetic::traits::{ModPowPrecomputed, ModSquarePrecomputed};\n///\n/// let data = u16::precompute_mod_pow_data(&497);\n/// assert_eq!(100u16.mod_square_precomputed(497, &data), 60);\n/// assert_eq!(200u16.mod_square_precomputed(497, &data), 240);\n/// assert_eq!(300u16.mod_square_precomputed(497, &data), 43);\n/// ```\n///\n/// # mod_square_precomputed_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::{ModPowPrecomputed, ModSquarePrecomputedAssign};\n///\n/// let data = u32::precompute_mod_pow_data(&497);\n///\n/// let mut x = 100u32;\n/// x.mod_square_precomputed_assign(497, &data);\n/// assert_eq!(x, 60);\n///\n/// let mut x = 200u32;\n/// x.mod_square_precomputed_assign(497, &data);\n/// assert_eq!(x, 240);\n///\n/// let mut x = 300u32;\n/// x.mod_square_precomputed_assign(497, &data);\n/// assert_eq!(x, 43);\n/// ```\npub mod mod_square;\n/// [`ModSub`](traits::ModSub) and [`ModSubAssign`](traits::ModSubAssign), traits for subtracting\n/// two numbers modulo another number.\n///\n/// # mod_sub\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModSub;\n///\n/// assert_eq!(4u8.mod_sub(3, 5), 1);\n/// assert_eq!(7u32.mod_sub(9, 10), 8);\n/// ```\n///\n/// # mod_sub_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModSubAssign;\n///\n/// let mut n = 4u8;\n/// n.mod_sub_assign(3, 5);\n/// assert_eq!(n, 1);\n///\n/// let mut n = 7u32;\n/// n.mod_sub_assign(9, 10);\n/// assert_eq!(n, 8);\n/// ```\npub mod mod_sub;\n/// [`NegAssign`](traits::NegAssign), a trait for negating a number in place.\n///\n/// # neg_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::NegAssign;\n///\n/// let mut x = 0i8;\n/// x.neg_assign();\n/// assert_eq!(x, 0i8);\n///\n/// let mut x = 100i64;\n/// x.neg_assign();\n/// assert_eq!(x, -100i64);\n///\n/// let mut x = -100i64;\n/// x.neg_assign();\n/// assert_eq!(x, 100i64);\n///\n/// let mut x = 1.2f32;\n/// x.neg_assign();\n/// assert_eq!(x, -1.2f32);\n/// ```\npub mod neg;\n/// [`NextPowerOf2`](traits::NextPowerOf2) and [`NextPowerOf2Assign`](traits::NextPowerOf2Assign),\n/// traits for getting the next-highest power of 2.\n///\n/// # next_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::NextPowerOf2;\n///\n/// assert_eq!(100.0f32.next_power_of_2(), 128.0);\n/// assert_eq!(0.01f32.next_power_of_2(), 0.015625);\n/// ```\n///\n/// # next_power_of_2_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::NextPowerOf2Assign;\n///\n/// let mut x = 0u8;\n/// x.next_power_of_2_assign();\n/// assert_eq!(x, 1);\n///\n/// let mut x = 4u16;\n/// x.next_power_of_2_assign();\n/// assert_eq!(x, 4);\n///\n/// let mut x = 10u32;\n/// x.next_power_of_2_assign();\n/// assert_eq!(x, 16);\n///\n/// let mut x = (1u64 << 40) - 5;\n/// x.next_power_of_2_assign();\n/// assert_eq!(x, 1 << 40);\n///\n/// let mut x = 100.0f32;\n/// x.next_power_of_2_assign();\n/// assert_eq!(x, 128.0);\n///\n/// let mut x = 0.01f32;\n/// x.next_power_of_2_assign();\n/// assert_eq!(x, 0.015625);\n/// ```\npub mod next_power_of_2;\n/// [`OverflowingAbs`](traits::OverflowingAbs) and\n/// [`OverflowingAbsAssign`](traits::OverflowingAbsAssign), traits for taking the absolute value of\n/// a number and returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_abs_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingAbsAssign;\n///\n/// let mut x = 0i8;\n/// assert_eq!(x.overflowing_abs_assign(), false);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 100i64;\n/// assert_eq!(x.overflowing_abs_assign(), false);\n/// assert_eq!(x, 100);\n///\n/// let mut x = -100i64;\n/// assert_eq!(x.overflowing_abs_assign(), false);\n/// assert_eq!(x, 100);\n///\n/// let mut x = -128i8;\n/// assert_eq!(x.overflowing_abs_assign(), true);\n/// assert_eq!(x, -128);\n/// ```\npub mod overflowing_abs;\n/// [`OverflowingAdd`](traits::OverflowingAdd) and\n/// [`OverflowingAddAssign`](traits::OverflowingAddAssign), traits for adding two numbers and\n/// returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_add_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingAddAssign;\n///\n/// let mut x = 123u16;\n/// assert_eq!(x.overflowing_add_assign(456), false);\n/// assert_eq!(x, 579);\n///\n/// let mut x = 123u8;\n/// assert_eq!(x.overflowing_add_assign(200), true);\n/// assert_eq!(x, 67);\n/// ```\npub mod overflowing_add;\n/// [`OverflowingAddMul`](traits::OverflowingAddMul) and\n/// [`OverflowingAddMulAssign`](traits::OverflowingAddMulAssign), traits for adding the product of\n/// two other numbers to a number and returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_add_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingAddMul;\n///\n/// assert_eq!(2u8.overflowing_add_mul(3, 7), (23, false));\n/// assert_eq!(2u8.overflowing_add_mul(20, 20), (146, true));\n///\n/// assert_eq!(127i8.overflowing_add_mul(-2, 100), (-73, false));\n/// assert_eq!((-127i8).overflowing_add_mul(-2, 100), (-71, true));\n/// ```\n///\n/// # overflowing_add_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingAddMulAssign;\n///\n/// let mut x = 2u8;\n/// assert_eq!(x.overflowing_add_mul_assign(3, 7), false);\n/// assert_eq!(x, 23);\n///\n/// let mut x = 2u8;\n/// assert_eq!(x.overflowing_add_mul_assign(20, 20), true);\n/// assert_eq!(x, 146);\n///\n/// let mut x = 127i8;\n/// assert_eq!(x.overflowing_add_mul_assign(-2, 100), false);\n/// assert_eq!(x, -73);\n///\n/// let mut x = -127i8;\n/// assert_eq!(x.overflowing_add_mul_assign(-2, 100), true);\n/// assert_eq!(x, -71);\n/// ```\npub mod overflowing_add_mul;\n/// [`OverflowingDiv`](traits::OverflowingDiv) and\n/// [`OverflowingDivAssign`](traits::OverflowingDivAssign), traits for dividing two numbers and\n/// returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_div_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingDivAssign;\n///\n/// let mut x = 100u16;\n/// assert_eq!(x.overflowing_div_assign(3), false);\n/// assert_eq!(x, 33);\n///\n/// let mut x = -128i8;\n/// assert_eq!(x.overflowing_div_assign(-1), true);\n/// assert_eq!(x, -128);\n/// ```\npub mod overflowing_div;\n/// [`OverflowingMul`](traits::OverflowingMul) and\n/// [`OverflowingMulAssign`](traits::OverflowingMulAssign), traits for multiplying two numbers and\n/// returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingMulAssign;\n///\n/// let mut x = 123u16;\n/// assert_eq!(x.overflowing_mul_assign(456), false);\n/// assert_eq!(x, 56088);\n///\n/// let mut x = 123u8;\n/// assert_eq!(x.overflowing_mul_assign(200), true);\n/// assert_eq!(x, 24);\n/// ```\npub mod overflowing_mul;\n/// [`OverflowingNeg`](traits::OverflowingNeg) and\n/// [`OverflowingNegAssign`](traits::OverflowingNegAssign), traits for negating a number and\n/// returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_neg_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingNegAssign;\n///\n/// let mut x = 0i8;\n/// assert_eq!(x.overflowing_neg_assign(), false);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 100u64;\n/// assert_eq!(x.overflowing_neg_assign(), true);\n/// assert_eq!(x, 18446744073709551516);\n///\n/// let mut x = -100i64;\n/// assert_eq!(x.overflowing_neg_assign(), false);\n/// assert_eq!(x, 100);\n///\n/// let mut x = -128i8;\n/// assert_eq!(x.overflowing_neg_assign(), true);\n/// assert_eq!(x, -128);\n/// ```\npub mod overflowing_neg;\n/// [`OverflowingPow`](traits::OverflowingPow) and\n/// [`OverflowingPowAssign`](traits::OverflowingPowAssign), traits for raising a number to a power\n/// and returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_pow_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingPowAssign;\n///\n/// let mut x = 3u8;\n/// assert_eq!(x.overflowing_pow_assign(3), false);\n/// assert_eq!(x, 27);\n///\n/// let mut x = -10i32;\n/// assert_eq!(x.overflowing_pow_assign(9), false);\n/// assert_eq!(x, -1000000000);\n///\n/// let mut x = -10i16;\n/// assert_eq!(x.overflowing_pow_assign(9), true);\n/// assert_eq!(x, 13824);\n/// ```\npub mod overflowing_pow;\n/// [`OverflowingSquare`](traits::OverflowingSquare) and\n/// [`OverflowingSquareAssign`](traits::OverflowingSquareAssign), traits for squaring a number and\n/// returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_square_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingSquareAssign;\n///\n/// let mut x = 3u8;\n/// assert_eq!(x.overflowing_square_assign(), false);\n/// assert_eq!(x, 9);\n///\n/// let mut x = -1000i32;\n/// assert_eq!(x.overflowing_square_assign(), false);\n/// assert_eq!(x, 1000000);\n///\n/// let mut x = 1000u16;\n/// assert_eq!(x.overflowing_square_assign(), true);\n/// assert_eq!(x, 16960);\n/// ```\npub mod overflowing_square;\n/// [`OverflowingSub`](traits::OverflowingSub) and\n/// [`OverflowingSubAssign`](traits::OverflowingSubAssign), traits for subtracting two numbers and\n/// returning a boolean indicating whether an overflow occurred.\n///\n/// # overflowing_sub\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingSquare;\n///\n/// assert_eq!(3u8.overflowing_square(), (9, false));\n/// assert_eq!((-1000i32).overflowing_square(), (1000000, false));\n/// assert_eq!(1000u16.overflowing_square(), (16960, true));\n/// ```\n///\n/// # overflowing_sub_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingSubAssign;\n///\n/// let mut x = 456u16;\n/// assert_eq!(x.overflowing_sub_assign(123), false);\n/// assert_eq!(x, 333);\n///\n/// let mut x = 123u16;\n/// assert_eq!(x.overflowing_sub_assign(456), true);\n/// assert_eq!(x, 65203);\n/// ```\npub mod overflowing_sub;\n/// [`OverflowingSubMul`](traits::OverflowingSubMul) and\n/// [`OverflowingSubMulAssign`](traits::OverflowingSubMulAssign), traits for subtracting the product\n/// of two other numbers from a number and returning a boolean indicating whether an overflow\n/// occurred.\n///\n/// # overflowing_sub_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingSubMul;\n///\n/// assert_eq!(60u8.overflowing_sub_mul(5, 10), (10, false));\n/// assert_eq!(2u8.overflowing_sub_mul(10, 5), (208, true));\n///\n/// assert_eq!(127i8.overflowing_sub_mul(2, 100), (-73, false));\n/// assert_eq!((-127i8).overflowing_sub_mul(2, 100), (-71, true));\n/// ```\n///\n/// # overflowing_sub_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::OverflowingSubMulAssign;\n///\n/// let mut x = 60u8;\n/// assert_eq!(x.overflowing_sub_mul_assign(5, 10), false);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 2u8;\n/// assert_eq!(x.overflowing_sub_mul_assign(10, 5), true);\n/// assert_eq!(x, 208);\n///\n/// let mut x = 127i8;\n/// assert_eq!(x.overflowing_sub_mul_assign(2, 100), false);\n/// assert_eq!(x, -73);\n///\n/// let mut x = -127i8;\n/// assert_eq!(x.overflowing_sub_mul_assign(2, 100), true);\n/// assert_eq!(x, -71);\n/// ```\npub mod overflowing_sub_mul;\n/// [`Parity`](traits::Parity), a trait for determining whether a number is even or odd.\n///\n/// # even\n/// ```\n/// use malachite_base::num::arithmetic::traits::Parity;\n///\n/// assert_eq!(0u8.even(), true);\n/// assert_eq!((-5i16).even(), false);\n/// assert_eq!(4u32.even(), true);\n/// ```\n///\n/// # odd\n/// ```\n/// use malachite_base::num::arithmetic::traits::Parity;\n///\n/// assert_eq!(0u8.odd(), false);\n/// assert_eq!((-5i16).odd(), true);\n/// assert_eq!(4u32.odd(), false);\n/// ```\npub mod parity;\n/// [`Pow`](traits::Pow) and [`PowAssign`](traits::PowAssign), traits for raising a number to a\n/// power.\n///\n/// # pow_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::PowAssign;\n///\n/// let mut x = 3u8;\n/// x.pow_assign(3);\n/// assert_eq!(x, 27);\n///\n/// let mut x = -10i32;\n/// x.pow_assign(9);\n/// assert_eq!(x, -1000000000);\n///\n/// let mut x = 2.0f32;\n/// x.pow_assign(5);\n/// assert_eq!(x, 32.0);\n///\n/// let mut x = 2.0f32;\n/// x.pow_assign(5.0);\n/// assert_eq!(x, 32.0);\n/// ```\npub mod pow;\n/// [`PowerOf2`](traits::PowerOf2), a trait for computing a power of 2.\n///\n/// # power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::PowerOf2;\n///\n/// assert_eq!(u16::power_of_2(0), 1);\n/// assert_eq!(u8::power_of_2(3), 8);\n/// assert_eq!(u64::power_of_2(40), 1 << 40);\n///\n/// assert_eq!(i16::power_of_2(0), 1);\n/// assert_eq!(i8::power_of_2(3), 8);\n/// assert_eq!(i64::power_of_2(40), 1 << 40);\n///\n/// assert_eq!(f32::power_of_2(0u64), 1.0);\n/// assert_eq!(f32::power_of_2(3u64), 8.0);\n/// assert_eq!(f32::power_of_2(-3i64), 0.125);\n/// ```\npub mod power_of_2;\n/// Traits for computing the primorial and the product of the first $n$ primes. There is a trait\n/// whose implementations panic if the result cannot be represented, and a checked trait whose\n/// implementations return `None` in that case: [`Primorial`](traits::Primorial) and\n/// [`CheckedPrimorial`](traits::CheckedPrimorial).\n///\n/// # primorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::Primorial;\n///\n/// assert_eq!(u8::primorial(0), 1);\n/// assert_eq!(u8::primorial(1), 1);\n/// assert_eq!(u8::primorial(2), 2);\n/// assert_eq!(u8::primorial(3), 6);\n/// assert_eq!(u8::primorial(4), 6);\n/// assert_eq!(u8::primorial(5), 30);\n/// assert_eq!(u32::primorial(20), 9699690);\n/// ```\n///\n/// # product_of_first_n_primes\n/// ```\n/// use malachite_base::num::arithmetic::traits::Primorial;\n///\n/// assert_eq!(u8::product_of_first_n_primes(0), 1);\n/// assert_eq!(u8::product_of_first_n_primes(1), 2);\n/// assert_eq!(u8::product_of_first_n_primes(2), 6);\n/// assert_eq!(u8::product_of_first_n_primes(3), 30);\n/// assert_eq!(u8::product_of_first_n_primes(4), 210);\n/// assert_eq!(u32::product_of_first_n_primes(9), 223092870);\n/// ```\n///\n/// # checked_primorial\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedPrimorial;\n///\n/// assert_eq!(u8::checked_primorial(0), Some(1));\n/// assert_eq!(u8::checked_primorial(1), Some(1));\n/// assert_eq!(u8::checked_primorial(2), Some(2));\n/// assert_eq!(u8::checked_primorial(3), Some(6));\n/// assert_eq!(u8::checked_primorial(4), Some(6));\n/// assert_eq!(u8::checked_primorial(5), Some(30));\n///\n/// assert_eq!(u8::checked_primorial(11), None);\n/// assert_eq!(u32::checked_primorial(20), Some(9699690));\n/// assert_eq!(u32::checked_primorial(100), None);\n/// ```\n///\n/// # checked_product_of_first_n_primes\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedPrimorial;\n///\n/// assert_eq!(u8::checked_product_of_first_n_primes(0), Some(1));\n/// assert_eq!(u8::checked_product_of_first_n_primes(1), Some(2));\n/// assert_eq!(u8::checked_product_of_first_n_primes(2), Some(6));\n/// assert_eq!(u8::checked_product_of_first_n_primes(3), Some(30));\n/// assert_eq!(u8::checked_product_of_first_n_primes(4), Some(210));\n/// assert_eq!(u32::checked_product_of_first_n_primes(9), Some(223092870));\n///\n/// assert_eq!(u8::checked_product_of_first_n_primes(5), None);\n/// assert_eq!(u32::checked_product_of_first_n_primes(100), None);\n/// ```\npub mod primorial;\n/// [`Reciprocal`](traits::Reciprocal) and [`ReciprocalAssign`](traits::ReciprocalAssign), traits\n/// for computing the reciprocal (multiplicative inverse) of a number.\n///\n/// # reciprocal\n/// ```\n/// use malachite_base::num::arithmetic::traits::Reciprocal;\n///\n/// assert_eq!(0.0f32.reciprocal(), f32::INFINITY);\n/// assert_eq!(1.5f32.reciprocal(), 0.6666667);\n/// ```\n///\n/// # reciprocal_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ReciprocalAssign;\n///\n/// let mut x = 0.0f32;\n/// x.reciprocal_assign();\n/// assert_eq!(x, f32::INFINITY);\n///\n/// let mut x = 1.5f32;\n/// x.reciprocal_assign();\n/// assert_eq!(x, 0.6666667);\n/// ```\npub mod reciprocal;\n/// Traits for taking the $n$th root of a number.\n///\n/// The traits are [`FloorRoot`](traits::FloorRoot), [`FloorRootAssign`](traits::FloorRootAssign),\n/// [`CeilingRoot`](traits::CeilingRoot), [`CeilingRootAssign`](traits::CeilingRootAssign),\n/// [`CheckedRoot`](traits::CheckedRoot), [`RootRem`](traits::RootRem), and\n/// [`RootAssignRem`](traits::RootAssignRem).\n///\n/// # floor_root\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorRoot;\n///\n/// assert_eq!(999u16.floor_root(3), 9);\n/// assert_eq!(1000u16.floor_root(3), 10);\n/// assert_eq!(1001u16.floor_root(3), 10);\n/// assert_eq!(100000000000i64.floor_root(5), 158);\n/// assert_eq!((-100000000000i64).floor_root(5), -159);\n/// ```\n///\n/// # floor_root_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorRootAssign;\n///\n/// let mut x = 999u16;\n/// x.floor_root_assign(3);\n/// assert_eq!(x, 9);\n///\n/// let mut x = 1000u16;\n/// x.floor_root_assign(3);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 1001u16;\n/// x.floor_root_assign(3);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 100000000000i64;\n/// x.floor_root_assign(5);\n/// assert_eq!(x, 158);\n///\n/// let mut x = -100000000000i64;\n/// x.floor_root_assign(5);\n/// assert_eq!(x, -159);\n/// ```\n///\n/// # ceiling_root\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingRoot;\n///\n/// assert_eq!(999u16.ceiling_root(3), 10);\n/// assert_eq!(1000u16.ceiling_root(3), 10);\n/// assert_eq!(1001u16.ceiling_root(3), 11);\n/// assert_eq!(100000000000i64.ceiling_root(5), 159);\n/// assert_eq!((-100000000000i64).ceiling_root(5), -158);\n/// ```\n///\n/// # ceiling_root_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingRootAssign;\n///\n/// let mut x = 999u16;\n/// x.ceiling_root_assign(3);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 1000u16;\n/// x.ceiling_root_assign(3);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 1001u16;\n/// x.ceiling_root_assign(3);\n/// assert_eq!(x, 11);\n///\n/// let mut x = 100000000000i64;\n/// x.ceiling_root_assign(5);\n/// assert_eq!(x, 159);\n///\n/// let mut x = -100000000000i64;\n/// x.ceiling_root_assign(5);\n/// assert_eq!(x, -158);\n/// ```\n///\n/// # checked_root\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedRoot;\n///\n/// assert_eq!(999u16.checked_root(3), None);\n/// assert_eq!(1000u16.checked_root(3), Some(10));\n/// assert_eq!(1001u16.checked_root(3), None);\n/// assert_eq!(100000000000i64.checked_root(5), None);\n/// assert_eq!((-100000000000i64).checked_root(5), None);\n/// assert_eq!(10000000000i64.checked_root(5), Some(100));\n/// assert_eq!((-10000000000i64).checked_root(5), Some(-100));\n/// ```\n///\n/// # root_rem\n/// ```\n/// use malachite_base::num::arithmetic::traits::RootRem;\n///\n/// assert_eq!(999u16.root_rem(3), (9, 270));\n/// assert_eq!(1000u16.root_rem(3), (10, 0));\n/// assert_eq!(1001u16.root_rem(3), (10, 1));\n/// assert_eq!(100000000000u64.root_rem(5), (158, 1534195232));\n/// ```\n///\n/// # root_assign_rem\n/// ```\n/// use malachite_base::num::arithmetic::traits::RootAssignRem;\n///\n/// let mut x = 999u16;\n/// assert_eq!(x.root_assign_rem(3), 270);\n/// assert_eq!(x, 9);\n///\n/// let mut x = 1000u16;\n/// assert_eq!(x.root_assign_rem(3), 0);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 1001u16;\n/// assert_eq!(x.root_assign_rem(3), 1);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 100000000000u64;\n/// assert_eq!(x.root_assign_rem(5), 1534195232);\n/// assert_eq!(x, 158);\n/// ```\npub mod root;\n/// [`RotateLeft`](traits::RotateLeft), [`RotateLeftAssign`](traits::RotateLeftAssign),\n/// [`RotateRight`](traits::RotateRight), and [`RotateRightAssign`](traits::RotateRightAssign),\n/// traits for rotating a number's bits.\n///\n/// # rotate_left_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::RotateLeftAssign;\n///\n/// let mut x: u32 = 0xabcd6789;\n/// x.rotate_left_assign(4);\n/// assert_eq!(x, 0xbcd6789a);\n///\n/// x = 0xabcd6789;\n/// x.rotate_left_assign(32);\n/// assert_eq!(x, 0xabcd6789);\n///\n/// x = 0xabcd6789;\n/// x.rotate_left_assign(36);\n/// assert_eq!(x, 0xbcd6789a);\n/// ```\n///\n/// # rotate_right_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::RotateRightAssign;\n///\n/// let mut x: u32 = 0xabcd6789;\n/// x.rotate_right_assign(4);\n/// assert_eq!(x, 0x9abcd678);\n///\n/// x = 0xabcd6789;\n/// x.rotate_right_assign(32);\n/// assert_eq!(x, 0xabcd6789);\n///\n/// x = 0xabcd6789;\n/// x.rotate_right_assign(36);\n/// assert_eq!(x, 0x9abcd678);\n/// ```\npub mod rotate;\n/// [`RoundToMultiple`](traits::RoundToMultiple) and\n/// [`RoundToMultipleAssign`](traits::RoundToMultipleAssign), traits for rounding a number to a\n/// multiple of another number.\n///\n/// # round_to_multiple\n/// ```\n/// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(5u32.round_to_multiple(0, Down), (0, Less));\n///\n/// assert_eq!(10u8.round_to_multiple(4, Down), (8, Less));\n/// assert_eq!(10u16.round_to_multiple(4, Up), (12, Greater));\n/// assert_eq!(10u32.round_to_multiple(5, Exact), (10, Equal));\n/// assert_eq!(10u64.round_to_multiple(3, Nearest), (9, Less));\n/// assert_eq!(20u128.round_to_multiple(3, Nearest), (21, Greater));\n/// assert_eq!(10usize.round_to_multiple(4, Nearest), (8, Less));\n/// assert_eq!(14u8.round_to_multiple(4, Nearest), (16, Greater));\n///\n/// assert_eq!((-5i32).round_to_multiple(0, Down), (0, Greater));\n///\n/// assert_eq!((-10i8).round_to_multiple(4, Down), (-8, Greater));\n/// assert_eq!((-10i16).round_to_multiple(4, Up), (-12, Less));\n/// assert_eq!((-10i32).round_to_multiple(5, Exact), (-10, Equal));\n/// assert_eq!((-10i64).round_to_multiple(3, Nearest), (-9, Greater));\n/// assert_eq!((-20i128).round_to_multiple(3, Nearest), (-21, Less));\n/// assert_eq!((-10isize).round_to_multiple(4, Nearest), (-8, Greater));\n/// assert_eq!((-14i8).round_to_multiple(4, Nearest), (-16, Less));\n///\n/// assert_eq!((-10i16).round_to_multiple(-4, Down), (-8, Greater));\n/// assert_eq!((-10i32).round_to_multiple(-4, Up), (-12, Less));\n/// assert_eq!((-10i64).round_to_multiple(-5, Exact), (-10, Equal));\n/// assert_eq!((-10i128).round_to_multiple(-3, Nearest), (-9, Greater));\n/// assert_eq!((-20isize).round_to_multiple(-3, Nearest), (-21, Less));\n/// assert_eq!((-10i8).round_to_multiple(-4, Nearest), (-8, Greater));\n/// assert_eq!((-14i16).round_to_multiple(-4, Nearest), (-16, Less));\n/// ```\n///\n/// # round_to_multiple_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = 5u32;\n/// assert_eq!(x.round_to_multiple_assign(0, Down), Less);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 10u8;\n/// assert_eq!(x.round_to_multiple_assign(4, Down), Less);\n/// assert_eq!(x, 8);\n///\n/// let mut x = 10u16;\n/// assert_eq!(x.round_to_multiple_assign(4, Up), Greater);\n/// assert_eq!(x, 12);\n///\n/// let mut x = 10u32;\n/// assert_eq!(x.round_to_multiple_assign(5, Exact), Equal);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 10u64;\n/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Less);\n/// assert_eq!(x, 9);\n///\n/// let mut x = 20u128;\n/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Greater);\n/// assert_eq!(x, 21);\n///\n/// let mut x = 10usize;\n/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Less);\n/// assert_eq!(x, 8);\n///\n/// let mut x = 14u8;\n/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Greater);\n/// assert_eq!(x, 16);\n///\n/// let mut x = -5i32;\n/// assert_eq!(x.round_to_multiple_assign(0, Down), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -10i8;\n/// assert_eq!(x.round_to_multiple_assign(4, Down), Greater);\n/// assert_eq!(x, -8);\n///\n/// let mut x = -10i16;\n/// assert_eq!(x.round_to_multiple_assign(4, Up), Less);\n/// assert_eq!(x, -12);\n///\n/// let mut x = -10i32;\n/// assert_eq!(x.round_to_multiple_assign(5, Exact), Equal);\n/// assert_eq!(x, -10);\n///\n/// let mut x = -10i64;\n/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Greater);\n/// assert_eq!(x, -9);\n///\n/// let mut x = -20i128;\n/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Less);\n/// assert_eq!(x, -21);\n///\n/// let mut x = -10isize;\n/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Greater);\n/// assert_eq!(x, -8);\n///\n/// let mut x = -14i8;\n/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Less);\n/// assert_eq!(x, -16);\n///\n/// let mut x = -10i16;\n/// assert_eq!(x.round_to_multiple_assign(-4, Down), Greater);\n/// assert_eq!(x, -8);\n///\n/// let mut x = -10i32;\n/// assert_eq!(x.round_to_multiple_assign(-4, Up), Less);\n/// assert_eq!(x, -12);\n///\n/// let mut x = -10i64;\n/// assert_eq!(x.round_to_multiple_assign(-5, Exact), Equal);\n/// assert_eq!(x, -10);\n///\n/// let mut x = -10i128;\n/// assert_eq!(x.round_to_multiple_assign(-3, Nearest), Greater);\n/// assert_eq!(x, -9);\n///\n/// let mut x = -20isize;\n/// assert_eq!(x.round_to_multiple_assign(-3, Nearest), Less);\n/// assert_eq!(x, -21);\n///\n/// let mut x = -10i8;\n/// assert_eq!(x.round_to_multiple_assign(-4, Nearest), Greater);\n/// assert_eq!(x, -8);\n///\n/// let mut x = -14i16;\n/// assert_eq!(x.round_to_multiple_assign(-4, Nearest), Less);\n/// assert_eq!(x, -16);\n/// ```\npub mod round_to_multiple;\n/// [`RoundToMultipleOfPowerOf2`](traits::RoundToMultipleOfPowerOf2) and\n/// [`RoundToMultipleOfPowerOf2Assign`](traits::RoundToMultipleOfPowerOf2Assign), traits for\n/// rounding a number to a multiple of a power of 2.\n///\n/// # round_to_multiple_of_power_of_2\n/// ```\n/// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Floor), (8, Less));\n/// assert_eq!(\n///     10u8.round_to_multiple_of_power_of_2(2, Ceiling),\n///     (12, Greater)\n/// );\n/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Down), (8, Less));\n/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Up), (12, Greater));\n/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Nearest), (8, Less));\n/// assert_eq!(12u8.round_to_multiple_of_power_of_2(2, Exact), (12, Equal));\n///\n/// assert_eq!(\n///     (-10i8).round_to_multiple_of_power_of_2(2, Floor),\n///     (-12, Less)\n/// );\n/// assert_eq!(\n///     (-10i8).round_to_multiple_of_power_of_2(2, Ceiling),\n///     (-8, Greater)\n/// );\n/// assert_eq!(\n///     (-10i8).round_to_multiple_of_power_of_2(2, Down),\n///     (-8, Greater)\n/// );\n/// assert_eq!((-10i8).round_to_multiple_of_power_of_2(2, Up), (-12, Less));\n/// assert_eq!(\n///     (-10i8).round_to_multiple_of_power_of_2(2, Nearest),\n///     (-8, Greater)\n/// );\n/// assert_eq!(\n///     (-12i8).round_to_multiple_of_power_of_2(2, Exact),\n///     (-12, Equal)\n/// );\n/// ```\n///\n/// # round_to_multiple_of_power_of_2_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = 10u8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Floor), Less);\n/// assert_eq!(x, 8);\n///\n/// let mut x = 10u8;\n/// assert_eq!(\n///     x.round_to_multiple_of_power_of_2_assign(2, Ceiling),\n///     Greater\n/// );\n/// assert_eq!(x, 12);\n///\n/// let mut x = 10u8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Down), Less);\n/// assert_eq!(x, 8);\n///\n/// let mut x = 10u8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Up), Greater);\n/// assert_eq!(x, 12);\n///\n/// let mut x = 10u8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Nearest), Less);\n/// assert_eq!(x, 8);\n///\n/// let mut x = 12u8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Exact), Equal);\n/// assert_eq!(x, 12);\n///\n/// let mut x = -10i8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Floor), Less);\n/// assert_eq!(x, -12);\n///\n/// let mut x = -10i8;\n/// assert_eq!(\n///     x.round_to_multiple_of_power_of_2_assign(2, Ceiling),\n///     Greater\n/// );\n/// assert_eq!(x, -8);\n///\n/// let mut x = -10i8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Down), Greater);\n/// assert_eq!(x, -8);\n///\n/// let mut x = -10i8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Up), Less);\n/// assert_eq!(x, -12);\n///\n/// let mut x = -10i8;\n/// assert_eq!(\n///     x.round_to_multiple_of_power_of_2_assign(2, Nearest),\n///     Greater\n/// );\n/// assert_eq!(x, -8);\n///\n/// let mut x = -12i8;\n/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Exact), Equal);\n/// assert_eq!(x, -12);\n/// ```\npub mod round_to_multiple_of_power_of_2;\n/// [`SaturatingAbs`](traits::SaturatingAbs) and\n/// [`SaturatingAbsAssign`](traits::SaturatingAbsAssign), traits for taking the absolute value of a\n/// number and saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_abs_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingAbsAssign;\n///\n/// let mut x = 0i8;\n/// x.saturating_abs_assign();\n/// assert_eq!(x, 0);\n///\n/// let mut x = 100i64;\n/// x.saturating_abs_assign();\n/// assert_eq!(x, 100);\n///\n/// let mut x = -100i64;\n/// x.saturating_abs_assign();\n/// assert_eq!(x, 100);\n///\n/// let mut x = -128i8;\n/// x.saturating_abs_assign();\n/// assert_eq!(x, 127);\n/// ```\npub mod saturating_abs;\n/// [`SaturatingAdd`](traits::SaturatingAdd) and\n/// [`SaturatingAddAssign`](traits::SaturatingAddAssign), traits for adding two numbers and\n/// saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_add_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingAddAssign;\n///\n/// let mut x = 123u16;\n/// x.saturating_add_assign(456);\n/// assert_eq!(x, 579);\n///\n/// let mut x = 123u8;\n/// x.saturating_add_assign(200);\n/// assert_eq!(x, 255);\n/// ```\npub mod saturating_add;\n/// [`SaturatingAddMul`](traits::SaturatingAddMul) and\n/// [`SaturatingAddMulAssign`](traits::SaturatingAddMulAssign), traits for adding the product of two\n/// numbers to a number and saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_add_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingAddMul;\n///\n/// assert_eq!(2u8.saturating_add_mul(3, 7), 23);\n/// assert_eq!(2u8.saturating_add_mul(20, 20), 255);\n///\n/// assert_eq!(127i8.saturating_add_mul(-2, 100), -73);\n/// assert_eq!((-127i8).saturating_add_mul(-2, 100), -128);\n/// ```\n///\n/// # saturating_add_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingAddMulAssign;\n///\n/// let mut x = 2u8;\n/// x.saturating_add_mul_assign(3, 7);\n/// assert_eq!(x, 23);\n///\n/// let mut x = 2u8;\n/// x.saturating_add_mul_assign(20, 20);\n/// assert_eq!(x, 255);\n///\n/// let mut x = 127i8;\n/// x.saturating_add_mul_assign(-2, 100);\n/// assert_eq!(x, -73);\n///\n/// let mut x = -127i8;\n/// x.saturating_add_mul_assign(-2, 100);\n/// assert_eq!(x, -128);\n/// ```\npub mod saturating_add_mul;\n/// [`SaturatingMul`](traits::SaturatingMul) and\n/// [`SaturatingMulAssign`](traits::SaturatingMulAssign), traits for multiplying two numbers and\n/// saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingMulAssign;\n///\n/// let mut x = 123u16;\n/// x.saturating_mul_assign(456);\n/// assert_eq!(x, 56088);\n///\n/// let mut x = 123u8;\n/// x.saturating_mul_assign(200);\n/// assert_eq!(x, 255);\n/// ```\npub mod saturating_mul;\n/// [`SaturatingNeg`](traits::SaturatingNeg) and\n/// [`SaturatingNegAssign`](traits::SaturatingNegAssign), traits for negating a number and\n/// saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_neg_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingNegAssign;\n///\n/// let mut x = 0i8;\n/// x.saturating_neg_assign();\n/// assert_eq!(x, 0);\n///\n/// let mut x = 100i64;\n/// x.saturating_neg_assign();\n/// assert_eq!(x, -100);\n///\n/// let mut x = -100i64;\n/// x.saturating_neg_assign();\n/// assert_eq!(x, 100);\n///\n/// let mut x = -128i8;\n/// x.saturating_neg_assign();\n/// assert_eq!(x, 127);\n/// ```\npub mod saturating_neg;\n/// [`SaturatingPow`](traits::SaturatingPow) and\n/// [`SaturatingPowAssign`](traits::SaturatingPowAssign), traits for raising a number to a power and\n/// saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_pow_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingPowAssign;\n///\n/// let mut x = 3u8;\n/// x.saturating_pow_assign(3);\n/// assert_eq!(x, 27);\n///\n/// let mut x = -10i32;\n/// x.saturating_pow_assign(9);\n/// assert_eq!(x, -1000000000);\n///\n/// let mut x = -10i16;\n/// x.saturating_pow_assign(9);\n/// assert_eq!(x, -32768);\n/// ```\npub mod saturating_pow;\n/// [`SaturatingSquare`](traits::SaturatingSquare) and\n/// [`SaturatingSquareAssign`](traits::SaturatingSquareAssign), traits for squaring a number and\n/// saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_square\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingSquare;\n///\n/// assert_eq!(3u8.saturating_square(), 9);\n/// assert_eq!((-1000i32).saturating_square(), 1000000);\n/// assert_eq!(1000u16.saturating_square(), u16::MAX);\n/// ```\n///\n/// # saturating_square_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingSquareAssign;\n///\n/// let mut x = 3u8;\n/// x.saturating_square_assign();\n/// assert_eq!(x, 9);\n///\n/// let mut x = -1000i32;\n/// x.saturating_square_assign();\n/// assert_eq!(x, 1000000);\n///\n/// let mut x = 1000u16;\n/// x.saturating_square_assign();\n/// assert_eq!(x, u16::MAX);\n/// ```\npub mod saturating_square;\n/// [`SaturatingSub`](traits::SaturatingSub) and\n/// [`SaturatingSubAssign`](traits::SaturatingSubAssign), traits for subtracting two numbers and\n/// saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_sub_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingSubAssign;\n///\n/// let mut x = 456u16;\n/// x.saturating_sub_assign(123);\n/// assert_eq!(x, 333);\n///\n/// let mut x = 123u16;\n/// x.saturating_sub_assign(456);\n/// assert_eq!(x, 0);\n/// ```\npub mod saturating_sub;\n/// [`SaturatingSubMul`](traits::SaturatingSubMul) and\n/// [`SaturatingSubMulAssign`](traits::SaturatingSubMulAssign), traits for subtracting a number by\n/// the product of two numbers and saturating at numeric bounds instead of overflowing.\n///\n/// # saturating_sub_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingSubMul;\n///\n/// assert_eq!(60u8.saturating_sub_mul(5, 10), 10);\n/// assert_eq!(2u8.saturating_sub_mul(10, 5), 0);\n///\n/// assert_eq!(127i8.saturating_sub_mul(2, 100), -73);\n/// assert_eq!((-127i8).saturating_sub_mul(2, 100), -128);\n/// ```\n///\n/// # saturating_sub_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SaturatingSubMulAssign;\n///\n/// let mut x = 60u8;\n/// x.saturating_sub_mul_assign(5, 10);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 2u8;\n/// x.saturating_sub_mul_assign(10, 5);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 127i8;\n/// x.saturating_sub_mul_assign(2, 100);\n/// assert_eq!(x, -73);\n///\n/// let mut x = -127i8;\n/// x.saturating_sub_mul_assign(2, 100);\n/// assert_eq!(x, -128);\n/// ```\npub mod saturating_sub_mul;\n/// [`ShlRound`](traits::ShlRound) and [`ShlRoundAssign`](traits::ShlRoundAssign), traits for\n/// multiplying a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](crate::rounding_modes::RoundingMode).\n///\n/// # shl_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShlRound;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(0x101u16.shl_round(-8i8, Down), (1, Less));\n/// assert_eq!(0x101u32.shl_round(-8i16, Up), (2, Greater));\n///\n/// assert_eq!((-0x101i16).shl_round(-9i32, Down), (0, Greater));\n/// assert_eq!((-0x101i32).shl_round(-9i64, Up), (-1, Less));\n/// assert_eq!((-0x101i64).shl_round(-9i8, Nearest), (-1, Less));\n/// assert_eq!((-0xffi32).shl_round(-9i16, Nearest), (0, Greater));\n/// assert_eq!((-0x100i16).shl_round(-9i32, Nearest), (0, Greater));\n///\n/// assert_eq!(0x100u64.shl_round(-8i64, Exact), (1, Equal));\n/// ```\n///\n/// # shl_round_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShlRoundAssign;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = 0x101u16;\n/// assert_eq!(x.shl_round_assign(-8i8, Down), Less);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0x101u32;\n/// assert_eq!(x.shl_round_assign(-8i16, Up), Greater);\n/// assert_eq!(x, 2);\n///\n/// let mut x = -0x101i16;\n/// assert_eq!(x.shl_round_assign(-9i32, Down), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -0x101i32;\n/// assert_eq!(x.shl_round_assign(-9i64, Up), Less);\n/// assert_eq!(x, -1);\n///\n/// let mut x = -0x101i64;\n/// assert_eq!(x.shl_round_assign(-9i8, Nearest), Less);\n/// assert_eq!(x, -1);\n///\n/// let mut x = -0xffi32;\n/// assert_eq!(x.shl_round_assign(-9i16, Nearest), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -0x100i16;\n/// assert_eq!(x.shl_round_assign(-9i32, Nearest), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 0x100u64;\n/// assert_eq!(x.shl_round_assign(-8i64, Exact), Equal);\n/// assert_eq!(x, 1);\n/// ```\npub mod shl_round;\n/// [`ShrRound`](traits::ShrRound) and [`ShrRoundAssign`](traits::ShrRoundAssign), traits for\n/// dividing a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](crate::rounding_modes::RoundingMode).\n///\n/// # shr_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShrRound;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(0x101u32.shr_round(8u8, Down), (1, Less));\n/// assert_eq!(0x101u16.shr_round(8u16, Up), (2, Greater));\n///\n/// assert_eq!(0x101u64.shr_round(9u32, Down), (0, Less));\n/// assert_eq!(0x101u32.shr_round(9u64, Up), (1, Greater));\n/// assert_eq!(0x101u16.shr_round(9u8, Nearest), (1, Greater));\n/// assert_eq!(0xffu8.shr_round(9u16, Nearest), (0, Less));\n/// assert_eq!(0x100u32.shr_round(9u32, Nearest), (0, Less));\n///\n/// assert_eq!(0x100u32.shr_round(8u64, Exact), (1, Equal));\n///\n/// assert_eq!(0x101i32.shr_round(8u8, Down), (1, Less));\n/// assert_eq!(0x101i16.shr_round(8u16, Up), (2, Greater));\n///\n/// assert_eq!((-0x101i32).shr_round(9u32, Down), (0, Greater));\n/// assert_eq!((-0x101i64).shr_round(9u64, Up), (-1, Less));\n/// assert_eq!((-0x101i16).shr_round(9u8, Nearest), (-1, Less));\n/// assert_eq!((-0xffi32).shr_round(9u16, Nearest), (0, Greater));\n/// assert_eq!((-0x100i64).shr_round(9u32, Nearest), (0, Greater));\n///\n/// assert_eq!(0x100i32.shr_round(8u64, Exact), (1, Equal));\n///\n/// assert_eq!(0x101u32.shr_round(8i8, Down), (1, Less));\n/// assert_eq!(0x101u16.shr_round(8i16, Up), (2, Greater));\n///\n/// assert_eq!((-0x101i32).shr_round(9i32, Down), (0, Greater));\n/// assert_eq!((-0x101i64).shr_round(9i64, Up), (-1, Less));\n/// assert_eq!((-0x101i16).shr_round(9i8, Nearest), (-1, Less));\n/// assert_eq!((-0xffi32).shr_round(9i16, Nearest), (0, Greater));\n/// assert_eq!((-0x100i64).shr_round(9i32, Nearest), (0, Greater));\n///\n/// assert_eq!(0x100u32.shr_round(8i64, Exact), (1, Equal));\n/// ```\n///\n/// # shr_round_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShrRoundAssign;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = 0x101u32;\n/// assert_eq!(x.shr_round_assign(8u8, Down), Less);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0x101u16;\n/// assert_eq!(x.shr_round_assign(8u16, Up), Greater);\n/// assert_eq!(x, 2);\n///\n/// let mut x = 0x101u64;\n/// assert_eq!(x.shr_round_assign(9u32, Down), Less);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 0x101u32;\n/// assert_eq!(x.shr_round_assign(9u64, Up), Greater);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0x101u16;\n/// assert_eq!(x.shr_round_assign(9u8, Nearest), Greater);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0xffu8;\n/// assert_eq!(x.shr_round_assign(9u16, Nearest), Less);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 0x100u32;\n/// assert_eq!(x.shr_round_assign(9u32, Nearest), Less);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 0x100u32;\n/// assert_eq!(x.shr_round_assign(8u64, Exact), Equal);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0x101i32;\n/// assert_eq!(x.shr_round_assign(8u8, Down), Less);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0x101i16;\n/// assert_eq!(x.shr_round_assign(8u16, Up), Greater);\n/// assert_eq!(x, 2);\n///\n/// let mut x = -0x101i32;\n/// assert_eq!(x.shr_round_assign(9u32, Down), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -0x101i64;\n/// assert_eq!(x.shr_round_assign(9u64, Up), Less);\n/// assert_eq!(x, -1);\n///\n/// let mut x = -0x101i16;\n/// assert_eq!(x.shr_round_assign(9u8, Nearest), Less);\n/// assert_eq!(x, -1);\n///\n/// let mut x = -0xffi32;\n/// assert_eq!(x.shr_round_assign(9u16, Nearest), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -0x100i64;\n/// assert_eq!(x.shr_round_assign(9u32, Nearest), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 0x100u32;\n/// assert_eq!(x.shr_round_assign(8i64, Exact), Equal);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0x101u32;\n/// assert_eq!(x.shr_round_assign(8i8, Down), Less);\n/// assert_eq!(x, 1);\n///\n/// let mut x = 0x101u16;\n/// assert_eq!(x.shr_round_assign(8i16, Up), Greater);\n/// assert_eq!(x, 2);\n///\n/// let mut x = -0x101i32;\n/// assert_eq!(x.shr_round_assign(9i32, Down), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -0x101i64;\n/// assert_eq!(x.shr_round_assign(9i64, Up), Less);\n/// assert_eq!(x, -1);\n///\n/// let mut x = -0x101i16;\n/// assert_eq!(x.shr_round_assign(9i8, Nearest), Less);\n/// assert_eq!(x, -1);\n///\n/// let mut x = -0xffi32;\n/// assert_eq!(x.shr_round_assign(9i16, Nearest), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -0x100i64;\n/// assert_eq!(x.shr_round_assign(9i32, Nearest), Greater);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 0x100u32;\n/// assert_eq!(x.shr_round_assign(8i64, Exact), Equal);\n/// assert_eq!(x, 1);\n/// ```\npub mod shr_round;\n/// [`Sign`](traits::Sign), a trait for determining the sign of a number.\n///\n/// # sign\n/// ```\n/// use malachite_base::num::arithmetic::traits::Sign;\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(0u8.sign(), Equal);\n/// assert_eq!(100u64.sign(), Greater);\n/// assert_eq!((-100i16).sign(), Less);\n///\n/// assert_eq!(0.0.sign(), Greater);\n/// assert_eq!(1.0.sign(), Greater);\n/// assert_eq!(f64::INFINITY.sign(), Greater);\n///\n/// assert_eq!((-0.0).sign(), Less);\n/// assert_eq!((-1.0).sign(), Less);\n/// assert_eq!(f64::NEGATIVE_INFINITY.sign(), Less);\n///\n/// assert_eq!(f64::NAN.sign(), Equal);\n/// ```\npub mod sign;\n/// Traits for taking the square root of a number.\n///\n/// The traits are [`FloorSqrt`](traits::FloorSqrt), [`FloorSqrtAssign`](traits::FloorSqrtAssign),\n/// [`CeilingSqrt`](traits::CeilingSqrt), [`CeilingSqrtAssign`](traits::CeilingSqrtAssign),\n/// [`CheckedSqrt`](traits::CheckedSqrt), [`SqrtRem`](traits::SqrtRem),\n/// [`SqrtAssignRem`](traits::SqrtAssignRem), and [`SqrtAssign`](traits::SqrtAssign).\n///\n/// # floor_sqrt\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorSqrt;\n///\n/// assert_eq!(99u8.floor_sqrt(), 9);\n/// assert_eq!(100u8.floor_sqrt(), 10);\n/// assert_eq!(101u8.floor_sqrt(), 10);\n/// assert_eq!(1000000000i32.floor_sqrt(), 31622);\n/// assert_eq!(10000000000i64.floor_sqrt(), 100000);\n/// ```\n///\n/// # floor_sqrt_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::FloorSqrtAssign;\n///\n/// let mut x = 99u8;\n/// x.floor_sqrt_assign();\n/// assert_eq!(x, 9);\n///\n/// let mut x = 100u8;\n/// x.floor_sqrt_assign();\n/// assert_eq!(x, 10);\n///\n/// let mut x = 101u8;\n/// x.floor_sqrt_assign();\n/// assert_eq!(x, 10);\n///\n/// let mut x = 1000000000i32;\n/// x.floor_sqrt_assign();\n/// assert_eq!(x, 31622);\n///\n/// let mut x = 10000000000i64;\n/// x.floor_sqrt_assign();\n/// assert_eq!(x, 100000);\n/// ```\n///\n/// # ceiling_sqrt\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingSqrt;\n///\n/// assert_eq!(99u8.ceiling_sqrt(), 10);\n/// assert_eq!(100u8.ceiling_sqrt(), 10);\n/// assert_eq!(101u8.ceiling_sqrt(), 11);\n/// assert_eq!(1000000000u32.ceiling_sqrt(), 31623);\n/// assert_eq!(10000000000u64.ceiling_sqrt(), 100000);\n/// ```\n///\n/// # ceiling_sqrt_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::CeilingSqrtAssign;\n///\n/// let mut x = 99u8;\n/// x.ceiling_sqrt_assign();\n/// assert_eq!(x, 10);\n///\n/// let mut x = 100u8;\n/// x.ceiling_sqrt_assign();\n/// assert_eq!(x, 10);\n///\n/// let mut x = 101u8;\n/// x.ceiling_sqrt_assign();\n/// assert_eq!(x, 11);\n///\n/// let mut x = 1000000000i32;\n/// x.ceiling_sqrt_assign();\n/// assert_eq!(x, 31623);\n///\n/// let mut x = 10000000000i64;\n/// x.ceiling_sqrt_assign();\n/// assert_eq!(x, 100000);\n/// ```\n///\n/// # checked_sqrt\n/// ```\n/// use malachite_base::num::arithmetic::traits::CheckedSqrt;\n///\n/// assert_eq!(99u8.checked_sqrt(), None);\n/// assert_eq!(100u8.checked_sqrt(), Some(10));\n/// assert_eq!(101u8.checked_sqrt(), None);\n/// assert_eq!(1000000000i32.checked_sqrt(), None);\n/// assert_eq!(10000000000i64.checked_sqrt(), Some(100000));\n/// ```\n///\n/// # sqrt_rem\n/// ```\n/// use malachite_base::num::arithmetic::traits::SqrtRem;\n///\n/// assert_eq!(99u8.sqrt_rem(), (9, 18));\n/// assert_eq!(100u8.sqrt_rem(), (10, 0));\n/// assert_eq!(101u8.sqrt_rem(), (10, 1));\n/// assert_eq!(1000000000u32.sqrt_rem(), (31622, 49116));\n/// assert_eq!(10000000000u64.sqrt_rem(), (100000, 0));\n/// ```\n///\n/// # sqrt_assign_rem\n/// ```\n/// use malachite_base::num::arithmetic::traits::SqrtAssignRem;\n///\n/// let mut x = 99u8;\n/// assert_eq!(x.sqrt_assign_rem(), 18);\n/// assert_eq!(x, 9);\n///\n/// let mut x = 100u8;\n/// assert_eq!(x.sqrt_assign_rem(), 0);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 101u8;\n/// assert_eq!(x.sqrt_assign_rem(), 1);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 1000000000u32;\n/// assert_eq!(x.sqrt_assign_rem(), 49116);\n/// assert_eq!(x, 31622);\n///\n/// let mut x = 10000000000u64;\n/// assert_eq!(x.sqrt_assign_rem(), 0);\n/// assert_eq!(x, 100000);\n/// ```\n///\n/// # sqrt_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SqrtAssign;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// let mut x = 4.0f64;\n/// x.sqrt_assign();\n/// assert_eq!(NiceFloat(x), NiceFloat(2.0));\n///\n/// let mut x = 2.0f64;\n/// x.sqrt_assign();\n/// assert_eq!(NiceFloat(x), NiceFloat(std::f64::consts::SQRT_2));\n/// ```\npub mod sqrt;\n/// [`Square`](traits::Square) and [`SquareAssign`](traits::SquareAssign), traits for squaring a\n/// number.\n///\n/// # square\n/// ```\n/// use malachite_base::num::arithmetic::traits::Square;\n///\n/// assert_eq!(3u8.square(), 9);\n/// assert_eq!((-1000i32).square(), 1000000);\n/// assert_eq!(1.5f32.square(), 2.25);\n/// ```\n///\n/// # square_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SquareAssign;\n///\n/// let mut x = 3u8;\n/// x.square_assign();\n/// assert_eq!(x, 9);\n///\n/// let mut x = -1000i32;\n/// x.square_assign();\n/// assert_eq!(x, 1000000);\n///\n/// let mut x = 1.5f32;\n/// x.square_assign();\n/// assert_eq!(x, 2.25);\n/// ```\npub mod square;\n/// [`SubMul`](traits::SubMul) and [`SubMulAssign`](traits::SubMulAssign), traits for subtracting\n/// the product of two numbers from a number.\n///\n/// # sub_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::SubMul;\n///\n/// assert_eq!(60u32.sub_mul(5, 10), 10);\n/// assert_eq!(127i8.sub_mul(2, 100), -73);\n/// assert_eq!(1.0f32.sub_mul(2.0, 3.0), -5.0);\n/// ```\n///\n/// # sub_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::SubMulAssign;\n///\n/// let mut x = 60u32;\n/// x.sub_mul_assign(5, 10);\n/// assert_eq!(x, 10);\n///\n/// let mut x = 127i8;\n/// x.sub_mul_assign(2, 100);\n/// assert_eq!(x, -73);\n///\n/// let mut x = 1.0f32;\n/// x.sub_mul_assign(2.0, 3.0);\n/// assert_eq!(x, -5.0);\n/// ```\npub mod sub_mul;\n/// Various traits for performing arithmetic operations on numbers.\npub mod traits;\n/// [`WrappingAbs`](traits::WrappingAbs) and [`WrappingAbsAssign`](traits::WrappingAbsAssign),\n/// traits for computing the absolute value of a number and wrapping at the boundary of the type.\n///\n/// # wrapping_abs_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingAbsAssign;\n///\n/// let mut x = 0i8;\n/// x.wrapping_abs_assign();\n/// assert_eq!(x, 0);\n///\n/// let mut x = 100i64;\n/// x.wrapping_abs_assign();\n/// assert_eq!(x, 100);\n///\n/// let mut x = -100i64;\n/// x.wrapping_abs_assign();\n/// assert_eq!(x, 100);\n///\n/// let mut x = -128i8;\n/// x.wrapping_abs_assign();\n/// assert_eq!(x, -128);\n/// ```\npub mod wrapping_abs;\n/// [`WrappingAdd`](traits::WrappingAdd) and [`WrappingAddAssign`](traits::WrappingAddAssign),\n/// traits for adding two numbers and wrapping at the boundary of the type.\n///\n/// # wrapping_add_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingAddAssign;\n///\n/// let mut x = 123u16;\n/// x.wrapping_add_assign(456);\n/// assert_eq!(x, 579);\n///\n/// let mut x = 123u8;\n/// x.wrapping_add_assign(200);\n/// assert_eq!(x, 67);\n/// ```\npub mod wrapping_add;\n/// [`WrappingAddMul`](traits::WrappingAddMul) and\n/// [`WrappingAddMulAssign`](traits::WrappingAddMulAssign), traits for adding the product of two\n/// numbers to a third and wrapping at the boundary of the type.\n///\n/// # wrapping_add_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingAddMul;\n///\n/// assert_eq!(2u8.wrapping_add_mul(3, 7), 23);\n/// assert_eq!((-127i8).wrapping_add_mul(-2, 100), -71);\n/// ```\n///\n/// # wrapping_add_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingAddMulAssign;\n///\n/// let mut x = 2u8;\n/// x.wrapping_add_mul_assign(3, 7);\n/// assert_eq!(x, 23);\n///\n/// let mut x = -127i8;\n/// x.wrapping_add_mul_assign(-2, 100);\n/// assert_eq!(x, -71);\n/// ```\npub mod wrapping_add_mul;\n/// [`WrappingDiv`](traits::WrappingDiv) and [`WrappingDivAssign`](traits::WrappingDivAssign),\n/// traits for dividing two numbers and wrapping at the boundary of the type.\n///\n/// # wrapping_div_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingDivAssign;\n///\n/// let mut x = 100u16;\n/// x.wrapping_div_assign(3);\n/// assert_eq!(x, 33);\n///\n/// let mut x = -128i8;\n/// x.wrapping_div_assign(-1);\n/// assert_eq!(x, -128);\n/// ```\npub mod wrapping_div;\n/// [`WrappingMul`](traits::WrappingMul) and [`WrappingMulAssign`](traits::WrappingMulAssign),\n/// traits for multiplying two numbers and wrapping at the boundary of the type.\n///\n/// # wrapping_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingMulAssign;\n///\n/// let mut x = 123u16;\n/// x.wrapping_mul_assign(456);\n/// assert_eq!(x, 56088);\n///\n/// let mut x = 123u8;\n/// x.wrapping_mul_assign(200);\n/// assert_eq!(x, 24);\n/// ```\npub mod wrapping_mul;\n/// [`WrappingNeg`](traits::WrappingNeg) and [`WrappingNegAssign`](traits::WrappingNegAssign) for\n/// negating a number and wrapping at the boundary of the type.\n///\n/// # wrapping_neg_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingNegAssign;\n///\n/// let mut x = 0i8;\n/// x.wrapping_neg_assign();\n/// assert_eq!(x, 0);\n///\n/// let mut x = 100u64;\n/// x.wrapping_neg_assign();\n/// assert_eq!(x, 18446744073709551516);\n///\n/// let mut x = -100i64;\n/// x.wrapping_neg_assign();\n/// assert_eq!(x, 100);\n///\n/// let mut x = -128i8;\n/// x.wrapping_neg_assign();\n/// assert_eq!(x, -128);\n/// ```\npub mod wrapping_neg;\n/// [`WrappingPow`](traits::WrappingPow) and [`WrappingPowAssign`](traits::WrappingPowAssign),\n/// traits for raising a number to a power and wrapping at the boundary of the type.\n///\n/// # wrapping_pow_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingPowAssign;\n///\n/// let mut x = 3u8;\n/// x.wrapping_pow_assign(3);\n/// assert_eq!(x, 27);\n///\n/// let mut x = -10i32;\n/// x.wrapping_pow_assign(9);\n/// assert_eq!(x, -1000000000);\n///\n/// let mut x = -10i16;\n/// x.wrapping_pow_assign(9);\n/// assert_eq!(x, 13824);\n/// ```\npub mod wrapping_pow;\n/// [`WrappingSquare`](traits::WrappingSquare) and\n/// [`WrappingSquareAssign`](traits::WrappingAbsAssign), traits for squaring a number and wrapping\n/// at the boundary of the type.\n///\n/// # wrapping_square\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingSquare;\n///\n/// assert_eq!(3u8.wrapping_square(), 9);\n/// assert_eq!((-1000i32).wrapping_square(), 1000000);\n/// assert_eq!(1000u16.wrapping_square(), 16960);\n/// ```\n///\n/// # wrapping_square_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingSquareAssign;\n///\n/// let mut x = 3u8;\n/// x.wrapping_square_assign();\n/// assert_eq!(x, 9);\n///\n/// let mut x = -1000i32;\n/// x.wrapping_square_assign();\n/// assert_eq!(x, 1000000);\n///\n/// let mut x = 1000u16;\n/// x.wrapping_square_assign();\n/// assert_eq!(x, 16960);\n/// ```\npub mod wrapping_square;\n/// [`WrappingSub`](traits::WrappingSub) and [`WrappingSubAssign`](traits::WrappingSubAssign),\n/// traits for subtracting two numbers and wrapping at the boundary of the type.\n///\n/// # wrapping_sub_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingSubAssign;\n///\n/// let mut x = 456u16;\n/// x.wrapping_sub_assign(123);\n/// assert_eq!(x, 333);\n///\n/// let mut x = 123u16;\n/// x.wrapping_sub_assign(456);\n/// assert_eq!(x, 65203);\n/// ```\npub mod wrapping_sub;\n/// [`WrappingSubMul`](traits::WrappingSubMul) and\n/// [`WrappingSubMulAssign`](traits::WrappingSubMulAssign), traits for subtracting a number by the\n/// product of two other numbers and wrapping at the boundary of the type.\n///\n/// # wrapping_sub_mul\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingSubMul;\n///\n/// assert_eq!(127i8.wrapping_sub_mul(2, 100), -73);\n/// assert_eq!((-127i8).wrapping_sub_mul(2, 100), -71);\n/// ```\n///\n/// # wrapping_sub_mul_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::WrappingAddMulAssign;\n///\n/// let mut x = 2u8;\n/// x.wrapping_add_mul_assign(3, 7);\n/// assert_eq!(x, 23);\n///\n/// let mut x = -127i8;\n/// x.wrapping_add_mul_assign(-2, 100);\n/// assert_eq!(x, -71);\n/// ```\npub mod wrapping_sub_mul;\n/// [`XMulYToZZ`](traits::XMulYToZZ), a trait for multiplying two numbers and returning the result\n/// as a double-width number.\n///\n/// # x_mul_y_to_zz\n/// ```\n/// use malachite_base::num::arithmetic::traits::XMulYToZZ;\n///\n/// assert_eq!(u64::x_mul_y_to_zz(15, 3), (0, 45));\n/// assert_eq!(u8::x_mul_y_to_zz(0x78, 0x9a), (0x48, 0x30));\n/// ```\npub mod x_mul_y_to_zz;\n/// [`XXAddYYToZZ`](traits::XXAddYYToZZ), a trait for adding two double-width numbers and returning\n/// the result as a double-width number.\n///\n/// # xx_add_yy_to_zz\n/// ```\n/// use malachite_base::num::arithmetic::traits::XXAddYYToZZ;\n///\n/// assert_eq!(u64::xx_add_yy_to_zz(0x12, 0x34, 0x33, 0x33), (0x45, 0x67));\n/// assert_eq!(u8::xx_add_yy_to_zz(0x78, 0x9a, 0xbc, 0xde), (0x35, 0x78));\n/// ```\npub mod xx_add_yy_to_zz;\n/// [`XXDivModYToQR`](traits::XXDivModYToQR), a trait for dividing a double-width number by a\n/// single-width number and returning the quotient and remainder.\n///\n/// # xx_div_mod_y_to_qr\n/// ```\n/// use malachite_base::num::arithmetic::traits::XXDivModYToQR;\n///\n/// assert_eq!(\n///     u64::xx_div_mod_y_to_qr(0x12, 0x34, 0x33),\n///     (0x5a5a5a5a5a5a5a5b, 0x13)\n/// );\n/// assert_eq!(u8::xx_div_mod_y_to_qr(0x78, 0x9a, 0xbc), (0xa4, 0x2a));\n/// ```\npub mod xx_div_mod_y_to_qr;\n/// [`XXSubYYToZZ`](traits::XXSubYYToZZ), a trait for subtracting two double-width numbers and\n/// returning the result as a double-width number.\n///\n/// # xx_sub_yy_to_zz\n/// ```\n/// use malachite_base::num::arithmetic::traits::XXSubYYToZZ;\n///\n/// assert_eq!(u64::xx_sub_yy_to_zz(0x67, 0x89, 0x33, 0x33), (0x34, 0x56));\n/// assert_eq!(u8::xx_sub_yy_to_zz(0x78, 0x9a, 0xbc, 0xde), (0xbb, 0xbc));\n/// ```\npub mod xx_sub_yy_to_zz;\n/// [`XXXAddYYYToZZZ`](traits::XXXAddYYYToZZZ), a trait for adding two triple-width numbers and\n/// returning the result as a triple-width number.\n///\n/// # xxx_add_yyy_to_zzz\n/// ```\n/// use malachite_base::num::arithmetic::traits::XXXAddYYYToZZZ;\n///\n/// assert_eq!(\n///     u64::xxx_add_yyy_to_zzz(0x12, 0x34, 0x56, 0x33, 0x33, 0x33),\n///     (0x45, 0x67, 0x89)\n/// );\n/// assert_eq!(\n///     u8::xxx_add_yyy_to_zzz(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc),\n///     (0x57, 0x99, 0x98)\n/// );\n/// ```\npub mod xxx_add_yyy_to_zzz;\n/// [`XXXSubYYYToZZZ`](traits::XXXSubYYYToZZZ), a trait for subtracting two triple-width numbers and\n/// returning the result as a triple-width number.\n///\n/// # xxx_sub_yyy_to_zzz\n/// ```\n/// use malachite_base::num::arithmetic::traits::XXXSubYYYToZZZ;\n///\n/// assert_eq!(\n///     u64::xxx_sub_yyy_to_zzz(0x67, 0x89, 0xab, 0x33, 0x33, 0x33),\n///     (0x34, 0x56, 0x78)\n/// );\n/// assert_eq!(\n///     u8::xxx_sub_yyy_to_zzz(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc),\n///     (0x99, 0x9b, 0xe0)\n/// );\n/// ```\npub mod xxx_sub_yyy_to_zzz;\n/// [`XXXXAddYYYYToZZZZ`](traits::XXXXAddYYYYToZZZZ), a trait for adding two quadruple-width numbers\n/// and returning the result as a quadruple-width number.\n///\n/// # xxxx_add_yyyy_to_zzzz\n/// ```\n/// use malachite_base::num::arithmetic::traits::XXXXAddYYYYToZZZZ;\n///\n/// assert_eq!(\n///     u64::xxxx_add_yyyy_to_zzzz(0x12, 0x34, 0x56, 0x78, 0x33, 0x33, 0x33, 0x33),\n///     (0x45, 0x67, 0x89, 0xab)\n/// );\n/// assert_eq!(\n///     u8::xxxx_add_yyyy_to_zzzz(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc, 0xba, 0x98),\n///     (0x77, 0x77, 0x77, 0x76)\n/// );\n/// ```\npub mod xxxx_add_yyyy_to_zzzz;\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2010 William Hart\n//\n//      Copyright © 2021 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModAdd, ModAddAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_add<T: PrimitiveUnsigned>(x: T, y: T, m: T) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    assert!(y < m, \"y must be reduced mod m, but {y} >= {m}\");\n    let neg = m - x;\n    if neg > y { x + y } else { y - neg }\n}\n\nfn mod_add_assign<T: PrimitiveUnsigned>(x: &mut T, y: T, m: T) {\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    assert!(y < m, \"y must be reduced mod m, but {y} >= {m}\");\n    let neg = m - *x;\n    if neg > y {\n        *x += y;\n    } else {\n        *x = y - neg;\n    }\n}\n\nmacro_rules! impl_mod_add {\n    ($t:ident) => {\n        impl ModAdd<$t> for $t {\n            type Output = $t;\n\n            /// Adds two numbers modulo a third number $m$. The inputs must be already reduced\n            /// modulo $m$.\n            ///\n            /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_add#mod_add).\n            ///\n            /// This is equivalent to `nmod_add` from `nmod.h`, FLINT 2.7.1.\n            #[inline]\n            fn mod_add(self, other: $t, m: $t) -> $t {\n                mod_add(self, other, m)\n            }\n        }\n\n        impl ModAddAssign<$t> for $t {\n            /// Adds two numbers modulo a third number $m$, in place. The inputs must be already\n            /// reduced modulo $m$.\n            ///\n            /// $x \\gets z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_add#mod_add_assign).\n            ///\n            /// This is equivalent to `nmod_add` from `nmod.h`, FLINT 2.7.1, where the result is\n            /// assigned to `a`.\n            #[inline]\n            fn mod_add_assign(&mut self, other: $t, m: $t) {\n                mod_add_assign(self, other, m);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_add);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009, 2016 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::ModInverse;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::rounding_modes::RoundingMode::*;\n\n// This is a variation of `n_xgcd` from `ulong_extras/xgcd.c`, FLINT 2.7.1.\npub_test! {mod_inverse_binary<\n    U: WrappingFrom<S> + PrimitiveUnsigned,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    x: U,\n    m: U,\n) -> Option<U> {\n    assert_ne!(x, U::ZERO);\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let mut u1 = S::ONE;\n    let mut v2 = S::ONE;\n    let mut u2 = S::ZERO;\n    let mut v1 = S::ZERO;\n    let mut u3 = m;\n    let mut v3 = x;\n    let mut d;\n    let mut t2;\n    let mut t1;\n    if (m & x).get_highest_bit() {\n        d = u3 - v3;\n        t2 = v2;\n        t1 = u2;\n        u2 = u1 - u2;\n        u1 = t1;\n        u3 = v3;\n        v2 = v1 - v2;\n        v1 = t2;\n        v3 = d;\n    }\n    while v3.get_bit(U::WIDTH - 2) {\n        d = u3 - v3;\n        if d < v3 {\n            // quot = 1\n            t2 = v2;\n            t1 = u2;\n            u2 = u1 - u2;\n            u1 = t1;\n            u3 = v3;\n            v2 = v1 - v2;\n            v1 = t2;\n            v3 = d;\n        } else if d < (v3 << 1) {\n            // quot = 2\n            t1 = u2;\n            u2 = u1 - (u2 << 1);\n            u1 = t1;\n            u3 = v3;\n            t2 = v2;\n            v2 = v1 - (v2 << 1);\n            v1 = t2;\n            v3 = d - u3;\n        } else {\n            // quot = 3\n            t1 = u2;\n            u2 = u1 - S::wrapping_from(3) * u2;\n            u1 = t1;\n            u3 = v3;\n            t2 = v2;\n            v2 = v1 - S::wrapping_from(3) * v2;\n            v1 = t2;\n            v3 = d - (u3 << 1);\n        }\n    }\n    while v3 != U::ZERO {\n        d = u3 - v3;\n        // overflow not possible, top 2 bits of v3 not set\n        if u3 < (v3 << 2) {\n            if d < v3 {\n                // quot = 1\n                t2 = v2;\n                t1 = u2;\n                u2 = u1 - u2;\n                u1 = t1;\n                u3 = v3;\n                v2 = v1 - v2;\n                v1 = t2;\n                v3 = d;\n            } else if d < (v3 << 1) {\n                // quot = 2\n                t1 = u2;\n                u2 = u1.wrapping_sub(u2 << 1);\n                u1 = t1;\n                u3 = v3;\n                t2 = v2;\n                v2 = v1.wrapping_sub(v2 << 1);\n                v1 = t2;\n                v3 = d - u3;\n            } else {\n                // quot = 3\n                t1 = u2;\n                u2 = u1.wrapping_sub(S::wrapping_from(3).wrapping_mul(u2));\n                u1 = t1;\n                u3 = v3;\n                t2 = v2;\n                v2 = v1.wrapping_sub(S::wrapping_from(3).wrapping_mul(v2));\n                v1 = t2;\n                v3 = d.wrapping_sub(u3 << 1);\n            }\n        } else {\n            let (quot, rem) = u3.div_rem(v3);\n            t1 = u2;\n            u2 = u1.wrapping_sub(S::wrapping_from(quot).wrapping_mul(u2));\n            u1 = t1;\n            u3 = v3;\n            t2 = v2;\n            v2 = v1.wrapping_sub(S::wrapping_from(quot).wrapping_mul(v2));\n            v1 = t2;\n            v3 = rem;\n        }\n    }\n    if u3 != U::ONE {\n        return None;\n    }\n    let mut inverse = U::wrapping_from(v1);\n    if u1 <= S::ZERO {\n        inverse.wrapping_sub_assign(m);\n    }\n    let limit = (m >> 1u32).wrapping_neg();\n    if inverse < limit {\n        let k = (limit - inverse).div_round(m, Ceiling).0;\n        inverse.wrapping_add_assign(m.wrapping_mul(k));\n    }\n    Some(if inverse.get_highest_bit() {\n        inverse.wrapping_add(m)\n    } else {\n        inverse\n    })\n}}\n\nmacro_rules! impl_mod_inverse {\n    ($u:ident, $s:ident) => {\n        impl ModInverse<$u> for $u {\n            type Output = $u;\n\n            /// Computes the multiplicative inverse of a number modulo another number $m$. The input\n            /// must be already reduced modulo $m$.\n            ///\n            /// Returns `None` if $x$ and $m$ are not coprime.\n            ///\n            /// $f(x, m) = y$, where $x, y < m$, $\\gcd(x, y) = 1$, and $xy \\equiv 1 \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n^2)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), m.significant_bits())`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_inverse#mod_inverse).\n            #[inline]\n            fn mod_inverse(self, m: $u) -> Option<$u> {\n                mod_inverse_binary::<$u, $s>(self, m)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_mod_inverse);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::ModIsReduced;\n\nmacro_rules! impl_mod_is_reduced {\n    ($t:ident) => {\n        impl ModIsReduced for $t {\n            /// Returns whether a number is reduced modulo another number $m$; in other words,\n            /// whether it is less than $m$. $m$ cannot be zero.\n            ///\n            /// $f(x, m) = (x < m)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if $m$ is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_is_reduced#mod_is_reduced).\n            #[inline]\n            fn mod_is_reduced(&self, m: &$t) -> bool {\n                assert_ne!(*m, 0);\n                self < m\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_is_reduced);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005\n//      Free Software Foundation, Inc.\n//\n//      Copyright © 2006, 2007, 2008, 2009, 2010, 2015, 2016 William Hart\n//\n//      Copyright © 2010, 2011, 2021 Fredrik Johansson\n//\n//      Copyright © 2008, Peter Shrimpton\n//\n//      Copyright © 2009, Tom Boothby\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    ModMul, ModMulAssign, ModMulPrecomputed, ModMulPrecomputedAssign, Parity, PowerOf2,\n    WrappingSubAssign,\n};\nuse crate::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, HasHalf, JoinHalves, SplitInHalf, WrappingFrom};\nuse crate::num::logic::traits::LeadingZeros;\n\npub_test! {naive_mod_mul<T: PrimitiveUnsigned>(x: T, y: T, m: T) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    assert!(y < m, \"y must be reduced mod m, but {y} >= {m}\");\n    let (product_1, product_0) = T::x_mul_y_to_zz(x, y);\n    T::xx_div_mod_y_to_qr(product_1, product_0, m).1\n}}\n\nconst INVERT_U32_TABLE_LOG_SIZE: u64 = 9;\n\nconst INVERT_U32_TABLE_SIZE: usize = 1 << INVERT_U32_TABLE_LOG_SIZE;\n\n// INVERT_U32_TABLE[i] = floor((2^24 - 2^14 + 2^9) / (2^9 + i))\nconst INVERT_U32_TABLE: [u32; INVERT_U32_TABLE_SIZE] = [\n    32737, 32673, 32609, 32546, 32483, 32420, 32357, 32295, 32233, 32171, 32109, 32048, 31987,\n    31926, 31865, 31805, 31744, 31684, 31625, 31565, 31506, 31447, 31388, 31329, 31271, 31212,\n    31154, 31097, 31039, 30982, 30924, 30868, 30811, 30754, 30698, 30642, 30586, 30530, 30475,\n    30419, 30364, 30309, 30255, 30200, 30146, 30092, 30038, 29984, 29930, 29877, 29824, 29771,\n    29718, 29666, 29613, 29561, 29509, 29457, 29405, 29354, 29303, 29251, 29200, 29150, 29099,\n    29049, 28998, 28948, 28898, 28849, 28799, 28750, 28700, 28651, 28602, 28554, 28505, 28457,\n    28409, 28360, 28313, 28265, 28217, 28170, 28123, 28075, 28029, 27982, 27935, 27889, 27842,\n    27796, 27750, 27704, 27658, 27613, 27568, 27522, 27477, 27432, 27387, 27343, 27298, 27254,\n    27209, 27165, 27121, 27078, 27034, 26990, 26947, 26904, 26861, 26818, 26775, 26732, 26690,\n    26647, 26605, 26563, 26521, 26479, 26437, 26395, 26354, 26312, 26271, 26230, 26189, 26148,\n    26108, 26067, 26026, 25986, 25946, 25906, 25866, 25826, 25786, 25747, 25707, 25668, 25628,\n    25589, 25550, 25511, 25473, 25434, 25395, 25357, 25319, 25281, 25242, 25205, 25167, 25129,\n    25091, 25054, 25016, 24979, 24942, 24905, 24868, 24831, 24794, 24758, 24721, 24685, 24649,\n    24612, 24576, 24540, 24504, 24469, 24433, 24397, 24362, 24327, 24291, 24256, 24221, 24186,\n    24151, 24117, 24082, 24047, 24013, 23979, 23944, 23910, 23876, 23842, 23808, 23774, 23741,\n    23707, 23674, 23640, 23607, 23574, 23541, 23508, 23475, 23442, 23409, 23377, 23344, 23312,\n    23279, 23247, 23215, 23183, 23151, 23119, 23087, 23055, 23023, 22992, 22960, 22929, 22898,\n    22866, 22835, 22804, 22773, 22742, 22711, 22681, 22650, 22619, 22589, 22559, 22528, 22498,\n    22468, 22438, 22408, 22378, 22348, 22318, 22289, 22259, 22229, 22200, 22171, 22141, 22112,\n    22083, 22054, 22025, 21996, 21967, 21938, 21910, 21881, 21853, 21824, 21796, 21767, 21739,\n    21711, 21683, 21655, 21627, 21599, 21571, 21544, 21516, 21488, 21461, 21433, 21406, 21379,\n    21352, 21324, 21297, 21270, 21243, 21216, 21190, 21163, 21136, 21110, 21083, 21056, 21030,\n    21004, 20977, 20951, 20925, 20899, 20873, 20847, 20821, 20795, 20769, 20744, 20718, 20693,\n    20667, 20642, 20616, 20591, 20566, 20540, 20515, 20490, 20465, 20440, 20415, 20390, 20366,\n    20341, 20316, 20292, 20267, 20243, 20218, 20194, 20170, 20145, 20121, 20097, 20073, 20049,\n    20025, 20001, 19977, 19953, 19930, 19906, 19882, 19859, 19835, 19812, 19789, 19765, 19742,\n    19719, 19696, 19672, 19649, 19626, 19603, 19581, 19558, 19535, 19512, 19489, 19467, 19444,\n    19422, 19399, 19377, 19354, 19332, 19310, 19288, 19265, 19243, 19221, 19199, 19177, 19155,\n    19133, 19112, 19090, 19068, 19046, 19025, 19003, 18982, 18960, 18939, 18917, 18896, 18875,\n    18854, 18832, 18811, 18790, 18769, 18748, 18727, 18706, 18686, 18665, 18644, 18623, 18603,\n    18582, 18561, 18541, 18520, 18500, 18479, 18459, 18439, 18419, 18398, 18378, 18358, 18338,\n    18318, 18298, 18278, 18258, 18238, 18218, 18199, 18179, 18159, 18139, 18120, 18100, 18081,\n    18061, 18042, 18022, 18003, 17984, 17964, 17945, 17926, 17907, 17888, 17869, 17850, 17831,\n    17812, 17793, 17774, 17755, 17736, 17718, 17699, 17680, 17662, 17643, 17624, 17606, 17587,\n    17569, 17551, 17532, 17514, 17496, 17477, 17459, 17441, 17423, 17405, 17387, 17369, 17351,\n    17333, 17315, 17297, 17279, 17261, 17244, 17226, 17208, 17191, 17173, 17155, 17138, 17120,\n    17103, 17085, 17068, 17051, 17033, 17016, 16999, 16982, 16964, 16947, 16930, 16913, 16896,\n    16879, 16862, 16845, 16828, 16811, 16794, 16778, 16761, 16744, 16727, 16711, 16694, 16677,\n    16661, 16644, 16628, 16611, 16595, 16578, 16562, 16546, 16529, 16513, 16497, 16481, 16464,\n    16448, 16432, 16416, 16400, 16384,\n];\n\n#[cfg(feature = \"test_build\")]\npub fn test_invert_u32_table() {\n    for (i, &x) in INVERT_U32_TABLE.iter().enumerate() {\n        let value = (u32::power_of_2(24) - u32::power_of_2(14) + u32::power_of_2(9))\n            / (u32::power_of_2(9) + u32::exact_from(i));\n        assert_eq!(\n            x, value,\n            \"INVERT_U32_TABLE gives incorrect value, {x}, for index {i}\"\n        );\n    }\n}\n\n// Computes\n// $$\n// f(x) = \\left \\lfloor \\frac{2^{64} - 2^{32}x - 1}{x} \\right \\rfloor =\n//     \\left \\lfloor \\frac{2^{64}-1}{x}-2^{32} \\right \\rfloor.\n// $$\n//\n// The highest bit of `x` must be set.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `invert_limb` from `longlong.h`, FLINT 2.7.1, when `GMP_LIMB_BITS == 32`.\npub_crate_test! {limbs_invert_limb_u32(x: u32) -> u32 {\n    assert!(x.get_highest_bit());\n    let a = INVERT_U32_TABLE[usize::exact_from(x << 1 >> 23)];\n    let b = (a << 4)\n        .wrapping_sub((u64::from(a * a) * u64::from((x >> 11) + 1)).upper_half())\n        .wrapping_sub(1);\n    let mut c = b.wrapping_mul(x >> 1).wrapping_neg();\n    if x.odd() {\n        c.wrapping_sub_assign(b.wrapping_sub(b >> 1));\n    }\n    let d = (b << 15).wrapping_add((u64::from(b) * u64::from(c)).upper_half() >> 1);\n    d.wrapping_sub(\n        (u64::from(d) * u64::from(x))\n            .wrapping_add(u64::from(x))\n            .upper_half()\n            .wrapping_add(x),\n    )\n}}\n\nconst INVERT_U64_TABLE_LOG_SIZE: u64 = 8;\n\nconst INVERT_U64_TABLE_SIZE: usize = 1 << INVERT_U64_TABLE_LOG_SIZE;\n\n// INVERT_U32_TABLE[i] = floor((2^19 - 3*2^8) / (2^8 + i))\nconst INVERT_U64_TABLE: [u64; INVERT_U64_TABLE_SIZE] = [\n    2045, 2037, 2029, 2021, 2013, 2005, 1998, 1990, 1983, 1975, 1968, 1960, 1953, 1946, 1938, 1931,\n    1924, 1917, 1910, 1903, 1896, 1889, 1883, 1876, 1869, 1863, 1856, 1849, 1843, 1836, 1830, 1824,\n    1817, 1811, 1805, 1799, 1792, 1786, 1780, 1774, 1768, 1762, 1756, 1750, 1745, 1739, 1733, 1727,\n    1722, 1716, 1710, 1705, 1699, 1694, 1688, 1683, 1677, 1672, 1667, 1661, 1656, 1651, 1646, 1641,\n    1636, 1630, 1625, 1620, 1615, 1610, 1605, 1600, 1596, 1591, 1586, 1581, 1576, 1572, 1567, 1562,\n    1558, 1553, 1548, 1544, 1539, 1535, 1530, 1526, 1521, 1517, 1513, 1508, 1504, 1500, 1495, 1491,\n    1487, 1483, 1478, 1474, 1470, 1466, 1462, 1458, 1454, 1450, 1446, 1442, 1438, 1434, 1430, 1426,\n    1422, 1418, 1414, 1411, 1407, 1403, 1399, 1396, 1392, 1388, 1384, 1381, 1377, 1374, 1370, 1366,\n    1363, 1359, 1356, 1352, 1349, 1345, 1342, 1338, 1335, 1332, 1328, 1325, 1322, 1318, 1315, 1312,\n    1308, 1305, 1302, 1299, 1295, 1292, 1289, 1286, 1283, 1280, 1276, 1273, 1270, 1267, 1264, 1261,\n    1258, 1255, 1252, 1249, 1246, 1243, 1240, 1237, 1234, 1231, 1228, 1226, 1223, 1220, 1217, 1214,\n    1211, 1209, 1206, 1203, 1200, 1197, 1195, 1192, 1189, 1187, 1184, 1181, 1179, 1176, 1173, 1171,\n    1168, 1165, 1163, 1160, 1158, 1155, 1153, 1150, 1148, 1145, 1143, 1140, 1138, 1135, 1133, 1130,\n    1128, 1125, 1123, 1121, 1118, 1116, 1113, 1111, 1109, 1106, 1104, 1102, 1099, 1097, 1095, 1092,\n    1090, 1088, 1086, 1083, 1081, 1079, 1077, 1074, 1072, 1070, 1068, 1066, 1064, 1061, 1059, 1057,\n    1055, 1053, 1051, 1049, 1047, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024,\n];\n\n/// Tests that `INVERT_U64_TABLE` is correct.\n#[cfg(feature = \"test_build\")]\npub fn test_invert_u64_table() {\n    for (i, &x) in INVERT_U64_TABLE.iter().enumerate() {\n        let value = (u64::power_of_2(19) - 3 * u64::power_of_2(8))\n            / (u64::power_of_2(8) + u64::exact_from(i));\n        assert_eq!(\n            x, value,\n            \"INVERT_U64_TABLE gives incorrect value, {x}, for index {i}\"\n        );\n    }\n}\n\n// Computes\n// $$\n// f(x) = \\left \\lfloor \\frac{2^{128} - 2^{64}x - 1}{x} \\right \\rfloor =\n//     \\left \\lfloor \\frac{2^{128}-1}{x}-2^{64} \\right \\rfloor.\n// $$\n//\n// The highest bit of `x` must be set.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `invert_limb` from `longlong.h`, FLINT 2.7.1, when `GMP_LIMB_BITS == 64`.\npub_crate_test! {limbs_invert_limb_u64(x: u64) -> u64 {\n    assert!(x.get_highest_bit());\n    let a = (x >> 24) + 1;\n    let b = INVERT_U64_TABLE[usize::exact_from(x << 1 >> 56)];\n    let c = (b << 11).wrapping_sub(((b * b).wrapping_mul(a) >> 40) + 1);\n    let d = (c.wrapping_mul(u64::power_of_2(60).wrapping_sub(c.wrapping_mul(a))) >> 47)\n        .wrapping_add(c << 13);\n    let mut e = d.wrapping_mul(x >> 1).wrapping_neg();\n    if x.odd() {\n        e.wrapping_sub_assign(d.wrapping_sub(d >> 1));\n    }\n    let f = (d << 31).wrapping_add((u128::from(d) * u128::from(e)).upper_half() >> 1);\n    f.wrapping_sub(\n        (u128::from(f) * u128::from(x))\n            .wrapping_add(u128::from(x))\n            .upper_half()\n            .wrapping_add(x),\n    )\n}}\n\n// This is equivalent to `n_ll_mod_preinv` from `ulong_extras/ll_mod_preinv.c`, FLINT 2.7.1.\npub_test! {mod_preinverted_double<\n    T: PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    mut x_1: T,\n    x_0: T,\n    d: T,\n    d_inv: T,\n) -> T {\n    assert_ne!(d, T::ZERO);\n    let d_inv = DT::from(d_inv);\n    let shift = LeadingZeros::leading_zeros(d);\n    if shift == 0 {\n        if x_1 >= d {\n            x_1 -= d;\n        }\n        let (q_1, q_0) = (d_inv * DT::from(x_1))\n            .wrapping_add(DT::join_halves(x_1, x_0))\n            .split_in_half();\n        let mut r = x_0.wrapping_sub(q_1.wrapping_add(T::ONE).wrapping_mul(d));\n        if r > q_0 {\n            r.wrapping_add_assign(d);\n        }\n        if r < d {\n            r\n        } else {\n            r - d\n        }\n    } else {\n        let mut d = d;\n        if x_1 >= d {\n            let y_1 = x_1 >> (T::WIDTH - shift);\n            let y_0 = x_1 << shift;\n            d <<= shift;\n            let (q1, q0) = (d_inv * DT::from(y_1))\n                .wrapping_add(DT::join_halves(y_1, y_0))\n                .split_in_half();\n            x_1 = y_0.wrapping_sub(q1.wrapping_add(T::ONE).wrapping_mul(d));\n            if x_1 > q0 {\n                x_1.wrapping_add_assign(d);\n            }\n            if x_1 >= d {\n                x_1 -= d;\n            }\n        } else {\n            d <<= shift;\n            x_1 <<= shift;\n        }\n        let y_1 = x_1.wrapping_add(x_0 >> (T::WIDTH - shift));\n        let y_0 = x_0 << shift;\n        let (q_1, q_0) = (d_inv * DT::from(y_1))\n            .wrapping_add(DT::join_halves(y_1, y_0))\n            .split_in_half();\n        let mut r = y_0.wrapping_sub(q_1.wrapping_add(T::ONE).wrapping_mul(d));\n        if r > q_0 {\n            r.wrapping_add_assign(d);\n        }\n        if r < d {\n            r >> shift\n        } else {\n            (r - d) >> shift\n        }\n    }\n}}\n\n// This is equivalent to `n_mulmod2_preinv` from `ulong_extras.h`, FLINT 2.7.1.\npub_test! {fast_mod_mul<\n    T: PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    x: T,\n    y: T,\n    m: T,\n    inv: T,\n) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    assert!(y < m, \"y must be reduced mod m, but {y} >= {m}\");\n    let (product_1, product_0) = (DT::from(x) * DT::from(y)).split_in_half();\n    mod_preinverted_double::<T, DT>(product_1, product_0, m, inv)\n}}\n\nmacro_rules! impl_mod_mul_precomputed_fast {\n    ($t:ident, $dt:ident, $invert_limb:ident) => {\n        impl ModMulPrecomputed<$t, $t> for $t {\n            type Output = $t;\n            type Data = $t;\n\n            /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n            /// [`mod_mul_precomputed_assign`](super::traits::ModMulPrecomputedAssign).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// This is equivalent to `n_preinvert_limb` from `ulong_extras.h`, FLINT 2.7.1.\n            fn precompute_mod_mul_data(&m: &$t) -> $t {\n                $invert_limb(m << LeadingZeros::leading_zeros(m))\n            }\n\n            /// Multiplies two numbers modulo a third number $m$. The inputs must be already reduced\n            /// modulo $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular multiplications with the same modulus. The precomputed data should be\n            /// obtained using\n            /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_mul#mod_mul_precomputed).\n            ///\n            /// This is equivalent to `n_mulmod2_preinv` from `ulong_extras.h`, FLINT 2.7.1.\n            fn mod_mul_precomputed(self, other: $t, m: $t, data: &$t) -> $t {\n                fast_mod_mul::<$t, $dt>(self, other, m, *data)\n            }\n        }\n    };\n}\nimpl_mod_mul_precomputed_fast!(u32, u64, limbs_invert_limb_u32);\nimpl_mod_mul_precomputed_fast!(u64, u128, limbs_invert_limb_u64);\n\nmacro_rules! impl_mod_mul_precomputed_promoted {\n    ($t:ident) => {\n        impl ModMulPrecomputed<$t, $t> for $t {\n            type Output = $t;\n            type Data = u32;\n\n            /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n            /// [`mod_mul_precomputed_assign`](super::traits::ModMulPrecomputedAssign).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// This is equivalent to `n_preinvert_limb` from `ulong_extras.h`, FLINT 2.7.1.\n            fn precompute_mod_mul_data(&m: &$t) -> u32 {\n                u32::precompute_mod_mul_data(&u32::from(m))\n            }\n\n            /// Multiplies two numbers modulo a third number $m$. The inputs must be already reduced\n            /// modulo $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular multiplications with the same modulus. The precomputed data should be\n            /// obtained using\n            /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_mul#mod_mul_precomputed).\n            ///\n            /// This is equivalent to `n_mulmod2_preinv` from `ulong_extras.h`, FLINT 2.7.1.\n            fn mod_mul_precomputed(self, other: $t, m: $t, data: &u32) -> $t {\n                $t::wrapping_from(u32::from(self).mod_mul_precomputed(\n                    u32::from(other),\n                    u32::from(m),\n                    data,\n                ))\n            }\n        }\n    };\n}\nimpl_mod_mul_precomputed_promoted!(u8);\nimpl_mod_mul_precomputed_promoted!(u16);\n\nimpl ModMulPrecomputed<Self, Self> for u128 {\n    type Output = Self;\n    type Data = ();\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](super::traits::ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    fn precompute_mod_mul_data(_m: &Self) {}\n\n    /// Multiplies two numbers modulo a third number $m$. The inputs must be already reduced modulo\n    /// $m$.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// See [here](super::mod_mul#mod_mul_precomputed).\n    ///\n    /// This is equivalent to `n_mulmod2_preinv` from `ulong_extras.h`, FLINT 2.7.1.\n    #[inline]\n    fn mod_mul_precomputed(self, other: Self, m: Self, _data: &()) -> Self {\n        naive_mod_mul(self, other, m)\n    }\n}\n\nimpl ModMulPrecomputed<Self, Self> for usize {\n    type Output = Self;\n    type Data = Self;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](super::traits::ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to `n_preinvert_limb` from `ulong_extras.h`, FLINT 2.7.1.\n    fn precompute_mod_mul_data(&m: &Self) -> Self {\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::precompute_mod_mul_data(&u32::wrapping_from(m)))\n        } else {\n            Self::wrapping_from(u64::precompute_mod_mul_data(&u64::wrapping_from(m)))\n        }\n    }\n\n    /// Multiplies two numbers modulo a third number $m$. The inputs must be already reduced modulo\n    /// $m$.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// `precompute_mod_mul_data`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// See [here](super::mod_mul#mod_mul_precomputed).\n    ///\n    /// This is equivalent to `n_mulmod2_preinv` from `ulong_extras.h`, FLINT 2.7.1.\n    fn mod_mul_precomputed(self, other: Self, m: Self, data: &Self) -> Self {\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::wrapping_from(self).mod_mul_precomputed(\n                u32::wrapping_from(other),\n                u32::wrapping_from(m),\n                &u32::wrapping_from(*data),\n            ))\n        } else {\n            Self::wrapping_from(u64::wrapping_from(self).mod_mul_precomputed(\n                u64::wrapping_from(other),\n                u64::wrapping_from(m),\n                &u64::wrapping_from(*data),\n            ))\n        }\n    }\n}\n\nmacro_rules! impl_mod_mul {\n    ($t:ident) => {\n        impl ModMulPrecomputedAssign<$t, $t> for $t {\n            /// Multiplies two numbers modulo a third number $m$, in place. The inputs must be\n            /// already reduced modulo $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular multiplications with the same modulus. The precomputed data should be\n            /// obtained using\n            /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_mul#mod_mul_precomputed_assign).\n            ///\n            /// This is equivalent to `n_mulmod2_preinv` from `ulong_extras.h`, FLINT 2.7.1, where\n            /// the return value is assigned to `a`.\n            #[inline]\n            fn mod_mul_precomputed_assign(&mut self, other: $t, m: $t, data: &Self::Data) {\n                *self = self.mod_mul_precomputed(other, m, data);\n            }\n        }\n\n        impl ModMul<$t> for $t {\n            type Output = $t;\n\n            /// Multiplies two numbers modulo a third number $m$. The inputs must be already reduced\n            /// modulo $m$.\n            ///\n            /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_mul#mod_mul).\n            ///\n            /// This is equivalent to `nmod_mul` from `nmod.h`, FLINT 2.7.1.\n            #[inline]\n            fn mod_mul(self, other: $t, m: $t) -> $t {\n                naive_mod_mul(self, other, m)\n            }\n        }\n\n        impl ModMulAssign<$t> for $t {\n            /// Multiplies two numbers modulo a third number $m$, in place. The inputs must be\n            /// already reduced modulo $m$.\n            ///\n            /// $x \\gets z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_mul#mod_mul_assign).\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// This is equivalent to `nmod_mul` from `nmod.h`, FLINT 2.7.1, where the result is\n            /// assigned to `a`.\n            #[inline]\n            fn mod_mul_assign(&mut self, other: $t, m: $t) {\n                *self = naive_mod_mul(*self, other, m);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2010 William Hart\n//\n//      Copyright © 2021 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModNeg, ModNegAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_neg<T: PrimitiveUnsigned>(x: T, m: T) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if x == T::ZERO { T::ZERO } else { m - x }\n}\n\nfn mod_neg_assign<T: PrimitiveUnsigned>(x: &mut T, m: T) {\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if *x != T::ZERO {\n        *x = m - *x;\n    }\n}\n\nmacro_rules! impl_mod_neg {\n    ($t:ident) => {\n        impl ModNeg for $t {\n            type Output = $t;\n\n            /// Negates a number modulo another number $m$, in place. The input must be already\n            /// reduced modulo $m$.\n            ///\n            /// $f(x, m) = y$, where $x, y < m$ and $-x \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_neg#mod_neg).\n            ///\n            /// This is equivalent to `nmod_neg` from `nmod.h`, FLINT 2.7.1.\n            #[inline]\n            fn mod_neg(self, m: $t) -> $t {\n                mod_neg(self, m)\n            }\n        }\n\n        impl ModNegAssign for $t {\n            /// Negates a number modulo another number $m$. The input must be already reduced modulo\n            /// $m$.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $-x \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_neg#mod_neg_assign).\n            ///\n            /// This is equivalent to `nmod_neg` from `nmod.h`, FLINT 2.7.1, where the output is\n            /// assigned to `a`.\n            #[inline]\n            fn mod_neg_assign(&mut self, m: $t) {\n                mod_neg_assign(self, m)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_neg);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    CeilingMod, CeilingModAssign, Mod, ModAssign, NegMod, NegModAssign, UnsignedAbs,\n};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::ExactFrom;\n\nfn neg_mod_unsigned<T: PrimitiveUnsigned>(x: T, other: T) -> T {\n    let remainder = x % other;\n    if remainder == T::ZERO {\n        T::ZERO\n    } else {\n        other - remainder\n    }\n}\n\nfn neg_mod_assign_unsigned<T: PrimitiveUnsigned>(x: &mut T, other: T) {\n    *x %= other;\n    if *x != T::ZERO {\n        *x = other - *x;\n    }\n}\n\nmacro_rules! impl_mod_unsigned {\n    ($t:ident) => {\n        impl Mod<$t> for $t {\n            type Output = $t;\n\n            /// Divides a number by another number, returning just the remainder.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$\n            /// and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n            /// $$\n            ///\n            /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#mod_op).\n            #[inline]\n            fn mod_op(self, other: $t) -> $t {\n                self % other\n            }\n        }\n\n        impl ModAssign<$t> for $t {\n            /// Divides a number by another number, replacing the first number by the remainder.\n            ///\n            /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$\n            /// and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#mod_assign).\n            #[inline]\n            fn mod_assign(&mut self, other: $t) {\n                *self %= other;\n            }\n        }\n\n        impl NegMod<$t> for $t {\n            type Output = $t;\n\n            /// Divides the negative of a number by another number, returning just the remainder.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$\n            /// and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#neg_mod).\n            #[inline]\n            fn neg_mod(self, other: $t) -> $t {\n                neg_mod_unsigned(self, other)\n            }\n        }\n\n        impl NegModAssign<$t> for $t {\n            /// Divides the negative of a number by another number, returning just the remainder.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$\n            /// and $0 \\leq r < y$.\n            ///\n            /// $$\n            /// x \\gets y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#neg_mod_assign).\n            #[inline]\n            fn neg_mod_assign(&mut self, other: $t) {\n                neg_mod_assign_unsigned(self, other);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_unsigned);\n\nfn mod_op_signed<\n    U: PrimitiveUnsigned,\n    S: ExactFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: S,\n    other: S,\n) -> S {\n    let remainder = if (x >= S::ZERO) == (other >= S::ZERO) {\n        x.unsigned_abs() % other.unsigned_abs()\n    } else {\n        x.unsigned_abs().neg_mod(other.unsigned_abs())\n    };\n    if other >= S::ZERO {\n        S::exact_from(remainder)\n    } else {\n        -S::exact_from(remainder)\n    }\n}\n\nfn ceiling_mod_signed<\n    U: PrimitiveUnsigned,\n    S: ExactFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: S,\n    other: S,\n) -> S {\n    let remainder = if (x >= S::ZERO) == (other >= S::ZERO) {\n        x.unsigned_abs().neg_mod(other.unsigned_abs())\n    } else {\n        x.unsigned_abs() % other.unsigned_abs()\n    };\n    if other >= S::ZERO {\n        -S::exact_from(remainder)\n    } else {\n        S::exact_from(remainder)\n    }\n}\n\nmacro_rules! impl_mod_signed {\n    ($t:ident) => {\n        impl Mod<$t> for $t {\n            type Output = $t;\n\n            /// Divides a number by another number, returning just the remainder. The remainder has\n            /// the same sign as the second number.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$\n            /// and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n            /// $$\n            ///\n            /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#mod_op).\n            #[inline]\n            fn mod_op(self, other: $t) -> $t {\n                mod_op_signed(self, other)\n            }\n        }\n\n        impl ModAssign<$t> for $t {\n            /// Divides a number by another number, replacing the first number by the remainder. The\n            /// remainder has the same sign as the second number.\n            ///\n            /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$\n            /// and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#mod_assign).\n            #[inline]\n            fn mod_assign(&mut self, other: $t) {\n                *self = self.mod_op(other);\n            }\n        }\n\n        impl CeilingMod<$t> for $t {\n            type Output = $t;\n\n            /// Divides a number by another number, returning just the remainder. The remainder has\n            /// the opposite sign as the second number.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$\n            /// and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#ceiling_mod).\n            #[inline]\n            fn ceiling_mod(self, other: $t) -> $t {\n                ceiling_mod_signed(self, other)\n            }\n        }\n\n        impl CeilingModAssign<$t> for $t {\n            /// Divides a number by another number, replacing the first number by the remainder. The\n            /// remainder has the opposite sign as the second number.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$\n            /// and $0 \\leq |r| < |y|$.\n            ///\n            /// $$\n            /// x \\gets x - y\\left \\lceil\\frac{x}{y} \\right \\rceil.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `other` is 0.\n            ///\n            /// # Examples\n            /// See [here](super::mod_op#ceiling_mod_assign).\n            #[inline]\n            fn ceiling_mod_assign(&mut self, other: $t) {\n                *self = self.ceiling_mod(other);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_mod_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009, 2010, 2012, 2016 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::mod_mul::{limbs_invert_limb_u32, limbs_invert_limb_u64};\nuse crate::num::arithmetic::traits::{\n    ModPow, ModPowAssign, ModPowPrecomputed, ModPowPrecomputedAssign,\n};\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf};\nuse crate::num::logic::traits::{BitIterable, LeadingZeros};\n\npub_test! {simple_binary_mod_pow<T: PrimitiveUnsigned>(x: T, exp: u64, m: T) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if m == T::ONE {\n        return T::ZERO;\n    }\n    let data = T::precompute_mod_mul_data(&m);\n    let mut out = T::ONE;\n    for bit in exp.bits().rev() {\n        out.mod_mul_precomputed_assign(out, m, &data);\n        if bit {\n            out.mod_mul_precomputed_assign(x, m, &data);\n        }\n    }\n    out\n}}\n\n// m.get_highest_bit(), x < m, y < m\n//\n// This is equivalent to `n_mulmod_preinv` from `ulong_extras/mulmod_preinv.c`, FLINT 2.7.1.\npub(crate) fn mul_mod_helper<\n    T: PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    mut x: T,\n    y: T,\n    m: T,\n    inverse: T,\n    shift: u64,\n) -> T {\n    x >>= shift;\n    let p = DT::from(x) * DT::from(y);\n    let (p_hi, p_lo) = p.split_in_half();\n    let (q_1, q_0) = (DT::from(p_hi) * DT::from(inverse))\n        .wrapping_add(p)\n        .split_in_half();\n    let mut r = p_lo.wrapping_sub(q_1.wrapping_add(T::ONE).wrapping_mul(m));\n    if r > q_0 {\n        r.wrapping_add_assign(m);\n    }\n    if r < m { r } else { r.wrapping_sub(m) }\n}\n\n// m.get_highest_bit(), x < m\n//\n// This is equivalent to `n_powmod_ui_preinv` from ulong_extras/powmod_ui_preinv.c, FLINT 2.7.1.\npub(crate) fn fast_mod_pow<\n    T: PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    mut x: T,\n    exp: u64,\n    m: T,\n    inverse: T,\n    shift: u64,\n) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if exp == 0 {\n        let x = T::power_of_2(shift);\n        if x == m { T::ZERO } else { x }\n    } else if x == T::ZERO {\n        T::ZERO\n    } else {\n        let mut bits = exp.bits();\n        let mut out = if bits.next().unwrap() {\n            x\n        } else {\n            T::power_of_2(shift)\n        };\n        for bit in bits {\n            x = mul_mod_helper::<T, DT>(x, x, m, inverse, shift);\n            if bit {\n                out = mul_mod_helper::<T, DT>(out, x, m, inverse, shift);\n            }\n        }\n        out\n    }\n}\n\nmacro_rules! impl_mod_pow_precomputed_fast {\n    ($t:ident, $dt:ident, $invert_limb:ident) => {\n        impl ModPowPrecomputed<u64, $t> for $t {\n            type Output = $t;\n            type Data = ($t, u64);\n\n            /// Precomputes data for modular exponentiation.\n            ///\n            /// See `mod_pow_precomputed` and\n            /// [`mod_pow_precomputed_assign`](super::traits::ModPowPrecomputedAssign).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            fn precompute_mod_pow_data(&m: &$t) -> ($t, u64) {\n                let leading_zeros = LeadingZeros::leading_zeros(m);\n                ($invert_limb(m << leading_zeros), leading_zeros)\n            }\n\n            /// Raises a number to a power modulo another number $m$. The base must be already\n            /// reduced modulo $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular exponentiations with the same modulus. The precomputed data should be\n            /// obtained using\n            /// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data).\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_pow#mod_pow_precomputed).\n            fn mod_pow_precomputed(self, exp: u64, m: $t, data: &($t, u64)) -> $t {\n                let (inverse, shift) = *data;\n                fast_mod_pow::<$t, $dt>(self << shift, exp, m << shift, inverse, shift) >> shift\n            }\n        }\n    };\n}\nimpl_mod_pow_precomputed_fast!(u32, u64, limbs_invert_limb_u32);\nimpl_mod_pow_precomputed_fast!(u64, u128, limbs_invert_limb_u64);\n\nmacro_rules! impl_mod_pow_precomputed_promoted {\n    ($t:ident) => {\n        impl ModPowPrecomputed<u64, $t> for $t {\n            type Output = $t;\n            type Data = (u32, u64);\n\n            /// Precomputes data for modular exponentiation.\n            ///\n            /// See `mod_pow_precomputed` and\n            /// [`mod_pow_precomputed_assign`](super::traits::ModPowPrecomputedAssign).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            fn precompute_mod_pow_data(&m: &$t) -> (u32, u64) {\n                u32::precompute_mod_pow_data(&u32::from(m))\n            }\n\n            /// Raises a number to a power modulo another number $m$. The base must be already\n            /// reduced modulo $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular exponentiations with the same modulus. The precomputed data should be\n            /// obtained using\n            /// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data).\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_pow#mod_pow_precomputed).\n            fn mod_pow_precomputed(self, exp: u64, m: $t, data: &(u32, u64)) -> $t {\n                $t::wrapping_from(u32::from(self).mod_pow_precomputed(exp, u32::from(m), data))\n            }\n        }\n    };\n}\nimpl_mod_pow_precomputed_promoted!(u8);\nimpl_mod_pow_precomputed_promoted!(u16);\n\nimpl ModPowPrecomputed<u64, Self> for u128 {\n    type Output = Self;\n    type Data = ();\n\n    /// Precomputes data for modular exponentiation.\n    ///\n    /// See `mod_pow_precomputed` and\n    /// [`mod_pow_precomputed_assign`](super::traits::ModPowPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    fn precompute_mod_pow_data(_m: &Self) {}\n\n    /// Raises a number to a power modulo another number $m$. The base must be already reduced\n    /// modulo $m$.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// exponentiations with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// See [here](super::mod_pow#mod_pow_precomputed).\n    #[inline]\n    fn mod_pow_precomputed(self, exp: u64, m: Self, _data: &()) -> Self {\n        simple_binary_mod_pow(self, exp, m)\n    }\n}\n\nimpl ModPowPrecomputed<u64, Self> for usize {\n    type Output = Self;\n    type Data = (Self, u64);\n\n    /// Precomputes data for modular exponentiation.\n    ///\n    /// See `mod_pow_precomputed` and\n    /// [`mod_pow_precomputed_assign`](super::traits::ModPowPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    fn precompute_mod_pow_data(&m: &Self) -> (Self, u64) {\n        if USIZE_IS_U32 {\n            let (inverse, shift) = u32::precompute_mod_pow_data(&u32::wrapping_from(m));\n            (Self::wrapping_from(inverse), shift)\n        } else {\n            let (inverse, shift) = u64::precompute_mod_pow_data(&u64::wrapping_from(m));\n            (Self::wrapping_from(inverse), shift)\n        }\n    }\n\n    /// Raises a number to a power modulo another number $m$. The base must be already reduced\n    /// modulo $m$.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// exponentiations with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// See [here](super::mod_pow#mod_pow_precomputed).\n    fn mod_pow_precomputed(self, exp: u64, m: Self, data: &(Self, u64)) -> Self {\n        let (inverse, shift) = *data;\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::wrapping_from(self).mod_pow_precomputed(\n                exp,\n                u32::wrapping_from(m),\n                &(u32::wrapping_from(inverse), shift),\n            ))\n        } else {\n            Self::wrapping_from(u64::wrapping_from(self).mod_pow_precomputed(\n                exp,\n                u64::wrapping_from(m),\n                &(u64::wrapping_from(inverse), shift),\n            ))\n        }\n    }\n}\n\nmacro_rules! impl_mod_pow {\n    ($t:ident) => {\n        impl ModPowPrecomputedAssign<u64, $t> for $t {\n            /// Raises a number to a power modulo another number $m$, in place. The base must be\n            /// already reduced modulo $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular exponentiations with the same modulus. The precomputed data should be\n            /// obtained using\n            /// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data).\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_pow#mod_pow_precomputed_assign).\n            #[inline]\n            fn mod_pow_precomputed_assign(&mut self, exp: u64, m: $t, data: &Self::Data) {\n                *self = self.mod_pow_precomputed(exp, m, data);\n            }\n        }\n\n        impl ModPow<u64> for $t {\n            type Output = $t;\n\n            /// Raises a number to a power modulo another number $m$. The base must be already\n            /// reduced modulo $m$.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_pow#mod_pow).\n            #[inline]\n            fn mod_pow(self, exp: u64, m: $t) -> $t {\n                simple_binary_mod_pow(self, exp, m)\n            }\n        }\n\n        impl ModPowAssign<u64> for $t {\n            /// Raises a number to a power modulo another number $m$, in place. The base must be\n            /// already reduced modulo $m$.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_pow#mod_pow_assign).\n            #[inline]\n            fn mod_pow_assign(&mut self, exp: u64, m: $t) {\n                *self = simple_binary_mod_pow(*self, exp, m);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_pow);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    CeilingModPowerOf2, CeilingModPowerOf2Assign, ModPowerOf2, ModPowerOf2Assign, NegModPowerOf2,\n    NegModPowerOf2Assign, RemPowerOf2, RemPowerOf2Assign,\n};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse core::fmt::Debug;\n\nconst ERROR_MESSAGE: &str = \"Result exceeds width of output type\";\n\nfn mod_power_of_2_unsigned<T: PrimitiveUnsigned>(x: T, pow: u64) -> T {\n    if x == T::ZERO || pow >= T::WIDTH {\n        x\n    } else {\n        x & T::low_mask(pow)\n    }\n}\n\nfn mod_power_of_2_assign_unsigned<T: PrimitiveUnsigned>(x: &mut T, pow: u64) {\n    if *x != T::ZERO && pow < T::WIDTH {\n        *x &= T::low_mask(pow);\n    }\n}\n\n#[inline]\nfn neg_mod_power_of_2_unsigned<T: PrimitiveUnsigned>(x: T, pow: u64) -> T {\n    assert!(x == T::ZERO || pow <= T::WIDTH, \"{ERROR_MESSAGE}\");\n    x.wrapping_neg().mod_power_of_2(pow)\n}\n\nmacro_rules! impl_mod_power_of_2_unsigned {\n    ($s:ident) => {\n        impl ModPowerOf2 for $s {\n            type Output = $s;\n\n            /// Divides a number by $2^k$, returning just the remainder.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#mod_power_of_2).\n            #[inline]\n            fn mod_power_of_2(self, pow: u64) -> $s {\n                mod_power_of_2_unsigned(self, pow)\n            }\n        }\n\n        impl ModPowerOf2Assign for $s {\n            /// Divides a number by $2^k$, replacing the first number by the remainder.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// x \\gets x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#mod_power_of_2_assign).\n            #[inline]\n            fn mod_power_of_2_assign(&mut self, pow: u64) {\n                mod_power_of_2_assign_unsigned(self, pow);\n            }\n        }\n\n        impl RemPowerOf2 for $s {\n            type Output = $s;\n\n            /// Divides a number by $2^k$, returning just the remainder. For unsigned integers,\n            /// `rem_power_of_2` is equivalent to [`mod_power_of_2`](super::traits::ModPowerOf2).\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#rem_power_of_2).\n            #[inline]\n            fn rem_power_of_2(self, pow: u64) -> $s {\n                self.mod_power_of_2(pow)\n            }\n        }\n\n        impl RemPowerOf2Assign for $s {\n            /// Divides a number by $2^k$, replacing the first number by the remainder. For unsigned\n            /// integers, `rem_power_of_2_assign` is equivalent to\n            /// [`mod_power_of_2_assign`](super::traits::ModPowerOf2Assign).\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// x \\gets x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#rem_power_of_2_assign).\n            #[inline]\n            fn rem_power_of_2_assign(&mut self, pow: u64) {\n                self.mod_power_of_2_assign(pow)\n            }\n        }\n\n        impl NegModPowerOf2 for $s {\n            type Output = $s;\n\n            /// Divides the negative of a number by a $2^k$, returning just the remainder.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k -\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// f(x, k) = 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil - x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is nonzero and `pow` is greater than `Self::WIDTH`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#neg_mod_power_of_2).\n            #[inline]\n            fn neg_mod_power_of_2(self, pow: u64) -> $s {\n                neg_mod_power_of_2_unsigned(self, pow)\n            }\n        }\n\n        impl NegModPowerOf2Assign for $s {\n            /// Divides the negative of a number by $2^k$, returning just the remainder.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k -\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// x \\gets 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil - x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is nonzero and `pow` is greater than `Self::WIDTH`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#neg_mod_power_of_2_assign).\n            #[inline]\n            fn neg_mod_power_of_2_assign(&mut self, pow: u64) {\n                *self = self.neg_mod_power_of_2(pow)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_unsigned);\n\nfn mod_power_of_2_signed<U: PrimitiveUnsigned + WrappingFrom<S>, S: PrimitiveSigned>(\n    x: S,\n    pow: u64,\n) -> U {\n    assert!(x >= S::ZERO || pow <= S::WIDTH, \"{ERROR_MESSAGE}\");\n    U::wrapping_from(x).mod_power_of_2(pow)\n}\n\nfn mod_power_of_2_assign_signed<U, S: TryFrom<U> + ModPowerOf2<Output = U> + PrimitiveSigned>(\n    x: &mut S,\n    pow: u64,\n) where\n    <S as TryFrom<U>>::Error: Debug,\n{\n    *x = S::try_from(x.mod_power_of_2(pow)).expect(ERROR_MESSAGE);\n}\n\nfn rem_power_of_2_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    x: S,\n    pow: u64,\n) -> S {\n    if x >= S::ZERO {\n        S::wrapping_from(U::wrapping_from(x).mod_power_of_2(pow))\n    } else {\n        S::wrapping_from(U::wrapping_from(x.wrapping_neg()).mod_power_of_2(pow)).wrapping_neg()\n    }\n}\n\nfn ceiling_mod_power_of_2_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: TryFrom<U> + PrimitiveSigned,\n>(\n    x: S,\n    pow: u64,\n) -> S\nwhere\n    <S as TryFrom<U>>::Error: Debug,\n{\n    let abs_result = if x >= S::ZERO {\n        U::wrapping_from(x).neg_mod_power_of_2(pow)\n    } else {\n        U::wrapping_from(x.wrapping_neg()).mod_power_of_2(pow)\n    };\n    S::try_from(abs_result)\n        .expect(ERROR_MESSAGE)\n        .checked_neg()\n        .expect(ERROR_MESSAGE)\n}\n\nmacro_rules! impl_mod_power_of_2_signed {\n    ($u:ident, $s:ident) => {\n        impl ModPowerOf2 for $s {\n            type Output = $u;\n\n            /// Divides a number by $2^k$, returning just the remainder. The remainder is\n            /// non-negative.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is negative and `pow` is greater than `Self::WIDTH`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#mod_power_of_2).\n            #[inline]\n            fn mod_power_of_2(self, pow: u64) -> $u {\n                mod_power_of_2_signed(self, pow)\n            }\n        }\n\n        impl ModPowerOf2Assign for $s {\n            /// Divides a number by $2^k$, replacing the first number by the remainder. The\n            /// remainder is non-negative.\n            ///\n            /// If the quotient were computed, he quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// x \\gets x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is negative and `pow` is greater than or equal to `Self::WIDTH`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#mod_power_of_2_assign).\n            #[inline]\n            fn mod_power_of_2_assign(&mut self, pow: u64) {\n                mod_power_of_2_assign_signed(self, pow);\n            }\n        }\n\n        impl RemPowerOf2 for $s {\n            type Output = $s;\n\n            /// Divides a number by $2^k$, returning just the remainder. The remainder has the same\n            /// sign as the first number.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq |r| < 2^k$.\n            ///\n            /// $$\n            /// f(x, k) = x - 2^k\\operatorname{sgn}(x)\\left \\lfloor \\frac{|x|}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#rem_power_of_2).\n            #[inline]\n            fn rem_power_of_2(self, pow: u64) -> $s {\n                rem_power_of_2_signed::<$u, $s>(self, pow)\n            }\n        }\n\n        impl RemPowerOf2Assign for $s {\n            /// Divides a number by $2^k$, replacing the first number by the remainder. The\n            /// remainder has the same sign as the first number.\n            ///\n            /// If the quotient were computed, he quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq r < 2^k$.\n            ///\n            /// $$\n            /// x \\gets x - 2^k\\operatorname{sgn}(x)\\left \\lfloor \\frac{|x|}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#rem_power_of_2_assign).\n            #[inline]\n            fn rem_power_of_2_assign(&mut self, pow: u64) {\n                *self = self.rem_power_of_2(pow)\n            }\n        }\n\n        impl CeilingModPowerOf2 for $s {\n            type Output = $s;\n\n            /// Divides a number by $2^k$, returning just the remainder. The remainder is\n            /// non-positive.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq -r < 2^k$.\n            ///\n            /// $$\n            /// f(x, y) =  x - 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is positive or `Self::MIN`, and `pow` is greater than or equal to\n            /// `Self::WIDTH`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#ceiling_mod_power_of_2).\n            #[inline]\n            fn ceiling_mod_power_of_2(self, pow: u64) -> $s {\n                ceiling_mod_power_of_2_signed::<$u, $s>(self, pow)\n            }\n        }\n\n        impl CeilingModPowerOf2Assign for $s {\n            /// Divides a number by $2^k$, replacing the first number by the remainder. The\n            /// remainder is non-positive.\n            ///\n            /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k +\n            /// r$ and $0 \\leq -r < 2^k$.\n            ///\n            /// $$\n            /// x \\gets x - 2^k\\left \\lceil\\frac{x}{2^k} \\right \\rceil.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is positive or `Self::MIN`, and `pow` is greater than or equal to\n            /// `Self::WIDTH`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2#ceiling_mod_power_of_2_assign).\n            #[inline]\n            fn ceiling_mod_power_of_2_assign(&mut self, pow: u64) {\n                *self = self.ceiling_mod_power_of_2(pow)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_mod_power_of_2_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModPowerOf2Add, ModPowerOf2AddAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_power_of_2_add<T: PrimitiveUnsigned>(x: T, y: T, pow: u64) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    assert!(\n        y.significant_bits() <= pow,\n        \"y must be reduced mod 2^pow, but {y} >= 2^{pow}\"\n    );\n    x.wrapping_add(y).mod_power_of_2(pow)\n}\n\nfn mod_power_of_2_add_assign<T: PrimitiveUnsigned>(x: &mut T, y: T, pow: u64) {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    assert!(\n        y.significant_bits() <= pow,\n        \"y must be reduced mod 2^pow, but {y} >= 2^{pow}\"\n    );\n    x.wrapping_add_assign(y);\n    x.mod_power_of_2_assign(pow);\n}\n\nmacro_rules! impl_mod_power_of_2_add {\n    ($t:ident) => {\n        impl ModPowerOf2Add<$t> for $t {\n            type Output = $t;\n\n            /// Adds two numbers modulo a third number $2^k$. The inputs must be already reduced\n            /// modulo $2^k$.\n            ///\n            /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` or `other` are greater\n            /// than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_add#mod_power_of_2_add).\n            #[inline]\n            fn mod_power_of_2_add(self, other: $t, pow: u64) -> $t {\n                mod_power_of_2_add(self, other, pow)\n            }\n        }\n\n        impl ModPowerOf2AddAssign<$t> for $t {\n            /// Adds two numbers modulo a third number $2^k$, in place. The inputs must be already\n            /// reduced modulo $2^k$.\n            ///\n            /// $x \\gets z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` or `other` are greater\n            /// than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_add#mod_power_of_2_add_assign).\n            #[inline]\n            fn mod_power_of_2_add_assign(&mut self, other: $t, pow: u64) {\n                mod_power_of_2_add_assign(self, other, pow);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_add);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::ModPowerOf2Inverse;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\n// Uses Newton's method, as described by Colin Plumb in\n// https://groups.google.com/g/sci.crypt/c/UI-UMbUnYGk/m/hX2-wQVyE3oJ.\npub_test! {mod_power_of_2_inverse_fast<T: PrimitiveUnsigned>(x: T, pow: u64) -> Option<T> {\n    assert_ne!(x, T::ZERO);\n    assert!(pow <= T::WIDTH);\n    assert!(x.significant_bits() <= pow, \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\");\n    if x.even() {\n        return None;\n    } else if x == T::ONE {\n        return Some(T::ONE);\n    }\n    let mut small_pow = 2;\n    let mut inverse = x.mod_power_of_2(2);\n    while small_pow < pow {\n        small_pow <<= 1;\n        if small_pow > pow {\n            small_pow = pow;\n        }\n        // inverse <- inverse * (2 - inverse * x) mod 2^small_pow\n        inverse.mod_power_of_2_mul_assign(\n            T::TWO.mod_power_of_2_sub(\n                inverse.mod_power_of_2_mul(x.mod_power_of_2(small_pow), small_pow),\n                small_pow,\n            ),\n            small_pow,\n        );\n    }\n    Some(inverse)\n}}\n\nmacro_rules! impl_mod_power_of_2_inverse {\n    ($u:ident) => {\n        impl ModPowerOf2Inverse for $u {\n            type Output = $u;\n\n            /// Computes the multiplicative inverse of a number modulo $2^k$. The input must be\n            /// already reduced modulo $2^k$.\n            ///\n            /// Returns `None` if $x$ is even.\n            ///\n            /// $f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \\equiv 1 \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH`, if `self` is zero, or if `self` is\n            /// greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_inverse#mod_power_of_2_inverse).\n            #[inline]\n            fn mod_power_of_2_inverse(self, pow: u64) -> Option<$u> {\n                mod_power_of_2_inverse_fast(self, pow)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_inverse);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::ModPowerOf2IsReduced;\nuse crate::num::logic::traits::SignificantBits;\n\nmacro_rules! impl_mod_power_of_2_is_reduced {\n    ($t:ident) => {\n        impl ModPowerOf2IsReduced for $t {\n            /// Returns whether a number is reduced modulo another number $2^k$; in other words,\n            /// whether it has no more than $k$ significant bits.\n            ///\n            /// $f(x, k) = (x < 2^k)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_is_reduced#mod_power_of_2_is_reduced).\n            #[inline]\n            fn mod_power_of_2_is_reduced(&self, pow: u64) -> bool {\n                self.significant_bits() <= pow\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_is_reduced);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModPowerOf2Mul, ModPowerOf2MulAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_power_of_2_mul<T: PrimitiveUnsigned>(x: T, y: T, pow: u64) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    assert!(\n        y.significant_bits() <= pow,\n        \"y must be reduced mod 2^pow, but {y} >= 2^{pow}\"\n    );\n    x.wrapping_mul(y).mod_power_of_2(pow)\n}\n\n#[inline]\nfn mod_power_of_2_mul_assign<T: PrimitiveUnsigned>(x: &mut T, y: T, pow: u64) {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    assert!(\n        y.significant_bits() <= pow,\n        \"y must be reduced mod 2^pow, but {y} >= 2^{pow}\"\n    );\n    x.wrapping_mul_assign(y);\n    x.mod_power_of_2_assign(pow);\n}\n\nmacro_rules! impl_mod_power_of_2_mul {\n    ($t:ident) => {\n        impl ModPowerOf2Mul<$t> for $t {\n            type Output = $t;\n\n            /// Multiplies two numbers modulo a third number $2^k$. The inputs must be already\n            /// reduced modulo $2^k$.\n            ///\n            /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $xy \\equiv z \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` or `other` are greater\n            /// than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_mul#mod_power_of_2_mul).\n            #[inline]\n            fn mod_power_of_2_mul(self, other: $t, pow: u64) -> $t {\n                mod_power_of_2_mul(self, other, pow)\n            }\n        }\n\n        impl ModPowerOf2MulAssign<$t> for $t {\n            /// Multiplies two numbers modulo a third number $2^k$, in place. The inputs must be\n            /// already reduced modulo $2^k$.\n            ///\n            /// $x \\gets z$, where $x, y, z < 2^k$ and $xy \\equiv z \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` or `other` are greater\n            /// than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_mul#mod_power_of_2_mul_assign).\n            #[inline]\n            fn mod_power_of_2_mul_assign(&mut self, other: $t, pow: u64) {\n                mod_power_of_2_mul_assign(self, other, pow)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModPowerOf2Neg, ModPowerOf2NegAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_power_of_2_neg<T: PrimitiveUnsigned>(x: T, pow: u64) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    x.wrapping_neg().mod_power_of_2(pow)\n}\n\nfn mod_power_of_2_neg_assign<T: PrimitiveUnsigned>(x: &mut T, pow: u64) {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    x.wrapping_neg_assign();\n    x.mod_power_of_2_assign(pow);\n}\n\nmacro_rules! impl_mod_power_of_2_neg {\n    ($t:ident) => {\n        impl ModPowerOf2Neg for $t {\n            type Output = $t;\n\n            /// Negates a number modulo another number $2^k$. The input must be already reduced\n            /// modulo $2^k$.\n            ///\n            /// $f(x, k) = y$, where $x, y < 2^k$ and $-x \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than or equal\n            /// to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_neg#mod_power_of_2_neg).\n            #[inline]\n            fn mod_power_of_2_neg(self, pow: u64) -> $t {\n                mod_power_of_2_neg(self, pow)\n            }\n        }\n\n        impl ModPowerOf2NegAssign for $t {\n            /// Negates a number modulo another number $2^k$, in place. The input must be already\n            /// reduced modulo $2^k$.\n            ///\n            /// $x \\gets y$, where $x, y < 2^k$ and $-x \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than or equal\n            /// to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_neg#mod_power_of_2_neg_assign).\n            #[inline]\n            fn mod_power_of_2_neg_assign(&mut self, pow: u64) {\n                mod_power_of_2_neg_assign(self, pow);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_neg);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModPowerOf2Pow, ModPowerOf2PowAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::logic::traits::BitIterable;\n\nfn mod_power_of_2_pow<T: PrimitiveUnsigned>(x: T, exp: u64, pow: u64) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    if pow == 0 {\n        return T::ZERO;\n    }\n    let mut out = T::ONE;\n    for bit in exp.bits().rev() {\n        out.mod_power_of_2_mul_assign(out, pow);\n        if bit {\n            out.mod_power_of_2_mul_assign(x, pow);\n        }\n    }\n    out\n}\n\nmacro_rules! impl_mod_power_of_2_pow {\n    ($t:ident) => {\n        impl ModPowerOf2Pow<u64> for $t {\n            type Output = $t;\n\n            /// Raises a number to a power modulo another number $2^k$. The base must be already\n            /// reduced modulo $2^k$.\n            ///\n            /// $f(x, n, k) = y$, where $x, y < 2^k$ and $x^n \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than or equal\n            /// to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_pow#mod_power_of_2_pow).\n            #[inline]\n            fn mod_power_of_2_pow(self, exp: u64, pow: u64) -> $t {\n                mod_power_of_2_pow(self, exp, pow)\n            }\n        }\n\n        impl ModPowerOf2PowAssign<u64> for $t {\n            /// Raises a number to a power modulo another number $2^k$, in place. The base must be\n            /// already reduced modulo $2^k$.\n            ///\n            /// $x \\gets y$, where $x, y < 2^k$ and $x^n \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than or equal\n            /// to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_pow#mod_power_of_2_pow_assign).\n            #[inline]\n            fn mod_power_of_2_pow_assign(&mut self, exp: u64, pow: u64) {\n                *self = self.mod_power_of_2_pow(exp, pow);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_pow);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModPowerOf2Shl, ModPowerOf2ShlAssign, UnsignedAbs};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\n\nfn mod_power_of_2_shl_unsigned<T: PrimitiveUnsigned + Shl<U, Output = T>, U: PrimitiveUnsigned>(\n    x: T,\n    other: U,\n    pow: u64,\n) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    if other >= U::exact_from(T::WIDTH) {\n        T::ZERO\n    } else {\n        (x << other).mod_power_of_2(pow)\n    }\n}\n\nfn mod_power_of_2_shl_assign_unsigned<T: PrimitiveUnsigned + ShlAssign<U>, U: PrimitiveUnsigned>(\n    x: &mut T,\n    other: U,\n    pow: u64,\n) {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    if other >= U::exact_from(T::WIDTH) {\n        *x = T::ZERO;\n    } else {\n        *x <<= other;\n        x.mod_power_of_2_assign(pow);\n    }\n}\n\nmacro_rules! impl_mod_power_of_2_shl_unsigned {\n    ($t:ident) => {\n        macro_rules! impl_mod_power_of_2_shl_unsigned_inner {\n            ($u:ident) => {\n                impl ModPowerOf2Shl<$u> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo $2^k$. The\n                    /// number must be already reduced modulo $2^k$.\n                    ///\n                    /// $f(x, n, k) = y$, where $x, y < 2^k$ and $2^nx \\equiv y \\mod 2^k$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than\n                    /// or equal to $2^k$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl).\n                    #[inline]\n                    fn mod_power_of_2_shl(self, other: $u, pow: u64) -> $t {\n                        mod_power_of_2_shl_unsigned(self, other, pow)\n                    }\n                }\n\n                impl ModPowerOf2ShlAssign<$u> for $t {\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo $2^k$, in place.\n                    /// The number must be already reduced modulo $2^k$.\n                    ///\n                    /// $x \\gets y$, where $x, y < 2^k$ and $2^nx \\equiv y \\mod 2^k$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than\n                    /// or equal to $2^k$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl_assign).\n                    #[inline]\n                    fn mod_power_of_2_shl_assign(&mut self, other: $u, pow: u64) {\n                        mod_power_of_2_shl_assign_unsigned(self, other, pow);\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_mod_power_of_2_shl_unsigned_inner);\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_shl_unsigned);\n\nfn mod_power_of_2_shl_signed<\n    T: ModPowerOf2Shl<U, Output = T> + PrimitiveInt + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    other: S,\n    pow: u64,\n) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        x.mod_power_of_2_shl(other_abs, pow)\n    } else {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            T::ZERO\n        } else {\n            x >> other_abs\n        }\n    }\n}\n\nfn mod_power_of_2_shl_assign_signed<\n    T: ModPowerOf2ShlAssign<U> + PrimitiveInt + ShrAssign<U>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: &mut T,\n    other: S,\n    pow: u64,\n) {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        x.mod_power_of_2_shl_assign(other_abs, pow);\n    } else {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            *x = T::ZERO;\n        } else {\n            *x >>= other_abs;\n        }\n    }\n}\n\nmacro_rules! impl_mod_power_of_2_shl_signed {\n    ($t:ident) => {\n        macro_rules! impl_mod_power_of_2_shl_signed_inner {\n            ($u:ident) => {\n                impl ModPowerOf2Shl<$u> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo $2^k$. The\n                    /// number must be already reduced modulo $2^k$.\n                    ///\n                    /// $f(x, n, k) = y$, where $x, y < 2^k$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod\n                    /// 2^k$.\n                    ///\n                    /// # Panics\n                    /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than\n                    /// or equal to $2^k$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl).\n                    #[inline]\n                    fn mod_power_of_2_shl(self, other: $u, pow: u64) -> $t {\n                        mod_power_of_2_shl_signed(self, other, pow)\n                    }\n                }\n\n                impl ModPowerOf2ShlAssign<$u> for $t {\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo $2^k$, in place.\n                    /// The number must be already reduced modulo $2^k$.\n                    ///\n                    /// $x \\gets y$, where $x, y < 2^k$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod\n                    /// 2^k$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than\n                    /// or equal to $2^k$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl_assign).\n                    #[inline]\n                    fn mod_power_of_2_shl_assign(&mut self, other: $u, pow: u64) {\n                        mod_power_of_2_shl_assign_signed(self, other, pow);\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_mod_power_of_2_shl_signed_inner);\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_shl_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    ModPowerOf2Shl, ModPowerOf2ShlAssign, ModPowerOf2Shr, ModPowerOf2ShrAssign, UnsignedAbs,\n};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse core::ops::{Shr, ShrAssign};\n\nfn mod_power_of_2_shr_signed<\n    T: ModPowerOf2Shl<U, Output = T> + PrimitiveInt + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    other: S,\n    pow: u64,\n) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            T::ZERO\n        } else {\n            x >> other_abs\n        }\n    } else {\n        x.mod_power_of_2_shl(other_abs, pow)\n    }\n}\n\nfn mod_power_of_2_shr_assign_signed<\n    T: ModPowerOf2ShlAssign<U> + PrimitiveInt + ShrAssign<U>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: &mut T,\n    other: S,\n    pow: u64,\n) {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            *x = T::ZERO;\n        } else {\n            *x >>= other_abs;\n        }\n    } else {\n        x.mod_power_of_2_shl_assign(other_abs, pow);\n    }\n}\n\nmacro_rules! impl_mod_power_of_2_shr_signed {\n    ($t:ident) => {\n        macro_rules! impl_mod_power_of_2_shr_signed_inner {\n            ($u:ident) => {\n                impl ModPowerOf2Shr<$u> for $t {\n                    type Output = $t;\n\n                    /// Right-shifts a number (divides it by a power of 2) modulo $2^k$. The number\n                    /// must be already reduced modulo $2^k$.\n                    ///\n                    /// $f(x, n, k) = y$, where $x, y < 2^k$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y\n                    /// \\mod 2^k$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than\n                    /// or equal to $2^k$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_power_of_2_shr#mod_power_of_2_shr).\n                    #[inline]\n                    fn mod_power_of_2_shr(self, other: $u, pow: u64) -> $t {\n                        mod_power_of_2_shr_signed(self, other, pow)\n                    }\n                }\n\n                impl ModPowerOf2ShrAssign<$u> for $t {\n                    /// Right-shifts a number (divides it by a power of 2) modulo $2^k$, in place.\n                    /// The number must be already reduced modulo $2^k$.\n                    ///\n                    /// $x \\gets y$, where $x, y < 2^k$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod\n                    /// 2^k$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than\n                    /// or equal to $2^k$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_power_of_2_shr#mod_power_of_2_shr_assign).\n                    #[inline]\n                    fn mod_power_of_2_shr_assign(&mut self, other: $u, pow: u64) {\n                        mod_power_of_2_shr_assign_signed(self, other, pow)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_mod_power_of_2_shr_signed_inner);\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_shr_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    ModPowerOf2Mul, ModPowerOf2MulAssign, ModPowerOf2Square, ModPowerOf2SquareAssign,\n};\n\nmacro_rules! impl_mod_power_of_2_square {\n    ($t:ident) => {\n        impl ModPowerOf2Square for $t {\n            type Output = $t;\n\n            /// Squares a number modulo another number $2^k$. The input must be already reduced\n            /// modulo $2^k$.\n            ///\n            /// $f(x, k) = y$, where $x, y < 2^k$ and $x^2 \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than or equal\n            /// to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_square#mod_power_of_2_square).\n            #[inline]\n            fn mod_power_of_2_square(self, pow: u64) -> $t {\n                self.mod_power_of_2_mul(self, pow)\n            }\n        }\n\n        impl ModPowerOf2SquareAssign for $t {\n            /// Squares a number modulo another number $2^k$, in place. The input must be already\n            /// reduced modulo $2^k$.\n            ///\n            /// $x \\gets y$, where $x, y < 2^k$ and $x^2 \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` is greater than or equal\n            /// to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_square#mod_power_of_2_square_assign).\n            #[inline]\n            fn mod_power_of_2_square_assign(&mut self, pow: u64) {\n                self.mod_power_of_2_mul_assign(*self, pow);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_square);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_power_of_2_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModPowerOf2Sub, ModPowerOf2SubAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_power_of_2_sub<T: PrimitiveUnsigned>(x: T, y: T, pow: u64) -> T {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    assert!(\n        y.significant_bits() <= pow,\n        \"y must be reduced mod 2^pow, but {y} >= 2^{pow}\"\n    );\n    x.wrapping_sub(y).mod_power_of_2(pow)\n}\n\nfn mod_power_of_2_sub_assign<T: PrimitiveUnsigned>(x: &mut T, y: T, pow: u64) {\n    assert!(pow <= T::WIDTH);\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    assert!(\n        y.significant_bits() <= pow,\n        \"y must be reduced mod 2^pow, but {y} >= 2^{pow}\"\n    );\n    x.wrapping_sub_assign(y);\n    x.mod_power_of_2_assign(pow);\n}\n\nmacro_rules! impl_mod_power_of_2_sub {\n    ($t:ident) => {\n        impl ModPowerOf2Sub<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts two numbers modulo a third number $2^k$. The inputs must be already\n            /// reduced modulo $2^k$.\n            ///\n            /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` or `other` are greater\n            /// than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_sub#mod_power_of_2_sub).\n            #[inline]\n            fn mod_power_of_2_sub(self, other: $t, pow: u64) -> $t {\n                mod_power_of_2_sub(self, other, pow)\n            }\n        }\n\n        impl ModPowerOf2SubAssign<$t> for $t {\n            /// Subtracts two numbers modulo a third number $2^k$, in place. The inputs must be\n            /// already reduced modulo $2^k$.\n            ///\n            /// $x \\gets z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `pow` is greater than `Self::WIDTH` or if `self` or `other` are greater\n            /// than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_sub#mod_power_of_2_sub_assign).\n            #[inline]\n            fn mod_power_of_2_sub_assign(&mut self, other: $t, pow: u64) {\n                mod_power_of_2_sub_assign(self, other, pow);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_sub);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModShl, ModShlAssign, UnsignedAbs};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::ExactFrom;\nuse core::ops::{Shr, ShrAssign};\n\nfn mod_shl_unsigned<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(x: T, other: U, m: T) -> T\nwhere\n    u64: ExactFrom<U>,\n{\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if other == U::ZERO {\n        x\n    } else if m == T::ONE || m == T::TWO {\n        T::ZERO\n    } else {\n        x.mod_mul(T::TWO.mod_pow(u64::exact_from(other), m), m)\n    }\n}\n\nfn mod_shl_assign_unsigned<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(x: &mut T, other: U, m: T)\nwhere\n    u64: ExactFrom<U>,\n{\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if other == U::ZERO {\n    } else if m == T::ONE || m == T::TWO {\n        *x = T::ZERO;\n    } else {\n        x.mod_mul_assign(T::TWO.mod_pow(u64::exact_from(other), m), m);\n    }\n}\n\nmacro_rules! impl_mod_shl_unsigned {\n    ($t:ident) => {\n        macro_rules! impl_mod_shl_unsigned_inner {\n            ($u:ident) => {\n                impl ModShl<$u, $t> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo a number $m$.\n                    /// The number must be already reduced modulo $m$.\n                    ///\n                    /// $f(x, n, m) = y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `other.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `self` is greater than or equal to `m`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_shl#mod_shl).\n                    #[inline]\n                    fn mod_shl(self, other: $u, m: $t) -> $t {\n                        mod_shl_unsigned(self, other, m)\n                    }\n                }\n\n                impl ModShlAssign<$u, $t> for $t {\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo a number $m$, in\n                    /// place. The number must be already reduced modulo $m$.\n                    ///\n                    /// $x \\gets y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `other.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `self` is greater than or equal to `m`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_shl#mod_shl_assign).\n                    #[inline]\n                    fn mod_shl_assign(&mut self, other: $u, m: $t) {\n                        mod_shl_assign_unsigned(self, other, m);\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_mod_shl_unsigned_inner);\n    };\n}\napply_to_unsigneds!(impl_mod_shl_unsigned);\n\nfn mod_shl_signed<\n    T: ModShl<U, T, Output = T> + PrimitiveInt + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    other: S,\n    m: T,\n) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        x.mod_shl(other_abs, m)\n    } else {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            T::ZERO\n        } else {\n            x >> other_abs\n        }\n    }\n}\n\nfn mod_shl_assign_signed<\n    T: ModShlAssign<U, T> + PrimitiveUnsigned + ShrAssign<U>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: &mut T,\n    other: S,\n    m: T,\n) {\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        x.mod_shl_assign(other_abs, m);\n    } else {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            *x = T::ZERO;\n        } else {\n            *x >>= other_abs;\n        }\n    }\n}\n\nmacro_rules! impl_mod_shl_signed {\n    ($t:ident) => {\n        macro_rules! impl_mod_shl_signed_inner {\n            ($u:ident) => {\n                impl ModShl<$u, $t> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo a number $m$.\n                    /// The number must be already reduced modulo $m$.\n                    ///\n                    /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod\n                    /// m$.\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `other.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `self` is greater than or equal to `m`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_shl#mod_shl).\n                    #[inline]\n                    fn mod_shl(self, other: $u, m: $t) -> $t {\n                        mod_shl_signed(self, other, m)\n                    }\n                }\n\n                impl ModShlAssign<$u, $t> for $t {\n                    /// Left-shifts a number (multiplies it by a power of 2) modulo a number $m$, in\n                    /// place. The number must be already reduced modulo $m$.\n                    ///\n                    /// $x \\gets y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod m$.\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `other.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `self` is greater than or equal to `m`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_shl#mod_shl_assign).\n                    #[inline]\n                    fn mod_shl_assign(&mut self, other: $u, m: $t) {\n                        mod_shl_assign_signed(self, other, m);\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_mod_shl_signed_inner);\n    };\n}\napply_to_unsigneds!(impl_mod_shl_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModShl, ModShlAssign, ModShr, ModShrAssign, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse core::ops::{Shr, ShrAssign};\n\nfn mod_shr_signed<\n    T: ModShl<U, T, Output = T> + PrimitiveUnsigned + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    other: S,\n    m: T,\n) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            T::ZERO\n        } else {\n            x >> other_abs\n        }\n    } else {\n        x.mod_shl(other_abs, m)\n    }\n}\n\nfn mod_shr_assign_signed<\n    T: ModShlAssign<U, T> + PrimitiveUnsigned + ShrAssign<U>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: &mut T,\n    other: S,\n    m: T,\n) {\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let other_abs = other.unsigned_abs();\n    if other >= S::ZERO {\n        let width = U::wrapping_from(T::WIDTH);\n        if width != U::ZERO && other_abs >= width {\n            *x = T::ZERO;\n        } else {\n            *x >>= other_abs;\n        }\n    } else {\n        x.mod_shl_assign(other_abs, m);\n    }\n}\n\nmacro_rules! impl_mod_shr_signed {\n    ($t:ident) => {\n        macro_rules! impl_mod_shr_signed_inner {\n            ($u:ident) => {\n                impl ModShr<$u, $t> for $t {\n                    type Output = $t;\n\n                    /// Right-shifts a number (divides it by a power of 2) modulo a number $m$. The\n                    /// number must be already reduced modulo $m$.\n                    ///\n                    /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y\n                    /// \\mod m$.\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `other.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `self` is greater than or equal to `m`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_shr#mod_shr).\n                    #[inline]\n                    fn mod_shr(self, other: $u, m: $t) -> $t {\n                        mod_shr_signed(self, other, m)\n                    }\n                }\n\n                impl ModShrAssign<$u, $t> for $t {\n                    /// Right-shifts a number (divides it by a power of 2) modulo a number $m$, in\n                    /// place. The number must be already reduced modulo $m$.\n                    ///\n                    /// $x \\gets y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod m$.\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `other.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `self` is greater than or equal to `m`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mod_shr#mod_shr).\n                    #[inline]\n                    fn mod_shr_assign(&mut self, other: $u, m: $t) {\n                        mod_shr_assign_signed(self, other, m)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_mod_shr_signed_inner);\n    };\n}\napply_to_unsigneds!(impl_mod_shr_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    ModPow, ModPowAssign, ModPowPrecomputed, ModPowPrecomputedAssign, ModSquare, ModSquareAssign,\n    ModSquarePrecomputed, ModSquarePrecomputedAssign,\n};\n\nmacro_rules! impl_mod_square {\n    ($t:ident) => {\n        impl ModSquare for $t {\n            type Output = $t;\n\n            /// Squares a number modulo another number $m$. The input must be already reduced modulo\n            /// $m$.\n            ///\n            /// $f(x, m) = y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_square#mod_square).\n            #[inline]\n            fn mod_square(self, m: $t) -> $t {\n                self.mod_pow(2, m)\n            }\n        }\n\n        impl ModSquareAssign for $t {\n            /// Squares a number modulo another number $m$, in place. The input must be already\n            /// reduced modulo $m$.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_square#mod_square_assign).\n            #[inline]\n            fn mod_square_assign(&mut self, m: $t) {\n                self.mod_pow_assign(2, m);\n            }\n        }\n\n        impl ModSquarePrecomputed<u64, $t> for $t {\n            /// Squares a number modulo another number $m$. The input must be already reduced modulo\n            /// $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular squarings with the same modulus. The precomputed data should be obtained\n            /// using [`precompute_mod_pow_data`](super::traits::ModPowPrecomputed).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_square#mod_square_precomputed).\n            #[inline]\n            fn mod_square_precomputed(self, m: $t, data: &Self::Data) -> Self::Output {\n                self.mod_pow_precomputed(2, m, data)\n            }\n        }\n\n        impl ModSquarePrecomputedAssign<u64, $t> for $t {\n            /// Squares a number modulo another number $m$, in place. The input must be already\n            /// reduced modulo $m$.\n            ///\n            /// Some precomputed data is provided; this speeds up computations involving several\n            /// modular squarings with the same modulus. The precomputed data should be obtained\n            /// using [`precompute_mod_pow_data`](super::traits::ModPowPrecomputed).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_square#mod_square_precomputed_assign).\n            #[inline]\n            fn mod_square_precomputed_assign(&mut self, m: $t, data: &Self::Data) {\n                self.mod_pow_precomputed_assign(2, m, data);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_square);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/mod_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2010 William Hart\n//\n//      Copyright © 2021 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModSub, ModSubAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_sub<T: PrimitiveUnsigned>(x: T, y: T, m: T) -> T {\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    assert!(y < m, \"y must be reduced mod m, but {y} >= {m}\");\n    let diff = x.wrapping_sub(y);\n    if x < y { m.wrapping_add(diff) } else { diff }\n}\n\nmacro_rules! impl_mod_sub {\n    ($t:ident) => {\n        impl ModSub<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts two numbers modulo a third number $m$. The inputs must be already reduced\n            /// modulo $m$.\n            ///\n            /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_sub#mod_sub).\n            ///\n            /// This is equivalent to `nmod_sub` from `nmod.h`, FLINT 2.7.1.\n            #[inline]\n            fn mod_sub(self, other: $t, m: $t) -> $t {\n                mod_sub(self, other, m)\n            }\n        }\n\n        impl ModSubAssign<$t> for $t {\n            /// Subtracts two numbers modulo a third number $m$, in place. The inputs must be\n            /// already reduced modulo $m$.\n            ///\n            /// $x \\gets z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` or `other` are greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_sub#mod_sub_assign).\n            ///\n            /// This is equivalent to `nmod_sub` from `nmod.h`, FLINT 2.7.1, where the result is\n            /// assigned to `a`.\n            #[inline]\n            fn mod_sub_assign(&mut self, other: $t, m: $t) {\n                *self = self.mod_sub(other, m);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_sub);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::NegAssign;\n\nmacro_rules! impl_neg_signed {\n    ($t:ident) => {\n        impl NegAssign for $t {\n            /// Negates a number in place.\n            ///\n            /// Assumes that the negative can be represented.\n            ///\n            /// $x \\gets -x$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::neg#neg_assign).\n            #[inline]\n            fn neg_assign(&mut self) {\n                *self = -*self;\n            }\n        }\n    };\n}\napply_to_signeds!(impl_neg_signed);\n\nmacro_rules! impl_neg_float {\n    ($t:ident) => {\n        impl NegAssign for $t {\n            /// Negates a number in place.\n            ///\n            /// Assumes that the negative can be represented.\n            ///\n            /// $x \\gets -x$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::neg#neg_assign).\n            #[inline]\n            fn neg_assign(&mut self) {\n                *self = -*self;\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_neg_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{NextPowerOf2, NextPowerOf2Assign, PowerOf2, Sign};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::conversion::traits::SciMantissaAndExponent;\nuse core::cmp::Ordering::*;\n\nmacro_rules! impl_next_power_of_2_unsigned {\n    ($t:ident) => {\n        impl NextPowerOf2 for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `next_power_of_two` functions in the standard library,\n            /// for example [this one](u32::next_power_of_two).\n            #[inline]\n            fn next_power_of_2(self) -> $t {\n                $t::next_power_of_two(self)\n            }\n        }\n\n        impl NextPowerOf2Assign for $t {\n            /// Replaces a number with the smallest power of 2 greater than or equal to it.\n            ///\n            /// $x \\gets 2^{\\lceil \\log_2 x \\rceil}$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the next power of 2 is greater than the type's maximum value.\n            ///\n            /// # Examples\n            /// See [here](super::next_power_of_2#next_power_of_2_assign).\n            #[inline]\n            fn next_power_of_2_assign(&mut self) {\n                *self = $t::next_power_of_2(*self);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_next_power_of_2_unsigned);\n\nmacro_rules! impl_next_power_of_2_primitive_float {\n    ($t:ident) => {\n        impl NextPowerOf2 for $t {\n            type Output = $t;\n\n            /// Finds the smallest power of 2 greater than or equal to a number.\n            ///\n            /// $x \\gets 2^{\\lceil \\log_2 x \\rceil}$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` has a negative sign (positive zero is allowed, but negative zero is\n            /// not), or if the next power of 2 is greater than the type's maximum value.\n            ///\n            /// # Examples\n            /// See [here](super::next_power_of_2#next_power_of_2).\n            #[inline]\n            fn next_power_of_2(self) -> $t {\n                assert_eq!(self.sign(), Greater);\n                assert!(self.is_finite());\n                if self == 0.0 {\n                    return $t::MIN_POSITIVE_SUBNORMAL;\n                }\n                let (mantissa, exponent) = self.sci_mantissa_and_exponent();\n                if mantissa == 1.0 {\n                    self\n                } else if exponent == $t::MAX_EXPONENT {\n                    panic!(\"Next power of 2 is too large to represent\");\n                } else {\n                    $t::power_of_2(exponent + 1)\n                }\n            }\n        }\n\n        impl NextPowerOf2Assign for $t {\n            /// Replaces a number with the smallest power of 2 greater than or equal to it.\n            ///\n            /// $x \\gets 2^{\\lceil \\log_2 x \\rceil}$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the next power of 2 is greater than the type's maximum value.\n            ///\n            /// # Examples\n            /// See [here](super::next_power_of_2#next_power_of_2_assign).\n            #[inline]\n            fn next_power_of_2_assign(&mut self) {\n                *self = $t::next_power_of_2(*self);\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_next_power_of_2_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{OverflowingAbs, OverflowingAbsAssign};\n\nmacro_rules! impl_overflowing_abs {\n    ($t:ident) => {\n        impl OverflowingAbs for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_abs` functions in the standard library, for\n            /// example [this one](i32::overflowing_abs).\n            #[inline]\n            fn overflowing_abs(self) -> ($t, bool) {\n                $t::overflowing_abs(self)\n            }\n        }\n\n        impl OverflowingAbsAssign for $t {\n            /// Replaces a number with its absolute value.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_abs#overflowing_abs_assign).\n            #[inline]\n            fn overflowing_abs_assign(&mut self) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_abs();\n                overflow\n            }\n        }\n    };\n}\napply_to_signeds!(impl_overflowing_abs);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{OverflowingAdd, OverflowingAddAssign};\n\nmacro_rules! impl_overflowing_add {\n    ($t:ident) => {\n        impl OverflowingAdd<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_add` functions in the standard library, for\n            /// example [this one](u32::overflowing_add).\n            #[inline]\n            fn overflowing_add(self, other: $t) -> ($t, bool) {\n                $t::overflowing_add(self, other)\n            }\n        }\n\n        impl OverflowingAddAssign<$t> for $t {\n            /// Adds a number to another number, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_add#overflowing_add_assign).\n            #[inline]\n            fn overflowing_add_assign(&mut self, other: $t) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_add(other);\n                overflow\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_overflowing_add);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    OverflowingAddAssign, OverflowingAddMul, OverflowingAddMulAssign, UnsignedAbs,\n};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn overflowing_add_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> (T, bool) {\n    let (product, overflow_1) = y.overflowing_mul(z);\n    let (result, overflow_2) = x.overflowing_add(product);\n    (result, overflow_1 | overflow_2)\n}\n\nmacro_rules! impl_overflowing_add_mul_unsigned {\n    ($t:ident) => {\n        impl OverflowingAddMul<$t> for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers.\n            ///\n            /// Returns a tuple containing the result and a boolean indicating whether an arithmetic\n            /// overflow occurred. If an overflow occurred, then the wrapped value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_add_mul#overflowing_add_mul).\n            #[inline]\n            fn overflowing_add_mul(self, y: $t, z: $t) -> ($t, bool) {\n                overflowing_add_mul_unsigned(self, y, z)\n            }\n        }\n\n        impl OverflowingAddMulAssign<$t> for $t {\n            /// Adds a number and the product of two other numbers, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_add_mul#overflowing_add_mul_assign).\n            #[inline]\n            fn overflowing_add_mul_assign(&mut self, y: $t, z: $t) -> bool {\n                let (product, overflow) = y.overflowing_mul(z);\n                self.overflowing_add_assign(product) | overflow\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_overflowing_add_mul_unsigned);\n\nfn overflowing_add_mul_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: S,\n    y: S,\n    z: S,\n) -> (S, bool) {\n    if y == S::ZERO || z == S::ZERO {\n        return (x, false);\n    }\n    let x_sign = x >= S::ZERO;\n    if x_sign == ((y >= S::ZERO) == (z >= S::ZERO)) {\n        let (product, overflow_1) = y.overflowing_mul(z);\n        let (result, overflow_2) = x.overflowing_add(product);\n        (result, overflow_1 | overflow_2)\n    } else {\n        let result = x.wrapping_add(y.wrapping_mul(z));\n        let overflow = {\n            let x = x.unsigned_abs();\n            match y.unsigned_abs().checked_mul(z.unsigned_abs()) {\n                Some(product) => {\n                    x < product\n                        && if x_sign {\n                            !x.wrapping_sub(product).get_highest_bit()\n                        } else {\n                            product.wrapping_sub(x).get_highest_bit()\n                        }\n                }\n                None => true,\n            }\n        };\n        (result, overflow)\n    }\n}\n\nmacro_rules! impl_overflowing_add_mul_signed {\n    ($t:ident) => {\n        impl OverflowingAddMul<$t> for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers.\n            ///\n            /// Returns a tuple containing the result and a boolean indicating whether an arithmetic\n            /// overflow occurred. If an overflow occurred, then the wrapped value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_add_mul#overflowing_add_mul).\n            #[inline]\n            fn overflowing_add_mul(self, y: $t, z: $t) -> ($t, bool) {\n                overflowing_add_mul_signed(self, y, z)\n            }\n        }\n\n        impl OverflowingAddMulAssign<$t> for $t {\n            /// Adds a number and the product of two other numbers, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_add_mul#overflowing_add_mul_assign).\n            #[inline]\n            fn overflowing_add_mul_assign(&mut self, y: $t, z: $t) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_add_mul(y, z);\n                overflow\n            }\n        }\n    };\n}\napply_to_signeds!(impl_overflowing_add_mul_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{OverflowingDiv, OverflowingDivAssign};\n\nmacro_rules! impl_overflowing_div {\n    ($t:ident) => {\n        impl OverflowingDiv<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_div` functions in the standard library, for\n            /// example [this one](u32::overflowing_div).\n            #[inline]\n            fn overflowing_div(self, other: $t) -> ($t, bool) {\n                $t::overflowing_div(self, other)\n            }\n        }\n\n        impl OverflowingDivAssign<$t> for $t {\n            /// Divides a number by another number, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned. Overflow only occurs when `Self` is\n            /// signed, `self` is `Self::MIN`, and `other` is -1. The \"actual\" result, `-Self::MIN`,\n            /// can't be represented and is wrapped back to `Self::MIN`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_div#overflowing_div_assign).\n            #[inline]\n            fn overflowing_div_assign(&mut self, other: $t) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_div(other);\n                overflow\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_overflowing_div);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{OverflowingMul, OverflowingMulAssign};\n\nmacro_rules! impl_overflowing_mul {\n    ($t:ident) => {\n        impl OverflowingMul<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_mul` functions in the standard library, for\n            /// example [this one](u32::overflowing_mul).\n            #[inline]\n            fn overflowing_mul(self, other: $t) -> ($t, bool) {\n                $t::overflowing_mul(self, other)\n            }\n        }\n\n        impl OverflowingMulAssign<$t> for $t {\n            /// Multiplies a number by another number, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_mul#overflowing_mul_assign).\n            #[inline]\n            fn overflowing_mul_assign(&mut self, other: $t) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_mul(other);\n                overflow\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_overflowing_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{OverflowingNeg, OverflowingNegAssign};\n\nmacro_rules! impl_overflowing_neg {\n    ($t:ident) => {\n        impl OverflowingNeg for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_neg` functions in the standard library, for\n            /// example [this one](u32::overflowing_neg).\n            #[inline]\n            fn overflowing_neg(self) -> ($t, bool) {\n                $t::overflowing_neg(self)\n            }\n        }\n\n        impl OverflowingNegAssign for $t {\n            /// Negates a number in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_neg#overflowing_neg_assign).\n            #[inline]\n            fn overflowing_neg_assign(&mut self) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_neg();\n                overflow\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_overflowing_neg);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{OverflowingPow, OverflowingPowAssign, Parity, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::OverflowingFrom;\nuse crate::num::logic::traits::BitIterable;\n\nfn overflowing_pow_unsigned<T: PrimitiveUnsigned>(x: T, exp: u64) -> (T, bool) {\n    if exp == 0 {\n        (T::ONE, false)\n    } else if x < T::TWO {\n        (x, false)\n    } else {\n        let (mut power, mut overflow) = (x, false);\n        for bit in exp.bits().rev().skip(1) {\n            overflow |= power.overflowing_square_assign();\n            if bit {\n                overflow |= power.overflowing_mul_assign(x);\n            }\n        }\n        (power, overflow)\n    }\n}\n\nfn overflowing_unsigned_to_signed_neg<\n    U: PrimitiveUnsigned,\n    S: OverflowingFrom<U> + PrimitiveSigned,\n>(\n    x: U,\n) -> (S, bool) {\n    let (signed_x, overflow) = S::overflowing_from(x);\n    if signed_x == S::MIN {\n        (signed_x, false)\n    } else {\n        (signed_x.wrapping_neg(), overflow)\n    }\n}\n\nfn overflowing_pow_signed<\n    U: PrimitiveUnsigned,\n    S: OverflowingFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: S,\n    exp: u64,\n) -> (S, bool) {\n    let (p_abs, overflow) = OverflowingPow::overflowing_pow(x.unsigned_abs(), exp);\n    let (p, overflow_2) = if x >= S::ZERO || exp.even() {\n        S::overflowing_from(p_abs)\n    } else {\n        overflowing_unsigned_to_signed_neg(p_abs)\n    };\n    (p, overflow || overflow_2)\n}\n\nmacro_rules! impl_overflowing_pow_unsigned {\n    ($t:ident) => {\n        impl OverflowingPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_pow` functions in the standard library, for\n            /// example [this one](u32::overflowing_pow).\n            #[inline]\n            fn overflowing_pow(self, exp: u64) -> ($t, bool) {\n                overflowing_pow_unsigned(self, exp)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_overflowing_pow_unsigned);\n\nmacro_rules! impl_overflowing_pow_signed {\n    ($t:ident) => {\n        impl OverflowingPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_pow` functions in the standard library, for\n            /// example [this one](i32::overflowing_pow).\n            #[inline]\n            fn overflowing_pow(self, exp: u64) -> ($t, bool) {\n                overflowing_pow_signed(self, exp)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_overflowing_pow_signed);\n\nmacro_rules! impl_overflowing_pow_primitive_int {\n    ($t:ident) => {\n        impl OverflowingPowAssign<u64> for $t {\n            /// Raises a number to a power, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_pow#overflowing_pow_assign).\n            #[inline]\n            fn overflowing_pow_assign(&mut self, exp: u64) -> bool {\n                let overflow;\n                (*self, overflow) = OverflowingPow::overflowing_pow(*self, exp);\n                overflow\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_overflowing_pow_primitive_int);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    OverflowingMulAssign, OverflowingSquare, OverflowingSquareAssign,\n};\n\nmacro_rules! impl_overflowing_square {\n    ($t:ident) => {\n        impl OverflowingSquare for $t {\n            type Output = $t;\n\n            /// Squares a number.\n            ///\n            /// Returns a tuple containing the result and a boolean indicating whether an arithmetic\n            /// occurred. If an overflow occurred, then the wrapped value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_square#overflowing_square).\n            #[inline]\n            fn overflowing_square(self) -> ($t, bool) {\n                self.overflowing_mul(self)\n            }\n        }\n\n        impl OverflowingSquareAssign for $t {\n            /// Squares a number in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_square#overflowing_square_assign).\n            #[inline]\n            fn overflowing_square_assign(&mut self) -> bool {\n                self.overflowing_mul_assign(*self)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_overflowing_square);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{OverflowingSub, OverflowingSubAssign};\n\nmacro_rules! impl_overflowing_sub {\n    ($t:ident) => {\n        impl OverflowingSub<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `overflowing_sub` functions in the standard library, for\n            /// example [this one](u32::overflowing_sub).\n            #[inline]\n            fn overflowing_sub(self, other: $t) -> ($t, bool) {\n                $t::overflowing_sub(self, other)\n            }\n        }\n\n        impl OverflowingSubAssign<$t> for $t {\n            /// Subtracts a number by another number, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow\n            /// occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_sub#overflowing_sub_assign).\n            #[inline]\n            fn overflowing_sub_assign(&mut self, other: $t) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_sub(other);\n                overflow\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_overflowing_sub);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/overflowing_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    OverflowingSubAssign, OverflowingSubMul, OverflowingSubMulAssign, UnsignedAbs,\n};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn overflowing_sub_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> (T, bool) {\n    let (product, overflow_1) = y.overflowing_mul(z);\n    let (result, overflow_2) = x.overflowing_sub(product);\n    (result, overflow_1 | overflow_2)\n}\n\nmacro_rules! impl_overflowing_sub_mul_unsigned {\n    ($t:ident) => {\n        impl OverflowingSubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers.\n            ///\n            /// Returns a tuple containing the result and a boolean indicating whether an arithmetic\n            /// overflow would occur. If an overflow would have occurred, then the wrapped value is\n            /// returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_sub_mul#overflowing_sub_mul).\n            #[inline]\n            fn overflowing_sub_mul(self, y: $t, z: $t) -> ($t, bool) {\n                overflowing_sub_mul_unsigned(self, y, z)\n            }\n        }\n\n        impl OverflowingSubMulAssign<$t> for $t {\n            /// Subtracts a number by the product of two other numbers, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow would occur. If an\n            /// overflow would have occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_sub_mul#overflowing_sub_mul_assign).\n            #[inline]\n            fn overflowing_sub_mul_assign(&mut self, y: $t, z: $t) -> bool {\n                let (product, overflow) = y.overflowing_mul(z);\n                self.overflowing_sub_assign(product) | overflow\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_overflowing_sub_mul_unsigned);\n\nfn overflowing_sub_mul<U: PrimitiveUnsigned, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: S,\n    y: S,\n    z: S,\n) -> (S, bool) {\n    if y == S::ZERO || z == S::ZERO {\n        return (x, false);\n    }\n    let x_sign = x >= S::ZERO;\n    if x_sign == ((y >= S::ZERO) != (z >= S::ZERO)) {\n        let (product, overflow_1) = y.overflowing_mul(z);\n        let (result, overflow_2) = x.overflowing_sub(product);\n        (result, overflow_1 | overflow_2)\n    } else {\n        let result = x.wrapping_sub(y.wrapping_mul(z));\n        let overflow = {\n            let x = x.unsigned_abs();\n            match y.unsigned_abs().checked_mul(z.unsigned_abs()) {\n                Some(product) => {\n                    x < product\n                        && if x_sign {\n                            !x.wrapping_sub(product).get_highest_bit()\n                        } else {\n                            product.wrapping_sub(x).get_highest_bit()\n                        }\n                }\n                None => true,\n            }\n        };\n        (result, overflow)\n    }\n}\n\nmacro_rules! impl_overflowing_sub_mul_signed {\n    ($t:ident) => {\n        impl OverflowingSubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers.\n            ///\n            /// Returns a tuple containing the result and a boolean indicating whether an arithmetic\n            /// overflow occurred. If an overflow occurred, then the wrapped value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_sub_mul#overflowing_sub_mul).\n            #[inline]\n            fn overflowing_sub_mul(self, y: $t, z: $t) -> ($t, bool) {\n                overflowing_sub_mul(self, y, z)\n            }\n        }\n\n        impl OverflowingSubMulAssign<$t> for $t {\n            /// Subtracts a number by the product of two other numbers, in place.\n            ///\n            /// Returns a boolean indicating whether an arithmetic overflow would occur. If an\n            /// overflow would have occurred, then the wrapped value is assigned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::overflowing_sub_mul#overflowing_sub_mul_assign).\n            #[inline]\n            fn overflowing_sub_mul_assign(&mut self, y: $t, z: $t) -> bool {\n                let overflow;\n                (*self, overflow) = self.overflowing_sub_mul(y, z);\n                overflow\n            }\n        }\n    };\n}\napply_to_signeds!(impl_overflowing_sub_mul_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::Parity;\n\nmacro_rules! impl_parity {\n    ($t:ident) => {\n        impl Parity for $t {\n            /// Tests whether a number is even.\n            ///\n            /// $f(x) = (2|x)$.\n            ///\n            /// $f(x) = (\\exists k \\in \\N \\ x = 2k)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::parity#even).\n            #[inline]\n            fn even(self) -> bool {\n                (self & 1) == 0\n            }\n\n            /// Tests whether a number is odd.\n            ///\n            /// $f(x) = (2\\nmid x)$.\n            ///\n            /// $f(x) = (\\exists k \\in \\N \\ x = 2k+1)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::parity#odd).\n            #[inline]\n            fn odd(self) -> bool {\n                (self & 1) != 0\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_parity);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Parity, Pow, PowAssign};\nuse crate::num::conversion::traits::ExactFrom;\n\nmacro_rules! impl_pow_unsigned {\n    ($t:ident) => {\n        impl Pow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `pow` functions in the standard library, for example\n            /// [this one](u32::pow).\n            #[inline]\n            fn pow(self, exp: u64) -> $t {\n                if exp == 0 {\n                    1\n                } else if self < 2 {\n                    self\n                } else {\n                    self.pow(u32::exact_from(exp))\n                }\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_pow_unsigned);\n\nmacro_rules! impl_pow_signed {\n    ($t:ident) => {\n        impl Pow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `pow` functions in the standard library, for example\n            /// [this one](i32::pow).\n            #[inline]\n            fn pow(self, exp: u64) -> $t {\n                if exp == 0 {\n                    1\n                } else if self == 0 || self == 1 {\n                    self\n                } else if self == -1 {\n                    if exp.even() { 1 } else { -1 }\n                } else {\n                    self.pow(u32::exact_from(exp))\n                }\n            }\n        }\n    };\n}\napply_to_signeds!(impl_pow_signed);\n\nmacro_rules! impl_pow_primitive_int {\n    ($t:ident) => {\n        impl PowAssign<u64> for $t {\n            /// Raises a number to a power, in place.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `exp.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::pow#pow_assign).\n            #[inline]\n            fn pow_assign(&mut self, exp: u64) {\n                *self = Pow::pow(*self, exp);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_pow_primitive_int);\n\nmacro_rules! impl_pow_primitive_float {\n    ($t:ident) => {\n        impl Pow<i64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `powi` functions in the standard library, for example\n            /// [this one](f32::powi).\n            #[inline]\n            fn pow(self, exp: i64) -> $t {\n                libm::Libm::<$t>::pow(self, exp as $t)\n            }\n        }\n\n        impl PowAssign<i64> for $t {\n            /// Raises a number to a power, in place.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::pow#pow_assign).\n            #[inline]\n            fn pow_assign(&mut self, exp: i64) {\n                *self = libm::Libm::<$t>::pow(*self, exp as $t);\n            }\n        }\n\n        impl Pow<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `powf` functions in the standard library, for example\n            /// [this one](f32::powf).\n            #[inline]\n            fn pow(self, exp: $t) -> $t {\n                libm::Libm::<$t>::pow(self, exp)\n            }\n        }\n\n        impl PowAssign<$t> for $t {\n            /// Raises a number to a power, in place.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::pow#pow_assign).\n            #[inline]\n            fn pow_assign(&mut self, exp: $t) {\n                *self = libm::Libm::<$t>::pow(*self, exp);\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_pow_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::PowerOf2;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{IntegerMantissaAndExponent, SaturatingFrom};\n\nfn power_of_2_unsigned<T: PrimitiveUnsigned>(pow: u64) -> T {\n    assert!(pow < T::WIDTH);\n    T::ONE << pow\n}\n\nmacro_rules! impl_power_of_2_unsigned {\n    ($t:ident) => {\n        impl PowerOf2<u64> for $t {\n            /// Raises 2 to an integer power.\n            ///\n            /// $f(k) = 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the result is not representable.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2#power_of_2).\n            #[inline]\n            fn power_of_2(pow: u64) -> $t {\n                power_of_2_unsigned(pow)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_power_of_2_unsigned);\n\nfn power_of_2_signed<T: PrimitiveSigned>(pow: u64) -> T {\n    assert!(pow < T::WIDTH - 1);\n    T::ONE << pow\n}\n\nmacro_rules! impl_power_of_2_signed {\n    ($t:ident) => {\n        impl PowerOf2<u64> for $t {\n            /// Raises 2 to an integer power.\n            ///\n            /// $f(k) = 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the result is not representable.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2#power_of_2).\n            #[inline]\n            fn power_of_2(pow: u64) -> $t {\n                power_of_2_signed(pow)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_power_of_2_signed);\n\nmacro_rules! impl_power_of_2_primitive_float {\n    ($t:ident) => {\n        impl PowerOf2<u64> for $t {\n            /// Raises 2 to an integer power.\n            ///\n            /// $f(k) = 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the power is greater than `Self::MAX_EXPONENT`.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2#power_of_2).\n            #[inline]\n            fn power_of_2(pow: u64) -> $t {\n                $t::from_integer_mantissa_and_exponent(1, i64::saturating_from(pow)).unwrap()\n            }\n        }\n\n        impl PowerOf2<i64> for $t {\n            /// Raises 2 to an integer power.\n            ///\n            /// $f(k) = 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the power is smaller than `Self::MIN_EXPONENT` or greater than\n            /// `Self::MAX_EXPONENT`.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2#power_of_2).\n            #[inline]\n            fn power_of_2(pow: i64) -> $t {\n                $t::from_integer_mantissa_and_exponent(1, pow).unwrap()\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_power_of_2_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedPrimorial, Primorial};\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::conversion::traits::WrappingFrom;\n\nconst PRIMORIALS_U8: [u8; 5] = [1, 2, 6, 30, 210];\nconst PRIMORIALS_U16: [u16; 7] = [1, 2, 6, 30, 210, 2310, 30030];\nconst PRIMORIALS_U32: [u32; 10] = [1, 2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870];\nconst PRIMORIALS_U64: [u64; 16] = [\n    1,\n    2,\n    6,\n    30,\n    210,\n    2310,\n    30030,\n    510510,\n    9699690,\n    223092870,\n    6469693230,\n    200560490130,\n    7420738134810,\n    304250263527210,\n    13082761331670030,\n    614889782588491410,\n];\nconst PRIMORIALS_U128: [u128; 27] = [\n    1,\n    2,\n    6,\n    30,\n    210,\n    2310,\n    30030,\n    510510,\n    9699690,\n    223092870,\n    6469693230,\n    200560490130,\n    7420738134810,\n    304250263527210,\n    13082761331670030,\n    614889782588491410,\n    32589158477190044730,\n    1922760350154212639070,\n    117288381359406970983270,\n    7858321551080267055879090,\n    557940830126698960967415390,\n    40729680599249024150621323470,\n    3217644767340672907899084554130,\n    267064515689275851355624017992790,\n    23768741896345550770650537601358310,\n    2305567963945518424753102147331756070,\n    232862364358497360900063316880507363070,\n];\n\nconst PRIMORIAL_PRIMES_U8: [u64; 5] = [2, 3, 5, 7, 11];\n\nconst PRIMORIAL_PRIMES_U16: [u64; 7] = [2, 3, 5, 7, 11, 13, 17];\n\nconst PRIMORIAL_PRIMES_U32: [u64; 10] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29];\n\nconst PRIMORIAL_PRIMES_U64: [u64; 16] =\n    [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53];\n\nconst PRIMORIAL_PRIMES_U128: [u64; 27] = [\n    2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,\n    101, 103,\n];\n\nmacro_rules! impl_primorials_a {\n    ($t:ident, $ps:ident, $pps:ident) => {\n        impl CheckedPrimorial for $t {\n            /// Computes the primorial of a number: the product of all primes less than or equal to\n            /// it.\n            ///\n            /// The\n            /// [`checked_product_of_first_n_primes`](CheckedPrimorial::checked_product_of_first_n_primes)\n            /// function is similar; it computes the primorial of the $n$th prime.\n            ///\n            /// If the input is too large, the function returns `None`.\n            ///\n            /// $$\n            /// f(n) = \\\\begin{cases}\n            ///     \\operatorname{Some}(n\\\\#) & \\text{if} \\\\quad n\\\\# < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad n\\\\# \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primorial#checked_primorial).\n            #[inline]\n            fn checked_primorial(n: u64) -> Option<$t> {\n                let i = match $pps.binary_search(&n) {\n                    Ok(i) => i + 1,\n                    Err(i) => i,\n                };\n                $ps.get(i).copied()\n            }\n\n            /// Computes the product of the first $n$ primes.\n            ///\n            /// The [`checked_primorial`](CheckedPrimorial::checked_primorial) function is similar;\n            /// it computes the product of all primes less than or equal to $n$.\n            ///\n            /// If the input is too large, the function returns `None`.\n            ///\n            /// $$\n            /// f(n) = \\\\begin{cases}\n            ///     \\operatorname{Some}(p_n\\\\#) & \\text{if} \\\\quad p_n\\\\# < 2^W, \\\\\\\\\n            ///     \\operatorname{None} & \\text{if} \\\\quad p_n\\\\# \\geq 2^W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primorial#checked_product_of_first_n_primes).\n            #[inline]\n            fn checked_product_of_first_n_primes(n: u64) -> Option<$t> {\n                $ps.get(usize::try_from(n).ok()?).copied()\n            }\n        }\n    };\n}\nimpl_primorials_a!(u8, PRIMORIALS_U8, PRIMORIAL_PRIMES_U8);\nimpl_primorials_a!(u16, PRIMORIALS_U16, PRIMORIAL_PRIMES_U16);\nimpl_primorials_a!(u32, PRIMORIALS_U32, PRIMORIAL_PRIMES_U32);\nimpl_primorials_a!(u64, PRIMORIALS_U64, PRIMORIAL_PRIMES_U64);\nimpl_primorials_a!(u128, PRIMORIALS_U128, PRIMORIAL_PRIMES_U128);\n\nimpl CheckedPrimorial for usize {\n    /// Computes the primorial of a [`usize`]: the product of all primes less than or equal to it.\n    ///\n    /// The\n    /// [`checked_product_of_first_n_primes`](CheckedPrimorial::checked_product_of_first_n_primes)\n    /// function is similar; it computes the primorial of the $n$th prime.\n    ///\n    /// If the input is too large, the function returns `None`.\n    ///\n    /// $$\n    /// f(n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(n\\\\#) & \\text{if} \\\\quad n\\\\# < 2^W, \\\\\\\\\n    ///     \\operatorname{None} & \\text{if} \\\\quad n\\\\# \\geq 2^W,\n    /// \\\\end{cases}\n    /// $$\n    /// where $W$ is `usize::WIDTH`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::primorial#checked_primorial).\n    #[inline]\n    fn checked_primorial(n: u64) -> Option<Self> {\n        if USIZE_IS_U32 {\n            u32::checked_primorial(n).map(Self::wrapping_from)\n        } else {\n            u64::checked_primorial(n).map(Self::wrapping_from)\n        }\n    }\n\n    /// Computes the product of the first $n$ primes.\n    ///\n    /// The [`checked_primorial`](CheckedPrimorial::checked_primorial) function is similar; it\n    /// computes the product of all primes less than or equal to $n$.\n    ///\n    /// If the input is too large, the function returns `None`.\n    ///\n    /// $$\n    /// f(n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(p_n\\\\#) & \\text{if} \\\\quad p_n\\\\# < 2^W, \\\\\\\\\n    ///     \\operatorname{None} & \\text{if} \\\\quad p_n\\\\# \\geq 2^W,\n    /// \\\\end{cases}\n    /// $$\n    /// where $W$ is `usize::WIDTH`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::primorial#checked_product_of_first_n_primes).\n    #[inline]\n    fn checked_product_of_first_n_primes(n: u64) -> Option<Self> {\n        if USIZE_IS_U32 {\n            u32::checked_product_of_first_n_primes(n).map(Self::wrapping_from)\n        } else {\n            u64::checked_product_of_first_n_primes(n).map(Self::wrapping_from)\n        }\n    }\n}\n\nmacro_rules! impl_primorials_b {\n    ($t:ident) => {\n        impl Primorial for $t {\n            /// Computes the primorial of a number: the product of all primes less than or equal to\n            /// it.\n            ///\n            /// The [`product_of_first_n_primes`](Primorial::product_of_first_n_primes) function is\n            /// similar; it computes the primorial of the $n$th prime.\n            ///\n            /// If the input is too large, the function panics. For a function that returns `None`\n            /// instead, try [`checked_primorial`](CheckedPrimorial::checked_primorial).\n            ///\n            /// $$\n            /// f(n) = n\\\\# = \\prod_{p \\leq n \\atop p \\\\ \\\\text {prime}} p.\n            /// $$\n            ///\n            /// $n\\\\# = O(e^{(1+o(1))n})$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the output is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::primorial#primorial).\n            #[inline]\n            fn primorial(n: u64) -> $t {\n                $t::checked_primorial(n).unwrap()\n            }\n\n            /// Computes the product of the first $n$ primes.\n            ///\n            /// The [`primorial`](Primorial::primorial) function is similar; it computes the product\n            /// of all primes less than or equal to $n$.\n            ///\n            /// If the input is too large, the function panics. For a function that returns `None`\n            /// instead, try\n            /// [`checked_product_of_first_n_primes`](CheckedPrimorial::checked_product_of_first_n_primes).\n            ///\n            /// $$\n            /// f(n) = p_n\\\\# = \\prod_{k=1}^n p_n,\n            /// $$\n            /// where $p_n$ is the $n$th prime number.\n            ///\n            /// $p_n\\\\# = O\\left ( \\left ( \\frac{1}{e}k\\log k\\left ( \\frac{\\log k}{e^2}k \\right\n            /// )^{1/\\log k} \\right )^k \\omega(1)\\right )$.\n            ///\n            /// This asymptotic approximation is due to [Bart\n            /// Michels](https://math.stackexchange.com/a/1594930).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the output is too large to be represented.\n            ///\n            /// # Examples\n            /// See [here](super::primorial#product_of_first_n_primes).\n            #[inline]\n            fn product_of_first_n_primes(n: u64) -> $t {\n                $t::checked_product_of_first_n_primes(n).unwrap()\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_primorials_b);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Reciprocal, ReciprocalAssign};\n\nmacro_rules! impl_reciprocal {\n    ($t:ident) => {\n        impl Reciprocal for $t {\n            type Output = $t;\n\n            /// Takes the reciprocal of a floating-point number.\n            ///\n            /// $$\n            /// f(x) = 1/x+\\varepsilon.\n            /// $$\n            /// Let $p$ be the precision of the input float (typically 24 for `f32`s and 53 for\n            /// `f64`s, unless the float is subnormal).\n            /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to\n            ///   be 0.\n            /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n            ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p+1}$.\n            /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| <\n            ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n            ///\n            /// If the output has a precision, it is `prec`.\n            ///\n            /// Special cases:\n            /// - $f(\\text{NaN})=\\text{NaN}$\n            /// - $f(\\infty)=0.0$\n            /// - $f(-\\infty)=-0.0$\n            /// - $f(0.0)=\\infty$\n            /// - $f(-0.0)=-\\infty$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::reciprocal#reciprocal).\n            #[inline]\n            fn reciprocal(self) -> $t {\n                1.0 / self\n            }\n        }\n\n        impl ReciprocalAssign for $t {\n            /// Takes the reciprocal of a floating-point number, in place.\n            ///\n            /// $x \\gets 1/x+\\varepsilon$. Let $p$ be the precision of the input float (typically 24\n            /// for `f32`s and 53 for `f64`s, unless the float is subnormal).\n            /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to\n            ///   be 0.\n            /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n            ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p+1}$.\n            /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| <\n            ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n            ///\n            /// See the `reciprocal` documentation for information on special cases.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::reciprocal#reciprocal_assign).\n            #[inline]\n            fn reciprocal_assign(&mut self) {\n                *self = 1.0 / *self;\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_reciprocal);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2015 William Hart\n//\n//      Copyright © 2015 Fredrik Johansson\n//\n//      Copyright © 2015 Kushagra Singh\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(feature = \"test_build\")]\nuse crate::num::arithmetic::sqrt::floor_inverse_checked_binary;\n#[cfg(feature = \"test_build\")]\nuse crate::num::arithmetic::traits::DivRound;\nuse crate::num::arithmetic::traits::{\n    CeilingRoot, CeilingRootAssign, CeilingSqrt, CheckedRoot, CheckedSqrt, DivMod, FloorRoot,\n    FloorRootAssign, FloorSqrt, Parity, Pow, PowerOf2, RootAssignRem, RootRem, SqrtRem, XMulYToZZ,\n};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{\n    RawMantissaAndExponent, RoundingFrom, SaturatingFrom, WrappingFrom,\n};\nuse crate::num::logic::traits::{LowMask, SignificantBits};\nuse crate::rounding_modes::RoundingMode::*;\nuse core::cmp::Ordering::*;\n\nconst U8_CUBES: [u8; 7] = [0, 1, 8, 27, 64, 125, 216];\n\n// This section is created by max_base.rs.\nconst MAX_BASE_8: [u8; 8] = [0, 255, 15, 6, 3, 3, 2, 2];\n\nconst MAX_POWER_8: [u8; 8] = [0, 255, 225, 216, 81, 243, 64, 128];\n\nconst MAX_BASE_16: [u16; 16] = [0, 65535, 255, 40, 15, 9, 6, 4, 3, 3, 3, 2, 2, 2, 2, 2];\n\nconst MAX_POWER_16: [u16; 16] = [\n    0, 65535, 65025, 64000, 50625, 59049, 46656, 16384, 6561, 19683, 59049, 2048, 4096, 8192,\n    16384, 32768,\n];\n\nconst MAX_BASE_32: [u32; 32] = [\n    0, 4294967295, 65535, 1625, 255, 84, 40, 23, 15, 11, 9, 7, 6, 5, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2,\n    2, 2, 2, 2, 2, 2, 2, 2,\n];\n\nconst MAX_POWER_32: [u32; 32] = [\n    0, 4294967295, 4294836225, 4291015625, 4228250625, 4182119424, 4096000000, 3404825447,\n    2562890625, 2357947691, 3486784401, 1977326743, 2176782336, 1220703125, 268435456, 1073741824,\n    43046721, 129140163, 387420489, 1162261467, 3486784401, 2097152, 4194304, 8388608, 16777216,\n    33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648,\n];\n\nconst MAX_BASE_64: [u64; 64] = [\n    0,\n    18446744073709551615,\n    4294967295,\n    2642245,\n    65535,\n    7131,\n    1625,\n    565,\n    255,\n    138,\n    84,\n    56,\n    40,\n    30,\n    23,\n    19,\n    15,\n    13,\n    11,\n    10,\n    9,\n    8,\n    7,\n    6,\n    6,\n    5,\n    5,\n    5,\n    4,\n    4,\n    4,\n    4,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n];\n\nconst MAX_POWER_64: [u64; 64] = [\n    0,\n    18446744073709551615,\n    18446744065119617025,\n    18446724184312856125,\n    18445618199572250625,\n    18439629140666724651,\n    18412815093994140625,\n    18379730316001328125,\n    17878103347812890625,\n    18151468971815029248,\n    17490122876598091776,\n    16985107389382393856,\n    16777216000000000000,\n    15943230000000000000,\n    11592836324538749809,\n    15181127029874798299,\n    6568408355712890625,\n    8650415919381337933,\n    5559917313492231481,\n    10000000000000000000,\n    12157665459056928801,\n    9223372036854775808,\n    3909821048582988049,\n    789730223053602816,\n    4738381338321616896,\n    298023223876953125,\n    1490116119384765625,\n    7450580596923828125,\n    72057594037927936,\n    288230376151711744,\n    1152921504606846976,\n    4611686018427387904,\n    1853020188851841,\n    5559060566555523,\n    16677181699666569,\n    50031545098999707,\n    150094635296999121,\n    450283905890997363,\n    1350851717672992089,\n    4052555153018976267,\n    12157665459056928801,\n    2199023255552,\n    4398046511104,\n    8796093022208,\n    17592186044416,\n    35184372088832,\n    70368744177664,\n    140737488355328,\n    281474976710656,\n    562949953421312,\n    1125899906842624,\n    2251799813685248,\n    4503599627370496,\n    9007199254740992,\n    18014398509481984,\n    36028797018963968,\n    72057594037927936,\n    144115188075855872,\n    288230376151711744,\n    576460752303423488,\n    1152921504606846976,\n    2305843009213693952,\n    4611686018427387904,\n    9223372036854775808,\n];\n\nconst MAX_BASE_128: [u128; 128] = [\n    0,\n    340282366920938463463374607431768211455,\n    18446744073709551615,\n    6981463658331,\n    4294967295,\n    50859008,\n    2642245,\n    319557,\n    65535,\n    19112,\n    7131,\n    3183,\n    1625,\n    920,\n    565,\n    370,\n    255,\n    184,\n    138,\n    106,\n    84,\n    68,\n    56,\n    47,\n    40,\n    34,\n    30,\n    26,\n    23,\n    21,\n    19,\n    17,\n    15,\n    14,\n    13,\n    12,\n    11,\n    11,\n    10,\n    9,\n    9,\n    8,\n    8,\n    7,\n    7,\n    7,\n    6,\n    6,\n    6,\n    6,\n    5,\n    5,\n    5,\n    5,\n    5,\n    5,\n    4,\n    4,\n    4,\n    4,\n    4,\n    4,\n    4,\n    4,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    3,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n    2,\n];\n\nconst MAX_POWER_128: [u128; 128] = [\n    0,\n    340282366920938463463374607431768211455,\n    340282366920938463426481119284349108225,\n    340282366920856711588743492508790678691,\n    340282366604025813516997721482669850625,\n    340282351457171161640582485552312352768,\n    340281633132112807150397932954950015625,\n    340281506971235808117106851925354131693,\n    340240830764391036687105719527812890625,\n    340216388952569572744243119867142602752,\n    340019922845325450206316382040251071801,\n    339784078391451014674643196649809097167,\n    339031759685618453659117221832275390625,\n    338253076642491662461829120000000000000,\n    337814486488938281014651876763916015625,\n    333446267951815307088493000000000000000,\n    319626579315078487616775634918212890625,\n    317616452802997733092688724349413228544,\n    329475825834763755052723200291095445504,\n    302559950208758936970093677790372560896,\n    305904398238499908683087849324518834176,\n    303869538891536196286006028740295917568,\n    288493873028852398739253829029106548736,\n    287243845682065590744605010781602099023,\n    281474976710656000000000000000000000000,\n    193630125104980427932766033374162714624,\n    254186582832900000000000000000000000000,\n    160059109085386090080713531498405298176,\n    134393854047545109686936775588697536481,\n    220983347100817338120002444455525554981,\n    230466617897195215045509519405933293401,\n    139288917338851014461418017489467720433,\n    43143988327398919500410556793212890625,\n    66408730383449729837806206197059026944,\n    74829695578286078013428929473144712489,\n    59066822915424320448445358917464096768,\n    30912680532870672635673352936887453361,\n    340039485861577398992406882305761986971,\n    100000000000000000000000000000000000000,\n    16423203268260658146231467800709255289,\n    147808829414345923316083210206383297601,\n    10633823966279326983230456482242756608,\n    85070591730234615865843651857942052864,\n    2183814375991796599109312252753832343,\n    15286700631942576193765185769276826401,\n    107006904423598033356356300384937784807,\n    623673825204293256669089197883129856,\n    3742042951225759540014535187298779136,\n    22452257707354557240087211123792674816,\n    134713546244127343440523266742756048896,\n    88817841970012523233890533447265625,\n    444089209850062616169452667236328125,\n    2220446049250313080847263336181640625,\n    11102230246251565404236316680908203125,\n    55511151231257827021181583404541015625,\n    277555756156289135105907917022705078125,\n    5192296858534827628530496329220096,\n    20769187434139310514121985316880384,\n    83076749736557242056487941267521536,\n    332306998946228968225951765070086144,\n    1329227995784915872903807060280344576,\n    5316911983139663491615228241121378304,\n    21267647932558653966460912964485513216,\n    85070591730234615865843651857942052864,\n    3433683820292512484657849089281,\n    10301051460877537453973547267843,\n    30903154382632612361920641803529,\n    92709463147897837085761925410587,\n    278128389443693511257285776231761,\n    834385168331080533771857328695283,\n    2503155504993241601315571986085849,\n    7509466514979724803946715958257547,\n    22528399544939174411840147874772641,\n    67585198634817523235520443624317923,\n    202755595904452569706561330872953769,\n    608266787713357709119683992618861307,\n    1824800363140073127359051977856583921,\n    5474401089420219382077155933569751763,\n    16423203268260658146231467800709255289,\n    49269609804781974438694403402127765867,\n    147808829414345923316083210206383297601,\n    2417851639229258349412352,\n    4835703278458516698824704,\n    9671406556917033397649408,\n    19342813113834066795298816,\n    38685626227668133590597632,\n    77371252455336267181195264,\n    154742504910672534362390528,\n    309485009821345068724781056,\n    618970019642690137449562112,\n    1237940039285380274899124224,\n    2475880078570760549798248448,\n    4951760157141521099596496896,\n    9903520314283042199192993792,\n    19807040628566084398385987584,\n    39614081257132168796771975168,\n    79228162514264337593543950336,\n    158456325028528675187087900672,\n    316912650057057350374175801344,\n    633825300114114700748351602688,\n    1267650600228229401496703205376,\n    2535301200456458802993406410752,\n    5070602400912917605986812821504,\n    10141204801825835211973625643008,\n    20282409603651670423947251286016,\n    40564819207303340847894502572032,\n    81129638414606681695789005144064,\n    162259276829213363391578010288128,\n    324518553658426726783156020576256,\n    649037107316853453566312041152512,\n    1298074214633706907132624082305024,\n    2596148429267413814265248164610048,\n    5192296858534827628530496329220096,\n    10384593717069655257060992658440192,\n    20769187434139310514121985316880384,\n    41538374868278621028243970633760768,\n    83076749736557242056487941267521536,\n    166153499473114484112975882535043072,\n    332306998946228968225951765070086144,\n    664613997892457936451903530140172288,\n    1329227995784915872903807060280344576,\n    2658455991569831745807614120560689152,\n    5316911983139663491615228241121378304,\n    10633823966279326983230456482242756608,\n    21267647932558653966460912964485513216,\n    42535295865117307932921825928971026432,\n    85070591730234615865843651857942052864,\n    170141183460469231731687303715884105728,\n];\n\npub_test! {floor_root_approx_and_refine<T: PrimitiveUnsigned, F: Fn(T) -> f64, G: Fn(f64) -> T>(\n    f: F,\n    g: G,\n    x: T,\n    exp: u64,\n) -> T {\n    assert_ne!(exp, 0);\n    if x == T::ZERO || exp == 1 {\n        return x;\n    }\n    if exp >= T::WIDTH {\n        return T::ONE;\n    }\n    let exp_usize = usize::wrapping_from(exp);\n    let max_root = match T::WIDTH {\n        u8::WIDTH => T::wrapping_from(MAX_BASE_8[exp_usize]),\n        u16::WIDTH => T::wrapping_from(MAX_BASE_16[exp_usize]),\n        u32::WIDTH => T::wrapping_from(MAX_BASE_32[exp_usize]),\n        u64::WIDTH => T::wrapping_from(MAX_BASE_64[exp_usize]),\n        u128::WIDTH => T::wrapping_from(MAX_BASE_128[exp_usize]),\n        _ => unreachable!(),\n    };\n    let max_pow = match T::WIDTH {\n        u8::WIDTH => T::wrapping_from(MAX_POWER_8[exp_usize]),\n        u16::WIDTH => T::wrapping_from(MAX_POWER_16[exp_usize]),\n        u32::WIDTH => T::wrapping_from(MAX_POWER_32[exp_usize]),\n        u64::WIDTH => T::wrapping_from(MAX_POWER_64[exp_usize]),\n        u128::WIDTH => T::wrapping_from(MAX_POWER_128[exp_usize]),\n        _ => unreachable!(),\n    };\n    if x >= max_pow {\n        return max_root;\n    }\n    let mut root = g(f(x).pow(1.0 / (exp as f64)));\n    let mut pow = if let Some(pow) = root.checked_pow(exp) {\n        pow\n    } else {\n        // set to max possible pow\n        root = max_root;\n        max_pow\n    };\n    match pow.cmp(&x) {\n        Equal => root,\n        Less => loop {\n            root += T::ONE;\n            pow = root.pow(exp);\n            match pow.cmp(&x) {\n                Equal => return root,\n                Less => {}\n                Greater => return root - T::ONE,\n            }\n        },\n        Greater => loop {\n            root -= T::ONE;\n            pow = root.pow(exp);\n            if pow <= x {\n                return root;\n            }\n        },\n    }\n}}\n\n// Coefficients of Chebyshev's approximation polynomial (deg 2) {c0, c1, c2} splitting 0.5 to 1 into\n// 8 equal intervals\n//\n// Values of these coefficients of Chebyshev's approximation polynomial have been calculated from\n// the python module, \"mpmath\" - http://mpmath.org/ function call: mpmath.chebyfit(lambda x:\n// mpmath.root(x,3), [i, j], 3, error=True) where (i, j) is the  range.\n//\n// ```\n//          c0          c1           c2        range\n// 0.445434042 0.864136635 -0.335205926 [0.50000, 0.53125]\n// 0.454263239 0.830878907 -0.303884962 [0.53125, 0.56250]\n// 0.462761624 0.800647514 -0.276997626 [0.56250, 0.59375]\n// 0.470958569 0.773024522 -0.253724515 [0.59375, 0.62500]\n// 0.478879482 0.747667468 -0.233429710 [0.62500, 0.65625]\n// 0.486546506 0.724292830 -0.215613166 [0.65625, 0.68750]\n// 0.493979069 0.702663686 -0.199877008 [0.68750, 0.71875]\n// 0.501194325 0.682580388 -0.185901247 [0.71875, 0.75000]\n// 0.508207500 0.663873398 -0.173426009 [0.75000, 0.78125]\n// 0.515032183 0.646397742 -0.162238357 [0.78125, 0.81250]\n// 0.521680556 0.630028647 -0.152162376 [0.81250, 0.84375]\n// 0.528163588 0.614658092 -0.143051642 [0.84375, 0.87500]\n// 0.534491194 0.600192044 -0.134783425 [0.87500, 0.90625]\n// 0.540672371 0.586548233 -0.127254189 [0.90625, 0.93750]\n// 0.546715310 0.573654340 -0.120376066 [0.93750, 0.96875]\n// 0.552627494 0.561446514 -0.114074068 [0.96875, 1.00000]\n// ```\n//\n// 1^(1/3), 2^(1/3), 4^(1/3)\nconst FACTOR_TABLE: [f32; 3] = [1.000000, 1.259921, 1.587401];\n\n#[allow(clippy::excessive_precision)]\nconst COEFF: [[f32; 3]; 16] = [\n    [0.445434042, 0.864136635, -0.335205926],\n    [0.454263239, 0.830878907, -0.303884962],\n    [0.462761624, 0.800647514, -0.276997626],\n    [0.470958569, 0.773024522, -0.253724515],\n    [0.478879482, 0.747667468, -0.233429710],\n    [0.486546506, 0.724292830, -0.215613166],\n    [0.493979069, 0.702663686, -0.199877008],\n    [0.501194325, 0.682580388, -0.185901247],\n    [0.508207500, 0.663873398, -0.173426009],\n    [0.515032183, 0.646397742, -0.162238357],\n    [0.521680556, 0.630028647, -0.152162376],\n    [0.528163588, 0.614658092, -0.143051642],\n    [0.534491194, 0.600192044, -0.134783425],\n    [0.540672371, 0.586548233, -0.127254189],\n    [0.546715310, 0.573654340, -0.120376066],\n    [0.552627494, 0.561446514, -0.114074068],\n];\n\n// n cannot be 0\n//\n// This is equivalent to `n_cbrt_chebyshev_approx` from\n// `ulong_extras/cbrt_chebyshev_approximation.c`, FLINT 2.7.1, where `FLINT64` is `false`.\npub_test! {cbrt_chebyshev_approx_u32(n: u32) -> u32 {\n    // UPPER_LIMIT is the max cube root possible for one word\n    const UPPER_LIMIT: u32 = 1625; // 1625 < (2^32)^(1/3)\n    const BIAS_HEX: u32 = 0x3f000000;\n    const BIAS: u32 = 126;\n    let (mantissa, exponent) = (n as f32).raw_mantissa_and_exponent();\n    let mut mantissa = u32::wrapping_from(mantissa);\n    let table_index = usize::wrapping_from(mantissa >> (f32::MANTISSA_WIDTH - 4));\n    mantissa |= BIAS_HEX;\n    let (exponent_over_3, exponent_rem) = (u32::wrapping_from(exponent) - BIAS).div_mod(3);\n\n    // Calculating cube root of dec using Chebyshev approximation polynomial\n    //\n    // Evaluating approx polynomial at (dec) by Estrin's scheme\n    let x = f32::from_bits(mantissa);\n    let row = COEFF[table_index];\n    let mut cbrt = ((row[0] + row[1] * x + row[2] * (x * x))\n        * f32::power_of_2(i64::wrapping_from(exponent_over_3))\n        * FACTOR_TABLE[usize::wrapping_from(exponent_rem)]) as u32;\n    const MAX_CUBE: u32 = UPPER_LIMIT * UPPER_LIMIT * UPPER_LIMIT;\n    if cbrt >= UPPER_LIMIT {\n        if n >= MAX_CUBE {\n            return UPPER_LIMIT;\n        }\n        cbrt = UPPER_LIMIT - 1;\n    }\n    while cbrt * cbrt * cbrt <= n {\n        cbrt += 1;\n        if cbrt == UPPER_LIMIT {\n            break;\n        }\n    }\n    while cbrt * cbrt * cbrt > n {\n        cbrt -= 1;\n    }\n    cbrt\n}}\n\n// n cannot be 0\n//\n// This is equivalent to `n_cbrt_chebyshev_approx` from\n// `ulong_extras/cbrt_chebyshev_approximation.c`, FLINT 2.7.1, where `FLINT64` is `true`.\npub_test! {cbrt_chebyshev_approx_u64(n: u64) -> u64 {\n    // UPPER_LIMIT is the max cube root possible for one word\n    const UPPER_LIMIT: u64 = 2642245; // 2642245 < (2^64)^(1/3)\n    const BIAS_HEX: u64 = 0x3fe0000000000000;\n    const BIAS: u64 = 1022;\n    let (mut mantissa, exponent) = (n as f64).raw_mantissa_and_exponent();\n    let table_index = usize::wrapping_from(mantissa >> (f64::MANTISSA_WIDTH - 4));\n    mantissa |= BIAS_HEX;\n    let (exponent_over_3, exponent_rem) = (exponent - BIAS).div_mod(3);\n\n    // Calculating cube root of dec using Chebyshev approximation polynomial\n    //\n    // Evaluating approx polynomial at x by Estrin's scheme\n    let x = f64::from_bits(mantissa);\n    let row = COEFF[table_index];\n    let mut cbrt = ((f64::from(row[0]) + f64::from(row[1]) * x + f64::from(row[2]) * (x * x))\n        * f64::power_of_2(i64::wrapping_from(exponent_over_3))\n        * f64::from(FACTOR_TABLE[usize::wrapping_from(exponent_rem)])) as u64;\n    const MAX_CUBE: u64 = UPPER_LIMIT * UPPER_LIMIT * UPPER_LIMIT;\n    if cbrt >= UPPER_LIMIT {\n        if n >= MAX_CUBE {\n            return UPPER_LIMIT;\n        }\n        cbrt = UPPER_LIMIT - 1;\n    }\n    while cbrt * cbrt * cbrt <= n {\n        cbrt += 1;\n        if cbrt == UPPER_LIMIT {\n            break;\n        }\n    }\n    while cbrt * cbrt * cbrt > n {\n        cbrt -= 1;\n    }\n    cbrt\n}}\n\n// This is equivalent to `n_cbrt_estimate` from `ulong_extras/n_cbrt_estimate.c`, FLINT 2.7.1, where\n// `FLINT64` is `true`.\n#[cfg(feature = \"test_build\")]\nfn cbrt_estimate_f64(a: f64) -> f64 {\n    const S: u64 = 4607182418800017408; // ((1 << 10) - 1) << 52\n    f64::from_bits(\n        u64::wrapping_from((u128::from(a.to_bits() - S) * 6148914691236517205) >> 64) + S,\n    )\n}\n\n// This is equivalent to `n_cbrt` from `ulong_extras/cbrt.c`, FLINT 2.7.1, where `FLINT64` is\n// `false`.\n#[cfg(feature = \"test_build\")]\npub fn fast_floor_cbrt_u32(n: u32) -> u32 {\n    // Taking care of smaller roots\n    if n < 125 {\n        return if n >= 64 {\n            4\n        } else if n >= 27 {\n            3\n        } else if n >= 8 {\n            2\n        } else {\n            u32::from(n >= 1)\n        };\n    }\n    if n < 1331 {\n        return if n >= 1000 {\n            10\n        } else if n >= 729 {\n            9\n        } else if n >= 512 {\n            8\n        } else if n >= 343 {\n            7\n        } else if n >= 216 {\n            6\n        } else {\n            5\n        };\n    }\n    if n < 4913 {\n        return if n >= 4096 {\n            16\n        } else if n >= 3375 {\n            15\n        } else if n >= 2744 {\n            14\n        } else if n >= 2197 {\n            13\n        } else if n >= 1728 {\n            12\n        } else {\n            11\n        };\n    }\n    let val = f64::from(n);\n    const UPPER_LIMIT: u32 = 1625; // 1625 < (2^32)^(1/3)\n    let mut x = cbrt_estimate_f64(val);\n    // Kahan's iterations to get cube root\n    let xcub = x * x * x;\n    let num = (xcub - val) * x;\n    let den = xcub + xcub + val;\n    x -= num / den;\n    let mut ret = x as u32;\n    const UPPER_LIMIT_CUBE: u32 = UPPER_LIMIT * UPPER_LIMIT * UPPER_LIMIT;\n    // In case ret ^ 3 or (ret + 1) ^ 3 will cause overflow\n    if ret >= UPPER_LIMIT {\n        if n >= UPPER_LIMIT_CUBE {\n            return UPPER_LIMIT;\n        }\n        ret = UPPER_LIMIT - 1;\n    }\n    while ret * ret * ret <= n {\n        ret += 1;\n        if ret == UPPER_LIMIT {\n            break;\n        }\n    }\n    while ret * ret * ret > n {\n        ret -= 1;\n    }\n    ret\n}\n\n// TODO tune\n#[cfg(feature = \"test_build\")]\nconst CBRT_CHEBYSHEV_THRESHOLD: u64 = 10;\n\n// This is equivalent to `n_cbrt` from `ulong_extras/cbrt.c`, FLINT 2.7.1, where `FLINT64` is\n// `true`.\n#[cfg(feature = \"test_build\")]\npub fn fast_floor_cbrt_u64(n: u64) -> u64 {\n    // Taking care of smaller roots\n    if n < 125 {\n        return if n >= 64 {\n            4\n        } else if n >= 27 {\n            3\n        } else if n >= 8 {\n            2\n        } else {\n            u64::from(n >= 1)\n        };\n    }\n    if n < 1331 {\n        return if n >= 1000 {\n            10\n        } else if n >= 729 {\n            9\n        } else if n >= 512 {\n            8\n        } else if n >= 343 {\n            7\n        } else if n >= 216 {\n            6\n        } else {\n            5\n        };\n    }\n    if n < 4913 {\n        return if n >= 4096 {\n            16\n        } else if n >= 3375 {\n            15\n        } else if n >= 2744 {\n            14\n        } else if n >= 2197 {\n            13\n        } else if n >= 1728 {\n            12\n        } else {\n            11\n        };\n    }\n    if n.significant_bits() > CBRT_CHEBYSHEV_THRESHOLD {\n        return cbrt_chebyshev_approx_u64(n);\n    }\n    let val = n as f64;\n    const UPPER_LIMIT: u64 = 2642245; // 2642245 < (2^64)^(1/3)\n    let mut x = cbrt_estimate_f64(val);\n    // Kahan's iterations to get cube root\n    let xcub = x * x * x;\n    let num = (xcub - val) * x;\n    let den = xcub + xcub + val;\n    x -= num / den;\n    let mut ret = x as u64;\n    const UPPER_LIMIT_CUBE: u64 = UPPER_LIMIT * UPPER_LIMIT * UPPER_LIMIT;\n    // In case ret ^ 3 or (ret + 1) ^ 3 will cause overflow\n    if ret >= UPPER_LIMIT {\n        if n >= UPPER_LIMIT_CUBE {\n            return UPPER_LIMIT;\n        }\n        ret = UPPER_LIMIT - 1;\n    }\n    while ret * ret * ret <= n {\n        ret += 1;\n        if ret == UPPER_LIMIT {\n            break;\n        }\n    }\n    while ret * ret * ret > n {\n        ret -= 1;\n    }\n    ret\n}\n\n// this table contains the value of UWORD_MAX / n, for n in range [1, 32]\nconst MUL_FACTOR_32: [u32; 33] = [\n    0,\n    u32::MAX,\n    2147483647,\n    1431655765,\n    1073741823,\n    858993459,\n    715827882,\n    613566756,\n    536870911,\n    477218588,\n    429496729,\n    390451572,\n    357913941,\n    330382099,\n    306783378,\n    286331153,\n    268435455,\n    252645135,\n    238609294,\n    226050910,\n    214748364,\n    204522252,\n    195225786,\n    186737708,\n    178956970,\n    171798691,\n    165191049,\n    159072862,\n    153391689,\n    148102320,\n    143165576,\n    138547332,\n    134217727,\n];\n\n// this table contains the value of UWORD_MAX / n, for n in range [1, 64]\nconst MUL_FACTOR_64: [u64; 65] = [\n    0,\n    u64::MAX,\n    9223372036854775807,\n    6148914691236517205,\n    4611686018427387903,\n    3689348814741910323,\n    3074457345618258602,\n    2635249153387078802,\n    2305843009213693951,\n    2049638230412172401,\n    1844674407370955161,\n    1676976733973595601,\n    1537228672809129301,\n    1418980313362273201,\n    1317624576693539401,\n    1229782938247303441,\n    1152921504606846975,\n    1085102592571150095,\n    1024819115206086200,\n    970881267037344821,\n    922337203685477580,\n    878416384462359600,\n    838488366986797800,\n    802032351030850070,\n    768614336404564650,\n    737869762948382064,\n    709490156681136600,\n    683212743470724133,\n    658812288346769700,\n    636094623231363848,\n    614891469123651720,\n    595056260442243600,\n    576460752303423487,\n    558992244657865200,\n    542551296285575047,\n    527049830677415760,\n    512409557603043100,\n    498560650640798692,\n    485440633518672410,\n    472993437787424400,\n    461168601842738790,\n    449920587163647600,\n    439208192231179800,\n    428994048225803525,\n    419244183493398900,\n    409927646082434480,\n    401016175515425035,\n    392483916461905353,\n    384307168202282325,\n    376464164769582686,\n    368934881474191032,\n    361700864190383365,\n    354745078340568300,\n    348051774975651917,\n    341606371735362066,\n    335395346794719120,\n    329406144173384850,\n    323627089012448273,\n    318047311615681924,\n    312656679215416129,\n    307445734561825860,\n    302405640552615600,\n    297528130221121800,\n    292805461487453200,\n    288230376151711743,\n];\n\n// This is equivalent to `n_root_estimate` from `ulong_extras/root_estimate.c`, FLINT 2.7.1, where\n// `FLINT64` is `false`.\nfn root_estimate_32(a: f64, n: usize) -> u32 {\n    let s = u32::low_mask(f32::EXPONENT_WIDTH - 1) << f32::MANTISSA_WIDTH;\n    f32::from_bits(u32::x_mul_y_to_zz((a as f32).to_bits() - s, MUL_FACTOR_32[n]).0 + s) as u32\n}\n\n// This is equivalent to `n_root_estimate` from `ulong_extras/root_estimate.c`, FLINT 2.7.1, where\n// `FLINT64` is `true`.\nfn root_estimate_64(a: f64, n: usize) -> u64 {\n    let s = u64::low_mask(f64::EXPONENT_WIDTH - 1) << f64::MANTISSA_WIDTH;\n    f64::from_bits(u64::x_mul_y_to_zz(a.to_bits() - s, MUL_FACTOR_64[n]).0 + s) as u64\n}\n\nconst INV_TABLE: [f64; 65] = [\n    0.000000000000000,\n    1.000000000000000,\n    0.500000000000000,\n    0.333333333333333,\n    0.250000000000000,\n    0.200000000000000,\n    0.166666666666667,\n    0.142857142857143,\n    0.125000000000000,\n    0.111111111111111,\n    0.100000000000000,\n    0.090909090909091,\n    0.083333333333333,\n    0.076923076923077,\n    0.071428571428571,\n    0.066666666666667,\n    0.062500000000000,\n    0.058823529411765,\n    0.055555555555556,\n    0.052631578947368,\n    0.050000000000000,\n    0.047619047619048,\n    0.045454545454545,\n    0.043478260869565,\n    0.041666666666667,\n    0.040000000000000,\n    0.038461538461538,\n    0.037037037037037,\n    0.035714285714286,\n    0.034482758620690,\n    0.033333333333333,\n    0.032258064516129,\n    0.031250000000000,\n    0.030303030303030,\n    0.029411764705882,\n    0.028571428571429,\n    0.027777777777778,\n    0.027027027027027,\n    0.026315789473684,\n    0.025641025641026,\n    0.025000000000000,\n    0.024390243902439,\n    0.023809523809524,\n    0.023255813953488,\n    0.022727272727273,\n    0.022222222222222,\n    0.021739130434783,\n    0.021276595744681,\n    0.020833333333333,\n    0.020408163265306,\n    0.020000000000000,\n    0.019607843137255,\n    0.019230769230769,\n    0.018867924528302,\n    0.018518518518519,\n    0.018181818181818,\n    0.017857142857143,\n    0.017543859649123,\n    0.017241379310345,\n    0.016949152542373,\n    0.016666666666667,\n    0.016393442622951,\n    0.016129032258065,\n    0.015873015873016,\n    0.015625000000000,\n];\n\n// This is equivalent to `n_root` from `ulong_extras/root.c`, FLINT 2.7.1, where `FLINT64` is\n// `false` and `root` is nonzero.\npub_test! {fast_floor_root_u32(n: u32, exp: u64) -> u32 {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return n;\n    } else if exp >= u32::WIDTH || n.significant_bits() <= exp {\n        return 1;\n    } else if exp == 2 {\n        return n.floor_sqrt();\n    } else if exp == 3 {\n        return cbrt_chebyshev_approx_u32(n);\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_32[exp_usize]; // n <= upper_limit ^ exp\n    let x = root_estimate_32(f64::from(n), exp_usize);\n    // one round of Newton iteration\n    let mut root = u32::rounding_from(\n        (f64::from(n / x.pow(exp - 1)) - f64::from(x)) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return root;\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    root\n}}\n\n// This is equivalent to `n_root` from `ulong_extras/root.c`, FLINT 2.7.1, where `FLINT64` is `true`\n// and `root` is nonzero.\npub_test! {fast_floor_root_u64(n: u64, exp: u64) -> u64 {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return n;\n    } else if exp == 2 {\n        return n.floor_sqrt();\n    } else if exp == 3 {\n        return cbrt_chebyshev_approx_u64(n);\n    } else if exp >= u64::WIDTH || (1 << exp) > n {\n        return 1;\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_64[exp_usize]; // n <= upper_limit ^ exp\n    let x = root_estimate_64(n as f64, exp_usize);\n    // one round of Newton iteration\n    let mut root = u64::rounding_from(\n        (((n / x.saturating_pow(exp - 1)) as f64) - x as f64) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return root;\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    root\n}}\n\npub_test! {fast_ceiling_root_u32(n: u32, exp: u64) -> u32 {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return n;\n    }\n    if exp >= u32::WIDTH || n.significant_bits() <= exp {\n        return 2;\n    }\n    if exp == 2 {\n        return n.ceiling_sqrt();\n    }\n    if exp == 3 {\n        let root = cbrt_chebyshev_approx_u32(n);\n        return if root.pow(3) == n { root } else { root + 1 };\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_32[exp_usize]; // n <= upper_limit ^ exp\n    let x = root_estimate_32(f64::from(n), exp_usize);\n    // one round of Newton iteration\n    let mut root = u32::rounding_from(\n        (f64::from(n / x.pow(exp - 1)) - f64::from(x)) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return root;\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    if pow == n {\n        root\n    } else {\n        root + 1\n    }\n}}\n\npub_test! {fast_ceiling_root_u64(n: u64, exp: u64) -> u64 {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return n;\n    }\n    if exp >= u64::WIDTH || n.significant_bits() <= exp {\n        return 2;\n    }\n    if exp == 2 {\n        return n.ceiling_sqrt();\n    }\n    if exp == 3 {\n        let root = cbrt_chebyshev_approx_u64(n);\n        return if root.pow(3) == n { root } else { root + 1 };\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_64[exp_usize]; // n <= upper_limit ^ root\n    let x = root_estimate_64(n as f64, exp_usize);\n    // one round of Newton iteration\n    let mut root = u64::rounding_from(\n        (((n / x.wrapping_pow(exp - 1)) as f64) - x as f64) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return root;\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    if pow == n {\n        root\n    } else {\n        root + 1\n    }\n}}\n\npub_test! {fast_checked_root_u32(n: u32, exp: u64) -> Option<u32> {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return Some(n);\n    }\n    if exp >= u32::WIDTH || n.significant_bits() <= exp {\n        return None;\n    }\n    if exp == 2 {\n        return n.checked_sqrt();\n    }\n    if exp == 3 {\n        let root = cbrt_chebyshev_approx_u32(n);\n        return if root.pow(3) == n { Some(root) } else { None };\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_32[exp_usize]; // n <= upper_limit ^ exp\n    let x = root_estimate_32(f64::from(n), exp_usize);\n    // one round of Newton iteration\n    let mut root = u32::rounding_from(\n        (f64::from(n / x.pow(exp - 1)) - f64::from(x)) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return Some(root);\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    if pow == n {\n        Some(root)\n    } else {\n        None\n    }\n}}\n\npub_test! {fast_checked_root_u64(n: u64, exp: u64) -> Option<u64> {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return Some(n);\n    }\n    if exp >= u64::WIDTH || n.significant_bits() <= exp {\n        return None;\n    }\n    if exp == 2 {\n        return n.checked_sqrt();\n    }\n    if exp == 3 {\n        let root = cbrt_chebyshev_approx_u64(n);\n        return if root.pow(3) == n { Some(root) } else { None };\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_64[exp_usize]; // n <= upper_limit ^ root\n    let x = root_estimate_64(n as f64, exp_usize);\n    // one round of Newton iteration\n    let mut root = u64::rounding_from(\n        (((n / x.wrapping_pow(exp - 1)) as f64) - x as f64) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return Some(root);\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    if pow == n {\n        Some(root)\n    } else {\n        None\n    }\n}}\n\npub_test! {fast_root_rem_u32(n: u32, exp: u64) -> (u32, u32) {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return (n, 0);\n    }\n    if exp >= u32::WIDTH || n.significant_bits() <= exp {\n        return (1, n - 1);\n    }\n    if exp == 2 {\n        return n.sqrt_rem();\n    }\n    if exp == 3 {\n        let root = cbrt_chebyshev_approx_u32(n);\n        let pow = root.pow(3);\n        return (root, n - pow);\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_32[exp_usize]; // n <= upper_limit ^ exp\n    let x = root_estimate_32(f64::from(n), exp_usize);\n    // one round of Newton iteration\n    let mut root = u32::rounding_from(\n        (f64::from(n / x.pow(exp - 1)) - f64::from(x)) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return (root, 0);\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    (root, n - pow)\n}}\n\npub_test! {fast_root_rem_u64(n: u64, exp: u64) -> (u64, u64) {\n    assert_ne!(exp, 0);\n    if n < 2 || exp == 1 {\n        return (n, 0);\n    }\n    if exp >= u64::WIDTH || n.significant_bits() <= exp {\n        return (1, n - 1);\n    }\n    if exp == 2 {\n        return n.sqrt_rem();\n    }\n    if exp == 3 {\n        let root = cbrt_chebyshev_approx_u64(n);\n        let pow = root.pow(3);\n        return (root, n - pow);\n    }\n    let exp = u32::wrapping_from(exp);\n    let exp_usize = usize::wrapping_from(exp);\n    let upper_limit = MAX_BASE_64[exp_usize]; // n <= upper_limit ^ root\n    let x = root_estimate_64(n as f64, exp_usize);\n    // one round of Newton iteration\n    let mut root = u64::rounding_from(\n        (((n / x.wrapping_pow(exp - 1)) as f64) - x as f64) * INV_TABLE[exp_usize],\n        Down,\n    ).0;\n    if root >= upper_limit {\n        root = upper_limit - 1;\n    }\n    let mut pow = root.pow(exp);\n    if pow == n {\n        return (root, 0);\n    }\n    while pow <= n {\n        root += 1;\n        pow = root.pow(exp);\n        if root == upper_limit {\n            break;\n        }\n    }\n    while pow > n {\n        root -= 1;\n        pow = root.pow(exp);\n    }\n    (root, n - pow)\n}}\n\n#[cfg(feature = \"test_build\")]\npub fn floor_root_binary<T: PrimitiveUnsigned>(x: T, exp: u64) -> T {\n    if exp == 0 {\n        panic!(\"Cannot take 0th root\");\n    } else if exp == 1 || x < T::TWO {\n        x\n    } else {\n        let bits = x.significant_bits();\n        if bits <= exp {\n            T::ONE\n        } else {\n            let p = T::power_of_2(bits.div_round(exp, Ceiling).0);\n            floor_inverse_checked_binary(|i| i.checked_pow(exp), x, p >> 1, p)\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\npub fn ceiling_root_binary<T: PrimitiveUnsigned>(x: T, exp: u64) -> T {\n    let floor_root = floor_root_binary(x, exp);\n    if floor_root.pow(exp) == x {\n        floor_root\n    } else {\n        floor_root + T::ONE\n    }\n}\n\n#[cfg(feature = \"test_build\")]\npub fn checked_root_binary<T: PrimitiveUnsigned>(x: T, exp: u64) -> Option<T> {\n    let floor_root = floor_root_binary(x, exp);\n    if floor_root.pow(exp) == x {\n        Some(floor_root)\n    } else {\n        None\n    }\n}\n\n#[cfg(feature = \"test_build\")]\npub fn root_rem_binary<T: PrimitiveUnsigned>(x: T, exp: u64) -> (T, T) {\n    let floor_root = floor_root_binary(x, exp);\n    (floor_root, x - floor_root.pow(exp))\n}\n\nimpl FloorRoot<u64> for u8 {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of a [`u8`].\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#floor_root).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses lookup tables.\n    #[inline]\n    fn floor_root(self, exp: u64) -> Self {\n        match (self, exp) {\n            (_, 0) => panic!(),\n            (0 | 1, _) | (_, 1) => self,\n            (_, 8..=u64::MAX) => 1,\n            (x, 2) => x.floor_sqrt(),\n            (x, 3) => Self::wrapping_from(match U8_CUBES.binary_search(&x) {\n                Ok(i) => i,\n                Err(i) => i - 1,\n            }),\n            (x, 4) if x < 16 => 1,\n            (x, 4) if x < 81 => 2,\n            (x, 5) if x < 32 => 1,\n            (x, 5) if x < 243 => 2,\n            (_, 4 | 5) => 3,\n            (x, 6) if x < 64 => 1,\n            (x, 7) if x < 128 => 1,\n            (_, 6 | 7) => 2,\n        }\n    }\n}\n\nimpl CeilingRoot<u64> for u8 {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of a [`u8`].\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#ceiling_root).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses lookup tables.\n    fn ceiling_root(self, exp: u64) -> Self {\n        match (self, exp) {\n            (_, 0) => panic!(),\n            (0 | 1, _) | (_, 1) => self,\n            (_, 8..=u64::MAX) => 2,\n            (x, 2) => x.ceiling_sqrt(),\n            (x, 3) => Self::wrapping_from(match U8_CUBES.binary_search(&x) {\n                Ok(i) | Err(i) => i,\n            }),\n            (x, 4) if x <= 16 => 2,\n            (x, 4) if x <= 81 => 3,\n            (x, 5) if x <= 32 => 2,\n            (x, 5) if x <= 243 => 3,\n            (_, 4 | 5) => 4,\n            (x, 6) if x <= 64 => 2,\n            (x, 7) if x <= 128 => 2,\n            (_, 6 | 7) => 3,\n        }\n    }\n}\n\nimpl CheckedRoot<u64> for u8 {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`u8`], or `None` if the [`u8`] is not a perfect $n$th\n    /// power.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#checked_root).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses lookup tables.\n    fn checked_root(self, exp: u64) -> Option<Self> {\n        match (self, exp) {\n            (_, 0) => panic!(),\n            (0 | 1, _) | (_, 1) => Some(self),\n            (x, 2) => x.checked_sqrt(),\n            (x, 3) => U8_CUBES.binary_search(&x).ok().map(Self::wrapping_from),\n            (16, 4) | (32, 5) | (64, 6) | (128, 7) => Some(2),\n            (81, 4) | (243, 5) => Some(3),\n            _ => None,\n        }\n    }\n}\n\nimpl RootRem<u64> for u8 {\n    type RootOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the $n$th root of a [`u8`], and the remainder (the difference between\n    /// the [`u8`] and the $n$th power of the floor).\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#root_rem).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses lookup tables.\n    fn root_rem(self, exp: u64) -> (Self, Self) {\n        match (self, exp) {\n            (_, 0) => panic!(),\n            (0 | 1, _) | (_, 1) => (self, 0),\n            (x, 8..=u64::MAX) => (1, x - 1),\n            (x, 2) => x.sqrt_rem(),\n            (x, 3) => match U8_CUBES.binary_search(&x) {\n                Ok(i) => (Self::wrapping_from(i), 0),\n                Err(i) => (Self::wrapping_from(i - 1), x - U8_CUBES[i - 1]),\n            },\n            (x, 4) if x < 16 => (1, x - 1),\n            (x, 4) if x < 81 => (2, x - 16),\n            (x, 4) => (3, x - 81),\n            (x, 5) if x < 32 => (1, x - 1),\n            (x, 5) if x < 243 => (2, x - 32),\n            (x, 5) => (3, x - 243),\n            (x, 6) if x < 64 => (1, x - 1),\n            (x, 6) => (2, x - 64),\n            (x, 7) if x < 128 => (1, x - 1),\n            (x, 7) => (2, x - 128),\n        }\n    }\n}\n\nimpl FloorRoot<u64> for u16 {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of a [`u16`].\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#checked_root).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn floor_root(self, exp: u64) -> Self {\n        Self::wrapping_from(u32::from(self).floor_root(exp))\n    }\n}\n\nimpl CeilingRoot<u64> for u16 {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of a [`u16`].\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#ceiling_root).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn ceiling_root(self, exp: u64) -> Self {\n        Self::wrapping_from(u32::from(self).ceiling_root(exp))\n    }\n}\n\nimpl CheckedRoot<u64> for u16 {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`u16`], or `None` if the [`u16`] is not a perfect $n$th\n    /// power.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#checked_root).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn checked_root(self, exp: u64) -> Option<Self> {\n        u32::from(self).checked_root(exp).map(Self::wrapping_from)\n    }\n}\n\nimpl RootRem<u64> for u16 {\n    type RootOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the $n$th root of a [`u16`], and the remainder (the difference between\n    /// the [`u16`] and the $n$th power of the floor).\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#root_rem).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn root_rem(self, exp: u64) -> (Self, Self) {\n        let (sqrt, rem) = u32::from(self).root_rem(exp);\n        (Self::wrapping_from(sqrt), Self::wrapping_from(rem))\n    }\n}\n\nimpl FloorRoot<u64> for u32 {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of a [`u32`].\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#floor_root).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u32`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn floor_root(self, exp: u64) -> Self {\n        fast_floor_root_u32(self, exp)\n    }\n}\n\nimpl CeilingRoot<u64> for u32 {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of a [`u32`].\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#ceiling_root).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u32`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn ceiling_root(self, exp: u64) -> Self {\n        fast_ceiling_root_u32(self, exp)\n    }\n}\n\nimpl CheckedRoot<u64> for u32 {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`u32`], or `None` if the [`u32`] is not a perfect $n$th\n    /// power.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#checked_root).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u32`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn checked_root(self, exp: u64) -> Option<Self> {\n        fast_checked_root_u32(self, exp)\n    }\n}\n\nimpl RootRem<u64> for u32 {\n    type RootOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the $n$th root of a [`u32`], and the remainder (the difference between\n    /// the [`u32`] and the $n$th power of the floor).\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#root_rem).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u32`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn root_rem(self, exp: u64) -> (Self, Self) {\n        fast_root_rem_u32(self, exp)\n    }\n}\n\nimpl FloorRoot<Self> for u64 {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of a [`u64`].\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#floor_root).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u64`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn floor_root(self, exp: Self) -> Self {\n        fast_floor_root_u64(self, exp)\n    }\n}\n\nimpl CeilingRoot<Self> for u64 {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of a [`u64`].\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#ceiling_root).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u64`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn ceiling_root(self, exp: Self) -> Self {\n        fast_ceiling_root_u64(self, exp)\n    }\n}\n\nimpl CheckedRoot<Self> for u64 {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`u64`], or `None` if the [`u64`] is not a perfect $n$th\n    /// power.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#checked_root).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u64`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn checked_root(self, exp: Self) -> Option<Self> {\n        fast_checked_root_u64(self, exp)\n    }\n}\n\nimpl RootRem<Self> for u64 {\n    type RootOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the $n$th root of a [`u64`], and the remainder (the difference between\n    /// the [`u64`] and the $n$th power of the floor).\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#root_rem).\n    ///\n    /// # Notes\n    /// For cube roots, the [`u64`] implementation uses a piecewise Chebyshev approximation. For\n    /// other roots, it uses Newton's method. In both implementations, the result of these\n    /// approximations is adjusted afterwards to account for error.\n    #[inline]\n    fn root_rem(self, exp: Self) -> (Self, Self) {\n        fast_root_rem_u64(self, exp)\n    }\n}\n\nimpl FloorRoot<u64> for usize {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of a [`usize`].\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#floor_root).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn floor_root(self, exp: u64) -> Self {\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::wrapping_from(self).floor_root(exp))\n        } else {\n            Self::wrapping_from(u64::wrapping_from(self).floor_root(exp))\n        }\n    }\n}\n\nimpl CeilingRoot<u64> for usize {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of a [`usize`].\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#ceiling_root).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn ceiling_root(self, exp: u64) -> Self {\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::wrapping_from(self).ceiling_root(exp))\n        } else {\n            Self::wrapping_from(u64::wrapping_from(self).ceiling_root(exp))\n        }\n    }\n}\n\nimpl CheckedRoot<u64> for usize {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`usize`], or `None` if the [`usize`] is not a perfect $n$th\n    /// power.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#checked_root).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn checked_root(self, exp: u64) -> Option<Self> {\n        if USIZE_IS_U32 {\n            u32::wrapping_from(self)\n                .checked_root(exp)\n                .map(Self::wrapping_from)\n        } else {\n            u64::wrapping_from(self)\n                .checked_root(exp)\n                .map(Self::wrapping_from)\n        }\n    }\n}\n\nimpl RootRem<u64> for usize {\n    type RootOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the $n$th root of a [`usize`], and the remainder (the difference\n    /// between the [`usize`] and the $n$th power of the floor).\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#root_rem).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn root_rem(self, exp: u64) -> (Self, Self) {\n        if USIZE_IS_U32 {\n            let (sqrt, rem) = u32::wrapping_from(self).root_rem(exp);\n            (Self::wrapping_from(sqrt), Self::wrapping_from(rem))\n        } else {\n            let (sqrt, rem) = u64::wrapping_from(self).root_rem(exp);\n            (Self::wrapping_from(sqrt), Self::wrapping_from(rem))\n        }\n    }\n}\n\nimpl FloorRoot<u64> for u128 {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of a [`u128`].\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#floor_root).\n    ///\n    /// # Notes\n    /// The [`u128`] implementation computes the root using floating-point arithmetic. The\n    /// approximate result is adjusted afterwards to account for error.\n    fn floor_root(self, exp: u64) -> Self {\n        if exp == 2 {\n            return self.floor_sqrt();\n        }\n        floor_root_approx_and_refine(|x| x as f64, |x| x as Self, self, exp)\n    }\n}\n\nimpl CeilingRoot<u64> for u128 {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of a [`u128`].\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#ceiling_root).\n    ///\n    /// # Notes\n    /// The [`u128`] implementation computes the root using floating-point arithmetic. The\n    /// approximate result is adjusted afterwards to account for error.\n    fn ceiling_root(self, exp: u64) -> Self {\n        if exp == 2 {\n            return self.ceiling_sqrt();\n        }\n        let root = floor_root_approx_and_refine(|x| x as f64, |x| x as Self, self, exp);\n        if root.pow(u32::saturating_from(exp)) == self {\n            root\n        } else {\n            root + 1\n        }\n    }\n}\n\nimpl CheckedRoot<u64> for u128 {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`u128`], or `None` if the [`u128`] is not a perfect $n$th\n    /// power.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#checked_root).\n    ///\n    /// # Notes\n    /// The [`u128`] implementation computes the root using floating-point arithmetic. The\n    /// approximate result is adjusted afterwards to account for error.\n    fn checked_root(self, exp: u64) -> Option<Self> {\n        if exp == 2 {\n            return self.checked_sqrt();\n        }\n        let root = floor_root_approx_and_refine(|x| x as f64, |x| x as Self, self, exp);\n        if root.pow(u32::saturating_from(exp)) == self {\n            Some(root)\n        } else {\n            None\n        }\n    }\n}\n\nimpl RootRem<u64> for u128 {\n    type RootOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the $n$th root of a [`u128`], and the remainder (the difference between\n    /// the [`u128`] and the $n$th power of the floor).\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^n)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::root#root_rem).\n    ///\n    /// # Notes\n    /// The [`u128`] implementation computes the root using floating-point arithmetic. The\n    /// approximate result is adjusted afterwards to account for error.\n    fn root_rem(self, exp: u64) -> (Self, Self) {\n        if exp == 2 {\n            return self.sqrt_rem();\n        }\n        let root = floor_root_approx_and_refine(|x| x as f64, |x| x as Self, self, exp);\n        (root, self - root.pow(u32::saturating_from(exp)))\n    }\n}\n\nmacro_rules! impl_root_assign_rem {\n    ($t: ident) => {\n        impl RootAssignRem<u64> for $t {\n            type RemOutput = $t;\n\n            /// Replaces an integer with the floor of its $n$th root, and returns the remainder (the\n            /// difference between the original integer and the $n$th power of the floor).\n            ///\n            /// $f(x, n) = x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^n$,\n            ///\n            /// $x \\gets \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `exp` is zero.\n            ///\n            /// # Examples\n            /// See [here](super::root#root_assign_rem).\n            #[inline]\n            fn root_assign_rem(&mut self, exp: u64) -> $t {\n                let rem;\n                (*self, rem) = self.root_rem(exp);\n                rem\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_root_assign_rem);\n\nmacro_rules! impl_root_signed {\n    ($t: ident) => {\n        impl FloorRoot<u64> for $t {\n            type Output = $t;\n\n            /// Returns the floor of the $n$th root of an integer.\n            ///\n            /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `exp` is zero, or if `self` is negative and `exp` is even.\n            ///\n            /// # Examples\n            /// See [here](super::root#floor_root).\n            #[inline]\n            fn floor_root(self, exp: u64) -> $t {\n                if self >= 0 {\n                    $t::wrapping_from(self.unsigned_abs().floor_root(exp))\n                } else if exp.odd() {\n                    $t::wrapping_from(self.unsigned_abs().ceiling_root(exp)).wrapping_neg()\n                } else {\n                    panic!(\"Cannot take even root of a negative number\");\n                }\n            }\n        }\n\n        impl CeilingRoot<u64> for $t {\n            type Output = $t;\n\n            /// Returns the ceiling of the $n$th root of an integer.\n            ///\n            /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `exp` is zero, or if `self` is negative and `exp` is even.\n            ///\n            /// # Examples\n            /// See [here](super::root#ceiling_root).\n            #[inline]\n            fn ceiling_root(self, exp: u64) -> $t {\n                if self >= 0 {\n                    $t::wrapping_from(self.unsigned_abs().ceiling_root(exp))\n                } else if exp.odd() {\n                    $t::wrapping_from(self.unsigned_abs().floor_root(exp)).wrapping_neg()\n                } else {\n                    panic!(\"Cannot take even root of a negative number\");\n                }\n            }\n        }\n\n        impl CheckedRoot<u64> for $t {\n            type Output = $t;\n\n            /// Returns the the $n$th root of an integer, or `None` if the integer is not a perfect\n            /// $n$th power.\n            ///\n            /// $$\n            /// f(x, n) = \\\\begin{cases}\n            ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `exp` is zero, or if `self` is negative and `exp` is even.\n            ///\n            /// # Examples\n            /// See [here](super::root#checked_root).\n            #[inline]\n            fn checked_root(self, exp: u64) -> Option<$t> {\n                if self >= 0 {\n                    self.unsigned_abs().checked_root(exp).map($t::wrapping_from)\n                } else if exp.odd() {\n                    self.unsigned_abs()\n                        .checked_root(exp)\n                        .map(|x| $t::wrapping_from(x).wrapping_neg())\n                } else {\n                    panic!(\"Cannot take even root of a negative number\");\n                }\n            }\n        }\n    };\n}\napply_to_signeds!(impl_root_signed);\n\nmacro_rules! impl_root_primitive_int {\n    ($t: ident) => {\n        impl FloorRootAssign<u64> for $t {\n            /// Replaces an integer with the floor of its $n$th root.\n            ///\n            /// $x \\gets \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `exp` is zero, or if `self` is negative and `exp` is even.\n            ///\n            /// # Examples\n            /// See [here](super::root#floor_root_assign).\n            #[inline]\n            fn floor_root_assign(&mut self, exp: u64) {\n                *self = self.floor_root(exp);\n            }\n        }\n\n        impl CeilingRootAssign<u64> for $t {\n            /// Replaces an integer with the ceiling of its $n$th root.\n            ///\n            /// $x \\gets \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `exp` is zero, or if `self` is negative and `exp` is even.\n            ///\n            /// # Examples\n            /// See [here](super::root#ceiling_root_assign).\n            #[inline]\n            fn ceiling_root_assign(&mut self, exp: u64) {\n                *self = self.ceiling_root(exp);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_root_primitive_int);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/rotate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    RotateLeft, RotateLeftAssign, RotateRight, RotateRightAssign,\n};\nuse crate::num::conversion::traits::WrappingFrom;\n\nmacro_rules! impl_rotate {\n    ($t:ident) => {\n        impl RotateLeft for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `rotate_left` functions in the standard library, for\n            /// example [this one](u32::rotate_left).\n            #[inline]\n            fn rotate_left(self, n: u64) -> $t {\n                $t::rotate_left(self, u32::wrapping_from(n))\n            }\n        }\n\n        impl RotateLeftAssign for $t {\n            /// Rotates a number left, in place.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::rotate#rotate_left_assign).\n            #[inline]\n            fn rotate_left_assign(&mut self, n: u64) {\n                *self = self.rotate_left(u32::wrapping_from(n));\n            }\n        }\n\n        impl RotateRight for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `rotate_right` functions in the standard library, for\n            /// example [this one](u32::rotate_right).\n            #[inline]\n            fn rotate_right(self, n: u64) -> $t {\n                $t::rotate_right(self, u32::wrapping_from(n))\n            }\n        }\n\n        impl RotateRightAssign for $t {\n            /// Rotates a number right, in place.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::rotate#rotate_right_assign).\n            #[inline]\n            fn rotate_right_assign(&mut self, n: u64) {\n                *self = self.rotate_right(u32::wrapping_from(n));\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_rotate);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{RoundToMultiple, RoundToMultipleAssign, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::ExactFrom;\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse core::cmp::Ordering::{self, *};\n\nfn round_to_multiple_unsigned<T: PrimitiveUnsigned>(\n    x: T,\n    other: T,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    match (x, other) {\n        (x, y) if x == y => (x, Equal),\n        (x, y) if y == T::ZERO => match rm {\n            Down | Floor | Nearest => (T::ZERO, Less),\n            _ => panic!(\"Cannot round {x} to zero using RoundingMode {rm}\"),\n        },\n        (x, y) => {\n            let r = x % y;\n            if r == T::ZERO {\n                (x, Equal)\n            } else {\n                let floor = x - r;\n                match rm {\n                    Down | Floor => (floor, Less),\n                    Up | Ceiling => (floor.checked_add(y).unwrap(), Greater),\n                    Nearest => {\n                        match r.cmp(&(y >> 1)) {\n                            Less => (floor, Less),\n                            Greater => (floor.checked_add(y).unwrap(), Greater),\n                            Equal => {\n                                if y.odd() {\n                                    (floor, Less)\n                                } else {\n                                    // The even multiple of y will have more trailing zeros.\n                                    let (ceiling, overflow) = floor.overflowing_add(y);\n                                    if floor.trailing_zeros() > ceiling.trailing_zeros() {\n                                        (floor, Less)\n                                    } else if overflow {\n                                        panic!(\"Cannot round {x} to {y} using RoundingMode {rm}\");\n                                    } else {\n                                        (ceiling, Greater)\n                                    }\n                                }\n                            }\n                        }\n                    }\n                    Exact => {\n                        panic!(\"Cannot round {x} to {y} using RoundingMode {rm}\")\n                    }\n                }\n            }\n        }\n    }\n}\n\nmacro_rules! impl_round_to_multiple_unsigned {\n    ($t:ident) => {\n        impl RoundToMultiple<$t> for $t {\n            type Output = $t;\n\n            /// Rounds a number to a multiple of another number, according to a specified rounding\n            /// mode. An [`Ordering`] is also returned, indicating whether the returned value is\n            /// less than, equal to, or greater than the original value.\n            ///\n            /// The only rounding modes that are guaranteed to return without a panic are `Down` and\n            /// `Floor`.\n            ///\n            /// Let $q = \\frac{x}{y}$:\n            ///\n            /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n            ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n            ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n            ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n            ///     y \\lfloor q \\rfloor &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even} \\\\\\\\\n            ///     y \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n            ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\N$.\n            ///\n            /// The following two expressions are equivalent:\n            /// - `x.round_to_multiple(other, Exact)`\n            /// - `{ assert!(x.divisible_by(other)); x }`\n            ///\n            /// but the latter should be used as it is clearer and more efficient.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n            /// - If the multiple is outside the representable range.\n            /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n            ///\n            /// # Examples\n            /// See [here](super::round_to_multiple#round_to_multiple).\n            #[inline]\n            fn round_to_multiple(self, other: $t, rm: RoundingMode) -> ($t, Ordering) {\n                round_to_multiple_unsigned(self, other, rm)\n            }\n        }\n\n        impl RoundToMultipleAssign<$t> for $t {\n            /// Rounds a number to a multiple of another number in place, according to a specified\n            /// rounding mode. An [`Ordering`] is returned, indicating whether the returned value is\n            /// less than, equal to, or greater than the original value.\n            ///\n            /// The only rounding modes that are guaranteed to return without a panic are `Down` and\n            /// `Floor`.\n            ///\n            /// See the [`RoundToMultiple`] documentation for details.\n            ///\n            /// The following two expressions are equivalent:\n            /// - `x.round_to_multiple_assign(other, Exact);`\n            /// - `assert!(x.divisible_by(other));`\n            ///\n            /// but the latter should be used as it is clearer and more efficient.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n            /// - If the multiple is outside the representable range.\n            /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n            ///\n            /// # Examples\n            /// See [here](super::round_to_multiple#round_to_multiple_assign).\n            #[inline]\n            fn round_to_multiple_assign(&mut self, other: $t, rm: RoundingMode) -> Ordering {\n                let o;\n                (*self, o) = self.round_to_multiple(other, rm);\n                o\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_round_to_multiple_unsigned);\n\nfn round_to_multiple_signed<\n    U: PrimitiveUnsigned,\n    S: ExactFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: S,\n    other: S,\n    rm: RoundingMode,\n) -> (S, Ordering) {\n    if x >= S::ZERO {\n        let (m, o) = x.unsigned_abs().round_to_multiple(other.unsigned_abs(), rm);\n        (S::exact_from(m), o)\n    } else {\n        let (abs_result, o) = x\n            .unsigned_abs()\n            .round_to_multiple(other.unsigned_abs(), -rm);\n        (\n            if abs_result == S::MIN.unsigned_abs() {\n                S::MIN\n            } else {\n                S::exact_from(abs_result).checked_neg().unwrap()\n            },\n            o.reverse(),\n        )\n    }\n}\n\nmacro_rules! impl_round_to_multiple_signed {\n    ($t:ident) => {\n        impl RoundToMultiple<$t> for $t {\n            type Output = $t;\n\n            /// Rounds a number to a multiple of another number, according to a specified rounding\n            /// mode. An [`Ordering`] is also returned, indicating whether the returned value is\n            /// less than, equal to, or greater than the original value.\n            ///\n            /// The only rounding mode that is guaranteed to return without a panic is `Down`.\n            ///\n            /// Let $q = \\frac{x}{|y|}$:\n            ///\n            /// $f(x, y, \\mathrm{Down}) =  \\operatorname{sgn}(q) |y| \\lfloor |q| \\rfloor.$\n            ///\n            /// $f(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) |y| \\lceil |q| \\rceil.$\n            ///\n            /// $f(x, y, \\mathrm{Floor}) = |y| \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, y, \\mathrm{Ceiling}) = |y| \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n            ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n            ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n            ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n            ///     y \\lfloor q \\rfloor &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even} \\\\\\\\\n            ///     y \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n            ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n            ///\n            /// The following two expressions are equivalent:\n            /// - `x.round_to_multiple(other, Exact)`\n            /// - `{ assert!(x.divisible_by(other)); x }`\n            ///\n            /// but the latter should be used as it is clearer and more efficient.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n            /// - If the multiple is outside the representable range.\n            /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n            ///\n            /// # Examples\n            /// See [here](super::round_to_multiple#round_to_multiple).\n            #[inline]\n            fn round_to_multiple(self, other: $t, rm: RoundingMode) -> ($t, Ordering) {\n                round_to_multiple_signed(self, other, rm)\n            }\n        }\n\n        impl RoundToMultipleAssign<$t> for $t {\n            /// Rounds a number to a multiple of another number in place, according to a specified\n            /// rounding mode. An [`Ordering`] is returned, indicating whether the returned value is\n            /// less than, equal to, or greater than the original value.\n            ///\n            /// The only rounding mode that is guaranteed to return without a panic is `Down`.\n            ///\n            /// See the [`RoundToMultiple`] documentation for details.\n            ///\n            /// The following two expressions are equivalent:\n            /// - `x.round_to_multiple_assign(other, Exact);`\n            /// - `assert!(x.divisible_by(other));`\n            ///\n            /// but the latter should be used as it is clearer and more efficient.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n            /// - If the multiple is outside the representable range.\n            /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n            ///\n            /// # Examples\n            /// See [here](super::round_to_multiple#round_to_multiple_assign).\n            #[inline]\n            fn round_to_multiple_assign(&mut self, other: $t, rm: RoundingMode) -> Ordering {\n                let o;\n                (*self, o) = self.round_to_multiple(other, rm);\n                o\n            }\n        }\n    };\n}\napply_to_signeds!(impl_round_to_multiple_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::rounding_modes::RoundingMode;\nuse core::cmp::Ordering;\n\nfn round_to_multiple_of_power_of_2<T: PrimitiveInt>(\n    x: T,\n    pow: u64,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    let (s, o) = x.shr_round(pow, rm);\n    (s.arithmetic_checked_shl(pow).unwrap(), o)\n}\n\nmacro_rules! impl_round_to_multiple_of_power_of_2 {\n    ($t:ident) => {\n        impl RoundToMultipleOfPowerOf2<u64> for $t {\n            type Output = $t;\n\n            /// Rounds a number to a multiple of $2^k$ according to a specified rounding mode. An\n            /// [`Ordering`] is also returned, indicating whether the returned value is less than,\n            /// equal to, or greater than the original value.\n            ///\n            /// The only rounding mode that is guaranteed to return without a panic is `Down`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = 2^k \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = 2^k \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n            ///\n            /// $f(x, k, \\mathrm{Floor}) = 2^k \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Ceiling}) = 2^k \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     2^k \\lfloor q \\rfloor & \\text{if} \\\\quad\n            ///     q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n            ///     2^k \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n            ///     2^k \\lfloor q \\rfloor &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even} \\\\\\\\\n            ///     2^k \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = 2^k q$, but panics if $q \\notin \\Z$.\n            ///\n            /// The following two expressions are equivalent:\n            /// - `x.round_to_multiple_of_power_of_2(pow, Exact)`\n            /// - `{ assert!(x.divisible_by_power_of_2(pow)); x }`\n            ///\n            /// but the latter should be used as it is clearer and more efficient.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// - If `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n            /// - If `rm` is `Floor`, but `self` is negative with a too-large absolute value to\n            ///   round to the next lowest multiple.\n            /// - If `rm` is `Ceiling`, but `self` is too large to round to the next highest\n            ///   multiple.\n            /// - If `rm` is `Up`, but `self` has too large an absolute value to round to the next\n            ///   multiple with a greater absolute value.\n            /// - If `rm` is `Nearest`, but the nearest multiple is outside the representable range.\n            ///\n            /// # Examples\n            /// See [here](super::round_to_multiple_of_power_of_2#round_to_multiple_of_power_of_2).\n            #[inline]\n            fn round_to_multiple_of_power_of_2(self, pow: u64, rm: RoundingMode) -> ($t, Ordering) {\n                round_to_multiple_of_power_of_2(self, pow, rm)\n            }\n        }\n\n        impl RoundToMultipleOfPowerOf2Assign<u64> for $t {\n            /// Rounds a number to a multiple of $2^k$ in place, according to a specified rounding\n            /// mode. An [`Ordering`] is returned, indicating whether the returned value is less\n            /// than, equal to, or greater than the original value.\n            ///\n            /// The only rounding mode that is guaranteed to return without a panic is `Down`.\n            ///\n            /// See the [`RoundToMultipleOfPowerOf2`] documentation for details.\n            ///\n            /// The following two expressions are equivalent:\n            /// - `x.round_to_multiple_of_power_of_2_assign(pow, Exact);`\n            /// - `assert!(x.divisible_by_power_of_2(pow));`\n            ///\n            /// but the latter should be used as it is clearer and more efficient.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// - If `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n            /// - If `rm` is `Floor`, but `self` is negative with a too-large absolute value to\n            ///   round to the next lowest multiple.\n            /// - If `rm` is `Ceiling`, but `self` is too large to round to the next highest\n            ///   multiple.\n            /// - If `rm` is `Up`, but `self` has too large an absolute value to round to the next\n            ///   multiple with a greater absolute value.\n            /// - If `rm` is `Nearest`, but the nearest multiple is outside the representable range.\n            ///\n            /// # Examples\n            /// See\n            /// [here](super::round_to_multiple_of_power_of_2#round_to_multiple_of_power_of_2_assign).\n            #[inline]\n            fn round_to_multiple_of_power_of_2_assign(\n                &mut self,\n                pow: u64,\n                rm: RoundingMode,\n            ) -> Ordering {\n                let o;\n                (*self, o) = self.round_to_multiple_of_power_of_2(pow, rm);\n                o\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_round_to_multiple_of_power_of_2);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingAbs, SaturatingAbsAssign};\n\nmacro_rules! impl_saturating_abs {\n    ($t:ident) => {\n        impl SaturatingAbs for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `saturating_abs` functions in the standard library, for\n            /// example [this one](i32::saturating_abs).\n            #[inline]\n            fn saturating_abs(self) -> $t {\n                $t::saturating_abs(self)\n            }\n        }\n\n        impl SaturatingAbsAssign for $t {\n            /// Replaces a number with its absolute value, saturating at the numeric bounds instead\n            /// of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     |x| & \\text{if} \\\\quad x > -2^{W-1}, \\\\\\\\\n            ///     2^{W-1} - 1 & \\text{if} \\\\quad x = -2^{W-1},\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_abs#saturating_abs_assign).\n            #[inline]\n            fn saturating_abs_assign(&mut self) {\n                *self = self.saturating_abs();\n            }\n        }\n    };\n}\napply_to_signeds!(impl_saturating_abs);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingAdd, SaturatingAddAssign};\n\nmacro_rules! impl_saturating_add {\n    ($t:ident) => {\n        impl SaturatingAdd<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `saturating_add` functions in the standard library, for\n            /// example [this one](i32::saturating_add).\n            #[inline]\n            fn saturating_add(self, other: $t) -> $t {\n                $t::saturating_add(self, other)\n            }\n        }\n\n        impl SaturatingAddAssign<$t> for $t {\n            /// Adds a number to another number, in place, saturating at the numeric bounds instead\n            /// of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x + y & \\text{if} \\\\quad m \\leq x + y \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x + y > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x + y < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_add#saturating_add_assign).\n            #[inline]\n            fn saturating_add_assign(&mut self, other: $t) {\n                *self = self.saturating_add(other);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_saturating_add);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingAddMul, SaturatingAddMulAssign, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\nfn saturating_add_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> T {\n    x.saturating_add(y.saturating_mul(z))\n}\n\nfn saturating_add_mul_assign_unsigned<T: PrimitiveUnsigned>(x: &mut T, y: T, z: T) {\n    x.saturating_add_assign(y.saturating_mul(z));\n}\n\nmacro_rules! impl_saturating_add_mul_unsigned {\n    ($t:ident) => {\n        impl SaturatingAddMul<$t> for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers, saturating at the numeric bounds\n            /// instead of overflowing.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     x + yz & \\text{if} \\\\quad m \\leq x + yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x + yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x + yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_add_mul#saturating_add_mul).\n            #[inline]\n            fn saturating_add_mul(self, y: $t, z: $t) -> $t {\n                saturating_add_mul_unsigned(self, y, z)\n            }\n        }\n\n        impl SaturatingAddMulAssign<$t> for $t {\n            /// Adds a number and the product of two other numbers in place, saturating at the\n            /// numeric bounds instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x + yz & \\text{if} \\\\quad m \\leq x + yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x + yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x + yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_add#saturating_add_mul_assign).\n            #[inline]\n            fn saturating_add_mul_assign(&mut self, y: $t, z: $t) {\n                saturating_add_mul_assign_unsigned(self, y, z);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_saturating_add_mul_unsigned);\n\nfn saturating_add_mul_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: S,\n    y: S,\n    z: S,\n) -> S {\n    if y == S::ZERO || z == S::ZERO {\n        return x;\n    }\n    let x_sign = x >= S::ZERO;\n    if x_sign == ((y >= S::ZERO) == (z >= S::ZERO)) {\n        x.saturating_add(y.saturating_mul(z))\n    } else {\n        let x = x.unsigned_abs();\n        let product = if let Some(product) = y.unsigned_abs().checked_mul(z.unsigned_abs()) {\n            product\n        } else {\n            return if x_sign { S::MIN } else { S::MAX };\n        };\n        let result = S::wrapping_from(if x_sign {\n            x.wrapping_sub(product)\n        } else {\n            product.wrapping_sub(x)\n        });\n        if x >= product || (x_sign == (result < S::ZERO)) {\n            result\n        } else if x_sign {\n            S::MIN\n        } else {\n            S::MAX\n        }\n    }\n}\n\nmacro_rules! impl_saturating_add_mul_signed {\n    ($t:ident) => {\n        impl SaturatingAddMul<$t> for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers, saturating at the numeric bounds\n            /// instead of overflowing.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     x + yz & \\text{if} \\\\quad m \\leq x + yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x + yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x + yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_add_mul#saturating_add_mul_assign).\n            #[inline]\n            fn saturating_add_mul(self, y: $t, z: $t) -> $t {\n                saturating_add_mul_signed(self, y, z)\n            }\n        }\n\n        impl SaturatingAddMulAssign<$t> for $t {\n            /// Adds a number and the product of two other numbers in place, saturating at the\n            /// numeric bounds instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x + yz & \\text{if} \\\\quad m \\leq x + yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x + yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x + yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_add_mul#saturating_add_mul_assign).\n            #[inline]\n            fn saturating_add_mul_assign(&mut self, y: $t, z: $t) {\n                *self = self.saturating_add_mul(y, z);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_saturating_add_mul_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingMul, SaturatingMulAssign};\n\nmacro_rules! impl_saturating_mul {\n    ($t:ident) => {\n        impl SaturatingMul<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `saturating_mul` functions in the standard library, for\n            /// example [this one](i32::saturating_mul).\n            #[inline]\n            fn saturating_mul(self, other: $t) -> $t {\n                $t::saturating_mul(self, other)\n            }\n        }\n\n        impl SaturatingMulAssign<$t> for $t {\n            /// Multiplies a number by another number, in place, saturating at the numeric bounds\n            /// instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     xy & \\text{if} \\\\quad m \\leq xy \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad xy > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad xy < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_mul#saturating_mul_assign).\n            #[inline]\n            fn saturating_mul_assign(&mut self, other: $t) {\n                *self = self.saturating_mul(other);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_saturating_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingNeg, SaturatingNegAssign};\n\nmacro_rules! impl_saturating_neg {\n    ($t:ident) => {\n        impl SaturatingNeg for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `saturating_neg` functions in the standard library, for\n            /// example [this one](i32::saturating_neg).\n            #[inline]\n            fn saturating_neg(self) -> $t {\n                $t::saturating_neg(self)\n            }\n        }\n\n        impl SaturatingNegAssign for $t {\n            /// Negates a number in place, saturating at the numeric bounds instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     -x & \\text{if} \\\\quad x^2 > -2^{W-1}, \\\\\\\\\n            ///     2^{W-1} - 1 & \\text{if} \\\\quad x = -2^{W-1},\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_neg#saturating_neg_assign).\n            #[inline]\n            fn saturating_neg_assign(&mut self) {\n                *self = self.saturating_neg();\n            }\n        }\n    };\n}\napply_to_signeds!(impl_saturating_neg);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Parity, SaturatingPow, SaturatingPowAssign};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn saturating_pow_unsigned<T: PrimitiveUnsigned>(x: T, exp: u64) -> T {\n    if exp == 0 {\n        T::ONE\n    } else if x < T::TWO {\n        x\n    } else if let Some(p) = x.checked_pow(exp) {\n        p\n    } else {\n        T::MAX\n    }\n}\n\nfn saturating_pow_signed<T: PrimitiveSigned>(x: T, exp: u64) -> T {\n    if exp == 0 {\n        T::ONE\n    } else if x == T::ZERO || x == T::ONE {\n        x\n    } else if x == T::NEGATIVE_ONE {\n        if exp.even() { T::ONE } else { T::NEGATIVE_ONE }\n    } else if let Some(p) = x.checked_pow(exp) {\n        p\n    } else if x > T::ZERO || exp.even() {\n        T::MAX\n    } else {\n        T::MIN\n    }\n}\n\nmacro_rules! impl_saturating_pow_unsigned {\n    ($t:ident) => {\n        impl SaturatingPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `saturating_pow` functions in the standard library, for\n            /// example [this one](u32::saturating_pow).\n            #[inline]\n            fn saturating_pow(self, exp: u64) -> $t {\n                saturating_pow_unsigned(self, exp)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_saturating_pow_unsigned);\n\nmacro_rules! impl_saturating_pow_signed {\n    ($t:ident) => {\n        impl SaturatingPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `saturating_pow` functions in the standard library, for\n            /// example [this one](i32::saturating_pow).\n            #[inline]\n            fn saturating_pow(self, exp: u64) -> $t {\n                saturating_pow_signed(self, exp)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_saturating_pow_signed);\n\nmacro_rules! impl_saturating_pow_primitive_int {\n    ($t:ident) => {\n        impl SaturatingPowAssign<u64> for $t {\n            /// Raises a number to a power, in place, saturating at the numeric bounds instead of\n            /// overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x^y & \\text{if} \\\\quad m \\leq x^y \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x^y > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x^y < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_pow#saturating_pow_assign).\n            #[inline]\n            fn saturating_pow_assign(&mut self, exp: u64) {\n                *self = SaturatingPow::saturating_pow(*self, exp);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_saturating_pow_primitive_int);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    SaturatingMulAssign, SaturatingSquare, SaturatingSquareAssign,\n};\n\nmacro_rules! impl_saturating_square {\n    ($t:ident) => {\n        impl SaturatingSquare for $t {\n            type Output = $t;\n\n            /// Squares a number, saturating at the numeric bounds instead of overflowing.\n            ///\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     x^2 & \\text{if} \\\\quad x^2 \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x^2 > M,\n            /// \\\\end{cases}\n            /// $$\n            /// where $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_square#saturating_square).\n            #[inline]\n            fn saturating_square(self) -> $t {\n                self.saturating_mul(self)\n            }\n        }\n\n        impl SaturatingSquareAssign for $t {\n            /// Squares a number in place, saturating at the numeric bounds instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x^2 & \\text{if} \\\\quad x^2 \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x^2 > M,\n            /// \\\\end{cases}\n            /// $$\n            /// where $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_square#saturating_square_assign).\n            #[inline]\n            fn saturating_square_assign(&mut self) {\n                self.saturating_mul_assign(*self);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_saturating_square);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingSub, SaturatingSubAssign};\n\nmacro_rules! impl_saturating_sub {\n    ($t:ident) => {\n        impl SaturatingSub<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `saturating_sub` functions in the standard library, for\n            /// example [this one](i32::saturating_sub).\n            #[inline]\n            fn saturating_sub(self, other: $t) -> $t {\n                $t::saturating_sub(self, other)\n            }\n        }\n\n        impl SaturatingSubAssign<$t> for $t {\n            /// Subtracts a number by another number in place, saturating at the numeric bounds\n            /// instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x - y & \\text{if} \\\\quad m \\leq x - y \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x - y > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x - y < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_sub#saturating_sub_assign).\n            #[inline]\n            fn saturating_sub_assign(&mut self, other: $t) {\n                *self = self.saturating_sub(other);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_saturating_sub);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/saturating_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingSubMul, SaturatingSubMulAssign, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\nfn saturating_sub_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> T {\n    x.saturating_sub(y.saturating_mul(z))\n}\n\nfn saturating_sub_mul_assign_unsigned<T: PrimitiveUnsigned>(x: &mut T, y: T, z: T) {\n    x.saturating_sub_assign(y.saturating_mul(z));\n}\n\nmacro_rules! impl_saturating_sub_mul_unsigned {\n    ($t:ident) => {\n        impl SaturatingSubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers, saturating at the numeric\n            /// bounds instead of overflowing.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     x - yz & \\text{if} \\\\quad m \\leq x - yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x - yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x - yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_sub_mul#saturating_sub_mul_assign).\n            #[inline]\n            fn saturating_sub_mul(self, y: $t, z: $t) -> $t {\n                saturating_sub_mul_unsigned(self, y, z)\n            }\n        }\n\n        impl SaturatingSubMulAssign<$t> for $t {\n            /// Subtracts a number by the product of two other numbers in place, saturating at the\n            /// numeric bounds instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x - yz & \\text{if} \\\\quad m \\leq x - yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x - yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x - yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_sub_mul#saturating_sub_mul_assign).\n            #[inline]\n            fn saturating_sub_mul_assign(&mut self, y: $t, z: $t) {\n                saturating_sub_mul_assign_unsigned(self, y, z);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_saturating_sub_mul_unsigned);\n\nfn saturating_sub_mul_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: S,\n    y: S,\n    z: S,\n) -> S {\n    if y == S::ZERO || z == S::ZERO {\n        return x;\n    }\n    let x_sign = x >= S::ZERO;\n    if x_sign == ((y >= S::ZERO) != (z >= S::ZERO)) {\n        x.saturating_sub(y.saturating_mul(z))\n    } else {\n        let x = x.unsigned_abs();\n        let product = if let Some(product) = y.unsigned_abs().checked_mul(z.unsigned_abs()) {\n            product\n        } else {\n            return if x_sign { S::MIN } else { S::MAX };\n        };\n        let result = S::wrapping_from(if x_sign {\n            x.wrapping_sub(product)\n        } else {\n            product.wrapping_sub(x)\n        });\n        if x >= product || (x_sign == (result < S::ZERO)) {\n            result\n        } else if x_sign {\n            S::MIN\n        } else {\n            S::MAX\n        }\n    }\n}\n\nmacro_rules! impl_saturating_sub_mul_signed {\n    ($t:ident) => {\n        impl SaturatingSubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers, saturating at the numeric\n            /// bounds instead of overflowing.\n            ///\n            /// $$\n            /// f(x, y, z) = \\\\begin{cases}\n            ///     x - yz & \\text{if} \\\\quad m \\leq x - yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x - yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x - yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_sub_mul#saturating_sub_mul).\n            #[inline]\n            fn saturating_sub_mul(self, y: $t, z: $t) -> $t {\n                saturating_sub_mul_signed(self, y, z)\n            }\n        }\n\n        impl SaturatingSubMulAssign<$t> for $t {\n            /// Subtracts a number by the product of two other numbers in place, saturating at the\n            /// numeric bounds instead of overflowing.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     x - yz & \\text{if} \\\\quad m \\leq x - yz \\leq M, \\\\\\\\\n            ///     M & \\text{if} \\\\quad x - yz > M, \\\\\\\\\n            ///     m & \\text{if} \\\\quad x - yz < m,\n            /// \\\\end{cases}\n            /// $$\n            /// where $m$ is `Self::MIN` and $M$ is `Self::MAX`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::saturating_sub_mul#saturating_sub_mul_assign).\n            #[inline]\n            fn saturating_sub_mul_assign(&mut self, y: $t, z: $t) {\n                *self = self.saturating_sub_mul(y, z);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_saturating_sub_mul_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    ShlRound, ShlRoundAssign, ShrRound, ShrRoundAssign, UnsignedAbs,\n};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::rounding_modes::RoundingMode;\nuse core::cmp::Ordering::{self, *};\nuse core::ops::{Shl, ShlAssign};\n\nfn shl_round<\n    T: PrimitiveInt + Shl<U, Output = T> + ShrRound<U, Output = T>,\n    U,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    bits: S,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    if bits >= S::ZERO {\n        let width = S::wrapping_from(T::WIDTH);\n        (\n            if width >= S::ZERO && bits >= width {\n                T::ZERO\n            } else {\n                x << bits.unsigned_abs()\n            },\n            Equal,\n        )\n    } else {\n        x.shr_round(bits.unsigned_abs(), rm)\n    }\n}\n\nfn shl_round_assign<\n    T: PrimitiveInt + ShlAssign<U> + ShrRoundAssign<U>,\n    U,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: &mut T,\n    bits: S,\n    rm: RoundingMode,\n) -> Ordering {\n    if bits >= S::ZERO {\n        let width = S::wrapping_from(T::WIDTH);\n        if width >= S::ZERO && bits >= width {\n            *x = T::ZERO;\n        } else {\n            *x <<= bits.unsigned_abs();\n        }\n        Equal\n    } else {\n        x.shr_round_assign(bits.unsigned_abs(), rm)\n    }\n}\n\nmacro_rules! impl_shl_round {\n    ($t:ident) => {\n        macro_rules! impl_shl_round_inner {\n            ($u:ident) => {\n                impl ShlRound<$u> for $t {\n                    type Output = $t;\n\n                    /// Left-shifts a number (multiplies it by a power of 2 or divides it by a power\n                    /// of 2 and takes the floor) and rounds according to the specified rounding\n                    /// mode. An [`Ordering`] is also returned, indicating whether the returned\n                    /// value is less than, equal to, or greater than the exact value. If `bits` is\n                    /// non-negative, then the returned [`Ordering`] is always `Equal`, even if the\n                    /// higher bits of the result are lost.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `bits > 0 || self.divisible_by_power_of_2(bits)`.\n                    /// Rounding might only be necessary if `bits` is negative.\n                    ///\n                    /// Let $q = x2^k$, and let $g$ be the function that just returns the first\n                    /// element of the pair, without the [`Ordering`]:\n                    ///\n                    /// $g(x, k, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n                    ///\n                    /// $g(x, k, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n                    ///\n                    /// $$\n                    /// g(x, k, \\mathrm{Nearest}) = \\begin{cases}\n                    ///     \\lfloor q \\rfloor & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n                    ///     \\lceil q \\rceil & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n                    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n                    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n                    ///     \\\\ \\text{is even}, \\\\\\\\\n                    ///     \\lceil q \\rceil &\n                    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n                    ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n                    /// \\end{cases}\n                    /// $$\n                    ///\n                    /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n                    ///\n                    /// Then\n                    ///\n                    /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `bits` is positive and `rm` is `Exact` but `self` is not divisible\n                    /// by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shl_round#shl_round).\n                    #[inline]\n                    fn shl_round(self, bits: $u, rm: RoundingMode) -> ($t, Ordering) {\n                        shl_round(self, bits, rm)\n                    }\n                }\n\n                impl ShlRoundAssign<$u> for $t {\n                    /// Left-shifts a number (multiplies it by a power of 2 or divides it by a power\n                    /// of 2 and takes the floor) and rounds according to the specified rounding\n                    /// mode, in place. An [`Ordering`] is returned, indicating whether the assigned\n                    /// value is less than, equal to, or greater than the exact value. If `bits` is\n                    /// non-negative, then the returned [`Ordering`] is always `Equal`, even if the\n                    /// higher bits of the result are lost.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `bits > 0 || self.divisible_by_power_of_2(bits)`.\n                    /// Rounding might only be necessary if `bits` is negative.\n                    ///\n                    /// See the [`ShlRound`] documentation for details.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `bits` is positive and `rm` is `Exact` but `self` is not divisible\n                    /// by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shl_round#shl_round_assign).\n                    #[inline]\n                    fn shl_round_assign(&mut self, bits: $u, rm: RoundingMode) -> Ordering {\n                        shl_round_assign(self, bits, rm)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_shl_round_inner);\n    };\n}\napply_to_primitive_ints!(impl_shl_round);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ShrRound, ShrRoundAssign, UnsignedAbs};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse core::cmp::Ordering::{self, *};\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\n\nfn shr_round_unsigned_unsigned<\n    T: PrimitiveUnsigned + Shl<U, Output = T> + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n>(\n    x: T,\n    bits: U,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    if bits == U::ZERO || x == T::ZERO {\n        return (x, Equal);\n    }\n    let width = U::wrapping_from(T::WIDTH);\n    match rm {\n        Down | Floor if bits >= width => (T::ZERO, Less),\n        Down | Floor => {\n            let shifted = x >> bits;\n            (shifted, if shifted << bits == x { Equal } else { Less })\n        }\n        Up | Ceiling if bits >= width => (T::ONE, Greater),\n        Up | Ceiling => {\n            let shifted = x >> bits;\n            if shifted << bits == x {\n                (shifted, Equal)\n            } else {\n                (shifted + T::ONE, Greater)\n            }\n        }\n        Nearest if bits == width && x > T::power_of_2(T::WIDTH - 1) => (T::ONE, Greater),\n        Nearest if bits >= width => (T::ZERO, Less),\n        Nearest => {\n            let bm1 = bits - U::ONE;\n            let mostly_shifted = x >> bm1;\n            let bm1_zeros = mostly_shifted << bm1 == x;\n            if mostly_shifted.even() {\n                // round down\n                (mostly_shifted >> 1, if bm1_zeros { Equal } else { Less })\n            } else if !bm1_zeros {\n                // round up\n                ((mostly_shifted >> 1) + T::ONE, Greater)\n            } else {\n                // result is half-integer; round to even\n                let shifted: T = mostly_shifted >> 1;\n                if shifted.even() {\n                    (shifted, Less)\n                } else {\n                    (shifted + T::ONE, Greater)\n                }\n            }\n        }\n        Exact if bits >= width => {\n            panic!(\"Right shift is not exact: {x} >> {bits}\");\n        }\n        Exact => {\n            let shifted = x >> bits;\n            assert!(\n                shifted << bits == x,\n                \"Right shift is not exact: {x} >> {bits}\"\n            );\n            (shifted, Equal)\n        }\n    }\n}\n\nfn shr_round_assign_unsigned_unsigned<\n    T: PrimitiveUnsigned + Shl<U, Output = T> + ShrAssign<U>,\n    U: PrimitiveUnsigned,\n>(\n    x: &mut T,\n    bits: U,\n    rm: RoundingMode,\n) -> Ordering {\n    if bits == U::ZERO || *x == T::ZERO {\n        return Equal;\n    }\n    let width = U::wrapping_from(T::WIDTH);\n    match rm {\n        Down | Floor if bits >= width => {\n            *x = T::ZERO;\n            Less\n        }\n        Down | Floor => {\n            let original = *x;\n            *x >>= bits;\n            if *x << bits == original { Equal } else { Less }\n        }\n        Up | Ceiling if bits >= width => {\n            *x = T::ONE;\n            Greater\n        }\n        Up | Ceiling => {\n            let original = *x;\n            *x >>= bits;\n            if *x << bits == original {\n                Equal\n            } else {\n                *x += T::ONE;\n                Greater\n            }\n        }\n        Nearest if bits == width && *x > T::power_of_2(T::WIDTH - 1) => {\n            *x = T::ONE;\n            Greater\n        }\n        Nearest if bits >= width => {\n            *x = T::ZERO;\n            Less\n        }\n        Nearest => {\n            let original = *x;\n            let bm1 = bits - U::ONE;\n            *x >>= bm1;\n            let bm1_zeros = *x << bm1 == original;\n            let old_x = *x;\n            *x >>= 1;\n            if old_x.even() {\n                // round down\n                if bm1_zeros { Equal } else { Less }\n            } else if !bm1_zeros {\n                // round up\n                *x += T::ONE;\n                Greater\n            } else {\n                // result is half-integer; round to even\n                if x.even() {\n                    Less\n                } else {\n                    *x += T::ONE;\n                    Greater\n                }\n            }\n        }\n        Exact if bits >= width => {\n            panic!(\"Right shift is not exact: {} >>= {}\", *x, bits);\n        }\n        Exact => {\n            let original = *x;\n            *x >>= bits;\n            assert!(\n                *x << bits == original,\n                \"Right shift is not exact: {original} >>= {bits}\"\n            );\n            Equal\n        }\n    }\n}\n\nmacro_rules! impl_shr_round_unsigned_unsigned {\n    ($t:ident) => {\n        macro_rules! impl_shr_round_unsigned_unsigned_inner {\n            ($u:ident) => {\n                impl ShrRound<$u> for $t {\n                    type Output = $t;\n\n                    /// Shifts a number right (divides it by a power of 2) and rounds according to\n                    /// the specified rounding mode. An [`Ordering`] is also returned, indicating\n                    /// whether the returned value is less than, equal to, or greater than the exact\n                    /// value.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `self.divisible_by_power_of_2(bits)`.\n                    ///\n                    /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the\n                    /// first element of the pair, without the [`Ordering`]:\n                    ///\n                    /// $g(x, k, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n                    ///\n                    /// $g(x, k, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n                    ///\n                    /// $$\n                    /// g(x, k, \\mathrm{Nearest}) = \\begin{cases}\n                    ///     \\lfloor q \\rfloor & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n                    ///     \\lceil q \\rceil & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n                    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n                    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n                    ///     \\\\ \\text{is even}, \\\\\\\\\n                    ///     \\lceil q \\rceil &\n                    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n                    ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n                    /// \\end{cases}\n                    /// $$\n                    ///\n                    /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n                    ///\n                    /// Then\n                    ///\n                    /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `rm` is `Exact` but `self` is not divisible by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shr_round#shr_round).\n                    #[inline]\n                    fn shr_round(self, bits: $u, rm: RoundingMode) -> ($t, Ordering) {\n                        shr_round_unsigned_unsigned(self, bits, rm)\n                    }\n                }\n\n                impl ShrRoundAssign<$u> for $t {\n                    /// Shifts a number right (divides it by a power of 2) and rounds according to\n                    /// the specified rounding mode, in place. An [`Ordering`] is returned,\n                    /// indicating whether the assigned value is less than, equal to, or greater\n                    /// than the exact value.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `self.divisible_by_power_of_2(bits)`.\n                    ///\n                    /// See the [`ShrRound`] documentation for details.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `rm` is `Exact` but `self` is not divisible by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shr_round#shr_round_assign).\n                    #[inline]\n                    fn shr_round_assign(&mut self, bits: $u, rm: RoundingMode) -> Ordering {\n                        shr_round_assign_unsigned_unsigned(self, bits, rm)\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_shr_round_unsigned_unsigned_inner);\n    };\n}\napply_to_unsigneds!(impl_shr_round_unsigned_unsigned);\n\nfn shr_round_signed_unsigned<\n    U: PrimitiveUnsigned + ShrRound<B, Output = U>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n    B,\n>(\n    x: S,\n    bits: B,\n    rm: RoundingMode,\n) -> (S, Ordering) {\n    let abs = x.unsigned_abs();\n    if x >= S::ZERO {\n        let (abs_shifted, o) = abs.shr_round(bits, rm);\n        (S::wrapping_from(abs_shifted), o)\n    } else {\n        let (abs_shifted, o) = abs.shr_round(bits, -rm);\n        (\n            if abs_shifted == U::ZERO {\n                S::ZERO\n            } else if abs_shifted == S::MIN.unsigned_abs() {\n                S::MIN\n            } else {\n                -S::wrapping_from(abs_shifted)\n            },\n            o.reverse(),\n        )\n    }\n}\n\nmacro_rules! impl_shr_round_signed_unsigned {\n    ($t:ident) => {\n        macro_rules! impl_shr_round_signed_unsigned_inner {\n            ($u:ident) => {\n                impl ShrRound<$u> for $t {\n                    type Output = $t;\n\n                    /// Shifts a number right (divides it by a power of 2) and rounds according to\n                    /// the specified rounding mode. An [`Ordering`] is also returned, indicating\n                    /// whether the returned value is less than, equal to, or greater than the exact\n                    /// value.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `self.divisible_by_power_of_2(bits)`.\n                    ///\n                    /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the\n                    /// first element of the pair, without the [`Ordering`]:\n                    ///\n                    /// $g(x, k, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n                    ///\n                    /// $g(x, k, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n                    ///\n                    /// $$\n                    /// g(x, k, \\mathrm{Nearest}) = \\begin{cases}\n                    ///     \\lfloor q \\rfloor & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n                    ///     \\lceil q \\rceil & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n                    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n                    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n                    ///     \\\\ \\text{is even}, \\\\\\\\\n                    ///     \\lceil q \\rceil &\n                    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n                    ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n                    /// \\end{cases}\n                    /// $$\n                    ///\n                    /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n                    ///\n                    /// Then\n                    ///\n                    /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `rm` is `Exact` but `self` is not divisible by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shr_round#shr_round).\n                    #[inline]\n                    fn shr_round(self, bits: $u, rm: RoundingMode) -> ($t, Ordering) {\n                        shr_round_signed_unsigned(self, bits, rm)\n                    }\n                }\n\n                impl ShrRoundAssign<$u> for $t {\n                    /// Shifts a number right (divides it by a power of 2) and rounds according to\n                    /// the specified rounding mode, in place. An [`Ordering`] isreturned,\n                    /// indicating whether the assigned value is less than, equal to, or greater\n                    /// than the exact value.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `self.divisible_by_power_of_2(bits)`.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `rm` is `Exact` but `self` is not divisible by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shr_round#shr_round_assign).\n                    #[inline]\n                    fn shr_round_assign(&mut self, bits: $u, rm: RoundingMode) -> Ordering {\n                        let o;\n                        (*self, o) = self.shr_round(bits, rm);\n                        o\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_shr_round_signed_unsigned_inner);\n    };\n}\napply_to_signeds!(impl_shr_round_signed_unsigned);\n\nfn shr_round_primitive_signed<\n    T: PrimitiveInt + Shl<U, Output = T> + ShrRound<U, Output = T>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: T,\n    bits: S,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    if bits >= S::ZERO {\n        x.shr_round(bits.unsigned_abs(), rm)\n    } else {\n        let abs = bits.unsigned_abs();\n        (\n            if abs >= U::wrapping_from(T::WIDTH) {\n                T::ZERO\n            } else {\n                x << bits.unsigned_abs()\n            },\n            Equal,\n        )\n    }\n}\n\nfn shr_round_assign_primitive_signed<\n    T: PrimitiveInt + ShlAssign<U> + ShrRoundAssign<U>,\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: &mut T,\n    bits: S,\n    rm: RoundingMode,\n) -> Ordering {\n    if bits >= S::ZERO {\n        x.shr_round_assign(bits.unsigned_abs(), rm)\n    } else {\n        let abs = bits.unsigned_abs();\n        if abs >= U::wrapping_from(T::WIDTH) {\n            *x = T::ZERO;\n        } else {\n            *x <<= bits.unsigned_abs();\n        }\n        Equal\n    }\n}\n\nmacro_rules! impl_shr_round_primitive_signed {\n    ($t:ident) => {\n        macro_rules! impl_shr_round_primitive_signed_inner {\n            ($u:ident) => {\n                impl ShrRound<$u> for $t {\n                    type Output = $t;\n\n                    /// Shifts a number right (divides it by a power of 2) and rounds according to\n                    /// the specified rounding mode. An [`Ordering`] is also returned, indicating\n                    /// whether the returned value is less than, equal to, or greater than the exact\n                    /// value. If `bits` is negative, then the returned [`Ordering`] is always\n                    /// `Equal`, even if the higher bits of the result are lost.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `self.divisible_by_power_of_2(bits)`. Rounding\n                    /// might only be necessary if `bits` is non-negative.\n                    ///\n                    /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the\n                    /// first element of the pair, without the [`Ordering`]:\n                    ///\n                    /// $g(x, k, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n                    ///\n                    /// $g(x, k, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n                    ///\n                    /// $g(x, k, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n                    ///\n                    /// $g(x, k, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n                    ///\n                    /// $$\n                    /// g(x, k, \\mathrm{Nearest}) = \\begin{cases}\n                    ///     \\lfloor q \\rfloor & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n                    ///     \\lceil q \\rceil & \\text{if}\n                    ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n                    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n                    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n                    ///     \\\\ \\text{is even}, \\\\\\\\\n                    ///     \\lceil q \\rceil &\n                    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n                    ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n                    /// \\end{cases}\n                    /// $$\n                    ///\n                    /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n                    ///\n                    /// Then\n                    ///\n                    /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `bits` is positive and `rm` is `Exact` but `self` is not divisible\n                    /// by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shr_round#shr_round).\n                    #[inline]\n                    fn shr_round(self, bits: $u, rm: RoundingMode) -> ($t, Ordering) {\n                        shr_round_primitive_signed(self, bits, rm)\n                    }\n                }\n\n                impl ShrRoundAssign<$u> for $t {\n                    /// Shifts a number right (divides it by a power of 2) and rounds according to\n                    /// the specified rounding mode, in place. An [`Ordering`] is returned,\n                    /// indicating whether the assigned value is less than, equal to, or greater\n                    /// than the exact value. If `bits` is negative, then the returned [`Ordering`]\n                    /// is always `Equal`, even if the higher bits of the result are lost.\n                    ///\n                    /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether\n                    /// `Exact` can be passed, use `self.divisible_by_power_of_2(bits)`. Rounding\n                    /// might only be necessary if `bits` is non-negative.\n                    ///\n                    /// See the [`ShrRound`] documentation for details.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `bits` is positive and `rm` is `Exact` but `self` is not divisible\n                    /// by $2^b$.\n                    ///\n                    /// # Examples\n                    /// See [here](super::shr_round#shr_round_assign).\n                    #[inline]\n                    fn shr_round_assign(&mut self, bits: $u, rm: RoundingMode) -> Ordering {\n                        shr_round_assign_primitive_signed(self, bits, rm)\n                    }\n                }\n            };\n        }\n        apply_to_signeds!(impl_shr_round_primitive_signed_inner);\n    };\n}\napply_to_primitive_ints!(impl_shr_round_primitive_signed);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::Sign;\nuse core::cmp::Ordering::{self, *};\n\nmacro_rules! impl_sign_primitive_int {\n    ($t:ident) => {\n        impl Sign for $t {\n            /// Compares a number to zero.\n            ///\n            /// Returns `Greater`, `Equal`, or `Less`, depending on whether the number is positive,\n            /// zero, or negative, respectively.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sign#sign).\n            #[inline]\n            fn sign(&self) -> Ordering {\n                self.cmp(&0)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_sign_primitive_int);\n\nmacro_rules! impl_sign_primitive_float {\n    ($t:ident) => {\n        impl Sign for $t {\n            /// Compares a number to zero.\n            ///\n            /// - Positive finite numbers, positive zero, and positive infinity have sign `Greater`.\n            /// - Negative finite numbers, negative zero, and negative infinity have sign `Less`.\n            /// - `NaN` has sign `Equal`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sign#sign).\n            #[inline]\n            fn sign(&self) -> Ordering {\n                if self.is_nan() {\n                    Equal\n                } else if self.is_sign_positive() {\n                    Greater\n                } else {\n                    Less\n                }\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_sign_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_sqrtrem1` contributed to the GNU project by Torbjörn Granlund.\n//\n//      Copyright © 1999-2002, 2004, 2005, 2008, 2010, 2012, 2015, 2017 Free Software Foundation,\n//      Inc.\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    CeilingSqrt, CeilingSqrtAssign, CheckedSqrt, FloorSqrt, FloorSqrtAssign,\n    RoundToMultipleOfPowerOf2, ShrRound, Sqrt, SqrtAssign, SqrtAssignRem, SqrtRem,\n};\nuse crate::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::logic::traits::SignificantBits;\nuse crate::rounding_modes::RoundingMode::*;\nuse core::cmp::Ordering::*;\n\nconst U8_SQUARES: [u8; 16] = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225];\n\nimpl FloorSqrt for u8 {\n    type Output = Self;\n\n    /// Returns the floor of the square root of a [`u8`].\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#floor_sqrt).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses a lookup table.\n    fn floor_sqrt(self) -> Self {\n        Self::wrapping_from(match U8_SQUARES.binary_search(&self) {\n            Ok(i) => i,\n            Err(i) => i - 1,\n        })\n    }\n}\n\nimpl CeilingSqrt for u8 {\n    type Output = Self;\n\n    /// Returns the ceiling of the square root of a [`u8`].\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#ceiling_sqrt).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses a lookup table.\n    fn ceiling_sqrt(self) -> Self {\n        Self::wrapping_from(match U8_SQUARES.binary_search(&self) {\n            Ok(i) | Err(i) => i,\n        })\n    }\n}\n\nimpl CheckedSqrt for u8 {\n    type Output = Self;\n\n    /// Returns the the square root of a [`u8`], or `None` if the [`u8`] is not a perfect square.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#checked_sqrt).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses a lookup table.\n    fn checked_sqrt(self) -> Option<Self> {\n        U8_SQUARES\n            .binary_search(&self)\n            .ok()\n            .map(Self::wrapping_from)\n    }\n}\n\nimpl SqrtRem for u8 {\n    type SqrtOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the square root of a [`u8`], and the remainder (the difference between\n    /// the [`u8`] and the square of the floor).\n    ///\n    /// $f(x) = (\\lfloor\\sqrt{x}\\rfloor, x - \\lfloor\\sqrt{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#sqrt_rem).\n    ///\n    /// # Notes\n    /// The [`u8`] implementation uses a lookup table.\n    fn sqrt_rem(self) -> (Self, Self) {\n        match U8_SQUARES.binary_search(&self) {\n            Ok(i) => (Self::wrapping_from(i), 0),\n            Err(i) => (Self::wrapping_from(i - 1), self - U8_SQUARES[i - 1]),\n        }\n    }\n}\n\npub(crate) fn floor_inverse_checked_binary<T: PrimitiveUnsigned, F: Fn(T) -> Option<T>>(\n    f: F,\n    x: T,\n    mut low: T,\n    mut high: T,\n) -> T {\n    loop {\n        if high <= low {\n            return low;\n        }\n        let mid: T = low.checked_add(high).unwrap().shr_round(1, Ceiling).0;\n        match f(mid).map(|mid| mid.cmp(&x)) {\n            Some(Equal) => return mid,\n            Some(Less) => low = mid,\n            Some(Greater) | None => high = mid - T::ONE,\n        }\n    }\n}\n\npub_test! {floor_sqrt_binary<T: PrimitiveUnsigned>(x: T) -> T {\n    if x < T::TWO {\n        x\n    } else {\n        let p = T::power_of_2(x.significant_bits().shr_round(1, Ceiling).0);\n        floor_inverse_checked_binary(T::checked_square, x, p >> 1, p)\n    }\n}}\n\npub_test! {ceiling_sqrt_binary<T: PrimitiveUnsigned>(x: T) -> T {\n    let floor_sqrt = floor_sqrt_binary(x);\n    if floor_sqrt.square() == x {\n        floor_sqrt\n    } else {\n        floor_sqrt + T::ONE\n    }\n}}\n\npub_test! {checked_sqrt_binary<T: PrimitiveUnsigned>(x: T) -> Option<T> {\n    let floor_sqrt = floor_sqrt_binary(x);\n    if floor_sqrt.square() == x {\n        Some(floor_sqrt)\n    } else {\n        None\n    }\n}}\n\npub_test! {sqrt_rem_binary<T: PrimitiveUnsigned>(x: T) -> (T, T) {\n    let floor_sqrt = floor_sqrt_binary(x);\n    (floor_sqrt, x - floor_sqrt.square())\n}}\n\nconst INV_SQRT_TAB: [u16; 384] = [\n    0xff, 0xfd, 0xfb, 0xf9, 0xf7, 0xf5, 0xf3, 0xf2, 0xf0, 0xee, 0xec, 0xea, 0xe9, 0xe7, 0xe5, 0xe4,\n    0xe2, 0xe0, 0xdf, 0xdd, 0xdb, 0xda, 0xd8, 0xd7, 0xd5, 0xd4, 0xd2, 0xd1, 0xcf, 0xce, 0xcc, 0xcb,\n    0xc9, 0xc8, 0xc6, 0xc5, 0xc4, 0xc2, 0xc1, 0xc0, 0xbe, 0xbd, 0xbc, 0xba, 0xb9, 0xb8, 0xb7, 0xb5,\n    0xb4, 0xb3, 0xb2, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3,\n    0xa2, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92,\n    0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83,\n    0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x79, 0x78, 0x77, 0x76,\n    0x76, 0x75, 0x74, 0x73, 0x72, 0x72, 0x71, 0x70, 0x6f, 0x6f, 0x6e, 0x6d, 0x6d, 0x6c, 0x6b, 0x6a,\n    0x6a, 0x69, 0x68, 0x68, 0x67, 0x66, 0x66, 0x65, 0x64, 0x64, 0x63, 0x62, 0x62, 0x61, 0x60, 0x60,\n    0x5f, 0x5e, 0x5e, 0x5d, 0x5c, 0x5c, 0x5b, 0x5a, 0x5a, 0x59, 0x59, 0x58, 0x57, 0x57, 0x56, 0x56,\n    0x55, 0x54, 0x54, 0x53, 0x53, 0x52, 0x52, 0x51, 0x50, 0x50, 0x4f, 0x4f, 0x4e, 0x4e, 0x4d, 0x4d,\n    0x4c, 0x4b, 0x4b, 0x4a, 0x4a, 0x49, 0x49, 0x48, 0x48, 0x47, 0x47, 0x46, 0x46, 0x45, 0x45, 0x44,\n    0x44, 0x43, 0x43, 0x42, 0x42, 0x41, 0x41, 0x40, 0x40, 0x3f, 0x3f, 0x3e, 0x3e, 0x3d, 0x3d, 0x3c,\n    0x3c, 0x3b, 0x3b, 0x3a, 0x3a, 0x39, 0x39, 0x39, 0x38, 0x38, 0x37, 0x37, 0x36, 0x36, 0x35, 0x35,\n    0x35, 0x34, 0x34, 0x33, 0x33, 0x32, 0x32, 0x32, 0x31, 0x31, 0x30, 0x30, 0x2f, 0x2f, 0x2f, 0x2e,\n    0x2e, 0x2d, 0x2d, 0x2d, 0x2c, 0x2c, 0x2b, 0x2b, 0x2b, 0x2a, 0x2a, 0x29, 0x29, 0x29, 0x28, 0x28,\n    0x27, 0x27, 0x27, 0x26, 0x26, 0x26, 0x25, 0x25, 0x24, 0x24, 0x24, 0x23, 0x23, 0x23, 0x22, 0x22,\n    0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e, 0x1d, 0x1d, 0x1d, 0x1c,\n    0x1c, 0x1b, 0x1b, 0x1b, 0x1a, 0x1a, 0x1a, 0x19, 0x19, 0x19, 0x18, 0x18, 0x18, 0x18, 0x17, 0x17,\n    0x17, 0x16, 0x16, 0x16, 0x15, 0x15, 0x15, 0x14, 0x14, 0x14, 0x13, 0x13, 0x13, 0x12, 0x12, 0x12,\n    0x12, 0x11, 0x11, 0x11, 0x10, 0x10, 0x10, 0x0f, 0x0f, 0x0f, 0x0f, 0x0e, 0x0e, 0x0e, 0x0d, 0x0d,\n    0x0d, 0x0c, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0a, 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x09, 0x09,\n    0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04,\n    0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\n];\n\n// This is equivalent to `mpn_sqrtrem1` from `mpn/generic/sqrtrem.c`, GMP 6.2.1, where both the\n// square root and the remainder are returned.\n#[doc(hidden)]\npub fn sqrt_rem_newton<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    n: U,\n) -> (U, U) {\n    let magic = match U::WIDTH {\n        u32::WIDTH => {\n            U::wrapping_from(0x100000u32) // 0xfee6f < MAGIC < 0x29cbc8\n        }\n        u64::WIDTH => {\n            U::wrapping_from(0x10000000000u64) // 0xffe7debbfc < magic < 0x232b1850f410\n        }\n        _ => panic!(),\n    };\n    assert!(n.leading_zeros() < 2);\n    // Use Newton iterations for approximating 1/sqrt(a) instead of sqrt(a), since we can do the\n    // former without division. As part of the last iteration convert from 1/sqrt(a) to sqrt(a).\n    let i: usize = (n >> (U::WIDTH - 9)).wrapping_into(); // extract bits for table lookup\n    let mut inv_sqrt = U::wrapping_from(INV_SQRT_TAB[i - 0x80]);\n    inv_sqrt.set_bit(8); // initial 1/sqrt(a)\n    let mut sqrt: U = match U::WIDTH {\n        u32::WIDTH => {\n            let p = inv_sqrt * (n >> 8);\n            let t: U = p >> 13;\n            let a: U = n << 6;\n            let t = S::wrapping_from(a.wrapping_sub(t.wrapping_square()).wrapping_sub(magic)) >> 8;\n            p.wrapping_add(U::wrapping_from((S::wrapping_from(inv_sqrt) * t) >> 7)) >> 16\n        }\n        u64::WIDTH => {\n            let a1 = n >> (U::WIDTH - 33);\n            let t = (S::wrapping_from(0x2000000000000u64 - 0x30000)\n                - S::wrapping_from(a1 * inv_sqrt.square()))\n                >> 16;\n            let a: U = inv_sqrt << 16;\n            inv_sqrt = a.wrapping_add(U::wrapping_from((S::wrapping_from(inv_sqrt) * t) >> 18));\n            let p = inv_sqrt * (n >> 24);\n            let t: U = p >> 25;\n            let a: U = n << 14;\n            let t = S::wrapping_from(a.wrapping_sub(t.wrapping_square()).wrapping_sub(magic)) >> 24;\n            p.wrapping_add(U::wrapping_from((S::wrapping_from(inv_sqrt) * t) >> 15)) >> 32\n        }\n        _ => unreachable!(),\n    };\n    // x0 is now a full limb approximation of sqrt(a0)\n    let mut square = sqrt.square();\n    if square + (sqrt << 1) < n {\n        square += (sqrt << 1) + U::ONE;\n        sqrt += U::ONE;\n    }\n    (sqrt, n - square)\n}\n\n// Returns (sqrt, r_hi, r_lo) such that [n_lo, n_hi] = sqrt ^ 2 + [r_lo, r_hi].\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_sqrtrem2` from `mpn/generic/sqrtrem.c`, GMP 6.2.1.\npub fn sqrt_rem_2_newton<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    n_hi: U,\n    n_lo: U,\n) -> (U, bool, U) {\n    assert!(n_hi.leading_zeros() < 2);\n    let (mut sqrt, mut r_lo) = sqrt_rem_newton::<U, S>(n_hi);\n    let prec = U::WIDTH >> 1;\n    let prec_p_1: u64 = prec + 1;\n    let prec_m_1: u64 = prec - 1;\n    // r_lo <= 2 * sqrt < 2 ^ (prec + 1)\n    r_lo = (r_lo << prec_m_1) | (n_lo >> prec_p_1);\n    let mut q = r_lo / sqrt;\n    // q <= 2 ^ prec, if q = 2 ^ prec, reduce the overestimate.\n    q -= q >> prec;\n    // now we have q < 2 ^ prec\n    let u = r_lo - q * sqrt;\n    // now we have (rp_lo << prec + n_lo >> prec) / 2 = q * sqrt + u\n    sqrt = (sqrt << prec) | q;\n    let mut r_hi = (u >> prec_m_1) + U::ONE;\n    r_lo = (u << prec_p_1) | (n_lo.mod_power_of_2(prec_p_1));\n    let q_squared = q.square();\n    if r_lo < q_squared {\n        assert_ne!(r_hi, U::ZERO);\n        r_hi -= U::ONE;\n    }\n    r_lo.wrapping_sub_assign(q_squared);\n    if r_hi == U::ZERO {\n        r_lo.wrapping_add_assign(sqrt);\n        if r_lo < sqrt {\n            r_hi += U::ONE;\n        }\n        sqrt -= U::ONE;\n        r_lo.wrapping_add_assign(sqrt);\n        if r_lo < sqrt {\n            r_hi += U::ONE;\n        }\n    }\n    r_hi -= U::ONE;\n    assert!(r_hi < U::TWO);\n    (sqrt, r_hi == U::ONE, r_lo)\n}\n\n// This is equivalent to `n_sqrt` from `ulong_extras/sqrt.c`, FLINT 2.7.1.\nfn floor_sqrt_approx_and_refine<T: PrimitiveUnsigned, F: Fn(T) -> f64, G: Fn(f64) -> T>(\n    f: F,\n    g: G,\n    max_square: T,\n    x: T,\n) -> T {\n    if x >= max_square {\n        return T::low_mask(T::WIDTH >> 1);\n    }\n    let mut sqrt = g(f(x).sqrt());\n    let mut square = if let Some(square) = sqrt.checked_square() {\n        square\n    } else {\n        // set to max possible sqrt\n        sqrt = T::low_mask(T::WIDTH >> 1);\n        sqrt.square()\n    };\n    match square.cmp(&x) {\n        Equal => sqrt,\n        Less => loop {\n            square = square.checked_add((sqrt << 1) + T::ONE).unwrap();\n            sqrt += T::ONE;\n            match square.cmp(&x) {\n                Equal => return sqrt,\n                Less => {}\n                Greater => return sqrt - T::ONE,\n            }\n        },\n        Greater => loop {\n            square -= (sqrt << 1) - T::ONE;\n            sqrt -= T::ONE;\n            if square <= x {\n                return sqrt;\n            }\n        },\n    }\n}\n\nfn ceiling_sqrt_approx_and_refine<T: PrimitiveUnsigned, F: Fn(T) -> f64, G: Fn(f64) -> T>(\n    f: F,\n    g: G,\n    max_square: T,\n    x: T,\n) -> T {\n    if x > max_square {\n        return T::power_of_2(T::WIDTH >> 1);\n    }\n    let mut sqrt = g(f(x).sqrt());\n    let mut square = if let Some(square) = sqrt.checked_square() {\n        square\n    } else {\n        // set to max possible sqrt\n        sqrt = T::low_mask(T::WIDTH >> 1);\n        sqrt.square()\n    };\n    match square.cmp(&x) {\n        Equal => sqrt,\n        Less => loop {\n            square = square.checked_add((sqrt << 1) + T::ONE).unwrap();\n            sqrt += T::ONE;\n            if square >= x {\n                return sqrt;\n            }\n        },\n        Greater => loop {\n            square -= (sqrt << 1) - T::ONE;\n            sqrt -= T::ONE;\n            match square.cmp(&x) {\n                Equal => return sqrt,\n                Greater => {}\n                Less => return sqrt + T::ONE,\n            }\n        },\n    }\n}\n\nfn checked_sqrt_approx_and_refine<T: PrimitiveUnsigned, F: Fn(T) -> f64, G: Fn(f64) -> T>(\n    f: F,\n    g: G,\n    max_square: T,\n    x: T,\n) -> Option<T> {\n    if x > max_square {\n        return None;\n    }\n    let mut sqrt = g(f(x).sqrt());\n    let mut square = if let Some(square) = sqrt.checked_square() {\n        square\n    } else {\n        // set to max possible sqrt\n        sqrt = T::low_mask(T::WIDTH >> 1);\n        sqrt.square()\n    };\n    match square.cmp(&x) {\n        Equal => Some(sqrt),\n        Less => loop {\n            square = square.checked_add((sqrt << 1) + T::ONE).unwrap();\n            sqrt += T::ONE;\n            match square.cmp(&x) {\n                Equal => return Some(sqrt),\n                Less => {}\n                Greater => return None,\n            }\n        },\n        Greater => loop {\n            square -= (sqrt << 1) - T::ONE;\n            sqrt -= T::ONE;\n            match square.cmp(&x) {\n                Equal => return Some(sqrt),\n                Less => return None,\n                Greater => {}\n            }\n        },\n    }\n}\n\n// This is equivalent to `n_sqrtrem` from `ulong_extras/sqrtrem.c`, FLINT 2.7.1.\nfn sqrt_rem_approx_and_refine<T: PrimitiveUnsigned, F: Fn(T) -> f64, G: Fn(f64) -> T>(\n    f: F,\n    g: G,\n    max_square: T,\n    x: T,\n) -> (T, T) {\n    if x >= max_square {\n        return (T::low_mask(T::WIDTH >> 1), x - max_square);\n    }\n    let mut sqrt = g(f(x).sqrt());\n    let mut square = if let Some(square) = sqrt.checked_square() {\n        square\n    } else {\n        // set to max possible sqrt\n        sqrt = T::low_mask(T::WIDTH >> 1);\n        sqrt.square()\n    };\n    match square.cmp(&x) {\n        Equal => (sqrt, T::ZERO),\n        Less => loop {\n            square = square.checked_add((sqrt << 1) + T::ONE).unwrap();\n            sqrt += T::ONE;\n            match square.cmp(&x) {\n                Equal => return (sqrt, T::ZERO),\n                Less => {}\n                Greater => {\n                    square -= (sqrt << 1) - T::ONE;\n                    sqrt -= T::ONE;\n                    return (sqrt, x - square);\n                }\n            }\n        },\n        Greater => loop {\n            square -= (sqrt << 1) - T::ONE;\n            sqrt -= T::ONE;\n            if square <= x {\n                return (sqrt, x - square);\n            }\n        },\n    }\n}\n\nfn floor_sqrt_newton_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    x: U,\n) -> U {\n    if x == U::ZERO {\n        return U::ZERO;\n    }\n    let shift = x\n        .leading_zeros()\n        .round_to_multiple_of_power_of_2(1, Floor)\n        .0;\n    sqrt_rem_newton::<U, S>(x << shift).0 >> (shift >> 1)\n}\n\nfn ceiling_sqrt_newton_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    x: U,\n) -> U {\n    if x == U::ZERO {\n        return U::ZERO;\n    }\n    let shift = x\n        .leading_zeros()\n        .round_to_multiple_of_power_of_2(1, Floor)\n        .0;\n    let (mut sqrt, rem) = sqrt_rem_newton::<U, S>(x << shift);\n    sqrt >>= shift >> 1;\n    if rem != U::ZERO {\n        sqrt += U::ONE;\n    }\n    sqrt\n}\n\nfn checked_sqrt_newton_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    x: U,\n) -> Option<U> {\n    if x == U::ZERO {\n        return Some(U::ZERO);\n    }\n    let shift = x\n        .leading_zeros()\n        .round_to_multiple_of_power_of_2(1, Floor)\n        .0;\n    let (sqrt, rem) = sqrt_rem_newton::<U, S>(x << shift);\n    if rem == U::ZERO {\n        Some(sqrt >> (shift >> 1))\n    } else {\n        None\n    }\n}\n\nfn sqrt_rem_newton_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    x: U,\n) -> (U, U) {\n    if x == U::ZERO {\n        return (U::ZERO, U::ZERO);\n    }\n    let shift = x\n        .leading_zeros()\n        .round_to_multiple_of_power_of_2(1, Floor)\n        .0;\n    let (mut sqrt, rem) = sqrt_rem_newton::<U, S>(x << shift);\n    if shift == 0 {\n        (sqrt, rem)\n    } else {\n        sqrt >>= shift >> 1;\n        (sqrt, x - sqrt.square())\n    }\n}\n\nmacro_rules! impl_sqrt_newton {\n    ($u: ident, $s: ident) => {\n        impl FloorSqrt for $u {\n            type Output = $u;\n\n            /// Returns the floor of the square root of an integer.\n            ///\n            /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#floor_sqrt).\n            ///\n            /// # Notes\n            /// For [`u32`] and [`u64`], the square root is computed using Newton's method.\n            #[inline]\n            fn floor_sqrt(self) -> $u {\n                floor_sqrt_newton_helper::<$u, $s>(self)\n            }\n        }\n\n        impl CeilingSqrt for $u {\n            type Output = $u;\n\n            /// Returns the ceiling of the square root of an integer.\n            ///\n            /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#ceiling_sqrt).\n            ///\n            /// # Notes\n            /// For [`u32`] and [`u64`], the square root is computed using Newton's method.\n            #[inline]\n            fn ceiling_sqrt(self) -> $u {\n                ceiling_sqrt_newton_helper::<$u, $s>(self)\n            }\n        }\n\n        impl CheckedSqrt for $u {\n            type Output = $u;\n\n            /// Returns the the square root of an integer, or `None` if the integer is not a perfect\n            /// square.\n            ///\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#checked_sqrt).\n            ///\n            /// # Notes\n            /// For [`u32`] and [`u64`], the square root is computed using Newton's method.\n            #[inline]\n            fn checked_sqrt(self) -> Option<$u> {\n                checked_sqrt_newton_helper::<$u, $s>(self)\n            }\n        }\n\n        impl SqrtRem for $u {\n            type SqrtOutput = $u;\n            type RemOutput = $u;\n\n            /// Returns the floor of the square root of an integer, and the remainder (the\n            /// difference between the integer and the square of the floor).\n            ///\n            /// $f(x) = (\\lfloor\\sqrt{x}\\rfloor, x - \\lfloor\\sqrt{x}\\rfloor^2)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#sqrt_rem).\n            ///\n            /// # Notes\n            /// For [`u32`] and [`u64`], the square root is computed using Newton's method.\n            #[inline]\n            fn sqrt_rem(self) -> ($u, $u) {\n                sqrt_rem_newton_helper::<$u, $s>(self)\n            }\n        }\n    };\n}\nimpl_sqrt_newton!(u32, i32);\nimpl_sqrt_newton!(u64, i64);\n\nimpl FloorSqrt for u16 {\n    type Output = Self;\n\n    /// Returns the floor of the square root of a [`u16`].\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#floor_sqrt).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn floor_sqrt(self) -> Self {\n        Self::wrapping_from(u32::from(self).floor_sqrt())\n    }\n}\n\nimpl CeilingSqrt for u16 {\n    type Output = Self;\n\n    /// Returns the ceiling of the square root of a [`u16`].\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#ceiling_sqrt).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn ceiling_sqrt(self) -> Self {\n        Self::wrapping_from(u32::from(self).ceiling_sqrt())\n    }\n}\n\nimpl CheckedSqrt for u16 {\n    type Output = Self;\n\n    /// Returns the the square root of a [`u16`], or `None` if the integer is not a perfect square.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#checked_sqrt).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn checked_sqrt(self) -> Option<Self> {\n        u32::from(self).checked_sqrt().map(Self::wrapping_from)\n    }\n}\n\nimpl SqrtRem for u16 {\n    type SqrtOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the square root of a [`u16`], and the remainder (the difference between\n    /// the [`u16`] and the square of the floor).\n    ///\n    /// $f(x) = (\\lfloor\\sqrt{x}\\rfloor, x - \\lfloor\\sqrt{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#sqrt_rem).\n    ///\n    /// # Notes\n    /// The [`u16`] implementation calls the implementation for [`u32`]s.\n    #[inline]\n    fn sqrt_rem(self) -> (Self, Self) {\n        let (sqrt, rem) = u32::from(self).sqrt_rem();\n        (Self::wrapping_from(sqrt), Self::wrapping_from(rem))\n    }\n}\n\nimpl FloorSqrt for usize {\n    type Output = Self;\n\n    /// Returns the floor of the square root of a [`usize`].\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#floor_sqrt).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn floor_sqrt(self) -> Self {\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::wrapping_from(self).floor_sqrt())\n        } else {\n            Self::wrapping_from(u64::wrapping_from(self).floor_sqrt())\n        }\n    }\n}\n\nimpl CeilingSqrt for usize {\n    type Output = Self;\n\n    /// Returns the ceiling of the square root of a [`usize`].\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#ceiling_sqrt).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn ceiling_sqrt(self) -> Self {\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::wrapping_from(self).ceiling_sqrt())\n        } else {\n            Self::wrapping_from(u64::wrapping_from(self).ceiling_sqrt())\n        }\n    }\n}\n\nimpl CheckedSqrt for usize {\n    type Output = Self;\n\n    /// Returns the the square root of a [`usize`], or `None` if the [`usize`] is not a perfect\n    /// square.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#checked_sqrt).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn checked_sqrt(self) -> Option<Self> {\n        if USIZE_IS_U32 {\n            u32::wrapping_from(self)\n                .checked_sqrt()\n                .map(Self::wrapping_from)\n        } else {\n            u64::wrapping_from(self)\n                .checked_sqrt()\n                .map(Self::wrapping_from)\n        }\n    }\n}\n\nimpl SqrtRem for usize {\n    type SqrtOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the square root of a [`usize`], and the remainder (the difference\n    /// between the [`usize`] and the square of the floor).\n    ///\n    /// $f(x) = (\\lfloor\\sqrt{x}\\rfloor, x - \\lfloor\\sqrt{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#sqrt_rem).\n    ///\n    /// # Notes\n    /// The [`usize`] implementation calls the [`u32`] or [`u64`] implementations.\n    #[inline]\n    fn sqrt_rem(self) -> (Self, Self) {\n        if USIZE_IS_U32 {\n            let (sqrt, rem) = u32::wrapping_from(self).sqrt_rem();\n            (Self::wrapping_from(sqrt), Self::wrapping_from(rem))\n        } else {\n            let (sqrt, rem) = u64::wrapping_from(self).sqrt_rem();\n            (Self::wrapping_from(sqrt), Self::wrapping_from(rem))\n        }\n    }\n}\n\n// TODO tune\nconst U128_SQRT_THRESHOLD: u64 = 125;\nconst U128_MAX_SQUARE: u128 = 0xfffffffffffffffe0000000000000001;\n\nimpl FloorSqrt for u128 {\n    type Output = Self;\n\n    /// Returns the floor of the square root of a [`u128`].\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#floor_sqrt).\n    ///\n    /// # Notes\n    /// For [`u128`], using a floating-point approximation and refining the result works, but the\n    /// number of necessary adjustments becomes large for large [`u128`]s. To overcome this, large\n    /// [`u128`]s switch to a binary search algorithm. To get decent starting bounds, the following\n    /// fact is used:\n    ///\n    /// If $x$ is nonzero and has $b$ significant bits, then\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b-1$,\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b$,\n    ///\n    /// $2^{2\\lfloor (b-1)/2 \\rfloor} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $2^{2(\\lceil b/2 \\rceil-1)} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $\\lfloor\\sqrt{2^{2(\\lceil b/2 \\rceil-1)}}\\rfloor \\leq \\lfloor\\sqrt{x}\\rfloor \\leq\n    /// \\lfloor\\sqrt{2^{2\\lceil b/2 \\rceil}}\\rfloor$, since $x \\mapsto \\lfloor\\sqrt{x}\\rfloor$ is\n    /// weakly increasing,\n    ///\n    /// $2^{\\lceil b/2 \\rceil-1} \\leq \\lfloor\\sqrt{x}\\rfloor \\leq 2^{\\lceil b/2 \\rceil}$.\n    ///\n    /// For example, since $10^9$ has 30 significant bits, we know that $2^{14} \\leq\n    /// \\lfloor\\sqrt{10^9}\\rfloor \\leq 2^{15}$.\n    fn floor_sqrt(self) -> Self {\n        if self.significant_bits() < U128_SQRT_THRESHOLD {\n            floor_sqrt_approx_and_refine(|x| x as f64, |x| x as Self, U128_MAX_SQUARE, self)\n        } else {\n            floor_sqrt_binary(self)\n        }\n    }\n}\n\nimpl CeilingSqrt for u128 {\n    type Output = Self;\n\n    /// Returns the ceiling of the square root of a [`u128`].\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#ceiling_sqrt).\n    ///\n    /// # Notes\n    /// For [`u128`], using a floating-point approximation and refining the result works, but the\n    /// number of necessary adjustments becomes large for large [`u128`]s. To overcome this, large\n    /// [`u128`]s switch to a binary search algorithm. To get decent starting bounds, the following\n    /// fact is used:\n    ///\n    /// If $x$ is nonzero and has $b$ significant bits, then\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b-1$,\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b$,\n    ///\n    /// $2^{2\\lfloor (b-1)/2 \\rfloor} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $2^{2(\\lceil b/2 \\rceil-1)} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $\\lfloor\\sqrt{2^{2(\\lceil b/2 \\rceil-1)}}\\rfloor \\leq \\lfloor\\sqrt{x}\\rfloor \\leq\n    /// \\lfloor\\sqrt{2^{2\\lceil b/2 \\rceil}}\\rfloor$, since $x \\mapsto \\lfloor\\sqrt{x}\\rfloor$ is\n    /// weakly increasing,\n    ///\n    /// $2^{\\lceil b/2 \\rceil-1} \\leq \\lfloor\\sqrt{x}\\rfloor \\leq 2^{\\lceil b/2 \\rceil}$.\n    ///\n    /// For example, since $10^9$ has 30 significant bits, we know that $2^{14} \\leq\n    /// \\lfloor\\sqrt{10^9}\\rfloor \\leq 2^{15}$.\n    fn ceiling_sqrt(self) -> Self {\n        if self.significant_bits() < U128_SQRT_THRESHOLD {\n            ceiling_sqrt_approx_and_refine(|x| x as f64, |x| x as Self, U128_MAX_SQUARE, self)\n        } else {\n            ceiling_sqrt_binary(self)\n        }\n    }\n}\n\nimpl CheckedSqrt for u128 {\n    type Output = Self;\n\n    /// Returns the the square root of a [`u128`], or `None` if the [`u128`] is not a perfect\n    /// square.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#checked_sqrt).\n    ///\n    /// # Notes\n    /// For [`u128`], using a floating-point approximation and refining the result works, but the\n    /// number of necessary adjustments becomes large for large [`u128`]s. To overcome this, large\n    /// [`u128`]s switch to a binary search algorithm. To get decent starting bounds, the following\n    /// fact is used:\n    ///\n    /// If $x$ is nonzero and has $b$ significant bits, then\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b-1$,\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b$,\n    ///\n    /// $2^{2\\lfloor (b-1)/2 \\rfloor} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $2^{2(\\lceil b/2 \\rceil-1)} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $\\lfloor\\sqrt{2^{2(\\lceil b/2 \\rceil-1)}}\\rfloor \\leq \\lfloor\\sqrt{x}\\rfloor \\leq\n    /// \\lfloor\\sqrt{2^{2\\lceil b/2 \\rceil}}\\rfloor$, since $x \\mapsto \\lfloor\\sqrt{x}\\rfloor$ is\n    /// weakly increasing,\n    ///\n    /// $2^{\\lceil b/2 \\rceil-1} \\leq \\lfloor\\sqrt{x}\\rfloor \\leq 2^{\\lceil b/2 \\rceil}$.\n    ///\n    /// For example, since $10^9$ has 30 significant bits, we know that $2^{14} \\leq\n    /// \\lfloor\\sqrt{10^9}\\rfloor \\leq 2^{15}$.\n    fn checked_sqrt(self) -> Option<Self> {\n        if self.significant_bits() < U128_SQRT_THRESHOLD {\n            checked_sqrt_approx_and_refine(|x| x as f64, |x| x as Self, U128_MAX_SQUARE, self)\n        } else {\n            checked_sqrt_binary(self)\n        }\n    }\n}\n\nimpl SqrtRem for u128 {\n    type SqrtOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the square root of a [`u128`], and the remainder (the difference\n    /// between the [`u128`] and the square of the floor).\n    ///\n    /// $f(x) = (\\lfloor\\sqrt{x}\\rfloor, x - \\lfloor\\sqrt{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::sqrt#sqrt_rem).\n    ///\n    /// # Notes\n    /// For [`u128`], using a floating-point approximation and refining the result works, but the\n    /// number of necessary adjustments becomes large for large [`u128`]s. To overcome this, large\n    /// [`u128`]s switch to a binary search algorithm. To get decent starting bounds, the following\n    /// fact is used:\n    ///\n    /// If $x$ is nonzero and has $b$ significant bits, then\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b-1$,\n    ///\n    /// $2^{b-1} \\leq x \\leq 2^b$,\n    ///\n    /// $2^{2\\lfloor (b-1)/2 \\rfloor} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $2^{2(\\lceil b/2 \\rceil-1)} \\leq x \\leq 2^{2\\lceil b/2 \\rceil}$,\n    ///\n    /// $\\lfloor\\sqrt{2^{2(\\lceil b/2 \\rceil-1)}}\\rfloor \\leq \\lfloor\\sqrt{x}\\rfloor \\leq\n    /// \\lfloor\\sqrt{2^{2\\lceil b/2 \\rceil}}\\rfloor$, since $x \\mapsto \\lfloor\\sqrt{x}\\rfloor$ is\n    /// weakly increasing,\n    ///\n    /// $2^{\\lceil b/2 \\rceil-1} \\leq \\lfloor\\sqrt{x}\\rfloor \\leq 2^{\\lceil b/2 \\rceil}$.\n    ///\n    /// For example, since $10^9$ has 30 significant bits, we know that $2^{14} \\leq\n    /// \\lfloor\\sqrt{10^9}\\rfloor \\leq 2^{15}$.\n    fn sqrt_rem(self) -> (Self, Self) {\n        if self.significant_bits() < U128_SQRT_THRESHOLD {\n            sqrt_rem_approx_and_refine(|x| x as f64, |x| x as Self, U128_MAX_SQUARE, self)\n        } else {\n            sqrt_rem_binary(self)\n        }\n    }\n}\n\nmacro_rules! impl_sqrt_signed {\n    ($u: ident, $s: ident) => {\n        impl FloorSqrt for $s {\n            type Output = $s;\n\n            /// Returns the floor of the square root of an integer.\n            ///\n            /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is negative.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#floor_sqrt).\n            #[inline]\n            fn floor_sqrt(self) -> Self {\n                if self >= 0 {\n                    $s::wrapping_from(self.unsigned_abs().floor_sqrt())\n                } else {\n                    panic!(\"Cannot take square root of {}\", self)\n                }\n            }\n        }\n\n        impl CeilingSqrt for $s {\n            type Output = $s;\n\n            /// Returns the ceiling of the square root of an integer.\n            ///\n            /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is negative.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#ceiling_sqrt).\n            #[inline]\n            fn ceiling_sqrt(self) -> $s {\n                if self >= 0 {\n                    $s::wrapping_from(self.unsigned_abs().ceiling_sqrt())\n                } else {\n                    panic!(\"Cannot take square root of {}\", self)\n                }\n            }\n        }\n\n        impl CheckedSqrt for $s {\n            type Output = $s;\n\n            /// Returns the the square root of an integer, or `None` if the integer is not a perfect\n            /// square.\n            ///\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n            ///     \\operatorname{None} & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is negative.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#checked_sqrt).\n            #[inline]\n            fn checked_sqrt(self) -> Option<$s> {\n                if self >= 0 {\n                    self.unsigned_abs().checked_sqrt().map($s::wrapping_from)\n                } else {\n                    panic!(\"Cannot take square root of {}\", self)\n                }\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_sqrt_signed);\n\nmacro_rules! impl_sqrt_assign_rem_unsigned {\n    ($t: ident) => {\n        impl SqrtAssignRem for $t {\n            type RemOutput = $t;\n\n            /// Replaces an integer with the floor of its square root, and returns the remainder\n            /// (the difference between the original integer and the square of the floor).\n            ///\n            /// $f(x) = x - \\lfloor\\sqrt{x}\\rfloor^2$,\n            ///\n            /// $x \\gets \\lfloor\\sqrt{x}\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#sqrt_assign_rem).\n            #[inline]\n            fn sqrt_assign_rem(&mut self) -> $t {\n                let rem;\n                (*self, rem) = self.sqrt_rem();\n                rem\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_sqrt_assign_rem_unsigned);\n\nmacro_rules! impl_sqrt_assign {\n    ($t: ident) => {\n        impl FloorSqrtAssign for $t {\n            /// Replaces an integer with the floor of its square root.\n            ///\n            /// $x \\gets \\lfloor\\sqrt{x}\\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is negative.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#floor_sqrt_assign).\n            #[inline]\n            fn floor_sqrt_assign(&mut self) {\n                *self = self.floor_sqrt();\n            }\n        }\n\n        impl CeilingSqrtAssign for $t {\n            /// Replaces an integer with the ceiling of its square root.\n            ///\n            /// $x \\gets \\lceil\\sqrt{x}\\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is negative.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#ceiling_sqrt_assign).\n            #[inline]\n            fn ceiling_sqrt_assign(&mut self) {\n                *self = self.ceiling_sqrt();\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_sqrt_assign);\n\nmacro_rules! impl_sqrt_primitive_float {\n    ($f:ident) => {\n        impl Sqrt for $f {\n            type Output = Self;\n\n            /// This is a wrapper over the `sqrt` function in `libm`.\n            #[inline]\n            fn sqrt(self) -> $f {\n                libm::Libm::<$f>::sqrt(self)\n            }\n        }\n\n        impl SqrtAssign for $f {\n            /// Replaces a number with its square root.\n            ///\n            /// $x \\gets \\sqrt x$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sqrt#sqrt_assign).\n            #[inline]\n            fn sqrt_assign(&mut self) {\n                *self = self.sqrt();\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_sqrt_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Square, SquareAssign};\n\nmacro_rules! impl_square {\n    ($t:ident) => {\n        impl Square for $t {\n            type Output = $t;\n\n            /// Squares a number.\n            ///\n            /// $f(x) = x^2$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::square#square).\n            #[inline]\n            fn square(self) -> $t {\n                self * self\n            }\n        }\n\n        impl SquareAssign for $t {\n            /// Squares a number in place.\n            ///\n            /// $x \\gets x^2$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::square#square_assign).\n            #[inline]\n            fn square_assign(&mut self) {\n                *self *= *self;\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_square);\napply_to_primitive_floats!(impl_square);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SubMul, SubMulAssign, WrappingSubMul, WrappingSubMulAssign};\n\nmacro_rules! impl_sub_mul_primitive_int {\n    ($t:ident) => {\n        impl SubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers.\n            ///\n            /// $f(x, y, z) = x - yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sub_mul#sub_mul).\n            #[inline]\n            fn sub_mul(self, y: $t, z: $t) -> $t {\n                self.wrapping_sub_mul(y, z)\n            }\n        }\n\n        impl SubMulAssign<$t> for $t {\n            /// Subtracts a number by the product of two other numbers in place.\n            ///\n            /// $x \\gets x - yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sub_mul#sub_mul_assign).\n            #[inline]\n            fn sub_mul_assign(&mut self, y: $t, z: $t) {\n                self.wrapping_sub_mul_assign(y, z);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_sub_mul_primitive_int);\n\nmacro_rules! impl_sub_mul_primitive_float {\n    ($t:ident) => {\n        impl SubMul for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers.\n            ///\n            /// $f(x, y, z) = x - yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sub_mul#sub_mul).\n            #[inline]\n            fn sub_mul(self, y: $t, z: $t) -> $t {\n                self - y * z\n            }\n        }\n\n        impl SubMulAssign<$t> for $t {\n            /// Subtracts a number by the product of two other numbers in place.\n            ///\n            /// $x \\gets x - yz$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::sub_mul#sub_mul_assign).\n            #[inline]\n            fn sub_mul_assign(&mut self, y: $t, z: $t) {\n                *self -= y * z;\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_sub_mul_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::traits::Two;\nuse crate::rounding_modes::RoundingMode;\nuse core::cmp::Ordering;\n\n/// Takes the absolute value of a number. Assumes that the number has a representable absolute\n/// value.\npub trait Abs {\n    type Output;\n\n    fn abs(self) -> Self::Output;\n}\n\n/// Replaces a number with its absolute value. Assumes that the number has a representable absolute\n/// value.\npub trait AbsAssign {\n    fn abs_assign(&mut self);\n}\n\n/// Takes the absolute value of a number and converts to the unsigned equivalent.\npub trait UnsignedAbs {\n    type Output;\n\n    fn unsigned_abs(self) -> Self::Output;\n}\n\n/// Subtracts two numbers and takes the absolute value of the difference.\npub trait AbsDiff<RHS = Self> {\n    type Output;\n\n    fn abs_diff(self, other: RHS) -> Self::Output;\n}\n\n/// Replaces a number with the absolute value of its difference with another number.\npub trait AbsDiffAssign<RHS = Self> {\n    fn abs_diff_assign(&mut self, other: RHS);\n}\n\n/// Adds a number and the product of two other numbers.\npub trait AddMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn add_mul(self, y: Y, z: Z) -> Self::Output;\n}\n\n/// Adds a number and the product of two other numbers, in place.\npub trait AddMulAssign<Y = Self, Z = Self> {\n    fn add_mul_assign(&mut self, y: Y, z: Z);\n}\n\n/// Calculates the AGM (arithmetic-geometric mean) of two numbers.\npub trait Agm<RHS = Self> {\n    type Output;\n\n    fn agm(self, other: RHS) -> Self::Output;\n}\n\n/// Replaces a number with the AGM (arithmetic-geometric mean) of it and another number.\npub trait AgmAssign<RHS = Self> {\n    fn agm_assign(&mut self, other: RHS);\n}\n\n/// Left-shifts a number (multiplies it by a power of 2), returning `None` if the result is not\n/// representable.\npub trait ArithmeticCheckedShl<RHS> {\n    type Output;\n\n    fn arithmetic_checked_shl(self, other: RHS) -> Option<Self::Output>;\n}\n\n/// Right-shifts a number (divides it by a power of 2), returning `None` if the result is not\n/// representable.\npub trait ArithmeticCheckedShr<RHS> {\n    type Output;\n\n    fn arithmetic_checked_shr(self, other: RHS) -> Option<Self::Output>;\n}\n\npub trait BinomialCoefficient<T = Self> {\n    fn binomial_coefficient(n: T, k: T) -> Self;\n}\n\npub trait CheckedBinomialCoefficient<T = Self>: Sized {\n    fn checked_binomial_coefficient(n: T, k: T) -> Option<Self>;\n}\n\n/// Takes the ceiling of a number.\npub trait Ceiling {\n    type Output;\n\n    fn ceiling(self) -> Self::Output;\n}\n\n/// Replaces a number with its ceiling.\npub trait CeilingAssign {\n    fn ceiling_assign(&mut self);\n}\n\n/// Takes the absolute valie of a number, returning `None` if the result is not representable.\npub trait CheckedAbs {\n    type Output;\n\n    fn checked_abs(self) -> Option<Self::Output>;\n}\n\n/// Adds two numbers, returning `None` if the result is not representable.\npub trait CheckedAdd<RHS = Self> {\n    type Output;\n\n    fn checked_add(self, other: RHS) -> Option<Self::Output>;\n}\n\n/// Adds a number and the product of two other numbers, returning `None` if the result is not\n/// representable.\npub trait CheckedAddMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn checked_add_mul(self, y: Y, z: Z) -> Option<Self::Output>;\n}\n\n/// Divides two numbers, returning `None` if the result is not representable.\npub trait CheckedDiv<RHS = Self> {\n    type Output;\n\n    fn checked_div(self, other: RHS) -> Option<Self::Output>;\n}\n\n/// Multiplies two numbers, returning `None` if the result is not representable.\npub trait CheckedMul<RHS = Self> {\n    type Output;\n\n    fn checked_mul(self, other: RHS) -> Option<Self::Output>;\n}\n\n/// Negates a number, returning `None` if the result is not representable.\npub trait CheckedNeg {\n    type Output;\n\n    fn checked_neg(self) -> Option<Self::Output>;\n}\n\n/// Finds the smallest integer power of 2 greater than or equal to a number, returning `None` if the\n/// result is not representable.\npub trait CheckedNextPowerOf2 {\n    type Output;\n\n    fn checked_next_power_of_2(self) -> Option<Self::Output>;\n}\n\n/// Raises a number to a power, returning `None` if the result is not representable.\npub trait CheckedPow<RHS> {\n    type Output;\n\n    fn checked_pow(self, exp: RHS) -> Option<Self::Output>;\n}\n\n/// Squares a number, returning `None` if the result is not representable.\npub trait CheckedSquare {\n    type Output;\n\n    fn checked_square(self) -> Option<Self::Output>;\n}\n\n/// Subtracts two numbers, returning `None` if the result is not representable.\npub trait CheckedSub<RHS = Self> {\n    type Output;\n\n    fn checked_sub(self, other: RHS) -> Option<Self::Output>;\n}\n\n/// Subtracts a number by the product of two other numbers, returning `None` if the result is not\n/// representable.\npub trait CheckedSubMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn checked_sub_mul(self, y: Y, z: Z) -> Option<Self::Output>;\n}\n\n/// Determines whether two numbers are coprime.\npub trait CoprimeWith<RHS = Self> {\n    fn coprime_with(self, other: RHS) -> bool;\n}\n\n/// Divides two numbers, assuming the first exactly divides the second.\n///\n/// If it doesn't, the `div_exact` function may panic or return a meaningless result.\npub trait DivExact<RHS = Self> {\n    type Output;\n\n    fn div_exact(self, other: RHS) -> Self::Output;\n}\n\n/// Divides a number by another number in place, assuming the first exactly divides the second.\n///\n/// If it doesn't, this function may panic or assign a meaningless number to the first number.\npub trait DivExactAssign<RHS = Self> {\n    fn div_exact_assign(&mut self, other: RHS);\n}\n\n/// Divides two numbers, returning the quotient and remainder. The quotient is rounded towards\n/// negative infinity, and the remainder has the same sign as the divisor (second input).\n///\n/// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\npub trait DivMod<RHS = Self> {\n    type DivOutput;\n    type ModOutput;\n\n    fn div_mod(self, other: RHS) -> (Self::DivOutput, Self::ModOutput);\n}\n\n/// Divides a number by another number in place, returning the remainder. The quotient is rounded\n/// towards negative infinity, and the remainder has the same sign as the divisor (second input).\n///\n/// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\npub trait DivAssignMod<RHS = Self> {\n    type ModOutput;\n\n    fn div_assign_mod(&mut self, other: RHS) -> Self::ModOutput;\n}\n\n/// Divides two numbers, returning the quotient and remainder. The quotient is rounded towards zero,\n/// and the remainder has the same sign as the dividend (first input).\n///\n/// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\npub trait DivRem<RHS = Self> {\n    type DivOutput;\n    type RemOutput;\n\n    fn div_rem(self, other: RHS) -> (Self::DivOutput, Self::RemOutput);\n}\n\n/// Divides a number by another number in place, returning the remainder. The quotient is rounded\n/// towards zero, and the remainder has the same sign as the dividend (first input).\n///\n/// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\npub trait DivAssignRem<RHS = Self> {\n    type RemOutput;\n\n    fn div_assign_rem(&mut self, other: RHS) -> Self::RemOutput;\n}\n\n/// Divides a number by another number, returning the ceiling of the quotient and the remainder of\n/// the negative of the first number divided by the second.\n///\n/// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\npub trait CeilingDivNegMod<RHS = Self> {\n    type DivOutput;\n    type ModOutput;\n\n    fn ceiling_div_neg_mod(self, other: RHS) -> (Self::DivOutput, Self::ModOutput);\n}\n\n/// Divides a number by another number in place, taking the ceiling of the quotient and returning\n/// the remainder of the negative of the first number divided by the second.\n///\n/// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\npub trait CeilingDivAssignNegMod<RHS = Self> {\n    type ModOutput;\n\n    fn ceiling_div_assign_neg_mod(&mut self, other: RHS) -> Self::ModOutput;\n}\n\n/// Divides a number by another number, returning the quotient and remainder. The quotient is\n/// rounded towards positive infinity and the remainder has the opposite sign as the divisor (second\n/// input).\n///\n/// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\npub trait CeilingDivMod<RHS = Self> {\n    type DivOutput;\n    type ModOutput;\n\n    fn ceiling_div_mod(self, other: RHS) -> (Self::DivOutput, Self::ModOutput);\n}\n\n/// Divides a number by another number in place, taking the quotient and returning the remainder.\n/// The quotient is rounded towards positive infinity and the remainder has the opposite sign of the\n/// divisor (second input).\n///\n/// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\npub trait CeilingDivAssignMod<RHS = Self> {\n    type ModOutput;\n\n    fn ceiling_div_assign_mod(&mut self, other: RHS) -> Self::ModOutput;\n}\n\n/// Divides a number by another number and rounds according to a specified rounding mode. An\n/// [`Ordering`] is also returned, indicating whether the returned value is less than, equal to, or\n/// greater than the exact value.\npub trait DivRound<RHS = Self> {\n    type Output;\n\n    fn div_round(self, other: RHS, rm: RoundingMode) -> (Self::Output, Ordering);\n}\n\n/// Divides a number by another number in place and rounds according to a specified rounding mode.\n/// An [`Ordering`] is returned, indicating whether the assigned value is less than, equal to, or\n/// greater than the exact value.\npub trait DivRoundAssign<RHS = Self> {\n    fn div_round_assign(&mut self, other: RHS, rm: RoundingMode) -> Ordering;\n}\n\n/// Determines whether a number is divisible by $2^k$.\npub trait DivisibleByPowerOf2 {\n    fn divisible_by_power_of_2(self, pow: u64) -> bool;\n}\n\n/// Determines whether a number is divisible by another number.\npub trait DivisibleBy<RHS = Self> {\n    fn divisible_by(self, other: RHS) -> bool;\n}\n\n/// Determines whether a number is equivalent to another number modulo $2^k$.\npub trait EqModPowerOf2<RHS = Self> {\n    fn eq_mod_power_of_2(self, other: RHS, pow: u64) -> bool;\n}\n\n/// Determines whether a number is equivalent to another number modulo $m$.\npub trait EqMod<RHS = Self, M = Self> {\n    fn eq_mod(self, other: RHS, m: M) -> bool;\n}\n\n/// Computes the GCD (greatest common divisor) of two numbers $a$ and $b$, and also the coefficients\n/// $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$.\n///\n/// The are infinitely many $x$, $y$ that satisfy the identity, so the full specification is more\n/// detailed:\n///\n/// - $f(0, 0) = (0, 0, 0)$.\n/// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n/// - $f(a, ak) = (-a, -1, 0)$ if $a < 0$ and $k \\neq 1$.\n/// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n/// - $f(bk, b) = (-b, 0, -1)$ if $b < 0$.\n/// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(|a|, |b|)$, where\n///   $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq \\lfloor a/g\n///   \\rfloor$.\npub trait ExtendedGcd<RHS = Self> {\n    type Gcd;\n    type Cofactor;\n\n    fn extended_gcd(self, other: RHS) -> (Self::Gcd, Self::Cofactor, Self::Cofactor);\n}\n\n/// Computes the factorial of a `u64`.\npub trait Factorial {\n    fn factorial(n: u64) -> Self;\n}\n\n/// Computes the factorial of a `u64`, returning `None` if the result is too large to be\n/// represented.\npub trait CheckedFactorial: Sized {\n    fn checked_factorial(n: u64) -> Option<Self>;\n}\n\n/// Computes the double factorial of a `u64`. The double factorial of a non-negative integer is the\n/// product of all the positive integers that are less than or equal to it and have the same parity\n/// as it.\npub trait DoubleFactorial {\n    fn double_factorial(n: u64) -> Self;\n}\n\n/// Computes the double factorial of a `u64`, returning `None` if the result is too large to be\n/// represented. The double factorial of a non-negative integer is the product of all the positive\n/// integers that are less than or equal to it and have the same parity as it.\npub trait CheckedDoubleFactorial: Sized {\n    fn checked_double_factorial(n: u64) -> Option<Self>;\n}\n\n/// Computes the $m$-multifactorial of a `u64`. The $m$-multifactorial of a non-negative integer $n$\n/// is the product of all integers $k$ such that $0<k\\leq n$ and $k\\equiv n \\pmod m$.\npub trait Multifactorial {\n    fn multifactorial(n: u64, m: u64) -> Self;\n}\n\n/// Computes the $m$-multifactorial of a `u64`, returning `None` if the result is too large to be\n/// represented. The $m$-multifactorial of a non-negative integer $n$ is the product of all integers\n/// $k$ such that $0<k\\leq n$ and $k\\equiv n \\pmod m$.\npub trait CheckedMultifactorial: Sized {\n    fn checked_multifactorial(n: u64, m: u64) -> Option<Self>;\n}\n\n/// Computes the subfactorial of a `u64`. The subfactorial of a non-negative integer $n$ counts the\n/// number of derangements of $n$ elements, which are the permutations in which no element is fixed.\npub trait Subfactorial {\n    fn subfactorial(n: u64) -> Self;\n}\n\n/// Computes the subfactorial of a `u64`, returning `None` if the result is too large to be\n/// represented. The subfactorial of a non-negative integer $n$ counts the number of derangements of\n/// $n$ elements, which are the permutations in which no element is fixed.\npub trait CheckedSubfactorial: Sized {\n    fn checked_subfactorial(n: u64) -> Option<Self>;\n}\n\n/// Takes the floor of a number.\npub trait Floor {\n    type Output;\n\n    fn floor(self) -> Self::Output;\n}\n\n/// Replaces a number with its floor.\npub trait FloorAssign {\n    fn floor_assign(&mut self);\n}\n\n/// Calculates the GCD (greatest common divisor) of two numbers.\npub trait Gcd<RHS = Self> {\n    type Output;\n\n    fn gcd(self, other: RHS) -> Self::Output;\n}\n\n/// Replaces a number with the GCD (greatest common divisor) of it and another number.\npub trait GcdAssign<RHS = Self> {\n    fn gcd_assign(&mut self, other: RHS);\n}\n\n/// Determines whether a number is an integer power of 2.\npub trait IsPowerOf2 {\n    fn is_power_of_2(&self) -> bool;\n}\n\n/// Calculates the LCM (least common multiple) of two numbers.\npub trait Lcm<RHS = Self> {\n    type Output;\n\n    fn lcm(self, other: RHS) -> Self::Output;\n}\n\n/// Replaces a number with the LCM (least common multiple) of it and another number.\npub trait LcmAssign<RHS = Self> {\n    fn lcm_assign(&mut self, other: RHS);\n}\n\n/// Takes the natural logarithm of a number.\npub trait Ln {\n    type Output;\n\n    fn ln(self) -> Self::Output;\n}\n\n/// Replaces a number with its natural logarithm.\npub trait LnAssign {\n    fn ln_assign(&mut self);\n}\n\n/// Calculates the LCM (least common multiple) of two numbers, returning `None` if the result is not\n/// representable.\npub trait CheckedLcm<RHS = Self> {\n    type Output;\n\n    fn checked_lcm(self, other: RHS) -> Option<Self::Output>;\n}\n\n/// Calculates the Legendre symbol of two numbers. Typically the implementations will be identical\n/// to those of [`JacobiSymbol`].\npub trait LegendreSymbol<RHS = Self> {\n    fn legendre_symbol(self, other: RHS) -> i8;\n}\n\n/// Calculates the Jacobi symbol of two numbers.\npub trait JacobiSymbol<RHS = Self> {\n    fn jacobi_symbol(self, other: RHS) -> i8;\n}\n\n/// Calculates the Kronecker symbol of two numbers.\npub trait KroneckerSymbol<RHS = Self> {\n    fn kronecker_symbol(self, other: RHS) -> i8;\n}\n\n/// Calculates the base-$b$ logarithm of a number, or returns `None` if the number is not a perfect\n/// power of $b$.\npub trait CheckedLogBase<B = Self> {\n    type Output;\n\n    fn checked_log_base(self, base: B) -> Option<Self::Output>;\n}\n\n/// Calculates the floor of the base-$b$ logarithm of a number.\npub trait FloorLogBase<B = Self> {\n    type Output;\n\n    fn floor_log_base(self, base: B) -> Self::Output;\n}\n\n/// Calculates the ceiling of the base-$b$ logarithm of a number.\npub trait CeilingLogBase<B = Self> {\n    type Output;\n\n    fn ceiling_log_base(self, base: B) -> Self::Output;\n}\n\n/// Calculates the base-2 logarithm of a number, or returns `None` if the number is not a perfect\n/// power of 2.\npub trait CheckedLogBase2 {\n    type Output;\n\n    fn checked_log_base_2(self) -> Option<Self::Output>;\n}\n\n/// Calculates the floor of the base-2 logarithm of a number.\npub trait FloorLogBase2 {\n    type Output;\n\n    fn floor_log_base_2(self) -> Self::Output;\n}\n\n/// Calculates the ceiling of the base-2 logarithm of a number.\npub trait CeilingLogBase2 {\n    type Output;\n\n    fn ceiling_log_base_2(self) -> Self::Output;\n}\n\n/// Calculates the base-$2^k$ logarithm of a number, or returns `None` if the number is not a\n/// perfect power of $2^k$.\npub trait CheckedLogBasePowerOf2<POW> {\n    type Output;\n\n    fn checked_log_base_power_of_2(self, pow: POW) -> Option<Self::Output>;\n}\n\n/// Calculates the floor of the base-$2^k$ logarithm of a number.\npub trait FloorLogBasePowerOf2<POW> {\n    type Output;\n\n    fn floor_log_base_power_of_2(self, pow: POW) -> Self::Output;\n}\n\n/// Calculates the ceiling of the base-$2^k$ logarithm of a number.\npub trait CeilingLogBasePowerOf2<POW> {\n    type Output;\n\n    fn ceiling_log_base_power_of_2(self, pow: POW) -> Self::Output;\n}\n\n/// Adds two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.\npub trait ModAdd<RHS = Self, M = Self> {\n    type Output;\n\n    fn mod_add(self, other: RHS, m: M) -> Self::Output;\n}\n\n/// Adds two numbers modulo a third number $m$, in place. The inputs must be already reduced modulo\n/// $m$.\npub trait ModAddAssign<RHS = Self, M = Self> {\n    fn mod_add_assign(&mut self, other: RHS, m: M);\n}\n\n/// Finds the multiplicative inverse of a number modulo another number $m$. The input must be\n/// already reduced modulo $m$.\npub trait ModInverse<M = Self> {\n    type Output;\n\n    fn mod_inverse(self, m: M) -> Option<Self::Output>;\n}\n\n/// Checks whether a number is reduced modulo another number $m$.\npub trait ModIsReduced<M = Self> {\n    fn mod_is_reduced(&self, m: &M) -> bool;\n}\n\n/// Multiplies two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.\npub trait ModMul<RHS = Self, M = Self> {\n    type Output;\n\n    fn mod_mul(self, other: RHS, m: M) -> Self::Output;\n}\n\n/// Multiplies two numbers modulo a third number $m$, in place. The inputs must be already reduced\n/// modulo $m$.\npub trait ModMulAssign<RHS = Self, M = Self> {\n    fn mod_mul_assign(&mut self, other: RHS, m: M);\n}\n\n/// Multiplies two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.\n///\n/// If multiple modular multiplications with the same modulus are necessary, it can be quicker to\n/// precompute some piece of data and reuse it in the multiplication calls. This trait provides a\n/// function for precomputing the data and a function for using it during multiplication.\npub trait ModMulPrecomputed<RHS = Self, M = Self> {\n    type Output;\n    type Data;\n\n    /// Precomputes some data to use for modular multiplication.\n    fn precompute_mod_mul_data(m: &M) -> Self::Data;\n\n    fn mod_mul_precomputed(self, other: RHS, m: M, data: &Self::Data) -> Self::Output;\n}\n\n/// Multiplies two numbers modulo a third number $m$, in place.The inputs must be already reduced\n/// modulo $m$.\n///\n/// If multiple modular multiplications with the same modulus are necessary, it can be quicker to\n/// precompute some piece of data and reuse it in the multiplication calls. This trait provides a\n/// function for using precomputed data during multiplication. For precomputing the data, use the\n/// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data) function in\n/// [`ModMulPrecomputed`].\npub trait ModMulPrecomputedAssign<RHS = Self, M = Self>: ModMulPrecomputed<RHS, M> {\n    fn mod_mul_precomputed_assign(&mut self, other: RHS, m: M, data: &Self::Data);\n}\n\n/// Negates a number modulo another number $m$. The input must be already reduced modulo $m$.\npub trait ModNeg<M = Self> {\n    type Output;\n\n    fn mod_neg(self, m: M) -> Self::Output;\n}\n\n/// Negates a number modulo another number $m$, in place. The input must be already reduced modulo\n/// $m$.\npub trait ModNegAssign<M = Self> {\n    fn mod_neg_assign(&mut self, m: M);\n}\n\n/// Divides a number by another number, returning just the remainder. The remainder has the same\n/// sign as the divisor (second number).\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \\leq\n/// |r| < |y|$.\npub trait Mod<RHS = Self> {\n    type Output;\n\n    fn mod_op(self, other: RHS) -> Self::Output;\n}\n\n/// Divides a number by another number, replacing the first number by the remainder. The remainder\n/// has the same sign as the divisor (second number).\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \\leq\n/// |r| < |y|$.\npub trait ModAssign<RHS = Self> {\n    fn mod_assign(&mut self, other: RHS);\n}\n\n/// Divides the negative of a number by another number, returning the remainder.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0 \\leq\n/// r < y$.\npub trait NegMod<RHS = Self> {\n    type Output;\n\n    fn neg_mod(self, other: RHS) -> Self::Output;\n}\n\n/// Divides the negative of a number by another number, replacing the first number by the remainder.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0 \\leq\n/// r < y$.\npub trait NegModAssign<RHS = Self> {\n    fn neg_mod_assign(&mut self, other: RHS);\n}\n\n/// Divides a number by another number, returning just the remainder. The remainder has the opposite\n/// sign as the divisor (second number).\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \\leq\n/// |r| < |y|$.\npub trait CeilingMod<RHS = Self> {\n    type Output;\n\n    fn ceiling_mod(self, other: RHS) -> Self::Output;\n}\n\n/// Divides a number by another number, replacing the first number by the remainder. The remainder\n/// has the same sign as the divisor (second number).\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0 \\leq\n/// |r| < |y|$.\npub trait CeilingModAssign<RHS = Self> {\n    fn ceiling_mod_assign(&mut self, other: RHS);\n}\n\n/// Raises a number to a power modulo another number $m$. The base must be already reduced modulo\n/// $m$.\npub trait ModPow<RHS = Self, M = Self> {\n    type Output;\n\n    fn mod_pow(self, exp: RHS, m: M) -> Self::Output;\n}\n\n/// Raises a number to a power modulo another number $m$, in place. The base must be already reduced\n/// modulo $m$.\npub trait ModPowAssign<RHS = Self, M = Self> {\n    fn mod_pow_assign(&mut self, exp: RHS, m: M);\n}\n\n/// Raises a number to a power modulo another number $m$. The base must be already reduced modulo\n/// $m$.\n///\n/// If multiple modular exponentiations with the same modulus are necessary, it can be quicker to\n/// precompute some piece of data and reuse it in the exponentiation calls. This trait provides a\n/// function for precomputing the data and a function for using it during exponentiation.\npub trait ModPowPrecomputed<RHS = Self, M = Self>\nwhere\n    Self: Sized,\n{\n    type Output;\n    type Data;\n\n    /// Precomputes some data to use for modular exponentiation.\n    fn precompute_mod_pow_data(m: &M) -> Self::Data;\n\n    fn mod_pow_precomputed(self, exp: RHS, m: M, data: &Self::Data) -> Self::Output;\n}\n\n/// Raises a number to a power modulo another number $m$, in place. The base must be already reduced\n/// modulo $m$.\n///\n/// If multiple modular exponentiations with the same modulus are necessary, it can be quicker to\n/// precompute some piece of data and reuse it in the exponentiation calls. This trait provides a\n/// function for using precomputed data during exponentiation. For precomputing the data, use the\n/// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data) function in\n/// [`ModPowPrecomputed`].\npub trait ModPowPrecomputedAssign<RHS: Two = Self, M = Self>: ModPowPrecomputed<RHS, M> {\n    fn mod_pow_precomputed_assign(&mut self, exp: RHS, m: M, data: &Self::Data);\n}\n\n/// Adds two numbers modulo $2^k$. The inputs must be already reduced modulo $2^k$.\npub trait ModPowerOf2Add<RHS = Self> {\n    type Output;\n\n    fn mod_power_of_2_add(self, other: RHS, pow: u64) -> Self::Output;\n}\n\n/// Adds two numbers modulo $2^k$, in place. The inputs must be already reduced modulo $2^k$.\npub trait ModPowerOf2AddAssign<RHS = Self> {\n    fn mod_power_of_2_add_assign(&mut self, other: RHS, pow: u64);\n}\n\n/// Finds the multiplicative inverse of a number modulo $2^k$. The input must be already reduced\n/// modulo $2^k$.\npub trait ModPowerOf2Inverse {\n    type Output;\n\n    fn mod_power_of_2_inverse(self, pow: u64) -> Option<Self::Output>;\n}\n\n/// Checks whether a number is reduced modulo $2^k$.\npub trait ModPowerOf2IsReduced {\n    fn mod_power_of_2_is_reduced(&self, pow: u64) -> bool;\n}\n\n/// Multiplies two numbers modulo $2^k$. The inputs must be already reduced modulo $2^k$.\npub trait ModPowerOf2Mul<RHS = Self> {\n    type Output;\n\n    fn mod_power_of_2_mul(self, other: RHS, pow: u64) -> Self::Output;\n}\n\n/// Multiplies two numbers modulo $2^k$, in place. The inputs must be already reduced modulo $2^k$.\npub trait ModPowerOf2MulAssign<RHS = Self> {\n    fn mod_power_of_2_mul_assign(&mut self, other: RHS, pow: u64);\n}\n\n/// Negates a number modulo $2^k$. The input must be already reduced modulo $2^k$.\npub trait ModPowerOf2Neg {\n    type Output;\n\n    fn mod_power_of_2_neg(self, pow: u64) -> Self::Output;\n}\n\n/// Negates a number modulo $2^k$ in place. The input must be already reduced modulo $2^k$.\npub trait ModPowerOf2NegAssign {\n    fn mod_power_of_2_neg_assign(&mut self, pow: u64);\n}\n\n/// Raises a number to a power modulo $2^k$. The base must be already reduced modulo $2^k$.\npub trait ModPowerOf2Pow<RHS = Self> {\n    type Output;\n\n    fn mod_power_of_2_pow(self, exp: RHS, pow: u64) -> Self::Output;\n}\n\n/// Raises a number to a power modulo $2^k$, in place. The base must be already reduced modulo\n/// $2^k$.\npub trait ModPowerOf2PowAssign<RHS = Self> {\n    fn mod_power_of_2_pow_assign(&mut self, exp: RHS, pow: u64);\n}\n\n/// Left-shifts a number (multiplies it by a power of 2) modulo $2^k$. The number must be already\n/// reduced modulo $2^k$.\npub trait ModPowerOf2Shl<RHS> {\n    type Output;\n\n    fn mod_power_of_2_shl(self, other: RHS, pow: u64) -> Self::Output;\n}\n\n/// Left-shifts a number (multiplies it by a power of 2) modulo $2^k$, in place. The number must be\n/// already reduced modulo $2^k$.\npub trait ModPowerOf2ShlAssign<RHS> {\n    fn mod_power_of_2_shl_assign(&mut self, other: RHS, pow: u64);\n}\n\n/// Right-shifts a number (divides it by a power of 2) modulo $2^k$. The number must be already\n/// reduced modulo $2^k$.\npub trait ModPowerOf2Shr<RHS> {\n    type Output;\n\n    fn mod_power_of_2_shr(self, other: RHS, pow: u64) -> Self::Output;\n}\n\n/// Right-shifts a number (divides it by a power of 2) modulo $2^k$, in place. The number must be\n/// already reduced modulo $2^k$.\npub trait ModPowerOf2ShrAssign<RHS> {\n    fn mod_power_of_2_shr_assign(&mut self, other: RHS, pow: u64);\n}\n\n/// Squares a number modulo $2^k$. The input must be already reduced modulo $2^k$.\npub trait ModPowerOf2Square {\n    type Output;\n\n    fn mod_power_of_2_square(self, pow: u64) -> Self::Output;\n}\n\n/// Squares a number modulo $2^k$ in place. The input must be already reduced modulo $2^k$.\npub trait ModPowerOf2SquareAssign {\n    fn mod_power_of_2_square_assign(&mut self, pow: u64);\n}\n\n/// Subtracts two numbers modulo $2^k$. The inputs must be already reduced modulo $2^k$.\npub trait ModPowerOf2Sub<RHS = Self> {\n    type Output;\n\n    fn mod_power_of_2_sub(self, other: RHS, pow: u64) -> Self::Output;\n}\n\n/// Subtracts two numbers modulo $2^k$, in place. The inputs must be already reduced modulo $2^k$.\npub trait ModPowerOf2SubAssign<RHS = Self> {\n    fn mod_power_of_2_sub_assign(&mut self, other: RHS, pow: u64);\n}\n\n/// Divides a number by $2^k$, returning just the remainder. The remainder is non-negative.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and $0\n/// \\leq r < 2^k$.\npub trait ModPowerOf2 {\n    type Output;\n\n    fn mod_power_of_2(self, other: u64) -> Self::Output;\n}\n\n/// Divides a number by $2^k$, replacing the number by the remainder. The remainder is non-negative.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and $0\n/// \\leq r < 2^k$.\npub trait ModPowerOf2Assign {\n    fn mod_power_of_2_assign(&mut self, other: u64);\n}\n\n/// Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the\n/// number.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and $0\n/// \\leq |r| < 2^k$.\npub trait RemPowerOf2 {\n    type Output;\n\n    fn rem_power_of_2(self, other: u64) -> Self::Output;\n}\n\n/// Divides a number by $2^k$, replacing the number by the remainder. The remainder has the same\n/// sign as the number.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and $0\n/// \\leq |r| < 2^k$.\npub trait RemPowerOf2Assign {\n    fn rem_power_of_2_assign(&mut self, other: u64);\n}\n\n/// Divides the negative of a number by $2^k$, returning the remainder.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0\n/// \\leq r < 2^k$.\npub trait NegModPowerOf2 {\n    type Output;\n\n    fn neg_mod_power_of_2(self, other: u64) -> Self::Output;\n}\n\n/// Divides the negative of a number by $2^k$, replacing the number by the remainder.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0\n/// \\leq r < 2^k$.\npub trait NegModPowerOf2Assign {\n    fn neg_mod_power_of_2_assign(&mut self, other: u64);\n}\n\n/// Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and $0\n/// \\leq -r < 2^k$.\npub trait CeilingModPowerOf2 {\n    type Output;\n\n    fn ceiling_mod_power_of_2(self, other: u64) -> Self::Output;\n}\n\n/// Divides a number by $2^k$, replacing the number by the remainder. The remainder is non-positive.\n///\n/// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and $0\n/// \\leq -r < 2^k$.\npub trait CeilingModPowerOf2Assign {\n    fn ceiling_mod_power_of_2_assign(&mut self, other: u64);\n}\n\n/// Left-shifts a number (multiplies it by a power of 2) modulo another number $m$. The number must\n/// be already reduced modulo $m$.\npub trait ModShl<RHS, M = Self> {\n    type Output;\n\n    fn mod_shl(self, other: RHS, m: M) -> Self::Output;\n}\n\n/// Left-shifts a number (multiplies it by a power of 2) modulo another number $m$, in place. The\n/// number must be already reduced modulo $m$.\npub trait ModShlAssign<RHS, M = Self> {\n    fn mod_shl_assign(&mut self, other: RHS, m: M);\n}\n\n/// Left-shifts a number (divides it by a power of 2) modulo another number $m$. The number must be\n/// already reduced modulo $m$.\npub trait ModShr<RHS, M = Self> {\n    type Output;\n\n    fn mod_shr(self, other: RHS, m: M) -> Self::Output;\n}\n\n/// Left-shifts a number (divides it by a power of 2) modulo another number $m$, in place. The\n/// number must be already reduced modulo $m$.\npub trait ModShrAssign<RHS, M = Self> {\n    fn mod_shr_assign(&mut self, other: RHS, m: M);\n}\n\n/// Squares a number modulo another number $m$. The input must be already reduced modulo $m$.\npub trait ModSquare<M = Self> {\n    type Output;\n\n    fn mod_square(self, m: M) -> Self::Output;\n}\n\n/// Squares a number modulo another number $m$, in place. The input must be already reduced modulo\n/// $m$.\npub trait ModSquareAssign<M = Self> {\n    fn mod_square_assign(&mut self, m: M);\n}\n\n/// Squares a number modulo another number $m$. The input must be already reduced modulo $m$.\n///\n/// If multiple modular squarings with the same modulus are necessary, it can be quicker to\n/// precompute some piece of data using\n/// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data) function in\n/// [`ModMulPrecomputed`] and reuse it in the squaring calls.\npub trait ModSquarePrecomputed<RHS = Self, M = Self>: ModPowPrecomputed<RHS, M>\nwhere\n    Self: Sized,\n{\n    fn mod_square_precomputed(self, m: M, data: &Self::Data) -> Self::Output;\n}\n\n/// Squares a number modulo another number $m$, in place. The input must be already reduced modulo\n/// $m$.\n///\n/// If multiple modular squarings with the same modulus are necessary, it can be quicker to\n/// precompute some piece of data using\n/// [`precompute_mod_pow_data`](ModPowPrecomputed::precompute_mod_pow_data) function in\n/// [`ModMulPrecomputed`] and reuse it in the squaring calls.\npub trait ModSquarePrecomputedAssign<RHS = Self, M = Self>: ModPowPrecomputed<RHS, M> {\n    fn mod_square_precomputed_assign(&mut self, m: M, data: &Self::Data);\n}\n\n/// Adds two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.\npub trait ModSub<RHS = Self, M = Self> {\n    type Output;\n\n    fn mod_sub(self, other: RHS, m: M) -> Self::Output;\n}\n\n/// Adds two numbers modulo a third number $m$, in place. The inputs must be already reduced modulo\n/// $m$.\npub trait ModSubAssign<RHS = Self, M = Self> {\n    fn mod_sub_assign(&mut self, other: RHS, m: M);\n}\n\n/// Replaces a number with its negative. Assumes the result is representable.\npub trait NegAssign {\n    fn neg_assign(&mut self);\n}\n\n/// Returns the smallest power of 2 greater than or equal to a number. Assumes the result is\n/// representable.\npub trait NextPowerOf2 {\n    type Output;\n\n    fn next_power_of_2(self) -> Self::Output;\n}\n\n/// Replaces a number with the smallest power of 2 greater than or equal it. Assumes the result is\n/// representable.\npub trait NextPowerOf2Assign {\n    fn next_power_of_2_assign(&mut self);\n}\n\n/// Takes the absolute value of a number.\n///\n/// Returns a tuple of the result along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingAbs {\n    type Output;\n\n    fn overflowing_abs(self) -> (Self::Output, bool);\n}\n\n/// Replaces a number with its absolute value.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingAbsAssign {\n    fn overflowing_abs_assign(&mut self) -> bool;\n}\n\n/// Adds two numbers.\n///\n/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingAdd<RHS = Self> {\n    type Output;\n\n    fn overflowing_add(self, other: RHS) -> (Self::Output, bool);\n}\n\n/// Adds a number to another number in place.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingAddAssign<RHS = Self> {\n    fn overflowing_add_assign(&mut self, other: RHS) -> bool;\n}\n\n/// Adds a number and the product of two other numbers.\n///\n/// Returns a tuple of the result along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingAddMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn overflowing_add_mul(self, y: Y, z: Z) -> (Self::Output, bool);\n}\n\n/// Adds a number and the product of two other numbers, in place.\n///\n/// Returns a tuple of the result along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingAddMulAssign<Y = Self, Z = Self> {\n    fn overflowing_add_mul_assign(&mut self, y: Y, z: Z) -> bool;\n}\n\n/// Divides two numbers.\n///\n/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingDiv<RHS = Self> {\n    type Output;\n\n    fn overflowing_div(self, other: RHS) -> (Self::Output, bool);\n}\n\n/// Divides a number by another number in place.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingDivAssign<RHS = Self> {\n    fn overflowing_div_assign(&mut self, other: RHS) -> bool;\n}\n\n/// Multiplies two numbers.\n///\n/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingMul<RHS = Self> {\n    type Output;\n\n    fn overflowing_mul(self, other: RHS) -> (Self::Output, bool);\n}\n\n/// Multiplies a number by another number in place.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingMulAssign<RHS = Self> {\n    fn overflowing_mul_assign(&mut self, other: RHS) -> bool;\n}\n\n/// Negates a number.\n///\n/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingNeg {\n    type Output;\n\n    fn overflowing_neg(self) -> (Self::Output, bool);\n}\n\n/// Negates a number in place.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingNegAssign {\n    fn overflowing_neg_assign(&mut self) -> bool;\n}\n\n/// Raises a number to a power.\n///\n/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingPow<RHS> {\n    type Output;\n\n    fn overflowing_pow(self, exp: RHS) -> (Self::Output, bool);\n}\n\n/// Raises a number to a power in place.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingPowAssign<RHS = Self> {\n    fn overflowing_pow_assign(&mut self, exp: RHS) -> bool;\n}\n\n/// Squares a number.\n///\n/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingSquare {\n    type Output;\n\n    fn overflowing_square(self) -> (Self::Output, bool);\n}\n\n/// Squares a number in place.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingSquareAssign {\n    fn overflowing_square_assign(&mut self) -> bool;\n}\n\n/// Subtracts two numbers.\n///\n/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingSub<RHS = Self> {\n    type Output;\n\n    fn overflowing_sub(self, other: RHS) -> (Self::Output, bool);\n}\n\n/// Subtracts a number by another number in place.\n///\n/// Returns a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred,\n/// then the wrapped number is assigned.\npub trait OverflowingSubAssign<RHS = Self> {\n    fn overflowing_sub_assign(&mut self, other: RHS) -> bool;\n}\n\n/// Subtracts a number by the product of two other numbers.\n///\n/// Returns a tuple of the result along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingSubMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn overflowing_sub_mul(self, y: Y, z: Z) -> (Self::Output, bool);\n}\n\n/// Subtracts a number by the product of two other numbers, in place.\n///\n/// Returns a tuple of the result along with a boolean indicating whether an arithmetic overflow\n/// occurred. If an overflow occurred, then the wrapped number is returned.\npub trait OverflowingSubMulAssign<Y = Self, Z = Self> {\n    fn overflowing_sub_mul_assign(&mut self, y: Y, z: Z) -> bool;\n}\n\n/// Determines whether a number is even or odd.\npub trait Parity {\n    /// Determines whether a number is even.\n    fn even(self) -> bool;\n\n    /// Determines whether a number is odd.\n    fn odd(self) -> bool;\n}\n\n/// Raises a number to a power. Assumes the result is representable.\npub trait Pow<RHS> {\n    type Output;\n\n    fn pow(self, exp: RHS) -> Self::Output;\n}\n\n/// Raises a number to a power in place. Assumes the result is representable.\npub trait PowAssign<RHS = Self> {\n    fn pow_assign(&mut self, exp: RHS);\n}\n\n/// Raises 2 to a power.\npub trait PowerOf2<POW> {\n    fn power_of_2(pow: POW) -> Self;\n}\n\npub trait Primorial {\n    fn primorial(n: u64) -> Self;\n\n    fn product_of_first_n_primes(n: u64) -> Self;\n}\n\npub trait CheckedPrimorial: Sized {\n    fn checked_primorial(n: u64) -> Option<Self>;\n\n    fn checked_product_of_first_n_primes(n: u64) -> Option<Self>;\n}\n\n/// Finds the reciprocal (multiplicative inverse) of a number.\npub trait Reciprocal {\n    type Output;\n\n    fn reciprocal(self) -> Self::Output;\n}\n\n/// Replaces a number with its reciprocal (multiplicative inverse).\npub trait ReciprocalAssign {\n    fn reciprocal_assign(&mut self);\n}\n\n/// Takes the reciprocal of the square root of a number.\npub trait ReciprocalSqrt {\n    type Output;\n\n    fn reciprocal_sqrt(self) -> Self::Output;\n}\n\n/// Replaces a number with the reciprocal of its square root.\npub trait ReciprocalSqrtAssign {\n    fn reciprocal_sqrt_assign(&mut self);\n}\n\n/// Finds the floor of the $n$th root of a number.\npub trait FloorRoot<POW> {\n    type Output;\n\n    fn floor_root(self, pow: POW) -> Self::Output;\n}\n\n/// Replaces a number with the floor of its $n$th root.\npub trait FloorRootAssign<POW> {\n    fn floor_root_assign(&mut self, pow: POW);\n}\n\n/// Finds the ceiling of the $n$th root of a number.\npub trait CeilingRoot<POW> {\n    type Output;\n\n    fn ceiling_root(self, pow: POW) -> Self::Output;\n}\n\n/// Replaces a number with the ceiling of its $n$th root.\npub trait CeilingRootAssign<POW> {\n    fn ceiling_root_assign(&mut self, pow: POW);\n}\n\n/// Finds the $n$th root of a number, returning `None` if it is not a perfect $n$th power.\npub trait CheckedRoot<POW> {\n    type Output;\n\n    fn checked_root(self, pow: POW) -> Option<Self::Output>;\n}\n\n/// Finds the floor of the $n$th root of a number, returning both the root and the remainder.\npub trait RootRem<POW> {\n    type RootOutput;\n    type RemOutput;\n\n    fn root_rem(self, exp: POW) -> (Self::RootOutput, Self::RemOutput);\n}\n\n/// Replaces a number with the floor of its $n$th root, returning the remainder.\npub trait RootAssignRem<POW> {\n    type RemOutput;\n\n    fn root_assign_rem(&mut self, exp: POW) -> Self::RemOutput;\n}\n\n/// Rotates a number left, inserting the leftmost bits into the right end.\npub trait RotateLeft {\n    type Output;\n\n    fn rotate_left(self, n: u64) -> Self::Output;\n}\n\n/// Rotates a number left, inserting the leftmost bits into the right end, in place.\npub trait RotateLeftAssign {\n    fn rotate_left_assign(&mut self, n: u64);\n}\n\n/// Rotates a number right, inserting the leftmost bits into the left end.\npub trait RotateRight {\n    type Output;\n\n    fn rotate_right(self, n: u64) -> Self::Output;\n}\n\n/// Rotates a number right, inserting the leftmost bits into the left end, in place.\npub trait RotateRightAssign {\n    fn rotate_right_assign(&mut self, n: u64);\n}\n\n/// Rounds a number to a multiple of another number, according to a specified rounding mode. An\n/// [`Ordering`] is also returned, indicating whether the returned value is less than, equal to, or\n/// greater than the original value.\npub trait RoundToMultiple<RHS = Self> {\n    type Output;\n\n    fn round_to_multiple(self, other: RHS, rm: RoundingMode) -> (Self::Output, Ordering);\n}\n\n/// Rounds a number to a multiple of another number in place, according to a specified rounding\n/// mode. [`Ordering`] is returned, indicating whether the returned value is less than, equal to, or\n/// greater than the original value.\npub trait RoundToMultipleAssign<RHS = Self> {\n    fn round_to_multiple_assign(&mut self, other: RHS, rm: RoundingMode) -> Ordering;\n}\n\n/// Rounds a number to a multiple of $2^k$, according to a specified rounding mode. An [`Ordering`]\n/// is also returned, indicating whether the returned value is less than, equal to, or greater than\n/// the original value.\npub trait RoundToMultipleOfPowerOf2<RHS> {\n    type Output;\n\n    fn round_to_multiple_of_power_of_2(\n        self,\n        pow: RHS,\n        rm: RoundingMode,\n    ) -> (Self::Output, Ordering);\n}\n\n/// Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode. An\n/// [`Ordering`] is returned, indicating whether the returned value is less than, equal to, or\n/// greater than the original value.\npub trait RoundToMultipleOfPowerOf2Assign<RHS> {\n    fn round_to_multiple_of_power_of_2_assign(&mut self, pow: RHS, rm: RoundingMode) -> Ordering;\n}\n\n/// Takes the absolute value of a number, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingAbs {\n    type Output;\n\n    fn saturating_abs(self) -> Self::Output;\n}\n\n/// Replaces a number with its absolute value, saturating at the numeric bounds instead of\n/// overflowing.\npub trait SaturatingAbsAssign {\n    fn saturating_abs_assign(&mut self);\n}\n\n/// Adds two numbers, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingAdd<RHS = Self> {\n    type Output;\n\n    fn saturating_add(self, other: RHS) -> Self::Output;\n}\n\n/// Add a number to another number in place, saturating at the numeric bounds instead of\n/// overflowing.\npub trait SaturatingAddAssign<RHS = Self> {\n    fn saturating_add_assign(&mut self, other: RHS);\n}\n\n/// Adds a number and the product of two other numbers, saturating at the numeric bounds instead of\n/// overflowing.\npub trait SaturatingAddMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn saturating_add_mul(self, y: Y, z: Z) -> Self::Output;\n}\n\n/// Adds a number and the product of two other numbers in place, saturating at the numeric bounds\n/// instead of overflowing.\npub trait SaturatingAddMulAssign<Y = Self, Z = Self> {\n    fn saturating_add_mul_assign(&mut self, y: Y, z: Z);\n}\n\n/// Multiplies two numbers, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingMul<RHS = Self> {\n    type Output;\n\n    fn saturating_mul(self, other: RHS) -> Self::Output;\n}\n\n/// Multiplies a number by another number in place, saturating at the numeric bounds instead of\n/// overflowing.\npub trait SaturatingMulAssign<RHS = Self> {\n    fn saturating_mul_assign(&mut self, other: RHS);\n}\n\n/// Negates a number, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingNeg {\n    type Output;\n\n    fn saturating_neg(self) -> Self::Output;\n}\n\n/// Negates a number in place, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingNegAssign {\n    fn saturating_neg_assign(&mut self);\n}\n\n/// Raises a number to a power, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingPow<RHS> {\n    type Output;\n\n    fn saturating_pow(self, exp: RHS) -> Self::Output;\n}\n\n/// Raises a number to a power in place, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingPowAssign<RHS = Self> {\n    fn saturating_pow_assign(&mut self, exp: RHS);\n}\n\n/// Squares a number, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingSquare {\n    type Output;\n\n    fn saturating_square(self) -> Self::Output;\n}\n\n/// Squares a number in place, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingSquareAssign {\n    fn saturating_square_assign(&mut self);\n}\n\n/// Subtracts two numbers, saturating at the numeric bounds instead of overflowing.\npub trait SaturatingSub<RHS = Self> {\n    type Output;\n\n    fn saturating_sub(self, other: RHS) -> Self::Output;\n}\n\n/// Subtracts a number by another number in place, saturating at the numeric bounds instead of\n/// overflowing.\npub trait SaturatingSubAssign<RHS = Self> {\n    fn saturating_sub_assign(&mut self, other: RHS);\n}\n\n/// Subtracts a number by the product of two other numbers, saturating at the numeric bounds instead\n/// of overflowing.\npub trait SaturatingSubMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn saturating_sub_mul(self, y: Y, z: Z) -> Self::Output;\n}\n\n/// Subtracts a number by the product of two other numbers in place, saturating at the numeric\n/// bounds instead of overflowing.\npub trait SaturatingSubMulAssign<Y = Self, Z = Self> {\n    fn saturating_sub_mul_assign(&mut self, y: Y, z: Z);\n}\n\n/// Left-shifts a number (multiplies it by a power of 2), rounding the result according to a\n/// specified rounding mode. An [`Ordering`] is also returned, indicating whether the returned value\n/// is less than, equal to, or greater than the exact value.\n///\n/// Rounding might only be necessary if `other` is negative.\npub trait ShlRound<RHS> {\n    type Output;\n\n    fn shl_round(self, other: RHS, rm: RoundingMode) -> (Self::Output, Ordering);\n}\n\n/// Left-shifts a number (multiplies it by a power of 2) in place, rounding the result according to\n/// a specified rounding mode. An [`Ordering`] is also returned, indicating whether the assigned\n/// value is less than, equal to, or greater than the exact value.\n///\n/// Rounding might only be necessary if `other` is negative.\npub trait ShlRoundAssign<RHS> {\n    fn shl_round_assign(&mut self, other: RHS, rm: RoundingMode) -> Ordering;\n}\n\n/// Right-shifts a number (divides it by a power of 2), rounding the result according to a specified\n/// rounding mode. An [`Ordering`] is also returned, indicating whether the returned value is less\n/// than, equal to, or greater than the exact value.\n///\n/// Rounding might only be necessary if `other` is positive.\npub trait ShrRound<RHS> {\n    type Output;\n\n    fn shr_round(self, other: RHS, rm: RoundingMode) -> (Self::Output, Ordering);\n}\n\n/// Right-shifts a number (divides it by a power of 2) in place, rounding the result according to a\n/// specified rounding mode. An [`Ordering`] is also returned, indicating whether the assigned value\n/// is less than, equal to, or greater than the exact value.\n///\n/// Rounding might only be necessary if `other` is positive.\npub trait ShrRoundAssign<RHS> {\n    fn shr_round_assign(&mut self, other: RHS, rm: RoundingMode) -> Ordering;\n}\n\n/// Returns `Greater`, `Equal`, or `Less`, depending on whether a number is positive, zero, or\n/// negative, respectively.\npub trait Sign {\n    fn sign(&self) -> Ordering;\n}\n\n/// Takes the square root of a number.\npub trait Sqrt {\n    type Output;\n\n    fn sqrt(self) -> Self::Output;\n}\n\n/// Replaces a number with its square root.\npub trait SqrtAssign {\n    fn sqrt_assign(&mut self);\n}\n\n/// Finds the floor of the square root of a number.\npub trait FloorSqrt {\n    type Output;\n\n    fn floor_sqrt(self) -> Self::Output;\n}\n\n/// Replaces a number with the floor of its square root.\npub trait FloorSqrtAssign {\n    fn floor_sqrt_assign(&mut self);\n}\n\n/// Finds the ceiling of the square root of a number.\npub trait CeilingSqrt {\n    type Output;\n\n    fn ceiling_sqrt(self) -> Self::Output;\n}\n\n/// Replaces a number with the ceiling of its square root.\npub trait CeilingSqrtAssign {\n    fn ceiling_sqrt_assign(&mut self);\n}\n\n/// Finds the square root of a number, returning `None` if it is not a perfect square.\npub trait CheckedSqrt {\n    type Output;\n\n    fn checked_sqrt(self) -> Option<Self::Output>;\n}\n\n/// Finds the floor of the square root of a number, returning both the root and the remainder.\npub trait SqrtRem {\n    type SqrtOutput;\n    type RemOutput;\n\n    fn sqrt_rem(self) -> (Self::SqrtOutput, Self::RemOutput);\n}\n\n/// Replaces a number with the floor of its square root, returning the remainder.\npub trait SqrtAssignRem {\n    type RemOutput;\n\n    fn sqrt_assign_rem(&mut self) -> Self::RemOutput;\n}\n\n/// Squares a number.\npub trait Square {\n    type Output;\n\n    fn square(self) -> Self::Output;\n}\n\n/// Replaces a number with its square.\npub trait SquareAssign {\n    fn square_assign(&mut self);\n}\n\n/// Subtracts a number by the product of two other numbers.\npub trait SubMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn sub_mul(self, y: Y, z: Z) -> Self::Output;\n}\n\n/// Subtracts a number by the product of two other numbers, in place.\npub trait SubMulAssign<Y = Self, Z = Self> {\n    fn sub_mul_assign(&mut self, y: Y, z: Z);\n}\n\n/// Takes the absolute value of a number, wrapping around at the boundary of the type.\npub trait WrappingAbs {\n    type Output;\n\n    fn wrapping_abs(self) -> Self::Output;\n}\n\n/// Replaces a number with its absolute value, wrapping around at the boundary of the type.\npub trait WrappingAbsAssign {\n    fn wrapping_abs_assign(&mut self);\n}\n\n/// Adds two numbers, wrapping around at the boundary of the type.\npub trait WrappingAdd<RHS = Self> {\n    type Output;\n\n    fn wrapping_add(self, other: RHS) -> Self::Output;\n}\n\n/// Adds a number to another number in place, wrapping around at the boundary of the type.\npub trait WrappingAddAssign<RHS = Self> {\n    fn wrapping_add_assign(&mut self, other: RHS);\n}\n\n/// Adds a number and the product of two other numbers, wrapping around at the boundary of the type.\npub trait WrappingAddMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn wrapping_add_mul(self, y: Y, z: Z) -> Self::Output;\n}\n\n/// Adds a number and the product of two other numbers, in place, wrapping around at the boundary of\n/// the type.\npub trait WrappingAddMulAssign<Y = Self, Z = Self> {\n    fn wrapping_add_mul_assign(&mut self, y: Y, z: Z);\n}\n\n/// Divides a number by another number, wrapping around at the boundary of the type.\npub trait WrappingDiv<RHS = Self> {\n    type Output;\n\n    fn wrapping_div(self, other: RHS) -> Self::Output;\n}\n\n/// Divides a number by another number in place, wrapping around at the boundary of the type.\npub trait WrappingDivAssign<RHS = Self> {\n    fn wrapping_div_assign(&mut self, other: RHS);\n}\n\n/// Multiplies two numbers, wrapping around at the boundary of the type.\npub trait WrappingMul<RHS = Self> {\n    type Output;\n\n    fn wrapping_mul(self, other: RHS) -> Self::Output;\n}\n\n/// Multiplies a number by another number in place, wrapping around at the boundary of the type.\npub trait WrappingMulAssign<RHS = Self> {\n    fn wrapping_mul_assign(&mut self, other: RHS);\n}\n\n/// Negates a number, wrapping around at the boundary of the type.\npub trait WrappingNeg {\n    type Output;\n\n    fn wrapping_neg(self) -> Self::Output;\n}\n\n/// Negates a number in place, wrapping around at the boundary of the type.\npub trait WrappingNegAssign {\n    fn wrapping_neg_assign(&mut self);\n}\n\n/// Raises a number to a power, wrapping around at the boundary of the type.\npub trait WrappingPow<RHS> {\n    type Output;\n\n    fn wrapping_pow(self, exp: RHS) -> Self::Output;\n}\n\n/// Raises a number to a power in place, wrapping around at the boundary of the type.\npub trait WrappingPowAssign<RHS = Self> {\n    fn wrapping_pow_assign(&mut self, exp: RHS);\n}\n\n/// Squares a number, wrapping around at the boundary of the type.\npub trait WrappingSquare {\n    type Output;\n\n    fn wrapping_square(self) -> Self::Output;\n}\n\n/// Squares a number in place, wrapping around at the boundary of the type.\npub trait WrappingSquareAssign {\n    fn wrapping_square_assign(&mut self);\n}\n\n/// Subtracts two numbers, wrapping around at the boundary of the type.\npub trait WrappingSub<RHS = Self> {\n    type Output;\n\n    fn wrapping_sub(self, other: RHS) -> Self::Output;\n}\n\n/// Subtracts a number by another number in place, wrapping around at the boundary of the type.\npub trait WrappingSubAssign<RHS = Self> {\n    fn wrapping_sub_assign(&mut self, other: RHS);\n}\n\n/// Subtracts a number by the product of two other numbers, wrapping around at the boundary of the\n/// type.\npub trait WrappingSubMul<Y = Self, Z = Self> {\n    type Output;\n\n    fn wrapping_sub_mul(self, y: Y, z: Z) -> Self::Output;\n}\n\n/// Subtracts a number by the product of two other numbers, in place, wrapping around at the\n/// boundary of the type.\npub trait WrappingSubMulAssign<Y = Self, Z = Self> {\n    fn wrapping_sub_mul_assign(&mut self, y: Y, z: Z);\n}\n\n/// Multiplies two numbers, returning the product as a pair of `Self` values.\n///\n/// The more significant number always comes first.\npub trait XMulYToZZ: Sized {\n    fn x_mul_y_to_zz(x: Self, y: Self) -> (Self, Self);\n}\n\n/// Adds two numbers, each composed of two `Self` values, returning the sum as a pair of `Self`\n/// values.\n///\n/// The more significant number always comes first. Addition is wrapping, and overflow is not\n/// indicated.\npub trait XXAddYYToZZ: Sized {\n    fn xx_add_yy_to_zz(x_1: Self, x_0: Self, y_1: Self, y_0: Self) -> (Self, Self);\n}\n\n/// Computes the quotient and remainder of two numbers. The first is composed of two `Self` values,\n/// and the second of a single one.\n///\n/// `x_1` must be less than `y`.\npub trait XXDivModYToQR: Sized {\n    fn xx_div_mod_y_to_qr(x_1: Self, x_0: Self, y: Self) -> (Self, Self);\n}\n\n/// Subtracts two numbers, each composed of two `Self` values, returing the difference as a pair of\n/// `Self` values.\n///\n/// The more significant number always comes first. Subtraction is wrapping, and overflow is not\n/// indicated.\npub trait XXSubYYToZZ: Sized {\n    fn xx_sub_yy_to_zz(x_1: Self, x_0: Self, y_1: Self, y_0: Self) -> (Self, Self);\n}\n\n/// Adds two numbers, each composed of three `Self` values, returning the sum as a triple of `Self`\n/// values.\n///\n/// The more significant number always comes first. Addition is wrapping, and overflow is not\n/// indicated.\npub trait XXXAddYYYToZZZ: Sized {\n    fn xxx_add_yyy_to_zzz(\n        x_2: Self,\n        x_1: Self,\n        x_0: Self,\n        y_2: Self,\n        y_1: Self,\n        y_0: Self,\n    ) -> (Self, Self, Self);\n}\n\n/// Subtracts two numbers, each composed of three `Self` values, returing the difference as a triple\n/// of `Self` values.\n///\n/// The more significant number always comes first. Subtraction is wrapping, and overflow is not\n/// indicated.\npub trait XXXSubYYYToZZZ: Sized {\n    fn xxx_sub_yyy_to_zzz(\n        x_2: Self,\n        x_1: Self,\n        x_0: Self,\n        y_2: Self,\n        y_1: Self,\n        y_0: Self,\n    ) -> (Self, Self, Self);\n}\n\n/// Adds two numbers, each composed of four `Self` values, returning the sum as a quadruple of\n/// `Self` values.\n///\n/// The more significant number always comes first. Addition is wrapping, and overflow is not\n/// indicated.\npub trait XXXXAddYYYYToZZZZ: Sized {\n    #[allow(clippy::too_many_arguments)]\n    fn xxxx_add_yyyy_to_zzzz(\n        x_3: Self,\n        x_2: Self,\n        x_1: Self,\n        x_0: Self,\n        y_3: Self,\n        y_2: Self,\n        y_1: Self,\n        y_0: Self,\n    ) -> (Self, Self, Self, Self);\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingAbs, WrappingAbsAssign};\n\nmacro_rules! impl_wrapping_abs {\n    ($t:ident) => {\n        impl WrappingAbs for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_abs` functions in the standard library, for\n            /// example [this one](i32::wrapping_abs).\n            #[inline]\n            fn wrapping_abs(self) -> $t {\n                $t::wrapping_abs(self)\n            }\n        }\n\n        impl WrappingAbsAssign for $t {\n            /// Replaces a number with its absolute value, wrapping around at the boundary of the\n            /// type.\n            ///\n            /// $$\n            /// x \\gets \\\\begin{cases}\n            ///     |x| & \\text{if} \\\\quad x > -2^{W-1}, \\\\\\\\\n            ///     -2^{W-1} & \\text{if} \\\\quad x = -2^{W-1},\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_abs#wrapping_abs_assign).\n            #[inline]\n            fn wrapping_abs_assign(&mut self) {\n                *self = self.wrapping_abs();\n            }\n        }\n    };\n}\napply_to_signeds!(impl_wrapping_abs);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingAdd, WrappingAddAssign};\n\nmacro_rules! impl_wrapping_add {\n    ($t:ident) => {\n        impl WrappingAdd<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_add` functions in the standard library, for\n            /// example [this one](u32::wrapping_add).\n            #[inline]\n            fn wrapping_add(self, other: $t) -> $t {\n                $t::wrapping_add(self, other)\n            }\n        }\n\n        impl WrappingAddAssign<$t> for $t {\n            /// Adds a number to another number in place, wrapping around at the boundary of the\n            /// type.\n            ///\n            /// $x \\gets z$, where $z \\equiv x + y \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_add#wrapping_add_assign).\n            #[inline]\n            fn wrapping_add_assign(&mut self, other: $t) {\n                *self = self.wrapping_add(other);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_add);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingAddMul, WrappingAddMulAssign};\nuse crate::num::basic::integers::PrimitiveInt;\n\nfn wrapping_add_mul<T: PrimitiveInt>(x: T, y: T, z: T) -> T {\n    x.wrapping_add(y.wrapping_mul(z))\n}\n\nfn wrapping_add_mul_assign<T: PrimitiveInt>(x: &mut T, y: T, z: T) {\n    x.wrapping_add_assign(y.wrapping_mul(z));\n}\n\nmacro_rules! impl_wrapping_add_mul {\n    ($t:ident) => {\n        impl WrappingAddMul<$t> for $t {\n            type Output = $t;\n\n            /// Adds a number and the product of two other numbers, wrapping around at the boundary\n            /// of the type.\n            ///\n            /// $f(x, y, z) = w$, where $w \\equiv x + yz \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_add_mul#wrapping_add_mul).\n            #[inline]\n            fn wrapping_add_mul(self, y: $t, z: $t) -> $t {\n                wrapping_add_mul(self, y, z)\n            }\n        }\n\n        impl WrappingAddMulAssign<$t> for $t {\n            /// Adds a number and the product of two other numbers in place, wrapping around at the\n            /// boundary of the type.\n            ///\n            /// $x \\gets w$, where $w \\equiv x + yz \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_add_mul#wrapping_add_mul_assign).\n            #[inline]\n            fn wrapping_add_mul_assign(&mut self, y: $t, z: $t) {\n                wrapping_add_mul_assign(self, y, z);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_add_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingDiv, WrappingDivAssign};\n\nmacro_rules! impl_wrapping_div {\n    ($t:ident) => {\n        impl WrappingDiv<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_div` functions in the standard library, for\n            /// example [this one](u32::wrapping_div).\n            #[inline]\n            fn wrapping_div(self, other: $t) -> $t {\n                $t::wrapping_div(self, other)\n            }\n        }\n\n        impl WrappingDivAssign<$t> for $t {\n            /// Divides a number by another number in place, wrapping around at the boundary of the\n            /// type.\n            ///\n            /// Wrapping only occurs when `Self` is signed, `self` is `Self::MIN`, and `other` is\n            /// -1. The \"actual\" result, `-Self::MIN`, can't be represented and is wrapped back to\n            /// `Self::MIN`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_div#wrapping_div_assign).\n            #[inline]\n            fn wrapping_div_assign(&mut self, other: $t) {\n                *self = self.wrapping_div(other);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_div);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingMul, WrappingMulAssign};\n\nmacro_rules! impl_wrapping_mul {\n    ($t:ident) => {\n        impl WrappingMul<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_mul` functions in the standard library, for\n            /// example [this one](u32::wrapping_mul).\n            #[inline]\n            fn wrapping_mul(self, other: $t) -> $t {\n                $t::wrapping_mul(self, other)\n            }\n        }\n\n        impl WrappingMulAssign<$t> for $t {\n            /// Adds a number to another number in place, wrapping around at the boundary of the\n            /// type.\n            ///\n            /// $x \\gets z$, where $z \\equiv xy \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_mul#wrapping_mul_assign).\n            #[inline]\n            fn wrapping_mul_assign(&mut self, other: $t) {\n                *self = self.wrapping_mul(other);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingNeg, WrappingNegAssign};\n\nmacro_rules! impl_wrapping_neg {\n    ($t:ident) => {\n        impl WrappingNeg for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_neg` functions in the standard library, for\n            /// example [this one](u32::wrapping_neg).\n            #[inline]\n            fn wrapping_neg(self) -> $t {\n                $t::wrapping_neg(self)\n            }\n        }\n\n        impl WrappingNegAssign for $t {\n            /// Negates a number in place, wrapping around at the boundary of the type.\n            ///\n            /// $x \\gets y$, where $y \\equiv -x \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_neg#wrapping_neg_assign).\n            #[inline]\n            fn wrapping_neg_assign(&mut self) {\n                *self = self.wrapping_neg();\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_neg);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{Parity, UnsignedAbs, WrappingPow, WrappingPowAssign};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::logic::traits::BitIterable;\n\nfn wrapping_pow_unsigned<T: PrimitiveUnsigned>(x: T, exp: u64) -> T {\n    if exp == 0 {\n        T::ONE\n    } else if x < T::TWO {\n        x\n    } else {\n        let mut power = x;\n        for bit in exp.bits().rev().skip(1) {\n            power.wrapping_square_assign();\n            if bit {\n                power.wrapping_mul_assign(x);\n            }\n        }\n        power\n    }\n}\n\nfn wrapping_pow_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    x: S,\n    exp: u64,\n) -> S {\n    let p_abs = x.unsigned_abs().wrapping_pow(exp);\n    if x >= S::ZERO || exp.even() {\n        S::wrapping_from(p_abs)\n    } else {\n        S::wrapping_from(p_abs).wrapping_neg()\n    }\n}\n\nmacro_rules! impl_wrapping_pow_unsigned {\n    ($t:ident) => {\n        impl WrappingPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_pow` functions in the standard library, for\n            /// example [this one](u32::wrapping_pow).\n            #[inline]\n            fn wrapping_pow(self, exp: u64) -> $t {\n                wrapping_pow_unsigned(self, exp)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_wrapping_pow_unsigned);\n\nmacro_rules! impl_wrapping_pow_signed {\n    ($t:ident) => {\n        impl WrappingPow<u64> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_pow` functions in the standard library, for\n            /// example [this one](i32::wrapping_pow).\n            #[inline]\n            fn wrapping_pow(self, exp: u64) -> $t {\n                wrapping_pow_signed(self, exp)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_wrapping_pow_signed);\n\nmacro_rules! impl_wrapping_pow_primitive_int {\n    ($t:ident) => {\n        impl WrappingPowAssign<u64> for $t {\n            /// Raises a number to a power, in place, wrapping around at the boundary of the type.\n            ///\n            /// $x \\gets y$, where $y \\equiv x^n \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_pow#wrapping_pow_assign).\n            #[inline]\n            fn wrapping_pow_assign(&mut self, exp: u64) {\n                *self = WrappingPow::wrapping_pow(*self, exp);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_pow_primitive_int);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingMulAssign, WrappingSquare, WrappingSquareAssign};\n\nmacro_rules! impl_wrapping_square {\n    ($t:ident) => {\n        impl WrappingSquare for $t {\n            type Output = $t;\n\n            /// Squares a number, wrapping around at the boundary of the type.\n            ///\n            /// $f(x) = y$, where $y \\equiv x^2 \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_square#wrapping_square).\n            #[inline]\n            fn wrapping_square(self) -> $t {\n                self.wrapping_mul(self)\n            }\n        }\n\n        impl WrappingSquareAssign for $t {\n            /// Squares a number in place, wrapping around at the boundary of the type.\n            ///\n            /// $x \\gets y$, where $y \\equiv x^2 \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_square#wrapping_square_assign).\n            #[inline]\n            fn wrapping_square_assign(&mut self) {\n                self.wrapping_mul_assign(*self);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_square);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingSub, WrappingSubAssign};\n\nmacro_rules! impl_wrapping_sub {\n    ($t:ident) => {\n        impl WrappingSub<$t> for $t {\n            type Output = $t;\n\n            /// This is a wrapper over the `wrapping_sub` functions in the standard library, for\n            /// example [this one](u32::wrapping_sub).\n            #[inline]\n            fn wrapping_sub(self, other: $t) -> $t {\n                $t::wrapping_sub(self, other)\n            }\n        }\n\n        impl WrappingSubAssign<$t> for $t {\n            /// Subtracts a number by another number in place, wrapping around at the boundary of\n            /// the type.\n            ///\n            /// $x \\gets z$, where $z \\equiv x - y \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_sub#wrapping_sub_assign).\n            #[inline]\n            fn wrapping_sub_assign(&mut self, other: $t) {\n                *self = self.wrapping_sub(other);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_sub);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/wrapping_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{WrappingSubMul, WrappingSubMulAssign};\nuse crate::num::basic::integers::PrimitiveInt;\n\nfn wrapping_sub_mul<T: PrimitiveInt>(x: T, y: T, z: T) -> T {\n    x.wrapping_sub(y.wrapping_mul(z))\n}\n\nfn wrapping_sub_mul_assign<T: PrimitiveInt>(x: &mut T, y: T, z: T) {\n    x.wrapping_sub_assign(y.wrapping_mul(z));\n}\n\nmacro_rules! impl_wrapping_sub_mul {\n    ($t:ident) => {\n        impl WrappingSubMul<$t> for $t {\n            type Output = $t;\n\n            /// Subtracts a number by the product of two other numbers, wrapping around at the\n            /// boundary of the type.\n            ///\n            /// $f(x, y, z) = w$, where $w \\equiv x - yz \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_sub_mul#wrapping_sub_mul).\n            #[inline]\n            fn wrapping_sub_mul(self, y: $t, z: $t) -> $t {\n                wrapping_sub_mul(self, y, z)\n            }\n        }\n\n        impl WrappingSubMulAssign<$t> for $t {\n            /// Subtracts a number by the product of two other numbers in place, wrapping around at\n            /// the boundary of the type.\n            ///\n            /// $x \\gets w$, where $w \\equiv x - yz \\mod 2^W$ and $W$ is `Self::WIDTH`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::wrapping_sub_mul#wrapping_sub_mul_assign).\n            #[inline]\n            fn wrapping_sub_mul_assign(&mut self, y: $t, z: $t) {\n                wrapping_sub_mul_assign(self, y, z)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_wrapping_sub_mul);\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/x_mul_y_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-1994, 1996, 1997, 1999-2005, 2007-2009, 2011-2020 Free Software\n//      Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::XMulYToZZ;\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::half::{wide_join_halves, wide_split_in_half, wide_upper_half};\nuse crate::num::conversion::traits::{HasHalf, SplitInHalf, WrappingFrom};\n\nfn implicit_x_mul_y_to_zz<T, DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf>(\n    x: T,\n    y: T,\n) -> (T, T) {\n    (DT::from(x) * DT::from(y)).split_in_half()\n}\n\npub_test! {explicit_x_mul_y_to_zz<T: PrimitiveUnsigned>(x: T, y: T) -> (T, T) {\n    let (x_1, x_0) = wide_split_in_half(x);\n    let (y_1, y_0) = wide_split_in_half(y);\n    let x_0_y_0 = x_0 * y_0;\n    let mut x_0_y_1 = x_0 * y_1;\n    let x_1_y_0 = x_1 * y_0;\n    let mut x_1_y_1 = x_1 * y_1;\n    let (x_0_y_0_1, x_0_y_0_0) = wide_split_in_half(x_0_y_0);\n    x_0_y_1.wrapping_add_assign(x_0_y_0_1);\n    if x_0_y_1.overflowing_add_assign(x_1_y_0) {\n        x_1_y_1.wrapping_add_assign(T::power_of_2(T::WIDTH >> 1));\n    }\n    let z_1 = x_1_y_1.wrapping_add(wide_upper_half(x_0_y_1));\n    let z_0 = wide_join_halves(x_0_y_1, x_0_y_0_0);\n    (z_1, z_0)\n}}\n\nmacro_rules! implicit_x_mul_y_to_zz {\n    ($t:ident, $dt:ident) => {\n        impl XMulYToZZ for $t {\n            /// Multiplies two numbers, returning the product as a pair of `Self` values.\n            ///\n            /// The more significant value always comes first.\n            ///\n            /// $$\n            /// f(x, y) = (z_1, z_0),\n            /// $$\n            /// where $W$ is `Self::WIDTH`,\n            ///\n            /// $x, y, z_1, z_0 < 2^W$, and\n            /// $$\n            /// xy = 2^Wz_1 + z_0.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::x_mul_y_to_zz#x_mul_y_to_zz).\n            ///\n            /// This is equivalent to `umul_ppmm` from `longlong.h`, GMP 6.2.1, where `(w1, w0)` is\n            /// returned.\n            #[inline]\n            fn x_mul_y_to_zz(x: $t, y: $t) -> ($t, $t) {\n                implicit_x_mul_y_to_zz::<$t, $dt>(x, y)\n            }\n        }\n    };\n}\n\nimplicit_x_mul_y_to_zz!(u8, u16);\nimplicit_x_mul_y_to_zz!(u16, u32);\nimplicit_x_mul_y_to_zz!(u32, u64);\nimplicit_x_mul_y_to_zz!(u64, u128);\n\nimpl XMulYToZZ for usize {\n    /// Multiplies two numbers, returning the product as a pair of [`usize`] values.\n    ///\n    /// The more significant value always comes first.\n    ///\n    /// $$\n    /// f(x, y) = (z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x, y, z_1, z_0 < 2^W$, and\n    /// $$\n    /// xy = 2^Wz_1 + z_0.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::x_mul_y_to_zz#x_mul_y_to_zz).\n    ///\n    /// This is equivalent to `umul_ppmm` from `longlong.h`, GMP 6.2.1, where `(w1, w0)` is\n    /// returned.\n    fn x_mul_y_to_zz(x: Self, y: Self) -> (Self, Self) {\n        if USIZE_IS_U32 {\n            let (z_1, z_0) = u32::x_mul_y_to_zz(u32::wrapping_from(x), u32::wrapping_from(y));\n            (Self::wrapping_from(z_1), Self::wrapping_from(z_0))\n        } else {\n            let (z_1, z_0) = u64::x_mul_y_to_zz(u64::wrapping_from(x), u64::wrapping_from(y));\n            (Self::wrapping_from(z_1), Self::wrapping_from(z_0))\n        }\n    }\n}\n\nimpl XMulYToZZ for u128 {\n    /// Multiplies two numbers, returning the product as a pair of [`u128`] values.\n    ///\n    /// The more significant value always comes first.\n    ///\n    /// $$\n    /// f(x, y) = (z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x, y, z_1, z_0 < 2^W$, and\n    /// $$\n    /// xy = 2^Wz_1 + z_0.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::x_mul_y_to_zz#x_mul_y_to_zz).\n    ///\n    /// This is equivalent to `umul_ppmm` from `longlong.h`, GMP 6.2.1, where `(w1, w0)` is\n    /// returned.\n    #[inline]\n    fn x_mul_y_to_zz(x: Self, y: Self) -> (Self, Self) {\n        explicit_x_mul_y_to_zz(x, y)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/xx_add_yy_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-1994, 1996, 1997, 1999-2005, 2007-2009, 2011-2020 Free Software\n//      Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::XXAddYYToZZ;\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{JoinHalves, SplitInHalf, WrappingFrom};\n\nfn implicit_xx_add_yy_to_zz<DT: JoinHalves + PrimitiveUnsigned + SplitInHalf>(\n    x_1: DT::Half,\n    x_0: DT::Half,\n    y_1: DT::Half,\n    y_0: DT::Half,\n) -> (DT::Half, DT::Half) {\n    DT::join_halves(x_1, x_0)\n        .wrapping_add(DT::join_halves(y_1, y_0))\n        .split_in_half()\n}\n\npub_test! {\nexplicit_xx_add_yy_to_zz<T: PrimitiveUnsigned>(x_1: T, x_0: T, y_1: T, y_0: T) -> (T, T) {\n    let (z_0, carry) = x_0.overflowing_add(y_0);\n    let mut z_1 = x_1.wrapping_add(y_1);\n    if carry {\n        z_1.wrapping_add_assign(T::ONE);\n    }\n    (z_1, z_0)\n}}\n\nmacro_rules! implicit_xx_add_yy_to_zz {\n    ($t:ident, $dt:ident) => {\n        impl XXAddYYToZZ for $t {\n            /// Adds two numbers, each composed of two `Self` values, returning the sum as a pair of\n            /// `Self` values.\n            ///\n            /// The more significant value always comes first. Addition is wrapping, and overflow is\n            /// not indicated.\n            ///\n            /// $$\n            /// f(x_1, x_0, y_1, y_0) = (z_1, z_0),\n            /// $$\n            /// where $W$ is `Self::WIDTH`,\n            ///\n            /// $x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and\n            /// $$\n            /// (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \\equiv 2^Wz_1 + z_0 \\mod 2^{2W}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::xx_add_yy_to_zz#xx_add_yy_to_zz).\n            ///\n            /// This is equivalent to `add_ssaaaa` from `longlong.h`, GMP 6.2.1, where `(sh, sl)` is\n            /// returned.\n            #[inline]\n            fn xx_add_yy_to_zz(x_1: $t, x_0: $t, y_1: $t, y_0: $t) -> ($t, $t) {\n                implicit_xx_add_yy_to_zz::<$dt>(x_1, x_0, y_1, y_0)\n            }\n        }\n    };\n}\n\nimplicit_xx_add_yy_to_zz!(u8, u16);\nimplicit_xx_add_yy_to_zz!(u16, u32);\nimplicit_xx_add_yy_to_zz!(u32, u64);\nimplicit_xx_add_yy_to_zz!(u64, u128);\n\nimpl XXAddYYToZZ for usize {\n    /// Adds two numbers, each composed of two [`usize`] values, returning the sum as a pair of\n    /// `usize` values.\n    ///\n    /// The more significant value always comes first. Addition is wrapping, and overflow is not\n    /// indicated.\n    ///\n    /// $$\n    /// f(x_1, x_0, y_1, y_0) = (z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and\n    /// $$\n    /// (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \\equiv 2^Wz_1 + z_0 \\mod 2^{2W}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xx_add_yy_to_zz#xx_add_yy_to_zz).\n    ///\n    /// This is equivalent to `add_ssaaaa` from `longlong.h`, GMP 6.2.1, where `(sh, sl)` is\n    /// returned.\n    fn xx_add_yy_to_zz(x_1: Self, x_0: Self, y_1: Self, y_0: Self) -> (Self, Self) {\n        if USIZE_IS_U32 {\n            let (z_1, z_0) = u32::xx_add_yy_to_zz(\n                u32::wrapping_from(x_1),\n                u32::wrapping_from(x_0),\n                u32::wrapping_from(y_1),\n                u32::wrapping_from(y_0),\n            );\n            (Self::wrapping_from(z_1), Self::wrapping_from(z_0))\n        } else {\n            let (z_1, z_0) = u64::xx_add_yy_to_zz(\n                u64::wrapping_from(x_1),\n                u64::wrapping_from(x_0),\n                u64::wrapping_from(y_1),\n                u64::wrapping_from(y_0),\n            );\n            (Self::wrapping_from(z_1), Self::wrapping_from(z_0))\n        }\n    }\n}\n\nimpl XXAddYYToZZ for u128 {\n    /// Adds two numbers, each composed of two [`u128`] values, returning the sum as a pair of\n    /// [`u128`] values.\n    ///\n    /// The more significant value always comes first. Addition is wrapping, and overflow is not\n    /// indicated.\n    ///\n    /// $$\n    /// f(x_1, x_0, y_1, y_0) = (z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and\n    /// $$\n    /// (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \\equiv 2^Wz_1 + z_0 \\mod 2^{2W}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xx_add_yy_to_zz#xx_add_yy_to_zz).\n    ///\n    /// This is equivalent to `add_ssaaaa` from `longlong.h`, GMP 6.2.1, where `(sh, sl)` is\n    /// returned.\n    #[inline]\n    fn xx_add_yy_to_zz(x_1: Self, x_0: Self, y_1: Self, y_0: Self) -> (Self, Self) {\n        explicit_xx_add_yy_to_zz(x_1, x_0, y_1, y_0)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/xx_div_mod_y_to_qr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005\n//      Free Software Foundation, Inc.\n//\n//      Copyright © 2009, 2015, 2016 William Hart\n//\n//      Copyright © 2011 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::XXDivModYToQR;\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::half::{wide_join_halves, wide_split_in_half};\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf};\nuse crate::num::logic::traits::LeadingZeros;\n\nfn implicit_xx_div_mod_y_to_qr<\n    T: PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    x_1: T,\n    x_0: T,\n    y: T,\n) -> (T, T) {\n    assert!(x_1 < y);\n    let (q, r) = DT::join_halves(x_1, x_0).div_mod(DT::from(y));\n    (q.lower_half(), r.lower_half())\n}\n\n// This is equivalent to `udiv_qrnnd_int` from `longlong.h`, FLINT 2.7.1, where `(q, r)` is\n// returned.\nfn explicit_xx_div_mod_y_to_qr_normalized<T: PrimitiveUnsigned>(x_1: T, x_0: T, y: T) -> (T, T) {\n    let (d_1, d_0) = wide_split_in_half(y);\n    let (x_0_1, x_0_0) = wide_split_in_half(x_0);\n    let mut q_1 = x_1 / d_1;\n    let mut r_1 = x_1.wrapping_sub(q_1.wrapping_mul(d_1));\n    let product = q_1.wrapping_mul(d_0);\n    r_1 = wide_join_halves(r_1, x_0_1);\n    if r_1 < product {\n        q_1.wrapping_sub_assign(T::ONE);\n        if !r_1.overflowing_add_assign(y) && r_1 < product {\n            q_1.wrapping_sub_assign(T::ONE);\n            r_1.wrapping_add_assign(y);\n        }\n    }\n    r_1.wrapping_sub_assign(product);\n    let mut q_0 = r_1 / d_1;\n    let mut r_0 = r_1.wrapping_sub(q_0.wrapping_mul(d_1));\n    let product = q_0.wrapping_mul(d_0);\n    r_0 = wide_join_halves(r_0, x_0_0);\n    if r_0 < product {\n        q_0.wrapping_sub_assign(T::ONE);\n        if !r_0.overflowing_add_assign(y) && r_0 < product {\n            q_0.wrapping_sub_assign(T::ONE);\n            r_0.wrapping_add_assign(y);\n        }\n    }\n    r_0.wrapping_sub_assign(product);\n    (wide_join_halves(q_1, q_0), r_0)\n}\n\n// This is udiv_qrnnd from longlong.h, FLINT 2.7.1, where (q, r) is returned.\npub_test! {explicit_xx_div_mod_y_to_qr<T: PrimitiveUnsigned>(x_1: T, x_0: T, y: T) -> (T, T) {\n    assert!(x_1 < y);\n    let shift = LeadingZeros::leading_zeros(y);\n    if shift == 0 {\n        explicit_xx_div_mod_y_to_qr_normalized(x_1, x_0, y)\n    } else {\n        let (q, r) = explicit_xx_div_mod_y_to_qr_normalized(\n            (x_1 << shift) | (x_0 >> (T::WIDTH - shift)),\n            x_0 << shift,\n            y << shift,\n        );\n        (q, r >> shift)\n    }\n}}\n\nmacro_rules! implicit_xx_div_mod_to_qr {\n    ($t:ident, $dt:ident) => {\n        impl XXDivModYToQR for $t {\n            /// Computes the quotient and remainder of two numbers. The first is composed of two\n            /// `Self` values, and the second of a single one.\n            ///\n            /// `x_1` must be less than `y`.\n            ///\n            /// $$\n            /// f(x_1, x_0, y) = (q, r),\n            /// $$\n            /// where $W$ is `Self::WIDTH`,\n            ///\n            /// $x_1, x_0, y, q, r < 2^W$,\n            ///\n            /// $x_1, r < y$, and\n            /// $$\n            /// qy + r = 2^Wx_1 + x_0.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::xx_div_mod_y_to_qr#xx_div_mod_y_to_qr).\n            ///\n            /// This is equivalent to `udiv_qrnnd` from `longlong.h`, FLINT 2.7.1, where `(q, r)` is\n            /// returned.\n            #[inline]\n            fn xx_div_mod_y_to_qr(x_1: $t, x_0: $t, y: $t) -> ($t, $t) {\n                implicit_xx_div_mod_y_to_qr::<$t, $dt>(x_1, x_0, y)\n            }\n        }\n    };\n}\n\nimplicit_xx_div_mod_to_qr!(u8, u16);\nimplicit_xx_div_mod_to_qr!(u16, u32);\nimplicit_xx_div_mod_to_qr!(u32, u64);\nimplicit_xx_div_mod_to_qr!(u64, u128);\n\nimpl XXDivModYToQR for usize {\n    /// Computes the quotient and remainder of two numbers. The first is composed of two [`usize`]\n    /// values, and the second of a single one.\n    ///\n    /// `x_1` must be less than `y`.\n    ///\n    /// $$\n    /// f(x_1, x_0, y) = (q, r),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_1, x_0, y, q, r < 2^W$,\n    ///\n    /// $x_1, r < y$, and\n    /// $$\n    /// qy + r = 2^Wx_1 + x_0.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xx_div_mod_y_to_qr#xx_div_mod_y_to_qr).\n    ///\n    /// This is `udiv_qrnnd` from `longlong.h`, FLINT 2.7.1, where `(q, r)` is returned.\n    fn xx_div_mod_y_to_qr(x_1: Self, x_0: Self, y: Self) -> (Self, Self) {\n        if USIZE_IS_U32 {\n            let (q, r) = u32::xx_div_mod_y_to_qr(\n                u32::wrapping_from(x_1),\n                u32::wrapping_from(x_0),\n                u32::wrapping_from(y),\n            );\n            (Self::wrapping_from(q), Self::wrapping_from(r))\n        } else {\n            let (q, r) = u64::xx_div_mod_y_to_qr(\n                u64::wrapping_from(x_1),\n                u64::wrapping_from(x_0),\n                u64::wrapping_from(y),\n            );\n            (Self::wrapping_from(q), Self::wrapping_from(r))\n        }\n    }\n}\n\nimpl XXDivModYToQR for u128 {\n    /// Computes the quotient and remainder of two numbers. The first is composed of two [`u128`]\n    /// values, and the second of a single one.\n    ///\n    /// `x_1` must be less than `y`.\n    ///\n    /// $$\n    /// f(x_1, x_0, y) = (q, r),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_1, x_0, y, q, r < 2^W$,\n    ///\n    /// $x_1, r < y$, and\n    /// $$\n    /// qy + r = 2^Wx_1 + x_0.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xx_div_mod_y_to_qr#xx_div_mod_y_to_qr).\n    ///\n    /// This is equivalent to `udiv_qrnnd` from `longlong.h`, FLINT 2.7.1, where `(q, r)` is\n    /// returned.\n    #[inline]\n    fn xx_div_mod_y_to_qr(x_1: Self, x_0: Self, y: Self) -> (Self, Self) {\n        explicit_xx_div_mod_y_to_qr(x_1, x_0, y)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/xx_sub_yy_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-1994, 1996, 1997, 1999-2005, 2007-2009, 2011-2020 Free Software\n//      Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::XXSubYYToZZ;\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{JoinHalves, SplitInHalf, WrappingFrom};\n\nfn implicit_xx_sub_yy_to_zz<DT: JoinHalves + PrimitiveUnsigned + SplitInHalf>(\n    x_1: DT::Half,\n    x_0: DT::Half,\n    y_1: DT::Half,\n    y_0: DT::Half,\n) -> (DT::Half, DT::Half) {\n    DT::join_halves(x_1, x_0)\n        .wrapping_sub(DT::join_halves(y_1, y_0))\n        .split_in_half()\n}\n\npub_test! {\nexplicit_xx_sub_yy_to_zz<T: PrimitiveUnsigned>(x_1: T, x_0: T, y_1: T, y_0: T) -> (T, T) {\n    let (z_0, borrow) = x_0.overflowing_sub(y_0);\n    let mut z_1 = x_1.wrapping_sub(y_1);\n    if borrow {\n        z_1.wrapping_sub_assign(T::ONE);\n    }\n    (z_1, z_0)\n}}\n\nmacro_rules! implicit_xx_sub_yy_to_zz {\n    ($t:ident, $dt:ident) => {\n        impl XXSubYYToZZ for $t {\n            /// Subtracts two numbers, each composed of two `Self` values, returning the difference\n            /// as a pair of `Self` values.\n            ///\n            /// The more significant value always comes first. Subtraction is wrapping, and overflow\n            /// is not indicated.\n            ///\n            /// $$\n            /// f(x_1, x_0, y_1, y_0) = (z_1, z_0),\n            /// $$\n            /// where $W$ is `Self::WIDTH`,\n            ///\n            /// $x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and\n            /// $$\n            /// (2^Wx_1 + x_0) - (2^Wy_1 + y_0) \\equiv 2^Wz_1 + z_0 \\mod 2^{2W}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::xx_sub_yy_to_zz#xx_sub_yy_to_zz).\n            ///\n            /// This is equivalent to `sub_ddmmss` from `longlong.h`, GMP 6.2.1, where `(sh, sl)` is\n            /// returned.\n            #[inline]\n            fn xx_sub_yy_to_zz(x_1: $t, x_0: $t, y_1: $t, y_0: $t) -> ($t, $t) {\n                implicit_xx_sub_yy_to_zz::<$dt>(x_1, x_0, y_1, y_0)\n            }\n        }\n    };\n}\n\nimplicit_xx_sub_yy_to_zz!(u8, u16);\nimplicit_xx_sub_yy_to_zz!(u16, u32);\nimplicit_xx_sub_yy_to_zz!(u32, u64);\nimplicit_xx_sub_yy_to_zz!(u64, u128);\n\nimpl XXSubYYToZZ for usize {\n    /// Subtracts two numbers, each composed of two [`usize`] values, returning the difference as a\n    /// pair of [`usize`] values.\n    ///\n    /// The more significant value always comes first. Subtraction is wrapping, and overflow is not\n    /// indicated.\n    ///\n    /// $$\n    /// f(x_1, x_0, y_1, y_0) = (z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and\n    /// $$\n    /// (2^Wx_1 + x_0) - (2^Wy_1 + y_0) \\equiv 2^Wz_1 + z_0 \\mod 2^{2W}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xx_sub_yy_to_zz#xx_sub_yy_to_zz).\n    ///\n    /// This is equivalent to `sub_ddmmss` from `longlong.h`, GMP 6.2.1, where `(sh, sl)` is\n    /// returned.\n    fn xx_sub_yy_to_zz(x_1: Self, x_0: Self, y_1: Self, y_0: Self) -> (Self, Self) {\n        if USIZE_IS_U32 {\n            let (z_1, z_0) = u32::xx_sub_yy_to_zz(\n                u32::wrapping_from(x_1),\n                u32::wrapping_from(x_0),\n                u32::wrapping_from(y_1),\n                u32::wrapping_from(y_0),\n            );\n            (Self::wrapping_from(z_1), Self::wrapping_from(z_0))\n        } else {\n            let (z_1, z_0) = u64::xx_sub_yy_to_zz(\n                u64::wrapping_from(x_1),\n                u64::wrapping_from(x_0),\n                u64::wrapping_from(y_1),\n                u64::wrapping_from(y_0),\n            );\n            (Self::wrapping_from(z_1), Self::wrapping_from(z_0))\n        }\n    }\n}\n\nimpl XXSubYYToZZ for u128 {\n    /// Subtracts two numbers, each composed of two [`u128`] values, returning the difference as a\n    /// pair of [`u128`] values.\n    ///\n    /// The more significant value always comes first. Subtraction is wrapping, and overflow is not\n    /// indicated.\n    ///\n    /// $$\n    /// f(x_1, x_0, y_1, y_0) = (z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and\n    /// $$\n    /// (2^Wx_1 + x_0) - (2^Wy_1 + y_0) \\equiv 2^Wz_1 + z_0 \\mod 2^{2W}.\n    /// $$\n    ///\n    /// # Examples\n    /// See [here](super::xx_sub_yy_to_zz#xx_sub_yy_to_zz).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to `sub_ddmmss` from `longlong.h`, GMP 6.2.1, where `(sh, sl)` is\n    /// returned.\n    #[inline]\n    fn xx_sub_yy_to_zz(x_1: Self, x_0: Self, y_1: Self, y_0: Self) -> (Self, Self) {\n        explicit_xx_sub_yy_to_zz(x_1, x_0, y_1, y_0)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/xxx_add_yyy_to_zzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005\n//      Free Software Foundation, Inc.\n//\n//      Copyright © 2009, 2015, 2016 William Hart\n//\n//      Copyright © 2011 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::XXXAddYYYToZZZ;\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\npub_test! {xxx_add_yyy_to_zzz<T: PrimitiveUnsigned>(\n    x_2: T,\n    x_1: T,\n    x_0: T,\n    y_2: T,\n    y_1: T,\n    y_0: T,\n) -> (T, T, T) {\n    let (z_0, carry_1) = x_0.overflowing_add(y_0);\n    let (mut z_1, mut carry_2) = x_1.overflowing_add(y_1);\n    if carry_1 {\n        carry_2 |= z_1.overflowing_add_assign(T::ONE);\n    }\n    let mut z_2 = x_2.wrapping_add(y_2);\n    if carry_2 {\n        z_2.wrapping_add_assign(T::ONE);\n    }\n    (z_2, z_1, z_0)\n}}\n\nmacro_rules! impl_xxx_add_yyy_to_zzz {\n    ($t:ident) => {\n        impl XXXAddYYYToZZZ for $t {\n            /// Adds two numbers, each composed of three `Self` values, returning the sum as a\n            /// triple of `Self` values.\n            ///\n            /// The more significant value always comes first. Addition is wrapping, and overflow is\n            /// not indicated.\n            ///\n            /// $$\n            /// f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),\n            /// $$\n            /// where $W$ is `Self::WIDTH`,\n            ///\n            /// $x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and\n            /// $$\n            /// (2^{2W}x_2 + 2^Wx_1 + x_0) + (2^{2W}y_2 + 2^Wy_1 + y_0)\n            /// \\equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \\mod 2^{3W}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::xxx_add_yyy_to_zzz#xxx_add_yyy_to_zzz).\n            ///\n            /// This is equivalent to `add_sssaaaaaa` from `longlong.h`, FLINT 2.7.1, where `(sh,\n            /// sm, sl)` is returned.\n            #[inline]\n            fn xxx_add_yyy_to_zzz(\n                x_2: $t,\n                x_1: $t,\n                x_0: $t,\n                y_2: $t,\n                y_1: $t,\n                y_0: $t,\n            ) -> ($t, $t, $t) {\n                xxx_add_yyy_to_zzz::<$t>(x_2, x_1, x_0, y_2, y_1, y_0)\n            }\n        }\n    };\n}\n\nimpl_xxx_add_yyy_to_zzz!(u8);\nimpl_xxx_add_yyy_to_zzz!(u16);\nimpl_xxx_add_yyy_to_zzz!(u32);\nimpl_xxx_add_yyy_to_zzz!(u64);\nimpl_xxx_add_yyy_to_zzz!(u128);\n\nimpl XXXAddYYYToZZZ for usize {\n    /// Adds two numbers, each composed of three [`usize`] values, returning the sum as a triple of\n    /// [`usize`] values.\n    ///\n    /// The more significant value always comes first. Addition is wrapping, and overflow is not\n    /// indicated.\n    ///\n    /// $$\n    /// f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and\n    /// $$\n    /// (2^{2W}x_2 + 2^Wx_1 + x_0) + (2^{2W}y_2 + 2^Wy_1 + y_0)\n    /// \\equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \\mod 2^{3W}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xxx_add_yyy_to_zzz#xxx_add_yyy_to_zzz).\n    ///\n    /// This is equivalent to `add_sssaaaaaa` from `longlong.h`, FLINT 2.7.1, where `(sh, sm, sl)`\n    /// is returned.\n    fn xxx_add_yyy_to_zzz(\n        x_2: Self,\n        x_1: Self,\n        x_0: Self,\n        y_2: Self,\n        y_1: Self,\n        y_0: Self,\n    ) -> (Self, Self, Self) {\n        if USIZE_IS_U32 {\n            let (z_2, z_1, z_0) = u32::xxx_add_yyy_to_zzz(\n                u32::wrapping_from(x_2),\n                u32::wrapping_from(x_1),\n                u32::wrapping_from(x_0),\n                u32::wrapping_from(y_2),\n                u32::wrapping_from(y_1),\n                u32::wrapping_from(y_0),\n            );\n            (\n                Self::wrapping_from(z_2),\n                Self::wrapping_from(z_1),\n                Self::wrapping_from(z_0),\n            )\n        } else {\n            let (z_2, z_1, z_0) = u64::xxx_add_yyy_to_zzz(\n                u64::wrapping_from(x_2),\n                u64::wrapping_from(x_1),\n                u64::wrapping_from(x_0),\n                u64::wrapping_from(y_2),\n                u64::wrapping_from(y_1),\n                u64::wrapping_from(y_0),\n            );\n            (\n                Self::wrapping_from(z_2),\n                Self::wrapping_from(z_1),\n                Self::wrapping_from(z_0),\n            )\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/xxx_sub_yyy_to_zzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005\n//      Free Software Foundation, Inc.\n//\n//      Copyright © 2009, 2015, 2016 William Hart\n//\n//      Copyright © 2011 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::XXXSubYYYToZZZ;\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\npub_test! {xxx_sub_yyy_to_zzz<T: PrimitiveUnsigned>(\n    x_2: T,\n    x_1: T,\n    x_0: T,\n    y_2: T,\n    y_1: T,\n    y_0: T,\n) -> (T, T, T) {\n    let (z_0, borrow_1) = x_0.overflowing_sub(y_0);\n    let (mut z_1, mut borrow_2) = x_1.overflowing_sub(y_1);\n    if borrow_1 {\n        borrow_2 |= z_1.overflowing_sub_assign(T::ONE);\n    }\n    let mut z_2 = x_2.wrapping_sub(y_2);\n    if borrow_2 {\n        z_2.wrapping_sub_assign(T::ONE);\n    }\n    (z_2, z_1, z_0)\n}}\n\nmacro_rules! impl_xxx_sub_yyy_to_zzz {\n    ($t:ident) => {\n        impl XXXSubYYYToZZZ for $t {\n            /// Subtracts two numbers, each composed of three `Self` values, returning the\n            /// difference as a triple of `Self` values.\n            ///\n            /// The more significant value always comes first. Subtraction is wrapping, and overflow\n            /// is not indicated.\n            ///\n            /// $$\n            /// f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),\n            /// $$\n            /// where $W$ is `Self::WIDTH`,\n            ///\n            /// $x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and\n            /// $$\n            /// (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0)\n            /// \\equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \\mod 2^{3W}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::xxx_sub_yyy_to_zzz#xxx_sub_yyy_to_zzz).\n            ///\n            /// This is equivalent to `sub_dddmmmsss` from `longlong.h`, FLINT 2.7.1, where `(dh,\n            /// dm, dl)` is returned.\n            #[inline]\n            fn xxx_sub_yyy_to_zzz(\n                x_2: $t,\n                x_1: $t,\n                x_0: $t,\n                y_2: $t,\n                y_1: $t,\n                y_0: $t,\n            ) -> ($t, $t, $t) {\n                xxx_sub_yyy_to_zzz::<$t>(x_2, x_1, x_0, y_2, y_1, y_0)\n            }\n        }\n    };\n}\n\nimpl_xxx_sub_yyy_to_zzz!(u8);\nimpl_xxx_sub_yyy_to_zzz!(u16);\nimpl_xxx_sub_yyy_to_zzz!(u32);\nimpl_xxx_sub_yyy_to_zzz!(u64);\nimpl_xxx_sub_yyy_to_zzz!(u128);\n\nimpl XXXSubYYYToZZZ for usize {\n    /// Subtracts two numbers, each composed of three [`usize`] values, returning the difference as\n    /// a triple of [`usize`] values.\n    ///\n    /// The more significant value always comes first. Subtraction is wrapping, and overflow is not\n    /// indicated.\n    ///\n    /// $$\n    /// f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and\n    /// $$\n    /// (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0)\n    /// \\equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \\mod 2^{3W}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xxx_sub_yyy_to_zzz#xxx_sub_yyy_to_zzz).\n    ///\n    /// This is equivalent to `sub_dddmmmsss` from `longlong.h`, FLINT 2.7.1, where `(dh, dm, dl)`\n    /// is returned.\n    fn xxx_sub_yyy_to_zzz(\n        x_2: Self,\n        x_1: Self,\n        x_0: Self,\n        y_2: Self,\n        y_1: Self,\n        y_0: Self,\n    ) -> (Self, Self, Self) {\n        if USIZE_IS_U32 {\n            let (z_2, z_1, z_0) = u32::xxx_sub_yyy_to_zzz(\n                u32::wrapping_from(x_2),\n                u32::wrapping_from(x_1),\n                u32::wrapping_from(x_0),\n                u32::wrapping_from(y_2),\n                u32::wrapping_from(y_1),\n                u32::wrapping_from(y_0),\n            );\n            (\n                Self::wrapping_from(z_2),\n                Self::wrapping_from(z_1),\n                Self::wrapping_from(z_0),\n            )\n        } else {\n            let (z_2, z_1, z_0) = u64::xxx_sub_yyy_to_zzz(\n                u64::wrapping_from(x_2),\n                u64::wrapping_from(x_1),\n                u64::wrapping_from(x_0),\n                u64::wrapping_from(y_2),\n                u64::wrapping_from(y_1),\n                u64::wrapping_from(y_0),\n            );\n            (\n                Self::wrapping_from(z_2),\n                Self::wrapping_from(z_1),\n                Self::wrapping_from(z_0),\n            )\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/arithmetic/xxxx_add_yyyy_to_zzzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005\n//      Free Software Foundation, Inc.\n//\n//      Copyright © 2009, 2015, 2016 William Hart\n//\n//      Copyright © 2011 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::XXXXAddYYYYToZZZZ;\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\n#[allow(clippy::too_many_arguments)]\nfn xxxx_add_yyyy_to_zzzz<T: PrimitiveUnsigned>(\n    x_3: T,\n    x_2: T,\n    x_1: T,\n    x_0: T,\n    y_3: T,\n    y_2: T,\n    y_1: T,\n    y_0: T,\n) -> (T, T, T, T) {\n    let (z_0, carry_1) = x_0.overflowing_add(y_0);\n    let (mut z_1, mut carry_2) = x_1.overflowing_add(y_1);\n    if carry_1 {\n        carry_2 |= z_1.overflowing_add_assign(T::ONE);\n    }\n    let (mut z_2, mut carry_3) = x_2.overflowing_add(y_2);\n    if carry_2 {\n        carry_3 |= z_2.overflowing_add_assign(T::ONE);\n    }\n    let mut z_3 = x_3.wrapping_add(y_3);\n    if carry_3 {\n        z_3.wrapping_add_assign(T::ONE);\n    }\n    (z_3, z_2, z_1, z_0)\n}\n\nmacro_rules! impl_xxxx_add_yyyy_to_zzzz {\n    ($t:ident) => {\n        impl XXXXAddYYYYToZZZZ for $t {\n            /// Adds two numbers, each composed of four `Self` values, returning the sum as a\n            /// quadruple of `Self` values.\n            ///\n            /// The more significant value always comes first. Addition is wrapping, and overflow is\n            /// not indicated.\n            ///\n            /// $$\n            /// f(x_3, x_2, x_1, x_0, y_2, y_2, y_1, y_0) = (z_3, z_2, z_1, z_0),\n            /// $$\n            /// where $W$ is `Self::WIDTH`,\n            ///\n            /// $x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0, z_3, z_2, z_1, z_0 < 2^W$, and\n            /// $$\n            /// (2^{3W}x_3 + 2^{2W}x_2 + 2^Wx_1 + x_0) + (2^{3W}y_3 + 2^{2W}y_2 + 2^Wy_1 + y_0)\n            /// \\equiv 2^{3W}z_3 + 2^{2W}z_2 + 2^Wz_1 + z_0 \\mod 2^{4W}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::xxxx_add_yyyy_to_zzzz#xxxx_add_yyyy_to_zzzz).\n            ///\n            /// This is equivalent to `add_ssssaaaaaaaa` from `longlong.h`, FLINT 2.7.1, where `(s3,\n            /// s2, s1, s0)` is returned.\n            #[inline]\n            fn xxxx_add_yyyy_to_zzzz(\n                x_3: $t,\n                x_2: $t,\n                x_1: $t,\n                x_0: $t,\n                y_3: $t,\n                y_2: $t,\n                y_1: $t,\n                y_0: $t,\n            ) -> ($t, $t, $t, $t) {\n                xxxx_add_yyyy_to_zzzz::<$t>(x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0)\n            }\n        }\n    };\n}\n\nimpl_xxxx_add_yyyy_to_zzzz!(u8);\nimpl_xxxx_add_yyyy_to_zzzz!(u16);\nimpl_xxxx_add_yyyy_to_zzzz!(u32);\nimpl_xxxx_add_yyyy_to_zzzz!(u64);\nimpl_xxxx_add_yyyy_to_zzzz!(u128);\n\nimpl XXXXAddYYYYToZZZZ for usize {\n    /// Adds two numbers, each composed of four [`usize`] values, returning the sum as a quadruple\n    /// of [`usize`] values.\n    ///\n    /// The more significant value always comes first. Addition is wrapping, and overflow is not\n    /// indicated.\n    ///\n    /// $$\n    /// f(x_3, x_2, x_1, x_0, y_2, y_2, y_1, y_0) = (z_3, z_2, z_1, z_0),\n    /// $$\n    /// where $W$ is `Self::WIDTH`,\n    ///\n    /// $x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0, z_3, z_2, z_1, z_0 < 2^W$, and\n    /// $$\n    /// (2^{3W}x_3 + 2^{2W}x_2 + 2^Wx_1 + x_0) + (2^{3W}y_3 + 2^{2W}y_2 + 2^Wy_1 + y_0)\n    /// \\equiv 2^{3W}z_3 + 2^{2W}z_2 + 2^Wz_1 + z_0 \\mod 2^{4W}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::xxxx_add_yyyy_to_zzzz#xxxx_add_yyyy_to_zzzz).\n    ///\n    /// This is equivalent to `add_ssssaaaaaaaa` from `longlong.h`, FLINT 2.7.1, where `(s3, s2, s1,\n    /// s0)` is returned.\n    fn xxxx_add_yyyy_to_zzzz(\n        x_3: Self,\n        x_2: Self,\n        x_1: Self,\n        x_0: Self,\n        y_3: Self,\n        y_2: Self,\n        y_1: Self,\n        y_0: Self,\n    ) -> (Self, Self, Self, Self) {\n        if USIZE_IS_U32 {\n            let (z_3, z_2, z_1, z_0) = u32::xxxx_add_yyyy_to_zzzz(\n                u32::wrapping_from(x_3),\n                u32::wrapping_from(x_2),\n                u32::wrapping_from(x_1),\n                u32::wrapping_from(x_0),\n                u32::wrapping_from(y_3),\n                u32::wrapping_from(y_2),\n                u32::wrapping_from(y_1),\n                u32::wrapping_from(y_0),\n            );\n            (\n                Self::wrapping_from(z_3),\n                Self::wrapping_from(z_2),\n                Self::wrapping_from(z_1),\n                Self::wrapping_from(z_0),\n            )\n        } else {\n            let (z_3, z_2, z_1, z_0) = u64::xxxx_add_yyyy_to_zzzz(\n                u64::wrapping_from(x_3),\n                u64::wrapping_from(x_2),\n                u64::wrapping_from(x_1),\n                u64::wrapping_from(x_0),\n                u64::wrapping_from(y_3),\n                u64::wrapping_from(y_2),\n                u64::wrapping_from(y_1),\n                u64::wrapping_from(y_0),\n            );\n            (\n                Self::wrapping_from(z_3),\n                Self::wrapping_from(z_2),\n                Self::wrapping_from(z_1),\n                Self::wrapping_from(z_0),\n            )\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/basic/floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::comparison::traits::{Max, Min};\nuse crate::named::Named;\nuse crate::num::arithmetic::traits::{\n    Abs, AbsAssign, AddMul, AddMulAssign, Ceiling, CeilingAssign, CeilingLogBase2,\n    CeilingLogBasePowerOf2, CheckedLogBase2, CheckedLogBasePowerOf2, Floor, FloorAssign,\n    FloorLogBase2, FloorLogBasePowerOf2, IsPowerOf2, NegAssign, NextPowerOf2, NextPowerOf2Assign,\n    Pow, PowAssign, PowerOf2, Reciprocal, ReciprocalAssign, Sign, Sqrt, SqrtAssign, Square,\n    SquareAssign, SubMul, SubMulAssign,\n};\nuse crate::num::basic::traits::{\n    GaussConstant, Infinity, LemniscateConstant, Ln2, Log2E, NaN, NegativeInfinity, NegativeOne,\n    NegativeZero, One, OneHalf, OneOverPi, OneOverSqrtPi, OneOverSqrtTau, Phi, Pi, PiOver2,\n    PiOver3, PiOver4, PiOver6, PiOver8, PrimeConstant, ProuhetThueMorseConstant, Sqrt2, Sqrt2Over2,\n    Sqrt3, Sqrt3Over3, SqrtPi, Tau, Two, TwoOverPi, TwoOverSqrtPi, Zero,\n};\nuse crate::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, ExactInto, IntegerMantissaAndExponent, IsInteger, RawMantissaAndExponent,\n    RoundingFrom, RoundingInto, SciMantissaAndExponent, WrappingFrom,\n};\nuse crate::num::float::FmtRyuString;\nuse crate::num::logic::traits::{BitAccess, LowMask, SignificantBits, TrailingZeros};\nuse core::cmp::Ordering::*;\nuse core::fmt::{Debug, Display, LowerExp, UpperExp};\nuse core::iter::{Product, Sum};\nuse core::num::FpCategory;\nuse core::ops::{\n    Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign,\n};\nuse core::panic::RefUnwindSafe;\nuse core::str::FromStr;\n\n/// This trait defines functions on primitive float types: [`f32`] and [`f64`].\n///\n/// Many of the functions here concern exponents and mantissas. We define three ways to express a\n/// float, each with its own exponent and mantissa. In the following, let $x$ be an arbitrary\n/// positive, finite, non-zero, non-NaN float. Let $M$ and $E$ be the mantissa width and exponent\n/// width of the floating point type; for [`f32`]s, this is 23 and 8, and for [`f64`]s it's 52 and\n/// 11.\n///\n/// In the following we assume that $x$ is positive, but you can easily extend these definitions to\n/// negative floats by first taking their absolute value.\n///\n/// # raw form\n/// The raw exponent and raw mantissa are the actual bit patterns used to represent the components\n/// of $x$. The raw exponent $e_r$ is an integer in $[0, 2^E-2]$ and the raw mantissa $m_r$ is an\n/// integer in $[0, 2^M-1]$. Since we are dealing with a nonzero $x$, we forbid $e_r$ and $m_r$ from\n/// both being zero. We have\n/// $$\n/// x = \\\\begin{cases}\n///     2^{2-2^{E-1}-M}m_r & \\text{if} \\quad e_r = 0, \\\\\\\\\n///     2^{e_r-2^{E-1}+1}(2^{-M}m_r+1) & \\textrm{otherwise},\n/// \\\\end{cases}\n/// $$\n/// $$\n/// e_r = \\\\begin{cases}\n///     0 & \\text{if} \\quad x < 2^{2-2^{E-1}}, \\\\\\\\\n///     \\lfloor \\log_2 x \\rfloor + 2^{E-1} - 1 & \\textrm{otherwise},\n/// \\\\end{cases}\n/// $$\n/// $$\n/// m_r = \\\\begin{cases}\n///     2^{M+2^{E-1}-2}x & \\text{if} \\quad x < 2^{2-2^{E-1}}, \\\\\\\\\n///     2^M \\left ( \\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}-1\\right ) & \\textrm{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// # scientific form\n/// We can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is a rational number with $1\n/// \\leq m_s < 2$. If $x$ is a valid float, the scientific mantissa $m_s$ is always exactly\n/// representable as a float of the same type. We have\n/// $$\n/// x = 2^{e_s}m_s,\n/// $$\n/// $$\n/// e_s = \\lfloor \\log_2 x \\rfloor,\n/// $$\n/// $$\n/// m_s = \\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}.\n/// $$\n///\n/// # integer form\n/// We can also write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. We\n/// have\n/// $$\n/// x = 2^{e_i}m_i,\n/// $$\n/// $e_i$ is the unique integer such that $x/2^{e_i}$is an odd integer, and\n/// $$\n/// m_i = \\frac{x}{2^{e_i}}.\n/// $$\npub trait PrimitiveFloat:\n    'static\n    + Abs<Output = Self>\n    + AbsAssign\n    + Add<Output = Self>\n    + AddAssign<Self>\n    + AddMul<Output = Self>\n    + AddMulAssign<Self, Self>\n    + Ceiling<Output = Self>\n    + CeilingAssign\n    + CeilingLogBase2<Output = i64>\n    + CeilingLogBasePowerOf2<u64, Output = i64>\n    + CheckedLogBase2<Output = i64>\n    + CheckedLogBasePowerOf2<u64, Output = i64>\n    + ConvertibleFrom<u8>\n    + ConvertibleFrom<u16>\n    + ConvertibleFrom<u32>\n    + ConvertibleFrom<u64>\n    + ConvertibleFrom<u128>\n    + ConvertibleFrom<usize>\n    + ConvertibleFrom<i8>\n    + ConvertibleFrom<i16>\n    + ConvertibleFrom<i32>\n    + ConvertibleFrom<i64>\n    + ConvertibleFrom<i128>\n    + ConvertibleFrom<isize>\n    + Copy\n    + Debug\n    + Default\n    + Display\n    + Div<Output = Self>\n    + DivAssign\n    + EqAbs<Self>\n    + Floor<Output = Self>\n    + FloorAssign\n    + FloorLogBase2<Output = i64>\n    + FloorLogBasePowerOf2<u64, Output = i64>\n    + FmtRyuString\n    + From<f32>\n    + FromStr\n    + Infinity\n    + IntegerMantissaAndExponent<u64, i64>\n    + Into<f64>\n    + IsInteger\n    + IsPowerOf2\n    + Log2E\n    + Ln2\n    + LowerExp\n    + Min\n    + Max\n    + Mul<Output = Self>\n    + MulAssign<Self>\n    + Named\n    + NaN\n    + NegativeInfinity\n    + NegativeZero\n    + Neg<Output = Self>\n    + NegAssign\n    + NegativeOne\n    + NextPowerOf2<Output = Self>\n    + NextPowerOf2Assign\n    + One\n    + PartialEq<Self>\n    + PartialOrd<Self>\n    + PartialOrdAbs<Self>\n    + Phi\n    + Pi\n    + Pow<i64, Output = Self>\n    + Pow<Self, Output = Self>\n    + PowAssign<i64>\n    + PowAssign<Self>\n    + PowerOf2<i64>\n    + PowerOf2<u64>\n    + PrimeConstant\n    + Product\n    + RawMantissaAndExponent<u64, u64>\n    + Reciprocal<Output = Self>\n    + ReciprocalAssign\n    + RefUnwindSafe\n    + Rem<Output = Self>\n    + RemAssign<Self>\n    + RoundingFrom<u8>\n    + RoundingFrom<u16>\n    + RoundingFrom<u32>\n    + RoundingFrom<u64>\n    + RoundingFrom<u128>\n    + RoundingFrom<usize>\n    + RoundingFrom<i8>\n    + RoundingFrom<i16>\n    + RoundingFrom<i32>\n    + RoundingFrom<i64>\n    + RoundingFrom<i128>\n    + RoundingFrom<isize>\n    + RoundingInto<u8>\n    + RoundingInto<u16>\n    + RoundingInto<u32>\n    + RoundingInto<u64>\n    + RoundingInto<u128>\n    + RoundingInto<usize>\n    + RoundingInto<i8>\n    + RoundingInto<i16>\n    + RoundingInto<i32>\n    + RoundingInto<i64>\n    + RoundingInto<i128>\n    + RoundingInto<isize>\n    + SciMantissaAndExponent<Self, i64>\n    + Sign\n    + Sized\n    + Sqrt<Output = Self>\n    + SqrtAssign\n    + Sqrt2\n    + Sqrt2Over2\n    + Sqrt3\n    + Sqrt3Over3\n    + Square<Output = Self>\n    + SquareAssign\n    + Sub<Output = Self>\n    + SubAssign<Self>\n    + SubMul<Output = Self>\n    + SubMulAssign<Self, Self>\n    + Sum<Self>\n    + ProuhetThueMorseConstant\n    + Two\n    + UpperExp\n    + Zero\n{\n    /// The number of bits taken up by the type.\n    ///\n    /// This is $M+E+1$. The three terms in the sum correspond to the width of the mantissa, the\n    /// width of the exponent, and the sign bit.\n    /// - For [`f32`]s, this is 32.\n    /// - For [`f64`]s, this is 64.\n    const WIDTH: u64;\n    /// The number of bits taken up by the exponent.\n    /// - For [`f32`]s, this is 8.\n    /// - For [`f64`]s, this is 11.\n    const EXPONENT_WIDTH: u64 = Self::WIDTH - Self::MANTISSA_WIDTH - 1;\n    /// The number of bits taken up by the mantissa.\n    /// - For [`f32`]s, this is 23.\n    /// - For [`f64`]s, this is 52.\n    const MANTISSA_WIDTH: u64;\n    /// The smallest possible exponent of a float in the normal range. Any floats with smaller\n    /// exponents are subnormal and thus have reduced precision. This is $2-2^{E-1}$.\n    /// - For [`f32`]s, this is -126.\n    /// - For [`f64`]s, this is -1022.\n    const MIN_NORMAL_EXPONENT: i64 = -(1 << (Self::EXPONENT_WIDTH - 1)) + 2;\n    /// The smallest possible exponent of a float. This is $2-2^{E-1}-M$.\n    /// - For [`f32`]s, this is -149.\n    /// - For [`f64`]s, this is -1074.\n    const MIN_EXPONENT: i64 = Self::MIN_NORMAL_EXPONENT - (Self::MANTISSA_WIDTH as i64);\n    /// The largest possible exponent of a float. This is $2^{E-1}-1$.\n    /// - For [`f32`]s, this is 127.\n    /// - For [`f64`]s, this is 1023.\n    const MAX_EXPONENT: i64 = (1 << (Self::EXPONENT_WIDTH - 1)) - 1;\n    /// The smallest positive float. This is $2^{2-2^{E-1}-M}$.\n    /// - For [`f32`]s, this is $2^{-149}$, or `1.0e-45`.\n    /// - For [`f64`]s, this is $2^{-1074}$, or `5.0e-324`.\n    const MIN_POSITIVE_SUBNORMAL: Self;\n    /// The largest float in the subnormal range. This is $2^{2-2^{E-1}-M}(2^M-1)$.\n    /// - For [`f32`]s, this is $2^{-149}(2^{23}-1)$, or `1.1754942e-38`.\n    /// - For [`f64`]s, this is $2^{-1074}(2^{52}-1)$, or `2.225073858507201e-308`.\n    const MAX_SUBNORMAL: Self;\n    /// The smallest positive normal float. This is $2^{2-2^{E-1}}$.\n    /// - For [`f32`]s, this is $2^{-126}$, or `1.1754944e-38`.\n    /// - For [`f64`]s, this is $2^{-1022}$, or `2.2250738585072014e-308`.\n    const MIN_POSITIVE_NORMAL: Self;\n    /// The largest finite float. This is $2^{2^{E-1}-1}(2-2^{-M})$.\n    /// - For [`f32`]s, this is $2^{127}(2-2^{-23})$, or `3.4028235e38`.\n    /// - For [`f64`]s, this is $2^{1023}(2-2^{-52})$, or `1.7976931348623157e308`.\n    const MAX_FINITE: Self;\n    /// The smallest positive integer that cannot be represented as a float. This is $2^{M+1}+1$.\n    /// - For [`f32`]s, this is $2^{24}+1$, or 16777217.\n    /// - For [`f64`]s, this is $2^{53}+1$, or 9007199254740993.\n    const SMALLEST_UNREPRESENTABLE_UINT: u64;\n    /// If you list all floats in increasing order, excluding NaN and giving negative and positive\n    /// zero separate adjacent spots, this will be index of the last element, positive infinity. It\n    /// is $2^{M+1}(2^E-1)+1$.\n    /// - For [`f32`]s, this is $2^{32}-2^{24}+1$, or 4278190081.\n    /// - For [`f64`]s, this is $2^{64}-2^{53}+1$, or 18437736874454810625.\n    const LARGEST_ORDERED_REPRESENTATION: u64;\n\n    fn is_nan(self) -> bool;\n\n    fn is_infinite(self) -> bool;\n\n    fn is_finite(self) -> bool;\n\n    fn is_normal(self) -> bool;\n\n    fn is_sign_positive(self) -> bool;\n\n    fn is_sign_negative(self) -> bool;\n\n    fn classify(self) -> FpCategory;\n\n    fn to_bits(self) -> u64;\n\n    fn from_bits(v: u64) -> Self;\n\n    /// Tests whether `self` is negative zero.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    ///\n    /// assert!((-0.0).is_negative_zero());\n    /// assert!(!0.0.is_negative_zero());\n    /// assert!(!1.0.is_negative_zero());\n    /// assert!(!f32::NAN.is_negative_zero());\n    /// assert!(!f32::INFINITY.is_negative_zero());\n    /// ```\n    #[inline]\n    fn is_negative_zero(self) -> bool {\n        self.sign() == Less && self == Self::ZERO\n    }\n\n    /// If `self` is negative zero, returns positive zero; otherwise, returns `self`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert_eq!(NiceFloat((-0.0).abs_negative_zero()), NiceFloat(0.0));\n    /// assert_eq!(NiceFloat(0.0.abs_negative_zero()), NiceFloat(0.0));\n    /// assert_eq!(NiceFloat(1.0.abs_negative_zero()), NiceFloat(1.0));\n    /// assert_eq!(NiceFloat((-1.0).abs_negative_zero()), NiceFloat(-1.0));\n    /// assert_eq!(NiceFloat(f32::NAN.abs_negative_zero()), NiceFloat(f32::NAN));\n    /// ```\n    #[inline]\n    fn abs_negative_zero(self) -> Self {\n        if self == Self::ZERO { Self::ZERO } else { self }\n    }\n\n    /// If `self` is negative zero, replaces it with positive zero; otherwise, leaves `self`\n    /// unchanged.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// let mut f = -0.0;\n    /// f.abs_negative_zero_assign();\n    /// assert_eq!(NiceFloat(f), NiceFloat(0.0));\n    ///\n    /// let mut f = 0.0;\n    /// f.abs_negative_zero_assign();\n    /// assert_eq!(NiceFloat(f), NiceFloat(0.0));\n    ///\n    /// let mut f = 1.0;\n    /// f.abs_negative_zero_assign();\n    /// assert_eq!(NiceFloat(f), NiceFloat(1.0));\n    ///\n    /// let mut f = -1.0;\n    /// f.abs_negative_zero_assign();\n    /// assert_eq!(NiceFloat(f), NiceFloat(-1.0));\n    ///\n    /// let mut f = f32::NAN;\n    /// f.abs_negative_zero_assign();\n    /// assert_eq!(NiceFloat(f), NiceFloat(f32::NAN));\n    /// ```\n    #[inline]\n    fn abs_negative_zero_assign(&mut self) {\n        if *self == Self::ZERO {\n            *self = Self::ZERO;\n        }\n    }\n\n    /// Returns the smallest float larger than `self`.\n    ///\n    /// Passing `-0.0` returns `0.0`; passing `NaN` or positive infinity panics.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is `NaN` or positive infinity.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert_eq!(NiceFloat((-0.0f32).next_higher()), NiceFloat(0.0));\n    /// assert_eq!(NiceFloat(0.0f32.next_higher()), NiceFloat(1.0e-45));\n    /// assert_eq!(NiceFloat(1.0f32.next_higher()), NiceFloat(1.0000001));\n    /// assert_eq!(NiceFloat((-1.0f32).next_higher()), NiceFloat(-0.99999994));\n    /// ```\n    fn next_higher(self) -> Self {\n        assert!(!self.is_nan());\n        if self.sign() == Greater {\n            assert_ne!(self, Self::INFINITY);\n            Self::from_bits(self.to_bits() + 1)\n        } else if self == Self::ZERO {\n            // negative zero -> positive zero\n            Self::ZERO\n        } else {\n            Self::from_bits(self.to_bits() - 1)\n        }\n    }\n\n    /// Returns the largest float smaller than `self`.\n    ///\n    /// Passing `0.0` returns `-0.0`; passing `NaN` or negative infinity panics.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is `NaN` or negative infinity.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert_eq!(NiceFloat(0.0f32.next_lower()), NiceFloat(-0.0));\n    /// assert_eq!(NiceFloat((-0.0f32).next_lower()), NiceFloat(-1.0e-45));\n    /// assert_eq!(NiceFloat(1.0f32.next_lower()), NiceFloat(0.99999994));\n    /// assert_eq!(NiceFloat((-1.0f32).next_lower()), NiceFloat(-1.0000001));\n    /// ```\n    fn next_lower(self) -> Self {\n        assert!(!self.is_nan());\n        if self.sign() == Less {\n            assert_ne!(self, Self::NEGATIVE_INFINITY);\n            Self::from_bits(self.to_bits() + 1)\n        } else if self == Self::ZERO {\n            // positive zero -> negative zero\n            Self::NEGATIVE_ZERO\n        } else {\n            Self::from_bits(self.to_bits() - 1)\n        }\n    }\n\n    /// Maps `self` to an integer. The map preserves ordering, and adjacent floats are mapped to\n    /// adjacent integers.\n    ///\n    /// Negative infinity is mapped to 0, and positive infinity is mapped to the largest value,\n    /// [`LARGEST_ORDERED_REPRESENTATION`](PrimitiveFloat::LARGEST_ORDERED_REPRESENTATION). Negative\n    /// and positive zero are mapped to distinct adjacent values. Passing in `NaN` panics.\n    ///\n    /// The inverse operation is\n    /// [`from_ordered_representation`](PrimitiveFloat::from_ordered_representation).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is `NaN`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    /// use malachite_base::num::basic::traits::NegativeInfinity;\n    ///\n    /// assert_eq!(f32::NEGATIVE_INFINITY.to_ordered_representation(), 0);\n    /// assert_eq!((-0.0f32).to_ordered_representation(), 2139095040);\n    /// assert_eq!(0.0f32.to_ordered_representation(), 2139095041);\n    /// assert_eq!(1.0f32.to_ordered_representation(), 3204448257);\n    /// assert_eq!(f32::INFINITY.to_ordered_representation(), 4278190081);\n    /// ```\n    fn to_ordered_representation(self) -> u64 {\n        assert!(!self.is_nan());\n        let bits = self.to_bits();\n        if self.sign() == Greater {\n            (u64::low_mask(Self::EXPONENT_WIDTH) << Self::MANTISSA_WIDTH) + bits + 1\n        } else {\n            (u64::low_mask(Self::EXPONENT_WIDTH + 1) << Self::MANTISSA_WIDTH) - bits\n        }\n    }\n\n    /// Maps a non-negative integer, less than or equal to\n    /// [`LARGEST_ORDERED_REPRESENTATION`](PrimitiveFloat::LARGEST_ORDERED_REPRESENTATION), to a\n    /// float. The map preserves ordering, and adjacent integers are mapped to adjacent floats.\n    ///\n    /// Zero is mapped to negative infinity, and\n    /// [`LARGEST_ORDERED_REPRESENTATION`](PrimitiveFloat::LARGEST_ORDERED_REPRESENTATION) is mapped\n    /// to positive infinity. Negative and positive zero are produced by two distinct adjacent\n    /// integers. `NaN` is never produced.\n    ///\n    /// The inverse operation is\n    /// [`to_ordered_representation`](PrimitiveFloat::to_ordered_representation).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than\n    /// [`LARGEST_ORDERED_REPRESENTATION`](PrimitiveFloat::LARGEST_ORDERED_REPRESENTATION).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    /// use malachite_base::num::basic::traits::NegativeInfinity;\n    ///\n    /// assert_eq!(f32::from_ordered_representation(0), f32::NEGATIVE_INFINITY);\n    /// assert_eq!(f32::from_ordered_representation(2139095040), -0.0f32);\n    /// assert_eq!(f32::from_ordered_representation(2139095041), 0.0f32);\n    /// assert_eq!(f32::from_ordered_representation(3204448257), 1.0f32);\n    /// assert_eq!(f32::from_ordered_representation(4278190081), f32::INFINITY);\n    /// ```\n    fn from_ordered_representation(n: u64) -> Self {\n        let zero_exp = u64::low_mask(Self::EXPONENT_WIDTH) << Self::MANTISSA_WIDTH;\n        let f = if n <= zero_exp {\n            Self::from_bits((u64::low_mask(Self::EXPONENT_WIDTH + 1) << Self::MANTISSA_WIDTH) - n)\n        } else {\n            let f = Self::from_bits(n - zero_exp - 1);\n            assert_eq!(f.sign(), Greater);\n            f\n        };\n        assert!(!f.is_nan());\n        f\n    }\n\n    /// Returns the precision of a nonzero finite floating-point number.\n    ///\n    /// The precision is the number of significant bits of the integer mantissa. For example, the\n    /// positive floats with precision 1 are the powers of 2, those with precision 2 are 3 times a\n    /// power of 2, those with precision 3 are 5 or 7 times a power of 2, and so on.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero, infinite, or `NaN`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    ///\n    /// assert_eq!(1.0.precision(), 1);\n    /// assert_eq!(2.0.precision(), 1);\n    /// assert_eq!(3.0.precision(), 2);\n    /// assert_eq!(1.5.precision(), 2);\n    /// assert_eq!(1.234f32.precision(), 23);\n    /// ```\n    fn precision(self) -> u64 {\n        assert!(self.is_finite());\n        assert!(self != Self::ZERO);\n        let (mut mantissa, exponent) = self.raw_mantissa_and_exponent();\n        if exponent == 0 {\n            mantissa.significant_bits() - TrailingZeros::trailing_zeros(mantissa)\n        } else {\n            mantissa.set_bit(Self::MANTISSA_WIDTH);\n            Self::MANTISSA_WIDTH + 1 - TrailingZeros::trailing_zeros(mantissa)\n        }\n    }\n\n    /// Given a scientific exponent, returns the largest possible precision for a float with that\n    /// exponent.\n    ///\n    /// See the documentation of the [`precision`](PrimitiveFloat::precision) function for a\n    /// definition of precision.\n    ///\n    /// For exponents greater than or equal to\n    /// [`MIN_NORMAL_EXPONENT`](PrimitiveFloat::MIN_NORMAL_EXPONENT), the maximum precision is one\n    /// more than the mantissa width. For smaller exponents (corresponding to the subnormal range),\n    /// the precision is lower.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `exponent` is less than [`MIN_EXPONENT`](PrimitiveFloat::MIN_EXPONENT) or greater\n    /// than [`MAX_EXPONENT`](PrimitiveFloat::MAX_EXPONENT).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    ///\n    /// assert_eq!(f32::max_precision_for_sci_exponent(0), 24);\n    /// assert_eq!(f32::max_precision_for_sci_exponent(127), 24);\n    /// assert_eq!(f32::max_precision_for_sci_exponent(-149), 1);\n    /// assert_eq!(f32::max_precision_for_sci_exponent(-148), 2);\n    /// assert_eq!(f32::max_precision_for_sci_exponent(-147), 3);\n    /// ```\n    fn max_precision_for_sci_exponent(exponent: i64) -> u64 {\n        assert!(exponent >= Self::MIN_EXPONENT);\n        assert!(exponent <= Self::MAX_EXPONENT);\n        if exponent >= Self::MIN_NORMAL_EXPONENT {\n            Self::MANTISSA_WIDTH + 1\n        } else {\n            u64::wrapping_from(exponent - Self::MIN_EXPONENT) + 1\n        }\n    }\n}\n\n/// Defines basic trait implementations for floating-point types.\nmacro_rules! impl_basic_traits_primitive_float {\n    (\n        $t: ident,\n        $width: expr,\n        $min_positive_subnormal: expr,\n        $max_subnormal: expr,\n        $min_positive_normal: expr,\n        $prouhet_thue_morse_constant: expr,\n        $prime_constant: expr,\n        $sqrt_3: expr,\n        $sqrt_3_over_3: expr,\n        $phi: expr,\n        $sqrt_pi: expr,\n        $one_over_sqrt_pi: expr,\n        $one_over_sqrt_tau: expr,\n        $gauss_constant: expr,\n        $lemniscate_constant: expr\n    ) => {\n        impl PrimitiveFloat for $t {\n            const WIDTH: u64 = $width;\n            const MANTISSA_WIDTH: u64 = ($t::MANTISSA_DIGITS as u64) - 1;\n\n            const MAX_FINITE: Self = $t::MAX;\n            const MIN_POSITIVE_SUBNORMAL: Self = $min_positive_subnormal;\n            const MAX_SUBNORMAL: Self = $max_subnormal;\n            const MIN_POSITIVE_NORMAL: Self = $min_positive_normal;\n            const SMALLEST_UNREPRESENTABLE_UINT: u64 = (1 << (Self::MANTISSA_WIDTH + 1)) + 1;\n            // We can't shift by $width when $width is 64, so we shift by $width - 1 and then by 1\n            const LARGEST_ORDERED_REPRESENTATION: u64 = (1u64 << ($width - 1) << 1)\n                .wrapping_sub(((1 << Self::MANTISSA_WIDTH) - 1) << 1)\n                - 1;\n\n            #[inline]\n            fn is_nan(self) -> bool {\n                $t::is_nan(self)\n            }\n\n            #[inline]\n            fn is_infinite(self) -> bool {\n                $t::is_infinite(self)\n            }\n\n            #[inline]\n            fn is_finite(self) -> bool {\n                $t::is_finite(self)\n            }\n\n            #[inline]\n            fn is_normal(self) -> bool {\n                $t::is_normal(self)\n            }\n\n            #[inline]\n            fn is_sign_positive(self) -> bool {\n                $t::is_sign_positive(self)\n            }\n\n            #[inline]\n            fn is_sign_negative(self) -> bool {\n                $t::is_sign_negative(self)\n            }\n\n            #[inline]\n            fn classify(self) -> FpCategory {\n                $t::classify(self)\n            }\n\n            #[inline]\n            fn to_bits(self) -> u64 {\n                u64::wrapping_from($t::to_bits(self))\n            }\n\n            #[inline]\n            fn from_bits(v: u64) -> $t {\n                $t::from_bits(v.exact_into())\n            }\n        }\n\n        impl_named!($t);\n\n        /// The constant 0.\n        impl Zero for $t {\n            const ZERO: $t = 0.0;\n        }\n\n        /// The constant 1.\n        impl One for $t {\n            const ONE: $t = 1.0;\n        }\n\n        /// The constant 2.\n        impl Two for $t {\n            const TWO: $t = 2.0;\n        }\n\n        /// The constant 1/2.\n        impl OneHalf for $t {\n            const ONE_HALF: $t = 0.5;\n        }\n\n        /// The constant -1.0 for primitive floating-point types.\n        impl NegativeOne for $t {\n            const NEGATIVE_ONE: $t = -1.0;\n        }\n\n        /// The constant -0.0 for primitive floating-point types.\n        impl NegativeZero for $t {\n            const NEGATIVE_ZERO: $t = -0.0;\n        }\n\n        /// The constant Infinity for primitive floating-point types.\n        impl Infinity for $t {\n            const INFINITY: $t = $t::INFINITY;\n        }\n\n        /// The constant -Infinity for primitive floating-point types.\n        impl NegativeInfinity for $t {\n            const NEGATIVE_INFINITY: $t = $t::NEG_INFINITY;\n        }\n\n        /// The constant NaN for primitive floating-point types.\n        impl NaN for $t {\n            const NAN: $t = $t::NAN;\n        }\n\n        /// The lowest value representable by this type, negative infinity.\n        impl Min for $t {\n            const MIN: $t = $t::NEGATIVE_INFINITY;\n        }\n\n        /// The highest value representable by this type, positive infinity.\n        impl Max for $t {\n            const MAX: $t = $t::INFINITY;\n        }\n\n        /// The Prouhet-Thue-Morse constant.\n        impl ProuhetThueMorseConstant for $t {\n            const PROUHET_THUE_MORSE_CONSTANT: $t = $prouhet_thue_morse_constant;\n        }\n\n        /// The prime constant.\n        impl PrimeConstant for $t {\n            const PRIME_CONSTANT: $t = $prime_constant;\n        }\n\n        /// $\\ln 2$.\n        impl Ln2 for $t {\n            const LN_2: $t = core::$t::consts::LN_2;\n        }\n\n        /// $\\log_2 e$.\n        impl Log2E for $t {\n            const LOG_2_E: $t = core::$t::consts::LOG2_E;\n        }\n\n        /// $\\sqrt{2}$.\n        impl Sqrt2 for $t {\n            const SQRT_2: $t = core::$t::consts::SQRT_2;\n        }\n\n        /// $\\sqrt{3}$.\n        impl Sqrt3 for $t {\n            const SQRT_3: $t = $sqrt_3;\n        }\n\n        /// $\\sqrt{2}/2=\\sqrt{1/2}=1/\\sqrt{2}$.\n        impl Sqrt2Over2 for $t {\n            const SQRT_2_OVER_2: $t = core::$t::consts::FRAC_1_SQRT_2;\n        }\n\n        /// $\\sqrt{3}/3=\\sqrt{1/3}=1/\\sqrt{3}$.\n        impl Sqrt3Over3 for $t {\n            const SQRT_3_OVER_3: $t = $sqrt_3_over_3;\n        }\n\n        /// $\\varphi$, the golden ratio.\n        impl Phi for $t {\n            const PHI: $t = $phi;\n        }\n\n        /// $\\pi$.\n        impl Pi for $t {\n            const PI: $t = core::$t::consts::PI;\n        }\n\n        /// $\\tau=2\\pi$.\n        impl Tau for $t {\n            const TAU: $t = core::$t::consts::TAU;\n        }\n\n        /// $\\pi/2$.\n        impl PiOver2 for $t {\n            const PI_OVER_2: $t = core::$t::consts::FRAC_PI_2;\n        }\n\n        /// $\\pi/3$.\n        impl PiOver3 for $t {\n            const PI_OVER_3: $t = core::$t::consts::FRAC_PI_3;\n        }\n\n        /// $\\pi/4$.\n        impl PiOver4 for $t {\n            const PI_OVER_4: $t = core::$t::consts::FRAC_PI_4;\n        }\n\n        /// $\\pi/6$.\n        impl PiOver6 for $t {\n            const PI_OVER_6: $t = core::$t::consts::FRAC_PI_6;\n        }\n\n        /// $\\pi/8$.\n        impl PiOver8 for $t {\n            const PI_OVER_8: $t = core::$t::consts::FRAC_PI_8;\n        }\n\n        /// $1/\\pi$.\n        impl OneOverPi for $t {\n            const ONE_OVER_PI: $t = core::$t::consts::FRAC_1_PI;\n        }\n\n        /// $\\sqrt{\\pi}$.\n        impl SqrtPi for $t {\n            const SQRT_PI: $t = $sqrt_pi;\n        }\n\n        /// $1/\\sqrt{\\pi}$.\n        impl OneOverSqrtPi for $t {\n            const ONE_OVER_SQRT_PI: $t = $one_over_sqrt_pi;\n        }\n\n        /// $1/\\sqrt{\\tau}$.\n        impl OneOverSqrtTau for $t {\n            const ONE_OVER_SQRT_TAU: $t = $one_over_sqrt_tau;\n        }\n\n        /// $2/\\pi$.\n        impl TwoOverPi for $t {\n            const TWO_OVER_PI: $t = core::$t::consts::FRAC_2_PI;\n        }\n\n        /// $2/\\sqrt{\\pi}$.\n        impl TwoOverSqrtPi for $t {\n            const TWO_OVER_SQRT_PI: $t = core::$t::consts::FRAC_2_SQRT_PI;\n        }\n\n        /// $G=1/\\mathrm{AGM}(1,\\sqrt{2})$.\n        impl GaussConstant for $t {\n            const GAUSS_CONSTANT: $t = $gauss_constant;\n        }\n\n        /// $\\varpi=\\pi G$.\n        impl LemniscateConstant for $t {\n            const LEMNISCATE_CONSTANT: $t = $lemniscate_constant;\n        }\n    };\n}\nimpl_basic_traits_primitive_float!(\n    f32,\n    32,\n    1.0e-45,\n    1.1754942e-38,\n    1.1754944e-38,\n    0.41245404,\n    0.4146825,\n    1.7320508,\n    0.57735026,\n    1.618034,\n    1.7724539,\n    0.5641896,\n    0.3989423,\n    0.83462685,\n    2.6220574\n);\nimpl_basic_traits_primitive_float!(\n    f64,\n    64,\n    5.0e-324,\n    2.225073858507201e-308,\n    2.2250738585072014e-308,\n    0.4124540336401076,\n    0.41468250985111166,\n    1.7320508075688772,\n    0.5773502691896257,\n    1.618033988749895,\n    1.772453850905516,\n    0.5641895835477563,\n    0.3989422804014327,\n    0.8346268416740732,\n    2.6220575542921196\n);\n"
  },
  {
    "path": "malachite-base/src/num/basic/integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::comparison::traits::{Max, Min};\nuse crate::named::Named;\nuse crate::num::arithmetic::traits::{\n    AbsDiff, AddMul, AddMulAssign, ArithmeticCheckedShl, ArithmeticCheckedShr, BinomialCoefficient,\n    CeilingRoot, CeilingRootAssign, CeilingSqrt, CeilingSqrtAssign, CheckedAdd, CheckedAddMul,\n    CheckedBinomialCoefficient, CheckedDiv, CheckedMul, CheckedNeg, CheckedPow, CheckedRoot,\n    CheckedSqrt, CheckedSquare, CheckedSub, CheckedSubMul, DivAssignMod, DivAssignRem, DivExact,\n    DivExactAssign, DivMod, DivRem, DivRound, DivRoundAssign, DivisibleBy, DivisibleByPowerOf2,\n    EqMod, EqModPowerOf2, ExtendedGcd, FloorRoot, FloorRootAssign, FloorSqrt, FloorSqrtAssign,\n    JacobiSymbol, KroneckerSymbol, LegendreSymbol, Mod, ModAssign, ModPowerOf2, ModPowerOf2Assign,\n    OverflowingAdd, OverflowingAddAssign, OverflowingAddMul, OverflowingAddMulAssign,\n    OverflowingDiv, OverflowingDivAssign, OverflowingMul, OverflowingMulAssign, OverflowingNeg,\n    OverflowingNegAssign, OverflowingPow, OverflowingPowAssign, OverflowingSquare,\n    OverflowingSquareAssign, OverflowingSub, OverflowingSubAssign, OverflowingSubMul,\n    OverflowingSubMulAssign, Parity, Pow, PowAssign, PowerOf2, RemPowerOf2, RemPowerOf2Assign,\n    RotateLeft, RotateLeftAssign, RotateRight, RotateRightAssign, RoundToMultiple,\n    RoundToMultipleAssign, RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign,\n    SaturatingAdd, SaturatingAddAssign, SaturatingAddMul, SaturatingAddMulAssign, SaturatingMul,\n    SaturatingMulAssign, SaturatingPow, SaturatingPowAssign, SaturatingSquare,\n    SaturatingSquareAssign, SaturatingSub, SaturatingSubAssign, SaturatingSubMul,\n    SaturatingSubMulAssign, ShlRound, ShlRoundAssign, ShrRound, ShrRoundAssign, Sign, Square,\n    SquareAssign, SubMul, SubMulAssign, WrappingAdd, WrappingAddAssign, WrappingAddMul,\n    WrappingAddMulAssign, WrappingDiv, WrappingDivAssign, WrappingMul, WrappingMulAssign,\n    WrappingNeg, WrappingNegAssign, WrappingPow, WrappingPowAssign, WrappingSquare,\n    WrappingSquareAssign, WrappingSub, WrappingSubAssign, WrappingSubMul, WrappingSubMulAssign,\n};\nuse crate::num::basic::traits::{One, Two, Zero};\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, ExactInto, FromSciString, FromStringBase, IsInteger,\n    OverflowingFrom, OverflowingInto, RoundingFrom, RoundingInto, SaturatingFrom, SaturatingInto,\n    ToSci, ToStringBase, WrappingFrom, WrappingInto,\n};\nuse crate::num::factorization::traits::{ExpressAsPower, IsPower, IsSquare};\nuse crate::num::float::NiceFloat;\nuse crate::num::logic::traits::{\n    BitAccess, BitBlockAccess, BitConvertible, BitIterable, BitScan, CountOnes, CountZeros,\n    LeadingZeros, LowMask, NotAssign, SignificantBits, TrailingZeros,\n};\n#[cfg(feature = \"random\")]\nuse crate::num::random::HasRandomPrimitiveInts;\nuse core::fmt::{Binary, Debug, Display, LowerHex, Octal, UpperHex};\nuse core::hash::Hash;\nuse core::iter::{Product, Sum};\nuse core::ops::{\n    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,\n    Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign,\n};\nuse core::panic::{RefUnwindSafe, UnwindSafe};\nuse core::str::FromStr;\n\npub const USIZE_IS_U32: bool = usize::WIDTH == u32::WIDTH;\npub const USIZE_IS_U64: bool = usize::WIDTH == u64::WIDTH;\n\n// Checks that usize is equivalent to u32 or u64, at compile time. The rest of Malachite can assume\n// that this condition is true.\nconst _USIZE_ASSERTION: () = assert!(USIZE_IS_U32 || USIZE_IS_U64);\n\n// When the `random` feature is enabled, the HasRandomPrimitiveInts bound is included.\n\n#[cfg(feature = \"random\")]\n/// Defines functions on primitive integer types: uxx, ixx, usize, and isize.\n///\n/// The different types are distinguished by whether they are signed or unsigned, and by their\n/// widths. The width $W$ is the number of bits in the type. For example, the width of [`u32`] or\n/// [`i32`] is 32. Each type has $2^W$ distinct values.\n///\n/// Let $n$ be a value of type `Self`. If `Self` is unsigned, $0 \\leq n < 2^W$. If `Self` is signed,\n/// $2^{W-1} \\leq n < 2^{W-1}$.\npub trait PrimitiveInt:\n    'static\n    + AbsDiff<Self>\n    + Add<Self, Output = Self>\n    + AddAssign<Self>\n    + AddMul<Self, Self, Output = Self>\n    + AddMulAssign<Self, Self>\n    + ArithmeticCheckedShl<i128, Output = Self>\n    + ArithmeticCheckedShl<i16, Output = Self>\n    + ArithmeticCheckedShl<i32, Output = Self>\n    + ArithmeticCheckedShl<i64, Output = Self>\n    + ArithmeticCheckedShl<i8, Output = Self>\n    + ArithmeticCheckedShl<isize, Output = Self>\n    + ArithmeticCheckedShl<u128, Output = Self>\n    + ArithmeticCheckedShl<u16, Output = Self>\n    + ArithmeticCheckedShl<u32, Output = Self>\n    + ArithmeticCheckedShl<u64, Output = Self>\n    + ArithmeticCheckedShl<u8, Output = Self>\n    + ArithmeticCheckedShl<usize, Output = Self>\n    + ArithmeticCheckedShr<i128, Output = Self>\n    + ArithmeticCheckedShr<i16, Output = Self>\n    + ArithmeticCheckedShr<i32, Output = Self>\n    + ArithmeticCheckedShr<i64, Output = Self>\n    + ArithmeticCheckedShr<i8, Output = Self>\n    + ArithmeticCheckedShr<isize, Output = Self>\n    + Binary\n    + BinomialCoefficient<Self>\n    + BitAccess\n    + BitAnd<Self, Output = Self>\n    + BitAndAssign<Self>\n    + BitBlockAccess\n    + BitConvertible\n    + BitIterable\n    + BitOr<Self, Output = Self>\n    + BitOrAssign<Self>\n    + BitScan\n    + BitXor<Self, Output = Self>\n    + BitXorAssign<Self>\n    + CeilingRoot<u64, Output = Self>\n    + CeilingRootAssign<u64>\n    + CeilingSqrt<Output = Self>\n    + CeilingSqrtAssign\n    + CheckedAdd<Self, Output = Self>\n    + CheckedAddMul<Self, Self, Output = Self>\n    + CheckedBinomialCoefficient<Self>\n    + CheckedDiv<Self, Output = Self>\n    + CheckedMul<Self, Output = Self>\n    + CheckedNeg<Output = Self>\n    + CheckedPow<u64, Output = Self>\n    + CheckedRoot<u64, Output = Self>\n    + CheckedSqrt<Output = Self>\n    + CheckedSquare<Output = Self>\n    + CheckedSub<Self, Output = Self>\n    + CheckedSubMul<Self, Self, Output = Self>\n    + Clone\n    + ConvertibleFrom<f32>\n    + ConvertibleFrom<f64>\n    + ConvertibleFrom<i128>\n    + ConvertibleFrom<i16>\n    + ConvertibleFrom<i32>\n    + ConvertibleFrom<i64>\n    + ConvertibleFrom<i8>\n    + ConvertibleFrom<isize>\n    + ConvertibleFrom<u128>\n    + ConvertibleFrom<u16>\n    + ConvertibleFrom<u32>\n    + ConvertibleFrom<u64>\n    + ConvertibleFrom<u8>\n    + ConvertibleFrom<usize>\n    + Copy\n    + CountOnes\n    + CountZeros\n    + Debug\n    + Default\n    + Display\n    + Div<Self, Output = Self>\n    + DivAssign<Self>\n    + DivAssignMod<Self, ModOutput = Self>\n    + DivAssignRem<Self, RemOutput = Self>\n    + DivExact<Self, Output = Self>\n    + DivExactAssign<Self>\n    + DivMod<Self, DivOutput = Self, ModOutput = Self>\n    + DivRem<Self, DivOutput = Self, RemOutput = Self>\n    + DivRound<Self, Output = Self>\n    + DivRoundAssign<Self>\n    + DivisibleBy<Self>\n    + DivisibleByPowerOf2\n    + Eq\n    + EqMod<Self, Self>\n    + EqModPowerOf2<Self>\n    + ExactFrom<i128>\n    + ExactFrom<i16>\n    + ExactFrom<i32>\n    + ExactFrom<i64>\n    + ExactFrom<i8>\n    + ExactFrom<isize>\n    + ExactFrom<u128>\n    + ExactFrom<u16>\n    + ExactFrom<u32>\n    + ExactFrom<u64>\n    + ExactFrom<u8>\n    + ExactFrom<usize>\n    + ExactInto<i128>\n    + ExactInto<i16>\n    + ExactInto<i32>\n    + ExactInto<i64>\n    + ExactInto<i8>\n    + ExactInto<isize>\n    + ExactInto<u128>\n    + ExactInto<u16>\n    + ExactInto<u32>\n    + ExactInto<u64>\n    + ExactInto<u8>\n    + ExactInto<usize>\n    + ExpressAsPower\n    + ExtendedGcd<Self>\n    + FloorRoot<u64, Output = Self>\n    + FloorRootAssign<u64>\n    + FloorSqrt<Output = Self>\n    + FloorSqrtAssign\n    + From<bool>\n    + FromSciString\n    + FromStr\n    + FromStringBase\n    + HasRandomPrimitiveInts\n    + Hash\n    + IsInteger\n    + IsPower\n    + IsSquare\n    + JacobiSymbol<Self>\n    + KroneckerSymbol<Self>\n    + LeadingZeros\n    + LegendreSymbol<Self>\n    + LowMask\n    + LowerHex\n    + Max\n    + Min\n    + Mod<Self, Output = Self>\n    + ModAssign<Self>\n    + ModPowerOf2\n    + ModPowerOf2Assign\n    + Mul<Self, Output = Self>\n    + MulAssign<Self>\n    + Named\n    + Not<Output = Self>\n    + NotAssign\n    + Octal\n    + One\n    + Ord\n    + OverflowingAdd<Self, Output = Self>\n    + OverflowingAddAssign<Self>\n    + OverflowingAddMul<Self, Self, Output = Self>\n    + OverflowingAddMulAssign<Self, Self>\n    + OverflowingDiv<Self, Output = Self>\n    + OverflowingDivAssign<Self>\n    + OverflowingFrom<i128>\n    + OverflowingFrom<i16>\n    + OverflowingFrom<i32>\n    + OverflowingFrom<i64>\n    + OverflowingFrom<i8>\n    + OverflowingFrom<isize>\n    + OverflowingFrom<u128>\n    + OverflowingFrom<u16>\n    + OverflowingFrom<u32>\n    + OverflowingFrom<u64>\n    + OverflowingFrom<u8>\n    + OverflowingFrom<usize>\n    + OverflowingInto<i128>\n    + OverflowingInto<i16>\n    + OverflowingInto<i32>\n    + OverflowingInto<i64>\n    + OverflowingInto<i8>\n    + OverflowingInto<isize>\n    + OverflowingInto<u128>\n    + OverflowingInto<u16>\n    + OverflowingInto<u32>\n    + OverflowingInto<u64>\n    + OverflowingInto<u8>\n    + OverflowingInto<usize>\n    + OverflowingMul<Self, Output = Self>\n    + OverflowingMulAssign<Self>\n    + OverflowingNeg<Output = Self>\n    + OverflowingNegAssign\n    + OverflowingPow<u64, Output = Self>\n    + OverflowingPowAssign<u64>\n    + OverflowingSquare<Output = Self>\n    + OverflowingSquareAssign\n    + OverflowingSub<Self, Output = Self>\n    + OverflowingSubAssign<Self>\n    + OverflowingSubMul<Self, Self, Output = Self>\n    + OverflowingSubMulAssign<Self, Self>\n    + Parity\n    + PartialEq<Self>\n    + PartialOrd<Self>\n    + Pow<u64, Output = Self>\n    + PowAssign<u64>\n    + PowerOf2<u64>\n    + Product\n    + RefUnwindSafe\n    + Rem<Self, Output = Self>\n    + RemAssign<Self>\n    + RemPowerOf2<Output = Self>\n    + RemPowerOf2Assign\n    + RotateLeft<Output = Self>\n    + RotateLeftAssign\n    + RotateRight<Output = Self>\n    + RotateRightAssign\n    + RoundToMultiple<Self, Output = Self>\n    + RoundToMultipleAssign<Self>\n    + RoundToMultipleOfPowerOf2<u64, Output = Self>\n    + RoundToMultipleOfPowerOf2Assign<u64>\n    + RoundingFrom<f32>\n    + RoundingFrom<f64>\n    + RoundingInto<f32>\n    + RoundingInto<f64>\n    + SaturatingAdd<Self, Output = Self>\n    + SaturatingAddAssign<Self>\n    + SaturatingAddMul<Self, Self, Output = Self>\n    + SaturatingAddMulAssign<Self, Self>\n    + SaturatingFrom<i128>\n    + SaturatingFrom<i16>\n    + SaturatingFrom<i32>\n    + SaturatingFrom<i64>\n    + SaturatingFrom<i8>\n    + SaturatingFrom<isize>\n    + SaturatingFrom<u128>\n    + SaturatingFrom<u16>\n    + SaturatingFrom<u32>\n    + SaturatingFrom<u64>\n    + SaturatingFrom<u8>\n    + SaturatingFrom<usize>\n    + SaturatingInto<i128>\n    + SaturatingInto<i16>\n    + SaturatingInto<i32>\n    + SaturatingInto<i64>\n    + SaturatingInto<i8>\n    + SaturatingInto<isize>\n    + SaturatingInto<u128>\n    + SaturatingInto<u16>\n    + SaturatingInto<u32>\n    + SaturatingInto<u64>\n    + SaturatingInto<u8>\n    + SaturatingInto<usize>\n    + SaturatingMul<Self, Output = Self>\n    + SaturatingMulAssign<Self>\n    + SaturatingPow<u64, Output = Self>\n    + SaturatingPowAssign<u64>\n    + SaturatingSquare<Output = Self>\n    + SaturatingSquareAssign\n    + SaturatingSub<Self, Output = Self>\n    + SaturatingSubAssign<Self>\n    + SaturatingSubMul<Self, Self, Output = Self>\n    + SaturatingSubMulAssign<Self, Self>\n    + Shl<i128, Output = Self>\n    + Shl<i16, Output = Self>\n    + Shl<i32, Output = Self>\n    + Shl<i64, Output = Self>\n    + Shl<i8, Output = Self>\n    + Shl<u128, Output = Self>\n    + Shl<u16, Output = Self>\n    + Shl<u32, Output = Self>\n    + Shl<u64, Output = Self>\n    + Shl<u8, Output = Self>\n    + ShlAssign<i128>\n    + ShlAssign<i16>\n    + ShlAssign<i32>\n    + ShlAssign<i64>\n    + ShlAssign<i8>\n    + ShlAssign<isize>\n    + ShlAssign<u128>\n    + ShlAssign<u16>\n    + ShlAssign<u32>\n    + ShlAssign<u64>\n    + ShlAssign<u8>\n    + ShlAssign<usize>\n    + ShlRound<i128, Output = Self>\n    + ShlRound<i16, Output = Self>\n    + ShlRound<i32, Output = Self>\n    + ShlRound<i64, Output = Self>\n    + ShlRound<i8, Output = Self>\n    + ShlRound<isize, Output = Self>\n    + ShlRoundAssign<i128>\n    + ShlRoundAssign<i16>\n    + ShlRoundAssign<i32>\n    + ShlRoundAssign<i64>\n    + ShlRoundAssign<i8>\n    + ShlRoundAssign<isize>\n    + Shr<i128, Output = Self>\n    + Shr<i16, Output = Self>\n    + Shr<i32, Output = Self>\n    + Shr<i64, Output = Self>\n    + Shr<i8, Output = Self>\n    + Shr<isize, Output = Self>\n    + Shr<u128, Output = Self>\n    + Shr<u16, Output = Self>\n    + Shr<u32, Output = Self>\n    + Shr<u64, Output = Self>\n    + Shr<u8, Output = Self>\n    + Shr<usize, Output = Self>\n    + ShrAssign<i128>\n    + ShrAssign<i16>\n    + ShrAssign<i32>\n    + ShrAssign<i64>\n    + ShrAssign<i8>\n    + ShrAssign<isize>\n    + ShrAssign<u128>\n    + ShrAssign<u16>\n    + ShrAssign<u32>\n    + ShrAssign<u64>\n    + ShrAssign<u8>\n    + ShrAssign<usize>\n    + ShrRound<i128, Output = Self>\n    + ShrRound<i16, Output = Self>\n    + ShrRound<i32, Output = Self>\n    + ShrRound<i64, Output = Self>\n    + ShrRound<i8, Output = Self>\n    + ShrRound<isize, Output = Self>\n    + ShrRound<u128, Output = Self>\n    + ShrRound<u16, Output = Self>\n    + ShrRound<u32, Output = Self>\n    + ShrRound<u64, Output = Self>\n    + ShrRound<u8, Output = Self>\n    + ShrRound<usize, Output = Self>\n    + ShrRoundAssign<i128>\n    + ShrRoundAssign<i16>\n    + ShrRoundAssign<i32>\n    + ShrRoundAssign<i64>\n    + ShrRoundAssign<i8>\n    + ShrRoundAssign<isize>\n    + ShrRoundAssign<u128>\n    + ShrRoundAssign<u16>\n    + ShrRoundAssign<u32>\n    + ShrRoundAssign<u64>\n    + ShrRoundAssign<u8>\n    + ShrRoundAssign<usize>\n    + Sign\n    + SignificantBits\n    + Sized\n    + Square<Output = Self>\n    + SquareAssign\n    + Sub<Self, Output = Self>\n    + SubAssign<Self>\n    + SubMul<Self, Self, Output = Self>\n    + SubMulAssign<Self, Self>\n    + Sum<Self>\n    + ToSci\n    + ToStringBase\n    + TrailingZeros\n    + TryFrom<NiceFloat<f32>>\n    + TryFrom<i128>\n    + TryFrom<i16>\n    + TryFrom<i32>\n    + TryFrom<i64>\n    + TryFrom<i8>\n    + TryFrom<isize>\n    + TryFrom<u128>\n    + TryFrom<u16>\n    + TryFrom<u32>\n    + TryFrom<u64>\n    + TryFrom<u8>\n    + TryFrom<usize>\n    + TryInto<NiceFloat<f32>>\n    + TryInto<i128>\n    + TryInto<i16>\n    + TryInto<i32>\n    + TryInto<i64>\n    + TryInto<i8>\n    + TryInto<isize>\n    + TryInto<u128>\n    + TryInto<u16>\n    + TryInto<u32>\n    + TryInto<u64>\n    + TryInto<u8>\n    + TryInto<usize>\n    + Two\n    + UnwindSafe\n    + UpperHex\n    + WrappingAdd<Self, Output = Self>\n    + WrappingAddAssign<Self>\n    + WrappingAddMul<Self, Self, Output = Self>\n    + WrappingAddMulAssign<Self, Self>\n    + WrappingDiv<Self, Output = Self>\n    + WrappingDivAssign<Self>\n    + WrappingFrom<i128>\n    + WrappingFrom<i16>\n    + WrappingFrom<i32>\n    + WrappingFrom<i64>\n    + WrappingFrom<i8>\n    + WrappingFrom<isize>\n    + WrappingFrom<u128>\n    + WrappingFrom<u16>\n    + WrappingFrom<u32>\n    + WrappingFrom<u64>\n    + WrappingFrom<u8>\n    + WrappingFrom<usize>\n    + WrappingInto<i128>\n    + WrappingInto<i16>\n    + WrappingInto<i32>\n    + WrappingInto<i64>\n    + WrappingInto<i8>\n    + WrappingInto<isize>\n    + WrappingInto<u128>\n    + WrappingInto<u16>\n    + WrappingInto<u32>\n    + WrappingInto<u64>\n    + WrappingInto<u8>\n    + WrappingInto<usize>\n    + WrappingMul<Self, Output = Self>\n    + WrappingMulAssign<Self>\n    + WrappingNeg<Output = Self>\n    + WrappingNegAssign\n    + WrappingPow<u64, Output = Self>\n    + WrappingPowAssign<u64>\n    + WrappingSquare<Output = Self>\n    + WrappingSquareAssign\n    + WrappingSub<Self, Output = Self>\n    + WrappingSubAssign<Self>\n    + WrappingSubMul<Self, Self, Output = Self>\n    + WrappingSubMulAssign<Self, Self>\n    + Zero\n{\n    /// The number of bits of `Self`.\n    const WIDTH: u64;\n\n    /// The base-2 logarithm of the number of bits of `Self`.\n    ///\n    /// Whenever you need to use `n / WIDTH`, you can use `n >> LOG_WIDTH` instead.\n    ///\n    /// This is $\\log_2 W$.\n    ///\n    /// Note that this value is correct for all of the built-in primitive integer types, but it will\n    /// not be correct for custom types whose $W$ is not a power of 2. For such implementations,\n    /// `LOG_WIDTH` should not be used.\n    const LOG_WIDTH: u64 = Self::WIDTH.trailing_zeros() as u64;\n\n    /// A mask that consists of `LOG_WIDTH` bits.\n    ///\n    /// Whenever you need to use `n % WIDTH`, you can use `n & WIDTH_MASK` instead.\n    ///\n    /// This is $W - 1$.\n    ///\n    /// Note that this value is correct for all of the built-in primitive integer types, but it will\n    /// not be correct for custom types whose $W$ is not a power of 2. For such implementations,\n    /// `WIDTH_MASK` should not be used.\n    const WIDTH_MASK: u64 = Self::WIDTH - 1;\n\n    /// Gets the most-significant bit of `Self`. For signed integers, this is the sign bit.\n    ///\n    /// If `Self` is unsigned, $f(n) = (n \\geq 2^{W-1})$. If `Self` is unsigned, $f(n) = (n < 0)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    ///\n    /// assert_eq!(123u32.get_highest_bit(), false);\n    /// assert_eq!(4000000000u32.get_highest_bit(), true);\n    /// assert_eq!(2000000000i32.get_highest_bit(), false);\n    /// assert_eq!((-2000000000i32).get_highest_bit(), true);\n    /// ```\n    #[inline]\n    fn get_highest_bit(&self) -> bool {\n        self.get_bit(Self::WIDTH - 1)\n    }\n}\n\n#[cfg(not(feature = \"random\"))]\n/// Defines functions on primitive integer types: uxx, ixx, usize, and isize.\n///\n/// The different types are distinguished by whether they are signed or unsigned, and by their\n/// widths. The width $W$ is the number of bits in the type. For example, the width of [`u32`] or\n/// [`i32`] is 32. Each type has $2^W$ distinct values.\n///\n/// Let $n$ be a value of type `Self`. If `Self` is unsigned, $0 \\leq n < 2^W$. If `Self` is signed,\n/// $2^{W-1} \\leq n < 2^{W-1}$.\npub trait PrimitiveInt:\n    'static\n    + AbsDiff<Self>\n    + Add<Self, Output = Self>\n    + AddAssign<Self>\n    + AddMul<Self, Self, Output = Self>\n    + AddMulAssign<Self, Self>\n    + ArithmeticCheckedShl<i128, Output = Self>\n    + ArithmeticCheckedShl<i16, Output = Self>\n    + ArithmeticCheckedShl<i32, Output = Self>\n    + ArithmeticCheckedShl<i64, Output = Self>\n    + ArithmeticCheckedShl<i8, Output = Self>\n    + ArithmeticCheckedShl<isize, Output = Self>\n    + ArithmeticCheckedShl<u128, Output = Self>\n    + ArithmeticCheckedShl<u16, Output = Self>\n    + ArithmeticCheckedShl<u32, Output = Self>\n    + ArithmeticCheckedShl<u64, Output = Self>\n    + ArithmeticCheckedShl<u8, Output = Self>\n    + ArithmeticCheckedShl<usize, Output = Self>\n    + ArithmeticCheckedShr<i128, Output = Self>\n    + ArithmeticCheckedShr<i16, Output = Self>\n    + ArithmeticCheckedShr<i32, Output = Self>\n    + ArithmeticCheckedShr<i64, Output = Self>\n    + ArithmeticCheckedShr<i8, Output = Self>\n    + ArithmeticCheckedShr<isize, Output = Self>\n    + Binary\n    + BinomialCoefficient<Self>\n    + BitAccess\n    + BitAnd<Self, Output = Self>\n    + BitAndAssign<Self>\n    + BitBlockAccess\n    + BitConvertible\n    + BitIterable\n    + BitOr<Self, Output = Self>\n    + BitOrAssign<Self>\n    + BitScan\n    + BitXor<Self, Output = Self>\n    + BitXorAssign<Self>\n    + CeilingRoot<u64, Output = Self>\n    + CeilingRootAssign<u64>\n    + CeilingSqrt<Output = Self>\n    + CeilingSqrtAssign\n    + CheckedAdd<Self, Output = Self>\n    + CheckedAddMul<Self, Self, Output = Self>\n    + CheckedBinomialCoefficient<Self>\n    + CheckedDiv<Self, Output = Self>\n    + CheckedMul<Self, Output = Self>\n    + CheckedNeg<Output = Self>\n    + CheckedPow<u64, Output = Self>\n    + CheckedRoot<u64, Output = Self>\n    + CheckedSqrt<Output = Self>\n    + CheckedSquare<Output = Self>\n    + CheckedSub<Self, Output = Self>\n    + CheckedSubMul<Self, Self, Output = Self>\n    + Clone\n    + ConvertibleFrom<f32>\n    + ConvertibleFrom<f64>\n    + ConvertibleFrom<i128>\n    + ConvertibleFrom<i16>\n    + ConvertibleFrom<i32>\n    + ConvertibleFrom<i64>\n    + ConvertibleFrom<i8>\n    + ConvertibleFrom<isize>\n    + ConvertibleFrom<u128>\n    + ConvertibleFrom<u16>\n    + ConvertibleFrom<u32>\n    + ConvertibleFrom<u64>\n    + ConvertibleFrom<u8>\n    + ConvertibleFrom<usize>\n    + Copy\n    + CountOnes\n    + CountZeros\n    + Debug\n    + Default\n    + Display\n    + Div<Self, Output = Self>\n    + DivAssign<Self>\n    + DivAssignMod<Self, ModOutput = Self>\n    + DivAssignRem<Self, RemOutput = Self>\n    + DivExact<Self, Output = Self>\n    + DivExactAssign<Self>\n    + DivMod<Self, DivOutput = Self, ModOutput = Self>\n    + DivRem<Self, DivOutput = Self, RemOutput = Self>\n    + DivRound<Self, Output = Self>\n    + DivRoundAssign<Self>\n    + DivisibleBy<Self>\n    + DivisibleByPowerOf2\n    + Eq\n    + EqMod<Self, Self>\n    + EqModPowerOf2<Self>\n    + ExactFrom<i128>\n    + ExactFrom<i16>\n    + ExactFrom<i32>\n    + ExactFrom<i64>\n    + ExactFrom<i8>\n    + ExactFrom<isize>\n    + ExactFrom<u128>\n    + ExactFrom<u16>\n    + ExactFrom<u32>\n    + ExactFrom<u64>\n    + ExactFrom<u8>\n    + ExactFrom<usize>\n    + ExactInto<i128>\n    + ExactInto<i16>\n    + ExactInto<i32>\n    + ExactInto<i64>\n    + ExactInto<i8>\n    + ExactInto<isize>\n    + ExactInto<u128>\n    + ExactInto<u16>\n    + ExactInto<u32>\n    + ExactInto<u64>\n    + ExactInto<u8>\n    + ExactInto<usize>\n    + ExpressAsPower\n    + ExtendedGcd<Self>\n    + FloorRoot<u64, Output = Self>\n    + FloorRootAssign<u64>\n    + FloorSqrt<Output = Self>\n    + FloorSqrtAssign\n    + From<bool>\n    + FromSciString\n    + FromStr\n    + FromStringBase\n    + Hash\n    + IsInteger\n    + IsPower\n    + IsSquare\n    + JacobiSymbol<Self>\n    + KroneckerSymbol<Self>\n    + LeadingZeros\n    + LegendreSymbol<Self>\n    + LowMask\n    + LowerHex\n    + Max\n    + Min\n    + Mod<Self, Output = Self>\n    + ModAssign<Self>\n    + ModPowerOf2\n    + ModPowerOf2Assign\n    + Mul<Self, Output = Self>\n    + MulAssign<Self>\n    + Named\n    + Not<Output = Self>\n    + NotAssign\n    + Octal\n    + One\n    + Ord\n    + OverflowingAdd<Self, Output = Self>\n    + OverflowingAddAssign<Self>\n    + OverflowingAddMul<Self, Self, Output = Self>\n    + OverflowingAddMulAssign<Self, Self>\n    + OverflowingDiv<Self, Output = Self>\n    + OverflowingDivAssign<Self>\n    + OverflowingFrom<i128>\n    + OverflowingFrom<i16>\n    + OverflowingFrom<i32>\n    + OverflowingFrom<i64>\n    + OverflowingFrom<i8>\n    + OverflowingFrom<isize>\n    + OverflowingFrom<u128>\n    + OverflowingFrom<u16>\n    + OverflowingFrom<u32>\n    + OverflowingFrom<u64>\n    + OverflowingFrom<u8>\n    + OverflowingFrom<usize>\n    + OverflowingInto<i128>\n    + OverflowingInto<i16>\n    + OverflowingInto<i32>\n    + OverflowingInto<i64>\n    + OverflowingInto<i8>\n    + OverflowingInto<isize>\n    + OverflowingInto<u128>\n    + OverflowingInto<u16>\n    + OverflowingInto<u32>\n    + OverflowingInto<u64>\n    + OverflowingInto<u8>\n    + OverflowingInto<usize>\n    + OverflowingMul<Self, Output = Self>\n    + OverflowingMulAssign<Self>\n    + OverflowingNeg<Output = Self>\n    + OverflowingNegAssign\n    + OverflowingPow<u64, Output = Self>\n    + OverflowingPowAssign<u64>\n    + OverflowingSquare<Output = Self>\n    + OverflowingSquareAssign\n    + OverflowingSub<Self, Output = Self>\n    + OverflowingSubAssign<Self>\n    + OverflowingSubMul<Self, Self, Output = Self>\n    + OverflowingSubMulAssign<Self, Self>\n    + Parity\n    + PartialEq<Self>\n    + PartialOrd<Self>\n    + Pow<u64, Output = Self>\n    + PowAssign<u64>\n    + PowerOf2<u64>\n    + Product\n    + RefUnwindSafe\n    + Rem<Self, Output = Self>\n    + RemAssign<Self>\n    + RemPowerOf2<Output = Self>\n    + RemPowerOf2Assign\n    + RotateLeft<Output = Self>\n    + RotateLeftAssign\n    + RotateRight<Output = Self>\n    + RotateRightAssign\n    + RoundToMultiple<Self, Output = Self>\n    + RoundToMultipleAssign<Self>\n    + RoundToMultipleOfPowerOf2<u64, Output = Self>\n    + RoundToMultipleOfPowerOf2Assign<u64>\n    + RoundingFrom<f32>\n    + RoundingFrom<f64>\n    + RoundingInto<f32>\n    + RoundingInto<f64>\n    + SaturatingAdd<Self, Output = Self>\n    + SaturatingAddAssign<Self>\n    + SaturatingAddMul<Self, Self, Output = Self>\n    + SaturatingAddMulAssign<Self, Self>\n    + SaturatingFrom<i128>\n    + SaturatingFrom<i16>\n    + SaturatingFrom<i32>\n    + SaturatingFrom<i64>\n    + SaturatingFrom<i8>\n    + SaturatingFrom<isize>\n    + SaturatingFrom<u128>\n    + SaturatingFrom<u16>\n    + SaturatingFrom<u32>\n    + SaturatingFrom<u64>\n    + SaturatingFrom<u8>\n    + SaturatingFrom<usize>\n    + SaturatingInto<i128>\n    + SaturatingInto<i16>\n    + SaturatingInto<i32>\n    + SaturatingInto<i64>\n    + SaturatingInto<i8>\n    + SaturatingInto<isize>\n    + SaturatingInto<u128>\n    + SaturatingInto<u16>\n    + SaturatingInto<u32>\n    + SaturatingInto<u64>\n    + SaturatingInto<u8>\n    + SaturatingInto<usize>\n    + SaturatingMul<Self, Output = Self>\n    + SaturatingMulAssign<Self>\n    + SaturatingPow<u64, Output = Self>\n    + SaturatingPowAssign<u64>\n    + SaturatingSquare<Output = Self>\n    + SaturatingSquareAssign\n    + SaturatingSub<Self, Output = Self>\n    + SaturatingSubAssign<Self>\n    + SaturatingSubMul<Self, Self, Output = Self>\n    + SaturatingSubMulAssign<Self, Self>\n    + Shl<i128, Output = Self>\n    + Shl<i16, Output = Self>\n    + Shl<i32, Output = Self>\n    + Shl<i64, Output = Self>\n    + Shl<i8, Output = Self>\n    + Shl<u128, Output = Self>\n    + Shl<u16, Output = Self>\n    + Shl<u32, Output = Self>\n    + Shl<u64, Output = Self>\n    + Shl<u8, Output = Self>\n    + ShlAssign<i128>\n    + ShlAssign<i16>\n    + ShlAssign<i32>\n    + ShlAssign<i64>\n    + ShlAssign<i8>\n    + ShlAssign<isize>\n    + ShlAssign<u128>\n    + ShlAssign<u16>\n    + ShlAssign<u32>\n    + ShlAssign<u64>\n    + ShlAssign<u8>\n    + ShlAssign<usize>\n    + ShlRound<i128, Output = Self>\n    + ShlRound<i16, Output = Self>\n    + ShlRound<i32, Output = Self>\n    + ShlRound<i64, Output = Self>\n    + ShlRound<i8, Output = Self>\n    + ShlRound<isize, Output = Self>\n    + ShlRoundAssign<i128>\n    + ShlRoundAssign<i16>\n    + ShlRoundAssign<i32>\n    + ShlRoundAssign<i64>\n    + ShlRoundAssign<i8>\n    + ShlRoundAssign<isize>\n    + Shr<i128, Output = Self>\n    + Shr<i16, Output = Self>\n    + Shr<i32, Output = Self>\n    + Shr<i64, Output = Self>\n    + Shr<i8, Output = Self>\n    + Shr<isize, Output = Self>\n    + Shr<u128, Output = Self>\n    + Shr<u16, Output = Self>\n    + Shr<u32, Output = Self>\n    + Shr<u64, Output = Self>\n    + Shr<u8, Output = Self>\n    + Shr<usize, Output = Self>\n    + ShrAssign<i128>\n    + ShrAssign<i16>\n    + ShrAssign<i32>\n    + ShrAssign<i64>\n    + ShrAssign<i8>\n    + ShrAssign<isize>\n    + ShrAssign<u128>\n    + ShrAssign<u16>\n    + ShrAssign<u32>\n    + ShrAssign<u64>\n    + ShrAssign<u8>\n    + ShrAssign<usize>\n    + ShrRound<i128, Output = Self>\n    + ShrRound<i16, Output = Self>\n    + ShrRound<i32, Output = Self>\n    + ShrRound<i64, Output = Self>\n    + ShrRound<i8, Output = Self>\n    + ShrRound<isize, Output = Self>\n    + ShrRound<u128, Output = Self>\n    + ShrRound<u16, Output = Self>\n    + ShrRound<u32, Output = Self>\n    + ShrRound<u64, Output = Self>\n    + ShrRound<u8, Output = Self>\n    + ShrRound<usize, Output = Self>\n    + ShrRoundAssign<i128>\n    + ShrRoundAssign<i16>\n    + ShrRoundAssign<i32>\n    + ShrRoundAssign<i64>\n    + ShrRoundAssign<i8>\n    + ShrRoundAssign<isize>\n    + ShrRoundAssign<u128>\n    + ShrRoundAssign<u16>\n    + ShrRoundAssign<u32>\n    + ShrRoundAssign<u64>\n    + ShrRoundAssign<u8>\n    + ShrRoundAssign<usize>\n    + Sign\n    + SignificantBits\n    + Sized\n    + Square<Output = Self>\n    + SquareAssign\n    + Sub<Self, Output = Self>\n    + SubAssign<Self>\n    + SubMul<Self, Self, Output = Self>\n    + SubMulAssign<Self, Self>\n    + Sum<Self>\n    + ToSci\n    + ToStringBase\n    + TrailingZeros\n    + TryFrom<NiceFloat<f32>>\n    + TryFrom<i128>\n    + TryFrom<i16>\n    + TryFrom<i32>\n    + TryFrom<i64>\n    + TryFrom<i8>\n    + TryFrom<isize>\n    + TryFrom<u128>\n    + TryFrom<u16>\n    + TryFrom<u32>\n    + TryFrom<u64>\n    + TryFrom<u8>\n    + TryFrom<usize>\n    + TryInto<NiceFloat<f32>>\n    + TryInto<i128>\n    + TryInto<i16>\n    + TryInto<i32>\n    + TryInto<i64>\n    + TryInto<i8>\n    + TryInto<isize>\n    + TryInto<u128>\n    + TryInto<u16>\n    + TryInto<u32>\n    + TryInto<u64>\n    + TryInto<u8>\n    + TryInto<usize>\n    + Two\n    + UnwindSafe\n    + UpperHex\n    + WrappingAdd<Self, Output = Self>\n    + WrappingAddAssign<Self>\n    + WrappingAddMul<Self, Self, Output = Self>\n    + WrappingAddMulAssign<Self, Self>\n    + WrappingDiv<Self, Output = Self>\n    + WrappingDivAssign<Self>\n    + WrappingFrom<i128>\n    + WrappingFrom<i16>\n    + WrappingFrom<i32>\n    + WrappingFrom<i64>\n    + WrappingFrom<i8>\n    + WrappingFrom<isize>\n    + WrappingFrom<u128>\n    + WrappingFrom<u16>\n    + WrappingFrom<u32>\n    + WrappingFrom<u64>\n    + WrappingFrom<u8>\n    + WrappingFrom<usize>\n    + WrappingInto<i128>\n    + WrappingInto<i16>\n    + WrappingInto<i32>\n    + WrappingInto<i64>\n    + WrappingInto<i8>\n    + WrappingInto<isize>\n    + WrappingInto<u128>\n    + WrappingInto<u16>\n    + WrappingInto<u32>\n    + WrappingInto<u64>\n    + WrappingInto<u8>\n    + WrappingInto<usize>\n    + WrappingMul<Self, Output = Self>\n    + WrappingMulAssign<Self>\n    + WrappingNeg<Output = Self>\n    + WrappingNegAssign\n    + WrappingPow<u64, Output = Self>\n    + WrappingPowAssign<u64>\n    + WrappingSquare<Output = Self>\n    + WrappingSquareAssign\n    + WrappingSub<Self, Output = Self>\n    + WrappingSubAssign<Self>\n    + WrappingSubMul<Self, Self, Output = Self>\n    + WrappingSubMulAssign<Self, Self>\n    + Zero\n{\n    /// The number of bits of `Self`.\n    const WIDTH: u64;\n\n    /// The base-2 logarithm of the number of bits of `Self`.\n    ///\n    /// Whenever you need to use `n / WIDTH`, you can use `n >> LOG_WIDTH` instead.\n    ///\n    /// This is $\\log_2 W$.\n    ///\n    /// Note that this value is correct for all of the built-in primitive integer types, but it will\n    /// not be correct for custom types whose $W$ is not a power of 2. For such implementations,\n    /// `LOG_WIDTH` should not be used.\n    const LOG_WIDTH: u64 = Self::WIDTH.trailing_zeros() as u64;\n\n    /// A mask that consists of `LOG_WIDTH` bits.\n    ///\n    /// Whenever you need to use `n % WIDTH`, you can use `n & WIDTH_MASK` instead.\n    ///\n    /// This is $W - 1$.\n    ///\n    /// Note that this value is correct for all of the built-in primitive integer types, but it will\n    /// not be correct for custom types whose $W$ is not a power of 2. For such implementations,\n    /// `WIDTH_MASK` should not be used.\n    const WIDTH_MASK: u64 = Self::WIDTH - 1;\n\n    /// Gets the most-significant bit of `Self`. For signed integers, this is the sign bit.\n    ///\n    /// If `Self` is unsigned, $f(n) = (n \\geq 2^{W-1})$. If `Self` is unsigned, $f(n) = (n < 0)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    ///\n    /// assert_eq!(123u32.get_highest_bit(), false);\n    /// assert_eq!(4000000000u32.get_highest_bit(), true);\n    /// assert_eq!(2000000000i32.get_highest_bit(), false);\n    /// assert_eq!((-2000000000i32).get_highest_bit(), true);\n    /// ```\n    #[inline]\n    fn get_highest_bit(&self) -> bool {\n        self.get_bit(Self::WIDTH - 1)\n    }\n}\n\n/// Defines basic trait implementations that are the same for unsigned and signed types.\nmacro_rules! impl_basic_traits_primitive_int {\n    ($t:ident, $width:expr) => {\n        /// # Examples\n        ///\n        /// See [here](self).\n        impl PrimitiveInt for $t {\n            const WIDTH: u64 = $width;\n        }\n\n        impl_named!($t);\n\n        /// The constant 0.\n        ///\n        /// # Examples\n        /// See [here](self).\n        impl Zero for $t {\n            const ZERO: $t = 0;\n        }\n\n        /// The constant 1.\n        ///\n        /// # Examples\n        /// See [here](self).\n        impl One for $t {\n            const ONE: $t = 1;\n        }\n\n        /// The constant 2.\n        ///\n        /// # Examples\n        /// See [here](self).\n        impl Two for $t {\n            const TWO: $t = 2;\n        }\n\n        /// The lowest value representable by this type.\n        ///\n        /// If `Self` is unsigned, `MIN` is 0. If `Self` is signed, `MIN` is $-2^{W-1}$.\n        ///\n        /// # Examples\n        /// See [here](self).\n        impl Min for $t {\n            const MIN: $t = $t::MIN;\n        }\n\n        /// The highest value representable by this type.\n        ///\n        /// If `Self` is unsigned, `MAX` is $2^W-1$. If `Self` is signed, `MAX` is $2^{W-1}-1$.\n        ///\n        /// # Examples\n        /// See [here](self).\n        impl Max for $t {\n            const MAX: $t = $t::MAX;\n        }\n    };\n}\nimpl_basic_traits_primitive_int!(u8, 8);\nimpl_basic_traits_primitive_int!(u16, 16);\nimpl_basic_traits_primitive_int!(u32, 32);\nimpl_basic_traits_primitive_int!(u64, 64);\nimpl_basic_traits_primitive_int!(u128, 128);\nimpl_basic_traits_primitive_int!(usize, 0usize.trailing_zeros() as u64);\nimpl_basic_traits_primitive_int!(i8, 8);\nimpl_basic_traits_primitive_int!(i16, 16);\nimpl_basic_traits_primitive_int!(i32, 32);\nimpl_basic_traits_primitive_int!(i64, 64);\nimpl_basic_traits_primitive_int!(i128, 128);\nimpl_basic_traits_primitive_int!(isize, 0usize.trailing_zeros() as u64);\n"
  },
  {
    "path": "malachite-base/src/num/basic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// The [`PrimitiveFloat`](floats::PrimitiveFloat) trait.\npub mod floats;\n/// The [`PrimitiveInt`](integers::PrimitiveInt) trait.\n///\n/// ```\n/// use malachite_base::num::basic::integers::PrimitiveInt;\n/// use malachite_base::num::basic::traits::{One, Two, Zero};\n///\n/// assert_eq!(u32::WIDTH, 32);\n/// assert_eq!(u32::LOG_WIDTH, 5);\n/// assert_eq!(u32::WIDTH_MASK, 0x1f);\n///\n/// assert_eq!(u32::ZERO, 0);\n/// assert_eq!(u32::ONE, 1);\n/// assert_eq!(i16::TWO, 2);\n///\n/// assert_eq!(u32::MAX, 0xffffffff);\n/// assert_eq!(u32::MIN, 0);\n/// assert_eq!(i32::MAX, 0x7fffffff);\n/// assert_eq!(i32::MIN, -0x80000000);\n/// ```\npub mod integers;\n/// The [`PrimitiveSigned`](signeds::PrimitiveSigned) trait.\n///\n/// ```\n/// use malachite_base::num::basic::traits::NegativeOne;\n///\n/// assert_eq!(i16::NEGATIVE_ONE, -1);\n/// ```\npub mod signeds;\n/// Traits for constants.\npub mod traits;\n/// The [`PrimitiveUnsigned`](unsigneds::PrimitiveUnsigned) trait.\npub mod unsigneds;\n"
  },
  {
    "path": "malachite-base/src/num/basic/signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    Abs, AbsAssign, CeilingDivAssignMod, CeilingDivMod, CeilingMod, CeilingModAssign,\n    CeilingModPowerOf2, CeilingModPowerOf2Assign, CheckedAbs, ExtendedGcd, NegAssign,\n    OverflowingAbs, OverflowingAbsAssign, SaturatingAbs, SaturatingAbsAssign, SaturatingNeg,\n    SaturatingNegAssign, UnsignedAbs, WrappingAbs, WrappingAbsAssign,\n};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::traits::NegativeOne;\nuse crate::num::comparison::traits::{EqAbs, OrdAbs, PartialOrdAbs};\nuse crate::num::logic::traits::CheckedHammingDistance;\n#[cfg(feature = \"random\")]\nuse crate::num::random::{HasRandomSignedRange, RandomSignedChunkable};\nuse core::ops::Neg;\n\n// When the `random` feature is enabled, the HasRandomSignedRange and RandomSignedChunkable bounds\n// are included.\n\n#[cfg(feature = \"random\")]\n/// Defines functions on primitive signed integer types: ixx and isize.\npub trait PrimitiveSigned:\n    Abs<Output = Self>\n    + AbsAssign\n    + CeilingDivAssignMod<Self, ModOutput = Self>\n    + CeilingDivMod<Self, DivOutput = Self, ModOutput = Self>\n    + CeilingMod<Self, Output = Self>\n    + CeilingModAssign<Self>\n    + CeilingModPowerOf2<Output = Self>\n    + CeilingModPowerOf2Assign\n    + CheckedAbs<Output = Self>\n    + CheckedHammingDistance\n    + EqAbs<Self>\n    + ExtendedGcd<Self, Cofactor = Self>\n    + From<i8>\n    + HasRandomSignedRange\n    + Neg<Output = Self>\n    + NegAssign\n    + NegativeOne\n    + OrdAbs\n    + OverflowingAbs<Output = Self>\n    + OverflowingAbsAssign\n    + PartialOrdAbs<Self>\n    + PrimitiveInt\n    + RandomSignedChunkable\n    + SaturatingAbs<Output = Self>\n    + SaturatingAbsAssign\n    + SaturatingNeg<Output = Self>\n    + SaturatingNegAssign\n    + UnsignedAbs\n    + WrappingAbs<Output = Self>\n    + WrappingAbsAssign\n{\n}\n\n#[cfg(not(feature = \"random\"))]\n/// Defines functions on primitive signed integer types: ixx and isize.\npub trait PrimitiveSigned:\n    Abs<Output = Self>\n    + AbsAssign\n    + CeilingDivAssignMod<Self, ModOutput = Self>\n    + CeilingDivMod<Self, DivOutput = Self, ModOutput = Self>\n    + CeilingMod<Self, Output = Self>\n    + CeilingModAssign<Self>\n    + CeilingModPowerOf2<Output = Self>\n    + CeilingModPowerOf2Assign\n    + CheckedAbs<Output = Self>\n    + CheckedHammingDistance\n    + EqAbs<Self>\n    + ExtendedGcd<Self, Cofactor = Self>\n    + From<i8>\n    + Neg<Output = Self>\n    + NegAssign\n    + NegativeOne\n    + OrdAbs\n    + OverflowingAbs<Output = Self>\n    + OverflowingAbsAssign\n    + PartialOrdAbs<Self>\n    + PrimitiveInt\n    + SaturatingAbs<Output = Self>\n    + SaturatingAbsAssign\n    + SaturatingNeg<Output = Self>\n    + SaturatingNegAssign\n    + UnsignedAbs\n    + WrappingAbs<Output = Self>\n    + WrappingAbsAssign\n{\n}\n\n/// Defines basic trait implementations for signed types.\nmacro_rules! impl_basic_traits {\n    ($s: ident) => {\n        impl PrimitiveSigned for $s {}\n\n        /// The constant -1.\n        ///\n        /// # Examples\n        /// See [here](self).\n        impl NegativeOne for $s {\n            const NEGATIVE_ONE: $s = -1;\n        }\n    };\n}\napply_to_signeds!(impl_basic_traits);\n"
  },
  {
    "path": "malachite-base/src/num/basic/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Implementations of traits for NonZero* types by b4D8.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::num::*;\n\n/// Provides the constant 0.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait Zero {\n    const ZERO: Self;\n}\n\n/// Provides the constant 1.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait One {\n    const ONE: Self;\n}\n\n/// Provides the constant 2.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait Two {\n    const TWO: Self;\n}\n\n/// Provides the constant -1.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait NegativeOne {\n    const NEGATIVE_ONE: Self;\n}\n\n/// Provides the constant 1/2.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait OneHalf {\n    const ONE_HALF: Self;\n}\n\n/// Provides the constant -0.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait NegativeZero {\n    const NEGATIVE_ZERO: Self;\n}\n\n/// Provides the constant (positive) Infinity.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait Infinity {\n    const INFINITY: Self;\n}\n\n/// Provides the constant -Infinity.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait NegativeInfinity {\n    const NEGATIVE_INFINITY: Self;\n}\n\n/// Provides the constant NaN.\n#[allow(clippy::declare_interior_mutable_const)]\npub trait NaN {\n    const NAN: Self;\n}\n\n/// Provides the Prouhet-Thue-Morse constant, whose bits are the Thue-Morse sequence.\npub trait ProuhetThueMorseConstant {\n    const PROUHET_THUE_MORSE_CONSTANT: Self;\n}\n\n/// Provides the prime constant, whose $n$th bit (starting from $n=1$) is true if and only if $n$ is\n/// prime.\npub trait PrimeConstant {\n    const PRIME_CONSTANT: Self;\n}\n\n/// Provides $\\ln 2$.\npub trait Ln2 {\n    const LN_2: Self;\n}\n\n/// Provides $\\log_2 e$.\npub trait Log2E {\n    const LOG_2_E: Self;\n}\n\n/// Provides $\\sqrt{2}$.\npub trait Sqrt2 {\n    const SQRT_2: Self;\n}\n\n/// Provides $\\sqrt{3}$.\npub trait Sqrt3 {\n    const SQRT_3: Self;\n}\n\n/// Provides $\\sqrt{2}/2=\\sqrt{1/2}=1/\\sqrt{2}$.\npub trait Sqrt2Over2 {\n    const SQRT_2_OVER_2: Self;\n}\n\n/// Provides $\\sqrt{3}/3=\\sqrt{1/3}=1/\\sqrt{3}$.\npub trait Sqrt3Over3 {\n    const SQRT_3_OVER_3: Self;\n}\n\n/// Provides $\\varphi$, the golden ratio.\npub trait Phi {\n    const PHI: Self;\n}\n\n/// Provides $\\pi$.\npub trait Pi {\n    const PI: Self;\n}\n\n/// Provides $\\tau=2\\pi$.\npub trait Tau {\n    const TAU: Self;\n}\n\n/// Provides $\\pi/2$.\npub trait PiOver2 {\n    const PI_OVER_2: Self;\n}\n\n/// Provides $\\pi/3$.\npub trait PiOver3 {\n    const PI_OVER_3: Self;\n}\n\n/// Provides $\\pi/4$.\npub trait PiOver4 {\n    const PI_OVER_4: Self;\n}\n\n/// Provides $\\pi/6$.\npub trait PiOver6 {\n    const PI_OVER_6: Self;\n}\n\n/// Provides $\\pi/8$.\npub trait PiOver8 {\n    const PI_OVER_8: Self;\n}\n\n/// Provides $1/\\pi$.\npub trait OneOverPi {\n    const ONE_OVER_PI: Self;\n}\n\n/// Provides $\\sqrt{\\pi}$.\npub trait SqrtPi {\n    const SQRT_PI: Self;\n}\n\n/// Provides $1/\\sqrt{\\pi}$.\npub trait OneOverSqrtPi {\n    const ONE_OVER_SQRT_PI: Self;\n}\n\n/// Provides $1/\\sqrt{\\tau}=1/\\sqrt{2\\pi}$.\npub trait OneOverSqrtTau {\n    const ONE_OVER_SQRT_TAU: Self;\n}\n\n/// Provides $2/\\pi$.\npub trait TwoOverPi {\n    const TWO_OVER_PI: Self;\n}\n\n/// Provides $2/\\sqrt{\\pi}$.\npub trait TwoOverSqrtPi {\n    const TWO_OVER_SQRT_PI: Self;\n}\n\n/// Provides Gauss's constant, $G=1/\\mathrm{AGM}(1,\\sqrt{2})$.\n///\n/// Having three consecutive esses in an identifier is awkward, so let's pretend that we sometimes\n/// use AP Style and write \"Gauss' constant\".\npub trait GaussConstant {\n    const GAUSS_CONSTANT: Self;\n}\n\n/// Provides the lemniscate constant $\\varpi=\\pi G$, where $G$ is Gauss's constant.\npub trait LemniscateConstant {\n    const LEMNISCATE_CONSTANT: Self;\n}\n\n// Implementation for `NonZero*` types:\n// - `One` and `Two` for both signed and unsigned variants\n// - `NegativeOne` for the signed variant\nmacro_rules! impl_non_zero {\n    ($($t:ident),+) => {\n        $(\n            impl One for $t {\n                const ONE: Self = match Self::new(1) {\n                    Some(v) => v,\n                    None => unreachable!() // 1 is a valid nonzero value\n                };\n            }\n\n            impl Two for $t {\n                const TWO: Self = match Self::new(2) {\n                    Some(v) => v,\n                    None => unreachable!() // 2 is a valid nonzero value\n                };\n            }\n        )+\n    };\n    ($($u:ident && $i:ident),+) => {\n        $(\n            impl_non_zero!($u, $i);\n\n            impl NegativeOne for $i {\n                const NEGATIVE_ONE: Self = match Self::new(-1) {\n                    Some(v) => v,\n                    None => unreachable!() // -1 is a valid non zero value\n                };\n            }\n        )+\n    }\n}\n\nimpl_non_zero!(\n    NonZeroUsize && NonZeroIsize,\n    NonZeroU128 && NonZeroI128,\n    NonZeroU64 && NonZeroI64,\n    NonZeroU32 && NonZeroI32,\n    NonZeroU16 && NonZeroI16,\n    NonZeroU8 && NonZeroI8\n);\n"
  },
  {
    "path": "malachite-base/src/num/basic/unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    AbsDiff, AbsDiffAssign, CeilingDivAssignNegMod, CeilingDivNegMod, CeilingLogBase,\n    CeilingLogBase2, CeilingLogBasePowerOf2, CheckedDoubleFactorial, CheckedFactorial, CheckedLcm,\n    CheckedLogBase, CheckedLogBase2, CheckedLogBasePowerOf2, CheckedMultifactorial,\n    CheckedNextPowerOf2, CheckedPrimorial, CheckedSubfactorial, CoprimeWith, DoubleFactorial,\n    ExtendedGcd, Factorial, FloorLogBase, FloorLogBase2, FloorLogBasePowerOf2, Gcd, GcdAssign,\n    IsPowerOf2, Lcm, LcmAssign, ModAdd, ModAddAssign, ModInverse, ModIsReduced, ModMul,\n    ModMulAssign, ModMulPrecomputed, ModMulPrecomputedAssign, ModNeg, ModNegAssign, ModPow,\n    ModPowAssign, ModPowPrecomputed, ModPowPrecomputedAssign, ModPowerOf2, ModPowerOf2Add,\n    ModPowerOf2AddAssign, ModPowerOf2Inverse, ModPowerOf2IsReduced, ModPowerOf2Mul,\n    ModPowerOf2MulAssign, ModPowerOf2Neg, ModPowerOf2NegAssign, ModPowerOf2Pow,\n    ModPowerOf2PowAssign, ModPowerOf2Shl, ModPowerOf2ShlAssign, ModPowerOf2Shr,\n    ModPowerOf2ShrAssign, ModPowerOf2Square, ModPowerOf2SquareAssign, ModPowerOf2Sub,\n    ModPowerOf2SubAssign, ModSquare, ModSquareAssign, ModSquarePrecomputed,\n    ModSquarePrecomputedAssign, ModSub, ModSubAssign, Multifactorial, NegMod, NegModAssign,\n    NegModPowerOf2, NegModPowerOf2Assign, NextPowerOf2, NextPowerOf2Assign, Primorial,\n    RootAssignRem, RootRem, SqrtAssignRem, SqrtRem, Subfactorial, XMulYToZZ, XXAddYYToZZ,\n    XXDivModYToQR, XXSubYYToZZ, XXXAddYYYToZZZ, XXXSubYYYToZZZ, XXXXAddYYYYToZZZZ,\n};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::conversion::traits::{\n    Digits, FromOtherTypeSlice, IntegerMantissaAndExponent, PowerOf2DigitIterable, PowerOf2Digits,\n    SciMantissaAndExponent, VecFromOtherType, VecFromOtherTypeSlice,\n};\nuse crate::num::factorization::primes::{PrimesIterator, PrimesLessThanIterator};\nuse crate::num::factorization::traits::Primes;\nuse crate::num::logic::traits::{BitBlockAccess, HammingDistance};\n\n/// Defines functions on primitive unsigned integer types: uxx and usize.\npub trait PrimitiveUnsigned:\n    AbsDiff<Self, Output = Self>\n    + AbsDiffAssign<Self>\n    + BitBlockAccess<Bits = Self>\n    + CeilingLogBase<Output = u64>\n    + CeilingLogBase2<Output = u64>\n    + CeilingLogBasePowerOf2<u64, Output = u64>\n    + CeilingDivAssignNegMod<Self, ModOutput = Self>\n    + CeilingDivNegMod<Self, DivOutput = Self, ModOutput = Self>\n    + CheckedDoubleFactorial\n    + CheckedFactorial\n    + CheckedMultifactorial\n    + CheckedPrimorial\n    + CheckedSubfactorial\n    + CheckedLcm<Self, Output = Self>\n    + CheckedLogBase<Output = u64>\n    + CheckedLogBase2<Output = u64>\n    + CheckedLogBasePowerOf2<u64, Output = u64>\n    + CheckedNextPowerOf2<Output = Self>\n    + CoprimeWith<Self>\n    + DoubleFactorial\n    + Digits<u8>\n    + Digits<u16>\n    + Digits<u32>\n    + Digits<u64>\n    + Digits<u128>\n    + Digits<usize>\n    + ExtendedGcd<Self, Gcd = Self>\n    + Factorial\n    + FloorLogBase<Output = u64>\n    + FloorLogBase2<Output = u64>\n    + FloorLogBasePowerOf2<u64, Output = u64>\n    + From<u8>\n    + FromOtherTypeSlice<u8>\n    + FromOtherTypeSlice<u16>\n    + FromOtherTypeSlice<u32>\n    + FromOtherTypeSlice<u64>\n    + FromOtherTypeSlice<u128>\n    + FromOtherTypeSlice<usize>\n    + Gcd<Self, Output = Self>\n    + GcdAssign<Self>\n    + HammingDistance\n    + IntegerMantissaAndExponent<Self, u64>\n    + IsPowerOf2\n    + Lcm<Self, Output = Self>\n    + LcmAssign<Self>\n    + ModIsReduced<Self>\n    + ModAdd<Self, Self, Output = Self>\n    + ModAddAssign<Self, Self>\n    + ModInverse<Self, Output = Self>\n    + ModMul<Self, Self, Output = Self>\n    + ModMulAssign<Self, Self>\n    + ModMulPrecomputed<Self, Self, Output = Self>\n    + ModMulPrecomputedAssign<Self, Self>\n    + ModNeg<Self, Output = Self>\n    + ModNegAssign<Self>\n    + ModPow<u64, Self, Output = Self>\n    + ModPowAssign<u64, Self>\n    + ModPowerOf2<Output = Self>\n    + ModPowerOf2Add<Self, Output = Self>\n    + ModPowerOf2AddAssign<Self>\n    + ModPowerOf2Inverse<Output = Self>\n    + ModPowerOf2IsReduced\n    + ModPowerOf2Mul<Self, Output = Self>\n    + ModPowerOf2MulAssign<Self>\n    + ModPowerOf2Neg<Output = Self>\n    + ModPowerOf2NegAssign\n    + ModPowerOf2Pow<u64, Output = Self>\n    + ModPowerOf2PowAssign<u64>\n    + ModPowerOf2Shl<i8, Output = Self>\n    + ModPowerOf2Shl<i16, Output = Self>\n    + ModPowerOf2Shl<i32, Output = Self>\n    + ModPowerOf2Shl<i64, Output = Self>\n    + ModPowerOf2Shl<i128, Output = Self>\n    + ModPowerOf2Shl<u8, Output = Self>\n    + ModPowerOf2Shl<u16, Output = Self>\n    + ModPowerOf2Shl<u32, Output = Self>\n    + ModPowerOf2Shl<u64, Output = Self>\n    + ModPowerOf2Shl<u128, Output = Self>\n    + ModPowerOf2ShlAssign<u8>\n    + ModPowerOf2ShlAssign<u16>\n    + ModPowerOf2ShlAssign<u32>\n    + ModPowerOf2ShlAssign<u64>\n    + ModPowerOf2ShlAssign<u128>\n    + ModPowerOf2ShlAssign<usize>\n    + ModPowerOf2ShlAssign<i8>\n    + ModPowerOf2ShlAssign<i16>\n    + ModPowerOf2ShlAssign<i32>\n    + ModPowerOf2ShlAssign<i64>\n    + ModPowerOf2ShlAssign<i128>\n    + ModPowerOf2ShlAssign<isize>\n    + ModPowerOf2Shr<i8, Output = Self>\n    + ModPowerOf2Shr<i16, Output = Self>\n    + ModPowerOf2Shr<i32, Output = Self>\n    + ModPowerOf2Shr<i64, Output = Self>\n    + ModPowerOf2Shr<i128, Output = Self>\n    + ModPowerOf2ShrAssign<i8>\n    + ModPowerOf2ShrAssign<i16>\n    + ModPowerOf2ShrAssign<i32>\n    + ModPowerOf2ShrAssign<i64>\n    + ModPowerOf2ShrAssign<i128>\n    + ModPowerOf2ShrAssign<isize>\n    + ModPowerOf2Square<Output = Self>\n    + ModPowerOf2SquareAssign\n    + ModPowerOf2Sub<Self, Output = Self>\n    + ModPowerOf2SubAssign<Self>\n    + ModPowPrecomputed<u64, Self, Output = Self>\n    + ModPowPrecomputedAssign<u64, Self>\n    + ModSquare<Self, Output = Self>\n    + ModSquareAssign<Self>\n    + ModSquarePrecomputed<u64, Self, Output = Self>\n    + ModSquarePrecomputedAssign<u64, Self>\n    + ModSub<Self, Self, Output = Self>\n    + ModSubAssign<Self, Self>\n    + Multifactorial\n    + NegMod<Self, Output = Self>\n    + NegModAssign<Self>\n    + NegModPowerOf2<Output = Self>\n    + NegModPowerOf2Assign\n    + NextPowerOf2<Output = Self>\n    + NextPowerOf2Assign\n    + PowerOf2Digits<u8>\n    + PowerOf2Digits<u16>\n    + PowerOf2Digits<u32>\n    + PowerOf2Digits<u64>\n    + PowerOf2Digits<u128>\n    + PowerOf2Digits<usize>\n    + PowerOf2DigitIterable<u8>\n    + PowerOf2DigitIterable<u16>\n    + PowerOf2DigitIterable<u32>\n    + PowerOf2DigitIterable<u64>\n    + PowerOf2DigitIterable<u128>\n    + PowerOf2DigitIterable<usize>\n    + Primes<I = PrimesIterator<Self>, LI = PrimesLessThanIterator<Self>>\n    + PrimitiveInt\n    + Primorial\n    + RootRem<u64, RootOutput = Self, RemOutput = Self>\n    + RootAssignRem<u64, RemOutput = Self>\n    + SciMantissaAndExponent<f32, u64>\n    + SciMantissaAndExponent<f64, u64>\n    + SqrtRem<SqrtOutput = Self, RemOutput = Self>\n    + SqrtAssignRem<RemOutput = Self>\n    + Subfactorial\n    + VecFromOtherType<u8>\n    + VecFromOtherType<u16>\n    + VecFromOtherType<u32>\n    + VecFromOtherType<u64>\n    + VecFromOtherType<u128>\n    + VecFromOtherType<usize>\n    + VecFromOtherTypeSlice<u8>\n    + VecFromOtherTypeSlice<u16>\n    + VecFromOtherTypeSlice<u32>\n    + VecFromOtherTypeSlice<u64>\n    + VecFromOtherTypeSlice<u128>\n    + VecFromOtherTypeSlice<usize>\n    + XXAddYYToZZ\n    + XXDivModYToQR\n    + XXSubYYToZZ\n    + XMulYToZZ\n    + XXXAddYYYToZZZ\n    + XXXSubYYYToZZZ\n    + XXXXAddYYYYToZZZZ\n{\n}\n\nmacro_rules! impl_basic_traits {\n    ($u:ident) => {\n        impl PrimitiveUnsigned for $u {}\n    };\n}\napply_to_unsigneds!(impl_basic_traits);\n"
  },
  {
    "path": "malachite-base/src/num/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::UnsignedAbs;\nuse crate::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse core::cmp::Ordering;\n\nmacro_rules! impl_partial_ord_abs {\n    ($t:ident) => {\n        impl PartialOrdAbs<$t> for $t {\n            /// Compares the absolute values of two numbers, taking both by reference.\n            ///\n            /// The [`PartialOrdAbs`] interface allows for pairs of incomparable elements, but for\n            /// primitive integers these never occur.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::cmp_abs#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                Some(self.cmp_abs(other))\n            }\n        }\n    };\n}\napply_to_signeds!(impl_partial_ord_abs);\n\nfn cmp_abs_signed<U: Ord, S: Copy + UnsignedAbs<Output = U>>(x: &S, y: &S) -> Ordering {\n    x.unsigned_abs().cmp(&y.unsigned_abs())\n}\n\nmacro_rules! impl_ord_abs_signed {\n    ($t:ident) => {\n        impl OrdAbs for $t {\n            /// Compares the absolute values of two numbers, taking both by reference.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::cmp_abs#cmp_abs).\n            #[inline]\n            fn cmp_abs(&self, other: &Self) -> Ordering {\n                cmp_abs_signed(self, other)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_ord_abs_signed);\n\nmacro_rules! impl_ord_abs_primitive_float {\n    ($t:ident) => {\n        impl PartialOrdAbs for $t {\n            /// Compares the absolute values of two numbers, taking both by reference.\n            ///\n            /// For unsigned values, this is the same as ordinary comparison.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::cmp_abs#cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Self) -> Option<Ordering> {\n                self.abs().partial_cmp(&other.abs())\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_ord_abs_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::comparison::traits::EqAbs;\n\nmacro_rules! impl_eq_abs_signed {\n    ($t:ident) => {\n        impl EqAbs<$t> for $t {\n            /// Compares the absolute values of two numbers for equality, taking both by reference.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::eq_abs#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Self) -> bool {\n                self.unsigned_abs() == other.unsigned_abs()\n            }\n        }\n    };\n}\napply_to_signeds!(impl_eq_abs_signed);\n\nmacro_rules! impl_eq_abs_float {\n    ($t:ident) => {\n        impl EqAbs<$t> for $t {\n            /// Compares the absolute values of two numbers for equality, taking both by reference.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::eq_abs#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Self) -> bool {\n                self.abs() == other.abs()\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_eq_abs_float);\n"
  },
  {
    "path": "malachite-base/src/num/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// [`PartialOrdAbs`](`traits::PartialOrdAbs`) and [`OrdAbs`](`traits::OrdAbs`), traits for\n/// comparing the absolute values of numbers by order.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(123i32.partial_cmp_abs(&-456), Some(Less));\n/// assert_eq!(123i32.partial_cmp_abs(&-123), Some(Equal));\n/// ```\n///\n/// # cmp_abs\n/// ```\n/// use malachite_base::num::comparison::traits::OrdAbs;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(123i32.cmp_abs(&-456), Less);\n/// assert_eq!(123i32.cmp_abs(&-123), Equal);\n/// ```\npub mod cmp_abs;\n/// [`EqAbs`](`traits::EqAbs`), a trait for comparing the absolute values of numbers by equality.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::comparison::traits::EqAbs;\n///\n/// assert_eq!(123i32.eq_abs(&-456), false);\n/// assert_eq!(123i32.eq_abs(&-123), true);\n/// assert_eq!(1.0.eq_abs(&-1.0), true);\n/// assert_eq!(1.0.eq_abs(&f64::NAN), false);\n/// ```\npub mod eq_abs;\n/// Various traits for comparing numbers.\npub mod traits;\n"
  },
  {
    "path": "malachite-base/src/num/comparison/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\n\n/// Determines equality between the absolute values of two numbers.\npub trait EqAbs<Rhs: ?Sized = Self> {\n    /// Compares the absolute values of two numbers for equality, taking both by reference.\n    fn eq_abs(&self, other: &Rhs) -> bool;\n\n    /// Compares the absolute values of two numbers for inequality, taking both by reference.\n    ///\n    /// # Worst-case complexity\n    /// Same as the time and additional memory complexity of [`eq_abs`](Self::eq_abs).\n    #[inline]\n    fn ne_abs(&self, other: &Rhs) -> bool {\n        !self.eq_abs(other)\n    }\n}\n\n/// Determines equality between the absolute values of two numbers, where some pairs of numbers may\n/// not be comparable.\npub trait PartialOrdAbs<Rhs: ?Sized = Self> {\n    /// Compares the absolute values of two numbers, taking both by reference.\n    ///\n    /// If the two values are not comparable, `None` is returned.\n    fn partial_cmp_abs(&self, other: &Rhs) -> Option<Ordering>;\n\n    /// Determines whether the absolute value of one number is less than the absolute value of\n    /// another.\n    ///\n    /// # Worst-case complexity\n    /// Same as the time and additional memory complexity of\n    /// [`partial_cmp_abs`](Self::partial_cmp_abs).\n    #[inline]\n    fn lt_abs(&self, other: &Rhs) -> bool {\n        matches!(self.partial_cmp_abs(other), Some(Less))\n    }\n\n    /// Determines whether the absolute value of one number is less than or equal to the absolute\n    /// value of another.\n    ///\n    /// # Worst-case complexity\n    /// Same as the time and additional memory complexity of\n    /// [`partial_cmp_abs`](Self::partial_cmp_abs).\n    #[inline]\n    fn le_abs(&self, other: &Rhs) -> bool {\n        matches!(self.partial_cmp_abs(other), Some(Less | Equal))\n    }\n\n    /// Determines whether the absolute value of one number is greater than the absolute value of\n    /// another.\n    ///\n    /// # Worst-case complexity\n    /// Same as the time and additional memory complexity of\n    /// [`partial_cmp_abs`](Self::partial_cmp_abs).\n    #[inline]\n    fn gt_abs(&self, other: &Rhs) -> bool {\n        matches!(self.partial_cmp_abs(other), Some(Greater))\n    }\n\n    /// Determines whether the absolute value of one number is greater than or equal to the absolute\n    /// value of another.\n    ///\n    /// # Worst-case complexity\n    /// Same as the time and additional memory complexity of\n    /// [`partial_cmp_abs`](Self::partial_cmp_abs).\n    #[inline]\n    fn ge_abs(&self, other: &Rhs) -> bool {\n        matches!(self.partial_cmp_abs(other), Some(Greater | Equal))\n    }\n}\n\n/// Compares the absolute values of two numbers.\npub trait OrdAbs: Eq + PartialOrdAbs<Self> {\n    fn cmp_abs(&self, other: &Self) -> Ordering;\n}\n"
  },
  {
    "path": "malachite-base/src/num/conversion/digits/general_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, PowerOf2Digits, WrappingFrom,\n};\nuse alloc::vec::Vec;\nuse itertools::Itertools;\n\npub_test! {unsigned_to_digits_asc_naive<\n    T: ExactFrom<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<T>,\n>(\n    x: &T,\n    base: U,\n) -> Vec<U> {\n    assert!(base > U::ONE);\n    let mut digits = Vec::new();\n    let mut remainder = *x;\n    let base = T::exact_from(base);\n    while remainder != T::ZERO {\n        digits.push(U::wrapping_from(remainder.div_assign_mod(base)));\n    }\n    digits\n}}\n\nfn to_digits_asc<\n    T: ConvertibleFrom<U> + ExactFrom<U> + PrimitiveUnsigned + PowerOf2Digits<U>,\n    U: PrimitiveUnsigned + WrappingFrom<T>,\n>(\n    x: &T,\n    base: &U,\n) -> Vec<U> {\n    assert!(T::convertible_from(*base));\n    if *x == T::ZERO {\n        Vec::new()\n    } else if let Some(log_base) = base.checked_log_base_2() {\n        x.to_power_of_2_digits_asc(log_base)\n    } else {\n        unsigned_to_digits_asc_naive(x, *base)\n    }\n}\n\nfn to_digits_desc<\n    T: ConvertibleFrom<U> + ExactFrom<U> + PrimitiveUnsigned + PowerOf2Digits<U>,\n    U: PrimitiveUnsigned + WrappingFrom<T>,\n>(\n    x: &T,\n    base: &U,\n) -> Vec<U> {\n    assert!(T::convertible_from(*base));\n    if *x == T::ZERO {\n        Vec::new()\n    } else if let Some(log_base) = base.checked_log_base_2() {\n        x.to_power_of_2_digits_desc(log_base)\n    } else {\n        let mut digits = unsigned_to_digits_asc_naive(x, *base);\n        digits.reverse();\n        digits\n    }\n}\n\nfn from_digits_asc<\n    T: Digits<U> + PowerOf2Digits<U>,\n    U: PrimitiveUnsigned,\n    I: Iterator<Item = U>,\n>(\n    base: &U,\n    digits: I,\n) -> Option<T> {\n    if let Some(log_base) = base.checked_log_base_2() {\n        T::from_power_of_2_digits_asc(log_base, digits)\n    } else {\n        let mut digits = digits.collect_vec();\n        digits.reverse();\n        T::from_digits_desc(base, digits.into_iter())\n    }\n}\n\nfn from_digits_desc<\n    T: Digits<U> + TryFrom<U> + PrimitiveUnsigned + PowerOf2Digits<U>,\n    U: PrimitiveUnsigned,\n    I: Iterator<Item = U>,\n>(\n    base: &U,\n    digits: I,\n) -> Option<T> {\n    assert!(*base > U::ONE);\n    if let Some(log_base) = base.checked_log_base_2() {\n        T::from_power_of_2_digits_desc(log_base, digits)\n    } else {\n        let base = T::try_from(*base).ok()?;\n        let mut x = T::ZERO;\n        for digit in digits {\n            let digit = T::try_from(digit).ok()?;\n            if digit >= base {\n                return None;\n            }\n            x = x.checked_mul(base)?.checked_add(digit)?;\n        }\n        Some(x)\n    }\n}\n\nmacro_rules! impl_digits {\n    ($t:ident) => {\n        macro_rules! impl_digits_inner {\n            ($u:ident) => {\n                impl Digits<$u> for $t {\n                    /// Returns a [`Vec`] containing the digits of a number in ascending order\n                    /// (least- to most-significant).\n                    ///\n                    /// The base must be convertible to `Self`. If `self` is 0, the [`Vec`] is\n                    /// empty; otherwise, it ends with a nonzero digit.\n                    ///\n                    /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or\n                    /// $d_{k-1} \\neq 0$, and\n                    ///\n                    /// $$\n                    /// \\sum_{i=0}^{k-1}b^i d_i = x.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(n)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `self.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `base` is less than 2 or greater than `Self::MAX`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::general_digits#to_digits_asc).\n                    #[inline]\n                    fn to_digits_asc(&self, base: &$u) -> Vec<$u> {\n                        to_digits_asc(self, base)\n                    }\n\n                    /// Returns a [`Vec`] containing the digits of a number in descending order\n                    /// (most- to least-significant).\n                    ///\n                    /// The base must be convertible to `Self`. If `self` is 0, the [`Vec`] is\n                    /// empty; otherwise, it begins with a nonzero digit.\n                    ///\n                    /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or\n                    /// $d_{k-1} \\neq 0$, and\n                    ///\n                    /// $$\n                    /// \\sum_{i=0}^{k-1}b^i d_{k-i-1} = x.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(n)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `self.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `base` is less than 2 or greater than `$t::MAX`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::general_digits#to_digits_desc).\n                    #[inline]\n                    fn to_digits_desc(&self, base: &$u) -> Vec<$u> {\n                        to_digits_desc(self, base)\n                    }\n\n                    /// Converts an iterator of digits into a value.\n                    ///\n                    /// The input digits are in ascending order (least- to most-significant). The\n                    /// base must be no larger than `Self::MAX`. The function returns `None` if the\n                    /// input represents a number that can't fit in `Self`, if `base` is greater\n                    /// than `Self::MAX`, or if any of the digits are greater than or equal to the\n                    /// base.\n                    ///\n                    /// $$\n                    /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^id_i.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `base` is less than 2.\n                    ///\n                    /// # Examples\n                    /// See [here](super::general_digits#from_digits_asc).\n                    #[inline]\n                    fn from_digits_asc<I: Iterator<Item = $u>>(base: &$u, digits: I) -> Option<$t> {\n                        from_digits_asc(base, digits)\n                    }\n\n                    /// Converts an iterator of digits into a value.\n                    ///\n                    /// The input digits are in descending order (most- to least-significant). The\n                    /// base must be no larger than `Self::MAX`. The function returns `None` if the\n                    /// input represents a number that can't fit in `Self`, if `base` is greater\n                    /// than `Self::MAX`, or if any of the digits are greater than or equal to the\n                    /// base.\n                    ///\n                    /// $$\n                    /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^{k-i-1}d_i.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `base` is less than 2.\n                    ///\n                    /// # Examples\n                    /// See [here](super::general_digits#from_digits_desc).\n                    #[inline]\n                    fn from_digits_desc<I: Iterator<Item = $u>>(\n                        base: &$u,\n                        digits: I,\n                    ) -> Option<$t> {\n                        from_digits_desc(base, digits)\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_digits_inner);\n    };\n}\napply_to_unsigneds!(impl_digits);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// [`Digits`](super::traits::Digits), a trait for extracting digits from numbers and constructing\n/// numbers from digits.\n///\n/// # to_digits_asc\n/// ```\n/// use malachite_base::num::conversion::traits::Digits;\n///\n/// assert_eq!(0u8.to_digits_asc(&6u64), &[]);\n/// assert_eq!(2u16.to_digits_asc(&6u32), &[2]);\n/// assert_eq!(\n///     123456u32.to_digits_asc(&3u16),\n///     &[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2]\n/// );\n/// ```\n///\n/// # to_digits_desc\n/// ```\n/// use malachite_base::num::conversion::traits::Digits;\n///\n/// assert_eq!(0u8.to_digits_asc(&6u64), &[]);\n/// assert_eq!(2u16.to_digits_asc(&6u32), &[2]);\n/// assert_eq!(\n///     123456u32.to_digits_desc(&3u16),\n///     &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0]\n/// );\n/// ```\n///\n/// # from_digits_asc\n/// ```\n/// use malachite_base::num::conversion::traits::Digits;\n///\n/// assert_eq!(\n///     u8::from_digits_asc(&64, [0u64, 0, 0].iter().cloned()),\n///     Some(0)\n/// );\n/// assert_eq!(\n///     u32::from_digits_asc(&3, [0u64, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2].iter().cloned()),\n///     Some(123456)\n/// );\n/// assert_eq!(\n///     u32::from_digits_asc(&8, [3u16, 7, 1].iter().cloned()),\n///     Some(123)\n/// );\n///\n/// assert!(u64::from_digits_asc(&64, [1u8; 1000].iter().cloned()).is_none());\n/// assert!(u64::from_digits_asc(&2, [2u8].iter().cloned()).is_none());\n/// assert!(u8::from_digits_asc(&1000, [1u16, 2, 3].iter().cloned()).is_none());\n/// ```\n///\n/// # from_digits_desc\n/// ```\n/// use malachite_base::num::conversion::traits::Digits;\n///\n/// assert_eq!(\n///     u8::from_digits_desc(&64, [0u64, 0, 0].iter().cloned()),\n///     Some(0)\n/// );\n/// assert_eq!(\n///     u32::from_digits_desc(&3, [2u64, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0].iter().cloned()),\n///     Some(123456)\n/// );\n/// assert_eq!(\n///     u32::from_digits_desc(&8, [1u16, 7, 3].iter().cloned()),\n///     Some(123)\n/// );\n///\n/// assert!(u64::from_digits_desc(&64, [1u8; 1000].iter().cloned()).is_none());\n/// assert!(u64::from_digits_desc(&2, [2u8].iter().cloned()).is_none());\n/// assert!(u8::from_digits_desc(&1000, [1u16, 2, 3].iter().cloned()).is_none());\n/// ```\npub mod general_digits;\n/// [`PowerOf2DigitIterable`](super::traits::PowerOf2DigitIterable), a trait for producing\n/// [`PrimitivePowerOf2DigitIterator`](power_of_2_digit_iterable::PrimitivePowerOf2DigitIterator), a\n/// double-ended iterator for iterating over a number's base-$2^k$ digits.\n///\n/// # power_of_2_digits\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::conversion::traits::PowerOf2DigitIterable;\n///\n/// let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(0u8, 2);\n/// assert!(digits.next().is_none());\n///\n/// // 107 = 1101011b\n/// let digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(107u32, 2);\n/// assert_eq!(digits.collect_vec(), &[3, 2, 2, 1]);\n///\n/// let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(0u8, 2);\n/// assert!(digits.next_back().is_none());\n///\n/// // 107 = 1101011b\n/// let digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(107u32, 2);\n/// assert_eq!(digits.rev().collect_vec(), &[1, 2, 2, 3]);\n/// ```\npub mod power_of_2_digit_iterable;\n/// [`PowerOf2Digits`](super::traits::PowerOf2Digits), a trait for extracting base-$2^k$ $digits\n/// from numbers and constructing numbers from digits.\n///\n/// # to_power_of_2_digits_asc\n/// ```\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n///\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&0u8, 6),\n///     &[]\n/// );\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&2u16, 6),\n///     &[2]\n/// );\n/// // 123_10 = 173_8\n/// assert_eq!(\n///     PowerOf2Digits::<u16>::to_power_of_2_digits_asc(&123u32, 3),\n///     &[3, 7, 1]\n/// );\n/// ```\n///\n/// # to_power_of_2_digits_desc\n/// ```\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n///\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_desc(&0u8, 6),\n///     &[]\n/// );\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_desc(&2u16, 6),\n///     &[2]\n/// );\n/// // 123_10 = 173_8\n/// assert_eq!(\n///     PowerOf2Digits::<u16>::to_power_of_2_digits_desc(&123u32, 3),\n///     &[1, 7, 3]\n/// );\n/// ```\n///\n/// # from_power_of_2_digits_asc\n/// ```\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n///\n/// assert_eq!(\n///     u8::from_power_of_2_digits_asc(6, [0u64, 0, 0].iter().cloned()),\n///     Some(0)\n/// );\n/// assert_eq!(\n///     u16::from_power_of_2_digits_asc(6, [2u64, 0].iter().cloned()),\n///     Some(2)\n/// );\n/// assert_eq!(\n///     u32::from_power_of_2_digits_asc(3, [3u16, 7, 1].iter().cloned()),\n///     Some(123)\n/// );\n///\n/// assert!(u8::from_power_of_2_digits_asc(4, [1u64; 100].iter().cloned()).is_none());\n/// assert!(u8::from_power_of_2_digits_asc(1, [2u64].iter().cloned()).is_none());\n/// ```\n///\n/// # from_power_of_2_digits_desc\n/// ```\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n///\n/// assert_eq!(\n///     u8::from_power_of_2_digits_desc(6, [0u64, 0, 0].iter().cloned()),\n///     Some(0)\n/// );\n/// assert_eq!(\n///     u16::from_power_of_2_digits_desc(6, [0u64, 2].iter().cloned()),\n///     Some(2)\n/// );\n/// assert_eq!(\n///     u32::from_power_of_2_digits_desc(3, [1u16, 7, 3].iter().cloned()),\n///     Some(123)\n/// );\n///\n/// assert!(u8::from_power_of_2_digits_desc(4, [1u64; 100].iter().cloned()).is_none());\n/// assert!(u8::from_power_of_2_digits_desc(1, [2u64].iter().cloned()).is_none());\n/// ```\npub mod power_of_2_digits;\n"
  },
  {
    "path": "malachite-base/src/num/conversion/digits/power_of_2_digit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{DivRound, SaturatingSubAssign};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{\n    ExactFrom, PowerOf2DigitIterable, PowerOf2DigitIterator, WrappingFrom,\n};\nuse crate::num::logic::traits::BitBlockAccess;\nuse crate::rounding_modes::RoundingMode::*;\nuse core::marker::PhantomData;\n\n/// A double-ended iterator over the base-$2^k$ digits of an unsigned primitive integer.\n///\n/// This `struct` is created by the [`PowerOf2DigitIterable::power_of_2_digits`] function. See its\n/// documentation for more.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct PrimitivePowerOf2DigitIterator<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    pub(crate) value: T,\n    pub(crate) log_base: u64,\n    pub(crate) remaining: usize,\n    // If `n` is nonzero, this index initially points to the least-significant bit of the least-\n    // significant digit, and is left-shifted by `next`.\n    pub(crate) i: u64,\n    // If `n` is nonzero, this mask initially points to the least-significant bit of the most-\n    // significant nonzero digit, and is right-shifted by `next_back`.\n    pub(crate) j: u64,\n    phantom: PhantomData<*const U>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<<T as BitBlockAccess>::Bits>>\n    Iterator for PrimitivePowerOf2DigitIterator<T, U>\n{\n    type Item = U;\n\n    fn next(&mut self) -> Option<U> {\n        if self.remaining != 0 {\n            let digit = U::wrapping_from(self.value.get_bits(self.i, self.i + self.log_base));\n            self.i += self.log_base;\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<<T as BitBlockAccess>::Bits>>\n    DoubleEndedIterator for PrimitivePowerOf2DigitIterator<T, U>\n{\n    fn next_back(&mut self) -> Option<U> {\n        if self.remaining != 0 {\n            let digit = U::wrapping_from(self.value.get_bits(self.j, self.j + self.log_base));\n            self.j.saturating_sub_assign(self.log_base);\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<<T as BitBlockAccess>::Bits>>\n    ExactSizeIterator for PrimitivePowerOf2DigitIterator<T, U>\n{\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<<T as BitBlockAccess>::Bits>>\n    PowerOf2DigitIterator<U> for PrimitivePowerOf2DigitIterator<T, U>\n{\n    /// Retrieves base-$2^k$ digits by index.\n    ///\n    /// Indexing at or above the significant digit count returns zero.\n    ///\n    /// This function doesn't affect, and isn't affected by, the iterator's position.\n    ///\n    /// $f(x, k, i) = d_i$, where $0 \\leq d_i < 2^k$ for all $i$ and\n    /// $$\n    /// \\sum_{i=0}^\\infty2^{ki}d_i = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::{\n    ///     PowerOf2DigitIterable, PowerOf2DigitIterator,\n    /// };\n    ///\n    /// let digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(0u8, 2);\n    /// assert_eq!(digits.get_digit(0), 0);\n    ///\n    /// // 107 = 1101011b\n    /// let digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(107u32, 2);\n    /// assert_eq!(digits.get_digit(0), 3);\n    /// assert_eq!(digits.get_digit(1), 2);\n    /// assert_eq!(digits.get_digit(2), 2);\n    /// assert_eq!(digits.get_digit(100), 0);\n    /// ```\n    fn get_digit(&self, index: u64) -> U {\n        let i = index * self.log_base;\n        U::wrapping_from(self.value.get_bits(i, i + self.log_base))\n    }\n}\n\nfn power_of_2_digits<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    x: T,\n    log_base: u64,\n) -> PrimitivePowerOf2DigitIterator<T, U> {\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= U::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        U::NAME,\n        log_base\n    );\n    let significant_digits = x.significant_bits().div_round(log_base, Ceiling).0;\n    PrimitivePowerOf2DigitIterator {\n        value: x,\n        log_base,\n        remaining: usize::exact_from(significant_digits),\n        i: 0,\n        j: significant_digits.saturating_sub(1) * log_base,\n        phantom: PhantomData,\n    }\n}\n\nmacro_rules! impl_power_of_2_digit_iterable {\n    ($t:ident) => {\n        macro_rules! impl_power_of_2_digit_iterable_inner {\n            ($u:ident) => {\n                impl PowerOf2DigitIterable<$u> for $t {\n                    type PowerOf2DigitIterator = PrimitivePowerOf2DigitIterator<$t, $u>;\n\n                    /// Returns a double-ended iterator over the base-$2^k$ digits of a primitive\n                    /// unsigned integer.\n                    ///\n                    /// The forward order is ascending, so that less-significant digits appear\n                    /// first. There are no trailing zeros going forward, or leading zeros going\n                    /// backward.\n                    ///\n                    /// If it's necessary to get a [`Vec`] of all the digits, consider using\n                    /// [`to_power_of_2_digits_asc`](super::super::traits::PowerOf2Digits::to_power_of_2_digits_asc)\n                    /// or\n                    /// [`to_power_of_2_digits_desc`](super::super::traits::PowerOf2Digits::to_power_of_2_digits_desc)\n                    /// instead.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `log_base` is larger than the width of output type width.\n                    ///\n                    /// # Examples\n                    /// See [here](super::power_of_2_digit_iterable#power_of_2_digits).\n                    #[inline]\n                    fn power_of_2_digits(\n                        self,\n                        log_base: u64,\n                    ) -> PrimitivePowerOf2DigitIterator<$t, $u> {\n                        power_of_2_digits(self, log_base)\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_power_of_2_digit_iterable_inner);\n    };\n}\napply_to_unsigneds!(impl_power_of_2_digit_iterable);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/digits/power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{PowerOf2Digits, WrappingFrom};\nuse alloc::vec::Vec;\n\nfn to_power_of_2_digits_asc<T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<T>>(\n    x: &T,\n    log_base: u64,\n) -> Vec<U> {\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= U::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        U::NAME,\n        log_base\n    );\n    let mut digits = Vec::new();\n    if *x == T::ZERO {\n    } else if x.significant_bits() <= log_base {\n        digits.push(U::wrapping_from(*x));\n    } else {\n        let mut x = *x;\n        let mask = U::low_mask(log_base);\n        while x != T::ZERO {\n            digits.push(U::wrapping_from(x) & mask);\n            x >>= log_base;\n        }\n    }\n    digits\n}\n\nfn to_power_of_2_digits_desc<T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<T>>(\n    x: &T,\n    log_base: u64,\n) -> Vec<U> {\n    let mut digits = to_power_of_2_digits_asc(x, log_base);\n    digits.reverse();\n    digits\n}\n\nfn from_power_of_2_digits_asc<\n    T: TryFrom<U> + PrimitiveUnsigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned,\n    I: Iterator<Item = U>,\n>(\n    log_base: u64,\n    digits: I,\n) -> Option<T> {\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= U::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        U::NAME,\n        log_base\n    );\n    let mut n = T::ZERO;\n    let mut shift = 0;\n    for digit in digits {\n        if digit.significant_bits() > log_base {\n            return None;\n        }\n        n |= T::try_from(digit)\n            .ok()\n            .and_then(|d| d.arithmetic_checked_shl(shift))?;\n        shift += log_base;\n    }\n    Some(n)\n}\n\nfn from_power_of_2_digits_desc<\n    T: PrimitiveUnsigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned,\n    I: Iterator<Item = U>,\n>(\n    log_base: u64,\n    digits: I,\n) -> Option<T> {\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= U::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        U::NAME,\n        log_base\n    );\n    let mut n = T::ZERO;\n    for digit in digits {\n        if digit.significant_bits() > log_base {\n            return None;\n        }\n        let shifted = n.arithmetic_checked_shl(log_base)?;\n        n = shifted | T::wrapping_from(digit);\n    }\n    Some(n)\n}\n\nmacro_rules! impl_power_of_2_digits {\n    ($t:ident) => {\n        macro_rules! impl_power_of_2_digits_inner {\n            ($u:ident) => {\n                impl PowerOf2Digits<$u> for $t {\n                    /// Returns a [`Vec`] containing the base-$2^k$ digits of a number in ascending\n                    /// order (least- to most-significant).\n                    ///\n                    /// The base-2 logarithm of the base is specified. `log_base` must be no larger\n                    /// than the width of the digit type. If `self` is 0, the [`Vec`] is empty;\n                    /// otherwise, it ends with a nonzero digit.\n                    ///\n                    /// $f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \\leq d_i < 2^k$ for all $i$, $n=0$\n                    /// or $d_{n-1} \\neq 0$, and\n                    ///\n                    /// $$\n                    /// \\sum_{i=0}^{n-1}2^{ki}d_i = x.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(n)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `self.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `log_base` is greater than the width of the output type, or if\n                    /// `log_base` is zero.\n                    ///\n                    /// # Examples\n                    /// See [here](super::power_of_2_digits#to_power_of_2_digits_asc).\n                    #[inline]\n                    fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<$u> {\n                        to_power_of_2_digits_asc(self, log_base)\n                    }\n\n                    /// Returns a [`Vec`] containing the base-$2^k$ digits of a number in descending\n                    /// order (most- to least-significant).\n                    ///\n                    /// The base-2 logarithm of the base is specified. `log_base` must be no larger\n                    /// than the width of the digit type. If `self` is 0, the [`Vec`] is empty;\n                    /// otherwise, it begins with a nonzero digit.\n                    ///\n                    /// $f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \\leq d_i < 2^k$ for all $i$, $n=0$\n                    /// or $d_0 \\neq 0$, and\n                    ///\n                    /// $$\n                    /// \\sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(n)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is\n                    /// `self.significant_bits()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `log_base` is greater than the width of the output type, or if\n                    /// `log_base` is zero.\n                    ///\n                    /// # Examples\n                    /// See [here](super::power_of_2_digits#to_power_of_2_digits_desc).\n                    #[inline]\n                    fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<$u> {\n                        to_power_of_2_digits_desc(self, log_base)\n                    }\n\n                    /// Converts an iterator of base-$2^k$ digits into a value.\n                    ///\n                    /// The base-2 logarithm of the base is specified. The input digits are in\n                    /// ascending order (least- to most-significant). `log_base` must be no larger\n                    /// than the width of the digit type. The function returns `None` if the input\n                    /// represents a number that can't fit in the output type.\n                    ///\n                    /// $$\n                    /// f((d_i)_ {i=0}^{n-1}, k) = \\sum_{i=0}^{n-1}2^{ki}d_i.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `log_base` is greater than the width of the digit type, or if\n                    /// `log_base` is zero.\n                    ///\n                    /// # Examples\n                    /// See [here](super::power_of_2_digits#from_power_of_2_digits_asc).\n                    #[inline]\n                    fn from_power_of_2_digits_asc<I: Iterator<Item = $u>>(\n                        log_base: u64,\n                        digits: I,\n                    ) -> Option<$t> {\n                        from_power_of_2_digits_asc(log_base, digits)\n                    }\n\n                    /// Converts an iterator of base-$2^k$ digits into a value.\n                    ///\n                    /// The base-2 logarithm of the base is specified. The input digits are in\n                    /// descending order (most- to least-significant). `log_base` must be no larger\n                    /// than the width of the digit type. The function returns `None` if the input\n                    /// represents a number that can't fit in the output type.\n                    ///\n                    /// $$\n                    /// f((d_i)_ {i=0}^{n-1}, k) = \\sum_{i=0}^{n-1}2^{k (n-i-1)}d_i.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// $T(n) = O(n)$\n                    ///\n                    /// $M(n) = O(1)$\n                    ///\n                    /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n                    ///\n                    /// # Panics\n                    /// Panics if `log_base` is greater than the width of the digit type, or if\n                    /// `log_base` is zero.\n                    ///\n                    /// # Examples\n                    /// See [here](super::power_of_2_digits#from_power_of_2_digits_desc).\n                    fn from_power_of_2_digits_desc<I: Iterator<Item = $u>>(\n                        log_base: u64,\n                        digits: I,\n                    ) -> Option<$t> {\n                        from_power_of_2_digits_desc(log_base, digits)\n                    }\n                }\n            };\n        }\n        apply_to_unsigneds!(impl_power_of_2_digits_inner);\n    };\n}\napply_to_unsigneds!(impl_power_of_2_digits);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ShrRoundAssign, UnsignedAbs};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::mantissa_and_exponent::sci_mantissa_and_exponent_round;\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, OverflowingFrom, RoundingFrom, SaturatingFrom, SciMantissaAndExponent,\n    WrappingFrom,\n};\nuse crate::num::float::NiceFloat;\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse core::cmp::Ordering::{self, *};\nuse core::ops::Neg;\n\n// This macro defines conversions from a type to itself.\nmacro_rules! identity_conversion {\n    ($t:ty) => {\n        impl WrappingFrom<$t> for $t {\n            /// Converts a value to its own type. This conversion is always valid and always leaves\n            /// the value unchanged.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: $t) -> $t {\n                value\n            }\n        }\n\n        impl SaturatingFrom<$t> for $t {\n            /// Converts a value to its own type. This conversion is always valid and always leaves\n            /// the value unchanged.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#saturating_from).\n            #[inline]\n            fn saturating_from(value: $t) -> $t {\n                value\n            }\n        }\n\n        impl OverflowingFrom<$t> for $t {\n            /// Converts a value to its own type. Since this conversion is always valid and always\n            /// leaves the value unchanged, the second component of the result is always false (no\n            /// overflow).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#overflowing_from).\n            #[inline]\n            fn overflowing_from(value: $t) -> ($t, bool) {\n                (value, false)\n            }\n        }\n\n        impl ConvertibleFrom<$t> for $t {\n            /// Checks whether a value is convertible to its own type. The result is always `true`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#convertible_from).\n            #[inline]\n            fn convertible_from(_: $t) -> bool {\n                true\n            }\n        }\n    };\n}\n\n// This macro defines conversions from type $a to type $b, where every value of type $a is\n// representable by a value of type $b.\nmacro_rules! lossless_conversion {\n    ($a:ty, $b:ident) => {\n        impl WrappingFrom<$a> for $b {\n            /// Converts a value to another type. This conversion is always valid and always leaves\n            /// the value unchanged.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: $a) -> $b {\n                $b::from(value)\n            }\n        }\n\n        impl SaturatingFrom<$a> for $b {\n            /// Converts a value to another type. This conversion is always valid and always leaves\n            /// the value unchanged.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#saturating_from).\n            #[inline]\n            fn saturating_from(value: $a) -> $b {\n                $b::from(value)\n            }\n        }\n\n        impl OverflowingFrom<$a> for $b {\n            /// Converts a value to the value's type. Since this conversion is always valid and\n            /// always leaves the value unchanged, the second component of the result is always\n            /// false (no overflow).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#overflowing_from).\n            #[inline]\n            fn overflowing_from(value: $a) -> ($b, bool) {\n                ($b::from(value), false)\n            }\n        }\n\n        impl ConvertibleFrom<$a> for $b {\n            /// Checks whether a value is convertible to a different type. The result is always\n            /// `true`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#convertible_from).\n            #[inline]\n            fn convertible_from(_: $a) -> bool {\n                true\n            }\n        }\n    };\n}\n\nfn saturating_from_lossy<A: TryFrom<B> + PrimitiveInt, B: PrimitiveInt + WrappingFrom<A>>(\n    value: A,\n) -> B {\n    if let Ok(b_max) = A::try_from(B::MAX)\n        && value >= b_max\n    {\n        return B::MAX;\n    }\n    if let Ok(b_min) = A::try_from(B::MIN)\n        && value <= b_min\n    {\n        return B::MIN;\n    }\n    B::wrapping_from(value)\n}\n\nfn overflowing_from_lossy<A: PrimitiveInt + WrappingFrom<B>, B: PrimitiveInt + WrappingFrom<A>>(\n    value: A,\n) -> (B, bool) {\n    let result = B::wrapping_from(value);\n    (\n        result,\n        (result >= B::ZERO) != (value >= A::ZERO) || A::wrapping_from(result) != value,\n    )\n}\n\nfn convertible_from_lossy<A: PrimitiveInt + WrappingFrom<B>, B: PrimitiveInt + WrappingFrom<A>>(\n    value: A,\n) -> bool {\n    let result = B::wrapping_from(value);\n    (result >= B::ZERO) == (value >= A::ZERO) && A::wrapping_from(result) == value\n}\n\n// This macro defines conversions from type $a to type $b, where not every value of type $a is\n// representable by a value of type $b.\nmacro_rules! lossy_conversion {\n    ($a:ident, $b:ident) => {\n        #[allow(clippy::cast_lossless)]\n        impl WrappingFrom<$a> for $b {\n            /// Converts a value to another type. If the value cannot be represented in the new\n            /// type, it is wrapped.\n            ///\n            /// Let $W$ be the width of the target type.\n            ///\n            /// If the target type is unsigned, then $f_W(n) = m$, where $m < 2^W$ and $n + 2^W k =\n            /// m$ for some $k \\in \\Z$.\n            ///\n            /// If the target type is signed, then $f_W(n) = m$, where $-2^{W-1} \\leq m < 2^{W-1}$\n            /// and $n + 2^W k = m$ for some $k \\in \\Z$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: $a) -> $b {\n                value as $b\n            }\n        }\n\n        impl SaturatingFrom<$a> for $b {\n            /// Converts a value to another type. If the value cannot be represented in the new\n            /// type, the maximum or minimum value of the new type, whichever is closer, is\n            /// returned.\n            ///\n            /// Let $W$ be the width of the target type.\n            ///\n            /// If the target type is unsigned, then\n            /// $$\n            /// f_W(n) = \\\\begin{cases}\n            ///     0 & n < 0 \\\\\\\\\n            ///     2^W-1 & \\text{if} \\\\quad n \\geq 2^W, \\\\\\\\\n            ///     n & \\\\text{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// If the target type is signed, then\n            /// $$\n            /// f_W(n) = \\\\begin{cases}\n            ///     -2^{W-1} & \\text{if} \\\\quad n < -2^{W-1}, \\\\\\\\\n            ///     2^{W-1}-1 & \\text{if} \\\\quad n \\geq 2^{W-1}, \\\\\\\\\n            ///     n & \\\\text{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#saturating_from).\n            #[inline]\n            fn saturating_from(value: $a) -> $b {\n                saturating_from_lossy(value)\n            }\n        }\n\n        impl OverflowingFrom<$a> for $b {\n            /// Converts a value to another type. If the value cannot be represented in the new\n            /// type, it is wrapped. The second component of the result indicates whether overflow\n            /// occurred.\n            ///\n            /// Let $W$ be the width of the target type.\n            ///\n            /// If the target type is unsigned, then $f_W(n) = (m, k \\neq 0)$, where $m < 2^W$ and\n            /// $n + 2^W k = m$ for some $k \\in \\Z$.\n            ///\n            /// If the target type is signed, then $f_W(n) = (m, k \\neq 0)$, where $-2^{W-1} \\leq m\n            /// < 2^{W-1}$ and $n + 2^W k = m$ for some $k \\in \\Z$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#overflowing_from).\n            #[inline]\n            fn overflowing_from(value: $a) -> ($b, bool) {\n                overflowing_from_lossy(value)\n            }\n        }\n\n        impl ConvertibleFrom<$a> for $b {\n            /// Determines whether a value is convertible to a different type.\n            ///\n            /// Let $W$ be the width of the target type.\n            ///\n            /// If the target type is unsigned then,\n            /// $$\n            /// f_W(n) = (0 \\leq n < 2^W).\n            /// $$\n            ///\n            /// If the target type is signed then,\n            /// $$\n            /// f_W(n) = (-2^{W-1} \\leq n < 2^{W-1}-1).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from#convertible_from).\n            #[inline]\n            fn convertible_from(value: $a) -> bool {\n                convertible_from_lossy::<$a, $b>(value)\n            }\n        }\n    };\n}\n\n// This macro defines conversions from type $a to type $b, where the set of values representable by\n// type $a is a proper subset of the set of values representable by type $b.\nmacro_rules! proper_subset_conversion {\n    ($a:ident, $b:ident) => {\n        lossless_conversion!($a, $b);\n        lossy_conversion!($b, $a);\n    };\n}\n\n// This macro defines conversions from type $a to type $b, where the set of values representable by\n// type $a is neither a subset nor a superset of the set of values representable by type $b.\nmacro_rules! no_containment_conversion {\n    ($a:ident, $b:ident) => {\n        lossy_conversion!($a, $b);\n        lossy_conversion!($b, $a);\n    };\n}\n\napply_to_primitive_ints!(identity_conversion);\n\nproper_subset_conversion!(u8, u16);\nproper_subset_conversion!(u8, u32);\nproper_subset_conversion!(u8, u64);\nproper_subset_conversion!(u8, u128);\nproper_subset_conversion!(u8, usize);\nproper_subset_conversion!(u8, i16);\nproper_subset_conversion!(u8, i32);\nproper_subset_conversion!(u8, i64);\nproper_subset_conversion!(u8, i128);\nproper_subset_conversion!(u8, isize);\nproper_subset_conversion!(u16, u32);\nproper_subset_conversion!(u16, u64);\nproper_subset_conversion!(u16, u128);\nproper_subset_conversion!(u16, usize);\nproper_subset_conversion!(u16, i32);\nproper_subset_conversion!(u16, i64);\nproper_subset_conversion!(u16, i128);\nproper_subset_conversion!(u32, u64);\nproper_subset_conversion!(u32, u128);\nproper_subset_conversion!(u32, i64);\nproper_subset_conversion!(u32, i128);\nproper_subset_conversion!(u64, u128);\nproper_subset_conversion!(u64, i128);\nproper_subset_conversion!(i8, i16);\nproper_subset_conversion!(i8, i32);\nproper_subset_conversion!(i8, i64);\nproper_subset_conversion!(i8, i128);\nproper_subset_conversion!(i8, isize);\nproper_subset_conversion!(i16, i32);\nproper_subset_conversion!(i16, i64);\nproper_subset_conversion!(i16, i128);\nproper_subset_conversion!(i16, isize);\nproper_subset_conversion!(i32, i64);\nproper_subset_conversion!(i32, i128);\nproper_subset_conversion!(i64, i128);\n\nno_containment_conversion!(u8, i8);\nno_containment_conversion!(u16, i8);\nno_containment_conversion!(u16, i16);\nno_containment_conversion!(u16, isize);\nno_containment_conversion!(u32, usize);\nno_containment_conversion!(u32, i8);\nno_containment_conversion!(u32, i16);\nno_containment_conversion!(u32, i32);\nno_containment_conversion!(u32, isize);\nno_containment_conversion!(u64, usize);\nno_containment_conversion!(u64, i8);\nno_containment_conversion!(u64, i16);\nno_containment_conversion!(u64, i32);\nno_containment_conversion!(u64, i64);\nno_containment_conversion!(u64, isize);\nno_containment_conversion!(u128, usize);\nno_containment_conversion!(u128, i8);\nno_containment_conversion!(u128, i16);\nno_containment_conversion!(u128, i32);\nno_containment_conversion!(u128, i64);\nno_containment_conversion!(u128, i128);\nno_containment_conversion!(u128, isize);\nno_containment_conversion!(usize, i8);\nno_containment_conversion!(usize, i16);\nno_containment_conversion!(usize, i32);\nno_containment_conversion!(usize, i64);\nno_containment_conversion!(usize, i128);\nno_containment_conversion!(usize, isize);\nno_containment_conversion!(i32, isize);\nno_containment_conversion!(i64, isize);\nno_containment_conversion!(i128, isize);\n\nfn primitive_float_rounding_from_unsigned<T: PrimitiveFloat, U: PrimitiveUnsigned>(\n    value: U,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    if value == U::ZERO {\n        return (T::ZERO, Equal);\n    }\n    let (mantissa, exponent, o) = sci_mantissa_and_exponent_round(value, rm).unwrap();\n    if let Some(f) = T::from_sci_mantissa_and_exponent(mantissa, i64::wrapping_from(exponent)) {\n        (f, o)\n    } else {\n        match rm {\n            Exact => {\n                panic!(\"Value cannot be represented exactly as an {}\", T::NAME)\n            }\n            Floor | Down | Nearest => (T::MAX_FINITE, Less),\n            _ => (T::INFINITY, Greater),\n        }\n    }\n}\n\nfn unsigned_rounding_from_primitive_float<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    value: U,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    assert!(!value.is_nan());\n    if value.is_infinite() {\n        return if value.is_sign_positive() {\n            match rm {\n                Exact => {\n                    panic!(\"Value cannot be represented exactly as a {}\", T::NAME)\n                }\n                Down | Floor | Nearest => (T::MAX, Less),\n                _ => panic!(\"Cannot round away from positive infinity\"),\n            }\n        } else {\n            match rm {\n                Exact => {\n                    panic!(\"Value cannot be represented exactly as a {}\", T::NAME)\n                }\n                Down | Ceiling | Nearest => (T::ZERO, Greater),\n                _ => panic!(\"Cannot round away from negative infinity\"),\n            }\n        };\n    }\n    if value == U::ZERO {\n        return (T::ZERO, Equal);\n    }\n    if value.is_sign_negative() {\n        return match rm {\n            Exact => {\n                panic!(\"Value cannot be represented exactly as a {}\", T::NAME)\n            }\n            Ceiling | Down | Nearest => (T::ZERO, Greater),\n            _ => panic!(\"Value is less than 0 and rounding mode is {rm}\"),\n        };\n    }\n    let (mut mantissa, exponent) = value.integer_mantissa_and_exponent();\n    let (result, o) = if exponent <= 0 {\n        let o = mantissa.shr_round_assign(-exponent, rm);\n        (T::try_from(mantissa).ok(), o)\n    } else {\n        (\n            T::try_from(mantissa)\n                .ok()\n                .and_then(|n| n.arithmetic_checked_shl(exponent)),\n            Equal,\n        )\n    };\n    if let Some(n) = result {\n        (n, o)\n    } else {\n        match rm {\n            Exact => {\n                panic!(\"Value cannot be represented exactly as a {}\", T::NAME)\n            }\n            Floor | Down | Nearest => (T::MAX, Less),\n            _ => panic!(\n                \"Value is greater than {}::MAX and rounding mode is {}\",\n                T::NAME,\n                rm\n            ),\n        }\n    }\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct PrimitiveFloatFromUnsignedError;\n\nfn primitive_float_try_from_unsigned<T: PrimitiveFloat, U: PrimitiveUnsigned>(\n    value: U,\n) -> Result<T, PrimitiveFloatFromUnsignedError> {\n    if value == U::ZERO {\n        return Ok(T::ZERO);\n    }\n    let (mantissa, exponent, _) =\n        sci_mantissa_and_exponent_round(value, Exact).ok_or(PrimitiveFloatFromUnsignedError)?;\n    T::from_sci_mantissa_and_exponent(mantissa, i64::wrapping_from(exponent))\n        .ok_or(PrimitiveFloatFromUnsignedError)\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub enum UnsignedFromFloatError {\n    FloatInfiniteOrNan,\n    FloatNegative,\n    FloatNonIntegerOrOutOfRange,\n}\n\nfn unsigned_try_from_primitive_float<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    value: U,\n) -> Result<T, UnsignedFromFloatError> {\n    if !value.is_finite() {\n        Err(UnsignedFromFloatError::FloatInfiniteOrNan)\n    } else if value == U::ZERO {\n        Ok(T::ZERO)\n    } else if value < U::ZERO {\n        Err(UnsignedFromFloatError::FloatNegative)\n    } else {\n        let (mantissa, exponent) = value.integer_mantissa_and_exponent();\n        if exponent < 0 {\n            Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n        } else {\n            T::try_from(mantissa)\n                .or(Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange))\n                .and_then(|n| {\n                    n.arithmetic_checked_shl(exponent)\n                        .ok_or(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                })\n        }\n    }\n}\n\nfn primitive_float_convertible_from_unsigned<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned + SciMantissaAndExponent<T, u64>,\n>(\n    value: U,\n) -> bool {\n    if value == U::ZERO {\n        return true;\n    }\n    let precision = (value >> value.trailing_zeros()).significant_bits();\n    precision <= T::MANTISSA_WIDTH + 1\n        && i64::wrapping_from(SciMantissaAndExponent::<T, u64>::sci_exponent(value))\n            <= T::MAX_EXPONENT\n}\n\n#[inline]\nfn unsigned_convertible_from_primitive_float<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    value: U,\n) -> bool {\n    value >= U::ZERO\n        && value.is_integer()\n        && (value == U::ZERO || value.sci_exponent() < i64::wrapping_from(T::WIDTH))\n}\n\nmacro_rules! impl_from_float_unsigned {\n    ($u:ident) => {\n        macro_rules! impl_from_float_unsigned_inner {\n            ($f:ident) => {\n                impl RoundingFrom<$u> for $f {\n                    /// Converts a value of an unsigned type to a value of a floating point type\n                    /// according to a specified [`RoundingMode`]. An [`Ordering`] is also returned,\n                    /// indicating whether the returned value is less than, equal to, or greater\n                    /// than the original value.\n                    ///\n                    /// - If the rounding mode is `Floor` or `Down`, the largest float less than or\n                    ///   equal to the value is returned.\n                    /// - If the rounding mode is `Ceiling` or `Up`, the smallest float greater than\n                    ///   or equal to the value is returned.\n                    /// - If the rounding mode is `Nearest`, then the nearest float is returned. If\n                    ///   the value is exactly between two floats, the float with the zero\n                    ///   least-significant bit in its representation is selected. If the value is\n                    ///   larger than the maximum finite float (which can only happen when\n                    ///   converting a `u128` to an `f32`), the maximum finite float is returned.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `rm` is `Exact` but `value` is not exactly equal to any value of\n                    /// the primitive float type.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#rounding_from).\n                    #[inline]\n                    fn rounding_from(value: $u, rm: RoundingMode) -> ($f, Ordering) {\n                        primitive_float_rounding_from_unsigned(value, rm)\n                    }\n                }\n\n                impl RoundingFrom<$f> for $u {\n                    /// Converts a value of a floating point type to a value of an unsigned type\n                    /// according to a specified [`RoundingMode`]. An [`Ordering`] is also returned,\n                    /// indicating whether the returned value is less than, equal to, or greater\n                    /// than the original value.\n                    ///\n                    /// - If the rounding mode is `Floor`, the largest number less than or equal to\n                    ///   the value is returned. If the float is greater than the maximum\n                    ///   representable unsigned value, the maximum unsigned value is returned. If\n                    ///   the float is negative, the function panics.\n                    /// - If the rounding mode is `Ceiling`, the smallest number greater than or\n                    ///   equal to the value is returned. If the float is negative, zero is\n                    ///   returned. If the float is greater than the maximum representable unsigned\n                    ///   value, the function panics.\n                    /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor`\n                    ///   if the float is non-negative and as with `Ceiling` if the value is\n                    ///   negative.\n                    /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling`\n                    ///   if the value is non-negative and as with `Floor` if the value is negative.\n                    /// - If the rounding mode is `Nearest`, then the nearest value is returned. If\n                    ///   the value is exactly between two numbers, the even one is selected. If the\n                    ///   float is greater than the maximum representable unsigned value, the\n                    ///   maximum unsigned value is returned. If the float is negative, zero is\n                    ///   returned.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// - If `value` is `NaN`.\n                    /// - If `rm` is `Exact` but `value` is not exactly equal to any value of the\n                    ///   unsigned type.\n                    /// - If `value` is greater than the maximum value of the unsigned type and `rm`\n                    ///   is `Ceiling` or `Up`.\n                    /// - If `value` is negative and `rm` is `Floor` or `Up`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#rounding_from).\n                    #[inline]\n                    fn rounding_from(value: $f, rm: RoundingMode) -> ($u, Ordering) {\n                        unsigned_rounding_from_primitive_float(value, rm)\n                    }\n                }\n\n                impl TryFrom<$u> for NiceFloat<$f> {\n                    type Error = PrimitiveFloatFromUnsignedError;\n\n                    /// Converts a value of an unsigned type to a value of a floating point type,\n                    /// returning an error if an exact conversion is not possible.\n                    ///\n                    /// The conversion succeeds if the unsigned value is not too large to represent\n                    /// (which can only happen when converting a [`u128`] to an [`f32`]) and the\n                    /// precision of the unsigned value is not too high.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#try_from).\n                    #[inline]\n                    fn try_from(value: $u) -> Result<NiceFloat<$f>, Self::Error> {\n                        primitive_float_try_from_unsigned(value).map(NiceFloat)\n                    }\n                }\n\n                impl TryFrom<NiceFloat<$f>> for $u {\n                    type Error = UnsignedFromFloatError;\n\n                    /// Converts a value of a floating point type to a value of an unsigned type,\n                    /// returning an error if an exact conversion is not possible.\n                    ///\n                    /// The conversion succeeds if the floating point value is an integer, not\n                    /// negative (negative zero is ok), and not too large.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#try_from).\n                    #[inline]\n                    fn try_from(value: NiceFloat<$f>) -> Result<$u, Self::Error> {\n                        unsigned_try_from_primitive_float(value.0)\n                    }\n                }\n\n                impl ConvertibleFrom<$u> for $f {\n                    /// Checks whether a value of an unsigned type is convertible to a floating\n                    /// point type.\n                    ///\n                    /// An exact conversion is possible if the unsigned value is not too large to\n                    /// represent (which can only happen when converting a [`u128`] to an [`f32`])\n                    /// and the precision of the unsigned value is not too high.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#convertible_from).\n                    #[inline]\n                    fn convertible_from(value: $u) -> bool {\n                        primitive_float_convertible_from_unsigned::<$f, $u>(value)\n                    }\n                }\n\n                impl ConvertibleFrom<$f> for $u {\n                    /// Checks whether a value of a floating point type is convertible to an\n                    /// unsigned type.\n                    ///\n                    /// An exact conversion is possible if the floating point value is an integer,\n                    /// not negative (negative zero is ok), and not too large.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#convertible_from).\n                    #[inline]\n                    fn convertible_from(value: $f) -> bool {\n                        unsigned_convertible_from_primitive_float::<$u, $f>(value)\n                    }\n                }\n            };\n        }\n        apply_to_primitive_floats!(impl_from_float_unsigned_inner);\n    };\n}\napply_to_unsigneds!(impl_from_float_unsigned);\n\n#[inline]\nfn primitive_float_rounding_from_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n    F: PrimitiveFloat + RoundingFrom<U>,\n>(\n    value: S,\n    rm: RoundingMode,\n) -> (F, Ordering) {\n    let abs = value.unsigned_abs();\n    if value >= S::ZERO {\n        F::rounding_from(abs, rm)\n    } else {\n        let (x, o) = F::rounding_from(abs, -rm);\n        (-x, o.reverse())\n    }\n}\n\nfn signed_rounding_from_primitive_float<\n    U: PrimitiveUnsigned + RoundingFrom<F>,\n    S: TryFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    F: PrimitiveFloat,\n>(\n    value: F,\n    rm: RoundingMode,\n) -> (S, Ordering) {\n    if value.is_infinite() {\n        return if value.is_sign_positive() {\n            match rm {\n                Exact => {\n                    panic!(\"Value cannot be represented exactly as a {}\", S::NAME)\n                }\n                Down | Floor | Nearest => (S::MAX, Less),\n                _ => panic!(\"Cannot round away from extreme value\"),\n            }\n        } else {\n            match rm {\n                Exact => {\n                    panic!(\"Value cannot be represented exactly as a {}\", S::NAME)\n                }\n                Down | Nearest | Ceiling => (S::MIN, Greater),\n                _ => panic!(\"Cannot round away from extreme value\"),\n            }\n        };\n    }\n    if value == F::ZERO {\n        return (S::ZERO, Equal);\n    }\n    if value.is_sign_positive() {\n        let (abs, o) = U::rounding_from(value, rm);\n        if let Ok(n) = S::try_from(abs) {\n            (n, o)\n        } else {\n            match rm {\n                Exact => {\n                    panic!(\"Value cannot be represented exactly as an {}\", S::NAME)\n                }\n                Floor | Down | Nearest => (S::MAX, Less),\n                _ => panic!(\n                    \"Value is greater than {}::MAX and rounding mode is {}\",\n                    S::NAME,\n                    rm\n                ),\n            }\n        }\n    } else {\n        let (abs, o) = U::rounding_from(-value, -rm);\n        let n = if abs == S::MIN.unsigned_abs() {\n            Some(S::MIN)\n        } else {\n            S::try_from(abs).ok().map(Neg::neg)\n        };\n        if let Some(n) = n {\n            (n, o.reverse())\n        } else {\n            match rm {\n                Exact => {\n                    panic!(\"Value cannot be represented exactly as an {}\", S::NAME)\n                }\n                Ceiling | Down | Nearest => (S::MIN, Greater),\n                _ => panic!(\n                    \"Value is smaller than {}::MIN and rounding mode is {}\",\n                    S::NAME,\n                    rm\n                ),\n            }\n        }\n    }\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct PrimitiveFloatFromSignedError;\n\n#[inline]\nfn primitive_float_try_from_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n    F: PrimitiveFloat,\n>(\n    value: S,\n) -> Result<F, PrimitiveFloatFromSignedError>\nwhere\n    NiceFloat<F>: TryFrom<U>,\n{\n    let abs = value.unsigned_abs();\n    if value >= S::ZERO {\n        NiceFloat::<F>::try_from(abs)\n            .map(|f| f.0)\n            .map_err(|_| PrimitiveFloatFromSignedError)\n    } else {\n        NiceFloat::<F>::try_from(abs)\n            .map(|f| -f.0)\n            .map_err(|_| PrimitiveFloatFromSignedError)\n    }\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub enum SignedFromFloatError {\n    FloatInfiniteOrNan,\n    FloatNonIntegerOrOutOfRange,\n}\n\nfn signed_try_from_primitive_float<\n    U: TryFrom<NiceFloat<F>> + PrimitiveUnsigned,\n    S: TryFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n    F: PrimitiveFloat,\n>(\n    value: F,\n) -> Result<S, SignedFromFloatError> {\n    if !value.is_finite() {\n        return Err(SignedFromFloatError::FloatInfiniteOrNan);\n    }\n    if value >= F::ZERO {\n        S::try_from(\n            U::try_from(NiceFloat(value))\n                .or(Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange))?,\n        )\n        .or(Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange))\n    } else {\n        let abs = U::try_from(NiceFloat(-value))\n            .or(Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange))?;\n        if abs == S::MIN.unsigned_abs() {\n            Ok(S::MIN)\n        } else {\n            S::try_from(abs)\n                .map(Neg::neg)\n                .or(Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange))\n        }\n    }\n}\n\n#[inline]\nfn primitive_float_convertible_from_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n    F: ConvertibleFrom<U> + PrimitiveFloat,\n>(\n    value: S,\n) -> bool {\n    F::convertible_from(value.unsigned_abs())\n}\n\nfn signed_convertible_from_primitive_float<U: PrimitiveUnsigned, F: PrimitiveFloat>(\n    value: F,\n) -> bool {\n    if !value.is_integer() {\n        return false;\n    }\n    if value >= F::ZERO {\n        value == F::ZERO || value.sci_exponent() < i64::wrapping_from(U::WIDTH) - 1\n    } else {\n        let exponent = value.sci_exponent();\n        let limit = i64::wrapping_from(U::WIDTH) - 1;\n        value == F::ZERO\n            || exponent < limit\n            || exponent == limit\n                && value == -F::from_sci_mantissa_and_exponent(F::ONE, exponent).unwrap()\n    }\n}\n\nmacro_rules! impl_from_float_signed {\n    ($u:ident, $i:ident) => {\n        macro_rules! impl_from_float_signed_inner {\n            ($f:ident) => {\n                impl RoundingFrom<$i> for $f {\n                    /// Converts a value of a signed type to a value of a floating point type\n                    /// according to a specified [`RoundingMode`]. An [`Ordering`] is also returned,\n                    /// indicating whether the returned value is less than, equal to, or greater\n                    /// than the original value.\n                    ///\n                    /// - If the rounding mode is `Floor`, the largest float less than or equal to\n                    ///   the value is returned.\n                    /// - If the rounding mode is `Ceiling`, the smallest float greater than or\n                    ///   equal to the value is returned.\n                    /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor`\n                    ///   if the value is non-negative and as with `Ceiling` if the value is\n                    ///   negative.\n                    /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling`\n                    ///   if the value is non-negative and as with `Floor` if the value is negative.\n                    /// - If the rounding mode is `Nearest`, then the nearest float is returned. If\n                    ///   the value is exactly between two floats, the float with the zero\n                    ///   least-significant bit in its representation is selected.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `rm` is `Exact` but `value` is not exactly equal to any value of\n                    /// the primitive float type.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#rounding_from).\n                    #[inline]\n                    fn rounding_from(value: $i, rm: RoundingMode) -> ($f, Ordering) {\n                        primitive_float_rounding_from_signed::<$u, $i, $f>(value, rm)\n                    }\n                }\n\n                impl RoundingFrom<$f> for $i {\n                    /// Converts a value of a floating point type to a value of a signed type\n                    /// according to a specified [`RoundingMode`]. An [`Ordering`] is also returned,\n                    /// indicating whether the returned value is less than, equal to, or greater\n                    /// than the original value.\n                    ///\n                    /// - If the rounding mode is `Floor`, the largest number less than or equal to\n                    ///   the value is returned. If the float is greater than the maximum\n                    ///   representable signed value, the maximum signed value is returned. If the\n                    ///   float is smaller than the minimum representable signed value, the function\n                    ///   panics.\n                    /// - If the rounding mode is `Ceiling`, the smallest number greater than or\n                    ///   equal to the value is returned. If the float is smaller than the minimum\n                    ///   representable signed value, the minimum signed value is returned. If the\n                    ///   float is greater than the maximum representable signed value, the function\n                    ///   panics.\n                    /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor`\n                    ///   if the float is non-negative and as with `Ceiling` if the value is\n                    ///   negative.\n                    /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling`\n                    ///   if the value is non-negative and as with `Floor` if the value is negative.\n                    /// - If the rounding mode is `Nearest`, then the nearest value is returned. If\n                    ///   the value is exactly between two numbers, the even one is selected. If the\n                    ///   float is greater than the maximum representable signed value, the maximum\n                    ///   signed value is returned. If the float is smaller than the minimum\n                    ///   representable signed value, the minimum signed value is returned.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// - If `value` is `NaN`.\n                    /// - If `rm` is `Exact` but `value` is not exactly equal to any value of the\n                    ///   unsigned type.\n                    /// - If `value` is greater than the maximum value of the signed type and `rm`\n                    ///   is `Ceiling` or `Up`.\n                    /// - If `value` is smaller than the minimum value of the signed type and `rm`\n                    ///   is `Floor` or `Up`.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#rounding_from).\n                    #[inline]\n                    fn rounding_from(value: $f, rm: RoundingMode) -> ($i, Ordering) {\n                        signed_rounding_from_primitive_float::<$u, $i, $f>(value, rm)\n                    }\n                }\n\n                impl TryFrom<$i> for NiceFloat<$f> {\n                    type Error = PrimitiveFloatFromSignedError;\n\n                    /// Converts a value of a signed type to a value of a floating point type,\n                    /// returning an error if an exact conversion is not possible.\n                    ///\n                    /// The conversion succeeds if the precision of the signed value is not too\n                    /// high.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#try_from).\n                    #[inline]\n                    fn try_from(value: $i) -> Result<NiceFloat<$f>, Self::Error> {\n                        primitive_float_try_from_signed(value).map(NiceFloat)\n                    }\n                }\n\n                impl TryFrom<NiceFloat<$f>> for $i {\n                    type Error = SignedFromFloatError;\n\n                    /// Converts a value of a floating point type to a value of a signed type,\n                    /// returning an error if an exact conversion is not possible.\n                    ///\n                    /// The conversion succeeds if the floating point value is an integer and not\n                    /// too large or too small.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#try_from).\n                    #[inline]\n                    fn try_from(value: NiceFloat<$f>) -> Result<$i, Self::Error> {\n                        signed_try_from_primitive_float::<$u, $i, $f>(value.0)\n                    }\n                }\n\n                impl ConvertibleFrom<$i> for $f {\n                    /// Checks whether a value of a signed type is convertible to a floating point\n                    /// type.\n                    ///\n                    /// An exact conversion is possible if the precision of the signed value is not\n                    /// too high.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#convertible_from).\n                    #[inline]\n                    fn convertible_from(value: $i) -> bool {\n                        primitive_float_convertible_from_signed::<$u, $i, $f>(value)\n                    }\n                }\n\n                impl ConvertibleFrom<$f> for $i {\n                    /// Checks whether a value of a floating point type is convertible to a signed\n                    /// type.\n                    ///\n                    /// An exact conversion is possible if the floating point value is an integer\n                    /// and not too large or too small.\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Examples\n                    /// See [here](super::from#convertible_from).\n                    #[inline]\n                    fn convertible_from(value: $f) -> bool {\n                        signed_convertible_from_primitive_float::<$u, $f>(value)\n                    }\n                }\n            };\n        }\n        apply_to_primitive_floats!(impl_from_float_signed_inner);\n    };\n}\napply_to_unsigned_signed_pairs!(impl_from_float_signed);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/half.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf, WrappingFrom};\n\n#[inline]\nfn join_halves<T: From<H> + PrimitiveUnsigned, H: PrimitiveUnsigned>(upper: H, lower: H) -> T {\n    (T::from(upper) << H::WIDTH) | T::from(lower)\n}\n\n#[inline]\nfn upper_half<T: PrimitiveUnsigned, H: PrimitiveUnsigned + WrappingFrom<T>>(x: &T) -> H {\n    H::wrapping_from(*x >> H::WIDTH)\n}\n\nmacro_rules! impl_half_traits {\n    ($t:ident, $ht: ident) => {\n        impl HasHalf for $t {\n            /// The primitive integer type whose width is half of `Self`'s.\n            type Half = $ht;\n        }\n\n        impl JoinHalves for $t {\n            /// Joins two unsigned integers to form an unsigned integer with twice the width.\n            ///\n            /// Let $W$ be the width of `Self` (the output type).\n            ///\n            /// $f(x, y) = 2^{W/2} x + y$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::half#join_halves).\n            #[inline]\n            fn join_halves(upper: Self::Half, lower: Self::Half) -> Self {\n                join_halves(upper, lower)\n            }\n        }\n\n        impl SplitInHalf for $t {\n            /// Extracts the lower, or least significant, half of an unsigned integer.\n            ///\n            /// Let $W$ be the width of `Self` (the input type).\n            ///\n            /// $f(n) = m$, where $m < 2^{W/2}$ and $n + 2^{W/2} k = m$ for some $k \\in \\Z$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::half#lower_half).\n            #[inline]\n            fn lower_half(&self) -> Self::Half {\n                $ht::wrapping_from(*self)\n            }\n\n            /// Extracts the upper, or most-significant, half of an unsigned integer.\n            ///\n            /// Let $W$ be the width of `Self` (the input type).\n            ///\n            /// $f(n) = \\lfloor \\frac{n}{2^{W/2}} \\rfloor$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::half#upper_half).\n            #[inline]\n            fn upper_half(&self) -> Self::Half {\n                upper_half(self)\n            }\n        }\n    };\n}\nimpl_half_traits!(u16, u8);\nimpl_half_traits!(u32, u16);\nimpl_half_traits!(u64, u32);\nimpl_half_traits!(u128, u64);\n\n#[inline]\nfn wide_lower_half<T: PrimitiveUnsigned>(x: T) -> T {\n    x.mod_power_of_2(T::WIDTH >> 1)\n}\n\n#[inline]\npub(crate) fn wide_upper_half<T: PrimitiveUnsigned>(x: T) -> T {\n    x >> (T::WIDTH >> 1)\n}\n\n#[inline]\npub(crate) fn wide_split_in_half<T: PrimitiveUnsigned>(x: T) -> (T, T) {\n    (wide_upper_half(x), wide_lower_half(x))\n}\n\n#[inline]\npub(crate) fn wide_join_halves<T: PrimitiveUnsigned>(hi: T, lo: T) -> T {\n    (hi << (T::WIDTH >> 1)) | lo\n}\n"
  },
  {
    "path": "malachite-base/src/num/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::conversion::traits::{IsInteger, WrappingFrom};\nuse crate::num::logic::traits::TrailingZeros;\n\nfn is_integer_float<T: PrimitiveFloat>(x: T) -> bool {\n    if x.is_nan() || x.is_infinite() {\n        false\n    } else if x == T::ZERO {\n        true\n    } else {\n        let (raw_mantissa, raw_exponent) = x.raw_mantissa_and_exponent();\n        raw_exponent != 0\n            && i64::wrapping_from(\n                raw_exponent\n                    + if raw_mantissa == 0 {\n                        T::MANTISSA_WIDTH\n                    } else {\n                        TrailingZeros::trailing_zeros(raw_mantissa)\n                    },\n            ) > -T::MIN_EXPONENT\n    }\n}\n\nmacro_rules! impl_is_integer_primitive_int {\n    ($t:ident) => {\n        impl IsInteger for $t {\n            /// Determines whether a value is an integer.\n            ///\n            /// For primitive integer types this always returns `true`.\n            ///\n            /// $f(x) = \\textrm{true}$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_integer#is_integer).\n            #[inline]\n            fn is_integer(self) -> bool {\n                true\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_is_integer_primitive_int);\n\nmacro_rules! impl_is_integer_primitive_float {\n    ($t:ident) => {\n        impl IsInteger for $t {\n            /// Determines whether a value is an integer.\n            ///\n            /// $f(x) = (x \\in \\Z)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_integer#is_integer).\n            #[inline]\n            fn is_integer(self) -> bool {\n                is_integer_float(self)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_is_integer_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    ArithmeticCheckedShl, DivisibleByPowerOf2, ModPowerOf2, ShrRound,\n};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{\n    ExactFrom, IntegerMantissaAndExponent, RawMantissaAndExponent, SciMantissaAndExponent,\n    WrappingFrom,\n};\nuse crate::num::logic::traits::{BitAccess, LeadingZeros, LowMask, SignificantBits, TrailingZeros};\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse core::cmp::Ordering::{self, *};\n\nfn raw_mantissa_and_exponent<T: PrimitiveFloat>(x: T) -> (u64, u64) {\n    let bits = x.to_bits();\n    (\n        bits.mod_power_of_2(T::MANTISSA_WIDTH),\n        (bits >> T::MANTISSA_WIDTH).mod_power_of_2(T::EXPONENT_WIDTH),\n    )\n}\n\n#[inline]\nfn raw_mantissa<T: PrimitiveFloat>(x: T) -> u64 {\n    x.to_bits().mod_power_of_2(T::MANTISSA_WIDTH)\n}\n\n#[inline]\nfn raw_exponent<T: PrimitiveFloat>(x: T) -> u64 {\n    (x.to_bits() >> T::MANTISSA_WIDTH).mod_power_of_2(T::EXPONENT_WIDTH)\n}\n\nfn from_raw_mantissa_and_exponent<T: PrimitiveFloat>(raw_mantissa: u64, raw_exponent: u64) -> T {\n    assert!(raw_mantissa.significant_bits() <= T::MANTISSA_WIDTH);\n    assert!(raw_exponent.significant_bits() <= T::EXPONENT_WIDTH);\n    let x = T::from_bits((raw_exponent << T::MANTISSA_WIDTH) | raw_mantissa);\n    // Only output the canonical NaN\n    if x.is_nan() { T::NAN } else { x }\n}\n\nfn integer_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(x: T) -> (u64, i64) {\n    assert!(x.is_finite());\n    assert!(x != T::ZERO);\n    let (mut raw_mantissa, raw_exponent) = x.raw_mantissa_and_exponent();\n    if raw_exponent == 0 {\n        let trailing_zeros = raw_mantissa.trailing_zeros();\n        (\n            raw_mantissa >> trailing_zeros,\n            i64::wrapping_from(trailing_zeros) + T::MIN_EXPONENT,\n        )\n    } else {\n        raw_mantissa.set_bit(T::MANTISSA_WIDTH);\n        let trailing_zeros = TrailingZeros::trailing_zeros(raw_mantissa);\n        (\n            raw_mantissa >> trailing_zeros,\n            i64::wrapping_from(raw_exponent + trailing_zeros) + T::MIN_EXPONENT - 1,\n        )\n    }\n}\n\nfn integer_mantissa_primitive_float<T: PrimitiveFloat>(x: T) -> u64 {\n    assert!(x.is_finite());\n    assert!(x != T::ZERO);\n    let (mut raw_mantissa, raw_exponent) = x.raw_mantissa_and_exponent();\n    if raw_exponent != 0 {\n        raw_mantissa.set_bit(T::MANTISSA_WIDTH);\n    }\n    raw_mantissa >> raw_mantissa.trailing_zeros()\n}\n\nfn integer_exponent_primitive_float<T: PrimitiveFloat>(x: T) -> i64 {\n    assert!(x.is_finite());\n    assert!(x != T::ZERO);\n    let (raw_mantissa, raw_exponent) = x.raw_mantissa_and_exponent();\n    if raw_exponent == 0 {\n        i64::wrapping_from(raw_mantissa.trailing_zeros()) + T::MIN_EXPONENT\n    } else {\n        i64::wrapping_from(\n            raw_exponent\n                + if raw_mantissa == 0 {\n                    T::MANTISSA_WIDTH\n                } else {\n                    TrailingZeros::trailing_zeros(raw_mantissa)\n                },\n        ) + T::MIN_EXPONENT\n            - 1\n    }\n}\n\nfn from_integer_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    integer_mantissa: u64,\n    integer_exponent: i64,\n) -> Option<T> {\n    if integer_mantissa == 0 {\n        return Some(T::ZERO);\n    }\n    let trailing_zeros = integer_mantissa.trailing_zeros();\n    let (integer_mantissa, adjusted_exponent) = (\n        integer_mantissa >> trailing_zeros,\n        integer_exponent + i64::wrapping_from(trailing_zeros),\n    );\n    let mantissa_bits = integer_mantissa.significant_bits();\n    let sci_exponent = adjusted_exponent.checked_add(i64::exact_from(mantissa_bits))? - 1;\n    let mut raw_mantissa;\n    let raw_exponent;\n    if sci_exponent < T::MIN_EXPONENT || sci_exponent > T::MAX_EXPONENT {\n        return None;\n    } else if sci_exponent < T::MIN_NORMAL_EXPONENT {\n        if adjusted_exponent < T::MIN_EXPONENT {\n            return None;\n        }\n        raw_exponent = 0;\n        raw_mantissa = integer_mantissa << (adjusted_exponent - T::MIN_EXPONENT);\n    } else if mantissa_bits > T::MANTISSA_WIDTH + 1 {\n        return None;\n    } else {\n        raw_exponent = u64::exact_from(sci_exponent + i64::low_mask(T::EXPONENT_WIDTH - 1));\n        raw_mantissa = integer_mantissa << (T::MANTISSA_WIDTH + 1 - mantissa_bits);\n        raw_mantissa.clear_bit(T::MANTISSA_WIDTH);\n    }\n    Some(T::from_raw_mantissa_and_exponent(\n        raw_mantissa,\n        raw_exponent,\n    ))\n}\n\nfn sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(x: T) -> (T, i64) {\n    assert!(x.is_finite());\n    assert!(x != T::ZERO);\n    let (raw_mantissa, raw_exponent) = x.raw_mantissa_and_exponent();\n    // Note that Self::MAX_EXPONENT is also the raw exponent of 1.0.\n    if raw_exponent == 0 {\n        let leading_zeros =\n            LeadingZeros::leading_zeros(raw_mantissa) - (u64::WIDTH - T::MANTISSA_WIDTH);\n        let mut mantissa = raw_mantissa << (leading_zeros + 1);\n        mantissa.clear_bit(T::MANTISSA_WIDTH);\n        (\n            T::from_raw_mantissa_and_exponent(mantissa, u64::wrapping_from(T::MAX_EXPONENT)),\n            i64::wrapping_from(T::MANTISSA_WIDTH - leading_zeros - 1) + T::MIN_EXPONENT,\n        )\n    } else {\n        (\n            T::from_raw_mantissa_and_exponent(raw_mantissa, u64::wrapping_from(T::MAX_EXPONENT)),\n            i64::wrapping_from(raw_exponent) - T::MAX_EXPONENT,\n        )\n    }\n}\n\nfn sci_mantissa_primitive_float<T: PrimitiveFloat>(x: T) -> T {\n    assert!(x.is_finite());\n    assert!(x != T::ZERO);\n    let (mut mantissa, raw_exponent) = x.raw_mantissa_and_exponent();\n    // Note that Self::MAX_EXPONENT is also the raw exponent of 1.0.\n    if raw_exponent == 0 {\n        mantissa <<= LeadingZeros::leading_zeros(mantissa) - (u64::WIDTH - T::MANTISSA_WIDTH) + 1;\n        mantissa.clear_bit(T::MANTISSA_WIDTH);\n    }\n    T::from_raw_mantissa_and_exponent(mantissa, u64::wrapping_from(T::MAX_EXPONENT))\n}\n\nfn sci_exponent_primitive_float<T: PrimitiveFloat>(x: T) -> i64 {\n    assert!(x.is_finite());\n    assert!(x != T::ZERO);\n    let (raw_mantissa, raw_exponent) = x.raw_mantissa_and_exponent();\n    // Note that Self::MAX_EXPONENT is also the raw exponent of 1.0.\n    if raw_exponent == 0 {\n        i64::wrapping_from(u64::WIDTH - LeadingZeros::leading_zeros(raw_mantissa) - 1)\n            + T::MIN_EXPONENT\n    } else {\n        i64::wrapping_from(raw_exponent) - T::MAX_EXPONENT\n    }\n}\n\n#[allow(clippy::wrong_self_convention)]\nfn from_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    sci_mantissa: T,\n    sci_exponent: i64,\n) -> Option<T> {\n    assert!(sci_mantissa.is_finite());\n    assert!(sci_mantissa > T::ZERO);\n    if sci_exponent < T::MIN_EXPONENT || sci_exponent > T::MAX_EXPONENT {\n        return None;\n    }\n    let (mut orig_mantissa, orig_exponent) = sci_mantissa.raw_mantissa_and_exponent();\n    // Note that Self::MAX_EXPONENT is also the raw exponent of 1.0.\n    if orig_exponent != u64::wrapping_from(T::MAX_EXPONENT) {\n        return None;\n    }\n    if sci_exponent < T::MIN_NORMAL_EXPONENT {\n        let shift = T::MIN_NORMAL_EXPONENT - sci_exponent;\n        if orig_mantissa.divisible_by_power_of_2(u64::wrapping_from(shift)) {\n            orig_mantissa.set_bit(T::MANTISSA_WIDTH);\n            Some(T::from_raw_mantissa_and_exponent(orig_mantissa >> shift, 0))\n        } else {\n            None\n        }\n    } else {\n        Some(T::from_raw_mantissa_and_exponent(\n            orig_mantissa,\n            u64::wrapping_from(sci_exponent + T::MAX_EXPONENT),\n        ))\n    }\n}\n\n/// Returns the scientific mantissa and exponent of an unsinged value. An [`Ordering`] is also\n/// returned, indicating whether the mantissa and exponent correspond to a value less than, equal\n/// to, or greater than the original value.\n///\n/// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is a\n/// rational number with $1 \\leq m_s < 2$. We represent the rational mantissa as a float. The\n/// conversion might not be exact, so we round to the nearest float using the provided rounding\n/// mode. If the rounding mode is `Exact` but the conversion is not exact, `None` is returned.\n/// $$\n/// f(x, r) \\approx (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}, \\lfloor \\log_2 x \\rfloor).\n/// $$\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\n/// use malachite_base::num::conversion::mantissa_and_exponent::*;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::rounding_modes::RoundingMode::{self, *};\n/// use std::cmp::Ordering::{self, *};\n///\n/// fn test<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n///     n: T,\n///     rm: RoundingMode,\n///     out: Option<(U, u64, Ordering)>,\n/// ) {\n///     assert_eq!(\n///         sci_mantissa_and_exponent_round(n, rm).map(|(m, e, o)| (NiceFloat(m), e, o)),\n///         out.map(|(m, e, o)| (NiceFloat(m), e, o))\n///     );\n/// }\n/// test::<u32, f32>(3, Down, Some((1.5, 1, Equal)));\n/// test::<u32, f32>(3, Ceiling, Some((1.5, 1, Equal)));\n/// test::<u32, f32>(3, Up, Some((1.5, 1, Equal)));\n/// test::<u32, f32>(3, Nearest, Some((1.5, 1, Equal)));\n/// test::<u32, f32>(3, Exact, Some((1.5, 1, Equal)));\n///\n/// test::<u32, f32>(123, Floor, Some((1.921875, 6, Equal)));\n/// test::<u32, f32>(123, Down, Some((1.921875, 6, Equal)));\n/// test::<u32, f32>(123, Ceiling, Some((1.921875, 6, Equal)));\n/// test::<u32, f32>(123, Up, Some((1.921875, 6, Equal)));\n/// test::<u32, f32>(123, Nearest, Some((1.921875, 6, Equal)));\n/// test::<u32, f32>(123, Exact, Some((1.921875, 6, Equal)));\n///\n/// test::<u32, f32>(1000000000, Nearest, Some((1.8626451, 29, Equal)));\n/// test::<u32, f32>(999999999, Nearest, Some((1.8626451, 29, Greater)));\n/// ```\npub fn sci_mantissa_and_exponent_round<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    x: T,\n    rm: RoundingMode,\n) -> Option<(U, u64, Ordering)> {\n    assert_ne!(x, T::ZERO);\n    let significant_bits = x.significant_bits();\n    let mut exponent = significant_bits - 1;\n    let (mut raw_mantissa, o) = if significant_bits > U::MANTISSA_WIDTH {\n        let shift = significant_bits - U::MANTISSA_WIDTH - 1;\n        if rm == Exact && TrailingZeros::trailing_zeros(x) < shift {\n            return None;\n        }\n        let (s, o) = x.shr_round(shift, rm);\n        (s.wrapping_into(), o)\n    } else {\n        let x: u64 = x.wrapping_into();\n        (x << (U::MANTISSA_WIDTH - significant_bits + 1), Equal)\n    };\n    if raw_mantissa.significant_bits() == U::MANTISSA_WIDTH + 2 {\n        // Rounding up to a power of 2\n        raw_mantissa >>= 1;\n        exponent += 1;\n    }\n    raw_mantissa.clear_bit(U::MANTISSA_WIDTH);\n    // Note that Self::MAX_EXPONENT is also the raw exponent of 1.0.\n    Some((\n        U::from_raw_mantissa_and_exponent(raw_mantissa, u64::wrapping_from(U::MAX_EXPONENT)),\n        exponent,\n        o,\n    ))\n}\n\n/// Constructs a primitive integer from its scientific mantissa and exponent. An [`Ordering`] is\n/// also returned, indicating whether the returned value is less than, equal to, or greater than the\n/// exact value implied by the input.\n///\n/// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is a\n/// rational number with $1 \\leq m_s < 2$. Here, the rational mantissa is provided as a float. If\n/// the mantissa is outside the range $[1, 2)$, `None` is returned.\n///\n/// Some combinations of mantissas and exponents do not specify an integer, in which case the\n/// resulting value is rounded to an integer using the specified rounding mode. If the rounding mode\n/// is `Exact` but the input does not exactly specify an integer, `None` is returned.\n///\n/// $$\n/// f(x, r) \\approx 2^{e_s}m_s.\n/// $$\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `sci_mantissa` is zero.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\n/// use malachite_base::num::conversion::mantissa_and_exponent::*;\n/// use malachite_base::rounding_modes::RoundingMode::{self, *};\n/// use std::cmp::Ordering::{self, *};\n///\n/// fn test<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n///     mantissa: U,\n///     exponent: u64,\n///     rm: RoundingMode,\n///     out: Option<(T, Ordering)>,\n/// ) {\n///     assert_eq!(\n///         from_sci_mantissa_and_exponent_round::<T, U>(mantissa, exponent, rm),\n///         out\n///     );\n/// }\n/// test::<u32, f32>(1.5, 1, Floor, Some((3, Equal)));\n/// test::<u32, f32>(1.5, 1, Down, Some((3, Equal)));\n/// test::<u32, f32>(1.5, 1, Ceiling, Some((3, Equal)));\n/// test::<u32, f32>(1.5, 1, Up, Some((3, Equal)));\n/// test::<u32, f32>(1.5, 1, Nearest, Some((3, Equal)));\n/// test::<u32, f32>(1.5, 1, Exact, Some((3, Equal)));\n///\n/// test::<u32, f32>(1.51, 1, Floor, Some((3, Less)));\n/// test::<u32, f32>(1.51, 1, Down, Some((3, Less)));\n/// test::<u32, f32>(1.51, 1, Ceiling, Some((4, Greater)));\n/// test::<u32, f32>(1.51, 1, Up, Some((4, Greater)));\n/// test::<u32, f32>(1.51, 1, Nearest, Some((3, Less)));\n/// test::<u32, f32>(1.51, 1, Exact, None);\n///\n/// test::<u32, f32>(2.0, 1, Floor, None);\n/// test::<u32, f32>(10.0, 1, Floor, None);\n/// test::<u32, f32>(0.5, 1, Floor, None);\n/// ```\npub fn from_sci_mantissa_and_exponent_round<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n    sci_mantissa: U,\n    sci_exponent: u64,\n    rm: RoundingMode,\n) -> Option<(T, Ordering)> {\n    assert_ne!(sci_mantissa, U::ZERO);\n    if sci_mantissa < U::ONE || sci_mantissa >= U::TWO {\n        return None;\n    }\n    let mut raw_mantissa = sci_mantissa.raw_mantissa();\n    raw_mantissa.set_bit(U::MANTISSA_WIDTH);\n    if sci_exponent >= U::MANTISSA_WIDTH {\n        T::try_from(raw_mantissa)\n            .ok()?\n            .arithmetic_checked_shl(sci_exponent - U::MANTISSA_WIDTH)\n            .map(|n| (n, Equal))\n    } else {\n        let shift = U::MANTISSA_WIDTH - sci_exponent;\n        if rm == Exact && TrailingZeros::trailing_zeros(raw_mantissa) < shift {\n            return None;\n        }\n        let (s, o) = raw_mantissa.shr_round(shift, rm);\n        T::try_from(s).ok().map(|s| (s, o))\n    }\n}\n\nmacro_rules! impl_mantissa_and_exponent_unsigned {\n    ($t:ident) => {\n        impl IntegerMantissaAndExponent<$t, u64> for $t {\n            /// Returns the integer mantissa and exponent.\n            ///\n            /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n            /// $m_i$ is an odd integer.\n            /// $$\n            /// f(x) = (\\frac{|x|}{2^{e_i}}, e_i),\n            /// $$\n            /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n            ///\n            /// The inverse operation is\n            /// [`from_integer_mantissa_and_exponent`](Self::from_integer_mantissa_and_exponent).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#integer_mantissa_and_exponent).\n            #[inline]\n            fn integer_mantissa_and_exponent(self) -> ($t, u64) {\n                assert_ne!(self, 0);\n                let exponent = TrailingZeros::trailing_zeros(self);\n                (self >> exponent, exponent)\n            }\n\n            /// Returns the integer mantissa.\n            ///\n            /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n            /// $m_i$ is an odd integer.\n            /// $$\n            /// f(x) = \\frac{|x|}{2^{e_i}},\n            /// $$\n            /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#integer_mantissa).\n            #[inline]\n            fn integer_mantissa(self) -> $t {\n                assert_ne!(self, 0);\n                self >> self.trailing_zeros()\n            }\n\n            /// Returns the integer exponent.\n            ///\n            /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n            /// $m_i$ is an odd integer.\n            /// $$\n            /// f(x) = e_i,\n            /// $$\n            /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#integer_exponent).\n            #[inline]\n            fn integer_exponent(self) -> u64 {\n                assert_ne!(self, 0);\n                TrailingZeros::trailing_zeros(self)\n            }\n\n            /// Constructs an unsigned primitive integer from its integer mantissa and exponent.\n            ///\n            /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n            /// $m_i$ is an odd integer.\n            ///\n            /// $$\n            /// f(x) = 2^{e_i}m_i,\n            /// $$\n            /// or `None` if the result cannot be exactly represented as an integer of the desired\n            /// type (this happens if the exponent is too large).\n            ///\n            /// The input does not have to be reduced; that is to say, the mantissa does not have to\n            /// be odd.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#from_integer_mantissa_and_exponent).\n            #[inline]\n            fn from_integer_mantissa_and_exponent(\n                integer_mantissa: $t,\n                integer_exponent: u64,\n            ) -> Option<$t> {\n                integer_mantissa.arithmetic_checked_shl(integer_exponent)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mantissa_and_exponent_unsigned);\n\nmacro_rules! impl_sci_mantissa_and_exponent_unsigned {\n    ($u:ident) => {\n        macro_rules! impl_sci_mantissa_and_exponent_unsigned_inner {\n            ($f:ident) => {\n                impl SciMantissaAndExponent<$f, u64> for $u {\n                    /// Returns the scientific mantissa and exponent.\n                    ///\n                    /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an\n                    /// integer and $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent\n                    /// the rational mantissa as a float. The conversion might not be exact, so we\n                    /// round to the nearest float using the `Nearest` rounding mode. To use other\n                    /// rounding modes, use [`sci_mantissa_and_exponent_round`].\n                    ///\n                    /// If the result cannot be expressed as an integer of the specified type,\n                    /// `None` is returned.\n                    /// $$\n                    /// f(x) \\approx (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}},\n                    /// \\lfloor \\log_2 x \\rfloor).\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `self` is zero.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mantissa_and_exponent#sci_mantissa_and_exponent).\n                    #[inline]\n                    fn sci_mantissa_and_exponent(self) -> ($f, u64) {\n                        let (m, e, _) = sci_mantissa_and_exponent_round(self, Nearest).unwrap();\n                        (m, e)\n                    }\n\n                    /// Constructs a primitive integer from its scientific mantissa and exponent.\n                    ///\n                    /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an\n                    /// integer and $m_s$ is a rational number with $1 \\leq m_s < 2$. Here, the\n                    /// rational mantissa is provided as a float. If the mantissa is outside the\n                    /// range $[1, 2)$, `None` is returned.\n                    ///\n                    /// Some combinations of mantissas and exponents do not specify an integer, in\n                    /// which case the resulting value is rounded to an integer using the `Nearest`\n                    /// rounding mode. To specify other rounding modes, use\n                    /// [`from_sci_mantissa_and_exponent_round`].\n                    ///\n                    /// $$\n                    /// f(x) \\approx 2^{e_s}m_s.\n                    /// $$\n                    ///\n                    /// # Worst-case complexity\n                    /// Constant time and additional memory.\n                    ///\n                    /// # Panics\n                    /// Panics if `sci_mantissa` is zero.\n                    ///\n                    /// # Examples\n                    /// See [here](super::mantissa_and_exponent#from_sci_mantissa_and_exponent).\n                    #[inline]\n                    fn from_sci_mantissa_and_exponent(\n                        sci_mantissa: $f,\n                        sci_exponent: u64,\n                    ) -> Option<$u> {\n                        from_sci_mantissa_and_exponent_round(sci_mantissa, sci_exponent, Nearest)\n                            .map(|p| p.0)\n                    }\n                }\n            };\n        }\n        apply_to_primitive_floats!(impl_sci_mantissa_and_exponent_unsigned_inner);\n    };\n}\napply_to_unsigneds!(impl_sci_mantissa_and_exponent_unsigned);\n\nmacro_rules! impl_mantissa_and_exponent_primitive_float {\n    ($t:ident) => {\n        impl RawMantissaAndExponent<u64, u64> for $t {\n            /// Returns the raw mantissa and exponent.\n            ///\n            /// The raw exponent and raw mantissa are the actual bit patterns used to represent the\n            /// components of `self`. When `self` is nonzero and finite, the raw exponent $e_r$ is\n            /// an integer in $[0, 2^E-2]$ and the raw mantissa $m_r$ is an integer in $[0, 2^M-1]$.\n            ///\n            /// When `self` is nonzero and finite, $f(x) = (m_r, e_r)$, where\n            /// $$\n            /// m_r = \\\\begin{cases}\n            ///     2^{M+2^{E-1}-2}|x| & \\text{if} \\\\quad |x| < 2^{2-2^{E-1},} \\\\\\\\\n            ///     2^M \\left ( \\frac{|x|}{2^{\\lfloor \\log_2 |x| \\rfloor}}-1\\right ) &\n            ///     \\textrm{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// and\n            /// $$\n            /// e_r = \\\\begin{cases}\n            ///     0 & \\text{if} \\\\quad |x| < 2^{2-2^{E-1}} \\\\\\\\\n            ///     \\lfloor \\log_2 |x| \\rfloor + 2^{E-1} - 1 & \\textrm{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            /// and $M$ and $E$ are the mantissa width and exponent width, respectively.\n            ///\n            /// For zeros, infinities, or `NaN`, refer to [IEEE\n            /// 754](https://standards.ieee.org/ieee/754/6210/) or look at the examples below.\n            ///\n            /// The inverse operation is [`Self::from_raw_mantissa_and_exponent`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#raw_mantissa_and_exponent).\n            #[inline]\n            fn raw_mantissa_and_exponent(self) -> (u64, u64) {\n                raw_mantissa_and_exponent(self)\n            }\n\n            /// Returns the raw mantissa.\n            ///\n            /// The raw mantissa is the actual bit pattern used to represent the mantissa of `self`.\n            /// When `self` is nonzero and finite, it is an integer in $[0, 2^M-1]$.\n            ///\n            /// When `self` is nonzero and finite,\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     2^{M+2^{E-1}-2}|x| & \\text{if} \\\\quad |x| < 2^{2-2^{E-1}}, \\\\\\\\\n            ///     2^M \\left ( \\frac{|x|}{2^{\\lfloor \\log_2 |x| \\rfloor}}-1\\right )\n            ///     & \\textrm{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $M$ and $E$ are the mantissa width and exponent width, respectively.\n            ///\n            /// For zeros, infinities, or `NaN`, refer to [IEEE\n            /// 754](https://standards.ieee.org/ieee/754/6210/) or look at the examples below.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#raw_mantissa).\n            #[inline]\n            fn raw_mantissa(self) -> u64 {\n                raw_mantissa(self)\n            }\n\n            /// Returns the raw exponent.\n            ///\n            /// The raw exponent is the actual bit pattern used to represent the exponent of `self`.\n            /// When `self` is nonzero and finite, it is an integer in $[0, 2^E-2]$.\n            ///\n            /// When `self` is nonzero and finite,\n            /// $$\n            /// f(x) = \\\\begin{cases}\n            ///     0 & \\text{if} \\\\quad |x| < 2^{2-2^{E-1}}, \\\\\\\\\n            ///     \\lfloor \\log_2 |x| \\rfloor + 2^{E-1} - 1 & \\textrm{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $M$ and $E$ are the mantissa width and exponent width, respectively.\n            ///\n            /// For zeros, infinities, or `NaN`, refer to [IEEE\n            /// 754](https://standards.ieee.org/ieee/754/6210/) or look at the examples below.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#raw_exponent).\n            #[inline]\n            fn raw_exponent(self) -> u64 {\n                raw_exponent(self)\n            }\n\n            /// Constructs a float from its raw mantissa and exponent.\n            ///\n            /// The raw exponent and raw mantissa are the actual bit patterns used to represent the\n            /// components of a float. When the float is nonzero and finite, the raw exponent $e_r$\n            /// is an integer in $[0, 2^E-2]$ and the raw mantissa $m_r$ is an integer in $[0,\n            /// 2^M-1]$.\n            ///\n            /// When the exponent is not `2^E-1`,\n            /// $$\n            /// f(m_r, e_r) = \\\\begin{cases}\n            ///     2^{2-2^{E-1}-M}m_r & \\text{if} \\\\quad e_r = 0, \\\\\\\\\n            ///     2^{e_r-2^{E-1}+1}(2^{-M}m_r+1) & \\textrm{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $M$ and $E$ are the mantissa width and exponent width, respectively.\n            ///\n            /// For zeros, infinities, or `NaN`, refer to [IEEE\n            /// 754](https://standards.ieee.org/ieee/754/6210/) or look at the examples below.\n            ///\n            /// This function only outputs a single, canonical, `NaN`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#from_raw_mantissa_and_exponent).\n            #[inline]\n            fn from_raw_mantissa_and_exponent(raw_mantissa: u64, raw_exponent: u64) -> $t {\n                from_raw_mantissa_and_exponent(raw_mantissa, raw_exponent)\n            }\n        }\n\n        impl IntegerMantissaAndExponent<u64, i64> for $t {\n            /// Returns the integer mantissa and exponent.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where\n            /// $e_i$ is an integer and $m_i$ is an odd integer.\n            /// $$\n            /// f(x) = (\\frac{|x|}{2^{e_i}}, e_i),\n            /// $$\n            /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n            ///\n            /// The inverse operation is [`Self::from_integer_mantissa_and_exponent`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero, infinite, or `NaN`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#integer_mantissa_and_exponent).\n            #[inline]\n            fn integer_mantissa_and_exponent(self) -> (u64, i64) {\n                integer_mantissa_and_exponent_primitive_float(self)\n            }\n\n            /// Returns the integer mantissa.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where\n            /// $e_i$ is an integer and $m_i$ is an odd integer.\n            /// $$\n            /// f(x) = \\frac{|x|}{2^{e_i}},\n            /// $$\n            /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero, infinite, or `NaN`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#integer_mantissa).\n            #[inline]\n            fn integer_mantissa(self) -> u64 {\n                integer_mantissa_primitive_float(self)\n            }\n\n            /// Returns the integer exponent.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where\n            /// $e_i$ is an integer and $m_i$ is an odd integer.\n            /// $$\n            /// f(x) = e_i,\n            /// $$\n            /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero, infinite, or `NaN`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#integer_exponent).\n            #[inline]\n            fn integer_exponent(self) -> i64 {\n                integer_exponent_primitive_float(self)\n            }\n\n            /// Constructs a float from its integer mantissa and exponent.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where\n            /// $e_i$ is an integer and $m_i$ is an odd integer.\n            ///\n            /// $$\n            /// f(x) = 2^{e_i}m_i,\n            /// $$\n            /// or `None` if the result cannot be exactly represented as a float of the desired type\n            /// (this happens if the exponent is too large or too small, or if the mantissa's\n            /// precision is too high for the exponent).\n            ///\n            /// The input does not have to be reduced; that is to say, the mantissa does not have to\n            /// be odd.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#from_integer_mantissa_and_exponent).\n            #[inline]\n            fn from_integer_mantissa_and_exponent(\n                integer_mantissa: u64,\n                integer_exponent: i64,\n            ) -> Option<$t> {\n                from_integer_mantissa_and_exponent_primitive_float(\n                    integer_mantissa,\n                    integer_exponent,\n                )\n            }\n        }\n\n        impl SciMantissaAndExponent<$t, i64> for $t {\n            /// Returns the scientific mantissa and exponent.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_s}m_s$, where\n            /// $e_s$ is an integer and $m_s$ is a rational number with $1 \\leq m_s < 2$. If $x$ is\n            /// a valid float, the scientific mantissa $m_s$ is always exactly representable as a\n            /// float of the same type. We have\n            /// $$\n            /// f(x) = (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}, \\lfloor \\log_2 x \\rfloor).\n            /// $$\n            ///\n            /// The inverse operation is `from_sci_mantissa_and_exponent`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero, infinite, or `NaN`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_mantissa_and_exponent).\n            #[inline]\n            fn sci_mantissa_and_exponent(self) -> ($t, i64) {\n                sci_mantissa_and_exponent_primitive_float(self)\n            }\n\n            /// Returns the scientific mantissa.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_s}m_s$, where\n            /// $e_s$ is an integer and $m_s$ is a rational number with $1 \\leq m_s < 2$. If $x$ is\n            /// a valid float, the scientific mantissa $m_s$ is always exactly representable as a\n            /// float of the same type. We have\n            /// $$\n            /// f(x) = \\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero, infinite, or `NaN`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_mantissa).\n            #[inline]\n            fn sci_mantissa(self) -> $t {\n                sci_mantissa_primitive_float(self)\n            }\n\n            /// Returns the scientific exponent.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_s}m_s$, where\n            /// $e_s$ is an integer and $m_s$ is a rational number with $1 \\leq m_s < 2$. We have\n            /// $$\n            /// f(x) = \\lfloor \\log_2 x \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero, infinite, or `NaN`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_exponent).\n            #[inline]\n            fn sci_exponent(self) -> i64 {\n                sci_exponent_primitive_float(self)\n            }\n\n            /// Constructs a float from its scientific mantissa and exponent.\n            ///\n            /// When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_s}m_s$, where\n            /// $e_s$ is an integer and $m_s$ is a rational number with $1 \\leq m_s < 2$.\n            ///\n            /// $$\n            /// f(x) = 2^{e_s}m_s,\n            /// $$\n            /// or `None` if the result cannot be exactly represented as a float of the desired type\n            /// (this happens if the exponent is too large or too small, if the mantissa is not in\n            /// the range $[1, 2)$, or if the mantissa's precision is too high for the exponent).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `mantissa` is zero, infinite, or `NaN`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#from_sci_mantissa_and_exponent).\n            #[inline]\n            fn from_sci_mantissa_and_exponent(sci_mantissa: $t, sci_exponent: i64) -> Option<$t> {\n                from_sci_mantissa_and_exponent_primitive_float(sci_mantissa, sci_exponent)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_mantissa_and_exponent_primitive_float);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Traits for working with the digits of numbers.\npub mod digits;\n/// Traits for converting between different number types. The traits are\n/// [`WrappingFrom`](traits::WrappingFrom), [`SaturatingFrom`](traits::SaturatingFrom),\n/// [`OverflowingFrom`](traits::OverflowingFrom), [`ConvertibleFrom`](traits::ConvertibleFrom), and\n/// [`RoundingFrom`](traits::RoundingFrom).\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::conversion::from::{\n///     PrimitiveFloatFromSignedError, PrimitiveFloatFromUnsignedError, SignedFromFloatError,\n///     UnsignedFromFloatError,\n/// };\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(NiceFloat::<f32>::try_from(100u8), Ok(NiceFloat(100.0)));\n/// assert_eq!(\n///     NiceFloat::<f32>::try_from(u32::MAX),\n///     Err(PrimitiveFloatFromUnsignedError)\n/// );\n/// assert_eq!(NiceFloat::<f32>::try_from(100i8), Ok(NiceFloat(100.0)));\n/// assert_eq!(\n///     NiceFloat::<f32>::try_from(i32::MAX),\n///     Err(PrimitiveFloatFromSignedError)\n/// );\n///\n/// assert_eq!(u8::try_from(NiceFloat(100.0f32)), Ok(100));\n/// assert_eq!(\n///     u8::try_from(NiceFloat(100.1f32)),\n///     Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     u8::try_from(NiceFloat(300.0f32)),\n///     Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     u8::try_from(NiceFloat(-100.0f32)),\n///     Err(UnsignedFromFloatError::FloatNegative)\n/// );\n/// assert_eq!(i8::try_from(NiceFloat(-100.0f32)), Ok(-100));\n/// assert_eq!(\n///     i8::try_from(NiceFloat(-200.0f32)),\n///     Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// ```\n///\n/// # wrapping_from\n/// ```\n/// use malachite_base::num::conversion::traits::WrappingFrom;\n///\n/// assert_eq!(u8::wrapping_from(123u8), 123);\n/// assert_eq!(i32::wrapping_from(-5i32), -5);\n///\n/// assert_eq!(u16::wrapping_from(123u8), 123);\n/// assert_eq!(i64::wrapping_from(-5i32), -5);\n/// assert_eq!(u32::wrapping_from(5u64), 5);\n///\n/// assert_eq!(u8::wrapping_from(1000u16), 232);\n/// assert_eq!(u32::wrapping_from(-5i32), 4294967291);\n/// assert_eq!(i32::wrapping_from(3000000000u32), -1294967296);\n/// assert_eq!(i8::wrapping_from(-1000i16), 24);\n/// ```\n///\n/// # saturating_from\n/// ```\n/// use malachite_base::num::conversion::traits::SaturatingFrom;\n///\n/// assert_eq!(u8::saturating_from(123u8), 123);\n/// assert_eq!(i32::saturating_from(-5i32), -5);\n///\n/// assert_eq!(u16::saturating_from(123u8), 123);\n/// assert_eq!(i64::saturating_from(-5i32), -5);\n/// assert_eq!(u32::saturating_from(5u64), 5);\n///\n/// assert_eq!(u8::saturating_from(1000u16), 255);\n/// assert_eq!(u32::saturating_from(-5i32), 0);\n/// assert_eq!(i32::saturating_from(3000000000u32), 2147483647);\n/// assert_eq!(i8::saturating_from(-1000i16), -128);\n/// ```\n///\n/// # overflowing_from\n/// ```\n/// use malachite_base::num::conversion::traits::OverflowingFrom;\n///\n/// assert_eq!(u8::overflowing_from(123u8), (123, false));\n/// assert_eq!(i32::overflowing_from(-5i32), (-5, false));\n///\n/// assert_eq!(u16::overflowing_from(123u8), (123, false));\n/// assert_eq!(i64::overflowing_from(-5i32), (-5, false));\n/// assert_eq!(u32::overflowing_from(5u64), (5, false));\n///\n/// assert_eq!(u8::overflowing_from(1000u16), (232, true));\n/// assert_eq!(u32::overflowing_from(-5i32), (4294967291, true));\n/// assert_eq!(i32::overflowing_from(3000000000u32), (-1294967296, true));\n/// assert_eq!(i8::overflowing_from(-1000i16), (24, true));\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n///\n/// assert_eq!(u8::convertible_from(123u8), true);\n/// assert_eq!(i32::convertible_from(-5i32), true);\n///\n/// assert_eq!(u16::convertible_from(123u8), true);\n/// assert_eq!(i64::convertible_from(-5i32), true);\n/// assert_eq!(u32::convertible_from(5u64), true);\n///\n/// assert_eq!(u8::convertible_from(1000u16), false);\n/// assert_eq!(u32::convertible_from(-5i32), false);\n/// assert_eq!(i32::convertible_from(3000000000u32), false);\n/// assert_eq!(i8::convertible_from(-1000i16), false);\n///\n/// assert_eq!(f32::convertible_from(100u8), true);\n/// assert_eq!(f32::convertible_from(u32::MAX), false);\n///\n/// assert_eq!(u8::convertible_from(100.0f32), true);\n/// assert_eq!(u8::convertible_from(100.1f32), false);\n/// assert_eq!(u8::convertible_from(300.0f32), false);\n/// assert_eq!(u8::convertible_from(-100.0f32), false);\n/// ```\n///\n/// # rounding_from\n/// ```\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(f32::rounding_from(100, Floor), (100.0, Equal));\n/// assert_eq!(f32::rounding_from(100, Down), (100.0, Equal));\n/// assert_eq!(f32::rounding_from(100, Ceiling), (100.0, Equal));\n/// assert_eq!(f32::rounding_from(100, Up), (100.0, Equal));\n/// assert_eq!(f32::rounding_from(100, Nearest), (100.0, Equal));\n/// assert_eq!(f32::rounding_from(100, Exact), (100.0, Equal));\n///\n/// assert_eq!(f32::rounding_from(i32::MAX, Floor), (2147483500.0, Less));\n/// assert_eq!(f32::rounding_from(i32::MAX, Down), (2147483500.0, Less));\n/// assert_eq!(\n///     f32::rounding_from(i32::MAX, Ceiling),\n///     (2147483600.0, Greater)\n/// );\n/// assert_eq!(f32::rounding_from(i32::MAX, Up), (2147483600.0, Greater));\n/// assert_eq!(\n///     f32::rounding_from(i32::MAX, Nearest),\n///     (2147483600.0, Greater)\n/// );\n///\n/// assert_eq!(u32::rounding_from(100.0f32, Floor), (100, Equal));\n/// assert_eq!(u32::rounding_from(100.0f32, Down), (100, Equal));\n/// assert_eq!(u32::rounding_from(100.0f32, Ceiling), (100, Equal));\n/// assert_eq!(u32::rounding_from(100.0f32, Up), (100, Equal));\n/// assert_eq!(u32::rounding_from(100.0f32, Nearest), (100, Equal));\n/// assert_eq!(u32::rounding_from(100.0f32, Exact), (100, Equal));\n///\n/// assert_eq!(u32::rounding_from(100.5f32, Floor), (100, Less));\n/// assert_eq!(u32::rounding_from(100.5f32, Down), (100, Less));\n/// assert_eq!(u32::rounding_from(100.5f32, Ceiling), (101, Greater));\n/// assert_eq!(u32::rounding_from(100.5f32, Up), (101, Greater));\n/// assert_eq!(u32::rounding_from(100.5f32, Nearest), (100, Less));\n/// ```\npub mod from;\n/// [`JoinHalves`](traits::JoinHalves) and [`SplitInHalf`](traits::SplitInHalf), traits for joining\n/// the bits of two numbers or for splitting a number in half.\n///\n/// # join_halves\n/// ```\n/// use malachite_base::num::conversion::traits::JoinHalves;\n///\n/// assert_eq!(u16::join_halves(1, 2), 258);\n/// assert_eq!(u32::join_halves(0xabcd, 0x1234), 0xabcd1234);\n/// ```\n///\n/// # split_in_half\n/// ```\n/// use malachite_base::num::conversion::traits::SplitInHalf;\n///\n/// assert_eq!(258u16.split_in_half(), (1, 2));\n/// assert_eq!(0xabcd1234u32.split_in_half(), (0xabcd, 0x1234));\n/// ```\n///\n/// # lower_half\n/// ```\n/// use malachite_base::num::conversion::traits::SplitInHalf;\n///\n/// assert_eq!(258u16.lower_half(), 2);\n/// assert_eq!(0xabcd1234u32.lower_half(), 0x1234);\n/// ```\n///\n/// # upper_half\n/// ```\n/// use malachite_base::num::conversion::traits::SplitInHalf;\n///\n/// assert_eq!(258u16.upper_half(), 1);\n/// assert_eq!(0xabcd1234u32.upper_half(), 0xabcd);\n/// ```\npub mod half;\n/// [`IsInteger`](traits::IsInteger), a trait for determining whether a value is an integer.\n///\n/// # is_integer\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::conversion::traits::IsInteger;\n///\n/// assert_eq!(0.is_integer(), true);\n/// assert_eq!(1.is_integer(), true);\n/// assert_eq!(100.is_integer(), true);\n/// assert_eq!((-1).is_integer(), true);\n/// assert_eq!((-100).is_integer(), true);\n///\n/// assert_eq!(0.0.is_integer(), true);\n/// assert_eq!(1.0.is_integer(), true);\n/// assert_eq!(100.0.is_integer(), true);\n/// assert_eq!((-1.0).is_integer(), true);\n/// assert_eq!((-100.0).is_integer(), true);\n///\n/// assert_eq!(0.1.is_integer(), false);\n/// assert_eq!(100.1.is_integer(), false);\n/// assert_eq!(f32::NAN.is_integer(), false);\n/// assert_eq!(f32::INFINITY.is_integer(), false);\n/// assert_eq!(f32::NEGATIVE_INFINITY.is_integer(), false);\n/// ```\npub mod is_integer;\n/// Traits for converting numbers to and from mantissa and exponent representations.\n///\n/// See [`PrimitiveFloat`](super::basic::floats::PrimitiveFloat) for a description of the different\n/// types of mantissas and exponents. The traits are\n/// [`RawMantissaAndExponent`](traits::RawMantissaAndExponent),\n/// [`IntegerMantissaAndExponent`](traits::IntegerMantissaAndExponent), and\n/// [`SciMantissaAndExponent`](traits::SciMantissaAndExponent).\n///\n/// # raw_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::conversion::traits::RawMantissaAndExponent;\n///\n/// assert_eq!(0.0f32.raw_mantissa_and_exponent(), (0, 0));\n/// assert_eq!((-0.0f32).raw_mantissa_and_exponent(), (0, 0));\n/// assert_eq!(f32::NAN.raw_mantissa_and_exponent(), (0x400000, 255));\n/// assert_eq!(f32::INFINITY.raw_mantissa_and_exponent(), (0, 255));\n/// assert_eq!(f32::NEGATIVE_INFINITY.raw_mantissa_and_exponent(), (0, 255));\n/// assert_eq!(1.0f32.raw_mantissa_and_exponent(), (0, 127));\n/// assert_eq!(\n///     core::f32::consts::PI.raw_mantissa_and_exponent(),\n///     (4788187, 128)\n/// );\n/// assert_eq!(0.1f32.raw_mantissa_and_exponent(), (5033165, 123));\n/// ```\n///\n/// # raw_mantissa\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::conversion::traits::RawMantissaAndExponent;\n///\n/// assert_eq!(0.0f32.raw_mantissa(), 0);\n/// assert_eq!((-0.0f32).raw_mantissa(), 0);\n/// assert_eq!(f32::NAN.raw_mantissa(), 0x400000);\n/// assert_eq!(f32::INFINITY.raw_mantissa(), 0);\n/// assert_eq!(f32::NEGATIVE_INFINITY.raw_mantissa(), 0);\n/// assert_eq!(1.0f32.raw_mantissa(), 0);\n/// assert_eq!(core::f32::consts::PI.raw_mantissa(), 4788187);\n/// assert_eq!(0.1f32.raw_mantissa(), 5033165);\n/// ```\n///\n/// # raw_exponent\n///\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::conversion::traits::RawMantissaAndExponent;\n///\n/// assert_eq!(0.0f32.raw_exponent(), 0);\n/// assert_eq!((-0.0f32).raw_exponent(), 0);\n/// assert_eq!(f32::NAN.raw_exponent(), 255);\n/// assert_eq!(f32::INFINITY.raw_exponent(), 255);\n/// assert_eq!(f32::NEGATIVE_INFINITY.raw_exponent(), 255);\n/// assert_eq!(1.0f32.raw_exponent(), 127);\n/// assert_eq!(core::f32::consts::PI.raw_exponent(), 128);\n/// assert_eq!(0.1f32.raw_exponent(), 123);\n/// ```\n///\n/// # from_raw_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::conversion::traits::RawMantissaAndExponent;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     NiceFloat(f32::from_raw_mantissa_and_exponent(0, 0)),\n///     NiceFloat(0.0)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::from_raw_mantissa_and_exponent(0x400000, 255)),\n///     NiceFloat(f32::NAN)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::from_raw_mantissa_and_exponent(0, 255)),\n///     NiceFloat(f32::INFINITY)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::from_raw_mantissa_and_exponent(0, 127)),\n///     NiceFloat(1.0)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::from_raw_mantissa_and_exponent(4788187, 128)),\n///     NiceFloat(core::f32::consts::PI)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::from_raw_mantissa_and_exponent(5033165, 123)),\n///     NiceFloat(0.1)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::from_raw_mantissa_and_exponent(2097152, 130)),\n///     NiceFloat(10.0)\n/// );\n/// ```\n///\n/// # integer_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n///\n/// assert_eq!(1u8.integer_mantissa_and_exponent(), (1, 0));\n/// assert_eq!(2u8.integer_mantissa_and_exponent(), (1, 1));\n/// assert_eq!(3u8.integer_mantissa_and_exponent(), (3, 0));\n/// assert_eq!(100u8.integer_mantissa_and_exponent(), (25, 2));\n///\n/// assert_eq!(\n///     core::f32::consts::PI.integer_mantissa_and_exponent(),\n///     (13176795, -22)\n/// );\n/// assert_eq!(0.1f32.integer_mantissa_and_exponent(), (13421773, -27));\n/// assert_eq!(10.0f32.integer_mantissa_and_exponent(), (5, 1));\n/// assert_eq!(\n///     f32::MIN_POSITIVE_SUBNORMAL.integer_mantissa_and_exponent(),\n///     (1, -149)\n/// );\n/// assert_eq!(\n///     f32::MAX_SUBNORMAL.integer_mantissa_and_exponent(),\n///     (0x7fffff, -149)\n/// );\n/// assert_eq!(\n///     f32::MIN_POSITIVE_NORMAL.integer_mantissa_and_exponent(),\n///     (1, -126)\n/// );\n/// assert_eq!(\n///     f32::MAX_FINITE.integer_mantissa_and_exponent(),\n///     (0xffffff, 104)\n/// );\n/// ```\n///\n/// # integer_mantissa\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n///\n/// assert_eq!(1u8.integer_mantissa(), 1);\n/// assert_eq!(2u8.integer_mantissa(), 1);\n/// assert_eq!(3u8.integer_mantissa(), 3);\n/// assert_eq!(100u8.integer_mantissa(), 25);\n///\n/// assert_eq!(1.0f32.integer_mantissa(), 1);\n/// assert_eq!(core::f32::consts::PI.integer_mantissa(), 13176795);\n/// assert_eq!(0.1f32.integer_mantissa(), 13421773);\n/// assert_eq!(10.0f32.integer_mantissa(), 5);\n/// assert_eq!(f32::MIN_POSITIVE_SUBNORMAL.integer_mantissa(), 1);\n/// assert_eq!(f32::MAX_SUBNORMAL.integer_mantissa(), 0x7fffff);\n/// assert_eq!(f32::MIN_POSITIVE_NORMAL.integer_mantissa(), 1);\n/// assert_eq!(f32::MAX_FINITE.integer_mantissa(), 0xffffff);\n/// ```\n///\n/// # integer_exponent\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n///\n/// assert_eq!(1u8.integer_exponent(), 0);\n/// assert_eq!(2u8.integer_exponent(), 1);\n/// assert_eq!(3u8.integer_exponent(), 0);\n/// assert_eq!(100u8.integer_exponent(), 2);\n///\n/// assert_eq!(1.0f32.integer_exponent(), 0);\n/// assert_eq!(core::f32::consts::PI.integer_exponent(), -22);\n/// assert_eq!(0.1f32.integer_exponent(), -27);\n/// assert_eq!(10.0f32.integer_exponent(), 1);\n/// assert_eq!(f32::MIN_POSITIVE_SUBNORMAL.integer_exponent(), -149);\n/// assert_eq!(f32::MAX_SUBNORMAL.integer_exponent(), -149);\n/// assert_eq!(f32::MIN_POSITIVE_NORMAL.integer_exponent(), -126);\n/// assert_eq!(f32::MAX_FINITE.integer_exponent(), 104);\n/// ```\n///\n/// # from_integer_mantissa_and_exponent;\n/// ```\n/// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(u8::from_integer_mantissa_and_exponent(0, 1), Some(0));\n/// assert_eq!(u8::from_integer_mantissa_and_exponent(1, 0), Some(1));\n/// assert_eq!(u8::from_integer_mantissa_and_exponent(1, 1), Some(2));\n/// assert_eq!(u8::from_integer_mantissa_and_exponent(3, 0), Some(3));\n/// assert_eq!(u8::from_integer_mantissa_and_exponent(25, 2), Some(100));\n///\n/// assert_eq!(\n///     f32::from_integer_mantissa_and_exponent(0, 5).map(NiceFloat),\n///     Some(NiceFloat(0.0))\n/// );\n/// assert_eq!(\n///     f32::from_integer_mantissa_and_exponent(1, 0).map(NiceFloat),\n///     Some(NiceFloat(1.0))\n/// );\n/// assert_eq!(\n///     f32::from_integer_mantissa_and_exponent(4, -2).map(NiceFloat),\n///     Some(NiceFloat(1.0))\n/// );\n/// assert_eq!(\n///     f32::from_integer_mantissa_and_exponent(13176795, -22).map(NiceFloat),\n///     Some(NiceFloat(core::f32::consts::PI))\n/// );\n/// assert_eq!(\n///     f32::from_integer_mantissa_and_exponent(13421773, -27).map(NiceFloat),\n///     Some(NiceFloat(0.1))\n/// );\n/// assert_eq!(\n///     f32::from_integer_mantissa_and_exponent(5, 1).map(NiceFloat),\n///     Some(NiceFloat(10.0))\n/// );\n///\n/// assert_eq!(f32::from_integer_mantissa_and_exponent(5, 10000), None);\n/// assert_eq!(f32::from_integer_mantissa_and_exponent(5, -10000), None);\n/// // In the next 3 examples, the precision is too high.\n/// assert_eq!(f32::from_integer_mantissa_and_exponent(u64::MAX, -32), None);\n/// assert_eq!(f32::from_integer_mantissa_and_exponent(3, -150), None);\n/// assert_eq!(f32::from_integer_mantissa_and_exponent(1, 128), None);\n/// ```\n///\n/// # sci_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// let test = |n: u32, mantissa: f32, exponent: u64| {\n///     let (m, e) = n.sci_mantissa_and_exponent();\n///     assert_eq!(NiceFloat(m), NiceFloat(mantissa));\n///     assert_eq!(e, exponent);\n/// };\n/// test(3, 1.5, 1);\n/// test(123, 1.921875, 6);\n/// test(1000000000, 1.8626451, 29);\n///\n/// let test = |x: f32, mantissa: f32, exponent: i64| {\n///     let (actual_mantissa, actual_exponent) = x.sci_mantissa_and_exponent();\n///     assert_eq!(NiceFloat(actual_mantissa), NiceFloat(mantissa));\n///     assert_eq!(actual_exponent, exponent);\n/// };\n/// test(1.0, 1.0, 0);\n/// test(core::f32::consts::PI, 1.5707964, 1);\n/// test(0.1, 1.6, -4);\n/// test(10.0, 1.25, 3);\n/// test(f32::MIN_POSITIVE_SUBNORMAL, 1.0, -149);\n/// test(f32::MAX_SUBNORMAL, 1.9999998, -127);\n/// test(f32::MIN_POSITIVE_NORMAL, 1.0, -126);\n/// test(f32::MAX_FINITE, 1.9999999, 127);\n/// ```\n///\n/// # sci_mantissa\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(NiceFloat(1.0f32.sci_mantissa()), NiceFloat(1.0));\n/// assert_eq!(\n///     NiceFloat(core::f32::consts::PI.sci_mantissa()),\n///     NiceFloat(1.5707964)\n/// );\n/// assert_eq!(NiceFloat(0.1f32.sci_mantissa()), NiceFloat(1.6));\n/// assert_eq!(NiceFloat(10.0f32.sci_mantissa()), NiceFloat(1.25));\n/// assert_eq!(\n///     NiceFloat(f32::MIN_POSITIVE_SUBNORMAL.sci_mantissa()),\n///     NiceFloat(1.0)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::MAX_SUBNORMAL.sci_mantissa()),\n///     NiceFloat(1.9999998)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::MIN_POSITIVE_NORMAL.sci_mantissa()),\n///     NiceFloat(1.0)\n/// );\n/// assert_eq!(\n///     NiceFloat(f32::MAX_FINITE.sci_mantissa()),\n///     NiceFloat(1.9999999)\n/// );\n/// ```\n///\n/// # sci_exponent\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n///\n/// assert_eq!(1.0f32.sci_exponent(), 0);\n/// assert_eq!(core::f32::consts::PI.sci_exponent(), 1);\n/// assert_eq!(0.1f32.sci_exponent(), -4);\n/// assert_eq!(10.0f32.sci_exponent(), 3);\n/// assert_eq!(f32::MIN_POSITIVE_SUBNORMAL.sci_exponent(), -149);\n/// assert_eq!(f32::MAX_SUBNORMAL.sci_exponent(), -127);\n/// assert_eq!(f32::MIN_POSITIVE_NORMAL.sci_exponent(), -126);\n/// assert_eq!(f32::MAX_FINITE.sci_exponent(), 127);\n/// ```\n///\n/// # from_sci_mantissa_and_exponent;\n/// ```\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(u32::from_sci_mantissa_and_exponent(1.5, 1u64), Some(3u32));\n/// assert_eq!(u32::from_sci_mantissa_and_exponent(1.51, 1u64), Some(3u32));\n/// assert_eq!(\n///     u32::from_sci_mantissa_and_exponent(1.921875, 6u64),\n///     Some(123u32)\n/// );\n/// assert_eq!(u32::from_sci_mantissa_and_exponent(1.5, 1u64), Some(3u32));\n///\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.0, 0).map(NiceFloat),\n///     Some(NiceFloat(1.0))\n/// );\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.5707964, 1).map(NiceFloat),\n///     Some(NiceFloat(core::f32::consts::PI))\n/// );\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.6, -4).map(NiceFloat),\n///     Some(NiceFloat(0.1))\n/// );\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.25, 3).map(NiceFloat),\n///     Some(NiceFloat(10.0))\n/// );\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.0, -149).map(NiceFloat),\n///     Some(NiceFloat(f32::MIN_POSITIVE_SUBNORMAL))\n/// );\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.9999998, -127).map(NiceFloat),\n///     Some(NiceFloat(f32::MAX_SUBNORMAL))\n/// );\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.0, -126).map(NiceFloat),\n///     Some(NiceFloat(f32::MIN_POSITIVE_NORMAL))\n/// );\n/// assert_eq!(\n///     f32::from_sci_mantissa_and_exponent(1.9999999, 127).map(NiceFloat),\n///     Some(NiceFloat(f32::MAX_FINITE))\n/// );\n///\n/// assert_eq!(f32::from_sci_mantissa_and_exponent(2.0, 1), None);\n/// assert_eq!(f32::from_sci_mantissa_and_exponent(1.1, -2000), None);\n/// assert_eq!(f32::from_sci_mantissa_and_exponent(1.1, 2000), None);\n/// assert_eq!(f32::from_sci_mantissa_and_exponent(1.999, -149), None);\n/// ```\npub mod mantissa_and_exponent;\n/// Traits for converting slices to numbers, slices to [`Vec`]s, or numbers to [`Vec`]s. The traits\n/// are [`FromOtherTypeSlice`](traits::FromOtherTypeSlice),\n/// [`VecFromOtherTypeSlice`](traits::VecFromOtherTypeSlice), and\n/// [`VecFromOtherType`](traits::VecFromOtherType).\n///\n/// # from_other_type_slice\n/// ```\n/// use malachite_base::num::conversion::traits::FromOtherTypeSlice;\n///\n/// let xs: &[u32] = &[];\n/// assert_eq!(u32::from_other_type_slice(xs), 0);\n/// assert_eq!(u32::from_other_type_slice(&[123u32, 456]), 123);\n///\n/// assert_eq!(u8::from_other_type_slice(&[0xabcdu16, 0xef01]), 0xcd);\n///\n/// assert_eq!(u16::from_other_type_slice(&[0xabu8, 0xcd, 0xef]), 0xcdab);\n/// assert_eq!(u64::from_other_type_slice(&[0xabu8, 0xcd, 0xef]), 0xefcdab);\n/// ```\n///\n/// # vec_from_other_type_slice\n/// ```\n/// use malachite_base::num::conversion::traits::VecFromOtherTypeSlice;\n///\n/// assert_eq!(u32::vec_from_other_type_slice(&[123u32, 456]), &[123, 456]);\n/// assert_eq!(\n///     u8::vec_from_other_type_slice(&[0xcdabu16, 0x01ef, 0x4523, 0x8967]),\n///     &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89]\n/// );\n/// assert_eq!(\n///     u16::vec_from_other_type_slice(&[0xabu8, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),\n///     &[0xcdab, 0x01ef, 0x4523, 0x67]\n/// );\n/// ```\n///\n/// # vec_from_other_type\n/// ```\n/// use malachite_base::num::conversion::traits::VecFromOtherType;\n///\n/// assert_eq!(u32::vec_from_other_type(123u32), &[123]);\n/// assert_eq!(u8::vec_from_other_type(0xcdabu16), &[0xab, 0xcd]);\n/// assert_eq!(u16::vec_from_other_type(0xabu8), &[0xab]);\n/// ```\npub mod slice;\n/// Traits for converting numbers to and from [`String`]s.\npub mod string;\n/// Various traits for converting numbers.\npub mod traits;\n"
  },
  {
    "path": "malachite-base/src/num/conversion/slice.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::ShrRound;\nuse crate::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{\n    FromOtherTypeSlice, SplitInHalf, VecFromOtherType, VecFromOtherTypeSlice, WrappingFrom,\n};\nuse crate::rounding_modes::RoundingMode::*;\nuse alloc::vec;\nuse alloc::vec::Vec;\n\nconst fn from_other_type_slice_ident<T: PrimitiveUnsigned>(xs: &[T]) -> T {\n    if xs.is_empty() { T::ZERO } else { xs[0] }\n}\n\nmacro_rules! impl_slice_traits_ident {\n    ($a:ty) => {\n        impl FromOtherTypeSlice<$a> for $a {\n            /// Converts a slice of one type of value to a single value of the same type.\n            ///\n            /// $$\n            /// f((x_k)_{k=0}^{n-1}) = \\\\begin{cases}\n            ///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n            ///     x_0 & \\\\text{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is the width of the type.\n            ///\n            /// The slice is interpreted as the base-$2^W$ digits of the value, in ascending order,\n            /// where $W$ is the width of the type. If there's more than one element in the input\n            /// slice, the value wraps and all elements past the first are ignored. This means that\n            /// if the slice is empty, the output value is 0; otherwise, it's the first element of\n            /// the slice.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::slice#from_other_type_slice).\n            #[inline]\n            fn from_other_type_slice(xs: &[$a]) -> Self {\n                from_other_type_slice_ident(xs)\n            }\n        }\n\n        impl VecFromOtherTypeSlice<$a> for $a {\n            /// Converts a slice of one type of value to a [`Vec`] of the same type.\n            ///\n            /// In this case, it just converts the slice to a [`Vec`] the usual way.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n            ///\n            /// # Examples\n            /// See [here](super::slice#vec_from_other_type_slice).\n            #[inline]\n            fn vec_from_other_type_slice(xs: &[$a]) -> Vec<Self> {\n                xs.to_vec()\n            }\n        }\n\n        impl VecFromOtherType<$a> for $a {\n            /// Converts a value of one type to a [`Vec`] of the same type.\n            ///\n            /// In this case, it just creates a one-element [`Vec`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::slice#vec_from_other_type).\n            #[inline]\n            fn vec_from_other_type(x: $a) -> Vec<Self> {\n                ::alloc::vec![x]\n            }\n        }\n    };\n}\n\nfn from_other_type_slice_large_to_small<\n    A: PrimitiveUnsigned,\n    B: PrimitiveUnsigned + WrappingFrom<A>,\n>(\n    xs: &[A],\n) -> B {\n    if xs.is_empty() {\n        B::ZERO\n    } else {\n        B::wrapping_from(xs[0])\n    }\n}\n\nfn vec_from_other_type_slice_large_to_small<\n    A: PrimitiveUnsigned,\n    B: PrimitiveUnsigned + WrappingFrom<A>,\n>(\n    xs: &[A],\n) -> Vec<B> {\n    let log_size_ratio = A::LOG_WIDTH - B::LOG_WIDTH;\n    let mut out = ::alloc::vec![B::ZERO; xs.len() << log_size_ratio];\n    for (chunk, &u) in out.chunks_exact_mut(1 << log_size_ratio).zip(xs.iter()) {\n        let mut u = u;\n        for x in chunk {\n            *x = B::wrapping_from(u);\n            u >>= B::WIDTH;\n        }\n    }\n    out\n}\n\nfn vec_from_other_type_large_to_small<\n    A: PrimitiveUnsigned,\n    B: PrimitiveUnsigned + WrappingFrom<A>,\n>(\n    mut x: A,\n) -> Vec<B> {\n    let mut xs = ::alloc::vec![B::ZERO; 1 << (A::LOG_WIDTH - B::LOG_WIDTH)];\n    for out in &mut xs {\n        *out = B::wrapping_from(x);\n        x >>= B::WIDTH;\n    }\n    xs\n}\n\nmacro_rules! impl_slice_traits_large_to_small {\n    ($a:ident, $b:ident) => {\n        impl FromOtherTypeSlice<$a> for $b {\n            /// Converts a slice of one type of unsigned integer to a single value of a smaller\n            /// unsigned type.\n            ///\n            /// $$\n            /// f((x_k)_{k=0}^{n-1}) = \\\\begin{cases}\n            ///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n            ///     y & \\\\text{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $0 \\leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of\n            /// the output type.\n            ///\n            /// The slice is interpreted as the base-$2^W$ digits of the value, in ascending order,\n            /// where $W$ is the width of the type. If the slice is empty, the output value is 0;\n            /// otherwise, it consists of the least-significant bits of the first element of the\n            /// slice.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::slice#from_other_type_slice).\n            #[inline]\n            fn from_other_type_slice(xs: &[$a]) -> Self {\n                from_other_type_slice_large_to_small(xs)\n            }\n        }\n\n        impl VecFromOtherTypeSlice<$a> for $b {\n            /// Converts a slice of one type of unsigned integer to a [`Vec`] of a smaller unsigned\n            /// type.\n            ///\n            /// Each value of the input slice will be broken up into several values in the output\n            /// [`Vec`].\n            ///\n            /// Let $V$ be the the width of the input type and $W$ the width of the output type.\n            ///\n            /// $f((x_k)_ {k=0}^{n-1}) = (y_k)_ {k=0}^{m-1}$, where\n            ///\n            /// $$\n            /// \\sum_{j=0}^{n-1}2^{jV}x_j = \\sum_{j=0}^{m-1}2^{jW}y_j,\n            /// $$\n            ///\n            /// $y_j < 2^W$ for all $j$, and $m = 2^{V-W}n$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n            ///\n            /// # Examples\n            /// See [here](super::slice#vec_from_other_type_slice).\n            #[inline]\n            fn vec_from_other_type_slice(xs: &[$a]) -> Vec<Self> {\n                vec_from_other_type_slice_large_to_small(xs)\n            }\n        }\n\n        impl VecFromOtherType<$a> for $b {\n            /// Converts a value of one type of unsigned integer to a [`Vec`] of a smaller unsigned\n            /// type.\n            ///\n            /// The input value will be broken up into several values in the output [`Vec`].\n            ///\n            /// $f(x) = (y_k)_{k=0}^{m-1}$, where $x = \\sum_{j=0}^{m-1}2^{jW}y_j$ and $m =\n            /// 2^{V-W}n$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::slice#vec_from_other_type).\n            #[inline]\n            fn vec_from_other_type(x: $a) -> Vec<Self> {\n                vec_from_other_type_large_to_small(x)\n            }\n        }\n    };\n}\n\nfn from_other_type_slice_small_to_large<\n    A: PrimitiveUnsigned,\n    B: PrimitiveUnsigned + WrappingFrom<A>,\n>(\n    xs: &[A],\n) -> B {\n    let mut result = B::ZERO;\n    let mut offset = 0;\n    for &u in xs.iter().take(1 << (B::LOG_WIDTH - A::LOG_WIDTH)) {\n        result |= B::wrapping_from(u) << offset;\n        offset += A::WIDTH;\n    }\n    result\n}\n\nfn vec_from_other_type_slice_small_to_large<\n    A: PrimitiveUnsigned,\n    B: PrimitiveUnsigned + WrappingFrom<A>,\n>(\n    xs: &[A],\n) -> Vec<B> {\n    let log_size_ratio = B::LOG_WIDTH - A::LOG_WIDTH;\n    let mut out = ::alloc::vec![B::ZERO; xs.len().shr_round(log_size_ratio, Ceiling).0];\n    for (x, chunk) in out.iter_mut().zip(xs.chunks(1 << log_size_ratio)) {\n        *x = from_other_type_slice_small_to_large(chunk);\n    }\n    out\n}\n\nfn vec_from_other_type_small_to_large<A, B: WrappingFrom<A>>(x: A) -> Vec<B> {\n    ::alloc::vec![B::wrapping_from(x)]\n}\n\nmacro_rules! impl_slice_traits_small_to_large {\n    ($a:ident, $b:ident) => {\n        impl FromOtherTypeSlice<$a> for $b {\n            /// Converts a slice of one type of unsigned integer to a single value of a larger\n            /// unsigned type.\n            ///\n            /// Let $V$ be the the width of the input type and $W$ the width of the output type.\n            ///\n            /// $f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and\n            ///\n            /// $$\n            /// y = k2^W + \\sum_{j=0}^{n-1}2^{jV}x_j\n            /// $$\n            ///\n            /// for some integer $k$.\n            ///\n            /// If the input slice contains more values than necessary to build an output value, the\n            /// trailing values are ignored. If the input slice contains too few values to build an\n            /// output value, the most-significant bits of the output value are set to 0.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::slice#from_other_type_slice).\n            #[inline]\n            fn from_other_type_slice(xs: &[$a]) -> Self {\n                from_other_type_slice_small_to_large(xs)\n            }\n        }\n\n        impl VecFromOtherTypeSlice<$a> for $b {\n            /// Converts a slice of one type of unsigned integer to a [`Vec`] of a larger unsigned\n            /// type.\n            ///\n            /// Adjacent chunks of values in the input slice will be joined into values of the\n            /// output [`Vec`]. If the last few elements of the input slice don't make up a full\n            /// chunk, the most-significant bits of the last output value are set to 0.\n            ///\n            /// Let $V$ be the the width of the input type and $W$ the width of the output type.\n            ///\n            /// $f((x_k)_ {k=0}^{n-1}) = (y_k)_ {k=0}^{m-1}$, where\n            ///\n            /// $$\n            /// \\sum_{j=0}^{n-1}2^{jV}x_j = \\sum_{j=0}^{m-1}2^{jW}y_j,\n            /// $$\n            ///\n            /// $y_j < 2^W$ for all $j$, and $m = \\lceil n / 2^{W-V} \\rceil$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n            ///\n            /// # Examples\n            /// See [here](super::slice#vec_from_other_type_slice).\n            #[inline]\n            fn vec_from_other_type_slice(xs: &[$a]) -> Vec<Self> {\n                vec_from_other_type_slice_small_to_large(xs)\n            }\n        }\n\n        impl VecFromOtherType<$a> for $b {\n            /// Converts a value of one type of unsigned integer to a [`Vec`] of a larger unsigned\n            /// type.\n            ///\n            /// The output [`Vec`] only contains one value. The least-significant bits of the output\n            /// value contain the input value, and the most-significant bits are set to 0.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::slice#vec_from_other_type).\n            #[inline]\n            fn vec_from_other_type(x: $a) -> Vec<Self> {\n                vec_from_other_type_small_to_large(x)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_slice_traits_ident);\n\nimpl_slice_traits_large_to_small!(u16, u8);\nimpl_slice_traits_large_to_small!(u32, u8);\nimpl_slice_traits_large_to_small!(u32, u16);\nimpl_slice_traits_large_to_small!(u64, u8);\nimpl_slice_traits_large_to_small!(u64, u16);\nimpl_slice_traits_large_to_small!(u64, u32);\nimpl_slice_traits_large_to_small!(u128, u8);\nimpl_slice_traits_large_to_small!(u128, u16);\nimpl_slice_traits_large_to_small!(u128, u32);\nimpl_slice_traits_large_to_small!(u128, u64);\nimpl_slice_traits_large_to_small!(u128, usize);\nimpl_slice_traits_large_to_small!(usize, u8);\nimpl_slice_traits_large_to_small!(usize, u16);\n\nimpl_slice_traits_small_to_large!(u8, u16);\nimpl_slice_traits_small_to_large!(u8, u32);\nimpl_slice_traits_small_to_large!(u8, u64);\nimpl_slice_traits_small_to_large!(u8, u128);\nimpl_slice_traits_small_to_large!(u8, usize);\nimpl_slice_traits_small_to_large!(u16, u32);\nimpl_slice_traits_small_to_large!(u16, u64);\nimpl_slice_traits_small_to_large!(u16, u128);\nimpl_slice_traits_small_to_large!(u16, usize);\nimpl_slice_traits_small_to_large!(u32, u64);\nimpl_slice_traits_small_to_large!(u32, u128);\nimpl_slice_traits_small_to_large!(u64, u128);\nimpl_slice_traits_small_to_large!(usize, u128);\n\nimpl FromOtherTypeSlice<u32> for usize {\n    /// Converts a slice of `u32`s to a single `usize`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#from_other_type_slice).\n    fn from_other_type_slice(xs: &[u32]) -> Self {\n        if USIZE_IS_U32 {\n            if xs.is_empty() {\n                0\n            } else {\n                Self::wrapping_from(xs[0])\n            }\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            let mut result = 0;\n            let mut offset = 0;\n            for &u in xs.iter().take(2) {\n                result |= Self::wrapping_from(u) << offset;\n                offset += u32::WIDTH;\n            }\n            result\n        }\n    }\n}\n\nimpl VecFromOtherTypeSlice<u32> for usize {\n    /// Converts a slice of [`u32`]s to a [`Vec`] of [`usize`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// See [here](super::slice#vec_from_other_type_slice).\n    fn vec_from_other_type_slice(xs: &[u32]) -> Vec<Self> {\n        let mut out;\n        if USIZE_IS_U32 {\n            out = vec![0; xs.len()];\n            for (x, &u) in out.iter_mut().zip(xs.iter()) {\n                *x = Self::wrapping_from(u);\n            }\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            out = vec![0; xs.len().shr_round(1, Ceiling).0];\n            for (x, chunk) in out.iter_mut().zip(xs.chunks(2)) {\n                *x = Self::from_other_type_slice(chunk);\n            }\n        }\n        out\n    }\n}\n\nimpl VecFromOtherType<u32> for usize {\n    /// Converts a [`u32`] to a [`Vec`] of [`usize`]s.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#vec_from_other_type).\n    #[inline]\n    fn vec_from_other_type(x: u32) -> Vec<Self> {\n        vec![Self::wrapping_from(x)]\n    }\n}\n\nimpl FromOtherTypeSlice<u64> for usize {\n    /// Converts a slice of [`u64`]s to a single [`usize`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#from_other_type_slice).\n    #[inline]\n    fn from_other_type_slice(xs: &[u64]) -> Self {\n        if xs.is_empty() {\n            0\n        } else {\n            Self::wrapping_from(xs[0])\n        }\n    }\n}\n\nimpl VecFromOtherTypeSlice<u64> for usize {\n    /// Converts a slice of [`u64`]s to a [`Vec`] of [`usize`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// See [here](super::slice#vec_from_other_type_slice).\n    #[allow(arithmetic_overflow)]\n    fn vec_from_other_type_slice(xs: &[u64]) -> Vec<Self> {\n        let mut out;\n        if USIZE_IS_U32 {\n            out = ::alloc::vec![0; xs.len() << 1];\n            for (chunk, &u) in out.chunks_exact_mut(2).zip(xs.iter()) {\n                let mut u = u;\n                for x in chunk {\n                    *x = Self::wrapping_from(u);\n                    u >>= Self::WIDTH;\n                }\n            }\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            out = ::alloc::vec![0; xs.len()];\n            for (x, &u) in out.iter_mut().zip(xs.iter()) {\n                *x = Self::wrapping_from(u);\n            }\n        }\n        out\n    }\n}\n\nimpl VecFromOtherType<u64> for usize {\n    /// Converts a [`u64`] to a [`Vec`] of [`usize`]s.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#vec_from_other_type).\n    fn vec_from_other_type(x: u64) -> Vec<Self> {\n        if USIZE_IS_U32 {\n            let (upper, lower) = x.split_in_half();\n            ::alloc::vec![Self::wrapping_from(lower), Self::wrapping_from(upper)]\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            ::alloc::vec![Self::wrapping_from(x)]\n        }\n    }\n}\n\nimpl FromOtherTypeSlice<usize> for u32 {\n    /// Converts a slice of [`usize`]s to a single [`u32`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#from_other_type_slice).\n    #[inline]\n    fn from_other_type_slice(xs: &[usize]) -> Self {\n        if xs.is_empty() {\n            0\n        } else {\n            Self::wrapping_from(xs[0])\n        }\n    }\n}\n\nimpl VecFromOtherTypeSlice<usize> for u32 {\n    /// Converts a slice of [`usize`]s to a [`Vec`] of [`u32`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// See [here](super::slice#vec_from_other_type_slice).\n    #[allow(arithmetic_overflow)]\n    fn vec_from_other_type_slice(xs: &[usize]) -> Vec<Self> {\n        let mut out;\n        if USIZE_IS_U32 {\n            out = ::alloc::vec![0; xs.len()];\n            for (x, &u) in out.iter_mut().zip(xs.iter()) {\n                *x = Self::wrapping_from(u);\n            }\n        } else {\n            assert_eq!(usize::WIDTH, u64::WIDTH);\n            out = ::alloc::vec![0; xs.len() << 1];\n            for (chunk, &u) in out.chunks_exact_mut(2).zip(xs.iter()) {\n                let mut u = u;\n                for x in chunk {\n                    *x = Self::wrapping_from(u);\n                    u >>= Self::WIDTH;\n                }\n            }\n        }\n        out\n    }\n}\n\nimpl VecFromOtherType<usize> for u32 {\n    /// Converts a [`usize`] to a [`Vec`] of [`u32`]s.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#vec_from_other_type).\n    #[allow(arithmetic_overflow)]\n    fn vec_from_other_type(x: usize) -> Vec<Self> {\n        if USIZE_IS_U32 {\n            ::alloc::vec![Self::wrapping_from(x)]\n        } else {\n            assert_eq!(usize::WIDTH, u64::WIDTH);\n            let (upper, lower) = u64::wrapping_from(x).split_in_half();\n            ::alloc::vec![lower, upper]\n        }\n    }\n}\n\nimpl FromOtherTypeSlice<usize> for u64 {\n    /// Converts a slice of [`usize`]s to a single [`u64`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#from_other_type_slice).\n    fn from_other_type_slice(xs: &[usize]) -> Self {\n        if USIZE_IS_U32 {\n            let mut result = 0;\n            let mut offset = 0;\n            for &u in xs.iter().take(2) {\n                result |= Self::wrapping_from(u) << offset;\n                offset += usize::WIDTH;\n            }\n            result\n        } else {\n            assert_eq!(usize::WIDTH, Self::WIDTH);\n            if xs.is_empty() {\n                0\n            } else {\n                Self::wrapping_from(xs[0])\n            }\n        }\n    }\n}\n\nimpl VecFromOtherTypeSlice<usize> for u64 {\n    /// Converts a slice of [`usize`]s to a [`Vec`] of [`u64`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// See [here](super::slice#vec_from_other_type_slice).\n    fn vec_from_other_type_slice(xs: &[usize]) -> Vec<Self> {\n        let mut out;\n        if USIZE_IS_U32 {\n            out = ::alloc::vec![0; xs.len().shr_round(1, Ceiling).0];\n            for (x, chunk) in out.iter_mut().zip(xs.chunks(2)) {\n                *x = Self::from_other_type_slice(chunk);\n            }\n        } else {\n            assert_eq!(usize::WIDTH, Self::WIDTH);\n            out = ::alloc::vec![0; xs.len()];\n            for (x, &u) in out.iter_mut().zip(xs.iter()) {\n                *x = Self::wrapping_from(u);\n            }\n        }\n        out\n    }\n}\n\nimpl VecFromOtherType<usize> for u64 {\n    /// Converts a [`usize`] to a [`Vec`] of [`u64`]s.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::slice#vec_from_other_type).\n    #[inline]\n    fn vec_from_other_type(x: usize) -> Vec<Self> {\n        ::alloc::vec![Self::wrapping_from(x)]\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::Parity;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::conversion::string::from_string::digit_from_display_byte;\nuse crate::num::conversion::string::options::FromSciStringOptions;\nuse crate::num::conversion::traits::FromSciString;\nuse crate::rounding_modes::RoundingMode::*;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::{self, *};\nuse core::str::FromStr;\n\n#[doc(hidden)]\npub fn parse_exponent(s: &[u8]) -> Option<i64> {\n    i64::from_str(core::str::from_utf8(s).ok()?).ok()\n}\n\n#[doc(hidden)]\npub fn validate_helper(s: &[u8], base: u8) -> Option<()> {\n    for &c in s {\n        if digit_from_display_byte(c)? >= base {\n            return None;\n        }\n    }\n    Some(())\n}\n\n#[doc(hidden)]\npub fn is_zero_helper(s: &[u8], base: u8) -> Option<bool> {\n    let mut all_zeros = true;\n    for &c in s {\n        let d = digit_from_display_byte(c)?;\n        if d >= base {\n            return None;\n        }\n        if d != 0 {\n            all_zeros = false;\n        }\n    }\n    Some(all_zeros)\n}\n\n#[doc(hidden)]\npub fn cmp_half_helper(s: &[u8], base: u8) -> Option<Ordering> {\n    if s.is_empty() {\n        return Some(Less);\n    }\n    let h = base >> 1;\n    let mut done = false;\n    let mut result;\n    if base.even() {\n        // 1/2 is 0.h\n        result = Equal;\n        let mut first = true;\n        for &c in s {\n            let d = digit_from_display_byte(c)?;\n            if d >= base {\n                return None;\n            }\n            if done {\n                continue;\n            }\n            if first {\n                let half_c = d.cmp(&h);\n                if half_c != Equal {\n                    result = half_c;\n                    done = true;\n                }\n                first = false;\n            } else if d != 0 {\n                result = Greater;\n                done = true;\n            }\n        }\n    } else {\n        // 1/2 is 0.hhh...\n        result = Less;\n        for &c in s {\n            let d = digit_from_display_byte(c)?;\n            if done {\n                continue;\n            }\n            let half_c = d.cmp(&h);\n            if half_c != Equal {\n                result = half_c;\n                done = true;\n            }\n        }\n    }\n    Some(result)\n}\n\nfn parse_int<T: PrimitiveInt>(cs: &[u8], base: u8) -> Option<T> {\n    // if T is unsigned, from_string_base won't handle -0\n    let mut test_neg_zero = false;\n    if T::MIN == T::ZERO\n        && let Some(&b'-') = cs.first()\n    {\n        test_neg_zero = true;\n    }\n    if test_neg_zero {\n        if cs.len() == 1 {\n            return None;\n        }\n        for &c in &cs[1..] {\n            if c != b'0' {\n                return None;\n            }\n        }\n        Some(T::ZERO)\n    } else {\n        T::from_string_base(base, core::str::from_utf8(cs).ok()?)\n    }\n}\n\nfn up_1<T: PrimitiveInt>(x: T, neg: bool) -> Option<T> {\n    if neg {\n        x.checked_sub(T::ONE)\n    } else {\n        x.checked_add(T::ONE)\n    }\n}\n\n#[doc(hidden)]\npub fn preprocess_sci_string(s: &str, options: FromSciStringOptions) -> Option<(Vec<u8>, i64)> {\n    let mut s = s.as_bytes().to_vec();\n    let mut exponent = 0;\n    if options.base < 15 {\n        for (i, &c) in s.iter().enumerate().rev() {\n            if c == b'e' || c == b'E' {\n                if i == 0 || i == s.len() - 1 {\n                    return None;\n                }\n                exponent = parse_exponent(&s[i + 1..])?;\n                s.truncate(i);\n                break;\n            }\n        }\n    } else {\n        for (i, &c) in s.iter().enumerate().rev() {\n            if c == b'+' || c == b'-' {\n                if i == 0 {\n                    break;\n                }\n                if i == 1 || i == s.len() - 1 {\n                    return None;\n                }\n                let exp_indicator = s[i - 1];\n                if exp_indicator != b'e' && exp_indicator != b'E' {\n                    return None;\n                }\n                exponent = parse_exponent(&s[i..])?;\n                s.truncate(i - 1);\n                break;\n            }\n        }\n    }\n    let mut point_index = None;\n    for (i, &c) in s.iter().enumerate() {\n        if c == b'.' {\n            point_index = Some(i);\n            break;\n        }\n    }\n    if let Some(point_index) = point_index {\n        let len = s.len();\n        if point_index != len - 1 {\n            let next_char = s[point_index + 1];\n            if next_char == b'+' || next_char == b'-' {\n                return None;\n            }\n            exponent = exponent.checked_sub(i64::try_from(len - point_index - 1).ok()?)?;\n            s.copy_within(point_index + 1..len, point_index);\n        }\n        s.pop();\n    }\n    Some((s, exponent))\n}\n\nfn from_sci_string_with_options_primitive_int<T: PrimitiveInt>(\n    s: &str,\n    options: FromSciStringOptions,\n) -> Option<T> {\n    let (s, exponent) = preprocess_sci_string(s, options)?;\n    if exponent >= 0 {\n        let x = parse_int::<T>(&s, options.base)?;\n        x.checked_mul(T::wrapping_from(options.base).checked_pow(exponent.unsigned_abs())?)\n    } else {\n        let neg_exponent = usize::try_from(exponent.unsigned_abs()).ok()?;\n        let len = s.len();\n        if len == 0 {\n            return None;\n        }\n        let first = s[0];\n        let neg = first == b'-';\n        let sign = neg || first == b'+';\n        let rm = if neg {\n            -options.rounding_mode\n        } else {\n            options.rounding_mode\n        };\n        let sig_len = if sign { len - 1 } else { len };\n        if sig_len == 0 {\n            return None;\n        }\n        if neg_exponent > sig_len {\n            let s = if sign { &s[1..] } else { &s[..] };\n            return match rm {\n                Down | Floor | Nearest => {\n                    validate_helper(s, options.base)?;\n                    Some(T::ZERO)\n                }\n                Up | Ceiling => {\n                    if is_zero_helper(s, options.base)? {\n                        Some(T::ZERO)\n                    } else {\n                        up_1(T::ZERO, neg)\n                    }\n                }\n                Exact => None,\n            };\n        }\n        let (before_e, after_e) = s.split_at(len - neg_exponent);\n        let x = match before_e {\n            &[] | &[b'-'] | &[b'+'] => T::ZERO,\n            before_e => parse_int(before_e, options.base)?,\n        };\n        if after_e.is_empty() {\n            return Some(x);\n        }\n        match rm {\n            Down | Floor => {\n                validate_helper(after_e, options.base)?;\n                Some(x)\n            }\n            Up | Ceiling => {\n                if is_zero_helper(after_e, options.base)? {\n                    Some(x)\n                } else {\n                    up_1(x, neg)\n                }\n            }\n            Exact => {\n                if is_zero_helper(after_e, options.base)? {\n                    Some(x)\n                } else {\n                    None\n                }\n            }\n            Nearest => match cmp_half_helper(after_e, options.base)? {\n                Less => Some(x),\n                Greater => up_1(x, neg),\n                Equal => {\n                    if x.even() {\n                        Some(x)\n                    } else {\n                        up_1(x, neg)\n                    }\n                }\n            },\n        }\n    }\n}\n\nmacro_rules! impl_from_sci_string {\n    ($t:ident) => {\n        impl FromSciString for $t {\n            /// Converts a [`String`], possibly in scientfic notation, to a primitive integer.\n            ///\n            /// Use [`FromSciStringOptions`] to specify the base (from 2 to 36, inclusive) and the\n            /// rounding mode, in case rounding is necessary because the string represents a\n            /// non-integer.\n            ///\n            /// If the base is greater than 10, the higher digits are represented by the letters\n            /// `'a'` through `'z'` or `'A'` through `'Z'`; the case doesn't matter and doesn't need\n            /// to be consistent.\n            ///\n            /// Exponents are allowed, and are indicated using the character `'e'` or `'E'`. If the\n            /// base is 15 or greater, an ambiguity arises where it may not be clear whether `'e'`\n            /// is a digit or an exponent indicator. To resolve this ambiguity, always use a `'+'`\n            /// or `'-'` sign after the exponent indicator when the base is 15 or greater.\n            ///\n            /// The exponent itself is always parsed using base 10.\n            ///\n            /// Decimal (or other-base) points are allowed. These are most useful in conjunction\n            /// with exponents, but they may be used on their own. If the string represents a\n            /// non-integer, the rounding mode specified in `options` is used to round to an\n            /// integer.\n            ///\n            /// If the string is unparseable or parses to an out-of-range integer, `None` is\n            /// returned. `None` is also returned if the rounding mode in options is `Exact`, but\n            /// rounding is necessary.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n            ///\n            /// # Examples\n            /// See [here](super::from_sci_string).\n            #[inline]\n            fn from_sci_string_with_options(s: &str, options: FromSciStringOptions) -> Option<$t> {\n                from_sci_string_with_options_primitive_int(s, options)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_from_sci_string);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::conversion::traits::FromStringBase;\n\n/// Produces a digit from a byte corresponding to a numeric or alphabetic (lower- or uppercase)\n/// [`char`] that represents the digit.\n///\n/// Bytes corresponding to `char`s from '0' to '9' become digits 0 to 9. Bytes corresponding to\n/// `char`s from 'a' to 'z' become digits 10 to 35. Bytes corresponding to `char`s from 'A' to 'Z'\n/// also become digits 10 to 35. Passing a byte that does not correspond to any of these `char`s\n/// yields `None`.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::conversion::string::from_string::digit_from_display_byte;\n///\n/// assert_eq!(digit_from_display_byte(b'0'), Some(0));\n/// assert_eq!(digit_from_display_byte(b'9'), Some(9));\n/// assert_eq!(digit_from_display_byte(b'a'), Some(10));\n/// assert_eq!(digit_from_display_byte(b'z'), Some(35));\n/// assert_eq!(digit_from_display_byte(b'A'), Some(10));\n/// assert_eq!(digit_from_display_byte(b'Z'), Some(35));\n/// assert_eq!(digit_from_display_byte(b' '), None);\n/// assert_eq!(digit_from_display_byte(b'!'), None);\n/// ```\npub const fn digit_from_display_byte(b: u8) -> Option<u8> {\n    match b {\n        b'0'..=b'9' => Some(b - b'0'),\n        b'a'..=b'z' => Some(b - b'a' + 10),\n        b'A'..=b'Z' => Some(b - b'A' + 10),\n        _ => None,\n    }\n}\n\nmacro_rules! impl_from_string_base {\n    ($t:ident) => {\n        impl FromStringBase for $t {\n            /// This is a wrapper over the `from_str_radix` functions in the standard library, for\n            /// example [this one](u32::from_str_radix).\n            #[inline]\n            fn from_string_base(base: u8, s: &str) -> Option<Self> {\n                $t::from_str_radix(s, u32::from(base)).ok()\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_from_string_base);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// [`FromSciString`](super::traits::FromSciString), a trait for converting strings, possibly using\n/// scientific notation, to numbers.\n///\n/// # from_sci_string\n/// ```\n/// use malachite_base::num::conversion::traits::FromSciString;\n///\n/// assert_eq!(u8::from_sci_string(\"123\"), Some(123));\n/// assert_eq!(u8::from_sci_string(\"123.5\"), Some(124));\n/// assert_eq!(u8::from_sci_string(\"256\"), None);\n/// assert_eq!(u64::from_sci_string(\"1.23e10\"), Some(12300000000));\n/// ```\n///\n/// # from_sci_string_with_options\n/// ```\n/// use malachite_base::num::conversion::string::options::FromSciStringOptions;\n/// use malachite_base::num::conversion::traits::FromSciString;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n///\n/// let mut options = FromSciStringOptions::default();\n/// assert_eq!(\n///     u8::from_sci_string_with_options(\"123.5\", options),\n///     Some(124)\n/// );\n///\n/// options.set_rounding_mode(Floor);\n/// assert_eq!(\n///     u8::from_sci_string_with_options(\"123.5\", options),\n///     Some(123)\n/// );\n///\n/// options = FromSciStringOptions::default();\n/// options.set_base(16);\n/// assert_eq!(u8::from_sci_string_with_options(\"ff\", options), Some(255));\n/// ```\npub mod from_sci_string;\n/// [`FromStringBase`](super::traits::FromStringBase), a trait for converting strings in a specified\n/// base to numbers.\npub mod from_string;\n/// [`ToSciOptions`](options::ToSciOptions) and\n/// [`FromSciSringOptions`](options::FromSciStringOptions), `struct`s for specifying parameters when\n/// using the [`FromSciString`](super::traits::FromSciString) and [`ToSci`](super::traits::ToSci)\n/// traits.\npub mod options;\n/// [`ToSci`](super::traits::ToSci), a trait for converting a number to string, possibly using\n/// scientific notation.\n///\n/// # to_sci\n/// ```\n/// use malachite_base::num::conversion::traits::ToSci;\n///\n/// // If the value can fit in a `u32`, the result is the same as with `to_string`\n/// assert_eq!(123u8.to_sci().to_string(), \"123\");\n///\n/// assert_eq!(u128::MAX.to_sci().to_string(), \"3.402823669209385e38\");\n/// assert_eq!(i128::MIN.to_sci().to_string(), \"-1.701411834604692e38\");\n/// ```\n///\n/// # to_sci_with_options\n/// ```\n/// use malachite_base::num::conversion::string::options::ToSciOptions;\n/// use malachite_base::num::conversion::traits::ToSci;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n///\n/// let mut options = ToSciOptions::default();\n/// assert_eq!(123456u32.to_sci_with_options(options).to_string(), \"123456\");\n///\n/// options.set_precision(3);\n/// assert_eq!(123456u32.to_sci_with_options(options).to_string(), \"1.23e5\");\n///\n/// options.set_rounding_mode(Ceiling);\n/// assert_eq!(123456u32.to_sci_with_options(options).to_string(), \"1.24e5\");\n///\n/// options.set_e_uppercase();\n/// assert_eq!(123456u32.to_sci_with_options(options).to_string(), \"1.24E5\");\n///\n/// options.set_force_exponent_plus_sign(true);\n/// assert_eq!(\n///     123456u32.to_sci_with_options(options).to_string(),\n///     \"1.24E+5\"\n/// );\n///\n/// options = ToSciOptions::default();\n/// options.set_base(36);\n/// assert_eq!(123456u32.to_sci_with_options(options).to_string(), \"2n9c\");\n///\n/// options.set_uppercase();\n/// assert_eq!(123456u32.to_sci_with_options(options).to_string(), \"2N9C\");\n///\n/// options.set_base(2);\n/// options.set_precision(10);\n/// assert_eq!(\n///     123456u32.to_sci_with_options(options).to_string(),\n///     \"1.1110001e16\"\n/// );\n///\n/// options.set_include_trailing_zeros(true);\n/// assert_eq!(\n///     123456u32.to_sci_with_options(options).to_string(),\n///     \"1.111000100e16\"\n/// );\n/// ```\n///\n/// # fmt_sci_valid\n/// ```\n/// use malachite_base::num::conversion::string::options::ToSciOptions;\n/// use malachite_base::num::conversion::traits::ToSci;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n///\n/// let mut options = ToSciOptions::default();\n/// assert!(123u8.fmt_sci_valid(options));\n/// assert!(u128::MAX.fmt_sci_valid(options));\n/// options.set_rounding_mode(Exact);\n/// assert!(!u128::MAX.fmt_sci_valid(options)); // u128::MAX has more than 16 significant digits\n/// options.set_precision(50);\n/// assert!(u128::MAX.fmt_sci_valid(options));\n/// ```\npub mod to_sci;\n/// The [`BaseFmtWrapper`](to_string::BaseFmtWrapper) struct and\n/// [`ToStringBase`](super::traits::ToStringBase) trait, used for converting numbers to strings.\n///\n/// # Display::fmt for BaseFmtWrapper\n/// ```\n/// use malachite_base::num::conversion::string::to_string::BaseFmtWrapper;\n///\n/// let x = BaseFmtWrapper::new(1000000000u32, 36);\n/// assert_eq!(format!(\"{}\", x), \"gjdgxs\");\n/// assert_eq!(format!(\"{:#}\", x), \"GJDGXS\");\n/// assert_eq!(format!(\"{:010}\", x), \"0000gjdgxs\");\n/// assert_eq!(format!(\"{:#010}\", x), \"0000GJDGXS\");\n///\n/// let x = BaseFmtWrapper::new(-1000000000i32, 36);\n/// assert_eq!(format!(\"{}\", x), \"-gjdgxs\");\n/// assert_eq!(format!(\"{:#}\", x), \"-GJDGXS\");\n/// assert_eq!(format!(\"{:010}\", x), \"-000gjdgxs\");\n/// assert_eq!(format!(\"{:#010}\", x), \"-000GJDGXS\");\n/// ```\n///\n/// # Debug::fmt for BaseFmtWrapper\n/// ```\n/// use malachite_base::num::conversion::string::to_string::BaseFmtWrapper;\n///\n/// let x = BaseFmtWrapper::new(1000000000u32, 36);\n/// assert_eq!(format!(\"{:?}\", x), \"gjdgxs\");\n/// assert_eq!(format!(\"{:#?}\", x), \"GJDGXS\");\n/// assert_eq!(format!(\"{:010?}\", x), \"0000gjdgxs\");\n/// assert_eq!(format!(\"{:#010?}\", x), \"0000GJDGXS\");\n///\n/// let x = BaseFmtWrapper::new(-1000000000i32, 36);\n/// assert_eq!(format!(\"{:?}\", x), \"-gjdgxs\");\n/// assert_eq!(format!(\"{:#?}\", x), \"-GJDGXS\");\n/// assert_eq!(format!(\"{:010?}\", x), \"-000gjdgxs\");\n/// assert_eq!(format!(\"{:#010?}\", x), \"-000GJDGXS\");\n/// ```\n///\n/// # to_string_base\n/// ```\n/// use malachite_base::num::conversion::traits::ToStringBase;\n///\n/// assert_eq!(1000u16.to_string_base(2), \"1111101000\");\n/// assert_eq!(1000u16.to_string_base(10), \"1000\");\n/// assert_eq!(1000u16.to_string_base(36), \"rs\");\n///\n/// assert_eq!(1000i16.to_string_base(2), \"1111101000\");\n/// assert_eq!(1000i16.to_string_base(10), \"1000\");\n/// assert_eq!(1000i16.to_string_base(36), \"rs\");\n///\n/// assert_eq!((-1000i16).to_string_base(2), \"-1111101000\");\n/// assert_eq!((-1000i16).to_string_base(10), \"-1000\");\n/// assert_eq!((-1000i16).to_string_base(36), \"-rs\");\n/// ```\n///\n/// # to_string_base_upper\n/// ```\n/// use malachite_base::num::conversion::traits::ToStringBase;\n///\n/// assert_eq!(1000u16.to_string_base_upper(2), \"1111101000\");\n/// assert_eq!(1000u16.to_string_base_upper(10), \"1000\");\n/// assert_eq!(1000u16.to_string_base_upper(36), \"RS\");\n///\n/// assert_eq!(1000i16.to_string_base_upper(2), \"1111101000\");\n/// assert_eq!(1000i16.to_string_base_upper(10), \"1000\");\n/// assert_eq!(1000i16.to_string_base_upper(36), \"RS\");\n///\n/// assert_eq!((-1000i16).to_string_base_upper(2), \"-1111101000\");\n/// assert_eq!((-1000i16).to_string_base_upper(10), \"-1000\");\n/// assert_eq!((-1000i16).to_string_base_upper(36), \"-RS\");\n/// ```\npub mod to_string;\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/options/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::exhaustive::exhaustive_bools;\nuse crate::num::conversion::string::options::{FromSciStringOptions, SciSizeOptions, ToSciOptions};\nuse crate::num::exhaustive::{\n    exhaustive_negative_signeds, primitive_int_increasing_inclusive_range,\n};\nuse crate::num::logic::traits::NotAssign;\nuse crate::rounding_modes::RoundingMode;\nuse crate::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse crate::tuples::exhaustive::{exhaustive_triples, lex_pairs, lex_quadruples_from_single};\nuse alloc::boxed::Box;\n\n/// Generates all [`SciSizeOptions`]s.\n///\n/// This struct is created by [`exhaustive_sci_size_options`]; see its documentation for more.\npub struct ExhaustiveSciSizeOptions {\n    i: u64,\n    even: bool,\n}\n\nimpl Iterator for ExhaustiveSciSizeOptions {\n    type Item = SciSizeOptions;\n\n    fn next(&mut self) -> Option<SciSizeOptions> {\n        let out = if self.even {\n            if self.i == 0 {\n                SciSizeOptions::Complete\n            } else {\n                SciSizeOptions::Precision(self.i)\n            }\n        } else {\n            let i = self.i;\n            self.i += 1;\n            SciSizeOptions::Scale(i)\n        };\n        self.even.not_assign();\n        Some(out)\n    }\n}\n\n/// Generates all [`SciSizeOptions`]s.\n///\n/// The output length is $2^{65}$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\npub const fn exhaustive_sci_size_options() -> ExhaustiveSciSizeOptions {\n    ExhaustiveSciSizeOptions { i: 0, even: true }\n}\n\n/// Generates all [`ToSciOptions`]s.\n///\n/// This struct is created by [`exhaustive_to_sci_options`]; see its documentation for more.\npub struct ExhaustiveToSciOptions(\n    Box<\n        dyn Iterator<\n            Item = (\n                (u8, SciSizeOptions, i64),\n                (RoundingMode, (bool, bool, bool, bool)),\n            ),\n        >,\n    >,\n);\n\nimpl Iterator for ExhaustiveToSciOptions {\n    type Item = ToSciOptions;\n\n    fn next(&mut self) -> Option<ToSciOptions> {\n        let (\n            (base, size_options, neg_exp_threshold),\n            (\n                rounding_mode,\n                (lowercase, e_lowercase, force_exponent_plus_sign, include_trailing_zeros),\n            ),\n        ) = self.0.next()?;\n        Some(ToSciOptions {\n            base,\n            size_options,\n            neg_exp_threshold,\n            rounding_mode,\n            lowercase,\n            e_lowercase,\n            force_exponent_plus_sign,\n            include_trailing_zeros,\n        })\n    }\n}\n\n/// Generates all [`ToSciOptions`]s.\n///\n/// The output length is $2^{133}\\times 3 \\times 5 \\times 7 \\approx 1.4335 \\times 10^{42}$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\npub fn exhaustive_to_sci_options() -> ExhaustiveToSciOptions {\n    ExhaustiveToSciOptions(Box::new(lex_pairs(\n        exhaustive_triples(\n            primitive_int_increasing_inclusive_range(2, 36),\n            exhaustive_sci_size_options(),\n            exhaustive_negative_signeds(),\n        ),\n        lex_pairs(\n            exhaustive_rounding_modes(),\n            lex_quadruples_from_single(exhaustive_bools()),\n        ),\n    )))\n}\n\n/// Generates all [`FromSciStringOptions`]s.\n///\n/// This struct is created by [`exhaustive_from_sci_string_options`]; see its documentation for\n/// more.\npub struct ExhaustiveFromSciStringOptions(Box<dyn Iterator<Item = (u8, RoundingMode)>>);\n\nimpl Iterator for ExhaustiveFromSciStringOptions {\n    type Item = FromSciStringOptions;\n\n    fn next(&mut self) -> Option<FromSciStringOptions> {\n        let (base, rounding_mode) = self.0.next()?;\n        Some(FromSciStringOptions {\n            base,\n            rounding_mode,\n        })\n    }\n}\n\n/// Generates all [`FromSciStringOptions`]s.\n///\n/// The output length is 210.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\npub fn exhaustive_from_sci_string_options() -> ExhaustiveFromSciStringOptions {\n    ExhaustiveFromSciStringOptions(Box::new(lex_pairs(\n        primitive_int_increasing_inclusive_range(2, 36),\n        exhaustive_rounding_modes(),\n    )))\n}\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/options/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rounding_modes::RoundingMode::{self, *};\n\n/// A `struct` determining how much \"detail\" should be used when creating a scientific-notation\n/// string.\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub enum SciSizeOptions {\n    /// Indicates that the number should be rendered in its full precision.\n    Complete,\n    /// Indicates how many significant figures should be shown. The precision cannot be zero.\n    Precision(u64),\n    /// Indicates how many digits after the decimal (or other-base) point should be shown. For\n    /// example, if the base is 10 and the scale is 2, then up to two digits after the decimal point\n    /// should be shown.\n    Scale(u64),\n}\n\nimpl Default for SciSizeOptions {\n    fn default() -> Self {\n        Self::Precision(16) // Similar to f64 string output\n    }\n}\n\n#[cfg(feature = \"test_build\")]\nimpl SciSizeOptions {\n    pub const fn is_valid(&self) -> bool {\n        if let Self::Precision(p) = *self {\n            p != 0\n        } else {\n            true\n        }\n    }\n}\n\n/// A `struct` determining how a number should be formatted as a \"scientific\" string.\n///\n/// - The base must be between 2 and 36, inclusive. The characters representing the digits are `'0'`\n///   through `'9'` and either `'a'` through `'z'` or `'A'` through `'Z'`, depending on whether the\n///   `lowercase` field is set. The default base is 10.\n///\n/// - The rounding mode determines how the output should be rounded, in case the `size_options`\n///   field is such that the number can't be fully represented. The default rounding mode is\n///   `Nearest`.\n///\n/// - The size options determine the precision or scale that the number should be displayed with.\n///   The default is `Precision(16)`, which is about as much precision as an `f64` is usually\n///   displayed with.\n///\n/// - The negative exponent threshold determines when small numbers switch to scientific notation.\n///   The default is $-6$, meaning that the numbers $1/10, 1/100, 1/1000, \\ldots$. would be\n///   displayed as `0.1, 0.01, 0.001, 0.0001, 0.00001, 1e-6, 1e-7...`. The threshold must be\n///   negative.\n///\n/// - The lowercase setting determines whether digits in bases greater than 10 are lowercase or\n///   uppercase. The default is `true`.\n///\n/// - The exponent lowercase setting determines whether the exponent indicator is lowercase (`'e'`)\n///   or uppercase (`'E'`). The default is `true`.\n///\n/// - The \"force exponent plus sign\" setting determines whether positive exponents should be\n///   rendered with an explicit plus sign. If the base is 15 or greater, then the explicit plus sign\n///   is used regardless, in order to distinguish the exponent indicator from the digit `'e'`. The\n///   default is `false`.\n///\n/// - The \"include trailing zeros\" setting determines whether trailing zeros after the decimal (or\n///   other-base) point should be included. The default is `false`.\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct ToSciOptions {\n    pub(crate) base: u8,\n    pub(crate) rounding_mode: RoundingMode,\n    pub(crate) size_options: SciSizeOptions,\n    neg_exp_threshold: i64,\n    pub(crate) lowercase: bool,\n    pub(crate) e_lowercase: bool,\n    pub(crate) force_exponent_plus_sign: bool,\n    pub(crate) include_trailing_zeros: bool,\n}\n\nimpl Default for ToSciOptions {\n    fn default() -> Self {\n        Self {\n            base: 10,\n            rounding_mode: Nearest,\n            size_options: SciSizeOptions::default(),\n            neg_exp_threshold: -6,\n            lowercase: true,\n            e_lowercase: true,\n            force_exponent_plus_sign: false,\n            include_trailing_zeros: false,\n        }\n    }\n}\n\nimpl ToSciOptions {\n    /// Returns the base to be used in the conversion. It is always between 2 and 36, inclusive.\n    #[inline]\n    pub const fn get_base(&self) -> u8 {\n        self.base\n    }\n\n    /// Returns the rounding mode to be used in the conversion.\n    #[inline]\n    pub const fn get_rounding_mode(&self) -> RoundingMode {\n        self.rounding_mode\n    }\n\n    /// Returns the size options to be used in the conversion.\n    #[inline]\n    pub const fn get_size_options(&self) -> SciSizeOptions {\n        self.size_options\n    }\n\n    /// Returns the exponent low threshold to be used in the conversion. It is always negative.\n    #[inline]\n    pub const fn get_neg_exp_threshold(&self) -> i64 {\n        self.neg_exp_threshold\n    }\n\n    /// Returns whether the digits should be lowercase.\n    #[inline]\n    pub const fn get_lowercase(&self) -> bool {\n        self.lowercase\n    }\n\n    /// Returns whether the exponent indicator should be lowercase (`'e'` rather than `'E'`).\n    #[inline]\n    pub const fn get_e_lowercase(&self) -> bool {\n        self.e_lowercase\n    }\n\n    /// Returns whether positive exponents should always be preceded by an explicit plus sign.\n    #[inline]\n    pub const fn get_force_exponent_plus_sign(&self) -> bool {\n        self.force_exponent_plus_sign\n    }\n\n    /// Returns whether trailing zeros should be included after the decimal (or other-base) point.\n    #[inline]\n    pub const fn get_include_trailing_zeros(&self) -> bool {\n        self.include_trailing_zeros\n    }\n\n    /// Sets the base to be used in the conversion.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    #[inline]\n    pub fn set_base(&mut self, base: u8) {\n        assert!(base >= 2);\n        assert!(base <= 36);\n        self.base = base;\n    }\n\n    /// Sets the rounding mode to be used in the conversion.\n    #[inline]\n    pub const fn set_rounding_mode(&mut self, rm: RoundingMode) {\n        self.rounding_mode = rm;\n    }\n\n    /// Sets the size options to the \"Complete\" mode, indicating that the number should be converted\n    /// using its full precision.\n    #[inline]\n    pub const fn set_size_complete(&mut self) {\n        self.size_options = SciSizeOptions::Complete;\n    }\n\n    /// Sets the size options to some precision, or number of significant digits.\n    ///\n    /// # Panics\n    /// Panics if `precision` is zero.\n    #[inline]\n    pub fn set_precision(&mut self, precision: u64) {\n        assert_ne!(precision, 0);\n        self.size_options = SciSizeOptions::Precision(precision);\n    }\n\n    /// Sets the size options to some scale, or number of digits after the decimal (or other-base)\n    /// point.\n    #[inline]\n    pub const fn set_scale(&mut self, scale: u64) {\n        self.size_options = SciSizeOptions::Scale(scale);\n    }\n\n    /// Sets the threshold at which nonzero numbers with a small absolute value start being\n    /// represented using negative exponents.\n    #[inline]\n    pub fn set_neg_exp_threshold(&mut self, neg_exp_threshold: i64) {\n        assert!(neg_exp_threshold < 0);\n        self.neg_exp_threshold = neg_exp_threshold;\n    }\n\n    /// Specifies that digits in bases greater than ten should be output with lowercase letters.\n    #[inline]\n    pub const fn set_lowercase(&mut self) {\n        self.lowercase = true;\n    }\n\n    /// Specifies that digits in bases greater than ten should be output with uppercase letters.\n    #[inline]\n    pub const fn set_uppercase(&mut self) {\n        self.lowercase = false;\n    }\n\n    /// Specifies that the exponent-indicating character should be `'e'`.\n    #[inline]\n    pub const fn set_e_lowercase(&mut self) {\n        self.e_lowercase = true;\n    }\n\n    /// Specifies that the exponent-indicating character should be `'E'`.\n    #[inline]\n    pub const fn set_e_uppercase(&mut self) {\n        self.e_lowercase = false;\n    }\n\n    /// Sets whether a positive exponent should be preceded by an explicit plus sign.\n    ///\n    /// If the base is 15 or greater, an explicit plus sign will be used regardless, in order to\n    /// differentiate the exponent-indicating character from the digit `'e'`.\n    #[inline]\n    pub const fn set_force_exponent_plus_sign(&mut self, force_exponent_plus_sign: bool) {\n        self.force_exponent_plus_sign = force_exponent_plus_sign;\n    }\n\n    /// Sets whether trailing zeros after the decimal (or other-base) point should be included.\n    #[inline]\n    pub const fn set_include_trailing_zeros(&mut self, include_trailing_zeros: bool) {\n        self.include_trailing_zeros = include_trailing_zeros;\n    }\n\n    #[cfg(feature = \"test_build\")]\n    pub fn is_valid(&self) -> bool {\n        (2..=36).contains(&self.base) && self.neg_exp_threshold < 0 && self.size_options.is_valid()\n    }\n}\n\n/// A `struct` determining how a number should be parsed from a \"scientific\" string.\n///\n/// - The base must be between 2 and 36, inclusive. The characters representing the digits may be\n///   `'0'` through `'9'` and either `'a'` through `'z'` or `'A'` through `'Z'`. The default base is\n///   10.\n///\n/// - The rounding mode determines how the output should be rounded, in case the output type can't\n///   represent all possible input strings. The default rounding mode is `Nearest`.\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct FromSciStringOptions {\n    pub(crate) base: u8,\n    pub(crate) rounding_mode: RoundingMode,\n}\n\nimpl Default for FromSciStringOptions {\n    fn default() -> Self {\n        Self {\n            base: 10,\n            rounding_mode: Nearest,\n        }\n    }\n}\n\nimpl FromSciStringOptions {\n    /// Returns the base to be used in the conversion. It is always between 2 and 36, inclusive.\n    #[inline]\n    pub const fn get_base(&self) -> u8 {\n        self.base\n    }\n\n    /// Returns the rounding mode to be used in the conversion.\n    #[inline]\n    pub const fn get_rounding_mode(&self) -> RoundingMode {\n        self.rounding_mode\n    }\n\n    /// Sets the base to be used in the conversion.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    #[inline]\n    pub fn set_base(&mut self, base: u8) {\n        assert!(base >= 2);\n        assert!(base <= 36);\n        self.base = base;\n    }\n\n    /// Sets the rounding mode to be used in the conversion.\n    #[inline]\n    pub const fn set_rounding_mode(&mut self, rm: RoundingMode) {\n        self.rounding_mode = rm;\n    }\n\n    #[cfg(feature = \"test_build\")]\n    pub fn is_valid(&self) -> bool {\n        (2..=36).contains(&self.base)\n    }\n}\n\n/// Iterators that generate [`SciSizeOptions`], [`ToSciOptions`], and [`FromSciStringOptions`]\n/// without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`SciSizeOptions`], [`ToSciOptions`], and [`FromSciStringOptions`]\n/// randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/options/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::{RandomBools, random_bools};\nuse crate::num::conversion::string::options::{FromSciStringOptions, SciSizeOptions, ToSciOptions};\nuse crate::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomNegativeSigneds,\n    geometric_random_negative_signeds, geometric_random_unsigneds,\n};\nuse crate::num::random::{RandomUnsignedInclusiveRange, random_unsigned_inclusive_range};\nuse crate::random::Seed;\nuse crate::rounding_modes::random::{RandomRoundingModes, random_rounding_modes};\n\n/// Generates random [`SciSizeOptions`]s.\n///\n/// This struct is created by [`random_sci_size_options`]; see its documentation for more.\npub struct RandomSciSizeOptions {\n    bs: RandomBools,\n    xs: GeometricRandomNaturalValues<u64>,\n}\n\nimpl Iterator for RandomSciSizeOptions {\n    type Item = SciSizeOptions;\n\n    fn next(&mut self) -> Option<SciSizeOptions> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() {\n            if x == 0 {\n                SciSizeOptions::Complete\n            } else {\n                SciSizeOptions::Precision(x)\n            }\n        } else {\n            SciSizeOptions::Scale(x)\n        })\n    }\n}\n\n/// Generates random [`SciSizeOptions`]s.\n///\n/// The scales and precisions are chosen from a geometric distribution whose mean is the ratio\n/// `m_size_numerator / m_size_denominator`.\n///\n/// # Panics\n/// Panics if `m_size_numerator` or `m_size_denominator` are zero, or, if after being reduced to\n/// lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// The output length is infinite.\npub fn random_sci_size_options(\n    seed: Seed,\n    m_size_numerator: u64,\n    m_size_denominator: u64,\n) -> RandomSciSizeOptions {\n    RandomSciSizeOptions {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: geometric_random_unsigneds(seed.fork(\"xs\"), m_size_numerator, m_size_denominator),\n    }\n}\n\n/// Generates random [`ToSciOptions`]s.\n///\n/// This struct is created by [`random_to_sci_options`]; see its documentation for more.\npub struct RandomToSciOptions {\n    us: RandomUnsignedInclusiveRange<u8>,\n    rms: RandomRoundingModes,\n    sos: RandomSciSizeOptions,\n    is: GeometricRandomNegativeSigneds<i64>,\n    bs: RandomBools,\n}\n\nimpl Iterator for RandomToSciOptions {\n    type Item = ToSciOptions;\n\n    fn next(&mut self) -> Option<ToSciOptions> {\n        Some(ToSciOptions {\n            base: self.us.next().unwrap(),\n            rounding_mode: self.rms.next().unwrap(),\n            size_options: self.sos.next().unwrap(),\n            neg_exp_threshold: self.is.next().unwrap(),\n            lowercase: self.bs.next().unwrap(),\n            e_lowercase: self.bs.next().unwrap(),\n            force_exponent_plus_sign: self.bs.next().unwrap(),\n            include_trailing_zeros: self.bs.next().unwrap(),\n        })\n    }\n}\n\n/// Generates random [`ToSciOptions`]s.\n///\n/// The scales, precisions, and the negative of the negative exponenet threshold are chosen from a\n/// geometric distribution whose mean is the ratio `m_size_numerator / m_size_denominator`.\n///\n/// # Panics\n/// Panics if `m_size_numerator` or `m_size_denominator` are zero, or, if after being reduced to\n/// lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// The output length is infinite.\npub fn random_to_sci_options(\n    seed: Seed,\n    m_size_numerator: u64,\n    m_size_denominator: u64,\n) -> RandomToSciOptions {\n    RandomToSciOptions {\n        us: random_unsigned_inclusive_range(seed.fork(\"us\"), 2, 36),\n        rms: random_rounding_modes(seed.fork(\"rms\")),\n        sos: random_sci_size_options(seed.fork(\"sos\"), m_size_numerator, m_size_denominator),\n        is: geometric_random_negative_signeds(\n            seed.fork(\"is\"),\n            m_size_numerator,\n            m_size_denominator,\n        ),\n        bs: random_bools(seed.fork(\"bs\")),\n    }\n}\n\n/// Generates random [`FromSciStringOptions`]s.\n///\n/// This struct is created by [`random_from_sci_string_options`]; see its documentation for more.\npub struct RandomFromSciStringOptions {\n    us: RandomUnsignedInclusiveRange<u8>,\n    rms: RandomRoundingModes,\n}\n\nimpl Iterator for RandomFromSciStringOptions {\n    type Item = FromSciStringOptions;\n\n    fn next(&mut self) -> Option<FromSciStringOptions> {\n        Some(FromSciStringOptions {\n            base: self.us.next().unwrap(),\n            rounding_mode: self.rms.next().unwrap(),\n        })\n    }\n}\n\n/// Generates random [`FromSciStringOptions`]s.\n///\n/// The output length is infinite.\npub fn random_from_sci_string_options(seed: Seed) -> RandomFromSciStringOptions {\n    RandomFromSciStringOptions {\n        us: random_unsigned_inclusive_range(seed.fork(\"us\"), 2, 36),\n        rms: random_rounding_modes(seed.fork(\"rms\")),\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedLogBase2, NegAssign, Pow, UnsignedAbs};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::string::options::{SciSizeOptions, ToSciOptions};\nuse crate::num::conversion::string::to_string::BaseFmtWrapper;\nuse crate::num::conversion::string::to_string::{\n    digit_to_display_byte_lower, digit_to_display_byte_upper,\n};\nuse crate::num::conversion::traits::{ExactFrom, ToSci};\nuse crate::rounding_modes::RoundingMode::*;\nuse crate::slices::slice_trailing_zeros;\nuse alloc::string::String;\nuse core::fmt::{Display, Formatter, Write};\n\n/// A `struct` that can be used to format a number in scientific notation.\npub struct SciWrapper<'a, T: ToSci> {\n    pub(crate) x: &'a T,\n    pub(crate) options: ToSciOptions,\n}\n\nimpl<T: ToSci> Display for SciWrapper<'_, T> {\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> core::fmt::Result {\n        self.x.fmt_sci(f, self.options)\n    }\n}\n\n#[doc(hidden)]\npub fn write_exponent<T: PrimitiveInt>(\n    f: &mut Formatter,\n    options: ToSciOptions,\n    exp: T,\n) -> core::fmt::Result {\n    f.write_char(if options.get_e_lowercase() { 'e' } else { 'E' })?;\n    if exp > T::ZERO && (options.get_force_exponent_plus_sign() || options.get_base() >= 15) {\n        f.write_char('+')?;\n    }\n    write!(f, \"{exp}\")\n}\n\nfn write_helper<T>(x: T, f: &mut Formatter, options: ToSciOptions) -> core::fmt::Result\nwhere\n    BaseFmtWrapper<T>: Display,\n{\n    let w = BaseFmtWrapper {\n        x,\n        base: options.base,\n    };\n    if options.lowercase {\n        Display::fmt(&w, f)\n    } else {\n        write!(f, \"{w:#}\")\n    }\n}\n\nfn fmt_sci_valid_unsigned<T: PrimitiveUnsigned>(x: T, options: ToSciOptions) -> bool {\n    if x == T::ZERO || options.rounding_mode != Exact {\n        return true;\n    }\n    match options.size_options {\n        SciSizeOptions::Complete | SciSizeOptions::Scale(_) => true,\n        SciSizeOptions::Precision(precision) => {\n            let t_base = T::from(options.base);\n            let log = x.floor_log_base(t_base);\n            if log < precision {\n                return true;\n            }\n            let neg_scale = log - precision + 1;\n            if let Some(base_log) = options.base.checked_log_base_2() {\n                x.divisible_by_power_of_2(base_log * neg_scale)\n            } else {\n                x.divisible_by(Pow::pow(t_base, neg_scale))\n            }\n        }\n    }\n}\n\nfn fmt_sci_unsigned<T: PrimitiveUnsigned>(\n    mut x: T,\n    f: &mut Formatter,\n    options: ToSciOptions,\n) -> core::fmt::Result\nwhere\n    BaseFmtWrapper<T>: Display,\n{\n    match options.size_options {\n        SciSizeOptions::Complete | SciSizeOptions::Scale(0) => write_helper(x, f, options),\n        SciSizeOptions::Scale(scale) => {\n            write_helper(x, f, options)?;\n            if options.include_trailing_zeros {\n                f.write_char('.')?;\n                for _ in 0..scale {\n                    f.write_char('0')?;\n                }\n            }\n            Ok(())\n        }\n        SciSizeOptions::Precision(precision) => {\n            let t_base = T::from(options.base);\n            let log = if x == T::ZERO {\n                0\n            } else {\n                x.floor_log_base(t_base)\n            };\n            if log < precision {\n                // no exponent\n                write_helper(x, f, options)?;\n                if options.include_trailing_zeros {\n                    let extra_zeros = precision - log - 1;\n                    if extra_zeros != 0 {\n                        f.write_char('.')?;\n                        for _ in 0..extra_zeros {\n                            f.write_char('0')?;\n                        }\n                    }\n                }\n                Ok(())\n            } else {\n                // exponent\n                let mut e = log;\n                let neg_scale = log - precision + 1;\n                if let Some(base_log) = options.base.checked_log_base_2() {\n                    x.shr_round_assign(base_log * neg_scale, options.rounding_mode);\n                } else {\n                    x.div_round_assign(Pow::pow(t_base, neg_scale), options.rounding_mode);\n                }\n                let mut chars = x.to_digits_desc(&options.base);\n                let mut len = chars.len();\n                let p = usize::exact_from(precision);\n                if len > p {\n                    // rounded up to a power of the base, need to reduce precision\n                    chars.pop();\n                    len -= 1;\n                    e += 1;\n                }\n                assert_eq!(len, p);\n                if !options.include_trailing_zeros {\n                    chars.truncate(len - slice_trailing_zeros(&chars));\n                }\n                if options.lowercase {\n                    for digit in &mut chars {\n                        *digit = digit_to_display_byte_lower(*digit).unwrap();\n                    }\n                } else {\n                    for digit in &mut chars {\n                        *digit = digit_to_display_byte_upper(*digit).unwrap();\n                    }\n                }\n                len = chars.len();\n                if len != 1 {\n                    chars.push(b'0');\n                    chars.copy_within(1..len, 2);\n                    chars[1] = b'.';\n                }\n                f.write_str(&String::from_utf8(chars).unwrap())?;\n                write_exponent(f, options, e)\n            }\n        }\n    }\n}\n\n#[inline]\nfn fmt_sci_valid_signed<T: PrimitiveSigned>(x: T, options: ToSciOptions) -> bool\nwhere\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    fmt_sci_valid_unsigned(x.unsigned_abs(), options)\n}\n\nfn fmt_sci_signed<T: PrimitiveSigned>(\n    x: T,\n    f: &mut Formatter,\n    mut options: ToSciOptions,\n) -> core::fmt::Result\nwhere\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    let abs = x.unsigned_abs();\n    if x >= T::ZERO {\n        abs.fmt_sci(f, options)\n    } else {\n        options.rounding_mode.neg_assign();\n        f.write_char('-')?;\n        abs.fmt_sci(f, options)\n    }\n}\n\nmacro_rules! impl_to_sci_unsigned {\n    ($t:ident) => {\n        impl ToSci for $t {\n            /// Determines whether an unsigned number can be converted to a string using\n            /// [`to_sci_with_options`](super::super::traits::ToSci::to_sci_with_options) and a\n            /// particular set of options.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::to_sci#fmt_sci_valid).\n            #[inline]\n            fn fmt_sci_valid(&self, options: ToSciOptions) -> bool {\n                fmt_sci_valid_unsigned(*self, options)\n            }\n\n            /// Converts an unsigned number to a string using a specified base, possibly formatting\n            /// the number using scientific notation.\n            ///\n            /// See [`ToSciOptions`] for details on the available options. Note that setting\n            /// `neg_exp_threshold` has no effect, since there is never a need to use negative\n            /// exponents when representing an integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `options.rounding_mode` is `Exact`, but the size options are such that the\n            /// input must be rounded.\n            ///\n            /// # Examples\n            /// See [here](super::to_sci).\n            #[inline]\n            fn fmt_sci(&self, f: &mut Formatter, options: ToSciOptions) -> core::fmt::Result {\n                fmt_sci_unsigned(*self, f, options)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_to_sci_unsigned);\n\nmacro_rules! impl_to_sci_signed {\n    ($t:ident) => {\n        impl ToSci for $t {\n            /// Determines whether a signed number can be converted to a string using\n            /// [`to_sci_with_options`](super::super::traits::ToSci::to_sci_with_options) and a\n            /// particular set of options.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::to_sci#fmt_sci_valid).\n            #[inline]\n            fn fmt_sci_valid(&self, options: ToSciOptions) -> bool {\n                fmt_sci_valid_signed(*self, options)\n            }\n\n            /// Converts a signed number to a string using a specified base, possibly formatting the\n            /// number using scientific notation.\n            ///\n            /// See [`ToSciOptions`] for details on the available options. Note that setting\n            /// `neg_exp_threshold` has no effect, since there is never a need to use negative\n            /// exponents when representing an integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `options.rounding_mode` is `Exact`, but the size options are such that the\n            /// input must be rounded.\n            ///\n            /// # Examples\n            /// See [here](super::to_sci).\n            #[inline]\n            fn fmt_sci(&self, f: &mut Formatter, options: ToSciOptions) -> core::fmt::Result {\n                fmt_sci_signed(*self, f, options)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_to_sci_signed);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::UnsignedAbs;\nuse crate::num::basic::traits::Zero;\nuse crate::num::conversion::traits::{Digits, ToStringBase, WrappingFrom};\nuse crate::vecs::vec_pad_left;\nuse alloc::string::String;\nuse alloc::string::ToString;\nuse core::fmt::{Debug, Display, Formatter, Result, Write};\n\n/// A `struct` that allows for formatting a numeric type and rendering its digits in a specified\n/// base.\n#[derive(Clone, Eq, Hash, PartialEq)]\npub struct BaseFmtWrapper<T> {\n    pub(crate) x: T,\n    pub(crate) base: u8,\n}\n\nimpl<T> BaseFmtWrapper<T> {\n    /// Creates a new `BaseFmtWrapper`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::to_string::BaseFmtWrapper;\n    ///\n    /// let x = BaseFmtWrapper::new(1000000000u32, 36);\n    /// assert_eq!(format!(\"{}\", x), \"gjdgxs\");\n    /// assert_eq!(format!(\"{:#}\", x), \"GJDGXS\");\n    /// ```\n    pub fn new(x: T, base: u8) -> Self {\n        assert!((2..=36).contains(&base), \"base out of range\");\n        Self { x, base }\n    }\n\n    /// Recovers the value from a `BaseFmtWrapper`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::to_string::BaseFmtWrapper;\n    ///\n    /// assert_eq!(BaseFmtWrapper::new(1000000000u32, 36).unwrap(), 1000000000);\n    /// ```\n    #[allow(clippy::missing_const_for_fn)]\n    pub fn unwrap(self) -> T {\n        self.x\n    }\n}\n\n/// Converts a digit to a byte corresponding to a numeric or lowercase alphabetic [`char`] that\n/// represents the digit.\n///\n/// Digits from 0 to 9 become bytes corresponding to [`char`]s from '0' to '9'. Digits from 10 to 35\n/// become bytes representing the lowercase [`char`]s 'a' to 'z'. Passing a digit greater than 35\n/// gives a `None`.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::conversion::string::to_string::digit_to_display_byte_lower;\n///\n/// assert_eq!(digit_to_display_byte_lower(0), Some(b'0'));\n/// assert_eq!(digit_to_display_byte_lower(9), Some(b'9'));\n/// assert_eq!(digit_to_display_byte_lower(10), Some(b'a'));\n/// assert_eq!(digit_to_display_byte_lower(35), Some(b'z'));\n/// assert_eq!(digit_to_display_byte_lower(100), None);\n/// ```\npub const fn digit_to_display_byte_lower(b: u8) -> Option<u8> {\n    match b {\n        0..=9 => Some(b + b'0'),\n        10..=35 => Some(b + b'a' - 10),\n        _ => None,\n    }\n}\n\n/// Converts a digit to a byte corresponding to a numeric or uppercase alphabetic [`char`] that\n/// represents the digit.\n///\n/// Digits from 0 to 9 become bytes corresponding to [`char`]s from '0' to '9'. Digits from 10 to 35\n/// become bytes representing the lowercase [`char`]s 'A' to 'Z'. Passing a digit greater than 35\n/// gives a `None`.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::conversion::string::to_string::digit_to_display_byte_upper;\n///\n/// assert_eq!(digit_to_display_byte_upper(0), Some(b'0'));\n/// assert_eq!(digit_to_display_byte_upper(9), Some(b'9'));\n/// assert_eq!(digit_to_display_byte_upper(10), Some(b'A'));\n/// assert_eq!(digit_to_display_byte_upper(35), Some(b'Z'));\n/// assert_eq!(digit_to_display_byte_upper(100), None);\n/// ```\npub const fn digit_to_display_byte_upper(b: u8) -> Option<u8> {\n    match b {\n        0..=9 => Some(b + b'0'),\n        10..=35 => Some(b + b'A' - 10),\n        _ => None,\n    }\n}\n\nfn fmt_unsigned<T: Copy + Digits<u8> + Eq + Zero>(\n    w: &BaseFmtWrapper<T>,\n    f: &mut Formatter,\n) -> Result {\n    let mut digits = w.x.to_digits_desc(&u8::wrapping_from(w.base));\n    if f.alternate() {\n        for digit in &mut digits {\n            *digit = digit_to_display_byte_upper(*digit).unwrap();\n        }\n    } else {\n        for digit in &mut digits {\n            *digit = digit_to_display_byte_lower(*digit).unwrap();\n        }\n    }\n    if w.x == T::ZERO {\n        digits.push(b'0');\n    }\n    f.pad_integral(true, \"\", core::str::from_utf8(&digits).unwrap())\n}\n\nfn to_string_base_unsigned<T: Copy + Digits<u8> + Eq + Zero>(x: &T, base: u8) -> String {\n    assert!((2..=36).contains(&base), \"base out of range\");\n    if *x == T::ZERO {\n        \"0\".to_string()\n    } else {\n        let mut digits = x.to_digits_desc(&base);\n        for digit in &mut digits {\n            *digit = digit_to_display_byte_lower(*digit).unwrap();\n        }\n        String::from_utf8(digits).unwrap()\n    }\n}\n\nfn to_string_base_upper_unsigned<T: Copy + Digits<u8> + Eq + Zero>(x: &T, base: u8) -> String {\n    assert!((2..=36).contains(&base), \"base out of range\");\n    if *x == T::ZERO {\n        \"0\".to_string()\n    } else {\n        let mut digits = x.to_digits_desc(&base);\n        for digit in &mut digits {\n            *digit = digit_to_display_byte_upper(*digit).unwrap();\n        }\n        String::from_utf8(digits).unwrap()\n    }\n}\n\nmacro_rules! impl_to_string_base_unsigned {\n    ($t:ident) => {\n        impl Display for BaseFmtWrapper<$t> {\n            /// Writes a wrapped unsigned number to a string using a specified base.\n            ///\n            /// If the base is greater than 10, lowercase alphabetic letters are used by default.\n            /// Using the `#` flag switches to uppercase letters. Padding with zeros works as usual.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string).\n            #[inline]\n            fn fmt(&self, f: &mut Formatter) -> Result {\n                fmt_unsigned(self, f)\n            }\n        }\n\n        impl Debug for BaseFmtWrapper<$t> {\n            /// Writes a wrapped unsigned number to a string using a specified base.\n            ///\n            /// If the base is greater than 10, lowercase alphabetic letters are used by default.\n            /// Using the `#` flag switches to uppercase letters. Padding with zeros works as usual.\n            ///\n            /// This is the same as the [`Display::fmt`] implementation.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string).\n            #[inline]\n            fn fmt(&self, f: &mut Formatter) -> Result {\n                Display::fmt(self, f)\n            }\n        }\n\n        impl ToStringBase for $t {\n            /// Converts an unsigned number to a string using a specified base.\n            ///\n            /// Digits from 0 to 9 become `char`s from '0' to '9'. Digits from 10 to 35 become the\n            /// lowercase [`char`]s 'a' to 'z'.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string#to_string_base).\n            #[inline]\n            fn to_string_base(&self, base: u8) -> String {\n                to_string_base_unsigned(self, base)\n            }\n\n            /// Converts an unsigned number to a string using a specified base.\n            ///\n            /// Digits from 0 to 9 become `char`s from '0' to '9'. Digits from 10 to 35 become the\n            /// uppercase [`char`]s 'A' to 'Z'.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string#to_string_base_upper).\n            #[inline]\n            fn to_string_base_upper(&self, base: u8) -> String {\n                to_string_base_upper_unsigned(self, base)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_to_string_base_unsigned);\n\nfn fmt_signed<T: Copy + Ord + UnsignedAbs + Zero>(\n    w: &BaseFmtWrapper<T>,\n    f: &mut Formatter,\n) -> Result\nwhere\n    BaseFmtWrapper<<T as UnsignedAbs>::Output>: Display,\n{\n    if w.x < T::ZERO {\n        f.write_char('-')?;\n        if let Some(width) = f.width() {\n            return if f.alternate() {\n                write!(\n                    f,\n                    \"{:#0width$}\",\n                    &BaseFmtWrapper::new(w.x.unsigned_abs(), w.base),\n                    width = width.saturating_sub(1)\n                )\n            } else {\n                write!(\n                    f,\n                    \"{:0width$}\",\n                    &BaseFmtWrapper::new(w.x.unsigned_abs(), w.base),\n                    width = width.saturating_sub(1)\n                )\n            };\n        }\n    }\n    Display::fmt(&BaseFmtWrapper::new(w.x.unsigned_abs(), w.base), f)\n}\n\nfn to_string_base_signed<U: Digits<u8>, S: Copy + Eq + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &S,\n    base: u8,\n) -> String {\n    assert!((2..=36).contains(&base), \"base out of range\");\n    if *x == S::ZERO {\n        \"0\".to_string()\n    } else {\n        let mut digits = x.unsigned_abs().to_digits_desc(&u8::wrapping_from(base));\n        for digit in &mut digits {\n            *digit = digit_to_display_byte_lower(*digit).unwrap();\n        }\n        if *x < S::ZERO {\n            vec_pad_left(&mut digits, 1, b'-');\n        }\n        String::from_utf8(digits).unwrap()\n    }\n}\n\nfn to_string_base_upper_signed<\n    U: Digits<u8>,\n    S: Copy + Eq + Ord + UnsignedAbs<Output = U> + Zero,\n>(\n    x: &S,\n    base: u8,\n) -> String {\n    assert!((2..=36).contains(&base), \"base out of range\");\n    if *x == S::ZERO {\n        \"0\".to_string()\n    } else {\n        let mut digits = x.unsigned_abs().to_digits_desc(&base);\n        for digit in &mut digits {\n            *digit = digit_to_display_byte_upper(*digit).unwrap();\n        }\n        if *x < S::ZERO {\n            vec_pad_left(&mut digits, 1, b'-');\n        }\n        String::from_utf8(digits).unwrap()\n    }\n}\n\nmacro_rules! impl_to_string_base_signed {\n    ($u:ident, $s:ident) => {\n        impl Display for BaseFmtWrapper<$s> {\n            /// Writes a wrapped signed number to a string using a specified base.\n            ///\n            /// If the base is greater than 10, lowercase alphabetic letters are used by default.\n            /// Using the `#` flag switches to uppercase letters. Padding with zeros works as usual.\n            ///\n            /// Unlike with the default implementations of [`Binary`](std::fmt::Binary),\n            /// [`Octal`](std::fmt::Octal), [`LowerHex`](std::fmt::LowerHex), and\n            /// [`UpperHex`](std::fmt::UpperHex), negative numbers are represented using a negative\n            /// sign, not two's complement.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string).\n            #[inline]\n            fn fmt(&self, f: &mut Formatter) -> Result {\n                fmt_signed(self, f)\n            }\n        }\n\n        impl Debug for BaseFmtWrapper<$s> {\n            /// Writes a wrapped signed number to a string using a specified base.\n            ///\n            /// If the base is greater than 10, lowercase alphabetic letters are used by default.\n            /// Using the `#` flag switches to uppercase letters. Padding with zeros works as usual.\n            ///\n            /// Unlike with the default implementations of [`Binary`](std::fmt::Binary),\n            /// [`Octal`](std::fmt::Octal), [`LowerHex`](std::fmt::LowerHex), and\n            /// [`UpperHex`](std::fmt::UpperHex), negative numbers are represented using a negative\n            /// sign, not two's complement.\n            ///\n            /// This is the same as the [`Display::fmt`] implementation.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string).\n            #[inline]\n            fn fmt(&self, f: &mut Formatter) -> Result {\n                Display::fmt(self, f)\n            }\n        }\n\n        impl ToStringBase for $s {\n            /// Converts a signed number to a string using a specified base.\n            ///\n            /// Digits from 0 to 9 become `char`s from '0' to '9'. Digits from 10 to 35 become the\n            /// lowercase [`char`]s 'a' to 'z'.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string#to_string_base).\n            #[inline]\n            fn to_string_base(&self, base: u8) -> String {\n                to_string_base_signed::<$u, $s>(self, base)\n            }\n\n            /// Converts a signed number to a string using a specified base.\n            ///\n            /// Digits from 0 to 9 become `char`s from '0' to '9'. Digits from 10 to 35 become the\n            /// uppercase [`char`]s 'A' to 'Z'.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2 or greater than 36.\n            ///\n            /// # Examples\n            /// See [here](super::to_string#to_string_base_upper).\n            #[inline]\n            fn to_string_base_upper(&self, base: u8) -> String {\n                to_string_base_upper_signed::<$u, $s>(self, base)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_to_string_base_signed);\n"
  },
  {
    "path": "malachite-base/src/num/conversion/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::conversion::string::options::{FromSciStringOptions, ToSciOptions};\nuse crate::num::conversion::string::to_sci::SciWrapper;\nuse crate::rounding_modes::RoundingMode;\nuse alloc::string::String;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering;\nuse core::fmt::{Formatter, Result};\n\n/// Expresses a value as a [`Vec`] of digits, or reads a value from an iterator of digits.\n///\n/// The trait is parameterized by `T`, which is both the digit type and the base type.\npub trait Digits<T>: Sized {\n    /// Returns a [`Vec`] containing the digits of a value in ascending order: least- to\n    /// most-significant.\n    fn to_digits_asc(&self, base: &T) -> Vec<T>;\n\n    /// Returns a [`Vec`] containing the digits of a value in descending order: most- to\n    /// least-significant.\n    fn to_digits_desc(&self, base: &T) -> Vec<T>;\n\n    /// Converts an iterator of digits into a value.\n    ///\n    /// The input digits are in ascending order: least- to most-significant.\n    fn from_digits_asc<I: Iterator<Item = T>>(base: &T, digits: I) -> Option<Self>;\n\n    /// Converts an iterator of digits into a value.\n    ///\n    /// The input digits are in descending order: most- to least-significant.\n    fn from_digits_desc<I: Iterator<Item = T>>(base: &T, digits: I) -> Option<Self>;\n}\n\n/// An iterator over a value's base-$2^k$ digits.\npub trait PowerOf2DigitIterator<T>: Iterator<Item = T> + DoubleEndedIterator<Item = T> {\n    fn get_digit(&self, index: u64) -> T;\n}\n\n/// Creates an iterator over a value's base-$2^k$ digits.\npub trait PowerOf2DigitIterable<T> {\n    type PowerOf2DigitIterator: PowerOf2DigitIterator<T>;\n\n    /// Returns a double-ended iterator over a value's digits in base $2^l$, where $k$ is\n    /// `log_base`.\n    ///\n    /// The iterator ends after the value's most-significant digit.\n    fn power_of_2_digits(self, log_base: u64) -> Self::PowerOf2DigitIterator;\n}\n\n/// Expresses a value as a [`Vec`] of base-$2^k$ digits, or reads a value from an iterator of\n/// base-$2^k$ digits.\n///\n/// The trait is parameterized by the digit type.\npub trait PowerOf2Digits<T>: Sized {\n    /// Returns a [`Vec`] containing the digits of a value in ascending order: least- to\n    /// most-significant.\n    ///\n    /// The base is $2^k$, where $k$ is `log_base`.\n    fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<T>;\n\n    /// Returns a [`Vec`] containing the digits of a value in descending order: most- to\n    /// least-significant.\n    ///\n    /// The base is $2^k$, where $k$ is `log_base`.\n    fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<T>;\n\n    /// Converts an iterator of digits into a value.\n    ///\n    /// The input digits are in ascending order: least- to most-significant. The base is $2^k$,\n    /// where $k$ is `log_base`.\n    fn from_power_of_2_digits_asc<I: Iterator<Item = T>>(log_base: u64, digits: I) -> Option<Self>;\n\n    /// Converts an iterator of digits into a value.\n    ///\n    /// The input digits are in descending order: most- to least-significant. The base is $2^k$,\n    /// where $k$ is `log_base`.\n    fn from_power_of_2_digits_desc<I: Iterator<Item = T>>(log_base: u64, digits: I)\n    -> Option<Self>;\n}\n\n/// Converts a string slice in a given base to a value.\npub trait FromStringBase: Sized {\n    fn from_string_base(base: u8, s: &str) -> Option<Self>;\n}\n\n/// Converts a number to a string using a specified base.\npub trait ToStringBase {\n    /// Converts a signed number to a lowercase string using a specified base.\n    fn to_string_base(&self, base: u8) -> String;\n\n    /// Converts a signed number to an uppercase string using a specified base.\n    fn to_string_base_upper(&self, base: u8) -> String;\n}\n\n/// Converts a number to a string, possibly in scientific notation.\npub trait ToSci: Sized {\n    /// Formats a number, possibly in scientific notation.\n    fn fmt_sci(&self, f: &mut Formatter, options: ToSciOptions) -> Result;\n\n    /// Determines whether some formatting options can be applied to a number.\n    fn fmt_sci_valid(&self, options: ToSciOptions) -> bool;\n\n    /// Converts a number to a string, possibly in scientific notation.\n    fn to_sci_with_options(&self, options: ToSciOptions) -> SciWrapper<'_, Self> {\n        SciWrapper { x: self, options }\n    }\n\n    /// Converts a number to a string, possibly in scientific notation, using the default\n    /// [`ToSciOptions`].\n    #[inline]\n    fn to_sci(&self) -> SciWrapper<'_, Self> {\n        SciWrapper {\n            x: self,\n            options: ToSciOptions::default(),\n        }\n    }\n}\n\n/// Converts a `&str`, possibly in scientific notation, to a number.\npub trait FromSciString: Sized {\n    /// Converts a `&str`, possibly in scientific notation, to a number.\n    fn from_sci_string_with_options(s: &str, options: FromSciStringOptions) -> Option<Self>;\n\n    /// Converts a `&str`, possibly in scientific notation, to a number, using the default\n    /// [`FromSciStringOptions`].\n    #[inline]\n    fn from_sci_string(s: &str) -> Option<Self> {\n        Self::from_sci_string_with_options(s, FromSciStringOptions::default())\n    }\n}\n\n/// Converts a value from one type to another. If the conversion fails, the function panics.\n///\n/// It is recommended that this trait is not implemented directly; it is automatically implemented\n/// when [`TryFrom`] is implemented.\npub trait ExactFrom<T>: Sized {\n    fn exact_from(value: T) -> Self;\n}\n\n/// Converts a value from one type to another. If the conversion fails, the function panics.\n///\n/// It is recommended that this trait is not implemented directly; it is automatically implemented\n/// when [`ExactFrom`] is implemented.\npub trait ExactInto<T> {\n    fn exact_into(self) -> T;\n}\n\nimpl<T, U: TryFrom<T>> ExactFrom<T> for U {\n    #[inline]\n    fn exact_from(value: T) -> U {\n        U::try_from(value).ok().unwrap()\n    }\n}\n\nimpl<T, U: ExactFrom<T>> ExactInto<U> for T {\n    #[inline]\n    fn exact_into(self) -> U {\n        U::exact_from(self)\n    }\n}\n\n/// Converts a value from one type to another. where if the conversion is not exact the result will\n/// wrap around.\n///\n/// If `WrappingFrom` is implemented, it usually makes sense to implement [`OverflowingFrom`] as\n/// well.\npub trait WrappingFrom<T>: Sized {\n    fn wrapping_from(value: T) -> Self;\n}\n\n/// Converts a value from one type to another, where if the conversion is not exact the result will\n/// wrap around.\n///\n/// It is recommended that this trait is not implemented directly; it is automatically implemented\n/// when [`WrappingFrom`] is implemented.\npub trait WrappingInto<T>: Sized {\n    fn wrapping_into(self) -> T;\n}\n\nimpl<T, U: WrappingFrom<T>> WrappingInto<U> for T {\n    #[inline]\n    fn wrapping_into(self) -> U {\n        U::wrapping_from(self)\n    }\n}\n\n/// Converts a value from one type to another, where if the conversion is not exact the result is\n/// set to the maximum or minimum value of the result type, whichever is closer.\npub trait SaturatingFrom<T>: Sized {\n    fn saturating_from(value: T) -> Self;\n}\n\n/// Converts a value from one type to another, where if the conversion is not exact the result is\n/// set to the maximum or minimum value of the result type, whichever is closer.\n///\n/// It is recommended that this trait is not implemented directly; it is automatically implemented\n/// when [`SaturatingFrom`] is implemented.\npub trait SaturatingInto<T>: Sized {\n    fn saturating_into(self) -> T;\n}\n\nimpl<T, U: SaturatingFrom<T>> SaturatingInto<U> for T {\n    #[inline]\n    fn saturating_into(self) -> U {\n        U::saturating_from(self)\n    }\n}\n\n/// Converts a value from one type to another, where if the conversion is not exact the result will\n/// wrap around. The result is returned along with a [`bool`] that indicates whether wrapping has\n/// occurred.\n///\n/// If `OverflowingFrom` is implemented, it usually makes sense to implement [`WrappingFrom`] as\n/// well.\npub trait OverflowingFrom<T>: Sized {\n    fn overflowing_from(value: T) -> (Self, bool);\n}\n\n/// Converts a value from one type to another, where if the conversion is not exact the result will\n/// wrap around. The result is returned along with a [`bool`] that indicates whether wrapping has\n/// occurred.\n///\n/// It is recommended that this trait is not implemented directly; it is automatically implemented\n/// when [`OverflowingFrom`] is implemented.\npub trait OverflowingInto<T>: Sized {\n    fn overflowing_into(self) -> (T, bool);\n}\n\nimpl<T, U: OverflowingFrom<T>> OverflowingInto<U> for T {\n    #[inline]\n    fn overflowing_into(self) -> (U, bool) {\n        U::overflowing_from(self)\n    }\n}\n\n/// Converts a value from one type to another, where the conversion is made according to a specified\n/// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the returned value is\n/// less than, equal to, or greater than the original value.\npub trait RoundingFrom<T>: Sized {\n    fn rounding_from(value: T, rm: RoundingMode) -> (Self, Ordering);\n}\n\n/// Converts a value from one type to another, where the conversion is made according to a specified\n/// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the returned value is\n/// less than, equal to, or greater than the original value.\n///\n/// It is recommended that this trait is not implemented directly; it is automatically implemented\n/// when [`RoundingFrom`] is implemented.\npub trait RoundingInto<T>: Sized {\n    fn rounding_into(self, rm: RoundingMode) -> (T, Ordering);\n}\n\nimpl<T, U: RoundingFrom<T>> RoundingInto<U> for T {\n    #[inline]\n    fn rounding_into(self, rm: RoundingMode) -> (U, Ordering) {\n        U::rounding_from(self, rm)\n    }\n}\n\n/// Tests whether a value of one type is convertible into a value of another.\n///\n/// If `ConvertibleFrom<T>` for `Self` is implemented, it usually makes sense to implement\n/// [`TryFrom`] for `T` as well.\npub trait ConvertibleFrom<T> {\n    fn convertible_from(value: T) -> bool;\n}\n\n/// Associates with `Self` a type that's half `Self`'s size.\npub trait HasHalf {\n    /// The type that's half the size of `Self`.\n    type Half;\n}\n\n/// Provides a function to join two pieces into a number. For example, two [`u32`]s may be joined to\n/// form a [`u64`].\npub trait JoinHalves: HasHalf {\n    /// Joins two values into a single value; the upper, or most-significant, half comes first.\n    fn join_halves(upper: Self::Half, lower: Self::Half) -> Self;\n}\n\n/// Provides functions to split a number into two pieces. For example, a [`u64`] may be split into\n/// two [`u32`]s.\npub trait SplitInHalf: HasHalf {\n    /// Extracts the lower, or least-significant, half of a number.\n    fn lower_half(&self) -> Self::Half;\n\n    /// Extracts the upper, or most-significant half of a number.\n    fn upper_half(&self) -> Self::Half;\n\n    /// Extracts both halves of a number; the upper, or most-significant, half comes first.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(\\max(T_U(n), T_L(n)))$\n    ///\n    /// $M(n) = O(\\max(M_U(n), M_L(n)))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $T_U$ and $T_L$ are the time complexities of\n    /// the [`upper_half`](Self::upper_half) and [`lower_half`](Self::lower_half) functions,\n    /// respectively, and $M_U$ and $M_L$ are the memory complexities of the\n    /// [`upper_half`](Self::upper_half) and [`lower_half`](Self::lower_half) functions,\n    /// respectively.\n    #[inline]\n    fn split_in_half(&self) -> (Self::Half, Self::Half) {\n        (self.upper_half(), self.lower_half())\n    }\n}\n\n/// Determines whether a number is an integer.\npub trait IsInteger {\n    #[allow(clippy::wrong_self_convention)]\n    fn is_integer(self) -> bool;\n}\n\n/// Converts a number to or from a raw mantissa and exponent.\n///\n/// See [here](crate::num::basic::floats::PrimitiveFloat) for a definition of raw mantissa and\n/// exponent.\npub trait RawMantissaAndExponent<M, E, T = Self>: Sized {\n    /// Extracts the raw mantissa and exponent from a number.\n    fn raw_mantissa_and_exponent(self) -> (M, E);\n\n    /// Extracts the raw mantissa from a number.\n    fn raw_mantissa(self) -> M {\n        self.raw_mantissa_and_exponent().0\n    }\n\n    /// Extracts the raw exponent from a number.\n    fn raw_exponent(self) -> E {\n        self.raw_mantissa_and_exponent().1\n    }\n\n    /// Constructs a number from its raw mantissa and exponent.\n    fn from_raw_mantissa_and_exponent(raw_mantissa: M, raw_exponent: E) -> T;\n}\n\n/// Converts a number to or from an integer mantissa and exponent.\n///\n/// See [here](crate::num::basic::floats::PrimitiveFloat) for a definition of integer mantissa and\n/// exponent.\n///\n/// The mantissa is an odd integer, and the exponent is an integer, such that $x = 2^em$.\npub trait IntegerMantissaAndExponent<M, E, T = Self>: Sized {\n    /// Extracts the integer mantissa and exponent from a number.\n    fn integer_mantissa_and_exponent(self) -> (M, E);\n\n    /// Extracts the integer mantissa from a number.\n    fn integer_mantissa(self) -> M {\n        self.integer_mantissa_and_exponent().0\n    }\n\n    /// Extracts the integer exponent from a number.\n    fn integer_exponent(self) -> E {\n        self.integer_mantissa_and_exponent().1\n    }\n\n    /// Constructs a number from its integer mantissa and exponent.\n    fn from_integer_mantissa_and_exponent(integer_mantissa: M, integer_exponent: E) -> Option<T>;\n}\n\n/// Converts a number to or from a scientific mantissa and exponent.\n///\n/// See [here](crate::num::basic::floats::PrimitiveFloat) for a definition of scientific mantissa\n/// and exponent.\npub trait SciMantissaAndExponent<M, E, T = Self>: Sized {\n    /// Extracts the scientific mantissa and exponent from a number.\n    fn sci_mantissa_and_exponent(self) -> (M, E);\n\n    /// Extracts the scientific mantissa from a number.\n    fn sci_mantissa(self) -> M {\n        self.sci_mantissa_and_exponent().0\n    }\n\n    /// Extracts the scientific exponent from a number.\n    fn sci_exponent(self) -> E {\n        self.sci_mantissa_and_exponent().1\n    }\n\n    /// Constructs a number from its scientific mantissa and exponent.\n    fn from_sci_mantissa_and_exponent(sci_mantissa: M, sci_exponent: E) -> Option<T>;\n}\n\n/// Converts a slice of one type of value to a single value of another type.\npub trait FromOtherTypeSlice<T: Sized> {\n    fn from_other_type_slice(slice: &[T]) -> Self;\n}\n\n/// Converts a slice of one type of value to a [`Vec`] of another type.\npub trait VecFromOtherTypeSlice<T: Sized>: Sized {\n    fn vec_from_other_type_slice(slice: &[T]) -> Vec<Self>;\n}\n\n/// Converts a slice of one type of value to a [`Vec`] of another type.\npub trait VecFromOtherType<T>: Sized {\n    fn vec_from_other_type(value: T) -> Vec<Self>;\n}\n"
  },
  {
    "path": "malachite-base/src/num/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::iterators::{NonzeroValues, nonzero_values};\nuse crate::num::arithmetic::traits::{PowerOf2, RoundToMultipleOfPowerOf2};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::float::NiceFloat;\nuse crate::num::iterators::{RulerSequence, ruler_sequence};\nuse crate::num::logic::traits::{BitAccess, NotAssign, SignificantBits};\nuse crate::rounding_modes::RoundingMode::*;\nuse crate::tuples::exhaustive::{\n    ExhaustiveDependentPairs, ExhaustiveDependentPairsYsGenerator, LexDependentPairs,\n    exhaustive_dependent_pairs, lex_dependent_pairs,\n};\nuse alloc::vec::IntoIter;\nuse alloc::vec::Vec;\nuse core::iter::{Chain, Once, Rev, once};\nuse core::marker::PhantomData;\nuse itertools::{Interleave, Itertools};\n\n/// Generates all primitive integers in an interval.\n///\n/// This `struct` is created by [`primitive_int_increasing_range`] and\n/// [`primitive_int_increasing_inclusive_range`]; see their documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct PrimitiveIntIncreasingRange<T: PrimitiveInt> {\n    a: Option<T>,\n    b: Option<T>,\n}\n\nimpl<T: PrimitiveInt> Iterator for PrimitiveIntIncreasingRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.a == self.b {\n            None\n        } else {\n            let result = self.a;\n            self.a = result.and_then(|x| x.checked_add(T::ONE));\n            result\n        }\n    }\n}\n\nimpl<T: PrimitiveInt> DoubleEndedIterator for PrimitiveIntIncreasingRange<T> {\n    fn next_back(&mut self) -> Option<T> {\n        if self.a == self.b {\n            None\n        } else {\n            self.b = Some(self.b.map_or(T::MAX, |b| b - T::ONE));\n            self.b\n        }\n    }\n}\n\n/// Generates all values of a signed integer type in an interval, in order of increasing absolute\n/// value.\n///\n/// This `enum` is created by [`exhaustive_signed_range`] and [`exhaustive_signed_inclusive_range`];\n/// see their documentation for more.\n#[derive(Clone, Debug)]\npub enum ExhaustiveSignedRange<T: PrimitiveSigned> {\n    NonNegative(PrimitiveIntIncreasingRange<T>),\n    NonPositive(Rev<PrimitiveIntIncreasingRange<T>>),\n    BothSigns(ExhaustiveSigneds<T>),\n}\n\nimpl<T: PrimitiveSigned> Iterator for ExhaustiveSignedRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::NonNegative(xs) => xs.next(),\n            Self::NonPositive(xs) => xs.next(),\n            Self::BothSigns(xs) => xs.next(),\n        }\n    }\n}\n\n#[doc(hidden)]\npub type PrimitiveIntUpDown<T> =\n    Interleave<PrimitiveIntIncreasingRange<T>, Rev<PrimitiveIntIncreasingRange<T>>>;\n\n/// Generates all unsigned integers in ascending order.\n///\n/// The output is $(k)_{k=0}^{2^W-1}$, where $W$ is the width of the type.\n///\n/// The output length is $2^W$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_unsigneds;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_unsigneds::<u8>(), 10),\n///     \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_unsigneds<T: PrimitiveUnsigned>() -> PrimitiveIntIncreasingRange<T> {\n    primitive_int_increasing_inclusive_range(T::ZERO, T::MAX)\n}\n\n/// Generates all positive primitive integers in ascending order.\n///\n/// Let $L=2^W-1$ if `T` is unsigned and $L=2^{W-1}-1$ if `T` is signed, where $W$ is the width of\n/// the type.\n///\n/// The output is $(k)_{k=1}^{L}$.\n///\n/// The output length is $L$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_positive_primitive_ints;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_positive_primitive_ints::<u8>(), 10),\n///     \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_positive_primitive_ints<T: PrimitiveInt>() -> PrimitiveIntIncreasingRange<T> {\n    primitive_int_increasing_inclusive_range(T::ONE, T::MAX)\n}\n\npub type ExhaustiveSigneds<T> = Chain<Once<T>, PrimitiveIntUpDown<T>>;\n\n/// Generates all signed integers in order of increasing absolute value.\n///\n/// When two numbers have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i, j \\\\in [-2^{W-1}, 2^{W-1})$, where $W$ is the width of\n/// the type, and $i < j$.\n///\n/// The output length is $2^W$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_signeds;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_signeds::<i8>(), 10),\n///     \"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_signeds<T: PrimitiveSigned>() -> ExhaustiveSigneds<T> {\n    once(T::ZERO).chain(exhaustive_nonzero_signeds())\n}\n\n/// Generates all natural (non-negative) signed integers in ascending order.\n///\n/// The output is $(k)_{k=0}^{2^{W-1}-1}$, where $W$ is the width of the type.\n///\n/// The output length is $2^{W-1}$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_natural_signeds;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_natural_signeds::<i8>(), 10),\n///     \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_natural_signeds<T: PrimitiveSigned>() -> PrimitiveIntIncreasingRange<T> {\n    primitive_int_increasing_inclusive_range(T::ZERO, T::MAX)\n}\n\n/// Generates all negative signed integers in descending order.\n///\n/// The output is $(-k)_{k=1}^{2^{W-1}}$, where $W$ is the width of the type.\n///\n/// The output length is $2^{W-1}$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_negative_signeds;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_negative_signeds::<i8>(), 10),\n///     \"[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_negative_signeds<T: PrimitiveSigned>() -> Rev<PrimitiveIntIncreasingRange<T>> {\n    primitive_int_increasing_range(T::MIN, T::ZERO).rev()\n}\n\n/// Generates all nonzero signed integers in order of increasing absolute value.\n///\n/// When two numbers have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i, j \\\\in [-2^{W-1}, 2^{W-1}) \\\\setminus \\\\{0\\\\}$, where\n/// $W$ is the width of the type, and $i < j$.\n///\n/// The output length is $2^W-1$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_nonzero_signeds;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_nonzero_signeds::<i8>(), 10),\n///     \"[1, -1, 2, -2, 3, -3, 4, -4, 5, -5, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_nonzero_signeds<T: PrimitiveSigned>() -> PrimitiveIntUpDown<T> {\n    exhaustive_positive_primitive_ints().interleave(exhaustive_negative_signeds())\n}\n\n/// Generates all primitive integers in the half-open interval $[a, b)$, in ascending order.\n///\n/// $a$ must be less than or equal to $b$. If $a$ and $b$ are equal, the range is empty. This\n/// function cannot create a range that includes `T::MAX`; for that, use\n/// [`primitive_int_increasing_inclusive_range`].\n///\n/// The output is $(k)_{k=a}^{b-1}$.\n///\n/// The output length is $b - a$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::primitive_int_increasing_range;\n///\n/// assert_eq!(\n///     primitive_int_increasing_range::<i8>(-5, 5).collect_vec(),\n///     &[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]\n/// )\n/// ```\n#[inline]\npub fn primitive_int_increasing_range<T: PrimitiveInt>(\n    a: T,\n    b: T,\n) -> PrimitiveIntIncreasingRange<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    PrimitiveIntIncreasingRange {\n        a: Some(a),\n        b: Some(b),\n    }\n}\n\n/// Generates all primitive integers in the closed interval $[a, b]$, in ascending order.\n///\n/// $a$ must be less than or equal to $b$. If $a$ and $b$ are equal, the range contains a single\n/// element.\n///\n/// The output is $(k)_{k=a}^{b}$.\n///\n/// The output length is $b - a + 1$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::primitive_int_increasing_inclusive_range;\n///\n/// assert_eq!(\n///     primitive_int_increasing_inclusive_range::<i8>(-5, 5).collect_vec(),\n///     &[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n/// )\n/// ```\n#[inline]\npub fn primitive_int_increasing_inclusive_range<T: PrimitiveInt>(\n    a: T,\n    b: T,\n) -> PrimitiveIntIncreasingRange<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    PrimitiveIntIncreasingRange {\n        a: Some(a),\n        b: b.checked_add(T::ONE),\n    }\n}\n\n/// Generates all signed integers in the half-open interval $[a, b)$, in order of increasing\n/// absolute value.\n///\n/// When two numbers have the same absolute value, the positive one comes first. $a$ must be less\n/// than or equal to $b$. If $a$ and $b$ are equal, the range is empty. This function cannot create\n/// a range that includes `T::MAX`; for that, use [`exhaustive_signed_inclusive_range`].\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i, j \\\\in [0, b - a)$ and $i < j$.\n///\n/// The output length is $b - a$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_signed_range;\n///\n/// assert_eq!(\n///     exhaustive_signed_range::<i8>(-5, 5).collect_vec(),\n///     &[0, 1, -1, 2, -2, 3, -3, 4, -4, -5]\n/// )\n/// ```\npub fn exhaustive_signed_range<T: PrimitiveSigned>(a: T, b: T) -> ExhaustiveSignedRange<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    if a >= T::ZERO {\n        ExhaustiveSignedRange::NonNegative(primitive_int_increasing_range(a, b))\n    } else if b <= T::ZERO {\n        ExhaustiveSignedRange::NonPositive(primitive_int_increasing_range(a, b).rev())\n    } else {\n        ExhaustiveSignedRange::BothSigns(\n            once(T::ZERO).chain(\n                primitive_int_increasing_range(T::ONE, b)\n                    .interleave(primitive_int_increasing_range(a, T::ZERO).rev()),\n            ),\n        )\n    }\n}\n\n/// Generates all signed integers in the closed interval $[a, b]$, in order of increasing absolute\n/// value.\n///\n/// When two numbers have the same absolute value, the positive one comes first. $a$ must be less\n/// than or equal to $b$. If $a$ and $b$ are equal, the range contains a single element.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i, j \\\\in [0, b - a]$ and $i < j$.\n///\n/// The output length is $b - a + 1$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_signed_inclusive_range;\n///\n/// assert_eq!(\n///     exhaustive_signed_inclusive_range::<i8>(-5, 5).collect_vec(),\n///     &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n/// )\n/// ```\npub fn exhaustive_signed_inclusive_range<T: PrimitiveSigned>(\n    a: T,\n    b: T,\n) -> ExhaustiveSignedRange<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    if a >= T::ZERO {\n        ExhaustiveSignedRange::NonNegative(primitive_int_increasing_inclusive_range(a, b))\n    } else if b <= T::ZERO {\n        ExhaustiveSignedRange::NonPositive(primitive_int_increasing_inclusive_range(a, b).rev())\n    } else {\n        ExhaustiveSignedRange::BothSigns(\n            once(T::ZERO).chain(\n                primitive_int_increasing_inclusive_range(T::ONE, b)\n                    .interleave(primitive_int_increasing_inclusive_range(a, T::NEGATIVE_ONE).rev()),\n            ),\n        )\n    }\n}\n\n/// Generates all primitive floats in an interval, in increasing order.\n///\n/// This `struct` implements [`DoubleEndedIterator`], so you can reverse it to generate floats in\n/// decreasing order.\n///\n/// Positive zero and negative zero are both generated. Negative zero is considered to be less than\n/// positive zero.\n///\n/// This `struct` is created by [`primitive_float_increasing_range`] and\n/// [`primitive_float_increasing_inclusive_range`]; see their documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct PrimitiveFloatIncreasingRange<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    xs: PrimitiveIntIncreasingRange<u64>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for PrimitiveFloatIncreasingRange<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.xs.next().map(T::from_ordered_representation)\n    }\n}\n\nimpl<T: PrimitiveFloat> DoubleEndedIterator for PrimitiveFloatIncreasingRange<T> {\n    #[inline]\n    fn next_back(&mut self) -> Option<T> {\n        self.xs.next_back().map(T::from_ordered_representation)\n    }\n}\n\n/// Generates all primitive floats in the half-open interval $[a, b)$, in ascending order.\n///\n/// Positive and negative zero are treated as two distinct values, with negative zero being smaller\n/// than zero.\n///\n/// `NiceFloat(a)` must be less than or equal to `NiceFloat(b)`. If `NiceFloat(a)` and\n/// `NiceFloat(b)` are equal, the range is empty. This function cannot create a range that includes\n/// `INFINITY`; for that, use [`primitive_float_increasing_inclusive_range`].\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=\\varphi(a)}^{\\varphi(b)-1}$.\n///\n/// The output length is $\\varphi(b) - \\varphi(a)$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `NiceFloat(a) > NiceFloat(b)`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::primitive_float_increasing_range;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         primitive_float_increasing_range::<f32>(1.0, 2.0).map(NiceFloat),\n///         20\n///     ),\n///     \"[1.0, 1.0000001, 1.0000002, 1.0000004, 1.0000005, 1.0000006, 1.0000007, 1.0000008, \\\n///     1.000001, 1.0000011, 1.0000012, 1.0000013, 1.0000014, 1.0000015, 1.0000017, 1.0000018, \\\n///     1.0000019, 1.000002, 1.0000021, 1.0000023, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         primitive_float_increasing_range::<f32>(1.0, 2.0)\n///             .rev()\n///             .map(NiceFloat),\n///         20,\n///     ),\n///     \"[1.9999999, 1.9999998, 1.9999996, 1.9999995, 1.9999994, 1.9999993, 1.9999992, 1.999999, \\\n///     1.9999989, 1.9999988, 1.9999987, 1.9999986, 1.9999985, 1.9999983, 1.9999982, 1.9999981, \\\n///     1.999998, 1.9999979, 1.9999977, 1.9999976, ...]\",\n/// );\n/// ```\npub fn primitive_float_increasing_range<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n) -> PrimitiveFloatIncreasingRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(\n        NiceFloat(a) <= NiceFloat(b),\n        \"a must be less than or equal to b. a: {}, b: {}\",\n        NiceFloat(a),\n        NiceFloat(b)\n    );\n    PrimitiveFloatIncreasingRange {\n        phantom: PhantomData,\n        xs: primitive_int_increasing_range(\n            a.to_ordered_representation(),\n            b.to_ordered_representation(),\n        ),\n    }\n}\n\n/// Generates all primitive floats in the closed interval $[a, b]$, in ascending order.\n///\n/// Positive and negative zero are treated as two distinct values, with negative zero being smaller\n/// than zero.\n///\n/// `NiceFloat(a)` must be less than or equal to `NiceFloat(b)`. If `NiceFloat(a)` and\n/// `NiceFloat(b)` are equal, the range contains a single element.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=\\varphi(a)}^\\varphi(b)$.\n///\n/// The output length is $\\varphi(b) - \\varphi(a) + 1$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `NiceFloat(a) > NiceFloat(b)`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::primitive_float_increasing_inclusive_range;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         primitive_float_increasing_inclusive_range::<f32>(1.0, 2.0).map(NiceFloat),\n///         20\n///     ),\n///     \"[1.0, 1.0000001, 1.0000002, 1.0000004, 1.0000005, 1.0000006, 1.0000007, 1.0000008, \\\n///     1.000001, 1.0000011, 1.0000012, 1.0000013, 1.0000014, 1.0000015, 1.0000017, 1.0000018, \\\n///     1.0000019, 1.000002, 1.0000021, 1.0000023, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         primitive_float_increasing_inclusive_range::<f32>(1.0, 2.0)\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[2.0, 1.9999999, 1.9999998, 1.9999996, 1.9999995, 1.9999994, 1.9999993, 1.9999992, \\\n///     1.999999, 1.9999989, 1.9999988, 1.9999987, 1.9999986, 1.9999985, 1.9999983, 1.9999982, \\\n///     1.9999981, 1.999998, 1.9999979, 1.9999977, ...]\"\n/// );\n/// ```\npub fn primitive_float_increasing_inclusive_range<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n) -> PrimitiveFloatIncreasingRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(\n        NiceFloat(a) <= NiceFloat(b),\n        \"a must be less than or equal to b. a: {}, b: {}\",\n        NiceFloat(a),\n        NiceFloat(b)\n    );\n    PrimitiveFloatIncreasingRange {\n        phantom: PhantomData,\n        xs: primitive_int_increasing_inclusive_range(\n            a.to_ordered_representation(),\n            b.to_ordered_representation(),\n        ),\n    }\n}\n\n/// Generates all finite positive primitive floats, in ascending order.\n///\n/// Positive and negative zero are both excluded.\n///\n/// [`MIN_POSITIVE_SUBNORMAL`](super::basic::floats::PrimitiveFloat::MIN_POSITIVE_SUBNORMAL) is\n/// generated first and [`MAX_FINITE`](super::basic::floats::PrimitiveFloat::MAX_FINITE) is\n/// generated last. The returned iterator is double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=2^M(2^E-1)+2}^{2^{M+1}(2^E-1)}$.\n///\n/// The output length is $2^M(2^E-1)-1$.\n/// - For [`f32`], this is $2^{31}-2^{23}-1$, or 2139095039.\n/// - For [`f64`], this is $2^{63}-2^{52}-1$, or 9218868437227405311.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::positive_finite_primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         positive_finite_primitive_floats_increasing::<f32>().map(NiceFloat),\n///         20\n///     ),\n///     \"[1.0e-45, 3.0e-45, 4.0e-45, 6.0e-45, 7.0e-45, 8.0e-45, 1.0e-44, 1.1e-44, 1.3e-44, \\\n///     1.4e-44, 1.5e-44, 1.7e-44, 1.8e-44, 2.0e-44, 2.1e-44, 2.2e-44, 2.4e-44, 2.5e-44, 2.7e-44, \\\n///     2.8e-44, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         positive_finite_primitive_floats_increasing::<f32>()\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[3.4028235e38, 3.4028233e38, 3.402823e38, 3.4028229e38, 3.4028227e38, 3.4028225e38, \\\n///     3.4028222e38, 3.402822e38, 3.4028218e38, 3.4028216e38, 3.4028214e38, 3.4028212e38, \\\n///     3.402821e38, 3.4028208e38, 3.4028206e38, 3.4028204e38, 3.4028202e38, 3.40282e38, \\\n///     3.4028198e38, 3.4028196e38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn positive_finite_primitive_floats_increasing<T: PrimitiveFloat>()\n-> PrimitiveFloatIncreasingRange<T> {\n    primitive_float_increasing_inclusive_range(T::MIN_POSITIVE_SUBNORMAL, T::MAX_FINITE)\n}\n\n/// Generates all finite negative primitive floats, in ascending order.\n///\n/// Positive and negative zero are both excluded.\n///\n/// [`-MAX_FINITE`](super::basic::floats::PrimitiveFloat::MAX_FINITE) is generated first and\n/// [`-MIN_POSITIVE_SUBNORMAL`](super::basic::floats::PrimitiveFloat::MIN_POSITIVE_SUBNORMAL) is\n/// generated last. The returned iterator is double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=1}^{2^M(2^E-1)-1}$.\n///\n/// The output length is $2^M(2^E-1)-1$.\n/// - For [`f32`], this is $2^{31}-2^{23}-1$, or 2139095039.\n/// - For [`f64`], this is $2^{63}-2^{52}-1$, or 9218868437227405311.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::negative_finite_primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         negative_finite_primitive_floats_increasing::<f32>().map(NiceFloat),\n///         20\n///     ),\n///     \"[-3.4028235e38, -3.4028233e38, -3.402823e38, -3.4028229e38, -3.4028227e38, \\\n///     -3.4028225e38, -3.4028222e38, -3.402822e38, -3.4028218e38, -3.4028216e38, -3.4028214e38, \\\n///     -3.4028212e38, -3.402821e38, -3.4028208e38, -3.4028206e38, -3.4028204e38, -3.4028202e38, \\\n///     -3.40282e38, -3.4028198e38, -3.4028196e38, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         negative_finite_primitive_floats_increasing::<f32>()\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[-1.0e-45, -3.0e-45, -4.0e-45, -6.0e-45, -7.0e-45, -8.0e-45, -1.0e-44, -1.1e-44, \\\n///     -1.3e-44, -1.4e-44, -1.5e-44, -1.7e-44, -1.8e-44, -2.0e-44, -2.1e-44, -2.2e-44, -2.4e-44, \\\n///     -2.5e-44, -2.7e-44, -2.8e-44, ...]\"\n/// );\n/// ```\n#[inline]\npub fn negative_finite_primitive_floats_increasing<T: PrimitiveFloat>()\n-> PrimitiveFloatIncreasingRange<T> {\n    primitive_float_increasing_inclusive_range(-T::MAX_FINITE, -T::MIN_POSITIVE_SUBNORMAL)\n}\n\n/// Generates all finite nonzero primitive floats, in ascending order.\n///\n/// Positive and negative zero are both excluded.\n///\n/// [-`MAX_FINITE`](super::basic::floats::PrimitiveFloat::MAX_FINITE) is generated first and\n/// [`MAX_FINITE`](super::basic::floats::PrimitiveFloat::MAX_FINITE) is generated last. The returned\n/// iterator is double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is\n/// $$\n/// (\\varphi^{-1}(k))_ {k=1}^{2^M(2^E-1)-1} ⧺ (\\varphi^{-1}(k))_ {k=2^M(2^E-1)+2}^{2^{M+1}(2^E-1)}\n/// $$.\n///\n/// The output length is $2^{M+1}(2^E-1)-2$.\n/// - For [`f32`], this is $2^{32}-2^{24}-2$, or 4278190078.\n/// - For [`f64`], this is $2^{64}-2^{53}-2$, or 18437736874454810622.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::nonzero_finite_primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         nonzero_finite_primitive_floats_increasing::<f32>().map(NiceFloat),\n///         20\n///     ),\n///     \"[-3.4028235e38, -3.4028233e38, -3.402823e38, -3.4028229e38, -3.4028227e38, \\\n///     -3.4028225e38, -3.4028222e38, -3.402822e38, -3.4028218e38, -3.4028216e38, -3.4028214e38, \\\n///     -3.4028212e38, -3.402821e38, -3.4028208e38, -3.4028206e38, -3.4028204e38, -3.4028202e38, \\\n///     -3.40282e38, -3.4028198e38, -3.4028196e38, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         nonzero_finite_primitive_floats_increasing::<f32>()\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[3.4028235e38, 3.4028233e38, 3.402823e38, 3.4028229e38, 3.4028227e38, 3.4028225e38, \\\n///     3.4028222e38, 3.402822e38, 3.4028218e38, 3.4028216e38, 3.4028214e38, 3.4028212e38, \\\n///     3.402821e38, 3.4028208e38, 3.4028206e38, 3.4028204e38, 3.4028202e38, 3.40282e38, \\\n///     3.4028198e38, 3.4028196e38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn nonzero_finite_primitive_floats_increasing<T: PrimitiveFloat>()\n-> NonzeroValues<PrimitiveFloatIncreasingRange<T>> {\n    nonzero_values(finite_primitive_floats_increasing())\n}\n\n/// Generates all finite primitive floats, in ascending order.\n///\n/// Positive and negative zero are both included. Negative zero comes first.\n///\n/// [`-MAX_FINITE`](super::basic::floats::PrimitiveFloat::MAX_FINITE) is generated first and\n/// [`MAX_FINITE`](super::basic::floats::PrimitiveFloat::MAX_FINITE) is generated last. The\n/// returned iterator is double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=1}^{2^{M+1}(2^E-1)}$.\n///\n/// The output length is $2^{M+1}(2^E-1)$.\n/// - For [`f32`], this is $2^{32}-2^{24}$, or 4278190080.\n/// - For [`f64`], this is $2^{64}-2^{53}$, or 18437736874454810624.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::finite_primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         finite_primitive_floats_increasing::<f32>().map(NiceFloat),\n///         20\n///     ),\n///     \"[-3.4028235e38, -3.4028233e38, -3.402823e38, -3.4028229e38, -3.4028227e38, \\\n///     -3.4028225e38, -3.4028222e38, -3.402822e38, -3.4028218e38, -3.4028216e38, -3.4028214e38, \\\n///     -3.4028212e38, -3.402821e38, -3.4028208e38, -3.4028206e38, -3.4028204e38, -3.4028202e38, \\\n///     -3.40282e38, -3.4028198e38, -3.4028196e38, ...]\",\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         finite_primitive_floats_increasing::<f32>()\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[3.4028235e38, 3.4028233e38, 3.402823e38, 3.4028229e38, 3.4028227e38, 3.4028225e38, \\\n///     3.4028222e38, 3.402822e38, 3.4028218e38, 3.4028216e38, 3.4028214e38, 3.4028212e38, \\\n///     3.402821e38, 3.4028208e38, 3.4028206e38, 3.4028204e38, 3.4028202e38, 3.40282e38, \\\n///     3.4028198e38, 3.4028196e38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn finite_primitive_floats_increasing<T: PrimitiveFloat>() -> PrimitiveFloatIncreasingRange<T> {\n    primitive_float_increasing_inclusive_range(-T::MAX_FINITE, T::MAX_FINITE)\n}\n\n/// Generates all positive primitive floats, in ascending order.\n///\n/// Positive and negative zero are both excluded.\n///\n/// [`MIN_POSITIVE_SUBNORMAL`](super::basic::floats::PrimitiveFloat::MIN_POSITIVE_SUBNORMAL) is\n/// generated first and `INFINITY` is generated last. The returned iterator is\n/// double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=2^M(2^E-1)+2}^{2^{M+1}(2^E-1)+1}$.\n///\n/// The output length is $2^M(2^E-1)$.\n/// - For [`f32`], this is $2^{31}-2^{23}$, or 2139095040.\n/// - For [`f64`], this is $2^{63}-2^{52}$, or 9218868437227405312.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::positive_primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         positive_primitive_floats_increasing::<f32>().map(NiceFloat),\n///         20\n///     ),\n///     \"[1.0e-45, 3.0e-45, 4.0e-45, 6.0e-45, 7.0e-45, 8.0e-45, 1.0e-44, 1.1e-44, 1.3e-44, \\\n///     1.4e-44, 1.5e-44, 1.7e-44, 1.8e-44, 2.0e-44, 2.1e-44, 2.2e-44, 2.4e-44, 2.5e-44, 2.7e-44, \\\n///     2.8e-44, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         positive_primitive_floats_increasing::<f32>()\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[Infinity, 3.4028235e38, 3.4028233e38, 3.402823e38, 3.4028229e38, 3.4028227e38, \\\n///     3.4028225e38, 3.4028222e38, 3.402822e38, 3.4028218e38, 3.4028216e38, 3.4028214e38, \\\n///     3.4028212e38, 3.402821e38, 3.4028208e38, 3.4028206e38, 3.4028204e38, 3.4028202e38, \\\n///     3.40282e38, 3.4028198e38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn positive_primitive_floats_increasing<T: PrimitiveFloat>() -> PrimitiveFloatIncreasingRange<T>\n{\n    primitive_float_increasing_inclusive_range(T::MIN_POSITIVE_SUBNORMAL, T::INFINITY)\n}\n\n/// Generates all negative primitive floats, in ascending order.\n///\n/// Positive and negative zero are both excluded.\n///\n/// `NEGATIVE_INFINITY` is generated first and\n/// [`-MIN_POSITIVE_SUBNORMAL`](super::basic::floats::PrimitiveFloat::MIN_POSITIVE_SUBNORMAL) is\n/// generated last. The returned iterator is double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=0}^{2^M(2^E-1)-1}$.\n///\n/// The output length is $2^M(2^E-1)$.\n/// - For [`f32`], this is $2^{31}-2^{23}$, or 2139095040.\n/// - For [`f64`], this is $2^{63}-2^{52}$, or 9218868437227405312.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::negative_primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         negative_primitive_floats_increasing::<f32>().map(NiceFloat),\n///         20\n///     ),\n///     \"[-Infinity, -3.4028235e38, -3.4028233e38, -3.402823e38, -3.4028229e38, -3.4028227e38, \\\n///     -3.4028225e38, -3.4028222e38, -3.402822e38, -3.4028218e38, -3.4028216e38, -3.4028214e38, \\\n///     -3.4028212e38, -3.402821e38, -3.4028208e38, -3.4028206e38, -3.4028204e38, -3.4028202e38, \\\n///     -3.40282e38, -3.4028198e38, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         negative_primitive_floats_increasing::<f32>()\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[-1.0e-45, -3.0e-45, -4.0e-45, -6.0e-45, -7.0e-45, -8.0e-45, -1.0e-44, -1.1e-44, \\\n///     -1.3e-44, -1.4e-44, -1.5e-44, -1.7e-44, -1.8e-44, -2.0e-44, -2.1e-44, -2.2e-44, -2.4e-44, \\\n///     -2.5e-44, -2.7e-44, -2.8e-44, ...]\"\n/// );\n/// ```\n#[inline]\npub fn negative_primitive_floats_increasing<T: PrimitiveFloat>() -> PrimitiveFloatIncreasingRange<T>\n{\n    primitive_float_increasing_inclusive_range(T::NEGATIVE_INFINITY, -T::MIN_POSITIVE_SUBNORMAL)\n}\n\n/// Generates all nonzero primitive floats, in ascending order.\n///\n/// Positive and negative zero are both excluded.\n///\n/// `NEGATIVE_INFINITY` is generated first and `INFINITY` is generated last. The returned\n/// iterator is double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is\n/// $$\n/// (\\varphi^{-1}(k))_ {k=0}^{2^M(2^E-1)-1} ⧺ (\\varphi^{-1}(k))_\n/// {k=2^M(2^E-1)+2}^{2^{M+1}(2^E-1)+1} $$.\n///\n/// The output length is $2^{M+1}(2^E-1)$.\n/// - For [`f32`], this is $2^{32}-2^{24}$, or 4278190080.\n/// - For [`f64`], this is $2^{64}-2^{53}$, or 18437736874454810624.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::nonzero_primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         nonzero_primitive_floats_increasing::<f32>().map(NiceFloat),\n///         20\n///     ),\n///     \"[-Infinity, -3.4028235e38, -3.4028233e38, -3.402823e38, -3.4028229e38, -3.4028227e38, \\\n///     -3.4028225e38, -3.4028222e38, -3.402822e38, -3.4028218e38, -3.4028216e38, -3.4028214e38, \\\n///     -3.4028212e38, -3.402821e38, -3.4028208e38, -3.4028206e38, -3.4028204e38, -3.4028202e38, \\\n///     -3.40282e38, -3.4028198e38, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         nonzero_primitive_floats_increasing::<f32>()\n///             .rev()\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[Infinity, 3.4028235e38, 3.4028233e38, 3.402823e38, 3.4028229e38, 3.4028227e38, \\\n///     3.4028225e38, 3.4028222e38, 3.402822e38, 3.4028218e38, 3.4028216e38, 3.4028214e38, \\\n///     3.4028212e38, 3.402821e38, 3.4028208e38, 3.4028206e38, 3.4028204e38, 3.4028202e38, \\\n///     3.40282e38, 3.4028198e38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn nonzero_primitive_floats_increasing<T: PrimitiveFloat>()\n-> NonzeroValues<PrimitiveFloatIncreasingRange<T>> {\n    nonzero_values(primitive_floats_increasing())\n}\n\n/// Generates all primitive floats, except `NaN`, in ascending order.\n///\n/// Positive and negative zero are both included. Negative zero comes first.\n///\n/// `NEGATIVE_INFINITY` is generated first and `INFINITY` is generated last. The returned iterator\n/// is double-ended, so it may be reversed.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output is $(\\varphi^{-1}(k))_{k=0}^{2^{M+1}(2^E-1)+1}$.\n///\n/// The output length is $2^{M+1}(2^E-1)+2$.\n/// - For [`f32`], this is $2^{32}-2^{24}+2$, or 4278190082.\n/// - For [`f64`], this is $2^{64}-2^{53}+2$, or 18437736874454810626.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::primitive_floats_increasing;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(primitive_floats_increasing::<f32>().map(NiceFloat), 20),\n///     \"[-Infinity, -3.4028235e38, -3.4028233e38, -3.402823e38, -3.4028229e38, -3.4028227e38, \\\n///     -3.4028225e38, -3.4028222e38, -3.402822e38, -3.4028218e38, -3.4028216e38, -3.4028214e38, \\\n///     -3.4028212e38, -3.402821e38, -3.4028208e38, -3.4028206e38, -3.4028204e38, -3.4028202e38, \\\n///     -3.40282e38, -3.4028198e38, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         primitive_floats_increasing::<f32>().rev().map(NiceFloat),\n///         20\n///     ),\n///     \"[Infinity, 3.4028235e38, 3.4028233e38, 3.402823e38, 3.4028229e38, 3.4028227e38, \\\n///     3.4028225e38, 3.4028222e38, 3.402822e38, 3.4028218e38, 3.4028216e38, 3.4028214e38, \\\n///     3.4028212e38, 3.402821e38, 3.4028208e38, 3.4028206e38, 3.4028204e38, 3.4028202e38, \\\n///     3.40282e38, 3.4028198e38, ...]\"\n/// );\n/// ```\npub fn primitive_floats_increasing<T: PrimitiveFloat>() -> PrimitiveFloatIncreasingRange<T> {\n    primitive_float_increasing_inclusive_range(T::NEGATIVE_INFINITY, T::INFINITY)\n}\n\n/// Generates all finite positive primitive floats with a specified `sci_exponent` and precision.\n///\n/// This `struct` is created by [`exhaustive_primitive_floats_with_sci_exponent_and_precision`]; see\n/// its documentation for more.\n#[derive(Clone, Debug, Default)]\npub struct ConstantPrecisionPrimitiveFloats<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    n: u64,\n    increment: u64,\n    i: u64,\n    count: u64,\n}\n\nimpl<T: PrimitiveFloat> Iterator for ConstantPrecisionPrimitiveFloats<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.i == self.count {\n            None\n        } else {\n            let out = T::from_bits(self.n);\n            self.i += 1;\n            if self.i < self.count {\n                self.n += self.increment;\n            }\n            Some(out)\n        }\n    }\n}\n\n/// Generates all finite positive primitive floats with a specified `sci_exponent` and precision.\n///\n/// Positive and negative zero are both excluded.\n///\n/// A finite positive primitive float may be uniquely expressed as $x = m_s2^e_s$, where $1 \\leq m_s\n/// < 2$ and $e_s$ is an integer; then $e_s$ is the sci-exponent. An integer $e_s$ occurs as the\n/// sci-exponent of a float iff $2-2^{E-1}-M \\leq e_s < 2^{E-1}$.\n///\n/// In the above equation, $m$ is a dyadic rational. Let $p$ be the smallest integer such that\n/// $m2^{p-1}$ is an integer. Then $p$ is the float's precision. It is also the number of\n/// significant bits.\n///\n/// For example, consider the float $100.0$. It may be written as $\\frac{25}{16}2^6$, so\n/// $m=\\frac{25}{16}$ and $e=6$. We can write $m$ in binary as $1.1001_2$. Thus, the sci-exponent is\n/// 6 and the precision is 5.\n///\n/// If $p$ is 1, the output length is 1; otherwise, it is $2^{p-2}$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if the sci-exponent is less than\n/// [`MIN_EXPONENT`](super::basic::floats::PrimitiveFloat::MIN_EXPONENT) or greater than\n/// [`MAX_EXPONENT`](super::basic::floats::PrimitiveFloat::MAX_EXPONENT), or if the precision is\n/// zero or too large for the given sci-exponent (this can be checked using\n/// [`max_precision_for_sci_exponent`](super::basic::floats::PrimitiveFloat::max_precision_for_sci_exponent)).\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::*;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     exhaustive_primitive_floats_with_sci_exponent_and_precision::<f32>(0, 3)\n///         .map(NiceFloat)\n///         .collect_vec(),\n///     [1.25, 1.75].iter().copied().map(NiceFloat).collect_vec()\n/// );\n/// assert_eq!(\n///     exhaustive_primitive_floats_with_sci_exponent_and_precision::<f32>(0, 5)\n///         .map(NiceFloat)\n///         .collect_vec(),\n///     [1.0625, 1.1875, 1.3125, 1.4375, 1.5625, 1.6875, 1.8125, 1.9375]\n///         .iter()\n///         .copied()\n///         .map(NiceFloat)\n///         .collect_vec()\n/// );\n/// assert_eq!(\n///     exhaustive_primitive_floats_with_sci_exponent_and_precision::<f32>(6, 5)\n///         .map(NiceFloat)\n///         .collect_vec(),\n///     [68.0, 76.0, 84.0, 92.0, 100.0, 108.0, 116.0, 124.0]\n///         .iter()\n///         .copied()\n///         .map(NiceFloat)\n///         .collect_vec()\n/// );\n/// ```\npub fn exhaustive_primitive_floats_with_sci_exponent_and_precision<T: PrimitiveFloat>(\n    sci_exponent: i64,\n    precision: u64,\n) -> ConstantPrecisionPrimitiveFloats<T> {\n    assert!(sci_exponent >= T::MIN_EXPONENT);\n    assert!(sci_exponent <= T::MAX_EXPONENT);\n    assert_ne!(precision, 0);\n    let max_precision = T::max_precision_for_sci_exponent(sci_exponent);\n    assert!(precision <= max_precision);\n    let increment = u64::power_of_2(max_precision - precision + 1);\n    let first_mantissa = if precision == 1 {\n        1\n    } else {\n        u64::power_of_2(precision - 1) | 1\n    };\n    let first = T::from_integer_mantissa_and_exponent(\n        first_mantissa,\n        sci_exponent - i64::exact_from(precision) + 1,\n    )\n    .unwrap()\n    .to_bits();\n    let count = if precision == 1 {\n        1\n    } else {\n        u64::power_of_2(precision - 2)\n    };\n    ConstantPrecisionPrimitiveFloats {\n        phantom: PhantomData,\n        n: first,\n        increment,\n        i: 0,\n        count,\n    }\n}\n\n#[derive(Clone, Debug)]\nstruct PrimitiveFloatsWithExponentGenerator<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    sci_exponent: i64,\n}\n\nimpl<T: PrimitiveFloat>\n    ExhaustiveDependentPairsYsGenerator<u64, T, ConstantPrecisionPrimitiveFloats<T>>\n    for PrimitiveFloatsWithExponentGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &precision: &u64) -> ConstantPrecisionPrimitiveFloats<T> {\n        exhaustive_primitive_floats_with_sci_exponent_and_precision(self.sci_exponent, precision)\n    }\n}\n\n#[inline]\nfn exhaustive_primitive_floats_with_sci_exponent_helper<T: PrimitiveFloat>(\n    sci_exponent: i64,\n) -> LexDependentPairs<\n    u64,\n    T,\n    PrimitiveFloatsWithExponentGenerator<T>,\n    PrimitiveIntIncreasingRange<u64>,\n    ConstantPrecisionPrimitiveFloats<T>,\n> {\n    lex_dependent_pairs(\n        primitive_int_increasing_inclusive_range(\n            1,\n            T::max_precision_for_sci_exponent(sci_exponent),\n        ),\n        PrimitiveFloatsWithExponentGenerator {\n            phantom: PhantomData,\n            sci_exponent,\n        },\n    )\n}\n\n/// Generates all positive finite primitive floats with a specified `sci_exponent`.\n///\n/// This `struct` is created by [`exhaustive_primitive_floats_with_sci_exponent`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustivePrimitiveFloatsWithExponent<T: PrimitiveFloat>(\n    LexDependentPairs<\n        u64,\n        T,\n        PrimitiveFloatsWithExponentGenerator<T>,\n        PrimitiveIntIncreasingRange<u64>,\n        ConstantPrecisionPrimitiveFloats<T>,\n    >,\n);\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustivePrimitiveFloatsWithExponent<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all positive finite primitive floats with a specified sci-exponent.\n///\n/// Positive and negative zero are both excluded.\n///\n/// A finite positive primitive float may be uniquely expressed as $x = m_s2^e_s$, where $1 \\leq m_s\n/// < 2$ and $e_s$ is an integer; then $e$ is the sci-exponent. An integer $e_s$ occurs as the\n/// sci-exponent of a float iff $2-2^{E-1}-M \\leq e_s < 2^{E-1}$.\n///\n/// If $e_s \\geq 2-2^{E-1}$ (the float is normal), the output length is $2^M$.\n/// - For [`f32`], this is $2^{23}$, or 8388608.\n/// - For [`f64`], this is $2^{52}$, or 4503599627370496.\n///\n/// If $e_s < 2-2^{E-1}$ (the float is subnormal), the output length is $2^{e_s+2^{E-1}+M-2}$.\n/// - For [`f32`], this is $2^{e_s+149}$.\n/// - For [`f64`], this is $2^{e_s+1074}$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if the sci-exponent is less than\n/// [`MIN_EXPONENT`](super::basic::floats::PrimitiveFloat::MIN_EXPONENT) or greater than\n/// [`MAX_EXPONENT`](super::basic::floats::PrimitiveFloat::MAX_EXPONENT).\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_primitive_floats_with_sci_exponent;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_primitive_floats_with_sci_exponent::<f32>(0).map(NiceFloat),\n///         20\n///     ),\n///     \"[1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375, \\\n///     1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, ...]\",\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_primitive_floats_with_sci_exponent::<f32>(4).map(NiceFloat),\n///         20\n///     ),\n///     \"[16.0, 24.0, 20.0, 28.0, 18.0, 22.0, 26.0, 30.0, 17.0, 19.0, 21.0, 23.0, 25.0, 27.0, \\\n///     29.0, 31.0, 16.5, 17.5, 18.5, 19.5, ...]\"\n/// );\n/// assert_eq!(\n///     exhaustive_primitive_floats_with_sci_exponent::<f32>(-147)\n///         .map(NiceFloat)\n///         .collect_vec(),\n///     [6.0e-45, 8.0e-45, 7.0e-45, 1.0e-44]\n///         .iter()\n///         .copied()\n///         .map(NiceFloat)\n///         .collect_vec()\n/// );\n/// ```\n#[inline]\npub fn exhaustive_primitive_floats_with_sci_exponent<T: PrimitiveFloat>(\n    sci_exponent: i64,\n) -> ExhaustivePrimitiveFloatsWithExponent<T> {\n    ExhaustivePrimitiveFloatsWithExponent(exhaustive_primitive_floats_with_sci_exponent_helper(\n        sci_exponent,\n    ))\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustivePositiveFinitePrimitiveFloatsGenerator<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveFloat>\n    ExhaustiveDependentPairsYsGenerator<i64, T, ExhaustivePrimitiveFloatsWithExponent<T>>\n    for ExhaustivePositiveFinitePrimitiveFloatsGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &sci_exponent: &i64) -> ExhaustivePrimitiveFloatsWithExponent<T> {\n        exhaustive_primitive_floats_with_sci_exponent(sci_exponent)\n    }\n}\n\n#[inline]\nfn exhaustive_positive_finite_primitive_floats_helper<T: PrimitiveFloat>()\n-> ExhaustiveDependentPairs<\n    i64,\n    T,\n    RulerSequence<usize>,\n    ExhaustivePositiveFinitePrimitiveFloatsGenerator<T>,\n    ExhaustiveSignedRange<i64>,\n    ExhaustivePrimitiveFloatsWithExponent<T>,\n> {\n    exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_signed_inclusive_range(T::MIN_EXPONENT, T::MAX_EXPONENT),\n        ExhaustivePositiveFinitePrimitiveFloatsGenerator {\n            phantom: PhantomData,\n        },\n    )\n}\n\n/// Generates all positive finite primitive floats.\n///\n/// This `struct` is created by [`exhaustive_positive_finite_primitive_floats`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustivePositiveFinitePrimitiveFloats<T: PrimitiveFloat>(\n    ExhaustiveDependentPairs<\n        i64,\n        T,\n        RulerSequence<usize>,\n        ExhaustivePositiveFinitePrimitiveFloatsGenerator<T>,\n        ExhaustiveSignedRange<i64>,\n        ExhaustivePrimitiveFloatsWithExponent<T>,\n    >,\n);\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustivePositiveFinitePrimitiveFloats<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all positive finite primitive floats.\n///\n/// Positive and negative zero are both excluded.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats in\n/// ascending order instead, use [`positive_finite_primitive_floats_increasing`].\n///\n/// The output length is $2^M(2^E-1)-1$.\n/// - For [`f32`], this is $2^{31}-2^{23}-1$, or 2139095039.\n/// - For [`f64`], this is $2^{63}-2^{52}-1$, or 9218868437227405311.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_positive_finite_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_positive_finite_primitive_floats::<f32>().map(NiceFloat),\n///         50\n///     ),\n///     \"[1.0, 2.0, 1.5, 0.5, 1.25, 3.0, 1.75, 4.0, 1.125, 2.5, 1.375, 0.75, 1.625, 3.5, 1.875, \\\n///     0.25, 1.0625, 2.25, 1.1875, 0.625, 1.3125, 2.75, 1.4375, 6.0, 1.5625, 3.25, 1.6875, 0.875, \\\n///     1.8125, 3.75, 1.9375, 8.0, 1.03125, 2.125, 1.09375, 0.5625, 1.15625, 2.375, 1.21875, 5.0, \\\n///     1.28125, 2.625, 1.34375, 0.6875, 1.40625, 2.875, 1.46875, 0.375, 1.53125, 3.125, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_positive_finite_primitive_floats<T: PrimitiveFloat>()\n-> ExhaustivePositiveFinitePrimitiveFloats<T> {\n    ExhaustivePositiveFinitePrimitiveFloats(exhaustive_positive_finite_primitive_floats_helper())\n}\n\n/// Generates all negative finite primitive floats.\n///\n/// This `struct` is created by [`exhaustive_negative_finite_primitive_floats`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveNegativeFinitePrimitiveFloats<T: PrimitiveFloat>(\n    ExhaustivePositiveFinitePrimitiveFloats<T>,\n);\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustiveNegativeFinitePrimitiveFloats<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.0.next().map(|f| -f)\n    }\n}\n\n/// Generates all negative finite primitive floats.\n///\n/// Positive and negative zero are both excluded.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats in\n/// ascending order instead, use [`negative_finite_primitive_floats_increasing`].\n///\n/// The output length is $2^M(2^E-1)-1$.\n/// - For [`f32`], this is $2^{31}-2^{23}-1$, or 2139095039.\n/// - For [`f64`], this is $2^{63}-2^{52}-1$, or 9218868437227405311.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_negative_finite_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_negative_finite_primitive_floats::<f32>().map(NiceFloat),\n///         50\n///     ),\n///     \"[-1.0, -2.0, -1.5, -0.5, -1.25, -3.0, -1.75, -4.0, -1.125, -2.5, -1.375, -0.75, -1.625, \\\n///     -3.5, -1.875, -0.25, -1.0625, -2.25, -1.1875, -0.625, -1.3125, -2.75, -1.4375, -6.0, \\\n///     -1.5625, -3.25, -1.6875, -0.875, -1.8125, -3.75, -1.9375, -8.0, -1.03125, -2.125, \\\n///     -1.09375, -0.5625, -1.15625, -2.375, -1.21875, -5.0, -1.28125, -2.625, -1.34375, -0.6875, \\\n///     -1.40625, -2.875, -1.46875, -0.375, -1.53125, -3.125, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_negative_finite_primitive_floats<T: PrimitiveFloat>()\n-> ExhaustiveNegativeFinitePrimitiveFloats<T> {\n    ExhaustiveNegativeFinitePrimitiveFloats(exhaustive_positive_finite_primitive_floats())\n}\n\n/// Generates all nonzero finite primitive floats.\n///\n/// This `struct` is created by [`exhaustive_nonzero_finite_primitive_floats`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveNonzeroFinitePrimitiveFloats<T: PrimitiveFloat> {\n    toggle: bool,\n    xs: ExhaustivePositiveFinitePrimitiveFloats<T>,\n    x: T,\n}\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustiveNonzeroFinitePrimitiveFloats<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.toggle.not_assign();\n        Some(if self.toggle {\n            self.x = self.xs.next().unwrap();\n            self.x\n        } else {\n            -self.x\n        })\n    }\n}\n\n/// Generates all nonzero finite primitive floats.\n///\n/// Positive and negative zero are both excluded.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats in\n/// ascending order instead, use [`nonzero_finite_primitive_floats_increasing`].\n///\n/// The output length is $2^{M+1}(2^E-1)-2$.\n/// - For [`f32`], this is $2^{32}-2^{24}-2$, or 4278190078.\n/// - For [`f64`], this is $2^{64}-2^{53}-2$, or 18437736874454810622.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_nonzero_finite_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_nonzero_finite_primitive_floats::<f32>().map(NiceFloat),\n///         50\n///     ),\n///     \"[1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75, 4.0, \\\n///     -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5, \\\n///     1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625, -0.625, \\\n///     1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, 1.5625, -1.5625, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_nonzero_finite_primitive_floats<T: PrimitiveFloat>()\n-> ExhaustiveNonzeroFinitePrimitiveFloats<T> {\n    ExhaustiveNonzeroFinitePrimitiveFloats {\n        toggle: false,\n        xs: exhaustive_positive_finite_primitive_floats(),\n        x: T::ZERO,\n    }\n}\n\npub type ExhaustiveFinitePrimitiveFloats<T> =\n    Chain<IntoIter<T>, ExhaustiveNonzeroFinitePrimitiveFloats<T>>;\n\n/// Generates all finite primitive floats.\n///\n/// Positive and negative zero are both included.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats in\n/// ascending order instead, use [`finite_primitive_floats_increasing`].\n///\n/// The output length is $2^{M+1}(2^E-1)$.\n/// - For [`f32`], this is $2^{32}-2^{24}$, or 4278190080.\n/// - For [`f64`], this is $2^{64}-2^{53}$, or 18437736874454810624.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_finite_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_finite_primitive_floats::<f32>().map(NiceFloat),\n///         50\n///     ),\n///     \"[0.0, -0.0, 1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, \\\n///     -1.75, 4.0, -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, \\\n///     3.5, -3.5, 1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, \\\n///     0.625, -0.625, 1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_finite_primitive_floats<T: PrimitiveFloat>()\n-> Chain<IntoIter<T>, ExhaustiveNonzeroFinitePrimitiveFloats<T>> {\n    ::alloc::vec![T::ZERO, T::NEGATIVE_ZERO]\n        .into_iter()\n        .chain(exhaustive_nonzero_finite_primitive_floats())\n}\n\n/// Generates all positive primitive floats.\n///\n/// Positive and negative zero are both excluded.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats in\n/// ascending order instead, use [`positive_primitive_floats_increasing`].\n///\n/// The output length is $2^M(2^E-1)$.\n/// - For [`f32`], this is $2^{31}-2^{23}$, or 2139095040.\n/// - For [`f64`], this is $2^{63}-2^{52}$, or 9218868437227405312.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_positive_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_positive_primitive_floats::<f32>().map(NiceFloat),\n///         50\n///     ),\n///     \"[Infinity, 1.0, 2.0, 1.5, 0.5, 1.25, 3.0, 1.75, 4.0, 1.125, 2.5, 1.375, 0.75, 1.625, \\\n///     3.5, 1.875, 0.25, 1.0625, 2.25, 1.1875, 0.625, 1.3125, 2.75, 1.4375, 6.0, 1.5625, 3.25, \\\n///     1.6875, 0.875, 1.8125, 3.75, 1.9375, 8.0, 1.03125, 2.125, 1.09375, 0.5625, 1.15625, \\\n///     2.375, 1.21875, 5.0, 1.28125, 2.625, 1.34375, 0.6875, 1.40625, 2.875, 1.46875, 0.375, \\\n///     1.53125, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_positive_primitive_floats<T: PrimitiveFloat>()\n-> Chain<Once<T>, ExhaustivePositiveFinitePrimitiveFloats<T>> {\n    once(T::INFINITY).chain(exhaustive_positive_finite_primitive_floats())\n}\n\n/// Generates all negative primitive floats.\n///\n/// Positive and negative zero are both excluded.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats in\n/// ascending order instead, use [`negative_primitive_floats_increasing`].\n///\n/// The output length is $2^M(2^E-1)$.\n/// - For [`f32`], this is $2^{31}-2^{23}$, or 2139095040.\n/// - For [`f64`], this is $2^{63}-2^{52}$, or 9218868437227405312.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_negative_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_negative_primitive_floats::<f32>().map(NiceFloat),\n///         50\n///     ),\n///     \"[-Infinity, -1.0, -2.0, -1.5, -0.5, -1.25, -3.0, -1.75, -4.0, -1.125, -2.5, -1.375, \\\n///     -0.75, -1.625, -3.5, -1.875, -0.25, -1.0625, -2.25, -1.1875, -0.625, -1.3125, -2.75, \\\n///     -1.4375, -6.0, -1.5625, -3.25, -1.6875, -0.875, -1.8125, -3.75, -1.9375, -8.0, -1.03125, \\\n///     -2.125, -1.09375, -0.5625, -1.15625, -2.375, -1.21875, -5.0, -1.28125, -2.625, -1.34375, \\\n///     -0.6875, -1.40625, -2.875, -1.46875, -0.375, -1.53125, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_negative_primitive_floats<T: PrimitiveFloat>()\n-> Chain<Once<T>, ExhaustiveNegativeFinitePrimitiveFloats<T>> {\n    once(T::NEGATIVE_INFINITY).chain(exhaustive_negative_finite_primitive_floats())\n}\n\n/// Generates all nonzero primitive floats.\n///\n/// Positive and negative zero are both excluded. NaN is excluded as well.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats in\n/// ascending order instead, use [`nonzero_primitive_floats_increasing`].\n///\n/// The output length is $2^{M+1}(2^E-1)$.\n/// - For [`f32`], this is $2^{32}-2^{24}$, or 4278190080.\n/// - For [`f64`], this is $2^{64}-2^{53}$, or 18437736874454810624.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_nonzero_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_nonzero_primitive_floats::<f32>().map(NiceFloat),\n///         50\n///     ),\n///     \"[Infinity, -Infinity, 1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, \\\n///     -3.0, 1.75, -1.75, 4.0, -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, \\\n///     1.625, -1.625, 3.5, -3.5, 1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, \\\n///     1.1875, -1.1875, 0.625, -0.625, 1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, \\\n///     ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_nonzero_primitive_floats<T: PrimitiveFloat>()\n-> Chain<IntoIter<T>, ExhaustiveNonzeroFinitePrimitiveFloats<T>> {\n    ::alloc::vec![T::INFINITY, T::NEGATIVE_INFINITY]\n        .into_iter()\n        .chain(exhaustive_nonzero_finite_primitive_floats())\n}\n\n/// Generates all primitive floats.\n///\n/// Positive and negative zero are both included.\n///\n/// Roughly speaking, the simplest floats are generated first. If you want to generate the floats\n/// (except `NaN`) in ascending order instead, use [`primitive_floats_increasing`].\n///\n/// The output length is $2^{M+1}(2^E-1)+2$.\n/// - For [`f32`], this is $2^{32}-2^{24}+2$, or 4278190082.\n/// - For [`f64`], this is $2^{64}-2^{53}+2$, or 18437736874454810626.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_primitive_floats;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_primitive_floats::<f32>().map(NiceFloat), 50),\n///     \"[NaN, Infinity, -Infinity, 0.0, -0.0, 1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, \\\n///     -1.25, 3.0, -3.0, 1.75, -1.75, 4.0, -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, \\\n///     -0.75, 1.625, -1.625, 3.5, -3.5, 1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, \\\n///     -2.25, 1.1875, -1.1875, 0.625, -0.625, 1.3125, -1.3125, 2.75, -2.75, 1.4375, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_primitive_floats<T: PrimitiveFloat>()\n-> Chain<IntoIter<T>, ExhaustiveNonzeroFinitePrimitiveFloats<T>> {\n    ::alloc::vec![T::NAN, T::INFINITY, T::NEGATIVE_INFINITY, T::ZERO, T::NEGATIVE_ZERO]\n        .into_iter()\n        .chain(exhaustive_nonzero_finite_primitive_floats())\n}\n\npub_test! {exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    sci_exponent: i64,\n    precision: u64\n) -> ConstantPrecisionPrimitiveFloats<T> {\n    assert!(a.is_finite());\n    assert!(b.is_finite());\n    assert!(a > T::ZERO);\n    assert!(b > T::ZERO);\n    assert!(sci_exponent >= T::MIN_EXPONENT);\n    assert!(sci_exponent <= T::MAX_EXPONENT);\n    let (am, ae) = a.raw_mantissa_and_exponent();\n    let (bm, be) = b.raw_mantissa_and_exponent();\n    let ae_actual_sci_exponent = if ae == 0 {\n        i64::wrapping_from(am.significant_bits()) + T::MIN_EXPONENT - 1\n    } else {\n        i64::wrapping_from(ae) - T::MAX_EXPONENT\n    };\n    let be_actual_sci_exponent = if be == 0 {\n        i64::wrapping_from(bm.significant_bits()) + T::MIN_EXPONENT - 1\n    } else {\n        i64::wrapping_from(be) - T::MAX_EXPONENT\n    };\n    assert_eq!(ae_actual_sci_exponent, sci_exponent);\n    assert_eq!(be_actual_sci_exponent, sci_exponent);\n    assert!(am <= bm);\n    assert_ne!(precision, 0);\n    let max_precision = T::max_precision_for_sci_exponent(sci_exponent);\n    assert!(precision <= max_precision);\n    if precision == 1 && am == 0 {\n        return ConstantPrecisionPrimitiveFloats {\n            phantom: PhantomData,\n            n: a.to_bits(),\n            increment: 0,\n            i: 0,\n            count: 1,\n        };\n    }\n    let trailing_zeros = max_precision - precision;\n    let increment = u64::power_of_2(trailing_zeros + 1);\n    let mut start_mantissa = am.round_to_multiple_of_power_of_2(trailing_zeros, Up).0;\n    if !start_mantissa.get_bit(trailing_zeros) {\n        start_mantissa.set_bit(trailing_zeros);\n    }\n    if start_mantissa > bm {\n        return ConstantPrecisionPrimitiveFloats::default();\n    }\n    let mut end_mantissa = bm.round_to_multiple_of_power_of_2(trailing_zeros, Down).0;\n    if !end_mantissa.get_bit(trailing_zeros) {\n        let adjust = u64::power_of_2(trailing_zeros);\n        if adjust > end_mantissa {\n            return ConstantPrecisionPrimitiveFloats::default();\n        }\n        end_mantissa -= adjust;\n    }\n    assert!(start_mantissa <= end_mantissa);\n    let count = ((end_mantissa - start_mantissa) >> (trailing_zeros + 1)) + 1;\n    let first = T::from_raw_mantissa_and_exponent(start_mantissa, ae).to_bits();\n    ConstantPrecisionPrimitiveFloats {\n        phantom: PhantomData,\n        n: first,\n        increment,\n        i: 0,\n        count,\n    }\n}}\n\n#[derive(Clone, Debug)]\nstruct PrimitiveFloatsWithExponentInRangeGenerator<T: PrimitiveFloat> {\n    a: T,\n    b: T,\n    sci_exponent: i64,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveFloat>\n    ExhaustiveDependentPairsYsGenerator<u64, T, ConstantPrecisionPrimitiveFloats<T>>\n    for PrimitiveFloatsWithExponentInRangeGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &precision: &u64) -> ConstantPrecisionPrimitiveFloats<T> {\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range(\n            self.a,\n            self.b,\n            self.sci_exponent,\n            precision,\n        )\n    }\n}\n\n#[inline]\nfn exhaustive_primitive_floats_with_sci_exponent_in_range_helper<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    sci_exponent: i64,\n) -> LexDependentPairs<\n    u64,\n    T,\n    PrimitiveFloatsWithExponentInRangeGenerator<T>,\n    PrimitiveIntIncreasingRange<u64>,\n    ConstantPrecisionPrimitiveFloats<T>,\n> {\n    lex_dependent_pairs(\n        primitive_int_increasing_inclusive_range(\n            1,\n            T::max_precision_for_sci_exponent(sci_exponent),\n        ),\n        PrimitiveFloatsWithExponentInRangeGenerator {\n            a,\n            b,\n            sci_exponent,\n            phantom: PhantomData,\n        },\n    )\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct ExhaustivePrimitiveFloatsWithExponentInRange<T: PrimitiveFloat>(\n    LexDependentPairs<\n        u64,\n        T,\n        PrimitiveFloatsWithExponentInRangeGenerator<T>,\n        PrimitiveIntIncreasingRange<u64>,\n        ConstantPrecisionPrimitiveFloats<T>,\n    >,\n);\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustivePrimitiveFloatsWithExponentInRange<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n#[doc(hidden)]\n#[inline]\npub fn exhaustive_primitive_floats_with_sci_exponent_in_range<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    sci_exponent: i64,\n) -> ExhaustivePrimitiveFloatsWithExponentInRange<T> {\n    ExhaustivePrimitiveFloatsWithExponentInRange(\n        exhaustive_primitive_floats_with_sci_exponent_in_range_helper(a, b, sci_exponent),\n    )\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustivePositiveFinitePrimitiveFloatsInRangeGenerator<T: PrimitiveFloat> {\n    a: T,\n    b: T,\n    a_sci_exponent: i64,\n    b_sci_exponent: i64,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveFloat>\n    ExhaustiveDependentPairsYsGenerator<i64, T, ExhaustivePrimitiveFloatsWithExponentInRange<T>>\n    for ExhaustivePositiveFinitePrimitiveFloatsInRangeGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &sci_exponent: &i64) -> ExhaustivePrimitiveFloatsWithExponentInRange<T> {\n        let a = if sci_exponent == self.a_sci_exponent {\n            self.a\n        } else {\n            T::from_integer_mantissa_and_exponent(1, sci_exponent).unwrap()\n        };\n        let b = if sci_exponent == self.b_sci_exponent {\n            self.b\n        } else {\n            T::from_integer_mantissa_and_exponent(1, sci_exponent + 1)\n                .unwrap()\n                .next_lower()\n        };\n        exhaustive_primitive_floats_with_sci_exponent_in_range(a, b, sci_exponent)\n    }\n}\n\n#[inline]\nfn exhaustive_positive_finite_primitive_floats_in_range_helper<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n) -> ExhaustiveDependentPairs<\n    i64,\n    T,\n    RulerSequence<usize>,\n    ExhaustivePositiveFinitePrimitiveFloatsInRangeGenerator<T>,\n    ExhaustiveSignedRange<i64>,\n    ExhaustivePrimitiveFloatsWithExponentInRange<T>,\n> {\n    assert!(a.is_finite());\n    assert!(b.is_finite());\n    assert!(a > T::ZERO);\n    assert!(a <= b);\n    let (am, ae) = a.raw_mantissa_and_exponent();\n    let (bm, be) = b.raw_mantissa_and_exponent();\n    let a_sci_exponent = if ae == 0 {\n        i64::wrapping_from(am.significant_bits()) + T::MIN_EXPONENT - 1\n    } else {\n        i64::wrapping_from(ae) - T::MAX_EXPONENT\n    };\n    let b_sci_exponent = if be == 0 {\n        i64::wrapping_from(bm.significant_bits()) + T::MIN_EXPONENT - 1\n    } else {\n        i64::wrapping_from(be) - T::MAX_EXPONENT\n    };\n    exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_signed_inclusive_range(a_sci_exponent, b_sci_exponent),\n        ExhaustivePositiveFinitePrimitiveFloatsInRangeGenerator {\n            a,\n            b,\n            a_sci_exponent,\n            b_sci_exponent,\n            phantom: PhantomData,\n        },\n    )\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct ExhaustivePositiveFinitePrimitiveFloatsInRange<T: PrimitiveFloat>(\n    ExhaustiveDependentPairs<\n        i64,\n        T,\n        RulerSequence<usize>,\n        ExhaustivePositiveFinitePrimitiveFloatsInRangeGenerator<T>,\n        ExhaustiveSignedRange<i64>,\n        ExhaustivePrimitiveFloatsWithExponentInRange<T>,\n    >,\n);\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustivePositiveFinitePrimitiveFloatsInRange<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n#[doc(hidden)]\n#[inline]\npub fn exhaustive_positive_finite_primitive_floats_in_range<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n) -> ExhaustivePositiveFinitePrimitiveFloatsInRange<T> {\n    ExhaustivePositiveFinitePrimitiveFloatsInRange(\n        exhaustive_positive_finite_primitive_floats_in_range_helper(a, b),\n    )\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub enum ExhaustiveNonzeroFinitePrimitiveFloatsInRange<T: PrimitiveFloat> {\n    AllPositive(ExhaustivePositiveFinitePrimitiveFloatsInRange<T>),\n    AllNegative(ExhaustivePositiveFinitePrimitiveFloatsInRange<T>),\n    PositiveAndNegative(\n        bool,\n        ExhaustivePositiveFinitePrimitiveFloatsInRange<T>,\n        ExhaustivePositiveFinitePrimitiveFloatsInRange<T>,\n    ),\n}\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustiveNonzeroFinitePrimitiveFloatsInRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::AllPositive(xs) => xs.next(),\n            Self::AllNegative(xs) => xs.next().map(T::neg),\n            Self::PositiveAndNegative(toggle, pos_xs, neg_xs) => {\n                toggle.not_assign();\n                if *toggle {\n                    pos_xs.next().or_else(|| neg_xs.next().map(T::neg))\n                } else {\n                    neg_xs.next().map(T::neg).or_else(|| pos_xs.next())\n                }\n            }\n        }\n    }\n}\n\n#[doc(hidden)]\n#[inline]\npub fn exhaustive_nonzero_finite_primitive_floats_in_range<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n) -> ExhaustiveNonzeroFinitePrimitiveFloatsInRange<T> {\n    assert!(a.is_finite());\n    assert!(b.is_finite());\n    assert!(a != T::ZERO);\n    assert!(b != T::ZERO);\n    assert!(a <= b);\n    if a > T::ZERO {\n        ExhaustiveNonzeroFinitePrimitiveFloatsInRange::AllPositive(\n            exhaustive_positive_finite_primitive_floats_in_range(a, b),\n        )\n    } else if b < T::ZERO {\n        ExhaustiveNonzeroFinitePrimitiveFloatsInRange::AllNegative(\n            exhaustive_positive_finite_primitive_floats_in_range(-b, -a),\n        )\n    } else {\n        ExhaustiveNonzeroFinitePrimitiveFloatsInRange::PositiveAndNegative(\n            false,\n            exhaustive_positive_finite_primitive_floats_in_range(T::MIN_POSITIVE_SUBNORMAL, b),\n            exhaustive_positive_finite_primitive_floats_in_range(T::MIN_POSITIVE_SUBNORMAL, -a),\n        )\n    }\n}\n\n/// Generates all primitive floats in an interval.\n///\n/// This `enum` is created by [`exhaustive_primitive_float_range`] and\n/// [`exhaustive_primitive_float_inclusive_range`]; see their documentation for more.\n#[allow(clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum ExhaustivePrimitiveFloatInclusiveRange<T: PrimitiveFloat> {\n    JustSpecials(IntoIter<T>),\n    NotJustSpecials(Chain<IntoIter<T>, ExhaustiveNonzeroFinitePrimitiveFloatsInRange<T>>),\n}\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustivePrimitiveFloatInclusiveRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::JustSpecials(xs) => xs.next(),\n            Self::NotJustSpecials(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates all primitive floats in the half-open interval $[a, b)$.\n///\n/// Positive and negative zero are treated as two distinct values, with negative zero being smaller\n/// than zero.\n///\n/// The floats are generated in a way such that simpler floats (with lower precision) are generated\n/// first. To generate floats in ascending order instead, use [`primitive_float_increasing_range`]\n/// instead.\n///\n/// `NiceFloat(a)` must be less than or equal to `NiceFloat(b)`. If `NiceFloat(a)` and\n/// `NiceFloat(b)` are equal, the range is empty.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output length is $\\varphi(b) - \\varphi(a)$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `NiceFloat(a) > NiceFloat(b)`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_primitive_float_range;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_primitive_float_range::<f32>(core::f32::consts::E, core::f32::consts::PI)\n///             .map(NiceFloat),\n///         50\n///     ),\n///     \"[3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625, \\\n///     2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625, \\\n///     2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625, \\\n///     2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375, \\\n///     2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375, \\\n///     2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_primitive_float_range<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n) -> ExhaustivePrimitiveFloatInclusiveRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(NiceFloat(a) <= NiceFloat(b));\n    if NiceFloat(a) == NiceFloat(b) {\n        ExhaustivePrimitiveFloatInclusiveRange::JustSpecials(Vec::new().into_iter())\n    } else {\n        exhaustive_primitive_float_inclusive_range(a, b.next_lower())\n    }\n}\n\n/// Generates all primitive floats in the closed interval $[a, b]$.\n///\n/// Positive and negative zero are treated as two distinct values, with negative zero being smaller\n/// than zero.\n///\n/// The floats are generated in a way such that simpler floats (with lower precision) are generated\n/// first. To generate floats in ascending order instead, use\n/// `primitive_float_increasing_inclusive_range` instead.\n///\n/// `NiceFloat(a)` must be less than or equal to `NiceFloat(b)`. If `NiceFloat(a)` and\n/// `NiceFloat(b)` are equal, the range contains a single element.\n///\n/// Let $\\varphi$ be\n/// [`to_ordered_representation`](super::basic::floats::PrimitiveFloat::to_ordered_representation):\n///\n/// The output length is $\\varphi(b) - \\varphi(a) + 1$.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `NiceFloat(a) > NiceFloat(b)`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::exhaustive::exhaustive_primitive_float_inclusive_range;\n/// use malachite_base::num::float::NiceFloat;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_primitive_float_inclusive_range::<f32>(\n///             core::f32::consts::E,\n///             core::f32::consts::PI\n///         )\n///         .map(NiceFloat),\n///         50\n///     ),\n///     \"[3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625, \\\n///     2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625, \\\n///     2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625, \\\n///     2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375, \\\n///     2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375, \\\n///     2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875, ...]\"\n/// );\n/// ```\n#[inline]\npub fn exhaustive_primitive_float_inclusive_range<T: PrimitiveFloat>(\n    mut a: T,\n    mut b: T,\n) -> ExhaustivePrimitiveFloatInclusiveRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(NiceFloat(a) <= NiceFloat(b));\n    let mut specials = Vec::new();\n    if b == T::INFINITY {\n        specials.push(T::INFINITY);\n        if a == T::INFINITY {\n            return ExhaustivePrimitiveFloatInclusiveRange::JustSpecials(specials.into_iter());\n        }\n        b = T::MAX_FINITE;\n    }\n    if a == T::NEGATIVE_INFINITY {\n        specials.push(T::NEGATIVE_INFINITY);\n        if b == T::NEGATIVE_INFINITY {\n            return ExhaustivePrimitiveFloatInclusiveRange::JustSpecials(specials.into_iter());\n        }\n        a = -T::MAX_FINITE;\n    }\n    if NiceFloat(a) <= NiceFloat(T::ZERO) && NiceFloat(b) >= NiceFloat(T::ZERO) {\n        specials.push(T::ZERO);\n    }\n    if NiceFloat(a) <= NiceFloat(T::NEGATIVE_ZERO) && NiceFloat(b) >= NiceFloat(T::NEGATIVE_ZERO) {\n        specials.push(T::NEGATIVE_ZERO);\n    }\n    if a == T::ZERO {\n        if b == T::ZERO {\n            return ExhaustivePrimitiveFloatInclusiveRange::JustSpecials(specials.into_iter());\n        }\n        a = T::MIN_POSITIVE_SUBNORMAL;\n    }\n    if b == T::ZERO {\n        b = -T::MIN_POSITIVE_SUBNORMAL;\n    }\n    ExhaustivePrimitiveFloatInclusiveRange::NotJustSpecials(\n        specials\n            .into_iter()\n            .chain(exhaustive_nonzero_finite_primitive_floats_in_range(a, b)),\n    )\n}\n"
  },
  {
    "path": "malachite-base/src/num/factorization/factor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009 Tom Boothby\n//\n//      Copyright © 2008, 2009, 2012 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::mod_pow::mul_mod_helper;\nuse crate::num::arithmetic::sqrt::{sqrt_rem_2_newton, sqrt_rem_newton};\nuse crate::num::arithmetic::traits::{\n    DivMod, FloorRoot, FloorSqrt, Gcd, ModMulPrecomputed, ModSub, ModSubAssign, Parity, PowerOf2,\n    SqrtRem, Square, WrappingAddAssign, WrappingMulAssign, WrappingSquare, WrappingSubAssign,\n    XMulYToZZ, XXDivModYToQR, XXSubYYToZZ,\n};\nuse crate::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::factorization::primes::SMALL_PRIMES;\nuse crate::num::factorization::traits::{Factor, IsPrime, IsSquare, Primes};\nuse crate::num::logic::traits::{LeadingZeros, LowMask, SignificantBits};\nuse core::mem::swap;\n\npub(crate) const MAX_FACTORS_IN_U8: usize = 4;\npub(crate) const MAX_FACTORS_IN_U16: usize = 6;\npub(crate) const MAX_FACTORS_IN_U32: usize = 9;\npub(crate) const MAX_FACTORS_IN_U64: usize = 15;\npub(crate) const MAX_FACTORS_IN_USIZE: usize = 15;\n\n/// A struct that contains the prime factorization of an integer. See implementations of the\n/// [`Factor`] trait for more information.\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct Factors<T: PrimitiveUnsigned, const N: usize> {\n    factors: [T; N],\n    exponents: [u8; N],\n}\n\n/// An iterator over [`Factors`].\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct FactorsIterator<T: PrimitiveUnsigned, const N: usize> {\n    i: usize,\n    factors: Factors<T, N>,\n}\n\nimpl<T: PrimitiveUnsigned, const N: usize> Iterator for FactorsIterator<T, N> {\n    type Item = (T, u8);\n\n    fn next(&mut self) -> Option<(T, u8)> {\n        let e = *self.factors.exponents.get(self.i)?;\n        if e == 0 {\n            return None;\n        }\n        let f = self.factors.factors[self.i];\n        self.i += 1;\n        Some((f, e))\n    }\n}\n\nimpl<T: PrimitiveUnsigned, const N: usize> IntoIterator for Factors<T, N> {\n    type IntoIter = FactorsIterator<T, N>;\n    type Item = (T, u8);\n\n    fn into_iter(self) -> FactorsIterator<T, N> {\n        FactorsIterator {\n            i: 0,\n            factors: self,\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned, const N: usize> Factors<T, N> {\n    const fn new() -> Self {\n        Self {\n            factors: [T::ZERO; N],\n            exponents: [0; N],\n        }\n    }\n\n    // This takes linear time in the number of factors, but that's ok because the number of factors\n    // is small.\n    //\n    // This is n_factor_insert from ulong_extras/factor_insert.c, FLINT 3.1.2, but it also ensures\n    // that the factors are ordered least to greatest.\n    fn insert(&mut self, factor: T, exp: u8) {\n        let mut inserting = false;\n        let mut previous_f = T::ZERO;\n        let mut previous_e = 0;\n        for (f, e) in self.factors.iter_mut().zip(self.exponents.iter_mut()) {\n            if inserting {\n                swap(&mut previous_f, f);\n                swap(&mut previous_e, e);\n                if previous_e == 0 {\n                    break;\n                }\n            } else if *e == 0 {\n                *f = factor;\n                *e = exp;\n                break;\n            } else if *f == factor {\n                *e += exp;\n                break;\n            } else if *f > factor {\n                previous_f = *f;\n                previous_e = *e;\n                *f = factor;\n                *e = exp;\n                inserting = true;\n            }\n        }\n    }\n}\n\ntype FactorsU8 = Factors<u8, MAX_FACTORS_IN_U8>;\ntype FactorsU16 = Factors<u16, MAX_FACTORS_IN_U16>;\ntype FactorsU32 = Factors<u32, MAX_FACTORS_IN_U32>;\ntype FactorsU64 = Factors<u64, MAX_FACTORS_IN_U64>;\ntype FactorsUsize = Factors<usize, MAX_FACTORS_IN_USIZE>;\n\n// This is n_divrem2_precomp when FLINT64 is false, from ulong_extras/divrem2_precomp.c, FLINT\n// 3.1.2, simplified to only include the branches used when factoring a `u32`.\nfn div_rem_precomputed_float_for_u32_factorization(a: u32, n: u32, inverse: f64) -> (u32, u32) {\n    let mut q = (f64::from(a) * inverse) as u32;\n    let r = a.wrapping_sub(q * n);\n    let ri = i32::wrapping_from(r);\n    if ri >= i32::wrapping_from(n) {\n        q += (f64::from(ri) * inverse) as u32;\n        (q + 1, a.wrapping_sub(q * n).wrapping_sub(n))\n    } else {\n        (q, r)\n    }\n}\n\n// This is n_divrem2_precomp when FLINT64 is true, from ulong_extras/divrem2_precomp.c, FLINT 3.1.2,\n// returning both q and r.\nfn div_rem_precomputed_float_u64(a: u64, n: u64, npre: f64) -> (u64, u64) {\n    if a < n {\n        return (0, a);\n    }\n    if n.get_highest_bit() {\n        return (1, a.wrapping_sub(n));\n    }\n    let (mut q, r) = if n == 1 {\n        (a, 0)\n    } else {\n        let q = ((a as f64) * npre) as u64;\n        (q, a.wrapping_sub(q.wrapping_mul(n)))\n    };\n    let ri = i64::wrapping_from(r);\n    let ni = i64::wrapping_from(n);\n    if ri < ni.wrapping_neg() {\n        q -= ((-(ri as f64)) * npre) as u64;\n    } else if ri >= ni {\n        q += ((ri as f64) * npre) as u64;\n    } else if ri < 0 {\n        return (q - 1, r.wrapping_add(n));\n    } else {\n        return (q, r);\n    }\n    let r = a.wrapping_sub(q.wrapping_mul(n));\n    let ri = i64::wrapping_from(r);\n    if ri >= ni {\n        (q + 1, r.wrapping_sub(n))\n    } else if ri < 0 {\n        (q - 1, r.wrapping_add(n))\n    } else {\n        (q, r)\n    }\n}\n\n// This is n_remove2_precomp when FLINT64 is false, from ulong_extras/remove2_precomp.c, FLINT\n// 3.1.2, returning n and exp.\nfn remove_factor_precomputed_float_u32(mut n: u32, p: u32, inverse: f64) -> (u32, u8) {\n    if p == 2 {\n        let exp = n.trailing_zeros();\n        if exp != 0 {\n            n >>= exp;\n        }\n        (n, u8::wrapping_from(exp))\n    } else {\n        let mut exp = 0;\n        while n >= p {\n            let (q, r) = div_rem_precomputed_float_for_u32_factorization(n, p, inverse);\n            if r != 0 {\n                break;\n            }\n            exp += 1;\n            n = q;\n        }\n        (n, exp)\n    }\n}\n\n// This is n_remove2_precomp when FLINT64 is true, from ulong_extras/remove2_precomp.c, FLINT 3.1.2,\n// returning n and exp.\nfn remove_factor_precomputed_float_u64(mut n: u64, p: u64, inverse: f64) -> (u64, u8) {\n    if p == 2 {\n        let exp = u64::from(n.trailing_zeros());\n        if exp != 0 {\n            n >>= exp;\n        }\n        (n, u8::wrapping_from(exp))\n    } else {\n        let mut exp = 0;\n        while n >= p {\n            let (q, r) = div_rem_precomputed_float_u64(n, p, inverse);\n            if r != 0 {\n                break;\n            }\n            exp += 1;\n            n = q;\n        }\n        (n, exp)\n    }\n}\n\n// This is n_factor_trial_range when FLINT64 is false, from ulong_extras/factor_trial.c, FLINT\n// 3.1.2, where start == 0.\nfn factor_trial_range_u32(factors: &mut FactorsU32, mut n: u32, num_primes: usize) -> u32 {\n    for p in u32::primes().take(num_primes) {\n        if p.square() > n {\n            break;\n        }\n        let exp;\n        (n, exp) = remove_factor_precomputed_float_u32(n, p, 1.0 / f64::from(p));\n        if exp != 0 {\n            factors.insert(p, exp);\n        }\n    }\n    n\n}\n\n// This is n_factor_trial_range when FLINT64 is true, from ulong_extras/factor_trial.c, FLINT 3.1.2.\nfn factor_trial_range_u64(factors: &mut FactorsU64, mut n: u64, num_primes: usize) -> u64 {\n    for p in u64::primes().take(num_primes) {\n        if p.square() > n {\n            break;\n        }\n        let exp;\n        (n, exp) = remove_factor_precomputed_float_u64(n, p, 1.0 / (p as f64));\n        if exp != 0 {\n            factors.insert(p, exp);\n        }\n    }\n    n\n}\n\nconst POWER235_MOD63: [u8; 63] = [\n    7, 7, 4, 0, 5, 4, 0, 5, 6, 5, 4, 4, 0, 4, 4, 0, 5, 4, 5, 4, 4, 0, 5, 4, 0, 5, 4, 6, 7, 4, 0, 4,\n    4, 0, 4, 6, 7, 5, 4, 0, 4, 4, 0, 5, 4, 4, 5, 4, 0, 5, 4, 0, 4, 4, 4, 6, 4, 0, 5, 4, 0, 4, 6,\n];\nconst POWER235_MOD61: [u8; 61] = [\n    7, 7, 0, 3, 1, 1, 0, 0, 2, 3, 0, 6, 1, 5, 5, 1, 1, 0, 0, 1, 3, 4, 1, 2, 2, 1, 0, 3, 2, 4, 0, 0,\n    4, 2, 3, 0, 1, 2, 2, 1, 4, 3, 1, 0, 0, 1, 1, 5, 5, 1, 6, 0, 3, 2, 0, 0, 1, 1, 3, 0, 7,\n];\nconst POWER235_MOD44: [u8; 44] = [\n    7, 7, 0, 2, 3, 3, 0, 2, 2, 3, 0, 6, 7, 2, 0, 2, 3, 2, 0, 2, 3, 6, 0, 6, 2, 3, 0, 2, 2, 2, 0, 2,\n    6, 7, 0, 2, 3, 3, 0, 2, 2, 2, 0, 6,\n];\nconst POWER235_MOD31: [u8; 31] =\n    [7, 7, 3, 0, 3, 5, 4, 1, 3, 1, 1, 0, 0, 0, 1, 2, 3, 0, 1, 1, 1, 0, 0, 2, 0, 5, 4, 2, 1, 2, 6];\n\n// This is n_factor_power235 when FLINT64 is false, from ulong_extras/factor_power235.c, FLINT\n// 3.1.2, returning y and exp, and simplified to only include the branches used when factoring a\n// `u32`. In particular, only perfect squares are checked for.\nfn factor_square_u32(n: u32) -> (u32, u8) {\n    let mut t = POWER235_MOD31[(n % 31) as usize];\n    if t == 0 {\n        return (0, 0);\n    };\n    t &= POWER235_MOD44[(n % 44) as usize];\n    if t == 0 {\n        return (0, 0);\n    };\n    t &= POWER235_MOD61[(n % 61) as usize];\n    if t == 0 {\n        return (0, 0);\n    };\n    t &= POWER235_MOD63[(n % 63) as usize];\n    if t.odd() {\n        let (y, r) = n.sqrt_rem();\n        if r == 0 {\n            return (y, 2);\n        }\n    }\n    (0, 0)\n}\n\n// This is n_factor_power235 when FLINT64 is true, from ulong_extras/factor_power235.c, FLINT 3.1.2,\n// returning y and exp. Fifth powers are not checked for, because this function is only called on\n// values with no prime factor less than 27449, and 27449^5 is greater than 2^64.\nfn factor_power23_u64(n: u64) -> (u64, u8) {\n    let mut t = POWER235_MOD31[(n % 31) as usize];\n    if t == 0 {\n        return (0, 0);\n    };\n    t &= POWER235_MOD44[(n % 44) as usize];\n    if t == 0 {\n        return (0, 0);\n    };\n    t &= POWER235_MOD61[(n % 61) as usize];\n    if t == 0 {\n        return (0, 0);\n    };\n    t &= POWER235_MOD63[(n % 63) as usize];\n    if t.odd() {\n        let (y, r) = n.sqrt_rem();\n        if r == 0 {\n            return (y, 2);\n        }\n    }\n    if t & 2 != 0 {\n        let y = n.floor_root(3);\n        if n == y.pow(3) {\n            return (y, 3);\n        }\n    }\n    (0, 0)\n}\n\nconst FLINT_ONE_LINE_MULTIPLIER: u32 = 480;\n\n// This is n_factor_one_line when FLINT64 is true, from ulong_extras/factor_one_line.c, FLINT 3.1.2.\nfn factor_one_line_u64(mut n: u64, iters: usize) -> u64 {\n    let orig_n = n;\n    n.wrapping_mul_assign(u64::from(FLINT_ONE_LINE_MULTIPLIER));\n    let mut iin = 0;\n    let mut inn = n;\n    for _ in 0..iters {\n        if iin >= inn {\n            break;\n        }\n        let mut sqrti = inn.floor_sqrt() + 1;\n        let square = sqrti.square();\n        let mmod = square - inn;\n        if mmod.is_square() {\n            sqrti -= mmod.floor_sqrt();\n            let factor = orig_n.gcd(sqrti);\n            if factor != 1 {\n                return factor;\n            }\n        }\n        iin = inn;\n        inn.wrapping_add_assign(n);\n    }\n    0\n}\n\nfn wyhash64(seed: &mut u64) -> u64 {\n    seed.wrapping_add_assign(0x60bee2bee120fc15);\n    let tmp = u128::from(*seed) * 0xa3b195354a39b70d;\n    let tmp = ((tmp >> 64) ^ tmp).wrapping_mul(0x1b03738712fad5c9);\n    u64::wrapping_from((tmp >> 64) ^ tmp)\n}\n\nstruct WyhashRandomU64s {\n    seed: u64,\n}\n\nimpl WyhashRandomU64s {\n    const fn new() -> Self {\n        Self {\n            seed: 0x452aee49c457bbc3,\n        }\n    }\n}\n\nimpl Iterator for WyhashRandomU64s {\n    type Item = u64;\n\n    fn next(&mut self) -> Option<u64> {\n        Some(wyhash64(&mut self.seed))\n    }\n}\n\n// This is n_factor_pp1_table from ulong_extras/factor_pp1.c, FLINT 3.1.2.\nconst N_FACTOR_PP1_TABLE: [(u16, u8); 34] = [\n    (2784, 5),\n    (1208, 2),\n    (2924, 3),\n    (286, 5),\n    (58, 5),\n    (61, 4),\n    (815, 2),\n    (944, 2),\n    (61, 3),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (0, 0),\n    (606, 1),\n    (2403, 1),\n    (2524, 1),\n    (2924, 1),\n    (3735, 2),\n    (669, 2),\n    (6092, 3),\n    (2179, 3),\n    (3922, 3),\n    (6717, 4),\n    (4119, 4),\n    (2288, 4),\n    (9004, 3),\n    (9004, 3),\n    (9004, 3),\n];\n\n// This is n_pp1_pow_ui when FLINT64 is true, from ulong_extras/factor_pp1.c, FLINT 3.1.2, returning\n// the new values of x and y. y is not passed in as its initial value is never used.\nfn pp1_pow_ui_u64(mut x: u64, exp: u64, n: u64, ninv: u64, norm: u64) -> (u64, u64) {\n    let x_orig = x;\n    let two = u64::power_of_2(norm + 1);\n    let mut y = mul_mod_helper::<u64, u128>(x, x, n, ninv, norm).mod_sub(two, n);\n    let mut bit = u64::power_of_2(exp.significant_bits() - 2);\n    while bit != 0 {\n        (x, y) = if exp & bit != 0 {\n            (\n                mul_mod_helper::<u64, u128>(x, y, n, ninv, norm).mod_sub(x_orig, n),\n                mul_mod_helper::<u64, u128>(y, y, n, ninv, norm).mod_sub(two, n),\n            )\n        } else {\n            (\n                mul_mod_helper::<u64, u128>(x, x, n, ninv, norm).mod_sub(two, n),\n                mul_mod_helper::<u64, u128>(y, x, n, ninv, norm).mod_sub(x_orig, n),\n            )\n        };\n        bit >>= 1;\n    }\n    (x, y)\n}\n\n// This is n_pp1_factor when FLINT64 is true, from ulong_extras/factor_pp1.c, FLINT 3.1.2.\nfn pp1_factor_u64(mut n: u64, mut x: u64, norm: u64) -> u64 {\n    if norm != 0 {\n        n >>= norm;\n        x >>= norm;\n    }\n    x.mod_sub_assign(2, n);\n    if x == 0 { 0 } else { n.gcd(x) }\n}\n\n// This is n_pp1_find_power when FLINT64 is true, from ulong_extras/factor_pp1.c, FLINT 3.1.2,\n// returning factor and the new values of x and y. y is not passed in as its initial value is never\n// used.\nfn pp1_find_power_u64(mut x: u64, p: u64, n: u64, ninv: u64, norm: u64) -> (u64, u64, u64) {\n    let mut factor = 1;\n    let mut y = 0;\n    while factor == 1 {\n        (x, y) = pp1_pow_ui_u64(x, p, n, ninv, norm);\n        factor = pp1_factor_u64(n, x, norm);\n    }\n    (factor, x, y)\n}\n\n// This is n_factor_pp1 when FLINT64 is false, from ulong_extras/factor_pp1.c, FLINT 3.1.2. It is\n// assumed that n is odd.\nfn factor_pp1_u64(mut n: u64, b1: u64, c: u64) -> u64 {\n    let mut primes = u64::primes();\n    let sqrt = b1.floor_sqrt();\n    let bits0 = b1.significant_bits();\n    let norm = LeadingZeros::leading_zeros(n);\n    n <<= norm;\n    let n_inverse = u64::precompute_mod_mul_data(&n);\n    let mut x = c << norm;\n    // mul by various prime powers\n    let mut p = 0;\n    let mut old_p = 0;\n    let mut i = 0;\n    let mut old_x = 0;\n    while p < b1 {\n        let j = i + 1024;\n        old_p = p;\n        old_x = x;\n        while i < j {\n            p = primes.next().unwrap();\n            x = if p < sqrt {\n                pp1_pow_ui_u64(\n                    x,\n                    p.pow(u32::wrapping_from(bits0 / p.significant_bits())),\n                    n,\n                    n_inverse,\n                    norm,\n                )\n                .0\n            } else {\n                pp1_pow_ui_u64(x, p, n, n_inverse, norm).0\n            };\n            i += 1;\n        }\n        let factor = pp1_factor_u64(n, x, norm);\n        if factor == 0 {\n            break;\n        }\n        if factor != 1 {\n            return factor;\n        }\n    }\n    if p < b1 {\n        // factor = 0\n        primes.jump_after(old_p);\n        x = old_x;\n        loop {\n            p = primes.next().unwrap();\n            old_x = x;\n            x = if p < sqrt {\n                pp1_pow_ui_u64(\n                    x,\n                    p.pow(u32::wrapping_from(bits0 / p.significant_bits())),\n                    n,\n                    n_inverse,\n                    norm,\n                )\n                .0\n            } else {\n                pp1_pow_ui_u64(x, p, n, n_inverse, norm).0\n            };\n            let factor = pp1_factor_u64(n, x, norm);\n            if factor == 0 {\n                break;\n            }\n            if factor != 1 {\n                return factor;\n            }\n        }\n    } else {\n        return 0;\n    }\n    // factor still 0\n    pp1_find_power_u64(old_x, p, n, n_inverse, norm).0\n}\n\n// This is n_factor_pp1_wrapper when FLINT64 is true, from ulong_extras/factor_pp1.c, FLINT 3.1.2.\nfn factor_pp1_wrapper_u64(n: u64) -> u64 {\n    let bits = n.significant_bits();\n    // silently fail if trial factoring would always succeed\n    if bits < 31 {\n        return 0;\n    }\n    let (b1, count) = N_FACTOR_PP1_TABLE[usize::wrapping_from(bits) - 31];\n    let b1 = u64::from(b1);\n    let mut state = WyhashRandomU64s::new();\n    let mask = u64::low_mask((n - 4).significant_bits());\n    let limit = n - 3;\n    for _ in 0..count {\n        let mut randint = u64::MAX;\n        while randint >= limit {\n            randint = state.next().unwrap() & mask;\n        }\n        let factor = factor_pp1_u64(n, b1, randint + 3);\n        if factor != 0 {\n            return factor;\n        }\n    }\n    0\n}\n\n// This is equivalent to `mpn_sqrtrem` from `mpn/generic/sqrtrem.c`, GMP 6.2.1, where `rp` is not\n// `NULL` and `Limb == u64`, and the input has two limbs. One limb of the square root and two limbs\n// of the remainder are returned.\n#[doc(hidden)]\nfn limbs_sqrt_rem_to_out_u64(xs_hi: u64, xs_lo: u64) -> (u64, u64, u64, usize) {\n    let high = if xs_hi == 0 { xs_lo } else { xs_hi };\n    assert_ne!(high, 0);\n    let shift = LeadingZeros::leading_zeros(high) >> 1;\n    let two_shift = shift << 1;\n    if xs_hi == 0 {\n        let (sqrt_lo, rem_lo) = if shift == 0 {\n            sqrt_rem_newton::<u64, i64>(high)\n        } else {\n            let sqrt = sqrt_rem_newton::<u64, i64>(high << two_shift).0 >> shift;\n            (sqrt, high - sqrt.square())\n        };\n        (sqrt_lo, 0, rem_lo, usize::from(rem_lo != 0))\n    } else if shift == 0 {\n        let (sqrt_lo, rem_hi, rem_lo) = sqrt_rem_2_newton::<u64, i64>(xs_hi, xs_lo);\n        if rem_hi {\n            (sqrt_lo, 1, rem_lo, 2)\n        } else {\n            (sqrt_lo, 0, rem_lo, usize::from(rem_lo != 0))\n        }\n    } else {\n        let mut lo = xs_lo;\n        let hi = (high << two_shift) | (lo >> (u64::WIDTH - two_shift));\n        let sqrt_lo = sqrt_rem_2_newton::<u64, i64>(hi, lo << two_shift).0 >> shift;\n        lo.wrapping_sub_assign(sqrt_lo.wrapping_square());\n        (sqrt_lo, 0, lo, usize::from(lo != 0))\n    }\n}\n\nconst FACTOR_SQUFOF_ITERS: usize = 50_000;\nconst FACTOR_ONE_LINE_ITERS: usize = 40_000;\n\n// This is _ll_factor_SQUFOF when FLINT64 is true, from ulong_extras/factor_SQUFOF.c, FLINT 3.1.2.\nfn ll_factor_squfof_u64(n_hi: u64, n_lo: u64, max_iters: usize) -> u64 {\n    let (mut sqrt_lo, mut rem_lo, num) = if n_hi != 0 {\n        let (sqrt_lo, _, rem_lo, size) = limbs_sqrt_rem_to_out_u64(n_hi, n_lo);\n        (sqrt_lo, rem_lo, size)\n    } else {\n        let (sqrt_lo, rem_lo) = n_lo.sqrt_rem();\n        (sqrt_lo, rem_lo, usize::from(sqrt_lo != 0))\n    };\n    let sqroot = sqrt_lo;\n    let mut p = sqroot;\n    let mut q = rem_lo;\n    if q == 0 || num == 0 {\n        return sqroot;\n    }\n    let l = 1 + ((p << 1).floor_sqrt() << 1);\n    let l2 = l >> 1;\n    let mut qupto = 0;\n    let mut qlast = 1u64;\n    let mut qarr = [0; 50];\n    let mut r = 0;\n    let mut finished_loop = true;\n    for i in 0..max_iters {\n        let iq = (sqroot + p) / q;\n        let pnext = iq * q - p;\n        if q <= l {\n            if q.even() {\n                qarr[qupto] = q >> 1;\n                qupto += 1;\n                if qupto >= 50 {\n                    return 0;\n                }\n            } else if q <= l2 {\n                qarr[qupto] = q;\n                qupto += 1;\n                if qupto >= 50 {\n                    return 0;\n                }\n            }\n        }\n        let t = qlast.wrapping_add(iq.wrapping_mul(p.wrapping_sub(pnext)));\n        qlast = q;\n        q = t;\n        p = pnext;\n        if i.odd() || !q.is_square() {\n            continue;\n        }\n        r = q.floor_sqrt();\n        if qupto == 0 {\n            finished_loop = false;\n            break;\n        }\n        let mut done = true;\n        for &q in &qarr[..qupto] {\n            if r == q {\n                done = false;\n                break;\n            }\n        }\n        if done {\n            finished_loop = false;\n            break;\n        }\n        if r == 1 {\n            return 0;\n        }\n    }\n    if finished_loop {\n        return 0;\n    }\n    qlast = r;\n    p = p + r * ((sqroot - p) / r);\n    let rem_hi;\n    (rem_hi, rem_lo) = u64::x_mul_y_to_zz(p, p);\n    let sqrt_hi;\n    (sqrt_hi, sqrt_lo) = u64::xx_sub_yy_to_zz(n_hi, n_lo, rem_hi, rem_lo);\n    q = if sqrt_hi != 0 {\n        let norm = LeadingZeros::leading_zeros(qlast);\n        u64::xx_div_mod_y_to_qr(\n            (sqrt_hi << norm) + (sqrt_lo >> (u64::WIDTH - norm)),\n            sqrt_lo << norm,\n            qlast << norm,\n        )\n        .0\n    } else {\n        sqrt_lo / qlast\n    };\n    let mut finished_loop = true;\n    for _ in 0..max_iters {\n        let iq = (sqroot + p) / q;\n        let pnext = iq * q - p;\n        if p == pnext {\n            finished_loop = false;\n            break;\n        }\n        let t = qlast.wrapping_add(iq.wrapping_mul(p.wrapping_sub(pnext)));\n        qlast = q;\n        q = t;\n        p = pnext;\n    }\n    if finished_loop {\n        0\n    } else if q.even() {\n        q >> 1\n    } else {\n        q\n    }\n}\n\n// This is n_factor_SQUFOF when FLINT64 is true, from ulong_extras/factor_SQUFOF.c, FLINT 3.1.2.\nfn factor_squfof_u64(n: u64, iters: usize) -> u64 {\n    let mut factor = ll_factor_squfof_u64(0, n, iters);\n    let mut finished_loop = true;\n    for &p in &SMALL_PRIMES[1..] {\n        if factor != 0 {\n            finished_loop = false;\n            break;\n        }\n        let multiplier = u64::from(p);\n        let (multn_1, multn_0) = u64::x_mul_y_to_zz(multiplier, n);\n        factor = ll_factor_squfof_u64(multn_1, multn_0, iters);\n        if factor != 0 {\n            let (quot, rem) = factor.div_mod(multiplier);\n            if rem == 0 {\n                factor = quot;\n            }\n            if factor == 1 || factor == n {\n                factor = 0;\n            }\n        }\n    }\n    if finished_loop { 0 } else { factor }\n}\n\nconst FACTOR_TRIAL_PRIMES: usize = 3000;\nconst FACTOR_TRIAL_CUTOFF: u32 = 27449 * 27449;\n\nimpl Factor for u8 {\n    type FACTORS = FactorsU8;\n\n    /// Returns the prime factorization of a `u8`. The return value is iterable, and produces pairs\n    /// $(p,e)$ of type `(u8, u8)`, where the $p$ is prime and $e$ is the exponent of $p$. The\n    /// primes are in ascending order.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::factorization::traits::Factor;\n    ///\n    /// assert_eq!(251u8.factor().into_iter().collect_vec(), &[(251, 1)]);\n    /// assert_eq!(\n    ///     120u8.factor().into_iter().collect_vec(),\n    ///     &[(2, 3), (3, 1), (5, 1)]\n    /// );\n    /// ```\n    fn factor(&self) -> FactorsU8 {\n        assert_ne!(*self, 0);\n        let mut n = *self;\n        let mut factors = FactorsU8::new();\n        if n == 1 {\n            return factors;\n        }\n        let zeros = n.trailing_zeros();\n        if zeros != 0 {\n            factors.insert(2, zeros as Self);\n            n >>= zeros;\n            if n == 1 {\n                return factors;\n            }\n        }\n        let mut e;\n        let (q, r) = n.div_mod(3);\n        if r == 0 {\n            e = 1;\n            n = q;\n            let (q, r) = n.div_mod(3);\n            if r == 0 {\n                e = 2;\n                n = q;\n                let (q, r) = n.div_mod(3);\n                if r == 0 {\n                    e = 3;\n                    n = q;\n                    let (q, r) = n.div_mod(3);\n                    if r == 0 {\n                        e = 4;\n                        n = q;\n                        if n == 3 {\n                            e = 5;\n                            n = 1;\n                        }\n                    }\n                }\n            }\n            factors.insert(3, e);\n            if n == 1 {\n                return factors;\n            }\n        }\n        let (q, r) = n.div_mod(5);\n        if r == 0 {\n            e = 1;\n            n = q;\n            let (q, r) = n.div_mod(5);\n            if r == 0 {\n                e = 2;\n                n = q;\n                if n == 5 {\n                    e = 3;\n                    n = 1;\n                }\n            }\n            factors.insert(5, e);\n            if n == 1 {\n                return factors;\n            }\n        }\n        let (q, r) = n.div_mod(7);\n        if r == 0 {\n            e = 1;\n            n = q;\n            if n == 7 {\n                e = 2;\n                n = 1;\n            }\n            factors.insert(7, e);\n            if n == 1 {\n                return factors;\n            }\n        }\n        match n {\n            121 => {\n                factors.insert(11, 2);\n            }\n            143 => {\n                factors.insert(11, 1);\n                factors.insert(13, 1);\n            }\n            169 => {\n                factors.insert(13, 2);\n            }\n            187 => {\n                factors.insert(11, 1);\n                factors.insert(17, 1);\n            }\n            209 => {\n                factors.insert(11, 1);\n                factors.insert(19, 1);\n            }\n            221 => {\n                factors.insert(13, 1);\n                factors.insert(17, 1);\n            }\n            247 => {\n                factors.insert(13, 1);\n                factors.insert(19, 1);\n            }\n            253 => {\n                factors.insert(11, 1);\n                factors.insert(23, 1);\n            }\n            _ => {\n                factors.insert(n, 1);\n            }\n        }\n        factors\n    }\n}\n\nimpl Factor for u16 {\n    type FACTORS = FactorsU16;\n\n    /// Returns the prime factorization of a `u16`. The return value is iterable, and produces pairs\n    /// $(p,e)$ of type `(u16, u8)`, where the $p$ is prime and $e$ is the exponent of $p$. The\n    /// primes are in ascending order.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(2^{n/4})$\n    ///\n    /// $M(n) = O(2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::factorization::traits::Factor;\n    ///\n    /// assert_eq!(65521u16.factor().into_iter().collect_vec(), &[(65521, 1)]);\n    /// assert_eq!(\n    ///     40320u16.factor().into_iter().collect_vec(),\n    ///     &[(2, 7), (3, 2), (5, 1), (7, 1)]\n    /// );\n    /// ```\n    fn factor(&self) -> FactorsU16 {\n        let mut factors = FactorsU16::new();\n        for (f, e) in u32::from(*self).factor() {\n            factors.insert(f as Self, e);\n        }\n        factors\n    }\n}\n\nimpl Factor for u32 {\n    type FACTORS = FactorsU32;\n\n    /// Returns the prime factorization of a `u32`. The return value is iterable, and produces pairs\n    /// $(p,e)$ of type `(u32, u8)`, where the $p$ is prime and $e$ is the exponent of $p$. The\n    /// primes are in ascending order.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(2^{n/4})$\n    ///\n    /// $M(n) = O(2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::factorization::traits::Factor;\n    ///\n    /// assert_eq!(\n    ///     4294967291u32.factor().into_iter().collect_vec(),\n    ///     &[(4294967291, 1)]\n    /// );\n    /// assert_eq!(\n    ///     479001600u32.factor().into_iter().collect_vec(),\n    ///     &[(2, 10), (3, 5), (5, 2), (7, 1), (11, 1)]\n    /// );\n    /// ```\n    ///\n    /// This is n_factor when FLINT64 is false, from ulong_extras/factor.c, FLINT 3.1.2.\n    fn factor(&self) -> FactorsU32 {\n        let n = *self;\n        assert_ne!(n, 0);\n        let mut factors = FactorsU32::new();\n        let cofactor = factor_trial_range_u32(&mut factors, n, FACTOR_TRIAL_PRIMES);\n        if cofactor == 1 {\n            return factors;\n        }\n        if cofactor.is_prime() {\n            factors.insert(cofactor, 1);\n            return factors;\n        }\n        let mut factor_arr = [0; MAX_FACTORS_IN_U32];\n        let mut exp_arr = [0; MAX_FACTORS_IN_U32];\n        factor_arr[0] = cofactor;\n        let mut factors_left = 1;\n        exp_arr[0] = 1;\n        let cutoff = FACTOR_TRIAL_CUTOFF;\n        while factors_left != 0 {\n            let mut factor = factor_arr[factors_left - 1];\n            if factor >= cutoff {\n                let (mut cofactor, exp) = factor_square_u32(factor);\n                if cofactor != 0 {\n                    exp_arr[factors_left - 1] *= exp;\n                    factor = cofactor;\n                    factor_arr[factors_left - 1] = factor;\n                }\n                if factor >= cutoff && !factor.is_prime() {\n                    cofactor = Self::exact_from(factor_one_line_u64(\n                        u64::from(factor),\n                        FACTOR_ONE_LINE_ITERS,\n                    ));\n                    exp_arr[factors_left] = exp_arr[factors_left - 1];\n                    factor_arr[factors_left] = cofactor;\n                    factor_arr[factors_left - 1] /= cofactor;\n                    factors_left += 1;\n                } else {\n                    factors.insert(factor, exp_arr[factors_left - 1]);\n                    factors_left -= 1;\n                }\n            } else {\n                factors.insert(factor, exp_arr[factors_left - 1]);\n                factors_left -= 1;\n            }\n        }\n        factors\n    }\n}\n\nconst FACTOR_ONE_LINE_MAX: u64 = 1 << 39;\n\nimpl Factor for u64 {\n    type FACTORS = FactorsU64;\n\n    /// Returns the prime factorization of a `u64`. The return value is iterable, and produces pairs\n    /// $(p,e)$ of type `(u64, u8)`, where the $p$ is prime and $e$ is the exponent of $p$. The\n    /// primes are in ascending order.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(2^{n/4})$\n    ///\n    /// $M(n) = O(2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::factorization::traits::Factor;\n    ///\n    /// assert_eq!(\n    ///     18446744073709551557u64.factor().into_iter().collect_vec(),\n    ///     &[(18446744073709551557, 1)]\n    /// );\n    /// assert_eq!(\n    ///     2432902008176640000u64.factor().into_iter().collect_vec(),\n    ///     &[(2, 18), (3, 8), (5, 4), (7, 2), (11, 1), (13, 1), (17, 1), (19, 1)]\n    /// );\n    /// ```\n    ///\n    /// This is n_factor when FLINT64 is true, from ulong_extras/factor.c, FLINT 3.1.2.\n    fn factor(&self) -> FactorsU64 {\n        let n = *self;\n        assert_ne!(n, 0);\n        let mut factors = FactorsU64::new();\n        let cofactor = factor_trial_range_u64(&mut factors, n, FACTOR_TRIAL_PRIMES);\n        if cofactor == 1 {\n            return factors;\n        }\n        if cofactor.is_prime() {\n            factors.insert(cofactor, 1);\n            return factors;\n        }\n        let mut factor_arr = [0; MAX_FACTORS_IN_U64];\n        let mut exp_arr = [0; MAX_FACTORS_IN_U64];\n        factor_arr[0] = cofactor;\n        let mut factors_left = 1;\n        exp_arr[0] = 1;\n        const CUTOFF: u64 = FACTOR_TRIAL_CUTOFF as u64;\n        while factors_left != 0 {\n            let mut factor = factor_arr[factors_left - 1];\n            if factor >= CUTOFF {\n                let (mut cofactor, exp) = factor_power23_u64(factor);\n                if cofactor != 0 {\n                    exp_arr[factors_left - 1] *= exp;\n                    factor = cofactor;\n                    factor_arr[factors_left - 1] = factor;\n                }\n                if factor >= CUTOFF && !factor.is_prime() {\n                    cofactor = 0;\n                    if factor < FACTOR_ONE_LINE_MAX {\n                        cofactor = factor_one_line_u64(factor, FACTOR_ONE_LINE_ITERS);\n                    }\n                    if cofactor == 0 {\n                        cofactor = factor_pp1_wrapper_u64(factor);\n                        if cofactor == 0 {\n                            cofactor = factor_squfof_u64(factor, FACTOR_SQUFOF_ITERS);\n                            assert_ne!(cofactor, 0);\n                        }\n                    }\n                    exp_arr[factors_left] = exp_arr[factors_left - 1];\n                    factor_arr[factors_left] = cofactor;\n                    factor_arr[factors_left - 1] /= cofactor;\n                    factors_left += 1;\n                } else {\n                    factors.insert(factor, exp_arr[factors_left - 1]);\n                    factors_left -= 1;\n                }\n            } else {\n                factors.insert(factor, exp_arr[factors_left - 1]);\n                factors_left -= 1;\n            }\n        }\n        factors\n    }\n}\n\nimpl Factor for usize {\n    type FACTORS = FactorsUsize;\n\n    /// Returns the prime factorization of a `usize`. The return value is iterable, and produces\n    /// pairs $(p,e)$ of type `(usize, u8)`, where the $p$ is prime and $e$ is the exponent of $p$.\n    /// The primes are in ascending order.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(2^{n/4})$\n    ///\n    /// $M(n) = O(2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::factorization::traits::Factor;\n    ///\n    /// assert_eq!(\n    ///     4294967291usize.factor().into_iter().collect_vec(),\n    ///     &[(4294967291, 1)]\n    /// );\n    /// assert_eq!(\n    ///     479001600usize.factor().into_iter().collect_vec(),\n    ///     &[(2, 10), (3, 5), (5, 2), (7, 1), (11, 1)]\n    /// );\n    /// ```\n    fn factor(&self) -> FactorsUsize {\n        let mut factors = FactorsUsize::new();\n        if USIZE_IS_U32 {\n            for (f, e) in (*self as u32).factor() {\n                factors.insert(f as Self, e);\n            }\n        } else {\n            for (f, e) in (*self as u64).factor() {\n                factors.insert(f as Self, e);\n            }\n        }\n        factors\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/factorization/is_power.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{\n    CheckedRoot, DivAssignMod, DivMod, GcdAssign, Parity, RootRem, SqrtRem,\n};\nuse crate::num::basic::integers::USIZE_IS_U32;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::factorization::primes::SMALL_PRIMES;\nuse crate::num::factorization::traits::{\n    ExpressAsPower, Factor, IsPower, IsPrime, IsSquare, Primes,\n};\nuse crate::num::logic::traits::{SignificantBits, TrailingZeros};\n\n// The following arrays are bitmasks indicating whether an integer is a 2, 3, or 5th power residue.\n// For example, modulo 31 we have:\n// - squares:    {0, 1, 2, 4, 5, 7, 8, 9, 10, 14, 16, 18, 19, 20, 25, 28}\n// - cubes:      {0, 1, 2, 4, 8, 15, 16, 23, 27, 29, 30}\n// - 5th powers: {0, 1, 5, 6, 25, 26, 30}\n// Since 2 is a square, cube, but not a 5th power mod 31, we encode it as 011 = 3. Then MOD31[2] =\n// 3.\n\nconst MOD63: [u8; 63] = [\n    7, 7, 4, 0, 5, 4, 0, 5, 6, 5, 4, 4, 0, 4, 4, 0, 5, 4, 5, 4, 4, 0, 5, 4, 0, 5, 4, 6, 7, 4, 0, 4,\n    4, 0, 4, 6, 7, 5, 4, 0, 4, 4, 0, 5, 4, 4, 5, 4, 0, 5, 4, 0, 4, 4, 4, 6, 4, 0, 5, 4, 0, 4, 6,\n];\n\nconst MOD61: [u8; 61] = [\n    7, 7, 0, 3, 1, 1, 0, 0, 2, 3, 0, 6, 1, 5, 5, 1, 1, 0, 0, 1, 3, 4, 1, 2, 2, 1, 0, 3, 2, 4, 0, 0,\n    4, 2, 3, 0, 1, 2, 2, 1, 4, 3, 1, 0, 0, 1, 1, 5, 5, 1, 6, 0, 3, 2, 0, 0, 1, 1, 3, 0, 7,\n];\n\nconst MOD44: [u8; 44] = [\n    7, 7, 0, 2, 3, 3, 0, 2, 2, 3, 0, 6, 7, 2, 0, 2, 3, 2, 0, 2, 3, 6, 0, 6, 2, 3, 0, 2, 2, 2, 0, 2,\n    6, 7, 0, 2, 3, 3, 0, 2, 2, 2, 0, 6,\n];\n\nconst MOD31: [u8; 31] =\n    [7, 7, 3, 0, 3, 5, 4, 1, 3, 1, 1, 0, 0, 0, 1, 2, 3, 0, 1, 1, 1, 0, 0, 2, 0, 5, 4, 2, 1, 2, 6];\n\nconst MOD72: [u8; 72] = [\n    7, 7, 0, 0, 0, 7, 0, 7, 7, 7, 0, 7, 0, 7, 0, 0, 7, 7, 0, 7, 0, 0, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7,\n    7, 0, 0, 7, 0, 7, 0, 0, 7, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 0, 0, 7, 0, 7, 7, 0, 0, 7, 0, 7, 0, 7,\n    7, 7, 0, 7, 0, 0, 0, 7,\n];\n\nconst MOD49: [u8; 49] = [\n    1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,\n];\n\nconst MOD67: [u8; 67] = [\n    2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0,\n    0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 2,\n];\n\nconst MOD79: [u8; 79] = [\n    4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4,\n];\n\n// This is n_is_power when FLINT64 is false, from ulong_extras/is_power.c, FLINT 3.1.2.\nfn get_perfect_power_u32(n: u32) -> Option<(u32, u64)> {\n    // Check for powers 2, 3, 5\n    let mut t = MOD31[(n % 31) as usize];\n    t &= MOD44[(n % 44) as usize];\n    t &= MOD61[(n % 61) as usize];\n    t &= MOD63[(n % 63) as usize];\n    // Check for perfect square\n    if t & 1 != 0 {\n        let (rt, rem) = n.sqrt_rem();\n        if rem == 0 {\n            return Some((rt, 2));\n        }\n    }\n    // Check for perfect cube\n    if t & 2 != 0 {\n        let (rt, rem) = n.root_rem(3);\n        if rem == 0 {\n            return Some((rt, 3));\n        }\n    }\n    // Check for perfect fifth power\n    if t & 4 != 0 {\n        let (rt, rem) = n.root_rem(5);\n        if rem == 0 {\n            return Some((rt, 5));\n        }\n    }\n    // Check for powers 7, 11, 13\n    t = MOD49[(n % 49) as usize];\n    t |= MOD67[(n % 67) as usize];\n    t |= MOD79[(n % 79) as usize];\n    t &= MOD72[(n % 72) as usize];\n\n    // Check for perfect 7th power\n    if t & 1 != 0 {\n        let (rt, rem) = n.root_rem(7);\n        if rem == 0 {\n            return Some((rt, 7));\n        }\n    }\n    // Check for perfect 11th power\n    if t & 2 != 0 {\n        let (rt, rem) = n.root_rem(11);\n        if rem == 0 {\n            return Some((rt, 11));\n        }\n    }\n    // Check for perfect 13th power\n    if t & 13 != 0 {\n        let (rt, rem) = n.root_rem(13);\n        if rem == 0 {\n            return Some((rt, 13));\n        }\n    }\n    // Handle powers of 2\n    let count = u64::from(n.trailing_zeros());\n    let mut n = n >> count;\n    if n == 1 {\n        return if count == 1 {\n            None // Just 2^1 = 2, not a perfect power\n        } else {\n            Some((2, count))\n        };\n    }\n    // Check other powers (exp >= 17, root <= 13 and odd)\n    let mut exp = 0;\n    while n.is_multiple_of(3) {\n        n /= 3;\n        exp += 1;\n    }\n    if exp > 0 {\n        if n == 1 && exp > 1 {\n            if count == 0 {\n                return Some((3, exp));\n            } else if count == exp {\n                return Some((6, exp));\n            } else if count == 2 * exp {\n                return Some((12, exp));\n            }\n        }\n        return None;\n    }\n    None\n}\n\n// This is n_is_power when FLINT64 is false, from ulong_extras/is_power.c, FLINT 3.1.2, returning\n// only whether n can be expressed as a nontrivial perfect power.\nfn get_perfect_power_u32_bool(n: u32) -> bool {\n    // Check for powers 2, 3, 5\n    let mut t = MOD31[(n % 31) as usize];\n    t &= MOD44[(n % 44) as usize];\n    t &= MOD61[(n % 61) as usize];\n    t &= MOD63[(n % 63) as usize];\n    // Check for perfect square\n    if t & 1 != 0 && n.is_square() {\n        return true;\n    }\n    // Check for perfect cube\n    if t & 2 != 0 && n.root_rem(3).1 == 0 {\n        return true;\n    }\n    // Check for perfect fifth power\n    if t & 4 != 0 && n.root_rem(5).1 == 0 {\n        return true;\n    }\n    // Check for powers 7, 11, 13\n    t = MOD49[(n % 49) as usize];\n    t |= MOD67[(n % 67) as usize];\n    t |= MOD79[(n % 79) as usize];\n    t &= MOD72[(n % 72) as usize];\n    // Check for perfect 7th power\n    if t & 1 != 0 && n.root_rem(7).1 == 0 {\n        return true;\n    }\n    // Check for perfect 11th power\n    if t & 2 != 0 && n.root_rem(11).1 == 0 {\n        return true;\n    }\n    // Check for perfect 13th power\n    if t & 13 != 0 && n.root_rem(13).1 == 0 {\n        return true;\n    }\n    // Handle powers of 2\n    let count = n.trailing_zeros();\n    let mut n = n >> n.trailing_zeros();\n    if n == 1 {\n        return count != 1;\n    }\n    // Check other powers (exp >= 17, root <= 13 and odd)\n    let mut exp = 0;\n    while n.is_multiple_of(3) {\n        n /= 3;\n        exp += 1;\n    }\n    exp > 0 && n == 1 && exp > 1 && (count == 0 || count == exp || count == exp << 1)\n}\n\n// This is n_is_power when FLINT64 is true, from ulong_extras/is_power.c, FLINT 3.1.2.\nfn get_perfect_power_u64(n: u64) -> Option<(u64, u64)> {\n    // Check for powers 2, 3, 5\n    let mut t = MOD31[(n % 31) as usize];\n    t &= MOD44[(n % 44) as usize];\n    t &= MOD61[(n % 61) as usize];\n    t &= MOD63[(n % 63) as usize];\n    // Check for perfect square\n    if t & 1 != 0 {\n        let (rt, rem) = n.sqrt_rem();\n        if rem == 0 {\n            return Some((rt, 2));\n        }\n    }\n    // Check for perfect cube\n    if t & 2 != 0 {\n        let (rt, rem) = n.root_rem(3);\n        if rem == 0 {\n            return Some((rt, 3));\n        }\n    }\n    // Check for perfect fifth power\n    if t & 4 != 0 {\n        let (rt, rem) = n.root_rem(5);\n        if rem == 0 {\n            return Some((rt, 5));\n        }\n    }\n    // Check for powers 7, 11, 13\n    t = MOD49[(n % 49) as usize];\n    t |= MOD67[(n % 67) as usize];\n    t |= MOD79[(n % 79) as usize];\n    t &= MOD72[(n % 72) as usize];\n    // Check for perfect 7th power\n    if t & 1 != 0 {\n        let (rt, rem) = n.root_rem(7);\n        if rem == 0 {\n            return Some((rt, 7));\n        }\n    }\n    // Check for perfect 11th power\n    if t & 2 != 0 {\n        let (rt, rem) = n.root_rem(11);\n        if rem == 0 {\n            return Some((rt, 11));\n        }\n    }\n    // Check for perfect 13th power\n    if t & 13 != 0 {\n        let (rt, rem) = n.root_rem(13);\n        if rem == 0 {\n            return Some((rt, 13));\n        }\n    }\n    // Handle powers of 2\n    let count = u64::from(n.trailing_zeros());\n    let mut n = n >> count;\n    if n == 1 {\n        return if count == 1 {\n            None // Just 2^1 = 2, not a perfect power\n        } else {\n            Some((2, count))\n        };\n    }\n    // Check other powers (exp >= 17, root <= 13 and odd)\n    let mut exp = 0;\n    while n.is_multiple_of(3) {\n        n /= 3;\n        exp += 1;\n    }\n    if exp > 0 {\n        if n == 1 && exp > 1 {\n            if count == 0 {\n                return Some((3, exp));\n            } else if count == exp {\n                return Some((6, exp));\n            } else if count == 2 * exp {\n                return Some((12, exp));\n            }\n        }\n        return None;\n    }\n    // Check powers of 5\n    exp = 0;\n    while n.is_multiple_of(5) {\n        n /= 5;\n        exp += 1;\n    }\n    if exp > 0 {\n        if n == 1 && exp > 1 {\n            if count == 0 {\n                return Some((5, exp));\n            } else if count == exp {\n                return Some((10, exp));\n            }\n        }\n        return None;\n    }\n    if count > 0 {\n        return None;\n    }\n    // Check powers of 7\n    exp = 0;\n    while n.is_multiple_of(7) {\n        n /= 7;\n        exp += 1;\n    }\n    if exp > 0 {\n        if n == 1 && exp > 1 {\n            return Some((7, exp));\n        }\n        return None;\n    }\n    // Check powers of 11\n    exp = 0;\n    while n.is_multiple_of(11) {\n        n /= 11;\n        exp += 1;\n    }\n    if exp > 0 {\n        if n == 1 && exp > 1 {\n            return Some((11, exp));\n        }\n        return None;\n    }\n    // Check powers of 13\n    exp = 0;\n    while n.is_multiple_of(13) {\n        n /= 13;\n        exp += 1;\n    }\n    if exp > 0 {\n        if n == 1 && exp > 1 {\n            return Some((13, exp));\n        }\n        return None;\n    }\n    None\n}\n\n// This is n_is_power when FLINT64 is true, from ulong_extras/is_power.c, FLINT 3.1.2, returning\n// only whether n can be expressed as a nontrivial perfect power.\nfn get_perfect_power_u64_bool(n: u64) -> bool {\n    // Check for powers 2, 3, 5\n    let mut t = MOD31[(n % 31) as usize];\n    t &= MOD44[(n % 44) as usize];\n    t &= MOD61[(n % 61) as usize];\n    t &= MOD63[(n % 63) as usize];\n    // Check for perfect square\n    if t & 1 != 0 && n.is_square() {\n        return true;\n    }\n    // Check for perfect cube\n    if t & 2 != 0 && n.root_rem(3).1 == 0 {\n        return true;\n    }\n    // Check for perfect fifth power\n    if t & 4 != 0 && n.root_rem(5).1 == 0 {\n        return true;\n    }\n    // Check for powers 7, 11, 13\n    t = MOD49[(n % 49) as usize];\n    t |= MOD67[(n % 67) as usize];\n    t |= MOD79[(n % 79) as usize];\n    t &= MOD72[(n % 72) as usize];\n    // Check for perfect 7th power\n    if t & 1 != 0 && n.root_rem(7).1 == 0 {\n        return true;\n    }\n    // Check for perfect 11th power\n    if t & 2 != 0 && n.root_rem(11).1 == 0 {\n        return true;\n    }\n    // Check for perfect 13th power\n    if t & 13 != 0 && n.root_rem(13).1 == 0 {\n        return true;\n    }\n    // Handle powers of 2\n    let count = u64::from(n.trailing_zeros());\n    let mut n = n >> count;\n    if n == 1 {\n        return count != 1;\n    }\n    // Check other powers (exp >= 17, root <= 13 and odd)\n    let mut exp = 0;\n    while n.is_multiple_of(3) {\n        n /= 3;\n        exp += 1;\n    }\n    if exp > 0 {\n        return n == 1 && exp > 1 && (count == 0 || count == exp || count == exp << 1);\n    }\n    // Check powers of 5\n    exp = 0;\n    while n.is_multiple_of(5) {\n        n /= 5;\n        exp += 1;\n    }\n    if exp > 0 {\n        return n == 1 && exp > 1 && (count == 0 || count == exp);\n    }\n    if count > 0 {\n        return false;\n    }\n    // Check powers of 7\n    exp = 0;\n    while n.is_multiple_of(7) {\n        n /= 7;\n        exp += 1;\n    }\n    if exp > 0 {\n        return n == 1 && exp > 1;\n    }\n    // Check powers of 11\n    exp = 0;\n    while n.is_multiple_of(11) {\n        n /= 11;\n        exp += 1;\n    }\n    if exp > 0 {\n        return n == 1 && exp > 1;\n    }\n    // Check powers of 13\n    exp = 0;\n    while n.is_multiple_of(13) {\n        n /= 13;\n        exp += 1;\n    }\n    n == 1 && exp > 1\n}\n\nfn get_perfect_power_u128(n: u128) -> Option<(u128, u64)> {\n    if let Ok(n) = u64::try_from(n) {\n        return get_perfect_power_u64(n).map(|(p, e)| (u128::from(p), e));\n    }\n    // Find largest power of 2 dividing n\n    let mut pow_2 = TrailingZeros::trailing_zeros(n);\n    // Two divides exactly once - not a perfect power\n    if pow_2 == 1 {\n        return None;\n    }\n    // If pow_2 is prime, just check if n is a perfect pow_2-th power\n    if pow_2.is_prime() {\n        return n.checked_root(pow_2).map(|root| (root, pow_2));\n    }\n    // Divide out 2^pow_2 to get the odd part\n    let mut q = n >> pow_2;\n    // Factor out powers of small primes\n    for &prime in SMALL_PRIMES[..168].iter().skip(1) {\n        let prime = u128::from(prime);\n        let (new_q, r) = q.div_mod(prime);\n        if r == 0 {\n            q = new_q;\n            if q.div_assign_mod(prime) != 0 {\n                return None; // prime divides exactly once, reject\n            }\n            let mut pow_p = 2u64;\n            loop {\n                let (new_q, r) = q.div_mod(prime);\n                if r == 0 {\n                    q = new_q;\n                    pow_p += 1;\n                } else {\n                    break;\n                }\n            }\n            pow_2.gcd_assign(pow_p);\n            if pow_2 == 1 {\n                return None; // we have multiplicity 1 of some factor\n            }\n            // As soon as pow_2 becomes prime, stop factoring\n            if q == 1 || pow_2.is_prime() {\n                return n.checked_root(pow_2).map(|root| (root, pow_2));\n            }\n        }\n    }\n    // After factoring, check remaining cases\n    if pow_2 == 0 {\n        // No factors found above; exhaustively check all prime exponents\n        let bits = n.significant_bits();\n        for nth in u64::primes() {\n            // Terminate if exponent exceeds bit length (n ^ (1 / nth) < 2 for nth > bits)\n            if nth > bits {\n                return None;\n            }\n            if let Some(root) = n.checked_root(nth) {\n                return Some((root, nth));\n            }\n        }\n    } else {\n        // Found some factors; only check prime divisors of pow_2\n        for (nth, _) in pow_2.factor() {\n            if let Some(root) = n.checked_root(nth) {\n                return Some((root, nth));\n            }\n        }\n    }\n    None\n}\n\nfn get_perfect_power_u128_bool(n: u128) -> bool {\n    if let Ok(n) = u64::try_from(n) {\n        return get_perfect_power_u64_bool(n);\n    }\n    // Find largest power of 2 dividing n\n    let mut pow_2 = TrailingZeros::trailing_zeros(n);\n    // Two divides exactly once - not a perfect power\n    if pow_2 == 1 {\n        return false;\n    }\n    // If pow_2 is prime, check if n is a perfect pow_2-th power\n    if pow_2.is_prime() {\n        return n.checked_root(pow_2).is_some();\n    }\n    // Divide out 2^pow_2 to get the odd part\n    let mut q = n >> pow_2;\n    // Factor out powers of small primes\n    for &prime in SMALL_PRIMES[..168].iter().skip(1) {\n        let prime = u128::from(prime);\n        let (new_q, r) = q.div_mod(prime);\n        if r == 0 {\n            q = new_q;\n            if q.div_assign_mod(prime) != 0 {\n                return false; // prime divides exactly once, reject\n            }\n            let mut pow_p = 2u64;\n            loop {\n                let (new_q, r) = q.div_mod(prime);\n                if r == 0 {\n                    q = new_q;\n                    pow_p += 1;\n                } else {\n                    break;\n                }\n            }\n            pow_2.gcd_assign(pow_p);\n            if pow_2 == 1 {\n                return false; // we have multiplicity 1 of some factor\n            }\n            // As soon as pow_2 becomes prime, stop factoring\n            if q == 1 || pow_2.is_prime() {\n                return n.checked_root(pow_2).is_some();\n            }\n        }\n    }\n    // After factoring, check remaining cases\n    if pow_2 == 0 {\n        // No factors found above; exhaustively check all prime exponents\n        let bits = n.significant_bits();\n        for nth in u64::primes() {\n            // Terminate if exponent exceeds bit length (n ^ (1 / nth) < 2 for nth > bits)\n            if nth > bits {\n                return false;\n            }\n            if n.checked_root(nth).is_some() {\n                return true;\n            }\n        }\n    } else {\n        // Found some factors; only check prime divisors of pow_2\n        for (nth, _) in pow_2.factor() {\n            if n.checked_root(nth).is_some() {\n                return true;\n            }\n        }\n    }\n    false\n}\n\nfn express_as_power_u32(n: u32) -> Option<(u32, u64)> {\n    if n <= 1 {\n        return Some((n, 2));\n    }\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = get_perfect_power_u32(n)?;\n    while base > 3 {\n        match get_perfect_power_u32(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => {\n                return Some((base, exp));\n            }\n        }\n    }\n    Some((base, exp))\n}\n\nfn express_as_power_u64(n: u64) -> Option<(u64, u64)> {\n    if n <= 1 {\n        return Some((n, 2));\n    }\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = get_perfect_power_u64(n)?;\n    while base > 3 {\n        match get_perfect_power_u64(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => {\n                return Some((base, exp));\n            }\n        }\n    }\n    Some((base, exp))\n}\n\nfn express_as_power_u128(n: u128) -> Option<(u128, u64)> {\n    if n <= 1 {\n        return Some((n, 2));\n    }\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = get_perfect_power_u128(n)?;\n    while base > 3 {\n        match get_perfect_power_u128(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => {\n                return Some((base, exp));\n            }\n        }\n    }\n    Some((base, exp))\n}\n\nfn express_as_power_i32(n: i32) -> Option<(i32, u64)> {\n    if n == 0 || n == 1 {\n        return Some((n, 2));\n    }\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = get_perfect_power_u32(n.unsigned_abs())?;\n    while base > 3 {\n        match get_perfect_power_u32(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => break,\n        }\n    }\n    // handle negative input\n    if n < 0 && exp.even() {\n        while exp.even() {\n            base *= base;\n            exp >>= 1;\n        }\n        if exp == 1 {\n            return None;\n        }\n    }\n    let ibase = i32::exact_from(base);\n    Some((if n >= 0 { ibase } else { -ibase }, exp))\n}\n\nfn express_as_power_i64(n: i64) -> Option<(i64, u64)> {\n    if n == 0 || n == 1 {\n        return Some((n, 2));\n    }\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = get_perfect_power_u64(n.unsigned_abs())?;\n    while base > 3 {\n        match get_perfect_power_u64(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => break,\n        }\n    }\n    // handle negative input\n    if n < 0 && exp.even() {\n        while exp.even() {\n            base *= base;\n            exp >>= 1;\n        }\n        if exp == 1 {\n            return None;\n        }\n    }\n    let ibase = i64::exact_from(base);\n    Some((if n >= 0 { ibase } else { -ibase }, exp))\n}\n\nfn express_as_power_i128(n: i128) -> Option<(i128, u64)> {\n    if n == 0 || n == 1 {\n        return Some((n, 2));\n    }\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = get_perfect_power_u128(n.unsigned_abs())?;\n    while base > 3 {\n        match get_perfect_power_u128(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => break,\n        }\n    }\n    // handle negative input\n    if n < 0 && exp.even() {\n        while exp.even() {\n            base *= base;\n            exp >>= 1;\n        }\n        if exp == 1 {\n            return None;\n        }\n    }\n    let ibase = i128::exact_from(base);\n    Some((if n >= 0 { ibase } else { -ibase }, exp))\n}\n\n#[inline]\nfn is_power_u32(n: u32) -> bool {\n    n <= 1 || get_perfect_power_u32_bool(n)\n}\n\n#[inline]\nfn is_power_u64(n: u64) -> bool {\n    n <= 1 || get_perfect_power_u64_bool(n)\n}\n\nfn is_power_i32(n: i32) -> bool {\n    if n == 0 || n == 1 {\n        return true;\n    }\n    if n > 0 {\n        // For positive numbers, just check if it's a perfect power\n        return get_perfect_power_u32_bool(n.unsigned_abs());\n    }\n    // For negative numbers, we need to check if there's an odd exponent representation\n    //\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = if let Some((base, exp)) = get_perfect_power_u32(n.unsigned_abs()) {\n        (base, exp)\n    } else {\n        return false;\n    };\n    while base > 3 {\n        match get_perfect_power_u32(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => break,\n        }\n    }\n    // Check if we can make the exponent odd\n    !exp.is_power_of_two()\n}\n\nfn is_power_i64(n: i64) -> bool {\n    if n == 0 || n == 1 {\n        return true;\n    }\n    if n > 0 {\n        // For positive numbers, just check if it's a perfect power\n        return get_perfect_power_u64_bool(n.unsigned_abs());\n    }\n    // For negative numbers, we need to check if there's an odd exponent representation\n    //\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = if let Some((base, exp)) = get_perfect_power_u64(n.unsigned_abs()) {\n        (base, exp)\n    } else {\n        return false;\n    };\n    while base > 3 {\n        match get_perfect_power_u64(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => break,\n        }\n    }\n    // Check if we can make the exponent odd\n    !exp.is_power_of_two()\n}\n\nfn is_power_i128(n: i128) -> bool {\n    if n == 0 || n == 1 {\n        return true;\n    }\n    if n > 0 {\n        // For positive numbers, just check if it's a perfect power\n        return get_perfect_power_u128_bool(n.unsigned_abs());\n    }\n    // For negative numbers, we need to check if there's an odd exponent representation\n    //\n    // continue until we have largest possible exponent\n    let (mut base, mut exp) = if let Some((base, exp)) = get_perfect_power_u128(n.unsigned_abs()) {\n        (base, exp)\n    } else {\n        return false;\n    };\n    while base > 3 {\n        match get_perfect_power_u128(base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => break,\n        }\n    }\n    // Check if we can make the exponent odd\n    !exp.is_power_of_two()\n}\n\nimpl ExpressAsPower for u64 {\n    /// Expresses a number as a perfect power, if such a representation exists. We define a perfect\n    /// power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n    /// particular, 0 and 1 are considered perfect powers. If a number has more than one\n    /// representation as a power, the representation with the smallest base is returned. For\n    /// example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather than `(4,3)` or `(8,2)`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#express_as_power).\n    ///\n    /// # Notes\n    /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a perfect\n    ///   power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n    /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n    #[inline]\n    fn express_as_power(&self) -> Option<(u64, u64)> {\n        express_as_power_u64(*self)\n    }\n}\n\nimpl ExpressAsPower for u128 {\n    /// Expresses a number as a perfect power, if such a representation exists. We define a perfect\n    /// power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n    /// particular, 0 and 1 are considered perfect powers. If a number has more than one\n    /// representation as a power, the representation with the smallest base is returned. For\n    /// example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather than `(4,3)` or `(8,2)`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#express_as_power).\n    ///\n    /// # Notes\n    /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a perfect\n    ///   power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n    /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n    #[inline]\n    fn express_as_power(&self) -> Option<(Self, u64)> {\n        express_as_power_u128(*self)\n    }\n}\n\nimpl ExpressAsPower for usize {\n    /// Expresses a number as a perfect power, if such a representation exists. We define a perfect\n    /// power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n    /// particular, 0 and 1 are considered perfect powers. If a number has more than one\n    /// representation as a power, the representation with the smallest base is returned. For\n    /// example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather than `(4,3)` or `(8,2)`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#express_as_power).\n    ///\n    /// # Notes\n    /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a perfect\n    ///   power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n    /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n    fn express_as_power(&self) -> Option<(Self, u64)> {\n        if USIZE_IS_U32 {\n            match express_as_power_u32(u32::wrapping_from(*self)) {\n                Some((base, exp)) => Some((Self::wrapping_from(base), exp)),\n                _ => None,\n            }\n        } else {\n            match express_as_power_u64(u64::wrapping_from(*self)) {\n                Some((base, exp)) => Some((Self::wrapping_from(base), exp)),\n                _ => None,\n            }\n        }\n    }\n}\n\nimpl IsPower for u64 {\n    /// Determines whether an integer is a perfect power. We define a perfect power as any number of\n    /// the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In particular 0 and 1 are\n    /// considered perfect powers.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#is_power).\n    #[inline]\n    fn is_power(&self) -> bool {\n        is_power_u64(*self)\n    }\n}\n\nimpl IsPower for u128 {\n    /// Determines whether an integer is a perfect power. We define a perfect power as any number of\n    /// the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In particular 0 and 1 are\n    /// considered perfect powers.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#is_power).\n    #[inline]\n    fn is_power(&self) -> bool {\n        get_perfect_power_u128_bool(*self)\n    }\n}\n\nimpl IsPower for usize {\n    /// Determines whether an integer is a perfect power. We define a perfect power as any number of\n    /// the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In particular 0 and 1 are\n    /// considered perfect powers.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#is_power).\n    fn is_power(&self) -> bool {\n        if USIZE_IS_U32 {\n            is_power_u32(u32::wrapping_from(*self))\n        } else {\n            is_power_u64(u64::wrapping_from(*self))\n        }\n    }\n}\n\nmacro_rules! impl_unsigned_32 {\n    ($t: ident) => {\n        impl ExpressAsPower for $t {\n            /// Expresses a number as a perfect power, if such a representation exists. We define a\n            /// perfect power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both\n            /// integers. In particular, 0 and 1 are considered perfect powers. If a number has more\n            /// than one representation as a power, the representation with the smallest base is\n            /// returned. For example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather\n            /// than `(4,3)` or `(8,2)`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_power#express_as_power).\n            ///\n            /// # Notes\n            /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a\n            ///   perfect power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n            /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n            fn express_as_power(&self) -> Option<($t, u64)> {\n                match express_as_power_u32(u32::from(*self)) {\n                    Some((base, exp)) => Some(($t::exact_from(base), exp)),\n                    _ => None,\n                }\n            }\n        }\n\n        impl IsPower for $t {\n            /// Determines whether an integer is a perfect power. We define a perfect power as any\n            /// number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n            /// particular 0 and 1 are considered perfect powers.\n            ///\n            /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_power#is_power).\n            #[inline]\n            fn is_power(&self) -> bool {\n                is_power_u32(u32::from(*self))\n            }\n        }\n    };\n}\nimpl_unsigned_32!(u8);\nimpl_unsigned_32!(u16);\nimpl_unsigned_32!(u32);\n\nimpl ExpressAsPower for i64 {\n    /// Expresses a number as a perfect power, if such a representation exists. We define a perfect\n    /// power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n    /// particular, 0 and 1 are considered perfect powers. If a number has more than one\n    /// representation as a power, the representation with the smallest base is returned. For\n    /// example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather than `(4,3)` or `(8,2)`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#express_as_power).\n    ///\n    /// # Notes\n    /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a perfect\n    ///   power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n    /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n    #[inline]\n    fn express_as_power(&self) -> Option<(Self, u64)> {\n        express_as_power_i64(*self)\n    }\n}\n\nimpl ExpressAsPower for i128 {\n    /// Expresses a number as a perfect power, if such a representation exists. We define a perfect\n    /// power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n    /// particular, 0 and 1 are considered perfect powers. If a number has more than one\n    /// representation as a power, the representation with the smallest base is returned. For\n    /// example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather than `(4,3)` or `(8,2)`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#express_as_power).\n    ///\n    /// # Notes\n    /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a perfect\n    ///   power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n    /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n    #[inline]\n    fn express_as_power(&self) -> Option<(Self, u64)> {\n        express_as_power_i128(*self)\n    }\n}\n\nimpl ExpressAsPower for isize {\n    /// Expresses a number as a perfect power, if such a representation exists. We define a perfect\n    /// power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n    /// particular, 0 and 1 are considered perfect powers. If a number has more than one\n    /// representation as a power, the representation with the smallest base is returned. For\n    /// example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather than `(4,3)` or `(8,2)`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#express_as_power).\n    ///\n    /// # Notes\n    /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a perfect\n    ///   power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n    /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n    fn express_as_power(&self) -> Option<(Self, u64)> {\n        if USIZE_IS_U32 {\n            match express_as_power_i32(i32::wrapping_from(*self)) {\n                Some((base, exp)) => Some((Self::wrapping_from(base), exp)),\n                _ => None,\n            }\n        } else {\n            match express_as_power_i64(i64::wrapping_from(*self)) {\n                Some((base, exp)) => Some((Self::wrapping_from(base), exp)),\n                _ => None,\n            }\n        }\n    }\n}\n\nimpl IsPower for i64 {\n    /// Determines whether an integer is a perfect power. We define a perfect power as any number of\n    /// the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In particular 0 and 1 are\n    /// considered perfect powers.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#is_power).\n    #[inline]\n    fn is_power(&self) -> bool {\n        is_power_i64(*self)\n    }\n}\n\nimpl IsPower for i128 {\n    /// Determines whether an integer is a perfect power. We define a perfect power as any number of\n    /// the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In particular 0 and 1 are\n    /// considered perfect powers.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#is_power).\n    #[inline]\n    fn is_power(&self) -> bool {\n        is_power_i128(*self)\n    }\n}\n\nimpl IsPower for isize {\n    /// Determines whether an integer is a perfect power. We define a perfect power as any number of\n    /// the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In particular 0 and 1 are\n    /// considered perfect powers.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_power#is_power).\n    fn is_power(&self) -> bool {\n        if USIZE_IS_U32 {\n            is_power_i32(i32::wrapping_from(*self))\n        } else {\n            is_power_i64(i64::wrapping_from(*self))\n        }\n    }\n}\n\nmacro_rules! impl_signed_32 {\n    ($t: ident) => {\n        impl ExpressAsPower for $t {\n            /// Expresses a number as a perfect power, if such a representation exists. We define a\n            /// perfect power as any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both\n            /// integers. In particular, 0 and 1 are considered perfect powers. If a number has more\n            /// than one representation as a power, the representation with the smallest base is\n            /// returned. For example, $64=2^6=4^3=8^2$, but this function returns `(2,6)` rather\n            /// than `(4,3)` or `(8,2)`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_power#express_as_power).\n            ///\n            /// # Notes\n            /// - This returns an [`Option`] which is either `Some((base, exp))` if the input is a\n            ///   perfect power equal to $\\text{base}^\\text{exp}$, otherwise `None`.\n            /// - For 0 this returns `Some((0, 2))` and for 1 this returns `Some((1, 2))`.\n            fn express_as_power(&self) -> Option<($t, u64)> {\n                match express_as_power_i32(i32::from(*self)) {\n                    Some((base, exp)) => Some(($t::exact_from(base), exp)),\n                    _ => None,\n                }\n            }\n        }\n\n        impl IsPower for $t {\n            /// Determines whether an integer is a perfect power. We define a perfect power as any\n            /// number of the form $a^x$ where $x > 1$, with $a$ and $x$ both integers. In\n            /// particular 0 and 1 are considered perfect powers.\n            ///\n            /// $f(x) = (\\exists b \\in \\Z, e \\in \\N : e > 1 \\ \\text{and} \\ b^e = x)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_power#is_power).\n            #[inline]\n            fn is_power(&self) -> bool {\n                is_power_i32(i32::from(*self))\n            }\n        }\n    };\n}\nimpl_signed_32!(i8);\nimpl_signed_32!(i16);\nimpl_signed_32!(i32);\n"
  },
  {
    "path": "malachite-base/src/num/factorization/is_prime.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2008 Peter Shrimpton\n//\n//      Copyright © 2009 Tom Boothby\n//\n//      Copyright © 2009, 2010, 2013, 2015, 2016 William Hart\n//\n//      Copyright © 2010 Fredrik Johansson\n//\n//      Copyright © 2014 Dana Jacobsen\n//\n//      Copyright © 2023 Mathieu Gouttenoire\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::mod_pow::mul_mod_helper;\nuse crate::num::arithmetic::traits::{\n    Gcd, JacobiSymbol, ModAdd, ModInverse, ModMulPrecomputed, ModMulPrecomputedAssign, ModSub,\n    Parity, PowerOf2, WrappingAddAssign, WrappingNegAssign, XMulYToZZ, XXAddYYToZZ,\n};\nuse crate::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse crate::num::comparison::traits::PartialOrdAbs;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::factorization::traits::IsPrime;\nuse crate::num::logic::traits::{BitAccess, LeadingZeros, SignificantBits, TrailingZeros};\n\n// This is FLINT_ODD_PRIME_LOOKUP when FLINT64 is true, from ulong_extras/is_oddprime.c, FLINT\n// 3.1.2.\nconst ODD_PRIME_LOOKUP_U64: [u64; 32] = [\n    0x816d129a64b4cb6e,\n    0x2196820d864a4c32,\n    0xa48961205a0434c9,\n    0x4a2882d129861144,\n    0x834992132424030,\n    0x148a48844225064b,\n    0xb40b4086c304205,\n    0x65048928125108a0,\n    0x80124496804c3098,\n    0xc02104c941124221,\n    0x804490000982d32,\n    0x220825b082689681,\n    0x9004265940a28948,\n    0x6900924430434006,\n    0x12410da408088210,\n    0x86122d22400c060,\n    0x110d301821b0484,\n    0x14916022c044a002,\n    0x92094d204a6400c,\n    0x4ca2100800522094,\n    0xa48b081051018200,\n    0x34c108144309a25,\n    0x2084490880522502,\n    0x241140a218003250,\n    0xa41a00101840128,\n    0x2926000836004512,\n    0x10100480c0618283,\n    0xc20c26584822006d,\n    0x4520582024894810,\n    0x10c0250219002488,\n    0x802832ca01140868,\n    0x60901300264b0400,\n];\n\n// This is FLINT_ODD_PRIME_LOOKUP when FLINT64 is false, from ulong_extras/is_oddprime.c, FLINT\n// 3.1.2.\nconst ODD_PRIME_LOOKUP_U32: [u32; 64] = [\n    0x64b4cb6e, 0x816d129a, 0x864a4c32, 0x2196820d, 0x5a0434c9, 0xa4896120, 0x29861144, 0x4a2882d1,\n    0x32424030, 0x8349921, 0x4225064b, 0x148a4884, 0x6c304205, 0xb40b408, 0x125108a0, 0x65048928,\n    0x804c3098, 0x80124496, 0x41124221, 0xc02104c9, 0x982d32, 0x8044900, 0x82689681, 0x220825b0,\n    0x40a28948, 0x90042659, 0x30434006, 0x69009244, 0x8088210, 0x12410da4, 0x2400c060, 0x86122d2,\n    0x821b0484, 0x110d301, 0xc044a002, 0x14916022, 0x4a6400c, 0x92094d2, 0x522094, 0x4ca21008,\n    0x51018200, 0xa48b0810, 0x44309a25, 0x34c1081, 0x80522502, 0x20844908, 0x18003250, 0x241140a2,\n    0x1840128, 0xa41a001, 0x36004512, 0x29260008, 0xc0618283, 0x10100480, 0x4822006d, 0xc20c2658,\n    0x24894810, 0x45205820, 0x19002488, 0x10c02502, 0x1140868, 0x802832ca, 0x264b0400, 0x60901300,\n];\n\n// This is FLINT_D_BITS when FLINT64 is true, from flint.h, FLINT 3.1.2.\nconst FLINT_D_BITS: u64 = 53;\n\n// This is n_is_oddprime_small_u64 when FLINT64 is true, from ulong_extras/is_oddprime.c, FLINT\n// 3.1.2.\n#[inline]\nfn is_odd_prime_small_u64(n: u64) -> bool {\n    ODD_PRIME_LOOKUP_U64[(n >> 7) as usize].get_bit((n >> 1) & u64::WIDTH_MASK)\n}\n\n// This is n_is_oddprime_small_u64 when FLINT64 is false, from ulong_extras/is_oddprime.c, FLINT\n// 3.1.2.\n#[inline]\nfn is_odd_prime_small_u32(n: u32) -> bool {\n    ODD_PRIME_LOOKUP_U32[(n >> 6) as usize].get_bit(u64::from(n >> 1) & u32::WIDTH_MASK)\n}\n\n// This is n_mod2_preinv when FLINT64 is false, from ulong_extras/mod2_preinv.c, FLINT 3.1.2.\nfn mod_preinverted_u32(a: u32, mut n: u32, inverse: u32) -> u32 {\n    assert_ne!(n, 0);\n    let norm = LeadingZeros::leading_zeros(n);\n    n <<= norm;\n    let u1 = a >> (u32::WIDTH - norm);\n    let u0 = a << norm;\n    let (mut q1, mut q0) = u32::x_mul_y_to_zz(inverse, u1);\n    (q1, q0) = u32::xx_add_yy_to_zz(q1, q0, u1, u0);\n    let mut r = u0 - (q1 + 1) * n;\n    if r > q0 {\n        r += n;\n    }\n    if r < n { r >> norm } else { (r - n) >> norm }\n}\n\n// This is n_mod2_preinv when FLINT64 is true, from ulong_extras/mod2_preinv.c, FLINT 3.1.2.\nfn mod_preinverted_u64(a: u64, mut n: u64, inverse: u64) -> u64 {\n    assert_ne!(n, 0);\n    let norm = LeadingZeros::leading_zeros(n);\n    n <<= norm;\n    let u1 = a >> (u64::WIDTH - norm);\n    let u0 = a << norm;\n    let (mut q1, mut q0) = u64::x_mul_y_to_zz(inverse, u1);\n    (q1, q0) = u64::xx_add_yy_to_zz(q1, q0, u1, u0);\n    let mut r = u0 - (q1 + 1) * n;\n    if r > q0 {\n        r += n;\n    }\n    if r < n { r >> norm } else { (r - n) >> norm }\n}\n\n// This is n_powmod2_ui_preinv when FLINT64 is false, from ulong_extras/powmod2_ui_preinv.c, FLINT\n// 3.1.2.\nfn mod_pow_preinverted_u32(mut a: u32, mut exp: u32, mut n: u32, inverse: u32) -> u32 {\n    assert_ne!(n, 0);\n    if exp == 0 {\n        // anything modulo 1 is 0\n        return u32::from(n != 1);\n    }\n    if a == 0 {\n        return 0;\n    }\n    if a >= n {\n        a = mod_preinverted_u32(a, n, inverse);\n    }\n    let norm = LeadingZeros::leading_zeros(n);\n    a <<= norm;\n    n <<= norm;\n    while exp.even() {\n        a = mul_mod_helper::<u32, u64>(a, a, n, inverse, norm);\n        exp >>= 1;\n    }\n    let mut x = a;\n    loop {\n        exp >>= 1;\n        if exp == 0 {\n            break;\n        }\n        a = mul_mod_helper::<u32, u64>(a, a, n, inverse, norm);\n        if exp.odd() {\n            x = mul_mod_helper::<u32, u64>(x, a, n, inverse, norm);\n        }\n    }\n    x >> norm\n}\n\n// This is n_powmod2_ui_preinv when FLINT64 is true, from ulong_extras/powmod2_ui_preinv.c, FLINT\n// 3.1.2.\nfn mod_pow_preinverted_u64(mut a: u64, mut exp: u64, mut n: u64, inverse: u64) -> u64 {\n    assert_ne!(n, 0);\n    if exp == 0 {\n        // anything modulo 1 is 0\n        return u64::from(n != 1);\n    }\n    if a == 0 {\n        return 0;\n    }\n    if a >= n {\n        a = mod_preinverted_u64(a, n, inverse);\n    }\n    let norm = LeadingZeros::leading_zeros(n);\n    a <<= norm;\n    n <<= norm;\n    while exp.even() {\n        a = mul_mod_helper::<u64, u128>(a, a, n, inverse, norm);\n        exp >>= 1;\n    }\n    let mut x = a;\n    loop {\n        exp >>= 1;\n        if exp == 0 {\n            break;\n        }\n        a = mul_mod_helper::<u64, u128>(a, a, n, inverse, norm);\n        if exp.odd() {\n            x = mul_mod_helper::<u64, u128>(x, a, n, inverse, norm);\n        }\n    }\n    x >> norm\n}\n\n// This is n_mulmod_precomp when FLINT64 is true, from ulong_extras/mulmod_precomp.c, FLINT 3.1.2.\nfn mod_mul_preinverted_float(a: u64, b: u64, n: u64, inverse: f64) -> u64 {\n    let q = ((a as f64) * (b as f64) * inverse) as u64;\n    let mut r = (a.wrapping_mul(b)).wrapping_sub(q.wrapping_mul(n));\n    if r.get_highest_bit() {\n        r.wrapping_add_assign(n);\n        if r.get_highest_bit() {\n            return r.wrapping_add(n);\n        }\n    } else if r >= n {\n        return r - n;\n    }\n    r\n}\n\n// This is n_powmod_ui_precomp when FLINT64 is true, from ulong_extras/powmod_precomp.c, FLINT\n// 3.1.2.\npub(crate) fn mod_pow_preinverted_float(a: u64, mut exp: u64, n: u64, inverse: f64) -> u64 {\n    if n == 1 {\n        return 0;\n    }\n    let mut x = 1;\n    let mut y = a;\n    while exp != 0 {\n        if exp.odd() {\n            x = mod_mul_preinverted_float(x, y, n, inverse);\n        }\n        exp >>= 1;\n        if exp != 0 {\n            y = mod_mul_preinverted_float(y, y, n, inverse);\n        }\n    }\n    x\n}\n\n// This is n_is_probabprime_fermat when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT\n// 3.1.2.\nfn is_probable_prime_fermat(n: u64, i: u64) -> bool {\n    (if n.significant_bits() <= FLINT_D_BITS {\n        mod_pow_preinverted_float(i, n - 1, n, 1.0 / (n as f64))\n    } else {\n        mod_pow_preinverted_u64(i, n - 1, n, u64::precompute_mod_mul_data(&n))\n    }) == 1\n}\n\n// This is fchain_precomp when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT 3.1.2.\nfn fibonacci_chain_precomputed(m: u64, n: u64, inverse: f64) -> (u64, u64) {\n    let mut x = 2;\n    let mut y = n - 3;\n    let mut power = u64::power_of_2(m.significant_bits() - 1);\n    while power != 0 {\n        let xy = mod_mul_preinverted_float(x, y, n, inverse).mod_add(3, n);\n        (x, y) = if m & power != 0 {\n            (\n                xy,\n                mod_mul_preinverted_float(y, y, n, inverse).mod_sub(2, n),\n            )\n        } else {\n            (\n                mod_mul_preinverted_float(x, x, n, inverse).mod_sub(2, n),\n                xy,\n            )\n        };\n        power >>= 1;\n    }\n    (x, y)\n}\n\n// This is fchain2_preinv when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT 3.1.2.\nfn fibonacci_chain_preinvert(m: u64, n: u64, ninv: u64) -> (u64, u64) {\n    let mut x = 2;\n    let mut y = n - 3;\n    let mut power = u64::power_of_2(m.significant_bits() - 1);\n    while power != 0 {\n        let xy = x.mod_mul_precomputed(y, n, &ninv).mod_add(3, n);\n        (x, y) = if m & power != 0 {\n            (xy, y.mod_mul_precomputed(y, n, &ninv).mod_sub(2, n))\n        } else {\n            (x.mod_mul_precomputed(x, n, &ninv).mod_sub(2, n), xy)\n        };\n        power >>= 1;\n    }\n    (x, y)\n}\n\n// This is n_is_probabprime_fibonacci when FLINT64 is true, from ulong_extras/is_probabprime.c,\n// FLINT 3.1.2.\nfn is_probable_prime_fibonacci(n: u64) -> bool {\n    if i64::wrapping_from(n).le_abs(&3) {\n        return n >= 2;\n    }\n    // cannot overflow as (5 / n) = 0 for n = 2 ^ 64 - 1\n    let m = n.wrapping_sub(u64::wrapping_from(5.jacobi_symbol(n))) >> 1;\n    if n.significant_bits() <= FLINT_D_BITS {\n        let inverse = 1.0 / (n as f64);\n        let (x, y) = fibonacci_chain_precomputed(m, n, inverse);\n        mod_mul_preinverted_float(n - 3, x, n, inverse)\n            == mod_mul_preinverted_float(2, y, n, inverse)\n    } else {\n        let inverse = u64::precompute_mod_mul_data(&n);\n        let (x, y) = fibonacci_chain_preinvert(m, n, inverse);\n        (n - 3).mod_mul_precomputed(x, n, &inverse) == 2.mod_mul_precomputed(y, n, &inverse)\n    }\n}\n\n// This is lchain_precomp when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT 3.1.2.\nfn lucas_chain_precomputed(m: u64, a: u64, n: u64, npre: f64) -> (u64, u64) {\n    let mut x = 2;\n    let mut y = n - 3;\n    let mut power = u64::power_of_2(m.significant_bits() - 1);\n    while power != 0 {\n        let xy = mod_mul_preinverted_float(x, y, n, npre).mod_sub(a, n);\n        (x, y) = if m & power != 0 {\n            (xy, mod_mul_preinverted_float(y, y, n, npre).mod_sub(2, n))\n        } else {\n            (mod_mul_preinverted_float(x, x, n, npre).mod_sub(2, n), xy)\n        };\n        power >>= 1;\n    }\n    (x, y)\n}\n\n// This is lchain2_preinv when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT 3.1.2.\nfn lucas_chain_preinvert(m: u64, a: u64, n: u64, ninv: u64) -> (u64, u64) {\n    let mut x = 2;\n    let mut y = a;\n    let mut power = u64::power_of_2(m.significant_bits() - 1);\n    while power != 0 {\n        let xy = x.mod_mul_precomputed(y, n, &ninv).mod_sub(a, n);\n        (x, y) = if m & power != 0 {\n            (xy, y.mod_mul_precomputed(y, n, &ninv).mod_sub(2, n))\n        } else {\n            (x.mod_mul_precomputed(x, n, &ninv).mod_sub(2, n), xy)\n        };\n        power >>= 1;\n    }\n    (x, y)\n}\n\n// This is n_is_probabprime_lucas when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT\n// 3.1.2, where n is odd and greater than 52, and only true or false is returned, rather than 0, 1,\n// or -1.\nfn is_probable_prime_lucas(n: u64) -> bool {\n    let mut d = 0u64;\n    if i64::wrapping_from(n).le_abs(&2) {\n        return n == 2;\n    }\n    let mut neg_d = false;\n    let mut j = 0;\n    for i in 0..100 {\n        d = 5 + (i << 1);\n        neg_d = false;\n        if d.gcd(n % d) == 1 {\n            if i.odd() {\n                neg_d = true;\n            }\n            let jacobi = if neg_d {\n                (-i128::from(d)).jacobi_symbol(i128::from(n))\n            } else {\n                d.jacobi_symbol(n)\n            };\n            if jacobi == -1 {\n                break;\n            }\n        } else if n != d {\n            return false;\n        }\n        j += 1;\n    }\n    if j == 100 {\n        return true;\n    }\n    if neg_d {\n        d.wrapping_neg_assign();\n    }\n    let mut q = u64::wrapping_from(1i64.wrapping_sub(i64::wrapping_from(d)) / 4);\n    if q.get_highest_bit() {\n        q.wrapping_add_assign(n);\n    }\n    let a = q.mod_inverse(n).unwrap().mod_sub(2, n);\n    let (left, right) = if n <= FLINT_D_BITS {\n        let inverse = 1.0 / (n as f64);\n        let (x, y) = lucas_chain_precomputed(n + 1, a, n, inverse);\n        (\n            mod_mul_preinverted_float(a, x, n, inverse),\n            mod_mul_preinverted_float(2, y, n, inverse),\n        )\n    } else {\n        let inverse = u64::precompute_mod_mul_data(&n);\n        let (x, y) = lucas_chain_preinvert(n + 1, a, n, inverse);\n        (\n            a.mod_mul_precomputed(x, n, &inverse),\n            2.mod_mul_precomputed(y, n, &inverse),\n        )\n    };\n    left == right\n}\n\n// This is n_is_strong_probabprime2_preinv when FLINT64 is false, from\n// ulong_extras/is_strong_probabprime2_preinv.c, FLINT 3.1.2.\nfn is_strong_probable_prime_preinverted_u32(n: u32, inverse: u32, a: u32, d: u32) -> bool {\n    assert!(a < n);\n    let nm1 = n - 1;\n    if a <= 1 || a == nm1 {\n        return true;\n    }\n    let mut t = d;\n    let mut y = mod_pow_preinverted_u32(a, t, n, inverse);\n    if y == 1 {\n        return true;\n    }\n    t <<= 1;\n    while t != nm1 && y != nm1 {\n        y.mod_mul_precomputed_assign(y, n, &inverse);\n        t <<= 1;\n    }\n    y == nm1\n}\n\n// This is n_is_strong_probabprime2_preinv when FLINT64 is true, from\n// ulong_extras/is_strong_probabprime2_preinv.c, FLINT 3.1.2.\nfn is_strong_probable_prime_preinverted_u64(n: u64, inverse: u64, a: u64, d: u64) -> bool {\n    assert!(a < n);\n    let nm1 = n - 1;\n    if a <= 1 || a == nm1 {\n        return true;\n    }\n    let mut t = d;\n    let mut y = mod_pow_preinverted_u64(a, t, n, inverse);\n    if y == 1 {\n        return true;\n    }\n    t <<= 1;\n    while t != nm1 && y != nm1 {\n        y.mod_mul_precomputed_assign(y, n, &inverse);\n        t <<= 1;\n    }\n    y == nm1\n}\n\n// This is n_mod2_precomp when FLINT64 is true, from ulong_extras/mod2_precomp.c, FLINT 3.1.2.\nfn mod_preinverted_float(a: u64, n: u64, inverse: f64) -> u64 {\n    if a < n {\n        return a;\n    }\n    let ni = i64::wrapping_from(n);\n    if ni < 0 {\n        return a.wrapping_sub(n);\n    }\n    let (mut q, mut r) = if n == 1 {\n        (a, 0)\n    } else {\n        let q = ((a as f64) * inverse) as u64;\n        (\n            q,\n            i64::wrapping_from(a).wrapping_sub(i64::wrapping_from(q.wrapping_mul(n))),\n        )\n    };\n    if r < ni.wrapping_neg() {\n        q -= ((r.wrapping_neg() as f64) * inverse) as u64;\n    } else if r >= ni {\n        q += ((r as f64) * inverse) as u64;\n    } else if r < 0 {\n        return u64::wrapping_from(r + ni);\n    } else {\n        return u64::wrapping_from(r);\n    }\n    r = i64::wrapping_from(a) - i64::wrapping_from(q.wrapping_mul(n));\n    u64::wrapping_from(if r >= ni {\n        r.wrapping_sub(ni)\n    } else if r < 0 {\n        r.wrapping_add(ni)\n    } else {\n        r\n    })\n}\n\n// This is n_is_strong_probabprime_precomp when FLINT64 is true, from\n// ulong_extras/is_strong_probabprime_precomp.c, FLINT 3.1.2.\nfn is_strong_probable_prime_preinverted_float(n: u64, inverse: f64, mut a: u64, d: u64) -> bool {\n    // Map large base to range 2 ... n - 1\n    if a >= n {\n        a = mod_preinverted_float(a, n, inverse);\n    }\n    let nm1 = n - 1;\n    if a <= 1 || a == nm1 {\n        return true;\n    }\n    let mut t = d;\n    let mut y = mod_pow_preinverted_float(a, t, n, inverse);\n    if y == 1 {\n        return true;\n    }\n    t <<= 1;\n    while t != nm1 && y != nm1 {\n        y = mod_mul_preinverted_float(y, y, n, inverse);\n        t <<= 1;\n    }\n    y == nm1\n}\n\n// This is n_is_probabprime_BPSW when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT\n// 3.1.2, where n is odd and greater than 1.\nfn is_probable_prime_bpsw(n: u64) -> bool {\n    let nm10 = n % 10;\n    if nm10 == 3 || nm10 == 7 {\n        return is_probable_prime_fermat(n, 2) && is_probable_prime_fibonacci(n);\n    }\n    let mut d = n - 1;\n    while d.even() {\n        d >>= 1;\n    }\n    let result = if n.significant_bits() <= FLINT_D_BITS {\n        is_strong_probable_prime_preinverted_float(n, 1.0 / (n as f64), 2, d)\n    } else {\n        is_strong_probable_prime_preinverted_u64(n, u64::precompute_mod_mul_data(&n), 2, d)\n    };\n    if !result {\n        return false;\n    }\n    is_probable_prime_lucas(n)\n}\n\nconst FLINT_ODDPRIME_SMALL_CUTOFF: u32 = 4096;\n\n// This is n_is_probabprime when FLINT64 is false, from ulong_extras/is_probabprime.c, FLINT 3.1.2,\n// assuming n is odd and greater than 2.\nfn is_probable_prime_u32(n: u32) -> bool {\n    if n < FLINT_ODDPRIME_SMALL_CUTOFF {\n        return is_odd_prime_small_u32(n);\n    }\n    let mut d = n - 1;\n    d >>= TrailingZeros::trailing_zeros(d);\n    // For 32-bit, just the 2-base or 3-base Miller-Rabin is enough.\n    let inverse = u32::precompute_mod_mul_data(&n);\n    if n < 9080191 {\n        is_strong_probable_prime_preinverted_u32(n, inverse, 31, d)\n            && is_strong_probable_prime_preinverted_u32(n, inverse, 73, d)\n    } else {\n        is_strong_probable_prime_preinverted_u32(n, inverse, 2, d)\n            && is_strong_probable_prime_preinverted_u32(n, inverse, 7, d)\n            && is_strong_probable_prime_preinverted_u32(n, inverse, 61, d)\n    }\n}\n\n// This is n_is_probabprime when FLINT64 is true, from ulong_extras/is_probabprime.c, FLINT 3.1.2,\n// assuming n is odd and greater than 2.\nfn is_probable_prime_u64(n: u64) -> bool {\n    if n < u64::from(FLINT_ODDPRIME_SMALL_CUTOFF) {\n        return is_odd_prime_small_u64(n);\n    } else if n >= 1050535501 {\n        // Avoid the unnecessary inverse\n        return is_probable_prime_bpsw(n);\n    }\n    let mut d = n - 1;\n    d >>= TrailingZeros::trailing_zeros(d);\n    let inverse = 1.0 / (n as f64);\n    // For 64-bit, BPSW seems to be a little bit faster than 3 bases.\n    if n < 341531 {\n        is_strong_probable_prime_preinverted_float(n, inverse, 9345883071009581737, d)\n    } else {\n        is_strong_probable_prime_preinverted_float(n, inverse, 336781006125, d)\n            && is_strong_probable_prime_preinverted_float(n, inverse, 9639812373923155, d)\n    }\n}\n\nimpl IsPrime for u8 {\n    /// Tests whether a `u8` is prime.\n    ///\n    /// This implementation just does a few divisibility checks.\n    ///\n    /// If you want to generate many small primes, try using\n    /// [`u8::primes`][crate::num::factorization::traits::Primes::primes] instead.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::IsPrime;\n    ///\n    /// assert_eq!(5u8.is_prime(), true);\n    /// assert_eq!(6u8.is_prime(), false);\n    /// ```\n    fn is_prime(&self) -> bool {\n        let n = *self;\n        if n < 11 {\n            n == 2 || n == 3 || n == 5 || n == 7\n        } else if n.even() || n.is_multiple_of(3) || n.is_multiple_of(5) || n.is_multiple_of(7) {\n            false\n        } else {\n            n < 121 || !n.is_multiple_of(11) && !n.is_multiple_of(13)\n        }\n    }\n}\n\nimpl IsPrime for u16 {\n    /// Tests whether a `u16` is prime.\n    ///\n    /// This implementation does a few divisibility checks, then performs strong probable prime\n    /// tests with bases 31 and 73, which is enough to prove primality for any integer less than\n    /// $2^{16}$.\n    ///\n    /// If you want to generate many small primes, try using\n    /// [`u16::primes`][crate::num::factorization::traits::Primes::primes] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::IsPrime;\n    ///\n    /// assert_eq!(5u16.is_prime(), true);\n    /// assert_eq!(6u16.is_prime(), false);\n    /// assert_eq!(65521u16.is_prime(), true);\n    /// ```\n    fn is_prime(&self) -> bool {\n        // Flint's \"BPSW\" (which Malachite's code is based on) checked against Feitsma and Galway's\n        // database [1, 2] up to 2^64 by Dana Jacobsen.\n        // - [1] http://www.janfeitsma.nl/math/psp2/database\n        // - [2] http://www.cecm.sfu.ca/Pseudoprimes/index-2-to-64.html\n        let n = *self;\n        if n < 11 {\n            n == 2 || n == 3 || n == 5 || n == 7\n        } else if n.even() || n.is_multiple_of(3) || n.is_multiple_of(5) || n.is_multiple_of(7) {\n            false\n        } else if n < 121 {\n            // 11*11\n            true\n        } else if n.is_multiple_of(11)\n            || n.is_multiple_of(13)\n            || n.is_multiple_of(17)\n            || n.is_multiple_of(19)\n            || n.is_multiple_of(23)\n            || n.is_multiple_of(29)\n            || n.is_multiple_of(31)\n            || n.is_multiple_of(37)\n            || n.is_multiple_of(41)\n            || n.is_multiple_of(43)\n            || n.is_multiple_of(47)\n            || n.is_multiple_of(53)\n        {\n            false\n        } else {\n            n < 3481 || is_probable_prime_u32(u32::from(n))\n        }\n    }\n}\n\nimpl IsPrime for u32 {\n    /// Tests whether a `u32` is prime.\n    ///\n    /// This implementation does a few divisibility checks, then performs a few strong probable\n    /// prime tests, which is enough to prove primality for any integer less than $2^{32}$.\n    ///\n    /// If you want to generate many small primes, try using\n    /// [`u32::primes`][crate::num::factorization::traits::Primes::primes] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::IsPrime;\n    ///\n    /// assert_eq!(5u32.is_prime(), true);\n    /// assert_eq!(6u32.is_prime(), false);\n    /// assert_eq!(4294967291u32.is_prime(), true);\n    /// ```\n    fn is_prime(&self) -> bool {\n        // Flint's \"BPSW\" (which Malachite's code is based on) checked against Feitsma and Galway's\n        // database [1, 2] up to 2^64 by Dana Jacobsen.\n        // - [1] http://www.janfeitsma.nl/math/psp2/database\n        // - [2] http://www.cecm.sfu.ca/Pseudoprimes/index-2-to-64.html\n        let n = *self;\n        if n < 11 {\n            n == 2 || n == 3 || n == 5 || n == 7\n        } else if n.even() || n.is_multiple_of(3) || n.is_multiple_of(5) || n.is_multiple_of(7) {\n            false\n        } else if n < 121 {\n            // 11*11\n            true\n        } else if n.is_multiple_of(11)\n            || n.is_multiple_of(13)\n            || n.is_multiple_of(17)\n            || n.is_multiple_of(19)\n            || n.is_multiple_of(23)\n            || n.is_multiple_of(29)\n            || n.is_multiple_of(31)\n            || n.is_multiple_of(37)\n            || n.is_multiple_of(41)\n            || n.is_multiple_of(43)\n            || n.is_multiple_of(47)\n            || n.is_multiple_of(53)\n        {\n            false\n        } else if n < 3481 {\n            // 59*59\n            true\n        } else if n > 1000000\n            && (n.is_multiple_of(59)\n                || n.is_multiple_of(61)\n                || n.is_multiple_of(67)\n                || n.is_multiple_of(71)\n                || n.is_multiple_of(73)\n                || n.is_multiple_of(79)\n                || n.is_multiple_of(83)\n                || n.is_multiple_of(89)\n                || n.is_multiple_of(97)\n                || n.is_multiple_of(101)\n                || n.is_multiple_of(103)\n                || n.is_multiple_of(107)\n                || n.is_multiple_of(109)\n                || n.is_multiple_of(113)\n                || n.is_multiple_of(127)\n                || n.is_multiple_of(131)\n                || n.is_multiple_of(137)\n                || n.is_multiple_of(139)\n                || n.is_multiple_of(149))\n        {\n            false\n        } else {\n            is_probable_prime_u32(n)\n        }\n    }\n}\n\nimpl IsPrime for u64 {\n    /// Tests whether a `u64` is prime.\n    ///\n    /// This implementation first does a few divisibility checks. Then, depending on the input, it\n    /// either runs a few strong probable prime tests or the Baillie–PSW test. This is enough to\n    /// prove primality for any integer less than $2^{64}$.\n    ///\n    /// If you want to generate many small primes, try using\n    /// [`u64::primes`][crate::num::factorization::traits::Primes::primes] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::IsPrime;\n    ///\n    /// assert_eq!(5u64.is_prime(), true);\n    /// assert_eq!(6u64.is_prime(), false);\n    /// assert_eq!(5509785649208481923u64.is_prime(), true);\n    /// ```\n    fn is_prime(&self) -> bool {\n        // Flint's \"BPSW\" (which Malachite's code is based on) checked against Feitsma and Galway's\n        // database [1, 2] up to 2^64 by Dana Jacobsen.\n        // - [1] http://www.janfeitsma.nl/math/psp2/database\n        // - [2] http://www.cecm.sfu.ca/Pseudoprimes/index-2-to-64.html\n        let n = *self;\n        if n < 11 {\n            n == 2 || n == 3 || n == 5 || n == 7\n        } else if n.even() || n.is_multiple_of(3) || n.is_multiple_of(5) || n.is_multiple_of(7) {\n            false\n        } else if n < 121 {\n            // 11*11\n            true\n        } else if n.is_multiple_of(11)\n            || n.is_multiple_of(13)\n            || n.is_multiple_of(17)\n            || n.is_multiple_of(19)\n            || n.is_multiple_of(23)\n            || n.is_multiple_of(29)\n            || n.is_multiple_of(31)\n            || n.is_multiple_of(37)\n            || n.is_multiple_of(41)\n            || n.is_multiple_of(43)\n            || n.is_multiple_of(47)\n            || n.is_multiple_of(53)\n        {\n            false\n        } else if n < 3481 {\n            // 59*59\n            true\n        } else if n > 1000000\n            && (n.is_multiple_of(59)\n                || n.is_multiple_of(61)\n                || n.is_multiple_of(67)\n                || n.is_multiple_of(71)\n                || n.is_multiple_of(73)\n                || n.is_multiple_of(79)\n                || n.is_multiple_of(83)\n                || n.is_multiple_of(89)\n                || n.is_multiple_of(97)\n                || n.is_multiple_of(101)\n                || n.is_multiple_of(103)\n                || n.is_multiple_of(107)\n                || n.is_multiple_of(109)\n                || n.is_multiple_of(113)\n                || n.is_multiple_of(127)\n                || n.is_multiple_of(131)\n                || n.is_multiple_of(137)\n                || n.is_multiple_of(139)\n                || n.is_multiple_of(149))\n        {\n            false\n        } else {\n            is_probable_prime_u64(n)\n        }\n    }\n}\n\nimpl IsPrime for usize {\n    /// Tests whether a `usize` is prime.\n    ///\n    /// This implementation first does a few divisibility checks. Then, depending on the input, it\n    /// either runs a few strong probable prime tests or the Baillie–PSW test. This is enough to\n    /// prove primality for any integer that fits in a `usize`.\n    ///\n    /// If you want to generate many small primes, try using\n    /// [`usize::primes`][crate::num::factorization::traits::Primes::primes] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::IsPrime;\n    ///\n    /// assert_eq!(5usize.is_prime(), true);\n    /// assert_eq!(6usize.is_prime(), false);\n    /// assert_eq!(4294967291usize.is_prime(), true);\n    /// ```\n    #[inline]\n    fn is_prime(&self) -> bool {\n        if USIZE_IS_U32 {\n            u32::wrapping_from(*self).is_prime()\n        } else {\n            u64::wrapping_from(*self).is_prime()\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/factorization/is_square.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedSqrt, FloorSqrt, Square};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::conversion::traits::{SplitInHalf, WrappingFrom};\nuse crate::num::factorization::traits::IsSquare;\n\nconst IS_SQUARE_MOD64: [bool; 64] = [\n    true, true, false, false, true, false, false, false, false, true, false, false, false, false,\n    false, false, true, true, false, false, false, false, false, false, false, true, false, false,\n    false, false, false, false, false, true, false, false, true, false, false, false, false, true,\n    false, false, false, false, false, false, false, true, false, false, false, false, false,\n    false, false, true, false, false, false, false, false, false,\n];\n\nconst IS_SQUARE_MOD65: [bool; 65] = [\n    true, true, false, false, true, false, false, false, false, true, true, false, false, false,\n    true, false, true, false, false, false, false, false, false, false, false, true, true, false,\n    false, true, true, false, false, false, false, true, true, false, false, true, true, false,\n    false, false, false, false, false, false, false, true, false, true, false, false, false, true,\n    true, false, false, false, false, true, false, false, true,\n];\n\nconst IS_SQUARE_MOD63: [bool; 63] = [\n    true, true, false, false, true, false, false, true, false, true, false, false, false, false,\n    true, false, true, false, true, false, false, false, true, false, false, true, false, false,\n    true, false, false, false, false, false, false, true, true, true, false, false, false, false,\n    false, true, false, false, true, false, false, true, false, false, false, false, false, false,\n    true, false, true, false, false, false, false,\n];\n\n// This is n_is_square when FLINT64 is false, from ulong_extras/is_square.c, FLINT 3.1.2.\nfn is_square_u64(x: u64) -> bool {\n    IS_SQUARE_MOD64[(x % 64) as usize]\n        && IS_SQUARE_MOD63[(x % 63) as usize]\n        && IS_SQUARE_MOD65[(x % 65) as usize]\n        && x.floor_sqrt().square() == x\n}\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl IsSquare for $t {\n            /// Determines whether an integer is a perfect square.\n            ///\n            /// $f(x) = (\\exists b \\in \\Z : b^2 = x)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_square#is_square).\n            #[inline]\n            fn is_square(&self) -> bool {\n                is_square_u64(u64::wrapping_from(*self))\n            }\n        }\n    };\n}\nimpl_unsigned!(u8);\nimpl_unsigned!(u16);\nimpl_unsigned!(u32);\nimpl_unsigned!(u64);\nimpl_unsigned!(usize);\n\n// From mpn/generic/mod_34lsub1.c\nconst B1: u64 = u64::WIDTH >> 2;\nconst B2: u64 = B1 * 2;\nconst B3: u64 = B1 * 3;\n\nconst M2: u64 = (1 << B2) - 1;\nconst M3: u64 = (1 << B3) - 1;\n\nconst fn low0(n: u64) -> u64 {\n    n & M3\n}\n\nconst fn high0(n: u64) -> u64 {\n    n >> B3\n}\n\nconst fn low1(n: u64) -> u64 {\n    (n & M2) << B1\n}\n\nconst fn high1(n: u64) -> u64 {\n    n >> B2\n}\n\n// This is mpn_mod_34lsub1 from mpn/generic/mod_34lsub1.c, GMP 6.3.0.\n//\n// Calculate a remainder from `limbs` divided by 2^(u64::WIDTH*3/4)-1. The remainder is not fully\n// reduced, it's any limb value congruent to `limbs` modulo that divisor.\n//\n// Check gen-psqr.c. mpn_mod_34lsub1 preferred over mpn_mod_1 (plus a PERFSQR_PP modulus) with 32\n// and 64 bit limb.\nconst fn mod_34lsub1(x_hi: u64, x_lo: u64) -> u64 {\n    low0(x_lo) + high0(x_lo) + low1(x_hi) + high1(x_hi)\n}\n\nconst MOD34_BITS: u64 = (u64::WIDTH >> 2) * 3;\nconst MOD34_MASK: u64 = (1 << MOD34_BITS) - 1;\n\nconst fn perfsqr_mod_34(x_hi: u64, x_lo: u64) -> u64 {\n    let r = mod_34lsub1(x_hi, x_lo);\n    (r & MOD34_MASK) + (r >> MOD34_BITS)\n}\n\n// This is PERFSQR_MOD_BITS from mpn/perfsqr.h, GMP 6.3.0. Either 49 on 64 bit limb or 25 on 32 bit\n// limb. 2^48-1 = 3^2 * 5 * 7 * 13 * 17 * 97 ... 2^24-1 = 3^2 * 5 * 7 * 13 * 17 ...\nconst SQR_MOD_BITS: u64 = MOD34_BITS + 1;\nconst SQR_MOD_MASK: u64 = (1 << SQR_MOD_BITS) - 1;\n\nconst fn perfsqr_mod_idx(r: u64, d: u64, inv: u64) -> u64 {\n    assert!(r <= SQR_MOD_MASK);\n    assert!(inv.wrapping_mul(d) & SQR_MOD_MASK == 1);\n    assert!(u64::MAX / d >= SQR_MOD_MASK);\n    let q = r.wrapping_mul(inv) & SQR_MOD_MASK;\n    assert!(r == (q.wrapping_mul(d) & SQR_MOD_MASK));\n    q.wrapping_mul(d) >> SQR_MOD_BITS\n}\n\n// Single limb. Check precomputed bitmasks to see if remainder is a quadratic residue\nfn perfsqr_mod_1(r: u64, d: u64, inv: u64, mask: u64) -> bool {\n    assert!(d <= u64::WIDTH);\n    let idx = perfsqr_mod_idx(r, d, inv);\n    if (mask >> idx) & 1 == 0 {\n        // non-square\n        return false;\n    }\n    true\n}\n\n// Double limb. Check precomputed bitmasks to see if remainder is a quadratic residue\nfn perfsqr_mod_2(r: u64, d: u64, inv: u64, mhi: u64, mlo: u64) -> bool {\n    assert!(d <= const { 2 * u64::WIDTH });\n    let mut idx = perfsqr_mod_idx(r, d, inv);\n    let m = if idx < u64::WIDTH { mlo } else { mhi };\n    idx %= u64::WIDTH;\n    if (m >> idx) & 1 == 0 {\n        // non-square\n        return false;\n    }\n    true\n}\n\n// This test identifies 97.81% as non-squares. Grand total sq_res_0x100 and PERFSQR_MOD_TEST, 99.62%\n// non-squares.\nfn perfsqr_mod_test(x: u128) -> bool {\n    let (x_hi, x_lo) = x.split_in_half();\n    let r = perfsqr_mod_34(x_hi, x_lo);\n    perfsqr_mod_2(r, 91, 0xfd2fd2fd2fd3, 0x2191240, 0x8850a206953820e1) // 69.23%\n        && perfsqr_mod_2(r, 85, 0xfcfcfcfcfcfd, 0x82158, 0x10b48c4b4206a105) // 68.24%\n        && perfsqr_mod_1(r, 9, 0xe38e38e38e39, 0x93)  // 55.56%\n        && perfsqr_mod_2(r, 97, 0xfd5c5f02a3a1, 0x1eb628b47, 0x6067981b8b451b5f) // 49.48%\n}\n\n// This is sq_res0x100 from mpn/perfsqr.h when generated for 64 bit limb, GMP 6.3.0. Non-zero bit\n// indicates a quadratic residue mod 0x100. This test identifies 82.81% as non-squares (212/256).\nconst SQR_MOD256: [u64; 4] =\n    [0x202021202030213, 0x202021202020213, 0x202021202030212, 0x202021202020212];\n\nimpl IsSquare for u128 {\n    /// Determines whether an integer is a perfect square.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z : b^2 = x)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::is_square#is_square).\n    #[inline]\n    fn is_square(&self) -> bool {\n        let idx = self % 0x100; // mod 256\n\n        // The first test excludes 212/256 (82.8%) of the perfect square candidates in O(1) time.\n        //\n        // This just checks the particular bit in the bitmask SQR_MOD256_U64 encoding where the\n        // input can be a perfect square mod 256.\n        if (SQR_MOD256[(idx >> u64::LOG_WIDTH) as usize]\n            >> (idx & const { u64::WIDTH_MASK as Self }))\n            & 1\n            == 0\n        {\n            return false;\n        }\n        // The second test uses mpn_mod_34lsub1 to detect non-squares according to their residues\n        // modulo small primes (or powers of primes). See mpn/perfsqr.h, GMP 6.3.0.\n        if !perfsqr_mod_test(*self) {\n            return false;\n        }\n        // For the third and last test, we finally compute the square root, to make sure we've\n        // really got a perfect square.\n        self.checked_sqrt().is_some()\n    }\n}\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl IsSquare for $t {\n            /// Determines whether an integer is a perfect square.\n            ///\n            /// $f(x) = (\\exists b \\in \\Z : b^2 = x)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::is_square#is_square).\n            #[inline]\n            fn is_square(&self) -> bool {\n                if *self < 0 {\n                    false\n                } else {\n                    self.unsigned_abs().is_square()\n                }\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-base/src/num/factorization/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// [`Factor`](traits::Factor), a trait for computing the prime factorization of a number.\npub mod factor;\n/// [`IsPower`](traits::IsPower) and [`ExpressAsPower`](traits::ExpressAsPower), traits for testing\n/// if a number is a perfect power and, if it is, expressing it as such.\n///\n/// # is_power\n/// ```\n/// use malachite_base::num::factorization::traits::IsPower;\n///\n/// assert!(0u8.is_power());\n/// assert!(1u16.is_power());\n/// assert!(36u32.is_power());\n/// assert!(64u32.is_power());\n/// assert!(100u64.is_power());\n/// assert!(1728u64.is_power());\n///\n/// assert!(0u8.is_power());\n/// assert!(1u16.is_power());\n/// assert!(!2u64.is_power());\n/// assert!(!3u64.is_power());\n/// ```\n///\n/// # express_as_power\n/// ```\n/// use malachite_base::num::factorization::traits::ExpressAsPower;\n///\n/// assert_eq!(0u8.express_as_power().unwrap(), (0, 2));\n/// assert_eq!(1u16.express_as_power().unwrap(), (1, 2));\n/// assert_eq!(36u32.express_as_power().unwrap(), (6, 2));\n/// assert_eq!(64u32.express_as_power().unwrap(), (2, 6));\n/// assert_eq!(100u64.express_as_power().unwrap(), (10, 2));\n/// assert_eq!(1728u64.express_as_power().unwrap(), (12, 3));\n///\n/// assert!(0u8.express_as_power().is_some());\n/// assert!(1u16.express_as_power().is_some());\n/// assert!(2u64.express_as_power().is_none());\n/// assert!(3u64.express_as_power().is_none());\n/// ```\npub mod is_power;\n/// [`IsPrime`](traits::IsPrime), a trait for testing a number for primality.\npub mod is_prime;\n/// [`IsSquare`](traits::IsSquare), a trait for testing if a number if a perfect square.\n///\n/// # is_square\n/// ```\n/// use malachite_base::num::factorization::traits::IsSquare;\n///\n/// assert!(0u8.is_square());\n/// assert!(1u16.is_square());\n/// assert!(4u32.is_square());\n/// assert!(256u64.is_square());\n///\n/// assert!(!2u8.is_square());\n/// assert!(!5u16.is_square());\n/// assert!(!8u32.is_square());\n/// assert!(!128u64.is_square());\n/// ```\npub mod is_square;\n/// An efficient prime sieve.\npub mod prime_sieve;\n/// [`Primes`](traits::Primes), a trait for generating prime numbers.\n///\n/// # primes_less_than\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::factorization::traits::Primes;\n///\n/// assert_eq!(u8::primes_less_than(&10).collect_vec(), &[2, 3, 5, 7]);\n/// assert_eq!(u16::primes_less_than(&11).collect_vec(), &[2, 3, 5, 7]);\n/// assert_eq!(\n///     u32::primes_less_than(&100).collect_vec(),\n///     &[\n///         2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n///         89, 97\n///     ]\n/// );\n/// ```\n///\n/// # primes_less_than_or_equal_to\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::factorization::traits::Primes;\n///\n/// assert_eq!(\n///     u8::primes_less_than_or_equal_to(&10).collect_vec(),\n///     &[2, 3, 5, 7]\n/// );\n/// assert_eq!(\n///     u16::primes_less_than_or_equal_to(&11).collect_vec(),\n///     &[2, 3, 5, 7, 11]\n/// );\n/// assert_eq!(\n///     u32::primes_less_than_or_equal_to(&100).collect_vec(),\n///     &[\n///         2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n///         89, 97\n///     ]\n/// );\n/// ```\n///\n/// # primes\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::factorization::traits::Primes;\n///\n/// assert_eq!(\n///     u8::primes().collect_vec(),\n///     &[\n///         2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n///         89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179,\n///         181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251\n///     ]\n/// );\n/// ```\npub mod primes;\n/// [`PrimitiveRootPrime`](traits::PrimitiveRootPrime), a trait for finding a primitive root modulo\n/// a prime number.\n///\n/// # primitive_root_prime\n/// ```\n/// use malachite_base::num::factorization::traits::PrimitiveRootPrime;\n///\n/// assert_eq!(5u32.primitive_root_prime(), 2);\n/// assert_eq!(191u32.primitive_root_prime(), 19);\n/// assert_eq!(4294967291u32.primitive_root_prime(), 2);\n/// ```\npub mod primitive_root_prime;\n/// Various traits for generating primes, primality testing, and factorization.\npub mod traits;\n"
  },
  {
    "path": "malachite-base/src/num/factorization/prime_sieve.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `primesieve.c` contributed to the GNU project by Marco Bodrato.\n//\n//      Copyright © 2010-2012, 2015, 2016 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::ExactFrom;\nuse crate::num::logic::traits::CountOnes;\n\npub const SIEVE_SEED_U32: u32 = 0x69128480;\n// 70bits pre-sieved mask for primes 5, 7\npub const SIEVE_MASK1_U32: u32 = 0x12148960;\npub const SIEVE_MASK2_U32: u32 = 0x44a120cc;\npub const SIEVE_MASKT_U32: u32 = 0x1a;\npub const SEED_LIMIT_U32: u64 = 120;\n\npub const SIEVE_SEED_U64: u64 = 0x3294C9E069128480;\n// 110bits pre-sieved mask for primes 5, 11\npub const SIEVE_MASK1_U64: u64 = 0x81214a1204892058;\npub const SIEVE_MASKT_U64: u64 = 0xc8130681244;\n// 182bits pre-sieved mask for primes 7, 13\npub const SIEVE_2MSK1_U64: u64 = 0x9402180c40230184;\npub const SIEVE_2MSK2_U64: u64 = 0x0285021088402120;\npub const SIEVE_2MSKT_U64: u64 = 0xa41210084421;\npub const SEED_LIMIT_U64: u64 = 210;\n\nconst C70M2U32W: u64 = 70 - (u32::WIDTH << 1);\nconst C70MU32W: u64 = 70 - u32::WIDTH;\nconst C2U32W: u64 = u32::WIDTH << 1;\nconst C3U32WM70: u64 = 3 * u32::WIDTH - 70;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bit_array.len()`.\n//\n// This is equivalent to `fill_bitpattern` from `primesieve.c`, GMP 6.2.1.\nfn fill_bitpattern_u32(bit_array: &mut [u32], mut offset: u64) -> u64 {\n    let mut len = bit_array.len();\n    let (mut mask, mut mask2, mut tail) = if offset == 0 {\n        (SIEVE_MASK1_U32, SIEVE_MASK2_U32, SIEVE_MASKT_U32)\n    } else {\n        offset %= 70;\n        if offset != 0 {\n            if offset <= u32::WIDTH {\n                let offset_comp = u32::WIDTH - offset;\n                let mut mask = SIEVE_MASK2_U32 << offset_comp;\n                let mut mask2 = SIEVE_MASKT_U32 << offset_comp;\n                if offset != u32::WIDTH {\n                    mask |= SIEVE_MASK1_U32 >> offset;\n                    mask2 |= SIEVE_MASK2_U32 >> offset;\n                }\n                let tail = if offset <= C70M2U32W {\n                    (SIEVE_MASK1_U32 << (C70M2U32W - offset)) | (SIEVE_MASKT_U32 >> offset)\n                } else {\n                    mask2 |= SIEVE_MASK1_U32 << (C70MU32W - offset);\n                    SIEVE_MASK1_U32 >> (offset - C70M2U32W)\n                };\n                (mask, mask2, tail)\n            } else if offset < C2U32W {\n                let mut mask = (SIEVE_MASK2_U32 >> (offset - u32::WIDTH))\n                    | (SIEVE_MASKT_U32 << (C2U32W - offset));\n                if offset <= C70MU32W {\n                    let mut tail = SIEVE_MASK2_U32 << (C70MU32W - offset);\n                    if offset != C70MU32W {\n                        tail |= SIEVE_MASK1_U32 >> (offset - C70M2U32W);\n                    }\n                    (\n                        mask,\n                        (SIEVE_MASKT_U32 >> (offset - u32::WIDTH))\n                            | (SIEVE_MASK1_U32 << (C70MU32W - offset)),\n                        tail,\n                    )\n                } else {\n                    let d70_offset = 70 - offset;\n                    let width_m_d70_offset = u32::WIDTH - d70_offset;\n                    mask |= SIEVE_MASK1_U32 << d70_offset;\n                    (\n                        mask,\n                        (SIEVE_MASK2_U32 << d70_offset) | (SIEVE_MASK1_U32 >> width_m_d70_offset),\n                        SIEVE_MASK2_U32 >> width_m_d70_offset,\n                    )\n                }\n            } else {\n                let d70_offset = 70 - offset;\n                let width_m_d70_offset = u32::WIDTH - d70_offset;\n                (\n                    (SIEVE_MASK1_U32 << d70_offset) | (SIEVE_MASKT_U32 >> (offset - C2U32W)),\n                    (SIEVE_MASK2_U32 << d70_offset) | (SIEVE_MASK1_U32 >> width_m_d70_offset),\n                    (SIEVE_MASKT_U32 << d70_offset) | (SIEVE_MASK2_U32 >> width_m_d70_offset),\n                )\n            }\n        } else {\n            (SIEVE_MASK1_U32, SIEVE_MASK2_U32, SIEVE_MASKT_U32)\n        }\n    };\n    for xs in bit_array.chunks_mut(2) {\n        xs[0] = mask;\n        len -= 1;\n        if len == 0 {\n            break;\n        }\n        xs[1] = mask2;\n        let temp = mask2 >> C3U32WM70;\n        mask2 = (mask2 << C70M2U32W) | (mask >> C3U32WM70);\n        mask = (mask << C70M2U32W) | tail;\n        tail = temp;\n        len -= 1;\n        if len == 0 {\n            break;\n        }\n    }\n    2\n}\n\nconst C110MU64W: u64 = 110 - u64::WIDTH;\nconst C2U64WM110: u64 = (u64::WIDTH << 1) - 110;\nconst C182MU64W: u64 = 182 - u64::WIDTH;\nconst C182M2U64W: u64 = 182 - (u64::WIDTH << 1);\nconst C3U64WM182: u64 = 3 * u64::WIDTH - 182;\nconst C2U64W: u64 = u64::WIDTH << 1;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bit_array.len()`.\n//\n// This is equivalent to `fill_bitpattern` from `primesieve.c`, GMP 6.2.1.\nfn fill_bitpattern_u64(bit_array: &mut [u64], mut offset: u64) -> u64 {\n    let mut len = bit_array.len();\n    let ((mut m11, mut m12), (mut m21, mut m22, mut m23)) = if offset == 0 {\n        (\n            (SIEVE_MASK1_U64, SIEVE_MASKT_U64),\n            (SIEVE_2MSK1_U64, SIEVE_2MSK2_U64, SIEVE_2MSKT_U64),\n        )\n    } else {\n        // correctly handle offset == 0...\n        let mut m21 = offset % 110;\n        let (m11, m12) = if m21 != 0 {\n            if m21 < u64::WIDTH {\n                let mut m11 = (SIEVE_MASK1_U64 >> m21) | (SIEVE_MASKT_U64 << (u64::WIDTH - m21));\n                if m21 <= C110MU64W {\n                    (\n                        m11,\n                        (SIEVE_MASK1_U64 << (C110MU64W - m21)) | (SIEVE_MASKT_U64 >> m21),\n                    )\n                } else {\n                    m11 |= SIEVE_MASK1_U64 << (110 - m21);\n                    (m11, SIEVE_MASK1_U64 >> (m21 - C110MU64W))\n                }\n            } else {\n                (\n                    (SIEVE_MASK1_U64 << (110 - m21)) | (SIEVE_MASKT_U64 >> (m21 - u64::WIDTH)),\n                    (SIEVE_MASKT_U64 << (110 - m21)) | (SIEVE_MASK1_U64 >> (m21 - C110MU64W)),\n                )\n            }\n        } else {\n            (SIEVE_MASK1_U64, SIEVE_MASKT_U64)\n        };\n        ((m11, m12), {\n            offset %= 182;\n            if offset != 0 {\n                if offset <= u64::WIDTH {\n                    let mut m21 = SIEVE_2MSK2_U64 << (u64::WIDTH - offset);\n                    let mut m22 = SIEVE_2MSKT_U64 << (u64::WIDTH - offset);\n                    if offset != u64::WIDTH {\n                        m21 |= SIEVE_2MSK1_U64 >> offset;\n                        m22 |= SIEVE_2MSK2_U64 >> offset;\n                    }\n                    if offset <= C182M2U64W {\n                        (\n                            m21,\n                            m22,\n                            (SIEVE_2MSK1_U64 << (C182M2U64W - offset))\n                                | (SIEVE_2MSKT_U64 >> offset),\n                        )\n                    } else {\n                        m22 |= SIEVE_2MSK1_U64 << (C182MU64W - offset);\n                        (m21, m22, SIEVE_2MSK1_U64 >> (offset - C182M2U64W))\n                    }\n                } else if offset < C2U64W {\n                    m21 = (SIEVE_2MSK2_U64 >> (offset - u64::WIDTH))\n                        | (SIEVE_2MSKT_U64 << (C2U64W - offset));\n                    if offset <= C182MU64W {\n                        let mut m23 = SIEVE_2MSK2_U64 << (C182MU64W - offset);\n                        if offset != C182MU64W {\n                            m23 |= SIEVE_2MSK1_U64 >> (offset - C182M2U64W);\n                        }\n                        (\n                            m21,\n                            (SIEVE_2MSKT_U64 >> (offset - u64::WIDTH))\n                                | (SIEVE_2MSK1_U64 << (C182MU64W - offset)),\n                            m23,\n                        )\n                    } else {\n                        m21 |= SIEVE_2MSK1_U64 << (182 - offset);\n                        (\n                            m21,\n                            (SIEVE_2MSK2_U64 << (182 - offset))\n                                | (SIEVE_2MSK1_U64 >> (offset - C182MU64W)),\n                            SIEVE_2MSK2_U64 >> (offset - C182MU64W),\n                        )\n                    }\n                } else {\n                    (\n                        (SIEVE_2MSK1_U64 << (182 - offset))\n                            | (SIEVE_2MSKT_U64 >> (offset - C2U64W)),\n                        (SIEVE_2MSK2_U64 << (182 - offset))\n                            | (SIEVE_2MSK1_U64 >> (offset - C182MU64W)),\n                        (SIEVE_2MSKT_U64 << (182 - offset))\n                            | (SIEVE_2MSK2_U64 >> (offset - C182MU64W)),\n                    )\n                }\n            } else {\n                (SIEVE_2MSK1_U64, SIEVE_2MSK2_U64, SIEVE_2MSKT_U64)\n            }\n        })\n    };\n    for xs in bit_array.chunks_mut(2) {\n        xs[0] = m11 | m21;\n        len -= 1;\n        if len == 0 {\n            break;\n        }\n        let temp = m11 >> C2U64WM110;\n        m11 = (m11 << C110MU64W) | m12;\n        m12 = temp;\n        xs[1] = m11 | m22;\n        let temp = m11 >> C2U64WM110;\n        m11 = (m11 << C110MU64W) | m12;\n        m12 = temp;\n        let temp = m22 >> C3U64WM182;\n        m22 = (m22 << C182M2U64W) | (m21 >> C3U64WM182);\n        m21 = (m21 << C182M2U64W) | m23;\n        m23 = temp;\n        len -= 1;\n        if len == 0 {\n            break;\n        }\n    }\n    4\n}\n\n#[doc(hidden)]\n// This is equivalent to `n_to_bit` from `primesieve.c`, GMP 6.2.1.\npub const fn n_to_bit(n: u64) -> u64 {\n    ((n - 5) | 1) / 3\n}\n\n#[doc(hidden)]\n// This is equivalent to `id_to_n` from `primesieve.c`, GMP 6.2.1.\npub const fn id_to_n(id: u64) -> u64 {\n    id * 3 + 1 + (id & 1)\n}\n\n// # Worst-case complexity\n// $T(n) = O(n\\log\\log n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bit_array.len()`.\n//\n// This is equivalent to `first_block_primesieve` from `primesieve.c`, GMP 6.2.1.\nfn first_block_primesieve<T: PrimitiveUnsigned, F: Fn(&mut [T], u64) -> u64>(\n    bit_array: &mut [T],\n    n: u64,\n    fill_bitpattern: F,\n    sieve_seed: T,\n    seed_limit: u64,\n) {\n    assert!(n > 4);\n    let bits = n_to_bit(n);\n    let limbs = usize::exact_from(bits >> T::LOG_WIDTH);\n    let mut i = if limbs == 0 {\n        0\n    } else {\n        fill_bitpattern(&mut bit_array[1..=limbs], 0)\n    };\n    bit_array[0] = sieve_seed;\n    if (bits + 1) & T::WIDTH_MASK != 0 {\n        bit_array[limbs] |= T::MAX << ((bits + 1) & T::WIDTH_MASK);\n    }\n    if n > seed_limit {\n        assert!(i < T::WIDTH);\n        if n_to_bit(seed_limit + 1) < T::WIDTH {\n            i = 0;\n        }\n        let mut mask = T::power_of_2(i);\n        let mut index = 0;\n        for i in i + 1.. {\n            if bit_array[index] & mask == T::ZERO {\n                let mut step = id_to_n(i);\n                // lindex = n_to_bit(id_to_n(i) * id_to_n(i));\n                let mut lindex = i * (step + 1) - 1 + ((i & 1).wrapping_neg() & (i + 1));\n                // lindex = i * (step + 1 + (i & 1)) - 1 + (i & 1);\n                if lindex > bits {\n                    break;\n                }\n                step <<= 1;\n                let maskrot = step & T::WIDTH_MASK;\n                let mut lmask = T::power_of_2(lindex & T::WIDTH_MASK);\n                while lindex <= bits {\n                    bit_array[usize::exact_from(lindex >> T::LOG_WIDTH)] |= lmask;\n                    lmask.rotate_left_assign(maskrot);\n                    lindex += step;\n                }\n                // lindex = n_to_bit(id_to_n(i) * bit_to_n(i));\n                lindex = i * (i * 3 + 6) + (i & 1);\n                lmask = T::power_of_2(lindex & T::WIDTH_MASK);\n                while lindex <= bits {\n                    bit_array[usize::exact_from(lindex >> T::LOG_WIDTH)] |= lmask;\n                    lmask.rotate_left_assign(maskrot);\n                    lindex += step;\n                }\n            }\n            mask <<= 1;\n            if mask == T::ZERO {\n                mask = T::ONE;\n                index += 1;\n            }\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n\\log\\log n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bit_array.len()`.\n//\n// This is equivalent to `block_resieve` from `primesieve.c`, GMP 6.2.1.\nfn block_resieve<T: PrimitiveUnsigned, F: Fn(&mut [T], u64) -> u64>(\n    bit_array: &mut [T],\n    offset: u64,\n    sieve: &[T],\n    fill_bitpattern: &F,\n) {\n    let limbs = bit_array.len();\n    let off = offset;\n    assert_ne!(limbs, 0);\n    assert!(offset >= T::WIDTH);\n    let bits = u64::exact_from(limbs << T::LOG_WIDTH) - 1;\n    let i = fill_bitpattern(&mut bit_array[..limbs], offset - T::WIDTH);\n    assert!(i < T::WIDTH);\n    let mut mask = T::power_of_2(i);\n    let mut index = 0;\n    for i in i + 1.. {\n        if sieve[index] & mask == T::ZERO {\n            let mut step = id_to_n(i);\n            // lindex = n_to_bit(id_to_n(i)*id_to_n(i));\n            let mut lindex = i * (step + 1) - 1 + ((i & 1).wrapping_neg() & (i + 1));\n            // lindex = i*(step+1+(i&1))-1+(i&1);\n            if lindex > bits + off {\n                break;\n            }\n            step <<= 1;\n            let maskrot = step & T::WIDTH_MASK;\n            if lindex < off {\n                lindex += step * ((off - lindex - 1) / step + 1);\n            }\n            lindex -= off;\n            let mut lmask = T::power_of_2(lindex & T::WIDTH_MASK);\n            while lindex <= bits {\n                bit_array[usize::exact_from(lindex >> T::LOG_WIDTH)] |= lmask;\n                lmask.rotate_left_assign(maskrot);\n                lindex += step;\n            }\n            // lindex = n_to_bit(id_to_n(i)*bit_to_n(i));\n            lindex = i * (i * 3 + 6) + (i & 1);\n            if lindex < off {\n                lindex += step * ((off - lindex - 1) / step + 1);\n            }\n            lindex -= off;\n            lmask = T::power_of_2(lindex & T::WIDTH_MASK);\n            while lindex <= bits {\n                bit_array[usize::exact_from(lindex >> T::LOG_WIDTH)] |= lmask;\n                lmask.rotate_left_assign(maskrot);\n                lindex += step;\n            }\n        }\n        mask <<= 1;\n        if mask == T::ZERO {\n            mask = T::ONE;\n            index += 1;\n        }\n    }\n}\n\n#[doc(hidden)]\n#[inline]\n// This is equivalent to `primesieve_size` from `primesieve.c`, GMP 6.2.1.\npub fn limbs_prime_sieve_size<T: PrimitiveUnsigned>(n: u64) -> usize {\n    assert!(n >= 5);\n    usize::exact_from((n_to_bit(n) >> T::LOG_WIDTH) + 1)\n}\n\nconst BLOCK_SIZE: usize = 2048;\n\npub_test! {limbs_count_ones<T: PrimitiveUnsigned>(xs: &[T]) -> u64 {\n    xs.iter().map(|&x| CountOnes::count_ones(x)).sum()\n}}\n\n// Fills bit_array with the characteristic function of composite numbers up to the parameter n. I.e.\n// a bit set to \"1\" represent a composite, a \"0\" represent a prime.\n//\n// The primesieve_size(n) limbs pointed to by bit_array are overwritten. The returned value counts\n// prime integers in the interval [4, n]. Note that n > 4.\n//\n// Even numbers and multiples of 3 are excluded \"a priori\", only numbers equivalent to +/- 1 mod 6\n// have their bit in the array.\n//\n// Once sieved, if the bit b is ZERO it represent a prime, the represented prime is bit_to_n(b), if\n// the LSbit is bit 0, or id_to_n(b), if you call \"1\" the first bit.\n//\n// # Worst-case complexity\n// $T(n) = O(n\\log\\log n)$\n//\n// $M(n) = O(1)$\nfn limbs_prime_sieve_generic<T: PrimitiveUnsigned, F: Fn(&mut [T], u64) -> u64>(\n    bit_array: &mut [T],\n    n: u64,\n    fill_bitpattern: F,\n    sieve_seed: T,\n    seed_limit: u64,\n) -> u64 {\n    assert!(n > 4);\n    let bits = n_to_bit(n);\n    let size = usize::exact_from((bits >> T::LOG_WIDTH) + 1);\n    if size > BLOCK_SIZE << 1 {\n        let mut off = BLOCK_SIZE + (size % BLOCK_SIZE);\n        first_block_primesieve(\n            bit_array,\n            id_to_n(u64::exact_from(off) << T::LOG_WIDTH),\n            &fill_bitpattern,\n            sieve_seed,\n            seed_limit,\n        );\n        let (sieve, bit_array) = bit_array.split_at_mut(off);\n        for xs in bit_array.chunks_mut(BLOCK_SIZE) {\n            block_resieve(\n                xs,\n                u64::exact_from(off) << T::LOG_WIDTH,\n                sieve,\n                &fill_bitpattern,\n            );\n            off += BLOCK_SIZE;\n            if off >= size {\n                break;\n            }\n        }\n    } else {\n        first_block_primesieve(bit_array, n, &fill_bitpattern, sieve_seed, seed_limit);\n    }\n    if (bits + 1) & T::WIDTH_MASK != 0 {\n        bit_array[size - 1] |= T::MAX << ((bits + 1) & T::WIDTH_MASK);\n    }\n    (u64::exact_from(size) << T::LOG_WIDTH) - limbs_count_ones(&bit_array[..size])\n}\n\n#[doc(hidden)]\n// This is equivalent to `gmp_primesieve` from `primesieve.c`, GMP 6.2.1.\n#[inline]\npub fn limbs_prime_sieve_u32(bit_array: &mut [u32], n: u64) -> u64 {\n    limbs_prime_sieve_generic(\n        bit_array,\n        n,\n        fill_bitpattern_u32,\n        SIEVE_SEED_U32,\n        SEED_LIMIT_U32,\n    )\n}\n\n#[doc(hidden)]\n// This is equivalent to `gmp_primesieve` from `primesieve.c`, GMP 6.2.1.\n#[inline]\npub fn limbs_prime_sieve_u64(bit_array: &mut [u64], n: u64) -> u64 {\n    limbs_prime_sieve_generic(\n        bit_array,\n        n,\n        fill_bitpattern_u64,\n        SIEVE_SEED_U64,\n        SEED_LIMIT_U64,\n    )\n}\n"
  },
  {
    "path": "malachite-base/src/num/factorization/primes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library and the FLINT Library.\n//\n// Prime sieve code contributed to the GNU project by Marco Bodrato.\n//\n//      Copyright © 2009 Tom Boothby\n//\n//      Copyright © 2009 William Hart\n//\n//      Copyright © 2010 Fredrik Johansson\n//\n//      Copyright © 2010–2012, 2015, 2016 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::factorization::prime_sieve::n_to_bit;\nuse crate::num::factorization::prime_sieve::{\n    id_to_n, limbs_prime_sieve_size, limbs_prime_sieve_u64,\n};\nuse crate::num::factorization::traits::Primes;\nuse crate::num::logic::traits::TrailingZeros;\nuse alloc::vec::Vec;\nuse core::marker::PhantomData;\n\nconst NUM_SMALL_PRIMES: usize = 172;\n\n// This is flint_primes_small from ulong_extras/compute_primes.c, FLINT 3.1.2.\npub(crate) const SMALL_PRIMES: [u16; NUM_SMALL_PRIMES] = [\n    2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,\n    101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,\n    197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307,\n    311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421,\n    431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547,\n    557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659,\n    661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797,\n    809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929,\n    937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021,\n];\n\n// This differs from the identically-named function in malachite-nz; this one returns None if there\n// are no more false bits.\nfn limbs_index_of_next_false_bit<T: PrimitiveUnsigned>(xs: &[T], start: u64) -> Option<u64> {\n    let starting_index = usize::exact_from(start >> T::LOG_WIDTH);\n    if starting_index >= xs.len() {\n        return None;\n    }\n    if let Some(result) = xs[starting_index].index_of_next_false_bit(start & T::WIDTH_MASK)\n        && result != T::WIDTH\n    {\n        return Some((u64::wrapping_from(starting_index) << T::LOG_WIDTH) + result);\n    }\n    if starting_index == xs.len() - 1 {\n        return None;\n    }\n    let false_index = starting_index\n        + 1\n        + xs[starting_index + 1..]\n            .iter()\n            .take_while(|&&y| y == T::MAX)\n            .count();\n    if false_index == xs.len() {\n        None\n    } else {\n        Some(\n            (u64::exact_from(false_index) << T::LOG_WIDTH)\n                + TrailingZeros::trailing_zeros(!xs[false_index]),\n        )\n    }\n}\n\n/// An iterator over that generates all primes less than a given value.\n///\n/// This `struct` is created by [`Primes::primes_less_than`] and\n/// [`Primes::primes_less_than_or_equal_to`]; see their documentation for more.\n#[derive(Clone, Debug)]\npub struct PrimesLessThanIterator<T: PrimitiveUnsigned> {\n    small: bool,\n    i: u64,\n    limit: T,\n    sieve: Vec<u64>,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> PrimesLessThanIterator<T> {\n    fn new(n: T) -> Self {\n        let limit = n;\n        let n: u64 = n.saturating_into();\n        let mut sieve;\n        // 1031 is the smallest prime greater than 2^10.\n        if n < 1031 {\n            sieve = Vec::with_capacity(0);\n        } else {\n            sieve = alloc::vec![0; limbs_prime_sieve_size::<u64>(n)];\n            limbs_prime_sieve_u64(&mut sieve, n);\n        }\n        Self {\n            small: true,\n            i: 0,\n            limit,\n            sieve,\n            phantom: PhantomData,\n        }\n    }\n\n    /// Moves the iterator to just after a given value, returning whether the iterator will return\n    /// any more values after that point. If `false` is returned, calling `next` will return `None`;\n    /// if `true` is returned, calling `next` will return smallest prime greater than $n$.\n    ///\n    /// # Worst-case complexity (amortized)\n    /// $T(n) = O(n\\log \\log n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::Primes;\n    ///\n    /// let mut primes = u32::primes_less_than(&10_000);\n    /// assert_eq!(primes.jump_after(1000), true);\n    /// assert_eq!(primes.next(), Some(1009));\n    ///\n    /// assert_eq!(primes.jump_after(10_000), false);\n    /// assert_eq!(primes.next(), None);\n    /// ```\n    pub fn jump_after(&mut self, n: T) -> bool {\n        // 1021 is the greatest prime smaller than 2^10.\n        if n < T::saturating_from(1021) {\n            self.small = true;\n            self.i = u64::wrapping_from(match SMALL_PRIMES.binary_search(&n.wrapping_into()) {\n                Ok(i) => i + 1,\n                Err(i) => i,\n            });\n            if self.i == NUM_SMALL_PRIMES as u64 {\n                if self.sieve.is_empty() {\n                    false\n                } else {\n                    self.small = false;\n                    const NEXT_INDEX: u64 = n_to_bit(1031) - 1;\n                    self.i = NEXT_INDEX;\n                    let next_i =\n                        if let Some(next_i) = limbs_index_of_next_false_bit(&self.sieve, self.i) {\n                            next_i\n                        } else {\n                            return false;\n                        };\n                    let next_p = T::exact_from(id_to_n(next_i + 1));\n                    next_p <= self.limit\n                }\n            } else if let Ok(next_p) = T::try_from(SMALL_PRIMES[self.i as usize]) {\n                next_p <= self.limit\n            } else {\n                false\n            }\n        } else {\n            self.small = false;\n            self.i = if let Ok(n) = n.try_into() {\n                n_to_bit(n) + 1\n            } else {\n                return false;\n            };\n            let next_i = if let Some(next_i) = limbs_index_of_next_false_bit(&self.sieve, self.i) {\n                next_i\n            } else {\n                return false;\n            };\n            let next_p = T::exact_from(id_to_n(next_i + 1));\n            next_p <= self.limit\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for PrimesLessThanIterator<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.small {\n            let p = if let Ok(p) = T::try_from(SMALL_PRIMES[self.i as usize]) {\n                p\n            } else {\n                return None;\n            };\n            if p > self.limit {\n                return None;\n            }\n            self.i += 1;\n            if self.i == NUM_SMALL_PRIMES as u64 {\n                self.small = false;\n                const NEXT_INDEX: u64 = n_to_bit(1031) - 1;\n                self.i = NEXT_INDEX;\n            }\n            Some(p)\n        } else {\n            self.i = limbs_index_of_next_false_bit(&self.sieve, self.i)? + 1;\n            let p = T::exact_from(id_to_n(self.i));\n            if p > self.limit { None } else { Some(p) }\n        }\n    }\n}\n\n/// An iterator over that generates all primes.\n///\n/// This `struct` is created by [`Primes::primes`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct PrimesIterator<T: PrimitiveUnsigned> {\n    limit: T,\n    xs: PrimesLessThanIterator<T>,\n}\n\nimpl<T: PrimitiveUnsigned> PrimesIterator<T> {\n    fn new() -> Self {\n        let limit = T::saturating_from(1024u16);\n        Self {\n            limit,\n            xs: PrimesLessThanIterator::new(limit),\n        }\n    }\n\n    /// Moves the iterator to just after a given value, returning whether the iterator will return\n    /// any more values after that point. If `false` is returned, calling `next` will return `None`\n    /// (which only happens if $n$ is very close to the maximum value of `T`); if `true` is\n    /// returned, calling `next` will return smallest prime greater than $n$.\n    ///\n    /// # Worst-case complexity (amortized)\n    /// $T(n) = O(n\\log \\log n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::Primes;\n    ///\n    /// let mut primes = u16::primes();\n    /// assert_eq!(primes.jump_after(1000), true);\n    /// assert_eq!(primes.next(), Some(1009));\n    ///\n    /// assert_eq!(primes.jump_after(u16::MAX), false);\n    /// assert_eq!(primes.next(), None);\n    /// ```\n    pub fn jump_after(&mut self, n: T) -> bool {\n        loop {\n            if self.xs.jump_after(n) {\n                return true;\n            } else if self.limit == T::MAX {\n                return false;\n            }\n            self.limit.saturating_mul_assign(T::TWO);\n            while self.limit != T::MAX && self.limit <= n {\n                self.limit.saturating_mul_assign(T::TWO);\n            }\n            let i = self.xs.i;\n            self.xs = T::primes_less_than_or_equal_to(&self.limit);\n            self.xs.i = i;\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for PrimesIterator<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        loop {\n            let p = self.xs.next();\n            if p.is_some() {\n                return p;\n            } else if self.limit == T::MAX {\n                return None;\n            }\n            self.limit.saturating_mul_assign(T::TWO);\n            let i = if self.xs.small {\n                n_to_bit(1031)\n            } else {\n                self.xs.i\n            };\n            self.xs = T::primes_less_than_or_equal_to(&self.limit);\n            self.xs.small = false;\n            self.xs.i = i;\n        }\n    }\n}\n\nmacro_rules! impl_primes {\n    ($t:ident) => {\n        impl Primes for $t {\n            type I = PrimesIterator<$t>;\n            type LI = PrimesLessThanIterator<$t>;\n\n            /// Returns an iterator that generates all primes less than a given value.\n            ///\n            /// The iterator produced by `primes_less_than(n)` generates the same primes as the\n            /// iterator produced by `primes().take_while(|&p| p < n)`, but the latter would be\n            /// slower because it doesn't know in advance how large its prime sieve should be, and\n            /// might have to create larger and larger prime sieves.\n            ///\n            /// # Worst-case complexity (amortized)\n            /// $T(i) = O(\\log \\log i)$\n            ///\n            /// $M(i) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n            ///\n            /// # Examples\n            /// See [here](super::primes#primes_less_than).\n            #[inline]\n            fn primes_less_than(n: &$t) -> PrimesLessThanIterator<$t> {\n                PrimesLessThanIterator::new(n.saturating_sub(1))\n            }\n\n            /// Returns an iterator that generates all primes less than or equal to a given value.\n            ///\n            /// The iterator produced by `primes_less_than_or_equal_to(n)` generates the same primes\n            /// as the iterator produced by `primes().take_while(|&p| p <= n)`, but the latter would\n            /// be slower because it doesn't know in advance how large its prime sieve should be,\n            /// and might have to create larger and larger prime sieves.\n            ///\n            /// # Worst-case complexity (amortized)\n            /// $T(i) = O(\\log \\log i)$\n            ///\n            /// $M(i) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n            ///\n            /// # Examples\n            /// See [here](super::primes#primes_less_than_or_equal_to).\n            #[inline]\n            fn primes_less_than_or_equal_to(&n: &$t) -> PrimesLessThanIterator<$t> {\n                PrimesLessThanIterator::new(n)\n            }\n\n            /// Returns all primes that fit into the specified type.\n            ///\n            /// The iterator produced by `primes(n)` generates the same primes as the iterator\n            /// produced by `primes_less_than_or_equal_to(T::MAX)`. If you really need to generate\n            /// _every_ prime, and `T` is `u32` or smaller, then you should use the latter, as it\n            /// will allocate all the needed memory at once. If `T` is `u64` or larger, or if you\n            /// probably don't need every prime, then `primes()` will be faster as it won't allocate\n            /// too much memory right away.\n            ///\n            /// # Worst-case complexity (amortized)\n            /// $T(i) = O(\\log \\log i)$\n            ///\n            /// $M(i) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n            ///\n            /// # Examples\n            /// See [here](super::primes#primes).\n            #[inline]\n            fn primes() -> PrimesIterator<$t> {\n                PrimesIterator::new()\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_primes);\n\n/// An iterator that generates `bool`s up to a certain limit, where the $n$th `bool` is `true` if\n/// and only if $n$ is prime. See [`prime_indicator_sequence_less_than`] for more information.\n#[derive(Clone, Debug)]\npub struct PrimeIndicatorSequenceLessThan {\n    primes: PrimesLessThanIterator<u64>,\n    limit: u64,\n    i: u64,\n    next_prime: u64,\n}\n\nimpl Iterator for PrimeIndicatorSequenceLessThan {\n    type Item = bool;\n\n    fn next(&mut self) -> Option<bool> {\n        if self.i >= self.limit {\n            None\n        } else if self.i == self.next_prime {\n            self.i += 1;\n            self.next_prime = self.primes.next().unwrap_or(0);\n            Some(true)\n        } else {\n            self.i += 1;\n            Some(false)\n        }\n    }\n}\n\n/// Returns an iterator that generates an sequence of `bool`s, where the $n$th `bool` is `true` if\n/// and only if $n$ is prime. The first `bool` generated has index 1, and the last one has index\n/// $\\max(0,\\ell-1)$, where $\\ell$ is `limit`.\n///\n/// The output length is $max(0,\\ell-1)$, where $\\ell$ is `limit`.\n///\n/// # Worst-case complexity (amortized)\n/// $T(i) = O(\\log \\log \\log i)$\n///\n/// $M(i) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::factorization::primes::prime_indicator_sequence_less_than;\n///\n/// let s: String = prime_indicator_sequence_less_than(101)\n///     .map(|b| if b { '1' } else { '0' })\n///     .collect();\n/// assert_eq!(\n///     s,\n///     \"01101010001010001010001000001010000010001010001000001000001010000010001010000010001000001\\\n///     00000001000\"\n/// )\n/// ```\npub fn prime_indicator_sequence_less_than(limit: u64) -> PrimeIndicatorSequenceLessThan {\n    let mut primes = u64::primes_less_than(&limit);\n    primes.next(); // skip 2\n    PrimeIndicatorSequenceLessThan {\n        primes,\n        limit,\n        i: 1,\n        next_prime: 2,\n    }\n}\n\n/// Returns an iterator that generates an sequence of `bool`s, where the $n$th `bool` is `true` if\n/// and only if $n$ is prime. The first `bool` generated has index 1, and the last one has index\n/// `limit`.\n///\n/// The output length is `limit`.\n///\n/// # Worst-case complexity (amortized)\n/// $T(i) = O(\\log \\log \\log i)$\n///\n/// $M(i) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::factorization::primes::prime_indicator_sequence_less_than_or_equal_to;\n///\n/// let s: String = prime_indicator_sequence_less_than_or_equal_to(100)\n///     .map(|b| if b { '1' } else { '0' })\n///     .collect();\n/// assert_eq!(\n///     s,\n///     \"01101010001010001010001000001010000010001010001000001000001010000010001010000010001000001\\\n///     00000001000\"\n/// )\n/// ```\npub fn prime_indicator_sequence_less_than_or_equal_to(\n    limit: u64,\n) -> PrimeIndicatorSequenceLessThan {\n    prime_indicator_sequence_less_than(limit.checked_add(1).unwrap())\n}\n\n/// An iterator that generates `bool`s, where the $n$th `bool` is `true` if and only if $n$ is\n/// prime. See [`prime_indicator_sequence`] for more information.\n#[derive(Clone, Debug)]\npub struct PrimeIndicatorSequence {\n    primes: PrimesIterator<u64>,\n    i: u64,\n    next_prime: u64,\n}\n\nimpl Iterator for PrimeIndicatorSequence {\n    type Item = bool;\n\n    fn next(&mut self) -> Option<bool> {\n        Some(if self.i == self.next_prime {\n            self.i += 1;\n            self.next_prime = self.primes.next().unwrap();\n            true\n        } else {\n            self.i += 1;\n            false\n        })\n    }\n}\n\n/// Returns an iterator that generates an infinite sequence of `bool`s, where the $n$th `bool` is\n/// `true` if and only if $n$ is prime. The first `bool` generated has index 1.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity (amortized)\n/// $T(i) = O(\\log \\log \\log i)$\n///\n/// $M(i) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::factorization::primes::prime_indicator_sequence;\n///\n/// let s: String = prime_indicator_sequence()\n///     .take(100)\n///     .map(|b| if b { '1' } else { '0' })\n///     .collect();\n/// assert_eq!(\n///     s,\n///     \"01101010001010001010001000001010000010001010001000001000001010000010001010000010001000001\\\n///     00000001000\"\n/// )\n/// ```\npub fn prime_indicator_sequence() -> PrimeIndicatorSequence {\n    let mut primes = u64::primes();\n    primes.next(); // skip 2\n    PrimeIndicatorSequence {\n        primes,\n        i: 1,\n        next_prime: 2,\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/factorization/primitive_root_prime.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2013 Mike Hansen\n//\n//      Copyright © 2024 Vincent Neiger\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::exhaustive::primitive_int_increasing_range;\nuse crate::num::factorization::factor::{\n    MAX_FACTORS_IN_U8, MAX_FACTORS_IN_U16, MAX_FACTORS_IN_U32, MAX_FACTORS_IN_U64,\n    MAX_FACTORS_IN_USIZE,\n};\nuse crate::num::factorization::traits::{Factor, IsPrime, PrimitiveRootPrime};\n\n// This is n_primitive_root_prime from ulong_extras/primitive_root_prime.c, FLINT 3.3.0-dev.\nfn primitive_root_prime<T: PrimitiveUnsigned + IsPrime + Factor, const N: usize>(p: T) -> T\nwhere\n    <T as Factor>::FACTORS: Clone + IntoIterator<Item = (T, u8)>,\n{\n    assert!(p > T::ONE);\n    if p == T::TWO {\n        return T::ONE;\n    }\n    // compute (p - 1) / factors once and for all\n    let mut exponents = [T::ZERO; N];\n    let pm1 = p - T::ONE;\n    for (e, (pf, _)) in exponents.iter_mut().zip((p - T::ONE).factor().into_iter()) {\n        *e = pm1 / pf;\n    }\n    // try 2, 3, ..., p - 1\n    let data = T::precompute_mod_pow_data(&p);\n    'outer: for a in primitive_int_increasing_range(T::TWO, p) {\n        for &exponent in &exponents {\n            if exponent == T::ZERO {\n                break;\n            }\n            if a.mod_pow_precomputed(exponent.wrapping_into(), p, &data) == T::ONE {\n                continue 'outer;\n            }\n        }\n        return a;\n    }\n    // If we haven't found a primitive root, it must be because p is not prime. Confirm this by\n    // failing an assertion, which will produce an appropriate error message.\n    assert!(p.is_prime());\n    unreachable!()\n}\n\nmacro_rules! impl_primitive_root_prime {\n    ($t:ident, $n:ident) => {\n        impl PrimitiveRootPrime for $t {\n            type Output = $t;\n\n            /// Given a prime number, computes a primitive root modulo that number. In other words,\n            /// given a prime $p$, finds a generator of the cyclic group\n            /// $(\\mathbb{Z}/p\\mathbb{Z})^\\times$.\n            ///\n            /// If the input is not prime, this function's behavior is unspecified. Since primality\n            /// checking can be expensive, the input is not tested for primality.\n            ///\n            /// Currently the smallest primitive root is returned, but there is no guarantee that\n            /// this will be the case in the future.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(2^{n/4})$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is 0, and possibly panics if `self` is not prime.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_root_prime#primitive_root_prime).\n            #[inline]\n            fn primitive_root_prime(&self) -> $t {\n                primitive_root_prime::<$t, $n>(*self)\n            }\n        }\n    };\n}\nimpl_primitive_root_prime!(u8, MAX_FACTORS_IN_U8);\nimpl_primitive_root_prime!(u16, MAX_FACTORS_IN_U16);\nimpl_primitive_root_prime!(u32, MAX_FACTORS_IN_U32);\nimpl_primitive_root_prime!(u64, MAX_FACTORS_IN_U64);\nimpl_primitive_root_prime!(usize, MAX_FACTORS_IN_USIZE);\n"
  },
  {
    "path": "malachite-base/src/num/factorization/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// A trait for testing whether a number is prime.\npub trait IsPrime {\n    fn is_prime(&self) -> bool;\n}\n\n/// A trait for testing whether a number is a square.\npub trait IsSquare {\n    fn is_square(&self) -> bool;\n}\n\n/// A trait for testing whether a number is a perfect power.\npub trait IsPower {\n    fn is_power(&self) -> bool;\n}\n\n/// A trait for expessing as number as the power of some number raised to an exponent greater than\n/// 1, if such a representation exists.\npub trait ExpressAsPower: Sized {\n    fn express_as_power(&self) -> Option<(Self, u64)>;\n}\n\n/// A trait for finding the prime factorization of a number.\npub trait Factor {\n    type FACTORS;\n\n    fn factor(&self) -> Self::FACTORS;\n}\n\n/// A trait for producing iterators of primes.\npub trait Primes {\n    type I: Iterator<Item = Self>;\n    type LI: Iterator<Item = Self>;\n\n    fn primes_less_than(n: &Self) -> Self::LI;\n\n    fn primes_less_than_or_equal_to(n: &Self) -> Self::LI;\n\n    fn primes() -> Self::I;\n}\n\n/// A trait for finding a primitive root modulo a prime.\npub trait PrimitiveRootPrime {\n    type Output;\n\n    fn primitive_root_prime(&self) -> Self::Output;\n}\n"
  },
  {
    "path": "malachite-base/src/num/float/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::Abs;\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::comparison::traits::{EqAbs, OrdAbs, PartialOrdAbs};\nuse core::cmp::Ordering::{self, *};\nuse core::fmt::{self, Debug, Display, Formatter};\nuse core::hash::{Hash, Hasher};\nuse core::str::FromStr;\n\n/// `NiceFloat` is a wrapper around primitive float types that provides nicer [`Eq`], [`Ord`],\n/// [`Hash`], [`Display`], and [`FromStr`] instances.\n///\n/// In most languages, floats behave weirdly due to the IEEE 754 standard. The `NiceFloat` type\n/// ignores the standard in favor of more intuitive behavior.\n/// * Using `NiceFloat`, `NaN`s are equal to themselves. There is a single, unique `NaN`; there's no\n///   concept of signalling `NaN`s. Positive and negative zero are two distinct values, not equal to\n///   each other.\n/// * The `NiceFloat` hash respects this equality.\n/// * `NiceFloat` has a total order. These are the classes of floats, in ascending order:\n///   - Negative infinity\n///   - Negative nonzero finite floats\n///   - Negative zero\n///   - NaN\n///   - Positive zero\n///   - Positive nonzero finite floats\n///   - Positive infinity\n/// * `NiceFloat` uses a different [`Display`] implementation than floats do by default in Rust. For\n///   example, Rust will format `f32::MIN_POSITIVE_SUBNORMAL` as something with many zeros, but\n///   `NiceFloat(f32::MIN_POSITIVE_SUBNORMAL)` just formats it as `\"1.0e-45\"`. The conversion\n///   function uses David Tolnay's [`ryu`](https://docs.rs/ryu/latest/ryu/) crate, with a few\n///   modifications:\n///   - All finite floats have a decimal point. For example, Ryu by itself would convert\n///     `f32::MIN_POSITIVE_SUBNORMAL` to `\"1e-45\"`.\n///   - Positive infinity, negative infinity, and NaN are converted to the strings `\"Infinity\"`,\n///     `\"-Infinity\"`, and \"`NaN`\", respectively.\n/// * [`FromStr`] accepts these strings.\n#[derive(Clone, Copy, Default)]\npub struct NiceFloat<T: PrimitiveFloat>(pub T);\n\n#[derive(Eq, Ord, PartialEq, PartialOrd)]\nenum FloatType {\n    NegativeInfinity,\n    NegativeFinite,\n    NegativeZero,\n    NaN,\n    PositiveZero,\n    PositiveFinite,\n    PositiveInfinity,\n}\n\nimpl<T: PrimitiveFloat> NiceFloat<T> {\n    fn float_type(self) -> FloatType {\n        let f = self.0;\n        if f.is_nan() {\n            FloatType::NaN\n        } else if f.sign() == Greater {\n            if f == T::ZERO {\n                FloatType::PositiveZero\n            } else if f.is_finite() {\n                FloatType::PositiveFinite\n            } else {\n                FloatType::PositiveInfinity\n            }\n        } else if f == T::ZERO {\n            FloatType::NegativeZero\n        } else if f.is_finite() {\n            FloatType::NegativeFinite\n        } else {\n            FloatType::NegativeInfinity\n        }\n    }\n}\n\nimpl Abs for FloatType {\n    type Output = Self;\n\n    fn abs(self) -> Self::Output {\n        match self {\n            Self::NegativeInfinity => Self::PositiveInfinity,\n            Self::NegativeFinite => Self::PositiveFinite,\n            Self::NegativeZero => Self::PositiveZero,\n            t => t,\n        }\n    }\n}\n\nimpl<T: PrimitiveFloat> PartialEq<Self> for NiceFloat<T> {\n    /// Compares two `NiceFloat`s for equality.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of an equality operation that\n    /// respects the expected properties of symmetry, reflexivity, and transitivity. Using\n    /// `NiceFloat`, `NaN`s are equal to themselves. There is a single, unique `NaN`; there's no\n    /// concept of signalling `NaN`s. Positive and negative zero are two distinct values, not equal\n    /// to each other.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert_eq!(NiceFloat(0.0), NiceFloat(0.0));\n    /// assert_eq!(NiceFloat(f32::NAN), NiceFloat(f32::NAN));\n    /// assert_ne!(NiceFloat(f32::NAN), NiceFloat(0.0));\n    /// assert_ne!(NiceFloat(0.0), NiceFloat(-0.0));\n    /// assert_eq!(NiceFloat(1.0), NiceFloat(1.0));\n    /// ```\n    #[inline]\n    fn eq(&self, other: &Self) -> bool {\n        let f = self.0;\n        let g = other.0;\n        f.to_bits() == g.to_bits() || f.is_nan() && g.is_nan()\n    }\n}\n\nimpl<T: PrimitiveFloat> Eq for NiceFloat<T> {}\n\nimpl<T: PrimitiveFloat> EqAbs for NiceFloat<T> {\n    /// Compares the absolute values of two `NiceFloat`s for equality.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of an equality operation that\n    /// respects the expected properties of symmetry, reflexivity, and transitivity. Using\n    /// `NiceFloat`, `NaN`s are equal to themselves. There is a single, unique `NaN`; there's no\n    /// concept of signalling `NaN`s.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert!(NiceFloat(0.0).eq_abs(&NiceFloat(0.0)));\n    /// assert!(NiceFloat(f32::NAN).eq_abs(&NiceFloat(f32::NAN)));\n    /// assert!(NiceFloat(f32::NAN).ne_abs(&NiceFloat(0.0)));\n    /// assert!(NiceFloat(0.0).eq_abs(&NiceFloat(-0.0)));\n    /// assert!(NiceFloat(1.0).eq_abs(&NiceFloat(1.0)));\n    /// assert!(NiceFloat(1.0).eq_abs(&NiceFloat(-1.0)));\n    /// ```\n    fn eq_abs(&self, other: &Self) -> bool {\n        let f = self.0;\n        let g = other.0;\n        f.abs().to_bits() == g.abs().to_bits() || f.is_nan() && g.is_nan()\n    }\n}\n\nimpl<T: PrimitiveFloat> Hash for NiceFloat<T> {\n    /// Computes a hash of a `NiceFloat`.\n    ///\n    /// The hash is compatible with `NiceFloat` equality: all `NaN`s hash to the same value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    fn hash<H: Hasher>(&self, state: &mut H) {\n        let f = self.0;\n        if f.is_nan() {\n            \"NaN\".hash(state);\n        } else {\n            f.to_bits().hash(state);\n        }\n    }\n}\n\nimpl<T: PrimitiveFloat> Ord for NiceFloat<T> {\n    /// Compares two `NiceFloat`s.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of a comparison operation that\n    /// respects the expected properties of antisymmetry, reflexivity, and transitivity. `NiceFloat`\n    /// has a total order. These are the classes of floats, in ascending order:\n    ///   - Negative infinity\n    ///   - Negative nonzero finite floats\n    ///   - Negative zero\n    ///   - NaN\n    ///   - Positive zero\n    ///   - Positive nonzero finite floats\n    ///   - Positive infinity\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert!(NiceFloat(0.0) > NiceFloat(-0.0));\n    /// assert!(NiceFloat(f32::NAN) < NiceFloat(0.0));\n    /// assert!(NiceFloat(f32::NAN) > NiceFloat(-0.0));\n    /// assert!(NiceFloat(f32::INFINITY) > NiceFloat(f32::NAN));\n    /// assert!(NiceFloat(f32::NAN) < NiceFloat(1.0));\n    /// ```\n    fn cmp(&self, other: &Self) -> Ordering {\n        let self_type = self.float_type();\n        let other_type = other.float_type();\n        self_type.cmp(&other_type).then_with(|| {\n            if self_type == FloatType::PositiveFinite || self_type == FloatType::NegativeFinite {\n                self.0.partial_cmp(&other.0).unwrap()\n            } else {\n                Equal\n            }\n        })\n    }\n}\n\nimpl<T: PrimitiveFloat> PartialOrd<Self> for NiceFloat<T> {\n    /// Compares a `NiceFloat` to another `NiceFloat`.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp(other))\n    }\n}\n\nimpl<T: PrimitiveFloat> OrdAbs for NiceFloat<T> {\n    /// Compares the absolute values of two `NiceFloat`s.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of a comparison operation that\n    /// respects the expected properties of antisymmetry, reflexivity, and transitivity. `NiceFloat`\n    /// has a total order. These are the classes of floats, in order of ascending absolute value:\n    ///   - NaN\n    ///   - Positive zero\n    ///   - Positive nonzero finite floats\n    ///   - Positive infinity\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::NegativeInfinity;\n    /// use malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert!(NiceFloat(0.0).eq_abs(&NiceFloat(-0.0)));\n    /// assert!(NiceFloat(f32::NAN).lt_abs(&NiceFloat(0.0)));\n    /// assert!(NiceFloat(f32::NAN).lt_abs(&NiceFloat(-0.0)));\n    /// assert!(NiceFloat(f32::INFINITY).gt_abs(&NiceFloat(f32::NAN)));\n    /// assert!(NiceFloat(f32::NEGATIVE_INFINITY).gt_abs(&NiceFloat(f32::NAN)));\n    /// assert!(NiceFloat(f32::NAN).lt_abs(&NiceFloat(1.0)));\n    /// assert!(NiceFloat(f32::NAN).lt_abs(&NiceFloat(-1.0)));\n    /// ```\n    fn cmp_abs(&self, other: &Self) -> Ordering {\n        let self_type = self.float_type().abs();\n        let other_type = other.float_type().abs();\n        self_type.cmp(&other_type).then_with(|| {\n            if self_type == FloatType::PositiveFinite {\n                self.0.abs().partial_cmp(&other.0.abs()).unwrap()\n            } else {\n                Equal\n            }\n        })\n    }\n}\n\nimpl<T: PrimitiveFloat> PartialOrdAbs<Self> for NiceFloat<T> {\n    /// Compares the absolute values of two `NiceFloat`s.\n    ///\n    /// See the documentation for the [`OrdAbs`] implementation.\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp_abs(other))\n    }\n}\n\n#[doc(hidden)]\npub trait FmtRyuString: Copy {\n    fn fmt_ryu_string(self, f: &mut Formatter<'_>) -> fmt::Result;\n}\n\nmacro_rules! impl_fmt_ryu_string {\n    ($f: ident) => {\n        impl FmtRyuString for $f {\n            #[inline]\n            fn fmt_ryu_string(self, f: &mut Formatter<'_>) -> fmt::Result {\n                let mut buffer = ryu::Buffer::new();\n                let printed = buffer.format_finite(self);\n                // Convert e.g. \"1e100\" to \"1.0e100\". `printed` is ASCII, so we can manipulate bytes\n                // rather than chars.\n                let mut e_index = None;\n                let mut found_dot = false;\n                for (i, &b) in printed.as_bytes().iter().enumerate() {\n                    match b {\n                        b'.' => {\n                            found_dot = true;\n                            break; // If there's a '.', we don't need to do anything\n                        }\n                        b'e' => {\n                            e_index = Some(i);\n                            break; // OK to break since there won't be a '.' after an 'e'\n                        }\n                        _ => {}\n                    }\n                }\n                if found_dot {\n                    f.write_str(printed)\n                } else {\n                    if let Some(e_index) = e_index {\n                        let mut out_bytes = ::alloc::vec![0; printed.len() + 2];\n                        let (in_bytes_lo, in_bytes_hi) = printed.as_bytes().split_at(e_index);\n                        let (out_bytes_lo, out_bytes_hi) = out_bytes.split_at_mut(e_index);\n                        out_bytes_lo.copy_from_slice(in_bytes_lo);\n                        out_bytes_hi[0] = b'.';\n                        out_bytes_hi[1] = b'0';\n                        out_bytes_hi[2..].copy_from_slice(in_bytes_hi);\n                        f.write_str(core::str::from_utf8(&out_bytes).unwrap())\n                    } else {\n                        panic!(\"Unexpected Ryu string: {}\", printed);\n                    }\n                }\n            }\n        }\n    };\n}\n\nimpl_fmt_ryu_string!(f32);\nimpl_fmt_ryu_string!(f64);\n\nimpl<T: PrimitiveFloat> Display for NiceFloat<T> {\n    /// Formats a `NiceFloat` as a string.\n    ///\n    /// `NiceFloat` uses a different [`Display`] implementation than floats do by default in Rust.\n    /// For example, Rust will convert `f32::MIN_POSITIVE_SUBNORMAL` to something with many zeros,\n    /// but `NiceFloat(f32::MIN_POSITIVE_SUBNORMAL)` just converts to `\"1.0e-45\"`. The conversion\n    /// function uses David Tolnay's [`ryu`](https://docs.rs/ryu/latest/ryu/) crate, with a few\n    /// modifications:\n    /// - All finite floats have a decimal point. For example, Ryu by itself would convert\n    ///   `f32::MIN_POSITIVE_SUBNORMAL` to `\"1e-45\"`.\n    /// - Positive infinity, negative infinity, and NaN are converted to the strings `\"Infinity\"`,\n    ///   `\"-Infinity\"`, and \"`NaN`\", respectively.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::floats::PrimitiveFloat;\n    /// use malachite_base::num::basic::traits::NegativeInfinity;\n    /// use malachite_base::num::float::NiceFloat;\n    ///\n    /// assert_eq!(NiceFloat(0.0).to_string(), \"0.0\");\n    /// assert_eq!(NiceFloat(-0.0).to_string(), \"-0.0\");\n    /// assert_eq!(NiceFloat(f32::INFINITY).to_string(), \"Infinity\");\n    /// assert_eq!(NiceFloat(f32::NEGATIVE_INFINITY).to_string(), \"-Infinity\");\n    /// assert_eq!(NiceFloat(f32::NAN).to_string(), \"NaN\");\n    ///\n    /// assert_eq!(NiceFloat(1.0).to_string(), \"1.0\");\n    /// assert_eq!(NiceFloat(-1.0).to_string(), \"-1.0\");\n    /// assert_eq!(\n    ///     NiceFloat(f32::MIN_POSITIVE_SUBNORMAL).to_string(),\n    ///     \"1.0e-45\"\n    /// );\n    /// assert_eq!(\n    ///     NiceFloat(std::f64::consts::E).to_string(),\n    ///     \"2.718281828459045\"\n    /// );\n    /// assert_eq!(\n    ///     NiceFloat(std::f64::consts::PI).to_string(),\n    ///     \"3.141592653589793\"\n    /// );\n    /// ```\n    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {\n        if self.0.is_nan() {\n            f.write_str(\"NaN\")\n        } else if self.0.is_infinite() {\n            if self.0.sign() == Greater {\n                f.write_str(\"Infinity\")\n            } else {\n                f.write_str(\"-Infinity\")\n            }\n        } else {\n            self.0.fmt_ryu_string(f)\n        }\n    }\n}\n\nimpl<T: PrimitiveFloat> Debug for NiceFloat<T> {\n    /// Formats a `NiceFloat` as a string.\n    ///\n    /// This is identical to the [`Display::fmt`] implementation.\n    #[inline]\n    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {\n        Display::fmt(self, f)\n    }\n}\n\nimpl<T: PrimitiveFloat> FromStr for NiceFloat<T> {\n    type Err = <T as FromStr>::Err;\n\n    /// Converts a `&str` to a `NiceFloat`.\n    ///\n    /// If the `&str` does not represent a valid `NiceFloat`, an `Err` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ = `src.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::float::NiceFloat;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(NiceFloat::from_str(\"NaN\").unwrap(), NiceFloat(f32::NAN));\n    /// assert_eq!(NiceFloat::from_str(\"-0.00\").unwrap(), NiceFloat(-0.0f64));\n    /// assert_eq!(NiceFloat::from_str(\".123\").unwrap(), NiceFloat(0.123f32));\n    /// ```\n    #[inline]\n    fn from_str(src: &str) -> Result<Self, <T as FromStr>::Err> {\n        match src {\n            \"NaN\" => Ok(T::NAN),\n            \"Infinity\" => Ok(T::INFINITY),\n            \"-Infinity\" => Ok(T::NEGATIVE_INFINITY),\n            \"inf\" | \"-inf\" => T::from_str(\"invalid\"),\n            src => T::from_str(src),\n        }\n        .map(NiceFloat)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/iterators/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse crate::num::arithmetic::traits::{DivMod, DivisibleBy};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse core::cmp::Ordering::*;\nuse core::marker::PhantomData;\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct SameWidthIteratorToBitChunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n> {\n    xs: I,\n    width: u64,\n    phantom: PhantomData<*const U>,\n}\n\nimpl<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    SameWidthIteratorToBitChunks<I, T, U>\n{\n    fn next_with_wrapping<F: Fn(T) -> U>(&mut self, wrap: F) -> Option<Option<U>> {\n        self.xs.next().map(|x| {\n            if x.significant_bits() <= self.width {\n                Some(wrap(x))\n            } else {\n                None\n            }\n        })\n    }\n}\n\nconst fn same_width_iterator_to_bit_chunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    xs: I,\n    width: u64,\n) -> SameWidthIteratorToBitChunks<I, T, U> {\n    SameWidthIteratorToBitChunks {\n        xs,\n        width,\n        phantom: PhantomData,\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct EvenFractionIteratorToBitChunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n> {\n    xs: I,\n    x: T,\n    multiple: u64,\n    x_width: u64,\n    y_width: u64,\n    counter: u64,\n    phantom: PhantomData<*const U>,\n}\n\nimpl<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    EvenFractionIteratorToBitChunks<I, T, U>\n{\n    fn next_with_wrapping<F: Fn(T) -> U>(&mut self, wrap: F) -> Option<Option<U>> {\n        if self.counter == 0 {\n            if let Some(x) = self.xs.next() {\n                if x.significant_bits() > self.x_width {\n                    return Some(None);\n                }\n                self.x = x;\n                self.counter = self.multiple;\n            } else {\n                return None;\n            }\n        } else {\n            self.x >>= self.y_width;\n        }\n        let y = wrap(self.x.mod_power_of_2(self.y_width));\n        self.counter -= 1;\n        Some(Some(y))\n    }\n}\n\nconst fn even_fraction_iterator_to_bit_chunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    xs: I,\n    multiple: u64,\n    out_chunk_size: u64,\n) -> EvenFractionIteratorToBitChunks<I, T, U> {\n    EvenFractionIteratorToBitChunks {\n        xs,\n        x: T::ZERO,\n        multiple,\n        x_width: multiple * out_chunk_size,\n        y_width: out_chunk_size,\n        counter: 0,\n        phantom: PhantomData,\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct EvenMultipleIteratorToBitChunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n> {\n    xs: I,\n    x_width: u64,\n    y_width: u64,\n    done: bool,\n    phantom: PhantomData<*const U>,\n}\n\nimpl<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    EvenMultipleIteratorToBitChunks<I, T, U>\n{\n    fn next_with_wrapping<F: Fn(T) -> U>(&mut self, wrap: F) -> Option<Option<U>> {\n        if self.done {\n            return None;\n        }\n        let mut y = U::ZERO;\n        let mut shift = 0;\n        while shift < self.y_width {\n            if let Some(x) = self.xs.next() {\n                if x.significant_bits() > self.x_width {\n                    return Some(None);\n                }\n                y |= wrap(x) << shift;\n                shift += self.x_width;\n            } else {\n                self.done = true;\n                break;\n            }\n        }\n        if shift == 0 { None } else { Some(Some(y)) }\n    }\n}\n\nconst fn even_multiple_iterator_to_bit_chunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    xs: I,\n    in_chunk_size: u64,\n    out_chunk_size: u64,\n) -> EvenMultipleIteratorToBitChunks<I, T, U> {\n    EvenMultipleIteratorToBitChunks {\n        xs,\n        x_width: in_chunk_size,\n        y_width: out_chunk_size,\n        done: false,\n        phantom: PhantomData,\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct IrregularIteratorToBitChunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n> {\n    xs: I,\n    x: T,\n    x_width: u64,\n    y_width: u64,\n    remaining_x_bits: u64,\n    in_inner_loop: bool,\n    phantom: PhantomData<*const U>,\n}\n\nimpl<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    IrregularIteratorToBitChunks<I, T, U>\n{\n    fn next_with_wrapping<F: Fn(T) -> U>(&mut self, wrap: F) -> Option<Option<U>> {\n        let mut y = U::ZERO;\n        let mut remaining_y_bits = self.y_width;\n        loop {\n            if !self.in_inner_loop {\n                if let Some(x) = self.xs.next() {\n                    if x.significant_bits() > self.x_width {\n                        return Some(None);\n                    }\n                    self.x = x;\n                } else {\n                    break;\n                }\n                self.remaining_x_bits = self.x_width;\n                self.in_inner_loop = true;\n            }\n            while self.remaining_x_bits != 0 {\n                let y_index = self.y_width - remaining_y_bits;\n                if self.remaining_x_bits <= remaining_y_bits {\n                    y |= wrap(self.x) << y_index;\n                    remaining_y_bits -= self.remaining_x_bits;\n                    self.remaining_x_bits = 0;\n                } else {\n                    y |= wrap(self.x).mod_power_of_2(remaining_y_bits) << y_index;\n                    self.x >>= remaining_y_bits;\n                    self.remaining_x_bits -= remaining_y_bits;\n                    remaining_y_bits = 0;\n                }\n                if remaining_y_bits == 0 {\n                    return Some(Some(y));\n                }\n            }\n            self.in_inner_loop = false;\n        }\n        if y == U::ZERO { None } else { Some(Some(y)) }\n    }\n}\n\nconst fn irregular_iterator_to_bit_chunks<\n    I: Iterator<Item = T>,\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    xs: I,\n    in_chunk_size: u64,\n    out_chunk_size: u64,\n) -> IrregularIteratorToBitChunks<I, T, U> {\n    IrregularIteratorToBitChunks {\n        xs,\n        x: T::ZERO,\n        x_width: in_chunk_size,\n        y_width: out_chunk_size,\n        remaining_x_bits: 0,\n        in_inner_loop: false,\n        phantom: PhantomData,\n    }\n}\n\n/// Regroups an iterator of bit chunks into another iterator of bit chunks, possibly with a\n/// different chunk size.\n///\n/// This `enum` is created by [`iterator_to_bit_chunks`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub enum IteratorToBitChunks<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    SameWidth(SameWidthIteratorToBitChunks<I, T, U>),\n    EvenFraction(EvenFractionIteratorToBitChunks<I, T, U>),\n    EvenMultiple(EvenMultipleIteratorToBitChunks<I, T, U>),\n    Irregular(IrregularIteratorToBitChunks<I, T, U>),\n}\n\nimpl<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    IteratorToBitChunks<I, T, U>\n{\n    pub(crate) fn next_with_wrapping<F: Fn(T) -> U>(&mut self, wrap: F) -> Option<Option<U>> {\n        match self {\n            Self::SameWidth(xs) => xs.next_with_wrapping(wrap),\n            Self::EvenFraction(xs) => xs.next_with_wrapping(wrap),\n            Self::EvenMultiple(xs) => xs.next_with_wrapping(wrap),\n            Self::Irregular(xs) => xs.next_with_wrapping(wrap),\n        }\n    }\n}\n\nimpl<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<T>> Iterator\n    for IteratorToBitChunks<I, T, U>\n{\n    type Item = Option<U>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Option<U>> {\n        self.next_with_wrapping(U::wrapping_from)\n    }\n}\n\n/// Regroups an iterator of bit chunks into another iterator of bit chunks, possibly with a\n/// different chunk size.\n///\n/// In other words, let $A$ be the input chunk size and $B$ the output chunk size. Let's consider\n/// the lowest $A$ bits of each unsigned value produced by the input iterator, and concatenate them\n/// (least-significant bits first) into a single bit sequence. Then we chop the sequence up into\n/// chunks of $B$ bits, and have the output iterator return each chunk.\n///\n/// Let $(x\\_i)\\_{i=0}^{n-1}$ be the input iterator, where $n$ may be $\\infty$. If $n$ is finite, we\n/// assume that $x\\_{n-1} \\neq 0$. Then we define the bit sequence $b\\_{k=0}^\\infty$ such that $b\n/// \\in \\\\{0, 1\\\\}$, $b\\_k=0$ for $k \\geq An$, and\n/// $$\n/// x_i = \\sum_{k=0}^{A-1} b_{Ai+k}2^k.\n/// $$\n/// Then, let $(y\\_j)\\_{j=0}^{m-1}$ be a sequence such that\n/// $$\n/// y_j = \\sum_{k=0}^{B-1} b_{Bi+k}2^k.\n/// $$\n/// Then we have $f((x\\_i)\\_{i=0}^{n-1}) = (y\\_j)\\_{j=0}^{m-1}$. Note that the sequence $y$ is not\n/// uniquely specified, since it may contain arbitrarily many trailing zeros. However, if $x$ is\n/// finite, $y$ is guaranteed to also be finite.\n///\n/// The output length is $An/B + O(1)$, where $n$ is `xs.count()`, $A$ is `in_chunk_size`, and $B$\n/// is `out_chunk_size`.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::iterators::iterator_to_bit_chunks;\n///\n/// assert_eq!(\n///     iterator_to_bit_chunks::<_, u16, u32>([123, 456].iter().cloned(), 10, 10)\n///         .map(Option::unwrap)\n///         .collect_vec(),\n///     &[123, 456]\n/// );\n/// assert_eq!(\n///     iterator_to_bit_chunks::<_, u16, u16>([0b000111111, 0b110010010].iter().cloned(), 9, 3)\n///         .map(Option::unwrap)\n///         .collect_vec(),\n///     &[0b111, 0b111, 0b000, 0b010, 0b010, 0b110]\n/// );\n/// assert_eq!(\n///     iterator_to_bit_chunks::<_, u16, u32>(\n///         [0b111, 0b111, 0b000, 0b010, 0b010, 0b110].iter().cloned(),\n///         3,\n///         9\n///     )\n///     .map(Option::unwrap)\n///     .collect_vec(),\n///     &[0b000111111, 0b110010010]\n/// );\n/// assert_eq!(\n///     iterator_to_bit_chunks::<_, u32, u16>(\n///         [0b1010101, 0b1111101, 0b0100001, 0b110010].iter().cloned(),\n///         7,\n///         6\n///     )\n///     .map(Option::unwrap)\n///     .collect_vec(),\n///     &[0b010101, 0b111011, 0b000111, 0b010010, 0b110]\n/// );\n/// ```\npub fn iterator_to_bit_chunks<I: Iterator<Item = T>, T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    xs: I,\n    in_chunk_size: u64,\n    out_chunk_size: u64,\n) -> IteratorToBitChunks<I, T, U> {\n    assert_ne!(in_chunk_size, 0);\n    assert_ne!(out_chunk_size, 0);\n    assert!(in_chunk_size <= T::WIDTH);\n    assert!(out_chunk_size <= U::WIDTH);\n    match in_chunk_size.cmp(&out_chunk_size) {\n        Equal => {\n            return IteratorToBitChunks::SameWidth(same_width_iterator_to_bit_chunks(\n                xs,\n                in_chunk_size,\n            ));\n        }\n        Less => {\n            if out_chunk_size.divisible_by(in_chunk_size) {\n                return IteratorToBitChunks::EvenMultiple(even_multiple_iterator_to_bit_chunks(\n                    xs,\n                    in_chunk_size,\n                    out_chunk_size,\n                ));\n            }\n        }\n        Greater => {\n            let (multiple, remainder) = in_chunk_size.div_mod(out_chunk_size);\n            if remainder == 0 {\n                return IteratorToBitChunks::EvenFraction(even_fraction_iterator_to_bit_chunks(\n                    xs,\n                    multiple,\n                    out_chunk_size,\n                ));\n            }\n        }\n    }\n    IteratorToBitChunks::Irregular(irregular_iterator_to_bit_chunks(\n        xs,\n        in_chunk_size,\n        out_chunk_size,\n    ))\n}\n\n/// A `struct` that holds the state of the ruler sequence.\n///\n/// This `struct` is created by [`ruler_sequence`]; see its documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct RulerSequence<T: ExactFrom<u32>> {\n    i: u64,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: ExactFrom<u32>> Iterator for RulerSequence<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.i += 1;\n        Some(T::exact_from(self.i.trailing_zeros()))\n    }\n}\n\n/// Returns the ruler sequence.\n///\n/// The ruler sequence (<https://oeis.org/A007814>) is the number of times that 2 divides the\n/// numbers $1, 2, 3, \\ldots$.\n///\n/// $(x_i)_{i=1}^\\infty = t_i$, where for each $i$, $i = (2k_i+1)2^{t_i}$ for some $k_i\\in\n/// \\mathbb{Z}$.\n///\n/// The $n$th term of this sequence is no greater than $\\log_2(n + 1)$. Every number occurs\n/// infinitely many times, and any number's first occurrence is after all smaller numbers have\n/// occurred.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::iterators::ruler_sequence;\n///\n/// assert_eq!(\n///     prefix_to_string(ruler_sequence::<u32>(), 20),\n///     \"[0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, ...]\"\n/// );\n/// ```\npub const fn ruler_sequence<T: ExactFrom<u32>>() -> RulerSequence<T> {\n    RulerSequence {\n        i: 0,\n        phantom: PhantomData,\n    }\n}\n\n/// A `struct` that holds the state of a bit distributor sequence.\n///\n/// This `struct` is created by [`bit_distributor_sequence`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct BitDistributorSequence {\n    bit_distributor: BitDistributor,\n}\n\nimpl Iterator for BitDistributorSequence {\n    type Item = usize;\n\n    fn next(&mut self) -> Option<usize> {\n        let i = self.bit_distributor.get_output(1);\n        self.bit_distributor.increment_counter();\n        Some(i)\n    }\n}\n\n/// Returns a sequence based on a [`BitDistributor`].\n///\n/// The sequence is obtained by taking the second output of a two-output [`BitDistributor`]. If both\n/// output types are normal with weight 1, the sequence is <https://oeis.org/A059905>.\n///\n/// The smaller the first output type is relative to the second (where tiny outputs are smaller than\n/// normal outputs), the slower the sequence will grow.\n///\n/// - If the first output type is normal and the second is tiny, the sequence grows as $O(n)$.\n/// - If the first output type is tiny and the second is normal, the sequence grows as $O(\\log n)$.\n/// - If both output types are normal with weights $p$ and $q$, the sequence grows as\n///   $O(n^\\frac{p}{p+q})$.\n/// - The output types cannot both be tiny.\n///\n/// Every number occurs infinitely many times, and any number's first occurrence is after all\n/// smaller numbers have occurred. The sequence increases by no more than 1 at each step, but may\n/// decrease by an arbitrarily large amount.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if both output types are tiny.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::bit_distributor::BitDistributorOutputType;\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::iterators::bit_distributor_sequence;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         bit_distributor_sequence(\n///             BitDistributorOutputType::normal(1),\n///             BitDistributorOutputType::normal(2)\n///         ),\n///         50\n///     ),\n///     \"[0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, \\\n///     3, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 0, 1, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         bit_distributor_sequence(\n///             BitDistributorOutputType::normal(2),\n///             BitDistributorOutputType::normal(1)\n///         ),\n///         50\n///     ),\n///     \"[0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 11, 8, 9, 10, 11, 12, 13, 14, \\\n///     15, 12, 13, 14, 15, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 9, ...]\"\n/// );\n/// ```\npub fn bit_distributor_sequence(\n    x_output_type: BitDistributorOutputType,\n    y_output_type: BitDistributorOutputType,\n) -> BitDistributorSequence {\n    BitDistributorSequence {\n        bit_distributor: BitDistributor::new(&[y_output_type, x_output_type]),\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/logic/bit_access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::logic::traits::BitAccess;\n\nfn get_bit_unsigned<T: PrimitiveUnsigned>(x: &T, index: u64) -> bool {\n    index < T::WIDTH && (*x >> index).odd()\n}\n\nfn set_bit_unsigned<T: PrimitiveUnsigned>(x: &mut T, index: u64) {\n    if index < T::WIDTH {\n        *x |= T::power_of_2(index);\n    } else {\n        panic!(\n            \"Cannot set bit {} in non-negative value of width {}\",\n            index,\n            T::WIDTH\n        );\n    }\n}\n\nfn clear_bit_unsigned<T: PrimitiveUnsigned>(x: &mut T, index: u64) {\n    if index < T::WIDTH {\n        *x &= !T::power_of_2(index);\n    }\n}\n\nmacro_rules! impl_bit_access_unsigned {\n    ($t:ident) => {\n        impl BitAccess for $t {\n            /// Determines whether the $i$th bit of an unsigned primitive integer, or the\n            /// coefficient of $2^i$ in its binary expansion, is 0 or 1.\n            ///\n            /// `false` means 0 and `true` means 1. Getting bits beyond the type's width is allowed;\n            /// those bits are false.\n            ///\n            /// Let\n            /// $$\n            /// n = \\sum_{i=0}^\\infty 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the\n            /// rest are 0. Then $f(n, j) = (b_j = 1)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_access#get_bit).\n            #[inline]\n            fn get_bit(&self, index: u64) -> bool {\n                get_bit_unsigned(self, index)\n            }\n\n            /// Sets the $i$th bit of an unsigned primitive integer, or the coefficient of $2^i$ in\n            /// its binary expansion, to 1.\n            ///\n            /// Setting bits beyond the type's width is disallowed.\n            ///\n            /// Let\n            /// $$\n            /// n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$, and $W$ is the width of the type. Then\n            /// $$\n            /// n \\gets \\\\begin{cases}\n            ///     n + 2^j & \\text{if} \\\\quad b_j = 0, \\\\\\\\\n            ///     n & \\text{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $j < W$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if $i \\geq W$, where $i$ is `index` and $W$ is `$t::WIDTH`.\n            ///\n            /// # Examples\n            /// See [here](super::bit_access#set_bit).\n            #[inline]\n            fn set_bit(&mut self, index: u64) {\n                set_bit_unsigned(self, index)\n            }\n\n            /// Sets the $i$th bit of an unsigned primitive integer, or the coefficient of $2^i$ in\n            /// its binary expansion, to 0.\n            ///\n            /// Clearing bits beyond the type's width is allowed; since those bits are already\n            /// `false`, clearing them does nothing.\n            ///\n            /// Let\n            /// $$\n            /// n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$, and $W$ is the width of the type. Then\n            /// $$\n            /// n \\gets \\\\begin{cases}\n            ///     n - 2^j & \\text{if} \\\\quad b_j = 1, \\\\\\\\\n            ///     n & \\text{otherwise}.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_access#clear_bit).\n            #[inline]\n            fn clear_bit(&mut self, index: u64) {\n                clear_bit_unsigned(self, index)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_bit_access_unsigned);\n\nfn get_bit_signed<T: PrimitiveSigned>(x: &T, index: u64) -> bool {\n    if index < T::WIDTH {\n        (*x >> index).odd()\n    } else {\n        *x < T::ZERO\n    }\n}\n\nfn set_bit_signed<T: PrimitiveSigned>(x: &mut T, index: u64) {\n    if index < T::WIDTH {\n        *x |= T::ONE << index;\n    } else if *x >= T::ZERO {\n        panic!(\n            \"Cannot set bit {} in non-negative value of width {}\",\n            index,\n            T::WIDTH\n        );\n    }\n}\n\nfn clear_bit_signed<T: PrimitiveSigned>(x: &mut T, index: u64) {\n    if index < T::WIDTH {\n        *x &= !(T::ONE << index);\n    } else if *x < T::ZERO {\n        panic!(\n            \"Cannot clear bit {} in negative value of width {}\",\n            index,\n            T::WIDTH\n        );\n    }\n}\n\nmacro_rules! impl_bit_access_signed {\n    ($t:ident) => {\n        impl BitAccess for $t {\n            /// Determines whether the $i$th bit of a signed primitive integer is 0 or 1.\n            ///\n            /// `false` means 0 and `true` means 1. Getting bits beyond the type's width is allowed;\n            /// those bits are `true` if the value is negative, and `false` otherwise.\n            ///\n            /// If $n \\geq 0$, let\n            /// $$\n            /// n = \\sum_{i=0}^\\infty 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the\n            /// rest are 0. Then $f(n, i) = (b_i = 1)$.\n            ///\n            /// If $n < 0$, let\n            /// $$\n            /// 2^W + n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where\n            /// - $W$ is the type's width\n            /// - for all $i$, $b_i\\in \\\\{0, 1\\\\}$, and $b_i = 1$ for $i \\geq W$.\n            ///\n            /// Then $f(n, j) = (b_j = 1)$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_access#get_bit).\n            #[inline]\n            fn get_bit(&self, index: u64) -> bool {\n                get_bit_signed(self, index)\n            }\n\n            /// Sets the $i$th bit of a signed primitive integer to 1.\n            ///\n            /// Setting bits beyond the type's width is disallowed if the number is non-negative.\n            ///\n            /// If $n \\geq 0$ and $j \\neq W - 1$, let\n            /// $$\n            /// n = \\sum_{i=0}^{W-1} 2^{b_i};\n            /// $$\n            /// but if $n < 0$ or $j = W - 1$, let\n            /// $$\n            /// 2^W + n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$, and $W$ is the width of the type. Then\n            /// $$\n            /// n \\gets \\\\begin{cases}\n            ///     n + 2^j & \\text{if} \\\\quad b_j = 0, \\\\\\\\\n            ///     n & \\text{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $n < 0$ or $j < W$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if $n \\geq 0$ and $i \\geq W$, where $n$ is `self`, $i$ is `index` and $W$ is\n            /// the width of the type.\n            ///\n            /// # Examples\n            /// See [here](super::bit_access#set_bit).\n            #[inline]\n            fn set_bit(&mut self, index: u64) {\n                set_bit_signed(self, index)\n            }\n\n            /// Sets the $i$th bit of a signed primitive integer to 0.\n            ///\n            /// Clearing bits beyond the type's width is disallowed if the number is negative.\n            ///\n            /// If $n \\geq 0$ or $j = W - 1$, let\n            /// $$\n            /// n = \\sum_{i=0}^{W-1} 2^{b_i};\n            /// $$\n            /// but if $n < 0$ or $j = W - 1$, let\n            /// $$\n            /// 2^W + n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$ and $W$ is the width of the type. Then\n            /// $$\n            /// n \\gets \\\\begin{cases}\n            ///     n - 2^j & \\text{if} \\\\quad b_j = 1, \\\\\\\\\n            ///     n & \\text{otherwise},\n            /// \\\\end{cases}\n            /// $$\n            /// where $n \\geq 0$ or $j < W$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if $n < 0$ and $i \\geq W$, where $n$ is `self`, $i$ is `index` and $W$ is the\n            /// width of the type.\n            ///\n            /// # Examples\n            /// See [here](super::bit_access#clear_bit).\n            #[inline]\n            fn clear_bit(&mut self, index: u64) {\n                clear_bit_signed(self, index)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_bit_access_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/bit_block_access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{ModPowerOf2, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::logic::traits::{BitBlockAccess, LeadingZeros};\nuse core::cmp::min;\n\nconst ERROR_MESSAGE: &str = \"Result exceeds width of output type\";\n\nfn get_bits_unsigned<T: PrimitiveUnsigned>(x: &T, start: u64, end: u64) -> T {\n    assert!(start <= end);\n    if start >= T::WIDTH {\n        T::ZERO\n    } else {\n        (*x >> start).mod_power_of_2(end - start)\n    }\n}\n\nfn assign_bits_unsigned<T: PrimitiveUnsigned>(x: &mut T, start: u64, end: u64, bits: &T) {\n    assert!(start <= end);\n    let width = T::WIDTH;\n    let bits_width = end - start;\n    let bits = bits.mod_power_of_2(bits_width);\n    if bits != T::ZERO && LeadingZeros::leading_zeros(bits) < start {\n        panic!(\"{}\", ERROR_MESSAGE);\n    } else if start < width {\n        *x &= !(T::MAX.mod_power_of_2(min(bits_width, width - start)) << start);\n        *x |= bits << start;\n    }\n}\n\nmacro_rules! impl_bit_block_access_unsigned {\n    ($t:ident) => {\n        impl BitBlockAccess for $t {\n            type Bits = $t;\n\n            /// Extracts a block of adjacent bits from a number.\n            ///\n            /// The first index is `start` and last index is `end - 1`.\n            ///\n            /// The block of bits has the same type as the input. If `end` is greater than the\n            /// type's width, the high bits of the result are all 0.\n            ///\n            /// Let\n            /// $$\n            /// n = \\sum_{i=0}^\\infty 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the\n            /// rest are 0. Then\n            /// $$\n            /// f(n, p, q) = \\sum_{i=p}^{q-1} 2^{b_{i-p}}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `start < end`.\n            ///\n            /// # Examples\n            /// See [here](super::bit_block_access#get_bits).\n            #[inline]\n            fn get_bits(&self, start: u64, end: u64) -> Self {\n                get_bits_unsigned(self, start, end)\n            }\n\n            /// Replaces a block of adjacent bits in a number with other bits.\n            ///\n            /// The least-significant `end - start` bits of `bits` are assigned to bits `start`\n            /// through `end - 1`, inclusive, of `self`.\n            ///\n            /// The block of bits has the same type as the input. If `bits` has fewer bits than `end\n            /// - start`, the high bits are interpreted as 0. If `end` is greater than the type's\n            /// width, the high bits of `bits` must be 0.\n            ///\n            /// Let\n            /// $$\n            /// n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$ and $W$ is `$t::WIDTH`. Let\n            /// $$\n            /// m = \\sum_{i=0}^k 2^{d_i},\n            /// $$\n            /// where for all $i$, $d_i\\in \\\\{0, 1\\\\}$. Also, let $p, q \\in \\mathbb{N}$, where $d_i\n            /// = 0$ for all $i \\geq W + p$.\n            ///\n            /// Then\n            /// $$\n            /// n \\gets \\sum_{i=0}^{W-1} 2^{c_i},\n            /// $$\n            /// where\n            /// $$\n            /// \\\\{c_0, c_1, c_2, \\ldots, c_ {W-1}\\\\} =\n            /// \\\\{b_0, b_1, b_2, \\ldots, b_{p-1}, d_0, d_1, \\ldots, d_{p-q-1}, b_q, \\ldots,\n            /// b_ {W-1}\\\\}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Let `W` be the type's width. Panics if `start < end`, or if `end > W` and bits `W -\n            /// start` through `end - start` of `bits` are nonzero.\n            ///\n            /// # Examples\n            /// See [here](super::bit_block_access#assign_bits).\n            #[inline]\n            fn assign_bits(&mut self, start: u64, end: u64, bits: &Self::Bits) {\n                assign_bits_unsigned(self, start, end, bits)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_bit_block_access_unsigned);\n\nfn get_bits_signed<T: ModPowerOf2<Output = U> + PrimitiveSigned, U>(\n    x: &T,\n    start: u64,\n    end: u64,\n) -> U {\n    assert!(start <= end);\n    (if start >= T::WIDTH {\n        -T::from(*x < T::ZERO)\n    } else {\n        *x >> start\n    })\n    .mod_power_of_2(end - start)\n}\n\nfn assign_bits_signed<\n    T: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    x: &mut T,\n    start: u64,\n    end: u64,\n    bits: &U,\n) {\n    assert!(start <= end);\n    if *x >= T::ZERO {\n        let mut abs_x = x.unsigned_abs();\n        abs_x.assign_bits(start, end, bits);\n        assert!(!abs_x.get_highest_bit(), \"{ERROR_MESSAGE}\");\n        *x = T::wrapping_from(abs_x);\n    } else {\n        let width = T::WIDTH - 1;\n        let bits_width = end - start;\n        let bits = bits.mod_power_of_2(bits_width);\n        let max = U::MAX;\n        if bits_width > width + 1 {\n            panic!(\"{}\", ERROR_MESSAGE);\n        } else if start >= width {\n            assert!(bits == max.mod_power_of_2(bits_width), \"{ERROR_MESSAGE}\");\n        } else {\n            let lower_width = width - start;\n            if end > width && bits >> lower_width != max.mod_power_of_2(end - width) {\n                panic!(\"{}\", ERROR_MESSAGE);\n            } else {\n                *x &=\n                    T::wrapping_from(!(max.mod_power_of_2(min(bits_width, lower_width)) << start));\n                *x |= T::wrapping_from(bits << start);\n            }\n        }\n    }\n}\n\nmacro_rules! impl_bit_block_access_signed {\n    ($u:ident, $s:ident) => {\n        impl BitBlockAccess for $s {\n            type Bits = $u;\n\n            /// Extracts a block of adjacent bits from a number.\n            ///\n            /// The first index is `start` and last index is `end - 1`.\n            ///\n            /// The type of the block of bits is the unsigned version of the input type. If `end` is\n            /// greater than the type's width, the high bits of the result are all 0, or all 1,\n            /// depending on the input value's sign; and if the input is negative and `end - start`\n            /// is greater than the type's width, the function panics.\n            ///\n            /// If $n \\geq 0$, let\n            /// $$\n            /// n = \\sum_{i=0}^\\infty 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the\n            /// rest are 0. Then\n            /// $$\n            /// f(n, p, q) = \\sum_{i=p}^{q-1} 2^{b_{i-p}}.\n            /// $$\n            ///\n            /// If $n < 0$, let\n            /// $$\n            /// 2^W + n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where\n            /// - $W$ is the type's width\n            /// - for all $i$, $b_i\\in \\\\{0, 1\\\\}$, and $b_i = 1$ for $i \\geq W$.\n            ///\n            /// Then\n            /// $$\n            /// f(n, p, q) = \\sum_{i=p}^{q-1} 2^{b_{i-p}}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Let `W` be the type's width. Panics if `start < end` or (`self < 0` and `end - start\n            /// > W`).\n            ///\n            /// # Examples\n            /// See [here](super::bit_block_access#get_bits).\n            #[inline]\n            fn get_bits(&self, start: u64, end: u64) -> Self::Bits {\n                get_bits_signed(self, start, end)\n            }\n\n            /// Replaces a block of adjacent bits in a number with other bits.\n            ///\n            /// The least-significant `end - start` bits of `bits` are assigned to bits `start`\n            /// through `end - 1`, inclusive, of `self`.\n            ///\n            /// The type of the block of bits is the unsigned version of the input type. If `bits`\n            /// has fewer bits than `end - start`, the high bits are interpreted as 0 or 1,\n            /// depending on the sign of `self`. If `end` is greater than the type's width, the high\n            /// bits of `bits` must be 0 or 1, depending on the sign of `self`.\n            ///\n            /// The sign of `self` remains unchanged, since only a finite number of bits are changed\n            /// and the sign is determined by the implied infinite prefix of bits.\n            ///\n            /// If $n \\geq 0$ and $j \\neq W - 1$, let\n            /// $$\n            /// n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$ and $W$ is `$t::WIDTH`. Let\n            /// $$\n            /// m = \\sum_{i=0}^k 2^{d_i},\n            /// $$\n            /// where for all $i$, $d_i\\in \\\\{0, 1\\\\}$. Also, let $p, q \\in \\mathbb{N}$, where $d_i\n            /// = 0$ for all $i \\geq W + p - 1$. Then\n            /// $$\n            /// n \\gets \\sum_{i=0}^{W-1} 2^{c_i},\n            /// $$\n            /// where\n            /// $$\n            /// \\\\{c_0, c_1, c_2, \\ldots, c_ {W-1}\\\\} =\n            /// \\\\{b_0, b_1, b_2, \\ldots, b_{p-1}, d_0, d_1, \\ldots, d_{p-q-1}, b_q, \\ldots,\n            /// b_ {W-1}\\\\}.\n            /// $$\n            ///\n            /// If $n < 0$ or $j = W - 1$, let\n            /// $$\n            /// 2^W + n = \\sum_{i=0}^{W-1} 2^{b_i},\n            /// $$\n            /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$ and $W$ is `$t::WIDTH`. Let\n            /// $$\n            /// m = \\sum_{i=0}^k 2^{d_i},\n            /// $$\n            /// where for all $i$, $d_i\\in \\\\{0, 1\\\\}$. Also, let $p, q \\in \\mathbb{N}$, where $d_i\n            /// = 1$ for all $i \\geq W + p - 1$. Then\n            /// $$\n            /// f(n, p, q, m) = \\left ( \\sum_{i=0}^{W-1} 2^{c_i} \\right ) - 2^W,\n            /// $$\n            /// where\n            /// $$\n            /// \\\\{c_0, c_1, c_2, \\ldots, c_ {W-1}\\\\} =\n            /// \\\\{b_0, b_1, b_2, \\ldots, b_{p-1}, d_0, d_1, \\ldots, d_{p-q-1}, b_q, \\ldots,\n            /// b_ {W-1}\\\\}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Let `W` be the type's width Panics if `start < end`, or if `end >= W` and bits `W -\n            /// start` through `end - start` of `bits` are not equal to the original sign bit of\n            /// `self`.\n            ///\n            /// # Examples\n            /// See [here](super::bit_block_access#assign_bits).\n            #[inline]\n            fn assign_bits(&mut self, start: u64, end: u64, bits: &Self::Bits) {\n                assign_bits_signed(self, start, end, bits)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_bit_block_access_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/bit_convertible.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::logic::traits::{BitConvertible, LeadingZeros};\nuse alloc::vec::Vec;\n\nfn to_bits_asc_unsigned<T: PrimitiveUnsigned>(x: &T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    let mut x = *x;\n    while x != T::ZERO {\n        bits.push(x.odd());\n        x >>= 1;\n    }\n    bits\n}\n\nfn to_bits_desc_unsigned<T: PrimitiveUnsigned>(x: &T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    if *x == T::ZERO {\n        return bits;\n    }\n    bits.push(true);\n    if *x == T::ONE {\n        return bits;\n    }\n    let mut mask = T::power_of_2(T::WIDTH - LeadingZeros::leading_zeros(*x) - 2);\n    while mask != T::ZERO {\n        bits.push(*x & mask != T::ZERO);\n        mask >>= 1;\n    }\n    bits\n}\n\nfn from_bits_asc_unsigned<T: PrimitiveUnsigned, I: Iterator<Item = bool>>(bits: I) -> T {\n    let mut n = T::ZERO;\n    let mut mask = T::ONE;\n    for bit in bits {\n        if mask == T::ZERO {\n            assert!(!bit, \"Bits cannot fit in integer of type {}\", T::NAME);\n        } else {\n            if bit {\n                n |= mask;\n            }\n            mask <<= 1;\n        }\n    }\n    n\n}\n\n#[inline]\nfn from_bits_desc_unsigned<T: PrimitiveUnsigned, I: Iterator<Item = bool>>(bits: I) -> T {\n    let mut n = T::ZERO;\n    let high_mask = T::power_of_2(T::WIDTH - 1);\n    for bit in bits {\n        assert!(\n            n & high_mask == T::ZERO,\n            \"Bits cannot fit in integer of type {}\",\n            T::NAME\n        );\n        n <<= 1;\n        if bit {\n            n |= T::ONE;\n        }\n    }\n    n\n}\n\nmacro_rules! impl_bit_convertible_unsigned {\n    ($t:ident) => {\n        impl BitConvertible for $t {\n            /// Returns a [`Vec`] containing the bits of a number in ascending order: least- to\n            /// most-significant.\n            ///\n            /// If the number is 0, the [`Vec`] is empty; otherwise, it ends with `true`.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#to_bits_asc).\n            #[inline]\n            fn to_bits_asc(&self) -> Vec<bool> {\n                to_bits_asc_unsigned(self)\n            }\n\n            /// Returns a [`Vec`] containing the bits of a number in descending order: most- to\n            /// least-significant.\n            ///\n            /// If the number is 0, the [`Vec`] is empty; otherwise, it begins with `true`.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#to_bits_desc).\n            #[inline]\n            fn to_bits_desc(&self) -> Vec<bool> {\n                to_bits_desc_unsigned(self)\n            }\n\n            /// Converts an iterator of bits into a number. The bits should be in ascending order\n            /// (least- to most-significant).\n            ///\n            /// The function panics if the input represents a number that can't fit in the output\n            /// type.\n            ///\n            /// $$\n            /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^i \\[b_i\\],\n            /// $$\n            /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `bits.count()`.\n            ///\n            /// # Panics\n            /// Panics if the bits represent a value that isn't representable by the output type.\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#from_bits_asc).\n            #[inline]\n            fn from_bits_asc<I: Iterator<Item = bool>>(bits: I) -> $t {\n                from_bits_asc_unsigned(bits)\n            }\n\n            /// Converts an iterator of bits into a number. The bits should be in descending order\n            /// (most- to least-significant).\n            ///\n            /// The function panics if the input represents a number that can't fit in the output\n            /// type.\n            ///\n            /// $$\n            /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^{k-i-1} \\[b_i\\],\n            /// $$\n            /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `bits.count()`.\n            ///\n            /// # Panics\n            /// Panics if the bits represent a value that isn't representable by the output type.\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#from_bits_desc).\n            #[inline]\n            fn from_bits_desc<I: Iterator<Item = bool>>(bits: I) -> $t {\n                from_bits_desc_unsigned(bits)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_bit_convertible_unsigned);\n\nfn to_bits_asc_signed<T: PrimitiveSigned>(x: &T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    let mut x = *x;\n    if x >= T::ZERO {\n        while x != T::ZERO {\n            bits.push(x.odd());\n            x >>= 1;\n        }\n        if !bits.is_empty() {\n            bits.push(false);\n        }\n    } else {\n        while x != T::NEGATIVE_ONE {\n            bits.push(x.odd());\n            x >>= 1;\n        }\n        bits.push(true);\n    }\n    bits\n}\n\nfn to_bits_desc_signed<T: PrimitiveSigned>(x: &T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    if *x >= T::ZERO {\n        if *x == T::ZERO {\n            return bits;\n        }\n        bits.push(false);\n        bits.push(true);\n        if *x == T::ONE {\n            return bits;\n        }\n        let mut mask = T::power_of_2(T::WIDTH - LeadingZeros::leading_zeros(*x) - 2);\n        while mask != T::ZERO {\n            bits.push(*x & mask != T::ZERO);\n            mask >>= 1;\n        }\n    } else {\n        bits.push(true);\n        if *x == T::NEGATIVE_ONE {\n            return bits;\n        }\n        bits.push(false);\n        if *x == T::NEGATIVE_ONE << 1 {\n            return bits;\n        }\n        let mut mask = T::power_of_2(T::WIDTH - LeadingZeros::leading_zeros(!*x) - 2);\n        while mask != T::ZERO {\n            bits.push(*x & mask != T::ZERO);\n            mask >>= 1;\n        }\n    }\n    bits\n}\n\nfn from_bits_asc_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    I: Iterator<Item = bool>,\n>(\n    bits: I,\n) -> S {\n    let mut n = U::ZERO;\n    let mut mask = U::ONE;\n    let mut last_bit = false;\n    for bit in bits {\n        if mask == U::ZERO {\n            assert_eq!(\n                bit,\n                last_bit,\n                \"Bits cannot fit in integer of type {}\",\n                S::NAME\n            );\n        } else {\n            if bit {\n                n |= mask;\n            }\n            mask <<= 1;\n            last_bit = bit;\n        }\n    }\n    if last_bit {\n        S::wrapping_from(n | mask.wrapping_neg())\n    } else {\n        S::wrapping_from(n)\n    }\n}\n\n#[inline]\nfn from_bits_desc_signed<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    I: Iterator<Item = bool>,\n>(\n    bits: I,\n) -> S {\n    let mut n = U::ZERO;\n    let high_mask = U::power_of_2(U::WIDTH - 2);\n    let mut first = true;\n    let mut sign_bit = false;\n    for bit in bits {\n        if first {\n            sign_bit = bit;\n            first = false;\n        } else {\n            assert!(\n                n & high_mask == U::ZERO,\n                \"Bits cannot fit in integer of type {}\",\n                S::NAME\n            );\n            n <<= 1;\n            if bit != sign_bit {\n                n |= U::ONE;\n            }\n        }\n    }\n    if sign_bit {\n        S::wrapping_from(!n)\n    } else {\n        S::wrapping_from(n)\n    }\n}\n\nmacro_rules! impl_bit_convertible_signed {\n    ($u:ident, $s:ident) => {\n        impl BitConvertible for $s {\n            /// Returns a [`Vec`] containing the bits of a number in ascending order: least- to\n            /// most-significant.\n            ///\n            /// If the number is 0, the [`Vec`] is empty; otherwise, the last bit is the sign bit:\n            /// `false` if the number is non-negative and `true` if it is negative.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#to_bits_asc).\n            #[inline]\n            fn to_bits_asc(&self) -> Vec<bool> {\n                to_bits_asc_signed(self)\n            }\n\n            /// Returns a [`Vec`] containing the bits of a number in ascending order: most- to\n            /// least-significant.\n            ///\n            /// If the number is 0, the [`Vec`] is empty; otherwise, the first bit is the sign bit:\n            /// `false` if the number is non-negative and `true` if it is negative.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#to_bits_desc).\n            #[inline]\n            fn to_bits_desc(&self) -> Vec<bool> {\n                to_bits_desc_signed(self)\n            }\n\n            /// Converts an iterator of bits into a value. The bits should be in ascending order\n            /// (least- to most-significant).\n            ///\n            /// The bits are interpreted as in twos-complement, and the last bit is the sign bit; if\n            /// it is `false`, the number is non-negative, and if it is `true`, the number is\n            /// negative.\n            ///\n            /// The function panics if the input represents a number that can't fit in the output\n            /// type.\n            ///\n            /// Let $k$ be `bits.count()`. If $k = 0$ or $b_{k-1}$ is `false`, then\n            /// $$\n            /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^i \\[b_i\\],\n            /// $$\n            /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n            ///\n            /// If $b_{k-1}$ is `true`, then\n            /// $$\n            /// f((b_i)_ {i=0}^{k-1}) = \\left ( \\sum_{i=0}^{k-1}2^i \\[b_i\\] \\right ) - 2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `bits.count()`.\n            ///\n            /// # Panics\n            /// Panics if the bits represent a value that doesn't fit in the output type.\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#from_bits_asc).\n            #[inline]\n            fn from_bits_asc<I: Iterator<Item = bool>>(bits: I) -> $s {\n                from_bits_asc_signed::<$u, $s, _>(bits)\n            }\n\n            /// Converts an iterator of bits into a value. The bits should be in descending order\n            /// (most- to least-significant).\n            ///\n            /// The bits are interpreted as in twos-complement, and the first bit is the sign bit;\n            /// if it is `false`, the number is non-negative, and if it is `true`, the number is\n            /// negative.\n            ///\n            /// The function panics if the input represents a number that can't fit in the output\n            /// type.\n            ///\n            /// If `bits` is empty or $b_0$ is `false`, then\n            /// $$\n            /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^{k-i-1} \\[b_i\\],\n            /// $$\n            /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n            ///\n            /// If $b_0$ is `true`, then\n            /// $$\n            /// f((b_i)_ {i=0}^{k-1}) = \\left ( \\sum_{i=0}^{k-1}2^{k-i-1} \\[b_i\\] \\right ) - 2^k.\n            /// $$\n            ///\n            /// # Examples\n            /// See [here](super::bit_convertible#from_bits_desc).\n            #[inline]\n            fn from_bits_desc<I: Iterator<Item = bool>>(bits: I) -> $s {\n                from_bits_desc_signed::<$u, $s, _>(bits)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_bit_convertible_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/bit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::logic::traits::BitIterable;\nuse core::cmp::Ordering::*;\nuse core::cmp::min;\nuse core::marker::PhantomData;\nuse core::ops::Index;\n\n/// A double-ended iterator over the bits of an unsigned primitive integer.\n///\n/// This `struct` is created by [`BitIterable::bits`]; see its documentation for more.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct PrimitiveUnsignedBitIterator<T: PrimitiveUnsigned> {\n    pub(crate) value: T,\n    pub(crate) remaining: usize,\n    // If `n` is nonzero, this mask initially points to the least-significant bit, and is left-\n    // shifted by next().\n    pub(crate) i_mask: T,\n    // If `n` is nonzero, this mask initially points to the most-significant nonzero bit, and is\n    // right-shifted by next_back().\n    pub(crate) j_mask: T,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for PrimitiveUnsignedBitIterator<T> {\n    type Item = bool;\n\n    fn next(&mut self) -> Option<bool> {\n        if self.remaining != 0 {\n            let bit = self.value & self.i_mask != T::ZERO;\n            self.i_mask <<= 1;\n            self.remaining -= 1;\n            Some(bit)\n        } else {\n            None\n        }\n    }\n\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl<T: PrimitiveUnsigned> DoubleEndedIterator for PrimitiveUnsignedBitIterator<T> {\n    fn next_back(&mut self) -> Option<bool> {\n        if self.remaining != 0 {\n            let bit = self.value & self.j_mask != T::ZERO;\n            self.j_mask >>= 1;\n            self.remaining -= 1;\n            Some(bit)\n        } else {\n            None\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> ExactSizeIterator for PrimitiveUnsignedBitIterator<T> {}\n\nimpl<T: PrimitiveUnsigned> Index<u64> for PrimitiveUnsignedBitIterator<T> {\n    type Output = bool;\n\n    /// A function to retrieve bits by index.\n    ///\n    /// The index is the power of 2 of which the bit is a coefficient. Indexing at or above the\n    /// significant bit count returns false bits.\n    ///\n    /// This is equivalent to [`get_bit`](super::traits::BitAccess::get_bit).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitIterable;\n    ///\n    /// assert_eq!(0u8.bits()[0], false);\n    ///\n    /// // 105 = 1101001b\n    /// let bits = 105u32.bits();\n    /// assert_eq!(bits[0], true);\n    /// assert_eq!(bits[1], false);\n    /// assert_eq!(bits[2], false);\n    /// assert_eq!(bits[3], true);\n    /// assert_eq!(bits[4], false);\n    /// assert_eq!(bits[5], true);\n    /// assert_eq!(bits[6], true);\n    /// assert_eq!(bits[7], false);\n    /// assert_eq!(bits[100], false);\n    /// ```\n    fn index(&self, index: u64) -> &bool {\n        if self.value.get_bit(index) {\n            &true\n        } else {\n            &false\n        }\n    }\n}\n\nfn bits_unsigned<T: PrimitiveUnsigned>(x: T) -> PrimitiveUnsignedBitIterator<T> {\n    let significant_bits = x.significant_bits();\n    PrimitiveUnsignedBitIterator {\n        value: x,\n        remaining: usize::exact_from(significant_bits),\n        i_mask: T::ONE,\n        j_mask: T::power_of_2(significant_bits.saturating_sub(1)),\n    }\n}\n\nmacro_rules! impl_bit_iterable_unsigned {\n    ($t:ident) => {\n        impl BitIterable for $t {\n            type BitIterator = PrimitiveUnsignedBitIterator<$t>;\n\n            /// Returns a double-ended iterator over the bits of an unsigned primitive integer.\n            ///\n            /// The forward order is ascending, so that less significant bits appear first. There\n            /// are no trailing false bits going forward, or leading falses going backward.\n            ///\n            /// If it's necessary to get a [`Vec`] of all the bits, consider using\n            /// [`to_bits_asc`](super::traits::BitConvertible::to_bits_asc) or\n            /// [`to_bits_desc`](super::traits::BitConvertible::to_bits_desc) instead.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_iterable#bits).\n            #[inline]\n            fn bits(self) -> PrimitiveUnsignedBitIterator<$t> {\n                bits_unsigned(self)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_bit_iterable_unsigned);\n\n/// A double-ended iterator over the bits of a signed primitive integer.\n///\n/// This `struct` is created by [`BitIterable::bits`]; see its documentation for more.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct PrimitiveSignedBitIterator<U: PrimitiveUnsigned, S: PrimitiveSigned> {\n    phantom: PhantomData<*const S>,\n    xs: PrimitiveUnsignedBitIterator<U>,\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned> Iterator for PrimitiveSignedBitIterator<U, S> {\n    type Item = bool;\n\n    #[inline]\n    fn next(&mut self) -> Option<bool> {\n        self.xs.next()\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        self.xs.size_hint()\n    }\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned> DoubleEndedIterator\n    for PrimitiveSignedBitIterator<U, S>\n{\n    #[inline]\n    fn next_back(&mut self) -> Option<bool> {\n        self.xs.next_back()\n    }\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned> ExactSizeIterator\n    for PrimitiveSignedBitIterator<U, S>\n{\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned> Index<u64> for PrimitiveSignedBitIterator<U, S> {\n    type Output = bool;\n\n    /// A function to retrieve bits by index. The index is the power of 2 of which the bit is a\n    /// coefficient.\n    ///\n    /// Indexing at or above the significant bit count returns false or true bits, depending on the\n    /// value's sign.\n    ///\n    /// This is equivalent to [`get_bit`](super::traits::BitAccess::get_bit).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitIterable;\n    ///\n    /// assert_eq!(0i8.bits()[0], false);\n    ///\n    /// // -105 = 10010111 in two's complement\n    /// let bits = (-105i32).bits();\n    /// assert_eq!(bits[0], true);\n    /// assert_eq!(bits[1], true);\n    /// assert_eq!(bits[2], true);\n    /// assert_eq!(bits[3], false);\n    /// assert_eq!(bits[4], true);\n    /// assert_eq!(bits[5], false);\n    /// assert_eq!(bits[6], false);\n    /// assert_eq!(bits[7], true);\n    /// assert_eq!(bits[100], true);\n    /// ```\n    fn index(&self, index: u64) -> &bool {\n        if self.xs[min(index, U::WIDTH - 1)] {\n            &true\n        } else {\n            &false\n        }\n    }\n}\n\nfn bits_signed<U: PrimitiveUnsigned + WrappingFrom<S>, S: PrimitiveSigned>(\n    x: S,\n) -> PrimitiveSignedBitIterator<U, S> {\n    let unsigned = U::wrapping_from(x);\n    let significant_bits = match x.sign() {\n        Equal => 0,\n        Greater => unsigned.significant_bits() + 1,\n        Less => (!unsigned).significant_bits() + 1,\n    };\n    PrimitiveSignedBitIterator {\n        phantom: PhantomData,\n        xs: PrimitiveUnsignedBitIterator {\n            value: unsigned,\n            remaining: usize::exact_from(significant_bits),\n            i_mask: U::ONE,\n            j_mask: U::power_of_2(significant_bits.saturating_sub(1)),\n        },\n    }\n}\n\nmacro_rules! impl_bit_iterable_signed {\n    ($u:ident, $s:ident) => {\n        impl BitIterable for $s {\n            type BitIterator = PrimitiveSignedBitIterator<$u, $s>;\n\n            /// Returns a double-ended iterator over the bits of a signed primitive integer.\n            ///\n            /// The forward order is ascending, so that less significant bits appear first. There\n            /// are no trailing sign bits going forward, or leading sign bits going backward.\n            ///\n            /// If it's necessary to get a [`Vec`] of all the bits, consider using\n            /// [`to_bits_asc`](super::traits::BitConvertible::to_bits_asc) or\n            /// [`to_bits_desc`](super::traits::BitConvertible::to_bits_desc) instead.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_iterable#bits).\n            #[inline]\n            fn bits(self) -> PrimitiveSignedBitIterator<$u, $s> {\n                bits_signed::<$u, $s>(self)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_bit_iterable_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/bit_scan.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::logic::traits::{BitScan, TrailingZeros};\n\nfn index_of_next_false_bit_unsigned<T: PrimitiveUnsigned>(x: T, start: u64) -> u64 {\n    if start >= T::WIDTH {\n        start\n    } else {\n        TrailingZeros::trailing_zeros(!(x | T::low_mask(start)))\n    }\n}\n\nfn index_of_next_true_bit_unsigned<T: PrimitiveUnsigned>(x: T, start: u64) -> Option<u64> {\n    if start >= T::WIDTH {\n        None\n    } else {\n        let index = TrailingZeros::trailing_zeros(x & !T::low_mask(start));\n        if index == T::WIDTH { None } else { Some(index) }\n    }\n}\n\nmacro_rules! impl_bit_scan_unsigned {\n    ($t:ident) => {\n        impl BitScan for $t {\n            /// Given a number and a starting index, searches the number for the smallest index of a\n            /// `false` bit that is greater than or equal to the starting index.\n            ///\n            /// Since the number is unsigned and therefore has an implicit prefix of infinitely-many\n            /// zeros, this function always returns a value.\n            ///\n            /// Starting beyond the type's width is allowed; the result is the starting index.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_scan#index_of_next_false_bit).\n            #[inline]\n            fn index_of_next_false_bit(self, start: u64) -> Option<u64> {\n                Some(index_of_next_false_bit_unsigned(self, start))\n            }\n\n            /// Given a number and a starting index, searches the number for the smallest index of a\n            /// `true` bit that is greater than or equal to the starting index.\n            ///\n            /// If the starting index is greater than or equal to the type's width, the result is\n            /// `None` since there are no `true` bits past that point.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_scan#index_of_next_true_bit).\n            #[inline]\n            fn index_of_next_true_bit(self, start: u64) -> Option<u64> {\n                index_of_next_true_bit_unsigned(self, start)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_bit_scan_unsigned);\n\nfn index_of_next_false_bit_signed<T: PrimitiveSigned>(x: T, start: u64) -> Option<u64> {\n    if start >= T::WIDTH - 1 {\n        if x >= T::ZERO { Some(start) } else { None }\n    } else {\n        let index = TrailingZeros::trailing_zeros(!(x | T::low_mask(start)));\n        if index == T::WIDTH { None } else { Some(index) }\n    }\n}\n\nfn index_of_next_true_bit_signed<T: PrimitiveSigned>(x: T, start: u64) -> Option<u64> {\n    if start >= T::WIDTH - 1 {\n        if x >= T::ZERO { None } else { Some(start) }\n    } else {\n        let index = TrailingZeros::trailing_zeros(x & !T::low_mask(start));\n        if index == T::WIDTH { None } else { Some(index) }\n    }\n}\n\nmacro_rules! impl_bit_scan_signed {\n    ($t:ident) => {\n        impl BitScan for $t {\n            /// Given a number and a starting index, searches the number for the smallest index of a\n            /// `false` bit that is greater than or equal to the starting index.\n            ///\n            /// If the starting index is greater than or equal to the type's width, then the result\n            /// depends on whether the number is negative. If it is, then the result is `None` since\n            /// there are no `false` bits past that point. If the number is non-negative, then the\n            /// result is the starting index.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_scan#index_of_next_false_bit).\n            #[inline]\n            fn index_of_next_false_bit(self, start: u64) -> Option<u64> {\n                index_of_next_false_bit_signed(self, start)\n            }\n\n            /// Given a number and a starting index, searches the number for the smallest index of a\n            /// `true` bit that is greater than or equal to the starting index.\n            ///\n            /// If the starting index is greater than or equal to the type's width, then the result\n            /// depends on whether the number is non-negative. If it is, then the result is `None`\n            /// since there are no `true` bits past that point. If the number is negative, then the\n            /// result is the starting index.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::bit_scan#index_of_next_true_bit).\n            #[inline]\n            fn index_of_next_true_bit(self, start: u64) -> Option<u64> {\n                index_of_next_true_bit_signed(self, start)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_bit_scan_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::logic::traits::CountOnes;\n\nmacro_rules! impl_count_ones {\n    ($t:ident) => {\n        impl CountOnes for $t {\n            /// This is a wrapper over the `count_ones` functions in the standard library, for\n            /// example [this one](u32::count_ones).\n            #[inline]\n            fn count_ones(self) -> u64 {\n                u64::from($t::count_ones(self))\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_count_ones);\n"
  },
  {
    "path": "malachite-base/src/num/logic/count_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::logic::traits::CountZeros;\n\nmacro_rules! impl_count_zeros {\n    ($t:ident) => {\n        impl CountZeros for $t {\n            /// This is a wrapper over the `count_zeros` functions in the standard library, for\n            /// example [this one](u32::count_zeros).\n            #[inline]\n            fn count_zeros(self) -> u64 {\n                u64::from($t::count_zeros(self))\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_count_zeros);\n"
  },
  {
    "path": "malachite-base/src/num/logic/hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::logic::traits::{CheckedHammingDistance, CountOnes, HammingDistance};\n\nfn hamming_distance_unsigned<T: PrimitiveUnsigned>(x: T, y: T) -> u64 {\n    CountOnes::count_ones(x ^ y)\n}\n\nmacro_rules! impl_hamming_distance_unsigned {\n    ($t:ident) => {\n        impl HammingDistance<$t> for $t {\n            /// Returns the Hamming distance between two numbers, or the number of bit flips needed\n            /// to turn one into the other.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::hamming_distance#hamming_distance).\n            #[inline]\n            fn hamming_distance(self, other: $t) -> u64 {\n                hamming_distance_unsigned(self, other)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_hamming_distance_unsigned);\n\nfn checked_hamming_distance_signed<T: PrimitiveSigned>(x: T, y: T) -> Option<u64> {\n    if (x >= T::ZERO) == (y >= T::ZERO) {\n        Some(CountOnes::count_ones(x ^ y))\n    } else {\n        None\n    }\n}\n\nmacro_rules! impl_checked_hamming_distance_signed {\n    ($t:ident) => {\n        impl CheckedHammingDistance<$t> for $t {\n            /// Returns the Hamming distance between two numbers, or the number of bit flips needed\n            /// to turn one into the other.\n            ///\n            /// If the two numbers have opposite signs, then the number of flips would be infinite,\n            /// so the result is `None`.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::hamming_distance#checked_hamming_distance).\n            #[inline]\n            fn checked_hamming_distance(self, other: $t) -> Option<u64> {\n                checked_hamming_distance_signed(self, other)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_checked_hamming_distance_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/leading_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::logic::traits::LeadingZeros;\n\nmacro_rules! impl_leading_zeros {\n    ($t:ident) => {\n        impl LeadingZeros for $t {\n            /// This is a wrapper over the `leading_zeros` functions in the standard library, for\n            /// example [this one](u32::leading_zeros).\n            #[inline]\n            fn leading_zeros(self) -> u64 {\n                u64::from($t::leading_zeros(self))\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_leading_zeros);\n"
  },
  {
    "path": "malachite-base/src/num/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::logic::traits::LowMask;\n\nfn low_mask_unsigned<T: PrimitiveUnsigned>(bits: u64) -> T {\n    assert!(bits <= T::WIDTH);\n    if bits == T::WIDTH {\n        T::MAX\n    } else {\n        T::power_of_2(bits) - T::ONE\n    }\n}\n\nmacro_rules! impl_low_mask_unsigned {\n    ($t:ident) => {\n        impl LowMask for $t {\n            /// Returns a number whose least significant $b$ bits are `true` and whose other bits\n            /// are `false`.\n            ///\n            /// $f(b) = 2^b - 1$.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `bits` is greater than the width of of the type.\n            ///\n            /// # Examples\n            /// See [here](super::low_mask#low_mask).\n            #[inline]\n            fn low_mask(bits: u64) -> $t {\n                low_mask_unsigned(bits)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_low_mask_unsigned);\n\nfn low_mask_signed<T: PrimitiveSigned>(bits: u64) -> T {\n    assert!(bits <= T::WIDTH);\n    if bits == T::WIDTH {\n        T::NEGATIVE_ONE\n    } else if bits == T::WIDTH - 1 {\n        T::MAX\n    } else {\n        T::power_of_2(bits) - T::ONE\n    }\n}\n\nmacro_rules! impl_low_mask_signed {\n    ($t:ident) => {\n        impl LowMask for $t {\n            /// Returns a number whose least significant $b$ bits are `true` and whose other bits\n            /// are `false`.\n            ///\n            /// $$\n            /// f(b) = \\\\begin{cases}\n            ///     2^b - 1 & \\text{if} \\\\quad 0 \\leq n < W, \\\\\\\\\n            ///     -1 & \\text{if} \\\\quad n = W,\n            /// \\\\end{cases}\n            /// $$\n            /// where $W$ is the width of the type.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if `bits` is greater than the width of the type.\n            ///\n            /// # Examples\n            /// See [here](super::low_mask#low_mask).\n            #[inline]\n            fn low_mask(bits: u64) -> $t {\n                low_mask_signed(bits)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_low_mask_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// [`BitAccess`](traits::BitAccess), a trait for getting and setting individual bits of a number.\n///\n/// # get_bit\n/// ```\n/// use malachite_base::num::logic::traits::BitAccess;\n///\n/// assert_eq!(123u8.get_bit(2), false);\n/// assert_eq!(123u16.get_bit(3), true);\n/// assert_eq!(123u32.get_bit(100), false);\n/// assert_eq!(1000000000000u64.get_bit(12), true);\n/// assert_eq!(1000000000000u64.get_bit(100), false);\n///\n/// assert_eq!(123i8.get_bit(2), false);\n/// assert_eq!(123i16.get_bit(3), true);\n/// assert_eq!(123i32.get_bit(100), false);\n/// assert_eq!((-123i8).get_bit(0), true);\n/// assert_eq!((-123i16).get_bit(1), false);\n/// assert_eq!((-123i32).get_bit(100), true);\n/// assert_eq!(1000000000000i64.get_bit(12), true);\n/// assert_eq!(1000000000000i64.get_bit(100), false);\n/// assert_eq!((-1000000000000i64).get_bit(12), true);\n/// assert_eq!((-1000000000000i64).get_bit(100), true);\n/// ```\n///\n/// # set_bit\n/// ```\n/// use malachite_base::num::logic::traits::BitAccess;\n///\n/// let mut x = 0u8;\n/// x.set_bit(2);\n/// x.set_bit(5);\n/// x.set_bit(6);\n/// assert_eq!(x, 100);\n///\n/// let mut x = 0i8;\n/// x.set_bit(2);\n/// x.set_bit(5);\n/// x.set_bit(6);\n/// assert_eq!(x, 100);\n///\n/// let mut x = -0x100i16;\n/// x.set_bit(2);\n/// x.set_bit(5);\n/// x.set_bit(6);\n/// assert_eq!(x, -156);\n/// ```\n///\n/// # clear_bit\n/// ```\n/// use malachite_base::num::logic::traits::BitAccess;\n///\n/// let mut x = 0x7fu8;\n/// x.clear_bit(0);\n/// x.clear_bit(1);\n/// x.clear_bit(3);\n/// x.clear_bit(4);\n/// assert_eq!(x, 100);\n///\n/// let mut x = 0x7fi8;\n/// x.clear_bit(0);\n/// x.clear_bit(1);\n/// x.clear_bit(3);\n/// x.clear_bit(4);\n/// assert_eq!(x, 100);\n///\n/// let mut x = -156i16;\n/// x.clear_bit(2);\n/// x.clear_bit(5);\n/// x.clear_bit(6);\n/// assert_eq!(x, -256);\n/// ```\n///\n/// # assign_bit\n/// ```\n/// use malachite_base::num::logic::traits::BitAccess;\n///\n/// let mut x = 0;\n/// x.assign_bit(2, true);\n/// x.assign_bit(5, true);\n/// x.assign_bit(6, true);\n/// assert_eq!(x, 100);\n/// x.assign_bit(2, false);\n/// x.assign_bit(5, false);\n/// x.assign_bit(6, false);\n/// assert_eq!(x, 0);\n///\n/// x.assign_bit(2, true);\n/// x.assign_bit(5, true);\n/// x.assign_bit(6, true);\n/// assert_eq!(x, 100);\n/// x.assign_bit(2, false);\n/// x.assign_bit(5, false);\n/// x.assign_bit(6, false);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -0x100i16;\n/// x.assign_bit(2, true);\n/// x.assign_bit(5, true);\n/// x.assign_bit(6, true);\n/// assert_eq!(x, -156);\n/// x.assign_bit(2, false);\n/// x.assign_bit(5, false);\n/// x.assign_bit(6, false);\n/// assert_eq!(x, -256);\n/// ```\n///\n/// # flip_bit\n/// ```\n/// use malachite_base::num::logic::traits::BitAccess;\n///\n/// let mut x = 0u64;\n/// x.flip_bit(10);\n/// assert_eq!(x, 1024);\n/// x.flip_bit(10);\n/// assert_eq!(x, 0);\n///\n/// let mut x = 0i32;\n/// x.flip_bit(10);\n/// assert_eq!(x, 1024);\n/// x.flip_bit(10);\n/// assert_eq!(x, 0);\n///\n/// let mut x = -1i64;\n/// x.flip_bit(10);\n/// assert_eq!(x, -1025);\n/// x.flip_bit(10);\n/// assert_eq!(x, -1);\n/// ```\npub mod bit_access;\n/// [`BitBlockAccess`](traits::BitBlockAccess), a trait for getting and setting adjacent blocks of\n/// bits in a number.\n///\n/// # get_bits\n/// ```\n/// use malachite_base::num::logic::traits::BitBlockAccess;\n///\n/// assert_eq!(0xabcdu16.get_bits(4, 8), 0xc);\n/// assert_eq!(0xabcdu16.get_bits(12, 100), 0xa);\n/// assert_eq!(0xabcdu16.get_bits(5, 9), 14);\n/// assert_eq!(0xabcdu16.get_bits(5, 5), 0);\n/// assert_eq!(0xabcdu16.get_bits(100, 200), 0);\n///\n/// assert_eq!((-0x5433i16).get_bits(4, 8), 0xc);\n/// assert_eq!((-0x5433i16).get_bits(5, 9), 14);\n/// assert_eq!((-0x5433i16).get_bits(5, 5), 0);\n/// assert_eq!((-0x5433i16).get_bits(100, 104), 0xf);\n/// ```\n///\n/// # assign_bits\n/// ```\n/// use malachite_base::num::logic::traits::BitBlockAccess;\n///\n/// let mut x = 0xab5du16;\n/// x.assign_bits(4, 8, &0xc);\n/// assert_eq!(x, 0xabcd);\n///\n/// let mut x = 0xabcdu16;\n/// x.assign_bits(100, 200, &0);\n/// assert_eq!(x, 0xabcd);\n///\n/// let mut x = 0xabcdu16;\n/// x.assign_bits(0, 100, &0x1234);\n/// assert_eq!(x, 0x1234);\n///\n/// let mut x = 0x2b5di16;\n/// x.assign_bits(4, 8, &0xc);\n/// assert_eq!(x, 0x2bcd);\n///\n/// let mut x = -0x5413i16;\n/// x.assign_bits(4, 8, &0xc);\n/// assert_eq!(x, -0x5433);\n///\n/// let mut x = -0x5433i16;\n/// x.assign_bits(100, 104, &0xf);\n/// assert_eq!(x, -0x5433);\n/// ```\npub mod bit_block_access;\n/// [`BitConvertible`](traits::BitConvertible), a trait for extracting all bits from a number or\n/// constructing a number from bits.\n///\n/// # to_bits_asc\n/// ```\n/// use malachite_base::num::logic::traits::BitConvertible;\n///\n/// assert_eq!(0u8.to_bits_asc(), &[]);\n/// assert_eq!(2u16.to_bits_asc(), &[false, true]);\n/// assert_eq!(\n///     123u32.to_bits_asc(),\n///     &[true, true, false, true, true, true, true]\n/// );\n///\n/// assert_eq!(0i8.to_bits_asc(), &[]);\n/// assert_eq!(2i16.to_bits_asc(), &[false, true, false]);\n/// assert_eq!(\n///     (-123i32).to_bits_asc(),\n///     &[true, false, true, false, false, false, false, true]\n/// );\n/// ```\n///\n/// # to_bits_desc\n/// ```\n/// use malachite_base::num::logic::traits::BitConvertible;\n///\n/// assert_eq!(0u8.to_bits_desc(), &[]);\n/// assert_eq!(2u16.to_bits_desc(), &[true, false]);\n/// assert_eq!(\n///     123u32.to_bits_desc(),\n///     &[true, true, true, true, false, true, true]\n/// );\n///\n/// assert_eq!(0i8.to_bits_desc(), &[]);\n/// assert_eq!(2i16.to_bits_desc(), &[false, true, false]);\n/// assert_eq!(\n///     (-123i32).to_bits_desc(),\n///     &[true, false, false, false, false, true, false, true]\n/// );\n/// ```\n///\n/// # from_bits_asc\n/// ```\n/// use malachite_base::num::logic::traits::BitConvertible;\n/// use std::iter::empty;\n///\n/// assert_eq!(u8::from_bits_asc(empty()), 0);\n/// assert_eq!(u16::from_bits_asc([false, true, false].iter().cloned()), 2);\n/// assert_eq!(\n///     u32::from_bits_asc([true, true, false, true, true, true, true].iter().cloned()),\n///     123\n/// );\n///\n/// assert_eq!(i8::from_bits_asc(empty()), 0);\n/// assert_eq!(i16::from_bits_asc([false, true, false].iter().cloned()), 2);\n/// assert_eq!(\n///     i32::from_bits_asc(\n///         [true, false, true, false, false, false, false, true]\n///             .iter()\n///             .cloned()\n///     ),\n///     -123\n/// );\n/// ```\n///\n/// # from_bits_desc\n/// ```\n/// use malachite_base::num::logic::traits::BitConvertible;\n/// use std::iter::empty;\n///\n/// assert_eq!(u8::from_bits_desc(empty()), 0);\n/// assert_eq!(u16::from_bits_desc([false, true, false].iter().cloned()), 2);\n/// assert_eq!(\n///     u32::from_bits_desc([true, true, true, true, false, true, true].iter().cloned()),\n///     123\n/// );\n///\n/// assert_eq!(i8::from_bits_desc(empty()), 0);\n/// assert_eq!(i16::from_bits_desc([false, true, false].iter().cloned()), 2);\n/// assert_eq!(\n///     i32::from_bits_desc(\n///         [true, false, false, false, false, true, false, true]\n///             .iter()\n///             .cloned()\n///     ),\n///     -123\n/// );\n/// ```\npub mod bit_convertible;\n/// [`BitIterable`](traits::BitIterable), a trait for producing a double-ended iterator over a\n/// number's bits.\n///\n/// # bits\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::logic::traits::BitIterable;\n///\n/// assert!(0u8.bits().next().is_none());\n/// // 105 = 1101001b\n/// assert_eq!(\n///     105u32.bits().collect_vec(),\n///     &[true, false, false, true, false, true, true]\n/// );\n///\n/// assert!(0u8.bits().next_back().is_none());\n/// // 105 = 1101001b\n/// assert_eq!(\n///     105u32.bits().rev().collect_vec(),\n///     &[true, true, false, true, false, false, true]\n/// );\n///\n/// assert_eq!(0i8.bits().next(), None);\n/// // 105 = 01101001b, with a leading false bit to indicate sign\n/// assert_eq!(\n///     105i32.bits().collect_vec(),\n///     &[true, false, false, true, false, true, true, false]\n/// );\n/// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n/// assert_eq!(\n///     (-105i32).bits().collect_vec(),\n///     &[true, true, true, false, true, false, false, true]\n/// );\n///\n/// assert_eq!(0i8.bits().next_back(), None);\n/// // 105 = 01101001b, with a leading false bit to indicate sign\n/// assert_eq!(\n///     105i32.bits().rev().collect_vec(),\n///     &[false, true, true, false, true, false, false, true]\n/// );\n/// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n/// assert_eq!(\n///     (-105i32).bits().rev().collect_vec(),\n///     &[true, false, false, true, false, true, true, true]\n/// );\n/// ```\npub mod bit_iterable;\n/// [`BitScan`](traits::BitScan), a trait for finding the next `true` or `false` bit in a number\n/// after a provided index.\n///\n/// # index_of_next_false_bit\n/// ```\n/// use malachite_base::num::logic::traits::BitScan;\n///\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(0), Some(0));\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(20), Some(20));\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(31), Some(31));\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(32), Some(34));\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(33), Some(34));\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(34), Some(34));\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(35), Some(36));\n/// assert_eq!(0xb00000000u64.index_of_next_false_bit(100), Some(100));\n///\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(0), Some(0));\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(20), Some(20));\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(31), Some(31));\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(32), Some(34));\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(33), Some(34));\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(34), Some(34));\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(35), None);\n/// assert_eq!((-0x500000000i64).index_of_next_false_bit(100), None);\n/// ```\n///\n/// # index_of_next_true_bit\n/// ```\n/// use malachite_base::num::logic::traits::BitScan;\n///\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(0), Some(32));\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(20), Some(32));\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(31), Some(32));\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(32), Some(32));\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(33), Some(33));\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(34), Some(35));\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(35), Some(35));\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(36), None);\n/// assert_eq!(0xb00000000u64.index_of_next_true_bit(100), None);\n///\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(0), Some(32));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(20), Some(32));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(31), Some(32));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(32), Some(32));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(33), Some(33));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(34), Some(35));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(35), Some(35));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(36), Some(36));\n/// assert_eq!((-0x500000000i64).index_of_next_true_bit(100), Some(100));\n/// ```\npub mod bit_scan;\n/// [`CountOnes`](traits::CountOnes), a trait for counting the number of ones in the binary\n/// representation of a number.\npub mod count_ones;\n/// [`CountZeros`](traits::CountZeros), a trait for counting the number of ones in the binary\n/// representation of a number.\npub mod count_zeros;\n/// [`HammingDistance`](traits::HammingDistance) and\n/// [`CheckedHammingDistance`](traits::CheckedHammingDistance), traits for computing the Hamming\n/// distance between two numbers.\n///\n/// # hamming_distance\n/// ```\n/// use malachite_base::num::logic::traits::HammingDistance;\n///\n/// assert_eq!(123u32.hamming_distance(456), 6);\n/// assert_eq!(0u8.hamming_distance(255), 8);\n/// ```\n///\n/// # checked_hamming_distance\n/// ```\n/// use malachite_base::num::logic::traits::CheckedHammingDistance;\n///\n/// assert_eq!(123i32.checked_hamming_distance(456), Some(6));\n/// assert_eq!(0i8.checked_hamming_distance(127), Some(7));\n/// assert_eq!(0i8.checked_hamming_distance(-1), None);\n/// ```\npub mod hamming_distance;\n/// [`LeadingZeros`](traits::LeadingZeros), a trait for determining the number of zeros that a\n/// number starts with, when written in binary using $W$ bits, $W$ being the type width.\npub mod leading_zeros;\n/// [`LowMask`](traits::LowMask), a trait for generating a low bit mask (a number in which only the\n/// $k$ least-significant bits are 1).\n///\n/// # low_mask\n/// ```\n/// use malachite_base::num::logic::traits::LowMask;\n///\n/// assert_eq!(u16::low_mask(0), 0);\n/// assert_eq!(u8::low_mask(3), 0x7);\n/// assert_eq!(u8::low_mask(8), 0xff);\n/// assert_eq!(u64::low_mask(40), 0xffffffffff);\n///\n/// assert_eq!(i16::low_mask(0), 0);\n/// assert_eq!(i8::low_mask(3), 0x7);\n/// assert_eq!(i8::low_mask(8), -1);\n/// assert_eq!(i64::low_mask(40), 0xffffffffff);\n/// ```\npub mod low_mask;\n/// [`NotAssign`](traits::NotAssign), a trait for replacing a number with its bitwise negation.\n///\n/// # not_assign\n/// ```\n/// use malachite_base::num::logic::traits::NotAssign;\n///\n/// let mut x = 123u16;\n/// x.not_assign();\n/// assert_eq!(x, 65412);\n/// ```\npub mod not;\n/// [`SignificantBits`](traits::SignificantBits), a trait for determining how many significant bits\n/// a number has.\n///\n/// # significant_bits\n/// ```\n/// use malachite_base::num::logic::traits::SignificantBits;\n///\n/// assert_eq!(0u8.significant_bits(), 0);\n/// assert_eq!(100u64.significant_bits(), 7);\n///\n/// assert_eq!(0i8.significant_bits(), 0);\n/// assert_eq!((-100i64).significant_bits(), 7);\n/// ```\npub mod significant_bits;\n/// [`TrailingZeros`](traits::TrailingZeros), a trait for determining the number of zeros that a\n/// number ends with when written in binary.\npub mod trailing_zeros;\n/// Various traits for performing logic or bitwise operations on numbers.\npub mod traits;\n"
  },
  {
    "path": "malachite-base/src/num/logic/not.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::logic::traits::NotAssign;\n\nmacro_rules! impl_not {\n    ($t:ident) => {\n        impl NotAssign for $t {\n            /// Replaces a number with its bitwise negation.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::not#not_assign).\n            #[inline]\n            fn not_assign(&mut self) {\n                *self = !*self;\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_not);\n"
  },
  {
    "path": "malachite-base/src/num/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::UnsignedAbs;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::logic::traits::{LeadingZeros, SignificantBits};\n\nfn significant_bits_unsigned<T: PrimitiveUnsigned>(x: T) -> u64 {\n    T::WIDTH - LeadingZeros::leading_zeros(x)\n}\n\nmacro_rules! impl_significant_bits_unsigned {\n    ($t:ident) => {\n        impl SignificantBits for $t {\n            /// Returns the number of significant bits of an unsigned primitive integer.\n            ///\n            /// This is the integer's width minus the number of leading zeros.\n            ///\n            /// $$\n            /// f(n) = \\\\begin{cases}\n            ///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n            ///     \\lfloor \\log_2 n \\rfloor + 1 & \\text{if} \\\\quad n > 0.\n            /// \\\\end{cases}\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::significant_bits#significant_bits).\n            #[inline]\n            fn significant_bits(self) -> u64 {\n                significant_bits_unsigned(self)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_significant_bits_unsigned);\n\nfn significant_bits_signed<U: PrimitiveUnsigned, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: S,\n) -> u64 {\n    x.unsigned_abs().significant_bits()\n}\n\nmacro_rules! impl_significant_bits_signed {\n    ($u:ident, $s:ident) => {\n        /// Returns the number of significant bits of a signed primitive integer.\n        ///\n        /// This is the integer's width minus the number of leading zeros of its absolute value.\n        ///\n        /// $$\n        /// f(n) = \\\\begin{cases}\n        ///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n        ///     \\lfloor \\log_2 |n| \\rfloor + 1 & \\text{if} \\\\quad n \\neq 0.\n        /// \\\\end{cases}\n        /// $$\n        ///\n        /// # Worst-case complexity\n        /// Constant time and additional memory.\n        ///\n        /// # Examples\n        /// See [here](super::significant_bits#significant_bits).\n        impl SignificantBits for $s {\n            #[inline]\n            fn significant_bits(self) -> u64 {\n                significant_bits_signed(self)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_significant_bits_signed);\n"
  },
  {
    "path": "malachite-base/src/num/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::logic::traits::TrailingZeros;\n\nmacro_rules! impl_trailing_zeros {\n    ($t:ident) => {\n        impl TrailingZeros for $t {\n            /// This is a wrapper over the `trailing_zeros` functions in the standard library, for\n            /// example [this one](u32::trailing_zeros).\n            #[inline]\n            fn trailing_zeros(self) -> u64 {\n                u64::from($t::trailing_zeros(self))\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_trailing_zeros);\n"
  },
  {
    "path": "malachite-base/src/num/logic/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse alloc::vec::Vec;\nuse core::ops::Index;\n\n/// Defines functions that access or modify individual bits in a number.\npub trait BitAccess {\n    /// Determines whether a number has a `true` or `false` bit at `index`.\n    fn get_bit(&self, index: u64) -> bool;\n\n    /// Sets the bit at `index` to `true`.\n    fn set_bit(&mut self, index: u64);\n\n    /// Sets the bit at `index` to `false`.\n    fn clear_bit(&mut self, index: u64);\n\n    /// Sets the bit at `index` to whichever value `bit` is.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(\\max(T_S(n), T_C(n)))$,\n    ///\n    /// $M(n) = O(\\max(M_S(n), M_C(n)))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $T_S$ and $M_S$ are the complexities of\n    /// [`set_bit`](Self::set_bit), and $T_C$ and $M_C$ are the complexities of\n    /// [`clear_bit`](Self::clear_bit).\n    ///\n    /// # Panics\n    /// See panics for [`set_bit`](Self::set_bit) and [`clear_bit`](Self::clear_bit).\n    #[inline]\n    fn assign_bit(&mut self, index: u64, bit: bool) {\n        if bit {\n            self.set_bit(index);\n        } else {\n            self.clear_bit(index);\n        }\n    }\n\n    /// Sets the bit at `index` to the opposite of its original value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(T_G(n) + \\max(T_S(n), T_C(n)))$,\n    ///\n    /// $M(n) = O(M_G(n) + \\max(M_S(n), M_C(n)))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $T_G$ and $M_G$ are the complexities of\n    /// [`get_bit`](Self::get_bit), $T_S$ and $M_S$ are the complexities of\n    /// [`set_bit`](Self::set_bit), and $T_C$ and $M_C$ are the complexities of\n    /// [`clear_bit`](Self::clear_bit).\n    ///\n    /// # Panics\n    /// See panics for [`get_bit`](Self::get_bit), [`set_bit`](Self::set_bit) and\n    /// [`clear_bit`](Self::clear_bit).\n    #[inline]\n    fn flip_bit(&mut self, index: u64) {\n        if self.get_bit(index) {\n            self.clear_bit(index);\n        } else {\n            self.set_bit(index);\n        }\n    }\n}\n\n/// Defines functions that access or modify blocks of adjacent bits in a number.\npub trait BitBlockAccess: Sized {\n    type Bits;\n\n    /// Extracts a block of bits whose first index is `start` and last index is `end - 1`.\n    fn get_bits(&self, start: u64, end: u64) -> Self::Bits;\n\n    /// Extracts a block of bits whose first index is `start` and last index is `end - 1`, taking\n    /// ownership of `self`.\n    ///\n    /// # Worst-case complexity\n    /// For the default implementation, same as [`get_bits`](Self::get_bits).\n    ///\n    /// # Panics\n    /// For the default implementation, ee panics for [`get_bits`](Self::get_bits).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitBlockAccess;\n    ///\n    /// assert_eq!((-0x5433i16).get_bits_owned(4, 8), 0xc);\n    /// assert_eq!((-0x5433i16).get_bits_owned(5, 9), 14);\n    /// assert_eq!((-0x5433i16).get_bits_owned(5, 5), 0);\n    /// assert_eq!((-0x5433i16).get_bits_owned(100, 104), 0xf);\n    /// ```\n    #[inline]\n    fn get_bits_owned(self, start: u64, end: u64) -> Self::Bits {\n        self.get_bits(start, end)\n    }\n\n    /// Assigns the least-significant `end - start` bits of `bits` to bits `start` through `end - 1`\n    /// (inclusive) of `self`.\n    fn assign_bits(&mut self, start: u64, end: u64, bits: &Self::Bits);\n}\n\n/// Defines functions that express a number as a [`Vec`] of bits or construct a number from an\n/// iterator of bits.\npub trait BitConvertible {\n    /// Returns a [`Vec`] containing the bits of a number in ascending order: least- to\n    /// most-significant.\n    fn to_bits_asc(&self) -> Vec<bool>;\n\n    /// Returns a [`Vec`] containing the bits of a number in descending order: most- to\n    /// least-significant.\n    fn to_bits_desc(&self) -> Vec<bool>;\n\n    /// Converts an iterator of bits into a number. The input bits are in ascending order: least- to\n    /// most-significant.\n    fn from_bits_asc<I: Iterator<Item = bool>>(bits: I) -> Self;\n\n    /// Converts an iterator of bits into a value. The input bits are in descending order: most- to\n    /// least-significant.\n    fn from_bits_desc<I: Iterator<Item = bool>>(bits: I) -> Self;\n}\n\n/// Defines an iterator over a value's bits.\npub trait BitIterable {\n    type BitIterator: DoubleEndedIterator<Item = bool> + Index<u64>;\n\n    /// Returns a double-ended iterator over a number's bits. When iterating in the forward\n    /// direction, the iterator ends after the producing the number's most-significant bit.\n    fn bits(self) -> Self::BitIterator;\n}\n\n/// Defines functions that search for the next `true` or `false` bit in a number, starting at a\n/// specified index and searching in the more-significant direction.\npub trait BitScan {\n    /// Given a number and a starting index, searches the number for the smallest index of a `false`\n    /// bit that is greater than or equal to the starting index.\n    fn index_of_next_false_bit(self, start: u64) -> Option<u64>;\n\n    /// Given a number and a starting index, searches the number for the smallest index of a `true`\n    /// bit that is greater than or equal to the starting index.\n    fn index_of_next_true_bit(self, start: u64) -> Option<u64>;\n}\n\n/// Returns the number of ones in the binary representation of a number.\npub trait CountOnes {\n    fn count_ones(self) -> u64;\n}\n\n/// Returns the number of zeros in the binary representation of a number.\npub trait CountZeros {\n    fn count_zeros(self) -> u64;\n}\n\n/// Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one\n/// into the other.\npub trait HammingDistance<RHS = Self> {\n    fn hamming_distance(self, other: RHS) -> u64;\n}\n\n/// Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one\n/// into the other.\n///\n/// This trait allows for the possibility of the distance being undefined for some pairs of numbers,\n/// in which case [`checked_hamming_distance`](Self::checked_hamming_distance) should return `None`.\npub trait CheckedHammingDistance<RHS = Self> {\n    fn checked_hamming_distance(self, other: RHS) -> Option<u64>;\n}\n\n/// Returns the number of leading zeros in the binary representation of a number.\npub trait LeadingZeros {\n    fn leading_zeros(self) -> u64;\n}\n\n/// Returns a number whose least significant $b$ bits are `true` and whose other bits are `false`.\npub trait LowMask {\n    fn low_mask(bits: u64) -> Self;\n}\n\n/// Replaces a number with its bitwise negation.\npub trait NotAssign {\n    fn not_assign(&mut self);\n}\n\n// Returns the number of significant bits of a number.\npub trait SignificantBits {\n    /// The number of bits it takes to represent `self`.\n    fn significant_bits(self) -> u64;\n}\n\n/// Returns the number of trailing zeros in the binary representation of a number.\npub trait TrailingZeros {\n    fn trailing_zeros(self) -> u64;\n}\n"
  },
  {
    "path": "malachite-base/src/num/macros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_to_unsigneds {\n    ($m: tt) => {\n        $m!(u8);\n        $m!(u16);\n        $m!(u32);\n        $m!(u64);\n        $m!(u128);\n        $m!(usize);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_to_signeds {\n    ($m: tt) => {\n        $m!(i8);\n        $m!(i16);\n        $m!(i32);\n        $m!(i64);\n        $m!(i128);\n        $m!(isize);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_to_primitive_ints {\n    ($m: tt) => {\n        apply_to_unsigneds!($m);\n        apply_to_signeds!($m);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_to_unsigned_signed_pairs {\n    ($m: tt) => {\n        $m!(u8, i8);\n        $m!(u16, i16);\n        $m!(u32, i32);\n        $m!(u64, i64);\n        $m!(u128, i128);\n        $m!(usize, isize);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_unsigneds {\n    ($f: ident) => {\n        $f::<u8>();\n        $f::<u16>();\n        $f::<u32>();\n        $f::<u64>();\n        $f::<u128>();\n        $f::<usize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_signeds {\n    ($f: ident) => {\n        $f::<i8>();\n        $f::<i16>();\n        $f::<i32>();\n        $f::<i64>();\n        $f::<i128>();\n        $f::<isize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_ints {\n    ($f: ident) => {\n        apply_fn_to_unsigneds!($f);\n        apply_fn_to_signeds!($f);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_unsigned_signed_pairs {\n    ($f: ident) => {\n        $f::<u8, i8>();\n        $f::<u16, i16>();\n        $f::<u32, i32>();\n        $f::<u64, i64>();\n        $f::<u128, i128>();\n        $f::<usize, isize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_unsigneds_and_unsigneds {\n    ($f: ident) => {\n        $f::<u8, u8>();\n        $f::<u8, u16>();\n        $f::<u8, u32>();\n        $f::<u8, u64>();\n        $f::<u8, u128>();\n        $f::<u8, usize>();\n        $f::<u16, u8>();\n        $f::<u16, u16>();\n        $f::<u16, u32>();\n        $f::<u16, u64>();\n        $f::<u16, u128>();\n        $f::<u16, usize>();\n        $f::<u32, u8>();\n        $f::<u32, u16>();\n        $f::<u32, u32>();\n        $f::<u32, u64>();\n        $f::<u32, u128>();\n        $f::<u32, usize>();\n        $f::<u64, u8>();\n        $f::<u64, u16>();\n        $f::<u64, u32>();\n        $f::<u64, u64>();\n        $f::<u64, u128>();\n        $f::<u64, usize>();\n        $f::<u128, u8>();\n        $f::<u128, u16>();\n        $f::<u128, u32>();\n        $f::<u128, u64>();\n        $f::<u128, u128>();\n        $f::<u128, usize>();\n        $f::<usize, u8>();\n        $f::<usize, u16>();\n        $f::<usize, u32>();\n        $f::<usize, u64>();\n        $f::<usize, u128>();\n        $f::<usize, usize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_unsigneds_and_signeds {\n    ($f: ident) => {\n        $f::<u8, i8>();\n        $f::<u8, i16>();\n        $f::<u8, i32>();\n        $f::<u8, i64>();\n        $f::<u8, i128>();\n        $f::<u8, isize>();\n        $f::<u16, i8>();\n        $f::<u16, i16>();\n        $f::<u16, i32>();\n        $f::<u16, i64>();\n        $f::<u16, i128>();\n        $f::<u16, isize>();\n        $f::<u32, i8>();\n        $f::<u32, i16>();\n        $f::<u32, i32>();\n        $f::<u32, i64>();\n        $f::<u32, i128>();\n        $f::<u32, isize>();\n        $f::<u64, i8>();\n        $f::<u64, i16>();\n        $f::<u64, i32>();\n        $f::<u64, i64>();\n        $f::<u64, i128>();\n        $f::<u64, isize>();\n        $f::<u128, i8>();\n        $f::<u128, i16>();\n        $f::<u128, i32>();\n        $f::<u128, i64>();\n        $f::<u128, i128>();\n        $f::<u128, isize>();\n        $f::<usize, i8>();\n        $f::<usize, i16>();\n        $f::<usize, i32>();\n        $f::<usize, i64>();\n        $f::<usize, i128>();\n        $f::<usize, isize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_unsigneds_and_primitive_ints {\n    ($f: ident) => {\n        apply_fn_to_unsigneds_and_unsigneds!($f);\n        apply_fn_to_unsigneds_and_signeds!($f);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_unsigneds_and_unsigned_signed_pairs {\n    ($f: ident) => {\n        $f::<u8, u8, i8>();\n        $f::<u8, u16, i16>();\n        $f::<u8, u32, i32>();\n        $f::<u8, u64, i64>();\n        $f::<u8, u128, i128>();\n        $f::<u8, usize, isize>();\n        $f::<u16, u8, i8>();\n        $f::<u16, u16, i16>();\n        $f::<u16, u32, i32>();\n        $f::<u16, u64, i64>();\n        $f::<u16, u128, i128>();\n        $f::<u16, usize, isize>();\n        $f::<u32, u8, i8>();\n        $f::<u32, u16, i16>();\n        $f::<u32, u32, i32>();\n        $f::<u32, u64, i64>();\n        $f::<u32, u128, i128>();\n        $f::<u32, usize, isize>();\n        $f::<u64, u8, i8>();\n        $f::<u64, u16, i16>();\n        $f::<u64, u32, i32>();\n        $f::<u64, u64, i64>();\n        $f::<u64, u128, i128>();\n        $f::<u64, usize, isize>();\n        $f::<u128, u8, i8>();\n        $f::<u128, u16, i16>();\n        $f::<u128, u32, i32>();\n        $f::<u128, u64, i64>();\n        $f::<u128, u128, i128>();\n        $f::<u128, usize, isize>();\n        $f::<usize, u8, i8>();\n        $f::<usize, u16, i16>();\n        $f::<usize, u32, i32>();\n        $f::<usize, u64, i64>();\n        $f::<usize, u128, i128>();\n        $f::<usize, usize, isize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_unsigneds_and_primitive_floats {\n    ($f: ident) => {\n        $f::<u8, f32>();\n        $f::<u8, f64>();\n        $f::<u16, f32>();\n        $f::<u16, f64>();\n        $f::<u32, f32>();\n        $f::<u32, f64>();\n        $f::<u64, f32>();\n        $f::<u64, f64>();\n        $f::<u128, f32>();\n        $f::<u128, f64>();\n        $f::<usize, f32>();\n        $f::<usize, f64>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_signeds_and_primitive_floats {\n    ($f: ident) => {\n        $f::<i8, f32>();\n        $f::<i8, f64>();\n        $f::<i16, f32>();\n        $f::<i16, f64>();\n        $f::<i32, f32>();\n        $f::<i32, f64>();\n        $f::<i64, f32>();\n        $f::<i64, f64>();\n        $f::<i128, f32>();\n        $f::<i128, f64>();\n        $f::<isize, f32>();\n        $f::<isize, f64>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_ints_and_primitive_floats {\n    ($f: ident) => {\n        apply_fn_to_unsigneds_and_primitive_floats!($f);\n        apply_fn_to_signeds_and_primitive_floats!($f);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_floats_and_unsigneds {\n    ($f: ident) => {\n        $f::<f32, u8>();\n        $f::<f32, u16>();\n        $f::<f32, u32>();\n        $f::<f32, u64>();\n        $f::<f32, u128>();\n        $f::<f32, usize>();\n        $f::<f64, u8>();\n        $f::<f64, u16>();\n        $f::<f64, u32>();\n        $f::<f64, u64>();\n        $f::<f64, u128>();\n        $f::<f64, usize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_floats_and_signeds {\n    ($f: ident) => {\n        $f::<f32, i8>();\n        $f::<f32, i16>();\n        $f::<f32, i32>();\n        $f::<f32, i64>();\n        $f::<f32, i128>();\n        $f::<f32, isize>();\n        $f::<f64, i8>();\n        $f::<f64, i16>();\n        $f::<f64, i32>();\n        $f::<f64, i64>();\n        $f::<f64, i128>();\n        $f::<f64, isize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_floats_and_unsigned_signed_pairs {\n    ($f: ident) => {\n        $f::<f32, u8, i8>();\n        $f::<f32, u16, i16>();\n        $f::<f32, u32, i32>();\n        $f::<f32, u64, i64>();\n        $f::<f32, u128, i128>();\n        $f::<f32, usize, isize>();\n        $f::<f64, u8, i8>();\n        $f::<f64, u16, i16>();\n        $f::<f64, u32, i32>();\n        $f::<f64, u64, i64>();\n        $f::<f64, u128, i128>();\n        $f::<f64, usize, isize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_signeds_and_unsigneds {\n    ($f: ident) => {\n        $f::<i8, u8>();\n        $f::<i8, u16>();\n        $f::<i8, u32>();\n        $f::<i8, u64>();\n        $f::<i8, u128>();\n        $f::<i8, usize>();\n        $f::<i16, u8>();\n        $f::<i16, u16>();\n        $f::<i16, u32>();\n        $f::<i16, u64>();\n        $f::<i16, u128>();\n        $f::<i16, usize>();\n        $f::<i32, u8>();\n        $f::<i32, u16>();\n        $f::<i32, u32>();\n        $f::<i32, u64>();\n        $f::<i32, u128>();\n        $f::<i32, usize>();\n        $f::<i64, u8>();\n        $f::<i64, u16>();\n        $f::<i64, u32>();\n        $f::<i64, u64>();\n        $f::<i64, u128>();\n        $f::<i64, usize>();\n        $f::<i128, u8>();\n        $f::<i128, u16>();\n        $f::<i128, u32>();\n        $f::<i128, u64>();\n        $f::<i128, u128>();\n        $f::<i128, usize>();\n        $f::<isize, u8>();\n        $f::<isize, u16>();\n        $f::<isize, u32>();\n        $f::<isize, u64>();\n        $f::<isize, u128>();\n        $f::<isize, usize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_signeds_and_signeds {\n    ($f: ident) => {\n        $f::<i8, i8>();\n        $f::<i8, i16>();\n        $f::<i8, i32>();\n        $f::<i8, i64>();\n        $f::<i8, i128>();\n        $f::<i8, isize>();\n        $f::<i16, i8>();\n        $f::<i16, i16>();\n        $f::<i16, i32>();\n        $f::<i16, i64>();\n        $f::<i16, i128>();\n        $f::<i16, isize>();\n        $f::<i32, i8>();\n        $f::<i32, i16>();\n        $f::<i32, i32>();\n        $f::<i32, i64>();\n        $f::<i32, i128>();\n        $f::<i32, isize>();\n        $f::<i64, i8>();\n        $f::<i64, i16>();\n        $f::<i64, i32>();\n        $f::<i64, i64>();\n        $f::<i64, i128>();\n        $f::<i64, isize>();\n        $f::<i128, i8>();\n        $f::<i128, i16>();\n        $f::<i128, i32>();\n        $f::<i128, i64>();\n        $f::<i128, i128>();\n        $f::<i128, isize>();\n        $f::<isize, i8>();\n        $f::<isize, i16>();\n        $f::<isize, i32>();\n        $f::<isize, i64>();\n        $f::<isize, i128>();\n        $f::<isize, isize>();\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_ints_and_unsigneds {\n    ($f: ident) => {\n        apply_fn_to_unsigneds_and_unsigneds!($f);\n        apply_fn_to_signeds_and_unsigneds!($f);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_ints_and_signeds {\n    ($f: ident) => {\n        apply_fn_to_unsigneds_and_signeds!($f);\n        apply_fn_to_signeds_and_signeds!($f);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_ints_and_primitive_ints {\n    ($f: ident) => {\n        apply_fn_to_primitive_ints_and_unsigneds!($f);\n        apply_fn_to_primitive_ints_and_signeds!($f);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_to_primitive_floats {\n    ($m: tt) => {\n        $m!(f32);\n        $m!(f64);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_to_primitive_float_unsigned_pairs {\n    ($m: tt) => {\n        $m!(f32, u32);\n        $m!(f64, u64);\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! apply_fn_to_primitive_floats {\n    ($f: ident) => {\n        $f::<f32>();\n        $f::<f64>();\n    };\n}\n"
  },
  {
    "path": "malachite-base/src/num/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[doc(hidden)]\n#[macro_use]\npub mod macros;\n\n/// Traits for arithmetic.\npub mod arithmetic;\n/// Traits for primitive integers or floats and some of their basic functionality.\npub mod basic;\n/// Traits for comparing the absolute values of numbers for equality or order.\npub mod comparison;\n/// Traits for converting to and from numbers, converting to and from strings, and extracting\n/// digits.\npub mod conversion;\n/// Iterators that generate numbers without repetition.\npub mod exhaustive;\n/// Traits for generating primes, primality testing, and factorization.\npub mod factorization;\n/// [`NiceFloat`](float::NiceFloat), a wrapper around primitive floats.\npub mod float;\n/// Iterators related to numbers.\npub mod iterators;\n/// Traits for logic and bit manipulation.\npub mod logic;\n#[cfg(feature = \"random\")]\n/// Iterators that generate numbers randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/num/random/geometric.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::{\n    RandomBools, WeightedRandomBools, get_weighted_random_bool, random_bools, weighted_random_bools,\n};\nuse crate::num::arithmetic::traits::Gcd;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::ExactInto;\nuse crate::random::Seed;\nuse std::fmt::Debug;\n\nuse super::VariableRangeGenerator;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub(crate) struct SimpleRational {\n    pub(crate) n: u64,\n    pub(crate) d: u64,\n}\n\nimpl SimpleRational {\n    pub(crate) fn new(n: u64, d: u64) -> Self {\n        assert_ne!(d, 0);\n        let gcd = n.gcd(d);\n        Self {\n            n: n / gcd,\n            d: d / gcd,\n        }\n    }\n\n    fn inverse(self) -> Self {\n        assert_ne!(self.n, 0);\n        Self {\n            n: self.d,\n            d: self.n,\n        }\n    }\n\n    // unwrap not const yet\n    #[allow(clippy::missing_const_for_fn)]\n    fn sub_u64(self, x: u64) -> Self {\n        Self {\n            n: self.n.checked_sub(x.checked_mul(self.d).unwrap()).unwrap(),\n            d: self.d,\n        }\n    }\n}\n\npub(crate) fn mean_to_p_with_min<T: PrimitiveInt>(\n    min: T,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> (u64, u64) {\n    let um = SimpleRational::new(um_numerator, um_denominator);\n    let p = um.sub_u64(ExactInto::<u64>::exact_into(min)).inverse();\n    (p.n, p.d)\n}\n\n/// Generates random unsigned integers from a truncated geometric distribution.\n#[derive(Clone, Debug)]\npub struct GeometricRandomNaturalValues<T: PrimitiveInt> {\n    xs: WeightedRandomBools,\n    min: T,\n    max: T,\n}\n\nimpl<T: PrimitiveInt> Iterator for GeometricRandomNaturalValues<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        let mut failures = self.min;\n        loop {\n            if self.xs.next().unwrap() {\n                return Some(failures);\n            }\n            // Wrapping to min is equivalent to restarting this function.\n            if failures == self.max {\n                failures = self.min;\n            } else {\n                failures += T::ONE;\n            }\n        }\n    }\n}\n\nfn geometric_random_natural_values_inclusive_range<T: PrimitiveInt>(\n    seed: Seed,\n    min: T,\n    max: T,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> GeometricRandomNaturalValues<T> {\n    assert!(min <= max);\n    assert_ne!(um_denominator, 0);\n    let (numerator, denominator) = mean_to_p_with_min(min, um_numerator, um_denominator);\n    GeometricRandomNaturalValues {\n        xs: weighted_random_bools(seed, numerator, numerator.checked_add(denominator).unwrap()),\n        min,\n        max,\n    }\n}\n\nfn get_geometric_random_natural_value_from_inclusive_range<T: PrimitiveInt>(\n    range_generator: &mut VariableRangeGenerator,\n    min: T,\n    max: T,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> T {\n    assert!(min <= max);\n    assert_ne!(um_denominator, 0);\n    let (n, denominator) = mean_to_p_with_min(min, um_numerator, um_denominator);\n    let d = n.checked_add(denominator).unwrap();\n    let mut failures = min;\n    loop {\n        if get_weighted_random_bool(range_generator, n, d) {\n            return failures;\n        }\n        // Wrapping to min is equivalent to restarting this function.\n        if failures == max {\n            failures = min;\n        } else {\n            failures += T::ONE;\n        }\n    }\n}\n\n/// Generates random negative signed integers from a modified geometric distribution.\n#[derive(Clone, Debug)]\npub struct GeometricRandomNegativeSigneds<T: PrimitiveSigned> {\n    xs: WeightedRandomBools,\n    abs_min: T,\n    abs_max: T,\n}\n\nimpl<T: PrimitiveSigned> Iterator for GeometricRandomNegativeSigneds<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        let mut result = self.abs_min;\n        loop {\n            if self.xs.next().unwrap() {\n                return Some(result);\n            }\n            // Wrapping to min is equivalent to restarting this function.\n            if result == self.abs_max {\n                result = self.abs_min;\n            } else {\n                result -= T::ONE;\n            }\n        }\n    }\n}\n\nfn geometric_random_negative_signeds_inclusive_range<T: PrimitiveSigned>(\n    seed: Seed,\n    abs_min: T,\n    abs_max: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomNegativeSigneds<T> {\n    assert!(abs_min >= abs_max);\n    assert_ne!(abs_um_denominator, 0);\n    let (numerator, denominator) = mean_to_p_with_min(\n        abs_min.checked_neg().unwrap(),\n        abs_um_numerator,\n        abs_um_denominator,\n    );\n    GeometricRandomNegativeSigneds {\n        xs: weighted_random_bools(seed, numerator, numerator.checked_add(denominator).unwrap()),\n        abs_min,\n        abs_max,\n    }\n}\n\nfn get_geometric_random_negative_signed_from_inclusive_range<T: PrimitiveSigned>(\n    range_generator: &mut VariableRangeGenerator,\n    abs_min: T,\n    abs_max: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> T {\n    assert!(abs_min >= abs_max);\n    assert_ne!(abs_um_denominator, 0);\n    let (n, denominator) = mean_to_p_with_min(\n        abs_min.checked_neg().unwrap(),\n        abs_um_numerator,\n        abs_um_denominator,\n    );\n    let d = n.checked_add(denominator).unwrap();\n    let mut result = abs_min;\n    loop {\n        if get_weighted_random_bool(range_generator, n, d) {\n            return result;\n        }\n        // Wrapping to min is equivalent to restarting this function.\n        if result == abs_max {\n            result = abs_min;\n        } else {\n            result -= T::ONE;\n        }\n    }\n}\n\n/// Generates random nonzero signed integers from a modified geometric distribution.\n#[derive(Clone, Debug)]\npub struct GeometricRandomNonzeroSigneds<T: PrimitiveSigned> {\n    bs: RandomBools,\n    xs: WeightedRandomBools,\n    min: T,\n    max: T,\n}\n\nimpl<T: PrimitiveSigned> Iterator for GeometricRandomNonzeroSigneds<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        loop {\n            if self.bs.next().unwrap() {\n                let mut result = T::ONE;\n                loop {\n                    if self.xs.next().unwrap() {\n                        return Some(result);\n                    } else if result == self.max {\n                        break;\n                    }\n                    result += T::ONE;\n                }\n            } else {\n                let mut result = T::NEGATIVE_ONE;\n                loop {\n                    if self.xs.next().unwrap() {\n                        return Some(result);\n                    } else if result == self.min {\n                        break;\n                    }\n                    result -= T::ONE;\n                }\n            }\n        }\n    }\n}\n\nfn geometric_random_nonzero_signeds_inclusive_range<T: PrimitiveSigned>(\n    seed: Seed,\n    min: T,\n    max: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomNonzeroSigneds<T> {\n    assert!(min <= max);\n    assert_ne!(abs_um_denominator, 0);\n    let (numerator, denominator) = mean_to_p_with_min(T::ONE, abs_um_numerator, abs_um_denominator);\n    GeometricRandomNonzeroSigneds {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: weighted_random_bools(\n            seed.fork(\"xs\"),\n            numerator,\n            numerator.checked_add(denominator).unwrap(),\n        ),\n        min,\n        max,\n    }\n}\n\n/// Generates random signed integers from a modified geometric distribution.\n#[derive(Clone, Debug)]\npub struct GeometricRandomSigneds<T: PrimitiveSigned> {\n    bs: RandomBools,\n    xs: WeightedRandomBools,\n    min: T,\n    max: T,\n}\n\nimpl<T: PrimitiveSigned> Iterator for GeometricRandomSigneds<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        loop {\n            let mut result = T::ZERO;\n            if self.bs.next().unwrap() {\n                loop {\n                    if self.xs.next().unwrap() {\n                        if result == T::ZERO && self.bs.next().unwrap() {\n                            break;\n                        }\n                        return Some(result);\n                    } else if result == self.max {\n                        break;\n                    }\n                    result += T::ONE;\n                }\n            } else {\n                loop {\n                    if self.xs.next().unwrap() {\n                        if result == T::ZERO && self.bs.next().unwrap() {\n                            break;\n                        }\n                        return Some(result);\n                    } else if result == self.min {\n                        break;\n                    }\n                    result -= T::ONE;\n                }\n            }\n        }\n    }\n}\n\nfn geometric_random_signed_inclusive_range_helper<T: PrimitiveSigned>(\n    seed: Seed,\n    min: T,\n    max: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomSigneds<T> {\n    assert!(min <= max);\n    assert_ne!(abs_um_denominator, 0);\n    let (numerator, denominator) =\n        mean_to_p_with_min(T::ZERO, abs_um_numerator, abs_um_denominator);\n    GeometricRandomSigneds {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: weighted_random_bools(\n            seed.fork(\"xs\"),\n            numerator,\n            numerator.checked_add(denominator).unwrap(),\n        ),\n        min,\n        max,\n    }\n}\n\nfn get_geometric_random_signed_from_inclusive_range_helper<T: PrimitiveSigned>(\n    range_generator: &mut VariableRangeGenerator,\n    min: T,\n    max: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> T {\n    assert!(min <= max);\n    assert_ne!(abs_um_denominator, 0);\n    let (n, denominator) = mean_to_p_with_min(T::ZERO, abs_um_numerator, abs_um_denominator);\n    let d = n.checked_add(denominator).unwrap();\n    loop {\n        let mut result = T::ZERO;\n        if range_generator.next_bool() {\n            loop {\n                if get_weighted_random_bool(range_generator, n, d) {\n                    if result == T::ZERO && range_generator.next_bool() {\n                        break;\n                    }\n                    return result;\n                } else if result == max {\n                    break;\n                }\n                result += T::ONE;\n            }\n        } else {\n            loop {\n                if get_weighted_random_bool(range_generator, n, d) {\n                    if result == T::ZERO && range_generator.next_bool() {\n                        break;\n                    }\n                    return result;\n                } else if result == min {\n                    break;\n                }\n                result -= T::ONE;\n            }\n        }\n    }\n}\n\n/// Generates random negative signed integers in a range from a modified geometric distribution.\n#[allow(clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum GeometricRandomSignedRange<T: PrimitiveSigned> {\n    NonNegative(GeometricRandomNaturalValues<T>),\n    NonPositive(GeometricRandomNegativeSigneds<T>),\n    BothSigns(GeometricRandomSigneds<T>),\n}\n\nimpl<T: PrimitiveSigned> Iterator for GeometricRandomSignedRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::NonNegative(xs) => xs.next(),\n            Self::NonPositive(xs) => xs.next(),\n            Self::BothSigns(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates random unsigned integers from a truncated geometric distribution.\n///\n/// With this distribution, the probability of a value being generated decreases as the value\n/// increases. The probabilities $P(0), P(1), P(2), \\ldots$ decrease in a geometric sequence; that's\n/// where the \"geometric\" comes from. Unlike a true geometric distribution, this distribution is\n/// truncated, meaning that values above `T::MAX` are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `um_numerator / um_denominator`. The unadjusted mean is what\n/// the mean generated value would be if the distribution were not truncated. If $m_u$ is\n/// significantly lower than `T::MAX`, which is usually the case, then it is very close to the\n/// actual mean. The higher $m_u$ is, the more gently the probabilities drop; the lower it is, the\n/// more quickly they drop. $m_u$ must be greater than zero. It may be arbitrarily high, but note\n/// that the iteration time increases linearly with `um_numerator + um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[0, 2^W)$, where $W$ is the width of the type. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S,\n/// $$\n/// and whenever $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if `um_numerator` or `um_denominator` are zero, or, if after being reduced to lowest\n/// terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_unsigneds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(geometric_random_unsigneds::<u64>(EXAMPLE_SEED, 1, 1), 10),\n///     \"[1, 0, 0, 3, 4, 4, 1, 0, 0, 1, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p} - 1$, or $p = \\frac{1}{m_u + 1}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^np}{1-(1-p)^{2^W}} & \\text{if} \\\\quad 0 \\\\leq n < 2^W, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// It's also useful to note that\n/// $$\n///     \\lim_{W \\to \\infty} P(n) = (1-p)^np.\n/// $$\npub fn geometric_random_unsigneds<T: PrimitiveUnsigned>(\n    seed: Seed,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> GeometricRandomNaturalValues<T> {\n    assert_ne!(um_numerator, 0);\n    geometric_random_natural_values_inclusive_range(\n        seed,\n        T::ZERO,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n    )\n}\n\n/// Generates random positive unsigned integers from a truncated geometric distribution.\n///\n/// With this distribution, the probability of a value being generated decreases as the value\n/// increases. The probabilities $P(1), P(2), P(3), \\ldots$ decrease in a geometric sequence; that's\n/// where the \"geometric\" comes from. Unlike a true geometric distribution, this distribution is\n/// truncated, meaning that values above `T::MAX` are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `um_numerator / um_denominator`. The unadjusted mean is what\n/// the mean generated value would be if the distribution were not truncated. If $m_u$ is\n/// significantly lower than `T::MAX`, which is usually the case, then it is very close to the\n/// actual mean. The higher $m_u$ is, the more gently the probabilities drop; the lower it is, the\n/// more quickly they drop. $m_u$ must be greater than one. It may be arbitrarily high, but note\n/// that the iteration time increases linearly with `um_numerator + um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[1, 2^W)$, where $W$ is the width of the type. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n/// and whenever $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u}{m_u - 1}.\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if `um_denominator` is zero or if `um_numerator <= um_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_positive_unsigneds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_positive_unsigneds::<u64>(EXAMPLE_SEED, 2, 1),\n///         10\n///     ),\n///     \"[2, 1, 1, 4, 5, 5, 2, 1, 1, 2, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p}$, or $p = \\frac{1}{m_u}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^{n-1}p}{1-(1-p)^{2^W-1}} & \\text{if} \\\\quad 0 < n < 2^W, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// It's also useful to note that\n/// $$\n///     \\lim_{W \\to \\infty} P(n) = (1-p)^{n-1}p.\n/// $$\npub fn geometric_random_positive_unsigneds<T: PrimitiveUnsigned>(\n    seed: Seed,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> GeometricRandomNaturalValues<T> {\n    assert!(um_numerator > um_denominator);\n    geometric_random_natural_values_inclusive_range(\n        seed,\n        T::ONE,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n    )\n}\n\n/// Generates random signed integers from a modified geometric distribution.\n///\n/// This distribution can be derived from a truncated geometric distribution by mirroring it,\n/// producing a truncated double geometric distribution. Zero is included.\n///\n/// With this distribution, the probability of a value being generated decreases as its absolute\n/// value increases. The probabilities $P(0), P(\\pm 1), P(\\pm 2), \\ldots$ decrease in a geometric\n/// sequence; that's where the \"geometric\" comes from. Values below `T::MIN` or above `T::MAX` are\n/// never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `abs_um_numerator / abs_um_denominator`. The unadjusted mean\n/// is what the mean generated value would be if the distribution were not truncated, and were\n/// restricted to non-negative values. If $m_u$ is significantly lower than `T::MAX`, which is\n/// usually the case, then it is very close to the actual mean of the distribution restricted to\n/// positive values. The higher $m_u$ is, the more gently the probabilities drop; the lower it is,\n/// the more quickly they drop. $m_u$ must be greater than zero. It may be arbitrarily high, but\n/// note that the iteration time increases linearly with `abs_um_numerator + abs_um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[-2^{W-1}, 2^{W-1})$, where $W$ is the width of the type. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n/// Whenever $n \\geq 0$ and $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u}{m_u - 1},\n/// $$\n/// and whenever $n \\leq 0$ and $n, n - 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n-1)} = \\frac{m_u}{m_u - 1}.\n/// $$\n///\n/// As a corollary, $P(n) = P(-n)$ whenever $n, -n \\in S$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `abs_um_numerator + abs_um_denominator`.\n///\n/// # Panics\n/// Panics if `abs_um_numerator` or `abs_um_denominator` are zero, or, if after being reduced to\n/// lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(geometric_random_signeds::<i64>(EXAMPLE_SEED, 1, 1), 10),\n///     \"[-1, -1, -1, 1, -2, 1, 0, 0, 0, 0, ...]\"\n/// )\n/// ```\n///\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p} - 1$, or $p = \\frac{1}{m_u + 1}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^{|n|}p}{((1-p)^{2^{W-1}}-1)(p-2)} &\n///         \\text{if} \\\\quad -2^{W-1} \\leq n < 2^{W-1}, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// It's also useful to note that\n/// $$\n/// \\lim_{W \\to \\infty} P(n) = \\frac{(1-p)^{|n|}p}{2-p}.\n/// $$\npub fn geometric_random_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomSigneds<T> {\n    assert_ne!(abs_um_numerator, 0);\n    geometric_random_signed_inclusive_range_helper(\n        seed,\n        T::MIN,\n        T::MAX,\n        abs_um_numerator,\n        abs_um_denominator,\n    )\n}\n\n/// Generates random natural (non-negative) signed integers from a truncated geometric distribution.\n///\n/// With this distribution, the probability of a value being generated decreases as the value\n/// increases. The probabilities $P(0), P(1), P(2), \\ldots$ decrease in a geometric sequence; that's\n/// where the \"geometric\" comes from. Unlike a true geometric distribution, this distribution is\n/// truncated, meaning that values above `T::MAX` are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `um_numerator / um_denominator`. The unadjusted mean is what\n/// the mean generated value would be if the distribution were not truncated. If $m_u$ is\n/// significantly lower than `T::MAX`, which is usually the case, then it is very close to the\n/// actual mean. The higher $m_u$ is, the more gently the probabilities drop; the lower it is, the\n/// more quickly they drop. $m_u$ must be greater than zero. It may be arbitrarily high, but note\n/// that the iteration time increases linearly with `um_numerator + um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[0, 2^{W-1})$, where $W$ is the width of the type. Then we have\n/// $$\n///     P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n/// and whenever $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if `um_numerator` or `um_denominator` are zero, or, if after being reduced to lowest\n/// terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_natural_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_natural_signeds::<i64>(EXAMPLE_SEED, 1, 1),\n///         10\n///     ),\n///     \"[1, 0, 0, 3, 4, 4, 1, 0, 0, 1, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p} - 1$, or $p = \\frac{1}{m_u + 1}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^np}{1-(1-p)^{2^{W-1}}} & \\text{if} \\\\quad 0 \\\\leq n < 2^{W-1}, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// It's also useful to note that\n/// $$\n/// \\lim_{W \\to \\infty} P(n) = \\\\begin{cases}\n///     (1-p)^np & \\text{if} \\\\quad n \\geq 0, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\npub fn geometric_random_natural_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> GeometricRandomNaturalValues<T> {\n    assert_ne!(um_numerator, 0);\n    geometric_random_natural_values_inclusive_range(\n        seed,\n        T::ZERO,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n    )\n}\n\n/// Generates random positive signed integers from a truncated geometric distribution.\n///\n/// With this distribution, the probability of a value being generated decreases as the value\n/// increases. The probabilities $P(1), P(2), P(3), \\ldots$ decrease in a geometric sequence; that's\n/// where the \"geometric\" comes from. Unlike a true geometric distribution, this distribution is\n/// truncated, meaning that values above `T::MAX` are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `um_numerator / um_denominator`. The unadjusted mean is what\n/// the mean generated value would be if the distribution were not truncated. If $m_u$ is\n/// significantly lower than `T::MAX`, which is usually the case, then it is very close to the\n/// actual mean. The higher $m_u$ is, the more gently the probabilities drop; the lower it is, the\n/// more quickly they drop. $m_u$ must be greater than one. It may be arbitrarily high, but note\n/// that the iteration time increases linearly with `um_numerator + um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[1, 2^{W-1})$, where $W$ is the width of the type. Then we have\n/// $$\n///     P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n///\n/// and whenever $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u}{m_u - 1}.\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if `um_denominator` is zero or if `um_numerator <= um_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_positive_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_positive_signeds::<i64>(EXAMPLE_SEED, 2, 1),\n///         10\n///     ),\n///     \"[2, 1, 1, 4, 5, 5, 2, 1, 1, 2, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p}$, or $p = \\frac{1}{m_u}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^{n-1}p}{1-(1-p)^{2^{W-1}-1}} & \\text{if} \\\\quad 0 < n < 2^{W-1}, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// It's also useful to note that\n/// $$\n/// \\lim_{W \\to \\infty} P(n) = \\\\begin{cases}\n///     (1-p)^{n-1}p & \\text{if} \\\\quad n > 0, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\npub fn geometric_random_positive_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> GeometricRandomNaturalValues<T> {\n    geometric_random_natural_values_inclusive_range(\n        seed,\n        T::ONE,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n    )\n}\n\n/// Generates random negative signed integers from a modified geometric distribution.\n///\n/// This distribution can be derived from a truncated geometric distribution by negating its domain.\n/// The distribution is truncated at `T::MIN`.\n///\n/// With this distribution, the probability of a value being generated decreases as its absolute\n/// value increases. The probabilities $P(-1), P(-2), P(-3), \\ldots$ decrease in a geometric\n/// sequence; that's where the \"geometric\" comes from. Values below `T::MIN` are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `abs_um_numerator / abs_um_denominator`. The unadjusted mean\n/// is what the mean of the absolute values of the generated values would be if the distribution\n/// were not truncated. If $m_u$ is significantly lower than `-T::MIN`, which is usually the case,\n/// then it is very close to the actual mean of the absolute values. The higher $m_u$ is, the more\n/// gently the probabilities drop; the lower it is, the more quickly they drop. $m_u$ must be\n/// greater than one. It may be arbitrarily high, but note that the iteration time increases\n/// linearly with `abs_um_numerator + abs_um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[-2^{W-1}, 0)$, where $W$ is the width of the type. Then we have\n/// $$\n///     P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n///\n/// and whenever $n, n - 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n-1)} = \\frac{m_u}{m_u - 1}.\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `abs_um_numerator + abs_um_denominator`.\n///\n/// # Panics\n/// Panics if `abs_um_denominator` is zero or if `abs_um_numerator <= abs_um_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_negative_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_negative_signeds::<i64>(EXAMPLE_SEED, 2, 1),\n///         10\n///     ),\n///     \"[-2, -1, -1, -4, -5, -5, -2, -1, -1, -2, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p}$, or $p = \\frac{1}{m_u}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^{-n-1}p}{1-(1-p)^{2^{W-1}}} & \\text{if} \\\\quad -2^{W-1} \\leq n < 0, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// It's also useful to note that\n/// $$\n/// \\lim_{W \\to \\infty} P(n) = \\\\begin{cases}\n///     (1-p)^{-n-1}p & \\text{if} \\\\quad n < 0, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\npub fn geometric_random_negative_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomNegativeSigneds<T> {\n    assert!(abs_um_numerator > abs_um_denominator);\n    geometric_random_negative_signeds_inclusive_range(\n        seed,\n        T::NEGATIVE_ONE,\n        T::MIN,\n        abs_um_numerator,\n        abs_um_denominator,\n    )\n}\n\n/// Generates random nonzero signed integers from a modified geometric distribution.\n///\n/// This distribution can be derived from a truncated geometric distribution by mirroring it,\n/// producing a truncated double geometric distribution. Zero is excluded.\n///\n/// With this distribution, the probability of a value being generated decreases as its absolute\n/// value increases. The probabilities $P(\\pm 1), P(\\pm 2), P(\\pm 3), \\ldots$ decrease in a\n/// geometric sequence; that's where the \"geometric\" comes from. Values below `T::MIN` or above\n/// `T::MAX` are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `abs_um_numerator / abs_um_denominator`. The unadjusted mean\n/// is what the mean of the absolute values of the generated values would be if the distribution\n/// were not truncated. If $m_u$ is significantly lower than `T::MAX`, which is usually the case,\n/// then it is very close to the actual mean of the absolute values. The higher $m_u$ is, the more\n/// gently the probabilities drop; the lower it is, the more quickly they drop. $m_u$ must be\n/// greater than one. It may be arbitrarily high, but note that the iteration time increases\n/// linearly with `abs_um_numerator + abs_um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[-2^{W-1}, 2^{W-1}) \\setminus \\\\{0\\\\}$, where $W$ is the width of the type. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n/// $$\n/// P(1) = P(-1)\n/// $$\n/// Whenever $n > 0$ and $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u}{m_u - 1},\n/// $$\n/// and whenever $n < 0$ and $n, n - 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n-1)} = \\frac{m_u}{m_u - 1}.\n/// $$\n///\n/// As a corollary, $P(n) = P(-n)$ whenever $n, -n \\in S$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `abs_um_numerator + abs_um_denominator`.\n///\n/// # Panics\n/// Panics if `abs_um_denominator` is zero or if `abs_um_numerator <= abs_um_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_nonzero_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_nonzero_signeds::<i64>(EXAMPLE_SEED, 2, 1),\n///         10\n///     ),\n///     \"[-2, -2, -2, 2, -3, 2, -1, -1, -1, 1, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p}$, or $p = \\frac{1}{m_u}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^{|n|}p}{(1-p)^{2^{W-1}}(p-2)-2p+2} &\n///         \\text{if} \\\\quad -2^{W-1} \\leq n < 0 \\\\ \\mathrm{or} \\\\ 0 < n < -2^{W-1}, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// It's also useful to note that\n/// $$\n/// \\lim_{W \\to \\infty} P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^{|n|}p}{2-2p} & \\text{if} \\\\quad n \\neq 0, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\npub fn geometric_random_nonzero_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomNonzeroSigneds<T> {\n    assert!(abs_um_numerator > abs_um_denominator);\n    geometric_random_nonzero_signeds_inclusive_range(\n        seed,\n        T::MIN,\n        T::MAX,\n        abs_um_numerator,\n        abs_um_denominator,\n    )\n}\n\n/// Generates random unsigned integers from a truncated geometric distribution over the half-open\n/// interval $[a, b)$.\n///\n/// With this distribution, the probability of a value being generated decreases as the value\n/// increases. The probabilities $P(a), P(a + 1), P(a + 2), \\ldots$ decrease in a geometric\n/// sequence; that's where the \"geometric\" comes from. Unlike a true geometric distribution, this\n/// distribution is truncated, meaning that values above $b$ are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `um_numerator / um_denominator`. The unadjusted mean is what\n/// the mean generated value would be if the distribution were not truncated. If $m_u$ is\n/// significantly lower than $b$, then it is very close to the actual mean. The higher $m_u$ is, the\n/// more gently the probabilities drop; the lower it is, the more quickly they drop. $m_u$ must be\n/// greater than $a$. It may be arbitrarily high, but note that the iteration time increases\n/// linearly with `um_numerator + um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[a, b)$. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n///\n/// and whenever $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if $a \\geq b$, if `um_numerator` or `um_denominator` are zero, if their ratio is less\n/// than or equal to $a$, or if they are too large and manipulating them leads to arithmetic\n/// overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_unsigned_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_unsigned_range::<u16>(EXAMPLE_SEED, 1, 7, 3, 1),\n///         10\n///     ),\n///     \"[2, 5, 2, 3, 4, 2, 5, 6, 1, 2, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p} + a - 1$, or $p = \\frac{1}{m_u - a + 1}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^np}{(1-p)^a-(1-p)^b} & \\text{if} \\\\quad a \\\\leq n < b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n#[inline]\npub fn geometric_random_unsigned_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> GeometricRandomNaturalValues<T> {\n    assert!(a < b, \"a must be less than b. a: {a}, b: {b}\");\n    geometric_random_natural_values_inclusive_range(\n        seed,\n        a,\n        b - T::ONE,\n        um_numerator,\n        um_denominator,\n    )\n}\n\n/// Generates random unsigned integers from a truncated geometric distribution over the closed\n/// interval $[a, b]$.\n///\n/// With this distribution, the probability of a value being generated decreases as the value\n/// increases. The probabilities $P(a), P(a + 1), P(a + 2), \\ldots$ decrease in a geometric\n/// sequence; that's where the \"geometric\" comes from. Unlike a true geometric distribution, this\n/// distribution is truncated, meaning that values above $b$ are never generated.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `um_numerator / um_denominator`. The unadjusted mean is what\n/// the mean generated value would be if the distribution were not truncated. If $m_u$ is\n/// significantly lower than $b$, then it is very close to the actual mean. The higher $m_u$ is, the\n/// more gently the probabilities drop; the lower it is, the more quickly they drop. $m_u$ must be\n/// greater than $a$. It may be arbitrarily high, but note that the iteration time increases\n/// linearly with `um_numerator + um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[a, b]$. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n///\n/// and whenever $n, n + 1 \\in S$,\n/// $$\n/// \\frac{P(n)}{P(n+1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if $a > b$, if `um_numerator` or `um_denominator` are zero, if their ratio is less than\n/// or equal to $a$, or if they are too large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_unsigned_inclusive_range::<u16>(EXAMPLE_SEED, 1, 6, 3, 1),\n///         10\n///     ),\n///     \"[2, 5, 2, 3, 4, 2, 5, 6, 1, 2, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// Geometric distributions are more typically parametrized by a parameter $p$. The relationship\n/// between $p$ and $m_u$ is $m_u = \\frac{1}{p} + a - 1$, or $p = \\frac{1}{m_u - a + 1}$.\n///\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^np}{(1-p)^a-(1-p)^{b+1}} & \\text{if} \\\\quad a \\\\leq n \\\\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n#[inline]\npub fn geometric_random_unsigned_inclusive_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n    um_numerator: u64,\n    um_denominator: u64,\n) -> GeometricRandomNaturalValues<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    geometric_random_natural_values_inclusive_range(seed, a, b, um_numerator, um_denominator)\n}\n\n/// Generates random signed integers from a modified geometric distribution over the half-open\n/// interval $[a, b)$.\n///\n/// With this distribution, the probability of a value being generated decreases as its absolute\n/// value increases. The probabilities $P(n), P(n + \\operatorname{sgn}(n)), P(n +\n/// 2\\operatorname{sgn}(n)), \\ldots$, where $n, n + \\operatorname{sgn}(n), n +\n/// 2\\operatorname{sgn}(n), \\ldots \\in [a, b) \\\\setminus \\\\{0\\\\}$, decrease in a geometric sequence;\n/// that's where the \"geometric\" comes from.\n///\n/// The form of the distribution depends on the range. If $a \\geq 0$, the distribution is highest at\n/// $a$ and is truncated at $b$. If $b \\leq 1$, the distribution is reflected: it is highest at $b -\n/// 1$ and is truncated at $a$. Otherwise, the interval includes both positive and negative values.\n/// In that case the distribution is doubled: it is highest at zero and is truncated at $a$ and $b$.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `abs_um_numerator / abs_um_denominator`. The unadjusted mean\n/// is what the mean of the absolute values of the generated values would be if the distribution\n/// were not truncated. If $m_u$ is significantly lower than $b$, then it is very close to the\n/// actual mean of the absolute values. The higher $m_u$ is, the more gently the probabilities drop;\n/// the lower it is, the more quickly they drop. $m_u$ must be greater than $a$. It may be\n/// arbitrarily high, but note that the iteration time increases linearly with `abs_um_numerator +\n/// abs_um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[a, b)$. Let $c = \\min_{n\\in S}|n|$. Geometric distributions are typically parametrized\n/// by a parameter $p$. The relationship between $p$ and $m_u$ is $m_u = \\frac{1}{p} + c - 1$, or $p\n/// = \\frac{1}{m_u - c + 1}$. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n/// If $0, 1 \\in S$, then\n/// $$\n/// \\frac{P(0)}{P(1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n/// If $-1, 0 \\in S$, then\n/// $$\n/// \\frac{P(0)}{P(-1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n/// and whenever $n, n + \\operatorname{sgn}(n) \\in S \\setminus \\\\{0\\\\}$,\n/// $$\n/// \\frac{P(n)}{P(n+\\operatorname{sgn}(n))} = \\frac{m_u + 1}{m_u}.\n/// $$\n///\n/// As a corollary, $P(n) = P(-n)$ whenever $n, -n \\in S$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if $a \\geq b$, if `um_numerator` or `um_denominator` are zero, if their ratio is less\n/// than or equal to $a$, or if they are too large and manipulating them leads to arithmetic\n/// overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_signed_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_signed_range::<i8>(EXAMPLE_SEED, -100, 100, 30, 1),\n///         10\n///     ),\n///     \"[-32, -31, -88, 52, -40, 64, -36, -1, -7, 46, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^np}{(1-p)^a-(1-p)^b} & \\text{if} \\\\quad 0 \\\\leq a \\\\leq n < b, \\\\\\\\\n///     \\frac{(1-p)^{-n}p}{(1-p)^{1-b}-(1-p)^{1-a}} & \\text{if} \\\\quad a \\\\leq n < b \\\\leq 1, \\\\\\\\\n///     \\frac{(1-p)^{|n|}p}{2-p-(1-p)^{1-a}-(1-p)^b} &\n///         \\text{if} \\\\quad a < 0 < 1 < b \\\\ \\mathrm{and} \\\\ a \\\\leq n < b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n#[inline]\npub fn geometric_random_signed_range<T: PrimitiveSigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomSignedRange<T> {\n    assert!(a < b, \"a must be less than b. a: {a}, b: {b}\");\n    if a >= T::ZERO {\n        GeometricRandomSignedRange::NonNegative(geometric_random_natural_values_inclusive_range(\n            seed,\n            a,\n            b - T::ONE,\n            abs_um_numerator,\n            abs_um_denominator,\n        ))\n    } else if b <= T::ONE {\n        GeometricRandomSignedRange::NonPositive(geometric_random_negative_signeds_inclusive_range(\n            seed,\n            b - T::ONE,\n            a,\n            abs_um_numerator,\n            abs_um_denominator,\n        ))\n    } else {\n        GeometricRandomSignedRange::BothSigns(geometric_random_signed_inclusive_range_helper(\n            seed,\n            a,\n            b - T::ONE,\n            abs_um_numerator,\n            abs_um_denominator,\n        ))\n    }\n}\n\n/// Generates random signed integers from a modified geometric distribution over the closed interval\n/// $[a, b]$.\n///\n/// With this distribution, the probability of a value being generated decreases as its absolute\n/// value increases. The probabilities $P(n), P(n + \\operatorname{sgn}(n)), P(n +\n/// 2\\operatorname{sgn}(n)), \\ldots$, where $n, n + \\operatorname{sgn}(n), n +\n/// 2\\operatorname{sgn}(n), \\ldots \\in [a, b] \\\\setminus \\\\{0\\\\}$, decrease in a geometric sequence;\n/// that's where the \"geometric\" comes from.\n///\n/// The form of the distribution depends on the range. If $a \\geq 0$, the distribution is highest at\n/// $a$ and is truncated at $b$. If $b \\leq 0$, the distribution is reflected: it is highest at $b$\n/// and is truncated at $a$. Otherwise, the interval includes both positive and negative values. In\n/// that case the distribution is doubled: it is highest at zero and is truncated at $a$ and $b$.\n///\n/// The probabilities can drop more quickly or more slowly depending on a parameter $m_u$, called\n/// the unadjusted mean. It is equal to `abs_um_numerator / abs_um_denominator`. The unadjusted mean\n/// is what the mean of the absolute values of the generated values would be if the distribution\n/// were not truncated. If $m_u$ is significantly lower than $b$, then it is very close to the\n/// actual mean of the absolute values. The higher $m_u$ is, the more gently the probabilities drop;\n/// the lower it is, the more quickly they drop. $m_u$ must be greater than $a$. It may be\n/// arbitrarily high, but note that the iteration time increases linearly with `abs_um_numerator +\n/// abs_um_denominator`.\n///\n/// Here is a more precise characterization of this distribution. Let its support $S \\subset \\Z$\n/// equal $[a, b]$. Let $c = \\min_{n\\in S}|n|$. Geometric distributions are typically parametrized\n/// by a parameter $p$. The relationship between $p$ and $m_u$ is $m_u = \\frac{1}{p} + c - 1$, or $p\n/// = \\frac{1}{m_u - c + 1}$. Then we have\n/// $$\n/// P(n) \\neq 0 \\leftrightarrow n \\in S\n/// $$\n/// If $0, 1 \\in S$, then\n/// $$\n/// \\frac{P(0)}{P(1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n/// If $-1, 0 \\in S$, then\n/// $$\n/// \\frac{P(0)}{P(-1)} = \\frac{m_u + 1}{m_u}.\n/// $$\n/// and whenever $n, n + \\operatorname{sgn}(n) \\in S \\setminus \\\\{0\\\\}$,\n/// $$\n/// \\frac{P(n)}{P(n+\\operatorname{sgn}(n))} = \\frac{m_u + 1}{m_u}.\n/// $$\n///\n/// As a corollary, $P(n) = P(-n)$ whenever $n, -n \\in S$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if $a > b$, if `um_numerator` or `um_denominator` are zero, if their ratio is less than\n/// or equal to $a$, or if they are too large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::geometric::geometric_random_signed_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         geometric_random_signed_inclusive_range::<i8>(EXAMPLE_SEED, -100, 99, 30, 1),\n///         10\n///     ),\n///     \"[-32, -31, -88, 52, -40, 64, -36, -1, -7, 46, ...]\"\n/// )\n/// ```\n///\n/// # Further details\n/// The probability mass function of this distribution is\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{(1-p)^np}{(1-p)^a-(1-p)^{b+1}} & \\text{if} \\\\quad 0 \\\\leq a \\\\leq n \\\\leq b, \\\\\\\\\n///     \\frac{(1-p)^{-n}p}{(1-p)^{-b}-(1-p)^{1-a}}\n///         & \\text{if} \\\\quad a \\\\leq n \\\\leq b \\\\leq 0, \\\\\\\\\n///     \\frac{(1-p)^{|n|}p}{2-p-(1-p)^{1-a}-(1-p)^{b+1}}\n///         & \\text{if} \\\\quad a < 0 < b \\\\ \\mathrm{and} \\\\ a \\\\leq n \\\\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n#[inline]\npub fn geometric_random_signed_inclusive_range<T: PrimitiveSigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> GeometricRandomSignedRange<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    if a >= T::ZERO {\n        GeometricRandomSignedRange::NonNegative(geometric_random_natural_values_inclusive_range(\n            seed,\n            a,\n            b,\n            abs_um_numerator,\n            abs_um_denominator,\n        ))\n    } else if b <= T::ZERO {\n        GeometricRandomSignedRange::NonPositive(geometric_random_negative_signeds_inclusive_range(\n            seed,\n            b,\n            a,\n            abs_um_numerator,\n            abs_um_denominator,\n        ))\n    } else {\n        GeometricRandomSignedRange::BothSigns(geometric_random_signed_inclusive_range_helper(\n            seed,\n            a,\n            b,\n            abs_um_numerator,\n            abs_um_denominator,\n        ))\n    }\n}\n\n/// Generates a random signed integers from a modified geometric distribution over the closed\n/// interval $[a, b]$.\n///\n/// See [`geometric_random_signed_inclusive_range`] for a detailed description of the distribution.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ = `um_numerator + um_denominator`.\n///\n/// # Panics\n/// Panics if $a > b$, if `um_numerator` or `um_denominator` are zero, if their ratio is less than\n/// or equal to $a$, or if they are too large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::geometric::get_geometric_random_signed_from_inclusive_range;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     get_geometric_random_signed_from_inclusive_range::<i8>(\n///         &mut VariableRangeGenerator::new(EXAMPLE_SEED),\n///         -100,\n///         99,\n///         30,\n///         1\n///     ),\n///     8\n/// )\n/// ```\npub fn get_geometric_random_signed_from_inclusive_range<T: PrimitiveSigned>(\n    range_generator: &mut VariableRangeGenerator,\n    a: T,\n    b: T,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n) -> T {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    if a >= T::ZERO {\n        get_geometric_random_natural_value_from_inclusive_range(\n            range_generator,\n            a,\n            b,\n            abs_um_numerator,\n            abs_um_denominator,\n        )\n    } else if b <= T::ZERO {\n        get_geometric_random_negative_signed_from_inclusive_range(\n            range_generator,\n            b,\n            a,\n            abs_um_numerator,\n            abs_um_denominator,\n        )\n    } else {\n        get_geometric_random_signed_from_inclusive_range_helper(\n            range_generator,\n            a,\n            b,\n            abs_um_numerator,\n            abs_um_denominator,\n        )\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/num/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::{RandomBools, random_bools};\nuse crate::iterators::{\n    NonzeroValues, WithSpecialValue, WithSpecialValues, nonzero_values, with_special_value,\n    with_special_values,\n};\nuse crate::num::arithmetic::traits::{Parity, PowerOf2, ShrRound};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::float::NiceFloat;\nuse crate::num::iterators::{IteratorToBitChunks, iterator_to_bit_chunks};\nuse crate::num::logic::traits::{BitAccess, SignificantBits};\nuse crate::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomSignedRange,\n    geometric_random_signed_inclusive_range, geometric_random_unsigned_inclusive_range,\n    geometric_random_unsigneds,\n};\nuse crate::random::{EXAMPLE_SEED, Seed};\nuse crate::rounding_modes::RoundingMode::*;\nuse crate::vecs::{RandomValuesFromVec, random_values_from_vec};\nuse itertools::Itertools;\nuse rand::Rng;\nuse rand_chacha::ChaCha20Rng;\nuse std::collections::HashMap;\nuse std::convert::identity;\nuse std::fmt::Debug;\nuse std::marker::PhantomData;\n\n// Uniformly generates random primitive integers.\n#[doc(hidden)]\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct ThriftyRandomState {\n    x: u32,\n    bits_left: u64,\n}\n\n#[doc(hidden)]\npub trait HasRandomPrimitiveInts {\n    type State: Clone + Debug;\n\n    fn new_state() -> Self::State;\n\n    fn get_random(rng: &mut ChaCha20Rng, state: &mut Self::State) -> Self;\n}\n\nmacro_rules! impl_trivial_random_primitive_ints {\n    ($t: ident) => {\n        impl HasRandomPrimitiveInts for $t {\n            type State = ();\n\n            #[inline]\n            fn new_state() -> () {}\n\n            #[inline]\n            fn get_random(rng: &mut ChaCha20Rng, _state: &mut ()) -> $t {\n                rng.random()\n            }\n        }\n    };\n}\nimpl_trivial_random_primitive_ints!(u32);\nimpl_trivial_random_primitive_ints!(u64);\nimpl_trivial_random_primitive_ints!(u128);\nimpl_trivial_random_primitive_ints!(i32);\nimpl_trivial_random_primitive_ints!(i64);\nimpl_trivial_random_primitive_ints!(i128);\n\nimpl HasRandomPrimitiveInts for usize {\n    type State = ();\n\n    #[inline]\n    fn new_state() {}\n\n    #[inline]\n    fn get_random(rng: &mut ChaCha20Rng, _state: &mut ()) -> Self {\n        if USIZE_IS_U32 {\n            let x: u32 = rng.random();\n            x as Self\n        } else {\n            let x: u64 = rng.random();\n            x as Self\n        }\n    }\n}\n\nimpl HasRandomPrimitiveInts for isize {\n    type State = ();\n\n    #[inline]\n    fn new_state() {}\n\n    #[inline]\n    fn get_random(rng: &mut ChaCha20Rng, _state: &mut ()) -> Self {\n        if USIZE_IS_U32 {\n            let x: i32 = rng.random();\n            x as Self\n        } else {\n            let x: i64 = rng.random();\n            x as Self\n        }\n    }\n}\n\nfn get_random<T: PrimitiveInt>(rng: &mut ChaCha20Rng, state: &mut ThriftyRandomState) -> T {\n    if state.bits_left == 0 {\n        state.x = rng.random();\n        state.bits_left = u32::WIDTH - T::WIDTH;\n    } else {\n        state.x >>= T::WIDTH;\n        state.bits_left -= T::WIDTH;\n    }\n    T::wrapping_from(state.x)\n}\n\nmacro_rules! impl_thrifty_random_primitive_ints {\n    ($t: ident) => {\n        impl HasRandomPrimitiveInts for $t {\n            type State = ThriftyRandomState;\n\n            #[inline]\n            fn new_state() -> ThriftyRandomState {\n                ThriftyRandomState { x: 0, bits_left: 0 }\n            }\n\n            #[inline]\n            fn get_random(rng: &mut ChaCha20Rng, state: &mut ThriftyRandomState) -> $t {\n                get_random(rng, state)\n            }\n        }\n    };\n}\nimpl_thrifty_random_primitive_ints!(u8);\nimpl_thrifty_random_primitive_ints!(u16);\nimpl_thrifty_random_primitive_ints!(i8);\nimpl_thrifty_random_primitive_ints!(i16);\n\n/// Uniformly generates random primitive integers.\n///\n/// This `struct` is created by [`random_primitive_ints`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomPrimitiveInts<T: HasRandomPrimitiveInts> {\n    pub(crate) rng: ChaCha20Rng,\n    pub(crate) state: T::State,\n}\n\nimpl<T: HasRandomPrimitiveInts> Iterator for RandomPrimitiveInts<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        Some(T::get_random(&mut self.rng, &mut self.state))\n    }\n}\n\n/// Uniformly generates random unsigned integers less than a positive limit.\n///\n/// This `enum` is created by [`random_unsigneds_less_than`]; see its documentation for more.\n#[allow(clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum RandomUnsignedsLessThan<T: PrimitiveUnsigned> {\n    One,\n    AtLeastTwo(RandomUnsignedBitChunks<T>, T),\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for RandomUnsignedsLessThan<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::One => Some(T::ZERO),\n            Self::AtLeastTwo(xs, limit) => loop {\n                let x = xs.next();\n                if x.unwrap() < *limit {\n                    return x;\n                }\n            },\n        }\n    }\n}\n\n/// Uniformly generates random unsigned integers in the half-open interval $[a, b)$.\n///\n/// This `struct` is created by [`random_unsigned_range`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomUnsignedRange<T: PrimitiveUnsigned> {\n    pub(crate) xs: RandomUnsignedsLessThan<T>,\n    pub(crate) a: T,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for RandomUnsignedRange<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.xs.next().map(|x| x + self.a)\n    }\n}\n\n/// Uniformly generates random unsigned integers in the closed interval $[a, b]$.\n///\n/// This `struct` is created by [`random_unsigned_inclusive_range`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub enum RandomUnsignedInclusiveRange<T: PrimitiveUnsigned> {\n    NotAll(RandomUnsignedsLessThan<T>, T),\n    All(RandomPrimitiveInts<T>),\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for RandomUnsignedInclusiveRange<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::NotAll(xs, a) => xs.next().map(|x| x + *a),\n            Self::All(xs) => xs.next(),\n        }\n    }\n}\n\n#[doc(hidden)]\npub trait HasRandomSignedRange: Sized {\n    type UnsignedValue: PrimitiveUnsigned;\n\n    fn new_unsigned_range(seed: Seed, a: Self, b: Self)\n    -> RandomUnsignedRange<Self::UnsignedValue>;\n\n    fn new_unsigned_inclusive_range(\n        seed: Seed,\n        a: Self,\n        b: Self,\n    ) -> RandomUnsignedInclusiveRange<Self::UnsignedValue>;\n\n    fn from_unsigned_value(x: Self::UnsignedValue) -> Self;\n}\n\nmacro_rules! impl_has_random_signed_range {\n    ($u: ident, $s: ident) => {\n        impl HasRandomSignedRange for $s {\n            type UnsignedValue = $u;\n\n            fn new_unsigned_range(seed: Seed, mut a: $s, mut b: $s) -> RandomUnsignedRange<$u> {\n                a.flip_bit($u::WIDTH - 1);\n                b.flip_bit($u::WIDTH - 1);\n                random_unsigned_range(seed, $u::wrapping_from(a), $u::wrapping_from(b))\n            }\n\n            fn new_unsigned_inclusive_range(\n                seed: Seed,\n                mut a: $s,\n                mut b: $s,\n            ) -> RandomUnsignedInclusiveRange<$u> {\n                a.flip_bit($u::WIDTH - 1);\n                b.flip_bit($u::WIDTH - 1);\n                random_unsigned_inclusive_range(seed, $u::wrapping_from(a), $u::wrapping_from(b))\n            }\n\n            fn from_unsigned_value(mut u: $u) -> $s {\n                u.flip_bit($u::WIDTH - 1);\n                $s::wrapping_from(u)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_has_random_signed_range);\n\n/// Uniformly generates random signed integers in the half-open interval $[a, b)$.\n///\n/// This `struct` is created by [`random_signed_range`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomSignedRange<T: HasRandomSignedRange> {\n    pub(crate) xs: RandomUnsignedRange<T::UnsignedValue>,\n}\n\nimpl<T: HasRandomSignedRange> Iterator for RandomSignedRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.xs.next().map(T::from_unsigned_value)\n    }\n}\n\n/// Uniformly generates random signed integers in the closed interval $[a, b]$.\n///\n/// This `struct` is created by [`random_signed_inclusive_range`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomSignedInclusiveRange<T: HasRandomSignedRange> {\n    pub(crate) xs: RandomUnsignedInclusiveRange<T::UnsignedValue>,\n}\n\nimpl<T: HasRandomSignedRange> Iterator for RandomSignedInclusiveRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.xs.next().map(T::from_unsigned_value)\n    }\n}\n\n/// Uniformly generates unsigned integers with up to some number of bits.\n///\n/// This `struct` is created by [`random_unsigned_bit_chunks`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomUnsignedBitChunks<T: PrimitiveUnsigned> {\n    xs: IteratorToBitChunks<RandomPrimitiveInts<T>, T, T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for RandomUnsignedBitChunks<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.xs.next_with_wrapping(identity).map(Option::unwrap)\n    }\n}\n\n#[doc(hidden)]\npub trait RandomSignedChunkable: Sized {\n    type AbsoluteChunks: Clone + Debug;\n\n    fn new_absolute_chunks(seed: Seed, chunk_size: u64) -> Self::AbsoluteChunks;\n\n    fn next_chunk(xs: &mut Self::AbsoluteChunks) -> Option<Self>;\n}\n\nmacro_rules! impl_random_signed_chunkable {\n    ($u: ident, $s: ident) => {\n        impl RandomSignedChunkable for $s {\n            type AbsoluteChunks = RandomUnsignedBitChunks<$u>;\n\n            fn new_absolute_chunks(seed: Seed, chunk_size: u64) -> RandomUnsignedBitChunks<$u> {\n                random_unsigned_bit_chunks(seed, chunk_size)\n            }\n\n            fn next_chunk(xs: &mut Self::AbsoluteChunks) -> Option<$s> {\n                xs.next().map(WrappingFrom::wrapping_from)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_random_signed_chunkable);\n\n/// Uniformly generates signed integers with up to some number of bits.\n///\n/// This `struct` is created by [`random_signed_bit_chunks`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomSignedBitChunks<T: RandomSignedChunkable> {\n    pub(crate) xs: T::AbsoluteChunks,\n}\n\nimpl<T: RandomSignedChunkable> Iterator for RandomSignedBitChunks<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        T::next_chunk(&mut self.xs)\n    }\n}\n\n/// Modifies the output values of an iterator by setting their highest bit.\n#[derive(Clone, Debug)]\npub struct RandomHighestBitSetValues<I: Iterator>\nwhere\n    I::Item: PrimitiveInt,\n{\n    pub(crate) xs: I,\n    pub(crate) mask: I::Item,\n}\n\nimpl<I: Iterator> Iterator for RandomHighestBitSetValues<I>\nwhere\n    I::Item: PrimitiveInt,\n{\n    type Item = I::Item;\n\n    #[inline]\n    fn next(&mut self) -> Option<I::Item> {\n        self.xs.next().map(|x| x | self.mask)\n    }\n}\n\n/// Uniformly generates random primitive integers.\n///\n/// $P(x) = 2^{-W}$, where $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_primitive_ints::<u8>(EXAMPLE_SEED), 10),\n///     \"[113, 239, 69, 108, 228, 210, 168, 161, 87, 32, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_primitive_ints<T: PrimitiveInt>(seed: Seed) -> RandomPrimitiveInts<T> {\n    RandomPrimitiveInts {\n        rng: seed.get_rng(),\n        state: T::new_state(),\n    }\n}\n\n/// Uniformly generates random positive unsigned integers.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\\\frac{1}{2^W-1} & \\text{if} \\\\quad x > 0, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_positive_unsigneds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_positive_unsigneds::<u8>(EXAMPLE_SEED), 10),\n///     \"[113, 239, 69, 108, 228, 210, 168, 161, 87, 32, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_positive_unsigneds<T: PrimitiveUnsigned>(\n    seed: Seed,\n) -> NonzeroValues<RandomPrimitiveInts<T>> {\n    nonzero_values(random_primitive_ints(seed))\n}\n\n/// Uniformly generates random positive signed integers.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\\\frac{1}{2^{W-1}-1} & \\text{if} \\\\quad x > 0, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_positive_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_positive_signeds::<i8>(EXAMPLE_SEED), 10),\n///     \"[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_positive_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n) -> NonzeroValues<RandomSignedBitChunks<T>> {\n    nonzero_values(random_natural_signeds(seed))\n}\n\n/// Uniformly generates random negative signed integers.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     2^{1-W} & \\text{if} \\\\quad x < 0, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_negative_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_negative_signeds::<i8>(EXAMPLE_SEED), 10),\n///     \"[-15, -34, -105, -30, -58, -36, -76, -44, -95, -81, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_negative_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n) -> RandomHighestBitSetValues<RandomSignedBitChunks<T>> {\n    RandomHighestBitSetValues {\n        xs: random_signed_bit_chunks(seed, T::WIDTH - 1),\n        mask: T::MIN,\n    }\n}\n\n/// Uniformly generates random natural (non-negative) signed integers.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     2^{1-W} & \\text{if} \\\\quad x \\geq 0, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_natural_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_natural_signeds::<i8>(EXAMPLE_SEED), 10),\n///     \"[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_natural_signeds<T: PrimitiveSigned>(seed: Seed) -> RandomSignedBitChunks<T> {\n    random_signed_bit_chunks(seed, T::WIDTH - 1)\n}\n\n/// Uniformly generates random nonzero signed integers.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\\\frac{1}{2^W-1} & \\text{if} \\\\quad x \\\\neq 0, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_nonzero_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_nonzero_signeds::<i8>(EXAMPLE_SEED), 10),\n///     \"[113, -17, 69, 108, -28, -46, -88, -95, 87, 32, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_nonzero_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n) -> NonzeroValues<RandomPrimitiveInts<T>> {\n    nonzero_values(random_primitive_ints(seed))\n}\n\n/// Uniformly generates random unsigned integers less than a positive limit.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{\\\\ell} & \\text{if} \\\\quad x < \\\\ell, \\\\\\\\\n///     0 & \\\\text{otherwise,}\n/// \\\\end{cases}\n/// $$\n/// where $\\ell$ is `limit`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `limit` is 0.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_unsigneds_less_than;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_unsigneds_less_than::<u8>(EXAMPLE_SEED, 10), 10),\n///     \"[1, 7, 5, 4, 6, 4, 2, 8, 1, 7, ...]\"\n/// )\n/// ```\npub fn random_unsigneds_less_than<T: PrimitiveUnsigned>(\n    seed: Seed,\n    limit: T,\n) -> RandomUnsignedsLessThan<T> {\n    if limit == T::ZERO {\n        panic!(\"limit cannot be 0.\");\n    } else if limit == T::ONE {\n        RandomUnsignedsLessThan::One\n    } else {\n        RandomUnsignedsLessThan::AtLeastTwo(\n            random_unsigned_bit_chunks(seed, limit.ceiling_log_base_2()),\n            limit,\n        )\n    }\n}\n\n/// Uniformly generates random unsigned integers in the half-open interval $[a, b)$.\n///\n/// $a$ must be less than $b$. This function cannot create a range that includes `T::MAX`; for that,\n/// use [`random_unsigned_inclusive_range`].\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a} & \\text{if} \\\\quad a \\leq x < b, \\\\\\\\\n///     0 & \\\\text{otherwise.}\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_unsigned_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_unsigned_range::<u8>(EXAMPLE_SEED, 10, 20), 10),\n///     \"[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, ...]\"\n/// )\n/// ```\npub fn random_unsigned_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n) -> RandomUnsignedRange<T> {\n    assert!(a < b, \"a must be less than b. a: {a}, b: {b}\");\n    RandomUnsignedRange {\n        xs: random_unsigneds_less_than(seed, b - a),\n        a,\n    }\n}\n\n/// Uniformly generates random unsigned integers in the closed interval $[a, b]$.\n///\n/// $a$ must be less than or equal to $b$.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a+1} & \\text{if} \\\\quad a \\leq x \\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise.}\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_unsigned_inclusive_range::<u8>(EXAMPLE_SEED, 10, 19),\n///         10\n///     ),\n///     \"[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, ...]\"\n/// )\n/// ```\npub fn random_unsigned_inclusive_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n) -> RandomUnsignedInclusiveRange<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    if a == T::ZERO && b == T::MAX {\n        RandomUnsignedInclusiveRange::All(random_primitive_ints(seed))\n    } else {\n        RandomUnsignedInclusiveRange::NotAll(random_unsigneds_less_than(seed, b - a + T::ONE), a)\n    }\n}\n\n/// Uniformly generates random signed integers in the half-open interval $[a, b)$.\n///\n/// $a$ must be less than $b$. This function cannot create a range that includes `T::MAX`; for that,\n/// use [`random_signed_inclusive_range`].\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a} & \\text{if} \\\\quad a \\leq x < b, \\\\\\\\\n///     0 & \\\\text{otherwise.}\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_signed_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_signed_range::<i8>(EXAMPLE_SEED, -100, 100), 10),\n///     \"[13, -31, 8, 68, 61, -13, -68, 10, -17, 88, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_signed_range<T: PrimitiveSigned>(seed: Seed, a: T, b: T) -> RandomSignedRange<T> {\n    assert!(a < b, \"a must be less than b. a: {a}, b: {b}\");\n    RandomSignedRange {\n        xs: T::new_unsigned_range(seed, a, b),\n    }\n}\n\n/// Uniformly generates random signed integers in the closed interval $[a, b]$.\n///\n/// $a$ must be less than or equal to $b$.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a+1} & \\text{if} \\\\quad a \\leq x \\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise.}\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_signed_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_signed_inclusive_range::<i8>(EXAMPLE_SEED, -100, 99),\n///         10\n///     ),\n///     \"[13, -31, 8, 68, 61, -13, -68, 10, -17, 88, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_signed_inclusive_range<T: PrimitiveSigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n) -> RandomSignedInclusiveRange<T> {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    RandomSignedInclusiveRange {\n        xs: T::new_unsigned_inclusive_range(seed, a, b),\n    }\n}\n\n/// Uniformly generates unsigned integers containing some maximum number of bits.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     2^{-c} & \\text{if} \\\\quad 0 \\\\leq x < 2^c, \\\\\\\\\n///     0 & \\\\text{otherwise,}\n/// \\\\end{cases}\n/// $$\n/// where $c$ is `chunk_size`.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `chunk_size` is zero or greater than the width of the type.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_unsigned_bit_chunks;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_unsigned_bit_chunks::<u8>(EXAMPLE_SEED, 3), 10),\n///     \"[1, 6, 5, 7, 6, 3, 1, 2, 4, 5, ...]\"\n/// )\n/// ```\npub fn random_unsigned_bit_chunks<T: PrimitiveUnsigned>(\n    seed: Seed,\n    chunk_size: u64,\n) -> RandomUnsignedBitChunks<T> {\n    RandomUnsignedBitChunks {\n        xs: iterator_to_bit_chunks(random_primitive_ints(seed), T::WIDTH, chunk_size),\n    }\n}\n\n/// Uniformly generates signed integers containing some maximum number of bits.\n///\n/// The generated values will all be non-negative unless `chunk_size` is equal to the width of the\n/// type.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     2^{-c} & \\text{if} \\\\quad c = W \\\\ \\\\text{or}\n///         \\\\ (c < W \\\\ \\\\text{and} \\\\ 0 \\\\leq x < 2^c), \\\\\\\\\n///     0 & \\\\text{otherwise,}\n/// \\\\end{cases}\n/// $$\n/// where $c$ is `chunk_size` and $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `chunk_size` is zero or greater than the width of the type.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_signed_bit_chunks;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_signed_bit_chunks::<i8>(EXAMPLE_SEED, 3), 10),\n///     \"[1, 6, 5, 7, 6, 3, 1, 2, 4, 5, ...]\"\n/// )\n/// ```\npub fn random_signed_bit_chunks<T: PrimitiveSigned>(\n    seed: Seed,\n    chunk_size: u64,\n) -> RandomSignedBitChunks<T> {\n    assert!(chunk_size <= T::WIDTH);\n    RandomSignedBitChunks {\n        xs: T::new_absolute_chunks(seed, chunk_size),\n    }\n}\n\n/// Uniformly generates unsigned integers whose highest bit is set.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     2^{1-W} & \\text{if} \\\\quad 2^{W-1} \\\\leq x < 2^W ,\\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $W$ is the width of the type.\n///\n/// The output length is infinite.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_highest_bit_set_unsigneds;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(random_highest_bit_set_unsigneds::<u8>(EXAMPLE_SEED), 10),\n///     \"[241, 222, 151, 226, 198, 220, 180, 212, 161, 175, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_highest_bit_set_unsigneds<T: PrimitiveUnsigned>(\n    seed: Seed,\n) -> RandomHighestBitSetValues<RandomUnsignedBitChunks<T>> {\n    RandomHighestBitSetValues {\n        xs: random_unsigned_bit_chunks(seed, T::WIDTH - 1),\n        mask: T::power_of_2(T::WIDTH - 1),\n    }\n}\n\n/// Generates random primitive floats in the half-open interval $[a, b)$.\n///\n/// This `struct` is created by [`random_primitive_float_range`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomPrimitiveFloatRange<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    xs: RandomUnsignedRange<u64>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for RandomPrimitiveFloatRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.xs.next().map(T::from_ordered_representation)\n    }\n}\n\n/// Generates random primitive floats in the closed interval $[a, b]$.\n///\n/// This `struct` is created by [`random_primitive_float_inclusive_range`]; see its documentation\n/// for more.\n#[derive(Clone, Debug)]\npub struct RandomPrimitiveFloatInclusiveRange<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    xs: RandomUnsignedInclusiveRange<u64>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for RandomPrimitiveFloatInclusiveRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.xs.next().map(T::from_ordered_representation)\n    }\n}\n\n/// Generates random primitive floats in the half-open interval $[a, b)$.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, if the range\n/// is $[0, 2)$, a float in $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since\n/// these subranges contain an equal number of floats.\n///\n/// Positive and negative zero are treated as two distinct values, with negative zero being smaller\n/// than zero.\n///\n/// `NaN` is never generated.\n///\n/// $a$ must be less than $b$. This function cannot create a range that includes `T::INFINITY`; for\n/// that, use [`random_primitive_float_inclusive_range`].\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_primitive_float_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_primitive_float_range::<f32>(EXAMPLE_SEED, -0.1, 0.1).map(NiceFloat),\n///         10\n///     ),\n///     \"[5.664681e-11, 1.2492925e-35, 2.3242339e-29, 4.699183e-7, -2.8244436e-36, -2.264039e-37, \\\n///     -0.0000017299129, 1.40616e-23, 2.7418007e-27, 1.5418819e-16, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_primitive_float_range<T: PrimitiveFloat>(\n    seed: Seed,\n    a: T,\n    b: T,\n) -> RandomPrimitiveFloatRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(\n        NiceFloat(a) < NiceFloat(b),\n        \"a must be less than b. a: {}, b: {}\",\n        NiceFloat(a),\n        NiceFloat(b)\n    );\n    RandomPrimitiveFloatRange {\n        phantom: PhantomData,\n        xs: random_unsigned_range(\n            seed,\n            a.to_ordered_representation(),\n            b.to_ordered_representation(),\n        ),\n    }\n}\n\n/// Generates random primitive floats in the closed interval $[a, b]$.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, if the range\n/// is $[0, 2]$, a float in $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since\n/// these subranges contain an equal number of floats.\n///\n/// Positive and negative zero are treated as two distinct values, with negative zero being smaller\n/// than zero.\n///\n/// $a$ must be less than or equal to $b$.\n///\n/// `NaN` is never generated.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_primitive_float_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_primitive_float_inclusive_range::<f32>(EXAMPLE_SEED, -0.1, 0.1).map(NiceFloat),\n///         10\n///     ),\n///     \"[5.664681e-11, 1.2492925e-35, 2.3242339e-29, 4.699183e-7, -2.8244436e-36, -2.264039e-37, \\\n///     -0.0000017299129, 1.40616e-23, 2.7418007e-27, 1.5418819e-16, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_primitive_float_inclusive_range<T: PrimitiveFloat>(\n    seed: Seed,\n    a: T,\n    b: T,\n) -> RandomPrimitiveFloatInclusiveRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(\n        NiceFloat(a) <= NiceFloat(b),\n        \"a must be less than or equal to b. a: {}, b: {}\",\n        NiceFloat(a),\n        NiceFloat(b)\n    );\n    RandomPrimitiveFloatInclusiveRange {\n        phantom: PhantomData,\n        xs: random_unsigned_inclusive_range(\n            seed,\n            a.to_ordered_representation(),\n            b.to_ordered_representation(),\n        ),\n    }\n}\n\n/// Generates random finite positive primitive floats.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, a float in\n/// $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since these subranges contain an\n/// equal number of floats.\n///\n/// Positive zero is generated; negative zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_positive_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_positive_finite_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[9.5715654e26, 209.6476, 386935780.0, 7.965817e30, 0.00021030706, 0.0027270128, \\\n///     3.4398167e-34, 2.3397111e14, 44567765000.0, 2.3479653e21, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_positive_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n) -> RandomPrimitiveFloatInclusiveRange<T> {\n    random_primitive_float_inclusive_range(seed, T::MIN_POSITIVE_SUBNORMAL, T::MAX_FINITE)\n}\n\n/// Generates random finite negative primitive floats.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, a float in\n/// $(-1/2, 1/4]$ is as likely to be chosen as a float in $(-2, -1]$, since these subranges contain\n/// an equal number of floats.\n///\n/// Negative zero is generated; positive zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_negative_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_negative_finite_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[-2.3484663e-27, -0.010641626, -5.8060583e-9, -2.8182442e-31, -10462.532, -821.12994, \\\n///     -6.303163e33, -9.50376e-15, -4.9561126e-11, -8.565163e-22, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_negative_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n) -> RandomPrimitiveFloatInclusiveRange<T> {\n    random_primitive_float_inclusive_range(seed, -T::MAX_FINITE, -T::MIN_POSITIVE_SUBNORMAL)\n}\n\n/// Generates random finite nonzero primitive floats.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, a float in\n/// $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since these subranges contain an\n/// equal number of floats.\n///\n/// Neither positive nor negative zero are generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_nonzero_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_nonzero_finite_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[-2.3484663e-27, 2.287989e-18, -2.0729893e-12, 3.360012e28, -9.021723e-32, 3564911.2, \\\n///     -0.0000133769445, -1.8855448e18, 8.2494555e-29, 2.2178014e-38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_nonzero_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n) -> NonzeroValues<RandomPrimitiveFloatInclusiveRange<T>> {\n    nonzero_values(random_finite_primitive_floats(seed))\n}\n\n/// Generates random finite primitive floats.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, a float in\n/// $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since these subranges contain an\n/// equal number of floats.\n///\n/// Positive zero and negative zero are both generated. `NaN` is not.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_finite_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[-2.3484663e-27, 2.287989e-18, -2.0729893e-12, 3.360012e28, -9.021723e-32, 3564911.2, \\\n///     -0.0000133769445, -1.8855448e18, 8.2494555e-29, 2.2178014e-38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n) -> RandomPrimitiveFloatInclusiveRange<T> {\n    random_primitive_float_inclusive_range(seed, -T::MAX_FINITE, T::MAX_FINITE)\n}\n\n/// Generates random positive primitive floats.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, a float in\n/// $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since these subranges contain an\n/// equal number of floats.\n///\n/// Positive zero is generated; negative zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_positive_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_positive_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[9.5715654e26, 209.6476, 386935780.0, 7.965817e30, 0.00021030706, 0.0027270128, \\\n///     3.4398167e-34, 2.3397111e14, 44567765000.0, 2.3479653e21, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_positive_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n) -> RandomPrimitiveFloatInclusiveRange<T> {\n    random_primitive_float_inclusive_range(seed, T::MIN_POSITIVE_SUBNORMAL, T::INFINITY)\n}\n\n/// Generates random negative primitive floats.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, a float in\n/// $(-1/2, -1/4]$ is as likely to be chosen as a float in $(-2, -1]$, since these subranges contain\n/// an equal number of floats.\n///\n/// Negative zero is generated; positive zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_negative_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_negative_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[-2.3484665e-27, -0.010641627, -5.8060587e-9, -2.8182444e-31, -10462.533, -821.13, \\\n///     -6.3031636e33, -9.5037605e-15, -4.956113e-11, -8.565164e-22, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_negative_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n) -> RandomPrimitiveFloatInclusiveRange<T> {\n    random_primitive_float_inclusive_range(seed, T::NEGATIVE_INFINITY, -T::MIN_POSITIVE_SUBNORMAL)\n}\n\n/// Generates random nonzero primitive floats.\n///\n/// Every float within the range has an equal probability of being chosen. This does not mean that\n/// the distribution approximates a uniform distribution over the reals. For example, a float in\n/// $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since these subranges contain an\n/// equal number of floats.\n///\n/// Neither positive nor negative zero are generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_nonzero_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_nonzero_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[-2.3484665e-27, 2.2879888e-18, -2.0729896e-12, 3.3600117e28, -9.0217234e-32, 3564911.0, \\\n///     -0.000013376945, -1.885545e18, 8.249455e-29, 2.2178013e-38, ...]\",\n/// );\n/// ```\n#[inline]\npub fn random_nonzero_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n) -> NonzeroValues<RandomPrimitiveFloats<T>> {\n    nonzero_values(random_primitive_floats(seed))\n}\n\n/// Generates random primitive floats.\n///\n/// This `struct` is created by [`random_primitive_floats`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomPrimitiveFloats<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    pub(crate) xs: RandomUnsignedInclusiveRange<u64>,\n    nan: u64,\n}\n\nimpl<T: PrimitiveFloat> Iterator for RandomPrimitiveFloats<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.xs.next().map(|x| {\n            if x == self.nan {\n                T::NAN\n            } else {\n                T::from_ordered_representation(x)\n            }\n        })\n    }\n}\n\n/// Generates random finite primitive floats.\n///\n/// Every float has an equal probability of being chosen. This does not mean that the distribution\n/// approximates a uniform distribution over the reals. For example, a float in $[1/4, 1/2)$ is as\n/// likely to be chosen as a float in $[1, 2)$, since these subranges contain an equal number of\n/// floats.\n///\n/// Positive zero, negative zero, and `NaN` are all generated.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::random_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat),\n///         10\n///     ),\n///     \"[-2.3484665e-27, 2.2879888e-18, -2.0729896e-12, 3.3600117e28, -9.0217234e-32, 3564911.0, \\\n///     -0.000013376945, -1.885545e18, 8.249455e-29, 2.2178013e-38, ...]\"\n/// );\n/// ```\n#[inline]\npub fn random_primitive_floats<T: PrimitiveFloat>(seed: Seed) -> RandomPrimitiveFloats<T> {\n    let nan = T::INFINITY.to_ordered_representation() + 1;\n    RandomPrimitiveFloats {\n        phantom: PhantomData,\n        xs: random_unsigned_inclusive_range(seed, 0, nan),\n        nan,\n    }\n}\n\n/// Generates positive finite primitive floats.\n///\n/// This `struct` is created by [`special_random_positive_finite_primitive_floats`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct SpecialRandomPositiveFiniteFloats<T: PrimitiveFloat> {\n    seed: Seed,\n    sci_exponents: GeometricRandomSignedRange<i64>,\n    range_map: HashMap<i64, GeometricRandomNaturalValues<u64>>,\n    ranges: VariableRangeGenerator,\n    mean_precision_n: u64,\n    mean_precision_d: u64,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomPositiveFiniteFloats<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        let sci_exponent = self.sci_exponents.next().unwrap();\n        let mean_precision_n = self.mean_precision_n;\n        let mean_precision_d = self.mean_precision_d;\n        let seed = self.seed;\n        let precisions = self.range_map.entry(sci_exponent).or_insert_with(move || {\n            geometric_random_unsigned_inclusive_range(\n                seed.fork(&sci_exponent.to_string()),\n                1,\n                T::max_precision_for_sci_exponent(sci_exponent),\n                mean_precision_n,\n                mean_precision_d,\n            )\n        });\n        let precision = precisions.next().unwrap();\n        let mantissa = if precision == 1 {\n            1\n        } else {\n            // e.g. if precision is 4, generate odd values from 1001 through 1111, inclusive\n            let x = self.ranges.next_in_range(\n                u64::power_of_2(precision - 2),\n                u64::power_of_2(precision - 1),\n            );\n            (x << 1) | 1\n        };\n        T::from_integer_mantissa_and_exponent(\n            mantissa,\n            sci_exponent - i64::wrapping_from(precision) + 1,\n        )\n    }\n}\n\n/// Generates positive finite primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the mean absolute sci-exponent and precision by passing the numerators\n/// and denominators of their means.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Positive zero is generated; negative zero is not. `NaN` is not generated either. TODO: don't\n/// generate any zeros!\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_positive_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_positive_finite_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[0.80126953, 0.0000013709068, 0.015609741, 0.98552704, 65536.0, 0.008257866, \\\n///     0.017333984, 2.25, 7.7089844, 0.00004425831, 0.40625, 24576.0, 37249.0, 1.1991882, \\\n///     32.085938, 0.4375, 0.0012359619, 1536.0, 0.22912993, 0.0015716553, ...]\"\n/// );\n/// ```\npub fn special_random_positive_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> SpecialRandomPositiveFiniteFloats<T> {\n    assert_ne!(mean_precision_denominator, 0);\n    assert!(mean_precision_numerator > mean_precision_denominator);\n    SpecialRandomPositiveFiniteFloats {\n        seed: seed.fork(\"precisions\"),\n        sci_exponents: geometric_random_signed_inclusive_range(\n            EXAMPLE_SEED.fork(\"exponents\"),\n            T::MIN_EXPONENT,\n            T::MAX_EXPONENT,\n            mean_sci_exponent_numerator,\n            mean_sci_exponent_denominator,\n        ),\n        range_map: HashMap::new(),\n        ranges: VariableRangeGenerator::new(seed.fork(\"ranges\")),\n        mean_precision_n: mean_precision_numerator,\n        mean_precision_d: mean_precision_denominator,\n        phantom: PhantomData,\n    }\n}\n\n/// Generates negative finite primitive floats.\n///\n/// This `struct` is created by [`special_random_negative_finite_primitive_floats`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct SpecialRandomNegativeFiniteFloats<T: PrimitiveFloat>(\n    SpecialRandomPositiveFiniteFloats<T>,\n);\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomNegativeFiniteFloats<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        self.0.next().map(|f| -f)\n    }\n}\n\n/// Generates negative finite primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the mean absolute sci-exponent and precision by passing the numerators\n/// and denominators of their means.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Negative zero is generated; positive zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_negative_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_negative_finite_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[-0.80126953, -0.0000013709068, -0.015609741, -0.98552704, -65536.0, -0.008257866, \\\n///     -0.017333984, -2.25, -7.7089844, -0.00004425831, -0.40625, -24576.0, -37249.0, \\\n///     -1.1991882, -32.085938, -0.4375, -0.0012359619, -1536.0, -0.22912993, -0.0015716553, ...]\"\n/// );\n/// ```\n#[inline]\npub fn special_random_negative_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> SpecialRandomNegativeFiniteFloats<T> {\n    SpecialRandomNegativeFiniteFloats(special_random_positive_finite_primitive_floats(\n        seed,\n        mean_sci_exponent_numerator,\n        mean_sci_exponent_denominator,\n        mean_precision_numerator,\n        mean_precision_denominator,\n    ))\n}\n\n/// Generates nonzero finite primitive floats.\n///\n/// This `struct` is created by [`special_random_nonzero_finite_primitive_floats`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct SpecialRandomNonzeroFiniteFloats<T: PrimitiveFloat> {\n    bs: RandomBools,\n    xs: SpecialRandomPositiveFiniteFloats<T>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomNonzeroFiniteFloats<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() { x } else { -x })\n    }\n}\n\n/// Generates finite nonzero primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the mean absolute sci-exponent and precision by passing the numerators\n/// and denominators of their means.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Neither positive not negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_nonzero_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_nonzero_finite_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[-0.6328125, -9.536743e-7, -0.013671875, 0.6875, -70208.0, 0.01550293, -0.028625488, \\\n///     -3.3095703, -5.775879, 0.000034958124, 0.4375, 31678.0, -49152.0, -1.0, 49.885254, \\\n///     -0.40625, -0.0015869141, -1889.5625, -0.14140439, -0.001449585, ...]\"\n/// );\n/// ```\n#[inline]\npub fn special_random_nonzero_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> SpecialRandomNonzeroFiniteFloats<T> {\n    SpecialRandomNonzeroFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: special_random_positive_finite_primitive_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_numerator,\n            mean_sci_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates finite primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that a zero will be\n/// generated. You can also specify the mean absolute sci-exponent and precision by passing the\n/// numerators and denominators of their means of the nonzero floats.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Positive and negative zero are both generated. `NaN` is not.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_finite_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_finite_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[0.65625, 0.0000014255784, 0.013183594, 0.0, -0.8125, -74240.0, -0.0078125, -0.03060913, \\\n///     3.331552, 4.75, -0.000038146973, -0.3125, -27136.0, -0.0, -59392.0, -1.75, -41.1875, 0.0, \\\n///     0.30940247, -0.0009765625, ...]\"\n/// );\n/// ```\n#[inline]\npub fn special_random_finite_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n) -> WithSpecialValues<SpecialRandomNonzeroFiniteFloats<T>> {\n    with_special_values(\n        seed,\n        vec![T::ZERO, T::NEGATIVE_ZERO],\n        mean_zero_p_numerator,\n        mean_zero_p_denominator,\n        &|seed_2| {\n            special_random_nonzero_finite_primitive_floats(\n                seed_2,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            )\n        },\n    )\n}\n\n/// Generates positive primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that positive infinity\n/// will be generated. You can also specify the mean absolute sci-exponent and precision by passing\n/// the numerators and denominators of their means of the finite floats.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Positive zero is generated; negative zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_positive_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_positive_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[0.6328125, 9.536743e-7, 0.013671875, Infinity, 0.6875, 70208.0, 0.01550293, \\\n///     0.028625488, 3.3095703, 5.775879, 0.000034958124, 0.4375, 31678.0, Infinity, 49152.0, \\\n///     1.0, 49.885254, Infinity, 0.40625, 0.0015869141, ...]\"\n/// );\n/// ```\n#[inline]\npub fn special_random_positive_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValue<SpecialRandomPositiveFiniteFloats<T>> {\n    with_special_value(\n        seed,\n        T::INFINITY,\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            special_random_positive_finite_primitive_floats(\n                seed_2,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            )\n        },\n    )\n}\n\n/// Generates negative primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that negative infinity\n/// will be generated. You can also specify the mean absolute sci-exponent and precision by passing\n/// the numerators and denominators of their means of the finite floats.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Negative zero is generated; positive zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_negative_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_negative_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[-0.6328125, -9.536743e-7, -0.013671875, -Infinity, -0.6875, -70208.0, -0.01550293, \\\n///     -0.028625488, -3.3095703, -5.775879, -0.000034958124, -0.4375, -31678.0, -Infinity, \\\n///     -49152.0, -1.0, -49.885254, -Infinity, -0.40625, -0.0015869141, ...]\"\n/// );\n/// ```\n#[inline]\npub fn special_random_negative_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValue<SpecialRandomNegativeFiniteFloats<T>> {\n    with_special_value(\n        seed,\n        T::NEGATIVE_INFINITY,\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            special_random_negative_finite_primitive_floats(\n                seed_2,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            )\n        },\n    )\n}\n\n/// Generates nonzero primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that an infinity will\n/// be generated. You can also specify the mean absolute sci-exponent and precision by passing the\n/// numerators and denominators of their means of the finite floats.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Neither negative not positive zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_nonzero_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_nonzero_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[0.65625, 0.0000014255784, 0.013183594, Infinity, -0.8125, -74240.0, -0.0078125, \\\n///     -0.03060913, 3.331552, 4.75, -0.000038146973, -0.3125, -27136.0, -Infinity, -59392.0, \\\n///     -1.75, -41.1875, Infinity, 0.30940247, -0.0009765625, ...]\"\n/// );\n/// ```\n#[inline]\npub fn special_random_nonzero_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<SpecialRandomNonzeroFiniteFloats<T>> {\n    with_special_values(\n        seed,\n        vec![T::INFINITY, T::NEGATIVE_INFINITY],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            special_random_nonzero_finite_primitive_floats(\n                seed_2,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            )\n        },\n    )\n}\n\n/// Generates primitive floats.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that zero, infinity, or\n/// NaN will be generated. You can also specify the mean absolute sci-exponent and precision by\n/// passing the numerators and denominators of their means of the finite floats.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_primitive_floats;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///             .map(NiceFloat),\n///         20\n///     ),\n///     \"[0.65625, 0.0000014255784, 0.013183594, Infinity, -0.8125, -74240.0, -0.0078125, \\\n///     -0.03060913, 3.331552, 4.75, -0.000038146973, -0.3125, -27136.0, Infinity, -59392.0, \\\n///     -1.75, -41.1875, Infinity, 0.30940247, -0.0009765625, ...]\"\n/// );\n/// ```\n#[inline]\npub fn special_random_primitive_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<SpecialRandomNonzeroFiniteFloats<T>> {\n    with_special_values(\n        seed,\n        vec![T::ZERO, T::NEGATIVE_ZERO, T::INFINITY, T::NEGATIVE_INFINITY, T::NAN],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            special_random_nonzero_finite_primitive_floats(\n                seed_2,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            )\n        },\n    )\n}\n\n// normalized sci_exponent and raw mantissas in input, adjusted sci_exponent and mantissas in output\nfn mantissas_inclusive<T: PrimitiveFloat>(\n    mut sci_exponent: i64,\n    mut am: u64,\n    mut bm: u64,\n    precision: u64,\n) -> Option<(i64, u64, u64)> {\n    assert_ne!(precision, 0);\n    let p: u64 = if sci_exponent < T::MIN_NORMAL_EXPONENT {\n        let ab = am.significant_bits();\n        let bb = bm.significant_bits();\n        assert_eq!(ab, bb);\n        ab - precision\n    } else {\n        am.set_bit(T::MANTISSA_WIDTH);\n        bm.set_bit(T::MANTISSA_WIDTH);\n        T::MANTISSA_WIDTH + 1 - precision\n    };\n    let mut lo = am.shr_round(p, Up).0;\n    if lo.even() {\n        lo += 1;\n    }\n    let mut hi = bm.shr_round(p, Down).0;\n    if hi == 0 {\n        return None;\n    } else if hi.even() {\n        hi -= 1;\n    }\n    if sci_exponent >= T::MIN_NORMAL_EXPONENT {\n        sci_exponent -= i64::wrapping_from(T::MANTISSA_WIDTH);\n    }\n    sci_exponent += i64::wrapping_from(p);\n    if lo > hi {\n        None\n    } else {\n        Some((sci_exponent, lo >> 1, hi >> 1))\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct SpecialRandomPositiveFiniteFloatInclusiveRange<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    am: u64, // raw mantissa\n    bm: u64,\n    ae: i64, // sci_exponent\n    be: i64,\n    sci_exponents: GeometricRandomSignedRange<i64>,\n    precision_range_map: HashMap<i64, Vec<(i64, u64, u64)>>,\n    precision_indices: GeometricRandomNaturalValues<usize>,\n    ranges: VariableRangeGenerator,\n}\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomPositiveFiniteFloatInclusiveRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        let sci_exponent = self.sci_exponents.next().unwrap();\n        let ae = self.ae;\n        let be = self.be;\n        let am = self.am;\n        let bm = self.bm;\n        let precision_ranges = self\n            .precision_range_map\n            .entry(sci_exponent)\n            .or_insert_with(|| {\n                let am = if sci_exponent == ae {\n                    am\n                } else {\n                    T::from_integer_mantissa_and_exponent(1, sci_exponent)\n                        .unwrap()\n                        .raw_mantissa()\n                };\n                let bm = if sci_exponent == be {\n                    bm\n                } else {\n                    T::from_integer_mantissa_and_exponent(1, sci_exponent + 1)\n                        .unwrap()\n                        .next_lower()\n                        .raw_mantissa()\n                };\n                (1..=T::max_precision_for_sci_exponent(sci_exponent))\n                    .filter_map(|p| mantissas_inclusive::<T>(sci_exponent, am, bm, p))\n                    .collect_vec()\n            });\n        assert!(!precision_ranges.is_empty());\n        let i = self.precision_indices.next().unwrap() % precision_ranges.len();\n        let t = precision_ranges[i];\n        let mantissa = (self.ranges.next_in_inclusive_range(t.1, t.2) << 1) | 1;\n        Some(T::from_integer_mantissa_and_exponent(mantissa, t.0).unwrap())\n    }\n}\n\nfn special_random_positive_finite_float_inclusive_range<T: PrimitiveFloat>(\n    seed: Seed,\n    a: T,\n    b: T,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> SpecialRandomPositiveFiniteFloatInclusiveRange<T> {\n    assert!(a.is_finite());\n    assert!(b.is_finite());\n    assert!(a > T::ZERO);\n    assert!(a <= b);\n    let (am, ae) = a.raw_mantissa_and_exponent();\n    let (bm, be) = b.raw_mantissa_and_exponent();\n    let ae = if ae == 0 {\n        i64::wrapping_from(am.significant_bits()) + T::MIN_EXPONENT - 1\n    } else {\n        i64::wrapping_from(ae) - T::MAX_EXPONENT\n    };\n    let be = if be == 0 {\n        i64::wrapping_from(bm.significant_bits()) + T::MIN_EXPONENT - 1\n    } else {\n        i64::wrapping_from(be) - T::MAX_EXPONENT\n    };\n    SpecialRandomPositiveFiniteFloatInclusiveRange {\n        phantom: PhantomData,\n        am,\n        bm,\n        ae,\n        be,\n        sci_exponents: geometric_random_signed_inclusive_range(\n            seed.fork(\"exponents\"),\n            ae,\n            be,\n            mean_sci_exponent_numerator,\n            mean_sci_exponent_denominator,\n        ),\n        precision_range_map: HashMap::new(),\n        precision_indices: geometric_random_unsigneds(\n            seed.fork(\"precisions\"),\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        ranges: VariableRangeGenerator::new(seed.fork(\"ranges\")),\n    }\n}\n\n#[allow(clippy::large_enum_variant)]\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub enum SpecialRandomFiniteFloatInclusiveRange<T: PrimitiveFloat> {\n    AllPositive(SpecialRandomPositiveFiniteFloatInclusiveRange<T>),\n    AllNegative(SpecialRandomPositiveFiniteFloatInclusiveRange<T>),\n    PositiveAndNegative(\n        RandomBools,\n        SpecialRandomPositiveFiniteFloatInclusiveRange<T>,\n        SpecialRandomPositiveFiniteFloatInclusiveRange<T>,\n    ),\n}\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomFiniteFloatInclusiveRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::AllPositive(xs) => xs.next(),\n            Self::AllNegative(xs) => xs.next().map(|x| -x),\n            Self::PositiveAndNegative(bs, xs, ys) => {\n                if bs.next().unwrap() {\n                    xs.next()\n                } else {\n                    ys.next().map(|x| -x)\n                }\n            }\n        }\n    }\n}\n\nfn special_random_finite_float_inclusive_range<T: PrimitiveFloat>(\n    seed: Seed,\n    a: T,\n    b: T,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> SpecialRandomFiniteFloatInclusiveRange<T> {\n    assert!(a.is_finite());\n    assert!(b.is_finite());\n    assert_ne!(a, T::ZERO);\n    assert_ne!(b, T::ZERO);\n    assert!(a <= b);\n    if a > T::ZERO {\n        SpecialRandomFiniteFloatInclusiveRange::AllPositive(\n            special_random_positive_finite_float_inclusive_range(\n                seed,\n                a,\n                b,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            ),\n        )\n    } else if b < T::ZERO {\n        SpecialRandomFiniteFloatInclusiveRange::AllNegative(\n            special_random_positive_finite_float_inclusive_range(\n                seed,\n                -b,\n                -a,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            ),\n        )\n    } else {\n        SpecialRandomFiniteFloatInclusiveRange::PositiveAndNegative(\n            random_bools(seed.fork(\"bs\")),\n            special_random_positive_finite_float_inclusive_range(\n                seed,\n                T::MIN_POSITIVE_SUBNORMAL,\n                b,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            ),\n            special_random_positive_finite_float_inclusive_range(\n                seed,\n                T::MIN_POSITIVE_SUBNORMAL,\n                -a,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            ),\n        )\n    }\n}\n\n/// Generates random primitive floats in a range.\n///\n/// This `enum` is created by [`special_random_primitive_float_range`]; see its documentation for\n/// more.\n#[allow(clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum SpecialRandomFloatInclusiveRange<T: PrimitiveFloat> {\n    OnlySpecial(RandomValuesFromVec<T>),\n    NoSpecial(Box<SpecialRandomFiniteFloatInclusiveRange<T>>),\n    Special(Box<WithSpecialValues<SpecialRandomFiniteFloatInclusiveRange<T>>>),\n}\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomFloatInclusiveRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::OnlySpecial(xs) => xs.next(),\n            Self::NoSpecial(xs) => xs.next(),\n            Self::Special(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates random primitive floats in the half-open interval $[a, b)$.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that any special values\n/// (positive or negative zero or infinity) are generated, provided that they are in the range. You\n/// can also specify the mean absolute sci-exponent and precision by passing the numerators and\n/// denominators of their means of the finite floats.\n///\n/// But note that the means are only approximate, since the distributions we are sampling are\n/// truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual mean is lower than the specified means.\n/// - However, increasing the approximate mean increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater the smallest absolute of any sci-exponent of a\n///   float in the range, and the precision mean greater than 2, but they may be as high as you\n///   like.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater the smallest absolute value of any\n///   sci-exponent of a float in the range, and the precision mean greater than 2, but they may be\n///   as high as you like.\n///\n/// `NaN` is never generated.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a$ or $b$ are `NaN`, if $a$ is greater than or equal to $b$ in the `NiceFloat`\n/// ordering, if any of the denominators are zero, if the special probability is greater than 1, if\n/// the mean precision is less than 2, or if the mean sci-exponent is less than or equal to the\n/// minimum absolute value of any sci-exponent in the range.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_primitive_float_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_primitive_float_range::<f32>(\n///             EXAMPLE_SEED,\n///             core::f32::consts::E,\n///             core::f32::consts::PI,\n///             10,\n///             1,\n///             10,\n///             1,\n///             1,\n///             100\n///         )\n///         .map(NiceFloat),\n///         20\n///     ),\n///     \"[2.9238281, 2.953125, 3.0, 2.8671875, 2.8125, 3.125, 3.015625, 2.8462658, 3.140625, \\\n///     2.875, 3.0, 2.75, 3.0, 2.71875, 2.75, 3.0214844, 2.970642, 3.0179443, 2.968872, 2.75, ...]\"\n/// );\n/// ```\npub fn special_random_primitive_float_range<T: PrimitiveFloat>(\n    seed: Seed,\n    a: T,\n    b: T,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> SpecialRandomFloatInclusiveRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(NiceFloat(a) < NiceFloat(b));\n    special_random_primitive_float_inclusive_range(\n        seed,\n        a,\n        b.next_lower(),\n        mean_sci_exponent_numerator,\n        mean_sci_exponent_denominator,\n        mean_precision_numerator,\n        mean_precision_denominator,\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n    )\n}\n\n/// Generates random primitive floats in the closed interval $[a, b]$.\n///\n/// Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that any special values\n/// (positive or negative zero or infinity) are generated, provided that they are in the range. You\n/// can also specify the mean absolute sci-exponent and precision by passing the numerators and\n/// denominators of their means of the finite floats.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater the smallest absolute value of any\n///   sci-exponent of a float in the range, and the precision mean greater than 2, but they may be\n///   as high as you like.\n///\n/// `NaN` is never generated.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if $a$ or $b$ are `NaN`, if $a$ is greater than $b$ in the `NiceFloat` ordering, if any\n/// of the denominators are zero, if the special probability is greater than 1, if the mean\n/// precision is less than 2, or if the mean sci-exponent is less than or equal to the minimum\n/// absolute value of any sci-exponent in the range.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::num::random::special_random_primitive_float_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         special_random_primitive_float_inclusive_range::<f32>(\n///             EXAMPLE_SEED,\n///             core::f32::consts::E,\n///             core::f32::consts::PI,\n///             10,\n///             1,\n///             10,\n///             1,\n///             1,\n///             100\n///         )\n///         .map(NiceFloat),\n///         20\n///     ),\n///     \"[2.9238281, 2.953125, 3.0, 2.8671875, 2.8125, 3.125, 3.015625, 2.8462658, 3.140625, \\\n///     2.875, 3.0, 2.75, 3.0, 2.71875, 2.75, 3.0214844, 2.970642, 3.0179443, 2.968872, 2.75, ...]\"\n/// );\n/// ```\npub fn special_random_primitive_float_inclusive_range<T: PrimitiveFloat>(\n    seed: Seed,\n    mut a: T,\n    mut b: T,\n    mean_sci_exponent_numerator: u64,\n    mean_sci_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> SpecialRandomFloatInclusiveRange<T> {\n    assert!(!a.is_nan());\n    assert!(!b.is_nan());\n    assert!(NiceFloat(a) <= NiceFloat(b));\n    assert_ne!(mean_special_p_denominator, 0);\n    assert!(mean_special_p_numerator <= mean_special_p_denominator);\n    assert_ne!(mean_precision_denominator, 0);\n    assert!(mean_precision_numerator > mean_precision_denominator);\n    let only_special =\n        a == T::INFINITY || b == T::NEGATIVE_INFINITY || a == T::ZERO && b == T::ZERO;\n    let mut special_values = Vec::new();\n    if a == T::NEGATIVE_INFINITY {\n        special_values.push(a);\n        a = -T::MAX_FINITE;\n    }\n    if b == T::INFINITY {\n        special_values.push(b);\n        b = T::MAX_FINITE;\n    }\n    if NiceFloat(a) <= NiceFloat(T::NEGATIVE_ZERO) && NiceFloat(b) >= NiceFloat(T::NEGATIVE_ZERO) {\n        special_values.push(T::NEGATIVE_ZERO);\n    }\n    if NiceFloat(a) <= NiceFloat(T::ZERO) && NiceFloat(b) >= NiceFloat(T::ZERO) {\n        special_values.push(T::ZERO);\n    }\n    if a == T::ZERO {\n        a = T::MIN_POSITIVE_SUBNORMAL;\n    }\n    if b == T::ZERO {\n        b = -T::MIN_POSITIVE_SUBNORMAL;\n    }\n    if only_special {\n        SpecialRandomFloatInclusiveRange::OnlySpecial(random_values_from_vec(seed, special_values))\n    } else if special_values.is_empty() {\n        SpecialRandomFloatInclusiveRange::NoSpecial(Box::new(\n            special_random_finite_float_inclusive_range(\n                seed,\n                a,\n                b,\n                mean_sci_exponent_numerator,\n                mean_sci_exponent_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n            ),\n        ))\n    } else {\n        SpecialRandomFloatInclusiveRange::Special(Box::new(with_special_values(\n            seed,\n            special_values,\n            mean_special_p_numerator,\n            mean_special_p_denominator,\n            &|seed| {\n                special_random_finite_float_inclusive_range(\n                    seed,\n                    a,\n                    b,\n                    mean_sci_exponent_numerator,\n                    mean_sci_exponent_denominator,\n                    mean_precision_numerator,\n                    mean_precision_denominator,\n                )\n            },\n        )))\n    }\n}\n\n/// Generates unsigneds sampled from ranges. A single generator can sample from different ranges of\n/// different types.\n///\n/// This `struct` is created by [`VariableRangeGenerator::new`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct VariableRangeGenerator {\n    xs: RandomPrimitiveInts<u32>,\n    x: u32,\n    in_inner_loop: bool,\n    remaining_x_bits: u64,\n}\n\nimpl VariableRangeGenerator {\n    /// Generates unsigneds sampled from ranges. A single generator can sample from different ranges\n    /// of different types.\n    ///\n    /// If you only need to generate values from a single range, it is slightly more efficient to\n    /// use [`random_unsigned_bit_chunks`], [`random_unsigneds_less_than`],\n    /// [`random_unsigned_range`], or [`random_unsigned_inclusive_range`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::VariableRangeGenerator;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// let mut generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    /// assert_eq!(generator.next_bit_chunk::<u16>(10), 881);\n    /// assert_eq!(generator.next_less_than::<u8>(100), 34);\n    /// assert_eq!(generator.next_in_range::<u32>(10, 20), 16);\n    /// assert_eq!(generator.next_in_inclusive_range::<u64>(10, 20), 14);\n    /// ```\n    pub fn new(seed: Seed) -> Self {\n        Self {\n            xs: random_primitive_ints(seed),\n            x: 0,\n            in_inner_loop: false,\n            remaining_x_bits: 0,\n        }\n    }\n\n    /// Uniformly generates a `bool`.\n    ///\n    /// $$\n    /// $P(\\text{false}) = P(\\text{true}) = \\frac{1}{2}$.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::VariableRangeGenerator;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// let mut xs = Vec::with_capacity(10);\n    /// let mut generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    /// for _ in 0..10 {\n    ///     xs.push(generator.next_bool());\n    /// }\n    /// assert_eq!(\n    ///     xs,\n    ///     &[true, false, true, false, true, true, true, true, true, false]\n    /// );\n    /// ```\n    pub fn next_bool(&mut self) -> bool {\n        self.xs.next().unwrap().odd()\n    }\n\n    /// Uniformly generates an unsigned integer with up to some number of bits.\n    ///\n    /// $$\n    /// P(x) = \\\\begin{cases}\n    ///     2^{-c} & \\text{if} \\\\quad 0 \\\\leq x < 2^c, \\\\\\\\\n    ///     0 & \\text{if} \\\\quad \\\\text{otherwise,}\n    /// \\\\end{cases}\n    /// $$\n    /// where $c$ is `chunk_size`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `chunk_size` is zero or greater than the width of the type.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::VariableRangeGenerator;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// let mut xs = Vec::with_capacity(10);\n    /// let mut generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    /// for _ in 0..10 {\n    ///     xs.push(generator.next_bit_chunk::<u8>(3));\n    /// }\n    /// assert_eq!(xs, &[1, 6, 5, 7, 6, 3, 1, 2, 4, 5]);\n    /// ```\n    pub fn next_bit_chunk<T: PrimitiveUnsigned>(&mut self, chunk_size: u64) -> T {\n        assert_ne!(chunk_size, 0);\n        assert!(chunk_size <= T::WIDTH);\n        let mut y = T::ZERO;\n        let mut remaining_y_bits = chunk_size;\n        loop {\n            if !self.in_inner_loop {\n                self.x = self.xs.next().unwrap();\n                self.remaining_x_bits = u32::WIDTH;\n                self.in_inner_loop = true;\n            }\n            while self.remaining_x_bits != 0 {\n                let y_index = chunk_size - remaining_y_bits;\n                if self.remaining_x_bits <= remaining_y_bits {\n                    y |= T::wrapping_from(self.x) << y_index;\n                    remaining_y_bits -= self.remaining_x_bits;\n                    self.remaining_x_bits = 0;\n                } else {\n                    y |= T::wrapping_from(self.x).mod_power_of_2(remaining_y_bits) << y_index;\n                    self.x >>= remaining_y_bits;\n                    self.remaining_x_bits -= remaining_y_bits;\n                    remaining_y_bits = 0;\n                }\n                if remaining_y_bits == 0 {\n                    return y;\n                }\n            }\n            self.in_inner_loop = false;\n        }\n    }\n\n    /// Uniformly generates a random unsigned integer less than a positive limit.\n    ///\n    /// $$\n    /// P(x) = \\\\begin{cases}\n    ///     \\frac{1}{\\\\ell} & \\text{if} \\\\quad x < \\\\ell \\\\\\\\\n    ///     0 & \\\\text{otherwise}\n    /// \\\\end{cases}\n    /// $$\n    /// where $\\ell$ is `limit`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `limit` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::VariableRangeGenerator;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// let mut xs = Vec::with_capacity(10);\n    /// let mut generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    /// for _ in 0..10 {\n    ///     xs.push(generator.next_less_than(10u8));\n    /// }\n    /// assert_eq!(xs, &[1, 7, 5, 4, 6, 4, 2, 8, 1, 7]);\n    /// ```\n    pub fn next_less_than<T: PrimitiveUnsigned>(&mut self, limit: T) -> T {\n        assert_ne!(limit, T::ZERO);\n        if limit == T::ONE {\n            T::ZERO\n        } else {\n            let chunk_size = limit.ceiling_log_base_2();\n            loop {\n                let x = self.next_bit_chunk(chunk_size);\n                if x < limit {\n                    return x;\n                }\n            }\n        }\n    }\n\n    /// Uniformly generates a random unsigned integer in the half-open interval $[a, b)$.\n    ///\n    /// $a$ must be less than $b$. This function cannot create a range that includes `T::MAX`; for\n    /// that, use [`next_in_inclusive_range`](Self::next_in_inclusive_range).\n    ///\n    /// $$\n    /// P(x) = \\\\begin{cases}\n    ///     \\frac{1}{b-a} & \\text{if} \\\\quad a \\leq x < b, \\\\\\\\\n    ///     0 & \\\\text{otherwise.}\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if $a \\geq b$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::VariableRangeGenerator;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// let mut xs = Vec::with_capacity(10);\n    /// let mut generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    /// for _ in 0..10 {\n    ///     xs.push(generator.next_in_range(10u8, 20));\n    /// }\n    /// assert_eq!(xs, &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17]);\n    /// ```\n    pub fn next_in_range<T: PrimitiveUnsigned>(&mut self, a: T, b: T) -> T {\n        self.next_less_than(b - a) + a\n    }\n\n    /// Uniformly generates a random unsigned integer in the closed interval $[a, b]$.\n    ///\n    /// $a$ must be less than or equal to $b$.\n    ///\n    /// $$\n    /// P(x) = \\\\begin{cases}\n    ///     \\frac{1}{b-a+1} & \\text{if} \\\\quad a \\leq x \\leq b, \\\\\\\\\n    ///     0 & \\\\text{otherwise.}\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if $a > b$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::VariableRangeGenerator;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// let mut xs = Vec::with_capacity(10);\n    /// let mut generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    /// for _ in 0..10 {\n    ///     xs.push(generator.next_in_inclusive_range(10u8, 19));\n    /// }\n    /// assert_eq!(xs, &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17]);\n    /// ```\n    pub fn next_in_inclusive_range<T: PrimitiveUnsigned>(&mut self, a: T, b: T) -> T {\n        if a == T::ZERO && b == T::MAX {\n            self.next_bit_chunk(T::WIDTH)\n        } else {\n            self.next_less_than(b - a + T::ONE) + a\n        }\n    }\n}\n\n/// Iterators that generate primitive integers from geometric-like distributions.\npub mod geometric;\n\n/// Iterators that generate primitive integers that tend to have long runs of binary 0s and 1s.\n///\n/// Integers with long runs of 0s and 1s are good for testing; they're more likely to result in\n/// carries and borrows than uniformly random integers. This idea was inspired by GMP's\n/// `mpz_rrandomb` function, although striped integer generators are more general: they can also\n/// produce integers with runs that are shorter than average, so that they tend to contain\n/// alternating bits like $1010101$.\n///\n/// Let the average length of a run of 0s and 1s be $m$. The functions in this module allow the user\n/// to specify a rational $m$ through the parameters `m_numerator` and `m_denominator`. Since any\n/// binary sequence has an average run length of at least 1, $m$ must be at least 1; but if it is\n/// exactly 1 then the sequence is strictly alternating and no longer random, so 1 is not allowed\n/// either. if $m$ is between 1 and 2, the sequence is less likely to have two equal adjacent bits\n/// than a uniformly random sequence. If $m$ is 2, the sequence is uniformly random. If $m$ is\n/// greater than 2 (the most useful case), the sequence tends to have long runs of 0s and 1s.\n///\n/// # Details\n///\n/// A random striped sequence with parameter $m \\geq 1$ is an infinite sequence of bits, defined as\n/// follows. The first bit is 0 or 1 with equal probability. Every subsequent bit has a $1/m$\n/// probability of being different than the preceding bit. Notice that every sequence has an equal\n/// probability as its negation. Also, if $m > 1$, any sequence has a nonzero probability of\n/// occurring.\n///\n/// * $m=1$ is disallowed. If it were allowed, the sequence would be either\n///   $01010101010101010101\\ldots$ or $10101010101010101010\\ldots$.\n/// * If $1<m<2$, the sequence tends to alternate between 0 and 1 more often than a uniformly random\n///   sequence. A sample sequence with $m=33/32$ is\n///   $1010101010101010101010110101010101010101\\ldots$.\n/// * If $m=2$, the sequence is uniformly random. A sample sequence with $m=2$ is\n///   $1100110001101010100101101001000001100001\\ldots$.\n/// * If $m>2$, the sequence tends to have longer runs of 0s and 1s than a uniformly random\n///   sequence. A sample sequence with $m=32$ is $1111111111111111110000000011111111111111\\ldots$.\n///\n/// An alternative way to generate a striped sequence is to start with 0 or 1 with equal probability\n/// and then determine the length of each block of equal bits using a geometric distribution with\n/// mean $m$. In practice, this isn't any more efficient than the naive algorithm.\n///\n/// We can generate a random striped unsigned integer of type `T` by taking the first $W$ bits of a\n/// striped sequence. Fixing the parameter $m$ defines a distribution over `T`s. A few things can be\n/// said about the probability $P_m(n)$ of an unsigned integer $n$ of width $W$ being generated:\n/// * $P_m(n) = P_m(\\lnot n)$\n/// * $P_m(0) = P_m(2^W-1) = \\frac{1}{2} \\left ( 1-\\frac{1}{m} \\right )^{W-1}$. If $m>2$, this is\n///   the maximum probability achieved; if $m<2$, the minimum.\n/// * $P_m(\\lfloor 2^W/3 \\rfloor) = P_m(\\lfloor 2^{W+1}/3 \\rfloor) = 1/(2m^{W-1})$. If $m>2$, this\n///   is the minimum probability achieved; if $m<2$, the maximum.\n/// * Because of these distributions' symmetry, their mean is $(2^W-1)/2$ and their skewness is 0.\n///   It's hard to say anything about their standard deviations or excess kurtoses, although these\n///   can be computed quickly for specific values of $m$ when $W$ is 8 or 16.\n///\n/// We can similarly generate random striped signed integers of width $W$. The sign bit is chosen\n/// uniformly, and the remaining $W-1$ are taken from a striped sequence.\n///\n/// To generate striped integers from a range, the integers are constructed one bit at a time. Some\n/// bits are forced; they must be 0 or 1 in order for the final integer to be within the specified\n/// range. If a bit is _not_ forced, it is different from the preceding bit with probability $1/m$.\npub mod striped;\n"
  },
  {
    "path": "malachite-base/src/num/random/striped.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::{RandomBools, WeightedRandomBools, random_bools, weighted_random_bools};\nuse crate::iterators::{NonzeroValues, nonzero_values};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::random::geometric::{\n    GeometricRandomNaturalValues, geometric_random_unsigned_inclusive_range,\n    geometric_random_unsigneds, mean_to_p_with_min,\n};\nuse crate::num::random::{\n    RandomUnsignedInclusiveRange, RandomUnsignedRange, random_unsigned_inclusive_range,\n    random_unsigned_range,\n};\nuse crate::random::Seed;\nuse itertools::Itertools;\nuse std::iter::{Repeat, repeat};\nuse std::marker::PhantomData;\n\n/// Generates bits from a striped random sequence.\n///\n/// See [here](self) for more information.\n#[derive(Clone, Debug)]\npub struct StripedBitSource {\n    first_bit_of_block: bool,\n    previous_bit: bool,\n    bs: RandomBools,\n    xs: WeightedRandomBools,\n}\n\nimpl Iterator for StripedBitSource {\n    type Item = bool;\n\n    /// Gets a bit from this `StripedBitSource`. If this function is being called for the first\n    /// time, the probabilities of a `true` or a `false` are equal. On subsequent calls, the\n    /// probability of getting a bit different from the previous one is $1 / m$.\n    ///\n    /// To reset the bit source, so that the next call to `next` has equal probabilities of `true`\n    /// or `false`, call [`end_block`](Self::end_block).\n    ///\n    /// # Expected complexity\n    /// Constant time and additional memory.\n    #[inline]\n    fn next(&mut self) -> Option<bool> {\n        self.previous_bit = if self.first_bit_of_block {\n            self.first_bit_of_block = false;\n            self.bs.next().unwrap()\n        } else {\n            self.previous_bit ^ self.xs.next().unwrap()\n        };\n        Some(self.previous_bit)\n    }\n}\n\nimpl StripedBitSource {\n    /// Creates a new `StripedBitSource`.\n    ///\n    /// The mean run length is $m$, where $m$ is `m_numerator / m_denominator`.\n    ///\n    /// # Expected complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `m_denominator` is zero or if `m_numerator <= m_denominator`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::striped::StripedBitSource;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// let bit_source = StripedBitSource::new(EXAMPLE_SEED, 4, 1);\n    /// let mut string = String::with_capacity(40);\n    /// for bit in bit_source.take(40) {\n    ///     if bit {\n    ///         string.push('1');\n    ///     } else {\n    ///         string.push('0');\n    ///     }\n    /// }\n    /// assert_eq!(string, \"0000000101100110000000011110000000001111\");\n    /// ```\n    pub fn new(seed: Seed, m_numerator: u64, m_denominator: u64) -> Self {\n        assert_ne!(m_denominator, 0);\n        assert!(m_numerator > m_denominator);\n        let (numerator, denominator) = mean_to_p_with_min(1u64, m_numerator, m_denominator);\n        Self {\n            first_bit_of_block: true,\n            previous_bit: false,\n            bs: random_bools(seed.fork(\"bs\")),\n            xs: weighted_random_bools(seed.fork(\"xs\"), numerator, numerator + denominator),\n        }\n    }\n\n    /// Resets this `StripedBitSource`, so that the next time [`next`](Self::next) is called, the\n    /// probabilities of `true` or `false` will be equal.\n    ///\n    /// # Expected complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::striped::StripedBitSource;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// fn generate_string(bit_source: &mut StripedBitSource) -> String {\n    ///     let mut string = String::with_capacity(40);\n    ///     for bit in bit_source.take(40) {\n    ///         if bit {\n    ///             string.push('1');\n    ///         } else {\n    ///             string.push('0');\n    ///         }\n    ///     }\n    ///     string\n    /// }\n    ///\n    /// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 1000000, 1);\n    /// let mut strings = Vec::with_capacity(5);\n    /// for _ in 0..5 {\n    ///     strings.push(generate_string(&mut bit_source));\n    ///     bit_source.end_block();\n    /// }\n    /// assert_eq!(\n    ///     strings,\n    ///     &[\n    ///         \"0000000000000000000000000000000000000000\",\n    ///         \"0000000000000000000000000000000000000000\",\n    ///         \"0000000000000000000000000000000000000000\",\n    ///         \"1111111111111111111111111111111111111111\",\n    ///         \"0000000000000000000000000000000000000000\"\n    ///     ]\n    /// );\n    /// ```\n    pub const fn end_block(&mut self) {\n        self.first_bit_of_block = true;\n    }\n\n    /// Sets the previous bit of a `StripedBitSource`. This will affect the probability of the next\n    /// bit.\n    ///\n    /// # Expected complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::random::striped::StripedBitSource;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// fn generate_string(bit_source: &mut StripedBitSource) -> String {\n    ///     let mut string = String::with_capacity(40);\n    ///     for bit in bit_source.take(40) {\n    ///         if bit {\n    ///             string.push('1');\n    ///         } else {\n    ///             string.push('0');\n    ///         }\n    ///     }\n    ///     string\n    /// }\n    ///\n    /// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 1000000, 1);\n    /// bit_source.next();\n    /// let mut strings = Vec::with_capacity(3);\n    /// bit_source.set_previous_bit(true);\n    /// strings.push(generate_string(&mut bit_source));\n    /// bit_source.set_previous_bit(false);\n    /// strings.push(generate_string(&mut bit_source));\n    /// bit_source.set_previous_bit(true);\n    /// strings.push(generate_string(&mut bit_source));\n    /// assert_eq!(\n    ///     strings,\n    ///     &[\n    ///         \"1111111111111111111111111111111111111111\",\n    ///         \"0000000000000000000000000000000000000000\",\n    ///         \"1111111111111111111111111111111111111111\",\n    ///     ]\n    /// );\n    /// ```\n    pub const fn set_previous_bit(&mut self, bit: bool) {\n        self.previous_bit = bit;\n    }\n}\n\n/// Generates random unsigned integers from a random striped distribution.\n///\n/// This `struct` is created by [`striped_random_unsigned_bit_chunks`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct StripedRandomUnsignedBitChunks<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n    bits: StripedBitSource,\n    chunk_size: usize,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for StripedRandomUnsignedBitChunks<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.bits.end_block();\n        let mut x = T::ZERO;\n        for bit in (&mut self.bits).take(self.chunk_size) {\n            x <<= 1;\n            if bit {\n                x |= T::ONE;\n            }\n        }\n        Some(x)\n    }\n}\n\n/// Generates random signed integers from a random striped distribution.\n///\n/// This `struct` is created by [`striped_random_signeds`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct StripedRandomSigneds<T: PrimitiveSigned> {\n    phantom: PhantomData<*const T>,\n    bits: StripedBitSource,\n    bs: RandomBools,\n}\n\nimpl<T: PrimitiveSigned> Iterator for StripedRandomSigneds<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.bits.end_block();\n        let mut x = T::ZERO;\n        for bit in (&mut self.bits).take(usize::wrapping_from(T::WIDTH) - 1) {\n            x <<= 1;\n            if bit {\n                x |= T::ONE;\n            }\n        }\n        if self.bs.next().unwrap() {\n            x.set_bit(T::WIDTH - 1);\n        }\n        Some(x)\n    }\n}\n\n/// Generates random natural (non-negative) signed integers from a random striped distribution.\n///\n/// This `struct` is created by [`striped_random_natural_signeds`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct StripedRandomNaturalSigneds<T: PrimitiveSigned> {\n    phantom: PhantomData<*const T>,\n    bits: StripedBitSource,\n}\n\nimpl<T: PrimitiveSigned> Iterator for StripedRandomNaturalSigneds<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.bits.end_block();\n        let mut x = T::ZERO;\n        for bit in (&mut self.bits).take(usize::wrapping_from(T::WIDTH) - 1) {\n            x <<= 1;\n            if bit {\n                x |= T::ONE;\n            }\n        }\n        Some(x)\n    }\n}\n\n/// Generates random negative signed integers from a random striped distribution.\n///\n/// This `struct` is created by [`striped_random_negative_signeds`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct StripedRandomNegativeSigneds<T: PrimitiveSigned> {\n    phantom: PhantomData<*const T>,\n    bits: StripedBitSource,\n}\n\nimpl<T: PrimitiveSigned> Iterator for StripedRandomNegativeSigneds<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.bits.end_block();\n        let mut x = T::ZERO;\n        for bit in (&mut self.bits).take(usize::wrapping_from(T::WIDTH) - 1) {\n            x <<= 1;\n            if bit {\n                x |= T::ONE;\n            }\n        }\n        x.set_bit(T::WIDTH - 1);\n        Some(x)\n    }\n}\n\n/// Generates random unsigned integers from a random striped distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is the width of the type.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero or if m_numerator <= m_denominator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigneds;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigneds::<u8>(EXAMPLE_SEED, 4, 1).map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1, 1001100, 1111111, 11000011, 0, 10000000, 1111, 1110110, 0, 11111000, ...]\"\n/// )\n/// ```\n#[inline]\npub fn striped_random_unsigneds<T: PrimitiveUnsigned>(\n    seed: Seed,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> StripedRandomUnsignedBitChunks<T> {\n    striped_random_unsigned_bit_chunks(seed, T::WIDTH, m_numerator, m_denominator)\n}\n\n/// Generates random positive unsigned integers from a random striped distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is the width of the type.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero or if m_numerator <= m_denominator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_positive_unsigneds;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_positive_unsigneds::<u8>(EXAMPLE_SEED, 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1, 1001100, 1111111, 11000011, 10000000, 1111, 1110110, 11111000, 11111111, 11111101, \\\n///     ...]\"\n/// )\n/// ```\npub fn striped_random_positive_unsigneds<T: PrimitiveUnsigned>(\n    seed: Seed,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> NonzeroValues<StripedRandomUnsignedBitChunks<T>> {\n    nonzero_values(striped_random_unsigneds(seed, m_numerator, m_denominator))\n}\n\n/// Generates random signed integers from a random striped distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is the width of the type.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero or if m_numerator <= m_denominator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_signeds::<i8>(EXAMPLE_SEED, 4, 1).map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1100001, 1000000, 1100000, 10000111, 1111, 10000001, 1111000, 100011, 111101, 11111100, \\\n///     ...]\"\n/// )\n/// ```\npub fn striped_random_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> StripedRandomSigneds<T> {\n    StripedRandomSigneds {\n        phantom: PhantomData,\n        bits: StripedBitSource::new(seed.fork(\"bits\"), m_numerator, m_denominator),\n        bs: random_bools(seed.fork(\"bs\")),\n    }\n}\n\n/// Generates random natural (non-negative) signed integers from a random striped distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is the width of the type.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero or if m_numerator <= m_denominator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_natural_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_natural_signeds::<i8>(EXAMPLE_SEED, 4, 1).map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[0, 101100, 110000, 1111100, 1111, 1111110, 0, 111, 11101, 1100000, ...]\"\n/// )\n/// ```\npub fn striped_random_natural_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> StripedRandomNaturalSigneds<T> {\n    StripedRandomNaturalSigneds {\n        phantom: PhantomData,\n        bits: StripedBitSource::new(seed, m_numerator, m_denominator),\n    }\n}\n\n/// Generates random positive signed integers from a random striped distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is the width of the type.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero or if m_numerator <= m_denominator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_positive_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_positive_signeds::<i8>(EXAMPLE_SEED, 4, 1).map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[101100, 110000, 1111100, 1111, 1111110, 111, 11101, 1100000, 1111111, 1100000, ...]\"\n/// )\n/// ```\npub fn striped_random_positive_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> NonzeroValues<StripedRandomNaturalSigneds<T>> {\n    nonzero_values(striped_random_natural_signeds(\n        seed,\n        m_numerator,\n        m_denominator,\n    ))\n}\n\n/// Generates random negative signed integers from a random striped distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is the width of the type.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero or if m_numerator <= m_denominator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_negative_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_negative_signeds::<i8>(EXAMPLE_SEED, 4, 1).map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[10000000, 10101100, 10110000, 11111100, 10001111, 11111110, 10000000, 10000111, \\\n///     10011101, 11100000, ...]\"\n/// )\n/// ```\npub fn striped_random_negative_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> StripedRandomNegativeSigneds<T> {\n    StripedRandomNegativeSigneds {\n        phantom: PhantomData,\n        bits: StripedBitSource::new(seed, m_numerator, m_denominator),\n    }\n}\n\n/// Generates random nonzero signed integers from a random striped distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is the width of the type.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero or if m_numerator <= m_denominator.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_nonzero_signeds;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_nonzero_signeds::<i8>(EXAMPLE_SEED, 4, 1).map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1100001, 1000000, 1100000, 10000111, 1111, 10000001, 1111000, 100011, 111101, 11111100, \\\n///     ...]\"\n/// )\n/// ```\npub fn striped_random_nonzero_signeds<T: PrimitiveSigned>(\n    seed: Seed,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> NonzeroValues<StripedRandomSigneds<T>> {\n    nonzero_values(striped_random_signeds(seed, m_numerator, m_denominator))\n}\n\n/// Generates random unsigned integers of up to `chunk_size` bits from a random striped\n/// distribution.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `m_numerator /\n/// m_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is `chunk_size`.\n///\n/// # Panics\n/// Panics if `m_denominator` is zero, if m_numerator <= m_denominator, or if `chunk_size` is\n/// greater than the width of the type.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_bit_chunks;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_bit_chunks::<u8>(EXAMPLE_SEED, 3, 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[0, 0, 0, 101, 11, 100, 11, 11, 0, 111, ...]\"\n/// )\n/// ```\npub fn striped_random_unsigned_bit_chunks<T: PrimitiveUnsigned>(\n    seed: Seed,\n    chunk_size: u64,\n    m_numerator: u64,\n    m_denominator: u64,\n) -> StripedRandomUnsignedBitChunks<T> {\n    assert!(chunk_size <= T::WIDTH);\n    StripedRandomUnsignedBitChunks {\n        phantom: PhantomData,\n        bits: StripedBitSource::new(seed, m_numerator, m_denominator),\n        chunk_size: usize::exact_from(chunk_size),\n    }\n}\n\n/// Generates a striped `Vec<bool>`, with a given length, from a [`StripedBitSource`].\n///\n/// See [here](self) for more information.\n///\n/// The output length is `len`.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is `len`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::{get_striped_bool_vec, StripedBitSource};\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 10, 1);\n/// let bits: String = get_striped_bool_vec(&mut bit_source, 50)\n///     .into_iter()\n///     .map(|b| if b { '1' } else { '0' })\n///     .collect();\n/// assert_eq!(bits, \"00011111111111000000011111111111111000000000001111\");\n/// ```\npub fn get_striped_bool_vec(bit_source: &mut StripedBitSource, len: u64) -> Vec<bool> {\n    bit_source.end_block();\n    bit_source.take(usize::exact_from(len)).collect()\n}\n\n/// Generates random striped `Vec<bool>`s.\n#[derive(Clone, Debug)]\npub struct StripedRandomBoolVecs<I: Iterator<Item = u64>> {\n    lengths: I,\n    bit_source: StripedBitSource,\n}\n\nimpl<I: Iterator<Item = u64>> Iterator for StripedRandomBoolVecs<I> {\n    type Item = Vec<bool>;\n\n    fn next(&mut self) -> Option<Vec<bool>> {\n        Some(get_striped_bool_vec(\n            &mut self.bit_source,\n            self.lengths.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates random striped `Vec<bool>`s, with lengths from an iterator.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero or if `mean_stripe_numerator <=\n/// mean_stripe_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_bool_vecs_from_length_iterator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random_values_from_vec;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_bool_vecs_from_length_iterator(\n///             EXAMPLE_SEED,\n///             &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n///             10,\n///             1,\n///         )\n///         .map(|bs| bs\n///             .into_iter()\n///             .map(|b| if b { '1' } else { '0' })\n///             .collect::<String>()),\n///         20\n///     ),\n///     \"[00, 0000, 00, 0000, 0000, 11, , 00, , 1111, 0001, 11, 1100, 00, 0000, 0000, 1110, , \\\n///     0000, , ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_bool_vecs_from_length_iterator<I: Iterator<Item = u64>>(\n    seed: Seed,\n    lengths_gen: &dyn Fn(Seed) -> I,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomBoolVecs<I> {\n    StripedRandomBoolVecs {\n        lengths: lengths_gen(seed.fork(\"lengths\")),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates random striped `Vec<bool>`s of a given length.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// If `len` is 0, the output consists of the empty list, repeated.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `len`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_fixed_length_bool_vecs;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_fixed_length_bool_vecs(EXAMPLE_SEED, 5, 10, 1).map(|bs| bs\n///             .into_iter()\n///             .map(|b| if b { '1' } else { '0' })\n///             .collect::<String>()),\n///         20\n///     ),\n///     \"[00000, 00000, 00000, 00000, 00011, 11000, 00000, 11111, 01111, 11111, 10000, 00011, \\\n///     00000, 00000, 11000, 00000, 11111, 00000, 00000, 11111, ...]\"\n/// );\n/// ```\npub fn striped_random_fixed_length_bool_vecs(\n    seed: Seed,\n    len: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomBoolVecs<Repeat<u64>> {\n    striped_random_bool_vecs_from_length_iterator(\n        seed,\n        &|_| repeat(len),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped `Vec<bool>`s.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_length_numerator /\n/// mean_length_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, if `mean_length_numerator` or `mean_length_denominator` are zero, or,\n/// if after being reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_bool_vecs;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_bool_vecs(EXAMPLE_SEED, 10, 1, 2, 1).map(|bs| bs\n///             .into_iter()\n///             .map(|b| if b { '1' } else { '0' })\n///             .collect::<String>()),\n///         20\n///     ),\n///     \"[000000, 0, 00000000, 0, 00000001110000, , 11111, 0000, 1, , 011111, 11, , , 1, 000, , \\\n///     0, , 0, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_bool_vecs(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> StripedRandomBoolVecs<GeometricRandomNaturalValues<u64>> {\n    striped_random_bool_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigneds(seed_2, mean_length_numerator, mean_length_denominator)\n        },\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped `Vec<bool>`s, with a minimum length.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than\n/// `min_length`.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_length_numerator /\n/// mean_length_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, if `mean_length_numerator` or `mean_length_denominator` are zero, if\n/// their ratio is less than or equal to `min_length`, or if they are too large and manipulating\n/// them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_bool_vecs_min_length;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_bool_vecs_min_length(EXAMPLE_SEED, 3, 10, 1, 5, 1).map(|bs| bs\n///             .into_iter()\n///             .map(|b| if b { '1' } else { '0' })\n///             .collect::<String>()),\n///         20\n///     ),\n///     \"[000000000, 0000, 00000000111, 0111, 00000000011111111, 100, 00000111, 1111111, 0001, \\\n///     111, 111111111, 00000, 000, 000, 1111, 000000, 111, 0011, 000, 1111, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_bool_vecs_min_length(\n    seed: Seed,\n    min_length: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> StripedRandomBoolVecs<GeometricRandomNaturalValues<u64>> {\n    striped_random_bool_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigned_inclusive_range(\n                seed_2,\n                min_length,\n                u64::MAX,\n                mean_length_numerator,\n                mean_length_denominator,\n            )\n        },\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped `Vec<bool>`s, with lengths in $[a, b)$.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b)$. $a$ must be\n/// less than $b$.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// $$\n/// P((x_0, x_1, \\ldots, x_{n-1})) = \\\\begin{cases}\n///     \\frac{1}{b-a}\\prod_{i=0}^{n-1}P(x_i) & \\text{if} \\\\quad a \\leq n < b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(b)$\n///\n/// $M(n) = O(b)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_bool_vecs_length_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_bool_vecs_length_range(EXAMPLE_SEED, 4, 10, 10, 1).map(|bs| bs\n///             .into_iter()\n///             .map(|b| if b { '1' } else { '0' })\n///             .collect::<String>()),\n///         20\n///     ),\n///     \"[000000000, 000000000, 000111000, 000000000, 0111, 11111, 00111111, 1000000, 00000011, \\\n///     111111111, 111111, 00000000, 00000000, 001111, 111111111, 000000000, 110000, 0001111, \\\n///     0000000, 111101111, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_bool_vecs_length_range(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomBoolVecs<RandomUnsignedRange<u64>> {\n    striped_random_bool_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_range(seed_2, a, b),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped `Vec<bool>`s, with lengths in $[a, b]$.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b]$. $a$ must be\n/// less than $b$.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// $$\n/// P((x_0, x_1, \\ldots, x_{n-1})) = \\\\begin{cases}\n///     \\frac{1}{b-a+1}\\prod_{i=0}^{n-1}P(x_i) & \\text{if} \\\\quad a \\leq n \\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(b)$\n///\n/// $M(n) = O(b)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_bool_vecs_length_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_bool_vecs_length_inclusive_range(EXAMPLE_SEED, 4, 9, 10, 1).map(|bs| bs\n///             .into_iter()\n///             .map(|b| if b { '1' } else { '0' })\n///             .collect::<String>()),\n///         20\n///     ),\n///     \"[000000000, 000000000, 000111000, 000000000, 0111, 11111, 00111111, 1000000, 00000011, \\\n///     111111111, 111111, 00000000, 00000000, 001111, 111111111, 000000000, 110000, 0001111, \\\n///     0000000, 111101111, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_bool_vecs_length_inclusive_range(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomBoolVecs<RandomUnsignedInclusiveRange<u64>> {\n    striped_random_bool_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_inclusive_range(seed_2, a, b),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates a striped unsigned [`Vec`], with a given number of bits (not length!), from a\n/// [`StripedBitSource`].\n///\n/// See [here](self) for more information.\n///\n/// The output length is `bit_len.div_round(T::WIDTH, Ceiling)`.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `bit_len`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::striped::{get_striped_unsigned_vec, StripedBitSource};\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 10, 1);\n/// let xs = get_striped_unsigned_vec::<u8>(&mut bit_source, 100)\n///     .iter()\n///     .map(u8::to_binary_string)\n///     .collect_vec();\n/// assert_eq!(\n///     xs,\n///     &[\n///         \"11111000\", \"111111\", \"11100000\", \"11111111\", \"111\", \"11000000\", \"11111111\", \"0\", \"0\",\n///         \"11111000\", \"11111111\", \"11111111\", \"11\",\n///     ]\n/// );\n/// ```\npub fn get_striped_unsigned_vec<T: PrimitiveUnsigned>(\n    bit_source: &mut StripedBitSource,\n    bit_len: u64,\n) -> Vec<T> {\n    bit_source.end_block();\n    bit_source\n        .take(usize::exact_from(bit_len))\n        .chunks(usize::wrapping_from(T::WIDTH))\n        .into_iter()\n        .map(T::from_bits_asc)\n        .collect()\n}\n\n/// Generates random striped [`Vec`]s of unsigneds.\n#[derive(Clone, Debug)]\npub struct StripedRandomUnsignedVecs<T: PrimitiveUnsigned, I: Iterator<Item = u64>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = u64>> Iterator for StripedRandomUnsignedVecs<T, I> {\n    type Item = Vec<T>;\n\n    fn next(&mut self) -> Option<Vec<T>> {\n        Some(get_striped_unsigned_vec(\n            &mut self.bit_source,\n            self.lengths.next().unwrap() << T::LOG_WIDTH,\n        ))\n    }\n}\n\n/// Generates random striped [`Vec`]s of unsigneds, with lengths from an iterator.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero or if `mean_stripe_numerator <=\n/// mean_stripe_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_vecs_from_length_iterator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n/// use malachite_base::vecs::random_values_from_vec;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_vecs_from_length_iterator::<u8, _>(\n///             EXAMPLE_SEED,\n///             &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n///             10,\n///             1,\n///         )\n///         .map(|xs| prefix_to_string(xs.into_iter().map(|x: u8| x.to_binary_string()), 100)),\n///         10,\n///     ),\n///     \"[[0, 0], [1110000, 0, 11111100, 11], [11111110, 1111], [0, 0, 0, 11111000], \\\n///     [0, 0, 1111110, 0], [11011111, 11111111], [], [11110000, 11111111], [], \\\n///     [11111111, 11000011, 11111, 0], ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_unsigned_vecs_from_length_iterator<\n    T: PrimitiveUnsigned,\n    I: Iterator<Item = u64>,\n>(\n    seed: Seed,\n    lengths_gen: &dyn Fn(Seed) -> I,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomUnsignedVecs<T, I> {\n    StripedRandomUnsignedVecs {\n        phantom: PhantomData,\n        lengths: lengths_gen(seed.fork(\"lengths\")),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates random striped unsigned [`Vec`]s of a given length.\n///\n/// See [here](self) for more information.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// If `len` is 0, the output consists of the empty list, repeated.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `len`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_fixed_length_unsigned_vecs;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_fixed_length_unsigned_vecs::<u8>(EXAMPLE_SEED, 3, 10, 1).map(|xs| {\n///             prefix_to_string(xs.into_iter().map(|x: u8| x.to_binary_string()), 100)\n///         }),\n///         10,\n///     ),\n///     \"[[0, 0, 111000], [0, 11111100, 11], [11111110, 1111, 0], [0, 0, 11111000], \\\n///     [0, 0, 1111110], [11111111, 11011111, 11111111], [11110000, 11111111, 11111111], \\\n///     [11000011, 11111, 0], [0, 10000000, 11111001], [11111111, 0, 0], ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_fixed_length_unsigned_vecs<T: PrimitiveUnsigned>(\n    seed: Seed,\n    len: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomUnsignedVecs<T, Repeat<u64>> {\n    striped_random_unsigned_vecs_from_length_iterator(\n        seed,\n        &|_| repeat(len),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped [`Vec`]s of unsigneds.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// $$\n/// P((x_0, x_1, \\ldots, x_{n-1})) = \\frac{m^n}{(m+1)^{n+1}}\\prod_{i=0}^{n-1}P(x_i).\n/// $$\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_length_numerator /\n/// mean_length_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, if `mean_length_numerator` or `mean_length_denominator` are zero, or,\n/// if after being reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_vecs;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_vecs::<u8>(EXAMPLE_SEED, 10, 1, 2, 1)\n///             .map(|xs| prefix_to_string(xs.into_iter().map(|x: u8| x.to_binary_string()), 100)),\n///         10,\n///     ),\n///     \"[[0, 0, 111000, 0, 11111110, 10000001], [0], \\\n///     [11110000, 11111111, 11111111, 11111111, 11, 0, 10000000, 11111], [0], \\\n///     [10000, 0, 11111100, 11111111, 1111111, 11111000, 11, 0, 0, 10011000, 11111111, 111, 0, \\\n///     0], [], [11111111, 11111111, 11111111, 11111111, 10111111], [0, 0, 0, 11110000], \\\n///     [11111111], [], ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_unsigned_vecs<T: PrimitiveUnsigned>(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> StripedRandomUnsignedVecs<T, GeometricRandomNaturalValues<u64>> {\n    striped_random_unsigned_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigneds(seed_2, mean_length_numerator, mean_length_denominator)\n        },\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped [`Vec`]s of unsigneds, with a minimum length.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than\n/// `min_length`.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// $$\n/// P((x_0, x_1, \\ldots, x_{n-1})) = \\\\begin{cases}\n///     \\frac{(m-a)^{n-a}}{(m+1-a)^{n+1-a}}\\prod_{i=0}^{n-1}P(x_i) & n \\geq a \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $a$ is `min_length`.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_length_numerator /\n/// mean_length_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, if `mean_length_numerator` or `mean_length_denominator` are zero, if\n/// their ratio is less than or equal to `min_length`, or if they are too large and manipulating\n/// them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_vecs_min_length;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_vecs_min_length::<u8>(EXAMPLE_SEED, 2, 10, 1, 3, 1)\n///             .map(|xs| prefix_to_string(xs.into_iter().map(|x: u8| x.to_binary_string()), 100)),\n///         10,\n///     ),\n///     \"[[0, 0, 111000], [0, 11111100, 11, 11111111], \\\n///     [11110000, 11111111, 11111111, 11111111], [11111000, 11111111, 11111111, 11000000], \\\n///     [0, 10000, 0], [111, 0, 0, 1111], [11110000, 11111111], [11111111, 111111], \\\n///     [110, 10000000, 11111111], [11111111, 11111111], ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_unsigned_vecs_min_length<T: PrimitiveUnsigned>(\n    seed: Seed,\n    min_length: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> StripedRandomUnsignedVecs<T, GeometricRandomNaturalValues<u64>> {\n    striped_random_unsigned_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigned_inclusive_range(\n                seed_2,\n                min_length,\n                u64::MAX,\n                mean_length_numerator,\n                mean_length_denominator,\n            )\n        },\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped [`Vec`]s of unsigneds, with lengths in $[a, b)$.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b)$. $a$ must be\n/// less than $b$.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// $$\n/// P((x_0, x_1, \\ldots, x_{n-1})) = \\\\begin{cases}\n///     \\frac{1}{b-a}\\prod_{i=0}^{n-1}P(x_i) & \\text{if} \\\\quad a \\leq n < b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(b)$\n///\n/// $M(n) = O(b)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_vecs_length_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_vecs_length_range::<u8>(EXAMPLE_SEED, 2, 4, 10, 1)\n///             .map(|xs| prefix_to_string(xs.into_iter().map(|x: u8| x.to_binary_string()), 100)),\n///         10,\n///     ),\n///     \"[[0, 0, 111000], [0, 11111100], [11111000, 1, 11110000], [0, 0, 0], \\\n///     [11110000, 11111111], [11111111, 11, 11111111], [1000000, 0, 11110000], \\\n///     [11111111, 11111111], [1111000, 11000000, 11111111], [11111111, 11111111, 1100], ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_unsigned_vecs_length_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomUnsignedVecs<T, RandomUnsignedRange<u64>> {\n    striped_random_unsigned_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_range(seed_2, a, b),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped [`Vec`]s of unsigneds, with lengths in $[a, b]$.\n///\n/// See [here](self) for more information.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b]$. $a$ must be\n/// less than $b$.\n///\n/// The mean run length (before the bit sequences are truncated) is $m$ = `mean_stripe_numerator /\n/// mean_stripe_denominator`.\n///\n/// $$\n/// P((x_0, x_1, \\ldots, x_{n-1})) = \\\\begin{cases}\n///     \\frac{1}{b-a+1}\\prod_{i=0}^{n-1}P(x_i) & \\text{if} \\\\quad a \\leq n \\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(b)$\n///\n/// $M(n) = O(b)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_vecs_length_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_vecs_length_inclusive_range::<u8>(EXAMPLE_SEED, 2, 3, 10, 1)\n///             .map(|xs| prefix_to_string(xs.into_iter().map(|x: u8| x.to_binary_string()), 100)),\n///         10,\n///     ),\n///     \"[[0, 0, 111000], [0, 11111100], [11111000, 1, 11110000], [0, 0, 0], \\\n///     [11110000, 11111111], [11111111, 11, 11111111], [1000000, 0, 11110000], \\\n///     [11111111, 11111111], [1111000, 11000000, 11111111], [11111111, 11111111, 1100], ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_unsigned_vecs_length_inclusive_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomUnsignedVecs<T, RandomUnsignedInclusiveRange<u64>> {\n    striped_random_unsigned_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_inclusive_range(seed_2, a, b),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n#[inline]\nfn ranges_intersect<T: Copy + Ord>(lo_0: T, hi_0: T, lo: T, hi: T) -> bool {\n    lo <= hi_0 && lo_0 <= hi\n}\n\n/// Generates random striped unsigneds from a range.\n#[derive(Clone, Debug)]\npub struct StripedRandomUnsignedInclusiveRange<T: PrimitiveUnsigned> {\n    a: T,\n    b: T,\n    lo_template: T,\n    hi_template: T,\n    next_bit: u64,\n    bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for StripedRandomUnsignedInclusiveRange<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.next_bit == 0 {\n            return Some(self.lo_template);\n        }\n        let mut lo_template = self.lo_template;\n        let mut hi_template = self.hi_template;\n        let mut first = true;\n        let mut previous_forced = true;\n        let mut previous_bit = lo_template.get_bit(self.next_bit);\n        for next_bit in (0..self.next_bit).rev() {\n            let false_possible;\n            let true_possible;\n            if first {\n                false_possible = true;\n                true_possible = true;\n                lo_template.assign_bit(next_bit, true);\n                hi_template.assign_bit(next_bit, true);\n                first = false;\n            } else {\n                lo_template.assign_bit(next_bit, false);\n                hi_template.assign_bit(next_bit, false);\n                false_possible = ranges_intersect(lo_template, hi_template, self.a, self.b);\n                lo_template.assign_bit(next_bit, true);\n                hi_template.assign_bit(next_bit, true);\n                true_possible = ranges_intersect(lo_template, hi_template, self.a, self.b);\n            }\n            assert!(false_possible || true_possible);\n            let bit = if !false_possible {\n                previous_forced = true;\n                true\n            } else if !true_possible {\n                previous_forced = true;\n                false\n            } else {\n                if previous_forced {\n                    self.bit_source.end_block();\n                    self.bit_source.set_previous_bit(previous_bit);\n                    previous_forced = false;\n                }\n                self.bit_source.next().unwrap()\n            };\n            if !bit {\n                lo_template.assign_bit(next_bit, false);\n                hi_template.assign_bit(next_bit, false);\n            }\n            previous_bit = bit;\n        }\n        Some(lo_template)\n    }\n}\n\n/// Generates random striped unsigneds in the range $[a, b)$.\n///\n/// See [here](self) for more information.\n///\n/// The unsigneds are generated using a striped bit sequence with mean run length $m$ =\n/// `mean_stripe_numerator / mean_stripe_denominator`.\n///\n/// Because the unsigneds are constrained to be within a certain range, the actual mean run length\n/// will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean run\n/// length.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_range::<u8>(EXAMPLE_SEED, 1, 7, 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1, 1, 1, 110, 1, 110, 10, 11, 11, 100, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_unsigned_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomUnsignedInclusiveRange<T> {\n    assert!(a < b);\n    striped_random_unsigned_inclusive_range(\n        seed,\n        a,\n        b - T::ONE,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped unsigneds in the range $[a, b]$.\n///\n/// See [here](self) for more information.\n///\n/// The unsigneds are generated using a striped bit sequence with mean run length $m$ =\n/// `mean_stripe_numerator / mean_stripe_denominator`.\n///\n/// Because the unsigneds are constrained to be within a certain range, the actual mean run length\n/// will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean run\n/// length.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_unsigned_inclusive_range::<u8>(EXAMPLE_SEED, 1, 6, 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1, 1, 1, 110, 1, 110, 10, 11, 11, 100, ...]\"\n/// );\n/// ```\npub fn striped_random_unsigned_inclusive_range<T: PrimitiveUnsigned>(\n    seed: Seed,\n    a: T,\n    b: T,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomUnsignedInclusiveRange<T> {\n    assert!(a <= b);\n    let diff_bits = T::WIDTH - (a ^ b).leading_zeros();\n    let mask = T::low_mask(diff_bits);\n    let lo_template = a & !mask;\n    let hi_template = lo_template | mask;\n    StripedRandomUnsignedInclusiveRange {\n        a,\n        b,\n        lo_template,\n        hi_template,\n        next_bit: diff_bits,\n        bit_source: StripedBitSource::new(seed, mean_stripe_numerator, mean_stripe_denominator),\n    }\n}\n\n/// Generates random striped signeds from a range.\n#[allow(clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum StripedRandomSignedInclusiveRange<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + WrappingFrom<U>,\n> {\n    NonNegative(PhantomData<S>, StripedRandomUnsignedInclusiveRange<U>),\n    Negative(PhantomData<S>, StripedRandomUnsignedInclusiveRange<U>),\n    Both(\n        PhantomData<S>,\n        Box<RandomBools>,\n        StripedRandomUnsignedInclusiveRange<U>,\n        StripedRandomUnsignedInclusiveRange<U>,\n    ),\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned + WrappingFrom<U>> Iterator\n    for StripedRandomSignedInclusiveRange<U, S>\n{\n    type Item = S;\n\n    fn next(&mut self) -> Option<S> {\n        match self {\n            Self::NonNegative(_, xs) => xs.next().map(S::wrapping_from),\n            Self::Negative(_, xs) => xs.next().map(|x| S::wrapping_from(x).wrapping_neg()),\n            Self::Both(_, bs, xs_nn, xs_n) => {\n                if bs.next().unwrap() {\n                    xs_nn.next().map(S::wrapping_from)\n                } else {\n                    xs_n.next().map(|x| S::wrapping_from(x).wrapping_neg())\n                }\n            }\n        }\n    }\n}\n\n/// Generates random striped signeds in the range $[a, b]$.\n///\n/// See [here](self) for more information.\n///\n/// The unsigneds are generated using a striped bit sequence with mean run length $m$ =\n/// `mean_stripe_numerator / mean_stripe_denominator`.\n///\n/// Because the signeds are constrained to be within a certain range, the actual mean run length\n/// will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean run\n/// length.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_signed_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_signed_inclusive_range::<u8, i8>(EXAMPLE_SEED, -5, 10, 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[11111011, 11111100, 1000, 111, 11111111, 1000, 11, 1000, 0, 1000, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_signed_range<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    seed: Seed,\n    a: S,\n    b: S,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomSignedInclusiveRange<U, S> {\n    assert!(a < b);\n    striped_random_signed_inclusive_range(\n        seed,\n        a,\n        b - S::ONE,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped signeds in the range $[a, b)$.\n///\n/// See [here](self) for more information.\n///\n/// The unsigneds are generated using a striped bit sequence with mean run length $m$ =\n/// `mean_stripe_numerator / mean_stripe_denominator`.\n///\n/// Because the signeds are constrained to be within a certain range, the actual mean run length\n/// will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean run\n/// length.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::striped::striped_random_signed_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_signed_range::<u8, i8>(EXAMPLE_SEED, -5, 11, 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[11111011, 11111100, 1000, 111, 11111111, 1000, 11, 1000, 0, 1000, ...]\"\n/// );\n/// ```\npub fn striped_random_signed_inclusive_range<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    seed: Seed,\n    a: S,\n    b: S,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomSignedInclusiveRange<U, S> {\n    assert!(a <= b);\n    if a >= S::ZERO {\n        StripedRandomSignedInclusiveRange::NonNegative(\n            PhantomData,\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::wrapping_from(a),\n                U::wrapping_from(b),\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n            ),\n        )\n    } else if b < S::ZERO {\n        StripedRandomSignedInclusiveRange::Negative(\n            PhantomData,\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::wrapping_from(b.wrapping_neg()),\n                U::wrapping_from(a.wrapping_neg()),\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n            ),\n        )\n    } else {\n        StripedRandomSignedInclusiveRange::Both(\n            PhantomData,\n            Box::new(random_bools(seed.fork(\"sign\"))),\n            striped_random_unsigned_inclusive_range(\n                seed.fork(\"non-negative\"),\n                U::ZERO,\n                U::wrapping_from(b),\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n            ),\n            striped_random_unsigned_inclusive_range(\n                seed.fork(\"negative\"),\n                U::ONE,\n                U::wrapping_from(a.wrapping_neg()),\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n            ),\n        )\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/options/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::iter::{Chain, Once, once};\n\n/// Generates all [`Option`]s except `None`, with values from a given iterator.\n///\n/// This `struct` is created by [`exhaustive_somes`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveSomes<I: Iterator> {\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for ExhaustiveSomes<I> {\n    type Item = Option<I::Item>;\n\n    fn next(&mut self) -> Option<Option<I::Item>> {\n        self.xs.next().map(Some)\n    }\n}\n\n/// Generates all [`Option`]s except `None`, with values from a given iterator.\n///\n/// The elements of the given iterator are wrapped in `Some` and generated in the original order.\n///\n/// The output length is `xs.count()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::options::exhaustive::exhaustive_somes;\n///\n/// assert_eq!(\n///     exhaustive_somes([1, 2, 3].iter().cloned()).collect_vec(),\n///     &[Some(1), Some(2), Some(3)]\n/// );\n/// ```\n#[inline]\npub const fn exhaustive_somes<I: Iterator>(xs: I) -> ExhaustiveSomes<I> {\n    ExhaustiveSomes { xs }\n}\n\n/// Generates all [`Option`]s with values from a given iterator.\n///\n/// `None` comes first, followed by the elements of the given iterator wrapped in `Some`.\n///\n/// The output length is `xs.count()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::options::exhaustive::exhaustive_options;\n///\n/// assert_eq!(\n///     exhaustive_options([1, 2, 3].iter().cloned()).collect_vec(),\n///     &[None, Some(1), Some(2), Some(3)]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_options<I: Iterator>(xs: I) -> Chain<Once<Option<I::Item>>, ExhaustiveSomes<I>> {\n    once(None).chain(exhaustive_somes(xs))\n}\n"
  },
  {
    "path": "malachite-base/src/options/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::str::FromStr;\n\n/// Converts a string to an `Option<T>`, where `T` implements [`FromStr`].\n///\n/// If the string does not represent a valid `Option<T>`, `None` is returned.\n///\n/// If `T` does not implement [`FromStr`], try using [`option_from_str_custom`] instead.\n///\n/// # Examples\n/// ```\n/// use malachite_base::options::option_from_str;\n///\n/// assert_eq!(option_from_str::<bool>(\"Some(false)\"), Some(Some(false)));\n/// assert_eq!(option_from_str::<u32>(\"Some(5)\"), Some(Some(5)));\n/// assert_eq!(option_from_str::<u32>(\"None\"), Some(None));\n/// assert_eq!(option_from_str::<u32>(\"Some(hi)\"), None);\n/// assert_eq!(option_from_str::<bool>(\"abc\"), None);\n/// ```\n#[inline]\npub fn option_from_str<T: FromStr>(src: &str) -> Option<Option<T>> {\n    option_from_str_custom(&(|t| t.parse().ok()), src)\n}\n\n/// Converts a string to an `Option<T>`, given a function to parse a string into a `T`.\n///\n/// If the string does not represent a valid `Option<T>`, `None` is returned.\n///\n/// If `f` just uses the [`FromStr`] implementation on `T`, you can use [`option_from_str`] instead.\n///\n/// # Examples\n/// ```\n/// use malachite_base::options::{option_from_str, option_from_str_custom};\n/// use malachite_base::orderings::ordering_from_str;\n/// use std::cmp::Ordering::{self, *};\n///\n/// assert_eq!(\n///     option_from_str_custom::<Ordering>(&ordering_from_str, \"Some(Less)\"),\n///     Some(Some(Less))\n/// );\n/// assert_eq!(\n///     option_from_str_custom::<Option<bool>>(&option_from_str, \"Some(Some(false))\"),\n///     Some(Some(Some(false)))\n/// );\n/// assert_eq!(\n///     option_from_str_custom::<Ordering>(&ordering_from_str, \"Some(hi)\"),\n///     None\n/// );\n/// assert_eq!(\n///     option_from_str_custom::<Ordering>(&ordering_from_str, \"abc\"),\n///     None\n/// );\n/// ```\npub fn option_from_str_custom<T>(f: &dyn Fn(&str) -> Option<T>, src: &str) -> Option<Option<T>> {\n    if src == \"None\" {\n        Some(None)\n    } else if src.starts_with(\"Some(\") && src.ends_with(')') {\n        f(&src[5..src.len() - 1]).map(Some)\n    } else {\n        None\n    }\n}\n\n/// Iterators that generate [`Option`]s without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`Option`]s randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/options/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::{WeightedRandomBools, weighted_random_bools};\nuse crate::random::Seed;\n\n/// Generates random [`Option`]s except `None`, with values from a given random iterator.\n///\n/// This `struct` is created by [`random_somes`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomSomes<I: Iterator> {\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomSomes<I> {\n    type Item = Option<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Option<I::Item>> {\n        Some(self.xs.next())\n    }\n}\n\n/// Generates random [`Option`]s except `None`, with values from a given random iterator.\n///\n/// The values have the same distribution as the values generated by the given iterator: If $Q(x)$\n/// is the probability of $x$ being generated by `xs`, then\n///\n/// $P(\\operatorname{Some}(x)) = Q(x)$.\n///\n/// `xs` must be infinite.\n///\n/// The output length is infinite.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::options::random::random_somes;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToDebugString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_somes(random_primitive_ints::<u8>(EXAMPLE_SEED)).map(|x| x.to_debug_string()),\n///         5\n///     ),\n///     \"[Some(113), Some(239), Some(69), Some(108), Some(228), ...]\",\n/// )\n/// ```\npub const fn random_somes<I: Iterator>(xs: I) -> RandomSomes<I> {\n    RandomSomes { xs }\n}\n\n/// Generates random [`Option`]s with values from a given random iterator.\n///\n/// We don't use [`WithSpecialValue`](crate::iterators::WithSpecialValue) here because that requires\n/// `I::Item` to be cloneable. The \"special value\" in this case, `None`, can be produced on demand\n/// without any cloning.\n///\n/// This `struct` is created by [`random_options`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomOptions<I: Iterator> {\n    bs: WeightedRandomBools,\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomOptions<I> {\n    type Item = Option<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Option<I::Item>> {\n        Some(if self.bs.next().unwrap() {\n            self.xs.next()\n        } else {\n            None\n        })\n    }\n}\n\n/// Generates random [`Option`]s with values from a given random iterator.\n///\n/// The probability of generating `None` is specified by $p$ = `none_p_numerator /\n/// none_p_denominator`. If a `Some` is generated, its values have the same distribution as the\n/// values generated by the given iterator.\n///\n/// If $Q(x)$ is the probability of $x$ being generated by `xs`, then\n///\n/// $P(\\text{None}) = p$\n///\n/// $P(\\operatorname{Some}(x)) = (1-p)Q(x)$\n///\n/// `xs` must be infinite.\n///\n/// The output length is infinite.\n///\n/// # Panics\n/// Panics if `none_p_denominator` is 0 or `none_p_numerator > none_p_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::options::random::random_options;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToDebugString;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_options(EXAMPLE_SEED, 1, 2, &random_primitive_ints::<u8>)\n///             .map(|x| x.to_debug_string()),\n///         10\n///     ),\n///     \"[Some(85), Some(11), Some(136), None, Some(200), None, Some(235), Some(134), Some(203), \\\n///     None, ...]\"\n/// )\n/// ```\npub fn random_options<I: Iterator>(\n    seed: Seed,\n    none_p_numerator: u64,\n    none_p_denominator: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomOptions<I> {\n    RandomOptions {\n        bs: weighted_random_bools(\n            seed.fork(\"bs\"),\n            none_p_denominator - none_p_numerator,\n            none_p_denominator,\n        ),\n        xs: xs_gen(seed.fork(\"xs\")),\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/orderings/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::orderings::ORDERINGS;\nuse core::cmp::Ordering::{self, *};\nuse core::iter::Copied;\nuse core::slice::Iter;\n\npub type ExhaustiveOrderings = Copied<Iter<'static, Ordering>>;\n\n/// Generates all [`Ordering`]s, in increasing order.\n///\n/// The output length is 3.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::orderings::exhaustive::orderings_increasing;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(\n///     orderings_increasing().collect_vec(),\n///     &[Less, Equal, Greater]\n/// );\n/// ```\n#[inline]\npub fn orderings_increasing() -> ExhaustiveOrderings {\n    [Less, Equal, Greater].iter().copied()\n}\n\n/// Generates all [`Ordering`]s, with `Equal` coming first.\n///\n/// The output length is 3.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::orderings::exhaustive::exhaustive_orderings;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(\n///     exhaustive_orderings().collect_vec(),\n///     &[Equal, Less, Greater]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_orderings() -> Copied<Iter<'static, Ordering>> {\n    ORDERINGS.iter().copied()\n}\n"
  },
  {
    "path": "malachite-base/src/orderings/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\n\npub(crate) const ORDERINGS: [Ordering; 3] = [Equal, Less, Greater];\n\n/// Converts a string to an [`Ordering`].\n///\n/// If the string does not represent a valid [`Ordering`], `None` is returned.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::orderings::ordering_from_str;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(ordering_from_str(\"Equal\"), Some(Equal));\n/// assert_eq!(ordering_from_str(\"Less\"), Some(Less));\n/// assert_eq!(ordering_from_str(\"Greater\"), Some(Greater));\n/// assert_eq!(ordering_from_str(\"abc\"), None);\n/// ```\n#[inline]\npub fn ordering_from_str(src: &str) -> Option<Ordering> {\n    match src {\n        \"Equal\" => Some(Equal),\n        \"Less\" => Some(Less),\n        \"Greater\" => Some(Greater),\n        _ => None,\n    }\n}\n\n/// Iterators that generate [`Ordering`]s without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`Ordering`]s randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/orderings/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::orderings::ORDERINGS;\nuse crate::random::Seed;\nuse crate::slices::{RandomValuesFromSlice, random_values_from_slice};\nuse std::cmp::Ordering;\nuse std::iter::Copied;\n\npub type RandomOrderings = Copied<RandomValuesFromSlice<'static, Ordering>>;\n\n/// Generates a random [`Ordering`] that has an equal probability of being `Less`, `Greater`, or\n/// `Equal`.\n///\n/// $P(<) = P(=) = P(>) = \\frac{1}{3}$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::orderings::random::random_orderings;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(\n///     random_orderings(EXAMPLE_SEED).take(10).collect_vec(),\n///     &[Less, Equal, Less, Greater, Less, Less, Equal, Less, Equal, Greater]\n/// )\n/// ```\n#[inline]\npub fn random_orderings(seed: Seed) -> RandomOrderings {\n    random_values_from_slice(seed, &ORDERINGS).copied()\n}\n"
  },
  {
    "path": "malachite-base/src/platform.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(not(feature = \"std\"))]\n#[macro_export]\nmacro_rules! fma {\n    ($a: expr, $b: expr, $c: expr) => {{ libm::fma($a, $b, $c) }};\n}\n\n#[cfg(feature = \"std\")]\n#[macro_export]\nmacro_rules! fma {\n    ($a: expr, $b: expr, $c: expr) => {{ $a.mul_add($b, $c) }};\n}\n\npub use fma;\n\n#[cfg(not(feature = \"std\"))]\n#[macro_export]\nmacro_rules! round_even {\n    ($a: expr) => {{ libm::roundeven($a) }};\n}\n\n#[cfg(feature = \"std\")]\n#[macro_export]\nmacro_rules! round_even {\n    ($a: expr) => {{ $a.round_ties_even() }};\n}\n\npub use round_even;\n"
  },
  {
    "path": "malachite-base/src/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse rand::{RngCore, SeedableRng};\nuse rand_chacha::ChaCha20Rng;\nuse sha3::{Digest, Sha3_256};\n\n/// A random seed used for reproducible testing.\npub const EXAMPLE_SEED: Seed = Seed::from_bytes([\n    0xbf, 0x18, 0x11, 0xce, 0x15, 0xee, 0xfd, 0x20, 0x2f, 0xdf, 0x67, 0x6a, 0x6b, 0xba, 0xaf, 0x04,\n    0xff, 0x71, 0xe0, 0xf8, 0x0b, 0x2a, 0xcf, 0x27, 0x85, 0xb3, 0x32, 0xc6, 0x20, 0x80, 0x5e, 0x36,\n]);\n\n/// A type representing a random seed.\n#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]\npub struct Seed {\n    pub bytes: [u8; 32],\n}\n\nimpl Seed {\n    /// Creates a `Seed` from a slice of 32 bytes.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::random::Seed;\n    ///\n    /// Seed::from_bytes([10; 32]);\n    /// ```\n    #[inline]\n    pub const fn from_bytes(bytes: [u8; 32]) -> Self {\n        Self { bytes }\n    }\n\n    /// Creates a PRNG from a slice of 32 bytes.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// EXAMPLE_SEED.get_rng();\n    /// ```\n    #[inline]\n    pub fn get_rng(self) -> ChaCha20Rng {\n        ChaCha20Rng::from_seed(self.bytes)\n    }\n\n    /// Uniformly generates a random `Seed`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::random::Seed;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// assert_eq!(\n    ///     EXAMPLE_SEED.next(),\n    ///     Seed::from_bytes([\n    ///         0x71, 0xef, 0x45, 0x6c, 0xe4, 0xd2, 0xa8, 0xa1, 0x57, 0x20, 0x6e, 0x53, 0xbc, 0x22,\n    ///         0x59, 0xee, 0x5d, 0xc8, 0x95, 0x73, 0xbd, 0x95, 0xd9, 0xc9, 0x75, 0x92, 0x1f, 0x48,\n    ///         0x97, 0xa9, 0xae, 0x21\n    ///     ])\n    /// );\n    /// ```\n    #[inline]\n    pub fn next(self) -> Self {\n        let mut bytes = [0; 32];\n        self.get_rng().fill_bytes(&mut bytes);\n        Self::from_bytes(bytes)\n    }\n\n    /// Generates a new `Seed` from this seed. Passing different `key`s will, with very high\n    /// probability, generate different seeds.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::random::Seed;\n    /// use malachite_base::random::EXAMPLE_SEED;\n    ///\n    /// assert_eq!(\n    ///     EXAMPLE_SEED.fork(\"first\"),\n    ///     Seed::from_bytes([\n    ///         0x20, 0x18, 0x1, 0x3d, 0x96, 0x4d, 0x3e, 0x98, 0x10, 0x9d, 0x35, 0x75, 0x22, 0x89,\n    ///         0xf7, 0xe9, 0xbe, 0x2f, 0x9c, 0x15, 0x95, 0x42, 0x1a, 0x79, 0x52, 0xf, 0x56, 0x9a,\n    ///         0x7b, 0x8c, 0xd9, 0x34\n    ///     ])\n    /// );\n    /// assert_eq!(\n    ///     EXAMPLE_SEED.fork(\"second\"),\n    ///     Seed::from_bytes([\n    ///         0xe0, 0x36, 0x88, 0x58, 0x6d, 0x67, 0x33, 0xea, 0xf2, 0x1c, 0x88, 0xf9, 0xe3, 0xbd,\n    ///         0x52, 0xc0, 0xe5, 0xad, 0x61, 0x81, 0x21, 0xd8, 0x2f, 0x8e, 0xcd, 0xf, 0x89, 0x9d,\n    ///         0x32, 0xc5, 0x35, 0x83\n    ///     ])\n    /// );\n    /// ```\n    pub fn fork(&self, key: &str) -> Self {\n        let mut seed = self.next();\n        let forked_seed = &mut seed.bytes;\n        let hash = Sha3_256::digest(key.as_bytes());\n        for i in 0..32 {\n            forked_seed[i] ^= hash[i];\n        }\n        seed.next()\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/rational_sequences/access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rational_sequences::{RationalSequence, rational_sequence_reduce};\nuse core::ops::Index;\n\nimpl<T: Eq> Index<usize> for RationalSequence<T> {\n    type Output = T;\n\n    /// Gets a reference to an element of a [`RationalSequence`] at an index.\n    ///\n    /// If the index is greater than or equal to the length of the sequence, this function panics.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `index` is greater than or equal to the length of this sequence.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(RationalSequence::from_slices(&[1, 2], &[3, 4])[1], 2);\n    /// assert_eq!(RationalSequence::from_slices(&[1, 2], &[3, 4])[10], 3);\n    /// ```\n    #[inline]\n    fn index(&self, i: usize) -> &T {\n        self.get(i).unwrap()\n    }\n}\n\nimpl<T: Eq> RationalSequence<T> {\n    /// Gets a reference to an element of a [`RationalSequence`] at an index.\n    ///\n    /// If the index is greater than or equal to the length of the sequence, `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::from_slices(&[1, 2], &[3, 4]).get(1),\n    ///     Some(&2)\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::from_slices(&[1, 2], &[3, 4]).get(10),\n    ///     Some(&3)\n    /// );\n    /// ```\n    pub fn get(&self, i: usize) -> Option<&T> {\n        let non_repeating_len = self.non_repeating.len();\n        if i < non_repeating_len {\n            Some(&self.non_repeating[i])\n        } else if self.repeating.is_empty() {\n            None\n        } else {\n            Some(&self.repeating[(i - non_repeating_len) % self.repeating.len()])\n        }\n    }\n}\n\nimpl<T: Clone + Eq> RationalSequence<T> {\n    /// Mutates an element of a [`RationalSequence`] at an index using a provided closure, and then\n    /// returns whatever the closure returns.\n    ///\n    /// If the index is greater than or equal to the length of the sequence, this function panics.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n    ///\n    /// # Panics\n    /// Panics if `index` is greater than or equal to the length of this sequence.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// let mut xs = RationalSequence::from_slices(&[1, 2], &[3, 4]);\n    /// assert_eq!(\n    ///     xs.mutate(1, |x| {\n    ///         *x = 100;\n    ///         25\n    ///     }),\n    ///     25\n    /// );\n    /// assert_eq!(xs, RationalSequence::from_slices(&[1, 100], &[3, 4]));\n    ///\n    /// let mut xs = RationalSequence::from_slices(&[1, 2], &[3, 4]);\n    /// assert_eq!(\n    ///     xs.mutate(6, |x| {\n    ///         *x = 100;\n    ///         25\n    ///     }),\n    ///     25\n    /// );\n    /// assert_eq!(\n    ///     xs,\n    ///     RationalSequence::from_slices(&[1, 2, 3, 4, 3, 4, 100], &[4, 3])\n    /// );\n    /// ```\n    pub fn mutate<F: FnOnce(&mut T) -> U, U>(&mut self, i: usize, f: F) -> U {\n        let non_repeating_len = self.non_repeating.len();\n        let result = if i < non_repeating_len {\n            f(&mut self.non_repeating[i])\n        } else if self.repeating.is_empty() {\n            panic!(\"index out of bounds\");\n        } else {\n            let repeating_len = self.repeating.len();\n            let extra = i - non_repeating_len + 1;\n            self.non_repeating\n                .extend(self.repeating.iter().cycle().take(extra).cloned());\n            self.repeating.rotate_left(extra % repeating_len);\n            f(&mut self.non_repeating[i])\n        };\n        rational_sequence_reduce(&mut self.non_repeating, &mut self.repeating);\n        result\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/rational_sequences/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rational_sequences::RationalSequence;\nuse core::cmp::Ordering::{self, *};\n\nimpl<T: Eq + Ord> PartialOrd for RationalSequence<T> {\n    /// Compares a [`RationalSequence`] to another [`RationalSequence`].\n    ///\n    /// See [here](RationalSequence::cmp) for more information.\n    #[inline]\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp(other))\n    }\n}\n\nimpl<T: Eq + Ord> Ord for RationalSequence<T> {\n    /// Compares a [`RationalSequence`] to another [`RationalSequence`].\n    ///\n    /// The comparison is made lexicographically with respect to the element type's ordering.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.component_len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert!(\n    ///     RationalSequence::from_slice(&[1, 2]) < RationalSequence::from_slices(&[1, 2], &[1])\n    /// );\n    /// assert!(\n    ///     RationalSequence::from_slice(&[1, 2, 3])\n    ///         < RationalSequence::from_slices(&[1, 2], &[3, 4])\n    /// );\n    /// ```\n    fn cmp(&self, other: &Self) -> Ordering {\n        if self == other {\n            Equal\n        } else {\n            Iterator::cmp(self.iter(), other.iter())\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/rational_sequences/conversion.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rational_sequences::{RationalSequence, rational_sequence_reduce};\nuse alloc::vec;\nuse alloc::vec::Vec;\n\nimpl<T: Eq> RationalSequence<T> {\n    /// Converts a [`Vec`] to a finite [`RationalSequence`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(RationalSequence::<u8>::from_vec(vec![]).to_string(), \"[]\");\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vec(vec![1, 2]).to_string(),\n    ///     \"[1, 2]\"\n    /// );\n    /// ```\n    pub const fn from_vec(non_repeating: Vec<T>) -> Self {\n        Self {\n            non_repeating,\n            repeating: vec![],\n        }\n    }\n\n    /// Converts two [`Vec`]s to a finite [`RationalSequence`]. The first [`Vec`] is the\n    /// nonrepeating part and the second is the repeating part.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n + m^{1+\\varepsilon})$ for all $\\varepsilon > 0$\n    ///\n    /// $M(n, m) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `non_repeating.len()`, and $m$ is\n    /// `repeating.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![], vec![]).to_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![], vec![1, 2]).to_string(),\n    ///     \"[[1, 2]]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![1, 2], vec![]).to_string(),\n    ///     \"[1, 2]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![1, 2], vec![3, 4]).to_string(),\n    ///     \"[1, 2, [3, 4]]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![1, 2, 3], vec![4, 3]).to_string(),\n    ///     \"[1, 2, [3, 4]]\"\n    /// );\n    /// ```\n    pub fn from_vecs(mut non_repeating: Vec<T>, mut repeating: Vec<T>) -> Self {\n        rational_sequence_reduce(&mut non_repeating, &mut repeating);\n        Self {\n            non_repeating,\n            repeating,\n        }\n    }\n\n    /// Converts a [`RationalSequence`] to a pair of [`Vec`]s containing the non-repeating and\n    /// repeating parts, taking the [`RationalSequence`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::from_slices(&[1, 2], &[3, 4]).into_vecs(),\n    ///     (vec![1, 2], vec![3, 4])\n    /// );\n    /// ```\n    #[allow(clippy::missing_const_for_fn)] // can't be const because of destructors\n    pub fn into_vecs(self) -> (Vec<T>, Vec<T>) {\n        (self.non_repeating, self.repeating)\n    }\n\n    /// Returns references to the non-repeating and repeating parts of a [`RationalSequence`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::from_slices(&[1u8, 2], &[3, 4]).slices_ref(),\n    ///     (&[1u8, 2][..], &[3u8, 4][..])\n    /// );\n    /// ```\n    #[allow(clippy::missing_const_for_fn)]\n    pub fn slices_ref(&self) -> (&[T], &[T]) {\n        (&self.non_repeating, &self.repeating)\n    }\n}\n\nimpl<T: Clone + Eq> RationalSequence<T> {\n    /// Converts a slice to a finite [`RationalSequence`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(RationalSequence::<u8>::from_slice(&[]).to_string(), \"[]\");\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slice(&[1, 2]).to_string(),\n    ///     \"[1, 2]\"\n    /// );\n    /// ```\n    pub fn from_slice(non_repeating: &[T]) -> Self {\n        Self {\n            non_repeating: non_repeating.to_vec(),\n            repeating: vec![],\n        }\n    }\n\n    /// Converts two slices to a finite [`RationalSequence`]. The first slice is the nonrepeating\n    /// part and the second is the repeating part.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n + m^{1+\\varepsilon})$ for all $\\varepsilon > 0$\n    ///\n    /// $M(n, m) = O(n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `non_repeating.len()`, and $m$ is\n    /// `repeating.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[], &[]).to_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[], &[1, 2]).to_string(),\n    ///     \"[[1, 2]]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2], &[]).to_string(),\n    ///     \"[1, 2]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2], &[3, 4]).to_string(),\n    ///     \"[1, 2, [3, 4]]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2, 3], &[4, 3]).to_string(),\n    ///     \"[1, 2, [3, 4]]\"\n    /// );\n    /// ```\n    pub fn from_slices(non_repeating: &[T], repeating: &[T]) -> Self {\n        let mut non_repeating = non_repeating.to_vec();\n        let mut repeating = repeating.to_vec();\n        rational_sequence_reduce(&mut non_repeating, &mut repeating);\n        Self {\n            non_repeating,\n            repeating,\n        }\n    }\n\n    /// Converts a [`RationalSequence`] to a pair of [`Vec`]s containing the non-repeating and\n    /// repeating parts, taking the [`RationalSequence`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.component_len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::from_slices(&[1, 2], &[3, 4]).to_vecs(),\n    ///     (vec![1, 2], vec![3, 4])\n    /// );\n    /// ```\n    pub fn to_vecs(&self) -> (Vec<T>, Vec<T>) {\n        (self.non_repeating.clone(), self.repeating.clone())\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/rational_sequences/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::exhaustive::PrimitiveIntIncreasingRange;\nuse crate::rational_sequences::{RationalSequence, rational_sequence_is_reduced};\nuse crate::tuples::exhaustive::{ExhaustivePairs1Input, exhaustive_pairs_from_single};\nuse crate::vecs::exhaustive::{ExhaustiveVecs, exhaustive_vecs};\n\n/// Generates all [`RationalSequence`]s containing elements from an iterator.\n///\n/// This `struct` is created by [`exhaustive_rational_sequences`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveRationalSequences<I: Clone + Iterator>(\n    ExhaustivePairs1Input<ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>>,\n)\nwhere\n    I::Item: Clone;\n\nimpl<I: Clone + Iterator> Iterator for ExhaustiveRationalSequences<I>\nwhere\n    I::Item: Clone + Eq,\n{\n    type Item = RationalSequence<I::Item>;\n\n    fn next(&mut self) -> Option<RationalSequence<I::Item>> {\n        loop {\n            let (non_repeating, repeating) = self.0.next()?;\n            if rational_sequence_is_reduced(&non_repeating, &repeating) {\n                return Some(RationalSequence {\n                    non_repeating,\n                    repeating,\n                });\n            }\n        }\n    }\n}\n\n/// Generates all [`RationalSequence`]s containing elements from a given iterator.\n///\n/// The input iterator should contain no repetitions, but this is not enforced.\n///\n/// The output length is 1 if the input iterator is empty, and infinite otherwise.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(T^\\prime(i) + (\\log i)^{1+\\varepsilon})$ for all $\\varepsilon > 0$\n///\n/// $M(i) = O((\\log i) M^\\prime(i))$\n///\n/// where $T$ is time, $M$ is additional memory, and $T^\\prime$ and $M^\\prime$ are the time and\n/// memory functions of the input iterator.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_unsigneds;\n/// use malachite_base::rational_sequences::exhaustive::exhaustive_rational_sequences;\n/// use malachite_base::strings::ToDebugString;\n///\n/// assert_eq!(\n///     exhaustive_rational_sequences(exhaustive_unsigneds::<u8>())\n///         .take(10)\n///         .collect_vec()\n///         .to_debug_string(),\n///     \"[[], [[0]], [0], [[1]], [0, [1]], [1], [1, [0]], [0, 0, 0], [0, 0, 0, [1]], [[2]]]\"\n/// )\n/// ```\npub fn exhaustive_rational_sequences<I: Clone + Iterator>(xs: I) -> ExhaustiveRationalSequences<I>\nwhere\n    I::Item: Clone + Eq,\n{\n    ExhaustiveRationalSequences(exhaustive_pairs_from_single(exhaustive_vecs(xs)))\n}\n"
  },
  {
    "path": "malachite-base/src/rational_sequences/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::slices::min_repeating_len;\nuse alloc::vec::Vec;\nuse core::iter::{Chain, Cycle};\n\nfn rational_sequence_reduce<T: Eq>(non_repeating: &mut Vec<T>, repeating: &mut Vec<T>) {\n    if repeating.is_empty() {\n        return;\n    }\n    repeating.truncate(min_repeating_len(repeating));\n    if non_repeating.is_empty() {\n        return;\n    }\n    let extra_non_repeating = non_repeating\n        .iter()\n        .rev()\n        .zip(repeating.iter().rev().cycle())\n        .take_while(|(x, y)| x == y)\n        .count();\n    if extra_non_repeating != 0 {\n        non_repeating.truncate(non_repeating.len() - extra_non_repeating);\n        let len = repeating.len();\n        repeating.rotate_right(extra_non_repeating % len);\n    }\n}\n\npub_test! {rational_sequence_is_reduced<T: Eq>(non_repeating: &[T], repeating: &[T]) -> bool {\n    if repeating.is_empty() {\n        return true;\n    }\n    if min_repeating_len(repeating) != repeating.len() {\n        return false;\n    }\n    if non_repeating.is_empty() {\n        return true;\n    }\n    non_repeating\n        .iter()\n        .rev()\n        .zip(repeating.iter().rev().cycle())\n        .take_while(|(x, y)| x == y)\n        .count()\n        == 0\n}}\n\n/// A `RationalSequence` is a sequence that is either finite or eventually repeating, just like the\n/// digits of a rational number.\n///\n/// In testing, the set of rational sequences may be used as a proxy for the set of all sequences,\n/// which is too large to work with.\n#[derive(Clone, Default, Eq, Hash, PartialEq)]\npub struct RationalSequence<T: Eq> {\n    non_repeating: Vec<T>,\n    repeating: Vec<T>,\n}\n\nimpl<T: Eq> RationalSequence<T> {\n    /// Returns whether this `RationalSequence` is empty.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(RationalSequence::<u8>::from_slice(&[]).is_empty(), true);\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slice(&[1, 2, 3]).is_empty(),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[], &[3, 4]).is_empty(),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2], &[3, 4]).is_empty(),\n    ///     false\n    /// );\n    /// ```\n    pub const fn is_empty(&self) -> bool {\n        self.non_repeating.is_empty() && self.repeating.is_empty()\n    }\n\n    /// Returns whether this `RationalSequence` is finite (has no repeating part).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(RationalSequence::<u8>::from_slice(&[]).is_finite(), true);\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slice(&[1, 2, 3]).is_finite(),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[], &[3, 4]).is_finite(),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2], &[3, 4]).is_finite(),\n    ///     false\n    /// );\n    /// ```\n    pub const fn is_finite(&self) -> bool {\n        self.repeating.is_empty()\n    }\n\n    /// Returns the length of this `RationalSequence`. If the sequence is infinite, `None` is\n    /// returned.\n    ///\n    /// For a measure of length that always exists, try [`component_len`](Self::component_len).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(RationalSequence::<u8>::from_slice(&[]).len(), Some(0));\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slice(&[1, 2, 3]).len(),\n    ///     Some(3)\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[], &[3, 4]).len(),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2], &[3, 4]).len(),\n    ///     None\n    /// );\n    /// ```\n    pub const fn len(&self) -> Option<usize> {\n        if self.repeating.is_empty() {\n            Some(self.non_repeating.len())\n        } else {\n            None\n        }\n    }\n\n    /// Returns the sum of the lengths of the non-repeating and repeating parts of this\n    /// `RationalSequence`.\n    ///\n    /// This is often a more useful way of measuring the complexity of a sequence than\n    /// [`len`](Self::len).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(RationalSequence::<u8>::from_slice(&[]).component_len(), 0);\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slice(&[1, 2, 3]).component_len(),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[], &[3, 4]).component_len(),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2], &[3, 4]).component_len(),\n    ///     4\n    /// );\n    /// ```\n    pub const fn component_len(&self) -> usize {\n        self.non_repeating.len() + self.repeating.len()\n    }\n\n    /// Returns an iterator of references to the elements of this sequence.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// let empty: &[u8] = &[];\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slice(empty)\n    ///         .iter()\n    ///         .cloned()\n    ///         .collect_vec(),\n    ///     empty\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slice(&[1, 2, 3])\n    ///         .iter()\n    ///         .cloned()\n    ///         .collect_vec(),\n    ///     &[1, 2, 3]\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[], &[3, 4])\n    ///         .iter()\n    ///         .cloned()\n    ///         .take(10)\n    ///         .collect_vec(),\n    ///     &[3, 4, 3, 4, 3, 4, 3, 4, 3, 4]\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_slices(&[1, 2], &[3, 4])\n    ///         .iter()\n    ///         .cloned()\n    ///         .take(10)\n    ///         .collect_vec(),\n    ///     &[1, 2, 3, 4, 3, 4, 3, 4, 3, 4]\n    /// );\n    /// ```\n    pub fn iter(&self) -> Chain<core::slice::Iter<'_, T>, Cycle<core::slice::Iter<'_, T>>> {\n        self.non_repeating\n            .iter()\n            .chain(self.repeating.iter().cycle())\n    }\n}\n\nimpl<T: Clone + Eq> RationalSequence<T> {\n    // Returns true iff `self` is valid.\n    //\n    // To be valid, the non-repeating and repeating parts must be reduced. For example, `[1, 2]` and\n    // `[3, 4]` is a reduced pair. On the other hand, `[1, 2]` and `[3, 4, 3, 4]` is a non-reduced\n    // pair representing the same sequence, as is `[1, 2, 3]` and `[4, 3]`. All `RationalSequence`s\n    // must be valid.\n    #[cfg(feature = \"test_build\")]\n    pub fn is_valid(&self) -> bool {\n        rational_sequence_is_reduced(&self.non_repeating, &self.repeating)\n    }\n}\n\n/// Functions for getting and setting elements in a [`RationalSequence`].\npub mod access;\n/// Functions for comparing [`RationalSequence`]s.\npub mod cmp;\n/// Functions for converting a [`RationalSequence`]s to and from a [`Vec`] or a slice.\npub mod conversion;\n/// Functions for generating all [`RationalSequence`]s over a set of elements.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Functions for generating random [`RationalSequence`]s from a set of elements.\npub mod random;\n/// Functions for displaying a [`RationalSequence`].\npub mod to_string;\n"
  },
  {
    "path": "malachite-base/src/rational_sequences/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::geometric::GeometricRandomNaturalValues;\nuse crate::random::Seed;\nuse crate::rational_sequences::RationalSequence;\nuse crate::vecs::random::{RandomVecs, random_vecs};\n\n/// Generates random [`RationalSequence`]s, given an iterator of random elements.\n///\n/// This `struct` is created by [`random_rational_sequences`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomRationalSequences<I: Iterator>(\n    RandomVecs<I::Item, GeometricRandomNaturalValues<u64>, I>,\n)\nwhere\n    I::Item: Eq;\n\nimpl<I: Iterator> Iterator for RandomRationalSequences<I>\nwhere\n    I::Item: Eq,\n{\n    type Item = RationalSequence<I::Item>;\n\n    fn next(&mut self) -> Option<RationalSequence<I::Item>> {\n        Some(RationalSequence::from_vecs(\n            self.0.next().unwrap(),\n            self.0.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates random [`RationalSequence`]s whose non-repeating and repeating components have a\n/// specified mean length, with elements from a given iterator.\n///\n/// The input iterator must be infinite, but this is not enforced.\n///\n/// The output length is infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::rational_sequences::random::random_rational_sequences;\n/// use malachite_base::rational_sequences::RationalSequence;\n///\n/// assert_eq!(\n///     random_rational_sequences(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1)\n///         .take(10)\n///         .map(|x| RationalSequence::to_string(&x))\n///         .collect_vec(),\n///     &[\n///         \"[[85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32]]\",\n///         \"[166, 234, 30, 218, [90, 106, 9, 216]]\",\n///         \"[204]\",\n///         \"[151, 213, 97, 253, 78, [91, 39]]\",\n///         \"[191, 175, 170, 232]\",\n///         \"[233, 2, 35, 22, 217, 198]\",\n///         \"[[114, 17, 32, 173, 114, 65, 121, 222, 173, 25, 144]]\",\n///         \"[148, 79, 115, 52, 73, 69, 137, 91]\",\n///         \"[153, 178, 112]\",\n///         \"[34, 95, 106, 167, 197, [130, 168, 122, 207, 172, 177, 86, 150, 221]]\"\n///     ]\n/// )\n/// ```\npub fn random_rational_sequences<I: Iterator>(\n    seed: Seed,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomRationalSequences<I>\nwhere\n    I::Item: Eq,\n{\n    RandomRationalSequences(random_vecs(\n        seed,\n        xs_gen,\n        mean_length_numerator,\n        mean_length_denominator,\n    ))\n}\n"
  },
  {
    "path": "malachite-base/src/rational_sequences/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rational_sequences::RationalSequence;\nuse core::fmt::{Debug, Display, Formatter, Result, Write};\n\nimpl<T: Display + Eq> Display for RationalSequence<T> {\n    /// Converts a [`RationalSequence`] to a [`String`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.component_len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![], vec![]).to_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![], vec![1, 2]).to_string(),\n    ///     \"[[1, 2]]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![1, 2], vec![]).to_string(),\n    ///     \"[1, 2]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![1, 2], vec![3, 4]).to_string(),\n    ///     \"[1, 2, [3, 4]]\"\n    /// );\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        f.write_char('[')?;\n        let mut first = true;\n        for x in &self.non_repeating {\n            if first {\n                first = false;\n            } else {\n                f.write_str(\", \")?;\n            }\n            Display::fmt(x, f)?;\n        }\n        if !self.repeating.is_empty() {\n            if !self.non_repeating.is_empty() {\n                f.write_str(\", \")?;\n            }\n            f.write_char('[')?;\n            let mut first = true;\n            for x in &self.repeating {\n                if first {\n                    first = false;\n                } else {\n                    f.write_str(\", \")?;\n                }\n                Display::fmt(x, f)?;\n            }\n            f.write_char(']')?;\n        }\n        f.write_char(']')\n    }\n}\n\nimpl<T: Display + Eq> Debug for RationalSequence<T> {\n    /// Converts a [`RationalSequence`] to a [`String`].\n    ///\n    /// This is the same implementation as for [`Display`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.component_len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    /// use malachite_base::strings::ToDebugString;\n    ///\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![], vec![]).to_debug_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![], vec![1, 2]).to_debug_string(),\n    ///     \"[[1, 2]]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![1, 2], vec![]).to_debug_string(),\n    ///     \"[1, 2]\"\n    /// );\n    /// assert_eq!(\n    ///     RationalSequence::<u8>::from_vecs(vec![1, 2], vec![3, 4]).to_string(),\n    ///     \"[1, 2, [3, 4]]\"\n    /// );\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/rounding_modes/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rounding_modes::{ROUNDING_MODES, RoundingMode};\nuse core::iter::Copied;\nuse core::slice::Iter;\n\npub type ExhaustiveRoundingModes = Copied<Iter<'static, RoundingMode>>;\n\n/// Generates all [`RoundingMode`]s.\n///\n/// The output length is 6.\n///\n/// # Complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n///\n/// assert_eq!(\n///     exhaustive_rounding_modes().collect_vec(),\n///     &[Down, Up, Floor, Ceiling, Nearest, Exact,]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_rounding_modes() -> ExhaustiveRoundingModes {\n    ROUNDING_MODES.iter().copied()\n}\n"
  },
  {
    "path": "malachite-base/src/rounding_modes/from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse alloc::string::String;\nuse alloc::string::ToString;\nuse core::str::FromStr;\n\nimpl FromStr for RoundingMode {\n    type Err = String;\n\n    /// Converts a string to a [`RoundingMode`].\n    ///\n    /// If the string does not represent a valid [`RoundingMode`], an `Err` is returned with the\n    /// unparseable string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ = `src.len()`.\n    ///\n    /// The worst case occurs when the input string is invalid and must be copied into an `Err`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::{self, *};\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(RoundingMode::from_str(\"Down\"), Ok(Down));\n    /// assert_eq!(RoundingMode::from_str(\"Up\"), Ok(Up));\n    /// assert_eq!(RoundingMode::from_str(\"Floor\"), Ok(Floor));\n    /// assert_eq!(RoundingMode::from_str(\"Ceiling\"), Ok(Ceiling));\n    /// assert_eq!(RoundingMode::from_str(\"Nearest\"), Ok(Nearest));\n    /// assert_eq!(RoundingMode::from_str(\"Exact\"), Ok(Exact));\n    /// assert_eq!(RoundingMode::from_str(\"abc\"), Err(\"abc\".to_string()));\n    /// ```\n    #[inline]\n    fn from_str(src: &str) -> Result<Self, String> {\n        match src {\n            \"Down\" => Ok(Down),\n            \"Up\" => Ok(Up),\n            \"Floor\" => Ok(Floor),\n            \"Ceiling\" => Ok(Ceiling),\n            \"Nearest\" => Ok(Nearest),\n            \"Exact\" => Ok(Exact),\n            _ => Err(src.to_string()),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/rounding_modes/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::named::Named;\nuse crate::rounding_modes::RoundingMode::*;\n\n/// An enum that specifies how a value should be rounded.\n///\n/// A `RoundingMode` can often be specified when a function conceptually returns a value of one\n/// type, but must be rounded to another type. The most common case is a conceptually real-valued\n/// function whose result must be rounded to an integer, like\n/// [`div_round`](crate::num::arithmetic::traits::DivRound::div_round).\n///\n/// # Examples\n/// Here are some examples of how floating-point values would be rounded to integer values using the\n/// different `RoundingMode`s.\n///\n/// | x    | `Floor` | `Ceiling` | `Down` | `Up` | `Nearest` | `Exact`    |\n/// |------|---------|-----------|--------|------|-----------|------------|\n/// |  3.0 |       3 |         3 |      3 |    3 |         3 |          3 |\n/// |  3.2 |       3 |         4 |      3 |    4 |         3 | `panic!()` |\n/// |  3.8 |       3 |         4 |      3 |    4 |         4 | `panic!()` |\n/// |  3.5 |       3 |         4 |      3 |    4 |         4 | `panic!()` |\n/// |  4.5 |       4 |         5 |      4 |    5 |         4 | `panic!()` |\n/// | -3.2 |      -4 |        -3 |     -3 |   -4 |        -3 | `panic!()` |\n/// | -3.8 |      -4 |        -3 |     -3 |   -4 |        -4 | `panic!()` |\n/// | -3.5 |      -4 |        -3 |     -3 |   -4 |        -4 | `panic!()` |\n/// | -4.5 |      -5 |        -4 |     -4 |   -5 |        -4 | `panic!()` |\n///\n/// Sometimes a `RoundingMode` is used in an unusual context, such as rounding an integer to a\n/// floating-point number, in which case further explanation of its behavior is provided at the\n/// usage site.\n///\n/// A `RoundingMode` takes up 1 byte of space.\n#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]\npub enum RoundingMode {\n    /// Applies the function $x \\mapsto \\operatorname{sgn}(x) \\lfloor |x| \\rfloor$. In other words,\n    /// the value is rounded towards 0.\n    Down,\n    /// Applies the function $x \\mapsto \\operatorname{sgn}(x) \\lceil |x| \\rceil$. In other words,\n    /// the value is rounded away from 0.\n    Up,\n    /// Applies the floor function: $x \\mapsto \\lfloor x \\rfloor$. In other words, the value is\n    /// rounded towards $-\\infty$.\n    Floor,\n    /// Applies the ceiling function: $x \\mapsto \\lceil x \\rceil$. In other words, the value is\n    /// rounded towards $\\infty$.\n    Ceiling,\n    /// Applies the function\n    /// $$\n    ///   x \\mapsto \\\\begin{cases}\n    ///       \\lfloor x \\rfloor & x - \\lfloor x \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///       \\lceil x \\rceil & x - \\lfloor x \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///       \\lfloor x \\rfloor &\n    ///  x - \\lfloor x \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///         \\\\ \\lfloor x \\rfloor \\\\ \\text{is even} \\\\\\\\\n    ///       \\lceil x \\rceil &\n    ///  x - \\lfloor x \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor x \\rfloor \\\\ \\text{is odd.}\n    ///   \\\\end{cases}\n    /// $$\n    /// In other words, it rounds to the nearest integer, and when there's a tie, it rounds to the\n    /// nearest even integer. This is also called _bankers' rounding_ and is often used as a\n    /// default.\n    Nearest,\n    /// Panics if the value is not already rounded.\n    Exact,\n}\n\nimpl_named!(RoundingMode);\n\n/// A list of all six rounding modes.\npub const ROUNDING_MODES: [RoundingMode; 6] = [Down, Up, Floor, Ceiling, Nearest, Exact];\n\n/// Iterators that generate [`RoundingMode`]s without repetition.\npub mod exhaustive;\n/// Functions for converting a string to a [`RoundingMode`].\npub mod from_str;\n/// Functions for negating a [`RoundingMode`].\npub mod neg;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`RoundingMode`]s randomly.\npub mod random;\n/// Functions for displaying a [`RoundingMode`].\npub mod to_string;\n"
  },
  {
    "path": "malachite-base/src/rounding_modes/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::NegAssign;\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse core::ops::Neg;\n\n/// Returns the negative of a [`RoundingMode`].\n///\n/// The negative is defined so that if a [`RoundingMode`] $m$ is used to round the result of an odd\n/// function $f$, then $f(x, -m) = -f(-x, m)$. `Floor` and `Ceiling` are swapped, and the other\n/// modes are unchanged.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n///\n/// assert_eq!(-Down, Down);\n/// assert_eq!(-Up, Up);\n/// assert_eq!(-Floor, Ceiling);\n/// assert_eq!(-Ceiling, Floor);\n/// assert_eq!(-Nearest, Nearest);\n/// assert_eq!(-Exact, Exact);\n/// ```\nimpl Neg for RoundingMode {\n    type Output = Self;\n\n    #[inline]\n    fn neg(self) -> Self {\n        match self {\n            Floor => Ceiling,\n            Ceiling => Floor,\n            rm => rm,\n        }\n    }\n}\n\nimpl NegAssign for RoundingMode {\n    /// Replaces a [`RoundingMode`] with its negative.\n    ///\n    /// The negative is defined so that if a [`RoundingMode`] $m$ is used to round the result of an\n    /// odd function $f$, then $f(x, -m) = -f(-x, m)$. `Floor` and `Ceiling` are swapped, and the\n    /// other modes are unchanged.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NegAssign;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    ///\n    /// let mut rm = Down;\n    /// rm.neg_assign();\n    /// assert_eq!(rm, Down);\n    ///\n    /// let mut rm = Floor;\n    /// rm.neg_assign();\n    /// assert_eq!(rm, Ceiling);\n    /// ```\n    #[inline]\n    fn neg_assign(&mut self) {\n        if *self == Floor {\n            *self = Ceiling;\n        } else if *self == Ceiling {\n            *self = Floor;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/rounding_modes/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::random::Seed;\nuse crate::rounding_modes::{ROUNDING_MODES, RoundingMode};\nuse crate::slices::{RandomValuesFromSlice, random_values_from_slice};\nuse std::iter::Copied;\n\n/// Uniformly generates random [`RoundingMode`]s.\npub type RandomRoundingModes = Copied<RandomValuesFromSlice<'static, RoundingMode>>;\n\n/// Uniformly generates random [`RoundingMode`]s.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity\n///\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::rounding_modes::random::random_rounding_modes;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n///\n/// assert_eq!(\n///     random_rounding_modes(EXAMPLE_SEED).take(10).collect_vec(),\n///     &[Up, Exact, Ceiling, Up, Floor, Nearest, Exact, Up, Floor, Exact]\n/// )\n/// ```\n#[inline]\npub fn random_rounding_modes(seed: Seed) -> RandomRoundingModes {\n    random_values_from_slice(seed, &ROUNDING_MODES).copied()\n}\n"
  },
  {
    "path": "malachite-base/src/rounding_modes/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::rounding_modes::RoundingMode;\nuse core::fmt::{Debug, Display, Formatter, Result};\n\nimpl Display for RoundingMode {\n    /// Converts a [`RoundingMode`] to a [`String`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    ///\n    /// assert_eq!(Down.to_string(), \"Down\");\n    /// assert_eq!(Up.to_string(), \"Up\");\n    /// assert_eq!(Floor.to_string(), \"Floor\");\n    /// assert_eq!(Ceiling.to_string(), \"Ceiling\");\n    /// assert_eq!(Nearest.to_string(), \"Nearest\");\n    /// assert_eq!(Exact.to_string(), \"Exact\");\n    /// ```\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Debug::fmt(self, f)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/sets/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::vecs::exhaustive::{\n    ExhaustiveOrderedUniqueCollections, LexFixedLengthOrderedUniqueCollections,\n    LexOrderedUniqueCollections, ShortlexOrderedUniqueCollections,\n};\n#[cfg(not(feature = \"std\"))]\nuse alloc::collections::BTreeSet;\nuse core::hash::Hash;\n#[cfg(not(feature = \"std\"))]\nuse hashbrown::HashSet;\n#[cfg(feature = \"std\")]\nuse std::collections::{BTreeSet, HashSet};\n\n/// Generates [`HashSet`]s of a given size with elements from a single iterator.\n///\n/// The [`HashSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n///\n/// If $k$ is 0, the output consists of one empty [`HashSet`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_hash_sets_fixed_length;\n/// use maplit::hashset;\n///\n/// let xss = lex_hash_sets_fixed_length(4, 1..=6).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2, 3, 4},\n///         hashset! {1, 2, 3, 5},\n///         hashset! {1, 2, 3, 6},\n///         hashset! {1, 2, 4, 5},\n///         hashset! {1, 2, 4, 6},\n///         hashset! {1, 2, 5, 6},\n///         hashset! {1, 3, 4, 5},\n///         hashset! {1, 3, 4, 6},\n///         hashset! {1, 3, 5, 6},\n///         hashset! {1, 4, 5, 6},\n///         hashset! {2, 3, 4, 5},\n///         hashset! {2, 3, 4, 6},\n///         hashset! {2, 3, 5, 6},\n///         hashset! {2, 4, 5, 6},\n///         hashset! {3, 4, 5, 6}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_hash_sets_fixed_length<I: Iterator>(\n    k: u64,\n    xs: I,\n) -> LexFixedLengthOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    LexFixedLengthOrderedUniqueCollections::new(k, xs)\n}\n\n/// Generates [`HashSet`]s with elements from a single iterator.\n///\n/// The [`HashSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`HashSet`]s of length 2 and above will never\n/// be generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`HashSet`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_hash_sets;\n/// use maplit::hashset;\n///\n/// let xss = shortlex_hash_sets(1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {},\n///         hashset! {1},\n///         hashset! {2},\n///         hashset! {3},\n///         hashset! {4},\n///         hashset! {1, 2},\n///         hashset! {1, 3},\n///         hashset! {1, 4},\n///         hashset! {2, 3},\n///         hashset! {2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4},\n///         hashset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_hash_sets<I: Clone + Iterator>(\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    shortlex_hash_sets_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`HashSet`]s with a mininum length, with elements from a single iterator.\n///\n/// The [`HashSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`HashSet`]s of length `\\max(2, \\ell + 1)` and\n/// above will never be generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_hash_sets_min_length;\n/// use maplit::hashset;\n///\n/// let xss = shortlex_hash_sets_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 3},\n///         hashset! {1, 4},\n///         hashset! {2, 3},\n///         hashset! {2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4},\n///         hashset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_hash_sets_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    shortlex_hash_sets_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`HashSet`]s, with lengths in a range $[a, b)$, with elements from a single iterator.\n///\n/// The [`HashSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`HashSet`]s of length `\\max(2, a + 1)` and\n/// above will never be generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`HashSet`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b - 1 \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_hash_sets_length_range;\n/// use maplit::hashset;\n///\n/// let xss = shortlex_hash_sets_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 3},\n///         hashset! {1, 4},\n///         hashset! {2, 3},\n///         hashset! {2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_hash_sets_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    shortlex_hash_sets_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`HashSet`]s, with lengths in a range $[a, b]$, with elements from a single iterator.\n///\n/// The [`HashSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`HashSet`]s of length `\\max(2, a + 1)` and\n/// above will never be generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`HashSet`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_hash_sets_length_inclusive_range;\n/// use maplit::hashset;\n///\n/// let xss = shortlex_hash_sets_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 3},\n///         hashset! {1, 4},\n///         hashset! {2, 3},\n///         hashset! {2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_hash_sets_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    ShortlexOrderedUniqueCollections::new(a, b, xs)\n}\n\n/// Generates [`HashSet`]s with elements from a single iterator.\n///\n/// The [`HashSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`HashSet`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_hash_sets;\n/// use maplit::hashset;\n///\n/// let xss = lex_hash_sets(1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {},\n///         hashset! {1},\n///         hashset! {1, 2},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 3, 4},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3},\n///         hashset! {1, 3, 4},\n///         hashset! {1, 4},\n///         hashset! {2},\n///         hashset! {2, 3},\n///         hashset! {2, 3, 4},\n///         hashset! {2, 4},\n///         hashset! {3},\n///         hashset! {3, 4},\n///         hashset! {4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_hash_sets<I: Clone + Iterator>(xs: I) -> LexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    lex_hash_sets_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`HashSet`]s with a mininum length, with elements from a single iterator.\n///\n/// The [`HashSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_hash_sets_min_length;\n/// use maplit::hashset;\n///\n/// let xss = lex_hash_sets_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 3, 4},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3},\n///         hashset! {1, 3, 4},\n///         hashset! {1, 4},\n///         hashset! {2, 3},\n///         hashset! {2, 3, 4},\n///         hashset! {2, 4},\n///         hashset! {3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_hash_sets_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    lex_hash_sets_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`HashSet`]s, with lengths in a range $[a, b)$, with elements from a single iterator.\n///\n/// The [`HashSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`HashSet`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b - 1 \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_hash_sets_length_range;\n/// use maplit::hashset;\n///\n/// let xss = lex_hash_sets_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3},\n///         hashset! {1, 3, 4},\n///         hashset! {1, 4},\n///         hashset! {2, 3},\n///         hashset! {2, 3, 4},\n///         hashset! {2, 4},\n///         hashset! {3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_hash_sets_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    lex_hash_sets_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`HashSet`]s, with lengths in a range $[a, b]$, with elements from a single iterator.\n///\n/// The [`HashSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`HashSet`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_hash_sets_length_inclusive_range;\n/// use maplit::hashset;\n///\n/// let xss = lex_hash_sets_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 2, 4},\n///         hashset! {1, 3},\n///         hashset! {1, 3, 4},\n///         hashset! {1, 4},\n///         hashset! {2, 3},\n///         hashset! {2, 3, 4},\n///         hashset! {2, 4},\n///         hashset! {3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_hash_sets_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    LexOrderedUniqueCollections::new(a, b, xs)\n}\n\n/// Generates [`HashSet`]s of a given size with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n///\n/// If $k$ is 0, the output consists of one empty [`HashSet`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_hash_sets_fixed_length;\n/// use maplit::hashset;\n///\n/// let xss = exhaustive_hash_sets_fixed_length(4, 1..=6).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2, 3, 4},\n///         hashset! {1, 2, 3, 5},\n///         hashset! {1, 2, 4, 5},\n///         hashset! {1, 3, 4, 5},\n///         hashset! {2, 3, 4, 5},\n///         hashset! {1, 2, 3, 6},\n///         hashset! {1, 2, 4, 6},\n///         hashset! {1, 3, 4, 6},\n///         hashset! {2, 3, 4, 6},\n///         hashset! {1, 2, 5, 6},\n///         hashset! {1, 3, 5, 6},\n///         hashset! {2, 3, 5, 6},\n///         hashset! {1, 4, 5, 6},\n///         hashset! {2, 4, 5, 6},\n///         hashset! {3, 4, 5, 6}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_hash_sets_fixed_length<I: Clone + Iterator>(\n    k: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    exhaustive_hash_sets_length_inclusive_range(k, k, xs)\n}\n\n/// Generates [`HashSet`]s with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`HashSet`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_hash_sets;\n/// use maplit::hashset;\n///\n/// let xss = exhaustive_hash_sets(1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {},\n///         hashset! {1},\n///         hashset! {2},\n///         hashset! {1, 2},\n///         hashset! {3},\n///         hashset! {1, 3},\n///         hashset! {2, 3},\n///         hashset! {1, 2, 3},\n///         hashset! {4},\n///         hashset! {1, 4},\n///         hashset! {2, 4},\n///         hashset! {1, 2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4},\n///         hashset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_hash_sets<I: Clone + Iterator>(\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    exhaustive_hash_sets_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`HashSet`]s with a mininum length, with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_hash_sets_min_length;\n/// use maplit::hashset;\n///\n/// let xss = exhaustive_hash_sets_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 3},\n///         hashset! {2, 3},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 4},\n///         hashset! {2, 4},\n///         hashset! {1, 2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4},\n///         hashset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_hash_sets_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    exhaustive_hash_sets_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`HashSet`]s, with lengths in a range $[a, b)$, with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`HashSet`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b - 1 \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_hash_sets_length_range;\n/// use maplit::hashset;\n///\n/// let xss = exhaustive_hash_sets_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 3},\n///         hashset! {2, 3},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 4},\n///         hashset! {2, 4},\n///         hashset! {1, 2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_hash_sets_length_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    if a >= b {\n        ExhaustiveOrderedUniqueCollections::None\n    } else {\n        exhaustive_hash_sets_length_inclusive_range(a, b - 1, xs)\n    }\n}\n\n/// Generates [`HashSet`]s, with lengths in a range $[a, b]$, with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`HashSet`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_hash_sets_length_inclusive_range;\n/// use maplit::hashset;\n///\n/// let xss = exhaustive_hash_sets_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {1, 2},\n///         hashset! {1, 3},\n///         hashset! {2, 3},\n///         hashset! {1, 2, 3},\n///         hashset! {1, 4},\n///         hashset! {2, 4},\n///         hashset! {1, 2, 4},\n///         hashset! {3, 4},\n///         hashset! {1, 3, 4},\n///         hashset! {2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_hash_sets_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, HashSet<I::Item>>\nwhere\n    I::Item: Clone + Eq + Hash,\n{\n    ExhaustiveOrderedUniqueCollections::new(a, b, xs)\n}\n\n/// Generates [`BTreeSet`]s of a given size with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n///\n/// If $k$ is 0, the output consists of one empty [`BTreeSet`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_b_tree_sets_fixed_length;\n/// use maplit::btreeset;\n///\n/// let xss = lex_b_tree_sets_fixed_length(4, 1..=6).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2, 3, 4},\n///         btreeset! {1, 2, 3, 5},\n///         btreeset! {1, 2, 3, 6},\n///         btreeset! {1, 2, 4, 5},\n///         btreeset! {1, 2, 4, 6},\n///         btreeset! {1, 2, 5, 6},\n///         btreeset! {1, 3, 4, 5},\n///         btreeset! {1, 3, 4, 6},\n///         btreeset! {1, 3, 5, 6},\n///         btreeset! {1, 4, 5, 6},\n///         btreeset! {2, 3, 4, 5},\n///         btreeset! {2, 3, 4, 6},\n///         btreeset! {2, 3, 5, 6},\n///         btreeset! {2, 4, 5, 6},\n///         btreeset! {3, 4, 5, 6}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_b_tree_sets_fixed_length<I: Iterator>(\n    k: u64,\n    xs: I,\n) -> LexFixedLengthOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    LexFixedLengthOrderedUniqueCollections::new(k, xs)\n}\n\n/// Generates [`BTreeSet`]s with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`BTreeSet`]s of length 2 and above will never\n/// be generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`HashSet`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_b_tree_sets;\n/// use maplit::btreeset;\n///\n/// let xss = shortlex_b_tree_sets(1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {},\n///         btreeset! {1},\n///         btreeset! {2},\n///         btreeset! {3},\n///         btreeset! {4},\n///         btreeset! {1, 2},\n///         btreeset! {1, 3},\n///         btreeset! {1, 4},\n///         btreeset! {2, 3},\n///         btreeset! {2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4},\n///         btreeset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_b_tree_sets<I: Clone + Iterator>(\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    shortlex_b_tree_sets_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`BTreeSet`]s with a mininum length, with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`BTreeSet`]s of length `\\max(2, \\ell + 1)`\n/// and above will never be generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_b_tree_sets_min_length;\n/// use maplit::btreeset;\n///\n/// let xss = shortlex_b_tree_sets_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 3},\n///         btreeset! {1, 4},\n///         btreeset! {2, 3},\n///         btreeset! {2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4},\n///         btreeset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_b_tree_sets_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    shortlex_b_tree_sets_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`BTreeSet`]s, with lengths in a range $[a, b)$, with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`BTreeSet`]s of length `\\max(2, a + 1)` and\n/// above will never be generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`BTreeSet`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b - 1 \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_b_tree_sets_length_range;\n/// use maplit::btreeset;\n///\n/// let xss = shortlex_b_tree_sets_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 3},\n///         btreeset! {1, 4},\n///         btreeset! {2, 3},\n///         btreeset! {2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_b_tree_sets_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    shortlex_b_tree_sets_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`BTreeSet`]s, with lengths in a range $[a, b]$, with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`BTreeSet`]s of length `\\max(2, a + 1)` and\n/// above will never be generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`BTreeSet`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::shortlex_b_tree_sets_length_inclusive_range;\n/// use maplit::btreeset;\n///\n/// let xss = shortlex_b_tree_sets_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 3},\n///         btreeset! {1, 4},\n///         btreeset! {2, 3},\n///         btreeset! {2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_b_tree_sets_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    ShortlexOrderedUniqueCollections::new(a, b, xs)\n}\n\n/// Generates [`BTreeSet`]s with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`BTreeSet`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_b_tree_sets;\n/// use maplit::btreeset;\n///\n/// let xss = lex_b_tree_sets(1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {},\n///         btreeset! {1},\n///         btreeset! {1, 2},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 3, 4},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3},\n///         btreeset! {1, 3, 4},\n///         btreeset! {1, 4},\n///         btreeset! {2},\n///         btreeset! {2, 3},\n///         btreeset! {2, 3, 4},\n///         btreeset! {2, 4},\n///         btreeset! {3},\n///         btreeset! {3, 4},\n///         btreeset! {4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_b_tree_sets<I: Clone + Iterator>(\n    xs: I,\n) -> LexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    lex_b_tree_sets_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`BTreeSet`]s with a mininum length, with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_b_tree_sets_min_length;\n/// use maplit::btreeset;\n///\n/// let xss = lex_b_tree_sets_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 3, 4},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3},\n///         btreeset! {1, 3, 4},\n///         btreeset! {1, 4},\n///         btreeset! {2, 3},\n///         btreeset! {2, 3, 4},\n///         btreeset! {2, 4},\n///         btreeset! {3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_b_tree_sets_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    lex_b_tree_sets_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`BTreeSet`]s, with lengths in a range $[a, b)$, with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`BTreeSet`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b - 1 \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_b_tree_sets_length_range;\n/// use maplit::btreeset;\n///\n/// let xss = lex_b_tree_sets_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3},\n///         btreeset! {1, 3, 4},\n///         btreeset! {1, 4},\n///         btreeset! {2, 3},\n///         btreeset! {2, 3, 4},\n///         btreeset! {2, 4},\n///         btreeset! {3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_b_tree_sets_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    lex_b_tree_sets_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`BTreeSet`]s, with lengths in a range $[a, b]$, with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`BTreeSet`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::lex_b_tree_sets_length_inclusive_range;\n/// use maplit::btreeset;\n///\n/// let xss = lex_b_tree_sets_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 2, 4},\n///         btreeset! {1, 3},\n///         btreeset! {1, 3, 4},\n///         btreeset! {1, 4},\n///         btreeset! {2, 3},\n///         btreeset! {2, 3, 4},\n///         btreeset! {2, 4},\n///         btreeset! {3, 4},\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_b_tree_sets_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    LexOrderedUniqueCollections::new(a, b, xs)\n}\n\n/// Generates [`BTreeSet`]s of a given size with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n///\n/// If $k$ is 0, the output consists of one empty [`BTreeSet`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_b_tree_sets_fixed_length;\n/// use maplit::btreeset;\n///\n/// let xss = exhaustive_b_tree_sets_fixed_length(4, 1..=6).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2, 3, 4},\n///         btreeset! {1, 2, 3, 5},\n///         btreeset! {1, 2, 4, 5},\n///         btreeset! {1, 3, 4, 5},\n///         btreeset! {2, 3, 4, 5},\n///         btreeset! {1, 2, 3, 6},\n///         btreeset! {1, 2, 4, 6},\n///         btreeset! {1, 3, 4, 6},\n///         btreeset! {2, 3, 4, 6},\n///         btreeset! {1, 2, 5, 6},\n///         btreeset! {1, 3, 5, 6},\n///         btreeset! {2, 3, 5, 6},\n///         btreeset! {1, 4, 5, 6},\n///         btreeset! {2, 4, 5, 6},\n///         btreeset! {3, 4, 5, 6}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_b_tree_sets_fixed_length<I: Clone + Iterator>(\n    k: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    exhaustive_b_tree_sets_length_inclusive_range(k, k, xs)\n}\n\n/// Generates [`BTreeSet`]s with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`BTreeSet`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_b_tree_sets;\n/// use maplit::btreeset;\n///\n/// let xss = exhaustive_b_tree_sets(1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {},\n///         btreeset! {1},\n///         btreeset! {2},\n///         btreeset! {1, 2},\n///         btreeset! {3},\n///         btreeset! {1, 3},\n///         btreeset! {2, 3},\n///         btreeset! {1, 2, 3},\n///         btreeset! {4},\n///         btreeset! {1, 4},\n///         btreeset! {2, 4},\n///         btreeset! {1, 2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4},\n///         btreeset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_b_tree_sets<I: Clone + Iterator>(\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    exhaustive_b_tree_sets_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`BTreeSet`]s with a mininum length, with elements from a single iterator.\n///\n/// The [`BTreeSet`]s are ordered lexicographically with respect to the order of the element\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_b_tree_sets_min_length;\n/// use maplit::btreeset;\n///\n/// let xss = exhaustive_b_tree_sets_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 3},\n///         btreeset! {2, 3},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 4},\n///         btreeset! {2, 4},\n///         btreeset! {1, 2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4},\n///         btreeset! {1, 2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_b_tree_sets_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    exhaustive_b_tree_sets_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`BTreeSet`]s, with lengths in a range $[a, b)$, with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`BTreeSet`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b - 1 \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_b_tree_sets_length_range;\n/// use maplit::btreeset;\n///\n/// let xss = exhaustive_b_tree_sets_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 3},\n///         btreeset! {2, 3},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 4},\n///         btreeset! {2, 4},\n///         btreeset! {1, 2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_b_tree_sets_length_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    if a >= b {\n        ExhaustiveOrderedUniqueCollections::None\n    } else {\n        exhaustive_b_tree_sets_length_inclusive_range(a, b - 1, xs)\n    }\n}\n\n/// Generates [`BTreeSet`]s, with lengths in a range $[a, b]$, with elements from a single iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`BTreeSet`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::sets::exhaustive::exhaustive_b_tree_sets_length_inclusive_range;\n/// use maplit::btreeset;\n///\n/// let xss = exhaustive_b_tree_sets_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {1, 2},\n///         btreeset! {1, 3},\n///         btreeset! {2, 3},\n///         btreeset! {1, 2, 3},\n///         btreeset! {1, 4},\n///         btreeset! {2, 4},\n///         btreeset! {1, 2, 4},\n///         btreeset! {3, 4},\n///         btreeset! {1, 3, 4},\n///         btreeset! {2, 3, 4}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_b_tree_sets_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, BTreeSet<I::Item>>\nwhere\n    I::Item: Clone + Ord,\n{\n    ExhaustiveOrderedUniqueCollections::new(a, b, xs)\n}\n"
  },
  {
    "path": "malachite-base/src/sets/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Iterators that generate sets without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate sets randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/sets/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::conversion::traits::ExactFrom;\nuse crate::num::random::geometric::{\n    GeometricRandomNaturalValues, geometric_random_unsigned_inclusive_range,\n    geometric_random_unsigneds,\n};\nuse crate::num::random::{\n    RandomUnsignedInclusiveRange, RandomUnsignedRange, random_unsigned_inclusive_range,\n    random_unsigned_range,\n};\nuse crate::random::Seed;\n#[cfg(not(feature = \"test_build\"))]\nuse alloc::collections::BTreeSet;\nuse core::hash::Hash;\n#[cfg(not(feature = \"test_build\"))]\nuse hashbrown::HashSet;\n#[cfg(feature = \"test_build\")]\nuse std::collections::{BTreeSet, HashSet};\n\n/// Generates random [`HashSet`]s of a fixed length, where the [`Vec`]s have no repeated elements,\n/// and the elements are in ascending order.\n///\n/// This `struct` is created by [`random_hash_sets_fixed_length`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomHashSetsFixedLength<I: Iterator>\nwhere\n    I::Item: Eq + Hash,\n{\n    len: usize,\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomHashSetsFixedLength<I>\nwhere\n    I::Item: Eq + Hash,\n{\n    type Item = HashSet<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<HashSet<I::Item>> {\n        let mut set = HashSet::new();\n        while set.len() < self.len {\n            set.insert(self.xs.next().unwrap());\n        }\n        Some(set)\n    }\n}\n\n/// Randomly generates [`HashSet`]s of a given length.\n///\n/// The input iterator must generate at least `len` distinct elements; otherwise, this iterator will\n/// hang.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// If `len` is 0, the output consists of the empty set, repeated.\n///\n/// `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_hash_sets_fixed_length;\n/// use maplit::hashset;\n///\n/// let xss = random_hash_sets_fixed_length(\n///     2,\n///     random_unsigned_inclusive_range::<u32>(EXAMPLE_SEED, 1, 100),\n/// )\n/// .take(10)\n/// .collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         hashset! {24, 95},\n///         hashset! {71, 99},\n///         hashset! {53, 93},\n///         hashset! {34, 85},\n///         hashset! {2, 48},\n///         hashset! {11, 55},\n///         hashset! {18, 48},\n///         hashset! {90, 93},\n///         hashset! {67, 93},\n///         hashset! {93, 95}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_hash_sets_fixed_length<I: Iterator>(len: u64, xs: I) -> RandomHashSetsFixedLength<I>\nwhere\n    I::Item: Eq + Hash,\n{\n    RandomHashSetsFixedLength {\n        len: usize::exact_from(len),\n        xs,\n    }\n}\n\n/// Generates random [`HashSet`]s with lengths from an iterator.\n#[derive(Clone, Debug)]\npub struct RandomHashSets<T: Eq + Hash, I: Iterator<Item = u64>, J: Iterator<Item = T>> {\n    lengths: I,\n    xs: J,\n}\n\nimpl<T: Eq + Hash, I: Iterator<Item = u64>, J: Iterator<Item = T>> Iterator\n    for RandomHashSets<T, I, J>\n{\n    type Item = HashSet<T>;\n\n    fn next(&mut self) -> Option<HashSet<T>> {\n        let len = usize::exact_from(self.lengths.next().unwrap());\n        let mut set = HashSet::new();\n        while set.len() < len {\n            set.insert(self.xs.next().unwrap());\n        }\n        Some(set)\n    }\n}\n\n/// Generates random [`HashSet`]s using elements from an iterator and with lengths from another\n/// iterator.\n///\n/// The input iterator must generate at least many distinct elements as any number generated by the\n/// lengths iterator; otherwise, this iterator will hang.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P(n)\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `lengths` and `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_hash_sets_from_length_iterator;\n/// use malachite_base::vecs::random_values_from_vec;\n/// use maplit::hashset;\n///\n/// let xs = random_hash_sets_from_length_iterator(\n///     EXAMPLE_SEED,\n///     &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n///     &random_primitive_ints::<u8>,\n/// );\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         hashset! {11, 85},\n///         hashset! {134, 136, 200, 235},\n///         hashset! {203, 223},\n///         hashset! {38, 177, 217, 235},\n///         hashset! {32, 162, 166, 234},\n///         hashset! {30, 218},\n///         hashset! {},\n///         hashset! {90, 106},\n///         hashset! {},\n///         hashset! {9, 151, 204, 216},\n///         hashset! {78, 97, 213, 253},\n///         hashset! {39, 91},\n///         hashset! {170, 175, 191, 232},\n///         hashset! {2, 233},\n///         hashset! {22, 35, 198, 217},\n///         hashset! {17, 32, 114, 173},\n///         hashset! {65, 114, 121, 222},\n///         hashset! {},\n///         hashset! {25, 144, 148, 173},\n///         hashset! {}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_hash_sets_from_length_iterator<\n    T: Eq + Hash,\n    I: Iterator<Item = u64>,\n    J: Iterator<Item = T>,\n>(\n    seed: Seed,\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n) -> RandomHashSets<T, I, J> {\n    RandomHashSets {\n        lengths: lengths_gen(seed.fork(\"lengths\")),\n        xs: xs_gen(seed.fork(\"xs\")),\n    }\n}\n\n/// Generates random [`HashSet`]s using elements from an iterator.\n///\n/// The lengths of the [`HashSet`]s are sampled from a geometric distribution with a specified mean\n/// $m$, equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P_g(n)\\prod\\_{i=0}^{n-1}P(x\\_i),\n/// $$\n/// where $P_g(n)$ is the probability function described in [`geometric_random_unsigneds`].\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_hash_sets;\n/// use maplit::hashset;\n///\n/// let xs = random_hash_sets(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         hashset! {},\n///         hashset! {11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235},\n///         hashset! {30, 90, 218, 234},\n///         hashset! {9, 106, 204, 216},\n///         hashset! {151},\n///         hashset! {},\n///         hashset! {78, 91, 97, 213, 253},\n///         hashset! {39, 191},\n///         hashset! {170, 175, 232, 233},\n///         hashset! {},\n///         hashset! {2, 22, 35, 114, 198, 217},\n///         hashset! {},\n///         hashset! {},\n///         hashset! {17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222},\n///         hashset! {52, 69, 73, 91, 115, 137, 153, 178},\n///         hashset! {},\n///         hashset! {34, 95, 112},\n///         hashset! {},\n///         hashset! {106, 130, 167, 168, 197},\n///         hashset! {86, 101, 122, 150, 172, 177, 207, 218, 221}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_hash_sets<I: Iterator>(\n    seed: Seed,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomHashSets<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_hash_sets_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigneds(seed_2, mean_length_numerator, mean_length_denominator)\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`HashSet`]s with a minimum length, using elements from an iterator.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P_g(n)\\prod\\_{i=0}^{n-1}P(x\\_i),\n/// $$\n/// where $P_g(n)$ is the probability function described in\n/// [`geometric_random_unsigned_inclusive_range`] with $a$ equal to `min_length` and `b` to\n/// `u64::MAX`.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, if their ratio is less\n/// than or equal to `min_length`, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_hash_sets_min_length;\n/// use maplit::hashset;\n///\n/// let xs = random_hash_sets_min_length(EXAMPLE_SEED, 2, &random_primitive_ints::<u8>, 6, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         hashset! {11, 85},\n///         hashset! {\n///             30, 32, 38, 90, 134, 136, 162, 166, 177, 200, 203, 217, 218, 223, 234, 235\n///         },\n///         hashset! {9, 106, 151, 204, 213, 216},\n///         hashset! {39, 78, 91, 97, 191, 253},\n///         hashset! {170, 175, 232},\n///         hashset! {2, 233},\n///         hashset! {17, 22, 32, 35, 114, 198, 217},\n///         hashset! {65, 114, 121, 173},\n///         hashset! {25, 79, 144, 148, 173, 222},\n///         hashset! {52, 115},\n///         hashset! {34, 69, 73, 91, 112, 137, 153, 178},\n///         hashset! {95, 106},\n///         hashset! {167, 197},\n///         hashset! {74, 86, 101, 115, 122, 130, 150, 168, 172, 177, 207, 218, 221},\n///         hashset! {9, 48, 52, 109, 123, 133, 159, 201, 247, 250},\n///         hashset! {196, 235},\n///         hashset! {40, 68, 97, 104, 190},\n///         hashset! {7, 216},\n///         hashset! {11, 24, 43, 112, 157, 216, 217},\n///         hashset! {29, 51, 55, 65, 84, 89, 103, 135, 191, 206, 211}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_hash_sets_min_length<I: Iterator>(\n    seed: Seed,\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomHashSets<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_hash_sets_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigned_inclusive_range(\n                seed_2,\n                min_length,\n                u64::MAX,\n                mean_length_numerator,\n                mean_length_denominator,\n            )\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`HashSet`]s with lengths in $[a, b)$, using elements from an iterator.\n///\n/// The lengths of the [`HashSet`]s are sampled from a uniform distribution on $[a, b)$. $a$ must be\n/// less than $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}, a, b) = \\frac{n!}{b - a}\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_hash_sets_length_range;\n/// use maplit::hashset;\n///\n/// let xs = random_hash_sets_length_range(EXAMPLE_SEED, 2, 5, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         hashset! {11, 85, 136},\n///         hashset! {134, 200, 203, 235},\n///         hashset! {38, 223, 235},\n///         hashset! {32, 162, 177, 217},\n///         hashset! {30, 166, 218, 234},\n///         hashset! {9, 90, 106},\n///         hashset! {204, 216},\n///         hashset! {97, 151, 213},\n///         hashset! {78, 253},\n///         hashset! {39, 91, 175, 191},\n///         hashset! {2, 170, 232, 233},\n///         hashset! {22, 35, 217},\n///         hashset! {17, 32, 114, 198},\n///         hashset! {65, 114, 173},\n///         hashset! {25, 121, 173, 222},\n///         hashset! {79, 115, 144, 148},\n///         hashset! {52, 69, 73, 137},\n///         hashset! {91, 153},\n///         hashset! {34, 95, 112, 178},\n///         hashset! {106, 167}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_hash_sets_length_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomHashSets<I::Item, RandomUnsignedRange<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_hash_sets_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n\n/// Generates random [`HashSet`]s with lengths in $[a, b]$, using elements from an iterator.\n///\n/// The lengths of the [`HashSet`]s are sampled from a uniform distribution on $[a, b)$. $a$ must be\n/// less than or equal to $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}, a, b) = \\frac{n!}{b - a + 1}\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_hash_sets_length_inclusive_range;\n/// use maplit::hashset;\n///\n/// let xs =\n///     random_hash_sets_length_inclusive_range(EXAMPLE_SEED, 2, 4, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         hashset! {11, 85, 136},\n///         hashset! {134, 200, 203, 235},\n///         hashset! {38, 223, 235},\n///         hashset! {32, 162, 177, 217},\n///         hashset! {30, 166, 218, 234},\n///         hashset! {9, 90, 106},\n///         hashset! {204, 216},\n///         hashset! {97, 151, 213},\n///         hashset! {78, 253},\n///         hashset! {39, 91, 175, 191},\n///         hashset! {2, 170, 232, 233},\n///         hashset! {22, 35, 217},\n///         hashset! {17, 32, 114, 198},\n///         hashset! {65, 114, 173},\n///         hashset! {25, 121, 173, 222},\n///         hashset! {79, 115, 144, 148},\n///         hashset! {52, 69, 73, 137},\n///         hashset! {91, 153},\n///         hashset! {34, 95, 112, 178},\n///         hashset! {106, 167}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_hash_sets_length_inclusive_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomHashSets<I::Item, RandomUnsignedInclusiveRange<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_hash_sets_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_inclusive_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n\n/// Generates random [`BTreeSet`]s of a fixed length, where the [`Vec`]s have no repeated elements,\n/// and the elements are in ascending order.\n///\n/// This `struct` is created by [`random_b_tree_sets_fixed_length`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomBTreeSetsFixedLength<I: Iterator>\nwhere\n    I::Item: Ord,\n{\n    len: usize,\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomBTreeSetsFixedLength<I>\nwhere\n    I::Item: Ord,\n{\n    type Item = BTreeSet<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<BTreeSet<I::Item>> {\n        let mut set = BTreeSet::new();\n        while set.len() < self.len {\n            set.insert(self.xs.next().unwrap());\n        }\n        Some(set)\n    }\n}\n\n/// Randomly generates [`BTreeSet`]s of a given length.\n///\n/// The input iterator must generate at least `len` distinct elements; otherwise, this iterator will\n/// hang.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// If `len` is 0, the output consists of the empty set, repeated.\n///\n/// `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_b_tree_sets_fixed_length;\n/// use maplit::btreeset;\n///\n/// let xss = random_b_tree_sets_fixed_length(\n///     2,\n///     random_unsigned_inclusive_range::<u32>(EXAMPLE_SEED, 1, 100),\n/// )\n/// .take(10)\n/// .collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[\n///         btreeset! {24, 95},\n///         btreeset! {71, 99},\n///         btreeset! {53, 93},\n///         btreeset! {34, 85},\n///         btreeset! {2, 48},\n///         btreeset! {11, 55},\n///         btreeset! {18, 48},\n///         btreeset! {90, 93},\n///         btreeset! {67, 93},\n///         btreeset! {93, 95}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_b_tree_sets_fixed_length<I: Iterator>(\n    len: u64,\n    xs: I,\n) -> RandomBTreeSetsFixedLength<I>\nwhere\n    I::Item: Ord,\n{\n    RandomBTreeSetsFixedLength {\n        len: usize::exact_from(len),\n        xs,\n    }\n}\n\n/// Generates random [`BTreeSet`]s with lengths from an iterator.\n#[derive(Clone, Debug)]\npub struct RandomBTreeSets<T: Ord, I: Iterator<Item = u64>, J: Iterator<Item = T>> {\n    lengths: I,\n    xs: J,\n}\n\nimpl<T: Ord, I: Iterator<Item = u64>, J: Iterator<Item = T>> Iterator for RandomBTreeSets<T, I, J> {\n    type Item = BTreeSet<T>;\n\n    fn next(&mut self) -> Option<BTreeSet<T>> {\n        let len = usize::exact_from(self.lengths.next().unwrap());\n        let mut set = BTreeSet::new();\n        while set.len() < len {\n            set.insert(self.xs.next().unwrap());\n        }\n        Some(set)\n    }\n}\n\n/// Generates random [`BTreeSet`]s using elements from an iterator and with lengths from another\n/// iterator.\n///\n/// The input iterator must generate at least many distinct elements as any number generated by the\n/// lengths iterator; otherwise, this iterator will hang.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P(n)\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `lengths` and `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_b_tree_sets_from_length_iterator;\n/// use malachite_base::vecs::random_values_from_vec;\n/// use maplit::btreeset;\n///\n/// let xs = random_b_tree_sets_from_length_iterator(\n///     EXAMPLE_SEED,\n///     &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n///     &random_primitive_ints::<u8>,\n/// );\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         btreeset! {11, 85},\n///         btreeset! {134, 136, 200, 235},\n///         btreeset! {203, 223},\n///         btreeset! {38, 177, 217, 235},\n///         btreeset! {32, 162, 166, 234},\n///         btreeset! {30, 218},\n///         btreeset! {},\n///         btreeset! {90, 106},\n///         btreeset! {},\n///         btreeset! {9, 151, 204, 216},\n///         btreeset! {78, 97, 213, 253},\n///         btreeset! {39, 91},\n///         btreeset! {170, 175, 191, 232},\n///         btreeset! {2, 233},\n///         btreeset! {22, 35, 198, 217},\n///         btreeset! {17, 32, 114, 173},\n///         btreeset! {65, 114, 121, 222},\n///         btreeset! {},\n///         btreeset! {25, 144, 148, 173},\n///         btreeset! {}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_b_tree_sets_from_length_iterator<\n    T: Ord,\n    I: Iterator<Item = u64>,\n    J: Iterator<Item = T>,\n>(\n    seed: Seed,\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n) -> RandomBTreeSets<T, I, J> {\n    RandomBTreeSets {\n        lengths: lengths_gen(seed.fork(\"lengths\")),\n        xs: xs_gen(seed.fork(\"xs\")),\n    }\n}\n\n/// Generates random [`BTreeSet`]s using elements from an iterator.\n///\n/// The lengths of the [`BTreeSet`]s are sampled from a geometric distribution with a specified mean\n/// $m$, equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P_g(n)\\prod\\_{i=0}^{n-1}P(x\\_i),\n/// $$\n/// where $P_g(n)$ is the probability function described in [`geometric_random_unsigneds`].\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_b_tree_sets;\n/// use maplit::btreeset;\n///\n/// let xs = random_b_tree_sets(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         btreeset! {},\n///         btreeset! {11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235},\n///         btreeset! {30, 90, 218, 234},\n///         btreeset! {9, 106, 204, 216},\n///         btreeset! {151},\n///         btreeset! {},\n///         btreeset! {78, 91, 97, 213, 253},\n///         btreeset! {39, 191},\n///         btreeset! {170, 175, 232, 233},\n///         btreeset! {},\n///         btreeset! {2, 22, 35, 114, 198, 217},\n///         btreeset! {},\n///         btreeset! {},\n///         btreeset! {17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222},\n///         btreeset! {52, 69, 73, 91, 115, 137, 153, 178},\n///         btreeset! {},\n///         btreeset! {34, 95, 112},\n///         btreeset! {},\n///         btreeset! {106, 130, 167, 168, 197},\n///         btreeset! {86, 101, 122, 150, 172, 177, 207, 218, 221}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_b_tree_sets<I: Iterator>(\n    seed: Seed,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomBTreeSets<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_b_tree_sets_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigneds(seed_2, mean_length_numerator, mean_length_denominator)\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`BTreeSet`]s with a minimum length, using elements from an iterator.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P_g(n)\\prod\\_{i=0}^{n-1}P(x\\_i),\n/// $$\n/// where $P_g(n)$ is the probability function described in\n/// [`geometric_random_unsigned_inclusive_range`], with $a$ equal to `min_length` and `b` to\n/// `u64::MAX`.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, if their ratio is less\n/// than or equal to `min_length`, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_b_tree_sets_min_length;\n/// use maplit::btreeset;\n///\n/// let xs = random_b_tree_sets_min_length(EXAMPLE_SEED, 2, &random_primitive_ints::<u8>, 6, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         btreeset! {11, 85},\n///         btreeset! {\n///             30, 32, 38, 90, 134, 136, 162, 166, 177, 200, 203, 217, 218, 223, 234, 235\n///         },\n///         btreeset! {9, 106, 151, 204, 213, 216},\n///         btreeset! {39, 78, 91, 97, 191, 253},\n///         btreeset! {170, 175, 232},\n///         btreeset! {2, 233},\n///         btreeset! {17, 22, 32, 35, 114, 198, 217},\n///         btreeset! {65, 114, 121, 173},\n///         btreeset! {25, 79, 144, 148, 173, 222},\n///         btreeset! {52, 115},\n///         btreeset! {34, 69, 73, 91, 112, 137, 153, 178},\n///         btreeset! {95, 106},\n///         btreeset! {167, 197},\n///         btreeset! {74, 86, 101, 115, 122, 130, 150, 168, 172, 177, 207, 218, 221},\n///         btreeset! {9, 48, 52, 109, 123, 133, 159, 201, 247, 250},\n///         btreeset! {196, 235},\n///         btreeset! {40, 68, 97, 104, 190},\n///         btreeset! {7, 216},\n///         btreeset! {11, 24, 43, 112, 157, 216, 217},\n///         btreeset! {29, 51, 55, 65, 84, 89, 103, 135, 191, 206, 211}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_b_tree_sets_min_length<I: Iterator>(\n    seed: Seed,\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomBTreeSets<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_b_tree_sets_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigned_inclusive_range(\n                seed_2,\n                min_length,\n                u64::MAX,\n                mean_length_numerator,\n                mean_length_denominator,\n            )\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`BTreeSet`]s with lengths in $[a, b]$, using elements from an iterator.\n///\n/// The lengths of the [`BTreeSet`]s are sampled from a uniform distribution on $[a, b)$. $a$ must\n/// be less than or equal to $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}, a, b) = \\frac{n!}{b - a + 1}\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_b_tree_sets_length_range;\n/// use maplit::btreeset;\n///\n/// let xs = random_b_tree_sets_length_range(EXAMPLE_SEED, 2, 5, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         btreeset! {11, 85, 136},\n///         btreeset! {134, 200, 203, 235},\n///         btreeset! {38, 223, 235},\n///         btreeset! {32, 162, 177, 217},\n///         btreeset! {30, 166, 218, 234},\n///         btreeset! {9, 90, 106},\n///         btreeset! {204, 216},\n///         btreeset! {97, 151, 213},\n///         btreeset! {78, 253},\n///         btreeset! {39, 91, 175, 191},\n///         btreeset! {2, 170, 232, 233},\n///         btreeset! {22, 35, 217},\n///         btreeset! {17, 32, 114, 198},\n///         btreeset! {65, 114, 173},\n///         btreeset! {25, 121, 173, 222},\n///         btreeset! {79, 115, 144, 148},\n///         btreeset! {52, 69, 73, 137},\n///         btreeset! {91, 153},\n///         btreeset! {34, 95, 112, 178},\n///         btreeset! {106, 167}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_b_tree_sets_length_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomBTreeSets<I::Item, RandomUnsignedRange<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_b_tree_sets_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n\n/// Generates random [`BTreeSet`]s with lengths in $[a, b]$, using elements from an iterator.\n///\n/// The lengths of the [`BTreeSet`]s are sampled from a uniform distribution on $[a, b)$. $a$ must\n/// be less than or equal to $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}, a, b) = \\frac{n!}{b - a + 1}\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::sets::random::random_b_tree_sets_length_inclusive_range;\n/// use maplit::btreeset;\n///\n/// let xs =\n///     random_b_tree_sets_length_inclusive_range(EXAMPLE_SEED, 2, 4, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values,\n///     &[\n///         btreeset! {11, 85, 136},\n///         btreeset! {134, 200, 203, 235},\n///         btreeset! {38, 223, 235},\n///         btreeset! {32, 162, 177, 217},\n///         btreeset! {30, 166, 218, 234},\n///         btreeset! {9, 90, 106},\n///         btreeset! {204, 216},\n///         btreeset! {97, 151, 213},\n///         btreeset! {78, 253},\n///         btreeset! {39, 91, 175, 191},\n///         btreeset! {2, 170, 232, 233},\n///         btreeset! {22, 35, 217},\n///         btreeset! {17, 32, 114, 198},\n///         btreeset! {65, 114, 173},\n///         btreeset! {25, 121, 173, 222},\n///         btreeset! {79, 115, 144, 148},\n///         btreeset! {52, 69, 73, 137},\n///         btreeset! {91, 153},\n///         btreeset! {34, 95, 112, 178},\n///         btreeset! {106, 167}\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_b_tree_sets_length_inclusive_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomBTreeSets<I::Item, RandomUnsignedInclusiveRange<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_b_tree_sets_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_inclusive_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n"
  },
  {
    "path": "malachite-base/src/slices/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1997, 1999-2016, 2009, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::DivisibleBy;\nuse crate::num::basic::traits::Zero;\n#[cfg(feature = \"random\")]\nuse crate::num::conversion::traits::ExactFrom;\n#[cfg(feature = \"random\")]\nuse crate::num::random::{RandomUnsignedsLessThan, random_unsigneds_less_than};\n#[cfg(feature = \"random\")]\nuse crate::random::Seed;\nuse alloc::vec::Vec;\n#[cfg(feature = \"random\")]\nuse rand::prelude::SliceRandom;\n#[cfg(feature = \"random\")]\nuse rand_chacha::ChaCha20Rng;\n\n/// Sets all values in a slice to 0.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::slices::slice_set_zero;\n///\n/// let mut xs = [1, 2, 3, 4, 5];\n/// slice_set_zero::<u32>(&mut xs[1..4]);\n/// assert_eq!(xs, [1, 0, 0, 0, 5]);\n/// ```\n///\n/// This is equivalent to `mpn_zero` from `mpn/generic/zero.c`, GMP 6.2.1. Note that this is needed\n/// less often in Malachite than in GMP, since Malachite generally initializes new memory with\n/// zeros.\npub fn slice_set_zero<T: Zero>(xs: &mut [T]) {\n    for x in &mut *xs {\n        *x = T::ZERO;\n    }\n}\n\n/// Tests whether all values in a slice are equal to 0.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::slices::slice_test_zero;\n///\n/// assert!(slice_test_zero::<u32>(&[0, 0, 0]));\n/// assert!(!slice_test_zero::<u32>(&[0, 1, 0]));\n/// ```\n///\n/// This is equivalent to `mpn_zero_p` from `gmp-h.in`, GMP 6.2.1.\npub fn slice_test_zero<T: Eq + Zero>(xs: &[T]) -> bool {\n    let zero = T::ZERO;\n    xs.iter().all(|x| x == &zero)\n}\n\n/// Counts the number of zeros that a slice starts with.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::slices::slice_leading_zeros;\n///\n/// assert_eq!(slice_leading_zeros::<u32>(&[1, 2, 3]), 0);\n/// assert_eq!(slice_leading_zeros::<u32>(&[0, 0, 0, 1, 2, 3]), 3);\n/// ```\npub fn slice_leading_zeros<T: Eq + Zero>(xs: &[T]) -> usize {\n    let zero = T::ZERO;\n    xs.iter().take_while(|&x| x == &zero).count()\n}\n\n/// Counts the number of zeros that a slice ends with.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::slices::slice_trailing_zeros;\n///\n/// assert_eq!(slice_trailing_zeros::<u32>(&[1, 2, 3]), 0);\n/// assert_eq!(slice_trailing_zeros::<u32>(&[1, 2, 3, 0, 0, 0]), 3);\n/// ```\npub fn slice_trailing_zeros<T: Eq + Zero>(xs: &[T]) -> usize {\n    let zero = T::ZERO;\n    xs.iter().rev().take_while(|&x| x == &zero).count()\n}\n\n/// Given a slice and an starting index, copies the subslice starting from that index to the\n/// beginning of the slice.\n///\n/// In other words, this function copies the contents of `&xs[starting_index..]` to `&xs[..xs.len()\n/// - starting_index]`.\n///\n/// In other other words, if $k$ is `starting_index`, the sequence $[x_0, x_1, \\ldots, x_{n-1}]$\n/// becomes $[x_k, x_{k+1}, \\ldots, x_{n-1}, x_{n-k}, x_{n-k+1}, \\ldots, x_{n-1}]$.\n///\n/// If `starting_index` is zero or `xs.len()`, nothing happens.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Panics\n/// Panics if `starting_index` is greater than the length of `xs`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::slices::slice_move_left;\n///\n/// let xs = &mut [1, 2, 3, 4, 5, 6];\n/// slice_move_left::<u32>(xs, 2);\n/// assert_eq!(xs, &[3, 4, 5, 6, 5, 6]);\n/// ```\n#[inline]\npub fn slice_move_left<T: Copy>(xs: &mut [T], starting_index: usize) {\n    xs.copy_within(starting_index..xs.len(), 0);\n}\n\n/// Splits an immutable slice into adjacent immutable chunks.\n///\n/// An input slice $\\mathbf{x}$, a chunk length $n$, and $k + 1$ output slice names $\\\\mathbf{x}_0,\n/// \\\\mathbf{x}_1, \\\\ldots, \\\\mathbf{x}_k$ are given. The last output slice name, $\\mathbf{x}_k$, is\n/// specified via a separate argument called `xs_last`.\n///\n/// The first $k$ output slice names are assigned adjacent length-$n$ chunks from $\\mathbf{x}$. If\n/// $|\\mathbf{x}| < kn$, the generated code panics.\n///\n/// The last slice, $\\mathbf{x}_k$, which is assigned to `xs_last`, has length $|\\mathbf{x}| - kn$.\n/// This length may be greater than $n$.\n///\n/// # Worst-case complexity\n/// $T(k) = O(k)$\n///\n/// $M(k) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $k$ is the number of output slice names `xs_i`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::split_into_chunks;\n///\n/// let xs = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];\n/// split_into_chunks!(xs, 3, [xs_1, xs_2, xs_3], xs_4);\n/// assert_eq!(xs_1, &[0, 1, 2]);\n/// assert_eq!(xs_2, &[3, 4, 5]);\n/// assert_eq!(xs_3, &[6, 7, 8]);\n/// assert_eq!(xs_4, &[9, 10, 11, 12]);\n/// ```\n#[macro_export]\nmacro_rules! split_into_chunks {\n    ($xs: expr, $n: expr, [$($xs_i: ident),*], $xs_last: ident) => {\n        let remainder = &$xs[..];\n        let n = $n;\n        $(\n            let ($xs_i, remainder) = remainder.split_at(n);\n        )*\n        let $xs_last = remainder;\n    }\n}\n\n/// Splits a mutable slice into adjacent mutable chunks.\n///\n/// An input slice $\\mathbf{x}$, a chunk length $n$, and $k + 1$ output slice names $\\\\mathbf{x}_0,\n/// \\\\mathbf{x}_1, \\\\ldots, \\\\mathbf{x}_k$ are given. The last output slice name, $\\mathbf{x}_k$, is\n/// specified via a separate argument called `xs_last`.\n///\n/// The first $k$ output slice names are assigned adjacent length-$n$ chunks from $\\mathbf{x}$. If\n/// $|\\mathbf{x}| < kn$, the generated code panics.\n///\n/// The last slice, $\\mathbf{x}_k$, which is assigned to `xs_last`, has length $|\\mathbf{x}| - kn$.\n/// This length may be greater than $n$.\n///\n/// # Worst-case complexity\n/// $T(k) = O(k)$\n///\n/// $M(k) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $k$ is the number of output slice names `xs_i`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::slices::slice_set_zero;\n/// use malachite_base::split_into_chunks_mut;\n///\n/// let xs = &mut [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];\n/// split_into_chunks_mut!(xs, 3, [xs_1, xs_2, xs_3], xs_4);\n/// assert_eq!(xs_1, &[0, 1, 2]);\n/// assert_eq!(xs_2, &[3, 4, 5]);\n/// assert_eq!(xs_3, &[6, 7, 8]);\n/// assert_eq!(xs_4, &[9, 10, 11, 12]);\n///\n/// slice_set_zero(xs_2);\n/// assert_eq!(xs, &[0, 1, 2, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12]);\n/// ```\n#[macro_export]\nmacro_rules! split_into_chunks_mut {\n    ($xs: expr, $n: expr, [$($xs_i: ident),*], $xs_last: ident) => {\n        let remainder = &mut $xs[..];\n        let n = $n;\n        $(\n            let ($xs_i, remainder) = remainder.split_at_mut(n);\n        )*\n        let $xs_last = remainder;\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random reference to a value from a nonempty slice.\n///\n/// This `struct` is created by [`random_values_from_slice`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomValuesFromSlice<'a, T> {\n    xs: &'a [T],\n    indices: RandomUnsignedsLessThan<u64>,\n}\n\n#[cfg(feature = \"random\")]\nimpl<'a, T> Iterator for RandomValuesFromSlice<'a, T> {\n    type Item = &'a T;\n\n    #[inline]\n    fn next(&mut self) -> Option<&'a T> {\n        Some(&self.xs[usize::exact_from(self.indices.next().unwrap())])\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random reference to a value from a nonempty slice.\n///\n/// The iterator cannot outlive the slice. It may be more convenient for the iterator to own the\n/// data, in which case you may use [`random_values_from_vec`](crate::vecs::random_values_from_vec)\n/// instead.\n///\n/// The output length is infinite.\n///\n/// $P(x) = 1/n$, where $n$ is `xs.len()`.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Panics\n/// Panics if `xs` is empty.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::slices::random_values_from_slice;\n///\n/// let xs = &[2, 3, 5, 7, 11];\n/// assert_eq!(\n///     random_values_from_slice(EXAMPLE_SEED, xs)\n///         .cloned()\n///         .take(10)\n///         .collect_vec(),\n///     &[3, 7, 3, 5, 11, 3, 5, 11, 2, 2]\n/// );\n/// ```\n#[inline]\npub fn random_values_from_slice<T>(seed: Seed, xs: &[T]) -> RandomValuesFromSlice<'_, T> {\n    assert!(!xs.is_empty(), \"empty slice\");\n    RandomValuesFromSlice {\n        xs,\n        indices: random_unsigneds_less_than(seed, u64::exact_from(xs.len())),\n    }\n}\n\npub(crate) fn advance_indices(indices: &mut [usize]) -> bool {\n    let n = indices.len();\n    if n == 0 {\n        return true;\n    }\n    // Find the index of the value right before the longest descending suffix.\n    let mut pivot_index = n;\n    let mut i = 0;\n    let mut reached_end = true;\n    while pivot_index > 0 {\n        pivot_index -= 1;\n        let next_i = indices[pivot_index];\n        if next_i < i {\n            reached_end = false;\n            break;\n        }\n        i = next_i;\n    }\n    if reached_end {\n        return true;\n    }\n    let pivot = indices[pivot_index];\n    let mut swap_index = n - 1;\n    while indices[swap_index] < pivot {\n        swap_index -= 1;\n    }\n    indices.swap(pivot_index, swap_index);\n    indices[pivot_index + 1..].reverse();\n    false\n}\n\n/// Generates every permutation of a slice.\n///\n/// This `struct` is created by [`exhaustive_slice_permutations`]; see its documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct ExhaustiveSlicePermutations<'a, T> {\n    xs: &'a [T],\n    indices: Vec<usize>,\n    done: bool,\n}\n\nimpl<'a, T> Iterator for ExhaustiveSlicePermutations<'a, T> {\n    type Item = Vec<&'a T>;\n\n    fn next(&mut self) -> Option<Vec<&'a T>> {\n        if self.done {\n            None\n        } else {\n            let out = Some(self.indices.iter().map(|&i| &self.xs[i]).collect());\n            self.done = advance_indices(&mut self.indices);\n            out\n        }\n    }\n}\n\n/// Generates every permutation of a slice.\n///\n/// The permutations are [`Vec`]s of references into the slice. It may be more convenient for the\n/// iterator to own the data, in which case you may use\n/// [`exhaustive_vec_permutations`](crate::vecs::exhaustive_vec_permutations) instead.\n///\n/// The permutations are generated in lexicographic order with respect to the ordering in the slice.\n///\n/// The output length is $n!$, where $n$ is `xs.len()`.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::slices::exhaustive_slice_permutations;\n///\n/// let css: Vec<String> = exhaustive_slice_permutations(&['a', 'b', 'c', 'd'])\n///     .map(|ds| ds.into_iter().copied().collect())\n///     .collect();\n/// assert_eq!(\n///     css.iter().map(String::as_str).collect_vec().as_slice(),\n///     [\n///         \"abcd\", \"abdc\", \"acbd\", \"acdb\", \"adbc\", \"adcb\", \"bacd\", \"badc\", \"bcad\", \"bcda\", \"bdac\",\n///         \"bdca\", \"cabd\", \"cadb\", \"cbad\", \"cbda\", \"cdab\", \"cdba\", \"dabc\", \"dacb\", \"dbac\", \"dbca\",\n///         \"dcab\", \"dcba\"\n///     ]\n/// );\n/// ```\npub fn exhaustive_slice_permutations<T>(xs: &[T]) -> ExhaustiveSlicePermutations<'_, T> {\n    ExhaustiveSlicePermutations {\n        xs,\n        indices: (0..xs.len()).collect(),\n        done: false,\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random permutation of references to a slice.\n///\n/// This `struct` is created by [`random_slice_permutations`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomSlicePermutations<'a, T> {\n    xs: &'a [T],\n    indices: Vec<usize>,\n    rng: ChaCha20Rng,\n}\n\n#[cfg(feature = \"random\")]\nimpl<'a, T> Iterator for RandomSlicePermutations<'a, T> {\n    type Item = Vec<&'a T>;\n\n    fn next(&mut self) -> Option<Vec<&'a T>> {\n        self.indices.shuffle(&mut self.rng);\n        Some(self.indices.iter().map(|&i| &self.xs[i]).collect())\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random permutation of references to a slice.\n///\n/// The iterator cannot outlive the slice. It may be more convenient for the iterator to own the\n/// data, in which case you may use\n/// [`random_vec_permutations`](crate::vecs::random_vec_permutations) instead.\n///\n/// The output length is infinite.\n///\n/// $P(p) = 1/n!$, where $n$ is `xs.len()`.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::slices::random_slice_permutations;\n///\n/// let css: Vec<String> = random_slice_permutations(EXAMPLE_SEED, &['a', 'b', 'c', 'd'])\n///     .take(20)\n///     .map(|ds| ds.into_iter().copied().collect())\n///     .collect();\n/// assert_eq!(\n///     css.iter().map(String::as_str).collect_vec().as_slice(),\n///     [\n///         \"dacb\", \"cbad\", \"cdab\", \"cbad\", \"cdab\", \"bcda\", \"bcda\", \"acbd\", \"bcda\", \"dbca\", \"bdac\",\n///         \"dbac\", \"dbca\", \"bcad\", \"cadb\", \"dacb\", \"acbd\", \"dbac\", \"bdca\", \"abdc\"\n///     ]\n/// );\n/// ```\npub fn random_slice_permutations<T>(seed: Seed, xs: &[T]) -> RandomSlicePermutations<'_, T> {\n    RandomSlicePermutations {\n        xs,\n        indices: (0..xs.len()).collect(),\n        rng: seed.get_rng(),\n    }\n}\n\n/// Given a slice with nonzero length $\\ell$, returns the smallest $n$ such that the slice consists\n/// of $n/\\ell$ copies of a length-$\\ell$ subslice.\n///\n/// Typically $\\ell = n$.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n^{1+\\varepsilon})$ for all $\\varepsilon > 0$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n///\n/// # Panics\n/// Panics if `xs` is empty.\n///\n/// # Examples\n/// ```\n/// use malachite_base::slices::min_repeating_len;\n///\n/// assert_eq!(min_repeating_len(&[1, 2, 1, 2, 1, 2]), 2);\n/// assert_eq!(min_repeating_len(&[1, 2, 1, 2, 1, 3]), 6);\n/// assert_eq!(min_repeating_len(&[5, 5, 5]), 1);\n/// ```\npub fn min_repeating_len<T: Eq>(xs: &[T]) -> usize {\n    let len = xs.len();\n    assert_ne!(len, 0);\n    for start_i in 1..=len >> 1 {\n        if !len.divisible_by(start_i) {\n            continue;\n        }\n        let (xs_lo, xs_hi) = xs.split_at(start_i);\n        if Iterator::eq(xs_lo.iter().cycle().take(len - start_i), xs_hi.iter()) {\n            return start_i;\n        }\n    }\n    len\n}\n"
  },
  {
    "path": "malachite-base/src/strings/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::chars::exhaustive::{ExhaustiveChars, exhaustive_chars};\nuse crate::num::exhaustive::PrimitiveIntIncreasingRange;\nuse crate::strings::{StringsFromCharVecs, strings_from_char_vecs};\nuse crate::vecs::exhaustive::{\n    ExhaustiveFixedLengthVecs1Input, ExhaustiveVecs, LexFixedLengthVecsFromSingle, ShortlexVecs,\n    exhaustive_vecs, exhaustive_vecs_fixed_length_from_single, lex_vecs_fixed_length_from_single,\n    shortlex_vecs,\n};\n\n/// Generates all [`String`]s of a given length with [`char`]s from a single iterator, in\n/// lexicographic order.\n///\n/// The order is lexicographic with respect to the order of the element iterator.\n///\n/// `cs` must be finite.\n///\n/// The output length is $\\ell^n$, where $\\ell$ is `cs.count()` and $n$ is `len`.\n///\n/// If `len` is 0, the output consists of one empty [`String`].\n///\n/// If `cs` is empty, the output is also empty, unless `len` is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::lex_fixed_length_strings_using_chars;\n///\n/// let ss = lex_fixed_length_strings_using_chars(2, ['c', 'a', 't'].iter().cloned()).collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\"cc\", \"ca\", \"ct\", \"ac\", \"aa\", \"at\", \"tc\", \"ta\", \"tt\"]\n/// );\n/// ```\n#[inline]\npub fn lex_fixed_length_strings_using_chars<I: Iterator<Item = char>>(\n    len: u64,\n    cs: I,\n) -> StringsFromCharVecs<LexFixedLengthVecsFromSingle<I>> {\n    strings_from_char_vecs(lex_vecs_fixed_length_from_single(len, cs))\n}\n\n/// Generates all [`String`]s of a given length in lexicographic order.\n///\n/// The order is lexicographic with respect to the order of [`exhaustive_chars`], which is not the\n/// default lexicographic order for [`char`]s. (For example, the first characters are not control\n/// characters, but lowercase Latin letters.) If you want the default [`char`] order, use\n/// `lex_fixed_length_strings_using_chars(len, chars_increasing())`.\n///\n/// The output length is $1112064^n$, where $n$ is `len`.\n///\n/// If `len` is 0, the output consists of one empty [`String`].\n///\n/// # Complexity per iteration\n/// $T(i, n) = O(n)$\n///\n/// $M(i, n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `len`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::lex_fixed_length_strings;\n///\n/// let ss = lex_fixed_length_strings(2).take(20).collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\n///         \"aa\", \"ab\", \"ac\", \"ad\", \"ae\", \"af\", \"ag\", \"ah\", \"ai\", \"aj\", \"ak\", \"al\", \"am\", \"an\",\n///         \"ao\", \"ap\", \"aq\", \"ar\", \"as\", \"at\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_fixed_length_strings(\n    len: u64,\n) -> StringsFromCharVecs<LexFixedLengthVecsFromSingle<ExhaustiveChars>> {\n    lex_fixed_length_strings_using_chars(len, exhaustive_chars())\n}\n\n/// Generates all `String`s of a given length with [`char`]s from a single iterator.\n///\n/// If `cs` is finite, the output length is $\\ell^n$, where $\\ell$ is `cs.count()` and $n$ is `len`.\n/// If `cs` is infinite, the output is also infinite.\n///\n/// If `len` is 0, the output consists of one empty [`String`].\n///\n/// If `cs` is empty, the output is also empty, unless `len` is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::exhaustive_fixed_length_strings_using_chars;\n///\n/// let ss = exhaustive_fixed_length_strings_using_chars(2, ['c', 'a', 't'].iter().cloned())\n///     .collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\"cc\", \"ca\", \"ac\", \"aa\", \"ct\", \"at\", \"tc\", \"ta\", \"tt\"]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_fixed_length_strings_using_chars<I: Iterator<Item = char>>(\n    len: u64,\n    cs: I,\n) -> StringsFromCharVecs<ExhaustiveFixedLengthVecs1Input<I>> {\n    strings_from_char_vecs(exhaustive_vecs_fixed_length_from_single(len, cs))\n}\n\n/// Generates all [`String`]s of a given length.\n///\n/// The output length is $1112064^n$, where $n$ is `len`.\n///\n/// If `len` is 0, the output consists of one empty [`String`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::exhaustive_fixed_length_strings;\n///\n/// let ss = exhaustive_fixed_length_strings(2).take(20).collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\n///         \"aa\", \"ab\", \"ba\", \"bb\", \"ac\", \"ad\", \"bc\", \"bd\", \"ca\", \"cb\", \"da\", \"db\", \"cc\", \"cd\",\n///         \"dc\", \"dd\", \"ae\", \"af\", \"be\", \"bf\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_fixed_length_strings(\n    len: u64,\n) -> StringsFromCharVecs<ExhaustiveFixedLengthVecs1Input<ExhaustiveChars>> {\n    exhaustive_fixed_length_strings_using_chars(len, exhaustive_chars())\n}\n\n/// Generates [`String`]s with [`char`]s from a specified iterator, in shortlex order.\n///\n/// Shortlex order means that the [`String`]s are output from shortest to longest, and [`String`]s\n/// of the same length are output in lexicographic order with respect to the ordering of the\n/// [`char`]s specified by the input iterator.\n///\n/// `cs` must be finite; if it's infinite, only [`String`]s of length 0 and 1 are ever produced.\n///\n/// If `cs` is empty, the output length is 1; otherwise, the output is infinite.\n///\n/// The lengths of the output [`String`]s grow logarithmically.\n///\n/// # Complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::shortlex_strings_using_chars;\n///\n/// let ss = shortlex_strings_using_chars('x'..='z')\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     ss.iter().map(String::as_str).collect_vec().as_slice(),\n///     &[\n///         \"\", \"x\", \"y\", \"z\", \"xx\", \"xy\", \"xz\", \"yx\", \"yy\", \"yz\", \"zx\", \"zy\", \"zz\", \"xxx\", \"xxy\",\n///         \"xxz\", \"xyx\", \"xyy\", \"xyz\", \"xzx\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_strings_using_chars<I: Clone + Iterator<Item = char>>(\n    cs: I,\n) -> StringsFromCharVecs<ShortlexVecs<char, PrimitiveIntIncreasingRange<u64>, I>> {\n    strings_from_char_vecs(shortlex_vecs(cs))\n}\n\n/// Generates [`String`]s in shortlex order.\n///\n/// Shortlex order means that the [`String`]s are output from shortest to longest, and [`String`]s\n/// of the same length are output in lexicographic order with respect to the order of\n/// [`exhaustive_chars`], which is not the default lexicographic order for [`char`]s. (For example,\n/// the first characters are not control characters, but lowercase Latin letters.) If you want the\n/// default [`char`] order, use `shortlex_strings_using_chars(chars_increasing())`.\n///\n/// The output is infinite.\n///\n/// The lengths of the output [`String`]s grow logarithmically.\n///\n/// # Complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::shortlex_strings;\n///\n/// let ss = shortlex_strings().take(20).collect_vec();\n/// assert_eq!(\n///     ss.iter().map(String::as_str).collect_vec().as_slice(),\n///     &[\n///         \"\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\",\n///         \"q\", \"r\", \"s\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_strings()\n-> StringsFromCharVecs<ShortlexVecs<char, PrimitiveIntIncreasingRange<u64>, ExhaustiveChars>> {\n    shortlex_strings_using_chars(exhaustive_chars())\n}\n\n/// Generates all [`String`]s with [`char`]s from a specified iterator.\n///\n/// If `cs` is empty, the output length is 1; otherwise, the output is infinite.\n///\n/// The lengths of the output [`String`]s grow logarithmically.\n///\n/// # Complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::exhaustive_strings_using_chars;\n///\n/// let ss = exhaustive_strings_using_chars('x'..='z')\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     ss.iter().map(String::as_str).collect_vec().as_slice(),\n///     &[\n///         \"\", \"x\", \"y\", \"xxx\", \"z\", \"xx\", \"xy\", \"xxxxx\", \"yx\", \"xxy\", \"yy\", \"xxxx\", \"xz\", \"xyx\",\n///         \"yz\", \"xxxxxx\", \"zx\", \"xyy\", \"zy\", \"xxxy\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_strings_using_chars<I: Clone + Iterator<Item = char>>(\n    cs: I,\n) -> StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, I>> {\n    strings_from_char_vecs(exhaustive_vecs(cs))\n}\n\n/// Generates all [`String`]s.\n///\n/// The lengths of the output [`String`]s grow logarithmically.\n///\n/// # Complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time and $M$ is additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::exhaustive::exhaustive_strings;\n///\n/// let ss = exhaustive_strings().take(20).collect_vec();\n/// assert_eq!(\n///     ss.iter().map(String::as_str).collect_vec().as_slice(),\n///     &[\n///         \"\", \"a\", \"b\", \"aaa\", \"c\", \"aa\", \"d\", \"aaaa\", \"e\", \"ab\", \"f\", \"aab\", \"g\", \"ba\", \"h\",\n///         \"aaaaa\", \"i\", \"bb\", \"j\", \"aba\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_strings()\n-> StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, ExhaustiveChars>> {\n    exhaustive_strings_using_chars(exhaustive_chars())\n}\n"
  },
  {
    "path": "malachite-base/src/strings/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::named::Named;\nuse alloc::string::String;\nuse alloc::vec::Vec;\nuse core::fmt::{Binary, Debug, LowerHex, Octal, UpperHex};\nuse hashbrown::HashSet;\nuse itertools::Itertools;\n\n/// Sorts the characters of a string slice and returns them in a new [`String`].\n///\n/// # Worst-case complexity\n/// $T(n) = O(n \\log n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::strings::string_sort;\n///\n/// assert_eq!(string_sort(\"Hello, world!\"), \" !,Hdellloorw\");\n/// assert_eq!(string_sort(\"Mississippi\"), \"Miiiippssss\");\n/// ```\npub fn string_sort(s: &str) -> String {\n    let mut chars = s.chars().collect_vec();\n    chars.sort_unstable();\n    chars.iter().collect()\n}\n\n/// Takes a string slice's unique characters and returns them in a new [`String`].\n///\n/// The unique characters are output in order of appearance.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::strings::string_unique;\n///\n/// assert_eq!(string_unique(\"Hello, world!\"), \"Helo, wrd!\");\n/// assert_eq!(string_unique(\"Mississippi\"), \"Misp\");\n/// ```\npub fn string_unique(s: &str) -> String {\n    let mut chars = HashSet::new();\n    let mut nub = String::new();\n    for c in s.chars() {\n        if chars.insert(c) {\n            nub.push(c);\n        }\n    }\n    nub\n}\n\n/// Returns whether all of the first string slice's characters are present in the second string\n/// slice.\n///\n/// Does not take multiplicities into account.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n + m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `s.len()`, and $m$ is `t.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::strings::string_is_subset;\n///\n/// assert_eq!(string_is_subset(\"oH, well\", \"Hello, world!\"), true);\n/// assert_eq!(string_is_subset(\"MMM\", \"Mississippi\"), true);\n/// assert_eq!(string_is_subset(\"Hello, World!\", \"Hello, world!\"), false);\n/// assert_eq!(string_is_subset(\"j\", \"Mississippi\"), false);\n/// ```\npub fn string_is_subset(s: &str, t: &str) -> bool {\n    let t_chars: HashSet<char> = t.chars().collect();\n    s.chars().all(|c| t_chars.contains(&c))\n}\n\nimpl_named!(String);\n\n/// A trait that provides an ergonomic way to create the string specified by a [`Debug`]\n/// implementation.\npub trait ToDebugString: Debug {\n    fn to_debug_string(&self) -> String;\n}\n\nimpl<T: Debug> ToDebugString for T {\n    /// Returns the [`String`] produced by `T`s [`Debug`] implementation.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    ///\n    /// assert_eq!([1, 2, 3].to_debug_string(), \"[1, 2, 3]\");\n    /// assert_eq!(\n    ///     [vec![2, 3], vec![], vec![4]].to_debug_string(),\n    ///     \"[[2, 3], [], [4]]\"\n    /// );\n    /// assert_eq!(Some(5).to_debug_string(), \"Some(5)\");\n    /// ```\n    #[inline]\n    fn to_debug_string(&self) -> String {\n        ::alloc::format!(\"{self:?}\")\n    }\n}\n\n/// A trait that provides an ergonomic way to create the string specified by a [`Binary`]\n/// implementation.\npub trait ToBinaryString: Binary {\n    fn to_binary_string(&self) -> String;\n}\n\nimpl<T: Binary> ToBinaryString for T {\n    /// Returns the [`String`] produced by `T`s [`Binary`] implementation.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToBinaryString;\n    ///\n    /// assert_eq!(5u64.to_binary_string(), \"101\");\n    /// assert_eq!((-100i16).to_binary_string(), \"1111111110011100\");\n    /// ```\n    #[inline]\n    fn to_binary_string(&self) -> String {\n        ::alloc::format!(\"{self:b}\")\n    }\n}\n\n/// A trait that provides an ergonomic way to create the string specified by an [`Octal`]\n/// implementation.\npub trait ToOctalString: Octal {\n    fn to_octal_string(&self) -> String;\n}\n\nimpl<T: Octal> ToOctalString for T {\n    /// Returns the [`String`] produced by `T`s [`Octal`] implementation.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToOctalString;\n    ///\n    /// assert_eq!(50u64.to_octal_string(), \"62\");\n    /// assert_eq!((-100i16).to_octal_string(), \"177634\");\n    /// ```\n    #[inline]\n    fn to_octal_string(&self) -> String {\n        ::alloc::format!(\"{self:o}\")\n    }\n}\n\n/// A trait that provides an ergonomic way to create the string specified by a [`LowerHex`]\n/// implementation.\npub trait ToLowerHexString: LowerHex {\n    fn to_lower_hex_string(&self) -> String;\n}\n\nimpl<T: LowerHex> ToLowerHexString for T {\n    /// Returns the [`String`] produced by `T`s [`LowerHex`] implementation.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToLowerHexString;\n    ///\n    /// assert_eq!(50u64.to_lower_hex_string(), \"32\");\n    /// assert_eq!((-100i16).to_lower_hex_string(), \"ff9c\");\n    /// ```\n    #[inline]\n    fn to_lower_hex_string(&self) -> String {\n        ::alloc::format!(\"{self:x}\")\n    }\n}\n\n/// A trait that provides an ergonomic way to create the string specified by an [`UpperHex`]\n/// implementation.\npub trait ToUpperHexString: UpperHex {\n    fn to_upper_hex_string(&self) -> String;\n}\n\nimpl<T: UpperHex> ToUpperHexString for T {\n    /// Returns the [`String`] produced by `T`s [`UpperHex`] implementation.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToUpperHexString;\n    ///\n    /// assert_eq!(50u64.to_upper_hex_string(), \"32\");\n    /// assert_eq!((-100i16).to_upper_hex_string(), \"FF9C\");\n    /// ```\n    #[inline]\n    fn to_upper_hex_string(&self) -> String {\n        ::alloc::format!(\"{self:X}\")\n    }\n}\n\n/// Generates [`String`]s, given an iterator that generates `Vec<char>`s.\n///\n/// This `struct` is created by [`strings_from_char_vecs`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct StringsFromCharVecs<I: Iterator<Item = Vec<char>>> {\n    css: I,\n}\n\nimpl<I: Iterator<Item = Vec<char>>> Iterator for StringsFromCharVecs<I> {\n    type Item = String;\n\n    #[inline]\n    fn next(&mut self) -> Option<String> {\n        self.css.next().map(|cs| cs.into_iter().collect())\n    }\n}\n\n/// Generates [`String`]s, given an iterator that generates `Vec<char>`s.\n///\n/// The elements appear in the same order as they do in the given iterator, but as [`String`]s.\n///\n/// The output length is `css.count()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::strings_from_char_vecs;\n///\n/// let ss =\n///     &strings_from_char_vecs([vec!['a', 'b'], vec!['c', 'd']].iter().cloned()).collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\"ab\", \"cd\"]\n/// );\n/// ```\n#[inline]\npub const fn strings_from_char_vecs<I: Iterator<Item = Vec<char>>>(\n    css: I,\n) -> StringsFromCharVecs<I> {\n    StringsFromCharVecs { css }\n}\n\n/// Iterators that generate [`String`]s without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`String`]s randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/strings/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::chars::random::{RandomCharRange, random_chars};\nuse crate::num::random::geometric::GeometricRandomNaturalValues;\nuse crate::random::Seed;\nuse crate::strings::StringsFromCharVecs;\nuse crate::vecs::random::{\n    RandomFixedLengthVecsFromSingle, RandomVecs, random_vecs, random_vecs_fixed_length_from_single,\n};\n\n/// Randomly generates [`String`]s of a given length using [`char`]s from a single iterator.\n///\n/// The probability of a particular length-$n$ [`String`] being generated is the product of the\n/// probabilities of each of its `char`s.\n///\n/// If `len` is 0, the output consists of the empty [`String`], repeated.\n///\n/// `cs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::random::random_char_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::random::random_fixed_length_strings_using_chars;\n///\n/// let ss = random_fixed_length_strings_using_chars(\n///     2,\n///     random_char_inclusive_range(EXAMPLE_SEED, 'a', 'c'),\n/// )\n/// .take(10)\n/// .collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\"ba\", \"bc\", \"bb\", \"ab\", \"ac\", \"ba\", \"bc\", \"ca\", \"ba\", \"cc\"]\n/// );\n/// ```\n#[inline]\npub const fn random_fixed_length_strings_using_chars<I: Iterator<Item = char>>(\n    len: u64,\n    cs: I,\n) -> StringsFromCharVecs<RandomFixedLengthVecsFromSingle<I>> {\n    StringsFromCharVecs {\n        css: random_vecs_fixed_length_from_single(len, cs),\n    }\n}\n\n/// Randomly generates [`String`]s of a given length.\n///\n/// The probability of a particular length-$n$ [`String`] being generated is $1112064^{-\\ell}$,\n/// where $\\ell$ is `len`.\n///\n/// If `len` is 0, the output consists of the empty [`String`], repeated.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `len`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::random::random_fixed_length_strings;\n///\n/// let ss = random_fixed_length_strings(EXAMPLE_SEED, 2)\n///     .take(10)\n///     .collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\n///         \"\\u{5f771}\\u{87234}\",\n///         \"\\u{bcd36}\\u{9e195}\",\n///         \"\\u{5da07}\\u{36553}\",\n///         \"\\u{45028}\\u{1cdfd}\",\n///         \"\\u{d8530}\\u{c7f2e}\",\n///         \"\\u{ba4bc}\\u{ff677}\",\n///         \"\\u{a12e2}\\u{d775c}\",\n///         \"\\u{f827b}\\u{bdf7a}\",\n///         \"簅\\u{15aca}\",\n///         \"\\u{4e5e2}\\u{bb286}\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_fixed_length_strings(\n    seed: Seed,\n    len: u64,\n) -> StringsFromCharVecs<RandomFixedLengthVecsFromSingle<RandomCharRange>> {\n    random_fixed_length_strings_using_chars(len, random_chars(seed))\n}\n\n/// Generates random [`String`]s using [`char`]s from an iterator.\n///\n/// The lengths of the [`String`]s are sampled from a geometric distribution with a specified mean\n/// $m$, equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// $$\n/// P((c_0, c_1, \\ldots, c_{n-1})) = \\frac{m^n}{(m+1)^{n+1}}\\prod_{i=0}^{n-1}P(c_i).\n/// $$\n///\n/// The iterators produced by `cs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::random::random_char_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::random::random_strings_using_chars;\n///\n/// let ss = random_strings_using_chars(\n///     EXAMPLE_SEED,\n///     &|seed| random_char_inclusive_range(seed, 'x', 'z'),\n///     4,\n///     1,\n/// )\n/// .take(10)\n/// .collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\"\", \"yyyyzxxxzxzxzx\", \"zzzy\", \"xzzx\", \"y\", \"\", \"zyzxz\", \"zy\", \"zyyx\", \"\"]\n/// );\n/// ```\n#[inline]\npub fn random_strings_using_chars<I: Iterator<Item = char>>(\n    seed: Seed,\n    cs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> StringsFromCharVecs<RandomVecs<char, GeometricRandomNaturalValues<u64>, I>> {\n    StringsFromCharVecs {\n        css: random_vecs(seed, cs_gen, mean_length_numerator, mean_length_denominator),\n    }\n}\n\n/// Generates random [`String`]s.\n///\n/// The lengths of the [`String`]s are sampled from a geometric distribution with a specified mean\n/// $m$, equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// $$\n/// P((c_0, c_1, \\ldots, c_{n-1})) = \\frac{m^n}{1112064^n(m+1)^{n+1}}\n/// $$\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(m)$\n///\n/// $M(n) = O(m)$\n///\n/// where $T$ is time, $M$ is additional memory, and $m$ is `mean_length_numerator /\n/// mean_length_denominator`.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::random::random_strings;\n///\n/// let ss = random_strings(EXAMPLE_SEED, 4, 1).take(10).collect_vec();\n/// assert_eq!(\n///     ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),\n///     &[\n///         \"\",\n///         \"\\u{81355}\\u{a331d}\\u{b707b}\\u{1354b}\\u{b16ac}𣙘\\u{67377}\\u{4aaa4}\\u{a6d6e}\\u{45616}\\\n///         \\u{7725f}\\u{41e2d}\\u{d6b59}\\u{de165}\",\n///         \"\\u{c2d29}\\u{695af}\\u{98fd7}\\u{10ca51}\",\n///         \"\\u{bec46}\\u{c0bec}\\u{cb677}\\u{71318}\",\n///         \"\\u{755e1}\",\n///         \"\",\n///         \"𫮜\\u{a2f84}柂\\u{f5560}\\u{6737b}\",\n///         \"\\u{8442e}\\u{a6883}\",\n///         \"\\u{49cf2}\\u{32d2b}\\u{1e6e5}\\u{1084bd}\",\n///         \"\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_strings(\n    seed: Seed,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> StringsFromCharVecs<RandomVecs<char, GeometricRandomNaturalValues<u64>, RandomCharRange>> {\n    random_strings_using_chars(\n        seed,\n        &random_chars,\n        mean_length_numerator,\n        mean_length_denominator,\n    )\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/bench/bucketers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::chars::crement::char_to_contiguous_range;\nuse crate::max;\nuse crate::num::arithmetic::traits::UnsignedAbs;\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::logic::traits::SignificantBits;\nuse crate::rational_sequences::RationalSequence;\nuse std::cmp::{max, min};\n\npub struct Bucketer<'a, T> {\n    pub bucketing_function: &'a dyn Fn(&T) -> usize,\n    pub bucketing_label: String,\n}\n\npub fn char_bucketer<'a>() -> Bucketer<'a, char> {\n    Bucketer {\n        bucketing_function: &|&c| usize::exact_from(char_to_contiguous_range(c)),\n        bucketing_label: \"char_to_contiguous_range(c)\".to_string(),\n    }\n}\n\npub fn float_size<T: PrimitiveFloat>(f: T) -> usize {\n    if f == T::ZERO || !f.is_finite() || f.is_nan() {\n        0\n    } else {\n        let (m, e) = f.integer_mantissa_and_exponent();\n        usize::exact_from(m.significant_bits()) + usize::wrapping_from(e.abs())\n    }\n}\n\npub fn primitive_float_bucketer<'a, T: PrimitiveFloat>(var_name: &str) -> Bucketer<'a, T> {\n    Bucketer {\n        bucketing_function: &|&f| float_size(f),\n        bucketing_label: format!(\"precision({var_name}) + |exponent({var_name})|\"),\n    }\n}\n\npub fn pair_1_primitive_float_bucketer<'a, T: PrimitiveFloat, U>(\n    var_name: &str,\n) -> Bucketer<'a, (T, U)> {\n    Bucketer {\n        bucketing_function: &|&(f, _)| float_size(f),\n        bucketing_label: format!(\"precision({var_name}) + |exponent({var_name})|\"),\n    }\n}\n\npub fn pair_max_primitive_float_bucketer<'a, T: PrimitiveFloat>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, T)> {\n    Bucketer {\n        bucketing_function: &|&(f, g)| max(float_size(f), float_size(g)),\n        bucketing_label: format!(\n            \"max(precision({x_name}) + |exponent({x_name})|, \\\n            precision({y_name}) + |exponent({y_name})|)\"\n        ),\n    }\n}\n\npub fn triple_1_primitive_float_bucketer<'a, T: PrimitiveFloat, U, V>(\n    var_name: &str,\n) -> Bucketer<'a, (T, U, V)> {\n    Bucketer {\n        bucketing_function: &|&(f, _, _)| float_size(f),\n        bucketing_label: format!(\"precision({var_name}) + |exponent({var_name})|\"),\n    }\n}\n\npub fn triple_max_primitive_float_bucketer<'a, T: PrimitiveFloat>(\n    x_name: &str,\n    y_name: &str,\n    z_name: &str,\n) -> Bucketer<'a, (T, T, T)> {\n    Bucketer {\n        bucketing_function: &|&(f, g, h)| max!(float_size(f), float_size(g), float_size(h)),\n        bucketing_label: format!(\n            \"max(precision({x_name}) + |exponent({x_name})|, \\\n            precision({y_name}) + |exponent({y_name})|, \\\n            precision({z_name}) + |exponent({z_name})|)\",\n        ),\n    }\n}\n\npub fn pair_primitive_float_bit_u64_max_bucketer<'a, T: PrimitiveFloat>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(u64::wrapping_from(float_size(*x)), *y))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn triple_1_2_primitive_float_bit_u64_max_bucketer<'a, T: PrimitiveFloat, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, u64, U)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| {\n            usize::exact_from(max(u64::wrapping_from(float_size(*x)), *y))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn usize_convertible_direct_bucketer<T: Copy>(var_name: &str) -> Bucketer<'_, T>\nwhere\n    usize: ExactFrom<T>,\n{\n    Bucketer {\n        bucketing_function: &|&x| usize::exact_from(x),\n        bucketing_label: var_name.to_string(),\n    }\n}\n\npub fn primitive_int_direct_bucketer<'a, T: PrimitiveInt>() -> Bucketer<'a, T>\nwhere\n    usize: ExactFrom<T>,\n{\n    usize_convertible_direct_bucketer(\"n\")\n}\n\npub fn unsigned_direct_bucketer<'a, T: PrimitiveUnsigned>() -> Bucketer<'a, T>\nwhere\n    usize: ExactFrom<T>,\n{\n    usize_convertible_direct_bucketer(\"u\")\n}\n\npub fn signed_direct_bucketer<'a, T: PrimitiveSigned>() -> Bucketer<'a, T>\nwhere\n    usize: ExactFrom<T>,\n{\n    usize_convertible_direct_bucketer(\"i\")\n}\n\npub fn usize_convertible_pair_max_bucketer<'a, T: Copy + Ord>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, T)>\nwhere\n    usize: ExactFrom<T>,\n{\n    Bucketer {\n        bucketing_function: &|&(x, y)| usize::exact_from(max(x, y)),\n        bucketing_label: format!(\"max({x_name}, {y_name})\"),\n    }\n}\n\npub fn abs_usize_convertible_pair_max_bucketer<'a, T: Copy + UnsignedAbs>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, T)>\nwhere\n    usize: ExactFrom<<T as UnsignedAbs>::Output>,\n    <T as UnsignedAbs>::Output: Ord,\n{\n    Bucketer {\n        bucketing_function: &|&(x, y)| usize::exact_from(max(x.unsigned_abs(), y.unsigned_abs())),\n        bucketing_label: format!(\"max({x_name}, {y_name})\"),\n    }\n}\n\npub fn abs_pair_usize_convertible_max_bucketer<'a, T: Copy + UnsignedAbs, U: Copy>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U)>\nwhere\n    usize: ExactFrom<<T as UnsignedAbs>::Output> + ExactFrom<U>,\n    <T as UnsignedAbs>::Output: Ord,\n{\n    Bucketer {\n        bucketing_function: &|&(x, y)| {\n            max(usize::exact_from(x.unsigned_abs()), usize::exact_from(y))\n        },\n        bucketing_label: format!(\"max({x_name}, {y_name})\"),\n    }\n}\n\npub fn abs_triple_1_2_usize_convertible_max_bucketer<'a, T: Copy + UnsignedAbs, U: Copy, V>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, V)>\nwhere\n    usize: ExactFrom<<T as UnsignedAbs>::Output> + ExactFrom<U>,\n    <T as UnsignedAbs>::Output: Ord,\n{\n    Bucketer {\n        bucketing_function: &|&(x, y, _)| {\n            max(usize::exact_from(x.unsigned_abs()), usize::exact_from(y))\n        },\n        bucketing_label: format!(\"max({x_name}, {y_name})\"),\n    }\n}\n\npub fn usize_convertible_pair_ratio_bucketer<'a, T: Copy>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, T)>\nwhere\n    usize: ExactFrom<T>,\n{\n    Bucketer {\n        bucketing_function: &|&(x, y)| usize::exact_from(x) / usize::exact_from(y),\n        bucketing_label: format!(\"{x_name} / {y_name}\"),\n    }\n}\n\npub fn signed_abs_bucketer<T: PrimitiveSigned>(var_name: &str) -> Bucketer<'_, T>\nwhere\n    usize: ExactFrom<<T as UnsignedAbs>::Output>,\n{\n    Bucketer {\n        bucketing_function: &|&x| usize::exact_from(x.unsigned_abs()),\n        bucketing_label: var_name.to_string(),\n    }\n}\n\npub fn bit_bucketer<T: Copy + SignificantBits>(var_name: &str) -> Bucketer<'_, T> {\n    Bucketer {\n        bucketing_function: &|&x| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn primitive_int_bit_bucketer<'a, T: PrimitiveInt>() -> Bucketer<'a, T> {\n    bit_bucketer(\"n\")\n}\n\npub fn unsigned_bit_bucketer<'a, T: PrimitiveUnsigned>() -> Bucketer<'a, T> {\n    bit_bucketer(\"u\")\n}\n\npub fn signed_bit_bucketer<'a, T: PrimitiveSigned>() -> Bucketer<'a, T> {\n    bit_bucketer(\"i\")\n}\n\npub fn ignore_highest_bit_unsigned_bit_bucketer<'a, T: PrimitiveUnsigned>(\n    var_name: &str,\n) -> Bucketer<'a, T> {\n    Bucketer {\n        bucketing_function: &|&x| {\n            let mut x = x;\n            x.clear_bit(T::WIDTH - 1);\n            usize::exact_from(x.significant_bits())\n        },\n        bucketing_label: format!(\n            \"({} - (1 << {})).significant_bits()\",\n            var_name,\n            T::WIDTH - 1\n        ),\n    }\n}\n\npub fn string_len_bucketer<'a>() -> Bucketer<'a, String> {\n    Bucketer {\n        bucketing_function: &String::len,\n        bucketing_label: \"s.len()\".to_string(),\n    }\n}\n\npub fn pair_string_max_len_bucketer<'a>(\n    s_name: &str,\n    t_name: &str,\n) -> Bucketer<'a, (String, String)> {\n    Bucketer {\n        bucketing_function: &|(s, t)| max(s.len(), t.len()),\n        bucketing_label: format!(\"max(s.len({s_name}), t.len({t_name}))\"),\n    }\n}\n\npub fn pair_1_string_len_bucketer<T>(s_name: &str) -> Bucketer<'_, (String, T)> {\n    Bucketer {\n        bucketing_function: &|(s, _)| s.len(),\n        bucketing_label: format!(\"{s_name}.len()\"),\n    }\n}\n\npub fn pair_2_string_len_bucketer<T>(s_name: &str) -> Bucketer<'_, (T, String)> {\n    Bucketer {\n        bucketing_function: &|(_, s)| s.len(),\n        bucketing_label: format!(\"{s_name}.len()\"),\n    }\n}\n\npub fn vec_len_bucketer<'a, T>() -> Bucketer<'a, Vec<T>> {\n    Bucketer {\n        bucketing_function: &Vec::len,\n        bucketing_label: \"xs.len()\".to_string(),\n    }\n}\n\npub fn pair_vec_max_len_bucketer<'a, T, U>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys)| max(xs.len(), ys.len()),\n        bucketing_label: format!(\"max({xs_name}.len(), {ys_name}.len())\"),\n    }\n}\n\npub fn pair_vec_min_len_bucketer<'a, T, U>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys)| min(xs.len(), ys.len()),\n        bucketing_label: format!(\"min({xs_name}.len(), {ys_name}.len())\"),\n    }\n}\n\npub fn pair_max_bit_bucketer<'a, T: Copy + SignificantBits, U: Copy + SignificantBits>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, U)> {\n    Bucketer {\n        bucketing_function: &|&(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn triple_max_bit_bucketer<\n    'a,\n    T: Copy + SignificantBits,\n    U: Copy + SignificantBits,\n    V: Copy + SignificantBits,\n>(\n    x_name: &str,\n    y_name: &str,\n    z_name: &str,\n) -> Bucketer<'a, (T, U, V)> {\n    Bucketer {\n        bucketing_function: &|&(x, y, z)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits())\",\n        ),\n    }\n}\n\npub fn quadruple_max_bit_bucketer<\n    'a,\n    T: Copy + SignificantBits,\n    U: Copy + SignificantBits,\n    V: Copy + SignificantBits,\n    W: Copy + SignificantBits,\n>(\n    x_name: &str,\n    y_name: &str,\n    z_name: &str,\n    w_name: &str,\n) -> Bucketer<'a, (T, U, V, W)> {\n    Bucketer {\n        bucketing_function: &|&(x, y, z, w)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits(),\n                w.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits(), {w_name}.significant_bits())\",\n        ),\n    }\n}\n\npub fn sextuple_max_bit_bucketer<\n    'a,\n    T: Copy + SignificantBits,\n    U: Copy + SignificantBits,\n    V: Copy + SignificantBits,\n    W: Copy + SignificantBits,\n    X: Copy + SignificantBits,\n    Y: Copy + SignificantBits,\n>(\n    x_name: &str,\n    y_name: &str,\n    z_name: &str,\n    w_name: &str,\n    v_name: &str,\n    u_name: &str,\n) -> Bucketer<'a, (T, U, V, W, X, Y)> {\n    Bucketer {\n        bucketing_function: &|&(x, y, z, w, v, u)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits(),\n                w.significant_bits(),\n                v.significant_bits(),\n                u.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits(), {w_name}.significant_bits(), \\\n            {v_name}.significant_bits(), {u_name}.significant_bits())\",\n        ),\n    }\n}\n\n#[allow(clippy::type_complexity)]\npub fn octuple_max_bit_bucketer<\n    'a,\n    T: Copy + SignificantBits,\n    U: Copy + SignificantBits,\n    V: Copy + SignificantBits,\n    W: Copy + SignificantBits,\n    X: Copy + SignificantBits,\n    Y: Copy + SignificantBits,\n    Z: Copy + SignificantBits,\n    A: Copy + SignificantBits,\n>(\n    x_name: &str,\n    y_name: &str,\n    z_name: &str,\n    w_name: &str,\n    v_name: &str,\n    u_name: &str,\n    t_name: &str,\n    s_name: &str,\n) -> Bucketer<'a, (T, U, V, W, X, Y, Z, A)> {\n    Bucketer {\n        bucketing_function: &|&(x, y, z, w, v, u, t, s)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits(),\n                w.significant_bits(),\n                v.significant_bits(),\n                u.significant_bits(),\n                t.significant_bits(),\n                s.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits(), {w_name}.significant_bits(), \\\n            {v_name}.significant_bits(), {u_name}.significant_bits(), \\\n            {t_name}.significant_bits(), {s_name}.significant_bits())\",\n        ),\n    }\n}\n\npub fn triple_1_2_max_bit_bucketer<'a, T: Copy + SignificantBits, U: Copy + SignificantBits, V>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, U, V)> {\n    Bucketer {\n        bucketing_function: &|&(x, y, ref _z)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn triple_2_3_product_bit_bucketer<\n    'a,\n    T,\n    U: Copy + SignificantBits,\n    V: Copy + SignificantBits,\n>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, U, V)> {\n    Bucketer {\n        bucketing_function: &|&(_, y, z)| {\n            usize::exact_from(\n                y.significant_bits()\n                    .checked_mul(z.significant_bits())\n                    .unwrap(),\n            )\n        },\n        bucketing_label: format!(\"{x_name}.significant_bits() * {y_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_1_bucketer<T: Copy, U>(x_name: &str) -> Bucketer<'_, (T, U)>\nwhere\n    usize: ExactFrom<T>,\n{\n    Bucketer {\n        bucketing_function: &|&(x, _)| usize::exact_from(x),\n        bucketing_label: x_name.to_string(),\n    }\n}\n\npub fn pair_2_bucketer<T, U: Copy>(y_name: &str) -> Bucketer<'_, (T, U)>\nwhere\n    usize: ExactFrom<U>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, y)| usize::exact_from(y),\n        bucketing_label: y_name.to_string(),\n    }\n}\n\npub fn pair_2_pair_2_bucketer<T, U, V: Copy>(y_name: &str) -> Bucketer<'_, (T, (U, V))>\nwhere\n    usize: ExactFrom<V>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, (_, y))| usize::exact_from(y),\n        bucketing_label: y_name.to_string(),\n    }\n}\n\npub fn pair_2_unsigned_abs_bucketer<T, U: Copy + UnsignedAbs>(y_name: &str) -> Bucketer<'_, (T, U)>\nwhere\n    usize: ExactFrom<<U as UnsignedAbs>::Output>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, y)| usize::exact_from(y.unsigned_abs()),\n        bucketing_label: y_name.to_string(),\n    }\n}\n\npub fn triple_2_bucketer<T, U: Copy, V>(y_name: &str) -> Bucketer<'_, (T, U, V)>\nwhere\n    usize: ExactFrom<U>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, y, _)| usize::exact_from(y),\n        bucketing_label: y_name.to_string(),\n    }\n}\n\npub fn triple_3_bucketer<T, U, V: Copy>(z_name: &str) -> Bucketer<'_, (T, U, V)>\nwhere\n    usize: ExactFrom<V>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, _, z)| usize::exact_from(z),\n        bucketing_label: z_name.to_string(),\n    }\n}\n\npub fn triple_2_unsigned_abs_bucketer<T, U: Copy + UnsignedAbs, V>(\n    y_name: &str,\n) -> Bucketer<'_, (T, U, V)>\nwhere\n    usize: ExactFrom<<U as UnsignedAbs>::Output>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, y, _)| usize::exact_from(y.unsigned_abs()),\n        bucketing_label: y_name.to_string(),\n    }\n}\n\npub fn pair_2_triple_2_bucketer<T, U, V: Copy, W>(y_name: &str) -> Bucketer<'_, (T, (U, V, W))>\nwhere\n    usize: ExactFrom<V>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, (_, y, _))| usize::exact_from(y),\n        bucketing_label: y_name.to_string(),\n    }\n}\n\npub fn triple_3_pair_2_bucketer<T, U, V, W: Copy>(y_name: &str) -> Bucketer<'_, (T, U, (V, W))>\nwhere\n    usize: ExactFrom<W>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, _, (_, y))| usize::exact_from(y),\n        bucketing_label: y_name.to_string(),\n    }\n}\n\npub fn pair_1_bit_bucketer<T: Copy + SignificantBits, U>(x_name: &str) -> Bucketer<'_, (T, U)> {\n    Bucketer {\n        bucketing_function: &|&(x, _)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{x_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_2_bit_bucketer<T, U: Copy + SignificantBits>(x_name: &str) -> Bucketer<'_, (T, U)> {\n    Bucketer {\n        bucketing_function: &|&(_, x)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{x_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_1_bit_bucketer<T: Copy + SignificantBits, U, V>(\n    x_name: &str,\n) -> Bucketer<'_, (T, U, V)> {\n    Bucketer {\n        bucketing_function: &|&(x, _, _)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{x_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_bit_bucketer<T, U, V: Copy + SignificantBits>(\n    z_name: &str,\n) -> Bucketer<'_, (T, U, V)> {\n    Bucketer {\n        bucketing_function: &|&(_, _, z)| usize::exact_from(z.significant_bits()),\n        bucketing_label: format!(\"{z_name}.significant_bits()\"),\n    }\n}\n\npub fn quadruple_1_2_bit_bucketer<T: PrimitiveUnsigned, U, V>(\n    combined_name: &str,\n) -> Bucketer<'_, (T, T, U, V)> {\n    Bucketer {\n        bucketing_function: &|&(x_1, x_0, _, _)| {\n            usize::exact_from(if x_1 == T::ZERO {\n                x_0.significant_bits()\n            } else {\n                x_1.significant_bits() + T::WIDTH\n            })\n        },\n        bucketing_label: format!(\"{combined_name}.significant_bits()\"),\n    }\n}\n\npub fn quadruple_3_bucketer<T, U, V: Copy, W>(z_name: &str) -> Bucketer<'_, (T, U, V, W)>\nwhere\n    usize: ExactFrom<V>,\n{\n    Bucketer {\n        bucketing_function: &|&(_, _, z, _)| usize::exact_from(z),\n        bucketing_label: z_name.to_string(),\n    }\n}\n\npub fn pair_primitive_int_bit_u64_max_bucketer<'a, T: PrimitiveInt>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn triple_1_2_primitive_int_bit_u64_max_bucketer<'a, T: PrimitiveInt, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, u64, U)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn pair_primitive_int_bit_i64_max_bucketer<'a, T: PrimitiveInt>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, i64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.unsigned_abs()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.unsigned_abs())\"),\n    }\n}\n\npub fn triple_primitive_int_bit_i64_u64_max_bucketer<'a, T: PrimitiveInt>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (T, i64, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn quadruple_1_2_3_primitive_int_bit_i64_u64_max_bucketer<'a, T: PrimitiveInt, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (T, i64, u64, U)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z, _)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn pair_1_vec_len_bucketer<T, U>(xs_name: &str) -> Bucketer<'_, (Vec<T>, U)> {\n    Bucketer {\n        bucketing_function: &|(xs, _)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn pair_1_vec_len_sub_1_bucketer<T, U>(xs_name: &str) -> Bucketer<'_, (Vec<T>, U)> {\n    Bucketer {\n        bucketing_function: &|(xs, _)| xs.len() - 1,\n        bucketing_label: format!(\"{xs_name}.len() - 1\"),\n    }\n}\n\npub fn pair_2_vec_len_bucketer<T, U>(ys_name: &str) -> Bucketer<'_, (T, Vec<U>)> {\n    Bucketer {\n        bucketing_function: &|(_, ys)| ys.len(),\n        bucketing_label: format!(\"{ys_name}.len()\"),\n    }\n}\n\npub fn triple_1_vec_len_bucketer<T, U, V>(xs_name: &str) -> Bucketer<'_, (Vec<T>, U, V)> {\n    Bucketer {\n        bucketing_function: &|(xs, _, _)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn triple_3_vec_len_bucketer<T, U, V>(xs_name: &str) -> Bucketer<'_, (T, U, Vec<V>)> {\n    Bucketer {\n        bucketing_function: &|(_, _, xs)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn triple_2_vec_len_bucketer<T, U, V>(xs_name: &str) -> Bucketer<'_, (T, Vec<U>, V)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, _)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn triple_vec_max_len_bucketer<'a, T, U, V>(\n    xs_name: &str,\n    ys_name: &str,\n    zs_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>, Vec<V>)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys, zs)| max!(xs.len(), ys.len(), zs.len()),\n        bucketing_label: format!(\"max({xs_name}.len(), {ys_name}.len(), {zs_name}.len())\"),\n    }\n}\n\npub fn triple_1_2_vec_max_len_bucketer<'a, T, U, V>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>, V)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys, _)| max(xs.len(), ys.len()),\n        bucketing_label: format!(\"max({xs_name}.len(), {ys_name}.len())\"),\n    }\n}\n\npub fn triple_2_3_vec_max_len_bucketer<'a, T, U, V>(\n    ys_name: &str,\n    zs_name: &str,\n) -> Bucketer<'a, (T, Vec<U>, Vec<V>)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, ys)| max(xs.len(), ys.len()),\n        bucketing_label: format!(\"max({ys_name}.len(), {zs_name}.len())\"),\n    }\n}\n\npub fn triple_1_2_vec_min_len_bucketer<'a, T, U, V>(\n    ys_name: &str,\n    zs_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>, V)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys, _)| min(xs.len(), ys.len()),\n        bucketing_label: format!(\"min({ys_name}.len(), {zs_name}.len())\"),\n    }\n}\n\npub fn triple_2_3_vec_min_len_bucketer<'a, T, U, V>(\n    ys_name: &str,\n    zs_name: &str,\n) -> Bucketer<'a, (T, Vec<U>, Vec<V>)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, ys)| min(xs.len(), ys.len()),\n        bucketing_label: format!(\"min({ys_name}.len(), {zs_name}.len())\"),\n    }\n}\n\npub fn quadruple_2_vec_len_bucketer<T, U, V, W>(xs_name: &str) -> Bucketer<'_, (T, Vec<U>, V, W)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, _, _)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn quadruple_3_vec_len_bucketer<T, U, V, W>(xs_name: &str) -> Bucketer<'_, (T, U, Vec<V>, W)> {\n    Bucketer {\n        bucketing_function: &|(_, _, xs, _)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn quadruple_4_vec_len_bucketer<T, U, V, W>(xs_name: &str) -> Bucketer<'_, (T, U, V, Vec<W>)> {\n    Bucketer {\n        bucketing_function: &|(_, _, _, xs)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn quadruple_1_3_vec_max_len_bucketer<'a, T, U, V, W>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (T, Vec<U>, V, Vec<W>)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, _, ys)| max(xs.len(), ys.len()),\n        bucketing_label: format!(\"max({xs_name}.len(), {ys_name}.len())\"),\n    }\n}\n\npub fn quintuple_1_vec_len_bucketer<T, U, V, W, X>(\n    xs_name: &str,\n) -> Bucketer<'_, (Vec<T>, U, V, W, X)> {\n    Bucketer {\n        bucketing_function: &|(xs, _, _, _, _)| xs.len(),\n        bucketing_label: format!(\"{xs_name}.len()\"),\n    }\n}\n\npub fn pair_sum_vec_len_bucketer<'a, T, U>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys)| xs.len() + ys.len(),\n        bucketing_label: format!(\"{xs_name}.len() + {ys_name}.len()\"),\n    }\n}\n\npub fn triple_2_3_sum_vec_len_bucketer<'a, T, U, V>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (T, Vec<U>, Vec<V>)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, ys)| xs.len() + ys.len(),\n        bucketing_label: format!(\"{xs_name}.len() + {ys_name}.len()\"),\n    }\n}\n\npub fn triple_2_3_diff_vec_len_bucketer<'a, T, U, V>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (T, Vec<U>, Vec<V>)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, ys)| xs.len() - ys.len(),\n        bucketing_label: format!(\"{xs_name}.len() - {ys_name}.len()\"),\n    }\n}\n\npub fn quadruple_2_3_diff_vec_len_bucketer<'a, T, U, V, W>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (T, Vec<U>, Vec<V>, W)> {\n    Bucketer {\n        bucketing_function: &|(_, xs, ys, _)| xs.len() - ys.len(),\n        bucketing_label: format!(\"{xs_name}.len() - {ys_name}.len()\"),\n    }\n}\n\npub fn get_bits_bucketer<T>() -> Bucketer<'static, (T, u64, u64)> {\n    Bucketer {\n        bucketing_function: &|&(_, start, end)| usize::exact_from(end - start),\n        bucketing_label: \"end - start\".to_string(),\n    }\n}\n\npub fn assign_bits_bucketer<T, U>() -> Bucketer<'static, (T, u64, u64, U)> {\n    Bucketer {\n        bucketing_function: &|&(_, start, end, _)| usize::exact_from(end - start),\n        bucketing_label: \"end - start\".to_string(),\n    }\n}\n\npub fn pair_1_vec_len_times_pair_2_bits_bucketer<'a, T, U: PrimitiveUnsigned>(\n    xs_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Vec<T>, U)> {\n    Bucketer {\n        bucketing_function: &|(xs, y)| {\n            xs.len()\n                .checked_mul(usize::exact_from(y.significant_bits()))\n                .unwrap()\n        },\n        bucketing_label: format!(\"{xs_name}.len() * {y_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_product_vec_len_bucketer<'a, T, U>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys)| xs.len().checked_mul(ys.len()).unwrap(),\n        bucketing_label: format!(\"{xs_name}.len() * {ys_name}.len()\"),\n    }\n}\n\npub fn triple_1_2_product_vec_len_bucketer<'a, T, U, V>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (Vec<T>, Vec<U>, V)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys, _)| xs.len().checked_mul(ys.len()).unwrap(),\n        bucketing_label: format!(\"{xs_name}.len() * {ys_name}.len()\"),\n    }\n}\n\npub fn triple_2_bits_times_triple_3_bucketer<'a, T, U, V: Copy>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, V)>\nwhere\n    usize: ExactFrom<V>,\n    for<'b> &'b U: SignificantBits,\n{\n    Bucketer {\n        bucketing_function: &|(_, x, y)| {\n            let x_bits: usize = ExactFrom::<u64>::exact_from(x.significant_bits());\n            x_bits.checked_mul(ExactFrom::<V>::exact_from(*y)).unwrap()\n        },\n        bucketing_label: format!(\"{x_name}.significant_bits() * {y_name}\"),\n    }\n}\n\npub fn pair_1_vec_len_times_pair_2_bucketer<'a, T, U: Copy>(\n    xs_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Vec<T>, U)>\nwhere\n    usize: ExactFrom<U>,\n{\n    Bucketer {\n        bucketing_function: &|(xs, y)| xs.len().checked_mul(usize::exact_from(*y)).unwrap(),\n        bucketing_label: format!(\"{xs_name}.len() * {y_name}\"),\n    }\n}\n\npub fn pair_1_bits_times_pair_2_bucketer<'a, T, U: Copy>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U)>\nwhere\n    usize: ExactFrom<U>,\n    for<'b> &'b T: SignificantBits,\n{\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            let x_bits: usize = ExactFrom::<u64>::exact_from(x.significant_bits());\n            x_bits.checked_mul(ExactFrom::<U>::exact_from(*y)).unwrap()\n        },\n        bucketing_label: format!(\"{x_name}.significant_bits() * {y_name}\"),\n    }\n}\n\npub fn triple_3_pair_1_bits_times_pair_2_bucketer<'a, T, U, V, W: Copy>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, (V, W))>\nwhere\n    usize: ExactFrom<W>,\n    for<'b> &'b V: SignificantBits,\n{\n    Bucketer {\n        bucketing_function: &|(_, _, (x, y))| {\n            let x_bits: usize = ExactFrom::<u64>::exact_from(x.significant_bits());\n            x_bits.checked_mul(ExactFrom::<W>::exact_from(*y)).unwrap()\n        },\n        bucketing_label: format!(\"{x_name}.significant_bits() * {y_name}\"),\n    }\n}\n\npub fn rational_sequence_len_bucketer<'a, T: Eq>(\n    xs_name: &str,\n) -> Bucketer<'a, RationalSequence<T>> {\n    Bucketer {\n        bucketing_function: &RationalSequence::component_len,\n        bucketing_label: format!(\"{xs_name}.component_len()\"),\n    }\n}\n\npub fn pair_rational_sequence_max_len_bucketer<'a, T: Eq, U: Eq>(\n    xs_name: &str,\n    ys_name: &str,\n) -> Bucketer<'a, (RationalSequence<T>, RationalSequence<U>)> {\n    Bucketer {\n        bucketing_function: &|(xs, ys)| max(xs.component_len(), ys.component_len()),\n        bucketing_label: format!(\"max({xs_name}.component_len(), {ys_name}.component_len())\"),\n    }\n}\n\npub fn pair_1_rational_sequence_len_bucketer<'a, T: Eq, U>(\n    xs_name: &str,\n) -> Bucketer<'a, (RationalSequence<T>, U)> {\n    Bucketer {\n        bucketing_function: &|(xs, _)| xs.component_len(),\n        bucketing_label: format!(\"{xs_name}.component_len()\"),\n    }\n}\n\npub fn quadruple_1_rational_sequence_len_bucketer<'a, T: Eq, U, V, W>(\n    xs_name: &str,\n) -> Bucketer<'a, (RationalSequence<T>, U, V, W)> {\n    Bucketer {\n        bucketing_function: &|(xs, _, _, _)| xs.component_len(),\n        bucketing_label: format!(\"{xs_name}.component_len()\"),\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::Parity;\nuse crate::num::conversion::traits::ExactFrom;\nuse crate::test_util::bench::bucketers::Bucketer;\nuse gnuplot::{AxesCommon, Caption, Color, Figure};\nuse itertools::Itertools;\nuse std::collections::{BTreeMap, HashMap};\nuse std::iter::Iterator;\nuse std::time::Instant;\n\nfn escape_label_string(s: &str) -> String {\n    let mut escaped = String::new();\n    for c in s.chars() {\n        if c == '_' {\n            escaped.push_str(\"\\\\_\");\n        } else if c == '&' {\n            escaped.push_str(\"\\\\&\");\n        } else {\n            escaped.push(c);\n        }\n    }\n    escaped\n}\n\nstruct BenchmarkSeriesOptions<'a, T: 'a> {\n    pub name: &'a str,\n    pub function: &'a mut dyn FnMut(T),\n    pub color: &'a str,\n}\n\nstruct BenchmarkOptions<'a, I: Iterator>\nwhere\n    I::Item: 'a,\n{\n    pub generator: I,\n    pub title: &'a str,\n    pub limit: usize,\n    pub bucketing_function: &'a dyn Fn(&I::Item) -> usize,\n    pub x_axis_label: &'a str,\n    pub y_axis_label: &'a str,\n    pub file_name: String,\n    pub series_options: Vec<BenchmarkSeriesOptions<'a, I::Item>>,\n}\n\nfn quick_median(xs: &mut [u64]) -> u64 {\n    assert!(!xs.is_empty());\n    xs.sort_unstable();\n    let half_index = xs.len() >> 1;\n    if xs.len().odd() {\n        xs[half_index]\n    } else {\n        (xs[half_index - 1] + xs[half_index]) >> 1\n    }\n}\n\nfn quick_mean(xs: &[u64]) -> u64 {\n    assert!(!xs.is_empty());\n    let sum: u64 = xs.iter().sum();\n    sum / u64::exact_from(xs.len())\n}\n\nfn run_benchmark_internal<I: Iterator>(mut options: BenchmarkOptions<I>)\nwhere\n    I::Item: Clone,\n{\n    let reps = 5;\n    let min_bucket_size = 2;\n\n    let mut durations_maps = Vec::new();\n    for _ in 0..options.series_options.len() {\n        durations_maps.push(HashMap::new());\n    }\n    for x in options.generator.take(options.limit) {\n        let size = (options.bucketing_function)(&x);\n        for (i, series) in options.series_options.iter_mut().enumerate() {\n            let mut durations_vec = Vec::new();\n            for _ in 0..reps {\n                let x = x.clone();\n                let now = Instant::now();\n                (series.function)(x);\n                durations_vec.push(u64::exact_from(now.elapsed().as_nanos()));\n            }\n            let median_duration = quick_median(&mut durations_vec);\n            durations_maps[i]\n                .entry(size)\n                .or_insert_with(Vec::new)\n                .push(median_duration);\n        }\n    }\n    let mut median_durations_maps = Vec::new();\n    for durations_map in durations_maps {\n        let mut median_durations_map: BTreeMap<usize, u64> = BTreeMap::new();\n        for (&size, durations) in &durations_map {\n            if durations.len() >= min_bucket_size {\n                median_durations_map.insert(size, quick_mean(durations));\n            }\n        }\n        median_durations_maps.push(median_durations_map);\n    }\n\n    let mut fg = Figure::new();\n    {\n        let axes = fg.axes2d();\n        axes.set_title(&escape_label_string(options.title), &[]);\n        axes.set_x_label(&escape_label_string(options.x_axis_label), &[]);\n        axes.set_y_label(&escape_label_string(options.y_axis_label), &[]);\n        for (median_durations_map, options) in median_durations_maps\n            .iter()\n            .zip(options.series_options.iter())\n        {\n            let sizes = median_durations_map\n                .iter()\n                .map(|entry| *entry.0)\n                .collect_vec();\n            let durations = median_durations_map\n                .iter()\n                .map(|entry| *entry.1)\n                .collect_vec();\n            axes.lines(\n                &sizes,\n                &durations,\n                &[\n                    Caption(&escape_label_string(options.name)),\n                    Color(gnuplot::RGBString(options.color)),\n                ],\n            );\n        }\n    }\n    fg.echo_to_file(&options.file_name);\n}\n\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub enum BenchmarkType {\n    Single,\n    LibraryComparison,\n    EvaluationStrategy,\n    Algorithms,\n}\n\n#[allow(clippy::print_stdout, clippy::type_complexity)]\npub fn run_benchmark<'a, I: Iterator>(\n    title: &'a str,\n    benchmark_type: BenchmarkType,\n    generator: I,\n    generation_mode_name: &'a str,\n    limit: usize,\n    file_name: &'a str,\n    bucketer: &Bucketer<'a, I::Item>,\n    series: &mut [(&'a str, &'a mut dyn FnMut(I::Item))],\n) where\n    I::Item: Clone,\n{\n    assert_eq!(\n        benchmark_type == BenchmarkType::Single,\n        series.len() == 1,\n        \"Bad benchmark: {title}. \\\n             Benchmarks should have type Single iff they have only one series.\",\n    );\n    if limit == 0 {\n        return;\n    }\n    let title = match benchmark_type {\n        BenchmarkType::Single => title.to_string(),\n        BenchmarkType::LibraryComparison => format!(\"{title} library comparison\"),\n        BenchmarkType::EvaluationStrategy => format!(\"{title} evaluation strategy\"),\n        BenchmarkType::Algorithms => format!(\"{title} algorithms\"),\n    };\n    println!(\"benchmarking {generation_mode_name} {title}\");\n    let colors = [\"green\", \"blue\", \"red\", \"black\", \"orange\", \"yellow\", \"gray\", \"purple\"];\n    assert!(series.len() <= colors.len(), \"not enough available colors\");\n    let mut series_options = Vec::new();\n    for (&mut (label, ref mut function), color) in series.iter_mut().zip(colors.iter()) {\n        series_options.push(BenchmarkSeriesOptions {\n            name: label,\n            function,\n            color,\n        });\n    }\n    let options = BenchmarkOptions {\n        generator,\n        title: &title,\n        limit,\n        bucketing_function: bucketer.bucketing_function,\n        x_axis_label: &bucketer.bucketing_label,\n        y_axis_label: \"time (ns)\",\n        file_name: file_name.to_string(),\n        series_options,\n    };\n    run_benchmark_internal(options);\n}\n\n#[allow(clippy::print_stdout, clippy::type_complexity)]\npub fn run_benchmark_old<'a, I: Iterator>(\n    title: &'a str,\n    benchmark_type: BenchmarkType,\n    generator: I,\n    generation_mode_name: &'a str,\n    limit: usize,\n    file_name: &'a str,\n    bucketing_function: &'a dyn Fn(&I::Item) -> usize,\n    bucketing_label: &'a str,\n    series: &mut [(&'a str, &'a mut dyn FnMut(I::Item))],\n) where\n    I::Item: Clone,\n{\n    assert_eq!(\n        benchmark_type == BenchmarkType::Single,\n        series.len() == 1,\n        \"Bad benchmark: {title}. \\\n             Benchmarks should have type Single iff they have only one series.\",\n    );\n    if limit == 0 {\n        return;\n    }\n    let title = match benchmark_type {\n        BenchmarkType::Single => title.to_string(),\n        BenchmarkType::LibraryComparison => format!(\"{title} library comparison\"),\n        BenchmarkType::EvaluationStrategy => format!(\"{title} evaluation strategy\"),\n        BenchmarkType::Algorithms => format!(\"{title} algorithms\"),\n    };\n    println!(\"benchmarking {generation_mode_name} {title}\");\n    let colors = [\"green\", \"blue\", \"red\", \"black\", \"orange\", \"yellow\", \"gray\", \"purple\"];\n    assert!(series.len() <= colors.len(), \"not enough available colors\");\n    let mut series_options = Vec::new();\n    for (&mut (label, ref mut function), color) in series.iter_mut().zip(colors.iter()) {\n        series_options.push(BenchmarkSeriesOptions {\n            name: label,\n            function,\n            color,\n        });\n    }\n    let options = BenchmarkOptions {\n        generator,\n        title: &title,\n        limit,\n        bucketing_function,\n        x_axis_label: bucketing_label,\n        y_axis_label: \"time (ns)\",\n        file_name: format!(\"benchmarks/{file_name}\"),\n        series_options,\n    };\n    run_benchmark_internal(options);\n}\n\n#[macro_export]\nmacro_rules! no_out {\n    ($e:expr) => {{\n        $e;\n    }};\n}\n\npub mod bucketers;\n"
  },
  {
    "path": "malachite-base/src/test_util/common/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse std::cmp::Ordering;\nuse std::fmt::Debug;\nuse std::str::FromStr;\n\n#[macro_export]\nmacro_rules! assert_panic {\n    ($e: expr) => {\n        let result = catch_unwind(|| $e);\n        assert!(result.is_err());\n    };\n}\n\nfn read_strings<T: FromStr>(strings: &[&str]) -> Vec<T>\nwhere\n    T::Err: Debug,\n{\n    strings.iter().map(|s| s.parse().unwrap()).collect()\n}\n\nfn test_helper_helper<\n    T: Debug + FromStr,\n    U: Debug + Eq,\n    F: FnMut(usize, usize) -> U,\n    G: FnMut(&T, &T) -> U,\n>(\n    strings: &[&str],\n    mut compare_indices: F,\n    mut compare_elements: G,\n) where\n    T::Err: Debug,\n{\n    let xs = read_strings::<T>(strings);\n    let ys = read_strings::<T>(strings);\n    for (i, x) in xs.iter().enumerate() {\n        for (j, y) in ys.iter().enumerate() {\n            assert_eq!(compare_indices(i, j), compare_elements(x, y));\n        }\n    }\n}\n\npub fn test_eq_helper<T: Debug + Eq + FromStr>(strings: &[&str])\nwhere\n    T::Err: Debug,\n{\n    test_helper_helper(strings, |i, j| i == j, |x: &T, y: &T| x == y);\n}\n\npub fn test_cmp_helper<T: Debug + FromStr + Ord>(strings: &[&str])\nwhere\n    T::Err: Debug,\n{\n    test_helper_helper::<T, _, _, _>(strings, |i, j| i.cmp(&j), Ord::cmp);\n}\n\npub fn test_custom_cmp_helper<T: Debug + FromStr, F: FnMut(&T, &T) -> Ordering>(\n    strings: &[&str],\n    compare: F,\n) where\n    T::Err: Debug,\n{\n    test_helper_helper(strings, |i, j| i.cmp(&j), compare);\n}\n\n#[macro_export]\nmacro_rules! triple_significant_bits_fn {\n    ($t:ident, $bucketing_function:ident) => {\n        fn $bucketing_function(t: &($t, $t, $t)) -> usize {\n            usize::exact_from(max!(\n                t.0.significant_bits(),\n                t.1.significant_bits(),\n                t.2.significant_bits()\n            ))\n        }\n    };\n}\n\npub const TRIPLE_SIGNIFICANT_BITS_LABEL: &str =\n    \"max(a.significant_bits(), b.significant_bits(), c.significant_bits())\";\n\npub fn rle_encode<I: Iterator>(xs: I) -> Vec<(I::Item, usize)>\nwhere\n    I::Item: Clone + Eq,\n{\n    let mut out = Vec::new();\n    let mut previous: Option<I::Item> = None;\n    let mut count = 0;\n    for x in xs {\n        if let Some(p) = previous.as_ref() {\n            if x == *p {\n                count += 1;\n            } else {\n                out.push((p.clone(), count));\n                previous = Some(x.clone());\n                count = 1;\n            }\n        } else {\n            count = 1;\n            previous = Some(x.clone());\n        }\n    }\n    if let Some(p) = previous {\n        out.push((p, count));\n    }\n    out\n}\n\npub fn rle_decode<T: Clone>(ps: &[(T, usize)]) -> Vec<T> {\n    let mut out = Vec::new();\n    for (x, count) in ps {\n        for _ in 0..*count {\n            out.push(x.clone());\n        }\n    }\n    out\n}\n\npub fn test_double_ended_iterator_size_hint<I: Clone + DoubleEndedIterator>(\n    mut xs: I,\n    original_expected_size: usize,\n) {\n    let original_xs = xs.clone();\n    let mut expected_size = original_expected_size;\n    for _ in 0..10 {\n        assert_eq!(xs.size_hint(), (expected_size, Some(expected_size)));\n        if xs.next().is_none() {\n            break;\n        };\n        expected_size -= 1;\n    }\n    let mut xs = original_xs;\n    let mut expected_size = original_expected_size;\n    for _ in 0..10 {\n        assert_eq!(xs.size_hint(), (expected_size, Some(expected_size)));\n        if xs.next_back().is_none() {\n            break;\n        };\n        expected_size -= 1;\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/extra_variadic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse crate::iterators::iterator_cache::IteratorCache;\nuse crate::num::arithmetic::traits::CheckedPow;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::logic::traits::SignificantBits;\nuse crate::num::random::{RandomUnsignedRange, random_unsigned_range};\nuse crate::random::Seed;\nuse crate::tuples::exhaustive::clone_helper;\nuse crate::tuples::random::next_helper;\nuse crate::unions::UnionFromStrError;\nuse crate::{\n    custom_tuples, exhaustive_tuples_1_input, exhaustive_unions, lex_custom_tuples, lex_tuples,\n    random_custom_tuples, random_tuples, random_unions, union_struct,\n};\nuse std::cmp::max;\nuse std::fmt::{self, Display, Formatter};\nuse std::marker::PhantomData;\nuse std::str::FromStr;\n\nfn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n    (a.unwrap(), b.unwrap(), c.unwrap())\n}\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_quadruple<X, Y, Z, W>(\n    (a, b, c, d): (Option<X>, Option<Y>, Option<Z>, Option<W>),\n) -> (X, Y, Z, W) {\n    (a.unwrap(), b.unwrap(), c.unwrap(), d.unwrap())\n}\n\nlex_tuples!(\n    (pub(crate)),\n    3,\n    LexTriples,\n    LexTriplesFromSingle,\n    lex_triples,\n    lex_triples_from_single,\n    (T, T, T),\n    [0, X, I, xs, x],\n    [1, Y, J, ys, y],\n    [2, Z, K, zs, z]\n);\n\nlex_custom_tuples!(\n    (pub(crate)),\n    LexTriplesXYY,\n    (X, Y, Y),\n    (None, None, None),\n    unwrap_triple,\n    lex_triples_xyy,\n    [X, I, xs, [0, x_0]],\n    [Y, J, ys, [1, y_1], [2, y_2]]\n);\n\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveTriples1Input,\n    exhaustive_triples_1_input,\n    exhaustive_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveQuadruples1Input,\n    exhaustive_quadruples_1_input,\n    exhaustive_quadruples_from_single,\n    (I::Item, I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveSextuples1Input,\n    exhaustive_sextuples_1_input,\n    exhaustive_sextuples_from_single,\n    (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w],\n    [4, output_type_v],\n    [5, output_type_u]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveOctuples1Input,\n    exhaustive_octuples_1_input,\n    exhaustive_octuples_from_single,\n    (\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item\n    ),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w],\n    [4, output_type_v],\n    [5, output_type_u],\n    [6, output_type_t],\n    [7, output_type_s]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveDuodecuples1Input,\n    exhaustive_duodecuples_1_input,\n    exhaustive_duodecuples_from_single,\n    (\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item\n    ),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w],\n    [4, output_type_v],\n    [5, output_type_u],\n    [6, output_type_t],\n    [7, output_type_s],\n    [8, output_type_r],\n    [9, output_type_q],\n    [10, output_type_p],\n    [11, output_type_o]\n);\n\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveTriplesXXY,\n    (X, X, Y),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xxy,\n    exhaustive_triples_xxy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]]\n);\ncustom_tuples!(\n     (pub(crate)),\n     ExhaustiveTriplesXYX,\n     (X, Y, X),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xyx,\n    exhaustive_triples_xyx_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_ys_1]],\n    [Y, J, ys, ys_done, [1, output_type_xs_2]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXXXY,\n    (X, X, X, Y),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xxxy,\n    exhaustive_quadruples_xxxy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1], [2, output_type_xs_2]],\n    [Y, J, ys, ys_done, [3, output_type_ys_3]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXXYX,\n    (X, X, Y, X),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xxyx,\n    exhaustive_quadruples_xxyx_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1], [3, output_type_xs_3]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXYYX,\n    (X, Y, Y, X),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xyyx,\n    exhaustive_quadruples_xyyx_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [3, output_type_xs_3]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXYYZ,\n    (X, Y, Y, Z),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xyyz,\n    exhaustive_quadruples_xyyz_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]],\n    [Z, K, zs, zs_done, [3, output_type_zs_3]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXYZZ,\n    (X, Y, Z, Z),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xyzz,\n    exhaustive_quadruples_xyzz_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1]],\n    [Z, K, zs, zs_done, [2, output_type_zs_2], [3, output_type_zs_3]]\n);\n\nrandom_tuples!(\n    (pub(crate)),\n    RandomTriples,\n    RandomTriplesFromSingle,\n    random_triples,\n    random_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen]\n);\nrandom_tuples!(\n    (pub(crate)),\n    RandomQuadruples,\n    RandomQuadruplesFromSingle,\n    random_quadruples,\n    random_quadruples_from_single,\n    (I::Item, I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen],\n    [3, W, L, ws, ws_gen]\n);\nrandom_tuples!(\n    (pub(crate)),\n    RandomSextuples,\n    RandomSextuplesFromSingle,\n    random_sextuples,\n    random_sextuples_from_single,\n    (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen],\n    [3, W, L, ws, ws_gen],\n    [4, V, M, vs, vs_gen],\n    [5, U, N, us, us_gen]\n);\nrandom_tuples!(\n    (pub(crate)),\n    RandomOctuples,\n    RandomOctuplesFromSingle,\n    random_octuples,\n    random_octuples_from_single,\n    (\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item\n    ),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen],\n    [3, W, L, ws, ws_gen],\n    [4, V, M, vs, vs_gen],\n    [5, U, N, us, us_gen],\n    [6, T, O, ts, ts_gen],\n    [7, S, P, ss, ss_gen]\n);\nrandom_tuples!(\n    (pub(crate)),\n    RandomDuodecuples,\n    RandomDuodecuplesFromSingle,\n    random_duodecuples,\n    random_duodecuples_from_single,\n    (\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item\n    ),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen],\n    [3, W, L, ws, ws_gen],\n    [4, V, M, vs, vs_gen],\n    [5, U, N, us, us_gen],\n    [6, T, OI, ts, ts_gen],\n    [7, S, PI, ss, ss_gen],\n    [8, R, QI, rs, rs_gen],\n    [9, Q, RI, qs, qs_gen],\n    [10, P, SI, ps, ps_gen],\n    [11, O, TI, os, os_gen]\n);\n\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXXY,\n    (X, X, Y),\n    random_triples_xxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n    [Y, J, ys, ys_gen, [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXYX,\n    (X, Y, X),\n    random_triples_xyx,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n    [Y, J, ys, ys_gen, [y_1, x_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXYY,\n    (X, Y, Y),\n    random_triples_xyy,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXXXY,\n    (X, X, X, Y),\n    random_quadruples_xxxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1], [x_2, x_2]],\n    [Y, J, ys, ys_gen, [y_3, y_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXXYX,\n    (X, X, Y, X),\n    random_quadruples_xxyx,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1], [x_3, y_2]],\n    [Y, J, ys, ys_gen, [y_2, x_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXYYX,\n    (X, Y, Y, X),\n    random_quadruples_xyyx,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_3, y_1]],\n    [Y, J, ys, ys_gen, [y_1, y_2], [y_2, x_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXYXY,\n    (X, Y, X, Y),\n    random_quadruples_xyxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n    [Y, J, ys, ys_gen, [y_1, x_2], [y_3, y_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXYYZ,\n    (X, Y, Y, Z),\n    random_quadruples_xyyz,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]],\n    [Z, K, zs, zs_gen, [z_3, z_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXYZZ,\n    (X, Y, Z, Z),\n    random_quadruples_xyzz,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1]],\n    [Z, K, zs, zs_gen, [z_2, z_2], [z_3, z_3]]\n);\n\nexhaustive_unions!(\n    (pub(crate)),\n    Union3,\n    LexUnion3s,\n    ExhaustiveUnion3s,\n    lex_union3s,\n    exhaustive_union3s,\n    3,\n    [0, X, I, A, xs, xs_done],\n    [1, Y, J, B, ys, ys_done],\n    [2, Z, K, C, zs, zs_done]\n);\n\nunion_struct!(\n    (pub(crate)),\n    Union3,\n    Union3<T, T, T>,\n    [A, A, 'A', a],\n    [B, B, 'B', b],\n    [C, C, 'C', c]\n);\n\nrandom_unions!(\n    (pub(crate)),\n    Union3,\n    RandomUnion3s,\n    random_union3s,\n    3,\n    [0, X, I, A, xs, xs_gen],\n    [1, Y, J, B, ys, ys_gen],\n    [2, Z, K, C, zs, zs_gen]\n);\n"
  },
  {
    "path": "malachite-base/src/test_util/generators/common.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse std::collections::HashMap;\nuse std::marker::PhantomData;\n\npub const TINY_LIMIT: usize = 1000;\npub const SMALL_LIMIT: usize = 1000;\npub const LARGE_LIMIT: usize = 10000;\n\n#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]\npub enum GenMode {\n    Exhaustive,\n    Random,\n    SpecialRandom,\n}\n\nimpl GenMode {\n    pub const fn name(self) -> &'static str {\n        match self {\n            Self::Exhaustive => \"exhaustive\",\n            Self::Random => \"random\",\n            Self::SpecialRandom => \"special_random\",\n        }\n    }\n}\n\npub type It<T> = Box<dyn Iterator<Item = T>>;\n\n#[derive(Clone, Debug)]\npub struct GenConfig(HashMap<String, u64>);\n\nimpl GenConfig {\n    pub fn new() -> Self {\n        Self(HashMap::new())\n    }\n\n    pub fn insert(&mut self, key: &str, value: u64) {\n        self.0.insert(key.to_string(), value);\n    }\n\n    pub fn get_or(&self, key: &'static str, default: u64) -> u64 {\n        *self.0.get(key).unwrap_or(&default)\n    }\n}\n\nimpl Default for GenConfig {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\npub struct Generator<T: 'static> {\n    phantom: PhantomData<*const T>,\n    exhaustive: &'static dyn Fn() -> It<T>,\n    random: &'static dyn Fn(&GenConfig) -> It<T>,\n    special_random: Option<&'static dyn Fn(&GenConfig) -> It<T>>,\n}\n\nimpl<T> Generator<T> {\n    pub fn new(\n        exhaustive: &'static dyn Fn() -> It<T>,\n        random: &'static dyn Fn(&GenConfig) -> It<T>,\n        special_random: &'static dyn Fn(&GenConfig) -> It<T>,\n    ) -> Self {\n        Self {\n            phantom: PhantomData,\n            exhaustive,\n            random,\n            special_random: Some(special_random),\n        }\n    }\n\n    pub fn new_no_special(\n        exhaustive: &'static dyn Fn() -> It<T>,\n        random: &'static dyn Fn(&GenConfig) -> It<T>,\n    ) -> Self {\n        Self {\n            phantom: PhantomData,\n            exhaustive,\n            random,\n            special_random: None,\n        }\n    }\n\n    fn test_properties_with_config_with_limit_and_optional_exhaustive_limit<F: FnMut(T)>(\n        &self,\n        config: &GenConfig,\n        mut test: F,\n        limit: usize,\n        exhaustive_limit: bool,\n    ) {\n        if exhaustive_limit {\n            for x in (self.exhaustive)().take(limit) {\n                test(x);\n            }\n        } else {\n            for x in (self.exhaustive)() {\n                test(x);\n            }\n        }\n        for x in (self.random)(config).take(limit) {\n            test(x);\n        }\n        if let Some(special_random) = self.special_random {\n            for x in special_random(config).take(limit) {\n                test(x);\n            }\n        }\n    }\n\n    pub fn test_properties_with_limit<F: FnMut(T)>(&self, limit: usize, test: F) {\n        self.test_properties_with_config_with_limit_and_optional_exhaustive_limit(\n            &GenConfig::new(),\n            test,\n            limit,\n            true,\n        );\n    }\n\n    fn test_properties_with_config_optional_exhaustive_limit<F: FnMut(T)>(\n        &self,\n        config: &GenConfig,\n        test: F,\n        exhaustive_limit: bool,\n    ) {\n        self.test_properties_with_config_with_limit_and_optional_exhaustive_limit(\n            config,\n            test,\n            LARGE_LIMIT,\n            exhaustive_limit,\n        );\n    }\n\n    pub fn test_properties_with_config<F: FnMut(T)>(&self, config: &GenConfig, test: F) {\n        self.test_properties_with_config_optional_exhaustive_limit(config, test, true);\n    }\n\n    #[inline]\n    pub fn test_properties<F: FnMut(T)>(&self, test: F) {\n        self.test_properties_with_config(&GenConfig::new(), test);\n    }\n\n    #[inline]\n    pub fn test_properties_with_limit_and_no_exhaustive_limit<F: FnMut(T)>(&self, test: F) {\n        self.test_properties_with_config_optional_exhaustive_limit(&GenConfig::new(), test, false);\n    }\n\n    #[inline]\n    pub fn test_properties_no_exhaustive_limit<F: FnMut(T)>(&self, test: F) {\n        self.test_properties_with_config_optional_exhaustive_limit(&GenConfig::new(), test, false);\n    }\n\n    pub fn get(&self, gm: GenMode, config: &GenConfig) -> It<T> {\n        match gm {\n            GenMode::Exhaustive => (self.exhaustive)(),\n            GenMode::Random => (self.random)(config),\n            GenMode::SpecialRandom => {\n                (self\n                    .special_random\n                    .expect(\"special_random mode unsupported\"))(config)\n            }\n        }\n    }\n}\n\npub fn permute_1_3_2<A: 'static, B: 'static, C: 'static>(\n    it: Box<dyn Iterator<Item = (A, B, C)>>,\n) -> Box<dyn Iterator<Item = (A, C, B)>> {\n    Box::new(it.map(|(a, b, c)| (a, c, b)))\n}\n\npub fn permute_2_1<A: 'static, B: 'static>(\n    it: Box<dyn Iterator<Item = (A, B)>>,\n) -> Box<dyn Iterator<Item = (B, A)>> {\n    Box::new(it.map(|(a, b)| (b, a)))\n}\n\npub fn permute_3_1_4_2<A: 'static, B: 'static, C: 'static, D: 'static>(\n    it: Box<dyn Iterator<Item = (A, B, C, D)>>,\n) -> Box<dyn Iterator<Item = (C, A, D, B)>> {\n    Box::new(it.map(|(a, b, c, d)| (c, a, d, b)))\n}\n\npub fn reshape_1_2_to_3<A: 'static, B: 'static, C: 'static>(\n    it: Box<dyn Iterator<Item = (A, (B, C))>>,\n) -> Box<dyn Iterator<Item = (A, B, C)>> {\n    Box::new(it.map(|(a, (b, c))| (a, b, c)))\n}\n\npub fn reshape_1_3_to_4<A: 'static, B: 'static, C: 'static, D: 'static>(\n    it: Box<dyn Iterator<Item = (A, (B, C, D))>>,\n) -> Box<dyn Iterator<Item = (A, B, C, D)>> {\n    Box::new(it.map(|(a, (b, c, d))| (a, b, c, d)))\n}\n\npub fn reshape_2_1_to_3<A: 'static, B: 'static, C: 'static>(\n    it: Box<dyn Iterator<Item = ((A, B), C)>>,\n) -> Box<dyn Iterator<Item = (A, B, C)>> {\n    Box::new(it.map(|((a, b), c)| (a, b, c)))\n}\n\npub fn reshape_2_1_1_to_4<A: 'static, B: 'static, C: 'static, D: 'static>(\n    it: Box<dyn Iterator<Item = ((A, B), C, D)>>,\n) -> Box<dyn Iterator<Item = (A, B, C, D)>> {\n    Box::new(it.map(|((a, b), c, d)| (a, b, c, d)))\n}\n\n#[allow(clippy::type_complexity)]\npub fn reshape_2_2_to_4<A: 'static, B: 'static, C: 'static, D: 'static>(\n    it: Box<dyn Iterator<Item = ((A, B), (C, D))>>,\n) -> Box<dyn Iterator<Item = (A, B, C, D)>> {\n    Box::new(it.map(|((a, b), (c, d))| (a, b, c, d)))\n}\n\npub fn reshape_3_1_to_4<A: 'static, B: 'static, C: 'static, D: 'static>(\n    it: Box<dyn Iterator<Item = ((A, B, C), D)>>,\n) -> Box<dyn Iterator<Item = (A, B, C, D)>> {\n    Box::new(it.map(|((a, b, c), d)| (a, b, c, d)))\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/generators/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::exhaustive::{ExhaustiveBools, exhaustive_bools};\nuse crate::chars::constants::NUMBER_OF_CHARS;\nuse crate::chars::exhaustive::{exhaustive_ascii_chars, exhaustive_chars};\nuse crate::iterators::bit_distributor::BitDistributorOutputType;\nuse crate::iterators::iter_windows;\nuse crate::max;\nuse crate::num::arithmetic::traits::CoprimeWith;\nuse crate::num::arithmetic::traits::{\n    ArithmeticCheckedShl, CheckedNeg, DivRound, Parity, PowerOf2, ShrRound, UnsignedAbs,\n};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::string::options::exhaustive::{\n    exhaustive_from_sci_string_options, exhaustive_sci_size_options, exhaustive_to_sci_options,\n};\nuse crate::num::conversion::string::options::{FromSciStringOptions, SciSizeOptions, ToSciOptions};\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, HasHalf, JoinHalves, RoundingFrom, SaturatingFrom,\n    SplitInHalf, WrappingFrom,\n};\nuse crate::num::exhaustive::{\n    ExhaustiveSigneds, PrimitiveIntIncreasingRange, exhaustive_finite_primitive_floats,\n    exhaustive_natural_signeds, exhaustive_negative_signeds,\n    exhaustive_nonzero_finite_primitive_floats, exhaustive_nonzero_signeds,\n    exhaustive_positive_finite_primitive_floats, exhaustive_positive_primitive_ints,\n    exhaustive_primitive_float_range, exhaustive_primitive_floats,\n    exhaustive_signed_inclusive_range, exhaustive_signed_range, exhaustive_signeds,\n    exhaustive_unsigneds, primitive_int_increasing_inclusive_range, primitive_int_increasing_range,\n};\nuse crate::num::float::NiceFloat;\nuse crate::num::iterators::{bit_distributor_sequence, ruler_sequence};\nuse crate::num::logic::traits::{BitBlockAccess, LeadingZeros};\nuse crate::rational_sequences::RationalSequence;\nuse crate::rational_sequences::exhaustive::exhaustive_rational_sequences;\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse crate::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse crate::slices::slice_test_zero;\nuse crate::strings::exhaustive::{exhaustive_strings, exhaustive_strings_using_chars};\nuse crate::strings::{StringsFromCharVecs, strings_from_char_vecs};\nuse crate::test_util::extra_variadic::{\n    ExhaustiveTriples1Input, ExhaustiveTriplesXXY, Union3, exhaustive_duodecuples_from_single,\n    exhaustive_octuples_from_single, exhaustive_quadruples_from_single, exhaustive_quadruples_xxxy,\n    exhaustive_quadruples_xxxy_custom_output, exhaustive_quadruples_xxyx,\n    exhaustive_quadruples_xyyx, exhaustive_quadruples_xyyz,\n    exhaustive_quadruples_xyyz_custom_output, exhaustive_quadruples_xyzz,\n    exhaustive_sextuples_from_single, exhaustive_triples_from_single, exhaustive_triples_xxy,\n    exhaustive_triples_xxy_custom_output, exhaustive_triples_xyx,\n    exhaustive_triples_xyx_custom_output, lex_triples_from_single, lex_triples_xyy, lex_union3s,\n};\nuse crate::test_util::generators::common::{\n    It, permute_1_3_2, permute_2_1, permute_3_1_4_2, reshape_1_2_to_3, reshape_2_1_1_to_4,\n    reshape_2_1_to_3, reshape_2_2_to_4, reshape_3_1_to_4,\n};\nuse crate::test_util::generators::{\n    digits_valid, exhaustive_pairs_big_small, exhaustive_pairs_big_tiny, large_exponent,\n    signed_assign_bits_valid, smallest_invalid_value, unsigned_assign_bits_valid,\n};\nuse crate::test_util::num::arithmetic::mod_mul::limbs_invert_limb_naive;\nuse crate::test_util::num::conversion::string::from_sci_string::DECIMAL_SCI_STRING_CHARS;\nuse crate::test_util::num::float::PRIMITIVE_FLOAT_CHARS;\nuse crate::test_util::rounding_modes::ROUNDING_MODE_CHARS;\nuse crate::tuples::exhaustive::{\n    ExhaustiveDependentPairsYsGenerator, ExhaustivePairs, ExhaustivePairs1Input,\n    ExhaustiveQuadruples, ExhaustiveTriples, ExhaustiveTriplesXYY, exhaustive_dependent_pairs,\n    exhaustive_ordered_unique_pairs, exhaustive_pairs, exhaustive_pairs_from_single,\n    exhaustive_quadruples, exhaustive_triples, exhaustive_triples_custom_output,\n    exhaustive_triples_xyy, exhaustive_triples_xyy_custom_output, lex_pairs, lex_pairs_from_single,\n};\nuse crate::vecs::exhaustive::{\n    ExhaustiveFixedLengthVecs1Input, ExhaustiveVecs, LexFixedLengthVecsFromSingle, ShortlexVecs,\n    exhaustive_vecs, exhaustive_vecs_fixed_length_from_single,\n    exhaustive_vecs_length_inclusive_range, exhaustive_vecs_min_length,\n    lex_vecs_fixed_length_from_single, shortlex_vecs, shortlex_vecs_length_inclusive_range,\n    shortlex_vecs_min_length,\n};\nuse itertools::{Itertools, repeat_n};\nuse std::cmp::{max, min};\nuse std::iter::once;\nuse std::marker::PhantomData;\nuse std::vec::IntoIter;\n\n// general\n\nfn add_mul_inputs_valid<T: PrimitiveInt>(x: T, y: T, z: T) -> bool {\n    x.checked_add_mul(y, z).is_some()\n}\n\nfn sub_mul_inputs_valid<T: PrimitiveInt>(x: T, y: T, z: T) -> bool {\n    x.checked_sub_mul(y, z).is_some()\n}\n\n// -- bool --\n\npub fn exhaustive_bool_gen() -> It<bool> {\n    Box::new(exhaustive_bools())\n}\n\n// -- char --\n\npub fn exhaustive_char_gen() -> It<char> {\n    Box::new(exhaustive_chars())\n}\n\n#[allow(unstable_name_collisions)]\npub fn exhaustive_char_gen_var_1() -> It<char> {\n    Box::new(char::MIN..char::MAX)\n}\n\n#[allow(unstable_name_collisions)]\npub fn exhaustive_char_gen_var_2() -> It<char> {\n    Box::new('\\u{1}'..=char::MAX)\n}\n\n// -- (char, char) --\n\npub fn exhaustive_char_pair_gen() -> It<(char, char)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_chars()))\n}\n\n// -- FromSciStringOptions --\n\npub fn exhaustive_from_sci_string_options_gen() -> It<FromSciStringOptions> {\n    Box::new(exhaustive_from_sci_string_options())\n}\n\n// -- (FromSciStringOptions, PrimitiveUnsigned) --\n\npub fn exhaustive_from_sci_string_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(FromSciStringOptions, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_from_sci_string_options(),\n        primitive_int_increasing_inclusive_range(T::TWO, T::from(36u8)),\n    ))\n}\n\n// -- (FromSciStringOptions, RoundingMode) --\n\npub fn exhaustive_from_sci_string_options_rounding_mode_pair_gen()\n-> It<(FromSciStringOptions, RoundingMode)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_from_sci_string_options(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\n// -- PrimitiveFloat --\n\npub fn exhaustive_primitive_float_gen<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_primitive_floats())\n}\n\npub fn exhaustive_primitive_float_gen_var_1<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_primitive_float_range(\n        T::NEGATIVE_ONE / T::TWO,\n        T::INFINITY,\n    ))\n}\n\nstruct ExhaustivePositiveNaturalFloats<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    done: bool,\n    exponent: i64,\n    limit: u64,\n    mantissa: u64,\n}\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustivePositiveNaturalFloats<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.done {\n            None\n        } else {\n            let f = T::from_integer_mantissa_and_exponent(self.mantissa, self.exponent).unwrap();\n            if f == T::MAX_FINITE {\n                self.done = true;\n            } else {\n                self.mantissa += 1;\n                if self.mantissa == self.limit {\n                    self.mantissa >>= 1;\n                    self.exponent += 1;\n                    self.limit = u64::power_of_2(T::MANTISSA_WIDTH + 1);\n                }\n            }\n            Some(f)\n        }\n    }\n}\n\nfn exhaustive_positive_natural_floats<T: PrimitiveFloat>() -> ExhaustivePositiveNaturalFloats<T> {\n    ExhaustivePositiveNaturalFloats {\n        phantom: PhantomData,\n        done: false,\n        exponent: 0,\n        limit: u64::power_of_2(T::MANTISSA_WIDTH + 1),\n        mantissa: 1,\n    }\n}\n\npub fn exhaustive_primitive_float_gen_var_2<T: PrimitiveFloat>() -> It<T> {\n    Box::new(once(T::ZERO).chain(exhaustive_positive_natural_floats()))\n}\n\npub fn exhaustive_primitive_float_gen_var_3<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_positive_finite_primitive_floats::<T>().filter(|f| !f.is_integer()))\n}\n\npub fn exhaustive_primitive_float_gen_var_4<T: PrimitiveFloat>() -> It<T> {\n    let limit =\n        T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH)).unwrap();\n    Box::new(\n        exhaustive_positive_natural_floats::<T>()\n            .take_while(move |&f| f <= limit)\n            .map(|f| f - T::ONE / T::TWO),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_5<T: PrimitiveFloat>() -> It<T> {\n    Box::new(\n        lex_pairs(\n            exhaustive_primitive_float_gen_var_2::<T>(),\n            exhaustive_bools(),\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_6<T: PrimitiveFloat>() -> It<T> {\n    Box::new(\n        lex_pairs(\n            exhaustive_primitive_float_gen_var_3::<T>(),\n            exhaustive_bools(),\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_7<T: PrimitiveFloat>() -> It<T> {\n    Box::new(\n        lex_pairs(\n            exhaustive_primitive_float_gen_var_4::<T>(),\n            exhaustive_bools(),\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_8<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_finite_primitive_floats())\n}\n\npub fn exhaustive_primitive_float_gen_var_9<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_primitive_floats::<T>().filter(|&f| !f.is_nan() && f != T::INFINITY))\n}\n\npub fn exhaustive_primitive_float_gen_var_10<T: PrimitiveFloat>() -> It<T> {\n    Box::new(\n        exhaustive_primitive_floats::<T>().filter(|&f| !f.is_nan() && f != T::NEGATIVE_INFINITY),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_11<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_primitive_floats::<T>().filter(|&f| !f.is_nan()))\n}\n\npub fn exhaustive_primitive_float_gen_var_12<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_nonzero_finite_primitive_floats())\n}\n\npub fn exhaustive_primitive_float_gen_var_13<T: PrimitiveFloat, U: PrimitiveUnsigned>() -> It<T>\nwhere\n    NiceFloat<T>: TryFrom<U>,\n{\n    Box::new(\n        exhaustive_unsigneds::<U>().filter_map(|x| NiceFloat::<T>::try_from(x).ok().map(|x| x.0)),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_14<T: PrimitiveFloat, U: PrimitiveSigned>() -> It<T>\nwhere\n    NiceFloat<T>: TryFrom<U>,\n{\n    Box::new(\n        exhaustive_signeds::<U>().filter_map(|x| NiceFloat::<T>::try_from(x).ok().map(|x| x.0)),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_15<\n    T: PrimitiveFloat,\n    U: ConvertibleFrom<T> + PrimitiveInt,\n>() -> It<T> {\n    Box::new(exhaustive_primitive_floats::<T>().filter(|&f| !U::convertible_from(f)))\n}\n\npub fn exhaustive_primitive_float_gen_var_16<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned,\n>() -> It<T> {\n    let limit = min(\n        NiceFloat(T::rounding_from(U::MAX, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    Box::new(\n        exhaustive_positive_natural_floats::<T>()\n            .take_while(move |&f| f <= limit)\n            .map(|f| f - T::ONE / T::TWO),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_17<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned,\n>() -> It<T> {\n    let min_limit = min(\n        NiceFloat(-T::rounding_from(U::MIN, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    let max_limit = min(\n        NiceFloat(T::rounding_from(U::MAX, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    Box::new(\n        exhaustive_positive_natural_floats::<T>()\n            .take_while(move |&f| f <= max_limit)\n            .map(|f| f - T::ONE / T::TWO)\n            .interleave(\n                exhaustive_positive_natural_floats::<T>()\n                    .take_while(move |&f| f <= min_limit)\n                    .map(|f| T::ONE / T::TWO - f),\n            ),\n    )\n}\n\npub fn exhaustive_primitive_float_gen_var_18<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_positive_finite_primitive_floats::<T>())\n}\n\npub fn exhaustive_primitive_float_gen_var_19<T: PrimitiveFloat>() -> It<T> {\n    Box::new(exhaustive_primitive_float_range(\n        T::ZERO,\n        T::power_of_2(T::MAX_EXPONENT),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat) --\n\npub fn exhaustive_primitive_float_pair_gen<T: PrimitiveFloat>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_primitive_floats()))\n}\n\npub fn exhaustive_primitive_float_pair_gen_var_1<T: PrimitiveFloat>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_primitive_floats::<T>().filter(|&f| !f.is_nan()),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat, PrimitiveFloat) --\n\npub fn exhaustive_primitive_float_triple_gen<T: PrimitiveFloat>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_primitive_floats()))\n}\n\n// -- (PrimitiveFloat, PrimitiveInt) --\n\npub fn exhaustive_primitive_float_primitive_int_pair_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveInt,\n>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_finite_primitive_floats(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned) --\n\npub fn exhaustive_primitive_float_signed_pair_gen<T: PrimitiveFloat, U: PrimitiveSigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_primitive_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_primitive_float_signed_pair_gen_var_1<T: PrimitiveFloat, U: PrimitiveSigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_finite_primitive_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_primitive_float_signed_pair_gen_var_2<T: PrimitiveFloat>() -> It<(T, i64)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_primitive_float_range(T::ONE, T::TWO),\n            exhaustive_signed_inclusive_range(T::MIN_EXPONENT, T::MAX_EXPONENT),\n        )\n        .filter(|&(m, e)| m.precision() <= T::max_precision_for_sci_exponent(e)),\n    )\n}\n\npub fn exhaustive_primitive_float_signed_pair_gen_var_3<T: PrimitiveFloat>() -> It<(T, i64)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_primitive_float_range(T::ONE, T::TWO),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_primitive_float_signed_pair_gen_var_4<T: PrimitiveFloat, U: PrimitiveSigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_primitive_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn exhaustive_primitive_float_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>() -> It<(T, U, V)> {\n    reshape_1_2_to_3(Box::new(exhaustive_pairs_big_small(\n        exhaustive_primitive_floats(),\n        exhaustive_pairs(exhaustive_signeds(), exhaustive_positive_primitive_ints()),\n    )))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned) --\n\npub fn exhaustive_primitive_float_unsigned_pair_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_finite_primitive_floats(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_primitive_float_unsigned_pair_gen_var_2<T: PrimitiveFloat>() -> It<(T, u64)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_primitive_float_range(T::ONE, T::TWO),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_primitive_float_unsigned_pair_gen_var_3<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_primitive_floats(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(\n            exhaustive_positive_finite_primitive_floats(),\n            exhaustive_unsigneds(),\n        ),\n        exhaustive_rounding_modes(),\n    )))\n}\n\npub fn exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveFloat>()\n-> It<(T, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(\n            exhaustive_primitive_float_range(T::ONE, T::TWO),\n            exhaustive_unsigneds(),\n        ),\n        exhaustive_rounding_modes(),\n    )))\n}\n\n// var 3 is in malachite-float.\n\n// -- (PrimitiveFloat, RoundingMode) --\n\npub(crate) fn float_rounding_mode_filter_var_1<T: PrimitiveFloat>(p: &(T, RoundingMode)) -> bool {\n    let &(f, rm) = p;\n    match rm {\n        Floor | Up => f >= T::ZERO,\n        Ceiling | Down => f > T::NEGATIVE_ONE,\n        Nearest => f >= T::NEGATIVE_ONE / T::TWO,\n        Exact => f >= T::ZERO && f.is_integer(),\n    }\n}\n\npub fn exhaustive_primitive_float_rounding_mode_pair_gen_var_1<T: PrimitiveFloat>()\n-> It<(T, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_finite_primitive_floats(),\n            exhaustive_rounding_modes(),\n        )\n        .filter(float_rounding_mode_filter_var_1),\n    )\n}\n\npub fn exhaustive_primitive_float_rounding_mode_pair_gen_var_2<T: PrimitiveFloat>()\n-> It<(T, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_finite_primitive_floats::<T>(),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&(f, rm)| rm != Exact || f.is_integer()),\n    )\n}\n\npub fn exhaustive_primitive_float_rounding_mode_pair_gen_var_3<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: ConvertibleFrom<T> + PrimitiveInt,\n>() -> It<(T, RoundingMode)> {\n    let f_min = T::rounding_from(U::MIN, Down).0;\n    let f_max = T::rounding_from(U::MAX, Down).0;\n    Box::new(\n        lex_pairs(\n            exhaustive_primitive_floats::<T>().filter(|f| !f.is_nan()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(move |&(f, rm)| match rm {\n            Up => f >= f_min && f <= f_max,\n            Ceiling => f <= f_max,\n            Floor => f >= f_min,\n            Down | Nearest => true,\n            Exact => U::convertible_from(f),\n        }),\n    )\n}\n\n// -- PrimitiveInt --\n\npub fn exhaustive_primitive_int_gen_var_1<T: PrimitiveInt>() -> It<T> {\n    Box::new(exhaustive_positive_primitive_ints())\n}\n\npub fn exhaustive_primitive_int_gen_var_2<T: PrimitiveInt>() -> It<T> {\n    Box::new(primitive_int_increasing_inclusive_range(T::TWO, T::MAX))\n}\n\npub fn exhaustive_primitive_int_gen_var_3<T: PrimitiveInt>() -> It<T> {\n    Box::new(primitive_int_increasing_range(T::ZERO, T::exact_from(36)))\n}\n\npub fn exhaustive_primitive_int_gen_var_4<T: PrimitiveInt>() -> It<T> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        T::TWO,\n        T::exact_from(36),\n    ))\n}\n\npub fn exhaustive_primitive_int_gen_var_5<T: PrimitiveInt>() -> It<T> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        T::power_of_2(T::WIDTH - 2),\n        T::MAX,\n    ))\n}\n\npub fn exhaustive_primitive_int_gen_var_6<T: PrimitiveInt>() -> It<T> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        T::wrapping_from(5u8),\n        T::MAX,\n    ))\n}\n\n// -- (PrimitiveInt, PrimitiveInt) --\n\npub fn exhaustive_primitive_int_pair_gen_var_1<T: PrimitiveInt, U: ExactFrom<u8> + PrimitiveInt>()\n-> It<(T, U)> {\n    Box::new(lex_pairs(\n        exhaustive_positive_primitive_ints(),\n        primitive_int_increasing_inclusive_range(U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn exhaustive_primitive_int_pair_gen_var_2<T: PrimitiveInt, U: PrimitiveInt>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_primitive_ints(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_primitive_int_pair_gen_var_3<T: PrimitiveInt, U: PrimitiveInt>() -> T1<T, U> {\n    Box::new(exhaustive_pairs_big_small(\n        exhaustive_positive_primitive_ints(),\n        primitive_int_increasing_inclusive_range(U::TWO, U::MAX),\n    ))\n}\n\npub fn exhaustive_primitive_int_pair_gen_var_4<T: PrimitiveInt>() -> It<(T, T)> {\n    Box::new(exhaustive_ordered_unique_pairs(\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (PrimitiveInt, PrimitiveUnsigned) --\n\npub fn exhaustive_primitive_int_unsigned_pair_gen_var_1<T: PrimitiveInt, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_primitive_ints(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_primitive_int_unsigned_pair_gen_var_2<T: PrimitiveInt, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs(\n        primitive_int_increasing_inclusive_range(T::power_of_2(T::WIDTH - 2), T::MAX),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_primitive_int_unsigned_pair_gen_var_3<T: PrimitiveInt>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs_from_single(\n        primitive_int_increasing_inclusive_range(T::TWO, T::MAX),\n    ))\n}\n\n// -- (PrimitiveInt, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_primitive_int_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, U)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_positive_primitive_ints(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter_map(|(x, y, z): (T, U, U)| y.checked_add(z).map(|new_z| (x, y, new_z))),\n    )\n}\n\n// -- (PrimitiveInt, RoundingMode) --\n\npub fn exhaustive_primitive_int_rounding_mode_pair_gen_var_1<T: PrimitiveInt>()\n-> It<(T, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_positive_primitive_ints(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_primitive_int_rounding_mode_pair_gen_var_2<T: PrimitiveInt>()\n-> It<(T, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_positive_primitive_ints(),\n        exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n    ))\n}\n\n// -- PrimitiveSigned --\n\npub fn exhaustive_signed_gen<T: PrimitiveSigned>() -> It<T> {\n    Box::new(exhaustive_signeds())\n}\n\npub fn exhaustive_signed_gen_var_1<T: PrimitiveSigned>() -> It<T> {\n    Box::new(exhaustive_signed_inclusive_range(T::MIN + T::ONE, T::MAX))\n}\n\npub fn exhaustive_signed_gen_var_2<T: PrimitiveSigned>() -> It<T> {\n    Box::new(exhaustive_natural_signeds())\n}\n\npub fn exhaustive_signed_gen_var_3<T: PrimitiveSigned>() -> It<T> {\n    Box::new(exhaustive_signeds().filter(|&x| x != T::ZERO && x != T::NEGATIVE_ONE))\n}\n\npub fn exhaustive_signed_gen_var_4<T: PrimitiveSigned>() -> It<T> {\n    Box::new(exhaustive_negative_signeds())\n}\n\npub fn exhaustive_signed_gen_var_5<T: PrimitiveSigned>() -> It<T> {\n    Box::new(exhaustive_nonzero_signeds())\n}\n\npub fn exhaustive_signed_gen_var_6<T: PrimitiveSigned, U: ConvertibleFrom<T> + PrimitiveFloat>()\n-> It<T> {\n    Box::new(exhaustive_signeds().filter(|&x| U::convertible_from(x)))\n}\n\npub fn exhaustive_signed_gen_var_7<T: PrimitiveSigned, U: ConvertibleFrom<T> + PrimitiveFloat>()\n-> It<T> {\n    Box::new(\n        primitive_int_increasing_inclusive_range(\n            T::saturating_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n            T::MAX,\n        )\n        .interleave(\n            primitive_int_increasing_inclusive_range(\n                T::MIN,\n                T::saturating_from(U::SMALLEST_UNREPRESENTABLE_UINT).saturating_neg(),\n            )\n            .rev(),\n        )\n        .filter(|&x| !U::convertible_from(x)),\n    )\n}\n\npub fn exhaustive_signed_gen_var_8<T: PrimitiveSigned, U: ConvertibleFrom<T> + PrimitiveFloat>()\n-> It<T> {\n    Box::new(\n        iter_windows(\n            2,\n            primitive_int_increasing_inclusive_range(\n                T::exact_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n                T::MAX,\n            )\n            .filter(|&x| U::convertible_from(x)),\n        )\n        .filter_map(|xs| {\n            let mut xs = xs.into_iter();\n            let a = xs.next().unwrap();\n            let diff = xs.next().unwrap() - a;\n            if diff.even() {\n                // This happens almost always\n                Some(a + (diff >> 1))\n            } else {\n                None\n            }\n        })\n        .interleave(\n            iter_windows(\n                2,\n                primitive_int_increasing_inclusive_range(\n                    T::MIN,\n                    T::exact_from(U::SMALLEST_UNREPRESENTABLE_UINT)\n                        .checked_neg()\n                        .unwrap(),\n                )\n                .rev()\n                .filter(|&x| U::convertible_from(x)),\n            )\n            .filter_map(|xs| {\n                let mut xs = xs.into_iter();\n                let a = xs.next().unwrap();\n                let diff = a - xs.next().unwrap();\n                if diff.even() {\n                    // This happens almost always\n                    Some(a - (diff >> 1))\n                } else {\n                    None\n                }\n            }),\n        ),\n    )\n}\n\npub fn exhaustive_signed_gen_var_9<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> It<S> {\n    let limit = S::wrapping_from(U::wrapping_from(S::MAX).floor_sqrt());\n    Box::new(exhaustive_signed_inclusive_range(-limit, limit))\n}\n\npub fn exhaustive_signed_gen_var_10<T: PrimitiveFloat>() -> It<i64> {\n    Box::new(exhaustive_signed_inclusive_range(\n        T::MIN_EXPONENT,\n        T::MAX_EXPONENT,\n    ))\n}\n\npub fn exhaustive_signed_gen_var_11<T: PrimitiveSigned>() -> It<T> {\n    Box::new(exhaustive_signeds().filter(|&x| x != T::ZERO && x != T::MIN))\n}\n\npub fn exhaustive_signed_gen_var_12<T: PrimitiveSigned>() -> It<T> {\n    Box::new(\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 2))\n            .map(|u| (u << 1) | T::ONE),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned) --\n\npub fn exhaustive_signed_pair_gen<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_signeds()))\n}\n\npub fn exhaustive_signed_pair_gen_var_1<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_natural_signeds())\n            .interleave(exhaustive_pairs_from_single(exhaustive_negative_signeds())),\n    )\n}\n\npub fn exhaustive_signed_pair_gen_var_3<T: PrimitiveSigned, U: PrimitiveSigned>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_signeds(),\n        exhaustive_signeds(),\n    ))\n}\n\nstruct TakeWhileExtra<I: Iterator, P: Fn(&I::Item) -> bool> {\n    xs: I,\n    p: P,\n    false_seen: bool,\n}\n\nimpl<I: Iterator, P: Fn(&I::Item) -> bool> Iterator for TakeWhileExtra<I, P> {\n    type Item = I::Item;\n\n    fn next(&mut self) -> Option<I::Item> {\n        loop {\n            if let Some(x) = self.xs.next() {\n                if (self.p)(&x) {\n                    return Some(x);\n                } else if self.false_seen {\n                    return None;\n                }\n                self.false_seen = true;\n            } else {\n                return None;\n            }\n        }\n    }\n}\n\n#[inline]\nconst fn take_while_extra<I: Iterator, P: Fn(&I::Item) -> bool>(\n    xs: I,\n    p: P,\n) -> TakeWhileExtra<I, P> {\n    TakeWhileExtra {\n        xs,\n        p,\n        false_seen: false,\n    }\n}\n\nstruct SignedDivisiblePairsGenerator<T: PrimitiveSigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveSigned> ExhaustiveDependentPairsYsGenerator<T, T, It<T>>\n    for SignedDivisiblePairsGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, y: &T) -> It<T> {\n        // A simple take_while doesn't work. For example, if T is i8 and y is 64, trying to\n        // checked-multiply y by the exhaustive signeds gives [Some(0), Some(64), Some(-64), None,\n        // Some(-128), None, None, ...], where the first None corresponds to 128, which is not\n        // representable as an i8. Doing a take_while would lose the Some(-128). Instead, we use\n        // take_while_extra, which is like a take_while, but it waits until it sees a second None to\n        // stop iterating.\n        let y = *y;\n        Box::new(\n            take_while_extra(\n                exhaustive_signeds().map(move |k| y.checked_mul(k)),\n                Option::is_some,\n            )\n            .map(Option::unwrap),\n        )\n    }\n}\n\npub fn exhaustive_signed_pair_gen_var_4<T: PrimitiveSigned>() -> It<(T, T)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_nonzero_signeds(),\n        SignedDivisiblePairsGenerator {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_signed_pair_gen_var_5<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_signeds(), exhaustive_nonzero_signeds())\n            .filter(|&(x, y)| x != T::MIN || y != T::NEGATIVE_ONE),\n    )\n}\n\npub fn exhaustive_signed_pair_gen_var_6<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_signeds::<T>(), exhaustive_nonzero_signeds::<T>())\n            .filter(|&(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn exhaustive_signed_pair_gen_var_7<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_signeds(),\n        exhaustive_nonzero_signeds(),\n    ))\n}\n\npub fn exhaustive_signed_pair_gen_var_8<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_natural_signeds()))\n}\n\npub fn exhaustive_signed_pair_gen_var_9<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_signeds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 2))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\npub fn exhaustive_signed_pair_gen_var_10<T: PrimitiveSigned>() -> It<(T, T)>\nwhere\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    Box::new(\n        exhaustive_pairs_from_single(\n            primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 2))\n                .map(|u| (u << 1) | T::ONE),\n        )\n        .filter(|&(a, b): &(T, T)| a.unsigned_abs().coprime_with(b.unsigned_abs())),\n    )\n}\n\npub fn exhaustive_signed_pair_gen_var_11<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>() -> It<(S, S)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_signeds())\n            .filter(|&(x, y): &(S, S)| x.unsigned_abs().coprime_with(y.unsigned_abs())),\n    )\n}\n\npub fn exhaustive_signed_pair_gen_var_12<T: PrimitiveSigned, U: PrimitiveSigned>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs(exhaustive_signeds(), exhaustive_signeds()))\n}\n\npub fn exhaustive_signed_pair_gen_var_13<T: PrimitiveSigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_signeds())\n            .filter(|&(n, k)| T::checked_binomial_coefficient(n, k).is_some()),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned) --\n\npub fn exhaustive_signed_triple_gen<T: PrimitiveSigned>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_signeds()))\n}\n\npub fn exhaustive_signed_triple_gen_var_1<T: PrimitiveSigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_signeds())\n            .filter(|&(x, y, z)| add_mul_inputs_valid(x, y, z)),\n    )\n}\n\npub fn exhaustive_signed_triple_gen_var_2<T: PrimitiveSigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_signeds())\n            .filter(|&(x, y, z)| sub_mul_inputs_valid(x, y, z)),\n    )\n}\n\npub fn exhaustive_signed_triple_gen_var_3<T: PrimitiveSigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_natural_signeds())\n            .interleave(exhaustive_triples_from_single(exhaustive_negative_signeds())),\n    )\n}\n\nstruct SignedModEqTriplesInnerGenerator<U: PrimitiveUnsigned, S: PrimitiveSigned> {\n    phantom: PhantomData<(U, S)>,\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned + WrappingFrom<U>>\n    ExhaustiveDependentPairsYsGenerator<(U, U), (S, S), It<(S, S)>>\n    for SignedModEqTriplesInnerGenerator<U, S>\n{\n    #[inline]\n    fn get_ys(&self, p: &(U, U)) -> It<(S, S)> {\n        let &(m, k) = p;\n        if k == U::ZERO {\n            Box::new(exhaustive_signeds().map(|x| (x, x)))\n        } else {\n            let d = m.checked_mul(k).unwrap();\n            let d_s = S::wrapping_from(d);\n            Box::new(\n                exhaustive_signed_inclusive_range(S::MIN, S::MAX.wrapping_sub(d_s))\n                    .map(move |n| (n, n.wrapping_add(d_s)))\n                    .interleave(\n                        exhaustive_signed_inclusive_range(S::MIN, S::MAX.wrapping_sub(d_s))\n                            .map(move |n| (n.wrapping_add(d_s), n)),\n                    ),\n            )\n        }\n    }\n}\n\nstruct SignedModEqTriplesGenerator<U: PrimitiveUnsigned, S: PrimitiveSigned> {\n    phantom: PhantomData<(U, S)>,\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>>\n    ExhaustiveDependentPairsYsGenerator<S, (S, S), It<(S, S)>>\n    for SignedModEqTriplesGenerator<U, S>\n{\n    #[inline]\n    fn get_ys(&self, m: &S) -> It<(S, S)> {\n        let m = *m;\n        let m_abs = m.unsigned_abs();\n        if m == S::ZERO {\n            Box::new(exhaustive_signeds().map(|x| (x, x)))\n        } else {\n            Box::new(\n                exhaustive_dependent_pairs(\n                    bit_distributor_sequence(\n                        BitDistributorOutputType::normal(1),\n                        BitDistributorOutputType::normal(1),\n                    ),\n                    primitive_int_increasing_inclusive_range(U::ZERO, U::MAX / m_abs)\n                        .map(move |k| (m_abs, k)),\n                    SignedModEqTriplesInnerGenerator {\n                        phantom: PhantomData,\n                    },\n                )\n                .map(|p| p.1),\n            )\n        }\n    }\n}\n\npub fn exhaustive_signed_triple_gen_var_4<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() -> It<(S, S, S)> {\n    reshape_2_1_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_signeds(),\n        SignedModEqTriplesGenerator {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_signed_triple_gen_var_5<T: PrimitiveSigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_signeds::<T>())\n            .filter(|&(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\npub fn exhaustive_signed_triple_gen_var_6<T: PrimitiveSigned>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_signeds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 2))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\npub fn exhaustive_signed_triple_gen_var_7<T: PrimitiveSigned>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_signeds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 2))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned, PrimitiveSigned) --\n\npub fn exhaustive_signed_quadruple_gen<T: PrimitiveSigned>() -> It<(T, T, T, T)> {\n    Box::new(exhaustive_quadruples_from_single(exhaustive_signeds()))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn exhaustive_signed_signed_signed_unsigned_quadruple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, T, T, U)> {\n    Box::new(exhaustive_quadruples_xxxy_custom_output(\n        exhaustive_signeds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveUnsigned) --\n\nstruct SignedModPow2EqTriplesInnerGenerator<U: PrimitiveUnsigned, S: PrimitiveSigned> {\n    phantom: PhantomData<(U, S)>,\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned + WrappingFrom<U>>\n    ExhaustiveDependentPairsYsGenerator<(u64, U), (S, S), It<(S, S)>>\n    for SignedModPow2EqTriplesInnerGenerator<U, S>\n{\n    #[inline]\n    fn get_ys(&self, p: &(u64, U)) -> It<(S, S)> {\n        let &(pow, k) = p;\n        if k == U::ZERO {\n            Box::new(exhaustive_signeds().map(|x| (x, x)))\n        } else {\n            let d = k << pow;\n            let d_s = S::wrapping_from(d);\n            Box::new(\n                exhaustive_signed_inclusive_range(S::MIN, S::MAX.wrapping_sub(d_s))\n                    .map(move |n| (n, n.wrapping_add(d_s)))\n                    .interleave(\n                        exhaustive_signed_inclusive_range(S::MIN, S::MAX.wrapping_sub(d_s))\n                            .map(move |n| (n.wrapping_add(d_s), n)),\n                    ),\n            )\n        }\n    }\n}\n\nstruct SignedModPow2EqTriplesGenerator<U: PrimitiveUnsigned, S: PrimitiveSigned> {\n    phantom: PhantomData<(U, S)>,\n}\n\nimpl<U: PrimitiveUnsigned, S: PrimitiveSigned + WrappingFrom<U>>\n    ExhaustiveDependentPairsYsGenerator<u64, (S, S), It<(S, S)>>\n    for SignedModPow2EqTriplesGenerator<U, S>\n{\n    #[inline]\n    fn get_ys(&self, pow: &u64) -> It<(S, S)> {\n        let pow = *pow;\n        if pow >= S::WIDTH {\n            Box::new(exhaustive_signeds().map(|x| (x, x)))\n        } else {\n            Box::new(\n                exhaustive_dependent_pairs(\n                    bit_distributor_sequence(\n                        BitDistributorOutputType::normal(1),\n                        BitDistributorOutputType::normal(1),\n                    ),\n                    primitive_int_increasing_inclusive_range(U::ZERO, U::MAX >> pow)\n                        .map(move |k| (pow, k)),\n                    SignedModPow2EqTriplesInnerGenerator {\n                        phantom: PhantomData,\n                    },\n                )\n                .map(|p| p.1),\n            )\n        }\n    }\n}\n\npub fn exhaustive_signed_signed_unsigned_triple_gen_var_1<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> It<(S, S, u64)> {\n    reshape_2_1_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_unsigneds(),\n        SignedModPow2EqTriplesGenerator::<U, S> {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_signed_signed_unsigned_triple_gen_var_2<T: PrimitiveSigned>() -> It<(T, T, u64)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_signeds::<T>(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter(|&(x, y, pow)| !x.eq_mod_power_of_2(y, pow)),\n    )\n}\n\npub fn exhaustive_signed_signed_unsigned_triple_gen_var_3<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>() -> It<(T, U, V)> {\n    reshape_1_2_to_3(Box::new(exhaustive_pairs_big_small(\n        exhaustive_signeds(),\n        exhaustive_pairs(exhaustive_signeds(), exhaustive_positive_primitive_ints()),\n    )))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, RoundingMode) --\n\npub fn exhaustive_signed_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(T, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs(exhaustive_signeds::<T>(), exhaustive_nonzero_signeds::<T>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, y), rm)| {\n            (x != T::MIN || y != T::NEGATIVE_ONE) && (rm != Exact || x.divisible_by(y))\n        }),\n    ))\n}\n\nfn round_to_multiple_unsigned_helper<T: PrimitiveUnsigned>(x: T, y: T, rm: RoundingMode) -> bool {\n    if x == y {\n        true\n    } else if y == T::ZERO {\n        rm == Down || rm == Floor || rm == Nearest\n    } else {\n        x.div_round(y, rm).0.checked_mul(y).is_some()\n    }\n}\n\nfn round_to_multiple_signed_helper<\n    U: PrimitiveUnsigned,\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: S,\n    y: S,\n    rm: RoundingMode,\n) -> bool {\n    let x_abs = x.unsigned_abs();\n    let y_abs = y.unsigned_abs();\n    if x >= S::ZERO {\n        round_to_multiple_unsigned_helper(x_abs, y_abs, rm)\n            && S::convertible_from(x_abs.round_to_multiple(y_abs, rm).0)\n    } else if !round_to_multiple_unsigned_helper(x_abs, y_abs, -rm) {\n        false\n    } else {\n        let abs_result = x_abs.round_to_multiple(y_abs, -rm).0;\n        abs_result == S::MIN.unsigned_abs()\n            || S::try_from(abs_result)\n                .ok()\n                .and_then(CheckedNeg::checked_neg)\n                .is_some()\n    }\n}\n\npub(crate) fn round_to_multiple_signed_filter_map<\n    U: PrimitiveUnsigned,\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    x: S,\n    y: S,\n    rm: RoundingMode,\n) -> Option<(S, S, RoundingMode)> {\n    if rm == Exact {\n        x.checked_mul(y).map(|product| (product, y, rm))\n    } else if round_to_multiple_signed_helper(x, y, rm) {\n        Some((x, y, rm))\n    } else {\n        None\n    }\n}\n\npub fn exhaustive_signed_signed_rounding_mode_triple_gen_var_2<\n    U: PrimitiveUnsigned,\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>() -> It<(S, S, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs(exhaustive_signeds(), exhaustive_nonzero_signeds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter_map(|((x, y), rm)| round_to_multiple_signed_filter_map::<U, S>(x, y, rm)),\n    )\n}\n\npub fn exhaustive_signed_signed_rounding_mode_triple_gen_var_3<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_signeds::<T>(), exhaustive_signeds::<U>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, pow), rm)| {\n            rm != Exact || pow <= U::ZERO || x.divisible_by_power_of_2(pow.exact_into())\n        }),\n    ))\n}\n\npub fn exhaustive_signed_signed_rounding_mode_triple_gen_var_4<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_signeds::<T>(), exhaustive_signeds::<U>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, pow), rm)| {\n            let pow: i64 = pow.exact_into();\n            rm != Exact || pow >= 0 || x.divisible_by_power_of_2(pow.unsigned_abs())\n        }),\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn exhaustive_signed_unsigned_pair_gen<T: PrimitiveSigned, U: PrimitiveUnsigned>() -> It<(T, U)>\n{\n    Box::new(exhaustive_pairs(\n        exhaustive_signeds(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_2<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_signeds(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_3<T: PrimitiveSigned>() -> It<(T, u64)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_natural_signeds(),\n            primitive_int_increasing_range(0, T::WIDTH),\n        )\n        .interleave(exhaustive_pairs(\n            exhaustive_negative_signeds(),\n            exhaustive_unsigneds(),\n        )),\n    )\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_4<T: PrimitiveSigned>() -> It<(T, u64)> {\n    Box::new(lex_pairs(\n        exhaustive_signeds(),\n        primitive_int_increasing_range(0, T::WIDTH),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_5<T: PrimitiveSigned>() -> It<(T, u64)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_negative_signeds(),\n            primitive_int_increasing_range(0, T::WIDTH),\n        )\n        .interleave(exhaustive_pairs(\n            exhaustive_natural_signeds(),\n            exhaustive_unsigneds(),\n        )),\n    )\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_6<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>() -> It<(T, U)> {\n    Box::new(lex_pairs(\n        exhaustive_signeds(),\n        primitive_int_increasing_inclusive_range(U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_7<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_natural_signeds(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_8<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>() -> It<(T, U)> {\n    Box::new(lex_pairs(\n        exhaustive_natural_signeds(),\n        primitive_int_increasing_inclusive_range(U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_9<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_signeds::<T>(), exhaustive_unsigneds::<U>())\n            .filter(|&(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\nstruct SignedDivisibleByP2PairsGenerator<T: PrimitiveSigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveSigned> ExhaustiveDependentPairsYsGenerator<u64, T, It<T>>\n    for SignedDivisibleByP2PairsGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, pow: &u64) -> It<T> {\n        let pow = *pow;\n        if pow >= T::WIDTH {\n            Box::new(once(T::ZERO))\n        } else if pow == 0 {\n            Box::new(exhaustive_signeds())\n        } else {\n            Box::new(\n                exhaustive_signed_inclusive_range(\n                    -T::low_mask(T::WIDTH - pow),\n                    T::low_mask(T::WIDTH - pow),\n                )\n                .map(move |k| k << pow),\n            )\n        }\n    }\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_10<T: PrimitiveSigned>() -> It<(T, u64)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_unsigneds(),\n        SignedDivisibleByP2PairsGenerator {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_11<T: PrimitiveSigned>() -> It<(T, u64)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_natural_signeds(), exhaustive_unsigneds()).interleave(\n            exhaustive_pairs_big_tiny(\n                exhaustive_signeds(),\n                primitive_int_increasing_inclusive_range(0, T::WIDTH),\n            ),\n        ),\n    )\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_12<T: PrimitiveSigned>() -> It<(T, u64)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_signed_range(T::MIN + T::ONE, T::ONE),\n            exhaustive_unsigneds(),\n        )\n        .interleave(exhaustive_pairs_big_tiny(\n            exhaustive_signeds(),\n            primitive_int_increasing_range(0, T::WIDTH),\n        )),\n    )\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_13<T: PrimitiveSigned, U: PrimitiveInt>()\n-> It<(T, u64)> {\n    Box::new(lex_pairs(\n        exhaustive_signeds(),\n        primitive_int_increasing_inclusive_range(0, U::WIDTH),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_14<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_signed_inclusive_range(\n            if T::WIDTH <= u64::WIDTH {\n                T::MIN\n            } else {\n                -T::exact_from(u64::MAX)\n            },\n            T::saturating_from(u64::MAX),\n        ),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_15<T: PrimitiveSigned>() -> It<(T, u64)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_signeds::<T>(), exhaustive_unsigneds())\n            .filter(|&(x, y)| x.checked_pow(y).is_some()),\n    )\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_16<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_signed_range(T::MIN + T::ONE, T::ZERO),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_17<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_natural_signeds(),\n            exhaustive_positive_primitive_ints(),\n        )\n        .interleave(exhaustive_pairs_big_tiny(\n            exhaustive_negative_signeds(),\n            exhaustive_unsigneds::<U>()\n                .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | U::ONE)),\n        )),\n    )\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_18<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_signeds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_pair_gen_var_19<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_signeds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, bool) --\n\npub fn exhaustive_signed_unsigned_bool_triple_gen_var_1<T: PrimitiveSigned>() -> It<(T, u64, bool)>\n{\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_signeds(), exhaustive_unsigneds())\n            .map(|(x, y)| (x, y, x < T::ZERO))\n            .interleave(\n                lex_pairs(\n                    exhaustive_signeds(),\n                    primitive_int_increasing_range(0, T::WIDTH),\n                )\n                .map(|(x, y)| (x, y, x >= T::ZERO)),\n            ),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_signed_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> It<(T, U, V)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_signeds(),\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, U)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_positive_primitive_ints(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .interleave(exhaustive_triples_custom_output(\n            exhaustive_signed_inclusive_range(T::MIN, T::ZERO),\n            exhaustive_unsigneds(),\n            primitive_int_increasing_inclusive_range(U::ZERO, U::exact_from(T::WIDTH)),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        ))\n        .filter_map(|(x, y, z)| y.checked_add(z).map(|new_z| (x, y, new_z))),\n    )\n}\n\npub fn exhaustive_signed_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> It<(T, U, V)> {\n    permute_1_3_2(reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_signeds(), exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(U::TWO, U::exact_from(36u8)),\n    ))))\n}\n\npub fn exhaustive_signed_unsigned_unsigned_triple_gen_var_4<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, T, U)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_signeds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_signed_unsigned_unsigned_unsigned_quadruple_gen_var_1<\n    T: PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n>() -> It<(T, u64, u64, U)> {\n    Box::new(\n        exhaustive_quadruples_xyyz_custom_output(\n            exhaustive_signeds(),\n            exhaustive_unsigneds(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        )\n        .filter_map(|(x, y, z, w): (T, u64, u64, U)| {\n            y.checked_add(z).and_then(|new_z| {\n                if signed_assign_bits_valid(x, y, new_z, w) {\n                    Some((x, y, new_z, w))\n                } else {\n                    None\n                }\n            })\n        }),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_signed_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(T, u64, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_signeds::<T>(), exhaustive_unsigneds::<u64>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter_map(|((x, pow), rm)| round_to_multiple_of_power_of_2_filter_map(x, pow, rm)),\n    )\n}\n\npub fn exhaustive_signed_unsigned_rounding_mode_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_signeds::<T>(), exhaustive_unsigneds::<U>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, y), rm)| rm != Exact || x.divisible_by_power_of_2(y.exact_into())),\n    ))\n}\n\n// var 3 through 5 are in malachite-float.\n\npub fn exhaustive_signed_unsigned_rounding_mode_triple_gen_var_6<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs(\n            exhaustive_signeds::<T>(),\n            exhaustive_positive_primitive_ints::<U>(),\n        ),\n        exhaustive_rounding_modes(),\n    )))\n}\n\n// -- (PrimitiveSigned, RoundingMode) --\n\npub fn exhaustive_signed_rounding_mode_pair_gen<T: PrimitiveSigned>() -> It<(T, RoundingMode)> {\n    Box::new(lex_pairs(exhaustive_signeds(), exhaustive_rounding_modes()))\n}\n\npub fn exhaustive_signed_rounding_mode_pair_gen_var_1<T: PrimitiveSigned>() -> It<(T, RoundingMode)>\n{\n    Box::new(lex_pairs(\n        exhaustive_nonzero_signeds(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_signed_rounding_mode_pair_gen_var_2<T: PrimitiveSigned>() -> It<(T, RoundingMode)>\n{\n    Box::new(lex_pairs(\n        exhaustive_signed_inclusive_range(T::MIN + T::ONE, T::MAX),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_signed_rounding_mode_pair_gen_var_3<T: PrimitiveSigned>() -> It<(T, RoundingMode)>\n{\n    Box::new(lex_pairs(\n        exhaustive_nonzero_signeds().filter(|&x| x != T::MIN),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_signed_rounding_mode_pair_gen_var_4<\n    T: PrimitiveSigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>() -> It<(T, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_signeds(), exhaustive_rounding_modes())\n            .filter(|&(i, rm)| rm != Exact || U::convertible_from(i)),\n    )\n}\n\n// -- (PrimitiveSigned, ToSciOptions) --\n\npub fn exhaustive_signed_to_sci_options_pair_gen<T: PrimitiveSigned>() -> It<(T, ToSciOptions)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_signeds(),\n        exhaustive_to_sci_options(),\n    ))\n}\n\ntype TSO = ToSciOptions;\npub fn exhaustive_signed_to_sci_options_pair_gen_var_1<T: PrimitiveSigned>() -> It<(T, TSO)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_signeds::<T>(), exhaustive_to_sci_options())\n            .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- (PrimitiveSigned, Vec<bool>) --\n\nstruct SignedBoolVecPairGeneratorVar1;\n\nimpl<T: PrimitiveSigned>\n    ExhaustiveDependentPairsYsGenerator<T, Vec<bool>, LexFixedLengthVecsFromSingle<ExhaustiveBools>>\n    for SignedBoolVecPairGeneratorVar1\n{\n    #[inline]\n    fn get_ys(&self, &x: &T) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(\n            u64::exact_from(x.to_bits_asc().len()),\n            exhaustive_bools(),\n        )\n    }\n}\n\npub fn exhaustive_signed_bool_vec_pair_gen_var_1<T: PrimitiveSigned>() -> It<(T, Vec<bool>)> {\n    Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_signeds(),\n        SignedBoolVecPairGeneratorVar1,\n    ))\n}\n\n// -- PrimitiveUnsigned --\n\npub fn exhaustive_unsigned_gen<T: PrimitiveUnsigned>() -> It<T> {\n    Box::new(exhaustive_unsigneds())\n}\n\npub fn exhaustive_unsigned_gen_var_1() -> It<u32> {\n    Box::new(primitive_int_increasing_range(0, NUMBER_OF_CHARS))\n}\n\npub fn exhaustive_unsigned_gen_var_2<T: PrimitiveInt>() -> It<u64> {\n    Box::new(primitive_int_increasing_inclusive_range(1, T::WIDTH))\n}\n\npub fn exhaustive_unsigned_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() -> It<U> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        U::TWO,\n        U::saturating_from(T::MAX),\n    ))\n}\n\npub fn exhaustive_unsigned_gen_var_5<T: PrimitiveInt>() -> It<u64> {\n    Box::new(primitive_int_increasing_inclusive_range(0, T::WIDTH))\n}\n\npub fn exhaustive_unsigned_gen_var_6() -> It<u8> {\n    Box::new(\n        lex_union3s(\n            primitive_int_increasing_inclusive_range(b'0', b'9'),\n            primitive_int_increasing_inclusive_range(b'a', b'z'),\n            primitive_int_increasing_inclusive_range(b'A', b'Z'),\n        )\n        .map(Union3::unwrap),\n    )\n}\n\npub fn exhaustive_unsigned_gen_var_7<T: PrimitiveUnsigned>() -> It<T> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        T::power_of_2(T::WIDTH - 1),\n        T::MAX,\n    ))\n}\n\npub fn exhaustive_unsigned_gen_var_8<T: PrimitiveFloat>() -> It<u64> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        0,\n        T::LARGEST_ORDERED_REPRESENTATION,\n    ))\n}\n\npub fn exhaustive_unsigned_gen_var_9<T: PrimitiveUnsigned>() -> It<T> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        T::ZERO,\n        T::power_of_2(T::WIDTH - 1),\n    ))\n}\n\npub fn exhaustive_unsigned_gen_var_10<T: PrimitiveInt>() -> It<u64> {\n    Box::new(primitive_int_increasing_range(0, T::WIDTH))\n}\n\npub fn exhaustive_unsigned_gen_var_11<T: PrimitiveInt>() -> It<u64> {\n    Box::new(primitive_int_increasing_inclusive_range(0, T::WIDTH - 2))\n}\n\npub fn exhaustive_unsigned_gen_var_12<\n    T: PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>() -> It<T> {\n    Box::new(exhaustive_unsigneds().filter(|&x| U::convertible_from(x)))\n}\n\npub fn exhaustive_unsigned_gen_var_13<\n    T: PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>() -> It<T> {\n    Box::new(\n        primitive_int_increasing_inclusive_range(\n            T::saturating_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n            T::MAX,\n        )\n        .filter(|&x| !U::convertible_from(x)),\n    )\n}\n\npub fn exhaustive_unsigned_gen_var_14<\n    T: PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>() -> It<T> {\n    Box::new(\n        iter_windows(\n            2,\n            primitive_int_increasing_inclusive_range(\n                T::exact_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n                T::MAX,\n            )\n            .filter(|&x| U::convertible_from(x)),\n        )\n        .filter_map(|xs| {\n            let mut xs = xs.into_iter();\n            let a = xs.next().unwrap();\n            let diff = xs.next().unwrap() - a;\n            if diff.even() {\n                // This happens almost always\n                Some(a + (diff >> 1))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_gen_var_15<T: PrimitiveUnsigned>() -> It<T> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        T::ZERO,\n        T::MAX.floor_sqrt(),\n    ))\n}\n\npub fn exhaustive_unsigned_gen_var_22<T: PrimitiveUnsigned>() -> It<T> {\n    Box::new(\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n    )\n}\n\npub fn exhaustive_unsigned_gen_var_23<T: PrimitiveUnsigned>() -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_factorial);\n    Box::new(primitive_int_increasing_range(0, limit))\n}\n\npub fn exhaustive_unsigned_gen_var_24<T: PrimitiveUnsigned>() -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_double_factorial);\n    Box::new(primitive_int_increasing_range(0, limit))\n}\n\npub fn exhaustive_unsigned_gen_var_25<T: PrimitiveUnsigned>() -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_subfactorial);\n    Box::new(primitive_int_increasing_range(0, limit))\n}\n\npub fn exhaustive_unsigned_gen_var_26<T: PrimitiveUnsigned>() -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_primorial);\n    Box::new(primitive_int_increasing_range(0, limit))\n}\n\npub fn exhaustive_unsigned_gen_var_27<T: PrimitiveUnsigned>() -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_product_of_first_n_primes);\n    Box::new(primitive_int_increasing_range(0, limit))\n}\n\npub fn exhaustive_unsigned_gen_var_28<T: PrimitiveUnsigned>() -> It<T> {\n    Box::new(T::primes())\n}\n\npub fn exhaustive_unsigned_gen_var_29<T: PrimitiveFloat>() -> It<u64> {\n    Box::new(primitive_int_increasing_inclusive_range(\n        0,\n        u64::exact_from(T::MAX_EXPONENT),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveInt) --\n\npub fn exhaustive_unsigned_primitive_int_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_unsigneds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_primitive_int_pair_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveInt,\n>() -> It<(T, U)> {\n    Box::new(lex_pairs(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn exhaustive_unsigned_primitive_int_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_unsigneds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveInt, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_primitive_int_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n    V: PrimitiveUnsigned,\n>() -> It<(T, u64, V)> {\n    Box::new(exhaustive_triples(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(1, U::WIDTH),\n        exhaustive_unsigneds(),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned) --\n\npub fn exhaustive_unsigned_signed_pair_gen<T: PrimitiveUnsigned, U: PrimitiveSigned>() -> It<(T, U)>\n{\n    Box::new(exhaustive_pairs(\n        exhaustive_unsigneds(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_unsigned_signed_pair_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveSigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_unsigneds(),\n        exhaustive_signeds(),\n    ))\n}\n\nstruct IntegerMantissaAndExponentGenerator<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveFloat> ExhaustiveDependentPairsYsGenerator<(u64, i64), (u64, i64), It<(u64, i64)>>\n    for IntegerMantissaAndExponentGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, p: &(u64, i64)) -> It<(u64, i64)> {\n        let &(mantissa, exponent) = p;\n        Box::new(exhaustive_natural_signeds().filter_map(move |i| {\n            Some((\n                mantissa.arithmetic_checked_shl(i)?,\n                exponent.checked_sub(i)?,\n            ))\n        }))\n    }\n}\n\npub fn exhaustive_unsigned_signed_pair_gen_var_2<T: PrimitiveFloat>() -> It<(u64, i64)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_positive_finite_primitive_floats().map(T::integer_mantissa_and_exponent),\n            IntegerMantissaAndExponentGenerator::<T> {\n                phantom: PhantomData,\n            },\n        )\n        .map(|p| p.1),\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned, PrimitiveUnsigned) --\n\nstruct ModPowerOf2PairWithExtraSignedGenerator<T: PrimitiveUnsigned, U: PrimitiveSigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\ntype LongType<T, U> = ExhaustivePairs<T, PrimitiveIntIncreasingRange<T>, U, ExhaustiveSigneds<U>>;\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveSigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (T, U),\n        ExhaustivePairs<T, PrimitiveIntIncreasingRange<T>, U, ExhaustiveSigneds<U>>,\n    > for ModPowerOf2PairWithExtraSignedGenerator<T, U>\n{\n    #[inline]\n    fn get_ys(&self, &pow: &u64) -> LongType<T, U> {\n        exhaustive_pairs(\n            primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(pow)),\n            exhaustive_signeds(),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>() -> It<(T, U, u64)> {\n    reshape_2_1_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(0, T::WIDTH),\n        ModPowerOf2PairWithExtraSignedGenerator::<T, U> {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_unsigned_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>() -> It<(T, U, T)> {\n    Box::new(\n        exhaustive_triples_xyx(\n            exhaustive_unsigneds(),\n            exhaustive_signed_inclusive_range(\n                if U::WIDTH <= u64::WIDTH {\n                    U::MIN\n                } else {\n                    -U::exact_from(u64::MAX)\n                },\n                U::saturating_from(u64::MAX),\n            ),\n        )\n        .filter_map(|(x, y, z): (T, U, T)| Some((x, y, x.checked_add(z)?.checked_add(T::ONE)?))),\n    )\n}\n\npub fn exhaustive_unsigned_signed_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>() -> It<(T, U, T)> {\n    Box::new(\n        exhaustive_triples_xyx(exhaustive_unsigneds(), exhaustive_signeds()).filter_map(\n            |(x, y, z): (T, U, T)| Some((x, y, x.checked_add(z)?.checked_add(T::ONE)?)),\n        ),\n    )\n}\n\npub fn exhaustive_unsigned_signed_unsigned_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>() -> It<(T, U, V)> {\n    reshape_1_2_to_3(Box::new(exhaustive_pairs_big_small(\n        exhaustive_unsigneds(),\n        exhaustive_pairs(exhaustive_signeds(), exhaustive_positive_primitive_ints()),\n    )))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned, RoundingMode) --\n\npub fn exhaustive_unsigned_signed_rounding_mode_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_unsigneds::<T>(), exhaustive_signeds::<U>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, pow), rm)| {\n            rm != Exact || pow <= U::ZERO || x.divisible_by_power_of_2(pow.exact_into())\n        }),\n    ))\n}\n\npub fn exhaustive_unsigned_signed_rounding_mode_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_unsigneds::<T>(), exhaustive_signeds::<U>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, pow), rm)| {\n            let pow: i64 = pow.exact_into();\n            rm != Exact || pow >= 0 || x.divisible_by_power_of_2(pow.unsigned_abs())\n        }),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_pair_gen<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_1() -> It<(u32, u32)> {\n    Box::new(exhaustive_pairs_from_single(\n        primitive_int_increasing_range(0, NUMBER_OF_CHARS),\n    ))\n}\n\ntype T1<T, U> = It<(T, U)>;\n\npub fn exhaustive_unsigned_pair_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> T1<T, U>\n{\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> It<(T, u64)> {\n    Box::new(lex_pairs(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_range(0, T::WIDTH),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveInt>() -> It<(T, u64)> {\n    Box::new(lex_pairs(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(1, U::WIDTH),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_5<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() -> It<(T, U)> {\n    Box::new(exhaustive_pairs_big_small(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(U::TWO, U::saturating_from(T::MAX)),\n    ))\n}\n\n// TODO make better\npub fn exhaustive_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x <= y))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_7<\n    T: PrimitiveInt + SaturatingFrom<U>,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> It<(T, V)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        primitive_int_increasing_inclusive_range(T::TWO, T::saturating_from(U::MAX)),\n        exhaustive_unsigneds(),\n    ))\n}\n\nstruct UnsignedDivisiblePairsGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<T, T, It<T>>\n    for UnsignedDivisiblePairsGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, y: &T) -> It<T> {\n        let y = *y;\n        Box::new(\n            exhaustive_unsigneds()\n                .map(move |k| y.checked_mul(k))\n                .take_while(Option::is_some)\n                .map(Option::unwrap),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_positive_primitive_ints(),\n        UnsignedDivisiblePairsGenerator {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_9<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> T1<T, U>\n{\n    Box::new(exhaustive_pairs(\n        exhaustive_unsigneds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_10<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_unsigneds::<T>(),\n            exhaustive_positive_primitive_ints::<T>(),\n        )\n        .filter(|&(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_11<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> T1<T, U>\n{\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_unsigneds::<T>(), exhaustive_unsigneds::<U>())\n            .filter(|&(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\nstruct UnsignedDivisibleByP2PairsGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<u64, T, It<T>>\n    for UnsignedDivisibleByP2PairsGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, pow: &u64) -> It<T> {\n        let pow = *pow;\n        if pow >= T::WIDTH {\n            Box::new(once(T::ZERO))\n        } else {\n            Box::new(\n                primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - pow))\n                    .map(move |k| k << pow),\n            )\n        }\n    }\n}\n\npub fn exhaustive_unsigned_pair_gen_var_12<T: PrimitiveUnsigned>() -> It<(T, u64)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_unsigneds(),\n        UnsignedDivisibleByP2PairsGenerator {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_13<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(exhaustive_ordered_unique_pairs(exhaustive_unsigneds()))\n}\n\nstruct ModPowerOf2SingleGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<u64, T, PrimitiveIntIncreasingRange<T>>\n    for ModPowerOf2SingleGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &pow: &u64) -> PrimitiveIntIncreasingRange<T> {\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(pow))\n    }\n}\n\nstruct ModPowerOf2SingleGenerator2<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<u64, T, PrimitiveIntIncreasingRange<T>>\n    for ModPowerOf2SingleGenerator2<T>\n{\n    #[inline]\n    fn get_ys(&self, &pow: &u64) -> PrimitiveIntIncreasingRange<T> {\n        primitive_int_increasing_inclusive_range(T::ONE, T::low_mask(pow))\n    }\n}\n\npub fn exhaustive_unsigned_pair_gen_var_14<T: PrimitiveUnsigned>() -> It<(T, u64)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(0, T::WIDTH),\n        ModPowerOf2SingleGenerator {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_15<T: PrimitiveUnsigned>() -> It<(T, u64)> {\n    Box::new(\n        exhaustive_unsigneds()\n            .map(|x| (T::ZERO, x))\n            .interleave(exhaustive_pairs_big_tiny(\n                exhaustive_positive_primitive_ints(),\n                primitive_int_increasing_range(0, T::WIDTH),\n            )),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_16<T: PrimitiveFloat>() -> It<(u64, u64)> {\n    Box::new(exhaustive_pairs_from_single(\n        primitive_int_increasing_inclusive_range(0, T::LARGEST_ORDERED_REPRESENTATION),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_17<T: PrimitiveUnsigned, U: PrimitiveInt>() -> It<(T, u64)>\n{\n    Box::new(lex_pairs(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(0, U::WIDTH),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_18<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U)> {\n    Box::new(exhaustive_pairs(\n        primitive_int_increasing_inclusive_range(T::ZERO, T::saturating_from(u64::MAX)),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_19<T: PrimitiveFloat>() -> It<(u64, u64)> {\n    Box::new(exhaustive_pairs(\n        primitive_int_increasing_range(0, u64::power_of_2(T::MANTISSA_WIDTH)),\n        primitive_int_increasing_range(0, u64::power_of_2(T::EXPONENT_WIDTH)),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_20<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_unsigneds()))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_21<T: PrimitiveUnsigned>() -> It<(T, u64)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_unsigneds::<T>(), exhaustive_unsigneds())\n            .filter(|&(x, y)| x.checked_pow(y).is_some()),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_22<T: PrimitiveUnsigned>() -> It<(T, u64)> {\n    Box::new(exhaustive_unsigned_pair_gen_var_14().map(|(x, p)| (x, T::WIDTH - p)))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_23<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_unsigneds::<T>())\n            .filter(|&(x, y)| x.checked_lcm(y).is_some()),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_24<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs(\n        primitive_int_increasing_inclusive_range(T::power_of_2(T::WIDTH - 1), T::MAX),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_25<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_positive_primitive_ints(), exhaustive_unsigneds())\n            .filter(|&(x, y)| x != T::ONE || y != T::ZERO),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_26<T: PrimitiveUnsigned>() -> It<(T, u64)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(1, T::WIDTH),\n        ModPowerOf2SingleGenerator2 {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_27<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_28<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs_from_single(\n            primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE),\n        )\n        .filter(|&(a, b): &(T, T)| a.coprime_with(b)),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_29<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_unsigneds())\n            .filter(|&(x, y): &(T, T)| x.coprime_with(y)),\n    )\n}\n\nstruct MultifactorialNGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<u64, u64, PrimitiveIntIncreasingRange<u64>>\n    for MultifactorialNGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &m: &u64) -> PrimitiveIntIncreasingRange<u64> {\n        let limit = smallest_invalid_value(|n| T::checked_multifactorial(n, m));\n        primitive_int_increasing_range(0, limit)\n    }\n}\n\npub fn exhaustive_unsigned_pair_gen_var_30<T: PrimitiveUnsigned>() -> It<(u64, u64)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_positive_primitive_ints(),\n        MultifactorialNGenerator {\n            phantom: PhantomData::<*const T>,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_pair_gen_var_31<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_unsigneds())\n            .filter(|&(n, k)| T::checked_binomial_coefficient(n, k).is_some()),\n    )\n}\n\n// vars 32 through 36 are in malachite-nz.\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, bool) --\n\npub fn exhaustive_unsigned_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(T, u64, bool)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_unsigneds(), exhaustive_unsigneds())\n            .map(|(x, y)| (x, y, false))\n            .interleave(\n                lex_pairs(\n                    exhaustive_unsigneds(),\n                    primitive_int_increasing_range(0, T::WIDTH),\n                )\n                .map(|(x, y)| (x, y, true)),\n            ),\n    )\n}\n\npub fn exhaustive_unsigned_unsigned_bool_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, bool)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs(exhaustive_unsigneds(), exhaustive_positive_primitive_ints()),\n        exhaustive_bools(),\n    )))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_unsigneds())\n            .filter(|&(x, y, z)| add_mul_inputs_valid(x, y, z)),\n    )\n}\n\npub fn exhaustive_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_unsigneds())\n            .filter(|&(x, y, z)| sub_mul_inputs_valid(x, y, z)),\n    )\n}\n\npub fn exhaustive_unsigned_triple_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, T, U)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, U)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_unsigneds(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter_map(|(x, y, z): (T, U, U)| y.checked_add(z).map(|new_z| (x, y, new_z))),\n    )\n}\n\npub fn exhaustive_unsigned_triple_gen_var_5<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> It<(T, U, V)> {\n    permute_1_3_2(reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_unsigneds(), exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(U::TWO, U::exact_from(36u8)),\n    ))))\n}\n\nstruct UnsignedModEqTriplesInnerGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<(T, T), (T, T), It<(T, T)>>\n    for UnsignedModEqTriplesInnerGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, p: &(T, T)) -> It<(T, T)> {\n        let &(m, k) = p;\n        if k == T::ZERO {\n            Box::new(exhaustive_unsigneds().map(|x| (x, x)))\n        } else {\n            let d = m.checked_mul(k).unwrap();\n            Box::new(\n                primitive_int_increasing_inclusive_range(T::ZERO, T::MAX - d)\n                    .map(move |n| (n, n + d))\n                    .interleave(\n                        primitive_int_increasing_inclusive_range(T::ZERO, T::MAX - d)\n                            .map(move |n| (n + d, n)),\n                    ),\n            )\n        }\n    }\n}\n\nstruct UnsignedModEqTriplesGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<T, (T, T), It<(T, T)>>\n    for UnsignedModEqTriplesGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, m: &T) -> It<(T, T)> {\n        let m = *m;\n        if m == T::ZERO {\n            Box::new(exhaustive_unsigneds().map(|x| (x, x)))\n        } else {\n            Box::new(\n                exhaustive_dependent_pairs(\n                    bit_distributor_sequence(\n                        BitDistributorOutputType::normal(1),\n                        BitDistributorOutputType::normal(1),\n                    ),\n                    primitive_int_increasing_inclusive_range(T::ZERO, T::MAX / m)\n                        .map(move |k| (m, k)),\n                    UnsignedModEqTriplesInnerGenerator {\n                        phantom: PhantomData,\n                    },\n                )\n                .map(|p| p.1),\n            )\n        }\n    }\n}\n\npub fn exhaustive_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    reshape_2_1_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_unsigneds(),\n        UnsignedModEqTriplesGenerator {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_7<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_unsigneds::<T>())\n            .filter(|&(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\nstruct UnsignedModPow2EqTriplesInnerGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<(u64, T), (T, T), It<(T, T)>>\n    for UnsignedModPow2EqTriplesInnerGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, p: &(u64, T)) -> It<(T, T)> {\n        let &(pow, k) = p;\n        if k == T::ZERO {\n            Box::new(exhaustive_unsigneds().map(|x| (x, x)))\n        } else {\n            let d = k << pow;\n            Box::new(\n                primitive_int_increasing_inclusive_range(T::ZERO, T::MAX - d)\n                    .map(move |n| (n, n + d))\n                    .interleave(\n                        primitive_int_increasing_inclusive_range(T::ZERO, T::MAX - d)\n                            .map(move |n| (n + d, n)),\n                    ),\n            )\n        }\n    }\n}\n\nstruct UnsignedModPow2EqTriplesGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<u64, (T, T), It<(T, T)>>\n    for UnsignedModPow2EqTriplesGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, pow: &u64) -> It<(T, T)> {\n        let pow = *pow;\n        if pow >= T::WIDTH {\n            Box::new(exhaustive_unsigneds().map(|x| (x, x)))\n        } else {\n            Box::new(\n                exhaustive_dependent_pairs(\n                    bit_distributor_sequence(\n                        BitDistributorOutputType::normal(1),\n                        BitDistributorOutputType::normal(1),\n                    ),\n                    primitive_int_increasing_inclusive_range(T::ZERO, T::MAX >> pow)\n                        .map(move |k| (pow, k)),\n                    UnsignedModPow2EqTriplesInnerGenerator {\n                        phantom: PhantomData,\n                    },\n                )\n                .map(|p| p.1),\n            )\n        }\n    }\n}\n\npub fn exhaustive_unsigned_triple_gen_var_8<T: PrimitiveUnsigned>() -> It<(T, T, u64)> {\n    reshape_2_1_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_unsigneds(),\n        UnsignedModPow2EqTriplesGenerator {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_9<T: PrimitiveUnsigned>() -> It<(T, T, u64)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_unsigneds::<T>(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter(|&(x, y, pow)| !x.eq_mod_power_of_2(y, pow)),\n    )\n}\n\nstruct ModPowerOf2PairGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (T, T),\n        ExhaustivePairs1Input<PrimitiveIntIncreasingRange<T>>,\n    > for ModPowerOf2PairGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &pow: &u64) -> ExhaustivePairs1Input<PrimitiveIntIncreasingRange<T>> {\n        exhaustive_pairs_from_single(primitive_int_increasing_inclusive_range(\n            T::ZERO,\n            T::low_mask(pow),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_triple_gen_var_10<T: PrimitiveUnsigned>() -> It<(T, T, u64)> {\n    reshape_2_1_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(0, T::WIDTH),\n        ModPowerOf2PairGenerator {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_11<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_unsigneds::<T>())\n            .filter_map(|(x, y, z)| Some((x, y, max(x, y).checked_add(z)?.checked_add(T::ONE)?))),\n    )\n}\n\npub fn exhaustive_unsigned_triple_gen_var_12<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, U)> {\n    Box::new(exhaustive_triples_xyy_custom_output(\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_13<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, T)> {\n    Box::new(\n        exhaustive_triples_xyx_custom_output(\n            exhaustive_unsigneds(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        )\n        .filter_map(|(x, y, z): (T, U, T)| Some((x, y, x.checked_add(z)?.checked_add(T::ONE)?))),\n    )\n}\n\npub fn exhaustive_unsigned_triple_gen_var_14<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, T)> {\n    Box::new(\n        exhaustive_triples_xyx(exhaustive_unsigneds(), exhaustive_unsigneds()).filter_map(\n            |(x, y, z): (T, U, T)| Some((x, y, x.checked_add(z)?.checked_add(T::ONE)?)),\n        ),\n    )\n}\n\nstruct ModPowerOf2PairWithExtraUnsignedGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (T, U),\n        ExhaustivePairs<T, PrimitiveIntIncreasingRange<T>, U, PrimitiveIntIncreasingRange<U>>,\n    > for ModPowerOf2PairWithExtraUnsignedGenerator<T, U>\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &pow: &u64,\n    ) -> ExhaustivePairs<T, PrimitiveIntIncreasingRange<T>, U, PrimitiveIntIncreasingRange<U>> {\n        exhaustive_pairs(\n            primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(pow)),\n            exhaustive_unsigneds(),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_triple_gen_var_15<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, u64)> {\n    reshape_2_1_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(0, T::WIDTH),\n        ModPowerOf2PairWithExtraUnsignedGenerator::<T, U> {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_16<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, T)> {\n    Box::new(\n        exhaustive_triples_xyx(\n            exhaustive_unsigneds(),\n            primitive_int_increasing_inclusive_range(U::ZERO, U::saturating_from(u64::MAX)),\n        )\n        .filter_map(|(x, y, z): (T, U, T)| Some((x, y, x.checked_add(z)?.checked_add(T::ONE)?))),\n    )\n}\n\npub fn exhaustive_unsigned_triple_gen_var_17<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_unsigneds()))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_18<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_xyx(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_19<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_20<T: PrimitiveUnsigned>() -> It<(T, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\npub fn exhaustive_unsigned_triple_gen_var_21<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, T, U)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, u64, u64, U)> {\n    Box::new(\n        exhaustive_quadruples_xyyz_custom_output(\n            exhaustive_unsigneds(),\n            exhaustive_unsigneds(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        )\n        .filter_map(|(x, y, z, w): (T, u64, u64, U)| {\n            y.checked_add(z).and_then(|new_z| {\n                if unsigned_assign_bits_valid(y, new_z, w) {\n                    Some((x, y, new_z, w))\n                } else {\n                    None\n                }\n            })\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, T, T, U)> {\n    Box::new(exhaustive_quadruples_xxxy_custom_output(\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\nstruct ModPowerOf2TripleGenerator<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (T, T, T),\n        ExhaustiveTriples1Input<PrimitiveIntIncreasingRange<T>>,\n    > for ModPowerOf2TripleGenerator<T>\n{\n    #[inline]\n    fn get_ys(&self, &pow: &u64) -> ExhaustiveTriples1Input<PrimitiveIntIncreasingRange<T>> {\n        exhaustive_triples_from_single(primitive_int_increasing_inclusive_range(\n            T::ZERO,\n            T::low_mask(pow),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_3<T: PrimitiveUnsigned>() -> It<(T, T, T, u64)> {\n    reshape_3_1_to_4(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(0, T::WIDTH),\n        ModPowerOf2TripleGenerator {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_4<T: PrimitiveUnsigned>() -> It<(T, T, T, T)> {\n    Box::new(\n        exhaustive_quadruples_from_single(exhaustive_unsigneds::<T>()).filter_map(\n            |(x, y, z, w)| Some((x, y, z, max!(x, y, z).checked_add(w)?.checked_add(T::ONE)?)),\n        ),\n    )\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_5<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>() -> It<(T, T, T, T)> {\n    Box::new(\n        exhaustive_triples_xxy(exhaustive_unsigneds(), exhaustive_positive_primitive_ints()).map(\n            |(x_1, x_0, d)| {\n                let inv = limbs_invert_limb_naive::<T, DT>(d << LeadingZeros::leading_zeros(d));\n                (x_1, x_0, d, inv)\n            },\n        ),\n    )\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_6<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, T, U, T)> {\n    Box::new(\n        exhaustive_quadruples_xxyx(exhaustive_unsigneds::<T>(), exhaustive_unsigneds::<U>())\n            .filter_map(|(x, y, z, w)| {\n                Some((x, y, z, max(x, y).checked_add(w)?.checked_add(T::ONE)?))\n            }),\n    )\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_7<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, U, T)> {\n    Box::new(\n        exhaustive_quadruples_xyyx(exhaustive_unsigneds::<T>(), exhaustive_unsigneds::<U>())\n            .filter_map(|(x, y, z, w)| Some((x, y, z, x.checked_add(w)?.checked_add(T::ONE)?))),\n    )\n}\n\nstruct ModPowerOf2TripleWithExtraUnsignedGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (T, T, U),\n        ExhaustiveTriplesXXY<T, PrimitiveIntIncreasingRange<T>, U, PrimitiveIntIncreasingRange<U>>,\n    > for ModPowerOf2TripleWithExtraUnsignedGenerator<T, U>\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &pow: &u64,\n    ) -> ExhaustiveTriplesXXY<T, PrimitiveIntIncreasingRange<T>, U, PrimitiveIntIncreasingRange<U>>\n    {\n        exhaustive_triples_xxy(\n            primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(pow)),\n            exhaustive_unsigneds(),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_8<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, T, U, u64)> {\n    reshape_3_1_to_4(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(0, T::WIDTH),\n        ModPowerOf2TripleWithExtraUnsignedGenerator::<T, U> {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\nstruct ModPowerOf2QuadrupleWithTwoExtraUnsignedsGenerator<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (T, U, U),\n        ExhaustiveTriplesXYY<T, PrimitiveIntIncreasingRange<T>, U, PrimitiveIntIncreasingRange<U>>,\n    > for ModPowerOf2QuadrupleWithTwoExtraUnsignedsGenerator<T, U>\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &pow: &u64,\n    ) -> ExhaustiveTriplesXYY<T, PrimitiveIntIncreasingRange<T>, U, PrimitiveIntIncreasingRange<U>>\n    {\n        exhaustive_triples_xyy(\n            primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(pow)),\n            exhaustive_unsigneds(),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_9<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(T, U, U, u64)> {\n    reshape_3_1_to_4(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(0, T::WIDTH),\n        ModPowerOf2QuadrupleWithTwoExtraUnsignedsGenerator::<T, U> {\n            phantom: PhantomData,\n        },\n    ))))\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_10<T: PrimitiveUnsigned>() -> It<(T, T, T, T)> {\n    Box::new(exhaustive_quadruples_from_single(exhaustive_unsigneds()))\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_11<T: PrimitiveUnsigned>() -> It<(T, T, T, T)> {\n    Box::new(\n        exhaustive_quadruples_from_single(exhaustive_unsigneds()).filter(|&(n1, n0, d1, d0)| {\n            // conditions: D >= 2^W, N >= D, and N / D < 2^W\n            d1 != T::ZERO && (n1 > d1 || n1 == d1 && n0 >= d0)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_quadruple_gen_var_12<T: PrimitiveUnsigned>() -> It<(T, T, T, T)> {\n    Box::new(exhaustive_quadruples_xxxy(\n        exhaustive_unsigneds(),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n    ))\n}\n\n// -- (PrimitiveUnsigned * 6) --\n\npub fn exhaustive_unsigned_sextuple_gen_var_1<T: PrimitiveUnsigned>() -> It<(T, T, T, T, T, T)> {\n    Box::new(exhaustive_sextuples_from_single(exhaustive_unsigneds()))\n}\n\n// var 2 is in malachite-nz.\n\n// -- (PrimitiveUnsigned * 8) --\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_octuple_gen_var_1<T: PrimitiveUnsigned>() -> It<(T, T, T, T, T, T, T, T)>\n{\n    Box::new(exhaustive_octuples_from_single(exhaustive_unsigneds()))\n}\n\n// -- (PrimitiveUnsigned * 9) --\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_nonuple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(T, T, T, T, T, T, T, T, T)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_triples_from_single(exhaustive_unsigneds()))\n            .map(|((a, b, c), (d, e, f), (g, h, i))| (a, b, c, d, e, f, g, h, i)),\n    )\n}\n\n// -- (PrimitiveUnsigned * 12) --\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_duodecuple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(T, T, T, T, T, T, T, T, T, T, T, T)> {\n    Box::new(exhaustive_duodecuples_from_single(exhaustive_unsigneds()))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(T, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs(\n                exhaustive_unsigneds::<T>(),\n                exhaustive_positive_primitive_ints::<T>(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, y), rm)| rm != Exact || x.divisible_by(y)),\n    ))\n}\n\npub(crate) fn round_to_multiple_unsigned_filter_map<T: PrimitiveUnsigned>(\n    x: T,\n    y: T,\n    rm: RoundingMode,\n) -> Option<(T, T, RoundingMode)> {\n    if x == y {\n        Some((x, y, rm))\n    } else if y == T::ZERO {\n        if rm == Floor || rm == Down || rm == Nearest {\n            Some((x, y, rm))\n        } else {\n            None\n        }\n    } else if rm != Exact {\n        x.div_round(y, rm).0.checked_mul(y).map(|_| (x, y, rm))\n    } else {\n        x.checked_mul(y).map(|product| (product, y, rm))\n    }\n}\n\npub(crate) fn round_to_multiple_of_power_of_2_filter_map<T: PrimitiveInt>(\n    n: T,\n    u: u64,\n    rm: RoundingMode,\n) -> Option<(T, u64, RoundingMode)> {\n    if n == T::ZERO || rm != Exact {\n        n.shr_round(u, rm)\n            .0\n            .arithmetic_checked_shl(u)\n            .map(|_| (n, u, rm))\n    } else {\n        n.arithmetic_checked_shl(u).map(|shifted| (shifted, u, rm))\n    }\n}\n\npub fn exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> It<(T, T, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs(\n                exhaustive_unsigneds::<T>(),\n                exhaustive_positive_primitive_ints::<T>(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter_map(|((x, y), rm)| round_to_multiple_unsigned_filter_map(x, y, rm)),\n    )\n}\n\npub fn exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveUnsigned>()\n-> It<(T, u64, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_unsigneds::<T>(), exhaustive_unsigneds::<u64>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter_map(|((x, pow), rm)| round_to_multiple_of_power_of_2_filter_map(x, pow, rm)),\n    )\n}\n\npub fn exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_5<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_unsigneds::<T>(), exhaustive_unsigneds::<U>()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, y), rm)| rm != Exact || x.divisible_by_power_of_2(y.exact_into())),\n    ))\n}\n\n// vars 6 through 7 are in malachite-float.\n\npub fn exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_8<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(T, U, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs(\n            exhaustive_unsigneds::<T>(),\n            exhaustive_positive_primitive_ints::<U>(),\n        ),\n        exhaustive_rounding_modes(),\n    )))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, Vec<bool>) --\n\nstruct UnsignedUnsignedBoolVecTripleGeneratorVar1;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (T, u64),\n        Vec<bool>,\n        LexFixedLengthVecsFromSingle<ExhaustiveBools>,\n    > for UnsignedUnsignedBoolVecTripleGeneratorVar1\n{\n    #[inline]\n    fn get_ys(&self, &(x, log_base): &(T, u64)) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(\n            x.significant_bits().div_round(log_base, Ceiling).0,\n            exhaustive_bools(),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_unsigned_bool_vec_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(T, u64, Vec<bool>)> {\n    reshape_2_1_to_3(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        lex_pairs(\n            exhaustive_unsigneds(),\n            primitive_int_increasing_inclusive_range(1, U::WIDTH),\n        ),\n        UnsignedUnsignedBoolVecTripleGeneratorVar1,\n    )))\n}\n\n// -- (PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_unsigned_rounding_mode_pair_gen<T: PrimitiveUnsigned>() -> It<(T, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_unsigneds(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_unsigned_rounding_mode_pair_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>() -> It<(T, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_unsigneds(), exhaustive_rounding_modes())\n            .filter(move |&(u, rm)| rm != Exact || U::convertible_from(u)),\n    )\n}\n\n// -- (PrimitiveUnsigned, String) --\n\npub fn valid_digit_chars(base: u8) -> Vec<char> {\n    let mut chars = Vec::new();\n    if base <= 10 {\n        chars.extend('0'..char::from(base + b'0'));\n    } else {\n        chars.extend('0'..='9');\n        chars.extend('a'..char::from(base - 10 + b'a'));\n        chars.extend('A'..char::from(base - 10 + b'A'));\n    }\n    chars\n}\n\nstruct DigitStringGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        u8,\n        String,\n        StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, IntoIter<char>>>,\n    > for DigitStringGenerator\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &base: &u8,\n    ) -> StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, IntoIter<char>>>\n    {\n        assert!((2..=36).contains(&base));\n        strings_from_char_vecs(exhaustive_vecs_min_length(\n            1,\n            valid_digit_chars(base).into_iter(),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_string_pair_gen_var_1() -> It<(u8, String)> {\n    Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        primitive_int_increasing_inclusive_range(2, 36),\n        DigitStringGenerator,\n    ))\n}\n\npub fn exhaustive_unsigned_string_pair_gen_var_2() -> It<(u8, String)> {\n    Box::new(exhaustive_pairs(\n        primitive_int_increasing_inclusive_range(2, 36),\n        exhaustive_strings(),\n    ))\n}\n\nstruct TargetedIntegerFromStringBaseInputs {\n    neg: bool,\n    u: u8,\n    s: String,\n    uss: It<(u8, String)>,\n}\n\nimpl Iterator for TargetedIntegerFromStringBaseInputs {\n    type Item = (u8, String);\n\n    fn next(&mut self) -> Option<(u8, String)> {\n        Some(if self.neg {\n            self.neg = false;\n            let next = self.uss.next().unwrap();\n            self.u = next.0;\n            self.s = next.1;\n            (self.u, self.s.clone())\n        } else {\n            self.neg = true;\n            let mut s = '-'.to_string();\n            s.push_str(&self.s);\n            (self.u, s)\n        })\n    }\n}\n\npub fn exhaustive_unsigned_string_pair_gen_var_3() -> It<(u8, String)> {\n    Box::new(TargetedIntegerFromStringBaseInputs {\n        neg: true,\n        u: 0,\n        s: String::new(),\n        uss: exhaustive_unsigned_string_pair_gen_var_1(),\n    })\n}\n\n// -- (PrimitiveUnsigned, ToSciOptions) --\n\npub fn exhaustive_unsigned_to_sci_options_pair_gen<T: PrimitiveUnsigned>() -> It<(T, ToSciOptions)>\n{\n    Box::new(exhaustive_pairs(\n        exhaustive_unsigneds(),\n        exhaustive_to_sci_options(),\n    ))\n}\n\npub fn exhaustive_unsigned_to_sci_options_pair_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(T, ToSciOptions)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_unsigneds::<T>(), exhaustive_to_sci_options())\n            .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- (PrimitiveUnsigned, Vec<bool>) --\n\nstruct UnsignedBoolVecPairGeneratorVar1;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<T, Vec<bool>, LexFixedLengthVecsFromSingle<ExhaustiveBools>>\n    for UnsignedBoolVecPairGeneratorVar1\n{\n    #[inline]\n    fn get_ys(&self, &x: &T) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(x.significant_bits(), exhaustive_bools())\n    }\n}\n\npub fn exhaustive_unsigned_bool_vec_pair_gen_var_1<T: PrimitiveUnsigned>() -> It<(T, Vec<bool>)> {\n    Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_unsigneds(),\n        UnsignedBoolVecPairGeneratorVar1,\n    ))\n}\n\n// -- RationalSequence<PrimitiveUnsigned> --\n\npub fn exhaustive_unsigned_rational_sequence_gen<T: PrimitiveUnsigned>() -> It<RationalSequence<T>>\n{\n    Box::new(exhaustive_rational_sequences(exhaustive_unsigneds()))\n}\n\n// -- (RationalSequence<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_rational_sequence_unsigned_pair_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(RationalSequence<T>, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_rational_sequences(exhaustive_unsigneds()),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_rational_sequence_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(RationalSequence<T>, usize)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_rational_sequences(exhaustive_unsigneds()),\n            exhaustive_unsigneds(),\n        )\n        .filter(|&(ref xs, i)| {\n            if let Some(len) = xs.len() {\n                i < len\n            } else {\n                true\n            }\n        }),\n    )\n}\n\n// -- (RationalSequence<PrimitiveUnsigned>, RationalSequence<PrimitiveUnsigned>) --\n\npub fn exhaustive_unsigned_rational_sequence_pair_gen<T: PrimitiveUnsigned>()\n-> It<(RationalSequence<T>, RationalSequence<T>)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_rational_sequences(\n        exhaustive_unsigneds(),\n    )))\n}\n\n// -- RationalSequence<PrimitiveUnsigned> * 3 --\n\npub fn exhaustive_unsigned_rational_sequence_triple_gen<T: PrimitiveUnsigned>() -> It<(\n    RationalSequence<T>,\n    RationalSequence<T>,\n    RationalSequence<T>,\n)> {\n    Box::new(exhaustive_triples_from_single(\n        exhaustive_rational_sequences(exhaustive_unsigneds()),\n    ))\n}\n\n// -- RoundingMode --\n\npub fn exhaustive_rounding_mode_gen() -> It<RoundingMode> {\n    Box::new(exhaustive_rounding_modes())\n}\n\n// -- (RoundingMode, RoundingMode) --\n\npub fn exhaustive_rounding_mode_pair_gen() -> It<(RoundingMode, RoundingMode)> {\n    Box::new(lex_pairs_from_single(exhaustive_rounding_modes()))\n}\n\n// -- (RoundingMode, RoundingMode, RoundingMode) --\n\npub fn exhaustive_rounding_mode_triple_gen() -> It<(RoundingMode, RoundingMode, RoundingMode)> {\n    Box::new(lex_triples_from_single(exhaustive_rounding_modes()))\n}\n\n// -- SciSizeOptions --\n\npub fn exhaustive_sci_size_options_gen() -> It<SciSizeOptions> {\n    Box::new(exhaustive_sci_size_options())\n}\n\n// -- String --\n\npub fn exhaustive_string_gen() -> It<String> {\n    Box::new(exhaustive_strings())\n}\n\npub fn exhaustive_string_gen_var_1() -> It<String> {\n    Box::new(exhaustive_strings_using_chars(exhaustive_ascii_chars()))\n}\n\npub fn exhaustive_string_gen_var_2() -> It<String> {\n    Box::new(exhaustive_strings_using_chars(ROUNDING_MODE_CHARS.chars()))\n}\n\npub fn exhaustive_string_gen_var_3() -> It<String> {\n    Box::new(strings_from_char_vecs(exhaustive_vecs_min_length(\n        1,\n        '0'..='9',\n    )))\n}\n\nstruct TargetedIntegerFromStrStringsVar1 {\n    neg: bool,\n    s: String,\n    ss: It<String>,\n}\n\nimpl Iterator for TargetedIntegerFromStrStringsVar1 {\n    type Item = String;\n\n    fn next(&mut self) -> Option<String> {\n        Some(if self.neg {\n            self.neg = false;\n            self.s = self.ss.next().unwrap();\n            self.s.clone()\n        } else {\n            self.neg = true;\n            format!(\"-{}\", self.s)\n        })\n    }\n}\n\npub fn exhaustive_string_gen_var_4() -> It<String> {\n    Box::new(TargetedIntegerFromStrStringsVar1 {\n        neg: true,\n        s: String::new(),\n        ss: exhaustive_string_gen_var_3(),\n    })\n}\n\npub fn exhaustive_string_gen_var_5() -> It<String> {\n    Box::new(strings_from_char_vecs(exhaustive_vecs_min_length(\n        1,\n        '0'..='1',\n    )))\n}\n\npub fn exhaustive_string_gen_var_6() -> It<String> {\n    Box::new(strings_from_char_vecs(exhaustive_vecs_min_length(\n        1,\n        '0'..='7',\n    )))\n}\n\npub fn exhaustive_string_gen_var_7() -> It<String> {\n    Box::new(strings_from_char_vecs(exhaustive_vecs_min_length(\n        1,\n        lex_union3s('0'..='9', 'a'..='f', 'A'..='F').map(Union3::unwrap),\n    )))\n}\n\npub fn exhaustive_string_gen_var_8() -> It<String> {\n    Box::new(\n        strings_from_char_vecs(exhaustive_vecs_min_length(\n            1,\n            lex_union3s('0'..='9', 'a'..='f', 'A'..='F').map(Union3::unwrap),\n        ))\n        .map(|s| format!(\"\\\"0x{s}\\\"\")),\n    )\n}\n\nstruct TargetedIntegerFromStrStringsVar2 {\n    neg: bool,\n    s: String,\n    ss: It<String>,\n}\n\nimpl Iterator for TargetedIntegerFromStrStringsVar2 {\n    type Item = String;\n\n    fn next(&mut self) -> Option<String> {\n        Some(if self.neg {\n            self.neg = false;\n            self.s = self.ss.next().unwrap();\n            format!(\"\\\"0x{}\\\"\", self.s)\n        } else {\n            self.neg = true;\n            format!(\"\\\"-0x{}\\\"\", self.s)\n        })\n    }\n}\n\npub fn exhaustive_string_gen_var_9() -> It<String> {\n    Box::new(TargetedIntegerFromStrStringsVar2 {\n        neg: true,\n        s: String::new(),\n        ss: exhaustive_string_gen_var_7(),\n    })\n}\n\npub fn exhaustive_string_gen_var_10() -> It<String> {\n    Box::new(exhaustive_strings_using_chars(\n        PRIMITIVE_FLOAT_CHARS.chars(),\n    ))\n}\n\n// vars 11 through 12 are in malachite-q.\n\npub fn exhaustive_string_gen_var_13() -> It<String> {\n    Box::new(exhaustive_strings_using_chars(\n        DECIMAL_SCI_STRING_CHARS.chars(),\n    ))\n}\n\npub fn exhaustive_string_gen_var_14() -> It<String> {\n    Box::new(exhaustive_strings().filter(|s| !large_exponent(s)))\n}\n\npub fn exhaustive_string_gen_var_15() -> It<String> {\n    Box::new(\n        exhaustive_strings_using_chars(DECIMAL_SCI_STRING_CHARS.chars())\n            .filter(|s| !large_exponent(s)),\n    )\n}\n\n// -- (String, FromSciStringOptions) --\n\npub fn exhaustive_string_from_sci_string_options_pair_gen() -> It<(String, FromSciStringOptions)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_strings(),\n        exhaustive_from_sci_string_options(),\n    ))\n}\n\nstruct SciDigitStringGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        FromSciStringOptions,\n        String,\n        StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, IntoIter<char>>>,\n    > for SciDigitStringGenerator\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &options: &FromSciStringOptions,\n    ) -> StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, IntoIter<char>>>\n    {\n        let base = options.get_base();\n        let mut cs = vec!['+', '-', '.'];\n        if base < 15 {\n            cs.push('e');\n            cs.push('E');\n        }\n        cs.extend(valid_digit_chars(base));\n        assert!((2..=36).contains(&base));\n        strings_from_char_vecs(exhaustive_vecs_min_length(1, cs.into_iter()))\n    }\n}\n\nstruct SciDigitStringGenerator2;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        u8,\n        String,\n        StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, IntoIter<char>>>,\n    > for SciDigitStringGenerator2\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &base: &u8,\n    ) -> StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, IntoIter<char>>>\n    {\n        let mut cs = vec!['+', '-', '.'];\n        if base < 15 {\n            cs.push('e');\n            cs.push('E');\n        }\n        cs.extend(valid_digit_chars(base));\n        assert!((2..=36).contains(&base));\n        strings_from_char_vecs(exhaustive_vecs_min_length(1, cs.into_iter()))\n    }\n}\n\npub fn exhaustive_string_from_sci_string_options_pair_gen_var_1()\n-> It<(String, FromSciStringOptions)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_from_sci_string_options(),\n        SciDigitStringGenerator,\n    )))\n}\n\npub fn exhaustive_string_from_sci_string_options_pair_gen_var_2()\n-> It<(String, FromSciStringOptions)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_strings().filter(|s| !large_exponent(s)),\n        exhaustive_from_sci_string_options(),\n    ))\n}\n\npub fn exhaustive_string_from_sci_string_options_pair_gen_var_3()\n-> It<(String, FromSciStringOptions)> {\n    permute_2_1(Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_from_sci_string_options(),\n            SciDigitStringGenerator,\n        )\n        .filter(|(_, s)| !large_exponent(s)),\n    ))\n}\n\n// -- (String, PrimitiveUnsigned) --\n\npub fn exhaustive_string_unsigned_pair_gen_var_1() -> It<(String, u8)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_strings().filter(|s| !large_exponent(s)),\n        primitive_int_increasing_inclusive_range(2, 36),\n    ))\n}\n\npub fn exhaustive_string_unsigned_pair_gen_var_2() -> It<(String, u8)> {\n    permute_2_1(Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            primitive_int_increasing_inclusive_range(2, 36),\n            SciDigitStringGenerator2,\n        )\n        .filter(|(_, s)| !large_exponent(s)),\n    ))\n}\n\n// -- (String, String) --\n\npub fn exhaustive_string_pair_gen() -> It<(String, String)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_strings()))\n}\n\npub fn exhaustive_string_pair_gen_var_1() -> It<(String, String)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_strings_using_chars(exhaustive_ascii_chars()),\n    ))\n}\n\n// -- ToSciOptions --\n\npub fn exhaustive_to_sci_options_gen() -> It<ToSciOptions> {\n    Box::new(exhaustive_to_sci_options())\n}\n\n// -- (ToSciOptions, bool) --\n\npub fn exhaustive_to_sci_options_bool_pair_gen() -> It<(ToSciOptions, bool)> {\n    Box::new(lex_pairs(exhaustive_to_sci_options(), exhaustive_bools()))\n}\n\n// -- (ToSciOptions, PrimitiveInt) --\n\npub fn exhaustive_to_sci_options_primitive_int_pair_gen_var_1<T: PrimitiveInt>()\n-> It<(ToSciOptions, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_to_sci_options(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (ToSciOptions, PrimitiveSigned) --\n\npub fn exhaustive_to_sci_options_signed_pair_gen_var_1<T: PrimitiveSigned>() -> It<(TSO, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_to_sci_options(),\n        exhaustive_negative_signeds(),\n    ))\n}\n\n// -- (ToSciOptions, PrimitiveUnsigned) --\n\npub fn exhaustive_to_sci_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(ToSciOptions, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_to_sci_options(),\n        primitive_int_increasing_inclusive_range(T::TWO, T::from(36u8)),\n    ))\n}\n\npub fn exhaustive_to_sci_options_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(ToSciOptions, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_to_sci_options(),\n        exhaustive_unsigneds(),\n    ))\n}\n\n// -- (ToSciOptions, RoundingMode) --\n\npub fn exhaustive_to_sci_options_rounding_mode_pair_gen() -> It<(ToSciOptions, RoundingMode)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_to_sci_options(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\n// -- Vec<bool> --\n\npub fn exhaustive_bool_vec_gen() -> It<Vec<bool>> {\n    Box::new(shortlex_vecs(exhaustive_bools()))\n}\n\npub fn exhaustive_bool_vec_gen_var_1<T: PrimitiveUnsigned>() -> It<Vec<bool>> {\n    Box::new(\n        shortlex_vecs_length_inclusive_range(0, T::WIDTH, exhaustive_bools()).interleave(\n            exhaustive_pairs_big_tiny(\n                lex_vecs_fixed_length_from_single(T::WIDTH, exhaustive_bools()),\n                exhaustive_positive_primitive_ints(),\n            )\n            .map(|(bs, n)| bs.into_iter().chain(repeat_n(false, n)).collect()),\n        ),\n    )\n}\n\npub fn exhaustive_bool_vec_gen_var_2<T: PrimitiveSigned>() -> It<Vec<bool>> {\n    Box::new(\n        shortlex_vecs_length_inclusive_range(0, T::WIDTH - 1, exhaustive_bools()).interleave(\n            exhaustive_pairs_big_tiny(\n                lex_vecs_fixed_length_from_single(T::WIDTH - 1, exhaustive_bools()),\n                exhaustive_nonzero_signeds::<isize>(),\n            )\n            .map(|(bs, n)| {\n                bs.into_iter()\n                    .chain(repeat_n(n < 0, n.unsigned_abs()))\n                    .collect()\n            }),\n        ),\n    )\n}\n\npub fn exhaustive_bool_vec_gen_var_3<T: PrimitiveUnsigned>() -> It<Vec<bool>> {\n    Box::new(\n        shortlex_vecs_length_inclusive_range(0, T::WIDTH, exhaustive_bools()).interleave(\n            exhaustive_pairs_big_tiny(\n                lex_vecs_fixed_length_from_single(T::WIDTH, exhaustive_bools()),\n                exhaustive_positive_primitive_ints(),\n            )\n            .map(|(bs, n)| repeat_n(false, n).chain(bs).collect()),\n        ),\n    )\n}\n\npub fn exhaustive_bool_vec_gen_var_4<T: PrimitiveSigned>() -> It<Vec<bool>> {\n    Box::new(\n        shortlex_vecs_length_inclusive_range(0, T::WIDTH - 1, exhaustive_bools()).interleave(\n            exhaustive_pairs_big_tiny(\n                lex_vecs_fixed_length_from_single(T::WIDTH - 1, exhaustive_bools()),\n                exhaustive_nonzero_signeds::<isize>(),\n            )\n            .map(|(bs, n)| repeat_n(n < 0, n.unsigned_abs()).chain(bs).collect()),\n        ),\n    )\n}\n\npub fn exhaustive_bool_vec_gen_var_5() -> It<Vec<bool>> {\n    Box::new(shortlex_vecs_min_length(1, exhaustive_bools()).filter(|bs| bs.iter().any(|&b| b)))\n}\n\n// -- Vec<PrimitiveUnsigned> --\n\npub fn exhaustive_unsigned_vec_gen<T: PrimitiveUnsigned>() -> It<Vec<T>> {\n    Box::new(exhaustive_vecs(exhaustive_unsigneds()))\n}\n\npub fn exhaustive_unsigned_vec_gen_var_1<T: PrimitiveUnsigned>() -> It<Vec<T>> {\n    Box::new(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn exhaustive_unsigned_vec_gen_var_2<T: PrimitiveUnsigned>() -> It<Vec<T>> {\n    Box::new(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n    )\n}\n\npub fn exhaustive_unsigned_vec_gen_var_3<T: PrimitiveUnsigned>() -> It<Vec<T>> {\n    Box::new(exhaustive_vecs(exhaustive_unsigneds()).filter(|xs| xs.last() != Some(&T::ZERO)))\n}\n\npub fn exhaustive_unsigned_vec_gen_var_4<T: PrimitiveUnsigned>() -> It<Vec<T>> {\n    Box::new(exhaustive_vecs_min_length(1, exhaustive_unsigneds()))\n}\n\n// var 5 is in malachite-nz.\n\npub fn exhaustive_unsigned_vec_gen_var_6<T: PrimitiveUnsigned>() -> It<Vec<T>> {\n    Box::new(exhaustive_vecs_min_length(2, exhaustive_unsigneds()))\n}\n\n// --(Vec<PrimitiveUnsigned>, PrimitiveInt) --\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs_big_small(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs_big_small(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        primitive_int_increasing_inclusive_range(U::exact_from(3), U::MAX),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds()),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_5<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_6<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(U::power_of_2(U::WIDTH - 1), U::MAX),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_7<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds()),\n        primitive_int_increasing_range(U::ONE, U::power_of_2(U::WIDTH - 1)),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_8<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(U::power_of_2(U::WIDTH - 1), U::MAX),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_9<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()),\n        primitive_int_increasing_range(U::ONE, U::power_of_2(U::WIDTH - 1)),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_10<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()),\n        primitive_int_increasing_range(U::ONE, U::power_of_2(U::WIDTH - 2)),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_primitive_int_pair_gen_var_11<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs_big_small(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        primitive_int_increasing_inclusive_range(U::TWO, U::MAX),\n    ))\n}\n\n// --(Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        exhaustive_unsigneds(),\n    ))\n}\n\nstruct UnsignedVecUnsignedPairGeneratorVar1;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (usize, usize),\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n    > for UnsignedVecUnsignedPairGeneratorVar1\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &p: &(usize, usize),\n    ) -> ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>> {\n        exhaustive_vecs_fixed_length_from_single(u64::exact_from(p.1), exhaustive_unsigneds())\n    }\n}\n\n// TODO generate (usize, usize) pairs better\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> T1<Vec<T>, usize>\n{\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x <= y),\n            UnsignedVecUnsignedPairGeneratorVar1,\n        )\n        .map(|((x, _), zs)| (zs, x)),\n    )\n}\n\nstruct UnsignedVecUnsignedPairGeneratorVar2<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<u64, Vec<U>, It<Vec<U>>>\n    for UnsignedVecUnsignedPairGeneratorVar2<T, U>\n{\n    #[inline]\n    fn get_ys(&self, &log_base: &u64) -> It<Vec<U>> {\n        Box::new(\n            exhaustive_vecs_length_inclusive_range(\n                0,\n                T::WIDTH.div_round(log_base, Ceiling).0,\n                primitive_int_increasing_inclusive_range(\n                    U::ZERO,\n                    U::low_mask(min(T::WIDTH, log_base)),\n                ),\n            )\n            .filter(move |xs| digits_valid::<T, U>(log_base, xs)),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<U>, u64)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(1, U::WIDTH),\n        UnsignedVecUnsignedPairGeneratorVar2::<T, U> {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<U>, u64)> {\n    Box::new(\n        exhaustive_unsigned_vec_unsigned_pair_gen_var_2::<T, U>()\n            .map(|(xs, y)| (xs.into_iter().rev().collect(), y)),\n    )\n}\n\n// var 4 is in malachite-nz\n\nstruct ValidDigitsGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned + WrappingFrom<U>, U: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<U, Vec<T>, It<Vec<T>>> for ValidDigitsGenerator<T, U>\n{\n    #[inline]\n    fn get_ys(&self, base: &U) -> It<Vec<T>> {\n        Box::new(exhaustive_vecs(primitive_int_increasing_range(\n            T::ZERO,\n            T::wrapping_from(*base),\n        )))\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_5<\n    T: PrimitiveUnsigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() -> It<(Vec<T>, U)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        primitive_int_increasing_inclusive_range(U::TWO, U::saturating_from(T::MAX)),\n        ValidDigitsGenerator {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> It<(Vec<T>, u64)>\n{\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(1, T::WIDTH),\n    ))\n}\n\nstruct DigitsDesc<T: PrimitiveUnsigned> {\n    max_digits: Vec<T>,\n    ds: ShortlexVecs<T, PrimitiveIntIncreasingRange<u64>, PrimitiveIntIncreasingRange<T>>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for DigitsDesc<T> {\n    type Item = Vec<T>;\n\n    fn next(&mut self) -> Option<Vec<T>> {\n        loop {\n            let digits = self.ds.next()?;\n            if digits.len() < self.max_digits.len() || digits <= self.max_digits {\n                return Some(digits);\n            }\n        }\n    }\n}\n\nstruct DigitsDescGenerator<T: PrimitiveUnsigned, U: Digits<T> + PrimitiveUnsigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: Digits<T> + PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<T, Vec<T>, DigitsDesc<T>> for DigitsDescGenerator<T, U>\n{\n    #[inline]\n    fn get_ys(&self, base: &T) -> DigitsDesc<T> {\n        let max_digits = U::MAX.to_digits_desc(base);\n        DigitsDesc {\n            ds: shortlex_vecs_length_inclusive_range(\n                0,\n                u64::exact_from(max_digits.len()),\n                primitive_int_increasing_range(T::ZERO, *base),\n            ),\n            max_digits,\n        }\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_7<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>() -> It<(Vec<T>, T)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        primitive_int_increasing_inclusive_range(T::TWO, T::saturating_from(U::MAX)),\n        DigitsDescGenerator::<T, U> {\n            phantom: PhantomData,\n        },\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_8<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>() -> It<(Vec<T>, T)> {\n    Box::new(\n        exhaustive_unsigned_vec_unsigned_pair_gen_var_7::<T, U>().map(|(mut xs, base)| {\n            xs.reverse();\n            (xs, base)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_9<T: PrimitiveUnsigned>() -> It<(Vec<T>, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(T::TWO, T::MAX),\n    ))\n}\n\nstruct PowerOf2DigitsGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        Vec<T>,\n        ExhaustiveVecs<T, PrimitiveIntIncreasingRange<u64>, PrimitiveIntIncreasingRange<T>>,\n    > for PowerOf2DigitsGenerator\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &log_base: &u64,\n    ) -> ExhaustiveVecs<T, PrimitiveIntIncreasingRange<u64>, PrimitiveIntIncreasingRange<T>> {\n        exhaustive_vecs(primitive_int_increasing_inclusive_range(\n            T::ZERO,\n            T::low_mask(log_base),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_10<T: PrimitiveUnsigned>() -> It<(Vec<T>, u64)>\n{\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        primitive_int_increasing_inclusive_range(1, T::WIDTH),\n        PowerOf2DigitsGenerator,\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_11<T: PrimitiveUnsigned>() -> It<(Vec<T>, u64)>\n{\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(1, T::WIDTH),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_12<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(U::TWO, U::saturating_from(T::MAX)),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_13<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_14<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_15<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_vecs(exhaustive_unsigneds()),\n            exhaustive_unsigneds(),\n        )\n        .filter(|(xs, y)| *y < U::exact_from(xs.len() << T::LOG_WIDTH)),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_16<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_17<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n        exhaustive_unsigneds(),\n    ))\n}\n\n// vars 18 through 20 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_21<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> It<(Vec<T>, u64)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        primitive_int_increasing_range(1, U::WIDTH),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_22<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> It<(Vec<T>, u64)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()),\n        primitive_int_increasing_range(1, U::WIDTH),\n    ))\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U, V)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n    ))\n}\n\nstruct UnsignedVecUnsignedUnsignedTripleGeneratorVar2;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (usize, usize),\n        Vec<T>,\n        ExhaustiveVecs<T, PrimitiveIntIncreasingRange<u64>, PrimitiveIntIncreasingRange<T>>,\n    > for UnsignedVecUnsignedUnsignedTripleGeneratorVar2\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j): &(usize, usize),\n    ) -> ExhaustiveVecs<T, PrimitiveIntIncreasingRange<u64>, PrimitiveIntIncreasingRange<T>> {\n        exhaustive_vecs_min_length(u64::exact_from(i * j), exhaustive_unsigneds())\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, usize, usize)> {\n    reshape_1_2_to_3(permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_pairs_from_single(exhaustive_unsigneds()),\n        UnsignedVecUnsignedUnsignedTripleGeneratorVar2,\n    ))))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U, U)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_vecs(exhaustive_unsigneds()),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter_map(|(xs, y, z): (Vec<T>, U, U)| y.checked_add(z).map(|new_z| (xs, y, new_z))),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U, U)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_vecs_min_length(1, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter_map(|(xs, y, z): (Vec<T>, U, U)| y.checked_add(z).map(|new_z| (xs, y, new_z))),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// var 6 is in malachite-nz.\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_7<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, T, T)> {\n    Box::new(exhaustive_triples(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_unsigneds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_8<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, T, U)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// var 9 is in malachite-nz.\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_10<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, T, T)> {\n    Box::new(exhaustive_triples(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n        exhaustive_unsigneds(),\n    ))\n}\n\n// vars 11 through 12 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_13<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, T, U)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_unsigneds(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// var 14 is in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_unsigned_vec_unsigned_rounding_mode_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U, RoundingMode)> {\n    Box::new(exhaustive_triples(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_unsigneds(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_rounding_mode_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, U, RoundingMode)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n        exhaustive_unsigneds(),\n        exhaustive_rounding_modes(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n    ))\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\npub fn exhaustive_unsigned_vec_pair_gen<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_vecs(\n        exhaustive_unsigneds(),\n    )))\n}\n\npub struct UnsignedVecPairLenGenerator1;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64),\n        (Vec<T>, Vec<T>),\n        ExhaustivePairs<\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        >,\n    > for UnsignedVecPairLenGenerator1\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j): &(u64, u64),\n    ) -> ExhaustivePairs<\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n    > {\n        exhaustive_pairs(\n            exhaustive_vecs_fixed_length_from_single(i, exhaustive_unsigneds()),\n            exhaustive_vecs_fixed_length_from_single(j, exhaustive_unsigneds()),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_1<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_2<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_3<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_vecs_min_length(\n        1,\n        exhaustive_unsigneds(),\n    )))\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_4<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_vecs_min_length(1, exhaustive_unsigneds())).filter(\n            |(xs, es)| {\n                !xs.is_empty()\n                    && (es.len() > 1 || es.len() == 1 && es[0] > T::ONE)\n                    && *es.last().unwrap() != T::ZERO\n            },\n        ),\n    )\n}\n\nstruct UnsignedVecSqrtRemGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<(u64, u64), (Vec<T>, Vec<T>), It<(Vec<T>, Vec<T>)>>\n    for UnsignedVecSqrtRemGenerator\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(&self, &(out_len, len): &(u64, u64)) -> It<(Vec<T>, Vec<T>)> {\n        Box::new(\n            exhaustive_triples(\n                exhaustive_vecs_fixed_length_from_single(out_len, exhaustive_unsigneds()),\n                exhaustive_vecs_fixed_length_from_single(len - 1, exhaustive_unsigneds()),\n                primitive_int_increasing_inclusive_range(T::power_of_2(T::WIDTH - 2), T::MAX),\n            )\n            .map(move |(out, mut ns, n_hi)| {\n                ns.insert((usize::exact_from(out_len) << 1) - 1, n_hi);\n                (out, ns)\n            }),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_5<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let n = x.checked_add(2)?;\n                let len: u64 = n.arithmetic_checked_shl(1)?;\n                let len = len.checked_add(y)?;\n                Some((n, len))\n            }),\n            UnsignedVecSqrtRemGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct UnsignedVecSqrtGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<(u64, u64), (Vec<T>, Vec<T>), It<(Vec<T>, Vec<T>)>>\n    for UnsignedVecSqrtGenerator\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(&self, &(out_len, len): &(u64, u64)) -> It<(Vec<T>, Vec<T>)> {\n        Box::new(\n            exhaustive_triples(\n                exhaustive_vecs_fixed_length_from_single(out_len, exhaustive_unsigneds()),\n                exhaustive_vecs_fixed_length_from_single(len - 1, exhaustive_unsigneds()),\n                exhaustive_positive_primitive_ints(),\n            )\n            .map(move |(out, mut ns, n_hi)| {\n                ns.push(n_hi);\n                (out, ns)\n            }),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_6<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let in_len = x.checked_add(1)?;\n                let mut out_len: u64 = in_len.shr_round(1, Ceiling).0;\n                out_len = out_len.checked_add(y)?;\n                Some((out_len, in_len))\n            }),\n            UnsignedVecSqrtGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct UnsignedVecPairSameLenGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (Vec<T>, Vec<T>),\n        ExhaustivePairs1Input<ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>>,\n    > for UnsignedVecPairSameLenGenerator\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &len: &u64,\n    ) -> ExhaustivePairs1Input<ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>>\n    {\n        exhaustive_pairs_from_single(exhaustive_vecs_fixed_length_from_single(\n            len,\n            exhaustive_unsigneds(),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_7<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_unsigneds(),\n            UnsignedVecPairSameLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_8<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_vecs(exhaustive_unsigneds()).filter(|xs| xs.last() != Some(&T::ZERO)),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_9<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()).filter(|xs| !slice_test_zero(xs)),\n    ))\n}\n\npub struct UnsignedVecPairLenGenerator2;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64),\n        (Vec<T>, Vec<T>),\n        ExhaustivePairs<Vec<T>, It<Vec<T>>, Vec<T>, It<Vec<T>>>,\n    > for UnsignedVecPairLenGenerator2\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j): &(u64, u64),\n    ) -> ExhaustivePairs<Vec<T>, It<Vec<T>>, Vec<T>, It<Vec<T>>> {\n        exhaustive_pairs(\n            Box::new(\n                exhaustive_vecs_fixed_length_from_single(i, exhaustive_unsigneds())\n                    .filter(|xs| !slice_test_zero(xs)),\n            ),\n            Box::new(\n                exhaustive_vecs_fixed_length_from_single(j, exhaustive_unsigneds())\n                    .filter(|xs| !slice_test_zero(xs)),\n            ),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_10<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator2,\n        )\n        .map(|p| p.1),\n    )\n}\n\n// var 11 is in malachite-nz.\n\npub fn exhaustive_unsigned_vec_pair_gen_var_12<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            ruler_sequence(),\n            // TODO\n            exhaustive_pairs_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .filter_map(|(_, (ns, ds))| {\n            if *ds.last().unwrap() == T::ZERO {\n                None\n            } else {\n                Some((ns, ds))\n            }\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_13<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .filter_map(\n            |(_, (xs, ys)): (_, (Vec<T>, Vec<T>))| if ys[0].odd() { Some((xs, ys)) } else { None },\n        ),\n    )\n}\n\n// vars 14 through 15 are in malachite-nz\n\npub fn exhaustive_unsigned_vec_pair_gen_var_16<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .filter_map(|(_, (mut xs, mut ys))| {\n            let last_x = xs.last_mut().unwrap();\n            let last_y = ys.last_mut().unwrap();\n            if *last_x == T::MAX || *last_y == T::MAX {\n                None\n            } else {\n                *last_x += T::ONE;\n                *last_y += T::ONE;\n                Some((xs, ys))\n            }\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_17<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .filter_map(|(_, (mut xs, mut ys))| {\n            let last_x = xs.last_mut().unwrap();\n            let last_y = ys.last_mut().unwrap();\n            if *last_x == T::MAX || *last_y == T::MAX {\n                None\n            } else {\n                *last_x += T::ONE;\n                *last_y += T::ONE;\n                Some((xs, ys))\n            }\n        }),\n    )\n}\n\n// var 18 is in malachite-nz.\n\npub fn exhaustive_unsigned_vec_pair_gen_var_19<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_triples(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds()),\n            primitive_int_increasing_inclusive_range(T::power_of_2(T::WIDTH - 1), T::MAX),\n            exhaustive_unsigneds(),\n        )\n        .map(|(n, d_1, d_0)| (n, vec![d_0, d_1])),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_20<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds::<T>()).filter_map(|mut xs| {\n            let last = xs.last_mut().unwrap();\n            *last = last.checked_add(T::ONE)?;\n            Some(xs)\n        }),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_21<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\n// vars 22 through 31 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_pair_gen_var_32<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_33<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_positive_primitive_ints(),\n            UnsignedVecPairSameLenGenerator,\n        )\n        .filter_map(|(_, (xs, ys)): (_, (Vec<T>, Vec<T>))| {\n            if (*xs.last().unwrap() != T::ZERO || *ys.last().unwrap() != T::ZERO) && ys[0].odd() {\n                Some((xs, ys))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n// var 34 is in malachite-nz.\n\n// --(Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, bool) --\n\npub fn exhaustive_unsigned_vec_unsigned_vec_bool_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, bool)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_unsigned_vec_pair_gen_var_7(),\n        exhaustive_bools(),\n    )))\n}\n\n// --(Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n        exhaustive_unsigneds(),\n    )))\n}\n\n// var 2 and 3 are in malachite-nz\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n        exhaustive_unsigneds(),\n    )))\n}\n\nstruct UnsignedVecPairLenGenerator3;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64),\n        (Vec<T>, Vec<T>),\n        ExhaustivePairs<\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            It<Vec<T>>,\n        >,\n    > for UnsignedVecPairLenGenerator3\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j): &(u64, u64),\n    ) -> ExhaustivePairs<\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        It<Vec<T>>,\n    > {\n        exhaustive_pairs(\n            exhaustive_vecs_fixed_length_from_single(i, exhaustive_unsigneds()),\n            Box::new(\n                exhaustive_vecs_fixed_length_from_single(j, exhaustive_unsigneds())\n                    .filter(|xs| !slice_test_zero(xs)),\n            ),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator3,\n        )\n        .map(|p| p.1),\n        exhaustive_unsigneds(),\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// vars 7 through 8 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\nstruct UnsignedVecPairLenAndIndexGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64, u64),\n        (Vec<T>, Vec<T>, usize),\n        It<(Vec<T>, Vec<T>, usize)>,\n    > for UnsignedVecPairLenAndIndexGenerator\n{\n    #[inline]\n    fn get_ys(&self, &(x, y, i): &(u64, u64, u64)) -> It<(Vec<T>, Vec<T>, usize)> {\n        Box::new(\n            exhaustive_pairs(\n                exhaustive_vecs_fixed_length_from_single(x, exhaustive_unsigneds()),\n                exhaustive_vecs_fixed_length_from_single(y, exhaustive_unsigneds()),\n            )\n            .map(move |(x, y)| (x, y, usize::exact_from(i))),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, usize)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(x, y, i)| {\n                    let y = y.checked_add(i)?;\n                    let x = x.checked_add(y)?;\n                    Some((x, y, i))\n                },\n            ),\n            UnsignedVecPairLenAndIndexGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs(\n        exhaustive_unsigned_vec_pair_gen_var_7(),\n        exhaustive_unsigneds(),\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n        exhaustive_positive_primitive_ints(),\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, Vec<T>, u64)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n        primitive_int_increasing_range(1, U::WIDTH),\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, Vec<T>, u64)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n        primitive_int_increasing_range(1, U::WIDTH),\n    )))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, usize)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, i)| {\n                let x = x.checked_add(i)?;\n                Some((x, x, i))\n            }),\n            UnsignedVecPairLenAndIndexGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\n// --(Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\npub struct UnsignedVecTripleXYYLenGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64),\n        (Vec<T>, Vec<T>, Vec<T>),\n        ExhaustiveTriplesXYY<\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        >,\n    > for UnsignedVecTripleXYYLenGenerator\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j): &(u64, u64),\n    ) -> ExhaustiveTriplesXYY<\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n    > {\n        exhaustive_triples_xyy(\n            exhaustive_vecs_fixed_length_from_single(i, exhaustive_unsigneds()),\n            exhaustive_vecs_fixed_length_from_single(j, exhaustive_unsigneds()),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let y = y.checked_add(1)?;\n                let x = x.checked_add(y.arithmetic_checked_shl(1)?)?;\n                Some((x, y))\n            }),\n            UnsignedVecTripleXYYLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub struct UnsignedVecTripleLenGenerator1;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64, u64),\n        (Vec<T>, Vec<T>, Vec<T>),\n        ExhaustiveTriples<\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        >,\n    > for UnsignedVecTripleLenGenerator1\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j, k): &(u64, u64, u64),\n    ) -> ExhaustiveTriples<\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n    > {\n        exhaustive_triples(\n            exhaustive_vecs_fixed_length_from_single(i, exhaustive_unsigneds()),\n            exhaustive_vecs_fixed_length_from_single(j, exhaustive_unsigneds()),\n            exhaustive_vecs_fixed_length_from_single(k, exhaustive_unsigneds()),\n        )\n    }\n}\n\npub struct UnsignedVecQuadrupleLenGenerator1;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64, u64, u64),\n        (Vec<T>, Vec<T>, Vec<T>, Vec<T>),\n        ExhaustiveQuadruples<\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        >,\n    > for UnsignedVecQuadrupleLenGenerator1\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j, k, l): &(u64, u64, u64, u64),\n    ) -> ExhaustiveQuadruples<\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n    > {\n        exhaustive_quadruples(\n            exhaustive_vecs_fixed_length_from_single(i, exhaustive_unsigneds()),\n            exhaustive_vecs_fixed_length_from_single(j, exhaustive_unsigneds()),\n            exhaustive_vecs_fixed_length_from_single(k, exhaustive_unsigneds()),\n            exhaustive_vecs_fixed_length_from_single(l, exhaustive_unsigneds()),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(o, x, y)| {\n                    let y = y.checked_add(1)?;\n                    let x = x.checked_add(y)?;\n                    let o = x.checked_add(y)?.checked_add(o)?;\n                    Some((o, x, y))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(o, x, y)| {\n                    let y = y.checked_add(1)?;\n                    let x = x.checked_add(1)?;\n                    let o = x.checked_add(y)?.checked_add(o)?;\n                    Some((o, x, y))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\n// vars 4 through 23 are in malachite-nz\n\npub fn exhaustive_unsigned_vec_triple_gen_var_24<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let y = y.checked_add(1)?;\n                let x = x.checked_add(y)?;\n                Some((x, y))\n            }),\n            UnsignedVecTripleXYYLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_25<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let y = y.checked_add(2)?;\n                let x = x.checked_add(y.arithmetic_checked_shl(1)?)?;\n                Some((x, y))\n            }),\n            UnsignedVecTripleXYYLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_26<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let y = y.checked_add(2)?;\n                let x = x.checked_add(y)?;\n                Some((x, y))\n            }),\n            UnsignedVecTripleXYYLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct UnsignedVecTripleXXXLenGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (Vec<T>, Vec<T>, Vec<T>),\n        ExhaustiveTriples1Input<ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>>,\n    > for UnsignedVecTripleXXXLenGenerator\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &i: &u64,\n    ) -> ExhaustiveTriples1Input<ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>>\n    {\n        exhaustive_triples_from_single(exhaustive_vecs_fixed_length_from_single(\n            i,\n            exhaustive_unsigneds(),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_27<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            primitive_int_increasing_inclusive_range::<u64>(2, u64::MAX),\n            UnsignedVecTripleXXXLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct UnsignedVecSqrtRemGenerator3;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64, u64),\n        (Vec<T>, Vec<T>, Vec<T>),\n        It<(Vec<T>, Vec<T>, Vec<T>)>,\n    > for UnsignedVecSqrtRemGenerator3\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(&self, &(out_len, rem_len, len): &(u64, u64, u64)) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n        Box::new(\n            exhaustive_quadruples(\n                exhaustive_vecs_fixed_length_from_single(out_len, exhaustive_unsigneds()),\n                exhaustive_vecs_fixed_length_from_single(rem_len, exhaustive_unsigneds()),\n                exhaustive_vecs_fixed_length_from_single(len - 1, exhaustive_unsigneds()),\n                exhaustive_positive_primitive_ints(),\n            )\n            .map(move |(out, rs, mut ns, n_hi)| {\n                ns.push(n_hi);\n                (out, rs, ns)\n            }),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_28<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(x, y, z)| {\n                    let in_len = x.checked_add(1)?;\n                    let mut out_len: u64 = in_len.shr_round(1, Ceiling).0;\n                    out_len = out_len.checked_add(y)?;\n                    let rem_len = in_len.checked_add(z)?;\n                    Some((out_len, rem_len, in_len))\n                },\n            ),\n            UnsignedVecSqrtRemGenerator3,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_29<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_unsigneds(),\n            UnsignedVecTripleXXXLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_30<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_triples_from_single(\n        exhaustive_vecs(exhaustive_unsigneds()).filter(|xs| xs.last() != Some(&T::ZERO)),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_31<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let x = x.checked_add(y)?;\n                Some((x, y))\n            }),\n            UnsignedVecTripleXYYLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_32<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(o, x, y)| {\n                    let o = max(x, y).checked_add(o)?;\n                    Some((o, x, y))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct UnsignedVecTripleLenGenerator2;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64, u64),\n        (Vec<T>, Vec<T>, Vec<T>),\n        ExhaustiveTriples<\n            Vec<T>,\n            ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n            Vec<T>,\n            It<Vec<T>>,\n            Vec<T>,\n            It<Vec<T>>,\n        >,\n    > for UnsignedVecTripleLenGenerator2\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(\n        &self,\n        &(i, j, k): &(u64, u64, u64),\n    ) -> ExhaustiveTriples<\n        Vec<T>,\n        ExhaustiveFixedLengthVecs1Input<PrimitiveIntIncreasingRange<T>>,\n        Vec<T>,\n        It<Vec<T>>,\n        Vec<T>,\n        It<Vec<T>>,\n    > {\n        exhaustive_triples(\n            exhaustive_vecs_fixed_length_from_single(i, exhaustive_unsigneds()),\n            Box::new(\n                exhaustive_vecs_fixed_length_from_single(j, exhaustive_unsigneds())\n                    .filter(|xs| !slice_test_zero(xs)),\n            ),\n            Box::new(\n                exhaustive_vecs_fixed_length_from_single(k, exhaustive_unsigneds())\n                    .filter(|xs| !slice_test_zero(xs)),\n            ),\n        )\n    }\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_33<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(o, x, y)| {\n                    let x = x.checked_add(1)?;\n                    let y = y.checked_add(1)?;\n                    let o = o.checked_add(x)?;\n                    Some((o, x, y))\n                },\n            ),\n            UnsignedVecTripleLenGenerator2,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_34<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(o, x, y)| {\n                    let x = x.checked_add(1)?;\n                    let y = y.checked_add(1)?;\n                    let o = o.checked_add(max(x, y))?;\n                    Some((o, x, y))\n                },\n            ),\n            UnsignedVecTripleLenGenerator2,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_35<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(o, x, y)| {\n                    let x = x.checked_add(1)?;\n                    let y = y.checked_add(1)?;\n                    let o = o.checked_add(min(x, y))?;\n                    Some((o, x, y))\n                },\n            ),\n            UnsignedVecTripleLenGenerator2,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_36<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_triples_from_single(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    ))\n}\n\n// vars 37 through 38 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_triple_gen_var_39<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_triples_from_single(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    ))\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_40<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(o, x, y)| {\n                    let x = x.checked_add(y)?;\n                    let o = o.checked_add(x)?;\n                    Some((o, x, y))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_41<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n            .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    ))\n}\n\n// vars 42 through 49 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_triple_gen_var_50<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(x, y, z)| {\n                    let y = y.checked_add(1)?;\n                    let x = x.checked_add(y)?;\n                    let z = z.checked_add(y.arithmetic_checked_shl(1)?)?;\n                    Some((x, y, z))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (x, mut y, z)): (_, (Vec<T>, Vec<T>, Vec<T>))| {\n            let last_y = y.last_mut().unwrap();\n            if last_y.get_highest_bit() {\n                return None;\n            }\n            last_y.set_bit(T::WIDTH - 1);\n            Some((x, y, z))\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_51<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(x, y, z)| {\n                    let y = y.checked_add(5)?;\n                    let x = x.checked_add(y)?;\n                    let z = z.checked_add(y.arithmetic_checked_shl(1)?)?;\n                    Some((x, y, z))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (x, mut y, z)): (_, (Vec<T>, Vec<T>, Vec<T>))| {\n            let last_y = y.last_mut().unwrap();\n            if last_y.get_highest_bit() {\n                return None;\n            }\n            last_y.set_bit(T::WIDTH - 1);\n            Some((x, y, z))\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_52<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(x, y, z)| {\n                    let q = x.checked_add(3)?;\n                    let n = y.checked_add(9)?;\n                    let d = z.checked_add(6)?;\n                    if n < d {\n                        return None;\n                    }\n                    let q_alt = n - d + 1;\n                    if (q_alt << 1) > n || q_alt > d {\n                        return None;\n                    }\n                    let n_alt = q_alt << 1;\n                    let d_alt = q_alt;\n                    if q >= q_alt && d_alt >= 6 && n_alt >= d_alt + 3 && d_alt >= q_alt {\n                        Some((q, n, d))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (x, y, mut z)): (_, (Vec<T>, Vec<T>, Vec<T>))| {\n            let last_z = z.last_mut().unwrap();\n            if last_z.get_highest_bit() {\n                return None;\n            }\n            last_z.set_bit(T::WIDTH - 1);\n            Some((x, y, z))\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_53<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                exhaustive_pairs(\n                    exhaustive_unsigneds(),\n                    primitive_int_increasing_inclusive_range(2, u64::MAX),\n                )\n                .filter(|&(x, y)| x >= y - 2),\n                UnsignedVecPairLenGenerator1,\n            ),\n            exhaustive_unsigned_pair_gen_var_24(),\n        )\n        .map(|((_, (q, n)), (d_1, d_0))| (q, n, vec![d_0, d_1])),\n    )\n}\n\n// vars 54 through 56 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_triple_gen_var_57<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(r_len, n_len, d_len)| {\n                    let d_len = d_len.checked_add(2)?;\n                    let r_len = r_len.checked_add(d_len)?;\n                    let n_len = n_len.checked_add(d_len)?;\n                    Some((r_len, n_len, d_len))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (r, n, mut d)): (_, (Vec<T>, Vec<T>, Vec<T>))| {\n            let last_d = d.last_mut().unwrap();\n            *last_d = last_d.checked_add(T::ONE)?;\n            Some((r, n, d))\n        }),\n    )\n}\n\n// var 58 is in malachite-nz.\n\npub fn exhaustive_unsigned_vec_triple_gen_var_59<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(xs_len, ys_len, zs_len)| {\n                    let ys_len = ys_len.checked_add(2)?;\n                    let zs_len = zs_len.checked_add(2)?;\n                    let xs_len = xs_len.checked_add(ys_len + zs_len - 1)?;\n                    Some((xs_len, ys_len, zs_len))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(\n            |(_, (mut xs, mut ys, mut zs)): (_, (Vec<T>, Vec<T>, Vec<T>))| {\n                let last_x = xs.last_mut().unwrap();\n                *last_x = last_x.checked_add(T::ONE)?;\n                let last_y = ys.last_mut().unwrap();\n                *last_y = last_y.checked_add(T::ONE)?;\n                let last_z = zs.last_mut().unwrap();\n                *last_z = last_z.checked_add(T::ONE)?;\n                Some((xs, ys, zs))\n            },\n        ),\n    )\n}\n\n// var 60 is in malachite-nz.\n\n// -- large types --\n\npub fn exhaustive_large_type_gen_var_1<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>, T, T)> {\n    reshape_2_2_to_4(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n        exhaustive_pairs_from_single(exhaustive_unsigneds()),\n    )))\n}\n\nstruct UnsignedVecSqrtRemGenerator2;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64),\n        (Vec<T>, Vec<T>, u64, bool),\n        It<(Vec<T>, Vec<T>, u64, bool)>,\n    > for UnsignedVecSqrtRemGenerator2\n{\n    #[allow(clippy::type_complexity)]\n    #[inline]\n    fn get_ys(&self, &(n, len): &(u64, u64)) -> It<(Vec<T>, Vec<T>, u64, bool)> {\n        Box::new(\n            exhaustive_pairs(\n                exhaustive_vecs_fixed_length_from_single(n, exhaustive_unsigneds()),\n                exhaustive_vecs_fixed_length_from_single(len, exhaustive_unsigneds::<T>())\n                    .filter(|xs| *xs.last().unwrap() != T::ZERO),\n            )\n            .map(move |(out, ns)| {\n                let shift = ns.last().unwrap().leading_zeros() >> 1;\n                (out, ns, shift, len.odd())\n            }),\n        )\n    }\n}\n\npub fn exhaustive_large_type_gen_var_2<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>, u64, bool)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            Box::new(exhaustive_unsigneds::<u64>().filter_map(|x| {\n                let len = x.checked_add(9)?;\n                let n = len.shr_round(1, Ceiling).0;\n                Some((n, len))\n            })),\n            UnsignedVecSqrtRemGenerator2,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_large_type_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(Vec<T>, U, U, Vec<T>)> {\n    Box::new(\n        exhaustive_quadruples_xyyx::<Vec<T>, _, U, _>(\n            exhaustive_vecs(exhaustive_unsigneds()),\n            exhaustive_unsigneds(),\n        )\n        .filter_map(|(x, y, z, w)| Some((x, y, y.checked_add(U::ONE)?.checked_add(z)?, w))),\n    )\n}\n\npub fn exhaustive_large_type_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> It<(Vec<T>, U, U, Vec<T>)> {\n    Box::new(\n        exhaustive_quadruples_xyyz(\n            exhaustive_vecs_min_length(1, exhaustive_unsigneds::<T>())\n                .filter(|xs| !slice_test_zero(xs)),\n            exhaustive_unsigneds::<U>(),\n            exhaustive_vecs(exhaustive_unsigneds::<T>()),\n        )\n        .filter_map(|(x, y, z, w)| Some((x, y, y.checked_add(U::ONE)?.checked_add(z)?, w))),\n    )\n}\n\n// vars 5 through 8 are in malachite-nz\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_9<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>, Vec<T>, bool)>\n{\n    reshape_3_1_to_4(Box::new(lex_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(|(x, y)| {\n                let x = x.checked_add(y)?;\n                Some((x, y))\n            }),\n            UnsignedVecTripleXYYLenGenerator,\n        )\n        .map(|p| p.1),\n        exhaustive_bools(),\n    )))\n}\n\n// vars 10 through 21 are in malachite-nz.\n\npub fn exhaustive_large_type_gen_var_22<T: PrimitiveUnsigned>()\n-> It<(RationalSequence<T>, usize, T, T)> {\n    Box::new(\n        exhaustive_quadruples_xyzz(\n            exhaustive_rational_sequences(exhaustive_unsigneds()),\n            exhaustive_unsigneds(),\n            exhaustive_unsigneds(),\n        )\n        .filter(|&(ref xs, index, _, _)| {\n            if let Some(len) = xs.len() {\n                index < len\n            } else {\n                true\n            }\n        }),\n    )\n}\n\n// vars 23 through 26 are in malachite-nz.\n\npub fn exhaustive_large_type_gen_var_27<T: PrimitiveUnsigned>() -> It<(bool, Vec<T>, bool, Vec<T>)>\n{\n    permute_3_1_4_2(reshape_2_1_1_to_4(Box::new(lex_triples_xyy(\n        exhaustive_pairs_from_single(\n            exhaustive_vecs(exhaustive_unsigneds()).filter(|xs| xs.last() != Some(&T::ZERO)),\n        ),\n        exhaustive_bools(),\n    ))))\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/generators/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::iterators::bit_distributor::BitDistributorOutputType;\nuse crate::num::arithmetic::traits::UnsignedAbs;\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::string::options::{FromSciStringOptions, SciSizeOptions, ToSciOptions};\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, HasHalf, JoinHalves, RoundingFrom, SaturatingFrom,\n    SplitInHalf, WrappingFrom, WrappingInto,\n};\nuse crate::num::factorization::traits::IsPrime;\nuse crate::num::float::NiceFloat;\nuse crate::num::logic::traits::{BitBlockAccess, LeadingZeros};\nuse crate::rational_sequences::RationalSequence;\nuse crate::rounding_modes::RoundingMode;\nuse crate::slices::slice_trailing_zeros;\nuse crate::test_util::generators::common::Generator;\nuse crate::test_util::generators::exhaustive::*;\nuse crate::test_util::generators::random::*;\nuse crate::test_util::generators::special_random::*;\nuse crate::tuples::exhaustive::{ExhaustivePairs, exhaustive_pairs_custom_output};\n\n// general\n\n#[inline]\npub fn exhaustive_pairs_big_tiny<\n    X: Clone,\n    I: Iterator<Item = X>,\n    Y: Clone,\n    J: Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n) -> ExhaustivePairs<X, I, Y, J> {\n    exhaustive_pairs_custom_output(\n        xs,\n        ys,\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    )\n}\n\n#[inline]\npub fn exhaustive_pairs_big_small<\n    X: Clone,\n    I: Iterator<Item = X>,\n    Y: Clone,\n    J: Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n) -> ExhaustivePairs<X, I, Y, J> {\n    exhaustive_pairs_custom_output(\n        xs,\n        ys,\n        BitDistributorOutputType::normal(2),\n        BitDistributorOutputType::normal(1),\n    )\n}\n\nfn digits_valid<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(log_base: u64, digits: &[U]) -> bool {\n    let digits = &digits[..digits.len() - slice_trailing_zeros(digits)];\n    if digits.is_empty() {\n        return true;\n    }\n    let significant_bits = ((u64::wrapping_from(digits.len()) - 1) * log_base)\n        + digits.last().unwrap().significant_bits();\n    significant_bits <= T::WIDTH\n}\n\nfn unsigned_assign_bits_valid<T: PrimitiveUnsigned>(start: u64, end: u64, bits: T) -> bool {\n    let bits_width = end - start;\n    let bits = bits.mod_power_of_2(bits_width);\n    bits == T::ZERO || LeadingZeros::leading_zeros(bits) >= start\n}\n\nfn signed_assign_bits_valid<\n    T: PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n>(\n    x: T,\n    start: u64,\n    end: u64,\n    bits: U,\n) -> bool {\n    if x >= T::ZERO {\n        unsigned_assign_bits_valid(start, end, bits) && {\n            let mut abs_self = x.unsigned_abs();\n            abs_self.assign_bits(start, end, &bits);\n            !abs_self.get_highest_bit()\n        }\n    } else {\n        start <= end && {\n            let width = T::WIDTH;\n            let bits_width = end - start;\n            let bits = bits.mod_power_of_2(bits_width);\n            bits_width <= width\n                && if start >= width - 1 {\n                    bits == U::low_mask(bits_width)\n                } else {\n                    end < width || bits >> (width - 1 - start) == U::low_mask(end - width + 1)\n                }\n        }\n    }\n}\n\n// -- bool --\n\npub fn bool_gen() -> Generator<bool> {\n    Generator::new_no_special(&exhaustive_bool_gen, &random_bool_gen)\n}\n\n// -- char --\n\npub fn char_gen() -> Generator<char> {\n    Generator::new(\n        &exhaustive_char_gen,\n        &random_char_gen,\n        &special_random_char_gen,\n    )\n}\n\n// All `char`s except for `char::MAX`.\npub fn char_gen_var_1() -> Generator<char> {\n    Generator::new(\n        &exhaustive_char_gen_var_1,\n        &random_char_gen_var_1,\n        &special_random_char_gen_var_1,\n    )\n}\n\n// All `char`s except for `char::MIN`.\npub fn char_gen_var_2() -> Generator<char> {\n    Generator::new(\n        &exhaustive_char_gen_var_2,\n        &random_char_gen_var_2,\n        &special_random_char_gen_var_2,\n    )\n}\n\n// -- (char, char) --\n\npub fn char_pair_gen() -> Generator<(char, char)> {\n    Generator::new(\n        &exhaustive_char_pair_gen,\n        &random_char_pair_gen,\n        &special_random_char_pair_gen,\n    )\n}\n\n// -- FromSciStringOptions --\n\npub fn from_sci_string_options_gen() -> Generator<FromSciStringOptions> {\n    Generator::new_no_special(\n        &exhaustive_from_sci_string_options_gen,\n        &random_from_sci_string_options_gen,\n    )\n}\n\n// -- (FromSciStringOptions, PrimitiveUnsigned) --\n\n// All `(FromSciStringOptions, T)` where `T` is unsigned and the `T` is between 2 and 36, inclusive.\npub fn from_sci_string_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(FromSciStringOptions, T)> {\n    Generator::new(\n        &exhaustive_from_sci_string_options_unsigned_pair_gen_var_1,\n        &random_from_sci_string_options_unsigned_pair_gen_var_1,\n        &special_random_from_sci_string_options_unsigned_pair_gen_var_1,\n    )\n}\n\n// -- (FromSciStringOptions, RoundingMode) --\n\npub fn from_sci_string_options_rounding_mode_pair_gen()\n-> Generator<(FromSciStringOptions, RoundingMode)> {\n    Generator::new_no_special(\n        &exhaustive_from_sci_string_options_rounding_mode_pair_gen,\n        &random_from_sci_string_options_rounding_mode_pair_gen,\n    )\n}\n\n// -- PrimitiveFloat --\n\npub fn primitive_float_gen<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen,\n        &random_primitive_float_gen,\n        &special_random_primitive_float_gen,\n    )\n}\n\n// All primitive floats that are finite, not NaN, and greater than or equal to -0.5.\npub fn primitive_float_gen_var_1<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_1,\n        &random_primitive_float_gen_var_1,\n        &special_random_primitive_float_gen_var_1,\n    )\n}\n\n// All primitive floats that are non-negative and equal to an integer.\npub fn primitive_float_gen_var_2<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_2,\n        &random_primitive_float_gen_var_2,\n        &special_random_primitive_float_gen_var_2,\n    )\n}\n\n// All primitive floats that are non-negative and not equal to any integer.\npub fn primitive_float_gen_var_3<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_3,\n        &random_primitive_float_gen_var_3,\n        &special_random_primitive_float_gen_var_3,\n    )\n}\n\n// All primitive floats that are non-negative and halfway between two adjacent integers.\npub fn primitive_float_gen_var_4<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_4,\n        &random_primitive_float_gen_var_4,\n        &special_random_primitive_float_gen_var_4,\n    )\n}\n\n// All primitive floats that are equal to an integer.\npub fn primitive_float_gen_var_5<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_5,\n        &random_primitive_float_gen_var_5,\n        &special_random_primitive_float_gen_var_5,\n    )\n}\n\n// All primitive floats that are not equal to any integer.\npub fn primitive_float_gen_var_6<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_6,\n        &random_primitive_float_gen_var_6,\n        &special_random_primitive_float_gen_var_6,\n    )\n}\n\n// All primitive floats that are halfway between two adjacent integers.\npub fn primitive_float_gen_var_7<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_7,\n        &random_primitive_float_gen_var_7,\n        &special_random_primitive_float_gen_var_7,\n    )\n}\n\n// All finite primitive floats.\npub fn primitive_float_gen_var_8<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_8,\n        &random_primitive_float_gen_var_8,\n        &special_random_primitive_float_gen_var_8,\n    )\n}\n\n// All primitive floats that are not NaN or positive infinity.\npub fn primitive_float_gen_var_9<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_9,\n        &random_primitive_float_gen_var_9,\n        &special_random_primitive_float_gen_var_9,\n    )\n}\n\n// All primitive floats that are not NaN or negative infinity.\npub fn primitive_float_gen_var_10<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_10,\n        &random_primitive_float_gen_var_10,\n        &special_random_primitive_float_gen_var_10,\n    )\n}\n\n// All primitive floats that are not NaN.\npub fn primitive_float_gen_var_11<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_11,\n        &random_primitive_float_gen_var_11,\n        &special_random_primitive_float_gen_var_11,\n    )\n}\n\n// All nonzero finite primitive floats.\npub fn primitive_float_gen_var_12<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_12,\n        &random_primitive_float_gen_var_12,\n        &special_random_primitive_float_gen_var_12,\n    )\n}\n\n// All primitive floats `T` that are equal to an unsigned value of type `U`.\npub fn primitive_float_gen_var_13<T: PrimitiveFloat + RoundingFrom<U>, U: PrimitiveUnsigned>()\n-> Generator<T>\nwhere\n    NiceFloat<T>: TryFrom<U>,\n{\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_13::<T, U>,\n        &random_primitive_float_gen_var_13::<T, U>,\n        &special_random_primitive_float_gen_var_13::<T, U>,\n    )\n}\n\n// All primitive floats `T` that are equal to a signed value of type `U`.\npub fn primitive_float_gen_var_14<T: PrimitiveFloat + RoundingFrom<U>, U: PrimitiveSigned>()\n-> Generator<T>\nwhere\n    NiceFloat<T>: TryFrom<U>,\n{\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_14::<T, U>,\n        &random_primitive_float_gen_var_13::<T, U>,\n        &special_random_primitive_float_gen_var_14::<T, U>,\n    )\n}\n\n// All primitive floats of type `T` that are not equal to any primitive integer of type `U`.\npub fn primitive_float_gen_var_15<T: PrimitiveFloat, U: ConvertibleFrom<T> + PrimitiveInt>()\n-> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_15::<T, U>,\n        &random_primitive_float_gen_var_14::<T, U>,\n        &special_random_primitive_float_gen_var_15::<T, U>,\n    )\n}\n\n// All primitive floats of type `T` that are halfway between two adjacent values of the primitive\n// unsigned type `U`.\npub fn primitive_float_gen_var_16<T: PrimitiveFloat + RoundingFrom<U>, U: PrimitiveUnsigned>()\n-> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_16::<T, U>,\n        &random_primitive_float_gen_var_15::<T, U>,\n        &special_random_primitive_float_gen_var_16::<T, U>,\n    )\n}\n\n// All primitive floats of type `T` that are halfway between two adjacent values of the primitive\n// signed type `U`.\npub fn primitive_float_gen_var_17<T: PrimitiveFloat + RoundingFrom<U>, U: PrimitiveSigned>()\n-> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_17::<T, U>,\n        &random_primitive_float_gen_var_16::<T, U>,\n        &special_random_primitive_float_gen_var_17::<T, U>,\n    )\n}\n\n// All positive finite primitive floats of type `T`.\npub fn primitive_float_gen_var_18<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_18,\n        &random_primitive_float_gen_var_17,\n        &special_random_primitive_float_gen_var_18,\n    )\n}\n\n// All non-negative finite primitive floats of type `T` that are less than or equal to the largest\n// representable power of 2. Negative zero is excluded.\npub fn primitive_float_gen_var_19<T: PrimitiveFloat>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_float_gen_var_19,\n        &random_primitive_float_gen_var_18,\n        &special_random_primitive_float_gen_var_19,\n    )\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat) --\n\npub fn primitive_float_pair_gen<T: PrimitiveFloat>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_primitive_float_pair_gen,\n        &random_primitive_float_pair_gen,\n        &special_random_primitive_float_pair_gen,\n    )\n}\n\n// All pairs of primitive floats that are not NaN.\npub fn primitive_float_pair_gen_var_1<T: PrimitiveFloat>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_primitive_float_pair_gen_var_1,\n        &random_primitive_float_pair_gen_var_1,\n        &special_random_primitive_float_pair_gen_var_1,\n    )\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat, PrimitiveFloat) --\n\npub fn primitive_float_triple_gen<T: PrimitiveFloat>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_primitive_float_triple_gen,\n        &random_primitive_float_triple_gen,\n        &special_random_primitive_float_triple_gen,\n    )\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned) --\n\npub fn primitive_float_signed_pair_gen<T: PrimitiveFloat, U: PrimitiveSigned>() -> Generator<(T, U)>\n{\n    Generator::new(\n        &exhaustive_primitive_float_signed_pair_gen,\n        &random_primitive_float_signed_pair_gen,\n        &special_random_primitive_float_signed_pair_gen,\n    )\n}\n\n// All `(T, U)` where `T` is a primitive float type, `U` is signed, the `T` is finite and positive,\n// and the `U` is small.\npub fn primitive_float_signed_pair_gen_var_1<T: PrimitiveFloat, U: PrimitiveSigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_float_signed_pair_gen_var_1,\n        &random_primitive_float_signed_pair_gen_var_1,\n        &special_random_primitive_float_signed_pair_gen_var_1,\n    )\n}\n\n// All `(T, i64)` that are valid inputs to `T::from_sci_mantissa_and_exponent`.\npub fn primitive_float_signed_pair_gen_var_2<T: PrimitiveFloat>() -> Generator<(T, i64)> {\n    Generator::new(\n        &exhaustive_primitive_float_signed_pair_gen_var_2,\n        &random_primitive_float_signed_pair_gen_var_2,\n        &special_random_primitive_float_signed_pair_gen_var_2,\n    )\n}\n\n// All `(T, i64)` where `T` is a primitive float type, the `T` is greater than or equal to 1.0 and\n// less than 2.0, and the `i64` is small.\npub fn primitive_float_signed_pair_gen_var_3<T: PrimitiveFloat>() -> Generator<(T, i64)> {\n    Generator::new(\n        &exhaustive_primitive_float_signed_pair_gen_var_3,\n        &random_primitive_float_signed_pair_gen_var_3,\n        &special_random_primitive_float_signed_pair_gen_var_3,\n    )\n}\n\n// All `(T, U)` where `T` is a primitive float type, `U` is signed, and the `U` is small.\npub fn primitive_float_signed_pair_gen_var_4<T: PrimitiveFloat, U: PrimitiveSigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_float_signed_pair_gen_var_4,\n        &random_primitive_float_signed_pair_gen_var_4,\n        &special_random_primitive_float_signed_pair_gen_var_4,\n    )\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned, PrimitiveUnsigned) --\n\n// All `(T, U, V)` where `T` is a primitive float type, `U` is signed, `V` is unsigned, the `U` is\n// small, and the `V` is small and positive.\npub fn primitive_float_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(T, U, V)> {\n    Generator::new(\n        &exhaustive_primitive_float_signed_unsigned_triple_gen_var_1,\n        &random_primitive_float_signed_unsigned_triple_gen_var_1,\n        &special_random_primitive_float_signed_unsigned_triple_gen_var_1,\n    )\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned) --\n\n// All `(T, U)` where `T` is a primitive float type, `U` is unsigned, the `T` is finite and\n// positive, and the `U` is small.\npub fn primitive_float_unsigned_pair_gen_var_1<T: PrimitiveFloat, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_float_unsigned_pair_gen_var_1,\n        &random_primitive_float_unsigned_pair_gen_var_1,\n        &special_random_primitive_float_unsigned_pair_gen_var_1,\n    )\n}\n\n// All `(T, u64)` where `T` is a primitive float type, the `T` is greater than or equal to 1.0 and\n// less than 2.0, and the `u64` is small.\npub fn primitive_float_unsigned_pair_gen_var_2<T: PrimitiveFloat>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_primitive_float_unsigned_pair_gen_var_2,\n        &random_primitive_float_unsigned_pair_gen_var_2,\n        &special_random_primitive_float_unsigned_pair_gen_var_2,\n    )\n}\n\n// All `(T, U)` where `T` is a primitive float type, `U` is unsigned, the `T` is finite and\n// positive, and the `U` is small and positive.\npub fn primitive_float_unsigned_pair_gen_var_3<T: PrimitiveFloat, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_float_primitive_int_pair_gen_var_1,\n        &random_primitive_float_unsigned_pair_gen_var_3,\n        &special_random_primitive_float_unsigned_pair_gen_var_3,\n    )\n}\n\n// All `(T, U)` where `T` is a primitive float type, `U` is unsigned, and the `U` is small and\n// positive.\npub fn primitive_float_unsigned_pair_gen_var_4<T: PrimitiveFloat, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_float_unsigned_pair_gen_var_3,\n        &random_primitive_float_unsigned_pair_gen_var_4,\n        &special_random_primitive_float_unsigned_pair_gen_var_4,\n    )\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\n// All `(T, U, RoundingMode)` where `T` is a primitive float type, `U` is unsigned, the `T` is\n// finite and positive, and the `U` is small.\npub fn primitive_float_unsigned_rounding_mode_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>() -> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_1,\n        &random_primitive_float_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(T, u64, RoundingMode)` where `T` is a primitive float type, the `T` is greater than or\n// equal to 1.0 and less than 2.0, and the `u64` is small.\npub fn primitive_float_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveFloat>()\n-> Generator<(T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_2,\n        &random_primitive_float_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// var 3 is in malachite-float.\n\n// -- (PrimitiveFloat, RoundingMode) --\n\n// All `(T, RoundingMode)` where `T` is a primitive float and the values are valid inputs to\n// `Natural::rounding_from`.\npub fn primitive_float_rounding_mode_pair_gen_var_1<T: PrimitiveFloat>()\n-> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_primitive_float_rounding_mode_pair_gen_var_1,\n        &random_primitive_float_rounding_mode_pair_gen_var_1,\n        &special_random_primitive_float_rounding_mode_pair_gen_var_1,\n    )\n}\n\n// All `(T, RoundingMode)` where `T` is a primitive float and the values are valid inputs to\n// `Integer::rounding_from`.\npub fn primitive_float_rounding_mode_pair_gen_var_2<T: PrimitiveFloat>()\n-> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_primitive_float_rounding_mode_pair_gen_var_2,\n        &random_primitive_float_rounding_mode_pair_gen_var_2,\n        &special_random_primitive_float_rounding_mode_pair_gen_var_2,\n    )\n}\n\n// All `(T, RoundingMode)` where `T` is a primitive float, `U` is unsigned, and the pair is a valid\n// input to `U::rounding_from`.\npub fn primitive_float_rounding_mode_pair_gen_var_3<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: ConvertibleFrom<T> + PrimitiveInt,\n>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_primitive_float_rounding_mode_pair_gen_var_3::<T, U>,\n        &random_primitive_float_rounding_mode_pair_gen_var_3::<T, U>,\n        &special_random_primitive_float_rounding_mode_pair_gen_var_3::<T, U>,\n    )\n}\n\n// -- PrimitiveSigned --\n\npub fn signed_gen<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen,\n        &random_primitive_int_gen,\n        &special_random_signed_gen,\n    )\n}\n\n// All signed `T`s which are not `T::MIN`.\npub fn signed_gen_var_1<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen_var_1,\n        &random_signed_gen_var_1,\n        &special_random_signed_gen_var_1,\n    )\n}\n\n// All signed natural (non-negative) `T`s.\npub fn signed_gen_var_2<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen_var_2,\n        &random_signed_gen_var_2,\n        &special_random_signed_gen_var_2,\n    )\n}\n\n// All signed `T`s that are neither 0 nor -1.\npub fn signed_gen_var_3<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen_var_3,\n        &random_signed_gen_var_3,\n        &special_random_signed_gen_var_3,\n    )\n}\n\n// All negative signed `T`s.\npub fn signed_gen_var_4<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen_var_4,\n        &random_signed_gen_var_4,\n        &special_random_signed_gen_var_4,\n    )\n}\n\n// All small signed `T`s.\npub fn signed_gen_var_5<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new_no_special(&exhaustive_signed_gen::<T>, &random_signed_gen_var_5::<T>)\n}\n\n// All nonzero signed `T`s.\npub fn signed_gen_var_6<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen_var_5,\n        &random_signed_gen_var_6,\n        &special_random_signed_gen_var_5,\n    )\n}\n\n// All signeds `T` that are equal to a primitive float value of type `U`.\npub fn signed_gen_var_7<\n    T: PrimitiveSigned + RoundingFrom<U>,\n    U: ConvertibleFrom<T> + PrimitiveFloat + RoundingFrom<T>,\n>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen_var_6::<T, U>,\n        &random_primitive_int_gen_var_1::<T, U>,\n        &special_random_primitive_int_gen_var_1::<T, U>,\n    )\n}\n\ntype G<T> = Generator<T>;\n// All signeds `S` that are not exactly equal to any value of a floating-point type `V`.\n//\n// Acceptable `(S, V)` pairs are those where `S::WIDTH` > `V::MANTISSA_WIDTH`.\npub fn signed_gen_var_8<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: ConvertibleFrom<S> + PrimitiveFloat,\n>() -> G<S> {\n    Generator::new(\n        &exhaustive_signed_gen_var_7::<S, V>,\n        &random_signed_gen_var_7::<S, V>,\n        &special_random_signed_gen_var_6::<U, S, V>,\n    )\n}\n\n// All signeds `S` that are exactly between two values of a floating-point type `V`.\n//\n// Acceptable `(S, V)` pairs are those where `S::WIDTH` > `V::MANTISSA_WIDTH`.\npub fn signed_gen_var_9<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: TryFrom<NiceFloat<V>> + PrimitiveSigned + WrappingFrom<U>,\n    V: ConvertibleFrom<S> + PrimitiveFloat + RoundingFrom<S>,\n>() -> Generator<S> {\n    Generator::new(\n        &exhaustive_signed_gen_var_8::<S, V>,\n        &random_signed_gen_var_8::<S, V>,\n        &special_random_signed_gen_var_7::<U, S, V>,\n    )\n}\n\n// All signed `T`s whose square is also representable as a `T`.\npub fn signed_gen_var_10<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<S> {\n    Generator::new(\n        &exhaustive_signed_gen_var_9::<U, S>,\n        &random_signed_gen_var_9::<U, S>,\n        &special_random_signed_gen_var_8::<U, S>,\n    )\n}\n\n// All valid scientific exponents for the float type `T`.\npub fn signed_gen_var_11<T: PrimitiveFloat>() -> Generator<i64> {\n    Generator::new(\n        &exhaustive_signed_gen_var_10::<T>,\n        &random_signed_gen_var_10::<T>,\n        &special_random_signed_gen_var_9::<T>,\n    )\n}\n\n// All signed `T`s that are neither 0 nor -1.\npub fn signed_gen_var_12<T: PrimitiveSigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_signed_gen_var_11,\n        &random_signed_gen_var_11,\n        &special_random_signed_gen_var_10,\n    )\n}\n\n// All odd positive signeds.\npub fn signed_gen_var_13<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<S> {\n    Generator::new(\n        &exhaustive_signed_gen_var_12,\n        &random_signed_gen_var_12,\n        &special_random_signed_gen_var_11::<U, S>,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned) --\n\npub fn signed_pair_gen<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen,\n        &random_primitive_int_pair_gen_var_1,\n        &special_random_signed_pair_gen,\n    )\n}\n\n// All pairs of signeds where either both values are non-negative or both are negative.\npub fn signed_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_1,\n        &random_signed_pair_gen_var_1,\n        &special_random_signed_pair_gen_var_1,\n    )\n}\n\n// All pairs of signeds where the second value is small.\npub fn signed_pair_gen_var_2<T: PrimitiveSigned, U: PrimitiveSigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_3,\n        &random_primitive_int_signed_pair_gen_var_1,\n        &special_random_signed_pair_gen_var_2,\n    )\n}\n\n// All pairs of signed `T` where the first is divisible by the second.\npub fn signed_pair_gen_var_3<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_4,\n        &random_signed_pair_gen_var_2,\n        &special_random_signed_pair_gen_var_3,\n    )\n}\n\n// All pairs of signed `T` where the second `T` is nonzero and the pair is not `(T::MIN, -1)`.\npub fn signed_pair_gen_var_4<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_5,\n        &random_signed_pair_gen_var_3,\n        &special_random_signed_pair_gen_var_4,\n    )\n}\n\n// All pairs of signed `T` where the second `T` is nonzero and the first is not divisible by the\n// second.\npub fn signed_pair_gen_var_5<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_6,\n        &random_signed_pair_gen_var_4,\n        &special_random_signed_pair_gen_var_5,\n    )\n}\n\n// All pairs of signed `T` where the second `T` is nonzero.\npub fn signed_pair_gen_var_6<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_7,\n        &random_signed_pair_gen_var_5,\n        &special_random_signed_pair_gen_var_6,\n    )\n}\n\n// All pairs of natural (non-negative) signeds.\npub fn signed_pair_gen_var_7<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_8,\n        &random_signed_pair_gen_var_6,\n        &special_random_signed_pair_gen_var_7,\n    )\n}\n\n// All pairs of signeds where the second element is positive and odd.\npub fn signed_pair_gen_var_8<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<(S, S)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_9,\n        &random_signed_pair_gen_var_7,\n        &special_random_signed_pair_gen_var_8::<U, S>,\n    )\n}\n\n// All coprime pairs of signeds where both elements are odd and positive.\npub fn signed_pair_gen_var_9<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() -> Generator<(S, S)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_10,\n        &random_signed_pair_gen_var_8,\n        &special_random_signed_pair_gen_var_9::<U, S>,\n    )\n}\n\n// All coprime pairs of signeds.\npub fn signed_pair_gen_var_10<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>() -> Generator<(S, S)> {\n    Generator::new(\n        &exhaustive_signed_pair_gen_var_11,\n        &random_signed_pair_gen_var_9,\n        &special_random_signed_pair_gen_var_10,\n    )\n}\n\n// All `(T, U)` where `T` and `U` are signed and both the `T` and the `U` are small.\npub fn signed_pair_gen_var_11<T: PrimitiveSigned, U: PrimitiveSigned>() -> Generator<(T, U)> {\n    Generator::new_no_special(\n        &exhaustive_signed_pair_gen_var_12,\n        &random_signed_pair_gen_var_10,\n    )\n}\n\n// All `(T, T)` where the `T`s are small, signed, and valid inputs to `T::binomial_coefficient`.\npub fn signed_pair_gen_var_12<T: PrimitiveSigned>() -> Generator<(T, T)> {\n    Generator::new_no_special(\n        &exhaustive_signed_pair_gen_var_13,\n        &random_signed_pair_gen_var_11,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned) --\n\npub fn signed_triple_gen<T: PrimitiveSigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen,\n        &random_primitive_int_triple_gen_var_4,\n        &special_random_signed_triple_gen,\n    )\n}\n\n// All `(x, y, z): (T, T, T)` where `T` is signed and x + y * z does not overflow.\npub fn signed_triple_gen_var_1<T: PrimitiveSigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen_var_1,\n        &random_signed_triple_gen_var_1,\n        &special_random_signed_triple_gen_var_1,\n    )\n}\n\n// All `(x, y, z): (T, T, T)` where `T` is signed and x - y * z does not overflow.\npub fn signed_triple_gen_var_2<T: PrimitiveSigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen_var_2,\n        &random_signed_triple_gen_var_2,\n        &special_random_signed_triple_gen_var_2,\n    )\n}\n\n// All triple of signeds where either all values are non-negative or all are negative.\npub fn signed_triple_gen_var_3<T: PrimitiveSigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen_var_3,\n        &random_signed_triple_gen_var_3,\n        &special_random_signed_triple_gen_var_3,\n    )\n}\n\n// All triples of signeds (x, y, m) where x is equal to y mod m.\npub fn signed_triple_gen_var_4<\n    U: PrimitiveUnsigned + WrappingInto<S> + WrappingFrom<S>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() -> Generator<(S, S, S)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen_var_4,\n        &random_signed_triple_gen_var_4::<U, S>,\n        &special_random_signed_triple_gen_var_4::<U, S>,\n    )\n}\n\n// All triples of signeds (x, y, m) where x is not equal to y mod m.\npub fn signed_triple_gen_var_5<T: PrimitiveSigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen_var_5,\n        &random_primitive_int_triple_gen_var_1,\n        &special_random_signed_triple_gen_var_5,\n    )\n}\n\n// All triples of signeds where the third element is positive and odd.\npub fn signed_triple_gen_var_6<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<(S, S, S)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen_var_6,\n        &random_signed_triple_gen_var_5,\n        &special_random_signed_triple_gen_var_6::<U, S>,\n    )\n}\n\n// All triples of signeds where the second and third elements are positive and odd.\npub fn signed_triple_gen_var_7<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<(S, S, S)> {\n    Generator::new(\n        &exhaustive_signed_triple_gen_var_7,\n        &random_signed_triple_gen_var_6,\n        &special_random_signed_triple_gen_var_7::<U, S>,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned, PrimitiveSigned) --\n\npub fn signed_quadruple_gen<T: PrimitiveSigned>() -> Generator<(T, T, T, T)> {\n    Generator::new(\n        &exhaustive_signed_quadruple_gen,\n        &random_primitive_int_quadruple_gen_var_4,\n        &special_random_signed_quadruple_gen,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned, PrimitiveUnsigned) --\n\n// All `(T, T, T, U)` where `T` is signed, `U` is unsigned, and the `U` is small.\npub fn signed_signed_signed_unsigned_quadruple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(T, T, T, U)> {\n    Generator::new(\n        &exhaustive_signed_signed_signed_unsigned_quadruple_gen_var_1,\n        &random_primitive_int_primitive_int_primitive_int_unsigned_quadruple_gen_var_1,\n        &special_random_signed_signed_signed_unsigned_quadruple_gen_var_2,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveUnsigned) --\n\n// All triples `(T, T, u64)` (x, y, k) where `T` is signed and x is equal to y mod $2^k$.\npub fn signed_signed_unsigned_triple_gen_var_1<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<(S, S, u64)> {\n    Generator::new(\n        &exhaustive_signed_signed_unsigned_triple_gen_var_1::<U, S>,\n        &random_signed_signed_unsigned_triple_gen_var_1::<U, S>,\n        &special_random_signed_signed_unsigned_triple_gen_var_1::<U, S>,\n    )\n}\n\n// All `(T, T, U)` where `T` is signed, `U` is unsigned, and the `U` is small.\npub fn signed_signed_unsigned_triple_gen_var_2<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_unsigned_triple_gen_var_4,\n        &random_primitive_int_primitive_int_unsigned_triple_gen_var_2,\n        &special_random_signed_signed_unsigned_triple_gen_var_2,\n    )\n}\n\n// All triples `(T, T, u64)` (x, y, k) where `T` is unsigned and x is not equal to y mod $2^k$.\npub fn signed_signed_unsigned_triple_gen_var_3<T: PrimitiveSigned>() -> Generator<(T, T, u64)> {\n    Generator::new(\n        &exhaustive_signed_signed_unsigned_triple_gen_var_2,\n        &random_primitive_int_primitive_int_unsigned_triple_gen_var_3,\n        &special_random_signed_signed_unsigned_triple_gen_var_3,\n    )\n}\n\n// All `(T, U, V)` where `T` is signed, `U` is signed and small, and `V` is unsigned, small, and\n// positive.\npub fn signed_signed_unsigned_triple_gen_var_4<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(T, U, V)> {\n    Generator::new(\n        &exhaustive_signed_signed_unsigned_triple_gen_var_3,\n        &random_signed_signed_unsigned_triple_gen_var_2,\n        &special_random_signed_signed_unsigned_triple_gen_var_4,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, RoundingMode) --\n\n// All `(T, T, RoundingMode)` where `T` is signed and the triple is a valid input to `T::div_round`.\npub fn signed_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(T, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_signed_rounding_mode_triple_gen_var_1,\n        &random_signed_signed_rounding_mode_triple_gen_var_1,\n        &special_random_signed_signed_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(T, T, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `T::round_to_multiple`.\npub fn signed_signed_rounding_mode_triple_gen_var_2<\n    U: PrimitiveUnsigned,\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>() -> Generator<(S, S, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_signed_rounding_mode_triple_gen_var_2,\n        &random_signed_signed_rounding_mode_triple_gen_var_2,\n        &special_random_signed_signed_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// All `(T, U, RoundingMode)` where `T` and `U` are signed and the triple is a valid input to\n// `T::shr_round`.\npub fn signed_signed_rounding_mode_triple_gen_var_3<T: PrimitiveSigned, U: PrimitiveSigned>()\n-> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_signed_rounding_mode_triple_gen_var_3,\n        &random_primitive_int_signed_rounding_mode_triple_gen_var_1,\n        &special_random_signed_signed_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// All `(T, U, RoundingMode)` where `T` and `U` are signed and the triple is a valid input to\n// `T::shl_round`.\npub fn signed_signed_rounding_mode_triple_gen_var_4<T: PrimitiveSigned, U: PrimitiveSigned>()\n-> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_signed_rounding_mode_triple_gen_var_4,\n        &random_primitive_int_signed_rounding_mode_triple_gen_var_2,\n        &special_random_signed_signed_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn signed_unsigned_pair_gen<T: PrimitiveSigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen,\n        &random_primitive_int_pair_gen,\n        &special_random_signed_unsigned_pair_gen,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, and the `U` is small.\npub fn signed_unsigned_pair_gen_var_1<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_2,\n        &random_primitive_int_unsigned_pair_gen_var_1,\n        &special_random_signed_unsigned_pair_gen_var_1,\n    )\n}\n\n// All `(T, u64)`s where `T` is signed and the `u64` is smaller than `T::WIDTH`.\npub fn signed_unsigned_pair_gen_var_2<T: PrimitiveSigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_4,\n        &random_primitive_int_unsigned_pair_gen_var_2,\n        &special_random_signed_unsigned_pair_gen_var_2,\n    )\n}\n\n// All `(T, u64)`s where `T` is signed and the either the `T` is negative or the `u64` is less than\n// `T::WIDTH`.\npub fn signed_unsigned_pair_gen_var_3<T: PrimitiveSigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_3,\n        &random_signed_unsigned_pair_gen_var_1,\n        &special_random_signed_unsigned_pair_gen_var_3,\n    )\n}\n\n// All `(T, u64)`s where `T` is signed and the either the `T` is non-negative or the `u64` is less\n// than `T::WIDTH`.\npub fn signed_unsigned_pair_gen_var_4<T: PrimitiveSigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_5,\n        &random_signed_unsigned_pair_gen_var_2,\n        &special_random_signed_unsigned_pair_gen_var_4,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, and the `U` is greater than 1 and no greater\n// than 36.\npub fn signed_unsigned_pair_gen_var_5<T: PrimitiveSigned, U: ExactFrom<u8> + PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_6,\n        &random_primitive_int_unsigned_pair_gen_var_5,\n        &special_random_signed_unsigned_pair_gen_var_5,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, the `T` is non-negative, and the `U` is\n// small.\npub fn signed_unsigned_pair_gen_var_6<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_7,\n        &random_signed_unsigned_pair_gen_var_3,\n        &special_random_signed_unsigned_pair_gen_var_6,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, the `T` is non-negative, and the `U` is\n// greater than 1 and no greater than 36.\npub fn signed_unsigned_pair_gen_var_7<T: PrimitiveSigned, U: ExactFrom<u8> + PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_8,\n        &random_signed_unsigned_pair_gen_var_4,\n        &special_random_signed_unsigned_pair_gen_var_7,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, the `U` is small, and the `T` is not\n// divisible by 2 to the power of the `U`.\npub fn signed_unsigned_pair_gen_var_8<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_9,\n        &random_primitive_int_unsigned_pair_gen_var_6,\n        &special_random_signed_unsigned_pair_gen_var_8,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, the `U` is small, and the `T` is divisible by\n// 2 to the power of the `U`.\npub fn signed_unsigned_pair_gen_var_9<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_10,\n        &random_primitive_int_unsigned_pair_gen_var_7,\n        &special_random_signed_unsigned_pair_gen_var_9,\n    )\n}\n\n// All `(T, u64)`s where `T` is signed and the either the `T` is non-negative or the `u64` is less\n// than or equal to `T::WIDTH`.\npub fn signed_unsigned_pair_gen_var_10<T: PrimitiveSigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_11,\n        &random_signed_unsigned_pair_gen_var_5,\n        &special_random_signed_unsigned_pair_gen_var_10,\n    )\n}\n\n// All `(S, u64)`s where `S` is signed and the either the `S` is non-positive and not `S::MIN`, or\n// the `u64` is less than `S::WIDTH`.\npub fn signed_unsigned_pair_gen_var_11<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<(S, u64)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_12,\n        &random_signed_unsigned_pair_gen_var_6,\n        &special_random_signed_unsigned_pair_gen_var_11::<U, S>,\n    )\n}\n\n// All `(T, u64)`s where `T` is signed and the `u64` is between 0 and `U::WIDTH`, inclusive.\npub fn signed_unsigned_pair_gen_var_12<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_13::<T, U>,\n        &random_primitive_int_unsigned_pair_gen_var_8::<T, U>,\n        &special_random_unsigned_pair_gen_var_17::<T, U>,\n    )\n}\n\n// All `(S, V)`s where `S` is signed, `V` is unsigned, `S` is between `-u64::MAX` and `u64::MAX`,\n// inclusive, and the `V` is positive.\npub fn signed_unsigned_pair_gen_var_13<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: PrimitiveUnsigned,\n>() -> Generator<(S, V)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_14,\n        &random_signed_unsigned_pair_gen_var_7,\n        &special_random_signed_unsigned_pair_gen_var_12::<U, S, V>,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, and both `T` and `U` are small.\npub fn signed_unsigned_pair_gen_var_14<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new_no_special(\n        &exhaustive_signed_unsigned_pair_gen,\n        &random_signed_unsigned_pair_gen_var_8,\n    )\n}\n\n// All `(T, u64)`s where `T` is signed, both the `T` and the `u64` are small, and the `T` raised to\n// the power of the `u64` does not overflow.\npub fn signed_unsigned_pair_gen_var_15<T: PrimitiveSigned>() -> Generator<(T, u64)> {\n    Generator::new_no_special(\n        &exhaustive_signed_unsigned_pair_gen_var_15,\n        &random_signed_unsigned_pair_gen_var_9,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, the `T` is positive, and the `U` is small.\npub fn signed_unsigned_pair_gen_var_16<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_int_unsigned_pair_gen_var_1,\n        &random_signed_unsigned_pair_gen_var_10,\n        &special_random_signed_unsigned_pair_gen_var_13,\n    )\n}\n\n// All `(S, V)`s where `S` is signed, `V` is unsigned, the `S` is negative and not `S::MIN`, and the\n// `V` is small.\npub fn signed_unsigned_pair_gen_var_17<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: PrimitiveUnsigned,\n>() -> Generator<(S, V)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_16,\n        &random_signed_unsigned_pair_gen_var_11,\n        &special_random_signed_unsigned_pair_gen_var_15::<U, S, V>,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, the `U` is unsigned, positive, and small, and either the `T`\n// is non-negative or the `U` is odd.\npub fn signed_unsigned_pair_gen_var_18<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_17,\n        &random_signed_unsigned_pair_gen_var_12,\n        &special_random_signed_unsigned_pair_gen_var_14,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, both `T` and `U` are small, and the `U` is\n// positive.\npub fn signed_unsigned_pair_gen_var_19<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new_no_special(\n        &exhaustive_signed_unsigned_pair_gen_var_18,\n        &random_signed_unsigned_pair_gen_var_13,\n    )\n}\n\n// All `(T, U)`s where `T` is signed, `U` is unsigned, and the `U` is small and positive.\npub fn signed_unsigned_pair_gen_var_20<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_pair_gen_var_19,\n        &random_primitive_int_unsigned_pair_gen_var_10,\n        &special_random_signed_unsigned_pair_gen_var_16,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, bool) --\n\n// All (`T`, `u64`, and `bool`) where `T` is signed and either the `u64` is smaller than `T::WIDTH`\n// or the `bool` is equal to whether the `T` is negative.\npub fn signed_unsigned_bool_triple_gen_var_1<T: PrimitiveSigned>() -> Generator<(T, u64, bool)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_bool_triple_gen_var_1,\n        &random_primitive_int_unsigned_bool_triple_gen_var_2,\n        &random_signed_unsigned_bool_triple_gen_var_1,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// All `(T, U, V)` where `T` is signed, `U` and `V` are unsigned, and the `V` is small.\npub fn signed_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(T, U, V)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_unsigned_triple_gen_var_1,\n        &random_primitive_int_primitive_int_unsigned_triple_gen_var_2,\n        &special_random_signed_unsigned_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(S, V, V)` where `S` is signed, `V` is unsigned, both `V`s are small, the first `V` is less\n// than or equal to the second, and if the `S` is negative, the difference between the two `V`s is\n// no greater than the width of `S`.\npub fn signed_unsigned_unsigned_triple_gen_var_2<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: PrimitiveUnsigned,\n>() -> Generator<(S, V, V)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_unsigned_triple_gen_var_2,\n        &random_signed_unsigned_unsigned_triple_gen_var_1,\n        &special_random_signed_unsigned_unsigned_triple_gen_var_2::<U, S, V>,\n    )\n}\n\n// All `(T, U, V)`s where `T` is signed, `U` and `V` are unsigned, the `U` is greater than 1 and no\n// greater than 36, and the `V` is small.\npub fn signed_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(T, U, V)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_unsigned_triple_gen_var_3,\n        &random_primitive_int_unsigned_unsigned_triple_gen_var_3,\n        &special_random_signed_unsigned_unsigned_triple_gen_var_3,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// All `(T, u64, u64, U)` where `T` is signed, `U` is unsigned, both `u64`s are small, and the four\n// values are valid arguments to `assign_bits`.\npub fn signed_unsigned_unsigned_unsigned_quadruple_gen_var_1<\n    T: PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n>() -> Generator<(T, u64, u64, U)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_unsigned_unsigned_quadruple_gen_var_1,\n        &random_signed_unsigned_unsigned_unsigned_quadruple_gen_var_1,\n        &special_random_signed_unsigned_unsigned_unsigned_quadruple_gen_var_1,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\n// All `(T, u64, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `T::round_to_multiple_of_power_of_2`.\npub fn signed_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_1,\n        &random_primitive_int_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_signed_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(T, U, RoundingMode)` where `T` is signed, `U` is unsigned, and the triple is a valid input\n// to `T::shr_round`.\npub fn signed_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_2,\n        &random_primitive_int_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_signed_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// vars 3 through 6 are in malachite-float.\n\n// All `(T, U, RoundingMode)` where `T` is signed, `U` is unsigned, and the `U` is positive.\npub fn signed_unsigned_rounding_mode_triple_gen_var_7<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_6,\n        &random_primitive_int_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_signed_unsigned_rounding_mode_triple_gen_var_6,\n    )\n}\n\n// All `(T, U, RoundingMode)` where `T` is small and signed, `U` is small and unsigned, and the `U`\n// is positive.\npub fn signed_unsigned_rounding_mode_triple_gen_var_8<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, RoundingMode)> {\n    Generator::new_no_special(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_6,\n        &random_signed_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// -- (PrimitiveSigned, RoundingMode) --\n\npub fn signed_rounding_mode_pair_gen<T: PrimitiveSigned>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_rounding_mode_pair_gen,\n        &random_primitive_int_rounding_mode_pair_gen,\n        &special_random_signed_rounding_mode_pair_gen,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is signed and the `T` is nonzero.\npub fn signed_rounding_mode_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_rounding_mode_pair_gen_var_1,\n        &random_signed_rounding_mode_pair_gen_var_1,\n        &special_random_signed_rounding_mode_pair_gen_var_1,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is signed and the `T` is not `T::MIN`.\npub fn signed_rounding_mode_pair_gen_var_2<T: PrimitiveSigned>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_rounding_mode_pair_gen_var_2,\n        &random_signed_rounding_mode_pair_gen_var_2,\n        &special_random_signed_rounding_mode_pair_gen_var_2,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is signed and the `T` is nonzero and not `T::MIN`.\npub fn signed_rounding_mode_pair_gen_var_3<T: PrimitiveSigned>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_rounding_mode_pair_gen_var_3,\n        &random_signed_rounding_mode_pair_gen_var_3,\n        &special_random_signed_rounding_mode_pair_gen_var_3,\n    )\n}\n\n// All `(T, RoundingMode)` where `T` is signed, `U` is a primitive float type, and the pair is a\n// valid input to `U::rounding_from`.\npub fn signed_rounding_mode_pair_gen_var_4<\n    T: PrimitiveSigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_rounding_mode_pair_gen_var_4::<T, U>,\n        &random_primitive_int_rounding_mode_pair_gen_var_1::<T, U>,\n        &special_random_signed_rounding_mode_pair_gen_var_4::<T, U>,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is small and signed.\npub fn signed_rounding_mode_pair_gen_var_5<T: PrimitiveSigned>() -> Generator<(T, RoundingMode)> {\n    Generator::new_no_special(\n        &exhaustive_signed_rounding_mode_pair_gen,\n        &random_signed_rounding_mode_pair_gen_var_4,\n    )\n}\n\n// -- (PrimitiveSigned, ToSciOptions) --\n\npub fn signed_to_sci_options_pair_gen<T: PrimitiveSigned>() -> Generator<(T, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_signed_to_sci_options_pair_gen,\n        &random_primitive_int_to_sci_options_pair_gen,\n        &special_random_signed_to_sci_options_pair_gen,\n    )\n}\n\n// All `(T, ToSciOptions)` pairs where `T` is signed and the `T` can be formatted using the options.\npub fn signed_to_sci_options_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(T, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_signed_to_sci_options_pair_gen_var_1,\n        &random_primitive_int_to_sci_options_pair_gen_var_1,\n        &special_random_signed_to_sci_options_pair_gen_var_1,\n    )\n}\n\n// -- (PrimitiveSigned, Vec<bool>) --\n\n// All `(T, Vec<bool>)` where `T` is signed and the `Vec` has as many elements as\n// `u64::exact_from(n.to_bits_asc().len())` (which is not necessarily the same as the number of\n// significant bits).\npub fn signed_bool_vec_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(T, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_signed_bool_vec_pair_gen_var_1,\n        &random_signed_bool_vec_pair_gen_var_1,\n        &special_random_signed_bool_vec_pair_gen_var_1,\n    )\n}\n\n// -- PrimitiveUnsigned --\n\npub fn unsigned_gen<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen,\n        &random_primitive_int_gen,\n        &special_random_unsigned_gen,\n    )\n}\n\n// All unsigned positive `T`s.\npub fn unsigned_gen_var_1<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_int_gen_var_1,\n        &random_unsigned_gen_var_1,\n        &special_random_unsigned_gen_var_1,\n    )\n}\n\n// All `u32`s smaller than `NUMBER_OF_CHARS`.\npub fn unsigned_gen_var_2() -> Generator<u32> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_1,\n        &random_unsigned_gen_var_2,\n        &special_random_unsigned_gen_var_2,\n    )\n}\n\n// All `u64`s between 1 and `T::WIDTH`, inclusive, where `T` is a primitive integer.\npub fn unsigned_gen_var_3<T: PrimitiveInt>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_2::<T>,\n        &random_unsigned_gen_var_3::<T>,\n        &special_random_unsigned_gen_var_3::<T>,\n    )\n}\n\n// All `U`s greater than 1 and no greater than `T::MAX`.\npub fn unsigned_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned + SaturatingFrom<T>>()\n-> Generator<U> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_4::<T, U>,\n        &random_unsigned_gen_var_4::<T, U>,\n        &special_random_unsigned_gen_var_4::<T, U>,\n    )\n}\n\n// All small unsigned `T`s.\npub fn unsigned_gen_var_5<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_gen::<T>,\n        &random_unsigned_gen_var_5::<T>,\n    )\n}\n\n// All unsigned `T`s greater than or equal to 2.\npub fn unsigned_gen_var_6<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_int_gen_var_2::<T>,\n        &random_unsigned_gen_var_6::<T>,\n        &special_random_unsigned_gen_var_5::<T>,\n    )\n}\n\n// All unsigned `T`s less than 36.\npub fn unsigned_gen_var_7<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_int_gen_var_3,\n        &random_unsigned_gen_var_7,\n        &special_random_unsigned_gen_var_6,\n    )\n}\n\n// All unsigned `T`s greater than or equal to 2 and less than or equal to 36.\npub fn unsigned_gen_var_8<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_int_gen_var_4,\n        &random_unsigned_gen_var_8,\n        &special_random_unsigned_gen_var_7,\n    )\n}\n\n// All `u64`s between 0 and `T::WIDTH`, inclusive, where `T` is a primitive integer.\npub fn unsigned_gen_var_9<T: PrimitiveInt>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_5::<T>,\n        &random_unsigned_gen_var_9::<T>,\n        &special_random_unsigned_gen_var_8::<T>,\n    )\n}\n\n// All `u8`s that correspond to an ASCII alphanumeric character: '0' through '9', 'a' through 'z',\n// and 'A' through 'Z'.\npub fn unsigned_gen_var_10() -> Generator<u8> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_6,\n        &random_unsigned_gen_var_10,\n        &special_random_unsigned_gen_var_9,\n    )\n}\n\n// All small positive unsigned `T`s.\npub fn unsigned_gen_var_11<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new_no_special(\n        &exhaustive_primitive_int_gen_var_1::<T>,\n        &random_unsigned_gen_var_11::<T>,\n    )\n}\n\n// All unsigned `T`s whose highest bit is set.\npub fn unsigned_gen_var_12<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_7,\n        &random_unsigned_gen_var_12,\n        &special_random_unsigned_gen_var_10,\n    )\n}\n\n// All unsigneds that are valid inputs into `T::from_ordered_representation` for a float type `T`.\npub fn unsigned_gen_var_13<T: PrimitiveFloat>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_8::<T>,\n        &random_unsigned_gen_var_13::<T>,\n        &special_random_unsigned_gen_var_11::<T>,\n    )\n}\n\n// All unsigned `T`s that are less than or equal to the largest representable power of 2.\npub fn unsigned_gen_var_14<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_9,\n        &random_unsigned_gen_var_14,\n        &special_random_unsigned_gen_var_12,\n    )\n}\n\n// All `u64`s between 0 and `T::WIDTH - 1`, inclusive, where `T` is a primitive integer.\npub fn unsigned_gen_var_15<T: PrimitiveInt>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_10::<T>,\n        &random_unsigned_gen_var_15::<T>,\n        &special_random_unsigned_gen_var_13::<T>,\n    )\n}\n\n// All `u64`s between 0 and `T::WIDTH - 2`, inclusive, where `T` is a primitive integer.\npub fn unsigned_gen_var_16<T: PrimitiveInt>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_11::<T>,\n        &random_unsigned_gen_var_16::<T>,\n        &special_random_unsigned_gen_var_14::<T>,\n    )\n}\n\n// All unsigned `T`s whose two highest bits are not both zero.\npub fn unsigned_gen_var_17<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_primitive_int_gen_var_5,\n        &random_unsigned_gen_var_17,\n        &special_random_unsigned_gen_var_15,\n    )\n}\n\n// All unsigneds `T` that are equal to a primitive float value of type `U`.\npub fn unsigned_gen_var_18<\n    T: PrimitiveUnsigned + RoundingFrom<U>,\n    U: ConvertibleFrom<T> + PrimitiveFloat + RoundingFrom<T>,\n>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_12::<T, U>,\n        &random_primitive_int_gen_var_1::<T, U>,\n        &special_random_primitive_int_gen_var_1::<T, U>,\n    )\n}\n\n// All unsigneds `T` that are not exactly equal to any value of a floating-point type `U`.\n//\n// Acceptable `(T, U)` pairs are those where `T::WIDTH` > `U::MANTISSA_WIDTH`.\npub fn unsigned_gen_var_19<T: PrimitiveUnsigned, U: ConvertibleFrom<T> + PrimitiveFloat>()\n-> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_13::<T, U>,\n        &random_unsigned_gen_var_18::<T, U>,\n        &special_random_unsigned_gen_var_16::<T, U>,\n    )\n}\n\n// All unsigneds `T` that are exactly between two values of a floating-point type `U`.\n//\n// Acceptable `(T, U)` pairs are those where `T::WIDTH` > `U::MANTISSA_WIDTH`.\npub fn unsigned_gen_var_20<\n    T: TryFrom<NiceFloat<U>> + PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat + RoundingFrom<T>,\n>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_14::<T, U>,\n        &random_unsigned_gen_var_19::<T, U>,\n        &special_random_unsigned_gen_var_17::<T, U>,\n    )\n}\n\n// All unsigned `T`s whose square is also representable as a `T`.\npub fn unsigned_gen_var_21<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_15,\n        &random_unsigned_gen_var_20,\n        &special_random_unsigned_gen_var_18,\n    )\n}\n\n// All odd unsigned `T`s.\npub fn unsigned_gen_var_22<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_22,\n        &random_unsigned_gen_var_21,\n        &special_random_unsigned_gen_var_19,\n    )\n}\n\npub(crate) fn smallest_invalid_value<T: PrimitiveUnsigned, F: Fn(u64) -> Option<T>>(f: F) -> u64 {\n    for n in 0.. {\n        if f(n).is_none() {\n            return n;\n        }\n    }\n    0\n}\n\n// All `u64`s whose factorial is representable as a `T`.\npub fn unsigned_gen_var_23<T: PrimitiveUnsigned>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_23::<T>,\n        &random_unsigned_gen_var_22::<T>,\n        &special_random_unsigned_gen_var_20::<T>,\n    )\n}\n\n// All `u64`s whose double factorial is representable as a `T`.\npub fn unsigned_gen_var_24<T: PrimitiveUnsigned>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_24::<T>,\n        &random_unsigned_gen_var_23::<T>,\n        &special_random_unsigned_gen_var_21::<T>,\n    )\n}\n\n// All `u64`s whose subfactorial is representable as a `T`.\npub fn unsigned_gen_var_25<T: PrimitiveUnsigned>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_25::<T>,\n        &random_unsigned_gen_var_24::<T>,\n        &special_random_unsigned_gen_var_22::<T>,\n    )\n}\n\n// All small unsigned `T`s greater than 4.\npub fn unsigned_gen_var_26<T: PrimitiveUnsigned>() -> Generator<T> {\n    Generator::new_no_special(\n        &exhaustive_primitive_int_gen_var_6,\n        &random_unsigned_gen_var_25,\n    )\n}\n\n// All `u64`s whose primorial is representable as a `T`.\npub fn unsigned_gen_var_27<T: PrimitiveUnsigned>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_26::<T>,\n        &random_unsigned_gen_var_26::<T>,\n        &special_random_unsigned_gen_var_23::<T>,\n    )\n}\n\n// All `u64`s `n` such that the product of the first `n` primes is representable as a `T`.\npub fn unsigned_gen_var_28<T: PrimitiveUnsigned>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_27::<T>,\n        &random_unsigned_gen_var_27::<T>,\n        &special_random_unsigned_gen_var_24::<T>,\n    )\n}\n\n// All unsigned prime `T`s.\npub fn unsigned_gen_var_29<T: PrimitiveUnsigned + IsPrime>() -> Generator<T> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_28,\n        &random_unsigned_gen_var_28,\n        &special_random_unsigned_gen_var_25,\n    )\n}\n\n// All `u64`s that are equal to valid scientific exponents for the float type `T`.\npub fn unsigned_gen_var_30<T: PrimitiveFloat>() -> Generator<u64> {\n    Generator::new(\n        &exhaustive_unsigned_gen_var_29::<T>,\n        &random_signed_gen_var_29::<T>,\n        &special_random_unsigned_gen_var_26::<T>,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned) --\n\npub fn unsigned_signed_pair_gen<T: PrimitiveUnsigned, U: PrimitiveSigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_pair_gen,\n        &random_primitive_int_pair_gen,\n        &special_random_unsigned_signed_pair_gen,\n    )\n}\n\n// All `(T, U)`s where `T` is unsigned, `U` is signed, and the `U` is small.\npub fn unsigned_signed_pair_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveSigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_pair_gen_var_1,\n        &random_primitive_int_signed_pair_gen_var_1,\n        &special_random_unsigned_signed_pair_gen_var_1,\n    )\n}\n\n// Given a float type `T`, returns all `(T::UnsignedOfEqualWidth, i64)` that are valid inputs to\n// `T::from_integer_mantissa_and_exponent`.\npub fn unsigned_signed_pair_gen_var_2<T: PrimitiveFloat>() -> Generator<(u64, i64)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_pair_gen_var_2::<T>,\n        &random_unsigned_signed_pair_gen_var_1::<T>,\n        &special_random_unsigned_signed_pair_gen_var_2::<T>,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned, PrimitiveUnsigned) --\n\n// All `(T, U, u64)` where `T` is unsigned, `U` is signed, the `U` is small, the u64 is no greater\n// than `T::WIDTH`, and the `T`s is less than 2 to the power of the `u64`.\npub fn unsigned_signed_unsigned_triple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveSigned>()\n-> Generator<(T, U, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_unsigned_triple_gen_var_1,\n        &random_unsigned_signed_unsigned_triple_gen_var_1,\n        &special_random_unsigned_signed_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(T, S, T)` where `T` is unsigned, `S` is signed, the `S` is between `-u64::MAX` and\n// `u64::MAX`, inclusive, and the first element is less than the third.\npub fn unsigned_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() -> Generator<(T, S, T)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_unsigned_triple_gen_var_2,\n        &random_primitive_int_signed_primitive_int_triple_gen_var_1,\n        &special_random_unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>,\n    )\n}\n\n// All `(T, U, T)` where `T` is unsigned, `U` is signed, and the first element is less than the\n// third.\npub fn unsigned_signed_unsigned_triple_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveSigned>()\n-> Generator<(T, U, T)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_unsigned_triple_gen_var_3,\n        &random_primitive_int_triple_gen_var_3,\n        &special_random_unsigned_signed_unsigned_triple_gen_var_3,\n    )\n}\n\n// All `(T, U, V)` where `T` is unsigned, `U` is signed and small, and `V` is unsigned, small, and\n// positive.\npub fn unsigned_signed_unsigned_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(T, U, V)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_unsigned_triple_gen_var_4,\n        &random_unsigned_signed_unsigned_triple_gen_var_2,\n        &special_random_unsigned_signed_unsigned_triple_gen_var_4,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned, RoundingMode) --\n\n// All `(T, U, RoundingMode)` where `T` is unsigned, `U` is signed, and the triple is a valid input\n// to `T::shr_round`.\npub fn unsigned_signed_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveSigned>()\n-> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_rounding_mode_triple_gen_var_1,\n        &random_primitive_int_signed_rounding_mode_triple_gen_var_1,\n        &special_random_unsigned_signed_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(T, U, RoundingMode)` where `T` is unsigned, `U` is signed, and the triple is a valid input\n// to `T::shl_round`.\npub fn unsigned_signed_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveSigned>()\n-> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_signed_rounding_mode_triple_gen_var_2,\n        &random_primitive_int_signed_rounding_mode_triple_gen_var_2,\n        &special_random_unsigned_signed_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn unsigned_pair_gen<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen,\n        &random_primitive_int_pair_gen,\n        &special_random_unsigned_pair_gen,\n    )\n}\n\n// All `(u32, u32)`s where each `u32` is smaller than `NUMBER_OF_CHARS`.\npub fn unsigned_pair_gen_var_1() -> Generator<(u32, u32)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_1,\n        &random_unsigned_pair_gen_var_1,\n        &special_random_unsigned_pair_gen_var_26,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned and the `U` is small.\npub fn unsigned_pair_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_2,\n        &random_primitive_int_unsigned_pair_gen_var_1,\n        &special_random_unsigned_pair_gen_var_1,\n    )\n}\n\n// All `(T, u64)`s where `T` is unsigned and the `u64` is smaller than `T::WIDTH`.\npub fn unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_3,\n        &random_primitive_int_unsigned_pair_gen_var_2,\n        &special_random_unsigned_pair_gen_var_2,\n    )\n}\n\n// All `(T, u64)`s where `T` is unsigned and the `u64` is between 1 and `U::WIDTH`, inclusive.\npub fn unsigned_pair_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, u64)>\n{\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_4::<T, U>,\n        &random_primitive_int_unsigned_pair_gen_var_3::<T, U>,\n        &special_random_unsigned_pair_gen_var_3::<T, U>,\n    )\n}\n\n// All `(T, u64)`s where `T` is unsigned, the `T` is small, and the `u64` is between 1 and\n// `U::WIDTH`, inclusive.\npub fn unsigned_pair_gen_var_5<T: PrimitiveUnsigned, U: PrimitiveInt>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_4::<T, U>,\n        &random_unsigned_pair_gen_var_2::<T, U>,\n        &special_random_unsigned_pair_gen_var_27::<T, U>,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned and the `U` is greater than 1 and no greater than\n// `T::MAX`.\npub fn unsigned_pair_gen_var_6<T: PrimitiveUnsigned, U: PrimitiveUnsigned + SaturatingFrom<T>>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_5::<T, U>,\n        &random_primitive_int_unsigned_pair_gen_var_4::<T, U>,\n        &special_random_unsigned_pair_gen_var_4::<T, U>,\n    )\n}\n\n// All `(T, T)` where `T` is unsigned and the first element is less than or equal to the second.\npub fn unsigned_pair_gen_var_7<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_6,\n        &random_primitive_int_pair_gen_var_2,\n        &special_random_unsigned_pair_gen_var_5,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned and the `U` is greater than 1 and no greater than\n// 36.\npub fn unsigned_pair_gen_var_8<T: PrimitiveUnsigned, U: ExactFrom<u8> + PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_primitive_int_pair_gen_var_2,\n        &random_primitive_int_unsigned_pair_gen_var_5,\n        &special_random_unsigned_pair_gen_var_6,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned, the `T` is small, and the `U` is greater than 1 and\n// no greater than 36.\npub fn unsigned_pair_gen_var_9<T: PrimitiveUnsigned, U: ExactFrom<u8> + PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_primitive_int_pair_gen_var_2,\n        &random_unsigned_pair_gen_var_3,\n        &special_random_unsigned_pair_gen_var_28,\n    )\n}\n\n// All `(T, V)`s where `T` is unsigned, the `T` is between 2 and `max(T::MAX, U::MAX)`, inclusive,\n// and the `V` is small.\npub fn unsigned_pair_gen_var_10<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(T, V)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_7::<T, U, V>,\n        &random_unsigned_pair_gen_var_4::<T, U, V>,\n        &special_random_unsigned_pair_gen_var_29::<T, U, V>,\n    )\n}\n\n// All pairs of unsigned `T` where the first is divisible by the second, and the second is positive.\npub fn unsigned_pair_gen_var_11<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_8,\n        &random_unsigned_pair_gen_var_5,\n        &special_random_unsigned_pair_gen_var_7,\n    )\n}\n\n// All pairs of unsigned `T` and `U` where the `U` is positive.\npub fn unsigned_pair_gen_var_12<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_9,\n        &random_unsigned_pair_gen_var_6,\n        &special_random_unsigned_pair_gen_var_8,\n    )\n}\n\n// All pairs of unsigned `T` where the second `T` is positive and the first is not divisible by the\n// second.\npub fn unsigned_pair_gen_var_13<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_10,\n        &random_unsigned_pair_gen_var_7,\n        &special_random_unsigned_pair_gen_var_9,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned, the `U` is small, and the `T` is not divisible by 2\n// to the power of the `U`.\npub fn unsigned_pair_gen_var_14<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_11,\n        &random_primitive_int_unsigned_pair_gen_var_6,\n        &special_random_unsigned_pair_gen_var_10,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned, the `U` is small, and the `T` is divisible by 2 to\n// the power of the `U`.\npub fn unsigned_pair_gen_var_15<T: PrimitiveUnsigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_12,\n        &random_primitive_int_unsigned_pair_gen_var_7,\n        &special_random_unsigned_pair_gen_var_11,\n    )\n}\n\n// All `(T, T)` where `T` is unsigned and the first element is smaller than the second.\npub fn unsigned_pair_gen_var_16<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_13,\n        &random_primitive_int_pair_gen_var_3,\n        &special_random_unsigned_pair_gen_var_12,\n    )\n}\n\n// All `(T, u64)` where `T` is unsigned, the u64 is no greater than `T::WIDTH`, and the `T` is less\n// than 2 to the power of the `u64`.\npub fn unsigned_pair_gen_var_17<T: PrimitiveUnsigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_14,\n        &random_unsigned_pair_gen_var_8,\n        &special_random_unsigned_pair_gen_var_13,\n    )\n}\n\n// All `(T, U)` where `T` and `U` are unsigned, the `T` and the `U` are small, and the `U` is\n// positive.\npub fn unsigned_pair_gen_var_18<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_primitive_int_gen_var_1,\n        &random_unsigned_pair_gen_var_9,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned, the `T` is positive and small, and the `U` is\n// greater than 1 and no greater than 36.\npub fn unsigned_pair_gen_var_19<T: PrimitiveUnsigned, U: ExactFrom<u8> + PrimitiveUnsigned>()\n-> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_int_pair_gen_var_1,\n        &random_unsigned_pair_gen_var_10,\n        &special_random_unsigned_pair_gen_var_30,\n    )\n}\n\n// All `(T, u64)`s where `T` is unsigned, and either the `T` is 0 or the `u64` is less than\n// `T::WIDTH`.\npub fn unsigned_pair_gen_var_20<T: PrimitiveUnsigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_15,\n        &random_unsigned_pair_gen_var_11,\n        &special_random_unsigned_pair_gen_var_31,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned and positive and the `U` is small.\npub fn unsigned_pair_gen_var_21<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_int_pair_gen_var_2,\n        &random_unsigned_pair_gen_var_12,\n        &special_random_unsigned_pair_gen_var_14,\n    )\n}\n\n// All pairs of unsigneds that each are valid inputs into `T::from_ordered_representation` for a\n// float type `T`.\npub fn unsigned_pair_gen_var_22<T: PrimitiveFloat>() -> Generator<(u64, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_16::<T>,\n        &random_unsigned_pair_gen_var_13::<T>,\n        &special_random_unsigned_pair_gen_var_32::<T>,\n    )\n}\n\n// All `(T, u64)`s where `T` is unsigned and the `u64` is between 0 and `U::WIDTH`, inclusive.\npub fn unsigned_pair_gen_var_23<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, u64)>\n{\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_17::<T, U>,\n        &random_primitive_int_unsigned_pair_gen_var_8::<T, U>,\n        &special_random_unsigned_pair_gen_var_15::<T, U>,\n    )\n}\n\n// All pairs of unsigneds where the first element is positive and the second is greater than 1.\npub fn unsigned_pair_gen_var_24<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_int_pair_gen_var_3,\n        &random_unsigned_pair_gen_var_14,\n        &special_random_unsigned_pair_gen_var_16,\n    )\n}\n\n// All pairs of unsigned `T` and `U` where the `U` is no greater than `u64::MAX` and `T` is\n// positive.\npub fn unsigned_pair_gen_var_25<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_18,\n        &random_unsigned_pair_gen_var_15,\n        &special_random_unsigned_pair_gen_var_18,\n    )\n}\n\n// Given a float type `T`, all `(u64, u64)` that are valid raw mantissas and exponents of a value of\n// type `T`.\npub fn unsigned_pair_gen_var_26<T: PrimitiveFloat>() -> Generator<(u64, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_19::<T>,\n        &random_unsigned_pair_gen_var_16::<T>,\n        &special_random_unsigned_pair_gen_var_19::<T>,\n    )\n}\n\n// All pairs of unsigneds of the same type.\npub fn unsigned_pair_gen_var_27<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_20,\n        &random_primitive_int_pair_gen_var_1,\n        &special_random_unsigned_pair_gen_var_35,\n    )\n}\n\n// All `(T, U)` where `T` and `U` are unsigned and both the `T` and the `U` are small.\npub fn unsigned_pair_gen_var_28<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen,\n        &random_unsigned_pair_gen_var_17,\n    )\n}\n\n// All `(T, u64)` where `T` is unsigned, both the `T` and the `u64` are small, and the `T` raised\n// the power of the `u64` does not overflow.\npub fn unsigned_pair_gen_var_29<T: PrimitiveUnsigned>() -> Generator<(T, u64)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_21,\n        &random_unsigned_pair_gen_var_18,\n    )\n}\n\n// All `(T, u64)` where `T` is unsigned and the `u64` is no greater than the number of leading zeros\n// of the `T`.\npub fn unsigned_pair_gen_var_30<T: PrimitiveUnsigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_22,\n        &random_unsigned_pair_gen_var_19,\n        &special_random_unsigned_pair_gen_var_20,\n    )\n}\n\n// All pairs of unsigned `T` where the two highest bits of the first `T` are not both zero.\npub fn unsigned_pair_gen_var_31<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_primitive_int_unsigned_pair_gen_var_2::<T, T>,\n        &random_unsigned_primitive_int_pair_gen_var_1::<T, T>,\n        &special_random_unsigned_pair_gen_var_33::<T, T>,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned and the `U` is small and positive.\npub fn unsigned_pair_gen_var_32<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_primitive_int_gen_var_3,\n        &random_primitive_int_unsigned_pair_gen_var_9,\n        &special_random_unsigned_pair_gen_var_21,\n    )\n}\n\n// All `(T, T)`s where `T` is unsigned. When the generation mode is random or special random, the\n// pairs are selected from a distribution such that their product is likely to be representable.\npub fn unsigned_pair_gen_var_33<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_20,\n        &random_unsigned_pair_gen_var_21,\n        &special_random_unsigned_pair_gen_var_22,\n    )\n}\n\n// All `(T, T)`s where the LCM of the two numbers is representable.\npub fn unsigned_pair_gen_var_34<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_23,\n        &random_unsigned_pair_gen_var_22,\n        &special_random_unsigned_pair_gen_var_23,\n    )\n}\n\n// All pairs of unsigneds where the highest bit of the first element is set.\npub fn unsigned_pair_gen_var_35<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_24,\n        &random_unsigned_pair_gen_var_23,\n        &special_random_unsigned_pair_gen_var_24,\n    )\n}\n\n// All pairs of unsigneds that are valid inputs to `limbs_precompute_mod_mul_two_limbs`.\npub fn unsigned_pair_gen_var_36<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_25,\n        &random_unsigned_pair_gen_var_24,\n        &special_random_unsigned_pair_gen_var_25,\n    )\n}\n\n// All `(T, U)`s where `T` and `U` are unsigned, the `T` is positive, and the `U` is small.\npub fn unsigned_pair_gen_var_37<T: PrimitiveUnsigned, U: PrimitiveUnsigned>() -> Generator<(T, U)> {\n    Generator::new(\n        &exhaustive_primitive_int_unsigned_pair_gen_var_1,\n        &random_unsigned_pair_gen_var_25,\n        &special_random_unsigned_pair_gen_var_34,\n    )\n}\n\n// All `(T, T)` where `T` is unsigned, both elements are nonzero, and the first element is smaller\n// than the second.\npub fn unsigned_pair_gen_var_38<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_primitive_int_pair_gen_var_4,\n        &random_unsigned_pair_gen_var_26,\n        &special_random_unsigned_pair_gen_var_36,\n    )\n}\n\n// All `(T, u64)` where `T` is unsigned, the u64 is no greater than `T::WIDTH`, the `T` is positive,\n// and the `T` is less than 2 to the power of the `u64`.\npub fn unsigned_pair_gen_var_39<T: PrimitiveUnsigned>() -> Generator<(T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_26,\n        &random_unsigned_pair_gen_var_27,\n        &special_random_unsigned_pair_gen_var_37,\n    )\n}\n\n// All pairs of unsigneds where the second element is odd.\npub fn unsigned_pair_gen_var_40<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_27,\n        &random_unsigned_pair_gen_var_28,\n        &special_random_unsigned_pair_gen_var_38,\n    )\n}\n\n// All coprime pairs of unsigneds where both elements are odd.\npub fn unsigned_pair_gen_var_41<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_28,\n        &random_unsigned_pair_gen_var_29,\n        &special_random_unsigned_pair_gen_var_39,\n    )\n}\n\n// All coprime pairs of unsigneds of the same type.\npub fn unsigned_pair_gen_var_42<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_pair_gen_var_29,\n        &random_unsigned_pair_gen_var_30,\n        &special_random_unsigned_pair_gen_var_40,\n    )\n}\n\n// All pairs `u64`s that are valid inputs to `T::multifactorial`.\npub fn unsigned_pair_gen_var_43<T: PrimitiveUnsigned>() -> Generator<(u64, u64)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_30::<T>,\n        &random_unsigned_pair_gen_var_31::<T>,\n    )\n}\n\n// All `(T, T)` where the `T`s are small, unsigned, and valid inputs to `T::binomial_coefficient`.\npub fn unsigned_pair_gen_var_44<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_31,\n        &random_unsigned_pair_gen_var_32,\n    )\n}\n\n// vars 45 through 49 are in malachite-nz\n\n// All pairs of unsigneds of the same type, where each value is greater than 1.\npub fn unsigned_pair_gen_var_50<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new(\n        &exhaustive_primitive_int_unsigned_pair_gen_var_3,\n        &random_unsigned_pair_gen_var_38,\n        &special_random_unsigned_pair_gen_var_41,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, bool) --\n\n// All `(T, u64, `bool) where `T` is unsigned and either the `bool` is false or the `u64` is smaller\n// than `T::WIDTH`.\npub fn unsigned_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, u64, bool)>\n{\n    Generator::new(\n        &exhaustive_unsigned_unsigned_bool_triple_gen_var_1,\n        &random_primitive_int_unsigned_bool_triple_gen_var_1,\n        &special_random_unsigned_unsigned_bool_triple_gen_var_1,\n    )\n}\n\n// All `(T, U, bool)` where `T` and `U` are unsigned and the `U` is positive.\npub fn unsigned_unsigned_bool_triple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, bool)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_bool_triple_gen_var_2,\n        &random_primitive_int_unsigned_bool_triple_gen_var_3,\n        &special_random_unsigned_unsigned_bool_triple_gen_var_2,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// All `(x, y, z): (T, T, T)` where `T` is unsigned and x + y * z does not overflow.\npub fn unsigned_triple_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_1,\n        &random_unsigned_triple_gen_var_1,\n        &special_random_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(x, y, z): (T, T, T)` where `T` is unsigned and x - y * z does not overflow.\npub fn unsigned_triple_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_2,\n        &random_unsigned_triple_gen_var_2,\n        &special_random_unsigned_triple_gen_var_2,\n    )\n}\n\n// All `(T, u64, V)` where `T` is unsigned, the `u64` is between 1 and `U::WIDTH`, inclusive, and\n// `V` is unsigned and the `V` is small.\npub fn unsigned_triple_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveInt, V: PrimitiveUnsigned>()\n-> Generator<(T, u64, V)> {\n    Generator::new(\n        &exhaustive_unsigned_primitive_int_unsigned_triple_gen_var_3::<T, U, V>,\n        &random_primitive_int_unsigned_unsigned_triple_gen_var_1::<T, U, V>,\n        &special_random_unsigned_triple_gen_var_3::<T, U, V>,\n    )\n}\n\n// All `(T, T, U)` where `T` and `U` are unsigned and the `U` is small.\npub fn unsigned_triple_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_3,\n        &random_primitive_int_primitive_int_unsigned_triple_gen_var_1,\n        &special_random_unsigned_triple_gen_var_4,\n    )\n}\n\n// All `(T, U, U)` where `T` and `U` are unsigned, both `U`s are small, and the second `U` is less\n// than or equal to the third.\npub fn unsigned_triple_gen_var_5<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, U)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_4,\n        &random_primitive_int_unsigned_unsigned_triple_gen_var_2,\n        &special_random_unsigned_triple_gen_var_5,\n    )\n}\n\n// All `(T, U, V)`s where `T`, `U`, and `V` are unsigned, the `U` is greater than 1 and no greater\n// than 36, and the `V` is small.\npub fn unsigned_triple_gen_var_6<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(T, U, V)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_5,\n        &random_primitive_int_unsigned_unsigned_triple_gen_var_3,\n        &special_random_unsigned_triple_gen_var_6,\n    )\n}\n\n// All triples of unsigneds (x, y, m) where x is equal to y mod m.\npub fn unsigned_triple_gen_var_7<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_6,\n        &random_unsigned_triple_gen_var_3,\n        &special_random_unsigned_triple_gen_var_7,\n    )\n}\n\n// All triples of unsigneds (x, y, m) where x is not equal to y mod m.\npub fn unsigned_triple_gen_var_8<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_7,\n        &random_primitive_int_triple_gen_var_1,\n        &special_random_unsigned_triple_gen_var_8,\n    )\n}\n\n// All triples `(T, T, u64)` (x, y, k) where `T` is unsigned and x is equal to y mod $2^k$.\npub fn unsigned_triple_gen_var_9<T: PrimitiveUnsigned>() -> Generator<(T, T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_8,\n        &random_unsigned_triple_gen_var_4,\n        &special_random_unsigned_triple_gen_var_9,\n    )\n}\n\n// All triples `(T, T, u64)` (x, y, k) where `T` is unsigned and x is not equal to y mod $2^k$.\npub fn unsigned_triple_gen_var_10<T: PrimitiveUnsigned>() -> Generator<(T, T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_9,\n        &random_primitive_int_primitive_int_unsigned_triple_gen_var_3,\n        &special_random_unsigned_triple_gen_var_10,\n    )\n}\n\n// All `(T, T, u64)` where `T` is unsigned, the u64 is no greater than `T::WIDTH`, and both `T`s are\n// less than 2 to the power of the `u64`.\npub fn unsigned_triple_gen_var_11<T: PrimitiveUnsigned>() -> Generator<(T, T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_10,\n        &random_unsigned_triple_gen_var_5,\n        &special_random_unsigned_triple_gen_var_11,\n    )\n}\n\n// All `(T, T, T)` where `T` is unsigned and the first and second elements are less than the third.\npub fn unsigned_triple_gen_var_12<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_11,\n        &random_primitive_int_triple_gen_var_2,\n        &special_random_unsigned_triple_gen_var_12,\n    )\n}\n\n// All `(T, U, U)` where `T` and `U` are unsigned and the `U`s are small.\npub fn unsigned_triple_gen_var_13<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, U)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_12,\n        &random_primitive_int_unsigned_unsigned_triple_gen_var_4,\n        &special_random_unsigned_triple_gen_var_13,\n    )\n}\n\n// All `(T, U, T)` where `T` and `U` are unsigned, the `U` is small, and the first element is less\n// than the third.\npub fn unsigned_triple_gen_var_14<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_13,\n        &random_primitive_int_unsigned_primitive_int_triple_gen_var_1,\n        &special_random_unsigned_triple_gen_var_14,\n    )\n}\n\n// All `(T, U, T)` where `T` and `U` are unsigned and the first element is less than the third.\npub fn unsigned_triple_gen_var_15<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_14,\n        &random_primitive_int_triple_gen_var_3,\n        &special_random_unsigned_triple_gen_var_15,\n    )\n}\n\n// All `(T, U, u64)` where `T` and `U` are unsigned, the u64 is no greater than `T::WIDTH`, and the\n// `T`s is less than 2 to the power of the `u64`.\npub fn unsigned_triple_gen_var_16<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_15,\n        &random_unsigned_primitive_int_unsigned_triple_gen_var_1,\n        &special_random_unsigned_triple_gen_var_16,\n    )\n}\n\n// All `(T, U, u64)` where `T` and `U` are unsigned, the `U` is small, the u64 is no greater than\n// `T::WIDTH`, and the `T`s is less than 2 to the power of the `u64`.\npub fn unsigned_triple_gen_var_17<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_15,\n        &random_unsigned_triple_gen_var_6,\n        &special_random_unsigned_triple_gen_var_17,\n    )\n}\n\n// All `(T, U, T)` where `T` and `U` are unsigned, the `U` is no larger than `u64::MAX`, and the\n// first element is less than the third.\npub fn unsigned_triple_gen_var_18<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_16,\n        &random_primitive_int_unsigned_primitive_int_triple_gen_var_2,\n        &special_random_unsigned_triple_gen_var_18,\n    )\n}\n\n// All triples of unsigneds of the same type.\npub fn unsigned_triple_gen_var_19<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_17,\n        &random_primitive_int_triple_gen_var_4,\n        &special_random_unsigned_triple_gen_var_19,\n    )\n}\n\n// All `(T, U, U)` where `T` and `U` are unsigned, both `U`s are small, the `T` is positive, and the\n// first `U` is less than or equal to the second.\npub fn unsigned_triple_gen_var_20<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, U)> {\n    Generator::new(\n        &exhaustive_primitive_int_unsigned_unsigned_triple_gen_var_1,\n        &random_unsigned_triple_gen_var_7,\n        &special_random_unsigned_triple_gen_var_20,\n    )\n}\n\n// All triples of unsigneds where the second element is odd.\npub fn unsigned_triple_gen_var_21<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_18,\n        &random_unsigned_triple_gen_var_8,\n        &special_random_unsigned_triple_gen_var_21,\n    )\n}\n\n// All triples of unsigneds where the third element is odd.\npub fn unsigned_triple_gen_var_22<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_19,\n        &random_unsigned_triple_gen_var_9,\n        &special_random_unsigned_triple_gen_var_22,\n    )\n}\n\n// All triples of unsigneds where the second and third elements are odd.\npub fn unsigned_triple_gen_var_23<T: PrimitiveUnsigned>() -> Generator<(T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_triple_gen_var_20,\n        &random_unsigned_triple_gen_var_10,\n        &special_random_unsigned_triple_gen_var_23,\n    )\n}\n\n// All `(T, T, U)`, where `T` and `U` are unsigned, and everything is small.\npub fn unsigned_triple_gen_var_24<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, T, U)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_triple_gen_var_21,\n        &random_unsigned_triple_gen_var_11,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// All `(T, u64, u64, U)` where `T` and `U` are unsigned, both `u64`s are small, and the four values\n// are valid arguments to `assign_bits`.\npub fn unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, u64, u64, U)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_1,\n        &random_primitive_int_unsigned_unsigned_unsigned_quadruple_gen_var_1,\n        &special_random_unsigned_quadruple_gen_var_1,\n    )\n}\n\n// All `(T, T, T, U)` where `T` and `U` are unsigned and the `U` is small.\npub fn unsigned_quadruple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, T, T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_2,\n        &random_primitive_int_primitive_int_primitive_int_unsigned_quadruple_gen_var_1,\n        &special_random_unsigned_quadruple_gen_var_2,\n    )\n}\n\n// All `(T, T, T, u64)` where `T` is unsigned, the u64 is no greater than `T::WIDTH`, and all three\n// `T`s are less than 2 to the power of the `u64`.\npub fn unsigned_quadruple_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(T, T, T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_3,\n        &random_unsigned_quadruple_gen_var_1,\n        &special_random_unsigned_quadruple_gen_var_3,\n    )\n}\n\n// All `(T, T, T, T)` where `T` is unsigned and the first three elements are each less than the\n// fourth.\npub fn unsigned_quadruple_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_4,\n        &random_primitive_int_quadruple_gen_var_1,\n        &special_random_unsigned_quadruple_gen_var_4,\n    )\n}\n\n// All `(T, T, T, T)` that are valid inputs to `limbs_mod_preinverted`.\npub fn unsigned_quadruple_gen_var_5<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>() -> Generator<(T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_5::<T, DT>,\n        &random_unsigned_quadruple_gen_var_2::<T, DT>,\n        &special_random_unsigned_quadruple_gen_var_5::<T, DT>,\n    )\n}\n\n// All `(T, T, U, T)` where `T` and `U` are unsigned and the first two elements are each less than\n// the fourth.\npub fn unsigned_quadruple_gen_var_6<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, T, U, T)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_6,\n        &random_primitive_int_quadruple_gen_var_2,\n        &special_random_unsigned_quadruple_gen_var_6,\n    )\n}\n\n// All `(T, U, U, T)` where `T` and `U` are unsigned and the first element is less than the fourth.\npub fn unsigned_quadruple_gen_var_7<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, U, T)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_7,\n        &random_primitive_int_quadruple_gen_var_3,\n        &special_random_unsigned_quadruple_gen_var_7,\n    )\n}\n\n// All `(T, T, U, u64)` where `T` and `U` are unsigned, the u64 is no greater than `T::WIDTH`, and\n// both `T`s are less than 2 to the power of the `u64`.\npub fn unsigned_quadruple_gen_var_8<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, T, U, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_8,\n        &random_unsigned_unsigned_primitive_int_unsigned_quadruple_gen_var_1,\n        &special_random_unsigned_quadruple_gen_var_8,\n    )\n}\n\n// All `(T, U, U, u64)` where `T` and `U` are unsigned, the u64 is no greater than `T::WIDTH`, and\n// the `T`s is less than 2 to the power of the `u64`.\npub fn unsigned_quadruple_gen_var_9<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(T, U, U, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_9,\n        &random_unsigned_primitive_int_primitive_int_unsigned_quadruple_gen_var_1,\n        &special_random_unsigned_quadruple_gen_var_9,\n    )\n}\n\n// All quadruples of unsigneds of the same type.\npub fn unsigned_quadruple_gen_var_10<T: PrimitiveUnsigned>() -> Generator<(T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_10,\n        &random_primitive_int_quadruple_gen_var_4,\n        &special_random_unsigned_quadruple_gen_var_10,\n    )\n}\n\n// All quadruples of unsigneds which, if grouped into two double-width unsigneds N and D (high\n// halves first) satisfy D >= 2^W, N >= D, and N / D < 2^W.\npub fn unsigned_quadruple_gen_var_11<T: PrimitiveUnsigned>() -> Generator<(T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_11,\n        &random_primitive_int_quadruple_gen_var_5,\n        &special_random_unsigned_quadruple_gen_var_11,\n    )\n}\n\n// All quadruples of unsigneds where the fourth element is odd.\npub fn unsigned_quadruple_gen_var_12<T: PrimitiveUnsigned>() -> Generator<(T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_quadruple_gen_var_12,\n        &random_unsigned_quadruple_gen_var_3,\n        &special_random_unsigned_quadruple_gen_var_12,\n    )\n}\n\n// -- (PrimitiveUnsigned * 6) --\n\n// All sextuples of unsigneds of the same type.\npub fn unsigned_sextuple_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, T, T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_sextuple_gen_var_1,\n        &random_primitive_int_sextuple_gen_var_1,\n        &special_random_unsigned_sextuple_gen_var_1,\n    )\n}\n\n// var 2 is in malachite-nz.\n\n// -- (PrimitiveUnsigned * 8) --\n\n// All octuples of unsigneds of the same type.\n#[allow(clippy::type_complexity)]\npub fn unsigned_octuple_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, T, T, T, T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_octuple_gen_var_1,\n        &random_primitive_int_octuple_gen_var_1,\n        &special_random_unsigned_octuple_gen_var_1,\n    )\n}\n\n// -- (PrimitiveUnsigned * 9) --\n\n// All nonuples of unsigneds of the same type.\n#[allow(clippy::type_complexity)]\npub fn unsigned_nonuple_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, T, T, T, T, T, T, T, T)>\n{\n    Generator::new(\n        &exhaustive_unsigned_nonuple_gen_var_1,\n        &random_primitive_int_nonuple_gen_var_1,\n        &special_random_unsigned_nonuple_gen_var_1,\n    )\n}\n\n// -- (PrimitiveUnsigned * 12) --\n\n// All duodecuples of unsigneds of the same type.\n#[allow(clippy::type_complexity)]\npub fn unsigned_duodecuple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(T, T, T, T, T, T, T, T, T, T, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_duodecuple_gen_var_1,\n        &random_primitive_int_duodecuple_gen_var_1,\n        &special_random_unsigned_duodecuple_gen_var_1,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\n// All `(T, T, RoundingMode)` that are valid inputs to `T::div_round`.\npub fn unsigned_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(T, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_1,\n        &random_unsigned_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_unsigned_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(T, T, RoundingMode)` where `T` is unsigned and the triple is a valid input to\n// `T::round_to_multiple`.\npub fn unsigned_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(T, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_3,\n        &random_unsigned_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_unsigned_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// All `(T, u64, RoundingMode)` where `T` is unsigned and the triple is a valid input to\n// `T::round_to_multiple_of_power_of_2`.\npub fn unsigned_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> Generator<(T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_4,\n        &random_primitive_int_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_unsigned_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// All `(T, U, RoundingMode)` where `T` is unsigned, `U` is unsigned, and the triple is a valid\n// input to `T::shr_round`.\npub fn unsigned_unsigned_rounding_mode_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_5,\n        &random_primitive_int_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_unsigned_unsigned_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// vars 5 through 6 are in malachite-float.\n\n// All `(T, U, RoundingMode)` where `T` and `U` are unsigned and the `U` is positive.\npub fn unsigned_unsigned_rounding_mode_triple_gen_var_7<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(T, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_8,\n        &random_primitive_int_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_unsigned_unsigned_rounding_mode_triple_gen_var_7,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, Vec<bool>) --\n\n// All `(T, u64, Vec<bool>)` where `T` is unsigned, the `u64` is between 1 and `U::WIDTH`,\n// inclusive, and the `Vec` has as many elements as the `T` has digits in base $2^\\ell$, where\n// $\\ell$ is the `u64`.\npub fn unsigned_unsigned_bool_vec_triple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> Generator<(T, u64, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_bool_vec_triple_gen_var_1::<T, U>,\n        &random_primitive_int_unsigned_bool_vec_triple_gen_var_1::<T, U>,\n        &special_random_unsigned_unsigned_bool_vec_triple_gen_var_1::<T, U>,\n    )\n}\n\n// -- (PrimitiveUnsigned, RoundingMode) --\n\npub fn unsigned_rounding_mode_pair_gen<T: PrimitiveUnsigned>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_rounding_mode_pair_gen,\n        &random_primitive_int_rounding_mode_pair_gen,\n        &special_random_unsigned_rounding_mode_pair_gen,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is unsigned and the `T` is positive.\npub fn unsigned_rounding_mode_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_primitive_int_rounding_mode_pair_gen_var_1,\n        &random_unsigned_rounding_mode_pair_gen_var_1,\n        &special_random_unsigned_rounding_mode_pair_gen_var_1,\n    )\n}\n\n// All `(T, RoundingMode)` where `T` is unsigned, `U` is a primitive float type, and the pair is a\n// valid input to `U::rounding_from`.\npub fn unsigned_rounding_mode_pair_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>() -> Generator<(T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_rounding_mode_pair_gen_var_1::<T, U>,\n        &random_primitive_int_rounding_mode_pair_gen_var_1::<T, U>,\n        &special_random_unsigned_rounding_mode_pair_gen_var_2::<T, U>,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is small, unsigned, and positive.\npub fn unsigned_rounding_mode_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(T, RoundingMode)>\n{\n    Generator::new_no_special(\n        &exhaustive_primitive_int_rounding_mode_pair_gen_var_1,\n        &random_unsigned_rounding_mode_pair_gen_var_2,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is small, unsigned, and positive, and the rounding mode is not\n// `Exact`.\npub fn unsigned_rounding_mode_pair_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(T, RoundingMode)>\n{\n    Generator::new_no_special(\n        &exhaustive_primitive_int_rounding_mode_pair_gen_var_2,\n        &random_unsigned_rounding_mode_pair_gen_var_3,\n    )\n}\n\n// All `(T, RoundingMode)`s where `T` is small and unsigned.\npub fn unsigned_rounding_mode_pair_gen_var_5<T: PrimitiveUnsigned>() -> Generator<(T, RoundingMode)>\n{\n    Generator::new_no_special(\n        &exhaustive_unsigned_rounding_mode_pair_gen,\n        &random_unsigned_rounding_mode_pair_gen_var_4,\n    )\n}\n\n// -- (PrimitiveUnsigned, String) --\n\n// All `(u8, String)` that, when passed to `Natural::from_string_base`, return a `Some`.\npub fn unsigned_string_pair_gen_var_1() -> Generator<(u8, String)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_string_pair_gen_var_1,\n        &random_unsigned_string_pair_gen_var_1,\n    )\n}\n\n// All `(u8, String)` that are valid inputs to `Natural::from_string_base` or\n// `Integer::from_string_base`, regardless of whether it returns `Some` or `None`.\npub fn unsigned_string_pair_gen_var_2() -> Generator<(u8, String)> {\n    Generator::new(\n        &exhaustive_unsigned_string_pair_gen_var_2,\n        &random_unsigned_string_pair_gen_var_2,\n        &special_random_unsigned_string_pair_gen_var_1,\n    )\n}\n\n// All `(u8, String)` that, when passed to `Integer::from_string_base`, return a `Some`.\npub fn unsigned_string_pair_gen_var_3() -> Generator<(u8, String)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_string_pair_gen_var_3,\n        &random_unsigned_string_pair_gen_var_3,\n    )\n}\n\n// -- (PrimitiveUnsigned, ToSciOptions) --\n\npub fn unsigned_to_sci_options_pair_gen<T: PrimitiveUnsigned>() -> Generator<(T, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_unsigned_to_sci_options_pair_gen,\n        &random_primitive_int_to_sci_options_pair_gen,\n        &special_random_unsigned_to_sci_options_pair_gen,\n    )\n}\n\ntype TSO = ToSciOptions;\n// All `(T, ToSciOptions)` pairs where `T` is unsigned and the `T` can be formatted using the\n// options.\npub fn unsigned_to_sci_options_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, TSO)> {\n    Generator::new(\n        &exhaustive_unsigned_to_sci_options_pair_gen_var_1,\n        &random_primitive_int_to_sci_options_pair_gen_var_1,\n        &special_random_unsigned_to_sci_options_pair_gen_var_1,\n    )\n}\n\n// -- (PrimitiveUnsigned, Vec<bool>) --\n\n// All `(T, Vec<bool>)` where `T` is unsigned and the `Vec` has as many elements as the `T` has\n// significant bits.\npub fn unsigned_bool_vec_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(T, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_unsigned_bool_vec_pair_gen_var_1,\n        &random_unsigned_bool_vec_pair_gen_var_1,\n        &special_random_unsigned_bool_vec_pair_gen_var_1,\n    )\n}\n\n// -- RationalSequence<PrimitiveUnsigned> --\n\npub fn unsigned_rational_sequence_gen<T: PrimitiveUnsigned>() -> Generator<RationalSequence<T>> {\n    Generator::new(\n        &exhaustive_unsigned_rational_sequence_gen,\n        &random_primitive_int_rational_sequence_gen,\n        &special_random_unsigned_rational_sequence_gen,\n    )\n}\n\n// -- (RationalSequence<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// All `(RationalSequence<T>, U)` pairs where `T` and `U` are unsigned and the `U` is small.\npub fn unsigned_rational_sequence_unsigned_pair_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(RationalSequence<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_rational_sequence_unsigned_pair_gen_var_1,\n        &random_primitive_int_rational_sequence_unsigned_pair_gen_var_1,\n        &special_random_unsigned_rational_sequence_unsigned_pair_gen_var_1,\n    )\n}\n\n// All `(RationalSequence<T>, usize)` pairs where `T` is unsigned and the `usize` is less than the\n// length of the `RationalSequence`.\npub fn unsigned_rational_sequence_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(RationalSequence<T>, usize)> {\n    Generator::new(\n        &exhaustive_unsigned_rational_sequence_unsigned_pair_gen_var_2,\n        &random_primitive_int_rational_sequence_unsigned_pair_gen_var_2,\n        &special_random_unsigned_rational_sequence_unsigned_pair_gen_var_2,\n    )\n}\n\n// -- (RationalSequence<PrimitiveUnsigned>, RationalSequence<PrimitiveUnsigned>) --\n\npub fn unsigned_rational_sequence_pair_gen<T: PrimitiveUnsigned>()\n-> Generator<(RationalSequence<T>, RationalSequence<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_rational_sequence_pair_gen,\n        &random_primitive_int_rational_sequence_pair_gen,\n        &special_random_unsigned_rational_sequence_pair_gen,\n    )\n}\n\n// -- RationalSequence<PrimitiveUnsigned> * 3 --\n\npub fn unsigned_rational_sequence_triple_gen<T: PrimitiveUnsigned>() -> Generator<(\n    RationalSequence<T>,\n    RationalSequence<T>,\n    RationalSequence<T>,\n)> {\n    Generator::new(\n        &exhaustive_unsigned_rational_sequence_triple_gen,\n        &random_primitive_int_rational_sequence_triple_gen,\n        &special_random_unsigned_rational_sequence_triple_gen,\n    )\n}\n\n// -- RoundingMode --\n\npub fn rounding_mode_gen() -> Generator<RoundingMode> {\n    Generator::new_no_special(&exhaustive_rounding_mode_gen, &random_rounding_mode_gen)\n}\n\n// -- (RoundingMode, RoundingMode) --\n\npub fn rounding_mode_pair_gen() -> Generator<(RoundingMode, RoundingMode)> {\n    Generator::new_no_special(\n        &exhaustive_rounding_mode_pair_gen,\n        &random_rounding_mode_pair_gen,\n    )\n}\n\n// -- (RoundingMode, RoundingMode, RoundingMode) --\n\npub fn rounding_mode_triple_gen() -> Generator<(RoundingMode, RoundingMode, RoundingMode)> {\n    Generator::new_no_special(\n        &exhaustive_rounding_mode_triple_gen,\n        &random_rounding_mode_triple_gen,\n    )\n}\n\n// -- SciSizeOptions --\n\npub fn sci_size_options_gen() -> Generator<SciSizeOptions> {\n    Generator::new_no_special(\n        &exhaustive_sci_size_options_gen,\n        &random_sci_size_options_gen,\n    )\n}\n\n// -- String --\n\npub fn string_gen() -> Generator<String> {\n    Generator::new(\n        &exhaustive_string_gen,\n        &random_string_gen,\n        &special_random_string_gen,\n    )\n}\n\n// All ASCII `String`s.\npub fn string_gen_var_1() -> Generator<String> {\n    Generator::new(\n        &exhaustive_string_gen_var_1,\n        &random_string_gen_var_1,\n        &special_random_string_gen_var_1,\n    )\n}\n\n// All `String`s containing only characters that appear in the `String` representations of\n// `RoundingMode`s.\npub fn string_gen_var_2() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_2, &random_string_gen_var_2)\n}\n\n// All nonempty `String`s containing only the characters '0' through '9'.\npub fn string_gen_var_3() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_3, &random_string_gen_var_3)\n}\n\n// All nonempty `String`s containing only the characters '0' through '9', except for a possible '-'\n// in the first position.\npub fn string_gen_var_4() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_4, &random_string_gen_var_4)\n}\n\n// All nonempty `String`s containing only the characters '0' and '1'.\npub fn string_gen_var_5() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_5, &random_string_gen_var_5)\n}\n\n// All nonempty `String`s containing only the characters '0' through '7'.\npub fn string_gen_var_6() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_6, &random_string_gen_var_6)\n}\n\n// All nonempty `String`s containing only the characters '0' through '9', 'a' through 'f', or 'A'\n// through 'F'.\npub fn string_gen_var_7() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_7, &random_string_gen_var_7)\n}\n\n// All `String`s of the form `\"\\\"0xD\\\"\"`, where D is a nonempty substring containing only the\n// characters '0' through '9', 'a' through 'f', or 'A' through 'F'.\npub fn string_gen_var_8() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_8, &random_string_gen_var_8)\n}\n\n// All `String`s of the form `\"\\\"0xD\\\"\"` or `\"\\\"-0xD\\\"\"`, where D is a nonempty substring containing\n// only the characters '0' through '9', 'a' through 'f', or 'A' through 'F'.\npub fn string_gen_var_9() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_9, &random_string_gen_var_9)\n}\n\n// All `String`s containing only characters that appear in the `String` representations of\n// `NiceFloat`s.\npub fn string_gen_var_10() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_10, &random_string_gen_var_10)\n}\n\n// vars 11 through 12 are in malachite-q.\n\n// All `String`s containing only the characters `+-.0123456789Ee`.\npub fn string_gen_var_13() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_13, &random_string_gen_var_13)\n}\n\nfn large_exponent(s: &str) -> bool {\n    let mut i = 0;\n    let mut expect_e = false;\n    for c in s.chars().rev() {\n        if expect_e {\n            return c == 'e' || c == 'E';\n        } else if c.is_ascii_digit() {\n            i += 1;\n        } else if i <= 3 {\n            return false;\n        } else if c == 'e' || c == 'E' {\n            return true;\n        } else if c == '+' || c == '-' {\n            expect_e = true;\n        }\n    }\n    false\n}\n\n// All `Strings` that do not end in an 'e' or 'E' followed by an optional plus or minus sign and\n// more than three digits.\npub fn string_gen_var_14() -> Generator<String> {\n    Generator::new(\n        &exhaustive_string_gen_var_14,\n        &random_string_gen_var_14,\n        &special_random_string_gen_var_4,\n    )\n}\n\n// All `String`s containing only the characters `+-.0123456789Ee`, and that do not end in an 'e' or\n// 'E' followed by an optional plus or minus sign and more than three digits.\npub fn string_gen_var_15() -> Generator<String> {\n    Generator::new_no_special(&exhaustive_string_gen_var_15, &random_string_gen_var_15)\n}\n\n// -- (String, FromSciStringOptions) --\n\npub fn string_from_sci_string_options_pair_gen() -> Generator<(String, FromSciStringOptions)> {\n    Generator::new(\n        &exhaustive_string_from_sci_string_options_pair_gen,\n        &random_string_from_sci_string_options_pair_gen,\n        &special_random_string_from_sci_string_options_pair_gen,\n    )\n}\n\n// All `(String, FromSciStringOptions)`, where the `String` only contains characters that occur in\n// valid inputs to `T::from_sci_string_options`, using the specified options.\npub fn string_from_sci_string_options_pair_gen_var_1() -> Generator<(String, FromSciStringOptions)>\n{\n    Generator::new_no_special(\n        &exhaustive_string_from_sci_string_options_pair_gen_var_1,\n        &random_string_from_sci_string_options_pair_gen_var_1,\n    )\n}\n\n// All `(String, FromSciStringOptions)`, where the string does not end in an 'e' or 'E' followed by\n// an optional plus or minus sign and more than three digits.\npub fn string_from_sci_string_options_pair_gen_var_2() -> Generator<(String, FromSciStringOptions)>\n{\n    Generator::new(\n        &exhaustive_string_from_sci_string_options_pair_gen_var_2,\n        &random_string_from_sci_string_options_pair_gen_var_2,\n        &special_random_string_from_sci_string_options_pair_gen_var_1,\n    )\n}\n\n// All `(String, FromSciStringOptions)`, where the `String` only contains characters that occur in\n// valid inputs to `T::from_sci_string_options`, using the specified options, and the string does\n// not end in an 'e' or 'E' followed by an optional plus or minus sign and more than three digits.\npub fn string_from_sci_string_options_pair_gen_var_3() -> Generator<(String, FromSciStringOptions)>\n{\n    Generator::new_no_special(\n        &exhaustive_string_from_sci_string_options_pair_gen_var_3,\n        &random_string_from_sci_string_options_pair_gen_var_3,\n    )\n}\n\n// -- (String, PrimitiveUnsigned) --\n\n// All `(String, u8)`s where the `u8` is between 2 and 36, inclusive, and the string does not end in\n// an 'e' or 'E' followed by an optional plus or minus sign and more than three digits.\npub fn string_unsigned_pair_gen_var_1() -> Generator<(String, u8)> {\n    Generator::new(\n        &exhaustive_string_unsigned_pair_gen_var_1,\n        &random_string_unsigned_pair_gen_var_1,\n        &special_random_string_unsigned_pair_gen_var_1,\n    )\n}\n\n// All `(String, u8)`s where the `u8` is between 2 and 36, inclusive, the `String` only contains\n// characters that occur in valid inputs to `T::from_sci_string_options` with the specified base,\n// and the string does not end in an 'e' or 'E' followed by an optional plus or minus sign and more\n// than three digits.\npub fn string_unsigned_pair_gen_var_2() -> Generator<(String, u8)> {\n    Generator::new_no_special(\n        &exhaustive_string_unsigned_pair_gen_var_2,\n        &random_string_unsigned_pair_gen_var_2,\n    )\n}\n\n// -- (String, String) --\n\npub fn string_pair_gen() -> Generator<(String, String)> {\n    Generator::new(\n        &exhaustive_string_pair_gen,\n        &random_string_pair_gen,\n        &special_random_string_pair_gen,\n    )\n}\n\n// All pairs of ASCII `String`s.\npub fn string_pair_gen_var_1() -> Generator<(String, String)> {\n    Generator::new(\n        &exhaustive_string_pair_gen_var_1,\n        &random_string_pair_gen_var_1,\n        &special_random_string_pair_gen_var_1,\n    )\n}\n\n// -- ToSciOptions --\n\npub fn to_sci_options_gen() -> Generator<ToSciOptions> {\n    Generator::new_no_special(&exhaustive_to_sci_options_gen, &random_to_sci_options_gen)\n}\n\n// -- (ToSciOptions, bool) --\n\npub fn to_sci_options_bool_pair_gen() -> Generator<(ToSciOptions, bool)> {\n    Generator::new_no_special(\n        &exhaustive_to_sci_options_bool_pair_gen,\n        &random_to_sci_options_bool_pair_gen,\n    )\n}\n\n// -- (ToSciOptions, PrimitiveSigned) --\n\n// All `(ToSciOptions, T)` where `T` is signed and the `T` is small and negative.\npub fn to_sci_options_signed_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(ToSciOptions, T)> {\n    Generator::new_no_special(\n        &exhaustive_to_sci_options_signed_pair_gen_var_1,\n        &random_to_sci_options_signed_pair_gen_var_1,\n    )\n}\n\n// -- (ToSciOptions, PrimitiveUnsigned) --\n\n// All `(ToSciOptions, T)` where `T` is unsigned and the `T` is between 2 and 36, inclusive.\npub fn to_sci_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(TSO, T)> {\n    Generator::new(\n        &exhaustive_to_sci_options_unsigned_pair_gen_var_1,\n        &random_to_sci_options_unsigned_pair_gen_var_1,\n        &special_random_to_sci_options_unsigned_pair_gen_var_1,\n    )\n}\n\n// All `(ToSciOptions, T)` where `T` is unsigned and the `T` is small.\npub fn to_sci_options_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(TSO, T)> {\n    Generator::new_no_special(\n        &exhaustive_to_sci_options_unsigned_pair_gen_var_2,\n        &random_to_sci_options_unsigned_pair_gen_var_2,\n    )\n}\n\n// All `(ToSciOptions, T)` where `T` is unsigned and the `T` is small and positive.\npub fn to_sci_options_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(TSO, T)> {\n    Generator::new_no_special(\n        &exhaustive_to_sci_options_primitive_int_pair_gen_var_1,\n        &random_to_sci_options_unsigned_pair_gen_var_3,\n    )\n}\n\n// -- (ToSciOptions, RoundingMode) --\n\npub fn to_sci_options_rounding_mode_pair_gen() -> Generator<(ToSciOptions, RoundingMode)> {\n    Generator::new_no_special(\n        &exhaustive_to_sci_options_rounding_mode_pair_gen,\n        &random_to_sci_options_rounding_mode_pair_gen,\n    )\n}\n\n// -- Vec<bool> --\n\npub fn bool_vec_gen() -> Generator<Vec<bool>> {\n    Generator::new(\n        &exhaustive_bool_vec_gen,\n        &random_bool_vec_gen,\n        &special_random_bool_vec_gen,\n    )\n}\n\n// All `Vec<bool>`s that could be the bits, in ascending order, of an unsigned value of type `T`.\n// The `Vec`s may be arbitrarily long.\npub fn bool_vec_gen_var_1<T: PrimitiveUnsigned>() -> Generator<Vec<bool>> {\n    Generator::new(\n        &exhaustive_bool_vec_gen_var_1::<T>,\n        &random_bool_vec_gen_var_1::<T>,\n        &special_random_bool_vec_gen_var_1::<T>,\n    )\n}\n\n// All `Vec<bool>`s that could be the bits, in ascending order, of a signed value of type `T`. The\n// `Vec`s may be arbitrarily long.\npub fn bool_vec_gen_var_2<T: PrimitiveSigned>() -> Generator<Vec<bool>> {\n    Generator::new(\n        &exhaustive_bool_vec_gen_var_2::<T>,\n        &random_bool_vec_gen_var_2::<T>,\n        &special_random_bool_vec_gen_var_2::<T>,\n    )\n}\n\n// All `Vec<bool>`s that could be the bits, in descending order, of an unsigned value of type `T`.\n// The `Vec`s may be arbitrarily long.\npub fn bool_vec_gen_var_3<T: PrimitiveUnsigned>() -> Generator<Vec<bool>> {\n    Generator::new(\n        &exhaustive_bool_vec_gen_var_3::<T>,\n        &random_bool_vec_gen_var_3::<T>,\n        &special_random_bool_vec_gen_var_3::<T>,\n    )\n}\n\n// All `Vec<bool>`s that could be the bits, in descending order, of a signed value of type `T`. The\n// `Vec`s may be arbitrarily long.\npub fn bool_vec_gen_var_4<T: PrimitiveSigned>() -> Generator<Vec<bool>> {\n    Generator::new(\n        &exhaustive_bool_vec_gen_var_4::<T>,\n        &random_bool_vec_gen_var_4::<T>,\n        &special_random_bool_vec_gen_var_4::<T>,\n    )\n}\n\n// All `Vec<bool>`s that contain at least one `true`.\npub fn bool_vec_gen_var_5() -> Generator<Vec<bool>> {\n    Generator::new(\n        &exhaustive_bool_vec_gen_var_5,\n        &random_bool_vec_gen_var_5,\n        &special_random_bool_vec_gen_var_5,\n    )\n}\n\n// -- Vec<PrimitiveUnsigned> --\n\npub fn unsigned_vec_gen<T: PrimitiveUnsigned>() -> Generator<Vec<T>> {\n    Generator::new(\n        &exhaustive_unsigned_vec_gen,\n        &random_primitive_int_vec_gen,\n        &special_random_unsigned_vec_gen,\n    )\n}\n\n// All nonempty `Vec`s of unsigneds whose last element is not zero.\npub fn unsigned_vec_gen_var_1<T: PrimitiveUnsigned>() -> Generator<Vec<T>> {\n    Generator::new(\n        &exhaustive_unsigned_vec_gen_var_1,\n        &random_primitive_int_vec_gen_var_1,\n        &special_random_unsigned_vec_gen_var_1,\n    )\n}\n\n// All `Vec`s of unsigneds that contain at least one nonzero value.\npub fn unsigned_vec_gen_var_2<T: PrimitiveUnsigned>() -> Generator<Vec<T>> {\n    Generator::new(\n        &exhaustive_unsigned_vec_gen_var_2,\n        &random_primitive_int_vec_gen_var_2,\n        &special_random_unsigned_vec_gen_var_2,\n    )\n}\n\n// All nonempty `Vec`s of unsigneds that do not end in a nonzero value.\npub fn unsigned_vec_gen_var_3<T: PrimitiveUnsigned>() -> Generator<Vec<T>> {\n    Generator::new(\n        &exhaustive_unsigned_vec_gen_var_3,\n        &random_primitive_int_vec_gen_var_3,\n        &special_random_unsigned_vec_gen_var_3,\n    )\n}\n\n// All nonempty `Vec`s of unsigneds.\npub fn unsigned_vec_gen_var_4<T: PrimitiveUnsigned>() -> Generator<Vec<T>> {\n    Generator::new(\n        &exhaustive_unsigned_vec_gen_var_4,\n        &random_primitive_int_vec_gen_var_4,\n        &special_random_unsigned_vec_gen_var_4,\n    )\n}\n\n// var 5 is in malachite-nz.\n\n// All `Vec`s of unsigneds with lengths at least 2.\npub fn unsigned_vec_gen_var_6<T: PrimitiveUnsigned>() -> Generator<Vec<T>> {\n    Generator::new(\n        &exhaustive_unsigned_vec_gen_var_6,\n        &random_primitive_int_vec_gen_var_5,\n        &special_random_unsigned_vec_gen_var_6,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn unsigned_vec_unsigned_pair_gen<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen,\n        &random_primitive_int_vec_primitive_int_pair_gen,\n        &special_random_unsigned_vec_unsigned_pair_gen,\n    )\n}\n\n// All `(Vec<T>, usize)` where `T` is unsigned and the `usize` is less than or equal to the length\n// of the `Vec`.\npub fn unsigned_vec_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, usize)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_1,\n        &random_primitive_int_vec_unsigned_pair_gen_var_1,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_3,\n    )\n}\n\n// All `(Vec<U>, u64)` such that the flipped `(u64, Vec<U>)` is a `Some`-returning input to\n// `from_power_of_2_digits_asc<T, U>`, where the `Vec` is no longer than the number of digits of\n// `T::MAX` in the base 2 to the power of the `u64`.\npub fn unsigned_vec_unsigned_pair_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<U>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_2::<T, U>,\n        &random_unsigned_vec_unsigned_pair_gen_var_1::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_1::<T, U>,\n    )\n}\n\n// All `(Vec<U>, u64)` such that the flipped `(u64, Vec<U>)` is a `Some`-returning input to\n// `from_power_of_2_digits_desc<T, U>`, where the `Vec` is no longer than the number of digits of\n// `T::MAX` in the base 2 to the power of the `u64`.\npub fn unsigned_vec_unsigned_pair_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<U>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_3::<T, U>,\n        &random_unsigned_vec_unsigned_pair_gen_var_2::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_2::<T, U>,\n    )\n}\n\n// var 4 is in malachite-nz\n\n// All `(Vec<T>, U)` that are valid, `Some`-returning inputs to _from_digits_desc_basecase in\n// malachite-nz.\npub fn unsigned_vec_unsigned_pair_gen_var_5<\n    T: ExactFrom<U> + PrimitiveUnsigned + WrappingFrom<U>,\n    U: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>,\n>() -> Generator<(Vec<T>, U)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_5::<T, U>,\n        &random_unsigned_vec_unsigned_pair_gen_var_3::<T, U>,\n    )\n}\n\n// All `(Vec<T>, u64)` such that the flipped `(u64, Vec<T>)` is a `Some`-returning input to\n// `from_power_of_2_digits_asc<T, U>` or `from_power_of_2_digits_desc<T, U>`, regardless of whether\n// the returned value is `Some` or `None`.\npub fn unsigned_vec_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_6::<T>,\n        &random_primitive_int_vec_unsigned_pair_gen_var_2::<T>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_5::<T>,\n    )\n}\n\n// All `(T, Vec<T>)` that are a valid input to `U::from_digits_desc`, where the `Vec` is no longer\n// than the number of digits of `U::MAX` in the base of the `T`.\npub fn unsigned_vec_unsigned_pair_gen_var_7<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, T)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_7::<T, U>,\n        &random_unsigned_vec_unsigned_pair_gen_var_4::<T, U>,\n    )\n}\n\n// All `(Vec<T>, T)` that are is a valid input to `U::from_digits_asc`, where the `Vec` is no longer\n// than the number of digits of `U::MAX` in the base of the `T`.\npub fn unsigned_vec_unsigned_pair_gen_var_8<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, T)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_8::<T, U>,\n        &random_unsigned_vec_unsigned_pair_gen_var_5::<T, U>,\n    )\n}\n\n// All `(Vec<T>, T)` such that the flipped `(u64, Vec<T>)` is a `Some`-returning input to\n// `from_digits_asc<T, U>` or `from_digits_desc<T, U>`, regardless of whether the returned value is\n// `Some` or `None`.\npub fn unsigned_vec_unsigned_pair_gen_var_9<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_9::<T>,\n        &random_unsigned_vec_unsigned_pair_gen_var_6::<T>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_6::<T>,\n    )\n}\n\n// All `(Vec<T>, u64)`, where the `u64` is between 1 and `T::WIDTH`, inclusive, and each `T` in the\n// `Vec` is less than 2 to the power of the `u64`.\npub fn unsigned_vec_unsigned_pair_gen_var_10<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_10,\n        &random_unsigned_vec_unsigned_pair_gen_var_7,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_7,\n    )\n}\n\n// All `(Vec<T>, u64)`, where the `u64` is between 1 and `T::WIDTH`, inclusive.\npub fn unsigned_vec_unsigned_pair_gen_var_11<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_11,\n        &random_primitive_int_vec_unsigned_pair_gen_var_3,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_8,\n    )\n}\n\n// All `(Vec<T>, U)` that are valid, inputs to from_digits_desc_basecase in malachite-nz, regardless\n// of whether they return `Some` or `None`.\npub fn unsigned_vec_unsigned_pair_gen_var_12<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() -> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_12::<T, U>,\n        &random_primitive_int_vec_unsigned_pair_gen_var_4::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_9::<T, U>,\n    )\n}\n\n// All `(Vec<T>, U)` where the last element of the `Vec` is nonzero.\npub fn unsigned_vec_unsigned_pair_gen_var_13<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_1::<T, U>,\n        &random_primitive_int_vec_unsigned_pair_gen_var_5::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_10::<T, U>,\n    )\n}\n\n// All `(Vec<T>, U)` where the last element of the `Vec` is nonzero and `U` is small and greater\n// than 2.\npub fn unsigned_vec_unsigned_pair_gen_var_14<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_2::<T, U>,\n        &random_primitive_int_vec_unsigned_pair_gen_var_6::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_11::<T, U>,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned and the `Vec` is nonempty.\npub fn unsigned_vec_unsigned_pair_gen_var_15<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_13,\n        &random_primitive_int_vec_primitive_int_pair_gen_var_1,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_11,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned and the `U` is small.\npub fn unsigned_vec_unsigned_pair_gen_var_16<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_14,\n        &random_primitive_int_vec_unsigned_pair_gen_var_7,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_13,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned and the U is less than `T::WIDTH` times the\n// length of the `Vec`.\npub fn unsigned_vec_unsigned_pair_gen_var_17<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_15,\n        &random_primitive_int_vec_unsigned_pair_gen_var_8,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_14,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned and the `Vec` contains at least one nonzero\n// value.\npub fn unsigned_vec_unsigned_pair_gen_var_18<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_16,\n        &random_primitive_int_vec_primitive_int_pair_gen_var_2,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_15,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` contains at least one nonzero value,\n// and the `U` is positive.\npub fn unsigned_vec_unsigned_pair_gen_var_19<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_3,\n        &random_primitive_int_vec_unsigned_pair_gen_var_9,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_16,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` contains at least one nonzero value,\n// and the `U` is small.\npub fn unsigned_vec_unsigned_pair_gen_var_20<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_17,\n        &random_primitive_int_vec_unsigned_pair_gen_var_10,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_17,\n    )\n}\n\n// var 21 is in malachite-nz.\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` has at least 2 elements, and the `U`\n// is positive.\npub fn unsigned_vec_unsigned_pair_gen_var_22<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_4,\n        &random_primitive_int_vec_unsigned_pair_gen_var_11,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_19,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` has at least 2 elements and at least\n// one nonzero element, and the `U` is positive.\npub fn unsigned_vec_unsigned_pair_gen_var_23<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_5,\n        &random_primitive_int_vec_unsigned_pair_gen_var_12,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_20,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` has at least 2 elements, and the\n// highest bit of the `U` is set.\npub fn unsigned_vec_unsigned_pair_gen_var_24<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_6,\n        &random_primitive_int_vec_unsigned_pair_gen_var_13,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_21,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` has at least 2 elements, the `U` is\n// positive, and the highest bit of the `U` is not set.\npub fn unsigned_vec_unsigned_pair_gen_var_25<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_7,\n        &random_primitive_int_vec_unsigned_pair_gen_var_14,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_22,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` is nonempty, and the highest bit of\n// the `U` is set.\npub fn unsigned_vec_unsigned_pair_gen_var_26<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_8,\n        &random_primitive_int_vec_unsigned_pair_gen_var_15,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_23,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` is nonempty, the `U` is positive, and\n// the highest bit of the `U` is not set.\npub fn unsigned_vec_unsigned_pair_gen_var_27<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_9,\n        &random_primitive_int_vec_unsigned_pair_gen_var_16,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_24,\n    )\n}\n\n// All `(Vec<T>, U)` where `T` and `U` are unsigned, the `Vec` is nonempty, the `U` is positive, and\n// the two highest bits of the `U` are not set.\npub fn unsigned_vec_unsigned_pair_gen_var_28<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_10,\n        &random_primitive_int_vec_unsigned_pair_gen_var_17,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_25,\n    )\n}\n\n// vars 29 through 30 are in malachite-nz.\n\n// All `(Vec<T>, U)` where the last element of the `Vec` is nonzero and `U` is small and greater\n// than 1.\npub fn unsigned_vec_unsigned_pair_gen_var_31<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_primitive_int_pair_gen_var_11::<T, U>,\n        &random_primitive_int_vec_unsigned_pair_gen_var_18::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_28::<T, U>,\n    )\n}\n\n// All `(Vec<T>, u64)`, where `T` is unsigned, `U` is a primitive integer type, and the `u64` is\n// between 1 and `U::WIDTH` - 1, inclusive.\npub fn unsigned_vec_unsigned_pair_gen_var_32<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> Generator<(Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_21::<T, U>,\n        &random_primitive_int_vec_unsigned_pair_gen_var_19::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_29::<T, U>,\n    )\n}\n\n// All `(Vec<T>, u64)`, where `T` is unsigned, `U` is a primitive integer type, the `Vec` is\n// nonempty, and the `u64` is between 1 and `U::WIDTH` - 1, inclusive.\npub fn unsigned_vec_unsigned_pair_gen_var_33<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> Generator<(Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_22::<T, U>,\n        &random_primitive_int_vec_unsigned_pair_gen_var_20::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_30::<T, U>,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\ntype T1<T> = Generator<(Vec<T>, T, T)>;\n\npub fn unsigned_vec_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> T1<T> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen,\n        &random_primitive_int_vec_primitive_int_primitive_int_triple_gen,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen,\n    )\n}\n\n// All `(Vec<T>, U, V)` where `T`, `U`, and `V` are unsigned and the `U` is small.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, U, V)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_1,\n        &random_primitive_int_vec_unsigned_primitive_int_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(Vec<T>, usize, usize)` where `T` is unsigned and the length of the `Vec` is at least the\n// product of the `usize`s.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, usize, usize)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_2,\n        &random_primitive_int_vec_unsigned_unsigned_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_2,\n    )\n}\n\n// All `(Vec<T>, U, U)` where `T` and `U` are unsigned, both `U`s are small, and the first `U` is\n// less than or equal to the second.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, U, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_3,\n        &random_primitive_int_vec_unsigned_unsigned_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_3,\n    )\n}\n\n// All `(Vec<T>, U, U)` where `T` and `U` are unsigned, both `U`s are small, the `Vec` contains at\n// least one nonzero value, and the first `U` is less than or equal to the second.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, U, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_4,\n        &random_primitive_int_vec_unsigned_unsigned_triple_gen_var_3,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_4,\n    )\n}\n\n// All `(Vec<T>, T, T)` where `T` is unsigned, both `T`s are positive, the `Vec` contains at least\n// two elements, and its last element is nonzero.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>() -> T1<T> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_5,\n        &random_primitive_int_vec_unsigned_unsigned_triple_gen_var_4,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_5,\n    )\n}\n\n// var 6 is in malachite-nz.\n\n// All `(Vec<T>, T, T)` where `T` is unsigned, the second `T` is positive, the `Vec` contains at\n// least two elements, and its last element is nonzero.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_7<T: PrimitiveUnsigned>() -> T1<T> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_7,\n        &random_primitive_int_vec_unsigned_unsigned_triple_gen_var_5,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_7,\n    )\n}\n\n// All `(Vec<T>, T, U)` where `T` and `U` are unsigned, the `U` is small, the `Vec` contains at\n// least two elements, and its last element is nonzero.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_8<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_8,\n        &random_primitive_int_vec_unsigned_unsigned_triple_gen_var_6,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_8,\n    )\n}\n\n// var 9 is in malachite-nz.\n\n// All `(Vec<T>, T, T)`s where `T` is unsigned, the `Vec` is nonempty, and the first `T` is odd.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_10<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, T, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_10,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_3,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_10,\n    )\n}\n\n// vars 11 through 12 are in malachite-nz.\n\n// All `(Vec<T>, T, U)` where `T` and `U` are unsigned, the `U` is small, and the `Vec` ends with a\n// nonzero element.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_13<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, T, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_13,\n        &random_primitive_int_vec_unsigned_unsigned_triple_gen_var_7,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_13,\n    )\n}\n\n// var 14 is in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Vec<T>, T, RoundingMode)` where `T` is unsigned, the `Vec` has at least two elements, and\n// the `Vec`s last element is nonzero.\npub fn unsigned_vec_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_rounding_mode_triple_gen_var_1,\n        &random_primitive_int_vec_primitive_int_rounding_mode_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Vec<T>, U, RoundingMode)` where `T` and `U` are unsigned, the `U` is small, and the `Vec`\n// does not only contain zeros.\npub fn unsigned_vec_unsigned_rounding_mode_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, U, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_rounding_mode_triple_gen_var_2,\n        &random_primitive_int_vec_primitive_int_rounding_mode_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\npub fn unsigned_vec_pair_gen<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen,\n        &random_primitive_int_vec_pair_gen,\n        &special_random_unsigned_vec_pair_gen,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned, both `Vec`s are nonempty, and the first `Vec` is at\n// least as long as the second.\npub fn unsigned_vec_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_2,\n        &random_primitive_int_vec_pair_gen_var_2,\n        &special_random_unsigned_vec_pair_gen_var_2,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and both `Vec`s are nonempty.\npub fn unsigned_vec_pair_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_3,\n        &random_primitive_int_vec_pair_gen_var_3,\n        &special_random_unsigned_vec_pair_gen_var_3,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` that are valid inputs to `limbs_pow_low` in malachite-nz.\npub fn unsigned_vec_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_4,\n        &random_primitive_int_vec_pair_gen_var_4,\n        &special_random_unsigned_vec_pair_gen_var_4,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` that are valid `(out, xs)` inputs to `limbs_sqrt_rem_helper`.\npub fn unsigned_vec_pair_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_5::<T>,\n        &random_unsigned_vec_pair_gen_var_1::<T>,\n        &special_random_unsigned_vec_pair_gen_var_5::<T>,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` that are valid `(out, xs)` inputs to `limbs_sqrt_to_out`.\npub fn unsigned_vec_pair_gen_var_5<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_6::<T>,\n        &random_unsigned_vec_pair_gen_var_2::<T>,\n        &special_random_unsigned_vec_pair_gen_var_6::<T>,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and both `Vec`s have the same length.\npub fn unsigned_vec_pair_gen_var_6<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_7,\n        &random_primitive_int_vec_pair_gen_var_5,\n        &special_random_unsigned_vec_pair_gen_var_7,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and neither `Vec` ends with zero.\npub fn unsigned_vec_pair_gen_var_7<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_8,\n        &random_primitive_int_vec_pair_gen_var_6,\n        &special_random_unsigned_vec_pair_gen_var_8,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and each `Vec` contains at least one nonzero value.\npub fn unsigned_vec_pair_gen_var_8<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_9,\n        &random_primitive_int_vec_pair_gen_var_7,\n        &special_random_unsigned_vec_pair_gen_var_9,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned, each `Vec` contains at least one nonzero value, and\n// the first `Vec` is at least as long as the second.\npub fn unsigned_vec_pair_gen_var_9<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_10,\n        &random_primitive_int_vec_pair_gen_var_8,\n        &special_random_unsigned_vec_pair_gen_var_10,\n    )\n}\n\n// var 10 is in malachite-nz.\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned, both `Vec`s have at least 2 elements, the first\n// `Vec` is at least as long as the second, and the last element of the second `Vec` is nonzero.\npub fn unsigned_vec_pair_gen_var_11<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_12,\n        &random_primitive_int_vec_pair_gen_var_10,\n        &special_random_unsigned_vec_pair_gen_var_12,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned, both `Vec`s are nonempty, the first `Vec` is at\n// least as long as the second, and the first element of the second `Vec` is odd.\npub fn unsigned_vec_pair_gen_var_12<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_13,\n        &random_primitive_int_vec_pair_gen_var_11,\n        &special_random_unsigned_vec_pair_gen_var_13,\n    )\n}\n\n// vars 13 through 14 are in malachite-nz.\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned, both `Vec`s are nonempty, the last elements of both\n// `Vec`s are nonzero, and the first `Vec` is at least as long as the second.\npub fn unsigned_vec_pair_gen_var_15<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_16,\n        &random_primitive_int_vec_pair_gen_var_12,\n        &special_random_unsigned_vec_pair_gen_var_16,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` that are valid inputs to `limbs_div_mod` and `limbs_divisible_by`.\npub fn unsigned_vec_pair_gen_var_16<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_17,\n        &random_primitive_int_vec_pair_gen_var_13,\n        &special_random_unsigned_vec_pair_gen_var_17,\n    )\n}\n\n// var 17 is in malachite-nz.\n\n// All `(Vec<T>, Vec<T>)` that are valid inputs to `limbs_mod_by_two_limb_normalized`.\npub fn unsigned_vec_pair_gen_var_18<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_19,\n        &random_unsigned_vec_pair_gen_var_5,\n        &special_random_unsigned_vec_pair_gen_var_19,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and both `Vec`s end with a nonzero number.\npub fn unsigned_vec_pair_gen_var_19<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_20,\n        &random_primitive_int_vec_pair_gen_var_14,\n        &special_random_unsigned_vec_pair_gen_var_20,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned, both `Vec`s have at least 2 elements, and the first\n// `Vec` is at least as long as the second.\npub fn unsigned_vec_pair_gen_var_20<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_21,\n        &random_primitive_int_vec_pair_gen_var_15,\n        &special_random_unsigned_vec_pair_gen_var_21,\n    )\n}\n\n// vars 21 through 30 are malachite-nz.\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and the first `Vec` is at least as long as the\n// second.\npub fn unsigned_vec_pair_gen_var_31<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_32,\n        &random_primitive_int_vec_pair_gen_var_26,\n        &special_random_unsigned_vec_pair_gen_var_32,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned, both `Vec`s have the same length, at least one ends\n// with a nonzero value, and the first element of the second `Vec` is odd.\npub fn unsigned_vec_pair_gen_var_32<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_33,\n        &random_primitive_int_vec_pair_gen_var_27,\n        &special_random_unsigned_vec_pair_gen_var_33,\n    )\n}\n\n// var 33 is in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, bool) --\n\n// All `(Vec<T>, Vec<T>, bool)` where `T` is unsigned and both `Vec`s have the same length.\npub fn unsigned_vec_unsigned_vec_bool_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, bool)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_bool_triple_gen_var_1,\n        &random_primitive_int_vec_primitive_int_vec_bool_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_vec_bool_triple_gen_var_1,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// All `(Vec<T>, Vec<T>, T)` where `T` is unsigned and the first `Vec` is at least as long as the\n// second.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n    )\n}\n\n// vars 2 and 3 are in malachite-nz\n\n// All `(Vec<T>, Vec<T>, T)` where `T` is unsigned, the first `Vec` is at least as long as the\n// second, and the second is nonempty.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, T)` where `T` is unsigned, the first `Vec` is at least as long as the\n// second, and the second contains at least one nonzero value.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_3,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, U)` where `T` and `U` are unsigned, the `U` is positive, both `Vec`s\n// contain at least two elements, and their last elements are nonzero.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_4,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6,\n    )\n}\n\n// vars 7 through 8 are in malachite-nz.\n\n// All `(Vec<T>, Vec<T>, U)` where `T` and `U` are unsigned, the `U` is small, and the last elements\n// of both `Vec`s are nonzero.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_5,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, U)` where `T` and `U` are unsigned, the `U` is positive, and the last\n// elements of both `Vec`s are nonzero.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, Vec<T>, U)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_6,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, usize)` where `T` is unsigned, the first `Vec` is at least as long as the\n// second, and the `usize` is no greater than the length of the second `Vec`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, usize)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11,\n        &random_primitive_int_vec_primitive_int_vec_unsigned_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, T)` where `T` is unsigned and the two `Vec`s have the same length.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_7,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, T)` where `T` is unsigned and positive, the first `Vec` is at least as long\n// as the second, and the second has at least two elements.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13,\n        &random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13,\n    )\n}\n\n// vars 14 through 21 are in malachite-nz.\n\n// All `(Vec<T>, Vec<T>, u64)` where `T` is unsigned, `U` is a primitive integer type, the first\n// `Vec` is at least as long as the second, and the `u64` is between 1 and `U::WIDTH - 1`,\n// inclusive.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> Generator<(Vec<T>, Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22::<T, U>,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_8::<T, U>,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22::<T, U>,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, u64)` where `T` is unsigned, `U` is a primitive integer type, the first\n// `Vec` is at least as long as the second, neither `Vec` is empty, and the `u64` is between 1 and\n// `U::WIDTH - 1`, inclusive.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> Generator<(Vec<T>, Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<T, U>,\n        &random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_9::<T, U>,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<T, U>,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, usize)` where `T` is unsigned, the `Vec`s have the same length, and the\n// `usize` is no greater than the length of either `Vec`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, Vec<T>, usize)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24,\n        &random_primitive_int_vec_primitive_int_vec_unsigned_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, no `Vec` is empty, the second and third\n// `Vec`s have equal length, and the first is at least twice as long as the second.\npub fn unsigned_vec_triple_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_1,\n        &random_primitive_int_vec_triple_gen_var_1,\n        &special_random_unsigned_vec_triple_gen_var_1,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, no `Vec` is empty, the second is at least\n// as long as the third, and the length of the first is at least the sum of the lengths of the\n// second and the third.\npub fn unsigned_vec_triple_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_2,\n        &random_primitive_int_vec_triple_gen_var_2,\n        &special_random_unsigned_vec_triple_gen_var_2,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, no `Vec` is empty, and the length of the\n// first is at least the sum of the lengths of the second and the third.\npub fn unsigned_vec_triple_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_3,\n        &random_primitive_int_vec_triple_gen_var_3,\n        &special_random_unsigned_vec_triple_gen_var_3,\n    )\n}\n\n// vars 4 through 23 are in malachite-nz\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, no `Vec` is empty, the second and third\n// `Vec`s have equal length, and the first is at least as long as the second.\npub fn unsigned_vec_triple_gen_var_24<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_24,\n        &random_primitive_int_vec_triple_gen_var_24,\n        &special_random_unsigned_vec_triple_gen_var_24,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, all `Vec`s have length at least 2, the\n// second and third `Vec`s have equal length, and the first is at least twice as long as the second.\npub fn unsigned_vec_triple_gen_var_25<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_25,\n        &random_primitive_int_vec_triple_gen_var_25,\n        &special_random_unsigned_vec_triple_gen_var_25,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, all `Vec`s have length at least 2, the\n// second and third `Vec`s have equal length, and the first is at least as long as the second.\npub fn unsigned_vec_triple_gen_var_26<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_26,\n        &random_primitive_int_vec_triple_gen_var_26,\n        &special_random_unsigned_vec_triple_gen_var_26,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned and all three `Vec`s have the same length,\n// which is at least 2.\npub fn unsigned_vec_triple_gen_var_27<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_27,\n        &random_primitive_int_vec_triple_gen_var_27,\n        &special_random_unsigned_vec_triple_gen_var_27,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid `(out, rs, xs)` inputs to `limbs_sqrt_rem_to_out`.\npub fn unsigned_vec_triple_gen_var_28<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_28::<T>,\n        &random_unsigned_vec_triple_gen_var_9::<T>,\n        &special_random_unsigned_vec_triple_gen_var_28::<T>,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned and all three `Vec`s have the same length.\npub fn unsigned_vec_triple_gen_var_29<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_29,\n        &random_primitive_int_vec_triple_gen_var_28,\n        &special_random_unsigned_vec_triple_gen_var_29,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned and no `Vec` ends with zero.\npub fn unsigned_vec_triple_gen_var_30<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_30,\n        &random_primitive_int_vec_triple_gen_var_29,\n        &special_random_unsigned_vec_triple_gen_var_30,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, the second and third `Vec`s have equal\n// length, and the first is at least as long as the second.\npub fn unsigned_vec_triple_gen_var_31<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_31,\n        &random_primitive_int_vec_triple_gen_var_30,\n        &special_random_unsigned_vec_triple_gen_var_31,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned and the first `Vec` is at least as long as\n// the second and at least as long as the third.\npub fn unsigned_vec_triple_gen_var_32<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_32,\n        &random_primitive_int_vec_triple_gen_var_31,\n        &special_random_unsigned_vec_triple_gen_var_32,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, the second and third `Vec`s each contain at\n// least one nonzero element, and the first `Vec` is at least as long as the second.\npub fn unsigned_vec_triple_gen_var_33<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_33,\n        &random_primitive_int_vec_triple_gen_var_32,\n        &special_random_unsigned_vec_triple_gen_var_33,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, the second and third `Vec`s each contain at\n// least one nonzero element, and the first `Vec` is at least as long as the second AND at least as\n// long as the third.\npub fn unsigned_vec_triple_gen_var_34<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_34,\n        &random_primitive_int_vec_triple_gen_var_33,\n        &special_random_unsigned_vec_triple_gen_var_34,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, the second and third `Vec`s each contain at\n// least one nonzero element, and the first `Vec` is at least as long as the second OR at least as\n// long as the third.\npub fn unsigned_vec_triple_gen_var_35<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_35,\n        &random_primitive_int_vec_triple_gen_var_34,\n        &special_random_unsigned_vec_triple_gen_var_35,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, each `Vec` contains at least two elements,\n// and the last element of each `Vec` is nonzero.\npub fn unsigned_vec_triple_gen_var_36<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_36,\n        &random_primitive_int_vec_triple_gen_var_35,\n        &special_random_unsigned_vec_triple_gen_var_36,\n    )\n}\n\n// vars 37 through 38 are in malachite-nz\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned and each `Vec` ends with a nonzero element.\npub fn unsigned_vec_triple_gen_var_39<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_39,\n        &random_primitive_int_vec_triple_gen_var_38,\n        &special_random_unsigned_vec_triple_gen_var_39,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned and the first `Vec` is at least as long as\n// the second and the second is at least as long as the third.\npub fn unsigned_vec_triple_gen_var_40<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_40,\n        &random_primitive_int_vec_triple_gen_var_39,\n        &special_random_unsigned_vec_triple_gen_var_40,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, every `Vec` ends with a nonzero element,\n// and the last `Vec` has length at least 2.\npub fn unsigned_vec_triple_gen_var_41<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_41,\n        &random_primitive_int_vec_triple_gen_var_40,\n        &special_random_unsigned_vec_triple_gen_var_41,\n    )\n}\n\n// vars 42 through 49 are in malachite-nz.\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where the first `Vec` is at least as long as the second, the third\n// is at least as long as twice the length of the second, and the second is nonempty and its most\n// significant bit is set.\npub fn unsigned_vec_triple_gen_var_50<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_50,\n        &random_primitive_int_vec_triple_gen_var_41,\n        &special_random_unsigned_vec_triple_gen_var_50,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where the first `Vec` is at least as long as the second, the third\n// is at least as long as twice the length of the second, and the second has length at least 5 and\n// its most significant bit is set.\npub fn unsigned_vec_triple_gen_var_51<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_51,\n        &random_primitive_int_vec_triple_gen_var_42,\n        &special_random_unsigned_vec_triple_gen_var_51,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that meet certain preconditions that enable comparing the\n// performance of divide-and-conquer division and Barrett division.\npub fn unsigned_vec_triple_gen_var_52<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_52,\n        &random_primitive_int_vec_triple_gen_var_43,\n        &special_random_unsigned_vec_triple_gen_var_52,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_div_mod_by_two_limb_normalized`.\npub fn unsigned_vec_triple_gen_var_53<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_53,\n        &random_unsigned_vec_triple_gen_var_10,\n        &special_random_unsigned_vec_triple_gen_var_53,\n    )\n}\n\n// vars 54 through 56 are in malachite-base.\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` where `T` is unsigned, the first `Vec` is at least as long as the\n// second and at least as long as the third, all `Vec`s have at least 2 elements, and the last\n// element of the third is nonzero.\npub fn unsigned_vec_triple_gen_var_57<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_57,\n        &random_primitive_int_vec_triple_gen_var_44,\n        &special_random_unsigned_vec_triple_gen_var_57,\n    )\n}\n\n// var 58 is in malachite-nz.\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` `(xs, ys, zs)` where `T` is unsigned, `ys` and `zs` have at least\n// two elements, `xs` has at least `ys.len() + zs.len() - 1` elements, and each slice ends with a\n// nonzero value.\npub fn unsigned_vec_triple_gen_var_59<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_59,\n        &random_primitive_int_vec_triple_gen_var_46,\n        &special_random_unsigned_vec_triple_gen_var_59,\n    )\n}\n\n// var 60 is in malachite-nz.\n\n// -- large types --\n\n// TODO description\npub fn large_type_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, T, T)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_1,\n        &random_large_type_gen_var_1,\n        &special_random_large_type_gen_var_1,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, u64, bool)` that are valid inputs to `limbs_sqrt_helper`.\npub fn large_type_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, u64, bool)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_2,\n        &random_large_type_gen_var_2,\n        &special_random_large_type_gen_var_2,\n    )\n}\n\n// All `(Vec<T>, U, U, Vec<T>)` where `T` and `U` are unsigned and the first `U` is less than the\n// second.\npub fn large_type_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U, U, Vec<T>)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_3,\n        &random_large_type_gen_var_3,\n        &special_random_large_type_gen_var_3,\n    )\n}\n\n// All `(Vec<T>, U, U, Vec<T>)` where `T` and `U` are unsigned, the first `U` is less than the\n// second, and the first `Vec` contains at least one nonzero value.\npub fn large_type_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, U, U, Vec<T>)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_4,\n        &random_large_type_gen_var_4,\n        &special_random_large_type_gen_var_4,\n    )\n}\n\n// vars 5 through 8 are in malachite-nz\n\n// All `(Vec<T>, Vec<T>, Vec<T>, bool)` where `T` is unsigned, the second and third `Vec`s have\n// equal length, and the first is at least as long as the second.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_9<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>, bool)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_9,\n        &random_large_type_gen_var_9,\n        &special_random_large_type_gen_var_9,\n    )\n}\n\n// vars 10 through 21 are in malachite-nz.\n\ntype T2<T> = Generator<(RationalSequence<T>, usize, T, T)>;\n\n// All `(RationalSequence<T>, usize, T, T)` quadruples where `T` is unsigned and the `usize` is less\n// than the length of the `RationalSequence`.\npub fn large_type_gen_var_22<T: PrimitiveUnsigned>() -> T2<T> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_22,\n        &random_large_type_gen_var_22,\n        &special_random_large_type_gen_var_22,\n    )\n}\n\n// vars 23 through 26 are in malachite-nz.\n\n// All (bool, Vec<T>, bool, Vec<T>) where `T` is unsigned and neither `Vec` ends with a zero.\npub fn large_type_gen_var_27<T: PrimitiveUnsigned>() -> Generator<(bool, Vec<T>, bool, Vec<T>)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_27,\n        &random_large_type_gen_var_27,\n        &special_random_large_type_gen_var_25,\n    )\n}\n\n// var 23 is in malachite-nz.\n\npub mod common;\npub mod exhaustive;\npub mod random;\npub mod special_random;\n"
  },
  {
    "path": "malachite-base/src/test_util/generators/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::{RandomBools, random_bools};\nuse crate::chars::constants::NUMBER_OF_CHARS;\nuse crate::chars::random::{\n    random_ascii_chars, random_char_inclusive_range, random_char_range, random_chars,\n};\nuse crate::iterators::with_special_value;\nuse crate::num::arithmetic::traits::CoprimeWith;\nuse crate::num::arithmetic::traits::{\n    ArithmeticCheckedShl, DivRound, Parity, PowerOf2, ShrRound, UnsignedAbs,\n};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::string::options::random::{\n    RandomFromSciStringOptions, random_from_sci_string_options, random_sci_size_options,\n    random_to_sci_options,\n};\nuse crate::num::conversion::string::options::{FromSciStringOptions, SciSizeOptions, ToSciOptions};\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, HasHalf, JoinHalves, RoundingFrom, SaturatingFrom,\n    SplitInHalf, WrappingFrom, WrappingInto,\n};\nuse crate::num::factorization::traits::IsPrime;\nuse crate::num::float::NiceFloat;\nuse crate::num::logic::traits::{BitBlockAccess, LeadingZeros};\nuse crate::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomSignedRange, GeometricRandomSigneds,\n    geometric_random_natural_signeds, geometric_random_negative_signeds,\n    geometric_random_nonzero_signeds, geometric_random_positive_unsigneds,\n    geometric_random_signed_inclusive_range, geometric_random_signed_range,\n    geometric_random_signeds, geometric_random_unsigned_inclusive_range,\n    geometric_random_unsigned_range, geometric_random_unsigneds,\n};\nuse crate::num::random::{\n    RandomPrimitiveInts, RandomUnsignedBitChunks, RandomUnsignedInclusiveRange,\n    RandomUnsignedRange, SpecialRandomNonzeroFiniteFloats, VariableRangeGenerator,\n    random_highest_bit_set_unsigneds, random_natural_signeds, random_negative_signeds,\n    random_nonzero_signeds, random_positive_signeds, random_positive_unsigneds,\n    random_primitive_ints, random_signed_inclusive_range, random_signed_range,\n    random_unsigned_bit_chunks, random_unsigned_inclusive_range, random_unsigned_range,\n    random_unsigneds_less_than, special_random_finite_primitive_floats,\n    special_random_nonzero_finite_primitive_floats,\n    special_random_positive_finite_primitive_floats,\n    special_random_primitive_float_inclusive_range, special_random_primitive_float_range,\n    special_random_primitive_floats,\n};\nuse crate::random::{EXAMPLE_SEED, Seed};\nuse crate::rational_sequences::RationalSequence;\nuse crate::rational_sequences::random::random_rational_sequences;\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse crate::rounding_modes::random::{RandomRoundingModes, random_rounding_modes};\nuse crate::slices::slice_test_zero;\nuse crate::strings::random::{random_strings, random_strings_using_chars};\nuse crate::strings::strings_from_char_vecs;\nuse crate::test_util::extra_variadic::{\n    Union3, random_duodecuples_from_single, random_octuples_from_single,\n    random_quadruples_from_single, random_quadruples_xxxy, random_quadruples_xxyx,\n    random_quadruples_xyxy, random_quadruples_xyyx, random_quadruples_xyyz, random_quadruples_xyzz,\n    random_sextuples_from_single, random_triples, random_triples_from_single, random_triples_xxy,\n    random_triples_xyx, random_triples_xyy, random_union3s,\n};\nuse crate::test_util::generators::common::{\n    GenConfig, It, reshape_1_2_to_3, reshape_2_1_to_3, reshape_2_2_to_4, reshape_3_1_to_4,\n};\nuse crate::test_util::generators::exhaustive::{\n    float_rounding_mode_filter_var_1, valid_digit_chars,\n};\nuse crate::test_util::generators::{\n    digits_valid, large_exponent, round_to_multiple_of_power_of_2_filter_map,\n    round_to_multiple_signed_filter_map, round_to_multiple_unsigned_filter_map,\n    signed_assign_bits_valid, smallest_invalid_value, unsigned_assign_bits_valid,\n};\nuse crate::test_util::num::arithmetic::mod_mul::limbs_invert_limb_naive;\nuse crate::test_util::num::conversion::string::from_sci_string::DECIMAL_SCI_STRING_CHARS;\nuse crate::test_util::num::float::PRIMITIVE_FLOAT_CHARS;\nuse crate::test_util::rounding_modes::ROUNDING_MODE_CHARS;\nuse crate::tuples::random::{random_ordered_unique_pairs, random_pairs, random_pairs_from_single};\nuse crate::unions::Union2;\nuse crate::unions::random::random_union2s;\nuse crate::vecs::random::{\n    random_vecs, random_vecs_fixed_length_from_single, random_vecs_length_inclusive_range,\n    random_vecs_min_length,\n};\nuse crate::vecs::random_values_from_vec;\nuse itertools::Itertools;\nuse itertools::repeat_n;\nuse std::cmp::{Ordering::*, max, min};\nuse std::collections::HashMap;\nuse std::marker::PhantomData;\nuse std::mem::swap;\n\n// -- bool --\n\npub fn random_bool_gen(_config: &GenConfig) -> It<bool> {\n    Box::new(random_bools(EXAMPLE_SEED))\n}\n\n// -- char --\n\npub fn random_char_gen(_config: &GenConfig) -> It<char> {\n    Box::new(random_chars(EXAMPLE_SEED))\n}\n\n#[allow(unstable_name_collisions)]\npub fn random_char_gen_var_1(_config: &GenConfig) -> It<char> {\n    Box::new(random_char_range(EXAMPLE_SEED, char::MIN, char::MAX))\n}\n\n#[allow(unstable_name_collisions)]\npub fn random_char_gen_var_2(_config: &GenConfig) -> It<char> {\n    Box::new(random_char_inclusive_range(\n        EXAMPLE_SEED,\n        '\\u{1}',\n        char::MAX,\n    ))\n}\n\n// -- (char, char) --\n\npub fn random_char_pair_gen(_config: &GenConfig) -> It<(char, char)> {\n    Box::new(random_pairs_from_single(random_chars(EXAMPLE_SEED)))\n}\n\n// -- FromSciStringOptions --\n\npub fn random_from_sci_string_options_gen(_config: &GenConfig) -> It<FromSciStringOptions> {\n    Box::new(random_from_sci_string_options(EXAMPLE_SEED))\n}\n\n// -- (FromSciStringOptions, PrimitiveUnsigned) --\n\npub fn random_from_sci_string_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(FromSciStringOptions, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_from_sci_string_options,\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::from(36u8)),\n    ))\n}\n\n// -- (FromSciStringOptions, RoundingMode) --\n\npub fn random_from_sci_string_options_rounding_mode_pair_gen(\n    _config: &GenConfig,\n) -> It<(FromSciStringOptions, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_from_sci_string_options,\n        &random_rounding_modes,\n    ))\n}\n\n// -- PrimitiveFloat --\n\npub fn random_primitive_float_gen<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(special_random_primitive_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n        config.get_or(\"special_p_mean_n\", 1),\n        config.get_or(\"special_p_mean_d\", 64),\n    ))\n}\n\npub fn random_primitive_float_gen_var_1<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(special_random_primitive_float_range(\n        EXAMPLE_SEED,\n        T::NEGATIVE_ONE / T::TWO,\n        T::INFINITY,\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n        config.get_or(\"special_p_mean_n\", 1),\n        config.get_or(\"special_p_mean_d\", 64),\n    ))\n}\n\nstruct RandomPositiveNaturalFloats<T: PrimitiveFloat> {\n    exponents: GeometricRandomSignedRange<i64>,\n    ranges: VariableRangeGenerator,\n    phantom: PhantomData<T>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for RandomPositiveNaturalFloats<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        let exponent = self.exponents.next().unwrap();\n        let a = if exponent == 0 {\n            1\n        } else {\n            u64::power_of_2(T::MANTISSA_WIDTH)\n        };\n        let mantissa = self\n            .ranges\n            .next_in_range(a, u64::power_of_2(T::MANTISSA_WIDTH + 1));\n        Some(T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap())\n    }\n}\n\nfn random_positive_natural_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n) -> RandomPositiveNaturalFloats<T> {\n    RandomPositiveNaturalFloats {\n        exponents: geometric_random_signed_range(\n            seed.fork(\"exponents\"),\n            0,\n            i64::power_of_2(T::EXPONENT_WIDTH - 1) - i64::wrapping_from(T::MANTISSA_WIDTH) - 1,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n        ),\n        ranges: VariableRangeGenerator::new(seed.fork(\"mantissas\")),\n        phantom: PhantomData,\n    }\n}\n\npub fn random_primitive_float_gen_var_2<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(with_special_value(EXAMPLE_SEED, T::ZERO, 1, 100, &|seed| {\n        random_positive_natural_floats(\n            seed,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n        )\n    }))\n}\n\npub fn random_primitive_float_gen_var_3<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        special_random_positive_finite_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n        )\n        .filter(|f| !f.is_integer()),\n    )\n}\n\npub fn random_primitive_float_gen_var_4<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        special_random_primitive_float_inclusive_range::<T>(\n            EXAMPLE_SEED,\n            T::ONE,\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            1,\n            100,\n        )\n        .map(|f| f.floor() - T::ONE / T::TWO),\n    )\n}\n\npub fn random_primitive_float_gen_var_5<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                with_special_value(seed, T::ZERO, 1, 100, &|seed_2| {\n                    random_positive_natural_floats(\n                        seed_2,\n                        config.get_or(\"exponent_mean_n\", 8),\n                        config.get_or(\"exponent_mean_d\", 1),\n                    )\n                })\n            },\n            &random_bools,\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn random_primitive_float_gen_var_6<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_positive_finite_primitive_floats::<T>(\n                    seed,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                )\n                .filter(|f| !f.is_integer())\n            },\n            &random_bools,\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn random_primitive_float_gen_var_7<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_primitive_float_inclusive_range::<T>(\n                    seed,\n                    T::ONE,\n                    T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                        .unwrap(),\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                    1,\n                    100,\n                )\n                .map(|f| f.floor() - T::ONE / T::TWO)\n            },\n            &random_bools,\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn random_primitive_float_gen_var_8<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(special_random_finite_primitive_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n        config.get_or(\"special_p_mean_n\", 1),\n        config.get_or(\"special_p_mean_d\", 64),\n    ))\n}\n\npub fn random_primitive_float_gen_var_9<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        special_random_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            config.get_or(\"special_p_mean_n\", 1),\n            config.get_or(\"special_p_mean_d\", 64),\n        )\n        .filter(|&f| !f.is_nan() && f != T::INFINITY),\n    )\n}\n\npub fn random_primitive_float_gen_var_10<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        special_random_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            config.get_or(\"special_p_mean_n\", 1),\n            config.get_or(\"special_p_mean_d\", 64),\n        )\n        .filter(|&f| !f.is_nan() && f != T::NEGATIVE_INFINITY),\n    )\n}\n\npub fn random_primitive_float_gen_var_11<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        special_random_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            config.get_or(\"special_p_mean_n\", 1),\n            config.get_or(\"special_p_mean_d\", 64),\n        )\n        .filter(|&f| !f.is_nan()),\n    )\n}\n\npub fn random_primitive_float_gen_var_12<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(special_random_nonzero_finite_primitive_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n    ))\n}\n\npub fn random_primitive_float_gen_var_13<T: PrimitiveFloat + RoundingFrom<U>, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<T> {\n    Box::new(random_primitive_ints::<U>(EXAMPLE_SEED).map(|n| T::rounding_from(n, Down).0))\n}\n\npub fn random_primitive_float_gen_var_14<\n    T: PrimitiveFloat,\n    U: ConvertibleFrom<T> + PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        special_random_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            config.get_or(\"special_p_mean_n\", 1),\n            config.get_or(\"special_p_mean_d\", 64),\n        )\n        .filter(|&f| !U::convertible_from(f)),\n    )\n}\n\npub fn random_primitive_float_gen_var_15<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    let limit = min(\n        NiceFloat(T::rounding_from(U::MAX, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    Box::new(\n        special_random_primitive_float_inclusive_range::<T>(\n            EXAMPLE_SEED,\n            T::ONE,\n            limit,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            1,\n            100,\n        )\n        .map(|f| f.floor() - T::ONE / T::TWO),\n    )\n}\n\npub fn random_primitive_float_gen_var_16<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    let min_limit = min(\n        NiceFloat(-T::rounding_from(U::MIN, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    let max_limit = min(\n        NiceFloat(T::rounding_from(U::MAX, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_primitive_float_inclusive_range::<T>(\n                    seed,\n                    T::ONE,\n                    max_limit,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                    1,\n                    100,\n                )\n                .map(|f| f.floor() - T::ONE / T::TWO)\n            },\n            &|seed| {\n                special_random_primitive_float_inclusive_range::<T>(\n                    seed,\n                    T::ONE,\n                    min_limit,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                    1,\n                    100,\n                )\n                .map(|f| T::ONE / T::TWO - f.floor())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_primitive_float_gen_var_17<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(special_random_positive_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n    ))\n}\n\npub fn random_primitive_float_gen_var_18<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::power_of_2(T::MAX_EXPONENT),\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n        1,\n        100,\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat) --\n\npub fn random_primitive_float_pair_gen<T: PrimitiveFloat>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(special_random_primitive_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n        config.get_or(\"special_p_mean_n\", 1),\n        config.get_or(\"special_p_mean_d\", 64),\n    )))\n}\n\npub fn random_primitive_float_pair_gen_var_1<T: PrimitiveFloat>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(\n        special_random_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            config.get_or(\"special_p_mean_n\", 1),\n            config.get_or(\"special_p_mean_d\", 64),\n        )\n        .filter(|&f| !f.is_nan()),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat, PrimitiveFloat) --\n\npub fn random_primitive_float_triple_gen<T: PrimitiveFloat>(config: &GenConfig) -> It<(T, T, T)> {\n    Box::new(random_triples_from_single(special_random_primitive_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"exponent_mean_n\", 8),\n        config.get_or(\"exponent_mean_d\", 1),\n        config.get_or(\"precision_mean_n\", 8),\n        config.get_or(\"precision_mean_d\", 1),\n        config.get_or(\"special_p_mean_n\", 1),\n        config.get_or(\"special_p_mean_d\", 64),\n    )))\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned) --\n\npub fn random_primitive_float_signed_pair_gen<T: PrimitiveFloat, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_float_signed_pair_gen_var_1<T: PrimitiveFloat, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_positive_finite_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_float_signed_pair_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, i64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_primitive_float_range(\n                    seed,\n                    T::ONE,\n                    T::TWO,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                    config.get_or(\"special_p_mean_n\", 1),\n                    config.get_or(\"special_p_mean_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signed_inclusive_range(\n                    seed,\n                    T::MIN_EXPONENT,\n                    T::MAX_EXPONENT,\n                    config.get_or(\"mean_small_signed_n\", 32),\n                    config.get_or(\"mean_small_signed_d\", 1),\n                )\n            },\n        )\n        .filter(|&(m, e)| m.precision() <= T::max_precision_for_sci_exponent(e)),\n    )\n}\n\npub fn random_primitive_float_signed_pair_gen_var_3<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, i64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_float_range(\n                seed,\n                T::ONE,\n                T::TWO,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_float_signed_pair_gen_var_4<T: PrimitiveFloat, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn random_primitive_float_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 32),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned) --\n\npub fn random_primitive_float_unsigned_pair_gen_var_1<T: PrimitiveFloat, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_positive_finite_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 32),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_float_unsigned_pair_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_float_range(\n                seed,\n                T::ONE,\n                T::TWO,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 32),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_float_unsigned_pair_gen_var_3<T: PrimitiveFloat, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_positive_finite_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 32),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_float_unsigned_pair_gen_var_4<T: PrimitiveFloat, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 32),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_primitive_float_unsigned_rounding_mode_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_positive_finite_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_primitive_float_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_float_range(\n                seed,\n                T::ONE,\n                T::TWO,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// var 3 is in malachite-float.\n\n// -- (PrimitiveFloat, RoundingMode) --\n\npub fn random_primitive_float_rounding_mode_pair_gen_var_1<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_finite_primitive_floats(\n                    seed,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                    config.get_or(\"special_p_mean_n\", 1),\n                    config.get_or(\"special_p_mean_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(float_rounding_mode_filter_var_1),\n    )\n}\n\npub fn random_primitive_float_rounding_mode_pair_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_finite_primitive_floats::<T>(\n                    seed,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                    config.get_or(\"special_p_mean_n\", 1),\n                    config.get_or(\"special_p_mean_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(f, rm)| rm != Exact || f.is_integer()),\n    )\n}\n\npub fn random_primitive_float_rounding_mode_pair_gen_var_3<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: ConvertibleFrom<T> + PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    let f_min = T::rounding_from(U::MIN, Down).0;\n    let f_max = T::rounding_from(U::MAX, Down).0;\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_primitive_floats::<T>(\n                    seed,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"precision_mean_n\", 8),\n                    config.get_or(\"precision_mean_d\", 1),\n                    config.get_or(\"special_p_mean_n\", 1),\n                    config.get_or(\"special_p_mean_d\", 64),\n                )\n                .filter(|f| !f.is_nan())\n            },\n            &random_rounding_modes,\n        )\n        .filter(move |&(f, rm)| match rm {\n            Up => f >= f_min && f <= f_max,\n            Ceiling => f <= f_max,\n            Floor => f >= f_min,\n            Down | Nearest => true,\n            Exact => U::convertible_from(f),\n        }),\n    )\n}\n\n// -- PrimitiveInt --\n\npub fn random_primitive_int_gen<T: PrimitiveInt>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_ints(EXAMPLE_SEED))\n}\n\npub fn random_primitive_int_gen_var_1<\n    T: PrimitiveInt + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        special_random_primitive_float_range(\n            EXAMPLE_SEED,\n            U::rounding_from(T::MIN, Down).0,\n            U::rounding_from(T::MAX, Down).0,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            config.get_or(\"special_p_mean_n\", 1),\n            config.get_or(\"special_p_mean_d\", 64),\n        )\n        .map(|f| T::rounding_from(f, Down).0),\n    )\n}\n\n// -- (PrimitiveInt, PrimitiveInt) --\n\npub fn random_primitive_int_pair_gen<T: PrimitiveInt, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &random_primitive_ints,\n    ))\n}\n\npub fn random_primitive_int_pair_gen_var_1<T: PrimitiveInt>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(random_primitive_ints(\n        EXAMPLE_SEED,\n    )))\n}\n\n// TODO make better\npub fn random_primitive_int_pair_gen_var_2<T: PrimitiveInt>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .map(|(x, y)| if x <= y { (x, y) } else { (y, x) }),\n    )\n}\n\npub fn random_primitive_int_pair_gen_var_3<T: PrimitiveInt>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_ordered_unique_pairs(random_primitive_ints::<T>(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- (PrimitiveInt, PrimitiveInt, PrimitiveInt) --\n\npub fn random_primitive_int_triple_gen_var_1<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints::<T>(EXAMPLE_SEED))\n            .filter(|&(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\n// Returns (highest, second-highest)\npub fn get_two_highest<T: Ord>(xs: &[T]) -> (&T, &T) {\n    assert!(xs.len() > 1);\n    let (mut hi, mut next_hi) = (&xs[0], &xs[1]);\n    if hi < next_hi {\n        swap(&mut hi, &mut next_hi);\n    }\n    for x in &xs[2..] {\n        if x > next_hi {\n            if x > hi {\n                hi = x;\n                next_hi = hi;\n            } else {\n                next_hi = x;\n            }\n        }\n    }\n    (hi, next_hi)\n}\n\npub fn random_primitive_int_triple_gen_var_2<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints::<T>(EXAMPLE_SEED)).filter_map(\n            |(x, y, z)| {\n                let ranking = [(x, 0), (y, 1), (z, 2)];\n                let (hi, next_hi) = get_two_highest(&ranking);\n                if hi.0 == next_hi.0 {\n                    None\n                } else {\n                    Some(match hi.1 {\n                        0 => (y, z, x),\n                        1 => (x, z, y),\n                        _ => (x, y, z),\n                    })\n                }\n            },\n        ),\n    )\n}\n\npub fn random_primitive_int_triple_gen_var_3<T: PrimitiveInt, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(EXAMPLE_SEED, &random_primitive_ints, &random_primitive_ints)\n            .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n                Equal => None,\n                Less => Some((x, y, z)),\n                Greater => Some((z, y, x)),\n            }),\n    )\n}\n\npub fn random_primitive_int_triple_gen_var_4<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_from_single(random_primitive_ints(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- (PrimitiveInt, PrimitiveInt, PrimitiveInt, PrimitiveInt) --\n\npub fn random_primitive_int_quadruple_gen_var_1<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(\n        random_quadruples_from_single(random_primitive_ints::<T>(EXAMPLE_SEED)).filter_map(\n            |(x, y, z, w)| {\n                let ranking = [(x, 0), (y, 1), (z, 2), (w, 3)];\n                let (hi, next_hi) = get_two_highest(&ranking);\n                if hi.0 == next_hi.0 {\n                    None\n                } else {\n                    Some(match hi.1 {\n                        0 => (y, z, w, x),\n                        1 => (x, z, w, y),\n                        2 => (x, y, w, z),\n                        _ => (x, y, z, w),\n                    })\n                }\n            },\n        ),\n    )\n}\n\npub fn random_primitive_int_quadruple_gen_var_2<T: PrimitiveInt, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, U, T)> {\n    Box::new(\n        random_quadruples_xxyx(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &random_primitive_ints::<U>,\n        )\n        .filter_map(|(x, y, z, w)| {\n            let ranking = [(x, 0), (y, 1), (w, 2)];\n            let (hi, next_hi) = get_two_highest(&ranking);\n            if hi.0 == next_hi.0 {\n                None\n            } else {\n                Some(match hi.1 {\n                    0 => (y, w, z, x),\n                    1 => (x, w, z, y),\n                    _ => (x, y, z, w),\n                })\n            }\n        }),\n    )\n}\n\npub fn random_primitive_int_quadruple_gen_var_3<T: PrimitiveInt, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, U, U, T)> {\n    Box::new(\n        random_quadruples_xyyx(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &random_primitive_ints::<U>,\n        )\n        .filter_map(|(x, y, z, w)| match x.cmp(&w) {\n            Equal => None,\n            Less => Some((x, y, z, w)),\n            Greater => Some((w, y, z, x)),\n        }),\n    )\n}\n\npub fn random_primitive_int_quadruple_gen_var_4<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(random_quadruples_from_single(random_primitive_ints(\n        EXAMPLE_SEED,\n    )))\n}\n\npub fn random_primitive_int_quadruple_gen_var_5<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(\n        random_quadruples_from_single(random_primitive_ints(EXAMPLE_SEED)).filter(\n            |&(n1, n0, d1, d0)| {\n                // conditions: D >= 2^W, N >= D, and N / D < 2^W\n                d1 != T::ZERO && (n1 > d1 || n1 == d1 && n0 >= d0)\n            },\n        ),\n    )\n}\n\n// -- (PrimitiveInt * 6) --\n\npub fn random_primitive_int_sextuple_gen_var_1<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T, T, T)> {\n    Box::new(random_sextuples_from_single(random_primitive_ints(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- (PrimitiveInt * 8) --\n\n#[allow(clippy::type_complexity)]\npub fn random_primitive_int_octuple_gen_var_1<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T, T, T, T, T)> {\n    Box::new(random_octuples_from_single(random_primitive_ints(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- (PrimitiveInt * 9) --\n\n#[allow(clippy::type_complexity)]\npub fn random_primitive_int_nonuple_gen_var_1<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T, T, T, T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_triples_from_single(random_primitive_ints(\n            EXAMPLE_SEED,\n        )))\n        .map(|((a, b, c), (d, e, f), (g, h, i))| (a, b, c, d, e, f, g, h, i)),\n    )\n}\n\n// -- (PrimitiveInt * 12) --\n\n#[allow(clippy::type_complexity)]\npub fn random_primitive_int_duodecuple_gen_var_1<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T, T, T, T, T, T, T, T, T)> {\n    Box::new(random_duodecuples_from_single(random_primitive_ints(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- (PrimitiveInt, PrimitiveInt, PrimitiveUnsigned) --\n\npub fn random_primitive_int_primitive_int_unsigned_triple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, T, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_primitive_int_unsigned_triple_gen_var_2<\n    T: PrimitiveInt,\n    U: PrimitiveInt,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_primitive_int_unsigned_triple_gen_var_3<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, T, u64)> {\n    Box::new(\n        random_triples_xxy(EXAMPLE_SEED, &random_primitive_ints::<T>, &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        })\n        .filter(|&(x, y, pow)| !x.eq_mod_power_of_2(y, pow)),\n    )\n}\n\n// -- (PrimitiveInt, PrimitiveInt, PrimitiveInt, PrimitiveUnsigned) --\n\npub fn random_primitive_int_primitive_int_primitive_int_unsigned_quadruple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, T, T, U)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveInt, PrimitiveSigned) --\n\npub fn random_primitive_int_signed_pair_gen_var_1<T: PrimitiveInt, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveInt, PrimitiveSigned, PrimitiveInt) --\n\npub fn random_primitive_int_signed_primitive_int_triple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveSigned,\n>(\n    _config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(EXAMPLE_SEED, &random_primitive_ints, &|seed| {\n            random_signed_inclusive_range(\n                seed,\n                if U::WIDTH <= u64::WIDTH {\n                    U::MIN\n                } else {\n                    -U::exact_from(u64::MAX)\n                },\n                U::saturating_from(u64::MAX),\n            )\n        })\n        .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\n// -- (PrimitiveInt, PrimitiveSigned, RoundingMode) --\n\npub fn random_primitive_int_signed_rounding_mode_triple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_signeds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, pow, rm)| {\n            rm != Exact || pow <= U::ZERO || x.divisible_by_power_of_2(pow.exact_into())\n        }),\n    )\n}\n\npub fn random_primitive_int_signed_rounding_mode_triple_gen_var_2<\n    T: PrimitiveInt,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_signeds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, pow, rm)| {\n            let pow: i64 = pow.exact_into();\n            rm != Exact || pow >= 0 || x.divisible_by_power_of_2(pow.unsigned_abs())\n        }),\n    )\n}\n\n// -- (PrimitiveInt, PrimitiveUnsigned) --\n\npub fn random_primitive_int_unsigned_pair_gen_var_1<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_2<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigneds_less_than(seed, T::WIDTH),\n    ))\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_3<T: PrimitiveInt, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigned_inclusive_range(seed, 1, U::WIDTH),\n    ))\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_4<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigned_inclusive_range(seed, U::TWO, U::saturating_from(T::MAX)),\n    ))\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_5<\n    T: PrimitiveInt,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigned_inclusive_range(seed, U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_6<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_pairs(EXAMPLE_SEED, &random_primitive_ints::<T>, &|seed| {\n            geometric_random_unsigneds::<U>(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        })\n        .filter(|&(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_7<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_pairs(EXAMPLE_SEED, &random_primitive_ints::<T>, &|seed| {\n            geometric_random_unsigneds::<U>(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        })\n        .map(|(mut x, y)| {\n            x.round_to_multiple_of_power_of_2_assign(y.exact_into(), Down);\n            (x, y)\n        }),\n    )\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_8<T: PrimitiveInt, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigneds_less_than(seed, U::WIDTH + 1),\n    ))\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_9<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_unsigned_pair_gen_var_10<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveInt, PrimitiveUnsigned, bool) --\n\npub fn random_primitive_int_unsigned_bool_triple_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, u64, bool)> {\n    reshape_1_2_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_union2s(\n                seed,\n                &|seed_2| {\n                    geometric_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                    .map(|x| (x, false))\n                },\n                &|seed_2| random_unsigneds_less_than(seed_2, T::WIDTH).map(|x| (x, true)),\n            )\n            .map(Union2::unwrap)\n        },\n    )))\n}\n\npub fn random_primitive_int_unsigned_bool_triple_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, u64, bool)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(seed, &random_primitive_ints, &|seed_2| {\n                    geometric_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                })\n                .map(|(x, y)| (x, y, x < T::ZERO))\n            },\n            &|seed| {\n                random_pairs(seed, &random_primitive_ints, &|seed_2| {\n                    random_unsigneds_less_than(seed_2, T::WIDTH)\n                })\n                .map(|(x, y)| (x, y, x >= T::ZERO))\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_primitive_int_unsigned_bool_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    _config: &GenConfig,\n) -> It<(T, U, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<T>,\n        &random_positive_unsigneds::<U>,\n        &random_bools,\n    ))\n}\n\n// -- (PrimitiveInt, PrimitiveUnsigned, PrimitiveInt) --\n\npub fn random_primitive_int_unsigned_primitive_int_triple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(EXAMPLE_SEED, &random_primitive_ints, &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        })\n        .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\npub fn random_primitive_int_unsigned_primitive_int_triple_gen_var_2<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    _config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(EXAMPLE_SEED, &random_primitive_ints, &|seed| {\n            random_unsigned_inclusive_range(seed, U::ZERO, U::saturating_from(u64::MAX))\n        })\n        .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\npub fn random_primitive_int_unsigned_primitive_int_triple_gen_var_3<\n    T: PrimitiveInt,\n    U: PrimitiveInt,\n>(\n    _config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(EXAMPLE_SEED, &random_primitive_ints, &random_primitive_ints)\n            .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n                Equal => None,\n                Less => Some((x, y, z)),\n                Greater => Some((z, y, x)),\n            }),\n    )\n}\n\n// -- (PrimitiveInt, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_primitive_int_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveInt,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, u64, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigned_inclusive_range(seed, 1, U::WIDTH),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, U)> {\n    Box::new(\n        random_triples_xyy(EXAMPLE_SEED, &random_primitive_ints, &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        })\n        .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) }),\n    )\n}\n\npub fn random_primitive_int_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveInt,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigned_inclusive_range(seed, U::TWO, U::exact_from(36u8)),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 4),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_unsigned_unsigned_triple_gen_var_4<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, U)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// --(PrimitiveInt, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_primitive_int_unsigned_unsigned_unsigned_quadruple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, u64, u64, U)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_primitive_ints,\n        )\n        .filter_map(|(x, y, z, w)| {\n            let (y, z) = if y <= z { (y, z) } else { (z, y) };\n            if unsigned_assign_bits_valid(y, z, w) {\n                Some((x, y, z, w))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n// --(PrimitiveInt, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_primitive_int_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, pow, rm)| round_to_multiple_of_power_of_2_filter_map(x, pow, rm)),\n    )\n}\n\npub fn random_primitive_int_unsigned_rounding_mode_triple_gen_var_2<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, y, rm)| rm != Exact || x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn random_primitive_int_unsigned_rounding_mode_triple_gen_var_4<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    _config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &random_positive_unsigneds,\n        &random_rounding_modes,\n    ))\n}\n\n// --(PrimitiveInt, PrimitiveUnsigned, Vec<bool>) --\n\nstruct PrimitiveIntUnsignedBoolVecTripleGeneratorVar1<T: PrimitiveInt> {\n    xs: RandomPrimitiveInts<T>,\n    log_bases: RandomUnsignedInclusiveRange<u64>,\n    bs: RandomBools,\n}\n\nimpl<T: PrimitiveInt> Iterator for PrimitiveIntUnsignedBoolVecTripleGeneratorVar1<T> {\n    type Item = (T, u64, Vec<bool>);\n\n    fn next(&mut self) -> Option<(T, u64, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let log_base = self.log_bases.next().unwrap();\n        let bs = (&mut self.bs)\n            .take(usize::exact_from(\n                x.significant_bits().div_round(log_base, Ceiling).0,\n            ))\n            .collect();\n        Some((x, log_base, bs))\n    }\n}\n\npub fn random_primitive_int_unsigned_bool_vec_triple_gen_var_1<T: PrimitiveInt, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, u64, Vec<bool>)> {\n    Box::new(PrimitiveIntUnsignedBoolVecTripleGeneratorVar1 {\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        log_bases: random_unsigned_inclusive_range(EXAMPLE_SEED.fork(\"log_bases\"), 1, U::WIDTH),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n// -- (PrimitiveInt, RoundingMode) --\n\npub fn random_primitive_int_rounding_mode_pair_gen<T: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_primitive_int_rounding_mode_pair_gen_var_1<\n    T: PrimitiveInt,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(\n        random_pairs(EXAMPLE_SEED, &random_primitive_ints, &random_rounding_modes)\n            .filter(move |&(n, rm)| rm != Exact || U::convertible_from(n)),\n    )\n}\n\n// -- (PrimitiveInt, ToSciOptions) --\n\npub fn random_primitive_int_to_sci_options_pair_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_to_sci_options_pair_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, ToSciOptions)> {\n    Box::new(\n        random_pairs(EXAMPLE_SEED, &random_primitive_ints::<T>, &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        })\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- PrimitiveSigned --\n\npub fn random_signed_gen_var_1<T: PrimitiveSigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_ints(EXAMPLE_SEED).filter(|&x| x != T::MIN))\n}\n\npub fn random_signed_gen_var_2<T: PrimitiveSigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_natural_signeds(EXAMPLE_SEED))\n}\n\npub fn random_signed_gen_var_3<T: PrimitiveSigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_ints(EXAMPLE_SEED).filter(|&x| x != T::ZERO && x != T::NEGATIVE_ONE))\n}\n\npub fn random_signed_gen_var_4<T: PrimitiveSigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_negative_signeds(EXAMPLE_SEED))\n}\n\npub fn random_signed_gen_var_5<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(geometric_random_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_small_signed_n\", 32),\n        config.get_or(\"mean_small_signed_d\", 1),\n    ))\n}\n\npub fn random_signed_gen_var_6<T: PrimitiveSigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_nonzero_signeds(EXAMPLE_SEED))\n}\n\npub fn random_signed_gen_var_7<T: PrimitiveSigned, U: ConvertibleFrom<T> + PrimitiveFloat>(\n    _config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_signed_inclusive_range(\n                    seed,\n                    T::saturating_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n                    T::MAX,\n                )\n            },\n            &|seed| {\n                random_signed_inclusive_range(\n                    seed,\n                    T::MIN,\n                    T::saturating_from(U::SMALLEST_UNREPRESENTABLE_UINT).saturating_neg(),\n                )\n            },\n        )\n        .map(Union2::unwrap)\n        .filter(|&x| !U::convertible_from(x)),\n    )\n}\n\npub fn random_signed_gen_var_8<\n    T: TryFrom<NiceFloat<U>> + PrimitiveSigned,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    _config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_signed_inclusive_range(\n                    seed,\n                    T::exact_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n                    T::MAX,\n                )\n                .filter_map(|a| {\n                    let f = U::rounding_from(a, Down).0;\n                    let a = T::try_from(NiceFloat(f)).ok()?;\n                    let b = T::try_from(NiceFloat(f.next_higher())).ok()?;\n                    let diff = b - a;\n                    if diff.even() {\n                        // This happens almost always\n                        Some(a + (diff >> 1))\n                    } else {\n                        None\n                    }\n                })\n            },\n            &|seed| {\n                random_signed_inclusive_range(\n                    seed,\n                    T::MIN,\n                    T::exact_from(U::SMALLEST_UNREPRESENTABLE_UINT)\n                        .checked_neg()\n                        .unwrap(),\n                )\n                .filter_map(|a| {\n                    let f = U::rounding_from(a, Down).0;\n                    let a = T::try_from(NiceFloat(f)).ok()?;\n                    let b = T::try_from(NiceFloat(f.next_lower())).ok()?;\n                    let diff = a - b;\n                    if diff.even() {\n                        // This happens almost always\n                        Some(a - (diff >> 1))\n                    } else {\n                        None\n                    }\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_gen_var_9<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    _config: &GenConfig,\n) -> It<S> {\n    let limit = S::wrapping_from(U::wrapping_from(S::MAX).floor_sqrt());\n    Box::new(random_signed_inclusive_range(EXAMPLE_SEED, -limit, limit))\n}\n\npub fn random_signed_gen_var_10<T: PrimitiveFloat>(_config: &GenConfig) -> It<i64> {\n    Box::new(random_signed_inclusive_range(\n        EXAMPLE_SEED,\n        T::MIN_EXPONENT,\n        T::MAX_EXPONENT,\n    ))\n}\n\npub fn random_signed_gen_var_11<T: PrimitiveSigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_ints(EXAMPLE_SEED).filter(|&x| x != T::ZERO && x != T::MIN))\n}\n\npub fn random_signed_gen_var_12<T: PrimitiveSigned>(_config: &GenConfig) -> It<T> {\n    Box::new(\n        random_signed_inclusive_range(EXAMPLE_SEED, T::ZERO, T::low_mask(T::WIDTH - 2))\n            .map(|u| (u << 1) | T::ONE),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned) --\n\npub fn random_signed_pair_gen_var_1<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| random_pairs_from_single(random_natural_signeds(seed)),\n            &|seed| random_pairs_from_single(random_negative_signeds(seed)),\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_pair_gen_var_2<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &random_nonzero_signeds::<T>,\n        )\n        .filter_map(|(mut x, y)| {\n            x.round_to_multiple_assign(y, Down);\n            if x == T::MIN && y == T::NEGATIVE_ONE {\n                None\n            } else {\n                Some((x, y))\n            }\n        }),\n    )\n}\n\npub fn random_signed_pair_gen_var_3<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &random_nonzero_signeds::<T>,\n        )\n        .filter(|&(x, y)| x != T::MIN || y != T::NEGATIVE_ONE),\n    )\n}\n\npub fn random_signed_pair_gen_var_4<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &random_nonzero_signeds::<T>,\n        )\n        .filter(|&(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn random_signed_pair_gen_var_5<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<T>,\n        &random_nonzero_signeds::<T>,\n    ))\n}\n\npub fn random_signed_pair_gen_var_6<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(random_natural_signeds::<T>(\n        EXAMPLE_SEED,\n    )))\n}\n\npub fn random_signed_pair_gen_var_7<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_signed_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 2))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn random_signed_pair_gen_var_8<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T)>\nwhere\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    Box::new(\n        random_pairs_from_single(\n            random_signed_inclusive_range(EXAMPLE_SEED, T::ZERO, T::low_mask(T::WIDTH - 2))\n                .map(|u| (u << 1) | T::ONE),\n        )\n        .filter(|&(a, b): &(T, T)| a.unsigned_abs().coprime_with(b.unsigned_abs())),\n    )\n}\n\npub fn random_signed_pair_gen_var_9<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    _config: &GenConfig,\n) -> It<(S, S)> {\n    Box::new(\n        random_pairs_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .filter(|&(x, y): &(S, S)| x.unsigned_abs().coprime_with(y.unsigned_abs())),\n    )\n}\n\npub fn random_signed_pair_gen_var_10<T: PrimitiveSigned, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_signed_pair_gen_var_11<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(geometric_random_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_small_n\", 32),\n            config.get_or(\"mean_small_d\", 1),\n        ))\n        .filter(|&(n, k)| T::checked_binomial_coefficient(n, k).is_some()),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned) --\n\nfn halve_bits<T: PrimitiveSigned>(x: T) -> T {\n    let half_width = (T::WIDTH >> 1) - 1;\n    let half_mask = T::low_mask(half_width);\n    if x >= T::ZERO {\n        x & half_mask\n    } else {\n        x | (T::NEGATIVE_ONE << half_width)\n    }\n}\n\npub(crate) fn reduce_to_fit_add_mul_signed<T: PrimitiveSigned>(x: T, y: T, z: T) -> (T, T, T) {\n    if x.checked_add_mul(y, z).is_some() {\n        (x, y, z)\n    } else {\n        (halve_bits(x), halve_bits(y), halve_bits(z))\n    }\n}\n\npub fn random_signed_triple_gen_var_1<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .map(|(x, y, z)| reduce_to_fit_add_mul_signed(x, y, z)),\n    )\n}\n\npub(crate) fn reduce_to_fit_sub_mul_signed<T: PrimitiveSigned>(x: T, y: T, z: T) -> (T, T, T) {\n    if x.checked_sub_mul(y, z).is_some() {\n        (x, y, z)\n    } else {\n        (halve_bits(x), halve_bits(y), halve_bits(z))\n    }\n}\n\npub fn random_signed_triple_gen_var_2<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .map(|(x, y, z)| reduce_to_fit_sub_mul_signed(x, y, z)),\n    )\n}\n\npub fn random_signed_triple_gen_var_3<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| random_triples_from_single(random_natural_signeds(seed)),\n            &|seed| random_triples_from_single(random_negative_signeds(seed)),\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_triple_gen_var_4<\n    U: PrimitiveUnsigned + WrappingFrom<S> + WrappingInto<S>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    _config: &GenConfig,\n) -> It<(S, S, S)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints::<S>(EXAMPLE_SEED)).map(|(x, y, m)| {\n            if m == S::ZERO {\n                let min = min(x, y);\n                (min, min, m)\n            } else if x <= y {\n                let adjusted_diff = U::wrapping_from(y.wrapping_sub(x))\n                    .round_to_multiple(m.unsigned_abs(), Down)\n                    .0;\n                (\n                    x,\n                    (U::wrapping_from(x).wrapping_add(adjusted_diff)).wrapping_into(),\n                    m,\n                )\n            } else {\n                let adjusted_diff = U::wrapping_from(x.wrapping_sub(y))\n                    .round_to_multiple(m.unsigned_abs(), Down)\n                    .0;\n                (\n                    (U::wrapping_from(y).wrapping_add(adjusted_diff)).wrapping_into(),\n                    y,\n                    m,\n                )\n            }\n        }),\n    )\n}\n\npub fn random_signed_triple_gen_var_5<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_signed_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 2))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn random_signed_triple_gen_var_6<T: PrimitiveSigned>(_config: &GenConfig) -> It<(T, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_signed_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 2))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn random_signed_signed_unsigned_triple_gen_var_1<\n    U: PrimitiveUnsigned + WrappingFrom<S> + WrappingInto<S>,\n    S: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(S, S, u64)> {\n    Box::new(\n        random_triples_xxy(EXAMPLE_SEED, &random_primitive_ints::<S>, &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_pow_n\", 32),\n                config.get_or(\"mean_pow_d\", 1),\n            )\n        })\n        .map(|(x, y, pow)| {\n            if pow >= S::WIDTH {\n                (x, x, pow)\n            } else if x <= y {\n                let adjusted_diff = U::wrapping_from(y.wrapping_sub(x))\n                    .round_to_multiple_of_power_of_2(pow, Down)\n                    .0;\n                (\n                    x,\n                    (U::wrapping_from(x).wrapping_add(adjusted_diff)).wrapping_into(),\n                    pow,\n                )\n            } else {\n                let adjusted_diff = U::wrapping_from(x.wrapping_sub(y))\n                    .round_to_multiple_of_power_of_2(pow, Down)\n                    .0;\n                (\n                    (U::wrapping_from(y).wrapping_add(adjusted_diff)).wrapping_into(),\n                    y,\n                    pow,\n                )\n            }\n        }),\n    )\n}\n\npub fn random_signed_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, RoundingMode) --\n\nstruct SignedSignedRoundingModeTripleGenerator<T: PrimitiveSigned> {\n    xs: RandomPrimitiveInts<T>,\n    rms: RandomRoundingModes,\n}\n\nimpl<T: PrimitiveSigned> Iterator for SignedSignedRoundingModeTripleGenerator<T> {\n    type Item = (T, T, RoundingMode);\n\n    fn next(&mut self) -> Option<(T, T, RoundingMode)> {\n        let mut x;\n        let mut y;\n        loop {\n            x = self.xs.next().unwrap();\n            loop {\n                y = self.xs.next().unwrap();\n                if y != T::ZERO {\n                    break;\n                }\n            }\n            if x != T::MIN || y != T::NEGATIVE_ONE {\n                break;\n            }\n        }\n        let rm = self.rms.next().unwrap();\n        if rm == Exact {\n            x.round_to_multiple_assign(y, Down);\n        }\n        Some((x, y, rm))\n    }\n}\n\npub fn random_signed_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    _config: &GenConfig,\n) -> It<(T, T, RoundingMode)> {\n    Box::new(SignedSignedRoundingModeTripleGenerator {\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        rms: random_rounding_modes(EXAMPLE_SEED.fork(\"rms\")),\n    })\n}\n\npub fn random_signed_signed_rounding_mode_triple_gen_var_2<\n    U: PrimitiveUnsigned,\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    _config: &GenConfig,\n) -> It<(S, S, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            &random_nonzero_signeds,\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_signed_filter_map(x, y, rm)),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn random_signed_unsigned_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(seed, &random_natural_signeds, &|seed_2| {\n                    random_unsigned_range(seed_2, 0, T::WIDTH)\n                })\n            },\n            &|seed| {\n                random_pairs(seed, &random_negative_signeds, &|seed_2| {\n                    geometric_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_unsigned_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(seed, &random_negative_signeds, &|seed_2| {\n                    random_unsigned_range(seed_2, 0, T::WIDTH)\n                })\n            },\n            &|seed| {\n                random_pairs(seed, &random_natural_signeds, &|seed_2| {\n                    geometric_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_unsigned_pair_gen_var_3<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_natural_signeds,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_signed_unsigned_pair_gen_var_4<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_natural_signeds,\n        &|seed| random_unsigned_inclusive_range(seed, U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn random_signed_unsigned_pair_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(seed, &random_natural_signeds, &|seed_2| {\n                    geometric_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                })\n            },\n            &|seed| {\n                random_pairs(seed, &random_primitive_ints, &|seed_2| {\n                    random_unsigned_inclusive_range(seed_2, 0, T::WIDTH)\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_unsigned_pair_gen_var_6<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| random_signed_range(seed_2, T::MIN + T::ONE, T::ONE),\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_small_n\", 32),\n                            config.get_or(\"mean_small_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(seed, &random_primitive_ints, &|seed_2| {\n                    random_unsigned_range(seed_2, 0, T::WIDTH)\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_unsigned_pair_gen_var_7<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_signed_inclusive_range(\n                seed,\n                if T::WIDTH <= u64::WIDTH {\n                    T::MIN\n                } else {\n                    -T::exact_from(u64::MAX)\n                },\n                T::saturating_from(u64::MAX),\n            )\n        },\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_signed_unsigned_pair_gen_var_8<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_signed_unsigned_pair_gen_var_9<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| x.checked_pow(y).is_some()),\n    )\n}\n\npub fn random_signed_unsigned_pair_gen_var_10<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_signeds,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_signed_unsigned_pair_gen_var_11<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_signed_range(seed, T::MIN + T::ONE, T::ZERO),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_signed_unsigned_pair_gen_var_12<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(seed, &random_natural_signeds, &|seed_2| {\n                    geometric_random_positive_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                })\n            },\n            &|seed| {\n                random_pairs(seed, &random_negative_signeds, &|seed_2| {\n                    geometric_random_unsigneds::<U>(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                    .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | U::ONE))\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_signed_unsigned_pair_gen_var_13<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_signed_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, U)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_triples_xyy(seed, &random_positive_signeds, &|seed_2| {\n                    geometric_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_small_n\", 32),\n                        config.get_or(\"mean_small_d\", 1),\n                    )\n                })\n                .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) })\n            },\n            &|seed| {\n                random_triples(\n                    seed,\n                    &|seed_2| random_signed_range(seed_2, T::MIN, T::ZERO),\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_small_n\", 32),\n                            config.get_or(\"mean_small_d\", 1),\n                        )\n                    },\n                    &|seed_2| random_unsigned_range(seed_2, U::ZERO, U::exact_from(T::WIDTH)),\n                )\n                .filter_map(|(x, y, z): (T, U, U)| y.checked_add(z).map(|new_z| (x, y, new_z)))\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_signed_unsigned_unsigned_unsigned_quadruple_gen_var_1<\n    T: PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, u64, u64, U)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_primitive_ints,\n        )\n        .filter_map(|(x, y, z, w)| {\n            let (y, z) = if y <= z { (y, z) } else { (z, y) };\n            if signed_assign_bits_valid(x, y, z, w) {\n                Some((x, y, z, w))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn random_signed_rounding_mode_pair_gen_var_1<T: PrimitiveSigned>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_nonzero_signeds,\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_signed_rounding_mode_pair_gen_var_2<T: PrimitiveSigned>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_signed_inclusive_range(seed, T::MIN + T::ONE, T::MAX),\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_signed_rounding_mode_pair_gen_var_3<T: PrimitiveSigned>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_nonzero_signeds(seed).filter(|&x| x != T::MIN),\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_signed_rounding_mode_pair_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode)\n\npub fn random_signed_unsigned_rounding_mode_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// --(PrimitiveSigned, Vec<bool>) --\n\nstruct SignedBoolVecPairGeneratorVar1<T: PrimitiveSigned> {\n    xs: RandomPrimitiveInts<T>,\n    bs: RandomBools,\n}\n\nimpl<T: PrimitiveSigned> Iterator for SignedBoolVecPairGeneratorVar1<T> {\n    type Item = (T, Vec<bool>);\n\n    fn next(&mut self) -> Option<(T, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = (&mut self.bs)\n            .take(usize::exact_from(u64::exact_from(x.to_bits_asc().len())))\n            .collect();\n        Some((x, bs))\n    }\n}\n\npub fn random_signed_bool_vec_pair_gen_var_1<T: PrimitiveSigned>(\n    _config: &GenConfig,\n) -> It<(T, Vec<bool>)> {\n    Box::new(SignedBoolVecPairGeneratorVar1 {\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n// -- PrimitiveUnsigned --\n\npub fn random_unsigned_gen_var_1<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_positive_unsigneds(EXAMPLE_SEED))\n}\n\npub fn random_unsigned_gen_var_2(_config: &GenConfig) -> It<u32> {\n    Box::new(random_unsigneds_less_than(EXAMPLE_SEED, NUMBER_OF_CHARS))\n}\n\npub fn random_unsigned_gen_var_3<T: PrimitiveInt>(_config: &GenConfig) -> It<u64> {\n    Box::new(random_unsigned_inclusive_range(EXAMPLE_SEED, 1, T::WIDTH))\n}\n\npub fn random_unsigned_gen_var_4<T: PrimitiveInt, U: PrimitiveUnsigned + SaturatingFrom<T>>(\n    _config: &GenConfig,\n) -> It<U> {\n    Box::new(random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        U::TWO,\n        U::saturating_from(T::MAX),\n    ))\n}\n\npub fn random_unsigned_gen_var_5<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(geometric_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_small_n\", 32),\n        config.get_or(\"mean_small_d\", 1),\n    ))\n}\n\npub fn random_unsigned_gen_var_6<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::MAX,\n    ))\n}\n\npub fn random_unsigned_gen_var_7<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_unsigneds_less_than(EXAMPLE_SEED, T::exact_from(36)))\n}\n\npub fn random_unsigned_gen_var_8<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::exact_from(36),\n    ))\n}\n\npub fn random_unsigned_gen_var_9<T: PrimitiveInt>(_config: &GenConfig) -> It<u64> {\n    Box::new(random_unsigneds_less_than(EXAMPLE_SEED, T::WIDTH + 1))\n}\n\npub fn random_unsigned_gen_var_10(_config: &GenConfig) -> It<u8> {\n    Box::new(\n        random_union3s(\n            EXAMPLE_SEED,\n            &|seed| random_unsigned_inclusive_range(seed, b'0', b'9'),\n            &|seed| random_unsigned_inclusive_range(seed, b'a', b'z'),\n            &|seed| random_unsigned_inclusive_range(seed, b'A', b'Z'),\n        )\n        .map(Union3::unwrap),\n    )\n}\n\npub fn random_unsigned_gen_var_11<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(geometric_random_positive_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_small_n\", 32),\n        config.get_or(\"mean_small_d\", 1),\n    ))\n}\n\npub fn random_unsigned_gen_var_12<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_highest_bit_set_unsigneds(EXAMPLE_SEED))\n}\n\npub fn random_unsigned_gen_var_13<T: PrimitiveFloat>(_config: &GenConfig) -> It<u64> {\n    Box::new(random_unsigneds_less_than(\n        EXAMPLE_SEED,\n        T::LARGEST_ORDERED_REPRESENTATION,\n    ))\n}\n\npub fn random_unsigned_gen_var_14<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_unsigneds_less_than(\n        EXAMPLE_SEED,\n        T::power_of_2(T::WIDTH - 1) + T::ONE,\n    ))\n}\n\npub fn random_unsigned_gen_var_15<T: PrimitiveInt>(_config: &GenConfig) -> It<u64> {\n    Box::new(random_unsigneds_less_than(EXAMPLE_SEED, T::WIDTH))\n}\n\npub fn random_unsigned_gen_var_16<T: PrimitiveInt>(_config: &GenConfig) -> It<u64> {\n    Box::new(random_unsigneds_less_than(EXAMPLE_SEED, T::WIDTH - 1))\n}\n\npub fn random_unsigned_gen_var_17<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::power_of_2(T::WIDTH - 2),\n        T::MAX,\n    ))\n}\n\npub fn random_unsigned_gen_var_18<T: PrimitiveUnsigned, U: ConvertibleFrom<T> + PrimitiveFloat>(\n    _config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        random_unsigned_inclusive_range(\n            EXAMPLE_SEED,\n            T::saturating_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n            T::MAX,\n        )\n        .filter(|&x| !U::convertible_from(x)),\n    )\n}\n\npub fn random_unsigned_gen_var_19<\n    T: TryFrom<NiceFloat<U>> + PrimitiveUnsigned,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    _config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        random_unsigned_inclusive_range(\n            EXAMPLE_SEED,\n            T::exact_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n            T::MAX,\n        )\n        .filter_map(|a| {\n            let f = U::rounding_from(a, Down).0;\n            let a = T::try_from(NiceFloat(f)).ok()?;\n            let b = T::try_from(NiceFloat(f.next_higher())).ok()?;\n            let diff = b - a;\n            if diff.even() {\n                // This happens almost always\n                Some(a + (diff >> 1))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn random_unsigned_gen_var_20<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::MAX.floor_sqrt(),\n    ))\n}\n\npub fn random_unsigned_gen_var_21<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<T> {\n    Box::new(\n        random_unsigned_inclusive_range(EXAMPLE_SEED, T::ZERO, T::low_mask(T::WIDTH - 1))\n            .map(|u| (u << 1) | T::ONE),\n    )\n}\n\npub fn random_unsigned_gen_var_22<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_factorial);\n    Box::new(random_unsigned_range(EXAMPLE_SEED, 0, limit))\n}\n\npub fn random_unsigned_gen_var_23<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_double_factorial);\n    Box::new(random_unsigned_range(EXAMPLE_SEED, 0, limit))\n}\n\npub fn random_unsigned_gen_var_24<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_subfactorial);\n    Box::new(random_unsigned_range(EXAMPLE_SEED, 0, limit))\n}\n\npub fn random_unsigned_gen_var_25<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(geometric_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::wrapping_from(5u8),\n        T::MAX,\n        config.get_or(\"mean_n\", 128),\n        config.get_or(\"mean_d\", 1),\n    ))\n}\n\npub fn random_unsigned_gen_var_26<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_primorial);\n    Box::new(random_unsigned_range(EXAMPLE_SEED, 0, limit))\n}\n\npub fn random_unsigned_gen_var_27<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_product_of_first_n_primes);\n    Box::new(random_unsigned_range(EXAMPLE_SEED, 0, limit))\n}\n\npub fn random_unsigned_gen_var_28<T: PrimitiveUnsigned + IsPrime>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_ints(EXAMPLE_SEED).filter(T::is_prime))\n}\n\npub fn random_signed_gen_var_29<T: PrimitiveFloat>(_config: &GenConfig) -> It<u64> {\n    Box::new(random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        0,\n        u64::exact_from(T::MAX_EXPONENT),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveInt) --\n\npub fn random_unsigned_primitive_int_pair_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveInt>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_inclusive_range(seed, T::power_of_2(T::WIDTH - 2), T::MAX),\n        &random_primitive_ints,\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveInt, PrimitiveInt, PrimitiveUnsigned) --\n\nstruct ModPowerOf2QuadrupleWithTwoExtraPrimitiveIntsGenerator<T: PrimitiveUnsigned, U: PrimitiveInt>\n{\n    ms: GeometricRandomNaturalValues<u64>,\n    us: RandomPrimitiveInts<U>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveInt> Iterator\n    for ModPowerOf2QuadrupleWithTwoExtraPrimitiveIntsGenerator<T, U>\n{\n    type Item = (T, U, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), self.us.next().unwrap(), pow))\n    }\n}\n\npub fn random_unsigned_primitive_int_primitive_int_unsigned_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(T, U, U, u64)> {\n    Box::new(ModPowerOf2QuadrupleWithTwoExtraPrimitiveIntsGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: random_primitive_ints(EXAMPLE_SEED.fork(\"us\")),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\n// -- (PrimitiveUnsigned, PrimitiveInt, PrimitiveUnsigned) --\n\nstruct ModPowerOf2TripleWithExtraPrimitiveIntGenerator<T: PrimitiveUnsigned, U: PrimitiveInt> {\n    ms: GeometricRandomNaturalValues<u64>,\n    us: RandomPrimitiveInts<U>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveInt> Iterator\n    for ModPowerOf2TripleWithExtraPrimitiveIntGenerator<T, U>\n{\n    type Item = (T, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn random_unsigned_primitive_int_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(T, U, u64)> {\n    Box::new(ModPowerOf2TripleWithExtraPrimitiveIntGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: random_primitive_ints(EXAMPLE_SEED.fork(\"us\")),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned) --\n\nstruct IntegerMantissaAndExponentGenerator<T: PrimitiveFloat> {\n    xs: SpecialRandomNonzeroFiniteFloats<T>,\n    shifts: GeometricRandomNaturalValues<i64>,\n}\n\n#[inline]\npub(crate) fn shift_integer_mantissa_and_exponent(\n    mantissa: u64,\n    exponent: i64,\n    shift: i64,\n) -> Option<(u64, i64)> {\n    Some((\n        mantissa.arithmetic_checked_shl(shift)?,\n        exponent.checked_sub(shift)?,\n    ))\n}\n\nimpl<T: PrimitiveFloat> Iterator for IntegerMantissaAndExponentGenerator<T> {\n    type Item = (u64, i64);\n\n    fn next(&mut self) -> Option<(u64, i64)> {\n        loop {\n            let (mantissa, exponent) = self.xs.next().unwrap().integer_mantissa_and_exponent();\n            let shift = self.shifts.next().unwrap();\n            let out = shift_integer_mantissa_and_exponent(mantissa, exponent, shift);\n            if out.is_some() {\n                return out;\n            }\n        }\n    }\n}\n\npub fn random_unsigned_signed_pair_gen_var_1<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(u64, i64)> {\n    Box::new(IntegerMantissaAndExponentGenerator::<T> {\n        xs: special_random_nonzero_finite_primitive_floats(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n        ),\n        shifts: geometric_random_natural_signeds(\n            EXAMPLE_SEED.fork(\"shifts\"),\n            config.get_or(\"shift_mean_n\", 4),\n            config.get_or(\"shift_mean_d\", 1),\n        ),\n    })\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned, PrimitiveUnsigned) --\n\nstruct ModPowerOf2TripleWithExtraSmallSignedGenerator<T: PrimitiveUnsigned, U: PrimitiveSigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    us: GeometricRandomSigneds<U>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveSigned> Iterator\n    for ModPowerOf2TripleWithExtraSmallSignedGenerator<T, U>\n{\n    type Item = (T, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn random_unsigned_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, u64)> {\n    Box::new(ModPowerOf2TripleWithExtraSmallSignedGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: geometric_random_signeds(\n            EXAMPLE_SEED.fork(\"us\"),\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\npub fn random_unsigned_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_unsigned_pair_gen_var_1(_config: &GenConfig) -> It<(u32, u32)> {\n    Box::new(random_pairs_from_single(random_unsigneds_less_than(\n        EXAMPLE_SEED,\n        NUMBER_OF_CHARS,\n    )))\n}\n\npub fn random_unsigned_pair_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, 1, U::WIDTH),\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_4<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, V)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::saturating_from(U::MAX)),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &random_positive_unsigneds::<T>,\n        )\n        .map(|(x, y)| (x.round_to_multiple(y, Down).0, y)),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_6<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<T>,\n        &random_positive_unsigneds::<U>,\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &random_positive_unsigneds::<T>,\n        )\n        .filter(|&(x, y)| !x.divisible_by(y)),\n    )\n}\n\nstruct ModPowerOf2SingleGenerator<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2SingleGenerator<T> {\n    type Item = (T, u64);\n\n    fn next(&mut self) -> Option<(T, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, pow))\n    }\n}\n\nstruct ModPowerOf2SingleGenerator2<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<Box<dyn Iterator<Item = T>>>>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2SingleGenerator2<T> {\n    type Item = (T, u64);\n\n    fn next(&mut self) -> Option<(T, u64)> {\n        let pow = self.ms.next().unwrap();\n        assert_ne!(pow, 0);\n        let xs = &mut self.xss[usize::wrapping_from(pow)];\n        if xs.is_none() {\n            *xs = Some(Box::new(\n                random_unsigned_bit_chunks(EXAMPLE_SEED.fork(&pow.to_string()), pow)\n                    .filter(|&x| x != T::ZERO),\n            ));\n        }\n        let x = xs.as_mut().unwrap().next().unwrap();\n        Some((x, pow))\n    }\n}\n\npub fn random_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, u64)> {\n    Box::new(ModPowerOf2SingleGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\npub fn random_unsigned_pair_gen_var_9<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_10<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, U::TWO, U::exact_from(36u8)),\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_11<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n                .map(|x| (T::ZERO, x))\n            },\n            &|seed| {\n                random_pairs(seed, &random_positive_unsigneds, &|seed_2| {\n                    random_unsigneds_less_than(seed_2, T::WIDTH)\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_12<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_unsigneds,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_13<T: PrimitiveFloat>(_config: &GenConfig) -> It<(u64, u64)> {\n    Box::new(random_pairs_from_single(random_unsigneds_less_than(\n        EXAMPLE_SEED,\n        T::LARGEST_ORDERED_REPRESENTATION,\n    )))\n}\n\npub fn random_unsigned_pair_gen_var_14<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_unsigneds,\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed,\n                U::TWO,\n                U::MAX,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_15<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_inclusive_range(seed, T::ZERO, T::saturating_from(u64::MAX)),\n        &random_positive_unsigneds::<U>,\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_16<T: PrimitiveFloat>(_config: &GenConfig) -> It<(u64, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_bit_chunks(seed, T::MANTISSA_WIDTH),\n        &|seed| random_unsigned_bit_chunks(seed, T::EXPONENT_WIDTH),\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_17<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_18<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| x.checked_pow(y).is_some()),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_19<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, u64)> {\n    Box::new(random_unsigned_pair_gen_var_8(config).map(|(x, p)| (x, T::WIDTH - p)))\n}\n\npub fn random_unsigned_pair_gen_var_20<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| random_unsigned_inclusive_range(seed, U::power_of_2(U::WIDTH - 2), U::MAX),\n    ))\n}\n\nstruct LikelyMultiplyablePairs<T: PrimitiveUnsigned> {\n    bits: GeometricRandomNaturalValues<u64>,\n    ranges: VariableRangeGenerator,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for LikelyMultiplyablePairs<T> {\n    type Item = (T, T);\n\n    fn next(&mut self) -> Option<(T, T)> {\n        let x_bits = self.bits.next().unwrap();\n        let x = if x_bits == 0 {\n            T::ZERO\n        } else {\n            self.ranges.next_bit_chunk(x_bits)\n        };\n        let y_bits = self.bits.next().unwrap();\n        let y = if y_bits == 0 {\n            T::ZERO\n        } else {\n            self.ranges.next_bit_chunk(y_bits)\n        };\n        Some((x, y))\n    }\n}\n\npub fn random_unsigned_pair_gen_var_21<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(LikelyMultiplyablePairs {\n        bits: geometric_random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"bits\"),\n            0,\n            T::WIDTH,\n            T::WIDTH >> 1,\n            1,\n        ),\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        phantom: PhantomData,\n    })\n}\n\npub fn random_unsigned_pair_gen_var_22<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_unsigned_pair_gen_var_21::<T>(config).filter(|&(x, y)| x.checked_lcm(y).is_some()),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_23<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_inclusive_range(seed, T::power_of_2(T::WIDTH - 1), T::MAX),\n        &random_primitive_ints,\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_24<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_positive_unsigneds,\n            &random_primitive_ints,\n        )\n        .filter(|&(x, y)| x != T::ONE || y != T::ZERO),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_25<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_unsigneds,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_26<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_ordered_unique_pairs(random_positive_unsigneds::<T>(\n        EXAMPLE_SEED,\n    )))\n}\n\npub fn random_unsigned_pair_gen_var_27<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, u64)> {\n    Box::new(ModPowerOf2SingleGenerator2 {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            1,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: {\n            let len = usize::wrapping_from(T::WIDTH) + 1;\n            let mut xss = Vec::with_capacity(len);\n            xss.resize_with(len, || None);\n            xss\n        },\n    })\n}\n\npub fn random_unsigned_pair_gen_var_28<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_unsigned_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn random_unsigned_pair_gen_var_29<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(\n            random_unsigned_inclusive_range(EXAMPLE_SEED, T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE),\n        )\n        .filter(|&(a, b): &(T, T)| a.coprime_with(b)),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_30<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .filter(|&(x, y): &(T, T)| x.coprime_with(y)),\n    )\n}\n\nstruct MultifactorialNGenerator<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    ranges: VariableRangeGenerator,\n    ms_to_n_limit: HashMap<u64, u64>,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for MultifactorialNGenerator<T> {\n    type Item = (u64, u64);\n\n    fn next(&mut self) -> Option<(u64, u64)> {\n        let m = self.ms.next().unwrap();\n        let smallest_invalid_n = self\n            .ms_to_n_limit\n            .entry(m)\n            .or_insert_with(|| smallest_invalid_value(|n| T::checked_multifactorial(n, m)));\n        let n = self.ranges.next_less_than(*smallest_invalid_n);\n        Some((n, m))\n    }\n}\n\npub fn random_unsigned_pair_gen_var_31<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(u64, u64)> {\n    Box::new(MultifactorialNGenerator {\n        ms: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_m_n\", 4),\n            config.get_or(\"mean_m_d\", 1),\n        ),\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        ms_to_n_limit: HashMap::new(),\n        phantom: PhantomData::<*const T>,\n    })\n}\n\npub fn random_unsigned_pair_gen_var_32<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(geometric_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_small_n\", 32),\n            config.get_or(\"mean_small_d\", 1),\n        ))\n        .filter(|&(n, k)| T::checked_binomial_coefficient(n, k).is_some()),\n    )\n}\n\n// vars 33 through 37 are in malachite-nz\n\npub fn random_unsigned_pair_gen_var_38<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::MAX,\n    )))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveInt, PrimitiveUnsigned) --\n\nstruct ModPowerOf2QuadrupleWithExtraPrimitiveIntGenerator<T: PrimitiveUnsigned, U: PrimitiveInt> {\n    ms: GeometricRandomNaturalValues<u64>,\n    us: RandomPrimitiveInts<U>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveInt> Iterator\n    for ModPowerOf2QuadrupleWithExtraPrimitiveIntGenerator<T, U>\n{\n    type Item = (T, T, U, u64);\n\n    fn next(&mut self) -> Option<(T, T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let (x, y) = if pow == 0 {\n            (T::ZERO, T::ZERO)\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            let xs = xs.as_mut().unwrap();\n            (xs.next().unwrap(), xs.next().unwrap())\n        };\n        Some((x, y, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn random_unsigned_unsigned_primitive_int_unsigned_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(T, T, U, u64)> {\n    Box::new(ModPowerOf2QuadrupleWithExtraPrimitiveIntGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: random_primitive_ints(EXAMPLE_SEED.fork(\"us\")),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\nfn wrapping_shr<T: PrimitiveInt>(x: T, bits: u64) -> T {\n    if bits >= x.significant_bits() {\n        T::ZERO\n    } else {\n        x >> bits\n    }\n}\n\npub(crate) fn reduce_to_fit_add_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> (T, T, T) {\n    let (p_hi, p_lo) = T::x_mul_y_to_zz(y, z);\n    let r_hi = T::xx_add_yy_to_zz(T::ZERO, x, p_hi, p_lo).0;\n    if r_hi == T::ZERO {\n        (x, y, z)\n    } else {\n        let excess_x: u64 = r_hi.significant_bits();\n        let excess_yz = excess_x.shr_round(1, Ceiling).0;\n        (\n            wrapping_shr(x, excess_x),\n            wrapping_shr(y, excess_yz),\n            wrapping_shr(z, excess_yz),\n        )\n    }\n}\n\npub fn random_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .map(|(x, y, z)| reduce_to_fit_add_mul_unsigned(x, y, z)),\n    )\n}\n\npub(crate) fn reduce_to_fit_sub_mul_unsigned<T: PrimitiveUnsigned>(x: T, y: T, z: T) -> (T, T, T) {\n    let x_bits = x.significant_bits();\n    let (p_hi, p_lo) = T::x_mul_y_to_zz(y, z);\n    let product_bits = if p_hi == T::ZERO {\n        p_lo.significant_bits()\n    } else {\n        p_hi.significant_bits() + T::WIDTH\n    };\n    if x_bits > product_bits {\n        (x, y, z)\n    } else {\n        let excess = (product_bits - x_bits + 1).shr_round(1, Ceiling).0;\n        (x, wrapping_shr(y, excess), wrapping_shr(z, excess))\n    }\n}\n\npub fn random_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .map(|(x, y, z)| reduce_to_fit_sub_mul_unsigned(x, y, z)),\n    )\n}\n\npub fn random_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_primitive_ints::<T>(EXAMPLE_SEED)).map(|(x, y, m)| {\n            if m == T::ZERO {\n                let min = min(x, y);\n                (min, min, m)\n            } else if x <= y {\n                let adjusted_diff = (y - x).round_to_multiple(m, Down).0;\n                (x, x + adjusted_diff, m)\n            } else {\n                let adjusted_diff = (x - y).round_to_multiple(m, Down).0;\n                (y + adjusted_diff, y, m)\n            }\n        }),\n    )\n}\n\npub fn random_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, u64)> {\n    Box::new(\n        random_triples_xxy(EXAMPLE_SEED, &random_primitive_ints::<T>, &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_pow_n\", 32),\n                config.get_or(\"mean_pow_d\", 1),\n            )\n        })\n        .map(|(x, y, pow)| {\n            if pow >= T::WIDTH {\n                (x, x, pow)\n            } else if x <= y {\n                let adjusted_diff = (y - x).round_to_multiple_of_power_of_2(pow, Down).0;\n                (x, x + adjusted_diff, pow)\n            } else {\n                let adjusted_diff = (x - y).round_to_multiple_of_power_of_2(pow, Down).0;\n                (y + adjusted_diff, y, pow)\n            }\n        }),\n    )\n}\n\nstruct ModPowerOf2PairGenerator<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2PairGenerator<T> {\n    type Item = (T, T, u64);\n\n    fn next(&mut self) -> Option<(T, T, u64)> {\n        let pow = self.ms.next().unwrap();\n        let (x, y) = if pow == 0 {\n            (T::ZERO, T::ZERO)\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            let xs = xs.as_mut().unwrap();\n            (xs.next().unwrap(), xs.next().unwrap())\n        };\n        Some((x, y, pow))\n    }\n}\n\npub fn random_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, u64)> {\n    Box::new(ModPowerOf2PairGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\nstruct ModPowerOf2TripleWithExtraSmallUnsignedGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n{\n    ms: GeometricRandomNaturalValues<u64>,\n    us: GeometricRandomNaturalValues<U>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for ModPowerOf2TripleWithExtraSmallUnsignedGenerator<T, U>\n{\n    type Item = (T, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn random_unsigned_triple_gen_var_6<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, u64)> {\n    Box::new(ModPowerOf2TripleWithExtraSmallUnsignedGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"us\"),\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\npub fn random_unsigned_triple_gen_var_7<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, U)> {\n    Box::new(\n        random_triples_xyy(EXAMPLE_SEED, &random_positive_unsigneds, &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        })\n        .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) }),\n    )\n}\n\npub fn random_unsigned_triple_gen_var_8<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_xyx(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_unsigned_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn random_unsigned_triple_gen_var_9<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_unsigned_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn random_unsigned_triple_gen_var_10<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_unsigned_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn random_unsigned_triple_gen_var_11<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\nstruct ModPowerOf2TripleGenerator<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<RandomUnsignedBitChunks<T>>>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2TripleGenerator<T> {\n    type Item = (T, T, T, u64);\n\n    fn next(&mut self) -> Option<(T, T, T, u64)> {\n        let pow = self.ms.next().unwrap();\n        let (x, y, z) = if pow == 0 {\n            (T::ZERO, T::ZERO, T::ZERO)\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                ));\n            }\n            let xs = xs.as_mut().unwrap();\n            (xs.next().unwrap(), xs.next().unwrap(), xs.next().unwrap())\n        };\n        Some((x, y, z, pow))\n    }\n}\n\npub fn random_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, u64)> {\n    Box::new(ModPowerOf2TripleGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n    })\n}\n\npub fn random_unsigned_quadruple_gen_var_2<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            &random_positive_unsigneds,\n        )\n        .map(|(x_1, x_0, d)| {\n            let inv = limbs_invert_limb_naive::<T, DT>(d << LeadingZeros::leading_zeros(d));\n            (x_1, x_0, d, inv)\n        }),\n    )\n}\n\npub fn random_unsigned_quadruple_gen_var_3<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        &|seed| {\n            random_unsigned_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\nstruct UnsignedUnsignedRoundingModeTripleGenerator<T: PrimitiveUnsigned> {\n    xs: RandomPrimitiveInts<T>,\n    rms: RandomRoundingModes,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedUnsignedRoundingModeTripleGenerator<T> {\n    type Item = (T, T, RoundingMode);\n\n    fn next(&mut self) -> Option<(T, T, RoundingMode)> {\n        let mut x = self.xs.next().unwrap();\n        let mut y;\n        loop {\n            y = self.xs.next().unwrap();\n            if y != T::ZERO {\n                break;\n            }\n        }\n        let rm = self.rms.next().unwrap();\n        if rm == Exact {\n            x.round_to_multiple_assign(y, Down);\n        }\n        Some((x, y, rm))\n    }\n}\n\npub fn random_unsigned_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, RoundingMode)> {\n    Box::new(UnsignedUnsignedRoundingModeTripleGenerator {\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        rms: random_rounding_modes(EXAMPLE_SEED.fork(\"rms\")),\n    })\n}\n\npub fn random_unsigned_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            &random_positive_unsigneds,\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_unsigned_filter_map(x, y, rm)),\n    )\n}\n\n// vars 3 through 5 are in malachite-float.\n\n// -- (PrimitiveUnsigned, RoundingMode) --\n\npub fn random_unsigned_rounding_mode_pair_gen_var_1<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_unsigneds,\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_unsigned_rounding_mode_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_unsigned_rounding_mode_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n    ))\n}\n\npub fn random_unsigned_rounding_mode_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (PrimitiveUnsigned, String) --\n\nstruct DigitStringGenerator {\n    ranges: VariableRangeGenerator,\n    digit_map: HashMap<u8, Vec<char>>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n}\n\nimpl Iterator for DigitStringGenerator {\n    type Item = (u8, String);\n\n    fn next(&mut self) -> Option<(u8, String)> {\n        let base = self.ranges.next_in_inclusive_range(2, 36);\n        let digits = self\n            .digit_map\n            .entry(base)\n            .or_insert_with(|| valid_digit_chars(base));\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut s = String::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            let index = self.ranges.next_less_than(digits.len());\n            s.push(digits[index]);\n        }\n        Some((base, s))\n    }\n}\n\npub fn random_unsigned_string_pair_gen_var_1(config: &GenConfig) -> It<(u8, String)> {\n    Box::new(DigitStringGenerator {\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        digit_map: HashMap::new(),\n        digit_counts: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            1,\n            usize::MAX,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n    })\n}\n\npub fn random_unsigned_string_pair_gen_var_2(config: &GenConfig) -> It<(u8, String)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_inclusive_range(seed, 2, 36),\n        &|seed| {\n            random_strings(\n                seed,\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct TargetedIntegerFromStringBaseInputs {\n    uss: It<(u8, String)>,\n    negs: RandomBools,\n}\n\nimpl Iterator for TargetedIntegerFromStringBaseInputs {\n    type Item = (u8, String);\n\n    fn next(&mut self) -> Option<(u8, String)> {\n        if self.negs.next().unwrap() {\n            let (u, s) = self.uss.next().unwrap();\n            let mut out = '-'.to_string();\n            out.push_str(&s);\n            Some((u, out))\n        } else {\n            self.uss.next()\n        }\n    }\n}\n\npub fn random_unsigned_string_pair_gen_var_3(config: &GenConfig) -> It<(u8, String)> {\n    Box::new(TargetedIntegerFromStringBaseInputs {\n        uss: Box::new(DigitStringGenerator {\n            ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n            digit_map: HashMap::new(),\n            digit_counts: geometric_random_unsigned_range(\n                EXAMPLE_SEED.fork(\"digit_counts\"),\n                1,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n        }),\n        negs: random_bools(EXAMPLE_SEED.fork(\"negs\")),\n    })\n}\n\n// --(PrimitiveUnsigned, Vec<bool>) --\n\nstruct UnsignedBoolVecPairGeneratorVar1<T: PrimitiveUnsigned> {\n    xs: RandomPrimitiveInts<T>,\n    bs: RandomBools,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedBoolVecPairGeneratorVar1<T> {\n    type Item = (T, Vec<bool>);\n\n    fn next(&mut self) -> Option<(T, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = (&mut self.bs)\n            .take(usize::exact_from(x.significant_bits()))\n            .collect();\n        Some((x, bs))\n    }\n}\n\npub fn random_unsigned_bool_vec_pair_gen_var_1<T: PrimitiveUnsigned>(\n    _config: &GenConfig,\n) -> It<(T, Vec<bool>)> {\n    Box::new(UnsignedBoolVecPairGeneratorVar1 {\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n// -- RationalSequence<PrimitiveInt> --\n\npub fn random_primitive_int_rational_sequence_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<RationalSequence<T>> {\n    Box::new(random_rational_sequences(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\n// -- (RationalSequence<PrimitiveInt>, PrimitiveUnsigned) --\n\npub fn random_primitive_int_rational_sequence_unsigned_pair_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rational_sequences(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 32),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_rational_sequence_unsigned_pair_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, usize)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rational_sequences(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_unsigned_n\", 32),\n                    config.get_or(\"mean_small_unsigned_d\", 1),\n                )\n            },\n        )\n        .filter(|&(ref xs, i)| {\n            if let Some(len) = xs.len() {\n                i < len\n            } else {\n                true\n            }\n        }),\n    )\n}\n\n// -- (RationalSequence<PrimitiveInt>, RationalSequence<PrimitiveInt>) --\n\npub fn random_primitive_int_rational_sequence_pair_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, RationalSequence<T>)> {\n    Box::new(random_pairs_from_single(random_rational_sequences(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\n// -- RationalSequence<PrimitiveInt> * 3 --\n\npub fn random_primitive_int_rational_sequence_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(\n    RationalSequence<T>,\n    RationalSequence<T>,\n    RationalSequence<T>,\n)> {\n    Box::new(random_triples_from_single(random_rational_sequences(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\n// -- RoundingMode --\n\npub fn random_rounding_mode_gen(_config: &GenConfig) -> It<RoundingMode> {\n    Box::new(random_rounding_modes(EXAMPLE_SEED))\n}\n\n// -- (RoundingMode, RoundingMode) --\n\npub fn random_rounding_mode_pair_gen(_config: &GenConfig) -> It<(RoundingMode, RoundingMode)> {\n    Box::new(random_pairs_from_single(random_rounding_modes(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- (RoundingMode, RoundingMode, RoundingMode) --\n\npub fn random_rounding_mode_triple_gen(\n    _config: &GenConfig,\n) -> It<(RoundingMode, RoundingMode, RoundingMode)> {\n    Box::new(random_triples_from_single(random_rounding_modes(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- SciSizeOptions --\n\npub fn random_sci_size_options_gen(config: &GenConfig) -> It<SciSizeOptions> {\n    Box::new(random_sci_size_options(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_size_n\", 32),\n        config.get_or(\"mean_size_d\", 1),\n    ))\n}\n\n// -- String --\n\npub fn random_string_gen(config: &GenConfig) -> It<String> {\n    Box::new(random_strings(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn random_string_gen_var_1(config: &GenConfig) -> It<String> {\n    Box::new(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &random_ascii_chars,\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn random_string_gen_var_2(config: &GenConfig) -> It<String> {\n    Box::new(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &|seed| random_values_from_vec(seed, ROUNDING_MODE_CHARS.chars().collect()),\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn random_string_gen_var_3(config: &GenConfig) -> It<String> {\n    Box::new(strings_from_char_vecs(random_vecs_min_length(\n        EXAMPLE_SEED,\n        1,\n        &|seed| random_values_from_vec(seed, ('0'..='9').collect()),\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\nstruct TargetedIntegerFromStrStringsVar1 {\n    ss: It<String>,\n    negs: RandomBools,\n}\n\nimpl Iterator for TargetedIntegerFromStrStringsVar1 {\n    type Item = String;\n\n    fn next(&mut self) -> Option<String> {\n        if self.negs.next().unwrap() {\n            Some(format!(\"-{}\", self.ss.next().unwrap()))\n        } else {\n            self.ss.next()\n        }\n    }\n}\n\npub fn random_string_gen_var_4(config: &GenConfig) -> It<String> {\n    Box::new(TargetedIntegerFromStrStringsVar1 {\n        ss: Box::new(strings_from_char_vecs(random_vecs_min_length(\n            EXAMPLE_SEED.fork(\"ss\"),\n            1,\n            &|seed| random_values_from_vec(seed, ('0'..='9').collect()),\n            config.get_or(\"mean_length_n\", 32),\n            config.get_or(\"mean_length_d\", 1),\n        ))),\n        negs: random_bools(EXAMPLE_SEED.fork(\"negs\")),\n    })\n}\n\npub fn random_string_gen_var_5(config: &GenConfig) -> It<String> {\n    Box::new(strings_from_char_vecs(random_vecs_min_length(\n        EXAMPLE_SEED,\n        1,\n        &|seed| random_values_from_vec(seed, ('0'..='1').collect()),\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub fn random_string_gen_var_6(config: &GenConfig) -> It<String> {\n    Box::new(strings_from_char_vecs(random_vecs_min_length(\n        EXAMPLE_SEED,\n        1,\n        &|seed| random_values_from_vec(seed, ('0'..='7').collect()),\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub fn random_string_gen_var_7(config: &GenConfig) -> It<String> {\n    Box::new(strings_from_char_vecs(random_vecs_min_length(\n        EXAMPLE_SEED,\n        1,\n        &|seed| {\n            random_union3s(\n                seed,\n                &|seed_2| random_values_from_vec(seed_2, ('0'..='9').collect()),\n                &|seed_2| random_values_from_vec(seed_2, ('a'..='f').collect()),\n                &|seed_2| random_values_from_vec(seed_2, ('A'..='F').collect()),\n            )\n            .map(Union3::unwrap)\n        },\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub fn random_string_gen_var_8(config: &GenConfig) -> It<String> {\n    Box::new(\n        strings_from_char_vecs(random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &|seed| {\n                random_union3s(\n                    seed,\n                    &|seed_2| random_values_from_vec(seed_2, ('0'..='9').collect()),\n                    &|seed_2| random_values_from_vec(seed_2, ('a'..='f').collect()),\n                    &|seed_2| random_values_from_vec(seed_2, ('A'..='F').collect()),\n                )\n                .map(Union3::unwrap)\n            },\n            config.get_or(\"mean_length_n\", 32),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|s| format!(\"\\\"0x{s}\\\"\")),\n    )\n}\n\nstruct TargetedIntegerFromStrStringsVar2 {\n    ss: It<String>,\n    negs: RandomBools,\n}\n\nimpl Iterator for TargetedIntegerFromStrStringsVar2 {\n    type Item = String;\n\n    fn next(&mut self) -> Option<String> {\n        Some(if self.negs.next().unwrap() {\n            format!(\"\\\"-0x{}\\\"\", self.ss.next().unwrap())\n        } else {\n            format!(\"\\\"0x{}\\\"\", self.ss.next().unwrap())\n        })\n    }\n}\n\npub fn random_string_gen_var_9(config: &GenConfig) -> It<String> {\n    Box::new(TargetedIntegerFromStrStringsVar2 {\n        ss: Box::new(strings_from_char_vecs(random_vecs_min_length(\n            EXAMPLE_SEED.fork(\"ss\"),\n            1,\n            &|seed| {\n                random_union3s(\n                    seed,\n                    &|seed_2| random_values_from_vec(seed_2, ('0'..='9').collect()),\n                    &|seed_2| random_values_from_vec(seed_2, ('a'..='f').collect()),\n                    &|seed_2| random_values_from_vec(seed_2, ('A'..='F').collect()),\n                )\n                .map(Union3::unwrap)\n            },\n            config.get_or(\"mean_length_n\", 32),\n            config.get_or(\"mean_length_d\", 1),\n        ))),\n        negs: random_bools(EXAMPLE_SEED.fork(\"negs\")),\n    })\n}\n\npub fn random_string_gen_var_10(config: &GenConfig) -> It<String> {\n    Box::new(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &|seed| random_values_from_vec(seed, PRIMITIVE_FLOAT_CHARS.chars().collect()),\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\n// vars 11 through 12 are in malachite-q.\n\npub fn random_string_gen_var_13(config: &GenConfig) -> It<String> {\n    Box::new(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &|seed| random_values_from_vec(seed, DECIMAL_SCI_STRING_CHARS.chars().collect()),\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn random_string_gen_var_14(config: &GenConfig) -> It<String> {\n    Box::new(\n        random_strings(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_length_n\", 32),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|s| !large_exponent(s)),\n    )\n}\n\npub fn random_string_gen_var_15(config: &GenConfig) -> It<String> {\n    Box::new(\n        random_strings_using_chars(\n            EXAMPLE_SEED,\n            &|seed| random_values_from_vec(seed, DECIMAL_SCI_STRING_CHARS.chars().collect()),\n            config.get_or(\"mean_length_n\", 32),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|s| !large_exponent(s)),\n    )\n}\n\n// -- (String, FromSciStringOptions) --\n\npub fn random_string_from_sci_string_options_pair_gen(\n    config: &GenConfig,\n) -> It<(String, FromSciStringOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_strings(\n                seed,\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &random_from_sci_string_options,\n    ))\n}\n\nstruct SciDigitStringGenerator {\n    options: RandomFromSciStringOptions,\n    ranges: VariableRangeGenerator,\n    digit_map: HashMap<u8, Vec<char>>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n}\n\nimpl Iterator for SciDigitStringGenerator {\n    type Item = (String, FromSciStringOptions);\n\n    fn next(&mut self) -> Option<(String, FromSciStringOptions)> {\n        let options = self.options.next().unwrap();\n        let base = options.get_base();\n        let digits = self.digit_map.entry(base).or_insert_with(|| {\n            let mut cs = vec!['+', '-', '.'];\n            if base < 15 {\n                cs.push('e');\n                cs.push('E');\n            }\n            cs.extend(valid_digit_chars(base));\n            cs\n        });\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut s = String::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            let index = self.ranges.next_less_than(digits.len());\n            s.push(digits[index]);\n        }\n        Some((s, options))\n    }\n}\n\nstruct SciDigitStringGenerator2 {\n    ranges: VariableRangeGenerator,\n    digit_map: HashMap<u8, Vec<char>>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n}\n\nimpl Iterator for SciDigitStringGenerator2 {\n    type Item = (String, u8);\n\n    fn next(&mut self) -> Option<(String, u8)> {\n        let base = self.ranges.next_in_inclusive_range(2, 36);\n        let digits = self.digit_map.entry(base).or_insert_with(|| {\n            let mut cs = vec!['+', '-', '.'];\n            if base < 15 {\n                cs.push('e');\n                cs.push('E');\n            }\n            cs.extend(valid_digit_chars(base));\n            cs\n        });\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut s = String::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            let index = self.ranges.next_less_than(digits.len());\n            s.push(digits[index]);\n        }\n        Some((s, base))\n    }\n}\n\npub fn random_string_from_sci_string_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(String, FromSciStringOptions)> {\n    Box::new(SciDigitStringGenerator {\n        options: random_from_sci_string_options(EXAMPLE_SEED.fork(\"options\")),\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        digit_map: HashMap::new(),\n        digit_counts: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            1,\n            usize::MAX,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n    })\n}\n\npub fn random_string_from_sci_string_options_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(String, FromSciStringOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_strings(\n                seed,\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|s| !large_exponent(s))\n        },\n        &random_from_sci_string_options,\n    ))\n}\n\npub fn random_string_from_sci_string_options_pair_gen_var_3(\n    config: &GenConfig,\n) -> It<(String, FromSciStringOptions)> {\n    Box::new(\n        SciDigitStringGenerator {\n            options: random_from_sci_string_options(EXAMPLE_SEED.fork(\"options\")),\n            ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n            digit_map: HashMap::new(),\n            digit_counts: geometric_random_unsigned_range(\n                EXAMPLE_SEED.fork(\"digit_counts\"),\n                1,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n        }\n        .filter(|(s, _)| !large_exponent(s)),\n    )\n}\n\n// -- (String, PrimitiveUnsigned) --\n\npub fn random_string_unsigned_pair_gen_var_1(config: &GenConfig) -> It<(String, u8)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_strings(\n                seed,\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|s| !large_exponent(s))\n        },\n        &|seed| random_unsigned_inclusive_range(seed, 2, 36),\n    ))\n}\n\npub fn random_string_unsigned_pair_gen_var_2(config: &GenConfig) -> It<(String, u8)> {\n    Box::new(\n        SciDigitStringGenerator2 {\n            ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n            digit_map: HashMap::new(),\n            digit_counts: geometric_random_unsigned_range(\n                EXAMPLE_SEED.fork(\"digit_counts\"),\n                1,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n        }\n        .filter(|(s, _)| !large_exponent(s)),\n    )\n}\n\n// -- (String, String) --\n\npub fn random_string_pair_gen(config: &GenConfig) -> It<(String, String)> {\n    Box::new(random_pairs_from_single(random_strings(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub fn random_string_pair_gen_var_1(config: &GenConfig) -> It<(String, String)> {\n    Box::new(random_pairs_from_single(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &random_ascii_chars,\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\n// -- ToSciOptions --\n\npub fn random_to_sci_options_gen(config: &GenConfig) -> It<ToSciOptions> {\n    Box::new(random_to_sci_options(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_size_n\", 32),\n        config.get_or(\"mean_size_d\", 1),\n    ))\n}\n\n// -- (ToSciOptions, bool) --\n\npub fn random_to_sci_options_bool_pair_gen(config: &GenConfig) -> It<(ToSciOptions, bool)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (ToSciOptions, PrimitiveSigned) --\n\npub fn random_to_sci_options_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(ToSciOptions, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_negative_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (ToSciOptions, PrimitiveUnsigned) --\n\npub fn random_to_sci_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(ToSciOptions, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::from(36u8)),\n    ))\n}\n\npub fn random_to_sci_options_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(ToSciOptions, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_to_sci_options_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(ToSciOptions, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (ToSciOptions, RoundingMode) --\n\npub fn random_to_sci_options_rounding_mode_pair_gen(\n    config: &GenConfig,\n) -> It<(ToSciOptions, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- Vec<bool> --\n\npub fn random_bool_vec_gen(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &random_bools,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn random_bool_vec_gen_var_1<T: PrimitiveUnsigned>(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| random_vecs_length_inclusive_range(seed, 0, T::WIDTH, &random_bools),\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| random_vecs_fixed_length_from_single(T::WIDTH, random_bools(seed_2)),\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| bs.into_iter().chain(repeat_n(false, n)).collect())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_bool_vec_gen_var_2<T: PrimitiveSigned>(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| random_vecs_length_inclusive_range(seed, 0, T::WIDTH - 1, &random_bools),\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_vecs_fixed_length_from_single(T::WIDTH - 1, random_bools(seed_2))\n                    },\n                    &|seed_2| {\n                        geometric_random_nonzero_signeds::<isize>(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| {\n                    bs.into_iter()\n                        .chain(repeat_n(n < 0, n.unsigned_abs()))\n                        .collect()\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_bool_vec_gen_var_3<T: PrimitiveUnsigned>(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| random_vecs_length_inclusive_range(seed, 0, T::WIDTH, &random_bools),\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| random_vecs_fixed_length_from_single(T::WIDTH, random_bools(seed_2)),\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| repeat_n(false, n).chain(bs).collect())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_bool_vec_gen_var_4<T: PrimitiveSigned>(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| random_vecs_length_inclusive_range(seed, 0, T::WIDTH - 1, &random_bools),\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_vecs_fixed_length_from_single(T::WIDTH - 1, random_bools(seed_2))\n                    },\n                    &|seed_2| {\n                        geometric_random_nonzero_signeds::<isize>(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| repeat_n(n < 0, n.unsigned_abs()).chain(bs).collect())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_bool_vec_gen_var_5(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_bools,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|bs| bs.iter().any(|&b| b)),\n    )\n}\n\n// -- Vec<PrimitiveInt> --\n\npub fn random_primitive_int_vec_gen<T: PrimitiveInt>(config: &GenConfig) -> It<Vec<T>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn random_primitive_int_vec_gen_var_1<T: PrimitiveInt>(config: &GenConfig) -> It<Vec<T>> {\n    Box::new(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn random_primitive_int_vec_gen_var_2<T: PrimitiveInt>(config: &GenConfig) -> It<Vec<T>> {\n    Box::new(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| !slice_test_zero(xs)),\n    )\n}\n\npub fn random_primitive_int_vec_gen_var_3<T: PrimitiveInt>(config: &GenConfig) -> It<Vec<T>> {\n    Box::new(\n        random_vecs(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| xs.last() != Some(&T::ZERO)),\n    )\n}\n\npub fn random_primitive_int_vec_gen_var_4<T: PrimitiveInt>(config: &GenConfig) -> It<Vec<T>> {\n    Box::new(random_vecs_min_length(\n        EXAMPLE_SEED,\n        1,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn random_primitive_int_vec_gen_var_5<T: PrimitiveInt>(config: &GenConfig) -> It<Vec<T>> {\n    Box::new(random_vecs_min_length(\n        EXAMPLE_SEED,\n        2,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\n// --(Vec<PrimitiveInt>, PrimitiveInt) --\n\npub fn random_primitive_int_vec_primitive_int_pair_gen<T: PrimitiveInt, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\npub fn random_primitive_int_vec_primitive_int_pair_gen_var_1<T: PrimitiveInt, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\npub fn random_primitive_int_vec_primitive_int_pair_gen_var_2<T: PrimitiveInt, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// --(Vec<PrimitiveInt>, PrimitiveUnsigned) --\n\nstruct PrimitiveIntVecUnsignedPairGeneratorVar1<T: PrimitiveInt> {\n    xs: GeometricRandomNaturalValues<usize>,\n    ys: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt> Iterator for PrimitiveIntVecUnsignedPairGeneratorVar1<T> {\n    type Item = (Vec<T>, usize);\n\n    fn next(&mut self) -> Option<(Vec<T>, usize)> {\n        let x_1 = self.xs.next().unwrap();\n        let x_2 = self.xs.next().unwrap();\n        let (len, i) = if x_1 <= x_2 { (x_2, x_1) } else { (x_1, x_2) };\n        Some(((&mut self.ys).take(len).collect(), i))\n    }\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, usize)> {\n    Box::new(PrimitiveIntVecUnsignedPairGeneratorVar1 {\n        xs: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        ys: random_primitive_ints(EXAMPLE_SEED.fork(\"ys\")),\n    })\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed,\n                1,\n                T::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_3<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_inclusive_range(\n                seed,\n                1,\n                T::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_4<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            random_unsigned_inclusive_range(seed.fork(\"base\"), U::TWO, U::saturating_from(T::MAX))\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_5<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_6<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_unsigned_inclusive_range(\n                seed,\n                U::exact_from(3),\n                U::MAX,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_7<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_8<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(xs, y)| *y < U::exact_from(xs.len() << T::LOG_WIDTH)),\n    )\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_9<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_10<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_11<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_12<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_13<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, U::power_of_2(U::WIDTH - 1), U::MAX),\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_14<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_range(seed, U::ONE, U::power_of_2(U::WIDTH - 1)),\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_15<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, U::power_of_2(U::WIDTH - 1), U::MAX),\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_16<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_range(seed, U::ONE, U::power_of_2(U::WIDTH - 1)),\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_17<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_range(seed, U::ONE, U::power_of_2(U::WIDTH - 2)),\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_18<T: PrimitiveInt, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::MAX,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_19<T: PrimitiveInt, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_pair_gen_var_20<T: PrimitiveInt, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\n// --(Vec<PrimitiveInt>, PrimitiveUnsigned, PrimitiveInt) --\n\npub fn random_primitive_int_vec_unsigned_primitive_int_triple_gen_var_1<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n    V: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 4),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// --(Vec<PrimitiveInt>, PrimitiveInt, PrimitiveInt) --\n\npub fn random_primitive_int_vec_primitive_int_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// --(Vec<PrimitiveInt>, PrimitiveInt, RoundingMode) --\n\npub fn random_primitive_int_vec_primitive_int_rounding_mode_triple_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &random_primitive_ints,\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_primitive_int_vec_primitive_int_rounding_mode_triple_gen_var_2<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 4),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// --(Vec<PrimitiveInt>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\nstruct PrimitiveIntVecUnsignedUnsignedTripleGeneratorVar1<T: PrimitiveInt> {\n    is: GeometricRandomNaturalValues<usize>,\n    xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt> Iterator for PrimitiveIntVecUnsignedUnsignedTripleGeneratorVar1<T> {\n    type Item = (Vec<T>, usize, usize);\n\n    fn next(&mut self) -> Option<(Vec<T>, usize, usize)> {\n        let i = self.is.next().unwrap();\n        let j = self.is.next().unwrap();\n        let excess = self.is.next().unwrap();\n        let xs = (&mut self.xs).take(i * j + excess).collect();\n        Some((xs, i, j))\n    }\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_triple_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, usize, usize)> {\n    Box::new(PrimitiveIntVecUnsignedUnsignedTripleGeneratorVar1 {\n        is: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"is\"),\n            config.get_or(\"mean_small_n\", 2),\n            config.get_or(\"mean_small_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, z)| if y <= z { (xs, y, z) } else { (xs, z, y) }),\n    )\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    1,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| !slice_test_zero(xs))\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, z)| if y <= z { (xs, y, z) } else { (xs, z, y) }),\n    )\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_triple_gen_var_4<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_triple_gen_var_5<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &random_primitive_ints,\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_triple_gen_var_6<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_triple_gen_var_7<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &random_primitive_ints,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveInt>) --\n\npub fn random_primitive_int_vec_pair_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(random_vecs(\n        EXAMPLE_SEED,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub struct PrimitiveIntVecPairLenGenerator1<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>> Iterator\n    for PrimitiveIntVecPairLenGenerator1<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        Some((\n            (&mut self.xs).take(i).collect(),\n            (&mut self.xs).take(j).collect(),\n        ))\n    }\n}\n\nfn random_primitive_int_vec_pair_gen_var_1_helper<T: PrimitiveInt>(\n    config: &GenConfig,\n    seed: Seed,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds(\n            seed.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        xs: random_primitive_ints(seed.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_pair_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_primitive_int_vec_pair_gen_var_1_helper(config, EXAMPLE_SEED)\n}\n\npub fn random_primitive_int_vec_pair_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_pair_gen_var_3<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(random_vecs_min_length(\n        EXAMPLE_SEED,\n        1,\n        &random_primitive_ints,\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub fn random_primitive_int_vec_pair_gen_var_4<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        random_pairs_from_single(random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter(|(xs, es)| {\n            !xs.is_empty()\n                && (es.len() > 1 || es.len() == 1 && es[0] > T::ONE)\n                && *es.last().unwrap() != T::ZERO\n        }),\n    )\n}\n\nstruct PrimitiveIntVecPairSameLenGenerator<T: PrimitiveInt, I: Iterator<Item = usize>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = usize>> Iterator\n    for PrimitiveIntVecPairSameLenGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let len = self.lengths.next().unwrap();\n        Some((\n            (&mut self.xs).take(len).collect(),\n            (&mut self.xs).take(len).collect(),\n        ))\n    }\n}\n\npub fn random_primitive_int_vec_pair_gen_var_5<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairSameLenGenerator {\n        phantom: PhantomData,\n        lengths: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_pair_gen_var_6<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(\n        random_vecs(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| xs.last() != Some(&T::ZERO)),\n    ))\n}\n\npub fn random_primitive_int_vec_pair_gen_var_7<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| !slice_test_zero(xs)),\n    ))\n}\n\npub struct PrimitiveIntVecPairLenGenerator2<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>> Iterator\n    for PrimitiveIntVecPairLenGenerator2<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        let mut xs;\n        loop {\n            xs = (&mut self.xs).take(i).collect_vec();\n            if !slice_test_zero(&xs) {\n                break;\n            }\n        }\n        let mut ys;\n        loop {\n            ys = (&mut self.xs).take(j).collect_vec();\n            if !slice_test_zero(&ys) {\n                break;\n            }\n        }\n        Some((xs, ys))\n    }\n}\n\npub fn random_primitive_int_vec_pair_gen_var_8<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\n// var 9 is in malachite-nz.\n\npub fn random_primitive_int_vec_pair_gen_var_10<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(_, ds)| *ds.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn random_primitive_int_vec_pair_gen_var_11<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints::<T>(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(xs, mut ys)| {\n            ys[0] |= T::ONE;\n            (xs, ys)\n        }),\n    )\n}\n\npub fn random_primitive_int_vec_pair_gen_var_12<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(xs, ys)| *xs.last().unwrap() != T::ZERO && *ys.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn random_primitive_int_vec_pair_gen_var_13<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(xs, ys)| *xs.last().unwrap() != T::ZERO && *ys.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn random_primitive_int_vec_pair_gen_var_14<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints::<T>,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter_map(|mut xs| {\n            let last = xs.last_mut().unwrap();\n            *last = last.checked_add(T::ONE)?;\n            Some(xs)\n        }),\n    ))\n}\n\npub fn random_primitive_int_vec_pair_gen_var_15<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            2,\n            usize::MAX,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\n// vars 16 through 25 are in malachite-nz.\n\npub fn random_primitive_int_vec_pair_gen_var_26<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_pair_gen_var_27<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecPairSameLenGenerator {\n            phantom: PhantomData,\n            lengths: geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(xs, ys): &(Vec<T>, Vec<T>)| {\n            (*xs.last().unwrap() != T::ZERO || *ys.last().unwrap() != T::ZERO) && ys[0].odd()\n        }),\n    )\n}\n\n// var 28 is in malachite-nz.\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveInt>, bool) --\n\npub fn random_primitive_int_vec_primitive_int_vec_bool_triple_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, bool)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| PrimitiveIntVecPairSameLenGenerator {\n            phantom: PhantomData,\n            lengths: geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n            xs: random_primitive_ints(seed.fork(\"xs\")),\n        },\n        &random_bools,\n    )))\n}\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveInt>, PrimitiveInt) --\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_1<\n    T: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_int_vec_pair_gen_var_1_helper(config, seed),\n        &random_primitive_ints,\n    )))\n}\n\nfn random_primitive_int_vec_pair_gen_var_2_helper<T: PrimitiveInt>(\n    config: &GenConfig,\n    seed: Seed,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            seed.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        xs: random_primitive_ints(seed.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_2<\n    T: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_int_vec_pair_gen_var_2_helper(config, seed),\n        &random_primitive_ints,\n    )))\n}\n\nstruct PrimitiveIntVecPairLenGenerator3<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>> Iterator\n    for PrimitiveIntVecPairLenGenerator3<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        let xs = (&mut self.xs).take(i).collect();\n        let mut ys;\n        loop {\n            ys = (&mut self.xs).take(j).collect_vec();\n            if !slice_test_zero(&ys) {\n                break;\n            }\n        }\n        Some((xs, ys))\n    }\n}\n\nfn random_primitive_int_vec_pair_gen_var_3_helper<T: PrimitiveInt>(\n    config: &GenConfig,\n    seed: Seed,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator3 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            seed.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        xs: random_primitive_ints(seed.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_3<\n    T: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_int_vec_pair_gen_var_3_helper(config, seed),\n        &random_primitive_ints,\n    )))\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_4<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_5<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_6<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &random_positive_unsigneds,\n    ))\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_7<\n    T: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| PrimitiveIntVecPairSameLenGenerator {\n            phantom: PhantomData,\n            lengths: geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n            xs: random_primitive_ints(seed.fork(\"xs\")),\n        },\n        &random_primitive_ints,\n    )))\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_8<\n    T: PrimitiveInt,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, u64)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_int_vec_pair_gen_var_1_helper(config, seed),\n        &|seed| random_unsigned_range(seed, 1, U::WIDTH),\n    )))\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_primitive_int_triple_gen_var_9<\n    T: PrimitiveInt,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, u64)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints(seed.fork(\"xs\")),\n        },\n        &|seed| random_unsigned_range(seed, 1, U::WIDTH),\n    )))\n}\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveInt>, PrimitiveUnsigned) --\n\npub struct PrimitiveIntVecPairLenAndIndexGenerator<\n    T: PrimitiveInt,\n    I: Iterator<Item = (usize, usize, usize)>,\n> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize, usize)>> Iterator\n    for PrimitiveIntVecPairLenAndIndexGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, usize);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, usize)> {\n        let (i, j, k) = self.lengths.next().unwrap();\n        Some((\n            (&mut self.xs).take(i).collect(),\n            (&mut self.xs).take(j).collect(),\n            k,\n        ))\n    }\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_unsigned_triple_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, usize)> {\n    Box::new(PrimitiveIntVecPairLenAndIndexGenerator {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(y)?;\n            let o = o.checked_add(x)?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_primitive_int_vec_unsigned_triple_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, usize)> {\n    Box::new(PrimitiveIntVecPairLenAndIndexGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, i)| {\n            let x = x.checked_add(i)?;\n            Some((x, x, i))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveInt>, Vec<PrimitiveInt>) --\n\npub struct PrimitiveIntVecTripleXYYLenGenerator<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>>\n{\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize)>> Iterator\n    for PrimitiveIntVecTripleXYYLenGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        Some((\n            (&mut self.xs).take(i).collect(),\n            (&mut self.xs).take(j).collect(),\n            (&mut self.xs).take(j).collect(),\n        ))\n    }\n}\n\npub fn random_primitive_int_vec_triple_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(y.arithmetic_checked_shl(1)?)?;\n            Some((x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub struct PrimitiveIntVecTripleLenGenerator1<\n    T: PrimitiveInt,\n    I: Iterator<Item = (usize, usize, usize)>,\n> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize, usize)>> Iterator\n    for PrimitiveIntVecTripleLenGenerator1<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (i, j, k) = self.lengths.next().unwrap();\n        Some((\n            (&mut self.xs).take(i).collect(),\n            (&mut self.xs).take(j).collect(),\n            (&mut self.xs).take(k).collect(),\n        ))\n    }\n}\n\npub struct PrimitiveIntVecQuadrupleLenGenerator1<\n    T: PrimitiveInt,\n    I: Iterator<Item = (usize, usize, usize, usize)>,\n> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize, usize, usize)>> Iterator\n    for PrimitiveIntVecQuadrupleLenGenerator1<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<Self::Item> {\n        let (i, j, k, l) = self.lengths.next().unwrap();\n        Some((\n            (&mut self.xs).take(i).collect(),\n            (&mut self.xs).take(j).collect(),\n            (&mut self.xs).take(k).collect(),\n            (&mut self.xs).take(l).collect(),\n        ))\n    }\n}\n\npub fn random_primitive_int_vec_triple_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(y)?;\n            let o = x.checked_add(y)?.checked_add(o)?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_3<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(1)?;\n            let o = x.checked_add(y)?.checked_add(o)?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\n// vars 4 through 23 are in malachite-nz\n\npub fn random_primitive_int_vec_triple_gen_var_24<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(y)?;\n            Some((x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_25<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(2)?;\n            let x = x.checked_add(y.arithmetic_checked_shl(1)?)?;\n            Some((x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_26<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(2)?;\n            let x = x.checked_add(y)?;\n            Some((x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\nstruct PrimitiveIntVecTripleXXXLenGenerator<T: PrimitiveInt, I: Iterator<Item = usize>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = usize>> Iterator\n    for PrimitiveIntVecTripleXXXLenGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let i = self.lengths.next().unwrap();\n        Some((\n            (&mut self.xs).take(i).collect(),\n            (&mut self.xs).take(i).collect(),\n            (&mut self.xs).take(i).collect(),\n        ))\n    }\n}\n\npub fn random_primitive_int_vec_triple_gen_var_27<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXXXLenGenerator {\n        phantom: PhantomData,\n        lengths: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            2,\n            usize::MAX,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_28<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXXXLenGenerator {\n        phantom: PhantomData,\n        lengths: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_29<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_from_single(\n        random_vecs(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| xs.last() != Some(&T::ZERO)),\n    ))\n}\n\npub fn random_primitive_int_vec_triple_gen_var_30<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let x = x.checked_add(y)?;\n            Some((x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_31<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let o = max(x, y).checked_add(o)?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\nstruct PrimitiveIntVecTripleLenGenerator2<\n    T: PrimitiveInt,\n    I: Iterator<Item = (usize, usize, usize)>,\n> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt, I: Iterator<Item = (usize, usize, usize)>> Iterator\n    for PrimitiveIntVecTripleLenGenerator2<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (i, j, k) = self.lengths.next().unwrap();\n        let out = (&mut self.xs).take(i).collect();\n        let mut xs;\n        loop {\n            xs = (&mut self.xs).take(j).collect_vec();\n            if !slice_test_zero(&xs) {\n                break;\n            }\n        }\n        let mut ys;\n        loop {\n            ys = (&mut self.xs).take(k).collect_vec();\n            if !slice_test_zero(&ys) {\n                break;\n            }\n        }\n        Some((out, xs, ys))\n    }\n}\n\npub fn random_primitive_int_vec_triple_gen_var_32<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(1)?;\n            let y = y.checked_add(1)?;\n            let o = o.checked_add(x)?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_33<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(1)?;\n            let y = y.checked_add(1)?;\n            let o = o.checked_add(max(x, y))?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_34<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(1)?;\n            let y = y.checked_add(1)?;\n            let o = o.checked_add(min(x, y))?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_35<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_from_single(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            2,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    ))\n}\n\n// vars 36 through 37 are in malachite-nz.\n\npub fn random_primitive_int_vec_triple_gen_var_38<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_from_single(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    ))\n}\n\npub fn random_primitive_int_vec_triple_gen_var_39<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(y)?;\n            let o = o.checked_add(x)?;\n            Some((o, x, y))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_40<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n    ))\n}\n\npub fn random_primitive_int_vec_triple_gen_var_41<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y, z)| {\n                let y = y.checked_add(1)?;\n                let x = x.checked_add(y)?;\n                let z = z.checked_add(y.arithmetic_checked_shl(1)?)?;\n                Some((x, y, z))\n            }),\n            xs: random_primitive_ints::<T>(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(x, mut y, z)| {\n            y.last_mut().unwrap().set_bit(T::WIDTH - 1);\n            (x, y, z)\n        }),\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_42<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y, z)| {\n                let y = y.checked_add(5)?;\n                let x = x.checked_add(y)?;\n                let z = z.checked_add(y.arithmetic_checked_shl(1)?)?;\n                Some((x, y, z))\n            }),\n            xs: random_primitive_ints::<T>(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(x, mut y, z)| {\n            y.last_mut().unwrap().set_bit(T::WIDTH - 1);\n            (x, y, z)\n        }),\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_43<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y, z)| {\n                let q = x.checked_add(3)?;\n                let n = y.checked_add(9)?;\n                let d = z.checked_add(6)?;\n                if n < d {\n                    return None;\n                }\n                let q_alt = n - d + 1;\n                if (q_alt << 1) > n || q_alt > d {\n                    return None;\n                }\n                let n_alt = q_alt << 1;\n                let d_alt = q_alt;\n                if q >= q_alt && d_alt >= 6 && n_alt >= d_alt + 3 && d_alt >= q_alt {\n                    Some((q, n, d))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints::<T>(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(x, y, mut z)| {\n            z.last_mut().unwrap().set_bit(T::WIDTH - 1);\n            (x, y, z)\n        }),\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_44<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(r_len, n_len, d_len)| {\n                let d_len = d_len.checked_add(2)?;\n                let r_len = r_len.checked_add(d_len)?;\n                let n_len = n_len.checked_add(d_len)?;\n                Some((r_len, n_len, d_len))\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter_map(|(r, n, mut d): (Vec<T>, Vec<T>, Vec<T>)| {\n            let last_d = d.last_mut().unwrap();\n            *last_d = last_d.checked_add(T::ONE)?;\n            Some((r, n, d))\n        }),\n    )\n}\n\n// var 45 is in malachite-nz.\n\npub fn random_primitive_int_vec_triple_gen_var_46<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(xs_len, ys_len, zs_len)| {\n                let ys_len = ys_len.checked_add(2)?;\n                let zs_len = zs_len.checked_add(2)?;\n                let xs_len = xs_len.checked_add(ys_len + zs_len - 1)?;\n                Some((xs_len, ys_len, zs_len))\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter_map(|(mut xs, mut ys, mut zs): (Vec<T>, Vec<T>, Vec<T>)| {\n            let last_x = xs.last_mut().unwrap();\n            *last_x = last_x.checked_add(T::ONE)?;\n            let last_y = ys.last_mut().unwrap();\n            *last_y = last_y.checked_add(T::ONE)?;\n            let last_z = zs.last_mut().unwrap();\n            *last_z = last_z.checked_add(T::ONE)?;\n            Some((xs, ys, zs))\n        }),\n    )\n}\n\n// var 47 is in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\nstruct UnsignedVecUnsignedPairGeneratorVar1<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    log_bases: GeometricRandomNaturalValues<u64>,\n    ranges: VariableRangeGenerator,\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for UnsignedVecUnsignedPairGeneratorVar1<T, U>\n{\n    type Item = (Vec<U>, u64);\n\n    fn next(&mut self) -> Option<(Vec<U>, u64)> {\n        let log_base = self.log_bases.next().unwrap();\n        let max_count = usize::exact_from(T::WIDTH.div_round(log_base, Ceiling).0);\n        loop {\n            let digit_count = self.ranges.next_in_inclusive_range(0, max_count);\n            let mut digits = Vec::with_capacity(digit_count);\n            for _ in 0..digit_count {\n                digits.push(self.ranges.next_bit_chunk(log_base));\n            }\n            if digits_valid::<T, U>(log_base, &digits) {\n                return Some((digits, log_base));\n            }\n        }\n    }\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<U>, u64)> {\n    Box::new(UnsignedVecUnsignedPairGeneratorVar1::<T, U> {\n        log_bases: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            1,\n            U::WIDTH,\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        phantom: PhantomData,\n    })\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<U>, u64)> {\n    Box::new(\n        random_unsigned_vec_unsigned_pair_gen_var_1::<T, U>(config)\n            .map(|(xs, y)| (xs.into_iter().rev().collect(), y)),\n    )\n}\n\nstruct BasecaseDigitsRandomGenerator<\n    T: ExactFrom<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n> {\n    bases: RandomUnsignedInclusiveRange<U>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    digits: VariableRangeGenerator,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: ExactFrom<U> + PrimitiveUnsigned, U: PrimitiveUnsigned + SaturatingFrom<T>> Iterator\n    for BasecaseDigitsRandomGenerator<T, U>\n{\n    type Item = (Vec<T>, U);\n\n    fn next(&mut self) -> Option<(Vec<T>, U)> {\n        let base = self.bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut digits = Vec::with_capacity(digit_count);\n        let t_base = T::exact_from(base);\n        for _ in 0..digit_count {\n            digits.push(self.digits.next_less_than(t_base));\n        }\n        Some((digits, base))\n    }\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_3<\n    T: ExactFrom<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(BasecaseDigitsRandomGenerator {\n        bases: random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"bases\"),\n            U::TWO,\n            U::saturating_from(T::MAX),\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        digits: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        phantom: PhantomData,\n    })\n}\n\nstruct DigitsDesc<T: PrimitiveUnsigned, U: Digits<T> + PrimitiveUnsigned> {\n    ranges: VariableRangeGenerator,\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned + SaturatingFrom<U>, U: Digits<T> + PrimitiveUnsigned> Iterator\n    for DigitsDesc<T, U>\n{\n    type Item = (Vec<T>, T);\n\n    fn next(&mut self) -> Option<(Vec<T>, T)> {\n        let base = self\n            .ranges\n            .next_in_inclusive_range(T::TWO, T::saturating_from(U::MAX));\n        let max_digits = U::MAX.to_digits_desc(&base);\n        let max_digits_len = max_digits.len();\n        loop {\n            let digit_count = self.ranges.next_in_inclusive_range(0, max_digits_len);\n            let mut ds = Vec::with_capacity(digit_count);\n            for _ in 0..digit_count {\n                ds.push(self.ranges.next_less_than(base));\n            }\n            if digit_count < max_digits_len || ds <= max_digits {\n                return Some((ds, base));\n            }\n        }\n    }\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_4<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    _config: &GenConfig,\n) -> It<(Vec<T>, T)> {\n    Box::new(DigitsDesc::<T, U> {\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        phantom: PhantomData,\n    })\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_5<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: Digits<T> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T)> {\n    Box::new(\n        random_unsigned_vec_unsigned_pair_gen_var_4::<T, U>(config).map(|(mut xs, base)| {\n            xs.reverse();\n            (xs, base)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::MAX),\n    ))\n}\n\nstruct PowerOf2DigitsGenerator<T: PrimitiveUnsigned> {\n    log_bases: GeometricRandomNaturalValues<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    ranges: VariableRangeGenerator,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for PowerOf2DigitsGenerator<T> {\n    type Item = (Vec<T>, u64);\n\n    fn next(&mut self) -> Option<(Vec<T>, u64)> {\n        let log_base = self.log_bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut digits = Vec::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            digits.push(self.ranges.next_bit_chunk(log_base));\n        }\n        Some((digits, log_base))\n    }\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(PowerOf2DigitsGenerator::<T> {\n        log_bases: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            1,\n            T::WIDTH,\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_count\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        phantom: PhantomData,\n    })\n}\n\n// vars 8 through 11 are in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// vars 1 through 2 are in malachite-nz.\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                1,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            random_unsigned_inclusive_range(seed, T::ZERO, T::low_mask(T::WIDTH - 1))\n                .map(|u| (u << 1) | T::ONE)\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// vars 4 through 6 are in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\nstruct UnsignedVecSqrtRemGenerator<T: PrimitiveUnsigned, I: Iterator<Item = (usize, usize)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n    hi_n_bits: RandomUnsignedRange<T>,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (usize, usize)>> Iterator\n    for UnsignedVecSqrtRemGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (out_len, len) = self.lengths.next().unwrap();\n        let out = (&mut self.xs).take(out_len).collect();\n        let mut ns: Vec<T> = (&mut self.xs).take(len).collect();\n        let n_hi = &mut ns[(usize::exact_from(out_len) << 1) - 1];\n        n_hi.mod_power_of_2_assign(T::WIDTH - 2);\n        *n_hi |= self.hi_n_bits.next().unwrap() << (T::WIDTH - 2);\n        Some((out, ns))\n    }\n}\n\npub fn random_unsigned_vec_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecSqrtRemGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let out_len = x.checked_add(2)?;\n            let len: usize = out_len.arithmetic_checked_shl(1)?;\n            let len = len.checked_add(y)?;\n            Some((out_len, len))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        hi_n_bits: random_unsigned_range(EXAMPLE_SEED.fork(\"hi_n_bits\"), T::ONE, T::exact_from(4)),\n    })\n}\n\nstruct UnsignedVecSqrtGenerator<T: PrimitiveUnsigned, I: Iterator<Item = (usize, usize)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (usize, usize)>> Iterator\n    for UnsignedVecSqrtGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (out_len, len) = self.lengths.next().unwrap();\n        let out = (&mut self.xs).take(out_len).collect();\n        let mut ns: Vec<T> = (&mut self.xs).take(len).collect();\n        let hi_n = ns.last_mut().unwrap();\n        if *hi_n == T::ZERO {\n            *hi_n = T::ONE;\n        }\n        Some((out, ns))\n    }\n}\n\npub fn random_unsigned_vec_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecSqrtGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let in_len = x.checked_add(1)?;\n            let mut out_len: usize = in_len.shr_round(1, Ceiling).0;\n            out_len = out_len.checked_add(y)?;\n            Some((out_len, in_len))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\n// vars 3 through 4 are in malachite-nz.\n\npub fn random_unsigned_vec_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| random_unsigned_inclusive_range(seed, T::power_of_2(T::WIDTH - 1), T::MAX),\n            &random_primitive_ints,\n        )\n        .map(|(n, d_1, d_0)| (n, vec![d_0, d_1])),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                seed.fork(\"lengths\"),\n                2,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints(seed.fork(\"xs\")),\n        },\n        &random_positive_unsigneds,\n    )))\n}\n\n// var 2 is in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// vars 1 through 8 are in malachite-nz.\n\nstruct UnsignedVecSqrtRemGenerator3<T: PrimitiveUnsigned, I: Iterator<Item = (usize, usize, usize)>>\n{\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (usize, usize, usize)>> Iterator\n    for UnsignedVecSqrtRemGenerator3<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (out_len, rs_len, len) = self.lengths.next().unwrap();\n        let out = (&mut self.xs).take(out_len).collect();\n        let rs = (&mut self.xs).take(rs_len).collect();\n        let mut ns: Vec<T> = (&mut self.xs).take(len).collect();\n        let hi_n = ns.last_mut().unwrap();\n        if *hi_n == T::ZERO {\n            *hi_n = T::ONE;\n        }\n        Some((out, rs, ns))\n    }\n}\n\npub fn random_unsigned_vec_triple_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecSqrtRemGenerator3 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y, z)| {\n            let in_len = x.checked_add(1)?;\n            let mut out_len: usize = in_len.shr_round(1, Ceiling).0;\n            out_len = out_len.checked_add(y)?;\n            let rem_len = in_len.checked_add(z)?;\n            Some((out_len, rem_len, in_len))\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_unsigned_vec_triple_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_positive_unsigneds::<usize>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter(|&(x, y)| y >= 2 && x >= y - 2),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_unsigned_inclusive_range(seed_2, T::power_of_2(T::WIDTH - 1), T::MAX)\n                    },\n                    &random_primitive_ints,\n                )\n            },\n        )\n        .map(|((q, n), (d_1, d_0))| (q, n, vec![d_0, d_1])),\n    )\n}\n\n// var 11 is in malachite-nz.\n\n// -- large types --\n\npub fn random_large_type_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T, T)> {\n    reshape_2_2_to_4(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_int_vec_pair_gen_var_1_helper(config, seed),\n        &|seed| random_pairs_from_single(random_primitive_ints(seed)),\n    )))\n}\n\nstruct UnsignedVecSqrtRemGenerator2<T: PrimitiveUnsigned> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: GeometricRandomNaturalValues<usize>,\n    pub xs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedVecSqrtRemGenerator2<T> {\n    type Item = (Vec<T>, Vec<T>, u64, bool);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, u64, bool)> {\n        let len = self.lengths.next().unwrap();\n        let n = len.shr_round(1, Ceiling).0;\n        let out = (&mut self.xs).take(n).collect();\n        let mut ns: Vec<T> = (&mut self.xs).take(len).collect();\n        let last = ns.last_mut().unwrap();\n        if *last == T::ZERO {\n            *last = T::ONE;\n        }\n        let shift = last.leading_zeros() >> 1;\n        Some((out, ns, shift, len.odd()))\n    }\n}\n\npub fn random_large_type_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, u64, bool)> {\n    Box::new(UnsignedVecSqrtRemGenerator2 {\n        phantom: PhantomData,\n        lengths: geometric_random_unsigned_range::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            9,\n            usize::MAX,\n            config.get_or(\"mean_length_n\", 12),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_large_type_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U, Vec<T>)> {\n    Box::new(\n        random_quadruples_xyyx::<_, _, U, _>(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\npub fn random_large_type_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U, Vec<T>)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints::<T>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| !slice_test_zero(xs))\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints::<T>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\n// vars 5 through 8 are in malachite-nz\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_9<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>, bool)> {\n    reshape_3_1_to_4(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| PrimitiveIntVecTripleXYYLenGenerator {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y)| {\n                let x = x.checked_add(y)?;\n                Some((x, y))\n            }),\n            xs: random_primitive_ints(seed.fork(\"xs\")),\n        },\n        &random_bools,\n    )))\n}\n\n// vars 10 through 21 are in malachite-nz.\n\npub fn random_large_type_gen_var_22<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, usize, T, T)> {\n    Box::new(\n        random_quadruples_xyzz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rational_sequences(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_unsigned_n\", 32),\n                    config.get_or(\"mean_small_unsigned_d\", 1),\n                )\n            },\n            &random_primitive_ints,\n        )\n        .filter(|&(ref xs, index, _, _)| {\n            if let Some(len) = xs.len() {\n                index < len\n            } else {\n                true\n            }\n        }),\n    )\n}\n\n// vars 23 through 26 are in malachite-nz.\n\npub fn random_large_type_gen_var_27<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(bool, Vec<T>, bool, Vec<T>)> {\n    Box::new(random_quadruples_xyxy(\n        EXAMPLE_SEED,\n        &random_bools,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| xs.last() != Some(&T::ZERO))\n        },\n    ))\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/generators/special_random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::bools::random::random_bools;\nuse crate::chars::constants::NUMBER_OF_CHARS;\nuse crate::chars::random::{\n    graphic_weighted_random_ascii_chars, graphic_weighted_random_char_inclusive_range,\n    graphic_weighted_random_char_range, graphic_weighted_random_chars,\n};\nuse crate::iterators::{NonzeroValues, with_special_value};\nuse crate::num::arithmetic::traits::{\n    ArithmeticCheckedShl, DivRound, Parity, PowerOf2, ShrRound, UnsignedAbs,\n};\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::string::options::random::{\n    random_from_sci_string_options, random_to_sci_options,\n};\nuse crate::num::conversion::string::options::{FromSciStringOptions, ToSciOptions};\nuse crate::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, HasHalf, JoinHalves, RoundingFrom, SaturatingFrom, SplitInHalf,\n    WrappingFrom, WrappingInto,\n};\nuse crate::num::factorization::traits::IsPrime;\nuse crate::num::float::NiceFloat;\nuse crate::num::logic::traits::{BitAccess, BitBlockAccess, LeadingZeros};\nuse crate::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomSignedRange, GeometricRandomSigneds,\n    geometric_random_natural_signeds, geometric_random_nonzero_signeds,\n    geometric_random_positive_unsigneds, geometric_random_signed_inclusive_range,\n    geometric_random_signed_range, geometric_random_signeds,\n    geometric_random_unsigned_inclusive_range, geometric_random_unsigned_range,\n    geometric_random_unsigneds,\n};\nuse crate::num::random::striped::{\n    StripedBitSource, StripedRandomSigneds, StripedRandomUnsignedBitChunks,\n    StripedRandomUnsignedInclusiveRange, get_striped_bool_vec, get_striped_unsigned_vec,\n    striped_random_bool_vecs, striped_random_bool_vecs_length_inclusive_range,\n    striped_random_bool_vecs_min_length, striped_random_fixed_length_bool_vecs,\n    striped_random_natural_signeds, striped_random_negative_signeds,\n    striped_random_nonzero_signeds, striped_random_positive_signeds,\n    striped_random_positive_unsigneds, striped_random_signed_inclusive_range,\n    striped_random_signed_range, striped_random_signeds, striped_random_unsigned_bit_chunks,\n    striped_random_unsigned_inclusive_range, striped_random_unsigned_range,\n    striped_random_unsigned_vecs, striped_random_unsigned_vecs_min_length,\n    striped_random_unsigneds,\n};\nuse crate::num::random::{\n    RandomPrimitiveFloatInclusiveRange, VariableRangeGenerator, random_finite_primitive_floats,\n    random_nonzero_finite_primitive_floats, random_positive_finite_primitive_floats,\n    random_primitive_float_inclusive_range, random_primitive_float_range, random_primitive_floats,\n    random_unsigneds_less_than,\n};\nuse crate::random::{EXAMPLE_SEED, Seed};\nuse crate::rational_sequences::RationalSequence;\nuse crate::rational_sequences::random::random_rational_sequences;\nuse crate::rounding_modes::RoundingMode::{self, *};\nuse crate::rounding_modes::random::{RandomRoundingModes, random_rounding_modes};\nuse crate::slices::slice_test_zero;\nuse crate::strings::random::random_strings_using_chars;\nuse crate::test_util::extra_variadic::{\n    Union3, random_duodecuples_from_single, random_octuples_from_single,\n    random_quadruples_from_single, random_quadruples_xxxy, random_quadruples_xxyx,\n    random_quadruples_xyxy, random_quadruples_xyyx, random_quadruples_xyyz, random_quadruples_xyzz,\n    random_sextuples_from_single, random_triples, random_triples_from_single, random_triples_xxy,\n    random_triples_xyx, random_triples_xyy, random_union3s,\n};\nuse crate::test_util::generators::common::{\n    GenConfig, It, reshape_1_2_to_3, reshape_2_1_to_3, reshape_2_2_to_4, reshape_3_1_to_4,\n};\nuse crate::test_util::generators::{\n    digits_valid, float_rounding_mode_filter_var_1, get_two_highest, large_exponent,\n    reduce_to_fit_add_mul_signed, reduce_to_fit_add_mul_unsigned, reduce_to_fit_sub_mul_signed,\n    reduce_to_fit_sub_mul_unsigned, round_to_multiple_of_power_of_2_filter_map,\n    round_to_multiple_signed_filter_map, round_to_multiple_unsigned_filter_map,\n    shift_integer_mantissa_and_exponent, signed_assign_bits_valid, smallest_invalid_value,\n    unsigned_assign_bits_valid,\n};\nuse crate::test_util::num::arithmetic::mod_mul::limbs_invert_limb_naive;\nuse crate::tuples::random::{random_ordered_unique_pairs, random_pairs, random_pairs_from_single};\nuse crate::unions::Union2;\nuse crate::unions::random::random_union2s;\nuse itertools::Itertools;\nuse itertools::repeat_n;\nuse std::cmp::{Ordering::*, max, min};\nuse std::collections::HashMap;\nuse std::marker::PhantomData;\n\n// -- char --\n\npub fn special_random_char_gen(config: &GenConfig) -> It<char> {\n    Box::new(graphic_weighted_random_chars(\n        EXAMPLE_SEED,\n        config.get_or(\"graphic_char_prob_n\", 50),\n        config.get_or(\"graphic_char_prob_d\", 51),\n    ))\n}\n\n#[allow(unstable_name_collisions)]\npub fn special_random_char_gen_var_1(config: &GenConfig) -> It<char> {\n    Box::new(graphic_weighted_random_char_range(\n        EXAMPLE_SEED,\n        char::MIN,\n        char::MAX,\n        config.get_or(\"graphic_char_prob_n\", 50),\n        config.get_or(\"graphic_char_prob_d\", 51),\n    ))\n}\n\n#[allow(unstable_name_collisions)]\npub fn special_random_char_gen_var_2(config: &GenConfig) -> It<char> {\n    Box::new(graphic_weighted_random_char_inclusive_range(\n        EXAMPLE_SEED,\n        '\\u{1}',\n        char::MAX,\n        config.get_or(\"graphic_char_prob_n\", 50),\n        config.get_or(\"graphic_char_prob_d\", 51),\n    ))\n}\n\n// -- (char, char) --\n\npub fn special_random_char_pair_gen(config: &GenConfig) -> It<(char, char)> {\n    Box::new(random_pairs_from_single(graphic_weighted_random_chars(\n        EXAMPLE_SEED,\n        config.get_or(\"graphic_char_prob_n\", 50),\n        config.get_or(\"graphic_char_prob_d\", 51),\n    )))\n}\n\n// -- (FromSciStringOptions, PrimitiveUnsigned> --\n\npub fn special_random_from_sci_string_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(FromSciStringOptions, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_from_sci_string_options,\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::from(36u8),\n                config.get_or(\"mean_stripe_n\", T::WIDTH),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- PrimitiveFloat --\n\npub fn special_random_primitive_float_gen<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_floats(EXAMPLE_SEED))\n}\n\npub fn special_random_primitive_float_gen_var_1<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_float_range(\n        EXAMPLE_SEED,\n        T::NEGATIVE_ONE / T::TWO,\n        T::INFINITY,\n    ))\n}\n\nstruct SpecialRandomPositiveNaturalFloats<T: PrimitiveFloat> {\n    exponents: GeometricRandomSignedRange<i64>,\n    mantissas: StripedRandomUnsignedBitChunks<u64>,\n    phantom: PhantomData<T>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomPositiveNaturalFloats<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        let exponent = self.exponents.next().unwrap();\n        let mut mantissa = self.mantissas.next().unwrap();\n        if exponent != 0 {\n            mantissa.set_bit(T::MANTISSA_WIDTH);\n        } else if mantissa == 0 {\n            mantissa = 1;\n        }\n        Some(T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap())\n    }\n}\n\nfn special_random_positive_natural_floats<T: PrimitiveFloat>(\n    seed: Seed,\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> SpecialRandomPositiveNaturalFloats<T> {\n    SpecialRandomPositiveNaturalFloats {\n        exponents: geometric_random_signed_range(\n            seed.fork(\"exponents\"),\n            0,\n            i64::power_of_2(T::EXPONENT_WIDTH - 1) - i64::wrapping_from(T::MANTISSA_WIDTH) - 1,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n        ),\n        mantissas: striped_random_unsigned_bit_chunks(\n            seed.fork(\"mantissas\"),\n            T::MANTISSA_WIDTH + 1,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        phantom: PhantomData,\n    }\n}\n\npub fn special_random_primitive_float_gen_var_2<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(with_special_value(EXAMPLE_SEED, T::ZERO, 1, 100, &|seed| {\n        special_random_positive_natural_floats(\n            seed,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"mean_stripe_n\", 16),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n    }))\n}\n\npub fn special_random_primitive_float_gen_var_3<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_positive_finite_primitive_floats::<T>(EXAMPLE_SEED).filter(|f| !f.is_integer()))\n}\n\npub fn special_random_primitive_float_gen_var_4<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(\n        random_primitive_float_inclusive_range::<T>(\n            EXAMPLE_SEED,\n            T::ONE,\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        )\n        .map(|f| f.floor() - T::ONE / T::TWO),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_5<T: PrimitiveFloat>(config: &GenConfig) -> It<T> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                with_special_value(seed, T::ZERO, 1, 100, &|seed_2| {\n                    special_random_positive_natural_floats(\n                        seed_2,\n                        config.get_or(\"exponent_mean_n\", 8),\n                        config.get_or(\"exponent_mean_d\", 1),\n                        config.get_or(\"mean_stripe_n\", 16),\n                        config.get_or(\"mean_stripe_d\", 1),\n                    )\n                })\n            },\n            &random_bools,\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_6<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| random_positive_finite_primitive_floats::<T>(seed).filter(|f| !f.is_integer()),\n            &random_bools,\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_7<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_primitive_float_inclusive_range::<T>(\n                    seed,\n                    T::ONE,\n                    T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                        .unwrap(),\n                )\n                .map(|f| f.floor() - T::ONE / T::TWO)\n            },\n            &random_bools,\n        )\n        .map(|(f, b)| if b { f } else { -f }),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_8<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_finite_primitive_floats(EXAMPLE_SEED))\n}\n\npub fn special_random_primitive_float_gen_var_9<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(\n        random_primitive_floats::<T>(EXAMPLE_SEED).filter(|&f| !f.is_nan() && f != T::INFINITY),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_10<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(\n        random_primitive_floats::<T>(EXAMPLE_SEED)\n            .filter(|&f| !f.is_nan() && f != T::NEGATIVE_INFINITY),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_11<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_floats::<T>(EXAMPLE_SEED).filter(|&f| !f.is_nan()))\n}\n\npub fn special_random_primitive_float_gen_var_12<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_nonzero_finite_primitive_floats(EXAMPLE_SEED))\n}\n\npub fn special_random_primitive_float_gen_var_13<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        striped_random_unsigneds::<U>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(|n| T::rounding_from(n, Down).0),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_14<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        striped_random_signeds::<U>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(|n| T::rounding_from(n, Down).0),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_15<\n    T: PrimitiveFloat,\n    U: ConvertibleFrom<T> + PrimitiveInt,\n>(\n    _config: &GenConfig,\n) -> It<T> {\n    Box::new(random_primitive_floats::<T>(EXAMPLE_SEED).filter(|&f| !U::convertible_from(f)))\n}\n\npub fn special_random_primitive_float_gen_var_16<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    _config: &GenConfig,\n) -> It<T> {\n    let limit = min(\n        NiceFloat(T::rounding_from(U::MAX, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    Box::new(\n        random_primitive_float_inclusive_range::<T>(EXAMPLE_SEED, T::ONE, limit)\n            .map(|f| f.floor() - T::ONE / T::TWO),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_17<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned,\n>(\n    _config: &GenConfig,\n) -> It<T> {\n    let min_limit = min(\n        NiceFloat(-T::rounding_from(U::MIN, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    let max_limit = min(\n        NiceFloat(T::rounding_from(U::MAX, Down).0),\n        NiceFloat(\n            T::from_integer_mantissa_and_exponent(1, i64::wrapping_from(T::MANTISSA_WIDTH))\n                .unwrap(),\n        ),\n    )\n    .0;\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_primitive_float_inclusive_range::<T>(seed, T::ONE, max_limit)\n                    .map(|f| f.floor() - T::ONE / T::TWO)\n            },\n            &|seed| {\n                random_primitive_float_inclusive_range::<T>(seed, T::ONE, min_limit)\n                    .map(|f| T::ONE / T::TWO - f.floor())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_primitive_float_gen_var_18<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_positive_finite_primitive_floats::<T>(EXAMPLE_SEED))\n}\n\npub fn special_random_primitive_float_gen_var_19<T: PrimitiveFloat>(_config: &GenConfig) -> It<T> {\n    Box::new(random_primitive_float_inclusive_range(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::power_of_2(T::MAX_EXPONENT),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat) --\n\npub fn special_random_primitive_float_pair_gen<T: PrimitiveFloat>(\n    _config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(random_primitive_floats(\n        EXAMPLE_SEED,\n    )))\n}\n\npub fn special_random_primitive_float_pair_gen_var_1<T: PrimitiveFloat>(\n    _config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(\n        random_primitive_floats::<T>(EXAMPLE_SEED).filter(|&f| !f.is_nan()),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveFloat, PrimitiveFloat) --\n\npub fn special_random_primitive_float_triple_gen<T: PrimitiveFloat>(\n    _config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_from_single(random_primitive_floats(\n        EXAMPLE_SEED,\n    )))\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned) --\n\npub fn special_random_primitive_float_signed_pair_gen<T: PrimitiveFloat, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_floats,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"small_signed_mean_n\", 32),\n                config.get_or(\"small_signed_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_primitive_float_signed_pair_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_finite_primitive_floats,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"small_signed_mean_n\", 32),\n                config.get_or(\"small_signed_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_primitive_float_signed_pair_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, i64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| random_primitive_float_range(seed, T::ONE, T::TWO),\n            &|seed| {\n                geometric_random_signed_inclusive_range(\n                    seed,\n                    T::MIN_EXPONENT,\n                    T::MAX_EXPONENT,\n                    config.get_or(\"small_signed_mean_n\", 32),\n                    config.get_or(\"small_signed_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|&(m, e)| m.precision() <= T::max_precision_for_sci_exponent(e)),\n    )\n}\n\npub fn special_random_primitive_float_signed_pair_gen_var_3<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, i64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_float_range(seed, T::ONE, T::TWO),\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"small_signed_mean_n\", 32),\n                config.get_or(\"small_signed_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_primitive_float_signed_pair_gen_var_4<\n    T: PrimitiveFloat,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_floats,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"small_signed_mean_n\", 32),\n                config.get_or(\"small_signed_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_primitive_float_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_floats,\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"small_signed_mean_n\", 32),\n                config.get_or(\"small_signed_mean_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned) --\n\npub fn special_random_primitive_float_unsigned_pair_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_finite_primitive_floats,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_primitive_float_unsigned_pair_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_float_range(seed, T::ONE, T::TWO),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_primitive_float_unsigned_pair_gen_var_3<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_positive_finite_primitive_floats,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_primitive_float_unsigned_pair_gen_var_4<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &random_primitive_floats,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_1<\n    T: PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_positive_finite_primitive_floats,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_signed_mean_n\", 32),\n                config.get_or(\"small_signed_mean_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| random_primitive_float_range(seed, T::ONE, T::TWO),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_signed_mean_n\", 32),\n                config.get_or(\"small_signed_mean_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// var 3 is in malachite-float.\n\n// -- (PrimitiveFloat, RoundingMode) --\n\npub fn special_random_primitive_float_rounding_mode_pair_gen_var_1<T: PrimitiveFloat>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_finite_primitive_floats,\n            &random_rounding_modes,\n        )\n        .filter(float_rounding_mode_filter_var_1),\n    )\n}\n\npub fn special_random_primitive_float_rounding_mode_pair_gen_var_2<T: PrimitiveFloat>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &random_primitive_floats::<T>,\n            &random_rounding_modes,\n        )\n        .filter(|&(f, rm)| rm != Exact || f.is_integer()),\n    )\n}\n\npub fn special_random_primitive_float_rounding_mode_pair_gen_var_3<\n    T: PrimitiveFloat + RoundingFrom<U>,\n    U: ConvertibleFrom<T> + PrimitiveInt,\n>(\n    _config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    let f_min = T::rounding_from(U::MIN, Down).0;\n    let f_max = T::rounding_from(U::MAX, Down).0;\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| random_primitive_floats::<T>(seed).filter(|f| !f.is_nan()),\n            &random_rounding_modes,\n        )\n        .filter(move |&(f, rm)| match rm {\n            Up => f >= f_min && f <= f_max,\n            Ceiling => f <= f_max,\n            Floor => f >= f_min,\n            Down | Nearest => true,\n            Exact => U::convertible_from(f),\n        }),\n    )\n}\n\n// -- PrimitiveInt --\n\npub fn special_random_primitive_int_gen_var_1<\n    T: PrimitiveInt + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    _config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        random_primitive_float_range(\n            EXAMPLE_SEED,\n            U::rounding_from(T::MIN, Down).0,\n            U::rounding_from(T::MAX, Down).0,\n        )\n        .map(|f| T::rounding_from(f, Down).0),\n    )\n}\n\n// -- PrimitiveSigned --\n\npub fn special_random_signed_gen<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_signed_gen_var_1<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(special_random_signed_gen(config).filter(|&x| x != T::MIN))\n}\n\npub fn special_random_signed_gen_var_2<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_natural_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_signed_gen_var_3<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(\n        striped_random_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .filter(|&x| x != T::ZERO && x != T::NEGATIVE_ONE),\n    )\n}\n\npub fn special_random_signed_gen_var_4<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_negative_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_signed_gen_var_5<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_nonzero_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_signed_gen_var_6<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: ConvertibleFrom<S> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<S> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signed_inclusive_range::<U, S>(\n                    seed,\n                    S::saturating_from(V::SMALLEST_UNREPRESENTABLE_UINT),\n                    S::MAX,\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_signed_inclusive_range::<U, S>(\n                    seed,\n                    S::MIN,\n                    S::saturating_from(V::SMALLEST_UNREPRESENTABLE_UINT).saturating_neg(),\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(Union2::unwrap)\n        .filter(|&x| !V::convertible_from(x)),\n    )\n}\n\npub fn special_random_signed_gen_var_7<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: TryFrom<NiceFloat<V>> + PrimitiveSigned + WrappingFrom<U>,\n    V: PrimitiveFloat + RoundingFrom<S>,\n>(\n    config: &GenConfig,\n) -> It<S> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signed_inclusive_range::<U, S>(\n                    seed,\n                    S::exact_from(V::SMALLEST_UNREPRESENTABLE_UINT),\n                    S::MAX,\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n                .filter_map(|a| {\n                    let f = V::rounding_from(a, Down).0;\n                    let a = S::try_from(NiceFloat(f)).ok()?;\n                    let b = S::try_from(NiceFloat(f.next_higher())).ok()?;\n                    let diff = b - a;\n                    if diff.even() {\n                        // This happens almost always\n                        Some(a + (diff >> 1))\n                    } else {\n                        None\n                    }\n                })\n            },\n            &|seed| {\n                striped_random_signed_inclusive_range::<U, S>(\n                    seed,\n                    S::MIN,\n                    S::exact_from(V::SMALLEST_UNREPRESENTABLE_UINT)\n                        .checked_neg()\n                        .unwrap(),\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n                .filter_map(|a| {\n                    let f = V::rounding_from(a, Down).0;\n                    let a = S::try_from(NiceFloat(f)).ok()?;\n                    let b = S::try_from(NiceFloat(f.next_lower())).ok()?;\n                    let diff = a - b;\n                    if diff.even() {\n                        // This happens almost always\n                        Some(a - (diff >> 1))\n                    } else {\n                        None\n                    }\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_gen_var_8<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<S> {\n    let limit = S::wrapping_from(U::wrapping_from(S::MAX).floor_sqrt());\n    Box::new(striped_random_signed_inclusive_range::<U, S>(\n        EXAMPLE_SEED,\n        -limit,\n        limit,\n        config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_signed_gen_var_9<T: PrimitiveFloat>(config: &GenConfig) -> It<i64> {\n    Box::new(striped_random_signed_inclusive_range::<u64, i64>(\n        EXAMPLE_SEED,\n        T::MIN_EXPONENT,\n        T::MAX_EXPONENT,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_signed_gen_var_10<T: PrimitiveSigned>(config: &GenConfig) -> It<T> {\n    Box::new(\n        striped_random_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .filter(|&x| x != T::ZERO && x != T::MIN),\n    )\n}\n\npub fn special_random_signed_gen_var_11<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<S> {\n    Box::new(\n        striped_random_signed_inclusive_range::<U, S>(\n            EXAMPLE_SEED,\n            S::ZERO,\n            S::low_mask(S::WIDTH - 2),\n            config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(|u| (u << 1) | S::ONE),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned) --\n\npub fn special_random_signed_pair_gen<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(striped_random_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_signed_pair_gen_var_1<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_natural_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ))\n            },\n            &|seed| {\n                random_pairs_from_single(striped_random_negative_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ))\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_pair_gen_var_2<T: PrimitiveSigned, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_signed_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_signed_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_pair_gen_var_3<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(mut x, y)| {\n            x.round_to_multiple_assign(y, Down);\n            if x == T::MIN && y == T::NEGATIVE_ONE {\n                None\n            } else {\n                Some((x, y))\n            }\n        }),\n    )\n}\n\npub fn special_random_signed_pair_gen_var_4<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| x != T::MIN || y != T::NEGATIVE_ONE),\n    )\n}\n\npub fn special_random_signed_pair_gen_var_5<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn special_random_signed_pair_gen_var_6<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_nonzero_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_pair_gen_var_7<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(striped_random_natural_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_signed_pair_gen_var_8<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<(S, S)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signed_inclusive_range::<U, S>(\n                seed,\n                S::ZERO,\n                S::low_mask(S::WIDTH - 2),\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | S::ONE)\n        },\n    ))\n}\n\npub fn special_random_signed_pair_gen_var_9<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<(S, S)> {\n    Box::new(\n        random_pairs_from_single(\n            striped_random_signed_inclusive_range::<U, S>(\n                EXAMPLE_SEED,\n                S::ZERO,\n                S::low_mask(S::WIDTH - 2),\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | S::ONE),\n        )\n        .filter(|&(a, b): &(S, S)| a.unsigned_abs().coprime_with(b.unsigned_abs())),\n    )\n}\n\npub fn special_random_signed_pair_gen_var_10<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    config: &GenConfig,\n) -> It<(S, S)> {\n    Box::new(\n        random_pairs_from_single(striped_random_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter(|&(x, y): &(S, S)| x.unsigned_abs().coprime_with(y.unsigned_abs())),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned) --\n\npub fn special_random_signed_triple_gen<T: PrimitiveSigned>(config: &GenConfig) -> It<(T, T, T)> {\n    Box::new(random_triples_from_single(striped_random_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_signed_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(x, y, z)| reduce_to_fit_add_mul_signed(x, y, z)),\n    )\n}\n\npub fn special_random_signed_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(x, y, z)| reduce_to_fit_sub_mul_signed(x, y, z)),\n    )\n}\n\npub fn special_random_signed_triple_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_triples_from_single(striped_random_natural_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ))\n            },\n            &|seed| {\n                random_triples_from_single(striped_random_negative_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ))\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_triple_gen_var_4<\n    U: PrimitiveUnsigned + WrappingFrom<S> + WrappingInto<S>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    config: &GenConfig,\n) -> It<(S, S, S)> {\n    Box::new(\n        random_triples_from_single(striped_random_signeds::<S>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(x, y, m)| {\n            if m == S::ZERO {\n                let min = min(x, y);\n                (min, min, m)\n            } else if x <= y {\n                let adjusted_diff = U::wrapping_from(y.wrapping_sub(x))\n                    .round_to_multiple(m.unsigned_abs(), Down)\n                    .0;\n                (\n                    x,\n                    (U::wrapping_from(x).wrapping_add(adjusted_diff)).wrapping_into(),\n                    m,\n                )\n            } else {\n                let adjusted_diff = U::wrapping_from(x.wrapping_sub(y))\n                    .round_to_multiple(m.unsigned_abs(), Down)\n                    .0;\n                (\n                    (U::wrapping_from(y).wrapping_add(adjusted_diff)).wrapping_into(),\n                    y,\n                    m,\n                )\n            }\n        }),\n    )\n}\n\npub fn special_random_signed_triple_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_signeds::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter(|&(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\npub fn special_random_signed_triple_gen_var_6<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<(S, S, S)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signed_inclusive_range::<U, S>(\n                seed,\n                S::ZERO,\n                S::low_mask(S::WIDTH - 2),\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | S::ONE)\n        },\n    ))\n}\n\npub fn special_random_signed_triple_gen_var_7<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<(S, S, S)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signed_inclusive_range::<U, S>(\n                seed,\n                S::ZERO,\n                S::low_mask(S::WIDTH - 2),\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | S::ONE)\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned, PrimitiveSigned) --\n\npub fn special_random_signed_quadruple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(random_quadruples_from_single(striped_random_signeds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_signed_signed_signed_unsigned_quadruple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, T, T, U)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_signed_signed_unsigned_triple_gen_var_1<\n    U: PrimitiveUnsigned + WrappingFrom<S> + WrappingInto<S>,\n    S: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(S, S, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<S>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_pow_n\", 32),\n                    config.get_or(\"mean_pow_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, pow)| {\n            if pow >= S::WIDTH {\n                (x, x, pow)\n            } else if x <= y {\n                let adjusted_diff = U::wrapping_from(y.wrapping_sub(x))\n                    .round_to_multiple_of_power_of_2(pow, Down)\n                    .0;\n                (\n                    x,\n                    (U::wrapping_from(x).wrapping_add(adjusted_diff)).wrapping_into(),\n                    pow,\n                )\n            } else {\n                let adjusted_diff = U::wrapping_from(x.wrapping_sub(y))\n                    .round_to_multiple_of_power_of_2(pow, Down)\n                    .0;\n                (\n                    (U::wrapping_from(y).wrapping_add(adjusted_diff)).wrapping_into(),\n                    y,\n                    pow,\n                )\n            }\n        }),\n    )\n}\n\npub fn special_random_signed_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_signed_unsigned_triple_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, T, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y, pow)| !x.eq_mod_power_of_2(y, pow)),\n    )\n}\n\npub fn special_random_signed_signed_unsigned_triple_gen_var_4<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveSigned, RoundingMode) --\n\nstruct SignedSignedRoundingModeTripleGenerator<T: PrimitiveSigned> {\n    xs: StripedRandomSigneds<T>,\n    rms: RandomRoundingModes,\n}\n\nimpl<T: PrimitiveSigned> Iterator for SignedSignedRoundingModeTripleGenerator<T> {\n    type Item = (T, T, RoundingMode);\n\n    fn next(&mut self) -> Option<(T, T, RoundingMode)> {\n        let mut x;\n        let mut y;\n        loop {\n            x = self.xs.next().unwrap();\n            loop {\n                y = self.xs.next().unwrap();\n                if y != T::ZERO {\n                    break;\n                }\n            }\n            if x != T::MIN || y != T::NEGATIVE_ONE {\n                break;\n            }\n        }\n        let rm = self.rms.next().unwrap();\n        if rm == Exact {\n            x.round_to_multiple_assign(y, Down);\n        }\n        Some((x, y, rm))\n    }\n}\n\npub fn special_random_signed_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, T, RoundingMode)> {\n    Box::new(SignedSignedRoundingModeTripleGenerator {\n        xs: striped_random_signeds(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        rms: random_rounding_modes(EXAMPLE_SEED.fork(\"rms\")),\n    })\n}\n\npub fn special_random_signed_signed_rounding_mode_triple_gen_var_2<\n    U: PrimitiveUnsigned,\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>(\n    config: &GenConfig,\n) -> It<(S, S, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_signed_filter_map(x, y, rm)),\n    )\n}\n\npub fn special_random_signed_signed_rounding_mode_triple_gen_var_3<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, pow, rm)| {\n            rm != Exact || pow <= U::ZERO || x.divisible_by_power_of_2(pow.exact_into())\n        }),\n    )\n}\n\npub fn special_random_signed_signed_rounding_mode_triple_gen_var_4<\n    T: PrimitiveSigned,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, pow, rm)| {\n            let pow: i64 = pow.exact_into();\n            rm != Exact || pow >= 0 || x.divisible_by_power_of_2(pow.unsigned_abs())\n        }),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_signed_unsigned_pair_gen<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_1<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| random_unsigneds_less_than(seed, T::WIDTH),\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed| {\n                        striped_random_natural_signeds(\n                            seed,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        striped_random_unsigned_range(\n                            seed_2,\n                            0,\n                            T::WIDTH,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed| {\n                        striped_random_negative_signeds(\n                            seed,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_negative_signeds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        striped_random_unsigned_range(\n                            seed_2,\n                            0,\n                            T::WIDTH,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_natural_signeds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_5<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::exact_from(36u8),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_6<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_natural_signeds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_7<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_natural_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::exact_from(36u8),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_8<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_large_signed_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_signed_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_9<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(mut x, y)| {\n            x.round_to_multiple_of_power_of_2_assign(y.exact_into(), Down);\n            (x, y)\n        }),\n    )\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_10<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_natural_signeds::<T>(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_signeds::<T>(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        striped_random_unsigned_inclusive_range(\n                            seed_2,\n                            0,\n                            T::WIDTH,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_11<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<(S, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_signed_range::<U, S>(\n                            seed_2,\n                            S::MIN + S::ONE,\n                            S::ONE,\n                            config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_signeds::<S>(\n                            seed_2,\n                            config.get_or(\"mean_large_unsigned_stripe_n\", S::WIDTH >> 1),\n                            config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        striped_random_unsigned_range(\n                            seed_2,\n                            0,\n                            S::WIDTH,\n                            config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_12<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(S, V)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signed_inclusive_range::<U, S>(\n                seed,\n                if S::WIDTH <= u64::WIDTH {\n                    S::MIN\n                } else {\n                    -S::exact_from(u64::MAX)\n                },\n                S::saturating_from(u64::MAX),\n                config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_13<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_signeds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_14<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed| {\n                        striped_random_natural_signeds(\n                            seed,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed| {\n                        striped_random_negative_signeds(\n                            seed,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds::<U>(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                        .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | U::ONE))\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_15<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(S, V)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signed_range::<U, S>(\n                seed,\n                S::MIN + S::ONE,\n                S::ZERO,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_pair_gen_var_16<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, bool) --\n\npub fn random_signed_unsigned_bool_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64, bool)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_signeds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n                .map(|(x, y)| (x, y, x < T::ZERO))\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_signeds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| random_unsigneds_less_than(seed_2, T::WIDTH),\n                )\n                .map(|(x, y)| (x, y, x >= T::ZERO))\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_signed_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_large_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_unsigned_unsigned_triple_gen_var_2<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(S, V, V)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_triples_xyy(\n                    seed,\n                    &|seed_2| {\n                        striped_random_positive_signeds(\n                            seed_2,\n                            config.get_or(\"mean_large_stripe_n\", S::WIDTH >> 1),\n                            config.get_or(\"mean_large_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n                .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) })\n            },\n            &|seed| {\n                random_triples(\n                    seed,\n                    &|seed_2| {\n                        striped_random_signed_range::<U, S>(\n                            seed_2,\n                            S::MIN,\n                            S::ZERO,\n                            config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        striped_random_unsigned_range(\n                            seed_2,\n                            V::ZERO,\n                            V::exact_from(S::WIDTH),\n                            config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n                .filter_map(|(x, y, z): (S, V, V)| y.checked_add(z).map(|new_z| (x, y, new_z)))\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_signed_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveSigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::exact_from(36u8),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_signed_unsigned_unsigned_unsigned_quadruple_gen_var_1<\n    T: PrimitiveSigned + UnsignedAbs<Output = U>,\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, u64, u64, U)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &|seed_2| {\n                striped_random_signeds(\n                    seed_2,\n                    config.get_or(\"mean_large_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &|seed_2| {\n                striped_random_unsigneds(\n                    seed_2,\n                    config.get_or(\"mean_large_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| {\n            let (y, z) = if y <= z { (y, z) } else { (z, y) };\n            if signed_assign_bits_valid(x, y, z, w) {\n                Some((x, y, z, w))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_signed_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, pow, rm)| round_to_multiple_of_power_of_2_filter_map(x, pow, rm)),\n    )\n}\n\npub fn special_random_signed_unsigned_rounding_mode_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, y, rm)| rm != Exact || x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\n// vars 3 through 5 are in malachite-float.\n\npub fn special_random_signed_unsigned_rounding_mode_triple_gen_var_6<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (PrimitiveSigned, RoundingMode) --\n\npub fn special_random_signed_rounding_mode_pair_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_signed_rounding_mode_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_nonzero_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_signed_rounding_mode_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .filter(|&x| x != T::MIN)\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_signed_rounding_mode_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_nonzero_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .filter(|&x| x != T::MIN)\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_signed_rounding_mode_pair_gen_var_4<\n    T: PrimitiveSigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(move |&(n, rm)| rm != Exact || U::convertible_from(n)),\n    )\n}\n\n// -- (PrimitiveUnsigned, ToSciOptions) --\n\npub fn special_random_signed_to_sci_options_pair_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_signed_to_sci_options_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"mean_size_n\", 32),\n                    config.get_or(\"mean_size_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- (PrimitiveSigned, Vec<bool>) --\n\nstruct SignedBoolVecPairGeneratorVar1<T: PrimitiveSigned> {\n    xs: StripedRandomSigneds<T>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveSigned> Iterator for SignedBoolVecPairGeneratorVar1<T> {\n    type Item = (T, Vec<bool>);\n\n    fn next(&mut self) -> Option<(T, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = get_striped_bool_vec(\n            &mut self.striped_bit_source,\n            u64::exact_from(x.to_bits_asc().len()),\n        );\n        Some((x, bs))\n    }\n}\n\npub fn special_random_signed_bool_vec_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, Vec<bool>)> {\n    Box::new(SignedBoolVecPairGeneratorVar1 {\n        xs: striped_random_signeds(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- PrimitiveUnsigned --\n\npub fn special_random_unsigned_gen<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_1<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_positive_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_2(config: &GenConfig) -> It<u32> {\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        NUMBER_OF_CHARS,\n        config.get_or(\"mean_stripe_n\", 16),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_3<T: PrimitiveInt>(config: &GenConfig) -> It<u64> {\n    Box::new(striped_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        1,\n        T::WIDTH,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_4<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    config: &GenConfig,\n) -> It<U> {\n    Box::new(striped_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        U::TWO,\n        U::saturating_from(T::MAX),\n        config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_5<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::MAX,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_6<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(36),\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_7<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::exact_from(36),\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_8<T: PrimitiveInt>(config: &GenConfig) -> It<u64> {\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        T::WIDTH + 1,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_9(config: &GenConfig) -> It<u8> {\n    Box::new(\n        random_union3s(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    b'0',\n                    b'9',\n                    config.get_or(\"mean_stripe_n\", 4),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    b'a',\n                    b'z',\n                    config.get_or(\"mean_stripe_n\", 4),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    b'A',\n                    b'Z',\n                    config.get_or(\"mean_stripe_n\", 4),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(Union3::unwrap),\n    )\n}\n\npub fn special_random_unsigned_gen_var_10<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::power_of_2(T::WIDTH - 1),\n        T::MAX,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_11<T: PrimitiveFloat>(config: &GenConfig) -> It<u64> {\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        T::LARGEST_ORDERED_REPRESENTATION,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_12<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::power_of_2(T::WIDTH - 1) + T::ONE,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_13<T: PrimitiveInt>(config: &GenConfig) -> It<u64> {\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        T::WIDTH,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_14<T: PrimitiveInt>(config: &GenConfig) -> It<u64> {\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        T::WIDTH - 1,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_15<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::power_of_2(T::WIDTH - 2),\n        T::MAX,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_16<\n    T: PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        striped_random_unsigned_inclusive_range(\n            EXAMPLE_SEED,\n            T::saturating_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n            T::MAX,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .filter(|&x| !U::convertible_from(x)),\n    )\n}\n\npub fn special_random_unsigned_gen_var_17<\n    T: TryFrom<NiceFloat<U>> + PrimitiveUnsigned,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>(\n    config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        striped_random_unsigned_inclusive_range(\n            EXAMPLE_SEED,\n            T::exact_from(U::SMALLEST_UNREPRESENTABLE_UINT),\n            T::MAX,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .filter_map(|a| {\n            let f = U::rounding_from(a, Down).0;\n            let a = T::try_from(NiceFloat(f)).ok()?;\n            let b = T::try_from(NiceFloat(f.next_higher())).ok()?;\n            let diff = b - a;\n            if diff.even() {\n                // This happens almost always\n                Some(a + (diff >> 1))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_gen_var_18<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(striped_random_unsigned_inclusive_range(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::MAX.floor_sqrt(),\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_19<T: PrimitiveUnsigned>(config: &GenConfig) -> It<T> {\n    Box::new(\n        striped_random_unsigned_inclusive_range(\n            EXAMPLE_SEED,\n            T::ZERO,\n            T::low_mask(T::WIDTH - 1),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(|u| (u << 1) | T::ONE),\n    )\n}\n\npub fn special_random_unsigned_gen_var_20<T: PrimitiveUnsigned>(config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_factorial);\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        limit,\n        config.get_or(\"mean_stripe_n\", 4),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_21<T: PrimitiveUnsigned>(config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_double_factorial);\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        limit,\n        config.get_or(\"mean_stripe_n\", 4),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_22<T: PrimitiveUnsigned>(config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_subfactorial);\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        limit,\n        config.get_or(\"mean_stripe_n\", 4),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_23<T: PrimitiveUnsigned>(config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_primorial);\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        limit,\n        config.get_or(\"mean_stripe_n\", 4),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_24<T: PrimitiveUnsigned>(config: &GenConfig) -> It<u64> {\n    let limit = smallest_invalid_value(T::checked_product_of_first_n_primes);\n    Box::new(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        limit,\n        config.get_or(\"mean_stripe_n\", 4),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_gen_var_25<T: PrimitiveUnsigned + IsPrime>(\n    config: &GenConfig,\n) -> It<T> {\n    Box::new(\n        striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .filter(T::is_prime),\n    )\n}\n\npub fn special_random_unsigned_gen_var_26<T: PrimitiveFloat>(config: &GenConfig) -> It<u64> {\n    Box::new(striped_random_unsigned_inclusive_range::<u64>(\n        EXAMPLE_SEED,\n        0,\n        u64::exact_from(T::MAX_EXPONENT),\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned) --\n\npub fn special_random_unsigned_signed_pair_gen<T: PrimitiveUnsigned, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_signed_pair_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_signed_n\", 32),\n                config.get_or(\"mean_small_signed_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct IntegerMantissaAndExponentGenerator<T: PrimitiveFloat> {\n    xs: NonzeroValues<RandomPrimitiveFloatInclusiveRange<T>>,\n    shifts: GeometricRandomNaturalValues<i64>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for IntegerMantissaAndExponentGenerator<T> {\n    type Item = (u64, i64);\n\n    fn next(&mut self) -> Option<(u64, i64)> {\n        loop {\n            let (mantissa, exponent) = self.xs.next().unwrap().integer_mantissa_and_exponent();\n            let shift = self.shifts.next().unwrap();\n            let out = shift_integer_mantissa_and_exponent(mantissa, exponent, shift);\n            if out.is_some() {\n                return out;\n            }\n        }\n    }\n}\n\npub fn special_random_unsigned_signed_pair_gen_var_2<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(u64, i64)> {\n    Box::new(IntegerMantissaAndExponentGenerator::<T> {\n        xs: random_nonzero_finite_primitive_floats(EXAMPLE_SEED.fork(\"xs\")),\n        shifts: geometric_random_natural_signeds(\n            EXAMPLE_SEED.fork(\"shifts\"),\n            config.get_or(\"shift_mean_n\", 4),\n            config.get_or(\"shift_mean_d\", 1),\n        ),\n    })\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned, PrimitiveUnsigned) --\n\nstruct ModPowerOf2TripleExtraSmallSignedGenerator<T: PrimitiveUnsigned, U: PrimitiveSigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    us: GeometricRandomSigneds<U>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveSigned> Iterator\n    for ModPowerOf2TripleExtraSmallSignedGenerator<T, U>\n{\n    type Item = (T, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn special_random_unsigned_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, u64)> {\n    Box::new(ModPowerOf2TripleExtraSmallSignedGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: geometric_random_signeds(\n            EXAMPLE_SEED.fork(\"ms\"),\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\npub fn special_random_unsigned_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    config: &GenConfig,\n) -> It<(T, S, T)> {\n    Box::new(\n        random_triples_xyx(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_signed_inclusive_range::<U, S>(\n                    seed,\n                    if S::WIDTH <= u64::WIDTH {\n                        S::MIN\n                    } else {\n                        -S::exact_from(u64::MAX)\n                    },\n                    S::saturating_from(u64::MAX),\n                    config.get_or(\"mean_stripe_n\", S::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z): (T, S, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\npub fn special_random_unsigned_signed_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_signeds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", U::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\npub fn special_random_unsigned_signed_unsigned_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveSigned, RoundingMode) --\n\npub fn special_random_unsigned_signed_rounding_mode_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, pow, rm)| {\n            rm != Exact || pow <= U::ZERO || x.divisible_by_power_of_2(pow.exact_into())\n        }),\n    )\n}\n\npub fn special_random_unsigned_signed_rounding_mode_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<U>(\n                    seed,\n                    config.get_or(\"mean_shift_n\", 4),\n                    config.get_or(\"mean_shift_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, pow, rm)| {\n            let pow: i64 = pow.exact_into();\n            rm != Exact || pow >= 0 || x.divisible_by_power_of_2(pow.unsigned_abs())\n        }),\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_unsigned_pair_gen<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| random_unsigneds_less_than(seed, T::WIDTH),\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::saturating_from(T::MAX),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// TODO make better\npub fn special_random_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(x, y)| if x <= y { (x, y) } else { (y, x) }),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_6<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::exact_from(36u8),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y)| (x.round_to_multiple(y, Down).0, y)),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_8<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_unsigneds::<U>(\n                seed,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_10<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_11<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(mut x, y)| {\n            x.round_to_multiple_of_power_of_2_assign(y.exact_into(), Down);\n            (x, y)\n        }),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_ordered_unique_pairs(striped_random_unsigneds::<T>(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\nstruct ModPowerOf2SingleGenerator<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2SingleGenerator<T> {\n    type Item = (T, u64);\n\n    fn next(&mut self) -> Option<(T, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, pow))\n    }\n}\n\nstruct ModPowerOf2SingleGenerator2<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<Box<dyn Iterator<Item = T>>>>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2SingleGenerator2<T> {\n    type Item = (T, u64);\n\n    fn next(&mut self) -> Option<(T, u64)> {\n        let pow = self.ms.next().unwrap();\n        assert_ne!(pow, 0);\n        let xs = &mut self.xss[usize::wrapping_from(pow)];\n        if xs.is_none() {\n            *xs = Some(Box::new(\n                striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                )\n                .filter(|&x| x != T::ZERO),\n            ));\n        }\n        let x = xs.as_mut().unwrap().next().unwrap();\n        Some((x, pow))\n    }\n}\n\npub fn special_random_unsigned_pair_gen_var_13<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(ModPowerOf2SingleGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\npub fn special_random_unsigned_pair_gen_var_14<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_15<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| random_unsigneds_less_than(seed, U::WIDTH + 1),\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_16<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed,\n                U::TWO,\n                U::MAX,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_17<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| random_unsigneds_less_than(seed, U::WIDTH + 1),\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_18<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::ZERO,\n                T::saturating_from(u64::MAX),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_unsigneds::<U>(\n                seed,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_19<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(u64, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_bit_chunks(\n                seed,\n                T::MANTISSA_WIDTH,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_bit_chunks(\n                seed,\n                T::EXPONENT_WIDTH,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_20<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(special_random_unsigned_pair_gen_var_13(config).map(|(x, p)| (x, T::WIDTH - p)))\n}\n\npub fn special_random_unsigned_pair_gen_var_21<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct LikelyMultiplyablePairs<T: PrimitiveUnsigned> {\n    bits: GeometricRandomNaturalValues<u64>,\n    striped_bit_source: StripedBitSource,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for LikelyMultiplyablePairs<T> {\n    type Item = (T, T);\n\n    fn next(&mut self) -> Option<(T, T)> {\n        let x = T::from_bits_asc(\n            get_striped_bool_vec(&mut self.striped_bit_source, self.bits.next().unwrap())\n                .into_iter(),\n        );\n        let y = T::from_bits_asc(\n            get_striped_bool_vec(&mut self.striped_bit_source, self.bits.next().unwrap())\n                .into_iter(),\n        );\n        Some((x, y))\n    }\n}\n\npub fn special_random_unsigned_pair_gen_var_22<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(LikelyMultiplyablePairs {\n        bits: geometric_random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"bits\"),\n            0,\n            T::WIDTH,\n            T::WIDTH >> 1,\n            1,\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        phantom: PhantomData,\n    })\n}\n\npub fn special_random_unsigned_pair_gen_var_23<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(\n        special_random_unsigned_pair_gen_var_22::<T>(config)\n            .filter(|&(x, y)| x.checked_lcm(y).is_some()),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_24<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::power_of_2(T::WIDTH - 1),\n                T::MAX,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_unsigned_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_25<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y)| x != T::ONE || y != T::ZERO),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_26(config: &GenConfig) -> It<(u32, u32)> {\n    Box::new(random_pairs_from_single(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        NUMBER_OF_CHARS,\n        config.get_or(\"mean_stripe_n\", 16),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_unsigned_pair_gen_var_27<T: PrimitiveUnsigned, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_stripe_n\", 4),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_28<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::exact_from(36u8),\n                config.get_or(\"mean_stripe_n\", 4),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_29<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, V)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::saturating_from(U::MAX),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_30<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::exact_from(36u8),\n                config.get_or(\"mean_stripe_n\", 4),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_31<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n                .map(|x| (T::ZERO, x))\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_positive_unsigneds::<T>(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        striped_random_unsigned_range(\n                            seed_2,\n                            0,\n                            T::WIDTH,\n                            config.get_or(\"mean_stripe_n\", 4),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_32<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(u64, u64)> {\n    Box::new(random_pairs_from_single(striped_random_unsigned_range(\n        EXAMPLE_SEED,\n        0,\n        T::LARGEST_ORDERED_REPRESENTATION,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_unsigned_pair_gen_var_33<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::power_of_2(T::WIDTH - 2),\n                T::MAX,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_34<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_35<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(striped_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_unsigned_pair_gen_var_36<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_ordered_unique_pairs(\n        striped_random_positive_unsigneds::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_37<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64)> {\n    Box::new(ModPowerOf2SingleGenerator2 {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            1,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: {\n            let len = usize::wrapping_from(T::WIDTH) + 1;\n            let mut xss = Vec::with_capacity(len);\n            xss.resize_with(len, || None);\n            xss\n        },\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\npub fn special_random_unsigned_pair_gen_var_38<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::ZERO,\n                T::low_mask(T::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn special_random_unsigned_pair_gen_var_39<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(\n            striped_random_unsigned_inclusive_range(\n                EXAMPLE_SEED,\n                T::ZERO,\n                T::low_mask(T::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | T::ONE),\n        )\n        .filter(|&(a, b): &(T, T)| a.coprime_with(b)),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_40<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(\n        random_pairs_from_single(striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter(|&(x, y): &(T, T)| x.coprime_with(y)),\n    )\n}\n\npub fn special_random_unsigned_pair_gen_var_41<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T)> {\n    Box::new(random_pairs_from_single(\n        striped_random_unsigned_inclusive_range(\n            EXAMPLE_SEED,\n            T::TWO,\n            T::MAX,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, bool) --\n\npub fn special_random_unsigned_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64, bool)> {\n    reshape_1_2_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            random_union2s(\n                seed,\n                &|seed_2| {\n                    geometric_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"small_unsigned_mean_n\", 32),\n                        config.get_or(\"small_unsigned_mean_d\", 1),\n                    )\n                    .map(|x| (x, false))\n                },\n                &|seed_2| random_unsigneds_less_than(seed_2, T::WIDTH).map(|x| (x, true)),\n            )\n            .map(Union2::unwrap)\n        },\n    )))\n}\n\npub fn special_random_unsigned_unsigned_bool_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_unsigneds::<U>(\n                seed,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(x, y, z)| reduce_to_fit_add_mul_unsigned(x, y, z)),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(x, y, z)| reduce_to_fit_sub_mul_unsigned(x, y, z)),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, u64, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_triple_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_triple_gen_var_5<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, U)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) }),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_6<\n    T: PrimitiveUnsigned,\n    U: ExactFrom<u8> + PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::exact_from(36u8),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_triple_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_unsigneds::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(x, y, m)| {\n            if m == T::ZERO {\n                let min = min(x, y);\n                (min, min, m)\n            } else if x <= y {\n                let adjusted_diff = (y - x).round_to_multiple(m, Down).0;\n                (x, x + adjusted_diff, m)\n            } else {\n                let adjusted_diff = (x - y).round_to_multiple(m, Down).0;\n                (y + adjusted_diff, y, m)\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_unsigneds::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter(|&(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_pow_n\", 32),\n                    config.get_or(\"mean_pow_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, pow)| {\n            if pow >= T::WIDTH {\n                (x, x, pow)\n            } else if x <= y {\n                let adjusted_diff = (y - x).round_to_multiple_of_power_of_2(pow, Down).0;\n                (x, x + adjusted_diff, pow)\n            } else {\n                let adjusted_diff = (x - y).round_to_multiple_of_power_of_2(pow, Down).0;\n                (y + adjusted_diff, y, pow)\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|&(x, y, pow)| !x.eq_mod_power_of_2(y, pow)),\n    )\n}\n\nstruct ModPowerOf2PairGenerator<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2PairGenerator<T> {\n    type Item = (T, T, u64);\n\n    fn next(&mut self) -> Option<(T, T, u64)> {\n        let pow = self.ms.next().unwrap();\n        let (x, y) = if pow == 0 {\n            (T::ZERO, T::ZERO)\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            let xs = xs.as_mut().unwrap();\n            (xs.next().unwrap(), xs.next().unwrap())\n        };\n        Some((x, y, pow))\n    }\n}\n\npub fn special_random_unsigned_triple_gen_var_11<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, u64)> {\n    Box::new(ModPowerOf2PairGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\npub fn special_random_unsigned_triple_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(\n        random_triples_from_single(striped_random_unsigneds::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter_map(|(x, y, z)| {\n            let ranking = [(x, 0), (y, 1), (z, 2)];\n            let (hi, next_hi) = get_two_highest(&ranking);\n            if hi.0 == next_hi.0 {\n                None\n            } else {\n                Some(match hi.1 {\n                    0 => (y, z, x),\n                    1 => (x, z, y),\n                    _ => (x, y, z),\n                })\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_13<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, U)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_triple_gen_var_14<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_15<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", U::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\nstruct ModPowerOf2TripleExtraUnsignedGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    us: StripedRandomUnsignedBitChunks<U>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for ModPowerOf2TripleExtraUnsignedGenerator<T, U>\n{\n    type Item = (T, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn special_random_unsigned_triple_gen_var_16<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, u64)> {\n    Box::new(ModPowerOf2TripleExtraUnsignedGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: striped_random_unsigneds::<U>(\n            EXAMPLE_SEED.fork(\"us\"),\n            config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\nstruct ModPowerOf2TripleExtraSmallUnsignedGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    us: GeometricRandomNaturalValues<U>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for ModPowerOf2TripleExtraSmallUnsignedGenerator<T, U>\n{\n    type Item = (T, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn special_random_unsigned_triple_gen_var_17<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, u64)> {\n    Box::new(ModPowerOf2TripleExtraSmallUnsignedGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"ms\"),\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\npub fn special_random_unsigned_triple_gen_var_18<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, T)> {\n    Box::new(\n        random_triples_xyx(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    U::ZERO,\n                    U::saturating_from(u64::MAX),\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z): (T, U, T)| match x.cmp(&z) {\n            Equal => None,\n            Less => Some((x, y, z)),\n            Greater => Some((z, y, x)),\n        }),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_19<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_from_single(striped_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_unsigned_triple_gen_var_20<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, U)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) }),\n    )\n}\n\npub fn special_random_unsigned_triple_gen_var_21<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_xyx(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::ZERO,\n                T::low_mask(T::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn special_random_unsigned_triple_gen_var_22<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::ZERO,\n                T::low_mask(T::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\npub fn special_random_unsigned_triple_gen_var_23<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::ZERO,\n                T::low_mask(T::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64, u64, U)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| {\n            let (y, z) = if y <= z { (y, z) } else { (z, y) };\n            if unsigned_assign_bits_valid(y, z, w) {\n                Some((x, y, z, w))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_quadruple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, U)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_large_unsigned_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_large_unsigned_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct ModPowerOf2TripleGenerator<T: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for ModPowerOf2TripleGenerator<T> {\n    type Item = (T, T, T, u64);\n\n    fn next(&mut self) -> Option<(T, T, T, u64)> {\n        let pow = self.ms.next().unwrap();\n        let (x, y, z) = if pow == 0 {\n            (T::ZERO, T::ZERO, T::ZERO)\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            let xs = xs.as_mut().unwrap();\n            (xs.next().unwrap(), xs.next().unwrap(), xs.next().unwrap())\n        };\n        Some((x, y, z, pow))\n    }\n}\n\npub fn special_random_unsigned_quadruple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, u64)> {\n    Box::new(ModPowerOf2TripleGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\npub fn special_random_unsigned_quadruple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(\n        random_quadruples_from_single(striped_random_unsigneds::<T>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter_map(|(x, y, z, w)| {\n            let ranking = [(x, 0), (y, 1), (z, 2), (w, 3)];\n            let (hi, next_hi) = get_two_highest(&ranking);\n            if hi.0 == next_hi.0 {\n                None\n            } else {\n                Some(match hi.1 {\n                    0 => (y, z, w, x),\n                    1 => (x, z, w, y),\n                    2 => (x, y, w, z),\n                    _ => (x, y, z, w),\n                })\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_quadruple_gen_var_5<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>(\n    config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|(x_1, x_0, d)| {\n            let inv = limbs_invert_limb_naive::<T, DT>(d << LeadingZeros::leading_zeros(d));\n            (x_1, x_0, d, inv)\n        }),\n    )\n}\n\npub fn special_random_unsigned_quadruple_gen_var_6<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, U, T)> {\n    Box::new(\n        random_quadruples_xxyx(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| {\n            let ranking = [(x, 0), (y, 1), (w, 2)];\n            let (hi, next_hi) = get_two_highest(&ranking);\n            if hi.0 == next_hi.0 {\n                None\n            } else {\n                Some(match hi.1 {\n                    0 => (y, w, z, x),\n                    1 => (x, w, z, y),\n                    _ => (x, y, z, w),\n                })\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_quadruple_gen_var_7<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, U, T)> {\n    Box::new(\n        random_quadruples_xyyx(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match x.cmp(&w) {\n            Equal => None,\n            Less => Some((x, y, z, w)),\n            Greater => Some((w, y, z, x)),\n        }),\n    )\n}\n\nstruct ModPowerOf2QuadrupleWithExtraUnsignedGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    us: StripedRandomUnsignedBitChunks<U>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for ModPowerOf2QuadrupleWithExtraUnsignedGenerator<T, U>\n{\n    type Item = (T, T, U, u64);\n\n    fn next(&mut self) -> Option<(T, T, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let (x, y) = if pow == 0 {\n            (T::ZERO, T::ZERO)\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            let xs = xs.as_mut().unwrap();\n            (xs.next().unwrap(), xs.next().unwrap())\n        };\n        Some((x, y, self.us.next().unwrap(), pow))\n    }\n}\n\npub fn special_random_unsigned_quadruple_gen_var_8<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, U, u64)> {\n    Box::new(ModPowerOf2QuadrupleWithExtraUnsignedGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: striped_random_unsigneds::<U>(\n            EXAMPLE_SEED.fork(\"us\"),\n            config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\nstruct ModPowerOf2QuadrupleWithTwoExtraUnsignedGenerator<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n{\n    ms: GeometricRandomNaturalValues<u64>,\n    xss: Vec<Option<StripedRandomUnsignedBitChunks<T>>>,\n    us: StripedRandomUnsignedBitChunks<U>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for ModPowerOf2QuadrupleWithTwoExtraUnsignedGenerator<T, U>\n{\n    type Item = (T, U, U, u64);\n\n    fn next(&mut self) -> Option<(T, U, U, u64)> {\n        let pow = self.ms.next().unwrap();\n        let x = if pow == 0 {\n            T::ZERO\n        } else {\n            let xs = &mut self.xss[usize::wrapping_from(pow)];\n            if xs.is_none() {\n                *xs = Some(striped_random_unsigned_bit_chunks(\n                    EXAMPLE_SEED.fork(&pow.to_string()),\n                    pow,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                ));\n            }\n            xs.as_mut().unwrap().next().unwrap()\n        };\n        Some((x, self.us.next().unwrap(), self.us.next().unwrap(), pow))\n    }\n}\n\npub fn special_random_unsigned_quadruple_gen_var_9<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, U, U, u64)> {\n    Box::new(ModPowerOf2QuadrupleWithTwoExtraUnsignedGenerator {\n        ms: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"ms\"),\n            0,\n            T::WIDTH,\n            config.get_or(\"mean_pow_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_pow_d\", 1),\n        ),\n        us: striped_random_unsigneds::<U>(\n            EXAMPLE_SEED.fork(\"us\"),\n            config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        xss: vec![None; usize::wrapping_from(T::WIDTH) + 1],\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n    })\n}\n\npub fn special_random_unsigned_quadruple_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(random_quadruples_from_single(striped_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\npub fn special_random_unsigned_quadruple_gen_var_11<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(\n        random_quadruples_from_single(striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter(|&(n1, n0, d1, d0)| {\n            // conditions: D >= 2^W, N >= D, and N / D < 2^W\n            d1 != T::ZERO && (n1 > d1 || n1 == d1 && n0 >= d0)\n        }),\n    )\n}\n\npub fn special_random_unsigned_quadruple_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::ZERO,\n                T::low_mask(T::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | T::ONE)\n        },\n    ))\n}\n\n// -- (PrimitiveUnsigned * 6) --\n\npub fn special_random_unsigned_sextuple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T, T, T)> {\n    Box::new(random_sextuples_from_single(striped_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\n// var 2 is in malachite-nz.\n\n// -- (PrimitiveUnsigned * 8) --\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_octuple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T, T, T, T, T)> {\n    Box::new(random_octuples_from_single(striped_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\n// -- (PrimitiveUnsigned * 9) --\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_nonuple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T, T, T, T, T, T)> {\n    Box::new(\n        random_triples_from_single(random_triples_from_single(striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )))\n        .map(|((a, b, c), (d, e, f), (g, h, i))| (a, b, c, d, e, f, g, h, i)),\n    )\n}\n\n// -- (PrimitiveUnsigned * 12) --\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_duodecuple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, T, T, T, T, T, T, T, T, T, T)> {\n    Box::new(random_duodecuples_from_single(striped_random_unsigneds(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n        config.get_or(\"mean_stripe_d\", 1),\n    )))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\nstruct UnsignedUnsignedRoundingModeTripleGenerator<T: PrimitiveUnsigned> {\n    xs: StripedRandomUnsignedBitChunks<T>,\n    rms: RandomRoundingModes,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedUnsignedRoundingModeTripleGenerator<T> {\n    type Item = (T, T, RoundingMode);\n\n    fn next(&mut self) -> Option<(T, T, RoundingMode)> {\n        let mut x = self.xs.next().unwrap();\n        let mut y;\n        loop {\n            y = self.xs.next().unwrap();\n            if y != T::ZERO {\n                break;\n            }\n        }\n        let rm = self.rms.next().unwrap();\n        if rm == Exact {\n            x.round_to_multiple_assign(y, Down);\n        }\n        Some((x, y, rm))\n    }\n}\n\npub fn special_random_unsigned_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, RoundingMode)> {\n    Box::new(UnsignedUnsignedRoundingModeTripleGenerator {\n        xs: striped_random_unsigneds(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        rms: random_rounding_modes(EXAMPLE_SEED.fork(\"rms\")),\n    })\n}\n\npub fn special_random_unsigned_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_unsigned_filter_map(x, y, rm)),\n    )\n}\n\npub fn special_random_unsigned_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, pow, rm)| round_to_multiple_of_power_of_2_filter_map(x, pow, rm)),\n    )\n}\n\npub fn special_random_unsigned_unsigned_rounding_mode_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, y, rm)| rm != Exact || x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\n// vars 5 through 6 are in malachite-float.\n\npub fn special_random_unsigned_unsigned_rounding_mode_triple_gen_var_7<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(T, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, Vec<bool>) --\n\nstruct UnsignedUnsignedBoolVecTripleGeneratorVar1<T: PrimitiveUnsigned> {\n    xs: StripedRandomUnsignedBitChunks<T>,\n    log_bases: StripedRandomUnsignedInclusiveRange<u64>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedUnsignedBoolVecTripleGeneratorVar1<T> {\n    type Item = (T, u64, Vec<bool>);\n\n    fn next(&mut self) -> Option<(T, u64, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let log_base = self.log_bases.next().unwrap();\n        let bs = get_striped_bool_vec(\n            &mut self.striped_bit_source,\n            x.significant_bits().div_round(log_base, Ceiling).0,\n        );\n        Some((x, log_base, bs))\n    }\n}\n\npub fn special_random_unsigned_unsigned_bool_vec_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(T, u64, Vec<bool>)> {\n    Box::new(UnsignedUnsignedBoolVecTripleGeneratorVar1 {\n        xs: striped_random_unsigneds(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        log_bases: striped_random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            1,\n            U::WIDTH,\n            config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- (PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_unsigned_rounding_mode_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_unsigned_rounding_mode_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_unsigned_rounding_mode_pair_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: ConvertibleFrom<T> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(T, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(move |&(n, rm)| rm != Exact || U::convertible_from(n)),\n    )\n}\n\n// -- (PrimitiveUnsigned, String) --\n\npub fn special_random_unsigned_string_pair_gen_var_1(config: &GenConfig) -> It<(u8, String)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                2,\n                36,\n                config.get_or(\"mean_stripe_n\", 4),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            random_strings_using_chars(\n                seed,\n                &|seed_2| {\n                    graphic_weighted_random_chars(\n                        seed_2,\n                        config.get_or(\"graphic_char_prob_n\", 50),\n                        config.get_or(\"graphic_char_prob_d\", 51),\n                    )\n                },\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (PrimitiveUnsigned, ToSciOptions) --\n\npub fn special_random_unsigned_to_sci_options_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_to_sci_options_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"mean_size_n\", 32),\n                    config.get_or(\"mean_size_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- (PrimitiveUnsigned, Vec<bool>) --\n\nstruct UnsignedBoolVecPairGeneratorVar1<T: PrimitiveUnsigned> {\n    xs: StripedRandomUnsignedBitChunks<T>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedBoolVecPairGeneratorVar1<T> {\n    type Item = (T, Vec<bool>);\n\n    fn next(&mut self) -> Option<(T, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = get_striped_bool_vec(&mut self.striped_bit_source, x.significant_bits());\n        Some((x, bs))\n    }\n}\n\npub fn special_random_unsigned_bool_vec_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, Vec<bool>)> {\n    Box::new(UnsignedBoolVecPairGeneratorVar1 {\n        xs: striped_random_unsigneds(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- RationalSequence<PrimitiveUnsigned> --\n\npub fn special_random_unsigned_rational_sequence_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<RationalSequence<T>> {\n    Box::new(random_rational_sequences(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\n// -- (RationalSequence<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn special_random_unsigned_rational_sequence_unsigned_pair_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rational_sequences(\n                seed,\n                &|seed_2| {\n                    striped_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                        config.get_or(\"mean_stripe_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 32),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_rational_sequence_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, usize)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rational_sequences(\n                    seed,\n                    &|seed_2| {\n                        striped_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_unsigned_n\", 32),\n                    config.get_or(\"mean_small_unsigned_d\", 1),\n                )\n            },\n        )\n        .filter(|&(ref xs, i)| {\n            if let Some(len) = xs.len() {\n                i < len\n            } else {\n                true\n            }\n        }),\n    )\n}\n\n// -- (RationalSequence<PrimitiveUnsigned>, RationalSequence<PrimitiveUnsigned>) --\n\npub fn special_random_unsigned_rational_sequence_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, RationalSequence<T>)> {\n    Box::new(random_pairs_from_single(random_rational_sequences(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\n// -- RationalSequence<PrimitiveUnsigned> * 3 --\n\npub fn special_random_unsigned_rational_sequence_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(\n    RationalSequence<T>,\n    RationalSequence<T>,\n    RationalSequence<T>,\n)> {\n    Box::new(random_triples_from_single(random_rational_sequences(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\n// -- String --\n\npub fn special_random_string_gen(config: &GenConfig) -> It<String> {\n    Box::new(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &|seed| {\n            graphic_weighted_random_chars(\n                seed,\n                config.get_or(\"graphic_char_prob_n\", 50),\n                config.get_or(\"graphic_char_prob_d\", 51),\n            )\n        },\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn special_random_string_gen_var_1(config: &GenConfig) -> It<String> {\n    Box::new(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &|seed| {\n            graphic_weighted_random_ascii_chars(\n                seed,\n                config.get_or(\"graphic_char_prob_n\", 50),\n                config.get_or(\"graphic_char_prob_d\", 51),\n            )\n        },\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\n// vars 2 and 3 are in malachite-q.\n\npub fn special_random_string_gen_var_4(config: &GenConfig) -> It<String> {\n    Box::new(\n        random_strings_using_chars(\n            EXAMPLE_SEED,\n            &|seed| {\n                graphic_weighted_random_chars(\n                    seed,\n                    config.get_or(\"graphic_char_prob_n\", 50),\n                    config.get_or(\"graphic_char_prob_d\", 51),\n                )\n            },\n            config.get_or(\"mean_length_n\", 32),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|s| !large_exponent(s)),\n    )\n}\n\n// -- (String, FromSciStringOptions) --\n\npub fn special_random_string_from_sci_string_options_pair_gen(\n    config: &GenConfig,\n) -> It<(String, FromSciStringOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_strings_using_chars(\n                seed,\n                &|seed_2| {\n                    graphic_weighted_random_chars(\n                        seed_2,\n                        config.get_or(\"graphic_char_prob_n\", 50),\n                        config.get_or(\"graphic_char_prob_d\", 51),\n                    )\n                },\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &random_from_sci_string_options,\n    ))\n}\n\npub fn special_random_string_from_sci_string_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(String, FromSciStringOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_strings_using_chars(\n                seed,\n                &|seed_2| {\n                    graphic_weighted_random_chars(\n                        seed_2,\n                        config.get_or(\"graphic_char_prob_n\", 50),\n                        config.get_or(\"graphic_char_prob_d\", 51),\n                    )\n                },\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|s| !large_exponent(s))\n        },\n        &random_from_sci_string_options,\n    ))\n}\n\n// -- (String, PrimitiveUnsigned) --\n\npub fn special_random_string_unsigned_pair_gen_var_1(config: &GenConfig) -> It<(String, u8)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_strings_using_chars(\n                seed,\n                &|seed_2| {\n                    graphic_weighted_random_chars(\n                        seed_2,\n                        config.get_or(\"graphic_char_prob_n\", 50),\n                        config.get_or(\"graphic_char_prob_d\", 51),\n                    )\n                },\n                config.get_or(\"mean_length_n\", 32),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|s| !large_exponent(s))\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                2,\n                36,\n                config.get_or(\"mean_stripe_n\", 4),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (String, String) --\n\npub fn special_random_string_pair_gen(config: &GenConfig) -> It<(String, String)> {\n    Box::new(random_pairs_from_single(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &|seed| {\n            graphic_weighted_random_chars(\n                seed,\n                config.get_or(\"graphic_char_prob_n\", 50),\n                config.get_or(\"graphic_char_prob_d\", 51),\n            )\n        },\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub fn special_random_string_pair_gen_var_1(config: &GenConfig) -> It<(String, String)> {\n    Box::new(random_pairs_from_single(random_strings_using_chars(\n        EXAMPLE_SEED,\n        &|seed| {\n            graphic_weighted_random_ascii_chars(\n                seed,\n                config.get_or(\"graphic_char_prob_n\", 50),\n                config.get_or(\"graphic_char_prob_d\", 51),\n            )\n        },\n        config.get_or(\"mean_length_n\", 32),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\n// -- (ToSciOptions, PrimitiveUnsigned> --\n\npub fn special_random_to_sci_options_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(ToSciOptions, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"mean_size_n\", 32),\n                config.get_or(\"mean_size_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::from(36u8),\n                config.get_or(\"mean_stripe_n\", T::WIDTH),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- Vec<bool> --\n\npub fn special_random_bool_vec_gen(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(striped_random_bool_vecs(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 8),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn special_random_bool_vec_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_bool_vecs_length_inclusive_range(\n                    seed,\n                    0,\n                    T::WIDTH,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_fixed_length_bool_vecs(\n                            seed_2,\n                            T::WIDTH,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| bs.into_iter().chain(repeat_n(false, n)).collect())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_bool_vec_gen_var_2<T: PrimitiveSigned>(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_bool_vecs_length_inclusive_range(\n                    seed,\n                    0,\n                    T::WIDTH,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_fixed_length_bool_vecs(\n                            seed_2,\n                            T::WIDTH - 1,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_nonzero_signeds::<isize>(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| {\n                    bs.into_iter()\n                        .chain(repeat_n(n < 0, n.unsigned_abs()))\n                        .collect()\n                })\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_bool_vec_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_bool_vecs_length_inclusive_range(\n                    seed,\n                    0,\n                    T::WIDTH,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_fixed_length_bool_vecs(\n                            seed_2,\n                            T::WIDTH,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| repeat_n(false, n).chain(bs).collect())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_bool_vec_gen_var_4<T: PrimitiveSigned>(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_bool_vecs_length_inclusive_range(\n                    seed,\n                    0,\n                    T::WIDTH - 1,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_fixed_length_bool_vecs(\n                            seed_2,\n                            T::WIDTH - 1,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_nonzero_signeds::<isize>(\n                            seed_2,\n                            config.get_or(\"mean_excess_length_n\", 32),\n                            config.get_or(\"mean_excess_length_d\", 1),\n                        )\n                    },\n                )\n                .map(|(bs, n)| repeat_n(n < 0, n.unsigned_abs()).chain(bs).collect())\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_bool_vec_gen_var_5(config: &GenConfig) -> It<Vec<bool>> {\n    Box::new(\n        striped_random_bool_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", 8),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|bs| bs.iter().any(|&b| b)),\n    )\n}\n\n// -- Vec<PrimitiveUnsigned> --\n\npub fn special_random_unsigned_vec_gen<T: PrimitiveUnsigned>(config: &GenConfig) -> It<Vec<T>> {\n    Box::new(striped_random_unsigned_vecs(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\npub fn special_random_unsigned_vec_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<Vec<T>> {\n    Box::new(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn special_random_unsigned_vec_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<Vec<T>> {\n    Box::new(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| !slice_test_zero(xs)),\n    )\n}\n\npub fn special_random_unsigned_vec_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<Vec<T>> {\n    Box::new(\n        striped_random_unsigned_vecs(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| xs.last() != Some(&T::ZERO)),\n    )\n}\n\npub fn special_random_unsigned_vec_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<Vec<T>> {\n    Box::new(striped_random_unsigned_vecs_min_length(\n        EXAMPLE_SEED,\n        1,\n        config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\n// var 5 is in malachite-nz.\n\npub fn special_random_unsigned_vec_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<Vec<T>> {\n    Box::new(striped_random_unsigned_vecs_min_length(\n        EXAMPLE_SEED,\n        2,\n        config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    ))\n}\n\n// --(Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn special_random_unsigned_vec_unsigned_pair_gen<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct UnsignedVecUnsignedPairGeneratorVar1<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    log_bases: GeometricRandomNaturalValues<u64>,\n    ranges: VariableRangeGenerator,\n    striped_bit_source: StripedBitSource,\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for UnsignedVecUnsignedPairGeneratorVar1<T, U>\n{\n    type Item = (Vec<U>, u64);\n\n    fn next(&mut self) -> Option<(Vec<U>, u64)> {\n        let log_base = self.log_bases.next().unwrap();\n        let max_count = usize::exact_from(T::WIDTH.div_round(log_base, Ceiling).0);\n        loop {\n            let digit_count = self.ranges.next_in_inclusive_range(0, max_count);\n            let mut digits = Vec::with_capacity(digit_count);\n            for _ in 0..digit_count {\n                digits.push(U::from_bits_asc(\n                    get_striped_bool_vec(&mut self.striped_bit_source, log_base).into_iter(),\n                ));\n            }\n            if digits_valid::<T, U>(log_base, &digits) {\n                return Some((digits, log_base));\n            }\n        }\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<U>, u64)> {\n    Box::new(UnsignedVecUnsignedPairGeneratorVar1::<T, U> {\n        log_bases: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            1,\n            U::WIDTH,\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        ranges: VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"ranges\")),\n        phantom: PhantomData,\n    })\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<U>, u64)> {\n    Box::new(\n        special_random_unsigned_vec_unsigned_pair_gen_var_1::<T, U>(config)\n            .map(|(xs, y)| (xs.into_iter().rev().collect(), y)),\n    )\n}\n\nstruct UnsignedVecUnsignedPairGeneratorVar3<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n    xs: GeometricRandomNaturalValues<usize>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedVecUnsignedPairGeneratorVar3<T> {\n    type Item = (Vec<T>, usize);\n\n    fn next(&mut self) -> Option<(Vec<T>, usize)> {\n        let x_1 = self.xs.next().unwrap();\n        let x_2 = self.xs.next().unwrap();\n        let (len, i) = if x_1 <= x_2 { (x_2, x_1) } else { (x_1, x_2) };\n        Some((\n            get_striped_unsigned_vec(\n                &mut self.striped_bit_source,\n                u64::exact_from(len) << T::LOG_WIDTH,\n            ),\n            i,\n        ))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, usize)> {\n    Box::new(UnsignedVecUnsignedPairGeneratorVar3 {\n        phantom: PhantomData,\n        xs: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// var 4 is in malachite-nz\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed.fork(\"log_bases\"),\n                1,\n                T::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::MAX,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct PowerOf2DigitsGenerator<T: PrimitiveUnsigned> {\n    log_bases: GeometricRandomNaturalValues<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    digit_map: HashMap<u64, StripedRandomUnsignedBitChunks<T>>,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for PowerOf2DigitsGenerator<T> {\n    type Item = (Vec<T>, u64);\n\n    fn next(&mut self) -> Option<(Vec<T>, u64)> {\n        let log_base = self.log_bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mean_stripe_n = self.mean_stripe_n;\n        let mean_stripe_d = self.mean_stripe_d;\n        let digits = self.digit_map.entry(log_base).or_insert_with(|| {\n            striped_random_unsigned_bit_chunks(\n                EXAMPLE_SEED.fork(&log_base.to_string()),\n                log_base,\n                mean_stripe_n,\n                mean_stripe_d,\n            )\n        });\n        let digits = digits.take(digit_count).collect_vec();\n        Some((digits, log_base))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(PowerOf2DigitsGenerator::<T> {\n        log_bases: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            1,\n            T::WIDTH,\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_count\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        digit_map: HashMap::new(),\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        phantom: PhantomData,\n    })\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_inclusive_range(\n                seed.fork(\"log_bases\"),\n                1,\n                T::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_9<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed.fork(\"base\"),\n                U::TWO,\n                U::saturating_from(T::MAX),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_10<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_11<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_unsigned_inclusive_range(\n                seed,\n                U::exact_from(3),\n                U::MAX,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_12<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_13<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_14<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_unsigned_n\", 4),\n                    config.get_or(\"mean_small_unsigned_d\", 1),\n                )\n            },\n        )\n        .filter(|(xs, y)| *y < U::exact_from(xs.len() << T::LOG_WIDTH)),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_15<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_16<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_17<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\n// var 18 is in malachite-nz\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_19<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_20<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_21<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::power_of_2(U::WIDTH - 1),\n                U::MAX,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_22<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_range(\n                seed,\n                U::ONE,\n                U::power_of_2(U::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_23<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                U::power_of_2(U::WIDTH - 1),\n                U::MAX,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_24<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_range(\n                seed,\n                U::ONE,\n                U::power_of_2(U::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_25<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_range(\n                seed,\n                U::ONE,\n                U::power_of_2(U::WIDTH - 2),\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// vars 26 through 27 are in malachite-nz.\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_28<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_unsigned_inclusive_range(\n                seed,\n                U::TWO,\n                U::MAX,\n                config.get_or(\"mean_small_unsigned_n\", 4),\n                config.get_or(\"mean_small_unsigned_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_29<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed.fork(\"log_bases\"),\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_30<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigned_range(\n                seed.fork(\"log_bases\"),\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_log_base_n\", 4),\n                config.get_or(\"mean_log_base_d\", 1),\n            )\n        },\n    ))\n}\n\n// --(Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n    V: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, V)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct UnsignedVecUnsignedUnsignedTripleGeneratorVar1<T: PrimitiveUnsigned> {\n    phantom: PhantomData<*const T>,\n    is: GeometricRandomNaturalValues<usize>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedVecUnsignedUnsignedTripleGeneratorVar1<T> {\n    type Item = (Vec<T>, usize, usize);\n\n    fn next(&mut self) -> Option<(Vec<T>, usize, usize)> {\n        let i = self.is.next().unwrap();\n        let j = self.is.next().unwrap();\n        let excess = self.is.next().unwrap();\n        let xs = get_striped_unsigned_vec(\n            &mut self.striped_bit_source,\n            u64::exact_from(i * j + excess) << T::LOG_WIDTH,\n        );\n        Some((xs, i, j))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, usize, usize)> {\n    Box::new(UnsignedVecUnsignedUnsignedTripleGeneratorVar1 {\n        phantom: PhantomData,\n        is: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"is\"),\n            config.get_or(\"small_unsigned_mean_n\", 2),\n            config.get_or(\"small_unsigned_mean_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, z)| if y <= z { (xs, y, z) } else { (xs, z, y) }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_4<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| !slice_test_zero(xs))\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, z)| if y <= z { (xs, y, z) } else { (xs, z, y) }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// var 6 is in malachite-nz.\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_8<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// var 9 is in malachite-nz.\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::ZERO,\n                T::low_mask(T::WIDTH - 1),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n            .map(|u| (u << 1) | T::ONE)\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// vars 11 through 12 are in malachite-nz.\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_13<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n// var 14 is in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_unsigned_vec_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_rounding_mode_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| !slice_test_zero(xs))\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 4),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\npub fn special_random_unsigned_vec_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(striped_random_unsigned_vecs(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_length_n\", 4),\n        config.get_or(\"mean_length_d\", 1),\n    )))\n}\n\npub struct UnsignedVecPairLenGenerator1<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> Iterator\n    for UnsignedVecPairLenGenerator1<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, j << T::LOG_WIDTH),\n        ))\n    }\n}\n\nfn special_random_unsigned_vec_pair_gen_var_1_helper<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n    seed: Seed,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds(\n            seed.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        striped_bit_source: StripedBitSource::new(\n            seed.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_unsigned_vec_pair_gen_var_1_helper(config, EXAMPLE_SEED)\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n    ))\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        random_pairs_from_single(striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter(|(xs, es)| {\n            !xs.is_empty()\n                && (es.len() > 1 || es.len() == 1 && es[0] > T::ONE)\n                && *es.last().unwrap() != T::ZERO\n        }),\n    )\n}\n\nstruct UnsignedVecSqrtRemGenerator<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    striped_bit_source: StripedBitSource,\n    hi_n_bits: StripedRandomUnsignedInclusiveRange<T>,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> Iterator\n    for UnsignedVecSqrtRemGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (out_len, len) = self.lengths.next().unwrap();\n        let out = get_striped_unsigned_vec(&mut self.striped_bit_source, out_len << T::LOG_WIDTH);\n        let mut ns: Vec<T> =\n            get_striped_unsigned_vec(&mut self.striped_bit_source, len << T::LOG_WIDTH);\n        let n_hi = &mut ns[(usize::exact_from(out_len) << 1) - 1];\n        n_hi.mod_power_of_2_assign(T::WIDTH - 2);\n        *n_hi |= self.hi_n_bits.next().unwrap() << (T::WIDTH - 2);\n        Some((out, ns))\n    }\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecSqrtRemGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let out_len = x.checked_add(2)?;\n            let len: u64 = out_len.arithmetic_checked_shl(1)?;\n            let len = len.checked_add(y)?;\n            Some((out_len, len))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        hi_n_bits: striped_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"hi_n_bits\"),\n            T::ONE,\n            T::exact_from(4),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct UnsignedVecSqrtGenerator<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> Iterator\n    for UnsignedVecSqrtGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (out_len, len) = self.lengths.next().unwrap();\n        let out = get_striped_unsigned_vec(&mut self.striped_bit_source, out_len << T::LOG_WIDTH);\n        let mut ns: Vec<T> =\n            get_striped_unsigned_vec(&mut self.striped_bit_source, len << T::LOG_WIDTH);\n        let hi_n = ns.last_mut().unwrap();\n        if *hi_n == T::ZERO {\n            *hi_n = T::ONE;\n        }\n        Some((out, ns))\n    }\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecSqrtGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let in_len = x.checked_add(1)?;\n            let mut out_len: u64 = in_len.shr_round(1, Ceiling).0;\n            out_len = out_len.checked_add(y)?;\n            Some((out_len, in_len))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct UnsignedVecPairSameLenGenerator<T: PrimitiveUnsigned, I: Iterator<Item = u64>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = u64>> Iterator\n    for UnsignedVecPairSameLenGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let len = self.lengths.next().unwrap() << T::LOG_WIDTH;\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, len),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, len),\n        ))\n    }\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairSameLenGenerator {\n        phantom: PhantomData,\n        lengths: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(\n        striped_random_unsigned_vecs(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| xs.last() != Some(&T::ZERO)),\n    ))\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| !slice_test_zero(xs)),\n    ))\n}\n\npub struct UnsignedVecPairLenGenerator2<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> Iterator\n    for UnsignedVecPairLenGenerator2<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        let mut xs;\n        loop {\n            xs = get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH);\n            if !slice_test_zero(&xs) {\n                break;\n            }\n        }\n        let mut ys;\n        loop {\n            ys = get_striped_unsigned_vec(&mut self.striped_bit_source, j << T::LOG_WIDTH);\n            if !slice_test_zero(&ys) {\n                break;\n            }\n        }\n        Some((xs, ys))\n    }\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// var 11 is in malachite-nz.\n\npub fn special_random_unsigned_vec_pair_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(_, ds)| *ds.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_13<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(xs, mut ys)| {\n            ys[0] |= T::ONE;\n            (xs, ys)\n        }),\n    )\n}\n\n// vars 14 through 15 are in malachite-nz.\n\npub fn special_random_unsigned_vec_pair_gen_var_16<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(xs, ys)| *xs.last().unwrap() != T::ZERO && *ys.last().unwrap() != T::ZERO),\n    )\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_17<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(xs, ys)| *xs.last().unwrap() != T::ZERO && *ys.last().unwrap() != T::ZERO),\n    )\n}\n\n// var 18 is in malachite-nz.\n\npub fn special_random_unsigned_vec_pair_gen_var_19<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    T::power_of_2(T::WIDTH - 1),\n                    T::MAX,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_unsigned_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_unsigned_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|(n, d_1, d_0)| (n, vec![d_0, d_1])),\n    )\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_20<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(random_pairs_from_single(\n        striped_random_unsigned_vecs_min_length::<T>(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter_map(|mut xs| {\n            let last = xs.last_mut().unwrap();\n            *last = last.checked_add(T::ONE)?;\n            Some(xs)\n        }),\n    ))\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_21<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            2,\n            u64::MAX,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// vars 22 through 31 are in malachite-nz.\n\npub fn special_random_unsigned_vec_pair_gen_var_32<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_33<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecPairSameLenGenerator {\n            phantom: PhantomData,\n            lengths: geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(xs, ys): &(Vec<T>, Vec<T>)| {\n            (*xs.last().unwrap() != T::ZERO || *ys.last().unwrap() != T::ZERO) && ys[0].odd()\n        }),\n    )\n}\n\n// var 34 is in malachite-nz.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, bool) --\n\npub fn special_random_unsigned_vec_unsigned_vec_bool_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, bool)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| UnsignedVecPairSameLenGenerator {\n            phantom: PhantomData,\n            lengths: geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n            striped_bit_source: StripedBitSource::new(\n                seed.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        },\n        &random_bools,\n    )))\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| special_random_unsigned_vec_pair_gen_var_1_helper(config, seed),\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    )))\n}\n\n// var 2 and 3 are in malachite-nz\n\nfn special_random_unsigned_vec_pair_gen_var_2_helper<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n    seed: Seed,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            seed.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        striped_bit_source: StripedBitSource::new(\n            seed.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| special_random_unsigned_vec_pair_gen_var_2_helper(config, seed),\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    )))\n}\n\nstruct UnsignedVecPairLenGenerator3<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> Iterator\n    for UnsignedVecPairLenGenerator3<T, I>\n{\n    type Item = (Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        let xs = get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH);\n        let mut ys;\n        loop {\n            ys = get_striped_unsigned_vec(&mut self.striped_bit_source, j << T::LOG_WIDTH);\n            if !slice_test_zero(&ys) {\n                break;\n            }\n        }\n        Some((xs, ys))\n    }\n}\n\nfn special_random_unsigned_vec_pair_gen_var_3_helper<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n    seed: Seed,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator3 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n            seed.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n        striped_bit_source: StripedBitSource::new(\n            seed.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| special_random_unsigned_vec_pair_gen_var_3_helper(config, seed),\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    )))\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// vars 7 through 8 are in malachite-nz.\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, U)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub struct PrimitiveIntVecPairLenAndIndexGenerator<\n    T: PrimitiveUnsigned,\n    I: Iterator<Item = (u64, u64, u64)>,\n> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64)>> Iterator\n    for PrimitiveIntVecPairLenAndIndexGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, usize);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, usize)> {\n        let (i, j, k) = self.lengths.next().unwrap();\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, j << T::LOG_WIDTH),\n            usize::exact_from(k),\n        ))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, usize)> {\n    Box::new(PrimitiveIntVecPairLenAndIndexGenerator {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(y)?;\n            let o = o.checked_add(x)?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| UnsignedVecPairSameLenGenerator {\n            phantom: PhantomData,\n            lengths: geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ),\n            striped_bit_source: StripedBitSource::new(\n                seed.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    )))\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                seed.fork(\"lengths\"),\n                2,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                seed.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        },\n        &|seed| {\n            striped_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    )))\n}\n\n// vars 14 through 21 are in malachite-nz.\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, u64)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| special_random_unsigned_vec_pair_gen_var_1_helper(config, seed),\n        &|seed| {\n            striped_random_unsigned_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    )))\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, u64)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                seed.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        },\n        &|seed| {\n            striped_random_unsigned_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_stripe_n\", U::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    )))\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, usize)> {\n    Box::new(PrimitiveIntVecPairLenAndIndexGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, i)| {\n            let x = x.checked_add(i)?;\n            Some((x, x, i))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\npub struct UnsignedVecTripleXYYLenGenerator<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64)>> Iterator\n    for UnsignedVecTripleXYYLenGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (i, j) = self.lengths.next().unwrap();\n        let shifted_j = j << T::LOG_WIDTH;\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, shifted_j),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, shifted_j),\n        ))\n    }\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(y.arithmetic_checked_shl(1)?)?;\n            Some((x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub struct UnsignedVecTripleLenGenerator1<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64)>>\n{\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64)>> Iterator\n    for UnsignedVecTripleLenGenerator1<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (i, j, k) = self.lengths.next().unwrap();\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, j << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, k << T::LOG_WIDTH),\n        ))\n    }\n}\n\npub struct UnsignedVecQuadrupleLenGenerator1<\n    T: PrimitiveUnsigned,\n    I: Iterator<Item = (u64, u64, u64, u64)>,\n> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64, u64)>> Iterator\n    for UnsignedVecQuadrupleLenGenerator1<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<Self::Item> {\n        let (i, j, k, l) = self.lengths.next().unwrap();\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, j << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, k << T::LOG_WIDTH),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, l << T::LOG_WIDTH),\n        ))\n    }\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(y)?;\n            let o = x.checked_add(y)?.checked_add(o)?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(1)?;\n            let o = x.checked_add(y)?.checked_add(o)?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// vars 4 through 23 are in malachite-nz\n\npub fn special_random_unsigned_vec_triple_gen_var_24<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(1)?;\n            let x = x.checked_add(y)?;\n            Some((x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_25<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(2)?;\n            let x = x.checked_add(y.arithmetic_checked_shl(1)?)?;\n            Some((x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_26<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let y = y.checked_add(2)?;\n            let x = x.checked_add(y)?;\n            Some((x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct UnsignedVecTripleXXXLenGenerator<T: PrimitiveUnsigned, I: Iterator<Item = u64>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = u64>> Iterator\n    for UnsignedVecTripleXXXLenGenerator<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let i = self.lengths.next().unwrap() << T::LOG_WIDTH;\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, i),\n        ))\n    }\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_27<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXXXLenGenerator {\n        phantom: PhantomData,\n        lengths: geometric_random_unsigned_range(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            2,\n            u64::MAX,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct UnsignedVecSqrtRemGenerator3<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64)>> {\n    phantom: PhantomData<*const T>,\n    lengths: I,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64)>> Iterator\n    for UnsignedVecSqrtRemGenerator3<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (out_len, rs_len, len) = self.lengths.next().unwrap();\n        let out = get_striped_unsigned_vec(&mut self.striped_bit_source, out_len << T::LOG_WIDTH);\n        let rs = get_striped_unsigned_vec(&mut self.striped_bit_source, rs_len << T::LOG_WIDTH);\n        let mut ns: Vec<T> =\n            get_striped_unsigned_vec(&mut self.striped_bit_source, len << T::LOG_WIDTH);\n        let hi_n = ns.last_mut().unwrap();\n        if *hi_n == T::ZERO {\n            *hi_n = T::ONE;\n        }\n        Some((out, rs, ns))\n    }\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_28<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecSqrtRemGenerator3 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y, z)| {\n            let in_len = x.checked_add(1)?;\n            let mut out_len: u64 = in_len.shr_round(1, Ceiling).0;\n            out_len = out_len.checked_add(y)?;\n            let rem_len = in_len.checked_add(z)?;\n            Some((out_len, rem_len, in_len))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_29<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXXXLenGenerator {\n        phantom: PhantomData,\n        lengths: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_30<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_from_single(\n        striped_random_unsigned_vecs(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| xs.last() != Some(&T::ZERO)),\n    ))\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_31<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(x, y)| {\n            let x = x.checked_add(y)?;\n            Some((x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_32<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let o = max(x, y).checked_add(o)?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct UnsignedVecTripleLenGenerator2<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64)>> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: I,\n    pub striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned, I: Iterator<Item = (u64, u64, u64)>> Iterator\n    for UnsignedVecTripleLenGenerator2<T, I>\n{\n    type Item = (Vec<T>, Vec<T>, Vec<T>);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, Vec<T>)> {\n        let (i, j, k) = self.lengths.next().unwrap();\n        let out = get_striped_unsigned_vec(&mut self.striped_bit_source, i << T::LOG_WIDTH);\n        let mut xs;\n        loop {\n            xs = get_striped_unsigned_vec(&mut self.striped_bit_source, j << T::LOG_WIDTH);\n            if !slice_test_zero(&xs) {\n                break;\n            }\n        }\n        let mut ys;\n        loop {\n            ys = get_striped_unsigned_vec(&mut self.striped_bit_source, k << T::LOG_WIDTH);\n            if !slice_test_zero(&ys) {\n                break;\n            }\n        }\n        Some((out, xs, ys))\n    }\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_33<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(1)?;\n            let y = y.checked_add(1)?;\n            let o = o.checked_add(x)?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_34<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(1)?;\n            let y = y.checked_add(1)?;\n            let o = o.checked_add(max(x, y))?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_35<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator2 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(1)?;\n            let y = y.checked_add(1)?;\n            let o = o.checked_add(min(x, y))?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_36<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_from_single(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            2,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    ))\n}\n\n// vars 37 through 38 are in malachite-nz.\n\npub fn special_random_unsigned_vec_triple_gen_var_39<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_from_single(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .filter(|xs| *xs.last().unwrap() != T::ZERO),\n    ))\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_40<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(|(o, x, y)| {\n            let x = x.checked_add(y)?;\n            let o = o.checked_add(x)?;\n            Some((o, x, y))\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_41<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                1,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != T::ZERO)\n        },\n    ))\n}\n\n// vars 42 through 49 are in malachite-nz.\n\npub fn special_random_unsigned_vec_triple_gen_var_50<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y, z)| {\n                let y = y.checked_add(1)?;\n                let x = x.checked_add(y)?;\n                let z = z.checked_add(y.arithmetic_checked_shl(1)?)?;\n                Some((x, y, z))\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(x, mut y, z): (Vec<T>, Vec<T>, Vec<T>)| {\n            y.last_mut().unwrap().set_bit(T::WIDTH - 1);\n            (x, y, z)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_51<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y, z)| {\n                let y = y.checked_add(5)?;\n                let x = x.checked_add(y)?;\n                let z = z.checked_add(y.arithmetic_checked_shl(1)?)?;\n                Some((x, y, z))\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(x, mut y, z): (Vec<T>, Vec<T>, Vec<T>)| {\n            y.last_mut().unwrap().set_bit(T::WIDTH - 1);\n            (x, y, z)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_52<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y, z)| {\n                let q = x.checked_add(3)?;\n                let n = y.checked_add(9)?;\n                let d = z.checked_add(6)?;\n                if n < d {\n                    return None;\n                }\n                let q_alt = n - d + 1;\n                if (q_alt << 1) > n || q_alt > d {\n                    return None;\n                }\n                let n_alt = q_alt << 1;\n                let d_alt = q_alt;\n                if q >= q_alt && d_alt >= 6 && n_alt >= d_alt + 3 && d_alt >= q_alt {\n                    Some((q, n, d))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(x, y, mut z): (Vec<T>, Vec<T>, Vec<T>)| {\n            z.last_mut().unwrap().set_bit(T::WIDTH - 1);\n            (x, y, z)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_53<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigneds(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter(|&(x, y)| y >= 2 && x >= y - 2),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_unsigned_inclusive_range(\n                            seed_2,\n                            T::power_of_2(T::WIDTH - 1),\n                            T::MAX,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed| {\n                        striped_random_unsigneds(\n                            seed,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n            },\n        )\n        .map(|((q, n), (d_1, d_0))| (q, n, vec![d_0, d_1])),\n    )\n}\n\n// vars 54 through 56 are in malachite-nz.\n\npub fn special_random_unsigned_vec_triple_gen_var_57<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(r_len, n_len, d_len)| {\n                let d_len = d_len.checked_add(2)?;\n                let r_len = r_len.checked_add(d_len)?;\n                let n_len = n_len.checked_add(d_len)?;\n                Some((r_len, n_len, d_len))\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter_map(|(r, n, mut d): (Vec<T>, Vec<T>, Vec<T>)| {\n            let last_d = d.last_mut().unwrap();\n            *last_d = last_d.checked_add(T::ONE)?;\n            Some((r, n, d))\n        }),\n    )\n}\n\n// var 58 is in malachite-nz.\n\npub fn special_random_unsigned_vec_triple_gen_var_59<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(xs_len, ys_len, zs_len)| {\n                let ys_len = ys_len.checked_add(2)?;\n                let zs_len = zs_len.checked_add(2)?;\n                let xs_len = xs_len.checked_add(ys_len + zs_len - 1)?;\n                Some((xs_len, ys_len, zs_len))\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter_map(|(mut xs, mut ys, mut zs): (Vec<T>, Vec<T>, Vec<T>)| {\n            let last_x = xs.last_mut().unwrap();\n            *last_x = last_x.checked_add(T::ONE)?;\n            let last_y = ys.last_mut().unwrap();\n            *last_y = last_y.checked_add(T::ONE)?;\n            let last_z = zs.last_mut().unwrap();\n            *last_z = last_z.checked_add(T::ONE)?;\n            Some((xs, ys, zs))\n        }),\n    )\n}\n\n// var 60 is in malachite-nz.\n\n// -- large types --\n\npub fn special_random_large_type_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, T, T)> {\n    reshape_2_2_to_4(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| special_random_unsigned_vec_pair_gen_var_1_helper(config, seed),\n        &|seed| {\n            random_pairs_from_single(striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ))\n        },\n    )))\n}\n\nstruct UnsignedVecSqrtRemGenerator2<T: PrimitiveUnsigned> {\n    pub phantom: PhantomData<*const T>,\n    pub lengths: GeometricRandomNaturalValues<u64>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for UnsignedVecSqrtRemGenerator2<T> {\n    type Item = (Vec<T>, Vec<T>, u64, bool);\n\n    fn next(&mut self) -> Option<(Vec<T>, Vec<T>, u64, bool)> {\n        let len = self.lengths.next().unwrap();\n        let n = len.shr_round(1, Ceiling).0;\n        let out = get_striped_unsigned_vec(&mut self.striped_bit_source, n << T::LOG_WIDTH);\n        let mut ns: Vec<T> =\n            get_striped_unsigned_vec(&mut self.striped_bit_source, len << T::LOG_WIDTH);\n        let last = ns.last_mut().unwrap();\n        if *last == T::ZERO {\n            *last = T::ONE;\n        }\n        let shift = last.leading_zeros() >> 1;\n        Some((out, ns, shift, len.odd()))\n    }\n}\n\npub fn special_random_large_type_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, u64, bool)> {\n    Box::new(UnsignedVecSqrtRemGenerator2 {\n        phantom: PhantomData,\n        lengths: geometric_random_unsigned_range::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            9,\n            u64::MAX,\n            config.get_or(\"mean_length_n\", 12),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_large_type_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U, Vec<T>)> {\n    Box::new(\n        random_quadruples_xyyx::<_, _, U, _>(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\npub fn special_random_large_type_gen_var_4<T: PrimitiveUnsigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, U, U, Vec<T>)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| !slice_test_zero(xs))\n            },\n            &|seed| {\n                geometric_random_unsigneds::<U>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigned_vecs::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\n// vars 5 through 8 are in malachite-nz\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>, bool)> {\n    reshape_3_1_to_4(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| UnsignedVecTripleXYYLenGenerator {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y)| {\n                let x = x.checked_add(y)?;\n                Some((x, y))\n            }),\n            striped_bit_source: StripedBitSource::new(\n                seed.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        },\n        &random_bools,\n    )))\n}\n\n// vars 10 through 21 are in malachite-nz.\n\npub fn special_random_large_type_gen_var_22<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(RationalSequence<T>, usize, T, T)> {\n    Box::new(\n        random_quadruples_xyzz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rational_sequences(\n                    seed,\n                    &|seed_2| {\n                        striped_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_unsigned_n\", 32),\n                    config.get_or(\"mean_small_unsigned_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(|&(ref xs, index, _, _)| {\n            if let Some(len) = xs.len() {\n                index < len\n            } else {\n                true\n            }\n        }),\n    )\n}\n\n// vars 23 through 24 are in malachite-nz.\n\npub fn special_random_large_type_gen_var_25<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(bool, Vec<T>, bool, Vec<T>)> {\n    Box::new(random_quadruples_xyxy(\n        EXAMPLE_SEED,\n        &random_bools,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| xs.last() != Some(&T::ZERO))\n        },\n    ))\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/hash/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse std::collections::hash_map::DefaultHasher;\nuse std::hash::{Hash, Hasher};\n\npub fn hash<T: Hash>(n: &T) -> u64 {\n    let mut s = DefaultHasher::new();\n    n.hash(&mut s);\n    s.finish()\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod bench;\npub mod common;\npub mod extra_variadic;\npub mod generators;\npub mod hash;\npub mod num;\npub mod rounding_modes;\npub mod runner;\npub mod sets;\npub mod slices;\npub mod stats;\npub mod vecs;\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\n\npub fn extended_gcd_unsigned_euclidean<\n    U: PrimitiveUnsigned,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    a: U,\n    b: U,\n) -> (U, S, S) {\n    if a == U::ZERO && b == U::ZERO {\n        (U::ZERO, S::ZERO, S::ZERO)\n    } else if a == b || a == U::ZERO {\n        (b, S::ZERO, S::ONE)\n    } else {\n        let (gcd, x, y) = extended_gcd_unsigned_euclidean(b % a, a);\n        (gcd, y - S::wrapping_from(b / a) * x, x)\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::logic::traits::NotAssign;\n\npub fn checked_factorial_naive<T: PrimitiveUnsigned>(n: u64) -> Option<T> {\n    let mut f = T::ONE;\n    let mut n = T::try_from(n).ok()?;\n    while n != T::ZERO {\n        f = f.checked_mul(n)?;\n        n -= T::ONE;\n    }\n    Some(f)\n}\n\npub fn checked_double_factorial_naive<T: PrimitiveUnsigned>(n: u64) -> Option<T> {\n    let mut f = T::ONE;\n    let mut n = T::try_from(n).ok()?;\n    while n != T::ZERO {\n        f = f.checked_mul(n)?;\n        n.saturating_sub_assign(T::TWO);\n    }\n    Some(f)\n}\n\npub fn checked_subfactorial_naive<T: PrimitiveUnsigned>(n: u64) -> Option<T> {\n    let mut f = T::ONE;\n    let mut b = true;\n    for i in 1..=n {\n        f = f.checked_mul(T::try_from(i).ok()?)?;\n        if b {\n            f -= T::ONE;\n        } else {\n            f = f.checked_add(T::ONE)?;\n        }\n        b.not_assign();\n    }\n    Some(f)\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1996, 1998, 1999-2002, 2000-2004, 2008, 2010 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{NegAssign, Parity};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{HasHalf, JoinHalves};\nuse crate::num::logic::traits::NotAssign;\nuse std::mem::swap;\n\n// This is equivalent to `n_jacobi_unsigned` from `ulong_extras/jacobi.c`, FLINT 2.7.1.\npub fn jacobi_symbol_unsigned_fast_1<T: PrimitiveUnsigned>(x: T, y: T) -> i8 {\n    let mut a = x;\n    let mut b = y;\n    let mut s = 1;\n    if a < b && b != T::ONE {\n        if a == T::ZERO {\n            return 0;\n        }\n        swap(&mut a, &mut b);\n        let exp = b.trailing_zeros();\n        b >>= exp;\n        if T::wrapping_from(exp)\n            .wrapping_mul(a.wrapping_square() - T::ONE)\n            .get_bit(3)\n            != (a - T::ONE).wrapping_mul(b - T::ONE).get_bit(2)\n        {\n            s.neg_assign();\n        }\n    }\n    while b != T::ONE {\n        if a >> 2 < b {\n            let temp = a - b;\n            a = b;\n            b = if temp < b {\n                temp\n            } else if temp < b << 1 {\n                temp - a\n            } else {\n                temp - (a << 1)\n            }\n        } else {\n            a %= b;\n            swap(&mut a, &mut b);\n        }\n        if b == T::ZERO {\n            return 0;\n        }\n        let exp = b.trailing_zeros();\n        b >>= exp;\n        if T::wrapping_from(exp)\n            .wrapping_mul(a.wrapping_square() - T::ONE)\n            .get_bit(3)\n            != (a - T::ONE).wrapping_mul(b - T::ONE).get_bit(2)\n        {\n            s.neg_assign();\n        }\n    }\n    s\n}\n\n// This is equivalent to `mpn_jacobi_base` from `mpn/jacbase.c`, GMP 6.2.1, where\n// `JACOBI_BASE_METHOD == 1` and `result_bit_1` is false.\npub fn jacobi_symbol_unsigned_fast_2_1<T: PrimitiveUnsigned>(mut a: T, mut b: T) -> i8 {\n    assert!(b.odd());\n    if b == T::ONE {\n        return 1;\n    } else if a == T::ZERO {\n        return 0;\n    }\n    let mut s = 1;\n    let a_twos = a.trailing_zeros();\n    if a_twos.odd() && ((b >> 1u32) ^ b).get_bit(1) {\n        s.neg_assign();\n    }\n    a >>= a_twos;\n    if a == T::ONE {\n        return s;\n    }\n    if a < b {\n        if (a & b).get_bit(1) {\n            s.neg_assign();\n        }\n        swap(&mut a, &mut b);\n    }\n    loop {\n        assert!(a.odd());\n        assert!(b.odd());\n        assert!(a >= b);\n        a -= b;\n        if a == T::ZERO {\n            return 0;\n        }\n        let a_twos = a.trailing_zeros();\n        if a_twos.odd() && ((b >> 1u32) ^ b).get_bit(1) {\n            s.neg_assign();\n        }\n        a >>= a_twos;\n        if a == T::ONE {\n            return s;\n        }\n        if a < b {\n            if (a & b).get_bit(1) {\n                s.neg_assign();\n            }\n            swap(&mut a, &mut b);\n        }\n    }\n}\n\n// This is equivalent to `mpn_jacobi_base` from `mpn/jacbase.c`, GMP 6.2.1, where\n// `JACOBI_BASE_METHOD == 2` and `result_bit_1` is false.\npub fn jacobi_symbol_unsigned_fast_2_2<T: PrimitiveUnsigned>(mut a: T, mut b: T) -> i8 {\n    assert!(b.odd());\n    if b == T::ONE {\n        return 1;\n    } else if a == T::ZERO {\n        return 0;\n    }\n    let mut s = 1;\n    if a.even() {\n        let two = (b >> 1u32) ^ b;\n        loop {\n            a >>= 1;\n            if two.get_bit(1) {\n                s.neg_assign();\n            }\n            if a.odd() {\n                break;\n            }\n        }\n    }\n    if a == T::ONE {\n        return s;\n    }\n    if a < b {\n        if (a & b).get_bit(1) {\n            s.neg_assign();\n        }\n        swap(&mut a, &mut b);\n    }\n    loop {\n        assert!(a.odd());\n        assert!(b.odd());\n        assert!(a >= b);\n        a -= b;\n        if a == T::ZERO {\n            return 0;\n        }\n        let two = (b >> 1u32) ^ b;\n        loop {\n            a >>= 1;\n            if two.get_bit(1) {\n                s.neg_assign();\n            }\n            if a.odd() {\n                break;\n            }\n        }\n        if a == T::ONE {\n            return s;\n        }\n        if a < b {\n            if (a & b).get_bit(1) {\n                s.neg_assign();\n            }\n            swap(&mut a, &mut b);\n        }\n    }\n}\n\n// This is equivalent to `mpn_jacobi_base` from `mpn/jacbase.c`, GMP 6.2.1, where\n// `JACOBI_BASE_METHOD == 3` and `result_bit_1` is false.\npub fn jacobi_symbol_unsigned_fast_2_3<T: PrimitiveUnsigned>(mut a: T, mut b: T) -> i8 {\n    assert!(b.odd());\n    if b == T::ONE {\n        return 1;\n    } else if a == T::ZERO {\n        return 0;\n    }\n    let mut s = 1;\n    let two = (b >> 1u32) ^ b;\n    let shift = !a & T::ONE;\n    let shift_8: u8 = shift.wrapping_into();\n    a >>= shift_8;\n    let mask = shift << 1u32;\n    if (two & mask).get_bit(1) {\n        s.neg_assign();\n    }\n    let two_bit = two.get_bit(1);\n    while a.even() {\n        a >>= 1;\n        if two_bit {\n            s.neg_assign();\n        }\n    }\n    if a == T::ONE {\n        return s;\n    }\n    if a < b {\n        if (a & b).get_bit(1) {\n            s.neg_assign();\n        }\n        swap(&mut a, &mut b);\n    }\n    loop {\n        assert!(a.odd());\n        assert!(b.odd());\n        assert!(a >= b);\n        a -= b;\n        if a == T::ZERO {\n            return 0;\n        }\n        let two = (b >> 1u32) ^ b;\n        let mask = !a & T::TWO;\n        a >>= 1;\n        if a.even() {\n            a >>= 1;\n        }\n        if (two ^ (two & mask)).get_bit(1) {\n            s.neg_assign();\n        }\n        while a.even() {\n            a >>= 1;\n            if two.get_bit(1) {\n                s.neg_assign();\n            }\n        }\n        if a == T::ONE {\n            return s;\n        }\n        if a < b {\n            if (a & b).get_bit(1) {\n                s.neg_assign();\n            }\n            swap(&mut a, &mut b);\n        }\n    }\n}\n\n// This is equivalent to `mpn_jacobi_base` from `mpn/jacbase.c`, GMP 6.2.1, where\n// `JACOBI_BASE_METHOD == 4` and `result_bit_1` is false.\npub fn jacobi_symbol_unsigned_fast_2_4<T: PrimitiveUnsigned>(mut a: T, mut b: T) -> i8 {\n    assert!(b.odd());\n    if b == T::ONE {\n        return 1;\n    } else if a == T::ZERO {\n        return 0;\n    }\n    let mut s = 1;\n    b >>= 1u32;\n    let c = a.trailing_zeros();\n    if (T::wrapping_from(c) & (b ^ (b >> 1))).odd() {\n        s.neg_assign();\n    }\n    // We may have c == T::WIDTH - 1, so we can't use a >> (c + 1).\n    a >>= c;\n    a >>= 1;\n    while b != T::ZERO {\n        let t = a.wrapping_sub(b);\n        if t == T::ZERO {\n            return 0;\n        }\n        let bgta = if t.get_highest_bit() { T::MAX } else { T::ZERO };\n        // If b > a, invoke reciprocity\n        if (bgta & a & b).odd() {\n            s.neg_assign();\n        }\n        // b <-- min (a, b)\n        b.wrapping_add_assign(bgta & t);\n        // a <-- |a - b|\n        a = (t ^ bgta).wrapping_sub(bgta);\n        // Number of trailing zeros is the same no matter if we look at t or a, but using t gives\n        // more parallelism.\n        let c = t.trailing_zeros() + 1;\n        // (2/b) = -1 if b = 3 or 5 mod 8\n        if (T::wrapping_from(c) & (b ^ (b >> 1))).odd() {\n            s.neg_assign();\n        }\n        a >>= c;\n    }\n    s\n}\n\npub fn jacobi_symbol_unsigned_double_simple<\n    T: PrimitiveUnsigned,\n    D: HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned,\n>(\n    x_1: T,\n    x_0: T,\n    y_1: T,\n    y_0: T,\n) -> i8 {\n    D::join_halves(x_1, x_0).jacobi_symbol(D::join_halves(y_1, y_0))\n}\n\n// Computes (a / b) where b is odd, and a and b are otherwise arbitrary two-limb numbers.\n//\n// This is equivalent to `mpn_jacobi_2` from `mpn/jacobi_2.c`, GMP 6.2.1, where `JACOBI_2_METHOD ==\n// 1` and `bit` is 0.\npub fn jacobi_symbol_unsigned_double_fast_1<T: PrimitiveUnsigned>(\n    mut x_1: T,\n    mut x_0: T,\n    mut y_1: T,\n    mut y_0: T,\n) -> i8 {\n    assert!(y_0.odd());\n    y_0 = (y_1 << (T::WIDTH - 1)) | (y_0 >> 1);\n    y_1 >>= 1;\n    if y_1 == T::ZERO && y_0 == T::ZERO {\n        return 1;\n    }\n    if x_1 == T::ZERO && x_0 == T::ZERO {\n        return 0;\n    }\n    if x_0 == T::ZERO {\n        x_0 = x_1;\n        x_1 = T::ZERO;\n    }\n    let mut bit = false;\n    let c = x_0.trailing_zeros() + 1;\n    if c.even() && (y_0 ^ (y_0 >> 1)).odd() {\n        bit.not_assign();\n    }\n    if c == T::WIDTH {\n        x_0 = x_1;\n        x_1 = T::ZERO;\n    } else {\n        x_0 = (x_1 << (T::WIDTH - c)) | (x_0 >> c);\n        x_1 >>= c;\n    }\n    while x_1 != T::ZERO || y_1 != T::ZERO {\n        let (diff_1, diff_0) = T::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0);\n        if diff_0 == T::ZERO && diff_1 == T::ZERO {\n            return 0;\n        }\n        let mask = if diff_1.get_highest_bit() {\n            T::MAX\n        } else {\n            T::ZERO\n        };\n        // If y > x, invoke reciprocity\n        if (mask & x_0 & y_0).odd() {\n            bit.not_assign();\n        }\n        // y <- min(x, y)\n        (y_1, y_0) = T::xx_add_yy_to_zz(y_1, y_0, diff_1 & mask, diff_0 & mask);\n        if y_1 == T::ZERO && y_0 == T::ZERO {\n            return if bit { -1 } else { 1 };\n        }\n        // x <- |x - y|\n        x_0 = (mask ^ diff_0).wrapping_sub(mask);\n        x_1 = mask ^ diff_1;\n        if x_0 == T::ZERO {\n            // If y > x, x_0 == 0 implies that we have a carry to propagate.\n            x_0 = x_1.wrapping_sub(mask);\n            x_1 = T::ZERO;\n        }\n        let c = x_0.trailing_zeros() + 1;\n        if c.odd() && (y_0 ^ (y_0 >> 1)).odd() {\n            bit.not_assign();\n        }\n        if c == T::WIDTH {\n            x_0 = x_1;\n            x_1 = T::ZERO;\n        } else {\n            x_0 = (x_1 << (T::WIDTH - c)) | (x_0 >> c);\n            x_1 >>= c;\n        }\n    }\n    assert_ne!(y_0, T::ZERO);\n    while (x_0 | y_0).get_highest_bit() {\n        // Need an extra comparison to get the mask.\n        let t = x_0.wrapping_sub(y_0);\n        let mask = if y_0 > x_0 { T::MAX } else { T::ZERO };\n        if t == T::ZERO {\n            return 0;\n        }\n        // If y > x, invoke reciprocity\n        if (mask & x_0 & y_0).odd() {\n            bit.not_assign();\n        }\n        // y <- min(x, y)\n        y_0.wrapping_add_assign(mask & t);\n        // x <- |x - y|\n        x_0 = (t ^ mask).wrapping_sub(mask);\n        // Number of trailing zeros is the same no matter if we look at t or x, but using t gives\n        // more parallelism.\n        let c = t.trailing_zeros() + 1;\n        // (2 / y) = -1 if y = 3 or 5 mod 8\n        if c.odd() && (y_0 ^ (y_0 >> 1)).odd() {\n            bit.not_assign();\n        }\n        if c == T::WIDTH {\n            return if bit { -1 } else { 1 };\n        }\n        x_0 >>= c;\n    }\n    let j = ((x_0 << 1u32) | T::ONE).jacobi_symbol((y_0 << 1u32) | T::ONE);\n    if bit { -j } else { j }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod extended_gcd;\npub mod factorial;\npub mod kronecker_symbol;\npub mod mod_inverse;\npub mod mod_mul;\npub mod mod_pow;\npub mod mod_power_of_2_inverse;\npub mod primorial;\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::test_util::num::arithmetic::extended_gcd::extended_gcd_unsigned_euclidean;\n\npub fn mod_inverse_euclidean<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    x: U,\n    m: U,\n) -> Option<U> {\n    assert_ne!(x, U::ZERO);\n    assert!(x < m);\n    let (gcd, inverse, _) = extended_gcd_unsigned_euclidean::<U, S>(x, m);\n    if gcd == U::ONE {\n        Some(if inverse >= S::ZERO {\n            U::wrapping_from(inverse)\n        } else {\n            U::wrapping_from(inverse).wrapping_add(m)\n        })\n    } else {\n        None\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::HasHalf;\n\npub fn limbs_invert_limb_naive<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned,\n>(\n    x: T,\n) -> T {\n    T::exact_from(DT::MAX / DT::from(x) - DT::power_of_2(T::WIDTH))\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\npub fn naive_mod_pow<T: PrimitiveUnsigned>(x: T, exp: u64, m: T) -> T {\n    if m == T::ONE {\n        return T::ZERO;\n    }\n    let data = T::precompute_mod_mul_data(&m);\n    let mut out = T::ONE;\n    for _ in 0..exp {\n        out.mod_mul_precomputed_assign(x, m, &data);\n    }\n    out\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/mod_power_of_2_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::test_util::num::arithmetic::extended_gcd::extended_gcd_unsigned_euclidean;\n\npub fn mod_power_of_2_inverse_euclidean<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>(\n    a: U,\n    pow: u64,\n) -> Option<U> {\n    assert_ne!(a, U::ZERO);\n    assert!(pow <= U::WIDTH);\n    assert!(a.significant_bits() <= pow);\n    if a.even() {\n        return None;\n    } else if a == U::ONE {\n        return Some(U::ONE);\n    }\n    Some(if pow == U::WIDTH {\n        let (q, r) = U::xx_div_mod_y_to_qr(U::ONE, U::ZERO, a);\n        let (_, x, y) = extended_gcd_unsigned_euclidean(r, a);\n        U::wrapping_from(y - S::wrapping_from(q) * x)\n    } else {\n        let m = U::power_of_2(pow);\n        let (_, x, _) = extended_gcd_unsigned_euclidean::<U, S>(a, m);\n        if x >= S::ZERO {\n            U::wrapping_from(x)\n        } else {\n            U::wrapping_from(x).wrapping_add(m)\n        }\n    })\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\n\npub fn checked_primorial_naive<T: PrimitiveUnsigned>(n: u64) -> Option<T> {\n    let n = T::try_from(n).ok()?;\n    let mut f = T::ONE;\n    for p in T::primes().take_while(|&p| p <= n) {\n        f = f.checked_mul(p)?;\n    }\n    Some(f)\n}\n\npub fn checked_product_of_first_n_primes_naive<T: PrimitiveUnsigned>(n: u64) -> Option<T> {\n    let mut f = T::ONE;\n    for p in T::primes().take(usize::try_from(n).ok()?) {\n        f = f.checked_mul(p)?;\n    }\n    Some(f)\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod string;\n"
  },
  {
    "path": "malachite-base/src/test_util/num/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub const DECIMAL_SCI_STRING_CHARS: &str = \"+-.0123456789Ee\";\n"
  },
  {
    "path": "malachite-base/src/test_util/num/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod from_sci_string;\npub mod to_string;\n"
  },
  {
    "path": "malachite-base/src/test_util/num/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{DivAssignMod, UnsignedAbs};\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::traits::Zero;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::string::to_string::digit_to_display_byte_lower;\nuse crate::num::conversion::traits::WrappingFrom;\n\npub fn to_string_base_unsigned_naive<T: PrimitiveUnsigned>(mut x: T, base: u8) -> String\nwhere\n    u8: WrappingFrom<T>,\n{\n    assert!((2..=36).contains(&base), \"base out of range\");\n    if x == T::ZERO {\n        \"0\".to_string()\n    } else {\n        let base = T::from(base);\n        let mut cs = Vec::new();\n        while x != T::ZERO {\n            cs.push(char::from(\n                digit_to_display_byte_lower(u8::wrapping_from(x.div_assign_mod(base))).unwrap(),\n            ));\n        }\n        cs.into_iter().rev().collect()\n    }\n}\n\npub fn to_string_base_signed_naive<T: PrimitiveSigned>(x: T, base: u8) -> String\nwhere\n    u8: WrappingFrom<<T as UnsignedAbs>::Output>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    assert!((2..=36).contains(&base), \"base out of range\");\n    if x == T::ZERO {\n        \"0\".to_string()\n    } else {\n        let base = <T as UnsignedAbs>::Output::from(base);\n        let mut cs = Vec::new();\n        let mut abs_x = x.unsigned_abs();\n        while abs_x != <T as UnsignedAbs>::Output::ZERO {\n            cs.push(char::from(\n                digit_to_display_byte_lower(u8::wrapping_from(abs_x.div_assign_mod(base))).unwrap(),\n            ));\n        }\n        if x < T::ZERO {\n            cs.push('-');\n        }\n        cs.into_iter().rev().collect()\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::float::NiceFloat;\nuse itertools::Itertools;\n\npub fn exhaustive_primitive_floats_helper_helper_with_limit<\n    T: PrimitiveFloat,\n    I: Iterator<Item = T>,\n>(\n    limit: usize,\n    xs: I,\n    out: &[T],\n) {\n    assert_eq!(\n        xs.take(limit).map(NiceFloat).collect_vec(),\n        out.iter().copied().map(NiceFloat).collect_vec()\n    );\n}\n\npub fn exhaustive_primitive_floats_helper_helper<T: PrimitiveFloat, I: Iterator<Item = T>>(\n    xs: I,\n    out: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_limit(50, xs, out);\n}\n\npub fn exhaustive_primitive_floats_helper_helper_with_reverse<\n    T: PrimitiveFloat,\n    I: Clone + DoubleEndedIterator<Item = T>,\n>(\n    xs: I,\n    first_20: &[T],\n    last_20: &[T],\n) {\n    assert_eq!(\n        xs.clone().take(20).map(NiceFloat).collect_vec(),\n        first_20.iter().copied().map(NiceFloat).collect_vec()\n    );\n    let mut reversed = xs.rev().take(20).map(NiceFloat).collect_vec();\n    reversed.reverse();\n    assert_eq!(\n        reversed,\n        last_20.iter().copied().map(NiceFloat).collect_vec()\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/factorization/factor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingInto;\nuse crate::test_util::common::rle_encode;\n\npub fn factor_naive<T: PrimitiveUnsigned>(mut n: T) -> Vec<(T, u8)> {\n    assert_ne!(n, T::ZERO);\n    if n == T::ONE {\n        return Vec::new();\n    }\n    let mut factors = Vec::new();\n    'outer: loop {\n        let limit = n.floor_sqrt();\n        for p in T::primes().take_while(|&p| p <= limit) {\n            let (q, r) = n.div_mod(p);\n            if r == T::ZERO {\n                factors.push(p);\n                n = q;\n                continue 'outer;\n            }\n        }\n        factors.push(n);\n        break;\n    }\n    rle_encode(factors.into_iter())\n        .into_iter()\n        .map(|(p, e)| {\n            let e: u8 = e.wrapping_into();\n            (p, e)\n        })\n        .collect()\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/factorization/is_prime.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse std::cmp::Ordering::*;\n\npub fn is_prime_naive<T: PrimitiveUnsigned>(n: T) -> bool {\n    match n.cmp(&T::TWO) {\n        Less => false,\n        Equal => true,\n        Greater => {\n            if n.even() {\n                return false;\n            }\n            let limit = n.floor_sqrt();\n            let mut i = T::from(3u8);\n            while i <= limit {\n                if n.divisible_by(i) {\n                    return false;\n                }\n                i += T::TWO;\n            }\n            true\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/factorization/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod factor;\npub mod is_prime;\npub mod prime_sieve;\npub mod primes;\n"
  },
  {
    "path": "malachite-base/src/test_util/num/factorization/prime_sieve.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{CheckedSquare, DivisibleBy, Parity};\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::factorization::prime_sieve::{id_to_n, limbs_count_ones, n_to_bit};\nuse crate::num::factorization::traits::IsPrime;\nuse crate::num::logic::traits::{NotAssign, TrailingZeros};\nuse crate::slices::slice_leading_zeros;\n\npub fn limbs_prime_sieve_naive_1<T: PrimitiveUnsigned>(bit_array: &mut [T], n: u64) -> u64 {\n    assert!(n > 4);\n    let mut f = 5;\n    let mut b = false;\n    'outer: for x in &mut *bit_array {\n        *x = T::MAX;\n        for i in 0..T::WIDTH {\n            if f.is_prime() {\n                x.clear_bit(i);\n            }\n            f += if b { 4 } else { 2 };\n            if f > n {\n                break 'outer;\n            }\n            b.not_assign();\n        }\n    }\n    (u64::exact_from(bit_array.len()) << T::LOG_WIDTH) - limbs_count_ones(bit_array)\n}\n\nfn limbs_index_of_next_true_bit<T: PrimitiveUnsigned>(xs: &[T], start: u64) -> Option<u64> {\n    let starting_index = usize::exact_from(start >> T::LOG_WIDTH);\n    if starting_index >= xs.len() {\n        None\n    } else if let Some(result) = xs[starting_index].index_of_next_true_bit(start & T::WIDTH_MASK) {\n        Some((u64::wrapping_from(starting_index) << T::LOG_WIDTH) + result)\n    } else if starting_index == xs.len() - 1 {\n        None\n    } else {\n        let true_index = starting_index + 1 + slice_leading_zeros(&xs[starting_index + 1..]);\n        if true_index == xs.len() {\n            None\n        } else {\n            let result_offset = u64::wrapping_from(true_index) << T::LOG_WIDTH;\n            Some(\n                result_offset\n                    .checked_add(TrailingZeros::trailing_zeros(xs[true_index]))\n                    .unwrap(),\n            )\n        }\n    }\n}\n\nfn limbs_set_bit_helper<T: PrimitiveUnsigned>(xs: &mut [T], index: u64, limb_index: usize) {\n    xs[limb_index].set_bit(index & T::WIDTH_MASK);\n}\n\nfn limbs_slice_set_bit<T: PrimitiveUnsigned>(xs: &mut [T], index: u64) {\n    limbs_set_bit_helper(xs, index, usize::exact_from(index >> T::LOG_WIDTH));\n}\n\nfn limbs_clear_bit<T: PrimitiveUnsigned>(xs: &mut [T], index: u64) {\n    let small_index = usize::exact_from(index >> T::LOG_WIDTH);\n    if small_index < xs.len() {\n        xs[small_index].clear_bit(index & T::WIDTH_MASK);\n    }\n}\n\npub fn limbs_prime_sieve_naive_2<T: PrimitiveUnsigned>(bit_array: &mut [T], n: u64) -> u64 {\n    assert!(n > 4);\n    for x in &mut *bit_array {\n        *x = T::MAX;\n    }\n    let mut p = 0;\n    loop {\n        let id = limbs_index_of_next_true_bit(bit_array, if p == 0 { 0 } else { n_to_bit(p) + 1 });\n        if let Some(id) = id {\n            p = id_to_n(id + 1);\n        } else {\n            break;\n        }\n        let m = p.checked_square();\n        if m.is_none() {\n            break;\n        }\n        let mut m = m.unwrap();\n        if m > n {\n            break;\n        }\n        let two_p = p << 1;\n        while m <= n {\n            if m.odd() && !m.divisible_by(3) {\n                limbs_clear_bit(bit_array, n_to_bit(m));\n            }\n            m += two_p;\n        }\n    }\n    for x in &mut *bit_array {\n        x.not_assign();\n    }\n    let bit_len = u64::exact_from(bit_array.len()) << T::LOG_WIDTH;\n    for i in (0..bit_len).rev() {\n        if id_to_n(i + 1) <= n {\n            break;\n        }\n        limbs_slice_set_bit(bit_array, i);\n    }\n    bit_len - limbs_count_ones(bit_array)\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/factorization/primes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::exhaustive::primitive_int_increasing_inclusive_range;\n\npub struct PrimesNaive<T: PrimitiveUnsigned>(T);\n\nimpl<T: PrimitiveUnsigned> Iterator for PrimesNaive<T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.0 == T::ONE {\n            self.0 = T::TWO;\n            return Some(self.0);\n        } else if self.0 == T::TWO {\n            self.0 = T::from(3u8);\n            return Some(self.0);\n        }\n        'outer: loop {\n            self.0 = self.0.checked_add(T::TWO)?;\n            let a = T::from(3u8);\n            let b = self.0.floor_sqrt();\n            if a <= b {\n                for f in primitive_int_increasing_inclusive_range(a, b) {\n                    if self.0.divisible_by(f) {\n                        continue 'outer;\n                    }\n                }\n            }\n            return Some(self.0);\n        }\n    }\n}\n\npub const fn primes_naive<T: PrimitiveUnsigned>() -> PrimesNaive<T> {\n    // 1 will never actually be generated\n    PrimesNaive(T::ONE)\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/float/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub const PRIMITIVE_FLOAT_CHARS: &str = \"-.0123456789INaefinty\";\n"
  },
  {
    "path": "malachite-base/src/test_util/num/logic/bit_block_access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::traits::Zero;\nuse crate::num::logic::traits::BitAccess;\n\npub fn get_bits_naive<T: BitAccess, U: BitAccess + Zero>(n: &T, start: u64, end: u64) -> U {\n    let mut result = U::ZERO;\n    for i in start..end {\n        if n.get_bit(i) {\n            result.set_bit(i - start);\n        }\n    }\n    result\n}\n\npub fn assign_bits_naive<T: BitAccess, U: BitAccess>(n: &mut T, start: u64, end: u64, bits: &U) {\n    for i in start..end {\n        n.assign_bit(i, bits.get_bit(i - start));\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/logic/bit_convertible.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::ExactFrom;\nuse crate::num::logic::traits::BitConvertible;\nuse itertools::Itertools;\n\npub fn to_bits_asc_alt<T: BitConvertible>(n: &T) -> Vec<bool> {\n    let mut bits = n.to_bits_desc();\n    bits.reverse();\n    bits\n}\n\npub fn to_bits_desc_alt<T: BitConvertible>(n: &T) -> Vec<bool> {\n    let mut bits = n.to_bits_asc();\n    bits.reverse();\n    bits\n}\n\npub fn from_bits_asc_alt<T: BitConvertible, I: Iterator<Item = bool>>(bits: I) -> T {\n    let mut bits = bits.collect_vec();\n    bits.reverse();\n    T::from_bits_desc(bits.into_iter())\n}\n\npub fn from_bits_desc_alt<T: BitConvertible, I: Iterator<Item = bool>>(bits: I) -> T {\n    let mut bits = bits.collect_vec();\n    bits.reverse();\n    T::from_bits_asc(bits.into_iter())\n}\n\npub fn to_bits_asc_unsigned_naive<T: PrimitiveUnsigned>(n: T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    for i in 0..n.significant_bits() {\n        bits.push(n.get_bit(i));\n    }\n    bits\n}\n\npub fn to_bits_desc_unsigned_naive<T: PrimitiveUnsigned>(n: T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    for i in (0..n.significant_bits()).rev() {\n        bits.push(n.get_bit(i));\n    }\n    bits\n}\n\npub fn from_bits_asc_unsigned_naive<T: PrimitiveUnsigned, I: Iterator<Item = bool>>(bits: I) -> T {\n    let mut n = T::ZERO;\n    for i in bits\n        .enumerate()\n        .filter_map(|(i, bit)| if bit { Some(u64::exact_from(i)) } else { None })\n    {\n        n.set_bit(i);\n    }\n    n\n}\n\npub fn to_bits_asc_signed_naive<T: PrimitiveSigned>(n: T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    if n == T::ZERO {\n        return bits;\n    }\n    for i in 0..n.significant_bits() {\n        bits.push(n.get_bit(i));\n    }\n    let last_bit = *bits.last().unwrap();\n    if last_bit != (n < T::ZERO) {\n        bits.push(!last_bit);\n    }\n    bits\n}\n\npub fn to_bits_desc_signed_naive<T: PrimitiveSigned>(n: T) -> Vec<bool> {\n    let mut bits = Vec::new();\n    if n == T::ZERO {\n        return bits;\n    }\n    let significant_bits = n.significant_bits();\n    let last_bit = n.get_bit(significant_bits - 1);\n    if last_bit != (n < T::ZERO) {\n        bits.push(!last_bit);\n    }\n    for i in (0..significant_bits).rev() {\n        bits.push(n.get_bit(i));\n    }\n    bits\n}\n\npub fn from_bits_asc_signed_naive<T: PrimitiveSigned, I: Iterator<Item = bool>>(bits: I) -> T {\n    let bits = bits.collect_vec();\n    if bits.is_empty() {\n        return T::ZERO;\n    }\n    let mut n;\n    if *bits.last().unwrap() {\n        n = T::NEGATIVE_ONE;\n        for i in bits\n            .iter()\n            .enumerate()\n            .filter_map(|(i, &bit)| if bit { None } else { Some(u64::exact_from(i)) })\n        {\n            n.clear_bit(i);\n        }\n    } else {\n        n = T::ZERO;\n        for i in bits\n            .iter()\n            .enumerate()\n            .filter_map(|(i, &bit)| if bit { Some(u64::exact_from(i)) } else { None })\n        {\n            n.set_bit(i);\n        }\n    };\n    n\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod bit_block_access;\npub mod bit_convertible;\n"
  },
  {
    "path": "malachite-base/src/test_util/num/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod arithmetic;\npub mod conversion;\npub mod exhaustive;\npub mod factorization;\npub mod float;\npub mod logic;\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/test_util/num/random/geometric.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::logic::traits::BitAccess;\nuse std::cmp::Ordering::*;\n\npub fn unadjusted_mean_to_adjusted_mean(unadjusted_mean: f64, limit: f64) -> f64 {\n    let m = limit;\n    assert!(unadjusted_mean > 0.0);\n    assert!(m > 0.0);\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let pow = q.powf(m + 1.0);\n    let adjusted = ((m * p + 1.0) * pow - q) / (p * (pow - 1.0));\n    adjusted.abs()\n}\n\npub fn adjusted_mean_to_unadjusted_mean(adjusted_mean: f64, limit: f64) -> f64 {\n    assert!(adjusted_mean > 0.0);\n    assert!(adjusted_mean < limit / 2.0);\n    let mut min = f64::MIN_POSITIVE_SUBNORMAL.to_ordered_representation();\n    let mut max = f64::MAX_FINITE.to_ordered_representation();\n    loop {\n        if min == max {\n            let f_max =\n                unadjusted_mean_to_adjusted_mean(f64::from_ordered_representation(max), limit);\n            assert!(!f_max.is_nan() && f_max <= limit && f_max >= adjusted_mean);\n            return f64::from_ordered_representation(max);\n        }\n        let (sum, overflow) = min.overflowing_add(max);\n        let mut mid = sum >> 1;\n        if overflow {\n            mid.set_bit(u64::WIDTH - 1);\n        }\n        let f_mid = unadjusted_mean_to_adjusted_mean(f64::from_ordered_representation(mid), limit);\n        let compare = if f_mid.is_nan() {\n            Greater\n        } else {\n            f_mid.partial_cmp(&adjusted_mean).unwrap()\n        };\n        match compare {\n            Greater => max = mid,\n            Less => min = mid + 1,\n            Equal => return f64::from_ordered_representation(mid),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/num/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::floats::PrimitiveFloat;\nuse crate::num::float::NiceFloat;\nuse crate::test_util::stats::common_values_map::common_values_map;\nuse crate::test_util::stats::median;\nuse crate::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse itertools::Itertools;\n\npub fn random_primitive_floats_helper_helper<\n    T: CheckedToF64 + PrimitiveFloat,\n    I: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    let actual_values = xs.clone().take(20).map(NiceFloat).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone().map(NiceFloat));\n    let actual_median = median(xs.clone().map(NiceFloat).take(1000000));\n    let actual_moment_stats = moment_stats(xs.take(1000000));\n    let (lo, hi) = expected_median;\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values.as_slice(),\n            actual_median,\n            actual_moment_stats\n        ),\n        (\n            expected_values.iter().copied().map(NiceFloat).collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|&(x, freq)| (NiceFloat(x), freq))\n                .collect_vec()\n                .as_slice(),\n            (NiceFloat(lo), hi.map(NiceFloat)),\n            expected_moment_stats\n        )\n    );\n}\n\npub fn special_random_primitive_floats_helper_helper<\n    T: CheckedToF64 + PrimitiveFloat,\n    I: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    let actual_values = xs.clone().take(50).map(NiceFloat).collect_vec();\n    let actual_common_values = common_values_map(1000000, 20, xs.clone().map(NiceFloat));\n    let actual_median = median(xs.clone().map(NiceFloat).take(1000000));\n    let actual_moment_stats = moment_stats(xs.take(1000000));\n    let (lo, hi) = expected_median;\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values.as_slice(),\n            actual_median,\n            actual_moment_stats\n        ),\n        (\n            expected_values.iter().copied().map(NiceFloat).collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|&(x, freq)| (NiceFloat(x), freq))\n                .collect_vec()\n                .as_slice(),\n            (NiceFloat(lo), hi.map(NiceFloat)),\n            expected_moment_stats\n        )\n    );\n}\n\npub mod geometric;\n"
  },
  {
    "path": "malachite-base/src/test_util/rounding_modes/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub const ROUNDING_MODE_CHARS: &str = \"CDEFNUacegilnoprstwx\";\n"
  },
  {
    "path": "malachite-base/src/test_util/runner/cmd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::test_util::generators::common::{GenConfig, GenMode};\nuse clap::{App, Arg};\nuse itertools::Itertools;\nuse std::str::FromStr;\n\n#[derive(Clone, Debug)]\npub struct CommandLineArguments {\n    pub codegen_key: Option<String>,\n    pub demo_key: Option<String>,\n    pub bench_key: Option<String>,\n    pub generation_mode: GenMode,\n    pub config: GenConfig,\n    pub limit: usize,\n    pub out: String,\n}\n\npub fn read_command_line_arguments(name: &str) -> CommandLineArguments {\n    let matches = App::new(name)\n        .version(\"0.1.0\")\n        .author(\"Mikhail Hogrefe <mikhailhogrefe@gmail.com>\")\n        .about(\"Runs demos and benchmarks for malachite-base functions.\")\n        .arg(\n            Arg::with_name(\"generation_mode\")\n                .short(\"m\")\n                .long(\"generation_mode\")\n                .help(\"May be 'exhaustive', 'random', or 'special_random'.\")\n                .takes_value(true),\n        )\n        .arg(\n            Arg::with_name(\"config\")\n                .short(\"c\")\n                .long(\"config\")\n                .help(\"e.g. 'mean_run_length_n 4 mean_run_length_d 1'\")\n                .takes_value(true),\n        )\n        .arg(\n            Arg::with_name(\"limit\")\n                .short(\"l\")\n                .long(\"limit\")\n                .help(\"Specifies the maximum number of elements to generate\")\n                .takes_value(true),\n        )\n        .arg(\n            Arg::with_name(\"out\")\n                .short(\"o\")\n                .long(\"out\")\n                .help(\"Specifies the file name to write a benchmark to\")\n                .takes_value(true),\n        )\n        .arg(\n            Arg::with_name(\"demo\")\n                .short(\"d\")\n                .long(\"demo\")\n                .help(\"Specifies the demo name\")\n                .takes_value(true),\n        )\n        .arg(\n            Arg::with_name(\"bench\")\n                .short(\"b\")\n                .long(\"bench\")\n                .help(\"Specifies the benchmark name\")\n                .takes_value(true),\n        )\n        .arg(\n            Arg::with_name(\"codegen\")\n                .short(\"g\")\n                .long(\"codegen\")\n                .help(\"Specifies the code to generate\")\n                .takes_value(true),\n        )\n        .get_matches();\n\n    let generation_mode = match matches.value_of(\"generation_mode\").unwrap_or(\"exhaustive\") {\n        \"exhaustive\" => GenMode::Exhaustive,\n        \"random\" => GenMode::Random,\n        \"special_random\" => GenMode::SpecialRandom,\n        _ => panic!(\"Invalid generation mode\"),\n    };\n    let config_string = matches.value_of(\"config\").unwrap_or(\"\");\n    let mut config = GenConfig::new();\n    if !config_string.is_empty() {\n        for mut chunk in &config_string.split(' ').chunks(2) {\n            let key = chunk.next().unwrap();\n            let value =\n                u64::from_str(chunk.next().expect(\"Bad config\")).expect(\"Invalid config value\");\n            config.insert(key, value);\n        }\n    }\n    let limit =\n        usize::from_str(matches.value_of(\"limit\").unwrap_or(\"10000\")).expect(\"Invalid limit\");\n    let out = matches.value_of(\"out\").unwrap_or(\"temp.gp\").to_string();\n    let demo_key = matches.value_of(\"demo\").map(ToString::to_string);\n    let bench_key = matches.value_of(\"bench\").map(ToString::to_string);\n    let codegen_key = matches.value_of(\"codegen\").map(ToString::to_string);\n    assert!(\n        demo_key.is_some() || bench_key.is_some() || codegen_key.is_some(),\n        \"Must specify demo, bench, or codegen\"\n    );\n    CommandLineArguments {\n        codegen_key,\n        demo_key,\n        bench_key,\n        generation_mode,\n        config,\n        limit,\n        out,\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/runner/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::test_util::generators::common::{GenConfig, GenMode};\nuse std::collections::HashMap;\n\npub type DemoFn = &'static dyn Fn(GenMode, &GenConfig, usize);\npub type BenchFn = &'static dyn Fn(GenMode, &GenConfig, usize, &str);\n\npub struct Runner {\n    demo_map: HashMap<&'static str, DemoFn>,\n    bench_map: HashMap<&'static str, BenchFn>,\n}\n\nimpl Runner {\n    pub fn new() -> Self {\n        Self {\n            demo_map: HashMap::new(),\n            bench_map: HashMap::new(),\n        }\n    }\n\n    pub fn run_demo(&self, key: &str, gm: GenMode, config: &GenConfig, limit: usize) {\n        self.demo_map.get(key).expect(\"Invalid demo key\")(gm, config, limit);\n    }\n\n    pub fn run_bench(\n        &self,\n        key: &str,\n        gm: GenMode,\n        config: &GenConfig,\n        limit: usize,\n        file_name: &str,\n    ) {\n        self.bench_map.get(key).expect(\"Invalid bench key\")(gm, config, limit, file_name);\n    }\n\n    pub fn register_demo(&mut self, key: &'static str, f: DemoFn) {\n        assert!(\n            self.demo_map.insert(key, f).is_none(),\n            \"Duplicate demo with key {key}\",\n        );\n    }\n\n    pub fn register_bench(&mut self, key: &'static str, f: BenchFn) {\n        assert!(\n            self.bench_map.insert(key, f).is_none(),\n            \"Duplicate bench with key {key}\",\n        );\n    }\n}\n\nimpl Default for Runner {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\n#[macro_export]\nmacro_rules! register_demo {\n    ($runner: ident, $f: ident) => {\n        $runner.register_demo(stringify!($f), &$f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_demos {\n    ($runner: ident, $f: ident $(,$t:ty)*) => {\n        $(\n            $runner.register_demo(concat!(stringify!($f), \"_\", stringify!($t)), &$f::<$t>);\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_demos_2 {\n    ($runner: ident, $f: ident $(,[$t:ty, $u:ty])*) => {\n        $(\n            $runner.register_demo(\n                concat!(stringify!($f), \"_\", stringify!($t), \"_\", stringify!($u)),\n                &$f::<$t, $u>\n            );\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_demos_3_only_1_3_in_key {\n    ($runner: ident, $f: ident $(,[$t:ty, $u:ty, $v:ty])*) => {\n        $(\n            $runner.register_demo(\n                concat!(stringify!($f), \"_\", stringify!($t), \"_\", stringify!($v)),\n                &$f::<$t, $u, $v>\n            );\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_benches_3_only_1_3_in_key {\n    ($runner: ident, $f: ident $(,[$t:ty, $u:ty, $v:ty])*) => {\n        $(\n            $runner.register_bench(\n                concat!(stringify!($f), \"_\", stringify!($t), \"_\", stringify!($v)),\n                &$f::<$t, $u, $v>\n            );\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_demos_2_only_first_in_key {\n    ($runner: ident, $f: ident $(,[$t:ty, $u:ty])*) => {\n        $(\n            $runner.register_demo(\n                concat!(stringify!($f), \"_\", stringify!($t)),\n                &$f::<$t, $u>\n            );\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos!($runner, $f, u8, u16, u32, u64, u128, usize);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos!($runner, $f, i8, i16, i32, i64, i128, isize);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_float_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos!($runner, $f, f32, f64);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_float_unsigned_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [f32, u8],\n            [f32, u16],\n            [f32, u32],\n            [f32, u64],\n            [f32, u128],\n            [f32, usize],\n            [f64, u8],\n            [f64, u16],\n            [f64, u32],\n            [f64, u64],\n            [f64, u128],\n            [f64, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_float_signed_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [f32, i8],\n            [f32, i16],\n            [f32, i32],\n            [f32, i64],\n            [f32, i128],\n            [f32, isize],\n            [f64, i8],\n            [f64, i16],\n            [f64, i32],\n            [f64, i64],\n            [f64, i128],\n            [f64, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_unsigned_match_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2_only_first_in_key!(\n            $runner,\n            $f,\n            [i8, u8],\n            [i16, u16],\n            [i32, u32],\n            [i64, u64],\n            [i128, u128],\n            [isize, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_signed_match_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2_only_first_in_key!(\n            $runner,\n            $f,\n            [u8, i8],\n            [u16, i16],\n            [u32, i32],\n            [u64, i64],\n            [u128, i128],\n            [usize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_demos {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_demos!($runner, $f);\n        register_signed_demos!($runner, $f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_unsigned_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [u8, u8],\n            [u8, u16],\n            [u8, u32],\n            [u8, u64],\n            [u8, u128],\n            [u8, usize],\n            [u16, u8],\n            [u16, u16],\n            [u16, u32],\n            [u16, u64],\n            [u16, u128],\n            [u16, usize],\n            [u32, u8],\n            [u32, u16],\n            [u32, u32],\n            [u32, u64],\n            [u32, u128],\n            [u32, usize],\n            [u64, u8],\n            [u64, u16],\n            [u64, u32],\n            [u64, u64],\n            [u64, u128],\n            [u64, usize],\n            [u128, u8],\n            [u128, u16],\n            [u128, u32],\n            [u128, u64],\n            [u128, u128],\n            [u128, usize],\n            [usize, u8],\n            [usize, u16],\n            [usize, u32],\n            [usize, u64],\n            [usize, u128],\n            [usize, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_unsigned_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [i8, u8],\n            [i8, u16],\n            [i8, u32],\n            [i8, u64],\n            [i8, u128],\n            [i8, usize],\n            [i16, u8],\n            [i16, u16],\n            [i16, u32],\n            [i16, u64],\n            [i16, u128],\n            [i16, usize],\n            [i32, u8],\n            [i32, u16],\n            [i32, u32],\n            [i32, u64],\n            [i32, u128],\n            [i32, usize],\n            [i64, u8],\n            [i64, u16],\n            [i64, u32],\n            [i64, u64],\n            [i64, u128],\n            [i64, usize],\n            [i128, u8],\n            [i128, u16],\n            [i128, u32],\n            [i128, u64],\n            [i128, u128],\n            [i128, usize],\n            [isize, u8],\n            [isize, u16],\n            [isize, u32],\n            [isize, u64],\n            [isize, u128],\n            [isize, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_unsigned_demos {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_unsigned_demos!($runner, $f);\n        register_signed_unsigned_demos!($runner, $f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_signed_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [u8, i8],\n            [u8, i16],\n            [u8, i32],\n            [u8, i64],\n            [u8, i128],\n            [u8, isize],\n            [u16, i8],\n            [u16, i16],\n            [u16, i32],\n            [u16, i64],\n            [u16, i128],\n            [u16, isize],\n            [u32, i8],\n            [u32, i16],\n            [u32, i32],\n            [u32, i64],\n            [u32, i128],\n            [u32, isize],\n            [u64, i8],\n            [u64, i16],\n            [u64, i32],\n            [u64, i64],\n            [u64, i128],\n            [u64, isize],\n            [u128, i8],\n            [u128, i16],\n            [u128, i32],\n            [u128, i64],\n            [u128, i128],\n            [u128, isize],\n            [usize, i8],\n            [usize, i16],\n            [usize, i32],\n            [usize, i64],\n            [usize, i128],\n            [usize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_unsigned_signed_match_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_3_only_1_3_in_key!(\n            $runner,\n            $f,\n            [u8, u8, i8],\n            [u8, u16, i16],\n            [u8, u32, i32],\n            [u8, u64, i64],\n            [u8, u128, i128],\n            [u8, usize, isize],\n            [u16, u8, i8],\n            [u16, u16, i16],\n            [u16, u32, i32],\n            [u16, u64, i64],\n            [u16, u128, i128],\n            [u16, usize, isize],\n            [u32, u8, i8],\n            [u32, u16, i16],\n            [u32, u32, i32],\n            [u32, u64, i64],\n            [u32, u128, i128],\n            [u32, usize, isize],\n            [u64, u8, i8],\n            [u64, u16, i16],\n            [u64, u32, i32],\n            [u64, u64, i64],\n            [u64, u128, i128],\n            [u64, usize, isize],\n            [u128, u8, i8],\n            [u128, u16, i16],\n            [u128, u32, i32],\n            [u128, u64, i64],\n            [u128, u128, i128],\n            [u128, usize, isize],\n            [usize, u8, i8],\n            [usize, u16, i16],\n            [usize, u32, i32],\n            [usize, u64, i64],\n            [usize, u128, i128],\n            [usize, usize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_signed_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [i8, i8],\n            [i8, i16],\n            [i8, i32],\n            [i8, i64],\n            [i8, i128],\n            [i8, isize],\n            [i16, i8],\n            [i16, i16],\n            [i16, i32],\n            [i16, i64],\n            [i16, i128],\n            [i16, isize],\n            [i32, i8],\n            [i32, i16],\n            [i32, i32],\n            [i32, i64],\n            [i32, i128],\n            [i32, isize],\n            [i64, i8],\n            [i64, i16],\n            [i64, i32],\n            [i64, i64],\n            [i64, i128],\n            [i64, isize],\n            [i128, i8],\n            [i128, i16],\n            [i128, i32],\n            [i128, i64],\n            [i128, i128],\n            [i128, isize],\n            [isize, i8],\n            [isize, i16],\n            [isize, i32],\n            [isize, i64],\n            [isize, i128],\n            [isize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_signed_demos {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_signed_demos!($runner, $f);\n        register_signed_signed_demos!($runner, $f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_primitive_float_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [u8, f32],\n            [u8, f64],\n            [u16, f32],\n            [u16, f64],\n            [u32, f32],\n            [u32, f64],\n            [u64, f32],\n            [u64, f64],\n            [u128, f32],\n            [u128, f64],\n            [usize, f32],\n            [usize, f64]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_primitive_float_demos {\n    ($runner: ident, $f: ident) => {\n        register_generic_demos_2!(\n            $runner,\n            $f,\n            [i8, f32],\n            [i8, f64],\n            [i16, f32],\n            [i16, f64],\n            [i32, f32],\n            [i32, f64],\n            [i64, f32],\n            [i64, f64],\n            [i128, f32],\n            [i128, f64],\n            [isize, f32],\n            [isize, f64]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_primitive_float_demos {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_primitive_float_demos!($runner, $f);\n        register_signed_primitive_float_demos!($runner, $f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_bench {\n    ($runner: ident, $f: ident) => {\n        $runner.register_bench(stringify!($f), &$f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_benches {\n    ($runner: ident, $f: ident $(,$t:ty)*) => {\n        $(\n            $runner.register_bench(concat!(stringify!($f), \"_\", stringify!($t)), &$f::<$t>);\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_benches_2 {\n    ($runner: ident, $f: ident $(,[$t:ty, $u:ty])*) => {\n        $(\n            $runner.register_bench(\n                concat!(stringify!($f), \"_\", stringify!($t), \"_\", stringify!($u)),\n                &$f::<$t, $u>\n            );\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_generic_benches_2_only_first_in_key {\n    ($runner: ident, $f: ident $(,[$t:ty, $u:ty])*) => {\n        $(\n            $runner.register_bench(\n                concat!(stringify!($f), \"_\", stringify!($t)),\n                &$f::<$t, $u>\n            );\n        )*\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches!($runner, $f, u8, u16, u32, u64, u128, usize);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches!($runner, $f, i8, i16, i32, i64, i128, isize);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_float_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches!($runner, $f, f32, f64);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_float_unsigned_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [f32, u8],\n            [f32, u16],\n            [f32, u32],\n            [f32, u64],\n            [f32, u128],\n            [f32, usize],\n            [f64, u8],\n            [f64, u16],\n            [f64, u32],\n            [f64, u64],\n            [f64, u128],\n            [f64, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_float_signed_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [f32, i8],\n            [f32, i16],\n            [f32, i32],\n            [f32, i64],\n            [f32, i128],\n            [f32, isize],\n            [f64, i8],\n            [f64, i16],\n            [f64, i32],\n            [f64, i64],\n            [f64, i128],\n            [f64, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_unsigned_match_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2_only_first_in_key!(\n            $runner,\n            $f,\n            [i8, u8],\n            [i16, u16],\n            [i32, u32],\n            [i64, u64],\n            [i128, u128],\n            [isize, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_signed_match_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2_only_first_in_key!(\n            $runner,\n            $f,\n            [u8, i8],\n            [u16, i16],\n            [u32, i32],\n            [u64, i64],\n            [u128, i128],\n            [usize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_benches {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_benches!($runner, $f);\n        register_signed_benches!($runner, $f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_unsigned_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [u8, u8],\n            [u8, u16],\n            [u8, u32],\n            [u8, u64],\n            [u8, u128],\n            [u8, usize],\n            [u16, u8],\n            [u16, u16],\n            [u16, u32],\n            [u16, u64],\n            [u16, u128],\n            [u16, usize],\n            [u32, u8],\n            [u32, u16],\n            [u32, u32],\n            [u32, u64],\n            [u32, u128],\n            [u32, usize],\n            [u64, u8],\n            [u64, u16],\n            [u64, u32],\n            [u64, u64],\n            [u64, u128],\n            [u64, usize],\n            [u128, u8],\n            [u128, u16],\n            [u128, u32],\n            [u128, u64],\n            [u128, u128],\n            [u128, usize],\n            [usize, u8],\n            [usize, u16],\n            [usize, u32],\n            [usize, u64],\n            [usize, u128],\n            [usize, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_unsigned_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [i8, u8],\n            [i8, u16],\n            [i8, u32],\n            [i8, u64],\n            [i8, u128],\n            [i8, usize],\n            [i16, u8],\n            [i16, u16],\n            [i16, u32],\n            [i16, u64],\n            [i16, u128],\n            [i16, usize],\n            [i32, u8],\n            [i32, u16],\n            [i32, u32],\n            [i32, u64],\n            [i32, u128],\n            [i32, usize],\n            [i64, u8],\n            [i64, u16],\n            [i64, u32],\n            [i64, u64],\n            [i64, u128],\n            [i64, usize],\n            [i128, u8],\n            [i128, u16],\n            [i128, u32],\n            [i128, u64],\n            [i128, u128],\n            [i128, usize],\n            [isize, u8],\n            [isize, u16],\n            [isize, u32],\n            [isize, u64],\n            [isize, u128],\n            [isize, usize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_unsigned_benches {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_unsigned_benches!($runner, $f);\n        register_signed_unsigned_benches!($runner, $f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_signed_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [u8, i8],\n            [u8, i16],\n            [u8, i32],\n            [u8, i64],\n            [u8, i128],\n            [u8, isize],\n            [u16, i8],\n            [u16, i16],\n            [u16, i32],\n            [u16, i64],\n            [u16, i128],\n            [u16, isize],\n            [u32, i8],\n            [u32, i16],\n            [u32, i32],\n            [u32, i64],\n            [u32, i128],\n            [u32, isize],\n            [u64, i8],\n            [u64, i16],\n            [u64, i32],\n            [u64, i64],\n            [u64, i128],\n            [u64, isize],\n            [u128, i8],\n            [u128, i16],\n            [u128, i32],\n            [u128, i64],\n            [u128, i128],\n            [u128, isize],\n            [usize, i8],\n            [usize, i16],\n            [usize, i32],\n            [usize, i64],\n            [usize, i128],\n            [usize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_unsigned_signed_match_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_3_only_1_3_in_key!(\n            $runner,\n            $f,\n            [u8, u8, i8],\n            [u8, u16, i16],\n            [u8, u32, i32],\n            [u8, u64, i64],\n            [u8, u128, i128],\n            [u8, usize, isize],\n            [u16, u8, i8],\n            [u16, u16, i16],\n            [u16, u32, i32],\n            [u16, u64, i64],\n            [u16, u128, i128],\n            [u16, usize, isize],\n            [u32, u8, i8],\n            [u32, u16, i16],\n            [u32, u32, i32],\n            [u32, u64, i64],\n            [u32, u128, i128],\n            [u32, usize, isize],\n            [u64, u8, i8],\n            [u64, u16, i16],\n            [u64, u32, i32],\n            [u64, u64, i64],\n            [u64, u128, i128],\n            [u64, usize, isize],\n            [u128, u8, i8],\n            [u128, u16, i16],\n            [u128, u32, i32],\n            [u128, u64, i64],\n            [u128, u128, i128],\n            [u128, usize, isize],\n            [usize, u8, i8],\n            [usize, u16, i16],\n            [usize, u32, i32],\n            [usize, u64, i64],\n            [usize, u128, i128],\n            [usize, usize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_signed_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [i8, i8],\n            [i8, i16],\n            [i8, i32],\n            [i8, i64],\n            [i8, i128],\n            [i8, isize],\n            [i16, i8],\n            [i16, i16],\n            [i16, i32],\n            [i16, i64],\n            [i16, i128],\n            [i16, isize],\n            [i32, i8],\n            [i32, i16],\n            [i32, i32],\n            [i32, i64],\n            [i32, i128],\n            [i32, isize],\n            [i64, i8],\n            [i64, i16],\n            [i64, i32],\n            [i64, i64],\n            [i64, i128],\n            [i64, isize],\n            [i128, i8],\n            [i128, i16],\n            [i128, i32],\n            [i128, i64],\n            [i128, i128],\n            [i128, isize],\n            [isize, i8],\n            [isize, i16],\n            [isize, i32],\n            [isize, i64],\n            [isize, i128],\n            [isize, isize]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_signed_benches {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_signed_benches!($runner, $f);\n        register_signed_signed_benches!($runner, $f);\n    };\n}\n\n#[macro_export]\nmacro_rules! register_unsigned_primitive_float_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [u8, f32],\n            [u8, f64],\n            [u16, f32],\n            [u16, f64],\n            [u32, f32],\n            [u32, f64],\n            [u64, f32],\n            [u64, f64],\n            [u128, f32],\n            [u128, f64],\n            [usize, f32],\n            [usize, f64]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_signed_primitive_float_benches {\n    ($runner: ident, $f: ident) => {\n        register_generic_benches_2!(\n            $runner,\n            $f,\n            [i8, f32],\n            [i8, f64],\n            [i16, f32],\n            [i16, f64],\n            [i32, f32],\n            [i32, f64],\n            [i64, f32],\n            [i64, f64],\n            [i128, f32],\n            [i128, f64],\n            [isize, f32],\n            [isize, f64]\n        );\n    };\n}\n\n#[macro_export]\nmacro_rules! register_primitive_int_primitive_float_benches {\n    ($runner: ident, $f: ident) => {\n        register_unsigned_primitive_float_benches!($runner, $f);\n        register_signed_primitive_float_benches!($runner, $f);\n    };\n}\n\npub mod cmd;\n"
  },
  {
    "path": "malachite-base/src/test_util/sets/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(not(feature = \"std\"))]\nuse alloc::collections::BTreeSet;\n#[cfg(not(feature = \"std\"))]\nuse hashbrown::HashSet;\nuse itertools::Itertools;\n#[cfg(feature = \"std\")]\nuse std::collections::{BTreeSet, HashSet};\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\npub fn exhaustive_b_tree_sets_helper_helper<\n    T: Clone + Debug + Ord,\n    I: Iterator<Item = BTreeSet<T>>,\n>(\n    xss: I,\n    out: &[BTreeSet<T>],\n) {\n    let xss = xss.take(20).collect_vec();\n    assert_eq!(xss.into_iter().collect_vec().as_slice(), out);\n}\n\npub fn exhaustive_b_tree_sets_small_helper_helper<\n    T: Clone + Debug + Ord,\n    I: Clone + Iterator<Item = BTreeSet<T>>,\n>(\n    xss: I,\n    out_len: usize,\n    out: &[BTreeSet<T>],\n) {\n    let xss_prefix = xss.clone().take(20).collect_vec();\n    assert_eq!(xss_prefix.into_iter().collect_vec().as_slice(), out);\n    assert_eq!(xss.count(), out_len);\n}\n\npub fn exhaustive_hash_sets_helper_helper<\n    T: Clone + Debug + Eq + Hash,\n    I: Iterator<Item = HashSet<T>>,\n>(\n    xss: I,\n    out: &[HashSet<T>],\n) {\n    let xss = xss.take(20).collect_vec();\n    assert_eq!(xss.into_iter().collect_vec().as_slice(), out);\n}\n\npub fn exhaustive_hash_sets_small_helper_helper<\n    T: Clone + Debug + Eq + Hash,\n    I: Clone + Iterator<Item = HashSet<T>>,\n>(\n    xss: I,\n    out_len: usize,\n    out: &[HashSet<T>],\n) {\n    let xss_prefix = xss.clone().take(20).collect_vec();\n    assert_eq!(xss_prefix.into_iter().collect_vec().as_slice(), out);\n    assert_eq!(xss.count(), out_len);\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/sets/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod exhaustive;\n"
  },
  {
    "path": "malachite-base/src/test_util/slices/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub fn slice_move_left_naive<T: Copy>(xs: &mut [T], amount: usize) {\n    let slice = xs[amount..].to_vec();\n    let limit = xs.len() - amount;\n    xs[..limit].copy_from_slice(&slice);\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/stats/common_values_map.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::strings::ToDebugString;\nuse std::cmp::Ordering;\nuse std::collections::{BinaryHeap, HashMap};\nuse std::fmt::{Debug, Display};\nuse std::hash::Hash;\n\nmacro_rules! impl_common_values_map {\n    ($CommonOrdered: ident, $StringTrait: ident, $to_string: ident, $common_values_map: ident) => {\n        #[derive(Eq, PartialEq)]\n        struct $CommonOrdered<T: $StringTrait + Eq> {\n            x: T,\n            frequency: usize,\n        }\n\n        impl<T: $StringTrait + Eq> PartialOrd for $CommonOrdered<T> {\n            fn partial_cmp(&self, other: &$CommonOrdered<T>) -> Option<Ordering> {\n                Some(self.cmp(other))\n            }\n        }\n\n        impl<T: $StringTrait + Eq> Ord for $CommonOrdered<T> {\n            fn cmp(&self, other: &$CommonOrdered<T>) -> Ordering {\n                other.frequency.cmp(&self.frequency).then_with(|| {\n                    let x = self.x.$to_string();\n                    let y = other.x.$to_string();\n                    x.len().cmp(&y.len()).then_with(|| x.cmp(&y))\n                })\n            }\n        }\n\n        /// Takes the first `limit` values of an iterator `xs`. Groups them into (unique value,\n        /// frequency) pairs. Takes the top `n` pairs, preferring ones with high frequency. To break\n        /// ties, prefers values with low `$to_string` representations, where the strings are\n        /// shortlex-ordered (ordered by length, then lexicographically).\n        pub fn $common_values_map<I: Iterator>(\n            limit: usize,\n            n: usize,\n            xs: I,\n        ) -> Vec<(I::Item, usize)>\n        where\n            I::Item: $StringTrait + Eq + Hash,\n        {\n            assert_ne!(n, 0);\n            let mut frequencies: HashMap<I::Item, usize> = HashMap::new();\n            for x in xs.take(limit) {\n                *frequencies.entry(x).or_insert(0) += 1;\n            }\n            let mut top_n = BinaryHeap::new();\n            let mut full = false;\n            for (x, frequency) in frequencies {\n                top_n.push($CommonOrdered { x, frequency });\n                if full {\n                    top_n.pop();\n                } else if top_n.len() == n {\n                    full = true;\n                }\n            }\n            let mut common_values = Vec::new();\n            while let Some(pair) = top_n.pop() {\n                common_values.push((pair.x, pair.frequency));\n            }\n            common_values.reverse();\n            common_values\n        }\n    };\n}\nimpl_common_values_map!(CommonOrdered, Display, to_string, common_values_map);\nimpl_common_values_map!(\n    CommonOrderedDebug,\n    Debug,\n    to_debug_string,\n    common_values_map_debug\n);\n"
  },
  {
    "path": "malachite-base/src/test_util/stats/median.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::test_util::stats::moments::CheckedToF64;\n\npub const fn uniform_bool_median(min: bool, max: bool) -> (bool, Option<bool>) {\n    if min == max {\n        (min, None)\n    } else {\n        (false, Some(true))\n    }\n}\n\npub fn uniform_primitive_int_median<T: PrimitiveInt>(min: T, max: T) -> (T, Option<T>) {\n    let mut mean = min.wrapping_add(max);\n    mean >>= 1;\n    if mean < min || mean > max {\n        mean.flip_bit(T::WIDTH - 1);\n    }\n    if min.even() == max.even() {\n        (mean, None)\n    } else {\n        (mean, Some(mean + T::ONE))\n    }\n}\n\npub fn deleted_uniform_primitive_int_median<T: PrimitiveInt>(\n    min: T,\n    max: T,\n    deleted: T,\n) -> (T, Option<T>) {\n    let (mut lo, mut hi) = uniform_primitive_int_median(min, max - T::ONE);\n    if lo >= deleted {\n        lo += T::ONE;\n    }\n    if let Some(hi) = hi.as_mut()\n        && *hi >= deleted\n    {\n        *hi += T::ONE;\n    }\n    (lo, hi)\n}\n\nfn binary_search_median<T: PrimitiveInt, P: Fn(T) -> f64, C: Fn(T) -> f64>(\n    mut min: T,\n    mut max: T,\n    pmf: P,\n    cdf: C,\n) -> (T, Option<T>) {\n    let initial_median;\n    loop {\n        if min == max {\n            initial_median = Some(min);\n            break;\n        }\n        let mut mean = min.wrapping_add(max);\n        mean >>= 1;\n        if mean < min || mean > max {\n            mean.flip_bit(T::WIDTH - 1);\n        }\n        if 1.0 - cdf(mean) > 0.5 {\n            min = mean + T::ONE;\n        } else if cdf(max) - pmf(max) > 0.5 {\n            max = mean;\n        } else {\n            initial_median = Some(mean);\n            break;\n        }\n    }\n    let mut first_median = initial_median.unwrap();\n    let mut first_good = false;\n    while 1.0 - cdf(first_median) <= 0.5 && cdf(first_median) - pmf(first_median) <= 0.5 {\n        first_good = true;\n        first_median.wrapping_sub_assign(T::ONE);\n    }\n    assert!(first_good, \"could not find median\");\n    first_median.wrapping_add_assign(T::ONE);\n    let mut last_median = first_median.wrapping_add(T::ONE);\n    while 1.0 - cdf(last_median) <= 0.5 && cdf(last_median) - pmf(last_median) <= 0.5 {\n        last_median.wrapping_add_assign(T::ONE);\n    }\n    last_median.wrapping_sub_assign(T::ONE);\n    if first_median == last_median {\n        (first_median, None)\n    } else {\n        (first_median, Some(last_median))\n    }\n}\n\nfn truncated_geometric_pmf(m: f64, unadjusted_mean: f64, n: f64) -> f64 {\n    if n >= 0.0 && m >= n {\n        let p = 1.0 / (unadjusted_mean + 1.0);\n        let q = 1.0 - p;\n        (q.powf(n) * p) / (1.0 - q.powf(1.0 + m))\n    } else {\n        0.0\n    }\n}\n\nfn truncated_geometric_cdf(m: f64, unadjusted_mean: f64, n: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    if n < 0.0 {\n        0.0\n    } else if n <= m {\n        let q = 1.0 - p;\n        (1.0 - q.powf(1.0 + n)) / (1.0 - q.powf(1.0 + m))\n    } else {\n        1.0\n    }\n}\n\npub fn truncated_geometric_median<T: CheckedToF64 + PrimitiveInt>(\n    min: T,\n    max: T,\n    unadjusted_mean: f64,\n) -> (T, Option<T>) {\n    assert!(min >= T::ZERO);\n    assert!(min <= max);\n    let min_64 = min.checked_to_f64();\n    let max_64 = max.checked_to_f64() - min_64;\n    let unadjusted_mean = unadjusted_mean - min_64;\n    binary_search_median(\n        min,\n        max,\n        |n| truncated_geometric_pmf(max_64, unadjusted_mean, n.checked_to_f64() - min_64),\n        |n| truncated_geometric_cdf(max_64, unadjusted_mean, n.checked_to_f64() - min_64),\n    )\n}\n\nfn double_nonzero_geometric_pmf(a: f64, b: f64, unadjusted_mean: f64, n: f64) -> f64 {\n    if n == 0.0 || n > a || n < -b {\n        0.0\n    } else {\n        let p = 1.0 / (unadjusted_mean + 1.0);\n        let q = 1.0 - p;\n        q.powf(-1.0 + n.abs()) * p / (2.0 - q.powf(a) - q.powf(b))\n    }\n}\n\nfn double_nonzero_geometric_cdf(a: f64, b: f64, unadjusted_mean: f64, n: f64) -> f64 {\n    if n < -b {\n        return 0.0;\n    } else if n >= a {\n        return 1.0;\n    }\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let d = 2.0 - q.powf(a) - q.powf(b);\n    if n == -b {\n        q.powf(-1.0 + b) * p / d\n    } else if n < 0.0 {\n        (1.0 - q.powf(1.0 + b + n)) * q.powf(-1.0 - n) / d\n    } else {\n        (2.0 - q.powf(b) - q.powf(n)) / d\n    }\n}\n\npub fn double_nonzero_geometric_median<T: CheckedToF64 + PrimitiveSigned>(\n    min: T,\n    max: T,\n    unadjusted_mean: f64,\n) -> (T, Option<T>) {\n    assert!(min < T::ZERO);\n    assert!(max > T::ZERO);\n    let min_64 = -min.checked_to_f64();\n    let max_64 = max.checked_to_f64();\n    binary_search_median(\n        min,\n        max,\n        |n| double_nonzero_geometric_pmf(max_64, min_64, unadjusted_mean, n.checked_to_f64()),\n        |n| double_nonzero_geometric_cdf(max_64, min_64, unadjusted_mean, n.checked_to_f64()),\n    )\n}\n\nfn double_geometric_pmf(a: f64, b: f64, unadjusted_mean: f64, n: f64) -> f64 {\n    if n > a || n < -b {\n        0.0\n    } else {\n        let p = 1.0 / (unadjusted_mean + 1.0);\n        let q = 1.0 - p;\n        let qpa = q.powf(a);\n        q.powf(n.abs()) * p / (2.0 - qpa - q.powf(1.0 + b) - p + qpa * p)\n    }\n}\n\nfn double_geometric_cdf(a: f64, b: f64, unadjusted_mean: f64, n: f64) -> f64 {\n    if n < -b {\n        return 0.0;\n    } else if n >= a {\n        return 1.0;\n    }\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    let d = 2.0 - qpa - q.powf(1.0 + b) - p + qpa * p;\n    if n == -b {\n        qpb * p / d\n    } else if n <= 0.0 {\n        (1.0 - q.powf(1.0 + b + n)) * q.powf(-n) / d\n    } else {\n        (2.0 - qpb - q.powf(1.0 + n) - p + qpb * p) / d\n    }\n}\n\npub fn double_geometric_median<T: CheckedToF64 + PrimitiveSigned>(\n    min: T,\n    max: T,\n    unadjusted_mean: f64,\n) -> (T, Option<T>) {\n    assert!(min < T::ZERO);\n    assert!(max > T::ZERO);\n    let min_64 = -min.checked_to_f64();\n    let max_64 = max.checked_to_f64();\n    binary_search_median(\n        min,\n        max,\n        |n| double_geometric_pmf(max_64, min_64, unadjusted_mean, n.checked_to_f64()),\n        |n| double_geometric_cdf(max_64, min_64, unadjusted_mean, n.checked_to_f64()),\n    )\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/stats/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::Parity;\nuse itertools::Itertools;\n\npub fn median<I: Iterator>(xs: I) -> (I::Item, Option<I::Item>)\nwhere\n    I::Item: Eq + Ord,\n{\n    let mut xs = xs.collect_vec();\n    assert!(!xs.is_empty());\n    xs.sort_unstable();\n    let n = xs.len();\n    let half_n = n >> 1;\n    if n.even() {\n        // swap-remove m_2 first because if n == 2 it's the last element of the list.\n        let m_2 = xs.swap_remove(half_n);\n        let m_1 = xs.swap_remove(half_n - 1);\n        if m_1 == m_2 {\n            (m_1, None)\n        } else {\n            (m_1, Some(m_2))\n        }\n    } else {\n        (xs.swap_remove(half_n), None)\n    }\n}\n\npub mod common_values_map;\npub mod median;\npub mod moments;\n"
  },
  {
    "path": "malachite-base/src/test_util/stats/moments.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::arithmetic::traits::{SaturatingAbs, UnsignedAbs};\nuse crate::num::basic::integers::PrimitiveInt;\nuse crate::num::basic::signeds::PrimitiveSigned;\nuse crate::num::basic::traits::Zero;\nuse crate::num::basic::unsigneds::PrimitiveUnsigned;\nuse crate::num::conversion::traits::WrappingFrom;\nuse crate::num::float::NiceFloat;\nuse crate::test_util::stats::common_values_map::common_values_map;\nuse crate::test_util::stats::median;\nuse crate::test_util::stats::median::{\n    deleted_uniform_primitive_int_median, double_geometric_median, double_nonzero_geometric_median,\n    truncated_geometric_median, uniform_bool_median, uniform_primitive_int_median,\n};\nuse itertools::Itertools;\nuse std::fmt::{self, Debug, Formatter};\n\n// Panics if the input exceeds the finite range of f64.\npub trait CheckedToF64 {\n    fn checked_to_f64(&self) -> f64;\n}\n\nmacro_rules! impl_checked_to_f64_for_primitive_ints {\n    ($t: ident) => {\n        impl CheckedToF64 for $t {\n            #[allow(clippy::cast_lossless)]\n            #[inline]\n            fn checked_to_f64(&self) -> f64 {\n                // No primitive integer type, not even u128 and i128, exceeds the finite range of\n                // f64.\n                *self as f64\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_checked_to_f64_for_primitive_ints);\n\nimpl CheckedToF64 for bool {\n    #[inline]\n    fn checked_to_f64(&self) -> f64 {\n        if *self { 1.0 } else { 0.0 }\n    }\n}\n\nimpl CheckedToF64 for f32 {\n    #[inline]\n    fn checked_to_f64(&self) -> f64 {\n        f64::from(*self)\n    }\n}\n\nimpl CheckedToF64 for f64 {\n    #[inline]\n    fn checked_to_f64(&self) -> f64 {\n        *self\n    }\n}\n\n#[derive(Copy, Clone, Eq, PartialEq)]\npub struct MomentStats {\n    pub mean: NiceFloat<f64>,\n    pub standard_deviation: NiceFloat<f64>,\n    pub skewness: NiceFloat<f64>,\n    pub excess_kurtosis: NiceFloat<f64>,\n}\n\nimpl Debug for MomentStats {\n    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {\n        f.write_fmt(format_args!(\n            \"MomentStats {{ mean: NiceFloat({}), standard_deviation: NiceFloat({}), \\\n                skewness: NiceFloat({}), excess_kurtosis: NiceFloat({}) }}\",\n            self.mean, self.standard_deviation, self.skewness, self.excess_kurtosis\n        ))\n    }\n}\n\n// From https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance\n#[allow(clippy::suspicious_operation_groupings)]\npub fn moment_stats<I: Iterator>(xs: I) -> MomentStats\nwhere\n    I::Item: CheckedToF64,\n{\n    let mut n: usize = 1;\n    let mut m = 0.0;\n    let mut m_2 = 0.0;\n    let mut m_3 = 0.0;\n    let mut m_4 = 0.0;\n    for x in xs {\n        let d = x.checked_to_f64() - m;\n        let nf = n.checked_to_f64();\n        let d_n = d / nf;\n        let d_n_2 = d_n * d_n;\n        let d_n_3 = d_n_2 * d_n;\n        let m_4_1 = (nf - 1.0) * (nf * nf - 3.0 * nf + 3.0) * d_n_3 * d;\n        let m_4_2 = m_2 * d_n_2 * 6.0;\n        let m_4_3 = m_3 * d_n * 4.0;\n        m_4 += m_4_1 + m_4_2 - m_4_3;\n        let m_3_1 = (nf - 1.0) * (nf - 2.0) * d_n_2 * d;\n        let m_3_2 = m_2 * d_n * 3.0;\n        m_3 += m_3_1 - m_3_2;\n        m_2 += (nf - 1.0) * d_n * d;\n        m += d_n;\n        n += 1;\n    }\n    n -= 1;\n    let nf = n.checked_to_f64();\n    let mean = m;\n    let standard_deviation = (m_2 / (nf - 1.0)).sqrt();\n    let sqrt_m_2 = m_2.sqrt();\n    let skewness = m_3 * nf.sqrt() / (sqrt_m_2 * sqrt_m_2 * sqrt_m_2);\n    let excess_kurtosis = m_4 * nf / (m_2 * m_2) - 3.0;\n    MomentStats {\n        mean: NiceFloat(mean),\n        standard_deviation: NiceFloat(standard_deviation),\n        skewness: NiceFloat(skewness),\n        excess_kurtosis: NiceFloat(excess_kurtosis),\n    }\n}\n\npub const NAN_MOMENT_STATS: MomentStats = MomentStats {\n    mean: NiceFloat(f64::NAN),\n    standard_deviation: NiceFloat(f64::NAN),\n    skewness: NiceFloat(f64::NAN),\n    excess_kurtosis: NiceFloat(f64::NAN),\n};\n\npub fn mean<I: Iterator>(xs: I) -> NiceFloat<f64>\nwhere\n    I::Item: CheckedToF64,\n{\n    let mut n: usize = 1;\n    let mut m = 0.0;\n    for x in xs {\n        let d_n = (x.checked_to_f64() - m) / n.checked_to_f64();\n        m += d_n;\n        n += 1;\n    }\n    NiceFloat(m)\n}\n\nfn moment_stats_from_raw_moments(\n    mean: f64,\n    p_2_mean: f64,\n    p_3_mean: f64,\n    p_4_mean: f64,\n) -> MomentStats {\n    let mean_2 = mean * mean;\n    let mean_3 = mean_2 * mean;\n    let mean_4 = mean_2 * mean_2;\n    let variance = p_2_mean - mean_2;\n    let standard_deviation = variance.sqrt();\n    let mu_3 = p_3_mean - 3.0 * mean * p_2_mean + 2.0 * mean_3;\n    let mu_4 = p_4_mean - 4.0 * mean * p_3_mean + 6.0 * mean_2 * p_2_mean - 3.0 * mean_4;\n    MomentStats {\n        mean: NiceFloat(mean),\n        standard_deviation: NiceFloat(standard_deviation),\n        skewness: NiceFloat(mu_3 / (variance * standard_deviation)),\n        excess_kurtosis: NiceFloat(mu_4 / (variance * variance) - 3.0),\n    }\n}\n\n#[inline]\nfn pop_uniform_mean<T: CheckedToF64>(a: &T, b: &T) -> f64 {\n    (a.checked_to_f64() + b.checked_to_f64()) / 2.0\n}\n\nfn pop_uniform_standard_deviation<T: CheckedToF64>(a: &T, b: &T) -> f64 {\n    let a = a.checked_to_f64();\n    let b = b.checked_to_f64();\n    let n = b - a + 1.0;\n    ((n * n - 1.0) / 12.0).sqrt()\n}\n\nfn pop_uniform_skewness<T: CheckedToF64>(a: &T, b: &T) -> f64 {\n    let a = a.checked_to_f64();\n    let b = b.checked_to_f64();\n    if a == b { f64::NAN } else { 0.0 }\n}\n\nfn pop_uniform_excess_kurtosis<T: CheckedToF64>(a: &T, b: &T) -> f64 {\n    let a = a.checked_to_f64();\n    let b = b.checked_to_f64();\n    if a == b {\n        f64::NAN\n    } else {\n        let n = b - a + 1.0;\n        let n_squared = n * n;\n        6.0 / 5.0 * (-1.0 - 2.0 / (-1.0 + n_squared))\n    }\n}\n\npub fn pop_disc_uniform_dist_moment_stats<T: CheckedToF64>(a: &T, b: &T) -> MomentStats {\n    MomentStats {\n        mean: NiceFloat(pop_uniform_mean(a, b)),\n        standard_deviation: NiceFloat(pop_uniform_standard_deviation(a, b)),\n        skewness: NiceFloat(pop_uniform_skewness(a, b)),\n        excess_kurtosis: NiceFloat(pop_uniform_excess_kurtosis(a, b)),\n    }\n}\n\npub fn uniform_bool_assertions<I: Clone + Iterator<Item = bool>>(\n    xs: I,\n    a: bool,\n    b: bool,\n    expected_values: &[bool],\n    expected_common_values: &[(bool, usize)],\n    expected_pop_median: (bool, Option<bool>),\n    expected_sample_median: (bool, Option<bool>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    let actual_values = xs.clone().take(20).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone());\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            uniform_bool_median(a, b),\n            actual_sample_median,\n            pop_disc_uniform_dist_moment_stats(&a, &b),\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats\n        )\n    );\n}\n\npub fn uniform_primitive_int_assertions<I: Clone + Iterator>(\n    xs: I,\n    a: I::Item,\n    b: I::Item,\n    expected_values: &[I::Item],\n    expected_common_values: &[(I::Item, usize)],\n    expected_pop_median: (I::Item, Option<I::Item>),\n    expected_sample_median: (I::Item, Option<I::Item>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) where\n    I::Item: CheckedToF64 + PrimitiveInt,\n{\n    let actual_values = xs.clone().take(20).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone());\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            uniform_primitive_int_median(a, b),\n            actual_sample_median,\n            pop_disc_uniform_dist_moment_stats(&a, &b),\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats\n        )\n    );\n}\n\nfn pop_deleted_disc_uniform_dist_mean<T: CheckedToF64>(a: &T, b: &T, c: &T) -> f64 {\n    let a = a.checked_to_f64();\n    let b = b.checked_to_f64();\n    let c = c.checked_to_f64();\n    (a - a * a + b + b * b - 2.0 * c) / (2.0 * (b - a))\n}\n\nfn pop_deleted_disc_uniform_dist_2_mean<T: CheckedToF64>(a: &T, b: &T, c: &T) -> f64 {\n    let a = a.checked_to_f64();\n    let b = b.checked_to_f64();\n    let c = c.checked_to_f64();\n    let a_2 = a * a;\n    let a_3 = a_2 * a;\n    (a - 3.0 * a_2 + 2.0 * a_3 - b * (1.0 + b) * (1.0 + 2.0 * b) + 6.0 * c * c) / (6.0 * (a - b))\n}\n\nfn pop_deleted_disc_uniform_dist_3_mean<T: CheckedToF64>(a: &T, b: &T, c: &T) -> f64 {\n    let a = a.checked_to_f64();\n    let b = b.checked_to_f64();\n    let c = c.checked_to_f64();\n    let a_2 = a * a;\n    let b_2 = b * b;\n    let a_m_1 = a - 1.0;\n    let b_p_1 = b + 1.0;\n    (a_m_1 * a_m_1 * a_2 - b_2 * b_p_1 * b_p_1 + 4.0 * c * c * c) / (4.0 * (a - b))\n}\n\nfn pop_deleted_disc_uniform_dist_4_mean<T: CheckedToF64>(a: &T, b: &T, c: &T) -> f64 {\n    let a = a.checked_to_f64();\n    let b = b.checked_to_f64();\n    let c = c.checked_to_f64();\n    let a_2 = a * a;\n    let a_3 = a_2 * a;\n    let a_4 = a_2 * a_2;\n    let a_5 = a_3 * a_2;\n    let b_2 = b * b;\n    let b_3 = b_2 * b;\n    let b_4 = b_2 * b_2;\n    let b_5 = b_3 * b_2;\n    let c_2 = c * c;\n    (-a + 10.0 * a_3 - 15.0 * a_4 + 6.0 * a_5 + b - 10.0 * b_3 - 15.0 * b_4 - 6.0 * b_5\n        + 30.0 * c_2 * c_2)\n        / (30.0 * (a - b))\n}\n\nfn deleted_uniform_primitive_int_moment_stats<T: CheckedToF64 + Ord>(\n    a: &T,\n    b: &T,\n    c: &T,\n) -> MomentStats {\n    assert!(a <= c);\n    assert!(c <= b);\n    moment_stats_from_raw_moments(\n        pop_deleted_disc_uniform_dist_mean(a, b, c),\n        pop_deleted_disc_uniform_dist_2_mean(a, b, c),\n        pop_deleted_disc_uniform_dist_3_mean(a, b, c),\n        pop_deleted_disc_uniform_dist_4_mean(a, b, c),\n    )\n}\n\npub fn deleted_uniform_primitive_int_assertions<I: Clone + Iterator>(\n    xs: I,\n    a: I::Item,\n    b: I::Item,\n    c: I::Item,\n    expected_values: &[I::Item],\n    expected_common_values: &[(I::Item, usize)],\n    expected_pop_median: (I::Item, Option<I::Item>),\n    expected_sample_median: (I::Item, Option<I::Item>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) where\n    I::Item: CheckedToF64 + PrimitiveInt,\n{\n    let actual_values = xs.clone().take(20).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone());\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            deleted_uniform_primitive_int_median(a, b, c),\n            actual_sample_median,\n            deleted_uniform_primitive_int_moment_stats(&a, &b, &c),\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n// unadjusted_mean is what the mean would be if the distribution were not truncated.\nfn pop_truncated_geometric_dist_mean(max: f64, unadjusted_mean: f64) -> f64 {\n    let m = max;\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    (q - q.powf(m) * q * (1.0 + m * p)) / (p - q.powf(1.0 + m) * p)\n}\n\nfn pop_truncated_geometric_dist_2_mean(max: f64, unadjusted_mean: f64) -> f64 {\n    let m = max;\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let p_2 = p * p;\n    (2.0 - 3.0 * p + p_2 - q.powf(m) * q * (2.0 + p * (-1.0 + m * (2.0 + m * p))))\n        / ((1.0 - q.powf(1.0 + m)) * p_2)\n}\n\nfn pop_truncated_geometric_dist_3_mean(max: f64, unadjusted_mean: f64) -> f64 {\n    let m = max;\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let p_2 = p * p;\n    let p_3 = p_2 * p;\n    (6.0 - 12.0 * p + 7.0 * p_2\n        - p_3\n        - q.powf(m) * q * (6.0 + p * (-6.0 + p + m * (6.0 + p * (-3.0 + m * (3.0 + m * p))))))\n        / ((1.0 - q.powf(1.0 + m)) * p_3)\n}\n\nfn pop_truncated_geometric_dist_4_mean(max: f64, unadjusted_mean: f64) -> f64 {\n    let m = max;\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let m_2 = m * m;\n    let m_4 = m_2 * m_2;\n    let p_2 = p * p;\n    let p_3 = p_2 * p;\n    let p_4 = p_2 * p_2;\n    (1.0 / ((1.0 - q.powf(1.0 + m)) * p_4))\n        * (24.0 - 60.0 * p + 50.0 * p_2 - 15.0 * p_3 + p_4\n            - q.powf(m)\n                * q\n                * (24.0\n                    + p * (-36.0\n                        + 24.0 * m\n                        + 2.0 * (7.0 + 6.0 * (-2.0 + m) * m) * p\n                        + (-1.0 + 2.0 * m * (2.0 + m * (-3.0 + 2.0 * m))) * p_2\n                        + m_4 * p_3)))\n}\n\nfn pop_truncated_geometric_dist_moment_stats(\n    min: f64,\n    max: f64,\n    unadjusted_mean: f64,\n) -> MomentStats {\n    assert!(min <= max);\n    assert!(min <= unadjusted_mean); // unadjusted_mean may be arbitrarily large\n    let unadjusted_mean = unadjusted_mean - min;\n    let max = max - min;\n    let mut stats = moment_stats_from_raw_moments(\n        pop_truncated_geometric_dist_mean(max, unadjusted_mean),\n        pop_truncated_geometric_dist_2_mean(max, unadjusted_mean),\n        pop_truncated_geometric_dist_3_mean(max, unadjusted_mean),\n        pop_truncated_geometric_dist_4_mean(max, unadjusted_mean),\n    );\n    stats.mean = NiceFloat(stats.mean.0 + min);\n    stats\n}\n\npub fn truncated_geometric_dist_assertions<I: Clone + Iterator>(\n    xs: I,\n    min: I::Item,\n    max: I::Item,\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[I::Item],\n    expected_common_values: &[(I::Item, usize)],\n    expected_pop_median: (I::Item, Option<I::Item>),\n    expected_sample_median: (I::Item, Option<I::Item>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) where\n    I::Item: CheckedToF64 + PrimitiveInt,\n{\n    let min_64 = min.checked_to_f64();\n    let max_64 = max.checked_to_f64();\n    let unadjusted_mean = um_numerator as f64 / um_denominator as f64;\n    let actual_values = xs.clone().take(20).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone());\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            truncated_geometric_median(min, max, unadjusted_mean),\n            actual_sample_median,\n            pop_truncated_geometric_dist_moment_stats(min_64, max_64, unadjusted_mean),\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats\n        )\n    );\n}\n\npub fn negative_truncated_geometric_dist_assertions<\n    I: Clone + Iterator<Item = S>,\n    S: CheckedToF64 + PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n    U: CheckedToF64 + PrimitiveUnsigned,\n>(\n    xs: I,\n    abs_min: S,\n    abs_max: S,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n    expected_values: &[S],\n    expected_common_values: &[(S, usize)],\n    expected_pop_median: (S, Option<S>),\n    expected_sample_median: (S, Option<S>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    let abs_min_64 = -abs_min.checked_to_f64();\n    let abs_max_64 = -abs_max.checked_to_f64();\n    let abs_unadjusted_mean = abs_um_numerator as f64 / abs_um_denominator as f64;\n    let actual_values = xs.clone().take(20).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone());\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    let mut pop_sample_moment_stats =\n        pop_truncated_geometric_dist_moment_stats(abs_min_64, abs_max_64, abs_unadjusted_mean);\n    pop_sample_moment_stats.mean = NiceFloat(-pop_sample_moment_stats.mean.0);\n    pop_sample_moment_stats.skewness = NiceFloat(-pop_sample_moment_stats.skewness.0);\n    let (x, y) = truncated_geometric_median(\n        abs_min.unsigned_abs(),\n        abs_max.unsigned_abs(),\n        abs_unadjusted_mean,\n    );\n    let (x, y) = y.map_or((S::wrapping_from(x.wrapping_neg()), None), |y| {\n        (\n            S::wrapping_from(y.wrapping_neg()),\n            Some(S::wrapping_from(x.wrapping_neg())),\n        )\n    });\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            (x, y),\n            actual_sample_median,\n            pop_sample_moment_stats,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats\n        )\n    );\n}\n\nfn pop_double_nonzero_truncated_geometric_dist_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    (qpa * (1.0 + a * p) - qpb * (1.0 + b * p)) / ((-2.0 + qpa + qpb) * p)\n}\n\nfn pop_double_nonzero_truncated_geometric_dist_2_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    (2.0 + (p * (2.0 - qpa + a * qpa * (2.0 + a * p) + qpb * (-1.0 + b * (2.0 + b * p))))\n        / (-2.0 + qpa + qpb))\n        / (p * p)\n}\n\nfn pop_double_nonzero_truncated_geometric_dist_3_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    (qpa * (6.0 + p * (-6.0 + p + a * (6.0 + p * (-3.0 + a * (3.0 + a * p)))))\n        - qpb * (6.0 + p * (-6.0 + p + b * (6.0 + p * (-3.0 + b * (3.0 + b * p))))))\n        / ((-2.0 + qpa + qpb) * p * p * p)\n}\n\nfn pop_double_nonzero_truncated_geometric_dist_4_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let a_2 = a * a;\n    let a_3 = a_2 * a;\n    let a_4 = a_2 * a_2;\n    let b_2 = b * b;\n    let b_4 = b_2 * b_2;\n    let p_2 = p * p;\n    let p_3 = p_2 * p;\n    let p_4 = p_2 * p_2;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    1.0 / p_4\n        * (24.0\n            + 1.0 / (-2.0 + qpa + qpb)\n                * p\n                * (-6.0 * a_2 * qpa * (-2.0 + p) * p + 4.0 * a_3 * qpa * p_2 + a_4 * qpa * p_3\n                    - (-2.0 + qpa) * (36.0 + (-14.0 + p) * p)\n                    + 4.0 * a * qpa * (6.0 + (-6.0 + p) * p)\n                    + qpb\n                        * (-36.0\n                            + 24.0 * b\n                            + 2.0 * (7.0 + 6.0 * (-2.0 + b) * b) * p\n                            + (-1.0 + 2.0 * b * (2.0 + b * (-3.0 + 2.0 * b))) * p_2\n                            + b_4 * p_3)))\n}\n\nfn pop_double_nonzero_truncated_geometric_dist_moment_stats(\n    min: f64,\n    max: f64,\n    unadjusted_mean: f64,\n) -> MomentStats {\n    assert!(min < 0.0);\n    assert!(max > 0.0);\n    assert!(unadjusted_mean > 1.0); // unadjusted_mean may be arbitrarily large\n    moment_stats_from_raw_moments(\n        pop_double_nonzero_truncated_geometric_dist_mean(-min, max, unadjusted_mean - 1.0),\n        pop_double_nonzero_truncated_geometric_dist_2_mean(-min, max, unadjusted_mean - 1.0),\n        pop_double_nonzero_truncated_geometric_dist_3_mean(-min, max, unadjusted_mean - 1.0),\n        pop_double_nonzero_truncated_geometric_dist_4_mean(-min, max, unadjusted_mean - 1.0),\n    )\n}\n\npub fn double_nonzero_truncated_geometric_dist_assertions<I: Clone + Iterator>(\n    xs: I,\n    min: I::Item,\n    max: I::Item,\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[I::Item],\n    expected_common_values: &[(I::Item, usize)],\n    expected_abs_mean: NiceFloat<f64>,\n    expected_pop_median: (I::Item, Option<I::Item>),\n    expected_sample_median: (I::Item, Option<I::Item>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) where\n    I::Item: CheckedToF64 + PrimitiveSigned,\n{\n    let min_64 = min.checked_to_f64();\n    let max_64 = max.checked_to_f64();\n    let unadjusted_mean = um_numerator as f64 / um_denominator as f64;\n    let actual_values = xs.clone().take(20).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone());\n    let actual_abs_mean = mean(xs.clone().map(SaturatingAbs::saturating_abs).take(1000000));\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            actual_abs_mean,\n            double_nonzero_geometric_median(min, max, unadjusted_mean),\n            actual_sample_median,\n            pop_double_nonzero_truncated_geometric_dist_moment_stats(\n                min_64,\n                max_64,\n                unadjusted_mean,\n            ),\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_abs_mean,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats\n        )\n    );\n}\n\nfn pop_double_truncated_geometric_dist_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    q * (qpa * (1.0 + a * p) - q.powf(b) * (1.0 + b * p))\n        / (p * (-2.0 + qpa + q.powf(1.0 + b) + p - qpa * p))\n}\n\n#[allow(clippy::suspicious_operation_groupings)]\nfn pop_double_truncated_geometric_dist_2_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    q * (2.0 * (-2.0 + qpa + qpb)\n        + p * (2.0 - qpa + a * qpa * (2.0 + a * p) + qpb * (-1.0 + b * (2.0 + b * p))))\n        / (p * p * (-2.0 + qpa + q.powf(1.0 + b) + p - qpa * p))\n}\n\nfn pop_double_truncated_geometric_dist_3_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    q * (qpa * (6.0 + p * (-6.0 + p + a * (6.0 + p * (-3.0 + a * (3.0 + a * p)))))\n        - qpb * (6.0 + p * (-6.0 + p + b * (6.0 + p * (-3.0 + b * (3.0 + b * p))))))\n        / (p * p * p * (-2.0 + qpa + q.powf(1.0 + b) + p - qpa * p))\n}\n\nfn pop_double_truncated_geometric_dist_4_mean(b: f64, a: f64, unadjusted_mean: f64) -> f64 {\n    let p = 1.0 / (unadjusted_mean + 1.0);\n    let q = 1.0 - p;\n    let qpa = q.powf(a);\n    let qpb = q.powf(b);\n    let a_2 = a * a;\n    let a_3 = a_2 * a;\n    let a_4 = a_2 * a_2;\n    let b_2 = b * b;\n    let b_4 = b_2 * b_2;\n    let p_2 = p * p;\n    let p_3 = p_2 * p;\n    let p_4 = p_2 * p_2;\n    q * (24.0 * (-2.0 + qpa + qpb)\n        + p * (-6.0 * a_2 * qpa * (-2.0 + p) * p + 4.0 * a_3 * qpa * p_2 + a_4 * qpa * p_3\n            - (-2.0 + qpa) * (36.0 + (-14.0 + p) * p)\n            + 4.0 * a * qpa * (6.0 + (-6.0 + p) * p)\n            + qpb\n                * (-36.0\n                    + 24.0 * b\n                    + 2.0 * (7.0 + 6.0 * (-2.0 + b) * b) * p\n                    + (-1.0 + 2.0 * b * (2.0 + b * (-3.0 + 2.0 * b))) * p_2\n                    + b_4 * p_3)))\n        / (p_4 * (-2.0 + qpa + q.powf(1.0 + b) + p - qpa * p))\n}\n\nfn pop_double_truncated_geometric_dist_moment_stats(\n    min: f64,\n    max: f64,\n    unadjusted_mean: f64,\n) -> MomentStats {\n    assert!(min < 0.0);\n    assert!(max > 0.0);\n    assert!(unadjusted_mean > 0.0); // unadjusted_mean may be arbitrarily large\n    moment_stats_from_raw_moments(\n        pop_double_truncated_geometric_dist_mean(-min, max, unadjusted_mean),\n        pop_double_truncated_geometric_dist_2_mean(-min, max, unadjusted_mean),\n        pop_double_truncated_geometric_dist_3_mean(-min, max, unadjusted_mean),\n        pop_double_truncated_geometric_dist_4_mean(-min, max, unadjusted_mean),\n    )\n}\n\npub fn double_truncated_geometric_dist_assertions<I: Clone + Iterator>(\n    xs: I,\n    min: I::Item,\n    max: I::Item,\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[I::Item],\n    expected_common_values: &[(I::Item, usize)],\n    expected_natural_mean: NiceFloat<f64>,\n    expected_pop_median: (I::Item, Option<I::Item>),\n    expected_sample_median: (I::Item, Option<I::Item>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) where\n    I::Item: CheckedToF64 + PrimitiveSigned,\n{\n    let min_64 = min.checked_to_f64();\n    let max_64 = max.checked_to_f64();\n    let unadjusted_mean = um_numerator as f64 / um_denominator as f64;\n    let actual_values = xs.clone().take(20).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone());\n    let actual_natural_mean = mean(xs.clone().filter(|&x| x >= I::Item::ZERO).take(1000000));\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            actual_natural_mean,\n            double_geometric_median(min, max, unadjusted_mean),\n            actual_sample_median,\n            pop_double_truncated_geometric_dist_moment_stats(min_64, max_64, unadjusted_mean),\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_natural_mean,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/vecs/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse std::fmt::Debug;\n\npub fn exhaustive_vecs_helper_helper<T, I: Iterator<Item = Vec<T>>>(xss: I, out: &[&[T]])\nwhere\n    T: Clone + Debug + Eq,\n{\n    let xss = xss.take(20).collect_vec();\n    assert_eq!(xss.iter().map(Vec::as_slice).collect_vec().as_slice(), out);\n}\n\npub fn exhaustive_vecs_small_helper_helper<T, I: Clone + Iterator<Item = Vec<T>>>(\n    xss: I,\n    out_len: usize,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    let xss_prefix = xss.clone().take(20).collect_vec();\n    assert_eq!(\n        xss_prefix\n            .iter()\n            .map(Vec::as_slice)\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n    assert_eq!(xss.count(), out_len);\n}\n"
  },
  {
    "path": "malachite-base/src/test_util/vecs/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod exhaustive;\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/test_util/vecs/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::test_util::stats::common_values_map::common_values_map_debug;\nuse crate::test_util::stats::median;\nuse itertools::Itertools;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\npub fn random_vecs_helper_helper<T, I: Clone + Iterator<Item = Vec<T>>>(\n    xss: I,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) where\n    T: Clone + Debug + Eq + Hash + Ord,\n{\n    let values = xss.clone().take(20).collect_vec();\n    let values = values.iter().map(Vec::as_slice).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xss.clone());\n    let common_values = common_values\n        .iter()\n        .map(|(xs, f)| (xs.as_slice(), *f))\n        .collect_vec();\n    let (a, ob) = median(xss.take(1000000));\n    let median = (a.as_slice(), ob.as_deref());\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n"
  },
  {
    "path": "malachite-base/src/tuples/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse crate::iterators::iterator_cache::IteratorCache;\nuse crate::num::arithmetic::traits::CheckedPow;\nuse crate::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse crate::num::logic::traits::SignificantBits;\nuse crate::vecs::exhaustive::{\n    UniqueIndices, fixed_length_ordered_unique_indices_helper, next_bit_pattern, unique_indices,\n};\nuse alloc::vec;\nuse alloc::vec::Vec;\nuse core::cmp::max;\nuse core::fmt::Debug;\nuse core::iter::{Once, once};\nuse core::marker::PhantomData;\nuse core::mem::take;\n\n/// Generates the only unit: `()`.\n///\n/// The output length is 1.\n///\n/// # Worst-case complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::exhaustive_units;\n///\n/// assert_eq!(exhaustive_units().collect_vec(), &[()]);\n/// ```\npub fn exhaustive_units() -> Once<()> {\n    once(())\n}\n\n// hack for macro\npub_test! {\n#[inline]\nclone_helper<T: Clone>(x: &T, _i: usize) -> T {\n    x.clone()\n}}\n\n/// Defines lexicographic tuple generators.\n///\n/// Malachite provides [`lex_pairs`] and [`lex_pairs_from_single`], but you can also define\n/// `lex_triples`, `lex_quadruples`, and so on, and `lex_triples_from_single`,\n/// `lex_quadruples_from_single`, and so on, in your program using the code below. The documentation\n/// for [`lex_pairs`] and [`lex_pairs_from_single`] describes these other functions as well.\n///\n/// See usage examples [here](self#lex_pairs) and [here](self#lex_pairs_from_single).\n///\n/// ```\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_tuples;\n///\n/// fn clone_helper<T: Clone>(x: &T, _i: usize) -> T {\n///     x.clone()\n/// }\n///\n/// lex_tuples!(\n///     (pub(crate)),\n///     3,\n///     LexTriples,\n///     LexTriplesFromSingle,\n///     lex_triples,\n///     lex_triples_from_single,\n///     (T, T, T),\n///     [0, X, I, xs, x],\n///     [1, Y, J, ys, y],\n///     [2, Z, K, zs, z]\n/// );\n/// lex_tuples!(\n///     (pub(crate)),\n///     4,\n///     LexQuadruples,\n///     LexQuadruplesFromSingle,\n///     lex_quadruples,\n///     lex_quadruples_from_single,\n///     (T, T, T, T),\n///     [0, X, I, xs, x],\n///     [1, Y, J, ys, y],\n///     [2, Z, K, zs, z],\n///     [3, W, L, ws, w]\n/// );\n/// lex_tuples!(\n///     (pub(crate)),\n///     5,\n///     LexQuintuples,\n///     LexQuintuplesFromSingle,\n///     lex_quintuples,\n///     lex_quintuples_from_single,\n///     (T, T, T, T, T),\n///     [0, X, I, xs, x],\n///     [1, Y, J, ys, y],\n///     [2, Z, K, zs, z],\n///     [3, W, L, ws, w],\n///     [4, V, M, vs, v]\n/// );\n/// lex_tuples!(\n///     (pub(crate)),\n///     6,\n///     LexSextuples,\n///     LexSextuplesFromSingle,\n///     lex_sextuples,\n///     lex_sextuples_from_single,\n///     (T, T, T, T, T, T),\n///     [0, X, I, xs, x],\n///     [1, Y, J, ys, y],\n///     [2, Z, K, zs, z],\n///     [3, W, L, ws, w],\n///     [4, V, M, vs, v],\n///     [5, U, N, us, u]\n/// );\n/// lex_tuples!(\n///     (pub(crate)),\n///     7,\n///     LexSeptuples,\n///     LexSeptuplesFromSingle,\n///     lex_septuples,\n///     lex_septuples_from_single,\n///     (T, T, T, T, T, T, T),\n///     [0, X, I, xs, x],\n///     [1, Y, J, ys, y],\n///     [2, Z, K, zs, z],\n///     [3, W, L, ws, w],\n///     [4, V, M, vs, v],\n///     [5, U, N, us, u],\n///     [6, T, O, ts, t]\n/// );\n/// lex_tuples!(\n///     (pub(crate)),\n///     8,\n///     LexOctuples,\n///     LexOctuplesFromSingle,\n///     lex_octuples,\n///     lex_octuples_from_single,\n///     (T, T, T, T, T, T, T, T),\n///     [0, X, I, xs, x],\n///     [1, Y, J, ys, y],\n///     [2, Z, K, zs, z],\n///     [3, W, L, ws, w],\n///     [4, V, M, vs, v],\n///     [5, U, N, us, u],\n///     [6, T, O, ts, t],\n///     [7, S, P, ss, s]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! lex_tuples {\n    (\n        ($($vis:tt)*),\n        $k: expr,\n        $exhaustive_struct: ident,\n        $exhaustive_struct_from_single: ident,\n        $exhaustive_fn: ident,\n        $exhaustive_fn_from_single: ident,\n        $single_out: tt,\n        $([$i: expr, $t: ident, $it: ident, $xs: ident, $x:ident]),*\n    ) => {\n        /// This documentation applies not only to `LexPairs`, but also to `LexTriples`,\n        /// `LexQuadruples`, and so on. See `lex_tuples` for more information.\n        ///\n        /// Generates all $n$-tuples with elements from $n$ iterators, in lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterators.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<$($t: Clone, $it: Iterator<Item = $t>,)*> {\n            first: bool,\n            done: bool,\n            $($xs: IteratorCache<$it>,)*\n            counters: [usize; $k],\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> $exhaustive_struct<$($t, $it,)*> {\n            fn increment_counters(&mut self) -> bool {\n                for (i, counter) in self.counters.iter_mut().enumerate().rev() {\n                    *counter += 1;\n                    let no_carry = match i {\n                        $(\n                            $i => self.$xs.get(*counter).is_some(),\n                        )*\n                        _ => unreachable!(),\n                    };\n                    if no_carry {\n                        return false;\n                    } else if i == 0 {\n                        return true;\n                    }\n                    *counter = 0;\n                }\n                false\n            }\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> Iterator for $exhaustive_struct<$($t, $it,)*>\n        {\n            type Item = ($($t,)*);\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if self.done {\n                    None\n                } else if self.first {\n                    self.first = false;\n                    $(\n                        let $x;\n                    )*\n                    $(\n                        if let Some(x) = self.$xs.get(0) {\n                            $x = x.clone();\n                        } else {\n                            self.done = true;\n                            return None;\n                        }\n                    )*\n                    Some(($($x,)*))\n                } else if self.increment_counters() {\n                    self.done = true;\n                    None\n                } else {\n                    Some(($(self.$xs.get(self.counters[$i]).unwrap().clone(),)*))\n                }\n            }\n        }\n\n        /// This documentation applies not only to `lex_pairs`, but also to `lex_triples`,\n        /// `lex_quadruples`, and so on. See [`lex_tuples`] for more information.\n        ///\n        /// Generates all $n$-tuples with elements from $n$ iterators, in lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterators.\n        ///\n        /// All of `ys`, `zs`, ... (but not necessarily `xs`) must be finite. If `xs` is finite, the\n        /// output length is the product of the lengths of all the input iterators. If `xs` is\n        /// infinite, the output is also infinite.\n        ///\n        /// If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#lex_pairs).\n        #[allow(dead_code)]\n        $($vis)* const fn $exhaustive_fn<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            $($xs: $it,)*\n        ) -> $exhaustive_struct<$($t, $it,)*> {\n            $exhaustive_struct {\n                first: true,\n                done: false,\n                $($xs: IteratorCache::new($xs),)*\n                counters: [$($i * 0,)*],\n            }\n        }\n\n        /// This documentation applies not only to `LexPairsFromSingle`, but also to\n        /// `LexTriplesFromSingle`, `LexQuadruplesFromSingle`, and so on. See [`lex_tuples`] for\n        /// more information.\n        ///\n        /// Generates all $n$-tuples with elements a single iterator, in lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterator.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct_from_single<T: Clone, I: Iterator<Item = T>> {\n            first: bool,\n            done: bool,\n            xs: IteratorCache<I>,\n            counters: [usize; $k],\n        }\n\n        impl<T: Clone, I: Iterator<Item = T>> $exhaustive_struct_from_single<T, I> {\n            fn increment_counters(&mut self) -> bool {\n                for (i, counter) in self.counters.iter_mut().enumerate().rev() {\n                    *counter += 1;\n                    if self.xs.get(*counter).is_some() {\n                        return false;\n                    } else if i == 0 {\n                        return true;\n                    }\n                    *counter = 0;\n                }\n                false\n            }\n        }\n\n        impl<T: Clone, I: Iterator<Item = T>> Iterator for $exhaustive_struct_from_single<T, I> {\n            type Item = $single_out;\n\n            fn next(&mut self) -> Option<$single_out> {\n                if self.done {\n                    None\n                } else if self.first {\n                    self.first = false;\n                    if let Some(x) = self.xs.get(0) {\n                        Some(($(clone_helper(x, $i),)*))\n                    } else {\n                        self.done = true;\n                        None\n                    }\n                } else if self.increment_counters() {\n                    self.done = true;\n                    None\n                } else {\n                    Some(($(self.xs.get(self.counters[$i]).unwrap().clone(),)*))\n                }\n            }\n        }\n\n        /// This documentation applies not only to `lex_pairs_from_single`, but also to\n        /// `lex_triples_from_single`, `lex_quadruples_from_single`, and so on. See [`lex_tuples`]\n        /// for more information.\n        ///\n        /// Generates all $n$-tuples with elements from a single iterator, in lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterator.\n        ///\n        /// `xs` must be finite.\n        ///\n        /// The output length is $k^n$, where $k$ is `xs.count()` and $n$ is `len`.\n        ///\n        /// If `xs` is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#lex_pairs_from_single).\n        #[allow(dead_code)]\n        $($vis)* const fn $exhaustive_fn_from_single<T: Clone, I: Iterator<Item = T>>(\n            xs: I\n        ) -> $exhaustive_struct_from_single<T, I> {\n            $exhaustive_struct_from_single {\n                first: true,\n                done: false,\n                xs: IteratorCache::new(xs),\n                counters: [$($i * 0,)*],\n            }\n        }\n    }\n}\nlex_tuples!(\n    (pub),\n    2,\n    LexPairs,\n    LexPairsFromSingle,\n    lex_pairs,\n    lex_pairs_from_single,\n    (T, T),\n    [0, X, I, xs, x],\n    [1, Y, J, ys, y]\n);\nlex_tuples!(\n    (pub(crate)),\n    4,\n    LexQuadruples,\n    LexQuadruplesFromSingle,\n    lex_quadruples,\n    lex_quadruples_from_single,\n    (T, T, T, T),\n    [0, X, I, xs, x],\n    [1, Y, J, ys, y],\n    [2, Z, K, zs, z],\n    [3, W, L, ws, w]\n);\n\n/// Defines custom lexicographic tuple generators.\n///\n/// You can define custom tuple generators like `lex_triples_xxy` in your program using the code\n/// below.\n///\n/// See usage examples [here](self#lex_triples_xxy).\n///\n/// ```\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_custom_tuples;\n///\n/// fn _unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n///     (a.unwrap(), b.unwrap(), c.unwrap())\n/// }\n///\n/// lex_custom_tuples! {\n///     (pub),\n///     LexTriplesXXY,\n///     (X, X, Y),\n///     (None, None, None),\n///     _unwrap_triple,\n///     lex_triples_xxy,\n///     [X, I, xs, [0, x_0], [1, x_1]],\n///     [Y, J, ys, [2, y_2]]\n/// }\n/// lex_custom_tuples!(\n///     (pub),\n///     LexTriplesXYX,\n///     (X, Y, X),\n///     (None, None, None),\n///     _unwrap_triple,\n///     lex_triples_xyx,\n///     [X, I, xs, [0, x_0], [2, x_2]],\n///     [Y, J, ys, [1, y_1]]\n/// );\n/// lex_custom_tuples!(\n///     (pub),\n///     LexTriplesXYY,\n///     (X, Y, Y),\n///     (None, None, None),\n///     _unwrap_triple,\n///     lex_triples_xyy,\n///     [X, I, xs, [0, x_0]],\n///     [Y, J, ys, [1, y_1], [2, y_2]]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! lex_custom_tuples {\n    (\n        ($($vis:tt)*),\n        $exhaustive_struct: ident,\n        $out_t: ty,\n        $nones: expr,\n        $unwrap_tuple: ident,\n        $exhaustive_fn: ident,\n        $([$t: ident, $it: ident, $xs: ident, $([$i: tt, $x: ident]),*]),*\n    ) => {\n        // Generates all $n$-tuples with elements from $m$ iterators, where $m \\leq n$, in\n        // lexicographic order.\n        //\n        // The order is lexicographic with respect to the order of the element iterators.\n        //\n        // The mapping from iterators to tuple slots is indicated by the struct name; for example,\n        // in `LexTriplesXYX` there are two iterators, `X`, and `Y`; `X` generates the elements in\n        // the first and third slots of the output triples, and `Y` generates the elements in the\n        // second slots.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<$($t: Clone, $it: Iterator<Item = $t>,)*> {\n            first: bool,\n            done: bool,\n            $($xs: IteratorCache<$it>,)*\n            counters: Vec<usize>,\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> $exhaustive_struct<$($t, $it,)*> {\n            fn increment_counters(&mut self) -> bool {\n                for (i, counter) in self.counters.iter_mut().enumerate().rev() {\n                    *counter += 1;\n                    let no_carry = match i {\n                        $(\n                            $($i)|* => self.$xs.get(*counter).is_some(),\n                        )*\n                        _ => unreachable!(),\n                    };\n                    if no_carry {\n                        return false;\n                    } else if i == 0 {\n                        return true;\n                    }\n                    *counter = 0;\n                }\n                false\n            }\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> Iterator for $exhaustive_struct<$($t, $it,)*>\n        {\n            type Item = $out_t;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if self.done {\n                    None\n                } else if self.first {\n                    self.first = false;\n                    $($(let $x;)*)*\n                    $(\n                        if let Some(x) = self.$xs.get(0) {\n                            $($x = x.clone();)*\n                        } else {\n                            self.done = true;\n                            return None;\n                        }\n                    )*\n                    let mut out = $nones;\n                    $($(out.$i = Some($x);)*)*\n                    Some($unwrap_tuple(out))\n                } else if self.increment_counters() {\n                    self.done = true;\n                    None\n                } else {\n                    let mut out = $nones;\n                    $($(out.$i = self.$xs.get(self.counters[$i]).cloned();)*)*\n                    Some($unwrap_tuple(out))\n                }\n            }\n        }\n\n        // Generates all $n$-tuples with elements from $m$ iterators, where $m \\leq n$, in\n        // lexicographic order.\n        //\n        // The order is lexicographic with respect to the order of the element iterators.\n        //\n        // The mapping from iterators to tuple slots is indicated by the function name; for example,\n        // `lex_triples_xyx` takes two iterators, `xs`, and `ys`; `xs` generates the elements in the\n        // first and third slots of the output triples, and `ys` generates the elements in the\n        // second slots.\n        //\n        // Let `xs` be the input iterator mapped to the first slot of the output tuples. All the\n        // input iterators, except possibly `xs`, must be finite. If `xs` is finite, the output\n        // length is the product of the lengths of all the input iterators. If `xs` is infinite, the\n        // output is also infinite.\n        //\n        // If any of the input iterators is empty, the output is also empty.\n        //\n        // # Examples\n        // See [here](self#lex_triples_xyx).\n        $($vis)* fn $exhaustive_fn<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            $($xs: $it,)*\n        ) -> $exhaustive_struct<$($t, $it,)*> {\n            $exhaustive_struct {\n                first: true,\n                done: false,\n                $($xs: IteratorCache::new($xs),)*\n                counters: vec![$($(($i * 0),)*)*],\n            }\n        }\n    }\n}\n\n/// Defines exhaustive tuple generators that generate tuples from a single iterator.\n///\n/// Malachite provides [`exhaustive_pairs_from_single`] and [`exhaustive_pairs_1_input`], but you\n/// can also define `exhaustive_triples_from_single`, `exhaustive_quadruples_from_single`, and so\n/// on, and `exhaustive_triples_1_input`, `exhaustive_quadruples_1_input`, and so on, in your\n/// program using the code below. The documentation for [`exhaustive_pairs_from_single`] and\n/// [`exhaustive_pairs_1_input`] describes these other functions as well.\n///\n/// See usage examples [here](self#exhaustive_pairs_from_single) and\n/// [here](self#exhaustive_pairs_1_input).\n///\n/// ```\n/// use malachite_base::exhaustive_tuples_1_input;\n/// use malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::num::arithmetic::traits::CheckedPow;\n/// use malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n/// use malachite_base::num::logic::traits::SignificantBits;\n/// use std::cmp::max;\n/// use std::marker::PhantomData;\n///\n/// exhaustive_tuples_1_input!(\n///     (pub(crate)),\n///     ExhaustiveTriples1Input,\n///     exhaustive_triples_1_input,\n///     exhaustive_triples_from_single,\n///     (I::Item, I::Item, I::Item),\n///     [0, output_type_x],\n///     [1, output_type_y],\n///     [2, output_type_z]\n/// );\n/// exhaustive_tuples_1_input!(\n///     (pub(crate)),\n///     ExhaustiveQuadruples1Input,\n///     exhaustive_quadruples_1_input,\n///     exhaustive_quadruples_from_single,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     [0, output_type_x],\n///     [1, output_type_y],\n///     [2, output_type_z],\n///     [3, output_type_w]\n/// );\n/// exhaustive_tuples_1_input!(\n///     (pub(crate)),\n///     ExhaustiveQuintuples1Input,\n///     exhaustive_quintuples_1_input,\n///     exhaustive_quintuples_from_single,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     [0, output_type_x],\n///     [1, output_type_y],\n///     [2, output_type_z],\n///     [3, output_type_w],\n///     [4, output_type_v]\n/// );\n/// exhaustive_tuples_1_input!(\n///     (pub(crate)),\n///     ExhaustiveSextuples1Input,\n///     exhaustive_sextuples_1_input,\n///     exhaustive_sextuples_from_single,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     [0, output_type_x],\n///     [1, output_type_y],\n///     [2, output_type_z],\n///     [3, output_type_w],\n///     [4, output_type_v],\n///     [5, output_type_u]\n/// );\n/// exhaustive_tuples_1_input!(\n///     (pub(crate)),\n///     ExhaustiveSeptuples1Input,\n///     exhaustive_septuples_1_input,\n///     exhaustive_septuples_from_single,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     [0, output_type_x],\n///     [1, output_type_y],\n///     [2, output_type_z],\n///     [3, output_type_w],\n///     [4, output_type_v],\n///     [5, output_type_u],\n///     [6, output_type_t]\n/// );\n/// exhaustive_tuples_1_input!(\n///     (pub(crate)),\n///     ExhaustiveOctuples1Input,\n///     exhaustive_octuples_1_input,\n///     exhaustive_octuples_from_single,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     [0, output_type_x],\n///     [1, output_type_y],\n///     [2, output_type_z],\n///     [3, output_type_w],\n///     [4, output_type_v],\n///     [5, output_type_u],\n///     [6, output_type_t],\n///     [7, output_type_s]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! exhaustive_tuples_1_input {\n    (\n        ($($vis:tt)*),\n        $exhaustive_struct: ident,\n        $exhaustive_fn: ident,\n        $exhaustive_fn_from_single: ident,\n        $out_type: ty,\n        $([$i: tt, $out_x: ident]),*\n    ) => {\n        /// This documentation applies not only to `ExhaustivePairs1Input`, but also to\n        /// `ExhaustiveTriples1Input`, `ExhaustiveQuadruples1Input`, and so on. See\n        /// [`exhaustive_tuples_1_input`] for more information.\n        ///\n        /// Generates all $n$-tuples of a given length with elements from a single iterator.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<I: Iterator>\n        where\n            I::Item: Clone,\n        {\n            i: u64,\n            limit: Option<u64>,\n            distributor: BitDistributor,\n            xs: IteratorCache<I>,\n            xs_done: bool,\n            phantom: PhantomData<*const I::Item>,\n        }\n\n        impl<I: Iterator> Iterator for $exhaustive_struct<I>\n        where\n            I::Item: Clone,\n        {\n            type Item = $out_type;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if Some(self.i) == self.limit {\n                    None\n                } else {\n                    if self.i == u64::MAX {\n                        panic!(\"Too many iterations\");\n                    }\n                    loop {\n                        let mut all_are_valid = true;\n                        $(\n                            if all_are_valid &&\n                                    self.xs.get(self.distributor.get_output($i)).is_none() {\n                                all_are_valid = false;\n                            }\n                        )*\n                        if all_are_valid {\n                            break;\n                        } else if !self.xs_done {\n                            let xs_len = self.xs.known_len().unwrap();\n                            $(\n                                let _max_index = $i;\n                            )*\n                            let size = _max_index + 1;\n                            self.limit = CheckedPow::checked_pow(\n                                u64::exact_from(xs_len),\n                                u64::exact_from(size)\n                            );\n                            if Some(self.i) == self.limit {\n                                return None;\n                            }\n                            self.xs_done = true;\n                            // xs_len > 0 at this point\n                            self.distributor.set_max_bits(\n                                &[0],\n                                max(1, usize::wrapping_from((xs_len - 1).significant_bits())),\n                            );\n                        } else {\n                            self.distributor.increment_counter();\n                        }\n                    }\n                    let result = Some(\n                        ($(self.xs.get(self.distributor.get_output($i)).unwrap().clone(),)*)\n                    );\n                    self.i += 1;\n                    self.distributor.increment_counter();\n                    result\n                }\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_pairs_1_input`, but also to\n        /// `exhaustive_triples_1_input`, `exhaustive_quadruples_1_input`, and so on. See\n        /// [`exhaustive_tuples_1_input`] for more information.\n        ///\n        /// Generates all length-$n$ tuples with elements from a single iterator.\n        ///\n        /// These functions differ from `exhaustive_[n-tuples]_from_single` in that different\n        /// [`BitDistributorOutputType`]s may be specified for each output element.\n        ///\n        /// The $i$th parameter `output_types_[x_i]` is a [`BitDistributorOutputType`] that\n        /// determines how quickly the $i$th output slot advances through the iterator; see the\n        /// [`BitDistributor`] documentation for a description of the different types.\n        ///\n        /// If `xs` is finite, the output length is $k^n$, where $k$ is `xs.count()` and $n$ is the\n        /// width of the tuples. If `xs` is infinite, the output is also infinite.\n        ///\n        /// If `xs` is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_pairs_1_input).\n        #[allow(dead_code)]\n        $($vis)* fn $exhaustive_fn<I: Iterator>(\n            xs: I,\n            $($out_x: BitDistributorOutputType,)*\n        ) -> $exhaustive_struct<I>\n        where\n            I::Item: Clone,\n        {\n            $exhaustive_struct {\n                i: 0,\n                limit: None,\n                distributor: BitDistributor::new(&[$($out_x,)*]),\n                xs: IteratorCache::new(xs),\n                xs_done: false,\n                phantom: PhantomData,\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_pairs_from_single`, but also to\n        /// `exhaustive_triples_from_single`, `exhaustive_quadruples_from_single`, and so on. See\n        /// [`exhaustive_tuples_1_input`] for more information.\n        ///\n        /// Generates all $n$-tuples with elements from a single iterator.\n        ///\n        /// If `xs` is finite, the output length is $k^n$, where $k$ is `xs.count()` and $n$ is the\n        /// width of the tuples. If `xs` is infinite, the output is also infinite.\n        ///\n        /// If `xs` is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_pairs_from_single).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* fn $exhaustive_fn_from_single<I: Iterator>(xs: I) -> $exhaustive_struct<I>\n        where\n            I::Item: Clone,\n        {\n            $exhaustive_fn(xs, $(BitDistributorOutputType::normal(1 + $i * 0)),*)\n        }\n    }\n}\nexhaustive_tuples_1_input!(\n    (pub),\n    ExhaustivePairs1Input,\n    exhaustive_pairs_1_input,\n    exhaustive_pairs_from_single,\n    (I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y]\n);\n\n/// Defines exhaustive tuple generators.\n///\n/// Malachite provides [`exhaustive_pairs`] and [`exhaustive_pairs_custom_output`], but you can also\n/// define `exhaustive_triples`, `exhaustive_quadruples`, and so on, and\n/// `exhaustive_triples_custom_output`, `exhaustive_quadruples_custom_output`, and so on, in your\n/// program using the code below. The documentation for [`exhaustive_pairs`] and\n/// [`exhaustive_pairs_custom_output`] describes these other functions as well.\n///\n/// See usage examples [here](self#exhaustive_pairs) and\n/// [here](self#exhaustive_pairs_custom_output).\n///\n/// ```\n/// use malachite_base::exhaustive_tuples;\n/// use malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n/// use malachite_base::num::logic::traits::SignificantBits;\n/// use std::cmp::max;\n///\n/// exhaustive_tuples!(\n///     (pub(crate)),\n///     ExhaustiveTriples,\n///     exhaustive_triples,\n///     exhaustive_triples_custom_output,\n///     [0, X, I, xs, xs_done, output_type_x],\n///     [1, Y, J, ys, ys_done, output_type_y],\n///     [2, Z, K, zs, zs_done, output_type_z]\n/// );\n/// exhaustive_tuples!(\n///     (pub(crate)),\n///     ExhaustiveQuadruples,\n///     exhaustive_quadruples,\n///     exhaustive_quadruples_custom_output,\n///     [0, X, I, xs, xs_done, output_type_x],\n///     [1, Y, J, ys, ys_done, output_type_y],\n///     [2, Z, K, zs, zs_done, output_type_z],\n///     [3, W, L, ws, ws_done, output_type_w]\n/// );\n/// exhaustive_tuples!(\n///     (pub(crate)),\n///     ExhaustiveQuintuples,\n///     exhaustive_quintuples,\n///     exhaustive_quintuples_custom_output,\n///     [0, X, I, xs, xs_done, output_type_x],\n///     [1, Y, J, ys, ys_done, output_type_y],\n///     [2, Z, K, zs, zs_done, output_type_z],\n///     [3, W, L, ws, ws_done, output_type_w],\n///     [4, V, M, vs, vs_done, output_type_v]\n/// );\n/// exhaustive_tuples!(\n///     (pub(crate)),\n///     ExhaustiveSextuples,\n///     exhaustive_sextuples,\n///     exhaustive_sextuples_custom_output,\n///     [0, X, I, xs, xs_done, output_type_x],\n///     [1, Y, J, ys, ys_done, output_type_y],\n///     [2, Z, K, zs, zs_done, output_type_z],\n///     [3, W, L, ws, ws_done, output_type_w],\n///     [4, V, M, vs, vs_done, output_type_v],\n///     [5, U, N, us, us_done, output_type_u]\n/// );\n/// exhaustive_tuples!(\n///     (pub(crate)),\n///     ExhaustiveSeptuples,\n///     exhaustive_septuples,\n///     exhaustive_septuples_custom_output,\n///     [0, X, I, xs, xs_done, output_type_x],\n///     [1, Y, J, ys, ys_done, output_type_y],\n///     [2, Z, K, zs, zs_done, output_type_z],\n///     [3, W, L, ws, ws_done, output_type_w],\n///     [4, V, M, vs, vs_done, output_type_v],\n///     [5, U, N, us, us_done, output_type_u],\n///     [6, T, O, ts, ts_done, output_type_t]\n/// );\n/// exhaustive_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOctuples,\n///     exhaustive_octuples,\n///     exhaustive_octuples_custom_output,\n///     [0, X, I, xs, xs_done, output_type_x],\n///     [1, Y, J, ys, ys_done, output_type_y],\n///     [2, Z, K, zs, zs_done, output_type_z],\n///     [3, W, L, ws, ws_done, output_type_w],\n///     [4, V, M, vs, vs_done, output_type_v],\n///     [5, U, N, us, us_done, output_type_u],\n///     [6, T, O, ts, ts_done, output_type_t],\n///     [7, S, P, ss, ss_done, output_type_s]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! exhaustive_tuples {\n    (\n        ($($vis:tt)*),\n        $exhaustive_struct: ident,\n        $exhaustive_fn: ident,\n        $exhaustive_fn_custom_output: ident,\n        $([$i: tt, $t: ident, $it: ident, $xs: ident, $xs_done: ident, $out_x: ident]),*\n    ) => {\n        /// This documentation applies not only to `ExhaustivePairs`, but also to\n        /// `ExhaustiveTriples`, `ExhaustiveQuadruples`, and so on. See [`exhaustive_tuples`] for\n        /// more information.\n        ///\n        /// Generates all $n$-tuples with elements from $n$ iterators.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<$($t: Clone, $it: Iterator<Item = $t>,)*> {\n            i: u64,\n            limit: Option<u64>,\n            distributor: BitDistributor,\n            $(\n                $xs: IteratorCache<$it>,\n                $xs_done: bool,\n            )*\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> $exhaustive_struct<$($t, $it,)*> {\n            fn try_getting_limit(&mut self) {\n                let mut all_limits_known = true;\n                $(\n                    if let Some(xs_len) = self.$xs.known_len() {\n                        if xs_len == 0 {\n                            self.limit = Some(0);\n                            return;\n                        }\n                    } else {\n                        all_limits_known = false;\n                    }\n                )*\n                if !all_limits_known {\n                    return;\n                }\n                let mut product = 1u64;\n                $(\n                    let xs_len = u64::exact_from(self.$xs.known_len().unwrap());\n                    if let Some(new_product) = product.checked_mul(u64::exact_from(xs_len)) {\n                        product = new_product;\n                    } else {\n                        return;\n                    }\n                )*\n                self.limit = Some(product);\n            }\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> Iterator for $exhaustive_struct<$($t, $it,)*>\n        {\n            type Item = ($($t,)*);\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if Some(self.i) == self.limit {\n                    None\n                } else {\n                    if self.i == u64::MAX {\n                        panic!(\"Too many iterations\");\n                    }\n                    loop {\n                        $(\n                            if self.$xs.get(self.distributor.get_output($i)).is_none() {\n                                if !self.$xs_done {\n                                    let xs_len = self.$xs.known_len().unwrap();\n                                    self.try_getting_limit();\n                                    if Some(self.i) == self.limit {\n                                        return None;\n                                    }\n                                    self.$xs_done = true;\n                                    self.distributor.set_max_bits(\n                                        &[$i],\n                                        max(\n                                            1,\n                                            usize::wrapping_from((xs_len - 1).significant_bits())\n                                        ),\n                                    );\n                                } else {\n                                    self.distributor.increment_counter();\n                                }\n                                continue;\n                            }\n                        )*\n                        break;\n                    }\n                    let result = Some(\n                        ($(self.$xs.get(self.distributor.get_output($i)).unwrap().clone(),)*)\n                    );\n                    self.i += 1;\n                    self.distributor.increment_counter();\n                    result\n                }\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_pairs_custom_output`, but also to\n        /// `exhaustive_triples_custom_output`, `exhaustive_quadruples_custom_output`, and so on.\n        /// See [`exhaustive_tuples`] for more information.\n        ///\n        /// Generates all $n$-tuples with elements from $n$ iterators, possibly with different\n        /// output growth rates.\n        ///\n        /// The $i$th `output_type_[x_i]` parameter is a [`BitDistributorOutputType`] that\n        /// determines how quickly the $i$th output slot advances through its iterator; see the\n        /// [`BitDistributor`] documentation for a description of the different types.\n        ///\n        /// If all of `xs`, `ys`, `zs`, ... are finite, the output length is the product of their\n        /// lengths. If any of `xs`, `ys`, `zs`, ... are infinite, the output is also infinite.\n        ///\n        /// If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_pairs_custom_output).\n        #[allow(dead_code)]\n        $($vis)* fn $exhaustive_fn_custom_output<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            $($xs: $it,)*\n            $($out_x: BitDistributorOutputType,)*\n        ) -> $exhaustive_struct<$($t, $it,)*> {\n            $exhaustive_struct {\n                i: 0,\n                limit: None,\n                distributor: BitDistributor::new(&[$($out_x,)*]),\n                $(\n                    $xs: IteratorCache::new($xs),\n                    $xs_done: false,\n                )*\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_pairs`, but also to\n        /// `exhaustive_triples`, `exhaustive_quadruples`, and so on. See [`exhaustive_tuples`] for\n        /// more information.\n        ///\n        /// Generates all $n$-tuples with elements from $n$ iterators.\n        ///\n        /// If all of `xs`, `ys`, `zs`, ... are finite, the output length is the product of their\n        /// lengths. If any of `xs`, `ys`, `zs`, ... are infinite, the output is also infinite.\n        ///\n        /// If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_pairs).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* fn $exhaustive_fn<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            $($xs: $it,)*\n        ) -> $exhaustive_struct<$($t, $it,)*> {\n            $exhaustive_fn_custom_output(\n                $($xs,)*\n                $(BitDistributorOutputType::normal(1 + 0 * $i),)*\n            )\n        }\n    }\n}\n\nexhaustive_tuples!(\n    (pub),\n    ExhaustivePairs,\n    exhaustive_pairs,\n    exhaustive_pairs_custom_output,\n    [0, X, I, xs, xs_done, output_type_x],\n    [1, Y, J, ys, ys_done, output_type_y]\n);\n\n#[cfg(feature = \"test_build\")]\nexhaustive_tuples!(\n    (pub),\n    ExhaustiveTriples,\n    exhaustive_triples,\n    exhaustive_triples_custom_output,\n    [0, X, I, xs, xs_done, output_type_x],\n    [1, Y, J, ys, ys_done, output_type_y],\n    [2, Z, K, zs, zs_done, output_type_z]\n);\n\n#[cfg(not(feature = \"test_build\"))]\nexhaustive_tuples!(\n    (pub(crate)),\n    ExhaustiveTriples,\n    exhaustive_triples,\n    exhaustive_triples_custom_output,\n    [0, X, I, xs, xs_done, output_type_x],\n    [1, Y, J, ys, ys_done, output_type_y],\n    [2, Z, K, zs, zs_done, output_type_z]\n);\n\n#[cfg(feature = \"test_build\")]\nexhaustive_tuples!(\n    (pub),\n    ExhaustiveQuadruples,\n    exhaustive_quadruples,\n    exhaustive_quadruples_custom_output,\n    [0, X, I, xs, xs_done, output_type_x],\n    [1, Y, J, ys, ys_done, output_type_y],\n    [2, Z, K, zs, zs_done, output_type_z],\n    [3, W, L, ws, ws_done, output_type_w]\n);\n\n/// Defines custom exhaustive tuple generators.\n///\n/// You can define custom tuple generators like `exhaustive_triples_xyx` or\n/// `exhaustive_triples_xyx_custom_output` in your program using the code below.\n///\n/// See usage examples [here](self#exhaustive_triples_xyx) and\n/// [here](self#exhaustive_triples_xyx_custom_output).\n///\n/// ```\n/// use malachite_base::custom_tuples;\n/// use malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n/// use malachite_base::num::logic::traits::SignificantBits;\n/// use std::cmp::max;\n///\n/// #[allow(clippy::missing_const_for_fn)]\n/// fn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n///     (a.unwrap(), b.unwrap(), c.unwrap())\n/// }\n///\n/// #[allow(clippy::missing_const_for_fn)]\n/// fn unwrap_quadruple<X, Y, Z, W>(\n///     (a, b, c, d): (Option<X>, Option<Y>, Option<Z>, Option<W>),\n/// ) -> (X, Y, Z, W) {\n///     (a.unwrap(), b.unwrap(), c.unwrap(), d.unwrap())\n/// }\n///\n/// #[allow(clippy::missing_const_for_fn)]\n/// fn unwrap_quintuple<X, Y, Z, W, V>(\n///     (a, b, c, d, e): (Option<X>, Option<Y>, Option<Z>, Option<W>, Option<V>),\n/// ) -> (X, Y, Z, W, V) {\n///     (a.unwrap(), b.unwrap(), c.unwrap(), d.unwrap(), e.unwrap())\n/// }\n///\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveTriplesXXY,\n///     (X, X, Y),\n///     (None, None, None),\n///     unwrap_triple,\n///     exhaustive_triples_xxy,\n///     exhaustive_triples_xxy_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n///     [Y, J, ys, ys_done, [2, output_type_ys_2]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveTriplesXYX,\n///     (X, Y, X),\n///     (None, None, None),\n///     unwrap_triple,\n///     exhaustive_triples_xyx,\n///     exhaustive_triples_xyx_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_ys_1]],\n///     [Y, J, ys, ys_done, [1, output_type_xs_2]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveTriplesXYY,\n///     (X, Y, Y),\n///     (None, None, None),\n///     unwrap_triple,\n///     exhaustive_triples_xyy,\n///     exhaustive_triples_xyy_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0]],\n///     [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuadruplesXXXY,\n///     (X, X, X, Y),\n///     (None, None, None, None),\n///     unwrap_quadruple,\n///     exhaustive_quadruples_xxxy,\n///     exhaustive_quadruples_xxxy_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1], [2, output_type_xs_2]],\n///     [Y, J, ys, ys_done, [3, output_type_ys_3]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuadruplesXXYX,\n///     (X, X, Y, X),\n///     (None, None, None, None),\n///     unwrap_quadruple,\n///     exhaustive_quadruples_xxyx,\n///     exhaustive_quadruples_xxyx_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1], [3, output_type_xs_3]],\n///     [Y, J, ys, ys_done, [2, output_type_ys_2]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuadruplesXXYZ,\n///     (X, X, Y, Z),\n///     (None, None, None, None),\n///     unwrap_quadruple,\n///     exhaustive_quadruples_xxyz,\n///     exhaustive_quadruples_xxyz_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n///     [Y, J, ys, ys_done, [2, output_type_ys_2]],\n///     [Z, K, zs, zs_done, [3, output_type_zs_3]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuadruplesXYXZ,\n///     (X, Y, X, Z),\n///     (None, None, None, None),\n///     unwrap_quadruple,\n///     exhaustive_quadruples_xyxz,\n///     exhaustive_quadruples_xyxz_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_xs_2]],\n///     [Y, J, ys, ys_done, [1, output_type_ys_1]],\n///     [Z, K, zs, zs_done, [3, output_type_zs_3]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuadruplesXYYX,\n///     (X, Y, Y, X),\n///     (None, None, None, None),\n///     unwrap_quadruple,\n///     exhaustive_quadruples_xyyx,\n///     exhaustive_quadruples_xyyx_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [3, output_type_xs_3]],\n///     [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuadruplesXYYZ,\n///     (X, Y, Y, Z),\n///     (None, None, None, None),\n///     unwrap_quadruple,\n///     exhaustive_quadruples_xyyz,\n///     exhaustive_quadruples_xyyz_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0]],\n///     [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]],\n///     [Z, K, zs, zs_done, [3, output_type_zs_3]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuadruplesXYZZ,\n///     (X, Y, Z, Z),\n///     (None, None, None, None),\n///     unwrap_quadruple,\n///     exhaustive_quadruples_xyzz,\n///     exhaustive_quadruples_xyzz_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0]],\n///     [Y, J, ys, ys_done, [1, output_type_ys_1]],\n///     [Z, K, zs, zs_done, [2, output_type_zs_2], [3, output_type_zs_3]]\n/// );\n/// custom_tuples!(\n///     (pub),\n///     ExhaustiveQuintuplesXYYYZ,\n///     (X, Y, Y, Y, Z),\n///     (None, None, None, None, None),\n///     unwrap_quintuple,\n///     exhaustive_quintuples_xyyyz,\n///     exhaustive_quintuples_xyyyz_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0]],\n///     [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2], [3, output_type_ys_3]],\n///     [Z, K, zs, zs_done, [4, output_type_zs_4]]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! custom_tuples {\n    (\n        ($($vis:tt)*),\n        $exhaustive_struct: ident,\n        $out_t: ty,\n        $nones: expr,\n        $unwrap_tuple: ident,\n        $exhaustive_fn: ident,\n        $exhaustive_custom_fn: ident,\n        $([$t: ident, $it: ident, $xs: ident, $xs_done: ident, $([$i: tt, $out_x: ident]),*]),*\n    ) => {\n        // Generates all $n$-tuples with elements from $m$ iterators, where $m \\leq n$.\n        //\n        // The mapping from iterators to tuple slots is indicated by the struct name; for example,\n        // in `TriplesXYX` there are two iterators, `X`, and `Y`; `X` generates the elements in the\n        // first and third slots of the output triples, and `Y` generates the elements in the second\n        // slots.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<$($t: Clone, $it: Iterator<Item = $t>,)*> {\n            i: u64,\n            limit: Option<u64>,\n            distributor: BitDistributor,\n            $(\n                $xs: IteratorCache<$it>,\n                $xs_done: bool,\n            )*\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> $exhaustive_struct<$($t, $it,)*> {\n            fn try_getting_limit(&mut self) {\n                let mut all_limits_known = true;\n                $(\n                    if let Some(xs_len) = self.$xs.known_len() {\n                        if xs_len == 0 {\n                            self.limit = Some(0);\n                            return;\n                        }\n                    } else {\n                        all_limits_known = false;\n                    }\n                )*\n                if !all_limits_known {\n                    return;\n                }\n                let mut product = 1u64;\n                $(\n                    let xs_len = u64::exact_from(self.$xs.known_len().unwrap());\n                    $(\n                        let _x = $i;\n                        if let Some(new_product) = product.checked_mul(xs_len) {\n                            product = new_product;\n                        } else {\n                            return;\n                        }\n                    )*\n                )*\n                self.limit = Some(product);\n            }\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> Iterator\n            for $exhaustive_struct<$($t, $it,)*>\n        {\n            type Item = $out_t;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if Some(self.i) == self.limit {\n                    None\n                } else {\n                    if self.i == u64::MAX {\n                        panic!(\"Too many iterations\");\n                    }\n                    loop {\n                        $(\n                            $(\n                                if self.$xs.get(self.distributor.get_output($i)).is_none() {\n                                    if !self.$xs_done {\n                                        let xs_len = self.$xs.known_len().unwrap();\n                                        self.try_getting_limit();\n                                        if Some(self.i) == self.limit {\n                                            return None;\n                                        }\n                                        self.$xs_done = true;\n                                        self.distributor.set_max_bits(\n                                            &[$i],\n                                            max(\n                                                1,\n                                                usize::wrapping_from(\n                                                    (xs_len - 1).significant_bits()\n                                                )\n                                            ),\n                                        );\n                                    } else {\n                                        self.distributor.increment_counter();\n                                    }\n                                    continue;\n                                }\n                            )*\n                        )*\n                        break;\n                    }\n                    let mut out = $nones;\n                    $(\n                        $(\n                            let x = self.$xs.get(self.distributor.get_output($i)).unwrap();\n                            out.$i = Some(x.clone());\n                        )*\n                    )*\n                    self.i += 1;\n                    self.distributor.increment_counter();\n                    Some($unwrap_tuple(out))\n                }\n            }\n        }\n\n        // Generates all $n$-tuples with elements from $m$ iterators, where $m \\leq n$, possibly\n        // with different output growth rates.\n        //\n        // The mapping from iterators to tuple slots is indicated by the function name; for example,\n        // `exhaustive_triples_xyx_custom_output` takes two iterators, `xs`, and `ys`; `xs`\n        // generates the elements in the first and third slots of the output triples, and `ys`\n        // generates the elements in the second slots.\n        //\n        // Let $i$ be the index of the input iterators and $j$ be the index of the output slots. So\n        // for `exhaustive_triples_xyx_custom_output`, $i=0$ corresponds to $j=0$ and $j=2$, and\n        // $i=1$ corresponds to $j=1$.\n        //\n        // The $j$th `output_type_[i_j]` parameter is a\n        // [`BitDistributorOutputType`](crate::iterators::bit_distributor::BitDistributorOutputType)\n        // that determines how quickly the $j$th output slot advances through its iterator; see the\n        // [`BitDistributor`](crate::iterators::bit_distributor::BitDistributor) documentation for a\n        // description of the different types.\n        //\n        // If all of `xs`, `ys`, `zs`, ... are finite, then the output length may be obtained by\n        // raising the length of each input iterator to power of the number of outputs it maps to,\n        // and taking the product of the resulting values.\n        //\n        // If any of `xs`, `ys`, `zs`, ... are infinite, the output is also infinite.\n        //\n        // If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        //\n        // # Examples\n        // See [here](self#exhaustive_triples_xyx_custom_output).\n        #[allow(dead_code)]\n        $($vis)* fn $exhaustive_custom_fn<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            $($xs: $it,)*\n            $($($out_x: BitDistributorOutputType,)*)*\n        ) -> $exhaustive_struct<$($t, $it,)*> {\n            $exhaustive_struct {\n                i: 0,\n                limit: None,\n                distributor: BitDistributor::new(&[$($($out_x,)*)*]),\n                $(\n                    $xs: IteratorCache::new($xs),\n                    $xs_done: false,\n                )*\n            }\n        }\n\n        // Generates all $n$-tuples with elements from $m$ iterators, where $m \\leq n$.\n        //\n        // The mapping from iterators to tuple slots is indicated by the function name; for example,\n        // `exhaustive_triples_xyx` takes two iterators, `xs`, and `ys`; `xs` generates the elements\n        // in the first and third slots of the output triples, and `ys` generates the elements in\n        // the second slots.\n        //\n        // If all of `xs`, `ys`, `zs`, ... are finite, then the output length may be obtained by\n        // raising the length of each input iterator to power of the number of outputs it maps to,\n        // and taking the product of the resulting values.\n        //\n        // If any of `xs`, `ys`, `zs`, ... are infinite, the output is also infinite.\n        //\n        // If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        //\n        // # Examples\n        // See [here](self#exhaustive_triples_xyx).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* fn $exhaustive_fn<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            $($xs: $it,)*\n        ) -> $exhaustive_struct<$($t, $it,)*> {\n            $exhaustive_custom_fn(\n                $($xs,)*\n                $($(BitDistributorOutputType::normal(1 + 0 * $i),)*)*\n            )\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n    (a.unwrap(), b.unwrap(), c.unwrap())\n}\n\n#[cfg(feature = \"test_build\")]\ncustom_tuples!(\n    (pub),\n    ExhaustiveTriplesXYY,\n    (X, Y, Y),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xyy,\n    exhaustive_triples_xyy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]]\n);\n\n/// A trait used by dependent-pairs structs.\n///\n/// Given a reference to an `x`, produces an iterator of `ys`.\n///\n/// See [`LexDependentPairs`] and [`ExhaustiveDependentPairs`].\npub trait ExhaustiveDependentPairsYsGenerator<X: Clone, Y, J: Iterator<Item = Y>> {\n    fn get_ys(&self, x: &X) -> J;\n}\n\n/// Generates pairs $(x, y)$, where the possible values of $y$ depend on the value of $x$. All $y$\n/// values are output before proceeding to the next $x$.\n///\n/// This `struct` is created by; [`lex_dependent_pairs`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct LexDependentPairs<\n    X: Clone,\n    Y,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n> {\n    done: bool,\n    stop_after_empty_ys: bool,\n    xs: I,\n    ys: Option<J>,\n    x: Option<X>,\n    ys_generator: S,\n}\n\nimpl<\n    X: Clone,\n    Y,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n> LexDependentPairs<X, Y, S, I, J>\n{\n    fn advance_xs(&mut self) -> bool {\n        if let Some(next_x) = self.xs.next() {\n            self.x = Some(next_x);\n            self.ys = Some(self.ys_generator.get_ys(self.x.as_ref().unwrap()));\n            false\n        } else {\n            true\n        }\n    }\n}\n\nimpl<\n    X: Clone,\n    Y,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n> Iterator for LexDependentPairs<X, Y, S, I, J>\n{\n    type Item = (X, Y);\n\n    fn next(&mut self) -> Option<(X, Y)> {\n        if self.done {\n            None\n        } else {\n            let mut new_ys = false;\n            if self.x.is_none() {\n                if self.advance_xs() {\n                    self.done = true;\n                    return None;\n                }\n                new_ys = true;\n            }\n            loop {\n                if let Some(y) = self.ys.as_mut().unwrap().next() {\n                    return Some((self.x.as_ref().unwrap().clone(), y));\n                } else if self.stop_after_empty_ys && new_ys || self.advance_xs() {\n                    self.done = true;\n                    return None;\n                }\n                new_ys = true;\n            }\n        }\n    }\n}\n\n/// Generates pairs $(x, y)$, where the possible values of $y$ depend on the value of $x$. All $y$\n/// values are output before proceeding to the next $x$.\n///\n/// This function takes an iterator `xs` that produces $x$ values, along with a `ys_generator` that\n/// creates an iterator of $y$ values when given a reference to an $x$ value. The resulting iterator\n/// first generates all pairs generated by the first $x$ value, then all pairs generated by the\n/// second $x$ value, and so on.\n///\n/// It's called `lex_dependent_pairs` because if the `xs` iterator produces elements in some order,\n/// and each `ys` iterator produces elements in some order (uniform across all `ys`), then the\n/// resulting pairs are output in lexicographic order with respect to the $x$ and $y$ orders.\n///\n/// Each `ys` iterator produced by `ys_generator` must be finite; if some `ys` is infinite, then no\n/// further `xs` value will be used. For a similar function that works with infinite `ys`, see\n/// [`exhaustive_dependent_pairs`].\n///\n/// If, after a certain point, all the generated `ys` are empty, the output iterator will hang\n/// trying to find another $(x, y)$ to output. To get around this, try\n/// [`lex_dependent_pairs_stop_after_empty_ys`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::{\n///     lex_dependent_pairs, ExhaustiveDependentPairsYsGenerator,\n/// };\n/// use maplit::hashmap;\n/// use std::collections::HashMap;\n/// use std::hash::Hash;\n/// use std::iter::Cloned;\n/// use std::slice::Iter;\n///\n/// #[derive(Clone, Debug)]\n/// struct DPGeneratorFromMap<X: Clone + Eq + Hash, Y: 'static + Clone> {\n///     map: HashMap<X, &'static [Y]>,\n/// }\n///\n/// impl<X: Clone + Eq + Hash, Y: 'static + Clone>\n///     ExhaustiveDependentPairsYsGenerator<X, Y, Cloned<Iter<'static, Y>>>\n///     for DPGeneratorFromMap<X, Y>\n/// {\n///     #[inline]\n///     fn get_ys(&self, x: &X) -> Cloned<Iter<'static, Y>> {\n///         self.map[x].iter().cloned()\n///     }\n/// }\n///\n/// let xs = [\"a\", \"b\", \"c\", \"b\", \"a\"].iter().cloned();\n/// let xss = lex_dependent_pairs(\n///     xs,\n///     DPGeneratorFromMap {\n///         map: hashmap! {\n///             \"a\" => &[2, 3, 4][..],\n///             \"b\" => &[20][..],\n///             \"c\" => &[30, 40][..]\n///         },\n///     },\n/// )\n/// .take(20)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.as_slice(),\n///     &[\n///         (\"a\", 2),\n///         (\"a\", 3),\n///         (\"a\", 4),\n///         (\"b\", 20),\n///         (\"c\", 30),\n///         (\"c\", 40),\n///         (\"b\", 20),\n///         (\"a\", 2),\n///         (\"a\", 3),\n///         (\"a\", 4)\n///     ]\n/// );\n///\n/// let xs = [1, 2, 3, 2, 3, 2, 2].iter().cloned();\n/// let xss = lex_dependent_pairs(\n///     xs,\n///     DPGeneratorFromMap {\n///         map: hashmap! {\n///             1 => &[100, 101, 102][..],\n///             2 => &[][..],\n///             3 => &[300, 301, 302][..]\n///         },\n///     },\n/// )\n/// .take(20)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.as_slice(),\n///     &[(1, 100), (1, 101), (1, 102), (3, 300), (3, 301), (3, 302), (3, 300), (3, 301), (3, 302),]\n/// );\n/// ```\n#[inline]\npub const fn lex_dependent_pairs<\n    X: Clone,\n    Y,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n>(\n    xs: I,\n    ys_generator: S,\n) -> LexDependentPairs<X, Y, S, I, J> {\n    LexDependentPairs {\n        done: false,\n        stop_after_empty_ys: false,\n        xs,\n        ys: None,\n        x: None,\n        ys_generator,\n    }\n}\n\n/// Generates pairs $(x, y)$, where the possible values of $y$ depend on the value of $x$. $x$\n/// values with no corresponding $y$ values are treated specially.\n///\n/// See [`lex_dependent_pairs`] for context.\n///\n/// If the output iterator encounters an $x$ value whose corresponding `ys` iterator is empty, the\n/// output iterator stops iterating altogether. This prevents the iterator from getting stuck if all\n/// `ys` iterators after a certain point are empty.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::{\n///     lex_dependent_pairs_stop_after_empty_ys, ExhaustiveDependentPairsYsGenerator,\n/// };\n/// use maplit::hashmap;\n/// use std::collections::HashMap;\n/// use std::hash::Hash;\n/// use std::iter::Cloned;\n/// use std::slice::Iter;\n///\n/// #[derive(Clone, Debug)]\n/// struct DPGeneratorFromMap<X: Clone + Eq + Hash, Y: 'static + Clone> {\n///     map: HashMap<X, &'static [Y]>,\n/// }\n///\n/// impl<X: Clone + Eq + Hash, Y: 'static + Clone>\n///     ExhaustiveDependentPairsYsGenerator<X, Y, Cloned<Iter<'static, Y>>>\n///     for DPGeneratorFromMap<X, Y>\n/// {\n///     #[inline]\n///     fn get_ys(&self, x: &X) -> Cloned<Iter<'static, Y>> {\n///         self.map[x].iter().cloned()\n///     }\n/// }\n///\n/// let xs = [1, 2, 3, 2, 3, 2, 2].iter().cloned();\n/// let xss = lex_dependent_pairs_stop_after_empty_ys(\n///     xs,\n///     DPGeneratorFromMap {\n///         map: hashmap! {\n///             1 => &[100, 101, 102][..],\n///             2 => &[][..],\n///             3 => &[300, 301, 302][..]\n///         },\n///     },\n/// )\n/// .take(20)\n/// .collect_vec();\n/// // Stops after seeing 2, which maps to an empty iterator\n/// assert_eq!(xss.as_slice(), &[(1, 100), (1, 101), (1, 102)]);\n/// ```\n#[inline]\npub const fn lex_dependent_pairs_stop_after_empty_ys<\n    X: Clone,\n    Y,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n>(\n    xs: I,\n    ys_generator: S,\n) -> LexDependentPairs<X, Y, S, I, J> {\n    LexDependentPairs {\n        done: false,\n        stop_after_empty_ys: true,\n        xs,\n        ys: None,\n        x: None,\n        ys_generator,\n    }\n}\n\n/// Generates pairs $(x, y)$, where the possible values of $y$ depend on the value of $x$.\n///\n/// This `struct` is created by [`exhaustive_dependent_pairs`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveDependentPairs<\n    X: Clone,\n    Y,\n    G: Iterator<Item = usize>,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n> {\n    done: bool,\n    xs_done: bool,\n    stop_after_empty_ys: bool,\n    index_generator: G,\n    xs: I,\n    xs_yss: Vec<(X, J, bool)>,\n    ys_generator: S,\n}\n\nimpl<\n    X: Clone,\n    Y,\n    G: Iterator<Item = usize>,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n> Iterator for ExhaustiveDependentPairs<X, Y, G, S, I, J>\n{\n    type Item = (X, Y);\n\n    fn next(&mut self) -> Option<(X, Y)> {\n        if self.done {\n            None\n        } else {\n            let original_i = self.index_generator.next().unwrap();\n            loop {\n                let mut i = original_i;\n                let mut xs_yss_len = self.xs_yss.len();\n                if self.xs_done {\n                    i %= xs_yss_len;\n                } else if i >= xs_yss_len {\n                    for x in (&mut self.xs).take(i - xs_yss_len + 1) {\n                        let ys = self.ys_generator.get_ys(&x);\n                        self.xs_yss.push((x, ys, true));\n                    }\n                    xs_yss_len = self.xs_yss.len();\n                    if xs_yss_len == 0 {\n                        self.done = true;\n                        return None;\n                    } else if i >= xs_yss_len {\n                        self.xs_done = true;\n                        i %= xs_yss_len;\n                    }\n                }\n                let t = &mut self.xs_yss[i];\n                if let Some(y) = t.1.next() {\n                    // t has been used\n                    t.2 = false;\n                    return Some((t.0.clone(), y));\n                } else if self.stop_after_empty_ys && t.2 {\n                    self.done = true;\n                    return None;\n                }\n                self.xs_yss.remove(i);\n                if self.xs_done && self.xs_yss.is_empty() {\n                    self.done = true;\n                    return None;\n                }\n            }\n        }\n    }\n}\n\n/// Generates pairs $(x, y)$, where the possible values of $y$ depend on the value of $x$.\n///\n/// This function takes an iterator `xs` that produces $x$ values, along with a `ys_generator` that\n/// creates an iterator of $y$ values when given a reference to an $x$ value. The resulting iterator\n/// does not use all of an $x$'s $y$s immediately. Instead, it uses an `index_generator` (an\n/// iterator of `usize`s) to determine which $x$ value's iterator should be advanced. This\n/// arrangement allows for an $x$ to map to infinitely many `ys`.\n///\n/// `index_generator` must generate every natural number infinitely many times. Good generators can\n/// be created using [`ruler_sequence`](crate::num::iterators::ruler_sequence) or\n/// [`bit_distributor_sequence`](crate::num::iterators::bit_distributor_sequence). The slower the\n/// sequence's growth rate, the more this iterator will prefer to use initial $x$ values before\n/// exploring later ones.\n///\n/// If you want all of an $x$ value's $y$s to be used before moving on to the next $x$, use\n/// [`lex_dependent_pairs`] instead.\n///\n/// If, after a certain point, all the generated `ys` are empty, the output iterator will hang\n/// trying to find another $(x, y)$ to output. To get around this, try\n/// [`exhaustive_dependent_pairs_stop_after_empty_ys`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_positive_primitive_ints;\n/// use malachite_base::num::iterators::ruler_sequence;\n/// use malachite_base::tuples::exhaustive::{\n///     exhaustive_dependent_pairs, ExhaustiveDependentPairsYsGenerator,\n/// };\n/// use maplit::hashmap;\n/// use std::collections::HashMap;\n/// use std::hash::Hash;\n/// use std::iter::Cloned;\n/// use std::slice::Iter;\n///\n/// #[derive(Clone, Debug)]\n/// struct MultiplesGeneratorHelper {\n///     u: u64,\n///     step: u64,\n/// }\n///\n/// impl Iterator for MultiplesGeneratorHelper {\n///     type Item = u64;\n///\n///     fn next(&mut self) -> Option<u64> {\n///         let next = self.u;\n///         self.u += self.step;\n///         Some(next)\n///     }\n/// }\n///\n/// #[derive(Clone, Debug)]\n/// struct MultiplesGenerator {}\n///\n/// impl ExhaustiveDependentPairsYsGenerator<u64, u64, MultiplesGeneratorHelper>\n///     for MultiplesGenerator\n/// {\n///     #[inline]\n///     fn get_ys(&self, x: &u64) -> MultiplesGeneratorHelper {\n///         MultiplesGeneratorHelper { u: *x, step: *x }\n///     }\n/// }\n///\n/// #[derive(Clone, Debug)]\n/// struct DPGeneratorFromMap<X: Clone + Eq + Hash, Y: 'static + Clone> {\n///     map: HashMap<X, &'static [Y]>,\n/// }\n///\n/// impl<X: Clone + Eq + Hash, Y: 'static + Clone>\n///     ExhaustiveDependentPairsYsGenerator<X, Y, Cloned<Iter<'static, Y>>>\n///     for DPGeneratorFromMap<X, Y>\n/// {\n///     #[inline]\n///     fn get_ys(&self, x: &X) -> Cloned<Iter<'static, Y>> {\n///         self.map[x].iter().cloned()\n///     }\n/// }\n///\n/// // All (x, y) where x is a positive natural and y is a positive multiple of x. It would be\n/// // easier to do\n/// //\n/// // exhaustive_pairs_from_single(exhaustive_positive_primitive_ints::<u64>())\n/// //      .map(|(x, y)| (x, x * y))\n/// //\n/// // in this case.\n/// let xs = exhaustive_positive_primitive_ints::<u64>();\n/// let xss = exhaustive_dependent_pairs(ruler_sequence(), xs.clone(), MultiplesGenerator {})\n///     .take(50)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.as_slice(),\n///     &[\n///         (1, 1),\n///         (2, 2),\n///         (1, 2),\n///         (3, 3),\n///         (1, 3),\n///         (2, 4),\n///         (1, 4),\n///         (4, 4),\n///         (1, 5),\n///         (2, 6),\n///         (1, 6),\n///         (3, 6),\n///         (1, 7),\n///         (2, 8),\n///         (1, 8),\n///         (5, 5),\n///         (1, 9),\n///         (2, 10),\n///         (1, 10),\n///         (3, 9),\n///         (1, 11),\n///         (2, 12),\n///         (1, 12),\n///         (4, 8),\n///         (1, 13),\n///         (2, 14),\n///         (1, 14),\n///         (3, 12),\n///         (1, 15),\n///         (2, 16),\n///         (1, 16),\n///         (6, 6),\n///         (1, 17),\n///         (2, 18),\n///         (1, 18),\n///         (3, 15),\n///         (1, 19),\n///         (2, 20),\n///         (1, 20),\n///         (4, 12),\n///         (1, 21),\n///         (2, 22),\n///         (1, 22),\n///         (3, 18),\n///         (1, 23),\n///         (2, 24),\n///         (1, 24),\n///         (5, 10),\n///         (1, 25),\n///         (2, 26)\n///     ]\n/// );\n///\n/// let xs = [1, 2, 3, 2, 3, 2, 2].iter().cloned();\n/// let xss = exhaustive_dependent_pairs(\n///     ruler_sequence(),\n///     xs,\n///     DPGeneratorFromMap {\n///         map: hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n///     },\n/// )\n/// .take(20)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.as_slice(),\n///     &[(1, 100), (3, 300), (1, 101), (3, 300), (1, 102), (3, 301), (3, 302), (3, 301), (3, 302)]\n/// );\n/// ```\n#[inline]\npub const fn exhaustive_dependent_pairs<\n    X: Clone,\n    Y,\n    G: Iterator<Item = usize>,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n>(\n    index_generator: G,\n    xs: I,\n    ys_generator: S,\n) -> ExhaustiveDependentPairs<X, Y, G, S, I, J> {\n    ExhaustiveDependentPairs {\n        done: false,\n        xs_done: false,\n        stop_after_empty_ys: false,\n        index_generator,\n        xs,\n        xs_yss: Vec::new(),\n        ys_generator,\n    }\n}\n\n/// Generates pairs $(x, y)$, where the possible values of $y$ depend on the value of $x$. $x$\n/// values with no corresponding $y$ values are treated specially.\n///\n/// See [`exhaustive_dependent_pairs`] for context.\n///\n/// If the output iterator encounters an $x$ value whose corresponding `ys` iterator is empty, the\n/// output iterator stops iterating altogether. This prevents the iterator from getting stuck if all\n/// `ys` iterators after a certain point are empty.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::iterators::ruler_sequence;\n/// use malachite_base::tuples::exhaustive::{\n///     exhaustive_dependent_pairs_stop_after_empty_ys, ExhaustiveDependentPairsYsGenerator,\n/// };\n/// use maplit::hashmap;\n/// use std::collections::HashMap;\n/// use std::hash::Hash;\n/// use std::iter::Cloned;\n/// use std::slice::Iter;\n///\n/// #[derive(Clone, Debug)]\n/// struct DPGeneratorFromMap<X: Clone + Eq + Hash, Y: 'static + Clone> {\n///     map: HashMap<X, &'static [Y]>,\n/// }\n///\n/// impl<X: Clone + Eq + Hash, Y: 'static + Clone>\n///     ExhaustiveDependentPairsYsGenerator<X, Y, Cloned<Iter<'static, Y>>>\n///     for DPGeneratorFromMap<X, Y>\n/// {\n///     #[inline]\n///     fn get_ys(&self, x: &X) -> Cloned<Iter<'static, Y>> {\n///         self.map[x].iter().cloned()\n///     }\n/// }\n///\n/// let xs = [1, 2, 3, 2, 3, 2, 2].iter().cloned();\n/// let xss = exhaustive_dependent_pairs_stop_after_empty_ys(\n///     ruler_sequence(),\n///     xs,\n///     DPGeneratorFromMap {\n///         map: hashmap! {\n///             1 => &[100, 101, 102][..],\n///             2 => &[][..],\n///             3 => &[300, 301, 302][..]\n///         },\n///     },\n/// )\n/// .take(20)\n/// .collect_vec();\n/// assert_eq!(xss.as_slice(), &[(1, 100)]);\n/// ```\n#[inline]\npub const fn exhaustive_dependent_pairs_stop_after_empty_ys<\n    X: Clone,\n    Y,\n    G: Iterator<Item = usize>,\n    S: ExhaustiveDependentPairsYsGenerator<X, Y, J>,\n    I: Iterator<Item = X>,\n    J: Iterator<Item = Y>,\n>(\n    index_generator: G,\n    xs: I,\n    ys_generator: S,\n) -> ExhaustiveDependentPairs<X, Y, G, S, I, J> {\n    ExhaustiveDependentPairs {\n        done: false,\n        xs_done: false,\n        stop_after_empty_ys: true,\n        index_generator,\n        xs,\n        xs_yss: Vec::new(),\n        ys_generator,\n    }\n}\n\n/// Defines lexicographic ordered unique tuple generators.\n///\n/// Malachite provides [`lex_ordered_unique_pairs`], but you can also define\n/// `lex_ordered_unique_triples`, `lex_ordered_unique_quadruples`, and so on, in your program using\n/// the code below. The documentation for [`lex_ordered_unique_pairs`] describes these other\n/// functions as well.\n///\n/// See usage examples [here](self#lex_ordered_unique_quadruples).\n///\n/// ```\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_ordered_unique_tuples;\n/// use malachite_base::vecs::exhaustive::fixed_length_ordered_unique_indices_helper;\n/// use std::marker::PhantomData;\n///\n/// lex_ordered_unique_tuples!(\n///     (pub(crate)),\n///     LexOrderedUniqueTriples,\n///     3,\n///     (I::Item, I::Item, I::Item),\n///     lex_ordered_unique_triples,\n///     [0, 1, 2]\n/// );\n/// lex_ordered_unique_tuples!(\n///     (pub(crate)),\n///     LexOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     lex_ordered_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n/// lex_ordered_unique_tuples!(\n///     (pub(crate)),\n///     LexOrderedUniqueQuintuples,\n///     5,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     lex_ordered_unique_quintuples,\n///     [0, 1, 2, 3, 4]\n/// );\n/// lex_ordered_unique_tuples!(\n///     (pub(crate)),\n///     LexOrderedUniqueSextuples,\n///     6,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     lex_ordered_unique_sextuples,\n///     [0, 1, 2, 3, 4, 5]\n/// );\n/// lex_ordered_unique_tuples!(\n///     (pub(crate)),\n///     LexOrderedUniqueSeptuples,\n///     7,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     lex_ordered_unique_septuples,\n///     [0, 1, 2, 3, 4, 5, 6]\n/// );\n/// lex_ordered_unique_tuples!(\n///     (pub(crate)),\n///     LexOrderedUniqueOctuples,\n///     8,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     lex_ordered_unique_octuples,\n///     [0, 1, 2, 3, 4, 5, 6, 7]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! lex_ordered_unique_tuples {\n    (\n        ($($vis:tt)*),\n        $struct: ident,\n        $k: expr,\n        $out_t: ty,\n        $fn: ident,\n        [$($i: expr),*]\n    ) => {\n        /// This documentation applies not only to `LexOrderedUniquePairs`, but also to\n        /// `LexOrderedUniqueTriples`, `LexOrderedUniqueQuadruples`, and so on. See\n        /// [`lex_ordered_unique_tuples`] for more information.\n        ///\n        /// Generates all $k$-tuples of elements from an iterator, where the tuples have no\n        /// repetitions and are ordered the same way as in the iterator.\n        ///\n        /// The tuples are generated in lexicographic order with respect to the order of the element\n        /// iterator.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $struct<I: Iterator> where I::Item: Clone {\n            first: bool,\n            done: bool,\n            xs: IteratorCache<I>,\n            indices: [usize; $k],\n            phantom: PhantomData<*const I::Item>,\n        }\n\n        impl<I: Iterator> Iterator for $struct<I> where I::Item: Clone {\n            type Item = $out_t;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if self.done {\n                    return None;\n                }\n                if self.first {\n                    self.first = false;\n                    self.xs.get($k);\n                    if let Some(n) = self.xs.known_len() {\n                        if n < $k {\n                            self.done = true;\n                            return None;\n                        }\n                    }\n                } else {\n                    if let Some(n) = self.xs.known_len() {\n                        if fixed_length_ordered_unique_indices_helper(n, $k, &mut self.indices) {\n                            self.done = true;\n                            return None;\n                        }\n                    } else {\n                        *self.indices.last_mut().unwrap() += 1;\n                    }\n                }\n                if let Some(&last_index) = self.indices.last() {\n                    // Give known len a chance to be set\n                    self.xs.get(last_index + 1);\n                }\n                Some(($(self.xs.assert_get(self.indices[$i]).clone(),)*))\n            }\n        }\n\n        /// This documentation applies not only to `lex_ordered_unique_pairs`, but also to\n        /// `lex_ordered_unique_triples`, `lex_ordered_unique_quadruples`, and so on. See\n        /// [`lex_ordered_unique_tuples`] for more information.\n        ///\n        /// Generates $k$-tuples of elements from a single iterator, such that each tuple has no\n        /// repeated elements, and the elements in each [`Vec`] are ordered the same way as they are\n        /// in the source iterator.\n        ///\n        /// The source iterator should not repeat any elements, but this is not enforced.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterator.\n        ///\n        /// If the input iterator is infinite, the output length is also infinite.\n        ///\n        /// If the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n        ///\n        /// If `xs` is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#lex_ordered_unique_quadruples).\n        $($vis)* const fn $fn<I: Iterator>(xs: I) -> $struct<I> where I::Item: Clone {\n            $struct {\n                first: true,\n                done: false,\n                xs: IteratorCache::new(xs),\n                indices: [$($i),*],\n                phantom: PhantomData,\n            }\n        }\n    }\n}\n\nlex_ordered_unique_tuples!(\n    (pub),\n    LexOrderedUniquePairs,\n    2,\n    (I::Item, I::Item),\n    lex_ordered_unique_pairs,\n    [0, 1]\n);\n\n/// Defines exhaustive ordered unique tuple generators.\n///\n/// Malachite provides [`exhaustive_ordered_unique_pairs`], but you can also define\n/// `exhaustive_ordered_unique_triples`, `exhaustive_ordered_unique_quadruples`, and so on, in your\n/// program using the code below. The documentation for [`exhaustive_ordered_unique_pairs`]\n/// describes these other functions as well.\n///\n/// See usage examples [here](self#exhaustive_ordered_unique_quadruples).\n///\n/// ```\n/// use malachite_base::exhaustive_ordered_unique_tuples;\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::vecs::exhaustive::next_bit_pattern;\n///\n/// exhaustive_ordered_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOrderedUniqueTriples,\n///     3,\n///     (I::Item, I::Item, I::Item),\n///     exhaustive_ordered_unique_triples,\n///     [0, 1, 2]\n/// );\n/// exhaustive_ordered_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_ordered_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n/// exhaustive_ordered_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOrderedUniqueQuintuples,\n///     5,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_ordered_unique_quintuples,\n///     [0, 1, 2, 3, 4]\n/// );\n/// exhaustive_ordered_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOrderedUniqueSextuples,\n///     6,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_ordered_unique_sextuples,\n///     [0, 1, 2, 3, 4, 5]\n/// );\n/// exhaustive_ordered_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOrderedUniqueSeptuples,\n///     7,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     exhaustive_ordered_unique_septuples,\n///     [0, 1, 2, 3, 4, 5, 6]\n/// );\n/// exhaustive_ordered_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOrderedUniqueOctuples,\n///     8,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     exhaustive_ordered_unique_octuples,\n///     [0, 1, 2, 3, 4, 5, 6, 7]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! exhaustive_ordered_unique_tuples {\n    (\n        ($($vis:tt)*),\n        $struct: ident,\n        $k: expr,\n        $out_t: ty,\n        $fn: ident,\n        [$($i: expr),*]\n    ) => {\n        /// This documentation applies not only to `ExhaustiveOrderedUniquePairs`, but also to\n        /// `ExhaustiveOrderedUniqueTriples`, `ExhaustiveOrderedUniqueQuadruples`, and so on. See\n        /// [`exhaustive_ordered_unique_tuples`] for more information.\n        ///\n        /// Generates all $k$-tuples of elements from an iterator, where the tuples have no\n        /// repetitions and are ordered the same way as in the iterator.\n        #[derive(Clone)]\n        pub struct $struct<I: Iterator>\n        where\n            I::Item: Clone,\n        {\n            done: bool,\n            first: bool,\n            xs: IteratorCache<I>,\n            pattern: Vec<bool>,\n        }\n\n        impl<I: Iterator> Iterator for $struct<I>\n        where\n            I::Item: Clone,\n        {\n            type Item = $out_t;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if self.done {\n                    return None;\n                } else if self.first {\n                    self.first = false;\n                } else {\n                    let mut c = $k;\n                    next_bit_pattern(&mut self.pattern, &mut c, $k, $k);\n                }\n                if !self.pattern.is_empty() && self.xs.get(self.pattern.len() - 1).is_none() {\n                    self.done = true;\n                    return None;\n                }\n                let mut results = self.pattern.iter().enumerate().filter_map(|(i, &b)| {\n                    if b {\n                        Some(self.xs.assert_get(i).clone())\n                    } else {\n                        None\n                    }\n                });\n                Some(($(((results.next().unwrap(), $i).0)),*))\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_ordered_unique_pairs`, but also to\n        /// `exhaustive_ordered_unique_triples`, `exhaustive_ordered_unique_quadruples`, and so on.\n        /// See [`exhaustive_ordered_unique_tuples`] for more information.\n        ///\n        /// Generates $k$-tuples of elements from a single iterator, such that each tuple has no\n        /// repeated elements, and the elements in each [`Vec`] are ordered the same way as they are\n        /// in the source iterator.\n        ///\n        /// The source iterator should not repeat any elements, but this is not enforced.\n        ///\n        /// If the input iterator is infinite, the output length is also infinite.\n        ///\n        /// If the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n        ///\n        /// If `xs` is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_ordered_unique_quadruples).\n        pub fn $fn<I: Iterator>(xs: I) -> $struct<I>\n        where\n            I::Item: Clone,\n        {\n            $struct {\n                done: false,\n                first: true,\n                xs: IteratorCache::new(xs),\n                pattern: vec![true; $k],\n            }\n        }\n    }\n}\nexhaustive_ordered_unique_tuples!(\n    (pub),\n    ExhaustiveOrderedUniquePairs,\n    2,\n    (I::Item, I::Item),\n    exhaustive_ordered_unique_pairs,\n    [0, 1]\n);\n\n/// Defines lexicographic unique tuple generators.\n///\n/// Malachite provides [`lex_unique_pairs`], but you can also define `lex_unique_triples`,\n/// `lex_unique_quadruples`, and so on, in your program using the code below. The documentation for\n/// [`lex_unique_pairs`] describes these other functions as well.\n///\n/// See usage examples [here](self#lex_unique_pairs).\n///\n/// ```\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_unique_tuples;\n/// use malachite_base::vecs::exhaustive::{unique_indices, UniqueIndices};\n///\n/// lex_unique_tuples!(\n///     (pub(crate)),\n///     LexUniqueTriples,\n///     3,\n///     (I::Item, I::Item, I::Item),\n///     lex_unique_triples,\n///     [0, 1, 2]\n/// );\n/// lex_unique_tuples!(\n///     (pub(crate)),\n///     LexUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     lex_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n/// lex_unique_tuples!(\n///     (pub(crate)),\n///     LexUniqueQuintuples,\n///     5,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     lex_unique_quintuples,\n///     [0, 1, 2, 3, 4]\n/// );\n/// lex_unique_tuples!(\n///     (pub(crate)),\n///     LexUniqueSextuples,\n///     6,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     lex_unique_sextuples,\n///     [0, 1, 2, 3, 4, 5]\n/// );\n/// lex_unique_tuples!(\n///     (pub(crate)),\n///     LexUniqueSeptuples,\n///     7,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     lex_unique_septuples,\n///     [0, 1, 2, 3, 4, 5, 6]\n/// );\n/// lex_unique_tuples!(\n///     (pub(crate)),\n///     LexUniqueOctuples,\n///     8,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     lex_unique_octuples,\n///     [0, 1, 2, 3, 4, 5, 6, 7]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! lex_unique_tuples {\n    (\n        ($($vis:tt)*),\n        $struct: ident,\n        $k: expr,\n        $out_t: ty,\n        $fn: ident,\n        [$($i: expr),*]\n    ) => {\n        /// This documentation applies not only to `LexUniquePairs`, but also to `LexUniqueTriples`,\n        /// `LexUniqueQuadruples`, and so on. See [`lex_unique_tuples`] for more information.\n        ///\n        /// Generates all $k$-tuples of elements from an iterator, where the tuples have no\n        /// repetitions.\n        ///\n        /// The tuples are generated in lexicographic order with respect to the order of the element\n        /// iterator.\n        #[derive(Clone)]\n        $($vis)* struct $struct<I: Iterator> where I::Item: Clone {\n            first: bool,\n            xs: IteratorCache<I>,\n            indices: UniqueIndices,\n        }\n\n        impl<I: Iterator> Iterator for $struct<I> where I::Item: Clone {\n            type Item = $out_t;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if self.first {\n                    let nonempty = !self.indices.used.is_empty();\n                    if nonempty && self.xs.get(self.indices.get_n() - 1).is_none() {\n                        self.indices.done = true;\n                    }\n                    self.first = false;\n                }\n                if self.xs.get(self.indices.get_n()).is_some() {\n                    self.indices.increment_n();\n                }\n                self.indices.next().map(|indices| {\n                    let mut results = indices.into_iter().map(|i| self.xs.assert_get(i).clone());\n                    ($(((results.next().unwrap(), $i).0)),*)\n                })\n            }\n        }\n\n        /// This documentation applies not only to `lex_unique_pairs`, but also to\n        /// `lex_unique_triples`, `lex_unique_quadruples`, and so on. See [`lex_unique_tuples`] for\n        /// more information.\n        ///\n        /// Generates $k$-tuples of elements from a single iterator, such that each tuple has no\n        /// repeated elements.\n        ///\n        /// The source iterator should not repeat any elements, but this is not enforced.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterator.\n        ///\n        /// If the input iterator is infinite, the output length is also infinite.\n        ///\n        /// If the input iterator length is $n$, the output length is $\\frac{n!}{k!}$.\n        ///\n        /// If `xs` is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#lex_unique_quadruples).\n        #[inline]\n        $($vis)* fn $fn<I: Iterator>(xs: I) -> $struct<I> where I::Item: Clone {\n            $struct {\n                first: true,\n                xs: IteratorCache::new(xs),\n                // Initial n is k, but will grow to reach actual n (or forever, if n is infinite)\n                indices: unique_indices($k, $k),\n            }\n        }\n    }\n}\n\nlex_unique_tuples!(\n    (pub),\n    LexUniquePairs,\n    2,\n    (I::Item, I::Item),\n    lex_unique_pairs,\n    [0, 1]\n);\n\n/// Generates all pairs of elements from an iterator, where the pairs have no repetitions.\n///\n/// This `struct` is created by [`exhaustive_unique_pairs`]; see its documentation for more.\n#[derive(Clone)]\npub struct ExhaustiveUniquePairs<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    next: Option<(I::Item, I::Item)>,\n    ps: ExhaustiveOrderedUniquePairs<I>,\n}\n\nimpl<I: Iterator> Iterator for ExhaustiveUniquePairs<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = (I::Item, I::Item);\n\n    fn next(&mut self) -> Option<(I::Item, I::Item)> {\n        if self.next.is_some() {\n            take(&mut self.next)\n        } else if let Some(p) = self.ps.next() {\n            self.next = Some((p.1.clone(), p.0.clone()));\n            Some(p)\n        } else {\n            None\n        }\n    }\n}\n\n/// Generates pairs of elements from a single iterator, such that each pair has no repeated\n/// elements.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $\\tfrac{1}{2}{n!}$.\n///\n/// If `xs` is empty, the output is also empty.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::exhaustive_unique_pairs;\n///\n/// let xss = exhaustive_unique_pairs(1..=6).take(20).collect_vec();\n/// assert_eq!(\n///     xss.into_iter().collect_vec().as_slice(),\n///     &[\n///         (1, 2),\n///         (2, 1),\n///         (1, 3),\n///         (3, 1),\n///         (2, 3),\n///         (3, 2),\n///         (1, 4),\n///         (4, 1),\n///         (2, 4),\n///         (4, 2),\n///         (3, 4),\n///         (4, 3),\n///         (1, 5),\n///         (5, 1),\n///         (2, 5),\n///         (5, 2),\n///         (3, 5),\n///         (5, 3),\n///         (4, 5),\n///         (5, 4)\n///     ]\n/// );\n/// ```\npub fn exhaustive_unique_pairs<I: Iterator>(xs: I) -> ExhaustiveUniquePairs<I>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveUniquePairs {\n        next: None,\n        ps: exhaustive_ordered_unique_pairs(xs),\n    }\n}\n\n/// Defines lexicographic unique tuple generators.\n///\n/// Malachite provides [`exhaustive_unique_pairs`], but you can also define\n/// `exhaustive_unique_triples`, `lex_unique_quadruples`, and so on, in your program using the code\n/// below.\n///\n/// See usage examples [here](self#lex_unique_quadruples).\n///\n/// ```\n/// use malachite_base::exhaustive_unique_tuples;\n/// use malachite_base::num::iterators::{ruler_sequence, RulerSequence};\n/// use malachite_base::tuples::exhaustive::{\n///     exhaustive_dependent_pairs, ExhaustiveDependentPairs,\n/// };\n/// use malachite_base::vecs::exhaustive::{\n///     exhaustive_ordered_unique_vecs_fixed_length, ExhaustiveOrderedUniqueCollections,\n///     ExhaustiveUniqueVecsGenerator,\n/// };\n/// use malachite_base::vecs::ExhaustiveVecPermutations;\n///\n/// exhaustive_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveUniqueTriples,\n///     3,\n///     (I::Item, I::Item, I::Item),\n///     exhaustive_unique_triples,\n///     [0, 1, 2]\n/// );\n/// exhaustive_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n/// exhaustive_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveUniqueQuintuples,\n///     5,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_unique_quintuples,\n///     [0, 1, 2, 3, 4]\n/// );\n/// exhaustive_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveUniqueSextuples,\n///     6,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_unique_sextuples,\n///     [0, 1, 2, 3, 4, 5]\n/// );\n/// exhaustive_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveUniqueSeptuples,\n///     7,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     exhaustive_unique_septuples,\n///     [0, 1, 2, 3, 4, 5, 6]\n/// );\n/// exhaustive_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveUniqueOctuples,\n///     8,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     exhaustive_unique_octuples,\n///     [0, 1, 2, 3, 4, 5, 6, 7]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! exhaustive_unique_tuples {\n    (\n        ($($vis:tt)*),\n        $struct: ident,\n        $k: expr,\n        $out_t: ty,\n        $fn: ident,\n        [$($i: expr),*]\n    ) => {\n        // Generates all $k$-tuples of elements from an iterator, where the tuples have no\n        // repetitions.\n        #[derive(Clone)]\n        $($vis)* struct $struct<I: Iterator> where I::Item: Clone {\n            xss: ExhaustiveDependentPairs<\n                Vec<I::Item>,\n                Vec<I::Item>,\n                RulerSequence<usize>,\n                ExhaustiveUniqueVecsGenerator<I::Item, I>,\n                ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>,\n                ExhaustiveVecPermutations<I::Item>,\n            >\n        }\n\n        impl<I: Iterator> Iterator for $struct<I> where I::Item: Clone {\n            type Item = $out_t;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                self.xss.next().map(|mut p| {\n                    let mut drain = p.1.drain(..);\n                    ($(((drain.next().unwrap(), $i).0)),*)\n                })\n            }\n        }\n\n        // Generates $k$-tuples of elements from a single iterator, such that each tuple has no\n        // repeated elements.\n        //\n        // The source iterator should not repeat any elements, but this is not enforced.\n        //\n        // If the input iterator is infinite, the output length is also infinite.\n        //\n        // If the input iterator length is $n$, the output length is $\\frac{n!}{k!}$.\n        //\n        // If `xs` is empty, the output is also empty.\n        //\n        // # Examples\n        // See [here](self#exhaustive_unique_quadruples).\n        $($vis)* fn $fn<I: Iterator>(xs: I) -> $struct<I> where I::Item: Clone {\n            $struct {\n                xss: exhaustive_dependent_pairs(\n                    ruler_sequence(),\n                    exhaustive_ordered_unique_vecs_fixed_length($k, xs),\n                    ExhaustiveUniqueVecsGenerator::new(),\n                )\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/tuples/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Generates all singletons (1-element tuples) with values from a given iterator.\n///\n/// This `struct` is created by [`singletons`]; see its documentation for more.\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct Singletons<I: Iterator> {\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for Singletons<I> {\n    type Item = (I::Item,);\n\n    #[inline]\n    fn next(&mut self) -> Option<(I::Item,)> {\n        self.xs.next().map(|x| (x,))\n    }\n}\n\n/// Generates all singletons (1-element tuples) with values from a given iterator.\n///\n/// The elements appear in the same order as they do in the given iterator, but wrapped in `(_,)`.\n///\n/// The output length is `xs.count()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::singletons;\n///\n/// assert_eq!(\n///     singletons([1, 2, 3].iter().cloned()).collect_vec(),\n///     &[(1,), (2,), (3,)]\n/// );\n/// ```\n#[inline]\npub const fn singletons<I: Iterator>(xs: I) -> Singletons<I> {\n    Singletons { xs }\n}\n\n/// Iterators that generate tuples without repetition.\n///\n/// To reduce binary size and lower compilation time, many of the functions described here are not\n/// actually defined in Malachite, but may be created in your program using macros exported from\n/// Malachite. To do this, see the documentation for `lex_tuples` and `lex_custom_tuples`.\n///\n/// # lex_pairs\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::lex_pairs;\n///\n/// assert_eq!(\n///     lex_pairs('a'..'f', 0..3).collect_vec(),\n///     &[\n///         ('a', 0),\n///         ('a', 1),\n///         ('a', 2),\n///         ('b', 0),\n///         ('b', 1),\n///         ('b', 2),\n///         ('c', 0),\n///         ('c', 1),\n///         ('c', 2),\n///         ('d', 0),\n///         ('d', 1),\n///         ('d', 2),\n///         ('e', 0),\n///         ('e', 1),\n///         ('e', 2)\n///     ]\n/// );\n/// ```\n///\n/// # lex_pairs_from_single\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::lex_pairs_from_single;\n///\n/// assert_eq!(\n///     lex_pairs_from_single(0..3).collect_vec(),\n///     &[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]\n/// );\n/// ```\n///\n/// # lex_triples_xyx\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_custom_tuples;\n///\n/// fn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n///     (a.unwrap(), b.unwrap(), c.unwrap())\n/// }\n///\n/// lex_custom_tuples!(\n///     (pub(crate)),\n///     LexTriplesXYX,\n///     (X, Y, X),\n///     (None, None, None),\n///     unwrap_triple,\n///     lex_triples_xyx,\n///     [X, I, xs, [0, x_0], [2, x_2]],\n///     [Y, J, ys, [1, y_1]]\n/// );\n///\n/// // We are generating triples of `char`, `i8`, and `char` using two input iterators. The first\n/// // iterator, `xs`, the chars 'a' through 'c', and the second, `ys`, produces the three numbers\n/// // 0, 1, and 2. The function we're using is `lex_triples_xyx`, meaning that the first element of\n/// // the output triples will be taken from `xs`, the second element from `ys`, and the third also\n/// // from `xs`.\n/// let ts = lex_triples_xyx('a'..='c', 0..3);\n/// assert_eq!(\n///     ts.collect_vec(),\n///     &[\n///         ('a', 0, 'a'),\n///         ('a', 0, 'b'),\n///         ('a', 0, 'c'),\n///         ('a', 1, 'a'),\n///         ('a', 1, 'b'),\n///         ('a', 1, 'c'),\n///         ('a', 2, 'a'),\n///         ('a', 2, 'b'),\n///         ('a', 2, 'c'),\n///         ('b', 0, 'a'),\n///         ('b', 0, 'b'),\n///         ('b', 0, 'c'),\n///         ('b', 1, 'a'),\n///         ('b', 1, 'b'),\n///         ('b', 1, 'c'),\n///         ('b', 2, 'a'),\n///         ('b', 2, 'b'),\n///         ('b', 2, 'c'),\n///         ('c', 0, 'a'),\n///         ('c', 0, 'b'),\n///         ('c', 0, 'c'),\n///         ('c', 1, 'a'),\n///         ('c', 1, 'b'),\n///         ('c', 1, 'c'),\n///         ('c', 2, 'a'),\n///         ('c', 2, 'b'),\n///         ('c', 2, 'c')\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_pairs_from_single\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::exhaustive_pairs_from_single;\n///\n/// assert_eq!(\n///     exhaustive_pairs_from_single(0..4).collect_vec(),\n///     &[\n///         (0, 0),\n///         (0, 1),\n///         (1, 0),\n///         (1, 1),\n///         (0, 2),\n///         (0, 3),\n///         (1, 2),\n///         (1, 3),\n///         (2, 0),\n///         (2, 1),\n///         (3, 0),\n///         (3, 1),\n///         (2, 2),\n///         (2, 3),\n///         (3, 2),\n///         (3, 3)\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_pairs_1_input\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n/// use malachite_base::exhaustive_tuples_1_input;\n/// use malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::num::arithmetic::traits::CheckedPow;\n/// use malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n/// use malachite_base::num::logic::traits::SignificantBits;\n/// use std::cmp::max;\n/// use std::marker::PhantomData;\n///\n/// exhaustive_tuples_1_input!(\n///     (pub(crate)),\n///     ExhaustiveTriples1Input,\n///     exhaustive_triples_1_input,\n///     exhaustive_triples_from_single,\n///     (I::Item, I::Item, I::Item),\n///     [0, output_type_x],\n///     [1, output_type_y],\n///     [2, output_type_z]\n/// );\n///\n/// // We are generating triples of `char`s using one input iterator, which produces all ASCII\n/// // `char`s. The third element has a tiny output type, so it will grow more slowly than the other\n/// // two elements (though it doesn't look that way from the first few tuples).\n/// let ts = exhaustive_triples_1_input(\n///     exhaustive_ascii_chars(),\n///     BitDistributorOutputType::normal(1),\n///     BitDistributorOutputType::normal(1),\n///     BitDistributorOutputType::tiny(),\n/// );\n/// assert_eq!(\n///     ts.take(20).collect_vec(),\n///     &[\n///         ('a', 'a', 'a'),\n///         ('a', 'a', 'b'),\n///         ('a', 'a', 'c'),\n///         ('a', 'a', 'd'),\n///         ('a', 'b', 'a'),\n///         ('a', 'b', 'b'),\n///         ('a', 'b', 'c'),\n///         ('a', 'b', 'd'),\n///         ('a', 'a', 'e'),\n///         ('a', 'a', 'f'),\n///         ('a', 'a', 'g'),\n///         ('a', 'a', 'h'),\n///         ('a', 'b', 'e'),\n///         ('a', 'b', 'f'),\n///         ('a', 'b', 'g'),\n///         ('a', 'b', 'h'),\n///         ('b', 'a', 'a'),\n///         ('b', 'a', 'b'),\n///         ('b', 'a', 'c'),\n///         ('b', 'a', 'd')\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_pairs\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::exhaustive::exhaustive_pairs;\n///\n/// let xss = exhaustive_pairs(['a', 'b', 'c'].iter().cloned(), 0..3).collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[('a', 0), ('a', 1), ('b', 0), ('b', 1), ('a', 2), ('b', 2), ('c', 0), ('c', 1), ('c', 2)]\n/// );\n/// ```\n///\n/// # exhaustive_pairs_custom_output\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::bit_distributor::BitDistributorOutputType;\n/// use malachite_base::tuples::exhaustive::exhaustive_pairs_custom_output;\n///\n/// let xss = exhaustive_pairs_custom_output(\n///     ['a', 'b', 'c'].iter().cloned(),\n///     0..3,\n///     BitDistributorOutputType::normal(1),\n///     BitDistributorOutputType::tiny(),\n/// )\n/// .collect_vec();\n/// assert_eq!(\n///     xss,\n///     &[('a', 0), ('a', 1), ('a', 2), ('b', 0), ('b', 1), ('b', 2), ('c', 0), ('c', 1), ('c', 2)]\n/// );\n/// ```\n///\n/// # exhaustive_triples_xyx\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n/// use malachite_base::custom_tuples;\n/// use malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n/// use malachite_base::num::logic::traits::SignificantBits;\n/// use std::cmp::max;\n///\n/// #[allow(clippy::missing_const_for_fn)]\n/// fn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n///     (a.unwrap(), b.unwrap(), c.unwrap())\n/// }\n///\n/// custom_tuples!(\n///     (pub(crate)),\n///     ExhaustiveTriplesXYX,\n///     (X, Y, X),\n///     (None, None, None),\n///     unwrap_triple,\n///     exhaustive_triples_xyx,\n///     exhaustive_triples_xyx_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_ys_1]],\n///     [Y, J, ys, ys_done, [1, output_type_xs_2]]\n/// );\n///\n/// // We are generating triples of `char`, `i8`, and `char` using two input iterators. The first\n/// // iterator, `xs`, produces all ASCII `char`s, and the second, `ys`, produces the three numbers\n/// // 0, 1, and 2. The function we're using is `exhaustive_triples_xyx`, meaning that the first\n/// // element of the output triples will be taken from `xs`, the second element from `ys`, and the\n/// // third also from `xs`.\n/// let ts = exhaustive_triples_xyx(exhaustive_ascii_chars(), 0..3);\n/// assert_eq!(\n///     ts.take(20).collect_vec(),\n///     &[\n///         ('a', 0, 'a'),\n///         ('a', 0, 'b'),\n///         ('a', 1, 'a'),\n///         ('a', 1, 'b'),\n///         ('b', 0, 'a'),\n///         ('b', 0, 'b'),\n///         ('b', 1, 'a'),\n///         ('b', 1, 'b'),\n///         ('a', 0, 'c'),\n///         ('a', 0, 'd'),\n///         ('a', 1, 'c'),\n///         ('a', 1, 'd'),\n///         ('b', 0, 'c'),\n///         ('b', 0, 'd'),\n///         ('b', 1, 'c'),\n///         ('b', 1, 'd'),\n///         ('a', 2, 'a'),\n///         ('a', 2, 'b'),\n///         ('b', 2, 'a'),\n///         ('b', 2, 'b')\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_triples_xyx_custom_output\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n/// use malachite_base::custom_tuples;\n/// use malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n/// use malachite_base::num::logic::traits::SignificantBits;\n/// use std::cmp::max;\n///\n/// #[allow(clippy::missing_const_for_fn)]\n/// fn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n///     (a.unwrap(), b.unwrap(), c.unwrap())\n/// }\n///\n/// custom_tuples!(\n///     (pub(crate)),\n///     ExhaustiveTriplesXYX,\n///     (X, Y, X),\n///     (None, None, None),\n///     unwrap_triple,\n///     exhaustive_triples_xyx,\n///     exhaustive_triples_xyx_custom_output,\n///     [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_ys_1]],\n///     [Y, J, ys, ys_done, [1, output_type_xs_2]]\n/// );\n///\n/// // We are generating triples of `char`, `i8`, and `char` using two input iterators. The first\n/// // iterator, `xs`, produces all ASCII `char`s, and the second, `ys`, produces the three numbers\n/// // 0, 1, and 2. The function we're using is `exhaustive_triples_xyx_custom_output`, meaning that\n/// // the first element of the output triples will be taken from `xs`, the second element from\n/// // `ys`, and the third also from `xs`.\n/// //\n/// // The third element has a tiny output type, so it will grow more slowly than the other two\n/// // elements (though it doesn't look that way from the first few tuples).\n/// let ts = exhaustive_triples_xyx_custom_output(\n///     exhaustive_ascii_chars(),\n///     0..3,\n///     BitDistributorOutputType::normal(1),\n///     BitDistributorOutputType::normal(1),\n///     BitDistributorOutputType::tiny(),\n/// );\n/// assert_eq!(\n///     ts.take(20).collect_vec(),\n///     &[\n///         ('a', 0, 'a'),\n///         ('a', 0, 'b'),\n///         ('a', 0, 'c'),\n///         ('a', 0, 'd'),\n///         ('a', 1, 'a'),\n///         ('a', 1, 'b'),\n///         ('a', 1, 'c'),\n///         ('a', 1, 'd'),\n///         ('a', 0, 'e'),\n///         ('a', 0, 'f'),\n///         ('a', 0, 'g'),\n///         ('a', 0, 'h'),\n///         ('a', 1, 'e'),\n///         ('a', 1, 'f'),\n///         ('a', 1, 'g'),\n///         ('a', 1, 'h'),\n///         ('b', 0, 'a'),\n///         ('b', 0, 'b'),\n///         ('b', 0, 'c'),\n///         ('b', 0, 'd')\n///     ]\n/// );\n/// ```\n///\n/// # lex_ordered_unique_quadruples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_ordered_unique_tuples;\n/// use malachite_base::vecs::exhaustive::fixed_length_ordered_unique_indices_helper;\n/// use std::marker::PhantomData;\n///\n/// lex_ordered_unique_tuples!(\n///     (pub(crate)),\n///     LexOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     lex_ordered_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n///\n/// let xss = lex_ordered_unique_quadruples(1..=6).collect_vec();\n/// assert_eq!(\n///     xss.into_iter().collect_vec().as_slice(),\n///     &[\n///         (1, 2, 3, 4),\n///         (1, 2, 3, 5),\n///         (1, 2, 3, 6),\n///         (1, 2, 4, 5),\n///         (1, 2, 4, 6),\n///         (1, 2, 5, 6),\n///         (1, 3, 4, 5),\n///         (1, 3, 4, 6),\n///         (1, 3, 5, 6),\n///         (1, 4, 5, 6),\n///         (2, 3, 4, 5),\n///         (2, 3, 4, 6),\n///         (2, 3, 5, 6),\n///         (2, 4, 5, 6),\n///         (3, 4, 5, 6)\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_ordered_unique_quadruples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::exhaustive_ordered_unique_tuples;\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::vecs::exhaustive::next_bit_pattern;\n///\n/// exhaustive_ordered_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_ordered_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n///\n/// let xss = exhaustive_ordered_unique_quadruples(1..=6).collect_vec();\n/// assert_eq!(\n///     xss.into_iter().collect_vec().as_slice(),\n///     &[\n///         (1, 2, 3, 4),\n///         (1, 2, 3, 5),\n///         (1, 2, 4, 5),\n///         (1, 3, 4, 5),\n///         (2, 3, 4, 5),\n///         (1, 2, 3, 6),\n///         (1, 2, 4, 6),\n///         (1, 3, 4, 6),\n///         (2, 3, 4, 6),\n///         (1, 2, 5, 6),\n///         (1, 3, 5, 6),\n///         (2, 3, 5, 6),\n///         (1, 4, 5, 6),\n///         (2, 4, 5, 6),\n///         (3, 4, 5, 6)\n///     ]\n/// );\n/// ```\n///\n/// # lex_unique_quadruples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_unique_tuples;\n/// use malachite_base::vecs::exhaustive::{unique_indices, UniqueIndices};\n///\n/// lex_unique_tuples!(\n///     (pub(crate)),\n///     LexUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     lex_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n///\n/// let xss = lex_unique_quadruples(1..=6).take(20).collect_vec();\n/// assert_eq!(\n///     xss.into_iter().collect_vec().as_slice(),\n///     &[\n///         (1, 2, 3, 4),\n///         (1, 2, 3, 5),\n///         (1, 2, 3, 6),\n///         (1, 2, 4, 3),\n///         (1, 2, 4, 5),\n///         (1, 2, 4, 6),\n///         (1, 2, 5, 3),\n///         (1, 2, 5, 4),\n///         (1, 2, 5, 6),\n///         (1, 2, 6, 3),\n///         (1, 2, 6, 4),\n///         (1, 2, 6, 5),\n///         (1, 3, 2, 4),\n///         (1, 3, 2, 5),\n///         (1, 3, 2, 6),\n///         (1, 3, 4, 2),\n///         (1, 3, 4, 5),\n///         (1, 3, 4, 6),\n///         (1, 3, 5, 2),\n///         (1, 3, 5, 4)\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_unique_quadruples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::exhaustive_unique_tuples;\n/// use malachite_base::num::iterators::{ruler_sequence, RulerSequence};\n/// use malachite_base::tuples::exhaustive::{\n///     exhaustive_dependent_pairs, ExhaustiveDependentPairs,\n/// };\n/// use malachite_base::vecs::exhaustive::{\n///     exhaustive_ordered_unique_vecs_fixed_length, ExhaustiveOrderedUniqueCollections,\n///     ExhaustiveUniqueVecsGenerator,\n/// };\n/// use malachite_base::vecs::ExhaustiveVecPermutations;\n///\n/// exhaustive_unique_tuples!(\n///     (pub(crate)),\n///     ExhaustiveUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     exhaustive_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n///\n/// let xss = exhaustive_unique_quadruples(1..=6).take(20).collect_vec();\n/// assert_eq!(\n///     xss.into_iter().collect_vec().as_slice(),\n///     &[\n///         (1, 2, 3, 4),\n///         (1, 2, 3, 5),\n///         (1, 2, 4, 3),\n///         (1, 2, 4, 5),\n///         (1, 3, 2, 4),\n///         (1, 2, 5, 3),\n///         (1, 3, 4, 2),\n///         (1, 3, 4, 5),\n///         (1, 4, 2, 3),\n///         (1, 3, 2, 5),\n///         (1, 4, 3, 2),\n///         (1, 2, 5, 4),\n///         (2, 1, 3, 4),\n///         (1, 3, 5, 2),\n///         (2, 1, 4, 3),\n///         (2, 3, 4, 5),\n///         (2, 3, 1, 4),\n///         (1, 5, 2, 3),\n///         (2, 3, 4, 1),\n///         (1, 4, 2, 5)\n///     ]\n/// );\n/// ```\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate tuples randomly.\n///\n/// # random_pairs\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::random::random_char_inclusive_range;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::tuples::random::random_pairs;\n///\n/// let ps = random_pairs(\n///     EXAMPLE_SEED,\n///     &|seed| random_unsigned_inclusive_range::<u8>(seed, 0, 2),\n///     &|seed| random_char_inclusive_range(seed, 'x', 'z'),\n/// );\n/// assert_eq!(\n///     ps.take(20).collect_vec().as_slice(),\n///     &[\n///         (1, 'z'),\n///         (1, 'x'),\n///         (1, 'z'),\n///         (1, 'y'),\n///         (2, 'x'),\n///         (0, 'z'),\n///         (0, 'z'),\n///         (0, 'z'),\n///         (2, 'z'),\n///         (0, 'y'),\n///         (2, 'x'),\n///         (0, 'x'),\n///         (2, 'z'),\n///         (0, 'z'),\n///         (2, 'x'),\n///         (2, 'x'),\n///         (2, 'y'),\n///         (1, 'y'),\n///         (0, 'x'),\n///         (2, 'x')\n///     ]\n/// );\n/// ```\n///\n/// # random_pairs_from_single\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::tuples::random::random_pairs_from_single;\n///\n/// let ps = random_pairs_from_single(random_unsigned_inclusive_range::<u8>(EXAMPLE_SEED, 0, 2));\n/// assert_eq!(\n///     ps.take(20).collect_vec().as_slice(),\n///     &[\n///         (1, 0),\n///         (1, 2),\n///         (1, 1),\n///         (0, 1),\n///         (0, 2),\n///         (1, 0),\n///         (1, 2),\n///         (2, 0),\n///         (1, 0),\n///         (2, 2),\n///         (2, 1),\n///         (0, 2),\n///         (2, 1),\n///         (1, 1),\n///         (0, 0),\n///         (2, 0),\n///         (2, 2),\n///         (1, 0),\n///         (1, 1),\n///         (0, 2)\n///     ]\n/// );\n/// ```\n///\n/// # random_triples_xyx\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::random::random_char_inclusive_range;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::{Seed, EXAMPLE_SEED};\n/// use malachite_base::random_custom_tuples;\n///\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomTriplesXYX,\n///     (X, Y, X),\n///     random_triples_xyx,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n///     [Y, J, ys, ys_gen, [y_1, x_2]]\n/// );\n///\n/// // We are generating triples of `char`s using two input iterators. The first iterator, `xs`,\n/// // produces all ASCII `char`s, and the second, `ys`, produces the three numbers 0, 1, and 2. The\n/// // function we're using is `random_triples_xyx`, meaning that the first element of the\n/// // output triples will be taken from `xs`, the second element from `ys`, and the third also from\n/// // `xs`.\n/// let ts = random_triples_xyx(\n///     EXAMPLE_SEED,\n///     &|seed| random_char_inclusive_range(seed, 'x', 'z'),\n///     &|seed| random_unsigned_inclusive_range::<u8>(seed, 0, 2),\n/// );\n/// assert_eq!(\n///     ts.take(20).collect_vec().as_slice(),\n///     &[\n///         ('y', 2, 'y'),\n///         ('y', 0, 'y'),\n///         ('z', 2, 'x'),\n///         ('x', 1, 'x'),\n///         ('z', 0, 'x'),\n///         ('z', 2, 'x'),\n///         ('z', 2, 'x'),\n///         ('z', 2, 'z'),\n///         ('z', 2, 'y'),\n///         ('x', 1, 'z'),\n///         ('z', 0, 'x'),\n///         ('y', 0, 'z'),\n///         ('y', 2, 'z'),\n///         ('x', 2, 'z'),\n///         ('z', 0, 'y'),\n///         ('z', 0, 'y'),\n///         ('y', 1, 'x'),\n///         ('z', 1, 'z'),\n///         ('x', 0, 'z'),\n///         ('z', 0, 'x')\n///     ]\n/// );\n/// ```\n///\n/// # random_ordered_unique_quadruples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::random_ordered_unique_tuples;\n/// use malachite_base::sets::random::{\n///     random_b_tree_sets_fixed_length, RandomBTreeSetsFixedLength,\n/// };\n///\n/// random_ordered_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     random_ordered_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n///\n/// let qs = random_ordered_unique_quadruples(random_unsigned_inclusive_range::<u8>(\n///     EXAMPLE_SEED,\n///     1,\n///     10,\n/// ));\n/// assert_eq!(\n///     qs.take(20).collect_vec().as_slice(),\n///     &[\n///         (2, 5, 6, 8),\n///         (3, 5, 7, 9),\n///         (1, 2, 6, 8),\n///         (3, 4, 6, 7),\n///         (3, 6, 9, 10),\n///         (4, 6, 8, 10),\n///         (3, 6, 8, 10),\n///         (2, 5, 9, 10),\n///         (2, 3, 8, 10),\n///         (1, 3, 7, 8),\n///         (1, 2, 6, 10),\n///         (2, 5, 8, 9),\n///         (1, 8, 9, 10),\n///         (1, 3, 7, 8),\n///         (2, 3, 4, 5),\n///         (1, 3, 4, 8),\n///         (3, 6, 7, 9),\n///         (5, 6, 7, 8),\n///         (3, 4, 5, 9),\n///         (4, 6, 9, 10)\n///     ]\n/// );\n/// ```\n///\n/// # random_unique_quadruples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::random_unique_tuples;\n/// use std::collections::HashMap;\n/// use std::hash::Hash;\n///\n/// random_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     random_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n///\n/// let qs = random_unique_quadruples(random_unsigned_inclusive_range::<u8>(EXAMPLE_SEED, 1, 10));\n/// assert_eq!(\n///     qs.take(20).collect_vec().as_slice(),\n///     &[\n///         (2, 8, 6, 5),\n///         (7, 5, 3, 9),\n///         (2, 8, 6, 1),\n///         (3, 7, 4, 6),\n///         (3, 10, 6, 9),\n///         (6, 10, 4, 8),\n///         (6, 10, 8, 3),\n///         (10, 2, 9, 5),\n///         (8, 10, 2, 3),\n///         (8, 1, 7, 3),\n///         (2, 6, 1, 10),\n///         (9, 5, 8, 2),\n///         (8, 1, 9, 10),\n///         (7, 3, 8, 1),\n///         (3, 2, 5, 4),\n///         (3, 8, 4, 1),\n///         (9, 7, 6, 3),\n///         (5, 7, 8, 6),\n///         (5, 3, 9, 4),\n///         (9, 10, 4, 6)\n///     ]\n/// );\n/// ```\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/tuples/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::random::Seed;\nuse std::cmp::Ordering::*;\nuse std::iter::{Repeat, repeat};\n\n/// Generates random units; repeats `()`.\n///\n/// $P(()) = 1$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::tuples::random::random_units;\n///\n/// assert_eq!(random_units().take(10).collect_vec(), &[(); 10]);\n/// ```\npub fn random_units() -> Repeat<()> {\n    repeat(())\n}\n\n// hack for macro\n#[doc(hidden)]\n#[inline]\npub fn next_helper<I: Iterator>(x: &mut I, _i: usize) -> Option<I::Item> {\n    x.next()\n}\n\n/// Defines random tuple generators.\n///\n/// Malachite provides [`random_pairs`] and [`random_pairs_from_single`], but you can also define\n/// `random_triples`, `random_quadruples`, and so on, and `random_triples_from_single`,\n/// `random_quadruples_from_single`, and so on, in your program using the code below. The\n/// documentation for [`random_pairs`] and [`random_pairs_from_single`] describes these other\n/// functions as well.\n///\n/// See usage examples [here](self#random_pairs) and [here](self#random_pairs_from_single).\n///\n/// ```\n/// use malachite_base::random::Seed;\n/// use malachite_base::random_tuples;\n/// use malachite_base::tuples::random::next_helper;\n///\n/// random_tuples!(\n///     (pub(crate)),\n///     RandomTriples,\n///     RandomTriplesFromSingle,\n///     random_triples,\n///     random_triples_from_single,\n///     (I::Item, I::Item, I::Item),\n///     [0, X, I, xs, xs_gen],\n///     [1, Y, J, ys, ys_gen],\n///     [2, Z, K, zs, zs_gen]\n/// );\n/// random_tuples!(\n///     (pub(crate)),\n///     RandomQuadruples,\n///     RandomQuadruplesFromSingle,\n///     random_quadruples,\n///     random_quadruples_from_single,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     [0, X, I, xs, xs_gen],\n///     [1, Y, J, ys, ys_gen],\n///     [2, Z, K, zs, zs_gen],\n///     [3, W, L, ws, ws_gen]\n/// );\n/// random_tuples!(\n///     (pub(crate)),\n///     RandomQuintuples,\n///     RandomQuintuplesFromSingle,\n///     random_quintuples,\n///     random_quintuples_from_single,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     [0, X, I, xs, xs_gen],\n///     [1, Y, J, ys, ys_gen],\n///     [2, Z, K, zs, zs_gen],\n///     [3, W, L, ws, ws_gen],\n///     [4, V, M, vs, vs_gen]\n/// );\n/// random_tuples!(\n///     (pub(crate)),\n///     RandomSextuples,\n///     RandomSextuplesFromSingle,\n///     random_sextuples,\n///     random_sextuples_from_single,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     [0, X, I, xs, xs_gen],\n///     [1, Y, J, ys, ys_gen],\n///     [2, Z, K, zs, zs_gen],\n///     [3, W, L, ws, ws_gen],\n///     [4, V, M, vs, vs_gen],\n///     [5, U, N, us, us_gen]\n/// );\n/// random_tuples!(\n///     (pub(crate)),\n///     RandomSeptuples,\n///     RandomSeptuplesFromSingle,\n///     random_septuples,\n///     random_septuples_from_single,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     [0, X, I, xs, xs_gen],\n///     [1, Y, J, ys, ys_gen],\n///     [2, Z, K, zs, zs_gen],\n///     [3, W, L, ws, ws_gen],\n///     [4, V, M, vs, vs_gen],\n///     [5, U, N, us, us_gen],\n///     [6, T, O, ts, ts_gen]\n/// );\n/// random_tuples!(\n///     (pub(crate)),\n///     RandomOctuples,\n///     RandomOctuplesFromSingle,\n///     random_octuples,\n///     random_octuples_from_single,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     [0, X, I, xs, xs_gen],\n///     [1, Y, J, ys, ys_gen],\n///     [2, Z, K, zs, zs_gen],\n///     [3, W, L, ws, ws_gen],\n///     [4, V, M, vs, vs_gen],\n///     [5, U, N, us, us_gen],\n///     [6, T, O, ts, ts_gen],\n///     [7, S, P, ss, ss_gen]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! random_tuples {\n    (\n        ($($vis:tt)*),\n        $random_struct: ident,\n        $random_struct_from_single: ident,\n        $random_fn: ident,\n        $random_fn_from_single: ident,\n        $single_out: tt,\n        $([$i: expr, $t: ident, $it: ident, $xs: ident, $xs_gen:ident]),*\n    ) => {\n        /// This documentation applies not only to `RandomPairs`, but also to `RandomTriples`,\n        /// `RandomQuadruples`, and so on. See [`random_tuples`] for more information.\n        ///\n        /// Generates random $n$-tuples using elements from $n$ iterators.\n        #[derive(Clone, Debug)]\n        #[allow(dead_code)]\n        $($vis)* struct $random_struct<$($t: Clone, $it: Iterator<Item = $t>,)*> {\n            $($xs: $it,)*\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> Iterator for $random_struct<$($t, $it,)*>\n        {\n            type Item = ($($t,)*);\n\n            #[inline]\n            fn next(&mut self) -> Option<Self::Item> {\n                Some(($(self.$xs.next().unwrap()),*))\n            }\n        }\n\n        /// This documentation applies not only to `random_pairs`, but also to `random_triples`,\n        /// `random_quadruples`, and so on. See [`random_tuples`] for more information.\n        ///\n        /// Generates random $n$-tuples with elements from $n$ iterators.\n        ///\n        /// The probability of a particular $n$-tuple being generated is the product of the\n        /// probabilities of each of its elements.\n        ///\n        /// `xs`, `ys`, `zs`, ... must be infinite.\n        ///\n        /// # Examples\n        /// See [here](self#random_pairs).\n        #[allow(dead_code)]\n        $($vis)* fn $random_fn<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            seed: Seed,\n            $($xs_gen: &dyn Fn(Seed) -> $it,)*\n        ) -> $random_struct<$($t, $it,)*> {\n            $random_struct {\n                $($xs: $xs_gen(seed.fork(stringify!($xs))),)*\n            }\n        }\n\n        /// This documentation applies not only to `RandomPairsFromSingle`, but also to\n        /// `RandomTriplesFromSingle`, `RandomQuadruplesFromSingle`, and so on. See\n        /// [`random_tuples`] for more information.\n        ///\n        /// Generates random $n$-tuples using elements from a single iterator.\n        #[derive(Clone, Debug)]\n        #[allow(dead_code)]\n        $($vis)* struct $random_struct_from_single<I: Iterator> {\n            xs: I\n        }\n\n        impl<I: Iterator> Iterator for $random_struct_from_single<I> {\n            type Item = $single_out;\n\n            #[inline]\n            fn next(&mut self) -> Option<$single_out> {\n                Some(($(next_helper(&mut self.xs, $i).unwrap(),)*))\n            }\n        }\n\n        /// This documentation applies not only to `random_pairs_from_single`, but also to\n        /// `random_triples_from_single`, `random_quadruples_from_single`, and so on. See\n        /// [`random_tuples`] for more information.\n        ///\n        /// Generates random $n$-tuples using elements from a single iterator.\n        ///\n        /// The probability of a particular $n$-tuple being generated is the product of the\n        /// probabilities of each of its elements.\n        ///\n        /// `xs` must be infinite.\n        ///\n        /// # Examples\n        /// See [here](self#random_pairs_from_single).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* const fn $random_fn_from_single<I: Iterator>(xs: I)\n                -> $random_struct_from_single<I> {\n            $random_struct_from_single { xs }\n        }\n    }\n}\n\nrandom_tuples!(\n    (pub),\n    RandomPairs,\n    RandomPairsFromSingle,\n    random_pairs,\n    random_pairs_from_single,\n    (I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen]\n);\n\n/// Defines custom random tuple generators.\n///\n/// You can define custom tuple generators like `random_triples_xyx` in your program using the code\n/// below.\n///\n/// See usage examples [here](self#random_triples_xyx).\n///\n/// ```\n/// use malachite_base::random::Seed;\n/// use malachite_base::random_custom_tuples;\n///\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomTriplesXXY,\n///     (X, X, Y),\n///     random_triples_xxy,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n///     [Y, J, ys, ys_gen, [y_2, y_2]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomTriplesXYX,\n///     (X, Y, X),\n///     random_triples_xyx,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n///     [Y, J, ys, ys_gen, [y_1, x_2]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomTriplesXYY,\n///     (X, Y, Y),\n///     random_triples_xyy,\n///     [X, I, xs, xs_gen, [x_0, x_0]],\n///     [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuadruplesXXXY,\n///     (X, X, X, Y),\n///     random_quadruples_xxxy,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1], [x_2, x_2]],\n///     [Y, J, ys, ys_gen, [y_3, y_3]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuadruplesXXYX,\n///     (X, X, Y, X),\n///     random_quadruples_xxyx,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1], [x_3, y_2]],\n///     [Y, J, ys, ys_gen, [y_2, x_3]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuadruplesXXYZ,\n///     (X, X, Y, Z),\n///     random_quadruples_xxyz,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n///     [Y, J, ys, ys_gen, [y_2, y_2]],\n///     [Z, K, zs, zs_gen, [z_3, z_3]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuadruplesXYXZ,\n///     (X, Y, X, Z),\n///     random_quadruples_xyxz,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n///     [Y, J, ys, ys_gen, [y_1, x_2]],\n///     [Z, K, zs, zs_gen, [z_3, z_3]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuadruplesXYYX,\n///     (X, Y, Y, X),\n///     random_quadruples_xyyx,\n///     [X, I, xs, xs_gen, [x_0, x_0], [x_3, y_1]],\n///     [Y, J, ys, ys_gen, [y_1, y_2], [y_2, x_3]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuadruplesXYYZ,\n///     (X, Y, Y, Z),\n///     random_quadruples_xyyz,\n///     [X, I, xs, xs_gen, [x_0, x_0]],\n///     [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]],\n///     [Z, K, zs, zs_gen, [z_3, z_3]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuadruplesXYZZ,\n///     (X, Y, Z, Z),\n///     random_quadruples_xyzz,\n///     [X, I, xs, xs_gen, [x_0, x_0]],\n///     [Y, J, ys, ys_gen, [y_1, y_1]],\n///     [Z, K, zs, zs_gen, [z_2, z_2], [z_3, z_3]]\n/// );\n/// random_custom_tuples!(\n///     (pub(crate)),\n///     RandomQuintuplesXYYYZ,\n///     (X, Y, Y, Y, Z),\n///     random_quintuples_xyyyz,\n///     [X, I, xs, xs_gen, [x_0, x_0]],\n///     [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2], [y_3, y_3]],\n///     [Z, K, zs, zs_gen, [z_4, z_4]]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! random_custom_tuples {\n    (\n        ($($vis:tt)*),\n        $random_struct: ident,\n        $out_t: ty,\n        $random_fn: ident,\n        $([$t: ident, $it: ident, $xs: ident, $xs_gen: ident, $([$x: ident, $x_ord: ident]),*]),*\n    ) => {\n        // Generates random $n$-tuples with elements from $m$ iterators, where $m \\leq n$.\n        //\n        // The mapping from iterators to tuple slots is indicated by the struct name; for example,\n        // in `RandomTriplesXYX` there are two iterators, `X`, and `Y`; `X` generates the elements\n        // in the first and third slots of the output triples, and `Y` generates the elements in the\n        // second slots.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $random_struct<$($t: Clone, $it: Iterator<Item = $t>,)*> {\n            $($xs: $it,)*\n        }\n\n        impl<$($t: Clone, $it: Iterator<Item = $t>,)*> Iterator for $random_struct<$($t, $it,)*>\n        {\n            type Item = $out_t;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                $(\n                    $(\n                        let $x = self.$xs.next().unwrap();\n                    )*\n                )*\n                Some(($($($x_ord,)*)*))\n            }\n        }\n\n        // Generates random $n$-tuples with elements from $m$ iterators, where $m \\leq n$.\n        //\n        // The mapping from iterators to tuple slots is indicated by the function name; for example,\n        // `random_triples_xyx` takes two iterators, `xs`, and `ys`; `xs` generates the elements in\n        // the first and third slots of the output triples, and `ys` generates the elements in the\n        // second slots.\n        //\n        // The probability of a particular $n$-tuple being generated is the product of the\n        // probabilities of each of its elements.\n        //\n        // `xs`, `ys`, `zs`, ... must be infinite.\n        //\n        // # Examples\n        // See [here](self#random_triples_xyx).\n        $($vis)* fn $random_fn<$($t: Clone, $it: Iterator<Item = $t>,)*>(\n            seed: Seed,\n            $($xs_gen: &dyn Fn(Seed) -> $it,)*\n        ) -> $random_struct<$($t, $it,)*> {\n            $random_struct {\n                $($xs: $xs_gen(seed.fork(stringify!($xs))),)*\n            }\n        }\n    }\n}\n\n/// Generates random pairs using elements from a single iterator, where the first element is less\n/// than the second.\n#[derive(Clone, Debug)]\npub struct RandomOrderedUniquePairs<I: Iterator>\nwhere\n    I::Item: Ord,\n{\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomOrderedUniquePairs<I>\nwhere\n    I::Item: Ord,\n{\n    type Item = (I::Item, I::Item);\n\n    #[inline]\n    fn next(&mut self) -> Option<Self::Item> {\n        let mut out_0 = None;\n        let out_1;\n        loop {\n            let x = self.xs.next().unwrap();\n            if out_0.is_none() {\n                out_0 = Some(x);\n            } else {\n                match x.cmp(out_0.as_ref().unwrap()) {\n                    Equal => {}\n                    Greater => {\n                        out_1 = x;\n                        break;\n                    }\n                    Less => {\n                        out_1 = out_0.unwrap();\n                        out_0 = Some(x);\n                        break;\n                    }\n                }\n            }\n        }\n        Some((out_0.unwrap(), out_1))\n    }\n}\n\n/// Generates random pairs using elements from a single iterator, where the first element of each\n/// pair is less than the second.\n///\n/// The input iterator must generate at least two distinct elements; otherwise, this iterator will\n/// hang.\n///\n/// $$\n/// P((x\\_0, x\\_1)) = 2P(x\\_0)P(x\\_1).\n/// $$\n///\n/// The above formula assumes that the pair is valid, \\emph{i.e.} its first element is less than its\n/// second. The probability of an invalid pair is zero.\n///\n/// `xs` must be infinite.\n#[inline]\npub const fn random_ordered_unique_pairs<I: Iterator>(xs: I) -> RandomOrderedUniquePairs<I>\nwhere\n    I::Item: Ord,\n{\n    RandomOrderedUniquePairs { xs }\n}\n\n/// Defines random ordered unique tuple generators.\n///\n/// Malachite provides [`random_ordered_unique_pairs`], but you can also define\n/// `random_ordered_unique_triples`, `random_ordered_unique_quadruples`, and so on, in your program\n/// using the code below.\n///\n/// See usage examples [here](self#random_ordered_unique_quadruples).\n///\n/// ```\n/// use malachite_base::random_ordered_unique_tuples;\n/// use malachite_base::sets::random::{\n///     random_b_tree_sets_fixed_length, RandomBTreeSetsFixedLength,\n/// };\n///\n/// random_ordered_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueTriples,\n///     3,\n///     (I::Item, I::Item, I::Item),\n///     random_ordered_unique_triples,\n///     [0, 1, 2]\n/// );\n/// random_ordered_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     random_ordered_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n/// random_ordered_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueQuintuples,\n///     5,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     random_ordered_unique_quintuples,\n///     [0, 1, 2, 3, 4]\n/// );\n/// random_ordered_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueSextuples,\n///     6,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     random_ordered_unique_sextuples,\n///     [0, 1, 2, 3, 4, 5]\n/// );\n/// random_ordered_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueSeptuples,\n///     7,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     random_ordered_unique_septuples,\n///     [0, 1, 2, 3, 4, 5, 6]\n/// );\n/// random_ordered_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueOctuples,\n///     8,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     random_ordered_unique_octuples,\n///     [0, 1, 2, 3, 4, 5, 6, 7]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! random_ordered_unique_tuples {\n    (\n        ($($vis:tt)*),\n        $struct: ident,\n        $k: expr,\n        $out_t: ty,\n        $fn: ident,\n        [$($i: expr),*]\n    ) => {\n        // Generates random $n$-tuples using elements from a single iterator, where the tuples have\n        // no repeated elements, and the elements are in ascending order.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $struct<I: Iterator> where I::Item: Ord {\n            xs: RandomBTreeSetsFixedLength<I>,\n        }\n\n        impl<I: Iterator> Iterator for $struct<I> where I::Item: Ord {\n            type Item = $out_t;\n\n            #[inline]\n            fn next(&mut self) -> Option<Self::Item> {\n                let mut elements = self.xs.next().unwrap().into_iter();\n                Some(($(((elements.next().unwrap(), $i).0)),*))\n            }\n        }\n\n        // Generates random $n$-tuples using elements from a single iterator, where the tuples have\n        // no repeated elements, and the elements are in ascending order.\n        //\n        // The input iterator must generate at least `len` distinct elements; otherwise, this\n        // iterator will hang.\n        //\n        // $$\n        // P((x\\_i)\\_{i=0}^{n-1}) = n!\\prod\\_{i=0}^{n-1}P(x\\_i).\n        // $$\n        //\n        // The above formula assumes that the tuple is valid, \\emph{i.e.} its elements are strictly\n        // increasing. The probability of an invalid tuple is zero.\n        //\n        // `xs` must be infinite.\n        //\n        // # Examples\n        // See [here](self#random_ordered_unique_quadruples).\n        #[inline]\n        $($vis)* fn $fn<I: Iterator>(xs: I) -> $struct<I>\n        where\n            I::Item: Ord,\n        {\n            $struct {\n                xs: random_b_tree_sets_fixed_length($k, xs),\n            }\n        }\n    }\n}\n\n/// Generates random pairs using elements from a single iterator, where the first element is not\n/// equal to the second.\n#[derive(Clone, Debug)]\npub struct RandomUniquePairs<I: Iterator>\nwhere\n    I::Item: Eq,\n{\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomUniquePairs<I>\nwhere\n    I::Item: Eq,\n{\n    type Item = (I::Item, I::Item);\n\n    #[inline]\n    fn next(&mut self) -> Option<Self::Item> {\n        let mut out_0 = None;\n        let out_1;\n        loop {\n            let x = self.xs.next().unwrap();\n            if let Some(out_0) = out_0.as_ref() {\n                if x != *out_0 {\n                    out_1 = x;\n                    break;\n                }\n            } else {\n                out_0 = Some(x);\n            }\n        }\n        Some((out_0.unwrap(), out_1))\n    }\n}\n\n/// Generates random pairs using elements from a single iterator, where the two elements of each\n/// pair are unequal.\n///\n/// The input iterator must generate at least two distinct elements; otherwise, this iterator will\n/// hang.\n///\n/// `xs` must be infinite.\n#[inline]\npub const fn random_unique_pairs<I: Iterator>(xs: I) -> RandomUniquePairs<I>\nwhere\n    I::Item: Eq,\n{\n    RandomUniquePairs { xs }\n}\n\n/// Defines random unique tuple generators.\n///\n/// Malachite provides [`random_unique_pairs`], but you can also define `random_unique_triples`,\n/// `random_unique_quadruples`, and so on, in your program using the code below.\n///\n/// See usage examples [here](self#random_unique_quadruples).\n///\n/// ```\n/// use malachite_base::random_unique_tuples;\n/// use std::collections::HashMap;\n/// use std::hash::Hash;\n///\n/// random_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueTriples,\n///     3,\n///     (I::Item, I::Item, I::Item),\n///     random_unique_triples,\n///     [0, 1, 2]\n/// );\n/// random_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueQuadruples,\n///     4,\n///     (I::Item, I::Item, I::Item, I::Item),\n///     random_unique_quadruples,\n///     [0, 1, 2, 3]\n/// );\n/// random_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueQuintuples,\n///     5,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item),\n///     random_unique_quintuples,\n///     [0, 1, 2, 3, 4]\n/// );\n/// random_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueSextuples,\n///     6,\n///     (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n///     random_unique_sextuples,\n///     [0, 1, 2, 3, 4, 5]\n/// );\n/// random_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueSeptuples,\n///     7,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     random_unique_septuples,\n///     [0, 1, 2, 3, 4, 5, 6]\n/// );\n/// random_unique_tuples!(\n///     (pub(crate)),\n///     RandomOrderedUniqueOctuples,\n///     8,\n///     (\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item,\n///         I::Item\n///     ),\n///     random_unique_octuples,\n///     [0, 1, 2, 3, 4, 5, 6, 7]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! random_unique_tuples {\n    (\n        ($($vis:tt)*),\n        $struct: ident,\n        $k: expr,\n        $out_t: ty,\n        $fn: ident,\n        [$($i: tt),*]\n    ) => {\n        #[derive(Clone, Debug)]\n        $($vis)* struct $struct<I: Iterator> where I::Item: Eq + Hash {\n            xs: I,\n        }\n\n        impl<I: Iterator> Iterator for $struct<I> where I::Item: Eq + Hash {\n            type Item = $out_t;\n\n            #[inline]\n            fn next(&mut self) -> Option<Self::Item> {\n                let mut xs_to_indices = HashMap::with_capacity($k);\n                let mut i = 0;\n                while i < $k {\n                    xs_to_indices\n                        .entry(self.xs.next().unwrap())\n                        .or_insert_with(|| {\n                            i += 1;\n                            i - 1\n                        });\n                }\n                let mut out = ($((None, $i).0),*);\n                for (x, i) in xs_to_indices {\n                    match i {\n                        $($i => {out.$i = Some(x)},)*\n                        _ => {}\n                    }\n                }\n                Some(($(out.$i.unwrap()),*))\n            }\n        }\n\n        #[inline]\n        $($vis)* fn $fn<I: Iterator>(xs: I) -> $struct<I> where I::Item: Eq + Hash,\n        {\n            $struct { xs }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/unions/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::unions::Union2;\n\n/// Defines exhaustive union generators.\n///\n/// Malachite provides [`lex_union2s`] and [`exhaustive_union2s`], but you can also define\n/// `lex_union3s`, `lex_union4s`, and so on, and `exhaustive_union3s`, `exhaustive_union4s`, and so\n/// on, in your program using the code below. The documentation for [`lex_union2s`] and\n/// [`exhaustive_union2s`] describes these other functions as well.\n///\n/// See usage examples [here](self#lex_union2s) and [here](self#exhaustive_union2s).\n///\n/// ```\n/// use malachite_base::unions::UnionFromStrError;\n/// use malachite_base::{exhaustive_unions, union_struct};\n/// use std::fmt::{self, Display, Formatter};\n/// use std::str::FromStr;\n///\n/// union_struct!(\n///     (pub(crate)),\n///     Union3,\n///     Union3<T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union4,\n///     Union4<T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union5,\n///     Union5<T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union6,\n///     Union6<T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union7,\n///     Union7<T, T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f],\n///     [G, G, 'G', g]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union8,\n///     Union8<T, T, T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f],\n///     [G, G, 'G', g],\n///     [H, H, 'H', h]\n/// );\n///\n/// exhaustive_unions!(\n///     (pub(crate)),\n///     Union3,\n///     LexUnion3s,\n///     ExhaustiveUnion3s,\n///     lex_union3s,\n///     exhaustive_union3s,\n///     3,\n///     [0, X, I, A, xs, xs_done],\n///     [1, Y, J, B, ys, ys_done],\n///     [2, Z, K, C, zs, zs_done]\n/// );\n/// exhaustive_unions!(\n///     (pub(crate)),\n///     Union4,\n///     LexUnion4s,\n///     ExhaustiveUnion4s,\n///     lex_union4s,\n///     exhaustive_union4s,\n///     4,\n///     [0, X, I, A, xs, xs_done],\n///     [1, Y, J, B, ys, ys_done],\n///     [2, Z, K, C, zs, zs_done],\n///     [3, W, L, D, ws, ws_done]\n/// );\n/// exhaustive_unions!(\n///     (pub(crate)),\n///     Union5,\n///     LexUnion5s,\n///     ExhaustiveUnion5s,\n///     lex_union5s,\n///     exhaustive_union5s,\n///     5,\n///     [0, X, I, A, xs, xs_done],\n///     [1, Y, J, B, ys, ys_done],\n///     [2, Z, K, C, zs, zs_done],\n///     [3, W, L, D, ws, ws_done],\n///     [4, V, M, E, vs, vs_done]\n/// );\n/// exhaustive_unions!(\n///     (pub(crate)),\n///     Union6,\n///     LexUnion6s,\n///     ExhaustiveUnion6s,\n///     lex_union6s,\n///     exhaustive_union6s,\n///     6,\n///     [0, X, I, A, xs, xs_done],\n///     [1, Y, J, B, ys, ys_done],\n///     [2, Z, K, C, zs, zs_done],\n///     [3, W, L, D, ws, ws_done],\n///     [4, V, M, E, vs, vs_done],\n///     [5, U, N, F, us, us_done]\n/// );\n/// exhaustive_unions!(\n///     (pub(crate)),\n///     Union7,\n///     LexUnion7s,\n///     ExhaustiveUnion7s,\n///     lex_union7s,\n///     exhaustive_union7s,\n///     7,\n///     [0, X, I, A, xs, xs_done],\n///     [1, Y, J, B, ys, ys_done],\n///     [2, Z, K, C, zs, zs_done],\n///     [3, W, L, D, ws, ws_done],\n///     [4, V, M, E, vs, vs_done],\n///     [5, U, N, F, us, us_done],\n///     [6, T, O, G, ts, ts_done]\n/// );\n/// exhaustive_unions!(\n///     (pub(crate)),\n///     Union8,\n///     LexUnion8s,\n///     ExhaustiveUnion8s,\n///     lex_union8s,\n///     exhaustive_union8s,\n///     8,\n///     [0, X, I, A, xs, xs_done],\n///     [1, Y, J, B, ys, ys_done],\n///     [2, Z, K, C, zs, zs_done],\n///     [3, W, L, D, ws, ws_done],\n///     [4, V, M, E, vs, vs_done],\n///     [5, U, N, F, us, us_done],\n///     [6, T, O, G, ts, ts_done],\n///     [7, S, P, H, ss, ss_done]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! exhaustive_unions {\n    (\n        ($($vis:tt)*),\n        $union: ident,\n        $lex_struct: ident,\n        $exhaustive_struct: ident,\n        $lex_fn: ident,\n        $exhaustive_fn: ident,\n        $n: expr,\n        $([$i: expr, $t: ident, $it: ident, $variant: ident, $xs: ident, $xs_done:ident]),*\n    ) => {\n        /// This documentation applies not only to `LexUnion2s`, but also to `LexUnion3s`,\n        /// `LexUnion4s`, and so on. See [`exhaustive_unions`] for more information.\n        ///\n        /// Generates all $n$-unions with elements from $n$ iterators, in lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterators. All of\n        /// the first variant's elements are generated first, followed by the second variant's\n        /// elements, and so on.\n        #[allow(dead_code)]\n        #[derive(Clone, Debug)]\n        $($vis)* struct $lex_struct<$($t, $it: Iterator<Item=$t>),*> {\n            i: u64,\n            $($xs: $it,)*\n        }\n\n        impl<$($t, $it: Iterator<Item=$t>),*> Iterator for $lex_struct<$($t, $it),*> {\n            type Item = $union<$($t),*>;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                loop {\n                    match self.i {\n                        $(\n                            $i => {\n                                let next = self.$xs.next().map($union::$variant);\n                                if next.is_some() {\n                                    return next;\n                                }\n                            },\n                        )*\n                        _ => return None,\n                    }\n                    self.i += 1;\n                }\n            }\n        }\n\n        /// This documentation applies not only to `lex_union2s`, but also to `lex_union3s`,\n        /// `lex_union4s`, and so on. See [`exhaustive_unions`] for more information.\n        ///\n        /// Generates all $n$-unions with elements from $n$ iterators, in lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterators. All of\n        /// the first variant's elements are generated first, followed by the second variant's\n        /// elements, and so on. This means that all of the iterators, except possibly the last one,\n        /// must be finite. For functions that support multiple infinite element iterators, try\n        /// `exhaustive_union[n]s`.\n        ///\n        /// If the last iterator is finite, the output length is the sum of the lengths of all the\n        /// input iterators. If the last iterator is infinite, the output is also infinite.\n        ///\n        /// If all of the input iterators are empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#lex_union2s).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* const fn $lex_fn<$($t, $it: Iterator<Item=$t>),*>($($xs: $it),*) ->\n                $lex_struct<$($t, $it),*> {\n            $lex_struct {\n                i: 0,\n                $($xs,)*\n            }\n        }\n\n        /// This documentation applies not only to `ExhaustiveUnion2s`, but also to\n        /// `ExhaustiveUnion3s`, `ExhaustiveUnion4s`, and so on. See [`exhaustive_unions`] for more\n        /// information.\n        ///\n        /// Generates all $n$-unions with elements from $n$ iterators.\n        #[allow(dead_code)]\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<$($t, $it: Iterator<Item=$t>),*> {\n            done: bool,\n            i: u64,\n            $(\n                $xs: $it,\n                $xs_done: bool,\n            )*\n        }\n\n        impl<$($t, $it: Iterator<Item=$t>),*> Iterator for $exhaustive_struct<$($t, $it),*> {\n            type Item = $union<$($t),*>;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                if self.done {\n                    None\n                } else {\n                    let original_i = self.i;\n                    loop {\n                        let mut next = None;\n                        match self.i {\n                            $(\n                                $i => if !self.$xs_done {\n                                    next = self.$xs.next().map($union::$variant);\n                                    self.$xs_done = next.is_none();\n                                },\n                            )*\n                            _ => unreachable!(),\n                        }\n                        self.i += 1;\n                        if self.i == $n {\n                            self.i = 0;\n                        }\n                        if next.is_some() {\n                            return next;\n                        }\n                        if self.i == original_i {\n                            self.done = true;\n                            return None;\n                        }\n                    }\n                }\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_union2s`, but also to\n        /// `exhaustive_union3s`, `exhaustive_union4s`, and so on. See [`exhaustive_unions`] for\n        /// more information.\n        ///\n        /// Generates all $n$-unions with elements from $n$ iterators.\n        ///\n        /// The input iterators are advanced in a round-robin fashion. First an element from the\n        /// first variant's iterator is selected, followed by an element from the second variant's\n        /// iterator, and so on until an element has been selected from each iterator. Then another\n        /// element from the first iterator is selected, etc. Iterators that have been exhausted are\n        /// skipped. [`exhaustive_union2s`] behaves just like\n        /// [`Itertools::interleave`]([`itertools::Itertools::interleave`]).\n        ///\n        /// If all input iterators are finite, the output length is the sum of the lengths of the\n        /// iterators. If any iterator is infinite, the output is also infinite.\n        ///\n        /// If all of the input iterators are empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_union2s).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* const fn $exhaustive_fn<$($t, $it: Iterator<Item=$t>),*>($($xs: $it),*) ->\n                $exhaustive_struct<$($t, $it),*> {\n            $exhaustive_struct {\n                done: false,\n                i: 0,\n                $(\n                    $xs,\n                    $xs_done: false,\n                )*\n            }\n        }\n    }\n}\n\nexhaustive_unions!(\n    (pub),\n    Union2,\n    LexUnion2s,\n    ExhaustiveUnion2s,\n    lex_union2s,\n    exhaustive_union2s,\n    2,\n    [0, X, I, A, xs, xs_done],\n    [1, Y, J, B, ys, ys_done]\n);\n"
  },
  {
    "path": "malachite-base/src/unions/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse alloc::string::String;\nuse alloc::string::ToString;\nuse core::fmt::{self, Display, Formatter};\nuse core::str::FromStr;\n\n/// This is the error type for the unions' [`FromStr`] implementations.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub enum UnionFromStrError<E> {\n    /// For when the union's variant can't be determined.\n    Generic(String),\n    /// For when the union's variant can be determined but the wrapped value can't be parsed.\n    Specific(E),\n}\n\n/// Defines unions.\n///\n/// Malachite provides [`Union2`], but you can also define `Union3`, `Union4`, and so on, in your\n/// program using the code below. The documentation for [`Union2`] and describes these other `enum`s\n/// as well.\n///\n/// ```\n/// use malachite_base::union_struct;\n/// use malachite_base::unions::UnionFromStrError;\n/// use std::fmt::{self, Display, Formatter};\n/// use std::str::FromStr;\n///\n/// union_struct!(\n///     (pub(crate)),\n///     Union3,\n///     Union3<T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union4,\n///     Union4<T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union5,\n///     Union5<T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union6,\n///     Union6<T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union7,\n///     Union7<T, T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f],\n///     [G, G, 'G', g]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union8,\n///     Union8<T, T, T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f],\n///     [G, G, 'G', g],\n///     [H, H, 'H', h]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! union_struct {\n    (\n        ($($vis:tt)*),\n        $name: ident,\n        $single: ty,\n        $([$t: ident, $cons: ident, $c: expr, $x: ident]),*\n    ) => {\n        #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]\n        /// This is a union, or sum type, of $n$ values. It is essentially a generic enum.\n        $($vis)* enum $name<$($t),*> {\n            $($cons($t)),*\n        }\n\n        impl<T> $single {\n            /// Given a union whose variants all have the same type, unwraps it into a value of that\n            /// type.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](self#unwrap).\n            #[allow(clippy::missing_const_for_fn)] // Can't be const because of destructor\n            $($vis)* fn unwrap(self) -> T {\n                match self {\n                    $(\n                        $name::$cons($x) => $x\n                    ),*\n                }\n            }\n        }\n\n        impl<$($t: Display),*> Display for $name<$($t),*> {\n            /// Converts a union to a [`String`].\n            ///\n            /// # Examples\n            /// See [here](self#fmt).\n            #[inline]\n            fn fmt(&self, f: &mut Formatter) -> fmt::Result {\n                match self {\n                    $(\n                        $name::$cons($x) => f.write_fmt(format_args!(\"{}({})\", $c, $x))\n                    ),*\n                }\n            }\n        }\n\n        impl<$($t: FromStr),*> FromStr for $name<$($t),*> {\n            type Err = UnionFromStrError<$name<$($t::Err),*>>;\n\n            /// Converts a string to a union.\n            ///\n            /// If the string does not represent a valid union, an error value is returned.\n            ///\n            /// # Examples\n            /// See [here](self#from_str).\n            #[inline]\n            fn from_str(src: &str) -> Result<$name<$($t),*>, Self::Err> {\n                if src.is_empty() {\n                    return Err(UnionFromStrError::Generic(String::new()));\n                }\n                let (head, tail) = src.split_at(1);\n                let tail = if let Some(tail) = tail.strip_prefix('(') {\n                    tail\n                } else {\n                    return Err(UnionFromStrError::Generic(src.to_string()));\n                };\n                let tail = if let Some(tail) = tail.strip_suffix(')') {\n                    tail\n                } else {\n                    return Err(UnionFromStrError::Generic(src.to_string()));\n                };\n                match head.chars().next().unwrap() {\n                    $(\n                        $c => $t::from_str(tail)\n                                .map($name::$cons)\n                                .map_err(|e| UnionFromStrError::Specific($name::$cons(e))),\n                    )*\n                    _ => Err(UnionFromStrError::Generic(src.to_string()))\n                }\n            }\n        }\n    }\n}\n\nunion_struct!((pub), Union2, Union2<T, T>, [A, A, 'A', a], [B, B, 'B', b]);\n\n/// Iterators that generate unions without repetition.\n///\n/// # lex_union2s\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::unions::exhaustive::lex_union2s;\n/// use malachite_base::unions::Union2;\n///\n/// let u2s = lex_union2s(exhaustive_bools(), 0..4).collect_vec();\n/// assert_eq!(\n///     u2s.as_slice(),\n///     &[\n///         Union2::A(false),\n///         Union2::A(true),\n///         Union2::B(0),\n///         Union2::B(1),\n///         Union2::B(2),\n///         Union2::B(3)\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_union2s\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::unions::exhaustive::exhaustive_union2s;\n/// use malachite_base::unions::Union2;\n///\n/// let u2s = exhaustive_union2s(exhaustive_bools(), 0..4).collect_vec();\n/// assert_eq!(\n///     u2s.as_slice(),\n///     &[\n///         Union2::A(false),\n///         Union2::B(0),\n///         Union2::A(true),\n///         Union2::B(1),\n///         Union2::B(2),\n///         Union2::B(3)\n///     ]\n/// );\n/// ```\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate unions randomly.\n///\n/// # random_union2s\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::random::random_char_inclusive_range;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::unions::random::random_union2s;\n/// use malachite_base::unions::Union2;\n///\n/// let us = random_union2s(\n///     EXAMPLE_SEED,\n///     &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n///     &|seed| random_unsigned_inclusive_range::<u32>(seed, 1, 10),\n/// );\n/// assert_eq!(\n///     us.take(20).collect_vec().as_slice(),\n///     &[\n///         Union2::A('v'),\n///         Union2::B(3),\n///         Union2::A('c'),\n///         Union2::A('q'),\n///         Union2::A('i'),\n///         Union2::A('e'),\n///         Union2::A('p'),\n///         Union2::A('g'),\n///         Union2::A('s'),\n///         Union2::B(7),\n///         Union2::A('n'),\n///         Union2::A('t'),\n///         Union2::B(9),\n///         Union2::A('m'),\n///         Union2::A('z'),\n///         Union2::B(7),\n///         Union2::B(9),\n///         Union2::A('o'),\n///         Union2::A('m'),\n///         Union2::B(3),\n///     ],\n/// );\n/// ```\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/unions/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::{RandomUnsignedRange, random_unsigned_range};\nuse crate::random::Seed;\nuse crate::unions::Union2;\n\n/// Defines random union generators.\n///\n/// Malachite provides [`random_union2s`], but you can also define `random_union3s`,\n/// `random_union4s`, and so on, in your program using the code below. The documentation for\n/// [`random_union2s`] describes these other functions as well.\n///\n/// See usage examples [here](self#random_union2s).\n///\n/// ```\n/// use malachite_base::num::random::{random_unsigned_range, RandomUnsignedRange};\n/// use malachite_base::random::Seed;\n/// use malachite_base::unions::UnionFromStrError;\n/// use malachite_base::{random_unions, union_struct};\n/// use std::fmt::{self, Display, Formatter};\n/// use std::str::FromStr;\n///\n/// union_struct!(\n///     (pub(crate)),\n///     Union3,\n///     Union3<T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union4,\n///     Union4<T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union5,\n///     Union5<T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union6,\n///     Union6<T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union7,\n///     Union7<T, T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f],\n///     [G, G, 'G', g]\n/// );\n/// union_struct!(\n///     (pub(crate)),\n///     Union8,\n///     Union8<T, T, T, T, T, T, T, T>,\n///     [A, A, 'A', a],\n///     [B, B, 'B', b],\n///     [C, C, 'C', c],\n///     [D, D, 'D', d],\n///     [E, E, 'E', e],\n///     [F, F, 'F', f],\n///     [G, G, 'G', g],\n///     [H, H, 'H', h]\n/// );\n///\n/// random_unions!(\n///     (pub(crate)),\n///     Union3,\n///     RandomUnion3s,\n///     random_union3s,\n///     3,\n///     [0, X, I, A, xs, xs_gen],\n///     [1, Y, J, B, ys, ys_gen],\n///     [2, Z, K, C, zs, zs_gen]\n/// );\n/// random_unions!(\n///     (pub(crate)),\n///     Union4,\n///     RandomUnion4s,\n///     random_union4s,\n///     4,\n///     [0, X, I, A, xs, xs_gen],\n///     [1, Y, J, B, ys, ys_gen],\n///     [2, Z, K, C, zs, zs_gen],\n///     [3, W, L, D, ws, ws_gen]\n/// );\n/// random_unions!(\n///     (pub(crate)),\n///     Union5,\n///     RandomUnion5s,\n///     random_union5s,\n///     5,\n///     [0, X, I, A, xs, xs_gen],\n///     [1, Y, J, B, ys, ys_gen],\n///     [2, Z, K, C, zs, zs_gen],\n///     [3, W, L, D, ws, ws_gen],\n///     [4, V, M, E, vs, vs_gen]\n/// );\n/// random_unions!(\n///     (pub(crate)),\n///     Union6,\n///     RandomUnion6s,\n///     random_union6s,\n///     6,\n///     [0, X, I, A, xs, xs_gen],\n///     [1, Y, J, B, ys, ys_gen],\n///     [2, Z, K, C, zs, zs_gen],\n///     [3, W, L, D, ws, ws_gen],\n///     [4, V, M, E, vs, vs_gen],\n///     [5, U, N, F, us, us_gen]\n/// );\n/// random_unions!(\n///     (pub(crate)),\n///     Union7,\n///     RandomUnion7s,\n///     random_union7s,\n///     7,\n///     [0, X, I, A, xs, xs_gen],\n///     [1, Y, J, B, ys, ys_gen],\n///     [2, Z, K, C, zs, zs_gen],\n///     [3, W, L, D, ws, ws_gen],\n///     [4, V, M, E, vs, vs_gen],\n///     [5, U, N, F, us, us_gen],\n///     [6, T, O, G, ts, ts_gen]\n/// );\n/// random_unions!(\n///     (pub(crate)),\n///     Union8,\n///     RandomUnion8s,\n///     random_union8s,\n///     8,\n///     [0, X, I, A, xs, xs_gen],\n///     [1, Y, J, B, ys, ys_gen],\n///     [2, Z, K, C, zs, zs_gen],\n///     [3, W, L, D, ws, ws_gen],\n///     [4, V, M, E, vs, vs_gen],\n///     [5, U, N, F, us, us_gen],\n///     [6, T, O, G, ts, ts_gen],\n///     [7, S, P, H, ss, ss_gen]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! random_unions {\n    (\n        ($($vis:tt)*),\n        $union: ident,\n        $random_struct: ident,\n        $random_fn: ident,\n        $n: expr,\n        $([$i: expr, $t: ident, $it: ident, $variant: ident, $xs: ident, $xs_gen: ident]),*\n    ) => {\n        /// This documentation applies not only to `RandomUnion2s`, but also to `RandomUnion3s`,\n        /// `RandomUnion4s`, and so on. See [`random_unions`] for more information.\n        ///\n        /// Generates random $n$-unions with elements from $n$ iterators.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $random_struct<$($t, $it: Iterator<Item=$t>),*> {\n            indices: RandomUnsignedRange<usize>,\n            $($xs: $it,)*\n        }\n\n        impl<$($t, $it: Iterator<Item=$t>),*> Iterator for $random_struct<$($t, $it),*> {\n            type Item = $union<$($t),*>;\n\n            fn next(&mut self) -> Option<Self::Item> {\n                match self.indices.next().unwrap() {\n                    $($i => self.$xs.next().map($union::$variant),)*\n                    _ => unreachable!(),\n                }\n            }\n        }\n\n        /// This documentation applies not only to `random_union2s`, but also to `random_union3s`,\n        /// `random_union4s`, and so on. See [`random_unions`] for more information.\n        ///\n        /// Generates random $n$-unions with elements from $n$ iterators.\n        ///\n        /// The probability of a particular $n$-union being generated is the probability of its\n        /// element divided by $n$.\n        ///\n        /// `xs`, `ys`, `zs`, ... must be infinite.\n        ///\n        /// # Examples\n        /// See [here](self#random_union2s).\n        $($vis)* fn $random_fn<$($t, $it: Iterator<Item=$t>),*>(\n            seed: Seed, $($xs_gen: &dyn Fn(Seed) -> $it),*\n        ) -> $random_struct<$($t, $it),*> {\n            $random_struct {\n                indices: random_unsigned_range(seed.fork(\"indices\"), 0, $n),\n                $($xs: $xs_gen(seed.fork(stringify!($xs))),)*\n            }\n        }\n    }\n}\nrandom_unions!(\n    (pub),\n    Union2,\n    RandomUnion2s,\n    random_union2s,\n    2,\n    [0, X, I, A, xs, xs_gen],\n    [1, Y, J, B, ys, ys_gen]\n);\n"
  },
  {
    "path": "malachite-base/src/vecs/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse crate::iterators::iterator_cache::IteratorCache;\nuse crate::num::arithmetic::traits::CheckedPow;\nuse crate::num::conversion::traits::{ExactFrom, SaturatingFrom, WrappingFrom};\nuse crate::num::exhaustive::{\n    PrimitiveIntIncreasingRange, exhaustive_unsigneds, primitive_int_increasing_inclusive_range,\n    primitive_int_increasing_range,\n};\nuse crate::num::iterators::{RulerSequence, ruler_sequence};\nuse crate::num::logic::traits::SignificantBits;\nuse crate::tuples::exhaustive::{\n    ExhaustiveDependentPairs, ExhaustiveDependentPairsYsGenerator, LexDependentPairs,\n    exhaustive_dependent_pairs, exhaustive_dependent_pairs_stop_after_empty_ys,\n    lex_dependent_pairs_stop_after_empty_ys,\n};\nuse crate::vecs::{ExhaustiveVecPermutations, exhaustive_vec_permutations};\nuse alloc::vec;\nuse alloc::vec::Vec;\nuse core::cmp::{\n    Ordering::{self, *},\n    max, min,\n};\nuse core::iter::{FromIterator, Once, Zip, empty, once};\nuse core::marker::PhantomData;\nuse core::mem::take;\nuse core::ops::RangeFrom;\nuse itertools::{Itertools, repeat_n};\n\n#[doc(hidden)]\npub fn validate_oi_map<I: Iterator<Item = usize>>(max_input_index: usize, xs: I) {\n    let mut oi_unique = hashbrown::HashSet::new();\n    oi_unique.extend(xs);\n    let oi_sorted_unique = oi_unique.into_iter().sorted().collect_vec();\n    assert_eq!(oi_sorted_unique.len(), max_input_index + 1);\n    assert_eq!(*oi_sorted_unique.first().unwrap(), 0);\n    assert_eq!(*oi_sorted_unique.last().unwrap(), max_input_index);\n}\n\n#[doc(hidden)]\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct LexFixedLengthVecsOutput {\n    pub input_index: usize,\n    pub counter: usize,\n}\n\n/// Defines lexicographic fixed-length [`Vec`] generators.\n///\n/// Malachite provides [`lex_vecs_length_2`] and [`lex_vecs_fixed_length_2_inputs`], but you can\n/// also define `lex_vecs_length_3`, `lex_vecs_length_4`, and so on, and\n/// `lex_vecs_fixed_length_3_inputs`, `lex_vecs_fixed_length_4_inputs`, and so on, in your program\n/// using the code below. The documentation for [`lex_vecs_length_2`] and\n/// [`lex_vecs_fixed_length_2_inputs`] describes these other functions as well.\n///\n/// See usage examples [here](self#lex_vecs_length_2) and\n/// [here](self#lex_vecs_fixed_length_2_inputs).\n///\n/// ```\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::lex_vecs_fixed_length;\n/// use malachite_base::vecs::exhaustive::{validate_oi_map, LexFixedLengthVecsOutput};\n///\n/// lex_vecs_fixed_length!(\n///     (pub(crate)),\n///     LexFixedLengthVecs3Inputs,\n///     lex_vecs_fixed_length_3_inputs,\n///     lex_vecs_length_3,\n///     [0, I, xs, xs_outputs],\n///     [1, J, ys, ys_outputs],\n///     [2, K, zs, zs_outputs]\n/// );\n/// lex_vecs_fixed_length!(\n///     (pub(crate)),\n///     LexFixedLengthVecs4Inputs,\n///     lex_vecs_fixed_length_4_inputs,\n///     lex_vecs_length_4,\n///     [0, I, xs, xs_outputs],\n///     [1, J, ys, ys_outputs],\n///     [2, K, zs, zs_outputs],\n///     [3, L, ws, ws_outputs]\n/// );\n/// lex_vecs_fixed_length!(\n///     (pub(crate)),\n///     LexFixedLengthVecs5Inputs,\n///     lex_vecs_fixed_length_5_inputs,\n///     lex_vecs_length_5,\n///     [0, I, xs, xs_outputs],\n///     [1, J, ys, ys_outputs],\n///     [2, K, zs, zs_outputs],\n///     [3, L, ws, ws_outputs],\n///     [4, M, vs, vs_outputs]\n/// );\n/// lex_vecs_fixed_length!(\n///     (pub(crate)),\n///     LexFixedLengthVecs6Inputs,\n///     lex_vecs_fixed_length_6_inputs,\n///     lex_vecs_length_6,\n///     [0, I, xs, xs_outputs],\n///     [1, J, ys, ys_outputs],\n///     [2, K, zs, zs_outputs],\n///     [3, L, ws, ws_outputs],\n///     [4, M, vs, vs_outputs],\n///     [5, N, us, us_outputs]\n/// );\n/// lex_vecs_fixed_length!(\n///     (pub(crate)),\n///     LexFixedLengthVecs7Inputs,\n///     lex_vecs_fixed_length_7_inputs,\n///     lex_vecs_length_7,\n///     [0, I, xs, xs_outputs],\n///     [1, J, ys, ys_outputs],\n///     [2, K, zs, zs_outputs],\n///     [3, L, ws, ws_outputs],\n///     [4, M, vs, vs_outputs],\n///     [5, N, us, us_outputs],\n///     [6, O, ts, ts_outputs]\n/// );\n/// lex_vecs_fixed_length!(\n///     (pub(crate)),\n///     LexFixedLengthVecs8Inputs,\n///     lex_vecs_fixed_length_8_inputs,\n///     lex_vecs_length_8,\n///     [0, I, xs, xs_outputs],\n///     [1, J, ys, ys_outputs],\n///     [2, K, zs, zs_outputs],\n///     [3, L, ws, ws_outputs],\n///     [4, M, vs, vs_outputs],\n///     [5, N, us, us_outputs],\n///     [6, O, ts, ts_outputs],\n///     [7, P, ss, ss_outputs]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! lex_vecs_fixed_length {\n    (\n        ($($vis:tt)*),\n        $exhaustive_struct: ident,\n        $exhaustive_custom_fn: ident,\n        $exhaustive_1_to_1_fn: ident,\n        $([$i: expr, $it: ident, $xs: ident, $xs_outputs: ident]),*\n    ) => {\n        /// This documentation applies not only to `LexFixedLengthVecs2Inputs`, but also to\n        /// `LexFixedLengthVecs3Inputs`, `LexFixedLengthVecs4Inputs`, and so on. See\n        /// [`lex_vecs_fixed_length`] for more information.\n        ///\n        /// Generates all [`Vec`]s of a given length with elements from $m$ iterators, in\n        /// lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterators.\n        ///\n        /// The fixed length $n$ of the [`Vec`]s is greater than or equal to $m$.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<T: Clone, $($it: Iterator<Item = T>,)*> {\n            first: bool,\n            done: bool,\n            $(\n                $xs: IteratorCache<$it>,\n                $xs_outputs: Vec<usize>,\n            )*\n            outputs: Vec<LexFixedLengthVecsOutput>,\n        }\n\n        impl<T: Clone, $($it: Iterator<Item = T>,)*> $exhaustive_struct<T, $($it,)*> {\n            fn increment_counters(&mut self) -> bool {\n                for (i, output) in self.outputs.iter_mut().enumerate().rev() {\n                    output.counter += 1;\n                    let no_carry = match output.input_index {\n                        $(\n                            $i => self.$xs.get(output.counter).is_some(),\n                        )*\n                        _ => unreachable!(),\n                    };\n                    if no_carry {\n                        return false;\n                    } else if i == 0 {\n                        return true;\n                    }\n                    output.counter = 0;\n                }\n                false\n            }\n        }\n\n        impl<T: Clone, $($it: Iterator<Item = T>,)*> Iterator for $exhaustive_struct<T, $($it,)*>\n        {\n            type Item = Vec<T>;\n\n            fn next(&mut self) -> Option<Vec<T>> {\n                if self.done {\n                    None\n                } else if self.first {\n                    self.first = false;\n                    let mut next = vec![None; self.outputs.len()];\n                    $(\n                        if let Some(x) = self.$xs.get(0) {\n                            for &output_index in &self.$xs_outputs {\n                                next[output_index] = Some(x.clone());\n                            }\n                        } else {\n                            self.done = true;\n                            return None;\n                        }\n                    )*\n                    Some(next.into_iter().map(Option::unwrap).collect())\n                } else {\n                    if self.increment_counters() {\n                        self.done = true;\n                        return None;\n                    }\n                    let mut next = Vec::with_capacity(self.outputs.len());\n                    for &output in &self.outputs {\n                        let x = match output.input_index {\n                            $(\n                                $i => self.$xs.get(output.counter),\n                            )*\n                            _ => unreachable!(),\n                        };\n                        next.push(x.unwrap().clone());\n                    }\n                    Some(next)\n                }\n            }\n        }\n\n        /// This documentation applies not only to `lex_vecs_fixed_length_2_inputs`, but also to\n        /// `lex_vecs_fixed_length_3_inputs`, `lex_vecs_fixed_length_4_inputs`, and so on. See\n        /// [`lex_vecs_fixed_length`] for more information.\n        ///\n        /// Generates all length-$n$ [`Vec`]s with elements from $m$ iterators, where $m \\leq n$, in\n        /// lexicographic order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterators.\n        ///\n        /// The `output_to_input_map` parameter defines which iterators are mapped to which slot in\n        /// the output [`Vec`]s. The length of the output [`Vec`]s, $n$, is specified by the length\n        /// of `output_to_input_map`.\n        ///\n        /// The $i$th element of `output_to_input_map` is an index from 0 to $m-1$ which specifies\n        /// which iterator the $i$th output slot is populated with. Together, the elements must\n        /// include all indices from 0 to $m-1$, inclusive, possibly with repetitions.\n        ///\n        /// Let `xs` be the input iterator mapped to the first slot of the output [`Vec`]s. All the\n        /// input iterators, except possibly `xs`, must be finite. If `xs` is finite, the output\n        /// length is the product of the lengths of all the input iterators. If `xs` is infinite,\n        /// the output is also infinite.\n        ///\n        /// If any of the input iterators is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#lex_vecs_fixed_length_2_inputs).\n        #[allow(dead_code)]\n        $($vis)* fn $exhaustive_custom_fn<T: Clone, $($it: Iterator<Item = T>,)*>(\n            $($xs: $it,)*\n            output_to_input_map: &[usize],\n        ) -> $exhaustive_struct<T, $($it,)*> {\n            $(\n                let _max_input_index = $i;\n            )*\n            validate_oi_map(_max_input_index, output_to_input_map.iter().cloned());\n            $(\n                let $xs_outputs = output_to_input_map\n                    .iter()\n                    .enumerate()\n                    .filter_map(|(o, i)| if *i == $i { Some(o) } else { None })\n                    .collect();\n            )*\n            $exhaustive_struct {\n                first: true,\n                done: false,\n                $(\n                    $xs: IteratorCache::new($xs),\n                    $xs_outputs,\n                )*\n                outputs: output_to_input_map\n                    .iter()\n                    .map(|&i| LexFixedLengthVecsOutput {\n                        input_index: i,\n                        counter: 0,\n                    })\n                    .collect(),\n            }\n        }\n\n        /// This documentation applies not only to `lex_vecs_length_2`, but also to\n        /// `lex_vecs_length_3`, `lex_vecs_length_4`, and so on. See [`lex_vecs_fixed_length`] for\n        /// more information.\n        ///\n        /// Generates all length-$n$ [`Vec`]s with elements from $n$ iterators, in lexicographic\n        /// order.\n        ///\n        /// The order is lexicographic with respect to the order of the element iterators.\n        ///\n        /// All of `ys`, `zs`, ... (but not necessarily `xs`) must be finite. If `xs` is finite, the\n        /// output length is the product of the lengths of all the input iterators. If `xs` is\n        /// infinite, the output is also infinite.\n        ///\n        /// If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#lex_vecs_length_2).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* fn $exhaustive_1_to_1_fn<T: Clone, $($it: Iterator<Item = T>,)*>(\n            $($xs: $it,)*\n        ) -> $exhaustive_struct<T, $($it,)*> {\n            $exhaustive_custom_fn($($xs,)* &[$($i,)*])\n        }\n    }\n}\n\nlex_vecs_fixed_length!(\n    (pub),\n    LexFixedLengthVecs2Inputs,\n    lex_vecs_fixed_length_2_inputs,\n    lex_vecs_length_2,\n    [0, I, xs, xs_outputs],\n    [1, J, ys, ys_outputs]\n);\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct LexFixedLengthVecsFromSingleG<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    first: bool,\n    done: bool,\n    xs: IteratorCache<I>,\n    counters: Vec<usize>,\n    phantom: PhantomData<*const I::Item>,\n}\n\nimpl<I: Iterator> LexFixedLengthVecsFromSingleG<I>\nwhere\n    I::Item: Clone,\n{\n    fn increment_counters(&mut self) -> bool {\n        for (i, counter) in self.counters.iter_mut().enumerate().rev() {\n            *counter += 1;\n            if self.xs.get(*counter).is_some() {\n                return false;\n            } else if i == 0 {\n                return true;\n            }\n            *counter = 0;\n        }\n        false\n    }\n}\n\nimpl<I: Iterator> Iterator for LexFixedLengthVecsFromSingleG<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        if self.done {\n            None\n        } else if self.first {\n            self.first = false;\n            if let Some(x) = self.xs.get(0) {\n                Some(repeat_n(x, self.counters.len()).cloned().collect())\n            } else {\n                self.done = true;\n                None\n            }\n        } else if self.increment_counters() {\n            self.done = true;\n            None\n        } else {\n            let xs = &mut self.xs;\n            Some(\n                self.counters\n                    .iter()\n                    .map(|&c| xs.get(c).unwrap().clone())\n                    .collect(),\n            )\n        }\n    }\n}\n\nfn lex_vecs_fixed_length_from_single_g<I: Iterator>(\n    len: u64,\n    xs: I,\n) -> LexFixedLengthVecsFromSingleG<I>\nwhere\n    I::Item: Clone,\n{\n    LexFixedLengthVecsFromSingleG {\n        first: true,\n        done: false,\n        xs: IteratorCache::new(xs),\n        counters: vec![0; usize::exact_from(len)],\n        phantom: PhantomData,\n    }\n}\n\n/// Generates all [`Vec`]s of a given length with elements from a single iterator, in lexicographic\n/// order.\n///\n/// The order is lexicographic with respect to the order of the element iterator.\n///\n/// This `struct` is created by the [`lex_vecs_fixed_length_from_single`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub enum LexFixedLengthVecsFromSingle<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    Zero(Once<Vec<I::Item>>),\n    One(I),\n    GreaterThanOne(LexFixedLengthVecsFromSingleG<I>),\n}\n\nimpl<I: Iterator> Iterator for LexFixedLengthVecsFromSingle<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        match self {\n            Self::Zero(xs) => xs.next(),\n            Self::One(xs) => xs.next().map(|x| vec![x]),\n            Self::GreaterThanOne(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates all [`Vec`]s of a given length with elements from a single iterator, in lexicographic\n/// order.\n///\n/// The order is lexicographic with respect to the order of the element iterator.\n///\n/// `xs` must be finite.\n///\n/// The output length is $k^n$, where $k$ is `xs.count()` and $n$ is `len`.\n///\n/// If `len` is 0, the output consists of one empty [`Vec`].\n///\n/// If `xs` is empty, the output is also empty, unless `len` is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_vecs_fixed_length_from_single;\n///\n/// let xss = lex_vecs_fixed_length_from_single(2, 0..4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[0, 0],\n///         &[0, 1],\n///         &[0, 2],\n///         &[0, 3],\n///         &[1, 0],\n///         &[1, 1],\n///         &[1, 2],\n///         &[1, 3],\n///         &[2, 0],\n///         &[2, 1],\n///         &[2, 2],\n///         &[2, 3],\n///         &[3, 0],\n///         &[3, 1],\n///         &[3, 2],\n///         &[3, 3]\n///     ]\n/// );\n/// ```\npub fn lex_vecs_fixed_length_from_single<I: Iterator>(\n    len: u64,\n    xs: I,\n) -> LexFixedLengthVecsFromSingle<I>\nwhere\n    I::Item: Clone,\n{\n    match len {\n        0 => LexFixedLengthVecsFromSingle::Zero(once(Vec::new())),\n        1 => LexFixedLengthVecsFromSingle::One(xs),\n        len => LexFixedLengthVecsFromSingle::GreaterThanOne(lex_vecs_fixed_length_from_single_g(\n            len, xs,\n        )),\n    }\n}\n\n/// Defines exhaustive fixed-length [`Vec`] generators.\n///\n/// Malachite provides [`exhaustive_vecs_length_2`] and [`exhaustive_vecs_fixed_length_2_inputs`],\n/// but you can also define `exhaustive_vecs_length_3`, `exhaustive_vecs_length_4`, and so on, and\n/// `exhaustive_vecs_fixed_length_3_inputs`, `exhaustive_vecs_fixed_length_4_inputs`, and so on, in\n/// your program using the code below. The documentation for [`exhaustive_vecs_length_2`] and\n/// [`exhaustive_vecs_fixed_length_2_inputs`] describes these other functions as well.\n///\n/// See usage examples [here](self#exhaustive_vecs_length_2) and\n/// [here](self#exhaustive_vecs_fixed_length_2_inputs).\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::exhaustive_vecs_fixed_length;\n/// use malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n/// use malachite_base::iterators::iterator_cache::IteratorCache;\n/// use malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n/// use malachite_base::num::logic::traits::SignificantBits;\n/// use malachite_base::vecs::exhaustive::validate_oi_map;\n/// use std::cmp::max;\n///\n/// exhaustive_vecs_fixed_length!(\n///     (pub(crate)),\n///     ExhaustiveFixedLengthVecs3Inputs,\n///     exhaustive_vecs_fixed_length_3_inputs,\n///     exhaustive_vecs_length_3,\n///     [0, I, xs, xs_done, xs_outputs],\n///     [1, J, ys, ys_done, ys_outputs],\n///     [2, K, zs, zs_done, zs_outputs]\n/// );\n/// exhaustive_vecs_fixed_length!(\n///     (pub(crate)),\n///     ExhaustiveFixedLengthVecs4Inputs,\n///     exhaustive_vecs_fixed_length_4_inputs,\n///     exhaustive_vecs_length_4,\n///     [0, I, xs, xs_done, xs_outputs],\n///     [1, J, ys, ys_done, ys_outputs],\n///     [2, K, zs, zs_done, zs_outputs],\n///     [3, L, ws, ws_done, ws_outputs]\n/// );\n/// exhaustive_vecs_fixed_length!(\n///     (pub(crate)),\n///     ExhaustiveFixedLengthVecs5Inputs,\n///     exhaustive_vecs_fixed_length_5_inputs,\n///     exhaustive_vecs_length_5,\n///     [0, I, xs, xs_done, xs_outputs],\n///     [1, J, ys, ys_done, ys_outputs],\n///     [2, K, zs, zs_done, zs_outputs],\n///     [3, L, ws, ws_done, ws_outputs],\n///     [4, M, vs, vs_done, vs_outputs]\n/// );\n/// exhaustive_vecs_fixed_length!(\n///     (pub(crate)),\n///     ExhaustiveFixedLengthVecs6Inputs,\n///     exhaustive_vecs_fixed_length_6_inputs,\n///     exhaustive_vecs_length_6,\n///     [0, I, xs, xs_done, xs_outputs],\n///     [1, J, ys, ys_done, ys_outputs],\n///     [2, K, zs, zs_done, zs_outputs],\n///     [3, L, ws, ws_done, ws_outputs],\n///     [4, M, vs, vs_done, vs_outputs],\n///     [5, N, us, us_done, us_outputs]\n/// );\n/// exhaustive_vecs_fixed_length!(\n///     (pub(crate)),\n///     ExhaustiveFixedLengthVecs7,\n///     exhaustive_vecs_fixed_length_7_inputs,\n///     exhaustive_vecs_length_7,\n///     [0, I, xs, xs_done, xs_outputs],\n///     [1, J, ys, ys_done, ys_outputs],\n///     [2, K, zs, zs_done, zs_outputs],\n///     [3, L, ws, ws_done, ws_outputs],\n///     [4, M, vs, vs_done, vs_outputs],\n///     [5, N, us, us_done, us_outputs],\n///     [6, O, ts, ts_done, ts_outputs]\n/// );\n/// exhaustive_vecs_fixed_length!(\n///     (pub(crate)),\n///     ExhaustiveFixedLengthVecs8Inputs,\n///     exhaustive_vecs_fixed_length_8_inputs,\n///     exhaustive_vecs_length_8,\n///     [0, I, xs, xs_done, xs_outputs],\n///     [1, J, ys, ys_done, ys_outputs],\n///     [2, K, zs, zs_done, zs_outputs],\n///     [3, L, ws, ws_done, ws_outputs],\n///     [4, M, vs, vs_done, vs_outputs],\n///     [5, N, us, us_done, us_outputs],\n///     [6, O, ts, ts_done, ts_outputs],\n///     [7, P, ss, ss_done, ss_outputs]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! exhaustive_vecs_fixed_length {\n    (\n        ($($vis:tt)*),\n        $exhaustive_struct: ident,\n        $exhaustive_custom_fn: ident,\n        $exhaustive_1_to_1_fn: ident,\n        $([$i: expr, $it: ident, $xs: ident, $xs_done: ident, $outputs: ident]),*\n    ) => {\n        /// This documentation applies not only to `ExhaustiveFixedLengthVecs2Inputs`, but also to\n        /// `ExhaustiveFixedLengthVecs3Inputs`, `ExhaustiveFixedLengthVecs4Inputs`, and so on. See\n        /// [`exhaustive_vecs_fixed_length`] for more information.\n        ///\n        /// Generates all [`Vec`]s of a given length with elements from $m$ iterators.\n        ///\n        /// The fixed length $n$ of the [`Vec`]s is greater than or equal to $m$.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $exhaustive_struct<T: Clone, $($it: Iterator<Item=T>,)*> {\n            i: u64,\n            len: u64,\n            limit: Option<u64>,\n            distributor: BitDistributor,\n            $(\n                $xs: IteratorCache<$it>,\n                $xs_done: bool,\n                $outputs: Vec<usize>,\n            )*\n        }\n\n        impl<T: Clone, $($it: Iterator<Item=T>,)*> $exhaustive_struct<T, $($it,)*> {\n            fn try_getting_limit(&mut self) {\n                let mut all_limits_known = true;\n                $(\n                    if let Some(xs_len) = self.$xs.known_len() {\n                        if xs_len == 0 {\n                            self.limit = Some(0);\n                            return;\n                        }\n                    } else {\n                        all_limits_known = false;\n                    }\n                )*\n                if !all_limits_known {\n                    return;\n                }\n                let mut product = 1u64;\n                $(\n                    let xs_len = u64::exact_from(self.$xs.known_len().unwrap());\n                    for _ in 0..self.$outputs.len() {\n                        if let Some(new_product) = product.checked_mul(xs_len) {\n                            product = new_product;\n                        } else {\n                            return;\n                        }\n                    }\n                )*\n                self.limit = Some(product);\n            }\n        }\n\n        impl<T: Clone, $($it: Iterator<Item=T>,)*> Iterator for $exhaustive_struct<T, $($it,)*> {\n            type Item = Vec<T>;\n\n            fn next(&mut self) -> Option<Vec<T>> {\n                if Some(self.i) == self.limit {\n                    None\n                } else {\n                    if self.i == u64::MAX {\n                        panic!(\"Too many iterations\");\n                    }\n                    loop {\n                        let mut all_are_valid = true;\n                        $(\n                            for &output_index in &self.$outputs {\n                                if self.$xs.get(\n                                    self.distributor.get_output(output_index)\n                                ).is_none() {\n                                    all_are_valid = false;\n                                    break;\n                                }\n                            }\n                            if !all_are_valid {\n                                if self.i == 0 {\n                                    self.limit = Some(0);\n                                    return None;\n                                } else if !self.$xs_done {\n                                    self.try_getting_limit();\n                                    if Some(self.i) == self.limit {\n                                        return None;\n                                    }\n                                    self.$xs_done = true;\n                                    let xs_len = self.$xs.known_len().unwrap();\n                                    // xs_len > 0 at this point\n                                    self.distributor.set_max_bits(\n                                        &self.$outputs,\n                                        max(\n                                            1,\n                                            usize::wrapping_from((xs_len - 1).significant_bits())\n                                        )\n                                    );\n                                } else {\n                                    self.distributor.increment_counter();\n                                }\n                                continue;\n                            }\n                        )*\n                        break;\n                    }\n                    let mut out = vec![None; usize::exact_from(self.len)];\n                    $(\n                        for &output_index in &self.$outputs {\n                            let x = self.$xs.get(self.distributor.get_output(output_index));\n                            out[output_index] = Some(x.unwrap().clone());\n                        }\n                    )*\n                    self.i += 1;\n                    self.distributor.increment_counter();\n                    Some(out.into_iter().map(Option::unwrap).collect())\n                }\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_vecs_fixed_length_2_inputs`, but also\n        /// to `exhaustive_vecs_fixed_length_3_inputs`, `exhaustive_vecs_fixed_length_4_inputs`, and\n        /// so on. See [`exhaustive_vecs_fixed_length`] for more information.\n        ///\n        /// Generates all [`Vec`]s of a given length with elements from $m$ iterators, where $m \\leq\n        /// n$.\n        ///\n        /// The `output_types` parameter defines which iterators are mapped to which slot in the\n        /// output [`Vec`]s, and how quickly each output slot advances through its iterator. The\n        /// length of the output [`Vec`]s, $n$, is specified by the length of `output_types`.\n        ///\n        /// The $i$th element of `output_types` is a pair of [`BitDistributorOutputType`] and\n        /// `usize`. The [`BitDistributorOutputType`] determines how quickly the $i$th output slot\n        /// advances through its iterator; see the [`BitDistributor`] documentation for a\n        /// description of the different types. The `usize` is an index from 0 to $m-1$ which\n        /// specifies which iterator the $i$th output slot is populated with. Together, the `usize`s\n        /// must include all indices from 0 to $m-1$, inclusive, possibly with repetitions.\n        ///\n        /// If all of `xs`, `ys`, `zs`, ... are finite, the output length is the product of their\n        /// lengths. If any of `xs`, `ys`, `zs`, ... are infinite, the output is also infinite.\n        ///\n        /// If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        ///\n        /// # Panics\n        /// Panics if the `usize`s in `output_types` do not include all indices from 0 to $m-1$,\n        /// inclusive, possibly with repetitions. In particular, the length of `output_types` must\n        /// be at least $m$.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_vecs_fixed_length_2_inputs).\n        #[allow(dead_code)]\n        $($vis)* fn $exhaustive_custom_fn<T: Clone, $($it: Iterator<Item=T>,)*> (\n            $($xs: $it,)*\n            output_types: &[(BitDistributorOutputType, usize)],\n        ) -> $exhaustive_struct<T, $($it,)*> {\n            $(\n                let _max_input_index = $i;\n            )*\n            let output_to_input_map = output_types.iter().map(|(_, i)| *i).collect_vec();\n            validate_oi_map(_max_input_index, output_to_input_map.iter().cloned());\n            $exhaustive_struct {\n                i: 0,\n                len: u64::exact_from(output_types.len()),\n                limit: None,\n                distributor: BitDistributor::new(output_types.iter().map(|(ot, _)| *ot)\n                    .collect_vec().as_slice()),\n                $(\n                    $xs: IteratorCache::new($xs),\n                    $xs_done: false,\n                    $outputs: output_types.iter().enumerate()\n                        .filter_map(|(o, (_, i))| if *i == $i { Some(o) } else { None }).collect(),\n                )*\n            }\n        }\n\n        /// This documentation applies not only to `exhaustive_vecs_length_2`, but also to\n        /// `exhaustive_vecs_length_3`, `exhaustive_vecs_length_4`, and so on. See\n        /// [`exhaustive_vecs_fixed_length`] for more information.\n        ///\n        /// Generates all length-$n$ [`Vec`]s with elements from $n$ iterators.\n        ///\n        /// If all of `xs`, `ys`, `zs`, ... are finite, the output length is the product of their\n        /// lengths. If any of `xs`, `ys`, `zs`, ... are infinite, the output is also infinite.\n        ///\n        /// If any of `xs`, `ys`, `zs`, ... is empty, the output is also empty.\n        ///\n        /// # Examples\n        /// See [here](self#exhaustive_vecs_length_2).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* fn $exhaustive_1_to_1_fn<T: Clone, $($it: Iterator<Item=T>,)*> (\n            $($xs: $it,)*\n        ) -> $exhaustive_struct<T, $($it,)*> {\n            $exhaustive_custom_fn(\n                $($xs,)*\n                &[$((BitDistributorOutputType::normal(1), $i),)*]\n            )\n        }\n    }\n}\n\nexhaustive_vecs_fixed_length!(\n    (pub),\n    ExhaustiveFixedLengthVecs2Inputs,\n    exhaustive_vecs_fixed_length_2_inputs,\n    exhaustive_vecs_length_2,\n    [0, I, xs, xs_done, xs_outputs],\n    [1, J, ys, ys_done, ys_outputs]\n);\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct ExhaustiveFixedLengthVecs1InputG<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    i: u64,\n    len: u64,\n    limit: Option<u64>,\n    distributor: BitDistributor,\n    xs: IteratorCache<I>,\n    xs_done: bool,\n    phantom: PhantomData<*const I::Item>,\n}\n\nimpl<I: Iterator> Iterator for ExhaustiveFixedLengthVecs1InputG<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        if Some(self.i) == self.limit {\n            None\n        } else {\n            assert!(self.i != u64::MAX, \"Too many iterations\");\n            loop {\n                let mut all_are_valid = true;\n                for i in 0..usize::exact_from(self.len) {\n                    if self.xs.get(self.distributor.get_output(i)).is_none() {\n                        all_are_valid = false;\n                        break;\n                    }\n                }\n                if all_are_valid {\n                    break;\n                } else if !self.xs_done {\n                    let xs_len = self.xs.known_len().unwrap();\n                    self.limit = CheckedPow::checked_pow(u64::exact_from(xs_len), self.len);\n                    if Some(self.i) == self.limit {\n                        return None;\n                    }\n                    self.xs_done = true;\n                    // xs_len > 0 at this point\n                    self.distributor.set_max_bits(\n                        &[0],\n                        max(1, usize::wrapping_from((xs_len - 1).significant_bits())),\n                    );\n                } else {\n                    self.distributor.increment_counter();\n                }\n            }\n            let out = (0..usize::exact_from(self.len))\n                .map(|i| self.xs.get(self.distributor.get_output(i)).unwrap().clone())\n                .collect();\n            self.i += 1;\n            self.distributor.increment_counter();\n            Some(out)\n        }\n    }\n}\n\nfn exhaustive_vecs_fixed_length_1_input_g<I: Iterator>(\n    xs: I,\n    output_types: &[BitDistributorOutputType],\n) -> ExhaustiveFixedLengthVecs1InputG<I>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveFixedLengthVecs1InputG {\n        i: 0,\n        len: u64::exact_from(output_types.len()),\n        limit: None,\n        distributor: BitDistributor::new(output_types),\n        xs: IteratorCache::new(xs),\n        xs_done: false,\n        phantom: PhantomData,\n    }\n}\n\n/// Generates all [`Vec`]s of a given length with elements from a single iterator.\n///\n/// This `struct` is created by [`exhaustive_vecs_fixed_length_from_single`]; see its documentation\n/// for more.\n#[allow(clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum ExhaustiveFixedLengthVecs1Input<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    Zero(Once<Vec<I::Item>>),\n    One(I),\n    GreaterThanOne(ExhaustiveFixedLengthVecs1InputG<I>),\n}\n\nimpl<I: Iterator> Iterator for ExhaustiveFixedLengthVecs1Input<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        match self {\n            Self::Zero(xs) => xs.next(),\n            Self::One(xs) => xs.next().map(|x| vec![x]),\n            Self::GreaterThanOne(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates all length-$n$ [`Vec`]s with elements from a single iterator.\n///\n/// This function differs from [`exhaustive_vecs_fixed_length_from_single`] in that different\n/// [`BitDistributorOutputType`]s may be specified for each output element.\n///\n/// The $i$th element of `output_types` is a [`BitDistributorOutputType`] that determines how\n/// quickly the $i$th output slot advances through the iterator; see the [`BitDistributor`]\n/// documentation for a description of the different types. The length of the output [`Vec`]s, $n$,\n/// is specified by the length of `output_types`.\n///\n/// If `xs` is finite, the output length is $k^n$, where $k$ is `xs.count()` and $n$ is `len`. If\n/// `xs` is infinite, the output is also infinite.\n///\n/// If `len` is 0, the output consists of one empty [`Vec`].\n///\n/// If `xs` is empty, the output is also empty, unless `len` is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n/// use malachite_base::iterators::bit_distributor::BitDistributorOutputType;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_fixed_length_1_input;\n///\n/// // We are generating length-3 [`Vec`]s of chars using one input iterator, which produces all\n/// // ASCII chars. The third element has a tiny output type, so it will grow more slowly than the\n/// // other two elements (though it doesn't look that way from the first few [`Vec`]s).\n/// let xss = exhaustive_vecs_fixed_length_1_input(\n///     exhaustive_ascii_chars(),\n///     &[\n///         BitDistributorOutputType::normal(1),\n///         BitDistributorOutputType::normal(1),\n///         BitDistributorOutputType::tiny(),\n///     ],\n/// );\n/// let xss_prefix = xss.take(20).collect_vec();\n/// assert_eq!(\n///     xss_prefix\n///         .iter()\n///         .map(Vec::as_slice)\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         &['a', 'a', 'a'],\n///         &['a', 'a', 'b'],\n///         &['a', 'a', 'c'],\n///         &['a', 'a', 'd'],\n///         &['a', 'b', 'a'],\n///         &['a', 'b', 'b'],\n///         &['a', 'b', 'c'],\n///         &['a', 'b', 'd'],\n///         &['a', 'a', 'e'],\n///         &['a', 'a', 'f'],\n///         &['a', 'a', 'g'],\n///         &['a', 'a', 'h'],\n///         &['a', 'b', 'e'],\n///         &['a', 'b', 'f'],\n///         &['a', 'b', 'g'],\n///         &['a', 'b', 'h'],\n///         &['b', 'a', 'a'],\n///         &['b', 'a', 'b'],\n///         &['b', 'a', 'c'],\n///         &['b', 'a', 'd']\n///     ]\n/// );\n/// ```\npub fn exhaustive_vecs_fixed_length_1_input<I: Iterator>(\n    xs: I,\n    output_types: &[BitDistributorOutputType],\n) -> ExhaustiveFixedLengthVecs1Input<I>\nwhere\n    I::Item: Clone,\n{\n    match output_types.len() {\n        0 => ExhaustiveFixedLengthVecs1Input::Zero(once(Vec::new())),\n        1 => ExhaustiveFixedLengthVecs1Input::One(xs),\n        _ => ExhaustiveFixedLengthVecs1Input::GreaterThanOne(\n            exhaustive_vecs_fixed_length_1_input_g(xs, output_types),\n        ),\n    }\n}\n\n/// Generates all [`Vec`]s of a given length with elements from a single iterator.\n///\n/// If `xs` is finite, the output length is $\\ell^n$, where $\\ell$ is `xs.count()` and $n$ is `len`.\n/// If `xs` is infinite, the output is also infinite.\n///\n/// If `len` is 0, the output consists of one empty [`Vec`].\n///\n/// If `xs` is empty, the output is also empty, unless `len` is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_fixed_length_from_single;\n///\n/// let xss = exhaustive_vecs_fixed_length_from_single(2, 0..4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[0, 0],\n///         &[0, 1],\n///         &[1, 0],\n///         &[1, 1],\n///         &[0, 2],\n///         &[0, 3],\n///         &[1, 2],\n///         &[1, 3],\n///         &[2, 0],\n///         &[2, 1],\n///         &[3, 0],\n///         &[3, 1],\n///         &[2, 2],\n///         &[2, 3],\n///         &[3, 2],\n///         &[3, 3]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_vecs_fixed_length_from_single<I: Iterator>(\n    len: u64,\n    xs: I,\n) -> ExhaustiveFixedLengthVecs1Input<I>\nwhere\n    I::Item: Clone,\n{\n    exhaustive_vecs_fixed_length_1_input(\n        xs,\n        &vec![BitDistributorOutputType::normal(1); usize::exact_from(len)],\n    )\n}\n\n#[derive(Clone, Debug)]\nstruct LexVecsGenerator<Y: Clone, J: Clone + Iterator<Item = Y>> {\n    ys: J,\n}\n\nimpl<Y: Clone, J: Clone + Iterator<Item = Y>>\n    ExhaustiveDependentPairsYsGenerator<u64, Vec<Y>, LexFixedLengthVecsFromSingle<J>>\n    for LexVecsGenerator<Y, J>\n{\n    #[inline]\n    fn get_ys(&self, &x: &u64) -> LexFixedLengthVecsFromSingle<J> {\n        lex_vecs_fixed_length_from_single(x, self.ys.clone())\n    }\n}\n\n#[inline]\nconst fn shortlex_vecs_from_element_iterator_helper<\n    T: Clone,\n    I: Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n) -> LexDependentPairs<u64, Vec<T>, LexVecsGenerator<T, J>, I, LexFixedLengthVecsFromSingle<J>> {\n    lex_dependent_pairs_stop_after_empty_ys(xs, LexVecsGenerator { ys })\n}\n\n/// Generates all [`Vec`]s with elements from a specified iterator and with lengths from another\n/// iterator.\n#[derive(Clone, Debug)]\npub struct ShortlexVecs<T: Clone, I: Iterator<Item = u64>, J: Clone + Iterator<Item = T>>(\n    LexDependentPairs<u64, Vec<T>, LexVecsGenerator<T, J>, I, LexFixedLengthVecsFromSingle<J>>,\n);\n\nimpl<T: Clone, I: Iterator<Item = u64>, J: Clone + Iterator<Item = T>> Iterator\n    for ShortlexVecs<T, I, J>\n{\n    type Item = Vec<T>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<T>> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all [`Vec`]s with elements from a specified iterator and with lengths from another\n/// iterator.\n///\n/// The length-generating iterator is `xs`, and the element-generating iterator is `ys`.\n///\n/// If the provided lengths are $\\ell_0, \\ell_1, \\ell_2, \\ldots$, then first all [`Vec`]s with\n/// length $\\ell_0$ will be generated, in lexicographic order; then all [`Vec`]s with length\n/// $\\ell_2$, and so on. If the lengths iterator has repetitions, then the generated [`Vec`]s will\n/// be repeated too.\n///\n/// `ys` must be finite; if it's infinite, the output will never get past the first nonzero $\\ell$.\n///\n/// There's one quirk if `ys` is empty: then the iterator will stop as soon as it encounters a\n/// nonzero $\\ell$, even if there are zeros later on. This prevents the iterator hanging when given\n/// an empty `ys` and lengths $0, 1, 2, \\ldots$.\n///\n/// If `ys` is empty, the output length is the amount of zeros generated by `xs` before the first\n/// nonzero length. If `ys` is nonempty and `xs` is infinite, the output is infinite. Finally, if\n/// `ys` is nonempty and `xs` is finite, the output length is\n/// $$\n/// \\sum_{k=0}^{m-1} n^{\\ell_k},\n/// $$\n/// where $n$ is `ys.count()` and $m$ is `xs.count()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::nevers::nevers;\n/// use malachite_base::vecs::exhaustive::shortlex_vecs_from_length_iterator;\n///\n/// let xss = shortlex_vecs_from_length_iterator([2, 1, 2].iter().cloned(), exhaustive_bools())\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[false, false][..],\n///         &[false, true],\n///         &[true, false],\n///         &[true, true],\n///         &[false],\n///         &[true],\n///         &[false, false],\n///         &[false, true],\n///         &[true, false],\n///         &[true, true]\n///     ]\n/// );\n///\n/// let xss =\n///     shortlex_vecs_from_length_iterator([0, 0, 1, 0].iter().cloned(), nevers()).collect_vec();\n/// // Stops after first empty ys\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[&[], &[]]\n/// );\n/// ```\n#[inline]\npub const fn shortlex_vecs_from_length_iterator<\n    T: Clone,\n    I: Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n) -> ShortlexVecs<T, I, J> {\n    ShortlexVecs(shortlex_vecs_from_element_iterator_helper(xs, ys))\n}\n\n/// Generates [`Vec`]s with elements from a specified iterator, in shortlex order.\n///\n/// Shortlex order means that the [`Vec`]s are output from shortest to longest, and [`Vec`]s of the\n/// same length are output in lexicographic order with respect to the ordering of the [`Vec`]\n/// elements specified by the input iterator.\n///\n/// `xs` must be finite; if it's infinite, only [`Vec`]s of length 0 and 1 are ever produced.\n///\n/// If `xs` is empty, the output length is 1; otherwise, the output is infinite.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::vecs::exhaustive::shortlex_vecs;\n///\n/// let bss = shortlex_vecs(exhaustive_bools()).take(20).collect_vec();\n/// assert_eq!(\n///     bss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[false],\n///         &[true],\n///         &[false, false],\n///         &[false, true],\n///         &[true, false],\n///         &[true, true],\n///         &[false, false, false],\n///         &[false, false, true],\n///         &[false, true, false],\n///         &[false, true, true],\n///         &[true, false, false],\n///         &[true, false, true],\n///         &[true, true, false],\n///         &[true, true, true],\n///         &[false, false, false, false],\n///         &[false, false, false, true],\n///         &[false, false, true, false],\n///         &[false, false, true, true],\n///         &[false, true, false, false]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_vecs<I: Clone + Iterator>(\n    xs: I,\n) -> ShortlexVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    shortlex_vecs_from_length_iterator(exhaustive_unsigneds(), xs)\n}\n\n/// Generates all [`Vec`]s with a minimum length and with elements from a specified iterator, in\n/// shortlex order.\n///\n/// Shortlex order means that the [`Vec`]s are output from shortest to longest, and [`Vec`]s of the\n/// same length are output in lexicographic order with respect to the ordering of the [`Vec`]\n/// elements specified by the input iterator.\n///\n/// `xs` must be finite; if it's infinite, only [`Vec`]s of length `min_length` (or 0 and 1, if\n/// `min_length` is 0) are ever produced.\n///\n/// If `xs` is empty and `min_length` is 0, the output length is 1; if `xs` is empty and\n/// `min_length` is greater than 0, the output is empty; otherwise, the output is infinite.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::vecs::exhaustive::shortlex_vecs_min_length;\n///\n/// let bss = shortlex_vecs_min_length(2, exhaustive_bools())\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     bss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[false, false][..],\n///         &[false, true],\n///         &[true, false],\n///         &[true, true],\n///         &[false, false, false],\n///         &[false, false, true],\n///         &[false, true, false],\n///         &[false, true, true],\n///         &[true, false, false],\n///         &[true, false, true],\n///         &[true, true, false],\n///         &[true, true, true],\n///         &[false, false, false, false],\n///         &[false, false, false, true],\n///         &[false, false, true, false],\n///         &[false, false, true, true],\n///         &[false, true, false, false],\n///         &[false, true, false, true],\n///         &[false, true, true, false],\n///         &[false, true, true, true]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_vecs_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ShortlexVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    shortlex_vecs_from_length_iterator(\n        primitive_int_increasing_inclusive_range(min_length, u64::MAX),\n        xs,\n    )\n}\n\n/// Generates all [`Vec`]s with lengths in $[a, b)$ and with elements from a specified iterator, in\n/// shortlex order.\n///\n/// Shortlex order means that the [`Vec`]s are output from shortest to longest, and [`Vec`]s of the\n/// same length are output in lexicographic order with respect to the ordering of the [`Vec`]\n/// elements specified by the input iterator.\n///\n/// `xs` must be finite; if it's infinite and $a < b$, only [`Vec`]s of length `a` (or 0 and 1, if\n/// `a` is 0) are ever produced.\n///\n/// The output length is\n/// $$\n/// \\sum_{k=a}^{b-1} n^k,\n/// $$\n/// where $k$ is `xs.count()`.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::vecs::exhaustive::shortlex_vecs_length_range;\n///\n/// let bss = shortlex_vecs_length_range(2, 4, exhaustive_bools()).collect_vec();\n/// assert_eq!(\n///     bss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[false, false][..],\n///         &[false, true],\n///         &[true, false],\n///         &[true, true],\n///         &[false, false, false],\n///         &[false, false, true],\n///         &[false, true, false],\n///         &[false, true, true],\n///         &[true, false, false],\n///         &[true, false, true],\n///         &[true, true, false],\n///         &[true, true, true]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_vecs_length_range<I: Clone + Iterator>(\n    a: u64,\n    mut b: u64,\n    xs: I,\n) -> ShortlexVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    if a > b {\n        b = a;\n    }\n    shortlex_vecs_from_length_iterator(primitive_int_increasing_range(a, b), xs)\n}\n\n/// Generates all [`Vec`]s with lengths in $[a, b]$ and with elements from a specified iterator, in\n/// shortlex order.\n///\n/// Shortlex order means that the [`Vec`]s are output from shortest to longest, and [`Vec`]s of the\n/// same length are output in lexicographic order with respect to the ordering of the [`Vec`]\n/// elements specified by the input iterator.\n///\n/// `xs` must be finite; if it's infinite, only [`Vec`]s of length `a` (or 0 and 1, if `a` is 0) are\n/// ever produced.\n///\n/// The output length is\n/// $$\n/// \\sum_{k=a}^b n^k,\n/// $$\n/// where $k$ is `xs.count()`.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::vecs::exhaustive::shortlex_vecs_length_inclusive_range;\n///\n/// let bss = shortlex_vecs_length_inclusive_range(2, 3, exhaustive_bools()).collect_vec();\n/// assert_eq!(\n///     bss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[false, false][..],\n///         &[false, true],\n///         &[true, false],\n///         &[true, true],\n///         &[false, false, false],\n///         &[false, false, true],\n///         &[false, true, false],\n///         &[false, true, true],\n///         &[true, false, false],\n///         &[true, false, true],\n///         &[true, true, false],\n///         &[true, true, true]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_vecs_length_inclusive_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> ShortlexVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    if a > b {\n        a = 1;\n        b = 0;\n    }\n    shortlex_vecs_from_length_iterator(primitive_int_increasing_range(a, b.saturating_add(1)), xs)\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\nstruct ExhaustiveVecsGenerator<Y: Clone, J: Clone + Iterator<Item = Y>> {\n    ys: J,\n}\n\nimpl<Y: Clone, J: Clone + Iterator<Item = Y>>\n    ExhaustiveDependentPairsYsGenerator<u64, Vec<Y>, ExhaustiveFixedLengthVecs1Input<J>>\n    for ExhaustiveVecsGenerator<Y, J>\n{\n    #[inline]\n    fn get_ys(&self, &x: &u64) -> ExhaustiveFixedLengthVecs1Input<J> {\n        exhaustive_vecs_fixed_length_1_input(\n            self.ys.clone(),\n            &vec![BitDistributorOutputType::normal(1); usize::exact_from(x)],\n        )\n    }\n}\n\n#[inline]\nconst fn exhaustive_vecs_from_element_iterator_helper<\n    T: Clone,\n    I: Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n) -> ExhaustiveDependentPairs<\n    u64,\n    Vec<T>,\n    RulerSequence<usize>,\n    ExhaustiveVecsGenerator<T, J>,\n    I,\n    ExhaustiveFixedLengthVecs1Input<J>,\n> {\n    exhaustive_dependent_pairs_stop_after_empty_ys(\n        ruler_sequence(),\n        xs,\n        ExhaustiveVecsGenerator { ys },\n    )\n}\n\n/// Generates all [`Vec`]s with elements from a specified iterator and with lengths from another\n/// iterator.\n#[derive(Clone, Debug)]\npub struct ExhaustiveVecs<T: Clone, I: Iterator<Item = u64>, J: Clone + Iterator<Item = T>>(\n    ExhaustiveDependentPairs<\n        u64,\n        Vec<T>,\n        RulerSequence<usize>,\n        ExhaustiveVecsGenerator<T, J>,\n        I,\n        ExhaustiveFixedLengthVecs1Input<J>,\n    >,\n);\n\nimpl<T: Clone, I: Iterator<Item = u64>, J: Clone + Iterator<Item = T>> Iterator\n    for ExhaustiveVecs<T, I, J>\n{\n    type Item = Vec<T>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<T>> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all [`Vec`]s with elements from a specified iterator and with lengths from another\n/// iterator.\n///\n/// The length-generating iterator is `xs`, and the element-generating iterator is `ys`.\n///\n/// If the lengths iterator has repetitions, then the generated [`Vec`]s will be repeated too.\n///\n/// There's one quirk if `ys` is empty: then the iterator will stop at some point after it\n/// encounters a nonzero $\\ell$, even if there are zeros later on. This prevents the iterator\n/// hanging when given an empty `ys` and lengths $0, 1, 2, \\ldots$.\n///\n/// - If `ys` is empty, the output length is finite.\n/// - If `ys` is infinite, the output length is infinite.\n/// - If `ys` is nonempty and finite, and `xs` is infinite, the output is infinite.\n/// - If `ys` is nonempty and finite, and `xs` is finite, the output length is\n///   $$\n///   \\sum_{k=0}^{m-1} n^{\\ell_k},\n///   $$\n///   where $n$ is `ys.count()` and $m$ is `xs.count()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::bools::exhaustive::exhaustive_bools;\n/// use malachite_base::nevers::nevers;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_from_length_iterator;\n///\n/// let xss = exhaustive_vecs_from_length_iterator([2, 1, 2].iter().cloned(), exhaustive_bools())\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[false, false][..],\n///         &[false],\n///         &[false, true],\n///         &[false, false],\n///         &[true, false],\n///         &[true],\n///         &[true, true],\n///         &[false, true],\n///         &[true, false],\n///         &[true, true]\n///     ]\n/// );\n///\n/// let xss =\n///     exhaustive_vecs_from_length_iterator([0, 0, 1, 0].iter().cloned(), nevers()).collect_vec();\n/// // Stops at some point after first empty ys\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[&[], &[]]\n/// );\n/// ```\n#[inline]\npub const fn exhaustive_vecs_from_length_iterator<\n    T: Clone,\n    I: Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    lengths: I,\n    xs: J,\n) -> ExhaustiveVecs<T, I, J> {\n    ExhaustiveVecs(exhaustive_vecs_from_element_iterator_helper(lengths, xs))\n}\n\n/// Generates all [`Vec`]s with elements from a specified iterator.\n///\n/// If `xs` is empty, the output length is 1; otherwise, the output is infinite.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_unsigneds;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs;\n///\n/// let xss = exhaustive_vecs(exhaustive_unsigneds::<u32>())\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[0],\n///         &[1],\n///         &[0, 0, 0],\n///         &[2],\n///         &[0, 0],\n///         &[3],\n///         &[0, 0, 0, 0],\n///         &[4],\n///         &[0, 1],\n///         &[5],\n///         &[0, 0, 1],\n///         &[6],\n///         &[1, 0],\n///         &[7],\n///         &[0, 0, 0, 0, 0],\n///         &[8],\n///         &[1, 1],\n///         &[9],\n///         &[0, 1, 0]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_vecs<I: Clone + Iterator>(\n    xs: I,\n) -> ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    exhaustive_vecs_from_length_iterator(exhaustive_unsigneds(), xs)\n}\n\n/// Generates all [`Vec`]s with a minimum length and with elements from a specified iterator.\n///\n/// If `xs` is empty and `min_length` is 0, the output length is 1; if `xs` is empty and\n/// `min_length` is greater than 0, the output is empty; otherwise, the output is infinite.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_unsigneds;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_min_length;\n///\n/// let xss = exhaustive_vecs_min_length(2, exhaustive_unsigneds::<u32>())\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[0, 0][..],\n///         &[0, 0, 0],\n///         &[0, 1],\n///         &[0, 0, 0, 0],\n///         &[1, 0],\n///         &[0, 0, 1],\n///         &[1, 1],\n///         &[0, 0, 0, 0, 0],\n///         &[0, 2],\n///         &[0, 1, 0],\n///         &[0, 3],\n///         &[0, 0, 0, 1],\n///         &[1, 2],\n///         &[0, 1, 1],\n///         &[1, 3],\n///         &[0, 0, 0, 0, 0, 0],\n///         &[2, 0],\n///         &[1, 0, 0],\n///         &[2, 1],\n///         &[0, 0, 1, 0]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_vecs_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    exhaustive_vecs_from_length_iterator(\n        primitive_int_increasing_inclusive_range(min_length, u64::MAX),\n        xs,\n    )\n}\n\n/// Generates all [`Vec`]s with lengths in $[a, b)$ and with elements from a specified iterator.\n///\n/// - If $a \\geq b$, the output length is 0.\n/// - If $a = 0$ and $b = 1$, the output length is 1.\n/// - If $a < b$, $b > 1$, and `xs` is infinite, the output length is infinite.\n/// - If `xs` is finite, the output length is\n///   $$\n///   \\sum_{k=a}^{b-1} n^k,\n///   $$\n///   where $k$ is `xs.count()`.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_unsigneds;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_length_range;\n///\n/// let xss = exhaustive_vecs_length_range(2, 4, exhaustive_unsigneds::<u32>())\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[0, 0][..],\n///         &[0, 0, 0],\n///         &[0, 1],\n///         &[1, 0],\n///         &[1, 1],\n///         &[0, 0, 1],\n///         &[0, 2],\n///         &[0, 1, 0],\n///         &[0, 3],\n///         &[0, 1, 1],\n///         &[1, 2],\n///         &[1, 3],\n///         &[2, 0],\n///         &[1, 0, 0],\n///         &[2, 1],\n///         &[3, 0],\n///         &[3, 1],\n///         &[1, 0, 1],\n///         &[2, 2],\n///         &[2, 3]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_vecs_length_range<I: Clone + Iterator>(\n    a: u64,\n    mut b: u64,\n    xs: I,\n) -> ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    if a > b {\n        b = a;\n    }\n    exhaustive_vecs_from_length_iterator(primitive_int_increasing_range(a, b), xs)\n}\n\n/// Generates all [`Vec`]s with lengths in $[a, b]$ and with elements from a specified iterator.\n///\n/// - If $a > b$, the output length is 0.\n/// - If $a = b = 0$, the output length is 1.\n/// - If $a < b$, $b > 0$, and `xs` is infinite, the output length is infinite.\n/// - If `xs` is finite, the output length is\n///   $$\n///   \\sum_{k=a}^b n^k,\n///   $$\n///   where $k$ is `xs.count()`.\n///\n/// The lengths of the output [`Vec`]s grow logarithmically.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::exhaustive::exhaustive_unsigneds;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_length_inclusive_range;\n///\n/// let xss = exhaustive_vecs_length_inclusive_range(2, 4, exhaustive_unsigneds::<u32>())\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[0, 0][..],\n///         &[0, 0, 0],\n///         &[0, 1],\n///         &[0, 0, 0, 0],\n///         &[1, 0],\n///         &[0, 0, 1],\n///         &[1, 1],\n///         &[0, 2],\n///         &[0, 3],\n///         &[0, 1, 0],\n///         &[1, 2],\n///         &[0, 0, 0, 1],\n///         &[1, 3],\n///         &[0, 1, 1],\n///         &[2, 0],\n///         &[1, 0, 0],\n///         &[2, 1],\n///         &[1, 0, 1],\n///         &[3, 0],\n///         &[0, 0, 1, 0]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_vecs_length_inclusive_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I>\nwhere\n    I::Item: Clone,\n{\n    if a > b {\n        a = 1;\n        b = 0;\n    }\n    exhaustive_vecs_from_length_iterator(primitive_int_increasing_range(a, b.saturating_add(1)), xs)\n}\n\n/// Generates all collections of elements from an iterator, where the collections are of a fixed\n/// length, have no repetitions, and are ordered the same way as in the iterator.\n#[derive(Clone, Debug)]\npub struct LexFixedLengthOrderedUniqueCollections<I: Iterator, C: FromIterator<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    first: bool,\n    done: bool,\n    xs: IteratorCache<I>,\n    indices: Vec<usize>,\n    phantom: PhantomData<(I::Item, C)>,\n}\n\nimpl<I: Iterator, C: FromIterator<I::Item>> LexFixedLengthOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    pub fn new(k: u64, xs: I) -> Self {\n        Self {\n            first: true,\n            done: false,\n            xs: IteratorCache::new(xs),\n            indices: (0..usize::exact_from(k)).collect(),\n            phantom: PhantomData,\n        }\n    }\n}\n\n#[doc(hidden)]\npub fn fixed_length_ordered_unique_indices_helper(\n    n: usize,\n    k: usize,\n    indices: &mut [usize],\n) -> bool {\n    let mut expected_j = n - 1;\n    let mut i = k - 1;\n    // Find longest suffix of the form [..., n - 3, n - 2, n - 1]. After this loop, i is the index\n    // right before this longest suffix.\n    loop {\n        if expected_j != indices[i] {\n            break;\n        }\n        if i == 0 {\n            return true;\n        }\n        i -= 1;\n        expected_j -= 1;\n    }\n    let mut j = indices[i] + 1;\n    for index in &mut indices[i..] {\n        *index = j;\n        j += 1;\n    }\n    false\n}\n\nimpl<I: Iterator, C: FromIterator<I::Item>> Iterator\n    for LexFixedLengthOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    type Item = C;\n\n    fn next(&mut self) -> Option<C> {\n        if self.done {\n            return None;\n        }\n        let k = self.indices.len();\n        if self.first {\n            self.first = false;\n            self.xs.get(k);\n            if let Some(n) = self.xs.known_len()\n                && n < k\n            {\n                self.done = true;\n                return None;\n            }\n        } else {\n            if k == 0 {\n                self.done = true;\n                return None;\n            }\n            if let Some(n) = self.xs.known_len() {\n                if fixed_length_ordered_unique_indices_helper(n, k, &mut self.indices) {\n                    self.done = true;\n                    return None;\n                }\n            } else {\n                *self.indices.last_mut().unwrap() += 1;\n            }\n        }\n        if let Some(&last_index) = self.indices.last() {\n            // Give known len a chance to be set\n            self.xs.get(last_index + 1);\n        }\n        Some(\n            self.indices\n                .iter()\n                .map(|&i| self.xs.assert_get(i).clone())\n                .collect(),\n        )\n    }\n}\n\n/// Generates [`Vec`]s of a given length with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the same way as\n/// they are in the source iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The order is lexicographic with respect to the order of the element iterator.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n///\n/// If $k$ is 0, the output consists of one empty [`Vec`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_fixed_length;\n///\n/// let xss = lex_ordered_unique_vecs_fixed_length(4, 1..=6).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2, 3, 4],\n///         &[1, 2, 3, 5],\n///         &[1, 2, 3, 6],\n///         &[1, 2, 4, 5],\n///         &[1, 2, 4, 6],\n///         &[1, 2, 5, 6],\n///         &[1, 3, 4, 5],\n///         &[1, 3, 4, 6],\n///         &[1, 3, 5, 6],\n///         &[1, 4, 5, 6],\n///         &[2, 3, 4, 5],\n///         &[2, 3, 4, 6],\n///         &[2, 3, 5, 6],\n///         &[2, 4, 5, 6],\n///         &[3, 4, 5, 6]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_ordered_unique_vecs_fixed_length<I: Iterator>(\n    k: u64,\n    xs: I,\n) -> LexFixedLengthOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    LexFixedLengthOrderedUniqueCollections::new(k, xs)\n}\n\n/// Generates all collections of elements from an iterator in shortlex order, where the collections\n/// have no repetitions and are ordered the same way as in the iterator.\n#[derive(Clone)]\npub struct ShortlexOrderedUniqueCollections<I: Clone + Iterator, C: FromIterator<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    current_len: u64,\n    max_len: u64,\n    xs: I,\n    current_xss: LexFixedLengthOrderedUniqueCollections<I, C>,\n}\n\nimpl<I: Clone + Iterator, C: FromIterator<I::Item>> ShortlexOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    pub(crate) fn new(a: u64, b: u64, xs: I) -> Self {\n        Self {\n            current_len: a,\n            max_len: b,\n            xs: xs.clone(),\n            current_xss: LexFixedLengthOrderedUniqueCollections::new(a, xs),\n        }\n    }\n}\n\nimpl<I: Clone + Iterator, C: FromIterator<I::Item>> Iterator\n    for ShortlexOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    type Item = C;\n\n    fn next(&mut self) -> Option<C> {\n        if self.current_len > self.max_len {\n            return None;\n        }\n        if let Some(next) = self.current_xss.next() {\n            Some(next)\n        } else {\n            self.current_len += 1;\n            if self.current_len > self.max_len {\n                return None;\n            }\n            self.current_xss = LexFixedLengthOrderedUniqueCollections {\n                first: true,\n                done: false,\n                xs: IteratorCache::new(self.xs.clone()),\n                indices: (0..usize::exact_from(self.current_len)).collect(),\n                phantom: PhantomData,\n            };\n            if let Some(next) = self.current_xss.next() {\n                Some(next)\n            } else {\n                // Prevent any further iteration\n                self.max_len = 0;\n                self.current_len = 1;\n                None\n            }\n        }\n    }\n}\n\n/// Generates [`Vec`]s with elements from a single iterator, such that each [`Vec`] has no repeated\n/// elements, and the elements in each [`Vec`] are ordered the same way as they are in the source\n/// iterator.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length 2 and above will never be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`Vec`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs;\n///\n/// let xss = shortlex_ordered_unique_vecs(1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[1],\n///         &[2],\n///         &[3],\n///         &[4],\n///         &[1, 2],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 4],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4],\n///         &[1, 2, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_ordered_unique_vecs<I: Clone + Iterator>(\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    shortlex_ordered_unique_vecs_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s with a mininum length, with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the same way as\n/// they are in the source iterator.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length `\\max(2, \\ell + 1)` and\n/// above will never be generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs_min_length;\n///\n/// let xss = shortlex_ordered_unique_vecs_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 4],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4],\n///         &[1, 2, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_ordered_unique_vecs_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    shortlex_ordered_unique_vecs_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b)$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the\n/// same way as they are in the source iterator.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length `\\max(2, a + 1)` and above\n/// will never be generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^{b - 1} \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs_length_range;\n///\n/// let xss = shortlex_ordered_unique_vecs_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 4],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4],\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_ordered_unique_vecs_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    shortlex_ordered_unique_vecs_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b]$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the\n/// same way as they are in the source iterator.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length `\\max(2, a + 1)` and above\n/// will never be generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs_length_inclusive_range;\n///\n/// let xss = shortlex_ordered_unique_vecs_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 4],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4],\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_ordered_unique_vecs_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ShortlexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    ShortlexOrderedUniqueCollections::new(a, b, xs)\n}\n\n/// Generates all collections of elements from an iterator in lexicographic order, where the\n/// collections have no repetitions and are ordered the same way as in the iterator.\n#[derive(Clone, Debug)]\npub struct LexOrderedUniqueCollections<I: Iterator, C: FromIterator<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    done: bool,\n    first: bool,\n    min_len: usize,\n    max_len: usize,\n    xs: IteratorCache<I>,\n    indices: Vec<usize>,\n    phantom: PhantomData<(I::Item, C)>,\n}\n\nimpl<I: Iterator, C: FromIterator<I::Item>> LexOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    pub(crate) fn new(a: u64, b: u64, xs: I) -> Self {\n        Self {\n            done: a > b,\n            first: true,\n            min_len: usize::exact_from(a),\n            max_len: usize::exact_from(b),\n            xs: IteratorCache::new(xs),\n            indices: (0..usize::exact_from(a)).collect(),\n            phantom: PhantomData,\n        }\n    }\n}\n\nimpl<I: Iterator, C: FromIterator<I::Item>> Iterator for LexOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    type Item = C;\n\n    fn next(&mut self) -> Option<C> {\n        if self.done {\n            return None;\n        }\n        let k = self.indices.len();\n        if self.first {\n            self.first = false;\n            self.xs.get(k);\n            if let Some(n) = self.xs.known_len()\n                && n < k\n            {\n                self.done = true;\n                return None;\n            }\n        } else if k == 0 {\n            if self.xs.get(0).is_none() {\n                self.done = true;\n                return None;\n            }\n            self.indices.push(0);\n        } else {\n            let last_i = *self.indices.last().unwrap();\n            let next_i = last_i + 1;\n            if k < self.max_len && self.xs.get(next_i).is_some() {\n                // For example, if xs is [0, 1, 2, 3] and max_len is 4, then the next set of indices\n                // after [0, 1] is [0, 1, 2].\n                self.indices.push(next_i);\n            } else if k == self.min_len {\n                // For example, if xs is [0, 1, 2, 3] and min_len is 2, then the next set of indices\n                // after [1, 3] is [2, 3].\n                if let Some(n) = self.xs.known_len() {\n                    if fixed_length_ordered_unique_indices_helper(n, k, &mut self.indices) {\n                        self.done = true;\n                        return None;\n                    }\n                } else {\n                    *self.indices.last_mut().unwrap() += 1;\n                }\n            } else if self.xs.get(next_i).is_some() {\n                // For example, if xs is [0, 1, 2, 3] and max_len is 3, then the next set of indices\n                // after [1, 2, 3] is [1, 2, 4].\n                *self.indices.last_mut().unwrap() = next_i;\n            } else {\n                let x = self.indices.pop();\n                if let Some(last) = self.indices.last_mut() {\n                    // For example, if xs is [0, 1, 2, 3] and max_len is 3, then the next set of\n                    // indices after [0, 1, 2] is [0, 1, 3].\n                    *last += 1;\n                } else {\n                    let next_x = x.unwrap() + 1;\n                    if self.xs.get(next_x).is_none() {\n                        // For example, if xs is [0, 1, 2, 3], then nothing comes after the indices\n                        // [3].\n                        self.done = true;\n                        return None;\n                    }\n                    // For example, if xs is [0, 1, 2, 3] and max_len is 1, then the next set of\n                    // indices after [0] is [1].\n                    self.indices.push(next_x);\n                }\n            }\n        }\n        if let Some(&last_index) = self.indices.last() {\n            // Give known len a chance to be set\n            self.xs.get(last_index + 1);\n        }\n        Some(\n            self.indices\n                .iter()\n                .map(|&i| self.xs.assert_get(i).clone())\n                .collect(),\n        )\n    }\n}\n\n/// Generates [`Vec`]s with elements from a single iterator, such that each [`Vec`] has no repeated\n/// elements, and the elements in each [`Vec`] are ordered the same way as they are in the source\n/// iterator.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`Vec`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_ordered_unique_vecs;\n///\n/// let xss = lex_ordered_unique_vecs(1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[1],\n///         &[1, 2],\n///         &[1, 2, 3],\n///         &[1, 2, 3, 4],\n///         &[1, 2, 4],\n///         &[1, 3],\n///         &[1, 3, 4],\n///         &[1, 4],\n///         &[2],\n///         &[2, 3],\n///         &[2, 3, 4],\n///         &[2, 4],\n///         &[3],\n///         &[3, 4],\n///         &[4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_ordered_unique_vecs<I: Clone + Iterator>(\n    xs: I,\n) -> LexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    lex_ordered_unique_vecs_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s with a mininum length, with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the same way as\n/// they are in the source iterator.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_min_length;\n///\n/// let xss = lex_ordered_unique_vecs_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 2, 3],\n///         &[1, 2, 3, 4],\n///         &[1, 2, 4],\n///         &[1, 3],\n///         &[1, 3, 4],\n///         &[1, 4],\n///         &[2, 3],\n///         &[2, 3, 4],\n///         &[2, 4],\n///         &[3, 4],\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_ordered_unique_vecs_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    lex_ordered_unique_vecs_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b)$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the\n/// same way as they are in the source iterator.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^{b - 1} \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_length_range;\n///\n/// let xss = lex_ordered_unique_vecs_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3],\n///         &[1, 3, 4],\n///         &[1, 4],\n///         &[2, 3],\n///         &[2, 3, 4],\n///         &[2, 4],\n///         &[3, 4],\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_ordered_unique_vecs_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    lex_ordered_unique_vecs_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b]$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the\n/// same way as they are in the source iterator.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_length_inclusive_range;\n///\n/// let xss = lex_ordered_unique_vecs_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3],\n///         &[1, 3, 4],\n///         &[1, 4],\n///         &[2, 3],\n///         &[2, 3, 4],\n///         &[2, 4],\n///         &[3, 4],\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_ordered_unique_vecs_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> LexOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    LexOrderedUniqueCollections::new(a, b, xs)\n}\n\n/// This function is used for iterating through all bit patterns with a specified number of minimum\n/// and maximum `true` bits.\n///\n/// Given an existing bit pattern, and a reference `bit_count`, which must equal the number of\n/// `true`s in the pattern, mutates the pattern into the next pattern with a valid number of `true`\n/// bits. See the unit tests for many examples.\n///\n/// # Worst-case complexity\n/// $$\n/// T(k) = O(k)\n/// $$\n///\n/// $$\n/// M(k) = O(k)\n/// $$\n///\n/// where $T$ is time, $M$ is additional memory, and $k$ is the length of `pattern`. The memory\n/// usage is only linear when the pattern vector needs to be reallocated, which happens rarely.\n///\n/// # Panics\n/// Panics if `max_bits` is zero. (However, `min_bits` may be zero.)\n///\n/// # Examples\n/// ```\n/// use malachite_base::vecs::exhaustive::next_bit_pattern;\n///\n/// // Suppose we are generating all bit patterns with 2 to 4 true bits, inclusive. Suppose our\n/// // current pattern is `1111000`. Then, the lexicographically next largest valid pattern is\n/// // `10000001`. (All patterns of the form `1111xxx`, where the `x`s are not all zero, have too\n/// // many ones. That brings us to `10000000`, which has too few ones, and then `10000001`.)\n/// //\n/// // The patterns are represented \"in reverse\", with least-significant bits appearing first.\n/// let mut pattern = vec![false, false, false, true, true, true, true];\n/// let mut bit_count = 4;\n/// next_bit_pattern(&mut pattern, &mut bit_count, 2, 4);\n/// assert_eq!(\n///     pattern,\n///     &[true, false, false, false, false, false, false, true]\n/// );\n/// assert_eq!(bit_count, 2);\n/// ```\npub fn next_bit_pattern(\n    pattern: &mut Vec<bool>,\n    bit_count: &mut usize,\n    min_bits: usize,\n    max_bits: usize,\n) {\n    assert_ne!(max_bits, 0);\n    match pattern.first() {\n        None => {\n            pattern.push(true);\n            *bit_count = 1;\n        }\n        Some(&false) => {\n            if *bit_count < max_bits {\n                pattern[0] = true;\n                *bit_count += 1;\n            } else {\n                let leading_false_count = pattern.iter().take_while(|&&b| !b).count();\n                let true_after_false_count = pattern[leading_false_count..]\n                    .iter()\n                    .take_while(|&&b| b)\n                    .count();\n                let tf_count = leading_false_count + true_after_false_count;\n                if tf_count == pattern.len() {\n                    for b in &mut *pattern {\n                        *b = false;\n                    }\n                    pattern.push(true);\n                    *bit_count = 1;\n                } else {\n                    for b in &mut pattern[leading_false_count..tf_count] {\n                        *b = false;\n                    }\n                    pattern[tf_count] = true;\n                    *bit_count -= true_after_false_count - 1;\n                }\n                if *bit_count < min_bits {\n                    let diff = min_bits - *bit_count;\n                    for b in &mut pattern[..diff] {\n                        *b = true;\n                    }\n                    *bit_count += diff;\n                }\n            }\n        }\n        Some(&true) => {\n            let leading_true_count = pattern.iter().take_while(|&&b| b).count();\n            for b in &mut pattern[..leading_true_count] {\n                *b = false;\n            }\n            if leading_true_count == pattern.len() {\n                pattern.push(true);\n            } else {\n                pattern[leading_true_count] = true;\n            }\n            *bit_count -= leading_true_count - 1;\n            if *bit_count < min_bits {\n                let diff = min_bits - *bit_count;\n                for b in &mut pattern[..diff] {\n                    *b = true;\n                }\n                *bit_count += diff;\n            }\n        }\n    }\n}\n\n#[derive(Clone)]\n#[doc(hidden)]\npub struct ExhaustiveOrderedUniqueCollectionsGreaterThanOne<I: Iterator, C: FromIterator<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    done: bool,\n    first: bool,\n    min_bits: usize,\n    max_bits: usize,\n    xs: IteratorCache<I>,\n    pattern: Vec<bool>,\n    bit_count: usize,\n    phantom: PhantomData<*const C>,\n}\n\nimpl<I: Iterator, C: FromIterator<I::Item>> Iterator\n    for ExhaustiveOrderedUniqueCollectionsGreaterThanOne<I, C>\nwhere\n    I::Item: Clone,\n{\n    type Item = C;\n\n    fn next(&mut self) -> Option<C> {\n        if self.done {\n            return None;\n        } else if self.first {\n            self.first = false;\n        } else {\n            next_bit_pattern(\n                &mut self.pattern,\n                &mut self.bit_count,\n                self.min_bits,\n                self.max_bits,\n            );\n        }\n        if !self.pattern.is_empty() && self.xs.get(self.pattern.len() - 1).is_none() {\n            self.done = true;\n            return None;\n        }\n        Some(\n            self.pattern\n                .iter()\n                .enumerate()\n                .filter_map(|(i, &b)| {\n                    if b {\n                        Some(self.xs.assert_get(i).clone())\n                    } else {\n                        None\n                    }\n                })\n                .collect(),\n        )\n    }\n}\n\n/// Generates all collections of elements from an iterator, where the collections have no\n/// repetitions and are ordered the same way as in the iterator.\n#[derive(Clone)]\npub enum ExhaustiveOrderedUniqueCollections<I: Iterator, C: FromIterator<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    None,\n    Zero(bool),\n    ZeroOne(bool, I),\n    One(I),\n    GreaterThanOne(ExhaustiveOrderedUniqueCollectionsGreaterThanOne<I, C>),\n}\n\nimpl<I: Iterator, C: FromIterator<I::Item>> ExhaustiveOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    pub(crate) fn new(a: u64, b: u64, xs: I) -> Self {\n        match (a, b) {\n            (a, b) if a > b => Self::None,\n            (0, 0) => Self::Zero(false),\n            (0, 1) => Self::ZeroOne(true, xs),\n            (1, 1) => Self::One(xs),\n            (a, b) => Self::GreaterThanOne(ExhaustiveOrderedUniqueCollectionsGreaterThanOne {\n                done: false,\n                first: true,\n                min_bits: usize::saturating_from(a),\n                max_bits: usize::saturating_from(b),\n                xs: IteratorCache::new(xs),\n                pattern: vec![true; usize::saturating_from(a)],\n                bit_count: usize::saturating_from(a),\n                phantom: PhantomData,\n            }),\n        }\n    }\n}\n\nimpl<I: Iterator, C: FromIterator<I::Item>> Iterator for ExhaustiveOrderedUniqueCollections<I, C>\nwhere\n    I::Item: Clone,\n{\n    type Item = C;\n\n    fn next(&mut self) -> Option<C> {\n        match self {\n            Self::None => None,\n            Self::Zero(done) => {\n                if *done {\n                    None\n                } else {\n                    *done = true;\n                    Some(empty().collect())\n                }\n            }\n            Self::ZeroOne(first, xs) => {\n                if *first {\n                    *first = false;\n                    Some(empty().collect())\n                } else {\n                    xs.next().map(|x| once(x).collect())\n                }\n            }\n            Self::One(xs) => xs.next().map(|x| once(x).collect()),\n            Self::GreaterThanOne(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates [`Vec`]s of a given length with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the same way as\n/// they are in the source iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is $\\binom{n}{k}$.\n///\n/// If $k$ is 0, the output consists of one empty [`Vec`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_fixed_length;\n///\n/// let xss = exhaustive_ordered_unique_vecs_fixed_length(4, 1..=6).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2, 3, 4],\n///         &[1, 2, 3, 5],\n///         &[1, 2, 4, 5],\n///         &[1, 3, 4, 5],\n///         &[2, 3, 4, 5],\n///         &[1, 2, 3, 6],\n///         &[1, 2, 4, 6],\n///         &[1, 3, 4, 6],\n///         &[2, 3, 4, 6],\n///         &[1, 2, 5, 6],\n///         &[1, 3, 5, 6],\n///         &[2, 3, 5, 6],\n///         &[1, 4, 5, 6],\n///         &[2, 4, 5, 6],\n///         &[3, 4, 5, 6]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_ordered_unique_vecs_fixed_length<I: Iterator>(\n    k: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    exhaustive_ordered_unique_vecs_length_inclusive_range(k, k, xs)\n}\n\n/// Generates [`Vec`]s with elements from a single iterator, such that each [`Vec`] has no repeated\n/// elements, and the elements in each [`Vec`] are ordered the same way as they are in the source\n/// iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is $2^n$.\n///\n/// If `xs` is empty, the output consists of a single empty [`Vec`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs;\n///\n/// let xss = exhaustive_ordered_unique_vecs(1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[1],\n///         &[2],\n///         &[1, 2],\n///         &[3],\n///         &[1, 3],\n///         &[2, 3],\n///         &[1, 2, 3],\n///         &[4],\n///         &[1, 4],\n///         &[2, 4],\n///         &[1, 2, 4],\n///         &[3, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4],\n///         &[1, 2, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_ordered_unique_vecs<I: Iterator>(\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    exhaustive_ordered_unique_vecs_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s with a mininum length, with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the same way as\n/// they are in the source iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_min_length;\n///\n/// let xss = exhaustive_ordered_unique_vecs_min_length(2, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[2, 3],\n///         &[1, 2, 3],\n///         &[1, 4],\n///         &[2, 4],\n///         &[1, 2, 4],\n///         &[3, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4],\n///         &[1, 2, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_ordered_unique_vecs_min_length<I: Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    exhaustive_ordered_unique_vecs_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b)$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the\n/// same way as they are in the source iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^{b - 1} \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_length_range;\n///\n/// let xss = exhaustive_ordered_unique_vecs_length_range(2, 4, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[2, 3],\n///         &[1, 2, 3],\n///         &[1, 4],\n///         &[2, 4],\n///         &[1, 2, 4],\n///         &[3, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_ordered_unique_vecs_length_range<I: Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    if a >= b {\n        ExhaustiveOrderedUniqueCollections::None\n    } else {\n        exhaustive_ordered_unique_vecs_length_inclusive_range(a, b - 1, xs)\n    }\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b]$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements, and the elements in each [`Vec`] are ordered the\n/// same way as they are in the source iterator.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\binom{n}{i}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_length_inclusive_range;\n///\n/// let xss = exhaustive_ordered_unique_vecs_length_inclusive_range(2, 3, 1..=4).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[2, 3],\n///         &[1, 2, 3],\n///         &[1, 4],\n///         &[2, 4],\n///         &[1, 2, 4],\n///         &[3, 4],\n///         &[1, 3, 4],\n///         &[2, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_ordered_unique_vecs_length_inclusive_range<I: Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveOrderedUniqueCollections::new(a, b, xs)\n}\n\nfn fixed_length_unique_indices_helper(indices: &mut [usize], used: &mut [bool]) -> bool {\n    let n = used.len();\n    let k = indices.len();\n    assert!(k <= n);\n    for i in (0..k).rev() {\n        let x = indices[i];\n        used[x] = false;\n        for y in x + 1..n {\n            if !used[y] {\n                indices[i] = y;\n                used[y] = true;\n                let mut p = 0;\n                for j in &mut indices[i + 1..k] {\n                    while used[p] {\n                        p += 1;\n                    }\n                    *j = p;\n                    used[p] = true;\n                }\n                return false;\n            }\n        }\n    }\n    true\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct UniqueIndices {\n    pub done: bool,\n    first: bool,\n    indices: Vec<usize>,\n    pub used: Vec<bool>,\n}\n\nimpl UniqueIndices {\n    #[doc(hidden)]\n    pub const fn get_n(&self) -> usize {\n        self.used.len()\n    }\n\n    #[doc(hidden)]\n    pub fn increment_n(&mut self) {\n        self.used.push(false);\n    }\n}\n\nimpl Iterator for UniqueIndices {\n    type Item = Vec<usize>;\n\n    fn next(&mut self) -> Option<Vec<usize>> {\n        if self.done {\n            None\n        } else if self.first {\n            self.first = false;\n            Some(self.indices.clone())\n        } else if fixed_length_unique_indices_helper(&mut self.indices, &mut self.used) {\n            self.done = true;\n            None\n        } else {\n            Some(self.indices.clone())\n        }\n    }\n}\n\n#[doc(hidden)]\npub fn unique_indices(n: usize, k: usize) -> UniqueIndices {\n    UniqueIndices {\n        done: n == 0 && k != 0,\n        first: true,\n        indices: (0..k).collect_vec(),\n        used: repeat_n(true, k)\n            .chain(repeat_n(false, n - k))\n            .collect_vec(),\n    }\n}\n\n/// Generates all [`Vec`]s of elements from an iterator, where the [`Vec`]s are of a fixed length\n/// and have no repetitions.\n#[derive(Clone)]\npub struct LexUniqueVecsFixedLength<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    first: bool,\n    xs: IteratorCache<I>,\n    indices: UniqueIndices,\n}\n\nimpl<I: Iterator> Iterator for LexUniqueVecsFixedLength<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Self::Item> {\n        if self.first {\n            if !self.indices.used.is_empty() && self.xs.get(self.indices.get_n() - 1).is_none() {\n                self.indices.done = true;\n            }\n            self.first = false;\n        }\n        if self.xs.get(self.indices.get_n()).is_some() {\n            self.indices.increment_n();\n        }\n        self.indices.next().map(|indices| {\n            indices\n                .into_iter()\n                .map(|i| self.xs.assert_get(i).clone())\n                .collect_vec()\n        })\n    }\n}\n\n/// Generates [`Vec`]s of a given length with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The order is lexicographic with respect to the order of the element iterator.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is\n/// $$\n/// (n)_ k = \\prod_ {i=0}^{k-1}(n - i) = frac{n!}{(n-k)!}.\n/// $$\n///\n/// If $k$ is 0, the output consists of one empty [`Vec`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_unique_vecs_fixed_length;\n///\n/// let xss = lex_unique_vecs_fixed_length(4, 1..=6)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2, 3, 4],\n///         &[1, 2, 3, 5],\n///         &[1, 2, 3, 6],\n///         &[1, 2, 4, 3],\n///         &[1, 2, 4, 5],\n///         &[1, 2, 4, 6],\n///         &[1, 2, 5, 3],\n///         &[1, 2, 5, 4],\n///         &[1, 2, 5, 6],\n///         &[1, 2, 6, 3],\n///         &[1, 2, 6, 4],\n///         &[1, 2, 6, 5],\n///         &[1, 3, 2, 4],\n///         &[1, 3, 2, 5],\n///         &[1, 3, 2, 6],\n///         &[1, 3, 4, 2],\n///         &[1, 3, 4, 5],\n///         &[1, 3, 4, 6],\n///         &[1, 3, 5, 2],\n///         &[1, 3, 5, 4],\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_unique_vecs_fixed_length<I: Iterator>(k: u64, xs: I) -> LexUniqueVecsFixedLength<I>\nwhere\n    I::Item: Clone,\n{\n    let k = usize::exact_from(k);\n    LexUniqueVecsFixedLength {\n        first: true,\n        xs: IteratorCache::new(xs),\n        // Initial n is k, but will grow to reach actual n (or forever, if n is infinite)\n        indices: unique_indices(k, k),\n    }\n}\n\n/// Generates all [`Vec`]s of elements from an iterator in shortlex order, where the [`Vec`]s have\n/// no repetitions.\n#[derive(Clone)]\npub struct ShortlexUniqueVecs<I: Clone + Iterator>\nwhere\n    I::Item: Clone,\n{\n    current_len: u64,\n    max_len: u64,\n    xs: I,\n    current_xss: LexUniqueVecsFixedLength<I>,\n}\n\nimpl<I: Clone + Iterator> ShortlexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    fn new(a: u64, b: u64, xs: I) -> Self {\n        Self {\n            current_len: a,\n            max_len: b,\n            xs: xs.clone(),\n            current_xss: lex_unique_vecs_fixed_length(a, xs),\n        }\n    }\n}\n\nimpl<I: Clone + Iterator> Iterator for ShortlexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        if self.current_len > self.max_len {\n            return None;\n        }\n        if let Some(next) = self.current_xss.next() {\n            Some(next)\n        } else {\n            self.current_len += 1;\n            if self.current_len > self.max_len {\n                return None;\n            }\n            self.current_xss = lex_unique_vecs_fixed_length(self.current_len, self.xs.clone());\n            if let Some(next) = self.current_xss.next() {\n                Some(next)\n            } else {\n                // Prevent any further iteration\n                self.max_len = 0;\n                self.current_len = 1;\n                None\n            }\n        }\n    }\n}\n\n/// Generates [`Vec`]s with elements from a single iterator, such that each [`Vec`] has no repeated\n/// elements.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length 2 and above will never be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_ {k=0}^n \\frac{n!}{k!}\n/// $$\n/// $$\n/// = \\\\begin{cases}\n///     1 & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     2 & \\text{if} \\\\quad n = 1, \\\\\\\\\n///     \\operatorname{round}(en!) & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// See <https://oeis.org/A000522>.\n///\n/// If `xs` is empty, the output consists of a single empty [`Vec`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_unique_vecs;\n///\n/// let xss = shortlex_unique_vecs(1..=4).take(20).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[1],\n///         &[2],\n///         &[3],\n///         &[4],\n///         &[1, 2],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 1],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 1],\n///         &[3, 2],\n///         &[3, 4],\n///         &[4, 1],\n///         &[4, 2],\n///         &[4, 3],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 2]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_unique_vecs<I: Clone + Iterator>(xs: I) -> ShortlexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    shortlex_unique_vecs_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s with a mininum length, with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length `\\max(2, \\ell + 1)` and\n/// above will never be generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_ {k=\\ell}^n \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_unique_vecs_min_length;\n///\n/// let xss = shortlex_unique_vecs_min_length(2, 1..=4)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 1],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 1],\n///         &[3, 2],\n///         &[3, 4],\n///         &[4, 1],\n///         &[4, 2],\n///         &[4, 3],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 2],\n///         &[1, 3, 4],\n///         &[1, 4, 2],\n///         &[1, 4, 3],\n///         &[2, 1, 3],\n///         &[2, 1, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_unique_vecs_min_length<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ShortlexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    shortlex_unique_vecs_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b)$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length `\\max(2, a + 1)` and above\n/// will never be generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^{b - 1} \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_unique_vecs_length_range;\n///\n/// let xss = shortlex_unique_vecs_length_range(2, 4, 1..=4)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 1],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 1],\n///         &[3, 2],\n///         &[3, 4],\n///         &[4, 1],\n///         &[4, 2],\n///         &[4, 3],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 2],\n///         &[1, 3, 4],\n///         &[1, 4, 2],\n///         &[1, 4, 3],\n///         &[2, 1, 3],\n///         &[2, 1, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_unique_vecs_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> ShortlexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    shortlex_unique_vecs_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b]$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements.\n///\n/// The [`Vec`]s are generated in order of increasing length, and within each length they are\n/// ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, [`Vec`]s of length `\\max(2, a + 1)` and above\n/// will never be generated.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::shortlex_unique_vecs_length_inclusive_range;\n///\n/// let xss = shortlex_unique_vecs_length_inclusive_range(2, 3, 1..=4)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[1, 4],\n///         &[2, 1],\n///         &[2, 3],\n///         &[2, 4],\n///         &[3, 1],\n///         &[3, 2],\n///         &[3, 4],\n///         &[4, 1],\n///         &[4, 2],\n///         &[4, 3],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 2],\n///         &[1, 3, 4],\n///         &[1, 4, 2],\n///         &[1, 4, 3],\n///         &[2, 1, 3],\n///         &[2, 1, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn shortlex_unique_vecs_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ShortlexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    ShortlexUniqueVecs::new(a, b, xs)\n}\n\nfn compare_indexed_vecs_lex<T>(xs: &[(usize, T)], ys: &[(usize, T)]) -> Ordering {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    for i in 0..min(xs_len, ys_len) {\n        let o = xs[i].0.cmp(&ys[i].0);\n        if o != Equal {\n            return o;\n        }\n    }\n    xs_len.cmp(&ys_len)\n}\n\n/// Generates all collections of elements from an iterator in lexicographic order, where the\n/// collections have no repetitions.\n#[derive(Clone)]\npub struct LexUniqueVecs<I: Clone + Iterator>\nwhere\n    I::Item: Clone,\n{\n    done: bool,\n    first: bool,\n    min: usize,\n    max: usize,\n    xs_for_prefix: I,\n    xs: I,\n    phase_1_vec: Option<Vec<I::Item>>,\n    xsss: Vec<LexUniqueVecsFixedLength<Zip<RangeFrom<usize>, I>>>,\n    next_xss: Vec<Option<Vec<(usize, I::Item)>>>,\n}\n\nimpl<I: Clone + Iterator> Iterator for LexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        if self.done {\n            return None;\n        }\n        if self.first {\n            self.first = false;\n            return self.phase_1_vec.clone();\n        }\n        if let Some(prefix) = self.phase_1_vec.as_mut()\n            && prefix.len() < self.max\n        {\n            if let Some(x) = self.xs_for_prefix.next() {\n                prefix.push(x);\n                return Some(prefix.clone());\n            }\n            self.max = prefix.len();\n        }\n        if self.phase_1_vec.is_some() {\n            for k in self.min..=self.max {\n                let mut xss =\n                    lex_unique_vecs_fixed_length(u64::exact_from(k), (0..).zip(self.xs.clone()));\n                // Skip over first Vec of length k, which was already generated in phase 1\n                xss.next();\n                self.next_xss.push(xss.next());\n                self.xsss.push(xss);\n            }\n            self.phase_1_vec = None;\n        }\n        let mut min_i = None;\n        let mut i_done = None;\n        for i in 0..self.next_xss.len() {\n            let choose = if let Some(xs) = &self.next_xss[i] {\n                if let Some(min_i) = min_i {\n                    let ys: &Option<Vec<(usize, I::Item)>> = &self.next_xss[min_i];\n                    compare_indexed_vecs_lex(xs, ys.as_ref().unwrap()) == Less\n                } else {\n                    true\n                }\n            } else {\n                i_done = Some(i);\n                false\n            };\n            if choose {\n                min_i = Some(i);\n            }\n        }\n        if let Some(i) = min_i {\n            self.next_xss.push(self.xsss[i].next());\n            let xs = self\n                .next_xss\n                .swap_remove(i)\n                .map(|xs| xs.into_iter().map(|p| p.1).collect());\n            if let Some(i_done) = i_done {\n                self.xsss.remove(i_done);\n                self.next_xss.remove(i_done);\n            }\n            xs\n        } else {\n            self.done = true;\n            None\n        }\n    }\n}\n\n/// Generates [`Vec`]s with elements from a single iterator, such that each [`Vec`] has no repeated\n/// elements.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_ {k=0}^n \\frac{n!}{k!}\n/// $$\n/// $$\n/// = \\\\begin{cases}\n///     1 & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     2 & \\text{if} \\\\quad n = 1, \\\\\\\\\n///     \\operatorname{round}(en!) & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// See <https://oeis.org/A000522>.\n///\n/// If `xs` is empty, the output consists of a single empty [`Vec`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_unique_vecs;\n///\n/// let xss = lex_unique_vecs(1..=4).take(20).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[1],\n///         &[1, 2],\n///         &[1, 2, 3],\n///         &[1, 2, 3, 4],\n///         &[1, 2, 4],\n///         &[1, 2, 4, 3],\n///         &[1, 3],\n///         &[1, 3, 2],\n///         &[1, 3, 2, 4],\n///         &[1, 3, 4],\n///         &[1, 3, 4, 2],\n///         &[1, 4],\n///         &[1, 4, 2],\n///         &[1, 4, 2, 3],\n///         &[1, 4, 3],\n///         &[1, 4, 3, 2],\n///         &[2],\n///         &[2, 1],\n///         &[2, 1, 3]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_unique_vecs<I: Clone + Iterator>(xs: I) -> LexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    lex_unique_vecs_length_inclusive_range(0, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s with a mininum length, with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_unique_vecs_min_length;\n///\n/// let xss = lex_unique_vecs_min_length(2, 1..=4).take(20).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 2, 3],\n///         &[1, 2, 3, 4],\n///         &[1, 2, 4],\n///         &[1, 2, 4, 3],\n///         &[1, 3],\n///         &[1, 3, 2],\n///         &[1, 3, 2, 4],\n///         &[1, 3, 4],\n///         &[1, 3, 4, 2],\n///         &[1, 4],\n///         &[1, 4, 2],\n///         &[1, 4, 2, 3],\n///         &[1, 4, 3],\n///         &[1, 4, 3, 2],\n///         &[2, 1],\n///         &[2, 1, 3],\n///         &[2, 1, 3, 4],\n///         &[2, 1, 4],\n///         &[2, 1, 4, 3]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_unique_vecs_min_length<I: Clone + Iterator>(min_length: u64, xs: I) -> LexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    lex_unique_vecs_length_inclusive_range(min_length, u64::MAX, xs)\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b)$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^{b - 1} \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_unique_vecs_length_range;\n///\n/// let xss = lex_unique_vecs_length_range(2, 4, 1..=4)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3],\n///         &[1, 3, 2],\n///         &[1, 3, 4],\n///         &[1, 4],\n///         &[1, 4, 2],\n///         &[1, 4, 3],\n///         &[2, 1],\n///         &[2, 1, 3],\n///         &[2, 1, 4],\n///         &[2, 3],\n///         &[2, 3, 1],\n///         &[2, 3, 4],\n///         &[2, 4],\n///         &[2, 4, 1],\n///         &[2, 4, 3],\n///         &[3, 1],\n///         &[3, 1, 2]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_unique_vecs_length_range<I: Clone + Iterator>(\n    mut a: u64,\n    mut b: u64,\n    xs: I,\n) -> LexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    if b == 0 {\n        // Transform an empty (x, 0) range into (2, 1), which is also empty but doesn't cause\n        // overflow\n        a = 2;\n        b = 1;\n    }\n    lex_unique_vecs_length_inclusive_range(a, b - 1, xs)\n}\n\n/// Generates [`Vec`]s with a mininum length, with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements.\n///\n/// The [`Vec`]s are ordered lexicographically with respect to the order of the element iterator.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// The iterator should be finite; if it is infinite, only prefixes of the iterator will be\n/// generated.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_{i=\\ell}^n \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_unique_vecs_min_length;\n///\n/// let xss = lex_unique_vecs_min_length(2, 1..=4).take(20).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 2, 3],\n///         &[1, 2, 3, 4],\n///         &[1, 2, 4],\n///         &[1, 2, 4, 3],\n///         &[1, 3],\n///         &[1, 3, 2],\n///         &[1, 3, 2, 4],\n///         &[1, 3, 4],\n///         &[1, 3, 4, 2],\n///         &[1, 4],\n///         &[1, 4, 2],\n///         &[1, 4, 2, 3],\n///         &[1, 4, 3],\n///         &[1, 4, 3, 2],\n///         &[2, 1],\n///         &[2, 1, 3],\n///         &[2, 1, 3, 4],\n///         &[2, 1, 4],\n///         &[2, 1, 4, 3]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn lex_unique_vecs_length_inclusive_range<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> LexUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    let a = usize::exact_from(a);\n    let b = usize::exact_from(b);\n    let mut xs_for_prefix = xs.clone();\n    let phase_1_vec = (&mut xs_for_prefix).take(a).collect_vec();\n    LexUniqueVecs {\n        done: a > b || phase_1_vec.len() < a,\n        first: true,\n        min: a,\n        max: b,\n        xs_for_prefix,\n        xs,\n        phase_1_vec: Some(phase_1_vec),\n        xsss: Vec::new(),\n        next_xss: Vec::new(),\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone)]\npub struct ExhaustiveUniqueVecs2<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    next: Option<(I::Item, I::Item)>,\n    ps: ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>,\n}\n\nimpl<I: Iterator> Iterator for ExhaustiveUniqueVecs2<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        if self.next.is_some() {\n            let (a, b) = take(&mut self.next).unwrap();\n            Some(vec![a, b])\n        } else if let Some(p) = self.ps.next() {\n            self.next = Some((p[1].clone(), p[0].clone()));\n            Some(p)\n        } else {\n            None\n        }\n    }\n}\n\nfn exhaustive_unique_vecs_2<I: Iterator>(xs: I) -> ExhaustiveUniqueVecs2<I>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveUniqueVecs2 {\n        next: None,\n        ps: exhaustive_ordered_unique_vecs_fixed_length(2, xs),\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct ExhaustiveUniqueVecsGenerator<T: Clone, I: Iterator<Item = T>> {\n    phantom: PhantomData<(T, I)>,\n}\n\nimpl<T: Clone, I: Iterator<Item = T>> ExhaustiveUniqueVecsGenerator<T, I> {\n    #[doc(hidden)]\n    #[inline]\n    pub const fn new() -> Self {\n        Self {\n            phantom: PhantomData,\n        }\n    }\n}\n\nimpl<T: Clone, I: Iterator<Item = T>>\n    ExhaustiveDependentPairsYsGenerator<Vec<T>, Vec<T>, ExhaustiveVecPermutations<T>>\n    for ExhaustiveUniqueVecsGenerator<T, I>\n{\n    #[inline]\n    fn get_ys(&self, xs: &Vec<T>) -> ExhaustiveVecPermutations<T> {\n        exhaustive_vec_permutations(xs.clone())\n    }\n}\n\n/// Generates all fixed-length [`Vec`]s of elements from an iterator, where the [`Vec`]s have no\n/// repetitions and are ordered the same way as in the iterator.\n#[derive(Clone)]\npub enum ExhaustiveUniqueVecsFixedLength<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    Zero(bool),\n    One(I),\n    Two(ExhaustiveUniqueVecs2<I>),\n    GreaterThanTwo(\n        ExhaustiveDependentPairs<\n            Vec<I::Item>,\n            Vec<I::Item>,\n            RulerSequence<usize>,\n            ExhaustiveUniqueVecsGenerator<I::Item, I>,\n            ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>,\n            ExhaustiveVecPermutations<I::Item>,\n        >,\n    ),\n}\n\nimpl<I: Iterator> Iterator for ExhaustiveUniqueVecsFixedLength<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        match self {\n            Self::Zero(done) => {\n                if *done {\n                    None\n                } else {\n                    *done = true;\n                    Some(Vec::new())\n                }\n            }\n            Self::One(xs) => xs.next().map(|x| vec![x]),\n            Self::Two(ps) => ps.next(),\n            Self::GreaterThanTwo(xss) => xss.next().map(|p| p.1),\n        }\n    }\n}\n\n/// Generates [`Vec`]s of a given length with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $k$ is 0, the output length is 1.\n///\n/// If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.\n///\n/// If $k$ is nonzero and the input iterator length is $n$, the output length is\n/// $$\n/// (n)_ k = \\prod_ {i=0}^{k-1}(n - i) = frac{n!}{(n-k)!}.\n/// $$\n///\n/// If $k$ is 0, the output consists of one empty [`Vec`].\n///\n/// If `xs` is empty, the output is also empty, unless $k$ is 0.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_unique_vecs_fixed_length;\n///\n/// let xss = exhaustive_unique_vecs_fixed_length(4, 1..=6)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2, 3, 4],\n///         &[1, 2, 3, 5],\n///         &[1, 2, 4, 3],\n///         &[1, 2, 4, 5],\n///         &[1, 3, 2, 4],\n///         &[1, 2, 5, 3],\n///         &[1, 3, 4, 2],\n///         &[1, 3, 4, 5],\n///         &[1, 4, 2, 3],\n///         &[1, 3, 2, 5],\n///         &[1, 4, 3, 2],\n///         &[1, 2, 5, 4],\n///         &[2, 1, 3, 4],\n///         &[1, 3, 5, 2],\n///         &[2, 1, 4, 3],\n///         &[2, 3, 4, 5],\n///         &[2, 3, 1, 4],\n///         &[1, 5, 2, 3],\n///         &[2, 3, 4, 1],\n///         &[1, 4, 2, 5]\n///     ]\n/// );\n/// ```\npub fn exhaustive_unique_vecs_fixed_length<I: Iterator>(\n    k: u64,\n    xs: I,\n) -> ExhaustiveUniqueVecsFixedLength<I>\nwhere\n    I::Item: Clone,\n{\n    match k {\n        0 => ExhaustiveUniqueVecsFixedLength::Zero(false),\n        1 => ExhaustiveUniqueVecsFixedLength::One(xs),\n        2 => ExhaustiveUniqueVecsFixedLength::Two(exhaustive_unique_vecs_2(xs)),\n        k => ExhaustiveUniqueVecsFixedLength::GreaterThanTwo(exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_ordered_unique_vecs_fixed_length(k, xs),\n            ExhaustiveUniqueVecsGenerator::new(),\n        )),\n    }\n}\n\n/// Generates all [`Vec`]s of elements from an iterator, where the [`Vec`]s have no repetitions and\n/// are ordered the same way as in the iterator.\n#[derive(Clone)]\npub struct ExhaustiveUniqueVecs<I: Iterator>\nwhere\n    I::Item: Clone,\n{\n    xs: ExhaustiveDependentPairs<\n        Vec<I::Item>,\n        Vec<I::Item>,\n        RulerSequence<usize>,\n        ExhaustiveUniqueVecsGenerator<I::Item, I>,\n        ExhaustiveOrderedUniqueCollections<I, Vec<I::Item>>,\n        ExhaustiveVecPermutations<I::Item>,\n    >,\n}\n\nimpl<I: Iterator> Iterator for ExhaustiveUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    type Item = Vec<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        self.xs.next().map(|p| p.1)\n    }\n}\n\n/// Generates [`Vec`]s with elements from a single iterator, such that each [`Vec`] has no repeated\n/// elements.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_ {k=0}^n \\frac{n!}{k!}\n/// $$\n/// $$\n/// = \\\\begin{cases}\n///     1 & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     2 & \\text{if} \\\\quad n = 1, \\\\\\\\\n///     \\operatorname{round}(en!) & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// See <https://oeis.org/A000522>.\n///\n/// If `xs` is empty, the output consists of a single empty [`Vec`].\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_unique_vecs;\n///\n/// let xss = exhaustive_unique_vecs(1..=4).take(20).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[1],\n///         &[2],\n///         &[3],\n///         &[1, 2],\n///         &[1, 3],\n///         &[2, 1],\n///         &[1, 2, 3],\n///         &[3, 1],\n///         &[2, 3],\n///         &[3, 2],\n///         &[4],\n///         &[1, 3, 2],\n///         &[1, 4],\n///         &[2, 1, 3],\n///         &[3, 4],\n///         &[2, 3, 1],\n///         &[4, 1],\n///         &[3, 1, 2],\n///         &[2, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_unique_vecs<I: Iterator>(xs: I) -> ExhaustiveUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveUniqueVecs {\n        xs: exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_ordered_unique_vecs(xs),\n            ExhaustiveUniqueVecsGenerator::new(),\n        ),\n    }\n}\n\n/// Generates [`Vec`]s with a mininum length, with elements from a single iterator, such that each\n/// [`Vec`] has no repeated elements.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If the input iterator is infinite, the output length is also infinite.\n///\n/// If the input iterator length is $n$ and the `min_length` is $\\ell$, the output length is\n/// $$\n/// \\sum_ {k=\\ell}^n \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_unique_vecs_min_length;\n///\n/// let xss = exhaustive_unique_vecs_min_length(2, 1..=4)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[2, 1],\n///         &[2, 3],\n///         &[3, 1],\n///         &[3, 2],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 2],\n///         &[1, 4],\n///         &[2, 1, 3],\n///         &[2, 4],\n///         &[2, 3, 1],\n///         &[4, 1],\n///         &[3, 1, 2],\n///         &[3, 4],\n///         &[3, 2, 1],\n///         &[4, 2],\n///         &[1, 4, 2],\n///         &[1, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_unique_vecs_min_length<I: Iterator>(\n    min_length: u64,\n    xs: I,\n) -> ExhaustiveUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveUniqueVecs {\n        xs: exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_ordered_unique_vecs_min_length(min_length, xs),\n            ExhaustiveUniqueVecsGenerator::new(),\n        ),\n    }\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b)$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $a \\leq b$, the output is empty.\n///\n/// If $a = 0$ and $b = 1$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a < b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^{b - 1} \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_unique_vecs_length_range;\n///\n/// let xss = exhaustive_unique_vecs_length_range(2, 4, 1..=4)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[2, 1],\n///         &[2, 3],\n///         &[3, 1],\n///         &[3, 2],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 2],\n///         &[1, 4],\n///         &[2, 1, 3],\n///         &[2, 4],\n///         &[2, 3, 1],\n///         &[4, 1],\n///         &[3, 1, 2],\n///         &[3, 4],\n///         &[3, 2, 1],\n///         &[4, 2],\n///         &[1, 4, 2],\n///         &[1, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_unique_vecs_length_range<I: Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveUniqueVecs {\n        xs: exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_ordered_unique_vecs_length_range(a, b, xs),\n            ExhaustiveUniqueVecsGenerator::new(),\n        ),\n    }\n}\n\n/// Generates [`Vec`]s, with lengths in a range $[a, b]$, with elements from a single iterator, such\n/// that each [`Vec`] has no repeated elements.\n///\n/// The source iterator should not repeat any elements, but this is not enforced.\n///\n/// If $a < b$, the output is empty.\n///\n/// If $a = b = 0$, the output consists of a single empty [`Vec`].\n///\n/// If the input iterator is infinite and $0 < a \\leq b$, the output length is also infinite.\n///\n/// If the input iterator length is $n$, the output length is\n/// $$\n/// \\sum_{i=a}^b \\frac{n!}{k!}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_unique_vecs_length_inclusive_range;\n///\n/// let xss = exhaustive_unique_vecs_length_inclusive_range(2, 3, 1..=4)\n///     .take(20)\n///     .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 2][..],\n///         &[1, 3],\n///         &[2, 1],\n///         &[2, 3],\n///         &[3, 1],\n///         &[3, 2],\n///         &[1, 2, 3],\n///         &[1, 2, 4],\n///         &[1, 3, 2],\n///         &[1, 4],\n///         &[2, 1, 3],\n///         &[2, 4],\n///         &[2, 3, 1],\n///         &[4, 1],\n///         &[3, 1, 2],\n///         &[3, 4],\n///         &[3, 2, 1],\n///         &[4, 2],\n///         &[1, 4, 2],\n///         &[1, 3, 4]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_unique_vecs_length_inclusive_range<I: Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n) -> ExhaustiveUniqueVecs<I>\nwhere\n    I::Item: Clone,\n{\n    ExhaustiveUniqueVecs {\n        xs: exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_ordered_unique_vecs_length_inclusive_range(a, b, xs),\n            ExhaustiveUniqueVecsGenerator::new(),\n        ),\n    }\n}\n\n/// Generates all $k$-compositions of a number: all length-$k$ [`Vec`]s of positive [`usize`]s whose\n/// sum is a given number.\n#[derive(Clone, Debug)]\npub struct LexKCompositions {\n    done: bool,\n    first: bool,\n    xs: Vec<usize>,\n}\n\nimpl Iterator for LexKCompositions {\n    type Item = Vec<usize>;\n\n    fn next(&mut self) -> Option<Vec<usize>> {\n        if self.done {\n            return None;\n        } else if self.first {\n            self.first = false;\n            return Some(self.xs.clone());\n        }\n        let last_not_one_index = self.xs.iter().rposition(|&x| x != 1);\n        if last_not_one_index.is_none() || last_not_one_index == Some(0) {\n            self.done = true;\n            return None;\n        }\n        let last_not_one_index = last_not_one_index.unwrap();\n        self.xs[last_not_one_index - 1] += 1;\n        let last_not_one = self.xs[last_not_one_index];\n        let (last, init) = self.xs.split_last_mut().unwrap();\n        *last = last_not_one - 1;\n        for x in &mut init[last_not_one_index..] {\n            *x = 1;\n        }\n        Some(self.xs.clone())\n    }\n}\n\n/// Generates all $k$-compositions of a number: given $n$ and $k$, generates all length-$k$ [`Vec`]s\n/// of positive [`usize`]s whose sum is $n$.\n///\n/// The [`Vec`]s are output in lexicographic order.\n///\n/// If $k = 0$ and $n \\neq 0$, or if $n < k$, then the output is empty.\n///\n/// The output length is\n/// $$\n/// \\binom{n-1}{k-1}.\n/// $$\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_k_compositions;\n///\n/// let xss = lex_k_compositions(5, 3).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[&[1, 1, 3], &[1, 2, 2], &[1, 3, 1], &[2, 1, 2], &[2, 2, 1], &[3, 1, 1]]\n/// );\n/// ```\npub fn lex_k_compositions(n: usize, k: usize) -> LexKCompositions {\n    if k == 0 && n != 0 || n < k {\n        return LexKCompositions {\n            done: true,\n            first: true,\n            xs: Vec::new(),\n        };\n    }\n    let mut xs = vec![1; k];\n    if k != 0 {\n        xs[k - 1] = n + 1 - k;\n    }\n    LexKCompositions {\n        done: false,\n        first: true,\n        xs,\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct LexKCompositionsGenerator {\n    k: usize,\n}\n\nimpl ExhaustiveDependentPairsYsGenerator<usize, Vec<usize>, LexKCompositions>\n    for LexKCompositionsGenerator\n{\n    #[inline]\n    fn get_ys(&self, &n: &usize) -> LexKCompositions {\n        lex_k_compositions(n, self.k)\n    }\n}\n\n/// Generates $k$-compositions of $n$ for all $n$ in a given range: all length-$k$ [`Vec`]s of\n/// positive [`usize`]s whose sum is in a given range.\n#[derive(Clone, Debug)]\npub struct ExhaustiveCombinedKCompositions {\n    xs: ExhaustiveDependentPairs<\n        usize,\n        Vec<usize>,\n        RulerSequence<usize>,\n        LexKCompositionsGenerator,\n        PrimitiveIntIncreasingRange<usize>,\n        LexKCompositions,\n    >,\n}\n\nimpl Iterator for ExhaustiveCombinedKCompositions {\n    type Item = Vec<usize>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<usize>> {\n        self.xs.next().map(|p| p.1)\n    }\n}\n\n/// Given $n_\\text{min}$, $n_\\text{max}$, and $k$, generates all length-$k$ [`Vec`]s of positive\n/// [`usize`]s whose sum is in the closed interval $[n_\\text{min}, n_\\text{max}]$.\n///\n/// The output length is\n/// $$\n/// \\sum_{n=n_\\text{min}}^{n_\\text{max}} \\binom{n-1}{k-1}.\n/// $$\n///\n/// # Panics\n/// Panics if $n_\\text{min} > n_\\text{max}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_combined_k_compositions;\n///\n/// let xss = exhaustive_combined_k_compositions(4, 6, 3).collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[1, 1, 2],\n///         &[1, 1, 3],\n///         &[1, 2, 1],\n///         &[1, 1, 4],\n///         &[2, 1, 1],\n///         &[1, 2, 2],\n///         &[1, 3, 1],\n///         &[1, 2, 3],\n///         &[2, 1, 2],\n///         &[1, 3, 2],\n///         &[2, 2, 1],\n///         &[3, 1, 1],\n///         &[1, 4, 1],\n///         &[2, 1, 3],\n///         &[2, 2, 2],\n///         &[2, 3, 1],\n///         &[3, 1, 2],\n///         &[3, 2, 1],\n///         &[4, 1, 1]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_combined_k_compositions(\n    n_min: usize,\n    n_max: usize,\n    k: usize,\n) -> ExhaustiveCombinedKCompositions {\n    ExhaustiveCombinedKCompositions {\n        xs: exhaustive_dependent_pairs(\n            ruler_sequence(),\n            primitive_int_increasing_inclusive_range(n_min, n_max),\n            LexKCompositionsGenerator { k },\n        ),\n    }\n}\n"
  },
  {
    "path": "malachite-base/src/vecs/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(feature = \"random\")]\nuse crate::num::conversion::traits::ExactFrom;\n#[cfg(feature = \"random\")]\nuse crate::num::random::{RandomUnsignedsLessThan, random_unsigneds_less_than};\n#[cfg(feature = \"random\")]\nuse crate::random::Seed;\nuse crate::slices::advance_indices;\nuse alloc::string::String;\nuse alloc::vec::Vec;\nuse core::str::FromStr;\n#[cfg(feature = \"random\")]\nuse rand::prelude::SliceRandom;\n#[cfg(feature = \"random\")]\nuse rand_chacha::ChaCha20Rng;\n\n/// Inserts several copies of a value at the left (beginning) of a [`Vec`].\n///\n/// Using this function is more efficient than inserting the values one by one.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n + m)$\n///\n/// $M(n) = O(n + m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ = `xs.len()` before the function is called, and\n/// $m$ = `pad_size`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::vecs::vec_pad_left;\n///\n/// let mut xs = vec![1, 2, 3];\n/// vec_pad_left::<u32>(&mut xs, 5, 10);\n/// assert_eq!(xs, [10, 10, 10, 10, 10, 1, 2, 3]);\n/// ```\npub fn vec_pad_left<T: Clone>(xs: &mut Vec<T>, pad_size: usize, pad_value: T) {\n    let old_len = xs.len();\n    xs.resize(old_len + pad_size, pad_value);\n    for i in (0..old_len).rev() {\n        xs.swap(i, i + pad_size);\n    }\n}\n\n/// Deletes several values from the left (beginning) of a [`Vec`].\n///\n/// Using this function is more efficient than deleting the values one by one.\n///\n/// # Worst-case complexity\n/// $T(n) = O(\\operatorname{max}(1, n - m))$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ = `xs.len()` before the function is called, and\n/// $m$ = `delete_size`.\n///\n/// # Panics\n/// Panics if `delete_size` is greater than `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::vecs::vec_delete_left;\n///\n/// let mut xs = vec![1, 2, 3, 4, 5];\n/// vec_delete_left::<u32>(&mut xs, 3);\n/// assert_eq!(xs, [4, 5]);\n/// ```\npub fn vec_delete_left<T: Copy>(xs: &mut Vec<T>, delete_size: usize) {\n    let old_len = xs.len();\n    xs.copy_within(delete_size..old_len, 0);\n    xs.truncate(old_len - delete_size);\n}\n\n/// Converts a string to an `Vec<T>`, where `T` implements [`FromStr`].\n///\n/// If the string does not represent a valid `Vec<T>`, `None` is returned.\n///\n/// If `T` does not implement [`FromStr`], try using [`vec_from_str_custom`] instead.\n///\n/// Substrings representing `T`s may contain commas. Sometimes this may lead to ambiguities: for\n/// example, the two `Vec<&str>`s `vec![\"a, b\"]` and `vec![\"a\", \"b\"]` both have the string\n/// representation `\"[a, b]\"`. The parser is greedy, so it will interpet this string as `vec![\"a\",\n/// \"b\"]`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::nevers::Never;\n/// use malachite_base::vecs::vec_from_str;\n///\n/// assert_eq!(vec_from_str::<Never>(\"[]\"), Some(vec![]));\n/// assert_eq!(vec_from_str(\"[5, 6, 7]\"), Some(vec![5, 6, 7]));\n/// assert_eq!(\n///     vec_from_str(\"[false, false, true]\"),\n///     Some(vec![false, false, true])\n/// );\n/// assert_eq!(vec_from_str::<bool>(\"[false, false, true\"), None);\n/// ```\n#[inline]\npub fn vec_from_str<T: FromStr>(src: &str) -> Option<Vec<T>> {\n    vec_from_str_custom(&(|t| t.parse().ok()), src)\n}\n\n/// Converts a string to an `Vec<T>`, given a function to parse a string into a `T`.\n///\n/// If the string does not represent a valid `Option<T>`, `None` is returned.\n///\n/// If `f` just uses [`FromStr::from_str`], you can use [`vec_from_str`] instead.\n///\n/// Substrings representing `T`s may contain commas. Sometimes this may lead to ambiguities: for\n/// example, the two `Vec<&str>`s `vec![\"a, b\"]` and `vec![\"a\", \"b\"]` both have the string\n/// representation `\"[a, b]\"`. The parser is greedy, so it will interpet this string as `vec![\"a\",\n/// \"b\"]`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::options::option_from_str;\n/// use malachite_base::orderings::ordering_from_str;\n/// use malachite_base::vecs::{vec_from_str, vec_from_str_custom};\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(\n///     vec_from_str_custom(&ordering_from_str, \"[Less, Greater]\"),\n///     Some(vec![Less, Greater]),\n/// );\n/// assert_eq!(\n///     vec_from_str_custom(&option_from_str, \"[Some(false), None]\"),\n///     Some(vec![Some(false), None]),\n/// );\n/// assert_eq!(\n///     vec_from_str_custom(&vec_from_str, \"[[], [3], [2, 5]]\"),\n///     Some(vec![vec![], vec![3], vec![2, 5]]),\n/// );\n/// assert_eq!(\n///     vec_from_str_custom(&option_from_str::<bool>, \"[Some(fals), None]\"),\n///     None\n/// );\n/// ```\npub fn vec_from_str_custom<T>(f: &dyn Fn(&str) -> Option<T>, src: &str) -> Option<Vec<T>> {\n    if !src.starts_with('[') || !src.ends_with(']') {\n        return None;\n    }\n    let mut xs = Vec::new();\n    let mut buffer = String::new();\n    for token in src[1..src.len() - 1].split(\", \") {\n        if !buffer.is_empty() {\n            buffer.push_str(\", \");\n        }\n        buffer.push_str(token);\n        if let Some(x) = f(&buffer) {\n            xs.push(x);\n            buffer.clear();\n        }\n    }\n    if buffer.is_empty() { Some(xs) } else { None }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random value from a nonempty [`Vec`].\n///\n/// This `struct` is created by [`random_values_from_vec`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomValuesFromVec<T: Clone> {\n    xs: Vec<T>,\n    indices: RandomUnsignedsLessThan<u64>,\n}\n\n#[cfg(feature = \"random\")]\nimpl<T: Clone> Iterator for RandomValuesFromVec<T> {\n    type Item = T;\n\n    #[inline]\n    fn next(&mut self) -> Option<T> {\n        Some(self.xs[usize::exact_from(self.indices.next().unwrap())].clone())\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random value from a nonempty [`Vec`].\n///\n/// The iterator owns the data. It may be more convenient for the iterator to return references to a\n/// pre-existing slice, in which case you may use\n/// [`random_values_from_slice`](crate::slices::random_values_from_slice) instead.\n///\n/// The output length is infinite.\n///\n/// $P(x) = 1/n$, where $n$ is `xs.len()`.\n///\n/// # Panics\n/// Panics if `xs` is empty.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random_values_from_vec;\n///\n/// let xs = vec![2, 3, 5, 7, 11];\n/// assert_eq!(\n///     random_values_from_vec(EXAMPLE_SEED, xs)\n///         .take(10)\n///         .collect_vec(),\n///     &[3, 7, 3, 5, 11, 3, 5, 11, 2, 2]\n/// );\n/// ```\n#[inline]\npub fn random_values_from_vec<T: Clone>(seed: Seed, xs: Vec<T>) -> RandomValuesFromVec<T> {\n    assert!(!xs.is_empty(), \"empty Vec\");\n    let indices = random_unsigneds_less_than(seed, u64::exact_from(xs.len()));\n    RandomValuesFromVec { xs, indices }\n}\n\n/// Generates every permutation of a [`Vec`].\n///\n/// This `struct` is created by [`exhaustive_vec_permutations`]; see its documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct ExhaustiveVecPermutations<T: Clone> {\n    xs: Vec<T>,\n    indices: Vec<usize>,\n    done: bool,\n}\n\nimpl<T: Clone> Iterator for ExhaustiveVecPermutations<T> {\n    type Item = Vec<T>;\n\n    fn next(&mut self) -> Option<Vec<T>> {\n        if self.done {\n            None\n        } else {\n            let out = Some(self.indices.iter().map(|&i| self.xs[i].clone()).collect());\n            self.done = advance_indices(&mut self.indices);\n            out\n        }\n    }\n}\n\n/// Generates every permutation of a [`Vec`].\n///\n/// The permutations are [`Vec`]s of cloned items. It may be more convenient for the iterator to\n/// return references to a slice, in which case you may use\n/// [`exhaustive_slice_permutations`](crate::slices::exhaustive_slice_permutations) instead.\n///\n/// The permutations are generated in lexicographic order with respect to the ordering in the\n/// [`Vec`].\n///\n/// The output length is $n!$, where $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive_vec_permutations;\n///\n/// let css: Vec<String> = exhaustive_vec_permutations(vec!['a', 'b', 'c', 'd'])\n///     .map(|ds| ds.into_iter().collect())\n///     .collect();\n/// assert_eq!(\n///     css.iter().map(String::as_str).collect_vec().as_slice(),\n///     [\n///         \"abcd\", \"abdc\", \"acbd\", \"acdb\", \"adbc\", \"adcb\", \"bacd\", \"badc\", \"bcad\", \"bcda\", \"bdac\",\n///         \"bdca\", \"cabd\", \"cadb\", \"cbad\", \"cbda\", \"cdab\", \"cdba\", \"dabc\", \"dacb\", \"dbac\", \"dbca\",\n///         \"dcab\", \"dcba\"\n///     ]\n/// );\n/// ```\npub fn exhaustive_vec_permutations<T: Clone>(xs: Vec<T>) -> ExhaustiveVecPermutations<T> {\n    let len = xs.len();\n    ExhaustiveVecPermutations {\n        xs,\n        indices: (0..len).collect(),\n        done: false,\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random [`Vec`] of values cloned from an original [`Vec`].\n///\n/// This `struct` is created by [`random_vec_permutations`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomVecPermutations<T: Clone> {\n    xs: Vec<T>,\n    indices: Vec<usize>,\n    rng: ChaCha20Rng,\n}\n\n#[cfg(feature = \"random\")]\nimpl<T: Clone> Iterator for RandomVecPermutations<T> {\n    type Item = Vec<T>;\n\n    fn next(&mut self) -> Option<Vec<T>> {\n        self.indices.shuffle(&mut self.rng);\n        Some(self.indices.iter().map(|&i| self.xs[i].clone()).collect())\n    }\n}\n\n#[cfg(feature = \"random\")]\n/// Uniformly generates a random [`Vec`] of values cloned from an original [`Vec`].\n///\n/// The permutations are [`Vec`]s of cloned items. It may be more convenient for the iterator to\n/// return references to a slice, in which case you may use\n/// [`random_slice_permutations`](crate::slices::random_slice_permutations) instead.\n///\n/// The output length is infinite.\n///\n/// $P(p) = 1/n!$, where $n$ is `xs.len()`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random_vec_permutations;\n///\n/// let css: Vec<String> = random_vec_permutations(EXAMPLE_SEED, vec!['a', 'b', 'c', 'd'])\n///     .take(20)\n///     .map(|ds| ds.into_iter().collect())\n///     .collect();\n/// assert_eq!(\n///     css.iter().map(String::as_str).collect_vec().as_slice(),\n///     [\n///         \"dacb\", \"cbad\", \"cdab\", \"cbad\", \"cdab\", \"bcda\", \"bcda\", \"acbd\", \"bcda\", \"dbca\", \"bdac\",\n///         \"dbac\", \"dbca\", \"bcad\", \"cadb\", \"dacb\", \"acbd\", \"dbac\", \"bdca\", \"abdc\"\n///     ]\n/// );\n/// ```\npub fn random_vec_permutations<T: Clone>(seed: Seed, xs: Vec<T>) -> RandomVecPermutations<T> {\n    let len = xs.len();\n    RandomVecPermutations {\n        xs,\n        indices: (0..len).collect(),\n        rng: seed.get_rng(),\n    }\n}\n\n/// Iterators that generate [`Vec`]s without repetition.\n///\n/// # lex_vecs_length_2\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::lex_vecs_length_2;\n///\n/// let xss = lex_vecs_length_2(\n///     ['a', 'b', 'c'].iter().cloned(),\n///     ['x', 'y', 'z'].iter().cloned(),\n/// )\n/// .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &['a', 'x'],\n///         &['a', 'y'],\n///         &['a', 'z'],\n///         &['b', 'x'],\n///         &['b', 'y'],\n///         &['b', 'z'],\n///         &['c', 'x'],\n///         &['c', 'y'],\n///         &['c', 'z']\n///     ]\n/// );\n/// ```\n///\n/// # lex_vecs_fixed_length_2_inputs\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n/// use malachite_base::vecs::exhaustive::lex_vecs_fixed_length_2_inputs;\n///\n/// // We are generating length-3 `Vec`s of `char`s using two input iterators. The first iterator\n/// // (with index 0) produces all ASCII `char`s, and the second (index 1) produces the three\n/// // `char`s `'x'`, `'y'`, and `'z'`. The elements of `output_types` are 0, 1, and 0, meaning that\n/// // the first element of the output `Vec`s will be taken from iterator 0, the second element from\n/// // iterator 1, and the third also from iterator 0.\n/// let xss = lex_vecs_fixed_length_2_inputs(\n///     exhaustive_ascii_chars(),\n///     ['x', 'y', 'z'].iter().cloned(),\n///     &[0, 1, 0],\n/// );\n/// let xss_prefix = xss.take(20).collect_vec();\n/// assert_eq!(\n///     xss_prefix\n///         .iter()\n///         .map(Vec::as_slice)\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         &['a', 'x', 'a'],\n///         &['a', 'x', 'b'],\n///         &['a', 'x', 'c'],\n///         &['a', 'x', 'd'],\n///         &['a', 'x', 'e'],\n///         &['a', 'x', 'f'],\n///         &['a', 'x', 'g'],\n///         &['a', 'x', 'h'],\n///         &['a', 'x', 'i'],\n///         &['a', 'x', 'j'],\n///         &['a', 'x', 'k'],\n///         &['a', 'x', 'l'],\n///         &['a', 'x', 'm'],\n///         &['a', 'x', 'n'],\n///         &['a', 'x', 'o'],\n///         &['a', 'x', 'p'],\n///         &['a', 'x', 'q'],\n///         &['a', 'x', 'r'],\n///         &['a', 'x', 's'],\n///         &['a', 'x', 't']\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_vecs_length_2\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_length_2;\n///\n/// let xss = exhaustive_vecs_length_2(\n///     ['a', 'b', 'c'].iter().cloned(),\n///     ['x', 'y', 'z'].iter().cloned(),\n/// )\n/// .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &['a', 'x'],\n///         &['a', 'y'],\n///         &['b', 'x'],\n///         &['b', 'y'],\n///         &['a', 'z'],\n///         &['b', 'z'],\n///         &['c', 'x'],\n///         &['c', 'y'],\n///         &['c', 'z']\n///     ]\n/// );\n/// ```\n///\n/// # exhaustive_vecs_fixed_length_2_inputs\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n/// use malachite_base::iterators::bit_distributor::BitDistributorOutputType;\n/// use malachite_base::vecs::exhaustive::exhaustive_vecs_fixed_length_2_inputs;\n///\n/// // We are generating length-3 `Vec`s of `char`s using two input iterators. The first iterator\n/// // (with index 0) produces all ASCII `char`s, and the second (index 1) produces the three\n/// // `char`s `'x'`, `'y'`, and `'z'`. The elements of `output_types` have the indices 0, 1, and 0,\n/// // meaning that the first element of the output `Vec`s will be taken from iterator 0, the second\n/// // element from iterator 1, and the third also from iterator 0. The third element has a tiny\n/// // output type, so it will grow more slowly than the other two elements (though it doesn't look\n/// // that way from the first few `Vec`s).\n/// let xss = exhaustive_vecs_fixed_length_2_inputs(\n///     exhaustive_ascii_chars(),\n///     ['x', 'y', 'z'].iter().cloned(),\n///     &[\n///         (BitDistributorOutputType::normal(1), 0),\n///         (BitDistributorOutputType::normal(1), 1),\n///         (BitDistributorOutputType::tiny(), 0),\n///     ],\n/// );\n/// let xss_prefix = xss.take(20).collect_vec();\n/// assert_eq!(\n///     xss_prefix\n///         .iter()\n///         .map(Vec::as_slice)\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         &['a', 'x', 'a'],\n///         &['a', 'x', 'b'],\n///         &['a', 'x', 'c'],\n///         &['a', 'x', 'd'],\n///         &['a', 'y', 'a'],\n///         &['a', 'y', 'b'],\n///         &['a', 'y', 'c'],\n///         &['a', 'y', 'd'],\n///         &['a', 'x', 'e'],\n///         &['a', 'x', 'f'],\n///         &['a', 'x', 'g'],\n///         &['a', 'x', 'h'],\n///         &['a', 'y', 'e'],\n///         &['a', 'y', 'f'],\n///         &['a', 'y', 'g'],\n///         &['a', 'y', 'h'],\n///         &['b', 'x', 'a'],\n///         &['b', 'x', 'b'],\n///         &['b', 'x', 'c'],\n///         &['b', 'x', 'd']\n///     ]\n/// );\n/// ```\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`Vec`]s randomly.\n///\n/// # random_vecs_length_2\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::random::random_char_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs_length_2;\n///\n/// let xss = random_vecs_length_2(\n///     EXAMPLE_SEED,\n///     &|seed| random_char_inclusive_range(seed, 'a', 'c'),\n///     &|seed| random_char_inclusive_range(seed, 'x', 'z'),\n/// )\n/// .take(20)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &['b', 'z'],\n///         &['b', 'x'],\n///         &['b', 'z'],\n///         &['b', 'y'],\n///         &['c', 'x'],\n///         &['a', 'z'],\n///         &['a', 'z'],\n///         &['a', 'z'],\n///         &['c', 'z'],\n///         &['a', 'y'],\n///         &['c', 'x'],\n///         &['a', 'x'],\n///         &['c', 'z'],\n///         &['a', 'z'],\n///         &['c', 'x'],\n///         &['c', 'x'],\n///         &['c', 'y'],\n///         &['b', 'y'],\n///         &['a', 'x'],\n///         &['c', 'x']\n///     ]\n/// );\n/// ```\n///\n/// # random_vecs_fixed_length_2_inputs\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::chars::random::{random_ascii_chars, random_char_inclusive_range};\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs_fixed_length_2_inputs;\n///\n/// // We are generating length-3 `Vec`s of `char`s using two input iterators. The first iterator\n/// // (with index 0) produces random ASCII `char`s, and the second (index 1) produces the three\n/// // `char`s `'x'`, `'y'`, and `'z'`, uniformly at random. The elements of `output_types` are 0,\n/// // 1, and 0, meaning that the first element of the output `Vec`s will be taken from iterator 0,\n/// // the second element from iterator 1, and the third also from iterator 0.\n/// let xss = random_vecs_fixed_length_2_inputs(\n///     EXAMPLE_SEED,\n///     &random_ascii_chars,\n///     &|seed| random_char_inclusive_range(seed, 'x', 'z'),\n///     &[0, 1, 0],\n/// )\n/// .take(20)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &['U', 'z', '\\u{16}'],\n///         &[' ', 'x', 'D'],\n///         &['<', 'z', ']'],\n///         &['a', 'y', 'e'],\n///         &['_', 'x', 'M'],\n///         &[',', 'z', 'O'],\n///         &['\\u{1d}', 'z', 'V'],\n///         &['(', 'z', '\\u{10}'],\n///         &['&', 'z', 'U'],\n///         &['{', 'y', 'P'],\n///         &['-', 'x', 'K'],\n///         &['Z', 'x', '\\u{4}'],\n///         &['X', 'z', '\\u{19}'],\n///         &['_', 'z', ','],\n///         &['\\u{1d}', 'x', ','],\n///         &['?', 'x', '\\''],\n///         &['[', 'y', 'N'],\n///         &['|', 'y', '}'],\n///         &['*', 'x', '\\u{15}'],\n///         &['z', 'x', 't']\n///     ]\n/// );\n/// ```\npub mod random;\n"
  },
  {
    "path": "malachite-base/src/vecs/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::conversion::traits::ExactFrom;\nuse crate::num::random::geometric::{\n    GeometricRandomNaturalValues, geometric_random_unsigned_inclusive_range,\n    geometric_random_unsigneds,\n};\nuse crate::num::random::{\n    RandomUnsignedInclusiveRange, RandomUnsignedRange, random_unsigned_inclusive_range,\n    random_unsigned_range,\n};\nuse crate::random::Seed;\nuse crate::sets::random::{\n    RandomBTreeSets, RandomBTreeSetsFixedLength, random_b_tree_sets_fixed_length,\n    random_b_tree_sets_from_length_iterator,\n};\nuse crate::vecs::exhaustive::validate_oi_map;\nuse std::cmp::Ordering::*;\nuse std::collections::HashMap;\nuse std::hash::Hash;\nuse std::iter::{Repeat, repeat};\n\n/// Generates random [`Vec`]s of a given length using elements from a single iterator.\n///\n/// This `struct` is created by [`random_vecs_fixed_length_from_single`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct RandomFixedLengthVecsFromSingle<I: Iterator> {\n    len: u64,\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomFixedLengthVecsFromSingle<I> {\n    type Item = Vec<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        Some((&mut self.xs).take(usize::exact_from(self.len)).collect())\n    }\n}\n\n/// Randomly generates [`Vec`]s of a given length using elements from a single iterator.\n///\n/// The probability of a particular length-$n$ [`Vec`] being generated is the product of the\n/// probabilities of each of its elements.\n///\n/// If `len` is 0, the output consists of the empty list, repeated.\n///\n/// `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs_fixed_length_from_single;\n///\n/// let xss = random_vecs_fixed_length_from_single(\n///     2,\n///     random_unsigned_inclusive_range::<u32>(EXAMPLE_SEED, 1, 100),\n/// )\n/// .take(10)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[95, 24],\n///         &[99, 71],\n///         &[93, 53],\n///         &[85, 34],\n///         &[48, 2],\n///         &[55, 11],\n///         &[48, 18],\n///         &[90, 93],\n///         &[67, 93],\n///         &[93, 95]\n///     ]\n/// );\n/// ```\n#[inline]\npub const fn random_vecs_fixed_length_from_single<I: Iterator>(\n    len: u64,\n    xs: I,\n) -> RandomFixedLengthVecsFromSingle<I> {\n    RandomFixedLengthVecsFromSingle { len, xs }\n}\n\n/// Defines random fixed-length [`Vec`] generators.\n///\n/// Malachite provides [`random_vecs_length_2`] and [`random_vecs_fixed_length_2_inputs`], but you\n/// can also define `random_vecs_length_3`, `random_vecs_length_4`, and so on, and\n/// `random_vecs_fixed_length_3_inputs`, `random_vecs_fixed_length_4_inputs`, and so on, in your\n/// program using the code below. The documentation for [`random_vecs_length_2`] and\n/// [`random_vecs_fixed_length_2_inputs`] describes these other functions as well.\n///\n/// See usage examples [here](self#lex_vecs_length_2) and\n/// [here](self#random_vecs_fixed_length_2_inputs).\n///\n/// ```\n/// use malachite_base::random::Seed;\n/// use malachite_base::random_vecs_fixed_length;\n/// use malachite_base::vecs::exhaustive::validate_oi_map;\n///\n/// random_vecs_fixed_length!(\n///     (pub(crate)),\n///     RandomFixedLengthVecs3Inputs,\n///     random_vecs_fixed_length_3_inputs,\n///     random_vecs_length_3,\n///     [0, I, xs, xs_gen],\n///     [1, J, ys, ys_gen],\n///     [2, K, zs, zs_gen]\n/// );\n/// random_vecs_fixed_length!(\n///     (pub(crate)),\n///     RandomFixedLengthVecs4Inputs,\n///     random_vecs_fixed_length_4_inputs,\n///     random_vecs_length_4,\n///     [0, I, xs, xs_gen],\n///     [1, J, ys, ys_gen],\n///     [2, K, zs, zs_gen],\n///     [3, L, ws, ws_gen]\n/// );\n/// random_vecs_fixed_length!(\n///     (pub(crate)),\n///     RandomFixedLengthVecs5Inputs,\n///     random_vecs_fixed_length_5_inputs,\n///     random_vecs_length_5,\n///     [0, I, xs, xs_gen],\n///     [1, J, ys, ys_gen],\n///     [2, K, zs, zs_gen],\n///     [3, L, ws, ws_gen],\n///     [4, M, vs, vs_gen]\n/// );\n/// random_vecs_fixed_length!(\n///     (pub(crate)),\n///     RandomFixedLengthVecs6Inputs,\n///     random_vecs_fixed_length_6_inputs,\n///     random_vecs_length_6,\n///     [0, I, xs, xs_gen],\n///     [1, J, ys, ys_gen],\n///     [2, K, zs, zs_gen],\n///     [3, L, ws, ws_gen],\n///     [4, M, vs, vs_gen],\n///     [5, N, us, us_gen]\n/// );\n/// random_vecs_fixed_length!(\n///     (pub(crate)),\n///     RandomFixedLengthVecs7Inputs,\n///     random_vecs_fixed_length_7_inputs,\n///     random_vecs_length_7,\n///     [0, I, xs, xs_gen],\n///     [1, J, ys, ys_gen],\n///     [2, K, zs, zs_gen],\n///     [3, L, ws, ws_gen],\n///     [4, M, vs, vs_gen],\n///     [5, N, us, us_gen],\n///     [6, O, ts, ts_gen]\n/// );\n/// random_vecs_fixed_length!(\n///     (pub(crate)),\n///     RandomFixedLengthVecs8Inputs,\n///     random_vecs_fixed_length_8_inputs,\n///     random_vecs_length_8,\n///     [0, I, xs, xs_gen],\n///     [1, J, ys, ys_gen],\n///     [2, K, zs, zs_gen],\n///     [3, L, ws, ws_gen],\n///     [4, M, vs, vs_gen],\n///     [5, N, us, us_gen],\n///     [6, O, ts, ts_gen],\n///     [7, P, ss, ss_gen]\n/// );\n/// ```\n#[macro_export]\nmacro_rules! random_vecs_fixed_length {\n    (\n        ($($vis:tt)*),\n        $random_struct: ident,\n        $random_fn: ident,\n        $random_1_to_1_fn: ident,\n        $([$i: expr, $it: ident, $xs: ident, $xs_gen: ident]),*\n    ) => {\n        /// This documentation applies not only to `RandomFixedLengthVecs2Inputs`, but also to\n        /// `RandomFixedLengthVecs3Inputs`, `RandomFixedLengthVecs4Inputs`, and so on. See\n        /// [`random_vecs_fixed_length`] for more information.\n        ///\n        /// Generates random [`Vec`]s of a given length using elements from $m$ iterators.\n        ///\n        /// The fixed length $n$ of the [`Vec`]s is greater than or equal to $m$.\n        #[derive(Clone, Debug)]\n        $($vis)* struct $random_struct<T, $($it: Iterator<Item = T>),*> {\n            $($xs: $it,)*\n            output_to_input_map: Vec<usize>,\n        }\n\n        impl<T, $($it: Iterator<Item = T>),*> Iterator\n            for $random_struct<T, $($it),*>\n        {\n            type Item = Vec<T>;\n\n            #[inline]\n            fn next(&mut self) -> Option<Vec<T>> {\n                let mut out = Vec::with_capacity(self.output_to_input_map.len());\n                for &i in &self.output_to_input_map {\n                    out.push(\n                        match i {\n                            $(\n                                $i => self.$xs.next(),\n                            )*\n                            _ => unreachable!(),\n                        }\n                        .unwrap(),\n                    );\n                }\n                Some(out)\n            }\n        }\n\n        /// This documentation applies not only to `random_vecs_fixed_length_2_inputs`, but also to\n        /// `random_vecs_fixed_length_3_inputs`, `random_vecs_fixed_length_4_inputs`, and so on. See\n        /// [`random_vecs_fixed_length`] for more information.\n        ///\n        /// Generates random length-$n$ [`Vec`]s using elements from $m$ iterators, where $m \\leq\n        /// n$.\n        ///\n        /// The `output_to_input_map` parameter defines which iterators are mapped to which slot in\n        /// the output [`Vec`]s. The length of the output [`Vec`]s, $n$, is specified by the length\n        /// of `output_to_input_map`.\n        ///\n        /// The $i$th element of `output_to_input_map` is an index from 0 to $m-1$ which specifies\n        /// which iterator the $i$th output slot is populated with. Together, the elements must\n        /// include all indices from 0 to $m-1$, inclusive, possibly with repetitions.\n        ///\n        /// `xs` must be infinite.\n        ///\n        /// # Examples\n        /// See [here](self#random_vecs_fixed_length_2_inputs).\n        #[allow(dead_code)]\n        $($vis)* fn $random_fn<T, $($it: Iterator<Item = T>),*>(\n            seed: Seed,\n            $($xs_gen: &dyn Fn(Seed) -> $it,)*\n            output_to_input_map: &[usize],\n        ) -> $random_struct<T, $($it),*> {\n            $(\n                let _max_input_index = $i;\n            )*\n            validate_oi_map(_max_input_index, output_to_input_map.iter().cloned());\n            $random_struct {\n                $($xs: $xs_gen(seed.fork(stringify!($xs))),)*\n                output_to_input_map: output_to_input_map.to_vec(),\n            }\n        }\n\n        /// This documentation applies not only to `random_vecs_length_2`, but also to\n        /// `random_vecs_length_3`, `random_vecs_length_4`, and so on. See\n        /// [`random_vecs_fixed_length`] for more information.\n        ///\n        /// Generates random length-$n$ [`Vec`]s with elements from $n$ iterators.\n        ///\n        /// The probability of a particular length-$n$ [`Vec`] being generated is the product of the\n        /// probabilities of each of its elements.\n        ///\n        /// `xs`, `ys`, `zs`, ... must be infinite.\n        ///\n        /// # Examples\n        /// See [here](self#random_vecs_length_2).\n        #[allow(dead_code)]\n        #[inline]\n        $($vis)* fn $random_1_to_1_fn<T, $($it: Iterator<Item = T>),*>(\n            seed: Seed,\n            $($xs_gen: &dyn Fn(Seed) -> $it,)*\n        ) -> $random_struct<T, $($it),*> {\n            $random_fn(seed, $($xs_gen,)* &[$($i),*])\n        }\n    }\n}\n\nrandom_vecs_fixed_length!(\n    (pub),\n    RandomFixedLengthVecs2Inputs,\n    random_vecs_fixed_length_2_inputs,\n    random_vecs_length_2,\n    [0, I, xs, xs_gen],\n    [1, J, ys, ys_gen]\n);\n\n/// Generates random [`Vec`]s using elements from an iterator and with lengths from another\n/// iterator.\n#[derive(Clone, Debug)]\npub struct RandomVecs<T, I: Iterator<Item = u64>, J: Iterator<Item = T>> {\n    lengths: I,\n    xs: J,\n}\n\nimpl<T, I: Iterator<Item = u64>, J: Iterator<Item = T>> Iterator for RandomVecs<T, I, J> {\n    type Item = Vec<T>;\n\n    fn next(&mut self) -> Option<Vec<T>> {\n        Some(\n            (&mut self.xs)\n                .take(usize::exact_from(self.lengths.next().unwrap()))\n                .collect(),\n        )\n    }\n}\n\n/// Generates random [`Vec`]s using elements from an iterator and with lengths from another\n/// iterator.\n///\n/// The probability of a particular [`Vec`] being generated is the product of the probabilities of\n/// each of its elements, multiplied by the probability of its length being generated.\n///\n/// `lengths` and `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs_from_length_iterator;\n/// use malachite_base::vecs::random_values_from_vec;\n///\n/// let xs = random_vecs_from_length_iterator(\n///     EXAMPLE_SEED,\n///     &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n///     &random_primitive_ints::<u8>,\n/// );\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11][..],\n///         &[136, 200, 235, 134],\n///         &[203, 223],\n///         &[38, 235, 217, 177],\n///         &[162, 32, 166, 234],\n///         &[30, 218],\n///         &[],\n///         &[90, 106],\n///         &[],\n///         &[9, 216, 204, 151],\n///         &[213, 97, 253, 78],\n///         &[91, 39],\n///         &[191, 175, 170, 232],\n///         &[233, 2],\n///         &[35, 22, 217, 198],\n///         &[114, 17, 32, 173],\n///         &[114, 65, 121, 222],\n///         &[],\n///         &[173, 25, 144, 148],\n///         &[]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_vecs_from_length_iterator<T, I: Iterator<Item = u64>, J: Iterator<Item = T>>(\n    seed: Seed,\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n) -> RandomVecs<T, I, J> {\n    RandomVecs {\n        lengths: lengths_gen(seed.fork(\"lengths\")),\n        xs: xs_gen(seed.fork(\"xs\")),\n    }\n}\n\n/// Generates random [`Vec`]s using elements from an iterator.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = \\frac{m^n}{(m+1)^{n+1}}\\prod_{i=0}^{n-1}P(x_i).\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs;\n///\n/// let xs = random_vecs(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32],\n///         &[166, 234, 30, 218],\n///         &[90, 106, 9, 216],\n///         &[204],\n///         &[],\n///         &[151, 213, 97, 253, 78],\n///         &[91, 39],\n///         &[191, 175, 170, 232],\n///         &[],\n///         &[233, 2, 35, 22, 217, 198],\n///         &[],\n///         &[],\n///         &[114, 17, 32, 173, 114, 65, 121, 222, 173, 25, 144],\n///         &[148, 79, 115, 52, 73, 69, 137, 91],\n///         &[],\n///         &[153, 178, 112],\n///         &[],\n///         &[34, 95, 106, 167, 197],\n///         &[130, 168, 122, 207, 172, 177, 86, 150, 221]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_vecs<I: Iterator>(\n    seed: Seed,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomVecs<I::Item, GeometricRandomNaturalValues<u64>, I> {\n    random_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigneds(seed_2, mean_length_numerator, mean_length_denominator)\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with a minimum length, using elements from an iterator.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than\n/// `min_length`.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = \\\\begin{cases}\n///     \\frac{(m-a)^{n-a}}{(m+1-a)^{n+1-a}}\\prod_{i=0}^{n-1}P(x_i) & \\text{if} \\\\quad n\\geq a, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $a$ is `min_length`.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, if their ratio is less\n/// than or equal to `min_length`, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs_min_length;\n///\n/// let xs = random_vecs_min_length(EXAMPLE_SEED, 2, &random_primitive_ints::<u8>, 6, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11][..],\n///         &[136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32, 166, 234, 30, 218],\n///         &[90, 106, 9, 216, 204, 151],\n///         &[213, 97, 253, 78, 91, 39],\n///         &[191, 175, 170],\n///         &[232, 233],\n///         &[2, 35, 22, 217, 198, 114, 17],\n///         &[32, 173, 114, 65],\n///         &[121, 222, 173, 25, 144, 148],\n///         &[79, 115],\n///         &[52, 73, 69, 137, 91, 153, 178, 112],\n///         &[34, 95],\n///         &[106, 167],\n///         &[197, 130, 168, 122, 207, 172, 177, 86, 150, 221, 218, 101, 115],\n///         &[74, 9, 123, 109, 52, 201, 159, 247, 250, 48],\n///         &[133, 235],\n///         &[196, 40, 97, 104, 68],\n///         &[190, 216],\n///         &[7, 216, 157, 43, 43, 112, 217],\n///         &[24, 11, 103, 211, 84, 135, 55, 29, 206, 89, 65]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_vecs_min_length<I: Iterator>(\n    seed: Seed,\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomVecs<I::Item, GeometricRandomNaturalValues<u64>, I> {\n    random_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigned_inclusive_range(\n                seed_2,\n                min_length,\n                u64::MAX,\n                mean_length_numerator,\n                mean_length_denominator,\n            )\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with lengths in $[a, b)$, using elements from an iterator.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b)$. $a$ must be\n/// less than $b$.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = \\\\begin{cases}\n///     \\frac{1}{b-a}\\prod_{i=0}^{n-1}P(x_i) & \\text{if} \\\\quad a \\leq n < b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs_length_range;\n///\n/// let xs = random_vecs_length_range(EXAMPLE_SEED, 2, 5, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11, 136][..],\n///         &[200, 235, 134, 203],\n///         &[223, 38, 235],\n///         &[217, 177, 162, 32],\n///         &[166, 234, 30, 218],\n///         &[90, 106, 9],\n///         &[216, 204],\n///         &[151, 213, 97],\n///         &[253, 78],\n///         &[91, 39, 191, 175],\n///         &[170, 232, 233, 2],\n///         &[35, 22, 217],\n///         &[198, 114, 17, 32],\n///         &[173, 114, 65],\n///         &[121, 222, 173, 25],\n///         &[144, 148, 79, 115],\n///         &[52, 73, 69, 137],\n///         &[91, 153],\n///         &[178, 112, 34, 95],\n///         &[106, 167]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_vecs_length_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomVecs<I::Item, RandomUnsignedRange<u64>, I> {\n    random_vecs_from_length_iterator(seed, &|seed_2| random_unsigned_range(seed_2, a, b), xs_gen)\n}\n\n/// Generates random [`Vec`]s with lengths in $[a, b]$, using elements from an iterator.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b]$. $a$ must be\n/// less than or equal to $b$.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = \\\\begin{cases}\n///     \\frac{1}{b-a+1}\\prod_{i=0}^{n-1}P(x_i) & \\text{if} \\\\quad a \\leq n \\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_vecs_length_inclusive_range;\n///\n/// let xs = random_vecs_length_inclusive_range(EXAMPLE_SEED, 2, 4, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11, 136][..],\n///         &[200, 235, 134, 203],\n///         &[223, 38, 235],\n///         &[217, 177, 162, 32],\n///         &[166, 234, 30, 218],\n///         &[90, 106, 9],\n///         &[216, 204],\n///         &[151, 213, 97],\n///         &[253, 78],\n///         &[91, 39, 191, 175],\n///         &[170, 232, 233, 2],\n///         &[35, 22, 217],\n///         &[198, 114, 17, 32],\n///         &[173, 114, 65],\n///         &[121, 222, 173, 25],\n///         &[144, 148, 79, 115],\n///         &[52, 73, 69, 137],\n///         &[91, 153],\n///         &[178, 112, 34, 95],\n///         &[106, 167]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_vecs_length_inclusive_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomVecs<I::Item, RandomUnsignedInclusiveRange<u64>, I> {\n    random_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_inclusive_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct RandomOrderedUniqueVecsLength2<I: Iterator>\nwhere\n    I::Item: Ord,\n{\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomOrderedUniqueVecsLength2<I>\nwhere\n    I::Item: Ord,\n{\n    type Item = Vec<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        let mut out = Vec::with_capacity(2);\n        loop {\n            let x = self.xs.next().unwrap();\n            if out.is_empty() {\n                out.push(x);\n            } else {\n                match x.cmp(&out[0]) {\n                    Equal => {}\n                    Greater => {\n                        out.push(x);\n                        break;\n                    }\n                    Less => {\n                        out.insert(0, x);\n                        break;\n                    }\n                }\n            }\n        }\n        Some(out)\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct RandomOrderedUniqueVecsFixedLengthGreaterThan2<I: Iterator>\nwhere\n    I::Item: Ord,\n{\n    xs: RandomBTreeSetsFixedLength<I>,\n}\n\nimpl<I: Iterator> Iterator for RandomOrderedUniqueVecsFixedLengthGreaterThan2<I>\nwhere\n    I::Item: Ord,\n{\n    type Item = Vec<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        Some(self.xs.next().unwrap().into_iter().collect())\n    }\n}\n\n/// Generates random [`Vec`]s of a fixed length, where the [`Vec`]s have no repeated elements, and\n/// the elements are in ascending order.\n///\n/// This `struct` is created by [`random_ordered_unique_vecs_fixed_length`]; see its documentation\n/// for more.\n#[derive(Clone, Debug)]\npub enum RandomOrderedUniqueVecsFixedLength<I: Iterator>\nwhere\n    I::Item: Ord,\n{\n    Zero,\n    One(I),\n    Two(RandomOrderedUniqueVecsLength2<I>),\n    GreaterThan2(RandomOrderedUniqueVecsFixedLengthGreaterThan2<I>),\n}\n\nimpl<I: Iterator> Iterator for RandomOrderedUniqueVecsFixedLength<I>\nwhere\n    I::Item: Ord,\n{\n    type Item = Vec<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        match self {\n            Self::Zero => Some(vec![]),\n            Self::One(xs) => xs.next().map(|x| vec![x]),\n            Self::Two(xs) => xs.next(),\n            Self::GreaterThan2(xs) => xs.next(),\n        }\n    }\n}\n\n/// Randomly generates [`Vec`]s of a given length, where the [`Vec`]s have no repeated elements, and\n/// the elements are in ascending order.\n///\n/// The input iterator must generate at least `len` distinct elements; otherwise, this iterator will\n/// hang.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// The above formula assumes that the [`Vec`] is valid, \\emph{i.e.} its elements are strictly\n/// increasing. The probability of an invalid [`Vec`] is zero.\n///\n/// If `len` is 0, the output consists of the empty list, repeated.\n///\n/// `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_ordered_unique_vecs_fixed_length;\n///\n/// let xss = random_ordered_unique_vecs_fixed_length(\n///     2,\n///     random_unsigned_inclusive_range::<u32>(EXAMPLE_SEED, 1, 100),\n/// )\n/// .take(10)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[24, 95],\n///         &[71, 99],\n///         &[53, 93],\n///         &[34, 85],\n///         &[2, 48],\n///         &[11, 55],\n///         &[18, 48],\n///         &[90, 93],\n///         &[67, 93],\n///         &[93, 95]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_ordered_unique_vecs_fixed_length<I: Iterator>(\n    len: u64,\n    xs: I,\n) -> RandomOrderedUniqueVecsFixedLength<I>\nwhere\n    I::Item: Ord,\n{\n    match len {\n        0 => RandomOrderedUniqueVecsFixedLength::Zero,\n        1 => RandomOrderedUniqueVecsFixedLength::One(xs),\n        2 => RandomOrderedUniqueVecsFixedLength::Two(RandomOrderedUniqueVecsLength2 { xs }),\n        len => RandomOrderedUniqueVecsFixedLength::GreaterThan2(\n            RandomOrderedUniqueVecsFixedLengthGreaterThan2 {\n                xs: random_b_tree_sets_fixed_length(len, xs),\n            },\n        ),\n    }\n}\n\n/// Generates random [`Vec`]s with lengths from an iterator, where the [`Vec`]s have no repeated\n/// elements, and the elements are in ascending order.\n#[derive(Clone, Debug)]\npub struct RandomOrderedUniqueVecs<T: Ord, I: Iterator<Item = u64>, J: Iterator<Item = T>> {\n    xs: RandomBTreeSets<T, I, J>,\n}\n\nimpl<T: Ord, I: Iterator<Item = u64>, J: Iterator<Item = T>> Iterator\n    for RandomOrderedUniqueVecs<T, I, J>\n{\n    type Item = Vec<T>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<T>> {\n        Some(self.xs.next().unwrap().into_iter().collect())\n    }\n}\n\n/// Generates random [`Vec`]s using elements from an iterator and with lengths from another\n/// iterator, where the [`Vec`]s have no repeated elements, and the elements are in ascending order.\n///\n/// The input iterator must generate at least many distinct elements as any number generated by the\n/// lengths iterator; otherwise, this iterator will hang.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P(n)\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// The above formula assumes that the [`Vec`] is valid, \\emph{i.e.} its elements are strictly\n/// increasing. The probability of an invalid [`Vec`] is zero.\n///\n/// `lengths` and `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_ordered_unique_vecs_from_length_iterator;\n/// use malachite_base::vecs::random_values_from_vec;\n///\n/// let xs = random_ordered_unique_vecs_from_length_iterator(\n///     EXAMPLE_SEED,\n///     &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n///     &random_primitive_ints::<u8>,\n/// );\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[11, 85][..],\n///         &[134, 136, 200, 235],\n///         &[203, 223],\n///         &[38, 177, 217, 235],\n///         &[32, 162, 166, 234],\n///         &[30, 218],\n///         &[],\n///         &[90, 106],\n///         &[],\n///         &[9, 151, 204, 216],\n///         &[78, 97, 213, 253],\n///         &[39, 91],\n///         &[170, 175, 191, 232],\n///         &[2, 233],\n///         &[22, 35, 198, 217],\n///         &[17, 32, 114, 173],\n///         &[65, 114, 121, 222],\n///         &[],\n///         &[25, 144, 148, 173],\n///         &[]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_ordered_unique_vecs_from_length_iterator<\n    T: Ord,\n    I: Iterator<Item = u64>,\n    J: Iterator<Item = T>,\n>(\n    seed: Seed,\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n) -> RandomOrderedUniqueVecs<T, I, J> {\n    RandomOrderedUniqueVecs {\n        xs: random_b_tree_sets_from_length_iterator(seed, lengths_gen, xs_gen),\n    }\n}\n\n/// Generates random [`Vec`]s using elements from an iterator, where the [`Vec`]s have no repeated\n/// elements, and the elements are in ascending order.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P_g(n)\\prod\\_{i=0}^{n-1}P(x\\_i),\n/// $$\n/// where $P_g(n)$ is the probability function described in [`geometric_random_unsigneds`].\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_ordered_unique_vecs;\n///\n/// let xs = random_ordered_unique_vecs(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235],\n///         &[30, 90, 218, 234],\n///         &[9, 106, 204, 216],\n///         &[151],\n///         &[],\n///         &[78, 91, 97, 213, 253],\n///         &[39, 191],\n///         &[170, 175, 232, 233],\n///         &[],\n///         &[2, 22, 35, 114, 198, 217],\n///         &[],\n///         &[],\n///         &[17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222],\n///         &[52, 69, 73, 91, 115, 137, 153, 178],\n///         &[],\n///         &[34, 95, 112],\n///         &[],\n///         &[106, 130, 167, 168, 197],\n///         &[86, 101, 122, 150, 172, 177, 207, 218, 221]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_ordered_unique_vecs<I: Iterator>(\n    seed: Seed,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomOrderedUniqueVecs<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_ordered_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigneds(seed_2, mean_length_numerator, mean_length_denominator)\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with a minimum length, using elements from an iterator, where the\n/// [`Vec`]s have no repeated elements, and the elements are in ascending order.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}) = n!P_g(n)\\prod\\_{i=0}^{n-1}P(x\\_i),\n/// $$\n/// where $P_g(n)$ is the probability function described in\n/// [`geometric_random_unsigned_inclusive_range`], with $a$ equal to `min_length` and `b` to\n/// `u64::MAX`.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, if their ratio is less\n/// than or equal to `min_length`, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_ordered_unique_vecs_min_length;\n///\n/// let xs =\n///     random_ordered_unique_vecs_min_length(EXAMPLE_SEED, 2, &random_primitive_ints::<u8>, 6, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[11, 85][..],\n///         &[30, 32, 38, 90, 134, 136, 162, 166, 177, 200, 203, 217, 218, 223, 234, 235],\n///         &[9, 106, 151, 204, 213, 216],\n///         &[39, 78, 91, 97, 191, 253],\n///         &[170, 175, 232],\n///         &[2, 233],\n///         &[17, 22, 32, 35, 114, 198, 217],\n///         &[65, 114, 121, 173],\n///         &[25, 79, 144, 148, 173, 222],\n///         &[52, 115],\n///         &[34, 69, 73, 91, 112, 137, 153, 178],\n///         &[95, 106],\n///         &[167, 197],\n///         &[74, 86, 101, 115, 122, 130, 150, 168, 172, 177, 207, 218, 221],\n///         &[9, 48, 52, 109, 123, 133, 159, 201, 247, 250],\n///         &[196, 235],\n///         &[40, 68, 97, 104, 190],\n///         &[7, 216],\n///         &[11, 24, 43, 112, 157, 216, 217],\n///         &[29, 51, 55, 65, 84, 89, 103, 135, 191, 206, 211]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_ordered_unique_vecs_min_length<I: Iterator>(\n    seed: Seed,\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomOrderedUniqueVecs<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_ordered_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigned_inclusive_range(\n                seed_2,\n                min_length,\n                u64::MAX,\n                mean_length_numerator,\n                mean_length_denominator,\n            )\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with lengths in $[a, b)$, using elements from an iterator, where the\n/// [`Vec`]s have no repeated elements, and the elements are in ascending order.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b)$. $a$ must be\n/// less than $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}, a, b) = \\frac{n!}{b - a}\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_ordered_unique_vecs_length_range;\n///\n/// let xs =\n///     random_ordered_unique_vecs_length_range(EXAMPLE_SEED, 2, 5, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[11, 85, 136][..],\n///         &[134, 200, 203, 235],\n///         &[38, 223, 235],\n///         &[32, 162, 177, 217],\n///         &[30, 166, 218, 234],\n///         &[9, 90, 106],\n///         &[204, 216],\n///         &[97, 151, 213],\n///         &[78, 253],\n///         &[39, 91, 175, 191],\n///         &[2, 170, 232, 233],\n///         &[22, 35, 217],\n///         &[17, 32, 114, 198],\n///         &[65, 114, 173],\n///         &[25, 121, 173, 222],\n///         &[79, 115, 144, 148],\n///         &[52, 69, 73, 137],\n///         &[91, 153],\n///         &[34, 95, 112, 178],\n///         &[106, 167]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_ordered_unique_vecs_length_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomOrderedUniqueVecs<I::Item, RandomUnsignedRange<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_ordered_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with lengths in $[a, b]$, using elements from an iterator, where the\n/// [`Vec`]s have no repeated elements, and the elements are in ascending order.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b]$. $a$ must be\n/// less than or equal to $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// $$\n/// P((x\\_i)\\_{i=0}^{n-1}, a, b) = \\frac{n!}{b - a + 1}\\prod\\_{i=0}^{n-1}P(x\\_i).\n/// $$\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_ordered_unique_vecs_length_inclusive_range;\n///\n/// let xs = random_ordered_unique_vecs_length_inclusive_range(\n///     EXAMPLE_SEED,\n///     2,\n///     4,\n///     &random_primitive_ints::<u8>,\n/// );\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[11, 85, 136][..],\n///         &[134, 200, 203, 235],\n///         &[38, 223, 235],\n///         &[32, 162, 177, 217],\n///         &[30, 166, 218, 234],\n///         &[9, 90, 106],\n///         &[204, 216],\n///         &[97, 151, 213],\n///         &[78, 253],\n///         &[39, 91, 175, 191],\n///         &[2, 170, 232, 233],\n///         &[22, 35, 217],\n///         &[17, 32, 114, 198],\n///         &[65, 114, 173],\n///         &[25, 121, 173, 222],\n///         &[79, 115, 144, 148],\n///         &[52, 69, 73, 137],\n///         &[91, 153],\n///         &[34, 95, 112, 178],\n///         &[106, 167]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_ordered_unique_vecs_length_inclusive_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomOrderedUniqueVecs<I::Item, RandomUnsignedInclusiveRange<u64>, I>\nwhere\n    I::Item: Ord,\n{\n    random_ordered_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_inclusive_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct RandomUniqueVecsLength2<I: Iterator>\nwhere\n    I::Item: Eq,\n{\n    xs: I,\n}\n\nimpl<I: Iterator> Iterator for RandomUniqueVecsLength2<I>\nwhere\n    I::Item: Eq,\n{\n    type Item = Vec<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        let mut out = Vec::with_capacity(2);\n        loop {\n            let x = self.xs.next().unwrap();\n            if out.is_empty() {\n                out.push(x);\n            } else if x != out[0] {\n                out.push(x);\n                return Some(out);\n            }\n        }\n    }\n}\n\n/// Generates random [`Vec`]s with lengths from an iterator, where the [`Vec`]s have no repeated\n/// elements.\n#[derive(Clone, Debug)]\npub struct RandomUniqueVecs<T: Eq + Hash, I: Iterator<Item = u64>, J: Iterator<Item = T>> {\n    lengths: I,\n    xs: J,\n}\n\nimpl<T: Eq + Hash, I: Iterator<Item = u64>, J: Iterator<Item = T>> Iterator\n    for RandomUniqueVecs<T, I, J>\n{\n    type Item = Vec<T>;\n\n    fn next(&mut self) -> Option<Vec<T>> {\n        // We avoid cloning the T values. We first move them into a HashMap, then into a\n        // Vec<Option<T>>, then into the output Vec<T>.\n        let len = usize::exact_from(self.lengths.next().unwrap());\n        let mut xs_to_indices = HashMap::with_capacity(len);\n        let mut i = 0;\n        while i < len {\n            xs_to_indices\n                .entry(self.xs.next().unwrap())\n                .or_insert_with(|| {\n                    i += 1;\n                    i - 1\n                });\n        }\n        let mut out = Vec::with_capacity(len);\n        out.resize_with(len, || None);\n        for (x, i) in xs_to_indices {\n            out[i] = Some(x);\n        }\n        Some(out.into_iter().map(Option::unwrap).collect())\n    }\n}\n\n/// Generates random [`Vec`]s using elements from an iterator and with lengths from another\n/// iterator, where the [`Vec`]s have no repeated elements.\n///\n/// The input iterator must generate at least many distinct elements as any number generated by the\n/// lengths iterator; otherwise, this iterator will hang.\n///\n/// `lengths` and `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_unique_vecs_from_length_iterator;\n/// use malachite_base::vecs::random_values_from_vec;\n///\n/// let xs = random_unique_vecs_from_length_iterator(\n///     EXAMPLE_SEED,\n///     &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n///     &random_primitive_ints::<u8>,\n/// );\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11][..],\n///         &[136, 200, 235, 134],\n///         &[203, 223],\n///         &[38, 235, 217, 177],\n///         &[162, 32, 166, 234],\n///         &[30, 218],\n///         &[],\n///         &[90, 106],\n///         &[],\n///         &[9, 216, 204, 151],\n///         &[213, 97, 253, 78],\n///         &[91, 39],\n///         &[191, 175, 170, 232],\n///         &[233, 2],\n///         &[35, 22, 217, 198],\n///         &[114, 17, 32, 173],\n///         &[114, 65, 121, 222],\n///         &[],\n///         &[173, 25, 144, 148],\n///         &[]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_unique_vecs_from_length_iterator<\n    T: Eq + Hash,\n    I: Iterator<Item = u64>,\n    J: Iterator<Item = T>,\n>(\n    seed: Seed,\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n) -> RandomUniqueVecs<T, I, J> {\n    RandomUniqueVecs {\n        lengths: lengths_gen(seed.fork(\"lengths\")),\n        xs: xs_gen(seed.fork(\"xs\")),\n    }\n}\n\n/// Generates random [`Vec`]s of a fixed length, where the [`Vec`]s have no repeated elements.\n///\n/// This `enum` is created by [`random_unique_vecs_fixed_length`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub enum RandomUniqueVecsFixedLength<I: Iterator>\nwhere\n    I::Item: Eq + Hash,\n{\n    Zero,\n    One(I),\n    Two(RandomUniqueVecsLength2<I>),\n    GreaterThan2(RandomUniqueVecs<I::Item, Repeat<u64>, I>),\n}\n\nimpl<I: Iterator> Iterator for RandomUniqueVecsFixedLength<I>\nwhere\n    I::Item: Eq + Hash,\n{\n    type Item = Vec<I::Item>;\n\n    #[inline]\n    fn next(&mut self) -> Option<Vec<I::Item>> {\n        match self {\n            Self::Zero => Some(vec![]),\n            Self::One(xs) => xs.next().map(|x| vec![x]),\n            Self::Two(xs) => xs.next(),\n            Self::GreaterThan2(xs) => xs.next(),\n        }\n    }\n}\n\n/// Randomly generates [`Vec`]s of a given length, where the [`Vec`]s have no repeated elements.\n///\n/// The input iterator must generate at least `len` distinct elements; otherwise, this iterator will\n/// hang.\n///\n/// If `len` is 0, the output consists of the empty list, repeated.\n///\n/// `xs` must be infinite.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_unsigned_inclusive_range;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_unique_vecs_fixed_length;\n///\n/// let xss = random_unique_vecs_fixed_length(\n///     2,\n///     random_unsigned_inclusive_range::<u32>(EXAMPLE_SEED, 1, 100),\n/// )\n/// .take(10)\n/// .collect_vec();\n/// assert_eq!(\n///     xss.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[95, 24],\n///         &[99, 71],\n///         &[93, 53],\n///         &[85, 34],\n///         &[48, 2],\n///         &[55, 11],\n///         &[48, 18],\n///         &[90, 93],\n///         &[67, 93],\n///         &[93, 95]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_unique_vecs_fixed_length<I: Iterator>(\n    len: u64,\n    xs: I,\n) -> RandomUniqueVecsFixedLength<I>\nwhere\n    I::Item: Eq + Hash,\n{\n    match len {\n        0 => RandomUniqueVecsFixedLength::Zero,\n        1 => RandomUniqueVecsFixedLength::One(xs),\n        2 => RandomUniqueVecsFixedLength::Two(RandomUniqueVecsLength2 { xs }),\n        len => RandomUniqueVecsFixedLength::GreaterThan2(RandomUniqueVecs {\n            lengths: repeat(len),\n            xs,\n        }),\n    }\n}\n\n/// Generates random [`Vec`]s using elements from an iterator, where the [`Vec`]s have no repeated\n/// elements.\n///\n/// The lengths of the [`Vec`]s are sampled from a geometric distribution with a specified mean $m$,\n/// equal to `mean_length_numerator / mean_length_denominator`. $m$ must be greater than 0.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, or, if after being\n/// reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_unique_vecs;\n///\n/// let xs = random_unique_vecs(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[][..],\n///         &[85, 11, 136, 200, 235, 134, 203, 223, 38, 217, 177, 162, 32, 166],\n///         &[234, 30, 218, 90],\n///         &[106, 9, 216, 204],\n///         &[151],\n///         &[],\n///         &[213, 97, 253, 78, 91],\n///         &[39, 191],\n///         &[175, 170, 232, 233],\n///         &[],\n///         &[2, 35, 22, 217, 198, 114],\n///         &[],\n///         &[],\n///         &[17, 32, 173, 114, 65, 121, 222, 25, 144, 148, 79],\n///         &[115, 52, 73, 69, 137, 91, 153, 178],\n///         &[],\n///         &[112, 34, 95],\n///         &[],\n///         &[106, 167, 197, 130, 168],\n///         &[122, 207, 172, 177, 86, 150, 221, 218, 101]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_unique_vecs<I: Iterator>(\n    seed: Seed,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomUniqueVecs<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigneds(seed_2, mean_length_numerator, mean_length_denominator)\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with a minimum length, using elements from an iterator, where the\n/// [`Vec`]s have no repeated elements.\n///\n/// Strictly speaking, the input iterator must generate infinitely many distinct elements. In\n/// practice it only needs to generate $k$ distinct elements, where $k$ is the largest length\n/// actually sampled from the geometric distribution. For example, if `mean_length_numerator /\n/// mean_length_denominator` is significantly lower than 256, then it's ok to use\n/// `random_unsigneds::<u8>`.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if `mean_length_numerator` or `mean_length_denominator` are zero, if their ratio is less\n/// than or equal to `min_length`, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_unique_vecs_min_length;\n///\n/// let xs = random_unique_vecs_min_length(EXAMPLE_SEED, 2, &random_primitive_ints::<u8>, 6, 1);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11][..],\n///         &[136, 200, 235, 134, 203, 223, 38, 217, 177, 162, 32, 166, 234, 30, 218, 90],\n///         &[106, 9, 216, 204, 151, 213],\n///         &[97, 253, 78, 91, 39, 191],\n///         &[175, 170, 232],\n///         &[233, 2],\n///         &[35, 22, 217, 198, 114, 17, 32],\n///         &[173, 114, 65, 121],\n///         &[222, 173, 25, 144, 148, 79],\n///         &[115, 52],\n///         &[73, 69, 137, 91, 153, 178, 112, 34],\n///         &[95, 106],\n///         &[167, 197],\n///         &[130, 168, 122, 207, 172, 177, 86, 150, 221, 218, 101, 115, 74],\n///         &[9, 123, 109, 52, 201, 159, 247, 250, 48, 133],\n///         &[235, 196],\n///         &[40, 97, 104, 68, 190],\n///         &[216, 7],\n///         &[216, 157, 43, 112, 217, 24, 11],\n///         &[103, 211, 84, 135, 55, 29, 206, 89, 65, 191, 51]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_unique_vecs_min_length<I: Iterator>(\n    seed: Seed,\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n) -> RandomUniqueVecs<I::Item, GeometricRandomNaturalValues<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| {\n            geometric_random_unsigned_inclusive_range(\n                seed_2,\n                min_length,\n                u64::MAX,\n                mean_length_numerator,\n                mean_length_denominator,\n            )\n        },\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with lengths in $[a, b)$, using elements from an iterator, where the\n/// [`Vec`]s have no repeated elements.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b)$. $a$ must be\n/// less than $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_unique_vecs_length_range;\n///\n/// let xs = random_unique_vecs_length_range(EXAMPLE_SEED, 2, 5, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11, 136][..],\n///         &[200, 235, 134, 203],\n///         &[223, 38, 235],\n///         &[217, 177, 162, 32],\n///         &[166, 234, 30, 218],\n///         &[90, 106, 9],\n///         &[216, 204],\n///         &[151, 213, 97],\n///         &[253, 78],\n///         &[91, 39, 191, 175],\n///         &[170, 232, 233, 2],\n///         &[35, 22, 217],\n///         &[198, 114, 17, 32],\n///         &[173, 114, 65],\n///         &[121, 222, 173, 25],\n///         &[144, 148, 79, 115],\n///         &[52, 73, 69, 137],\n///         &[91, 153],\n///         &[178, 112, 34, 95],\n///         &[106, 167]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_unique_vecs_length_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomUniqueVecs<I::Item, RandomUnsignedRange<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n\n/// Generates random [`Vec`]s with lengths in $[a, b]$, using elements from an iterator, where the\n/// [`Vec`]s have no repeated elements.\n///\n/// The lengths of the [`Vec`]s are sampled from a uniform distribution on $[a, b]$. $a$ must be\n/// less than or equal to $b$.\n///\n/// The input iterator must generate at least $b$ distinct elements.\n///\n/// `xs_gen` must be infinite.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::vecs::random::random_unique_vecs_length_inclusive_range;\n///\n/// let xs =\n///     random_unique_vecs_length_inclusive_range(EXAMPLE_SEED, 2, 4, &random_primitive_ints::<u8>);\n/// let values = xs.take(20).collect_vec();\n/// assert_eq!(\n///     values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n///     &[\n///         &[85, 11, 136][..],\n///         &[200, 235, 134, 203],\n///         &[223, 38, 235],\n///         &[217, 177, 162, 32],\n///         &[166, 234, 30, 218],\n///         &[90, 106, 9],\n///         &[216, 204],\n///         &[151, 213, 97],\n///         &[253, 78],\n///         &[91, 39, 191, 175],\n///         &[170, 232, 233, 2],\n///         &[35, 22, 217],\n///         &[198, 114, 17, 32],\n///         &[173, 114, 65],\n///         &[121, 222, 173, 25],\n///         &[144, 148, 79, 115],\n///         &[52, 73, 69, 137],\n///         &[91, 153],\n///         &[178, 112, 34, 95],\n///         &[106, 167]\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_unique_vecs_length_inclusive_range<I: Iterator>(\n    seed: Seed,\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n) -> RandomUniqueVecs<I::Item, RandomUnsignedInclusiveRange<u64>, I>\nwhere\n    I::Item: Eq + Hash,\n{\n    random_unique_vecs_from_length_iterator(\n        seed,\n        &|seed_2| random_unsigned_inclusive_range(seed_2, a, b),\n        xs_gen,\n    )\n}\n"
  },
  {
    "path": "malachite-base/tests/bools/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::comparison::traits::{Max, Min};\nuse malachite_base::named::Named;\n\n#[test]\nfn test_min() {\n    assert_eq!(bool::MIN, false);\n}\n\n#[test]\nfn test_max() {\n    assert_eq!(bool::MAX, true);\n}\n\n#[test]\npub fn test_named() {\n    assert_eq!(bool::NAME, \"bool\");\n}\n"
  },
  {
    "path": "malachite-base/tests/bools/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\n\n#[test]\nfn test_exhaustive_bools() {\n    assert_eq!(exhaustive_bools().collect_vec(), &[false, true]);\n}\n"
  },
  {
    "path": "malachite-base/tests/bools/not_assign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::NotAssign;\nuse malachite_base::test_util::generators::bool_gen;\n\n#[test]\nfn test_not_assign() {\n    let test = |mut b: bool, out| {\n        b.not_assign();\n        assert_eq!(b, out);\n    };\n    test(false, true);\n    test(true, false);\n}\n\n#[test]\nfn not_assign_properties() {\n    bool_gen().test_properties(|b| {\n        let mut mut_b = b;\n        mut_b.not_assign();\n        assert_ne!(mut_b, b);\n        assert_eq!(mut_b, !b);\n        mut_b.not_assign();\n        assert_eq!(mut_b, b);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/bools/random/get_weighted_random_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::random::get_weighted_random_bool;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::random::EXAMPLE_SEED;\n\nfn get_weighted_random_bool_helper(n: u64, d: u64, out: bool) {\n    assert_eq!(\n        get_weighted_random_bool(&mut VariableRangeGenerator::new(EXAMPLE_SEED), n, d),\n        out\n    );\n}\n\n#[test]\nfn test_get_weighted_random_bool() {\n    get_weighted_random_bool_helper(0, 1, false);\n    get_weighted_random_bool_helper(1, 1, true);\n    get_weighted_random_bool_helper(1, 2, false);\n    get_weighted_random_bool_helper(1, 100, false);\n    get_weighted_random_bool_helper(99, 100, true);\n}\n\n#[test]\n#[should_panic]\nfn get_weighted_random_bool_fail_1() {\n    get_weighted_random_bool(&mut VariableRangeGenerator::new(EXAMPLE_SEED), 0, 0);\n}\n\n#[test]\n#[should_panic]\nfn get_weighted_random_bool_fail_2() {\n    get_weighted_random_bool(&mut VariableRangeGenerator::new(EXAMPLE_SEED), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn get_weighted_random_bool_fail_3() {\n    get_weighted_random_bool(&mut VariableRangeGenerator::new(EXAMPLE_SEED), 2, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/bools/random/random_bools.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{MomentStats, uniform_bool_assertions};\n\n#[test]\nfn test_random_bools() {\n    uniform_bool_assertions(\n        random_bools(EXAMPLE_SEED),\n        false,\n        true,\n        &[\n            true, false, false, false, true, true, true, false, true, true, true, true, false,\n            true, true, true, true, false, true, false,\n        ],\n        &[(true, 500473), (false, 499527)],\n        (false, Some(true)),\n        (true, None),\n        MomentStats {\n            mean: NiceFloat(0.5),\n            standard_deviation: NiceFloat(0.5),\n            skewness: NiceFloat(0.0),\n            excess_kurtosis: NiceFloat(-1.9999999999999998),\n        },\n        MomentStats {\n            mean: NiceFloat(0.5004730000000077),\n            standard_deviation: NiceFloat(0.5000000262710417),\n            skewness: NiceFloat(-0.0018920008465908307),\n            excess_kurtosis: NiceFloat(-1.999996420332894),\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/bools/random/weighted_random_bools.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::bools::random::weighted_random_bools;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\n\nfn weighted_random_bools_helper(\n    p_numerator: u64,\n    p_denominator: u64,\n    expected_values: &[bool],\n    expected_common_values: &[(bool, usize)],\n    expected_median: (bool, Option<bool>),\n) {\n    let xs = weighted_random_bools(EXAMPLE_SEED, p_numerator, p_denominator);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_weighted_random_bools() {\n    // p = 0\n    weighted_random_bools_helper(0, 1, &[false; 20], &[(false, 1000000)], (false, None));\n    // p = 1\n    weighted_random_bools_helper(1, 1, &[true; 20], &[(true, 1000000)], (true, None));\n    // p = 1/2\n    weighted_random_bools_helper(\n        1,\n        2,\n        &[\n            false, true, true, true, false, false, false, true, false, false, false, false, true,\n            false, false, false, false, true, false, true,\n        ],\n        &[(false, 500473), (true, 499527)],\n        (false, None),\n    );\n    // p = 1/51\n    weighted_random_bools_helper(\n        1,\n        51,\n        &[\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false,\n        ],\n        &[(false, 980406), (true, 19594)],\n        (false, None),\n    );\n    // w = 50/51\n    weighted_random_bools_helper(\n        50,\n        51,\n        &[\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, false, true, true, true,\n        ],\n        &[(true, 980602), (false, 19398)],\n        (true, None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn weighted_random_bools_fail_1() {\n    weighted_random_bools(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn weighted_random_bools_fail_2() {\n    weighted_random_bools(EXAMPLE_SEED, 2, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/char_type.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::CharType;\nuse malachite_base::chars::exhaustive::chars_increasing;\nuse std::collections::HashSet;\n\n#[test]\nfn test_char_type() {\n    let char_types = [\n        CharType::AsciiLower,\n        CharType::AsciiUpper,\n        CharType::AsciiNumeric,\n        CharType::AsciiNonAlphanumericGraphic,\n        CharType::NonAsciiGraphic,\n        CharType::NonGraphic,\n    ];\n    let mut remaining_chars: HashSet<_> = chars_increasing().collect();\n    let mut n = remaining_chars.len();\n    let mut frequencies = Vec::new();\n    for &char_type in &char_types {\n        remaining_chars.retain(|&c| !char_type.contains(c));\n        let frequency = n - remaining_chars.len();\n        n = remaining_chars.len();\n        frequencies.push((char_type, frequency));\n    }\n    assert_eq!(n, 0);\n    assert_eq!(\n        frequencies,\n        &[\n            (CharType::AsciiLower, 26),\n            (CharType::AsciiUpper, 26),\n            (CharType::AsciiNumeric, 10),\n            (CharType::AsciiNonAlphanumericGraphic, 33),\n            (CharType::NonAsciiGraphic, 157383),\n            (CharType::NonGraphic, 954586)\n        ]\n    );\n\n    let first_chars = char_types.iter().map(|&char_type| {\n        (\n            char_type,\n            chars_increasing().find(|&c| char_type.contains(c)).unwrap(),\n        )\n    });\n    assert_eq!(\n        first_chars.collect_vec(),\n        &[\n            (CharType::AsciiLower, 'a'),\n            (CharType::AsciiUpper, 'A'),\n            (CharType::AsciiNumeric, '0'),\n            (CharType::AsciiNonAlphanumericGraphic, ' '),\n            (CharType::NonAsciiGraphic, '¡'),\n            (CharType::NonGraphic, '\\u{0}')\n        ]\n    );\n\n    let last_chars = char_types.iter().map(|&char_type| {\n        (\n            char_type,\n            chars_increasing()\n                .rev()\n                .find(|&c| char_type.contains(c))\n                .unwrap(),\n        )\n    });\n    assert_eq!(\n        last_chars.collect_vec(),\n        &[\n            (CharType::AsciiLower, 'z'),\n            (CharType::AsciiUpper, 'Z'),\n            (CharType::AsciiNumeric, '9'),\n            (CharType::AsciiNonAlphanumericGraphic, '~'),\n            (CharType::NonAsciiGraphic, '𳑹'),\n            (CharType::NonGraphic, '\\u{10ffff}')\n        ]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\n\n#[test]\nfn test_min() {\n    assert_eq!(char::MIN, '\\u{0}');\n}\n\n#[test]\nfn test_max() {\n    assert_eq!(char::MAX, '\\u{10ffff}');\n}\n\n#[test]\npub fn test_named() {\n    assert_eq!(bool::NAME, \"bool\");\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/crement/char_to_contiguous_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::constants::{\n    CHAR_JUST_ABOVE_SURROGATES, CHAR_JUST_BELOW_SURROGATES, NUMBER_OF_CHARS,\n};\nuse malachite_base::chars::crement::{char_to_contiguous_range, contiguous_range_to_char};\nuse malachite_base::test_util::generators::{char_gen, char_pair_gen};\n\n#[test]\nfn test_char_to_contiguous_range() {\n    let test = |c, out| {\n        assert_eq!(char_to_contiguous_range(c), out);\n    };\n    test('\\u{0}', 0);\n    test('a', 97);\n    test('A', 65);\n    test(CHAR_JUST_BELOW_SURROGATES, 55295);\n    test(CHAR_JUST_ABOVE_SURROGATES, 55296);\n    test(char::MAX, 1112063);\n}\n\n#[test]\nfn char_to_contiguous_range_properties() {\n    char_gen().test_properties_no_exhaustive_limit(|c| {\n        let u = char_to_contiguous_range(c);\n        assert_eq!(contiguous_range_to_char(u), Some(c));\n        assert!(u < NUMBER_OF_CHARS);\n    });\n\n    char_pair_gen().test_properties(|(c, d)| {\n        assert_eq!(\n            c.cmp(&d),\n            char_to_contiguous_range(c).cmp(&char_to_contiguous_range(d))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/crement/contiguous_range_to_char.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::constants::{\n    CHAR_JUST_ABOVE_SURROGATES, CHAR_JUST_BELOW_SURROGATES, NUMBER_OF_CHARS,\n};\nuse malachite_base::chars::crement::{char_to_contiguous_range, contiguous_range_to_char};\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_2, unsigned_pair_gen_var_1,\n};\n\n#[test]\nfn test_contiguous_range_to_char() {\n    let test = |u, out| {\n        assert_eq!(contiguous_range_to_char(u), out);\n    };\n    test(0, Some('\\u{0}'));\n    test(97, Some('a'));\n    test(65, Some('A'));\n    test(55295, Some(CHAR_JUST_BELOW_SURROGATES));\n    test(55296, Some(CHAR_JUST_ABOVE_SURROGATES));\n    test(NUMBER_OF_CHARS - 1, Some(char::MAX));\n    test(NUMBER_OF_CHARS, None);\n    test(u32::MAX, None);\n}\n\n#[test]\nfn contiguous_range_to_char_properties() {\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(contiguous_range_to_char(u).is_some(), u < NUMBER_OF_CHARS);\n    });\n\n    unsigned_gen_var_2().test_properties(|u| {\n        assert_eq!(\n            char_to_contiguous_range(contiguous_range_to_char(u).unwrap()),\n            u\n        );\n    });\n\n    unsigned_pair_gen_var_1().test_properties(|(u, v)| {\n        assert_eq!(\n            u.cmp(&v),\n            contiguous_range_to_char(u).cmp(&contiguous_range_to_char(v))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/crement/crement.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::constants::{CHAR_JUST_ABOVE_SURROGATES, CHAR_JUST_BELOW_SURROGATES};\nuse malachite_base::chars::crement::{decrement_char, increment_char};\nuse malachite_base::test_util::generators::{char_gen_var_1, char_gen_var_2};\n\n#[test]\nfn test_increment_char() {\n    let test = |mut c: char, out| {\n        increment_char(&mut c);\n        assert_eq!(c, out);\n    };\n    test('\\u{0}', '\\u{1}');\n    test('a', 'b');\n    test('A', 'B');\n    test(CHAR_JUST_BELOW_SURROGATES, CHAR_JUST_ABOVE_SURROGATES);\n    test('\\u{10fffe}', char::MAX);\n}\n\n#[test]\n#[should_panic]\nfn increment_char_fail() {\n    let mut c = char::MAX;\n    increment_char(&mut c);\n}\n\n#[test]\nfn test_decrement_char() {\n    let test = |mut c: char, out| {\n        decrement_char(&mut c);\n        assert_eq!(c, out);\n    };\n    test('\\u{1}', '\\u{0}');\n    test('b', 'a');\n    test('B', 'A');\n    test(CHAR_JUST_ABOVE_SURROGATES, CHAR_JUST_BELOW_SURROGATES);\n    test(char::MAX, '\\u{10fffe}');\n}\n\n#[test]\n#[should_panic]\nfn decrement_char_fail() {\n    let mut c = '\\u{0}';\n    decrement_char(&mut c);\n}\n\n#[test]\nfn increment_char_properties() {\n    char_gen_var_1().test_properties_no_exhaustive_limit(|c| {\n        let mut mut_c = c;\n        increment_char(&mut mut_c);\n        assert_ne!(mut_c, c);\n        decrement_char(&mut mut_c);\n        assert_eq!(mut_c, c);\n    });\n}\n\n#[test]\nfn decrement_char_properties() {\n    char_gen_var_2().test_properties_no_exhaustive_limit(|c| {\n        let mut mut_c = c;\n        decrement_char(&mut mut_c);\n        assert_ne!(mut_c, c);\n        increment_char(&mut mut_c);\n        assert_eq!(mut_c, c);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/exhaustive/ascii_chars_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::exhaustive::ascii_chars_increasing;\n\n#[test]\nfn test_ascii_chars_increasing() {\n    assert_eq!(\n        ascii_chars_increasing().collect::<String>(),\n        \"\\u{0}\\u{1}\\u{2}\\u{3}\\u{4}\\u{5}\\u{6}\\u{7}\\u{8}\\t\\n\\u{b}\\u{c}\\r\\u{e}\\u{f}\\u{10}\\u{11}\\u{12}\\\n        \\u{13}\\u{14}\\u{15}\\u{16}\\u{17}\\u{18}\\u{19}\\u{1a}\\u{1b}\\u{1c}\\u{1d}\\u{1e}\\u{1f} !\\\"#$%&\\'()*\\\n        +,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u{7f}\"\n    );\n    assert_eq!(ascii_chars_increasing().count(), 1 << 7);\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/exhaustive/chars_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::constants::NUMBER_OF_CHARS;\nuse malachite_base::chars::exhaustive::chars_increasing;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\n#[test]\nfn test_chars_increasing() {\n    assert_eq!(\n        chars_increasing().take(200).collect::<String>(),\n        \"\\u{0}\\u{1}\\u{2}\\u{3}\\u{4}\\u{5}\\u{6}\\u{7}\\u{8}\\t\\n\\u{b}\\u{c}\\r\\u{e}\\u{f}\\u{10}\\u{11}\\u{12}\\\n        \\u{13}\\u{14}\\u{15}\\u{16}\\u{17}\\u{18}\\u{19}\\u{1a}\\u{1b}\\u{1c}\\u{1d}\\u{1e}\\u{1f} !\\\"#$%&\\'()*\\\n        +,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\u{7f}\\\n        \\u{80}\\u{81}\\u{82}\\u{83}\\u{84}\\u{85}\\u{86}\\u{87}\\u{88}\\u{89}\\u{8a}\\u{8b}\\u{8c}\\u{8d}\\u{8e}\\\n        \\u{8f}\\u{90}\\u{91}\\u{92}\\u{93}\\u{94}\\u{95}\\u{96}\\u{97}\\u{98}\\u{99}\\u{9a}\\u{9b}\\u{9c}\\u{9d}\\\n        \\u{9e}\\u{9f}\\u{a0}¡¢£¤¥¦§¨©ª«¬\\u{ad}®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇ\"\n    );\n    assert_eq!(\n        chars_increasing().rev().take(200).collect::<String>(),\n        \"\\u{10ffff}\\u{10fffe}\\u{10fffd}\\u{10fffc}\\u{10fffb}\\u{10fffa}\\u{10fff9}\\u{10fff8}\\u{10fff7}\\\n        \\u{10fff6}\\u{10fff5}\\u{10fff4}\\u{10fff3}\\u{10fff2}\\u{10fff1}\\u{10fff0}\\u{10ffef}\\u{10ffee}\\\n        \\u{10ffed}\\u{10ffec}\\u{10ffeb}\\u{10ffea}\\u{10ffe9}\\u{10ffe8}\\u{10ffe7}\\u{10ffe6}\\u{10ffe5}\\\n        \\u{10ffe4}\\u{10ffe3}\\u{10ffe2}\\u{10ffe1}\\u{10ffe0}\\u{10ffdf}\\u{10ffde}\\u{10ffdd}\\u{10ffdc}\\\n        \\u{10ffdb}\\u{10ffda}\\u{10ffd9}\\u{10ffd8}\\u{10ffd7}\\u{10ffd6}\\u{10ffd5}\\u{10ffd4}\\u{10ffd3}\\\n        \\u{10ffd2}\\u{10ffd1}\\u{10ffd0}\\u{10ffcf}\\u{10ffce}\\u{10ffcd}\\u{10ffcc}\\u{10ffcb}\\u{10ffca}\\\n        \\u{10ffc9}\\u{10ffc8}\\u{10ffc7}\\u{10ffc6}\\u{10ffc5}\\u{10ffc4}\\u{10ffc3}\\u{10ffc2}\\u{10ffc1}\\\n        \\u{10ffc0}\\u{10ffbf}\\u{10ffbe}\\u{10ffbd}\\u{10ffbc}\\u{10ffbb}\\u{10ffba}\\u{10ffb9}\\u{10ffb8}\\\n        \\u{10ffb7}\\u{10ffb6}\\u{10ffb5}\\u{10ffb4}\\u{10ffb3}\\u{10ffb2}\\u{10ffb1}\\u{10ffb0}\\u{10ffaf}\\\n        \\u{10ffae}\\u{10ffad}\\u{10ffac}\\u{10ffab}\\u{10ffaa}\\u{10ffa9}\\u{10ffa8}\\u{10ffa7}\\u{10ffa6}\\\n        \\u{10ffa5}\\u{10ffa4}\\u{10ffa3}\\u{10ffa2}\\u{10ffa1}\\u{10ffa0}\\u{10ff9f}\\u{10ff9e}\\u{10ff9d}\\\n        \\u{10ff9c}\\u{10ff9b}\\u{10ff9a}\\u{10ff99}\\u{10ff98}\\u{10ff97}\\u{10ff96}\\u{10ff95}\\u{10ff94}\\\n        \\u{10ff93}\\u{10ff92}\\u{10ff91}\\u{10ff90}\\u{10ff8f}\\u{10ff8e}\\u{10ff8d}\\u{10ff8c}\\u{10ff8b}\\\n        \\u{10ff8a}\\u{10ff89}\\u{10ff88}\\u{10ff87}\\u{10ff86}\\u{10ff85}\\u{10ff84}\\u{10ff83}\\u{10ff82}\\\n        \\u{10ff81}\\u{10ff80}\\u{10ff7f}\\u{10ff7e}\\u{10ff7d}\\u{10ff7c}\\u{10ff7b}\\u{10ff7a}\\u{10ff79}\\\n        \\u{10ff78}\\u{10ff77}\\u{10ff76}\\u{10ff75}\\u{10ff74}\\u{10ff73}\\u{10ff72}\\u{10ff71}\\u{10ff70}\\\n        \\u{10ff6f}\\u{10ff6e}\\u{10ff6d}\\u{10ff6c}\\u{10ff6b}\\u{10ff6a}\\u{10ff69}\\u{10ff68}\\u{10ff67}\\\n        \\u{10ff66}\\u{10ff65}\\u{10ff64}\\u{10ff63}\\u{10ff62}\\u{10ff61}\\u{10ff60}\\u{10ff5f}\\u{10ff5e}\\\n        \\u{10ff5d}\\u{10ff5c}\\u{10ff5b}\\u{10ff5a}\\u{10ff59}\\u{10ff58}\\u{10ff57}\\u{10ff56}\\u{10ff55}\\\n        \\u{10ff54}\\u{10ff53}\\u{10ff52}\\u{10ff51}\\u{10ff50}\\u{10ff4f}\\u{10ff4e}\\u{10ff4d}\\u{10ff4c}\\\n        \\u{10ff4b}\\u{10ff4a}\\u{10ff49}\\u{10ff48}\\u{10ff47}\\u{10ff46}\\u{10ff45}\\u{10ff44}\\u{10ff43}\\\n        \\u{10ff42}\\u{10ff41}\\u{10ff40}\\u{10ff3f}\\u{10ff3e}\\u{10ff3d}\\u{10ff3c}\\u{10ff3b}\\u{10ff3a}\\\n        \\u{10ff39}\\u{10ff38}\"\n    );\n    assert_eq!(\n        chars_increasing().count(),\n        usize::exact_from(NUMBER_OF_CHARS)\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/exhaustive/exhaustive_ascii_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\n\n#[test]\nfn test_exhaustive_ascii_chars() {\n    assert_eq!(\n        exhaustive_ascii_chars().collect::<String>(),\n        \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !\\\"#$%&\\'()*+,-./:;<=>?@[\\\\\\\n        ]^_`{|}~\\u{0}\\u{1}\\u{2}\\u{3}\\u{4}\\u{5}\\u{6}\\u{7}\\u{8}\\t\\n\\u{b}\\u{c}\\r\\u{e}\\u{f}\\u{10}\\u{11}\\\n        \\u{12}\\u{13}\\u{14}\\u{15}\\u{16}\\u{17}\\u{18}\\u{19}\\u{1a}\\u{1b}\\u{1c}\\u{1d}\\u{1e}\\u{1f}\\u{7f}\"\n    );\n    assert_eq!(exhaustive_ascii_chars().count(), 1 << 7);\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/exhaustive/exhaustive_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::constants::NUMBER_OF_CHARS;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\n#[test]\nfn test_exhaustive_chars() {\n    assert_eq!(\n        exhaustive_chars().take(200).collect::<String>(),\n        \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !\\\"#$%&\\'()*+,-./:;<=>?@[\\\\\\\n        ]^_`{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóô\\\n        õö÷øùúûüýþÿĀāĂăĄąĆćĈĉĊ\"\n    );\n    assert_eq!(\n        exhaustive_chars().count(),\n        usize::exact_from(NUMBER_OF_CHARS)\n    );\n    let mut chars = exhaustive_chars()\n        .skip(usize::exact_from(NUMBER_OF_CHARS) - 200)\n        .collect_vec();\n    chars.reverse();\n    assert_eq!(\n        chars.iter().collect::<String>(),\n        \"\\u{10ffff}\\u{10fffe}\\u{10fffd}\\u{10fffc}\\u{10fffb}\\u{10fffa}\\u{10fff9}\\u{10fff8}\\u{10fff7}\\\n        \\u{10fff6}\\u{10fff5}\\u{10fff4}\\u{10fff3}\\u{10fff2}\\u{10fff1}\\u{10fff0}\\u{10ffef}\\u{10ffee}\\\n        \\u{10ffed}\\u{10ffec}\\u{10ffeb}\\u{10ffea}\\u{10ffe9}\\u{10ffe8}\\u{10ffe7}\\u{10ffe6}\\u{10ffe5}\\\n        \\u{10ffe4}\\u{10ffe3}\\u{10ffe2}\\u{10ffe1}\\u{10ffe0}\\u{10ffdf}\\u{10ffde}\\u{10ffdd}\\u{10ffdc}\\\n        \\u{10ffdb}\\u{10ffda}\\u{10ffd9}\\u{10ffd8}\\u{10ffd7}\\u{10ffd6}\\u{10ffd5}\\u{10ffd4}\\u{10ffd3}\\\n        \\u{10ffd2}\\u{10ffd1}\\u{10ffd0}\\u{10ffcf}\\u{10ffce}\\u{10ffcd}\\u{10ffcc}\\u{10ffcb}\\u{10ffca}\\\n        \\u{10ffc9}\\u{10ffc8}\\u{10ffc7}\\u{10ffc6}\\u{10ffc5}\\u{10ffc4}\\u{10ffc3}\\u{10ffc2}\\u{10ffc1}\\\n        \\u{10ffc0}\\u{10ffbf}\\u{10ffbe}\\u{10ffbd}\\u{10ffbc}\\u{10ffbb}\\u{10ffba}\\u{10ffb9}\\u{10ffb8}\\\n        \\u{10ffb7}\\u{10ffb6}\\u{10ffb5}\\u{10ffb4}\\u{10ffb3}\\u{10ffb2}\\u{10ffb1}\\u{10ffb0}\\u{10ffaf}\\\n        \\u{10ffae}\\u{10ffad}\\u{10ffac}\\u{10ffab}\\u{10ffaa}\\u{10ffa9}\\u{10ffa8}\\u{10ffa7}\\u{10ffa6}\\\n        \\u{10ffa5}\\u{10ffa4}\\u{10ffa3}\\u{10ffa2}\\u{10ffa1}\\u{10ffa0}\\u{10ff9f}\\u{10ff9e}\\u{10ff9d}\\\n        \\u{10ff9c}\\u{10ff9b}\\u{10ff9a}\\u{10ff99}\\u{10ff98}\\u{10ff97}\\u{10ff96}\\u{10ff95}\\u{10ff94}\\\n        \\u{10ff93}\\u{10ff92}\\u{10ff91}\\u{10ff90}\\u{10ff8f}\\u{10ff8e}\\u{10ff8d}\\u{10ff8c}\\u{10ff8b}\\\n        \\u{10ff8a}\\u{10ff89}\\u{10ff88}\\u{10ff87}\\u{10ff86}\\u{10ff85}\\u{10ff84}\\u{10ff83}\\u{10ff82}\\\n        \\u{10ff81}\\u{10ff80}\\u{10ff7f}\\u{10ff7e}\\u{10ff7d}\\u{10ff7c}\\u{10ff7b}\\u{10ff7a}\\u{10ff79}\\\n        \\u{10ff78}\\u{10ff77}\\u{10ff76}\\u{10ff75}\\u{10ff74}\\u{10ff73}\\u{10ff72}\\u{10ff71}\\u{10ff70}\\\n        \\u{10ff6f}\\u{10ff6e}\\u{10ff6d}\\u{10ff6c}\\u{10ff6b}\\u{10ff6a}\\u{10ff69}\\u{10ff68}\\u{10ff67}\\\n        \\u{10ff66}\\u{10ff65}\\u{10ff64}\\u{10ff63}\\u{10ff62}\\u{10ff61}\\u{10ff60}\\u{10ff5f}\\u{10ff5e}\\\n        \\u{10ff5d}\\u{10ff5c}\\u{10ff5b}\\u{10ff5a}\\u{10ff59}\\u{10ff58}\\u{10ff57}\\u{10ff56}\\u{10ff55}\\\n        \\u{10ff54}\\u{10ff53}\\u{10ff52}\\u{10ff51}\\u{10ff50}\\u{10ff4f}\\u{10ff4e}\\u{10ff4d}\\u{10ff4c}\\\n        \\u{10ff4b}\\u{10ff4a}\\u{10ff49}\\u{10ff48}\\u{10ff47}\\u{10ff46}\\u{10ff45}\\u{10ff44}\\u{10ff43}\\\n        \\u{10ff42}\\u{10ff41}\\u{10ff40}\\u{10ff3f}\\u{10ff3e}\\u{10ff3d}\\u{10ff3c}\\u{10ff3b}\\u{10ff3a}\\\n        \\u{10ff39}\\u{10ff38}\"\n    );\n\n    assert_eq!(\n        exhaustive_chars().skip(94).take(200).collect::<String>(),\n        \"~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùú\\\n        ûüýþÿĀāĂăĄąĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıĲĳĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňŉŊŋŌōŎŏŐőŒœŔŕ\\\n        ŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨ\"\n    );\n\n    assert_eq!(\n        exhaustive_chars()\n            .skip(141698)\n            .take(200)\n            .collect::<String>(),\n        \"𮜾𮜿𮝀𮝁𮝂𮝃𮝄𮝅𮝆𮝇𮝈𮝉𮝊𮝋𮝌𮝍𮝎𮝏𮝐𮝑𮝒𮝓𮝔𮝕𮝖𮝗𮝘𮝙𮝚𮝛𮝜𮝝𮝞𮝟𮝠𮝡𮝢𮝣𮝤𮝥𮝦𮝧𮝨𮝩𮝪𮝫𮝬𮝭𮝮𮝯𮝰𮝱𮝲𮝳𮝴𮝵𮝶𮝷𮝸𮝹𮝺𮝻𮝼𮝽𮝾𮝿𮞀𮞁𮞂𮞃𮞄𮞅𮞆𮞇𮞈𮞉𮞊𮞋𮞌𮞍𮞎𮞏𮞐𮞑𮞒𮞓𮞔𮞕𮞖\\\n        𮞗𮞘𮞙𮞚𮞛𮞜𮞝𮞞𮞟𮞠𮞡𮞢𮞣𮞤𮞥𮞦𮞧𮞨𮞩𮞪𮞫𮞬𮞭𮞮𮞯𮞰𮞱𮞲𮞳𮞴𮞵𮞶𮞷𮞸𮞹𮞺𮞻𮞼𮞽𮞾𮞿𮟀𮟁𮟂𮟃𮟄𮟅𮟆𮟇𮟈𮟉𮟊𮟋𮟌𮟍𮟎𮟏𮟐𮟑𮟒𮟓𮟔𮟕𮟖𮟗𮟘𮟙𮟚𮟛𮟜𮟝𮟞𮟟𮟠𮟡𮟢𮟣𮟤𮟥𮟦𮟧𮟨𮟩𮟪𮟫𮟬𮟭𮟮𮟯𮟰\\\n        𮟱𮟲𮟳𮟴𮟵𮟶𮟷𮟸𮟹𮟺𮟻𮟼𮟽𮟾𮟿𮠀𮠁𮠂𮠃𮠄𮠅\"\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/is_graphic.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::char_is_graphic;\nuse malachite_base::chars::exhaustive::{ascii_chars_increasing, chars_increasing};\nuse malachite_base::iterators::matching_intervals_in_iterator;\n\n#[test]\nfn test_is_graphic() {\n    let test = |c, out| {\n        assert_eq!(char_is_graphic(c), out);\n    };\n    test(' ', true);\n    test('a', true);\n    test('A', true);\n    test('0', true);\n    test('!', true);\n    test('ñ', true);\n    test('\\0', false);\n    test('\\n', false);\n    test('\\u{5f771}', false);\n\n    assert_eq!(\n        ascii_chars_increasing()\n            .filter(|&c| char_is_graphic(c))\n            .count(),\n        95\n    );\n    assert_eq!(\n        chars_increasing().filter(|&c| char_is_graphic(c)).count(),\n        157478\n    );\n    assert_eq!(\n        matching_intervals_in_iterator(chars_increasing(), |&c| { char_is_graphic(c) })\n            .iter()\n            .map(|i| (i.0 as u32, i.1 as u32))\n            .collect_vec(),\n        &[\n            (32, 126),\n            (161, 172),\n            (174, 767),\n            (880, 887),\n            (890, 895),\n            (900, 906),\n            (908, 908),\n            (910, 929),\n            (931, 1154),\n            (1162, 1327),\n            (1329, 1366),\n            (1369, 1418),\n            (1421, 1423),\n            (1470, 1470),\n            (1472, 1472),\n            (1475, 1475),\n            (1478, 1478),\n            (1488, 1514),\n            (1519, 1524),\n            (1542, 1551),\n            (1563, 1563),\n            (1565, 1610),\n            (1632, 1647),\n            (1649, 1749),\n            (1758, 1758),\n            (1765, 1766),\n            (1769, 1769),\n            (1774, 1805),\n            (1808, 1808),\n            (1810, 1839),\n            (1869, 1957),\n            (1969, 1969),\n            (1984, 2026),\n            (2036, 2042),\n            (2046, 2069),\n            (2074, 2074),\n            (2084, 2084),\n            (2088, 2088),\n            (2096, 2110),\n            (2112, 2136),\n            (2142, 2142),\n            (2144, 2154),\n            (2160, 2191),\n            (2208, 2249),\n            (2307, 2361),\n            (2363, 2363),\n            (2365, 2368),\n            (2377, 2380),\n            (2382, 2384),\n            (2392, 2401),\n            (2404, 2432),\n            (2434, 2435),\n            (2437, 2444),\n            (2447, 2448),\n            (2451, 2472),\n            (2474, 2480),\n            (2482, 2482),\n            (2486, 2489),\n            (2493, 2493),\n            (2495, 2496),\n            (2503, 2504),\n            (2507, 2508),\n            (2510, 2510),\n            (2524, 2525),\n            (2527, 2529),\n            (2534, 2557),\n            (2563, 2563),\n            (2565, 2570),\n            (2575, 2576),\n            (2579, 2600),\n            (2602, 2608),\n            (2610, 2611),\n            (2613, 2614),\n            (2616, 2617),\n            (2622, 2624),\n            (2649, 2652),\n            (2654, 2654),\n            (2662, 2671),\n            (2674, 2676),\n            (2678, 2678),\n            (2691, 2691),\n            (2693, 2701),\n            (2703, 2705),\n            (2707, 2728),\n            (2730, 2736),\n            (2738, 2739),\n            (2741, 2745),\n            (2749, 2752),\n            (2761, 2761),\n            (2763, 2764),\n            (2768, 2768),\n            (2784, 2785),\n            (2790, 2801),\n            (2809, 2809),\n            (2818, 2819),\n            (2821, 2828),\n            (2831, 2832),\n            (2835, 2856),\n            (2858, 2864),\n            (2866, 2867),\n            (2869, 2873),\n            (2877, 2877),\n            (2880, 2880),\n            (2887, 2888),\n            (2891, 2892),\n            (2908, 2909),\n            (2911, 2913),\n            (2918, 2935),\n            (2947, 2947),\n            (2949, 2954),\n            (2958, 2960),\n            (2962, 2965),\n            (2969, 2970),\n            (2972, 2972),\n            (2974, 2975),\n            (2979, 2980),\n            (2984, 2986),\n            (2990, 3001),\n            (3007, 3007),\n            (3009, 3010),\n            (3014, 3016),\n            (3018, 3020),\n            (3024, 3024),\n            (3046, 3066),\n            (3073, 3075),\n            (3077, 3084),\n            (3086, 3088),\n            (3090, 3112),\n            (3114, 3129),\n            (3133, 3133),\n            (3137, 3140),\n            (3160, 3162),\n            (3164, 3165),\n            (3168, 3169),\n            (3174, 3183),\n            (3191, 3200),\n            (3202, 3212),\n            (3214, 3216),\n            (3218, 3240),\n            (3242, 3251),\n            (3253, 3257),\n            (3261, 3262),\n            (3265, 3265),\n            (3267, 3268),\n            (3292, 3294),\n            (3296, 3297),\n            (3302, 3311),\n            (3313, 3315),\n            (3330, 3340),\n            (3342, 3344),\n            (3346, 3386),\n            (3389, 3389),\n            (3391, 3392),\n            (3398, 3400),\n            (3402, 3404),\n            (3406, 3407),\n            (3412, 3414),\n            (3416, 3425),\n            (3430, 3455),\n            (3458, 3459),\n            (3461, 3478),\n            (3482, 3505),\n            (3507, 3515),\n            (3517, 3517),\n            (3520, 3526),\n            (3536, 3537),\n            (3544, 3550),\n            (3558, 3567),\n            (3570, 3572),\n            (3585, 3632),\n            (3634, 3635),\n            (3647, 3654),\n            (3663, 3675),\n            (3713, 3714),\n            (3716, 3716),\n            (3718, 3722),\n            (3724, 3747),\n            (3749, 3749),\n            (3751, 3760),\n            (3762, 3763),\n            (3773, 3773),\n            (3776, 3780),\n            (3782, 3782),\n            (3792, 3801),\n            (3804, 3807),\n            (3840, 3863),\n            (3866, 3892),\n            (3894, 3894),\n            (3896, 3896),\n            (3898, 3911),\n            (3913, 3948),\n            (3967, 3967),\n            (3973, 3973),\n            (3976, 3980),\n            (4030, 4037),\n            (4039, 4044),\n            (4046, 4058),\n            (4096, 4140),\n            (4145, 4145),\n            (4152, 4152),\n            (4155, 4156),\n            (4159, 4183),\n            (4186, 4189),\n            (4193, 4208),\n            (4213, 4225),\n            (4227, 4228),\n            (4231, 4236),\n            (4238, 4252),\n            (4254, 4293),\n            (4295, 4295),\n            (4301, 4301),\n            (4304, 4680),\n            (4682, 4685),\n            (4688, 4694),\n            (4696, 4696),\n            (4698, 4701),\n            (4704, 4744),\n            (4746, 4749),\n            (4752, 4784),\n            (4786, 4789),\n            (4792, 4798),\n            (4800, 4800),\n            (4802, 4805),\n            (4808, 4822),\n            (4824, 4880),\n            (4882, 4885),\n            (4888, 4954),\n            (4960, 4988),\n            (4992, 5017),\n            (5024, 5109),\n            (5112, 5117),\n            (5120, 5759),\n            (5761, 5788),\n            (5792, 5880),\n            (5888, 5905),\n            (5919, 5937),\n            (5941, 5942),\n            (5952, 5969),\n            (5984, 5996),\n            (5998, 6000),\n            (6016, 6067),\n            (6070, 6070),\n            (6078, 6085),\n            (6087, 6088),\n            (6100, 6108),\n            (6112, 6121),\n            (6128, 6137),\n            (6144, 6154),\n            (6160, 6169),\n            (6176, 6264),\n            (6272, 6276),\n            (6279, 6312),\n            (6314, 6314),\n            (6320, 6389),\n            (6400, 6430),\n            (6435, 6438),\n            (6441, 6443),\n            (6448, 6449),\n            (6451, 6456),\n            (6464, 6464),\n            (6468, 6509),\n            (6512, 6516),\n            (6528, 6571),\n            (6576, 6601),\n            (6608, 6618),\n            (6622, 6678),\n            (6681, 6682),\n            (6686, 6741),\n            (6743, 6743),\n            (6753, 6753),\n            (6755, 6756),\n            (6765, 6770),\n            (6784, 6793),\n            (6800, 6809),\n            (6816, 6829),\n            (6916, 6963),\n            (6974, 6977),\n            (6981, 6988),\n            (6990, 7018),\n            (7028, 7039),\n            (7042, 7073),\n            (7078, 7079),\n            (7086, 7141),\n            (7143, 7143),\n            (7146, 7148),\n            (7150, 7150),\n            (7164, 7211),\n            (7220, 7221),\n            (7227, 7241),\n            (7245, 7306),\n            (7312, 7354),\n            (7357, 7367),\n            (7379, 7379),\n            (7393, 7393),\n            (7401, 7404),\n            (7406, 7411),\n            (7413, 7415),\n            (7418, 7418),\n            (7424, 7615),\n            (7680, 7957),\n            (7960, 7965),\n            (7968, 8005),\n            (8008, 8013),\n            (8016, 8023),\n            (8025, 8025),\n            (8027, 8027),\n            (8029, 8029),\n            (8031, 8061),\n            (8064, 8116),\n            (8118, 8132),\n            (8134, 8147),\n            (8150, 8155),\n            (8157, 8175),\n            (8178, 8180),\n            (8182, 8190),\n            (8208, 8231),\n            (8240, 8286),\n            (8304, 8305),\n            (8308, 8334),\n            (8336, 8348),\n            (8352, 8385),\n            (8448, 8587),\n            (8592, 9257),\n            (9280, 9290),\n            (9312, 11123),\n            (11126, 11502),\n            (11506, 11507),\n            (11513, 11557),\n            (11559, 11559),\n            (11565, 11565),\n            (11568, 11623),\n            (11631, 11632),\n            (11648, 11670),\n            (11680, 11686),\n            (11688, 11694),\n            (11696, 11702),\n            (11704, 11710),\n            (11712, 11718),\n            (11720, 11726),\n            (11728, 11734),\n            (11736, 11742),\n            (11776, 11869),\n            (11904, 11929),\n            (11931, 12019),\n            (12032, 12245),\n            (12272, 12287),\n            (12289, 12329),\n            (12336, 12351),\n            (12353, 12438),\n            (12443, 12543),\n            (12549, 12591),\n            (12593, 12686),\n            (12688, 12773),\n            (12783, 12830),\n            (12832, 42124),\n            (42128, 42182),\n            (42192, 42539),\n            (42560, 42606),\n            (42611, 42611),\n            (42622, 42653),\n            (42656, 42735),\n            (42738, 42743),\n            (42752, 42972),\n            (42993, 43009),\n            (43011, 43013),\n            (43015, 43018),\n            (43020, 43044),\n            (43047, 43051),\n            (43056, 43065),\n            (43072, 43127),\n            (43136, 43203),\n            (43214, 43225),\n            (43250, 43262),\n            (43264, 43301),\n            (43310, 43334),\n            (43346, 43346),\n            (43359, 43388),\n            (43395, 43442),\n            (43444, 43445),\n            (43450, 43451),\n            (43454, 43455),\n            (43457, 43469),\n            (43471, 43481),\n            (43486, 43492),\n            (43494, 43518),\n            (43520, 43560),\n            (43567, 43568),\n            (43571, 43572),\n            (43584, 43586),\n            (43588, 43595),\n            (43597, 43597),\n            (43600, 43609),\n            (43612, 43643),\n            (43645, 43695),\n            (43697, 43697),\n            (43701, 43702),\n            (43705, 43709),\n            (43712, 43712),\n            (43714, 43714),\n            (43739, 43755),\n            (43758, 43765),\n            (43777, 43782),\n            (43785, 43790),\n            (43793, 43798),\n            (43808, 43814),\n            (43816, 43822),\n            (43824, 43883),\n            (43888, 44004),\n            (44006, 44007),\n            (44009, 44012),\n            (44016, 44025),\n            (44032, 55203),\n            (55216, 55238),\n            (55243, 55291),\n            (63744, 64109),\n            (64112, 64217),\n            (64256, 64262),\n            (64275, 64279),\n            (64285, 64285),\n            (64287, 64310),\n            (64312, 64316),\n            (64318, 64318),\n            (64320, 64321),\n            (64323, 64324),\n            (64326, 64975),\n            (65008, 65023),\n            (65040, 65049),\n            (65072, 65106),\n            (65108, 65126),\n            (65128, 65131),\n            (65136, 65140),\n            (65142, 65276),\n            (65281, 65437),\n            (65440, 65470),\n            (65474, 65479),\n            (65482, 65487),\n            (65490, 65495),\n            (65498, 65500),\n            (65504, 65510),\n            (65512, 65518),\n            (65532, 65533),\n            (65536, 65547),\n            (65549, 65574),\n            (65576, 65594),\n            (65596, 65597),\n            (65599, 65613),\n            (65616, 65629),\n            (65664, 65786),\n            (65792, 65794),\n            (65799, 65843),\n            (65847, 65934),\n            (65936, 65948),\n            (65952, 65952),\n            (66000, 66044),\n            (66176, 66204),\n            (66208, 66256),\n            (66273, 66299),\n            (66304, 66339),\n            (66349, 66378),\n            (66384, 66421),\n            (66432, 66461),\n            (66463, 66499),\n            (66504, 66517),\n            (66560, 66717),\n            (66720, 66729),\n            (66736, 66771),\n            (66776, 66811),\n            (66816, 66855),\n            (66864, 66915),\n            (66927, 66938),\n            (66940, 66954),\n            (66956, 66962),\n            (66964, 66965),\n            (66967, 66977),\n            (66979, 66993),\n            (66995, 67001),\n            (67003, 67004),\n            (67008, 67059),\n            (67072, 67382),\n            (67392, 67413),\n            (67424, 67431),\n            (67456, 67461),\n            (67463, 67504),\n            (67506, 67514),\n            (67584, 67589),\n            (67592, 67592),\n            (67594, 67637),\n            (67639, 67640),\n            (67644, 67644),\n            (67647, 67669),\n            (67671, 67742),\n            (67751, 67759),\n            (67808, 67826),\n            (67828, 67829),\n            (67835, 67867),\n            (67871, 67897),\n            (67903, 67929),\n            (67968, 68023),\n            (68028, 68047),\n            (68050, 68096),\n            (68112, 68115),\n            (68117, 68119),\n            (68121, 68149),\n            (68160, 68168),\n            (68176, 68184),\n            (68192, 68255),\n            (68288, 68324),\n            (68331, 68342),\n            (68352, 68405),\n            (68409, 68437),\n            (68440, 68466),\n            (68472, 68497),\n            (68505, 68508),\n            (68521, 68527),\n            (68608, 68680),\n            (68736, 68786),\n            (68800, 68850),\n            (68858, 68899),\n            (68912, 68921),\n            (68928, 68965),\n            (68974, 68997),\n            (69006, 69007),\n            (69216, 69246),\n            (69248, 69289),\n            (69293, 69293),\n            (69296, 69297),\n            (69314, 69319),\n            (69328, 69336),\n            (69376, 69415),\n            (69424, 69445),\n            (69457, 69465),\n            (69488, 69505),\n            (69510, 69513),\n            (69552, 69579),\n            (69600, 69622),\n            (69632, 69632),\n            (69634, 69687),\n            (69703, 69709),\n            (69714, 69743),\n            (69745, 69746),\n            (69749, 69749),\n            (69762, 69810),\n            (69815, 69816),\n            (69819, 69820),\n            (69822, 69825),\n            (69840, 69864),\n            (69872, 69881),\n            (69891, 69926),\n            (69932, 69932),\n            (69942, 69959),\n            (69968, 70002),\n            (70004, 70006),\n            (70018, 70069),\n            (70079, 70079),\n            (70081, 70088),\n            (70093, 70094),\n            (70096, 70111),\n            (70113, 70132),\n            (70144, 70161),\n            (70163, 70190),\n            (70194, 70195),\n            (70200, 70205),\n            (70207, 70208),\n            (70272, 70278),\n            (70280, 70280),\n            (70282, 70285),\n            (70287, 70301),\n            (70303, 70313),\n            (70320, 70366),\n            (70368, 70370),\n            (70384, 70393),\n            (70402, 70403),\n            (70405, 70412),\n            (70415, 70416),\n            (70419, 70440),\n            (70442, 70448),\n            (70450, 70451),\n            (70453, 70457),\n            (70461, 70461),\n            (70463, 70463),\n            (70465, 70468),\n            (70471, 70472),\n            (70475, 70476),\n            (70480, 70480),\n            (70493, 70499),\n            (70528, 70537),\n            (70539, 70539),\n            (70542, 70542),\n            (70544, 70581),\n            (70583, 70583),\n            (70585, 70586),\n            (70602, 70602),\n            (70604, 70605),\n            (70609, 70609),\n            (70611, 70613),\n            (70615, 70616),\n            (70656, 70711),\n            (70720, 70721),\n            (70725, 70725),\n            (70727, 70747),\n            (70749, 70749),\n            (70751, 70753),\n            (70784, 70831),\n            (70833, 70834),\n            (70841, 70841),\n            (70843, 70844),\n            (70846, 70846),\n            (70849, 70849),\n            (70852, 70855),\n            (70864, 70873),\n            (71040, 71086),\n            (71088, 71089),\n            (71096, 71099),\n            (71102, 71102),\n            (71105, 71131),\n            (71168, 71218),\n            (71227, 71228),\n            (71230, 71230),\n            (71233, 71236),\n            (71248, 71257),\n            (71264, 71276),\n            (71296, 71338),\n            (71340, 71340),\n            (71342, 71343),\n            (71352, 71353),\n            (71360, 71369),\n            (71376, 71395),\n            (71424, 71450),\n            (71454, 71454),\n            (71456, 71457),\n            (71462, 71462),\n            (71472, 71494),\n            (71680, 71726),\n            (71736, 71736),\n            (71739, 71739),\n            (71840, 71922),\n            (71935, 71942),\n            (71945, 71945),\n            (71948, 71955),\n            (71957, 71958),\n            (71960, 71983),\n            (71985, 71989),\n            (71991, 71992),\n            (71999, 72002),\n            (72004, 72006),\n            (72016, 72025),\n            (72096, 72103),\n            (72106, 72147),\n            (72156, 72159),\n            (72161, 72164),\n            (72192, 72192),\n            (72203, 72242),\n            (72249, 72250),\n            (72255, 72262),\n            (72272, 72272),\n            (72279, 72280),\n            (72284, 72329),\n            (72343, 72343),\n            (72346, 72354),\n            (72368, 72440),\n            (72448, 72457),\n            (72545, 72545),\n            (72549, 72549),\n            (72551, 72551),\n            (72640, 72673),\n            (72688, 72697),\n            (72704, 72712),\n            (72714, 72751),\n            (72766, 72766),\n            (72768, 72773),\n            (72784, 72812),\n            (72816, 72847),\n            (72873, 72873),\n            (72881, 72881),\n            (72884, 72884),\n            (72960, 72966),\n            (72968, 72969),\n            (72971, 73008),\n            (73030, 73030),\n            (73040, 73049),\n            (73056, 73061),\n            (73063, 73064),\n            (73066, 73102),\n            (73107, 73108),\n            (73110, 73110),\n            (73112, 73112),\n            (73120, 73129),\n            (73136, 73179),\n            (73184, 73193),\n            (73440, 73458),\n            (73461, 73464),\n            (73474, 73488),\n            (73490, 73525),\n            (73534, 73535),\n            (73539, 73561),\n            (73648, 73648),\n            (73664, 73713),\n            (73727, 74649),\n            (74752, 74862),\n            (74864, 74868),\n            (74880, 75075),\n            (77712, 77810),\n            (77824, 78895),\n            (78913, 78918),\n            (78944, 82938),\n            (82944, 83526),\n            (90368, 90397),\n            (90410, 90412),\n            (90416, 90425),\n            (92160, 92728),\n            (92736, 92766),\n            (92768, 92777),\n            (92782, 92862),\n            (92864, 92873),\n            (92880, 92909),\n            (92917, 92917),\n            (92928, 92975),\n            (92983, 92997),\n            (93008, 93017),\n            (93019, 93025),\n            (93027, 93047),\n            (93053, 93071),\n            (93504, 93561),\n            (93760, 93850),\n            (93856, 93880),\n            (93883, 93907),\n            (93952, 94026),\n            (94032, 94087),\n            (94099, 94111),\n            (94176, 94179),\n            (94194, 94198),\n            (94208, 101589),\n            (101631, 101662),\n            (101760, 101874),\n            (110576, 110579),\n            (110581, 110587),\n            (110589, 110590),\n            (110592, 110882),\n            (110898, 110898),\n            (110928, 110930),\n            (110933, 110933),\n            (110948, 110951),\n            (110960, 111355),\n            (113664, 113770),\n            (113776, 113788),\n            (113792, 113800),\n            (113808, 113817),\n            (113820, 113820),\n            (113823, 113823),\n            (117760, 118012),\n            (118016, 118451),\n            (118458, 118480),\n            (118496, 118512),\n            (118608, 118723),\n            (118784, 119029),\n            (119040, 119078),\n            (119081, 119140),\n            (119146, 119148),\n            (119171, 119172),\n            (119180, 119209),\n            (119214, 119274),\n            (119296, 119361),\n            (119365, 119365),\n            (119488, 119507),\n            (119520, 119539),\n            (119552, 119638),\n            (119648, 119672),\n            (119808, 119892),\n            (119894, 119964),\n            (119966, 119967),\n            (119970, 119970),\n            (119973, 119974),\n            (119977, 119980),\n            (119982, 119993),\n            (119995, 119995),\n            (119997, 120003),\n            (120005, 120069),\n            (120071, 120074),\n            (120077, 120084),\n            (120086, 120092),\n            (120094, 120121),\n            (120123, 120126),\n            (120128, 120132),\n            (120134, 120134),\n            (120138, 120144),\n            (120146, 120485),\n            (120488, 120779),\n            (120782, 121343),\n            (121399, 121402),\n            (121453, 121460),\n            (121462, 121475),\n            (121477, 121483),\n            (122624, 122654),\n            (122661, 122666),\n            (122928, 122989),\n            (123136, 123180),\n            (123191, 123197),\n            (123200, 123209),\n            (123214, 123215),\n            (123536, 123565),\n            (123584, 123627),\n            (123632, 123641),\n            (123647, 123647),\n            (124112, 124139),\n            (124144, 124153),\n            (124368, 124397),\n            (124400, 124410),\n            (124415, 124415),\n            (124608, 124638),\n            (124640, 124642),\n            (124644, 124645),\n            (124647, 124653),\n            (124656, 124660),\n            (124670, 124671),\n            (124896, 124902),\n            (124904, 124907),\n            (124909, 124910),\n            (124912, 124926),\n            (124928, 125124),\n            (125127, 125135),\n            (125184, 125251),\n            (125259, 125259),\n            (125264, 125273),\n            (125278, 125279),\n            (126065, 126132),\n            (126209, 126269),\n            (126464, 126467),\n            (126469, 126495),\n            (126497, 126498),\n            (126500, 126500),\n            (126503, 126503),\n            (126505, 126514),\n            (126516, 126519),\n            (126521, 126521),\n            (126523, 126523),\n            (126530, 126530),\n            (126535, 126535),\n            (126537, 126537),\n            (126539, 126539),\n            (126541, 126543),\n            (126545, 126546),\n            (126548, 126548),\n            (126551, 126551),\n            (126553, 126553),\n            (126555, 126555),\n            (126557, 126557),\n            (126559, 126559),\n            (126561, 126562),\n            (126564, 126564),\n            (126567, 126570),\n            (126572, 126578),\n            (126580, 126583),\n            (126585, 126588),\n            (126590, 126590),\n            (126592, 126601),\n            (126603, 126619),\n            (126625, 126627),\n            (126629, 126633),\n            (126635, 126651),\n            (126704, 126705),\n            (126976, 127019),\n            (127024, 127123),\n            (127136, 127150),\n            (127153, 127167),\n            (127169, 127183),\n            (127185, 127221),\n            (127232, 127405),\n            (127462, 127490),\n            (127504, 127547),\n            (127552, 127560),\n            (127568, 127569),\n            (127584, 127589),\n            (127744, 128728),\n            (128732, 128748),\n            (128752, 128764),\n            (128768, 128985),\n            (128992, 129003),\n            (129008, 129008),\n            (129024, 129035),\n            (129040, 129095),\n            (129104, 129113),\n            (129120, 129159),\n            (129168, 129197),\n            (129200, 129211),\n            (129216, 129217),\n            (129232, 129240),\n            (129280, 129623),\n            (129632, 129645),\n            (129648, 129660),\n            (129664, 129674),\n            (129678, 129734),\n            (129736, 129736),\n            (129741, 129756),\n            (129759, 129770),\n            (129775, 129784),\n            (129792, 129938),\n            (129940, 130042),\n            (131072, 173791),\n            (173824, 178205),\n            (178208, 183981),\n            (183984, 191456),\n            (191472, 192093),\n            (194560, 195101),\n            (196608, 201546),\n            (201552, 210041)\n        ][..]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/graphic_weighted_random_ascii_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::graphic_weighted_random_ascii_chars;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn graphic_weighted_random_ascii_chars_helper(\n    p_numerator: u64,\n    p_denominator: u64,\n    expected_values: &str,\n    expected_common_values: &[(char, usize)],\n    expected_median: (char, Option<char>),\n) {\n    let xs = graphic_weighted_random_ascii_chars(EXAMPLE_SEED, p_numerator, p_denominator);\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_graphic_weighted_random_ascii_chars() {\n    // p = 1/2\n    graphic_weighted_random_ascii_chars_helper(\n        1,\n        2,\n        \"\\u{1b}x\\u{8}1\\r4\\u{2}N\\u{11}\\u{11}(\\u{13}bcXr$g)\\t7/E\\u{11}+fY\\u{10}Po\\u{1}\\u{17}\\u{17}\\\n        \\u{13}o\\u{1}.\\u{0}\\u{b}\\u{3}$\\u{6}\\nV2R.\\u{f}\\u{5}\\u{19}$\\u{1f}V=\\u{1c}\\u{6}\\u{15}\\u{6}\\\n        \\u{11}\\r\\u{19}6\\u{2}\\u{19}=\\u{12}\\u{18}Dq\\u{6}S<\\u{6}\\u{1d}C\\u{b}M\\u{8}\\u{15}\\u{16}\\u{f}W_\\\n        \\u{0}\\u{12}%\\u{18}\\u{10}\\u{10}OX?\\u{1f}\\u{12}b\\u{c}}\\u{10}rJa\\u{e}D\\u{1e}`o635\\u{2}Q:w\\u{3}\\\n        \\u{1}3m\\u{5}Y\\u{1f}=\\u{7}8\\tn\\r\\u{1}\\nq\\u{13}\\u{3}\\t\\u{f}fR:/\\u{f}2\\u{2}\\u{1c}6\\u{13}\\u{13}\\\n        z\\u{15}r\\u{f}\\u{4}<\\u{1d}<a\\u{4}A\\nZ\\u{18}\\u{7}<\\u{19}$2\\u{12}/2)jCz!\\u{5}\\u{14}r\\u{15}\\\n        \\u{16}{%\\u{1f}\\u{5}(r\\u{14}\\u{12}\\u{11}\\u{14}\\u{4}N\\u{c}?X\\u{5}\\u{1d}<\\u{b} \\u{0}!\\u{10}\\\n        \\u{1e}\",\n        &[\n            ('\\u{13}', 15346),\n            ('\\r', 15339),\n            ('\\u{19}', 15334),\n            ('\\u{1}', 15259),\n            ('\\u{1b}', 15259),\n            ('\\u{1d}', 15225),\n            ('\\n', 15209),\n            ('\\u{6}', 15206),\n            ('\\u{1e}', 15194),\n            ('\\u{12}', 15193),\n        ],\n        ('\\\"', None),\n    );\n    // p = 1/51\n    graphic_weighted_random_ascii_chars_helper(\n        1,\n        51,\n        \"\\u{1b}\\u{8}x\\r\\u{2}\\u{11}\\u{11}\\u{13}\\t\\u{11}\\u{10}\\u{1}\\u{17}\\u{17}\\u{13}\\u{1}\\u{0}\\u{b}\\\n        \\u{3}\\u{6}\\n\\u{f}\\u{5}\\u{19}\\u{1f}\\u{1c}\\u{6}\\u{15}\\u{6}\\u{11}\\r\\u{19}\\u{2}\\u{19}\\u{12}\\\n        \\u{18}\\u{6}\\u{6}1\\u{1d}\\u{b}\\u{8}\\u{15}\\u{16}\\u{f}\\u{0}\\u{12}\\u{18}\\u{10}\\u{10}\\u{1f}\\u{12}\\\n        \\u{c}\\u{10}\\u{e}\\u{1e}\\u{2}\\u{3}\\u{1}\\u{5}\\u{1f}\\u{7}\\t\\r\\u{1}\\n\\u{13}\\u{3}\\t\\u{f}\\u{f}\\\n        \\u{2}\\u{1c}\\u{13}\\u{13}\\u{15}\\u{f}\\u{4}\\u{1d}\\u{4}\\n\\u{18}\\u{7}\\u{19}\\u{12}\\u{5}\\u{14}\\\n        \\u{15}\\u{16}\\u{1f}\\u{5}\\u{14}\\u{12}\\u{11}\\u{14}\\u{4}\\u{c}\\u{5}\\u{1d}\\u{b}\\u{0}\\u{10}\\u{1e}\\\n        \\u{1e}\\u{10}\\u{19}\\u{4}\\u{15}4\\u{1f}\\u{12}\\u{1b}\\u{e}\\u{f}\\u{7}\\u{1e}\\u{10}\\u{1d}\\u{c}\\\n        \\u{13}\\u{11}\\u{f}\\u{18}\\u{1e}\\u{15}\\u{19}\\u{b}\\u{3}\\u{15}N\\u{16}\\u{14}\\u{6}\\u{b}\\u{1d}\\u{c}\\\n        \\u{1f}\\u{17}\\u{13}\\n\\u{1f}\\u{7f}\\u{1a}\\u{c}\\u{5}\\u{7}\\u{1f}\\u{1a}\\u{1d}\\u{1d}\\u{c}\\u{1f}\\\n        \\u{17}\\t\\u{1f}\\u{14}\\u{b}\\u{5}\\u{13}\\u{17}\\u{0}\\u{b}\\u{10}\\u{10}\\u{6}\\u{19}\\u{1d}\\u{18}\\\n        \\u{0}\\u{11}\\u{7}\\t\\u{2}\\u{13}\\u{11}\\u{1f}\\u{1b}\\u{19}\\u{13}\\u{6}\\u{4}\\u{11}\\u{1d}\\u{15}\\\n        \\u{8}\\u{8}\\u{2}\\u{18}\\u{f}\\u{b}\\u{f}\\u{1a}\\t\\u{11}\\u{1}\\u{11}\\u{3}\\n\\u{16}\\u{e}\",\n        &[\n            ('\\u{13}', 30211),\n            ('\\u{19}', 30173),\n            ('\\r', 30045),\n            ('\\u{1}', 29977),\n            ('\\u{3}', 29971),\n            ('\\u{4}', 29936),\n            ('\\u{f}', 29920),\n            ('\\u{12}', 29882),\n            ('\\u{18}', 29864),\n            ('\\u{14}', 29793),\n        ],\n        ('\\u{10}', None),\n    );\n    // p = 50/51\n    graphic_weighted_random_ascii_chars_helper(\n        50,\n        51,\n        \"x14N(bcXr$g)7/E+fYPoo.$V2R.$V=6=DqS<CMW_%OX?b}rJaD`o635Q:w3mY=8nq\\u{1b}fR:/26zr<<aAZ<$2/2)\\\n        jCz!r{%(rN?X< !:z*KWArQ1-#AJCW-/}v,m`xKpzt5?u\\u{8}IJN\\'wYe9f\\\".RmqMxz7l7qOjs`$-%s5LO`L{G5y\\\n        \\r8%7/J ZD!4!Gq.kQb>pr\\u{2}+UFFc;8P:\",\n        &[\n            ('d', 10548),\n            ('C', 10506),\n            ('7', 10501),\n            ('R', 10486),\n            ('D', 10484),\n            ('q', 10476),\n            ('1', 10468),\n            ('6', 10463),\n            ('\\'', 10452),\n            ('$', 10448),\n        ],\n        ('N', None),\n    );\n}\n#[test]\n#[should_panic]\nfn graphic_weighted_random_ascii_chars_fail_1() {\n    graphic_weighted_random_ascii_chars(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_ascii_chars_fail_2() {\n    graphic_weighted_random_ascii_chars(EXAMPLE_SEED, 2, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/graphic_weighted_random_char_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn graphic_weighted_random_char_inclusive_range_helper(\n    a: char,\n    b: char,\n    p_numerator: u64,\n    p_denominator: u64,\n    expected_values: &str,\n    expected_common_values: &[(char, usize)],\n    expected_median: (char, Option<char>),\n) {\n    let xs = graphic_weighted_random_char_inclusive_range(\n        EXAMPLE_SEED,\n        a,\n        b,\n        p_numerator,\n        p_denominator,\n    );\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_graphic_weighted_random_char_inclusive_range() {\n    // 'a', '\\u{7f}', p = 1/2\n    graphic_weighted_random_char_inclusive_range_helper(\n        'a',\n        '\\u{7f}',\n        1,\n        2,\n        \"\\u{7f}y\\u{7f}g\\u{7f}c\\u{7f}k\\u{7f}\\u{7f}}\\u{7f}ccjlybr\\u{7f}tue\\u{7f}}ye\\u{7f}oz\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}d\\u{7f}f\\u{7f}\\u{7f}\\u{7f}f\\u{7f}\\u{7f}fmxr\\u{7f}\\u{7f}\\u{7f}g\\u{7f}hy\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}q\\u{7f}\\u{7f}t\\u{7f}\\u{7f}pk\\u{7f}oh\\u{7f}\\u{7f}i\\\n        \\u{7f}q\\u{7f}\\u{7f}\\u{7f}\\u{7f}nf\\u{7f}\\u{7f}l\\u{7f}\\u{7f}\\u{7f}sqf\\u{7f}\\u{7f}t\\u{7f}d\\\n        \\u{7f}emm\\u{7f}|\\u{7f}{z|wu\\u{7f}dsc\\u{7f}\\u{7f}f{\\u{7f}t\\u{7f}r\\u{7f}t\\u{7f}q\\u{7f}\\u{7f}\\\n        \\u{7f}h\\u{7f}\\u{7f}\\u{7f}\\u{7f}klx~\\u{7f}x\\u{7f}\\u{7f}c\\u{7f}\\u{7f}u\\u{7f}l\\u{7f}\\u{7f}y\\\n        \\u{7f}~d\\u{7f}~\\u{7f}f\\u{7f}\\u{7f}m\\u{7f}xf\\u{7f}lkvcu{e\\u{7f}\\u{7f}b\\u{7f}\\u{7f}yh\\u{7f}\\\n        \\u{7f}nz\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}e\\u{7f}vu\\u{7f}\\u{7f}}\\u{7f}y\\u{7f}u\\u{7f}\\u{7f}\",\n        &[\n            ('\\u{7f}', 499332),\n            ('a', 16868),\n            ('t', 16831),\n            ('j', 16829),\n            ('r', 16822),\n            ('i', 16816),\n            ('f', 16806),\n            ('{', 16780),\n            ('s', 16763),\n            ('d', 16749),\n        ],\n        ('~', None),\n    );\n    // 'a', '\\u{7f}', p = 1/51\n    graphic_weighted_random_char_inclusive_range_helper(\n        'a',\n        '\\u{7f}',\n        1,\n        51,\n        \"\\u{7f}\\u{7f}y\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}g\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}c\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}k\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\",\n        &[\n            ('\\u{7f}', 980198),\n            ('h', 697),\n            ('n', 691),\n            ('i', 681),\n            ('w', 680),\n            ('r', 677),\n            ('a', 675),\n            ('|', 674),\n            ('q', 673),\n            ('e', 670),\n        ],\n        ('\\u{7f}', None),\n    );\n    // 'a', '\\u{7f}', p = 50/51\n    graphic_weighted_random_char_inclusive_range_helper(\n        'a',\n        '\\u{7f}',\n        50,\n        51,\n        \"ygck}ccjlybrtue}yeozdfffmxrghyqtpkohiqnflsqftdemm|{z|wudscf{trtqh\\u{7f}klx~xculy~d~fmxflkv\\\n        cu{ebyhnzevu}yuzvtuz}{b~yyzin}zsjthazlcluvu}a\\u{7f}yvhhbgevdxo}unwjqepanjmpckouxtwwbi{nla\\\n        \\u{7f}cs{vphyrdaqhzndmqdqg\\u{7f}{{mfwk|xf\",\n        &[\n            ('a', 32996),\n            ('f', 32964),\n            ('q', 32960),\n            ('{', 32942),\n            ('s', 32886),\n            ('t', 32809),\n            ('d', 32768),\n            ('n', 32767),\n            ('p', 32766),\n            ('i', 32765),\n        ],\n        ('p', None),\n    );\n\n    // '\\u{100}', '\\u{3ff}', p = 1/2\n    graphic_weighted_random_char_inclusive_range_helper(\n        '\\u{100}',\n        '\\u{3ff}',\n        1,\n        2,\n        \"\\u{31b}ǘ\\u{324}ɂ\\u{35a}Ŝ\\u{367}Ȣ\\u{337}\\u{342}Ι\\u{36e}Ƙƣʅΰǟ˳ˊ\\u{315}ȇʰɥ\\u{32c}ΈϞƃ\\u{30b}ʌμ\\\n        \\u{346}\\u{36a}\\u{328}\\u{334}Ƣ\\u{380}ϳ\\u{32e}\\u{359}\\u{36b}Ϫ\\u{333}\\u{312}ǰɪŗŽ\\u{302}\\u{305}\\\n        \\u{32e}ƽ\\u{357}ɥϻ\\u{349}\\u{35f}\\u{316}\\u{33a}\\u{383}\\u{301}\\u{31d}ƚ\\u{360}\\u{35d}ʧ\\u{30c}\\\n        \\u{30c}ƙϮ\\u{34a}șϒ\\u{367}\\u{35f}Ϣ\\u{308}ć\\u{353}\\u{333}\\u{381}\\u{30f}ɾɢ\\u{367}\\u{340}ǧ\\\n        \\u{356}\\u{30c}\\u{351}ǁʴȶ\\u{33e}\\u{358}Ɛ\\u{351}ď\\u{366}ȭˬɂ\\u{38b}ϰ\\u{342}ȁʺċλǿ\\u{30c}αăǰ\\\n        \\u{31c}\\u{327}ʹʃ\\u{34a}Ű\\u{36a}ǐ\\u{33f}Ƭ\\u{34c}ɖ\\u{361}\\u{335}\\u{318}Ͼ\\u{349}\\u{35d}\\u{330}\\\n        \\u{35c}ƾƱǒȆ\\u{320}Ɉ\\u{348}\\u{324}Ϫ\\u{31d}\\u{35c}ʶ\\u{332}ť\\u{33d}\\u{300}ˍ\\u{326}ďǑ\\u{329}ɶ\\\n        \\u{33d}Ɂ\\u{31f}\\u{363}ȭ\\u{320}ƭğ\\u{321}Ⱦ˹ĺǗʋǆ˺\\u{31a}\\u{35c}ʐ\\u{304}\\u{365}Ǎŋ\\u{34f}\\u{31f}\\\n        ɽɷ\\u{31e}\\u{32a}\\u{31a}\\u{307}\\u{319}ϲ\\u{310}Ÿȃ\\u{369}\\u{359}Ĩ\\u{33e}Ş\\u{38d}˭\\u{31e}\\\n        \\u{321}\",\n        &[\n            ('\\u{326}', 4271),\n            ('\\u{357}', 4238),\n            ('\\u{33b}', 4235),\n            ('\\u{36b}', 4235),\n            ('\\u{348}', 4228),\n            ('\\u{30b}', 4225),\n            ('\\u{304}', 4224),\n            ('\\u{30d}', 4224),\n            ('\\u{327}', 4221),\n            ('\\u{325}', 4217),\n        ],\n        ('\\u{319}', None),\n    );\n    // '\\u{100}', '\\u{3ff}', p = 1/51\n    graphic_weighted_random_char_inclusive_range_helper(\n        '\\u{100}',\n        '\\u{3ff}',\n        1,\n        51,\n        \"\\u{31b}\\u{324}ǘ\\u{35a}\\u{367}\\u{337}\\u{342}\\u{36e}\\u{315}\\u{32c}\\u{30b}\\u{346}\\u{36a}\\\n        \\u{328}\\u{334}\\u{380}\\u{32e}\\u{359}\\u{36b}\\u{333}\\u{312}\\u{302}\\u{305}\\u{32e}\\u{357}\\u{349}\\\n        \\u{35f}\\u{316}\\u{33a}\\u{383}\\u{301}\\u{31d}\\u{360}\\u{35d}\\u{30c}\\u{30c}\\u{34a}\\u{367}ɂ\\\n        \\u{35f}\\u{308}\\u{353}\\u{333}\\u{381}\\u{30f}\\u{367}\\u{340}\\u{356}\\u{30c}\\u{351}\\u{33e}\\u{358}\\\n        \\u{351}\\u{366}\\u{38b}\\u{342}\\u{30c}\\u{31c}\\u{327}\\u{34a}\\u{36a}\\u{33f}\\u{34c}\\u{361}\\u{335}\\\n        \\u{318}\\u{349}\\u{35d}\\u{330}\\u{35c}\\u{320}\\u{348}\\u{324}\\u{31d}\\u{35c}\\u{332}\\u{33d}\\u{300}\\\n        \\u{326}\\u{329}\\u{33d}\\u{31f}\\u{363}\\u{320}\\u{321}\\u{31a}\\u{35c}\\u{304}\\u{365}\\u{34f}\\u{31f}\\\n        \\u{31e}\\u{32a}\\u{31a}\\u{307}\\u{319}\\u{310}\\u{369}\\u{359}\\u{33e}\\u{38d}\\u{31e}\\u{321}\\u{339}\\\n        \\u{330}\\u{30f}\\u{303}\\u{345}Ŝ\\u{32f}\\u{35f}\\u{33e}\\u{30c}\\u{313}\\u{365}\\u{356}\\u{36c}\\\n        \\u{36f}\\u{304}\\u{314}\\u{369}\\u{310}\\u{339}\\u{33f}\\u{354}\\u{347}\\u{378}\\u{366}\\u{380}Ȣ\\\n        \\u{326}\\u{313}\\u{383}\\u{36c}\\u{336}\\u{357}\\u{31e}\\u{324}\\u{317}\\u{351}\\u{323}\\u{328}\\u{330}\\\n        \\u{307}\\u{336}\\u{326}\\u{32a}\\u{350}\\u{342}\\u{315}\\u{36b}\\u{32b}\\u{382}\\u{34b}\\u{33d}\\u{34a}\\\n        \\u{314}\\u{322}\\u{311}\\u{364}\\u{34c}\\u{322}\\u{337}\\u{30c}\\u{362}\\u{317}\\u{300}\\u{348}\\u{367}\\\n        \\u{35b}\\u{353}\\u{32e}\\u{328}\\u{346}\\u{328}\\u{324}\\u{329}\\u{379}\\u{366}\\u{328}\\u{30f}\\u{31e}\\\n        \\u{368}\\u{368}\\u{38b}\\u{318}\\u{353}\\u{35d}\\u{31e}\\u{360}\\u{33c}\\u{315}\\u{33c}\\u{31f}\\u{323}\\\n        \\u{38b}\\u{379}\\u{38d}\\u{365}\\u{340}\",\n        &[\n            ('\\u{30d}', 8469),\n            ('\\u{326}', 8280),\n            ('\\u{327}', 8268),\n            ('\\u{357}', 8250),\n            ('\\u{30c}', 8244),\n            ('\\u{325}', 8242),\n            ('\\u{30a}', 8232),\n            ('\\u{30b}', 8232),\n            ('\\u{35d}', 8222),\n            ('\\u{36b}', 8221),\n        ],\n        ('\\u{33b}', None),\n    );\n    // '\\u{100}', '\\u{3ff}', p = 50/51\n    graphic_weighted_random_char_inclusive_range_helper(\n        '\\u{100}',\n        '\\u{3ff}',\n        50,\n        51,\n        \"ǘɂŜȢΙƘƣʅΰǟ˳ˊȇʰɥΈϞƃʌμƢϳϪǰɪŗŽƽɥϻƚʧƙϮșϒϢćɾɢǧǁʴȶƐďȭˬɂϰȁʺċλǿαăǰʹʃŰǐƬɖϾ\\u{31b}ƾƱǒȆɈϪʶťˍďǑɶɁȭƭğȾ˹\\\n        ĺǗʋǆ˺ʐǍŋɽɷϲŸȃĨŞ˭ƪřœɃˡϹƤǁĥɨʎʄˬıɐƺˀǍǷěέƼȞŞȩǀ΄ʱǱȭ\\u{324}ʚǃϧśŅˊǉΰϿǟϵȟǘĹϋȎʜɴϻϝͺĪƕ˪ϥŪˍʸĻέ˙ĠĢĄšǝ˿Ί\\\n        \\u{35a}ΗʩǊŰŦʝŋƶˈąŠɂŻǱƲɛΚʜťγ\\u{367}ϽϹčǇīϥſʏȵ\",\n        &[\n            ('Ώ', 1637),\n            ('Ɣ', 1627),\n            ('ɭ', 1618),\n            ('Έ', 1616),\n            ('Ɯ', 1613),\n            ('Ȓ', 1610),\n            ('Ǧ', 1609),\n            ('˵', 1608),\n            ('˷', 1607),\n            ('ƒ', 1606),\n        ],\n        ('ɉ', None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_inclusive_range_fail_1() {\n    graphic_weighted_random_char_inclusive_range(EXAMPLE_SEED, 'a', '\\u{80}', 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_inclusive_range_fail_2() {\n    graphic_weighted_random_char_inclusive_range(EXAMPLE_SEED, 'a', '\\u{80}', 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_inclusive_range_fail_3() {\n    graphic_weighted_random_char_inclusive_range(EXAMPLE_SEED, '\\u{80}', 'a', 1, 1);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_inclusive_range_fail_4() {\n    graphic_weighted_random_char_inclusive_range(EXAMPLE_SEED, 'a', 'z', 1, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/graphic_weighted_random_char_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::graphic_weighted_random_char_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn graphic_weighted_random_char_range_helper(\n    a: char,\n    b: char,\n    p_numerator: u64,\n    p_denominator: u64,\n    expected_values: &str,\n    expected_common_values: &[(char, usize)],\n    expected_median: (char, Option<char>),\n) {\n    let xs = graphic_weighted_random_char_range(EXAMPLE_SEED, a, b, p_numerator, p_denominator);\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_graphic_weighted_random_char_range() {\n    // 'a', '\\u{80}', p = 1/2\n    graphic_weighted_random_char_range_helper(\n        'a',\n        '\\u{80}',\n        1,\n        2,\n        \"\\u{7f}y\\u{7f}g\\u{7f}c\\u{7f}k\\u{7f}\\u{7f}}\\u{7f}ccjlybr\\u{7f}tue\\u{7f}}ye\\u{7f}oz\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}d\\u{7f}f\\u{7f}\\u{7f}\\u{7f}f\\u{7f}\\u{7f}fmxr\\u{7f}\\u{7f}\\u{7f}g\\u{7f}hy\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}q\\u{7f}\\u{7f}t\\u{7f}\\u{7f}pk\\u{7f}oh\\u{7f}\\u{7f}i\\\n        \\u{7f}q\\u{7f}\\u{7f}\\u{7f}\\u{7f}nf\\u{7f}\\u{7f}l\\u{7f}\\u{7f}\\u{7f}sqf\\u{7f}\\u{7f}t\\u{7f}d\\\n        \\u{7f}emm\\u{7f}|\\u{7f}{z|wu\\u{7f}dsc\\u{7f}\\u{7f}f{\\u{7f}t\\u{7f}r\\u{7f}t\\u{7f}q\\u{7f}\\u{7f}\\\n        \\u{7f}h\\u{7f}\\u{7f}\\u{7f}\\u{7f}klx~\\u{7f}x\\u{7f}\\u{7f}c\\u{7f}\\u{7f}u\\u{7f}l\\u{7f}\\u{7f}y\\\n        \\u{7f}~d\\u{7f}~\\u{7f}f\\u{7f}\\u{7f}m\\u{7f}xf\\u{7f}lkvcu{e\\u{7f}\\u{7f}b\\u{7f}\\u{7f}yh\\u{7f}\\\n        \\u{7f}nz\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}e\\u{7f}vu\\u{7f}\\u{7f}}\\u{7f}y\\u{7f}u\\u{7f}\\u{7f}\",\n        &[\n            ('\\u{7f}', 499332),\n            ('a', 16868),\n            ('t', 16831),\n            ('j', 16829),\n            ('r', 16822),\n            ('i', 16816),\n            ('f', 16806),\n            ('{', 16780),\n            ('s', 16763),\n            ('d', 16749),\n        ],\n        ('~', None),\n    );\n    // 'a', '\\u{80}', p = 1/51\n    graphic_weighted_random_char_range_helper(\n        'a',\n        '\\u{80}',\n        1,\n        51,\n        \"\\u{7f}\\u{7f}y\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}g\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}c\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}k\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\u{7f}\\\n        \\u{7f}\\u{7f}\",\n        &[\n            ('\\u{7f}', 980198),\n            ('h', 697),\n            ('n', 691),\n            ('i', 681),\n            ('w', 680),\n            ('r', 677),\n            ('a', 675),\n            ('|', 674),\n            ('q', 673),\n            ('e', 670),\n        ],\n        ('\\u{7f}', None),\n    );\n    // 'a', '\\u{80}', p = 50/51\n    graphic_weighted_random_char_range_helper(\n        'a',\n        '\\u{80}',\n        50,\n        51,\n        \"ygck}ccjlybrtue}yeozdfffmxrghyqtpkohiqnflsqftdemm|{z|wudscf{trtqh\\u{7f}klx~xculy~d~fmxflkv\\\n        cu{ebyhnzevu}yuzvtuz}{b~yyzin}zsjthazlcluvu}a\\u{7f}yvhhbgevdxo}unwjqepanjmpckouxtwwbi{nla\\\n        \\u{7f}cs{vphyrdaqhzndmqdqg\\u{7f}{{mfwk|xf\",\n        &[\n            ('a', 32996),\n            ('f', 32964),\n            ('q', 32960),\n            ('{', 32942),\n            ('s', 32886),\n            ('t', 32809),\n            ('d', 32768),\n            ('n', 32767),\n            ('p', 32766),\n            ('i', 32765),\n        ],\n        ('p', None),\n    );\n\n    // '\\u{100}', '\\u{400}', w = 1/2\n    graphic_weighted_random_char_range_helper(\n        '\\u{100}',\n        '\\u{400}',\n        1,\n        2,\n        \"\\u{31b}ǘ\\u{324}ɂ\\u{35a}Ŝ\\u{367}Ȣ\\u{337}\\u{342}Ι\\u{36e}Ƙƣʅΰǟ˳ˊ\\u{315}ȇʰɥ\\u{32c}ΈϞƃ\\u{30b}ʌμ\\\n        \\u{346}\\u{36a}\\u{328}\\u{334}Ƣ\\u{380}ϳ\\u{32e}\\u{359}\\u{36b}Ϫ\\u{333}\\u{312}ǰɪŗŽ\\u{302}\\u{305}\\\n        \\u{32e}ƽ\\u{357}ɥϻ\\u{349}\\u{35f}\\u{316}\\u{33a}\\u{383}\\u{301}\\u{31d}ƚ\\u{360}\\u{35d}ʧ\\u{30c}\\\n        \\u{30c}ƙϮ\\u{34a}șϒ\\u{367}\\u{35f}Ϣ\\u{308}ć\\u{353}\\u{333}\\u{381}\\u{30f}ɾɢ\\u{367}\\u{340}ǧ\\\n        \\u{356}\\u{30c}\\u{351}ǁʴȶ\\u{33e}\\u{358}Ɛ\\u{351}ď\\u{366}ȭˬɂ\\u{38b}ϰ\\u{342}ȁʺċλǿ\\u{30c}αăǰ\\\n        \\u{31c}\\u{327}ʹʃ\\u{34a}Ű\\u{36a}ǐ\\u{33f}Ƭ\\u{34c}ɖ\\u{361}\\u{335}\\u{318}Ͼ\\u{349}\\u{35d}\\u{330}\\\n        \\u{35c}ƾƱǒȆ\\u{320}Ɉ\\u{348}\\u{324}Ϫ\\u{31d}\\u{35c}ʶ\\u{332}ť\\u{33d}\\u{300}ˍ\\u{326}ďǑ\\u{329}ɶ\\\n        \\u{33d}Ɂ\\u{31f}\\u{363}ȭ\\u{320}ƭğ\\u{321}Ⱦ˹ĺǗʋǆ˺\\u{31a}\\u{35c}ʐ\\u{304}\\u{365}Ǎŋ\\u{34f}\\u{31f}\\\n        ɽɷ\\u{31e}\\u{32a}\\u{31a}\\u{307}\\u{319}ϲ\\u{310}Ÿȃ\\u{369}\\u{359}Ĩ\\u{33e}Ş\\u{38d}˭\\u{31e}\\\n        \\u{321}\",\n        &[\n            ('\\u{326}', 4271),\n            ('\\u{357}', 4238),\n            ('\\u{33b}', 4235),\n            ('\\u{36b}', 4235),\n            ('\\u{348}', 4228),\n            ('\\u{30b}', 4225),\n            ('\\u{304}', 4224),\n            ('\\u{30d}', 4224),\n            ('\\u{327}', 4221),\n            ('\\u{325}', 4217),\n        ],\n        ('\\u{319}', None),\n    );\n    // '\\u{100}', '\\u{400}', p = 1/51\n    graphic_weighted_random_char_range_helper(\n        '\\u{100}',\n        '\\u{400}',\n        1,\n        51,\n        \"\\u{31b}\\u{324}ǘ\\u{35a}\\u{367}\\u{337}\\u{342}\\u{36e}\\u{315}\\u{32c}\\u{30b}\\u{346}\\u{36a}\\\n        \\u{328}\\u{334}\\u{380}\\u{32e}\\u{359}\\u{36b}\\u{333}\\u{312}\\u{302}\\u{305}\\u{32e}\\u{357}\\u{349}\\\n        \\u{35f}\\u{316}\\u{33a}\\u{383}\\u{301}\\u{31d}\\u{360}\\u{35d}\\u{30c}\\u{30c}\\u{34a}\\u{367}ɂ\\\n        \\u{35f}\\u{308}\\u{353}\\u{333}\\u{381}\\u{30f}\\u{367}\\u{340}\\u{356}\\u{30c}\\u{351}\\u{33e}\\u{358}\\\n        \\u{351}\\u{366}\\u{38b}\\u{342}\\u{30c}\\u{31c}\\u{327}\\u{34a}\\u{36a}\\u{33f}\\u{34c}\\u{361}\\u{335}\\\n        \\u{318}\\u{349}\\u{35d}\\u{330}\\u{35c}\\u{320}\\u{348}\\u{324}\\u{31d}\\u{35c}\\u{332}\\u{33d}\\u{300}\\\n        \\u{326}\\u{329}\\u{33d}\\u{31f}\\u{363}\\u{320}\\u{321}\\u{31a}\\u{35c}\\u{304}\\u{365}\\u{34f}\\u{31f}\\\n        \\u{31e}\\u{32a}\\u{31a}\\u{307}\\u{319}\\u{310}\\u{369}\\u{359}\\u{33e}\\u{38d}\\u{31e}\\u{321}\\u{339}\\\n        \\u{330}\\u{30f}\\u{303}\\u{345}Ŝ\\u{32f}\\u{35f}\\u{33e}\\u{30c}\\u{313}\\u{365}\\u{356}\\u{36c}\\\n        \\u{36f}\\u{304}\\u{314}\\u{369}\\u{310}\\u{339}\\u{33f}\\u{354}\\u{347}\\u{378}\\u{366}\\u{380}Ȣ\\\n        \\u{326}\\u{313}\\u{383}\\u{36c}\\u{336}\\u{357}\\u{31e}\\u{324}\\u{317}\\u{351}\\u{323}\\u{328}\\u{330}\\\n        \\u{307}\\u{336}\\u{326}\\u{32a}\\u{350}\\u{342}\\u{315}\\u{36b}\\u{32b}\\u{382}\\u{34b}\\u{33d}\\u{34a}\\\n        \\u{314}\\u{322}\\u{311}\\u{364}\\u{34c}\\u{322}\\u{337}\\u{30c}\\u{362}\\u{317}\\u{300}\\u{348}\\u{367}\\\n        \\u{35b}\\u{353}\\u{32e}\\u{328}\\u{346}\\u{328}\\u{324}\\u{329}\\u{379}\\u{366}\\u{328}\\u{30f}\\u{31e}\\\n        \\u{368}\\u{368}\\u{38b}\\u{318}\\u{353}\\u{35d}\\u{31e}\\u{360}\\u{33c}\\u{315}\\u{33c}\\u{31f}\\u{323}\\\n        \\u{38b}\\u{379}\\u{38d}\\u{365}\\u{340}\",\n        &[\n            ('\\u{30d}', 8469),\n            ('\\u{326}', 8280),\n            ('\\u{327}', 8268),\n            ('\\u{357}', 8250),\n            ('\\u{30c}', 8244),\n            ('\\u{325}', 8242),\n            ('\\u{30a}', 8232),\n            ('\\u{30b}', 8232),\n            ('\\u{35d}', 8222),\n            ('\\u{36b}', 8221),\n        ],\n        ('\\u{33b}', None),\n    );\n    // '\\u{100}', '\\u{400}', p = 50/51\n    graphic_weighted_random_char_range_helper(\n        '\\u{100}',\n        '\\u{400}',\n        50,\n        51,\n        \"ǘɂŜȢΙƘƣʅΰǟ˳ˊȇʰɥΈϞƃʌμƢϳϪǰɪŗŽƽɥϻƚʧƙϮșϒϢćɾɢǧǁʴȶƐďȭˬɂϰȁʺċλǿαăǰʹʃŰǐƬɖϾ\\u{31b}ƾƱǒȆɈϪʶťˍďǑɶɁȭƭğȾ˹\\\n        ĺǗʋǆ˺ʐǍŋɽɷϲŸȃĨŞ˭ƪřœɃˡϹƤǁĥɨʎʄˬıɐƺˀǍǷěέƼȞŞȩǀ΄ʱǱȭ\\u{324}ʚǃϧśŅˊǉΰϿǟϵȟǘĹϋȎʜɴϻϝͺĪƕ˪ϥŪˍʸĻέ˙ĠĢĄšǝ˿Ί\\\n        \\u{35a}ΗʩǊŰŦʝŋƶˈąŠɂŻǱƲɛΚʜťγ\\u{367}ϽϹčǇīϥſʏȵ\",\n        &[\n            ('Ώ', 1637),\n            ('Ɣ', 1627),\n            ('ɭ', 1618),\n            ('Έ', 1616),\n            ('Ɯ', 1613),\n            ('Ȓ', 1610),\n            ('Ǧ', 1609),\n            ('˵', 1608),\n            ('˷', 1607),\n            ('ƒ', 1606),\n        ],\n        ('ɉ', None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_range_fail_1() {\n    graphic_weighted_random_char_range(EXAMPLE_SEED, 'a', '\\u{80}', 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_range_fail_2() {\n    graphic_weighted_random_char_range(EXAMPLE_SEED, 'a', '\\u{80}', 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_range_fail_3() {\n    graphic_weighted_random_char_range(EXAMPLE_SEED, '\\u{80}', 'a', 1, 1);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_char_range_fail_4() {\n    graphic_weighted_random_char_range(EXAMPLE_SEED, 'a', 'z', 1, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/graphic_weighted_random_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::graphic_weighted_random_chars;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn graphic_weighted_random_chars_helper(\n    p_numerator: u64,\n    p_denominator: u64,\n    expected_values: &str,\n    expected_common_values: &[(char, usize)],\n    expected_median: (char, Option<char>),\n) {\n    let xs = graphic_weighted_random_chars(EXAMPLE_SEED, p_numerator, p_denominator);\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_graphic_weighted_random_chars() {\n    // p = 1/2\n    graphic_weighted_random_chars_helper(\n        1,\n        2,\n        \"\\u{90141}𗄡\\u{3a6f5}𭼭\\u{d9ae0}礜\\u{e9c8d}깬\\u{3b5ce}\\u{d5d73}ꅉ\\u{8ea12}杼쭗𫆬╳𲐕𡺽⢏\\u{3b038}𲣍𮛊瀊\\\n        \\u{74682}𰥶𲛂ՠ\\u{c9ca4}𥐷𨫉\\u{c76d1}\\u{55d29}\\u{f10a9}\\u{38719}𥧻\\u{f48f9}𤜖\\u{1943f}\\u{38880}\\\n        \\u{5d11b}𠡩\\u{e2590}\\u{c30b6}𰭝🈱𰠲厨\\u{fc1b9}\\u{ad565}\\u{70791}𠀓\\u{ed09c}𩰦⋘\\u{1b138}\\u{3596f}\\\n        \\u{6457d}\\u{798a6}\\u{b3ee3}\\u{f9067}\\u{77896}𑇫\\u{eeda4}\\u{f41c9}𐤚\\u{37247}\\u{da9a4}⎖𡙄\\\n        \\u{a2ae4}摕𮨱\\u{aa868}\\u{77563}𖭨\\u{feca2}𰊗\\u{707ed}\\u{4f05d}\\u{6a423}\\u{cae98}蚆𓈧\\u{1c058}\\\n        \\u{103a5d}𥍎\\u{6185a}\\u{7e601}\\u{55835}𓪞𤪨𠷯\\u{c80f7}\\u{d7686}뛕\\u{15f71}䂇\\u{8c53b}𡴬Ở쀖\\\n        \\u{3cec3}𝓩\\u{648a3}𪔭𪣂𓑫憒쇝\\u{6b44b}𭋋㆐쬾\\u{5a137}\\u{8a66b}𣌺𲙃\\u{11e7c}𪪯\\u{a0d66}𐓍\\u{d0f11}ჷ\\\n        \\u{6d431}𡙫\\u{70e7a}\\u{c27cf}\\u{a1819}𭕍\\u{b3f9e}\\u{44b14}\\u{d5c59}\\u{87e6d}𜵐𦀢죍呶\\u{9f484}𫪬\\\n        \\u{1000c5}\\u{56709}䍪\\u{bcc29}\\u{8fb24}𧠨\\u{53577}姖\\u{f3a83}\\u{a6dad}𭩝\\u{e42cf}𦠄𰒁\\u{f61a3}𫵥\\\n        \\u{b56a5}𐌞\\u{c789e}\\u{e83ec}䆞\\u{45ddc}𪠊𒐆\\u{db711}𲪃𳇴뎒𡟨𘋯𓃸𥙨\\u{ce6cc}\\u{5a49d}㨟\\u{92ece}\\\n        \\u{c7883}ֆ뇫\\u{bbf05}\\u{85be0}𩬳𦜟\\u{edae}\\u{b7331}\\u{fd6e7}\\u{12bbe}\\u{ae977}𘇶\\u{c77c5}𝓈譀\\\n        \\u{426f7}\\u{9fda3}𢷏\\u{ce98c}𘁉\\u{6b0b9}𝆵\\u{cc4fa}\\u{49c49}\",\n        &[\n            ('𗎫', 13),\n            ('𧯐', 13),\n            ('𪬏', 13),\n            ('𲍾', 13),\n            ('Ẅ', 12),\n            ('罚', 12),\n            ('뛱', 12),\n            ('ﬢ', 12),\n            ('𘀧', 12),\n            ('𛰸', 12),\n        ],\n        ('𱎧', None),\n    );\n    // p = 1/51\n    graphic_weighted_random_chars_helper(\n        1,\n        51,\n        \"\\u{90141}\\u{3a6f5}𗄡\\u{d9ae0}\\u{e9c8d}\\u{3b5ce}\\u{d5d73}\\u{8ea12}\\u{3b038}\\u{74682}\\\n        \\u{c9ca4}\\u{c76d1}\\u{55d29}\\u{f10a9}\\u{38719}\\u{f48f9}\\u{1943f}\\u{38880}\\u{5d11b}\\u{e2590}\\\n        \\u{c30b6}\\u{fc1b9}\\u{ad565}\\u{70791}\\u{ed09c}\\u{1b138}\\u{3596f}\\u{6457d}\\u{798a6}\\u{b3ee3}\\\n        \\u{f9067}\\u{77896}\\u{eeda4}\\u{f41c9}\\u{37247}\\u{da9a4}\\u{a2ae4}\\u{aa868}𭼭\\u{77563}\\\n        \\u{feca2}\\u{707ed}\\u{4f05d}\\u{6a423}\\u{cae98}\\u{1c058}\\u{103a5d}\\u{6185a}\\u{7e601}\\\n        \\u{55835}\\u{c80f7}\\u{d7686}\\u{15f71}\\u{8c53b}\\u{3cec3}\\u{648a3}\\u{6b44b}\\u{5a137}\\u{8a66b}\\\n        \\u{11e7c}\\u{a0d66}\\u{d0f11}\\u{6d431}\\u{70e7a}\\u{c27cf}\\u{a1819}\\u{b3f9e}\\u{44b14}\\u{d5c59}\\\n        \\u{87e6d}\\u{9f484}\\u{1000c5}\\u{56709}\\u{bcc29}\\u{8fb24}\\u{53577}\\u{f3a83}\\u{a6dad}\\\n        \\u{e42cf}\\u{f61a3}\\u{b56a5}\\u{c789e}\\u{e83ec}\\u{45ddc}\\u{db711}\\u{ce6cc}\\u{5a49d}\\u{92ece}\\\n        \\u{c7883}\\u{bbf05}\\u{85be0}\\u{edae}\\u{b7331}\\u{fd6e7}\\u{12bbe}\\u{ae977}\\u{c77c5}\\u{426f7}\\\n        \\u{9fda3}\\u{ce98c}\\u{6b0b9}\\u{cc4fa}\\u{49c49}\\u{fefd4}\\u{49ed9}\\u{78198}\\u{4473f}\\u{366ef}\\\n        礜\\u{bd970}\\u{ea269}\\u{9212c}\\u{71474}\\u{3d023}\\u{5a63f}\\u{55acd}\\u{fa199}\\u{bb388}\\\n        \\u{101b0}\\u{9d8ed}\\u{eb14a}\\u{fa5db}\\u{e338b}\\u{f9cd0}\\u{2f1db}\\u{8e5ec}\\u{37c8e}\\u{771fa}\\\n        \\u{b74cb}깬\\u{aab2a}\\u{e024b}\\u{10d4e8}\\u{92de4}\\u{fa12f}\\u{42b42}\\u{1a2f2}\\u{afd94}\\\n        \\u{8318f}\\u{73fd1}\\u{44439}\\u{72279}\\u{103ded}\\u{7ad52}\\u{1098eb}\\u{f3200}\\u{97125}\\\n        \\u{8165f}\\u{c26b9}\\u{ad664}\\u{b0861}\\u{cd9f9}\\u{d068f}\\u{f9180}\\u{c6a23}\\u{ba7a0}\\u{896a0}\\\n        \\u{a2ae2}\\u{109104}\\u{d8e4d}\\u{53bb5}\\u{10be12}\\u{cf22d}\\u{d361f}\\u{a126c}\\u{c6710}\\\n        \\u{68b09}\\u{bd7b6}\\u{7894a}\\u{c4004}\\u{51bea}\\u{506d1}\\u{b9e4e}\\u{a300c}\\u{fbea6}\\u{f0f37}\\\n        \\u{565c6}\\u{1184c}\\u{1c479}\\u{359ab}\\u{38f38}\\u{198e3}\\u{ad730}\\u{7df6f}\\u{540ee}\\u{14e95}\\\n        \\u{3e57d}\\u{fded1}\\u{4613f}\\u{bdc98}\\u{567d6}\\u{7f434}\\u{b47aa}\\u{8adc0}\\u{f6f1d}\\u{e2068}\\\n        \\u{b8913}\\u{3401b}\\u{e9f10}\\u{debe0}\",\n        &[\n            ('\\u{7cb51}', 9),\n            ('\\u{9f2b9}', 9),\n            ('\\u{39d1d}', 8),\n            ('\\u{3f6cd}', 8),\n            ('\\u{654c8}', 8),\n            ('\\u{66ab5}', 8),\n            ('\\u{6cbc3}', 8),\n            ('\\u{7cf6b}', 8),\n            ('\\u{9d925}', 8),\n            ('\\u{a99f8}', 8),\n        ],\n        ('\\u{99011}', None),\n    );\n    // p = 50/51\n    graphic_weighted_random_chars_helper(\n        50,\n        51,\n        \"𗄡𭼭礜깬ꅉ杼쭗𫆬╳𲐕𡺽⢏𲣍𮛊瀊𰥶𲛂ՠ𥐷𨫉𥧻𤜖𠡩𰭝🈱𰠲厨𠀓𩰦⋘𑇫𐤚⎖𡙄摕𮨱𖭨𰊗蚆𓈧𥍎𓪞𤪨𠷯뛕䂇𡴬Ở쀖𝓩𪔭𪣂𓑫憒쇝𭋋㆐쬾𣌺𲙃𪪯𐓍ჷ𡙫𭕍\\u{90141}𜵐𦀢죍呶𫪬䍪𧠨姖𭩝𦠄𰒁𫵥𐌞䆞𪠊\\\n        𒐆𲪃𳇴뎒𡟨𘋯𓃸𥙨㨟ֆ뇫𩬳𦜟𘇶𝓈譀𢷏𘁉𝆵鎋彔𮂔𥌴𠵀𘯴𥷀𱠪𫃗𬁵𑄷蠃𰱩𨨜鐔𛇛ㅐ耂𤁤ꔺ𥚍𦖇歠𠝼퉫𤰃𤋡笃羼𠼆\\u{3a6f5}𗼌𡝿𓳸𢏼𰮬𫽩敃置𥟓𢚩𢇠𣗡𗎫ᕵ붏삇𓡫𦬓闑贛𧴈𒾭𬱞𤉀𨯝𣘉𑨬𫸊𮂺𢽋掟𞡙\\\n        ✄㕵굜𖪢𥘀㾒\\u{d9ae0}𖭤𱹜褱𓖫𭗺𦢓𐽺튕䯷𘳏𩶇𞹔𗟦釽쥐達헷𦩫𳈂𫛘\\u{e9c8d}𗮶𠃅𘱜裳𦃿Ǐ𪥈𲜳䖇\",\n        &[\n            ('𗔓', 20),\n            ('𲍾', 20),\n            ('ﱠ', 19),\n            ('𓕋', 19),\n            ('𬏄', 19),\n            ('𳅸', 19),\n            ('䦯', 18),\n            ('幋', 18),\n            ('跠', 18),\n            ('𗢹', 18),\n        ],\n        ('🂄', Some('🂅')),\n    );\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_chars_fail_1() {\n    graphic_weighted_random_chars(EXAMPLE_SEED, 0, 0);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_chars_fail_2() {\n    graphic_weighted_random_chars(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn graphic_weighted_random_chars_fail_3() {\n    graphic_weighted_random_chars(EXAMPLE_SEED, 2, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/random_ascii_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::random_ascii_chars;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\n#[test]\nfn test_random_ascii_chars() {\n    let xs = random_ascii_chars(EXAMPLE_SEED);\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (\n            \"q^\\u{17}bF\\\\4T!/\\u{1}q6\\n/\\u{11}Y\\\\wB\\\\r\\\\^\\u{15}3\\'.\\'r\\u{7}$\\u{17}S:\\rr@I(\\u{10}\\\n            \\u{11}}\\u{b}\\u{7}0z5.n1\\u{10}At<9.w\\\\?b\\u{15}(\\\\hJ\\u{10}cO\\\\^5Edc\\u{1f}kq{t=z./\\u{5}x\\\n            \\u{1}dZrJ%\\u{5}`=VU_\\u{7f}b;\\u{13}\\u{6}U.k\\r\\u{6}PBk]$p\\u{1a}+FOH.\\r,a\\u{1}=DZZ\\u{16}\\\n            \\u{18}cY\\t\\u{1e}\\u{19}&<,\\u{13}%\\u{c}{Z!$Z,\\u{17}\\u{8}?\\u{3}\\u{4}]\\u{1}H\\u{c}(K*|l\\\n            \\u{15}8^:\\u{e}\\u{7f}D(P\\u{1}XEk!$\\u{14}/];E9d\\u{e})|v\\u{e}W*).\\u{19}\\u{11}5\\u{7f}b8\\\n            \\u{18}:\",\n            &[\n                ('\\u{2}', 8077),\n                ('y', 8039),\n                ('0', 8015),\n                ('q', 7966),\n                ('\\u{8}', 7937),\n                ('M', 7933),\n                ('2', 7928),\n                ('[', 7927),\n                ('R', 7925),\n                ('f', 7924)\n            ][..],\n            ('?', None)\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/random_char_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn random_char_inclusive_range_helper(\n    a: char,\n    b: char,\n    expected_values: &str,\n    expected_common_values: &[(char, usize)],\n    expected_median: (char, Option<char>),\n) {\n    let xs = random_char_inclusive_range(EXAMPLE_SEED, a, b);\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_char_inclusive_range() {\n    random_char_inclusive_range_helper(\n        'a',\n        'a',\n        \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n        aaaaaaaaaaaaaaaaaaa\",\n        &[('a', 1000000)],\n        ('a', None),\n    );\n    random_char_inclusive_range_helper(\n        'a',\n        'c',\n        \"babcbbabacbabccabacccbaccbbbaacaccbabbaccacabcbbccbbbacabbbcabbcbbbcbcbbcabbbcabcbaacabbbc\\\n        bccccccbacabaacbcababbaabcacabbbabaaacbccccbccabbaaacabaabccacabccccabbcacccaaccaccaccbbbca\\\n        abcbaabcccbccbbbabc\",\n        &[('b', 333784), ('c', 333516), ('a', 332700)],\n        ('b', None),\n    );\n    random_char_inclusive_range_helper(\n        'a',\n        'z',\n        \"rlewrsgkdlbeouylrelopxqkoonftexoshqulgvonioatekqesxybqjsrbsajhpzzvzpcxcuyfkcsrexwwcjymyxhj\\\n        pxkbyhasvvkwucaopwwpxyncdkvllxbdavqlxlsaxglzyhrulnqvqdipeklnnbgdhejggrhwgjjmmpndcjsvlqypdqq\\\n        odasmavfvcmxcvoopcr\",\n        &[\n            ('x', 38904),\n            ('q', 38795),\n            ('s', 38687),\n            ('w', 38660),\n            ('d', 38655),\n            ('f', 38647),\n            ('a', 38592),\n            ('n', 38569),\n            ('j', 38531),\n            ('z', 38530),\n        ],\n        ('n', None),\n    );\n    random_char_inclusive_range_helper(\n        '!',\n        '9',\n        \"2,%723\\'+$,\\\"%/59,2%,/081+//.&4%8/3(15,\\'6/.)/!4%+1%389\\\"1*32\\\"3!*(060#8#59&+#32%877#*9-98\\\n        (*08+\\\"9(!366+75#!/077089.#$+6,,8\\\"$!61,8,3!8\\',9(25,.161$)0%+,..\\\"\\'$(%*\\'\\'2(7\\'**--0.$#*\\\n        36,190$11/$!3-!6&6#-8#6//0#2#5\\\"!\",\n        &[\n            ('8', 40444),\n            ('1', 40300),\n            ('7', 40244),\n            ('3', 40201),\n            ('&', 40174),\n            ('$', 40171),\n            ('.', 40117),\n            ('*', 40111),\n            ('!', 40107),\n            ('#', 40076),\n        ],\n        ('-', None),\n    );\n    random_char_inclusive_range_helper(\n        '\\u{D7FF}',\n        '\\u{E000}',\n        \"\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\\n        \\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\\n        \\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\",\n        &[('\\u{e000}', 500473), ('\\u{d7ff}', 499527)],\n        ('\\u{e000}', None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_char_inclusive_range_fail() {\n    random_char_inclusive_range(EXAMPLE_SEED, 'b', 'a');\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/random_char_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::random_char_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn random_char_range_helper(\n    a: char,\n    b: char,\n    expected_values: &str,\n    expected_common_values: &[(char, usize)],\n    expected_median: (char, Option<char>),\n) {\n    let xs = random_char_range(EXAMPLE_SEED, a, b);\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_char_range() {\n    random_char_range_helper(\n        'a',\n        'b',\n        \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\n        aaaaaaaaaaaaaaaaaaa\",\n        &[('a', 1000000)],\n        ('a', None),\n    );\n    random_char_range_helper(\n        'a',\n        'd',\n        \"babcbbabacbabccabacccbaccbbbaacaccbabbaccacabcbbccbbbacabbbcabbcbbbcbcbbcabbbcabcbaacabbbc\\\n        bccccccbacabaacbcababbaabcacabbbabaaacbccccbccabbaaacabaabccacabccccabbcacccaaccaccaccbbbca\\\n        abcbaabcccbccbbbabc\",\n        &[('b', 333784), ('c', 333516), ('a', 332700)],\n        ('b', None),\n    );\n    random_char_range_helper(\n        'a',\n        'z',\n        \"rlewrsgkdlbeouylrelopxqkoonftexoshqulgvonioatekqesxybqjsrbsajhpvpcxcuyfkcsrexwwcjymyxhjpxk\\\n        byhasvvkwucaopwwpxyncdkvllxbdavqlxlsaxglyhrulnqvqdipeklnnbgdhejggrhwgjjmmpndcjsvlqypdqqodas\\\n        mavfvcmxcvoopcrcuba\",\n        &[\n            ('x', 40444),\n            ('q', 40300),\n            ('w', 40244),\n            ('s', 40201),\n            ('f', 40174),\n            ('d', 40171),\n            ('n', 40117),\n            ('j', 40111),\n            ('a', 40107),\n            ('c', 40076),\n        ],\n        ('m', None),\n    );\n    random_char_range_helper(\n        '!',\n        '9',\n        \"2,%723\\'+$,\\\"%/5,2%,/081+//.&4%8/3(15,\\'6/.)/!4%+1%38\\\"1*32\\\"3!*(060#8#5&+#32%877#*-8(*08+\\\n        \\\"(!366+75#!/07708.#$+6,,8\\\"$!61,8,3!8\\',(25,.161$)0%+,..\\\"\\'$(%*\\'\\'2(7\\'**--0.$#*36,10$11\\\n        /$!3-!6&6#-8#6//0#2#5\\\"!#8/)%238/\",\n        &[\n            ('8', 42093),\n            ('1', 42031),\n            ('$', 41908),\n            ('3', 41887),\n            ('&', 41836),\n            ('7', 41830),\n            ('!', 41753),\n            ('.', 41753),\n            ('*', 41699),\n            ('+', 41673),\n        ],\n        ('-', None),\n    );\n    random_char_range_helper(\n        '\\u{D7FF}',\n        '\\u{E001}',\n        \"\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\\n        \\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\\n        \\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{d7ff}\\\n        \\u{e000}\\u{d7ff}\\u{d7ff}\\u{e000}\\u{e000}\\u{e000}\\u{d7ff}\\u{e000}\\u{d7ff}\\u{e000}\\u{e000}\\\n        \\u{e000}\\u{d7ff}\",\n        &[('\\u{e000}', 500473), ('\\u{d7ff}', 499527)],\n        ('\\u{e000}', None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_char_range_fail() {\n    random_char_range(EXAMPLE_SEED, 'a', 'a');\n}\n"
  },
  {
    "path": "malachite-base/tests/chars/random/random_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::chars::random::random_chars;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\n#[test]\nfn test_random_chars() {\n    let xs = random_chars(EXAMPLE_SEED);\n    let values = xs.clone().take(200).collect::<String>();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_str(), common_values.as_slice(), median),\n        (\n            \"\\u{5f771}\\u{87234}\\u{bcd36}\\u{9e195}\\u{5da07}\\u{36553}\\u{45028}\\u{1cdfd}\\u{d8530}\\\n            \\u{c7f2e}\\u{ba4bc}\\u{ff677}\\u{a12e2}\\u{d775c}\\u{f827b}\\u{bdf7a}簅\\u{15aca}\\u{4e5e2}\\\n            \\u{bb286}\\u{18eeb}\\u{bac4f}\\u{5b55a}\\u{65709}\\u{b2626}\\u{31a93}\\u{8757b}\\u{b3524}\\\n            \\u{fcc17}\\u{32c01}\\u{aada8}\\u{57e7c}\\u{eb738}栨\\u{51a21}\\u{ef6af}\\u{b9caa}\\u{d5099}\\\n            \\u{e397f}\\u{32518}\\u{6952d}\\u{93ad5}\\u{65c6e}\\u{dc7bd}\\u{aec4c}\\u{dd524}\\u{c0bc1}\\\n            \\u{795d0}\\u{dbb9d}\\u{a50fb}紐\\u{4effe}\\u{794af}\\u{1b5a0}\\u{56be3}\\u{78fc9}\\u{5870a}\\\n            \\u{106f48}\\u{dfffa}\\u{3cc01}\\u{91290}\\u{4628e}\\u{bee71}\\u{70e90}\\u{b48bb}\\u{3a445}\\\n            \\u{10a645}𬆠\\u{e59de}\\u{61b5a}\\u{f4783}\\u{c5ab2}幔\\u{fdb07}\\u{abccb}\\u{ba750}\\u{88d5a}\\\n            \\u{a706e}\\u{969a2}\\u{1089e3}\\u{102189}\\u{5f066}\\u{10ea66}\\u{435bb}\\u{bcbd6}\\u{4bc59}𱆞\\\n            \\u{f50a0}\\u{47bc1}\\u{5fd98}\\u{91a7a}\\u{100a8d}\\u{e0017}\\u{9db06}\\u{1ab04}\\u{780f6}ㅚ\\\n            \\u{5fc0a}\\u{fb714}\\u{c62cd}\\u{b22dc}\\u{10364e}\\u{ee477}\\u{f0983}\\u{b5c36}\\u{41f7b}\\\n            \\u{bdf28}\\u{b27f7}\\u{94dc8}\\u{73381}\\u{34609}\\u{52911}\\u{e56bf}\\u{100af4}\\u{396ff}\\\n            \\u{1051a8}𬅑\\u{815dc}\\u{fd1e7}\\u{e6e9c}攠\\u{eceaa}\\u{10029d}\\u{5e236}\\u{d963b}\\u{bbb1a}\\\n            \\u{108b67}\\u{e5bc3}\\u{97108}𢔱\\u{9f166}\\u{dedb4}\\u{52752}\\u{45bf5}\\u{86d73}\\u{ff2fd}쫵\\\n            \\u{78f74}\\u{93bc0}\\u{c308f}\\u{e8b6}\\u{89619}\\u{1cdf9}\\u{b9c86}\\u{9f375}\\u{c2487}\\\n            \\u{e1c3e}\\u{f6e29}\\u{79cc5}𬑎\\u{9a803}\\u{bf22e}\\u{7e88e}\\u{c50e8}\\u{58c32}\\u{79248}𰥦\\\n            \\u{b238b}\\u{104b92}\\u{8cc78}\\u{eecc5}𢇡\\u{e1fb6}\\u{625ab}\\u{a1988}䮨\\u{bbaa5}\\u{143be}\\\n            \\u{a12d4}\\u{1028e1}\\u{1c105}\\u{9493f}\\u{efa70}\\u{13487}紋\\u{b1948}\\u{89052}\\u{8c3cb}\\\n            \\u{b82d2}\\u{729c3}\\u{10c5ba}\\u{dec07}𰢫\\u{d277f}\\u{3e5dc}\\u{52431}\\u{4867e}\\u{75774}𪲨\\\n            \\u{b865a}\\u{105191}\\u{93891}\\u{c4975}\\u{c2f58}\\u{d387c}\\u{157dd}\\u{77a83}\\u{d6eec}\\\n            \\u{b2581}\\u{9bb09}\",\n            &[\n                ('\\u{1e21d}', 8),\n                ('\\u{bd934}', 8),\n                ('\\u{dc941}', 8),\n                ('䄡', 7),\n                ('霜', 7),\n                ('𐊩', 7),\n                ('𣡝', 7),\n                ('𦇍', 7),\n                ('𩩻', 7),\n                ('𰊻', 7)\n            ][..],\n            ('\\u{88629}', Some('\\u{8862a}'))\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/comparison/macros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen, signed_triple_gen, unsigned_gen, unsigned_pair_gen_var_27,\n    unsigned_triple_gen_var_19,\n};\nuse std::cmp::{max, min};\n\n#[test]\npub fn test_min() {\n    assert_eq!(min!(4), 4);\n    assert_eq!(min!(4, 5, 6), 4);\n}\n\n#[test]\npub fn test_max() {\n    assert_eq!(max!(4), 4);\n    assert_eq!(max!(4, 5, 6), 6);\n}\n\nfn unsigned_max_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(max!(x), x);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(max!(x, y), max(x, y));\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        assert_eq!(max!(x, y, z), max(max(x, y), z));\n        assert_eq!(max!(x, y, z), max(x, max(y, z)));\n    });\n}\n\nfn signed_max_properties_helper<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(max!(x), x);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(max!(x, y), max(x, y));\n    });\n\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        assert_eq!(max!(x, y, z), max(max(x, y), z));\n        assert_eq!(max!(x, y, z), max(x, max(y, z)));\n    });\n}\n\n#[test]\nfn max_properties() {\n    apply_fn_to_unsigneds!(unsigned_max_properties_helper);\n    apply_fn_to_signeds!(signed_max_properties_helper);\n}\n\nfn unsigned_min_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(min!(x), x);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(min!(x, y), min(x, y));\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        assert_eq!(min!(x, y, z), min(min(x, y), z));\n        assert_eq!(min!(x, y, z), min(x, min(y, z)));\n    });\n}\n\nfn signed_min_properties_helper<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(min!(x), x);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(min!(x, y), min(x, y));\n    });\n\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        assert_eq!(min!(x, y, z), min(min(x, y), z));\n        assert_eq!(min!(x, y, z), min(x, min(y, z)));\n    });\n}\n\n#[test]\nfn min_properties() {\n    apply_fn_to_unsigneds!(unsigned_min_properties_helper);\n    apply_fn_to_signeds!(signed_min_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/extra_variadic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse malachite_base::iterators::iterator_cache::IteratorCache;\nuse malachite_base::num::arithmetic::traits::CheckedPow;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::iterators::{RulerSequence, ruler_sequence};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::num::random::{RandomUnsignedRange, random_unsigned_range};\nuse malachite_base::random::Seed;\nuse malachite_base::sets::random::{RandomBTreeSetsFixedLength, random_b_tree_sets_fixed_length};\nuse malachite_base::tuples::exhaustive::{\n    ExhaustiveDependentPairs, clone_helper, exhaustive_dependent_pairs,\n};\nuse malachite_base::tuples::random::next_helper;\nuse malachite_base::unions::UnionFromStrError;\nuse malachite_base::vecs::ExhaustiveVecPermutations;\nuse malachite_base::vecs::exhaustive::{\n    ExhaustiveOrderedUniqueCollections, ExhaustiveUniqueVecsGenerator, LexFixedLengthVecsOutput,\n    UniqueIndices, exhaustive_ordered_unique_vecs_fixed_length,\n    fixed_length_ordered_unique_indices_helper, next_bit_pattern, unique_indices, validate_oi_map,\n};\nuse std::cmp::max;\nuse std::collections::HashMap;\nuse std::fmt::{self, Display, Formatter};\nuse std::hash::Hash;\nuse std::marker::PhantomData;\nuse std::str::FromStr;\n\nfn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n    (a.unwrap(), b.unwrap(), c.unwrap())\n}\n\nlex_custom_tuples! {\n    (pub(crate)),\n    LexTriplesXXY,\n    (X, X, Y),\n    (None, None, None),\n    unwrap_triple,\n    lex_triples_xxy,\n    [X, I, xs, [0, x_0], [1, x_1]],\n    [Y, J, ys, [2, y_2]]\n}\n\nlex_custom_tuples!(\n    (pub(crate)),\n    LexTriplesXYX,\n    (X, Y, X),\n    (None, None, None),\n    unwrap_triple,\n    lex_triples_xyx,\n    [X, I, xs, [0, x_0], [2, x_2]],\n    [Y, J, ys, [1, y_1]]\n);\n\nlex_tuples!(\n    (pub(crate)),\n    3,\n    LexTriples,\n    LexTriplesFromSingle,\n    lex_triples,\n    lex_triples_from_single,\n    (T, T, T),\n    [0, X, I, xs, x],\n    [1, Y, J, ys, y],\n    [2, Z, K, zs, z]\n);\n\nlex_tuples!(\n    (pub(crate)),\n    4,\n    LexQuadruples,\n    LexQuadruplesFromSingle,\n    lex_quadruples,\n    lex_quadruples_from_single,\n    (T, T, T, T),\n    [0, X, I, xs, x],\n    [1, Y, J, ys, y],\n    [2, Z, K, zs, z],\n    [3, W, L, ws, w]\n);\n\nlex_tuples!(\n    (pub(crate)),\n    5,\n    LexQuintuples,\n    LexQuintuplesFromSingle,\n    lex_quintuples,\n    lex_quintuples_from_single,\n    (T, T, T, T, T),\n    [0, X, I, xs, x],\n    [1, Y, J, ys, y],\n    [2, Z, K, zs, z],\n    [3, W, L, ws, w],\n    [4, V, M, vs, v]\n);\n\nlex_tuples!(\n    (pub(crate)),\n    8,\n    LexOctuples,\n    LexOctuplesFromSingle,\n    lex_octuples,\n    lex_octuples_from_single,\n    (T, T, T, T, T, T, T, T),\n    [0, X, I, xs, x],\n    [1, Y, J, ys, y],\n    [2, Z, K, zs, z],\n    [3, W, L, ws, w],\n    [4, V, M, vs, v],\n    [5, U, N, us, u],\n    [6, T, O, ts, t],\n    [7, S, P, ss, s]\n);\n\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveTriples1Input,\n    exhaustive_triples_1_input,\n    exhaustive_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveQuadruples1Input,\n    exhaustive_quadruples_1_input,\n    exhaustive_quadruples_from_single,\n    (I::Item, I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveQuintuples1Input,\n    exhaustive_quintuples_1_input,\n    exhaustive_quintuples_from_single,\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w],\n    [4, output_type_v]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveOctuples1Input,\n    exhaustive_octuples_1_input,\n    exhaustive_octuples_from_single,\n    (\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item\n    ),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w],\n    [4, output_type_v],\n    [5, output_type_u],\n    [6, output_type_t],\n    [7, output_type_s]\n);\n\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveTriplesXXY,\n    (X, X, Y),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xxy,\n    exhaustive_triples_xxy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]]\n);\ncustom_tuples!(\n     (pub(crate)),\n     ExhaustiveTriplesXYX,\n     (X, Y, X),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xyx,\n    exhaustive_triples_xyx_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_ys_1]],\n    [Y, J, ys, ys_done, [1, output_type_xs_2]]\n);\n\nlex_ordered_unique_tuples!(\n     (pub(crate)),\n     LexOrderedUniqueTriples,\n     3,\n     (I::Item, I::Item, I::Item),\n    lex_ordered_unique_triples,\n    [0, 1, 2]\n);\nlex_ordered_unique_tuples!(\n    (pub(crate)),\n    LexOrderedUniqueQuadruples,\n    4,\n    (I::Item, I::Item, I::Item, I::Item),\n    lex_ordered_unique_quadruples,\n    [0, 1, 2, 3]\n);\nlex_ordered_unique_tuples!(\n    (pub(crate)),\n    LexOrderedUniqueQuintuples,\n    5,\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    lex_ordered_unique_quintuples,\n    [0, 1, 2, 3, 4]\n);\n\nexhaustive_ordered_unique_tuples!(\n    (pub(crate)),\n    ExhaustiveOrderedUniqueTriples,\n    3,\n    (I::Item, I::Item, I::Item),\n    exhaustive_ordered_unique_triples,\n    [0, 1, 2]\n);\nexhaustive_ordered_unique_tuples!(\n    (pub(crate)),\n    ExhaustiveOrderedUniqueQuadruples,\n    4,\n    (I::Item, I::Item, I::Item, I::Item),\n    exhaustive_ordered_unique_quadruples,\n    [0, 1, 2, 3]\n);\nexhaustive_ordered_unique_tuples!(\n    (pub(crate)),\n    ExhaustiveOrderedUniqueQuintuples,\n    5,\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    exhaustive_ordered_unique_quintuples,\n    [0, 1, 2, 3, 4]\n);\n\nlex_unique_tuples!(\n     (pub(crate)),\n     LexUniqueTriples,\n     3,\n     (I::Item, I::Item, I::Item),\n    lex_unique_triples,\n    [0, 1, 2]\n);\nlex_unique_tuples!(\n    (pub(crate)),\n    LexUniqueQuadruples,\n    4,\n    (I::Item, I::Item, I::Item, I::Item),\n    lex_unique_quadruples,\n    [0, 1, 2, 3]\n);\nlex_unique_tuples!(\n    (pub(crate)),\n    LexUniqueQuintuples,\n    5,\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    lex_unique_quintuples,\n    [0, 1, 2, 3, 4]\n);\n\nexhaustive_unique_tuples!(\n     (pub(crate)),\n     ExhaustiveUniqueTriples,\n     3,\n     (I::Item, I::Item, I::Item),\n     exhaustive_unique_triples,\n     [0, 1, 2]\n);\nexhaustive_unique_tuples!(\n    (pub(crate)),\n    ExhaustiveUniqueQuadruples,\n    4,\n    (I::Item, I::Item, I::Item, I::Item),\n    exhaustive_unique_quadruples,\n    [0, 1, 2, 3]\n);\nexhaustive_unique_tuples!(\n    (pub(crate)),\n    ExhaustiveUniqueQuintuples,\n    5,\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    exhaustive_unique_quintuples,\n    [0, 1, 2, 3, 4]\n);\n\nrandom_tuples!(\n    (pub(crate)),\n    RandomTriples,\n    RandomTriplesFromSingle,\n    random_triples,\n    random_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen]\n);\n\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXXY,\n    (X, X, Y),\n    random_triples_xxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n    [Y, J, ys, ys_gen, [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXYX,\n    (X, Y, X),\n    random_triples_xyx,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n    [Y, J, ys, ys_gen, [y_1, x_2]]\n);\n\nrandom_ordered_unique_tuples!(\n    (pub(crate)),\n    RandomOrderedUniqueTriples,\n    3,\n    (I::Item, I::Item, I::Item),\n    random_ordered_unique_triples,\n    [0, 1, 2]\n);\nrandom_unique_tuples!(\n    (pub(crate)),\n    RandomUniqueTriples,\n    3,\n    (I::Item, I::Item, I::Item),\n    random_unique_triples,\n    [0, 1, 2]\n);\n\nexhaustive_unions!(\n    (pub(crate)),\n    Union3,\n    LexUnion3s,\n    ExhaustiveUnion3s,\n    lex_union3s,\n    exhaustive_union3s,\n    3,\n    [0, X, I, A, xs, xs_done],\n    [1, Y, J, B, ys, ys_done],\n    [2, Z, K, C, zs, zs_done]\n);\n\nunion_struct!(\n    (pub(crate)),\n    Union3,\n    Union3<T, T, T>,\n    [A, A, 'A', a],\n    [B, B, 'B', b],\n    [C, C, 'C', c]\n);\n\nrandom_unions!(\n    (pub(crate)),\n    Union3,\n    RandomUnion3s,\n    random_union3s,\n    3,\n    [0, X, I, A, xs, xs_gen],\n    [1, Y, J, B, ys, ys_gen],\n    [2, Z, K, C, zs, zs_gen]\n);\n\nlex_vecs_fixed_length!(\n    (pub(crate)),\n    LexFixedLengthVecs3Inputs,\n    lex_vecs_fixed_length_3_inputs,\n    lex_vecs_length_3,\n    [0, I, xs, xs_outputs],\n    [1, J, ys, ys_outputs],\n    [2, K, zs, zs_outputs]\n);\n\nexhaustive_vecs_fixed_length!(\n    (pub(crate)),\n    ExhaustiveFixedLengthVecs3Inputs,\n    exhaustive_vecs_fixed_length_3_inputs,\n    exhaustive_vecs_length_3,\n    [0, I, xs, xs_done, xs_outputs],\n    [1, J, ys, ys_done, ys_outputs],\n    [2, K, zs, zs_done, zs_outputs]\n);\n\nrandom_vecs_fixed_length!(\n    (pub(crate)),\n    RandomFixedLengthVecs3Inputs,\n    random_vecs_fixed_length_3_inputs,\n    random_vecs_length_3,\n    [0, I, xs, xs_gen],\n    [1, J, ys, ys_gen],\n    [2, K, zs, zs_gen]\n);\n"
  },
  {
    "path": "malachite-base/tests/iterators/bit_distributor/bit_map_as_slice.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n\nfn bit_distributor_helper(bit_distributor: &BitDistributor, bit_map: &[usize]) {\n    assert_eq!(bit_distributor.bit_map_as_slice(), bit_map);\n}\n\n#[test]\nfn test_bit_map_as_slice() {\n    bit_distributor_helper(\n        &BitDistributor::new(&[BitDistributorOutputType::normal(1)]),\n        &[0; 64],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[BitDistributorOutputType::normal(1); 2]),\n        &[\n            1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,\n            0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,\n            1, 0, 1, 0, 1, 0,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[BitDistributorOutputType::normal(1); 3]),\n        &[\n            2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1,\n            0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2,\n            1, 0, 2, 1, 0, 2,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[BitDistributorOutputType::normal(1); 5]),\n        &[\n            4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1,\n            0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2,\n            1, 0, 4, 3, 2, 1,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[BitDistributorOutputType::normal(2); 2]),\n        &[\n            1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1,\n            1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,\n            0, 0, 1, 1, 0, 0,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(2),\n        ]),\n        &[\n            1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1,\n            0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1,\n            1, 0, 1, 1, 0, 1,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[\n            BitDistributorOutputType::normal(2),\n            BitDistributorOutputType::normal(1),\n        ]),\n        &[\n            1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,\n            0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,\n            0, 0, 1, 0, 0, 1,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[\n            BitDistributorOutputType::normal(2),\n            BitDistributorOutputType::normal(3),\n        ]),\n        &[\n            1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0,\n            0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1,\n            0, 0, 1, 1, 1, 0,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        ]),\n        &[\n            1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 1,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        ]),\n        &[\n            0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 0,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        ]),\n        &[\n            2, 1, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 2,\n        ],\n    );\n    bit_distributor_helper(\n        &BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        ]),\n        &[\n            3, 2, 1, 3, 0, 1, 0, 2, 1, 0, 1, 0, 1, 0, 1, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,\n            1, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,\n            1, 0, 1, 0, 1, 3,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1)]);\n    bit_distributor.set_max_bits(&[0], 5);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            0,\n            0,\n            0,\n            0,\n            0,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1); 2]);\n    bit_distributor.set_max_bits(&[1], 2);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1); 2]);\n    bit_distributor.set_max_bits(&[0], 2);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ]);\n    bit_distributor.set_max_bits(&[0], 2);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ]);\n    bit_distributor.set_max_bits(&[1], 2);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1); 5]);\n    bit_distributor.set_max_bits(&[0], 2);\n    bit_distributor.set_max_bits(&[1], 1);\n    bit_distributor.set_max_bits(&[2], 5);\n    bit_distributor.set_max_bits(&[3], 3);\n    bit_distributor.set_max_bits(&[4], 4);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            4,\n            3,\n            2,\n            1,\n            0,\n            4,\n            3,\n            2,\n            0,\n            4,\n            3,\n            2,\n            4,\n            2,\n            2,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n            usize::MAX,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(2); 2]);\n    bit_distributor.set_max_bits(&[0], 5);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1,\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ]);\n    bit_distributor.set_max_bits(&[0], 5);\n    bit_distributor_helper(\n        &bit_distributor,\n        &[\n            2, 1, 0, 2, 0, 0, 0, 1, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1,\n            2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2,\n            1, 2, 1, 2, 1, 2,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/bit_distributor/get_output.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n\nfn bit_distributor_helper(mut bit_distributor: BitDistributor, expected_outputs: &[&[usize]]) {\n    let mut outputs = Vec::new();\n    for _ in 0..20 {\n        outputs.push(\n            (0..bit_distributor.output_types.len())\n                .map(|i| bit_distributor.get_output(i))\n                .collect::<Vec<usize>>(),\n        );\n        bit_distributor.increment_counter();\n    }\n    assert_eq!(outputs, expected_outputs);\n}\n\n#[test]\nfn test_get_output() {\n    bit_distributor_helper(\n        BitDistributor::new(&[BitDistributorOutputType::normal(1)]),\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[BitDistributorOutputType::normal(1); 2]),\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[0, 4],\n            &[0, 5],\n            &[1, 4],\n            &[1, 5],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[BitDistributorOutputType::normal(1); 3]),\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[1, 0, 2],\n            &[1, 0, 3],\n            &[1, 1, 2],\n            &[1, 1, 3],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 3, 0],\n            &[0, 3, 1],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[BitDistributorOutputType::normal(1); 5]),\n        &[\n            &[0, 0, 0, 0, 0],\n            &[0, 0, 0, 0, 1],\n            &[0, 0, 0, 1, 0],\n            &[0, 0, 0, 1, 1],\n            &[0, 0, 1, 0, 0],\n            &[0, 0, 1, 0, 1],\n            &[0, 0, 1, 1, 0],\n            &[0, 0, 1, 1, 1],\n            &[0, 1, 0, 0, 0],\n            &[0, 1, 0, 0, 1],\n            &[0, 1, 0, 1, 0],\n            &[0, 1, 0, 1, 1],\n            &[0, 1, 1, 0, 0],\n            &[0, 1, 1, 0, 1],\n            &[0, 1, 1, 1, 0],\n            &[0, 1, 1, 1, 1],\n            &[1, 0, 0, 0, 0],\n            &[1, 0, 0, 0, 1],\n            &[1, 0, 0, 1, 0],\n            &[1, 0, 0, 1, 1],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[BitDistributorOutputType::normal(2); 2]),\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 0],\n            &[3, 1],\n            &[3, 2],\n            &[3, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(2),\n        ]),\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[1, 4],\n            &[1, 5],\n            &[1, 6],\n            &[1, 7],\n            &[0, 8],\n            &[0, 9],\n            &[0, 10],\n            &[0, 11],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[\n            BitDistributorOutputType::normal(2),\n            BitDistributorOutputType::normal(1),\n        ]),\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[4, 0],\n            &[4, 1],\n            &[5, 0],\n            &[5, 1],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[\n            BitDistributorOutputType::normal(2),\n            BitDistributorOutputType::normal(3),\n        ]),\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[1, 4],\n            &[1, 5],\n            &[1, 6],\n            &[1, 7],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        ]),\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[1, 4],\n            &[1, 5],\n            &[1, 6],\n            &[1, 7],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        ]),\n        &[\n            &[0, 0],\n            &[1, 0],\n            &[2, 0],\n            &[3, 0],\n            &[0, 1],\n            &[1, 1],\n            &[2, 1],\n            &[3, 1],\n            &[4, 0],\n            &[5, 0],\n            &[6, 0],\n            &[7, 0],\n            &[4, 1],\n            &[5, 1],\n            &[6, 1],\n            &[7, 1],\n            &[0, 2],\n            &[1, 2],\n            &[2, 2],\n            &[3, 2],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        ]),\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[1, 0, 2],\n            &[1, 0, 3],\n            &[1, 1, 2],\n            &[1, 1, 3],\n            &[2, 0, 0],\n            &[2, 0, 1],\n            &[2, 1, 0],\n            &[2, 1, 1],\n        ],\n    );\n    bit_distributor_helper(\n        BitDistributor::new(&[\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        ]),\n        &[\n            &[0, 0, 0, 0],\n            &[0, 0, 0, 1],\n            &[0, 0, 1, 0],\n            &[0, 0, 1, 1],\n            &[0, 1, 0, 0],\n            &[0, 1, 0, 1],\n            &[0, 1, 1, 0],\n            &[0, 1, 1, 1],\n            &[0, 0, 0, 2],\n            &[0, 0, 0, 3],\n            &[0, 0, 1, 2],\n            &[0, 0, 1, 3],\n            &[0, 1, 0, 2],\n            &[0, 1, 0, 3],\n            &[0, 1, 1, 2],\n            &[0, 1, 1, 3],\n            &[1, 0, 0, 0],\n            &[1, 0, 0, 1],\n            &[1, 0, 1, 0],\n            &[1, 0, 1, 1],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1)]);\n    bit_distributor.set_max_bits(&[0], 5);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1); 2]);\n    bit_distributor.set_max_bits(&[1], 2);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[4, 0],\n            &[4, 1],\n            &[5, 0],\n            &[5, 1],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1); 2]);\n    bit_distributor.set_max_bits(&[0], 2);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[0, 4],\n            &[0, 5],\n            &[1, 4],\n            &[1, 5],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ]);\n    bit_distributor.set_max_bits(&[0], 2);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[1, 4],\n            &[1, 5],\n            &[1, 6],\n            &[1, 7],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ]);\n    bit_distributor.set_max_bits(&[1], 2);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 0],\n            &[3, 1],\n            &[3, 2],\n            &[3, 3],\n            &[4, 0],\n            &[4, 1],\n            &[4, 2],\n            &[4, 3],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(1); 5]);\n    bit_distributor.set_max_bits(&[0], 2);\n    bit_distributor.set_max_bits(&[1], 1);\n    bit_distributor.set_max_bits(&[2], 5);\n    bit_distributor.set_max_bits(&[3], 3);\n    bit_distributor.set_max_bits(&[4], 4);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0, 0, 0, 0, 0],\n            &[0, 0, 0, 0, 1],\n            &[0, 0, 0, 1, 0],\n            &[0, 0, 0, 1, 1],\n            &[0, 0, 1, 0, 0],\n            &[0, 0, 1, 0, 1],\n            &[0, 0, 1, 1, 0],\n            &[0, 0, 1, 1, 1],\n            &[0, 1, 0, 0, 0],\n            &[0, 1, 0, 0, 1],\n            &[0, 1, 0, 1, 0],\n            &[0, 1, 0, 1, 1],\n            &[0, 1, 1, 0, 0],\n            &[0, 1, 1, 0, 1],\n            &[0, 1, 1, 1, 0],\n            &[0, 1, 1, 1, 1],\n            &[1, 0, 0, 0, 0],\n            &[1, 0, 0, 0, 1],\n            &[1, 0, 0, 1, 0],\n            &[1, 0, 0, 1, 1],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[BitDistributorOutputType::normal(2); 2]);\n    bit_distributor.set_max_bits(&[0], 5);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 0],\n            &[3, 1],\n            &[3, 2],\n            &[3, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n        ],\n    );\n    let mut bit_distributor = BitDistributor::new(&[\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ]);\n    bit_distributor.set_max_bits(&[0], 5);\n    bit_distributor_helper(\n        bit_distributor,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[1, 0, 2],\n            &[1, 0, 3],\n            &[1, 1, 2],\n            &[1, 1, 3],\n            &[2, 0, 0],\n            &[2, 0, 1],\n            &[2, 1, 0],\n            &[2, 1, 1],\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_output_fail() {\n    let bd = BitDistributor::new(&[BitDistributorOutputType::normal(2); 3]);\n    bd.get_output(4);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/bit_distributor/increment_counter.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n\n#[test]\nfn test_increment_counter() {\n    let mut bd = BitDistributor::new(&[BitDistributorOutputType::normal(1)]);\n    let mut outputs = Vec::new();\n    for _ in 0..20 {\n        outputs.push(bd.get_output(0));\n        bd.increment_counter();\n    }\n    assert_eq!(\n        outputs,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/bit_distributor/new.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n\n#[test]\nfn test_bit_distributor() {\n    BitDistributor::new(&[BitDistributorOutputType::normal(1)]);\n}\n\n#[test]\n#[should_panic]\nfn bit_distributor_fail_1() {\n    BitDistributor::new(&[]);\n}\n\n#[test]\n#[should_panic]\nfn bit_distributor_fail_2() {\n    BitDistributor::new(&[BitDistributorOutputType::tiny(); 2]);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/bit_distributor/set_max_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\n\n#[test]\nfn test_set_max_bits() {\n    let mut bd = BitDistributor::new(&[BitDistributorOutputType::normal(2); 3]);\n    assert_eq!(\n        bd.bit_map_as_slice(),\n        &[\n            2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0,\n            0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 1,\n            0, 0, 2, 2, 1, 1\n        ][..]\n    );\n\n    bd.set_max_bits(&[0, 2], 5);\n    assert_eq!(\n        bd.bit_map_as_slice(),\n        &[\n            2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, 2, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n            1, 1, 1, 1, 1, 1\n        ][..]\n    );\n}\n\n#[test]\n#[should_panic]\nfn set_max_bits_fail_1() {\n    let mut bd = BitDistributor::new(&[BitDistributorOutputType::normal(2); 3]);\n    bd.set_max_bits(&[0], 0);\n}\n\n#[test]\n#[should_panic]\nfn set_max_bits_fail_2() {\n    let mut bd = BitDistributor::new(&[BitDistributorOutputType::normal(2); 3]);\n    bd.set_max_bits(&[0, 3], 2);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/comparison/delta_directions.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::comparison::delta_directions;\nuse std::cmp::Ordering::{self, *};\n\nfn delta_directions_helper(xs: &[u8], result: &[Ordering]) {\n    assert_eq!(delta_directions(xs.iter()).collect_vec(), result);\n    assert_eq!(result.len(), xs.len().saturating_sub(1));\n    assert_eq!(\n        delta_directions(xs.iter().rev())\n            .map(Ordering::reverse)\n            .collect_vec(),\n        result.iter().copied().rev().collect_vec()\n    );\n}\n\n#[test]\nfn test_delta_directions() {\n    delta_directions_helper(&[], &[]);\n    delta_directions_helper(&[5], &[]);\n    delta_directions_helper(&[5, 6], &[Greater]);\n    delta_directions_helper(&[5, 5], &[Equal]);\n    delta_directions_helper(&[5, 4], &[Less]);\n    delta_directions_helper(&[1, 2, 3, 4], &[Greater; 3]);\n    delta_directions_helper(&[1, 2, 2, 4], &[Greater, Equal, Greater]);\n    delta_directions_helper(&[1, 3, 2, 4], &[Greater, Less, Greater]);\n    delta_directions_helper(\n        &[3, 1, 4, 1, 5, 9],\n        &[Less, Greater, Less, Greater, Greater],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/comparison/is_strictly_ascending.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::{\n    is_strictly_ascending, is_strictly_descending, is_weakly_ascending, is_weakly_descending,\n};\n\nfn is_strictly_ascending_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_strictly_ascending(xs.iter()), result);\n    assert_eq!(is_strictly_descending(xs.iter().rev()), result);\n    if xs.len() < 2 {\n        assert!(result);\n    }\n    if result {\n        assert!(is_weakly_ascending(xs.iter()));\n        if xs.len() > 1 {\n            assert!(!is_weakly_descending(xs.iter()));\n        }\n    }\n}\n\n#[test]\nfn test_is_strictly_ascending() {\n    is_strictly_ascending_helper(&[], true);\n    is_strictly_ascending_helper(&[5], true);\n    is_strictly_ascending_helper(&[5, 6], true);\n    is_strictly_ascending_helper(&[5, 5], false);\n    is_strictly_ascending_helper(&[5, 4], false);\n    is_strictly_ascending_helper(&[1, 2, 3, 4], true);\n    is_strictly_ascending_helper(&[1, 2, 2, 4], false);\n    is_strictly_ascending_helper(&[1, 3, 2, 4], false);\n    is_strictly_ascending_helper(&[3, 1, 4, 1, 5, 9], false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/comparison/is_strictly_descending.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::{\n    is_strictly_ascending, is_strictly_descending, is_weakly_ascending, is_weakly_descending,\n};\n\nfn is_strictly_descending_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_strictly_descending(xs.iter()), result);\n    assert_eq!(is_strictly_ascending(xs.iter().rev()), result);\n    if xs.len() < 2 {\n        assert!(result);\n    }\n    if result {\n        assert!(is_weakly_descending(xs.iter()));\n        if xs.len() > 1 {\n            assert!(!is_weakly_ascending(xs.iter()));\n        }\n    }\n}\n\n#[test]\nfn test_is_strictly_descending() {\n    is_strictly_descending_helper(&[], true);\n    is_strictly_descending_helper(&[5], true);\n    is_strictly_descending_helper(&[6, 5], true);\n    is_strictly_descending_helper(&[6, 6], false);\n    is_strictly_descending_helper(&[6, 7], false);\n    is_strictly_descending_helper(&[4, 3, 2, 1], true);\n    is_strictly_descending_helper(&[4, 2, 2, 1], false);\n    is_strictly_descending_helper(&[4, 2, 3, 1], false);\n    is_strictly_descending_helper(&[3, 1, 4, 1, 5, 9], false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/comparison/is_strictly_zigzagging.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::{\n    is_strictly_zigzagging, is_weakly_ascending, is_weakly_descending, is_weakly_zigzagging,\n};\n\nfn is_strictly_zigzagging_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_strictly_zigzagging(xs.iter()), result);\n    assert_eq!(is_strictly_zigzagging(xs.iter().rev()), result);\n    if xs.len() < 2 {\n        assert!(result);\n    }\n    if result {\n        assert!(is_weakly_zigzagging(xs.iter()));\n        if xs.len() > 2 {\n            assert!(!is_weakly_ascending(xs.iter()));\n            assert!(!is_weakly_descending(xs.iter()));\n        }\n    }\n}\n\n#[test]\nfn test_is_strictly_zigzagging() {\n    is_strictly_zigzagging_helper(&[], true);\n    is_strictly_zigzagging_helper(&[5], true);\n    is_strictly_zigzagging_helper(&[5, 6], true);\n    is_strictly_zigzagging_helper(&[5, 5], false);\n    is_strictly_zigzagging_helper(&[5, 4], true);\n    is_strictly_zigzagging_helper(&[1, 2, 3, 4], false);\n    is_strictly_zigzagging_helper(&[1, 2, 2, 4], false);\n    is_strictly_zigzagging_helper(&[1, 3, 2, 4], true);\n    is_strictly_zigzagging_helper(&[3, 1, 4, 1, 5, 9], false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/comparison/is_weakly_ascending.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::{\n    is_strictly_ascending, is_weakly_ascending, is_weakly_descending,\n};\n\nfn is_weakly_ascending_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_weakly_ascending(xs.iter()), result);\n    assert_eq!(is_weakly_descending(xs.iter().rev()), result);\n    if xs.len() < 2 {\n        assert!(result);\n    }\n    if !result {\n        assert!(!is_strictly_ascending(xs.iter()));\n    }\n}\n\n#[test]\nfn test_is_weakly_ascending() {\n    is_weakly_ascending_helper(&[], true);\n    is_weakly_ascending_helper(&[5], true);\n    is_weakly_ascending_helper(&[5, 6], true);\n    is_weakly_ascending_helper(&[5, 5], true);\n    is_weakly_ascending_helper(&[5, 4], false);\n    is_weakly_ascending_helper(&[1, 2, 3, 4], true);\n    is_weakly_ascending_helper(&[1, 2, 2, 4], true);\n    is_weakly_ascending_helper(&[1, 3, 2, 4], false);\n    is_weakly_ascending_helper(&[3, 1, 4, 1, 5, 9], false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/comparison/is_weakly_descending.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::{\n    is_strictly_descending, is_weakly_ascending, is_weakly_descending,\n};\n\nfn is_weakly_descending_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_weakly_descending(xs.iter()), result);\n    assert_eq!(is_weakly_ascending(xs.iter().rev()), result);\n    if xs.len() < 2 {\n        assert!(result);\n    }\n    if !result {\n        assert!(!is_strictly_descending(xs.iter()));\n    }\n}\n\n#[test]\nfn test_is_weakly_descending() {\n    is_weakly_descending_helper(&[], true);\n    is_weakly_descending_helper(&[5], true);\n    is_weakly_descending_helper(&[6, 5], true);\n    is_weakly_descending_helper(&[6, 6], true);\n    is_weakly_descending_helper(&[6, 7], false);\n    is_weakly_descending_helper(&[4, 3, 2, 1], true);\n    is_weakly_descending_helper(&[4, 2, 2, 1], true);\n    is_weakly_descending_helper(&[4, 2, 3, 1], false);\n    is_weakly_descending_helper(&[3, 1, 4, 1, 5, 9], false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/comparison/is_weakly_zigzagging.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::{is_strictly_zigzagging, is_weakly_zigzagging};\n\nfn is_weakly_zigzagging_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_weakly_zigzagging(xs.iter()), result);\n    assert_eq!(is_weakly_zigzagging(xs.iter().rev()), result);\n    if xs.len() < 3 {\n        assert!(result);\n    }\n    if !result {\n        assert!(!is_strictly_zigzagging(xs.iter()));\n    }\n}\n\n#[test]\nfn test_is_weakly_zigzagging() {\n    is_weakly_zigzagging_helper(&[], true);\n    is_weakly_zigzagging_helper(&[5], true);\n    is_weakly_zigzagging_helper(&[5, 6], true);\n    is_weakly_zigzagging_helper(&[5, 5], true);\n    is_weakly_zigzagging_helper(&[5, 4], true);\n    is_weakly_zigzagging_helper(&[1, 2, 3, 4], false);\n    is_weakly_zigzagging_helper(&[1, 2, 2, 4], true);\n    is_weakly_zigzagging_helper(&[1, 3, 2, 4], true);\n    is_weakly_zigzagging_helper(&[3, 1, 4, 1, 5, 9], false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/count_is_at_least.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::count_is_at_least;\nuse std::iter::repeat;\n\nfn count_is_at_least_helper(xs: &[u8], n: usize, result: bool) {\n    assert_eq!(count_is_at_least(xs.iter(), n), result);\n    assert_eq!(count_is_at_least(xs.iter().rev(), n), result);\n}\n\n#[test]\nfn test_count_is_at_least() {\n    count_is_at_least_helper(&[], 0, true);\n    count_is_at_least_helper(&[], 1, false);\n    count_is_at_least_helper(&[5], 0, true);\n    count_is_at_least_helper(&[5], 1, true);\n    count_is_at_least_helper(&[5], 2, false);\n    count_is_at_least_helper(&[1, 2, 3, 4], 4, true);\n    count_is_at_least_helper(&[1, 2, 3, 4], 5, false);\n    count_is_at_least_helper(&[4; 100], 90, true);\n    count_is_at_least_helper(&[4; 100], 101, false);\n\n    assert_eq!(count_is_at_least(repeat(10), 20), true);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/count_is_at_most.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::count_is_at_most;\nuse std::iter::repeat;\n\nfn count_is_at_most_helper(xs: &[u8], n: usize, result: bool) {\n    assert_eq!(count_is_at_most(xs.iter(), n), result);\n    assert_eq!(count_is_at_most(xs.iter().rev(), n), result);\n}\n\n#[test]\nfn test_count_is_at_most() {\n    count_is_at_most_helper(&[], 0, true);\n    count_is_at_most_helper(&[], 1, true);\n    count_is_at_most_helper(&[5], 0, false);\n    count_is_at_most_helper(&[5], 1, true);\n    count_is_at_most_helper(&[5], 2, true);\n    count_is_at_most_helper(&[1, 2, 3, 4], 3, false);\n    count_is_at_most_helper(&[1, 2, 3, 4], 4, true);\n    count_is_at_most_helper(&[1, 2, 3, 4], 5, true);\n    count_is_at_most_helper(&[4; 100], 120, true);\n    count_is_at_most_helper(&[4; 100], 90, false);\n\n    assert_eq!(count_is_at_most(repeat(10), 20), false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/first_and_last.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::first_and_last;\n\nfn first_and_last_helper(xs: &[u8], result: Option<(u8, u8)>) {\n    assert_eq!(first_and_last(&mut xs.iter().copied()), result);\n}\n\n#[test]\nfn test_first_and_last() {\n    first_and_last_helper(&[1, 2, 10, 11, 12, 7, 8, 16, 5], Some((1, 5)));\n    first_and_last_helper(&[5], Some((5, 5)));\n    first_and_last_helper(&[], None);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/is_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::{is_weakly_ascending, is_weakly_descending};\nuse malachite_base::iterators::is_constant;\n\nfn is_constant_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_constant(xs.iter()), result);\n    assert_eq!(is_constant(xs.iter().rev()), result);\n    assert_eq!(\n        is_weakly_ascending(xs.iter()) && is_weakly_descending(xs.iter()),\n        result\n    );\n    if xs.len() < 2 {\n        assert!(result);\n    }\n}\n\n#[test]\nfn test_is_constant() {\n    is_constant_helper(&[], true);\n\n    is_constant_helper(&[5], true);\n    is_constant_helper(&[5, 6], false);\n    is_constant_helper(&[5, 5], true);\n    is_constant_helper(&[5, 4], false);\n    is_constant_helper(&[1; 4], true);\n    is_constant_helper(&[1, 2, 3, 4], false);\n    is_constant_helper(&[1, 2, 2, 4], false);\n    is_constant_helper(&[4; 100], true);\n\n    assert_eq!(is_constant([1, 2].into_iter().cycle()), false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/is_unique.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::is_unique;\n\nfn is_unique_helper(xs: &[u8], result: bool) {\n    assert_eq!(is_unique(xs.iter()), result);\n    assert_eq!(is_unique(xs.iter().rev()), result);\n}\n\n#[test]\nfn test_is_unique() {\n    is_unique_helper(&[], true);\n    is_unique_helper(&[5], true);\n    is_unique_helper(&[5, 6], true);\n    is_unique_helper(&[5, 5], false);\n    is_unique_helper(&[5, 4], true);\n    is_unique_helper(&[1, 2, 3, 4], true);\n    is_unique_helper(&[1, 2, 2, 4], false);\n    is_unique_helper(&[1, 2, 3, 1], false);\n    is_unique_helper(&[4; 100], false);\n\n    assert_eq!(is_unique([1, 2].iter().cycle()), false);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/iter_windows.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::iter_windows;\nuse std::fmt::Debug;\n\nfn iter_windows_helper<I: Iterator>(size: usize, xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    let windows = iter_windows(size, xs)\n        .map(|ws| ws.iter().cloned().collect_vec())\n        .collect_vec();\n    assert_eq!(\n        windows.iter().map(Vec::as_slice).collect_vec().as_slice(),\n        out\n    );\n}\n\n#[test]\nfn test_iter_windows() {\n    iter_windows_helper(1, 0..=5, &[&[0], &[1], &[2], &[3], &[4], &[5]]);\n    iter_windows_helper(2, 0..=5, &[&[0, 1], &[1, 2], &[2, 3], &[3, 4], &[4, 5]]);\n    iter_windows_helper(3, 0..=5, &[&[0, 1, 2], &[1, 2, 3], &[2, 3, 4], &[3, 4, 5]]);\n    iter_windows_helper(4, 0..=5, &[&[0, 1, 2, 3], &[1, 2, 3, 4], &[2, 3, 4, 5]]);\n    iter_windows_helper(5, 0..=5, &[&[0, 1, 2, 3, 4], &[1, 2, 3, 4, 5]]);\n    iter_windows_helper(6, 0..=5, &[&[0, 1, 2, 3, 4, 5]]);\n    iter_windows_helper(7, 0..=5, &[]);\n}\n\n#[test]\n#[should_panic]\nfn iter_windows_fail() {\n    iter_windows(0, 0..10);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/iterator_cache.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::__std_iter::empty;\nuse malachite_base::iterators::iterator_cache::IteratorCache;\nuse malachite_base::nevers::Never;\nuse malachite_base::num::exhaustive::exhaustive_signeds;\n\n#[test]\nfn test_iterator_cache() {\n    let mut xs = IteratorCache::new(empty::<Never>());\n    assert_eq!(xs.known_len(), None);\n    assert_eq!(xs.get(1), None);\n    assert_eq!(xs.known_len(), Some(0));\n    assert_eq!(xs.get(0), None);\n\n    let mut xs = IteratorCache::new([1, 2, 3].iter().copied());\n    assert_eq!(xs.known_len(), None);\n    assert_eq!(xs.get(1), Some(&2));\n    assert_eq!(xs.assert_get(1), &2);\n    assert_eq!(xs.known_len(), None);\n    assert_eq!(xs.get(0), Some(&1));\n    assert_eq!(xs.assert_get(0), &1);\n    assert_eq!(xs.get(3), None);\n    assert_eq!(xs.known_len(), Some(3));\n    assert_eq!(xs.get(2), Some(&3));\n    assert_eq!(xs.assert_get(2), &3);\n\n    let mut xs = IteratorCache::new(exhaustive_signeds::<i64>());\n    assert_eq!(xs.get(1), Some(&1));\n    assert_eq!(xs.assert_get(1), &1);\n    assert_eq!(xs.known_len(), None);\n    assert_eq!(xs.get(0), Some(&0));\n    assert_eq!(xs.assert_get(0), &0);\n    assert_eq!(xs.get(3), Some(&2));\n    assert_eq!(xs.assert_get(3), &2);\n    assert_eq!(xs.get(100), Some(&-50));\n    assert_eq!(xs.assert_get(100), &-50);\n    assert_eq!(xs.known_len(), None);\n}\n\n#[test]\n#[should_panic]\nfn iterator_cache_fail() {\n    IteratorCache::new(empty::<Never>()).assert_get(0);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/matching_intervals_in_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::matching_intervals_in_iterator;\n\nfn matching_intervals_in_iterator_helper<F: Fn(&u8) -> bool>(xs: &[u8], f: F, result: &[(u8, u8)]) {\n    assert_eq!(\n        matching_intervals_in_iterator(xs.iter().copied(), f).as_slice(),\n        result\n    );\n}\n\n#[test]\nfn test_matching_intervals_in_iterator() {\n    let xs = &[1, 2, 10, 11, 12, 7, 8, 16, 5];\n    matching_intervals_in_iterator_helper(xs, |&x| x >= 10, &[(10, 12), (16, 16)]);\n    matching_intervals_in_iterator_helper(xs, |&x| x < 10, &[(1, 2), (7, 8), (5, 5)]);\n    matching_intervals_in_iterator_helper(xs, |&x| x >= 100, &[]);\n    matching_intervals_in_iterator_helper(xs, |&x| x < 100, &[(1, 5)]);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/nonzero_values.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::nonzero_values;\n\n#[test]\npub fn test_nonzero_values() {\n    let test = |xs: &[u32], out: &[u32]| {\n        assert_eq!(nonzero_values(xs.iter().copied()).collect_vec(), out);\n    };\n    test(&[], &[]);\n    test(&[1, 2, 3], &[1, 2, 3]);\n    test(&[1, 0, 3], &[1, 3]);\n    test(&[1, 2, 0, 0, 0], &[1, 2]);\n    test(&[0, 0, 0], &[]);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/prefix_to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::prefix_to_string;\n\n#[test]\nfn test_prefix_to_string() {\n    let test = |xs: &[u32], max_len: usize, out: &str| {\n        assert_eq!(prefix_to_string(xs.iter(), max_len), out);\n    };\n    test(&[], 1, \"[]\");\n    test(&[1, 2, 3, 4], 1, \"[1, ...]\");\n    test(&[1, 2, 3, 4], 2, \"[1, 2, ...]\");\n    test(&[1, 2, 3, 4], 3, \"[1, 2, 3, ...]\");\n    test(&[1, 2, 3, 4], 4, \"[1, 2, 3, 4]\");\n    test(&[1, 2, 3, 4], 10, \"[1, 2, 3, 4]\");\n}\n\n#[test]\n#[should_panic]\nfn prefix_to_string_fail() {\n    prefix_to_string([1, 2, 3].iter(), 0);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/thue_morse_sequence.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::thue_morse_sequence;\n\n#[test]\npub fn test_thue_morse_sequence() {\n    let s: String = thue_morse_sequence()\n        .take(1000)\n        .map(|b| if b { '1' } else { '0' })\n        .collect();\n    assert_eq!(\n        s,\n        \"01101001100101101001011001101001100101100110100101101001100101101001011001101001011010011\\\n        001011001101001100101101001011001101001100101100110100101101001100101100110100110010110100\\\n        101100110100101101001100101101001011001101001100101100110100101101001100101101001011001101\\\n        001011010011001011001101001100101101001011001101001011010011001011010010110011010011001011\\\n        001101001011010011001011001101001100101101001011001101001100101100110100101101001100101101\\\n        001011001101001011010011001011001101001100101101001011001101001100101100110100101101001100\\\n        101100110100110010110100101100110100101101001100101101001011001101001100101100110100101101\\\n        001100101100110100110010110100101100110100110010110011010010110100110010110100101100110100\\\n        101101001100101100110100110010110100101100110100101101001100101101001011001101001100101100\\\n        110100101101001100101101001011001101001011010011001011001101001100101101001011001101001100\\\n        101100110100101101001100101100110100110010110100101100110100101101001100101101001011001101\\\n        00110010110\"\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/with_special_value.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::iterators::with_special_value;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::options::random::random_options;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::fmt::Debug;\n\nfn with_special_value_helper<I: Clone + Iterator>(\n    special_value: I::Item,\n    p_special_numerator: u64,\n    p_special_denominator: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[I::Item],\n    expected_common_values: &[(I::Item, usize)],\n    expected_median: (I::Item, Option<I::Item>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = with_special_value(\n        EXAMPLE_SEED,\n        special_value,\n        p_special_numerator,\n        p_special_denominator,\n        xs_gen,\n    );\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_with_special_value() {\n    // special_value = 0, p = 1/2\n    with_special_value_helper(\n        0,\n        1,\n        2,\n        &random_primitive_ints::<u8>,\n        &[0, 0, 0, 85, 0, 11, 0, 0, 0, 136, 200, 235, 0, 0, 134, 0, 0, 0, 0, 0],\n        &[\n            (0, 501536),\n            (81, 2080),\n            (208, 2071),\n            (35, 2070),\n            (211, 2051),\n            (112, 2043),\n            (162, 2043),\n            (143, 2041),\n            (220, 2040),\n            (73, 2038),\n        ],\n        (0, None),\n    );\n    // special_value = 0, p = 50/51\n    with_special_value_helper(\n        0,\n        50,\n        51,\n        &random_primitive_ints::<u8>,\n        &[0; 20],\n        &[\n            (0, 980537),\n            (18, 101),\n            (25, 99),\n            (116, 97),\n            (226, 97),\n            (237, 97),\n            (23, 95),\n            (185, 95),\n            (30, 94),\n            (73, 94),\n        ],\n        (0, None),\n    );\n    // p = special_value = 0, 1/51\n    with_special_value_helper(\n        0,\n        1,\n        51,\n        &random_primitive_ints::<u8>,\n        &[\n            85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32, 166, 234, 30, 218,\n            90, 106,\n        ],\n        &[\n            (0, 23543),\n            (58, 4029),\n            (81, 4001),\n            (194, 3979),\n            (66, 3971),\n            (64, 3969),\n            (143, 3965),\n            (4, 3962),\n            (196, 3951),\n            (208, 3939),\n        ],\n        (125, None),\n    );\n    // special_value = 0, p = 1/11\n    with_special_value_helper(\n        Some(0),\n        1,\n        11,\n        &|seed| random_options(seed, 1, 11, &random_primitive_ints::<u8>),\n        &[\n            Some(229),\n            Some(58),\n            Some(126),\n            Some(0),\n            Some(192),\n            Some(140),\n            Some(235),\n            Some(50),\n            Some(162),\n            Some(5),\n            Some(14),\n            Some(107),\n            Some(218),\n            Some(0),\n            Some(96),\n            Some(86),\n            Some(51),\n            Some(240),\n            Some(0),\n            Some(186),\n        ],\n        &[\n            (Some(0), 94315),\n            (None, 82945),\n            (Some(186), 3381),\n            (Some(193), 3376),\n            (Some(55), 3364),\n            (Some(83), 3364),\n            (Some(245), 3360),\n            (Some(148), 3352),\n            (Some(143), 3345),\n            (Some(136), 3339),\n        ],\n        (Some(101), None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn with_special_value_fail_1() {\n    with_special_value(EXAMPLE_SEED, 0, 1, 0, &random_primitive_ints::<u8>);\n}\n\n#[test]\n#[should_panic]\nfn with_special_value_fail_2() {\n    with_special_value(EXAMPLE_SEED, 0, 2, 1, &random_primitive_ints::<u8>);\n}\n"
  },
  {
    "path": "malachite-base/tests/iterators/with_special_values.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::iterators::with_special_values;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::options::random::random_options;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::fmt::Debug;\n\nfn with_special_values_helper<I: Clone + Iterator>(\n    special_values: &[I::Item],\n    p_special_numerator: u64,\n    p_special_denominator: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[I::Item],\n    expected_common_values: &[(I::Item, usize)],\n    expected_median: (I::Item, Option<I::Item>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = with_special_values(\n        EXAMPLE_SEED,\n        special_values.to_vec(),\n        p_special_numerator,\n        p_special_denominator,\n        xs_gen,\n    );\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_with_special_values() {\n    // special_values = &[0, 1, 2], p = 1/2\n    with_special_values_helper(\n        &[0, 1, 2],\n        1,\n        2,\n        &random_primitive_ints::<u8>,\n        &[2, 0, 2, 85, 0, 11, 1, 2, 0, 136, 200, 235, 0, 0, 134, 2, 0, 0, 0, 0],\n        &[\n            (2, 168816),\n            (0, 168721),\n            (1, 167914),\n            (81, 2080),\n            (208, 2071),\n            (35, 2070),\n            (211, 2051),\n            (112, 2043),\n            (162, 2043),\n            (143, 2041),\n        ],\n        (2, None),\n    );\n    // special_values = &[0, 1], p = 50/51\n    with_special_values_helper(\n        &[0, 1],\n        50,\n        51,\n        &random_primitive_ints::<u8>,\n        &[0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0],\n        &[\n            (1, 490697),\n            (0, 489910),\n            (18, 101),\n            (25, 99),\n            (116, 97),\n            (226, 97),\n            (237, 97),\n            (23, 95),\n            (185, 95),\n            (30, 94),\n        ],\n        (1, None),\n    );\n    // p = special_values = &[0, 1, 2, 3], 1/51\n    with_special_values_helper(\n        &[0, 1, 2, 3],\n        1,\n        51,\n        &random_primitive_ints::<u8>,\n        &[\n            85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32, 166, 234, 30, 218,\n            90, 106,\n        ],\n        &[\n            (2, 8933),\n            (0, 8779),\n            (1, 8736),\n            (3, 8736),\n            (58, 4029),\n            (81, 4001),\n            (194, 3979),\n            (66, 3971),\n            (64, 3969),\n            (143, 3965),\n        ],\n        (125, None),\n    );\n    // special_values = &[None, Some(0), Some(1)], p = 1/11\n    with_special_values_helper(\n        &[None, Some(0), Some(1)],\n        1,\n        11,\n        &|seed| random_options(seed, 1, 11, &random_primitive_ints::<u8>),\n        &[\n            Some(229),\n            Some(58),\n            Some(126),\n            Some(1),\n            Some(192),\n            Some(140),\n            Some(235),\n            Some(50),\n            Some(162),\n            Some(5),\n            Some(14),\n            Some(107),\n            Some(218),\n            None,\n            Some(96),\n            Some(86),\n            Some(51),\n            Some(240),\n            Some(1),\n            Some(186),\n        ],\n        &[\n            (None, 113578),\n            (Some(1), 33583),\n            (Some(0), 33308),\n            (Some(186), 3381),\n            (Some(193), 3376),\n            (Some(55), 3364),\n            (Some(83), 3364),\n            (Some(245), 3360),\n            (Some(148), 3352),\n            (Some(143), 3345),\n        ],\n        (Some(101), None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn with_special_values_fail_1() {\n    with_special_values(EXAMPLE_SEED, vec![0, 1], 1, 0, &random_primitive_ints::<u8>);\n}\n\n#[test]\n#[should_panic]\nfn with_special_values_fail_2() {\n    with_special_values(EXAMPLE_SEED, vec![0, 1], 2, 1, &random_primitive_ints::<u8>);\n}\n\n#[test]\n#[should_panic]\nfn with_special_values_fail_3() {\n    with_special_values(EXAMPLE_SEED, vec![], 1, 2, &random_primitive_ints::<u8>);\n}\n"
  },
  {
    "path": "malachite-base/tests/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::trivially_copy_pass_by_ref\n)]\n#![allow(\n    clippy::assertions_on_constants, // Compile-time asserts still useful\n    clippy::bool_assert_comparison, // Often clearer than using !\n    clippy::cognitive_complexity,\n    clippy::excessive_precision,\n    clippy::float_cmp,\n    clippy::too_many_arguments,\n    clippy::upper_case_acronyms,\n    unstable_name_collisions\n)]\n\nextern crate core;\nextern crate itertools;\n#[macro_use]\nextern crate malachite_base;\n#[macro_use]\nextern crate maplit;\nextern crate rand;\nextern crate rand_chacha;\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\n\nconst SAMPLE_OUTPUT_TYPES_2: [[BitDistributorOutputType; 2]; 4] = [\n    [BitDistributorOutputType::normal(1); 2],\n    [BitDistributorOutputType::normal(2); 2],\n    [BitDistributorOutputType::normal(1), BitDistributorOutputType::normal(2)],\n    [BitDistributorOutputType::normal(1), BitDistributorOutputType::tiny()],\n];\n\nconst SAMPLE_OUTPUT_TYPES_3: [[BitDistributorOutputType; 3]; 9] = [\n    [BitDistributorOutputType::normal(1); 3],\n    [BitDistributorOutputType::normal(2); 3],\n    [\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(2),\n        BitDistributorOutputType::normal(3),\n    ],\n    [\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n    ],\n    [\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n    ],\n    [\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ],\n    [\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ],\n    [\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ],\n    [\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n    ],\n];\n\npub mod bools {\n    pub mod constants;\n    pub mod exhaustive;\n    pub mod not_assign;\n    pub mod random {\n        pub mod get_weighted_random_bool;\n        pub mod random_bools;\n        pub mod weighted_random_bools;\n    }\n}\npub mod comparison {\n    pub mod macros;\n}\npub mod chars {\n    pub mod char_type;\n    pub mod constants;\n    pub mod crement {\n        pub mod char_to_contiguous_range;\n        pub mod contiguous_range_to_char;\n        #[allow(clippy::module_inception)]\n        pub mod crement;\n    }\n    pub mod exhaustive {\n        pub mod ascii_chars_increasing;\n        pub mod chars_increasing;\n        pub mod exhaustive_ascii_chars;\n        pub mod exhaustive_chars;\n    }\n    pub mod is_graphic;\n    pub mod random {\n        pub mod graphic_weighted_random_ascii_chars;\n        pub mod graphic_weighted_random_char_inclusive_range;\n        pub mod graphic_weighted_random_char_range;\n        pub mod graphic_weighted_random_chars;\n        pub mod random_ascii_chars;\n        pub mod random_char_inclusive_range;\n        pub mod random_char_range;\n        pub mod random_chars;\n    }\n}\npub mod extra_variadic;\npub mod iterators {\n    pub mod bit_distributor {\n        pub mod bit_map_as_slice;\n        pub mod get_output;\n        pub mod increment_counter;\n        pub mod new;\n        pub mod set_max_bits;\n    }\n    pub mod comparison {\n        pub mod delta_directions;\n        pub mod is_strictly_ascending;\n        pub mod is_strictly_descending;\n        pub mod is_strictly_zigzagging;\n        pub mod is_weakly_ascending;\n        pub mod is_weakly_descending;\n        pub mod is_weakly_zigzagging;\n    }\n    pub mod count_is_at_least;\n    pub mod count_is_at_most;\n    pub mod first_and_last;\n    pub mod is_constant;\n    pub mod is_unique;\n    pub mod iter_windows;\n    pub mod iterator_cache;\n    pub mod matching_intervals_in_iterator;\n    pub mod nonzero_values;\n    pub mod prefix_to_string;\n    pub mod thue_morse_sequence;\n    pub mod with_special_value;\n    pub mod with_special_values;\n}\npub mod named;\npub mod nevers {\n    #[allow(clippy::module_inception)]\n    pub mod nevers;\n}\npub mod num {\n    pub mod arithmetic {\n        pub mod abs;\n        pub mod abs_diff;\n        pub mod add_mul;\n        pub mod arithmetic_checked_shl;\n        pub mod arithmetic_checked_shr;\n        pub mod binomial_coefficient;\n        pub mod ceiling;\n        pub mod checked_abs;\n        pub mod checked_add_mul;\n        pub mod checked_neg;\n        pub mod checked_pow;\n        pub mod checked_square;\n        pub mod checked_sub_mul;\n        pub mod coprime_with;\n        pub mod div_exact;\n        pub mod div_mod;\n        pub mod div_round;\n        pub mod divisible_by;\n        pub mod divisible_by_power_of_2;\n        pub mod eq_mod;\n        pub mod eq_mod_power_of_2;\n        pub mod extended_gcd;\n        pub mod factorial;\n        pub mod floor;\n        pub mod gcd;\n        pub mod is_power_of_2;\n        pub mod kronecker_symbol;\n        pub mod lcm;\n        pub mod log_base;\n        pub mod log_base_2;\n        pub mod log_base_power_of_2;\n        pub mod mod_add;\n        pub mod mod_inverse;\n        pub mod mod_is_reduced;\n        pub mod mod_mul;\n        pub mod mod_neg;\n        pub mod mod_op;\n        pub mod mod_pow;\n        pub mod mod_power_of_2;\n        pub mod mod_power_of_2_add;\n        pub mod mod_power_of_2_inverse;\n        pub mod mod_power_of_2_is_reduced;\n        pub mod mod_power_of_2_mul;\n        pub mod mod_power_of_2_neg;\n        pub mod mod_power_of_2_pow;\n        pub mod mod_power_of_2_shl;\n        pub mod mod_power_of_2_shr;\n        pub mod mod_power_of_2_square;\n        pub mod mod_power_of_2_sub;\n        pub mod mod_shl;\n        pub mod mod_shr;\n        pub mod mod_square;\n        pub mod mod_sub;\n        pub mod neg;\n        pub mod next_power_of_2;\n        pub mod overflowing_abs;\n        pub mod overflowing_add;\n        pub mod overflowing_add_mul;\n        pub mod overflowing_div;\n        pub mod overflowing_mul;\n        pub mod overflowing_neg;\n        pub mod overflowing_pow;\n        pub mod overflowing_square;\n        pub mod overflowing_sub;\n        pub mod overflowing_sub_mul;\n        pub mod parity;\n        pub mod pow;\n        pub mod power_of_2;\n        pub mod primorial;\n        pub mod reciprocal;\n        pub mod root;\n        pub mod rotate;\n        pub mod round_to_multiple;\n        pub mod round_to_multiple_of_power_of_2;\n        pub mod saturating_abs;\n        pub mod saturating_add;\n        pub mod saturating_add_mul;\n        pub mod saturating_mul;\n        pub mod saturating_neg;\n        pub mod saturating_pow;\n        pub mod saturating_square;\n        pub mod saturating_sub;\n        pub mod saturating_sub_mul;\n        pub mod shl_round;\n        pub mod shr_round;\n        pub mod sign;\n        pub mod sqrt;\n        pub mod square;\n        pub mod sub_mul;\n        pub mod wrapping_abs;\n        pub mod wrapping_add;\n        pub mod wrapping_add_mul;\n        pub mod wrapping_div;\n        pub mod wrapping_mul;\n        pub mod wrapping_neg;\n        pub mod wrapping_pow;\n        pub mod wrapping_square;\n        pub mod wrapping_sub;\n        pub mod wrapping_sub_mul;\n        pub mod x_mul_y_to_zz;\n        pub mod xx_add_yy_to_zz;\n        pub mod xx_div_mod_y_to_qr;\n        pub mod xx_sub_yy_to_zz;\n        pub mod xxx_add_yyy_to_zzz;\n        pub mod xxx_sub_yyy_to_zzz;\n        pub mod xxxx_add_yyyy_to_zzzz;\n    }\n    pub mod basic {\n        pub mod constants;\n    }\n    pub mod comparison {\n        pub mod cmp_abs;\n        pub mod eq_abs;\n    }\n    pub mod conversion {\n        pub mod digits {\n            pub mod general_digits {\n                pub mod from_digits;\n                pub mod to_digits;\n            }\n            pub mod power_of_2_digits {\n                pub mod from_power_of_2_digits;\n                pub mod power_of_2_digit_iterable;\n                pub mod to_power_of_2_digits;\n            }\n        }\n        pub mod froms {\n            pub mod convertible_from;\n            pub mod from;\n            pub mod overflowing_from;\n            pub mod rounding_from;\n            pub mod saturating_from;\n            pub mod try_from_and_exact_from;\n            pub mod wrapping_from;\n        }\n        pub mod half {\n            pub mod join_halves;\n            pub mod lower_half;\n            pub mod split_in_half;\n            pub mod upper_half;\n        }\n        pub mod is_integer;\n        pub mod mantissa_and_exponent {\n            pub mod integer_mantissa_and_exponent;\n            pub mod raw_mantissa_and_exponent;\n            pub mod sci_mantissa_and_exponent;\n        }\n        pub mod slice {\n            pub mod from_other_type_slice;\n            pub mod vec_from_other_type;\n            pub mod vec_from_other_type_slice;\n        }\n        pub mod string {\n            pub mod from_sci_string;\n            pub mod from_string;\n            pub mod options {\n                pub mod from_sci_string_options;\n                pub mod to_sci_options;\n            }\n            pub mod to_sci;\n            pub mod to_string;\n        }\n    }\n    pub mod exhaustive {\n        pub mod exhaustive_finite_primitive_floats;\n        pub mod exhaustive_natural_signeds;\n        pub mod exhaustive_negative_finite_primitive_floats;\n        pub mod exhaustive_negative_primitive_floats;\n        pub mod exhaustive_negative_signeds;\n        pub mod exhaustive_nonzero_finite_primitive_floats;\n        pub mod exhaustive_nonzero_finite_primitive_floats_in_range;\n        pub mod exhaustive_nonzero_primitive_floats;\n        pub mod exhaustive_nonzero_signeds;\n        pub mod exhaustive_positive_finite_primitive_floats;\n        pub mod exhaustive_positive_finite_primitive_floats_in_range;\n        pub mod exhaustive_positive_primitive_floats;\n        pub mod exhaustive_positive_primitive_ints;\n        pub mod exhaustive_primitive_float_inclusive_range;\n        pub mod exhaustive_primitive_float_range;\n        pub mod exhaustive_primitive_floats;\n        pub mod exhaustive_primitive_floats_with_sci_exponent;\n        pub mod exhaustive_primitive_floats_with_sci_exponent_and_precision;\n        pub mod exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range;\n        pub mod exhaustive_primitive_floats_with_sci_exponent_in_range;\n        pub mod exhaustive_signed_inclusive_range;\n        pub mod exhaustive_signed_range;\n        pub mod exhaustive_signeds;\n        pub mod exhaustive_unsigneds;\n        pub mod finite_primitive_floats_increasing;\n        pub mod negative_finite_primitive_floats_increasing;\n        pub mod negative_primitive_floats_increasing;\n        pub mod nonzero_finite_primitive_floats_increasing;\n        pub mod nonzero_primitive_floats_increasing;\n        pub mod positive_finite_primitive_floats_increasing;\n        pub mod positive_primitive_floats_increasing;\n        pub mod primitive_float_increasing_inclusive_range;\n        pub mod primitive_float_increasing_range;\n        pub mod primitive_floats_increasing;\n        pub mod primitive_int_increasing_inclusive_range;\n        pub mod primitive_int_increasing_range;\n    }\n    pub mod factorization {\n        pub mod factor;\n        pub mod is_power;\n        pub mod is_prime;\n        pub mod is_square;\n        pub mod prime_indicator_sequence;\n        pub mod prime_indicator_sequence_less_than;\n        pub mod prime_sieve;\n        pub mod primes;\n        pub mod primitive_root_prime;\n    }\n    pub mod float {\n        pub mod basic {\n            pub mod abs_negative_zero;\n            pub mod from_ordered_representation;\n            pub mod is_negative_zero;\n            pub mod max_precision_for_sci_exponent;\n            pub mod next_higher;\n            pub mod next_lower;\n            pub mod precision;\n            pub mod to_ordered_representation;\n        }\n        pub mod nice_float {\n            pub mod cmp;\n            pub mod cmp_abs;\n            pub mod eq;\n            pub mod eq_abs;\n            pub mod from_str;\n            pub mod hash;\n            pub mod to_string;\n        }\n    }\n    pub mod iterators {\n        pub mod bit_distributor_sequence;\n        pub mod iterator_to_bit_chunks;\n        pub mod ruler_sequence;\n    }\n    pub mod logic {\n        pub mod bit_access {\n            pub mod assign_bit;\n            pub mod clear_bit;\n            pub mod flip_bit;\n            pub mod get_bit;\n            pub mod set_bit;\n        }\n        pub mod bit_block_access {\n            pub mod assign_bits;\n            pub mod get_bits;\n        }\n        pub mod bit_convertible {\n            pub mod from_bits;\n            pub mod to_bits;\n        }\n        pub mod bit_iterable;\n        pub mod bit_scan {\n            pub mod index_of_next_false_bit;\n            pub mod index_of_next_true_bit;\n        }\n        pub mod get_highest_bit;\n        pub mod hamming_distance;\n        pub mod low_mask;\n        pub mod not_assign;\n        pub mod significant_bits;\n    }\n    pub mod random {\n        pub mod geometric {\n            pub mod geometric_random_natural_signeds;\n            pub mod geometric_random_negative_signeds;\n            pub mod geometric_random_nonzero_signeds;\n            pub mod geometric_random_positive_signeds;\n            pub mod geometric_random_positive_unsigneds;\n            pub mod geometric_random_signed_inclusive_range;\n            pub mod geometric_random_signed_range;\n            pub mod geometric_random_signeds;\n            pub mod geometric_random_unsigned_inclusive_range;\n            pub mod geometric_random_unsigned_range;\n            pub mod geometric_random_unsigneds;\n            pub mod get_geometric_random_signed_from_inclusive_range;\n            pub mod mean;\n        }\n        pub mod random_finite_primitive_floats;\n        pub mod random_highest_bit_set_unsigneds;\n        pub mod random_natural_signeds;\n        pub mod random_negative_finite_primitive_floats;\n        pub mod random_negative_primitive_floats;\n        pub mod random_negative_signeds;\n        pub mod random_nonzero_finite_primitive_floats;\n        pub mod random_nonzero_primitive_floats;\n        pub mod random_nonzero_signeds;\n        pub mod random_positive_finite_primitive_floats;\n        pub mod random_positive_primitive_floats;\n        pub mod random_positive_signeds;\n        pub mod random_positive_unsigneds;\n        pub mod random_primitive_float_inclusive_range;\n        pub mod random_primitive_float_range;\n        pub mod random_primitive_floats;\n        pub mod random_primitive_ints;\n        pub mod random_signed_bit_chunks;\n        pub mod random_signed_inclusive_range;\n        pub mod random_signed_range;\n        pub mod random_unsigned_bit_chunks;\n        pub mod random_unsigned_inclusive_range;\n        pub mod random_unsigned_range;\n        pub mod random_unsigneds_less_than;\n        pub mod special_random_finite_primitive_floats;\n        pub mod special_random_negative_finite_primitive_floats;\n        pub mod special_random_negative_primitive_floats;\n        pub mod special_random_nonzero_finite_primitive_floats;\n        pub mod special_random_nonzero_primitive_floats;\n        pub mod special_random_positive_finite_primitive_floats;\n        pub mod special_random_positive_primitive_floats;\n        pub mod special_random_primitive_float_inclusive_range;\n        pub mod special_random_primitive_float_range;\n        pub mod special_random_primitive_floats;\n        pub mod striped {\n            pub mod get_striped_bool_vec;\n            pub mod get_striped_unsigned_vec;\n            pub mod striped_bit_source;\n            pub mod striped_random_bool_vecs;\n            pub mod striped_random_bool_vecs_from_length_iterator;\n            pub mod striped_random_bool_vecs_length_inclusive_range;\n            pub mod striped_random_bool_vecs_length_range;\n            pub mod striped_random_bool_vecs_min_length;\n            pub mod striped_random_fixed_length_bool_vecs;\n            pub mod striped_random_fixed_length_unsigned_vecs;\n            pub mod striped_random_natural_signeds;\n            pub mod striped_random_negative_signeds;\n            pub mod striped_random_nonzero_signeds;\n            pub mod striped_random_positive_signeds;\n            pub mod striped_random_positive_unsigneds;\n            pub mod striped_random_signed_inclusive_range;\n            pub mod striped_random_signed_range;\n            pub mod striped_random_signeds;\n            pub mod striped_random_unsigned_bit_chunks;\n            pub mod striped_random_unsigned_inclusive_range;\n            pub mod striped_random_unsigned_range;\n            pub mod striped_random_unsigned_vecs;\n            pub mod striped_random_unsigned_vecs_from_length_iterator;\n            pub mod striped_random_unsigned_vecs_length_inclusive_range;\n            pub mod striped_random_unsigned_vecs_length_range;\n            pub mod striped_random_unsigned_vecs_min_length;\n            pub mod striped_random_unsigneds;\n        }\n        pub mod variable_range_generator {\n            pub mod next_bit_chunk;\n            pub mod next_bool;\n            pub mod next_in_inclusive_range;\n            pub mod next_in_range;\n            pub mod next_less_than;\n        }\n    }\n}\npub mod options {\n    pub mod exhaustive {\n        pub mod exhaustive_options;\n        pub mod exhaustive_somes;\n    }\n    pub mod option_from_str;\n    pub mod random {\n        pub mod random_options;\n        pub mod random_somes;\n    }\n}\npub mod orderings {\n    pub mod exhaustive;\n    pub mod ordering_from_str;\n    pub mod random;\n}\npub mod random {\n    pub mod fork;\n    pub mod from_bytes;\n    pub mod get_rng;\n    pub mod next;\n}\npub mod rational_sequences {\n    pub mod access {\n        pub mod get;\n        pub mod mutate;\n    }\n    pub mod basic {\n        pub mod component_len;\n        pub mod is_empty;\n        pub mod is_finite;\n        pub mod iter;\n        pub mod len;\n    }\n    pub mod comparison {\n        pub mod cmp;\n        pub mod eq;\n        pub mod hash;\n    }\n    pub mod conversion {\n        pub mod clone;\n        pub mod from_vec;\n        pub mod from_vecs;\n        pub mod to_vecs;\n    }\n    pub mod exhaustive;\n    pub mod random;\n    pub mod to_string;\n}\npub mod rounding_modes {\n    pub mod clone;\n    pub mod cmp;\n    pub mod eq;\n    pub mod exhaustive;\n    pub mod from_str;\n    pub mod hash;\n    pub mod neg;\n    pub mod random;\n    pub mod size;\n    pub mod to_string;\n}\npub mod sets {\n    pub mod exhaustive {\n        pub mod exhaustive_b_tree_sets;\n        pub mod exhaustive_b_tree_sets_fixed_length;\n        pub mod exhaustive_b_tree_sets_length_inclusive_range;\n        pub mod exhaustive_b_tree_sets_length_range;\n        pub mod exhaustive_b_tree_sets_min_length;\n        #[cfg(feature = \"std\")]\n        pub mod exhaustive_hash_sets;\n        #[cfg(feature = \"std\")]\n        pub mod exhaustive_hash_sets_fixed_length;\n        #[cfg(feature = \"std\")]\n        pub mod exhaustive_hash_sets_length_inclusive_range;\n        #[cfg(feature = \"std\")]\n        pub mod exhaustive_hash_sets_length_range;\n        #[cfg(feature = \"std\")]\n        pub mod exhaustive_hash_sets_min_length;\n        pub mod lex_b_tree_sets;\n        pub mod lex_b_tree_sets_fixed_length;\n        pub mod lex_b_tree_sets_length_inclusive_range;\n        pub mod lex_b_tree_sets_length_range;\n        pub mod lex_b_tree_sets_min_length;\n        #[cfg(feature = \"std\")]\n        pub mod lex_hash_sets;\n        #[cfg(feature = \"std\")]\n        pub mod lex_hash_sets_fixed_length;\n        #[cfg(feature = \"std\")]\n        pub mod lex_hash_sets_length_inclusive_range;\n        #[cfg(feature = \"std\")]\n        pub mod lex_hash_sets_length_range;\n        #[cfg(feature = \"std\")]\n        pub mod lex_hash_sets_min_length;\n        pub mod shortlex_b_tree_sets;\n        pub mod shortlex_b_tree_sets_length_inclusive_range;\n        pub mod shortlex_b_tree_sets_length_range;\n        pub mod shortlex_b_tree_sets_min_length;\n        #[cfg(feature = \"std\")]\n        pub mod shortlex_hash_sets;\n        #[cfg(feature = \"std\")]\n        pub mod shortlex_hash_sets_length_inclusive_range;\n        #[cfg(feature = \"std\")]\n        pub mod shortlex_hash_sets_length_range;\n        #[cfg(feature = \"std\")]\n        pub mod shortlex_hash_sets_min_length;\n    }\n    pub mod random {\n        pub mod random_b_tree_sets;\n        pub mod random_b_tree_sets_fixed_length;\n        pub mod random_b_tree_sets_from_length_iterator;\n        pub mod random_b_tree_sets_length_inclusive_range;\n        pub mod random_b_tree_sets_length_range;\n        pub mod random_b_tree_sets_min_length;\n        pub mod random_hash_sets;\n        pub mod random_hash_sets_fixed_length;\n        pub mod random_hash_sets_from_length_iterator;\n        pub mod random_hash_sets_length_inclusive_range;\n        pub mod random_hash_sets_length_range;\n        pub mod random_hash_sets_min_length;\n    }\n}\npub mod slices {\n    pub mod exhaustive_slice_permutations;\n    pub mod min_repeating_len;\n    pub mod random_slice_permutations;\n    pub mod slice_leading_zeros;\n    pub mod slice_move_left;\n    pub mod slice_set_zero;\n    pub mod slice_test_zero;\n    pub mod slice_trailing_zeros;\n    pub mod split_into_chunks;\n}\npub mod strings {\n    pub mod exhaustive {\n        pub mod exhaustive_fixed_length_strings;\n        pub mod exhaustive_fixed_length_strings_using_chars;\n        pub mod exhaustive_strings;\n        pub mod exhaustive_strings_using_chars;\n        pub mod lex_fixed_length_strings;\n        pub mod lex_fixed_length_strings_using_chars;\n        pub mod shortlex_strings;\n        pub mod shortlex_strings_using_chars;\n    }\n    pub mod random {\n        pub mod random_fixed_length_strings;\n        pub mod random_fixed_length_strings_using_chars;\n        pub mod random_strings;\n        pub mod random_strings_using_chars;\n    }\n    pub mod string_is_subset;\n    pub mod string_sort;\n    pub mod string_unique;\n    pub mod strings_from_char_vecs;\n    pub mod to_binary_string;\n    pub mod to_debug_string;\n    pub mod to_lower_hex_string;\n    pub mod to_octal_string;\n    pub mod to_upper_hex_string;\n}\npub mod tuples {\n    pub mod exhaustive {\n        pub mod exhaustive_custom_tuples;\n        pub mod exhaustive_dependent_pairs;\n        pub mod exhaustive_ordered_unique_tuples;\n        pub mod exhaustive_tuples_1_input;\n        pub mod exhaustive_tuples_custom_output;\n        pub mod exhaustive_tuples_from_single;\n        pub mod exhaustive_unique_tuples;\n        pub mod exhaustive_units;\n        pub mod lex_custom_tuples;\n        pub mod lex_dependent_pairs;\n        pub mod lex_ordered_unique_tuples;\n        pub mod lex_tuples;\n        pub mod lex_tuples_from_single;\n        pub mod lex_unique_tuples;\n    }\n    pub mod random {\n        pub mod random_custom_tuples;\n        pub mod random_ordered_unique_tuples;\n        pub mod random_tuples;\n        pub mod random_tuples_from_single;\n        pub mod random_unique_tuples;\n        pub mod random_units;\n    }\n    pub mod singletons;\n}\npub mod unions {\n    pub mod clone;\n    pub mod debug;\n    pub mod display;\n    pub mod eq;\n    pub mod exhaustive {\n        pub mod exhaustive_unions;\n        pub mod lex_unions;\n    }\n    pub mod from_str;\n    pub mod ord;\n    pub mod random {\n        pub mod random_unions;\n    }\n    pub mod unwrap;\n}\npub mod vecs {\n    pub mod exhaustive {\n        pub mod exhaustive_combined_k_compositions;\n        pub mod exhaustive_ordered_unique_vecs;\n        pub mod exhaustive_ordered_unique_vecs_fixed_length;\n        pub mod exhaustive_ordered_unique_vecs_length_inclusive_range;\n        pub mod exhaustive_ordered_unique_vecs_length_range;\n        pub mod exhaustive_ordered_unique_vecs_min_length;\n        pub mod exhaustive_unique_vecs;\n        pub mod exhaustive_unique_vecs_fixed_length;\n        pub mod exhaustive_unique_vecs_length_inclusive_range;\n        pub mod exhaustive_unique_vecs_length_range;\n        pub mod exhaustive_unique_vecs_min_length;\n        pub mod exhaustive_vecs;\n        pub mod exhaustive_vecs_fixed_length_from_single;\n        pub mod exhaustive_vecs_fixed_length_m_inputs;\n        pub mod exhaustive_vecs_from_length_iterator;\n        pub mod exhaustive_vecs_length_inclusive_range;\n        pub mod exhaustive_vecs_length_n;\n        pub mod exhaustive_vecs_length_range;\n        pub mod exhaustive_vecs_min_length;\n        pub mod lex_k_compositions;\n        pub mod lex_ordered_unique_vecs;\n        pub mod lex_ordered_unique_vecs_fixed_length;\n        pub mod lex_ordered_unique_vecs_length_inclusive_range;\n        pub mod lex_ordered_unique_vecs_length_range;\n        pub mod lex_ordered_unique_vecs_min_length;\n        pub mod lex_unique_vecs;\n        pub mod lex_unique_vecs_fixed_length;\n        pub mod lex_unique_vecs_length_inclusive_range;\n        pub mod lex_unique_vecs_length_range;\n        pub mod lex_unique_vecs_min_length;\n        pub mod lex_vecs_fixed_length_from_single;\n        pub mod lex_vecs_fixed_length_m_inputs;\n        pub mod lex_vecs_length_n;\n        pub mod next_bit_pattern;\n        pub mod shortlex_ordered_unique_vecs;\n        pub mod shortlex_ordered_unique_vecs_length_inclusive_range;\n        pub mod shortlex_ordered_unique_vecs_length_range;\n        pub mod shortlex_ordered_unique_vecs_min_length;\n        pub mod shortlex_unique_vecs;\n        pub mod shortlex_unique_vecs_length_inclusive_range;\n        pub mod shortlex_unique_vecs_length_range;\n        pub mod shortlex_unique_vecs_min_length;\n        pub mod shortlex_vecs;\n        pub mod shortlex_vecs_from_length_iterator;\n        pub mod shortlex_vecs_length_inclusive_range;\n        pub mod shortlex_vecs_length_range;\n        pub mod shortlex_vecs_min_length;\n    }\n    pub mod exhaustive_vec_permutations;\n    pub mod random {\n        pub mod random_ordered_unique_vecs;\n        pub mod random_ordered_unique_vecs_fixed_length;\n        pub mod random_ordered_unique_vecs_from_length_iterator;\n        pub mod random_ordered_unique_vecs_length_inclusive_range;\n        pub mod random_ordered_unique_vecs_length_range;\n        pub mod random_ordered_unique_vecs_min_length;\n        pub mod random_unique_vecs;\n        pub mod random_unique_vecs_fixed_length;\n        pub mod random_unique_vecs_from_length_iterator;\n        pub mod random_unique_vecs_length_inclusive_range;\n        pub mod random_unique_vecs_length_range;\n        pub mod random_unique_vecs_min_length;\n        pub mod random_vecs;\n        pub mod random_vecs_fixed_length;\n        pub mod random_vecs_fixed_length_from_single;\n        pub mod random_vecs_fixed_length_m_inputs;\n        pub mod random_vecs_from_length_iterator;\n        pub mod random_vecs_length_inclusive_range;\n        pub mod random_vecs_length_range;\n        pub mod random_vecs_min_length;\n    }\n    pub mod random_values_from_vec;\n    pub mod random_vec_permutations;\n    pub mod vec_delete_left;\n    pub mod vec_from_str;\n    pub mod vec_pad_left;\n}\n"
  },
  {
    "path": "malachite-base/tests/named/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::rounding_modes::RoundingMode;\n\n#[test]\npub fn test_named() {\n    fn test<T: Named>(out: &str) {\n        assert_eq!(T::NAME, out);\n    }\n    test::<String>(\"String\");\n    test::<RoundingMode>(\"RoundingMode\");\n}\n"
  },
  {
    "path": "malachite-base/tests/nevers/nevers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::nevers::nevers;\n\n#[test]\nfn test_nevers() {\n    assert_eq!(nevers().collect_vec(), &[]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen_var_1};\nuse std::cmp::Ordering::*;\n\nfn abs_signed_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.abs(), out);\n\n        let mut n = n;\n        n.abs_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::ONE, T::ONE);\n    test(T::exact_from(100), T::exact_from(100));\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::exact_from(-100), T::exact_from(100));\n}\n\nfn abs_primitive_float_helper<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(NiceFloat(n.abs()), NiceFloat(out));\n\n        let mut n = n;\n        n.abs_assign();\n        assert_eq!(NiceFloat(n), NiceFloat(out));\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::NEGATIVE_ZERO, T::ZERO);\n    test(T::INFINITY, T::INFINITY);\n    test(T::NEGATIVE_INFINITY, T::INFINITY);\n    test(T::NAN, T::NAN);\n    test(T::ONE, T::ONE);\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::from(100.0f32), T::from(100.0f32));\n    test(T::from(-100.0f32), T::from(100.0f32));\n}\n\n#[test]\nfn test_abs() {\n    apply_fn_to_signeds!(abs_signed_helper);\n    apply_fn_to_primitive_floats!(abs_primitive_float_helper);\n}\n\nfn abs_assign_properties_signed_helper<\n    U,\n    S: ExactFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>() {\n    signed_gen_var_1::<S>().test_properties(|n| {\n        let mut abs = n;\n        abs.abs_assign();\n        assert_eq!(abs, n.abs());\n        assert_eq!(abs.abs(), abs);\n        assert_eq!(abs == n, n >= S::ZERO);\n        assert_eq!(S::exact_from(n.unsigned_abs()), abs);\n    });\n}\n\nfn abs_assign_properties_primitive_float_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|f| {\n        let mut abs = f;\n        abs.abs_assign();\n        assert_eq!(NiceFloat(abs), NiceFloat(f.abs()));\n        assert_eq!(NiceFloat(abs.abs()), NiceFloat(abs));\n        assert_eq!(NiceFloat(abs) == NiceFloat(f), f.sign() != Less);\n    });\n}\n\n#[test]\nfn abs_assign_properties() {\n    apply_fn_to_unsigned_signed_pairs!(abs_assign_properties_signed_helper);\n    apply_fn_to_primitive_floats!(abs_assign_properties_primitive_float_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AbsDiff, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen, unsigned_gen, unsigned_pair_gen_var_27,\n};\nuse std::cmp::{max, min};\n\n#[test]\nfn test_abs_diff() {\n    fn test_unsigned<T: PrimitiveUnsigned>(x: T, y: T, out: T) {\n        assert_eq!(x.abs_diff(y), out);\n\n        let mut x = x;\n        x.abs_diff_assign(y);\n        assert_eq!(x, out);\n    }\n    test_unsigned::<u8>(1, 100, 99);\n    test_unsigned::<u8>(100, 1, 99);\n    test_unsigned::<u16>(10, 10, 0);\n    test_unsigned::<u32>(0, u32::MAX, u32::MAX);\n    test_unsigned::<u32>(u32::MAX, 0, u32::MAX);\n    test_unsigned::<u32>(u32::MAX, u32::MAX, 0);\n\n    fn test_signed<T: PrimitiveSigned + AbsDiff<Output = U>, U: PrimitiveUnsigned>(\n        x: T,\n        y: T,\n        out: U,\n    ) {\n        assert_eq!(x.abs_diff(y), out);\n    }\n    test_signed::<i8, _>(1, 100, 99);\n    test_signed::<i8, _>(1, -100, 101);\n    test_signed::<i8, _>(-1, 100, 101);\n    test_signed::<i8, _>(-1, -100, 99);\n    test_signed::<i8, _>(100, 1, 99);\n    test_signed::<i8, _>(100, -1, 101);\n    test_signed::<i8, _>(-100, 1, 101);\n    test_signed::<i8, _>(-100, -1, 99);\n    test_signed::<i16, _>(10, 10, 0);\n    test_signed::<i16, _>(10, -10, 20);\n    test_signed::<i16, _>(-10, 10, 20);\n    test_signed::<i16, _>(-10, -10, 0);\n    test_signed::<i32, _>(0, i32::MAX, u32::exact_from(i32::MAX));\n    test_signed::<i32, _>(0, -i32::MAX, u32::exact_from(i32::MAX));\n    test_signed::<i32, _>(i32::MAX, 0, u32::exact_from(i32::MAX));\n    test_signed::<i32, _>(-i32::MAX, 0, u32::exact_from(i32::MAX));\n    test_signed::<i32, _>(i32::MAX, i32::MAX, 0);\n    test_signed::<i32, _>(i32::MAX, -i32::MAX, u32::MAX - 1);\n    test_signed::<i32, _>(-i32::MAX, i32::MAX, u32::MAX - 1);\n    test_signed::<i32, _>(-i32::MAX, -i32::MAX, 0);\n\n    test_signed::<i64, _>(i64::MIN, i64::MAX, u64::MAX);\n    test_signed::<i64, _>(i64::MIN, -i64::MAX, 1);\n}\n\nfn abs_diff_properties_unsigned_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let diff = x.abs_diff(y);\n        let mut mut_x = x;\n        mut_x.abs_diff_assign(y);\n        assert_eq!(mut_x, diff);\n\n        assert_eq!(y.abs_diff(x), diff);\n        assert_eq!(max(x, y) - min(x, y), diff);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.abs_diff(T::ZERO), x);\n        assert_eq!(T::ZERO.abs_diff(x), x);\n        assert_eq!(x.abs_diff(x), T::ZERO);\n    });\n}\n\nfn abs_diff_properties_signed_helper<\n    U: PrimitiveUnsigned,\n    T: AbsDiff<Output = U> + UnsignedAbs<Output = U> + PrimitiveSigned,\n>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let diff = x.abs_diff(y);\n        assert_eq!(y.abs_diff(x), diff);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.abs_diff(T::ZERO), x.unsigned_abs());\n        assert_eq!(T::ZERO.abs_diff(x), x.unsigned_abs());\n        assert_eq!(x.abs_diff(x), U::ZERO);\n    });\n}\n\n#[test]\nfn abs_diff_properties() {\n    apply_fn_to_unsigneds!(abs_diff_properties_unsigned_helper);\n    apply_fn_to_unsigned_signed_pairs!(abs_diff_properties_signed_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_triple_gen, signed_pair_gen, signed_triple_gen_var_1, unsigned_pair_gen_var_27,\n    unsigned_triple_gen_var_1,\n};\n\n#[test]\nfn test_add_mul() {\n    fn test_i<T: PrimitiveInt>(x: T, y: T, z: T, out: T) {\n        assert_eq!(x.add_mul(y, z), out);\n\n        let mut x = x;\n        x.add_mul_assign(y, z);\n        assert_eq!(x, out);\n    }\n    test_i::<u8>(2, 3, 7, 23);\n    test_i::<u32>(7, 5, 10, 57);\n    test_i::<u64>(123, 456, 789, 359907);\n    test_i::<i32>(123, -456, 789, -359661);\n    test_i::<i128>(-123, 456, 789, 359661);\n    test_i::<i8>(127, -2, 100, -73);\n    test_i::<i8>(-127, 2, 100, 73);\n    test_i::<i8>(-128, 1, 0, -128);\n\n    fn test_f<T: PrimitiveFloat>(x: T, y: T, z: T, out: T) {\n        assert_eq!(NiceFloat(x.add_mul(y, z)), NiceFloat(out));\n\n        let mut x = x;\n        x.add_mul_assign(y, z);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n    }\n    test_f::<f32>(1.0, 2.0, 3.0, 7.0);\n    test_f::<f32>(1.0, f32::INFINITY, 2.0, f32::INFINITY);\n    test_f::<f32>(f32::NAN, 1.0, 2.0, f32::NAN);\n}\n\nfn add_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_1::<T>().test_properties(|(x, y, z)| {\n        let result = x.add_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.add_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.add_mul(z, y), result);\n        assert_eq!(result.sub_mul(y, z), x);\n        assert_eq!(x.checked_add_mul(y, z), Some(result));\n        assert_eq!(x.saturating_add_mul(y, z), result);\n        assert_eq!(x.wrapping_add_mul(y, z), result);\n        assert_eq!(x.overflowing_add_mul(y, z), (result, false));\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.add_mul(T::ZERO, b), a);\n        assert_eq!(a.add_mul(b, T::ZERO), a);\n    });\n}\n\nfn add_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen_var_1::<T>().test_properties(|(x, y, z)| {\n        let result = x.add_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.add_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.add_mul(z, y), result);\n        assert_eq!(result.sub_mul(y, z), x);\n        assert_eq!(x.checked_add_mul(y, z), Some(result));\n        assert_eq!(x.saturating_add_mul(y, z), result);\n        assert_eq!(x.wrapping_add_mul(y, z), result);\n        assert_eq!(x.overflowing_add_mul(y, z), (result, false));\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.add_mul(T::ZERO, b), a);\n        assert_eq!(a.add_mul(b, T::ZERO), a);\n    });\n}\n\nfn add_mul_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.add_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.add_mul_assign(y, z);\n        assert_eq!(NiceFloat(x_alt), NiceFloat(result));\n\n        assert_eq!(NiceFloat(x.add_mul(z, y)), NiceFloat(result));\n    });\n}\n\n#[test]\nfn add_mul_properties() {\n    apply_fn_to_unsigneds!(add_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(add_mul_properties_helper_signed);\n    apply_fn_to_primitive_floats!(add_mul_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/arithmetic_checked_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShl, ArithmeticCheckedShr};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, signed_pair_gen_var_2, signed_unsigned_pair_gen_var_1,\n    unsigned_gen, unsigned_gen_var_5, unsigned_pair_gen_var_2, unsigned_signed_pair_gen_var_1,\n};\nuse std::ops::Shr;\n\n#[test]\nfn test_arithmetic_checked_shl() {\n    fn test<T: ArithmeticCheckedShl<U, Output = T> + PrimitiveInt, U: PrimitiveInt>(\n        t: T,\n        u: U,\n        out: Option<T>,\n    ) {\n        assert_eq!(t.arithmetic_checked_shl(u), out);\n    }\n    test::<u16, u8>(0, 0, Some(0));\n    test::<u8, u16>(3, 6, Some(192));\n    test::<u8, u32>(3, 7, None);\n    test::<u64, u64>(3, 100, None);\n    test::<u64, u128>(0, 100, Some(0));\n\n    test::<u32, i8>(100, -3, Some(12));\n    test::<u32, i16>(100, -100, Some(0));\n\n    test::<i8, u8>(3, 5, Some(96));\n    test::<i8, u16>(3, 6, None);\n    test::<i8, u32>(-3, 5, Some(-96));\n    test::<i8, u64>(-3, 6, None);\n    test::<i16, u128>(3, 100, None);\n    test::<i16, usize>(-3, 100, None);\n    test::<i64, u8>(0, 100, Some(0));\n\n    test::<i8, i8>(3, 5, Some(96));\n    test::<i8, i16>(3, 6, None);\n    test::<i8, i32>(-3, 5, Some(-96));\n    test::<i8, i64>(-3, 6, None);\n    test::<i16, i128>(3, 100, None);\n    test::<i16, isize>(-3, 100, None);\n    test::<i32, i8>(0, 100, Some(0));\n    test::<i32, i16>(100, -3, Some(12));\n    test::<i32, i32>(-100, -3, Some(-13));\n    test::<i64, i64>(100, -100, Some(0));\n    test::<i64, i128>(-100, -100, Some(-1));\n}\n\nfn arithmetic_checked_shl_properties_helper_unsigned_unsigned<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveUnsigned + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n>()\nwhere\n    u64: ExactFrom<U>,\n{\n    unsigned_pair_gen_var_2::<T, U>().test_properties(|(n, u)| {\n        if let Some(shifted) = n.arithmetic_checked_shl(u) {\n            assert!(shifted >= n);\n            if n != T::ZERO {\n                assert_eq!(shifted >> u, n);\n            }\n        } else {\n            assert_ne!(n, T::ZERO);\n            assert!(LeadingZeros::leading_zeros(n) < u64::exact_from(u));\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.arithmetic_checked_shl(U::ZERO), Some(n));\n    });\n\n    unsigned_gen_var_5::<U>().test_properties(|u| {\n        assert_eq!(T::ZERO.arithmetic_checked_shl(u), Some(T::ZERO));\n    });\n}\n\n// Type repetition to avoid long line\n#[allow(\n    clippy::type_repetition_in_bounds,\n    clippy::trait_duplication_in_bounds,\n    clippy::multiple_bound_locations\n)]\nfn arithmetic_checked_shl_properties_helper_unsigned_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + ArithmeticCheckedShr<U, Output = T>,\n    U: PrimitiveSigned,\n>()\nwhere\n    u64: ExactFrom<U>,\n    T: PrimitiveUnsigned,\n{\n    unsigned_signed_pair_gen_var_1::<T, U>().test_properties(|(n, i)| {\n        let shifted = n.arithmetic_checked_shl(i);\n        if shifted.is_none() {\n            assert_ne!(n, T::ZERO);\n        }\n        if i != U::MIN {\n            assert_eq!(n.arithmetic_checked_shr(-i), shifted);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.arithmetic_checked_shl(U::ZERO), Some(n));\n    });\n\n    signed_gen_var_5::<U>().test_properties(|i| {\n        assert_eq!(T::ZERO.arithmetic_checked_shl(i), Some(T::ZERO));\n    });\n}\n\nfn arithmetic_checked_shl_properties_helper_signed_unsigned<\n    T: ArithmeticCheckedShl<U, Output = T> + PrimitiveSigned + Shr<U, Output = T>,\n    U: PrimitiveUnsigned,\n>()\nwhere\n    u64: ExactFrom<U>,\n{\n    signed_unsigned_pair_gen_var_1::<T, U>().test_properties(|(n, u)| {\n        if let Some(shifted) = n.arithmetic_checked_shl(u) {\n            assert!(shifted.ge_abs(&n));\n            if n != T::ZERO {\n                assert_eq!(shifted >> u, n);\n            }\n        } else {\n            assert_ne!(n, T::ZERO);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.arithmetic_checked_shl(U::ZERO), Some(n));\n    });\n\n    unsigned_gen_var_5::<U>().test_properties(|u| {\n        assert_eq!(T::ZERO.arithmetic_checked_shl(u), Some(T::ZERO));\n    });\n}\n\nfn arithmetic_checked_shl_properties_helper_signed_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + ArithmeticCheckedShr<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveSigned,\n>()\nwhere\n    u64: ExactFrom<U>,\n{\n    signed_pair_gen_var_2::<T, U>().test_properties(|(n, i)| {\n        let shifted = n.arithmetic_checked_shl(i);\n        if shifted.is_none() {\n            assert_ne!(n, T::ZERO);\n        }\n        if i != U::MIN {\n            assert_eq!(n.arithmetic_checked_shr(-i), shifted);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.arithmetic_checked_shl(U::ZERO), Some(n));\n    });\n\n    signed_gen_var_5::<U>().test_properties(|i| {\n        assert_eq!(T::ZERO.arithmetic_checked_shl(i), Some(T::ZERO));\n    });\n}\n\n#[test]\nfn arithmetic_checked_shl_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(\n        arithmetic_checked_shl_properties_helper_unsigned_unsigned\n    );\n    apply_fn_to_unsigneds_and_signeds!(arithmetic_checked_shl_properties_helper_unsigned_signed);\n    apply_fn_to_signeds_and_unsigneds!(arithmetic_checked_shl_properties_helper_signed_unsigned);\n    apply_fn_to_signeds_and_signeds!(arithmetic_checked_shl_properties_helper_signed_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/arithmetic_checked_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShl, ArithmeticCheckedShr};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, signed_pair_gen_var_2, unsigned_gen,\n    unsigned_signed_pair_gen_var_1,\n};\n\n#[test]\nfn test_arithmetic_checked_shr() {\n    fn test<T: ArithmeticCheckedShr<U, Output = T> + PrimitiveInt, U: PrimitiveInt>(\n        t: T,\n        u: U,\n        out: Option<T>,\n    ) {\n        assert_eq!(t.arithmetic_checked_shr(u), out);\n    }\n    test::<u32, i8>(100, 3, Some(12));\n    test::<u32, i16>(100, 100, Some(0));\n\n    test::<i8, i8>(3, -5, Some(96));\n    test::<i8, i16>(3, -6, None);\n    test::<i8, i32>(-3, -5, Some(-96));\n    test::<i8, i64>(-3, -6, None);\n    test::<i16, i128>(3, -100, None);\n    test::<i16, isize>(-3, -100, None);\n    test::<i32, i8>(0, -100, Some(0));\n    test::<i32, i16>(100, 3, Some(12));\n    test::<i32, i32>(-100, 3, Some(-13));\n    test::<i64, i64>(100, 100, Some(0));\n    test::<i64, i128>(-100, 100, Some(-1));\n}\n\n// Type repetition to avoid long line\n#[allow(\n    clippy::type_repetition_in_bounds,\n    clippy::trait_duplication_in_bounds,\n    clippy::multiple_bound_locations\n)]\nfn arithmetic_checked_shr_properties_helper_unsigned_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + ArithmeticCheckedShr<U, Output = T>,\n    U: PrimitiveSigned,\n>()\nwhere\n    u64: ExactFrom<U>,\n    T: PrimitiveUnsigned,\n{\n    unsigned_signed_pair_gen_var_1::<T, U>().test_properties(|(n, i)| {\n        let shifted = n.arithmetic_checked_shr(i);\n        if shifted.is_none() {\n            assert_ne!(n, T::ZERO);\n        }\n        if i != U::MIN {\n            assert_eq!(n.arithmetic_checked_shl(-i), shifted);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.arithmetic_checked_shr(U::ZERO), Some(n));\n    });\n\n    signed_gen_var_5::<U>().test_properties(|i| {\n        assert_eq!(T::ZERO.arithmetic_checked_shr(i), Some(T::ZERO));\n    });\n}\n\nfn arithmetic_checked_shr_properties_helper_signed_signed<\n    T: ArithmeticCheckedShl<U, Output = T> + ArithmeticCheckedShr<U, Output = T> + PrimitiveSigned,\n    U: PrimitiveSigned,\n>()\nwhere\n    u64: ExactFrom<U>,\n{\n    signed_pair_gen_var_2::<T, U>().test_properties(|(n, i)| {\n        let shifted = n.arithmetic_checked_shr(i);\n        if shifted.is_none() {\n            assert_ne!(n, T::ZERO);\n        }\n        if i != U::MIN {\n            assert_eq!(n.arithmetic_checked_shl(-i), shifted);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.arithmetic_checked_shr(U::ZERO), Some(n));\n    });\n\n    signed_gen_var_5::<U>().test_properties(|i| {\n        assert_eq!(T::ZERO.arithmetic_checked_shr(i), Some(T::ZERO));\n    });\n}\n\n#[test]\nfn arithmetic_checked_shr_properties() {\n    apply_fn_to_unsigneds_and_signeds!(arithmetic_checked_shr_properties_helper_unsigned_signed);\n    apply_fn_to_signeds_and_signeds!(arithmetic_checked_shr_properties_helper_signed_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::BinomialCoefficient;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_2, signed_pair_gen_var_11, signed_pair_gen_var_12, unsigned_gen,\n    unsigned_gen_var_1, unsigned_pair_gen_var_28, unsigned_pair_gen_var_44,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_binomial_coefficient() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, k: T, out: T) {\n        assert_eq!(T::binomial_coefficient(n, k), out);\n    }\n    test_u::<u8>(0, 0, 1);\n\n    test_u::<u8>(1, 0, 1);\n    test_u::<u8>(1, 1, 1);\n\n    test_u::<u8>(2, 0, 1);\n    test_u::<u8>(2, 1, 2);\n    test_u::<u8>(2, 2, 1);\n\n    test_u::<u8>(3, 0, 1);\n    test_u::<u8>(3, 1, 3);\n    test_u::<u8>(3, 2, 3);\n    test_u::<u8>(3, 3, 1);\n\n    test_u::<u8>(4, 0, 1);\n    test_u::<u8>(4, 1, 4);\n    test_u::<u8>(4, 2, 6);\n    test_u::<u8>(4, 3, 4);\n    test_u::<u8>(4, 4, 1);\n\n    test_u::<u8>(1, 2, 0);\n    test_u::<u8>(10, 5, 252);\n    test_u::<u128>(100, 50, 100891344545564193334812497256);\n\n    fn test_i<T: PrimitiveSigned>(n: T, k: T, out: T) {\n        assert_eq!(T::binomial_coefficient(n, k), out);\n    }\n    test_i::<i8>(0, 0, 1);\n\n    test_i::<i8>(1, 0, 1);\n    test_i::<i8>(1, 1, 1);\n\n    test_i::<i8>(2, 0, 1);\n    test_i::<i8>(2, 1, 2);\n    test_i::<i8>(2, 2, 1);\n\n    test_i::<i8>(3, 0, 1);\n    test_i::<i8>(3, 1, 3);\n    test_i::<i8>(3, 2, 3);\n    test_i::<i8>(3, 3, 1);\n\n    test_i::<i8>(4, 0, 1);\n    test_i::<i8>(4, 1, 4);\n    test_i::<i8>(4, 2, 6);\n    test_i::<i8>(4, 3, 4);\n    test_i::<i8>(4, 4, 1);\n\n    test_i::<i8>(1, 2, 0);\n    test_i::<i16>(10, 5, 252);\n    test_i::<i128>(100, 50, 100891344545564193334812497256);\n\n    test_i::<i8>(-1, 0, 1);\n    test_i::<i8>(-1, 1, -1);\n\n    test_i::<i8>(-2, 0, 1);\n    test_i::<i8>(-2, 1, -2);\n    test_i::<i8>(-2, 2, 3);\n\n    test_i::<i8>(-3, 0, 1);\n    test_i::<i8>(-3, 1, -3);\n    test_i::<i8>(-3, 2, 6);\n    test_i::<i8>(-3, 3, -10);\n\n    test_i::<i8>(-1, 2, 1);\n    test_i::<i16>(-10, 5, -2002);\n    test_i::<i128>(-80, 50, 1828256793482238093393785743858493760);\n\n    test_i::<i8>(-128, 1, -128);\n    test_i::<i8>(-2, 127, -128);\n}\n\n#[test]\npub fn binomial_coefficient_fail() {\n    assert_panic!(u8::binomial_coefficient(11, 5));\n    assert_panic!(u128::binomial_coefficient(1000000, 1000));\n    assert_panic!(i8::binomial_coefficient(11, 5));\n    assert_panic!(i128::binomial_coefficient(1000000, 1000));\n    assert_panic!(i8::binomial_coefficient(1, -1));\n}\n\n#[test]\nfn test_checked_binomial_coefficient() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, k: T, out: Option<T>) {\n        assert_eq!(T::checked_binomial_coefficient(n, k), out);\n    }\n    test_u::<u8>(0, 0, Some(1));\n\n    test_u::<u8>(1, 0, Some(1));\n    test_u::<u8>(1, 1, Some(1));\n\n    test_u::<u8>(2, 0, Some(1));\n    test_u::<u8>(2, 1, Some(2));\n    test_u::<u8>(2, 2, Some(1));\n\n    test_u::<u8>(3, 0, Some(1));\n    test_u::<u8>(3, 1, Some(3));\n    test_u::<u8>(3, 2, Some(3));\n    test_u::<u8>(3, 3, Some(1));\n\n    test_u::<u8>(4, 0, Some(1));\n    test_u::<u8>(4, 1, Some(4));\n    test_u::<u8>(4, 2, Some(6));\n    test_u::<u8>(4, 3, Some(4));\n    test_u::<u8>(4, 4, Some(1));\n\n    test_u::<u8>(1, 2, Some(0));\n    test_u::<u8>(10, 5, Some(252));\n    test_u::<u128>(100, 50, Some(100891344545564193334812497256));\n\n    test_u::<u8>(11, 5, None);\n    test_u::<u128>(1000000, 1000, None);\n\n    fn test_i<T: PrimitiveSigned>(n: T, k: T, out: Option<T>) {\n        assert_eq!(T::checked_binomial_coefficient(n, k), out);\n    }\n    test_i::<i8>(0, 0, Some(1));\n\n    test_i::<i8>(1, 0, Some(1));\n    test_i::<i8>(1, 1, Some(1));\n\n    test_i::<i8>(2, 0, Some(1));\n    test_i::<i8>(2, 1, Some(2));\n    test_i::<i8>(2, 2, Some(1));\n\n    test_i::<i8>(3, 0, Some(1));\n    test_i::<i8>(3, 1, Some(3));\n    test_i::<i8>(3, 2, Some(3));\n    test_i::<i8>(3, 3, Some(1));\n\n    test_i::<i8>(4, 0, Some(1));\n    test_i::<i8>(4, 1, Some(4));\n    test_i::<i8>(4, 2, Some(6));\n    test_i::<i8>(4, 3, Some(4));\n    test_i::<i8>(4, 4, Some(1));\n\n    test_i::<i8>(1, 2, Some(0));\n    test_i::<i16>(10, 5, Some(252));\n    test_i::<i128>(100, 50, Some(100891344545564193334812497256));\n\n    test_i::<i8>(-1, 0, Some(1));\n    test_i::<i8>(-1, 1, Some(-1));\n\n    test_i::<i8>(-2, 0, Some(1));\n    test_i::<i8>(-2, 1, Some(-2));\n    test_i::<i8>(-2, 2, Some(3));\n\n    test_i::<i8>(-3, 0, Some(1));\n    test_i::<i8>(-3, 1, Some(-3));\n    test_i::<i8>(-3, 2, Some(6));\n    test_i::<i8>(-3, 3, Some(-10));\n\n    test_i::<i8>(-1, 2, Some(1));\n    test_i::<i16>(-10, 5, Some(-2002));\n    test_i::<i128>(-80, 50, Some(1828256793482238093393785743858493760));\n\n    test_i::<i8>(-128, 1, Some(-128));\n    test_i::<i8>(-2, 127, Some(-128));\n\n    test_i::<i8>(11, 5, None);\n    test_i::<i128>(1000000, 1000, None);\n    test_i::<i8>(1, -1, None);\n}\n\nfn binomial_coefficient_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_44::<T>().test_properties(|(n, k)| {\n        let b = T::binomial_coefficient(n, k);\n        assert_eq!(b == T::ZERO, n < k);\n        if n >= k {\n            assert_eq!(T::binomial_coefficient(n, n - k), b);\n        }\n        if n != T::ZERO && k != T::ZERO {\n            let c = T::binomial_coefficient(n - T::ONE, k - T::ONE);\n            assert_eq!(T::binomial_coefficient(n - T::ONE, k) + c, b);\n            let gcd = n.gcd(k);\n            assert_eq!(c / (k / gcd) * (n / gcd), b);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(T::binomial_coefficient(n, T::ZERO), T::ONE);\n        assert_eq!(T::binomial_coefficient(n, T::ONE), n);\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(T::binomial_coefficient(n, n), T::ONE);\n        assert_eq!(T::binomial_coefficient(n, n - T::ONE), n);\n        assert_eq!(T::binomial_coefficient(T::ZERO, n), T::ZERO);\n    });\n}\n\nfn binomial_coefficient_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_12::<T>().test_properties(|(n, k)| {\n        let b = T::binomial_coefficient(n, k);\n        assert_eq!(b == T::ZERO, n >= T::ZERO && n < k);\n        if n >= k {\n            assert_eq!(T::binomial_coefficient(n, n - k), b);\n        }\n        if n != T::MIN\n            && k != T::ZERO\n            && let Some(c) = T::checked_binomial_coefficient(n - T::ONE, k)\n        {\n            assert_eq!(c + T::binomial_coefficient(n - T::ONE, k - T::ONE), b);\n        }\n        if n != T::MIN\n            && let Some(s) = (n - T::ONE).checked_add(k)\n            && let Some(mut b_alt) = T::checked_binomial_coefficient(s, k)\n        {\n            if k.odd() {\n                b_alt.neg_assign();\n            }\n            assert_eq!(T::binomial_coefficient(-n, k), b_alt);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(T::binomial_coefficient(n, T::ONE), n);\n        assert_eq!(T::binomial_coefficient(n, T::ZERO), T::ONE);\n    });\n\n    signed_gen_var_2::<T>().test_properties(|n| {\n        assert_eq!(T::binomial_coefficient(n, n), T::ONE);\n        if n != T::ZERO {\n            assert_eq!(T::binomial_coefficient(n, n - T::ONE), n);\n            assert_eq!(T::binomial_coefficient(T::ZERO, n), T::ZERO);\n        }\n    });\n}\n\n#[test]\nfn binomial_coefficient_properties() {\n    apply_fn_to_unsigneds!(binomial_coefficient_helper_unsigned);\n    apply_fn_to_signeds!(binomial_coefficient_helper_signed);\n}\n\nfn checked_binomial_coefficient_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_28::<T, T>().test_properties(|(n, k)| {\n        if let Some(b) = T::checked_binomial_coefficient(n, k) {\n            assert_eq!(T::binomial_coefficient(n, k), b);\n        }\n    });\n}\n\nfn checked_binomial_coefficient_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_11::<T, T>().test_properties(|(n, k)| {\n        if let Some(b) = T::checked_binomial_coefficient(n, k) {\n            assert_eq!(T::binomial_coefficient(n, k), b);\n        }\n    });\n}\n\n#[test]\nfn checked_binomial_coefficient_properties() {\n    apply_fn_to_unsigneds!(checked_binomial_coefficient_helper_unsigned);\n    apply_fn_to_signeds!(checked_binomial_coefficient_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/ceiling.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen;\n\nfn ceiling_assign_primitive_float_helper<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(NiceFloat(n.ceiling()), NiceFloat(out));\n\n        let mut n = n;\n        n.ceiling_assign();\n        assert_eq!(NiceFloat(n), NiceFloat(out));\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::NEGATIVE_ZERO, T::NEGATIVE_ZERO);\n    test(T::INFINITY, T::INFINITY);\n    test(T::NEGATIVE_INFINITY, T::NEGATIVE_INFINITY);\n    test(T::NAN, T::NAN);\n    test(T::ONE, T::ONE);\n    test(T::NEGATIVE_ONE, T::NEGATIVE_ONE);\n    test(T::from(1.5f32), T::from(2.0f32));\n    test(T::from(-1.5f32), T::from(-1.0f32));\n}\n\n#[test]\nfn test_ceiling() {\n    apply_fn_to_primitive_floats!(ceiling_assign_primitive_float_helper);\n}\n\nfn ceiling_assign_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|f| {\n        let mut ceiling = f;\n        ceiling.ceiling_assign();\n        assert_eq!(NiceFloat(ceiling), NiceFloat(f.ceiling()));\n        assert_eq!(NiceFloat(ceiling.ceiling()), NiceFloat(ceiling));\n        assert_eq!(NiceFloat(-ceiling), NiceFloat((-f).floor()));\n        assert_eq!(f.sign(), ceiling.sign());\n    });\n}\n\n#[test]\nfn ceiling_assign_properties() {\n    apply_fn_to_primitive_floats!(ceiling_assign_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/checked_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\n\nfn checked_abs_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.checked_abs(), out);\n    };\n    test(T::ZERO, Some(T::ZERO));\n    test(T::ONE, Some(T::ONE));\n    test(T::exact_from(100), Some(T::exact_from(100)));\n    test(T::NEGATIVE_ONE, Some(T::ONE));\n    test(T::exact_from(-100), Some(T::exact_from(100)));\n    test(T::MIN, None);\n}\n\n#[test]\nfn test_checked_abs() {\n    apply_fn_to_signeds!(checked_abs_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/checked_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_checked_add_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: Option<T>) {\n        assert_eq!(x.checked_add_mul(y, z), out);\n    }\n    test::<u8>(2, 3, 7, Some(23));\n    test::<u32>(7, 5, 10, Some(57));\n    test::<u64>(123, 456, 789, Some(359907));\n    test::<i32>(123, -456, 789, Some(-359661));\n    test::<i128>(-123, 456, 789, Some(359661));\n    test::<i8>(127, -2, 100, Some(-73));\n    test::<i8>(-127, 2, 100, Some(73));\n    test::<i8>(-128, 1, 0, Some(-128));\n\n    test::<u8>(2, 20, 20, None);\n    test::<i8>(-127, -2, 100, None);\n    test::<i8>(127, 1, 100, None);\n    test::<i8>(-127, -1, 100, None);\n    test::<i8>(-127, -10, 100, None);\n}\n\nfn checked_add_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let result = x.checked_add_mul(y, z);\n        assert_eq!(x.checked_add_mul(z, y), result);\n        assert_eq!(result.is_none(), x.overflowing_add_mul(y, z).1);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.checked_add_mul(T::ZERO, b), Some(a));\n        assert_eq!(a.checked_add_mul(T::ONE, b), a.checked_add(b));\n        assert_eq!(T::ZERO.checked_add_mul(a, b), a.checked_mul(b));\n        assert_eq!(a.checked_add_mul(b, T::ZERO), Some(a));\n        assert_eq!(a.checked_add_mul(b, T::ONE), a.checked_add(b));\n    });\n}\n\nfn checked_add_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.checked_add_mul(y, z);\n        assert_eq!(x.checked_add_mul(z, y), result);\n        assert_eq!(result.is_none(), x.overflowing_add_mul(y, z).1);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.checked_add_mul(T::ZERO, b), Some(a));\n        assert_eq!(a.checked_add_mul(T::ONE, b), a.checked_add(b));\n        assert_eq!(T::ZERO.checked_add_mul(a, b), a.checked_mul(b));\n        assert_eq!(a.checked_add_mul(b, T::ZERO), Some(a));\n        assert_eq!(a.checked_add_mul(b, T::ONE), a.checked_add(b));\n    });\n}\n\n#[test]\nfn checked_add_mul_properties() {\n    apply_fn_to_unsigneds!(checked_add_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(checked_add_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/checked_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\n\nfn checked_neg_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.checked_neg(), out);\n    };\n    test(T::ZERO, Some(T::ZERO));\n    test(T::ONE, Some(T::NEGATIVE_ONE));\n    test(T::exact_from(100), Some(T::exact_from(-100)));\n    test(T::NEGATIVE_ONE, Some(T::ONE));\n    test(T::exact_from(-100), Some(T::exact_from(100)));\n    test(T::MIN, None);\n}\n\n#[test]\nfn test_checked_neg() {\n    apply_fn_to_signeds!(checked_neg_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/checked_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\n\n#[test]\nfn test_checked_pow() {\n    fn test<T: PrimitiveInt>(x: T, y: u64, out: Option<T>) {\n        assert_eq!(x.checked_pow(y), out);\n    }\n    test::<u8>(0, 0, Some(1));\n    test::<u64>(123, 0, Some(1));\n    test::<u64>(123, 1, Some(123));\n    test::<u16>(0, 123, Some(0));\n    test::<u16>(1, 123, Some(1));\n    test::<i16>(-1, 123, Some(-1));\n    test::<i16>(-1, 124, Some(1));\n    test::<u8>(3, 3, Some(27));\n    test::<i32>(-10, 9, Some(-1000000000));\n    test::<i32>(-10, 10, None);\n    test::<i16>(-10, 9, None);\n    test::<i16>(10, 9, None);\n    test::<i64>(123, 456, None);\n    test::<u64>(0, u64::MAX, Some(0));\n    test::<u64>(1, u64::MAX, Some(1));\n    test::<u64>(123, u64::MAX, None);\n    test::<i64>(0, u64::MAX, Some(0));\n    test::<i64>(1, u64::MAX, Some(1));\n    test::<i64>(-1, u64::MAX, Some(-1));\n    test::<i64>(-1, u64::MAX - 1, Some(1));\n    test::<i64>(123, u64::MAX, None);\n    test::<i64>(-123, u64::MAX, None);\n    test::<i64>(-123, u64::MAX - 1, None);\n}\n\nfn checked_pow_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let power = x.checked_pow(y);\n        if let Some(power) = power {\n            if y != 0 {\n                assert!(power >= x);\n            }\n            assert_eq!(power, x.pow(y));\n        }\n    });\n}\n\nfn checked_pow_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let power = x.checked_pow(y);\n        if let Some(power) = power {\n            assert_eq!(power, x.pow(y));\n        }\n    });\n}\n\n#[test]\nfn checked_pow_properties() {\n    apply_fn_to_unsigneds!(checked_pow_properties_helper_unsigned);\n    apply_fn_to_signeds!(checked_pow_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/checked_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\n#[test]\nfn test_checked_square() {\n    fn test<T: PrimitiveInt>(x: T, out: Option<T>) {\n        assert_eq!(x.checked_square(), out);\n    }\n    test::<u8>(0, Some(0));\n    test::<i16>(1, Some(1));\n    test::<u32>(2, Some(4));\n    test::<i64>(3, Some(9));\n    test::<u128>(10, Some(100));\n    test::<isize>(123, Some(15129));\n    test::<u32>(1000, Some(1000000));\n\n    test::<i16>(-1, Some(1));\n    test::<i32>(-2, Some(4));\n    test::<i64>(-3, Some(9));\n    test::<i128>(-10, Some(100));\n    test::<isize>(-123, Some(15129));\n    test::<i32>(-1000, Some(1000000));\n\n    test::<u16>(1000, None);\n    test::<i16>(-1000, None);\n}\n\nfn unsigned_checked_square_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        let square = x.checked_square();\n        assert_eq!(square, x.checked_pow(2));\n        if let Some(square) = square {\n            assert_eq!(x.square(), square);\n        }\n    });\n}\n\nfn signed_checked_square_properties_helper<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        let square = x.checked_square();\n        assert_eq!(square, x.checked_pow(2));\n        if let Some(square) = square {\n            assert_eq!(x.square(), square);\n        }\n    });\n}\n\n#[test]\nfn checked_square_properties() {\n    apply_fn_to_unsigneds!(unsigned_checked_square_properties_helper);\n    apply_fn_to_signeds!(signed_checked_square_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/checked_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_checked_sub_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: Option<T>) {\n        assert_eq!(x.checked_sub_mul(y, z), out);\n    }\n    test::<u8>(100, 3, 7, Some(79));\n    test::<u32>(60, 5, 10, Some(10));\n    test::<u64>(1000000, 456, 789, Some(640216));\n    test::<i32>(123, -456, 789, Some(359907));\n    test::<i128>(-123, 456, 789, Some(-359907));\n    test::<i8>(127, 2, 100, Some(-73));\n    test::<i8>(-127, -2, 100, Some(73));\n    test::<i8>(-128, 1, 0, Some(-128));\n\n    test::<u8>(2, 10, 5, None);\n    test::<i8>(-127, 2, 100, None);\n    test::<i8>(-127, 1, 100, None);\n    test::<i8>(127, -1, 100, None);\n    test::<i8>(127, -10, 100, None);\n}\n\nfn checked_sub_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let result = x.checked_sub_mul(y, z);\n        assert_eq!(x.checked_sub_mul(z, y), result);\n        assert_eq!(result.is_none(), x.overflowing_sub_mul(y, z).1);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.checked_sub_mul(T::ZERO, b), Some(a));\n        assert_eq!(a.checked_sub_mul(T::ONE, b), a.checked_sub(b));\n        assert_eq!(a.checked_sub_mul(b, T::ZERO), Some(a));\n        assert_eq!(a.checked_sub_mul(b, T::ONE), a.checked_sub(b));\n    });\n}\n\nfn checked_sub_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.checked_sub_mul(y, z);\n        assert_eq!(x.checked_sub_mul(z, y), result);\n        assert_eq!(result.is_none(), x.overflowing_sub_mul(y, z).1);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.checked_sub_mul(T::ZERO, b), Some(a));\n        assert_eq!(a.checked_sub_mul(T::ONE, b), a.checked_sub(b));\n        assert_eq!(a.checked_sub_mul(b, T::ZERO), Some(a));\n        assert_eq!(a.checked_sub_mul(b, T::ONE), a.checked_sub(b));\n    });\n}\n\n#[test]\nfn checked_sub_mul_properties() {\n    apply_fn_to_unsigneds!(checked_sub_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(checked_sub_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/coprime_with.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::coprime_with::{\n    coprime_with_check_2, coprime_with_check_2_3, coprime_with_check_2_3_5,\n};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_coprime_with() {\n    fn test<T: PrimitiveUnsigned>(x: T, y: T, out: bool) {\n        assert_eq!(x.coprime_with(y), out);\n    }\n    test::<u8>(0, 0, false);\n    test::<u8>(0, 1, true);\n    test::<u16>(0, 6, false);\n    test::<u32>(6, 0, false);\n    test::<u64>(1, 6, true);\n    test::<u128>(6, 1, true);\n    test::<usize>(8, 12, false);\n    test::<u8>(54, 24, false);\n    test::<u16>(42, 56, false);\n    test::<u32>(48, 18, false);\n    test::<u64>(3, 5, true);\n    test::<u128>(12, 60, false);\n    test::<usize>(12, 90, false);\n    test::<usize>(25, 14, true);\n}\n\nfn coprime_with_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let c = x.coprime_with(y);\n        assert_eq!(x.gcd(y) == T::ONE, c);\n        assert_eq!(coprime_with_check_2(x, y), c);\n        assert_eq!(coprime_with_check_2_3(x, y), c);\n        assert_eq!(coprime_with_check_2_3_5(x, y), c);\n        assert_eq!(y.coprime_with(x), c);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.coprime_with(x), x == T::ONE);\n        assert!(x.coprime_with(T::ONE));\n        assert_eq!(x.coprime_with(T::ZERO), x == T::ONE);\n        if x != T::MAX {\n            assert!(x.coprime_with(x + T::ONE));\n        }\n    });\n}\n\n#[test]\nfn coprime_with_properties() {\n    apply_fn_to_unsigneds!(coprime_with_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_6, signed_pair_gen_var_3, unsigned_gen, unsigned_gen_var_1,\n    unsigned_pair_gen_var_11,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_div_exact() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.div_exact(y), out);\n\n        let mut x = x;\n        x.div_exact_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 123, 0);\n    test::<u16>(123, 1, 123);\n    test::<u32>(123, 123, 1);\n    test::<usize>(56088, 123, 456);\n    test::<u64>(0, 1000000000000, 0);\n    test::<u128>(1000000000000, 1, 1000000000000);\n    test::<usize>(1000000000000, 1000000000000, 1);\n    test::<usize>(123000000000000, 1000000000000, 123);\n    test::<usize>(123000000000000, 123, 1000000000000);\n    test::<u128>(121932631112635269000000, 123456789000, 987654321000);\n    test::<u64>(0x1fffffffe, 0xffffffff, 2);\n    test::<u64>(18446744065119617025, 0xffffffff, 0xffffffff);\n\n    test::<i8>(0, -123, 0);\n    test::<i16>(123, -1, -123);\n    test::<i32>(123, -123, -1);\n    test::<isize>(56088, -123, -456);\n    test::<i64>(0, -1000000000000, 0);\n    test::<i128>(1000000000000, -1, -1000000000000);\n    test::<isize>(1000000000000, -1000000000000, -1);\n    test::<isize>(123000000000000, -1000000000000, -123);\n    test::<isize>(123000000000000, -123, -1000000000000);\n    test::<i128>(121932631112635269000000, -123456789000, -987654321000);\n    test::<i64>(0x1fffffffe, -0xffffffff, -2);\n    test::<i128>(18446744065119617025, -0xffffffff, -0xffffffff);\n\n    test::<i16>(-123, 1, -123);\n    test::<i32>(-123, 123, -1);\n    test::<isize>(-56088, 123, -456);\n    test::<i128>(-1000000000000, 1, -1000000000000);\n    test::<isize>(-1000000000000, 1000000000000, -1);\n    test::<isize>(-123000000000000, 1000000000000, -123);\n    test::<isize>(-123000000000000, 123, -1000000000000);\n    test::<i128>(-121932631112635269000000, 123456789000, -987654321000);\n    test::<i64>(-0x1fffffffe, 0xffffffff, -2);\n    test::<i128>(-18446744065119617025, 0xffffffff, -0xffffffff);\n\n    test::<i16>(-123, -1, 123);\n    test::<i32>(-123, -123, 1);\n    test::<isize>(-56088, -123, 456);\n    test::<i128>(-1000000000000, -1, 1000000000000);\n    test::<isize>(-1000000000000, -1000000000000, 1);\n    test::<isize>(-123000000000000, -1000000000000, 123);\n    test::<isize>(-123000000000000, -123, 1000000000000);\n    test::<i128>(-121932631112635269000000, -123456789000, 987654321000);\n    test::<i64>(-0x1fffffffe, -0xffffffff, 2);\n    test::<i128>(-18446744065119617025, -0xffffffff, 0xffffffff);\n}\n\nfn div_exact_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::ONE.div_exact(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.div_exact_assign(T::ZERO);\n    });\n}\n\n#[test]\npub fn div_exact_fail() {\n    apply_fn_to_primitive_ints!(div_exact_fail_helper);\n}\n\nfn div_exact_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_11::<T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        mut_x.div_exact_assign(y);\n        let q = mut_x;\n\n        assert_eq!(x.div_exact(y), q);\n        assert_eq!(x.div_round(y, Exact).0, q);\n        assert_eq!(q * y, x);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.div_exact(T::ONE), x);\n        assert_panic!(x.div_exact(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.div_exact_assign(T::ZERO);\n        });\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|x| {\n        assert_eq!(T::ZERO.div_exact(x), T::ZERO);\n        assert_eq!(x.div_exact(x), T::ONE);\n    });\n}\n\nfn div_exact_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_3::<T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        mut_x.div_exact_assign(y);\n        let q = mut_x;\n\n        assert_eq!(x.div_exact(y), q);\n        assert_eq!(x.div_round(y, Exact).0, q);\n        assert_eq!(q * y, x);\n\n        if x != T::MIN {\n            assert_eq!((-x).div_exact(y), -q);\n        }\n        if y != T::MIN && q != T::MIN {\n            assert_eq!(x.div_exact(-y), -q);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.div_exact(T::ONE), x);\n        assert_panic!(x.div_exact(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.div_exact_assign(T::ZERO);\n        });\n    });\n\n    signed_gen_var_6::<T>().test_properties(|x| {\n        assert_eq!(T::ZERO.div_exact(x), T::ZERO);\n        assert_eq!(x.div_exact(x), T::ONE);\n    });\n}\n\n#[test]\nfn div_exact_properties() {\n    apply_fn_to_unsigneds!(div_exact_properties_helper_unsigned);\n    apply_fn_to_signeds!(div_exact_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_6, signed_pair_gen_var_4, unsigned_gen, unsigned_gen_var_1,\n    unsigned_pair_gen_var_12,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_div_mod_and_div_rem_unsigned() {\n    fn test<T: PrimitiveUnsigned>(n: T, d: T, q: T, r: T) {\n        assert_eq!(n.div_mod(d), (q, r));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.div_assign_mod(d), r);\n        assert_eq!(mut_n, q);\n\n        assert_eq!(n.div_rem(d), (q, r));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.div_assign_rem(d), r);\n        assert_eq!(mut_n, q);\n    }\n    test::<u8>(0, 1, 0, 0);\n    test::<u16>(0, 123, 0, 0);\n    test::<u32>(1, 1, 1, 0);\n    test::<u64>(123, 1, 123, 0);\n    test::<usize>(123, 123, 1, 0);\n    test::<u128>(123, 456, 0, 123);\n    test::<u16>(456, 123, 3, 87);\n    test::<u32>(u32::MAX, 1, u32::MAX, 0);\n    test::<usize>(0xffffffff, 0xffffffff, 1, 0);\n    test::<u64>(1000000000000, 1, 1000000000000, 0);\n    test::<u64>(1000000000000, 3, 333333333333, 1);\n    test::<u64>(1000000000000, 123, 8130081300, 100);\n    test::<u64>(1000000000000, 0xffffffff, 232, 3567587560);\n    test::<u128>(1000000000000000000000000, 1, 1000000000000000000000000, 0);\n    test::<u128>(1000000000000000000000000, 3, 333333333333333333333333, 1);\n    test::<u128>(1000000000000000000000000, 123, 8130081300813008130081, 37);\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        232830643708079,\n        3167723695,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1234567890987,\n        810000006723,\n        530068894399,\n    );\n    test::<u128>(\n        253640751230376270397812803167,\n        2669936877441,\n        94998781946290113,\n        1520301762334,\n    );\n    test::<u64>(3768477692975601, 11447376614057827956, 0, 3768477692975601);\n    test::<u64>(3356605361737854, 3081095617839357, 1, 275509743898497);\n    test::<u128>(\n        1098730198198174614195,\n        953382298040157850476,\n        1,\n        145347900158016763719,\n    );\n    test::<u128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<u128>(1000000000000000000000000, 1000000000000000000000000, 1, 0);\n    test::<u128>(0, 1000000000000000000000000, 0, 0);\n    test::<u128>(123, 1000000000000000000000000, 0, 123);\n}\n\nfn div_mod_and_div_rem_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        let r = mut_x.div_assign_mod(y);\n        let q = mut_x;\n\n        assert_eq!(x.div_mod(y), (q, r));\n\n        let mut mut_x = x;\n        let r_alt = mut_x.div_assign_rem(y);\n        let q_alt = mut_x;\n        assert_eq!((q_alt, r_alt), (q, r));\n\n        assert_eq!(x.div_rem(y), (q, r));\n\n        assert_eq!((x / y, x % y), (q, r));\n        assert!(r < y);\n        assert_eq!(q * y + r, x);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.div_mod(T::ONE), (x, T::ZERO));\n        assert_panic!(x.div_mod(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.div_assign_mod(T::ZERO)\n        });\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|x| {\n        assert_eq!(x.div_mod(x), (T::ONE, T::ZERO));\n        assert_eq!(T::ZERO.div_mod(x), (T::ZERO, T::ZERO));\n        if x > T::ONE {\n            assert_eq!(T::ONE.div_mod(x), (T::ZERO, T::ONE));\n        }\n    });\n}\n\n#[test]\nfn test_div_mod_signed() {\n    fn test<T: PrimitiveSigned>(n: T, d: T, q: T, r: T) {\n        assert_eq!(n.div_mod(d), (q, r));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.div_assign_mod(d), r);\n        assert_eq!(mut_n, q);\n    }\n    test::<i8>(0, 1, 0, 0);\n    test::<i16>(0, 123, 0, 0);\n    test::<i32>(1, 1, 1, 0);\n    test::<i64>(123, 1, 123, 0);\n    test::<i128>(123, 123, 1, 0);\n    test::<isize>(123, 456, 0, 123);\n    test::<i16>(456, 123, 3, 87);\n    test::<i64>(0xffffffff, 1, 0xffffffff, 0);\n    test::<i64>(0xffffffff, 0xffffffff, 1, 0);\n    test::<i64>(1000000000000, 1, 1000000000000, 0);\n    test::<i64>(1000000000000, 3, 333333333333, 1);\n    test::<i64>(1000000000000, 123, 8130081300, 100);\n    test::<i64>(1000000000000, 0xffffffff, 232, 3567587560);\n    test::<i128>(1000000000000000000000000, 1, 1000000000000000000000000, 0);\n    test::<i128>(1000000000000000000000000, 3, 333333333333333333333333, 1);\n    test::<i128>(1000000000000000000000000, 123, 8130081300813008130081, 37);\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        232830643708079,\n        3167723695,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1234567890987,\n        810000006723,\n        530068894399,\n    );\n    test::<i128>(\n        253640751230376270397812803167,\n        2669936877441,\n        94998781946290113,\n        1520301762334,\n    );\n    test::<i128>(3768477692975601, 11447376614057827956, 0, 3768477692975601);\n    test::<i64>(3356605361737854, 3081095617839357, 1, 275509743898497);\n    test::<i128>(\n        1098730198198174614195,\n        953382298040157850476,\n        1,\n        145347900158016763719,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, 1000000000000000000000000, 1, 0);\n    test::<i128>(0, 1000000000000000000000000, 0, 0);\n    test::<i128>(123, 1000000000000000000000000, 0, 123);\n\n    test::<i8>(0, -1, 0, 0);\n    test::<i16>(0, -123, 0, 0);\n    test::<i32>(1, -1, -1, 0);\n    test::<i64>(123, -1, -123, 0);\n    test::<i128>(123, -123, -1, 0);\n    test::<isize>(123, -456, -1, -333);\n    test::<i16>(456, -123, -4, -36);\n    test::<i64>(0xffffffff, -1, -0xffffffff, 0);\n    test::<i64>(0xffffffff, -0xffffffff, -1, 0);\n    test::<i64>(1000000000000, -1, -1000000000000, 0);\n    test::<i64>(1000000000000, -3, -333333333334, -2);\n    test::<i64>(1000000000000, -123, -8130081301, -23);\n    test::<i64>(1000000000000, -0xffffffff, -233, -727379735);\n    test::<i128>(1000000000000000000000000, -1, -1000000000000000000000000, 0);\n    test::<i128>(1000000000000000000000000, -3, -333333333333333333333334, -2);\n    test::<i128>(\n        1000000000000000000000000,\n        -123,\n        -8130081300813008130082,\n        -86,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        -232830643708080,\n        -1127243600,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1234567890987,\n        -810000006724,\n        -704498996588,\n    );\n    test::<i128>(\n        253640751230376270397812803167,\n        -2669936877441,\n        -94998781946290114,\n        -1149635115107,\n    );\n    test::<i128>(\n        3768477692975601,\n        -11447376614057827956,\n        -1,\n        -11443608136364852355,\n    );\n    test::<i64>(3356605361737854, -3081095617839357, -2, -2805585873940860);\n    test::<i128>(\n        1098730198198174614195,\n        -953382298040157850476,\n        -2,\n        -808034397882141086757,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        -69738658860594537152875081748,\n        -1,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, -1000000000000000000000000, -1, 0);\n    test::<i128>(0, -1000000000000000000000000, 0, 0);\n    test::<i128>(\n        123,\n        -1000000000000000000000000,\n        -1,\n        -999999999999999999999877,\n    );\n\n    test::<i8>(-1, 1, -1, 0);\n    test::<i16>(-123, 1, -123, 0);\n    test::<i32>(-123, 123, -1, 0);\n    test::<i64>(-123, 456, -1, 333);\n    test::<isize>(-456, 123, -4, 36);\n    test::<i64>(-0xffffffff, -1, 0xffffffff, 0);\n    test::<i64>(-0xffffffff, 0xffffffff, -1, 0);\n    test::<i64>(-1000000000000, 1, -1000000000000, 0);\n    test::<i64>(-1000000000000, 3, -333333333334, 2);\n    test::<i64>(-1000000000000, 123, -8130081301, 23);\n    test::<i64>(-1000000000000, 0xffffffff, -233, 727379735);\n    test::<i128>(-1000000000000000000000000, 1, -1000000000000000000000000, 0);\n    test::<i128>(-1000000000000000000000000, 3, -333333333333333333333334, 2);\n    test::<i128>(-1000000000000000000000000, 123, -8130081300813008130082, 86);\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        -232830643708080,\n        1127243600,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1234567890987,\n        -810000006724,\n        704498996588,\n    );\n    test::<i128>(\n        -253640751230376270397812803167,\n        2669936877441,\n        -94998781946290114,\n        1149635115107,\n    );\n    test::<i128>(\n        -3768477692975601,\n        11447376614057827956,\n        -1,\n        11443608136364852355,\n    );\n    test::<i64>(-3356605361737854, 3081095617839357, -2, 2805585873940860);\n    test::<i128>(\n        -1098730198198174614195,\n        953382298040157850476,\n        -2,\n        808034397882141086757,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        69738658860594537152875081748,\n        -1,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, 1000000000000000000000000, -1, 0);\n    test::<i128>(\n        -123,\n        1000000000000000000000000,\n        -1,\n        999999999999999999999877,\n    );\n\n    test::<i8>(-1, -1, 1, 0);\n    test::<i16>(-123, -1, 123, 0);\n    test::<i32>(-123, -123, 1, 0);\n    test::<i64>(-123, -456, 0, -123);\n    test::<isize>(-456, -123, 3, -87);\n    test::<i128>(-0xffffffff, -1, 0xffffffff, 0);\n    test::<i64>(-0xffffffff, -0xffffffff, 1, 0);\n    test::<i64>(-1000000000000, -1, 1000000000000, 0);\n    test::<i64>(-1000000000000, -3, 333333333333, -1);\n    test::<i64>(-1000000000000, -123, 8130081300, -100);\n    test::<i64>(-1000000000000, -0xffffffff, 232, -3567587560);\n    test::<i128>(-1000000000000000000000000, -1, 1000000000000000000000000, 0);\n    test::<i128>(-1000000000000000000000000, -3, 333333333333333333333333, -1);\n    test::<i128>(\n        -1000000000000000000000000,\n        -123,\n        8130081300813008130081,\n        -37,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        232830643708079,\n        -3167723695,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1234567890987,\n        810000006723,\n        -530068894399,\n    );\n    test::<i128>(\n        -253640751230376270397812803167,\n        -2669936877441,\n        94998781946290113,\n        -1520301762334,\n    );\n    test::<i128>(\n        -3768477692975601,\n        -11447376614057827956,\n        0,\n        -3768477692975601,\n    );\n    test::<i64>(-3356605361737854, -3081095617839357, 1, -275509743898497);\n    test::<i128>(\n        -1098730198198174614195,\n        -953382298040157850476,\n        1,\n        -145347900158016763719,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        -69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, -1000000000000000000000000, 1, 0);\n    test::<i128>(-123, -1000000000000000000000000, 0, -123);\n}\n\nfn div_mod_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::ONE.div_mod(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.div_assign_mod(T::ZERO);\n    });\n}\n\nfn div_mod_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::MIN.div_mod(T::NEGATIVE_ONE));\n    assert_panic!({\n        let mut n = T::MIN;\n        n.div_assign_mod(T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\npub fn div_mod_fail() {\n    apply_fn_to_primitive_ints!(div_mod_fail_helper);\n    apply_fn_to_signeds!(div_mod_signed_fail_helper);\n}\n\nfn div_mod_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_4::<T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        let r = mut_x.div_assign_mod(y);\n        let q = mut_x;\n\n        assert_eq!(x.div_mod(y), (q, r));\n\n        let (q_alt, r_alt) = (x.div_round(y, Floor).0, x.mod_op(y));\n        assert_eq!(q_alt, q);\n        assert_eq!(r_alt, r);\n\n        assert!(r.lt_abs(&y));\n        assert!(r == T::ZERO || (r > T::ZERO) == (y > T::ZERO));\n        if let Some(product) = q.checked_mul(y) {\n            assert_eq!(product + r, x);\n        } else if q > T::ZERO {\n            assert_eq!((q - T::ONE) * y + r + y, x);\n        } else {\n            assert_eq!((q + T::ONE) * y + r - y, x);\n        }\n        if x != T::MIN {\n            let (neg_q, neg_r) = (-x).div_mod(y);\n            assert_eq!(x.ceiling_div_mod(y), (-neg_q, -neg_r));\n        }\n        if y != T::MIN && (x != T::MIN || y != T::ONE) {\n            let (neg_q, r) = x.div_mod(-y);\n            assert_eq!(x.ceiling_div_mod(y), (-neg_q, r));\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        let (q, r) = x.div_mod(T::ONE);\n        assert_eq!(q, x);\n        assert_eq!(r, T::ZERO);\n\n        if x != T::MIN {\n            let (q, r) = x.div_mod(T::NEGATIVE_ONE);\n            assert_eq!(q, -x);\n            assert_eq!(r, T::ZERO);\n        }\n        assert_panic!(x.div_mod(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.div_assign_mod(T::ZERO)\n        });\n    });\n\n    signed_gen_var_6::<T>().test_properties(|x| {\n        assert_eq!(x.div_mod(T::ONE), (x, T::ZERO));\n        assert_eq!(x.div_mod(x), (T::ONE, T::ZERO));\n        assert_eq!(T::ZERO.div_mod(x), (T::ZERO, T::ZERO));\n        if x != T::MIN {\n            assert_eq!(x.div_mod(T::NEGATIVE_ONE), (-x, T::ZERO));\n            assert_eq!(x.div_mod(-x), (T::NEGATIVE_ONE, T::ZERO));\n        }\n        if x > T::ONE {\n            assert_eq!(T::ONE.div_mod(x), (T::ZERO, T::ONE));\n            assert_eq!(T::NEGATIVE_ONE.div_mod(x), (T::NEGATIVE_ONE, x - T::ONE));\n        }\n    });\n}\n\n#[test]\nfn div_mod_properties() {\n    apply_fn_to_unsigneds!(div_mod_and_div_rem_properties_helper_unsigned);\n    apply_fn_to_signeds!(div_mod_properties_helper_signed);\n}\n\n#[test]\nfn test_div_rem_signed() {\n    fn test<T: PrimitiveSigned>(n: T, d: T, q: T, r: T) {\n        assert_eq!(n.div_rem(d), (q, r));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.div_assign_rem(d), r);\n        assert_eq!(mut_n, q);\n    }\n    test::<i8>(0, 1, 0, 0);\n    test::<i16>(0, 123, 0, 0);\n    test::<i32>(1, 1, 1, 0);\n    test::<i64>(123, 1, 123, 0);\n    test::<i128>(123, 123, 1, 0);\n    test::<isize>(123, 456, 0, 123);\n    test::<i16>(456, 123, 3, 87);\n    test::<i64>(0xffffffff, 1, 0xffffffff, 0);\n    test::<i64>(0xffffffff, 0xffffffff, 1, 0);\n    test::<i64>(1000000000000, 1, 1000000000000, 0);\n    test::<i64>(1000000000000, 3, 333333333333, 1);\n    test::<i64>(1000000000000, 123, 8130081300, 100);\n    test::<i64>(1000000000000, 0xffffffff, 232, 3567587560);\n    test::<i128>(1000000000000000000000000, 1, 1000000000000000000000000, 0);\n    test::<i128>(1000000000000000000000000, 3, 333333333333333333333333, 1);\n    test::<i128>(1000000000000000000000000, 123, 8130081300813008130081, 37);\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        232830643708079,\n        3167723695,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1234567890987,\n        810000006723,\n        530068894399,\n    );\n    test::<i128>(\n        253640751230376270397812803167,\n        2669936877441,\n        94998781946290113,\n        1520301762334,\n    );\n    test::<i128>(3768477692975601, 11447376614057827956, 0, 3768477692975601);\n    test::<i64>(3356605361737854, 3081095617839357, 1, 275509743898497);\n    test::<i128>(\n        1098730198198174614195,\n        953382298040157850476,\n        1,\n        145347900158016763719,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, 1000000000000000000000000, 1, 0);\n    test::<i128>(0, 1000000000000000000000000, 0, 0);\n    test::<i128>(123, 1000000000000000000000000, 0, 123);\n\n    test::<i8>(0, -1, 0, 0);\n    test::<i16>(0, -123, 0, 0);\n    test::<i32>(1, -1, -1, 0);\n    test::<i64>(123, -1, -123, 0);\n    test::<i128>(123, -123, -1, 0);\n    test::<isize>(123, -456, 0, 123);\n    test::<i16>(456, -123, -3, 87);\n    test::<i64>(0xffffffff, -1, -0xffffffff, 0);\n    test::<i64>(0xffffffff, -0xffffffff, -1, 0);\n    test::<i64>(1000000000000, -1, -1000000000000, 0);\n    test::<i64>(1000000000000, -3, -333333333333, 1);\n    test::<i64>(1000000000000, -123, -8130081300, 100);\n    test::<i64>(1000000000000, -0xffffffff, -232, 3567587560);\n    test::<i128>(1000000000000000000000000, -1, -1000000000000000000000000, 0);\n    test::<i128>(1000000000000000000000000, -3, -333333333333333333333333, 1);\n    test::<i128>(1000000000000000000000000, -123, -8130081300813008130081, 37);\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        -232830643708079,\n        3167723695,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1234567890987,\n        -810000006723,\n        530068894399,\n    );\n    test::<i128>(\n        253640751230376270397812803167,\n        -2669936877441,\n        -94998781946290113,\n        1520301762334,\n    );\n    test::<i128>(3768477692975601, -11447376614057827956, 0, 3768477692975601);\n    test::<i64>(3356605361737854, -3081095617839357, -1, 275509743898497);\n    test::<i128>(\n        1098730198198174614195,\n        -953382298040157850476,\n        -1,\n        145347900158016763719,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        -69738658860594537152875081748,\n        -1,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, -1000000000000000000000000, -1, 0);\n    test::<i128>(0, -1000000000000000000000000, 0, 0);\n    test::<i128>(123, -1000000000000000000000000, 0, 123);\n\n    test::<i8>(-1, 1, -1, 0);\n    test::<i16>(-123, 1, -123, 0);\n    test::<i32>(-123, 123, -1, 0);\n    test::<i64>(-123, 456, 0, -123);\n    test::<isize>(-456, 123, -3, -87);\n    test::<i64>(-0xffffffff, 1, -0xffffffff, 0);\n    test::<i64>(-0xffffffff, 0xffffffff, -1, 0);\n    test::<i64>(-1000000000000, 1, -1000000000000, 0);\n    test::<i64>(-1000000000000, 3, -333333333333, -1);\n    test::<i64>(-1000000000000, 123, -8130081300, -100);\n    test::<i64>(-1000000000000, 0xffffffff, -232, -3567587560);\n    test::<i128>(-1000000000000000000000000, 1, -1000000000000000000000000, 0);\n    test::<i128>(-1000000000000000000000000, 3, -333333333333333333333333, -1);\n    test::<i128>(\n        -1000000000000000000000000,\n        123,\n        -8130081300813008130081,\n        -37,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        -232830643708079,\n        -3167723695,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1234567890987,\n        -810000006723,\n        -530068894399,\n    );\n    test::<i128>(\n        -253640751230376270397812803167,\n        2669936877441,\n        -94998781946290113,\n        -1520301762334,\n    );\n    test::<i128>(\n        -3768477692975601,\n        11447376614057827956,\n        0,\n        -3768477692975601,\n    );\n    test::<i64>(-3356605361737854, 3081095617839357, -1, -275509743898497);\n    test::<i128>(\n        -1098730198198174614195,\n        953382298040157850476,\n        -1,\n        -145347900158016763719,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        69738658860594537152875081748,\n        -1,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, 1000000000000000000000000, -1, 0);\n    test::<i128>(-123, 1000000000000000000000000, 0, -123);\n\n    test::<i8>(-1, -1, 1, 0);\n    test::<i16>(-123, -1, 123, 0);\n    test::<i32>(-123, -123, 1, 0);\n    test::<i64>(-123, -456, 0, -123);\n    test::<isize>(-456, -123, 3, -87);\n    test::<i64>(-0xffffffff, -1, 0xffffffff, 0);\n    test::<i64>(-0xffffffff, -0xffffffff, 1, 0);\n    test::<i64>(-1000000000000, -1, 1000000000000, 0);\n    test::<i64>(-1000000000000, -3, 333333333333, -1);\n    test::<i64>(-1000000000000, -123, 8130081300, -100);\n    test::<i64>(-1000000000000, -0xffffffff, 232, -3567587560);\n    test::<i128>(-1000000000000000000000000, -1, 1000000000000000000000000, 0);\n    test::<i128>(-1000000000000000000000000, -3, 333333333333333333333333, -1);\n    test::<i128>(\n        -1000000000000000000000000,\n        -123,\n        8130081300813008130081,\n        -37,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        232830643708079,\n        -3167723695,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1234567890987,\n        810000006723,\n        -530068894399,\n    );\n    test::<i128>(\n        -253640751230376270397812803167,\n        -2669936877441,\n        94998781946290113,\n        -1520301762334,\n    );\n    test::<i128>(\n        -3768477692975601,\n        -11447376614057827956,\n        0,\n        -3768477692975601,\n    );\n    test::<i64>(-3356605361737854, -3081095617839357, 1, -275509743898497);\n    test::<i128>(\n        -1098730198198174614195,\n        -953382298040157850476,\n        1,\n        -145347900158016763719,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        -69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, -1000000000000000000000000, 1, 0);\n    test::<i128>(-123, -1000000000000000000000000, 0, -123);\n}\n\nfn div_rem_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::ONE.div_rem(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.div_assign_rem(T::ZERO);\n    });\n}\n\nfn div_rem_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::MIN.div_rem(T::NEGATIVE_ONE));\n    assert_panic!({\n        let mut n = T::MIN;\n        n.div_assign_rem(T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\npub fn div_rem_fail() {\n    apply_fn_to_primitive_ints!(div_rem_fail_helper);\n    apply_fn_to_signeds!(div_rem_signed_fail_helper);\n}\n\nfn div_rem_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_4::<T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        let r = mut_x.div_assign_rem(y);\n        let q = mut_x;\n\n        assert_eq!(x.div_rem(y), (q, r));\n\n        assert_eq!((x / y, x % y), (q, r));\n\n        assert!(r.lt_abs(&y));\n        assert!(r == T::ZERO || (r > T::ZERO) == (x > T::ZERO));\n        assert_eq!(q * y + r, x);\n\n        if x != T::MIN {\n            assert_eq!((-x).div_rem(y), (-q, -r));\n        }\n        if y != T::MIN && (x != T::MIN || y != T::ONE) {\n            assert_eq!(x.div_rem(-y), (-q, r));\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        let (q, r) = x.div_rem(T::ONE);\n        assert_eq!(q, x);\n        assert_eq!(r, T::ZERO);\n\n        if x != T::MIN {\n            let (q, r) = x.div_rem(T::NEGATIVE_ONE);\n            assert_eq!(q, -x);\n            assert_eq!(r, T::ZERO);\n        }\n        assert_panic!(x.div_rem(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.div_assign_rem(T::ZERO)\n        });\n    });\n\n    signed_gen_var_6::<T>().test_properties(|x| {\n        assert_eq!(x.div_rem(T::ONE), (x, T::ZERO));\n        assert_eq!(x.div_rem(x), (T::ONE, T::ZERO));\n        assert_eq!(T::ZERO.div_rem(x), (T::ZERO, T::ZERO));\n        if x != T::MIN {\n            assert_eq!(x.div_rem(T::NEGATIVE_ONE), (-x, T::ZERO));\n            assert_eq!(x.div_rem(-x), (T::NEGATIVE_ONE, T::ZERO));\n        }\n        if x > T::ONE {\n            assert_eq!(T::ONE.div_rem(x), (T::ZERO, T::ONE));\n            assert_eq!(T::NEGATIVE_ONE.div_rem(x), (T::ZERO, T::NEGATIVE_ONE));\n        }\n    });\n}\n\n#[test]\nfn div_rem_properties() {\n    apply_fn_to_signeds!(div_rem_properties_helper_signed);\n}\n\n#[test]\nfn test_ceiling_div_neg_mod() {\n    fn test<T: PrimitiveUnsigned>(n: T, d: T, q: T, r: T) {\n        assert_eq!(n.ceiling_div_neg_mod(d), (q, r));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.ceiling_div_assign_neg_mod(d), r);\n        assert_eq!(mut_n, q);\n    }\n    test::<u8>(0, 1, 0, 0);\n    test::<u16>(0, 123, 0, 0);\n    test::<u32>(1, 1, 1, 0);\n    test::<u64>(123, 1, 123, 0);\n    test::<u128>(123, 123, 1, 0);\n    test::<usize>(123, 456, 1, 333);\n    test::<u16>(456, 123, 4, 36);\n    test::<u64>(0xffffffff, 1, 0xffffffff, 0);\n    test::<u64>(0xffffffff, 0xffffffff, 1, 0);\n    test::<u64>(1000000000000, 1, 1000000000000, 0);\n    test::<u64>(1000000000000, 3, 333333333334, 2);\n    test::<u64>(1000000000000, 123, 8130081301, 23);\n    test::<u64>(1000000000000, 0xffffffff, 233, 727379735);\n    test::<u128>(1000000000000000000000000, 1, 1000000000000000000000000, 0);\n    test::<u128>(1000000000000000000000000, 3, 333333333333333333333334, 2);\n    test::<u128>(1000000000000000000000000, 123, 8130081300813008130082, 86);\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        232830643708080,\n        1127243600,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1234567890987,\n        810000006724,\n        704498996588,\n    );\n    test::<u128>(\n        253640751230376270397812803167,\n        2669936877441,\n        94998781946290114,\n        1149635115107,\n    );\n    test::<u64>(\n        3768477692975601,\n        11447376614057827956,\n        1,\n        11443608136364852355,\n    );\n    test::<u64>(3356605361737854, 3081095617839357, 2, 2805585873940860);\n    test::<u128>(\n        1098730198198174614195,\n        953382298040157850476,\n        2,\n        808034397882141086757,\n    );\n    test::<u128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<u128>(1000000000000000000000000, 1000000000000000000000000, 1, 0);\n    test::<u128>(0, 1000000000000000000000000, 0, 0);\n    test::<u128>(123, 1000000000000000000000000, 1, 999999999999999999999877);\n}\n\nfn ceiling_div_neg_mod_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.ceiling_div_neg_mod(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.ceiling_div_assign_neg_mod(T::ZERO);\n    });\n}\n\n#[test]\npub fn ceiling_div_neg_mod_fail() {\n    apply_fn_to_unsigneds!(ceiling_div_neg_mod_fail_helper);\n}\n\nfn ceiling_div_neg_mod_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        let r = mut_x.ceiling_div_assign_neg_mod(y);\n        let q = mut_x;\n\n        assert_eq!(x.ceiling_div_neg_mod(y), (q, r));\n\n        let (q_alt, r_alt) = (x.div_round(y, Ceiling).0, x.neg_mod(y));\n        assert_eq!(q_alt, q);\n        assert_eq!(r_alt, r);\n\n        assert!(r < y);\n        if let Some(product) = q.checked_mul(y) {\n            assert_eq!(product - r, x);\n        } else {\n            assert_eq!((q - T::ONE) * y - r + y, x);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.ceiling_div_neg_mod(T::ONE), (x, T::ZERO));\n        assert_panic!(x.ceiling_div_neg_mod(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.ceiling_div_assign_neg_mod(T::ZERO)\n        });\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|x| {\n        assert_eq!(x.ceiling_div_neg_mod(x), (T::ONE, T::ZERO));\n        assert_eq!(T::ZERO.ceiling_div_neg_mod(x), (T::ZERO, T::ZERO));\n        if x > T::ONE {\n            assert_eq!(T::ONE.ceiling_div_neg_mod(x), (T::ONE, x - T::ONE));\n        }\n    });\n}\n\n#[test]\nfn ceiling_div_neg_mod_properties() {\n    apply_fn_to_unsigneds!(ceiling_div_neg_mod_properties_helper);\n}\n\n#[test]\nfn test_ceiling_div_mod() {\n    fn test<T: PrimitiveSigned>(n: T, d: T, q: T, r: T) {\n        assert_eq!(n.ceiling_div_mod(d), (q, r));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.ceiling_div_assign_mod(d), r);\n        assert_eq!(mut_n, q);\n    }\n    test::<i8>(0, 1, 0, 0);\n    test::<i16>(0, 123, 0, 0);\n    test::<i32>(1, 1, 1, 0);\n    test::<i64>(123, 1, 123, 0);\n    test::<i128>(123, 123, 1, 0);\n    test::<isize>(123, 456, 1, -333);\n    test::<i16>(456, 123, 4, -36);\n    test::<i64>(0xffffffff, 1, 0xffffffff, 0);\n    test::<i64>(0xffffffff, 0xffffffff, 1, 0);\n    test::<i64>(1000000000000, 1, 1000000000000, 0);\n    test::<i64>(1000000000000, 3, 333333333334, -2);\n    test::<i64>(1000000000000, 123, 8130081301, -23);\n    test::<i64>(1000000000000, 0xffffffff, 233, -727379735);\n    test::<i128>(1000000000000000000000000, 1, 1000000000000000000000000, 0);\n    test::<i128>(1000000000000000000000000, 3, 333333333333333333333334, -2);\n    test::<i128>(1000000000000000000000000, 123, 8130081300813008130082, -86);\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        232830643708080,\n        -1127243600,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1234567890987,\n        810000006724,\n        -704498996588,\n    );\n    test::<i128>(\n        253640751230376270397812803167,\n        2669936877441,\n        94998781946290114,\n        -1149635115107,\n    );\n    test::<i128>(\n        3768477692975601,\n        11447376614057827956,\n        1,\n        -11443608136364852355,\n    );\n    test::<i64>(3356605361737854, 3081095617839357, 2, -2805585873940860);\n    test::<i128>(\n        1098730198198174614195,\n        953382298040157850476,\n        2,\n        -808034397882141086757,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, 1000000000000000000000000, 1, 0);\n    test::<i128>(0, 1000000000000000000000000, 0, 0);\n    test::<i128>(123, 1000000000000000000000000, 1, -999999999999999999999877);\n\n    test::<i8>(0, -1, 0, 0);\n    test::<i16>(0, -123, 0, 0);\n    test::<i32>(1, -1, -1, 0);\n    test::<i64>(123, -1, -123, 0);\n    test::<i128>(123, -123, -1, 0);\n    test::<isize>(123, -456, 0, 123);\n    test::<i16>(456, -123, -3, 87);\n    test::<i64>(0xffffffff, -1, -0xffffffff, 0);\n    test::<i64>(0xffffffff, -0xffffffff, -1, 0);\n    test::<i64>(1000000000000, -1, -1000000000000, 0);\n    test::<i64>(1000000000000, -3, -333333333333, 1);\n    test::<i64>(1000000000000, -123, -8130081300, 100);\n    test::<i64>(1000000000000, -0xffffffff, -232, 3567587560);\n    test::<i128>(1000000000000000000000000, -1, -1000000000000000000000000, 0);\n    test::<i128>(1000000000000000000000000, -3, -333333333333333333333333, 1);\n    test::<i128>(1000000000000000000000000, -123, -8130081300813008130081, 37);\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        -232830643708079,\n        3167723695,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1234567890987,\n        -810000006723,\n        530068894399,\n    );\n    test::<i128>(\n        253640751230376270397812803167,\n        -2669936877441,\n        -94998781946290113,\n        1520301762334,\n    );\n    test::<i128>(3768477692975601, -11447376614057827956, 0, 3768477692975601);\n    test::<i64>(3356605361737854, -3081095617839357, -1, 275509743898497);\n    test::<i128>(\n        1098730198198174614195,\n        -953382298040157850476,\n        -1,\n        145347900158016763719,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        -69738658860594537152875081748,\n        -1,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, -1000000000000000000000000, -1, 0);\n    test::<i128>(0, -1000000000000000000000000, 0, 0);\n    test::<i128>(123, -1000000000000000000000000, 0, 123);\n\n    test::<i8>(-1, 1, -1, 0);\n    test::<i16>(-123, 1, -123, 0);\n    test::<i32>(-123, 123, -1, 0);\n    test::<i64>(-123, 456, 0, -123);\n    test::<i128>(-456, 123, -3, -87);\n    test::<isize>(-0xffffffff, 1, -0xffffffff, 0);\n    test::<i64>(-0xffffffff, 0xffffffff, -1, 0);\n    test::<i64>(-1000000000000, 1, -1000000000000, 0);\n    test::<i64>(-1000000000000, 3, -333333333333, -1);\n    test::<i64>(-1000000000000, 123, -8130081300, -100);\n    test::<i64>(-1000000000000, 0xffffffff, -232, -3567587560);\n    test::<i128>(-1000000000000000000000000, 1, -1000000000000000000000000, 0);\n    test::<i128>(-1000000000000000000000000, 3, -333333333333333333333333, -1);\n    test::<i128>(\n        -1000000000000000000000000,\n        123,\n        -8130081300813008130081,\n        -37,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        -232830643708079,\n        -3167723695,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1234567890987,\n        -810000006723,\n        -530068894399,\n    );\n    test::<i128>(\n        -253640751230376270397812803167,\n        2669936877441,\n        -94998781946290113,\n        -1520301762334,\n    );\n    test::<i128>(\n        -3768477692975601,\n        11447376614057827956,\n        0,\n        -3768477692975601,\n    );\n    test::<i64>(-3356605361737854, 3081095617839357, -1, -275509743898497);\n    test::<i128>(\n        -1098730198198174614195,\n        953382298040157850476,\n        -1,\n        -145347900158016763719,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        69738658860594537152875081748,\n        -1,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, 1000000000000000000000000, -1, 0);\n    test::<i128>(0, 1000000000000000000000000, 0, 0);\n    test::<i128>(-123, 1000000000000000000000000, 0, -123);\n\n    test::<i8>(-1, -1, 1, 0);\n    test::<i16>(-123, -1, 123, 0);\n    test::<i32>(-123, -123, 1, 0);\n    test::<i64>(-123, -456, 1, 333);\n    test::<i128>(-456, -123, 4, 36);\n    test::<isize>(-0xffffffff, -1, 0xffffffff, 0);\n    test::<i64>(-0xffffffff, -0xffffffff, 1, 0);\n    test::<i64>(-1000000000000, -1, 1000000000000, 0);\n    test::<i64>(-1000000000000, -3, 333333333334, 2);\n    test::<i64>(-1000000000000, -123, 8130081301, 23);\n    test::<i64>(-1000000000000, -0xffffffff, 233, 727379735);\n    test::<i128>(-1000000000000000000000000, -1, 1000000000000000000000000, 0);\n    test::<i128>(-1000000000000000000000000, -3, 333333333333333333333334, 2);\n    test::<i128>(-1000000000000000000000000, -123, 8130081300813008130082, 86);\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        232830643708080,\n        1127243600,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1234567890987,\n        810000006724,\n        704498996588,\n    );\n    test::<i128>(\n        -253640751230376270397812803167,\n        -2669936877441,\n        94998781946290114,\n        1149635115107,\n    );\n    test::<i128>(\n        -3768477692975601,\n        -11447376614057827956,\n        1,\n        11443608136364852355,\n    );\n    test::<i64>(-3356605361737854, -3081095617839357, 2, 2805585873940860);\n    test::<i128>(\n        -1098730198198174614195,\n        -953382298040157850476,\n        2,\n        808034397882141086757,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        -69738658860594537152875081748,\n        1,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, -1000000000000000000000000, 1, 0);\n    test::<i128>(0, -1000000000000000000000000, 0, 0);\n    test::<i128>(\n        -123,\n        -1000000000000000000000000,\n        1,\n        999999999999999999999877,\n    );\n}\n\nfn ceiling_div_mod_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::ONE.ceiling_div_mod(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.ceiling_div_assign_mod(T::ZERO);\n    });\n    assert_panic!(T::MIN.ceiling_div_mod(T::NEGATIVE_ONE));\n    assert_panic!({\n        let mut n = T::MIN;\n        n.ceiling_div_assign_mod(T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\npub fn ceiling_div_mod_fail() {\n    apply_fn_to_signeds!(ceiling_div_mod_fail_helper);\n}\n\nfn ceiling_div_mod_properties_helper<T: PrimitiveSigned>() {\n    signed_pair_gen_var_4::<T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        let r = mut_x.ceiling_div_assign_mod(y);\n        let q = mut_x;\n\n        assert_eq!(x.ceiling_div_mod(y), (q, r));\n\n        let (q_alt, r_alt) = (x.div_round(y, Ceiling).0, x.ceiling_mod(y));\n        assert_eq!(q_alt, q);\n        assert_eq!(r_alt, r);\n\n        assert!(r.lt_abs(&y));\n        assert!(r == T::ZERO || (r > T::ZERO) != (y > T::ZERO));\n        if let Some(product) = q.checked_mul(y) {\n            assert_eq!(product + r, x);\n        } else if q > T::ZERO {\n            assert_eq!((q - T::ONE) * y + r + y, x);\n        } else {\n            assert_eq!((q + T::ONE) * y + r - y, x);\n        }\n\n        if x != T::MIN {\n            let (neg_q, neg_r) = (-x).ceiling_div_mod(y);\n            assert_eq!(x.div_mod(y), (-neg_q, -neg_r));\n        }\n        if y != T::MIN && (x != T::MIN || y != T::ONE) {\n            let (neg_q, r) = x.ceiling_div_mod(-y);\n            assert_eq!(x.div_mod(y), (-neg_q, r));\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        let (q, r) = x.ceiling_div_mod(T::ONE);\n        assert_eq!(q, x);\n        assert_eq!(r, T::ZERO);\n\n        if x != T::MIN {\n            let (q, r) = x.ceiling_div_mod(T::NEGATIVE_ONE);\n            assert_eq!(q, -x);\n            assert_eq!(r, T::ZERO);\n        }\n        assert_panic!(x.ceiling_div_mod(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.ceiling_div_assign_mod(T::ZERO)\n        });\n    });\n\n    signed_gen_var_6::<T>().test_properties(|x| {\n        assert_eq!(x.ceiling_div_mod(T::ONE), (x, T::ZERO));\n        if x != T::MIN {\n            assert_eq!(x.ceiling_div_mod(T::NEGATIVE_ONE), (-x, T::ZERO));\n        }\n        assert_eq!(x.ceiling_div_mod(x), (T::ONE, T::ZERO));\n        if x != T::MIN {\n            assert_eq!(x.ceiling_div_mod(-x), (T::NEGATIVE_ONE, T::ZERO));\n        }\n        assert_eq!(T::ZERO.ceiling_div_mod(x), (T::ZERO, T::ZERO));\n    });\n}\n\n#[test]\nfn ceiling_div_mod_properties() {\n    apply_fn_to_signeds!(ceiling_div_mod_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen_var_3, signed_pair_gen_var_5, signed_rounding_mode_pair_gen,\n    signed_rounding_mode_pair_gen_var_1, signed_rounding_mode_pair_gen_var_2,\n    signed_rounding_mode_pair_gen_var_3, signed_signed_rounding_mode_triple_gen_var_1,\n    unsigned_pair_gen_var_11, unsigned_pair_gen_var_12, unsigned_pair_gen_var_13,\n    unsigned_rounding_mode_pair_gen, unsigned_rounding_mode_pair_gen_var_1,\n    unsigned_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_div_round_unsigned() {\n    fn test<T: PrimitiveUnsigned>(n: T, d: T, rm: RoundingMode, q: T, o: Ordering) {\n        assert_eq!(n.div_round(d, rm), (q, o));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.div_round_assign(d, rm), o);\n        assert_eq!(mut_n, q);\n    }\n    test::<u8>(0, 1, Down, 0, Equal);\n    test::<u8>(0, 1, Floor, 0, Equal);\n    test::<u8>(0, 1, Up, 0, Equal);\n    test::<u8>(0, 1, Ceiling, 0, Equal);\n    test::<u8>(0, 1, Nearest, 0, Equal);\n    test::<u8>(0, 1, Exact, 0, Equal);\n\n    test::<u16>(0, 123, Down, 0, Equal);\n    test::<u16>(0, 123, Floor, 0, Equal);\n    test::<u16>(0, 123, Up, 0, Equal);\n    test::<u16>(0, 123, Ceiling, 0, Equal);\n    test::<u16>(0, 123, Nearest, 0, Equal);\n    test::<u16>(0, 123, Exact, 0, Equal);\n\n    test::<u32>(1, 1, Down, 1, Equal);\n    test::<u32>(1, 1, Floor, 1, Equal);\n    test::<u32>(1, 1, Up, 1, Equal);\n    test::<u32>(1, 1, Ceiling, 1, Equal);\n    test::<u32>(1, 1, Nearest, 1, Equal);\n    test::<u32>(1, 1, Exact, 1, Equal);\n\n    test::<u64>(123, 1, Down, 123, Equal);\n    test::<u64>(123, 1, Floor, 123, Equal);\n    test::<u64>(123, 1, Up, 123, Equal);\n    test::<u64>(123, 1, Ceiling, 123, Equal);\n    test::<u64>(123, 1, Nearest, 123, Equal);\n    test::<u64>(123, 1, Exact, 123, Equal);\n\n    test::<u128>(123, 2, Down, 61, Less);\n    test::<u128>(123, 2, Floor, 61, Less);\n    test::<u128>(123, 2, Up, 62, Greater);\n    test::<u128>(123, 2, Ceiling, 62, Greater);\n    test::<u128>(123, 2, Nearest, 62, Greater);\n\n    test::<usize>(125, 2, Down, 62, Less);\n    test::<usize>(125, 2, Floor, 62, Less);\n    test::<usize>(125, 2, Up, 63, Greater);\n    test::<usize>(125, 2, Ceiling, 63, Greater);\n    test::<usize>(125, 2, Nearest, 62, Less);\n\n    test::<u8>(123, 123, Down, 1, Equal);\n    test::<u8>(123, 123, Floor, 1, Equal);\n    test::<u8>(123, 123, Up, 1, Equal);\n    test::<u8>(123, 123, Ceiling, 1, Equal);\n    test::<u8>(123, 123, Nearest, 1, Equal);\n    test::<u8>(123, 123, Exact, 1, Equal);\n\n    test::<u16>(123, 456, Down, 0, Less);\n    test::<u16>(123, 456, Floor, 0, Less);\n    test::<u16>(123, 456, Up, 1, Greater);\n    test::<u16>(123, 456, Ceiling, 1, Greater);\n    test::<u16>(123, 456, Nearest, 0, Less);\n\n    test::<u64>(1000000000000, 1, Down, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Floor, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Up, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Ceiling, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Nearest, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Exact, 1000000000000, Equal);\n\n    test::<u64>(1000000000000, 3, Down, 333333333333, Less);\n    test::<u64>(1000000000000, 3, Floor, 333333333333, Less);\n    test::<u64>(1000000000000, 3, Up, 333333333334, Greater);\n    test::<u64>(1000000000000, 3, Ceiling, 333333333334, Greater);\n    test::<u64>(1000000000000, 3, Nearest, 333333333333, Less);\n\n    test::<u64>(999999999999, 2, Down, 499999999999, Less);\n    test::<u64>(999999999999, 2, Floor, 499999999999, Less);\n    test::<u64>(999999999999, 2, Up, 500000000000, Greater);\n    test::<u64>(999999999999, 2, Ceiling, 500000000000, Greater);\n    test::<u64>(999999999999, 2, Nearest, 500000000000, Greater);\n\n    test::<u64>(1000000000001, 2, Down, 500000000000, Less);\n    test::<u64>(1000000000001, 2, Floor, 500000000000, Less);\n    test::<u64>(1000000000001, 2, Up, 500000000001, Greater);\n    test::<u64>(1000000000001, 2, Ceiling, 500000000001, Greater);\n    test::<u64>(1000000000001, 2, Nearest, 500000000000, Less);\n\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Down,\n        232830643708079,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Floor,\n        232830643708079,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Up,\n        232830643708080,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Ceiling,\n        232830643708080,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Nearest,\n        232830643708080,\n        Greater,\n    );\n\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Down,\n        1000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Floor,\n        1000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Up,\n        1000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Ceiling,\n        1000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Nearest,\n        1000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Exact,\n        1000000000000,\n        Equal,\n    );\n\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Down,\n        999999999999,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Floor,\n        999999999999,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Up,\n        1000000000000,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Ceiling,\n        1000000000000,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Nearest,\n        999999999999,\n        Less,\n    );\n\n    test::<u128>(\n        2999999999999999999999999,\n        2000000000000000000000000,\n        Nearest,\n        1,\n        Less,\n    );\n    test::<u128>(\n        3000000000000000000000000,\n        2000000000000000000000000,\n        Nearest,\n        2,\n        Greater,\n    );\n    test::<u128>(\n        3000000000000000000000001,\n        2000000000000000000000000,\n        Nearest,\n        2,\n        Greater,\n    );\n}\n\n#[test]\nfn test_div_round_signed() {\n    fn test<T: PrimitiveSigned>(n: T, d: T, rm: RoundingMode, q: T, o: Ordering) {\n        assert_eq!(n.div_round(d, rm), (q, o));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.div_round_assign(d, rm), o);\n        assert_eq!(mut_n, q);\n    }\n    test::<i8>(0, 1, Down, 0, Equal);\n    test::<i8>(0, 1, Floor, 0, Equal);\n    test::<i8>(0, 1, Up, 0, Equal);\n    test::<i8>(0, 1, Ceiling, 0, Equal);\n    test::<i8>(0, 1, Nearest, 0, Equal);\n    test::<i8>(0, 1, Exact, 0, Equal);\n\n    test::<i16>(0, 123, Down, 0, Equal);\n    test::<i16>(0, 123, Floor, 0, Equal);\n    test::<i16>(0, 123, Up, 0, Equal);\n    test::<i16>(0, 123, Ceiling, 0, Equal);\n    test::<i16>(0, 123, Nearest, 0, Equal);\n    test::<i16>(0, 123, Exact, 0, Equal);\n\n    test::<i32>(1, 1, Down, 1, Equal);\n    test::<i32>(1, 1, Floor, 1, Equal);\n    test::<i32>(1, 1, Up, 1, Equal);\n    test::<i32>(1, 1, Ceiling, 1, Equal);\n    test::<i32>(1, 1, Nearest, 1, Equal);\n    test::<i32>(1, 1, Exact, 1, Equal);\n\n    test::<i64>(123, 1, Down, 123, Equal);\n    test::<i64>(123, 1, Floor, 123, Equal);\n    test::<i64>(123, 1, Up, 123, Equal);\n    test::<i64>(123, 1, Ceiling, 123, Equal);\n    test::<i64>(123, 1, Nearest, 123, Equal);\n    test::<i64>(123, 1, Exact, 123, Equal);\n\n    test::<i128>(123, 2, Down, 61, Less);\n    test::<i128>(123, 2, Floor, 61, Less);\n    test::<i128>(123, 2, Up, 62, Greater);\n    test::<i128>(123, 2, Ceiling, 62, Greater);\n    test::<i128>(123, 2, Nearest, 62, Greater);\n\n    test::<isize>(125, 2, Down, 62, Less);\n    test::<isize>(125, 2, Floor, 62, Less);\n    test::<isize>(125, 2, Up, 63, Greater);\n    test::<isize>(125, 2, Ceiling, 63, Greater);\n    test::<isize>(125, 2, Nearest, 62, Less);\n\n    test::<i8>(123, 123, Down, 1, Equal);\n    test::<i8>(123, 123, Floor, 1, Equal);\n    test::<i8>(123, 123, Up, 1, Equal);\n    test::<i8>(123, 123, Ceiling, 1, Equal);\n    test::<i8>(123, 123, Nearest, 1, Equal);\n    test::<i8>(123, 123, Exact, 1, Equal);\n\n    test::<i16>(123, 456, Down, 0, Less);\n    test::<i16>(123, 456, Floor, 0, Less);\n    test::<i16>(123, 456, Up, 1, Greater);\n    test::<i16>(123, 456, Ceiling, 1, Greater);\n    test::<i16>(123, 456, Nearest, 0, Less);\n\n    test::<i64>(1000000000000, 1, Down, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Floor, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Up, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Ceiling, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Nearest, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Exact, 1000000000000, Equal);\n\n    test::<i64>(1000000000000, 3, Down, 333333333333, Less);\n    test::<i64>(1000000000000, 3, Floor, 333333333333, Less);\n    test::<i64>(1000000000000, 3, Up, 333333333334, Greater);\n    test::<i64>(1000000000000, 3, Ceiling, 333333333334, Greater);\n    test::<i64>(1000000000000, 3, Nearest, 333333333333, Less);\n\n    test::<i64>(999999999999, 2, Down, 499999999999, Less);\n    test::<i64>(999999999999, 2, Floor, 499999999999, Less);\n    test::<i64>(999999999999, 2, Up, 500000000000, Greater);\n    test::<i64>(999999999999, 2, Ceiling, 500000000000, Greater);\n    test::<i64>(999999999999, 2, Nearest, 500000000000, Greater);\n\n    test::<i64>(1000000000001, 2, Down, 500000000000, Less);\n    test::<i64>(1000000000001, 2, Floor, 500000000000, Less);\n    test::<i64>(1000000000001, 2, Up, 500000000001, Greater);\n    test::<i64>(1000000000001, 2, Ceiling, 500000000001, Greater);\n    test::<i64>(1000000000001, 2, Nearest, 500000000000, Less);\n\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Down,\n        232830643708079,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Floor,\n        232830643708079,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Up,\n        232830643708080,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Ceiling,\n        232830643708080,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Nearest,\n        232830643708080,\n        Greater,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Down,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Floor,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Up,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Ceiling,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Nearest,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Exact,\n        1000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Down,\n        999999999999,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Floor,\n        999999999999,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Up,\n        1000000000000,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Ceiling,\n        1000000000000,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Nearest,\n        999999999999,\n        Less,\n    );\n\n    test::<i128>(\n        2999999999999999999999999,\n        2000000000000000000000000,\n        Nearest,\n        1,\n        Less,\n    );\n    test::<i128>(\n        3000000000000000000000000,\n        2000000000000000000000000,\n        Nearest,\n        2,\n        Greater,\n    );\n    test::<i128>(\n        3000000000000000000000001,\n        2000000000000000000000000,\n        Nearest,\n        2,\n        Greater,\n    );\n\n    test::<i8>(0, -1, Down, 0, Equal);\n    test::<i8>(0, -1, Floor, 0, Equal);\n    test::<i8>(0, -1, Up, 0, Equal);\n    test::<i8>(0, -1, Ceiling, 0, Equal);\n    test::<i8>(0, -1, Nearest, 0, Equal);\n    test::<i8>(0, -1, Exact, 0, Equal);\n\n    test::<i16>(0, -123, Down, 0, Equal);\n    test::<i16>(0, -123, Floor, 0, Equal);\n    test::<i16>(0, -123, Up, 0, Equal);\n    test::<i16>(0, -123, Ceiling, 0, Equal);\n    test::<i16>(0, -123, Nearest, 0, Equal);\n    test::<i16>(0, -123, Exact, 0, Equal);\n\n    test::<i32>(1, -1, Down, -1, Equal);\n    test::<i32>(1, -1, Floor, -1, Equal);\n    test::<i32>(1, -1, Up, -1, Equal);\n    test::<i32>(1, -1, Ceiling, -1, Equal);\n    test::<i32>(1, -1, Nearest, -1, Equal);\n    test::<i32>(1, -1, Exact, -1, Equal);\n\n    test::<i64>(123, -1, Down, -123, Equal);\n    test::<i64>(123, -1, Floor, -123, Equal);\n    test::<i64>(123, -1, Up, -123, Equal);\n    test::<i64>(123, -1, Ceiling, -123, Equal);\n    test::<i64>(123, -1, Nearest, -123, Equal);\n    test::<i64>(123, -1, Exact, -123, Equal);\n\n    test::<i128>(123, -2, Down, -61, Greater);\n    test::<i128>(123, -2, Floor, -62, Less);\n    test::<i128>(123, -2, Up, -62, Less);\n    test::<i128>(123, -2, Ceiling, -61, Greater);\n    test::<i128>(123, -2, Nearest, -62, Less);\n\n    test::<isize>(125, -2, Down, -62, Greater);\n    test::<isize>(125, -2, Floor, -63, Less);\n    test::<isize>(125, -2, Up, -63, Less);\n    test::<isize>(125, -2, Ceiling, -62, Greater);\n    test::<isize>(125, -2, Nearest, -62, Greater);\n\n    test::<i8>(123, -123, Down, -1, Equal);\n    test::<i8>(123, -123, Floor, -1, Equal);\n    test::<i8>(123, -123, Up, -1, Equal);\n    test::<i8>(123, -123, Ceiling, -1, Equal);\n    test::<i8>(123, -123, Nearest, -1, Equal);\n    test::<i8>(123, -123, Exact, -1, Equal);\n\n    test::<i16>(123, -456, Down, 0, Greater);\n    test::<i16>(123, -456, Floor, -1, Less);\n    test::<i16>(123, -456, Up, -1, Less);\n    test::<i16>(123, -456, Ceiling, 0, Greater);\n    test::<i16>(123, -456, Nearest, 0, Greater);\n\n    test::<i64>(1000000000000, -1, Down, -1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Floor, -1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Up, -1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Ceiling, -1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Nearest, -1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Exact, -1000000000000, Equal);\n\n    test::<i64>(1000000000000, -3, Down, -333333333333, Greater);\n    test::<i64>(1000000000000, -3, Floor, -333333333334, Less);\n    test::<i64>(1000000000000, -3, Up, -333333333334, Less);\n    test::<i64>(1000000000000, -3, Ceiling, -333333333333, Greater);\n    test::<i64>(1000000000000, -3, Nearest, -333333333333, Greater);\n\n    test::<i64>(999999999999, -2, Down, -499999999999, Greater);\n    test::<i64>(999999999999, -2, Floor, -500000000000, Less);\n    test::<i64>(999999999999, -2, Up, -500000000000, Less);\n    test::<i64>(999999999999, -2, Ceiling, -499999999999, Greater);\n    test::<i64>(999999999999, -2, Nearest, -500000000000, Less);\n\n    test::<i64>(1000000000001, -2, Down, -500000000000, Greater);\n    test::<i64>(1000000000001, -2, Floor, -500000000001, Less);\n    test::<i64>(1000000000001, -2, Up, -500000000001, Less);\n    test::<i64>(1000000000001, -2, Ceiling, -500000000000, Greater);\n    test::<i64>(1000000000001, -2, Nearest, -500000000000, Greater);\n\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Down,\n        -232830643708079,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Floor,\n        -232830643708080,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Up,\n        -232830643708080,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Ceiling,\n        -232830643708079,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Nearest,\n        -232830643708080,\n        Less,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Down,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Floor,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Up,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Ceiling,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Nearest,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Exact,\n        -1000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Down,\n        -999999999999,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Floor,\n        -1000000000000,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Up,\n        -1000000000000,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Ceiling,\n        -999999999999,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Nearest,\n        -999999999999,\n        Greater,\n    );\n\n    test::<i128>(\n        2999999999999999999999999,\n        -2000000000000000000000000,\n        Nearest,\n        -1,\n        Greater,\n    );\n    test::<i128>(\n        3000000000000000000000000,\n        -2000000000000000000000000,\n        Nearest,\n        -2,\n        Less,\n    );\n    test::<i128>(\n        3000000000000000000000001,\n        -2000000000000000000000000,\n        Nearest,\n        -2,\n        Less,\n    );\n\n    test::<i8>(-1, 1, Down, -1, Equal);\n    test::<i8>(-1, 1, Floor, -1, Equal);\n    test::<i8>(-1, 1, Up, -1, Equal);\n    test::<i8>(-1, 1, Ceiling, -1, Equal);\n    test::<i8>(-1, 1, Nearest, -1, Equal);\n    test::<i8>(-1, 1, Exact, -1, Equal);\n\n    test::<i16>(-123, 1, Down, -123, Equal);\n    test::<i16>(-123, 1, Floor, -123, Equal);\n    test::<i16>(-123, 1, Up, -123, Equal);\n    test::<i16>(-123, 1, Ceiling, -123, Equal);\n    test::<i16>(-123, 1, Nearest, -123, Equal);\n    test::<i16>(-123, 1, Exact, -123, Equal);\n\n    test::<i32>(-123, 2, Down, -61, Greater);\n    test::<i32>(-123, 2, Floor, -62, Less);\n    test::<i32>(-123, 2, Up, -62, Less);\n    test::<i32>(-123, 2, Ceiling, -61, Greater);\n    test::<i32>(-123, 2, Nearest, -62, Less);\n\n    test::<i64>(-125, 2, Down, -62, Greater);\n    test::<i64>(-125, 2, Floor, -63, Less);\n    test::<i64>(-125, 2, Up, -63, Less);\n    test::<i64>(-125, 2, Ceiling, -62, Greater);\n    test::<i64>(-125, 2, Nearest, -62, Greater);\n\n    test::<i128>(-123, 123, Down, -1, Equal);\n    test::<i128>(-123, 123, Floor, -1, Equal);\n    test::<i128>(-123, 123, Up, -1, Equal);\n    test::<i128>(-123, 123, Ceiling, -1, Equal);\n    test::<i128>(-123, 123, Nearest, -1, Equal);\n    test::<i128>(-123, 123, Exact, -1, Equal);\n\n    test::<isize>(-123, 456, Down, 0, Greater);\n    test::<isize>(-123, 456, Floor, -1, Less);\n    test::<isize>(-123, 456, Up, -1, Less);\n    test::<isize>(-123, 456, Ceiling, 0, Greater);\n    test::<isize>(-123, 456, Nearest, 0, Greater);\n\n    test::<i64>(-1000000000000, 1, Down, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Floor, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Up, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Ceiling, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Nearest, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Exact, -1000000000000, Equal);\n\n    test::<i64>(-1000000000000, 3, Down, -333333333333, Greater);\n    test::<i64>(-1000000000000, 3, Floor, -333333333334, Less);\n    test::<i64>(-1000000000000, 3, Up, -333333333334, Less);\n    test::<i64>(-1000000000000, 3, Ceiling, -333333333333, Greater);\n    test::<i64>(-1000000000000, 3, Nearest, -333333333333, Greater);\n\n    test::<i64>(-999999999999, 2, Down, -499999999999, Greater);\n    test::<i64>(-999999999999, 2, Floor, -500000000000, Less);\n    test::<i64>(-999999999999, 2, Up, -500000000000, Less);\n    test::<i64>(-999999999999, 2, Ceiling, -499999999999, Greater);\n    test::<i64>(-999999999999, 2, Nearest, -500000000000, Less);\n\n    test::<i64>(-1000000000001, 2, Down, -500000000000, Greater);\n    test::<i64>(-1000000000001, 2, Floor, -500000000001, Less);\n    test::<i64>(-1000000000001, 2, Up, -500000000001, Less);\n    test::<i64>(-1000000000001, 2, Ceiling, -500000000000, Greater);\n    test::<i64>(-1000000000001, 2, Nearest, -500000000000, Greater);\n\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Down,\n        -232830643708079,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Floor,\n        -232830643708080,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Up,\n        -232830643708080,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Ceiling,\n        -232830643708079,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Nearest,\n        -232830643708080,\n        Less,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Down,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Floor,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Up,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Ceiling,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Nearest,\n        -1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Exact,\n        -1000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Down,\n        -999999999999,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Floor,\n        -1000000000000,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Up,\n        -1000000000000,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Ceiling,\n        -999999999999,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Nearest,\n        -999999999999,\n        Greater,\n    );\n\n    test::<i128>(\n        -2999999999999999999999999,\n        2000000000000000000000000,\n        Nearest,\n        -1,\n        Greater,\n    );\n    test::<i128>(\n        -3000000000000000000000000,\n        2000000000000000000000000,\n        Nearest,\n        -2,\n        Less,\n    );\n    test::<i128>(\n        -3000000000000000000000001,\n        2000000000000000000000000,\n        Nearest,\n        -2,\n        Less,\n    );\n\n    test::<i8>(-1, -1, Down, 1, Equal);\n    test::<i8>(-1, -1, Floor, 1, Equal);\n    test::<i8>(-1, -1, Up, 1, Equal);\n    test::<i8>(-1, -1, Ceiling, 1, Equal);\n    test::<i8>(-1, -1, Nearest, 1, Equal);\n    test::<i8>(-1, -1, Exact, 1, Equal);\n\n    test::<i16>(-123, -1, Down, 123, Equal);\n    test::<i16>(-123, -1, Floor, 123, Equal);\n    test::<i16>(-123, -1, Up, 123, Equal);\n    test::<i16>(-123, -1, Ceiling, 123, Equal);\n    test::<i16>(-123, -1, Nearest, 123, Equal);\n    test::<i16>(-123, -1, Exact, 123, Equal);\n\n    test::<i32>(-123, -2, Down, 61, Less);\n    test::<i32>(-123, -2, Floor, 61, Less);\n    test::<i32>(-123, -2, Up, 62, Greater);\n    test::<i32>(-123, -2, Ceiling, 62, Greater);\n    test::<i32>(-123, -2, Nearest, 62, Greater);\n\n    test::<i64>(-125, -2, Down, 62, Less);\n    test::<i64>(-125, -2, Floor, 62, Less);\n    test::<i64>(-125, -2, Up, 63, Greater);\n    test::<i64>(-125, -2, Ceiling, 63, Greater);\n    test::<i64>(-125, -2, Nearest, 62, Less);\n\n    test::<i128>(-123, -123, Down, 1, Equal);\n    test::<i128>(-123, -123, Floor, 1, Equal);\n    test::<i128>(-123, -123, Up, 1, Equal);\n    test::<i128>(-123, -123, Ceiling, 1, Equal);\n    test::<i128>(-123, -123, Nearest, 1, Equal);\n    test::<i128>(-123, -123, Exact, 1, Equal);\n\n    test::<isize>(-123, -456, Down, 0, Less);\n    test::<isize>(-123, -456, Floor, 0, Less);\n    test::<isize>(-123, -456, Up, 1, Greater);\n    test::<isize>(-123, -456, Ceiling, 1, Greater);\n    test::<isize>(-123, -456, Nearest, 0, Less);\n\n    test::<i64>(-1000000000000, -1, Down, 1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Floor, 1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Up, 1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Ceiling, 1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Nearest, 1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Exact, 1000000000000, Equal);\n\n    test::<i64>(-1000000000000, -3, Down, 333333333333, Less);\n    test::<i64>(-1000000000000, -3, Floor, 333333333333, Less);\n    test::<i64>(-1000000000000, -3, Up, 333333333334, Greater);\n    test::<i64>(-1000000000000, -3, Ceiling, 333333333334, Greater);\n    test::<i64>(-1000000000000, -3, Nearest, 333333333333, Less);\n\n    test::<i64>(-999999999999, -2, Down, 499999999999, Less);\n    test::<i64>(-999999999999, -2, Floor, 499999999999, Less);\n    test::<i64>(-999999999999, -2, Up, 500000000000, Greater);\n    test::<i64>(-999999999999, -2, Ceiling, 500000000000, Greater);\n    test::<i64>(-999999999999, -2, Nearest, 500000000000, Greater);\n\n    test::<i64>(-1000000000001, -2, Down, 500000000000, Less);\n    test::<i64>(-1000000000001, -2, Floor, 500000000000, Less);\n    test::<i64>(-1000000000001, -2, Up, 500000000001, Greater);\n    test::<i64>(-1000000000001, -2, Ceiling, 500000000001, Greater);\n    test::<i64>(-1000000000001, -2, Nearest, 500000000000, Less);\n\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Down,\n        232830643708079,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Floor,\n        232830643708079,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Up,\n        232830643708080,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Ceiling,\n        232830643708080,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Nearest,\n        232830643708080,\n        Greater,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Down,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Floor,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Up,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Ceiling,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Nearest,\n        1000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Exact,\n        1000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Down,\n        999999999999,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Floor,\n        999999999999,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Up,\n        1000000000000,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Ceiling,\n        1000000000000,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Nearest,\n        999999999999,\n        Less,\n    );\n\n    test::<i128>(\n        -2999999999999999999999999,\n        -2000000000000000000000000,\n        Nearest,\n        1,\n        Less,\n    );\n    test::<i128>(\n        -3000000000000000000000000,\n        -2000000000000000000000000,\n        Nearest,\n        2,\n        Greater,\n    );\n    test::<i128>(\n        -3000000000000000000000001,\n        -2000000000000000000000000,\n        Nearest,\n        2,\n        Greater,\n    );\n\n    test::<i8>(-128, 1, Down, -128, Equal);\n    test::<i8>(-128, 1, Up, -128, Equal);\n    test::<i8>(-128, 1, Floor, -128, Equal);\n    test::<i8>(-128, 1, Ceiling, -128, Equal);\n    test::<i8>(-128, 1, Nearest, -128, Equal);\n    test::<i8>(-128, 1, Exact, -128, Equal);\n}\n\nfn div_round_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::exact_from(10).div_round(T::ZERO, Floor));\n    assert_panic!(T::exact_from(10).div_round(T::exact_from(3), Exact));\n    assert_panic!(T::exact_from(10).div_round_assign(T::ZERO, Floor));\n    assert_panic!(T::exact_from(10).div_round_assign(T::exact_from(3), Exact));\n}\n\nfn div_round_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::MIN.div_round(T::NEGATIVE_ONE, Floor));\n    assert_panic!({\n        let mut n = T::MIN;\n        n.div_round_assign(T::NEGATIVE_ONE, Floor);\n    });\n}\n\n#[test]\nfn div_round_fail() {\n    apply_fn_to_primitive_ints!(div_round_fail_helper);\n    apply_fn_to_signeds!(div_round_signed_fail_helper);\n}\n\nfn div_round_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_unsigned_rounding_mode_triple_gen_var_1::<T>().test_properties(|(x, y, rm)| {\n        let mut mut_x = x;\n        let o = mut_x.div_round_assign(y, rm);\n        let q = mut_x;\n\n        assert_eq!(x.div_round(y, rm), (q, o));\n        assert!(q <= x);\n        assert_eq!(x.divisible_by(y), o == Equal);\n\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if let Some(product) = q.checked_mul(y) {\n            assert_eq!(product.cmp(&x), o);\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(x.div_round(y, rm), (q, Equal));\n            }\n        } else {\n            assert_panic!(x.div_round(y, Exact));\n        }\n    });\n\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(x, y)| {\n        assert_eq!(x.ceiling_div_neg_mod(y).0, x.div_round(y, Ceiling).0);\n    });\n\n    unsigned_pair_gen_var_11::<T>().test_properties(|(x, y)| {\n        let q = x.div_exact(y);\n        let o = Equal;\n        assert_eq!(x.div_round(y, Down), (q, o));\n        assert_eq!(x.div_round(y, Up), (q, o));\n        assert_eq!(x.div_round(y, Floor), (q, o));\n        assert_eq!(x.div_round(y, Ceiling), (q, o));\n        assert_eq!(x.div_round(y, Nearest), (q, o));\n        assert_eq!(x.div_round(y, Exact), (q, o));\n    });\n\n    unsigned_pair_gen_var_13::<T>().test_properties(|(x, y)| {\n        let down = x.div_round(y, Down);\n        assert_eq!(down.1, Less);\n        let up = (down.0 + T::ONE, Greater);\n        assert_eq!(x.div_round(y, Up), up);\n        assert_eq!(x.div_round(y, Floor), down);\n        assert_eq!(x.div_round(y, Ceiling), up);\n        let nearest = x.div_round(y, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(x, rm)| {\n        assert_eq!(x.div_round(T::ONE, rm), (x, Equal));\n        assert_panic!(x.div_round(T::ZERO, rm));\n        assert_panic!({\n            let mut y = x;\n            y.div_round_assign(T::ZERO, rm)\n        });\n    });\n\n    unsigned_rounding_mode_pair_gen_var_1::<T>().test_properties(|(x, rm)| {\n        assert_eq!(T::ZERO.div_round(x, rm), (T::ZERO, Equal));\n        assert_eq!(x.div_round(x, rm), (T::ONE, Equal));\n    });\n}\n\nfn div_round_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_signed_rounding_mode_triple_gen_var_1::<T>().test_properties(|(x, y, rm)| {\n        let mut mut_x = x;\n        let o = mut_x.div_round_assign(y, rm);\n        let q = mut_x;\n\n        assert_eq!(x.div_round(y, rm), (q, o));\n\n        assert!(q.le_abs(&x));\n        assert_eq!(x.divisible_by(y), o == Equal);\n        if x != T::MIN {\n            let (q_alt, o_alt) = (-x).div_round(y, -rm);\n            assert_eq!(-q_alt, q);\n            assert_eq!(o_alt.reverse(), o);\n        }\n        if y != T::MIN && (x != T::MIN || (y != T::ONE && y != T::NEGATIVE_ONE)) {\n            let (q_alt, o_alt) = x.div_round(-y, -rm);\n            assert_eq!(-q_alt, q);\n            assert_eq!(o_alt.reverse(), o);\n        }\n\n        match ((x >= T::ZERO) == (y >= T::ZERO), rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if let Some(product) = q.checked_mul(y) {\n            assert_eq!(product.cmp(&x), if y >= T::ZERO { o } else { o.reverse() });\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(x.div_round(y, rm), (q, Equal));\n            }\n        } else {\n            assert_panic!(x.div_round(y, Exact));\n        }\n    });\n\n    signed_pair_gen_var_3::<T>().test_properties(|(x, y)| {\n        let q = x.div_exact(y);\n        let o = Equal;\n        assert_eq!(x.div_round(y, Down), (q, o));\n        assert_eq!(x.div_round(y, Up), (q, o));\n        assert_eq!(x.div_round(y, Floor), (q, o));\n        assert_eq!(x.div_round(y, Ceiling), (q, o));\n        assert_eq!(x.div_round(y, Nearest), (q, o));\n        assert_eq!(x.div_round(y, Exact), (q, o));\n    });\n\n    signed_pair_gen_var_5::<T>().test_properties(|(x, y)| {\n        let down = x.div_round(y, Down);\n        let up = if (x >= T::ZERO) == (y >= T::ZERO) {\n            (down.0 + T::ONE, Greater)\n        } else {\n            (down.0 - T::ONE, Less)\n        };\n        let floor = x.div_round(y, Floor);\n        let ceiling = (floor.0 + T::ONE, Greater);\n        assert_eq!(x.div_round(y, Up), up);\n        assert_eq!(x.div_round(y, Ceiling), ceiling);\n        let nearest = x.div_round(y, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(x, rm)| {\n        assert_eq!(x.div_round(T::ONE, rm), (x, Equal));\n        assert_panic!(x.div_round(T::ZERO, rm));\n        assert_panic!({\n            let mut y = x;\n            y.div_round_assign(T::ZERO, rm)\n        });\n    });\n\n    signed_rounding_mode_pair_gen_var_2::<T>().test_properties(|(x, rm)| {\n        assert_eq!(x.div_round(T::NEGATIVE_ONE, rm), (-x, Equal));\n    });\n\n    signed_rounding_mode_pair_gen_var_1::<T>().test_properties(|(x, rm)| {\n        assert_eq!(T::ZERO.div_round(x, rm), (T::ZERO, Equal));\n        assert_eq!(x.div_round(x, rm), (T::ONE, Equal));\n    });\n\n    signed_rounding_mode_pair_gen_var_3::<T>().test_properties(|(x, rm)| {\n        assert_eq!(x.div_round(-x, rm), (T::NEGATIVE_ONE, Equal));\n        assert_eq!((-x).div_round(x, rm), (T::NEGATIVE_ONE, Equal));\n    });\n}\n\n#[test]\nfn div_round_properties() {\n    apply_fn_to_unsigneds!(div_round_properties_helper_unsigned);\n    apply_fn_to_signeds!(div_round_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_6, signed_pair_gen, signed_pair_gen_var_3, signed_pair_gen_var_5,\n    unsigned_gen, unsigned_gen_var_1, unsigned_pair_gen_var_11, unsigned_pair_gen_var_13,\n    unsigned_pair_gen_var_27,\n};\n\n#[test]\nfn test_divisible_by() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: bool) {\n        assert_eq!(x.divisible_by(y), out);\n    }\n    test::<u8>(0, 0, true);\n    test::<u16>(1, 0, false);\n    test::<u64>(1000000000000, 0, false);\n    test::<u32>(0, 1, true);\n    test::<u128>(0, 123, true);\n    test::<usize>(1, 1, true);\n    test::<u8>(123, 1, true);\n    test::<u16>(123, 123, true);\n    test::<u32>(123, 456, false);\n    test::<u64>(456, 123, false);\n    test::<u128>(369, 123, true);\n    test::<usize>(0xffffffff, 1, true);\n    test::<u32>(u32::MAX, u32::MAX, true);\n    test::<u64>(1000000000000, 1, true);\n    test::<u64>(1000000000000, 3, false);\n    test::<u64>(1000000000002, 3, true);\n    test::<u64>(1000000000000, 123, false);\n    test::<u64>(1000000000000, 0xffffffff, false);\n    test::<u128>(1000000000000000000000000, 1, true);\n    test::<u128>(1000000000000000000000000, 3, false);\n    test::<u128>(1000000000000000000000002, 3, true);\n    test::<u128>(1000000000000000000000000, 123, false);\n    test::<u128>(1000000000000000000000000, 0xffffffff, false);\n    test::<u128>(1000000000000000000000000, 1000000000000, true);\n    test::<u128>(1000000000000000000000000, 1000000000001, false);\n\n    test::<i64>(1000000000000, 0, false);\n    test::<i32>(0, -1, true);\n    test::<i128>(0, -123, true);\n    test::<isize>(1, -1, true);\n    test::<i8>(123, -1, true);\n    test::<i16>(123, -123, true);\n    test::<i32>(123, -456, false);\n    test::<i64>(456, -123, false);\n    test::<i128>(369, -123, true);\n    test::<i64>(0xffffffff, -1, true);\n    test::<i64>(0xffffffff, -0xffffffff, true);\n    test::<i64>(1000000000000, -1, true);\n    test::<i64>(1000000000000, -3, false);\n    test::<i64>(1000000000002, -3, true);\n    test::<i64>(1000000000000, -123, false);\n    test::<i64>(1000000000000, -0xffffffff, false);\n    test::<i128>(1000000000000000000000000, -1, true);\n    test::<i128>(1000000000000000000000000, -3, false);\n    test::<i128>(1000000000000000000000002, -3, true);\n    test::<i128>(1000000000000000000000000, -123, false);\n    test::<i128>(1000000000000000000000000, -0xffffffff, false);\n    test::<i128>(1000000000000000000000000, -1000000000000, true);\n    test::<i128>(1000000000000000000000000, -1000000000001, false);\n\n    test::<i16>(-1, 0, false);\n    test::<i64>(-1000000000000, 0, false);\n    test::<isize>(-1, 1, true);\n    test::<i8>(-123, 1, true);\n    test::<i16>(-123, 123, true);\n    test::<i32>(-123, 456, false);\n    test::<i64>(-456, 123, false);\n    test::<i128>(-369, 123, true);\n    test::<i64>(-0xffffffff, 1, true);\n    test::<i64>(-0xffffffff, 0xffffffff, true);\n    test::<i64>(-1000000000000, 1, true);\n    test::<i64>(-1000000000000, 3, false);\n    test::<i64>(-1000000000002, 3, true);\n    test::<i64>(-1000000000000, 123, false);\n    test::<i64>(-1000000000000, 0xffffffff, false);\n    test::<i128>(-1000000000000000000000000, 1, true);\n    test::<i128>(-1000000000000000000000000, 3, false);\n    test::<i128>(-1000000000000000000000002, 3, true);\n    test::<i128>(-1000000000000000000000000, 123, false);\n    test::<i128>(-1000000000000000000000000, 0xffffffff, false);\n    test::<i128>(-1000000000000000000000000, 1000000000000, true);\n    test::<i128>(-1000000000000000000000000, 1000000000001, false);\n\n    test::<isize>(-1, -1, true);\n    test::<i8>(-123, -1, true);\n    test::<i16>(-123, -123, true);\n    test::<i32>(-123, -456, false);\n    test::<i64>(-456, -123, false);\n    test::<i128>(-369, -123, true);\n    test::<i64>(-0xffffffff, -1, true);\n    test::<i64>(-0xffffffff, -0xffffffff, true);\n    test::<i64>(-1000000000000, -1, true);\n    test::<i64>(-1000000000000, -3, false);\n    test::<i64>(-1000000000002, -3, true);\n    test::<i64>(-1000000000000, -123, false);\n    test::<i64>(-1000000000000, -0xffffffff, false);\n    test::<i128>(-1000000000000000000000000, -1, true);\n    test::<i128>(-1000000000000000000000000, -3, false);\n    test::<i128>(-1000000000000000000000002, -3, true);\n    test::<i128>(-1000000000000000000000000, -123, false);\n    test::<i128>(-1000000000000000000000000, -0xffffffff, false);\n    test::<i128>(-1000000000000000000000000, -1000000000000, true);\n    test::<i128>(-1000000000000000000000000, -1000000000001, false);\n}\n\nfn divisible_by_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let divisible = x.divisible_by(y);\n        assert_eq!(x == T::ZERO || y != T::ZERO && x % y == T::ZERO, divisible);\n    });\n\n    unsigned_pair_gen_var_11::<T>().test_properties(|(x, y)| {\n        assert!(x.divisible_by(y));\n        assert!(x == T::ZERO || y != T::ZERO && x % y == T::ZERO);\n    });\n\n    unsigned_pair_gen_var_13::<T>().test_properties(|(x, y)| {\n        assert!(!x.divisible_by(y));\n        assert!(x != T::ZERO && (y == T::ZERO || x % y != T::ZERO));\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert!(n.divisible_by(T::ONE));\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert!(!n.divisible_by(T::ZERO));\n        assert!(T::ZERO.divisible_by(n));\n        if n > T::ONE {\n            assert!(!T::ONE.divisible_by(n));\n        }\n        assert!(n.divisible_by(n));\n    });\n}\n\nfn divisible_by_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let divisible = x.divisible_by(y);\n        assert_eq!(\n            x == T::ZERO || x == T::MIN && y == T::NEGATIVE_ONE || y != T::ZERO && x % y == T::ZERO,\n            divisible\n        );\n        if x != T::MIN {\n            assert_eq!((-x).divisible_by(y), divisible);\n        }\n        if y != T::MIN {\n            assert_eq!(x.divisible_by(-y), divisible);\n        }\n    });\n\n    signed_pair_gen_var_3::<T>().test_properties(|(x, y)| {\n        assert!(x.divisible_by(y));\n        assert!(\n            x == T::ZERO || x == T::MIN && y == T::NEGATIVE_ONE || y != T::ZERO && x % y == T::ZERO\n        );\n    });\n\n    signed_pair_gen_var_5::<T>().test_properties(|(x, y)| {\n        assert!(!x.divisible_by(y));\n        assert!(\n            x != T::ZERO\n                && (x != T::MIN || y != T::NEGATIVE_ONE)\n                && (y == T::ZERO || x % y != T::ZERO)\n        );\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert!(n.divisible_by(T::ONE));\n        assert!(n.divisible_by(T::NEGATIVE_ONE));\n    });\n\n    signed_gen_var_6::<T>().test_properties(|n| {\n        assert!(!n.divisible_by(T::ZERO));\n        assert!(T::ZERO.divisible_by(n));\n        if n > T::ONE {\n            assert!(!T::ONE.divisible_by(n));\n        }\n        assert!(n.divisible_by(n));\n    });\n}\n\n#[test]\nfn divisible_by_properties() {\n    apply_fn_to_unsigneds!(divisible_by_properties_helper_unsigned);\n    apply_fn_to_signeds!(divisible_by_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen_var_1, signed_unsigned_pair_gen_var_8,\n    signed_unsigned_pair_gen_var_9, unsigned_gen, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_14, unsigned_pair_gen_var_15,\n};\n\nfn divisible_by_power_of_2_primitive_helper<T: PrimitiveInt>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.divisible_by_power_of_2(pow), out);\n    };\n    test(T::ZERO, 0, true);\n    test(T::ZERO, 10, true);\n    test(T::ZERO, 100, true);\n    test(T::exact_from(123), 0, true);\n    test(T::exact_from(123), 1, false);\n    if T::WIDTH >= u64::WIDTH {\n        test(T::exact_from(1000000000000u64), 0, true);\n        test(T::exact_from(1000000000000u64), 12, true);\n        test(T::exact_from(1000000000000u64), 13, false);\n    }\n    test(T::MAX, 0, true);\n    test(T::MAX, 1, false);\n    test(T::power_of_2(T::WIDTH >> 1), 0, true);\n    test(T::power_of_2(T::WIDTH >> 1), T::WIDTH >> 1, true);\n    test(T::power_of_2(T::WIDTH >> 1), (T::WIDTH >> 1) + 1, false);\n}\n\nfn divisible_by_power_of_2_signed_helper<T: PrimitiveSigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.divisible_by_power_of_2(pow), out);\n    };\n    test(T::exact_from(-123), 0, true);\n    test(T::exact_from(-123), 1, false);\n    if T::WIDTH >= u64::WIDTH {\n        test(T::exact_from(-1000000000000i64), 0, true);\n        test(T::exact_from(-1000000000000i64), 12, true);\n        test(T::exact_from(-1000000000000i64), 13, false);\n    }\n    test(T::MIN + T::ONE, 0, true);\n    test(T::MIN + T::ONE, 1, false);\n    test(T::MIN, 0, true);\n    test(T::MIN, T::WIDTH - 1, true);\n    test(T::MIN, T::WIDTH, false);\n}\n\n#[test]\nfn test_divisible_by_power_of_2() {\n    apply_fn_to_primitive_ints!(divisible_by_power_of_2_primitive_helper);\n    apply_fn_to_signeds!(divisible_by_power_of_2_signed_helper);\n}\n\nfn divisible_by_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(x, pow)| {\n        let divisible = x.divisible_by_power_of_2(pow);\n        if x != T::ZERO {\n            assert_eq!(x.trailing_zeros() >= pow, divisible);\n        }\n    });\n\n    unsigned_pair_gen_var_15::<T>().test_properties(|(x, pow)| {\n        assert!(x.divisible_by_power_of_2(pow));\n        if x != T::ZERO {\n            assert!(x.trailing_zeros() >= pow);\n        }\n    });\n\n    unsigned_pair_gen_var_14::<T, u64>().test_properties(|(x, pow)| {\n        assert!(!x.divisible_by_power_of_2(pow));\n        if x != T::ZERO {\n            assert!(x.trailing_zeros() < pow);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert!(x.divisible_by_power_of_2(0));\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert!(T::ZERO.divisible_by_power_of_2(pow));\n    });\n}\n\nfn divisible_by_power_of_2_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_1::<T, u64>().test_properties(|(x, pow)| {\n        let divisible = x.divisible_by_power_of_2(pow);\n        if x != T::ZERO {\n            assert_eq!(x.trailing_zeros() >= pow, divisible);\n        }\n        if x != T::MIN {\n            assert_eq!((-x).divisible_by_power_of_2(pow), divisible);\n        }\n    });\n\n    signed_unsigned_pair_gen_var_9::<T, u64>().test_properties(|(x, pow)| {\n        assert!(x.divisible_by_power_of_2(pow));\n        if x != T::ZERO {\n            assert!(x.trailing_zeros() >= pow);\n        }\n        if x != T::MIN {\n            assert!((-x).divisible_by_power_of_2(pow));\n        }\n    });\n\n    signed_unsigned_pair_gen_var_8::<T, u64>().test_properties(|(x, pow)| {\n        assert!(!x.divisible_by_power_of_2(pow));\n        if x != T::ZERO {\n            assert!(x.trailing_zeros() < pow);\n        }\n        if x != T::MIN {\n            assert!(!(-x).divisible_by_power_of_2(pow));\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert!(x.divisible_by_power_of_2(0));\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert!(T::ZERO.divisible_by_power_of_2(pow));\n    });\n}\n\n#[test]\nfn divisible_by_power_of_2_properties() {\n    apply_fn_to_unsigneds!(divisible_by_power_of_2_properties_helper_unsigned);\n    apply_fn_to_signeds!(divisible_by_power_of_2_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_quadruple_gen, signed_triple_gen, signed_triple_gen_var_4,\n    signed_triple_gen_var_5, unsigned_pair_gen_var_27, unsigned_quadruple_gen_var_10,\n    unsigned_triple_gen_var_7, unsigned_triple_gen_var_8, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_eq_mod() {\n    fn test<T: PrimitiveInt>(x: T, y: T, m: T, out: bool) {\n        assert_eq!(x.eq_mod(y, m), out);\n    }\n    test::<u8>(0, 0, 0, true);\n    test::<u16>(0, 1, 0, false);\n    test::<u32>(57, 57, 0, true);\n    test::<u64>(57, 58, 0, false);\n    test::<u128>(1000000000000, 57, 0, false);\n    test::<usize>(0, 256, 256, true);\n    test::<u16>(0, 256, 512, false);\n    test::<u16>(13, 23, 10, true);\n    test::<u32>(13, 24, 10, false);\n    test::<u64>(13, 21, 1, true);\n    test::<u128>(13, 21, 2, true);\n    test::<usize>(13, 21, 4, true);\n    test::<u8>(13, 21, 8, true);\n    test::<u16>(13, 21, 16, false);\n    test::<u32>(13, 21, 3, false);\n    test::<u64>(1000000000001, 1, 4096, true);\n    test::<u128>(1000000000001, 1, 8192, false);\n    test::<u64>(12345678987654321, 321, 1000, true);\n    test::<u64>(12345678987654321, 322, 1000, false);\n    test::<u64>(1234, 1234, 1000000000000, true);\n    test::<u64>(1234, 1235, 1000000000000, false);\n    test::<u64>(1000000001234, 1000000002234, 1000, true);\n    test::<u64>(1000000001234, 1000000002235, 1000, false);\n    test::<u64>(1000000001234, 1234, 1000000000000, true);\n    test::<u64>(1000000001234, 1235, 1000000000000, false);\n    test::<u64>(1000000001234, 5000000001234, 1000000000000, true);\n    test::<u64>(1000000001234, 5000000001235, 1000000000000, false);\n\n    test::<i8>(0, -1, 0, false);\n    test::<i16>(57, -57, 0, false);\n    test::<i32>(57, -58, 0, false);\n    test::<i64>(1000000000000, -57, 0, false);\n    test::<i128>(0, -256, 256, true);\n    test::<isize>(0, -256, 512, false);\n    test::<i8>(13, -27, 10, true);\n    test::<i16>(13, -28, 10, false);\n    test::<i32>(29, -27, 1, true);\n    test::<i64>(29, -27, 2, true);\n    test::<i128>(29, -27, 4, true);\n    test::<isize>(29, -27, 8, true);\n    test::<i8>(29, -27, 16, false);\n    test::<i16>(29, -27, 3, false);\n    test::<i64>(999999999999, -1, 4096, true);\n    test::<i64>(999999999999, -1, 8192, false);\n    test::<i64>(12345678987654321, -679, 1000, true);\n    test::<i64>(12345678987654321, -680, 1000, false);\n    test::<i64>(1000000001234, -999999999766, 1000, true);\n    test::<i64>(1000000001234, -999999999767, 1000, false);\n    test::<i64>(1000000001234, -999999998766, 1000000000000, true);\n    test::<i64>(1000000001234, -999999998767, 1000000000000, false);\n\n    test::<i16>(-57, 57, 0, false);\n    test::<i32>(-57, 58, 0, false);\n    test::<i64>(-1000000000000, 57, 0, false);\n    test::<i8>(-13, 27, 10, true);\n    test::<i16>(-13, 28, 10, false);\n    test::<i32>(-29, 27, 1, true);\n    test::<i64>(-29, 27, 2, true);\n    test::<i128>(-29, 27, 4, true);\n    test::<isize>(-29, 27, 8, true);\n    test::<i8>(-29, 27, 16, false);\n    test::<i16>(-29, 27, 3, false);\n    test::<i64>(-999999999999, 1, 4096, true);\n    test::<i64>(-999999999999, 1, 8192, false);\n    test::<i64>(-12345678987654321, 679, 1000, true);\n    test::<i64>(-12345678987654321, 680, 1000, false);\n    test::<i64>(-1000000001234, 999999999766, 1000, true);\n    test::<i64>(-1000000001234, 999999999767, 1000, false);\n    test::<i64>(-1000000001234, 999999998766, 1000000000000, true);\n    test::<i64>(-1000000001234, 999999998767, 1000000000000, false);\n\n    test::<i32>(-57, -57, 0, true);\n    test::<i64>(-57, -58, 0, false);\n    test::<i128>(-1000000000000, -57, 0, false);\n    test::<i16>(-13, -23, 10, true);\n    test::<i32>(-13, -24, 10, false);\n    test::<i64>(-13, -21, 1, true);\n    test::<i128>(-13, -21, 2, true);\n    test::<isize>(-13, -21, 4, true);\n    test::<i8>(-13, -21, 8, true);\n    test::<i16>(-13, -21, 16, false);\n    test::<i32>(-13, -21, 3, false);\n    test::<i64>(-1000000000001, -1, 4096, true);\n    test::<i128>(-1000000000001, -1, 8192, false);\n    test::<i64>(-12345678987654321, -321, 1000, true);\n    test::<i64>(-12345678987654321, -322, 1000, false);\n    test::<i64>(-1234, -1234, 1000000000000, true);\n    test::<i64>(-1234, -1235, 1000000000000, false);\n    test::<i64>(-1000000001234, -1000000002234, 1000, true);\n    test::<i64>(-1000000001234, -1000000002235, 1000, false);\n    test::<i64>(-1000000001234, -1234, 1000000000000, true);\n    test::<i64>(-1000000001234, -1235, 1000000000000, false);\n    test::<i64>(-1000000001234, -5000000001234, 1000000000000, true);\n    test::<i64>(-1000000001234, -5000000001235, 1000000000000, false);\n\n    test::<isize>(0, 256, -256, true);\n    test::<i16>(0, 256, -512, false);\n    test::<i16>(13, 23, -10, true);\n    test::<i32>(13, 24, -10, false);\n    test::<i64>(13, 21, -1, true);\n    test::<i128>(13, 21, -2, true);\n    test::<isize>(13, 21, -4, true);\n    test::<i8>(13, 21, -8, true);\n    test::<i16>(13, 21, -16, false);\n    test::<i32>(13, 21, -3, false);\n    test::<i64>(1000000000001, 1, -4096, true);\n    test::<i128>(1000000000001, 1, -8192, false);\n    test::<i64>(12345678987654321, 321, -1000, true);\n    test::<i64>(12345678987654321, 322, -1000, false);\n    test::<i64>(1234, 1234, -1000000000000, true);\n    test::<i64>(1234, 1235, -1000000000000, false);\n    test::<i64>(1000000001234, 1000000002234, -1000, true);\n    test::<i64>(1000000001234, 1000000002235, -1000, false);\n    test::<i64>(1000000001234, 1234, -1000000000000, true);\n    test::<i64>(1000000001234, 1235, -1000000000000, false);\n    test::<i64>(1000000001234, 5000000001234, -1000000000000, true);\n    test::<i64>(1000000001234, 5000000001235, -1000000000000, false);\n\n    test::<i128>(0, -256, -256, true);\n    test::<isize>(0, -256, -512, false);\n    test::<i8>(13, -27, -10, true);\n    test::<i16>(13, -28, -10, false);\n    test::<i32>(29, -27, -1, true);\n    test::<i64>(29, -27, -2, true);\n    test::<i128>(29, -27, -4, true);\n    test::<isize>(29, -27, -8, true);\n    test::<i8>(29, -27, -16, false);\n    test::<i16>(29, -27, -3, false);\n    test::<i64>(999999999999, -1, -4096, true);\n    test::<i64>(999999999999, -1, -8192, false);\n    test::<i64>(12345678987654321, -679, -1000, true);\n    test::<i64>(12345678987654321, -680, -1000, false);\n    test::<i64>(1000000001234, -999999999766, -1000, true);\n    test::<i64>(1000000001234, -999999999767, -1000, false);\n    test::<i64>(1000000001234, -999999998766, -1000000000000, true);\n    test::<i64>(1000000001234, -999999998767, -1000000000000, false);\n\n    test::<i8>(-13, 27, -10, true);\n    test::<i16>(-13, 28, -10, false);\n    test::<i32>(-29, 27, -1, true);\n    test::<i64>(-29, 27, -2, true);\n    test::<i128>(-29, 27, -4, true);\n    test::<isize>(-29, 27, -8, true);\n    test::<i8>(-29, 27, -16, false);\n    test::<i16>(-29, 27, -3, false);\n    test::<i64>(-999999999999, 1, -4096, true);\n    test::<i64>(-999999999999, 1, -8192, false);\n    test::<i64>(-12345678987654321, 679, -1000, true);\n    test::<i64>(-12345678987654321, 680, -1000, false);\n    test::<i64>(-1000000001234, 999999999766, -1000, true);\n    test::<i64>(-1000000001234, 999999999767, -1000, false);\n    test::<i64>(-1000000001234, 999999998766, -1000000000000, true);\n    test::<i64>(-1000000001234, 999999998767, -1000000000000, false);\n\n    test::<i16>(-13, -23, -10, true);\n    test::<i32>(-13, -24, -10, false);\n    test::<i64>(-13, -21, -1, true);\n    test::<i128>(-13, -21, -2, true);\n    test::<isize>(-13, -21, -4, true);\n    test::<i8>(-13, -21, -8, true);\n    test::<i16>(-13, -21, -16, false);\n    test::<i32>(-13, -21, -3, false);\n    test::<i64>(-1000000000001, -1, -4096, true);\n    test::<i128>(-1000000000001, -1, -8192, false);\n    test::<i64>(-12345678987654321, -321, -1000, true);\n    test::<i64>(-12345678987654321, -322, -1000, false);\n    test::<i64>(-1234, -1234, -1000000000000, true);\n    test::<i64>(-1234, -1235, -1000000000000, false);\n    test::<i64>(-1000000001234, -1000000002234, -1000, true);\n    test::<i64>(-1000000001234, -1000000002235, -1000, false);\n    test::<i64>(-1000000001234, -1234, -1000000000000, true);\n    test::<i64>(-1000000001234, -1235, -1000000000000, false);\n    test::<i64>(-1000000001234, -5000000001234, -1000000000000, true);\n    test::<i64>(-1000000001234, -5000000001235, -1000000000000, false);\n}\n\nfn eq_mod_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, m)| {\n        let equal = x.eq_mod(y, m);\n        assert_eq!(y.eq_mod(x, m), equal);\n    });\n\n    unsigned_triple_gen_var_7::<T>().test_properties(|(x, y, m)| {\n        assert!(x.eq_mod(y, m));\n        assert!(y.eq_mod(x, m));\n    });\n\n    unsigned_triple_gen_var_8::<T>().test_properties(|(x, y, m)| {\n        assert!(!x.eq_mod(y, m));\n        assert!(!y.eq_mod(x, m));\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert!(x.eq_mod(y, T::ONE));\n        assert_eq!(x.eq_mod(y, T::ZERO), x == y);\n        assert_eq!(x.eq_mod(T::ZERO, y), x.divisible_by(y));\n        assert!(x.eq_mod(x, y));\n    });\n\n    unsigned_quadruple_gen_var_10::<T>().test_properties(|(x, y, z, m)| {\n        if x.eq_mod(y, m) && y.eq_mod(z, m) {\n            assert!(x.eq_mod(z, m));\n        }\n    });\n}\n\nfn eq_mod_properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() {\n    signed_triple_gen::<S>().test_properties(|(x, y, m)| {\n        let equal = x.eq_mod(y, m);\n        assert_eq!(y.eq_mod(x, m), equal);\n\n        if x != S::MIN && y != S::MIN {\n            assert_eq!((-x).eq_mod(-y, m), equal);\n        }\n        if m != S::MIN {\n            assert_eq!(x.eq_mod(y, -m), equal);\n        }\n    });\n\n    signed_triple_gen_var_4::<U, S>().test_properties(|(x, y, m)| {\n        assert!(x.eq_mod(y, m));\n        assert!(y.eq_mod(x, m));\n    });\n\n    signed_triple_gen_var_5::<S>().test_properties(|(x, y, m)| {\n        assert!(!x.eq_mod(y, m));\n        assert!(!y.eq_mod(x, m));\n    });\n\n    signed_pair_gen::<S>().test_properties(|(x, y)| {\n        assert!(x.eq_mod(y, S::ONE));\n        assert_eq!(x.eq_mod(y, S::ZERO), x == y);\n        assert_eq!(x.eq_mod(S::ZERO, y), x.divisible_by(y));\n        assert!(x.eq_mod(x, y));\n    });\n\n    signed_quadruple_gen::<S>().test_properties(|(x, y, z, m)| {\n        if x.eq_mod(y, m) && y.eq_mod(z, m) {\n            assert!(x.eq_mod(z, m));\n        }\n    });\n}\n\n#[test]\nfn eq_mod_properties() {\n    apply_fn_to_unsigneds!(eq_mod_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(eq_mod_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_signed_signed_unsigned_quadruple_gen_var_1,\n    signed_signed_unsigned_triple_gen_var_1, signed_signed_unsigned_triple_gen_var_2,\n    signed_signed_unsigned_triple_gen_var_3, signed_unsigned_pair_gen_var_1,\n    unsigned_pair_gen_var_2, unsigned_pair_gen_var_27, unsigned_quadruple_gen_var_2,\n    unsigned_triple_gen_var_4, unsigned_triple_gen_var_9, unsigned_triple_gen_var_10,\n};\n\nfn eq_mod_power_of_2_primitive_helper<T: PrimitiveInt>() {\n    let test = |n: T, other, pow, out| {\n        assert_eq!(n.eq_mod_power_of_2(other, pow), out);\n    };\n    test(T::ZERO, T::power_of_2(T::WIDTH >> 1), T::WIDTH >> 1, true);\n    test(\n        T::ZERO,\n        T::power_of_2(T::WIDTH >> 1),\n        (T::WIDTH >> 1) + 1,\n        false,\n    );\n    test(T::exact_from(13), T::exact_from(21), 0, true);\n    test(T::exact_from(13), T::exact_from(21), 1, true);\n    test(T::exact_from(13), T::exact_from(21), 2, true);\n    test(T::exact_from(13), T::exact_from(21), 3, true);\n    test(T::exact_from(13), T::exact_from(21), 4, false);\n    test(T::exact_from(13), T::exact_from(21), 100, false);\n    test(T::MAX, T::MAX, T::WIDTH, true);\n    test(T::MAX, T::MAX, 100, true);\n    if T::WIDTH >= u64::WIDTH {\n        test(T::exact_from(1000000000001u64), T::ONE, 12, true);\n        test(T::exact_from(1000000000001u64), T::ONE, 13, false);\n        test(\n            T::exact_from(281474976710672u64),\n            T::exact_from(844424930131984u64),\n            49,\n            true,\n        );\n        test(\n            T::exact_from(281474976710672u64),\n            T::exact_from(844424930131984u64),\n            50,\n            false,\n        );\n    }\n}\n\nfn eq_mod_power_of_2_signed_helper<T: PrimitiveSigned>() {\n    let test = |n: T, other, pow, out| {\n        assert_eq!(n.eq_mod_power_of_2(other, pow), out);\n    };\n    test(T::ZERO, -T::power_of_2(T::WIDTH >> 1), T::WIDTH >> 1, true);\n    test(\n        T::ZERO,\n        -T::power_of_2(T::WIDTH >> 1),\n        (T::WIDTH >> 1) + 1,\n        false,\n    );\n    test(T::exact_from(-13), T::exact_from(27), 0, true);\n    test(T::exact_from(-13), T::exact_from(27), 1, true);\n    test(T::exact_from(-13), T::exact_from(27), 2, true);\n    test(T::exact_from(-13), T::exact_from(27), 3, true);\n    test(T::exact_from(-13), T::exact_from(27), 4, false);\n    test(T::exact_from(-13), T::exact_from(27), 100, false);\n    test(T::exact_from(13), T::exact_from(-27), 0, true);\n    test(T::exact_from(13), T::exact_from(-27), 1, true);\n    test(T::exact_from(13), T::exact_from(-27), 2, true);\n    test(T::exact_from(13), T::exact_from(-27), 3, true);\n    test(T::exact_from(13), T::exact_from(-27), 4, false);\n    test(T::exact_from(13), T::exact_from(-27), 100, false);\n    test(\n        T::NEGATIVE_ONE,\n        T::power_of_2(T::WIDTH >> 1) - T::ONE,\n        T::WIDTH >> 1,\n        true,\n    );\n    test(\n        T::power_of_2(T::WIDTH >> 1) - T::ONE,\n        T::NEGATIVE_ONE,\n        T::WIDTH >> 1,\n        true,\n    );\n    if T::WIDTH >= u64::WIDTH {\n        test(\n            T::exact_from(-1000000000001i64),\n            T::exact_from(4095),\n            13,\n            true,\n        );\n        test(\n            T::exact_from(-1000000000001i64),\n            T::exact_from(4095),\n            14,\n            false,\n        );\n        test(\n            T::exact_from(1000000000001i64),\n            T::exact_from(-4095),\n            13,\n            true,\n        );\n        test(\n            T::exact_from(1000000000001i64),\n            T::exact_from(-4095),\n            14,\n            false,\n        );\n    }\n\n    test(T::exact_from(-13), T::exact_from(-21), 0, true);\n    test(T::exact_from(-13), T::exact_from(-21), 1, true);\n    test(T::exact_from(-13), T::exact_from(-21), 2, true);\n    test(T::exact_from(-13), T::exact_from(-21), 3, true);\n    test(T::exact_from(-13), T::exact_from(-21), 4, false);\n    test(T::exact_from(-13), T::exact_from(-21), 100, false);\n    test(\n        T::power_of_2(T::WIDTH >> 1) - T::ONE,\n        T::power_of_2(T::WIDTH >> 1) - T::ONE,\n        T::WIDTH >> 1,\n        true,\n    );\n    if T::WIDTH >= u64::WIDTH {\n        test(T::exact_from(-1000000000001i64), T::NEGATIVE_ONE, 12, true);\n        test(T::exact_from(-1000000000001i64), T::NEGATIVE_ONE, 13, false);\n        test(\n            T::exact_from(-281474976710672i64),\n            T::exact_from(-844424930131984i64),\n            49,\n            true,\n        );\n        test(\n            T::exact_from(-281474976710672i64),\n            T::exact_from(-844424930131984i64),\n            50,\n            false,\n        );\n    }\n\n    if T::WIDTH >= u128::WIDTH {\n        test(\n            T::exact_from(1311693408901639117i128),\n            T::exact_from(-17135050664807912499i128),\n            64,\n            true,\n        );\n        test(\n            T::exact_from(1311693408901639117i128),\n            T::exact_from(-17135050663395328000i128),\n            64,\n            false,\n        );\n        test(\n            T::exact_from(1311693408901639117i128),\n            T::exact_from(-17135050664807912499i128),\n            65,\n            false,\n        );\n        test(\n            T::exact_from(1311693408901639117i128),\n            T::exact_from(-17135050664807912499i128),\n            128,\n            false,\n        );\n        test(\n            T::exact_from(5633680281231555440641310720i128),\n            T::exact_from(-5634717283396403096794955776i128),\n            80,\n            true,\n        );\n\n        test(\n            T::exact_from(-1311693408901639117i128),\n            T::exact_from(17135050664807912499i128),\n            64,\n            true,\n        );\n        test(\n            T::exact_from(-1311693408901639117i128),\n            T::exact_from(17135050663395328000i128),\n            64,\n            false,\n        );\n        test(\n            T::exact_from(-1311693408901639117i128),\n            T::exact_from(17135050664807912499i128),\n            65,\n            false,\n        );\n        test(\n            T::exact_from(-1311693408901639117i128),\n            T::exact_from(17135050664807912499i128),\n            128,\n            false,\n        );\n        test(\n            T::exact_from(-5633680281231555440641310720i128),\n            T::exact_from(5634717283396403096794955776i128),\n            80,\n            true,\n        );\n    }\n}\n\n#[test]\nfn test_eq_mod_power_of_2() {\n    apply_fn_to_primitive_ints!(eq_mod_power_of_2_primitive_helper);\n    apply_fn_to_signeds!(eq_mod_power_of_2_signed_helper);\n}\n\nfn eq_mod_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_4::<T, u64>().test_properties(|(x, y, pow)| {\n        let eq_mod_power_of_2 = x.eq_mod_power_of_2(y, pow);\n        assert_eq!(y.eq_mod_power_of_2(x, pow), eq_mod_power_of_2);\n        assert_eq!(\n            x.mod_power_of_2(pow) == y.mod_power_of_2(pow),\n            eq_mod_power_of_2\n        );\n    });\n\n    unsigned_triple_gen_var_9::<T>().test_properties(|(x, y, pow)| {\n        assert!(x.eq_mod_power_of_2(y, pow));\n        assert!(y.eq_mod_power_of_2(x, pow));\n        assert_eq!(x.mod_power_of_2(pow), y.mod_power_of_2(pow));\n    });\n\n    unsigned_triple_gen_var_10::<T>().test_properties(|(x, y, pow)| {\n        assert!(!x.eq_mod_power_of_2(y, pow));\n        assert!(!y.eq_mod_power_of_2(x, pow));\n        assert_ne!(x.mod_power_of_2(pow), y.mod_power_of_2(pow));\n    });\n\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, pow)| {\n        assert!(n.eq_mod_power_of_2(n, pow));\n        assert_eq!(\n            n.eq_mod_power_of_2(T::ZERO, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n        assert_eq!(\n            T::ZERO.eq_mod_power_of_2(n, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n    });\n\n    unsigned_quadruple_gen_var_2::<T, u64>().test_properties(|(x, y, z, pow)| {\n        if x.eq_mod_power_of_2(y, pow) && y.eq_mod_power_of_2(z, pow) {\n            assert!(x.eq_mod_power_of_2(z, pow));\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert!(x.eq_mod_power_of_2(y, 0));\n    });\n}\n\nfn eq_mod_power_of_2_properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    signed_signed_unsigned_triple_gen_var_2::<S, u64>().test_properties(|(x, y, pow)| {\n        let eq_mod_power_of_2 = x.eq_mod_power_of_2(y, pow);\n        assert_eq!(y.eq_mod_power_of_2(x, pow), eq_mod_power_of_2);\n        assert_eq!(\n            U::wrapping_from(x).mod_power_of_2(pow) == U::wrapping_from(y).mod_power_of_2(pow),\n            eq_mod_power_of_2,\n        );\n    });\n\n    signed_signed_unsigned_triple_gen_var_1::<U, S>().test_properties(|(x, y, pow)| {\n        assert!(x.eq_mod_power_of_2(y, pow));\n        assert!(y.eq_mod_power_of_2(x, pow));\n        assert_eq!(\n            U::wrapping_from(x).mod_power_of_2(pow),\n            U::wrapping_from(y).mod_power_of_2(pow),\n        );\n    });\n\n    signed_signed_unsigned_triple_gen_var_3::<S>().test_properties(|(x, y, pow)| {\n        assert!(!x.eq_mod_power_of_2(y, pow));\n        assert!(!y.eq_mod_power_of_2(x, pow));\n        assert_ne!(\n            U::wrapping_from(x).mod_power_of_2(pow),\n            U::wrapping_from(y).mod_power_of_2(pow),\n        );\n    });\n\n    signed_unsigned_pair_gen_var_1::<S, u64>().test_properties(|(n, pow)| {\n        assert!(n.eq_mod_power_of_2(n, pow));\n        assert_eq!(\n            n.eq_mod_power_of_2(S::ZERO, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n        assert_eq!(\n            S::ZERO.eq_mod_power_of_2(n, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n    });\n\n    signed_signed_signed_unsigned_quadruple_gen_var_1::<S, u64>().test_properties(\n        |(x, y, z, pow)| {\n            if x.eq_mod_power_of_2(y, pow) && y.eq_mod_power_of_2(z, pow) {\n                assert!(x.eq_mod_power_of_2(z, pow));\n            }\n        },\n    );\n\n    signed_pair_gen::<S>().test_properties(|(x, y)| {\n        assert!(x.eq_mod_power_of_2(y, 0));\n    });\n}\n\n#[test]\nfn eq_mod_power_of_2_properties() {\n    apply_fn_to_unsigneds!(eq_mod_power_of_2_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(eq_mod_power_of_2_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::extended_gcd::extended_gcd_unsigned_binary;\nuse malachite_base::num::arithmetic::traits::{ExtendedGcd, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen, unsigned_gen, unsigned_pair_gen_var_27,\n};\nuse malachite_base::test_util::num::arithmetic::extended_gcd::extended_gcd_unsigned_euclidean;\nuse std::cmp::min;\n\n#[test]\nfn test_extended_gcd() {\n    fn test_u<\n        U: ExtendedGcd<Cofactor = S> + PrimitiveUnsigned + WrappingFrom<S>,\n        S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n    >(\n        a: U,\n        b: U,\n        gcd: U,\n        x: S,\n        y: S,\n    ) {\n        assert_eq!(a.extended_gcd(b), (gcd, x, y));\n        assert_eq!(extended_gcd_unsigned_euclidean(a, b), (gcd, x, y));\n        assert_eq!(extended_gcd_unsigned_binary::<U, S>(a, b), (gcd, x, y));\n    }\n    test_u::<u8, _>(0, 0, 0, 0, 0);\n    test_u::<u8, _>(0, 1, 1, 0, 1);\n    test_u::<u8, _>(1, 0, 1, 1, 0);\n    test_u::<u8, _>(1, 1, 1, 0, 1);\n    test_u::<u16, _>(0, 6, 6, 0, 1);\n    test_u::<u32, _>(6, 0, 6, 1, 0);\n    test_u::<u64, _>(1, 6, 1, 1, 0);\n    test_u::<usize, _>(6, 1, 1, 0, 1);\n    test_u::<u128, _>(6, 6, 6, 0, 1);\n    test_u::<u128, _>(8, 12, 4, -1, 1);\n    test_u::<u8, _>(54, 24, 6, 1, -2);\n    test_u::<u16, _>(42, 56, 14, -1, 1);\n    test_u::<u32, _>(48, 18, 6, -1, 3);\n    test_u::<u64, _>(3, 5, 1, 2, -1);\n    test_u::<usize, _>(12, 60, 12, 1, 0);\n    test_u::<u128, _>(12, 90, 6, -7, 1);\n    test_u::<u16, _>(240, 46, 2, -9, 47);\n\n    fn test_s<U: PrimitiveUnsigned, S: ExtendedGcd<Gcd = U> + PrimitiveSigned>(\n        a: S,\n        b: S,\n        gcd: U,\n        x: S,\n        y: S,\n    ) {\n        assert_eq!(a.extended_gcd(b), (gcd, x, y));\n    }\n    test_s::<_, i8>(0, 0, 0, 0, 0);\n    test_s::<_, i8>(0, 1, 1, 0, 1);\n    test_s::<_, i8>(0, -1, 1, 0, -1);\n    test_s::<_, i8>(1, 0, 1, 1, 0);\n    test_s::<_, i8>(-1, 0, 1, -1, 0);\n    test_s::<_, i8>(1, 1, 1, 0, 1);\n    test_s::<_, i8>(1, -1, 1, 0, -1);\n    test_s::<_, i8>(-1, 1, 1, 0, 1);\n    test_s::<_, i8>(-1, -1, 1, 0, -1);\n    test_s::<_, i16>(0, 6, 6, 0, 1);\n    test_s::<_, i16>(0, -6, 6, 0, -1);\n    test_s::<_, i32>(6, 0, 6, 1, 0);\n    test_s::<_, i32>(-6, 0, 6, -1, 0);\n    test_s::<_, i64>(1, 6, 1, 1, 0);\n    test_s::<_, i64>(1, -6, 1, 1, 0);\n    test_s::<_, i64>(-1, 6, 1, -1, 0);\n    test_s::<_, i64>(-1, -6, 1, -1, 0);\n    test_s::<_, isize>(6, 1, 1, 0, 1);\n    test_s::<_, isize>(6, -1, 1, 0, -1);\n    test_s::<_, isize>(-6, 1, 1, 0, 1);\n    test_s::<_, isize>(-6, -1, 1, 0, -1);\n    test_s::<_, i128>(6, 6, 6, 0, 1);\n    test_s::<_, i128>(6, -6, 6, 0, -1);\n    test_s::<_, i128>(-6, 6, 6, 0, 1);\n    test_s::<_, i128>(-6, -6, 6, 0, -1);\n    test_s::<_, i128>(8, 12, 4, -1, 1);\n    test_s::<_, i8>(54, 24, 6, 1, -2);\n    test_s::<_, i16>(42, 56, 14, -1, 1);\n    test_s::<_, i32>(48, 18, 6, -1, 3);\n    test_s::<_, i64>(3, 5, 1, 2, -1);\n    test_s::<_, i128>(12, 90, 6, -7, 1);\n    test_s::<_, i16>(240, 46, 2, -9, 47);\n    test_s::<_, i16>(240, -46, 2, -9, -47);\n    test_s::<_, i16>(-240, 46, 2, 9, 47);\n    test_s::<_, i16>(-240, -46, 2, 9, -47);\n    test_s::<_, i8>(-128, -128, 128, 0, -1);\n    test_s::<_, i8>(0, -128, 128, 0, -1);\n    test_s::<_, i8>(-128, 0, 128, -1, 0);\n    test_s::<_, isize>(12, 60, 12, 1, 0);\n    test_s::<_, isize>(-12, 60, 12, -1, 0);\n    test_s::<_, isize>(12, -60, 12, 1, 0);\n    test_s::<_, isize>(-12, -60, 12, -1, 0);\n    test_s::<_, isize>(60, 12, 12, 0, 1);\n    test_s::<_, isize>(-60, 12, 12, 0, 1);\n    test_s::<_, isize>(60, -12, 12, 0, -1);\n    test_s::<_, isize>(-60, -12, 12, 0, -1);\n}\n\nfn extended_gcd_properties_helper_unsigned<\n    U: ExtendedGcd<Cofactor = S> + PrimitiveUnsigned + WrappingFrom<S>,\n    S: TryFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() {\n    unsigned_pair_gen_var_27::<U>().test_properties(|(a, b)| {\n        let (gcd, x, y) = a.extended_gcd(b);\n        assert_eq!(a.gcd(b), gcd);\n        assert_eq!(\n            S::wrapping_from(a)\n                .wrapping_mul(x)\n                .wrapping_add(S::wrapping_from(b).wrapping_mul(y)),\n            S::wrapping_from(gcd)\n        );\n        if let (Ok(a), Ok(b), Ok(gcd)) = (S::try_from(a), S::try_from(b), S::try_from(gcd))\n            && let (Some(ax), Some(by)) = (a.checked_mul(x), b.checked_mul(y))\n        {\n            assert_eq!(ax + by, gcd);\n        }\n\n        // uniqueness\n        if a != U::ZERO && b != U::ZERO && gcd != min(a, b) {\n            assert!(x.unsigned_abs() <= (b / gcd) >> 1);\n            assert!(y.unsigned_abs() <= (a / gcd) >> 1);\n        }\n\n        let reverse = b.extended_gcd(a);\n        if a == b {\n            assert_eq!(reverse, (gcd, x, y));\n        } else {\n            assert_eq!(reverse, (gcd, y, x));\n        }\n\n        assert_eq!(extended_gcd_unsigned_euclidean(a, b), (gcd, x, y));\n        assert_eq!(extended_gcd_unsigned_binary::<U, S>(a, b), (gcd, x, y));\n    });\n\n    unsigned_gen::<U>().test_properties(|x| {\n        if x != U::ZERO {\n            assert_eq!(x.extended_gcd(x), (x, S::ZERO, S::ONE));\n            assert_eq!(x.extended_gcd(U::ZERO), (x, S::ONE, S::ZERO));\n            assert_eq!(U::ZERO.extended_gcd(x), (x, S::ZERO, S::ONE));\n        }\n        if x != U::ONE {\n            assert_eq!(U::ONE.extended_gcd(x), (U::ONE, S::ONE, S::ZERO));\n        }\n        assert_eq!(x.extended_gcd(U::ONE), (U::ONE, S::ZERO, S::ONE));\n    });\n}\n\nfn extended_gcd_properties_helper_signed<\n    U: TryFrom<S> + PrimitiveUnsigned,\n    S: ExtendedGcd<Gcd = U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>() {\n    signed_pair_gen::<S>().test_properties(|(a, b)| {\n        let (gcd, x, y) = a.extended_gcd(b);\n        assert!(gcd >= U::ZERO);\n        let abs_a = a.unsigned_abs();\n        let abs_b = b.unsigned_abs();\n        assert_eq!(abs_a.gcd(abs_b), gcd);\n        let s_gcd = a.wrapping_mul(x).wrapping_add(b.wrapping_mul(y));\n        assert_eq!(s_gcd.unsigned_abs(), gcd);\n        if let (Some(ax), Some(by)) = (a.checked_mul(x), b.checked_mul(y)) {\n            assert_eq!(U::exact_from(ax + by), gcd);\n        }\n\n        // uniqueness\n        if a != S::ZERO && b != S::ZERO && gcd != min(abs_a, abs_b) {\n            assert!(x.unsigned_abs() <= (abs_b / gcd) >> 1);\n            assert!(y.unsigned_abs() <= (abs_a / gcd) >> 1);\n        }\n\n        let reverse = b.extended_gcd(a);\n        if a == b {\n            assert_eq!(reverse, (gcd, x, y));\n        } else if b != S::MIN && a == -b {\n            assert_eq!(reverse, (gcd, x, -y));\n        } else {\n            assert_eq!(reverse, (gcd, y, x));\n        }\n    });\n\n    signed_gen::<S>().test_properties(|x| {\n        if x != S::ZERO {\n            assert_eq!(\n                x.extended_gcd(x),\n                (\n                    x.unsigned_abs(),\n                    S::ZERO,\n                    if x >= S::ZERO {\n                        S::ONE\n                    } else {\n                        S::NEGATIVE_ONE\n                    }\n                )\n            );\n            if x != S::MIN {\n                assert_eq!(\n                    x.extended_gcd(-x),\n                    (\n                        x.unsigned_abs(),\n                        S::ZERO,\n                        if x < S::ZERO { S::ONE } else { S::NEGATIVE_ONE }\n                    )\n                );\n            }\n            assert_eq!(\n                x.extended_gcd(S::ZERO),\n                (\n                    x.unsigned_abs(),\n                    if x >= S::ZERO {\n                        S::ONE\n                    } else {\n                        S::NEGATIVE_ONE\n                    },\n                    S::ZERO\n                )\n            );\n            assert_eq!(\n                S::ZERO.extended_gcd(x),\n                (\n                    x.unsigned_abs(),\n                    S::ZERO,\n                    if x >= S::ZERO {\n                        S::ONE\n                    } else {\n                        S::NEGATIVE_ONE\n                    }\n                )\n            );\n        }\n        if x.unsigned_abs() != U::ONE {\n            assert_eq!(S::ONE.extended_gcd(x), (U::ONE, S::ONE, S::ZERO));\n        }\n        assert_eq!(x.extended_gcd(S::ONE), (U::ONE, S::ZERO, S::ONE));\n    });\n}\n\n#[test]\nfn extended_gcd_properties() {\n    apply_fn_to_unsigned_signed_pairs!(extended_gcd_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(extended_gcd_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::factorial::checked_multifactorial_naive;\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_23, unsigned_gen_var_24, unsigned_gen_var_25,\n    unsigned_pair_gen_var_12, unsigned_pair_gen_var_43,\n};\nuse malachite_base::test_util::num::arithmetic::factorial::{\n    checked_double_factorial_naive, checked_factorial_naive, checked_subfactorial_naive,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_factorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: T) {\n        assert_eq!(T::factorial(n), out);\n    }\n    test::<u8>(0, 1);\n    test::<u8>(1, 1);\n    test::<u8>(2, 2);\n    test::<u8>(3, 6);\n    test::<u8>(4, 24);\n    test::<u8>(5, 120);\n    test::<u32>(10, 3628800);\n}\n\nfn factorial_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::factorial(100));\n}\n\n#[test]\nfn factorial_fail() {\n    apply_fn_to_unsigneds!(factorial_fail_helper);\n}\n\n#[test]\nfn test_checked_factorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: Option<T>) {\n        assert_eq!(T::checked_factorial(n), out);\n        assert_eq!(checked_factorial_naive(n), out);\n    }\n    test::<u8>(0, Some(1));\n    test::<u8>(1, Some(1));\n    test::<u8>(2, Some(2));\n    test::<u8>(3, Some(6));\n    test::<u8>(4, Some(24));\n    test::<u8>(5, Some(120));\n    test::<u32>(10, Some(3628800));\n\n    test::<u8>(6, None);\n    test::<u32>(100, None);\n}\n\n#[test]\nfn test_double_factorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: T) {\n        assert_eq!(T::double_factorial(n), out);\n    }\n    test::<u8>(0, 1);\n    test::<u8>(1, 1);\n    test::<u8>(2, 2);\n    test::<u8>(3, 3);\n    test::<u8>(4, 8);\n    test::<u8>(5, 15);\n    test::<u8>(6, 48);\n    test::<u8>(7, 105);\n    test::<u32>(19, 654729075);\n    test::<u32>(20, 3715891200);\n}\n\nfn double_factorial_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::double_factorial(100));\n}\n\n#[test]\nfn double_factorial_fail() {\n    apply_fn_to_unsigneds!(double_factorial_fail_helper);\n}\n\n#[test]\nfn test_checked_double_factorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: Option<T>) {\n        assert_eq!(T::checked_double_factorial(n), out);\n        assert_eq!(checked_double_factorial_naive(n), out);\n    }\n    test::<u8>(0, Some(1));\n    test::<u8>(1, Some(1));\n    test::<u8>(2, Some(2));\n    test::<u8>(3, Some(3));\n    test::<u8>(4, Some(8));\n    test::<u8>(5, Some(15));\n    test::<u8>(6, Some(48));\n    test::<u8>(7, Some(105));\n    test::<u32>(19, Some(654729075));\n    test::<u32>(20, Some(3715891200));\n\n    test::<u8>(8, None);\n    test::<u32>(100, None);\n}\n\n#[test]\nfn test_multifactorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, m: u64, out: T) {\n        assert_eq!(T::multifactorial(n, m), out);\n    }\n    test::<u8>(0, 1, 1);\n    test::<u8>(1, 1, 1);\n    test::<u8>(2, 1, 2);\n    test::<u8>(3, 1, 6);\n    test::<u8>(4, 1, 24);\n    test::<u8>(5, 1, 120);\n\n    test::<u8>(0, 2, 1);\n    test::<u8>(1, 2, 1);\n    test::<u8>(2, 2, 2);\n    test::<u8>(3, 2, 3);\n    test::<u8>(4, 2, 8);\n    test::<u8>(5, 2, 15);\n    test::<u8>(6, 2, 48);\n    test::<u8>(7, 2, 105);\n\n    test::<u8>(0, 3, 1);\n    test::<u8>(1, 3, 1);\n    test::<u8>(2, 3, 2);\n    test::<u8>(3, 3, 3);\n    test::<u8>(4, 3, 4);\n    test::<u8>(5, 3, 10);\n    test::<u8>(6, 3, 18);\n    test::<u8>(7, 3, 28);\n    test::<u8>(8, 3, 80);\n    test::<u8>(9, 3, 162);\n\n    test::<u32>(10, 1, 3628800);\n    test::<u32>(20, 2, 3715891200);\n    test::<u32>(25, 3, 608608000);\n}\n\nfn multifactorial_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::multifactorial(1, 0));\n    assert_panic!(T::multifactorial(100, 1));\n}\n\n#[test]\nfn multifactorial_fail() {\n    apply_fn_to_unsigneds!(multifactorial_fail_helper);\n}\n\n#[test]\nfn test_checked_multifactorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, m: u64, out: Option<T>) {\n        assert_eq!(T::checked_multifactorial(n, m), out);\n        assert_eq!(checked_multifactorial_naive(n, m), out);\n    }\n    test::<u8>(0, 1, Some(1));\n    test::<u8>(1, 1, Some(1));\n    test::<u8>(2, 1, Some(2));\n    test::<u8>(3, 1, Some(6));\n    test::<u8>(4, 1, Some(24));\n    test::<u8>(5, 1, Some(120));\n\n    test::<u8>(0, 2, Some(1));\n    test::<u8>(1, 2, Some(1));\n    test::<u8>(2, 2, Some(2));\n    test::<u8>(3, 2, Some(3));\n    test::<u8>(4, 2, Some(8));\n    test::<u8>(5, 2, Some(15));\n    test::<u8>(6, 2, Some(48));\n    test::<u8>(7, 2, Some(105));\n\n    test::<u8>(0, 3, Some(1));\n    test::<u8>(1, 3, Some(1));\n    test::<u8>(2, 3, Some(2));\n    test::<u8>(3, 3, Some(3));\n    test::<u8>(4, 3, Some(4));\n    test::<u8>(5, 3, Some(10));\n    test::<u8>(6, 3, Some(18));\n    test::<u8>(7, 3, Some(28));\n    test::<u8>(8, 3, Some(80));\n    test::<u8>(9, 3, Some(162));\n\n    test::<u32>(10, 1, Some(3628800));\n    test::<u32>(20, 2, Some(3715891200));\n    test::<u32>(25, 3, Some(608608000));\n\n    test::<u8>(6, 1, None);\n    test::<u8>(8, 2, None);\n    test::<u8>(10, 3, None);\n    test::<u32>(100, 1, None);\n    test::<u32>(100, 2, None);\n    test::<u32>(100, 3, None);\n}\n\nfn checked_multifactorial_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::checked_multifactorial(1, 0));\n}\n\n#[test]\nfn checked_multifactorial_fail() {\n    apply_fn_to_unsigneds!(checked_multifactorial_fail_helper);\n}\n\n#[test]\nfn test_subfactorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: T) {\n        assert_eq!(T::subfactorial(n), out);\n    }\n    test::<u8>(0, 1);\n    test::<u8>(1, 0);\n    test::<u8>(2, 1);\n    test::<u8>(3, 2);\n    test::<u8>(4, 9);\n    test::<u8>(5, 44);\n    test::<u32>(10, 1334961);\n}\n\nfn subfactorial_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::subfactorial(100));\n}\n\n#[test]\nfn subfactorial_fail() {\n    apply_fn_to_unsigneds!(subfactorial_fail_helper);\n}\n\n#[test]\nfn test_checked_subfactorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: Option<T>) {\n        assert_eq!(T::checked_subfactorial(n), out);\n        assert_eq!(checked_subfactorial_naive(n), out);\n    }\n    test::<u8>(0, Some(1));\n    test::<u8>(1, Some(0));\n    test::<u8>(2, Some(1));\n    test::<u8>(3, Some(2));\n    test::<u8>(4, Some(9));\n    test::<u8>(5, Some(44));\n    test::<u32>(10, Some(1334961));\n\n    test::<u8>(6, None);\n    test::<u32>(100, None);\n}\n\nfn factorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_23::<T>().test_properties(|n| {\n        let f = T::factorial(n);\n        assert_eq!(T::checked_factorial(n), Some(f));\n        assert_eq!(T::multifactorial(n, 1), f);\n        assert_ne!(f, T::ZERO);\n        if n != 0 {\n            assert_eq!(f / T::factorial(n - 1), T::exact_from(n));\n        }\n    });\n}\n\n#[test]\nfn factorial_properties() {\n    apply_fn_to_unsigneds!(factorial_properties_helper);\n}\n\nfn checked_factorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen().test_properties(|n| {\n        let of = T::checked_factorial(n);\n        assert_eq!(checked_factorial_naive(n), of);\n        assert_eq!(T::checked_multifactorial(n, 1), of);\n        assert_ne!(of, Some(T::ZERO));\n        if let Some(f) = of {\n            assert_eq!(T::factorial(n), f);\n        }\n        if n != u64::MAX && of.is_none() {\n            assert!(T::checked_factorial(n + 1).is_none());\n        }\n    });\n}\n\n#[test]\nfn checked_factorial_properties() {\n    apply_fn_to_unsigneds!(checked_factorial_properties_helper);\n}\n\nfn double_factorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_24::<T>().test_properties(|n| {\n        let f = T::double_factorial(n);\n        assert_eq!(T::checked_double_factorial(n), Some(f));\n        assert_eq!(T::multifactorial(n, 2), f);\n        assert_ne!(f, T::ZERO);\n        if n > 1 {\n            assert_eq!(f / T::double_factorial(n - 2), T::exact_from(n));\n        }\n    });\n}\n\n#[test]\nfn double_factorial_properties() {\n    apply_fn_to_unsigneds!(double_factorial_properties_helper);\n}\n\nfn checked_double_factorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen().test_properties(|n| {\n        let of = T::checked_double_factorial(n);\n        assert_eq!(checked_double_factorial_naive(n), of);\n        assert_eq!(T::checked_multifactorial(n, 2), of);\n        assert_ne!(of, Some(T::ZERO));\n        if let Some(f) = of {\n            assert_eq!(T::double_factorial(n), f);\n        }\n        if n != u64::MAX && of.is_none() {\n            assert!(T::checked_double_factorial(n + 1).is_none());\n        }\n    });\n}\n\n#[test]\nfn checked_double_factorial_properties() {\n    apply_fn_to_unsigneds!(checked_double_factorial_properties_helper);\n}\n\nfn multifactorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_43::<T>().test_properties(|(n, m)| {\n        let f = T::multifactorial(n, m);\n        assert_eq!(T::checked_multifactorial(n, m), Some(f));\n        assert_ne!(f, T::ZERO);\n        if n >= m {\n            assert_eq!(f / T::multifactorial(n - m, m), T::exact_from(n));\n        }\n    });\n}\n\n#[test]\nfn multifactorial_properties() {\n    apply_fn_to_unsigneds!(multifactorial_properties_helper);\n}\n\nfn checked_multifactorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<u64, u64>().test_properties(|(n, m)| {\n        let of = T::checked_multifactorial(n, m);\n        assert_eq!(checked_multifactorial_naive(n, m), of);\n        assert_ne!(of, Some(T::ZERO));\n        if let Some(f) = of {\n            assert_eq!(T::multifactorial(n, m), f);\n        }\n        if n != u64::MAX && of.is_none() {\n            assert!(T::checked_multifactorial(n + 1, m).is_none());\n        }\n    });\n}\n\n#[test]\nfn checked_multifactorial_properties() {\n    apply_fn_to_unsigneds!(checked_multifactorial_properties_helper);\n}\n\nfn subfactorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_25::<T>().test_properties(|n| {\n        let f = T::subfactorial(n);\n        assert_eq!(T::checked_subfactorial(n), Some(f));\n        if n != 1 {\n            assert_ne!(f, T::ZERO);\n        }\n        if n != 0 && n != 2 {\n            let g = if n.even() { f - T::ONE } else { f + T::ONE };\n            assert_eq!(g / T::subfactorial(n - 1), T::exact_from(n));\n        }\n    });\n}\n\n#[test]\nfn subfactorial_properties() {\n    apply_fn_to_unsigneds!(subfactorial_properties_helper);\n}\n\nfn checked_subfactorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen().test_properties(|n| {\n        let of = T::checked_subfactorial(n);\n        assert_eq!(checked_subfactorial_naive(n), of);\n        if n != 1 {\n            assert_ne!(of, Some(T::ZERO));\n        }\n        if let Some(f) = of {\n            assert_eq!(T::subfactorial(n), f);\n        }\n        if n != u64::MAX && of.is_none() {\n            assert!(T::checked_subfactorial(n + 1).is_none());\n        }\n    });\n}\n\n#[test]\nfn checked_subfactorial_properties() {\n    apply_fn_to_unsigneds!(checked_subfactorial_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/floor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen;\n\nfn floor_assign_primitive_float_helper<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(NiceFloat(n.floor()), NiceFloat(out));\n\n        let mut n = n;\n        n.floor_assign();\n        assert_eq!(NiceFloat(n), NiceFloat(out));\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::NEGATIVE_ZERO, T::NEGATIVE_ZERO);\n    test(T::INFINITY, T::INFINITY);\n    test(T::NEGATIVE_INFINITY, T::NEGATIVE_INFINITY);\n    test(T::NAN, T::NAN);\n    test(T::ONE, T::ONE);\n    test(T::NEGATIVE_ONE, T::NEGATIVE_ONE);\n    test(T::from(1.5f32), T::from(1.0f32));\n    test(T::from(-1.5f32), T::from(-2.0f32));\n}\n\n#[test]\nfn test_floor_assign() {\n    apply_fn_to_primitive_floats!(floor_assign_primitive_float_helper);\n}\n\nfn floor_assign_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|f| {\n        let mut floor = f;\n        floor.floor_assign();\n        assert_eq!(NiceFloat(floor), NiceFloat(f.floor()));\n        assert_eq!(NiceFloat(floor.floor()), NiceFloat(floor));\n        assert_eq!(NiceFloat(-floor), NiceFloat((-f).ceiling()));\n        assert_eq!(f.sign(), floor.sign());\n    });\n}\n\n#[test]\nfn floor_assign_properties() {\n    apply_fn_to_primitive_floats!(floor_assign_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::gcd::{gcd_binary, gcd_euclidean, gcd_fast_a, gcd_fast_b};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_gcd() {\n    fn test<T: PrimitiveUnsigned>(x: T, y: T, out: T) {\n        assert_eq!(x.gcd(y), out);\n\n        let mut x = x;\n        x.gcd_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, 0);\n    test::<u16>(0, 6, 6);\n    test::<u32>(6, 0, 6);\n    test::<u64>(1, 6, 1);\n    test::<u128>(6, 1, 1);\n    test::<usize>(8, 12, 4);\n    test::<u8>(54, 24, 6);\n    test::<u16>(42, 56, 14);\n    test::<u32>(48, 18, 6);\n    test::<u64>(3, 5, 1);\n    test::<u128>(12, 60, 12);\n    test::<usize>(12, 90, 6);\n}\n\nfn gcd_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let gcd = x.gcd(y);\n        assert_eq!(gcd_euclidean(x, y), gcd);\n        assert_eq!(gcd_binary(x, y), gcd);\n        assert_eq!(gcd_fast_a(x, y), gcd);\n        assert_eq!(gcd_fast_b(x, y), gcd);\n\n        let mut x_mut = x;\n        x_mut.gcd_assign(y);\n        assert_eq!(x_mut, gcd);\n\n        assert_eq!(y.gcd(x), gcd);\n        assert!(x.divisible_by(gcd));\n        assert!(y.divisible_by(gcd));\n        if gcd != T::ZERO {\n            assert!((x.div_exact(gcd)).coprime_with(y.div_exact(gcd)));\n        }\n        assert_eq!(gcd == T::ZERO, x == T::ZERO && y == T::ZERO);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.gcd(x), x);\n        assert_eq!(x.gcd(T::ONE), T::ONE);\n        assert_eq!(x.gcd(T::ZERO), x);\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        assert_eq!(x.gcd(y).gcd(z), x.gcd(y.gcd(z)));\n    });\n}\n\n#[test]\nfn gcd_properties() {\n    apply_fn_to_unsigneds!(gcd_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::test_util::generators::primitive_float_gen;\n\nfn is_power_of_2_helper<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(n.is_power_of_2(), out);\n    };\n    test(T::ZERO, false);\n    test(T::NEGATIVE_ZERO, false);\n    test(T::INFINITY, false);\n    test(T::NEGATIVE_INFINITY, false);\n    test(T::NAN, false);\n    test(T::NEGATIVE_ONE, false);\n    test(T::from(1.5f32), false);\n    test(T::from(-1.5f32), false);\n\n    test(T::ONE, true);\n    test(T::TWO, true);\n    test(T::from(4.0f32), true);\n    test(T::from(0.5f32), true);\n    test(T::from(0.25f32), true);\n}\n\n#[test]\nfn test_is_power_of_2() {\n    apply_fn_to_primitive_floats!(is_power_of_2_helper);\n}\n\nfn is_power_of_2_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|f| {\n        if f.is_power_of_2() {\n            assert_eq!(f.precision(), 1);\n            assert_eq!(T::power_of_2(f.checked_log_base_2().unwrap()), f);\n        }\n    });\n}\n\n#[test]\nfn is_power_of_2_properties() {\n    apply_fn_to_primitive_floats!(is_power_of_2_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::kronecker_symbol::{\n    jacobi_symbol_unsigned_double_fast_2, jacobi_symbol_unsigned_simple,\n};\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{HasHalf, JoinHalves, WrappingFrom};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_13, signed_pair_gen, signed_pair_gen_var_8, signed_pair_gen_var_9,\n    signed_pair_gen_var_10, signed_triple_gen, signed_triple_gen_var_6, signed_triple_gen_var_7,\n    unsigned_gen, unsigned_gen_var_22, unsigned_pair_gen_var_27, unsigned_pair_gen_var_40,\n    unsigned_pair_gen_var_41, unsigned_pair_gen_var_42, unsigned_quadruple_gen_var_12,\n    unsigned_triple_gen_var_19, unsigned_triple_gen_var_22, unsigned_triple_gen_var_23,\n};\nuse malachite_base::test_util::num::arithmetic::kronecker_symbol::{\n    jacobi_symbol_unsigned_double_fast_1, jacobi_symbol_unsigned_double_simple,\n    jacobi_symbol_unsigned_fast_1, jacobi_symbol_unsigned_fast_2_1,\n    jacobi_symbol_unsigned_fast_2_2, jacobi_symbol_unsigned_fast_2_3,\n    jacobi_symbol_unsigned_fast_2_4,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_jacobi_symbol() {\n    fn test_u<T: PrimitiveUnsigned>(a: T, n: T, s: i8) {\n        assert_eq!(a.legendre_symbol(n), s);\n        assert_eq!(a.jacobi_symbol(n), s);\n        assert_eq!(a.kronecker_symbol(n), s);\n        assert_eq!(jacobi_symbol_unsigned_simple(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_1(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_1(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_2(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_3(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_4(a, n), s);\n    }\n    test_u::<u8>(0, 1, 1);\n    test_u::<u8>(0, 3, 0);\n    test_u::<u8>(1, 3, 1);\n    test_u::<u8>(2, 3, -1);\n    test_u::<u8>(0, 5, 0);\n    test_u::<u8>(1, 5, 1);\n    test_u::<u8>(2, 5, -1);\n    test_u::<u8>(3, 5, -1);\n    test_u::<u8>(4, 5, 1);\n    test_u::<u8>(0, 7, 0);\n    test_u::<u8>(1, 7, 1);\n    test_u::<u8>(2, 7, 1);\n    test_u::<u8>(3, 7, -1);\n    test_u::<u8>(4, 7, 1);\n    test_u::<u8>(5, 7, -1);\n    test_u::<u8>(6, 7, -1);\n    test_u::<u8>(0, 9, 0);\n    test_u::<u8>(1, 9, 1);\n    test_u::<u8>(2, 9, 1);\n    test_u::<u8>(3, 9, 0);\n    test_u::<u8>(4, 9, 1);\n    test_u::<u8>(5, 9, 1);\n    test_u::<u8>(6, 9, 0);\n    test_u::<u8>(7, 9, 1);\n    test_u::<u8>(8, 9, 1);\n\n    test_u::<u8>(7, 7, 0);\n    test_u::<u8>(8, 7, 1);\n    test_u::<u8>(9, 7, 1);\n    test_u::<u8>(10, 7, -1);\n    test_u::<u8>(11, 7, 1);\n    test_u::<u8>(12, 7, -1);\n    test_u::<u8>(13, 7, -1);\n    test_u::<u8>(9, 9, 0);\n    test_u::<u8>(10, 9, 1);\n    test_u::<u8>(11, 9, 1);\n    test_u::<u8>(12, 9, 0);\n    test_u::<u8>(13, 9, 1);\n    test_u::<u8>(14, 9, 1);\n    test_u::<u8>(15, 9, 0);\n    test_u::<u8>(16, 9, 1);\n    test_u::<u8>(17, 9, 1);\n\n    test_u::<u16>(1001, 9907, -1);\n    test_u::<u16>(10908, 9907, -1);\n\n    fn test_s<U: PrimitiveUnsigned, S: ModPowerOf2<Output = U> + PrimitiveSigned>(\n        a: S,\n        n: S,\n        s: i8,\n    ) {\n        assert_eq!(a.legendre_symbol(n), s);\n        assert_eq!(a.jacobi_symbol(n), s);\n        assert_eq!(a.kronecker_symbol(n), s);\n    }\n    test_s::<u8, i8>(0, 1, 1);\n    test_s::<u8, i8>(0, 3, 0);\n    test_s::<u8, i8>(1, 3, 1);\n    test_s::<u8, i8>(2, 3, -1);\n    test_s::<u8, i8>(0, 5, 0);\n    test_s::<u8, i8>(1, 5, 1);\n    test_s::<u8, i8>(2, 5, -1);\n    test_s::<u8, i8>(3, 5, -1);\n    test_s::<u8, i8>(4, 5, 1);\n    test_s::<u8, i8>(0, 7, 0);\n    test_s::<u8, i8>(1, 7, 1);\n    test_s::<u8, i8>(2, 7, 1);\n    test_s::<u8, i8>(3, 7, -1);\n    test_s::<u8, i8>(4, 7, 1);\n    test_s::<u8, i8>(5, 7, -1);\n    test_s::<u8, i8>(6, 7, -1);\n    test_s::<u8, i8>(0, 9, 0);\n    test_s::<u8, i8>(1, 9, 1);\n    test_s::<u8, i8>(2, 9, 1);\n    test_s::<u8, i8>(3, 9, 0);\n    test_s::<u8, i8>(4, 9, 1);\n    test_s::<u8, i8>(5, 9, 1);\n    test_s::<u8, i8>(6, 9, 0);\n    test_s::<u8, i8>(7, 9, 1);\n    test_s::<u8, i8>(8, 9, 1);\n\n    test_s::<u8, i8>(7, 7, 0);\n    test_s::<u8, i8>(8, 7, 1);\n    test_s::<u8, i8>(9, 7, 1);\n    test_s::<u8, i8>(10, 7, -1);\n    test_s::<u8, i8>(11, 7, 1);\n    test_s::<u8, i8>(12, 7, -1);\n    test_s::<u8, i8>(13, 7, -1);\n    test_s::<u8, i8>(9, 9, 0);\n    test_s::<u8, i8>(10, 9, 1);\n    test_s::<u8, i8>(11, 9, 1);\n    test_s::<u8, i8>(12, 9, 0);\n    test_s::<u8, i8>(13, 9, 1);\n    test_s::<u8, i8>(14, 9, 1);\n    test_s::<u8, i8>(15, 9, 0);\n    test_s::<u8, i8>(16, 9, 1);\n    test_s::<u8, i8>(17, 9, 1);\n\n    test_s::<u8, i8>(-7, 7, 0);\n    test_s::<u8, i8>(-6, 7, 1);\n    test_s::<u8, i8>(-5, 7, 1);\n    test_s::<u8, i8>(-4, 7, -1);\n    test_s::<u8, i8>(-3, 7, 1);\n    test_s::<u8, i8>(-2, 7, -1);\n    test_s::<u8, i8>(-1, 7, -1);\n    test_s::<u8, i8>(-9, 9, 0);\n    test_s::<u8, i8>(-8, 9, 1);\n    test_s::<u8, i8>(-7, 9, 1);\n    test_s::<u8, i8>(-6, 9, 0);\n    test_s::<u8, i8>(-5, 9, 1);\n    test_s::<u8, i8>(-4, 9, 1);\n    test_s::<u8, i8>(-3, 9, 0);\n    test_s::<u8, i8>(-2, 9, 1);\n    test_s::<u8, i8>(-1, 9, 1);\n\n    test_s::<u16, i16>(1001, 9907, -1);\n    test_s::<u16, i16>(10908, 9907, -1);\n    test_s::<u16, i16>(-8906, 9907, -1);\n}\n\nfn jacobi_symbol_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::ONE.jacobi_symbol(T::TWO));\n}\n\nfn jacobi_symbol_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::ONE.jacobi_symbol(T::NEGATIVE_ONE));\n}\n\n#[test]\nfn jacobi_symbol_fail() {\n    apply_fn_to_primitive_ints!(jacobi_symbol_fail_helper);\n    apply_fn_to_signeds!(jacobi_symbol_fail_helper_signed);\n}\n\n#[test]\nfn test_jacobi_symbol_unsigned_double() {\n    fn test<T: PrimitiveUnsigned, D: HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned>(\n        x_1: T,\n        x_0: T,\n        y_1: T,\n        y_0: T,\n        s: i8,\n    ) {\n        assert_eq!(\n            jacobi_symbol_unsigned_double_simple::<T, D>(x_1, x_0, y_1, y_0),\n            s\n        );\n        assert_eq!(jacobi_symbol_unsigned_double_fast_1(x_1, x_0, y_1, y_0), s);\n        assert_eq!(jacobi_symbol_unsigned_double_fast_2(x_1, x_0, y_1, y_0), s);\n    }\n    // - fast_1: y_1 == T::ZERO || y_0 == T::ZERO first time\n    // - fast_2: y_1 == T::ZERO && y_0 == T::ONE\n    test::<u64, u128>(0, 0, 0, 1, 1);\n    // - fast_1: y_1 != T::ZERO && y_0 != T::ZERO first time\n    // - fast_1: x_1 != T::ZERO && x_0 != T::ZERO\n    // - fast_1: x_0 != T::ZERO first time\n    // - fast_1: c != T::WIDTH first time\n    // - fast_1: diff_0 != T::ZERO && diff_1 != T::ZERO\n    // - fast_1: diff_1.get_highest_bit()\n    // - fast_1: y_1 != T::ZERO && y_0 != T::ZERO second time\n    // - fast_1: x_0 == T::ZERO second time\n    // - fast_1: c != T::WIDTH second time\n    // - fast_1: bit.even()\n    // - fast_2: y_1 != T::ZERO || y_0 != T::ONE\n    // - fast_2: x_0 != T::ZERO first time\n    // - fast_2: x_0.odd()\n    // - fast_2: x_1 == T::ZERO second time\n    // - fast_2: y_1 != T::ZERO\n    // - fast_2: skip_loop\n    // - fast_2: y_0 != T::ONE second time\n    // - fast_2: x_0 == T::ZERO fourth time\n    // - fast_2: x_1 != T::ZERO fourth time\n    // - fast_2: !bit.get_bit(1)\n    test::<u64, u128>(0, 3, 2, 3, 1);\n    // - fast_1: x_1 == T::ZERO || x_0 == T::ZERO\n    // - fast_2: x_0 == T::ZERO first time\n    // - fast_2: x_1 == T::ZERO first time\n    test::<u64, u128>(0, 0, 0, 3, 0);\n    // - fast_1: t != T::ZERO\n    // - fast_1: c == T::WIDTH third time\n    // - fast_2: y_0 == T::ONE second time\n    test::<u64, u128>(0, 1, 1, 1, 1);\n    // - fast_1: c != T::WIDTH third time\n    test::<u64, u128>(0, 1, 1, 3, 1);\n    // - fast_1: x_0 == T::ZERO first time\n    // - fast_2: x_1 != T::ZERO first time\n    // - fast_2: y_0 == T::ONE first time\n    test::<u64, u128>(1, 0, 0, 3, 1);\n    // - fast_1: bit.odd()\n    // - fast_2: x_1 != T::ZERO second time\n    // - fast_2: !skip_loop\n    // - fast_2: x_0 != T::ZERO fourth time\n    // - fast_2: bit.get_bit(1)\n    test::<u64, u128>(1, 1, 0, 3, -1);\n    // - fast_1: t == T::ZERO\n    // - fast_2: x_1 == y_1 first time\n    // - fast_2: x_1 == y_1 second time\n    // - fast_2: x_0 >= y_0\n    // - fast_2: x_0 == T::ZERO third time\n    test::<u64, u128>(1, 1, 1, 1, 0);\n    // - fast_1: y_1 == T::ZERO || y_0 == T::ZERO second time\n    test::<u64, u128>(0, 1, 2, 1, 1);\n    // - fast_1: x_0 != T::ZERO second time\n    // - fast_1: c == T::WIDTH second time\n    // - fast_2: x_1 != y_1 first time\n    // - fast_2: x_1 != T::ZERO third time\n    // - fast_2: y_0 == T::ZERO\n    test::<u64, u128>(1, 1, 2, 1, 1);\n    // - fast_1: !diff_1.get_highest_bit()\n    test::<u64, u128>(2, 1, 0, 3, 0);\n    // - fast_1: diff_0 == T::ZERO || diff_1 == T::ZERO\n    test::<u64, u128>(2, 1, 2, 1, 0);\n    // - fast_1: c == T::WIDTH first time\n    // - fast_2: x_0.even()\n    // - fast_2: y_0 != T::ZERO\n    test::<u8, u16>(242, 128, 173, 173, -1);\n    // - fast_2: y_1 == T::ZERO\n    test::<u8, u16>(0, 1, 0, 3, 1);\n    // - fast_2: x_0 < y_0\n    // - fast_2: x_0 != T::ZERO third time\n    // - fast_2: x_0 == T::ONE\n    test::<u8, u16>(1, 1, 1, 3, 1);\n    // - fast_2: x_0 != T::ONE\n    test::<u8, u16>(1, 1, 1, 7, -1);\n    // - fast_2: x_1 != y_1 second time\n    test::<u8, u16>(1, 1, 2, 3, 1);\n    // - fast_2: x_0 == T::ZERO second time\n    test::<u8, u16>(2, 1, 1, 1, 1);\n    // - fast_2: x_0 != T::ZERO second time\n    // - fast_2: x_1 == T::ZERO third time\n    test::<u8, u16>(2, 1, 1, 3, -1);\n    // - fast_2: y_0 != T::ONE first time\n    test::<u8, u16>(3, 0, 0, 3, 0);\n}\n\n// Odd n is already tested in test_jacobi_symbol, so here we just test even n\n#[test]\nfn test_kronecker_symbol() {\n    fn test_u<T: PrimitiveUnsigned>(a: T, n: T, s: i8) {\n        assert_eq!(a.kronecker_symbol(n), s);\n    }\n    test_u::<u8>(0, 2, 0);\n    test_u::<u8>(1, 2, 1);\n    test_u::<u8>(2, 2, 0);\n    test_u::<u8>(3, 2, -1);\n    test_u::<u8>(4, 2, 0);\n    test_u::<u8>(5, 2, -1);\n    test_u::<u8>(6, 2, 0);\n    test_u::<u8>(7, 2, 1);\n    test_u::<u8>(0, 4, 0);\n    test_u::<u8>(1, 4, 1);\n    test_u::<u8>(2, 4, 0);\n    test_u::<u8>(3, 4, 1);\n    test_u::<u8>(0, 6, 0);\n    test_u::<u8>(1, 6, 1);\n    test_u::<u8>(2, 6, 0);\n    test_u::<u8>(3, 6, 0);\n    test_u::<u8>(4, 6, 0);\n    test_u::<u8>(5, 6, 1);\n    test_u::<u8>(6, 6, 0);\n    test_u::<u8>(7, 6, 1);\n    test_u::<u8>(8, 6, 0);\n    test_u::<u8>(9, 6, 0);\n    test_u::<u8>(10, 6, 0);\n    test_u::<u8>(11, 6, 1);\n    test_u::<u8>(12, 6, 0);\n    test_u::<u8>(13, 6, -1);\n    test_u::<u8>(14, 6, 0);\n    test_u::<u8>(15, 6, 0);\n    test_u::<u8>(16, 6, 0);\n    test_u::<u8>(17, 6, -1);\n    test_u::<u8>(18, 6, 0);\n    test_u::<u8>(19, 6, -1);\n    test_u::<u8>(20, 6, 0);\n    test_u::<u8>(21, 6, 0);\n    test_u::<u8>(22, 6, 0);\n    test_u::<u8>(23, 6, -1);\n\n    test_u::<u16>(1001, 9908, -1);\n    test_u::<u16>(10909, 9908, -1);\n\n    fn test_s<U: PrimitiveUnsigned, S: ModPowerOf2<Output = U> + PrimitiveSigned>(\n        a: S,\n        n: S,\n        s: i8,\n    ) {\n        assert_eq!(a.kronecker_symbol(n), s);\n    }\n    test_s::<u8, i8>(0, 2, 0);\n    test_s::<u8, i8>(1, 2, 1);\n    test_s::<u8, i8>(2, 2, 0);\n    test_s::<u8, i8>(3, 2, -1);\n    test_s::<u8, i8>(4, 2, 0);\n    test_s::<u8, i8>(5, 2, -1);\n    test_s::<u8, i8>(6, 2, 0);\n    test_s::<u8, i8>(7, 2, 1);\n    test_s::<u8, i8>(0, 4, 0);\n    test_s::<u8, i8>(1, 4, 1);\n    test_s::<u8, i8>(2, 4, 0);\n    test_s::<u8, i8>(3, 4, 1);\n    test_s::<u8, i8>(0, 6, 0);\n    test_s::<u8, i8>(1, 6, 1);\n    test_s::<u8, i8>(2, 6, 0);\n    test_s::<u8, i8>(3, 6, 0);\n    test_s::<u8, i8>(4, 6, 0);\n    test_s::<u8, i8>(5, 6, 1);\n    test_s::<u8, i8>(6, 6, 0);\n    test_s::<u8, i8>(7, 6, 1);\n    test_s::<u8, i8>(8, 6, 0);\n    test_s::<u8, i8>(9, 6, 0);\n    test_s::<u8, i8>(10, 6, 0);\n    test_s::<u8, i8>(11, 6, 1);\n    test_s::<u8, i8>(12, 6, 0);\n    test_s::<u8, i8>(13, 6, -1);\n    test_s::<u8, i8>(14, 6, 0);\n    test_s::<u8, i8>(15, 6, 0);\n    test_s::<u8, i8>(16, 6, 0);\n    test_s::<u8, i8>(17, 6, -1);\n    test_s::<u8, i8>(18, 6, 0);\n    test_s::<u8, i8>(19, 6, -1);\n    test_s::<u8, i8>(20, 6, 0);\n    test_s::<u8, i8>(21, 6, 0);\n    test_s::<u8, i8>(22, 6, 0);\n    test_s::<u8, i8>(23, 6, -1);\n\n    test_s::<u8, i8>(-1, 2, 1);\n    test_s::<u8, i8>(-2, 2, 0);\n    test_s::<u8, i8>(-3, 2, -1);\n    test_s::<u8, i8>(-4, 2, 0);\n    test_s::<u8, i8>(-5, 2, -1);\n    test_s::<u8, i8>(-6, 2, 0);\n    test_s::<u8, i8>(-7, 2, 1);\n    test_s::<u8, i8>(-1, 4, 1);\n    test_s::<u8, i8>(-2, 4, 0);\n    test_s::<u8, i8>(-3, 4, 1);\n    test_s::<u8, i8>(-1, 6, -1);\n    test_s::<u8, i8>(-2, 6, 0);\n    test_s::<u8, i8>(-3, 6, 0);\n    test_s::<u8, i8>(-4, 6, 0);\n    test_s::<u8, i8>(-5, 6, -1);\n    test_s::<u8, i8>(-6, 6, 0);\n    test_s::<u8, i8>(-7, 6, -1);\n    test_s::<u8, i8>(-8, 6, 0);\n    test_s::<u8, i8>(-9, 6, 0);\n    test_s::<u8, i8>(-10, 6, 0);\n    test_s::<u8, i8>(-11, 6, -1);\n    test_s::<u8, i8>(-12, 6, 0);\n    test_s::<u8, i8>(-13, 6, 1);\n    test_s::<u8, i8>(-14, 6, 0);\n    test_s::<u8, i8>(-15, 6, 0);\n    test_s::<u8, i8>(-16, 6, 0);\n    test_s::<u8, i8>(-17, 6, 1);\n    test_s::<u8, i8>(-18, 6, 0);\n    test_s::<u8, i8>(-19, 6, 1);\n    test_s::<u8, i8>(-20, 6, 0);\n    test_s::<u8, i8>(-21, 6, 0);\n    test_s::<u8, i8>(-22, 6, 0);\n    test_s::<u8, i8>(-23, 6, 1);\n\n    test_s::<u8, i8>(0, -2, 0);\n    test_s::<u8, i8>(1, -2, 1);\n    test_s::<u8, i8>(2, -2, 0);\n    test_s::<u8, i8>(3, -2, -1);\n    test_s::<u8, i8>(4, -2, 0);\n    test_s::<u8, i8>(5, -2, -1);\n    test_s::<u8, i8>(6, -2, 0);\n    test_s::<u8, i8>(7, -2, 1);\n    test_s::<u8, i8>(0, -4, 0);\n    test_s::<u8, i8>(1, -4, 1);\n    test_s::<u8, i8>(2, -4, 0);\n    test_s::<u8, i8>(3, -4, 1);\n    test_s::<u8, i8>(0, -6, 0);\n    test_s::<u8, i8>(1, -6, 1);\n    test_s::<u8, i8>(2, -6, 0);\n    test_s::<u8, i8>(3, -6, 0);\n    test_s::<u8, i8>(4, -6, 0);\n    test_s::<u8, i8>(5, -6, 1);\n    test_s::<u8, i8>(6, -6, 0);\n    test_s::<u8, i8>(7, -6, 1);\n    test_s::<u8, i8>(8, -6, 0);\n    test_s::<u8, i8>(9, -6, 0);\n    test_s::<u8, i8>(10, -6, 0);\n    test_s::<u8, i8>(11, -6, 1);\n    test_s::<u8, i8>(12, -6, 0);\n    test_s::<u8, i8>(13, -6, -1);\n    test_s::<u8, i8>(14, -6, 0);\n    test_s::<u8, i8>(15, -6, 0);\n    test_s::<u8, i8>(16, -6, 0);\n    test_s::<u8, i8>(17, -6, -1);\n    test_s::<u8, i8>(18, -6, 0);\n    test_s::<u8, i8>(19, -6, -1);\n    test_s::<u8, i8>(20, -6, 0);\n    test_s::<u8, i8>(21, -6, 0);\n    test_s::<u8, i8>(22, -6, 0);\n    test_s::<u8, i8>(23, -6, -1);\n\n    test_s::<u8, i8>(-1, -2, -1);\n    test_s::<u8, i8>(-2, -2, 0);\n    test_s::<u8, i8>(-3, -2, 1);\n    test_s::<u8, i8>(-4, -2, 0);\n    test_s::<u8, i8>(-5, -2, 1);\n    test_s::<u8, i8>(-6, -2, 0);\n    test_s::<u8, i8>(-7, -2, -1);\n    test_s::<u8, i8>(-1, -4, -1);\n    test_s::<u8, i8>(-2, -4, 0);\n    test_s::<u8, i8>(-3, -4, -1);\n    test_s::<u8, i8>(-1, -6, 1);\n    test_s::<u8, i8>(-2, -6, 0);\n    test_s::<u8, i8>(-3, -6, 0);\n    test_s::<u8, i8>(-4, -6, 0);\n    test_s::<u8, i8>(-5, -6, 1);\n    test_s::<u8, i8>(-6, -6, 0);\n    test_s::<u8, i8>(-7, -6, 1);\n    test_s::<u8, i8>(-8, -6, 0);\n    test_s::<u8, i8>(-9, -6, 0);\n    test_s::<u8, i8>(-10, -6, 0);\n    test_s::<u8, i8>(-11, -6, 1);\n    test_s::<u8, i8>(-12, -6, 0);\n    test_s::<u8, i8>(-13, -6, -1);\n    test_s::<u8, i8>(-14, -6, 0);\n    test_s::<u8, i8>(-15, -6, 0);\n    test_s::<u8, i8>(-16, -6, 0);\n    test_s::<u8, i8>(-17, -6, -1);\n    test_s::<u8, i8>(-18, -6, 0);\n    test_s::<u8, i8>(-19, -6, -1);\n    test_s::<u8, i8>(-20, -6, 0);\n    test_s::<u8, i8>(-21, -6, 0);\n    test_s::<u8, i8>(-22, -6, 0);\n    test_s::<u8, i8>(-23, -6, -1);\n\n    test_s::<u16, i16>(1001, -9908, -1);\n    test_s::<u16, i16>(10909, -9908, -1);\n    test_s::<u16, i16>(-8907, -9908, 1);\n}\n\nfn jacobi_symbol_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_40::<T>().test_properties(|(a, n)| {\n        let s = a.jacobi_symbol(n);\n        assert_eq!(a.legendre_symbol(n), s);\n        assert_eq!(a.kronecker_symbol(n), s);\n        assert_eq!(jacobi_symbol_unsigned_simple(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_1(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_1(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_2(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_3(a, n), s);\n        assert_eq!(jacobi_symbol_unsigned_fast_2_4(a, n), s);\n        assert!(s.le_abs(&1i8));\n\n        if let Some(b) = a.checked_add(n) {\n            assert_eq!(b.jacobi_symbol(n), s);\n        }\n        if let Some(b) = a.checked_sub(n) {\n            assert_eq!(b.jacobi_symbol(n), s);\n        }\n        assert_eq!(s != 0, a.coprime_with(n));\n        if let Some(b) = a.checked_mul(T::TWO) {\n            let n_mod_8: u8 = n.mod_power_of_2(3).wrapping_into();\n            assert_eq!(\n                b.jacobi_symbol(n),\n                if n_mod_8 == 1 || n_mod_8 == 7 { s } else { -s }\n            );\n        }\n    });\n\n    unsigned_pair_gen_var_41::<T>().test_properties(|(m, n)| {\n        let n_mod_4: u8 = n.mod_power_of_2(2).wrapping_into();\n        let m_mod_4: u8 = m.mod_power_of_2(2).wrapping_into();\n        assert_eq!(\n            m.jacobi_symbol(n) * n.jacobi_symbol(m),\n            if n_mod_4 == 1 || m_mod_4 == 1 { 1 } else { -1 }\n        );\n    });\n\n    unsigned_triple_gen_var_22::<T>().test_properties(|(a, b, n)| {\n        if let Some(c) = a.checked_mul(b) {\n            assert_eq!(c.jacobi_symbol(n), a.jacobi_symbol(n) * b.jacobi_symbol(n));\n        }\n    });\n\n    unsigned_triple_gen_var_23::<T>().test_properties(|(a, m, n)| {\n        if let Some(o) = m.checked_mul(n) {\n            assert_eq!(a.jacobi_symbol(o), a.jacobi_symbol(m) * a.jacobi_symbol(n));\n        }\n    });\n\n    unsigned_gen_var_22::<T>().test_properties(|n| {\n        if n != T::ONE {\n            assert_eq!(T::ZERO.jacobi_symbol(n), 0);\n            assert_eq!(n.jacobi_symbol(n), 0);\n        }\n        assert_eq!(T::ONE.jacobi_symbol(n), 1);\n        assert_eq!(n.jacobi_symbol(T::ONE), 1);\n        let n_mod_4: u8 = n.mod_power_of_2(2).wrapping_into();\n        assert_eq!(\n            (n - T::ONE).jacobi_symbol(n),\n            if n_mod_4 == 1 { 1 } else { -1 }\n        );\n        let n_mod_8: u8 = n.mod_power_of_2(3).wrapping_into();\n        assert_eq!(\n            T::TWO.jacobi_symbol(n),\n            if n_mod_8 == 1 || n_mod_8 == 7 { 1 } else { -1 }\n        );\n    });\n}\n\nfn jacobi_symbol_properties_double_helper_unsigned<\n    T: PrimitiveUnsigned,\n    D: HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned,\n>() {\n    unsigned_quadruple_gen_var_12::<T>().test_properties(|(x_1, x_0, y_1, y_0)| {\n        let s = jacobi_symbol_unsigned_double_simple::<T, D>(x_1, x_0, y_1, y_0);\n        assert_eq!(jacobi_symbol_unsigned_double_fast_1(x_1, x_0, y_1, y_0), s);\n        assert_eq!(jacobi_symbol_unsigned_double_fast_2(x_1, x_0, y_1, y_0), s);\n    });\n}\n\nfn jacobi_symbol_properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: ModPowerOf2<Output = U> + PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() {\n    signed_pair_gen_var_8::<U, S>().test_properties(|(a, n)| {\n        let s = a.jacobi_symbol(n);\n        assert_eq!(a.legendre_symbol(n), s);\n        assert_eq!(a.kronecker_symbol(n), s);\n        assert!(s.le_abs(&1i8));\n\n        if let Some(b) = a.checked_add(n) {\n            assert_eq!(b.jacobi_symbol(n), s);\n        }\n        if let Some(b) = a.checked_sub(n) {\n            assert_eq!(b.jacobi_symbol(n), s);\n        }\n        assert_eq!(s != 0, a.unsigned_abs().coprime_with(n.unsigned_abs()));\n        if let Some(b) = a.checked_mul(S::TWO) {\n            let n_mod_8: u8 = n.mod_power_of_2(3).wrapping_into();\n            assert_eq!(\n                b.jacobi_symbol(n),\n                if n_mod_8 == 1 || n_mod_8 == 7 { s } else { -s }\n            );\n        }\n        if let Some(b) = a.checked_neg() {\n            let n_mod_4: u8 = n.mod_power_of_2(2).wrapping_into();\n            assert_eq!(b.jacobi_symbol(n), if n_mod_4 == 1 { s } else { -s });\n        }\n    });\n\n    signed_pair_gen_var_9::<U, S>().test_properties(|(m, n)| {\n        let n_mod_4: u8 = n.mod_power_of_2(2).wrapping_into();\n        let m_mod_4: u8 = m.mod_power_of_2(2).wrapping_into();\n        assert_eq!(\n            m.jacobi_symbol(n) * n.jacobi_symbol(m),\n            if n_mod_4 == 1 || m_mod_4 == 1 { 1 } else { -1 }\n        );\n    });\n\n    signed_triple_gen_var_6::<U, S>().test_properties(|(a, b, n)| {\n        if let Some(c) = a.checked_mul(b) {\n            assert_eq!(c.jacobi_symbol(n), a.jacobi_symbol(n) * b.jacobi_symbol(n));\n        }\n    });\n\n    signed_triple_gen_var_7::<U, S>().test_properties(|(a, m, n)| {\n        if let Some(o) = m.checked_mul(n) {\n            assert_eq!(a.jacobi_symbol(o), a.jacobi_symbol(m) * a.jacobi_symbol(n));\n        }\n    });\n\n    signed_gen_var_13::<U, S>().test_properties(|n| {\n        if n != S::ONE {\n            assert_eq!(S::ZERO.jacobi_symbol(n), 0);\n            assert_eq!(n.jacobi_symbol(n), 0);\n        }\n        assert_eq!(S::ONE.jacobi_symbol(n), 1);\n        assert_eq!(n.jacobi_symbol(S::ONE), 1);\n        let n_mod_4: u8 = n.mod_power_of_2(2).wrapping_into();\n        assert_eq!(\n            S::NEGATIVE_ONE.jacobi_symbol(n),\n            if n_mod_4 == 1 { 1 } else { -1 }\n        );\n        let n_mod_8: u8 = n.mod_power_of_2(3).wrapping_into();\n        assert_eq!(\n            S::TWO.jacobi_symbol(n),\n            if n_mod_8 == 1 || n_mod_8 == 7 { 1 } else { -1 }\n        );\n    });\n}\n\n#[test]\nfn jacobi_symbol_properties() {\n    apply_fn_to_unsigneds!(jacobi_symbol_properties_helper_unsigned);\n    jacobi_symbol_properties_double_helper_unsigned::<u8, u16>();\n    jacobi_symbol_properties_double_helper_unsigned::<u16, u32>();\n    jacobi_symbol_properties_double_helper_unsigned::<u32, u64>();\n    jacobi_symbol_properties_double_helper_unsigned::<u64, u128>();\n    apply_fn_to_unsigned_signed_pairs!(jacobi_symbol_properties_helper_signed);\n}\n\nfn kronecker_symbol_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, n)| {\n        let s = a.kronecker_symbol(n);\n        assert!(s.le_abs(&1i8));\n\n        assert_eq!(s != 0, a.coprime_with(n));\n        let n_mod_4: u8 = n.mod_power_of_2(2).wrapping_into();\n        if n_mod_4 == 2 {\n            if let Some(four_n) = n.checked_mul(T::from(4u8)) {\n                if let Some(b) = a.checked_add(four_n) {\n                    assert_eq!(b.kronecker_symbol(n), s);\n                }\n                if let Some(b) = a.checked_sub(four_n) {\n                    assert_eq!(b.kronecker_symbol(n), s);\n                }\n            }\n        } else {\n            if let Some(b) = a.checked_add(n) {\n                assert_eq!(b.kronecker_symbol(n), s);\n            }\n            if let Some(b) = a.checked_sub(n) {\n                assert_eq!(b.kronecker_symbol(n), s);\n            }\n        }\n        let a_mod_4: u8 = a.mod_power_of_2(2).wrapping_into();\n        if a != T::ZERO && a_mod_4 != 3 {\n            if a_mod_4 == 2 {\n                if let Some(four_a) = a.checked_mul(T::from(4u8)) {\n                    if let Some(m) = n.checked_add(four_a) {\n                        assert_eq!(a.kronecker_symbol(m), s);\n                    }\n                    if let Some(m) = n.checked_sub(four_a) {\n                        assert_eq!(a.kronecker_symbol(m), s);\n                    }\n                }\n            } else {\n                if let Some(m) = n.checked_add(a) {\n                    assert_eq!(a.kronecker_symbol(m), s);\n                }\n                if let Some(m) = n.checked_sub(a) {\n                    assert_eq!(a.kronecker_symbol(m), s);\n                }\n            }\n        }\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        if let Some(p) = x.checked_mul(y) {\n            assert_eq!(\n                p.kronecker_symbol(z),\n                x.kronecker_symbol(z) * y.kronecker_symbol(z)\n            );\n        }\n        if let Some(p) = y.checked_mul(z) {\n            assert_eq!(\n                x.kronecker_symbol(p),\n                x.kronecker_symbol(y) * x.kronecker_symbol(z)\n            );\n        }\n    });\n\n    unsigned_pair_gen_var_42::<T>().test_properties(|(m, n)| {\n        let n_odd = if n == T::ZERO {\n            T::ONE\n        } else {\n            n >> n.trailing_zeros()\n        };\n        let m_odd = if m == T::ZERO {\n            T::ONE\n        } else {\n            m >> m.trailing_zeros()\n        };\n        let n_odd_mod_4: u8 = n_odd.mod_power_of_2(2).wrapping_into();\n        let m_odd_mod_4: u8 = m_odd.mod_power_of_2(2).wrapping_into();\n        let p = if n_odd_mod_4 == 1 || m_odd_mod_4 == 1 {\n            1\n        } else {\n            -1\n        };\n        assert_eq!(m.kronecker_symbol(n) * n.kronecker_symbol(m), p);\n    });\n\n    unsigned_gen().test_properties(|n| {\n        if n != T::ONE {\n            assert_eq!(T::ZERO.kronecker_symbol(n), 0);\n            assert_eq!(n.kronecker_symbol(n), 0);\n        }\n        assert_eq!(T::ONE.kronecker_symbol(n), 1);\n        assert_eq!(n.kronecker_symbol(T::ONE), 1);\n    });\n}\n\nfn kronecker_symbol_properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: ModPowerOf2<Output = U> + PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() {\n    signed_pair_gen::<S>().test_properties(|(a, n)| {\n        let s = a.kronecker_symbol(n);\n        assert!(s.le_abs(&1i8));\n\n        assert_eq!(s != 0, a.unsigned_abs().coprime_with(n.unsigned_abs()));\n        let n_mod_4: u8 = n.mod_power_of_2(2).wrapping_into();\n        if n_mod_4 == 2 {\n            if let Some(four_n) = n.checked_mul(S::from(4i8)) {\n                if let Some(b) = a.checked_add(four_n)\n                    && (n > S::ZERO || a.sign() == b.sign())\n                {\n                    assert_eq!(b.kronecker_symbol(n), s);\n                }\n                if let Some(b) = a.checked_sub(four_n)\n                    && (n > S::ZERO || a.sign() == b.sign())\n                {\n                    assert_eq!(b.kronecker_symbol(n), s);\n                }\n            }\n        } else {\n            if let Some(b) = a.checked_add(n)\n                && (n > S::ZERO || a.sign() == b.sign())\n            {\n                assert_eq!(b.kronecker_symbol(n), s);\n            }\n            if let Some(b) = a.checked_sub(n)\n                && (n > S::ZERO || a.sign() == b.sign())\n            {\n                assert_eq!(b.kronecker_symbol(n), s);\n            }\n        }\n        let a_mod_4: u8 = a.mod_power_of_2(2).wrapping_into();\n        if a != S::ZERO\n            && a_mod_4 != 3\n            && let Some(abs_a) = a.checked_abs()\n        {\n            if a_mod_4 == 2 {\n                if let Some(four_abs_a) = abs_a.checked_mul(S::from(4i8)) {\n                    if let Some(m) = n.checked_add(four_abs_a) {\n                        assert_eq!(a.kronecker_symbol(m), s);\n                    }\n                    if let Some(m) = n.checked_sub(four_abs_a) {\n                        assert_eq!(a.kronecker_symbol(m), s);\n                    }\n                }\n            } else {\n                if let Some(m) = n.checked_add(abs_a) {\n                    assert_eq!(a.kronecker_symbol(m), s);\n                }\n                if let Some(m) = n.checked_sub(abs_a) {\n                    assert_eq!(a.kronecker_symbol(m), s);\n                }\n            }\n        }\n\n        let m = a;\n        if let Some(m_abs) = m.checked_abs() {\n            let m_odd = if m == S::ZERO {\n                S::ONE\n            } else {\n                m >> m.trailing_zeros()\n            };\n            let m_odd_mod_4: u8 = m_odd.mod_power_of_2(2).wrapping_into();\n            // -m won't overflow since m.checked_abs() is Some\n            let m_star = if m_odd_mod_4 == 1 { m } else { -m };\n            assert_eq!(m_star.kronecker_symbol(n), n.kronecker_symbol(m_abs));\n        }\n    });\n\n    signed_triple_gen::<S>().test_properties(|(x, y, z)| {\n        if !(z == S::NEGATIVE_ONE && (x == S::ZERO && y < S::ZERO || x < S::ZERO && y == S::ZERO))\n            && let Some(p) = x.checked_mul(y)\n        {\n            assert_eq!(\n                p.kronecker_symbol(z),\n                x.kronecker_symbol(z) * y.kronecker_symbol(z)\n            );\n        }\n        let y_odd_mod_4: u8 = if y == S::ZERO {\n            0\n        } else {\n            (y >> y.trailing_zeros()).mod_power_of_2(2).wrapping_into()\n        };\n        let z_odd_mod_4: u8 = if z == S::ZERO {\n            0\n        } else {\n            (z >> z.trailing_zeros()).mod_power_of_2(2).wrapping_into()\n        };\n        if !(x == S::NEGATIVE_ONE\n            && (y == S::ZERO && z_odd_mod_4 == 3 || y_odd_mod_4 == 3 && z == S::ZERO))\n            && let Some(p) = y.checked_mul(z)\n        {\n            assert_eq!(\n                x.kronecker_symbol(p),\n                x.kronecker_symbol(y) * x.kronecker_symbol(z)\n            );\n        }\n    });\n\n    signed_pair_gen_var_10::<U, S>().test_properties(|(m, n)| {\n        let n_odd = if n == S::ZERO {\n            S::ONE\n        } else {\n            n >> n.trailing_zeros()\n        };\n        let m_odd = if m == S::ZERO {\n            S::ONE\n        } else {\n            m >> m.trailing_zeros()\n        };\n        let n_odd_mod_4: u8 = n_odd.mod_power_of_2(2).wrapping_into();\n        let m_odd_mod_4: u8 = m_odd.mod_power_of_2(2).wrapping_into();\n        let p = if n_odd_mod_4 == 1 || m_odd_mod_4 == 1 {\n            1\n        } else {\n            -1\n        };\n        assert_eq!(\n            m.kronecker_symbol(n) * n.kronecker_symbol(m),\n            if m < S::ZERO && n < S::ZERO { -p } else { p }\n        );\n        if let Some(m_abs) = m.checked_abs() {\n            assert_eq!(m.kronecker_symbol(n) * n.kronecker_symbol(m_abs), p);\n        }\n    });\n\n    signed_gen().test_properties(|n| {\n        if n != S::ONE && n != S::NEGATIVE_ONE {\n            assert_eq!(S::ZERO.kronecker_symbol(n), 0);\n            assert_eq!(n.kronecker_symbol(n), 0);\n        }\n        assert_eq!(S::ONE.kronecker_symbol(n), 1);\n        assert_eq!(n.kronecker_symbol(S::ONE), 1);\n        let n_odd = if n == S::ZERO {\n            S::ONE\n        } else {\n            n >> n.trailing_zeros()\n        };\n        let n_odd_mod_4: u8 = n_odd.mod_power_of_2(2).wrapping_into();\n        assert_eq!(\n            S::NEGATIVE_ONE.kronecker_symbol(n),\n            if n_odd_mod_4 == 1 { 1 } else { -1 }\n        );\n        assert_eq!(\n            n.kronecker_symbol(S::NEGATIVE_ONE),\n            if n >= S::ZERO { 1 } else { -1 }\n        );\n    });\n}\n\n#[test]\nfn kronecker_symbol_properties() {\n    apply_fn_to_unsigneds!(kronecker_symbol_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(kronecker_symbol_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/lcm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_33, unsigned_pair_gen_var_34, unsigned_triple_gen_var_19,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_lcm() {\n    fn test<T: PrimitiveUnsigned>(x: T, y: T, out: T) {\n        assert_eq!(x.lcm(y), out);\n\n        let mut x = x;\n        x.lcm_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, 0);\n    test::<u16>(0, 6, 0);\n    test::<u32>(6, 0, 0);\n    test::<u64>(1, 6, 6);\n    test::<u128>(6, 1, 6);\n    test::<usize>(8, 12, 24);\n    test::<u8>(54, 24, 216);\n    test::<u16>(42, 56, 168);\n    test::<u32>(48, 18, 144);\n    test::<u64>(3, 5, 15);\n    test::<u128>(12, 60, 60);\n    test::<usize>(12, 90, 180);\n}\n\nfn lcm_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::MAX.lcm(T::TWO));\n    assert_panic!({\n        let mut x = T::MAX;\n        x.lcm_assign(T::TWO);\n    });\n}\n\n#[test]\nfn lcm_fail() {\n    apply_fn_to_unsigneds!(lcm_fail_helper);\n}\n\n#[test]\nfn test_checked_lcm() {\n    fn test<T: PrimitiveUnsigned>(x: T, y: T, out: Option<T>) {\n        assert_eq!(x.checked_lcm(y), out);\n    }\n    test::<u8>(0, 0, Some(0));\n    test::<u16>(0, 6, Some(0));\n    test::<u32>(6, 0, Some(0));\n    test::<u64>(1, 6, Some(6));\n    test::<u128>(6, 1, Some(6));\n    test::<usize>(8, 12, Some(24));\n    test::<u8>(54, 24, Some(216));\n    test::<u16>(42, 56, Some(168));\n    test::<u32>(48, 18, Some(144));\n    test::<u64>(3, 5, Some(15));\n    test::<u128>(12, 60, Some(60));\n    test::<usize>(12, 90, Some(180));\n    test::<usize>(usize::MAX, 2, None);\n}\n\nfn lcm_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_34::<T>().test_properties(|(x, y)| {\n        let lcm = x.lcm(y);\n\n        let mut x_mut = x;\n        x_mut.lcm_assign(y);\n        assert_eq!(x_mut, lcm);\n\n        assert_eq!(y.lcm(x), lcm);\n        assert!(lcm.divisible_by(x));\n        assert!(lcm.divisible_by(y));\n        let gcd = x.gcd(y);\n        if x != T::ZERO {\n            assert_eq!(lcm / x * gcd, y);\n        }\n        if y != T::ZERO {\n            assert_eq!(lcm / y * gcd, x);\n        }\n        if gcd != T::ZERO {\n            assert_eq!(x / gcd * y, lcm);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.lcm(x), x);\n        assert_eq!(x.lcm(T::ONE), x);\n        assert_eq!(x.lcm(T::ZERO), T::ZERO);\n    });\n}\n\n#[test]\nfn lcm_properties() {\n    apply_fn_to_unsigneds!(lcm_properties_helper);\n}\n\nfn checked_lcm_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_33::<T>().test_properties(|(x, y)| {\n        let lcm = x.checked_lcm(y);\n        assert_eq!(y.checked_lcm(x), lcm);\n        if let Some(lcm) = lcm {\n            assert_eq!(x.lcm(y), lcm);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.checked_lcm(x), Some(x));\n        assert_eq!(x.checked_lcm(T::ONE), Some(x));\n        assert_eq!(x.checked_lcm(T::ZERO), Some(T::ZERO));\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        if x != T::ZERO && y != T::ZERO && z != T::ZERO {\n            assert_eq!(\n                x.checked_lcm(y).and_then(|n| n.checked_lcm(z)),\n                y.checked_lcm(z).and_then(|n| x.checked_lcm(n))\n            );\n        }\n    });\n}\n\n#[test]\nfn checked_lcm_properties() {\n    apply_fn_to_unsigneds!(checked_lcm_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::log_base::{ceiling_log_base_naive, checked_log_base_naive};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_1, unsigned_gen_var_6, unsigned_pair_gen_var_24,\n};\nuse std::panic::catch_unwind;\n\nfn floor_log_base_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, base, out| {\n        assert_eq!(n.floor_log_base(base), out);\n    };\n    test(T::ONE, T::TWO, 0);\n    test(T::ONE, T::exact_from(5), 0);\n    test(T::TWO, T::TWO, 1);\n    test(T::TWO, T::exact_from(3), 0);\n    test(T::exact_from(3), T::TWO, 1);\n    test(T::exact_from(3), T::exact_from(3), 1);\n    test(T::exact_from(3), T::exact_from(4), 0);\n    test(T::exact_from(100), T::exact_from(2), 6);\n    test(T::exact_from(100), T::exact_from(3), 4);\n    test(T::exact_from(100), T::exact_from(4), 3);\n    test(T::exact_from(100), T::exact_from(5), 2);\n    test(T::exact_from(100), T::exact_from(10), 2);\n    test(T::exact_from(100), T::exact_from(11), 1);\n}\n\n#[test]\nfn test_floor_log_base() {\n    apply_fn_to_unsigneds!(floor_log_base_helper);\n}\n\nfn floor_log_base_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.floor_log_base(T::TWO));\n    assert_panic!(T::TWO.floor_log_base(T::ZERO));\n    assert_panic!(T::TWO.floor_log_base(T::ONE));\n}\n\n#[test]\nfn floor_log_base_fail() {\n    apply_fn_to_unsigneds!(floor_log_base_fail_helper);\n}\n\nfn ceiling_log_base_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.ceiling_log_base(pow), out);\n    };\n    test(T::ONE, T::TWO, 0);\n    test(T::ONE, T::exact_from(5), 0);\n    test(T::TWO, T::TWO, 1);\n    test(T::TWO, T::exact_from(3), 1);\n    test(T::exact_from(3), T::TWO, 2);\n    test(T::exact_from(3), T::exact_from(3), 1);\n    test(T::exact_from(3), T::exact_from(4), 1);\n    test(T::exact_from(100), T::exact_from(2), 7);\n    test(T::exact_from(100), T::exact_from(3), 5);\n    test(T::exact_from(100), T::exact_from(4), 4);\n    test(T::exact_from(100), T::exact_from(5), 3);\n    test(T::exact_from(100), T::exact_from(10), 2);\n    test(T::exact_from(100), T::exact_from(11), 2);\n}\n\n#[test]\nfn test_ceiling_log_base() {\n    apply_fn_to_unsigneds!(ceiling_log_base_helper);\n}\n\nfn ceiling_log_base_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.ceiling_log_base(T::TWO));\n    assert_panic!(T::TWO.ceiling_log_base(T::ZERO));\n    assert_panic!(T::TWO.ceiling_log_base(T::ONE));\n}\n\n#[test]\nfn ceiling_log_base_fail() {\n    apply_fn_to_unsigneds!(ceiling_log_base_fail_helper);\n}\n\nfn checked_log_base_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.checked_log_base(pow), out);\n    };\n    test(T::ONE, T::TWO, Some(0));\n    test(T::ONE, T::exact_from(5), Some(0));\n    test(T::TWO, T::TWO, Some(1));\n    test(T::TWO, T::exact_from(3), None);\n    test(T::exact_from(3), T::TWO, None);\n    test(T::exact_from(3), T::exact_from(3), Some(1));\n    test(T::exact_from(3), T::exact_from(4), None);\n    test(T::exact_from(100), T::exact_from(2), None);\n    test(T::exact_from(100), T::exact_from(3), None);\n    test(T::exact_from(100), T::exact_from(4), None);\n    test(T::exact_from(100), T::exact_from(5), None);\n    test(T::exact_from(100), T::exact_from(10), Some(2));\n    test(T::exact_from(100), T::exact_from(11), None);\n}\n\n#[test]\nfn test_checked_log_base() {\n    apply_fn_to_unsigneds!(checked_log_base_helper);\n}\n\nfn checked_log_base_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.checked_log_base(T::TWO));\n    assert_panic!(T::TWO.checked_log_base(T::ZERO));\n    assert_panic!(T::TWO.checked_log_base(T::ONE));\n}\n\n#[test]\nfn checked_log_base_fail() {\n    apply_fn_to_unsigneds!(checked_log_base_fail_helper);\n}\n\nfn floor_log_base_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_24::<T, T>().test_properties(|(n, base)| {\n        let floor_log = n.floor_log_base(base);\n        assert!(floor_log < T::WIDTH);\n        assert_eq!(floor_log == 0, n < base);\n\n        if let Some(pow) = base.checked_pow(floor_log) {\n            assert!(pow <= n);\n        }\n        if let Some(pow) = base.checked_pow(floor_log + 1) {\n            assert!(pow > n);\n        }\n        let ceiling_log = n.ceiling_log_base(base);\n        assert!(ceiling_log == floor_log || ceiling_log == floor_log + 1);\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(n.floor_log_base(T::TWO), n.floor_log_base_2());\n    });\n\n    unsigned_gen_var_6().test_properties(|n| {\n        assert_eq!(T::ONE.floor_log_base(n), 0);\n        assert_eq!(n.floor_log_base(n), 1);\n    });\n}\n\n#[test]\nfn floor_log_base_properties() {\n    apply_fn_to_unsigneds!(floor_log_base_properties_helper);\n}\n\nfn ceiling_log_base_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_24::<T, T>().test_properties(|(n, base)| {\n        let ceiling_log = n.ceiling_log_base(base);\n        assert!(ceiling_log <= T::WIDTH);\n        assert_eq!(ceiling_log, ceiling_log_base_naive(n, base));\n        assert_eq!(ceiling_log == 0, n == T::ONE);\n\n        if let Some(pow) = base.checked_pow(ceiling_log) {\n            assert!(pow >= n);\n        }\n        if n != T::ONE\n            && let Some(pow) = base.checked_pow(ceiling_log - 1)\n        {\n            assert!(pow < n);\n        }\n\n        let floor_log = n.floor_log_base(base);\n        assert!(ceiling_log == floor_log || ceiling_log == floor_log + 1);\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(n.ceiling_log_base(T::TWO), n.ceiling_log_base_2());\n    });\n\n    unsigned_gen_var_6().test_properties(|n| {\n        assert_eq!(T::ONE.ceiling_log_base(n), 0);\n        assert_eq!(n.ceiling_log_base(n), 1);\n    });\n}\n\n#[test]\nfn ceiling_log_base_properties() {\n    apply_fn_to_unsigneds!(ceiling_log_base_properties_helper);\n}\n\nfn checked_log_base_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_24::<T, T>().test_properties(|(n, base)| {\n        let checked_log = n.checked_log_base(base);\n        assert_eq!(checked_log, checked_log_base_naive(n, base));\n        if let Some(log) = checked_log {\n            assert_eq!(base.pow(log), n);\n            assert!(log <= T::WIDTH);\n            assert_eq!(log == 0, n == T::ONE);\n            assert_eq!(n.floor_log_base(base), log);\n            assert_eq!(n.ceiling_log_base(base), log);\n        }\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(n.checked_log_base(T::TWO), n.checked_log_base_2());\n    });\n\n    unsigned_gen_var_6().test_properties(|n| {\n        assert_eq!(T::ONE.checked_log_base(n), Some(0));\n        assert_eq!(n.checked_log_base(n), Some(1));\n    });\n}\n\n#[test]\nfn checked_log_base_properties() {\n    apply_fn_to_unsigneds!(checked_log_base_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{primitive_float_gen_var_18, unsigned_gen_var_1};\nuse std::panic::catch_unwind;\n\nfn floor_log_base_2_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.floor_log_base_2(), out);\n    };\n    test(T::ONE, 0);\n    test(T::TWO, 1);\n    test(T::exact_from(3), 1);\n    test(T::exact_from(4), 2);\n    test(T::exact_from(5), 2);\n    test(T::exact_from(100), 6);\n    test(T::exact_from(128), 7);\n    test(T::MAX, T::WIDTH - 1);\n}\n\nfn floor_log_base_2_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(n.floor_log_base_2(), out);\n    };\n    test(T::ONE, 0);\n    test(T::TWO, 1);\n    test(T::from(3.0f32), 1);\n    test(T::from(4.0f32), 2);\n    test(T::from(5.0f32), 2);\n    test(T::from(100.0f32), 6);\n    test(T::from(128.0f32), 7);\n    test(T::from(0.4f32), -2);\n    test(T::from(0.5f32), -1);\n    test(T::from(0.6f32), -1);\n    test(T::MAX_FINITE, T::MAX_EXPONENT);\n    test(T::MIN_POSITIVE_SUBNORMAL, T::MIN_EXPONENT);\n}\n\n#[test]\nfn test_floor_log_base_2() {\n    apply_fn_to_unsigneds!(floor_log_base_2_helper_unsigned);\n    apply_fn_to_primitive_floats!(floor_log_base_2_helper_primitive_float);\n}\n\nfn floor_log_base_2_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.floor_log_base_2());\n}\n\nfn floor_log_base_2_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::ZERO.floor_log_base_2());\n    assert_panic!(T::NAN.floor_log_base_2());\n    assert_panic!(T::INFINITY.floor_log_base_2());\n    assert_panic!(T::NEGATIVE_INFINITY.floor_log_base_2());\n}\n\n#[test]\nfn floor_log_base_2_fail() {\n    apply_fn_to_unsigneds!(floor_log_base_2_fail_helper_unsigned);\n    apply_fn_to_primitive_floats!(floor_log_base_2_fail_helper_primitive_float);\n}\n\nfn ceiling_log_base_2_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.ceiling_log_base_2(), out);\n    };\n    test(T::ONE, 0);\n    test(T::TWO, 1);\n    test(T::exact_from(3), 2);\n    test(T::exact_from(4), 2);\n    test(T::exact_from(5), 3);\n    test(T::exact_from(100), 7);\n    test(T::exact_from(128), 7);\n    test(T::MAX, T::WIDTH);\n}\n\nfn ceiling_log_base_2_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(n.ceiling_log_base_2(), out);\n    };\n    test(T::ONE, 0);\n    test(T::TWO, 1);\n    test(T::from(3.0f32), 2);\n    test(T::from(4.0f32), 2);\n    test(T::from(5.0f32), 3);\n    test(T::from(100.0f32), 7);\n    test(T::from(128.0f32), 7);\n    test(T::from(0.4f32), -1);\n    test(T::from(0.5f32), -1);\n    test(T::from(0.6f32), 0);\n    test(T::MAX_FINITE, T::MAX_EXPONENT + 1);\n    test(T::MIN_POSITIVE_SUBNORMAL, T::MIN_EXPONENT);\n}\n\n#[test]\nfn test_ceiling_log_base_2() {\n    apply_fn_to_unsigneds!(ceiling_log_base_2_helper_unsigned);\n    apply_fn_to_primitive_floats!(ceiling_log_base_2_helper_primitive_float);\n}\n\nfn ceiling_log_base_2_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.ceiling_log_base_2());\n}\n\nfn ceiling_log_base_2_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::ZERO.ceiling_log_base_2());\n    assert_panic!(T::NAN.ceiling_log_base_2());\n    assert_panic!(T::INFINITY.ceiling_log_base_2());\n    assert_panic!(T::NEGATIVE_INFINITY.ceiling_log_base_2());\n}\n\n#[test]\nfn ceiling_log_base_2_fail() {\n    apply_fn_to_unsigneds!(ceiling_log_base_2_fail_helper_unsigned);\n    apply_fn_to_primitive_floats!(ceiling_log_base_2_fail_helper_primitive_float);\n}\n\nfn checked_log_base_2_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.checked_log_base_2(), out);\n    };\n    test(T::ONE, Some(0));\n    test(T::TWO, Some(1));\n    test(T::exact_from(3), None);\n    test(T::exact_from(4), Some(2));\n    test(T::exact_from(5), None);\n    test(T::exact_from(100), None);\n    test(T::exact_from(128), Some(7));\n    test(T::MAX, None);\n}\n\nfn checked_log_base_2_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(n.checked_log_base_2(), out);\n    };\n    test(T::ONE, Some(0));\n    test(T::TWO, Some(1));\n    test(T::from(3.0f32), None);\n    test(T::from(4.0f32), Some(2));\n    test(T::from(5.0f32), None);\n    test(T::from(100.0f32), None);\n    test(T::from(128.0f32), Some(7));\n    test(T::from(0.4f32), None);\n    test(T::from(0.5f32), Some(-1));\n    test(T::from(0.6f32), None);\n    test(T::MAX_FINITE, None);\n    test(T::MIN_POSITIVE_SUBNORMAL, Some(T::MIN_EXPONENT));\n}\n\n#[test]\nfn test_checked_log_base_2() {\n    apply_fn_to_unsigneds!(checked_log_base_2_helper_unsigned);\n    apply_fn_to_primitive_floats!(checked_log_base_2_helper_primitive_float);\n}\n\nfn checked_log_base_2_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.checked_log_base_2());\n}\n\nfn checked_log_base_2_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::ZERO.checked_log_base_2());\n    assert_panic!(T::NAN.checked_log_base_2());\n    assert_panic!(T::INFINITY.checked_log_base_2());\n    assert_panic!(T::NEGATIVE_INFINITY.checked_log_base_2());\n}\n\n#[test]\nfn checked_log_base_2_fail() {\n    apply_fn_to_unsigneds!(checked_log_base_2_fail_helper_unsigned);\n    apply_fn_to_primitive_floats!(checked_log_base_2_fail_helper_primitive_float);\n}\n\nfn floor_log_base_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        let floor_log_base_2 = n.floor_log_base_2();\n        assert_eq!(floor_log_base_2, n.significant_bits() - 1);\n        assert!(floor_log_base_2 < T::WIDTH);\n        assert_eq!(floor_log_base_2 == 0, n == T::ONE);\n        assert!(T::power_of_2(floor_log_base_2) <= n);\n        if floor_log_base_2 < T::WIDTH - 1 {\n            assert!(T::power_of_2(floor_log_base_2 + 1) > n);\n        }\n\n        let ceiling_log_base_2 = n.ceiling_log_base_2();\n        if n.is_power_of_2() {\n            assert_eq!(ceiling_log_base_2, floor_log_base_2);\n        } else {\n            assert_eq!(ceiling_log_base_2, floor_log_base_2 + 1);\n        }\n    });\n}\n\nfn floor_log_base_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen_var_18::<T>().test_properties(|n| {\n        let floor_log_base_2 = n.floor_log_base_2();\n        assert!(floor_log_base_2 <= T::MAX_EXPONENT);\n        assert!(floor_log_base_2 >= T::MIN_EXPONENT);\n        assert_eq!(floor_log_base_2 == 0, n >= T::ONE && n < T::TWO);\n        assert!(T::power_of_2(floor_log_base_2) <= n);\n        if floor_log_base_2 < T::MAX_EXPONENT {\n            assert!(T::power_of_2(floor_log_base_2 + 1) > n);\n        }\n\n        let ceiling_log_base_2 = n.ceiling_log_base_2();\n        if n.is_power_of_2() {\n            assert_eq!(ceiling_log_base_2, floor_log_base_2);\n        } else {\n            assert_eq!(ceiling_log_base_2, floor_log_base_2 + 1);\n        }\n    });\n}\n\n#[test]\nfn floor_log_base_2_properties() {\n    apply_fn_to_unsigneds!(floor_log_base_2_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(floor_log_base_2_properties_helper_primitive_float);\n}\n\nfn ceiling_log_base_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        let ceiling_log_base_2 = n.ceiling_log_base_2();\n        assert!(ceiling_log_base_2 <= T::WIDTH);\n        assert_eq!(ceiling_log_base_2 == 0, n == T::ONE);\n        if ceiling_log_base_2 < T::WIDTH {\n            assert!(T::power_of_2(ceiling_log_base_2) >= n);\n        }\n        if ceiling_log_base_2 != 0 {\n            assert!(T::power_of_2(ceiling_log_base_2 - 1) < n);\n        }\n\n        let floor_log_base_2 = n.floor_log_base_2();\n        if n.is_power_of_2() {\n            assert_eq!(floor_log_base_2, ceiling_log_base_2);\n        } else {\n            assert_eq!(floor_log_base_2, ceiling_log_base_2 - 1);\n        }\n    });\n}\n\nfn ceiling_log_base_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen_var_18::<T>().test_properties(|n| {\n        let ceiling_log_base_2 = n.ceiling_log_base_2();\n        assert!(ceiling_log_base_2 <= T::MAX_EXPONENT + 1);\n        assert!(ceiling_log_base_2 >= T::MIN_EXPONENT);\n        assert_eq!(ceiling_log_base_2 == 0, n > T::ONE / T::TWO && n <= T::ONE);\n        if ceiling_log_base_2 < T::MAX_EXPONENT {\n            assert!(T::power_of_2(ceiling_log_base_2) >= n);\n        }\n        if ceiling_log_base_2 > T::MIN_EXPONENT {\n            assert!(T::power_of_2(ceiling_log_base_2 - 1) < n);\n        }\n\n        let floor_log_base_2 = n.floor_log_base_2();\n        if n.is_power_of_2() {\n            assert_eq!(floor_log_base_2, ceiling_log_base_2);\n        } else {\n            assert_eq!(floor_log_base_2, ceiling_log_base_2 - 1);\n        }\n    });\n}\n\n#[test]\nfn ceiling_log_base_2_properties() {\n    apply_fn_to_unsigneds!(ceiling_log_base_2_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(ceiling_log_base_2_properties_helper_primitive_float);\n}\n\nfn checked_log_base_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        let checked_log_base_2 = n.checked_log_base_2();\n        assert_eq!(checked_log_base_2.is_some(), n.is_power_of_2());\n        if let Some(log_base_2) = checked_log_base_2 {\n            assert_eq!(T::power_of_2(log_base_2), n);\n            assert!(log_base_2 <= T::WIDTH);\n            assert_eq!(log_base_2 == 0, n == T::ONE);\n            assert_eq!(n.floor_log_base_2(), log_base_2);\n            assert_eq!(n.ceiling_log_base_2(), log_base_2);\n        }\n    });\n}\n\nfn checked_log_base_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen_var_18::<T>().test_properties(|n| {\n        let checked_log_base_2 = n.checked_log_base_2();\n        assert_eq!(checked_log_base_2.is_some(), n.is_power_of_2());\n        if let Some(log_base_2) = checked_log_base_2 {\n            assert_eq!(T::power_of_2(log_base_2), n);\n            assert!(log_base_2 <= T::MAX_EXPONENT);\n            assert!(log_base_2 >= T::MIN_EXPONENT);\n            assert_eq!(log_base_2 == 0, n == T::ONE);\n            assert_eq!(n.floor_log_base_2(), log_base_2);\n            assert_eq!(n.ceiling_log_base_2(), log_base_2);\n        }\n    });\n}\n\n#[test]\nfn checked_log_base_2_properties() {\n    apply_fn_to_unsigneds!(checked_log_base_2_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(checked_log_base_2_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::log_base_power_of_2::ceiling_log_base_power_of_2_naive;\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_18, primitive_float_unsigned_pair_gen_var_3, unsigned_gen_var_1,\n    unsigned_gen_var_11, unsigned_pair_gen_var_21,\n};\nuse std::panic::catch_unwind;\n\nfn floor_log_base_power_of_2_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.floor_log_base_power_of_2(pow), out);\n    };\n    test(T::ONE, 1, 0);\n    test(T::ONE, 5, 0);\n    test(T::TWO, 1, 1);\n    test(T::TWO, 2, 0);\n    test(T::exact_from(3), 1, 1);\n    test(T::exact_from(3), 2, 0);\n    test(T::exact_from(4), 1, 2);\n    test(T::exact_from(4), 2, 1);\n    test(T::exact_from(4), 3, 0);\n    test(T::exact_from(5), 1, 2);\n    test(T::exact_from(5), 2, 1);\n    test(T::exact_from(5), 3, 0);\n    test(T::exact_from(100), 1, 6);\n    test(T::exact_from(100), 2, 3);\n    test(T::exact_from(100), 3, 2);\n    test(T::exact_from(100), 4, 1);\n    test(T::exact_from(100), 7, 0);\n    test(T::exact_from(128), 1, 7);\n    test(T::exact_from(128), 2, 3);\n    test(T::exact_from(128), 3, 2);\n    test(T::exact_from(128), 4, 1);\n    test(T::exact_from(128), 7, 1);\n    test(T::MAX, 1, T::WIDTH - 1);\n}\n\nfn floor_log_base_power_of_2_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.floor_log_base_power_of_2(pow), out);\n    };\n    test(T::ONE, 1, 0);\n    test(T::ONE, 5, 0);\n    test(T::TWO, 1, 1);\n    test(T::TWO, 2, 0);\n    test(T::from(3.0f32), 1, 1);\n    test(T::from(3.0f32), 2, 0);\n    test(T::from(4.0f32), 1, 2);\n    test(T::from(4.0f32), 2, 1);\n    test(T::from(4.0f32), 3, 0);\n    test(T::from(5.0f32), 1, 2);\n    test(T::from(5.0f32), 2, 1);\n    test(T::from(5.0f32), 3, 0);\n    test(T::from(100.0f32), 1, 6);\n    test(T::from(100.0f32), 2, 3);\n    test(T::from(100.0f32), 3, 2);\n    test(T::from(100.0f32), 4, 1);\n    test(T::from(100.0f32), 7, 0);\n    test(T::from(128.0f32), 1, 7);\n    test(T::from(128.0f32), 2, 3);\n    test(T::from(128.0f32), 3, 2);\n    test(T::from(128.0f32), 4, 1);\n    test(T::from(128.0f32), 7, 1);\n    test(T::from(0.1f32), 1, -4);\n    test(T::from(0.1f32), 2, -2);\n    test(T::from(0.1f32), 3, -2);\n    test(T::from(0.1f32), 4, -1);\n    test(T::MIN_POSITIVE_SUBNORMAL, 1, T::MIN_EXPONENT);\n    test(T::MAX_FINITE, 1, T::MAX_EXPONENT);\n}\n\n#[test]\nfn test_floor_log_base_power_of_2() {\n    apply_fn_to_unsigneds!(floor_log_base_power_of_2_helper_unsigned);\n    apply_fn_to_primitive_floats!(floor_log_base_power_of_2_helper_primitive_float);\n}\n\nfn floor_log_base_power_of_2_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.floor_log_base_power_of_2(2));\n    assert_panic!(T::TWO.floor_log_base_power_of_2(0));\n}\n\nfn floor_log_base_power_of_2_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::ZERO.floor_log_base_power_of_2(2));\n    assert_panic!(T::NEGATIVE_ONE.floor_log_base_power_of_2(2));\n    assert_panic!(T::NEGATIVE_INFINITY.floor_log_base_power_of_2(2));\n    assert_panic!(T::INFINITY.floor_log_base_power_of_2(2));\n    assert_panic!(T::NAN.floor_log_base_power_of_2(2));\n\n    assert_panic!(T::TWO.floor_log_base_power_of_2(0));\n}\n\n#[test]\nfn floor_log_base_power_of_2_fail() {\n    apply_fn_to_unsigneds!(floor_log_base_power_of_2_fail_helper_unsigned);\n    apply_fn_to_primitive_floats!(floor_log_base_power_of_2_fail_helper_primitive_float);\n}\n\nfn ceiling_log_base_power_of_2_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.ceiling_log_base_power_of_2(pow), out);\n    };\n    test(T::ONE, 1, 0);\n    test(T::ONE, 5, 0);\n    test(T::TWO, 1, 1);\n    test(T::TWO, 2, 1);\n    test(T::exact_from(3), 1, 2);\n    test(T::exact_from(3), 2, 1);\n    test(T::exact_from(4), 1, 2);\n    test(T::exact_from(4), 2, 1);\n    test(T::exact_from(4), 3, 1);\n    test(T::exact_from(5), 1, 3);\n    test(T::exact_from(5), 2, 2);\n    test(T::exact_from(5), 3, 1);\n    test(T::exact_from(100), 1, 7);\n    test(T::exact_from(100), 2, 4);\n    test(T::exact_from(100), 3, 3);\n    test(T::exact_from(100), 4, 2);\n    test(T::exact_from(100), 7, 1);\n    test(T::exact_from(128), 1, 7);\n    test(T::exact_from(128), 2, 4);\n    test(T::exact_from(128), 3, 3);\n    test(T::exact_from(128), 4, 2);\n    test(T::exact_from(128), 7, 1);\n    test(T::MAX, 1, T::WIDTH);\n}\n\nfn ceiling_log_base_power_of_2_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.ceiling_log_base_power_of_2(pow), out);\n    };\n    test(T::ONE, 1, 0);\n    test(T::ONE, 5, 0);\n    test(T::TWO, 1, 1);\n    test(T::TWO, 2, 1);\n    test(T::from(3.0f32), 1, 2);\n    test(T::from(3.0f32), 2, 1);\n    test(T::from(4.0f32), 1, 2);\n    test(T::from(4.0f32), 2, 1);\n    test(T::from(4.0f32), 3, 1);\n    test(T::from(5.0f32), 1, 3);\n    test(T::from(5.0f32), 2, 2);\n    test(T::from(5.0f32), 3, 1);\n    test(T::from(100.0f32), 1, 7);\n    test(T::from(100.0f32), 2, 4);\n    test(T::from(100.0f32), 3, 3);\n    test(T::from(100.0f32), 4, 2);\n    test(T::from(100.0f32), 7, 1);\n    test(T::from(128.0f32), 1, 7);\n    test(T::from(128.0f32), 2, 4);\n    test(T::from(128.0f32), 3, 3);\n    test(T::from(128.0f32), 4, 2);\n    test(T::from(128.0f32), 7, 1);\n    test(T::from(0.1f32), 1, -3);\n    test(T::from(0.1f32), 2, -1);\n    test(T::from(0.1f32), 3, -1);\n    test(T::from(0.1f32), 4, 0);\n    test(T::MIN_POSITIVE_SUBNORMAL, 1, T::MIN_EXPONENT);\n    test(T::MAX_FINITE, 1, T::MAX_EXPONENT + 1);\n}\n\n#[test]\nfn test_ceiling_log_base_power_of_2() {\n    apply_fn_to_unsigneds!(ceiling_log_base_power_of_2_helper_unsigned);\n    apply_fn_to_primitive_floats!(ceiling_log_base_power_of_2_helper_primitive_float);\n}\n\nfn ceiling_log_base_power_of_2_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.ceiling_log_base_power_of_2(2));\n    assert_panic!(T::TWO.ceiling_log_base_power_of_2(0));\n}\n\nfn ceiling_log_base_power_of_2_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::ZERO.ceiling_log_base_power_of_2(2));\n    assert_panic!(T::NEGATIVE_ONE.ceiling_log_base_power_of_2(2));\n    assert_panic!(T::NEGATIVE_INFINITY.ceiling_log_base_power_of_2(2));\n    assert_panic!(T::INFINITY.ceiling_log_base_power_of_2(2));\n    assert_panic!(T::NAN.ceiling_log_base_power_of_2(2));\n\n    assert_panic!(T::TWO.ceiling_log_base_power_of_2(0));\n}\n\n#[test]\nfn ceiling_log_base_power_of_2_fail() {\n    apply_fn_to_unsigneds!(ceiling_log_base_power_of_2_fail_helper_unsigned);\n    apply_fn_to_primitive_floats!(ceiling_log_base_power_of_2_fail_helper_primitive_float);\n}\n\nfn checked_log_base_power_of_2_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.checked_log_base_power_of_2(pow), out);\n    };\n    test(T::ONE, 1, Some(0));\n    test(T::ONE, 5, Some(0));\n    test(T::TWO, 1, Some(1));\n    test(T::TWO, 2, None);\n    test(T::exact_from(3), 1, None);\n    test(T::exact_from(3), 2, None);\n    test(T::exact_from(4), 1, Some(2));\n    test(T::exact_from(4), 2, Some(1));\n    test(T::exact_from(4), 3, None);\n    test(T::exact_from(5), 1, None);\n    test(T::exact_from(5), 2, None);\n    test(T::exact_from(5), 3, None);\n    test(T::exact_from(100), 1, None);\n    test(T::exact_from(100), 2, None);\n    test(T::exact_from(100), 3, None);\n    test(T::exact_from(100), 4, None);\n    test(T::exact_from(100), 7, None);\n    test(T::exact_from(128), 1, Some(7));\n    test(T::exact_from(128), 2, None);\n    test(T::exact_from(128), 3, None);\n    test(T::exact_from(128), 4, None);\n    test(T::exact_from(128), 7, Some(1));\n    test(T::MAX, 1, None);\n}\n\nfn checked_log_base_power_of_2_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.checked_log_base_power_of_2(pow), out);\n    };\n    test(T::ONE, 1, Some(0));\n    test(T::ONE, 5, Some(0));\n    test(T::TWO, 1, Some(1));\n    test(T::TWO, 2, None);\n    test(T::from(3.0f32), 1, None);\n    test(T::from(3.0f32), 2, None);\n    test(T::from(4.0f32), 1, Some(2));\n    test(T::from(4.0f32), 2, Some(1));\n    test(T::from(4.0f32), 3, None);\n    test(T::from(5.0f32), 1, None);\n    test(T::from(5.0f32), 2, None);\n    test(T::from(5.0f32), 3, None);\n    test(T::from(100.0f32), 1, None);\n    test(T::from(100.0f32), 2, None);\n    test(T::from(100.0f32), 3, None);\n    test(T::from(100.0f32), 4, None);\n    test(T::from(100.0f32), 7, None);\n    test(T::from(128.0f32), 1, Some(7));\n    test(T::from(128.0f32), 2, None);\n    test(T::from(128.0f32), 3, None);\n    test(T::from(128.0f32), 4, None);\n    test(T::from(128.0f32), 7, Some(1));\n    test(T::from(0.1f32), 1, None);\n    test(T::from(0.1f32), 2, None);\n    test(T::from(0.1f32), 3, None);\n    test(T::from(0.1f32), 4, None);\n    test(T::MIN_POSITIVE_SUBNORMAL, 1, Some(T::MIN_EXPONENT));\n    test(T::MAX_FINITE, 1, None);\n}\n\n#[test]\nfn test_checked_log_base_power_of_2() {\n    apply_fn_to_unsigneds!(checked_log_base_power_of_2_helper_unsigned);\n    apply_fn_to_primitive_floats!(checked_log_base_power_of_2_helper_primitive_float);\n}\n\nfn checked_log_base_power_of_2_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.checked_log_base_power_of_2(2));\n    assert_panic!(T::TWO.checked_log_base_power_of_2(0));\n}\n\nfn checked_log_base_power_of_2_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::ZERO.checked_log_base_power_of_2(2));\n    assert_panic!(T::NEGATIVE_ONE.checked_log_base_power_of_2(2));\n    assert_panic!(T::NEGATIVE_INFINITY.checked_log_base_power_of_2(2));\n    assert_panic!(T::INFINITY.checked_log_base_power_of_2(2));\n    assert_panic!(T::NAN.checked_log_base_power_of_2(2));\n\n    assert_panic!(T::TWO.checked_log_base_power_of_2(0));\n}\n\n#[test]\nfn checked_log_base_power_of_2_fail() {\n    apply_fn_to_unsigneds!(checked_log_base_power_of_2_fail_helper_unsigned);\n    apply_fn_to_primitive_floats!(checked_log_base_power_of_2_fail_helper_primitive_float);\n}\n\nfn floor_log_base_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_21::<T, u64>().test_properties(|(n, pow)| {\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        assert!(floor_log < T::WIDTH);\n        assert_eq!(floor_log == 0, n.significant_bits() - 1 < pow);\n        if pow < T::WIDTH {\n            assert_eq!(n.floor_log_base(T::power_of_2(pow)), floor_log);\n        }\n\n        let product = floor_log * pow;\n        if product < T::WIDTH {\n            assert!(T::power_of_2(product) <= n);\n        }\n        let product_2 = product + pow;\n        if product_2 < T::WIDTH {\n            assert!(T::power_of_2(product_2) > n);\n        }\n\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        if n.is_power_of_2() && (n.significant_bits() - 1).divisible_by(pow) {\n            assert_eq!(ceiling_log, floor_log);\n        } else {\n            assert_eq!(ceiling_log, floor_log + 1);\n        }\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(n.floor_log_base_power_of_2(1), n.floor_log_base_2());\n        assert_eq!(n.floor_log_base_power_of_2(T::WIDTH), 0);\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(T::ONE.floor_log_base_power_of_2(pow), 0);\n        if pow < T::WIDTH {\n            assert_eq!(T::power_of_2(pow).floor_log_base_power_of_2(pow), 1);\n        }\n    });\n}\n\nfn floor_log_base_power_of_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_unsigned_pair_gen_var_3::<T, u64>().test_properties(|(n, pow)| {\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        assert!(floor_log <= T::MAX_EXPONENT);\n        assert!(floor_log >= T::MIN_EXPONENT);\n        let i_pow = i64::exact_from(pow);\n        if i_pow >= T::MIN_EXPONENT && i_pow <= T::MAX_EXPONENT {\n            assert_eq!(floor_log == 0, n >= T::ONE && n < T::power_of_2(i_pow));\n        }\n        let product = floor_log * i_pow;\n        if product >= T::MIN_EXPONENT && product <= T::MAX_EXPONENT {\n            assert!(T::power_of_2(product) <= n);\n        }\n        let product_2 = product + i_pow;\n        if product_2 >= T::MIN_EXPONENT && product_2 <= T::MAX_EXPONENT {\n            assert!(T::power_of_2(product_2) > n);\n        }\n\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        if n.is_power_of_2() && n.floor_log_base_2().divisible_by(i_pow) {\n            assert_eq!(ceiling_log, floor_log);\n        } else {\n            assert_eq!(ceiling_log, floor_log + 1);\n        }\n    });\n\n    primitive_float_gen_var_18::<T>().test_properties(|n| {\n        assert_eq!(n.floor_log_base_power_of_2(1), n.floor_log_base_2());\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(T::ONE.floor_log_base_power_of_2(pow), 0);\n    });\n}\n\n#[test]\nfn floor_log_base_power_of_2_properties_unsigned() {\n    apply_fn_to_unsigneds!(floor_log_base_power_of_2_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(floor_log_base_power_of_2_properties_helper_primitive_float);\n}\n\nfn ceiling_log_base_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_21::<T, u64>().test_properties(|(n, pow)| {\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        assert!(ceiling_log <= T::WIDTH);\n        assert_eq!(ceiling_log, ceiling_log_base_power_of_2_naive(n, pow));\n        assert_eq!(ceiling_log == 0, n == T::ONE);\n        if pow < T::WIDTH {\n            assert_eq!(n.ceiling_log_base(T::power_of_2(pow)), ceiling_log);\n        }\n\n        let product = ceiling_log * pow;\n        if product < T::WIDTH {\n            assert!(T::power_of_2(product) >= n);\n        }\n        if product != 0 {\n            assert!(T::power_of_2(product - pow) < n);\n        }\n\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        if n.is_power_of_2() && (n.significant_bits() - 1).divisible_by(pow) {\n            assert_eq!(floor_log, ceiling_log);\n        } else {\n            assert_eq!(floor_log, ceiling_log - 1);\n        }\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(n.ceiling_log_base_power_of_2(1), n.ceiling_log_base_2());\n        assert_eq!(\n            n.ceiling_log_base_power_of_2(T::WIDTH),\n            u64::from(n != T::ONE)\n        );\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(T::ONE.ceiling_log_base_power_of_2(pow), 0);\n        if pow < T::WIDTH {\n            assert_eq!(T::power_of_2(pow).ceiling_log_base_power_of_2(pow), 1);\n        }\n    });\n}\n\nfn ceiling_log_base_power_of_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_unsigned_pair_gen_var_3::<T, u64>().test_properties(|(n, pow)| {\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        assert!(ceiling_log <= T::MAX_EXPONENT + 1);\n        assert!(ceiling_log >= T::MIN_EXPONENT);\n        let i_pow = i64::exact_from(pow);\n        if i_pow >= T::MIN_EXPONENT && i_pow <= T::MAX_EXPONENT {\n            assert_eq!(\n                ceiling_log == 0,\n                n > T::ONE / T::power_of_2(i_pow) && n <= T::ONE\n            );\n        }\n        let product = ceiling_log * i_pow;\n        if product >= T::MIN_EXPONENT && product <= T::MAX_EXPONENT {\n            assert!(T::power_of_2(product) >= n);\n        }\n        let product_2 = product - i_pow;\n        if product_2 >= T::MIN_EXPONENT && product_2 <= T::MAX_EXPONENT {\n            assert!(T::power_of_2(product_2) < n);\n        }\n\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        if n.is_power_of_2() && n.floor_log_base_2().divisible_by(i_pow) {\n            assert_eq!(floor_log, ceiling_log);\n        } else {\n            assert_eq!(floor_log, ceiling_log - 1);\n        }\n    });\n\n    primitive_float_gen_var_18::<T>().test_properties(|n| {\n        assert_eq!(n.ceiling_log_base_power_of_2(1), n.ceiling_log_base_2());\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(T::ONE.ceiling_log_base_power_of_2(pow), 0);\n    });\n}\n\n#[test]\nfn ceiling_log_base_power_of_2_properties() {\n    apply_fn_to_unsigneds!(ceiling_log_base_power_of_2_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(ceiling_log_base_power_of_2_properties_helper_primitive_float);\n}\n\nfn checked_log_base_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_21::<T, u64>().test_properties(|(n, pow)| {\n        let checked_log = n.checked_log_base_power_of_2(pow);\n        assert_eq!(\n            checked_log.is_some(),\n            n.is_power_of_2() && (n.significant_bits() - 1).divisible_by(pow)\n        );\n        if pow < T::WIDTH {\n            assert_eq!(n.checked_log_base(T::power_of_2(pow)), checked_log);\n        }\n        if let Some(log) = checked_log {\n            assert_eq!(T::power_of_2(log * pow), n);\n            assert!(log <= T::WIDTH);\n            assert_eq!(log == 0, n == T::ONE);\n            assert_eq!(n.floor_log_base_power_of_2(pow), log);\n            assert_eq!(n.ceiling_log_base_power_of_2(pow), log);\n        }\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(n.checked_log_base_power_of_2(1), n.checked_log_base_2());\n        assert_eq!(\n            n.checked_log_base_power_of_2(T::WIDTH),\n            if n == T::ONE { Some(0) } else { None }\n        );\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(T::ONE.checked_log_base_power_of_2(pow), Some(0));\n        if pow < T::WIDTH {\n            assert_eq!(T::power_of_2(pow).checked_log_base_power_of_2(pow), Some(1));\n        }\n    });\n}\n\nfn checked_log_base_power_of_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_unsigned_pair_gen_var_3::<T, u64>().test_properties(|(n, pow)| {\n        let checked_log = n.checked_log_base_power_of_2(pow);\n        let i_pow = i64::exact_from(pow);\n        assert_eq!(\n            checked_log.is_some(),\n            n.is_power_of_2() && n.checked_log_base_2().unwrap().divisible_by(i_pow)\n        );\n        if let Some(log) = checked_log {\n            assert_eq!(T::power_of_2(log * i_pow), n);\n            assert!(log <= T::MAX_EXPONENT);\n            assert!(log >= T::MIN_EXPONENT);\n            assert_eq!(log == 0, n == T::ONE);\n            assert_eq!(n.floor_log_base_power_of_2(pow), log);\n            assert_eq!(n.ceiling_log_base_power_of_2(pow), log);\n        }\n    });\n\n    primitive_float_gen_var_18::<T>().test_properties(|n| {\n        assert_eq!(n.checked_log_base_power_of_2(1), n.checked_log_base_2());\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(T::ONE.checked_log_base_power_of_2(pow), Some(0));\n        let i_pow = i64::exact_from(pow);\n        if i_pow >= T::MIN_EXPONENT && i_pow <= T::MAX_EXPONENT {\n            assert_eq!(\n                T::power_of_2(i_pow).checked_log_base_power_of_2(pow),\n                Some(1)\n            );\n        }\n    });\n}\n\n#[test]\nfn checked_log_base_power_of_2_properties() {\n    apply_fn_to_unsigneds!(checked_log_base_power_of_2_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(checked_log_base_power_of_2_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_16, unsigned_pair_gen_var_27, unsigned_quadruple_gen_var_4,\n    unsigned_triple_gen_var_12,\n};\nuse std::panic::catch_unwind;\n\nfn mod_add_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, y: T, m, out| {\n        assert_eq!(x.mod_add(y, m), out);\n\n        let mut x = x;\n        x.mod_add_assign(y, m);\n        assert_eq!(x, out);\n    };\n    test(T::ZERO, T::ZERO, T::ONE, T::ZERO);\n    test(\n        T::ZERO,\n        T::exact_from(3),\n        T::exact_from(5),\n        T::exact_from(3),\n    );\n    test(\n        T::exact_from(7),\n        T::exact_from(5),\n        T::exact_from(10),\n        T::TWO,\n    );\n    test(\n        T::exact_from(100),\n        T::exact_from(100),\n        T::exact_from(123),\n        T::exact_from(77),\n    );\n    test(T::MAX - T::ONE, T::ONE, T::MAX, T::ZERO);\n    test(T::MAX - T::ONE, T::MAX - T::ONE, T::MAX, T::MAX - T::TWO);\n}\n\n#[test]\nfn test_mod_add() {\n    apply_fn_to_unsigneds!(mod_add_helper);\n}\n\nfn mod_add_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_add(T::ZERO, T::ZERO));\n    assert_panic!(T::from(123u8).mod_add(T::from(200u8), T::from(200u8)));\n    assert_panic!(T::from(200u8).mod_add(T::from(123u8), T::from(200u8)));\n}\n\n#[test]\nfn mod_add_fail() {\n    apply_fn_to_unsigneds!(mod_add_fail_helper);\n}\n\nfn mod_add_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_add_assign(T::ZERO, T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_add_assign(T::from(200u8), T::from(200u8));\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_add_assign(T::from(123u8), T::from(200u8));\n    });\n}\n\n#[test]\nfn mod_add_assign_fail() {\n    apply_fn_to_unsigneds!(mod_add_assign_fail_helper);\n}\n\nfn mod_add_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_12::<T>().test_properties(|(x, y, m)| {\n        assert!(x.mod_is_reduced(&m));\n        assert!(y.mod_is_reduced(&m));\n        let sum = x.mod_add(y, m);\n        assert!(sum.mod_is_reduced(&m));\n\n        let mut x_alt = x;\n        x_alt.mod_add_assign(y, m);\n        assert_eq!(x_alt, sum);\n\n        assert_eq!(sum.mod_sub(y, m), x);\n        assert_eq!(sum.mod_sub(x, m), y);\n        assert_eq!(y.mod_add(x, m), sum);\n        assert_eq!(x.mod_sub(y.mod_neg(m), m), sum);\n    });\n\n    unsigned_pair_gen_var_16::<T>().test_properties(|(x, m)| {\n        assert_eq!(x.mod_add(T::ZERO, m), x);\n        assert_eq!(T::ZERO.mod_add(x, m), x);\n        assert_eq!(x.mod_add(x.mod_neg(m), m), T::ZERO);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_panic!(x.mod_add(y, T::ZERO));\n        assert_panic!({\n            let mut x = x;\n            x.mod_add_assign(y, T::ZERO);\n        });\n    });\n\n    unsigned_quadruple_gen_var_4::<T>().test_properties(|(x, y, z, m)| {\n        assert_eq!(x.mod_add(y, m).mod_add(z, m), x.mod_add(y.mod_add(z, m), m));\n    });\n}\n\n#[test]\nfn mod_add_properties() {\n    apply_fn_to_unsigneds!(mod_add_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_inverse::mod_inverse_binary;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_6, unsigned_pair_gen_var_38,\n};\nuse malachite_base::test_util::num::arithmetic::mod_inverse::mod_inverse_euclidean;\nuse std::panic::catch_unwind;\n\nfn mod_inverse_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    let test = |n: U, m, out| {\n        assert_eq!(n.mod_inverse(m), out);\n        assert_eq!(mod_inverse_euclidean::<U, S>(n, m), out);\n        assert_eq!(mod_inverse_binary::<U, S>(n, m), out);\n    };\n\n    test(U::ONE, U::exact_from(5), Some(U::ONE));\n    test(U::exact_from(7), U::exact_from(10), Some(U::exact_from(3)));\n    test(U::exact_from(6), U::exact_from(10), None);\n    test(\n        U::exact_from(100),\n        U::exact_from(101),\n        Some(U::exact_from(100)),\n    );\n    test(U::ONE, U::MAX, Some(U::ONE));\n    test(U::MAX - U::ONE, U::MAX, Some(U::MAX - U::ONE));\n}\n\n#[test]\nfn test_mod_inverse() {\n    apply_fn_to_unsigned_signed_pairs!(mod_inverse_helper);\n}\n\nfn mod_inverse_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_inverse(T::ZERO));\n    assert_panic!(T::ZERO.mod_inverse(T::from(10u8)));\n    assert_panic!(T::from(123u8).mod_inverse(T::from(123u8)));\n}\n\n#[test]\nfn mod_inverse_fail() {\n    apply_fn_to_unsigneds!(mod_inverse_fail_helper);\n}\n\nfn mod_inverse_properties_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    unsigned_pair_gen_var_38::<U>().test_properties(|(n, m)| {\n        assert!(n.mod_is_reduced(&m));\n        let inverse = n.mod_inverse(m);\n        assert_eq!(mod_inverse_euclidean::<U, S>(n, m), inverse);\n        assert_eq!(mod_inverse_binary::<U, S>(n, m), inverse);\n        assert_eq!(inverse.is_some(), n.coprime_with(m));\n        if let Some(inverse) = inverse {\n            assert!(inverse.mod_is_reduced(&m));\n            assert_eq!(inverse.mod_inverse(m), Some(n));\n            assert_eq!(n.mod_mul(inverse, m), U::ONE);\n            assert_eq!((m - n).mod_inverse(m), Some(m - inverse));\n        }\n    });\n\n    unsigned_gen_var_6::<U>().test_properties(|m| {\n        assert_eq!(U::ONE.mod_inverse(m), Some(U::ONE));\n        assert_eq!((m - U::ONE).mod_inverse(m), Some(m - U::ONE));\n    });\n\n    unsigned_gen::<U>().test_properties(|x| {\n        assert_panic!(x.mod_inverse(U::ZERO));\n    });\n}\n\n#[test]\nfn mod_inverse_properties() {\n    apply_fn_to_unsigned_signed_pairs!(mod_inverse_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_12;\nuse std::panic::catch_unwind;\n\nfn mod_is_reduced_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, m, out| {\n        assert_eq!(n.mod_is_reduced(&m), out);\n    };\n    test(T::ZERO, T::exact_from(5), true);\n    test(T::exact_from(100), T::exact_from(100), false);\n    test(T::exact_from(100), T::exact_from(101), true);\n    test(T::MAX - T::ONE, T::MAX - T::ONE, false);\n    test(T::MAX - T::ONE, T::MAX, true);\n    test(T::MAX, T::MAX, false);\n}\n\n#[test]\nfn test_mod_is_reduced() {\n    apply_fn_to_unsigneds!(mod_is_reduced_helper);\n}\n\nfn mod_is_reduced_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_is_reduced(&T::ZERO));\n}\n\n#[test]\nfn mod_is_reduced_fail() {\n    apply_fn_to_unsigneds!(mod_is_reduced_fail_helper);\n}\n\nfn mod_is_reduced_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(n, m)| {\n        assert_eq!(n.mod_is_reduced(&m), n % m == n);\n    });\n}\n\n#[test]\nfn mod_is_reduced_properties() {\n    apply_fn_to_unsigneds!(mod_is_reduced_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_mul::{\n    fast_mod_mul, limbs_invert_limb_u32, limbs_invert_limb_u64, mod_preinverted_double,\n    naive_mod_mul, test_invert_u32_table, test_invert_u64_table,\n};\nuse malachite_base::num::arithmetic::traits::ModMulPrecomputed;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_12, unsigned_pair_gen_var_16, unsigned_pair_gen_var_27,\n    unsigned_quadruple_gen_var_4, unsigned_quadruple_gen_var_5, unsigned_triple_gen_var_12,\n};\nuse malachite_base::test_util::num::arithmetic::mod_mul::limbs_invert_limb_naive;\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_test_invert_u32_table() {\n    test_invert_u32_table();\n}\n\n#[test]\nfn test_test_invert_u64_table() {\n    test_invert_u64_table();\n}\n\n#[test]\nfn test_limbs_invert_limb_u32() {\n    let test = |x, out| {\n        assert_eq!(limbs_invert_limb_u32(x), out);\n        assert_eq!(limbs_invert_limb_naive::<u32, u64>(x), out);\n    };\n    test(0x80000000, u32::MAX);\n    test(0x80000001, 0xfffffffc);\n    test(u32::MAX - 1, 2);\n    test(u32::MAX, 1);\n    test(0x89abcdef, 0xdc08767e);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_limb_u32_fail() {\n    limbs_invert_limb_u32(123);\n}\n\n#[test]\nfn test_limbs_invert_limb_u64() {\n    let test = |x, out| {\n        assert_eq!(limbs_invert_limb_u64(x), out);\n        assert_eq!(limbs_invert_limb_naive::<u64, u128>(x), out);\n    };\n    test(0x8000000000000000, u64::MAX);\n    test(0x8000000000000001, 0xfffffffffffffffc);\n    test(0xfffffffffffffffe, 2);\n    test(u64::MAX, 1);\n    test(0x89abcdefedcba987, 0xdc08767b33d7ec8f);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_limb_u64_fail() {\n    limbs_invert_limb_u64(123);\n}\n\n#[test]\nfn test_mod_preinverted_double() {\n    fn test<\n        T: TryFrom<DT> + PrimitiveUnsigned,\n        DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n    >(\n        x_1: T,\n        x_0: T,\n        d: T,\n        out: T,\n    ) {\n        let d_inv = limbs_invert_limb_naive::<T, DT>(d << LeadingZeros::leading_zeros(d));\n        assert_eq!(mod_preinverted_double::<T, DT>(x_1, x_0, d, d_inv), out);\n        assert_eq!(T::exact_from(DT::join_halves(x_1, x_0) % DT::from(d)), out);\n    }\n    test::<u8, u16>(0, 0, 1, 0);\n    test::<u32, u64>(0, 1, 1, 0);\n    test::<u16, u32>(1, 0, 2, 0);\n    test::<u16, u32>(1, 7, 2, 1);\n    test::<u8, u16>(0x78, 0x9a, 0xbc, 0x2a);\n    test::<u64, u128>(0x12, 0x34, 0x33, 0x13);\n}\n\nfn mod_mul_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, y: T, m, out| {\n        assert_eq!(x.mod_mul(y, m), out);\n\n        let mut mut_x = x;\n        mut_x.mod_mul_assign(y, m);\n        assert_eq!(mut_x, out);\n\n        let data = T::precompute_mod_mul_data(&m);\n        assert_eq!(x.mod_mul_precomputed(y, m, &data), out);\n\n        let mut mut_x = x;\n        mut_x.mod_mul_precomputed_assign(y, m, &data);\n        assert_eq!(mut_x, out);\n\n        assert_eq!(naive_mod_mul(x, y, m), out);\n    };\n    test(T::ZERO, T::ZERO, T::ONE, T::ZERO);\n    test(T::TWO, T::exact_from(3), T::exact_from(7), T::exact_from(6));\n    test(\n        T::exact_from(7),\n        T::exact_from(3),\n        T::exact_from(10),\n        T::ONE,\n    );\n    test(\n        T::exact_from(100),\n        T::exact_from(100),\n        T::exact_from(123),\n        T::exact_from(37),\n    );\n    test(T::MAX - T::ONE, T::MAX - T::ONE, T::MAX, T::ONE);\n}\n\n#[test]\nfn test_mod_mul() {\n    apply_fn_to_unsigneds!(mod_mul_helper);\n}\n\nfn mod_mul_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_mul(T::ZERO, T::ZERO));\n    assert_panic!(T::from(123u8).mod_mul(T::from(200u8), T::from(200u8)));\n    assert_panic!(T::from(200u8).mod_mul(T::from(123u8), T::from(200u8)));\n}\n\n#[test]\nfn mod_mul_fail() {\n    apply_fn_to_unsigneds!(mod_mul_fail_helper);\n}\n\nfn mod_mul_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_mul_assign(T::ZERO, T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_mul_assign(T::from(200u8), T::from(200u8));\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_mul_assign(T::from(123u8), T::from(200u8));\n    });\n}\n\n#[test]\nfn mod_mul_assign_fail() {\n    apply_fn_to_unsigneds!(mod_mul_assign_fail_helper);\n}\n\n#[test]\nfn invert_limb_u32_properties() {\n    unsigned_gen_var_12().test_properties(|x| {\n        let inverse = limbs_invert_limb_u32(x);\n        assert_eq!(limbs_invert_limb_naive::<u32, u64>(x), inverse);\n        assert_ne!(inverse, 0);\n    });\n}\n\n#[test]\nfn invert_limb_u64_properties() {\n    unsigned_gen_var_12().test_properties(|x| {\n        let inverse = limbs_invert_limb_u64(x);\n        assert_eq!(limbs_invert_limb_naive::<u64, u128>(x), inverse);\n        assert_ne!(inverse, 0);\n    });\n}\n\nfn mod_mul_preinverted_properties_helper<\n    T: TryFrom<DT> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>() {\n    unsigned_quadruple_gen_var_5::<T, DT>().test_properties(|(x_1, x_0, d, d_inv)| {\n        let r = mod_preinverted_double::<T, DT>(x_1, x_0, d, d_inv);\n        let n = DT::join_halves(x_1, x_0);\n        assert_eq!(T::exact_from(n % DT::from(d)), r);\n        assert!(r < d);\n        let q = DT::join_halves(x_1, x_0) / DT::from(d);\n        assert_eq!(q * DT::from(d) + DT::from(r), n);\n    });\n}\n\n#[test]\nfn mod_mul_preinverted_properties() {\n    mod_mul_preinverted_properties_helper::<u8, u16>();\n    mod_mul_preinverted_properties_helper::<u16, u32>();\n    mod_mul_preinverted_properties_helper::<u32, u64>();\n    mod_mul_preinverted_properties_helper::<u64, u128>();\n}\n\nfn mod_mul_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_12::<T>().test_properties(|(x, y, m)| {\n        assert!(x.mod_is_reduced(&m));\n        assert!(y.mod_is_reduced(&m));\n        let product = x.mod_mul(y, m);\n        assert!(product.mod_is_reduced(&m));\n\n        let mut x_alt = x;\n        x_alt.mod_mul_assign(y, m);\n        assert_eq!(x_alt, product);\n\n        let data = T::precompute_mod_mul_data(&m);\n\n        assert_eq!(x.mod_mul_precomputed(y, m, &data), product);\n\n        let mut x_alt = x;\n        x_alt.mod_mul_precomputed_assign(y, m, &data);\n        assert_eq!(x_alt, product);\n\n        assert_eq!(naive_mod_mul(x, y, m), product);\n        assert_eq!(y.mod_mul(x, m), product);\n        assert_eq!(x.mod_mul(y.mod_neg(m), m), product.mod_neg(m));\n        assert_eq!(x.mod_neg(m).mod_mul(y, m), product.mod_neg(m));\n    });\n\n    unsigned_pair_gen_var_16::<T>().test_properties(|(x, m)| {\n        assert_eq!(x.mod_mul(T::ZERO, m), T::ZERO);\n        assert_eq!(T::ZERO.mod_mul(x, m), T::ZERO);\n        if m > T::ONE {\n            assert_eq!(x.mod_mul(T::ONE, m), x);\n            assert_eq!(T::ONE.mod_mul(x, m), x);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_panic!(x.mod_mul(y, T::ZERO));\n        assert_panic!({\n            let mut x = x;\n            x.mod_mul_assign(y, T::ZERO);\n        });\n    });\n\n    unsigned_quadruple_gen_var_4::<T>().test_properties(|(x, y, z, m)| {\n        assert_eq!(x.mod_mul(y, m).mod_mul(z, m), x.mod_mul(y.mod_mul(z, m), m));\n        assert_eq!(\n            x.mod_mul(y.mod_add(z, m), m),\n            x.mod_mul(y, m).mod_add(x.mod_mul(z, m), m)\n        );\n        assert_eq!(\n            x.mod_add(y, m).mod_mul(z, m),\n            x.mod_mul(z, m).mod_add(y.mod_mul(z, m), m)\n        );\n    });\n}\n\nfn mod_mul_properties_fast_helper<\n    T: TryFrom<DT> + ModMulPrecomputed<Data = T> + PrimitiveUnsigned,\n    DT: From<T> + HasHalf<Half = T> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n>() {\n    unsigned_triple_gen_var_12::<T>().test_properties(|(x, y, m)| {\n        let product = x.mod_mul(y, m);\n        assert_eq!(\n            fast_mod_mul::<T, DT>(x, y, m, T::precompute_mod_mul_data(&m)),\n            product\n        );\n    });\n}\n\n#[test]\nfn mod_mul_properties() {\n    apply_fn_to_unsigneds!(mod_mul_properties_helper);\n\n    mod_mul_properties_fast_helper::<u32, u64>();\n    mod_mul_properties_fast_helper::<u64, u128>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_1, unsigned_gen_var_6, unsigned_pair_gen_var_16,\n};\nuse std::panic::catch_unwind;\n\nfn mod_neg_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, m, out| {\n        assert_eq!(n.mod_neg(m), out);\n\n        let mut n = n;\n        n.mod_neg_assign(m);\n        assert_eq!(n, out);\n    };\n\n    test(T::ZERO, T::exact_from(5), T::ZERO);\n    test(T::exact_from(7), T::exact_from(10), T::exact_from(3));\n    test(T::exact_from(100), T::exact_from(101), T::ONE);\n    test(T::MAX - T::ONE, T::MAX, T::ONE);\n    test(T::ONE, T::MAX, T::MAX - T::ONE);\n}\n\n#[test]\nfn test_mod_neg() {\n    apply_fn_to_unsigneds!(mod_neg_helper);\n}\n\nfn mod_neg_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_neg(T::ZERO));\n    assert_panic!(T::from(123u8).mod_neg(T::from(123u8)));\n}\n\n#[test]\nfn mod_neg_fail() {\n    apply_fn_to_unsigneds!(mod_neg_fail_helper);\n}\n\nfn mod_neg_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_neg_assign(T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_neg_assign(T::from(123u8));\n    });\n}\n\n#[test]\nfn mod_neg_assign_fail() {\n    apply_fn_to_unsigneds!(mod_neg_assign_fail_helper);\n}\n\nfn mod_neg_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_16::<T>().test_properties(|(n, m)| {\n        assert!(n.mod_is_reduced(&m));\n        let neg = n.mod_neg(m);\n        assert!(neg.mod_is_reduced(&m));\n\n        let mut n_alt = n;\n        n_alt.mod_neg_assign(m);\n        assert_eq!(n_alt, neg);\n\n        assert_eq!(neg.mod_neg(m), n);\n        assert_eq!(n.mod_add(neg, m), T::ZERO);\n        assert_eq!(n == neg, n == T::ZERO || m.even() && n == m >> 1);\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|m| {\n        assert_eq!(T::ZERO.mod_neg(m), T::ZERO);\n    });\n\n    unsigned_gen_var_6::<T>().test_properties(|m| {\n        assert_eq!(T::ONE.mod_neg(m), m - T::ONE);\n        assert_eq!((m - T::ONE).mod_neg(m), T::ONE);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_panic!(x.mod_neg(T::ZERO));\n    });\n}\n\n#[test]\nfn mod_neg_properties() {\n    apply_fn_to_unsigneds!(mod_neg_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_6, signed_pair_gen_var_4, signed_pair_gen_var_6, unsigned_gen,\n    unsigned_gen_var_1, unsigned_pair_gen_var_12,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_mod_op_unsigned() {\n    fn test<T: PrimitiveUnsigned>(n: T, d: T, r: T) {\n        assert_eq!(n.mod_op(d), r);\n\n        let mut mut_n = n;\n        mut_n.mod_assign(d);\n        assert_eq!(mut_n, r);\n    }\n    test::<u8>(0, 1, 0);\n    test::<u16>(0, 123, 0);\n    test::<u32>(1, 1, 0);\n    test::<u64>(123, 1, 0);\n    test::<usize>(123, 123, 0);\n    test::<u128>(123, 456, 123);\n    test::<u16>(456, 123, 87);\n    test::<u32>(u32::MAX, 1, 0);\n    test::<usize>(0xffffffff, 0xffffffff, 0);\n    test::<u64>(1000000000000, 1, 0);\n    test::<u64>(1000000000000, 3, 1);\n    test::<u64>(1000000000000, 123, 100);\n    test::<u64>(1000000000000, 0xffffffff, 3567587560);\n    test::<u128>(1000000000000000000000000, 1, 0);\n    test::<u128>(1000000000000000000000000, 3, 1);\n    test::<u128>(1000000000000000000000000, 123, 37);\n    test::<u128>(1000000000000000000000000, 0xffffffff, 3167723695);\n    test::<u128>(1000000000000000000000000, 1234567890987, 530068894399);\n    test::<u128>(253640751230376270397812803167, 2669936877441, 1520301762334);\n    test::<u64>(3768477692975601, 11447376614057827956, 3768477692975601);\n    test::<u64>(3356605361737854, 3081095617839357, 275509743898497);\n    test::<u128>(\n        1098730198198174614195,\n        953382298040157850476,\n        145347900158016763719,\n    );\n    test::<u128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        0,\n    );\n    test::<u128>(1000000000000000000000000, 1000000000000000000000000, 0);\n    test::<u128>(0, 1000000000000000000000000, 0);\n    test::<u128>(123, 1000000000000000000000000, 123);\n}\n\n#[test]\nfn test_div_mod_signed() {\n    fn test<T: PrimitiveSigned>(n: T, d: T, r: T) {\n        assert_eq!(n.mod_op(d), r);\n\n        let mut mut_n = n;\n        mut_n.mod_assign(d);\n        assert_eq!(mut_n, r);\n    }\n    test::<i8>(0, 1, 0);\n    test::<i16>(0, 123, 0);\n    test::<i32>(1, 1, 0);\n    test::<i64>(123, 1, 0);\n    test::<i128>(123, 123, 0);\n    test::<isize>(123, 456, 123);\n    test::<i16>(456, 123, 87);\n    test::<i64>(0xffffffff, 1, 0);\n    test::<i64>(0xffffffff, 0xffffffff, 0);\n    test::<i64>(1000000000000, 1, 0);\n    test::<i64>(1000000000000, 3, 1);\n    test::<i64>(1000000000000, 123, 100);\n    test::<i64>(1000000000000, 0xffffffff, 3567587560);\n    test::<i128>(1000000000000000000000000, 1, 0);\n    test::<i128>(1000000000000000000000000, 3, 1);\n    test::<i128>(1000000000000000000000000, 123, 37);\n    test::<i128>(1000000000000000000000000, 0xffffffff, 3167723695);\n    test::<i128>(1000000000000000000000000, 1234567890987, 530068894399);\n    test::<i128>(253640751230376270397812803167, 2669936877441, 1520301762334);\n    test::<i128>(3768477692975601, 11447376614057827956, 3768477692975601);\n    test::<i64>(3356605361737854, 3081095617839357, 275509743898497);\n    test::<i128>(\n        1098730198198174614195,\n        953382298040157850476,\n        145347900158016763719,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, 1000000000000000000000000, 0);\n    test::<i128>(0, 1000000000000000000000000, 0);\n    test::<i128>(123, 1000000000000000000000000, 123);\n\n    test::<i8>(0, -1, 0);\n    test::<i16>(0, -123, 0);\n    test::<i32>(1, -1, 0);\n    test::<i64>(123, -1, 0);\n    test::<i128>(123, -123, 0);\n    test::<isize>(123, -456, -333);\n    test::<i16>(456, -123, -36);\n    test::<i64>(0xffffffff, -1, 0);\n    test::<i64>(0xffffffff, -0xffffffff, 0);\n    test::<i64>(1000000000000, -1, 0);\n    test::<i64>(1000000000000, -3, -2);\n    test::<i64>(1000000000000, -123, -23);\n    test::<i64>(1000000000000, -0xffffffff, -727379735);\n    test::<i128>(1000000000000000000000000, -1, 0);\n    test::<i128>(1000000000000000000000000, -3, -2);\n    test::<i128>(1000000000000000000000000, -123, -86);\n    test::<i128>(1000000000000000000000000, -0xffffffff, -1127243600);\n    test::<i128>(1000000000000000000000000, -1234567890987, -704498996588);\n    test::<i128>(\n        253640751230376270397812803167,\n        -2669936877441,\n        -1149635115107,\n    );\n    test::<i128>(\n        3768477692975601,\n        -11447376614057827956,\n        -11443608136364852355,\n    );\n    test::<i64>(3356605361737854, -3081095617839357, -2805585873940860);\n    test::<i128>(\n        1098730198198174614195,\n        -953382298040157850476,\n        -808034397882141086757,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        -69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, -1000000000000000000000000, 0);\n    test::<i128>(0, -1000000000000000000000000, 0);\n    test::<i128>(123, -1000000000000000000000000, -999999999999999999999877);\n\n    test::<i8>(-1, 1, 0);\n    test::<i16>(-123, 1, 0);\n    test::<i32>(-123, 123, 0);\n    test::<i64>(-123, 456, 333);\n    test::<isize>(-456, 123, 36);\n    test::<i64>(-0xffffffff, -1, 0);\n    test::<i64>(-0xffffffff, 0xffffffff, 0);\n    test::<i64>(-1000000000000, 1, 0);\n    test::<i64>(-1000000000000, 3, 2);\n    test::<i64>(-1000000000000, 123, 23);\n    test::<i64>(-1000000000000, 0xffffffff, 727379735);\n    test::<i128>(-1000000000000000000000000, 1, 0);\n    test::<i128>(-1000000000000000000000000, 3, 2);\n    test::<i128>(-1000000000000000000000000, 123, 86);\n    test::<i128>(-1000000000000000000000000, 0xffffffff, 1127243600);\n    test::<i128>(-1000000000000000000000000, 1234567890987, 704498996588);\n    test::<i128>(\n        -253640751230376270397812803167,\n        2669936877441,\n        1149635115107,\n    );\n    test::<i128>(\n        -3768477692975601,\n        11447376614057827956,\n        11443608136364852355,\n    );\n    test::<i64>(-3356605361737854, 3081095617839357, 2805585873940860);\n    test::<i128>(\n        -1098730198198174614195,\n        953382298040157850476,\n        808034397882141086757,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, 1000000000000000000000000, 0);\n    test::<i128>(-123, 1000000000000000000000000, 999999999999999999999877);\n\n    test::<i8>(-1, -1, 0);\n    test::<i16>(-123, -1, 0);\n    test::<i32>(-123, -123, 0);\n    test::<i64>(-123, -456, -123);\n    test::<isize>(-456, -123, -87);\n    test::<i128>(-0xffffffff, -1, 0);\n    test::<i64>(-0xffffffff, -0xffffffff, 0);\n    test::<i64>(-1000000000000, -1, 0);\n    test::<i64>(-1000000000000, -3, -1);\n    test::<i64>(-1000000000000, -123, -100);\n    test::<i64>(-1000000000000, -0xffffffff, -3567587560);\n    test::<i128>(-1000000000000000000000000, -1, 0);\n    test::<i128>(-1000000000000000000000000, -3, -1);\n    test::<i128>(-1000000000000000000000000, -123, -37);\n    test::<i128>(-1000000000000000000000000, -0xffffffff, -3167723695);\n    test::<i128>(-1000000000000000000000000, -1234567890987, -530068894399);\n    test::<i128>(\n        -253640751230376270397812803167,\n        -2669936877441,\n        -1520301762334,\n    );\n    test::<i128>(-3768477692975601, -11447376614057827956, -3768477692975601);\n    test::<i64>(-3356605361737854, -3081095617839357, -275509743898497);\n    test::<i128>(\n        -1098730198198174614195,\n        -953382298040157850476,\n        -145347900158016763719,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        -69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, -1000000000000000000000000, 0);\n    test::<i128>(-123, -1000000000000000000000000, -123);\n\n    test::<i8>(-128, -1, 0);\n}\n\nfn mod_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::ONE.mod_op(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.mod_assign(T::ZERO);\n    });\n}\n\n#[test]\npub fn mod_fail() {\n    apply_fn_to_primitive_ints!(mod_fail_helper);\n}\n\n#[test]\nfn test_neg_mod() {\n    fn test<T: PrimitiveUnsigned>(n: T, d: T, r: T) {\n        assert_eq!(n.neg_mod(d), r);\n\n        let mut mut_n = n;\n        mut_n.neg_mod_assign(d);\n        assert_eq!(mut_n, r);\n    }\n    test::<u8>(0, 1, 0);\n    test::<u16>(0, 123, 0);\n    test::<u32>(1, 1, 0);\n    test::<u64>(123, 1, 0);\n    test::<u128>(123, 123, 0);\n    test::<usize>(123, 456, 333);\n    test::<u16>(456, 123, 36);\n    test::<u64>(0xffffffff, 1, 0);\n    test::<u64>(0xffffffff, 0xffffffff, 0);\n    test::<u64>(1000000000000, 1, 0);\n    test::<u64>(1000000000000, 3, 2);\n    test::<u64>(1000000000000, 123, 23);\n    test::<u64>(1000000000000, 0xffffffff, 727379735);\n    test::<u128>(1000000000000000000000000, 1, 0);\n    test::<u128>(1000000000000000000000000, 3, 2);\n    test::<u128>(1000000000000000000000000, 123, 86);\n    test::<u128>(1000000000000000000000000, 0xffffffff, 1127243600);\n    test::<u128>(1000000000000000000000000, 1234567890987, 704498996588);\n    test::<u128>(253640751230376270397812803167, 2669936877441, 1149635115107);\n    test::<u64>(3768477692975601, 11447376614057827956, 11443608136364852355);\n    test::<u64>(3356605361737854, 3081095617839357, 2805585873940860);\n    test::<u128>(\n        1098730198198174614195,\n        953382298040157850476,\n        808034397882141086757,\n    );\n    test::<u128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        0,\n    );\n    test::<u128>(1000000000000000000000000, 1000000000000000000000000, 0);\n    test::<u128>(0, 1000000000000000000000000, 0);\n    test::<u128>(123, 1000000000000000000000000, 999999999999999999999877);\n}\n\nfn neg_mod_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.neg_mod(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.neg_mod_assign(T::ZERO);\n    });\n}\n\n#[test]\npub fn neg_mod_fail() {\n    apply_fn_to_unsigneds!(neg_mod_fail_helper);\n}\n\n#[test]\nfn test_ceiling_mod() {\n    fn test<T: PrimitiveSigned>(n: T, d: T, r: T) {\n        assert_eq!(n.ceiling_mod(d), r);\n\n        let mut mut_n = n;\n        mut_n.ceiling_mod_assign(d);\n        assert_eq!(mut_n, r);\n    }\n    test::<i8>(0, 1, 0);\n    test::<i16>(0, 123, 0);\n    test::<i32>(1, 1, 0);\n    test::<i64>(123, 1, 0);\n    test::<i128>(123, 123, 0);\n    test::<isize>(123, 456, -333);\n    test::<i16>(456, 123, -36);\n    test::<i64>(0xffffffff, 1, 0);\n    test::<i64>(0xffffffff, 0xffffffff, 0);\n    test::<i64>(1000000000000, 1, 0);\n    test::<i64>(1000000000000, 3, -2);\n    test::<i64>(1000000000000, 123, -23);\n    test::<i64>(1000000000000, 0xffffffff, -727379735);\n    test::<i128>(1000000000000000000000000, 1, 0);\n    test::<i128>(1000000000000000000000000, 3, -2);\n    test::<i128>(1000000000000000000000000, 123, -86);\n    test::<i128>(1000000000000000000000000, 0xffffffff, -1127243600);\n    test::<i128>(1000000000000000000000000, 1234567890987, -704498996588);\n    test::<i128>(\n        253640751230376270397812803167,\n        2669936877441,\n        -1149635115107,\n    );\n    test::<i128>(\n        3768477692975601,\n        11447376614057827956,\n        -11443608136364852355,\n    );\n    test::<i64>(3356605361737854, 3081095617839357, -2805585873940860);\n    test::<i128>(\n        1098730198198174614195,\n        953382298040157850476,\n        -808034397882141086757,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, 1000000000000000000000000, 0);\n    test::<i128>(0, 1000000000000000000000000, 0);\n    test::<i128>(123, 1000000000000000000000000, -999999999999999999999877);\n\n    test::<i8>(0, -1, 0);\n    test::<i16>(0, -123, 0);\n    test::<i32>(1, -1, 0);\n    test::<i64>(123, -1, 0);\n    test::<i128>(123, -123, 0);\n    test::<isize>(123, -456, 123);\n    test::<i16>(456, -123, 87);\n    test::<i64>(0xffffffff, -1, 0);\n    test::<i64>(0xffffffff, -0xffffffff, 0);\n    test::<i64>(1000000000000, -1, 0);\n    test::<i64>(1000000000000, -3, 1);\n    test::<i64>(1000000000000, -123, 100);\n    test::<i64>(1000000000000, -0xffffffff, 3567587560);\n    test::<i128>(1000000000000000000000000, -1, 0);\n    test::<i128>(1000000000000000000000000, -3, 1);\n    test::<i128>(1000000000000000000000000, -123, 37);\n    test::<i128>(1000000000000000000000000, -0xffffffff, 3167723695);\n    test::<i128>(1000000000000000000000000, -1234567890987, 530068894399);\n    test::<i128>(\n        253640751230376270397812803167,\n        -2669936877441,\n        1520301762334,\n    );\n    test::<i128>(3768477692975601, -11447376614057827956, 3768477692975601);\n    test::<i64>(3356605361737854, -3081095617839357, 275509743898497);\n    test::<i128>(\n        1098730198198174614195,\n        -953382298040157850476,\n        145347900158016763719,\n    );\n    test::<i128>(\n        69738658860594537152875081748,\n        -69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(1000000000000000000000000, -1000000000000000000000000, 0);\n    test::<i128>(0, -1000000000000000000000000, 0);\n    test::<i128>(123, -1000000000000000000000000, 123);\n\n    test::<i8>(-1, 1, 0);\n    test::<i16>(-123, 1, 0);\n    test::<i32>(-123, 123, 0);\n    test::<i64>(-123, 456, -123);\n    test::<i128>(-456, 123, -87);\n    test::<isize>(-0xffffffff, 1, 0);\n    test::<i64>(-0xffffffff, 0xffffffff, 0);\n    test::<i64>(-1000000000000, 1, 0);\n    test::<i64>(-1000000000000, 3, -1);\n    test::<i64>(-1000000000000, 123, -100);\n    test::<i64>(-1000000000000, 0xffffffff, -3567587560);\n    test::<i128>(-1000000000000000000000000, 1, 0);\n    test::<i128>(-1000000000000000000000000, 3, -1);\n    test::<i128>(-1000000000000000000000000, 123, -37);\n    test::<i128>(-1000000000000000000000000, 0xffffffff, -3167723695);\n    test::<i128>(-1000000000000000000000000, 1234567890987, -530068894399);\n    test::<i128>(\n        -253640751230376270397812803167,\n        2669936877441,\n        -1520301762334,\n    );\n    test::<i128>(-3768477692975601, 11447376614057827956, -3768477692975601);\n    test::<i64>(-3356605361737854, 3081095617839357, -275509743898497);\n    test::<i128>(\n        -1098730198198174614195,\n        953382298040157850476,\n        -145347900158016763719,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, 1000000000000000000000000, 0);\n    test::<i128>(0, 1000000000000000000000000, 0);\n    test::<i128>(-123, 1000000000000000000000000, -123);\n\n    test::<i8>(-1, -1, 0);\n    test::<i16>(-123, -1, 0);\n    test::<i32>(-123, -123, 0);\n    test::<i64>(-123, -456, 333);\n    test::<i128>(-456, -123, 36);\n    test::<isize>(-0xffffffff, -1, 0);\n    test::<i64>(-0xffffffff, -0xffffffff, 0);\n    test::<i64>(-1000000000000, -1, 0);\n    test::<i64>(-1000000000000, -3, 2);\n    test::<i64>(-1000000000000, -123, 23);\n    test::<i64>(-1000000000000, -0xffffffff, 727379735);\n    test::<i128>(-1000000000000000000000000, -1, 0);\n    test::<i128>(-1000000000000000000000000, -3, 2);\n    test::<i128>(-1000000000000000000000000, -123, 86);\n    test::<i128>(-1000000000000000000000000, -0xffffffff, 1127243600);\n    test::<i128>(-1000000000000000000000000, -1234567890987, 704498996588);\n    test::<i128>(\n        -253640751230376270397812803167,\n        -2669936877441,\n        1149635115107,\n    );\n    test::<i128>(\n        -3768477692975601,\n        -11447376614057827956,\n        11443608136364852355,\n    );\n    test::<i64>(-3356605361737854, -3081095617839357, 2805585873940860);\n    test::<i128>(\n        -1098730198198174614195,\n        -953382298040157850476,\n        808034397882141086757,\n    );\n    test::<i128>(\n        -69738658860594537152875081748,\n        -69738658860594537152875081748,\n        0,\n    );\n    test::<i128>(-1000000000000000000000000, -1000000000000000000000000, 0);\n    test::<i128>(0, -1000000000000000000000000, 0);\n    test::<i128>(-123, -1000000000000000000000000, 999999999999999999999877);\n\n    test::<i8>(-128, -1, 0);\n}\n\nfn ceiling_mod_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::ONE.ceiling_mod(T::ZERO));\n    assert_panic!({\n        let mut n = T::ONE;\n        n.ceiling_mod_assign(T::ZERO);\n    });\n}\n\n#[test]\npub fn ceiling_mod_fail() {\n    apply_fn_to_signeds!(ceiling_mod_fail_helper);\n}\n\nfn mod_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        mut_x.mod_assign(y);\n        let r = mut_x;\n\n        assert_eq!(x.mod_op(y), r);\n\n        let mut mut_x = x;\n        mut_x %= y;\n        assert_eq!(mut_x, r);\n        assert_eq!(x % y, r);\n        assert_eq!(x.div_mod(y).1, r);\n        assert_eq!(x.div_rem(y).1, r);\n        assert!(r < y);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.mod_op(T::ONE), T::ZERO);\n        assert_panic!(x.mod_op(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.mod_assign(T::ZERO);\n        });\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|x| {\n        assert_eq!(x.mod_op(x), T::ZERO);\n        assert_eq!(T::ZERO.mod_op(x), T::ZERO);\n        if x > T::ONE {\n            assert_eq!(T::ONE.mod_op(x), T::ONE);\n        }\n    });\n}\n\nfn mod_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_6::<T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        mut_x.mod_assign(y);\n        let r = mut_x;\n\n        assert_eq!(x.mod_op(y), r);\n        assert!(r.lt_abs(&y));\n        assert!(r == T::ZERO || (r > T::ZERO) == (y > T::ZERO));\n        if x != T::MIN {\n            assert_eq!(x.ceiling_mod(y), -(-x).mod_op(y));\n        }\n        if y != T::MIN {\n            assert_eq!(x.ceiling_mod(y), x.mod_op(-y));\n        }\n    });\n\n    signed_pair_gen_var_4::<T>().test_properties(|(x, y)| {\n        assert_eq!(x.mod_op(y), x.div_mod(y).1);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.mod_op(T::ONE), T::ZERO);\n        assert_eq!(x.mod_op(T::NEGATIVE_ONE), T::ZERO);\n        assert_panic!(x.mod_op(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.mod_assign(T::ZERO);\n        });\n    });\n\n    signed_gen_var_6::<T>().test_properties(|x| {\n        assert_eq!(x.mod_op(T::ONE), T::ZERO);\n        assert_eq!(x.mod_op(x), T::ZERO);\n        assert_eq!(T::ZERO.mod_op(x), T::ZERO);\n        assert_eq!(x.mod_op(T::NEGATIVE_ONE), T::ZERO);\n        if x != T::MIN {\n            assert_eq!(x.mod_op(-x), T::ZERO);\n        }\n        if x > T::ONE {\n            assert_eq!(T::ONE.mod_op(x), T::ONE);\n            assert_eq!(T::NEGATIVE_ONE.mod_op(x), x - T::ONE);\n        }\n    });\n}\n\n#[test]\nfn mod_properties() {\n    apply_fn_to_unsigneds!(mod_properties_helper_unsigned);\n    apply_fn_to_signeds!(mod_properties_helper_signed);\n}\n\nfn neg_mod_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        mut_x.neg_mod_assign(y);\n        let r = mut_x;\n        assert_eq!(x.neg_mod(y), r);\n        assert_eq!(x.ceiling_div_neg_mod(y).1, r);\n        assert!(r < y);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.neg_mod(T::ONE), T::ZERO);\n        assert_panic!(x.neg_mod(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.neg_mod_assign(T::ZERO);\n        });\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|x| {\n        assert_eq!(x.neg_mod(x), T::ZERO);\n        assert_eq!(T::ZERO.neg_mod(x), T::ZERO);\n        if x > T::ONE {\n            assert_eq!(T::ONE.neg_mod(x), x - T::ONE);\n        }\n    });\n}\n\n#[test]\nfn neg_mod_properties() {\n    apply_fn_to_unsigneds!(neg_mod_properties_helper);\n}\n\nfn ceiling_mod_properties_helper<T: PrimitiveSigned>() {\n    signed_pair_gen_var_6::<T>().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        mut_x.ceiling_mod_assign(y);\n        let r = mut_x;\n        assert_eq!(x.ceiling_mod(y), r);\n        assert!(r.lt_abs(&y));\n        assert!(r == T::ZERO || (r > T::ZERO) != (y > T::ZERO));\n        if x != T::MIN {\n            assert_eq!(x.mod_op(y), -(-x).ceiling_mod(y));\n        }\n        if y != T::MIN {\n            assert_eq!(x.mod_op(y), x.ceiling_mod(-y));\n        }\n    });\n\n    signed_pair_gen_var_4::<T>().test_properties(|(x, y)| {\n        assert_eq!(x.ceiling_mod(y), x.ceiling_div_mod(y).1);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.ceiling_mod(T::ONE), T::ZERO);\n        assert_eq!(x.ceiling_mod(T::NEGATIVE_ONE), T::ZERO);\n    });\n\n    signed_gen_var_6::<T>().test_properties(|x| {\n        assert_eq!(x.ceiling_mod(T::ONE), T::ZERO);\n        assert_eq!(x.ceiling_mod(T::NEGATIVE_ONE), T::ZERO);\n        assert_eq!(x.ceiling_mod(x), T::ZERO);\n        if x != T::MIN {\n            assert_eq!(x.ceiling_mod(-x), T::ZERO);\n        }\n        assert_eq!(T::ZERO.ceiling_mod(x), T::ZERO);\n    });\n}\n\n#[test]\nfn ceiling_mod_properties() {\n    apply_fn_to_signeds!(ceiling_mod_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_pow::simple_binary_mod_pow;\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen, unsigned_pair_gen_var_12, unsigned_pair_gen_var_16,\n    unsigned_quadruple_gen_var_6, unsigned_quadruple_gen_var_7, unsigned_triple_gen_var_14,\n    unsigned_triple_gen_var_15,\n};\nuse malachite_base::test_util::num::arithmetic::mod_pow::naive_mod_pow;\nuse std::panic::catch_unwind;\n\nfn mod_pow_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, exp: u64, m, out| {\n        assert_eq!(naive_mod_pow(x, exp, m), out);\n        assert_eq!(simple_binary_mod_pow(x, exp, m), out);\n\n        assert_eq!(x.mod_pow(exp, m), out);\n\n        let mut mut_x = x;\n        mut_x.mod_pow_assign(exp, m);\n        assert_eq!(mut_x, out);\n\n        let data = T::precompute_mod_pow_data(&m);\n        assert_eq!(x.mod_pow_precomputed(exp, m, &data), out);\n\n        let mut mut_x = x;\n        mut_x.mod_pow_precomputed_assign(exp, m, &data);\n        assert_eq!(mut_x, out);\n    };\n    test(T::ZERO, 0, T::ONE, T::ZERO);\n    test(T::ZERO, 0, T::exact_from(10), T::ONE);\n    test(T::ZERO, 1, T::exact_from(10), T::ZERO);\n\n    test(T::TWO, 10, T::exact_from(10), T::exact_from(4));\n    if T::WIDTH > u8::WIDTH {\n        test(T::exact_from(4), 13, T::exact_from(497), T::exact_from(445));\n        test(\n            T::exact_from(10),\n            1000,\n            T::exact_from(30),\n            T::exact_from(10),\n        );\n        test(T::TWO, 340, T::exact_from(341), T::ONE);\n        test(T::exact_from(5), 216, T::exact_from(217), T::ONE);\n    }\n    if T::WIDTH > u16::WIDTH {\n        test(\n            T::TWO,\n            1000000,\n            T::exact_from(1000000000),\n            T::exact_from(747109376),\n        );\n    }\n}\n\n#[test]\nfn test_mod_pow() {\n    apply_fn_to_unsigneds!(mod_pow_helper);\n}\n\nfn mod_pow_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_pow(10, T::ZERO));\n    assert_panic!(T::from(123u8).mod_pow(10, T::from(123u8)));\n}\n\n#[test]\nfn mod_pow_fail() {\n    apply_fn_to_unsigneds!(mod_pow_fail_helper);\n}\n\nfn mod_pow_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_pow_assign(10, T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_pow_assign(10, T::from(123u8));\n    });\n}\n\n#[test]\nfn mod_pow_assign_fail() {\n    apply_fn_to_unsigneds!(mod_pow_assign_fail_helper);\n}\n\nfn mod_pow_properties_helper_helper<T: PrimitiveUnsigned, F: Fn(T, u64, T) -> T>(\n    x: T,\n    exp: u64,\n    m: T,\n    f: F,\n) {\n    assert!(x.mod_is_reduced(&m));\n    let power = x.mod_pow(exp, m);\n    assert!(power.mod_is_reduced(&m));\n\n    let mut x_alt = x;\n    x_alt.mod_pow_assign(exp, m);\n    assert_eq!(x_alt, power);\n\n    let data = T::precompute_mod_pow_data(&m);\n\n    assert_eq!(x.mod_pow_precomputed(exp, m, &data), power);\n\n    let mut x_alt = x;\n    x_alt.mod_pow_precomputed_assign(exp, m, &data);\n    assert_eq!(x_alt, power);\n\n    assert_eq!(f(x, exp, m), power);\n    if exp.even() {\n        assert_eq!(x.mod_neg(m).mod_pow(exp, m), power);\n    } else {\n        assert_eq!(x.mod_neg(m).mod_pow(exp, m), power.mod_neg(m));\n    }\n}\n\nfn mod_pow_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_15::<T, u64>().test_properties(|(x, exp, m)| {\n        mod_pow_properties_helper_helper(x, exp, m, simple_binary_mod_pow);\n    });\n\n    unsigned_triple_gen_var_14::<T, u64>()\n        .test_properties(|(x, exp, m)| mod_pow_properties_helper_helper(x, exp, m, naive_mod_pow));\n\n    unsigned_pair_gen_var_12::<u64, T>().test_properties(|(exp, m)| {\n        assert_eq!(T::ZERO.mod_pow(exp, m), T::from(exp == 0 && m != T::ONE));\n        if m != T::ONE {\n            assert_eq!(T::ONE.mod_pow(exp, m), T::ONE);\n        }\n    });\n\n    unsigned_pair_gen_var_16::<T>().test_properties(|(x, m)| {\n        assert_eq!(x.mod_pow(0, m), T::from(m != T::ONE));\n        assert_eq!(x.mod_pow(1, m), x);\n        assert_eq!(x.mod_pow(2, m), x.mod_mul(x, m));\n    });\n\n    unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        assert_panic!(x.mod_pow(y, T::ZERO));\n        assert_panic!({\n            let mut x = x;\n            x.mod_pow_assign(y, T::ZERO);\n        });\n    });\n\n    unsigned_quadruple_gen_var_6::<T, u64>().test_properties(|(x, y, exp, m)| {\n        assert_eq!(\n            x.mod_mul(y, m).mod_pow(exp, m),\n            x.mod_pow(exp, m).mod_mul(y.mod_pow(exp, m), m)\n        );\n    });\n\n    unsigned_quadruple_gen_var_7::<T, u64>().test_properties(|(x, e, f, m)| {\n        if let Some(sum) = e.checked_add(f) {\n            assert_eq!(\n                x.mod_pow(sum, m),\n                x.mod_pow(e, m).mod_mul(x.mod_pow(f, m), m)\n            );\n        }\n        if let Some(product) = e.checked_mul(f) {\n            assert_eq!(x.mod_pow(product, m), x.mod_pow(e, m).mod_pow(f, m));\n        }\n    });\n}\n\n#[test]\nfn mod_pow_properties() {\n    apply_fn_to_unsigneds!(mod_pow_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, ModPowerOf2IsReduced};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen_var_1, signed_unsigned_pair_gen_var_4,\n    signed_unsigned_pair_gen_var_10, signed_unsigned_pair_gen_var_11, unsigned_gen,\n    unsigned_pair_gen_var_2, unsigned_pair_gen_var_20, unsigned_triple_gen_var_4,\n    unsigned_triple_gen_var_13,\n};\nuse std::cmp::min;\nuse std::fmt::Debug;\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_mod_power_of_2_and_rem_power_of_2_unsigned() {\n    fn test<T: PrimitiveUnsigned>(x: T, pow: u64, out: T) {\n        assert_eq!(x.mod_power_of_2(pow), out);\n\n        let mut mut_x = x;\n        mut_x.mod_power_of_2_assign(pow);\n        assert_eq!(mut_x, out);\n\n        assert_eq!(x.rem_power_of_2(pow), out);\n\n        let mut mut_x = x;\n        mut_x.rem_power_of_2_assign(pow);\n        assert_eq!(mut_x, out);\n    }\n    test::<u8>(0, 0, 0);\n    test::<u16>(260, 8, 4);\n    test::<u32>(1611, 4, 11);\n    test::<u8>(123, 100, 123);\n    test::<u64>(1000000000000, 0, 0);\n    test::<u64>(1000000000000, 12, 0);\n    test::<u64>(1000000000001, 12, 1);\n    test::<u64>(999999999999, 12, 4095);\n    test::<u64>(1000000000000, 15, 4096);\n    test::<u64>(1000000000000, 100, 1000000000000);\n    test::<u128>(1000000000000000000000000, 40, 1020608380928);\n    test::<u128>(1000000000000000000000000, 64, 2003764205206896640);\n    test::<u32>(u32::MAX, 31, 0x7fffffff);\n    test::<u32>(u32::MAX, 32, u32::MAX);\n    test::<usize>(0xffffffff, 33, 0xffffffff);\n    test::<u64>(0x100000000, 31, 0);\n    test::<u64>(0x100000000, 32, 0);\n    test::<u64>(0x100000000, 33, 0x100000000);\n    test::<u64>(0x100000001, 31, 1);\n    test::<u64>(0x100000001, 32, 1);\n    test::<u64>(0x100000001, 33, 0x100000001);\n}\n\n#[test]\nfn test_mod_power_of_2_signed() {\n    fn test<U: Copy + Debug + Eq, S: ModPowerOf2<Output = U> + PrimitiveSigned>(\n        x: S,\n        pow: u64,\n        out: U,\n    ) {\n        assert_eq!(x.mod_power_of_2(pow), out);\n    }\n    test::<_, i8>(0, 0, 0);\n    test::<_, i16>(2, 1, 0);\n    test::<_, i32>(260, 8, 4);\n    test::<_, i16>(1611, 4, 11);\n    test::<_, i8>(123, 100, 123);\n    test::<_, i64>(1000000000000, 0, 0);\n    test::<_, i64>(1000000000000, 12, 0);\n    test::<_, i64>(1000000000001, 12, 1);\n    test::<_, i64>(999999999999, 12, 4095);\n    test::<_, i64>(1000000000000, 15, 4096);\n    test::<_, i64>(1000000000000, 100, 1000000000000);\n    test::<_, i128>(1000000000000000000000000, 40, 1020608380928);\n    test::<_, i128>(1000000000000000000000000, 64, 2003764205206896640);\n    test::<_, i32>(0x7fffffff, 30, 0x3fffffff);\n    test::<_, i32>(0x7fffffff, 31, 0x7fffffff);\n    test::<_, isize>(0x7fffffff, 32, 0x7fffffff);\n    test::<_, i64>(0x80000000, 30, 0);\n    test::<_, i64>(0x80000000, 31, 0);\n    test::<_, i64>(0x80000000, 32, 0x80000000);\n    test::<_, i64>(0x80000001, 30, 1);\n    test::<_, i64>(0x80000001, 31, 1);\n    test::<_, i64>(0x80000001, 32, 0x80000001);\n    test::<_, i64>(0xffffffff, 31, 0x7fffffff);\n    test::<_, i64>(0xffffffff, 32, 0xffffffff);\n    test::<_, i64>(0xffffffff, 33, 0xffffffff);\n    test::<_, i64>(0x100000000, 31, 0);\n    test::<_, i64>(0x100000000, 32, 0);\n    test::<_, i64>(0x100000000, 33, 0x100000000);\n    test::<_, i64>(0x100000001, 31, 1);\n    test::<_, i64>(0x100000001, 32, 1);\n    test::<_, i64>(0x100000001, 33, 0x100000001);\n\n    test::<_, i8>(-2, 1, 0);\n    test::<_, i16>(-260, 8, 252);\n    test::<_, i32>(-1611, 4, 5);\n    test::<_, i128>(-123, 100, 1267650600228229401496703205253);\n    test::<_, i64>(-1000000000000, 0, 0);\n    test::<_, i64>(-1000000000000, 12, 0);\n    test::<_, i64>(-1000000000001, 12, 4095);\n    test::<_, i64>(-999999999999, 12, 1);\n    test::<_, i64>(-1000000000000, 15, 0x7000);\n    test::<_, i128>(-1000000000000, 100, 1267650600228229400496703205376);\n    test::<_, i128>(-1000000000000000000000000, 40, 78903246848);\n    test::<_, i128>(-1000000000000000000000000, 64, 16442979868502654976);\n    test::<_, i32>(-0x7fffffff, 30, 1);\n    test::<_, i32>(-0x7fffffff, 31, 1);\n    test::<_, i32>(-0x7fffffff, 32, 0x80000001);\n    test::<_, isize>(-0x80000000, 30, 0);\n    test::<_, isize>(-0x80000000, 31, 0);\n    test::<_, isize>(-0x80000000, 32, 0x80000000);\n    test::<_, i64>(-0x80000001, 30, 0x3fffffff);\n    test::<_, i64>(-0x80000001, 31, 0x7fffffff);\n    test::<_, i64>(-0x80000001, 32, 0x7fffffff);\n    test::<_, i64>(-0xffffffff, 31, 1);\n    test::<_, i64>(-0xffffffff, 32, 1);\n    test::<_, i64>(-0xffffffff, 33, 0x100000001);\n    test::<_, i64>(-0x100000000, 31, 0);\n    test::<_, i64>(-0x100000000, 32, 0);\n    test::<_, i64>(-0x100000000, 33, 0x100000000);\n    test::<_, i64>(-0x100000001, 31, 0x7fffffff);\n    test::<_, i64>(-0x100000001, 32, 0xffffffff);\n    test::<_, i64>(-0x100000001, 33, 0xffffffff);\n}\n\nfn mod_power_of_2_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::NEGATIVE_ONE.mod_power_of_2(200));\n}\n\n#[test]\nfn mod_power_of_2_signed_fail() {\n    apply_fn_to_signeds!(mod_power_of_2_signed_fail_helper);\n}\n\n#[test]\nfn test_mod_power_of_2_assign_signed() {\n    fn test<T: PrimitiveSigned>(x: T, pow: u64, out: T) {\n        let mut mut_x = x;\n        mut_x.mod_power_of_2_assign(pow);\n        assert_eq!(mut_x, out);\n    }\n    test::<i8>(0, 0, 0);\n    test::<i16>(2, 1, 0);\n    test::<i32>(260, 8, 4);\n    test::<i16>(1611, 4, 11);\n    test::<i8>(123, 100, 123);\n    test::<i64>(1000000000000, 0, 0);\n    test::<i64>(1000000000000, 12, 0);\n    test::<i64>(1000000000001, 12, 1);\n    test::<i64>(999999999999, 12, 4095);\n    test::<i64>(1000000000000, 15, 4096);\n    test::<i64>(1000000000000, 100, 1000000000000);\n    test::<i128>(1000000000000000000000000, 40, 1020608380928);\n    test::<i128>(1000000000000000000000000, 64, 2003764205206896640);\n    test::<i32>(0x7fffffff, 30, 0x3fffffff);\n    test::<i32>(0x7fffffff, 31, 0x7fffffff);\n    test::<isize>(0x7fffffff, 32, 0x7fffffff);\n    test::<i64>(0x80000000, 30, 0);\n    test::<i64>(0x80000000, 31, 0);\n    test::<i64>(0x80000000, 32, 0x80000000);\n    test::<i64>(0x80000001, 30, 1);\n    test::<i64>(0x80000001, 31, 1);\n    test::<i64>(0x80000001, 32, 0x80000001);\n    test::<i64>(0xffffffff, 31, 0x7fffffff);\n    test::<i64>(0xffffffff, 32, 0xffffffff);\n    test::<i64>(0xffffffff, 33, 0xffffffff);\n    test::<i64>(0x100000000, 31, 0);\n    test::<i64>(0x100000000, 32, 0);\n    test::<i64>(0x100000000, 33, 0x100000000);\n    test::<i64>(0x100000001, 31, 1);\n    test::<i64>(0x100000001, 32, 1);\n    test::<i64>(0x100000001, 33, 0x100000001);\n\n    test::<i8>(-2, 1, 0);\n    test::<i16>(-260, 8, 252);\n    test::<i32>(-1611, 4, 5);\n    test::<i128>(-123, 100, 1267650600228229401496703205253);\n    test::<i64>(-1000000000000, 0, 0);\n    test::<i64>(-1000000000000, 12, 0);\n    test::<i64>(-1000000000001, 12, 4095);\n    test::<i64>(-999999999999, 12, 1);\n    test::<i64>(-1000000000000, 15, 0x7000);\n    test::<i128>(-1000000000000, 100, 1267650600228229400496703205376);\n    test::<i128>(-1000000000000000000000000, 40, 78903246848);\n    test::<i128>(-1000000000000000000000000, 64, 16442979868502654976);\n    test::<i32>(-0x7fffffff, 30, 1);\n    test::<i32>(-0x7fffffff, 31, 1);\n    test::<i64>(-0x7fffffff, 32, 0x80000001);\n    test::<isize>(-0x80000000, 30, 0);\n    test::<isize>(-0x80000000, 31, 0);\n    test::<i64>(-0x80000000, 32, 0x80000000);\n    test::<i64>(-0x80000001, 30, 0x3fffffff);\n    test::<i64>(-0x80000001, 31, 0x7fffffff);\n    test::<i64>(-0x80000001, 32, 0x7fffffff);\n    test::<i64>(-0xffffffff, 31, 1);\n    test::<i64>(-0xffffffff, 32, 1);\n    test::<i64>(-0xffffffff, 33, 0x100000001);\n    test::<i64>(-0x100000000, 31, 0);\n    test::<i64>(-0x100000000, 32, 0);\n    test::<i64>(-0x100000000, 33, 0x100000000);\n    test::<i64>(-0x100000001, 31, 0x7fffffff);\n    test::<i64>(-0x100000001, 32, 0xffffffff);\n    test::<i64>(-0x100000001, 33, 0xffffffff);\n}\n\nfn mod_power_of_2_assign_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!({\n        let mut x = T::NEGATIVE_ONE;\n        x.mod_power_of_2_assign(200);\n    });\n    assert_panic!({\n        let mut x = T::MIN;\n        x.mod_power_of_2_assign(T::WIDTH);\n    });\n}\n\n#[test]\nfn mod_power_of_2_assign_signed_fail() {\n    apply_fn_to_signeds!(mod_power_of_2_assign_signed_fail_helper);\n}\n\n#[test]\nfn test_rem_power_of_2_signed() {\n    fn test<T: PrimitiveSigned>(x: T, pow: u64, out: T) {\n        assert_eq!(x.rem_power_of_2(pow), out);\n\n        let mut mut_x = x;\n        mut_x.rem_power_of_2_assign(pow);\n        assert_eq!(mut_x, out);\n    }\n    test::<i8>(0, 0, 0);\n    test::<i16>(2, 1, 0);\n    test::<i32>(260, 8, 4);\n    test::<i64>(1611, 4, 11);\n    test::<i8>(123, 100, 123);\n    test::<i64>(1000000000000, 0, 0);\n    test::<i64>(1000000000000, 12, 0);\n    test::<i64>(1000000000001, 12, 1);\n    test::<i64>(999999999999, 12, 4095);\n    test::<i64>(1000000000000, 15, 4096);\n    test::<i64>(1000000000000, 100, 1000000000000);\n    test::<i128>(1000000000000000000000000, 40, 1020608380928);\n    test::<i128>(1000000000000000000000000, 64, 2003764205206896640);\n    test::<i32>(0x7fffffff, 30, 0x3fffffff);\n    test::<i32>(0x7fffffff, 31, 0x7fffffff);\n    test::<isize>(0x7fffffff, 32, 0x7fffffff);\n    test::<i64>(0x80000000, 30, 0);\n    test::<i64>(0x80000000, 31, 0);\n    test::<i64>(0x80000000, 32, 0x80000000);\n    test::<i64>(0x80000001, 30, 1);\n    test::<i64>(0x80000001, 31, 1);\n    test::<i64>(0x80000001, 32, 0x80000001);\n    test::<i64>(0xffffffff, 31, 0x7fffffff);\n    test::<i64>(0xffffffff, 32, 0xffffffff);\n    test::<i64>(0xffffffff, 33, 0xffffffff);\n    test::<i64>(0x100000000, 31, 0);\n    test::<i64>(0x100000000, 32, 0);\n    test::<i64>(0x100000000, 33, 0x100000000);\n    test::<i64>(0x100000001, 31, 1);\n    test::<i64>(0x100000001, 32, 1);\n    test::<i64>(0x100000001, 33, 0x100000001);\n\n    test::<i8>(-2, 1, 0);\n    test::<i16>(-260, 8, -4);\n    test::<i32>(-1611, 4, -11);\n    test::<i64>(-123, 100, -123);\n    test::<i64>(-1000000000000, 0, 0);\n    test::<i64>(-1000000000000, 12, 0);\n    test::<i64>(-1000000000001, 12, -1);\n    test::<i64>(-999999999999, 12, -4095);\n    test::<i64>(-1000000000000, 15, -4096);\n    test::<i64>(-1000000000000, 100, -1000000000000);\n    test::<i128>(-1000000000000000000000000, 40, -1020608380928);\n    test::<i128>(-1000000000000000000000000, 64, -2003764205206896640);\n    test::<i32>(-0x7fffffff, 30, -0x3fffffff);\n    test::<i32>(-0x7fffffff, 31, -0x7fffffff);\n    test::<isize>(-0x7fffffff, 32, -0x7fffffff);\n    test::<i64>(-0x80000000, 30, 0);\n    test::<i64>(-0x80000000, 31, 0);\n    test::<i64>(-0x80000000, 32, -0x80000000);\n    test::<i64>(-0x80000001, 30, -1);\n    test::<i64>(-0x80000001, 31, -1);\n    test::<i64>(-0x80000001, 32, -0x80000001);\n    test::<i64>(-0xffffffff, 31, -0x7fffffff);\n    test::<i64>(-0xffffffff, 32, -0xffffffff);\n    test::<i64>(-0xffffffff, 33, -0xffffffff);\n    test::<i64>(-0x100000000, 31, 0);\n    test::<i64>(-0x100000000, 32, 0);\n    test::<i64>(-0x100000000, 33, -0x100000000);\n    test::<i64>(-0x100000001, 31, -1);\n    test::<i64>(-0x100000001, 32, -1);\n    test::<i64>(-0x100000001, 33, -0x100000001);\n}\n\n#[test]\nfn test_neg_mod_power_of_2_unsigned() {\n    fn test<T: PrimitiveUnsigned>(x: T, pow: u64, out: T) {\n        assert_eq!(x.neg_mod_power_of_2(pow), out);\n\n        let mut mut_x = x;\n        mut_x.neg_mod_power_of_2_assign(pow);\n        assert_eq!(mut_x, out);\n    }\n    test::<u8>(0, 0, 0);\n    test::<u16>(260, 8, 252);\n    test::<u32>(1611, 4, 5);\n    test::<u32>(1, 32, u32::MAX);\n    test::<u128>(123, 100, 1267650600228229401496703205253);\n    test::<u64>(1000000000000, 0, 0);\n    test::<u64>(1000000000000, 12, 0);\n    test::<u64>(1000000000001, 12, 4095);\n    test::<u64>(999999999999, 12, 1);\n    test::<u64>(1000000000000, 15, 0x7000);\n    test::<u128>(1000000000000, 100, 1267650600228229400496703205376);\n    test::<u128>(1000000000000000000000000, 40, 78903246848);\n    test::<u128>(1000000000000000000000000, 64, 16442979868502654976);\n    test::<u32>(u32::MAX, 31, 1);\n    test::<usize>(0xffffffff, 32, 1);\n    test::<u64>(0xffffffff, 33, 0x100000001);\n    test::<u64>(0x100000000, 31, 0);\n    test::<u64>(0x100000000, 32, 0);\n    test::<u64>(0x100000000, 33, 0x100000000);\n    test::<u64>(0x100000001, 31, 0x7fffffff);\n    test::<u64>(0x100000001, 32, 0xffffffff);\n    test::<u64>(0x100000001, 33, 0xffffffff);\n}\n\nfn neg_mod_power_of_2_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.neg_mod_power_of_2(200));\n    assert_panic!(T::MAX.neg_mod_power_of_2(T::WIDTH + 1));\n    assert_panic!({\n        let mut x = T::ONE;\n        x.neg_mod_power_of_2_assign(200);\n    });\n    assert_panic!({\n        let mut x = T::MAX;\n        x.neg_mod_power_of_2_assign(T::WIDTH + 1);\n    });\n}\n\n#[test]\nfn neg_mod_power_of_2_fail() {\n    apply_fn_to_unsigneds!(neg_mod_power_of_2_fail_helper);\n}\n\n#[test]\nfn test_ceiling_mod_power_of_2_signed() {\n    fn test<T: PrimitiveSigned>(x: T, pow: u64, out: T) {\n        assert_eq!(x.ceiling_mod_power_of_2(pow), out);\n\n        let mut mut_x = x;\n        mut_x.ceiling_mod_power_of_2_assign(pow);\n        assert_eq!(mut_x, out);\n    }\n    test::<i8>(0, 0, 0);\n    test::<i16>(2, 1, 0);\n    test::<i32>(260, 8, -252);\n    test::<i64>(1611, 4, -5);\n    test::<i128>(123, 100, -1267650600228229401496703205253);\n    test::<i64>(1000000000000, 0, 0);\n    test::<i64>(1000000000000, 12, 0);\n    test::<i64>(1000000000001, 12, -4095);\n    test::<i64>(999999999999, 12, -1);\n    test::<i64>(1000000000000, 15, -0x7000);\n    test::<i128>(1000000000000, 100, -1267650600228229400496703205376);\n    test::<i128>(1000000000000000000000000, 40, -78903246848);\n    test::<i128>(1000000000000000000000000, 64, -16442979868502654976);\n    test::<i32>(0x7fffffff, 30, -1);\n    test::<isize>(0x7fffffff, 31, -1);\n    test::<i64>(0x7fffffff, 32, -0x80000001);\n    test::<i64>(0x80000000, 30, 0);\n    test::<i64>(0x80000000, 31, 0);\n    test::<i64>(0x80000000, 32, -0x80000000);\n    test::<i64>(0x80000001, 30, -0x3fffffff);\n    test::<i64>(0x80000001, 31, -0x7fffffff);\n    test::<i64>(0x80000001, 32, -0x7fffffff);\n    test::<i64>(0xffffffff, 31, -1);\n    test::<i64>(0xffffffff, 32, -1);\n    test::<i64>(0xffffffff, 33, -0x100000001);\n    test::<i64>(0x100000000, 31, 0);\n    test::<i64>(0x100000000, 32, 0);\n    test::<i64>(0x100000000, 33, -0x100000000);\n    test::<i64>(0x100000001, 31, -0x7fffffff);\n    test::<i64>(0x100000001, 32, -0xffffffff);\n    test::<i64>(0x100000001, 33, -0xffffffff);\n\n    test::<i8>(-2, 1, 0);\n    test::<i16>(-260, 8, -4);\n    test::<i32>(-1611, 4, -11);\n    test::<i64>(-123, 100, -123);\n    test::<i64>(-1000000000000, 0, 0);\n    test::<i64>(-1000000000000, 12, 0);\n    test::<i64>(-1000000000001, 12, -1);\n    test::<i64>(-999999999999, 12, -4095);\n    test::<i64>(-1000000000000, 15, -4096);\n    test::<i64>(-1000000000000, 100, -1000000000000);\n    test::<i128>(-1000000000000000000000000, 40, -1020608380928);\n    test::<i128>(-1000000000000000000000000, 64, -2003764205206896640);\n    test::<i32>(-0x7fffffff, 30, -0x3fffffff);\n    test::<i32>(-0x7fffffff, 31, -0x7fffffff);\n    test::<i32>(-0x7fffffff, 32, -0x7fffffff);\n    test::<i32>(-0x80000000, 31, 0);\n    test::<isize>(-0x80000000, 30, 0);\n    test::<isize>(-0x80000000, 31, 0);\n    test::<isize>(-0x80000000, 32, -0x80000000);\n    test::<i64>(-0x80000001, 30, -1);\n    test::<i64>(-0x80000001, 31, -1);\n    test::<i64>(-0x80000001, 32, -0x80000001);\n    test::<i64>(-0xffffffff, 31, -0x7fffffff);\n    test::<i64>(-0xffffffff, 32, -0xffffffff);\n    test::<i64>(-0xffffffff, 33, -0xffffffff);\n    test::<i64>(-0x100000000, 31, 0);\n    test::<i64>(-0x100000000, 32, 0);\n    test::<i64>(-0x100000000, 33, -0x100000000);\n    test::<i64>(-0x100000001, 31, -1);\n    test::<i64>(-0x100000001, 32, -1);\n    test::<i64>(-0x100000001, 33, -0x100000001);\n}\n\nfn ceiling_mod_power_of_2_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::ONE.ceiling_mod_power_of_2(T::WIDTH));\n    assert_panic!(T::MIN.ceiling_mod_power_of_2(T::WIDTH));\n    assert_panic!({\n        let mut x = T::ONE;\n        x.ceiling_mod_power_of_2_assign(T::WIDTH);\n    });\n    assert_panic!({\n        let mut x = T::MIN;\n        x.ceiling_mod_power_of_2_assign(T::WIDTH);\n    });\n}\n\n#[test]\nfn ceiling_mod_power_of_2_fail() {\n    apply_fn_to_signeds!(ceiling_mod_power_of_2_fail_helper);\n}\n\nfn mod_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, pow)| {\n        let mut mut_n = n;\n        mut_n.mod_power_of_2_assign(pow);\n        let result = mut_n;\n        assert!(result.mod_power_of_2_is_reduced(pow));\n        assert_eq!(n.mod_power_of_2(pow), result);\n\n        let mut mut_n = n;\n        mut_n.rem_power_of_2_assign(pow);\n        assert_eq!(mut_n, result);\n        assert_eq!(n.rem_power_of_2(pow), result);\n\n        assert!(result <= n);\n        assert_eq!(result == T::ZERO, n.divisible_by_power_of_2(pow));\n        assert_eq!(result.mod_power_of_2(pow), result);\n    });\n\n    unsigned_triple_gen_var_4::<T, u64>().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.wrapping_add(y).mod_power_of_2(pow),\n            x.mod_power_of_2(pow)\n                .wrapping_add(y.mod_power_of_2(pow))\n                .mod_power_of_2(pow)\n        );\n        assert_eq!(\n            x.wrapping_mul(y).mod_power_of_2(pow),\n            x.mod_power_of_2(pow)\n                .wrapping_mul(y.mod_power_of_2(pow))\n                .mod_power_of_2(pow)\n        );\n    });\n\n    unsigned_triple_gen_var_13::<T, u64>().test_properties(|(n, u, v)| {\n        assert_eq!(\n            n.mod_power_of_2(u).mod_power_of_2(v),\n            n.mod_power_of_2(min(u, v))\n        );\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.mod_power_of_2(0), T::ZERO);\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert_eq!(T::ZERO.mod_power_of_2(pow), T::ZERO);\n    });\n}\n\nfn mod_power_of_2_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    <T as ModPowerOf2>::Output: ExactFrom<T> + PrimitiveUnsigned,\n{\n    signed_unsigned_pair_gen_var_10::<T>().test_properties(|(n, pow)| {\n        let result = n.mod_power_of_2(pow);\n        assert!(result.mod_power_of_2_is_reduced(pow));\n        assert_eq!(\n            result == <T as ModPowerOf2>::Output::ZERO,\n            n.divisible_by_power_of_2(pow)\n        );\n        assert_eq!(result.mod_power_of_2(pow), result);\n    });\n\n    signed_unsigned_pair_gen_var_4::<T>().test_properties(|(n, pow)| {\n        let mut mut_n = n;\n        mut_n.mod_power_of_2_assign(pow);\n        let result = mut_n;\n        assert_eq!(\n            n.mod_power_of_2(pow),\n            <T as ModPowerOf2>::Output::exact_from(result)\n        );\n\n        assert!(result >= T::ZERO);\n        assert_eq!(result == T::ZERO, n.divisible_by_power_of_2(pow));\n        assert_eq!(\n            result.mod_power_of_2(pow),\n            <T as ModPowerOf2>::Output::exact_from(result)\n        );\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.mod_power_of_2(0), <T as ModPowerOf2>::Output::ZERO);\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert_eq!(\n            T::ZERO.mod_power_of_2(pow),\n            <T as ModPowerOf2>::Output::ZERO\n        );\n    });\n}\n\n#[test]\nfn mod_power_of_2_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_properties_helper_unsigned);\n    apply_fn_to_signeds!(mod_power_of_2_properties_helper_signed);\n}\n\nfn rem_power_of_2_properties_helper<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_1::<T, u64>().test_properties(|(n, pow)| {\n        let mut mut_n = n;\n        mut_n.rem_power_of_2_assign(pow);\n        let result = mut_n;\n        assert_eq!(n.rem_power_of_2(pow), result);\n\n        if n != T::MIN {\n            assert_eq!((-n).rem_power_of_2(pow), -result);\n        }\n        assert!(result.le_abs(&n));\n        assert_eq!(result == T::ZERO, n.divisible_by_power_of_2(pow));\n        assert_eq!(result.rem_power_of_2(pow), result);\n        assert!(result == T::ZERO || (result > T::ZERO) == (n > T::ZERO));\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.rem_power_of_2(0), T::ZERO);\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert_eq!(T::ZERO.rem_power_of_2(pow), T::ZERO);\n    });\n}\n\n#[test]\nfn rem_power_of_2_properties() {\n    apply_fn_to_signeds!(rem_power_of_2_properties_helper);\n}\n\nfn neg_mod_power_of_2_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_20::<T>().test_properties(|(n, pow)| {\n        let mut mut_n = n;\n        mut_n.neg_mod_power_of_2_assign(pow);\n        let result = mut_n;\n        assert!(result.mod_power_of_2_is_reduced(pow));\n        assert_eq!(n.neg_mod_power_of_2(pow), result);\n\n        assert_eq!(result == T::ZERO, n.divisible_by_power_of_2(pow));\n        assert!(\n            result\n                .wrapping_add(n.mod_power_of_2(pow))\n                .divisible_by_power_of_2(pow)\n        );\n        assert_eq!(result.neg_mod_power_of_2(pow), n.mod_power_of_2(pow));\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.neg_mod_power_of_2(0), T::ZERO);\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert_eq!(T::ZERO.neg_mod_power_of_2(pow), T::ZERO);\n    });\n}\n\n#[test]\nfn neg_mod_power_of_2_properties() {\n    apply_fn_to_unsigneds!(neg_mod_power_of_2_properties_helper);\n}\n\nfn ceiling_mod_power_of_2_properties_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    signed_unsigned_pair_gen_var_11::<U, S>().test_properties(|(n, pow)| {\n        let mut mut_n = n;\n        mut_n.ceiling_mod_power_of_2_assign(pow);\n        let result = mut_n;\n        assert_eq!(n.ceiling_mod_power_of_2(pow), result);\n\n        assert!(result <= S::ZERO);\n        assert_eq!(result == S::ZERO, n.divisible_by_power_of_2(pow));\n    });\n\n    signed_gen::<S>().test_properties(|n| {\n        assert_eq!(n.ceiling_mod_power_of_2(0), S::ZERO);\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert_eq!(S::ZERO.ceiling_mod_power_of_2(pow), S::ZERO);\n    });\n}\n\n#[test]\nfn ceiling_mod_power_of_2_properties() {\n    apply_fn_to_unsigned_signed_pairs!(ceiling_mod_power_of_2_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_17, unsigned_quadruple_gen_var_3, unsigned_triple_gen_var_11,\n};\nuse std::panic::catch_unwind;\n\nfn mod_power_of_2_add_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, y: T, pow, out| {\n        assert_eq!(x.mod_power_of_2_add(y, pow), out);\n\n        let mut x = x;\n        x.mod_power_of_2_add_assign(y, pow);\n        assert_eq!(x, out);\n    };\n    test(T::ZERO, T::ZERO, 0, T::ZERO);\n    test(T::ZERO, T::ONE, 1, T::ONE);\n    test(T::ONE, T::ONE, 1, T::ZERO);\n    test(T::ZERO, T::TWO, 5, T::TWO);\n    test(T::exact_from(10), T::exact_from(14), 4, T::exact_from(8));\n    test(T::exact_from(100), T::exact_from(200), 8, T::exact_from(44));\n    test(T::MAX, T::ONE, T::WIDTH, T::ZERO);\n    test(T::MAX, T::MAX, T::WIDTH, T::MAX - T::ONE);\n}\n\n#[test]\nfn test_mod_power_of_2_add() {\n    apply_fn_to_unsigneds!(mod_power_of_2_add_helper);\n}\n\nfn mod_power_of_2_add_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.mod_power_of_2_add(T::ZERO, 0));\n    assert_panic!(T::ZERO.mod_power_of_2_add(T::ONE, 0));\n    assert_panic!(T::from(123u8).mod_power_of_2_add(T::from(200u8), 7));\n    assert_panic!(T::from(200u8).mod_power_of_2_add(T::from(123u8), 7));\n}\n\n#[test]\nfn mod_power_of_2_add_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_add_fail_helper);\n}\n\nfn mod_power_of_2_add_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_add_assign(T::ZERO, 0);\n    });\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_power_of_2_add_assign(T::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_power_of_2_add_assign(T::from(200u8), 7);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_add_assign(T::from(123u8), 7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_add_assign_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_add_assign_fail_helper);\n}\n\nfn mod_power_of_2_add_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_11::<T>().test_properties(|(x, y, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        assert!(y.mod_power_of_2_is_reduced(pow));\n        let sum = x.mod_power_of_2_add(y, pow);\n        assert!(sum.mod_power_of_2_is_reduced(pow));\n\n        let mut x_alt = x;\n        x_alt.mod_power_of_2_add_assign(y, pow);\n        assert_eq!(x_alt, sum);\n\n        assert_eq!(sum.mod_power_of_2_sub(y, pow), x);\n        assert_eq!(sum.mod_power_of_2_sub(x, pow), y);\n        assert_eq!(y.mod_power_of_2_add(x, pow), sum);\n        assert_eq!(x.mod_power_of_2_sub(y.mod_power_of_2_neg(pow), pow), sum);\n    });\n\n    unsigned_pair_gen_var_17::<T>().test_properties(|(x, pow)| {\n        assert_eq!(x.mod_power_of_2_add(T::ZERO, pow), x);\n        assert_eq!(T::ZERO.mod_power_of_2_add(x, pow), x);\n        assert_eq!(\n            x.mod_power_of_2_add(x.mod_power_of_2_neg(pow), pow),\n            T::ZERO\n        );\n    });\n\n    unsigned_quadruple_gen_var_3::<T>().test_properties(|(x, y, z, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_add(y, pow).mod_power_of_2_add(z, pow),\n            x.mod_power_of_2_add(y.mod_power_of_2_add(z, pow), pow)\n        );\n    });\n}\n\n#[test]\nfn mod_power_of_2_add_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_add_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::mod_power_of_2_inverse::mod_power_of_2_inverse_fast;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::generators::{unsigned_gen_var_3, unsigned_pair_gen_var_39};\nuse malachite_base::test_util::num::arithmetic::mod_power_of_2_inverse::*;\nuse std::panic::catch_unwind;\n\nfn mod_power_of_2_inverse_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    let test = |n: U, pow, out| {\n        assert_eq!(n.mod_power_of_2_inverse(pow), out);\n        assert_eq!(mod_power_of_2_inverse_euclidean::<U, S>(n, pow), out);\n        assert_eq!(mod_power_of_2_inverse_fast(n, pow), out);\n    };\n\n    test(U::ONE, 5, Some(U::ONE));\n    test(U::exact_from(7), 5, Some(U::exact_from(23)));\n    test(U::exact_from(31), 5, Some(U::exact_from(31)));\n    test(U::ONE, U::WIDTH, Some(U::ONE));\n    test(U::MAX, U::WIDTH, Some(U::MAX));\n}\n\n#[test]\nfn test_mod_power_of_2_inverse() {\n    apply_fn_to_unsigned_signed_pairs!(mod_power_of_2_inverse_helper);\n}\n\nfn mod_power_of_2_inverse_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_power_of_2_inverse(5));\n    assert_panic!(T::from(30u8).mod_power_of_2_inverse(3));\n    assert_panic!(T::from(3u8).mod_power_of_2_inverse(200));\n    assert_panic!(T::ONE.mod_power_of_2_inverse(0));\n    assert_panic!(T::from(200u8).mod_power_of_2_inverse(7));\n}\n\n#[test]\nfn mod_power_of_2_inverse_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_inverse_fail_helper);\n}\n\nfn mod_power_of_2_inverse_properties_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    unsigned_pair_gen_var_39::<U>().test_properties(|(n, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let inverse = n.mod_power_of_2_inverse(pow);\n        assert_eq!(mod_power_of_2_inverse_euclidean::<U, S>(n, pow), inverse);\n        assert_eq!(mod_power_of_2_inverse_fast(n, pow), inverse);\n        assert_eq!(inverse.is_some(), n.odd());\n        if let Some(inverse) = inverse {\n            assert!(inverse.mod_power_of_2_is_reduced(pow));\n            assert_eq!(inverse.mod_power_of_2_inverse(pow), Some(n));\n            assert_eq!(n.mod_power_of_2_mul(inverse, pow), U::ONE);\n            assert_eq!(\n                n.mod_power_of_2_neg(pow).mod_power_of_2_inverse(pow),\n                Some(inverse.mod_power_of_2_neg(pow))\n            );\n        }\n    });\n\n    unsigned_gen_var_3::<U>().test_properties(|pow| {\n        assert_eq!(U::ONE.mod_power_of_2_inverse(pow), Some(U::ONE));\n        assert_eq!(\n            U::low_mask(pow).mod_power_of_2_inverse(pow),\n            Some(U::low_mask(pow))\n        );\n    });\n}\n\n#[test]\nfn mod_power_of_2_inverse_properties() {\n    apply_fn_to_unsigned_signed_pairs!(mod_power_of_2_inverse_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_2;\n\nfn mod_power_of_2_is_reduced_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.mod_power_of_2_is_reduced(pow), out);\n    };\n\n    test(T::ZERO, 5, true);\n    test(T::exact_from(100), 5, false);\n    test(T::exact_from(100), 8, true);\n    test(T::MAX, T::WIDTH - 1, false);\n    test(T::MAX, T::WIDTH, true);\n}\n\n#[test]\nfn test_mod_power_of_2_is_reduced() {\n    apply_fn_to_unsigneds!(mod_power_of_2_is_reduced_helper);\n}\n\nfn mod_power_of_2_is_reduced_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, pow)| {\n        assert_eq!(n.mod_power_of_2_is_reduced(pow), n.mod_power_of_2(pow) == n);\n    });\n}\n\n#[test]\nfn mod_power_of_2_is_reduced_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_is_reduced_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_17, unsigned_quadruple_gen_var_3, unsigned_triple_gen_var_11,\n};\nuse std::panic::catch_unwind;\n\nfn mod_power_of_2_mul_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, y: T, pow, out| {\n        assert_eq!(x.mod_power_of_2_mul(y, pow), out);\n\n        let mut x = x;\n        x.mod_power_of_2_mul_assign(y, pow);\n        assert_eq!(x, out);\n    };\n    test(T::ZERO, T::ZERO, 0, T::ZERO);\n    test(T::ZERO, T::ONE, 1, T::ZERO);\n    test(T::ONE, T::ONE, 1, T::ONE);\n    test(T::exact_from(3), T::TWO, 5, T::exact_from(6));\n    test(T::exact_from(10), T::exact_from(14), 4, T::exact_from(12));\n    test(T::exact_from(100), T::exact_from(200), 8, T::exact_from(32));\n    test(T::ONE << (T::WIDTH - 1), T::TWO, T::WIDTH, T::ZERO);\n    test(T::MAX, T::MAX, T::WIDTH, T::ONE);\n}\n\n#[test]\nfn test_mod_power_of_2_mul() {\n    apply_fn_to_unsigneds!(mod_power_of_2_mul_helper);\n}\n\nfn mod_power_of_2_mul_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.mod_power_of_2_mul(T::ZERO, 0));\n    assert_panic!(T::ZERO.mod_power_of_2_mul(T::ONE, 0));\n    assert_panic!(T::from(123u8).mod_power_of_2_mul(T::from(200u8), 7));\n    assert_panic!(T::from(200u8).mod_power_of_2_mul(T::from(123u8), 7));\n}\n\n#[test]\nfn mod_power_of_2_mul_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_mul_fail_helper);\n}\n\nfn mod_power_of_2_mul_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_mul_assign(T::ZERO, 0);\n    });\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_power_of_2_mul_assign(T::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_power_of_2_mul_assign(T::from(200u8), 7);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_mul_assign(T::from(123u8), 7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_mul_assign_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_mul_assign_fail_helper);\n}\n\nfn mod_power_of_2_mul_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_11::<T>().test_properties(|(x, y, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        assert!(y.mod_power_of_2_is_reduced(pow));\n        let product = x.mod_power_of_2_mul(y, pow);\n        assert!(product.mod_power_of_2_is_reduced(pow));\n\n        let mut x_alt = x;\n        x_alt.mod_power_of_2_mul_assign(y, pow);\n        assert_eq!(x_alt, product);\n\n        assert_eq!(y.mod_power_of_2_mul(x, pow), product);\n        assert_eq!(\n            x.mod_power_of_2_mul(y.mod_power_of_2_neg(pow), pow),\n            product.mod_power_of_2_neg(pow)\n        );\n        assert_eq!(\n            x.mod_power_of_2_neg(pow).mod_power_of_2_mul(y, pow),\n            product.mod_power_of_2_neg(pow)\n        );\n    });\n\n    unsigned_pair_gen_var_17::<T>().test_properties(|(x, pow)| {\n        assert_eq!(x.mod_power_of_2_mul(T::ZERO, pow), T::ZERO);\n        assert_eq!(T::ZERO.mod_power_of_2_mul(x, pow), T::ZERO);\n        if pow != 0 {\n            assert_eq!(x.mod_power_of_2_mul(T::ONE, pow), x);\n            assert_eq!(T::ONE.mod_power_of_2_mul(x, pow), x);\n        }\n    });\n\n    unsigned_quadruple_gen_var_3::<T>().test_properties(|(x, y, z, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_mul(y, pow).mod_power_of_2_mul(z, pow),\n            x.mod_power_of_2_mul(y.mod_power_of_2_mul(z, pow), pow)\n        );\n        assert_eq!(\n            x.mod_power_of_2_mul(y.mod_power_of_2_add(z, pow), pow),\n            x.mod_power_of_2_mul(y, pow)\n                .mod_power_of_2_add(x.mod_power_of_2_mul(z, pow), pow)\n        );\n        assert_eq!(\n            x.mod_power_of_2_add(y, pow).mod_power_of_2_mul(z, pow),\n            x.mod_power_of_2_mul(z, pow)\n                .mod_power_of_2_add(y.mod_power_of_2_mul(z, pow), pow)\n        );\n    });\n}\n\n#[test]\nfn mod_power_of_2_mul_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_mul_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_17;\nuse std::panic::catch_unwind;\n\nfn mod_power_of_2_neg_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, pow, out| {\n        assert_eq!(n.mod_power_of_2_neg(pow), out);\n\n        let mut n = n;\n        n.mod_power_of_2_neg_assign(pow);\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, 5, T::ZERO);\n    test(T::exact_from(10), 4, T::exact_from(6));\n    test(T::exact_from(100), 8, T::exact_from(156));\n    test(T::ONE, T::WIDTH, T::MAX);\n    test(T::MAX, T::WIDTH, T::ONE);\n}\n\n#[test]\nfn test_mod_power_of_2_neg() {\n    apply_fn_to_unsigneds!(mod_power_of_2_neg_helper);\n}\n\nfn mod_power_of_2_neg_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.mod_power_of_2_neg(0));\n    assert_panic!(T::from(200u8).mod_power_of_2_neg(7));\n}\n\n#[test]\nfn mod_power_of_2_neg_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_neg_fail_helper);\n}\n\nfn mod_power_of_2_neg_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_neg_assign(0);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_neg_assign(7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_neg_assign_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_neg_assign_fail_helper);\n}\n\nfn mod_power_of_2_neg_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_17::<T>().test_properties(|(n, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let neg = n.mod_power_of_2_neg(pow);\n        assert!(neg.mod_power_of_2_is_reduced(pow));\n\n        let mut n_alt = n;\n        n_alt.mod_power_of_2_neg_assign(pow);\n        assert_eq!(n_alt, neg);\n\n        assert_eq!(neg, n.wrapping_neg().mod_power_of_2(pow));\n        assert_eq!(neg.mod_power_of_2_neg(pow), n);\n        assert_eq!(n.mod_power_of_2_add(neg, pow), T::ZERO);\n        assert_eq!(n == neg, n == T::ZERO || n == T::power_of_2(pow - 1));\n    });\n}\n\n#[test]\nfn mod_power_of_2_neg_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_neg_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_17, unsigned_pair_gen_var_23, unsigned_quadruple_gen_var_8,\n    unsigned_quadruple_gen_var_9, unsigned_triple_gen_var_16,\n};\nuse std::panic::catch_unwind;\n\nfn mod_power_of_2_pow_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, exp: u64, pow: u64, out| {\n        assert_eq!(x.mod_power_of_2_pow(exp, pow), out);\n\n        let mut mut_x = x;\n        mut_x.mod_power_of_2_pow_assign(exp, pow);\n        assert_eq!(mut_x, out);\n    };\n    test(T::ZERO, 0, 0, T::ZERO);\n    test(T::ZERO, 0, 3, T::ONE);\n    test(T::ZERO, 1, 3, T::ZERO);\n\n    test(T::TWO, 2, 3, T::exact_from(4));\n    test(T::exact_from(5), 13, 3, T::exact_from(5));\n    test(T::exact_from(7), 1000, 6, T::ONE);\n    test(T::exact_from(101), 1000000, 8, T::ONE);\n}\n\n#[test]\nfn test_mod_power_of_2_pow() {\n    apply_fn_to_unsigneds!(mod_power_of_2_pow_helper);\n}\n\nfn mod_power_of_2_pow_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.mod_power_of_2_pow(10, 0));\n    assert_panic!(T::from(200u8).mod_power_of_2_pow(10, 7));\n}\n\n#[test]\nfn mod_power_of_2_pow_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_pow_fail_helper);\n}\n\nfn mod_power_of_2_pow_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_pow_assign(10, 0);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_pow_assign(10, 7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_pow_assign_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_pow_assign_fail_helper);\n}\n\nfn mod_power_of_2_pow_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_16::<T, u64>().test_properties(|(x, exp, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        let power = x.mod_power_of_2_pow(exp, pow);\n        assert!(power.mod_power_of_2_is_reduced(pow));\n\n        let mut x_alt = x;\n        x_alt.mod_power_of_2_pow_assign(exp, pow);\n        assert_eq!(x_alt, power);\n        if exp.even() {\n            assert_eq!(\n                x.mod_power_of_2_neg(pow).mod_power_of_2_pow(exp, pow),\n                power\n            );\n        } else {\n            assert_eq!(\n                x.mod_power_of_2_neg(pow).mod_power_of_2_pow(exp, pow),\n                power.mod_power_of_2_neg(pow)\n            );\n        }\n    });\n\n    unsigned_pair_gen_var_23::<u64, T>().test_properties(|(exp, pow)| {\n        assert_eq!(\n            T::ZERO.mod_power_of_2_pow(exp, pow),\n            T::from(exp == 0 && pow != 0)\n        );\n        if pow != 0 {\n            assert_eq!(T::ONE.mod_power_of_2_pow(exp, pow), T::ONE);\n        }\n    });\n\n    unsigned_pair_gen_var_17::<T>().test_properties(|(x, pow)| {\n        assert_eq!(x.mod_power_of_2_pow(0, pow), T::from(pow != 0));\n        assert_eq!(x.mod_power_of_2_pow(1, pow), x);\n        assert_eq!(x.mod_power_of_2_pow(2, pow), x.mod_power_of_2_mul(x, pow));\n    });\n\n    unsigned_quadruple_gen_var_8::<T, u64>().test_properties(|(x, y, exp, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_mul(y, pow).mod_power_of_2_pow(exp, pow),\n            x.mod_power_of_2_pow(exp, pow)\n                .mod_power_of_2_mul(y.mod_power_of_2_pow(exp, pow), pow)\n        );\n    });\n\n    unsigned_quadruple_gen_var_9::<T, u64>().test_properties(|(x, e, f, pow)| {\n        if let Some(sum) = e.checked_add(f) {\n            assert_eq!(\n                x.mod_power_of_2_pow(sum, pow),\n                x.mod_power_of_2_pow(e, pow)\n                    .mod_power_of_2_mul(x.mod_power_of_2_pow(f, pow), pow)\n            );\n        }\n        if let Some(product) = e.checked_mul(f) {\n            assert_eq!(\n                x.mod_power_of_2_pow(product, pow),\n                x.mod_power_of_2_pow(e, pow).mod_power_of_2_pow(f, pow)\n            );\n        }\n    });\n}\n\n#[test]\nfn mod_power_of_2_pow_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_pow_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, ModPowerOf2Shl, ModPowerOf2ShlAssign, ModPowerOf2Shr,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_12, unsigned_pair_gen_var_17, unsigned_pair_gen_var_23,\n    unsigned_signed_unsigned_triple_gen_var_1, unsigned_triple_gen_var_17,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_mod_power_of_2_shl() {\n    fn test<\n        T: ModPowerOf2Shl<U, Output = T> + ModPowerOf2ShlAssign<U> + PrimitiveUnsigned,\n        U: PrimitiveInt,\n    >(\n        t: T,\n        u: U,\n        pow: u64,\n        out: T,\n    ) {\n        assert_eq!(t.mod_power_of_2_shl(u, pow), out);\n\n        let mut t = t;\n        t.mod_power_of_2_shl_assign(u, pow);\n        assert_eq!(t, out);\n    }\n    test::<u64, u8>(0, 0, 0, 0);\n    test::<u64, u8>(0, 0, 5, 0);\n    test::<u32, i16>(12, 2, 5, 16);\n    test::<u16, u32>(10, 100, 4, 0);\n    test::<u8, i64>(10, -2, 4, 2);\n    test::<u8, i64>(10, -100, 4, 0);\n    test::<u128, i8>(10, -100, 4, 0);\n}\n\nfn mod_power_of_2_shl_fail_helper<\n    T: PrimitiveUnsigned + ModPowerOf2Shl<U, Output = T>,\n    U: PrimitiveInt,\n>() {\n    assert_panic!(T::ONE.mod_power_of_2_shl(U::TWO, 0));\n    assert_panic!(T::from(200u8).mod_power_of_2_shl(U::TWO, 7));\n}\n\n#[test]\nfn mod_power_of_2_shl_fail() {\n    apply_fn_to_unsigneds_and_primitive_ints!(mod_power_of_2_shl_fail_helper);\n}\n\nfn mod_power_of_2_shl_assign_fail_helper<\n    T: PrimitiveUnsigned + ModPowerOf2ShlAssign<U>,\n    U: PrimitiveInt,\n>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_shl_assign(U::TWO, 0);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_shl_assign(U::TWO, 7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_shl_assign_fail() {\n    apply_fn_to_unsigneds_and_primitive_ints!(mod_power_of_2_shl_assign_fail_helper);\n}\n\nfn mod_power_of_2_shl_properties_unsigned_unsigned_helper<\n    T: ArithmeticCheckedShl<U, Output = T>\n        + ModPowerOf2Shl<U, Output = T>\n        + ModPowerOf2ShlAssign<U>\n        + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_triple_gen_var_17::<T, U>().test_properties(|(n, u, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let shifted = n.mod_power_of_2_shl(u, pow);\n        assert!(shifted.mod_power_of_2_is_reduced(pow));\n\n        let mut shifted_alt = n;\n        shifted_alt.mod_power_of_2_shl_assign(u, pow);\n        assert_eq!(shifted_alt, shifted);\n\n        if let Some(shifted_alt) = n.arithmetic_checked_shl(u) {\n            assert_eq!(shifted_alt.mod_power_of_2(pow), shifted);\n        }\n    });\n\n    unsigned_pair_gen_var_17::<T>().test_properties(|(n, pow)| {\n        assert_eq!(n.mod_power_of_2_shl(U::ZERO, pow), n);\n    });\n\n    unsigned_pair_gen_var_23::<U, T>().test_properties(|(u, pow)| {\n        assert_eq!(T::ZERO.mod_power_of_2_shl(u, pow), T::ZERO);\n    });\n}\n\nfn mod_power_of_2_shl_properties_unsigned_signed_helper<\n    T: ArithmeticCheckedShl<U, Output = T>\n        + ModPowerOf2Shl<U, Output = T>\n        + ModPowerOf2Shr<U, Output = T>\n        + ModPowerOf2ShlAssign<U>\n        + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>() {\n    unsigned_signed_unsigned_triple_gen_var_1::<T, U>().test_properties(|(n, i, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let shifted = n.mod_power_of_2_shl(i, pow);\n        assert!(shifted.mod_power_of_2_is_reduced(pow));\n\n        let mut shifted_alt = n;\n        shifted_alt.mod_power_of_2_shl_assign(i, pow);\n        assert_eq!(shifted_alt, shifted);\n\n        if let Some(shifted_alt) = n.arithmetic_checked_shl(i) {\n            assert_eq!(shifted_alt.mod_power_of_2(pow), shifted);\n        }\n\n        if i != U::MIN {\n            assert_eq!(n.mod_power_of_2_shr(-i, pow), shifted);\n        }\n    });\n\n    unsigned_pair_gen_var_17::<T>().test_properties(|(n, pow)| {\n        assert_eq!(n.mod_power_of_2_shl(U::ZERO, pow), n);\n    });\n\n    signed_unsigned_pair_gen_var_12::<U, T>().test_properties(|(i, pow)| {\n        assert_eq!(T::ZERO.mod_power_of_2_shl(i, pow), T::ZERO);\n    });\n}\n\n#[test]\nfn mod_power_of_2_shl_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(mod_power_of_2_shl_properties_unsigned_unsigned_helper);\n    apply_fn_to_unsigneds_and_signeds!(mod_power_of_2_shl_properties_unsigned_signed_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShr, ModPowerOf2Shl, ModPowerOf2Shr, ModPowerOf2ShrAssign,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_12, unsigned_pair_gen_var_17,\n    unsigned_signed_unsigned_triple_gen_var_1,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_mod_power_of_2_shr() {\n    fn test<\n        T: ModPowerOf2Shr<U, Output = T> + ModPowerOf2ShrAssign<U> + PrimitiveUnsigned,\n        U: PrimitiveSigned,\n    >(\n        t: T,\n        u: U,\n        pow: u64,\n        out: T,\n    ) {\n        assert_eq!(t.mod_power_of_2_shr(u, pow), out);\n\n        let mut t = t;\n        t.mod_power_of_2_shr_assign(u, pow);\n        assert_eq!(t, out);\n    }\n    test::<u64, i8>(0, 0, 0, 0);\n    test::<u64, i8>(0, 0, 5, 0);\n    test::<u32, i16>(12, -2, 5, 16);\n    test::<u16, i32>(10, -100, 4, 0);\n    test::<u8, i64>(10, 2, 4, 2);\n    test::<u8, i64>(10, 100, 4, 0);\n    test::<u128, i8>(10, 100, 4, 0);\n}\n\nfn mod_power_of_2_shr_fail_helper<\n    T: PrimitiveUnsigned + ModPowerOf2Shr<U, Output = T>,\n    U: PrimitiveSigned,\n>() {\n    assert_panic!(T::ONE.mod_power_of_2_shr(U::TWO, 0));\n    assert_panic!(T::from(200u8).mod_power_of_2_shr(U::TWO, 7));\n}\n\n#[test]\nfn mod_power_of_2_shr_fail() {\n    apply_fn_to_unsigneds_and_signeds!(mod_power_of_2_shr_fail_helper);\n}\n\nfn mod_power_of_2_shr_assign_fail_helper<\n    T: PrimitiveUnsigned + ModPowerOf2ShrAssign<U>,\n    U: PrimitiveSigned,\n>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_shr_assign(U::TWO, 0);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_shr_assign(U::TWO, 7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_shr_assign_fail() {\n    apply_fn_to_unsigneds_and_signeds!(mod_power_of_2_shr_assign_fail_helper);\n}\n\nfn mod_power_of_2_shl_properties_helper<\n    T: ArithmeticCheckedShr<U, Output = T>\n        + ModPowerOf2Shl<U, Output = T>\n        + ModPowerOf2Shr<U, Output = T>\n        + ModPowerOf2ShrAssign<U>\n        + PrimitiveUnsigned,\n    U: PrimitiveSigned,\n>() {\n    unsigned_signed_unsigned_triple_gen_var_1::<T, U>().test_properties(|(n, i, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let shifted = n.mod_power_of_2_shr(i, pow);\n        assert!(shifted.mod_power_of_2_is_reduced(pow));\n\n        let mut shifted_alt = n;\n        shifted_alt.mod_power_of_2_shr_assign(i, pow);\n        assert_eq!(shifted_alt, shifted);\n\n        if let Some(shifted_alt) = n.arithmetic_checked_shr(i) {\n            assert_eq!(shifted_alt.mod_power_of_2(pow), shifted);\n        }\n\n        if i != U::MIN {\n            assert_eq!(n.mod_power_of_2_shl(-i, pow), shifted);\n        }\n    });\n\n    unsigned_pair_gen_var_17::<T>().test_properties(|(n, pow)| {\n        assert_eq!(n.mod_power_of_2_shr(U::ZERO, pow), n);\n    });\n\n    signed_unsigned_pair_gen_var_12::<U, T>().test_properties(|(i, pow)| {\n        assert_eq!(T::ZERO.mod_power_of_2_shr(i, pow), T::ZERO);\n    });\n}\n\n#[test]\nfn mod_power_of_2_shl_properties() {\n    apply_fn_to_unsigneds_and_signeds!(mod_power_of_2_shl_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_9, unsigned_pair_gen_var_17, unsigned_triple_gen_var_11,\n};\nuse std::panic::catch_unwind;\n\nfn mod_power_of_2_square_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, pow: u64, out| {\n        assert_eq!(x.mod_power_of_2_square(pow), out);\n\n        let mut mut_x = x;\n        mut_x.mod_power_of_2_square_assign(pow);\n        assert_eq!(mut_x, out);\n    };\n    test(T::ZERO, 0, T::ZERO);\n    test(T::ZERO, 2, T::ZERO);\n    test(T::ONE, 2, T::ONE);\n    test(T::TWO, 2, T::ZERO);\n    test(T::TWO, 3, T::exact_from(4));\n    test(T::exact_from(5), 3, T::ONE);\n    test(T::exact_from(100), 8, T::exact_from(16));\n}\n\n#[test]\nfn test_mod_power_of_2_square() {\n    apply_fn_to_unsigneds!(mod_power_of_2_square_helper);\n}\n\nfn mod_power_of_2_square_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.mod_power_of_2_square(0));\n    assert_panic!(T::from(200u8).mod_power_of_2_square(7));\n}\n\n#[test]\nfn mod_power_of_2_square_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_square_fail_helper);\n}\n\nfn mod_power_of_2_square_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_square_assign(0);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_square_assign(7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_square_assign_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_square_assign_fail_helper);\n}\n\nfn mod_power_of_2_square_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_17::<T>().test_properties(|(x, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        let square = x.mod_power_of_2_square(pow);\n        assert!(square.mod_power_of_2_is_reduced(pow));\n\n        let mut x_alt = x;\n        x_alt.mod_power_of_2_square_assign(pow);\n        assert_eq!(x_alt, square);\n\n        assert_eq!(x.mod_power_of_2_pow(2, pow), x.mod_power_of_2_mul(x, pow));\n        assert_eq!(x.mod_power_of_2_neg(pow).mod_power_of_2_square(pow), square);\n    });\n\n    unsigned_gen_var_9::<T>().test_properties(|pow| {\n        assert_eq!(T::ZERO.mod_power_of_2_square(pow), T::ZERO);\n        if pow != 0 {\n            assert_eq!(T::ONE.mod_power_of_2_square(pow), T::ONE);\n        }\n    });\n\n    unsigned_triple_gen_var_11::<T>().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_mul(y, pow).mod_power_of_2_square(pow),\n            x.mod_power_of_2_square(pow)\n                .mod_power_of_2_mul(y.mod_power_of_2_square(pow), pow)\n        );\n    });\n}\n\n#[test]\nfn mod_power_of_2_square_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_square_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_power_of_2_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{unsigned_pair_gen_var_17, unsigned_triple_gen_var_11};\nuse std::panic::catch_unwind;\n\nfn mod_power_of_2_sub_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, y: T, pow, out| {\n        assert_eq!(x.mod_power_of_2_sub(y, pow), out);\n\n        let mut x = x;\n        x.mod_power_of_2_sub_assign(y, pow);\n        assert_eq!(x, out);\n    };\n    test(T::ZERO, T::ZERO, 0, T::ZERO);\n    test(T::ZERO, T::ONE, 1, T::ONE);\n    test(T::ONE, T::ONE, 1, T::ZERO);\n    test(T::exact_from(5), T::TWO, 5, T::exact_from(3));\n    test(T::exact_from(10), T::exact_from(14), 4, T::exact_from(12));\n    test(\n        T::exact_from(100),\n        T::exact_from(200),\n        8,\n        T::exact_from(156),\n    );\n    test(T::ZERO, T::ONE, T::WIDTH, T::MAX);\n    test(T::ONE, T::MAX, T::WIDTH, T::TWO);\n}\n\n#[test]\nfn test_mod_power_of_2_sub() {\n    apply_fn_to_unsigneds!(mod_power_of_2_sub_helper);\n}\n\nfn mod_power_of_2_sub_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.mod_power_of_2_sub(T::ZERO, 0));\n    assert_panic!(T::ZERO.mod_power_of_2_sub(T::ONE, 0));\n    assert_panic!(T::from(123u8).mod_power_of_2_sub(T::from(200u8), 7));\n    assert_panic!(T::from(200u8).mod_power_of_2_sub(T::from(123u8), 7));\n}\n\n#[test]\nfn mod_power_of_2_sub_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_sub_fail_helper);\n}\n\nfn mod_power_of_2_sub_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ONE;\n        x.mod_power_of_2_sub_assign(T::ZERO, 0);\n    });\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_power_of_2_sub_assign(T::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_power_of_2_sub_assign(T::from(200u8), 7);\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_power_of_2_sub_assign(T::from(123u8), 7);\n    });\n}\n\n#[test]\nfn mod_power_of_2_sub_assign_fail() {\n    apply_fn_to_unsigneds!(mod_power_of_2_sub_assign_fail_helper);\n}\n\nfn mod_power_of_2_sub_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_11::<T>().test_properties(|(x, y, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        assert!(y.mod_power_of_2_is_reduced(pow));\n        let diff = x.mod_power_of_2_sub(y, pow);\n        assert!(diff.mod_power_of_2_is_reduced(pow));\n\n        let mut x_alt = x;\n        x_alt.mod_power_of_2_sub_assign(y, pow);\n        assert_eq!(x_alt, diff);\n\n        assert_eq!(diff.mod_power_of_2_add(y, pow), x);\n        assert_eq!(diff.mod_power_of_2_sub(x, pow), y.mod_power_of_2_neg(pow));\n        assert_eq!(y.mod_power_of_2_sub(x, pow), diff.mod_power_of_2_neg(pow));\n        assert_eq!(x.mod_power_of_2_add(y.mod_power_of_2_neg(pow), pow), diff);\n    });\n\n    unsigned_pair_gen_var_17::<T>().test_properties(|(x, pow)| {\n        assert_eq!(x.mod_power_of_2_sub(T::ZERO, pow), x);\n        assert_eq!(\n            T::ZERO.mod_power_of_2_sub(x, pow),\n            x.mod_power_of_2_neg(pow)\n        );\n        assert_eq!(x.mod_power_of_2_sub(x, pow), T::ZERO);\n    });\n}\n\n#[test]\nfn mod_power_of_2_sub_properties() {\n    apply_fn_to_unsigneds!(mod_power_of_2_sub_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShl, ModShl, ModShlAssign, ModShr};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen_var_5, signed_unsigned_pair_gen_var_13, unsigned_gen_var_5, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_16, unsigned_pair_gen_var_25, unsigned_signed_pair_gen_var_1,\n    unsigned_signed_unsigned_triple_gen_var_2, unsigned_triple_gen_var_18,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_mod_shl() {\n    fn test<\n        T: ModShl<U, T, Output = T> + ModShlAssign<U, T> + PrimitiveUnsigned,\n        U: PrimitiveInt,\n    >(\n        t: T,\n        u: U,\n        m: T,\n        out: T,\n    ) {\n        assert_eq!(t.mod_shl(u, m), out);\n\n        let mut t = t;\n        t.mod_shl_assign(u, m);\n        assert_eq!(t, out);\n    }\n    test::<u64, u8>(0, 0, 1, 0);\n    test::<u64, u8>(0, 0, 5, 0);\n    test::<u32, i16>(8, 2, 10, 2);\n    test::<u16, u32>(10, 100, 17, 7);\n\n    test::<u8, i64>(10, -2, 15, 2);\n    test::<u8, i64>(10, -100, 19, 0);\n    test::<u128, i8>(10, -100, 19, 0);\n}\n\nfn mod_shl_fail_helper<T: PrimitiveUnsigned + ModShl<U, T, Output = T>, U: PrimitiveInt>() {\n    assert_panic!(T::ZERO.mod_shl(U::TWO, T::ZERO));\n    assert_panic!(T::from(123u8).mod_shl(U::TWO, T::from(123u8)));\n}\n\n#[test]\nfn mod_shl_fail() {\n    apply_fn_to_unsigneds_and_primitive_ints!(mod_shl_fail_helper);\n}\n\nfn mod_shl_assign_fail_helper<T: PrimitiveUnsigned + ModShlAssign<U, T>, U: PrimitiveInt>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_shl_assign(U::TWO, T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_shl_assign(U::TWO, T::from(123u8));\n    });\n}\n\n#[test]\nfn mod_shl_assign_fail() {\n    apply_fn_to_unsigneds_and_primitive_ints!(mod_shl_assign_fail_helper);\n}\n\nfn mod_shl_properties_unsigned_unsigned_helper<\n    T: ArithmeticCheckedShl<U, Output = T>\n        + ModShl<U, Output = T>\n        + ModShlAssign<U>\n        + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_triple_gen_var_18::<T, U>().test_properties(|(n, u, m)| {\n        assert!(n.mod_is_reduced(&m));\n        let shifted = n.mod_shl(u, m);\n        assert!(shifted.mod_is_reduced(&m));\n\n        let mut shifted_alt = n;\n        shifted_alt.mod_shl_assign(u, m);\n        assert_eq!(shifted_alt, shifted);\n\n        if let Some(shifted_alt) = n.arithmetic_checked_shl(u) {\n            assert_eq!(shifted_alt % m, shifted);\n        }\n    });\n\n    unsigned_pair_gen_var_16::<T>().test_properties(|(n, m)| {\n        assert_eq!(n.mod_shl(U::ZERO, m), n);\n    });\n\n    unsigned_pair_gen_var_25::<U, T>().test_properties(|(u, m)| {\n        assert_eq!(T::ZERO.mod_shl(u, m), T::ZERO);\n    });\n\n    unsigned_pair_gen_var_2::<T, U>().test_properties(|(n, u)| {\n        assert_panic!(n.mod_shl(u, T::ZERO));\n        assert_panic!({\n            let mut n = n;\n            n.mod_shl_assign(u, T::ZERO);\n        });\n    });\n\n    unsigned_gen_var_5::<U>().test_properties(|u| {\n        assert_eq!(T::ZERO.mod_shl(u, T::ONE), T::ZERO);\n    });\n}\n\nfn mod_shl_properties_unsigned_signed_helper<\n    T: ArithmeticCheckedShl<S, Output = T>\n        + ModShl<S, Output = T>\n        + ModShr<S, Output = T>\n        + ModShlAssign<S>\n        + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>().test_properties(|(n, i, m)| {\n        assert!(n.mod_is_reduced(&m));\n        let shifted = n.mod_shl(i, m);\n        assert!(shifted.mod_is_reduced(&m));\n\n        let mut shifted_alt = n;\n        shifted_alt.mod_shl_assign(i, m);\n        assert_eq!(shifted_alt, shifted);\n\n        if let Some(shifted_alt) = n.arithmetic_checked_shl(i) {\n            assert_eq!(shifted_alt % m, shifted);\n        }\n\n        if i != S::MIN {\n            assert_eq!(n.mod_shr(-i, m), shifted);\n        }\n    });\n\n    unsigned_pair_gen_var_16::<T>().test_properties(|(n, m)| {\n        assert_eq!(n.mod_shl(S::ZERO, m), n);\n    });\n\n    signed_unsigned_pair_gen_var_13::<U, S, T>().test_properties(|(i, m)| {\n        assert_eq!(T::ZERO.mod_shl(i, m), T::ZERO);\n    });\n\n    unsigned_signed_pair_gen_var_1::<T, S>().test_properties(|(n, i)| {\n        assert_panic!(n.mod_shl(i, T::ZERO));\n        assert_panic!({\n            let mut n = n;\n            n.mod_shl_assign(i, T::ZERO);\n        });\n    });\n\n    signed_gen_var_5::<S>().test_properties(|i| {\n        assert_eq!(T::ZERO.mod_shl(i, T::ONE), T::ZERO);\n    });\n}\n\n#[test]\nfn mod_shl_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(mod_shl_properties_unsigned_unsigned_helper);\n    apply_fn_to_unsigneds_and_unsigned_signed_pairs!(mod_shl_properties_unsigned_signed_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShr, ModShl, ModShr, ModShrAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen_var_5, signed_unsigned_pair_gen_var_13, unsigned_pair_gen_var_16,\n    unsigned_signed_pair_gen_var_1, unsigned_signed_unsigned_triple_gen_var_2,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_mod_shr() {\n    fn test<\n        T: ModShr<U, T, Output = T> + ModShrAssign<U, T> + PrimitiveUnsigned,\n        U: PrimitiveInt,\n    >(\n        t: T,\n        i: U,\n        m: T,\n        out: T,\n    ) {\n        assert_eq!(t.mod_shr(i, m), out);\n\n        let mut t = t;\n        t.mod_shr_assign(i, m);\n        assert_eq!(t, out);\n    }\n    test::<u64, i8>(0, 0, 1, 0);\n    test::<u64, i8>(0, 0, 5, 0);\n    test::<u32, i16>(8, -2, 10, 2);\n    test::<u16, i32>(10, -100, 17, 7);\n\n    test::<u8, i64>(10, 2, 15, 2);\n    test::<u8, i64>(10, 100, 19, 0);\n    test::<u128, i8>(10, 100, 19, 0);\n}\n\nfn mod_shr_fail_helper<T: PrimitiveUnsigned + ModShr<U, T, Output = T>, U: PrimitiveSigned>() {\n    assert_panic!(T::ZERO.mod_shr(U::TWO, T::ZERO));\n    assert_panic!(T::from(123u8).mod_shr(U::TWO, T::from(123u8)));\n}\n\n#[test]\nfn mod_shr_fail() {\n    apply_fn_to_unsigneds_and_signeds!(mod_shr_fail_helper);\n}\n\nfn mod_shr_assign_fail_helper<T: PrimitiveUnsigned + ModShrAssign<U, T>, U: PrimitiveSigned>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_shr_assign(U::TWO, T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_shr_assign(U::TWO, T::from(123u8));\n    });\n}\n\n#[test]\nfn mod_shr_assign_fail() {\n    apply_fn_to_unsigneds_and_signeds!(mod_shr_assign_fail_helper);\n}\n\nfn mod_shr_properties_helper<\n    T: ArithmeticCheckedShr<S, Output = T>\n        + ModShl<S, Output = T>\n        + ModShr<S, Output = T>\n        + ModShrAssign<S>\n        + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    unsigned_signed_unsigned_triple_gen_var_2::<T, U, S>().test_properties(|(n, i, m)| {\n        assert!(n.mod_is_reduced(&m));\n        let shifted = n.mod_shr(i, m);\n        assert!(shifted.mod_is_reduced(&m));\n\n        let mut shifted_alt = n;\n        shifted_alt.mod_shr_assign(i, m);\n        assert_eq!(shifted_alt, shifted);\n\n        if let Some(shifted_alt) = n.arithmetic_checked_shr(i) {\n            assert_eq!(shifted_alt % m, shifted);\n        }\n\n        if i != S::MIN {\n            assert_eq!(n.mod_shl(-i, m), shifted);\n        }\n    });\n\n    unsigned_pair_gen_var_16::<T>().test_properties(|(n, m)| {\n        assert_eq!(n.mod_shr(S::ZERO, m), n);\n    });\n\n    signed_unsigned_pair_gen_var_13::<U, S, T>().test_properties(|(i, m)| {\n        assert_eq!(T::ZERO.mod_shr(i, m), T::ZERO);\n    });\n\n    unsigned_signed_pair_gen_var_1::<T, S>().test_properties(|(n, i)| {\n        assert_panic!(n.mod_shr(i, T::ZERO));\n        assert_panic!({\n            let mut n = n;\n            n.mod_shr_assign(i, T::ZERO);\n        });\n    });\n\n    signed_gen_var_5::<S>().test_properties(|i| {\n        assert_eq!(T::ZERO.mod_shl(i, T::ONE), T::ZERO);\n    });\n}\n\n#[test]\nfn mod_shr_properties() {\n    apply_fn_to_unsigneds_and_unsigned_signed_pairs!(mod_shr_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_1, unsigned_pair_gen_var_16, unsigned_triple_gen_var_12,\n};\nuse std::panic::catch_unwind;\n\nfn mod_square_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, m, out| {\n        assert_eq!(x.mod_mul(x, m), out);\n        assert_eq!(x.mod_square(m), out);\n\n        let mut mut_x = x;\n        mut_x.mod_square_assign(m);\n        assert_eq!(mut_x, out);\n\n        let data = T::precompute_mod_pow_data(&m);\n        assert_eq!(x.mod_square_precomputed(m, &data), out);\n\n        let mut mut_x = x;\n        mut_x.mod_square_precomputed_assign(m, &data);\n        assert_eq!(mut_x, out);\n    };\n    test(T::ZERO, T::ONE, T::ZERO);\n    test(T::ONE, T::exact_from(10), T::ONE);\n    test(T::TWO, T::exact_from(10), T::exact_from(4));\n    if T::WIDTH > u8::WIDTH {\n        test(T::exact_from(100), T::exact_from(497), T::exact_from(60));\n        test(T::exact_from(200), T::exact_from(497), T::exact_from(240));\n        test(T::exact_from(300), T::exact_from(497), T::exact_from(43));\n    }\n}\n\n#[test]\nfn test_mod_square() {\n    apply_fn_to_unsigneds!(mod_square_helper);\n}\n\nfn mod_square_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_square(T::ZERO));\n    assert_panic!(T::from(123u8).mod_square(T::from(123u8)));\n}\n\n#[test]\nfn mod_square_fail() {\n    apply_fn_to_unsigneds!(mod_square_fail_helper);\n}\n\nfn mod_square_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_square_assign(T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_square_assign(T::from(123u8));\n    });\n}\n\n#[test]\nfn mod_square_assign_fail() {\n    apply_fn_to_unsigneds!(mod_square_assign_fail_helper);\n}\n\nfn mod_square_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_16::<T>().test_properties(|(x, m)| {\n        assert!(x.mod_is_reduced(&m));\n        let square = x.mod_square(m);\n        assert!(square.mod_is_reduced(&m));\n\n        let mut x_alt = x;\n        x_alt.mod_square_assign(m);\n        assert_eq!(x_alt, square);\n\n        let data = T::precompute_mod_pow_data(&m);\n\n        assert_eq!(x.mod_square_precomputed(m, &data), square);\n\n        let mut x_alt = x;\n        x_alt.mod_square_precomputed_assign(m, &data);\n        assert_eq!(x_alt, square);\n\n        assert_eq!(x.mod_mul(x, m), square);\n        assert_eq!(x.mod_neg(m).mod_square(m), square);\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|m| {\n        assert_eq!(T::ZERO.mod_square(m), T::ZERO);\n        if m != T::ONE {\n            assert_eq!(T::ONE.mod_square(m), T::ONE);\n        }\n    });\n\n    unsigned_triple_gen_var_12::<T>().test_properties(|(x, y, m)| {\n        assert_eq!(\n            x.mod_mul(y, m).mod_square(m),\n            x.mod_square(m).mod_mul(y.mod_square(m), m)\n        );\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_panic!(x.mod_square(T::ZERO));\n    });\n}\n\n#[test]\nfn mod_square_properties() {\n    apply_fn_to_unsigneds!(mod_square_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/mod_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_16, unsigned_pair_gen_var_27, unsigned_triple_gen_var_12,\n};\nuse std::panic::catch_unwind;\n\nfn mod_sub_helper<T: PrimitiveUnsigned>() {\n    let test = |x: T, y: T, m, out| {\n        assert_eq!(x.mod_sub(y, m), out);\n\n        let mut x = x;\n        x.mod_sub_assign(y, m);\n        assert_eq!(x, out);\n    };\n    test(T::ZERO, T::ZERO, T::ONE, T::ZERO);\n    test(T::exact_from(4), T::exact_from(3), T::exact_from(5), T::ONE);\n    test(\n        T::exact_from(7),\n        T::exact_from(9),\n        T::exact_from(10),\n        T::exact_from(8),\n    );\n    test(\n        T::exact_from(100),\n        T::exact_from(120),\n        T::exact_from(123),\n        T::exact_from(103),\n    );\n    test(T::ZERO, T::ONE, T::MAX, T::MAX - T::ONE);\n    test(T::MAX - T::TWO, T::MAX - T::ONE, T::MAX, T::MAX - T::ONE);\n}\n\n#[test]\nfn test_mod_sub() {\n    apply_fn_to_unsigneds!(mod_sub_helper);\n}\n\nfn mod_sub_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.mod_sub(T::ZERO, T::ZERO));\n    assert_panic!(T::from(123u8).mod_sub(T::from(200u8), T::from(200u8)));\n    assert_panic!(T::from(200u8).mod_sub(T::from(123u8), T::from(200u8)));\n}\n\n#[test]\nfn mod_sub_fail() {\n    apply_fn_to_unsigneds!(mod_sub_fail_helper);\n}\n\nfn mod_sub_assign_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut x = T::ZERO;\n        x.mod_sub_assign(T::ZERO, T::ZERO);\n    });\n    assert_panic!({\n        let mut x = T::from(123u8);\n        x.mod_sub_assign(T::from(200u8), T::from(200u8));\n    });\n    assert_panic!({\n        let mut x = T::from(200u8);\n        x.mod_sub_assign(T::from(123u8), T::from(200u8));\n    });\n}\n\n#[test]\nfn mod_sub_assign_fail() {\n    apply_fn_to_unsigneds!(mod_sub_assign_fail_helper);\n}\n\nfn mod_sub_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_12::<T>().test_properties(|(x, y, m)| {\n        assert!(x.mod_is_reduced(&m));\n        assert!(y.mod_is_reduced(&m));\n        let diff = x.mod_sub(y, m);\n        assert!(diff.mod_is_reduced(&m));\n\n        let mut x_alt = x;\n        x_alt.mod_sub_assign(y, m);\n        assert_eq!(x_alt, diff);\n\n        assert_eq!(diff.mod_add(y, m), x);\n        assert_eq!(diff.mod_sub(x, m), y.mod_neg(m));\n        assert_eq!(y.mod_sub(x, m), diff.mod_neg(m));\n        assert_eq!(x.mod_add(y.mod_neg(m), m), diff);\n    });\n\n    unsigned_pair_gen_var_16::<T>().test_properties(|(x, m)| {\n        assert_eq!(x.mod_sub(T::ZERO, m), x);\n        assert_eq!(T::ZERO.mod_sub(x, m), x.mod_neg(m));\n        assert_eq!(x.mod_sub(x, m), T::ZERO);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_panic!(x.mod_sub(y, T::ZERO));\n        assert_panic!({\n            let mut x = x;\n            x.mod_sub_assign(y, T::ZERO);\n        });\n    });\n}\n\n#[test]\nfn mod_sub_properties() {\n    apply_fn_to_unsigneds!(mod_sub_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen_var_1};\n\nfn neg_assign_helper_signed<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        let mut n = n;\n        n.neg_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::ONE, T::NEGATIVE_ONE);\n    test(T::exact_from(100), T::exact_from(-100));\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::exact_from(-100), T::exact_from(100));\n}\n\nfn neg_assign_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |x: T, out| {\n        let mut x = x;\n        x.neg_assign();\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n    };\n    test(T::ZERO, T::NEGATIVE_ZERO);\n    test(T::NEGATIVE_ZERO, T::ZERO);\n    test(T::INFINITY, T::NEGATIVE_INFINITY);\n    test(T::NEGATIVE_INFINITY, T::INFINITY);\n    test(T::NAN, T::NAN);\n\n    test(T::ONE, T::NEGATIVE_ONE);\n    test(T::from(100.0), T::from(-100.0));\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::from(-100.0), T::from(100.0));\n}\n\n#[test]\nfn test_neg_assign() {\n    apply_fn_to_signeds!(neg_assign_helper_signed);\n    apply_fn_to_primitive_floats!(neg_assign_helper_primitive_float);\n}\n\nfn neg_assign_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen_var_1::<T>().test_properties(|n| {\n        let mut neg = n;\n        neg.neg_assign();\n        assert_eq!(neg, -n);\n        assert_eq!(-neg, n);\n        assert_eq!(neg == n, n == T::ZERO);\n        assert_eq!(n + neg, T::ZERO);\n    });\n}\n\nfn neg_assign_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|x| {\n        let mut neg = x;\n        neg.neg_assign();\n        assert_eq!(NiceFloat(neg), NiceFloat(-x));\n        assert_eq!(NiceFloat(-neg), NiceFloat(x));\n        assert_eq!(NiceFloat(neg) == NiceFloat(x), x.is_nan());\n        if x.is_finite() {\n            assert_eq!(x + neg, T::ZERO);\n        }\n    });\n}\n\n#[test]\nfn neg_assign_properties() {\n    apply_fn_to_signeds!(neg_assign_properties_helper_signed);\n    apply_fn_to_primitive_floats!(neg_assign_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{primitive_float_gen_var_19, unsigned_gen_var_14};\nuse std::panic::catch_unwind;\n\nfn next_power_of_2_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.next_power_of_2(), out);\n\n        let mut n = n;\n        n.next_power_of_2_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ONE);\n    test(T::ONE, T::ONE);\n    test(T::exact_from(7), T::exact_from(8));\n    test(T::exact_from(8), T::exact_from(8));\n    test(T::exact_from(10), T::exact_from(16));\n    test((T::MAX >> 1u64) + T::ONE, (T::MAX >> 1u64) + T::ONE);\n    test(\n        (T::MAX >> 1u64) - T::exact_from(10),\n        (T::MAX >> 1u64) + T::ONE,\n    );\n}\n\nfn next_power_of_2_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(NiceFloat(n.next_power_of_2()), NiceFloat(out));\n\n        let mut n = n;\n        n.next_power_of_2_assign();\n        assert_eq!(NiceFloat(n), NiceFloat(out));\n    };\n    test(T::ZERO, T::MIN_POSITIVE_SUBNORMAL);\n    test(T::ONE, T::ONE);\n    test(T::from(7.0f32), T::from(8.0f32));\n    test(T::from(8.0f32), T::from(8.0f32));\n    test(T::from(10.0f32), T::from(16.0f32));\n    test(T::from(0.1f32), T::from(0.125f32));\n    test(T::from(0.01f32), T::from(0.015625f32));\n    test(\n        T::power_of_2(T::MAX_EXPONENT),\n        T::power_of_2(T::MAX_EXPONENT),\n    );\n}\n\n#[test]\nfn test_next_power_of_2() {\n    apply_fn_to_unsigneds!(next_power_of_2_helper_unsigned);\n    apply_fn_to_primitive_floats!(next_power_of_2_helper_primitive_float);\n}\n\nfn next_power_of_2_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::NEGATIVE_ZERO.next_power_of_2());\n    assert_panic!(T::INFINITY.next_power_of_2());\n    assert_panic!(T::NEGATIVE_INFINITY.next_power_of_2());\n    assert_panic!(T::NAN.next_power_of_2());\n    assert_panic!(T::NEGATIVE_ONE.next_power_of_2());\n    assert_panic!(T::MAX_FINITE.next_power_of_2());\n\n    let test = |x: T| {\n        let mut x = x;\n        x.next_power_of_2_assign();\n    };\n    assert_panic!(test(T::NEGATIVE_ZERO));\n    assert_panic!(test(T::INFINITY));\n    assert_panic!(test(T::NEGATIVE_INFINITY));\n    assert_panic!(test(T::NAN));\n    assert_panic!(test(T::NEGATIVE_ONE));\n    assert_panic!(test(T::MAX_FINITE));\n}\n\n#[test]\nfn next_power_of_2_fail() {\n    apply_fn_to_primitive_floats!(next_power_of_2_fail_helper_primitive_float);\n}\n\nfn next_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_14::<T>().test_properties(|n| {\n        let p = n.next_power_of_2();\n        assert!(p >= n);\n        assert!(p >> 1 <= n);\n        assert!(p.is_power_of_2());\n\n        let mut n = n;\n        n.next_power_of_2_assign();\n        assert_eq!(n, p);\n    });\n}\n\nfn next_power_of_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen_var_19::<T>().test_properties(|x| {\n        let p = x.next_power_of_2();\n        assert!(p >= x);\n        assert!(p / T::TWO <= x);\n        assert!(p.is_power_of_2());\n\n        let mut x = x;\n        x.next_power_of_2_assign();\n        assert_eq!(x, p);\n    });\n}\n\n#[test]\nfn next_power_of_2_properties() {\n    apply_fn_to_unsigneds!(next_power_of_2_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(next_power_of_2_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::generators::signed_gen;\n\nfn overflowing_abs_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out, overflow| {\n        assert_eq!(n.overflowing_abs(), (out, overflow));\n\n        let mut n = n;\n        assert_eq!(n.overflowing_abs_assign(), overflow);\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO, false);\n    test(T::ONE, T::ONE, false);\n    test(T::exact_from(100), T::exact_from(100), false);\n    test(T::MAX, T::MAX, false);\n    test(T::NEGATIVE_ONE, T::ONE, false);\n    test(T::exact_from(-100), T::exact_from(100), false);\n    test(T::MIN, T::MIN, true);\n}\n\n#[test]\nfn test_overflowing_abs() {\n    apply_fn_to_signeds!(overflowing_abs_helper);\n}\n\nfn overflowing_abs_properties_helper<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|n| {\n        let mut abs = n;\n        let overflow = abs.overflowing_abs_assign();\n        assert_eq!((abs, overflow), n.overflowing_abs());\n        assert_eq!(abs, n.wrapping_abs());\n        if n != T::MIN {\n            assert_eq!(n.abs(), abs);\n        }\n        assert_eq!(abs == n, n >= T::ZERO || n == T::MIN);\n        assert_eq!(n == T::MIN, overflow);\n    });\n}\n\n#[test]\nfn overflowing_abs_properties() {\n    apply_fn_to_signeds!(overflowing_abs_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_overflowing_add() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_add(y), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_add_assign(y), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u16>(123, 456, 579, false);\n    test::<u8>(123, 200, 67, true);\n    test::<i16>(123, -456, -333, false);\n    test::<i8>(123, 45, -88, true);\n    test::<i8>(-123, -45, 88, true);\n}\n\nfn overflowing_add_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut sum = x;\n        let overflow = sum.overflowing_add_assign(y);\n        assert_eq!((sum, overflow), x.overflowing_add(y));\n        assert_eq!(x.wrapping_add(y), sum);\n        if !overflow {\n            assert_eq!(sum, x + y);\n        }\n    });\n}\n\nfn overflowing_add_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut sum = x;\n        let overflow = sum.overflowing_add_assign(y);\n        assert_eq!((sum, overflow), x.overflowing_add(y));\n        assert_eq!(x.wrapping_add(y), sum);\n        if !overflow {\n            assert_eq!(sum, x + y);\n        }\n    });\n}\n\n#[test]\nfn overflowing_add_properties() {\n    apply_fn_to_unsigneds!(overflowing_add_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_add_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_overflowing_add_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_add_mul(y, z), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_add_mul_assign(y, z), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u8>(2, 3, 7, 23, false);\n    test::<u32>(7, 5, 10, 57, false);\n    test::<u64>(123, 456, 789, 359907, false);\n    test::<i32>(123, -456, 789, -359661, false);\n    test::<i128>(-123, 456, 789, 359661, false);\n    test::<i8>(127, -2, 100, -73, false);\n    test::<i8>(-127, 2, 100, 73, false);\n    test::<i8>(-128, 1, 0, -128, false);\n\n    test::<u8>(2, 20, 20, 146, true);\n    test::<i8>(-127, -2, 100, -71, true);\n    test::<i8>(127, 1, 100, -29, true);\n    test::<i8>(-127, -1, 100, 29, true);\n    test::<i8>(-127, -10, 100, -103, true);\n}\n\nfn overflowing_add_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let (result, overflow) = x.overflowing_add_mul(y, z);\n\n        let mut x_alt = x;\n        assert_eq!(x_alt.overflowing_add_mul_assign(y, z), overflow);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.overflowing_add_mul(z, y), (result, overflow));\n        assert_eq!(result.overflowing_sub_mul(y, z), (x, overflow));\n        assert_eq!(x.wrapping_add_mul(y, z), result);\n        assert_eq!(x.checked_add_mul(y, z).is_none(), overflow);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.overflowing_add_mul(T::ZERO, b), (a, false));\n        assert_eq!(a.overflowing_add_mul(T::ONE, b), a.overflowing_add(b));\n        assert_eq!(T::ZERO.overflowing_add_mul(a, b), a.overflowing_mul(b));\n        assert_eq!(a.overflowing_add_mul(b, T::ZERO), (a, false));\n        assert_eq!(a.overflowing_add_mul(b, T::ONE), a.overflowing_add(b));\n    });\n}\n\nfn overflowing_add_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let (result, overflow) = x.overflowing_add_mul(y, z);\n\n        let mut x_alt = x;\n        assert_eq!(x_alt.overflowing_add_mul_assign(y, z), overflow);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.overflowing_add_mul(z, y), (result, overflow));\n        assert_eq!(result.overflowing_sub_mul(y, z), (x, overflow));\n        assert_eq!(x.wrapping_add_mul(y, z), result);\n        assert_eq!(x.checked_add_mul(y, z).is_none(), overflow);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.overflowing_add_mul(T::ZERO, b), (a, false));\n        assert_eq!(a.overflowing_add_mul(T::ONE, b), a.overflowing_add(b));\n        assert_eq!(T::ZERO.overflowing_add_mul(a, b), a.overflowing_mul(b));\n        assert_eq!(a.overflowing_add_mul(b, T::ZERO), (a, false));\n        assert_eq!(a.overflowing_add_mul(b, T::ONE), a.overflowing_add(b));\n    });\n}\n\n#[test]\nfn overflowing_add_mul_properties() {\n    apply_fn_to_unsigneds!(overflowing_add_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_add_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen_var_6, unsigned_pair_gen_var_12};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_overflowing_div() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_div(y), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_div_assign(y), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u16>(0, 5, 0, false);\n    test::<u16>(123, 456, 0, false);\n    test::<u8>(100, 3, 33, false);\n    test::<i8>(100, -3, -33, false);\n    test::<i16>(-100, 3, -33, false);\n    test::<i32>(-100, -3, 33, false);\n    test::<i8>(-128, -1, -128, true);\n}\n\nfn overflowing_div_assign_fail_helper<T: PrimitiveInt>() {\n    assert_panic!({\n        let mut n = T::ONE;\n        n.overflowing_div_assign(T::ZERO);\n    });\n}\n\n#[test]\nfn overflowing_div_assign_fail() {\n    apply_fn_to_primitive_ints!(overflowing_div_assign_fail_helper);\n}\n\nfn overflowing_div_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(x, y)| {\n        let mut quotient = x;\n        let overflow = quotient.overflowing_div_assign(y);\n        assert_eq!((quotient, overflow), x.overflowing_div(y));\n        assert_eq!(x.wrapping_div(y), quotient);\n        assert!(!overflow);\n        assert_eq!(quotient, x / y);\n    });\n}\n\nfn overflowing_div_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_6::<T>().test_properties(|(x, y)| {\n        let mut quotient = x;\n        let overflow = quotient.overflowing_div_assign(y);\n        assert_eq!((quotient, overflow), x.overflowing_div(y));\n        assert_eq!(x.wrapping_div(y), quotient);\n        if !overflow {\n            assert_eq!(quotient, x / y);\n        }\n    });\n}\n\n#[test]\nfn overflowing_div_properties() {\n    apply_fn_to_unsigneds!(overflowing_div_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_div_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_overflowing_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_mul(y), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_mul_assign(y), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u16>(123, 456, 56088, false);\n    test::<u8>(123, 200, 24, true);\n    test::<i16>(123, -45, -5535, false);\n    test::<i8>(123, 45, -97, true);\n    test::<i8>(-123, 45, 97, true);\n}\n\nfn overflowing_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut product = x;\n        let overflow = product.overflowing_mul_assign(y);\n        assert_eq!((product, overflow), x.overflowing_mul(y));\n        assert_eq!(x.wrapping_mul(y), product);\n        if !overflow {\n            assert_eq!(product, x * y);\n        }\n    });\n}\n\nfn overflowing_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut product = x;\n        let overflow = product.overflowing_mul_assign(y);\n        assert_eq!((product, overflow), x.overflowing_mul(y));\n        assert_eq!(x.wrapping_mul(y), product);\n        if !overflow {\n            assert_eq!(product, x * y);\n        }\n    });\n}\n\n#[test]\nfn overflowing_mul_properties() {\n    apply_fn_to_unsigneds!(overflowing_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\nfn unsigned_overflowing_neg_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, out, overflow| {\n        assert_eq!(n.overflowing_neg(), (out, overflow));\n\n        let mut n = n;\n        assert_eq!(n.overflowing_neg_assign(), overflow);\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO, false);\n    test(T::ONE, T::MAX, true);\n    test(\n        T::exact_from(100),\n        T::MAX - T::exact_from(100) + T::ONE,\n        true,\n    );\n    test(T::MAX, T::ONE, true);\n}\n\nfn signed_overflowing_neg_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out, overflow| {\n        assert_eq!(n.overflowing_neg(), (out, overflow));\n\n        let mut n = n;\n        assert_eq!(n.overflowing_neg_assign(), overflow);\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO, false);\n    test(T::ONE, T::NEGATIVE_ONE, false);\n    test(T::exact_from(100), T::exact_from(-100), false);\n    test(T::MAX, T::MIN + T::ONE, false);\n    test(T::NEGATIVE_ONE, T::ONE, false);\n    test(T::exact_from(-100), T::exact_from(100), false);\n    test(T::MIN, T::MIN, true);\n}\n\n#[test]\nfn test_overflowing_neg() {\n    apply_fn_to_unsigneds!(unsigned_overflowing_neg_helper);\n    apply_fn_to_signeds!(signed_overflowing_neg_helper);\n}\n\nfn overflowing_neg_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let mut neg = n;\n        let overflow = neg.overflowing_neg_assign();\n        assert_eq!((neg, overflow), n.overflowing_neg());\n        assert_eq!(neg, n.wrapping_neg());\n        assert_eq!(neg == n, n == T::ZERO || n == T::power_of_2(T::WIDTH - 1));\n        assert_eq!(n != T::ZERO, overflow);\n    });\n}\n\nfn overflowing_neg_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|n| {\n        let mut neg = n;\n        let overflow = neg.overflowing_neg_assign();\n        assert_eq!((neg, overflow), n.overflowing_neg());\n        assert_eq!(neg, n.wrapping_neg());\n        assert_eq!(neg == n, n == T::ZERO || n == T::MIN);\n        assert_eq!(n == T::MIN, overflow);\n    });\n}\n\n#[test]\nfn overflowing_neg_properties() {\n    apply_fn_to_unsigneds!(overflowing_neg_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_neg_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\n\n#[test]\nfn test_overflowing_pow() {\n    fn test<T: PrimitiveInt>(x: T, y: u64, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_pow(y), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_pow_assign(y), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, 1, false);\n    test::<u64>(123, 0, 1, false);\n    test::<u64>(123, 1, 123, false);\n    test::<u16>(0, 123, 0, false);\n    test::<u16>(1, 123, 1, false);\n    test::<i16>(-1, 123, -1, false);\n    test::<i16>(-1, 124, 1, false);\n    test::<u8>(3, 3, 27, false);\n    test::<i32>(-10, 9, -1000000000, false);\n    test::<i32>(-10, 10, 1410065408, true);\n    test::<i16>(-10, 9, 13824, true);\n    test::<i16>(10, 9, -13824, true);\n    test::<i64>(123, 456, 2409344748064316129, true);\n    test::<u64>(0, u64::MAX, 0, false);\n    test::<u64>(1, u64::MAX, 1, false);\n    test::<u64>(123, u64::MAX, 3449391168254631603, true);\n    test::<i64>(0, u64::MAX, 0, false);\n    test::<i64>(1, u64::MAX, 1, false);\n    test::<i64>(-1, u64::MAX, -1, false);\n    test::<i64>(-1, u64::MAX - 1, 1, false);\n    test::<i64>(123, u64::MAX, 3449391168254631603, true);\n    test::<i64>(-123, u64::MAX, -3449391168254631603, true);\n    test::<i64>(-123, u64::MAX - 1, 4527249702272692521, true);\n}\n\nfn overflowing_pow_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let mut power = x;\n        let overflow = power.overflowing_pow_assign(y);\n        assert_eq!((power, overflow), x.overflowing_pow(y));\n        assert_eq!(x.wrapping_pow(y), power);\n        assert_eq!(x.checked_pow(y).is_none(), overflow);\n        if !overflow {\n            assert_eq!(power, x.pow(y));\n        }\n    });\n}\n\nfn overflowing_pow_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let mut power = x;\n        let overflow = power.overflowing_pow_assign(y);\n        assert_eq!((power, overflow), x.overflowing_pow(y));\n        assert_eq!(x.wrapping_pow(y), power);\n        assert_eq!(x.checked_pow(y).is_none(), overflow);\n        if !overflow {\n            assert_eq!(power, x.pow(y));\n        }\n    });\n}\n\n#[test]\nfn overflowing_pow_properties() {\n    apply_fn_to_unsigneds!(overflowing_pow_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_pow_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\n#[test]\nfn test_overflowing_square() {\n    fn test<T: PrimitiveInt>(x: T, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_square(), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_square_assign(), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, false);\n    test::<i16>(1, 1, false);\n    test::<u32>(2, 4, false);\n    test::<i64>(3, 9, false);\n    test::<u128>(10, 100, false);\n    test::<isize>(123, 15129, false);\n    test::<u32>(1000, 1000000, false);\n\n    test::<i16>(-1, 1, false);\n    test::<i32>(-2, 4, false);\n    test::<i64>(-3, 9, false);\n    test::<i128>(-10, 100, false);\n    test::<isize>(-123, 15129, false);\n    test::<i32>(-1000, 1000000, false);\n\n    test::<u16>(1000, 16960, true);\n    test::<i16>(-1000, 16960, true);\n}\n\nfn overflowing_square_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        let mut square = x;\n        let overflow = square.overflowing_square_assign();\n        assert_eq!((square, overflow), x.overflowing_square());\n        assert_eq!((square, overflow), x.overflowing_pow(2));\n        assert_eq!(x.wrapping_square(), square);\n        assert_eq!(x.checked_square().is_none(), overflow);\n        if !overflow {\n            assert_eq!(square, x.square());\n        }\n    });\n}\n\nfn overflowing_square_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        let mut square = x;\n        let overflow = square.overflowing_square_assign();\n        assert_eq!((square, overflow), x.overflowing_square());\n        assert_eq!((square, overflow), x.overflowing_pow(2));\n        assert_eq!(x.wrapping_square(), square);\n        assert_eq!(x.checked_square().is_none(), overflow);\n        if !overflow {\n            assert_eq!(square, x.square());\n        }\n    });\n}\n\n#[test]\nfn overflowing_square_properties() {\n    apply_fn_to_unsigneds!(overflowing_square_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_square_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_overflowing_sub() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_sub(y), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_sub_assign(y), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u16>(456, 123, 333, false);\n    test::<u8>(123, 200, 179, true);\n    test::<i16>(123, -456, 579, false);\n    test::<i8>(123, -45, -88, true);\n    test::<i8>(-123, 45, 88, true);\n}\n\nfn overflowing_sub_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut diff = x;\n        let overflow = diff.overflowing_sub_assign(y);\n        assert_eq!((diff, overflow), x.overflowing_sub(y));\n        assert_eq!(x.wrapping_sub(y), diff);\n        if !overflow {\n            assert_eq!(diff, x - y);\n        }\n    });\n}\n\nfn overflowing_sub_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut diff = x;\n        let overflow = diff.overflowing_sub_assign(y);\n        assert_eq!((diff, overflow), x.overflowing_sub(y));\n        assert_eq!(x.wrapping_sub(y), diff);\n        if !overflow {\n            assert_eq!(diff, x - y);\n        }\n    });\n}\n\n#[test]\nfn overflowing_sub_properties() {\n    apply_fn_to_unsigneds!(overflowing_sub_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_sub_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/overflowing_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_overflowing_sub_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: T, overflow: bool) {\n        assert_eq!(x.overflowing_sub_mul(y, z), (out, overflow));\n\n        let mut x = x;\n        assert_eq!(x.overflowing_sub_mul_assign(y, z), overflow);\n        assert_eq!(x, out);\n    }\n    test::<u8>(100, 3, 7, 79, false);\n    test::<u32>(60, 5, 10, 10, false);\n    test::<u64>(1000000, 456, 789, 640216, false);\n    test::<i32>(123, -456, 789, 359907, false);\n    test::<i128>(-123, 456, 789, -359907, false);\n    test::<i8>(127, 2, 100, -73, false);\n    test::<i8>(-127, -2, 100, 73, false);\n    test::<i8>(-128, 1, 0, -128, false);\n\n    test::<u8>(2, 10, 5, 208, true);\n    test::<i8>(-127, 2, 100, -71, true);\n    test::<i8>(-127, 1, 100, 29, true);\n    test::<i8>(127, -1, 100, -29, true);\n    test::<i8>(127, -10, 100, 103, true);\n}\n\nfn overflowing_sub_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let (result, overflow) = x.overflowing_sub_mul(y, z);\n\n        let mut x_alt = x;\n        assert_eq!(x_alt.overflowing_sub_mul_assign(y, z), overflow);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.overflowing_sub_mul(z, y), (result, overflow));\n        assert_eq!(result.overflowing_add_mul(y, z), (x, overflow));\n        assert_eq!(x.wrapping_sub_mul(y, z), result);\n        assert_eq!(x.checked_sub_mul(y, z).is_none(), overflow);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.overflowing_sub_mul(T::ZERO, b), (a, false));\n        assert_eq!(a.overflowing_sub_mul(T::ONE, b), a.overflowing_sub(b));\n        assert_eq!(a.overflowing_sub_mul(b, T::ZERO), (a, false));\n        assert_eq!(a.overflowing_sub_mul(b, T::ONE), a.overflowing_sub(b));\n    });\n}\n\nfn overflowing_sub_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let (result, overflow) = x.overflowing_sub_mul(y, z);\n\n        let mut x_alt = x;\n        assert_eq!(x_alt.overflowing_sub_mul_assign(y, z), overflow);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.overflowing_sub_mul(z, y), (result, overflow));\n        assert_eq!(result.overflowing_add_mul(y, z), (x, overflow));\n        assert_eq!(x.wrapping_sub_mul(y, z), result);\n        assert_eq!(x.checked_sub_mul(y, z).is_none(), overflow);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.overflowing_sub_mul(T::ZERO, b), (a, false));\n        assert_eq!(a.overflowing_sub_mul(T::ONE, b), a.overflowing_sub(b));\n        assert_eq!(a.overflowing_sub_mul(b, T::ZERO), (a, false));\n        assert_eq!(a.overflowing_sub_mul(b, T::ONE), a.overflowing_sub(b));\n    });\n}\n\n#[test]\nfn overflowing_sub_mul_properties() {\n    apply_fn_to_unsigneds!(overflowing_sub_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(overflowing_sub_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\nfn even_primitive_helper<T: PrimitiveInt>() {\n    let test = |n: T, out| {\n        assert_eq!(n.even(), out);\n    };\n    test(T::ZERO, true);\n    test(T::ONE, false);\n    test(T::TWO, true);\n    test(T::exact_from(123), false);\n    test(T::exact_from(124), true);\n    test(T::MAX, false);\n}\n\nfn even_signed_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.even(), out);\n    };\n    test(T::NEGATIVE_ONE, false);\n    test(T::exact_from(-123), false);\n    test(T::exact_from(-124), true);\n    test(T::MIN, true);\n}\n\n#[test]\nfn test_even() {\n    apply_fn_to_primitive_ints!(even_primitive_helper);\n    apply_fn_to_signeds!(even_signed_helper);\n}\n\nfn odd_primitive_helper<T: PrimitiveInt>() {\n    let test = |n: T, out| {\n        assert_eq!(n.odd(), out);\n    };\n    test(T::ZERO, false);\n    test(T::ONE, true);\n    test(T::TWO, false);\n    test(T::exact_from(123), true);\n    test(T::exact_from(124), false);\n    test(T::MAX, true);\n}\n\nfn odd_signed_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.odd(), out);\n    };\n    test(T::NEGATIVE_ONE, true);\n    test(T::exact_from(-123), true);\n    test(T::exact_from(-124), false);\n    test(T::MIN, false);\n}\n\n#[test]\nfn test_odd() {\n    apply_fn_to_primitive_ints!(odd_primitive_helper);\n    apply_fn_to_signeds!(odd_signed_helper);\n}\n\nfn even_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        let even = x.even();\n        assert_eq!(x.divisible_by(T::TWO), even);\n        assert_eq!(!x.odd(), even);\n        if x != T::MAX {\n            assert_eq!((x + T::ONE).odd(), even);\n        }\n        if x != T::ZERO {\n            assert_eq!((x - T::ONE).odd(), even);\n        }\n    });\n}\n\nfn even_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        let even = x.even();\n        assert_eq!(x.divisible_by(T::TWO), even);\n        assert_eq!(!x.odd(), even);\n        if x != T::MAX {\n            assert_eq!((x + T::ONE).odd(), even);\n        }\n        if x != T::MIN {\n            assert_eq!((x - T::ONE).odd(), even);\n            assert_eq!((-x).even(), even);\n        }\n    });\n}\n\n#[test]\nfn even_properties() {\n    apply_fn_to_unsigneds!(even_properties_helper_unsigned);\n    apply_fn_to_signeds!(even_properties_helper_signed);\n}\n\nfn odd_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        let odd = x.odd();\n        assert_ne!(x.divisible_by(T::TWO), odd);\n        assert_eq!(!x.even(), odd);\n        if x != T::MAX {\n            assert_eq!((x + T::ONE).even(), odd);\n        }\n        if x != T::ZERO {\n            assert_eq!((x - T::ONE).even(), odd);\n        }\n    });\n}\n\nfn odd_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        let odd = x.odd();\n        assert_ne!(x.divisible_by(T::TWO), odd);\n        assert_eq!(!x.even(), odd);\n        if x != T::MAX {\n            assert_eq!((x + T::ONE).even(), odd);\n        }\n        if x != T::MIN {\n            assert_eq!((x - T::ONE).even(), odd);\n            assert_eq!((-x).odd(), odd);\n        }\n    });\n}\n\n#[test]\nfn odd_properties() {\n    apply_fn_to_unsigneds!(odd_properties_helper_unsigned);\n    apply_fn_to_signeds!(odd_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_pair_gen, primitive_float_signed_pair_gen, signed_unsigned_pair_gen_var_15,\n    unsigned_pair_gen_var_29,\n};\n\n#[test]\nfn test_pow() {\n    fn test_primitive_int<T: PrimitiveInt>(x: T, y: u64, out: T) {\n        assert_eq!(x.pow(y), out);\n\n        let mut x = x;\n        x.pow_assign(y);\n        assert_eq!(x, out);\n    }\n    test_primitive_int::<u8>(0, 0, 1);\n    test_primitive_int::<u64>(123, 0, 1);\n    test_primitive_int::<u64>(123, 1, 123);\n    test_primitive_int::<u16>(0, 123, 0);\n    test_primitive_int::<u16>(1, 123, 1);\n    test_primitive_int::<i16>(-1, 123, -1);\n    test_primitive_int::<i16>(-1, 124, 1);\n    test_primitive_int::<u8>(3, 3, 27);\n    test_primitive_int::<i32>(-10, 9, -1000000000);\n    test_primitive_int::<i32>(-10, 8, 100000000);\n\n    fn test_i64_primitive_float<T: PrimitiveFloat>(x: T, y: i64, out: T) {\n        assert_eq!(NiceFloat(x.pow(y)), NiceFloat(out));\n\n        let mut x = x;\n        x.pow_assign(y);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n    }\n    test_i64_primitive_float::<f32>(2.0, 5, 32.0);\n\n    fn test_primitive_float_primitive_float<T: PrimitiveFloat>(x: T, y: T, out: T) {\n        assert_eq!(NiceFloat(x.pow(y)), NiceFloat(out));\n\n        let mut x = x;\n        x.pow_assign(y);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n    }\n    test_primitive_float_primitive_float::<f32>(2.0, 5.0, 32.0);\n}\n\nfn pow_assign_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_29::<T>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.pow_assign(y);\n        assert_eq!(power, x.pow(y));\n        if x > T::ONE {\n            assert_eq!(power.checked_log_base(x), Some(y));\n        }\n        if y != 0 {\n            assert_eq!(power.checked_root(y), Some(x));\n        }\n    });\n}\n\nfn pow_assign_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_15::<T>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.pow_assign(y);\n        assert_eq!(power, x.pow(y));\n        if y != 0 {\n            assert_eq!(\n                power.checked_root(y),\n                Some(if y.even() { x.abs() } else { x })\n            );\n        }\n    });\n}\n\nfn pow_assign_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_signed_pair_gen::<T, i64>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.pow_assign(y);\n        assert_eq!(NiceFloat(power), NiceFloat(x.pow(y)));\n    });\n\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.pow_assign(y);\n        assert_eq!(NiceFloat(power), NiceFloat(x.pow(y)));\n    });\n}\n\n#[test]\nfn pow_assign_properties() {\n    apply_fn_to_unsigneds!(pow_assign_properties_helper_unsigned);\n    apply_fn_to_signeds!(pow_assign_properties_helper_signed);\n    apply_fn_to_primitive_floats!(pow_assign_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen_var_11, unsigned_gen_var_15, unsigned_gen_var_16, unsigned_gen_var_30,\n};\nuse std::panic::catch_unwind;\n\nfn power_of_2_primitive_int_helper<T: PrimitiveInt>() {\n    let test = |pow, out| {\n        assert_eq!(T::power_of_2(pow), out);\n    };\n    test(0, T::ONE);\n    test(1, T::TWO);\n    test(2, T::exact_from(4));\n    test(3, T::exact_from(8));\n}\n\nfn power_of_2_unsigned_helper<T: PrimitiveUnsigned>() {\n    let test = |pow, out| {\n        assert_eq!(T::power_of_2(pow), out);\n    };\n    test(T::WIDTH - 1, T::ONE << (T::WIDTH - 1));\n}\n\nfn power_of_2_primitive_float_helper<T: PrimitiveFloat>() {\n    let test = |pow, out| {\n        assert_eq!(T::power_of_2(pow), out);\n    };\n    test(0, T::ONE);\n    test(1, T::TWO);\n    test(-1, T::from(0.5f32));\n    test(2, T::from(4.0f32));\n    test(-2, T::from(0.25f32));\n    test(T::MIN_EXPONENT, T::MIN_POSITIVE_SUBNORMAL);\n}\n\n#[test]\nfn test_power_of_2() {\n    apply_fn_to_primitive_ints!(power_of_2_primitive_int_helper);\n    apply_fn_to_unsigneds!(power_of_2_unsigned_helper);\n    apply_fn_to_primitive_floats!(power_of_2_primitive_float_helper);\n}\n\nfn power_of_2_unsigned_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::power_of_2(T::WIDTH));\n}\n\nfn power_of_2_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::power_of_2(T::WIDTH - 1));\n}\n\nfn power_of_2_primitive_float_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::power_of_2(T::MAX_EXPONENT + 1));\n    assert_panic!(T::power_of_2(T::MIN_EXPONENT - 1));\n    assert_panic!(T::power_of_2(10000u64));\n    assert_panic!(T::power_of_2(-10000i64));\n}\n\n#[test]\nfn power_of_2_fail() {\n    apply_fn_to_unsigneds!(power_of_2_unsigned_fail_helper);\n    apply_fn_to_signeds!(power_of_2_signed_fail_helper);\n    apply_fn_to_primitive_floats!(power_of_2_primitive_float_fail_helper);\n}\n\nfn power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_15::<T>().test_properties(|pow| {\n        let mut n = T::power_of_2(pow);\n        assert_eq!(n.checked_log_base_2(), Some(pow));\n        assert!(n.is_power_of_2());\n        n.clear_bit(pow);\n        assert_eq!(n, T::ZERO);\n    });\n}\n\nfn power_of_2_properties_helper_signed<U: TryFrom<S> + PrimitiveUnsigned, S: PrimitiveSigned>() {\n    unsigned_gen_var_16::<S>().test_properties(|pow| {\n        let mut n = S::power_of_2(pow);\n        assert_eq!(U::exact_from(n), U::power_of_2(pow));\n        n.clear_bit(pow);\n        assert_eq!(n, S::ZERO);\n    });\n}\n\nfn power_of_2_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    unsigned_gen_var_30::<T>().test_properties(|pow| {\n        let n = T::power_of_2(pow);\n        assert!(n > T::ZERO);\n        assert!(n.is_power_of_2());\n    });\n\n    signed_gen_var_11::<T>().test_properties(|pow| {\n        let n = T::power_of_2(pow);\n        assert!(n > T::ZERO);\n        assert!(n.is_power_of_2());\n    });\n}\n\n#[test]\nfn power_of_2_properties() {\n    apply_fn_to_unsigneds!(power_of_2_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(power_of_2_properties_helper_signed);\n    apply_fn_to_primitive_floats!(power_of_2_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::factorization::traits::Primes;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_27, unsigned_gen_var_28,\n};\nuse malachite_base::test_util::num::arithmetic::primorial::{\n    checked_primorial_naive, checked_product_of_first_n_primes_naive,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_primorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: T) {\n        assert_eq!(T::primorial(n), out);\n    }\n    test::<u8>(0, 1);\n    test::<u8>(1, 1);\n    test::<u8>(2, 2);\n    test::<u8>(3, 6);\n    test::<u8>(4, 6);\n    test::<u8>(5, 30);\n    test::<u32>(20, 9699690);\n}\n\nfn primorial_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::primorial(200));\n}\n\n#[test]\nfn primorial_fail() {\n    apply_fn_to_unsigneds!(primorial_fail_helper);\n}\n\n#[test]\nfn test_checked_primorial() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: Option<T>) {\n        assert_eq!(T::checked_primorial(n), out);\n        assert_eq!(checked_primorial_naive(n), out);\n    }\n    test::<u8>(0, Some(1));\n    test::<u8>(1, Some(1));\n    test::<u8>(2, Some(2));\n    test::<u8>(3, Some(6));\n    test::<u8>(4, Some(6));\n    test::<u8>(5, Some(30));\n    test::<u32>(20, Some(9699690));\n\n    test::<u8>(11, None);\n    test::<u32>(200, None);\n}\n\n#[test]\nfn test_product_of_first_n_primes() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: T) {\n        assert_eq!(T::product_of_first_n_primes(n), out);\n    }\n    test::<u8>(0, 1);\n    test::<u8>(1, 2);\n    test::<u8>(2, 6);\n    test::<u8>(3, 30);\n    test::<u8>(4, 210);\n    test::<u32>(9, 223092870);\n}\n\nfn product_of_first_n_primes_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::product_of_first_n_primes(100));\n}\n\n#[test]\nfn product_of_first_n_primes_fail() {\n    apply_fn_to_unsigneds!(product_of_first_n_primes_fail_helper);\n}\n\n#[test]\nfn test_checked_product_of_first_n_primes() {\n    fn test<T: PrimitiveUnsigned>(n: u64, out: Option<T>) {\n        assert_eq!(T::checked_product_of_first_n_primes(n), out);\n        assert_eq!(checked_product_of_first_n_primes_naive(n), out);\n    }\n    test::<u8>(0, Some(1));\n    test::<u8>(1, Some(2));\n    test::<u8>(2, Some(6));\n    test::<u8>(3, Some(30));\n    test::<u8>(4, Some(210));\n    test::<u32>(9, Some(223092870));\n\n    test::<u8>(5, None);\n    test::<u32>(100, None);\n}\n\nfn primorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_27::<T>().test_properties(|n| {\n        let f = T::primorial(n);\n        assert_eq!(T::checked_primorial(n), Some(f));\n        assert_ne!(f, T::ZERO);\n        // TODO compare with primorial(n - 1) depending on whether n is prime\n    });\n}\n\n#[test]\nfn primorial_properties() {\n    apply_fn_to_unsigneds!(primorial_properties_helper);\n}\n\nfn checked_primorial_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen().test_properties(|n| {\n        let of = T::checked_primorial(n);\n        assert_eq!(checked_primorial_naive(n), of);\n        assert_ne!(of, Some(T::ZERO));\n        if let Some(f) = of {\n            assert_eq!(T::primorial(n), f);\n        }\n        if n != u64::MAX && of.is_none() {\n            assert!(T::checked_primorial(n + 1).is_none());\n        }\n    });\n}\n\n#[test]\nfn checked_primorial_properties() {\n    apply_fn_to_unsigneds!(checked_primorial_properties_helper);\n}\n\nfn product_of_first_n_primes_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_28::<T>().test_properties(|n| {\n        let f = T::product_of_first_n_primes(n);\n        assert_eq!(T::checked_product_of_first_n_primes(n), Some(f));\n        assert_ne!(f, T::ZERO);\n        if n != 0 {\n            let p = u64::primes().nth(usize::exact_from(n) - 1).unwrap();\n            assert_eq!(T::primorial(p), f);\n            assert_eq!(f / T::product_of_first_n_primes(n - 1), T::exact_from(p));\n        }\n    });\n}\n\n#[test]\nfn product_of_first_n_primes_properties() {\n    apply_fn_to_unsigneds!(product_of_first_n_primes_properties_helper);\n}\n\nfn checked_product_of_first_n_primes_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen().test_properties(|n| {\n        let of = T::checked_product_of_first_n_primes(n);\n        assert_eq!(checked_product_of_first_n_primes_naive(n), of);\n        assert_ne!(of, Some(T::ZERO));\n        if let Some(f) = of {\n            assert_eq!(T::product_of_first_n_primes(n), f);\n        }\n        if n != u64::MAX && of.is_none() {\n            assert!(T::checked_product_of_first_n_primes(n + 1).is_none());\n        }\n    });\n}\n\n#[test]\nfn checked_product_of_first_n_primes_properties() {\n    apply_fn_to_unsigneds!(checked_product_of_first_n_primes_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen;\n\n#[test]\nfn test_reciprocal() {\n    fn test<T: PrimitiveFloat>(x: T, out: T) {\n        assert_eq!(NiceFloat(x.reciprocal()), NiceFloat(out));\n\n        let mut x = x;\n        x.reciprocal_assign();\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n    }\n    test::<f32>(f32::NAN, f32::NAN);\n    test::<f32>(f32::INFINITY, 0.0);\n    test::<f32>(f32::NEGATIVE_INFINITY, -0.0);\n    test::<f32>(0.0, f32::INFINITY);\n    test::<f32>(-0.0, f32::NEGATIVE_INFINITY);\n    test::<f32>(1.0, 1.0);\n    test::<f32>(-1.0, -1.0);\n    test::<f32>(0.5, 2.0);\n    test::<f32>(-0.5, -2.0);\n    test::<f32>(core::f32::consts::SQRT_2, 0.70710677);\n    test::<f32>(-core::f32::consts::SQRT_2, -0.70710677);\n    test::<f32>(core::f32::consts::PI, std::f32::consts::FRAC_1_PI);\n    test::<f32>(-core::f32::consts::PI, -std::f32::consts::FRAC_1_PI);\n\n    test::<f64>(f64::NAN, f64::NAN);\n    test::<f64>(f64::INFINITY, 0.0);\n    test::<f64>(f64::NEGATIVE_INFINITY, -0.0);\n    test::<f64>(0.0, f64::INFINITY);\n    test::<f64>(-0.0, f64::NEGATIVE_INFINITY);\n    test::<f64>(1.0, 1.0);\n    test::<f64>(-1.0, -1.0);\n    test::<f64>(0.5, 2.0);\n    test::<f64>(-0.5, -2.0);\n    test::<f64>(core::f64::consts::SQRT_2, 0.7071067811865475);\n    test::<f64>(-core::f64::consts::SQRT_2, -0.7071067811865475);\n    test::<f64>(core::f64::consts::PI, std::f64::consts::FRAC_1_PI);\n    test::<f64>(-core::f64::consts::PI, -std::f64::consts::FRAC_1_PI);\n}\n\nfn reciprocal_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|x| {\n        let mut reciprocal = x;\n        reciprocal.reciprocal_assign();\n        assert_eq!(NiceFloat(reciprocal), NiceFloat(x.reciprocal()));\n        assert_eq!(NiceFloat(reciprocal), NiceFloat(x.pow(-1)));\n        assert_eq!(NiceFloat((-x).reciprocal()), NiceFloat(-reciprocal));\n    });\n}\n\n#[test]\nfn reciprocal_properties() {\n    apply_fn_to_primitive_floats!(reciprocal_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::root::{\n    cbrt_chebyshev_approx_u32, cbrt_chebyshev_approx_u64, fast_ceiling_root_u32,\n    fast_ceiling_root_u64, fast_checked_root_u32, fast_checked_root_u64, fast_floor_cbrt_u32,\n    fast_floor_cbrt_u64, fast_floor_root_u32, fast_floor_root_u64, fast_root_rem_u32,\n    fast_root_rem_u64, floor_root_approx_and_refine,\n};\nuse malachite_base::num::arithmetic::root::{\n    ceiling_root_binary, checked_root_binary, floor_root_binary, root_rem_binary,\n};\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CheckedRoot, FloorRoot, Parity, RootRem,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_2, signed_unsigned_pair_gen_var_18, unsigned_gen,\n    unsigned_gen_var_1, unsigned_pair_gen_var_32,\n};\nuse std::ops::Neg;\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_floor_root() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, exp: u64, out: T) {\n        assert_eq!(n.floor_root(exp), out);\n        assert_eq!(floor_root_binary(n, exp), out);\n\n        let mut n = n;\n        n.floor_root_assign(exp);\n        assert_eq!(n, out);\n    }\n    test_u::<u8>(0, 1, 0);\n    test_u::<u8>(1, 1, 1);\n    test_u::<u8>(2, 1, 2);\n    test_u::<u8>(100, 1, 100);\n\n    test_u::<u8>(0, 2, 0);\n    test_u::<u8>(1, 2, 1);\n    test_u::<u8>(2, 2, 1);\n    test_u::<u8>(3, 2, 1);\n    test_u::<u8>(4, 2, 2);\n    test_u::<u8>(5, 2, 2);\n    test_u::<u8>(0, 3, 0);\n    test_u::<u8>(1, 3, 1);\n    test_u::<u8>(2, 3, 1);\n    test_u::<u8>(7, 3, 1);\n    test_u::<u8>(8, 3, 2);\n    test_u::<u8>(9, 3, 2);\n    test_u::<u8>(10, 2, 3);\n    test_u::<u8>(100, 2, 10);\n    test_u::<u8>(100, 3, 4);\n    test_u::<u32>(1000000000, 2, 31622);\n    test_u::<u32>(1000000000, 3, 1000);\n    test_u::<u32>(1000000000, 4, 177);\n    test_u::<u32>(1000000000, 5, 63);\n    test_u::<u32>(1000000000, 6, 31);\n    test_u::<u32>(1000000000, 7, 19);\n    test_u::<u32>(1000000000, 8, 13);\n    test_u::<u32>(1000000000, 9, 10);\n    test_u::<u32>(1000000000, 10, 7);\n\n    fn test_i<T: PrimitiveSigned>(n: T, exp: u64, out: T) {\n        assert_eq!(n.floor_root(exp), out);\n\n        let mut n = n;\n        n.floor_root_assign(exp);\n        assert_eq!(n, out);\n    }\n    test_i::<i8>(0, 1, 0);\n    test_i::<i8>(1, 1, 1);\n    test_i::<i8>(2, 1, 2);\n    test_i::<i8>(100, 1, 100);\n\n    test_i::<i8>(0, 2, 0);\n    test_i::<i8>(0, 2, 0);\n    test_i::<i8>(1, 2, 1);\n    test_i::<i8>(2, 2, 1);\n    test_i::<i8>(3, 2, 1);\n    test_i::<i8>(4, 2, 2);\n    test_i::<i8>(5, 2, 2);\n    test_i::<i8>(0, 3, 0);\n    test_i::<i8>(1, 3, 1);\n    test_i::<i8>(2, 3, 1);\n    test_i::<i8>(7, 3, 1);\n    test_i::<i8>(8, 3, 2);\n    test_i::<i8>(9, 3, 2);\n    test_i::<i8>(10, 2, 3);\n    test_i::<i8>(100, 2, 10);\n    test_i::<i8>(100, 3, 4);\n    test_i::<i32>(1000000000, 2, 31622);\n    test_i::<i32>(1000000000, 3, 1000);\n    test_i::<i32>(1000000000, 4, 177);\n    test_i::<i32>(1000000000, 5, 63);\n    test_i::<i32>(1000000000, 6, 31);\n    test_i::<i32>(1000000000, 7, 19);\n    test_i::<i32>(1000000000, 8, 13);\n    test_i::<i32>(1000000000, 9, 10);\n    test_i::<i32>(1000000000, 10, 7);\n\n    test_i::<i8>(-1, 1, -1);\n    test_i::<i8>(-2, 1, -2);\n    test_i::<i8>(-100, 1, -100);\n\n    test_i::<i8>(-1, 3, -1);\n    test_i::<i8>(-2, 3, -2);\n    test_i::<i8>(-7, 3, -2);\n    test_i::<i8>(-8, 3, -2);\n    test_i::<i8>(-9, 3, -3);\n    test_i::<i8>(-100, 3, -5);\n    test_i::<i32>(-1000000000, 3, -1000);\n    test_i::<i32>(-1000000000, 5, -64);\n    test_i::<i32>(-1000000000, 7, -20);\n    test_i::<i32>(-1000000000, 9, -10);\n}\n\nfn floor_root_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.floor_root(0));\n}\n\nfn floor_root_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::ONE.floor_root(0));\n    assert_panic!(T::NEGATIVE_ONE.floor_root(0));\n    assert_panic!(T::NEGATIVE_ONE.floor_root(2));\n    assert_panic!(T::NEGATIVE_ONE.floor_root(4));\n    assert_panic!(T::NEGATIVE_ONE.floor_root(100));\n}\n\n#[test]\npub fn floor_root_fail() {\n    apply_fn_to_unsigneds!(floor_root_fail_helper_unsigned);\n    apply_fn_to_signeds!(floor_root_fail_helper_signed);\n}\n\n#[test]\nfn test_ceiling_root() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, exp: u64, out: T) {\n        assert_eq!(n.ceiling_root(exp), out);\n        assert_eq!(ceiling_root_binary(n, exp), out);\n\n        let mut n = n;\n        n.ceiling_root_assign(exp);\n        assert_eq!(n, out);\n    }\n    test_u::<u8>(0, 1, 0);\n    test_u::<u8>(1, 1, 1);\n    test_u::<u8>(2, 1, 2);\n    test_u::<u8>(100, 1, 100);\n\n    test_u::<u8>(0, 2, 0);\n    test_u::<u8>(1, 2, 1);\n    test_u::<u8>(2, 2, 2);\n    test_u::<u8>(3, 2, 2);\n    test_u::<u8>(4, 2, 2);\n    test_u::<u8>(5, 2, 3);\n    test_u::<u8>(0, 3, 0);\n    test_u::<u8>(1, 3, 1);\n    test_u::<u8>(2, 3, 2);\n    test_u::<u8>(7, 3, 2);\n    test_u::<u8>(8, 3, 2);\n    test_u::<u8>(9, 3, 3);\n    test_u::<u8>(10, 2, 4);\n    test_u::<u8>(100, 2, 10);\n    test_u::<u8>(100, 3, 5);\n    test_u::<u32>(1000000000, 2, 31623);\n    test_u::<u32>(1000000000, 3, 1000);\n    test_u::<u32>(1000000000, 4, 178);\n    test_u::<u32>(1000000000, 5, 64);\n    test_u::<u32>(1000000000, 6, 32);\n    test_u::<u32>(1000000000, 7, 20);\n    test_u::<u32>(1000000000, 8, 14);\n    test_u::<u32>(1000000000, 9, 10);\n    test_u::<u32>(1000000000, 10, 8);\n\n    fn test_i<T: PrimitiveSigned>(n: T, exp: u64, out: T) {\n        assert_eq!(n.ceiling_root(exp), out);\n\n        let mut n = n;\n        n.ceiling_root_assign(exp);\n        assert_eq!(n, out);\n    }\n    test_i::<i8>(0, 1, 0);\n    test_i::<i8>(1, 1, 1);\n    test_i::<i8>(2, 1, 2);\n    test_i::<i8>(100, 1, 100);\n\n    test_i::<i8>(0, 2, 0);\n    test_i::<i8>(1, 2, 1);\n    test_i::<i8>(2, 2, 2);\n    test_i::<i8>(3, 2, 2);\n    test_i::<i8>(4, 2, 2);\n    test_i::<i8>(5, 2, 3);\n    test_i::<i8>(0, 3, 0);\n    test_i::<i8>(1, 3, 1);\n    test_i::<i8>(2, 3, 2);\n    test_i::<i8>(7, 3, 2);\n    test_i::<i8>(8, 3, 2);\n    test_i::<i8>(9, 3, 3);\n    test_i::<i8>(10, 2, 4);\n    test_i::<i8>(100, 2, 10);\n    test_i::<i8>(100, 3, 5);\n    test_i::<i32>(1000000000, 2, 31623);\n    test_i::<i32>(1000000000, 3, 1000);\n    test_i::<i32>(1000000000, 4, 178);\n    test_i::<i32>(1000000000, 5, 64);\n    test_i::<i32>(1000000000, 6, 32);\n    test_i::<i32>(1000000000, 7, 20);\n    test_i::<i32>(1000000000, 8, 14);\n    test_i::<i32>(1000000000, 9, 10);\n    test_i::<i32>(1000000000, 10, 8);\n\n    test_i::<i8>(-1, 1, -1);\n    test_i::<i8>(-2, 1, -2);\n    test_i::<i8>(-100, 1, -100);\n\n    test_i::<i8>(-1, 3, -1);\n    test_i::<i8>(-2, 3, -1);\n    test_i::<i8>(-7, 3, -1);\n    test_i::<i8>(-8, 3, -2);\n    test_i::<i8>(-9, 3, -2);\n    test_i::<i8>(-100, 3, -4);\n    test_i::<i32>(-1000000000, 3, -1000);\n    test_i::<i32>(-1000000000, 5, -63);\n    test_i::<i32>(-1000000000, 7, -19);\n    test_i::<i32>(-1000000000, 9, -10);\n}\n\nfn ceiling_root_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.ceiling_root(0));\n}\n\nfn ceiling_root_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::ONE.ceiling_root(0));\n    assert_panic!(T::NEGATIVE_ONE.ceiling_root(0));\n    assert_panic!(T::NEGATIVE_ONE.ceiling_root(2));\n    assert_panic!(T::NEGATIVE_ONE.ceiling_root(4));\n    assert_panic!(T::NEGATIVE_ONE.ceiling_root(100));\n}\n\n#[test]\npub fn ceiling_root_fail() {\n    apply_fn_to_unsigneds!(ceiling_root_fail_helper_unsigned);\n    apply_fn_to_signeds!(ceiling_root_fail_helper_signed);\n}\n\n#[test]\nfn test_checked_root() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, exp: u64, out: Option<T>) {\n        assert_eq!(n.checked_root(exp), out);\n        assert_eq!(checked_root_binary(n, exp), out);\n    }\n    test_u::<u8>(0, 1, Some(0));\n    test_u::<u8>(1, 1, Some(1));\n    test_u::<u8>(2, 1, Some(2));\n    test_u::<u8>(100, 1, Some(100));\n\n    test_u::<u8>(0, 2, Some(0));\n    test_u::<u8>(1, 2, Some(1));\n    test_u::<u8>(2, 2, None);\n    test_u::<u8>(3, 2, None);\n    test_u::<u8>(4, 2, Some(2));\n    test_u::<u8>(5, 2, None);\n    test_u::<u8>(0, 3, Some(0));\n    test_u::<u8>(1, 3, Some(1));\n    test_u::<u8>(2, 3, None);\n    test_u::<u8>(7, 3, None);\n    test_u::<u8>(8, 3, Some(2));\n    test_u::<u8>(9, 3, None);\n    test_u::<u8>(10, 2, None);\n    test_u::<u8>(100, 2, Some(10));\n    test_u::<u8>(100, 3, None);\n    test_u::<u32>(1000000000, 2, None);\n    test_u::<u32>(1000000000, 3, Some(1000));\n    test_u::<u32>(1000000000, 4, None);\n    test_u::<u32>(1000000000, 5, None);\n    test_u::<u32>(1000000000, 6, None);\n    test_u::<u32>(1000000000, 7, None);\n    test_u::<u32>(1000000000, 8, None);\n    test_u::<u32>(1000000000, 9, Some(10));\n    test_u::<u32>(1000000000, 10, None);\n\n    fn test_i<T: PrimitiveSigned>(n: T, exp: u64, out: Option<T>) {\n        assert_eq!(n.checked_root(exp), out);\n    }\n    test_i::<i8>(0, 1, Some(0));\n    test_i::<i8>(1, 1, Some(1));\n    test_i::<i8>(2, 1, Some(2));\n    test_i::<i8>(100, 1, Some(100));\n\n    test_i::<i8>(0, 2, Some(0));\n    test_i::<i8>(1, 2, Some(1));\n    test_i::<i8>(2, 2, None);\n    test_i::<i8>(3, 2, None);\n    test_i::<i8>(4, 2, Some(2));\n    test_i::<i8>(5, 2, None);\n    test_i::<i8>(0, 3, Some(0));\n    test_i::<i8>(1, 3, Some(1));\n    test_i::<i8>(2, 3, None);\n    test_i::<i8>(7, 3, None);\n    test_i::<i8>(8, 3, Some(2));\n    test_i::<i8>(9, 3, None);\n    test_i::<i8>(10, 2, None);\n    test_i::<i8>(100, 2, Some(10));\n    test_i::<i8>(100, 3, None);\n    test_i::<i32>(1000000000, 2, None);\n    test_i::<i32>(1000000000, 3, Some(1000));\n    test_i::<i32>(1000000000, 4, None);\n    test_i::<i32>(1000000000, 5, None);\n    test_i::<i32>(1000000000, 6, None);\n    test_i::<i32>(1000000000, 7, None);\n    test_i::<i32>(1000000000, 8, None);\n    test_i::<i32>(1000000000, 9, Some(10));\n    test_i::<i32>(1000000000, 10, None);\n\n    test_i::<i8>(-1, 1, Some(-1));\n    test_i::<i8>(-2, 1, Some(-2));\n    test_i::<i8>(-100, 1, Some(-100));\n\n    test_i::<i8>(-1, 3, Some(-1));\n    test_i::<i8>(-2, 3, None);\n    test_i::<i8>(-7, 3, None);\n    test_i::<i8>(-8, 3, Some(-2));\n    test_i::<i8>(-9, 3, None);\n    test_i::<i8>(-100, 3, None);\n    test_i::<i32>(-1000000000, 3, Some(-1000));\n    test_i::<i32>(-1000000000, 5, None);\n    test_i::<i32>(-1000000000, 7, None);\n    test_i::<i32>(-1000000000, 9, Some(-10));\n}\n\nfn checked_root_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.checked_root(0));\n}\n\nfn checked_root_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::ONE.checked_root(0));\n    assert_panic!(T::NEGATIVE_ONE.checked_root(0));\n    assert_panic!(T::NEGATIVE_ONE.checked_root(2));\n    assert_panic!(T::NEGATIVE_ONE.checked_root(4));\n    assert_panic!(T::NEGATIVE_ONE.checked_root(100));\n}\n\n#[test]\npub fn checked_root_fail() {\n    apply_fn_to_unsigneds!(checked_root_fail_helper_unsigned);\n    apply_fn_to_signeds!(checked_root_fail_helper_signed);\n}\n\n#[test]\nfn test_root_rem() {\n    fn test<T: PrimitiveUnsigned>(n: T, exp: u64, out_root: T, out_rem: T) {\n        assert_eq!(n.root_rem(exp), (out_root, out_rem));\n        assert_eq!(root_rem_binary(n, exp), (out_root, out_rem));\n\n        let mut n = n;\n        assert_eq!(n.root_assign_rem(exp), out_rem);\n        assert_eq!(n, out_root);\n    }\n    test::<u8>(0, 1, 0, 0);\n    test::<u8>(1, 1, 1, 0);\n    test::<u8>(2, 1, 2, 0);\n    test::<u8>(100, 1, 100, 0);\n\n    test::<u8>(0, 2, 0, 0);\n    test::<u8>(1, 2, 1, 0);\n    test::<u8>(2, 2, 1, 1);\n    test::<u8>(3, 2, 1, 2);\n    test::<u8>(4, 2, 2, 0);\n    test::<u8>(5, 2, 2, 1);\n    test::<u8>(0, 3, 0, 0);\n    test::<u8>(1, 3, 1, 0);\n    test::<u8>(2, 3, 1, 1);\n    test::<u8>(7, 3, 1, 6);\n    test::<u8>(8, 3, 2, 0);\n    test::<u8>(9, 3, 2, 1);\n    test::<u8>(10, 2, 3, 1);\n    test::<u8>(100, 2, 10, 0);\n    test::<u8>(100, 3, 4, 36);\n    test::<u32>(1000000000, 2, 31622, 49116);\n    test::<u32>(1000000000, 3, 1000, 0);\n    test::<u32>(1000000000, 4, 177, 18493759);\n    test::<u32>(1000000000, 5, 63, 7563457);\n    test::<u32>(1000000000, 6, 31, 112496319);\n    test::<u32>(1000000000, 7, 19, 106128261);\n    test::<u32>(1000000000, 8, 13, 184269279);\n    test::<u32>(1000000000, 9, 10, 0);\n    test::<u32>(1000000000, 10, 7, 717524751);\n}\n\nfn root_rem_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ONE.root_rem(0));\n}\n\n#[test]\npub fn root_rem_fail() {\n    apply_fn_to_unsigneds!(root_rem_fail_helper);\n}\n\nfn floor_root_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_32::<T, u64>().test_properties(|(n, exp)| {\n        let root = n.floor_root(exp);\n        let mut n_alt = n;\n        n_alt.floor_root_assign(exp);\n        assert_eq!(n_alt, root);\n        assert_eq!(floor_root_binary(n, exp), root);\n        let pow = root.pow(exp);\n        let ceiling_root = n.ceiling_root(exp);\n        if pow == n {\n            assert_eq!(ceiling_root, root);\n        } else {\n            assert_eq!(ceiling_root, root + T::ONE);\n        }\n        assert!(pow <= n);\n        if exp != 1\n            && let Some(next_pow) = (root + T::ONE).checked_pow(exp)\n        {\n            assert!(next_pow > n);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.floor_root(2), n.floor_sqrt());\n        assert_eq!(n.floor_root(1), n);\n\n        let cbrt = n.floor_root(3);\n        let mut n_alt = n;\n        n_alt.floor_root_assign(3);\n        assert_eq!(n_alt, cbrt);\n        assert_eq!(floor_root_binary(n, 3), cbrt);\n        let cube = cbrt.pow(3);\n        let ceiling_cbrt = n.ceiling_root(3);\n        if cube == n {\n            assert_eq!(ceiling_cbrt, cbrt);\n        } else {\n            assert_eq!(ceiling_cbrt, cbrt + T::ONE);\n        }\n        assert!(cube <= n);\n        if let Some(next_cube) = (cbrt + T::ONE).checked_pow(3) {\n            assert!(next_cube > n);\n        }\n    });\n}\n\nfn floor_root_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_18::<T, u64>().test_properties(|(n, exp)| {\n        let root = n.floor_root(exp);\n        let mut n_alt = n;\n        n_alt.floor_root_assign(exp);\n        assert_eq!(n_alt, root);\n        if let Some(pow) = root.checked_pow(exp) {\n            let ceiling_root = n.ceiling_root(exp);\n            if pow == n {\n                assert_eq!(ceiling_root, root);\n            } else {\n                assert_eq!(ceiling_root, root + T::ONE);\n            }\n            assert!(pow <= n);\n        }\n        if exp.odd() && n != T::MIN {\n            assert_eq!(-(-n).ceiling_root(exp), root);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.floor_root(1), n);\n\n        let cbrt = n.floor_root(3);\n        let mut n_alt = n;\n        n_alt.floor_root_assign(3);\n        assert_eq!(n_alt, cbrt);\n        if let Some(cube) = cbrt.checked_pow(3) {\n            let ceiling_cbrt = n.ceiling_root(3);\n            if cube == n {\n                assert_eq!(ceiling_cbrt, cbrt);\n            } else {\n                assert_eq!(ceiling_cbrt, cbrt + T::ONE);\n            }\n            assert!(cube <= n);\n        }\n        if n != T::MIN {\n            assert_ne!((-n).ceiling_root(3), T::MIN);\n            assert_eq!(-(-n).ceiling_root(3), cbrt);\n        }\n    });\n\n    signed_gen_var_2::<T>().test_properties(|n| {\n        assert_eq!(n.floor_root(2), n.floor_sqrt());\n    });\n}\n\nmacro_rules! floor_root_approx_and_refine_helper {\n    ($t:ty) => {\n        #[allow(clippy::cast_lossless)]\n        unsigned_pair_gen_var_32::<$t, u64>().test_properties(|(n, exp)| {\n            assert_eq!(\n                floor_root_approx_and_refine(|x| x as f64, |f| f as $t, n, exp),\n                n.floor_root(exp),\n            );\n        });\n\n        #[allow(clippy::cast_lossless)]\n        unsigned_gen::<$t>().test_properties(|n| {\n            assert_eq!(\n                floor_root_approx_and_refine(|x| x as f64, |f| f as $t, n, 3),\n                n.floor_root(3),\n            );\n        });\n    };\n}\n\n#[test]\nfn floor_root_properties() {\n    apply_fn_to_unsigneds!(floor_root_properties_helper_unsigned);\n    apply_fn_to_signeds!(floor_root_properties_helper_signed);\n\n    unsigned_gen_var_1::<u32>().test_properties(|n| {\n        assert_eq!(cbrt_chebyshev_approx_u32(n), n.floor_root(3));\n        assert_eq!(fast_floor_cbrt_u32(n), n.floor_root(3));\n    });\n\n    unsigned_gen_var_1::<u64>().test_properties(|n| {\n        assert_eq!(cbrt_chebyshev_approx_u64(n), n.floor_root(3));\n        assert_eq!(fast_floor_cbrt_u64(n), n.floor_root(3));\n    });\n\n    unsigned_pair_gen_var_32::<u32, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_floor_root_u32(n, exp), n.floor_root(exp));\n    });\n\n    unsigned_pair_gen_var_32::<u64, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_floor_root_u64(n, exp), n.floor_root(exp));\n    });\n\n    apply_to_unsigneds!(floor_root_approx_and_refine_helper);\n}\n\nfn ceiling_root_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_32::<T, u64>().test_properties(|(n, exp)| {\n        let root = n.ceiling_root(exp);\n        let mut n_alt = n;\n        n_alt.ceiling_root_assign(exp);\n        assert_eq!(n_alt, root);\n        assert_eq!(ceiling_root_binary(n, exp), root);\n        if let Some(pow) = root.checked_pow(exp) {\n            let floor_root = n.floor_root(exp);\n            if pow == n {\n                assert_eq!(floor_root, root);\n            } else {\n                assert_eq!(floor_root, root - T::ONE);\n            }\n            assert!(pow >= n);\n        }\n        if exp != 1 && n != T::ZERO {\n            assert!((root - T::ONE).pow(exp) < n);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.ceiling_root(2), n.ceiling_sqrt());\n        assert_eq!(n.ceiling_root(1), n);\n\n        let cbrt = n.ceiling_root(3);\n        let mut n_alt = n;\n        n_alt.ceiling_root_assign(3);\n        assert_eq!(n_alt, cbrt);\n        assert_eq!(ceiling_root_binary(n, 3), cbrt);\n        if let Some(cube) = cbrt.checked_pow(3) {\n            let floor_cbrt = n.floor_root(3);\n            if cube == n {\n                assert_eq!(floor_cbrt, cbrt);\n            } else {\n                assert_eq!(floor_cbrt, cbrt - T::ONE);\n            }\n            assert!(cube >= n);\n        }\n        if n != T::ZERO {\n            assert!((cbrt - T::ONE).pow(3) < n);\n        }\n    });\n}\n\nfn ceiling_root_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_18::<T, u64>().test_properties(|(n, exp)| {\n        let root = n.ceiling_root(exp);\n        let mut n_alt = n;\n        n_alt.ceiling_root_assign(exp);\n        assert_eq!(n_alt, root);\n        if let Some(pow) = root.checked_pow(exp) {\n            let floor_root = n.floor_root(exp);\n            if pow == n {\n                assert_eq!(floor_root, root);\n            } else {\n                assert_eq!(floor_root, root - T::ONE);\n            }\n            assert!(pow >= n);\n        }\n        if exp.odd() && n != T::MIN {\n            assert_eq!(-(-n).floor_root(exp), root);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.ceiling_root(1), n);\n\n        let cbrt = n.ceiling_root(3);\n        let mut n_alt = n;\n        n_alt.ceiling_root_assign(3);\n        assert_eq!(n_alt, cbrt);\n        if let Some(cube) = cbrt.checked_pow(3) {\n            let floor_cbrt = n.floor_root(3);\n            if cube == n {\n                assert_eq!(floor_cbrt, cbrt);\n            } else {\n                assert_eq!(floor_cbrt, cbrt - T::ONE);\n            }\n            assert!(cube >= n);\n        }\n        if n != T::MIN {\n            assert_eq!(-(-n).floor_root(3), cbrt);\n        }\n    });\n\n    signed_gen_var_2::<T>().test_properties(|n| {\n        assert_eq!(n.ceiling_root(2), n.ceiling_sqrt());\n    });\n}\n\n#[test]\nfn ceiling_root_properties() {\n    apply_fn_to_unsigneds!(ceiling_root_properties_helper_unsigned);\n    apply_fn_to_signeds!(ceiling_root_properties_helper_signed);\n\n    unsigned_pair_gen_var_32::<u32, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_ceiling_root_u32(n, exp), n.ceiling_root(exp));\n    });\n\n    unsigned_pair_gen_var_32::<u64, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_ceiling_root_u64(n, exp), n.ceiling_root(exp));\n    });\n}\n\nfn checked_root_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_32::<T, u64>().test_properties(|(n, exp)| {\n        let root = n.checked_root(exp);\n        assert_eq!(checked_root_binary(n, exp), root);\n        if let Some(root) = root {\n            assert_eq!(root.pow(exp), n);\n            assert_eq!(n.floor_root(exp), root);\n            assert_eq!(n.ceiling_root(exp), root);\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.checked_root(2), n.checked_sqrt());\n        assert_eq!(n.checked_root(1), Some(n));\n\n        let cbrt = n.checked_root(3);\n        assert_eq!(checked_root_binary(n, 3), cbrt);\n        if let Some(cbrt) = cbrt {\n            assert_eq!(cbrt.pow(3), n);\n            assert_eq!(n.floor_root(3), cbrt);\n            assert_eq!(n.ceiling_root(3), cbrt);\n        }\n    });\n}\n\nfn checked_root_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_18::<T, u64>().test_properties(|(n, exp)| {\n        let root = n.checked_root(exp);\n        if let Some(root) = root {\n            assert_eq!(root.pow(exp), n);\n            assert_eq!(n.floor_root(exp), root);\n            assert_eq!(n.ceiling_root(exp), root);\n        }\n        if exp.odd() && n != T::MIN {\n            assert_eq!((-n).checked_root(exp).map(Neg::neg), root);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        assert_eq!(n.checked_root(1), Some(n));\n\n        let cbrt = n.checked_root(3);\n        if let Some(cbrt) = cbrt {\n            assert_eq!(cbrt.pow(3), n);\n            assert_eq!(n.floor_root(3), cbrt);\n            assert_eq!(n.ceiling_root(3), cbrt);\n        }\n        if n != T::MIN {\n            assert_eq!((-n).checked_root(3).map(Neg::neg), cbrt);\n        }\n    });\n\n    signed_gen_var_2::<T>().test_properties(|n| {\n        assert_eq!(n.checked_root(2), n.checked_sqrt());\n    });\n}\n\n#[test]\nfn checked_root_properties() {\n    apply_fn_to_unsigneds!(checked_root_properties_helper_unsigned);\n    apply_fn_to_signeds!(checked_root_properties_helper_signed);\n\n    unsigned_pair_gen_var_32::<u32, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_checked_root_u32(n, exp), n.checked_root(exp));\n    });\n\n    unsigned_pair_gen_var_32::<u64, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_checked_root_u64(n, exp), n.checked_root(exp));\n    });\n}\n\nfn root_rem_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_32::<T, u64>().test_properties(|(n, exp)| {\n        let (root, rem) = n.root_rem(exp);\n        let mut n_alt = n;\n        assert_eq!(n_alt.root_assign_rem(exp), rem);\n        assert_eq!(n_alt, root);\n        assert_eq!(root_rem_binary(n, exp), (root, rem));\n        assert_eq!(n.floor_root(exp), root);\n        assert_eq!(root.pow(exp) + rem, n);\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(n.root_rem(2), n.sqrt_rem());\n        assert_eq!(n.root_rem(1), (n, T::ZERO));\n\n        let (cbrt, rem) = n.root_rem(3);\n        let mut n_alt = n;\n        assert_eq!(n_alt.root_assign_rem(3), rem);\n        assert_eq!(n_alt, cbrt);\n        assert_eq!(root_rem_binary(n, 3), (cbrt, rem));\n        assert_eq!(n.floor_root(3), cbrt);\n        assert_eq!(cbrt.pow(3) + rem, n);\n    });\n}\n\n#[test]\nfn root_rem_properties() {\n    apply_fn_to_unsigneds!(root_rem_properties_helper);\n\n    unsigned_pair_gen_var_32::<u32, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_root_rem_u32(n, exp), n.root_rem(exp));\n    });\n\n    unsigned_pair_gen_var_32::<u64, u64>().test_properties(|(n, exp)| {\n        assert_eq!(fast_root_rem_u64(n, exp), n.root_rem(exp));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/rotate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegMod;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen, unsigned_gen, unsigned_pair_gen,\n};\n\n#[test]\nfn test_rotate_left() {\n    fn test<T: PrimitiveInt>(x: T, n: u64, out: T) {\n        assert_eq!(x.rotate_left(n), out);\n\n        let mut x = x;\n        x.rotate_left_assign(n);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, 0);\n    test::<u8>(100, 0, 100);\n    test::<u16>(0xabcd, 0, 0xabcd);\n    test::<u16>(0xabcd, 4, 0xbcda);\n    test::<u16>(0xabcd, 8, 0xcdab);\n    test::<u16>(0xabcd, 12, 0xdabc);\n    test::<u16>(0xabcd, 16, 0xabcd);\n    test::<u16>(0xabcd, 160, 0xabcd);\n    test::<i8>(10, 0, 10);\n    test::<i8>(10, 1, 20);\n    test::<i8>(10, 2, 40);\n    test::<i8>(10, 3, 80);\n    test::<i8>(10, 4, -96);\n    test::<i8>(10, 5, 65);\n    test::<i8>(10, 6, -126);\n    test::<i8>(10, 7, 5);\n    test::<i8>(10, 8, 10);\n}\n\n#[test]\nfn test_rotate_right() {\n    fn test<T: PrimitiveInt>(x: T, n: u64, out: T) {\n        assert_eq!(x.rotate_right(n), out);\n\n        let mut x = x;\n        x.rotate_right_assign(n);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, 0);\n    test::<u8>(100, 0, 100);\n    test::<u16>(0xabcd, 0, 0xabcd);\n    test::<u16>(0xabcd, 4, 0xdabc);\n    test::<u16>(0xabcd, 8, 0xcdab);\n    test::<u16>(0xabcd, 12, 0xbcda);\n    test::<u16>(0xabcd, 16, 0xabcd);\n    test::<u16>(0xabcd, 160, 0xabcd);\n    test::<i8>(10, 0, 10);\n    test::<i8>(10, 1, 5);\n    test::<i8>(10, 2, -126);\n    test::<i8>(10, 3, 65);\n    test::<i8>(10, 4, -96);\n    test::<i8>(10, 5, 80);\n    test::<i8>(10, 6, 40);\n    test::<i8>(10, 7, 20);\n    test::<i8>(10, 8, 10);\n}\n\nfn rotate_left_properties_unsigned_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen::<T, u64>().test_properties(|(x, n)| {\n        let rotated = x.rotate_left(n);\n        let mut mut_x = x;\n        mut_x.rotate_left_assign(n);\n        assert_eq!(mut_x, rotated);\n        if let Some(m) = n.checked_add(T::WIDTH) {\n            assert_eq!(x.rotate_left(m), rotated);\n        }\n        assert_eq!(x.rotate_left(n & T::WIDTH_MASK), rotated);\n        assert_eq!(x.rotate_right(n.neg_mod(T::WIDTH)), rotated);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.rotate_left(0), x);\n        assert_eq!(x.rotate_left(T::WIDTH), x);\n    });\n\n    unsigned_gen::<u64>().test_properties(|n| {\n        assert_eq!(T::ZERO.rotate_left(n), T::ZERO);\n        assert_eq!(T::MAX.rotate_left(n), T::MAX);\n    });\n}\n\nfn rotate_left_properties_signed_helper<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen::<T, u64>().test_properties(|(x, n)| {\n        let rotated = x.rotate_left(n);\n        let mut mut_x = x;\n        mut_x.rotate_left_assign(n);\n        assert_eq!(mut_x, rotated);\n        if let Some(m) = n.checked_add(T::WIDTH) {\n            assert_eq!(x.rotate_left(m), rotated);\n        }\n        assert_eq!(x.rotate_left(n & T::WIDTH_MASK), rotated);\n        assert_eq!(x.rotate_right(n.neg_mod(T::WIDTH)), rotated);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.rotate_left(0), x);\n        assert_eq!(x.rotate_left(T::WIDTH), x);\n    });\n\n    unsigned_gen::<u64>().test_properties(|n| {\n        assert_eq!(T::ZERO.rotate_left(n), T::ZERO);\n        assert_eq!(T::NEGATIVE_ONE.rotate_left(n), T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\nfn rotate_left_properties() {\n    apply_fn_to_unsigneds!(rotate_left_properties_unsigned_helper);\n    apply_fn_to_signeds!(rotate_left_properties_signed_helper);\n}\n\nfn rotate_right_properties_unsigned_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen::<T, u64>().test_properties(|(x, n)| {\n        let rotated = x.rotate_right(n);\n        let mut mut_x = x;\n        mut_x.rotate_right_assign(n);\n        assert_eq!(mut_x, rotated);\n        if let Some(m) = n.checked_add(T::WIDTH) {\n            assert_eq!(x.rotate_right(m), rotated);\n        }\n        assert_eq!(x.rotate_right(n & T::WIDTH_MASK), rotated);\n        assert_eq!(x.rotate_left(n.neg_mod(T::WIDTH)), rotated);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.rotate_right(0), x);\n        assert_eq!(x.rotate_right(T::WIDTH), x);\n    });\n\n    unsigned_gen::<u64>().test_properties(|n| {\n        assert_eq!(T::ZERO.rotate_right(n), T::ZERO);\n        assert_eq!(T::MAX.rotate_right(n), T::MAX);\n    });\n}\n\nfn rotate_right_properties_signed_helper<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen::<T, u64>().test_properties(|(x, n)| {\n        let rotated = x.rotate_right(n);\n        let mut mut_x = x;\n        mut_x.rotate_right_assign(n);\n        assert_eq!(mut_x, rotated);\n        if let Some(m) = n.checked_add(T::WIDTH) {\n            assert_eq!(x.rotate_right(m), rotated);\n        }\n        assert_eq!(x.rotate_right(n & T::WIDTH_MASK), rotated);\n        assert_eq!(x.rotate_left(n.neg_mod(T::WIDTH)), rotated);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.rotate_right(0), x);\n        assert_eq!(x.rotate_right(T::WIDTH), x);\n    });\n\n    unsigned_gen::<u64>().test_properties(|n| {\n        assert_eq!(T::ZERO.rotate_right(n), T::ZERO);\n        assert_eq!(T::NEGATIVE_ONE.rotate_right(n), T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\nfn rotate_right_properties() {\n    apply_fn_to_unsigneds!(rotate_right_properties_unsigned_helper);\n    apply_fn_to_signeds!(rotate_right_properties_signed_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_pair_gen_var_5, signed_rounding_mode_pair_gen,\n    signed_signed_rounding_mode_triple_gen_var_2, unsigned_pair_gen_var_13,\n    unsigned_pair_gen_var_27, unsigned_rounding_mode_pair_gen,\n    unsigned_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_round_to_multiple_unsigned() {\n    fn test<T: PrimitiveUnsigned>(n: T, d: T, rm: RoundingMode, q: T, o: Ordering) {\n        assert_eq!(n.round_to_multiple(d, rm), (q, o));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.round_to_multiple_assign(d, rm), o);\n        assert_eq!(mut_n, q);\n    }\n    test::<u8>(0, 1, Down, 0, Equal);\n    test::<u8>(0, 1, Floor, 0, Equal);\n    test::<u8>(0, 1, Up, 0, Equal);\n    test::<u8>(0, 1, Ceiling, 0, Equal);\n    test::<u8>(0, 1, Nearest, 0, Equal);\n    test::<u8>(0, 1, Exact, 0, Equal);\n\n    test::<u16>(0, 123, Down, 0, Equal);\n    test::<u16>(0, 123, Floor, 0, Equal);\n    test::<u16>(0, 123, Up, 0, Equal);\n    test::<u16>(0, 123, Ceiling, 0, Equal);\n    test::<u16>(0, 123, Nearest, 0, Equal);\n    test::<u16>(0, 123, Exact, 0, Equal);\n\n    test::<u32>(1, 1, Down, 1, Equal);\n    test::<u32>(1, 1, Floor, 1, Equal);\n    test::<u32>(1, 1, Up, 1, Equal);\n    test::<u32>(1, 1, Ceiling, 1, Equal);\n    test::<u32>(1, 1, Nearest, 1, Equal);\n    test::<u32>(1, 1, Exact, 1, Equal);\n\n    test::<u64>(123, 1, Down, 123, Equal);\n    test::<u64>(123, 1, Floor, 123, Equal);\n    test::<u64>(123, 1, Up, 123, Equal);\n    test::<u64>(123, 1, Ceiling, 123, Equal);\n    test::<u64>(123, 1, Nearest, 123, Equal);\n    test::<u64>(123, 1, Exact, 123, Equal);\n\n    test::<u128>(123, 2, Down, 122, Less);\n    test::<u128>(123, 2, Floor, 122, Less);\n    test::<u128>(123, 2, Up, 124, Greater);\n    test::<u128>(123, 2, Ceiling, 124, Greater);\n    test::<u128>(123, 2, Nearest, 124, Greater);\n\n    test::<usize>(125, 2, Down, 124, Less);\n    test::<usize>(125, 2, Floor, 124, Less);\n    test::<usize>(125, 2, Up, 126, Greater);\n    test::<usize>(125, 2, Ceiling, 126, Greater);\n    test::<usize>(125, 2, Nearest, 124, Less);\n\n    test::<u8>(123, 123, Down, 123, Equal);\n    test::<u8>(123, 123, Floor, 123, Equal);\n    test::<u8>(123, 123, Up, 123, Equal);\n    test::<u8>(123, 123, Ceiling, 123, Equal);\n    test::<u8>(123, 123, Nearest, 123, Equal);\n    test::<u8>(123, 123, Exact, 123, Equal);\n\n    test::<u16>(123, 456, Down, 0, Less);\n    test::<u16>(123, 456, Floor, 0, Less);\n    test::<u16>(123, 456, Up, 456, Greater);\n    test::<u16>(123, 456, Ceiling, 456, Greater);\n    test::<u16>(123, 456, Nearest, 0, Less);\n\n    test::<u64>(1000000000000, 1, Down, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Floor, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Up, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Ceiling, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Nearest, 1000000000000, Equal);\n    test::<u64>(1000000000000, 1, Exact, 1000000000000, Equal);\n\n    test::<u64>(1000000000000, 3, Down, 999999999999, Less);\n    test::<u64>(1000000000000, 3, Floor, 999999999999, Less);\n    test::<u64>(1000000000000, 3, Up, 1000000000002, Greater);\n    test::<u64>(1000000000000, 3, Ceiling, 1000000000002, Greater);\n    test::<u64>(1000000000000, 3, Nearest, 999999999999, Less);\n\n    test::<u64>(999999999999, 2, Down, 999999999998, Less);\n    test::<u64>(999999999999, 2, Floor, 999999999998, Less);\n    test::<u64>(999999999999, 2, Up, 1000000000000, Greater);\n    test::<u64>(999999999999, 2, Ceiling, 1000000000000, Greater);\n    test::<u64>(999999999999, 2, Nearest, 1000000000000, Greater);\n\n    test::<u64>(1000000000001, 2, Down, 1000000000000, Less);\n    test::<u64>(1000000000001, 2, Floor, 1000000000000, Less);\n    test::<u64>(1000000000001, 2, Up, 1000000000002, Greater);\n    test::<u64>(1000000000001, 2, Ceiling, 1000000000002, Greater);\n    test::<u64>(1000000000001, 2, Nearest, 1000000000000, Less);\n\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Down,\n        999999999999996832276305,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Floor,\n        999999999999996832276305,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Up,\n        1000000000000001127243600,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Ceiling,\n        1000000000000001127243600,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Nearest,\n        1000000000000001127243600,\n        Greater,\n    );\n\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Down,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Floor,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Up,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Ceiling,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Nearest,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000000,\n        Exact,\n        1000000000000000000000000,\n        Equal,\n    );\n\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Down,\n        999999999999999999999999,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Floor,\n        999999999999999999999999,\n        Less,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Up,\n        1000000000001000000000000,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Ceiling,\n        1000000000001000000000000,\n        Greater,\n    );\n    test::<u128>(\n        1000000000000000000000000,\n        1000000000001,\n        Nearest,\n        999999999999999999999999,\n        Less,\n    );\n\n    test::<u128>(\n        2999999999999999999999999,\n        2000000000000000000000000,\n        Nearest,\n        2000000000000000000000000,\n        Less,\n    );\n    test::<u128>(\n        3000000000000000000000000,\n        2000000000000000000000000,\n        Nearest,\n        4000000000000000000000000,\n        Greater,\n    );\n    test::<u128>(\n        3000000000000000000000001,\n        2000000000000000000000000,\n        Nearest,\n        4000000000000000000000000,\n        Greater,\n    );\n\n    test::<u8>(0, 0, Floor, 0, Equal);\n    test::<u16>(0, 0, Ceiling, 0, Equal);\n    test::<u32>(0, 0, Down, 0, Equal);\n    test::<u64>(0, 0, Up, 0, Equal);\n    test::<u128>(0, 0, Nearest, 0, Equal);\n    test::<usize>(0, 0, Exact, 0, Equal);\n\n    test::<u8>(2, 0, Floor, 0, Less);\n    test::<u16>(2, 0, Down, 0, Less);\n    test::<u32>(2, 0, Nearest, 0, Less);\n}\n\n#[test]\nfn test_round_to_multiple_signed() {\n    fn test<T: PrimitiveSigned>(n: T, d: T, rm: RoundingMode, q: T, o: Ordering) {\n        assert_eq!(n.round_to_multiple(d, rm), (q, o));\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.round_to_multiple_assign(d, rm), o);\n        assert_eq!(mut_n, q);\n    }\n    test::<i8>(0, 1, Down, 0, Equal);\n    test::<i8>(0, 1, Floor, 0, Equal);\n    test::<i8>(0, 1, Up, 0, Equal);\n    test::<i8>(0, 1, Ceiling, 0, Equal);\n    test::<i8>(0, 1, Nearest, 0, Equal);\n    test::<i8>(0, 1, Exact, 0, Equal);\n\n    test::<i16>(0, 123, Down, 0, Equal);\n    test::<i16>(0, 123, Floor, 0, Equal);\n    test::<i16>(0, 123, Up, 0, Equal);\n    test::<i16>(0, 123, Ceiling, 0, Equal);\n    test::<i16>(0, 123, Nearest, 0, Equal);\n    test::<i16>(0, 123, Exact, 0, Equal);\n\n    test::<i32>(1, 1, Down, 1, Equal);\n    test::<i32>(1, 1, Floor, 1, Equal);\n    test::<i32>(1, 1, Up, 1, Equal);\n    test::<i32>(1, 1, Ceiling, 1, Equal);\n    test::<i32>(1, 1, Nearest, 1, Equal);\n    test::<i32>(1, 1, Exact, 1, Equal);\n\n    test::<i64>(123, 1, Down, 123, Equal);\n    test::<i64>(123, 1, Floor, 123, Equal);\n    test::<i64>(123, 1, Up, 123, Equal);\n    test::<i64>(123, 1, Ceiling, 123, Equal);\n    test::<i64>(123, 1, Nearest, 123, Equal);\n    test::<i64>(123, 1, Exact, 123, Equal);\n\n    test::<i128>(123, 2, Down, 122, Less);\n    test::<i128>(123, 2, Floor, 122, Less);\n    test::<i128>(123, 2, Up, 124, Greater);\n    test::<i128>(123, 2, Ceiling, 124, Greater);\n    test::<i128>(123, 2, Nearest, 124, Greater);\n\n    test::<isize>(125, 2, Down, 124, Less);\n    test::<isize>(125, 2, Floor, 124, Less);\n    test::<isize>(125, 2, Up, 126, Greater);\n    test::<isize>(125, 2, Ceiling, 126, Greater);\n    test::<isize>(125, 2, Nearest, 124, Less);\n\n    test::<i8>(123, 123, Down, 123, Equal);\n    test::<i8>(123, 123, Floor, 123, Equal);\n    test::<i8>(123, 123, Up, 123, Equal);\n    test::<i8>(123, 123, Ceiling, 123, Equal);\n    test::<i8>(123, 123, Nearest, 123, Equal);\n    test::<i8>(123, 123, Exact, 123, Equal);\n\n    test::<i16>(123, 456, Down, 0, Less);\n    test::<i16>(123, 456, Floor, 0, Less);\n    test::<i16>(123, 456, Up, 456, Greater);\n    test::<i16>(123, 456, Ceiling, 456, Greater);\n    test::<i16>(123, 456, Nearest, 0, Less);\n\n    test::<i64>(1000000000000, 1, Down, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Floor, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Up, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Ceiling, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Nearest, 1000000000000, Equal);\n    test::<i64>(1000000000000, 1, Exact, 1000000000000, Equal);\n\n    test::<i64>(1000000000000, 3, Down, 999999999999, Less);\n    test::<i64>(1000000000000, 3, Floor, 999999999999, Less);\n    test::<i64>(1000000000000, 3, Up, 1000000000002, Greater);\n    test::<i64>(1000000000000, 3, Ceiling, 1000000000002, Greater);\n    test::<i64>(1000000000000, 3, Nearest, 999999999999, Less);\n\n    test::<i64>(999999999999, 2, Down, 999999999998, Less);\n    test::<i64>(999999999999, 2, Floor, 999999999998, Less);\n    test::<i64>(999999999999, 2, Up, 1000000000000, Greater);\n    test::<i64>(999999999999, 2, Ceiling, 1000000000000, Greater);\n    test::<i64>(999999999999, 2, Nearest, 1000000000000, Greater);\n\n    test::<i64>(1000000000001, 2, Down, 1000000000000, Less);\n    test::<i64>(1000000000001, 2, Floor, 1000000000000, Less);\n    test::<i64>(1000000000001, 2, Up, 1000000000002, Greater);\n    test::<i64>(1000000000001, 2, Ceiling, 1000000000002, Greater);\n    test::<i64>(1000000000001, 2, Nearest, 1000000000000, Less);\n\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Down,\n        999999999999996832276305,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Floor,\n        999999999999996832276305,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Up,\n        1000000000000001127243600,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Ceiling,\n        1000000000000001127243600,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        0xffffffff,\n        Nearest,\n        1000000000000001127243600,\n        Greater,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Down,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Floor,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Up,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Ceiling,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Nearest,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Exact,\n        1000000000000000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Down,\n        999999999999999999999999,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Floor,\n        999999999999999999999999,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Up,\n        1000000000001000000000000,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Ceiling,\n        1000000000001000000000000,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000001,\n        Nearest,\n        999999999999999999999999,\n        Less,\n    );\n\n    test::<i128>(\n        2999999999999999999999999,\n        2000000000000000000000000,\n        Nearest,\n        2000000000000000000000000,\n        Less,\n    );\n    test::<i128>(\n        3000000000000000000000000,\n        2000000000000000000000000,\n        Nearest,\n        4000000000000000000000000,\n        Greater,\n    );\n    test::<i128>(\n        3000000000000000000000001,\n        2000000000000000000000000,\n        Nearest,\n        4000000000000000000000000,\n        Greater,\n    );\n\n    test::<i8>(0, -1, Down, 0, Equal);\n    test::<i8>(0, -1, Floor, 0, Equal);\n    test::<i8>(0, -1, Up, 0, Equal);\n    test::<i8>(0, -1, Ceiling, 0, Equal);\n    test::<i8>(0, -1, Nearest, 0, Equal);\n    test::<i8>(0, -1, Exact, 0, Equal);\n\n    test::<i16>(0, -123, Down, 0, Equal);\n    test::<i16>(0, -123, Floor, 0, Equal);\n    test::<i16>(0, -123, Up, 0, Equal);\n    test::<i16>(0, -123, Ceiling, 0, Equal);\n    test::<i16>(0, -123, Nearest, 0, Equal);\n    test::<i16>(0, -123, Exact, 0, Equal);\n\n    test::<i32>(1, -1, Down, 1, Equal);\n    test::<i32>(1, -1, Floor, 1, Equal);\n    test::<i32>(1, -1, Up, 1, Equal);\n    test::<i32>(1, -1, Ceiling, 1, Equal);\n    test::<i32>(1, -1, Nearest, 1, Equal);\n    test::<i32>(1, -1, Exact, 1, Equal);\n\n    test::<i64>(123, -1, Down, 123, Equal);\n    test::<i64>(123, -1, Floor, 123, Equal);\n    test::<i64>(123, -1, Up, 123, Equal);\n    test::<i64>(123, -1, Ceiling, 123, Equal);\n    test::<i64>(123, -1, Nearest, 123, Equal);\n    test::<i64>(123, -1, Exact, 123, Equal);\n\n    test::<i128>(123, -2, Down, 122, Less);\n    test::<i128>(123, -2, Floor, 122, Less);\n    test::<i128>(123, -2, Up, 124, Greater);\n    test::<i128>(123, -2, Ceiling, 124, Greater);\n    test::<i128>(123, -2, Nearest, 124, Greater);\n\n    test::<isize>(125, -2, Down, 124, Less);\n    test::<isize>(125, -2, Floor, 124, Less);\n    test::<isize>(125, -2, Up, 126, Greater);\n    test::<isize>(125, -2, Ceiling, 126, Greater);\n    test::<isize>(125, -2, Nearest, 124, Less);\n\n    test::<i8>(123, -123, Down, 123, Equal);\n    test::<i8>(123, -123, Floor, 123, Equal);\n    test::<i8>(123, -123, Up, 123, Equal);\n    test::<i8>(123, -123, Ceiling, 123, Equal);\n    test::<i8>(123, -123, Nearest, 123, Equal);\n    test::<i8>(123, -123, Exact, 123, Equal);\n\n    test::<i16>(123, -456, Down, 0, Less);\n    test::<i16>(123, -456, Floor, 0, Less);\n    test::<i16>(123, -456, Up, 456, Greater);\n    test::<i16>(123, -456, Ceiling, 456, Greater);\n    test::<i16>(123, -456, Nearest, 0, Less);\n\n    test::<i64>(1000000000000, -1, Down, 1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Floor, 1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Up, 1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Ceiling, 1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Nearest, 1000000000000, Equal);\n    test::<i64>(1000000000000, -1, Exact, 1000000000000, Equal);\n\n    test::<i64>(1000000000000, -3, Down, 999999999999, Less);\n    test::<i64>(1000000000000, -3, Floor, 999999999999, Less);\n    test::<i64>(1000000000000, -3, Up, 1000000000002, Greater);\n    test::<i64>(1000000000000, -3, Ceiling, 1000000000002, Greater);\n    test::<i64>(1000000000000, -3, Nearest, 999999999999, Less);\n\n    test::<i64>(999999999999, -2, Down, 999999999998, Less);\n    test::<i64>(999999999999, -2, Floor, 999999999998, Less);\n    test::<i64>(999999999999, -2, Up, 1000000000000, Greater);\n    test::<i64>(999999999999, -2, Ceiling, 1000000000000, Greater);\n    test::<i64>(999999999999, -2, Nearest, 1000000000000, Greater);\n\n    test::<i64>(1000000000001, -2, Down, 1000000000000, Less);\n    test::<i64>(1000000000001, -2, Floor, 1000000000000, Less);\n    test::<i64>(1000000000001, -2, Up, 1000000000002, Greater);\n    test::<i64>(1000000000001, -2, Ceiling, 1000000000002, Greater);\n    test::<i64>(1000000000001, -2, Nearest, 1000000000000, Less);\n\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Down,\n        999999999999996832276305,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Floor,\n        999999999999996832276305,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Up,\n        1000000000000001127243600,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Ceiling,\n        1000000000000001127243600,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -0xffffffff,\n        Nearest,\n        1000000000000001127243600,\n        Greater,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Down,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Floor,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Up,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000000,\n        Ceiling,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Nearest,\n        1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        1000000000000,\n        Exact,\n        1000000000000000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Down,\n        999999999999999999999999,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Floor,\n        999999999999999999999999,\n        Less,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Up,\n        1000000000001000000000000,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Ceiling,\n        1000000000001000000000000,\n        Greater,\n    );\n    test::<i128>(\n        1000000000000000000000000,\n        -1000000000001,\n        Nearest,\n        999999999999999999999999,\n        Less,\n    );\n\n    test::<i128>(\n        2999999999999999999999999,\n        -2000000000000000000000000,\n        Nearest,\n        2000000000000000000000000,\n        Less,\n    );\n    test::<i128>(\n        3000000000000000000000000,\n        -2000000000000000000000000,\n        Nearest,\n        4000000000000000000000000,\n        Greater,\n    );\n    test::<i128>(\n        3000000000000000000000001,\n        -2000000000000000000000000,\n        Nearest,\n        4000000000000000000000000,\n        Greater,\n    );\n\n    test::<i32>(-1, 1, Down, -1, Equal);\n    test::<i32>(-1, 1, Floor, -1, Equal);\n    test::<i32>(-1, 1, Up, -1, Equal);\n    test::<i32>(-1, 1, Ceiling, -1, Equal);\n    test::<i32>(-1, 1, Nearest, -1, Equal);\n    test::<i32>(-1, 1, Exact, -1, Equal);\n\n    test::<i64>(-123, 1, Down, -123, Equal);\n    test::<i64>(-123, 1, Floor, -123, Equal);\n    test::<i64>(-123, 1, Up, -123, Equal);\n    test::<i64>(-123, 1, Ceiling, -123, Equal);\n    test::<i64>(-123, 1, Nearest, -123, Equal);\n    test::<i64>(-123, 1, Exact, -123, Equal);\n\n    test::<i128>(-123, 2, Down, -122, Greater);\n    test::<i128>(-123, 2, Floor, -124, Less);\n    test::<i128>(-123, 2, Up, -124, Less);\n    test::<i128>(-123, 2, Ceiling, -122, Greater);\n    test::<i128>(-123, 2, Nearest, -124, Less);\n\n    test::<isize>(-125, 2, Down, -124, Greater);\n    test::<isize>(-125, 2, Floor, -126, Less);\n    test::<isize>(-125, 2, Up, -126, Less);\n    test::<isize>(-125, 2, Ceiling, -124, Greater);\n    test::<isize>(-125, 2, Nearest, -124, Greater);\n\n    test::<i8>(-123, 123, Down, -123, Equal);\n    test::<i8>(-123, 123, Floor, -123, Equal);\n    test::<i8>(-123, 123, Up, -123, Equal);\n    test::<i8>(-123, 123, Ceiling, -123, Equal);\n    test::<i8>(-123, 123, Nearest, -123, Equal);\n    test::<i8>(-123, 123, Exact, -123, Equal);\n\n    test::<i16>(-123, 456, Down, 0, Greater);\n    test::<i16>(-123, 456, Floor, -456, Less);\n    test::<i16>(-123, 456, Up, -456, Less);\n    test::<i16>(-123, 456, Ceiling, 0, Greater);\n    test::<i16>(-123, 456, Nearest, 0, Greater);\n\n    test::<i64>(-1000000000000, 1, Down, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Floor, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Up, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Ceiling, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Nearest, -1000000000000, Equal);\n    test::<i64>(-1000000000000, 1, Exact, -1000000000000, Equal);\n\n    test::<i64>(-1000000000000, 3, Down, -999999999999, Greater);\n    test::<i64>(-1000000000000, 3, Floor, -1000000000002, Less);\n    test::<i64>(-1000000000000, 3, Up, -1000000000002, Less);\n    test::<i64>(-1000000000000, 3, Ceiling, -999999999999, Greater);\n    test::<i64>(-1000000000000, 3, Nearest, -999999999999, Greater);\n\n    test::<i64>(-999999999999, 2, Down, -999999999998, Greater);\n    test::<i64>(-999999999999, 2, Floor, -1000000000000, Less);\n    test::<i64>(-999999999999, 2, Up, -1000000000000, Less);\n    test::<i64>(-999999999999, 2, Ceiling, -999999999998, Greater);\n    test::<i64>(-999999999999, 2, Nearest, -1000000000000, Less);\n\n    test::<i64>(-1000000000001, 2, Down, -1000000000000, Greater);\n    test::<i64>(-1000000000001, 2, Floor, -1000000000002, Less);\n    test::<i64>(-1000000000001, 2, Up, -1000000000002, Less);\n    test::<i64>(-1000000000001, 2, Ceiling, -1000000000000, Greater);\n    test::<i64>(-1000000000001, 2, Nearest, -1000000000000, Greater);\n\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Down,\n        -999999999999996832276305,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Floor,\n        -1000000000000001127243600,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Up,\n        -1000000000000001127243600,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Ceiling,\n        -999999999999996832276305,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        0xffffffff,\n        Nearest,\n        -1000000000000001127243600,\n        Less,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Down,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Floor,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Up,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Ceiling,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Nearest,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000000,\n        Exact,\n        -1000000000000000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Down,\n        -999999999999999999999999,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Floor,\n        -1000000000001000000000000,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Up,\n        -1000000000001000000000000,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Ceiling,\n        -999999999999999999999999,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        1000000000001,\n        Nearest,\n        -999999999999999999999999,\n        Greater,\n    );\n\n    test::<i128>(\n        -2999999999999999999999999,\n        2000000000000000000000000,\n        Nearest,\n        -2000000000000000000000000,\n        Greater,\n    );\n    test::<i128>(\n        -3000000000000000000000000,\n        2000000000000000000000000,\n        Nearest,\n        -4000000000000000000000000,\n        Less,\n    );\n    test::<i128>(\n        -3000000000000000000000001,\n        2000000000000000000000000,\n        Nearest,\n        -4000000000000000000000000,\n        Less,\n    );\n\n    test::<i32>(-1, -1, Down, -1, Equal);\n    test::<i32>(-1, -1, Floor, -1, Equal);\n    test::<i32>(-1, -1, Up, -1, Equal);\n    test::<i32>(-1, -1, Ceiling, -1, Equal);\n    test::<i32>(-1, -1, Nearest, -1, Equal);\n    test::<i32>(-1, -1, Exact, -1, Equal);\n\n    test::<i64>(-123, -1, Down, -123, Equal);\n    test::<i64>(-123, -1, Floor, -123, Equal);\n    test::<i64>(-123, -1, Up, -123, Equal);\n    test::<i64>(-123, -1, Ceiling, -123, Equal);\n    test::<i64>(-123, -1, Nearest, -123, Equal);\n    test::<i64>(-123, -1, Exact, -123, Equal);\n\n    test::<i128>(-123, -2, Down, -122, Greater);\n    test::<i128>(-123, -2, Floor, -124, Less);\n    test::<i128>(-123, -2, Up, -124, Less);\n    test::<i128>(-123, -2, Ceiling, -122, Greater);\n    test::<i128>(-123, -2, Nearest, -124, Less);\n\n    test::<isize>(-125, -2, Down, -124, Greater);\n    test::<isize>(-125, -2, Floor, -126, Less);\n    test::<isize>(-125, -2, Up, -126, Less);\n    test::<isize>(-125, -2, Ceiling, -124, Greater);\n    test::<isize>(-125, -2, Nearest, -124, Greater);\n\n    test::<i8>(-123, -123, Down, -123, Equal);\n    test::<i8>(-123, -123, Floor, -123, Equal);\n    test::<i8>(-123, -123, Up, -123, Equal);\n    test::<i8>(-123, -123, Ceiling, -123, Equal);\n    test::<i8>(-123, -123, Nearest, -123, Equal);\n    test::<i8>(-123, -123, Exact, -123, Equal);\n\n    test::<i16>(-123, -456, Down, 0, Greater);\n    test::<i16>(-123, -456, Floor, -456, Less);\n    test::<i16>(-123, -456, Up, -456, Less);\n    test::<i16>(-123, -456, Ceiling, 0, Greater);\n    test::<i16>(-123, -456, Nearest, 0, Greater);\n\n    test::<i64>(-1000000000000, -1, Down, -1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Floor, -1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Up, -1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Ceiling, -1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Nearest, -1000000000000, Equal);\n    test::<i64>(-1000000000000, -1, Exact, -1000000000000, Equal);\n\n    test::<i64>(-1000000000000, -3, Down, -999999999999, Greater);\n    test::<i64>(-1000000000000, -3, Floor, -1000000000002, Less);\n    test::<i64>(-1000000000000, -3, Up, -1000000000002, Less);\n    test::<i64>(-1000000000000, -3, Ceiling, -999999999999, Greater);\n    test::<i64>(-1000000000000, -3, Nearest, -999999999999, Greater);\n\n    test::<i64>(-999999999999, -2, Down, -999999999998, Greater);\n    test::<i64>(-999999999999, -2, Floor, -1000000000000, Less);\n    test::<i64>(-999999999999, -2, Up, -1000000000000, Less);\n    test::<i64>(-999999999999, -2, Ceiling, -999999999998, Greater);\n    test::<i64>(-999999999999, -2, Nearest, -1000000000000, Less);\n\n    test::<i64>(-1000000000001, -2, Down, -1000000000000, Greater);\n    test::<i64>(-1000000000001, -2, Floor, -1000000000002, Less);\n    test::<i64>(-1000000000001, -2, Up, -1000000000002, Less);\n    test::<i64>(-1000000000001, -2, Ceiling, -1000000000000, Greater);\n    test::<i64>(-1000000000001, -2, Nearest, -1000000000000, Greater);\n\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Down,\n        -999999999999996832276305,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Floor,\n        -1000000000000001127243600,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Up,\n        -1000000000000001127243600,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Ceiling,\n        -999999999999996832276305,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -0xffffffff,\n        Nearest,\n        -1000000000000001127243600,\n        Less,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Down,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Floor,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Up,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Ceiling,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Nearest,\n        -1000000000000000000000000,\n        Equal,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000000,\n        Exact,\n        -1000000000000000000000000,\n        Equal,\n    );\n\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Down,\n        -999999999999999999999999,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Floor,\n        -1000000000001000000000000,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Up,\n        -1000000000001000000000000,\n        Less,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Ceiling,\n        -999999999999999999999999,\n        Greater,\n    );\n    test::<i128>(\n        -1000000000000000000000000,\n        -1000000000001,\n        Nearest,\n        -999999999999999999999999,\n        Greater,\n    );\n\n    test::<i128>(\n        -2999999999999999999999999,\n        -2000000000000000000000000,\n        Nearest,\n        -2000000000000000000000000,\n        Greater,\n    );\n    test::<i128>(\n        -3000000000000000000000000,\n        -2000000000000000000000000,\n        Nearest,\n        -4000000000000000000000000,\n        Less,\n    );\n    test::<i128>(\n        -3000000000000000000000001,\n        -2000000000000000000000000,\n        Nearest,\n        -4000000000000000000000000,\n        Less,\n    );\n\n    test::<i8>(-128, 1, Down, -128, Equal);\n    test::<i8>(-128, 1, Up, -128, Equal);\n    test::<i8>(-128, 1, Floor, -128, Equal);\n    test::<i8>(-128, 1, Ceiling, -128, Equal);\n    test::<i8>(-128, 1, Nearest, -128, Equal);\n    test::<i8>(-128, 1, Exact, -128, Equal);\n\n    test::<i8>(-128, -1, Down, -128, Equal);\n    test::<i8>(-128, -1, Up, -128, Equal);\n    test::<i8>(-128, -1, Floor, -128, Equal);\n    test::<i8>(-128, -1, Ceiling, -128, Equal);\n    test::<i8>(-128, -1, Nearest, -128, Equal);\n    test::<i8>(-128, -1, Exact, -128, Equal);\n\n    test::<i8>(-128, -128, Down, -128, Equal);\n    test::<i8>(-128, -128, Up, -128, Equal);\n    test::<i8>(-128, -128, Floor, -128, Equal);\n    test::<i8>(-128, -128, Ceiling, -128, Equal);\n    test::<i8>(-128, -128, Nearest, -128, Equal);\n    test::<i8>(-128, -128, Exact, -128, Equal);\n\n    test::<i8>(0, 0, Floor, 0, Equal);\n    test::<i16>(0, 0, Ceiling, 0, Equal);\n    test::<i32>(0, 0, Down, 0, Equal);\n    test::<i64>(0, 0, Up, 0, Equal);\n    test::<i128>(0, 0, Nearest, 0, Equal);\n    test::<isize>(0, 0, Exact, 0, Equal);\n\n    test::<i8>(2, 0, Floor, 0, Less);\n    test::<i16>(2, 0, Down, 0, Less);\n    test::<i32>(2, 0, Nearest, 0, Less);\n    test::<i64>(-2, 0, Ceiling, 0, Greater);\n    test::<i128>(-2, 0, Down, 0, Greater);\n    test::<isize>(-2, 0, Nearest, 0, Greater);\n}\n\nfn round_to_multiple_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::exact_from(10).round_to_multiple(T::ZERO, Up));\n    assert_panic!(T::exact_from(10).round_to_multiple(T::exact_from(3), Exact));\n    assert_panic!(T::MAX.round_to_multiple(T::TWO, Ceiling));\n    assert_panic!(T::ONE.round_to_multiple(T::ZERO, Up));\n    assert_panic!(T::ONE.round_to_multiple(T::ZERO, Ceiling));\n    assert_panic!(T::ONE.round_to_multiple(T::ZERO, Exact));\n\n    assert_panic!(T::exact_from(10).round_to_multiple_assign(T::ZERO, Up));\n    assert_panic!({\n        T::exact_from(10).round_to_multiple_assign(T::exact_from(3), Exact);\n    });\n    assert_panic!({\n        let mut n = T::MAX;\n        n.round_to_multiple_assign(T::TWO, Ceiling);\n    });\n    assert_panic!({\n        let mut n = T::ONE;\n        n.round_to_multiple_assign(T::ZERO, Up);\n    });\n    assert_panic!({\n        let mut n = T::ONE;\n        n.round_to_multiple_assign(T::ZERO, Ceiling);\n    });\n    assert_panic!({\n        let mut n = T::ONE;\n        n.round_to_multiple_assign(T::ZERO, Exact);\n    });\n}\n\nfn round_to_multiple_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::MIN.round_to_multiple(T::exact_from(3), Floor));\n    assert_panic!(T::NEGATIVE_ONE.round_to_multiple(T::ZERO, Up));\n    assert_panic!(T::NEGATIVE_ONE.round_to_multiple(T::ZERO, Floor));\n    assert_panic!(T::NEGATIVE_ONE.round_to_multiple(T::ZERO, Exact));\n\n    assert_panic!({\n        let mut n = T::MIN;\n        n.round_to_multiple_assign(T::exact_from(3), Floor);\n    });\n    assert_panic!({\n        let mut n = T::NEGATIVE_ONE;\n        n.round_to_multiple_assign(T::ZERO, Up);\n    });\n    assert_panic!({\n        let mut n = T::NEGATIVE_ONE;\n        n.round_to_multiple_assign(T::ZERO, Floor);\n    });\n    assert_panic!({\n        let mut n = T::NEGATIVE_ONE;\n        n.round_to_multiple_assign(T::ZERO, Exact);\n    });\n}\n\n#[test]\nfn round_to_multiple_fail() {\n    apply_fn_to_primitive_ints!(round_to_multiple_fail_helper);\n    apply_fn_to_signeds!(round_to_multiple_signed_fail_helper);\n}\n\nfn round_to_multiple_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_unsigned_rounding_mode_triple_gen_var_2::<T>().test_properties(|(x, y, rm)| {\n        let (rounded, o) = x.round_to_multiple(y, rm);\n\n        let mut mut_x = x;\n        assert_eq!(mut_x.round_to_multiple_assign(y, rm), o);\n        assert_eq!(mut_x, rounded);\n\n        assert!(rounded.divisible_by(y));\n        assert_eq!(rounded.cmp(&x), o);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n        match rm {\n            Floor | Down => {\n                assert!(rounded <= x);\n            }\n            Ceiling | Up => {\n                assert!(rounded >= x);\n            }\n            Exact => assert_eq!(rounded, x),\n            Nearest => {\n                if y == T::ZERO {\n                    assert_eq!(rounded, T::ZERO);\n                } else {\n                    let mut closest = None;\n                    let mut second_closest = None;\n                    if rounded <= x {\n                        if let Some(above) = rounded.checked_add(y) {\n                            closest = Some(x - rounded);\n                            second_closest = Some(above - x);\n                        }\n                    } else if let Some(below) = rounded.checked_sub(y) {\n                        closest = Some(rounded - x);\n                        second_closest = Some(x - below);\n                    }\n                    if let (Some(closest), Some(second_closest)) = (closest, second_closest) {\n                        assert!(closest <= second_closest);\n                        if closest == second_closest {\n                            assert!(rounded.div_exact(y).even());\n                        }\n                    }\n                }\n            }\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(x.round_to_multiple(y, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(x.round_to_multiple(y, Exact));\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        if let Some(product) = x.checked_mul(y) {\n            let xo = (product, Equal);\n            assert_eq!(product.round_to_multiple(y, Down), xo);\n            assert_eq!(product.round_to_multiple(y, Up), xo);\n            assert_eq!(product.round_to_multiple(y, Floor), xo);\n            assert_eq!(product.round_to_multiple(y, Ceiling), xo);\n            assert_eq!(product.round_to_multiple(y, Nearest), xo);\n            assert_eq!(product.round_to_multiple(y, Exact), xo);\n        }\n    });\n\n    unsigned_pair_gen_var_13::<T>().test_properties(|(x, y)| {\n        let down = x.round_to_multiple(y, Down);\n        assert_eq!(down.1, Less);\n        if let Some(up) = down.0.checked_add(y) {\n            let up = (up, Greater);\n            assert_eq!(x.round_to_multiple(y, Up), up);\n            assert_eq!(x.round_to_multiple(y, Floor), down);\n            assert_eq!(x.round_to_multiple(y, Ceiling), up);\n            let nearest = x.round_to_multiple(y, Nearest);\n            assert!(nearest == down || nearest == up);\n        }\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(n, rm)| {\n        if rm == Floor || rm == Down || rm == Nearest {\n            assert_eq!(\n                n.round_to_multiple(T::ZERO, rm),\n                (T::ZERO, if n == T::ZERO { Equal } else { Less })\n            );\n        }\n        assert_eq!(T::ZERO.round_to_multiple(n, rm), (T::ZERO, Equal));\n        assert_eq!(n.round_to_multiple(T::ONE, rm), (n, Equal));\n        assert_eq!(n.round_to_multiple(n, rm), (n, Equal));\n    });\n}\n\nfn round_to_multiple_properties_helper_signed<\n    U: PrimitiveUnsigned,\n    S: TryFrom<U> + ConvertibleFrom<U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>() {\n    signed_signed_rounding_mode_triple_gen_var_2::<U, S>().test_properties(|(x, y, rm)| {\n        let (rounded, o) = x.round_to_multiple(y, rm);\n\n        let mut mut_x = x;\n        assert_eq!(mut_x.round_to_multiple_assign(y, rm), o);\n        assert_eq!(mut_x, rounded);\n\n        assert!(rounded.divisible_by(y));\n        assert_eq!(rounded.cmp(&x), o);\n        match (x >= S::ZERO, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        match rm {\n            Floor => assert!(rounded <= x),\n            Ceiling => assert!(rounded >= x),\n            Down => assert!(rounded.le_abs(&x)),\n            Up => assert!(rounded.ge_abs(&x)),\n            Exact => assert_eq!(rounded, x),\n            Nearest => {\n                if y == S::ZERO {\n                    assert_eq!(rounded, S::ZERO);\n                } else {\n                    let mut closest = None;\n                    let mut second_closest = None;\n                    let (o_above, o_below) = if y >= S::ZERO {\n                        (rounded.checked_add(y), rounded.checked_sub(y))\n                    } else {\n                        (rounded.checked_sub(y), rounded.checked_add(y))\n                    };\n                    if rounded <= x {\n                        if let Some(above) = o_above {\n                            closest = x.checked_sub(rounded);\n                            second_closest = above.checked_sub(x);\n                        }\n                    } else if let Some(below) = o_below {\n                        closest = rounded.checked_sub(x);\n                        second_closest = x.checked_sub(below);\n                    }\n                    if let (Some(closest), Some(second_closest)) = (closest, second_closest) {\n                        assert!(closest <= second_closest);\n                        if closest == second_closest {\n                            assert!(rounded.div_exact(y).even());\n                        }\n                    }\n                }\n            }\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(x.round_to_multiple(y, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(x.round_to_multiple(y, Exact));\n        }\n    });\n\n    signed_pair_gen::<S>().test_properties(|(x, y)| {\n        if let Some(product) = x.checked_mul(y) {\n            let xo = (product, Equal);\n            assert_eq!(product.round_to_multiple(y, Down), xo);\n            assert_eq!(product.round_to_multiple(y, Up), xo);\n            assert_eq!(product.round_to_multiple(y, Floor), xo);\n            assert_eq!(product.round_to_multiple(y, Ceiling), xo);\n            assert_eq!(product.round_to_multiple(y, Nearest), xo);\n            assert_eq!(product.round_to_multiple(y, Exact), xo);\n        }\n    });\n\n    signed_pair_gen_var_5::<S>().test_properties(|(x, y)| {\n        let down = x.round_to_multiple(y, Down);\n        assert_eq!(down.1, if x >= S::ZERO { Less } else { Greater });\n        if let Some(up) = if (x >= S::ZERO) == (y >= S::ZERO) {\n            down.0.checked_add(y)\n        } else {\n            down.0.checked_sub(y)\n        } {\n            let up = (up, if x >= S::ZERO { Greater } else { Less });\n            assert_eq!(x.round_to_multiple(y, Up), up);\n            if x >= S::ZERO {\n                assert_eq!(x.round_to_multiple(y, Floor), down);\n                assert_eq!(x.round_to_multiple(y, Ceiling), up);\n            } else {\n                assert_eq!(x.round_to_multiple(y, Floor), up);\n                assert_eq!(x.round_to_multiple(y, Ceiling), down);\n            }\n            let nearest = x.round_to_multiple(y, Nearest);\n            assert!(nearest == down || nearest == up);\n        }\n    });\n\n    signed_rounding_mode_pair_gen::<S>().test_properties(|(n, rm)| {\n        if rm == Down || rm == Nearest || rm == if n >= S::ZERO { Floor } else { Ceiling } {\n            assert_eq!(\n                n.round_to_multiple(S::ZERO, rm),\n                (S::ZERO, n.cmp(&S::ZERO).reverse())\n            );\n        }\n        assert_eq!(S::ZERO.round_to_multiple(n, rm), (S::ZERO, Equal));\n        assert_eq!(n.round_to_multiple(S::ONE, rm), (n, Equal));\n        assert_eq!(n.round_to_multiple(n, rm), (n, Equal));\n    });\n}\n\n#[test]\nfn round_to_multiple_properties() {\n    apply_fn_to_unsigneds!(round_to_multiple_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(round_to_multiple_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, signed_unsigned_pair_gen_var_1, signed_unsigned_pair_gen_var_8,\n    signed_unsigned_pair_gen_var_16, signed_unsigned_pair_gen_var_17,\n    signed_unsigned_rounding_mode_triple_gen_var_1, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_14, unsigned_pair_gen_var_21, unsigned_rounding_mode_pair_gen,\n    unsigned_unsigned_rounding_mode_triple_gen_var_3,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_round_to_multiple_of_power_of_2() {\n    fn test<T: PrimitiveInt>(n: T, pow: u64, rm: RoundingMode, out: T, o: Ordering) {\n        assert_eq!(n.round_to_multiple_of_power_of_2(pow, rm), (out, o));\n\n        let mut n = n;\n        assert_eq!(n.round_to_multiple_of_power_of_2_assign(pow, rm), o);\n        assert_eq!(n, out);\n    }\n    test::<u8>(0, 10, Exact, 0, Equal);\n    test::<u8>(17, 0, Exact, 17, Equal);\n\n    test::<u8>(10, 2, Floor, 8, Less);\n    test::<u16>(10, 2, Ceiling, 12, Greater);\n    test::<u32>(10, 2, Down, 8, Less);\n    test::<u64>(10, 2, Up, 12, Greater);\n    test::<u128>(10, 2, Nearest, 8, Less);\n    test::<usize>(12, 2, Exact, 12, Equal);\n\n    test::<i8>(-10, 2, Floor, -12, Less);\n    test::<i16>(-10, 2, Ceiling, -8, Greater);\n    test::<i32>(-10, 2, Down, -8, Greater);\n    test::<i64>(-10, 2, Up, -12, Less);\n    test::<i128>(-10, 2, Nearest, -8, Greater);\n    test::<isize>(-12, 2, Exact, -12, Equal);\n\n    test::<u8>(0xff, 4, Down, 0xf0, Less);\n    test::<u8>(0xff, 4, Floor, 0xf0, Less);\n    test::<u8>(0xef, 4, Up, 0xf0, Greater);\n    test::<u8>(0xef, 4, Ceiling, 0xf0, Greater);\n    test::<u8>(0xe8, 4, Nearest, 0xe0, Less);\n    test::<u8>(1, 8, Nearest, 0, Less);\n\n    test::<i8>(0x7f, 4, Down, 0x70, Less);\n    test::<i8>(0x7f, 4, Floor, 0x70, Less);\n    test::<i8>(0x6f, 4, Up, 0x70, Greater);\n    test::<i8>(0x6f, 4, Ceiling, 0x70, Greater);\n    test::<i8>(0x68, 4, Nearest, 0x60, Less);\n    test::<i8>(-0x7f, 4, Down, -0x70, Greater);\n    test::<i8>(-0x7f, 4, Floor, -0x80, Less);\n    test::<i8>(-0x7f, 4, Up, -0x80, Less);\n    test::<i8>(-0x7f, 4, Ceiling, -0x70, Greater);\n    test::<i8>(-0x78, 4, Nearest, -0x80, Less);\n}\n\nfn round_to_multiple_of_power_of_2_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::exact_from(10).round_to_multiple_of_power_of_2(4, Exact));\n    assert_panic!(T::MAX.round_to_multiple_of_power_of_2(4, Up));\n    assert_panic!(T::MAX.round_to_multiple_of_power_of_2(4, Ceiling));\n    assert_panic!(T::MAX.round_to_multiple_of_power_of_2(4, Nearest));\n    assert_panic!(T::ONE.round_to_multiple_of_power_of_2(T::WIDTH, Up));\n\n    assert_panic!(T::exact_from(10).round_to_multiple_of_power_of_2_assign(4, Exact));\n    assert_panic!({\n        let mut n = T::MAX;\n        n.round_to_multiple_of_power_of_2_assign(4, Up);\n    });\n    assert_panic!({\n        let mut n = T::MAX;\n        n.round_to_multiple_of_power_of_2_assign(4, Ceiling);\n    });\n    assert_panic!({\n        let mut n = T::MAX;\n        n.round_to_multiple_of_power_of_2_assign(4, Nearest);\n    });\n    assert_panic!({\n        let mut n = T::ONE;\n        n.round_to_multiple_of_power_of_2_assign(T::WIDTH, Up);\n    });\n}\n\nfn round_to_multiple_of_power_of_2_signed_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!((-T::MAX).round_to_multiple_of_power_of_2(T::WIDTH, Up));\n    assert_panic!((-T::MAX).round_to_multiple_of_power_of_2(T::WIDTH, Floor));\n\n    assert_panic!((-T::MAX).round_to_multiple_of_power_of_2_assign(T::WIDTH, Up));\n    assert_panic!({\n        (-T::MAX).round_to_multiple_of_power_of_2_assign(T::WIDTH, Floor);\n    });\n}\n\n#[test]\nfn round_to_multiple_of_power_of_2_fail() {\n    apply_fn_to_primitive_ints!(round_to_multiple_of_power_of_2_fail_helper);\n    apply_fn_to_signeds!(round_to_multiple_of_power_of_2_signed_fail_helper);\n}\n\nfn round_to_multiple_of_power_of_2_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_unsigned_rounding_mode_triple_gen_var_3::<T>().test_properties(|(n, pow, rm)| {\n        let (rounded, o) = n.round_to_multiple_of_power_of_2(pow, rm);\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.round_to_multiple_of_power_of_2_assign(pow, rm), o);\n        assert_eq!(mut_n, rounded);\n\n        assert!(rounded.divisible_by_power_of_2(pow));\n        assert_eq!(rounded.cmp(&n), o);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n        match rm {\n            Floor | Down => {\n                assert!(rounded <= n);\n            }\n            Ceiling | Up => {\n                assert!(rounded >= n);\n            }\n            Exact => assert_eq!(rounded, n),\n            Nearest => {\n                if let Some(k) = T::ONE.arithmetic_checked_shl(pow) {\n                    let mut closest = None;\n                    let mut second_closest = None;\n                    if rounded <= n {\n                        if let Some(above) = rounded.checked_add(k) {\n                            closest = Some(n - rounded);\n                            second_closest = Some(above - n);\n                        }\n                    } else if let Some(below) = rounded.checked_sub(k) {\n                        closest = Some(rounded - n);\n                        second_closest = Some(n - below);\n                    }\n                    if let (Some(closest), Some(second_closest)) = (closest, second_closest) {\n                        assert!(closest <= second_closest);\n                        if closest == second_closest {\n                            assert!(!rounded.get_bit(pow));\n                        }\n                    }\n                }\n            }\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.round_to_multiple_of_power_of_2(pow, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(n.round_to_multiple_of_power_of_2(pow, Exact));\n        }\n    });\n\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, pow)| {\n        if pow < T::WIDTH\n            && let Some(shifted) = n.arithmetic_checked_shl(pow)\n        {\n            let so = (shifted, Equal);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Down), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Up), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Floor), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Ceiling), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Nearest), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Exact), so);\n        }\n    });\n\n    unsigned_pair_gen_var_14::<T, u64>().test_properties(|(n, pow)| {\n        let down = n.round_to_multiple_of_power_of_2(pow, Down);\n        assert_eq!(down.1, Less);\n        if let Some(k) = T::ONE.arithmetic_checked_shl(pow)\n            && let Some(up) = down.0.checked_add(k)\n        {\n            let up = (up, Greater);\n            assert_eq!(n.round_to_multiple_of_power_of_2(pow, Up), up);\n            assert_eq!(n.round_to_multiple_of_power_of_2(pow, Floor), down);\n            assert_eq!(n.round_to_multiple_of_power_of_2(pow, Ceiling), up);\n            let nearest = n.round_to_multiple_of_power_of_2(pow, Nearest);\n            assert!(nearest == down || nearest == up);\n        }\n    });\n\n    unsigned_pair_gen_var_21::<T, u64>().test_properties(|(n, pow)| {\n        if let Some(shift) = pow.checked_add(T::WIDTH) {\n            assert_eq!(\n                n.round_to_multiple_of_power_of_2(shift, Down),\n                (T::ZERO, if n == T::ZERO { Equal } else { Less })\n            );\n            assert_eq!(\n                n.round_to_multiple_of_power_of_2(shift, Floor),\n                (T::ZERO, if n == T::ZERO { Equal } else { Less })\n            );\n            if let Some(extra_shift) = shift.checked_add(1) {\n                assert_eq!(\n                    n.round_to_multiple_of_power_of_2(extra_shift, Nearest),\n                    (T::ZERO, if n == T::ZERO { Equal } else { Less })\n                );\n            }\n        }\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(n, rm)| {\n        assert_eq!(n.round_to_multiple_of_power_of_2(0, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen().test_properties(|(pow, rm)| {\n        assert_eq!(\n            T::ZERO.round_to_multiple_of_power_of_2(pow, rm),\n            (T::ZERO, Equal)\n        );\n    });\n}\n\nfn round_to_multiple_of_power_of_2_properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    signed_unsigned_rounding_mode_triple_gen_var_1::<S>().test_properties(|(n, pow, rm)| {\n        let (rounded, o) = n.round_to_multiple_of_power_of_2(pow, rm);\n\n        let mut mut_n = n;\n        assert_eq!(mut_n.round_to_multiple_of_power_of_2_assign(pow, rm), o);\n        assert_eq!(mut_n, rounded);\n\n        assert!(rounded.divisible_by_power_of_2(pow));\n        assert_eq!(rounded.cmp(&n), o);\n        match (n >= S::ZERO, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        match rm {\n            Floor => assert!(rounded <= n),\n            Ceiling => assert!(rounded >= n),\n            Down => assert!(rounded.le_abs(&n)),\n            Up => assert!(rounded.ge_abs(&n)),\n            Exact => assert_eq!(rounded, n),\n            Nearest => {\n                if let Some(k) = S::ONE.arithmetic_checked_shl(pow) {\n                    let mut closest = None;\n                    let mut second_closest = None;\n                    if rounded <= n {\n                        if let Some(above) = rounded.checked_add(k) {\n                            closest = Some(n - rounded);\n                            second_closest = Some(above - n);\n                        }\n                    } else if let Some(below) = rounded.checked_sub(k) {\n                        closest = Some(rounded - n);\n                        second_closest = Some(n - below);\n                    }\n                    if let (Some(closest), Some(second_closest)) = (closest, second_closest) {\n                        assert!(closest <= second_closest);\n                        if closest == second_closest {\n                            assert!(!rounded.get_bit(pow));\n                        }\n                    }\n                }\n            }\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.round_to_multiple_of_power_of_2(pow, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(n.round_to_multiple_of_power_of_2(pow, Exact));\n        }\n    });\n\n    signed_unsigned_pair_gen_var_1::<S, u64>().test_properties(|(n, pow)| {\n        if pow < S::WIDTH\n            && let Some(shifted) = n.arithmetic_checked_shl(pow)\n        {\n            let so = (shifted, Equal);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Down), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Up), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Floor), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Ceiling), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Nearest), so);\n            assert_eq!(shifted.round_to_multiple_of_power_of_2(pow, Exact), so);\n        }\n    });\n\n    signed_unsigned_pair_gen_var_8::<S, u64>().test_properties(|(n, pow)| {\n        let down = n.round_to_multiple_of_power_of_2(pow, Down);\n        assert_eq!(down.1, if n >= S::ZERO { Less } else { Greater });\n        if let Some(k) = S::ONE.arithmetic_checked_shl(pow)\n            && let Some(up) = if n >= S::ZERO {\n                down.0.checked_add(k)\n            } else {\n                down.0.checked_sub(k)\n            }\n        {\n            let up = (up, if n >= S::ZERO { Greater } else { Less });\n            assert_eq!(n.round_to_multiple_of_power_of_2(pow, Up), up);\n            if n >= S::ZERO {\n                assert_eq!(n.round_to_multiple_of_power_of_2(pow, Floor), down);\n                assert_eq!(n.round_to_multiple_of_power_of_2(pow, Ceiling), up);\n            } else {\n                assert_eq!(n.round_to_multiple_of_power_of_2(pow, Floor), up);\n                assert_eq!(n.round_to_multiple_of_power_of_2(pow, Ceiling), down);\n            }\n            let nearest = n.round_to_multiple_of_power_of_2(pow, Nearest);\n            assert!(nearest == down || nearest == up);\n        }\n    });\n\n    signed_unsigned_pair_gen_var_16::<S, u64>().test_properties(|(i, pow)| {\n        if let Some(shift) = pow.checked_add(S::WIDTH - 1) {\n            assert_eq!(\n                i.round_to_multiple_of_power_of_2(shift, Down),\n                (S::ZERO, if i == S::ZERO { Equal } else { Less })\n            );\n            assert_eq!(\n                i.round_to_multiple_of_power_of_2(shift, Floor),\n                (S::ZERO, if i == S::ZERO { Equal } else { Less })\n            );\n            if let Some(extra_shift) = shift.checked_add(1) {\n                assert_eq!(\n                    i.round_to_multiple_of_power_of_2(extra_shift, Nearest),\n                    (S::ZERO, if i == S::ZERO { Equal } else { Less })\n                );\n            }\n        }\n    });\n\n    signed_unsigned_pair_gen_var_17::<U, S, u64>().test_properties(|(i, pow)| {\n        if let Some(shift) = pow.checked_add(S::WIDTH - 1) {\n            assert_eq!(\n                i.round_to_multiple_of_power_of_2(shift, Down),\n                (S::ZERO, if i == S::ZERO { Equal } else { Greater })\n            );\n            assert_eq!(\n                i.round_to_multiple_of_power_of_2(shift, Ceiling),\n                (S::ZERO, if i == S::ZERO { Equal } else { Greater })\n            );\n            if let Some(extra_shift) = shift.checked_add(1) {\n                assert_eq!(\n                    i.round_to_multiple_of_power_of_2(extra_shift, Nearest),\n                    (S::ZERO, if i == S::ZERO { Equal } else { Greater })\n                );\n            }\n        }\n    });\n\n    signed_rounding_mode_pair_gen::<S>().test_properties(|(n, rm)| {\n        assert_eq!(n.round_to_multiple_of_power_of_2(0, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen().test_properties(|(pow, rm)| {\n        assert_eq!(\n            S::ZERO.round_to_multiple_of_power_of_2(pow, rm),\n            (S::ZERO, Equal)\n        );\n    });\n}\n\n#[test]\nfn round_to_multiple_of_power_of_2_properties() {\n    apply_fn_to_unsigneds!(round_to_multiple_of_power_of_2_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(round_to_multiple_of_power_of_2_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::generators::signed_gen;\n\nfn saturating_abs_assign_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.saturating_abs(), out);\n\n        let mut n = n;\n        n.saturating_abs_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::ONE, T::ONE);\n    test(T::exact_from(100), T::exact_from(100));\n    test(T::MAX, T::MAX);\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::exact_from(-100), T::exact_from(100));\n    test(T::MIN, T::MAX);\n}\n\n#[test]\nfn test_saturating_abs_assign() {\n    apply_fn_to_signeds!(saturating_abs_assign_helper);\n}\n\nfn saturating_abs_properties_helper<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|n| {\n        let mut abs = n;\n        abs.saturating_abs_assign();\n        assert_eq!(abs, n.saturating_abs());\n        assert_eq!(abs.saturating_abs(), abs);\n        if n != T::MIN {\n            assert_eq!(n.abs(), abs);\n        }\n        assert_eq!(abs == n, n >= T::ZERO);\n    });\n}\n\n#[test]\nfn saturating_abs_properties() {\n    apply_fn_to_signeds!(saturating_abs_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_saturating_add() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.saturating_add(y), out);\n\n        let mut x = x;\n        x.saturating_add_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u16>(123, 456, 579);\n    test::<u8>(123, 200, 255);\n    test::<i16>(123, -456, -333);\n    test::<i8>(123, 45, 127);\n    test::<i8>(-123, -45, -128);\n}\n\nfn saturating_add_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut sum = x;\n        sum.saturating_add_assign(y);\n        assert_eq!(sum, x.saturating_add(y));\n        assert_eq!(y.saturating_add(x), sum);\n        assert!(sum >= x);\n        assert!(sum >= y);\n        if sum < T::MAX {\n            assert_eq!(sum, x + y);\n        }\n    });\n}\n\nfn saturating_add_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut sum = x;\n        sum.saturating_add_assign(y);\n        assert_eq!(sum, x.saturating_add(y));\n        assert_eq!(y.saturating_add(x), sum);\n        if sum > T::MIN && sum < T::MAX {\n            assert_eq!(sum, x + y);\n        }\n    });\n}\n\n#[test]\nfn saturating_add_properties() {\n    apply_fn_to_unsigneds!(saturating_add_properties_helper_unsigned);\n    apply_fn_to_signeds!(saturating_add_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_saturating_add_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: T) {\n        assert_eq!(x.saturating_add_mul(y, z), out);\n\n        let mut x = x;\n        x.saturating_add_mul_assign(y, z);\n        assert_eq!(x, out);\n    }\n    test::<u8>(2, 3, 7, 23);\n    test::<u32>(7, 5, 10, 57);\n    test::<u64>(123, 456, 789, 359907);\n    test::<i32>(123, -456, 789, -359661);\n    test::<i128>(-123, 456, 789, 359661);\n    test::<i8>(127, -2, 100, -73);\n    test::<i8>(-127, 2, 100, 73);\n    test::<i8>(-128, 1, 0, -128);\n\n    test::<u8>(2, 20, 20, 255);\n    test::<i8>(-127, -2, 100, -128);\n    test::<i8>(127, 1, 100, 127);\n    test::<i8>(-127, -1, 100, -128);\n    test::<i8>(-127, -10, 100, -128);\n}\n\nfn saturating_add_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let result = x.saturating_add_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.saturating_add_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.saturating_add_mul(z, y), result);\n        assert!(result >= x);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.saturating_add_mul(T::ZERO, b), a);\n        assert_eq!(a.saturating_add_mul(T::ONE, b), a.saturating_add(b));\n        assert_eq!(T::ZERO.saturating_add_mul(a, b), a.saturating_mul(b));\n        assert_eq!(a.saturating_add_mul(b, T::ZERO), a);\n        assert_eq!(a.saturating_add_mul(b, T::ONE), a.saturating_add(b));\n    });\n}\n\nfn saturating_add_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.saturating_add_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.saturating_add_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.saturating_add_mul(z, y), result);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.saturating_add_mul(T::ZERO, b), a);\n        assert_eq!(a.saturating_add_mul(T::ONE, b), a.saturating_add(b));\n        assert_eq!(T::ZERO.saturating_add_mul(a, b), a.saturating_mul(b));\n        assert_eq!(a.saturating_add_mul(b, T::ZERO), a);\n        assert_eq!(a.saturating_add_mul(b, T::ONE), a.saturating_add(b));\n    });\n}\n\n#[test]\nfn saturating_add_mul_properties() {\n    apply_fn_to_unsigneds!(saturating_add_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(saturating_add_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_saturating_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.saturating_mul(y), out);\n\n        let mut x = x;\n        x.saturating_mul_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u16>(123, 456, 56088);\n    test::<u8>(123, 200, 255);\n    test::<i16>(123, -45, -5535);\n    test::<i8>(123, 45, 127);\n    test::<i8>(-123, 45, -128);\n}\n\nfn saturating_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut product = x;\n        product.saturating_mul_assign(y);\n        assert_eq!(product, x.saturating_mul(y));\n        assert_eq!(y.saturating_mul(x), product);\n        assert!(product == T::ZERO || product >= x);\n        assert!(product == T::ZERO || product >= y);\n        if product < T::MAX {\n            assert_eq!(product, x * y);\n        }\n    });\n}\n\nfn saturating_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut product = x;\n        product.saturating_mul_assign(y);\n        assert_eq!(product, x.saturating_mul(y));\n        assert_eq!(y.saturating_mul(x), product);\n        if product > T::MIN && product < T::MAX {\n            assert_eq!(product, x * y);\n        }\n    });\n}\n\n#[test]\nfn saturating_mul_properties() {\n    apply_fn_to_unsigneds!(saturating_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(saturating_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::generators::signed_gen;\n\nfn saturating_neg_assign_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.saturating_neg(), out);\n\n        let mut n = n;\n        n.saturating_neg_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::ONE, T::NEGATIVE_ONE);\n    test(T::exact_from(100), T::exact_from(-100));\n    test(T::MAX, T::MIN + T::ONE);\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::exact_from(-100), T::exact_from(100));\n    test(T::MIN, T::MAX);\n}\n\n#[test]\nfn test_saturating_neg_assign() {\n    apply_fn_to_signeds!(saturating_neg_assign_helper);\n}\n\nfn saturating_neg_properties_helper<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|n| {\n        let mut neg = n;\n        neg.saturating_neg_assign();\n        assert_eq!(neg, n.saturating_neg());\n        if n != T::MIN {\n            assert_eq!(neg.saturating_neg(), n);\n        }\n        assert_eq!(neg == n, n == T::ZERO);\n    });\n}\n\n#[test]\nfn saturating_neg_properties() {\n    apply_fn_to_signeds!(saturating_neg_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\n\n#[test]\nfn test_saturating_pow() {\n    fn test<T: PrimitiveInt>(x: T, y: u64, out: T) {\n        assert_eq!(x.saturating_pow(y), out);\n\n        let mut x = x;\n        x.saturating_pow_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, 1);\n    test::<u64>(123, 0, 1);\n    test::<u64>(123, 1, 123);\n    test::<u16>(0, 123, 0);\n    test::<u16>(1, 123, 1);\n    test::<i16>(-1, 123, -1);\n    test::<i16>(-1, 124, 1);\n    test::<u8>(3, 3, 27);\n    test::<i32>(-10, 9, -1000000000);\n    test::<i32>(-10, 10, i32::MAX);\n    test::<i16>(-10, 9, i16::MIN);\n    test::<i16>(10, 9, i16::MAX);\n    test::<i64>(123, 456, i64::MAX);\n    test::<u64>(0, u64::MAX, 0);\n    test::<u64>(1, u64::MAX, 1);\n    test::<u64>(123, u64::MAX, u64::MAX);\n    test::<i64>(0, u64::MAX, 0);\n    test::<i64>(1, u64::MAX, 1);\n    test::<i64>(-1, u64::MAX, -1);\n    test::<i64>(-1, u64::MAX - 1, 1);\n    test::<i64>(123, u64::MAX, i64::MAX);\n    test::<i64>(-123, u64::MAX, i64::MIN);\n    test::<i64>(-123, u64::MAX - 1, i64::MAX);\n}\n\nfn saturating_pow_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.saturating_pow_assign(y);\n        assert_eq!(power, x.saturating_pow(y));\n        if y != 0 {\n            assert!(power >= x);\n        }\n        if power < T::MAX {\n            assert_eq!(power, x.pow(y));\n        }\n    });\n}\n\nfn saturating_pow_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.saturating_pow_assign(y);\n        assert_eq!(power, x.saturating_pow(y));\n        if power > T::MIN && power < T::MAX {\n            assert_eq!(power, x.pow(y));\n        }\n    });\n}\n\n#[test]\nfn saturating_pow_properties() {\n    apply_fn_to_unsigneds!(saturating_pow_properties_helper_unsigned);\n    apply_fn_to_signeds!(saturating_pow_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\n#[test]\nfn test_saturating_square() {\n    fn test<T: PrimitiveInt>(x: T, out: T) {\n        assert_eq!(x.saturating_square(), out);\n\n        let mut x = x;\n        x.saturating_square_assign();\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0);\n    test::<i16>(1, 1);\n    test::<u32>(2, 4);\n    test::<i64>(3, 9);\n    test::<u128>(10, 100);\n    test::<isize>(123, 15129);\n    test::<u32>(1000, 1000000);\n\n    test::<i16>(-1, 1);\n    test::<i32>(-2, 4);\n    test::<i64>(-3, 9);\n    test::<i128>(-10, 100);\n    test::<isize>(-123, 15129);\n    test::<i32>(-1000, 1000000);\n\n    test::<u16>(1000, u16::MAX);\n    test::<i16>(-1000, i16::MAX);\n}\n\nfn saturating_square_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        let mut square = x;\n        square.saturating_square_assign();\n        assert_eq!(square, x.saturating_square());\n        assert_eq!(square, x.saturating_pow(2));\n        assert!(square >= x);\n        if square < T::MAX {\n            assert_eq!(square, x.square());\n        }\n    });\n}\n\nfn saturating_square_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        let mut square = x;\n        square.saturating_square_assign();\n        assert_eq!(square, x.saturating_square());\n        assert_eq!(square, x.saturating_pow(2));\n        if square > T::MIN && square < T::MAX {\n            assert_eq!(square, x.square());\n        }\n    });\n}\n\n#[test]\nfn saturating_square_properties() {\n    apply_fn_to_unsigneds!(saturating_square_properties_helper_unsigned);\n    apply_fn_to_signeds!(saturating_square_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_saturating_sub() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.saturating_sub(y), out);\n\n        let mut x = x;\n        x.saturating_sub_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u16>(456, 123, 333);\n    test::<u8>(123, 200, 0);\n    test::<i16>(123, -456, 579);\n    test::<i8>(123, -45, 127);\n    test::<i8>(-123, 45, -128);\n}\n\nfn saturating_sub_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut diff = x;\n        diff.saturating_sub_assign(y);\n        assert_eq!(diff, x.saturating_sub(y));\n        assert!(diff <= x);\n        if diff > T::ZERO {\n            assert_eq!(diff, x - y);\n        }\n    });\n}\n\nfn saturating_sub_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut diff = x;\n        diff.saturating_sub_assign(y);\n        assert_eq!(diff, x.saturating_sub(y));\n        if diff > T::MIN && diff < T::MAX {\n            assert_eq!(diff, x - y);\n        }\n    });\n}\n\n#[test]\nfn saturating_sub_properties() {\n    apply_fn_to_unsigneds!(saturating_sub_properties_helper_unsigned);\n    apply_fn_to_signeds!(saturating_sub_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/saturating_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_saturating_sub_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: T) {\n        assert_eq!(x.saturating_sub_mul(y, z), out);\n\n        let mut x = x;\n        x.saturating_sub_mul_assign(y, z);\n        assert_eq!(x, out);\n    }\n    test::<u8>(100, 3, 7, 79);\n    test::<u32>(60, 5, 10, 10);\n    test::<u64>(1000000, 456, 789, 640216);\n    test::<i32>(123, -456, 789, 359907);\n    test::<i128>(-123, 456, 789, -359907);\n    test::<i8>(127, 2, 100, -73);\n    test::<i8>(-127, -2, 100, 73);\n    test::<i8>(-128, 1, 0, -128);\n\n    test::<u8>(2, 10, 5, 0);\n    test::<i8>(-127, 2, 100, -128);\n    test::<i8>(-127, 1, 100, -128);\n    test::<i8>(127, -1, 100, 127);\n    test::<i8>(127, -10, 100, 127);\n}\n\nfn saturating_sub_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let result = x.saturating_sub_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.saturating_sub_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.saturating_sub_mul(z, y), result);\n        assert!(result <= x);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.saturating_sub_mul(T::ZERO, b), a);\n        assert_eq!(a.saturating_sub_mul(T::ONE, b), a.saturating_sub(b));\n        assert_eq!(a.saturating_sub_mul(b, T::ZERO), a);\n        assert_eq!(a.saturating_sub_mul(b, T::ONE), a.saturating_sub(b));\n    });\n}\n\nfn saturating_sub_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.saturating_sub_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.saturating_sub_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.saturating_sub_mul(z, y), result);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.saturating_sub_mul(T::ZERO, b), a);\n        assert_eq!(a.saturating_sub_mul(T::ONE, b), a.saturating_sub(b));\n        assert_eq!(a.saturating_sub_mul(b, T::ZERO), a);\n        assert_eq!(a.saturating_sub_mul(b, T::ONE), a.saturating_sub(b));\n    });\n}\n\n#[test]\nfn saturating_sub_mul_properties() {\n    apply_fn_to_unsigneds!(saturating_sub_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(saturating_sub_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShr, ShlRound, ShlRoundAssign, ShrRound, UnsignedAbs,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, signed_signed_rounding_mode_triple_gen_var_4,\n    unsigned_rounding_mode_pair_gen, unsigned_signed_rounding_mode_triple_gen_var_2,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_shl_round() {\n    fn test<T: PrimitiveInt + ShlRound<U, Output = T> + ShlRoundAssign<U>, U: PrimitiveInt>(\n        t: T,\n        u: U,\n        rm: RoundingMode,\n        out: T,\n        o: Ordering,\n    ) {\n        assert_eq!(t.shl_round(u, rm), (out, o));\n\n        let mut t = t;\n        assert_eq!(t.shl_round_assign(u, rm), o);\n        assert_eq!(t, out);\n    }\n    test::<u8, i8>(0, 0, Down, 0, Equal);\n    test::<u8, i8>(0, 0, Up, 0, Equal);\n    test::<u8, i8>(0, 0, Floor, 0, Equal);\n    test::<u8, i8>(0, 0, Ceiling, 0, Equal);\n    test::<u8, i8>(0, 0, Nearest, 0, Equal);\n    test::<u8, i8>(0, 0, Exact, 0, Equal);\n\n    test::<u8, i16>(0, -10, Down, 0, Equal);\n    test::<u8, i16>(0, -10, Up, 0, Equal);\n    test::<u8, i16>(0, -10, Floor, 0, Equal);\n    test::<u8, i16>(0, -10, Ceiling, 0, Equal);\n    test::<u8, i16>(0, -10, Nearest, 0, Equal);\n    test::<u8, i16>(0, -10, Exact, 0, Equal);\n\n    test::<i8, i32>(123, 0, Down, 123, Equal);\n    test::<i8, i32>(123, 0, Up, 123, Equal);\n    test::<i8, i32>(123, 0, Floor, 123, Equal);\n    test::<i8, i32>(123, 0, Ceiling, 123, Equal);\n    test::<i8, i32>(123, 0, Nearest, 123, Equal);\n    test::<i8, i32>(123, 0, Exact, 123, Equal);\n\n    test::<u8, i64>(245, -1, Down, 122, Less);\n    test::<u8, i64>(245, -1, Up, 123, Greater);\n    test::<u8, i64>(245, -1, Floor, 122, Less);\n    test::<u8, i64>(245, -1, Ceiling, 123, Greater);\n    test::<u8, i64>(245, -1, Nearest, 122, Less);\n\n    test::<u8, i128>(246, -1, Down, 123, Equal);\n    test::<u8, i128>(246, -1, Up, 123, Equal);\n    test::<u8, i128>(246, -1, Floor, 123, Equal);\n    test::<u8, i128>(246, -1, Ceiling, 123, Equal);\n    test::<u8, i128>(246, -1, Nearest, 123, Equal);\n    test::<u8, i128>(246, -1, Exact, 123, Equal);\n\n    test::<u8, isize>(247, -1, Down, 123, Less);\n    test::<u8, isize>(247, -1, Up, 124, Greater);\n    test::<u8, isize>(247, -1, Floor, 123, Less);\n    test::<u8, isize>(247, -1, Ceiling, 124, Greater);\n    test::<u8, isize>(247, -1, Nearest, 124, Greater);\n\n    test::<i16, i8>(491, -2, Down, 122, Less);\n    test::<i16, i8>(491, -2, Up, 123, Greater);\n    test::<i16, i8>(491, -2, Floor, 122, Less);\n    test::<i16, i8>(491, -2, Ceiling, 123, Greater);\n    test::<i16, i8>(491, -2, Nearest, 123, Greater);\n\n    test::<u16, i16>(492, -2, Down, 123, Equal);\n    test::<u16, i16>(492, -2, Up, 123, Equal);\n    test::<u16, i16>(492, -2, Floor, 123, Equal);\n    test::<u16, i16>(492, -2, Ceiling, 123, Equal);\n    test::<u16, i16>(492, -2, Nearest, 123, Equal);\n    test::<u16, i16>(492, -2, Exact, 123, Equal);\n\n    test::<i16, i32>(493, -2, Down, 123, Less);\n    test::<i16, i32>(493, -2, Up, 124, Greater);\n    test::<i16, i32>(493, -2, Floor, 123, Less);\n    test::<i16, i32>(493, -2, Ceiling, 124, Greater);\n    test::<i16, i32>(493, -2, Nearest, 123, Less);\n\n    test::<u32, i8>(4127195135, -25, Down, 122, Less);\n    test::<u32, i8>(4127195135, -25, Up, 123, Greater);\n    test::<u32, i8>(4127195135, -25, Floor, 122, Less);\n    test::<u32, i8>(4127195135, -25, Ceiling, 123, Greater);\n    test::<u32, i8>(4127195135, -25, Nearest, 123, Greater);\n\n    test::<u32, i16>(4127195136, -25, Down, 123, Equal);\n    test::<u32, i16>(4127195136, -25, Up, 123, Equal);\n    test::<u32, i16>(4127195136, -25, Floor, 123, Equal);\n    test::<u32, i16>(4127195136, -25, Ceiling, 123, Equal);\n    test::<u32, i16>(4127195136, -25, Nearest, 123, Equal);\n    test::<u32, i16>(4127195136, -25, Exact, 123, Equal);\n\n    test::<u32, i32>(4127195137, -25, Down, 123, Less);\n    test::<u32, i32>(4127195137, -25, Up, 124, Greater);\n    test::<u32, i32>(4127195137, -25, Floor, 123, Less);\n    test::<u32, i32>(4127195137, -25, Ceiling, 124, Greater);\n    test::<u32, i32>(4127195137, -25, Nearest, 123, Less);\n\n    test::<i64, i8>(8254390271, -26, Down, 122, Less);\n    test::<i64, i8>(8254390271, -26, Up, 123, Greater);\n    test::<i64, i8>(8254390271, -26, Floor, 122, Less);\n    test::<i64, i8>(8254390271, -26, Ceiling, 123, Greater);\n    test::<i64, i8>(8254390271, -26, Nearest, 123, Greater);\n\n    test::<u64, i16>(8254390272, -26, Down, 123, Equal);\n    test::<u64, i16>(8254390272, -26, Up, 123, Equal);\n    test::<u64, i16>(8254390272, -26, Floor, 123, Equal);\n    test::<u64, i16>(8254390272, -26, Ceiling, 123, Equal);\n    test::<u64, i16>(8254390272, -26, Nearest, 123, Equal);\n    test::<u64, i16>(8254390272, -26, Exact, 123, Equal);\n\n    test::<i64, i32>(8254390273, -26, Down, 123, Less);\n    test::<i64, i32>(8254390273, -26, Up, 124, Greater);\n    test::<i64, i32>(8254390273, -26, Floor, 123, Less);\n    test::<i64, i32>(8254390273, -26, Ceiling, 124, Greater);\n    test::<i64, i32>(8254390273, -26, Nearest, 123, Less);\n\n    test::<i64, i64>(0xffffffff, -1, Down, 0x7fffffff, Less);\n    test::<i64, i64>(0xffffffff, -1, Up, 0x80000000, Greater);\n    test::<i64, i64>(0xffffffff, -1, Floor, 0x7fffffff, Less);\n    test::<i64, i64>(0xffffffff, -1, Ceiling, 0x80000000, Greater);\n    test::<i64, i64>(0xffffffff, -1, Nearest, 0x80000000, Greater);\n\n    test::<u64, i64>(0x100000000, -1, Down, 0x80000000, Equal);\n    test::<u64, i64>(0x100000000, -1, Up, 0x80000000, Equal);\n    test::<u64, i64>(0x100000000, -1, Floor, 0x80000000, Equal);\n    test::<u64, i64>(0x100000000, -1, Ceiling, 0x80000000, Equal);\n    test::<u64, i64>(0x100000000, -1, Nearest, 0x80000000, Equal);\n    test::<u64, i64>(0x100000000, -1, Exact, 0x80000000, Equal);\n\n    test::<u64, i128>(0x100000001, -1, Down, 0x80000000, Less);\n    test::<u64, i128>(0x100000001, -1, Up, 0x80000001, Greater);\n    test::<u64, i128>(0x100000001, -1, Floor, 0x80000000, Less);\n    test::<u64, i128>(0x100000001, -1, Ceiling, 0x80000001, Greater);\n    test::<u64, i128>(0x100000001, -1, Nearest, 0x80000000, Less);\n\n    test::<i64, isize>(1000000000000, 0, Down, 1000000000000, Equal);\n    test::<i64, isize>(1000000000000, 0, Up, 1000000000000, Equal);\n    test::<i64, isize>(1000000000000, 0, Floor, 1000000000000, Equal);\n    test::<i64, isize>(1000000000000, 0, Ceiling, 1000000000000, Equal);\n    test::<i64, isize>(1000000000000, 0, Nearest, 1000000000000, Equal);\n    test::<i64, isize>(1000000000000, 0, Exact, 1000000000000, Equal);\n\n    test::<i128, i8>(7999999999999, -3, Down, 999999999999, Less);\n    test::<i128, i8>(7999999999999, -3, Up, 1000000000000, Greater);\n    test::<i128, i8>(7999999999999, -3, Floor, 999999999999, Less);\n    test::<i128, i8>(7999999999999, -3, Ceiling, 1000000000000, Greater);\n    test::<i128, i8>(7999999999999, -3, Nearest, 1000000000000, Greater);\n\n    test::<u128, i16>(8000000000000, -3, Down, 1000000000000, Equal);\n    test::<u128, i16>(8000000000000, -3, Up, 1000000000000, Equal);\n    test::<u128, i16>(8000000000000, -3, Floor, 1000000000000, Equal);\n    test::<u128, i16>(8000000000000, -3, Ceiling, 1000000000000, Equal);\n    test::<u128, i16>(8000000000000, -3, Nearest, 1000000000000, Equal);\n    test::<u128, i16>(8000000000000, -3, Exact, 1000000000000, Equal);\n\n    test::<u128, i32>(8000000000001, -3, Down, 1000000000000, Less);\n    test::<u128, i32>(8000000000001, -3, Up, 1000000000001, Greater);\n    test::<u128, i32>(8000000000001, -3, Floor, 1000000000000, Less);\n    test::<u128, i32>(8000000000001, -3, Ceiling, 1000000000001, Greater);\n    test::<u128, i32>(8000000000001, -3, Nearest, 1000000000000, Less);\n\n    test::<i128, i64>(1000000000000, -10, Down, 976562500, Equal);\n    test::<i128, i64>(1000000000000, -10, Up, 976562500, Equal);\n    test::<i128, i64>(1000000000000, -10, Floor, 976562500, Equal);\n    test::<i128, i64>(1000000000000, -10, Ceiling, 976562500, Equal);\n    test::<i128, i64>(1000000000000, -10, Nearest, 976562500, Equal);\n    test::<i128, i64>(1000000000000, -10, Exact, 976562500, Equal);\n\n    test::<u128, i128>(980657949, -72, Down, 0, Less);\n    test::<u128, i128>(980657949, -72, Up, 1, Greater);\n    test::<u128, i128>(980657949, -72, Floor, 0, Less);\n    test::<u128, i128>(980657949, -72, Ceiling, 1, Greater);\n    test::<u128, i128>(980657949, -72, Nearest, 0, Less);\n\n    test::<i128, isize>(0xffffffff, -31, Down, 1, Less);\n    test::<i128, isize>(0xffffffff, -31, Up, 2, Greater);\n    test::<i128, isize>(0xffffffff, -31, Floor, 1, Less);\n    test::<i128, isize>(0xffffffff, -31, Ceiling, 2, Greater);\n    test::<i128, isize>(0xffffffff, -31, Nearest, 2, Greater);\n\n    test::<u32, i128>(0xffffffff, -32, Down, 0, Less);\n    test::<u32, i128>(0xffffffff, -32, Up, 1, Greater);\n    test::<u32, i128>(0xffffffff, -32, Floor, 0, Less);\n    test::<u32, i128>(0xffffffff, -32, Ceiling, 1, Greater);\n    test::<u32, i128>(0xffffffff, -32, Nearest, 1, Greater);\n\n    test::<u64, i8>(0x100000000, -32, Down, 1, Equal);\n    test::<u64, i8>(0x100000000, -32, Up, 1, Equal);\n    test::<u64, i8>(0x100000000, -32, Floor, 1, Equal);\n    test::<u64, i8>(0x100000000, -32, Ceiling, 1, Equal);\n    test::<u64, i8>(0x100000000, -32, Nearest, 1, Equal);\n    test::<u64, i8>(0x100000000, -32, Exact, 1, Equal);\n\n    test::<i64, i16>(0x100000000, -33, Down, 0, Less);\n    test::<i64, i16>(0x100000000, -33, Up, 1, Greater);\n    test::<i64, i16>(0x100000000, -33, Floor, 0, Less);\n    test::<i64, i16>(0x100000000, -33, Ceiling, 1, Greater);\n    test::<i64, i16>(0x100000000, -33, Nearest, 0, Less);\n\n    test::<u8, i8>(0, 10, Exact, 0, Equal);\n    test::<u8, i16>(123, 1, Exact, 246, Equal);\n    test::<u16, i32>(123, 2, Exact, 492, Equal);\n    test::<u64, i64>(123, 25, Exact, 4127195136, Equal);\n    test::<u128, i128>(123, 26, Exact, 8254390272, Equal);\n    test::<u8, isize>(123, 100, Exact, 0, Equal);\n\n    test::<u64, i8>(0x80000000, 1, Exact, 0x100000000, Equal);\n    test::<i64, i16>(1000000000000, 3, Exact, 8000000000000, Equal);\n    test::<u64, i8>(1000000000000, 24, Exact, 16777216000000000000, Equal);\n    test::<i128, i16>(1000000000000, 25, Exact, 33554432000000000000, Equal);\n    test::<u128, i32>(1000000000000, 31, Exact, 2147483648000000000000, Equal);\n    test::<i128, i64>(1000000000000, 32, Exact, 4294967296000000000000, Equal);\n    test::<u128, i128>(1000000000000, 33, Exact, 8589934592000000000000, Equal);\n    test::<i64, isize>(1000000000000, 100, Exact, 0, Equal);\n\n    test::<i8, i8>(-123, 0, Down, -123, Equal);\n    test::<i8, i8>(-123, 0, Up, -123, Equal);\n    test::<i8, i8>(-123, 0, Floor, -123, Equal);\n    test::<i8, i8>(-123, 0, Ceiling, -123, Equal);\n    test::<i8, i8>(-123, 0, Nearest, -123, Equal);\n    test::<i8, i8>(-123, 0, Exact, -123, Equal);\n\n    test::<i16, i8>(-245, -1, Down, -122, Greater);\n    test::<i16, i8>(-245, -1, Up, -123, Less);\n    test::<i16, i8>(-245, -1, Floor, -123, Less);\n    test::<i16, i8>(-245, -1, Ceiling, -122, Greater);\n    test::<i16, i8>(-245, -1, Nearest, -122, Greater);\n\n    test::<i16, i16>(-246, -1, Down, -123, Equal);\n    test::<i16, i16>(-246, -1, Up, -123, Equal);\n    test::<i16, i16>(-246, -1, Floor, -123, Equal);\n    test::<i16, i16>(-246, -1, Ceiling, -123, Equal);\n    test::<i16, i16>(-246, -1, Nearest, -123, Equal);\n    test::<i16, i16>(-246, -1, Exact, -123, Equal);\n\n    test::<i16, i32>(-247, -1, Down, -123, Greater);\n    test::<i16, i32>(-247, -1, Up, -124, Less);\n    test::<i16, i32>(-247, -1, Floor, -124, Less);\n    test::<i16, i32>(-247, -1, Ceiling, -123, Greater);\n    test::<i16, i32>(-247, -1, Nearest, -124, Less);\n\n    test::<i16, i64>(-491, -2, Down, -122, Greater);\n    test::<i16, i64>(-491, -2, Up, -123, Less);\n    test::<i16, i64>(-491, -2, Floor, -123, Less);\n    test::<i16, i64>(-491, -2, Ceiling, -122, Greater);\n    test::<i16, i64>(-491, -2, Nearest, -123, Less);\n\n    test::<i16, i128>(-492, -2, Down, -123, Equal);\n    test::<i16, i128>(-492, -2, Up, -123, Equal);\n    test::<i16, i128>(-492, -2, Floor, -123, Equal);\n    test::<i16, i128>(-492, -2, Ceiling, -123, Equal);\n    test::<i16, i128>(-492, -2, Nearest, -123, Equal);\n    test::<i16, i128>(-492, -2, Exact, -123, Equal);\n\n    test::<i16, isize>(-493, -2, Down, -123, Greater);\n    test::<i16, isize>(-493, -2, Up, -124, Less);\n    test::<i16, isize>(-493, -2, Floor, -124, Less);\n    test::<i16, isize>(-493, -2, Ceiling, -123, Greater);\n    test::<i16, isize>(-493, -2, Nearest, -123, Greater);\n\n    test::<i64, i8>(-4127195135, -25, Down, -122, Greater);\n    test::<i64, i8>(-4127195135, -25, Up, -123, Less);\n    test::<i64, i8>(-4127195135, -25, Floor, -123, Less);\n    test::<i64, i8>(-4127195135, -25, Ceiling, -122, Greater);\n    test::<i64, i8>(-4127195135, -25, Nearest, -123, Less);\n\n    test::<i64, i16>(-4127195136, -25, Down, -123, Equal);\n    test::<i64, i16>(-4127195136, -25, Up, -123, Equal);\n    test::<i64, i16>(-4127195136, -25, Floor, -123, Equal);\n    test::<i64, i16>(-4127195136, -25, Ceiling, -123, Equal);\n    test::<i64, i16>(-4127195136, -25, Nearest, -123, Equal);\n    test::<i64, i16>(-4127195136, -25, Exact, -123, Equal);\n\n    test::<i64, i32>(-4127195137, -25, Down, -123, Greater);\n    test::<i64, i32>(-4127195137, -25, Up, -124, Less);\n    test::<i64, i32>(-4127195137, -25, Floor, -124, Less);\n    test::<i64, i32>(-4127195137, -25, Ceiling, -123, Greater);\n    test::<i64, i32>(-4127195137, -25, Nearest, -123, Greater);\n\n    test::<i64, i64>(-8254390271, -26, Down, -122, Greater);\n    test::<i64, i64>(-8254390271, -26, Up, -123, Less);\n    test::<i64, i64>(-8254390271, -26, Floor, -123, Less);\n    test::<i64, i64>(-8254390271, -26, Ceiling, -122, Greater);\n    test::<i64, i64>(-8254390271, -26, Nearest, -123, Less);\n\n    test::<i64, i128>(-8254390272, -26, Down, -123, Equal);\n    test::<i64, i128>(-8254390272, -26, Up, -123, Equal);\n    test::<i64, i128>(-8254390272, -26, Floor, -123, Equal);\n    test::<i64, i128>(-8254390272, -26, Ceiling, -123, Equal);\n    test::<i64, i128>(-8254390272, -26, Nearest, -123, Equal);\n    test::<i64, i128>(-8254390272, -26, Exact, -123, Equal);\n\n    test::<i64, isize>(-8254390273, -26, Down, -123, Greater);\n    test::<i64, isize>(-8254390273, -26, Up, -124, Less);\n    test::<i64, isize>(-8254390273, -26, Floor, -124, Less);\n    test::<i64, isize>(-8254390273, -26, Ceiling, -123, Greater);\n    test::<i64, isize>(-8254390273, -26, Nearest, -123, Greater);\n\n    test::<i128, i8>(-0xffffffff, -1, Down, -0x7fffffff, Greater);\n    test::<i128, i8>(-0xffffffff, -1, Up, -0x80000000, Less);\n    test::<i128, i8>(-0xffffffff, -1, Floor, -0x80000000, Less);\n    test::<i128, i8>(-0xffffffff, -1, Ceiling, -0x7fffffff, Greater);\n    test::<i128, i8>(-0xffffffff, -1, Nearest, -0x80000000, Less);\n\n    test::<i128, i16>(-0x100000000, -1, Down, -0x80000000, Equal);\n    test::<i128, i16>(-0x100000000, -1, Up, -0x80000000, Equal);\n    test::<i128, i16>(-0x100000000, -1, Floor, -0x80000000, Equal);\n    test::<i128, i16>(-0x100000000, -1, Ceiling, -0x80000000, Equal);\n    test::<i128, i16>(-0x100000000, -1, Nearest, -0x80000000, Equal);\n    test::<i128, i16>(-0x100000000, -1, Exact, -0x80000000, Equal);\n\n    test::<i128, i32>(-0x100000001, -1, Down, -0x80000000, Greater);\n    test::<i128, i32>(-0x100000001, -1, Up, -0x80000001, Less);\n    test::<i128, i32>(-0x100000001, -1, Floor, -0x80000001, Less);\n    test::<i128, i32>(-0x100000001, -1, Ceiling, -0x80000000, Greater);\n    test::<i128, i32>(-0x100000001, -1, Nearest, -0x80000000, Greater);\n\n    test::<i128, i64>(-1000000000000, 0, Down, -1000000000000, Equal);\n    test::<i128, i64>(-1000000000000, 0, Up, -1000000000000, Equal);\n    test::<i128, i64>(-1000000000000, 0, Floor, -1000000000000, Equal);\n    test::<i128, i64>(-1000000000000, 0, Ceiling, -1000000000000, Equal);\n    test::<i128, i64>(-1000000000000, 0, Nearest, -1000000000000, Equal);\n    test::<i128, i64>(-1000000000000, 0, Exact, -1000000000000, Equal);\n\n    test::<i128, i128>(-7999999999999, -3, Down, -999999999999, Greater);\n    test::<i128, i128>(-7999999999999, -3, Up, -1000000000000, Less);\n    test::<i128, i128>(-7999999999999, -3, Floor, -1000000000000, Less);\n    test::<i128, i128>(-7999999999999, -3, Ceiling, -999999999999, Greater);\n    test::<i128, i128>(-7999999999999, -3, Nearest, -1000000000000, Less);\n\n    test::<i128, isize>(-8000000000000, -3, Down, -1000000000000, Equal);\n    test::<i128, isize>(-8000000000000, -3, Up, -1000000000000, Equal);\n    test::<i128, isize>(-8000000000000, -3, Floor, -1000000000000, Equal);\n    test::<i128, isize>(-8000000000000, -3, Ceiling, -1000000000000, Equal);\n    test::<i128, isize>(-8000000000000, -3, Nearest, -1000000000000, Equal);\n    test::<i128, isize>(-8000000000000, -3, Exact, -1000000000000, Equal);\n\n    test::<i64, i8>(-8000000000001, -3, Down, -1000000000000, Greater);\n    test::<i64, i8>(-8000000000001, -3, Up, -1000000000001, Less);\n    test::<i64, i8>(-8000000000001, -3, Floor, -1000000000001, Less);\n    test::<i64, i8>(-8000000000001, -3, Ceiling, -1000000000000, Greater);\n    test::<i64, i8>(-8000000000001, -3, Nearest, -1000000000000, Greater);\n\n    test::<i128, i16>(-16777216000000000000, -24, Down, -1000000000000, Equal);\n    test::<i128, i16>(-16777216000000000000, -24, Up, -1000000000000, Equal);\n    test::<i128, i16>(-16777216000000000000, -24, Floor, -1000000000000, Equal);\n    test::<i128, i16>(-16777216000000000000, -24, Ceiling, -1000000000000, Equal);\n    test::<i128, i16>(-16777216000000000000, -24, Nearest, -1000000000000, Equal);\n    test::<i128, i16>(-16777216000000000000, -24, Exact, -1000000000000, Equal);\n\n    test::<i128, i32>(-33554432000000000000, -25, Down, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, -25, Up, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, -25, Floor, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, -25, Ceiling, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, -25, Nearest, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, -25, Exact, -1000000000000, Equal);\n\n    test::<i128, i64>(-2147483648000000000000, -31, Down, -1000000000000, Equal);\n    test::<i128, i64>(-2147483648000000000000, -31, Up, -1000000000000, Equal);\n    test::<i128, i64>(-2147483648000000000000, -31, Floor, -1000000000000, Equal);\n    test::<i128, i64>(-2147483648000000000000, -31, Ceiling, -1000000000000, Equal);\n    test::<i128, i64>(-2147483648000000000000, -31, Nearest, -1000000000000, Equal);\n    test::<i128, i64>(-2147483648000000000000, -31, Exact, -1000000000000, Equal);\n\n    test::<i128, i128>(-4294967296000000000000, -32, Down, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, -32, Up, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, -32, Floor, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, -32, Ceiling, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, -32, Nearest, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, -32, Exact, -1000000000000, Equal);\n\n    test::<i128, isize>(-8589934592000000000000, -33, Down, -1000000000000, Equal);\n    test::<i128, isize>(-8589934592000000000000, -33, Up, -1000000000000, Equal);\n    test::<i128, isize>(-8589934592000000000000, -33, Floor, -1000000000000, Equal);\n    test::<i128, isize>(-8589934592000000000000, -33, Ceiling, -1000000000000, Equal);\n    test::<i128, isize>(-8589934592000000000000, -33, Nearest, -1000000000000, Equal);\n    test::<i128, isize>(-8589934592000000000000, -33, Exact, -1000000000000, Equal);\n\n    test::<i64, i8>(-1000000000000, -10, Down, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, -10, Up, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, -10, Floor, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, -10, Ceiling, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, -10, Nearest, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, -10, Exact, -976562500, Equal);\n\n    test::<i64, i16>(-980657949, -72, Down, 0, Greater);\n    test::<i64, i16>(-980657949, -72, Up, -1, Less);\n    test::<i64, i16>(-980657949, -72, Floor, -1, Less);\n    test::<i64, i16>(-980657949, -72, Ceiling, 0, Greater);\n    test::<i64, i16>(-980657949, -72, Nearest, 0, Greater);\n\n    test::<i64, i32>(-0xffffffff, -31, Down, -1, Greater);\n    test::<i64, i32>(-0xffffffff, -31, Up, -2, Less);\n    test::<i64, i32>(-0xffffffff, -31, Floor, -2, Less);\n    test::<i64, i32>(-0xffffffff, -31, Ceiling, -1, Greater);\n    test::<i64, i32>(-0xffffffff, -31, Nearest, -2, Less);\n\n    test::<i64, i64>(-0xffffffff, -32, Down, 0, Greater);\n    test::<i64, i64>(-0xffffffff, -32, Up, -1, Less);\n    test::<i64, i64>(-0xffffffff, -32, Floor, -1, Less);\n    test::<i64, i64>(-0xffffffff, -32, Ceiling, 0, Greater);\n    test::<i64, i64>(-0xffffffff, -32, Nearest, -1, Less);\n\n    test::<i64, i128>(-0x100000000, -32, Down, -1, Equal);\n    test::<i64, i128>(-0x100000000, -32, Up, -1, Equal);\n    test::<i64, i128>(-0x100000000, -32, Floor, -1, Equal);\n    test::<i64, i128>(-0x100000000, -32, Ceiling, -1, Equal);\n    test::<i64, i128>(-0x100000000, -32, Nearest, -1, Equal);\n    test::<i64, i128>(-0x100000000, -32, Exact, -1, Equal);\n\n    test::<i64, isize>(-0x100000000, -33, Down, 0, Greater);\n    test::<i64, isize>(-0x100000000, -33, Up, -1, Less);\n    test::<i64, isize>(-0x100000000, -33, Floor, -1, Less);\n    test::<i64, isize>(-0x100000000, -33, Ceiling, 0, Greater);\n    test::<i64, isize>(-0x100000000, -33, Nearest, 0, Greater);\n\n    test::<i16, i8>(-123, 1, Exact, -246, Equal);\n    test::<i16, i16>(-123, 2, Exact, -492, Equal);\n    test::<i64, i8>(-123, 25, Exact, -4127195136, Equal);\n    test::<i64, i16>(-123, 26, Exact, -8254390272, Equal);\n    test::<i64, i32>(-0x80000000, 1, Exact, -0x100000000, Equal);\n    test::<i64, i64>(-1000000000000, 3, Exact, -8000000000000, Equal);\n    test::<i128, i128>(-1000000000000, 24, Exact, -16777216000000000000, Equal);\n    test::<i128, isize>(-1000000000000, 25, Exact, -33554432000000000000, Equal);\n    test::<i128, i8>(-1000000000000, 31, Exact, -2147483648000000000000, Equal);\n    test::<i128, i16>(-1000000000000, 32, Exact, -4294967296000000000000, Equal);\n    test::<i128, i32>(-1000000000000, 33, Exact, -8589934592000000000000, Equal);\n}\n\nfn shl_round_fail_helper<\n    T: PrimitiveInt + ShlRound<U, Output = T> + ShlRoundAssign<U>,\n    U: PrimitiveSigned,\n>() {\n    assert_panic!(T::exact_from(123).shl_round(U::NEGATIVE_ONE, Exact));\n    assert_panic!(T::exact_from(123).shl_round(U::exact_from(-100), Exact));\n    assert_panic!(T::exact_from(123).shl_round_assign(U::NEGATIVE_ONE, Exact));\n    assert_panic!(T::exact_from(123).shl_round_assign(U::exact_from(-100), Exact));\n}\n\n#[test]\nfn shl_round_fail() {\n    apply_fn_to_primitive_ints_and_signeds!(shl_round_fail_helper);\n}\n\nfn shl_round_properties_helper_unsigned_signed<\n    T: ArithmeticCheckedShr<U, Output = T>\n        + PrimitiveUnsigned\n        + ShlRound<U, Output = T>\n        + ShlRoundAssign<U>\n        + ShrRound<U, Output = T>,\n    U: PrimitiveSigned,\n>()\nwhere\n    u64: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    unsigned_signed_rounding_mode_triple_gen_var_2::<T, U>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n;\n        let o = mut_n.shl_round_assign(i, rm);\n        let shifted = mut_n;\n\n        assert_eq!(n.shl_round(i, rm), (shifted, o));\n        if i < U::ZERO {\n            assert!(shifted <= n);\n        }\n        if i != U::MIN {\n            assert_eq!(n.shr_round(-i, rm), (shifted, o));\n        }\n        assert_eq!(\n            i >= U::ZERO || n.divisible_by_power_of_2(u64::exact_from(i.unsigned_abs())),\n            o == Equal\n        );\n        if i < U::ZERO\n            && let Some(m) = shifted.arithmetic_checked_shr(i)\n        {\n            assert_eq!(m.cmp(&n), o);\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.shl_round(i, rm), (shifted, Equal));\n            }\n        } else {\n            assert_panic!(n.shl_round(i, Exact));\n        }\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(n, rm)| {\n        assert_eq!(n.shl_round(U::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<U>().test_properties(|(i, rm)| {\n        assert_eq!(T::ZERO.shl_round(i, rm), (T::ZERO, Equal));\n    });\n}\n\nfn shl_round_properties_helper_signed_signed<\n    T: ArithmeticCheckedShr<U, Output = T>\n        + PrimitiveSigned\n        + ShlRound<U, Output = T>\n        + ShlRoundAssign<U>\n        + ShrRound<U, Output = T>,\n    U: PrimitiveSigned,\n>()\nwhere\n    u64: TryFrom<<U as UnsignedAbs>::Output>,\n{\n    signed_signed_rounding_mode_triple_gen_var_4::<T, U>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n;\n        let o = mut_n.shl_round_assign(i, rm);\n        let shifted = mut_n;\n\n        assert_eq!(n.shl_round(i, rm), (shifted, o));\n        if i < U::ZERO {\n            assert!(shifted.le_abs(&n));\n        }\n        if i != U::MIN {\n            assert_eq!(n.shr_round(-i, rm), (shifted, o));\n        }\n        assert_eq!(\n            i >= U::ZERO || n.divisible_by_power_of_2(u64::exact_from(i.unsigned_abs())),\n            o == Equal\n        );\n        if i < U::ZERO\n            && let Some(m) = shifted.arithmetic_checked_shr(i)\n        {\n            assert_eq!(m.cmp(&n), o);\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.shl_round(i, rm), (shifted, Equal));\n            }\n        } else {\n            assert_panic!(n.shl_round(i, Exact));\n        }\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(n, rm)| {\n        assert_eq!(n.shl_round(U::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<U>().test_properties(|(i, rm)| {\n        assert_eq!(T::ZERO.shl_round(i, rm), (T::ZERO, Equal));\n    });\n}\n\n#[test]\nfn shl_round_properties() {\n    apply_fn_to_unsigneds_and_signeds!(shl_round_properties_helper_unsigned_signed);\n    apply_fn_to_signeds_and_signeds!(shl_round_properties_helper_signed_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, ShlRound, ShrRound, ShrRoundAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, signed_signed_rounding_mode_triple_gen_var_3,\n    signed_unsigned_pair_gen_var_1, signed_unsigned_pair_gen_var_8,\n    signed_unsigned_pair_gen_var_16, signed_unsigned_pair_gen_var_17,\n    signed_unsigned_rounding_mode_triple_gen_var_2, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_14, unsigned_pair_gen_var_21, unsigned_rounding_mode_pair_gen,\n    unsigned_signed_rounding_mode_triple_gen_var_1,\n    unsigned_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_shr_round() {\n    fn test<T: PrimitiveInt + ShrRound<U, Output = T> + ShrRoundAssign<U>, U: PrimitiveInt>(\n        t: T,\n        u: U,\n        rm: RoundingMode,\n        out: T,\n        o: Ordering,\n    ) {\n        assert_eq!(t.shr_round(u, rm), (out, o));\n\n        let mut t = t;\n        assert_eq!(t.shr_round_assign(u, rm), o);\n        assert_eq!(t, out);\n    }\n    test::<u8, u8>(0, 0, Down, 0, Equal);\n    test::<u8, u8>(0, 0, Up, 0, Equal);\n    test::<u8, u8>(0, 0, Floor, 0, Equal);\n    test::<u8, u8>(0, 0, Ceiling, 0, Equal);\n    test::<u8, u8>(0, 0, Nearest, 0, Equal);\n    test::<u8, u8>(0, 0, Exact, 0, Equal);\n\n    test::<u8, i16>(0, 10, Down, 0, Equal);\n    test::<u8, i16>(0, 10, Up, 0, Equal);\n    test::<u8, i16>(0, 10, Floor, 0, Equal);\n    test::<u8, i16>(0, 10, Ceiling, 0, Equal);\n    test::<u8, i16>(0, 10, Nearest, 0, Equal);\n    test::<u8, i16>(0, 10, Exact, 0, Equal);\n\n    test::<i8, u32>(123, 0, Down, 123, Equal);\n    test::<i8, u32>(123, 0, Up, 123, Equal);\n    test::<i8, u32>(123, 0, Floor, 123, Equal);\n    test::<i8, u32>(123, 0, Ceiling, 123, Equal);\n    test::<i8, u32>(123, 0, Nearest, 123, Equal);\n    test::<i8, u32>(123, 0, Exact, 123, Equal);\n\n    test::<u8, u64>(245, 1, Down, 122, Less);\n    test::<u8, u64>(245, 1, Up, 123, Greater);\n    test::<u8, u64>(245, 1, Floor, 122, Less);\n    test::<u8, u64>(245, 1, Ceiling, 123, Greater);\n    test::<u8, u64>(245, 1, Nearest, 122, Less);\n\n    test::<u8, u128>(246, 1, Down, 123, Equal);\n    test::<u8, u128>(246, 1, Up, 123, Equal);\n    test::<u8, u128>(246, 1, Floor, 123, Equal);\n    test::<u8, u128>(246, 1, Ceiling, 123, Equal);\n    test::<u8, u128>(246, 1, Nearest, 123, Equal);\n    test::<u8, u128>(246, 1, Exact, 123, Equal);\n\n    test::<u8, usize>(247, 1, Down, 123, Less);\n    test::<u8, usize>(247, 1, Up, 124, Greater);\n    test::<u8, usize>(247, 1, Floor, 123, Less);\n    test::<u8, usize>(247, 1, Ceiling, 124, Greater);\n    test::<u8, usize>(247, 1, Nearest, 124, Greater);\n\n    test::<i16, i8>(491, 2, Down, 122, Less);\n    test::<i16, i8>(491, 2, Up, 123, Greater);\n    test::<i16, i8>(491, 2, Floor, 122, Less);\n    test::<i16, i8>(491, 2, Ceiling, 123, Greater);\n    test::<i16, i8>(491, 2, Nearest, 123, Greater);\n\n    test::<u16, i16>(492, 2, Down, 123, Equal);\n    test::<u16, i16>(492, 2, Up, 123, Equal);\n    test::<u16, i16>(492, 2, Floor, 123, Equal);\n    test::<u16, i16>(492, 2, Ceiling, 123, Equal);\n    test::<u16, i16>(492, 2, Nearest, 123, Equal);\n    test::<u16, i16>(492, 2, Exact, 123, Equal);\n\n    test::<i16, u32>(493, 2, Down, 123, Less);\n    test::<i16, u32>(493, 2, Up, 124, Greater);\n    test::<i16, u32>(493, 2, Floor, 123, Less);\n    test::<i16, u32>(493, 2, Ceiling, 124, Greater);\n    test::<i16, u32>(493, 2, Nearest, 123, Less);\n\n    test::<u32, i8>(4127195135, 25, Down, 122, Less);\n    test::<u32, i8>(4127195135, 25, Up, 123, Greater);\n    test::<u32, i8>(4127195135, 25, Floor, 122, Less);\n    test::<u32, i8>(4127195135, 25, Ceiling, 123, Greater);\n    test::<u32, i8>(4127195135, 25, Nearest, 123, Greater);\n\n    test::<u32, u16>(4127195136, 25, Down, 123, Equal);\n    test::<u32, u16>(4127195136, 25, Up, 123, Equal);\n    test::<u32, u16>(4127195136, 25, Floor, 123, Equal);\n    test::<u32, u16>(4127195136, 25, Ceiling, 123, Equal);\n    test::<u32, u16>(4127195136, 25, Nearest, 123, Equal);\n    test::<u32, u16>(4127195136, 25, Exact, 123, Equal);\n\n    test::<u32, i32>(4127195137, 25, Down, 123, Less);\n    test::<u32, i32>(4127195137, 25, Up, 124, Greater);\n    test::<u32, i32>(4127195137, 25, Floor, 123, Less);\n    test::<u32, i32>(4127195137, 25, Ceiling, 124, Greater);\n    test::<u32, i32>(4127195137, 25, Nearest, 123, Less);\n\n    test::<i64, u8>(8254390271, 26, Down, 122, Less);\n    test::<i64, u8>(8254390271, 26, Up, 123, Greater);\n    test::<i64, u8>(8254390271, 26, Floor, 122, Less);\n    test::<i64, u8>(8254390271, 26, Ceiling, 123, Greater);\n    test::<i64, u8>(8254390271, 26, Nearest, 123, Greater);\n\n    test::<u64, i16>(8254390272, 26, Down, 123, Equal);\n    test::<u64, i16>(8254390272, 26, Up, 123, Equal);\n    test::<u64, i16>(8254390272, 26, Floor, 123, Equal);\n    test::<u64, i16>(8254390272, 26, Ceiling, 123, Equal);\n    test::<u64, i16>(8254390272, 26, Nearest, 123, Equal);\n    test::<u64, i16>(8254390272, 26, Exact, 123, Equal);\n\n    test::<i64, u32>(8254390273, 26, Down, 123, Less);\n    test::<i64, u32>(8254390273, 26, Up, 124, Greater);\n    test::<i64, u32>(8254390273, 26, Floor, 123, Less);\n    test::<i64, u32>(8254390273, 26, Ceiling, 124, Greater);\n    test::<i64, u32>(8254390273, 26, Nearest, 123, Less);\n\n    test::<i64, i64>(0xffffffff, 1, Down, 0x7fffffff, Less);\n    test::<i64, i64>(0xffffffff, 1, Up, 0x80000000, Greater);\n    test::<i64, i64>(0xffffffff, 1, Floor, 0x7fffffff, Less);\n    test::<i64, i64>(0xffffffff, 1, Ceiling, 0x80000000, Greater);\n    test::<i64, i64>(0xffffffff, 1, Nearest, 0x80000000, Greater);\n\n    test::<u64, u64>(0x100000000, 1, Down, 0x80000000, Equal);\n    test::<u64, u64>(0x100000000, 1, Up, 0x80000000, Equal);\n    test::<u64, u64>(0x100000000, 1, Floor, 0x80000000, Equal);\n    test::<u64, u64>(0x100000000, 1, Ceiling, 0x80000000, Equal);\n    test::<u64, u64>(0x100000000, 1, Nearest, 0x80000000, Equal);\n    test::<u64, u64>(0x100000000, 1, Exact, 0x80000000, Equal);\n\n    test::<u64, i128>(0x100000001, 1, Down, 0x80000000, Less);\n    test::<u64, i128>(0x100000001, 1, Up, 0x80000001, Greater);\n    test::<u64, i128>(0x100000001, 1, Floor, 0x80000000, Less);\n    test::<u64, i128>(0x100000001, 1, Ceiling, 0x80000001, Greater);\n    test::<u64, i128>(0x100000001, 1, Nearest, 0x80000000, Less);\n\n    test::<i64, usize>(1000000000000, 0, Down, 1000000000000, Equal);\n    test::<i64, usize>(1000000000000, 0, Up, 1000000000000, Equal);\n    test::<i64, usize>(1000000000000, 0, Floor, 1000000000000, Equal);\n    test::<i64, usize>(1000000000000, 0, Ceiling, 1000000000000, Equal);\n    test::<i64, usize>(1000000000000, 0, Nearest, 1000000000000, Equal);\n    test::<i64, usize>(1000000000000, 0, Exact, 1000000000000, Equal);\n\n    test::<i128, i8>(7999999999999, 3, Down, 999999999999, Less);\n    test::<i128, i8>(7999999999999, 3, Up, 1000000000000, Greater);\n    test::<i128, i8>(7999999999999, 3, Floor, 999999999999, Less);\n    test::<i128, i8>(7999999999999, 3, Ceiling, 1000000000000, Greater);\n    test::<i128, i8>(7999999999999, 3, Nearest, 1000000000000, Greater);\n\n    test::<u128, u16>(8000000000000, 3, Down, 1000000000000, Equal);\n    test::<u128, u16>(8000000000000, 3, Up, 1000000000000, Equal);\n    test::<u128, u16>(8000000000000, 3, Floor, 1000000000000, Equal);\n    test::<u128, u16>(8000000000000, 3, Ceiling, 1000000000000, Equal);\n    test::<u128, u16>(8000000000000, 3, Nearest, 1000000000000, Equal);\n    test::<u128, u16>(8000000000000, 3, Exact, 1000000000000, Equal);\n\n    test::<u128, i32>(8000000000001, 3, Down, 1000000000000, Less);\n    test::<u128, i32>(8000000000001, 3, Up, 1000000000001, Greater);\n    test::<u128, i32>(8000000000001, 3, Floor, 1000000000000, Less);\n    test::<u128, i32>(8000000000001, 3, Ceiling, 1000000000001, Greater);\n    test::<u128, i32>(8000000000001, 3, Nearest, 1000000000000, Less);\n\n    test::<i128, u64>(1000000000000, 10, Down, 976562500, Equal);\n    test::<i128, u64>(1000000000000, 10, Up, 976562500, Equal);\n    test::<i128, u64>(1000000000000, 10, Floor, 976562500, Equal);\n    test::<i128, u64>(1000000000000, 10, Ceiling, 976562500, Equal);\n    test::<i128, u64>(1000000000000, 10, Nearest, 976562500, Equal);\n    test::<i128, u64>(1000000000000, 10, Exact, 976562500, Equal);\n\n    test::<u128, i128>(980657949, 72, Down, 0, Less);\n    test::<u128, i128>(980657949, 72, Up, 1, Greater);\n    test::<u128, i128>(980657949, 72, Floor, 0, Less);\n    test::<u128, i128>(980657949, 72, Ceiling, 1, Greater);\n    test::<u128, i128>(980657949, 72, Nearest, 0, Less);\n\n    test::<i128, isize>(0xffffffff, 31, Down, 1, Less);\n    test::<i128, isize>(0xffffffff, 31, Up, 2, Greater);\n    test::<i128, isize>(0xffffffff, 31, Floor, 1, Less);\n    test::<i128, isize>(0xffffffff, 31, Ceiling, 2, Greater);\n    test::<i128, isize>(0xffffffff, 31, Nearest, 2, Greater);\n\n    test::<u32, u128>(0xffffffff, 32, Down, 0, Less);\n    test::<u32, u128>(0xffffffff, 32, Up, 1, Greater);\n    test::<u32, u128>(0xffffffff, 32, Floor, 0, Less);\n    test::<u32, u128>(0xffffffff, 32, Ceiling, 1, Greater);\n    test::<u32, u128>(0xffffffff, 32, Nearest, 1, Greater);\n\n    test::<u64, i8>(0x100000000, 32, Down, 1, Equal);\n    test::<u64, i8>(0x100000000, 32, Up, 1, Equal);\n    test::<u64, i8>(0x100000000, 32, Floor, 1, Equal);\n    test::<u64, i8>(0x100000000, 32, Ceiling, 1, Equal);\n    test::<u64, i8>(0x100000000, 32, Nearest, 1, Equal);\n    test::<u64, i8>(0x100000000, 32, Exact, 1, Equal);\n\n    test::<i64, u16>(0x100000000, 33, Down, 0, Less);\n    test::<i64, u16>(0x100000000, 33, Up, 1, Greater);\n    test::<i64, u16>(0x100000000, 33, Floor, 0, Less);\n    test::<i64, u16>(0x100000000, 33, Ceiling, 1, Greater);\n    test::<i64, u16>(0x100000000, 33, Nearest, 0, Less);\n\n    test::<u8, i8>(0, -10, Exact, 0, Equal);\n    test::<u8, i16>(123, -1, Exact, 246, Equal);\n    test::<u16, i32>(123, -2, Exact, 492, Equal);\n    test::<u64, i64>(123, -25, Exact, 4127195136, Equal);\n    test::<u128, i128>(123, -26, Exact, 8254390272, Equal);\n    test::<u8, isize>(123, -100, Exact, 0, Equal);\n\n    test::<u64, i8>(0x80000000, -1, Exact, 0x100000000, Equal);\n    test::<i64, i16>(1000000000000, -3, Exact, 8000000000000, Equal);\n    test::<u64, i8>(1000000000000, -24, Exact, 16777216000000000000, Equal);\n    test::<i128, i16>(1000000000000, -25, Exact, 33554432000000000000, Equal);\n    test::<u128, i32>(1000000000000, -31, Exact, 2147483648000000000000, Equal);\n    test::<i128, i64>(1000000000000, -32, Exact, 4294967296000000000000, Equal);\n    test::<u128, i128>(1000000000000, -33, Exact, 8589934592000000000000, Equal);\n    test::<i64, isize>(1000000000000, -100, Exact, 0, Equal);\n\n    test::<i8, u8>(-123, 0, Down, -123, Equal);\n    test::<i8, u8>(-123, 0, Up, -123, Equal);\n    test::<i8, u8>(-123, 0, Floor, -123, Equal);\n    test::<i8, u8>(-123, 0, Ceiling, -123, Equal);\n    test::<i8, u8>(-123, 0, Nearest, -123, Equal);\n    test::<i8, u8>(-123, 0, Exact, -123, Equal);\n\n    test::<i16, i8>(-245, 1, Down, -122, Greater);\n    test::<i16, i8>(-245, 1, Up, -123, Less);\n    test::<i16, i8>(-245, 1, Floor, -123, Less);\n    test::<i16, i8>(-245, 1, Ceiling, -122, Greater);\n    test::<i16, i8>(-245, 1, Nearest, -122, Greater);\n\n    test::<i16, u16>(-246, 1, Down, -123, Equal);\n    test::<i16, u16>(-246, 1, Up, -123, Equal);\n    test::<i16, u16>(-246, 1, Floor, -123, Equal);\n    test::<i16, u16>(-246, 1, Ceiling, -123, Equal);\n    test::<i16, u16>(-246, 1, Nearest, -123, Equal);\n    test::<i16, u16>(-246, 1, Exact, -123, Equal);\n\n    test::<i16, i32>(-247, 1, Down, -123, Greater);\n    test::<i16, i32>(-247, 1, Up, -124, Less);\n    test::<i16, i32>(-247, 1, Floor, -124, Less);\n    test::<i16, i32>(-247, 1, Ceiling, -123, Greater);\n    test::<i16, i32>(-247, 1, Nearest, -124, Less);\n\n    test::<i16, u64>(-491, 2, Down, -122, Greater);\n    test::<i16, u64>(-491, 2, Up, -123, Less);\n    test::<i16, u64>(-491, 2, Floor, -123, Less);\n    test::<i16, u64>(-491, 2, Ceiling, -122, Greater);\n    test::<i16, u64>(-491, 2, Nearest, -123, Less);\n\n    test::<i16, i128>(-492, 2, Down, -123, Equal);\n    test::<i16, i128>(-492, 2, Up, -123, Equal);\n    test::<i16, i128>(-492, 2, Floor, -123, Equal);\n    test::<i16, i128>(-492, 2, Ceiling, -123, Equal);\n    test::<i16, i128>(-492, 2, Nearest, -123, Equal);\n    test::<i16, i128>(-492, 2, Exact, -123, Equal);\n\n    test::<i16, usize>(-493, 2, Down, -123, Greater);\n    test::<i16, usize>(-493, 2, Up, -124, Less);\n    test::<i16, usize>(-493, 2, Floor, -124, Less);\n    test::<i16, usize>(-493, 2, Ceiling, -123, Greater);\n    test::<i16, usize>(-493, 2, Nearest, -123, Greater);\n\n    test::<i64, i8>(-4127195135, 25, Down, -122, Greater);\n    test::<i64, i8>(-4127195135, 25, Up, -123, Less);\n    test::<i64, i8>(-4127195135, 25, Floor, -123, Less);\n    test::<i64, i8>(-4127195135, 25, Ceiling, -122, Greater);\n    test::<i64, i8>(-4127195135, 25, Nearest, -123, Less);\n\n    test::<i64, u16>(-4127195136, 25, Down, -123, Equal);\n    test::<i64, u16>(-4127195136, 25, Up, -123, Equal);\n    test::<i64, u16>(-4127195136, 25, Floor, -123, Equal);\n    test::<i64, u16>(-4127195136, 25, Ceiling, -123, Equal);\n    test::<i64, u16>(-4127195136, 25, Nearest, -123, Equal);\n    test::<i64, u16>(-4127195136, 25, Exact, -123, Equal);\n\n    test::<i64, i32>(-4127195137, 25, Down, -123, Greater);\n    test::<i64, i32>(-4127195137, 25, Up, -124, Less);\n    test::<i64, i32>(-4127195137, 25, Floor, -124, Less);\n    test::<i64, i32>(-4127195137, 25, Ceiling, -123, Greater);\n    test::<i64, i32>(-4127195137, 25, Nearest, -123, Greater);\n\n    test::<i64, u64>(-8254390271, 26, Down, -122, Greater);\n    test::<i64, u64>(-8254390271, 26, Up, -123, Less);\n    test::<i64, u64>(-8254390271, 26, Floor, -123, Less);\n    test::<i64, u64>(-8254390271, 26, Ceiling, -122, Greater);\n    test::<i64, u64>(-8254390271, 26, Nearest, -123, Less);\n\n    test::<i64, i128>(-8254390272, 26, Down, -123, Equal);\n    test::<i64, i128>(-8254390272, 26, Up, -123, Equal);\n    test::<i64, i128>(-8254390272, 26, Floor, -123, Equal);\n    test::<i64, i128>(-8254390272, 26, Ceiling, -123, Equal);\n    test::<i64, i128>(-8254390272, 26, Nearest, -123, Equal);\n    test::<i64, i128>(-8254390272, 26, Exact, -123, Equal);\n\n    test::<i64, usize>(-8254390273, 26, Down, -123, Greater);\n    test::<i64, usize>(-8254390273, 26, Up, -124, Less);\n    test::<i64, usize>(-8254390273, 26, Floor, -124, Less);\n    test::<i64, usize>(-8254390273, 26, Ceiling, -123, Greater);\n    test::<i64, usize>(-8254390273, 26, Nearest, -123, Greater);\n\n    test::<i128, i8>(-0xffffffff, 1, Down, -0x7fffffff, Greater);\n    test::<i128, i8>(-0xffffffff, 1, Up, -0x80000000, Less);\n    test::<i128, i8>(-0xffffffff, 1, Floor, -0x80000000, Less);\n    test::<i128, i8>(-0xffffffff, 1, Ceiling, -0x7fffffff, Greater);\n    test::<i128, i8>(-0xffffffff, 1, Nearest, -0x80000000, Less);\n\n    test::<i128, u16>(-0x100000000, 1, Down, -0x80000000, Equal);\n    test::<i128, u16>(-0x100000000, 1, Up, -0x80000000, Equal);\n    test::<i128, u16>(-0x100000000, 1, Floor, -0x80000000, Equal);\n    test::<i128, u16>(-0x100000000, 1, Ceiling, -0x80000000, Equal);\n    test::<i128, u16>(-0x100000000, 1, Nearest, -0x80000000, Equal);\n    test::<i128, u16>(-0x100000000, 1, Exact, -0x80000000, Equal);\n\n    test::<i128, i32>(-0x100000001, 1, Down, -0x80000000, Greater);\n    test::<i128, i32>(-0x100000001, 1, Up, -0x80000001, Less);\n    test::<i128, i32>(-0x100000001, 1, Floor, -0x80000001, Less);\n    test::<i128, i32>(-0x100000001, 1, Ceiling, -0x80000000, Greater);\n    test::<i128, i32>(-0x100000001, 1, Nearest, -0x80000000, Greater);\n\n    test::<i128, u64>(-1000000000000, 0, Down, -1000000000000, Equal);\n    test::<i128, u64>(-1000000000000, 0, Up, -1000000000000, Equal);\n    test::<i128, u64>(-1000000000000, 0, Floor, -1000000000000, Equal);\n    test::<i128, u64>(-1000000000000, 0, Ceiling, -1000000000000, Equal);\n    test::<i128, u64>(-1000000000000, 0, Nearest, -1000000000000, Equal);\n    test::<i128, u64>(-1000000000000, 0, Exact, -1000000000000, Equal);\n\n    test::<i128, i128>(-7999999999999, 3, Down, -999999999999, Greater);\n    test::<i128, i128>(-7999999999999, 3, Up, -1000000000000, Less);\n    test::<i128, i128>(-7999999999999, 3, Floor, -1000000000000, Less);\n    test::<i128, i128>(-7999999999999, 3, Ceiling, -999999999999, Greater);\n    test::<i128, i128>(-7999999999999, 3, Nearest, -1000000000000, Less);\n\n    test::<i128, usize>(-8000000000000, 3, Down, -1000000000000, Equal);\n    test::<i128, usize>(-8000000000000, 3, Up, -1000000000000, Equal);\n    test::<i128, usize>(-8000000000000, 3, Floor, -1000000000000, Equal);\n    test::<i128, usize>(-8000000000000, 3, Ceiling, -1000000000000, Equal);\n    test::<i128, usize>(-8000000000000, 3, Nearest, -1000000000000, Equal);\n    test::<i128, usize>(-8000000000000, 3, Exact, -1000000000000, Equal);\n\n    test::<i64, i8>(-8000000000001, 3, Down, -1000000000000, Greater);\n    test::<i64, i8>(-8000000000001, 3, Up, -1000000000001, Less);\n    test::<i64, i8>(-8000000000001, 3, Floor, -1000000000001, Less);\n    test::<i64, i8>(-8000000000001, 3, Ceiling, -1000000000000, Greater);\n    test::<i64, i8>(-8000000000001, 3, Nearest, -1000000000000, Greater);\n\n    test::<i128, u16>(-16777216000000000000, 24, Down, -1000000000000, Equal);\n    test::<i128, u16>(-16777216000000000000, 24, Up, -1000000000000, Equal);\n    test::<i128, u16>(-16777216000000000000, 24, Floor, -1000000000000, Equal);\n    test::<i128, u16>(-16777216000000000000, 24, Ceiling, -1000000000000, Equal);\n    test::<i128, u16>(-16777216000000000000, 24, Nearest, -1000000000000, Equal);\n    test::<i128, u16>(-16777216000000000000, 24, Exact, -1000000000000, Equal);\n\n    test::<i128, i32>(-33554432000000000000, 25, Down, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, 25, Up, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, 25, Floor, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, 25, Ceiling, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, 25, Nearest, -1000000000000, Equal);\n    test::<i128, i32>(-33554432000000000000, 25, Exact, -1000000000000, Equal);\n\n    test::<i128, u64>(-2147483648000000000000, 31, Down, -1000000000000, Equal);\n    test::<i128, u64>(-2147483648000000000000, 31, Up, -1000000000000, Equal);\n    test::<i128, u64>(-2147483648000000000000, 31, Floor, -1000000000000, Equal);\n    test::<i128, u64>(-2147483648000000000000, 31, Ceiling, -1000000000000, Equal);\n    test::<i128, u64>(-2147483648000000000000, 31, Nearest, -1000000000000, Equal);\n    test::<i128, u64>(-2147483648000000000000, 31, Exact, -1000000000000, Equal);\n\n    test::<i128, i128>(-4294967296000000000000, 32, Down, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, 32, Up, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, 32, Floor, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, 32, Ceiling, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, 32, Nearest, -1000000000000, Equal);\n    test::<i128, i128>(-4294967296000000000000, 32, Exact, -1000000000000, Equal);\n\n    test::<i128, usize>(-8589934592000000000000, 33, Down, -1000000000000, Equal);\n    test::<i128, usize>(-8589934592000000000000, 33, Up, -1000000000000, Equal);\n    test::<i128, usize>(-8589934592000000000000, 33, Floor, -1000000000000, Equal);\n    test::<i128, usize>(-8589934592000000000000, 33, Ceiling, -1000000000000, Equal);\n    test::<i128, usize>(-8589934592000000000000, 33, Nearest, -1000000000000, Equal);\n    test::<i128, usize>(-8589934592000000000000, 33, Exact, -1000000000000, Equal);\n\n    test::<i64, i8>(-1000000000000, 10, Down, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, 10, Up, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, 10, Floor, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, 10, Ceiling, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, 10, Nearest, -976562500, Equal);\n    test::<i64, i8>(-1000000000000, 10, Exact, -976562500, Equal);\n\n    test::<i64, u16>(-980657949, 72, Down, 0, Greater);\n    test::<i64, u16>(-980657949, 72, Up, -1, Less);\n    test::<i64, u16>(-980657949, 72, Floor, -1, Less);\n    test::<i64, u16>(-980657949, 72, Ceiling, 0, Greater);\n    test::<i64, u16>(-980657949, 72, Nearest, 0, Greater);\n\n    test::<i64, i32>(-0xffffffff, 31, Down, -1, Greater);\n    test::<i64, i32>(-0xffffffff, 31, Up, -2, Less);\n    test::<i64, i32>(-0xffffffff, 31, Floor, -2, Less);\n    test::<i64, i32>(-0xffffffff, 31, Ceiling, -1, Greater);\n    test::<i64, i32>(-0xffffffff, 31, Nearest, -2, Less);\n\n    test::<i64, u64>(-0xffffffff, 32, Down, 0, Greater);\n    test::<i64, u64>(-0xffffffff, 32, Up, -1, Less);\n    test::<i64, u64>(-0xffffffff, 32, Floor, -1, Less);\n    test::<i64, u64>(-0xffffffff, 32, Ceiling, 0, Greater);\n    test::<i64, u64>(-0xffffffff, 32, Nearest, -1, Less);\n\n    test::<i64, i128>(-0x100000000, 32, Down, -1, Equal);\n    test::<i64, i128>(-0x100000000, 32, Up, -1, Equal);\n    test::<i64, i128>(-0x100000000, 32, Floor, -1, Equal);\n    test::<i64, i128>(-0x100000000, 32, Ceiling, -1, Equal);\n    test::<i64, i128>(-0x100000000, 32, Nearest, -1, Equal);\n    test::<i64, i128>(-0x100000000, 32, Exact, -1, Equal);\n\n    test::<i64, usize>(-0x100000000, 33, Down, 0, Greater);\n    test::<i64, usize>(-0x100000000, 33, Up, -1, Less);\n    test::<i64, usize>(-0x100000000, 33, Floor, -1, Less);\n    test::<i64, usize>(-0x100000000, 33, Ceiling, 0, Greater);\n    test::<i64, usize>(-0x100000000, 33, Nearest, 0, Greater);\n\n    test::<i16, i8>(-123, -1, Exact, -246, Equal);\n    test::<i16, i16>(-123, -2, Exact, -492, Equal);\n    test::<i64, i8>(-123, -25, Exact, -4127195136, Equal);\n    test::<i64, i16>(-123, -26, Exact, -8254390272, Equal);\n    test::<i64, i32>(-0x80000000, -1, Exact, -0x100000000, Equal);\n    test::<i64, i64>(-1000000000000, -3, Exact, -8000000000000, Equal);\n    test::<i128, i128>(-1000000000000, -24, Exact, -16777216000000000000, Equal);\n    test::<i128, isize>(-1000000000000, -25, Exact, -33554432000000000000, Equal);\n    test::<i128, i8>(-1000000000000, -31, Exact, -2147483648000000000000, Equal);\n    test::<i128, i16>(-1000000000000, -32, Exact, -4294967296000000000000, Equal);\n    test::<i128, i32>(-1000000000000, -33, Exact, -8589934592000000000000, Equal);\n}\n\nfn shr_round_fail_helper<\n    T: PrimitiveInt + ShrRound<U, Output = T> + ShrRoundAssign<U>,\n    U: PrimitiveInt,\n>() {\n    assert_panic!(T::exact_from(123).shr_round(U::ONE, Exact));\n    assert_panic!(T::exact_from(123).shr_round(U::exact_from(100), Exact));\n    assert_panic!(T::exact_from(123).shr_round_assign(U::ONE, Exact));\n    assert_panic!(T::exact_from(123).shr_round_assign(U::exact_from(100), Exact));\n}\n\n#[test]\nfn shr_round_fail() {\n    apply_fn_to_primitive_ints_and_primitive_ints!(shr_round_fail_helper);\n}\n\nfn shr_round_properties_helper_unsigned_unsigned<\n    T: ArithmeticCheckedShl<U, Output = T>\n        + PrimitiveUnsigned\n        + ShrRound<U, Output = T>\n        + ShrRoundAssign<U>,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_unsigned_rounding_mode_triple_gen_var_4::<T, U>().test_properties(|(n, u, rm)| {\n        let mut mut_n = n;\n        let o = mut_n.shr_round_assign(u, rm);\n        let shifted = mut_n;\n\n        assert_eq!(n.shr_round(u, rm), (shifted, o));\n        assert!(shifted <= n);\n        assert_eq!(n.divisible_by_power_of_2(u.exact_into()), o == Equal);\n        if let Some(m) = shifted.arithmetic_checked_shl(u) {\n            assert_eq!(m.cmp(&n), o);\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.shr_round(u, rm), (shifted, Equal));\n            }\n        } else {\n            assert_panic!(n.shr_round(u, Exact));\n        }\n    });\n\n    unsigned_pair_gen_var_2::<T, U>().test_properties(|(n, u)| {\n        if u < U::exact_from(T::WIDTH) {\n            let no = (n, Equal);\n            if let Some(shifted) = n.arithmetic_checked_shl(u) {\n                assert_eq!(shifted.shr_round(u, Down), no);\n                assert_eq!(shifted.shr_round(u, Up), no);\n                assert_eq!(shifted.shr_round(u, Floor), no);\n                assert_eq!(shifted.shr_round(u, Ceiling), no);\n                assert_eq!(shifted.shr_round(u, Nearest), no);\n                assert_eq!(shifted.shr_round(u, Exact), no);\n            }\n        }\n    });\n\n    unsigned_pair_gen_var_14::<T, U>().test_properties(|(n, u)| {\n        let down = n.shr_round(u, Down);\n        assert_eq!(down.1, Less);\n        if let Some(up) = down.0.checked_add(T::ONE) {\n            let up = (up, Greater);\n            assert_eq!(n.shr_round(u, Up), up);\n            assert_eq!(n.shr_round(u, Floor), down);\n            assert_eq!(n.shr_round(u, Ceiling), up);\n            let nearest = n.shr_round(u, Nearest);\n            assert!(nearest == down || nearest == up);\n        }\n    });\n\n    unsigned_pair_gen_var_21::<T, U>().test_properties(|(t, u)| {\n        if let Some(shift) = u.checked_add(U::exact_from(T::WIDTH)) {\n            assert_eq!(t.shr_round(shift, Down), (T::ZERO, Less));\n            assert_eq!(t.shr_round(shift, Floor), (T::ZERO, Less));\n            assert_eq!(t.shr_round(shift, Up), (T::ONE, Greater));\n            assert_eq!(t.shr_round(shift, Ceiling), (T::ONE, Greater));\n            if let Some(extra_shift) = shift.checked_add(U::ONE) {\n                assert_eq!(t.shr_round(extra_shift, Nearest), (T::ZERO, Less));\n            }\n        }\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(n, rm)| {\n        assert_eq!(n.shr_round(U::ZERO, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen::<U>().test_properties(|(u, rm)| {\n        assert_eq!(T::ZERO.shr_round(u, rm), (T::ZERO, Equal));\n    });\n}\n\nfn shr_round_properties_helper_unsigned_signed<\n    T: ArithmeticCheckedShl<U, Output = T>\n        + PrimitiveUnsigned\n        + ShlRound<U, Output = T>\n        + ShrRound<U, Output = T>\n        + ShrRoundAssign<U>,\n    U: PrimitiveSigned,\n>() {\n    unsigned_signed_rounding_mode_triple_gen_var_1::<T, U>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n;\n        let o = mut_n.shr_round_assign(i, rm);\n        let shifted = mut_n;\n\n        assert_eq!(n.shr_round(i, rm), (shifted, o));\n        if i >= U::ZERO {\n            assert!(shifted <= n);\n        }\n        if i != U::MIN {\n            assert_eq!(n.shl_round(-i, rm), (shifted, o));\n        }\n        assert_eq!(\n            i <= U::ZERO || n.divisible_by_power_of_2(i.exact_into()),\n            o == Equal\n        );\n        if i >= U::ZERO\n            && let Some(m) = shifted.arithmetic_checked_shl(i)\n        {\n            assert_eq!(m.cmp(&n), o);\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.shr_round(i, rm), (shifted, Equal));\n            }\n        } else {\n            assert_panic!(n.shr_round(i, Exact));\n        }\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(n, rm)| {\n        assert_eq!(n.shr_round(U::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<U>().test_properties(|(i, rm)| {\n        assert_eq!(T::ZERO.shr_round(i, rm), (T::ZERO, Equal));\n    });\n}\n\nfn shr_round_properties_helper_signed_unsigned<\n    V: PrimitiveUnsigned,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: ArithmeticCheckedShl<V, Output = S>\n        + PrimitiveSigned\n        + ShrRound<V, Output = S>\n        + ShrRoundAssign<V>\n        + WrappingFrom<U>,\n>() {\n    signed_unsigned_rounding_mode_triple_gen_var_2::<S, V>().test_properties(|(n, u, rm)| {\n        let mut mut_n = n;\n        let o = mut_n.shr_round_assign(u, rm);\n        let shifted = mut_n;\n        assert_eq!(n.shr_round(u, rm), (shifted, o));\n\n        assert!(shifted.le_abs(&n));\n        if n != S::MIN {\n            let (x, o_alt) = (-n).shr_round(u, -rm);\n            if x != S::MIN {\n                assert_eq!(-x, shifted);\n            }\n            assert_eq!(o_alt, o.reverse());\n        }\n        assert_eq!(n.divisible_by_power_of_2(u.exact_into()), o == Equal);\n        if let Some(m) = shifted.arithmetic_checked_shl(u) {\n            assert_eq!(m.cmp(&n), o);\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.shr_round(u, rm), (shifted, Equal));\n            }\n        } else {\n            assert_panic!(n.shr_round(u, Exact));\n        }\n    });\n\n    signed_unsigned_pair_gen_var_1::<S, V>().test_properties(|(n, u)| {\n        if u < V::exact_from(S::WIDTH) {\n            let no = (n, Equal);\n            if let Some(shifted) = n.arithmetic_checked_shl(u) {\n                assert_eq!(shifted.shr_round(u, Down), no);\n                assert_eq!(shifted.shr_round(u, Up), no);\n                assert_eq!(shifted.shr_round(u, Floor), no);\n                assert_eq!(shifted.shr_round(u, Ceiling), no);\n                assert_eq!(shifted.shr_round(u, Nearest), no);\n                assert_eq!(shifted.shr_round(u, Exact), no);\n            }\n        }\n    });\n\n    signed_unsigned_pair_gen_var_8::<S, V>().test_properties(|(n, u)| {\n        let floor = n.shr_round(u, Floor);\n        assert_eq!(floor.1, Less);\n        if let Some(ceiling) = floor.0.checked_add(S::ONE) {\n            let ceiling = (ceiling, Greater);\n            assert_eq!(n.shr_round(u, Ceiling), ceiling);\n            if n >= S::ZERO {\n                assert_eq!(n.shr_round(u, Up), ceiling);\n                assert_eq!(n.shr_round(u, Down), floor);\n            } else {\n                assert_eq!(n.shr_round(u, Up), floor);\n                assert_eq!(n.shr_round(u, Down), ceiling);\n            }\n            let nearest = n.shr_round(u, Nearest);\n            assert!(nearest == floor || nearest == ceiling);\n        }\n    });\n\n    signed_unsigned_pair_gen_var_16::<S, V>().test_properties(|(i, u)| {\n        if let Some(shift) = u.checked_add(V::exact_from(S::WIDTH - 1)) {\n            assert_eq!(i.shr_round(shift, Down), (S::ZERO, Less));\n            assert_eq!(i.shr_round(shift, Floor), (S::ZERO, Less));\n            assert_eq!(i.shr_round(shift, Up), (S::ONE, Greater));\n            assert_eq!(i.shr_round(shift, Ceiling), (S::ONE, Greater));\n            if let Some(extra_shift) = shift.checked_add(V::ONE) {\n                assert_eq!(i.shr_round(extra_shift, Nearest), (S::ZERO, Less));\n            }\n        }\n    });\n\n    signed_unsigned_pair_gen_var_17::<U, S, V>().test_properties(|(i, u)| {\n        if let Some(shift) = u.checked_add(V::exact_from(S::WIDTH - 1)) {\n            assert_eq!(i.shr_round(shift, Down), (S::ZERO, Greater));\n            assert_eq!(i.shr_round(shift, Floor), (S::NEGATIVE_ONE, Less));\n            assert_eq!(i.shr_round(shift, Up), (S::NEGATIVE_ONE, Less));\n            assert_eq!(i.shr_round(shift, Ceiling), (S::ZERO, Greater));\n            if let Some(extra_shift) = shift.checked_add(V::ONE) {\n                assert_eq!(i.shr_round(extra_shift, Nearest), (S::ZERO, Greater));\n            }\n        }\n    });\n\n    signed_rounding_mode_pair_gen::<S>().test_properties(|(n, rm)| {\n        assert_eq!(n.shr_round(V::ZERO, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen::<V>().test_properties(|(u, rm)| {\n        assert_eq!(S::ZERO.shr_round(u, rm), (S::ZERO, Equal));\n    });\n}\n\nfn shr_round_properties_helper_signed_signed<\n    T: ArithmeticCheckedShl<U, Output = T>\n        + PrimitiveSigned\n        + ShlRound<U, Output = T>\n        + ShrRound<U, Output = T>\n        + ShrRoundAssign<U>,\n    U: PrimitiveSigned,\n>() {\n    signed_signed_rounding_mode_triple_gen_var_3::<T, U>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n;\n        let o = mut_n.shr_round_assign(i, rm);\n        let shifted = mut_n;\n\n        assert_eq!(n.shr_round(i, rm), (shifted, o));\n        if i >= U::ZERO {\n            assert!(shifted.le_abs(&n));\n        }\n        if i != U::MIN {\n            assert_eq!(n.shl_round(-i, rm), (shifted, o));\n        }\n        assert_eq!(\n            i <= U::ZERO || n.divisible_by_power_of_2(i.exact_into()),\n            o == Equal\n        );\n        if i >= U::ZERO\n            && let Some(m) = shifted.arithmetic_checked_shl(i)\n        {\n            assert_eq!(m.cmp(&n), o);\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(n.shr_round(i, rm), (shifted, Equal));\n            }\n        } else {\n            assert_panic!(n.shr_round(i, Exact));\n        }\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(n, rm)| {\n        assert_eq!(n.shr_round(U::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<U>().test_properties(|(i, rm)| {\n        assert_eq!(T::ZERO.shr_round(i, rm), (T::ZERO, Equal));\n    });\n}\n\n#[test]\nfn shr_round_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(shr_round_properties_helper_unsigned_unsigned);\n    apply_fn_to_unsigneds_and_signeds!(shr_round_properties_helper_unsigned_signed);\n    apply_fn_to_unsigneds_and_unsigned_signed_pairs!(shr_round_properties_helper_signed_unsigned);\n    apply_fn_to_signeds_and_signeds!(shr_round_properties_helper_signed_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen, unsigned_gen};\nuse std::cmp::Ordering::*;\n\nfn sign_helper_primitive_int<T: PrimitiveInt>() {\n    let test = |n: T, out| {\n        assert_eq!(n.sign(), out);\n    };\n    test(T::ZERO, Equal);\n    test(T::ONE, Greater);\n    test(T::exact_from(100), Greater);\n    test(T::MAX, Greater);\n}\n\nfn sign_helper_signed<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.sign(), out);\n    };\n    test(T::NEGATIVE_ONE, Less);\n    test(T::exact_from(-100), Less);\n    test(T::MIN, Less);\n}\n\nfn sign_helper_primitive_float<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(n.sign(), out);\n    };\n    test(T::ZERO, Greater);\n    test(T::NEGATIVE_ZERO, Less);\n    test(T::ONE, Greater);\n    test(T::NEGATIVE_ONE, Less);\n    test(T::INFINITY, Greater);\n    test(T::NEGATIVE_INFINITY, Less);\n    test(T::NAN, Equal);\n}\n\n#[test]\nfn test_sign() {\n    apply_fn_to_primitive_ints!(sign_helper_primitive_int);\n    apply_fn_to_signeds!(sign_helper_signed);\n    apply_fn_to_primitive_floats!(sign_helper_primitive_float);\n}\n\nfn sign_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let sign = n.sign();\n        assert_ne!(sign, Less);\n        assert_eq!(n.partial_cmp(&T::ZERO), Some(sign));\n    });\n}\n\nfn sign_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|n| {\n        let sign = n.sign();\n        assert_eq!(n.partial_cmp(&T::ZERO), Some(sign));\n        if n != T::MIN {\n            assert_eq!((-n).sign(), sign.reverse());\n        }\n    });\n}\n\nfn sign_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|f| {\n        let sign = f.sign();\n        if !f.is_nan() {\n            assert_eq!((-f).sign(), sign.reverse());\n        }\n    });\n}\n\n#[test]\nfn sign_properties() {\n    apply_fn_to_unsigneds!(sign_properties_helper_unsigned);\n    apply_fn_to_signeds!(sign_properties_helper_signed);\n    apply_fn_to_primitive_floats!(sign_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::sqrt::sqrt_rem_newton;\nuse malachite_base::num::arithmetic::sqrt::{\n    ceiling_sqrt_binary, checked_sqrt_binary, floor_sqrt_binary, sqrt_rem_binary,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, signed_gen_var_2, unsigned_gen, unsigned_gen_var_17,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_sqrt_rem_newton() {\n    fn test<U: PrimitiveUnsigned + WrappingFrom<S>, S: PrimitiveSigned + WrappingFrom<U>>(\n        n: U,\n        sqrt: U,\n        rem: U,\n    ) {\n        let (actual_sqrt, actual_rem) = sqrt_rem_newton::<U, S>(n);\n        assert_eq!(actual_sqrt, sqrt);\n        assert_eq!(actual_rem, rem);\n        assert_eq!(n.sqrt_rem(), (sqrt, rem));\n    }\n    // - no initial underestimate\n    test::<u32, i32>(2000000000, 44721, 32159);\n    test::<u32, i32>(u32::MAX, 65535, 131070);\n    // - initial underestimate\n    test::<u32, i32>(1073741824, 32768, 0);\n\n    test::<u64, i64>(10000000000000000000, 3162277660, 1064924400);\n    test::<u64, i64>(u64::MAX, 4294967295, 8589934590);\n}\n\n#[test]\nfn sqrt_rem_newton_fail() {\n    assert_panic!(sqrt_rem_newton::<u32, i32>(1));\n    assert_panic!(sqrt_rem_newton::<u64, i64>(1));\n}\n\n#[test]\nfn test_floor_sqrt() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, out: T) {\n        assert_eq!(n.floor_sqrt(), out);\n        assert_eq!(floor_sqrt_binary(n), out);\n\n        let mut n = n;\n        n.floor_sqrt_assign();\n        assert_eq!(n, out);\n    }\n    test_u::<u8>(0, 0);\n    test_u::<u8>(1, 1);\n    test_u::<u8>(2, 1);\n    test_u::<u8>(3, 1);\n    test_u::<u8>(4, 2);\n    test_u::<u8>(5, 2);\n    test_u::<u8>(10, 3);\n    test_u::<u8>(100, 10);\n    test_u::<u32>(1000000000, 31622);\n    test_u::<u64>(152415765279683, 12345677);\n    test_u::<u64>(152415765279684, 12345678);\n    test_u::<u64>(152415765279685, 12345678);\n\n    fn test_i<T: PrimitiveSigned>(n: T, out: T) {\n        assert_eq!(n.floor_sqrt(), out);\n\n        let mut n = n;\n        n.floor_sqrt_assign();\n        assert_eq!(n, out);\n    }\n    test_i::<i8>(0, 0);\n    test_i::<i8>(1, 1);\n    test_i::<i8>(2, 1);\n    test_i::<i8>(3, 1);\n    test_i::<i8>(4, 2);\n    test_i::<i8>(5, 2);\n    test_i::<i8>(10, 3);\n    test_i::<i8>(100, 10);\n    test_i::<i32>(1000000000, 31622);\n    test_i::<i64>(152415765279683, 12345677);\n    test_i::<i64>(152415765279684, 12345678);\n    test_i::<i64>(152415765279685, 12345678);\n}\n\nfn floor_sqrt_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::NEGATIVE_ONE.floor_sqrt());\n}\n\n#[test]\npub fn floor_sqrt_fail() {\n    apply_fn_to_signeds!(floor_sqrt_fail_helper);\n}\n\n#[test]\nfn test_ceiling_sqrt() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, out: T) {\n        assert_eq!(n.ceiling_sqrt(), out);\n        assert_eq!(ceiling_sqrt_binary(n), out);\n\n        let mut n = n;\n        n.ceiling_sqrt_assign();\n        assert_eq!(n, out);\n    }\n    test_u::<u8>(0, 0);\n    test_u::<u8>(1, 1);\n    test_u::<u8>(2, 2);\n    test_u::<u8>(3, 2);\n    test_u::<u8>(4, 2);\n    test_u::<u8>(5, 3);\n    test_u::<u8>(10, 4);\n    test_u::<u8>(100, 10);\n    test_u::<u32>(1000000000, 31623);\n    test_u::<u64>(152415765279683, 12345678);\n    test_u::<u64>(152415765279684, 12345678);\n    test_u::<u64>(152415765279685, 12345679);\n\n    fn test_i<T: PrimitiveSigned>(n: T, out: T) {\n        assert_eq!(n.ceiling_sqrt(), out);\n\n        let mut n = n;\n        n.ceiling_sqrt_assign();\n        assert_eq!(n, out);\n    }\n    test_i::<i8>(0, 0);\n    test_i::<i8>(1, 1);\n    test_i::<i8>(2, 2);\n    test_i::<i8>(3, 2);\n    test_i::<i8>(4, 2);\n    test_i::<i8>(5, 3);\n    test_i::<i8>(10, 4);\n    test_i::<i8>(100, 10);\n    test_i::<i32>(1000000000, 31623);\n    test_i::<i64>(152415765279683, 12345678);\n    test_i::<i64>(152415765279684, 12345678);\n    test_i::<i64>(152415765279685, 12345679);\n}\n\nfn ceiling_sqrt_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::NEGATIVE_ONE.ceiling_sqrt());\n}\n\n#[test]\npub fn ceiling_sqrt_fail() {\n    apply_fn_to_signeds!(ceiling_sqrt_fail_helper);\n}\n\n#[test]\nfn test_checked_sqrt() {\n    fn test_u<T: PrimitiveUnsigned>(n: T, out: Option<T>) {\n        assert_eq!(n.checked_sqrt(), out);\n        assert_eq!(checked_sqrt_binary(n), out);\n    }\n    test_u::<u8>(0, Some(0));\n    test_u::<u8>(1, Some(1));\n    test_u::<u8>(2, None);\n    test_u::<u8>(3, None);\n    test_u::<u8>(4, Some(2));\n    test_u::<u8>(5, None);\n    test_u::<u8>(10, None);\n    test_u::<u8>(100, Some(10));\n    test_u::<u32>(1000000000, None);\n    test_u::<u64>(152415765279683, None);\n    test_u::<u64>(152415765279684, Some(12345678));\n    test_u::<u64>(152415765279685, None);\n\n    fn test_i<T: PrimitiveSigned>(n: T, out: Option<T>) {\n        assert_eq!(n.checked_sqrt(), out);\n    }\n    test_i::<i8>(0, Some(0));\n    test_i::<i8>(1, Some(1));\n    test_i::<i8>(2, None);\n    test_i::<i8>(3, None);\n    test_i::<i8>(4, Some(2));\n    test_i::<i8>(5, None);\n    test_i::<i8>(10, None);\n    test_i::<i8>(100, Some(10));\n    test_i::<i32>(1000000000, None);\n    test_i::<i64>(152415765279683, None);\n    test_i::<i64>(152415765279684, Some(12345678));\n    test_i::<i64>(152415765279685, None);\n}\n\nfn checked_sqrt_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(T::NEGATIVE_ONE.checked_sqrt());\n}\n\n#[test]\npub fn checked_sqrt_fail() {\n    apply_fn_to_signeds!(checked_sqrt_fail_helper);\n}\n\n#[test]\nfn test_sqrt_rem() {\n    fn test<T: PrimitiveUnsigned>(n: T, sqrt: T, rem: T) {\n        let (actual_sqrt, actual_rem) = n.sqrt_rem();\n        assert_eq!(actual_sqrt, sqrt);\n        assert_eq!(actual_rem, rem);\n        assert_eq!(sqrt_rem_binary(n), (sqrt, rem));\n\n        let mut n = n;\n        assert_eq!(n.sqrt_assign_rem(), rem);\n        assert_eq!(n, sqrt);\n    }\n    test::<u8>(0, 0, 0);\n    test::<u8>(1, 1, 0);\n    test::<u8>(2, 1, 1);\n    test::<u8>(3, 1, 2);\n    test::<u8>(4, 2, 0);\n    test::<u8>(5, 2, 1);\n    test::<u8>(10, 3, 1);\n    test::<u8>(100, 10, 0);\n    test::<u32>(1000000000, 31622, 49116);\n    test::<u64>(152415765279683, 12345677, 24691354);\n    test::<u64>(152415765279684, 12345678, 0);\n    test::<u64>(152415765279685, 12345678, 1);\n}\n\n#[test]\nfn test_sqrt() {\n    fn test<T: PrimitiveFloat>(n: T, out: T) {\n        assert_eq!(NiceFloat(n.sqrt()), NiceFloat(out));\n\n        let mut n = n;\n        n.sqrt_assign();\n        assert_eq!(NiceFloat(n), NiceFloat(out));\n    }\n    test::<f32>(0.0, 0.0);\n    test::<f32>(-0.0, -0.0);\n    test::<f32>(1.0, 1.0);\n    test::<f32>(f32::INFINITY, f32::INFINITY);\n    test::<f32>(f32::NAN, f32::NAN);\n    test::<f32>(2.0, std::f32::consts::SQRT_2);\n    test::<f32>(-1.0, f32::NAN);\n\n    test::<f64>(0.0, 0.0);\n    test::<f64>(-0.0, -0.0);\n    test::<f64>(1.0, 1.0);\n    test::<f64>(f64::INFINITY, f64::INFINITY);\n    test::<f64>(f64::NAN, f64::NAN);\n    test::<f64>(2.0, std::f64::consts::SQRT_2);\n    test::<f64>(-1.0, f64::NAN);\n}\n\nfn floor_sqrt_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let sqrt = n.floor_sqrt();\n        let mut n_alt = n;\n        n_alt.floor_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(floor_sqrt_binary(n), sqrt);\n        assert_eq!(n.floor_root(2), sqrt);\n        let square = sqrt.square();\n        let ceiling_sqrt = n.ceiling_sqrt();\n        if square == n {\n            assert_eq!(ceiling_sqrt, sqrt);\n        } else {\n            assert_eq!(ceiling_sqrt, sqrt + T::ONE);\n        }\n        assert!(square <= n);\n        if let Some(next_square) = (sqrt + T::ONE).checked_square() {\n            assert!(next_square > n);\n        }\n    });\n}\n\nfn floor_sqrt_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen_var_2::<T>().test_properties(|n| {\n        let sqrt = n.floor_sqrt();\n        let mut n_alt = n;\n        n_alt.floor_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(n.floor_root(2), sqrt);\n        let square = sqrt.square();\n        let ceiling_sqrt = n.ceiling_sqrt();\n        if square == n {\n            assert_eq!(ceiling_sqrt, sqrt);\n        } else {\n            assert_eq!(ceiling_sqrt, sqrt + T::ONE);\n        }\n        assert!(square <= n);\n        if let Some(next_square) = (sqrt + T::ONE).checked_square() {\n            assert!(next_square > n);\n        }\n    });\n}\n\n#[test]\nfn floor_sqrt_properties() {\n    apply_fn_to_unsigneds!(floor_sqrt_properties_helper_unsigned);\n    apply_fn_to_signeds!(floor_sqrt_properties_helper_signed);\n}\n\nfn ceiling_sqrt_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let sqrt = n.ceiling_sqrt();\n        let mut n_alt = n;\n        n_alt.ceiling_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(ceiling_sqrt_binary(n), sqrt);\n        assert_eq!(n.ceiling_root(2), sqrt);\n        if let Some(square) = sqrt.checked_square() {\n            let floor_sqrt = n.floor_sqrt();\n            if square == n {\n                assert_eq!(floor_sqrt, sqrt);\n            } else {\n                assert_eq!(floor_sqrt, sqrt - T::ONE);\n            }\n            assert!(square >= n);\n        }\n        if n != T::ZERO {\n            assert!((sqrt - T::ONE).square() < n);\n        }\n    });\n}\n\nfn ceiling_sqrt_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen_var_2::<T>().test_properties(|n| {\n        let sqrt = n.ceiling_sqrt();\n        let mut n_alt = n;\n        n_alt.ceiling_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(n.ceiling_root(2), sqrt);\n        if let Some(square) = sqrt.checked_square() {\n            let floor_sqrt = n.floor_sqrt();\n            if square == n {\n                assert_eq!(floor_sqrt, sqrt);\n            } else {\n                assert_eq!(floor_sqrt, sqrt - T::ONE);\n            }\n            assert!(square >= n);\n        }\n        if n != T::ZERO {\n            assert!((sqrt - T::ONE).square() < n);\n        }\n    });\n}\n\n#[test]\nfn ceiling_sqrt_properties() {\n    apply_fn_to_unsigneds!(ceiling_sqrt_properties_helper_unsigned);\n    apply_fn_to_signeds!(ceiling_sqrt_properties_helper_signed);\n}\n\nfn checked_sqrt_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let sqrt = n.checked_sqrt();\n        assert_eq!(checked_sqrt_binary(n), sqrt);\n        assert_eq!(n.checked_root(2), sqrt);\n        if let Some(sqrt) = sqrt {\n            assert_eq!(sqrt.square(), n);\n            assert_eq!(n.floor_sqrt(), sqrt);\n            assert_eq!(n.ceiling_sqrt(), sqrt);\n        }\n    });\n}\n\nfn checked_sqrt_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen_var_2::<T>().test_properties(|n| {\n        let sqrt = n.checked_sqrt();\n        assert_eq!(n.checked_root(2), sqrt);\n        if let Some(sqrt) = sqrt {\n            assert_eq!(sqrt.square(), n);\n            assert_eq!(n.floor_sqrt(), sqrt);\n            assert_eq!(n.ceiling_sqrt(), sqrt);\n        }\n    });\n}\n\n#[test]\nfn checked_sqrt_properties() {\n    apply_fn_to_unsigneds!(checked_sqrt_properties_helper_unsigned);\n    apply_fn_to_signeds!(checked_sqrt_properties_helper_signed);\n}\n\nfn sqrt_rem_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let (sqrt, rem) = n.sqrt_rem();\n        let mut n_alt = n;\n        assert_eq!(n_alt.sqrt_assign_rem(), rem);\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(sqrt_rem_binary(n), (sqrt, rem));\n        assert_eq!(n.root_rem(2), (sqrt, rem));\n        assert_eq!(n.floor_sqrt(), sqrt);\n        assert!(rem <= sqrt << 1);\n        assert_eq!(sqrt.square() + rem, n);\n    });\n}\n\nfn sqrt_rem_properties_helper_extra<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    unsigned_gen_var_17::<U>().test_properties(|n| {\n        assert_eq!(sqrt_rem_newton::<U, S>(n), n.sqrt_rem());\n    });\n}\n\n#[test]\nfn sqrt_rem_properties() {\n    apply_fn_to_unsigneds!(sqrt_rem_properties_helper);\n    sqrt_rem_properties_helper_extra::<u32, i32>();\n    sqrt_rem_properties_helper_extra::<u64, i64>();\n}\n\nfn sqrt_assign_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|f| {\n        let mut sqrt = f;\n        sqrt.sqrt_assign();\n        assert_eq!(NiceFloat(sqrt), NiceFloat(f.sqrt()));\n        assert!(sqrt.is_nan() || sqrt >= T::ZERO);\n    });\n}\n\n#[test]\nfn sqrt_assign_properties() {\n    apply_fn_to_primitive_floats!(sqrt_assign_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, signed_gen_var_10, unsigned_gen_var_21,\n};\n\n#[test]\nfn test_square() {\n    fn test_i<T: PrimitiveInt>(x: T, out: T) {\n        assert_eq!(x.square(), out);\n\n        let mut x = x;\n        x.square_assign();\n        assert_eq!(x, out);\n    }\n    test_i::<u8>(0, 0);\n    test_i::<i16>(1, 1);\n    test_i::<u32>(2, 4);\n    test_i::<i64>(3, 9);\n    test_i::<u128>(10, 100);\n    test_i::<isize>(123, 15129);\n    test_i::<u32>(1000, 1000000);\n\n    test_i::<i16>(-1, 1);\n    test_i::<i32>(-2, 4);\n    test_i::<i64>(-3, 9);\n    test_i::<i128>(-10, 100);\n    test_i::<isize>(-123, 15129);\n    test_i::<i32>(-1000, 1000000);\n\n    fn test_f<T: PrimitiveFloat>(x: T, out: T) {\n        assert_eq!(NiceFloat(x.square()), NiceFloat(out));\n\n        let mut x = x;\n        x.square_assign();\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n    }\n    test_f::<f32>(f32::NAN, f32::NAN);\n    test_f::<f32>(f32::INFINITY, f32::INFINITY);\n    test_f::<f32>(f32::NEGATIVE_INFINITY, f32::INFINITY);\n    test_f::<f32>(0.0, 0.0);\n    test_f::<f32>(-0.0, 0.0);\n    test_f::<f32>(1.0, 1.0);\n    test_f::<f32>(-1.0, 1.0);\n    test_f::<f32>(0.5, 0.25);\n    test_f::<f32>(-0.5, 0.25);\n    test_f::<f32>(core::f32::consts::SQRT_2, 1.9999999);\n    test_f::<f32>(-core::f32::consts::SQRT_2, 1.9999999);\n    test_f::<f32>(core::f32::consts::PI, 9.869605);\n    test_f::<f32>(-core::f32::consts::PI, 9.869605);\n\n    test_f::<f64>(f64::NAN, f64::NAN);\n    test_f::<f64>(f64::INFINITY, f64::INFINITY);\n    test_f::<f64>(f64::NEGATIVE_INFINITY, f64::INFINITY);\n    test_f::<f64>(0.0, 0.0);\n    test_f::<f64>(-0.0, 0.0);\n    test_f::<f64>(1.0, 1.0);\n    test_f::<f64>(-1.0, 1.0);\n    test_f::<f64>(0.5, 0.25);\n    test_f::<f64>(-0.5, 0.25);\n    test_f::<f64>(core::f64::consts::SQRT_2, 2.0000000000000004);\n    test_f::<f64>(-core::f64::consts::SQRT_2, 2.0000000000000004);\n    test_f::<f64>(core::f64::consts::PI, 9.869604401089358);\n    test_f::<f64>(-core::f64::consts::PI, 9.869604401089358);\n}\n\nfn square_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_21::<T>().test_properties(|x| {\n        let mut square = x;\n        square.square_assign();\n        assert_eq!(square, x.square());\n        assert_eq!(square, x.pow(2));\n        assert_eq!(square.checked_sqrt(), Some(x));\n        if x > T::ONE {\n            assert_eq!(square.checked_log_base(x), Some(2));\n        }\n    });\n}\n\nfn square_properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>() {\n    signed_gen_var_10::<U, S>().test_properties(|x| {\n        let mut square = x;\n        square.square_assign();\n        assert_eq!(square, x.square());\n        assert_eq!(square, x.pow(2));\n        if x != S::MIN {\n            assert_eq!((-x).square(), square);\n        }\n        assert_eq!(\n            U::wrapping_from(square).checked_sqrt().unwrap(),\n            x.unsigned_abs()\n        );\n    });\n}\n\nfn square_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|x| {\n        let mut square = x;\n        square.square_assign();\n        assert_eq!(NiceFloat(square), NiceFloat(x.square()));\n        assert_eq!(NiceFloat(square), NiceFloat(x.pow(2)));\n        assert_eq!(NiceFloat((-x).square()), NiceFloat(square));\n    });\n}\n\n#[test]\nfn square_properties() {\n    apply_fn_to_unsigneds!(square_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(square_properties_helper_signed);\n    apply_fn_to_primitive_floats!(square_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_triple_gen, signed_pair_gen, signed_triple_gen_var_2, unsigned_pair_gen_var_27,\n    unsigned_triple_gen_var_2,\n};\n\n#[test]\nfn test_sub_mul() {\n    fn test_i<T: PrimitiveInt>(x: T, y: T, z: T, out: T) {\n        assert_eq!(x.sub_mul(y, z), out);\n\n        let mut x = x;\n        x.sub_mul_assign(y, z);\n        assert_eq!(x, out);\n    }\n    test_i::<u8>(100, 3, 7, 79);\n    test_i::<u32>(60, 5, 10, 10);\n    test_i::<u64>(1000000, 456, 789, 640216);\n    test_i::<i32>(123, -456, 789, 359907);\n    test_i::<i128>(-123, 456, 789, -359907);\n    test_i::<i8>(127, 2, 100, -73);\n    test_i::<i8>(-127, -2, 100, 73);\n    test_i::<i8>(-128, 1, 0, -128);\n\n    fn test_f<T: PrimitiveFloat>(x: T, y: T, z: T, out: T) {\n        assert_eq!(NiceFloat(x.sub_mul(y, z)), NiceFloat(out));\n\n        let mut x = x;\n        x.sub_mul_assign(y, z);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n    }\n    test_f::<f32>(1.0, 2.0, 3.0, -5.0);\n    test_f::<f32>(1.0, f32::INFINITY, 2.0, f32::NEGATIVE_INFINITY);\n    test_f::<f32>(f32::NAN, 1.0, 2.0, f32::NAN);\n}\n\nfn sub_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_2::<T>().test_properties(|(x, y, z)| {\n        let result = x.sub_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.sub_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.sub_mul(z, y), result);\n        assert_eq!(result.add_mul(y, z), x);\n        assert_eq!(x.checked_sub_mul(y, z), Some(result));\n        assert_eq!(x.saturating_sub_mul(y, z), result);\n        assert_eq!(x.wrapping_sub_mul(y, z), result);\n        assert_eq!(x.overflowing_sub_mul(y, z), (result, false));\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.sub_mul(T::ZERO, b), a);\n        assert_eq!(a.sub_mul(b, T::ZERO), a);\n    });\n}\n\nfn sub_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen_var_2::<T>().test_properties(|(x, y, z)| {\n        let result = x.sub_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.sub_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.sub_mul(z, y), result);\n        assert_eq!(result.add_mul(y, z), x);\n        assert_eq!(x.checked_sub_mul(y, z), Some(result));\n        assert_eq!(x.saturating_sub_mul(y, z), result);\n        assert_eq!(x.wrapping_sub_mul(y, z), result);\n        assert_eq!(x.overflowing_sub_mul(y, z), (result, false));\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.sub_mul(T::ZERO, b), a);\n        assert_eq!(a.sub_mul(b, T::ZERO), a);\n    });\n}\n\nfn sub_mul_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.sub_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.sub_mul_assign(y, z);\n        assert_eq!(NiceFloat(x_alt), NiceFloat(result));\n\n        assert_eq!(NiceFloat(x.sub_mul(z, y)), NiceFloat(result));\n    });\n}\n\n#[test]\nfn sub_mul_properties() {\n    apply_fn_to_unsigneds!(sub_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(sub_mul_properties_helper_signed);\n    apply_fn_to_primitive_floats!(sub_mul_properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::generators::signed_gen;\n\nfn wrapping_abs_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.wrapping_abs(), out);\n\n        let mut n = n;\n        n.wrapping_abs_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::ONE, T::ONE);\n    test(T::exact_from(100), T::exact_from(100));\n    test(T::MAX, T::MAX);\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::exact_from(-100), T::exact_from(100));\n    test(T::MIN, T::MIN);\n}\n\n#[test]\nfn test_wrapping_abs() {\n    apply_fn_to_signeds!(wrapping_abs_helper);\n}\n\nfn wrapping_abs_properties_helper<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|n| {\n        let mut abs = n;\n        abs.wrapping_abs_assign();\n        assert_eq!(abs, n.wrapping_abs());\n        assert_eq!(abs.wrapping_abs(), abs);\n        if n != T::MIN {\n            assert_eq!(n.abs(), abs);\n        }\n        assert_eq!(abs == n, n >= T::ZERO || n == T::MIN);\n    });\n}\n\n#[test]\nfn wrapping_abs_properties() {\n    apply_fn_to_signeds!(wrapping_abs_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_wrapping_add() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.wrapping_add(y), out);\n\n        let mut x = x;\n        x.wrapping_add_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u16>(123, 456, 579);\n    test::<u8>(123, 200, 67);\n    test::<i16>(123, -456, -333);\n    test::<i8>(123, 45, -88);\n    test::<i8>(-123, -45, 88);\n}\n\nfn wrapping_add_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut sum = x;\n        sum.wrapping_add_assign(y);\n        assert_eq!(sum, x.wrapping_add(y));\n        assert_eq!(sum, x.wrapping_sub(y.wrapping_neg()));\n        assert_eq!(sum.wrapping_sub(x), y);\n        assert_eq!(sum.wrapping_sub(y), x);\n        assert_eq!(y.wrapping_add(x), sum);\n    });\n}\n\nfn wrapping_add_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut sum = x;\n        sum.wrapping_add_assign(y);\n        assert_eq!(sum, x.wrapping_add(y));\n        assert_eq!(sum, x.wrapping_sub(y.wrapping_neg()));\n        assert_eq!(sum.wrapping_sub(x), y);\n        assert_eq!(sum.wrapping_sub(y), x);\n        assert_eq!(y.wrapping_add(x), sum);\n    });\n}\n\n#[test]\nfn wrapping_add_properties() {\n    apply_fn_to_unsigneds!(wrapping_add_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_add_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_wrapping_add_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: T) {\n        assert_eq!(x.wrapping_add_mul(y, z), out);\n\n        let mut x = x;\n        x.wrapping_add_mul_assign(y, z);\n        assert_eq!(x, out);\n    }\n    test::<u8>(2, 3, 7, 23);\n    test::<u32>(7, 5, 10, 57);\n    test::<u64>(123, 456, 789, 359907);\n    test::<i32>(123, -456, 789, -359661);\n    test::<i128>(-123, 456, 789, 359661);\n    test::<i8>(127, -2, 100, -73);\n    test::<i8>(-127, 2, 100, 73);\n    test::<i8>(-128, 1, 0, -128);\n\n    test::<u8>(2, 20, 20, 146);\n    test::<i8>(-127, -2, 100, -71);\n    test::<i8>(127, 1, 100, -29);\n    test::<i8>(-127, -1, 100, 29);\n    test::<i8>(-127, -10, 100, -103);\n}\n\nfn wrapping_add_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let result = x.wrapping_add_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.wrapping_add_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.wrapping_add_mul(z, y), result);\n        assert_eq!(result.wrapping_sub_mul(y, z), x);\n        assert_eq!(x.overflowing_add_mul(y, z).0, result);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.wrapping_add_mul(T::ZERO, b), a);\n        assert_eq!(a.wrapping_add_mul(T::ONE, b), a.wrapping_add(b));\n        assert_eq!(T::ZERO.wrapping_add_mul(a, b), a.wrapping_mul(b));\n        assert_eq!(a.wrapping_add_mul(b, T::ZERO), a);\n        assert_eq!(a.wrapping_add_mul(b, T::ONE), a.wrapping_add(b));\n    });\n}\n\nfn wrapping_add_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.wrapping_add_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.wrapping_add_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.wrapping_add_mul(z, y), result);\n        assert_eq!(result.wrapping_sub_mul(y, z), x);\n        assert_eq!(x.overflowing_add_mul(y, z).0, result);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.wrapping_add_mul(T::ZERO, b), a);\n        assert_eq!(a.wrapping_add_mul(T::ONE, b), a.wrapping_add(b));\n        assert_eq!(T::ZERO.wrapping_add_mul(a, b), a.wrapping_mul(b));\n        assert_eq!(a.wrapping_add_mul(b, T::ZERO), a);\n        assert_eq!(a.wrapping_add_mul(b, T::ONE), a.wrapping_add(b));\n    });\n}\n\n#[test]\nfn wrapping_add_mul_properties() {\n    apply_fn_to_unsigneds!(wrapping_add_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_add_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen_var_6, unsigned_gen, unsigned_pair_gen_var_12,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_wrapping_div() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.wrapping_div(y), out);\n\n        let mut x = x;\n        x.wrapping_div_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u16>(0, 5, 0);\n    test::<u16>(123, 456, 0);\n    test::<u8>(100, 3, 33);\n    test::<i8>(100, -3, -33);\n    test::<i16>(-100, 3, -33);\n    test::<i32>(-100, -3, 33);\n    test::<i8>(-128, -1, -128);\n}\n\nfn wrapping_div_assign_fail_helper<T: PrimitiveInt>() {\n    assert_panic!({\n        let mut n = T::ONE;\n        n.wrapping_div_assign(T::ZERO);\n    });\n}\n\n#[test]\nfn wrapping_div_assign_fail() {\n    apply_fn_to_primitive_ints!(wrapping_div_assign_fail_helper);\n}\n\nfn wrapping_div_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(x, y)| {\n        let mut quotient = x;\n        quotient.wrapping_div_assign(y);\n        assert_eq!(quotient, x.wrapping_div(y));\n        assert_eq!(x / y, quotient);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_panic!(x.wrapping_div(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.wrapping_div_assign(T::ZERO);\n        });\n    });\n}\n\nfn wrapping_div_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen_var_6::<T>().test_properties(|(x, y)| {\n        let mut quotient = x;\n        quotient.wrapping_div_assign(y);\n        assert_eq!(quotient, x.wrapping_div(y));\n        if x != T::MIN || y != T::NEGATIVE_ONE {\n            assert_eq!(x / y, quotient);\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_panic!(x.wrapping_div(T::ZERO));\n        assert_panic!({\n            let mut y = x;\n            y.wrapping_div_assign(T::ZERO);\n        });\n    });\n}\n\n#[test]\nfn wrapping_div_properties() {\n    apply_fn_to_unsigneds!(wrapping_div_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_div_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_wrapping_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.wrapping_mul(y), out);\n\n        let mut x = x;\n        x.wrapping_mul_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u16>(123, 456, 56088);\n    test::<u8>(123, 200, 24);\n    test::<i16>(123, -45, -5535);\n    test::<i8>(123, 45, -97);\n    test::<i8>(-123, 45, 97);\n}\n\nfn wrapping_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut product = x;\n        product.wrapping_mul_assign(y);\n        assert_eq!(product, x.wrapping_mul(y));\n        assert_eq!(y.wrapping_mul(x), product);\n    });\n}\n\nfn wrapping_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut product = x;\n        product.wrapping_mul_assign(y);\n        assert_eq!(product, x.wrapping_mul(y));\n        assert_eq!(y.wrapping_mul(x), product);\n    });\n}\n\n#[test]\nfn wrapping_mul_properties() {\n    apply_fn_to_unsigneds!(wrapping_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\nfn unsigned_wrapping_neg_helper<T: PrimitiveUnsigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.wrapping_neg(), out);\n\n        let mut n = n;\n        n.wrapping_neg_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::ONE, T::MAX);\n    test(T::exact_from(100), T::MAX - T::exact_from(100) + T::ONE);\n    test(T::MAX, T::ONE);\n}\n\nfn signed_wrapping_neg_helper<T: PrimitiveSigned>() {\n    let test = |n: T, out| {\n        assert_eq!(n.wrapping_neg(), out);\n\n        let mut n = n;\n        n.wrapping_neg_assign();\n        assert_eq!(n, out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::ONE, T::NEGATIVE_ONE);\n    test(T::exact_from(100), T::exact_from(-100));\n    test(T::MAX, T::MIN + T::ONE);\n    test(T::NEGATIVE_ONE, T::ONE);\n    test(T::exact_from(-100), T::exact_from(100));\n    test(T::MIN, T::MIN);\n}\n\n#[test]\nfn test_wrapping_neg() {\n    apply_fn_to_unsigneds!(unsigned_wrapping_neg_helper);\n    apply_fn_to_signeds!(signed_wrapping_neg_helper);\n}\n\nfn wrapping_neg_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let mut neg = n;\n        neg.wrapping_neg_assign();\n        assert_eq!(neg, n.wrapping_neg());\n        assert_eq!(neg.wrapping_neg(), n);\n        assert_eq!(neg == n, n == T::ZERO || n == T::power_of_2(T::WIDTH - 1));\n        assert_eq!(n.wrapping_add(neg), T::ZERO);\n    });\n}\n\nfn wrapping_neg_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|n| {\n        let mut neg = n;\n        neg.wrapping_neg_assign();\n        assert_eq!(neg, n.wrapping_neg());\n        assert_eq!(neg.wrapping_neg(), n);\n        assert_eq!(neg == n, n == T::ZERO || n == T::MIN);\n        assert_eq!(n.wrapping_add(neg), T::ZERO);\n    });\n}\n\n#[test]\nfn wrapping_neg_properties() {\n    apply_fn_to_unsigneds!(wrapping_neg_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_neg_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen, unsigned_pair_gen};\n\n#[test]\nfn test_wrapping_pow() {\n    fn test<T: PrimitiveInt>(x: T, y: u64, out: T) {\n        assert_eq!(x.wrapping_pow(y), out);\n\n        let mut x = x;\n        x.wrapping_pow_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0, 1);\n    test::<u64>(123, 0, 1);\n    test::<u64>(123, 1, 123);\n    test::<u16>(0, 123, 0);\n    test::<u16>(1, 123, 1);\n    test::<i16>(-1, 123, -1);\n    test::<i16>(-1, 124, 1);\n    test::<u8>(3, 3, 27);\n    test::<i32>(-10, 9, -1000000000);\n    test::<i32>(-10, 10, 1410065408);\n    test::<i16>(-10, 9, 13824);\n    test::<i16>(10, 9, -13824);\n    test::<i64>(123, 456, 2409344748064316129);\n    test::<u64>(0, u64::MAX, 0);\n    test::<u64>(1, u64::MAX, 1);\n    test::<u64>(123, u64::MAX, 3449391168254631603);\n    test::<i64>(0, u64::MAX, 0);\n    test::<i64>(1, u64::MAX, 1);\n    test::<i64>(-1, u64::MAX, -1);\n    test::<i64>(-1, u64::MAX - 1, 1);\n    test::<i64>(123, u64::MAX, 3449391168254631603);\n    test::<i64>(-123, u64::MAX, -3449391168254631603);\n    test::<i64>(-123, u64::MAX - 1, 4527249702272692521);\n}\n\nfn wrapping_pow_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.wrapping_pow_assign(y);\n        assert_eq!(power, x.wrapping_pow(y));\n    });\n}\n\nfn wrapping_pow_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen::<T, u64>().test_properties(|(x, y)| {\n        let mut power = x;\n        power.wrapping_pow_assign(y);\n        assert_eq!(power, x.wrapping_pow(y));\n        if x != T::MIN {\n            let neg_pow = (-x).wrapping_pow(y);\n            if y.even() {\n                assert_eq!(neg_pow, power);\n            } else {\n                assert_eq!(neg_pow, power.wrapping_neg());\n            }\n        }\n    });\n}\n\n#[test]\nfn wrapping_pow_properties() {\n    apply_fn_to_unsigneds!(wrapping_pow_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_pow_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\n#[test]\nfn test_wrapping_square() {\n    fn test<T: PrimitiveInt>(x: T, out: T) {\n        assert_eq!(x.wrapping_square(), out);\n\n        let mut x = x;\n        x.wrapping_square_assign();\n        assert_eq!(x, out);\n    }\n    test::<u8>(0, 0);\n    test::<i16>(1, 1);\n    test::<u32>(2, 4);\n    test::<i64>(3, 9);\n    test::<u128>(10, 100);\n    test::<isize>(123, 15129);\n    test::<u32>(1000, 1000000);\n\n    test::<i16>(-1, 1);\n    test::<i32>(-2, 4);\n    test::<i64>(-3, 9);\n    test::<i128>(-10, 100);\n    test::<isize>(-123, 15129);\n    test::<i32>(-1000, 1000000);\n\n    test::<u16>(1000, 16960);\n    test::<i16>(-1000, 16960);\n}\n\nfn wrapping_square_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        let mut square = x;\n        square.wrapping_square_assign();\n        assert_eq!(square, x.wrapping_square());\n        assert_eq!(square, x.wrapping_pow(2));\n    });\n}\n\nfn wrapping_square_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        let mut square = x;\n        square.wrapping_square_assign();\n        assert_eq!(square, x.wrapping_square());\n        assert_eq!(square, x.wrapping_pow(2));\n        if x != T::MIN {\n            assert_eq!((-x).wrapping_square(), square);\n        }\n    });\n}\n\n#[test]\nfn saturating_square_properties() {\n    apply_fn_to_unsigneds!(wrapping_square_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_square_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\n\n#[test]\nfn test_wrapping_sub() {\n    fn test<T: PrimitiveInt>(x: T, y: T, out: T) {\n        assert_eq!(x.wrapping_sub(y), out);\n\n        let mut x = x;\n        x.wrapping_sub_assign(y);\n        assert_eq!(x, out);\n    }\n    test::<u16>(456, 123, 333);\n    test::<u8>(123, 200, 179);\n    test::<i16>(123, -456, 579);\n    test::<i8>(123, -45, -88);\n    test::<i8>(-123, 45, 88);\n}\n\nfn wrapping_sub_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let mut diff = x;\n        diff.wrapping_sub_assign(y);\n        assert_eq!(diff, x.wrapping_sub(y));\n        assert_eq!(diff, x.wrapping_add(y.wrapping_neg()));\n        assert_eq!(diff.wrapping_add(y), x);\n        assert_eq!(y.wrapping_sub(x), diff.wrapping_neg());\n    });\n}\n\nfn wrapping_sub_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let mut diff = x;\n        diff.wrapping_sub_assign(y);\n        assert_eq!(diff, x.wrapping_sub(y));\n        assert_eq!(diff, x.wrapping_add(y.wrapping_neg()));\n        assert_eq!(diff.wrapping_add(y), x);\n        assert_eq!(y.wrapping_sub(x), diff.wrapping_neg());\n    });\n}\n\n#[test]\nfn wrapping_sub_properties() {\n    apply_fn_to_unsigneds!(wrapping_sub_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_sub_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/wrapping_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_triple_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_wrapping_sub_mul() {\n    fn test<T: PrimitiveInt>(x: T, y: T, z: T, out: T) {\n        assert_eq!(x.wrapping_sub_mul(y, z), out);\n\n        let mut x = x;\n        x.wrapping_sub_mul_assign(y, z);\n        assert_eq!(x, out);\n    }\n    test::<u8>(100, 3, 7, 79);\n    test::<u32>(60, 5, 10, 10);\n    test::<u64>(1000000, 456, 789, 640216);\n    test::<i32>(123, -456, 789, 359907);\n    test::<i128>(-123, 456, 789, -359907);\n    test::<i8>(127, 2, 100, -73);\n    test::<i8>(-127, -2, 100, 73);\n    test::<i8>(-128, 1, 0, -128);\n\n    test::<u8>(2, 10, 5, 208);\n    test::<i8>(-127, 2, 100, -71);\n    test::<i8>(-127, 1, 100, 29);\n    test::<i8>(127, -1, 100, -29);\n    test::<i8>(127, -10, 100, 103);\n}\n\nfn wrapping_sub_mul_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let result = x.wrapping_sub_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.wrapping_sub_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.wrapping_sub_mul(z, y), result);\n        assert_eq!(result.wrapping_add_mul(y, z), x);\n        assert_eq!(x.overflowing_sub_mul(y, z).0, result);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.wrapping_sub_mul(T::ZERO, b), a);\n        assert_eq!(a.wrapping_sub_mul(T::ONE, b), a.wrapping_sub(b));\n        assert_eq!(\n            T::ZERO.wrapping_sub_mul(a, b),\n            a.wrapping_mul(b).wrapping_neg()\n        );\n        assert_eq!(a.wrapping_sub_mul(b, T::ZERO), a);\n        assert_eq!(a.wrapping_sub_mul(b, T::ONE), a.wrapping_sub(b));\n    });\n}\n\nfn wrapping_sub_mul_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let result = x.wrapping_sub_mul(y, z);\n\n        let mut x_alt = x;\n        x_alt.wrapping_sub_mul_assign(y, z);\n        assert_eq!(x_alt, result);\n\n        assert_eq!(x.wrapping_sub_mul(z, y), result);\n        assert_eq!(result.wrapping_add_mul(y, z), x);\n        assert_eq!(x.overflowing_sub_mul(y, z).0, result);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(a, b)| {\n        assert_eq!(a.wrapping_sub_mul(T::ZERO, b), a);\n        assert_eq!(a.wrapping_sub_mul(T::ONE, b), a.wrapping_sub(b));\n        assert_eq!(\n            T::ZERO.wrapping_sub_mul(a, b),\n            a.wrapping_mul(b).wrapping_neg()\n        );\n        assert_eq!(a.wrapping_sub_mul(b, T::ZERO), a);\n        assert_eq!(a.wrapping_sub_mul(b, T::ONE), a.wrapping_sub(b));\n    });\n}\n\n#[test]\nfn wrapping_sub_mul_properties() {\n    apply_fn_to_unsigneds!(wrapping_sub_mul_properties_helper_unsigned);\n    apply_fn_to_signeds!(wrapping_sub_mul_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/x_mul_y_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::x_mul_y_to_zz::explicit_x_mul_y_to_zz;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\nfn test_x_mul_y_to_zz() {\n    fn test<T: PrimitiveUnsigned>(x: T, y: T, z_1: T, z_0: T) {\n        assert_eq!(T::x_mul_y_to_zz(x, y), (z_1, z_0));\n        assert_eq!(explicit_x_mul_y_to_zz(x, y), (z_1, z_0));\n    }\n    test::<u32>(0, 0, 0, 0);\n    test::<u64>(15, 3, 0, 45);\n    test::<u8>(0x78, 0x9a, 0x48, 0x30);\n    test::<u8>(u8::MAX, 0, 0, 0);\n    test::<u8>(u8::MAX, 1, 0, u8::MAX);\n    test(u16::MAX, u16::MAX, u16::MAX - 1, 1);\n}\n\nfn x_mul_y_to_zz_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let p = T::x_mul_y_to_zz(x, y);\n        assert_eq!(explicit_x_mul_y_to_zz(x, y), p);\n        assert_eq!(T::x_mul_y_to_zz(y, x), p);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(T::x_mul_y_to_zz(x, T::ZERO), (T::ZERO, T::ZERO));\n        assert_eq!(T::x_mul_y_to_zz(T::ZERO, x), (T::ZERO, T::ZERO));\n        assert_eq!(T::x_mul_y_to_zz(x, T::ONE), (T::ZERO, x));\n        assert_eq!(T::x_mul_y_to_zz(T::ONE, x), (T::ZERO, x));\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        let product_1 = T::x_mul_y_to_zz(x, y).1;\n        let product_2 = T::x_mul_y_to_zz(y, z).1;\n        assert_eq!(product_1.wrapping_mul(z), x.wrapping_mul(product_2));\n    });\n}\n\n#[test]\nfn x_mul_y_to_zz_properties() {\n    apply_fn_to_unsigneds!(x_mul_y_to_zz_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/xx_add_yy_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::xx_add_yy_to_zz::explicit_xx_add_yy_to_zz;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_quadruple_gen_var_10, unsigned_sextuple_gen_var_1,\n};\n\n#[test]\nfn test_xx_add_yy_to_zz() {\n    fn test<T: PrimitiveUnsigned>(x_1: T, x_0: T, y_1: T, y_0: T, z_1: T, z_0: T) {\n        assert_eq!(T::xx_add_yy_to_zz(x_1, x_0, y_1, y_0), (z_1, z_0));\n        assert_eq!(explicit_xx_add_yy_to_zz(x_1, x_0, y_1, y_0), (z_1, z_0));\n    }\n    test::<u32>(0, 0, 0, 0, 0, 0);\n    test::<u64>(0x12, 0x34, 0x33, 0x33, 0x45, 0x67);\n    test::<u8>(0x78, 0x9a, 0xbc, 0xde, 0x35, 0x78);\n    test::<u8>(u8::MAX, u8::MAX, 0, 1, 0, 0);\n    test(\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX - 1,\n    );\n}\n\nfn xx_add_yy_to_zz_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_quadruple_gen_var_10::<T>().test_properties(|(x_1, x_0, y_1, y_0)| {\n        let (z_1, z_0) = T::xx_add_yy_to_zz(x_1, x_0, y_1, y_0);\n        assert_eq!(explicit_xx_add_yy_to_zz(x_1, x_0, y_1, y_0), (z_1, z_0));\n\n        assert_eq!(T::xx_sub_yy_to_zz(z_1, z_0, y_1, y_0), (x_1, x_0));\n        assert_eq!(T::xx_sub_yy_to_zz(z_1, z_0, x_1, x_0), (y_1, y_0));\n        assert_eq!(T::xx_add_yy_to_zz(y_1, y_0, x_1, x_0), (z_1, z_0));\n        assert_eq!(T::xx_add_yy_to_zz(x_1, y_0, y_1, x_0), (z_1, z_0));\n\n        let (neg_y_1, neg_y_0) = T::xx_sub_yy_to_zz(T::ZERO, T::ZERO, y_1, y_0);\n        assert_eq!(T::xx_sub_yy_to_zz(x_1, x_0, neg_y_1, neg_y_0), (z_1, z_0));\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x_1, x_0)| {\n        assert_eq!(T::xx_add_yy_to_zz(x_1, x_0, T::ZERO, T::ZERO), (x_1, x_0));\n        assert_eq!(T::xx_add_yy_to_zz(T::ZERO, T::ZERO, x_1, x_0), (x_1, x_0));\n\n        let (neg_x_1, neg_x_0) = T::xx_sub_yy_to_zz(T::ZERO, T::ZERO, x_1, x_0);\n        assert_eq!(\n            T::xx_add_yy_to_zz(x_1, x_0, neg_x_1, neg_x_0),\n            (T::ZERO, T::ZERO)\n        );\n    });\n\n    unsigned_sextuple_gen_var_1::<T>().test_properties(|(x_1, x_0, y_1, y_0, z_1, z_0)| {\n        let (sum_1_1, sum_1_0) = T::xx_add_yy_to_zz(x_1, x_0, y_1, y_0);\n        let (sum_2_1, sum_2_0) = T::xx_add_yy_to_zz(y_1, y_0, z_1, z_0);\n        assert_eq!(\n            T::xx_add_yy_to_zz(sum_1_1, sum_1_0, z_1, z_0),\n            T::xx_add_yy_to_zz(x_1, x_0, sum_2_1, sum_2_0)\n        );\n    });\n}\n\n#[test]\nfn xx_add_yy_to_zz_properties() {\n    apply_fn_to_unsigneds!(xx_add_yy_to_zz_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/xx_div_mod_y_to_qr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::xx_div_mod_y_to_qr::explicit_xx_div_mod_y_to_qr;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{unsigned_gen_var_1, unsigned_triple_gen_var_15};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_xx_div_mod_y_to_qr() {\n    fn test<T: PrimitiveUnsigned>(x_1: T, x_0: T, y: T, q: T, r: T) {\n        assert_eq!(T::xx_div_mod_y_to_qr(x_1, x_0, y), (q, r));\n        assert_eq!(explicit_xx_div_mod_y_to_qr(x_1, x_0, y), (q, r));\n    }\n    test::<u8>(0, 0, 1, 0, 0);\n    test::<u32>(0, 1, 1, 1, 0);\n    test::<u16>(1, 0, 2, 0x8000, 0);\n    test::<u16>(1, 7, 2, 0x8003, 1);\n    test::<u8>(0x78, 0x9a, 0xbc, 0xa4, 0x2a);\n    test::<u64>(0x12, 0x34, 0x33, 0x5a5a5a5a5a5a5a5b, 0x13);\n}\n\nfn xx_div_mod_y_to_qr_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::xx_div_mod_y_to_qr(\n        T::exact_from(3),\n        T::exact_from(5),\n        T::ZERO\n    ));\n    assert_panic!(T::xx_div_mod_y_to_qr(\n        T::exact_from(3),\n        T::exact_from(5),\n        T::TWO\n    ));\n}\n\n#[test]\nfn xx_div_mod_y_to_qr_fail() {\n    apply_fn_to_unsigneds!(xx_div_mod_y_to_qr_fail_helper);\n}\n\nfn xx_div_mod_y_to_qr_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_15::<T, T>().test_properties(|(x_1, x_0, y)| {\n        let (q, r) = T::xx_div_mod_y_to_qr(x_1, x_0, y);\n        assert_eq!(explicit_xx_div_mod_y_to_qr(x_1, x_0, y), (q, r));\n\n        assert!(r < y);\n        let (product_1, product_0) = T::x_mul_y_to_zz(q, y);\n        assert_eq!(\n            T::xx_add_yy_to_zz(product_1, product_0, T::ZERO, r),\n            (x_1, x_0)\n        );\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|a| {\n        assert_eq!(\n            T::xx_div_mod_y_to_qr(T::ZERO, T::ZERO, a),\n            (T::ZERO, T::ZERO)\n        );\n        assert_eq!(T::xx_div_mod_y_to_qr(T::ZERO, a, a), (T::ONE, T::ZERO));\n    });\n}\n\n#[test]\nfn xx_div_mod_y_to_qr_properties() {\n    apply_fn_to_unsigneds!(xx_div_mod_y_to_qr_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/xx_sub_yy_to_zz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::xx_sub_yy_to_zz::explicit_xx_sub_yy_to_zz;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_quadruple_gen_var_10,\n};\n\n#[test]\nfn test_xx_sub_yy_to_zz() {\n    fn test<T: PrimitiveUnsigned>(x_1: T, x_0: T, y_1: T, y_0: T, z_1: T, z_0: T) {\n        assert_eq!(T::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0), (z_1, z_0));\n        assert_eq!(explicit_xx_sub_yy_to_zz(x_1, x_0, y_1, y_0), (z_1, z_0));\n    }\n    test::<u32>(0, 0, 0, 0, 0, 0);\n    test::<u64>(0x67, 0x89, 0x33, 0x33, 0x34, 0x56);\n    test::<u8>(0x78, 0x9a, 0xbc, 0xde, 0xbb, 0xbc);\n    test::<u8>(0, 0, 0, 1, u8::MAX, u8::MAX);\n    test(u16::MAX, u16::MAX, u16::MAX, u16::MAX, 0, 0);\n}\n\nfn xx_sub_yy_to_zz_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_quadruple_gen_var_10::<T>().test_properties(|(x_1, x_0, y_1, y_0)| {\n        let (z_1, z_0) = T::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0);\n        assert_eq!(explicit_xx_sub_yy_to_zz(x_1, x_0, y_1, y_0), (z_1, z_0));\n\n        assert_eq!(T::xx_add_yy_to_zz(z_1, z_0, y_1, y_0), (x_1, x_0));\n        assert_eq!(\n            T::xx_sub_yy_to_zz(z_1, z_0, x_1, x_0),\n            T::xx_sub_yy_to_zz(T::ZERO, T::ZERO, y_1, y_0)\n        );\n        assert_eq!(\n            T::xx_sub_yy_to_zz(y_1, y_0, x_1, x_0),\n            T::xx_sub_yy_to_zz(T::ZERO, T::ZERO, z_1, z_0)\n        );\n\n        let (neg_y_1, neg_y_0) = T::xx_sub_yy_to_zz(T::ZERO, T::ZERO, y_1, y_0);\n        assert_eq!(T::xx_add_yy_to_zz(x_1, x_0, neg_y_1, neg_y_0), (z_1, z_0));\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x_1, x_0)| {\n        assert_eq!(T::xx_sub_yy_to_zz(x_1, x_0, T::ZERO, T::ZERO), (x_1, x_0));\n        assert_eq!(T::xx_sub_yy_to_zz(x_1, x_0, x_1, x_0), (T::ZERO, T::ZERO));\n    });\n}\n\n#[test]\nfn xx_sub_yy_to_zz_properties() {\n    apply_fn_to_unsigneds!(xx_sub_yy_to_zz_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/xxx_add_yyy_to_zzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_nonuple_gen_var_1, unsigned_sextuple_gen_var_1, unsigned_triple_gen_var_19,\n};\n\n#[test]\n#[allow(clippy::too_many_arguments)]\nfn test_xxx_add_yyy_to_zzz() {\n    fn test<T: PrimitiveUnsigned>(\n        x_2: T,\n        x_1: T,\n        x_0: T,\n        y_2: T,\n        y_1: T,\n        y_0: T,\n        z_2: T,\n        z_1: T,\n        z_0: T,\n    ) {\n        assert_eq!(\n            T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0),\n            (z_2, z_1, z_0)\n        );\n    }\n    test::<u32>(0, 0, 0, 0, 0, 0, 0, 0, 0);\n    test::<u64>(0x12, 0x34, 0x56, 0x33, 0x33, 0x33, 0x45, 0x67, 0x89);\n    test::<u8>(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc, 0x57, 0x99, 0x98);\n    test::<u8>(u8::MAX, u8::MAX, u8::MAX, 0, 0, 1, 0, 0, 0);\n    test(\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX - 1,\n    );\n}\n\nfn xxx_add_yyy_to_zzz_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_sextuple_gen_var_1::<T>().test_properties(|(x_2, x_1, x_0, y_2, y_1, y_0)| {\n        let (z_2, z_1, z_0) = T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0);\n\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(z_2, z_1, z_0, y_2, y_1, y_0),\n            (x_2, x_1, x_0)\n        );\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(z_2, z_1, z_0, x_2, x_1, x_0),\n            (y_2, y_1, y_0)\n        );\n        assert_eq!(\n            T::xxx_add_yyy_to_zzz(y_2, y_1, y_0, x_2, x_1, x_0),\n            (z_2, z_1, z_0)\n        );\n\n        let (neg_y_2, neg_y_1, neg_y_0) =\n            T::xxx_sub_yyy_to_zzz(T::ZERO, T::ZERO, T::ZERO, y_2, y_1, y_0);\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(x_2, x_1, x_0, neg_y_2, neg_y_1, neg_y_0),\n            (z_2, z_1, z_0)\n        );\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x_2, x_1, x_0)| {\n        assert_eq!(\n            T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, T::ZERO, T::ZERO, T::ZERO),\n            (x_2, x_1, x_0)\n        );\n        assert_eq!(\n            T::xxx_add_yyy_to_zzz(T::ZERO, T::ZERO, T::ZERO, x_2, x_1, x_0),\n            (x_2, x_1, x_0)\n        );\n\n        let (neg_x_2, neg_x_1, neg_x_0) =\n            T::xxx_sub_yyy_to_zzz(T::ZERO, T::ZERO, T::ZERO, x_2, x_1, x_0);\n        assert_eq!(\n            T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, neg_x_2, neg_x_1, neg_x_0),\n            (T::ZERO, T::ZERO, T::ZERO)\n        );\n    });\n\n    unsigned_nonuple_gen_var_1::<T>().test_properties(\n        |(x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0)| {\n            let (sum_1_2, sum_1_1, sum_1_0) = T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0);\n            let (sum_2_2, sum_2_1, sum_2_0) = T::xxx_add_yyy_to_zzz(y_2, y_1, y_0, z_2, z_1, z_0);\n            assert_eq!(\n                T::xxx_add_yyy_to_zzz(sum_1_2, sum_1_1, sum_1_0, z_2, z_1, z_0),\n                T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, sum_2_2, sum_2_1, sum_2_0)\n            );\n        },\n    );\n}\n\n#[test]\nfn xxx_add_yyy_to_zzz_properties() {\n    apply_fn_to_unsigneds!(xxx_add_yyy_to_zzz_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/xxx_sub_yyy_to_zzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_sextuple_gen_var_1, unsigned_triple_gen_var_19,\n};\n\n#[test]\n#[allow(clippy::too_many_arguments)]\nfn test_xxx_sub_yyy_to_zzz() {\n    fn test<T: PrimitiveUnsigned>(\n        x_2: T,\n        x_1: T,\n        x_0: T,\n        y_2: T,\n        y_1: T,\n        y_0: T,\n        z_2: T,\n        z_1: T,\n        z_0: T,\n    ) {\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0),\n            (z_2, z_1, z_0)\n        );\n    }\n    test::<u32>(0, 0, 0, 0, 0, 0, 0, 0, 0);\n    test::<u64>(0x67, 0x89, 0xab, 0x33, 0x33, 0x33, 0x34, 0x56, 0x78);\n    test::<u8>(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc, 0x99, 0x9b, 0xe0);\n    test::<u8>(0, 0, 0, 0, 0, 1, u8::MAX, u8::MAX, u8::MAX);\n    test(\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        0,\n        0,\n        0,\n    );\n}\n\nfn xxx_sub_yyy_to_zzz_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_sextuple_gen_var_1::<T>().test_properties(|(x_2, x_1, x_0, y_2, y_1, y_0)| {\n        let (z_2, z_1, z_0) = T::xxx_sub_yyy_to_zzz(x_2, x_1, x_0, y_2, y_1, y_0);\n\n        assert_eq!(\n            T::xxx_add_yyy_to_zzz(z_2, z_1, z_0, y_2, y_1, y_0),\n            (x_2, x_1, x_0)\n        );\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(z_2, z_1, z_0, x_2, x_1, x_0),\n            T::xxx_sub_yyy_to_zzz(T::ZERO, T::ZERO, T::ZERO, y_2, y_1, y_0)\n        );\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(y_2, y_1, y_0, x_2, x_1, x_0),\n            T::xxx_sub_yyy_to_zzz(T::ZERO, T::ZERO, T::ZERO, z_2, z_1, z_0)\n        );\n\n        let (neg_y_2, neg_y_1, neg_y_0) =\n            T::xxx_sub_yyy_to_zzz(T::ZERO, T::ZERO, T::ZERO, y_2, y_1, y_0);\n        assert_eq!(\n            T::xxx_add_yyy_to_zzz(x_2, x_1, x_0, neg_y_2, neg_y_1, neg_y_0),\n            (z_2, z_1, z_0)\n        );\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x_2, x_1, x_0)| {\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(x_2, x_1, x_0, T::ZERO, T::ZERO, T::ZERO),\n            (x_2, x_1, x_0)\n        );\n        assert_eq!(\n            T::xxx_sub_yyy_to_zzz(x_2, x_1, x_0, x_2, x_1, x_0),\n            (T::ZERO, T::ZERO, T::ZERO)\n        );\n    });\n}\n\n#[test]\nfn xxx_sub_yyy_to_zzz_properties() {\n    apply_fn_to_unsigneds!(xxx_sub_yyy_to_zzz_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/arithmetic/xxxx_add_yyyy_to_zzzz.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    unsigned_duodecuple_gen_var_1, unsigned_octuple_gen_var_1, unsigned_quadruple_gen_var_10,\n};\n\n#[test]\n#[allow(clippy::too_many_arguments)]\nfn test_xxxx_add_yyyy_to_zzzz() {\n    fn test<T: PrimitiveUnsigned>(\n        x_3: T,\n        x_2: T,\n        x_1: T,\n        x_0: T,\n        y_3: T,\n        y_2: T,\n        y_1: T,\n        y_0: T,\n        z_3: T,\n        z_2: T,\n        z_1: T,\n        z_0: T,\n    ) {\n        assert_eq!(\n            T::xxxx_add_yyyy_to_zzzz(x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0),\n            (z_3, z_2, z_1, z_0)\n        );\n    }\n    test::<u32>(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n    test::<u64>(\n        0x12, 0x34, 0x56, 0x78, 0x33, 0x33, 0x33, 0x33, 0x45, 0x67, 0x89, 0xab,\n    );\n    test::<u8>(\n        0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc, 0xba, 0x98, 0x77, 0x77, 0x77, 0x76,\n    );\n    test::<u8>(u8::MAX, u8::MAX, u8::MAX, u8::MAX, 0, 0, 0, 1, 0, 0, 0, 0);\n    test(\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX,\n        u16::MAX - 1,\n    );\n}\n\nfn xxxx_sub_yyyy_to_zzzz<T: PrimitiveUnsigned>(\n    x_3: T,\n    x_2: T,\n    x_1: T,\n    x_0: T,\n    y_3: T,\n    y_2: T,\n    y_1: T,\n    y_0: T,\n) -> (T, T, T, T) {\n    let (z_0, borrow_1) = x_0.overflowing_sub(y_0);\n    let (mut z_1, mut borrow_2) = x_1.overflowing_sub(y_1);\n    if borrow_1 {\n        borrow_2 |= z_1.overflowing_sub_assign(T::ONE);\n    }\n    let (mut z_2, mut borrow_3) = x_2.overflowing_sub(y_2);\n    if borrow_2 {\n        borrow_3 |= z_2.overflowing_sub_assign(T::ONE);\n    }\n    let mut z_3 = x_3.wrapping_sub(y_3);\n    if borrow_3 {\n        z_3.wrapping_sub_assign(T::ONE);\n    }\n    (z_3, z_2, z_1, z_0)\n}\n\nfn xxxx_add_yyyy_to_zzzz_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_octuple_gen_var_1::<T>().test_properties(\n        |(x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0)| {\n            let (z_3, z_2, z_1, z_0) =\n                T::xxxx_add_yyyy_to_zzzz(x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0);\n\n            assert_eq!(\n                xxxx_sub_yyyy_to_zzzz(z_3, z_2, z_1, z_0, y_3, y_2, y_1, y_0),\n                (x_3, x_2, x_1, x_0)\n            );\n            assert_eq!(\n                xxxx_sub_yyyy_to_zzzz(z_3, z_2, z_1, z_0, x_3, x_2, x_1, x_0),\n                (y_3, y_2, y_1, y_0)\n            );\n            assert_eq!(\n                T::xxxx_add_yyyy_to_zzzz(y_3, y_2, y_1, y_0, x_3, x_2, x_1, x_0),\n                (z_3, z_2, z_1, z_0)\n            );\n\n            let (neg_y_3, neg_y_2, neg_y_1, neg_y_0) =\n                xxxx_sub_yyyy_to_zzzz(T::ZERO, T::ZERO, T::ZERO, T::ZERO, y_3, y_2, y_1, y_0);\n            assert_eq!(\n                xxxx_sub_yyyy_to_zzzz(x_3, x_2, x_1, x_0, neg_y_3, neg_y_2, neg_y_1, neg_y_0),\n                (z_3, z_2, z_1, z_0)\n            );\n        },\n    );\n\n    unsigned_quadruple_gen_var_10::<T>().test_properties(|(x_3, x_2, x_1, x_0)| {\n        assert_eq!(\n            T::xxxx_add_yyyy_to_zzzz(x_3, x_2, x_1, x_0, T::ZERO, T::ZERO, T::ZERO, T::ZERO),\n            (x_3, x_2, x_1, x_0)\n        );\n        assert_eq!(\n            T::xxxx_add_yyyy_to_zzzz(T::ZERO, T::ZERO, T::ZERO, T::ZERO, x_3, x_2, x_1, x_0),\n            (x_3, x_2, x_1, x_0)\n        );\n\n        let (neg_x_3, neg_x_2, neg_x_1, neg_x_0) =\n            xxxx_sub_yyyy_to_zzzz(T::ZERO, T::ZERO, T::ZERO, T::ZERO, x_3, x_2, x_1, x_0);\n        assert_eq!(\n            T::xxxx_add_yyyy_to_zzzz(x_3, x_2, x_1, x_0, neg_x_3, neg_x_2, neg_x_1, neg_x_0),\n            (T::ZERO, T::ZERO, T::ZERO, T::ZERO)\n        );\n    });\n\n    unsigned_duodecuple_gen_var_1::<T>().test_properties(\n        |(x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0, z_3, z_2, z_1, z_0)| {\n            let (sum_1_3, sum_1_2, sum_1_1, sum_1_0) =\n                T::xxxx_add_yyyy_to_zzzz(x_3, x_2, x_1, x_0, y_3, y_2, y_1, y_0);\n            let (sum_2_3, sum_2_2, sum_2_1, sum_2_0) =\n                T::xxxx_add_yyyy_to_zzzz(y_3, y_2, y_1, y_0, z_3, z_2, z_1, z_0);\n            assert_eq!(\n                T::xxxx_add_yyyy_to_zzzz(sum_1_3, sum_1_2, sum_1_1, sum_1_0, z_3, z_2, z_1, z_0),\n                T::xxxx_add_yyyy_to_zzzz(x_3, x_2, x_1, x_0, sum_2_3, sum_2_2, sum_2_1, sum_2_0)\n            );\n        },\n    );\n}\n\n#[test]\nfn xxxx_add_yyyy_to_zzzz_properties() {\n    apply_fn_to_unsigneds!(xxxx_add_yyyy_to_zzzz_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/basic/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Two, Zero,\n};\nuse malachite_base::num::float::NiceFloat;\n\nmacro_rules! test_unsigned_constants {\n    ($t: ident) => {\n        assert_eq!($t::ZERO, 0);\n        assert_eq!($t::ONE, 1);\n        assert_eq!($t::TWO, 2);\n    };\n}\n\nmacro_rules! test_signed_constants {\n    ($t: ident) => {\n        test_unsigned_constants!($t);\n        assert_eq!($t::NEGATIVE_ONE, -1);\n    };\n}\n\nmacro_rules! test_float_constants {\n    ($t: ident) => {\n        assert_eq!($t::ZERO, 0.0);\n        assert_eq!($t::ONE, 1.0);\n        assert_eq!($t::TWO, 2.0);\n        assert_eq!($t::NEGATIVE_ONE, -1.0);\n        assert_eq!($t::NEGATIVE_ZERO, -0.0);\n        assert_eq!($t::ONE_HALF, 0.5);\n    };\n}\n\n#[test]\nfn test_constants() {\n    apply_to_unsigneds!(test_unsigned_constants);\n    apply_to_signeds!(test_signed_constants);\n    apply_to_primitive_floats!(test_float_constants);\n}\n\n#[test]\nfn test_width_constants() {\n    assert_eq!(u8::WIDTH, 8);\n    assert_eq!(u8::LOG_WIDTH, 3);\n    assert_eq!(u8::WIDTH_MASK, 0x7);\n\n    assert_eq!(u16::WIDTH, 16);\n    assert_eq!(u16::LOG_WIDTH, 4);\n    assert_eq!(u16::WIDTH_MASK, 0xf);\n\n    assert_eq!(u32::WIDTH, 32);\n    assert_eq!(u32::LOG_WIDTH, 5);\n    assert_eq!(u32::WIDTH_MASK, 0x1f);\n\n    assert_eq!(u64::WIDTH, 64);\n    assert_eq!(u64::LOG_WIDTH, 6);\n    assert_eq!(u64::WIDTH_MASK, 0x3f);\n\n    assert_eq!(u128::WIDTH, 128);\n    assert_eq!(u128::LOG_WIDTH, 7);\n    assert_eq!(u128::WIDTH_MASK, 0x7f);\n\n    assert_eq!(i8::WIDTH, 8);\n    assert_eq!(i8::LOG_WIDTH, 3);\n    assert_eq!(i8::WIDTH_MASK, 0x7);\n\n    assert_eq!(i16::WIDTH, 16);\n    assert_eq!(i16::LOG_WIDTH, 4);\n    assert_eq!(i16::WIDTH_MASK, 0xf);\n\n    assert_eq!(i32::WIDTH, 32);\n    assert_eq!(i32::LOG_WIDTH, 5);\n    assert_eq!(i32::WIDTH_MASK, 0x1f);\n\n    assert_eq!(i64::WIDTH, 64);\n    assert_eq!(i64::LOG_WIDTH, 6);\n    assert_eq!(i64::WIDTH_MASK, 0x3f);\n\n    assert_eq!(i128::WIDTH, 128);\n    assert_eq!(i128::LOG_WIDTH, 7);\n    assert_eq!(i128::WIDTH_MASK, 0x7f);\n}\n\n#[test]\nfn test_other_float_constants() {\n    assert_eq!(f32::WIDTH, 32);\n    assert_eq!(f32::EXPONENT_WIDTH, 8);\n    assert_eq!(f32::MANTISSA_WIDTH, 23);\n    assert_eq!(f32::MIN_NORMAL_EXPONENT, -126);\n    assert_eq!(f32::MIN_EXPONENT, -149);\n    assert_eq!(f32::MAX_EXPONENT, 127);\n    assert_eq!(NiceFloat(f32::MIN_POSITIVE_SUBNORMAL), NiceFloat(1.0e-45));\n    assert_eq!(NiceFloat(f32::MAX_SUBNORMAL), NiceFloat(1.1754942e-38));\n    assert_eq!(\n        NiceFloat(f32::MIN_POSITIVE_NORMAL),\n        NiceFloat(1.1754944e-38)\n    );\n    assert_eq!(NiceFloat(f32::MAX_FINITE), NiceFloat(3.4028235e38));\n    assert_eq!(NiceFloat(Infinity::INFINITY), NiceFloat(f32::INFINITY));\n    assert_eq!(\n        NiceFloat(f32::NEGATIVE_INFINITY),\n        NiceFloat(f32::NEG_INFINITY)\n    );\n    assert_eq!(NiceFloat(NaN::NAN), NiceFloat(f32::NAN));\n    assert_eq!(f32::SMALLEST_UNREPRESENTABLE_UINT, 0x1000001);\n    assert_eq!(f32::LARGEST_ORDERED_REPRESENTATION, 0xff000001);\n\n    assert_eq!(f64::WIDTH, 64);\n    assert_eq!(f64::EXPONENT_WIDTH, 11);\n    assert_eq!(f64::MANTISSA_WIDTH, 52);\n    assert_eq!(f64::MIN_NORMAL_EXPONENT, -1022);\n    assert_eq!(f64::MIN_EXPONENT, -1074);\n    assert_eq!(f64::MAX_EXPONENT, 1023);\n    assert_eq!(NiceFloat(f64::MIN_POSITIVE_SUBNORMAL), NiceFloat(5.0e-324));\n    assert_eq!(\n        NiceFloat(f64::MAX_SUBNORMAL),\n        NiceFloat(2.225073858507201e-308)\n    );\n    assert_eq!(\n        NiceFloat(f64::MIN_POSITIVE_NORMAL),\n        NiceFloat(2.2250738585072014e-308)\n    );\n    assert_eq!(\n        NiceFloat(f64::MAX_FINITE),\n        NiceFloat(1.7976931348623157e308)\n    );\n    assert_eq!(NiceFloat(Infinity::INFINITY), NiceFloat(f64::INFINITY));\n    assert_eq!(\n        NiceFloat(f64::NEGATIVE_INFINITY),\n        NiceFloat(f64::NEG_INFINITY)\n    );\n    assert_eq!(NiceFloat(NaN::NAN), NiceFloat(f64::NAN));\n    assert_eq!(f32::SMALLEST_UNREPRESENTABLE_UINT, 0x1000001);\n    assert_eq!(f64::LARGEST_ORDERED_REPRESENTATION, 0xffe0000000000001);\n}\n\n#[test]\npub fn test_named() {\n    fn test<T: Named>(out: &str) {\n        assert_eq!(T::NAME, out);\n    }\n    test::<u8>(\"u8\");\n    test::<u16>(\"u16\");\n    test::<u32>(\"u32\");\n    test::<u64>(\"u64\");\n    test::<u128>(\"u128\");\n    test::<usize>(\"usize\");\n    test::<i8>(\"i8\");\n    test::<i16>(\"i16\");\n    test::<i32>(\"i32\");\n    test::<i64>(\"i64\");\n    test::<i128>(\"i128\");\n    test::<isize>(\"isize\");\n    test::<f32>(\"f32\");\n    test::<f64>(\"f64\");\n}\n"
  },
  {
    "path": "malachite-base/tests/num/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::comparison::traits::OrdAbs;\nuse malachite_base::test_util::generators::{signed_gen, signed_pair_gen, signed_triple_gen};\nuse std::cmp::Ordering::{self, *};\n\n#[test]\npub fn test_cmp_abs() {\n    fn test<T: Copy + OrdAbs>(x: T, y: T, cmp: Ordering) {\n        assert_eq!(x.cmp_abs(&y), cmp);\n        assert_eq!(x.partial_cmp_abs(&y), Some(cmp));\n        assert_eq!(x.lt_abs(&y), cmp == Less);\n        assert_eq!(x.gt_abs(&y), cmp == Greater);\n        assert_eq!(x.le_abs(&y), cmp != Greater);\n        assert_eq!(x.ge_abs(&y), cmp != Less);\n    }\n    test(123i64, 123i64, Equal);\n    test(123i64, 456i64, Less);\n    test(456i64, 123i64, Greater);\n\n    test(123i64, -123i64, Equal);\n    test(123i64, -456i64, Less);\n    test(456i64, -123i64, Greater);\n\n    test(-123i64, 123i64, Equal);\n    test(-123i64, 456i64, Less);\n    test(-456i64, 123i64, Greater);\n\n    test(-123i64, -123i64, Equal);\n    test(-123i64, -456i64, Less);\n    test(-456i64, -123i64, Greater);\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    <T as UnsignedAbs>::Output: Ord,\n{\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let cmp = x.cmp_abs(&y);\n        assert_eq!(x.unsigned_abs().cmp(&y.unsigned_abs()), cmp);\n        if x != T::MIN {\n            assert_eq!((-x).cmp_abs(&y), cmp);\n        }\n        if y != T::MIN {\n            assert_eq!(x.cmp_abs(&-y), cmp);\n        }\n        assert_eq!(x.partial_cmp_abs(&y), Some(cmp));\n        assert_eq!(x.lt_abs(&y), cmp == Less);\n        assert_eq!(x.gt_abs(&y), cmp == Greater);\n        assert_eq!(x.le_abs(&y), cmp != Greater);\n        assert_eq!(x.ge_abs(&y), cmp != Less);\n        assert_eq!(y.cmp_abs(&x), cmp.reverse());\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.cmp_abs(&x), Equal);\n        assert!(x.le_abs(&x));\n        assert!(x.ge_abs(&x));\n        assert!(!x.lt_abs(&x));\n        assert!(!x.gt_abs(&x));\n        assert!(x.le_abs(&T::MIN));\n        assert!(x.ge_abs(&T::ZERO));\n    });\n\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n}\n\n#[test]\nfn ord_abs_properties() {\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_11, primitive_float_pair_gen, primitive_float_triple_gen, signed_gen,\n    signed_pair_gen, signed_triple_gen,\n};\n\n#[test]\npub fn test_eq_abs() {\n    fn test<T: Copy + EqAbs>(x: T, y: T, eq: bool) {\n        assert_eq!(x.eq_abs(&y), eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!(y.ne_abs(&x), !eq);\n    }\n    test(123i64, 123i64, true);\n    test(123i64, 456i64, false);\n\n    test(123i64, -123i64, true);\n    test(123i64, -456i64, false);\n\n    test(-123i64, 123i64, true);\n    test(-123i64, 456i64, false);\n\n    test(-123i64, -123i64, true);\n    test(-123i64, -456i64, false);\n\n    test(123.0, 123.0, true);\n    test(123.0, 456.0, false);\n\n    test(123.0, -123.0, true);\n    test(123.0, -456.0, false);\n\n    test(-123.0, 123.0, true);\n    test(-123.0, 456.0, false);\n\n    test(-123.0, -123.0, true);\n    test(-123.0, -456.0, false);\n\n    test(123.0, f64::NAN, false);\n    test(f64::NAN, f64::NAN, false);\n    test(123.0, f64::INFINITY, false);\n    test(123.0, f64::NEGATIVE_INFINITY, false);\n    test(f64::INFINITY, f64::INFINITY, true);\n    test(f64::INFINITY, f64::NEGATIVE_INFINITY, true);\n    test(f64::NEGATIVE_INFINITY, f64::INFINITY, true);\n    test(f64::NEGATIVE_INFINITY, f64::NEGATIVE_INFINITY, true);\n    test(123.0, 0.0, false);\n    test(123.0, -0.0, false);\n    test(0.0, 0.0, true);\n    test(0.0, -0.0, true);\n    test(-0.0, 0.0, true);\n    test(-0.0, -0.0, true);\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    <T as UnsignedAbs>::Output: Eq,\n{\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.unsigned_abs().eq(&y.unsigned_abs()), eq);\n        if x != T::MIN {\n            assert_eq!((-x).eq_abs(&y), eq);\n        }\n        if y != T::MIN {\n            assert_eq!(x.eq_abs(&-y), eq);\n        }\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert!(x.eq_abs(&x));\n        assert!(!x.ne_abs(&x));\n    });\n\n    signed_triple_gen::<T>().test_properties(|(x, y, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n}\n\nfn properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.abs().eq(&y.abs()), eq);\n        assert_eq!((-x).eq_abs(&y), eq);\n        assert_eq!(x.eq_abs(&-y), eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n    });\n\n    primitive_float_gen_var_11::<T>().test_properties(|x| {\n        assert!(x.eq_abs(&x));\n        assert!(!x.ne_abs(&x));\n    });\n\n    primitive_float_triple_gen::<T>().test_properties(|(x, y, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n}\n\n#[test]\nfn eq_abs_properties() {\n    apply_fn_to_signeds!(properties_helper_signed);\n    apply_fn_to_primitive_floats!(properties_helper_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/digits/general_digits/from_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::repeat_n;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{Digits, SaturatingFrom};\nuse malachite_base::slices::{slice_leading_zeros, slice_trailing_zeros};\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_10, unsigned_vec_unsigned_pair_gen_var_7,\n    unsigned_vec_unsigned_pair_gen_var_8, unsigned_vec_unsigned_pair_gen_var_9,\n};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_from_digits_asc() {\n    fn test_ok<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        base: U,\n        digits: &[U],\n        out: T,\n    ) {\n        assert_eq!(T::from_digits_asc(&base, digits.iter().copied()), Some(out));\n    }\n    test_ok::<u8, u64>(64, &[], 0);\n    test_ok::<u8, u64>(64, &[0, 0, 0], 0);\n    test_ok::<u16, u64>(64, &[2], 2);\n    test_ok::<u32, u16>(8, &[3, 7, 1], 123);\n    test_ok::<u32, u16>(256, &[64, 66, 15], 1000000);\n    test_ok::<u32, u64>(256, &[64, 66, 15], 1000000);\n    test_ok::<u64, u32>(2, &[0, 0, 0, 1, 0, 1, 1, 1, 1, 1], 1000);\n\n    test_ok::<u64, u32>(3, &[], 0);\n    test_ok::<u64, u32>(3, &[2], 2);\n    test_ok::<u64, u32>(3, &[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2], 123456);\n    test_ok::<u64, u32>(10, &[6, 5, 4, 3, 2, 1], 123456);\n    test_ok::<u64, u32>(100, &[56, 34, 12], 123456);\n    test_ok::<u64, u32>(123, &[87, 19, 8], 123456);\n    test_ok::<u64, u32>(123, &[87, 19, 8, 0, 0, 0], 123456);\n\n    fn test_err<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(base: U, digits: &[U]) {\n        assert_eq!(T::from_digits_asc(&base, digits.iter().copied()), None);\n    }\n    test_err::<u8, u64>(64, &[1; 1000]);\n    test_err::<u8, u64>(2, &[2]);\n    test_err::<u8, u16>(1000, &[1, 2, 3]);\n}\n\nfn from_digits_asc_fail_helper<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>() {\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_digits_asc(&U::ZERO, digits.iter().copied());\n    });\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_digits_asc(&U::ONE, digits.iter().copied());\n    });\n}\n\n#[test]\npub fn test_from_digits_desc() {\n    fn test_ok<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        base: U,\n        digits: &[U],\n        out: T,\n    ) {\n        assert_eq!(\n            T::from_digits_desc(&base, digits.iter().copied()),\n            Some(out)\n        );\n    }\n    test_ok::<u8, u64>(64, &[], 0);\n    test_ok::<u8, u64>(64, &[0, 0, 0], 0);\n    test_ok::<u16, u64>(64, &[2], 2);\n    test_ok::<u32, u16>(8, &[1, 7, 3], 123);\n    test_ok::<u32, u16>(256, &[15, 66, 64], 1000000);\n    test_ok::<u32, u64>(256, &[15, 66, 64], 1000000);\n    test_ok::<u64, u32>(2, &[1, 1, 1, 1, 1, 0, 1, 0, 0, 0], 1000);\n\n    test_ok::<u64, u32>(3, &[], 0);\n    test_ok::<u64, u32>(3, &[2], 2);\n    test_ok::<u64, u32>(3, &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 123456);\n    test_ok::<u64, u32>(10, &[1, 2, 3, 4, 5, 6], 123456);\n    test_ok::<u64, u32>(100, &[12, 34, 56], 123456);\n    test_ok::<u64, u32>(123, &[8, 19, 87], 123456);\n    test_ok::<u64, u32>(123, &[0, 0, 0, 8, 19, 87], 123456);\n\n    fn test_err<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(base: U, digits: &[U]) {\n        assert_eq!(T::from_digits_desc(&base, digits.iter().copied()), None);\n    }\n    test_err::<u8, u64>(64, &[1; 1000]);\n    test_err::<u8, u64>(2, &[2]);\n    test_err::<u8, u16>(1000, &[1, 2, 3]);\n}\n\nfn from_digits_desc_fail_helper<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>() {\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_digits_desc(&U::ZERO, digits.iter().copied());\n    });\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_digits_desc(&U::ONE, digits.iter().copied());\n    });\n}\n\n#[test]\nfn from_digits_asc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_digits_asc_fail_helper);\n}\n\n#[test]\nfn from_digits_desc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_digits_desc_fail_helper);\n}\n\nfn from_digits_asc_helper<\n    T: Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() {\n    unsigned_vec_unsigned_pair_gen_var_9::<U>().test_properties(|(digits, base)| {\n        T::from_digits_asc(&base, digits.iter().copied());\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_8::<U, T>().test_properties(|(digits, base)| {\n        let n = T::from_digits_asc(&base, digits.iter().copied()).unwrap();\n        assert_eq!(\n            T::from_digits_desc(&base, digits.iter().rev().copied()).unwrap(),\n            n\n        );\n        let trailing_zeros = slice_trailing_zeros(&digits);\n        assert_eq!(\n            Digits::<U>::to_digits_asc(&n, &base),\n            &digits[..digits.len() - trailing_zeros]\n        );\n    });\n\n    unsigned_pair_gen_var_10::<U, T, usize>().test_properties(|(base, u)| {\n        assert_eq!(\n            T::from_digits_asc(&base, repeat_n(U::ZERO, u)).unwrap(),\n            T::ZERO\n        );\n    });\n}\n\n#[test]\nfn from_digits_asc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_digits_asc_helper);\n}\n\nfn from_digits_desc_helper<\n    T: Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() {\n    unsigned_vec_unsigned_pair_gen_var_9::<U>().test_properties(|(digits, base)| {\n        T::from_digits_asc(&base, digits.iter().copied());\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_7::<U, T>().test_properties(|(digits, base)| {\n        let n = T::from_digits_desc(&base, digits.iter().copied()).unwrap();\n        assert_eq!(\n            T::from_digits_asc(&base, digits.iter().rev().copied()).unwrap(),\n            n\n        );\n        let leading_zeros = slice_leading_zeros(&digits);\n        assert_eq!(\n            Digits::<U>::to_digits_desc(&n, &base),\n            &digits[leading_zeros..]\n        );\n    });\n\n    unsigned_pair_gen_var_10::<U, T, usize>().test_properties(|(base, u)| {\n        assert_eq!(\n            T::from_digits_desc(&base, repeat_n(U::ZERO, u)).unwrap(),\n            T::ZERO\n        );\n    });\n}\n\n#[test]\nfn from_digits_desc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_digits_desc_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/digits/general_digits/to_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::digits::general_digits::unsigned_to_digits_asc_naive;\nuse malachite_base::num::conversion::traits::{Digits, ExactFrom, SaturatingFrom, WrappingFrom};\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_4, unsigned_pair_gen_var_6,\n};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_to_digits_asc() {\n    fn test<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(x: T, base: U, out: &[U]) {\n        assert_eq!(x.to_digits_asc(&base), out);\n    }\n    test::<u8, u64>(0, 64, &[]);\n    test::<u16, u64>(2, 64, &[2]);\n    test::<u32, u16>(123, 8, &[3, 7, 1]);\n    test::<u32, u16>(1000000, 256, &[64, 66, 15]);\n    test::<u32, u64>(1000000, 256, &[64, 66, 15]);\n    test::<u64, u32>(1000, 2, &[0, 0, 0, 1, 0, 1, 1, 1, 1, 1]);\n\n    test::<u64, u32>(0, 3, &[]);\n    test::<u64, u32>(2, 3, &[2]);\n    test::<u64, u32>(123456, 3, &[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2]);\n    test::<u64, u32>(123456, 10, &[6, 5, 4, 3, 2, 1]);\n    test::<u64, u32>(123456, 100, &[56, 34, 12]);\n    test::<u64, u32>(123456, 123, &[87, 19, 8]);\n}\n\nfn to_digits_asc_fail_helper<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>() {\n    assert_panic!(T::exact_from(100).to_digits_asc(&U::ZERO));\n    assert_panic!(T::exact_from(100).to_digits_asc(&U::ONE));\n    if T::WIDTH < U::WIDTH {\n        assert_panic!(T::exact_from(100).to_digits_asc(&U::power_of_2(T::WIDTH)));\n    }\n}\n\n#[test]\nfn to_digits_asc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_digits_asc_fail_helper);\n}\n\n#[test]\npub fn test_to_digits_desc() {\n    fn test<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(x: T, base: U, out: &[U]) {\n        assert_eq!(x.to_digits_desc(&base), out);\n    }\n    test::<u8, u64>(0, 64, &[]);\n    test::<u16, u64>(2, 64, &[2]);\n    test::<u32, u16>(123, 8, &[1, 7, 3]);\n    test::<u32, u16>(1000000, 256, &[15, 66, 64]);\n    test::<u32, u64>(1000000, 256, &[15, 66, 64]);\n    test::<u64, u32>(1000, 2, &[1, 1, 1, 1, 1, 0, 1, 0, 0, 0]);\n\n    test::<u64, u32>(0, 3, &[]);\n    test::<u64, u32>(2, 3, &[2]);\n    test::<u64, u32>(123456, 3, &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0]);\n    test::<u64, u32>(123456, 10, &[1, 2, 3, 4, 5, 6]);\n    test::<u64, u32>(123456, 100, &[12, 34, 56]);\n    test::<u64, u32>(123456, 123, &[8, 19, 87]);\n}\n\nfn to_digits_desc_fail_helper<T: Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>() {\n    assert_panic!(T::exact_from(100).to_digits_desc(&U::ZERO));\n    assert_panic!(T::exact_from(100).to_digits_desc(&U::ONE));\n    if T::WIDTH < U::WIDTH {\n        assert_panic!(T::exact_from(100).to_digits_desc(&U::power_of_2(T::WIDTH)));\n    }\n}\n\n#[test]\nfn to_digits_desc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_digits_desc_fail_helper);\n}\n\nfn to_digits_asc_helper<\n    T: Digits<U> + ExactFrom<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>,\n>() {\n    unsigned_pair_gen_var_6::<T, U>().test_properties(|(u, base)| {\n        let digits = u.to_digits_asc(&base);\n        assert_eq!(unsigned_to_digits_asc_naive(&u, base), digits);\n        assert_eq!(\n            T::from_digits_asc(&base, digits.iter().copied()).unwrap(),\n            u\n        );\n        if u != T::ZERO {\n            assert_ne!(*digits.last().unwrap(), U::ZERO);\n        }\n        assert_eq!(\n            digits.iter().copied().rev().collect_vec(),\n            u.to_digits_desc(&base)\n        );\n        if u != T::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                u.floor_log_base(T::exact_from(base)) + 1\n            );\n        }\n        assert!(digits.iter().all(|&digit| digit <= base));\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(\n            u.to_digits_asc(&U::TWO)\n                .into_iter()\n                .map(|digit| digit == U::ONE)\n                .collect_vec(),\n            u.to_bits_asc()\n        );\n    });\n\n    unsigned_gen_var_4::<T, U>().test_properties(|base| {\n        assert!(T::ZERO.to_digits_asc(&base).is_empty());\n    });\n}\n\n#[test]\nfn to_digits_asc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_digits_asc_helper);\n}\n\nfn to_digits_desc_helper<\n    T: Digits<U> + ExactFrom<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned + SaturatingFrom<T>,\n>() {\n    unsigned_pair_gen_var_6::<T, U>().test_properties(|(u, base)| {\n        let digits = u.to_digits_desc(&base);\n        assert_eq!(\n            T::from_digits_desc(&base, digits.iter().copied()).unwrap(),\n            u\n        );\n        if u != T::ZERO {\n            assert_ne!(digits[0], U::ZERO);\n        }\n        assert_eq!(\n            digits.iter().copied().rev().collect_vec(),\n            u.to_digits_asc(&base)\n        );\n        if u != T::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                u.floor_log_base(T::exact_from(base)) + 1\n            );\n        }\n        assert!(digits.iter().all(|&digit| digit <= base));\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(\n            u.to_digits_desc(&U::TWO)\n                .into_iter()\n                .map(|digit| digit == U::ONE)\n                .collect_vec(),\n            u.to_bits_desc()\n        );\n    });\n\n    unsigned_gen_var_4::<T, U>().test_properties(|base| {\n        assert!(T::ZERO.to_digits_desc(&base).is_empty());\n    });\n}\n\n#[test]\nfn to_digits_desc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_digits_desc_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/digits/power_of_2_digits/from_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::repeat_n;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::PowerOf2Digits;\nuse malachite_base::slices::{slice_leading_zeros, slice_trailing_zeros};\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_5, unsigned_vec_unsigned_pair_gen_var_2,\n    unsigned_vec_unsigned_pair_gen_var_3, unsigned_vec_unsigned_pair_gen_var_6,\n};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_from_power_of_2_digits_asc() {\n    fn test_ok<T: PowerOf2Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        log_base: u64,\n        digits: &[U],\n        out: T,\n    ) {\n        assert_eq!(\n            T::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap(),\n            out\n        );\n    }\n    test_ok::<u8, u64>(6, &[], 0);\n    test_ok::<u16, u64>(6, &[2], 2);\n    test_ok::<u32, u16>(3, &[3, 7, 1], 123);\n    test_ok::<u32, u8>(8, &[64, 66, 15], 1000000);\n    test_ok::<u32, u64>(8, &[64, 66, 15], 1000000);\n    test_ok::<u64, u32>(1, &[0, 0, 0, 1, 0, 1, 1, 1, 1, 1], 1000);\n\n    fn test_err<T: PowerOf2Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        log_base: u64,\n        digits: &[U],\n    ) {\n        assert_eq!(\n            T::from_power_of_2_digits_asc(log_base, digits.iter().copied()),\n            None\n        );\n    }\n    test_err::<u8, u64>(4, &[1; 100]);\n    test_err::<u8, u64>(1, &[2]);\n}\n\nfn from_power_of_2_digits_asc_fail_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_power_of_2_digits_asc(U::WIDTH + 1, digits.iter().copied());\n    });\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_power_of_2_digits_asc(0, digits.iter().copied());\n    });\n}\n\n#[test]\nfn from_power_of_2_digits_asc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_power_of_2_digits_asc_fail_helper);\n}\n\n#[test]\npub fn test_from_power_of_2_digits_desc() {\n    fn test_ok<T: PowerOf2Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        log_base: u64,\n        digits: &[U],\n        out: T,\n    ) {\n        assert_eq!(\n            T::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap(),\n            out\n        );\n    }\n    test_ok::<u8, u64>(6, &[], 0);\n    test_ok::<u16, u64>(6, &[2], 2);\n    test_ok::<u32, u16>(3, &[1, 7, 3], 123);\n    test_ok::<u32, u8>(8, &[15, 66, 64], 1000000);\n    test_ok::<u32, u64>(8, &[15, 66, 64], 1000000);\n    test_ok::<u64, u32>(1, &[1, 1, 1, 1, 1, 0, 1, 0, 0, 0], 1000);\n\n    fn test_err<T: PowerOf2Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        log_base: u64,\n        digits: &[U],\n    ) {\n        assert_eq!(\n            T::from_power_of_2_digits_desc(log_base, digits.iter().copied()),\n            None\n        );\n    }\n    test_err::<u8, u64>(4, &[1; 100]);\n    test_err::<u8, u64>(1, &[2]);\n}\n\nfn from_power_of_2_digits_desc_fail_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_power_of_2_digits_desc(U::WIDTH + 1, digits.iter().copied());\n    });\n    assert_panic!({\n        let digits: &[U] = &[U::ONE];\n        T::from_power_of_2_digits_desc(0, digits.iter().copied());\n    });\n}\n\n#[test]\nfn from_power_of_2_digits_desc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_power_of_2_digits_desc_fail_helper);\n}\n\nfn from_power_of_2_digits_asc_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_vec_unsigned_pair_gen_var_6::<U>().test_properties(|(digits, log_base)| {\n        T::from_power_of_2_digits_asc(log_base, digits.iter().copied());\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_2::<T, U>().test_properties(|(digits, log_base)| {\n        let n = T::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap();\n        assert_eq!(\n            T::from_power_of_2_digits_desc(log_base, digits.iter().rev().copied()).unwrap(),\n            n\n        );\n        let trailing_zeros = slice_trailing_zeros(&digits);\n        assert_eq!(\n            PowerOf2Digits::<U>::to_power_of_2_digits_asc(&n, log_base),\n            &digits[..digits.len() - trailing_zeros]\n        );\n    });\n\n    unsigned_pair_gen_var_5::<usize, U>().test_properties(|(u, log_base)| {\n        assert_eq!(\n            T::from_power_of_2_digits_asc(log_base, repeat_n(U::ZERO, u)).unwrap(),\n            T::ZERO\n        );\n    });\n}\n\n#[test]\nfn from_power_of_2_digits_asc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_power_of_2_digits_asc_helper);\n}\n\nfn from_power_of_2_digits_desc_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_vec_unsigned_pair_gen_var_6::<U>().test_properties(|(digits, log_base)| {\n        T::from_power_of_2_digits_desc(log_base, digits.iter().copied());\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_3::<T, U>().test_properties(|(digits, log_base)| {\n        let n = T::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap();\n        assert_eq!(\n            T::from_power_of_2_digits_asc(log_base, digits.iter().rev().copied()).unwrap(),\n            n\n        );\n        let leading_zeros = slice_leading_zeros(&digits);\n        assert_eq!(\n            PowerOf2Digits::<U>::to_power_of_2_digits_desc(&n, log_base),\n            &digits[leading_zeros..]\n        );\n    });\n\n    unsigned_pair_gen_var_5::<usize, U>().test_properties(|(u, log_base)| {\n        assert_eq!(\n            T::from_power_of_2_digits_desc(log_base, repeat_n(U::ZERO, u)).unwrap(),\n            T::ZERO\n        );\n    });\n}\n\n#[test]\nfn from_power_of_2_digits_desc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_power_of_2_digits_desc_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/digits/power_of_2_digits/power_of_2_digit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivRound;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, PowerOf2DigitIterable, PowerOf2DigitIterator, PowerOf2Digits,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::common::test_double_ended_iterator_size_hint;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_4, unsigned_pair_gen_var_5, unsigned_triple_gen_var_3,\n    unsigned_unsigned_bool_vec_triple_gen_var_1,\n};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_power_of_2_digits() {\n    assert_eq!(\n        PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&107u32, 2),\n        &[3, 2, 2, 1]\n    );\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(107u32, 2);\n    assert_eq!(digits.next(), Some(3));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(2));\n    assert_eq!(digits.next(), Some(2));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 3);\n    assert_eq!(digits.get_digit(1), 2);\n    assert_eq!(digits.get_digit(2), 2);\n    assert_eq!(digits.get_digit(3), 1);\n    assert_eq!(digits.get_digit(4), 0);\n    assert_eq!(digits.get_digit(5), 0);\n\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(107u32, 2);\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next(), Some(3));\n    assert_eq!(digits.next(), Some(2));\n    assert_eq!(digits.next(), Some(2));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    let mut digits = PowerOf2DigitIterable::<u32>::power_of_2_digits(0u8, 5);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(\n        PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&105u32, 1),\n        &[1, 0, 0, 1, 0, 1, 1]\n    );\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(105u32, 1);\n    assert_eq!(digits.next(), Some(1));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(0));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next(), Some(1));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 1);\n    assert_eq!(digits.get_digit(1), 0);\n    assert_eq!(digits.get_digit(2), 0);\n    assert_eq!(digits.get_digit(3), 1);\n    assert_eq!(digits.get_digit(4), 0);\n    assert_eq!(digits.get_digit(5), 1);\n    assert_eq!(digits.get_digit(6), 1);\n    assert_eq!(digits.get_digit(7), 0);\n    assert_eq!(digits.get_digit(8), 0);\n\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(105u32, 1);\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next(), Some(1));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(0));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n}\n\nfn power_of_2_digits_fail_helper<\n    T: PowerOf2DigitIterable<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    assert_panic!(PowerOf2DigitIterable::<U>::power_of_2_digits(\n        T::exact_from(107),\n        0\n    ));\n    assert_panic!(PowerOf2DigitIterable::<U>::power_of_2_digits(\n        T::exact_from(107),\n        200\n    ));\n}\n\n#[test]\nfn power_of_2_digits_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(power_of_2_digits_fail_helper);\n}\n\nfn power_of_2_digit_iterable_helper<\n    T: PowerOf2DigitIterable<U> + PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>()\nwhere\n    <T as PowerOf2DigitIterable<U>>::PowerOf2DigitIterator: Clone,\n{\n    unsigned_pair_gen_var_4::<T, U>().test_properties(|(u, log_base)| {\n        test_double_ended_iterator_size_hint(\n            PowerOf2DigitIterable::<U>::power_of_2_digits(u, log_base),\n            usize::exact_from(u.significant_bits().div_round(log_base, Ceiling).0),\n        );\n    });\n\n    unsigned_unsigned_bool_vec_triple_gen_var_1::<T, U>().test_properties(\n        |(u, log_base, ref bs)| {\n            let mut digits = PowerOf2DigitIterable::<U>::power_of_2_digits(u, log_base);\n            let mut digit_vec = Vec::new();\n            let mut i = 0;\n            for &b in bs {\n                if b {\n                    digit_vec.insert(i, digits.next().unwrap());\n                    i += 1;\n                } else {\n                    digit_vec.insert(i, digits.next_back().unwrap());\n                }\n            }\n            assert!(digits.next().is_none());\n            assert!(digits.next_back().is_none());\n            assert_eq!(\n                PowerOf2Digits::<U>::to_power_of_2_digits_asc(&u, log_base),\n                digit_vec\n            );\n        },\n    );\n\n    unsigned_triple_gen_var_3::<T, U, u64>().test_properties(|(u, log_base, i)| {\n        let digits = PowerOf2DigitIterable::<U>::power_of_2_digits(u, log_base);\n        if i < u.significant_bits().div_round(log_base, Ceiling).0 {\n            assert_eq!(\n                digits.get_digit(i),\n                PowerOf2Digits::<U>::to_power_of_2_digits_asc(&u, log_base)[usize::exact_from(i)]\n            );\n        } else {\n            assert_eq!(digits.get_digit(i), U::ZERO);\n        }\n    });\n\n    unsigned_pair_gen_var_5::<u64, U>().test_properties(|(i, log_base)| {\n        let digits = PowerOf2DigitIterable::<U>::power_of_2_digits(T::ZERO, log_base);\n        assert_eq!(digits.get_digit(i), U::ZERO);\n    });\n}\n\n#[test]\nfn power_of_2_digit_iterable_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(power_of_2_digit_iterable_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/digits/power_of_2_digits/to_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::DivRound;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, PowerOf2Digits};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_3, unsigned_pair_gen_var_4,\n};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_to_power_of_2_digits_asc() {\n    fn test<T: PowerOf2Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        x: T,\n        log_base: u64,\n        out: &[U],\n    ) {\n        assert_eq!(\n            PowerOf2Digits::<U>::to_power_of_2_digits_asc(&x, log_base),\n            out\n        );\n    }\n    test::<u8, u64>(0, 6, &[]);\n    test::<u16, u64>(2, 6, &[2]);\n    test::<u32, u16>(123, 3, &[3, 7, 1]);\n    test::<u32, u8>(1000000, 8, &[64, 66, 15]);\n    test::<u32, u64>(1000000, 8, &[64, 66, 15]);\n    test::<u64, u32>(1000, 1, &[0, 0, 0, 1, 0, 1, 1, 1, 1, 1]);\n}\n\nfn to_power_of_2_digits_asc_fail_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    assert_panic!(PowerOf2Digits::<U>::to_power_of_2_digits_asc(\n        &T::exact_from(100),\n        U::WIDTH + 1\n    ));\n    assert_panic!(PowerOf2Digits::<U>::to_power_of_2_digits_asc(\n        &T::exact_from(100),\n        0\n    ));\n}\n\n#[test]\nfn to_power_of_2_digits_asc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_power_of_2_digits_asc_fail_helper);\n}\n\n#[test]\npub fn test_to_power_of_2_digits_desc() {\n    fn test<T: PowerOf2Digits<U> + PrimitiveUnsigned, U: PrimitiveUnsigned>(\n        x: T,\n        log_base: u64,\n        out: &[U],\n    ) {\n        assert_eq!(\n            PowerOf2Digits::<U>::to_power_of_2_digits_desc(&x, log_base),\n            out\n        );\n    }\n    test::<u8, u64>(0, 6, &[]);\n    test::<u16, u64>(2, 6, &[2]);\n    test::<u32, u16>(123, 3, &[1, 7, 3]);\n    test::<u32, u8>(1000000, 8, &[15, 66, 64]);\n    test::<u32, u64>(1000000, 8, &[15, 66, 64]);\n    test::<u64, u32>(1000, 1, &[1, 1, 1, 1, 1, 0, 1, 0, 0, 0]);\n}\n\nfn to_power_of_2_digits_desc_fail_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    assert_panic!(PowerOf2Digits::<U>::to_power_of_2_digits_desc(\n        &T::exact_from(100),\n        U::WIDTH + 1\n    ));\n    assert_panic!(PowerOf2Digits::<U>::to_power_of_2_digits_desc(\n        &T::exact_from(100),\n        0\n    ));\n}\n\n#[test]\nfn to_power_of_2_digits_desc_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_power_of_2_digits_desc_fail_helper);\n}\n\nfn to_power_of_2_digits_asc_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_pair_gen_var_4::<T, U>().test_properties(|(u, log_base)| {\n        let digits = PowerOf2Digits::<U>::to_power_of_2_digits_asc(&u, log_base);\n        assert_eq!(\n            T::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap(),\n            u\n        );\n        if u != T::ZERO {\n            assert_ne!(*digits.last().unwrap(), U::ZERO);\n        }\n        assert_eq!(\n            digits.iter().copied().rev().collect_vec(),\n            u.to_power_of_2_digits_desc(log_base)\n        );\n        if u != T::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                u.floor_log_base_power_of_2(log_base) + 1\n            );\n        }\n        assert!(\n            digits\n                .iter()\n                .all(|digit| digit.significant_bits() <= log_base)\n        );\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(\n            u.to_power_of_2_digits_asc(1)\n                .into_iter()\n                .map(|digit: U| digit == U::ONE)\n                .collect_vec(),\n            u.to_bits_asc()\n        );\n    });\n\n    unsigned_gen_var_3::<U>().test_properties(|log_base| {\n        assert!(PowerOf2Digits::<U>::to_power_of_2_digits_asc(&T::ZERO, log_base).is_empty());\n    });\n}\n\n#[test]\nfn to_power_of_2_digits_asc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_power_of_2_digits_asc_helper);\n}\n\nfn to_power_of_2_digits_desc_helper<\n    T: PowerOf2Digits<U> + PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_pair_gen_var_4::<T, U>().test_properties(|(u, log_base)| {\n        let digits = PowerOf2Digits::<U>::to_power_of_2_digits_desc(&u, log_base);\n        assert_eq!(\n            T::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap(),\n            u\n        );\n        if u != T::ZERO {\n            assert_ne!(digits[0], U::ZERO);\n        }\n        if u != T::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                u.floor_log_base_power_of_2(log_base) + 1\n            );\n        }\n        assert_eq!(\n            digits.len(),\n            usize::exact_from(u.significant_bits().div_round(log_base, Ceiling).0)\n        );\n        assert!(\n            digits\n                .iter()\n                .all(|digit| digit.significant_bits() <= log_base)\n        );\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(\n            u.to_power_of_2_digits_desc(1)\n                .into_iter()\n                .map(|digit: U| digit == U::ONE)\n                .collect_vec(),\n            u.to_bits_desc()\n        );\n    });\n\n    unsigned_gen_var_3::<U>().test_properties(|log_base| {\n        assert!(PowerOf2Digits::<U>::to_power_of_2_digits_desc(&T::ZERO, log_base).is_empty());\n    });\n}\n\n#[test]\nfn to_power_of_2_digits_desc_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(to_power_of_2_digits_desc_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/froms/convertible_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen, unsigned_gen};\nuse std::fmt::Debug;\n\n#[test]\npub fn test_convertible_from() {\n    fn test_single<T: ConvertibleFrom<T> + Copy + Debug>(n: T) {\n        assert!(T::convertible_from(n));\n    }\n    test_single(0u8);\n    test_single(5u64);\n    test_single(1000u32);\n    test_single(123u8);\n    test_single(-123i16);\n    test_single(i64::MIN);\n    test_single(usize::MAX);\n\n    fn test_double<T, U: ConvertibleFrom<T>>(n_in: T, convertible: bool) {\n        assert_eq!(U::convertible_from(n_in), convertible);\n    }\n    test_double::<_, u16>(0u8, true);\n    test_double::<_, i32>(1000u16, true);\n    test_double::<_, i8>(-5i16, true);\n    test_double::<_, u64>(255u8, true);\n\n    test_double::<_, u32>(-1i8, false);\n    test_double::<_, u16>(u32::MAX, false);\n    test_double::<_, u32>(i32::MIN, false);\n    test_double::<_, u16>(i32::MIN, false);\n    test_double::<_, i16>(i32::MIN, false);\n    test_double::<_, u32>(-5i32, false);\n    test_double::<_, i32>(3000000000u32, false);\n    test_double::<_, i8>(-1000i16, false);\n\n    test_double::<_, u8>(0.0f32, true);\n    test_double::<_, u8>(-0.0f32, true);\n    test_double::<_, u8>(123.0f32, true);\n    test_double::<_, i8>(-123.0f32, true);\n    test_double::<_, u8>(-123.0f32, false);\n    test_double::<_, u8>(500.0f32, false);\n    test_double::<_, u8>(123.1f32, false);\n    test_double::<_, u8>(f32::NAN, false);\n    test_double::<_, u8>(f32::INFINITY, false);\n    test_double::<_, u8>(f32::NEGATIVE_INFINITY, false);\n    test_double::<_, u8>(255.0f32, true);\n    test_double::<_, u8>(256.0f32, false);\n    test_double::<_, i8>(127.0f32, true);\n    test_double::<_, i8>(128.0f32, false);\n    test_double::<_, i8>(-128.0f32, true);\n    test_double::<_, i8>(-129.0f32, false);\n\n    test_double::<_, f32>(0u8, true);\n    test_double::<_, f32>(123u8, true);\n    test_double::<_, f32>(-123i8, true);\n    test_double::<_, f32>(u128::MAX, false);\n    test_double::<_, f32>(i128::MIN, true);\n    test_double::<_, f32>(i128::MIN + 1, false);\n    test_double::<_, f32>(u32::MAX, false);\n    test_double::<_, f32>(i32::MIN, true);\n    test_double::<_, f32>(i32::MIN + 1, false);\n}\n\nfn convertible_from_helper_primitive_int_unsigned<\n    T: TryFrom<U> + ConvertibleFrom<U> + PrimitiveInt,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_gen::<U>().test_properties(|u| {\n        let convertible = T::convertible_from(u);\n        assert_eq!(convertible, T::try_from(u).is_ok());\n    });\n}\n\nfn convertible_from_helper_primitive_int_signed<\n    T: TryFrom<U> + ConvertibleFrom<U> + PrimitiveInt,\n    U: PrimitiveSigned,\n>() {\n    signed_gen::<U>().test_properties(|i| {\n        let convertible = T::convertible_from(i);\n        assert_eq!(convertible, T::try_from(i).is_ok());\n    });\n}\n\nfn convertible_from_helper_primitive_int_primitive_float<\n    T: TryFrom<NiceFloat<U>> + ConvertibleFrom<U> + PrimitiveInt,\n    U: PrimitiveFloat,\n>() {\n    primitive_float_gen::<U>().test_properties(|f| {\n        let convertible = T::convertible_from(f);\n        assert_eq!(convertible, T::try_from(NiceFloat(f)).is_ok());\n    });\n}\n\nfn convertible_from_helper_primitive_float_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat,\n    U: PrimitiveUnsigned,\n>()\nwhere\n    NiceFloat<T>: TryFrom<U>,\n{\n    unsigned_gen::<U>().test_properties(|u| {\n        let convertible = T::convertible_from(u);\n        assert_eq!(convertible, NiceFloat::<T>::try_from(u).is_ok());\n    });\n}\n\nfn convertible_from_helper_primitive_float_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat,\n    U: PrimitiveSigned,\n>()\nwhere\n    NiceFloat<T>: TryFrom<U>,\n{\n    signed_gen::<U>().test_properties(|i| {\n        let convertible = T::convertible_from(i);\n        assert_eq!(convertible, NiceFloat::<T>::try_from(i).is_ok());\n    });\n}\n\n#[test]\nfn convertible_from_properties() {\n    apply_fn_to_primitive_ints_and_unsigneds!(convertible_from_helper_primitive_int_unsigned);\n    apply_fn_to_primitive_ints_and_signeds!(convertible_from_helper_primitive_int_signed);\n    apply_fn_to_primitive_ints_and_primitive_floats!(\n        convertible_from_helper_primitive_int_primitive_float\n    );\n    apply_fn_to_primitive_floats_and_unsigneds!(convertible_from_helper_primitive_float_unsigned);\n    apply_fn_to_primitive_floats_and_signeds!(convertible_from_helper_primitive_float_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/froms/from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    FromOtherTypeSlice, JoinHalves, SplitInHalf, VecFromOtherType, VecFromOtherTypeSlice,\n};\nuse std::fmt::Debug;\n\nfn split_in_half_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: (T::Half, T::Half))\nwhere\n    T::Half: PrimitiveUnsigned,\n{\n    assert_eq!(n.split_in_half(), out);\n}\n\n#[test]\npub fn test_split_in_half() {\n    split_in_half_helper(0u64, (0u32, 0u32));\n    split_in_half_helper(1u64, (0u32, 1u32));\n    split_in_half_helper(u16::from(u8::MAX), (0, u8::MAX));\n    split_in_half_helper(u16::from(u8::MAX) + 1, (1, 0));\n    split_in_half_helper(u16::MAX, (u8::MAX, u8::MAX));\n    split_in_half_helper(258u16, (1u8, 2u8));\n    split_in_half_helper(0xabcd1234u32, (0xabcd, 0x1234));\n}\n\nfn lower_half_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: T::Half)\nwhere\n    T::Half: PrimitiveUnsigned,\n{\n    assert_eq!(n.lower_half(), out);\n}\n\n#[test]\npub fn test_lower_half() {\n    lower_half_helper(0u64, 0u32);\n    lower_half_helper(1u64, 1u32);\n    lower_half_helper(u16::from(u8::MAX), u8::MAX);\n    lower_half_helper(u16::from(u8::MAX) + 1, 0);\n    lower_half_helper(u16::MAX, u8::MAX);\n    lower_half_helper(258u16, 2u8);\n    lower_half_helper(0xabcd1234u32, 0x1234);\n}\n\nfn upper_half_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: T::Half)\nwhere\n    T::Half: PrimitiveUnsigned,\n{\n    assert_eq!(n.upper_half(), out);\n}\n\n#[test]\npub fn test_upper_half() {\n    upper_half_helper(0u64, 0u32);\n    upper_half_helper(1u64, 0u32);\n    upper_half_helper(u16::from(u8::MAX), 0);\n    upper_half_helper(u16::from(u8::MAX) + 1, 1);\n    upper_half_helper(u16::MAX, u8::MAX);\n    upper_half_helper(258u16, 1u8);\n    upper_half_helper(0xabcd1234u32, 0xabcd);\n}\n\nfn join_halves_helper<T: JoinHalves + PrimitiveUnsigned>(upper: T::Half, lower: T::Half, out: T) {\n    assert_eq!(T::join_halves(upper, lower), out);\n}\n\n#[test]\npub fn test_join_halves() {\n    join_halves_helper(0u32, 0u32, 0u64);\n    join_halves_helper(0u32, 1u32, 1u64);\n    join_halves_helper(0, u8::MAX, u16::from(u8::MAX));\n    join_halves_helper(1, 0, u16::from(u8::MAX) + 1);\n    join_halves_helper(u8::MAX, u8::MAX, u16::MAX);\n    join_halves_helper(1, 2, 258u16);\n    join_halves_helper(0xabcd, 0x1234, 0xabcd1234u32);\n}\n\n#[test]\npub fn test_from_other_type_slice() {\n    fn test<T: Debug + Eq, U: Copy + Debug + Eq + FromOtherTypeSlice<T>>(slice: &[T], n: U) {\n        assert_eq!(U::from_other_type_slice(slice), n);\n    }\n    test::<u32, u32>(&[], 0);\n    test::<u32, u32>(&[123], 123);\n    test::<u32, u32>(&[123, 456], 123);\n\n    test::<u8, u16>(&[0xab], 0xab);\n    test::<u8, u16>(&[0xab, 0xcd], 0xcdab);\n    test::<u8, u16>(&[0xab, 0xcd, 0xef], 0xcdab);\n    test::<u8, u64>(\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67],\n        0x67452301efcdab,\n    );\n    test::<u8, u64>(\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xff],\n        0x8967452301efcdab,\n    );\n\n    test::<u64, u32>(&[], 0);\n    test::<u16, u8>(&[0xabcd, 0xef01], 0xcd);\n    test::<u128, u8>(&[0x1234567890a9cdef012345678909bcde], 0xde);\n}\n\n#[test]\npub fn test_vec_from_other_type_slice() {\n    fn test<T: Debug + Eq, U: Debug + Eq + VecFromOtherTypeSlice<T>>(slice: &[T], vec: &[U]) {\n        assert_eq!(U::vec_from_other_type_slice(slice), vec);\n    }\n    test::<u32, u32>(&[123, 456], &[123, 456]);\n    test::<u8, u16>(\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xff],\n        &[0xcdab, 0x01ef, 0x4523, 0x8967, 0xff],\n    );\n    test::<u8, u16>(&[0xab], &[0xab]);\n    test::<u16, u8>(\n        &[0xcdab, 0x01ef, 0x4523, 0x8967],\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89],\n    );\n}\n\n#[test]\npub fn test_vec_from_other_type() {\n    fn test<T: Debug + Eq, U: Debug + Eq + VecFromOtherType<T>>(value: T, vec: &[U]) {\n        assert_eq!(U::vec_from_other_type(value), vec);\n    }\n    test::<u32, u32>(123, &[123]);\n    test::<u8, u16>(0xab, &[0xab]);\n    test::<u16, u8>(0xcdab, &[0xab, 0xcd]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/froms/overflowing_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, OverflowingFrom, WrappingFrom};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse std::fmt::Debug;\n\n#[test]\npub fn test_overflowing_from() {\n    fn test_single<T: Copy + Debug + Eq + OverflowingFrom<T>>(n: T) {\n        assert_eq!(T::overflowing_from(n), (n, false));\n    }\n    test_single(0u8);\n    test_single(5u64);\n    test_single(1000u32);\n    test_single(123u8);\n    test_single(-123i16);\n    test_single(i64::MIN);\n    test_single(usize::MAX);\n\n    fn test_double<T, U: Copy + Debug + Eq + OverflowingFrom<T>>(n_in: T, n_out: (U, bool)) {\n        assert_eq!(U::overflowing_from(n_in), n_out);\n    }\n    test_double(0u8, (0u16, false));\n    test_double(1000u16, (1000i32, false));\n    test_double(-5i16, (-5i8, false));\n    test_double(255u8, (255u64, false));\n\n    test_double(-1i8, (u32::MAX, true));\n    test_double(u32::MAX, (u16::MAX, true));\n    test_double(i32::MIN, (0x80000000u32, true));\n    test_double(i32::MIN, (0u16, true));\n    test_double(i32::MIN, (0i16, true));\n    test_double(-5i32, (0xfffffffbu32, true));\n    test_double(3000000000u32, (-1294967296i32, true));\n    test_double(-1000i16, (24i8, true));\n}\n\nfn overflowing_from_helper_primitive_int_unsigned<\n    T: ConvertibleFrom<U> + OverflowingFrom<U> + WrappingFrom<U> + PrimitiveInt,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_gen::<U>().test_properties(|u| {\n        let result = T::overflowing_from(u);\n        assert_eq!(result, (T::wrapping_from(u), !T::convertible_from(u)));\n    });\n}\n\nfn overflowing_from_helper_primitive_int_signed<\n    T: ConvertibleFrom<U> + OverflowingFrom<U> + WrappingFrom<U> + PrimitiveInt,\n    U: PrimitiveSigned,\n>() {\n    signed_gen::<U>().test_properties(|i| {\n        let result = T::overflowing_from(i);\n        assert_eq!(result, (T::wrapping_from(i), !T::convertible_from(i)));\n    });\n}\n\n#[test]\nfn overflowing_from_properties() {\n    apply_fn_to_primitive_ints_and_unsigneds!(overflowing_from_helper_primitive_int_unsigned);\n    apply_fn_to_primitive_ints_and_signeds!(overflowing_from_helper_primitive_int_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/froms/rounding_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom, WrappingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_13, primitive_float_gen_var_14, primitive_float_gen_var_15,\n    primitive_float_gen_var_16, primitive_float_gen_var_17,\n    primitive_float_rounding_mode_pair_gen_var_3, signed_gen_var_7, signed_gen_var_8,\n    signed_gen_var_9, signed_rounding_mode_pair_gen_var_4, unsigned_gen_var_18,\n    unsigned_gen_var_19, unsigned_gen_var_20, unsigned_rounding_mode_pair_gen_var_2,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_rounding_from() {\n    fn test_from_floating_point<T: PrimitiveFloat, U: PrimitiveInt + RoundingFrom<T>>(\n        n_in: T,\n        rm: RoundingMode,\n        n_out: U,\n        o: Ordering,\n    ) {\n        assert_eq!(U::rounding_from(n_in, rm), (n_out, o));\n    }\n    test_from_floating_point::<f32, u8>(0.0, Down, 0, Equal);\n    test_from_floating_point::<f32, u8>(0.0, Floor, 0, Equal);\n    test_from_floating_point::<f32, u8>(0.0, Up, 0, Equal);\n    test_from_floating_point::<f32, u8>(0.0, Ceiling, 0, Equal);\n    test_from_floating_point::<f32, u8>(0.0, Nearest, 0, Equal);\n    test_from_floating_point::<f32, u8>(0.0, Exact, 0, Equal);\n\n    test_from_floating_point::<f32, u8>(-0.0, Down, 0, Equal);\n    test_from_floating_point::<f32, u8>(-0.0, Floor, 0, Equal);\n    test_from_floating_point::<f32, u8>(-0.0, Up, 0, Equal);\n    test_from_floating_point::<f32, u8>(-0.0, Ceiling, 0, Equal);\n    test_from_floating_point::<f32, u8>(-0.0, Nearest, 0, Equal);\n    test_from_floating_point::<f32, u8>(-0.0, Exact, 0, Equal);\n\n    test_from_floating_point::<f32, u8>(100.0, Down, 100, Equal);\n    test_from_floating_point::<f32, u8>(100.0, Floor, 100, Equal);\n    test_from_floating_point::<f32, u8>(100.0, Up, 100, Equal);\n    test_from_floating_point::<f32, u8>(100.0, Ceiling, 100, Equal);\n    test_from_floating_point::<f32, u8>(100.0, Nearest, 100, Equal);\n    test_from_floating_point::<f32, u8>(100.0, Exact, 100, Equal);\n\n    test_from_floating_point::<f32, u8>(100.1, Down, 100, Less);\n    test_from_floating_point::<f32, u8>(100.1, Floor, 100, Less);\n    test_from_floating_point::<f32, u8>(100.1, Up, 101, Greater);\n    test_from_floating_point::<f32, u8>(100.1, Ceiling, 101, Greater);\n    test_from_floating_point::<f32, u8>(100.1, Nearest, 100, Less);\n\n    test_from_floating_point::<f32, u8>(100.9, Down, 100, Less);\n    test_from_floating_point::<f32, u8>(100.9, Floor, 100, Less);\n    test_from_floating_point::<f32, u8>(100.9, Up, 101, Greater);\n    test_from_floating_point::<f32, u8>(100.9, Ceiling, 101, Greater);\n    test_from_floating_point::<f32, u8>(100.9, Nearest, 101, Greater);\n\n    test_from_floating_point::<f32, u8>(100.5, Down, 100, Less);\n    test_from_floating_point::<f32, u8>(100.5, Floor, 100, Less);\n    test_from_floating_point::<f32, u8>(100.5, Up, 101, Greater);\n    test_from_floating_point::<f32, u8>(100.5, Ceiling, 101, Greater);\n    test_from_floating_point::<f32, u8>(100.5, Nearest, 100, Less);\n\n    test_from_floating_point::<f32, u8>(101.5, Down, 101, Less);\n    test_from_floating_point::<f32, u8>(101.5, Floor, 101, Less);\n    test_from_floating_point::<f32, u8>(101.5, Up, 102, Greater);\n    test_from_floating_point::<f32, u8>(101.5, Ceiling, 102, Greater);\n    test_from_floating_point::<f32, u8>(101.5, Nearest, 102, Greater);\n\n    test_from_floating_point::<f32, u8>(256.0, Down, 255, Less);\n    test_from_floating_point::<f32, u8>(256.0, Floor, 255, Less);\n    test_from_floating_point::<f32, u8>(256.0, Nearest, 255, Less);\n\n    test_from_floating_point::<f32, u8>(-100.0, Down, 0, Greater);\n    test_from_floating_point::<f32, u8>(-100.0, Ceiling, 0, Greater);\n    test_from_floating_point::<f32, u8>(-100.0, Nearest, 0, Greater);\n\n    test_from_floating_point::<f32, i8>(128.0, Down, 127, Less);\n    test_from_floating_point::<f32, i8>(128.0, Floor, 127, Less);\n    test_from_floating_point::<f32, i8>(128.0, Nearest, 127, Less);\n\n    test_from_floating_point::<f32, i8>(-129.0, Down, -128, Greater);\n    test_from_floating_point::<f32, i8>(-129.0, Ceiling, -128, Greater);\n    test_from_floating_point::<f32, i8>(-129.0, Nearest, -128, Greater);\n\n    test_from_floating_point::<f32, u8>(f32::INFINITY, Down, 255, Less);\n    test_from_floating_point::<f32, u8>(f32::INFINITY, Floor, 255, Less);\n    test_from_floating_point::<f32, u8>(f32::INFINITY, Nearest, 255, Less);\n    test_from_floating_point::<f32, u8>(f32::NEGATIVE_INFINITY, Down, 0, Greater);\n    test_from_floating_point::<f32, u8>(f32::NEGATIVE_INFINITY, Ceiling, 0, Greater);\n    test_from_floating_point::<f32, u8>(f32::NEGATIVE_INFINITY, Nearest, 0, Greater);\n\n    test_from_floating_point::<f32, i8>(f32::INFINITY, Down, 127, Less);\n    test_from_floating_point::<f32, i8>(f32::INFINITY, Floor, 127, Less);\n    test_from_floating_point::<f32, i8>(f32::INFINITY, Nearest, 127, Less);\n    test_from_floating_point::<f32, i8>(f32::NEGATIVE_INFINITY, Down, -128, Greater);\n    test_from_floating_point::<f32, i8>(f32::NEGATIVE_INFINITY, Ceiling, -128, Greater);\n    test_from_floating_point::<f32, i8>(f32::NEGATIVE_INFINITY, Nearest, -128, Greater);\n\n    fn test_from_primitive_int<T: PrimitiveInt, U: PrimitiveFloat + RoundingFrom<T>>(\n        n_in: T,\n        rm: RoundingMode,\n        n_out: U,\n        o: Ordering,\n    ) {\n        let (x, actual_o) = U::rounding_from(n_in, rm);\n        assert_eq!((NiceFloat(x), actual_o), (NiceFloat(n_out), o));\n    }\n    test_from_primitive_int::<u8, f32>(0, Down, 0.0, Equal);\n    test_from_primitive_int::<u8, f32>(0, Floor, 0.0, Equal);\n    test_from_primitive_int::<u8, f32>(0, Up, 0.0, Equal);\n    test_from_primitive_int::<u8, f32>(0, Ceiling, 0.0, Equal);\n    test_from_primitive_int::<u8, f32>(0, Nearest, 0.0, Equal);\n    test_from_primitive_int::<u8, f32>(0, Exact, 0.0, Equal);\n\n    test_from_primitive_int::<u8, f32>(100, Down, 100.0, Equal);\n    test_from_primitive_int::<u8, f32>(100, Floor, 100.0, Equal);\n    test_from_primitive_int::<u8, f32>(100, Up, 100.0, Equal);\n    test_from_primitive_int::<u8, f32>(100, Ceiling, 100.0, Equal);\n    test_from_primitive_int::<u8, f32>(100, Nearest, 100.0, Equal);\n    test_from_primitive_int::<u8, f32>(100, Exact, 100.0, Equal);\n\n    test_from_primitive_int::<i8, f32>(-100, Down, -100.0, Equal);\n    test_from_primitive_int::<i8, f32>(-100, Floor, -100.0, Equal);\n    test_from_primitive_int::<i8, f32>(-100, Up, -100.0, Equal);\n    test_from_primitive_int::<i8, f32>(-100, Ceiling, -100.0, Equal);\n    test_from_primitive_int::<i8, f32>(-100, Nearest, -100.0, Equal);\n    test_from_primitive_int::<i8, f32>(-100, Exact, -100.0, Equal);\n\n    test_from_primitive_int::<i32, f32>(i32::MIN, Down, -2147483600.0, Equal);\n    test_from_primitive_int::<i32, f32>(i32::MIN, Floor, -2147483600.0, Equal);\n    test_from_primitive_int::<i32, f32>(i32::MIN, Up, -2147483600.0, Equal);\n    test_from_primitive_int::<i32, f32>(i32::MIN, Ceiling, -2147483600.0, Equal);\n    test_from_primitive_int::<i32, f32>(i32::MIN, Nearest, -2147483600.0, Equal);\n    test_from_primitive_int::<i32, f32>(i32::MIN, Exact, -2147483600.0, Equal);\n\n    test_from_primitive_int::<i32, f32>(i32::MAX, Down, 2147483500.0, Less);\n    test_from_primitive_int::<i32, f32>(i32::MAX, Floor, 2147483500.0, Less);\n    test_from_primitive_int::<i32, f32>(i32::MAX, Up, 2147483600.0, Greater);\n    test_from_primitive_int::<i32, f32>(i32::MAX, Ceiling, 2147483600.0, Greater);\n    test_from_primitive_int::<i32, f32>(i32::MAX, Nearest, 2147483600.0, Greater);\n\n    test_from_primitive_int::<u128, f32>(u128::MAX, Down, 3.4028235e38, Less);\n    test_from_primitive_int::<u128, f32>(u128::MAX, Floor, 3.4028235e38, Less);\n    test_from_primitive_int::<u128, f32>(u128::MAX, Up, f32::INFINITY, Greater);\n    test_from_primitive_int::<u128, f32>(u128::MAX, Ceiling, f32::INFINITY, Greater);\n    test_from_primitive_int::<u128, f32>(u128::MAX, Nearest, 3.4028235e38, Less);\n}\n\n#[test]\nfn exact_from_fail() {\n    assert_panic!(u8::rounding_from(100.1f32, Exact));\n\n    assert_panic!(u8::rounding_from(256.0f32, Exact));\n    assert_panic!(u8::rounding_from(256.0f32, Up));\n    assert_panic!(u8::rounding_from(256.0f32, Ceiling));\n    assert_panic!(u8::rounding_from(-100.0f32, Exact));\n    assert_panic!(u8::rounding_from(-100.0f32, Up));\n    assert_panic!(u8::rounding_from(-100.0f32, Floor));\n\n    assert_panic!(i8::rounding_from(128.0f32, Exact));\n    assert_panic!(i8::rounding_from(128.0f32, Up));\n    assert_panic!(i8::rounding_from(128.0f32, Ceiling));\n    assert_panic!(i8::rounding_from(-129.0f32, Exact));\n    assert_panic!(i8::rounding_from(-129.0f32, Up));\n    assert_panic!(i8::rounding_from(-129.0f32, Floor));\n\n    assert_panic!(u8::rounding_from(f32::NAN, Down));\n    assert_panic!(u8::rounding_from(f32::NAN, Floor));\n    assert_panic!(u8::rounding_from(f32::NAN, Up));\n    assert_panic!(u8::rounding_from(f32::NAN, Ceiling));\n    assert_panic!(u8::rounding_from(f32::NAN, Nearest));\n    assert_panic!(u8::rounding_from(f32::NAN, Exact));\n\n    assert_panic!(u8::rounding_from(f32::INFINITY, Up));\n    assert_panic!(u8::rounding_from(f32::INFINITY, Ceiling));\n    assert_panic!(u8::rounding_from(f32::INFINITY, Exact));\n    assert_panic!(u8::rounding_from(f32::NEGATIVE_INFINITY, Up));\n    assert_panic!(u8::rounding_from(f32::NEGATIVE_INFINITY, Floor));\n    assert_panic!(u8::rounding_from(f32::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(i8::rounding_from(f32::INFINITY, Up));\n    assert_panic!(i8::rounding_from(f32::INFINITY, Ceiling));\n    assert_panic!(i8::rounding_from(f32::INFINITY, Exact));\n    assert_panic!(i8::rounding_from(f32::NEGATIVE_INFINITY, Up));\n    assert_panic!(i8::rounding_from(f32::NEGATIVE_INFINITY, Floor));\n    assert_panic!(i8::rounding_from(f32::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(u8::rounding_from(f32::NAN, Down));\n\n    assert_panic!(f32::rounding_from(u32::MAX, Exact));\n    assert_panic!(f32::rounding_from(u128::MAX, Exact));\n}\n\nfn rounding_from_helper_unsigned_primitive_float<\n    T: ConvertibleFrom<U> + PrimitiveUnsigned + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>()\nwhere\n    NiceFloat<U>: TryFrom<T>,\n{\n    primitive_float_rounding_mode_pair_gen_var_3::<U, T>().test_properties(|(f, rm)| {\n        let (rounded, o) = T::rounding_from(f, rm);\n        match (f >= U::ZERO, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(T::rounding_from(f, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(T::rounding_from(f, Exact));\n        }\n    });\n\n    primitive_float_gen_var_13::<U, T>().test_properties(|f| {\n        let no = T::rounding_from(f, Exact);\n        assert_eq!(no, T::rounding_from(f, Floor));\n        assert_eq!(no, T::rounding_from(f, Ceiling));\n        assert_eq!(no, T::rounding_from(f, Down));\n        assert_eq!(no, T::rounding_from(f, Up));\n        assert_eq!(no, T::rounding_from(f, Nearest));\n    });\n\n    let f_max = U::rounding_from(T::MAX, Down).0;\n    primitive_float_gen_var_15::<U, T>().test_properties(|f| {\n        if f >= U::ZERO && f <= f_max {\n            let n_floor = T::rounding_from(f, Floor);\n            assert_eq!(n_floor.1, Less);\n            if let Some(n_ceiling) = n_floor.0.checked_add(T::ONE) {\n                let n_ceiling = (n_ceiling, Greater);\n                assert_eq!(n_ceiling, T::rounding_from(f, Ceiling));\n                assert_eq!(n_floor, T::rounding_from(f, Down));\n                assert_eq!(n_ceiling, T::rounding_from(f, Up));\n                let n_nearest = T::rounding_from(f, Nearest);\n                assert!(n_nearest == n_floor || n_nearest == n_ceiling);\n            }\n        }\n    });\n\n    primitive_float_gen_var_16::<U, T>().test_properties(|f| {\n        let floor = T::rounding_from(f, Floor);\n        let ceiling = (floor.0 + T::ONE, Greater);\n        let nearest = T::rounding_from(f, Nearest);\n        assert_eq!(nearest, if floor.0.even() { floor } else { ceiling });\n    });\n}\n\nfn rounding_from_helper_signed_primitive_float<\n    T: ConvertibleFrom<U> + PrimitiveSigned + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>()\nwhere\n    NiceFloat<U>: TryFrom<T>,\n{\n    primitive_float_rounding_mode_pair_gen_var_3::<U, T>().test_properties(|(f, rm)| {\n        let (rounded, o) = T::rounding_from(f, rm);\n        match (f >= U::ZERO, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(T::rounding_from(f, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(T::rounding_from(f, Exact));\n        }\n    });\n\n    primitive_float_gen_var_14::<U, T>().test_properties(|f| {\n        let no = T::rounding_from(f, Exact);\n        assert_eq!(no, T::rounding_from(f, Floor));\n        assert_eq!(no, T::rounding_from(f, Ceiling));\n        assert_eq!(no, T::rounding_from(f, Down));\n        assert_eq!(no, T::rounding_from(f, Up));\n        assert_eq!(no, T::rounding_from(f, Nearest));\n    });\n\n    let f_min = U::rounding_from(T::MIN, Down).0;\n    let f_max = U::rounding_from(T::MAX, Down).0;\n    primitive_float_gen_var_15::<U, T>().test_properties(|f| {\n        if f >= f_min && f <= f_max {\n            let n_floor = T::rounding_from(f, Floor);\n            if let Some(n_ceiling) = n_floor.0.checked_add(T::ONE) {\n                let n_ceiling = (n_ceiling, Greater);\n                assert_eq!(n_ceiling, T::rounding_from(f, Ceiling));\n                if f >= U::ZERO {\n                    assert_eq!(n_floor, T::rounding_from(f, Down));\n                    assert_eq!(n_ceiling, T::rounding_from(f, Up));\n                } else {\n                    assert_eq!(n_ceiling, T::rounding_from(f, Down));\n                    assert_eq!(n_floor, T::rounding_from(f, Up));\n                }\n                let n_nearest = T::rounding_from(f, Nearest);\n                assert!(n_nearest == n_floor || n_nearest == n_ceiling);\n            }\n        }\n    });\n\n    primitive_float_gen_var_17::<U, T>().test_properties(|f| {\n        let floor = T::rounding_from(f, Floor);\n        let ceiling = (floor.0 + T::ONE, Greater);\n        let nearest = T::rounding_from(f, Nearest);\n        assert_eq!(nearest, if floor.0.even() { floor } else { ceiling });\n    });\n}\n\nfn rounding_from_helper_primitive_float_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: TryFrom<NiceFloat<T>> + PrimitiveUnsigned + RoundingFrom<T>,\n>() {\n    unsigned_rounding_mode_pair_gen_var_2::<U, T>().test_properties(|(u, rm)| {\n        let (rounded, o) = T::rounding_from(u, rm);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(T::rounding_from(u, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(T::rounding_from(u, Exact));\n        }\n    });\n\n    unsigned_gen_var_18::<U, T>().test_properties(|u| {\n        let (f, o) = T::rounding_from(u, Exact);\n        let (f_alt, o_alt) = T::rounding_from(u, Floor);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(u, Ceiling);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(u, Down);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(u, Up);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(u, Nearest);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        assert_eq!(U::rounding_from(f, Exact), (u, Equal));\n    });\n\n    if U::WIDTH > T::MANTISSA_WIDTH {\n        unsigned_gen_var_19::<U, T>().test_properties(|u| {\n            let (f_below, o) = T::rounding_from(u, Floor);\n            assert_eq!(o, Less);\n            let f_above = f_below.next_higher();\n            let (f_alt, o) = T::rounding_from(u, Ceiling);\n            assert_eq!(NiceFloat(f_alt), NiceFloat(f_above));\n            assert_eq!(o, Greater);\n            let (f_alt, o) = T::rounding_from(u, Down);\n            assert_eq!(NiceFloat(f_alt), NiceFloat(f_below));\n            assert_eq!(o, Less);\n            let (f_alt, o) = T::rounding_from(u, Up);\n            assert_eq!(NiceFloat(f_alt), NiceFloat(f_above));\n            assert_eq!(o, Greater);\n            let (f_nearest, o) = T::rounding_from(u, Nearest);\n            assert!(\n                (NiceFloat(f_nearest), o) == (NiceFloat(f_below), Less)\n                    || (NiceFloat(f_nearest), o) == (NiceFloat(f_above), Greater)\n            );\n        });\n\n        unsigned_gen_var_20::<U, T>().test_properties(|u| {\n            let (floor, o) = T::rounding_from(u, Floor);\n            assert_eq!(o, Less);\n            let ceiling = floor.next_higher();\n            let (nearest, o) = T::rounding_from(u, Nearest);\n            assert_eq!(\n                (NiceFloat(nearest), o),\n                if floor.to_bits().even() {\n                    (NiceFloat(floor), Less)\n                } else {\n                    (NiceFloat(ceiling), Greater)\n                }\n            );\n        });\n    }\n}\n\nfn rounding_from_helper_primitive_float_signed<\n    T: ConvertibleFrom<S> + PrimitiveFloat + RoundingFrom<S>,\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: TryFrom<NiceFloat<T>> + PrimitiveSigned + RoundingFrom<T> + WrappingFrom<U>,\n>() {\n    signed_rounding_mode_pair_gen_var_4::<S, T>().test_properties(|(i, rm)| {\n        let (rounded, o) = T::rounding_from(i, rm);\n        match (i >= S::ZERO, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                assert_eq!(T::rounding_from(i, rm), (rounded, Equal));\n            }\n        } else {\n            assert_panic!(T::rounding_from(i, Exact));\n        }\n    });\n\n    signed_gen_var_7::<S, T>().test_properties(|i| {\n        let (f, o) = T::rounding_from(i, Exact);\n        let (f_alt, o_alt) = T::rounding_from(i, Floor);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(i, Ceiling);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(i, Down);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(i, Up);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        let (f_alt, o_alt) = T::rounding_from(i, Nearest);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n        assert_eq!(S::rounding_from(f, Exact), (i, Equal));\n    });\n\n    if S::WIDTH > T::MANTISSA_WIDTH {\n        signed_gen_var_8::<U, S, T>().test_properties(|i| {\n            let (f_below, o) = T::rounding_from(i, Floor);\n            assert_eq!(o, Less);\n            let f_above = f_below.next_higher();\n            let (f_alt, o_alt) = T::rounding_from(i, Ceiling);\n            assert_eq!(NiceFloat(f_alt), NiceFloat(f_above));\n            assert_eq!(o_alt, Greater);\n            if i >= S::ZERO {\n                let (f_alt, o_alt) = T::rounding_from(i, Down);\n                assert_eq!(NiceFloat(f_below), NiceFloat(f_alt));\n                assert_eq!(o_alt, Less);\n                let (f_alt, o_alt) = T::rounding_from(i, Up);\n                assert_eq!(NiceFloat(f_above), NiceFloat(f_alt));\n                assert_eq!(o_alt, Greater);\n            } else {\n                let (f_alt, o_alt) = T::rounding_from(i, Down);\n                assert_eq!(NiceFloat(f_above), NiceFloat(f_alt));\n                assert_eq!(o_alt, Greater);\n                let (f_alt, o_alt) = T::rounding_from(i, Up);\n                assert_eq!(NiceFloat(f_below), NiceFloat(f_alt));\n                assert_eq!(o_alt, Less);\n            }\n            let (f_nearest, o_alt) = T::rounding_from(i, Nearest);\n            assert!(\n                (NiceFloat(f_nearest), o_alt) == (NiceFloat(f_below), Less)\n                    || (NiceFloat(f_nearest), o_alt) == (NiceFloat(f_above), Greater)\n            );\n        });\n\n        signed_gen_var_9::<U, S, T>().test_properties(|i| {\n            let (floor, o) = T::rounding_from(i, Floor);\n            assert_eq!(o, Less);\n            let ceiling = floor.next_higher();\n            let (nearest, o) = T::rounding_from(i, Nearest);\n            assert_eq!(\n                (NiceFloat(nearest), o),\n                if floor.to_bits().even() {\n                    (NiceFloat(floor), Less)\n                } else {\n                    (NiceFloat(ceiling), Greater)\n                }\n            );\n        });\n    }\n}\n\n#[test]\nfn rounding_from_properties() {\n    apply_fn_to_unsigneds_and_primitive_floats!(rounding_from_helper_unsigned_primitive_float);\n    apply_fn_to_signeds_and_primitive_floats!(rounding_from_helper_signed_primitive_float);\n    apply_fn_to_primitive_floats_and_unsigneds!(rounding_from_helper_primitive_float_unsigned);\n    apply_fn_to_primitive_floats_and_unsigned_signed_pairs!(\n        rounding_from_helper_primitive_float_signed\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/froms/saturating_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, SaturatingFrom};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse std::fmt::Debug;\n\n#[test]\npub fn test_saturating_from() {\n    fn test_single<T: Copy + Debug + Eq + SaturatingFrom<T>>(n: T) {\n        assert_eq!(T::saturating_from(n), n);\n    }\n    test_single(0u8);\n    test_single(5u64);\n    test_single(1000u32);\n    test_single(123u8);\n    test_single(-123i16);\n    test_single(i64::MIN);\n    test_single(usize::MAX);\n\n    fn test_double<T, U: Copy + Debug + Eq + SaturatingFrom<T>>(n_in: T, n_out: U) {\n        assert_eq!(U::saturating_from(n_in), n_out);\n    }\n    test_double(0u8, 0u16);\n    test_double(1000u16, 1000i32);\n    test_double(-5i16, -5i8);\n    test_double(255u8, 255u64);\n\n    test_double(-1i8, 0u32);\n    test_double(u32::MAX, u16::MAX);\n    test_double(i32::MIN, 0u32);\n    test_double(i32::MIN, 0u16);\n    test_double(i32::MIN, i16::MIN);\n    test_double(-5i32, 0u32);\n    test_double(3000000000u32, i32::MAX);\n    test_double(-1000i16, i8::MIN);\n}\n\nfn saturating_from_helper_primitive_int_unsigned<\n    T: TryFrom<U> + ConvertibleFrom<U> + SaturatingFrom<U> + PrimitiveInt,\n    U: TryFrom<T> + PrimitiveUnsigned,\n>() {\n    unsigned_gen::<U>().test_properties(|u| {\n        let result = T::saturating_from(u);\n        if let Ok(u_u) = T::try_from(u) {\n            assert_eq!(result, u_u);\n        }\n        if let Ok(result_t) = U::try_from(result) {\n            assert!(result_t <= u);\n            assert_eq!(result_t == u, T::convertible_from(u));\n        }\n    });\n}\n\nfn saturating_from_helper_primitive_int_signed<\n    T: TryFrom<U> + ConvertibleFrom<U> + SaturatingFrom<U> + PrimitiveInt,\n    U: TryFrom<T> + PrimitiveSigned,\n>() {\n    signed_gen::<U>().test_properties(|i| {\n        let result = T::saturating_from(i);\n        if let Ok(i_u) = T::try_from(i) {\n            assert_eq!(result, i_u);\n        }\n        if let Ok(result_t) = U::try_from(result) {\n            assert!(result_t.le_abs(&i));\n            assert_eq!(result_t == i, T::convertible_from(i));\n        }\n    });\n}\n\n#[test]\nfn saturating_from_properties() {\n    apply_fn_to_primitive_ints_and_unsigneds!(saturating_from_helper_primitive_int_unsigned);\n    apply_fn_to_primitive_ints_and_signeds!(saturating_from_helper_primitive_int_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/froms/try_from_and_exact_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::from::{\n    PrimitiveFloatFromSignedError, PrimitiveFloatFromUnsignedError, SignedFromFloatError,\n    UnsignedFromFloatError,\n};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_gen_var_13, primitive_float_gen_var_14, signed_gen,\n    signed_gen_var_7, unsigned_gen, unsigned_gen_var_18,\n};\nuse std::fmt::Debug;\nuse std::panic::catch_unwind;\n\n#[allow(clippy::needless_pass_by_value)]\n#[test]\npub fn test_try_from() {\n    fn test_double_primitive_int<\n        T: PrimitiveFloat,\n        U: TryFrom<NiceFloat<T>, Error = E> + Copy + Debug + Eq,\n        E: Debug + Eq,\n    >(\n        n_in: T,\n        n_out: Result<U, E>,\n    ) {\n        assert_eq!(U::try_from(NiceFloat(n_in)), n_out);\n    }\n    test_double_primitive_int::<_, u8, _>(0.0f32, Ok(0));\n    test_double_primitive_int::<_, u8, _>(-0.0f32, Ok(0));\n    test_double_primitive_int::<_, u8, _>(123.0f32, Ok(123));\n    test_double_primitive_int::<_, i8, _>(-123.0f32, Ok(-123));\n    test_double_primitive_int::<_, u8, _>(-123.0f32, Err(UnsignedFromFloatError::FloatNegative));\n    test_double_primitive_int::<_, u8, _>(\n        500.0f32,\n        Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange),\n    );\n    test_double_primitive_int::<_, u8, _>(\n        123.1f32,\n        Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange),\n    );\n    test_double_primitive_int::<_, u8, _>(\n        f32::NAN,\n        Err(UnsignedFromFloatError::FloatInfiniteOrNan),\n    );\n    test_double_primitive_int::<_, u8, _>(\n        f32::INFINITY,\n        Err(UnsignedFromFloatError::FloatInfiniteOrNan),\n    );\n    test_double_primitive_int::<_, u8, _>(\n        f32::NEGATIVE_INFINITY,\n        Err(UnsignedFromFloatError::FloatInfiniteOrNan),\n    );\n    test_double_primitive_int::<_, u8, _>(255.0f32, Ok(255));\n    test_double_primitive_int::<_, u8, _>(\n        256.0f32,\n        Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange),\n    );\n    test_double_primitive_int::<_, i8, _>(127.0f32, Ok(127));\n    test_double_primitive_int::<_, i8, _>(\n        128.0f32,\n        Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange),\n    );\n    test_double_primitive_int::<_, i8, _>(-128.0f32, Ok(-128));\n    test_double_primitive_int::<_, i8, _>(\n        -129.0f32,\n        Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange),\n    );\n\n    fn test_double_primitive_float<T, U: PrimitiveFloat, E: Debug + Eq>(\n        n_in: T,\n        n_out: Result<U, E>,\n    ) where\n        NiceFloat<U>: TryFrom<T, Error = E>,\n    {\n        assert_eq!(NiceFloat::<U>::try_from(n_in), n_out.map(NiceFloat));\n    }\n    test_double_primitive_float::<_, f32, _>(0u8, Ok(0.0));\n    test_double_primitive_float::<_, f32, _>(123u8, Ok(123.0));\n    test_double_primitive_float::<_, f32, _>(-123i8, Ok(-123.0));\n    test_double_primitive_float::<_, f32, _>(u128::MAX, Err(PrimitiveFloatFromUnsignedError));\n    test_double_primitive_float::<_, f32, _>(i128::MIN, Ok(-1.7014118e38));\n    test_double_primitive_float::<_, f32, _>(i128::MIN + 1, Err(PrimitiveFloatFromSignedError));\n    test_double_primitive_float::<_, f32, _>(u32::MAX, Err(PrimitiveFloatFromUnsignedError));\n    test_double_primitive_float::<_, f32, _>(i32::MIN, Ok(-2147483600.0));\n    test_double_primitive_float::<_, f32, _>(i32::MIN + 1, Err(PrimitiveFloatFromSignedError));\n}\n\n#[test]\npub fn test_exact_from() {\n    fn test_single<T: Copy + Debug + Eq + ExactFrom<T>>(n: T) {\n        assert_eq!(T::exact_from(n), n);\n    }\n    test_single(0u8);\n    test_single(5u64);\n    test_single(1000u32);\n    test_single(123u8);\n    test_single(-123i16);\n    test_single(i64::MIN);\n    test_single(usize::MAX);\n\n    fn test_double_primitive_int<\n        T: PrimitiveFloat,\n        U: Copy + Debug + Eq + TryFrom<NiceFloat<T>>,\n    >(\n        n_in: T,\n        n_out: U,\n    ) {\n        assert_eq!(U::exact_from(NiceFloat(n_in)), n_out);\n    }\n    test_double_primitive_int(0.0f32, 0u8);\n    test_double_primitive_int(-0.0f32, 0u8);\n    test_double_primitive_int(123.0f32, 123u8);\n    test_double_primitive_int(-123.0f32, -123i8);\n    test_double_primitive_int(255.0f32, 255u8);\n    test_double_primitive_int(127.0f32, 127i8);\n    test_double_primitive_int(-128.0f32, -128i8);\n\n    fn test_double_primitive_float<T, U: PrimitiveFloat>(n_in: T, n_out: U)\n    where\n        NiceFloat<U>: TryFrom<T>,\n    {\n        assert_eq!(NiceFloat::<U>::exact_from(n_in), NiceFloat(n_out));\n    }\n    test_double_primitive_float(0u8, 0.0f32);\n    test_double_primitive_float(123u8, 123.0f32);\n    test_double_primitive_float(-123i8, -123.0f32);\n    test_double_primitive_float(i128::MIN, -1.7014118e38f32);\n    test_double_primitive_float(i32::MIN, -2147483600.0f32);\n}\n\n#[test]\nfn exact_from_fail() {\n    assert_panic!(u32::exact_from(-1i8));\n    assert_panic!(u16::exact_from(u32::MAX));\n    assert_panic!(u32::exact_from(i32::MIN));\n    assert_panic!(u16::exact_from(i32::MIN));\n    assert_panic!(i16::exact_from(i32::MIN));\n    assert_panic!(u32::exact_from(-5i32));\n    assert_panic!(i32::exact_from(3000000000u32));\n    assert_panic!(i8::exact_from(-1000i16));\n    assert_panic!(u8::exact_from(NiceFloat(-123.0f32)));\n    assert_panic!(u8::exact_from(NiceFloat(500.0f32)));\n    assert_panic!(u8::exact_from(NiceFloat(123.1f32)));\n    assert_panic!(u8::exact_from(NiceFloat(f32::NAN)));\n    assert_panic!(u8::exact_from(NiceFloat(f32::INFINITY)));\n    assert_panic!(u8::exact_from(NiceFloat(f32::NEGATIVE_INFINITY)));\n    assert_panic!(u8::exact_from(NiceFloat(256.0f32)));\n    assert_panic!(i8::exact_from(NiceFloat(128.0f32)));\n    assert_panic!(i8::exact_from(NiceFloat(-129.0f32)));\n    assert_panic!(NiceFloat::<f32>::exact_from(u128::MAX));\n    assert_panic!(NiceFloat::<f32>::exact_from(i128::MIN + 1));\n    assert_panic!(NiceFloat::<f32>::exact_from(u32::MAX));\n    assert_panic!(NiceFloat::<f32>::exact_from(i32::MIN + 1));\n}\n\nfn try_from_and_exact_from_helper_unsigned_primitive_float<\n    T: TryFrom<NiceFloat<U>, Error = UnsignedFromFloatError> + PrimitiveUnsigned + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>()\nwhere\n    NiceFloat<U>: TryFrom<T>,\n{\n    primitive_float_gen::<U>().test_properties(|f| {\n        let f = NiceFloat(f);\n        let result = T::try_from(f);\n        if let Ok(u) = result {\n            assert_eq!(u, T::exact_from(f));\n            assert_eq!(\n                NiceFloat(f.0.abs_negative_zero()),\n                NiceFloat::<U>::exact_from(u)\n            );\n        }\n    });\n\n    primitive_float_gen_var_13::<U, T>().test_properties(|f| {\n        let f = NiceFloat(f);\n        let u = T::exact_from(f);\n        assert_eq!(NiceFloat::<U>::exact_from(u), f);\n        assert_eq!(T::try_from(f).unwrap(), u);\n        assert_eq!(T::rounding_from(f.0, Exact).0, u);\n    });\n}\n\nfn try_from_and_exact_from_helper_signed_primitive_float<\n    T: TryFrom<NiceFloat<U>, Error = SignedFromFloatError> + PrimitiveSigned + RoundingFrom<U>,\n    U: PrimitiveFloat + RoundingFrom<T>,\n>()\nwhere\n    NiceFloat<U>: TryFrom<T>,\n{\n    primitive_float_gen::<U>().test_properties(|f| {\n        let f = NiceFloat(f);\n        let result = T::try_from(f);\n        if let Ok(i) = result {\n            assert_eq!(i, T::exact_from(f));\n            assert_eq!(\n                NiceFloat(f.0.abs_negative_zero()),\n                NiceFloat::<U>::exact_from(i)\n            );\n        }\n    });\n\n    primitive_float_gen_var_14::<U, T>().test_properties(|f| {\n        let f = NiceFloat(f);\n        let i = T::exact_from(f);\n        assert_eq!(NiceFloat::<U>::exact_from(i), f);\n        assert_eq!(T::try_from(f).unwrap(), i);\n        assert_eq!(T::rounding_from(f.0, Exact).0, i);\n    });\n}\n\nfn try_from_and_exact_from_helper_primitive_float_unsigned<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveUnsigned + RoundingFrom<T> + TryFrom<NiceFloat<T>>,\n>()\nwhere\n    NiceFloat<T>: TryFrom<U, Error = PrimitiveFloatFromUnsignedError>,\n{\n    unsigned_gen::<U>().test_properties(|u| {\n        let result = NiceFloat::<T>::try_from(u);\n        if let Ok(f) = result {\n            assert_eq!(f, NiceFloat::<T>::exact_from(u));\n            assert_eq!(u, U::exact_from(f));\n        }\n    });\n\n    unsigned_gen_var_18::<U, T>().test_properties(|u| {\n        let f = NiceFloat::<T>::exact_from(u);\n        assert_eq!(U::exact_from(f), u);\n        assert_eq!(NiceFloat::<T>::try_from(u).unwrap(), f);\n        assert_eq!(NiceFloat(T::rounding_from(u, Exact).0), f);\n    });\n}\n\nfn try_from_and_exact_from_helper_primitive_float_signed<\n    T: ConvertibleFrom<U> + PrimitiveFloat + RoundingFrom<U>,\n    U: PrimitiveSigned + RoundingFrom<T> + TryFrom<NiceFloat<T>>,\n>()\nwhere\n    NiceFloat<T>: TryFrom<U, Error = PrimitiveFloatFromSignedError>,\n{\n    signed_gen::<U>().test_properties(|i| {\n        let result = NiceFloat::<T>::try_from(i);\n        if let Ok(f) = result {\n            assert_eq!(f, NiceFloat::<T>::exact_from(i));\n            assert_eq!(i, U::exact_from(f));\n        }\n    });\n\n    signed_gen_var_7::<U, T>().test_properties(|i| {\n        let f = NiceFloat::<T>::exact_from(i);\n        assert_eq!(U::exact_from(f), i);\n        assert_eq!(NiceFloat::<T>::try_from(i).unwrap(), f);\n        assert_eq!(NiceFloat(T::rounding_from(i, Exact).0), f);\n    });\n}\n\n#[test]\nfn try_from_and_exact_from_properties() {\n    apply_fn_to_unsigneds_and_primitive_floats!(\n        try_from_and_exact_from_helper_unsigned_primitive_float\n    );\n    apply_fn_to_signeds_and_primitive_floats!(\n        try_from_and_exact_from_helper_signed_primitive_float\n    );\n    apply_fn_to_primitive_floats_and_unsigneds!(\n        try_from_and_exact_from_helper_primitive_float_unsigned\n    );\n    apply_fn_to_primitive_floats_and_signeds!(\n        try_from_and_exact_from_helper_primitive_float_signed\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/froms/wrapping_from.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{OverflowingFrom, WrappingFrom};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse std::fmt::Debug;\n\n#[test]\npub fn test_wrapping_from() {\n    fn test_single<T: Copy + Debug + Eq + WrappingFrom<T>>(n: T) {\n        assert_eq!(T::wrapping_from(n), n);\n    }\n    test_single(0u8);\n    test_single(5u64);\n    test_single(1000u32);\n    test_single(123u8);\n    test_single(-123i16);\n    test_single(i64::MIN);\n    test_single(usize::MAX);\n\n    fn test_double<T, U: Copy + Debug + Eq + WrappingFrom<T>>(n_in: T, n_out: U) {\n        assert_eq!(U::wrapping_from(n_in), n_out);\n    }\n    test_double(0u8, 0u16);\n    test_double(1000u16, 1000i32);\n    test_double(-5i16, -5i8);\n    test_double(255u8, 255u64);\n\n    test_double(-1i8, u32::MAX);\n    test_double(u32::MAX, u16::MAX);\n    test_double(i32::MIN, 0x80000000u32);\n    test_double(i32::MIN, 0u16);\n    test_double(i32::MIN, 0i16);\n    test_double(-5i32, 0xfffffffbu32);\n    test_double(3000000000u32, -1294967296i32);\n    test_double(-1000i16, 24i8);\n}\n\nfn wrapping_from_helper_primitive_int_unsigned<\n    T: OverflowingFrom<U> + WrappingFrom<U> + PrimitiveInt,\n    U: PrimitiveUnsigned,\n>() {\n    unsigned_gen::<U>().test_properties(|u| {\n        let result = T::wrapping_from(u);\n        assert_eq!(result, T::overflowing_from(u).0);\n    });\n}\n\nfn wrapping_from_helper_primitive_int_signed<\n    T: OverflowingFrom<U> + WrappingFrom<U> + PrimitiveInt,\n    U: PrimitiveSigned,\n>() {\n    signed_gen::<U>().test_properties(|i| {\n        let result = T::wrapping_from(i);\n        assert_eq!(result, T::overflowing_from(i).0);\n    });\n}\n\n#[test]\nfn wrapping_from_properties() {\n    apply_fn_to_primitive_ints_and_unsigneds!(wrapping_from_helper_primitive_int_unsigned);\n    apply_fn_to_primitive_ints_and_signeds!(wrapping_from_helper_primitive_int_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/half/join_halves.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf};\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_pair_gen_var_27};\n\nfn join_halves_helper<T: JoinHalves + PrimitiveUnsigned>(upper: T::Half, lower: T::Half, out: T) {\n    assert_eq!(T::join_halves(upper, lower), out);\n}\n\n#[test]\npub fn test_join_halves() {\n    join_halves_helper(0u32, 0u32, 0u64);\n    join_halves_helper(0u32, 1u32, 1u64);\n    join_halves_helper(0, u8::MAX, u16::from(u8::MAX));\n    join_halves_helper(1, 0, u16::from(u8::MAX) + 1);\n    join_halves_helper(u8::MAX, u8::MAX, u16::MAX);\n    join_halves_helper(1, 2, 258u16);\n    join_halves_helper(0xabcd, 0x1234, 0xabcd1234u32);\n}\n\nfn join_halves_properties_helper<\n    T: From<HT> + HasHalf<Half = HT> + JoinHalves + PrimitiveUnsigned + SplitInHalf,\n    HT: PrimitiveUnsigned,\n>() {\n    unsigned_pair_gen_var_27::<HT>().test_properties(|(x, y)| {\n        let joined = T::join_halves(x, y);\n        assert_eq!((T::from(x) << (T::WIDTH >> 1)) + T::from(y), joined);\n        assert_eq!(joined.upper_half(), x);\n        assert_eq!(joined.lower_half(), y);\n    });\n\n    unsigned_gen::<HT>().test_properties(|x| {\n        assert_eq!(T::join_halves(HT::ZERO, x), T::from(x));\n    });\n}\n\n#[test]\nfn join_halves_properties() {\n    join_halves_properties_helper::<u16, u8>();\n    join_halves_properties_helper::<u32, u16>();\n    join_halves_properties_helper::<u64, u32>();\n    join_halves_properties_helper::<u128, u64>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/half/lower_half.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf};\nuse malachite_base::test_util::generators::unsigned_gen;\n\nfn lower_half_test_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: T::Half)\nwhere\n    T::Half: PrimitiveUnsigned,\n{\n    assert_eq!(n.lower_half(), out);\n}\n\n#[test]\npub fn test_lower_half() {\n    lower_half_test_helper(0u64, 0u32);\n    lower_half_test_helper(1u64, 1u32);\n    lower_half_test_helper(u16::from(u8::MAX), u8::MAX);\n    lower_half_test_helper(u16::from(u8::MAX) + 1, 0);\n    lower_half_test_helper(u16::MAX, u8::MAX);\n    lower_half_test_helper(258u16, 2u8);\n    lower_half_test_helper(0xabcd1234u32, 0x1234);\n}\n\nfn lower_half_properties_helper<T: JoinHalves + PrimitiveUnsigned + SplitInHalf>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let lower = n.lower_half();\n        assert_eq!(T::join_halves(n.upper_half(), lower), n);\n    });\n}\n\n#[test]\nfn lower_half_properties() {\n    lower_half_properties_helper::<u16>();\n    lower_half_properties_helper::<u32>();\n    lower_half_properties_helper::<u64>();\n    lower_half_properties_helper::<u128>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/half/split_in_half.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf};\nuse malachite_base::test_util::generators::unsigned_gen;\n\nfn split_in_half_test_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: (T::Half, T::Half))\nwhere\n    T::Half: PrimitiveUnsigned,\n{\n    assert_eq!(n.split_in_half(), out);\n}\n\n#[test]\npub fn test_split_in_half() {\n    split_in_half_test_helper(0u64, (0u32, 0u32));\n    split_in_half_test_helper(1u64, (0u32, 1u32));\n    split_in_half_test_helper(u16::from(u8::MAX), (0, u8::MAX));\n    split_in_half_test_helper(u16::from(u8::MAX) + 1, (1, 0));\n    split_in_half_test_helper(u16::MAX, (u8::MAX, u8::MAX));\n    split_in_half_test_helper(258u16, (1u8, 2u8));\n    split_in_half_test_helper(0xabcd1234u32, (0xabcd, 0x1234));\n}\n\nfn split_in_half_properties_helper<T: JoinHalves + PrimitiveUnsigned + SplitInHalf>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let (upper, lower) = n.split_in_half();\n        assert_eq!(T::join_halves(upper, lower), n);\n    });\n}\n\n#[test]\nfn split_in_half_properties() {\n    split_in_half_properties_helper::<u16>();\n    split_in_half_properties_helper::<u32>();\n    split_in_half_properties_helper::<u64>();\n    split_in_half_properties_helper::<u128>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/half/upper_half.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf};\nuse malachite_base::test_util::generators::unsigned_gen;\n\nfn upper_half_test_helper<T: PrimitiveUnsigned + SplitInHalf>(n: T, out: T::Half)\nwhere\n    T::Half: PrimitiveUnsigned,\n{\n    assert_eq!(n.upper_half(), out);\n}\n\n#[test]\npub fn test_upper_half() {\n    upper_half_test_helper(0u64, 0u32);\n    upper_half_test_helper(1u64, 0u32);\n    upper_half_test_helper(u16::from(u8::MAX), 0);\n    upper_half_test_helper(u16::from(u8::MAX) + 1, 1);\n    upper_half_test_helper(u16::MAX, u8::MAX);\n    upper_half_test_helper(258u16, 1u8);\n    upper_half_test_helper(0xabcd1234u32, 0xabcd);\n}\n\nfn upper_half_properties_helper<T: JoinHalves + PrimitiveUnsigned + SplitInHalf>() {\n    unsigned_gen::<T>().test_properties(|n| {\n        let upper = n.upper_half();\n        assert_eq!(T::join_halves(upper, n.lower_half()), n);\n    });\n}\n\n#[test]\nfn upper_half_properties() {\n    upper_half_properties_helper::<u16>();\n    upper_half_properties_helper::<u32>();\n    upper_half_properties_helper::<u64>();\n    upper_half_properties_helper::<u128>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{primitive_float_gen, signed_gen, unsigned_gen};\n\n#[test]\npub fn test_is_integer() {\n    fn test_u<T: PrimitiveUnsigned>(u: T, is_integer: bool) {\n        assert_eq!(u.is_integer(), is_integer);\n    }\n    test_u::<u8>(0, true);\n    test_u::<u8>(1, true);\n    test_u::<u8>(100, true);\n\n    fn test_i<T: PrimitiveSigned>(i: T, is_integer: bool) {\n        assert_eq!(i.is_integer(), is_integer);\n    }\n    test_i::<i8>(0, true);\n    test_i::<i8>(1, true);\n    test_i::<i8>(100, true);\n    test_i::<i8>(-1, true);\n    test_i::<i8>(-100, true);\n\n    fn test_f<T: PrimitiveFloat>(f: T, is_integer: bool) {\n        assert_eq!(f.is_integer(), is_integer);\n    }\n    test_f::<f32>(0.0, true);\n    test_f::<f32>(1.0, true);\n    test_f::<f32>(100.0, true);\n    test_f::<f32>(-1.0, true);\n    test_f::<f32>(-100.0, true);\n\n    test_f::<f32>(0.1, false);\n    test_f::<f32>(100.1, false);\n    test_f::<f32>(-0.1, false);\n    test_f::<f32>(-100.1, false);\n    test_f::<f32>(f32::NAN, false);\n    test_f::<f32>(f32::INFINITY, false);\n    test_f::<f32>(f32::NEGATIVE_INFINITY, false);\n}\n\nfn is_integer_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|u| {\n        assert!(u.is_integer());\n    });\n}\n\nfn is_integer_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|i| {\n        assert!(i.is_integer());\n    });\n}\n\nfn is_integer_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|f| {\n        assert_eq!(\n            f.is_integer(),\n            f.is_finite() && (f == T::ZERO || f.integer_exponent() >= 0)\n        );\n    });\n}\n\n#[test]\nfn is_integer_properties() {\n    apply_fn_to_unsigneds!(is_integer_unsigned);\n    apply_fn_to_signeds!(is_integer_signed);\n    apply_fn_to_primitive_floats!(is_integer_primitive_float);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/mantissa_and_exponent/integer_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_12, unsigned_gen_var_1, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_30, unsigned_signed_pair_gen_var_1, unsigned_signed_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_integer_mantissa_and_exponent() {\n    fn test_unsigned<T: PrimitiveUnsigned>(x: T, mantissa: T, exponent: u64) {\n        assert_eq!(x.integer_mantissa(), mantissa);\n        assert_eq!(x.integer_exponent(), exponent);\n        assert_eq!(x.integer_mantissa_and_exponent(), (mantissa, exponent));\n    }\n    test_unsigned::<u8>(1, 1, 0);\n    test_unsigned::<u8>(2, 1, 1);\n    test_unsigned::<u8>(3, 3, 0);\n    test_unsigned::<u8>(100, 25, 2);\n    test_unsigned::<u32>(65536, 1, 16);\n\n    fn test_primitive_float<T: PrimitiveFloat>(x: T, mantissa: u64, exponent: i64) {\n        assert_eq!(x.integer_mantissa(), mantissa);\n        assert_eq!(x.integer_exponent(), exponent);\n        assert_eq!(x.integer_mantissa_and_exponent(), (mantissa, exponent));\n    }\n    test_primitive_float::<f32>(1.0, 1, 0);\n    test_primitive_float::<f32>(core::f32::consts::PI, 13176795, -22);\n    test_primitive_float::<f32>(0.1, 13421773, -27);\n    test_primitive_float::<f32>(10.0, 5, 1);\n    test_primitive_float::<f32>(f32::MIN_POSITIVE_SUBNORMAL, 1, -149);\n    test_primitive_float::<f32>(f32::MAX_SUBNORMAL, 0x7fffff, -149);\n    test_primitive_float::<f32>(f32::MIN_POSITIVE_NORMAL, 1, -126);\n    test_primitive_float::<f32>(f32::MAX_FINITE, 0xffffff, 104);\n\n    test_primitive_float::<f64>(1.0, 1, 0);\n    test_primitive_float::<f64>(core::f64::consts::PI, 884279719003555, -48);\n    test_primitive_float::<f64>(0.1, 3602879701896397, -55);\n    test_primitive_float::<f64>(10.0, 5, 1);\n    test_primitive_float::<f64>(f64::MIN_POSITIVE_SUBNORMAL, 1, -1074);\n    test_primitive_float::<f64>(f64::MAX_SUBNORMAL, 0xfffffffffffff, -1074);\n    test_primitive_float::<f64>(f64::MIN_POSITIVE_NORMAL, 1, -1022);\n    test_primitive_float::<f64>(f64::MAX_FINITE, 0x1fffffffffffff, 971);\n}\n\nfn integer_mantissa_and_exponent_unsigned_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.integer_mantissa_and_exponent());\n}\n\nfn integer_mantissa_and_exponent_primitive_float_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::NAN.integer_mantissa_and_exponent());\n    assert_panic!(T::INFINITY.integer_mantissa_and_exponent());\n    assert_panic!(T::NEGATIVE_INFINITY.integer_mantissa_and_exponent());\n    assert_panic!(T::ZERO.integer_mantissa_and_exponent());\n    assert_panic!(T::NEGATIVE_ZERO.integer_mantissa_and_exponent());\n}\n\n#[test]\npub fn integer_mantissa_and_exponent_fail() {\n    apply_fn_to_unsigneds!(integer_mantissa_and_exponent_unsigned_fail_helper);\n    apply_fn_to_primitive_floats!(integer_mantissa_and_exponent_primitive_float_fail_helper);\n}\n\n#[test]\npub fn test_from_integer_mantissa_and_exponent() {\n    fn test_unsigned<T: PrimitiveUnsigned>(mantissa: T, exponent: u64, x: Option<T>) {\n        assert_eq!(T::from_integer_mantissa_and_exponent(mantissa, exponent), x);\n    }\n    test_unsigned::<u8>(0, 0, Some(0));\n    test_unsigned::<u8>(1, 0, Some(1));\n    test_unsigned::<u8>(1, 1, Some(2));\n    test_unsigned::<u8>(3, 0, Some(3));\n    test_unsigned::<u8>(25, 2, Some(100));\n    test_unsigned::<u32>(1, 16, Some(65536));\n    test_unsigned::<u32>(1, 100, None);\n\n    fn test_primitive_float<T: PrimitiveFloat>(mantissa: u64, exponent: i64, x: Option<T>) {\n        assert_eq!(\n            T::from_integer_mantissa_and_exponent(mantissa, exponent).map(NiceFloat),\n            x.map(NiceFloat)\n        );\n    }\n    test_primitive_float::<f32>(0, 5, Some(0.0));\n    test_primitive_float::<f32>(1, 0, Some(1.0));\n    test_primitive_float::<f32>(4, -2, Some(1.0));\n    test_primitive_float::<f32>(13176795, -22, Some(core::f32::consts::PI));\n    test_primitive_float::<f32>(13421773, -27, Some(0.1));\n    test_primitive_float::<f32>(5, 1, Some(10.0));\n    test_primitive_float::<f32>(1, -149, Some(f32::MIN_POSITIVE_SUBNORMAL));\n    test_primitive_float::<f32>(4, -151, Some(f32::MIN_POSITIVE_SUBNORMAL));\n    test_primitive_float::<f32>(0x7fffff, -149, Some(f32::MAX_SUBNORMAL));\n    test_primitive_float::<f32>(1, -126, Some(f32::MIN_POSITIVE_NORMAL));\n    test_primitive_float::<f32>(0xffffff, 104, Some(f32::MAX_FINITE));\n    test_primitive_float::<f32>(1, 127, Some(1.7014118e38));\n    test_primitive_float::<f32>(5, 10000, None);\n    test_primitive_float::<f32>(5, -10000, None);\n    test_primitive_float::<f32>(u64::MAX, -32, None); // precision too high\n    test_primitive_float::<f32>(3, -150, None); // precision too high\n    test_primitive_float::<f32>(1, 128, None); // precision too high\n\n    test_primitive_float::<f64>(0, 5, Some(0.0));\n    test_primitive_float::<f64>(1, 0, Some(1.0));\n    test_primitive_float::<f64>(4, -2, Some(1.0));\n    test_primitive_float::<f64>(884279719003555, -48, Some(core::f64::consts::PI));\n    test_primitive_float::<f64>(3602879701896397, -55, Some(0.1));\n    test_primitive_float::<f64>(5, 1, Some(10.0));\n    test_primitive_float::<f64>(1, -1074, Some(f64::MIN_POSITIVE_SUBNORMAL));\n    test_primitive_float::<f64>(4, -1076, Some(f64::MIN_POSITIVE_SUBNORMAL));\n    test_primitive_float::<f64>(0xfffffffffffff, -1074, Some(f64::MAX_SUBNORMAL));\n    test_primitive_float::<f64>(1, -1022, Some(f64::MIN_POSITIVE_NORMAL));\n    test_primitive_float::<f64>(0x1fffffffffffff, 971, Some(f64::MAX_FINITE));\n    test_primitive_float::<f64>(1, 1023, Some(8.98846567431158e307));\n    test_primitive_float::<f64>(5, 10000, None);\n    test_primitive_float::<f64>(5, -10000, None);\n    test_primitive_float::<f64>(u64::MAX, -64, None); // precision too high\n    test_primitive_float::<f64>(3, -1075, None); // precision too high\n    test_primitive_float::<f64>(1, 1024, None); // precision too high\n}\n\nfn integer_mantissa_and_exponent_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_1::<T>().test_properties(|x| {\n        let (mantissa, exponent) = x.integer_mantissa_and_exponent();\n        assert_eq!(x.integer_mantissa(), mantissa);\n        assert_eq!(x.integer_exponent(), exponent);\n        assert_eq!(\n            T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap(),\n            x\n        );\n\n        assert!(exponent < T::WIDTH);\n        assert!(mantissa.odd());\n    });\n}\n\nfn integer_mantissa_and_exponent_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen_var_12::<T>().test_properties(|x| {\n        let (mantissa, exponent) = x.integer_mantissa_and_exponent();\n        assert_eq!(x.integer_mantissa(), mantissa);\n        assert_eq!(x.integer_exponent(), exponent);\n        assert_eq!(\n            NiceFloat(T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap()),\n            NiceFloat(x.abs())\n        );\n\n        assert!(exponent >= T::MIN_EXPONENT);\n        assert!(exponent <= T::MAX_EXPONENT);\n        assert!(mantissa.significant_bits() <= T::MANTISSA_WIDTH + 1);\n        assert!(mantissa.odd());\n    });\n}\n\n#[test]\nfn integer_mantissa_and_exponent_properties() {\n    apply_fn_to_unsigneds!(integer_mantissa_and_exponent_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(integer_mantissa_and_exponent_properties_helper_primitive_float);\n}\n\nfn from_integer_mantissa_and_exponent_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(mantissa, exponent)| {\n        T::from_integer_mantissa_and_exponent(mantissa, exponent);\n    });\n\n    unsigned_pair_gen_var_30::<T>().test_properties(|(mantissa, exponent)| {\n        let f = T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap();\n        if mantissa.odd() {\n            assert_eq!(f.integer_mantissa_and_exponent(), (mantissa, exponent));\n        }\n    });\n}\n\nfn from_integer_mantissa_and_exponent_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    unsigned_signed_pair_gen_var_1().test_properties(|(mantissa, exponent)| {\n        T::from_integer_mantissa_and_exponent(mantissa, exponent);\n    });\n\n    unsigned_signed_pair_gen_var_2::<T>().test_properties(|(mantissa, exponent)| {\n        let f = T::from_integer_mantissa_and_exponent(mantissa, exponent).unwrap();\n        assert!(!f.is_nan());\n        assert_eq!(f.sign(), Greater);\n        if !f.is_nan() && mantissa.odd() {\n            assert_eq!(f.integer_mantissa_and_exponent(), (mantissa, exponent));\n        }\n    });\n}\n\n#[test]\nfn from_integer_mantissa_and_exponent_properties() {\n    apply_fn_to_unsigneds!(from_integer_mantissa_and_exponent_properties_helper_unsigned);\n    apply_fn_to_primitive_floats!(\n        from_integer_mantissa_and_exponent_properties_helper_primitive_float\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/mantissa_and_exponent/raw_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::generators::{primitive_float_gen, unsigned_pair_gen_var_26};\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_raw_mantissa_and_exponent() {\n    fn test<T: PrimitiveFloat>(x: T, mantissa: u64, exponent: u64) {\n        assert_eq!(x.raw_mantissa(), mantissa);\n        assert_eq!(x.raw_exponent(), exponent);\n        assert_eq!(x.raw_mantissa_and_exponent(), (mantissa, exponent));\n    }\n    test::<f32>(0.0, 0, 0);\n    test::<f32>(-0.0, 0, 0);\n    test::<f32>(f32::NAN, 0x400000, 255);\n    test::<f32>(f32::INFINITY, 0, 255);\n    test::<f32>(f32::NEGATIVE_INFINITY, 0, 255);\n    test::<f32>(1.0, 0, 127);\n    test::<f32>(core::f32::consts::PI, 4788187, 128);\n    test::<f32>(0.1, 5033165, 123);\n    test::<f32>(10.0, 2097152, 130);\n    test::<f32>(f32::MIN_POSITIVE_SUBNORMAL, 1, 0);\n    test::<f32>(f32::MAX_SUBNORMAL, 0x7fffff, 0);\n    test::<f32>(f32::MIN_POSITIVE_NORMAL, 0, 1);\n    test::<f32>(f32::MAX_FINITE, 0x7fffff, 254);\n\n    test::<f64>(0.0, 0, 0);\n    test::<f64>(-0.0, 0, 0);\n    test::<f64>(f64::NAN, 0x8000000000000, 2047);\n    test::<f64>(f64::INFINITY, 0, 2047);\n    test::<f64>(f64::NEGATIVE_INFINITY, 0, 2047);\n    test::<f64>(1.0, 0, 1023);\n    test::<f64>(core::f64::consts::PI, 2570638124657944, 1024);\n    test::<f64>(0.1, 2702159776422298, 1019);\n    test::<f64>(10.0, 1125899906842624, 1026);\n    test::<f64>(f64::MIN_POSITIVE_SUBNORMAL, 1, 0);\n    test::<f64>(f64::MAX_SUBNORMAL, 0xfffffffffffff, 0);\n    test::<f64>(f64::MIN_POSITIVE_NORMAL, 0, 1);\n    test::<f64>(f64::MAX_FINITE, 0xfffffffffffff, 2046);\n}\n\n#[test]\npub fn test_raw_exponent() {\n    fn test<T: PrimitiveFloat>(x: T, exponent: u64) {\n        assert_eq!(x.raw_exponent(), exponent);\n    }\n\n    test::<f32>(0.0, 0);\n    test::<f32>(-0.0, 0);\n    test::<f32>(f32::NAN, 255);\n    test::<f32>(f32::INFINITY, 255);\n    test::<f32>(f32::NEGATIVE_INFINITY, 255);\n    test::<f32>(1.0, 127);\n    test::<f32>(core::f32::consts::PI, 128);\n    test::<f32>(0.1, 123);\n    test::<f32>(10.0, 130);\n    test::<f32>(f32::MIN_POSITIVE_SUBNORMAL, 0);\n    test::<f32>(f32::MAX_SUBNORMAL, 0);\n    test::<f32>(f32::MIN_POSITIVE_NORMAL, 1);\n    test::<f32>(f32::MAX_FINITE, 254);\n\n    test::<f64>(0.0, 0);\n    test::<f64>(-0.0, 0);\n    test::<f64>(f64::NAN, 2047);\n    test::<f64>(f64::INFINITY, 2047);\n    test::<f64>(f64::NEGATIVE_INFINITY, 2047);\n    test::<f64>(1.0, 1023);\n    test::<f64>(core::f64::consts::PI, 1024);\n    test::<f64>(0.1, 1019);\n    test::<f64>(10.0, 1026);\n    test::<f64>(f64::MIN_POSITIVE_SUBNORMAL, 0);\n    test::<f64>(f64::MAX_SUBNORMAL, 0);\n    test::<f64>(f64::MIN_POSITIVE_NORMAL, 1);\n    test::<f64>(f64::MAX_FINITE, 2046);\n}\n\npub fn test_from_raw_mantissa_and_exponent() {\n    fn test<T: PrimitiveFloat>(mantissa: u64, exponent: u64, x: T) {\n        assert_eq!(\n            NiceFloat(T::from_raw_mantissa_and_exponent(mantissa, exponent)),\n            NiceFloat(x)\n        );\n    }\n    test::<f32>(0, 0, 0.0);\n    test::<f32>(0x400000, 255, f32::NAN);\n    test::<f32>(0, 255, f32::INFINITY);\n    test::<f32>(0, 127, 1.0);\n    test::<f32>(4788187, 128, core::f32::consts::PI);\n    test::<f32>(5033165, 123, 0.1);\n    test::<f32>(2097152, 130, 10.0);\n    test::<f32>(1, 0, f32::MIN_POSITIVE_SUBNORMAL);\n    test::<f32>(0x7fffff, 0, f32::MAX_SUBNORMAL);\n    test::<f32>(0, 1, f32::MIN_POSITIVE_NORMAL);\n    test::<f32>(0x7fffff, 254, f32::MAX_FINITE);\n\n    test::<f64>(0, 0, 0.0);\n    test::<f64>(0x8000000000000, 2047, f64::NAN);\n    test::<f64>(0, 2047, f64::INFINITY);\n    test::<f64>(0, 1023, 1.0);\n    test::<f64>(2570638124657944, 1024, core::f64::consts::PI);\n    test::<f64>(2702159776422298, 1019, 0.1);\n    test::<f64>(1125899906842624, 1026, 10.0);\n    test::<f64>(1, 0, f64::MIN_POSITIVE_SUBNORMAL);\n    test::<f64>(0xfffffffffffff, 0, f64::MAX_SUBNORMAL);\n    test::<f64>(0, 1, f64::MIN_POSITIVE_NORMAL);\n    test::<f64>(0xfffffffffffff, 2046, f64::MAX_FINITE);\n}\n\nfn from_raw_mantissa_and_exponent_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::from_raw_mantissa_and_exponent(\n        u64::power_of_2(T::MANTISSA_WIDTH),\n        0\n    ));\n    assert_panic!(T::from_raw_mantissa_and_exponent(\n        0,\n        u64::power_of_2(T::EXPONENT_WIDTH)\n    ));\n}\n\n#[test]\npub fn from_raw_mantissa_and_exponent_fail() {\n    apply_fn_to_primitive_floats!(from_raw_mantissa_and_exponent_fail_helper);\n}\n\nfn raw_mantissa_and_exponent_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|x| {\n        let (mantissa, exponent) = x.raw_mantissa_and_exponent();\n        assert_eq!(x.raw_mantissa(), mantissa);\n        assert_eq!(x.raw_exponent(), exponent);\n        assert_eq!(\n            NiceFloat(T::from_raw_mantissa_and_exponent(mantissa, exponent)),\n            NiceFloat(x.abs())\n        );\n\n        assert!(exponent.significant_bits() <= T::EXPONENT_WIDTH);\n        assert!(mantissa.significant_bits() <= T::MANTISSA_WIDTH);\n    });\n}\n\n#[test]\nfn raw_mantissa_and_exponent_properties() {\n    apply_fn_to_primitive_floats!(raw_mantissa_and_exponent_properties_helper);\n}\n\nfn from_raw_mantissa_and_exponent_properties_helper<T: PrimitiveFloat>() {\n    unsigned_pair_gen_var_26::<T>().test_properties(|(mantissa, exponent)| {\n        let f = T::from_raw_mantissa_and_exponent(mantissa, exponent);\n        assert!(f.is_nan() || f.sign() == Greater);\n        if !f.is_nan() {\n            assert_eq!(f.raw_mantissa_and_exponent(), (mantissa, exponent));\n        }\n    });\n}\n\n#[test]\nfn from_raw_mantissa_and_exponent_properties() {\n    apply_fn_to_primitive_floats!(from_raw_mantissa_and_exponent_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/mantissa_and_exponent/sci_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::mantissa_and_exponent::{\n    from_sci_mantissa_and_exponent_round, sci_mantissa_and_exponent_round,\n};\nuse malachite_base::num::conversion::traits::SciMantissaAndExponent;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_12, primitive_float_signed_pair_gen_var_1,\n    primitive_float_signed_pair_gen_var_2, primitive_float_unsigned_pair_gen_var_1,\n    primitive_float_unsigned_pair_gen_var_2,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_1,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_2, unsigned_gen_var_1,\n    unsigned_rounding_mode_pair_gen_var_1,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_sci_mantissa_and_exponent() {\n    fn test_unsigned<T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>, U: PrimitiveFloat>(\n        x: T,\n        mantissa: U,\n        exponent: u64,\n    ) {\n        assert_eq!(NiceFloat(x.sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(SciMantissaAndExponent::<U, u64>::sci_exponent(x), exponent);\n        let (actual_mantissa, actual_exponent) = x.sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(actual_mantissa), NiceFloat(mantissa));\n        assert_eq!(actual_exponent, exponent);\n    }\n    test_unsigned::<u8, f32>(1, 1.0, 0);\n    test_unsigned::<u8, f32>(2, 1.0, 1);\n    test_unsigned::<u8, f32>(3, 1.5, 1);\n    test_unsigned::<u8, f32>(100, 1.5625, 6);\n    test_unsigned::<u32, f32>(65536, 1.0, 16);\n\n    test_unsigned::<u16, f32>(u16::MAX, 1.9999695, 15);\n    test_unsigned::<u32, f32>(u32::MAX, 1.0, 32);\n    test_unsigned::<u64, f32>(u64::MAX, 1.0, 64);\n\n    test_unsigned::<u16, f64>(u16::MAX, 1.999969482421875, 15);\n    test_unsigned::<u32, f64>(u32::MAX, 1.9999999995343387, 31);\n    test_unsigned::<u64, f64>(u64::MAX, 1.0, 64);\n\n    fn test_primitive_float<T: PrimitiveFloat>(x: T, mantissa: T, exponent: i64) {\n        assert_eq!(NiceFloat(x.sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(x.sci_exponent(), exponent);\n        let (actual_mantissa, actual_exponent) = x.sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(actual_mantissa), NiceFloat(mantissa));\n        assert_eq!(actual_exponent, exponent);\n    }\n    test_primitive_float::<f32>(1.0, 1.0, 0);\n    test_primitive_float::<f32>(core::f32::consts::PI, core::f32::consts::FRAC_PI_2, 1);\n    test_primitive_float::<f32>(0.1, 1.6, -4);\n    test_primitive_float::<f32>(10.0, 1.25, 3);\n    test_primitive_float::<f32>(f32::MIN_POSITIVE_SUBNORMAL, 1.0, -149);\n    test_primitive_float::<f32>(f32::MAX_SUBNORMAL, 1.9999998, -127);\n    test_primitive_float::<f32>(f32::MIN_POSITIVE_NORMAL, 1.0, -126);\n    test_primitive_float::<f32>(f32::MAX_FINITE, 1.9999999, 127);\n\n    test_primitive_float::<f64>(1.0, 1.0, 0);\n    test_primitive_float::<f64>(core::f64::consts::PI, core::f64::consts::FRAC_PI_2, 1);\n    test_primitive_float::<f64>(0.1, 1.6, -4);\n    test_primitive_float::<f64>(10.0, 1.25, 3);\n    test_primitive_float::<f64>(f64::MIN_POSITIVE_SUBNORMAL, 1.0, -1074);\n    test_primitive_float::<f64>(f64::MAX_SUBNORMAL, 1.9999999999999996, -1023);\n    test_primitive_float::<f64>(f64::MIN_POSITIVE_NORMAL, 1.0, -1022);\n    test_primitive_float::<f64>(f64::MAX_FINITE, 1.9999999999999998, 1023);\n}\n\nfn sci_mantissa_and_exponent_fail_helper_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>() {\n    assert_panic!(SciMantissaAndExponent::<U, u64>::sci_mantissa_and_exponent(\n        T::ZERO\n    ));\n}\n\nfn sci_mantissa_and_exponent_fail_helper_primitive_float<T: PrimitiveFloat>() {\n    assert_panic!(T::NAN.sci_mantissa_and_exponent());\n    assert_panic!(T::INFINITY.sci_mantissa_and_exponent());\n    assert_panic!(T::NEGATIVE_INFINITY.sci_mantissa_and_exponent());\n    assert_panic!(T::ZERO.sci_mantissa_and_exponent());\n    assert_panic!(T::NEGATIVE_ZERO.sci_mantissa_and_exponent());\n}\n\n#[test]\npub fn sci_mantissa_and_exponent_fail() {\n    apply_fn_to_unsigneds_and_primitive_floats!(sci_mantissa_and_exponent_fail_helper_unsigned);\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_fail_helper_primitive_float);\n}\n\n#[test]\npub fn test_sci_mantissa_and_exponent_round() {\n    fn test<T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>, U: PrimitiveFloat>(\n        x: T,\n        rm: RoundingMode,\n        out: Option<(U, u64, Ordering)>,\n    ) {\n        assert_eq!(\n            sci_mantissa_and_exponent_round::<T, U>(x, rm).map(|(m, e, o)| (NiceFloat(m), e, o)),\n            out.map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    }\n    test::<u8, f32>(1, Floor, Some((1.0, 0, Equal)));\n    test::<u8, f32>(1, Down, Some((1.0, 0, Equal)));\n    test::<u8, f32>(1, Ceiling, Some((1.0, 0, Equal)));\n    test::<u8, f32>(1, Up, Some((1.0, 0, Equal)));\n    test::<u8, f32>(1, Nearest, Some((1.0, 0, Equal)));\n    test::<u8, f32>(1, Exact, Some((1.0, 0, Equal)));\n\n    test::<u8, f32>(2, Floor, Some((1.0, 1, Equal)));\n    test::<u8, f32>(3, Floor, Some((1.5, 1, Equal)));\n    test::<u8, f32>(100, Floor, Some((1.5625, 6, Equal)));\n    test::<u32, f32>(65536, Floor, Some((1.0, 16, Equal)));\n\n    test::<u16, f32>(u16::MAX, Floor, Some((1.9999695, 15, Equal)));\n    test::<u16, f32>(u16::MAX, Down, Some((1.9999695, 15, Equal)));\n    test::<u16, f32>(u16::MAX, Ceiling, Some((1.9999695, 15, Equal)));\n    test::<u16, f32>(u16::MAX, Up, Some((1.9999695, 15, Equal)));\n    test::<u16, f32>(u16::MAX, Nearest, Some((1.9999695, 15, Equal)));\n    test::<u16, f32>(u16::MAX, Exact, Some((1.9999695, 15, Equal)));\n\n    test::<u32, f32>(u32::MAX, Floor, Some((1.9999999, 31, Less)));\n    test::<u32, f32>(u32::MAX, Down, Some((1.9999999, 31, Less)));\n    test::<u32, f32>(u32::MAX, Ceiling, Some((1.0, 32, Greater)));\n    test::<u32, f32>(u32::MAX, Up, Some((1.0, 32, Greater)));\n    test::<u32, f32>(u32::MAX, Nearest, Some((1.0, 32, Greater)));\n    test::<u32, f32>(u32::MAX, Exact, None);\n\n    test::<u64, f32>(u64::MAX, Floor, Some((1.9999999, 63, Less)));\n    test::<u64, f32>(u64::MAX, Down, Some((1.9999999, 63, Less)));\n    test::<u64, f32>(u64::MAX, Ceiling, Some((1.0, 64, Greater)));\n    test::<u64, f32>(u64::MAX, Up, Some((1.0, 64, Greater)));\n    test::<u64, f32>(u64::MAX, Nearest, Some((1.0, 64, Greater)));\n    test::<u64, f32>(u64::MAX, Exact, None);\n\n    test::<u16, f64>(u16::MAX, Floor, Some((1.999969482421875, 15, Equal)));\n    test::<u16, f64>(u16::MAX, Down, Some((1.999969482421875, 15, Equal)));\n    test::<u16, f64>(u16::MAX, Ceiling, Some((1.999969482421875, 15, Equal)));\n    test::<u16, f64>(u16::MAX, Up, Some((1.999969482421875, 15, Equal)));\n    test::<u16, f64>(u16::MAX, Nearest, Some((1.999969482421875, 15, Equal)));\n    test::<u16, f64>(u16::MAX, Exact, Some((1.999969482421875, 15, Equal)));\n\n    test::<u32, f64>(u32::MAX, Floor, Some((1.9999999995343387, 31, Equal)));\n    test::<u32, f64>(u32::MAX, Down, Some((1.9999999995343387, 31, Equal)));\n    test::<u32, f64>(u32::MAX, Ceiling, Some((1.9999999995343387, 31, Equal)));\n    test::<u32, f64>(u32::MAX, Up, Some((1.9999999995343387, 31, Equal)));\n    test::<u32, f64>(u32::MAX, Nearest, Some((1.9999999995343387, 31, Equal)));\n    test::<u32, f64>(u32::MAX, Exact, Some((1.9999999995343387, 31, Equal)));\n\n    test::<u64, f64>(u64::MAX, Floor, Some((1.9999999999999998, 63, Less)));\n    test::<u64, f64>(u64::MAX, Down, Some((1.9999999999999998, 63, Less)));\n    test::<u64, f64>(u64::MAX, Ceiling, Some((1.0, 64, Greater)));\n    test::<u64, f64>(u64::MAX, Up, Some((1.0, 64, Greater)));\n    test::<u64, f64>(u64::MAX, Nearest, Some((1.0, 64, Greater)));\n    test::<u64, f64>(u64::MAX, Exact, None);\n}\n\nfn sci_mantissa_and_exponent_round_fail_helper<T: PrimitiveUnsigned, U: PrimitiveFloat>() {\n    assert_panic!(sci_mantissa_and_exponent_round::<T, U>(T::ZERO, Floor));\n}\n\n#[test]\npub fn sci_mantissa_and_exponent_round_fail() {\n    apply_fn_to_unsigneds_and_primitive_floats!(sci_mantissa_and_exponent_round_fail_helper);\n}\n\n#[test]\npub fn test_from_sci_mantissa_and_exponent() {\n    fn test_unsigned<T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>, U: PrimitiveFloat>(\n        mantissa: U,\n        exponent: u64,\n        x: Option<T>,\n    ) {\n        assert_eq!(T::from_sci_mantissa_and_exponent(mantissa, exponent), x);\n    }\n    test_unsigned::<u8, f32>(1.0, 0, Some(1));\n    test_unsigned::<u8, f32>(1.0, 1, Some(2));\n    test_unsigned::<u8, f32>(1.5, 0, Some(2));\n    test_unsigned::<u8, f32>(1.5, 1, Some(3));\n    test_unsigned::<u8, f32>(1.5626, 6, Some(100));\n    test_unsigned::<u32, f32>(1.0, 16, Some(65536));\n    test_unsigned::<u32, f32>(1.0, 100, None);\n    test_unsigned::<u32, f64>(1.0, 32, None);\n\n    fn test_primitive_float<T: PrimitiveFloat>(mantissa: T, exponent: i64, x: Option<T>) {\n        assert_eq!(\n            T::from_sci_mantissa_and_exponent(mantissa, exponent).map(NiceFloat),\n            x.map(NiceFloat)\n        );\n    }\n    test_primitive_float::<f32>(1.0, 0, Some(1.0));\n    test_primitive_float::<f32>(std::f32::consts::FRAC_PI_2, 1, Some(core::f32::consts::PI));\n    test_primitive_float::<f32>(1.6, -4, Some(0.1));\n    test_primitive_float::<f32>(1.25, 3, Some(10.0));\n    test_primitive_float::<f32>(1.0, -149, Some(f32::MIN_POSITIVE_SUBNORMAL));\n    test_primitive_float::<f32>(1.9999998, -127, Some(f32::MAX_SUBNORMAL));\n    test_primitive_float::<f32>(1.0, -126, Some(f32::MIN_POSITIVE_NORMAL));\n    test_primitive_float::<f32>(1.9999999, 127, Some(f32::MAX_FINITE));\n\n    test_primitive_float::<f32>(2.0, 1, None);\n    test_primitive_float::<f32>(1.1, -2000, None);\n    test_primitive_float::<f32>(1.1, 2000, None);\n    test_primitive_float::<f32>(1.999, -149, None); // precision too high\n\n    test_primitive_float::<f64>(1.0, 0, Some(1.0));\n    test_primitive_float::<f64>(std::f64::consts::FRAC_PI_2, 1, Some(core::f64::consts::PI));\n    test_primitive_float::<f64>(1.6, -4, Some(0.1));\n    test_primitive_float::<f64>(1.25, 3, Some(10.0));\n    test_primitive_float::<f64>(1.0, -1074, Some(f64::MIN_POSITIVE_SUBNORMAL));\n    test_primitive_float::<f64>(1.9999999999999996, -1023, Some(f64::MAX_SUBNORMAL));\n    test_primitive_float::<f64>(1.0, -1022, Some(f64::MIN_POSITIVE_NORMAL));\n    test_primitive_float::<f64>(1.9999999999999998, 1023, Some(f64::MAX_FINITE));\n\n    test_primitive_float::<f64>(2.0, 1, None);\n    test_primitive_float::<f64>(1.1, -2000, None);\n    test_primitive_float::<f64>(1.1, 2000, None);\n    test_primitive_float::<f64>(1.999, -1074, None); // precision too high\n}\n\n#[test]\npub fn test_from_sci_mantissa_and_exponent_round() {\n    fn test<T: PrimitiveUnsigned, U: PrimitiveFloat>(\n        mantissa: U,\n        exponent: u64,\n        rm: RoundingMode,\n        xo: Option<(T, Ordering)>,\n    ) {\n        assert_eq!(\n            from_sci_mantissa_and_exponent_round::<T, U>(mantissa, exponent, rm),\n            xo\n        );\n    }\n    test::<u8, f32>(1.0, 0, Floor, Some((1, Equal)));\n    test::<u8, f32>(1.0, 0, Down, Some((1, Equal)));\n    test::<u8, f32>(1.0, 0, Ceiling, Some((1, Equal)));\n    test::<u8, f32>(1.0, 0, Up, Some((1, Equal)));\n    test::<u8, f32>(1.0, 0, Nearest, Some((1, Equal)));\n    test::<u8, f32>(1.0, 0, Exact, Some((1, Equal)));\n\n    test::<u8, f32>(1.25, 0, Floor, Some((1, Less)));\n    test::<u8, f32>(1.25, 0, Down, Some((1, Less)));\n    test::<u8, f32>(1.25, 0, Ceiling, Some((2, Greater)));\n    test::<u8, f32>(1.25, 0, Up, Some((2, Greater)));\n    test::<u8, f32>(1.25, 0, Nearest, Some((1, Less)));\n    test::<u8, f32>(1.25, 0, Exact, None);\n\n    test::<u8, f32>(1.5, 0, Floor, Some((1, Less)));\n    test::<u8, f32>(1.5, 0, Down, Some((1, Less)));\n    test::<u8, f32>(1.5, 0, Ceiling, Some((2, Greater)));\n    test::<u8, f32>(1.5, 0, Up, Some((2, Greater)));\n    test::<u8, f32>(1.5, 0, Nearest, Some((2, Greater)));\n    test::<u8, f32>(1.5, 0, Exact, None);\n\n    test::<u8, f32>(1.75, 0, Floor, Some((1, Less)));\n    test::<u8, f32>(1.75, 0, Down, Some((1, Less)));\n    test::<u8, f32>(1.75, 0, Ceiling, Some((2, Greater)));\n    test::<u8, f32>(1.75, 0, Up, Some((2, Greater)));\n    test::<u8, f32>(1.75, 0, Nearest, Some((2, Greater)));\n    test::<u8, f32>(1.75, 0, Exact, None);\n\n    test::<u8, f32>(1.5, 1, Floor, Some((3, Equal)));\n    test::<u8, f32>(1.5, 1, Down, Some((3, Equal)));\n    test::<u8, f32>(1.5, 1, Ceiling, Some((3, Equal)));\n    test::<u8, f32>(1.5, 1, Up, Some((3, Equal)));\n    test::<u8, f32>(1.5, 1, Nearest, Some((3, Equal)));\n    test::<u8, f32>(1.5, 1, Exact, Some((3, Equal)));\n\n    test::<u8, f32>(1.0, 100, Floor, None);\n    test::<u8, f32>(1.0, 100, Down, None);\n    test::<u8, f32>(1.0, 100, Ceiling, None);\n    test::<u8, f32>(1.0, 100, Up, None);\n    test::<u8, f32>(1.0, 100, Nearest, None);\n    test::<u8, f32>(1.0, 100, Exact, None);\n}\n\nfn from_sci_mantissa_and_exponent_round_fail_helper<T: PrimitiveUnsigned, U: PrimitiveFloat>() {\n    assert_panic!(from_sci_mantissa_and_exponent_round::<T, U>(\n        U::ZERO,\n        0,\n        Floor\n    ));\n}\n\n#[test]\npub fn from_sci_mantissa_and_exponent_round_fail() {\n    apply_fn_to_unsigneds_and_primitive_floats!(from_sci_mantissa_and_exponent_round_fail_helper);\n}\n\nfn sci_mantissa_and_exponent_properties_helper_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>() {\n    unsigned_gen_var_1::<T>().test_properties(|x| {\n        let (mantissa, exponent) = SciMantissaAndExponent::<U, u64>::sci_mantissa_and_exponent(x);\n        assert_eq!(NiceFloat(x.sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(SciMantissaAndExponent::<U, u64>::sci_exponent(x), exponent);\n        assert_eq!(\n            sci_mantissa_and_exponent_round(x, Nearest).map(|(m, e, _)| (NiceFloat(m), e)),\n            Some((NiceFloat(mantissa), exponent))\n        );\n\n        assert!(exponent <= T::WIDTH);\n        assert!(mantissa >= U::ONE);\n        assert!(mantissa < U::TWO);\n    });\n}\n\nfn sci_mantissa_and_exponent_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_gen_var_12::<T>().test_properties(|x| {\n        let (mantissa, exponent) = x.sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(x.sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(x.sci_exponent(), exponent);\n        assert_eq!(\n            NiceFloat(T::from_sci_mantissa_and_exponent(mantissa, exponent).unwrap()),\n            NiceFloat(x.abs())\n        );\n\n        assert!(exponent >= T::MIN_EXPONENT);\n        assert!(exponent <= T::MAX_EXPONENT);\n        assert!(mantissa >= T::ONE);\n        assert!(mantissa < T::TWO);\n\n        let precision = x.precision();\n        assert_eq!(mantissa.precision(), precision);\n        assert!(precision <= T::max_precision_for_sci_exponent(exponent));\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_properties() {\n    apply_fn_to_unsigneds_and_primitive_floats!(\n        sci_mantissa_and_exponent_properties_helper_unsigned\n    );\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_properties_helper_primitive_float);\n}\n\nfn sci_mantissa_and_exponent_properties_round_helper<T: PrimitiveUnsigned, U: PrimitiveFloat>() {\n    unsigned_rounding_mode_pair_gen_var_1::<T>().test_properties(|(x, rm)| {\n        if let Some((mantissa, exponent, o)) = sci_mantissa_and_exponent_round::<T, U>(x, rm) {\n            assert!(mantissa >= U::ONE);\n            assert!(mantissa < U::TWO);\n            match rm {\n                Floor | Down => assert_ne!(o, Greater),\n                Ceiling | Up => assert_ne!(o, Less),\n                Exact => assert_eq!(o, Equal),\n                _ => {}\n            }\n            if o == Equal {\n                for rm in exhaustive_rounding_modes() {\n                    assert_eq!(\n                        sci_mantissa_and_exponent_round(x, rm),\n                        Some((mantissa, exponent, Equal))\n                    );\n                }\n            } else {\n                assert!(sci_mantissa_and_exponent_round::<T, U>(x, Exact).is_none(),);\n            }\n        }\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        let (floor_mantissa, floor_exponent, o_floor) =\n            sci_mantissa_and_exponent_round::<T, U>(n, Floor).unwrap();\n        assert_ne!(o_floor, Greater);\n        assert_eq!(\n            sci_mantissa_and_exponent_round::<T, U>(n, Down).unwrap(),\n            (floor_mantissa, floor_exponent, o_floor)\n        );\n        let (ceiling_mantissa, ceiling_exponent, o_ceiling) =\n            sci_mantissa_and_exponent_round::<T, U>(n, Ceiling).unwrap();\n        assert_ne!(o_ceiling, Less);\n        assert_eq!(\n            sci_mantissa_and_exponent_round::<T, U>(n, Up).unwrap(),\n            (ceiling_mantissa, ceiling_exponent, o_ceiling)\n        );\n        let (nearest_mantissa, nearest_exponent, o_nearest) =\n            sci_mantissa_and_exponent_round::<T, U>(n, Nearest).unwrap();\n        if let Some((mantissa, exponent, o)) = sci_mantissa_and_exponent_round::<T, U>(n, Exact) {\n            assert_eq!(o, Equal);\n            assert_eq!(floor_mantissa, mantissa);\n            assert_eq!(ceiling_mantissa, mantissa);\n            assert_eq!(nearest_mantissa, mantissa);\n            assert_eq!(floor_exponent, exponent);\n            assert_eq!(ceiling_exponent, exponent);\n            assert_eq!(nearest_exponent, exponent);\n        } else {\n            assert_ne!(\n                (floor_mantissa, floor_exponent),\n                (ceiling_mantissa, ceiling_exponent)\n            );\n            assert!(\n                (nearest_mantissa, nearest_exponent, o_nearest)\n                    == (floor_mantissa, floor_exponent, Less)\n                    || (nearest_mantissa, nearest_exponent, o_nearest)\n                        == (ceiling_mantissa, ceiling_exponent, Greater)\n            );\n            if ceiling_mantissa == U::ONE {\n                assert_eq!(floor_mantissa, U::TWO.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent - 1);\n            } else {\n                assert_eq!(floor_mantissa, ceiling_mantissa.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent);\n            }\n        }\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_round_properties() {\n    apply_fn_to_unsigneds_and_primitive_floats!(sci_mantissa_and_exponent_properties_round_helper);\n}\n\nfn from_sci_mantissa_and_exponent_properties_helper_unsigned<\n    T: PrimitiveUnsigned + SciMantissaAndExponent<U, u64>,\n    U: PrimitiveFloat,\n>() {\n    primitive_float_unsigned_pair_gen_var_1::<U, u64>().test_properties(|(m, e)| {\n        T::from_sci_mantissa_and_exponent(m, e);\n    });\n\n    primitive_float_unsigned_pair_gen_var_2::<U>().test_properties(|(m, e)| {\n        assert!(m >= U::ONE && m < U::TWO);\n        let on = T::from_sci_mantissa_and_exponent(m, e);\n        assert_eq!(\n            from_sci_mantissa_and_exponent_round(m, e, Nearest).map(|p| p.0),\n            on\n        );\n    });\n}\n\nfn from_sci_mantissa_and_exponent_properties_helper_primitive_float<T: PrimitiveFloat>() {\n    primitive_float_signed_pair_gen_var_1().test_properties(|(mantissa, exponent)| {\n        T::from_sci_mantissa_and_exponent(mantissa, exponent);\n    });\n\n    primitive_float_signed_pair_gen_var_2::<T>().test_properties(|(mantissa, exponent)| {\n        let f = T::from_sci_mantissa_and_exponent(mantissa, exponent).unwrap();\n        assert!(!f.is_nan());\n        assert_eq!(f.sign(), Greater);\n        assert_eq!(f.sci_mantissa_and_exponent(), (mantissa, exponent));\n    });\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_properties() {\n    apply_fn_to_unsigneds_and_primitive_floats!(\n        from_sci_mantissa_and_exponent_properties_helper_unsigned\n    );\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_properties_helper_primitive_float);\n}\n\nfn from_sci_mantissa_and_exponent_properties_round_helper<\n    T: PrimitiveUnsigned,\n    U: PrimitiveFloat,\n>() {\n    primitive_float_unsigned_rounding_mode_triple_gen_var_1::<U, u64>().test_properties(\n        |(m, e, rm)| {\n            let on = from_sci_mantissa_and_exponent_round::<T, U>(m, e, rm);\n            if let Some((x, o)) = on {\n                assert!(m >= U::ONE && m < U::TWO);\n                if o == Equal {\n                    for rm in exhaustive_rounding_modes() {\n                        assert_eq!(\n                            from_sci_mantissa_and_exponent_round::<T, U>(m, e, rm),\n                            Some((x, Equal))\n                        );\n                    }\n                } else {\n                    assert!(from_sci_mantissa_and_exponent_round::<T, U>(m, e, Exact).is_none());\n                }\n            }\n        },\n    );\n\n    primitive_float_unsigned_rounding_mode_triple_gen_var_2::<U>().test_properties(|(m, e, rm)| {\n        assert!(m >= U::ONE && m < U::TWO);\n        from_sci_mantissa_and_exponent_round::<T, U>(m, e, rm);\n    });\n\n    primitive_float_unsigned_pair_gen_var_2::<U>().test_properties(|(m, e)| {\n        if let Some(ceiling_n) = from_sci_mantissa_and_exponent_round::<T, U>(m, e, Ceiling) {\n            assert_eq!(\n                from_sci_mantissa_and_exponent_round::<T, U>(m, e, Up).unwrap(),\n                ceiling_n\n            );\n            let floor_n = from_sci_mantissa_and_exponent_round::<T, U>(m, e, Floor).unwrap();\n            assert_eq!(\n                from_sci_mantissa_and_exponent_round::<T, U>(m, e, Down).unwrap(),\n                floor_n\n            );\n            let nearest_n = from_sci_mantissa_and_exponent_round::<T, U>(m, e, Nearest).unwrap();\n            if let Some(n) = from_sci_mantissa_and_exponent_round::<T, U>(m, e, Exact) {\n                assert_eq!(floor_n, n);\n                assert_eq!(ceiling_n, n);\n                assert_eq!(nearest_n, n);\n            } else {\n                assert!(nearest_n == floor_n || nearest_n == ceiling_n);\n                if floor_n.0 != T::MAX {\n                    assert_eq!(ceiling_n.0, floor_n.0 + T::ONE);\n                }\n            }\n        }\n    });\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_round_properties() {\n    apply_fn_to_unsigneds_and_primitive_floats!(\n        from_sci_mantissa_and_exponent_properties_round_helper\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/slice/from_other_type_slice.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{FromOtherTypeSlice, VecFromOtherTypeSlice};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse std::fmt::Debug;\n\n#[test]\npub fn test_from_other_type_slice() {\n    fn test<T: Debug + Eq, U: Copy + Debug + Eq + FromOtherTypeSlice<T>>(slice: &[T], n: U) {\n        assert_eq!(U::from_other_type_slice(slice), n);\n    }\n    test::<u32, u32>(&[], 0);\n    test::<u32, u32>(&[123], 123);\n    test::<u32, u32>(&[123, 456], 123);\n\n    test::<u8, u16>(&[0xab], 0xab);\n    test::<u8, u16>(&[0xab, 0xcd], 0xcdab);\n    test::<u8, u16>(&[0xab, 0xcd, 0xef], 0xcdab);\n    test::<u8, u64>(\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67],\n        0x67452301efcdab,\n    );\n    test::<u8, u64>(\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xff],\n        0x8967452301efcdab,\n    );\n\n    test::<u64, u32>(&[], 0);\n    test::<u16, u8>(&[0xabcd, 0xef01], 0xcd);\n    test::<u128, u8>(&[0x1234567890abcdef012345678909bcde], 0xde);\n}\n\nfn from_other_type_slice_helper<\n    T: PrimitiveUnsigned + FromOtherTypeSlice<U> + VecFromOtherTypeSlice<U>,\n    U: PrimitiveUnsigned,\n>() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << U::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_gen::<U>().test_properties_with_config(&config, |xs| {\n        let value = T::from_other_type_slice(&xs);\n        let ys = T::vec_from_other_type_slice(&xs);\n        if xs.is_empty() {\n            assert_eq!(value, T::ZERO);\n        } else {\n            assert_eq!(value, ys[0]);\n        }\n    });\n}\n\n#[test]\nfn from_other_type_slice_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(from_other_type_slice_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/slice/vec_from_other_type.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    FromOtherTypeSlice, VecFromOtherType, VecFromOtherTypeSlice,\n};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse std::fmt::Debug;\n\n#[test]\npub fn test_vec_from_other_type() {\n    fn test<T: Debug + Eq, U: Debug + Eq + VecFromOtherType<T>>(value: T, vec: &[U]) {\n        assert_eq!(U::vec_from_other_type(value), vec);\n    }\n    test::<u32, u32>(123, &[123]);\n    test::<u8, u16>(0xab, &[0xab]);\n    test::<u16, u8>(0xcdab, &[0xab, 0xcd]);\n}\n\nfn vec_from_other_type_helper<\n    T: PrimitiveUnsigned + FromOtherTypeSlice<U>,\n    U: PrimitiveUnsigned + VecFromOtherType<T> + VecFromOtherTypeSlice<T>,\n>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        let xs = U::vec_from_other_type(x);\n        assert_eq!(U::vec_from_other_type_slice(&[x]), xs);\n        assert_eq!(T::from_other_type_slice(&xs), x);\n    });\n}\n\n#[test]\nfn vec_from_other_type_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(vec_from_other_type_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/slice/vec_from_other_type_slice.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegModPowerOf2;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::VecFromOtherTypeSlice;\nuse malachite_base::slices::slice_test_zero;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse std::fmt::Debug;\n\n#[test]\npub fn test_vec_from_other_type_slice() {\n    fn test<T: Debug + Eq, U: Debug + Eq + VecFromOtherTypeSlice<T>>(slice: &[T], vec: &[U]) {\n        assert_eq!(U::vec_from_other_type_slice(slice), vec);\n    }\n    test::<u32, u32>(&[123, 456], &[123, 456]);\n    test::<u8, u16>(\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xff],\n        &[0xcdab, 0x01ef, 0x4523, 0x8967, 0xff],\n    );\n    test::<u8, u16>(&[0xab], &[0xab]);\n    test::<u16, u8>(\n        &[0xcdab, 0x01ef, 0x4523, 0x8967],\n        &[0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89],\n    );\n}\n\nfn vec_from_other_type_slice_helper<\n    T: PrimitiveUnsigned + VecFromOtherTypeSlice<U>,\n    U: PrimitiveUnsigned + VecFromOtherTypeSlice<T>,\n>() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << U::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_gen::<U>().test_properties_with_config(&config, |xs| {\n        let ys = T::vec_from_other_type_slice(&xs);\n        let xs_alt = U::vec_from_other_type_slice(&ys);\n        if U::WIDTH >= T::WIDTH {\n            assert_eq!(xs_alt, xs);\n        } else {\n            let number_of_extra_zeros = xs.len().neg_mod_power_of_2(T::LOG_WIDTH - U::LOG_WIDTH);\n            let (xs_alt_lo, xs_alt_hi) = xs_alt.split_at(xs.len());\n            assert_eq!(xs_alt_hi.len(), number_of_extra_zeros);\n            assert_eq!(xs_alt_lo, xs);\n            assert!(slice_test_zero(xs_alt_hi));\n        }\n    });\n}\n\n#[test]\nfn vec_from_other_type_slice_properties() {\n    apply_fn_to_unsigneds_and_unsigneds!(vec_from_other_type_slice_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    signed_gen, string_from_sci_string_options_pair_gen,\n    string_from_sci_string_options_pair_gen_var_1, string_gen, string_gen_var_13, unsigned_gen,\n};\n\n#[test]\npub fn test_from_sci_string() {\n    fn test<T: PrimitiveInt>(s: &str, out: Option<T>) {\n        assert_eq!(T::from_sci_string(s), out);\n        assert_eq!(\n            T::from_sci_string_with_options(s, FromSciStringOptions::default()),\n            out\n        );\n    }\n    test::<u8>(\"0\", Some(0));\n    test::<u8>(\"00\", Some(0));\n    test::<u8>(\"+0\", Some(0));\n    test::<u8>(\"-0\", Some(0));\n    test::<u8>(\"0.00\", Some(0));\n    test::<u8>(\"0e1\", Some(0));\n    test::<u8>(\"0e+1\", Some(0));\n    test::<u8>(\"0e-1\", Some(0));\n    test::<u8>(\"+0e+1\", Some(0));\n    test::<u8>(\"-0e+1\", Some(0));\n    test::<u8>(\"+0.0e+1\", Some(0));\n    test::<u8>(\"-0.0e+1\", Some(0));\n    test::<u8>(\".0\", Some(0));\n    test::<u8>(\".00\", Some(0));\n    test::<u8>(\".00e0\", Some(0));\n    test::<u8>(\".00e1\", Some(0));\n    test::<u8>(\".00e-1\", Some(0));\n    test::<u8>(\"-.0\", Some(0));\n    test::<u8>(\"-.00\", Some(0));\n    test::<u8>(\"-.00e0\", Some(0));\n    test::<u8>(\"-.00e1\", Some(0));\n    test::<u8>(\"-.00e-1\", Some(0));\n    test::<u8>(\"+.0\", Some(0));\n    test::<u8>(\"+.00\", Some(0));\n    test::<u8>(\"+.00e0\", Some(0));\n    test::<u8>(\"+.00e1\", Some(0));\n    test::<u8>(\"+.00e-1\", Some(0));\n\n    test::<u8>(\"123\", Some(123));\n    test::<u8>(\"00123\", Some(123));\n    test::<u8>(\"+123\", Some(123));\n    test::<u8>(\"123.00\", Some(123));\n    test::<u8>(\"123e0\", Some(123));\n    test::<u8>(\"12.3e1\", Some(123));\n    test::<u8>(\"1.23e2\", Some(123));\n    test::<u8>(\"1.23E2\", Some(123));\n    test::<u8>(\"1.23e+2\", Some(123));\n    test::<u8>(\"1.23E+2\", Some(123));\n    test::<u8>(\".123e3\", Some(123));\n    test::<u8>(\"0.123e3\", Some(123));\n    test::<u8>(\"+0.123e3\", Some(123));\n    test::<u8>(\"0.0123e4\", Some(123));\n    test::<u8>(\"1230e-1\", Some(123));\n    test::<u8>(\"12300e-2\", Some(123));\n    test::<u8>(\"12300E-2\", Some(123));\n\n    test::<u8>(\"123.4\", Some(123));\n    test::<u8>(\"123.8\", Some(124));\n    test::<u8>(\"123.5\", Some(124));\n    test::<u8>(\"124.5\", Some(124));\n    test::<u8>(\"255.49\", Some(255));\n    test::<u8>(\"255.5\", None);\n\n    test::<u8>(\"0.5\", Some(0));\n    test::<u8>(\"0.51\", Some(1));\n    test::<u8>(\"0.001\", Some(0));\n    test::<u8>(\"1e-10\", Some(0));\n    test::<u8>(\"-0.5\", Some(0));\n    test::<u8>(\"-0.51\", None);\n    test::<u8>(\"-0.001\", Some(0));\n    test::<u8>(\"-1e-10\", Some(0));\n\n    test::<u8>(\"\", None);\n    test::<u8>(\"+\", None);\n    test::<u8>(\"-\", None);\n    test::<u8>(\"10e\", None);\n    test::<u8>(\"++1\", None);\n    test::<u8>(\"256\", None);\n    test::<u8>(\"-1\", None);\n    test::<u8>(\"1e10\", None);\n    test::<u8>(\"1.0.0\", None);\n    test::<u8>(\"1e++1\", None);\n    test::<u8>(\"1e0.1\", None);\n    test::<u8>(\"--.0\", None);\n    test::<u8>(\"++.0\", None);\n    test::<u8>(\"0.000a\", None);\n    test::<u8>(\"0.00ae-10\", None);\n\n    test::<i8>(\"0\", Some(0));\n    test::<i8>(\"00\", Some(0));\n    test::<i8>(\"+0\", Some(0));\n    test::<i8>(\"-0\", Some(0));\n    test::<i8>(\"0.00\", Some(0));\n    test::<i8>(\"0e1\", Some(0));\n    test::<i8>(\"0e+1\", Some(0));\n    test::<i8>(\"0e-1\", Some(0));\n    test::<i8>(\"+0e+1\", Some(0));\n    test::<i8>(\"-0e+1\", Some(0));\n    test::<i8>(\"+0.0e+1\", Some(0));\n    test::<i8>(\"-0.0e+1\", Some(0));\n    test::<i8>(\".0\", Some(0));\n    test::<i8>(\".00\", Some(0));\n    test::<i8>(\".00e0\", Some(0));\n    test::<i8>(\".00e1\", Some(0));\n    test::<i8>(\".00e-1\", Some(0));\n    test::<i8>(\"-.0\", Some(0));\n    test::<i8>(\"-.00\", Some(0));\n    test::<i8>(\"-.00e0\", Some(0));\n    test::<i8>(\"-.00e1\", Some(0));\n    test::<i8>(\"-.00e-1\", Some(0));\n    test::<i8>(\"+.0\", Some(0));\n    test::<i8>(\"+.00\", Some(0));\n    test::<i8>(\"+.00e0\", Some(0));\n    test::<i8>(\"+.00e1\", Some(0));\n    test::<i8>(\"+.00e-1\", Some(0));\n\n    test::<i8>(\"123\", Some(123));\n    test::<i8>(\"00123\", Some(123));\n    test::<i8>(\"+123\", Some(123));\n    test::<i8>(\"123.00\", Some(123));\n    test::<i8>(\"123e0\", Some(123));\n    test::<i8>(\"12.3e1\", Some(123));\n    test::<i8>(\"1.23e2\", Some(123));\n    test::<i8>(\"1.23E2\", Some(123));\n    test::<i8>(\"1.23e+2\", Some(123));\n    test::<i8>(\"1.23E+2\", Some(123));\n    test::<i8>(\".123e3\", Some(123));\n    test::<i8>(\"0.123e3\", Some(123));\n    test::<i8>(\"+0.123e3\", Some(123));\n    test::<i8>(\"0.0123e4\", Some(123));\n    test::<i8>(\"1230e-1\", Some(123));\n    test::<i8>(\"12300e-2\", Some(123));\n    test::<i8>(\"12300E-2\", Some(123));\n\n    test::<i8>(\"-123\", Some(-123));\n    test::<i8>(\"-00123\", Some(-123));\n    test::<i8>(\"-123.00\", Some(-123));\n    test::<i8>(\"-123e0\", Some(-123));\n    test::<i8>(\"-12.3e1\", Some(-123));\n    test::<i8>(\"-1.23e2\", Some(-123));\n    test::<i8>(\"-1.23E2\", Some(-123));\n    test::<i8>(\"-1.23e+2\", Some(-123));\n    test::<i8>(\"-1.23E+2\", Some(-123));\n    test::<i8>(\"-.123e3\", Some(-123));\n    test::<i8>(\"-0.123e3\", Some(-123));\n    test::<i8>(\"-0.0123e4\", Some(-123));\n    test::<i8>(\"-1230e-1\", Some(-123));\n    test::<i8>(\"-12300e-2\", Some(-123));\n    test::<i8>(\"-12300E-2\", Some(-123));\n\n    test::<i8>(\"123.4\", Some(123));\n    test::<i8>(\"123.8\", Some(124));\n    test::<i8>(\"123.5\", Some(124));\n    test::<i8>(\"124.5\", Some(124));\n    test::<i8>(\"127.49\", Some(127));\n    test::<i8>(\"127.5\", None);\n\n    test::<i8>(\"-123.4\", Some(-123));\n    test::<i8>(\"-123.8\", Some(-124));\n    test::<i8>(\"-123.5\", Some(-124));\n    test::<i8>(\"-124.5\", Some(-124));\n    test::<i8>(\"-127.49\", Some(-127));\n    test::<i8>(\"-127.5\", Some(-128));\n    test::<i8>(\"-128.51\", None);\n\n    test::<i8>(\"\", None);\n    test::<i8>(\"+\", None);\n    test::<i8>(\"-\", None);\n    test::<i8>(\"10e\", None);\n    test::<i8>(\"++1\", None);\n    test::<i8>(\"128\", None);\n    test::<i8>(\"-129\", None);\n    test::<i8>(\"1e10\", None);\n    test::<i8>(\"1.0.0\", None);\n    test::<i8>(\"1e++1\", None);\n    test::<i8>(\"1e0.1\", None);\n    test::<i8>(\"--.0\", None);\n    test::<i8>(\"++.0\", None);\n    test::<i8>(\".+2\", None);\n    test::<i8>(\".-2\", None);\n    test::<i8>(\"0.000a\", None);\n    test::<i8>(\"0.00ae-10\", None);\n    test::<i8>(\"0e10000000000000000000000000000\", None);\n    test::<i8>(\"0e-10000000000000000000000000000\", None);\n}\n\n#[test]\npub fn test_from_sci_string_with_options() {\n    fn test<T: PrimitiveInt>(s: &str, options: FromSciStringOptions, out: Option<T>) {\n        assert_eq!(T::from_sci_string_with_options(s, options), out);\n    }\n    // For tests with the default options, see `test_from_sci_string`\n\n    let mut options = FromSciStringOptions::default();\n    options.set_base(2);\n    test::<u128>(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(3);\n    test::<u128>(\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(4);\n    test::<u128>(\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(5);\n    test::<u128>(\n        \"11031110441201303134210404233413032443021130230130231310\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(8);\n    test::<u128>(\n        \"3777777777777777777777777777777777777777777\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(16);\n    test::<u128>(\"ffffffffffffffffffffffffffffffff\", options, Some(u128::MAX));\n    options.set_base(32);\n    test::<u128>(\"7vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(u128::MAX));\n    options.set_base(36);\n    test::<u128>(\"f5lxx1zz5pnorynqglhzmsp33\", options, Some(u128::MAX));\n\n    options.set_base(2);\n    test::<i128>(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(3);\n    test::<i128>(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(4);\n    test::<i128>(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(5);\n    test::<i128>(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-3013030220323124042102424341431241221233040112312340403\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(8);\n    test::<i128>(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-2000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(16);\n    test::<i128>(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    test::<i128>(\n        \"-80000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(32);\n    test::<i128>(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    test::<i128>(\"-40000000000000000000000000\", options, Some(i128::MIN));\n    options.set_base(36);\n    test::<i128>(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n    test::<i128>(\"-7ksyyizzkutudzbv8aqztecjk\", options, Some(i128::MIN));\n\n    options.set_base(2);\n    test::<u32>(\"1e+5\", options, Some(32));\n    test::<u32>(\"1e5\", options, Some(32));\n    options.set_base(3);\n    test::<u32>(\"1e+5\", options, Some(243));\n    test::<u32>(\"1e5\", options, Some(243));\n    options.set_base(4);\n    test::<u32>(\"1e+5\", options, Some(1024));\n    test::<u32>(\"1e5\", options, Some(1024));\n    options.set_base(5);\n    test::<u32>(\"1e+5\", options, Some(3125));\n    test::<u32>(\"1e5\", options, Some(3125));\n    options.set_base(8);\n    test::<u32>(\"1e+5\", options, Some(32768));\n    test::<u32>(\"1e5\", options, Some(32768));\n    options.set_base(16);\n    test::<u32>(\"1e+5\", options, Some(1048576));\n    test::<u32>(\"1e5\", options, Some(485));\n    options.set_base(32);\n    test::<u32>(\"1e+5\", options, Some(33554432));\n    test::<u32>(\"1e5\", options, Some(1477));\n    options.set_base(36);\n    test::<u32>(\"1e+5\", options, Some(60466176));\n    test::<u32>(\"1E+5\", options, Some(60466176));\n    test::<u32>(\"1e5\", options, Some(1805));\n\n    options.set_base(16);\n    test::<u8>(\"ff\", options, Some(255));\n    test::<u8>(\"fF\", options, Some(255));\n    test::<u8>(\"Ff\", options, Some(255));\n    test::<u8>(\"FF\", options, Some(255));\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Down);\n    test::<u8>(\"123.4\", options, Some(123));\n    options.set_rounding_mode(Floor);\n    test::<u8>(\"123.4\", options, Some(123));\n    options.set_rounding_mode(Up);\n    test::<u8>(\"123.4\", options, Some(124));\n    options.set_rounding_mode(Ceiling);\n    test::<u8>(\"123.4\", options, Some(124));\n    options.set_rounding_mode(Nearest);\n    test::<u8>(\"123.4\", options, Some(123));\n    options.set_rounding_mode(Exact);\n    test::<u8>(\"123.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<u8>(\"123.5\", options, Some(123));\n    options.set_rounding_mode(Floor);\n    test::<u8>(\"123.5\", options, Some(123));\n    options.set_rounding_mode(Up);\n    test::<u8>(\"123.5\", options, Some(124));\n    options.set_rounding_mode(Ceiling);\n    test::<u8>(\"123.5\", options, Some(124));\n    options.set_rounding_mode(Nearest);\n    test::<u8>(\"123.5\", options, Some(124));\n    options.set_rounding_mode(Exact);\n    test::<u8>(\"123.5\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<u8>(\"0.4\", options, Some(0));\n    options.set_rounding_mode(Floor);\n    test::<u8>(\"0.4\", options, Some(0));\n    options.set_rounding_mode(Up);\n    test::<u8>(\"0.4\", options, Some(1));\n    options.set_rounding_mode(Ceiling);\n    test::<u8>(\"0.4\", options, Some(1));\n    options.set_rounding_mode(Nearest);\n    test::<u8>(\"0.4\", options, Some(0));\n    options.set_rounding_mode(Exact);\n    test::<u8>(\"0.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<u8>(\"0.04\", options, Some(0));\n    options.set_rounding_mode(Floor);\n    test::<u8>(\"0.04\", options, Some(0));\n    options.set_rounding_mode(Up);\n    test::<u8>(\"0.04\", options, Some(1));\n    options.set_rounding_mode(Ceiling);\n    test::<u8>(\"0.04\", options, Some(1));\n    options.set_rounding_mode(Nearest);\n    test::<u8>(\"0.04\", options, Some(0));\n    options.set_rounding_mode(Exact);\n    test::<u8>(\"0.04\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test::<u8>(\"1.01\", options, Some(1));\n    test::<u8>(\"1.1\", options, Some(2));\n    test::<u8>(\"1.11\", options, Some(2));\n    test::<u8>(\"0.01\", options, Some(0));\n    test::<u8>(\"0.1\", options, Some(0));\n    test::<u8>(\"0.11\", options, Some(1));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test::<u8>(\"1.1\", options, Some(1));\n    test::<u8>(\"1.11\", options, Some(1));\n    test::<u8>(\"1.111\", options, Some(1));\n    test::<u8>(\"1.112\", options, Some(2));\n    test::<u8>(\"0.1\", options, Some(0));\n    test::<u8>(\"0.11\", options, Some(0));\n    test::<u8>(\"0.111\", options, Some(0));\n    test::<u8>(\"0.112\", options, Some(1));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test::<u8>(\"2\", options, None);\n    test::<u8>(\"102\", options, None);\n    test::<u8>(\"12e4\", options, None);\n    test::<u8>(\"12e-4\", options, None);\n    test::<u8>(\"1.2\", options, None);\n    test::<u8>(\"0.2\", options, None);\n    test::<u8>(\"0.002\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Exact);\n    test::<u8>(\"1.5\", options, None);\n    test::<u8>(\"1.9999999999999999999999999999\", options, None);\n\n    options.set_base(2);\n    test::<i128>(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(3);\n    test::<i128>(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(4);\n    test::<i128>(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(5);\n    test::<i128>(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-3013030220323124042102424341431241221233040112312340403\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(8);\n    test::<i128>(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    test::<i128>(\n        \"-2000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(16);\n    test::<i128>(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    test::<i128>(\n        \"-80000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(32);\n    test::<i128>(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    test::<i128>(\"-40000000000000000000000000\", options, Some(i128::MIN));\n    options.set_base(36);\n    test::<i128>(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n    test::<i128>(\"-7ksyyizzkutudzbv8aqztecjk\", options, Some(i128::MIN));\n\n    options.set_base(2);\n    test::<i32>(\"1e+5\", options, Some(32));\n    test::<i32>(\"1e5\", options, Some(32));\n    options.set_base(3);\n    test::<i32>(\"1e+5\", options, Some(243));\n    test::<i32>(\"1e5\", options, Some(243));\n    options.set_base(4);\n    test::<i32>(\"1e+5\", options, Some(1024));\n    test::<i32>(\"1e5\", options, Some(1024));\n    options.set_base(5);\n    test::<i32>(\"1e+5\", options, Some(3125));\n    test::<i32>(\"1e5\", options, Some(3125));\n    options.set_base(8);\n    test::<i32>(\"1e+5\", options, Some(32768));\n    test::<i32>(\"1e5\", options, Some(32768));\n    options.set_base(16);\n    test::<i32>(\"1e+5\", options, Some(1048576));\n    test::<i32>(\"1e5\", options, Some(485));\n    options.set_base(32);\n    test::<i32>(\"1e+5\", options, Some(33554432));\n    test::<i32>(\"1e5\", options, Some(1477));\n    options.set_base(36);\n    test::<i32>(\"1e+5\", options, Some(60466176));\n    test::<i32>(\"1E+5\", options, Some(60466176));\n    test::<i32>(\"1e5\", options, Some(1805));\n\n    options.set_base(2);\n    test::<i32>(\"-1e+5\", options, Some(-32));\n    test::<i32>(\"-1e5\", options, Some(-32));\n    options.set_base(3);\n    test::<i32>(\"-1e+5\", options, Some(-243));\n    test::<i32>(\"-1e5\", options, Some(-243));\n    options.set_base(4);\n    test::<i32>(\"-1e+5\", options, Some(-1024));\n    test::<i32>(\"-1e5\", options, Some(-1024));\n    options.set_base(5);\n    test::<i32>(\"-1e+5\", options, Some(-3125));\n    test::<i32>(\"-1e5\", options, Some(-3125));\n    options.set_base(8);\n    test::<i32>(\"-1e+5\", options, Some(-32768));\n    test::<i32>(\"-1e5\", options, Some(-32768));\n    options.set_base(16);\n    test::<i32>(\"-1e+5\", options, Some(-1048576));\n    test::<i32>(\"-1e5\", options, Some(-485));\n    options.set_base(32);\n    test::<i32>(\"-1e+5\", options, Some(-33554432));\n    test::<i32>(\"-1e5\", options, Some(-1477));\n    options.set_base(36);\n    test::<i32>(\"-1e+5\", options, Some(-60466176));\n    test::<i32>(\"-1E+5\", options, Some(-60466176));\n    test::<i32>(\"-1e5\", options, Some(-1805));\n\n    options.set_base(16);\n    test::<i16>(\"ff\", options, Some(255));\n    test::<i16>(\"fF\", options, Some(255));\n    test::<i16>(\"Ff\", options, Some(255));\n    test::<i16>(\"FF\", options, Some(255));\n    test::<i16>(\"-ff\", options, Some(-255));\n    test::<i16>(\"-fF\", options, Some(-255));\n    test::<i16>(\"-Ff\", options, Some(-255));\n    test::<i16>(\"-FF\", options, Some(-255));\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Down);\n    test::<i8>(\"123.4\", options, Some(123));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"123.4\", options, Some(123));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"123.4\", options, Some(124));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"123.4\", options, Some(124));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"123.4\", options, Some(123));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"123.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<i8>(\"-123.4\", options, Some(-123));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"-123.4\", options, Some(-124));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"-123.4\", options, Some(-124));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"-123.4\", options, Some(-123));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"-123.4\", options, Some(-123));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"-123.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<i8>(\"123.5\", options, Some(123));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"123.5\", options, Some(123));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"123.5\", options, Some(124));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"123.5\", options, Some(124));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"123.5\", options, Some(124));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"123.5\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<i8>(\"-123.5\", options, Some(-123));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"-123.5\", options, Some(-124));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"-123.5\", options, Some(-124));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"-123.5\", options, Some(-123));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"-123.5\", options, Some(-124));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"-123.5\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<i8>(\"0.4\", options, Some(0));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"0.4\", options, Some(0));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"0.4\", options, Some(1));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"0.4\", options, Some(1));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"0.4\", options, Some(0));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"0.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<i8>(\"-0.4\", options, Some(0));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"-0.4\", options, Some(-1));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"-0.4\", options, Some(-1));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"-0.4\", options, Some(0));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"-0.4\", options, Some(0));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"-0.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<i8>(\"0.04\", options, Some(0));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"0.04\", options, Some(0));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"0.04\", options, Some(1));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"0.04\", options, Some(1));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"0.04\", options, Some(0));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"0.04\", options, None);\n\n    options.set_rounding_mode(Down);\n    test::<i8>(\"-0.04\", options, Some(0));\n    options.set_rounding_mode(Floor);\n    test::<i8>(\"-0.04\", options, Some(-1));\n    options.set_rounding_mode(Up);\n    test::<i8>(\"-0.04\", options, Some(-1));\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\"-0.04\", options, Some(0));\n    options.set_rounding_mode(Nearest);\n    test::<i8>(\"-0.04\", options, Some(0));\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"-0.04\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test::<i8>(\"1.01\", options, Some(1));\n    test::<i8>(\"1.1\", options, Some(2));\n    test::<i8>(\"1.11\", options, Some(2));\n    test::<i8>(\"0.01\", options, Some(0));\n    test::<i8>(\"0.1\", options, Some(0));\n    test::<i8>(\"0.11\", options, Some(1));\n    test::<i8>(\"-1.01\", options, Some(-1));\n    test::<i8>(\"-1.1\", options, Some(-2));\n    test::<i8>(\"-1.11\", options, Some(-2));\n    test::<i8>(\"-0.01\", options, Some(0));\n    test::<i8>(\"-0.1\", options, Some(0));\n    test::<i8>(\"-0.11\", options, Some(-1));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test::<i8>(\"1.1\", options, Some(1));\n    test::<i8>(\"1.11\", options, Some(1));\n    test::<i8>(\"1.111\", options, Some(1));\n    test::<i8>(\"1.112\", options, Some(2));\n    test::<i8>(\"0.1\", options, Some(0));\n    test::<i8>(\"0.11\", options, Some(0));\n    test::<i8>(\"0.111\", options, Some(0));\n    test::<i8>(\"0.112\", options, Some(1));\n    test::<i8>(\"-1.1\", options, Some(-1));\n    test::<i8>(\"-1.11\", options, Some(-1));\n    test::<i8>(\"-1.111\", options, Some(-1));\n    test::<i8>(\"-1.112\", options, Some(-2));\n    test::<i8>(\"-0.1\", options, Some(0));\n    test::<i8>(\"-0.11\", options, Some(0));\n    test::<i8>(\"-0.111\", options, Some(0));\n    test::<i8>(\"-0.112\", options, Some(-1));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test::<i8>(\"2\", options, None);\n    test::<i8>(\"102\", options, None);\n    test::<i8>(\"12e4\", options, None);\n    test::<i8>(\"12e-4\", options, None);\n    test::<i8>(\"1.2\", options, None);\n    test::<i8>(\"0.2\", options, None);\n    test::<i8>(\"0.002\", options, None);\n    test::<i8>(\"-2\", options, None);\n    test::<i8>(\"-102\", options, None);\n    test::<i8>(\"-12e4\", options, None);\n    test::<i8>(\"-12e-4\", options, None);\n    test::<i8>(\"-1.2\", options, None);\n    test::<i8>(\"-0.2\", options, None);\n    test::<i8>(\"-0.002\", options, None);\n    options.set_base(25);\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(\".be.2\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Exact);\n    test::<i8>(\"1.5\", options, None);\n    test::<i8>(\"1.9999999999999999999999999999\", options, None);\n    test::<i8>(\"-1.5\", options, None);\n    test::<i8>(\"-1.9999999999999999999999999999\", options, None);\n}\n\nfn from_sci_string_helper_helper<T: PrimitiveInt>(s: &str) {\n    if let Some(x) = T::from_sci_string(s) {\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 2);\n        for c in ['.', 'e', 'E', '+'] {\n            if s.contains(c) {\n                return;\n            }\n        }\n        if s.starts_with('0') || s.starts_with(\"-0\") {\n            return;\n        }\n        assert_eq!(x.to_string(), s);\n    }\n}\n\nfn from_sci_string_helper<T: PrimitiveInt>() {\n    string_gen().test_properties(|s| {\n        from_sci_string_helper_helper::<T>(&s);\n    });\n\n    string_gen_var_13().test_properties(|s| {\n        from_sci_string_helper_helper::<T>(&s);\n    });\n}\n\nfn from_sci_string_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(T::from_sci_string(&x.to_string()).unwrap(), x);\n    });\n}\n\nfn from_sci_string_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(T::from_sci_string(&x.to_string()).unwrap(), x);\n    });\n}\n\n#[test]\nfn from_sci_string_properties() {\n    apply_fn_to_primitive_ints!(from_sci_string_helper);\n    apply_fn_to_unsigneds!(from_sci_string_helper_unsigned);\n    apply_fn_to_signeds!(from_sci_string_helper_signed);\n}\n\nfn from_sci_string_with_options_helper_helper<T: PrimitiveInt>(\n    s: &str,\n    options: FromSciStringOptions,\n) {\n    if let Some(x) = T::from_sci_string_with_options(s, options) {\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 2);\n        for c in ['.', 'e', 'E', '+'] {\n            if s.contains(c) {\n                return;\n            }\n        }\n        if s.starts_with('0') || s.starts_with(\"-0\") {\n            return;\n        }\n        assert_eq!(x.to_string_base(options.get_base()), s.to_lowercase());\n    }\n}\n\nfn from_sci_string_with_options_helper<T: PrimitiveInt>() {\n    string_from_sci_string_options_pair_gen().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper_helper::<T>(&s, options);\n    });\n\n    string_from_sci_string_options_pair_gen_var_1().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper_helper::<T>(&s, options);\n    });\n}\n\n#[test]\nfn from_sci_string_with_options_properties() {\n    apply_fn_to_primitive_ints!(from_sci_string_with_options_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::string::from_string::digit_from_display_byte;\nuse malachite_base::num::conversion::string::to_string::{\n    digit_to_display_byte_lower, digit_to_display_byte_upper,\n};\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_gen_var_10};\n\n#[test]\nfn test_digit_from_display_byte() {\n    let test_ok = |x, y| {\n        assert_eq!(digit_from_display_byte(x).unwrap(), y);\n    };\n    test_ok(b'0', 0);\n    test_ok(b'1', 1);\n    test_ok(b'2', 2);\n    test_ok(b'3', 3);\n    test_ok(b'4', 4);\n    test_ok(b'5', 5);\n    test_ok(b'6', 6);\n    test_ok(b'7', 7);\n    test_ok(b'8', 8);\n    test_ok(b'9', 9);\n    test_ok(b'a', 10);\n    test_ok(b'b', 11);\n    test_ok(b'c', 12);\n    test_ok(b'x', 33);\n    test_ok(b'y', 34);\n    test_ok(b'z', 35);\n    test_ok(b'A', 10);\n    test_ok(b'B', 11);\n    test_ok(b'C', 12);\n    test_ok(b'X', 33);\n    test_ok(b'Y', 34);\n    test_ok(b'Z', 35);\n\n    let test_err = |x| {\n        assert!(digit_from_display_byte(x).is_none());\n    };\n    test_err(b' ');\n    test_err(b'!');\n}\n\n#[test]\nfn digit_from_display_byte_properties() {\n    unsigned_gen().test_properties(|b| {\n        assert_eq!(\n            digit_from_display_byte(b).is_some(),\n            b.is_ascii_alphanumeric()\n        );\n    });\n\n    unsigned_gen_var_10().test_properties(|b| {\n        let digit = digit_from_display_byte(b).unwrap();\n        assert!(b.is_ascii_alphanumeric());\n        // Both of the following conditions include numeric chars.\n        if !char::from(b).is_uppercase() {\n            assert_eq!(digit_to_display_byte_lower(digit), Some(b));\n        }\n        if !char::from(b).is_lowercase() {\n            assert_eq!(digit_to_display_byte_upper(digit), Some(b));\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/string/options/from_sci_string_options.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::{\n    from_sci_string_options_gen, from_sci_string_options_rounding_mode_pair_gen,\n    from_sci_string_options_unsigned_pair_gen_var_1,\n};\n\n#[test]\nfn from_sci_string_options_properties() {\n    from_sci_string_options_gen().test_properties(|options| {\n        let mut options_alt = options;\n\n        let base = options.get_base();\n        assert!(base >= 2);\n        assert!(base <= 36);\n        options_alt.set_base(base);\n        assert_eq!(options_alt, options);\n\n        let rounding_mode = options.get_rounding_mode();\n        options_alt.set_rounding_mode(rounding_mode);\n        assert_eq!(options_alt, options);\n    });\n\n    from_sci_string_options_unsigned_pair_gen_var_1().test_properties(|(mut options, base)| {\n        let old_options = options;\n        let old_base = options.get_base();\n        options.set_base(base);\n        assert_eq!(options.get_base(), base);\n        options.set_base(old_base);\n        assert_eq!(options, old_options);\n    });\n\n    from_sci_string_options_rounding_mode_pair_gen().test_properties(|(mut options, rm)| {\n        let old_options = options;\n        let old_rm = options.get_rounding_mode();\n        options.set_rounding_mode(rm);\n        assert_eq!(options.get_rounding_mode(), rm);\n        options.set_rounding_mode(old_rm);\n        assert_eq!(options, old_options);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/string/options/to_sci_options.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::string::options::SciSizeOptions;\nuse malachite_base::test_util::generators::{\n    to_sci_options_bool_pair_gen, to_sci_options_gen, to_sci_options_rounding_mode_pair_gen,\n    to_sci_options_signed_pair_gen_var_1, to_sci_options_unsigned_pair_gen_var_1,\n    to_sci_options_unsigned_pair_gen_var_2, to_sci_options_unsigned_pair_gen_var_3,\n};\n\n#[test]\nfn to_sci_options_properties() {\n    to_sci_options_gen().test_properties(|options| {\n        let mut options_alt = options;\n\n        let base = options.get_base();\n        assert!(base >= 2);\n        assert!(base <= 36);\n        options_alt.set_base(base);\n        assert_eq!(options_alt, options);\n\n        let rounding_mode = options.get_rounding_mode();\n        options_alt.set_rounding_mode(rounding_mode);\n        assert_eq!(options_alt, options);\n\n        let size_options = options.get_size_options();\n        match size_options {\n            SciSizeOptions::Complete => options_alt.set_size_complete(),\n            SciSizeOptions::Precision(p) => options_alt.set_precision(p),\n            SciSizeOptions::Scale(s) => options_alt.set_scale(s),\n        }\n        assert_eq!(options_alt, options);\n\n        let neg_exp_threshold = options.get_neg_exp_threshold();\n        assert!(neg_exp_threshold < 0);\n        options_alt.set_neg_exp_threshold(neg_exp_threshold);\n        assert_eq!(options_alt, options);\n\n        let lowercase = options.get_lowercase();\n        if lowercase {\n            options_alt.set_lowercase();\n        } else {\n            options_alt.set_uppercase();\n        }\n        assert_eq!(options_alt, options);\n\n        let e_lowercase = options.get_e_lowercase();\n        if e_lowercase {\n            options_alt.set_e_lowercase();\n        } else {\n            options_alt.set_e_uppercase();\n        }\n        assert_eq!(options_alt, options);\n\n        let force_exponent_plus_sign = options.get_force_exponent_plus_sign();\n        options_alt.set_force_exponent_plus_sign(force_exponent_plus_sign);\n        assert_eq!(options_alt, options);\n\n        let include_trailing_zeros = options.get_include_trailing_zeros();\n        options_alt.set_include_trailing_zeros(include_trailing_zeros);\n        assert_eq!(options_alt, options);\n\n        let mut options = options;\n        let old_options = options;\n        let old_lowercase = options.get_lowercase();\n        options.set_lowercase();\n        assert!(options.get_lowercase());\n        if old_lowercase {\n            options.set_lowercase();\n        } else {\n            options.set_uppercase();\n        }\n        assert_eq!(options, old_options);\n\n        let old_lowercase = options.get_lowercase();\n        options.set_uppercase();\n        assert!(!options.get_lowercase());\n        if old_lowercase {\n            options.set_lowercase();\n        } else {\n            options.set_uppercase();\n        }\n        assert_eq!(options, old_options);\n\n        let old_e_lowercase = options.get_e_lowercase();\n        options.set_e_lowercase();\n        assert!(options.get_e_lowercase());\n        if old_e_lowercase {\n            options.set_e_lowercase();\n        } else {\n            options.set_e_uppercase();\n        }\n        assert_eq!(options, old_options);\n\n        let old_e_lowercase = options.get_e_lowercase();\n        options.set_e_uppercase();\n        assert!(!options.get_e_lowercase());\n        if old_e_lowercase {\n            options.set_e_lowercase();\n        } else {\n            options.set_e_uppercase();\n        }\n        assert_eq!(options, old_options);\n    });\n\n    to_sci_options_unsigned_pair_gen_var_1().test_properties(|(mut options, base)| {\n        let old_options = options;\n        let old_base = options.get_base();\n        options.set_base(base);\n        assert_eq!(options.get_base(), base);\n        options.set_base(old_base);\n        assert_eq!(options, old_options);\n    });\n\n    to_sci_options_rounding_mode_pair_gen().test_properties(|(mut options, rm)| {\n        let old_options = options;\n        let old_rm = options.get_rounding_mode();\n        options.set_rounding_mode(rm);\n        assert_eq!(options.get_rounding_mode(), rm);\n        options.set_rounding_mode(old_rm);\n        assert_eq!(options, old_options);\n    });\n\n    to_sci_options_gen().test_properties(|mut options| {\n        let old_options = options;\n        let old_size_options = options.get_size_options();\n        options.set_size_complete();\n        assert_eq!(options.get_size_options(), SciSizeOptions::Complete);\n        match old_size_options {\n            SciSizeOptions::Complete => options.set_size_complete(),\n            SciSizeOptions::Precision(p) => options.set_precision(p),\n            SciSizeOptions::Scale(s) => options.set_scale(s),\n        }\n        assert_eq!(options, old_options);\n    });\n\n    to_sci_options_unsigned_pair_gen_var_3().test_properties(|(mut options, precision)| {\n        let old_options = options;\n        let old_size_options = options.get_size_options();\n        options.set_precision(precision);\n        assert_eq!(\n            options.get_size_options(),\n            SciSizeOptions::Precision(precision)\n        );\n        match old_size_options {\n            SciSizeOptions::Complete => options.set_size_complete(),\n            SciSizeOptions::Precision(p) => options.set_precision(p),\n            SciSizeOptions::Scale(s) => options.set_scale(s),\n        }\n        assert_eq!(options, old_options);\n    });\n\n    to_sci_options_unsigned_pair_gen_var_2().test_properties(|(mut options, scale)| {\n        let old_options = options;\n        let old_size_options = options.get_size_options();\n        options.set_scale(scale);\n        assert_eq!(options.get_size_options(), SciSizeOptions::Scale(scale));\n        match old_size_options {\n            SciSizeOptions::Complete => options.set_size_complete(),\n            SciSizeOptions::Precision(p) => options.set_precision(p),\n            SciSizeOptions::Scale(s) => options.set_scale(s),\n        }\n        assert_eq!(options, old_options);\n    });\n\n    to_sci_options_signed_pair_gen_var_1().test_properties(|(mut options, neg_exp_threshold)| {\n        let old_options = options;\n        let old_neg_exp_threshold = options.get_neg_exp_threshold();\n        options.set_neg_exp_threshold(neg_exp_threshold);\n        assert_eq!(options.get_neg_exp_threshold(), neg_exp_threshold);\n        options.set_neg_exp_threshold(old_neg_exp_threshold);\n        assert_eq!(options, old_options);\n    });\n\n    to_sci_options_bool_pair_gen().test_properties(|(mut options, b)| {\n        let old_options = options;\n        let old_force_exponent_plus_sign = options.get_force_exponent_plus_sign();\n        options.set_force_exponent_plus_sign(b);\n        assert_eq!(options.get_force_exponent_plus_sign(), b);\n        options.set_force_exponent_plus_sign(old_force_exponent_plus_sign);\n        assert_eq!(options, old_options);\n\n        let old_include_trailing_zeros = options.get_include_trailing_zeros();\n        options.set_include_trailing_zeros(b);\n        assert_eq!(options.get_include_trailing_zeros(), b);\n        options.set_include_trailing_zeros(old_include_trailing_zeros);\n        assert_eq!(options, old_options);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{FloorLogBase, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::options::{\n    FromSciStringOptions, SciSizeOptions, ToSciOptions,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_to_sci_options_pair_gen_var_1, unsigned_gen,\n    unsigned_to_sci_options_pair_gen_var_1,\n};\nuse malachite_base::test_util::num::conversion::string::from_sci_string::DECIMAL_SCI_STRING_CHARS;\nuse std::collections::HashMap;\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_to_sci() {\n    fn test<T: PrimitiveInt>(x: T, out: &str) {\n        assert_eq!(x.to_sci().to_string(), out);\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            out\n        );\n    }\n    test::<u8>(0, \"0\");\n    test::<u8>(1, \"1\");\n    test::<u8>(10, \"10\");\n    test::<u8>(100, \"100\");\n    test::<u16>(1000, \"1000\");\n    test::<u16>(10000, \"10000\");\n    test::<u32>(100000, \"100000\");\n    test::<u32>(1000000, \"1000000\");\n    test::<u32>(10000000, \"10000000\");\n    test::<u32>(100000000, \"100000000\");\n    test::<u32>(1000000000, \"1000000000\");\n    test::<u64>(10000000000, \"10000000000\");\n    test::<u64>(100000000000, \"100000000000\");\n    test::<u64>(1000000000000, \"1000000000000\");\n    test::<u64>(10000000000000, \"10000000000000\");\n    test::<u64>(100000000000000, \"100000000000000\");\n    test::<u64>(1000000000000000, \"1000000000000000\");\n    test::<u64>(10000000000000000, \"1e16\");\n    test::<u64>(100000000000000000, \"1e17\");\n    test::<u64>(u64::MAX, \"1.844674407370955e19\");\n    test::<u128>(u128::MAX, \"3.402823669209385e38\");\n\n    test::<u64>(999999999999999, \"999999999999999\");\n    test::<u64>(9999999999999999, \"9999999999999999\");\n    test::<u64>(99999999999999999, \"1e17\");\n    test::<u64>(999999999999999999, \"1e18\");\n\n    test::<i8>(0, \"0\");\n    test::<i8>(1, \"1\");\n    test::<i8>(10, \"10\");\n    test::<i8>(100, \"100\");\n    test::<i16>(1000, \"1000\");\n    test::<i16>(10000, \"10000\");\n    test::<i32>(100000, \"100000\");\n    test::<i32>(1000000, \"1000000\");\n    test::<i32>(10000000, \"10000000\");\n    test::<i32>(100000000, \"100000000\");\n    test::<i32>(1000000000, \"1000000000\");\n    test::<i64>(10000000000, \"10000000000\");\n    test::<i64>(100000000000, \"100000000000\");\n    test::<i64>(1000000000000, \"1000000000000\");\n    test::<i64>(10000000000000, \"10000000000000\");\n    test::<i64>(100000000000000, \"100000000000000\");\n    test::<i64>(1000000000000000, \"1000000000000000\");\n    test::<i64>(10000000000000000, \"1e16\");\n    test::<i64>(100000000000000000, \"1e17\");\n    test::<i64>(i64::MAX, \"9.223372036854776e18\");\n    test::<i128>(i128::MAX, \"1.701411834604692e38\");\n    test::<i8>(-1, \"-1\");\n    test::<i8>(-10, \"-10\");\n    test::<i8>(-100, \"-100\");\n    test::<i16>(-1000, \"-1000\");\n    test::<i16>(-10000, \"-10000\");\n    test::<i32>(-100000, \"-100000\");\n    test::<i32>(-1000000, \"-1000000\");\n    test::<i32>(-10000000, \"-10000000\");\n    test::<i32>(-100000000, \"-100000000\");\n    test::<i32>(-1000000000, \"-1000000000\");\n    test::<i64>(-10000000000, \"-10000000000\");\n    test::<i64>(-100000000000, \"-100000000000\");\n    test::<i64>(-1000000000000, \"-1000000000000\");\n    test::<i64>(-10000000000000, \"-10000000000000\");\n    test::<i64>(-100000000000000, \"-100000000000000\");\n    test::<i64>(-1000000000000000, \"-1000000000000000\");\n    test::<i64>(-10000000000000000, \"-1e16\");\n    test::<i64>(-100000000000000000, \"-1e17\");\n    test::<i64>(i64::MIN, \"-9.223372036854776e18\");\n    test::<i128>(i128::MIN, \"-1.701411834604692e38\");\n\n    test::<i64>(999999999999999, \"999999999999999\");\n    test::<i64>(9999999999999999, \"9999999999999999\");\n    test::<i64>(99999999999999999, \"1e17\");\n    test::<i64>(999999999999999999, \"1e18\");\n}\n\n#[test]\npub fn test_to_sci_with_options() {\n    fn test<T: PrimitiveInt>(x: T, options: ToSciOptions, out: &str) {\n        assert_eq!(x.to_sci_with_options(options).to_string(), out);\n    }\n    // For tests with the default options, see `test_to_sci`\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    test::<u8>(0, options, \"0.000000000000000\");\n    test::<u8>(1, options, \"1.000000000000000\");\n    test::<u8>(10, options, \"10.00000000000000\");\n    test::<u8>(100, options, \"100.0000000000000\");\n    test::<u16>(1000, options, \"1000.000000000000\");\n    test::<u16>(10000, options, \"10000.00000000000\");\n    test::<u32>(100000, options, \"100000.0000000000\");\n    test::<u32>(1000000, options, \"1000000.000000000\");\n    test::<u32>(10000000, options, \"10000000.00000000\");\n    test::<u32>(100000000, options, \"100000000.0000000\");\n    test::<u32>(1000000000, options, \"1000000000.000000\");\n    test::<u64>(10000000000, options, \"10000000000.00000\");\n    test::<u64>(100000000000, options, \"100000000000.0000\");\n    test::<u64>(1000000000000, options, \"1000000000000.000\");\n    test::<u64>(10000000000000, options, \"10000000000000.00\");\n    test::<u64>(100000000000000, options, \"100000000000000.0\");\n    test::<u64>(1000000000000000, options, \"1000000000000000\");\n    test::<u64>(10000000000000000, options, \"1.000000000000000e16\");\n    test::<u64>(100000000000000000, options, \"1.000000000000000e17\");\n    test::<u64>(u64::MAX, options, \"1.844674407370955e19\");\n    test::<u128>(u128::MAX, options, \"3.402823669209385e38\");\n\n    test::<u64>(999999999999999, options, \"999999999999999.0\");\n    test::<u64>(9999999999999999, options, \"9999999999999999\");\n    test::<u64>(99999999999999999, options, \"1.000000000000000e17\");\n    test::<u64>(999999999999999999, options, \"1.000000000000000e18\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test::<u128>(u128::MAX, options, \"1e128\");\n    options.set_base(3);\n    test::<u128>(u128::MAX, options, \"2.022011021210021e80\");\n    options.set_base(4);\n    test::<u128>(u128::MAX, options, \"1e64\");\n    options.set_base(5);\n    test::<u128>(u128::MAX, options, \"1.103111044120131e55\");\n    options.set_base(8);\n    test::<u128>(u128::MAX, options, \"4e42\");\n    // When base >= 15, there is a mandatory sign after the exponent indicator \"e\", to distinguish\n    // it from the digit \"e\"\n    options.set_base(16);\n    test::<u128>(u128::MAX, options, \"1e+32\");\n    options.set_base(32);\n    test::<u128>(u128::MAX, options, \"8e+25\");\n    options.set_base(36);\n    test::<u128>(u128::MAX, options, \"f.5lxx1zz5pnorynqe+24\");\n\n    // The sign can be forced in other cases too\n    options.set_base(3);\n    options.set_force_exponent_plus_sign(true);\n    test::<u128>(u128::MAX, options, \"2.022011021210021e+80\");\n\n    // The digits can be uppercase, and so can the exponent indicator\n    options = ToSciOptions::default();\n    options.set_base(36);\n    options.set_uppercase();\n    test::<u128>(u128::MAX, options, \"F.5LXX1ZZ5PNORYNQe+24\");\n\n    options.set_lowercase();\n    options.set_e_uppercase();\n    test::<u128>(u128::MAX, options, \"f.5lxx1zz5pnorynqE+24\");\n\n    options.set_uppercase();\n    test::<u128>(u128::MAX, options, \"F.5LXX1ZZ5PNORYNQE+24\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    options.set_base(2);\n    test::<u128>(\n        u128::MAX,\n        options,\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n    );\n    options.set_base(3);\n    test::<u128>(\n        u128::MAX,\n        options,\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n    );\n    options.set_base(4);\n    test::<u128>(\n        u128::MAX,\n        options,\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n    );\n    options.set_base(5);\n    test::<u128>(\n        u128::MAX,\n        options,\n        \"11031110441201303134210404233413032443021130230130231310\",\n    );\n    options.set_base(8);\n    test::<u128>(\n        u128::MAX,\n        options,\n        \"3777777777777777777777777777777777777777777\",\n    );\n    options.set_base(16);\n    test::<u128>(u128::MAX, options, \"ffffffffffffffffffffffffffffffff\");\n    options.set_base(32);\n    test::<u128>(u128::MAX, options, \"7vvvvvvvvvvvvvvvvvvvvvvvvv\");\n    options.set_base(36);\n    test::<u128>(u128::MAX, options, \"f5lxx1zz5pnorynqglhzmsp33\");\n\n    options = ToSciOptions::default();\n    options.set_precision(4);\n    options.set_include_trailing_zeros(true);\n    test::<u8>(0, options, \"0.000\");\n    test::<u8>(1, options, \"1.000\");\n    test::<u8>(10, options, \"10.00\");\n    test::<u8>(100, options, \"100.0\");\n    test::<u16>(1000, options, \"1000\");\n    test::<u16>(10000, options, \"1.000e4\");\n    test::<u8>(9, options, \"9.000\");\n    test::<u8>(99, options, \"99.00\");\n    test::<u16>(999, options, \"999.0\");\n    test::<u16>(9999, options, \"9999\");\n    test::<u32>(99999, options, \"1.000e5\");\n\n    options.set_include_trailing_zeros(false);\n    test::<u8>(0, options, \"0\");\n    test::<u8>(1, options, \"1\");\n    test::<u8>(10, options, \"10\");\n    test::<u8>(100, options, \"100\");\n    test::<u16>(1000, options, \"1000\");\n    test::<u16>(10000, options, \"1e4\");\n    test::<u8>(9, options, \"9\");\n    test::<u8>(99, options, \"99\");\n    test::<u16>(999, options, \"999\");\n    test::<u16>(9999, options, \"9999\");\n    test::<u32>(99999, options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_precision(1);\n    options.set_include_trailing_zeros(true); // doesn't matter when precision is 1\n    test::<u8>(0, options, \"0\");\n    test::<u8>(1, options, \"1\");\n    test::<u8>(10, options, \"1e1\");\n    test::<u8>(100, options, \"1e2\");\n    test::<u16>(1000, options, \"1e3\");\n    test::<u16>(10000, options, \"1e4\");\n    test::<u8>(9, options, \"9\");\n    test::<u8>(99, options, \"1e2\");\n    test::<u16>(999, options, \"1e3\");\n    test::<u16>(9999, options, \"1e4\");\n    test::<u32>(99999, options, \"1e5\");\n\n    options.set_include_trailing_zeros(false);\n    test::<u8>(0, options, \"0\");\n    test::<u8>(1, options, \"1\");\n    test::<u8>(10, options, \"1e1\");\n    test::<u8>(100, options, \"1e2\");\n    test::<u16>(1000, options, \"1e3\");\n    test::<u16>(10000, options, \"1e4\");\n    test::<u8>(9, options, \"9\");\n    test::<u8>(99, options, \"1e2\");\n    test::<u16>(999, options, \"1e3\");\n    test::<u16>(9999, options, \"1e4\");\n    test::<u32>(99999, options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    options.set_include_trailing_zeros(true);\n    test::<u8>(0, options, \"0.00\");\n    test::<u8>(1, options, \"1.00\");\n    test::<u8>(10, options, \"10.00\");\n    test::<u8>(100, options, \"100.00\");\n    test::<u16>(1000, options, \"1000.00\");\n    test::<u16>(10000, options, \"10000.00\");\n    test::<u8>(9, options, \"9.00\");\n    test::<u8>(99, options, \"99.00\");\n    test::<u16>(999, options, \"999.00\");\n    test::<u16>(9999, options, \"9999.00\");\n    test::<u32>(99999, options, \"99999.00\");\n\n    options.set_include_trailing_zeros(false);\n    test::<u8>(0, options, \"0\");\n    test::<u8>(1, options, \"1\");\n    test::<u8>(10, options, \"10\");\n    test::<u8>(100, options, \"100\");\n    test::<u16>(1000, options, \"1000\");\n    test::<u16>(10000, options, \"10000\");\n    test::<u8>(9, options, \"9\");\n    test::<u8>(99, options, \"99\");\n    test::<u16>(999, options, \"999\");\n    test::<u16>(9999, options, \"9999\");\n    test::<u32>(99999, options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_scale(0);\n    options.set_include_trailing_zeros(true); // doesn't matter when scale is 0\n    test::<u8>(0, options, \"0\");\n    test::<u8>(1, options, \"1\");\n    test::<u8>(10, options, \"10\");\n    test::<u8>(100, options, \"100\");\n    test::<u16>(1000, options, \"1000\");\n    test::<u16>(10000, options, \"10000\");\n    test::<u8>(9, options, \"9\");\n    test::<u8>(99, options, \"99\");\n    test::<u16>(999, options, \"999\");\n    test::<u16>(9999, options, \"9999\");\n    test::<u32>(99999, options, \"99999\");\n\n    options.set_include_trailing_zeros(false);\n    test::<u8>(0, options, \"0\");\n    test::<u8>(1, options, \"1\");\n    test::<u8>(10, options, \"10\");\n    test::<u8>(100, options, \"100\");\n    test::<u16>(1000, options, \"1000\");\n    test::<u16>(10000, options, \"10000\");\n    test::<u8>(9, options, \"9\");\n    test::<u8>(99, options, \"99\");\n    test::<u16>(999, options, \"999\");\n    test::<u16>(9999, options, \"9999\");\n    test::<u32>(99999, options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_precision(2);\n    options.set_rounding_mode(Nearest); // This is the default\n    test::<u8>(123, options, \"1.2e2\");\n    options.set_rounding_mode(Down);\n    test::<u8>(123, options, \"1.2e2\");\n    options.set_rounding_mode(Floor);\n    test::<u8>(123, options, \"1.2e2\");\n    options.set_rounding_mode(Up);\n    test::<u8>(123, options, \"1.3e2\");\n    options.set_rounding_mode(Ceiling);\n    test::<u8>(123, options, \"1.3e2\");\n\n    options.set_rounding_mode(Nearest);\n    test::<u8>(135, options, \"1.4e2\");\n    options.set_rounding_mode(Down);\n    test::<u8>(135, options, \"1.3e2\");\n    options.set_rounding_mode(Floor);\n    test::<u8>(135, options, \"1.3e2\");\n    options.set_rounding_mode(Up);\n    test::<u8>(135, options, \"1.4e2\");\n    options.set_rounding_mode(Ceiling);\n    test::<u8>(135, options, \"1.4e2\");\n\n    options.set_rounding_mode(Exact);\n    test::<u8>(140, options, \"1.4e2\");\n\n    options.set_rounding_mode(Nearest);\n    test::<u16>(999, options, \"1e3\");\n    options.set_rounding_mode(Down);\n    test::<u16>(999, options, \"9.9e2\");\n    options.set_rounding_mode(Floor);\n    test::<u16>(999, options, \"9.9e2\");\n    options.set_rounding_mode(Up);\n    test::<u16>(999, options, \"1e3\");\n    options.set_rounding_mode(Ceiling);\n    test::<u16>(999, options, \"1e3\");\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    test::<i8>(0, options, \"0.000000000000000\");\n    test::<i8>(1, options, \"1.000000000000000\");\n    test::<i8>(10, options, \"10.00000000000000\");\n    test::<i8>(100, options, \"100.0000000000000\");\n    test::<i16>(1000, options, \"1000.000000000000\");\n    test::<i16>(10000, options, \"10000.00000000000\");\n    test::<i32>(100000, options, \"100000.0000000000\");\n    test::<i32>(1000000, options, \"1000000.000000000\");\n    test::<i32>(10000000, options, \"10000000.00000000\");\n    test::<i32>(100000000, options, \"100000000.0000000\");\n    test::<i32>(1000000000, options, \"1000000000.000000\");\n    test::<i64>(10000000000, options, \"10000000000.00000\");\n    test::<i64>(100000000000, options, \"100000000000.0000\");\n    test::<i64>(1000000000000, options, \"1000000000000.000\");\n    test::<i64>(10000000000000, options, \"10000000000000.00\");\n    test::<i64>(100000000000000, options, \"100000000000000.0\");\n    test::<i64>(1000000000000000, options, \"1000000000000000\");\n    test::<i64>(10000000000000000, options, \"1.000000000000000e16\");\n    test::<i64>(100000000000000000, options, \"1.000000000000000e17\");\n    test::<i64>(i64::MAX, options, \"9.223372036854776e18\");\n    test::<i128>(i128::MAX, options, \"1.701411834604692e38\");\n    test::<i8>(-1, options, \"-1.000000000000000\");\n    test::<i8>(-10, options, \"-10.00000000000000\");\n    test::<i8>(-100, options, \"-100.0000000000000\");\n    test::<i16>(-1000, options, \"-1000.000000000000\");\n    test::<i16>(-10000, options, \"-10000.00000000000\");\n    test::<i32>(-100000, options, \"-100000.0000000000\");\n    test::<i32>(-1000000, options, \"-1000000.000000000\");\n    test::<i32>(-10000000, options, \"-10000000.00000000\");\n    test::<i32>(-100000000, options, \"-100000000.0000000\");\n    test::<i32>(-1000000000, options, \"-1000000000.000000\");\n    test::<i64>(-10000000000, options, \"-10000000000.00000\");\n    test::<i64>(-100000000000, options, \"-100000000000.0000\");\n    test::<i64>(-1000000000000, options, \"-1000000000000.000\");\n    test::<i64>(-10000000000000, options, \"-10000000000000.00\");\n    test::<i64>(-100000000000000, options, \"-100000000000000.0\");\n    test::<i64>(-1000000000000000, options, \"-1000000000000000\");\n    test::<i64>(-10000000000000000, options, \"-1.000000000000000e16\");\n    test::<i64>(-100000000000000000, options, \"-1.000000000000000e17\");\n    test::<i64>(i64::MIN, options, \"-9.223372036854776e18\");\n    test::<i128>(i128::MIN, options, \"-1.701411834604692e38\");\n\n    test::<i64>(999999999999999, options, \"999999999999999.0\");\n    test::<i64>(9999999999999999, options, \"9999999999999999\");\n    test::<i64>(99999999999999999, options, \"1.000000000000000e17\");\n    test::<i64>(999999999999999999, options, \"1.000000000000000e18\");\n    test::<i64>(-999999999999999, options, \"-999999999999999.0\");\n    test::<i64>(-9999999999999999, options, \"-9999999999999999\");\n    test::<i64>(-99999999999999999, options, \"-1.000000000000000e17\");\n    test::<i64>(-999999999999999999, options, \"-1.000000000000000e18\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test::<i128>(i128::MAX, options, \"1e127\");\n    test::<i128>(i128::MIN, options, \"-1e127\");\n    options.set_base(3);\n    test::<i128>(i128::MAX, options, \"1.01100201022001e80\");\n    test::<i128>(i128::MIN, options, \"-1.01100201022001e80\");\n    options.set_base(4);\n    test::<i128>(i128::MAX, options, \"2e63\");\n    test::<i128>(i128::MIN, options, \"-2e63\");\n    options.set_base(5);\n    test::<i128>(i128::MAX, options, \"3.013030220323124e54\");\n    test::<i128>(i128::MIN, options, \"-3.013030220323124e54\");\n    options.set_base(8);\n    test::<i128>(i128::MAX, options, \"2e42\");\n    test::<i128>(i128::MIN, options, \"-2e42\");\n    // When base >= 15, there is a mandatory sign after the exponent indicator \"e\", to distinguish\n    // it from the digit \"e\"\n    options.set_base(16);\n    test::<i128>(i128::MAX, options, \"8e+31\");\n    test::<i128>(i128::MIN, options, \"-8e+31\");\n    options.set_base(32);\n    test::<i128>(i128::MAX, options, \"4e+25\");\n    test::<i128>(i128::MIN, options, \"-4e+25\");\n    options.set_base(36);\n    test::<i128>(i128::MAX, options, \"7.ksyyizzkutudzbve+24\");\n    test::<i128>(i128::MIN, options, \"-7.ksyyizzkutudzbve+24\");\n\n    // The sign can be forced in other cases too\n    options.set_base(3);\n    options.set_force_exponent_plus_sign(true);\n    test::<i128>(i128::MAX, options, \"1.01100201022001e+80\");\n    test::<i128>(i128::MIN, options, \"-1.01100201022001e+80\");\n\n    // The digits can be uppercase, and so can the exponent indicator\n    options = ToSciOptions::default();\n    options.set_base(36);\n    options.set_uppercase();\n    test::<i128>(i128::MAX, options, \"7.KSYYIZZKUTUDZBVe+24\");\n    test::<i128>(i128::MIN, options, \"-7.KSYYIZZKUTUDZBVe+24\");\n\n    options.set_lowercase();\n    options.set_e_uppercase();\n    test::<i128>(i128::MAX, options, \"7.ksyyizzkutudzbvE+24\");\n    test::<i128>(i128::MIN, options, \"-7.ksyyizzkutudzbvE+24\");\n\n    options.set_uppercase();\n    test::<i128>(i128::MAX, options, \"7.KSYYIZZKUTUDZBVE+24\");\n    test::<i128>(i128::MIN, options, \"-7.KSYYIZZKUTUDZBVE+24\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    options.set_base(2);\n    test::<i128>(\n        i128::MAX,\n        options,\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n    );\n    test::<i128>(\n        i128::MIN,\n        options,\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n    );\n    options.set_base(3);\n    test::<i128>(\n        i128::MAX,\n        options,\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n    );\n    test::<i128>(\n        i128::MIN,\n        options,\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n    );\n    options.set_base(4);\n    test::<i128>(\n        i128::MAX,\n        options,\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n    );\n    test::<i128>(\n        i128::MIN,\n        options,\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n    );\n    options.set_base(5);\n    test::<i128>(\n        i128::MAX,\n        options,\n        \"3013030220323124042102424341431241221233040112312340402\",\n    );\n    test::<i128>(\n        i128::MIN,\n        options,\n        \"-3013030220323124042102424341431241221233040112312340403\",\n    );\n    options.set_base(8);\n    test::<i128>(\n        i128::MAX,\n        options,\n        \"1777777777777777777777777777777777777777777\",\n    );\n    test::<i128>(\n        i128::MIN,\n        options,\n        \"-2000000000000000000000000000000000000000000\",\n    );\n    options.set_base(16);\n    test::<i128>(i128::MAX, options, \"7fffffffffffffffffffffffffffffff\");\n    test::<i128>(i128::MIN, options, \"-80000000000000000000000000000000\");\n    options.set_base(32);\n    test::<i128>(i128::MAX, options, \"3vvvvvvvvvvvvvvvvvvvvvvvvv\");\n    test::<i128>(i128::MIN, options, \"-40000000000000000000000000\");\n    options.set_base(36);\n    test::<i128>(i128::MAX, options, \"7ksyyizzkutudzbv8aqztecjj\");\n    test::<i128>(i128::MIN, options, \"-7ksyyizzkutudzbv8aqztecjk\");\n\n    options = ToSciOptions::default();\n    options.set_precision(4);\n    options.set_include_trailing_zeros(true);\n    test::<i8>(0, options, \"0.000\");\n    test::<i8>(1, options, \"1.000\");\n    test::<i8>(10, options, \"10.00\");\n    test::<i8>(100, options, \"100.0\");\n    test::<i16>(1000, options, \"1000\");\n    test::<i16>(10000, options, \"1.000e4\");\n    test::<i8>(-1, options, \"-1.000\");\n    test::<i8>(-10, options, \"-10.00\");\n    test::<i8>(-100, options, \"-100.0\");\n    test::<i16>(-1000, options, \"-1000\");\n    test::<i16>(-10000, options, \"-1.000e4\");\n    test::<i8>(9, options, \"9.000\");\n    test::<i8>(99, options, \"99.00\");\n    test::<i16>(999, options, \"999.0\");\n    test::<i16>(9999, options, \"9999\");\n    test::<i32>(99999, options, \"1.000e5\");\n    test::<i8>(-9, options, \"-9.000\");\n    test::<i8>(-99, options, \"-99.00\");\n    test::<i16>(-999, options, \"-999.0\");\n    test::<i16>(-9999, options, \"-9999\");\n    test::<i32>(-99999, options, \"-1.000e5\");\n\n    options.set_include_trailing_zeros(false);\n    test::<i8>(0, options, \"0\");\n    test::<i8>(1, options, \"1\");\n    test::<i8>(10, options, \"10\");\n    test::<i8>(100, options, \"100\");\n    test::<i16>(1000, options, \"1000\");\n    test::<i16>(10000, options, \"1e4\");\n    test::<i8>(-1, options, \"-1\");\n    test::<i8>(-10, options, \"-10\");\n    test::<i8>(-100, options, \"-100\");\n    test::<i16>(-1000, options, \"-1000\");\n    test::<i16>(-10000, options, \"-1e4\");\n    test::<i8>(9, options, \"9\");\n    test::<i8>(99, options, \"99\");\n    test::<i16>(999, options, \"999\");\n    test::<i16>(9999, options, \"9999\");\n    test::<i32>(99999, options, \"1e5\");\n    test::<i8>(-9, options, \"-9\");\n    test::<i8>(-99, options, \"-99\");\n    test::<i16>(-999, options, \"-999\");\n    test::<i16>(-9999, options, \"-9999\");\n    test::<i32>(-99999, options, \"-1e5\");\n\n    options = ToSciOptions::default();\n    options.set_precision(1);\n    options.set_include_trailing_zeros(true); // doesn't matter when precision is 1\n    test::<i8>(0, options, \"0\");\n    test::<i8>(1, options, \"1\");\n    test::<i8>(10, options, \"1e1\");\n    test::<i8>(100, options, \"1e2\");\n    test::<i16>(1000, options, \"1e3\");\n    test::<i16>(10000, options, \"1e4\");\n    test::<i8>(-1, options, \"-1\");\n    test::<i8>(-10, options, \"-1e1\");\n    test::<i8>(-100, options, \"-1e2\");\n    test::<i16>(-1000, options, \"-1e3\");\n    test::<i16>(-10000, options, \"-1e4\");\n    test::<i8>(9, options, \"9\");\n    test::<i8>(99, options, \"1e2\");\n    test::<i16>(999, options, \"1e3\");\n    test::<i16>(9999, options, \"1e4\");\n    test::<i32>(99999, options, \"1e5\");\n    test::<i8>(-9, options, \"-9\");\n    test::<i8>(-99, options, \"-1e2\");\n    test::<i16>(-999, options, \"-1e3\");\n    test::<i16>(-9999, options, \"-1e4\");\n    test::<i32>(-99999, options, \"-1e5\");\n\n    options.set_include_trailing_zeros(false);\n    test::<i8>(0, options, \"0\");\n    test::<i8>(1, options, \"1\");\n    test::<i8>(10, options, \"1e1\");\n    test::<i8>(100, options, \"1e2\");\n    test::<i16>(1000, options, \"1e3\");\n    test::<i16>(10000, options, \"1e4\");\n    test::<i8>(-1, options, \"-1\");\n    test::<i8>(-10, options, \"-1e1\");\n    test::<i8>(-100, options, \"-1e2\");\n    test::<i16>(-1000, options, \"-1e3\");\n    test::<i16>(-10000, options, \"-1e4\");\n    test::<i8>(9, options, \"9\");\n    test::<i8>(99, options, \"1e2\");\n    test::<i16>(999, options, \"1e3\");\n    test::<i16>(9999, options, \"1e4\");\n    test::<i32>(99999, options, \"1e5\");\n    test::<i8>(-9, options, \"-9\");\n    test::<i8>(-99, options, \"-1e2\");\n    test::<i16>(-999, options, \"-1e3\");\n    test::<i16>(-9999, options, \"-1e4\");\n    test::<i32>(-99999, options, \"-1e5\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    options.set_include_trailing_zeros(true);\n    test::<i8>(0, options, \"0.00\");\n    test::<i8>(1, options, \"1.00\");\n    test::<i8>(10, options, \"10.00\");\n    test::<i8>(100, options, \"100.00\");\n    test::<i16>(1000, options, \"1000.00\");\n    test::<i16>(10000, options, \"10000.00\");\n    test::<i8>(-1, options, \"-1.00\");\n    test::<i8>(-10, options, \"-10.00\");\n    test::<i8>(-100, options, \"-100.00\");\n    test::<i16>(-1000, options, \"-1000.00\");\n    test::<i16>(-10000, options, \"-10000.00\");\n    test::<i8>(9, options, \"9.00\");\n    test::<i8>(99, options, \"99.00\");\n    test::<i16>(999, options, \"999.00\");\n    test::<i16>(9999, options, \"9999.00\");\n    test::<i32>(99999, options, \"99999.00\");\n    test::<i8>(-9, options, \"-9.00\");\n    test::<i8>(-99, options, \"-99.00\");\n    test::<i16>(-999, options, \"-999.00\");\n    test::<i16>(-9999, options, \"-9999.00\");\n    test::<i32>(-99999, options, \"-99999.00\");\n\n    options.set_include_trailing_zeros(false);\n    test::<i8>(0, options, \"0\");\n    test::<i8>(1, options, \"1\");\n    test::<i8>(10, options, \"10\");\n    test::<i8>(100, options, \"100\");\n    test::<i16>(1000, options, \"1000\");\n    test::<i16>(10000, options, \"10000\");\n    test::<i8>(-1, options, \"-1\");\n    test::<i8>(-10, options, \"-10\");\n    test::<i8>(-100, options, \"-100\");\n    test::<i16>(-1000, options, \"-1000\");\n    test::<i16>(-10000, options, \"-10000\");\n    test::<i8>(9, options, \"9\");\n    test::<i8>(99, options, \"99\");\n    test::<i16>(999, options, \"999\");\n    test::<i16>(9999, options, \"9999\");\n    test::<i32>(99999, options, \"99999\");\n    test::<i8>(-9, options, \"-9\");\n    test::<i8>(-99, options, \"-99\");\n    test::<i16>(-999, options, \"-999\");\n    test::<i16>(-9999, options, \"-9999\");\n    test::<i32>(-99999, options, \"-99999\");\n\n    options = ToSciOptions::default();\n    options.set_scale(0);\n    options.set_include_trailing_zeros(true); // doesn't matter when scale is 0\n    test::<i8>(0, options, \"0\");\n    test::<i8>(1, options, \"1\");\n    test::<i8>(10, options, \"10\");\n    test::<i8>(100, options, \"100\");\n    test::<i16>(1000, options, \"1000\");\n    test::<i16>(10000, options, \"10000\");\n    test::<i8>(-1, options, \"-1\");\n    test::<i8>(-10, options, \"-10\");\n    test::<i8>(-100, options, \"-100\");\n    test::<i16>(-1000, options, \"-1000\");\n    test::<i16>(-10000, options, \"-10000\");\n    test::<i8>(9, options, \"9\");\n    test::<i8>(99, options, \"99\");\n    test::<i16>(999, options, \"999\");\n    test::<i16>(9999, options, \"9999\");\n    test::<i32>(99999, options, \"99999\");\n    test::<i8>(-9, options, \"-9\");\n    test::<i8>(-99, options, \"-99\");\n    test::<i16>(-999, options, \"-999\");\n    test::<i16>(-9999, options, \"-9999\");\n    test::<i32>(-99999, options, \"-99999\");\n\n    options.set_include_trailing_zeros(false);\n    test::<i8>(0, options, \"0\");\n    test::<i8>(1, options, \"1\");\n    test::<i8>(10, options, \"10\");\n    test::<i8>(100, options, \"100\");\n    test::<i16>(1000, options, \"1000\");\n    test::<i16>(10000, options, \"10000\");\n    test::<i8>(-1, options, \"-1\");\n    test::<i8>(-10, options, \"-10\");\n    test::<i8>(-100, options, \"-100\");\n    test::<i16>(-1000, options, \"-1000\");\n    test::<i16>(-10000, options, \"-10000\");\n    test::<i8>(9, options, \"9\");\n    test::<i8>(99, options, \"99\");\n    test::<i16>(999, options, \"999\");\n    test::<i16>(9999, options, \"9999\");\n    test::<i32>(99999, options, \"99999\");\n    test::<i8>(-9, options, \"-9\");\n    test::<i8>(-99, options, \"-99\");\n    test::<i16>(-999, options, \"-999\");\n    test::<i16>(-9999, options, \"-9999\");\n    test::<i32>(-99999, options, \"-99999\");\n\n    options = ToSciOptions::default();\n    options.set_precision(2);\n    options.set_rounding_mode(Nearest); // This is the default\n    test::<i8>(123, options, \"1.2e2\");\n    test::<i8>(-123, options, \"-1.2e2\");\n    options.set_rounding_mode(Down);\n    test::<i8>(123, options, \"1.2e2\");\n    test::<i8>(-123, options, \"-1.2e2\");\n    options.set_rounding_mode(Floor);\n    test::<i8>(123, options, \"1.2e2\");\n    test::<i8>(-123, options, \"-1.3e2\");\n    options.set_rounding_mode(Up);\n    test::<i8>(123, options, \"1.3e2\");\n    test::<i8>(-123, options, \"-1.3e2\");\n    options.set_rounding_mode(Ceiling);\n    test::<i8>(123, options, \"1.3e2\");\n    test::<i8>(-123, options, \"-1.2e2\");\n\n    options.set_rounding_mode(Nearest);\n    test::<i16>(135, options, \"1.4e2\");\n    test::<i16>(-135, options, \"-1.4e2\");\n    options.set_rounding_mode(Down);\n    test::<i16>(135, options, \"1.3e2\");\n    test::<i16>(-135, options, \"-1.3e2\");\n    options.set_rounding_mode(Floor);\n    test::<i16>(135, options, \"1.3e2\");\n    test::<i16>(-135, options, \"-1.4e2\");\n    options.set_rounding_mode(Up);\n    test::<i16>(135, options, \"1.4e2\");\n    test::<i16>(-135, options, \"-1.4e2\");\n    options.set_rounding_mode(Ceiling);\n    test::<i16>(135, options, \"1.4e2\");\n    test::<i16>(-135, options, \"-1.3e2\");\n\n    options.set_rounding_mode(Exact);\n    test::<i16>(140, options, \"1.4e2\");\n    test::<i16>(-140, options, \"-1.4e2\");\n\n    options.set_rounding_mode(Nearest);\n    test::<i16>(999, options, \"1e3\");\n    test::<i16>(-999, options, \"-1e3\");\n    options.set_rounding_mode(Down);\n    test::<i16>(999, options, \"9.9e2\");\n    test::<i16>(-999, options, \"-9.9e2\");\n    options.set_rounding_mode(Floor);\n    test::<i16>(999, options, \"9.9e2\");\n    test::<i16>(-999, options, \"-1e3\");\n    options.set_rounding_mode(Up);\n    test::<i16>(999, options, \"1e3\");\n    test::<i16>(-999, options, \"-1e3\");\n    options.set_rounding_mode(Ceiling);\n    test::<i16>(999, options, \"1e3\");\n    test::<i16>(-999, options, \"-9.9e2\");\n}\n\nfn to_sci_with_options_fail_helper<T: PrimitiveInt>() {\n    assert_panic!({\n        let mut options = ToSciOptions::default();\n        options.set_rounding_mode(Exact);\n        options.set_precision(2);\n        T::wrapping_from(123u8)\n            .to_sci_with_options(options)\n            .to_string()\n    });\n}\n\n#[test]\npub fn to_sci_with_options_fail() {\n    apply_fn_to_primitive_ints!(to_sci_with_options_fail_helper);\n}\n\nfn to_sci_helper_unsigned<T: PrimitiveUnsigned>() {\n    let mut powers_of_10 = HashMap::new();\n    let ten = T::from(10u8);\n    let default_p = 16;\n    unsigned_gen::<T>().test_properties(|x| {\n        assert!(x.fmt_sci_valid(ToSciOptions::default()));\n        let s = x.to_sci().to_string();\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            s\n        );\n        assert!(string_is_subset(&s, DECIMAL_SCI_STRING_CHARS));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains('-'));\n        assert!(!s.contains('+'));\n        assert!(!s.contains('E'));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        if let Some(x_from) = T::from_sci_string(&s) {\n            if x == T::ZERO {\n                assert_eq!(x_from, T::ZERO);\n            } else {\n                let log = x.floor_log_base(ten);\n                if log < default_p {\n                    assert_eq!(x_from, x);\n                } else {\n                    let pow = *powers_of_10\n                        .entry(log - default_p + 1)\n                        .or_insert_with_key(|&p| ten.pow(p));\n                    assert_eq!(x.round_to_multiple(pow, Nearest).0, x_from);\n                }\n            }\n        } else {\n            assert_eq!(x.significant_bits(), T::WIDTH);\n        }\n    });\n}\n\nfn to_sci_helper_signed<T: PrimitiveSigned>()\nwhere\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    let mut powers_of_10 = HashMap::new();\n    let ten = T::from(10);\n    let u_ten = <T as UnsignedAbs>::Output::from(10u8);\n    let default_p = 16;\n    signed_gen::<T>().test_properties(|x| {\n        assert!(x.fmt_sci_valid(ToSciOptions::default()));\n        let s = x.to_sci().to_string();\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            s\n        );\n        assert!(string_is_subset(&s, DECIMAL_SCI_STRING_CHARS));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains('E'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(!s.contains(\"-.\"));\n        assert!(!s.contains(\"e-\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 1);\n        if let Some(x_from) = T::from_sci_string(&s) {\n            if x == T::ZERO {\n                assert_eq!(x_from, T::ZERO);\n            } else {\n                let log = x.unsigned_abs().floor_log_base(u_ten);\n                if log < default_p {\n                    assert_eq!(x_from, x);\n                } else {\n                    let pow = *powers_of_10\n                        .entry(log - default_p + 1)\n                        .or_insert_with_key(|&p| ten.pow(p));\n                    assert_eq!(x.round_to_multiple(pow, Nearest).0, x_from);\n                }\n            }\n        } else {\n            assert!(x.significant_bits() >= T::WIDTH - 1);\n        }\n    });\n}\n\n#[test]\nfn to_sci_properties() {\n    apply_fn_to_unsigneds!(to_sci_helper_unsigned);\n    apply_fn_to_signeds!(to_sci_helper_signed);\n}\n\nfn to_sci_with_options_helper_unsigned<T: PrimitiveUnsigned>() {\n    let mut powers = HashMap::new();\n    let mut chars = HashMap::new();\n    unsigned_to_sci_options_pair_gen_var_1::<T>().test_properties(|(x, options)| {\n        assert!(x.fmt_sci_valid(options));\n        let s = x.to_sci_with_options(options).to_string();\n        let cs: &mut String = chars.entry(options.get_base()).or_insert_with_key(|&base| {\n            let mut cs = \"+-.0123456789\".to_string();\n            if base > 10 {\n                let limit = usize::from(base - 10);\n                for c in ('a'..='z').take(limit) {\n                    cs.push(c);\n                }\n                for c in ('A'..='Z').take(limit) {\n                    cs.push(c);\n                }\n            }\n            if base < 15 {\n                cs.push('e');\n                cs.push('E');\n            }\n            cs\n        });\n        assert!(string_is_subset(&s, cs));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 1);\n        let mut from_options = FromSciStringOptions::default();\n        from_options.set_base(options.get_base());\n        if let Some(x_from) = T::from_sci_string_with_options(&s, from_options) {\n            if x == T::ZERO {\n                assert_eq!(x_from, T::ZERO);\n            } else {\n                let base = T::from(options.get_base());\n                let scale = match options.get_size_options() {\n                    SciSizeOptions::Complete | SciSizeOptions::Scale(_) => None,\n                    SciSizeOptions::Precision(p) => {\n                        let log = x.floor_log_base(base);\n                        if log >= p { Some(log - p + 1) } else { None }\n                    }\n                };\n                if let Some(scale) = scale {\n                    let pow = *powers\n                        .entry((base, scale))\n                        .or_insert_with(|| base.pow(scale));\n                    assert_eq!(\n                        x.round_to_multiple(pow, options.get_rounding_mode()).0,\n                        x_from\n                    );\n                } else {\n                    assert_eq!(x_from, x);\n                }\n            }\n        } else {\n            assert_eq!(x.significant_bits(), T::WIDTH);\n        }\n    });\n}\n\nfn to_sci_with_options_helper_signed<T: PrimitiveSigned>()\nwhere\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    let mut powers = HashMap::new();\n    let mut chars = HashMap::new();\n    signed_to_sci_options_pair_gen_var_1::<T>().test_properties(|(x, options)| {\n        assert!(x.fmt_sci_valid(options));\n        let s = x.to_sci_with_options(options).to_string();\n        let cs: &mut String = chars.entry(options.get_base()).or_insert_with_key(|&base| {\n            let mut cs = \"+-.0123456789\".to_string();\n            if base > 10 {\n                let limit = usize::from(base - 10);\n                for c in ('a'..='z').take(limit) {\n                    cs.push(c);\n                }\n                for c in ('A'..='Z').take(limit) {\n                    cs.push(c);\n                }\n            }\n            if base < 15 {\n                cs.push('e');\n                cs.push('E');\n            }\n            cs\n        });\n        assert!(string_is_subset(&s, cs));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(!s.contains(\"-.\"));\n        assert!(!s.contains(\"e-\"));\n        assert!(!s.contains(\"E-\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 1);\n        let mut from_options = FromSciStringOptions::default();\n        from_options.set_base(options.get_base());\n        if let Some(x_from) = T::from_sci_string_with_options(&s, from_options) {\n            if x == T::ZERO {\n                assert_eq!(x_from, T::ZERO);\n            } else {\n                let base = T::wrapping_from(options.get_base());\n                let u_base = <T as UnsignedAbs>::Output::from(options.get_base());\n                let scale = match options.get_size_options() {\n                    SciSizeOptions::Complete | SciSizeOptions::Scale(_) => None,\n                    SciSizeOptions::Precision(p) => {\n                        let log = x.unsigned_abs().floor_log_base(u_base);\n                        if log >= p { Some(log - p + 1) } else { None }\n                    }\n                };\n                if let Some(scale) = scale {\n                    let pow = *powers\n                        .entry((base, scale))\n                        .or_insert_with(|| base.pow(scale));\n                    assert_eq!(\n                        x.round_to_multiple(pow, options.get_rounding_mode()).0,\n                        x_from\n                    );\n                } else {\n                    assert_eq!(x_from, x);\n                }\n            }\n        } else {\n            assert!(x.significant_bits() >= T::WIDTH - 1);\n        }\n    });\n}\n\n#[test]\nfn to_sci_with_options_properties() {\n    apply_fn_to_unsigneds!(to_sci_with_options_helper_unsigned);\n    apply_fn_to_signeds!(to_sci_with_options_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::repeat_n;\nuse malachite_base::num::arithmetic::traits::{SaturatingSubAssign, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::to_string::{\n    BaseFmtWrapper, digit_to_display_byte_lower, digit_to_display_byte_upper,\n};\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::strings::{\n    ToBinaryString, ToLowerHexString, ToOctalString, ToUpperHexString, string_is_subset,\n};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_2, signed_unsigned_pair_gen_var_5, signed_unsigned_pair_gen_var_6,\n    signed_unsigned_unsigned_triple_gen_var_3, unsigned_gen, unsigned_gen_var_7,\n    unsigned_gen_var_8, unsigned_pair_gen_var_2, unsigned_pair_gen_var_8, unsigned_pair_gen_var_9,\n    unsigned_triple_gen_var_6,\n};\nuse malachite_base::test_util::num::conversion::string::to_string::{\n    to_string_base_signed_naive, to_string_base_unsigned_naive,\n};\nuse std::cmp::max;\nuse std::fmt::{Debug, Display};\nuse std::panic::catch_unwind;\n\nfn test_padding_unsigned(s: &str, s_padded: &str, width: usize) {\n    assert!(s_padded.ends_with(&s));\n    assert!(s_padded.len() >= width);\n    assert_eq!(s.len() >= width, s == s_padded);\n    if s.len() < width {\n        let diff = s_padded.len() - s.len();\n        assert!(s_padded[..diff].chars().all(|c| c == '0'));\n        assert_eq!(&s_padded[diff..], s);\n    }\n}\n\nfn test_padding_signed(mut s: &str, mut s_padded: &str, mut width: usize) {\n    assert!(s_padded.len() >= width);\n    assert_eq!(s.len() >= width, s == s_padded);\n    let negative = s.starts_with('-');\n    assert_eq!(s_padded.starts_with('-'), negative);\n    if negative {\n        s = &s[1..];\n        s_padded = &s_padded[1..];\n        width.saturating_sub_assign(1);\n    }\n    test_padding_unsigned(s, s_padded, width);\n}\n\n#[test]\nfn test_digit_to_display_byte_lower() {\n    let test_ok = |x, y| {\n        assert_eq!(digit_to_display_byte_lower(x).unwrap(), y);\n    };\n    test_ok(0, b'0');\n    test_ok(1, b'1');\n    test_ok(2, b'2');\n    test_ok(3, b'3');\n    test_ok(4, b'4');\n    test_ok(5, b'5');\n    test_ok(6, b'6');\n    test_ok(7, b'7');\n    test_ok(8, b'8');\n    test_ok(9, b'9');\n    test_ok(10, b'a');\n    test_ok(11, b'b');\n    test_ok(12, b'c');\n    test_ok(33, b'x');\n    test_ok(34, b'y');\n    test_ok(35, b'z');\n\n    let test_err = |x| {\n        assert!(digit_to_display_byte_lower(x).is_none());\n    };\n    test_err(36);\n    test_err(100);\n}\n\n#[test]\nfn digit_to_display_byte_lower_properties() {\n    unsigned_gen().test_properties(|b| {\n        assert_eq!(digit_to_display_byte_lower(b).is_some(), b < 36);\n    });\n\n    unsigned_gen_var_7().test_properties(|b| {\n        let display_byte = digit_to_display_byte_lower(b).unwrap();\n        assert!(display_byte.is_ascii_digit() || display_byte.is_ascii_lowercase());\n        let display_byte_upper = digit_to_display_byte_upper(b).unwrap();\n        assert_eq!(display_byte == display_byte_upper, b < 10);\n        assert_eq!(\n            char::from(display_byte).to_ascii_uppercase(),\n            char::from(display_byte_upper)\n        );\n    });\n}\n\n#[test]\nfn test_digit_to_display_byte_upper() {\n    let test_ok = |x, y| {\n        assert_eq!(digit_to_display_byte_upper(x).unwrap(), y);\n    };\n    test_ok(0, b'0');\n    test_ok(1, b'1');\n    test_ok(2, b'2');\n    test_ok(3, b'3');\n    test_ok(4, b'4');\n    test_ok(5, b'5');\n    test_ok(6, b'6');\n    test_ok(7, b'7');\n    test_ok(8, b'8');\n    test_ok(9, b'9');\n    test_ok(10, b'A');\n    test_ok(11, b'B');\n    test_ok(12, b'C');\n    test_ok(33, b'X');\n    test_ok(34, b'Y');\n    test_ok(35, b'Z');\n\n    let test_err = |x| {\n        assert!(digit_to_display_byte_upper(x).is_none());\n    };\n    test_err(36);\n    test_err(100);\n}\n\n#[test]\nfn digit_to_display_byte_upper_properties() {\n    unsigned_gen().test_properties(|b| {\n        assert_eq!(\n            digit_to_display_byte_upper(b).is_some(),\n            (0..36).contains(&b)\n        );\n    });\n\n    unsigned_gen_var_7().test_properties(|b| {\n        let display_byte = digit_to_display_byte_upper(b).unwrap();\n        assert!(display_byte.is_ascii_digit() || display_byte.is_ascii_uppercase());\n        let display_byte_lower = digit_to_display_byte_lower(b).unwrap();\n        assert_eq!(display_byte == display_byte_lower, b < 10);\n        assert_eq!(\n            char::from(display_byte).to_ascii_lowercase(),\n            char::from(display_byte_lower)\n        );\n    });\n}\n\n#[test]\npub fn test_to_string_base() {\n    fn test_u<T: PrimitiveUnsigned>(x: T, base: u8, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n        u8: WrappingFrom<T>,\n    {\n        assert_eq!(x.to_string_base(base), out);\n        assert_eq!(to_string_base_unsigned_naive(x, base), out);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(x, base)), out);\n    }\n    test_u::<u8>(0, 2, \"0\");\n    test_u::<u8>(0, 3, \"0\");\n    test_u::<u8>(0, 10, \"0\");\n    test_u::<u8>(0, 16, \"0\");\n    test_u::<u8>(0, 17, \"0\");\n    test_u::<u16>(2, 3, \"2\");\n    test_u::<u16>(2, 10, \"2\");\n    test_u::<u16>(2, 16, \"2\");\n    test_u::<u16>(2, 17, \"2\");\n    test_u::<u32>(123, 8, \"173\");\n    test_u::<u32>(1000000, 10, \"1000000\");\n    test_u::<u32>(1000000, 20, \"65000\");\n    test_u::<u32>(1000000, 36, \"lfls\");\n    test_u::<u64>(1000, 2, \"1111101000\");\n    test_u::<u64>(1000, 3, \"1101001\");\n    test_u::<u64>(1000, 4, \"33220\");\n    test_u::<u64>(1000, 10, \"1000\");\n    test_u::<u64>(1000, 20, \"2a0\");\n    test_u::<u64>(1000, 36, \"rs\");\n\n    fn test_u_width<T: PrimitiveUnsigned>(x: T, base: u8, width: usize, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n        u8: WrappingFrom<T>,\n    {\n        let s = x.to_string_base(base);\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:0width$?}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        test_padding_unsigned(&s, out, width);\n    }\n    test_u_width::<u8>(0, 2, 0, \"0\");\n    test_u_width::<u8>(0, 2, 1, \"0\");\n    test_u_width::<u8>(0, 2, 2, \"00\");\n    test_u_width::<u8>(0, 2, 5, \"00000\");\n    test_u_width::<u32>(1000000, 36, 0, \"lfls\");\n    test_u_width::<u32>(1000000, 36, 1, \"lfls\");\n    test_u_width::<u32>(1000000, 36, 2, \"lfls\");\n    test_u_width::<u32>(1000000, 36, 3, \"lfls\");\n    test_u_width::<u32>(1000000, 36, 4, \"lfls\");\n    test_u_width::<u32>(1000000, 36, 5, \"0lfls\");\n    test_u_width::<u32>(1000000, 36, 6, \"00lfls\");\n\n    fn test_i<T: PrimitiveSigned>(x: T, base: u8, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n        u8: WrappingFrom<<T as UnsignedAbs>::Output>,\n        <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n    {\n        assert_eq!(x.to_string_base(base), out);\n        assert_eq!(to_string_base_signed_naive(x, base), out);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(x, base)), out);\n    }\n    test_i::<i8>(0, 2, \"0\");\n    test_i::<i8>(0, 3, \"0\");\n    test_i::<i8>(0, 10, \"0\");\n    test_i::<i8>(0, 16, \"0\");\n    test_i::<i8>(0, 17, \"0\");\n    test_i::<i16>(2, 3, \"2\");\n    test_i::<i16>(2, 10, \"2\");\n    test_i::<i16>(2, 16, \"2\");\n    test_i::<i16>(2, 17, \"2\");\n    test_i::<i32>(123, 8, \"173\");\n    test_i::<i32>(1000000, 10, \"1000000\");\n    test_i::<i32>(1000000, 20, \"65000\");\n    test_i::<i32>(1000000, 36, \"lfls\");\n    test_i::<i64>(1000, 2, \"1111101000\");\n    test_i::<i64>(1000, 3, \"1101001\");\n    test_i::<i64>(1000, 4, \"33220\");\n    test_i::<i64>(1000, 10, \"1000\");\n    test_i::<i64>(1000, 20, \"2a0\");\n    test_i::<i64>(1000, 36, \"rs\");\n\n    test_i::<i16>(-2, 3, \"-2\");\n    test_i::<i16>(-2, 10, \"-2\");\n    test_i::<i16>(-2, 16, \"-2\");\n    test_i::<i16>(-2, 17, \"-2\");\n    test_i::<i32>(-123, 8, \"-173\");\n    test_i::<i32>(-1000000, 10, \"-1000000\");\n    test_i::<i32>(-1000000, 20, \"-65000\");\n    test_i::<i32>(-1000000, 36, \"-lfls\");\n    test_i::<i64>(-1000, 2, \"-1111101000\");\n    test_i::<i64>(-1000, 3, \"-1101001\");\n    test_i::<i64>(-1000, 4, \"-33220\");\n    test_i::<i64>(-1000, 10, \"-1000\");\n    test_i::<i64>(-1000, 20, \"-2a0\");\n    test_i::<i64>(-1000, 36, \"-rs\");\n\n    fn test_i_width<T: PrimitiveSigned>(x: T, base: u8, width: usize, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n        u8: WrappingFrom<T>,\n    {\n        let s = x.to_string_base(base);\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:0width$?}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        test_padding_signed(&s, out, width);\n    }\n    test_i_width::<i8>(0, 2, 0, \"0\");\n    test_i_width::<i8>(0, 2, 1, \"0\");\n    test_i_width::<i8>(0, 2, 2, \"00\");\n    test_i_width::<i8>(0, 2, 5, \"00000\");\n    test_i_width::<i32>(1000000, 36, 0, \"lfls\");\n    test_i_width::<i32>(1000000, 36, 1, \"lfls\");\n    test_i_width::<i32>(1000000, 36, 2, \"lfls\");\n    test_i_width::<i32>(1000000, 36, 3, \"lfls\");\n    test_i_width::<i32>(1000000, 36, 4, \"lfls\");\n    test_i_width::<i32>(1000000, 36, 5, \"0lfls\");\n    test_i_width::<i32>(1000000, 36, 6, \"00lfls\");\n    test_i_width::<i32>(-1000000, 36, 0, \"-lfls\");\n    test_i_width::<i32>(-1000000, 36, 1, \"-lfls\");\n    test_i_width::<i32>(-1000000, 36, 2, \"-lfls\");\n    test_i_width::<i32>(-1000000, 36, 3, \"-lfls\");\n    test_i_width::<i32>(-1000000, 36, 4, \"-lfls\");\n    test_i_width::<i32>(-1000000, 36, 5, \"-lfls\");\n    test_i_width::<i32>(-1000000, 36, 6, \"-0lfls\");\n}\n\nfn to_string_base_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::exact_from(100).to_string_base(0));\n    assert_panic!(T::exact_from(100).to_string_base(1));\n    assert_panic!(T::exact_from(100).to_string_base(37));\n    assert_panic!(T::exact_from(100).to_string_base(100));\n}\n\n#[test]\nfn to_string_base_fail() {\n    apply_fn_to_primitive_ints!(to_string_base_fail_helper);\n}\n\nfn to_string_base_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    BaseFmtWrapper<T>: Debug + Display,\n    u8: WrappingFrom<T>,\n{\n    unsigned_pair_gen_var_8::<T, u8>().test_properties(|(x, base)| {\n        let s = x.to_string_base(base);\n        assert_eq!(to_string_base_unsigned_naive(x, base), s);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(x.to_string_base_upper(base), s.to_uppercase());\n        assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(&s, \"0123456789abcdefghijklmnopqrstuvwxyz\"));\n        if x != T::ZERO {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.to_string_base(10), x.to_string());\n        assert_eq!(x.to_string_base(2), x.to_binary_string());\n        assert_eq!(x.to_string_base(8), x.to_octal_string());\n        assert_eq!(x.to_string_base(16), x.to_lower_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(T::ZERO.to_string_base(base), \"0\");\n        assert_eq!(T::ONE.to_string_base(base), \"1\");\n        assert_eq!(T::exact_from(base).to_string_base(base), \"10\");\n    });\n\n    unsigned_triple_gen_var_6::<T, u8, usize>().test_properties(|(x, base, width)| {\n        let fx = BaseFmtWrapper::new(x, base);\n        let s = x.to_string_base(base);\n        let s_padded = format!(\"{fx:0width$}\");\n        assert_eq!(format!(\"{fx:0width$?}\"), s_padded);\n        assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s_padded,\n            \"0123456789abcdefghijklmnopqrstuvwxyz\"\n        ));\n        test_padding_unsigned(&s, &s_padded, width);\n    });\n\n    unsigned_pair_gen_var_2::<T, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 16), width = width),\n            format!(\"{x:0width$x}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:0width$}\",\n            BaseFmtWrapper::new(T::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n}\n\nfn to_string_base_helper_signed<T: PrimitiveSigned>()\nwhere\n    BaseFmtWrapper<T>: Debug + Display,\n    u8: WrappingFrom<<T as UnsignedAbs>::Output>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    signed_unsigned_pair_gen_var_5::<T, u8>().test_properties(|(x, base)| {\n        let s = x.to_string_base(base);\n        assert_eq!(to_string_base_signed_naive(x, base), s);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(x.to_string_base_upper(base), s.to_uppercase());\n        assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s,\n            \"-0123456789abcdefghijklmnopqrstuvwxyz\"\n        ));\n        assert_eq!(x < T::ZERO, s.starts_with('-'));\n        assert!(!s.starts_with(\"-0\"));\n        if x != T::ZERO {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.to_string_base(10), x.to_string());\n    });\n\n    signed_gen_var_2::<T>().test_properties(|x| {\n        assert_eq!(x.to_string_base(2), x.to_binary_string());\n        assert_eq!(x.to_string_base(8), x.to_octal_string());\n        assert_eq!(x.to_string_base(16), x.to_lower_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(T::ZERO.to_string_base(base), \"0\");\n        assert_eq!(T::ONE.to_string_base(base), \"1\");\n        assert_eq!(T::NEGATIVE_ONE.to_string_base(base), \"-1\");\n        assert_eq!(T::exact_from(base).to_string_base(base), \"10\");\n    });\n\n    signed_unsigned_unsigned_triple_gen_var_3::<T, u8, usize>().test_properties(\n        |(x, base, width)| {\n            let fx = BaseFmtWrapper::new(x, base);\n            let s = x.to_string_base(base);\n            let s_padded = format!(\"{fx:0width$}\");\n            assert!(s_padded.len() >= width);\n            assert_eq!(s.len() >= width, s == s_padded);\n            assert_eq!(format!(\"{fx:0width$?}\"), s_padded);\n            assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n            assert!(string_is_subset(\n                &s_padded,\n                \"-0123456789abcdefghijklmnopqrstuvwxyz\"\n            ));\n            test_padding_signed(&s, &s_padded, width);\n        },\n    );\n\n    signed_unsigned_pair_gen_var_6::<T, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(x, 16), width = width),\n            format!(\"{x:0width$x}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:0width$}\",\n            BaseFmtWrapper::new(T::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n}\n\n#[test]\nfn to_string_base_properties() {\n    apply_fn_to_unsigneds!(to_string_base_helper_unsigned);\n    apply_fn_to_signeds!(to_string_base_helper_signed);\n}\n\n#[test]\npub fn test_to_string_base_upper() {\n    fn test_u<T: PrimitiveUnsigned>(x: T, base: u8, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n    {\n        assert_eq!(x.to_string_base_upper(base), out);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(x, base)), out);\n    }\n    test_u::<u8>(0, 2, \"0\");\n    test_u::<u8>(0, 3, \"0\");\n    test_u::<u8>(0, 10, \"0\");\n    test_u::<u8>(0, 16, \"0\");\n    test_u::<u8>(0, 17, \"0\");\n    test_u::<u16>(2, 3, \"2\");\n    test_u::<u16>(2, 10, \"2\");\n    test_u::<u16>(2, 16, \"2\");\n    test_u::<u16>(2, 17, \"2\");\n    test_u::<u32>(123, 8, \"173\");\n    test_u::<u32>(1000000, 10, \"1000000\");\n    test_u::<u32>(1000000, 20, \"65000\");\n    test_u::<u32>(1000000, 36, \"LFLS\");\n    test_u::<u64>(1000, 2, \"1111101000\");\n    test_u::<u64>(1000, 3, \"1101001\");\n    test_u::<u64>(1000, 4, \"33220\");\n    test_u::<u64>(1000, 10, \"1000\");\n    test_u::<u64>(1000, 20, \"2A0\");\n    test_u::<u64>(1000, 36, \"RS\");\n\n    fn test_u_width<T: PrimitiveUnsigned>(x: T, base: u8, width: usize, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n        u8: WrappingFrom<T>,\n    {\n        let s = x.to_string_base_upper(base);\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:#0width$?}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        test_padding_unsigned(&s, out, width);\n    }\n    test_u_width::<u8>(0, 2, 0, \"0\");\n    test_u_width::<u8>(0, 2, 1, \"0\");\n    test_u_width::<u8>(0, 2, 2, \"00\");\n    test_u_width::<u8>(0, 2, 5, \"00000\");\n    test_u_width::<u32>(1000000, 36, 0, \"LFLS\");\n    test_u_width::<u32>(1000000, 36, 1, \"LFLS\");\n    test_u_width::<u32>(1000000, 36, 2, \"LFLS\");\n    test_u_width::<u32>(1000000, 36, 3, \"LFLS\");\n    test_u_width::<u32>(1000000, 36, 4, \"LFLS\");\n    test_u_width::<u32>(1000000, 36, 5, \"0LFLS\");\n    test_u_width::<u32>(1000000, 36, 6, \"00LFLS\");\n\n    fn test_i<T: PrimitiveSigned>(x: T, base: u8, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n    {\n        assert_eq!(x.to_string_base_upper(base), out);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(x, base)), out);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(x, base)), out);\n    }\n    test_i::<i8>(0, 2, \"0\");\n    test_i::<i8>(0, 3, \"0\");\n    test_i::<i8>(0, 10, \"0\");\n    test_i::<i8>(0, 16, \"0\");\n    test_i::<i8>(0, 17, \"0\");\n    test_i::<i16>(2, 3, \"2\");\n    test_i::<i16>(2, 10, \"2\");\n    test_i::<i16>(2, 16, \"2\");\n    test_i::<i16>(2, 17, \"2\");\n    test_i::<i32>(123, 8, \"173\");\n    test_i::<i32>(1000000, 10, \"1000000\");\n    test_i::<i32>(1000000, 20, \"65000\");\n    test_i::<i32>(1000000, 36, \"LFLS\");\n    test_i::<i64>(1000, 2, \"1111101000\");\n    test_i::<i64>(1000, 3, \"1101001\");\n    test_i::<i64>(1000, 4, \"33220\");\n    test_i::<i64>(1000, 10, \"1000\");\n    test_i::<i64>(1000, 20, \"2A0\");\n    test_i::<i64>(1000, 36, \"RS\");\n\n    test_i::<i16>(-2, 3, \"-2\");\n    test_i::<i16>(-2, 10, \"-2\");\n    test_i::<i16>(-2, 16, \"-2\");\n    test_i::<i16>(-2, 17, \"-2\");\n    test_i::<i32>(-123, 8, \"-173\");\n    test_i::<i32>(-1000000, 10, \"-1000000\");\n    test_i::<i32>(-1000000, 20, \"-65000\");\n    test_i::<i32>(-1000000, 36, \"-LFLS\");\n    test_i::<i64>(-1000, 2, \"-1111101000\");\n    test_i::<i64>(-1000, 3, \"-1101001\");\n    test_i::<i64>(-1000, 4, \"-33220\");\n    test_i::<i64>(-1000, 10, \"-1000\");\n    test_i::<i64>(-1000, 20, \"-2A0\");\n    test_i::<i64>(-1000, 36, \"-RS\");\n\n    fn test_i_width<T: PrimitiveSigned>(x: T, base: u8, width: usize, out: &str)\n    where\n        BaseFmtWrapper<T>: Debug + Display,\n        u8: WrappingFrom<T>,\n    {\n        let s = x.to_string_base_upper(base);\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:#0width$?}\", BaseFmtWrapper::new(x, base), width = width),\n            out\n        );\n        test_padding_signed(&s, out, width);\n    }\n    test_i_width::<i8>(0, 2, 0, \"0\");\n    test_i_width::<i8>(0, 2, 1, \"0\");\n    test_i_width::<i8>(0, 2, 2, \"00\");\n    test_i_width::<i8>(0, 2, 5, \"00000\");\n    test_i_width::<i32>(1000000, 36, 0, \"LFLS\");\n    test_i_width::<i32>(1000000, 36, 1, \"LFLS\");\n    test_i_width::<i32>(1000000, 36, 2, \"LFLS\");\n    test_i_width::<i32>(1000000, 36, 3, \"LFLS\");\n    test_i_width::<i32>(1000000, 36, 4, \"LFLS\");\n    test_i_width::<i32>(1000000, 36, 5, \"0LFLS\");\n    test_i_width::<i32>(1000000, 36, 6, \"00LFLS\");\n    test_i_width::<i32>(-1000000, 36, 0, \"-LFLS\");\n    test_i_width::<i32>(-1000000, 36, 1, \"-LFLS\");\n    test_i_width::<i32>(-1000000, 36, 2, \"-LFLS\");\n    test_i_width::<i32>(-1000000, 36, 3, \"-LFLS\");\n    test_i_width::<i32>(-1000000, 36, 4, \"-LFLS\");\n    test_i_width::<i32>(-1000000, 36, 5, \"-LFLS\");\n    test_i_width::<i32>(-1000000, 36, 6, \"-0LFLS\");\n}\n\nfn to_string_base_upper_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::exact_from(100).to_string_base_upper(0));\n    assert_panic!(T::exact_from(100).to_string_base_upper(1));\n    assert_panic!(T::exact_from(100).to_string_base_upper(37));\n    assert_panic!(T::exact_from(100).to_string_base_upper(100));\n}\n\n#[test]\nfn to_string_base_upper_fail() {\n    apply_fn_to_primitive_ints!(to_string_base_upper_fail_helper);\n}\n\nfn to_string_base_upper_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    BaseFmtWrapper<T>: Debug + Display,\n{\n    unsigned_pair_gen_var_8::<T, u8>().test_properties(|(x, base)| {\n        let s = x.to_string_base_upper(base);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:#00}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(x.to_string_base(base), s.to_lowercase());\n        assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(&s, \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"));\n        if x != T::ZERO {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.to_string_base_upper(10), x.to_string());\n        assert_eq!(x.to_string_base_upper(2), x.to_binary_string());\n        assert_eq!(x.to_string_base_upper(8), x.to_octal_string());\n        assert_eq!(x.to_string_base_upper(16), x.to_upper_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(T::ZERO.to_string_base_upper(base), \"0\");\n        assert_eq!(T::ONE.to_string_base_upper(base), \"1\");\n        assert_eq!(T::exact_from(base).to_string_base_upper(base), \"10\");\n    });\n\n    unsigned_triple_gen_var_6::<T, u8, usize>().test_properties(|(x, base, width)| {\n        let fx = BaseFmtWrapper::new(x, base);\n        let s = x.to_string_base_upper(base);\n        let s_padded = format!(\"{fx:#0width$}\");\n        assert_eq!(format!(\"{fx:#0width$?}\"), s_padded);\n        assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s_padded,\n            \"01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n        ));\n        test_padding_unsigned(&s, &s_padded, width);\n    });\n\n    unsigned_pair_gen_var_2::<T, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 16), width = width),\n            format!(\"{x:0width$X}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:#0width$}\",\n            BaseFmtWrapper::new(T::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n}\n\nfn to_string_base_upper_helper_signed<T: PrimitiveSigned>()\nwhere\n    BaseFmtWrapper<T>: Debug + Display,\n{\n    signed_unsigned_pair_gen_var_5::<T, u8>().test_properties(|(x, base)| {\n        let s = x.to_string_base_upper(base);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(x, base)), s);\n        assert_eq!(x.to_string_base(base), s.to_lowercase());\n        assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s,\n            \"-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n        ));\n        assert_eq!(x < T::ZERO, s.starts_with('-'));\n        assert!(!s.starts_with(\"-0\"));\n        if x != T::ZERO {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.to_string_base_upper(10), x.to_string());\n    });\n\n    signed_gen_var_2::<T>().test_properties(|x| {\n        assert_eq!(x.to_string_base_upper(2), x.to_binary_string());\n        assert_eq!(x.to_string_base_upper(8), x.to_octal_string());\n        assert_eq!(x.to_string_base_upper(16), x.to_upper_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(T::ZERO.to_string_base_upper(base), \"0\");\n        assert_eq!(T::ONE.to_string_base_upper(base), \"1\");\n        assert_eq!(T::NEGATIVE_ONE.to_string_base_upper(base), \"-1\");\n        assert_eq!(T::exact_from(base).to_string_base_upper(base), \"10\");\n    });\n\n    signed_unsigned_unsigned_triple_gen_var_3::<T, u8, usize>().test_properties(\n        |(x, base, width)| {\n            let fx = BaseFmtWrapper::new(x, base);\n            let s = x.to_string_base_upper(base);\n            let s_padded = format!(\"{fx:#0width$}\");\n            assert!(s_padded.len() >= width);\n            assert_eq!(s.len() >= width, s == s_padded);\n            assert_eq!(format!(\"{fx:#0width$?}\"), s_padded);\n            assert_eq!(T::from_string_base(base, &s).unwrap(), x);\n            assert!(string_is_subset(\n                &s_padded,\n                \"-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n            ));\n            test_padding_signed(&s, &s_padded, width);\n        },\n    );\n\n    signed_unsigned_pair_gen_var_6::<T, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(x, 16), width = width),\n            format!(\"{x:0width$X}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:#0width$}\",\n            BaseFmtWrapper::new(T::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n}\n\n#[test]\nfn to_string_base_upper_properties() {\n    apply_fn_to_unsigneds!(to_string_base_upper_helper_unsigned);\n    apply_fn_to_signeds!(to_string_base_upper_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_finite_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_finite_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(exhaustive_finite_primitive_floats::<T>(), out);\n}\n\n#[test]\nfn test_exhaustive_finite_primitive_floats() {\n    exhaustive_finite_primitive_floats_helper::<f32>(&[\n        0.0, -0.0, 1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75,\n        4.0, -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5,\n        1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625, -0.625,\n        1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0,\n    ]);\n    exhaustive_finite_primitive_floats_helper::<f64>(&[\n        0.0, -0.0, 1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75,\n        4.0, -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5,\n        1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625, -0.625,\n        1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_natural_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::exhaustive::{exhaustive_natural_signeds, exhaustive_negative_signeds};\n\nfn exhaustive_natural_signeds_helper<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n{\n    let xs = exhaustive_natural_signeds::<T>()\n        .map(i8::exact_from)\n        .take(20)\n        .collect_vec();\n    assert_eq!(\n        xs,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    );\n    assert!(itertools::equal(\n        xs,\n        exhaustive_negative_signeds::<T>()\n            .map(|x| !i8::exact_from(x))\n            .take(20)\n    ));\n}\n\nfn exhaustive_natural_signeds_long_helper<T: PrimitiveSigned>(last_20: &[T]) {\n    let expected_len = usize::power_of_2(T::WIDTH - 1);\n    let xs = exhaustive_natural_signeds::<T>();\n    assert_eq!(xs.clone().count(), expected_len);\n    assert_eq!(xs.skip(expected_len - 20).collect_vec(), last_20);\n}\n\n#[test]\nfn test_exhaustive_natural_signeds() {\n    apply_fn_to_signeds!(exhaustive_natural_signeds_helper);\n\n    exhaustive_natural_signeds_long_helper::<i8>(&[\n        108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,\n        126, 127,\n    ]);\n    exhaustive_natural_signeds_long_helper::<i16>(&[\n        32748,\n        32749,\n        32750,\n        32751,\n        0x7ff0,\n        0x7ff1,\n        0x7ff2,\n        0x7ff3,\n        0x7ff4,\n        0x7ff5,\n        0x7ff6,\n        0x7ff7,\n        0x7ff8,\n        0x7ff9,\n        0x7ffa,\n        0x7ffb,\n        0x7ffc,\n        0x7ffd,\n        i16::MAX - 1,\n        i16::MAX,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_negative_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_negative_finite_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_negative_finite_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(\n        exhaustive_negative_finite_primitive_floats::<T>(),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_negative_finite_primitive_floats() {\n    exhaustive_negative_finite_primitive_floats_helper::<f32>(&[\n        -1.0, -2.0, -1.5, -0.5, -1.25, -3.0, -1.75, -4.0, -1.125, -2.5, -1.375, -0.75, -1.625,\n        -3.5, -1.875, -0.25, -1.0625, -2.25, -1.1875, -0.625, -1.3125, -2.75, -1.4375, -6.0,\n        -1.5625, -3.25, -1.6875, -0.875, -1.8125, -3.75, -1.9375, -8.0, -1.03125, -2.125, -1.09375,\n        -0.5625, -1.15625, -2.375, -1.21875, -5.0, -1.28125, -2.625, -1.34375, -0.6875, -1.40625,\n        -2.875, -1.46875, -0.375, -1.53125, -3.125,\n    ]);\n    exhaustive_negative_finite_primitive_floats_helper::<f64>(&[\n        -1.0, -2.0, -1.5, -0.5, -1.25, -3.0, -1.75, -4.0, -1.125, -2.5, -1.375, -0.75, -1.625,\n        -3.5, -1.875, -0.25, -1.0625, -2.25, -1.1875, -0.625, -1.3125, -2.75, -1.4375, -6.0,\n        -1.5625, -3.25, -1.6875, -0.875, -1.8125, -3.75, -1.9375, -8.0, -1.03125, -2.125, -1.09375,\n        -0.5625, -1.15625, -2.375, -1.21875, -5.0, -1.28125, -2.625, -1.34375, -0.6875, -1.40625,\n        -2.875, -1.46875, -0.375, -1.53125, -3.125,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_negative_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::exhaustive_negative_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_negative_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(exhaustive_negative_primitive_floats::<T>(), out);\n}\n\n#[test]\nfn test_exhaustive_negative_primitive_floats() {\n    exhaustive_negative_primitive_floats_helper::<f32>(&[\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        -2.0,\n        -1.5,\n        -0.5,\n        -1.25,\n        -3.0,\n        -1.75,\n        -4.0,\n        -1.125,\n        -2.5,\n        -1.375,\n        -0.75,\n        -1.625,\n        -3.5,\n        -1.875,\n        -0.25,\n        -1.0625,\n        -2.25,\n        -1.1875,\n        -0.625,\n        -1.3125,\n        -2.75,\n        -1.4375,\n        -6.0,\n        -1.5625,\n        -3.25,\n        -1.6875,\n        -0.875,\n        -1.8125,\n        -3.75,\n        -1.9375,\n        -8.0,\n        -1.03125,\n        -2.125,\n        -1.09375,\n        -0.5625,\n        -1.15625,\n        -2.375,\n        -1.21875,\n        -5.0,\n        -1.28125,\n        -2.625,\n        -1.34375,\n        -0.6875,\n        -1.40625,\n        -2.875,\n        -1.46875,\n        -0.375,\n        -1.53125,\n    ]);\n    exhaustive_negative_primitive_floats_helper::<f64>(&[\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        -2.0,\n        -1.5,\n        -0.5,\n        -1.25,\n        -3.0,\n        -1.75,\n        -4.0,\n        -1.125,\n        -2.5,\n        -1.375,\n        -0.75,\n        -1.625,\n        -3.5,\n        -1.875,\n        -0.25,\n        -1.0625,\n        -2.25,\n        -1.1875,\n        -0.625,\n        -1.3125,\n        -2.75,\n        -1.4375,\n        -6.0,\n        -1.5625,\n        -3.25,\n        -1.6875,\n        -0.875,\n        -1.8125,\n        -3.75,\n        -1.9375,\n        -8.0,\n        -1.03125,\n        -2.125,\n        -1.09375,\n        -0.5625,\n        -1.15625,\n        -2.375,\n        -1.21875,\n        -5.0,\n        -1.28125,\n        -2.625,\n        -1.34375,\n        -0.6875,\n        -1.40625,\n        -2.875,\n        -1.46875,\n        -0.375,\n        -1.53125,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_negative_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::exhaustive::{exhaustive_natural_signeds, exhaustive_negative_signeds};\n\nfn exhaustive_negative_signeds_helper<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n{\n    let xs = exhaustive_negative_signeds::<T>()\n        .map(i8::exact_from)\n        .take(20)\n        .collect_vec();\n    assert_eq!(\n        xs,\n        &[\n            -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19,\n            -20\n        ]\n    );\n    assert!(itertools::equal(\n        xs,\n        exhaustive_natural_signeds::<T>()\n            .map(|x| !i8::exact_from(x))\n            .take(20)\n    ));\n}\n\nfn exhaustive_negative_signeds_long_helper<T: PrimitiveSigned>(last_20: &[T]) {\n    let expected_len = usize::power_of_2(T::WIDTH - 1);\n    let xs = exhaustive_negative_signeds::<T>();\n    assert_eq!(xs.clone().count(), expected_len);\n    assert_eq!(xs.skip(expected_len - 20).collect_vec(), last_20);\n}\n\n#[test]\nfn test_exhaustive_negative_signeds() {\n    apply_fn_to_signeds!(exhaustive_negative_signeds_helper);\n\n    exhaustive_negative_signeds_long_helper::<i8>(&[\n        -109, -110, -111, -112, -113, -114, -115, -116, -117, -118, -119, -120, -121, -122, -123,\n        -124, -125, -126, -127, -128,\n    ]);\n    exhaustive_negative_signeds_long_helper::<i16>(&[\n        -32749,\n        -32750,\n        -32751,\n        -0x7ff0,\n        -0x7ff1,\n        -0x7ff2,\n        -0x7ff3,\n        -0x7ff4,\n        -0x7ff5,\n        -0x7ff6,\n        -0x7ff7,\n        -0x7ff8,\n        -0x7ff9,\n        -0x7ffa,\n        -0x7ffb,\n        -0x7ffc,\n        -0x7ffd,\n        -0x7ffe,\n        i16::MIN + 1,\n        i16::MIN,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_nonzero_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_nonzero_finite_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_nonzero_finite_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(\n        exhaustive_nonzero_finite_primitive_floats::<T>(),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_nonzero_finite_primitive_floats() {\n    exhaustive_nonzero_finite_primitive_floats_helper::<f32>(&[\n        1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75, 4.0, -4.0,\n        1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5, 1.875,\n        -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625, -0.625, 1.3125,\n        -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, 1.5625, -1.5625,\n    ]);\n    exhaustive_nonzero_finite_primitive_floats_helper::<f64>(&[\n        1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75, 4.0, -4.0,\n        1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5, 1.875,\n        -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625, -0.625, 1.3125,\n        -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, 1.5625, -1.5625,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_nonzero_finite_primitive_floats_in_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_nonzero_finite_primitive_floats_in_range;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\nuse std::panic::catch_unwind;\n\nfn exhaustive_nonzero_finite_primitive_floats_in_range_helper<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    out: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper(\n        exhaustive_nonzero_finite_primitive_floats_in_range::<T>(a, b),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_nonzero_finite_primitive_floats_in_range() {\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f32>(5.0, 5.0, &[5.0]);\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f32>(\n        1.0,\n        6.0,\n        &[\n            1.0, 2.0, 1.5, 4.0, 1.25, 3.0, 1.75, 1.125, 1.375, 2.5, 1.625, 6.0, 1.875, 3.5, 1.0625,\n            2.25, 1.1875, 2.75, 1.3125, 5.0, 1.4375, 3.25, 1.5625, 1.6875, 1.8125, 3.75, 1.9375,\n            4.5, 1.03125, 2.125, 1.09375, 5.5, 1.15625, 2.375, 1.21875, 4.25, 1.28125, 2.625,\n            1.34375, 1.40625, 1.46875, 2.875, 1.53125, 4.75, 1.59375, 3.125, 1.65625, 3.375,\n            1.71875, 3.625,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f32>(\n        -6.0,\n        -1.0,\n        &[\n            -1.0, -2.0, -1.5, -4.0, -1.25, -3.0, -1.75, -1.125, -1.375, -2.5, -1.625, -6.0, -1.875,\n            -3.5, -1.0625, -2.25, -1.1875, -2.75, -1.3125, -5.0, -1.4375, -3.25, -1.5625, -1.6875,\n            -1.8125, -3.75, -1.9375, -4.5, -1.03125, -2.125, -1.09375, -5.5, -1.15625, -2.375,\n            -1.21875, -4.25, -1.28125, -2.625, -1.34375, -1.40625, -1.46875, -2.875, -1.53125,\n            -4.75, -1.59375, -3.125, -1.65625, -3.375, -1.71875, -3.625,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f32>(\n        -6.0,\n        6.0,\n        &[\n            1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75, 4.0,\n            -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5,\n            1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625,\n            -0.625, 1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, 1.5625, -1.5625,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f32>(\n        -0.1,\n        10.0,\n        &[\n            1.0,\n            -0.0625,\n            2.0,\n            -0.03125,\n            1.5,\n            -0.09375,\n            0.5,\n            -0.015625,\n            1.25,\n            -0.078125,\n            3.0,\n            -0.046875,\n            1.75,\n            -0.0703125,\n            4.0,\n            -0.0078125,\n            1.125,\n            -0.0859375,\n            2.5,\n            -0.0390625,\n            1.375,\n            -0.06640625,\n            0.75,\n            -0.0234375,\n            1.625,\n            -0.07421875,\n            3.5,\n            -0.0546875,\n            1.875,\n            -0.08203125,\n            0.25,\n            -0.00390625,\n            1.0625,\n            -0.08984375,\n            2.25,\n            -0.03515625,\n            1.1875,\n            -0.09765625,\n            0.625,\n            -0.01953125,\n            1.3125,\n            -0.064453125,\n            2.75,\n            -0.04296875,\n            1.4375,\n            -0.068359375,\n            6.0,\n            -0.01171875,\n            1.5625,\n            -0.072265625,\n        ],\n    );\n\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f64>(5.0, 5.0, &[5.0]);\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f64>(\n        1.0,\n        6.0,\n        &[\n            1.0, 2.0, 1.5, 4.0, 1.25, 3.0, 1.75, 1.125, 1.375, 2.5, 1.625, 6.0, 1.875, 3.5, 1.0625,\n            2.25, 1.1875, 2.75, 1.3125, 5.0, 1.4375, 3.25, 1.5625, 1.6875, 1.8125, 3.75, 1.9375,\n            4.5, 1.03125, 2.125, 1.09375, 5.5, 1.15625, 2.375, 1.21875, 4.25, 1.28125, 2.625,\n            1.34375, 1.40625, 1.46875, 2.875, 1.53125, 4.75, 1.59375, 3.125, 1.65625, 3.375,\n            1.71875, 3.625,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f64>(\n        -6.0,\n        -1.0,\n        &[\n            -1.0, -2.0, -1.5, -4.0, -1.25, -3.0, -1.75, -1.125, -1.375, -2.5, -1.625, -6.0, -1.875,\n            -3.5, -1.0625, -2.25, -1.1875, -2.75, -1.3125, -5.0, -1.4375, -3.25, -1.5625, -1.6875,\n            -1.8125, -3.75, -1.9375, -4.5, -1.03125, -2.125, -1.09375, -5.5, -1.15625, -2.375,\n            -1.21875, -4.25, -1.28125, -2.625, -1.34375, -1.40625, -1.46875, -2.875, -1.53125,\n            -4.75, -1.59375, -3.125, -1.65625, -3.375, -1.71875, -3.625,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f64>(\n        -6.0,\n        6.0,\n        &[\n            1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75, 4.0,\n            -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5,\n            1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625,\n            -0.625, 1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, 1.5625, -1.5625,\n        ],\n    );\n    exhaustive_nonzero_finite_primitive_floats_in_range_helper::<f64>(\n        -0.1,\n        10.0,\n        &[\n            1.0,\n            -0.0625,\n            2.0,\n            -0.03125,\n            1.5,\n            -0.09375,\n            0.5,\n            -0.015625,\n            1.25,\n            -0.078125,\n            3.0,\n            -0.046875,\n            1.75,\n            -0.0703125,\n            4.0,\n            -0.0078125,\n            1.125,\n            -0.0859375,\n            2.5,\n            -0.0390625,\n            1.375,\n            -0.06640625,\n            0.75,\n            -0.0234375,\n            1.625,\n            -0.07421875,\n            3.5,\n            -0.0546875,\n            1.875,\n            -0.08203125,\n            0.25,\n            -0.00390625,\n            1.0625,\n            -0.08984375,\n            2.25,\n            -0.03515625,\n            1.1875,\n            -0.09765625,\n            0.625,\n            -0.01953125,\n            1.3125,\n            -0.064453125,\n            2.75,\n            -0.04296875,\n            1.4375,\n            -0.068359375,\n            6.0,\n            -0.01171875,\n            1.5625,\n            -0.072265625,\n        ],\n    );\n}\n\nfn exhaustive_nonzero_finite_primitive_floats_in_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(exhaustive_nonzero_finite_primitive_floats_in_range::<T>(\n        T::from(1.2),\n        T::from(1.1),\n    ));\n    assert_panic!(exhaustive_nonzero_finite_primitive_floats_in_range::<T>(\n        T::ONE,\n        T::INFINITY,\n    ));\n    assert_panic!(exhaustive_nonzero_finite_primitive_floats_in_range::<T>(\n        T::ONE,\n        T::NAN,\n    ));\n}\n\n#[test]\nfn exhaustive_nonzero_finite_primitive_floats_in_range_fail() {\n    apply_fn_to_primitive_floats!(exhaustive_nonzero_finite_primitive_floats_in_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_nonzero_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::exhaustive_nonzero_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_nonzero_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(exhaustive_nonzero_primitive_floats::<T>(), out);\n}\n\n#[test]\nfn test_exhaustive_nonzero_primitive_floats() {\n    exhaustive_nonzero_primitive_floats_helper::<f32>(&[\n        f32::INFINITY,\n        f32::NEGATIVE_INFINITY,\n        1.0,\n        -1.0,\n        2.0,\n        -2.0,\n        1.5,\n        -1.5,\n        0.5,\n        -0.5,\n        1.25,\n        -1.25,\n        3.0,\n        -3.0,\n        1.75,\n        -1.75,\n        4.0,\n        -4.0,\n        1.125,\n        -1.125,\n        2.5,\n        -2.5,\n        1.375,\n        -1.375,\n        0.75,\n        -0.75,\n        1.625,\n        -1.625,\n        3.5,\n        -3.5,\n        1.875,\n        -1.875,\n        0.25,\n        -0.25,\n        1.0625,\n        -1.0625,\n        2.25,\n        -2.25,\n        1.1875,\n        -1.1875,\n        0.625,\n        -0.625,\n        1.3125,\n        -1.3125,\n        2.75,\n        -2.75,\n        1.4375,\n        -1.4375,\n        6.0,\n        -6.0,\n    ]);\n    exhaustive_nonzero_primitive_floats_helper::<f64>(&[\n        f64::INFINITY,\n        f64::NEGATIVE_INFINITY,\n        1.0,\n        -1.0,\n        2.0,\n        -2.0,\n        1.5,\n        -1.5,\n        0.5,\n        -0.5,\n        1.25,\n        -1.25,\n        3.0,\n        -3.0,\n        1.75,\n        -1.75,\n        4.0,\n        -4.0,\n        1.125,\n        -1.125,\n        2.5,\n        -2.5,\n        1.375,\n        -1.375,\n        0.75,\n        -0.75,\n        1.625,\n        -1.625,\n        3.5,\n        -3.5,\n        1.875,\n        -1.875,\n        0.25,\n        -0.25,\n        1.0625,\n        -1.0625,\n        2.25,\n        -2.25,\n        1.1875,\n        -1.1875,\n        0.625,\n        -0.625,\n        1.3125,\n        -1.3125,\n        2.75,\n        -2.75,\n        1.4375,\n        -1.4375,\n        6.0,\n        -6.0,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_nonzero_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::exhaustive::exhaustive_nonzero_signeds;\n\nfn exhaustive_nonzero_signeds_helper<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n{\n    assert_eq!(\n        exhaustive_nonzero_signeds::<T>()\n            .map(i8::exact_from)\n            .take(20)\n            .collect_vec(),\n        &[1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n    );\n}\n\nfn exhaustive_nonzero_signeds_long_helper<T: PrimitiveSigned>(last_20: &[T]) {\n    let expected_len = usize::power_of_2(T::WIDTH) - 1;\n    let xs = exhaustive_nonzero_signeds::<T>();\n    assert_eq!(xs.clone().count(), expected_len);\n    assert_eq!(xs.skip(expected_len - 20).collect_vec(), last_20);\n}\n\n#[test]\nfn test_exhaustive_nonzero_signeds() {\n    apply_fn_to_signeds!(exhaustive_nonzero_signeds_helper);\n\n    exhaustive_nonzero_signeds_long_helper::<i8>(&[\n        -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126,\n        -126, 127, -127, -128,\n    ]);\n    exhaustive_nonzero_signeds_long_helper::<i16>(&[\n        -0x7ff6,\n        0x7ff7,\n        -0x7ff7,\n        0x7ff8,\n        -0x7ff8,\n        0x7ff9,\n        -0x7ff9,\n        0x7ffa,\n        -0x7ffa,\n        0x7ffb,\n        -0x7ffb,\n        0x7ffc,\n        -0x7ffc,\n        0x7ffd,\n        -0x7ffd,\n        i16::MAX - 1,\n        -0x7ffe,\n        i16::MAX,\n        i16::MIN + 1,\n        i16::MIN,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_positive_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_positive_finite_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_positive_finite_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(\n        exhaustive_positive_finite_primitive_floats::<T>(),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_positive_finite_primitive_floats() {\n    exhaustive_positive_finite_primitive_floats_helper::<f32>(&[\n        1.0, 2.0, 1.5, 0.5, 1.25, 3.0, 1.75, 4.0, 1.125, 2.5, 1.375, 0.75, 1.625, 3.5, 1.875, 0.25,\n        1.0625, 2.25, 1.1875, 0.625, 1.3125, 2.75, 1.4375, 6.0, 1.5625, 3.25, 1.6875, 0.875,\n        1.8125, 3.75, 1.9375, 8.0, 1.03125, 2.125, 1.09375, 0.5625, 1.15625, 2.375, 1.21875, 5.0,\n        1.28125, 2.625, 1.34375, 0.6875, 1.40625, 2.875, 1.46875, 0.375, 1.53125, 3.125,\n    ]);\n    exhaustive_positive_finite_primitive_floats_helper::<f64>(&[\n        1.0, 2.0, 1.5, 0.5, 1.25, 3.0, 1.75, 4.0, 1.125, 2.5, 1.375, 0.75, 1.625, 3.5, 1.875, 0.25,\n        1.0625, 2.25, 1.1875, 0.625, 1.3125, 2.75, 1.4375, 6.0, 1.5625, 3.25, 1.6875, 0.875,\n        1.8125, 3.75, 1.9375, 8.0, 1.03125, 2.125, 1.09375, 0.5625, 1.15625, 2.375, 1.21875, 5.0,\n        1.28125, 2.625, 1.34375, 0.6875, 1.40625, 2.875, 1.46875, 0.375, 1.53125, 3.125,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_positive_finite_primitive_floats_in_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_positive_finite_primitive_floats_in_range;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\nuse std::panic::catch_unwind;\n\nfn exhaustive_positive_finite_primitive_floats_in_range_helper<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    out: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper(\n        exhaustive_positive_finite_primitive_floats_in_range::<T>(a, b),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_positive_finite_primitive_floats_in_range() {\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f32>(5.0, 5.0, &[5.0]);\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f32>(\n        1.0,\n        6.0,\n        &[\n            1.0, 2.0, 1.5, 4.0, 1.25, 3.0, 1.75, 1.125, 1.375, 2.5, 1.625, 6.0, 1.875, 3.5, 1.0625,\n            2.25, 1.1875, 2.75, 1.3125, 5.0, 1.4375, 3.25, 1.5625, 1.6875, 1.8125, 3.75, 1.9375,\n            4.5, 1.03125, 2.125, 1.09375, 5.5, 1.15625, 2.375, 1.21875, 4.25, 1.28125, 2.625,\n            1.34375, 1.40625, 1.46875, 2.875, 1.53125, 4.75, 1.59375, 3.125, 1.65625, 3.375,\n            1.71875, 3.625,\n        ],\n    );\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f32>(\n        0.01,\n        100.0,\n        &[\n            1.0, 2.0, 1.5, 0.5, 1.25, 3.0, 1.75, 4.0, 1.125, 2.5, 1.375, 0.75, 1.625, 3.5, 1.875,\n            0.25, 1.0625, 2.25, 1.1875, 0.625, 1.3125, 2.75, 1.4375, 6.0, 1.5625, 3.25, 1.6875,\n            0.875, 1.8125, 3.75, 1.9375, 8.0, 1.03125, 2.125, 1.09375, 0.5625, 1.15625, 2.375,\n            1.21875, 5.0, 1.28125, 2.625, 1.34375, 0.6875, 1.40625, 2.875, 1.46875, 0.375, 1.53125,\n            3.125,\n        ],\n    );\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f32>(\n        255.9,\n        256.1,\n        &[\n            255.9375, 256.0, 255.90625, 255.96875, 255.92188, 256.0625, 255.95312, 256.03125,\n            255.98438, 256.09375, 255.91406, 255.92969, 255.94531, 256.01562, 255.96094, 255.97656,\n            255.99219, 256.04688, 255.90234, 255.91016, 255.91797, 256.07812, 255.92578, 256.0078,\n            255.9336, 256.02344, 255.9414, 255.94922, 255.95703, 256.03906, 255.96484, 256.0547,\n            255.97266, 256.0703, 255.98047, 255.98828, 255.9961, 256.08594, 255.90039, 256.0039,\n            255.9043, 256.01172, 255.9082, 255.91211, 255.91602, 256.01953, 255.91992, 255.92383,\n            255.92773, 256.02734,\n        ],\n    );\n\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f64>(5.0, 5.0, &[5.0]);\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f64>(\n        1.0,\n        6.0,\n        &[\n            1.0, 2.0, 1.5, 4.0, 1.25, 3.0, 1.75, 1.125, 1.375, 2.5, 1.625, 6.0, 1.875, 3.5, 1.0625,\n            2.25, 1.1875, 2.75, 1.3125, 5.0, 1.4375, 3.25, 1.5625, 1.6875, 1.8125, 3.75, 1.9375,\n            4.5, 1.03125, 2.125, 1.09375, 5.5, 1.15625, 2.375, 1.21875, 4.25, 1.28125, 2.625,\n            1.34375, 1.40625, 1.46875, 2.875, 1.53125, 4.75, 1.59375, 3.125, 1.65625, 3.375,\n            1.71875, 3.625,\n        ],\n    );\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f64>(\n        0.01,\n        100.0,\n        &[\n            1.0, 2.0, 1.5, 0.5, 1.25, 3.0, 1.75, 4.0, 1.125, 2.5, 1.375, 0.75, 1.625, 3.5, 1.875,\n            0.25, 1.0625, 2.25, 1.1875, 0.625, 1.3125, 2.75, 1.4375, 6.0, 1.5625, 3.25, 1.6875,\n            0.875, 1.8125, 3.75, 1.9375, 8.0, 1.03125, 2.125, 1.09375, 0.5625, 1.15625, 2.375,\n            1.21875, 5.0, 1.28125, 2.625, 1.34375, 0.6875, 1.40625, 2.875, 1.46875, 0.375, 1.53125,\n            3.125,\n        ],\n    );\n    exhaustive_positive_finite_primitive_floats_in_range_helper::<f64>(\n        255.9,\n        256.1,\n        &[\n            255.9375,\n            256.0,\n            255.90625,\n            255.96875,\n            255.921875,\n            256.0625,\n            255.953125,\n            256.03125,\n            255.984375,\n            256.09375,\n            255.9140625,\n            255.9296875,\n            255.9453125,\n            256.015625,\n            255.9609375,\n            255.9765625,\n            255.9921875,\n            256.046875,\n            255.90234375,\n            255.91015625,\n            255.91796875,\n            256.078125,\n            255.92578125,\n            256.0078125,\n            255.93359375,\n            256.0234375,\n            255.94140625,\n            255.94921875,\n            255.95703125,\n            256.0390625,\n            255.96484375,\n            256.0546875,\n            255.97265625,\n            256.0703125,\n            255.98046875,\n            255.98828125,\n            255.99609375,\n            256.0859375,\n            255.900390625,\n            256.00390625,\n            255.904296875,\n            256.01171875,\n            255.908203125,\n            255.912109375,\n            255.916015625,\n            256.01953125,\n            255.919921875,\n            255.923828125,\n            255.927734375,\n            256.02734375,\n        ],\n    );\n}\n\nfn exhaustive_positive_finite_primitive_floats_in_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(exhaustive_positive_finite_primitive_floats_in_range::<T>(\n        T::from(1.2),\n        T::from(1.1),\n    ));\n    assert_panic!(exhaustive_positive_finite_primitive_floats_in_range::<T>(\n        T::from(-1.1),\n        T::from(1.1),\n    ));\n    assert_panic!(exhaustive_positive_finite_primitive_floats_in_range::<T>(\n        T::ONE,\n        T::INFINITY,\n    ));\n    assert_panic!(exhaustive_positive_finite_primitive_floats_in_range::<T>(\n        T::ONE,\n        T::NAN,\n    ));\n}\n\n#[test]\nfn exhaustive_positive_finite_primitive_floats_in_range_fail() {\n    apply_fn_to_primitive_floats!(exhaustive_positive_finite_primitive_floats_in_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_positive_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_positive_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_positive_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(exhaustive_positive_primitive_floats::<T>(), out);\n}\n\n#[test]\nfn test_exhaustive_positive_primitive_floats() {\n    exhaustive_positive_primitive_floats_helper::<f32>(&[\n        f32::INFINITY,\n        1.0,\n        2.0,\n        1.5,\n        0.5,\n        1.25,\n        3.0,\n        1.75,\n        4.0,\n        1.125,\n        2.5,\n        1.375,\n        0.75,\n        1.625,\n        3.5,\n        1.875,\n        0.25,\n        1.0625,\n        2.25,\n        1.1875,\n        0.625,\n        1.3125,\n        2.75,\n        1.4375,\n        6.0,\n        1.5625,\n        3.25,\n        1.6875,\n        0.875,\n        1.8125,\n        3.75,\n        1.9375,\n        8.0,\n        1.03125,\n        2.125,\n        1.09375,\n        0.5625,\n        1.15625,\n        2.375,\n        1.21875,\n        5.0,\n        1.28125,\n        2.625,\n        1.34375,\n        0.6875,\n        1.40625,\n        2.875,\n        1.46875,\n        0.375,\n        1.53125,\n    ]);\n    exhaustive_positive_primitive_floats_helper::<f64>(&[\n        f64::INFINITY,\n        1.0,\n        2.0,\n        1.5,\n        0.5,\n        1.25,\n        3.0,\n        1.75,\n        4.0,\n        1.125,\n        2.5,\n        1.375,\n        0.75,\n        1.625,\n        3.5,\n        1.875,\n        0.25,\n        1.0625,\n        2.25,\n        1.1875,\n        0.625,\n        1.3125,\n        2.75,\n        1.4375,\n        6.0,\n        1.5625,\n        3.25,\n        1.6875,\n        0.875,\n        1.8125,\n        3.75,\n        1.9375,\n        8.0,\n        1.03125,\n        2.125,\n        1.09375,\n        0.5625,\n        1.15625,\n        2.375,\n        1.21875,\n        5.0,\n        1.28125,\n        2.625,\n        1.34375,\n        0.6875,\n        1.40625,\n        2.875,\n        1.46875,\n        0.375,\n        1.53125,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_positive_primitive_ints.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::exhaustive::exhaustive_positive_primitive_ints;\n\nfn exhaustive_positive_primitive_ints_helper<T: PrimitiveInt>()\nwhere\n    u8: ExactFrom<T>,\n{\n    assert_eq!(\n        exhaustive_positive_primitive_ints::<T>()\n            .map(u8::exact_from)\n            .take(20)\n            .collect_vec(),\n        &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n    );\n}\n\nfn exhaustive_positive_primitive_ints_long_helper<T: PrimitiveInt>(last_20: &[T]) {\n    let expected_len = if T::MIN == T::ZERO {\n        usize::power_of_2(T::WIDTH) - 1\n    } else {\n        usize::power_of_2(T::WIDTH - 1) - 1\n    };\n    let xs = exhaustive_positive_primitive_ints::<T>();\n    assert_eq!(xs.clone().count(), expected_len);\n    assert_eq!(xs.skip(expected_len - 20).collect_vec(), last_20);\n}\n\n#[test]\nfn test_exhaustive_positive_primitive_ints() {\n    apply_fn_to_primitive_ints!(exhaustive_positive_primitive_ints_helper);\n\n    exhaustive_positive_primitive_ints_long_helper::<u8>(&[\n        236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253,\n        254, 255,\n    ]);\n    exhaustive_positive_primitive_ints_long_helper::<i8>(&[\n        108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,\n        126, 127,\n    ]);\n    exhaustive_positive_primitive_ints_long_helper::<u16>(&[\n        65516,\n        65517,\n        65518,\n        65519,\n        0xfff0,\n        0xfff1,\n        0xfff2,\n        0xfff3,\n        0xfff4,\n        0xfff5,\n        0xfff6,\n        0xfff7,\n        0xfff8,\n        0xfff9,\n        0xfffa,\n        0xfffb,\n        0xfffc,\n        0xfffd,\n        u16::MAX - 1,\n        u16::MAX,\n    ]);\n    exhaustive_positive_primitive_ints_long_helper::<i16>(&[\n        32748,\n        32749,\n        32750,\n        32751,\n        0x7ff0,\n        0x7ff1,\n        0x7ff2,\n        0x7ff3,\n        0x7ff4,\n        0x7ff5,\n        0x7ff6,\n        0x7ff7,\n        0x7ff8,\n        0x7ff9,\n        0x7ffa,\n        0x7ffb,\n        0x7ffc,\n        0x7ffd,\n        i16::MAX - 1,\n        i16::MAX,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_primitive_float_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::exhaustive_primitive_float_inclusive_range;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\nuse std::panic::catch_unwind;\n\nfn exhaustive_primitive_float_inclusive_range_helper<T: PrimitiveFloat>(a: T, b: T, out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(\n        exhaustive_primitive_float_inclusive_range::<T>(a, b),\n        out,\n    );\n}\n\n#[allow(clippy::approx_constant)]\n#[test]\nfn test_exhaustive_primitive_float_inclusive_range() {\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(1.0, 1.0, &[1.0]);\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        1.0,\n        2.0,\n        &[\n            1.0, 2.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, 1.28125, 1.34375,\n            1.40625, 1.46875, 1.53125, 1.59375, 1.65625, 1.71875, 1.78125, 1.84375, 1.90625,\n            1.96875, 1.015625, 1.046875, 1.078125, 1.109375, 1.140625, 1.171875, 1.203125,\n            1.234375, 1.265625, 1.296875, 1.328125, 1.359375, 1.390625, 1.421875, 1.453125,\n            1.484375, 1.515625,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        -0.1,\n        0.1,\n        &[\n            0.0,\n            -0.0,\n            0.0625,\n            -0.0625,\n            0.03125,\n            -0.03125,\n            0.09375,\n            -0.09375,\n            0.015625,\n            -0.015625,\n            0.078125,\n            -0.078125,\n            0.046875,\n            -0.046875,\n            0.0703125,\n            -0.0703125,\n            0.0078125,\n            -0.0078125,\n            0.0859375,\n            -0.0859375,\n            0.0390625,\n            -0.0390625,\n            0.06640625,\n            -0.06640625,\n            0.0234375,\n            -0.0234375,\n            0.07421875,\n            -0.07421875,\n            0.0546875,\n            -0.0546875,\n            0.08203125,\n            -0.08203125,\n            0.00390625,\n            -0.00390625,\n            0.08984375,\n            -0.08984375,\n            0.03515625,\n            -0.03515625,\n            0.09765625,\n            -0.09765625,\n            0.01953125,\n            -0.01953125,\n            0.064453125,\n            -0.064453125,\n            0.04296875,\n            -0.04296875,\n            0.068359375,\n            -0.068359375,\n            0.01171875,\n            -0.01171875,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        100.0,\n        101.0,\n        &[\n            100.0, 101.0, 100.5, 100.25, 100.75, 100.125, 100.375, 100.625, 100.875, 100.0625,\n            100.1875, 100.3125, 100.4375, 100.5625, 100.6875, 100.8125, 100.9375, 100.03125,\n            100.09375, 100.15625, 100.21875, 100.28125, 100.34375, 100.40625, 100.46875, 100.53125,\n            100.59375, 100.65625, 100.71875, 100.78125, 100.84375, 100.90625, 100.96875,\n            100.015625, 100.046875, 100.078125, 100.109375, 100.140625, 100.171875, 100.203125,\n            100.234375, 100.265625, 100.296875, 100.328125, 100.359375, 100.390625, 100.421875,\n            100.453125, 100.484375, 100.515625,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        &[\n            f32::INFINITY,\n            1.2760589e38,\n            1.7014118e38,\n            1.0633824e38,\n            1.4887354e38,\n            1.1697206e38,\n            2.5521178e38,\n            1.3823971e38,\n            2.1267648e38,\n            1.5950736e38,\n            2.9774707e38,\n            1.0102133e38,\n            1.1165515e38,\n            1.2228898e38,\n            1.9140883e38,\n            1.329228e38,\n            1.4355662e38,\n            1.5419045e38,\n            2.3394413e38,\n            1.6482427e38,\n            1.0367978e38,\n            1.089967e38,\n            2.7647942e38,\n            1.1431361e38,\n            3.1901472e38,\n            1.1963052e38,\n            1.80775e38,\n            1.2494743e38,\n            1.3026434e38,\n            1.3558126e38,\n            2.0204266e38,\n            1.4089817e38,\n            2.233103e38,\n            1.4621508e38,\n            2.4457795e38,\n            1.5153199e38,\n            1.568489e38,\n            1.6216582e38,\n            2.658456e38,\n            1.6748273e38,\n            2.8711325e38,\n            1.0235056e38,\n            3.083809e38,\n            1.0500901e38,\n            1.0766747e38,\n            1.1032592e38,\n            3.2964854e38,\n            1.1298438e38,\n            1.1564284e38,\n            1.1830129e38,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, -0.0, 1.0e-45, -1.0e-45],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        -0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, -0.0, 1.0e-45],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, 1.0e-45],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        &[-0.0, -1.0e-45],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[0.0, -0.0, -1.0e-45],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        &[\n            f32::INFINITY,\n            f32::NEGATIVE_INFINITY,\n            0.0,\n            -0.0,\n            1.0,\n            -1.0,\n            2.0,\n            -2.0,\n            1.5,\n            -1.5,\n            0.5,\n            -0.5,\n            1.25,\n            -1.25,\n            3.0,\n            -3.0,\n            1.75,\n            -1.75,\n            4.0,\n            -4.0,\n            1.125,\n            -1.125,\n            2.5,\n            -2.5,\n            1.375,\n            -1.375,\n            0.75,\n            -0.75,\n            1.625,\n            -1.625,\n            3.5,\n            -3.5,\n            1.875,\n            -1.875,\n            0.25,\n            -0.25,\n            1.0625,\n            -1.0625,\n            2.25,\n            -2.25,\n            1.1875,\n            -1.1875,\n            0.625,\n            -0.625,\n            1.3125,\n            -1.3125,\n            2.75,\n            -2.75,\n            1.4375,\n            -1.4375,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        &[f32::NEGATIVE_INFINITY],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(\n        f32::INFINITY,\n        f32::INFINITY,\n        &[f32::INFINITY],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(0.0, 0.0, &[0.0]);\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(-0.0, -0.0, &[-0.0]);\n    exhaustive_primitive_float_inclusive_range_helper::<f32>(-0.0, 0.0, &[0.0, -0.0]);\n\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(1.0, 1.0, &[1.0]);\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        1.0,\n        2.0,\n        &[\n            1.0, 2.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, 1.28125, 1.34375,\n            1.40625, 1.46875, 1.53125, 1.59375, 1.65625, 1.71875, 1.78125, 1.84375, 1.90625,\n            1.96875, 1.015625, 1.046875, 1.078125, 1.109375, 1.140625, 1.171875, 1.203125,\n            1.234375, 1.265625, 1.296875, 1.328125, 1.359375, 1.390625, 1.421875, 1.453125,\n            1.484375, 1.515625,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        -0.1,\n        0.1,\n        &[\n            0.0,\n            -0.0,\n            0.0625,\n            -0.0625,\n            0.03125,\n            -0.03125,\n            0.09375,\n            -0.09375,\n            0.015625,\n            -0.015625,\n            0.078125,\n            -0.078125,\n            0.046875,\n            -0.046875,\n            0.0703125,\n            -0.0703125,\n            0.0078125,\n            -0.0078125,\n            0.0859375,\n            -0.0859375,\n            0.0390625,\n            -0.0390625,\n            0.06640625,\n            -0.06640625,\n            0.0234375,\n            -0.0234375,\n            0.07421875,\n            -0.07421875,\n            0.0546875,\n            -0.0546875,\n            0.08203125,\n            -0.08203125,\n            0.00390625,\n            -0.00390625,\n            0.08984375,\n            -0.08984375,\n            0.03515625,\n            -0.03515625,\n            0.09765625,\n            -0.09765625,\n            0.01953125,\n            -0.01953125,\n            0.064453125,\n            -0.064453125,\n            0.04296875,\n            -0.04296875,\n            0.068359375,\n            -0.068359375,\n            0.01171875,\n            -0.01171875,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        100.0,\n        101.0,\n        &[\n            100.0, 101.0, 100.5, 100.25, 100.75, 100.125, 100.375, 100.625, 100.875, 100.0625,\n            100.1875, 100.3125, 100.4375, 100.5625, 100.6875, 100.8125, 100.9375, 100.03125,\n            100.09375, 100.15625, 100.21875, 100.28125, 100.34375, 100.40625, 100.46875, 100.53125,\n            100.59375, 100.65625, 100.71875, 100.78125, 100.84375, 100.90625, 100.96875,\n            100.015625, 100.046875, 100.078125, 100.109375, 100.140625, 100.171875, 100.203125,\n            100.234375, 100.265625, 100.296875, 100.328125, 100.359375, 100.390625, 100.421875,\n            100.453125, 100.484375, 100.515625,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        1.0e308,\n        f64::INFINITY,\n        &[\n            f64::INFINITY,\n            1.348269851146737e308,\n            1.1235582092889474e308,\n            1.5729814930045264e308,\n            1.0112023883600527e308,\n            1.2359140302178422e308,\n            1.4606256720756317e308,\n            1.6853373139334212e308,\n            1.0673802988245e308,\n            1.1797361197533948e308,\n            1.2920919406822896e308,\n            1.4044477616111843e308,\n            1.516803582540079e308,\n            1.6291594034689738e308,\n            1.7415152243978685e308,\n            1.0392913435922764e308,\n            1.0954692540567238e308,\n            1.1516471645211711e308,\n            1.2078250749856185e308,\n            1.2640029854500659e308,\n            1.3201808959145132e308,\n            1.3763588063789606e308,\n            1.432536716843408e308,\n            1.4887146273078554e308,\n            1.5448925377723027e308,\n            1.6010704482367501e308,\n            1.6572483587011975e308,\n            1.7134262691656448e308,\n            1.7696041796300922e308,\n            1.0252468659761645e308,\n            1.0533358212083882e308,\n            1.081424776440612e308,\n            1.1095137316728356e308,\n            1.1376026869050593e308,\n            1.165691642137283e308,\n            1.1937805973695067e308,\n            1.2218695526017303e308,\n            1.249958507833954e308,\n            1.2780474630661777e308,\n            1.3061364182984014e308,\n            1.334225373530625e308,\n            1.3623143287628488e308,\n            1.3904032839950725e308,\n            1.4184922392272961e308,\n            1.4465811944595198e308,\n            1.4746701496917435e308,\n            1.5027591049239672e308,\n            1.5308480601561909e308,\n            1.5589370153884146e308,\n            1.5870259706206383e308,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, -0.0, 5.0e-324, -5.0e-324],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        -0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, -0.0, 5.0e-324],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, 5.0e-324],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        &[-0.0, -5.0e-324],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[0.0, -0.0, -5.0e-324],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        &[\n            f64::INFINITY,\n            f64::NEGATIVE_INFINITY,\n            0.0,\n            -0.0,\n            1.0,\n            -1.0,\n            2.0,\n            -2.0,\n            1.5,\n            -1.5,\n            0.5,\n            -0.5,\n            1.25,\n            -1.25,\n            3.0,\n            -3.0,\n            1.75,\n            -1.75,\n            4.0,\n            -4.0,\n            1.125,\n            -1.125,\n            2.5,\n            -2.5,\n            1.375,\n            -1.375,\n            0.75,\n            -0.75,\n            1.625,\n            -1.625,\n            3.5,\n            -3.5,\n            1.875,\n            -1.875,\n            0.25,\n            -0.25,\n            1.0625,\n            -1.0625,\n            2.25,\n            -2.25,\n            1.1875,\n            -1.1875,\n            0.625,\n            -0.625,\n            1.3125,\n            -1.3125,\n            2.75,\n            -2.75,\n            1.4375,\n            -1.4375,\n        ],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        &[f64::NEGATIVE_INFINITY],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(\n        f64::INFINITY,\n        f64::INFINITY,\n        &[f64::INFINITY],\n    );\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(0.0, 0.0, &[0.0]);\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(-0.0, -0.0, &[-0.0]);\n    exhaustive_primitive_float_inclusive_range_helper::<f64>(-0.0, 0.0, &[0.0, -0.0]);\n}\n\nfn exhaustive_primitive_float_inclusive_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(exhaustive_primitive_float_inclusive_range::<T>(\n        T::ONE,\n        T::ZERO\n    ));\n    assert_panic!(exhaustive_primitive_float_inclusive_range::<T>(\n        T::ONE,\n        T::NAN\n    ));\n}\n\n#[test]\nfn exhaustive_primitive_float_inclusive_range_fail() {\n    apply_fn_to_primitive_floats!(exhaustive_primitive_float_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_primitive_float_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::exhaustive_primitive_float_range;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\nuse std::panic::catch_unwind;\n\nfn exhaustive_primitive_float_range_helper<T: PrimitiveFloat>(a: T, b: T, out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(exhaustive_primitive_float_range::<T>(a, b), out);\n}\n\n#[allow(clippy::approx_constant)]\n#[test]\nfn test_exhaustive_primitive_float_range() {\n    exhaustive_primitive_float_range_helper::<f32>(1.0, 1.0, &[]);\n    exhaustive_primitive_float_range_helper::<f32>(\n        1.0,\n        2.0,\n        &[\n            1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, 1.28125, 1.34375,\n            1.40625, 1.46875, 1.53125, 1.59375, 1.65625, 1.71875, 1.78125, 1.84375, 1.90625,\n            1.96875, 1.015625, 1.046875, 1.078125, 1.109375, 1.140625, 1.171875, 1.203125,\n            1.234375, 1.265625, 1.296875, 1.328125, 1.359375, 1.390625, 1.421875, 1.453125,\n            1.484375, 1.515625, 1.546875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(\n        -0.1,\n        0.1,\n        &[\n            0.0,\n            -0.0,\n            0.0625,\n            -0.0625,\n            0.03125,\n            -0.03125,\n            0.09375,\n            -0.09375,\n            0.015625,\n            -0.015625,\n            0.078125,\n            -0.078125,\n            0.046875,\n            -0.046875,\n            0.0703125,\n            -0.0703125,\n            0.0078125,\n            -0.0078125,\n            0.0859375,\n            -0.0859375,\n            0.0390625,\n            -0.0390625,\n            0.06640625,\n            -0.06640625,\n            0.0234375,\n            -0.0234375,\n            0.07421875,\n            -0.07421875,\n            0.0546875,\n            -0.0546875,\n            0.08203125,\n            -0.08203125,\n            0.00390625,\n            -0.00390625,\n            0.08984375,\n            -0.08984375,\n            0.03515625,\n            -0.03515625,\n            0.09765625,\n            -0.09765625,\n            0.01953125,\n            -0.01953125,\n            0.064453125,\n            -0.064453125,\n            0.04296875,\n            -0.04296875,\n            0.068359375,\n            -0.068359375,\n            0.01171875,\n            -0.01171875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(\n        100.0,\n        101.0,\n        &[\n            100.0, 100.5, 100.25, 100.75, 100.125, 100.375, 100.625, 100.875, 100.0625, 100.1875,\n            100.3125, 100.4375, 100.5625, 100.6875, 100.8125, 100.9375, 100.03125, 100.09375,\n            100.15625, 100.21875, 100.28125, 100.34375, 100.40625, 100.46875, 100.53125, 100.59375,\n            100.65625, 100.71875, 100.78125, 100.84375, 100.90625, 100.96875, 100.015625,\n            100.046875, 100.078125, 100.109375, 100.140625, 100.171875, 100.203125, 100.234375,\n            100.265625, 100.296875, 100.328125, 100.359375, 100.390625, 100.421875, 100.453125,\n            100.484375, 100.515625, 100.546875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        &[\n            1.2760589e38,\n            1.7014118e38,\n            1.0633824e38,\n            1.4887354e38,\n            1.1697206e38,\n            2.5521178e38,\n            1.3823971e38,\n            2.1267648e38,\n            1.5950736e38,\n            2.9774707e38,\n            1.0102133e38,\n            1.1165515e38,\n            1.2228898e38,\n            1.9140883e38,\n            1.329228e38,\n            1.4355662e38,\n            1.5419045e38,\n            2.3394413e38,\n            1.6482427e38,\n            1.0367978e38,\n            1.089967e38,\n            2.7647942e38,\n            1.1431361e38,\n            3.1901472e38,\n            1.1963052e38,\n            1.80775e38,\n            1.2494743e38,\n            1.3026434e38,\n            1.3558126e38,\n            2.0204266e38,\n            1.4089817e38,\n            2.233103e38,\n            1.4621508e38,\n            2.4457795e38,\n            1.5153199e38,\n            1.568489e38,\n            1.6216582e38,\n            2.658456e38,\n            1.6748273e38,\n            2.8711325e38,\n            1.0235056e38,\n            3.083809e38,\n            1.0500901e38,\n            1.0766747e38,\n            1.1032592e38,\n            3.2964854e38,\n            1.1298438e38,\n            1.1564284e38,\n            1.1830129e38,\n            1.754581e38,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, -0.0, -1.0e-45],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(-0.0, f32::MIN_POSITIVE_SUBNORMAL, &[0.0, -0.0]);\n    exhaustive_primitive_float_range_helper::<f32>(0.0, f32::MIN_POSITIVE_SUBNORMAL, &[0.0]);\n    exhaustive_primitive_float_range_helper::<f32>(-f32::MIN_POSITIVE_SUBNORMAL, -0.0, &[-1.0e-45]);\n    exhaustive_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[-0.0, -1.0e-45],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        &[\n            f32::NEGATIVE_INFINITY,\n            0.0,\n            -0.0,\n            1.0,\n            -1.0,\n            2.0,\n            -2.0,\n            1.5,\n            -1.5,\n            0.5,\n            -0.5,\n            1.25,\n            -1.25,\n            3.0,\n            -3.0,\n            1.75,\n            -1.75,\n            4.0,\n            -4.0,\n            1.125,\n            -1.125,\n            2.5,\n            -2.5,\n            1.375,\n            -1.375,\n            0.75,\n            -0.75,\n            1.625,\n            -1.625,\n            3.5,\n            -3.5,\n            1.875,\n            -1.875,\n            0.25,\n            -0.25,\n            1.0625,\n            -1.0625,\n            2.25,\n            -2.25,\n            1.1875,\n            -1.1875,\n            0.625,\n            -0.625,\n            1.3125,\n            -1.3125,\n            2.75,\n            -2.75,\n            1.4375,\n            -1.4375,\n            6.0,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        &[],\n    );\n    exhaustive_primitive_float_range_helper::<f32>(f32::INFINITY, f32::INFINITY, &[]);\n    exhaustive_primitive_float_range_helper::<f32>(0.0, 0.0, &[]);\n    exhaustive_primitive_float_range_helper::<f32>(-0.0, -0.0, &[]);\n    exhaustive_primitive_float_range_helper::<f32>(-0.0, 0.0, &[-0.0]);\n\n    exhaustive_primitive_float_range_helper::<f64>(1.0, 1.0, &[]);\n    exhaustive_primitive_float_range_helper::<f64>(\n        1.0,\n        2.0,\n        &[\n            1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, 1.28125, 1.34375,\n            1.40625, 1.46875, 1.53125, 1.59375, 1.65625, 1.71875, 1.78125, 1.84375, 1.90625,\n            1.96875, 1.015625, 1.046875, 1.078125, 1.109375, 1.140625, 1.171875, 1.203125,\n            1.234375, 1.265625, 1.296875, 1.328125, 1.359375, 1.390625, 1.421875, 1.453125,\n            1.484375, 1.515625, 1.546875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        -0.1,\n        0.1,\n        &[\n            0.0,\n            -0.0,\n            0.0625,\n            -0.0625,\n            0.03125,\n            -0.03125,\n            0.09375,\n            -0.09375,\n            0.015625,\n            -0.015625,\n            0.078125,\n            -0.078125,\n            0.046875,\n            -0.046875,\n            0.0703125,\n            -0.0703125,\n            0.0078125,\n            -0.0078125,\n            0.0859375,\n            -0.0859375,\n            0.0390625,\n            -0.0390625,\n            0.06640625,\n            -0.06640625,\n            0.0234375,\n            -0.0234375,\n            0.07421875,\n            -0.07421875,\n            0.0546875,\n            -0.0546875,\n            0.08203125,\n            -0.08203125,\n            0.00390625,\n            -0.00390625,\n            0.08984375,\n            -0.08984375,\n            0.03515625,\n            -0.03515625,\n            0.09765625,\n            -0.09765625,\n            0.01953125,\n            -0.01953125,\n            0.064453125,\n            -0.064453125,\n            0.04296875,\n            -0.04296875,\n            0.068359375,\n            -0.068359375,\n            0.01171875,\n            -0.01171875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        100.0,\n        101.0,\n        &[\n            100.0, 100.5, 100.25, 100.75, 100.125, 100.375, 100.625, 100.875, 100.0625, 100.1875,\n            100.3125, 100.4375, 100.5625, 100.6875, 100.8125, 100.9375, 100.03125, 100.09375,\n            100.15625, 100.21875, 100.28125, 100.34375, 100.40625, 100.46875, 100.53125, 100.59375,\n            100.65625, 100.71875, 100.78125, 100.84375, 100.90625, 100.96875, 100.015625,\n            100.046875, 100.078125, 100.109375, 100.140625, 100.171875, 100.203125, 100.234375,\n            100.265625, 100.296875, 100.328125, 100.359375, 100.390625, 100.421875, 100.453125,\n            100.484375, 100.515625, 100.546875,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        1.0e308,\n        f64::INFINITY,\n        &[\n            1.348269851146737e308,\n            1.1235582092889474e308,\n            1.5729814930045264e308,\n            1.0112023883600527e308,\n            1.2359140302178422e308,\n            1.4606256720756317e308,\n            1.6853373139334212e308,\n            1.0673802988245e308,\n            1.1797361197533948e308,\n            1.2920919406822896e308,\n            1.4044477616111843e308,\n            1.516803582540079e308,\n            1.6291594034689738e308,\n            1.7415152243978685e308,\n            1.0392913435922764e308,\n            1.0954692540567238e308,\n            1.1516471645211711e308,\n            1.2078250749856185e308,\n            1.2640029854500659e308,\n            1.3201808959145132e308,\n            1.3763588063789606e308,\n            1.432536716843408e308,\n            1.4887146273078554e308,\n            1.5448925377723027e308,\n            1.6010704482367501e308,\n            1.6572483587011975e308,\n            1.7134262691656448e308,\n            1.7696041796300922e308,\n            1.0252468659761645e308,\n            1.0533358212083882e308,\n            1.081424776440612e308,\n            1.1095137316728356e308,\n            1.1376026869050593e308,\n            1.165691642137283e308,\n            1.1937805973695067e308,\n            1.2218695526017303e308,\n            1.249958507833954e308,\n            1.2780474630661777e308,\n            1.3061364182984014e308,\n            1.334225373530625e308,\n            1.3623143287628488e308,\n            1.3904032839950725e308,\n            1.4184922392272961e308,\n            1.4465811944595198e308,\n            1.4746701496917435e308,\n            1.5027591049239672e308,\n            1.5308480601561909e308,\n            1.5589370153884146e308,\n            1.5870259706206383e308,\n            1.615114925852862e308,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, -0.0, -5.0e-324],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(-0.0, f64::MIN_POSITIVE_SUBNORMAL, &[0.0, -0.0]);\n    exhaustive_primitive_float_range_helper::<f64>(0.0, f64::MIN_POSITIVE_SUBNORMAL, &[0.0]);\n    exhaustive_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        &[-5.0e-324],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[-0.0, -5.0e-324],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        &[\n            f64::NEGATIVE_INFINITY,\n            0.0,\n            -0.0,\n            1.0,\n            -1.0,\n            2.0,\n            -2.0,\n            1.5,\n            -1.5,\n            0.5,\n            -0.5,\n            1.25,\n            -1.25,\n            3.0,\n            -3.0,\n            1.75,\n            -1.75,\n            4.0,\n            -4.0,\n            1.125,\n            -1.125,\n            2.5,\n            -2.5,\n            1.375,\n            -1.375,\n            0.75,\n            -0.75,\n            1.625,\n            -1.625,\n            3.5,\n            -3.5,\n            1.875,\n            -1.875,\n            0.25,\n            -0.25,\n            1.0625,\n            -1.0625,\n            2.25,\n            -2.25,\n            1.1875,\n            -1.1875,\n            0.625,\n            -0.625,\n            1.3125,\n            -1.3125,\n            2.75,\n            -2.75,\n            1.4375,\n            -1.4375,\n            6.0,\n        ],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        &[],\n    );\n    exhaustive_primitive_float_range_helper::<f64>(f64::INFINITY, f64::INFINITY, &[]);\n    exhaustive_primitive_float_range_helper::<f64>(0.0, 0.0, &[]);\n    exhaustive_primitive_float_range_helper::<f64>(-0.0, -0.0, &[]);\n    exhaustive_primitive_float_range_helper::<f64>(-0.0, 0.0, &[-0.0]);\n}\n\nfn exhaustive_primitive_float_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(exhaustive_primitive_float_range::<T>(T::ONE, T::ZERO));\n    assert_panic!(exhaustive_primitive_float_range::<T>(T::ONE, T::NAN));\n}\n\n#[test]\nfn exhaustive_primitive_float_range_fail() {\n    apply_fn_to_primitive_floats!(exhaustive_primitive_float_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::exhaustive_primitive_floats;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\n\nfn exhaustive_primitive_floats_helper<T: PrimitiveFloat>(out: &[T]) {\n    exhaustive_primitive_floats_helper_helper(exhaustive_primitive_floats::<T>(), out);\n}\n\n#[test]\nfn test_exhaustive_primitive_floats() {\n    exhaustive_primitive_floats_helper::<f32>(&[\n        f32::NAN,\n        f32::INFINITY,\n        f32::NEGATIVE_INFINITY,\n        0.0,\n        -0.0,\n        1.0,\n        -1.0,\n        2.0,\n        -2.0,\n        1.5,\n        -1.5,\n        0.5,\n        -0.5,\n        1.25,\n        -1.25,\n        3.0,\n        -3.0,\n        1.75,\n        -1.75,\n        4.0,\n        -4.0,\n        1.125,\n        -1.125,\n        2.5,\n        -2.5,\n        1.375,\n        -1.375,\n        0.75,\n        -0.75,\n        1.625,\n        -1.625,\n        3.5,\n        -3.5,\n        1.875,\n        -1.875,\n        0.25,\n        -0.25,\n        1.0625,\n        -1.0625,\n        2.25,\n        -2.25,\n        1.1875,\n        -1.1875,\n        0.625,\n        -0.625,\n        1.3125,\n        -1.3125,\n        2.75,\n        -2.75,\n        1.4375,\n    ]);\n    exhaustive_primitive_floats_helper::<f64>(&[\n        f64::NAN,\n        f64::INFINITY,\n        f64::NEGATIVE_INFINITY,\n        0.0,\n        -0.0,\n        1.0,\n        -1.0,\n        2.0,\n        -2.0,\n        1.5,\n        -1.5,\n        0.5,\n        -0.5,\n        1.25,\n        -1.25,\n        3.0,\n        -3.0,\n        1.75,\n        -1.75,\n        4.0,\n        -4.0,\n        1.125,\n        -1.125,\n        2.5,\n        -2.5,\n        1.375,\n        -1.375,\n        0.75,\n        -0.75,\n        1.625,\n        -1.625,\n        3.5,\n        -3.5,\n        1.875,\n        -1.875,\n        0.25,\n        -0.25,\n        1.0625,\n        -1.0625,\n        2.25,\n        -2.25,\n        1.1875,\n        -1.1875,\n        0.625,\n        -0.625,\n        1.3125,\n        -1.3125,\n        2.75,\n        -2.75,\n        1.4375,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_primitive_floats_with_sci_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_primitive_floats_with_sci_exponent;\nuse malachite_base::test_util::num::exhaustive::*;\nuse std::panic::catch_unwind;\n\nfn exhaustive_primitive_floats_with_sci_exponent_helper<T: PrimitiveFloat>(\n    sci_exponent: i64,\n    out: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_limit(\n        20,\n        exhaustive_primitive_floats_with_sci_exponent::<T>(sci_exponent),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_primitive_floats_with_sci_exponent() {\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f32>(\n        0,\n        &[\n            1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f32>(\n        4,\n        &[\n            16.0, 24.0, 20.0, 28.0, 18.0, 22.0, 26.0, 30.0, 17.0, 19.0, 21.0, 23.0, 25.0, 27.0,\n            29.0, 31.0, 16.5, 17.5, 18.5, 19.5,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f32>(\n        -4,\n        &[\n            0.0625,\n            0.09375,\n            0.078125,\n            0.109375,\n            0.0703125,\n            0.0859375,\n            0.1015625,\n            0.1171875,\n            0.06640625,\n            0.07421875,\n            0.08203125,\n            0.08984375,\n            0.09765625,\n            0.10546875,\n            0.11328125,\n            0.12109375,\n            0.064453125,\n            0.068359375,\n            0.072265625,\n            0.076171875,\n        ],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f32>(-149, &[1.0e-45]);\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f32>(-148, &[3.0e-45, 4.0e-45]);\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f32>(\n        -147,\n        &[6.0e-45, 8.0e-45, 7.0e-45, 1.0e-44],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f32>(\n        127,\n        &[\n            1.7014118e38,\n            2.5521178e38,\n            2.1267648e38,\n            2.9774707e38,\n            1.9140883e38,\n            2.3394413e38,\n            2.7647942e38,\n            3.1901472e38,\n            1.80775e38,\n            2.0204266e38,\n            2.233103e38,\n            2.4457795e38,\n            2.658456e38,\n            2.8711325e38,\n            3.083809e38,\n            3.2964854e38,\n            1.754581e38,\n            1.8609192e38,\n            1.9672574e38,\n            2.0735957e38,\n        ],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f64>(\n        0,\n        &[\n            1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f64>(\n        4,\n        &[\n            16.0, 24.0, 20.0, 28.0, 18.0, 22.0, 26.0, 30.0, 17.0, 19.0, 21.0, 23.0, 25.0, 27.0,\n            29.0, 31.0, 16.5, 17.5, 18.5, 19.5,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f64>(\n        -4,\n        &[\n            0.0625,\n            0.09375,\n            0.078125,\n            0.109375,\n            0.0703125,\n            0.0859375,\n            0.1015625,\n            0.1171875,\n            0.06640625,\n            0.07421875,\n            0.08203125,\n            0.08984375,\n            0.09765625,\n            0.10546875,\n            0.11328125,\n            0.12109375,\n            0.064453125,\n            0.068359375,\n            0.072265625,\n            0.076171875,\n        ],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f64>(-1074, &[5.0e-324]);\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f64>(-1073, &[1.0e-323, 1.5e-323]);\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f64>(\n        -1072,\n        &[2.0e-323, 3.0e-323, 2.5e-323, 3.5e-323],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_helper::<f64>(\n        1023,\n        &[\n            8.98846567431158e307,\n            1.348269851146737e308,\n            1.1235582092889474e308,\n            1.5729814930045264e308,\n            1.0112023883600527e308,\n            1.2359140302178422e308,\n            1.4606256720756317e308,\n            1.6853373139334212e308,\n            9.550244778956053e307,\n            1.0673802988245e308,\n            1.1797361197533948e308,\n            1.2920919406822896e308,\n            1.4044477616111843e308,\n            1.516803582540079e308,\n            1.6291594034689738e308,\n            1.7415152243978685e308,\n            9.269355226633816e307,\n            9.83113433127829e307,\n            1.0392913435922764e308,\n            1.0954692540567238e308,\n        ],\n    );\n}\n\nfn exhaustive_primitive_floats_with_sci_exponent_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent::<T>(10000));\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent::<T>(-10000));\n}\n\n#[test]\nfn exhaustive_primitive_floats_with_sci_exponent_fail() {\n    apply_fn_to_primitive_floats!(exhaustive_primitive_floats_with_sci_exponent_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_primitive_floats_with_sci_exponent_and_precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_primitive_floats_with_sci_exponent_and_precision;\nuse malachite_base::test_util::num::exhaustive::*;\nuse std::panic::catch_unwind;\n\nfn exhaustive_primitive_floats_with_sci_exponent_and_precision_helper<T: PrimitiveFloat>(\n    sci_exponent: i64,\n    precision: u64,\n    out: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_limit(\n        20,\n        exhaustive_primitive_floats_with_sci_exponent_and_precision::<T>(sci_exponent, precision),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_primitive_floats_with_sci_exponent_and_precision() {\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(0, 1, &[1.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(0, 2, &[1.5]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(0, 3, &[1.25, 1.75]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        0,\n        4,\n        &[1.125, 1.375, 1.625, 1.875],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        0,\n        5,\n        &[1.0625, 1.1875, 1.3125, 1.4375, 1.5625, 1.6875, 1.8125, 1.9375],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(4, 1, &[16.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(4, 2, &[24.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(4, 3, &[20.0, 28.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        4,\n        4,\n        &[18.0, 22.0, 26.0, 30.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        4,\n        5,\n        &[17.0, 19.0, 21.0, 23.0, 25.0, 27.0, 29.0, 31.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(-4, 1, &[0.0625]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(-4, 2, &[0.09375]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        -4,\n        3,\n        &[0.078125, 0.109375],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        -4,\n        4,\n        &[0.0703125, 0.0859375, 0.1015625, 0.1171875],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        -4,\n        5,\n        &[\n            0.06640625, 0.07421875, 0.08203125, 0.08984375, 0.09765625, 0.10546875, 0.11328125,\n            0.12109375,\n        ],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(-149, 1, &[1.0e-45]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(-148, 1, &[3.0e-45]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(-148, 2, &[4.0e-45]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(-147, 1, &[6.0e-45]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(-147, 2, &[8.0e-45]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f32>(\n        -147,\n        3,\n        &[7.0e-45, 1.0e-44],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(0, 1, &[1.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(0, 2, &[1.5]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(0, 3, &[1.25, 1.75]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        0,\n        4,\n        &[1.125, 1.375, 1.625, 1.875],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        0,\n        5,\n        &[1.0625, 1.1875, 1.3125, 1.4375, 1.5625, 1.6875, 1.8125, 1.9375],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(4, 1, &[16.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(4, 2, &[24.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(4, 3, &[20.0, 28.0]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        4,\n        4,\n        &[18.0, 22.0, 26.0, 30.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        4,\n        5,\n        &[17.0, 19.0, 21.0, 23.0, 25.0, 27.0, 29.0, 31.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(-4, 1, &[0.0625]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(-4, 2, &[0.09375]);\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -4,\n        3,\n        &[0.078125, 0.109375],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -4,\n        4,\n        &[0.0703125, 0.0859375, 0.1015625, 0.1171875],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -4,\n        5,\n        &[\n            0.06640625, 0.07421875, 0.08203125, 0.08984375, 0.09765625, 0.10546875, 0.11328125,\n            0.12109375,\n        ],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -1074,\n        1,\n        &[5.0e-324],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -1073,\n        1,\n        &[1.0e-323],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -1073,\n        2,\n        &[1.5e-323],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -1072,\n        1,\n        &[2.0e-323],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -1072,\n        2,\n        &[3.0e-323],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_helper::<f64>(\n        -1072,\n        3,\n        &[2.5e-323, 3.5e-323],\n    );\n}\n\nfn exhaustive_primitive_floats_with_sci_exponent_and_precision_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent_and_precision::<T>(0, 0));\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent_and_precision::<T>(0, 100));\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent_and_precision::<T>(10000, 1));\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent_and_precision::<T>(-10000, 1));\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision::<T>(T::MIN_EXPONENT, 2)\n    );\n}\n\n#[test]\nfn exhaustive_primitive_floats_with_sci_exponent_and_precision_fail() {\n    apply_fn_to_primitive_floats!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_fail_helper\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::*;\nuse malachite_base::test_util::num::exhaustive::*;\nuse std::panic::catch_unwind;\n\nfn exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper<\n    T: PrimitiveFloat,\n>(\n    a: T,\n    b: T,\n    sci_exponent: i64,\n    precision: u64,\n    out: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_limit(\n        20,\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            a,\n            b,\n            sci_exponent,\n            precision,\n        ),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range() {\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        1,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        2,\n        &[3.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        3,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        4,\n        &[2.75],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        5,\n        &[2.875, 3.125],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        6,\n        &[2.8125, 2.9375, 3.0625],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        7,\n        &[2.71875, 2.78125, 2.84375, 2.90625, 2.96875, 3.03125, 3.09375],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        1,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        2,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        3,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        4,\n        &[1920.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        5,\n        &[1984.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        6,\n        &[1952.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        7,\n        &[1904.0, 1936.0, 1968.0, 2000.0],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        1,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        2,\n        &[8.0e-45],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        3,\n        &[7.0e-45, 1.0e-44],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1.0,\n        1.99,\n        0,\n        1,\n        &[1.0],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        1,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        2,\n        &[3.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        3,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        4,\n        &[2.75],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        5,\n        &[2.875, 3.125],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        6,\n        &[2.8125, 2.9375, 3.0625],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        7,\n        &[2.71875, 2.78125, 2.84375, 2.90625, 2.96875, 3.03125, 3.09375],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        1,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        2,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        3,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        4,\n        &[1920.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        5,\n        &[1984.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        6,\n        &[1952.0],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        7,\n        &[1904.0, 1936.0, 1968.0, 2000.0],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        1,\n        &[],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        2,\n        &[8.407790785948902e-45],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f64>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        3,\n        &[7.006492321624085e-45, 9.80908925027372e-45],\n    );\n\n    exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_helper::<f32>(\n        1.0,\n        1.99,\n        0,\n        1,\n        &[1.0],\n    );\n}\n\nfn exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_fail_helper<\n    T: PrimitiveFloat,\n>() {\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(1.1),\n            T::from(1.2),\n            0,\n            0\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(1.1),\n            T::from(1.2),\n            0,\n            100\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(1.1),\n            T::from(1.2),\n            10000,\n            1\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(1.1),\n            T::from(1.2),\n            -10000,\n            1\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::MIN_POSITIVE_SUBNORMAL,\n            T::MIN_POSITIVE_SUBNORMAL,\n            T::MIN_EXPONENT,\n            2\n        )\n    );\n\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(1.2),\n            T::from(1.1),\n            0,\n            1\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(1.1),\n            T::from(1.2),\n            1,\n            1\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(0.1),\n            T::from(1.2),\n            1,\n            1\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::from(-1.2),\n            T::from(1.1),\n            0,\n            1\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::ONE,\n            T::INFINITY,\n            0,\n            1\n        )\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range::<T>(\n            T::ONE,\n            T::NAN,\n            0,\n            1\n        )\n    );\n}\n\n#[test]\nfn exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_fail() {\n    apply_fn_to_primitive_floats!(\n        exhaustive_primitive_floats_with_sci_exponent_and_precision_in_range_fail_helper\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_primitive_floats_with_sci_exponent_in_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::exhaustive_primitive_floats_with_sci_exponent_in_range;\nuse malachite_base::test_util::num::exhaustive::exhaustive_primitive_floats_helper_helper;\nuse std::panic::catch_unwind;\n\nfn exhaustive_primitive_floats_with_sci_exponent_in_range_helper<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    sci_exponent: i64,\n    out: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper(\n        exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(a, b, sci_exponent),\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_primitive_floats_with_sci_exponent_in_range() {\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        1,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f32>(\n        1900.0,\n        2000.0,\n        10,\n        &[\n            1920.0, 1984.0, 1952.0, 1904.0, 1936.0, 1968.0, 2000.0, 1912.0, 1928.0, 1944.0, 1960.0,\n            1976.0, 1992.0, 1900.0, 1908.0, 1916.0, 1924.0, 1932.0, 1940.0, 1948.0, 1956.0, 1964.0,\n            1972.0, 1980.0, 1988.0, 1996.0, 1902.0, 1906.0, 1910.0, 1914.0, 1918.0, 1922.0, 1926.0,\n            1930.0, 1934.0, 1938.0, 1942.0, 1946.0, 1950.0, 1954.0, 1958.0, 1962.0, 1966.0, 1970.0,\n            1974.0, 1978.0, 1982.0, 1986.0, 1990.0, 1994.0,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f32>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        &[8.0e-45, 7.0e-45, 1.0e-44],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f32>(\n        1000000.0,\n        1000001.0,\n        19,\n        &[\n            1000000.0, 1000001.0, 1000000.5, 1000000.25, 1000000.75, 1000000.1, 1000000.4,\n            1000000.6, 1000000.9, 1000000.06, 1000000.2, 1000000.3, 1000000.44, 1000000.56,\n            1000000.7, 1000000.8, 1000000.94,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f32>(\n        1.0,\n        1.99,\n        0,\n        &[\n            1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, 1.28125, 1.34375,\n            1.40625, 1.46875, 1.53125, 1.59375, 1.65625, 1.71875, 1.78125, 1.84375, 1.90625,\n            1.96875, 1.015625, 1.046875, 1.078125, 1.109375, 1.140625, 1.171875, 1.203125,\n            1.234375, 1.265625, 1.296875, 1.328125, 1.359375, 1.390625, 1.421875, 1.453125,\n            1.484375, 1.515625, 1.546875,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f32>(5.0, 5.0, 2, &[5.0]);\n\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        1,\n        &[\n            3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625,\n            2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625,\n            2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625,\n            2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375,\n            2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375,\n            2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f64>(\n        1900.0,\n        2000.0,\n        10,\n        &[\n            1920.0, 1984.0, 1952.0, 1904.0, 1936.0, 1968.0, 2000.0, 1912.0, 1928.0, 1944.0, 1960.0,\n            1976.0, 1992.0, 1900.0, 1908.0, 1916.0, 1924.0, 1932.0, 1940.0, 1948.0, 1956.0, 1964.0,\n            1972.0, 1980.0, 1988.0, 1996.0, 1902.0, 1906.0, 1910.0, 1914.0, 1918.0, 1922.0, 1926.0,\n            1930.0, 1934.0, 1938.0, 1942.0, 1946.0, 1950.0, 1954.0, 1958.0, 1962.0, 1966.0, 1970.0,\n            1974.0, 1978.0, 1982.0, 1986.0, 1990.0, 1994.0,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f64>(\n        7.0e-45,\n        1.0e-44,\n        -147,\n        &[\n            8.407790785948902e-45,\n            7.006492321624085e-45,\n            9.80908925027372e-45,\n            7.707141553786494e-45,\n            9.108440018111311e-45,\n            7.35681693770529e-45,\n            8.057466169867698e-45,\n            8.758115402030107e-45,\n            9.458764634192515e-45,\n            7.181654629664687e-45,\n            7.531979245745892e-45,\n            7.882303861827096e-45,\n            8.2326284779083e-45,\n            8.582953093989505e-45,\n            8.933277710070709e-45,\n            9.283602326151913e-45,\n            9.633926942233117e-45,\n            9.984251558314322e-45,\n            7.094073475644386e-45,\n            7.269235783684989e-45,\n            7.444398091725591e-45,\n            7.619560399766193e-45,\n            7.794722707806795e-45,\n            7.969885015847397e-45,\n            8.145047323887999e-45,\n            8.320209631928601e-45,\n            8.495371939969203e-45,\n            8.670534248009806e-45,\n            8.845696556050408e-45,\n            9.02085886409101e-45,\n            9.196021172131612e-45,\n            9.371183480172214e-45,\n            9.546345788212816e-45,\n            9.721508096253418e-45,\n            9.89667040429402e-45,\n            7.050282898634236e-45,\n            7.137864052654537e-45,\n            7.225445206674838e-45,\n            7.313026360695139e-45,\n            7.40060751471544e-45,\n            7.488188668735741e-45,\n            7.575769822756042e-45,\n            7.663350976776343e-45,\n            7.750932130796644e-45,\n            7.838513284816945e-45,\n            7.926094438837247e-45,\n            8.013675592857548e-45,\n            8.101256746877849e-45,\n            8.18883790089815e-45,\n            8.276419054918451e-45,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f64>(\n        1000000.0,\n        1000001.0,\n        19,\n        &[\n            1000000.0,\n            1000001.0,\n            1000000.5,\n            1000000.25,\n            1000000.75,\n            1000000.125,\n            1000000.375,\n            1000000.625,\n            1000000.875,\n            1000000.0625,\n            1000000.1875,\n            1000000.3125,\n            1000000.4375,\n            1000000.5625,\n            1000000.6875,\n            1000000.8125,\n            1000000.9375,\n            1000000.03125,\n            1000000.09375,\n            1000000.15625,\n            1000000.21875,\n            1000000.28125,\n            1000000.34375,\n            1000000.40625,\n            1000000.46875,\n            1000000.53125,\n            1000000.59375,\n            1000000.65625,\n            1000000.71875,\n            1000000.78125,\n            1000000.84375,\n            1000000.90625,\n            1000000.96875,\n            1000000.015625,\n            1000000.046875,\n            1000000.078125,\n            1000000.109375,\n            1000000.140625,\n            1000000.171875,\n            1000000.203125,\n            1000000.234375,\n            1000000.265625,\n            1000000.296875,\n            1000000.328125,\n            1000000.359375,\n            1000000.390625,\n            1000000.421875,\n            1000000.453125,\n            1000000.484375,\n            1000000.515625,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f64>(\n        1.0,\n        1.99,\n        0,\n        &[\n            1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375,\n            1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, 1.28125, 1.34375,\n            1.40625, 1.46875, 1.53125, 1.59375, 1.65625, 1.71875, 1.78125, 1.84375, 1.90625,\n            1.96875, 1.015625, 1.046875, 1.078125, 1.109375, 1.140625, 1.171875, 1.203125,\n            1.234375, 1.265625, 1.296875, 1.328125, 1.359375, 1.390625, 1.421875, 1.453125,\n            1.484375, 1.515625, 1.546875,\n        ],\n    );\n    exhaustive_primitive_floats_with_sci_exponent_in_range_helper::<f64>(5.0, 5.0, 2, &[5.0]);\n}\n\nfn exhaustive_primitive_floats_with_sci_exponent_in_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(\n        T::from(1.1),\n        T::from(1.2),\n        10000,\n    ));\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(\n        T::from(1.1),\n        T::from(1.2),\n        -10000,\n    ));\n    assert_panic!(exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(\n        T::from(-1.2),\n        T::from(1.1),\n        0,\n    )\n    .for_each(|_| {}));\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(T::ONE, T::INFINITY, 0,)\n            .for_each(|_| {})\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(T::ONE, T::NAN, 0)\n            .for_each(|_| {})\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(T::from(1.2), T::from(1.1), 0,)\n            .for_each(|_| {})\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(T::from(1.1), T::from(1.2), 1,)\n            .for_each(|_| {})\n    );\n    assert_panic!(\n        exhaustive_primitive_floats_with_sci_exponent_in_range::<T>(T::from(0.1), T::from(1.2), 1,)\n            .for_each(|_| {})\n    );\n}\n\n#[test]\nfn exhaustive_primitive_floats_with_sci_exponent_in_range_fail() {\n    apply_fn_to_primitive_floats!(\n        exhaustive_primitive_floats_with_sci_exponent_in_range_fail_helper\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_signed_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::exhaustive::exhaustive_signed_inclusive_range;\nuse std::panic::catch_unwind;\n\nfn expected_range_len<T: PrimitiveSigned>(a: T, b: T) -> usize\nwhere\n    usize: WrappingFrom<T>,\n{\n    usize::wrapping_from(b).wrapping_sub(usize::wrapping_from(a)) + 1\n}\n\nfn exhaustive_signed_inclusive_range_helper_helper<T: PrimitiveSigned>(a: T, b: T, values: &[i8])\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    let xs = exhaustive_signed_inclusive_range::<T>(a, b)\n        .map(i8::exact_from)\n        .take(20)\n        .collect_vec();\n    assert_eq!(xs, values);\n    if T::WIDTH <= u16::WIDTH {\n        assert_eq!(\n            exhaustive_signed_inclusive_range(a, b).count(),\n            expected_range_len(a, b)\n        );\n    }\n}\n\nfn exhaustive_signed_inclusive_range_rev_helper<T: PrimitiveSigned>(a: T, b: T, rev_values: &[T])\nwhere\n    usize: WrappingFrom<T>,\n{\n    let len = expected_range_len(a, b);\n    assert_eq!(exhaustive_signed_inclusive_range(a, b).count(), len);\n    let mut tail = exhaustive_signed_inclusive_range::<T>(a, b)\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    tail.reverse();\n    assert_eq!(tail, rev_values);\n}\n\nfn exhaustive_signed_inclusive_range_helper<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    exhaustive_signed_inclusive_range_helper_helper(T::ZERO, T::ZERO, &[0]);\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::ZERO,\n        T::exact_from(9),\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n    );\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::exact_from(10),\n        T::exact_from(19),\n        &[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::ZERO,\n        T::MAX,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::ZERO,\n        T::MAX - T::ONE,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::exact_from(-20),\n        T::exact_from(-11),\n        &[-11, -12, -13, -14, -15, -16, -17, -18, -19, -20],\n    );\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::exact_from(-100),\n        T::exact_from(99),\n        &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10],\n    );\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::MIN,\n        T::MAX,\n        &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10],\n    );\n    exhaustive_signed_inclusive_range_helper_helper(\n        T::MIN + T::ONE,\n        T::MAX - T::ONE,\n        &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10],\n    );\n}\n\n#[test]\nfn test_exhaustive_signed_inclusive_range() {\n    apply_fn_to_signeds!(exhaustive_signed_inclusive_range_helper);\n\n    exhaustive_signed_inclusive_range_rev_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        &[\n            -128, -127, 127, -126, 126, -125, 125, -124, 124, -123, 123, -122, 122, -121, 121,\n            -120, 120, -119, 119, -118,\n        ],\n    );\n    exhaustive_signed_inclusive_range_rev_helper::<i8>(\n        i8::MIN + 1,\n        i8::MAX - 1,\n        &[\n            -127, -126, 126, -125, 125, -124, 124, -123, 123, -122, 122, -121, 121, -120, 120,\n            -119, 119, -118, 118, -117,\n        ],\n    );\n    exhaustive_signed_inclusive_range_rev_helper::<i16>(\n        i16::MIN,\n        i16::MAX,\n        &[\n            -32768, -32767, 32767, -32766, 32766, -32765, 32765, -32764, 32764, -32763, 32763,\n            -32762, 32762, -32761, 32761, -32760, 32760, -32759, 32759, -32758,\n        ],\n    );\n    exhaustive_signed_inclusive_range_rev_helper::<i16>(\n        i16::MIN + 1,\n        i16::MAX - 1,\n        &[\n            -32767, -32766, 32766, -32765, 32765, -32764, 32764, -32763, 32763, -32762, 32762,\n            -32761, 32761, -32760, 32760, -32759, 32759, -32758, 32758, -32757,\n        ],\n    );\n}\n\nfn exhaustive_signed_inclusive_range_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(exhaustive_signed_inclusive_range::<T>(T::ONE, T::ZERO));\n}\n\n#[test]\nfn exhaustive_signed_inclusive_range_fail() {\n    apply_fn_to_signeds!(exhaustive_signed_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_signed_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::exhaustive::exhaustive_signed_range;\nuse std::panic::catch_unwind;\n\nfn expected_range_len<T: PrimitiveSigned>(a: T, b: T) -> usize\nwhere\n    usize: WrappingFrom<T>,\n{\n    usize::wrapping_from(b).wrapping_sub(usize::wrapping_from(a))\n}\n\nfn exhaustive_signed_range_helper_helper<T: PrimitiveSigned>(a: T, b: T, values: &[i8])\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    let xs = exhaustive_signed_range::<T>(a, b)\n        .map(i8::exact_from)\n        .take(20)\n        .collect_vec();\n    assert_eq!(xs, values);\n    if T::WIDTH <= u16::WIDTH {\n        assert_eq!(\n            exhaustive_signed_range(a, b).count(),\n            expected_range_len(a, b)\n        );\n    }\n}\n\nfn exhaustive_signed_range_rev_helper<T: PrimitiveSigned>(a: T, b: T, rev_values: &[T])\nwhere\n    usize: WrappingFrom<T>,\n{\n    let len = expected_range_len(a, b);\n    assert_eq!(exhaustive_signed_range(a, b).count(), len);\n    let mut tail = exhaustive_signed_range::<T>(a, b)\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    tail.reverse();\n    assert_eq!(tail, rev_values);\n}\n\nfn exhaustive_signed_range_helper<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    exhaustive_signed_range_helper_helper(T::ZERO, T::ZERO, &[]);\n    exhaustive_signed_range_helper_helper(T::ZERO, T::ONE, &[0]);\n    exhaustive_signed_range_helper_helper(\n        T::ZERO,\n        T::exact_from(10),\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n    );\n    exhaustive_signed_range_helper_helper(\n        T::exact_from(10),\n        T::exact_from(20),\n        &[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    exhaustive_signed_range_helper_helper(\n        T::ZERO,\n        T::MAX,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    exhaustive_signed_range_helper_helper(\n        T::ZERO,\n        T::MAX - T::ONE,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    exhaustive_signed_range_helper_helper(\n        T::exact_from(-20),\n        T::exact_from(-10),\n        &[-11, -12, -13, -14, -15, -16, -17, -18, -19, -20],\n    );\n    exhaustive_signed_range_helper_helper(\n        T::exact_from(-100),\n        T::exact_from(100),\n        &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10],\n    );\n    exhaustive_signed_range_helper_helper(\n        T::MIN,\n        T::MAX,\n        &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10],\n    );\n    exhaustive_signed_range_helper_helper(\n        T::MIN + T::ONE,\n        T::MAX - T::ONE,\n        &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10],\n    );\n}\n\n#[test]\nfn test_exhaustive_signed_range() {\n    apply_fn_to_signeds!(exhaustive_signed_range_helper);\n\n    exhaustive_signed_range_rev_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        &[\n            -128, -127, -126, 126, -125, 125, -124, 124, -123, 123, -122, 122, -121, 121, -120,\n            120, -119, 119, -118, 118,\n        ],\n    );\n    exhaustive_signed_range_rev_helper::<i8>(\n        i8::MIN + 1,\n        i8::MAX - 1,\n        &[\n            -127, -126, -125, 125, -124, 124, -123, 123, -122, 122, -121, 121, -120, 120, -119,\n            119, -118, 118, -117, 117,\n        ],\n    );\n    exhaustive_signed_range_rev_helper::<i16>(\n        i16::MIN,\n        i16::MAX,\n        &[\n            -32768, -32767, -32766, 32766, -32765, 32765, -32764, 32764, -32763, 32763, -32762,\n            32762, -32761, 32761, -32760, 32760, -32759, 32759, -32758, 32758,\n        ],\n    );\n    exhaustive_signed_range_rev_helper::<i16>(\n        i16::MIN + 1,\n        i16::MAX - 1,\n        &[\n            -32767, -32766, -32765, 32765, -32764, 32764, -32763, 32763, -32762, 32762, -32761,\n            32761, -32760, 32760, -32759, 32759, -32758, 32758, -32757, 32757,\n        ],\n    );\n}\n\nfn exhaustive_signed_range_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(exhaustive_signed_range::<T>(T::ONE, T::ZERO));\n}\n\n#[test]\nfn exhaustive_signed_range_fail() {\n    apply_fn_to_signeds!(exhaustive_signed_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::exhaustive::exhaustive_signeds;\n\nfn exhaustive_signeds_helper<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n{\n    assert_eq!(\n        exhaustive_signeds::<T>()\n            .map(i8::exact_from)\n            .take(20)\n            .collect_vec(),\n        &[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]\n    );\n}\n\nfn exhaustive_signeds_long_helper<T: PrimitiveSigned>(last_20: &[T]) {\n    let expected_len = usize::power_of_2(T::WIDTH);\n    let xs = exhaustive_signeds::<T>();\n    assert_eq!(xs.clone().count(), expected_len);\n    assert_eq!(xs.skip(expected_len - 20).collect_vec(), last_20);\n}\n\n#[test]\nfn test_exhaustive_signeds() {\n    apply_fn_to_signeds!(exhaustive_signeds_helper);\n\n    exhaustive_signeds_long_helper::<i8>(&[\n        -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126,\n        -126, 127, -127, -128,\n    ]);\n    exhaustive_signeds_long_helper::<i16>(&[\n        -0x7ff6,\n        0x7ff7,\n        -0x7ff7,\n        0x7ff8,\n        -0x7ff8,\n        0x7ff9,\n        -0x7ff9,\n        0x7ffa,\n        -0x7ffa,\n        0x7ffb,\n        -0x7ffb,\n        0x7ffc,\n        -0x7ffc,\n        0x7ffd,\n        -0x7ffd,\n        i16::MAX - 1,\n        -0x7ffe,\n        i16::MAX,\n        i16::MIN + 1,\n        i16::MIN,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/exhaustive_unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\n\nfn exhaustive_unsigneds_helper<T: PrimitiveUnsigned>()\nwhere\n    u8: ExactFrom<T>,\n{\n    assert_eq!(\n        exhaustive_unsigneds::<T>()\n            .map(u8::exact_from)\n            .take(20)\n            .collect_vec(),\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n    );\n}\n\nfn exhaustive_unsigneds_long_helper<T: PrimitiveUnsigned>(last_20: &[T]) {\n    let expected_len = usize::power_of_2(T::WIDTH);\n    let xs = exhaustive_unsigneds::<T>();\n    assert_eq!(xs.clone().count(), expected_len);\n    assert_eq!(xs.skip(expected_len - 20).collect_vec(), last_20);\n}\n\n#[test]\nfn test_exhaustive_unsigneds() {\n    apply_fn_to_unsigneds!(exhaustive_unsigneds_helper);\n\n    exhaustive_unsigneds_long_helper::<u8>(&[\n        236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253,\n        254, 255,\n    ]);\n    exhaustive_unsigneds_long_helper::<u16>(&[\n        65516,\n        65517,\n        65518,\n        65519,\n        0xfff0,\n        0xfff1,\n        0xfff2,\n        0xfff3,\n        0xfff4,\n        0xfff5,\n        0xfff6,\n        0xfff7,\n        0xfff8,\n        0xfff9,\n        0xfffa,\n        0xfffb,\n        0xfffc,\n        0xfffd,\n        u16::MAX - 1,\n        u16::MAX,\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/finite_primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::finite_primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn finite_primitive_floats_increasing_helper<T: PrimitiveFloat>(first_20: &[T], last_20: &[T]) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        finite_primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_finite_primitive_floats_increasing() {\n    finite_primitive_floats_increasing_helper::<f32>(\n        &[\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n            -3.4028196e38,\n        ],\n        &[\n            3.4028196e38,\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n        ],\n    );\n    finite_primitive_floats_increasing_helper::<f64>(\n        &[\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n            -1.797693134862312e308,\n        ],\n        &[\n            1.797693134862312e308,\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/negative_finite_primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::negative_finite_primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn negative_finite_primitive_floats_increasing_helper<T: PrimitiveFloat>(\n    first_20: &[T],\n    last_20: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        negative_finite_primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_negative_finite_primitive_floats_increasing() {\n    negative_finite_primitive_floats_increasing_helper::<f32>(\n        &[\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n            -3.4028196e38,\n        ],\n        &[\n            -2.8e-44, -2.7e-44, -2.5e-44, -2.4e-44, -2.2e-44, -2.1e-44, -2.0e-44, -1.8e-44,\n            -1.7e-44, -1.5e-44, -1.4e-44, -1.3e-44, -1.1e-44, -1.0e-44, -8.0e-45, -7.0e-45,\n            -6.0e-45, -4.0e-45, -3.0e-45, -1.0e-45,\n        ],\n    );\n    negative_finite_primitive_floats_increasing_helper::<f64>(\n        &[\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n            -1.797693134862312e308,\n        ],\n        &[\n            -1.0e-322, -9.4e-323, -9.0e-323, -8.4e-323, -8.0e-323, -7.4e-323, -7.0e-323, -6.4e-323,\n            -6.0e-323, -5.4e-323, -5.0e-323, -4.4e-323, -4.0e-323, -3.5e-323, -3.0e-323, -2.5e-323,\n            -2.0e-323, -1.5e-323, -1.0e-323, -5.0e-324,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/negative_primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::negative_primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn negative_primitive_floats_increasing_helper<T: PrimitiveFloat>(first_20: &[T], last_20: &[T]) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        negative_primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_negative_primitive_floats_increasing() {\n    negative_primitive_floats_increasing_helper::<f32>(\n        &[\n            f32::NEGATIVE_INFINITY,\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n        ],\n        &[\n            -2.8e-44, -2.7e-44, -2.5e-44, -2.4e-44, -2.2e-44, -2.1e-44, -2.0e-44, -1.8e-44,\n            -1.7e-44, -1.5e-44, -1.4e-44, -1.3e-44, -1.1e-44, -1.0e-44, -8.0e-45, -7.0e-45,\n            -6.0e-45, -4.0e-45, -3.0e-45, -1.0e-45,\n        ],\n    );\n    negative_primitive_floats_increasing_helper::<f64>(\n        &[\n            f64::NEGATIVE_INFINITY,\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n        ],\n        &[\n            -1.0e-322, -9.4e-323, -9.0e-323, -8.4e-323, -8.0e-323, -7.4e-323, -7.0e-323, -6.4e-323,\n            -6.0e-323, -5.4e-323, -5.0e-323, -4.4e-323, -4.0e-323, -3.5e-323, -3.0e-323, -2.5e-323,\n            -2.0e-323, -1.5e-323, -1.0e-323, -5.0e-324,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/nonzero_finite_primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::nonzero_finite_primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn nonzero_finite_primitive_floats_increasing_helper<T: PrimitiveFloat>(\n    first_20: &[T],\n    last_20: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        nonzero_finite_primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_nonzero_finite_primitive_floats_increasing() {\n    nonzero_finite_primitive_floats_increasing_helper::<f32>(\n        &[\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n            -3.4028196e38,\n        ],\n        &[\n            3.4028196e38,\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n        ],\n    );\n    nonzero_finite_primitive_floats_increasing_helper::<f64>(\n        &[\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n            -1.797693134862312e308,\n        ],\n        &[\n            1.797693134862312e308,\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/nonzero_primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::nonzero_primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn nonzero_primitive_floats_increasing_helper<T: PrimitiveFloat>(first_20: &[T], last_20: &[T]) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        nonzero_primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_nonzero_primitive_floats_increasing() {\n    nonzero_primitive_floats_increasing_helper::<f32>(\n        &[\n            f32::NEGATIVE_INFINITY,\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n        ],\n        &[\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n            f32::INFINITY,\n        ],\n    );\n    nonzero_primitive_floats_increasing_helper::<f64>(\n        &[\n            f64::NEGATIVE_INFINITY,\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n        ],\n        &[\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n            f64::INFINITY,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/positive_finite_primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::positive_finite_primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn positive_finite_primitive_floats_increasing_helper<T: PrimitiveFloat>(\n    first_20: &[T],\n    last_20: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        positive_finite_primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_positive_finite_primitive_floats_increasing() {\n    positive_finite_primitive_floats_increasing_helper::<f32>(\n        &[\n            1.0e-45, 3.0e-45, 4.0e-45, 6.0e-45, 7.0e-45, 8.0e-45, 1.0e-44, 1.1e-44, 1.3e-44,\n            1.4e-44, 1.5e-44, 1.7e-44, 1.8e-44, 2.0e-44, 2.1e-44, 2.2e-44, 2.4e-44, 2.5e-44,\n            2.7e-44, 2.8e-44,\n        ],\n        &[\n            3.4028196e38,\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n        ],\n    );\n    positive_finite_primitive_floats_increasing_helper::<f64>(\n        &[\n            5.0e-324, 1.0e-323, 1.5e-323, 2.0e-323, 2.5e-323, 3.0e-323, 3.5e-323, 4.0e-323,\n            4.4e-323, 5.0e-323, 5.4e-323, 6.0e-323, 6.4e-323, 7.0e-323, 7.4e-323, 8.0e-323,\n            8.4e-323, 9.0e-323, 9.4e-323, 1.0e-322,\n        ],\n        &[\n            1.797693134862312e308,\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/positive_primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::exhaustive::positive_primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn positive_primitive_floats_increasing_helper<T: PrimitiveFloat>(first_20: &[T], last_20: &[T]) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        positive_primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_positive_primitive_floats_increasing() {\n    positive_primitive_floats_increasing_helper::<f32>(\n        &[\n            1.0e-45, 3.0e-45, 4.0e-45, 6.0e-45, 7.0e-45, 8.0e-45, 1.0e-44, 1.1e-44, 1.3e-44,\n            1.4e-44, 1.5e-44, 1.7e-44, 1.8e-44, 2.0e-44, 2.1e-44, 2.2e-44, 2.4e-44, 2.5e-44,\n            2.7e-44, 2.8e-44,\n        ],\n        &[\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n            f32::INFINITY,\n        ],\n    );\n    positive_primitive_floats_increasing_helper::<f64>(\n        &[\n            5.0e-324, 1.0e-323, 1.5e-323, 2.0e-323, 2.5e-323, 3.0e-323, 3.5e-323, 4.0e-323,\n            4.4e-323, 5.0e-323, 5.4e-323, 6.0e-323, 6.4e-323, 7.0e-323, 7.4e-323, 8.0e-323,\n            8.4e-323, 9.0e-323, 9.4e-323, 1.0e-322,\n        ],\n        &[\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n            f64::INFINITY,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/primitive_float_increasing_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::primitive_float_increasing_inclusive_range;\nuse malachite_base::test_util::num::exhaustive::*;\nuse std::panic::catch_unwind;\n\nfn primitive_float_increasing_inclusive_range_helper<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    first_20: &[T],\n    last_20: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        primitive_float_increasing_inclusive_range::<T>(a, b),\n        first_20,\n        last_20,\n    );\n}\n\n#[allow(clippy::approx_constant)]\n#[test]\nfn test_primitive_float_increasing_inclusive_range() {\n    primitive_float_increasing_inclusive_range_helper::<f32>(1.0, 1.0, &[1.0], &[1.0]);\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        1.0,\n        2.0,\n        &[\n            1.0, 1.0000001, 1.0000002, 1.0000004, 1.0000005, 1.0000006, 1.0000007, 1.0000008,\n            1.000001, 1.0000011, 1.0000012, 1.0000013, 1.0000014, 1.0000015, 1.0000017, 1.0000018,\n            1.0000019, 1.000002, 1.0000021, 1.0000023,\n        ],\n        &[\n            1.9999977, 1.9999979, 1.999998, 1.9999981, 1.9999982, 1.9999983, 1.9999985, 1.9999986,\n            1.9999987, 1.9999988, 1.9999989, 1.999999, 1.9999992, 1.9999993, 1.9999994, 1.9999995,\n            1.9999996, 1.9999998, 1.9999999, 2.0,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        -0.1,\n        0.1,\n        &[\n            -0.1,\n            -0.099999994,\n            -0.09999999,\n            -0.09999998,\n            -0.09999997,\n            -0.099999964,\n            -0.09999996,\n            -0.09999995,\n            -0.09999994,\n            -0.099999934,\n            -0.09999993,\n            -0.09999992,\n            -0.09999991,\n            -0.099999905,\n            -0.0999999,\n            -0.09999989,\n            -0.09999988,\n            -0.099999875,\n            -0.09999987,\n            -0.09999986,\n        ],\n        &[\n            0.09999986,\n            0.09999987,\n            0.099999875,\n            0.09999988,\n            0.09999989,\n            0.0999999,\n            0.099999905,\n            0.09999991,\n            0.09999992,\n            0.09999993,\n            0.099999934,\n            0.09999994,\n            0.09999995,\n            0.09999996,\n            0.099999964,\n            0.09999997,\n            0.09999998,\n            0.09999999,\n            0.099999994,\n            0.1,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        &[\n            core::f32::consts::E,\n            2.718282,\n            2.7182822,\n            2.7182825,\n            2.7182827,\n            2.718283,\n            2.7182832,\n            2.7182834,\n            2.7182837,\n            2.718284,\n            2.7182841,\n            2.7182844,\n            2.7182846,\n            2.7182848,\n            2.718285,\n            2.7182853,\n            2.7182856,\n            2.7182858,\n            2.718286,\n            2.7182863,\n        ],\n        &[\n            3.1415882,\n            3.1415884,\n            3.1415887,\n            3.141589,\n            3.1415892,\n            3.1415894,\n            3.1415896,\n            3.1415899,\n            3.14159,\n            3.1415904,\n            3.1415906,\n            3.1415908,\n            3.141591,\n            3.1415913,\n            3.1415915,\n            3.1415918,\n            3.141592,\n            3.1415923,\n            3.1415925,\n            core::f32::consts::PI,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        100.0,\n        101.0,\n        &[\n            100.0, 100.00001, 100.000015, 100.00002, 100.00003, 100.00004, 100.000046, 100.00005,\n            100.00006, 100.00007, 100.00008, 100.000084, 100.00009, 100.0001, 100.00011,\n            100.000114, 100.00012, 100.00013, 100.00014, 100.000145,\n        ],\n        &[\n            100.999855, 100.99986, 100.99987, 100.99988, 100.999886, 100.99989, 100.9999,\n            100.99991, 100.999916, 100.99992, 100.99993, 100.99994, 100.99995, 100.999954,\n            100.99996, 100.99997, 100.99998, 100.999985, 100.99999, 101.0,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        &[\n            1.0e38,\n            1.0000001e38,\n            1.0000002e38,\n            1.0000003e38,\n            1.0000004e38,\n            1.0000005e38,\n            1.0000006e38,\n            1.0000007e38,\n            1.0000008e38,\n            1.0000009e38,\n            1.000001e38,\n            1.0000011e38,\n            1.0000012e38,\n            1.0000013e38,\n            1.0000014e38,\n            1.0000015e38,\n            1.0000016e38,\n            1.0000017e38,\n            1.0000018e38,\n            1.0000019e38,\n        ],\n        &[\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n            f32::INFINITY,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[-1.0e-45, -0.0, 0.0, 1.0e-45],\n        &[-1.0e-45, -0.0, 0.0, 1.0e-45],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        -0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[-0.0, 0.0, 1.0e-45],\n        &[-0.0, 0.0, 1.0e-45],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, 1.0e-45],\n        &[0.0, 1.0e-45],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        &[-1.0e-45, -0.0],\n        &[-1.0e-45, -0.0],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[-1.0e-45, -0.0, 0.0],\n        &[-1.0e-45, -0.0, 0.0],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        &[\n            f32::NEGATIVE_INFINITY,\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n        ],\n        &[\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n            f32::INFINITY,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        &[f32::NEGATIVE_INFINITY],\n        &[f32::NEGATIVE_INFINITY],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(\n        f32::INFINITY,\n        f32::INFINITY,\n        &[f32::INFINITY],\n        &[f32::INFINITY],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f32>(0.0, 0.0, &[0.0], &[0.0]);\n    primitive_float_increasing_inclusive_range_helper::<f32>(-0.0, -0.0, &[-0.0], &[-0.0]);\n    primitive_float_increasing_inclusive_range_helper::<f32>(-0.0, 0.0, &[-0.0, 0.0], &[-0.0, 0.0]);\n\n    primitive_float_increasing_inclusive_range_helper::<f64>(1.0, 1.0, &[1.0], &[1.0]);\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        1.0,\n        2.0,\n        &[\n            1.0,\n            1.0000000000000002,\n            1.0000000000000004,\n            1.0000000000000007,\n            1.0000000000000009,\n            1.000000000000001,\n            1.0000000000000013,\n            1.0000000000000016,\n            1.0000000000000018,\n            1.000000000000002,\n            1.0000000000000022,\n            1.0000000000000024,\n            1.0000000000000027,\n            1.0000000000000029,\n            1.000000000000003,\n            1.0000000000000033,\n            1.0000000000000036,\n            1.0000000000000038,\n            1.000000000000004,\n            1.0000000000000042,\n        ],\n        &[\n            1.9999999999999958,\n            1.999999999999996,\n            1.9999999999999962,\n            1.9999999999999964,\n            1.9999999999999967,\n            1.999999999999997,\n            1.9999999999999971,\n            1.9999999999999973,\n            1.9999999999999976,\n            1.9999999999999978,\n            1.999999999999998,\n            1.9999999999999982,\n            1.9999999999999984,\n            1.9999999999999987,\n            1.999999999999999,\n            1.9999999999999991,\n            1.9999999999999993,\n            1.9999999999999996,\n            1.9999999999999998,\n            2.0,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        -0.1,\n        0.1,\n        &[\n            -0.1,\n            -0.09999999999999999,\n            -0.09999999999999998,\n            -0.09999999999999996,\n            -0.09999999999999995,\n            -0.09999999999999994,\n            -0.09999999999999992,\n            -0.09999999999999991,\n            -0.0999999999999999,\n            -0.09999999999999988,\n            -0.09999999999999987,\n            -0.09999999999999985,\n            -0.09999999999999984,\n            -0.09999999999999983,\n            -0.09999999999999981,\n            -0.0999999999999998,\n            -0.09999999999999978,\n            -0.09999999999999977,\n            -0.09999999999999976,\n            -0.09999999999999974,\n        ],\n        &[\n            0.09999999999999974,\n            0.09999999999999976,\n            0.09999999999999977,\n            0.09999999999999978,\n            0.0999999999999998,\n            0.09999999999999981,\n            0.09999999999999983,\n            0.09999999999999984,\n            0.09999999999999985,\n            0.09999999999999987,\n            0.09999999999999988,\n            0.0999999999999999,\n            0.09999999999999991,\n            0.09999999999999992,\n            0.09999999999999994,\n            0.09999999999999995,\n            0.09999999999999996,\n            0.09999999999999998,\n            0.09999999999999999,\n            0.1,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        &[\n            core::f64::consts::E,\n            2.7182818284590455,\n            2.718281828459046,\n            2.7182818284590464,\n            2.718281828459047,\n            2.7182818284590473,\n            2.7182818284590478,\n            2.718281828459048,\n            2.7182818284590486,\n            2.718281828459049,\n            2.7182818284590495,\n            2.71828182845905,\n            2.7182818284590504,\n            2.718281828459051,\n            2.7182818284590513,\n            2.7182818284590518,\n            2.718281828459052,\n            2.7182818284590526,\n            2.718281828459053,\n            2.7182818284590535,\n        ],\n        &[\n            3.1415926535897847,\n            3.141592653589785,\n            3.1415926535897856,\n            3.141592653589786,\n            3.1415926535897865,\n            3.141592653589787,\n            3.1415926535897873,\n            3.141592653589788,\n            3.1415926535897882,\n            3.1415926535897887,\n            3.141592653589789,\n            3.1415926535897896,\n            3.14159265358979,\n            3.1415926535897905,\n            3.141592653589791,\n            3.1415926535897913,\n            3.141592653589792,\n            3.1415926535897922,\n            3.1415926535897927,\n            core::f64::consts::PI,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        100.0,\n        101.0,\n        &[\n            100.0,\n            100.00000000000001,\n            100.00000000000003,\n            100.00000000000004,\n            100.00000000000006,\n            100.00000000000007,\n            100.00000000000009,\n            100.0000000000001,\n            100.00000000000011,\n            100.00000000000013,\n            100.00000000000014,\n            100.00000000000016,\n            100.00000000000017,\n            100.00000000000018,\n            100.0000000000002,\n            100.00000000000021,\n            100.00000000000023,\n            100.00000000000024,\n            100.00000000000026,\n            100.00000000000027,\n        ],\n        &[\n            100.99999999999973,\n            100.99999999999974,\n            100.99999999999976,\n            100.99999999999977,\n            100.99999999999979,\n            100.9999999999998,\n            100.99999999999982,\n            100.99999999999983,\n            100.99999999999984,\n            100.99999999999986,\n            100.99999999999987,\n            100.99999999999989,\n            100.9999999999999,\n            100.99999999999991,\n            100.99999999999993,\n            100.99999999999994,\n            100.99999999999996,\n            100.99999999999997,\n            100.99999999999999,\n            101.0,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        1.0e308,\n        f64::INFINITY,\n        &[\n            1.0e308,\n            1.0000000000000002e308,\n            1.0000000000000004e308,\n            1.0000000000000006e308,\n            1.0000000000000008e308,\n            1.000000000000001e308,\n            1.0000000000000012e308,\n            1.0000000000000014e308,\n            1.0000000000000016e308,\n            1.0000000000000018e308,\n            1.000000000000002e308,\n            1.0000000000000022e308,\n            1.0000000000000024e308,\n            1.0000000000000026e308,\n            1.0000000000000028e308,\n            1.000000000000003e308,\n            1.0000000000000032e308,\n            1.0000000000000034e308,\n            1.0000000000000036e308,\n            1.0000000000000038e308,\n        ],\n        &[\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n            f64::INFINITY,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[-5.0e-324, -0.0, 0.0, 5.0e-324],\n        &[-5.0e-324, -0.0, 0.0, 5.0e-324],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        -0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[-0.0, 0.0, 5.0e-324],\n        &[-0.0, 0.0, 5.0e-324],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[0.0, 5.0e-324],\n        &[0.0, 5.0e-324],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        &[-5.0e-324, -0.0],\n        &[-5.0e-324, -0.0],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[-5.0e-324, -0.0, 0.0],\n        &[-5.0e-324, -0.0, 0.0],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        &[\n            f64::NEGATIVE_INFINITY,\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n        ],\n        &[\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n            f64::INFINITY,\n        ],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        &[f64::NEGATIVE_INFINITY],\n        &[f64::NEGATIVE_INFINITY],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(\n        f64::INFINITY,\n        f64::INFINITY,\n        &[f64::INFINITY],\n        &[f64::INFINITY],\n    );\n    primitive_float_increasing_inclusive_range_helper::<f64>(0.0, 0.0, &[0.0], &[0.0]);\n    primitive_float_increasing_inclusive_range_helper::<f64>(-0.0, -0.0, &[-0.0], &[-0.0]);\n    primitive_float_increasing_inclusive_range_helper::<f64>(-0.0, 0.0, &[-0.0, 0.0], &[-0.0, 0.0]);\n}\n\nfn primitive_float_increasing_inclusive_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(primitive_float_increasing_inclusive_range::<T>(\n        T::ONE,\n        T::ZERO\n    ));\n    assert_panic!(primitive_float_increasing_inclusive_range::<T>(\n        T::ONE,\n        T::NAN\n    ));\n}\n\n#[test]\nfn primitive_float_increasing_inclusive_range_fail() {\n    apply_fn_to_primitive_floats!(primitive_float_increasing_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/primitive_float_increasing_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::primitive_float_increasing_range;\nuse malachite_base::test_util::num::exhaustive::*;\nuse std::panic::catch_unwind;\n\nfn primitive_float_increasing_range_helper<T: PrimitiveFloat>(\n    a: T,\n    b: T,\n    first_20: &[T],\n    last_20: &[T],\n) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        primitive_float_increasing_range::<T>(a, b),\n        first_20,\n        last_20,\n    );\n}\n\n#[allow(clippy::approx_constant)]\n#[test]\nfn test_primitive_float_increasing_range() {\n    primitive_float_increasing_range_helper::<f32>(1.0, 1.0, &[], &[]);\n    primitive_float_increasing_range_helper::<f32>(\n        1.0,\n        2.0,\n        &[\n            1.0, 1.0000001, 1.0000002, 1.0000004, 1.0000005, 1.0000006, 1.0000007, 1.0000008,\n            1.000001, 1.0000011, 1.0000012, 1.0000013, 1.0000014, 1.0000015, 1.0000017, 1.0000018,\n            1.0000019, 1.000002, 1.0000021, 1.0000023,\n        ],\n        &[\n            1.9999976, 1.9999977, 1.9999979, 1.999998, 1.9999981, 1.9999982, 1.9999983, 1.9999985,\n            1.9999986, 1.9999987, 1.9999988, 1.9999989, 1.999999, 1.9999992, 1.9999993, 1.9999994,\n            1.9999995, 1.9999996, 1.9999998, 1.9999999,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        -0.1,\n        0.1,\n        &[\n            -0.1,\n            -0.099999994,\n            -0.09999999,\n            -0.09999998,\n            -0.09999997,\n            -0.099999964,\n            -0.09999996,\n            -0.09999995,\n            -0.09999994,\n            -0.099999934,\n            -0.09999993,\n            -0.09999992,\n            -0.09999991,\n            -0.099999905,\n            -0.0999999,\n            -0.09999989,\n            -0.09999988,\n            -0.099999875,\n            -0.09999987,\n            -0.09999986,\n        ],\n        &[\n            0.09999985,\n            0.09999986,\n            0.09999987,\n            0.099999875,\n            0.09999988,\n            0.09999989,\n            0.0999999,\n            0.099999905,\n            0.09999991,\n            0.09999992,\n            0.09999993,\n            0.099999934,\n            0.09999994,\n            0.09999995,\n            0.09999996,\n            0.099999964,\n            0.09999997,\n            0.09999998,\n            0.09999999,\n            0.099999994,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        &[\n            core::f32::consts::E,\n            2.718282,\n            2.7182822,\n            2.7182825,\n            2.7182827,\n            2.718283,\n            2.7182832,\n            2.7182834,\n            2.7182837,\n            2.718284,\n            2.7182841,\n            2.7182844,\n            2.7182846,\n            2.7182848,\n            2.718285,\n            2.7182853,\n            2.7182856,\n            2.7182858,\n            2.718286,\n            2.7182863,\n        ],\n        &[\n            3.141588, 3.1415882, 3.1415884, 3.1415887, 3.141589, 3.1415892, 3.1415894, 3.1415896,\n            3.1415899, 3.14159, 3.1415904, 3.1415906, 3.1415908, 3.141591, 3.1415913, 3.1415915,\n            3.1415918, 3.141592, 3.1415923, 3.1415925,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        100.0,\n        101.0,\n        &[\n            100.0, 100.00001, 100.000015, 100.00002, 100.00003, 100.00004, 100.000046, 100.00005,\n            100.00006, 100.00007, 100.00008, 100.000084, 100.00009, 100.0001, 100.00011,\n            100.000114, 100.00012, 100.00013, 100.00014, 100.000145,\n        ],\n        &[\n            100.99985, 100.999855, 100.99986, 100.99987, 100.99988, 100.999886, 100.99989,\n            100.9999, 100.99991, 100.999916, 100.99992, 100.99993, 100.99994, 100.99995,\n            100.999954, 100.99996, 100.99997, 100.99998, 100.999985, 100.99999,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        &[\n            1.0e38,\n            1.0000001e38,\n            1.0000002e38,\n            1.0000003e38,\n            1.0000004e38,\n            1.0000005e38,\n            1.0000006e38,\n            1.0000007e38,\n            1.0000008e38,\n            1.0000009e38,\n            1.000001e38,\n            1.0000011e38,\n            1.0000012e38,\n            1.0000013e38,\n            1.0000014e38,\n            1.0000015e38,\n            1.0000016e38,\n            1.0000017e38,\n            1.0000018e38,\n            1.0000019e38,\n        ],\n        &[\n            3.4028196e38,\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[-1.0e-45, -0.0, 0.0],\n        &[-1.0e-45, -0.0, 0.0],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        -0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[-0.0, 0.0],\n        &[-0.0, 0.0],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        &[0.0],\n        &[0.0],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        &[-1.0e-45],\n        &[-1.0e-45],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[-1.0e-45, -0.0],\n        &[-1.0e-45, -0.0],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        &[\n            f32::NEGATIVE_INFINITY,\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n        ],\n        &[\n            3.4028196e38,\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        &[],\n        &[],\n    );\n    primitive_float_increasing_range_helper::<f32>(f32::INFINITY, f32::INFINITY, &[], &[]);\n    primitive_float_increasing_range_helper::<f32>(0.0, 0.0, &[], &[]);\n    primitive_float_increasing_range_helper::<f32>(-0.0, -0.0, &[], &[]);\n    primitive_float_increasing_range_helper::<f32>(-0.0, 0.0, &[-0.0], &[-0.0]);\n\n    primitive_float_increasing_range_helper::<f64>(1.0, 1.0, &[], &[]);\n    primitive_float_increasing_range_helper::<f64>(\n        1.0,\n        2.0,\n        &[\n            1.0,\n            1.0000000000000002,\n            1.0000000000000004,\n            1.0000000000000007,\n            1.0000000000000009,\n            1.000000000000001,\n            1.0000000000000013,\n            1.0000000000000016,\n            1.0000000000000018,\n            1.000000000000002,\n            1.0000000000000022,\n            1.0000000000000024,\n            1.0000000000000027,\n            1.0000000000000029,\n            1.000000000000003,\n            1.0000000000000033,\n            1.0000000000000036,\n            1.0000000000000038,\n            1.000000000000004,\n            1.0000000000000042,\n        ],\n        &[\n            1.9999999999999956,\n            1.9999999999999958,\n            1.999999999999996,\n            1.9999999999999962,\n            1.9999999999999964,\n            1.9999999999999967,\n            1.999999999999997,\n            1.9999999999999971,\n            1.9999999999999973,\n            1.9999999999999976,\n            1.9999999999999978,\n            1.999999999999998,\n            1.9999999999999982,\n            1.9999999999999984,\n            1.9999999999999987,\n            1.999999999999999,\n            1.9999999999999991,\n            1.9999999999999993,\n            1.9999999999999996,\n            1.9999999999999998,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        -0.1,\n        0.1,\n        &[\n            -0.1,\n            -0.09999999999999999,\n            -0.09999999999999998,\n            -0.09999999999999996,\n            -0.09999999999999995,\n            -0.09999999999999994,\n            -0.09999999999999992,\n            -0.09999999999999991,\n            -0.0999999999999999,\n            -0.09999999999999988,\n            -0.09999999999999987,\n            -0.09999999999999985,\n            -0.09999999999999984,\n            -0.09999999999999983,\n            -0.09999999999999981,\n            -0.0999999999999998,\n            -0.09999999999999978,\n            -0.09999999999999977,\n            -0.09999999999999976,\n            -0.09999999999999974,\n        ],\n        &[\n            0.09999999999999973,\n            0.09999999999999974,\n            0.09999999999999976,\n            0.09999999999999977,\n            0.09999999999999978,\n            0.0999999999999998,\n            0.09999999999999981,\n            0.09999999999999983,\n            0.09999999999999984,\n            0.09999999999999985,\n            0.09999999999999987,\n            0.09999999999999988,\n            0.0999999999999999,\n            0.09999999999999991,\n            0.09999999999999992,\n            0.09999999999999994,\n            0.09999999999999995,\n            0.09999999999999996,\n            0.09999999999999998,\n            0.09999999999999999,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        &[\n            core::f64::consts::E,\n            2.7182818284590455,\n            2.718281828459046,\n            2.7182818284590464,\n            2.718281828459047,\n            2.7182818284590473,\n            2.7182818284590478,\n            2.718281828459048,\n            2.7182818284590486,\n            2.718281828459049,\n            2.7182818284590495,\n            2.71828182845905,\n            2.7182818284590504,\n            2.718281828459051,\n            2.7182818284590513,\n            2.7182818284590518,\n            2.718281828459052,\n            2.7182818284590526,\n            2.718281828459053,\n            2.7182818284590535,\n        ],\n        &[\n            3.1415926535897842,\n            3.1415926535897847,\n            3.141592653589785,\n            3.1415926535897856,\n            3.141592653589786,\n            3.1415926535897865,\n            3.141592653589787,\n            3.1415926535897873,\n            3.141592653589788,\n            3.1415926535897882,\n            3.1415926535897887,\n            3.141592653589789,\n            3.1415926535897896,\n            3.14159265358979,\n            3.1415926535897905,\n            3.141592653589791,\n            3.1415926535897913,\n            3.141592653589792,\n            3.1415926535897922,\n            3.1415926535897927,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        100.0,\n        101.0,\n        &[\n            100.0,\n            100.00000000000001,\n            100.00000000000003,\n            100.00000000000004,\n            100.00000000000006,\n            100.00000000000007,\n            100.00000000000009,\n            100.0000000000001,\n            100.00000000000011,\n            100.00000000000013,\n            100.00000000000014,\n            100.00000000000016,\n            100.00000000000017,\n            100.00000000000018,\n            100.0000000000002,\n            100.00000000000021,\n            100.00000000000023,\n            100.00000000000024,\n            100.00000000000026,\n            100.00000000000027,\n        ],\n        &[\n            100.99999999999972,\n            100.99999999999973,\n            100.99999999999974,\n            100.99999999999976,\n            100.99999999999977,\n            100.99999999999979,\n            100.9999999999998,\n            100.99999999999982,\n            100.99999999999983,\n            100.99999999999984,\n            100.99999999999986,\n            100.99999999999987,\n            100.99999999999989,\n            100.9999999999999,\n            100.99999999999991,\n            100.99999999999993,\n            100.99999999999994,\n            100.99999999999996,\n            100.99999999999997,\n            100.99999999999999,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        1.0e308,\n        f64::INFINITY,\n        &[\n            1.0e308,\n            1.0000000000000002e308,\n            1.0000000000000004e308,\n            1.0000000000000006e308,\n            1.0000000000000008e308,\n            1.000000000000001e308,\n            1.0000000000000012e308,\n            1.0000000000000014e308,\n            1.0000000000000016e308,\n            1.0000000000000018e308,\n            1.000000000000002e308,\n            1.0000000000000022e308,\n            1.0000000000000024e308,\n            1.0000000000000026e308,\n            1.0000000000000028e308,\n            1.000000000000003e308,\n            1.0000000000000032e308,\n            1.0000000000000034e308,\n            1.0000000000000036e308,\n            1.0000000000000038e308,\n        ],\n        &[\n            1.797693134862312e308,\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[-5.0e-324, -0.0, 0.0],\n        &[-5.0e-324, -0.0, 0.0],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        -0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[-0.0, 0.0],\n        &[-0.0, 0.0],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        &[0.0],\n        &[0.0],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        &[-5.0e-324],\n        &[-5.0e-324],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        &[-5.0e-324, -0.0],\n        &[-5.0e-324, -0.0],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        &[\n            f64::NEGATIVE_INFINITY,\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n        ],\n        &[\n            1.797693134862312e308,\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n        ],\n    );\n    primitive_float_increasing_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        &[],\n        &[],\n    );\n    primitive_float_increasing_range_helper::<f64>(f64::INFINITY, f64::INFINITY, &[], &[]);\n    primitive_float_increasing_range_helper::<f64>(0.0, 0.0, &[], &[]);\n    primitive_float_increasing_range_helper::<f64>(-0.0, -0.0, &[], &[]);\n    primitive_float_increasing_range_helper::<f64>(-0.0, 0.0, &[-0.0], &[-0.0]);\n}\n\nfn primitive_float_increasing_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(primitive_float_increasing_range::<T>(T::ONE, T::ZERO));\n    assert_panic!(primitive_float_increasing_range::<T>(T::ONE, T::NAN));\n}\n\n#[test]\nfn primitive_float_increasing_range_fail() {\n    apply_fn_to_primitive_floats!(primitive_float_increasing_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/primitive_floats_increasing.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::exhaustive::primitive_floats_increasing;\nuse malachite_base::test_util::num::exhaustive::*;\n\nfn primitive_floats_increasing_helper<T: PrimitiveFloat>(first_20: &[T], last_20: &[T]) {\n    exhaustive_primitive_floats_helper_helper_with_reverse(\n        primitive_floats_increasing::<T>(),\n        first_20,\n        last_20,\n    );\n}\n\n#[test]\nfn test_primitive_floats_increasing() {\n    primitive_floats_increasing_helper::<f32>(\n        &[\n            f32::NEGATIVE_INFINITY,\n            -3.4028235e38,\n            -3.4028233e38,\n            -3.402823e38,\n            -3.4028229e38,\n            -3.4028227e38,\n            -3.4028225e38,\n            -3.4028222e38,\n            -3.402822e38,\n            -3.4028218e38,\n            -3.4028216e38,\n            -3.4028214e38,\n            -3.4028212e38,\n            -3.402821e38,\n            -3.4028208e38,\n            -3.4028206e38,\n            -3.4028204e38,\n            -3.4028202e38,\n            -3.40282e38,\n            -3.4028198e38,\n        ],\n        &[\n            3.4028198e38,\n            3.40282e38,\n            3.4028202e38,\n            3.4028204e38,\n            3.4028206e38,\n            3.4028208e38,\n            3.402821e38,\n            3.4028212e38,\n            3.4028214e38,\n            3.4028216e38,\n            3.4028218e38,\n            3.402822e38,\n            3.4028222e38,\n            3.4028225e38,\n            3.4028227e38,\n            3.4028229e38,\n            3.402823e38,\n            3.4028233e38,\n            3.4028235e38,\n            f32::INFINITY,\n        ],\n    );\n    primitive_floats_increasing_helper::<f64>(\n        &[\n            f64::NEGATIVE_INFINITY,\n            -1.7976931348623157e308,\n            -1.7976931348623155e308,\n            -1.7976931348623153e308,\n            -1.7976931348623151e308,\n            -1.797693134862315e308,\n            -1.7976931348623147e308,\n            -1.7976931348623145e308,\n            -1.7976931348623143e308,\n            -1.7976931348623141e308,\n            -1.797693134862314e308,\n            -1.7976931348623137e308,\n            -1.7976931348623135e308,\n            -1.7976931348623133e308,\n            -1.7976931348623131e308,\n            -1.797693134862313e308,\n            -1.7976931348623127e308,\n            -1.7976931348623125e308,\n            -1.7976931348623123e308,\n            -1.7976931348623121e308,\n        ],\n        &[\n            1.7976931348623121e308,\n            1.7976931348623123e308,\n            1.7976931348623125e308,\n            1.7976931348623127e308,\n            1.797693134862313e308,\n            1.7976931348623131e308,\n            1.7976931348623133e308,\n            1.7976931348623135e308,\n            1.7976931348623137e308,\n            1.797693134862314e308,\n            1.7976931348623141e308,\n            1.7976931348623143e308,\n            1.7976931348623145e308,\n            1.7976931348623147e308,\n            1.797693134862315e308,\n            1.7976931348623151e308,\n            1.7976931348623153e308,\n            1.7976931348623155e308,\n            1.7976931348623157e308,\n            f64::INFINITY,\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/primitive_int_increasing_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::exhaustive::primitive_int_increasing_inclusive_range;\nuse std::panic::catch_unwind;\n\nfn expected_range_len<T: PrimitiveInt>(a: T, b: T) -> usize\nwhere\n    usize: WrappingFrom<T>,\n{\n    usize::wrapping_from(b).wrapping_sub(usize::wrapping_from(a)) + 1\n}\n\nfn primitive_int_increasing_inclusive_range_helper_helper<T: PrimitiveInt>(\n    a: T,\n    b: T,\n    values: &[i8],\n) where\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    let xs = primitive_int_increasing_inclusive_range::<T>(a, b)\n        .map(i8::exact_from)\n        .take(20)\n        .collect_vec();\n    assert_eq!(xs, values);\n    if T::WIDTH <= u16::WIDTH {\n        let len = expected_range_len(a, b);\n        assert_eq!(primitive_int_increasing_inclusive_range(a, b).count(), len);\n        let mut init = primitive_int_increasing_inclusive_range::<T>(a, b)\n            .rev()\n            .skip(len.saturating_sub(20))\n            .map(i8::exact_from)\n            .collect_vec();\n        init.reverse();\n        assert_eq!(xs, init);\n    }\n}\n\nfn primitive_int_increasing_inclusive_range_rev_helper<T: PrimitiveInt>(\n    a: T,\n    b: T,\n    rev_values: &[T],\n) where\n    usize: WrappingFrom<T>,\n{\n    let xs = primitive_int_increasing_inclusive_range::<T>(a, b)\n        .rev()\n        .take(20)\n        .collect_vec();\n    assert_eq!(xs, rev_values);\n    if T::WIDTH <= u16::WIDTH {\n        let len = expected_range_len(a, b);\n        assert_eq!(\n            primitive_int_increasing_inclusive_range(a, b).rev().count(),\n            len\n        );\n        let mut tail = primitive_int_increasing_inclusive_range::<T>(a, b)\n            .skip(len.saturating_sub(20))\n            .collect_vec();\n        tail.reverse();\n        assert_eq!(xs, tail);\n    }\n}\n\nfn primitive_int_increasing_inclusive_range_helper<T: PrimitiveInt>()\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    primitive_int_increasing_inclusive_range_helper_helper(\n        T::exact_from(5),\n        T::exact_from(5),\n        &[5],\n    );\n    primitive_int_increasing_inclusive_range_helper_helper(\n        T::ONE,\n        T::exact_from(6),\n        &[1, 2, 3, 4, 5, 6],\n    );\n    primitive_int_increasing_inclusive_range_helper_helper(\n        T::exact_from(10),\n        T::exact_from(19),\n        &[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    primitive_int_increasing_inclusive_range_helper_helper(\n        T::ZERO,\n        T::MAX,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    primitive_int_increasing_inclusive_range_helper_helper(\n        T::ZERO,\n        T::MAX - T::ONE,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n}\n\nfn primitive_int_increasing_inclusive_range_helper_signed<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    primitive_int_increasing_inclusive_range_helper_helper(\n        T::exact_from(-20),\n        T::exact_from(-11),\n        &[-20, -19, -18, -17, -16, -15, -14, -13, -12, -11],\n    );\n    primitive_int_increasing_inclusive_range_helper_helper(\n        T::exact_from(-100),\n        T::exact_from(99),\n        &[\n            -100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84,\n            -83, -82, -81,\n        ],\n    );\n}\n\n#[test]\nfn test_primitive_int_increasing_inclusive_range() {\n    apply_fn_to_primitive_ints!(primitive_int_increasing_inclusive_range_helper);\n    apply_fn_to_signeds!(primitive_int_increasing_inclusive_range_helper_signed);\n\n    primitive_int_increasing_inclusive_range_rev_helper::<u8>(\n        0,\n        u8::MAX,\n        &[\n            255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239,\n            238, 237, 236,\n        ],\n    );\n    primitive_int_increasing_inclusive_range_rev_helper::<u8>(\n        0,\n        u8::MAX - 1,\n        &[\n            254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238,\n            237, 236, 235,\n        ],\n    );\n    primitive_int_increasing_inclusive_range_rev_helper::<u16>(\n        0,\n        u16::MAX,\n        &[\n            65535, 65534, 65533, 65532, 65531, 65530, 65529, 65528, 65527, 65526, 65525, 65524,\n            65523, 65522, 65521, 65520, 65519, 65518, 65517, 65516,\n        ],\n    );\n    primitive_int_increasing_inclusive_range_rev_helper::<u16>(\n        0,\n        u16::MAX - 1,\n        &[\n            65534, 65533, 65532, 65531, 65530, 65529, 65528, 65527, 65526, 65525, 65524, 65523,\n            65522, 65521, 65520, 65519, 65518, 65517, 65516, 65515,\n        ],\n    );\n\n    primitive_int_increasing_inclusive_range_helper_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        &[\n            -128, -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115,\n            -114, -113, -112, -111, -110, -109,\n        ],\n    );\n    primitive_int_increasing_inclusive_range_helper_helper::<i8>(\n        i8::MIN + 1,\n        i8::MAX - 1,\n        &[\n            -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115, -114,\n            -113, -112, -111, -110, -109, -108,\n        ],\n    );\n\n    primitive_int_increasing_inclusive_range_rev_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        &[\n            127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111,\n            110, 109, 108,\n        ],\n    );\n    primitive_int_increasing_inclusive_range_rev_helper::<i8>(\n        i8::MIN + 1,\n        i8::MAX - 1,\n        &[\n            126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110,\n            109, 108, 107,\n        ],\n    );\n    primitive_int_increasing_inclusive_range_rev_helper::<i16>(\n        i16::MIN,\n        i16::MAX,\n        &[\n            32767, 32766, 32765, 32764, 32763, 32762, 32761, 32760, 32759, 32758, 32757, 32756,\n            32755, 32754, 32753, 32752, 32751, 32750, 32749, 32748,\n        ],\n    );\n    primitive_int_increasing_inclusive_range_rev_helper::<i16>(\n        i16::MIN + 1,\n        i16::MAX - 1,\n        &[\n            32766, 32765, 32764, 32763, 32762, 32761, 32760, 32759, 32758, 32757, 32756, 32755,\n            32754, 32753, 32752, 32751, 32750, 32749, 32748, 32747,\n        ],\n    );\n}\n\nfn primitive_int_increasing_inclusive_range_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(primitive_int_increasing_inclusive_range::<T>(\n        T::ONE,\n        T::ZERO\n    ));\n}\n\n#[test]\nfn primitive_int_increasing_inclusive_range_fail() {\n    apply_fn_to_primitive_ints!(primitive_int_increasing_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/exhaustive/primitive_int_increasing_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::exhaustive::primitive_int_increasing_range;\nuse std::panic::catch_unwind;\n\nfn expected_range_len<T: PrimitiveInt>(a: T, b: T) -> usize\nwhere\n    usize: WrappingFrom<T>,\n{\n    usize::wrapping_from(b).wrapping_sub(usize::wrapping_from(a))\n}\n\nfn primitive_int_increasing_range_helper_helper<T: PrimitiveInt>(a: T, b: T, values: &[i8])\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    let xs = primitive_int_increasing_range::<T>(a, b)\n        .map(i8::exact_from)\n        .take(20)\n        .collect_vec();\n    assert_eq!(xs, values);\n    if T::WIDTH <= u16::WIDTH {\n        let len = expected_range_len(a, b);\n        assert_eq!(primitive_int_increasing_range(a, b).count(), len);\n        let mut init = primitive_int_increasing_range::<T>(a, b)\n            .rev()\n            .skip(len.saturating_sub(20))\n            .map(i8::exact_from)\n            .collect_vec();\n        init.reverse();\n        assert_eq!(xs, init);\n    }\n}\n\nfn primitive_int_increasing_range_rev_helper<T: PrimitiveInt>(a: T, b: T, rev_values: &[T])\nwhere\n    usize: WrappingFrom<T>,\n{\n    let xs = primitive_int_increasing_range::<T>(a, b)\n        .rev()\n        .take(20)\n        .collect_vec();\n    assert_eq!(xs, rev_values);\n    if T::WIDTH <= u16::WIDTH {\n        let len = expected_range_len(a, b);\n        assert_eq!(primitive_int_increasing_range(a, b).rev().count(), len);\n        let mut tail = primitive_int_increasing_range::<T>(a, b)\n            .skip(len.saturating_sub(20))\n            .collect_vec();\n        tail.reverse();\n        assert_eq!(xs, tail);\n    }\n}\n\nfn primitive_int_increasing_range_helper<T: PrimitiveInt>()\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    primitive_int_increasing_range_helper_helper(T::exact_from(5), T::exact_from(5), &[]);\n    primitive_int_increasing_range_helper_helper(T::exact_from(5), T::exact_from(6), &[5]);\n    primitive_int_increasing_range_helper_helper(T::ONE, T::exact_from(7), &[1, 2, 3, 4, 5, 6]);\n    primitive_int_increasing_range_helper_helper(\n        T::exact_from(10),\n        T::exact_from(20),\n        &[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    primitive_int_increasing_range_helper_helper(\n        T::ZERO,\n        T::MAX,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n    primitive_int_increasing_range_helper_helper(\n        T::ZERO,\n        T::MAX - T::ONE,\n        &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n    );\n}\n\nfn primitive_int_increasing_range_helper_signed<T: PrimitiveSigned>()\nwhere\n    i8: ExactFrom<T>,\n    usize: WrappingFrom<T>,\n{\n    primitive_int_increasing_range_helper_helper(\n        T::exact_from(-20),\n        T::exact_from(-10),\n        &[-20, -19, -18, -17, -16, -15, -14, -13, -12, -11],\n    );\n    primitive_int_increasing_range_helper_helper(\n        T::exact_from(-100),\n        T::exact_from(100),\n        &[\n            -100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84,\n            -83, -82, -81,\n        ],\n    );\n}\n\n#[test]\nfn test_primitive_int_increasing_range() {\n    apply_fn_to_primitive_ints!(primitive_int_increasing_range_helper);\n    apply_fn_to_signeds!(primitive_int_increasing_range_helper_signed);\n\n    primitive_int_increasing_range_rev_helper::<u8>(\n        0,\n        u8::MAX,\n        &[\n            254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238,\n            237, 236, 235,\n        ],\n    );\n    primitive_int_increasing_range_rev_helper::<u8>(\n        0,\n        u8::MAX - 1,\n        &[\n            253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237,\n            236, 235, 234,\n        ],\n    );\n    primitive_int_increasing_range_rev_helper::<u16>(\n        0,\n        u16::MAX,\n        &[\n            65534, 65533, 65532, 65531, 65530, 65529, 65528, 65527, 65526, 65525, 65524, 65523,\n            65522, 65521, 65520, 65519, 65518, 65517, 65516, 65515,\n        ],\n    );\n    primitive_int_increasing_range_rev_helper::<u16>(\n        0,\n        u16::MAX - 1,\n        &[\n            65533, 65532, 65531, 65530, 65529, 65528, 65527, 65526, 65525, 65524, 65523, 65522,\n            65521, 65520, 65519, 65518, 65517, 65516, 65515, 65514,\n        ],\n    );\n\n    primitive_int_increasing_range_helper_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        &[\n            -128, -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115,\n            -114, -113, -112, -111, -110, -109,\n        ],\n    );\n    primitive_int_increasing_range_helper_helper::<i8>(\n        i8::MIN + 1,\n        i8::MAX - 1,\n        &[\n            -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115, -114,\n            -113, -112, -111, -110, -109, -108,\n        ],\n    );\n\n    primitive_int_increasing_range_rev_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        &[\n            126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110,\n            109, 108, 107,\n        ],\n    );\n    primitive_int_increasing_range_rev_helper::<i8>(\n        i8::MIN + 1,\n        i8::MAX - 1,\n        &[\n            125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109,\n            108, 107, 106,\n        ],\n    );\n    primitive_int_increasing_range_rev_helper::<i16>(\n        i16::MIN,\n        i16::MAX,\n        &[\n            32766, 32765, 32764, 32763, 32762, 32761, 32760, 32759, 32758, 32757, 32756, 32755,\n            32754, 32753, 32752, 32751, 32750, 32749, 32748, 32747,\n        ],\n    );\n    primitive_int_increasing_range_rev_helper::<i16>(\n        i16::MIN + 1,\n        i16::MAX - 1,\n        &[\n            32765, 32764, 32763, 32762, 32761, 32760, 32759, 32758, 32757, 32756, 32755, 32754,\n            32753, 32752, 32751, 32750, 32749, 32748, 32747, 32746,\n        ],\n    );\n}\n\nfn primitive_int_increasing_range_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(primitive_int_increasing_range::<T>(T::ONE, T::ZERO));\n}\n\n#[test]\nfn primitive_int_increasing_range_fail() {\n    apply_fn_to_primitive_ints!(primitive_int_increasing_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/factor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::exhaustive::exhaustive_positive_primitive_ints;\nuse malachite_base::num::factorization::traits::{Factor, IsPrime};\nuse malachite_base::test_util::generators::unsigned_gen_var_1;\nuse malachite_base::test_util::num::factorization::factor::factor_naive;\nuse std::panic::catch_unwind;\n\nfn factor_helper<T: Factor + PrimitiveUnsigned>()\nwhere\n    <T as Factor>::FACTORS: IntoIterator<Item = (T, u8)>,\n{\n    let test = |n: u64, out: &[(u64, u8)]| {\n        if let Ok(n) = T::try_from(n) {\n            let factors = n\n                .factor()\n                .into_iter()\n                .map(|(f, e)| {\n                    let f: u64 = f.wrapping_into();\n                    (f, e)\n                })\n                .collect_vec();\n            assert_eq!(factors, out);\n\n            let factors_alt = factor_naive(n)\n                .into_iter()\n                .map(|(f, e)| {\n                    let f: u64 = f.wrapping_into();\n                    (f, e)\n                })\n                .collect_vec();\n            assert_eq!(factors_alt, out);\n        }\n    };\n    // - in n_factor_trial_range_u32\n    // - p * p > n in n_factor_trial_range_u32\n    // - cofactor == 1 in u32::factor\n    // - in n_factor_trial_range_u64\n    // - p * p > n in n_factor_trial_range_u64\n    // - cofactor == 1 in u64::factor\n    test(1, &[]);\n    // - cofactor != 1 in u32::factor\n    // - cofactor.is_prime() in u32::factor\n    // - cofactor != 1 in u64::factor\n    // - cofactor.is_prime() in u64::factor\n    test(2, &[(2, 1)]);\n    test(3, &[(3, 1)]);\n    // - p * p <= n in n_factor_trial_range_u32\n    // - in n_remove2_precomp_u32\n    // - p == 2 in n_remove2_precomp_u32\n    // - exp != 0 in n_remove2_precomp_u32\n    // - exp != 0 in n_factor_trial_range_u32\n    // - p * p <= n in n_factor_trial_range_u64\n    // - in n_remove2_precomp_u64\n    // - p == 2 in n_remove2_precomp_u64\n    // - exp != 0 in n_remove2_precomp_u64\n    // - exp != 0 in n_factor_trial_range_u64\n    test(4, &[(2, 2)]);\n    // - exp == 0 in n_remove2_precomp_u32\n    // - exp == 0 in n_factor_trial_range_u32\n    // - exp == 0 in n_remove2_precomp_u64\n    // - exp == 0 in n_factor_trial_range_u64\n    test(5, &[(5, 1)]);\n    test(6, &[(2, 1), (3, 1)]);\n    test(7, &[(7, 1)]);\n    test(8, &[(2, 3)]);\n    // - p != 2 in n_remove2_precomp_u32\n    // - in n_divrem2_precomp_u32\n    // - a >= n in n_divrem2_precomp_u32\n    // - !n.get_highest_bit() in n_divrem2_precomp_u32\n    // - n != 1 in n_divrem2_precomp_u32\n    // - 0 <= r < n first time in n_divrem2_precomp_u32\n    // - r == 0 in n_remove2_precomp_u32\n    // - p != 2 in n_remove2_precomp_u64\n    // - in n_divrem2_precomp_u64\n    // - a >= n in n_divrem2_precomp_u64\n    // - !n.get_highest_bit() in n_divrem2_precomp_u64\n    // - n != 1 in n_divrem2_precomp_u64\n    // - 0 <= r < n first time in n_divrem2_precomp_u64\n    // - r == 0 in n_remove2_precomp_u64\n    test(9, &[(3, 2)]);\n    test(10, &[(2, 1), (5, 1)]);\n\n    // - r != 0 in n_remove2_precomp_u32\n    // - r != 0 in n_remove2_precomp_u64\n    test(u64::power_of_2(4) - 1, &[(3, 1), (5, 1)]);\n    test(u64::power_of_2(5) - 1, &[(31, 1)]);\n    test(u64::power_of_2(6) - 1, &[(3, 2), (7, 1)]);\n    test(u64::power_of_2(7) - 1, &[(127, 1)]);\n    test(u64::power_of_2(8) - 1, &[(3, 1), (5, 1), (17, 1)]);\n    test(u64::power_of_2(9) - 1, &[(7, 1), (73, 1)]);\n    test(u64::power_of_2(10) - 1, &[(3, 1), (11, 1), (31, 1)]);\n    test(u64::power_of_2(11) - 1, &[(23, 1), (89, 1)]);\n    test(u64::power_of_2(12) - 1, &[(3, 2), (5, 1), (7, 1), (13, 1)]);\n    test(u64::power_of_2(13) - 1, &[(8191, 1)]);\n    test(u64::power_of_2(14) - 1, &[(3, 1), (43, 1), (127, 1)]);\n    test(u64::power_of_2(15) - 1, &[(7, 1), (31, 1), (151, 1)]);\n    test(\n        u64::power_of_2(16) - 1,\n        &[(3, 1), (5, 1), (17, 1), (257, 1)],\n    );\n    test(u64::power_of_2(17) - 1, &[(131071, 1)]);\n    test(u64::power_of_2(18) - 1, &[(3, 3), (7, 1), (19, 1), (73, 1)]);\n    test(u64::power_of_2(19) - 1, &[(524287, 1)]);\n    test(\n        u64::power_of_2(20) - 1,\n        &[(3, 1), (5, 2), (11, 1), (31, 1), (41, 1)],\n    );\n    test(u64::power_of_2(21) - 1, &[(7, 2), (127, 1), (337, 1)]);\n    test(\n        u64::power_of_2(22) - 1,\n        &[(3, 1), (23, 1), (89, 1), (683, 1)],\n    );\n    test(u64::power_of_2(23) - 1, &[(47, 1), (178481, 1)]);\n    test(\n        u64::power_of_2(24) - 1,\n        &[(3, 2), (5, 1), (7, 1), (13, 1), (17, 1), (241, 1)],\n    );\n    test(u64::power_of_2(25) - 1, &[(31, 1), (601, 1), (1801, 1)]);\n    // - r >= n first time in n_divrem2_precomp_u32\n    // - r >= n second time in n_divrem2_precomp_u32\n    // - r >= n first time in n_divrem2_precomp_u64\n    // - r >= n second time in n_divrem2_precomp_u64\n    test(u64::power_of_2(26) - 1, &[(3, 1), (2731, 1), (8191, 1)]);\n    test(u64::power_of_2(27) - 1, &[(7, 1), (73, 1), (262657, 1)]);\n    test(\n        u64::power_of_2(28) - 1,\n        &[(3, 1), (5, 1), (29, 1), (43, 1), (113, 1), (127, 1)],\n    );\n    test(u64::power_of_2(29) - 1, &[(233, 1), (1103, 1), (2089, 1)]);\n    test(\n        u64::power_of_2(30) - 1,\n        &[(3, 2), (7, 1), (11, 1), (31, 1), (151, 1), (331, 1)],\n    );\n    test(u64::power_of_2(31) - 1, &[(2147483647, 1)]);\n    test(\n        u64::power_of_2(32) - 1,\n        &[(3, 1), (5, 1), (17, 1), (257, 1), (65537, 1)],\n    );\n    test(\n        u64::power_of_2(33) - 1,\n        &[(7, 1), (23, 1), (89, 1), (599479, 1)],\n    );\n    // - !cofactor.is_prime() in u64::factor\n    // - factor >= cutoff in u64::factor\n    // - in n_factor_power235_u64\n    // - t != 0 first time in n_factor_power235_u64\n    // - t != 0 second time in n_factor_power235_u64\n    // - t == 0 third time in n_factor_power235_u64\n    // - cofactor == 0 in u64::factor\n    // - factor >= cutoff && !factor.is_prime() in u64::factor\n    // - in n_factor_one_line_u64\n    // - in n_is_square_u64\n    // - IS_SQUARE_MOD64[(x % 64) as usize] != 0 in n_is_square_u64\n    // - IS_SQUARE_MOD63[(x % 63) as usize] == 0 in n_is_square_u64\n    // - !n_is_square_u64(mmod) in n_factor_one_line_u64\n    // - IS_SQUARE_MOD63[(x % 63) as usize] != 0 in n_is_square_u64\n    // - IS_SQUARE_MOD65[(x % 65) as usize] == 0 in n_is_square_u64\n    // - IS_SQUARE_MOD64[(x % 64) as usize] == 0 in n_is_square_u64\n    // - IS_SQUARE_MOD65[(x % 65) as usize] != 0 in n_is_square_u64\n    // - n_is_square_u64(mmod) in n_factor_one_line_u64\n    // - found factor in u64::factor\n    // - factor < cutoff in u64::factor\n    test(u64::power_of_2(34) - 1, &[(3, 1), (43691, 1), (131071, 1)]);\n    test(\n        u64::power_of_2(35) - 1,\n        &[(31, 1), (71, 1), (127, 1), (122921, 1)],\n    );\n    test(\n        u64::power_of_2(36) - 1,\n        &[(3, 3), (5, 1), (7, 1), (13, 1), (19, 1), (37, 1), (73, 1), (109, 1)],\n    );\n    test(u64::power_of_2(37) - 1, &[(223, 1), (616318177, 1)]);\n    test(u64::power_of_2(38) - 1, &[(3, 1), (174763, 1), (524287, 1)]);\n    test(\n        u64::power_of_2(39) - 1,\n        &[(7, 1), (79, 1), (8191, 1), (121369, 1)],\n    );\n    test(\n        u64::power_of_2(40) - 1,\n        &[(3, 1), (5, 2), (11, 1), (17, 1), (31, 1), (41, 1), (61681, 1)],\n    );\n    test(u64::power_of_2(41) - 1, &[(13367, 1), (164511353, 1)]);\n    test(\n        u64::power_of_2(42) - 1,\n        &[(3, 2), (7, 2), (43, 1), (127, 1), (337, 1), (5419, 1)],\n    );\n    test(\n        u64::power_of_2(43) - 1,\n        &[(431, 1), (9719, 1), (2099863, 1)],\n    );\n    test(\n        u64::power_of_2(44) - 1,\n        &[(3, 1), (5, 1), (23, 1), (89, 1), (397, 1), (683, 1), (2113, 1)],\n    );\n    test(\n        u64::power_of_2(45) - 1,\n        &[(7, 1), (31, 1), (73, 1), (151, 1), (631, 1), (23311, 1)],\n    );\n    // - t == 0 first time in n_factor_power235_u64\n    test(\n        u64::power_of_2(46) - 1,\n        &[(3, 1), (47, 1), (178481, 1), (2796203, 1)],\n    );\n    test(\n        u64::power_of_2(47) - 1,\n        &[(2351, 1), (4513, 1), (13264529, 1)],\n    );\n    test(\n        u64::power_of_2(48) - 1,\n        &[(3, 2), (5, 1), (7, 1), (13, 1), (17, 1), (97, 1), (241, 1), (257, 1), (673, 1)],\n    );\n    test(u64::power_of_2(49) - 1, &[(127, 1), (4432676798593, 1)]);\n    test(\n        u64::power_of_2(50) - 1,\n        &[(3, 1), (11, 1), (31, 1), (251, 1), (601, 1), (1801, 1), (4051, 1)],\n    );\n    test(\n        u64::power_of_2(51) - 1,\n        &[(7, 1), (103, 1), (2143, 1), (11119, 1), (131071, 1)],\n    );\n    test(\n        u64::power_of_2(52) - 1,\n        &[(3, 1), (5, 1), (53, 1), (157, 1), (1613, 1), (2731, 1), (8191, 1)],\n    );\n    // - in n_factor_pp1_wrapper_u64\n    // - bits >= 31 in n_factor_pp1_wrapper_u64\n    // - in n_factor_squfof_u64\n    // - in ll_factor_squfof_u64\n    // - n_hi == 0 in ll_factor_squfof_u64\n    // - q != 0 && num != 0 in ll_factor_squfof_u64\n    // - q > l in ll_factor_squfof_u64\n    // - i.even() in ll_factor_squfof_u64\n    // - !n_is_square_u64(q) in ll_factor_squfof_u64\n    // - i.odd() in ll_factor_squfof_u64\n    // - q <= l in ll_factor_squfof_u64\n    // - q.odd() && q > l2 in ll_factor_squfof_u64\n    // - q.odd() && q <= l2 in ll_factor_squfof_u64\n    // - q.odd() && q <= l2 && qupto < 50 in ll_factor_squfof_u64\n    // - q.even() first time in ll_factor_squfof_u64\n    // - q.even() && qupto < 50 in ll_factor_squfof_u64\n    // - n_is_square_u64(q) in ll_factor_squfof_u64\n    // - qupto != 0 in ll_factor_squfof_u64\n    // - r != qarr[j] in ll_factor_squfof_u64\n    // - done in ll_factor_squfof_u64\n    // - !finished_loop in ll_factor_squfof_u64 first time\n    // - sqrt_hi == 0 in ll_factor_squfof_u64\n    // - p != pnext in ll_factor_squfof_u64\n    // - p == pnext in ll_factor_squfof_u64\n    // - !finished_loop in ll_factor_squfof_u64 second time\n    // - q.even() second time in ll_factor_squfof_u64\n    // - factor != 0 first time in n_factor_squfof_u64\n    // - !finished_loop in n_factor_squfof_u64\n    test(\n        u64::power_of_2(53) - 1,\n        &[(6361, 1), (69431, 1), (20394401, 1)],\n    );\n    // - t == 0 second time in n_factor_power235_u64\n    test(\n        u64::power_of_2(54) - 1,\n        &[(3, 4), (7, 1), (19, 1), (73, 1), (87211, 1), (262657, 1)],\n    );\n    // - -n <= r < 0 in n_divrem2_precomp_u64\n    test(\n        u64::power_of_2(55) - 1,\n        &[(23, 1), (31, 1), (89, 1), (881, 1), (3191, 1), (201961, 1)],\n    );\n    // - 0 <= r < n second time in n_divrem2_precomp_u64\n    test(\n        u64::power_of_2(56) - 1,\n        &[(3, 1), (5, 1), (17, 1), (29, 1), (43, 1), (113, 1), (127, 1), (15790321, 1)],\n    );\n    // - r < -n in n_divrem2_precomp_u64\n    // - r < 0 in n_divrem2_precomp_u64\n    // - t != 0 third time in n_factor_power235_u64\n    // - t.even() in n_factor_power235_u64\n    // - t & 2 == 0 in n_factor_power235_u64\n    // - t & 4 == 0 in n_factor_power235_u64\n    // - in n_factor_pp1_u64\n    // - n.odd() in n_factor_pp1_u64\n    // - pr < sqrt in n_factor_pp1_u64 first time\n    // - in n_pp1_pow_ui_u64\n    // - exp & bit == 0 in n_pp1_pow_ui_u64\n    // - exp & bit != 0 in n_pp1_pow_ui_u64\n    // - pr >= sqrt in n_factor_pp1_u64 first time\n    // - in n_pp1_factor_u64\n    // - norm != 0 in n_pp1_factor_u64\n    // - x != 0 in n_pp1_factor_u64\n    // - factor != 0 first time in n_factor_pp1_u64\n    // - factor != 1 first time in n_factor_pp1_u64\n    // - factor != 0 in n_factor_pp1_wrapper_u64\n    test(\n        u64::power_of_2(57) - 1,\n        &[(7, 1), (32377, 1), (524287, 1), (1212847, 1)],\n    );\n    test(\n        u64::power_of_2(58) - 1,\n        &[(3, 1), (59, 1), (233, 1), (1103, 1), (2089, 1), (3033169, 1)],\n    );\n    // - factor < cutoff || factor.is_prime() in u64::factor\n    test(u64::power_of_2(59) - 1, &[(179951, 1), (3203431780337, 1)]);\n    test(\n        u64::power_of_2(60) - 1,\n        &[\n            (3, 2),\n            (5, 2),\n            (7, 1),\n            (11, 1),\n            (13, 1),\n            (31, 1),\n            (41, 1),\n            (61, 1),\n            (151, 1),\n            (331, 1),\n            (1321, 1),\n        ],\n    );\n    test(u64::power_of_2(61) - 1, &[(2305843009213693951, 1)]);\n    // - t.odd() in n_factor_power235_u64\n    // - n != y.square() in n_factor_power235_u64\n    // - t & 4 != 0 in n_factor_power235_u64\n    // - n != y.pow(5) in n_factor_power235_u64\n    // - t & 2 != 0 in n_factor_power235_u64\n    // - n != y.pow(3) in n_factor_power235_u64\n    test(\n        u64::power_of_2(62) - 1,\n        &[(3, 1), (715827883, 1), (2147483647, 1)],\n    );\n    test(\n        u64::power_of_2(63) - 1,\n        &[(7, 2), (73, 1), (127, 1), (337, 1), (92737, 1), (649657, 1)],\n    );\n    test(\n        u64::MAX,\n        &[(3, 1), (5, 1), (17, 1), (257, 1), (641, 1), (65537, 1), (6700417, 1)],\n    );\n\n    test(u64::power_of_2(4) + 1, &[(17, 1)]);\n    test(u64::power_of_2(5) + 1, &[(3, 1), (11, 1)]);\n    test(u64::power_of_2(6) + 1, &[(5, 1), (13, 1)]);\n    test(u64::power_of_2(7) + 1, &[(3, 1), (43, 1)]);\n    test(u64::power_of_2(8) + 1, &[(257, 1)]);\n    test(u64::power_of_2(9) + 1, &[(3, 3), (19, 1)]);\n    test(u64::power_of_2(10) + 1, &[(5, 2), (41, 1)]);\n    test(u64::power_of_2(11) + 1, &[(3, 1), (683, 1)]);\n    test(u64::power_of_2(12) + 1, &[(17, 1), (241, 1)]);\n    test(u64::power_of_2(13) + 1, &[(3, 1), (2731, 1)]);\n    test(u64::power_of_2(14) + 1, &[(5, 1), (29, 1), (113, 1)]);\n    test(u64::power_of_2(15) + 1, &[(3, 2), (11, 1), (331, 1)]);\n    test(u64::power_of_2(16) + 1, &[(65537, 1)]);\n    test(u64::power_of_2(17) + 1, &[(3, 1), (43691, 1)]);\n    test(\n        u64::power_of_2(18) + 1,\n        &[(5, 1), (13, 1), (37, 1), (109, 1)],\n    );\n    test(u64::power_of_2(19) + 1, &[(3, 1), (174763, 1)]);\n    test(u64::power_of_2(20) + 1, &[(17, 1), (61681, 1)]);\n    test(u64::power_of_2(21) + 1, &[(3, 2), (43, 1), (5419, 1)]);\n    test(u64::power_of_2(22) + 1, &[(5, 1), (397, 1), (2113, 1)]);\n    test(u64::power_of_2(23) + 1, &[(3, 1), (2796203, 1)]);\n    test(u64::power_of_2(24) + 1, &[(97, 1), (257, 1), (673, 1)]);\n    test(\n        u64::power_of_2(25) + 1,\n        &[(3, 1), (11, 1), (251, 1), (4051, 1)],\n    );\n    test(\n        u64::power_of_2(26) + 1,\n        &[(5, 1), (53, 1), (157, 1), (1613, 1)],\n    );\n    test(u64::power_of_2(27) + 1, &[(3, 4), (19, 1), (87211, 1)]);\n    test(u64::power_of_2(28) + 1, &[(17, 1), (15790321, 1)]);\n    test(u64::power_of_2(29) + 1, &[(3, 1), (59, 1), (3033169, 1)]);\n    test(\n        u64::power_of_2(30) + 1,\n        &[(5, 2), (13, 1), (41, 1), (61, 1), (1321, 1)],\n    );\n    test(u64::power_of_2(31) + 1, &[(3, 1), (715827883, 1)]);\n    test(u64::power_of_2(32) + 1, &[(641, 1), (6700417, 1)]);\n    test(\n        u64::power_of_2(33) + 1,\n        &[(3, 2), (67, 1), (683, 1), (20857, 1)],\n    );\n    test(\n        u64::power_of_2(34) + 1,\n        &[(5, 1), (137, 1), (953, 1), (26317, 1)],\n    );\n    test(\n        u64::power_of_2(35) + 1,\n        &[(3, 1), (11, 1), (43, 1), (281, 1), (86171, 1)],\n    );\n    test(\n        u64::power_of_2(36) + 1,\n        &[(17, 1), (241, 1), (433, 1), (38737, 1)],\n    );\n    test(u64::power_of_2(37) + 1, &[(3, 1), (1777, 1), (25781083, 1)]);\n    test(\n        u64::power_of_2(38) + 1,\n        &[(5, 1), (229, 1), (457, 1), (525313, 1)],\n    );\n    test(u64::power_of_2(39) + 1, &[(3, 2), (2731, 1), (22366891, 1)]);\n    test(u64::power_of_2(40) + 1, &[(257, 1), (4278255361, 1)]);\n    test(u64::power_of_2(41) + 1, &[(3, 1), (83, 1), (8831418697, 1)]);\n    test(\n        u64::power_of_2(42) + 1,\n        &[(5, 1), (13, 1), (29, 1), (113, 1), (1429, 1), (14449, 1)],\n    );\n    test(u64::power_of_2(43) + 1, &[(3, 1), (2932031007403, 1)]);\n    test(\n        u64::power_of_2(44) + 1,\n        &[(17, 1), (353, 1), (2931542417, 1)],\n    );\n    test(\n        u64::power_of_2(45) + 1,\n        &[(3, 3), (11, 1), (19, 1), (331, 1), (18837001, 1)],\n    );\n    test(\n        u64::power_of_2(46) + 1,\n        &[(5, 1), (277, 1), (1013, 1), (1657, 1), (30269, 1)],\n    );\n    test(\n        u64::power_of_2(47) + 1,\n        &[(3, 1), (283, 1), (165768537521, 1)],\n    );\n    // - r == qarr[j] in ll_factor_squfof_u64\n    // - !done in ll_factor_squfof_u64\n    // - r != 1 in ll_factor_squfof_u64\n    test(\n        u64::power_of_2(48) + 1,\n        &[(193, 1), (65537, 1), (22253377, 1)],\n    );\n    test(\n        u64::power_of_2(49) + 1,\n        &[(3, 1), (43, 1), (4363953127297, 1)],\n    );\n    test(\n        u64::power_of_2(50) + 1,\n        &[(5, 3), (41, 1), (101, 1), (8101, 1), (268501, 1)],\n    );\n    test(\n        u64::power_of_2(51) + 1,\n        &[(3, 2), (307, 1), (2857, 1), (6529, 1), (43691, 1)],\n    );\n    test(\n        u64::power_of_2(52) + 1,\n        &[(17, 1), (858001, 1), (308761441, 1)],\n    );\n    test(\n        u64::power_of_2(53) + 1,\n        &[(3, 1), (107, 1), (28059810762433, 1)],\n    );\n    test(\n        u64::power_of_2(54) + 1,\n        &[(5, 1), (13, 1), (37, 1), (109, 1), (246241, 1), (279073, 1)],\n    );\n    test(\n        u64::power_of_2(55) + 1,\n        &[(3, 1), (11, 2), (683, 1), (2971, 1), (48912491, 1)],\n    );\n    test(\n        u64::power_of_2(56) + 1,\n        &[(257, 1), (5153, 1), (54410972897, 1)],\n    );\n    // - q.odd() in ll_factor_squfof_u64\n    test(\n        u64::power_of_2(57) + 1,\n        &[(3, 2), (571, 1), (174763, 1), (160465489, 1)],\n    );\n    test(\n        u64::power_of_2(58) + 1,\n        &[(5, 1), (107367629, 1), (536903681, 1)],\n    );\n    test(\n        u64::power_of_2(59) + 1,\n        &[(3, 1), (2833, 1), (37171, 1), (1824726041, 1)],\n    );\n    test(\n        u64::power_of_2(60) + 1,\n        &[(17, 1), (241, 1), (61681, 1), (4562284561, 1)],\n    );\n    test(u64::power_of_2(61) + 1, &[(3, 1), (768614336404564651, 1)]);\n    test(\n        u64::power_of_2(62) + 1,\n        &[(5, 1), (5581, 1), (8681, 1), (49477, 1), (384773, 1)],\n    );\n    test(\n        u64::power_of_2(63) + 1,\n        &[(3, 3), (19, 1), (43, 1), (5419, 1), (77158673929, 1)],\n    );\n\n    test(99, &[(3, 2), (11, 1)]);\n    test(999, &[(3, 3), (37, 1)]);\n    test(9999, &[(3, 2), (11, 1), (101, 1)]);\n    test(99999, &[(3, 2), (41, 1), (271, 1)]);\n    test(999999, &[(3, 3), (7, 1), (11, 1), (13, 1), (37, 1)]);\n    test(9999999, &[(3, 2), (239, 1), (4649, 1)]);\n    test(99999999, &[(3, 2), (11, 1), (73, 1), (101, 1), (137, 1)]);\n    test(999999999, &[(3, 4), (37, 1), (333667, 1)]);\n    test(9999999999, &[(3, 2), (11, 1), (41, 1), (271, 1), (9091, 1)]);\n    test(99999999999, &[(3, 2), (21649, 1), (513239, 1)]);\n    test(\n        999999999999,\n        &[(3, 3), (7, 1), (11, 1), (13, 1), (37, 1), (101, 1), (9901, 1)],\n    );\n    test(9999999999999, &[(3, 2), (53, 1), (79, 1), (265371653, 1)]);\n    test(\n        99999999999999,\n        &[(3, 2), (11, 1), (239, 1), (4649, 1), (909091, 1)],\n    );\n    test(\n        999999999999999,\n        &[(3, 3), (31, 1), (37, 1), (41, 1), (271, 1), (2906161, 1)],\n    );\n    test(\n        9999999999999999,\n        &[(3, 2), (11, 1), (17, 1), (73, 1), (101, 1), (137, 1), (5882353, 1)],\n    );\n    // - x == 0 in n_pp1_factor_u64\n    // - factor == 0 first time in n_factor_pp1_u64\n    // - pr >= b1 in n_factor_pp1_u64\n    // - factor == 0 in n_factor_pp1_wrapper_u64\n    // - qupto == 0 in ll_factor_squfof_u64\n    test(99999999999999999, &[(3, 2), (2071723, 1), (5363222357, 1)]);\n    test(\n        999999999999999999,\n        &[(3, 4), (7, 1), (11, 1), (13, 1), (19, 1), (37, 1), (52579, 1), (333667, 1)],\n    );\n    test(9999999999999999999, &[(3, 2), (1111111111111111111, 1)]);\n\n    test(11, &[(11, 1)]);\n    test(101, &[(101, 1)]);\n    test(1001, &[(7, 1), (11, 1), (13, 1)]);\n    test(10001, &[(73, 1), (137, 1)]);\n    test(100001, &[(11, 1), (9091, 1)]);\n    test(1000001, &[(101, 1), (9901, 1)]);\n    test(10000001, &[(11, 1), (909091, 1)]);\n    test(100000001, &[(17, 1), (5882353, 1)]);\n    test(1000000001, &[(7, 1), (11, 1), (13, 1), (19, 1), (52579, 1)]);\n    test(10000000001, &[(101, 1), (3541, 1), (27961, 1)]);\n    test(100000000001, &[(11, 2), (23, 1), (4093, 1), (8779, 1)]);\n    test(1000000000001, &[(73, 1), (137, 1), (99990001, 1)]);\n    test(10000000000001, &[(11, 1), (859, 1), (1058313049, 1)]);\n    test(\n        100000000000001,\n        &[(29, 1), (101, 1), (281, 1), (121499449, 1)],\n    );\n    test(\n        1000000000000001,\n        &[(7, 1), (11, 1), (13, 1), (211, 1), (241, 1), (2161, 1), (9091, 1)],\n    );\n    test(\n        10000000000000001,\n        &[(353, 1), (449, 1), (641, 1), (1409, 1), (69857, 1)],\n    );\n    test(\n        100000000000000001,\n        &[(11, 1), (103, 1), (4013, 1), (21993833369, 1)],\n    );\n    test(\n        1000000000000000001,\n        &[(101, 1), (9901, 1), (999999000001, 1)],\n    );\n    test(10000000000000000001, &[(11, 1), (909090909090909091, 1)]);\n\n    test(13 * 13, &[(13, 2)]);\n    test(251 * 251, &[(251, 2)]);\n    // - !cofactor.is_prime() in u32::factor\n    // - factor >= cutoff in u32::factor\n    // - in n_factor_power235_u32\n    // - t != 0 first time in n_factor_power235_u32\n    // - t != 0 second time in n_factor_power235_u32\n    // - t != 0 third time in n_factor_power235_u32\n    // - t.odd() in n_factor_power235_u32\n    // - n == y.square() in n_factor_power235_u32\n    // - cofactor != 0 in u32::factor\n    // - factor < cutoff || factor.is_prime() in u32::factor\n    // - n == y.square() in n_factor_power235_u64\n    // - cofactor != 0 in u64::factor\n    test(65521 * 65521, &[(65521, 2)]);\n    test(4294967291 * 4294967291, &[(4294967291, 2)]);\n\n    // - t == 0 second time in n_factor_power235_u32\n    // - cofactor == 0 in u32::factor\n    // - factor >= cutoff && !factor.is_prime() in u32::factor\n    // - found factor in u32::factor\n    // - factor < cutoff in u32::factor\n    test(2624473402, &[(2, 1), (36107, 1), (36343, 1)]);\n    test(\n        9255318658858690055,\n        &[(5, 1), (11, 1), (151, 1), (1114427291855351, 1)],\n    );\n    test(\n        17556177092145474537,\n        &[(3, 4), (37, 1), (1663, 1), (125399, 1), (28090333, 1)],\n    );\n    // - pr < b1 in n_factor_pp1_u64\n    // - pr < sqrt in n_factor_pp1_u64 second time\n    // - factor != 0 second time in n_factor_pp1_u64\n    // - factor == 1 second time in n_factor_pp1_u64\n    // - pr >= sqrt in n_factor_pp1_u64 second time\n    // - factor != 1 second time in n_factor_pp1_u64\n    test(\n        9037524565425377627,\n        &[(63793, 1), (3293177, 1), (43019107, 1)],\n    );\n    // - t == 0 third time in n_factor_power235_u32\n    test(2989205357, &[(53783, 1), (55579, 1)]);\n    // - t == 0 first time in n_factor_power235_u32\n    test(3703249699, &[(33107, 1), (111857, 1)]);\n    // - t.even() in n_factor_power235_u32\n    // - t & 2 == 0 in n_factor_power235_u32\n    // - t & 4 == 0 in n_factor_power235_u32\n    test(3763227521, &[(38317, 1), (98213, 1)]);\n    // - t & 2 != 0 in n_factor_power235_u32\n    // - n != y.pow(3) in n_factor_power235_u32\n    test(2574439811, &[(40961, 1), (62851, 1)]);\n    // - n != y.square() in n_factor_power235_u32\n    test(3819439849, &[(56659, 1), (67411, 1)]);\n    // - factor == 1 first time in n_factor_pp1_u64\n    test(\n        13303824785927286386,\n        &[(2, 1), (41681503, 1), (159589072231, 1)],\n    );\n    // - norm == 0 in n_pp1_factor_u64\n    test(10520651756201345771, &[(3995749, 1), (2632961118479, 1)]);\n    // - finished_loop in ll_factor_squfof_u64 first time\n    // - factor == 0 first time in n_factor_squfof_u64\n    // - factor == 0 second time in n_factor_squfof_u64\n    // - factor != 0 second time in n_factor_squfof_u64\n    // - rem != 0 in n_factor_squfof_u64\n    // - factor != 1 && factor != n in n_factor_squfof_u64\n    test(3090502153497041509, &[(1036310063, 1), (2982217643, 1)]);\n    // - rem == 0 in n_factor_squfof_u64\n    // - factor == 1 || factor == n in n_factor_squfof_u64\n    test(\n        9489796947312579142,\n        &[(2, 1), (7, 2), (2968261, 1), (32623365239, 1)],\n    );\n    // - n_hi != 0 in ll_factor_squfof_u64\n    // - in limbs_sqrt_rem_to_out_u64\n    // - xs_hi != 0 in limbs_sqrt_rem_to_out_u64\n    // - xs_hi != 0 && shift != 0 in limbs_sqrt_rem_to_out_u64\n    test(\n        11309902016914315274,\n        &[(2, 1), (1662217, 1), (3402053407261, 1)],\n    );\n    // - t & 4 != 0 in n_factor_power235_u32\n    // - n != y.pow(5) in n_factor_power235_u32\n    test(764502619, &[(27509, 1), (27791, 1)]);\n    // - bits < 31 in n_factor_pp1_wrapper_u64\n    // - q == 0 || num == 0 in ll_factor_squfof_u64\n    test(568345381095148801, &[(27457, 4)]);\n    // - n == y.pow(3) in n_factor_power235_u64\n    test(20699471212993, &[(27457, 3)]);\n    // - r == 1 in ll_factor_squfof_u64\n    test(\n        17600775324697324735,\n        &[(5, 1), (6862897, 1), (512925527651, 1)],\n    );\n    // - factor == 0 second time in n_factor_pp1_u64\n    test(7716102188277442009, &[(155049901, 1), (49765282909, 1)]);\n    // - q.even() && qupto >= 50 in ll_factor_squfof_u64\n    test(\n        11711972945807393444,\n        &[(2, 2), (17, 1), (16481, 1), (2530543, 1), (4129751, 1)],\n    );\n    // - q.odd() && q <= l2 && qupto >= 50 in ll_factor_squfof_u64\n    test(\n        5117728824117767206,\n        &[(2, 1), (255121, 1), (1219831, 1), (8222453, 1)],\n    );\n\n    // primorials\n    test(210, &[(2, 1), (3, 1), (5, 1), (7, 1)]);\n    test(30030, &[(2, 1), (3, 1), (5, 1), (7, 1), (11, 1), (13, 1)]);\n    test(\n        223092870,\n        &[(2, 1), (3, 1), (5, 1), (7, 1), (11, 1), (13, 1), (17, 1), (19, 1), (23, 1)],\n    );\n    test(\n        614889782588491410,\n        &[\n            (2, 1),\n            (3, 1),\n            (5, 1),\n            (7, 1),\n            (11, 1),\n            (13, 1),\n            (17, 1),\n            (19, 1),\n            (23, 1),\n            (29, 1),\n            (31, 1),\n            (37, 1),\n            (41, 1),\n            (43, 1),\n            (47, 1),\n        ],\n    );\n}\n\n#[test]\nfn test_factor() {\n    factor_helper::<u8>();\n    factor_helper::<u16>();\n    factor_helper::<u32>();\n    factor_helper::<u64>();\n    factor_helper::<usize>();\n}\n\nfn factor_fail_helper<T: Factor + PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.factor());\n}\n\n#[test]\npub fn factor_fail() {\n    factor_fail_helper::<u8>();\n    factor_fail_helper::<u16>();\n    factor_fail_helper::<u32>();\n    factor_fail_helper::<u64>();\n    factor_fail_helper::<usize>();\n}\n\nfn factor_properties_helper_helper<T: Factor + IsPrime + PrimitiveUnsigned>(n: T, test_naive: bool)\nwhere\n    <T as Factor>::FACTORS: IntoIterator<Item = (T, u8)>,\n{\n    let factors = n.factor().into_iter().collect_vec();\n    if test_naive {\n        assert_eq!(factor_naive(n), factors);\n    }\n    for &(p, e) in &factors {\n        assert!(p.is_prime());\n        assert_ne!(e, 0);\n    }\n    assert_eq!(\n        T::product(factors.into_iter().map(|(p, e)| p.pow(u64::from(e)))),\n        n\n    );\n}\n\nfn factor_properties_helper_1<T: Factor + IsPrime + PrimitiveUnsigned>()\nwhere\n    <T as Factor>::FACTORS: IntoIterator<Item = (T, u8)>,\n{\n    if T::WIDTH < u32::WIDTH {\n        for n in exhaustive_positive_primitive_ints::<T>() {\n            factor_properties_helper_helper(n, true);\n        }\n    } else {\n        for n in exhaustive_positive_primitive_ints::<T>().take(10_000_000) {\n            factor_properties_helper_helper(n, true);\n        }\n        unsigned_gen_var_1::<T>().test_properties(|n| {\n            factor_properties_helper_helper(n, false);\n        });\n    }\n}\n\n#[test]\nfn factor_properties() {\n    factor_properties_helper_1::<u8>();\n    factor_properties_helper_1::<u16>();\n    factor_properties_helper_1::<u32>();\n    factor_properties_helper_1::<u64>();\n    factor_properties_helper_1::<usize>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/is_power.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::CheckedSquare;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::factorization::traits::{ExpressAsPower, Factor};\nuse malachite_base::num::random::random_unsigned_bit_chunks;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen_var_15, unsigned_gen, unsigned_pair_gen_var_29,\n};\n\nconst NUM_TESTS: usize = 1000;\nconst BITS: u64 = 64;\n\n#[test]\nfn test_perfect_squares() {\n    // Test that squares pass the test\n    let iter = random_unsigned_bit_chunks::<u64>(EXAMPLE_SEED, BITS / 2).take(NUM_TESTS);\n    for d in iter {\n        if let Some(d_squared) = d.checked_square() {\n            let res = d_squared.express_as_power();\n            assert!(res.is_some());\n\n            let (base, exp) = res.unwrap();\n            assert_eq!(base.pow(u32::exact_from(exp)), d_squared);\n        }\n    }\n}\n\n#[test]\nfn test_perfect_cubes() {\n    let iter = random_unsigned_bit_chunks::<u32>(EXAMPLE_SEED, BITS / 3).take(NUM_TESTS);\n    for d in iter {\n        if let Some(d_pow) = d.checked_pow(3) {\n            let res = d_pow.express_as_power();\n            assert!(res.is_some());\n\n            let (base, exp) = res.unwrap();\n            assert_eq!(base.pow(u32::exact_from(exp)), d_pow);\n        }\n    }\n}\n\n#[test]\nfn test_perfect_fifth_powers() {\n    let iter = random_unsigned_bit_chunks::<u32>(EXAMPLE_SEED, BITS / 5).take(NUM_TESTS);\n    for d in iter {\n        if let Some(d_pow) = d.checked_pow(5) {\n            let res = d_pow.express_as_power();\n            assert!(res.is_some());\n\n            let (base, exp) = res.unwrap();\n            assert_eq!(base.pow(u32::exact_from(exp)), d_pow);\n        }\n    }\n}\n\n#[test]\nfn test_exhaustive_other_powers() {\n    // Exhaustively test all other powers This tests all bases from 2 up to 2^(WORD_BITS/5) and all\n    // their powers\n    let max_base = 1u64 << (64 / 5); // Limit to prevent excessive test time\n\n    for d in 2..max_base {\n        let mut n = d * d; // Start with d^2\n\n        // Keep multiplying by d until we overflow\n        loop {\n            let result = n.express_as_power();\n\n            if let Some((base, exp)) = result {\n                assert_eq!(base.pow(u32::exact_from(exp)), n);\n            }\n\n            // Try to multiply by d, break if overflow\n            match n.checked_mul(d) {\n                Some(next_n) => n = next_n,\n                None => break, // Overflow occurred\n            }\n        }\n    }\n}\n\n#[test]\nfn test_non_perfect_powers() {\n    let iter = random_unsigned_bit_chunks::<u64>(EXAMPLE_SEED, 64).take(NUM_TESTS);\n    for d in iter {\n        // naive perfect power testing by factoring\n        if d.factor().into_iter().count() != 1 {\n            assert!(d.express_as_power().is_none());\n        }\n    }\n}\n\n#[test]\nfn test_edge_cases() {\n    // non-perfect powers\n    let non_pows: [u64; 5] = [2, 3, 6, 11, 15];\n    for x in non_pows {\n        assert_eq!(x.express_as_power(), None);\n    }\n\n    let pows: [u64; 12] = [0, 1, 4, 8, 9, 16, 25, 32, 64, 81, 100, 128];\n    for x in pows {\n        let (base, exp) = x.express_as_power().unwrap();\n        assert_eq!(x, base.pow(u32::exact_from(exp)));\n    }\n}\n\n#[test]\nfn test_signed() {\n    assert_eq!(0i8.express_as_power().unwrap(), (0, 2));\n    assert_eq!(1i16.express_as_power().unwrap(), (1, 2));\n    assert_eq!(4i32.express_as_power().unwrap(), (2, 2));\n    assert_eq!(8i64.express_as_power().unwrap(), (2, 3));\n\n    assert_eq!((-1i32).express_as_power(), None);\n    // 64 = 2^6 = 4^3 but 3 is the largest odd exponent, so -64 = (-4)^3 where in the unsigned case\n    // we expect 2^6. etc.\n    assert_eq!((-64i32).express_as_power().unwrap(), (-4, 3));\n    assert_eq!((-4096i64).express_as_power().unwrap(), (-16, 3));\n    assert_eq!((-3486784401i64).express_as_power().unwrap(), (-81, 5));\n}\n\nfn express_as_power_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        if let Some((p, e)) = x.express_as_power() {\n            assert!(e > 1);\n            assert_eq!(p.pow(e), x);\n            if x > T::ONE {\n                assert!(p.express_as_power().is_none());\n            }\n        }\n    });\n\n    unsigned_pair_gen_var_29::<T>().test_properties(|(x, y)| {\n        if y > 1 {\n            let power = x.pow(y);\n            let ope = power.express_as_power();\n            assert!(ope.is_some());\n            let (p, e) = ope.unwrap();\n            assert_eq!(p.pow(e), power);\n            if x.express_as_power().is_none() {\n                assert_eq!(x, p);\n                assert_eq!(y, e);\n            }\n        }\n    });\n}\n\nfn express_as_power_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        if let Some((p, e)) = x.express_as_power() {\n            assert!(e > 1);\n            assert_eq!(p.pow(e), x);\n            if x > T::ONE {\n                assert!(p.express_as_power().is_none());\n            }\n        }\n    });\n\n    signed_unsigned_pair_gen_var_15::<T>().test_properties(|(x, y)| {\n        if x != T::NEGATIVE_ONE && y > 1 {\n            let power = x.pow(y);\n            let ope = power.express_as_power();\n            assert!(ope.is_some());\n            let (p, e) = ope.unwrap();\n            assert_eq!(p.pow(e), power);\n            if x >= T::ZERO && x.express_as_power().is_none() {\n                assert!(x.eq_abs(&p));\n                assert_eq!(y, e);\n            }\n        }\n    });\n}\n\n#[test]\nfn express_as_power_properties() {\n    apply_fn_to_unsigneds!(express_as_power_properties_helper_unsigned);\n    apply_fn_to_signeds!(express_as_power_properties_helper_signed);\n}\n\nfn is_power_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.is_power(), x.express_as_power().is_some());\n    });\n\n    unsigned_pair_gen_var_29::<T>().test_properties(|(x, y)| {\n        if y > 1 {\n            assert!(x.pow(y).is_power());\n        }\n    });\n}\n\nfn is_power_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.is_power(), x.express_as_power().is_some());\n    });\n\n    signed_unsigned_pair_gen_var_15::<T>().test_properties(|(x, y)| {\n        if x != T::NEGATIVE_ONE && y > 1 {\n            assert!(x.pow(y).is_power());\n        }\n    });\n}\n\n#[test]\nfn is_power_properties() {\n    apply_fn_to_unsigneds!(is_power_properties_helper_unsigned);\n    apply_fn_to_signeds!(is_power_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/is_prime.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::num::factorization::traits::IsPrime;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_pair_gen_var_50};\nuse malachite_base::test_util::num::factorization::is_prime::is_prime_naive;\n\nfn is_prime_helper<T: IsPrime + PrimitiveUnsigned>() {\n    let test = |n: u64, out| {\n        if let Ok(n) = T::try_from(n) {\n            assert_eq!(n.is_prime(), out);\n            assert_eq!(is_prime_naive(n), out);\n        }\n    };\n    // - in u32::is_prime\n    // - n < 11 in u32::is_prime\n    // - in u64::is_prime\n    // - n < 11 in u64::is_prime\n    test(0, false);\n    test(1, false);\n    test(2, true);\n    test(3, true);\n    test(4, false);\n    test(5, true);\n    test(6, false);\n    test(7, true);\n    test(8, false);\n    test(9, false);\n    test(10, false);\n\n    // - n >= 11 in u32::is_prime\n    // - prime factor <= 7 in u32::is_prime\n    // - n >= 11 in u64::is_prime\n    // - prime factor <= 7 in u64::is_prime\n    test(u64::power_of_2(4) - 1, false);\n    // - no prime factor <= 7 in u32::is_prime\n    // - n < 121 in u32::is_prime\n    // - no prime factor <= 7 in u64::is_prime\n    // - n < 121 in u64::is_prime\n    test(u64::power_of_2(5) - 1, true);\n    test(u64::power_of_2(6) - 1, false);\n    // - n >= 121 in u32::is_prime\n    // - no prime factor <= 53 in u32::is_prime\n    // - n < 3481 in u32::is_prime\n    // - n >= 121 in u64::is_prime\n    // - no prime factor <= 53 in u64::is_prime\n    // - n < 3481 in u64::is_prime\n    test(u64::power_of_2(7) - 1, true);\n    test(u64::power_of_2(8) - 1, false);\n    test(u64::power_of_2(9) - 1, false);\n    test(u64::power_of_2(10) - 1, false);\n    // - prime factor <= 53 in u32::is_prime\n    // - prime factor <= 53 in u64::is_prime\n    test(u64::power_of_2(11) - 1, false);\n    test(u64::power_of_2(12) - 1, false);\n    // - n >= 3481 in u32::is_prime\n    // - n <= 1000000 or no prime factor <= 149 in u32::is_prime\n    // - in n_is_probabprime_u32\n    // - FLINT_ODDPRIME_SMALL_CUTOFF <= n < FLINT_PRIMES_TAB_DEFAULT_CUTOFF in n_is_probabprime_u32\n    // - in n_is_oddprime_binary_u32\n    // - in n_prime_pi_bounds_u32\n    // - n >= PRIME_PI_ODD_LOOKUP_CUTOFF in n_prime_pi_bounds_u32\n    // - n < primes[prime_hi as usize] in n_is_oddprime_binary_u32\n    // - primes[(prime_lo + diff) as usize] > n in n_is_oddprime_binary_u32\n    // - diff > 1 in n_is_oddprime_binary_u32\n    // - diff <= diff2 in n_is_oddprime_binary_u32\n    // - primes[(prime_lo + diff) as usize] <= n in n_is_oddprime_binary_u32\n    // - diff <= 1 in n_is_oddprime_binary_u32\n    // - n >= 3481 in u64::is_prime\n    // - n <= 1000000 or no prime factor <= 149 in u64::is_prime\n    // - in n_is_probabprime_u64\n    // - FLINT_ODDPRIME_SMALL_CUTOFF <= n < FLINT_PRIMES_TAB_DEFAULT_CUTOFF in n_is_probabprime_u64\n    // - in n_is_oddprime_binary_u64\n    // - in n_prime_pi_bounds_u64\n    // - n >= PRIME_PI_ODD_LOOKUP_CUTOFF in n_prime_pi_bounds_u64\n    // - n < primes[prime_hi as usize] in n_is_oddprime_binary_u64\n    // - primes[(prime_lo + diff) as usize] > n in n_is_oddprime_binary_u64\n    // - diff > 1 in n_is_oddprime_binary_u64\n    // - diff <= diff2 in n_is_oddprime_binary_u64\n    // - primes[(prime_lo + diff) as usize] <= n in n_is_oddprime_binary_u64\n    // - diff <= 1 in n_is_oddprime_binary_u64\n    test(u64::power_of_2(13) - 1, true);\n    test(u64::power_of_2(14) - 1, false);\n    test(u64::power_of_2(15) - 1, false);\n    test(u64::power_of_2(16) - 1, false);\n    test(u64::power_of_2(17) - 1, true);\n    test(u64::power_of_2(18) - 1, false);\n    test(u64::power_of_2(19) - 1, true);\n    test(u64::power_of_2(20) - 1, false);\n    test(u64::power_of_2(21) - 1, false);\n    test(u64::power_of_2(22) - 1, false);\n    test(u64::power_of_2(23) - 1, false);\n    test(u64::power_of_2(24) - 1, false);\n    test(u64::power_of_2(25) - 1, false);\n    test(u64::power_of_2(26) - 1, false);\n    test(u64::power_of_2(27) - 1, false);\n    test(u64::power_of_2(28) - 1, false);\n    // - n >= FLINT_PRIMES_TAB_DEFAULT_CUTOFF in n_is_probabprime_u32\n    // - n >= 9080191 in n_is_probabprime_u32\n    // - in n_is_strong_probabprime2_preinv_u32\n    // - a > 1 && a != n - 1 in n_is_strong_probabprime2_preinv_u32\n    // - in n_powmod2_ui_preinv_u32\n    // - exp != 0 in n_powmod2_ui_preinv_u32\n    // - a != 0 in n_powmod2_ui_preinv_u32\n    // - a < n in n_powmod2_ui_preinv_u32\n    // - exp.odd() in n_powmod2_ui_preinv_u32\n    // - y == 1 in n_is_strong_probabprime2_preinv_u32\n    // - y != 1 in n_is_strong_probabprime2_preinv_u32\n    // - n >= FLINT_PRIMES_TAB_DEFAULT_CUTOFF in n_is_probabprime_u64\n    // - n < 1050535501 in n_is_probabprime_u64\n    // - n >= 341531 in n_is_probabprime_u64\n    // - in n_is_strong_probabprime_precomp_u64\n    // - a >= n in n_is_strong_probabprime_precomp_u64\n    // - in n_mod2_precomp_u64\n    // - a >= n in n_mod2_precomp_u64\n    // - ni >= 0 in n_mod2_precomp_u64\n    // - n != 1 in n_mod2_precomp_u64\n    // - rem >= 0 in n_mod2_precomp_u64 first time\n    // - a > 1 && a != n - 1 n_is_strong_probabprime_precomp_u64\n    // - in n_powmod_ui_precomp_u64\n    // - n != 1 in n_powmod_ui_precomp_u64\n    // - exp.odd() in n_powmod_ui_precomp_u64\n    // - in n_mulmod_precomp_u64\n    // - n > rem in n_mulmod_precomp_u64\n    // - exp != 0 in n_powmod_ui_precomp_u64\n    // - exp == 0 in n_powmod_ui_precomp_u64\n    // - y != 1 n_is_strong_probabprime_precomp_u64\n    test(u64::power_of_2(29) - 1, false);\n    test(u64::power_of_2(30) - 1, false);\n    // - n >= 1050535501 in n_is_probabprime_u64\n    // - in n_is_probabprime_bpsw_u64\n    // - n > 1 in n_is_probabprime_bpsw_u64\n    // - n.odd() in n_is_probabprime_bpsw_u64\n    // - nm10 == 3 || nm10 == 7 in n_is_probabprime_bpsw_u64\n    // - in n_is_probabprime_fermat_u64\n    // - n.significant_bits() <= FLINT_D_BITS_U64 in n_is_probabprime_fermat_u64\n    // - in n_powmod_u64\n    // - in n_powmod_precomp_u64\n    // - exp >= 0 in n_powmod_precomp_u64\n    // - exp.even() in n_powmod_ui_precomp_u64\n    // - in n_is_probabprime_fibonacci_u64\n    // - i64::wrapping_from(n).gt_abs(&3) in n_is_probabprime_fibonacci_u64\n    // - n.significant_bits() <= FLINT_D_BITS_U64 in n_is_probabprime_fibonacci_u64\n    // - in fchain_precomp_u64\n    // - m & power != 0 in fchain_precomp_u64\n    // - m & power == 0 in fchain_precomp_u64\n    test(u64::power_of_2(31) - 1, true);\n    test(u64::power_of_2(32) - 1, false);\n    test(u64::power_of_2(33) - 1, false);\n    test(u64::power_of_2(34) - 1, false);\n    test(u64::power_of_2(35) - 1, false);\n    test(u64::power_of_2(36) - 1, false);\n    // - nm10 != 3 && nm10 != 7 in n_is_probabprime_bpsw_u64\n    // - n.significant_bits() <= FLINT_D_BITS_U64 in n_is_probabprime_bpsw_u64\n    // - a < n in n_is_strong_probabprime_precomp_u64\n    // - y == 1 n_is_strong_probabprime_precomp_u64\n    // - n_is_strong_probabprime_precomp_u64(n, npre, 2, d) in n_is_probabprime_bpsw_u64\n    // - in n_is_probabprime_lucas_u64\n    // - d.gcd(n % d) == 1 in n_is_probabprime_lucas_u64\n    // - i.even() in n_is_probabprime_lucas_u64\n    // - !neg_d in n_is_probabprime_lucas_u64 first time\n    // - jacobi != -1 in n_is_probabprime_lucas_u64\n    // - i.odd() in n_is_probabprime_lucas_u64\n    // - neg_d in n_is_probabprime_lucas_u64 first time\n    // - jacobi == -1 in n_is_probabprime_lucas_u64\n    // - j < 100 in n_is_probabprime_lucas_u64\n    // - neg_d in n_is_probabprime_lucas_u64 second time\n    // - q >= 0 && n >= 52 in n_is_probabprime_lucas_u64\n    // - n > FLINT_D_BITS_U64 in n_is_probabprime_lucas_u64\n    // - in lchain2_preinv_u64\n    // - m & power != 0 in lchain2_preinv_u64\n    // - m & power == 0 in lchain2_preinv_u64\n    test(u64::power_of_2(37) - 1, false);\n    test(u64::power_of_2(38) - 1, false);\n    test(u64::power_of_2(39) - 1, false);\n    test(u64::power_of_2(40) - 1, false);\n    test(u64::power_of_2(41) - 1, false);\n    test(u64::power_of_2(42) - 1, false);\n    test(u64::power_of_2(43) - 1, false);\n    test(u64::power_of_2(44) - 1, false);\n    test(u64::power_of_2(45) - 1, false);\n    test(u64::power_of_2(46) - 1, false);\n    test(u64::power_of_2(47) - 1, false);\n    test(u64::power_of_2(48) - 1, false);\n    // - n > 1000000 and prime factor <= 149 in u64::is_prime\n    test(u64::power_of_2(49) - 1, false);\n    test(u64::power_of_2(50) - 1, false);\n    test(u64::power_of_2(51) - 1, false);\n    test(u64::power_of_2(52) - 1, false);\n    test(u64::power_of_2(53) - 1, false);\n    test(u64::power_of_2(54) - 1, false);\n    test(u64::power_of_2(55) - 1, false);\n    test(u64::power_of_2(56) - 1, false);\n    test(u64::power_of_2(57) - 1, false);\n    test(u64::power_of_2(58) - 1, false);\n    // - n.significant_bits() > FLINT_D_BITS_U64 in n_is_probabprime_fermat_u64\n    // - in n_powmod2_ui_preinv_u64\n    // - exp != 0 in n_powmod2_ui_preinv_u64\n    // - a != 0 in n_powmod2_ui_preinv_u64\n    // - a < 0 in n_powmod2_ui_preinv_u64\n    // - exp.odd() in n_powmod2_ui_preinv_u64\n    // - n.significant_bits() > FLINT_D_BITS_U64 in n_is_probabprime_fibonacci_u64\n    // - in fchain2_preinv_u64\n    // - m & power != 0 in fchain2_preinv_u64\n    // - m & power == 0 in fchain2_preinv_u64\n    test(u64::power_of_2(59) - 1, false);\n    test(u64::power_of_2(60) - 1, false);\n    // - n.significant_bits() > FLINT_D_BITS_U64 in n_is_probabprime_bpsw_u64\n    // - in n_is_strong_probabprime2_preinv_u64\n    // - a > 1 && a != n - 1 in n_is_strong_probabprime2_preinv_u64\n    // - y == 1 in n_is_strong_probabprime2_preinv_u64\n    // - n_is_strong_probabprime2_preinv_u64(n, ninv, 2, d) in n_is_probabprime_bpsw_u64\n    // - !neg_d in n_is_probabprime_lucas_u64 second time\n    // - q < 0 in n_is_probabprime_lucas_u64\n    // - q < 0 && n >= 52 in n_is_probabprime_lucas_u64\n    test(u64::power_of_2(61) - 1, true);\n    test(u64::power_of_2(62) - 1, false);\n    test(u64::power_of_2(63) - 1, false);\n    test(u64::MAX, false);\n\n    test(u64::power_of_2(4) + 1, true);\n    test(u64::power_of_2(5) + 1, false);\n    test(u64::power_of_2(6) + 1, false);\n    test(u64::power_of_2(7) + 1, false);\n    test(u64::power_of_2(8) + 1, true);\n    test(u64::power_of_2(9) + 1, false);\n    test(u64::power_of_2(10) + 1, false);\n    test(u64::power_of_2(11) + 1, false);\n    test(u64::power_of_2(12) + 1, false);\n    test(u64::power_of_2(13) + 1, false);\n    test(u64::power_of_2(14) + 1, false);\n    test(u64::power_of_2(15) + 1, false);\n    test(u64::power_of_2(16) + 1, true);\n    test(u64::power_of_2(17) + 1, false);\n    test(u64::power_of_2(18) + 1, false);\n    test(u64::power_of_2(19) + 1, false);\n    test(u64::power_of_2(20) + 1, false);\n    test(u64::power_of_2(21) + 1, false);\n    test(u64::power_of_2(22) + 1, false);\n    test(u64::power_of_2(23) + 1, false);\n    // - n > 1000000 and prime factor <= 149 in u32::is_prime\n    test(u64::power_of_2(24) + 1, false);\n    test(u64::power_of_2(25) + 1, false);\n    test(u64::power_of_2(26) + 1, false);\n    test(u64::power_of_2(27) + 1, false);\n    test(u64::power_of_2(28) + 1, false);\n    test(u64::power_of_2(29) + 1, false);\n    test(u64::power_of_2(30) + 1, false);\n    test(u64::power_of_2(31) + 1, false);\n    test(u64::power_of_2(32) + 1, false);\n    test(u64::power_of_2(33) + 1, false);\n    test(u64::power_of_2(34) + 1, false);\n    test(u64::power_of_2(35) + 1, false);\n    test(u64::power_of_2(36) + 1, false);\n    test(u64::power_of_2(37) + 1, false);\n    test(u64::power_of_2(38) + 1, false);\n    test(u64::power_of_2(39) + 1, false);\n    // - rem < 0 first time in n_mulmod_precomp_u64\n    // - rem >= 0 second time in n_mulmod_precomp_u64\n    test(u64::power_of_2(40) + 1, false);\n    test(u64::power_of_2(41) + 1, false);\n    test(u64::power_of_2(42) + 1, false);\n    test(u64::power_of_2(43) + 1, false);\n    test(u64::power_of_2(44) + 1, false);\n    test(u64::power_of_2(45) + 1, false);\n    test(u64::power_of_2(46) + 1, false);\n    test(u64::power_of_2(47) + 1, false);\n    test(u64::power_of_2(48) + 1, false);\n    test(u64::power_of_2(49) + 1, false);\n    test(u64::power_of_2(50) + 1, false);\n    test(u64::power_of_2(51) + 1, false);\n    test(u64::power_of_2(52) + 1, false);\n    test(u64::power_of_2(53) + 1, false);\n    test(u64::power_of_2(54) + 1, false);\n    test(u64::power_of_2(55) + 1, false);\n    test(u64::power_of_2(56) + 1, false);\n    test(u64::power_of_2(57) + 1, false);\n    test(u64::power_of_2(58) + 1, false);\n    test(u64::power_of_2(59) + 1, false);\n    test(u64::power_of_2(60) + 1, false);\n    test(u64::power_of_2(61) + 1, false);\n    test(u64::power_of_2(62) + 1, false);\n    test(u64::power_of_2(63) + 1, false);\n\n    test(u64::power_of_2(4) - 3, true);\n    test(u64::power_of_2(5) - 1, true);\n    test(u64::power_of_2(6) - 3, true);\n    test(u64::power_of_2(7) - 1, true);\n    test(u64::power_of_2(8) - 5, true);\n    test(u64::power_of_2(9) - 3, true);\n    test(u64::power_of_2(10) - 3, true);\n    test(u64::power_of_2(11) - 9, true);\n    // - n < FLINT_ODDPRIME_SMALL_CUTOFF in n_is_probabprime_u32\n    // - in n_is_oddprime_small_u32\n    // - n < FLINT_ODDPRIME_SMALL_CUTOFF in n_is_probabprime_u64\n    // - in n_is_oddprime_small_u64\n    test(u64::power_of_2(12) - 3, true);\n    test(u64::power_of_2(13) - 1, true);\n    test(u64::power_of_2(14) - 3, true);\n    test(u64::power_of_2(15) - 19, true);\n    test(u64::power_of_2(16) - 15, true);\n    test(u64::power_of_2(17) - 1, true);\n    test(u64::power_of_2(18) - 5, true);\n    test(u64::power_of_2(19) - 1, true);\n    // - n < 9080191 in n_is_probabprime_u32\n    test(u64::power_of_2(20) - 3, true);\n    // - exp.even() in n_powmod2_ui_preinv_u32\n    test(u64::power_of_2(21) - 9, true);\n    test(u64::power_of_2(22) - 3, true);\n    test(u64::power_of_2(23) - 15, true);\n    test(u64::power_of_2(24) - 3, true);\n    test(u64::power_of_2(25) - 39, true);\n    test(u64::power_of_2(26) - 5, true);\n    test(u64::power_of_2(27) - 39, true);\n    test(u64::power_of_2(28) - 57, true);\n    test(u64::power_of_2(29) - 3, true);\n    test(u64::power_of_2(30) - 35, true);\n    test(u64::power_of_2(31) - 1, true);\n    test(u64::power_of_2(32) - 5, true);\n    test(u64::power_of_2(33) - 9, true);\n    test(u64::power_of_2(34) - 41, true);\n    test(u64::power_of_2(35) - 31, true);\n    test(u64::power_of_2(36) - 5, true);\n    test(u64::power_of_2(37) - 25, true);\n    test(u64::power_of_2(38) - 45, true);\n    test(u64::power_of_2(39) - 7, true);\n    test(u64::power_of_2(40) - 87, true);\n    test(u64::power_of_2(41) - 21, true);\n    test(u64::power_of_2(42) - 11, true);\n    test(u64::power_of_2(43) - 57, true);\n    test(u64::power_of_2(44) - 17, true);\n    test(u64::power_of_2(45) - 55, true);\n    test(u64::power_of_2(46) - 21, true);\n    test(u64::power_of_2(47) - 115, true);\n    test(u64::power_of_2(48) - 59, true);\n    test(u64::power_of_2(49) - 81, true);\n    test(u64::power_of_2(50) - 27, true);\n    test(u64::power_of_2(51) - 129, true);\n    test(u64::power_of_2(52) - 47, true);\n    // - rem < 0 second time in n_mulmod_precomp_u64\n    test(u64::power_of_2(53) - 111, true);\n    // - exp.even() in n_powmod2_ui_preinv_u64\n    test(u64::power_of_2(54) - 33, true);\n    test(u64::power_of_2(55) - 55, true);\n    // - y != 1 in n_is_strong_probabprime2_preinv_u64\n    test(u64::power_of_2(56) - 5, true);\n    test(u64::power_of_2(57) - 13, true);\n    test(u64::power_of_2(58) - 27, true);\n    test(u64::power_of_2(59) - 55, true);\n    test(u64::power_of_2(60) - 93, true);\n    test(u64::power_of_2(61) - 1, true);\n    test(u64::power_of_2(62) - 57, true);\n    test(u64::power_of_2(63) - 25, true);\n    test(u64::MAX - 58, true);\n\n    test(u64::power_of_2(5) + 5, true);\n    test(u64::power_of_2(6) + 3, true);\n    test(u64::power_of_2(7) + 3, true);\n    test(u64::power_of_2(9) + 9, true);\n    test(u64::power_of_2(10) + 7, true);\n    test(u64::power_of_2(11) + 5, true);\n    test(u64::power_of_2(12) + 3, true);\n    test(u64::power_of_2(13) + 17, true);\n    test(u64::power_of_2(14) + 27, true);\n    // - diff > diff2 in n_is_oddprime_binary_u32\n    // - diff > diff2 in n_is_oddprime_binary_u64\n    test(u64::power_of_2(15) + 3, true);\n    test(u64::power_of_2(17) + 29, true);\n    test(u64::power_of_2(18) + 3, true);\n    test(u64::power_of_2(19) + 21, true);\n    test(u64::power_of_2(20) + 7, true);\n    test(u64::power_of_2(21) + 17, true);\n    test(u64::power_of_2(22) + 15, true);\n    test(u64::power_of_2(23) + 9, true);\n    test(u64::power_of_2(24) + 43, true);\n    test(u64::power_of_2(25) + 35, true);\n    test(u64::power_of_2(26) + 15, true);\n    test(u64::power_of_2(27) + 29, true);\n    test(u64::power_of_2(28) + 3, true);\n    test(u64::power_of_2(29) + 11, true);\n    test(u64::power_of_2(30) + 3, true);\n    test(u64::power_of_2(31) + 11, true);\n    test(u64::power_of_2(32) + 15, true);\n    test(u64::power_of_2(33) + 17, true);\n    test(u64::power_of_2(34) + 25, true);\n    test(u64::power_of_2(35) + 53, true);\n    test(u64::power_of_2(36) + 31, true);\n    test(u64::power_of_2(37) + 9, true);\n    test(u64::power_of_2(38) + 7, true);\n    test(u64::power_of_2(39) + 23, true);\n    test(u64::power_of_2(40) + 15, true);\n    test(u64::power_of_2(41) + 27, true);\n    test(u64::power_of_2(42) + 15, true);\n    test(u64::power_of_2(43) + 29, true);\n    test(u64::power_of_2(44) + 7, true);\n    test(u64::power_of_2(45) + 59, true);\n    test(u64::power_of_2(46) + 15, true);\n    test(u64::power_of_2(47) + 5, true);\n    test(u64::power_of_2(48) + 21, true);\n    test(u64::power_of_2(49) + 69, true);\n    test(u64::power_of_2(50) + 55, true);\n    test(u64::power_of_2(51) + 21, true);\n    test(u64::power_of_2(52) + 21, true);\n    test(u64::power_of_2(53) + 5, true);\n    test(u64::power_of_2(54) + 159, true);\n    test(u64::power_of_2(55) + 3, true);\n    test(u64::power_of_2(56) + 81, true);\n    test(u64::power_of_2(57) + 9, true);\n    test(u64::power_of_2(58) + 69, true);\n    test(u64::power_of_2(59) + 131, true);\n    test(u64::power_of_2(60) + 33, true);\n    test(u64::power_of_2(61) + 15, true);\n    test(u64::power_of_2(62) + 135, true);\n    test(u64::power_of_2(63) + 29, true);\n\n    test(11, true);\n    test(101, true);\n    test(1001, false);\n    test(10001, false);\n    test(100001, false);\n    test(1000001, false);\n    test(10000001, false);\n    test(100000001, false);\n    test(1000000001, false);\n    test(10000000001, false);\n    test(100000000001, false);\n    test(1000000000001, false);\n    test(10000000000001, false);\n    test(100000000000001, false);\n    test(1000000000000001, false);\n    // - !n_is_strong_probabprime2_preinv_u64(n, ninv, 2, d) in n_is_probabprime_bpsw_u64\n    test(10000000000000001, false);\n    test(100000000000000001, false);\n    test(1000000000000000001, false);\n    test(10000000000000000001, false);\n\n    test(11, true);\n    test(101, true);\n    test(1009, true);\n    test(10007, true);\n    test(100003, true);\n    test(1000003, true);\n    test(10000019, true);\n    test(100000007, true);\n    test(1000000007, true);\n    test(10000000019, true);\n    test(100000000003, true);\n    // - 0 <= rem <= n in n_mulmod_precomp_u64\n    test(1000000000039, true);\n    test(10000000000037, true);\n    test(100000000000031, true);\n    test(1000000000000037, true);\n    test(10000000000000061, true);\n    test(100000000000000003, true);\n    test(1000000000000000003, true);\n    test(10000000000000000051, true);\n\n    test(97, true);\n    test(997, true);\n    test(9973, true);\n    test(99991, true);\n    test(999983, true);\n    test(9999991, true);\n    test(99999989, true);\n    test(999999937, true);\n    test(9999999967, true);\n    test(99999999977, true);\n    test(999999999989, true);\n    test(9999999999971, true);\n    test(99999999999973, true);\n    test(999999999999989, true);\n    test(9999999999999937, true);\n    test(99999999999999997, true);\n    test(999999999999999989, true);\n    test(9999999999999999961, true);\n\n    test(1000003, true);\n    test(5509785649208481923, true);\n    test(8435959509307532899, true);\n    test(15455033058440548141, true);\n    test(13200125384684540339, true);\n    // - a <= 1 || a == n - 1 n_is_strong_probabprime_precomp_u64\n    test(6855593, true);\n    // - !n_is_strong_probabprime_precomp_u64(n, npre, 2, d) in n_is_probabprime_bpsw_u64\n    test(1050535501, false);\n    test(1114427291855351, true);\n}\n\n#[test]\nfn test_is_prime() {\n    is_prime_helper::<u8>();\n    is_prime_helper::<u16>();\n    is_prime_helper::<u32>();\n    is_prime_helper::<u64>();\n    is_prime_helper::<usize>();\n}\n\nfn is_prime_properties_helper_helper<T: IsPrime + PrimitiveUnsigned>(n: T) {\n    let is_prime = n.is_prime();\n    assert_eq!(is_prime_naive(n), is_prime);\n}\n\nfn is_prime_properties_helper_1<T: IsPrime + PrimitiveUnsigned>() {\n    if T::WIDTH < u32::WIDTH {\n        for n in exhaustive_unsigneds::<T>() {\n            is_prime_properties_helper_helper(n);\n        }\n    } else {\n        for n in exhaustive_unsigneds::<T>().take(10_000_000) {\n            is_prime_properties_helper_helper(n);\n        }\n        unsigned_gen::<T>().test_properties(|n| {\n            is_prime_properties_helper_helper(n);\n        });\n    }\n}\n\nfn is_prime_properties_helper_2<T: PrimitiveUnsigned, DT: From<T> + IsPrime + PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_50::<T>().test_properties(|(a, b)| {\n        assert!(!(DT::from(a) * DT::from(b)).is_prime());\n    });\n}\n\n#[test]\nfn is_prime_properties() {\n    is_prime_properties_helper_1::<u8>();\n    is_prime_properties_helper_1::<u16>();\n    is_prime_properties_helper_1::<u32>();\n    is_prime_properties_helper_1::<u64>();\n    is_prime_properties_helper_1::<usize>();\n\n    is_prime_properties_helper_2::<u16, u32>();\n    is_prime_properties_helper_2::<u32, u64>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/is_square.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::factorization::traits::IsSquare;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_4, signed_gen_var_10, unsigned_gen, unsigned_gen_var_21,\n    unsigned_pair_gen_var_27,\n};\n\nfn is_square_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.is_square(), x.checked_sqrt().is_some());\n    });\n\n    unsigned_gen_var_21::<T>().test_properties(|x| {\n        assert!(x.square().is_square());\n    });\n\n    // 1 < x < 2^32 avoids overflow and consecutive squares (0, 1).\n    unsigned_pair_gen_var_27::<T>().test_properties(|(mut x, mut y)| {\n        // test non squares in interval (x^2, (x+1)^2)\n        x.mod_power_of_2_assign(T::WIDTH >> 1);\n        y.mod_power_of_2_assign(T::WIDTH >> 1);\n        if x != T::ZERO {\n            let sqr = x.square();\n            let non_sqr = sqr + (y % (x << 1u32)) + T::ONE;\n            assert!(!non_sqr.is_square());\n        }\n    });\n}\n\nfn is_square_properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U> + UnsignedAbs<Output = U>,\n>() {\n    signed_gen::<S>().test_properties(|x| {\n        assert_eq!(x.is_square(), x >= S::ZERO && x.unsigned_abs().is_square());\n    });\n\n    signed_gen_var_10::<U, S>().test_properties(|x| {\n        assert!(x.square().is_square());\n    });\n\n    // test negative signed integers are non square and positive signed integer squares are squares.\n    signed_gen_var_4::<S>().test_properties(|x| {\n        assert!(!x.is_square());\n    });\n}\n\n#[test]\nfn is_square_properties() {\n    apply_fn_to_unsigneds!(is_square_properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(is_square_properties_helper_signed);\n}\n\n#[test]\nfn test_is_square() {\n    assert!(0u8.is_square());\n    assert!(0u16.is_square());\n    assert!(0u32.is_square());\n    assert!(0u64.is_square());\n\n    assert!(1u64.is_square());\n    assert!(4u64.is_square());\n    assert!(9u64.is_square());\n    assert!(16u64.is_square());\n    assert!(25u64.is_square());\n\n    assert!(0i8.is_square());\n    assert!(0i16.is_square());\n    assert!(0i32.is_square());\n    assert!(0i64.is_square());\n\n    assert!(1i64.is_square());\n    assert!(4i64.is_square());\n    assert!(9i64.is_square());\n    assert!(16i64.is_square());\n    assert!(25i64.is_square());\n\n    assert!(!(-1i64).is_square());\n    assert!(!(-4i64).is_square());\n    assert!(!(-9i64).is_square());\n    assert!(!(-16i64).is_square());\n    assert!(!(-25i64).is_square());\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/prime_indicator_sequence.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::factorization::primes::prime_indicator_sequence;\n\n#[test]\npub fn test_prime_indicator_sequence() {\n    let s: String = prime_indicator_sequence()\n        .take(1000)\n        .map(|b| if b { '1' } else { '0' })\n        .collect();\n    assert_eq!(\n        s,\n        \"01101010001010001010001000001010000010001010001000001000001010000010001010000010001000001\\\n        000000010001010001010001000000000000010001000001010000000001010000010000010001000001000001\\\n        010000000001010001010000000000010000000000010001010001000001010000000001000001000001000001\\\n        010000010001010000000001000000000000010001010001000000000000010000010000000001010001000001\\\n        000000010000010000010001000001000000010001000000010000000001010000000001010000010001000001\\\n        000000010001010001000000000001000000010001000000010001000001000000000001010000000000000000\\\n        010000010000000001000001000001010000010000000001000001000001010000010000010001010000000000\\\n        010000000001010001000001000001010000000000010001000001000000010000000001000000010000000001\\\n        000000010000010000010001000000010000010001000000010001000000000000010000000001000000000001\\\n        010000000001010001010000000001000000000000010001010001000000000000010001010001000000000000\\\n        000000010001000000010000000001000000010001000001000001000000000000010001000001000001000000\\\n        01000001000\"\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/prime_indicator_sequence_less_than.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::itertools::Itertools;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::factorization::primes::{\n    prime_indicator_sequence, prime_indicator_sequence_less_than,\n};\nuse malachite_base::test_util::generators::unsigned_gen_var_5;\n\nfn test_prime_indicator_sequence_helper(limit: u64, out: &str) {\n    let s: String = prime_indicator_sequence_less_than(limit)\n        .take(1000)\n        .map(|b| if b { '1' } else { '0' })\n        .collect();\n    assert_eq!(s, out);\n}\n\n#[test]\npub fn test_prime_indicator_sequence_less_than() {\n    test_prime_indicator_sequence_helper(0, \"\");\n    test_prime_indicator_sequence_helper(1, \"\");\n    test_prime_indicator_sequence_helper(2, \"0\");\n    test_prime_indicator_sequence_helper(3, \"01\");\n    test_prime_indicator_sequence_helper(4, \"011\");\n    test_prime_indicator_sequence_helper(5, \"0110\");\n    test_prime_indicator_sequence_helper(6, \"01101\");\n    test_prime_indicator_sequence_helper(7, \"011010\");\n    test_prime_indicator_sequence_helper(8, \"0110101\");\n    test_prime_indicator_sequence_helper(9, \"01101010\");\n    test_prime_indicator_sequence_helper(10, \"011010100\");\n    test_prime_indicator_sequence_helper(\n        100,\n        \"01101010001010001010001000001010000010001010001000001000001010000010001010000010001000001\\\n        0000000100\",\n    );\n    test_prime_indicator_sequence_helper(\n        1000,\n        \"01101010001010001010001000001010000010001010001000001000001010000010001010000010001000001\\\n        000000010001010001010001000000000000010001000001010000000001010000010000010001000001000001\\\n        010000000001010001010000000000010000000000010001010001000001010000000001000001000001000001\\\n        010000010001010000000001000000000000010001010001000000000000010000010000000001010001000001\\\n        000000010000010000010001000001000000010001000000010000000001010000000001010000010001000001\\\n        000000010001010001000000000001000000010001000000010001000001000000000001010000000000000000\\\n        010000010000000001000001000001010000010000000001000001000001010000010000010001010000000000\\\n        010000000001010001000001000001010000000000010001000001000000010000000001000000010000000001\\\n        000000010000010000010001000000010000010001000000010001000000000000010000000001000000000001\\\n        010000000001010001010000000001000000000000010001010001000000000000010001010001000000000000\\\n        000000010001000000010000000001000000010001000001000001000000000000010001000001000001000000\\\n        0100000100\",\n    );\n}\n\n#[test]\nfn prime_indicator_sequence_less_than_properties() {\n    unsigned_gen_var_5().test_properties(|limit| {\n        let bs = prime_indicator_sequence_less_than(limit).collect_vec();\n        let len = usize::exact_from(limit.saturating_sub(1));\n        assert_eq!(bs.len(), len);\n        assert_eq!(prime_indicator_sequence().take(len).collect_vec(), bs);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/prime_sieve.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::factorization::prime_sieve::{\n    limbs_prime_sieve_size, limbs_prime_sieve_u32, limbs_prime_sieve_u64,\n};\nuse malachite_base::test_util::generators::unsigned_gen_var_26;\nuse malachite_base::test_util::num::factorization::prime_sieve::{\n    limbs_prime_sieve_naive_1, limbs_prime_sieve_naive_2,\n};\n\n#[test]\nfn test_limbs_prime_sieve_u32() {\n    let test = |n, out, out_sieve: &[u32]| {\n        let mut sieve = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_u32(&mut sieve, n), out);\n        assert_eq!(sieve, out_sieve);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_naive_1::<u32>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_naive_2::<u32>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n    };\n    let test_large = |n, out| {\n        let mut sieve = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_u32(&mut sieve, n), out);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_naive_1::<u32>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_naive_2::<u32>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n    };\n    // - size <= BLOCK_SIZE << 1\n    // - limbs == 0 in first_block_primesieve\n    // - (bits + 1) & Limb::WIDTH_MASK != 0 in first_block_primesieve\n    // - (bits + 1) & Limb::WIDTH_MASK != 0\n    test(5, 1, &[4294967294]);\n    // - (bits + 1) & Limb::WIDTH_MASK == 0 in first_block_primesieve\n    // - (bits + 1) & Limb::WIDTH_MASK == 0\n    test(97, 23, &[1762821248]);\n    // - limbs != 0 in first_block_primesieve\n    // - offset == 0 first time in fill_bitpattern\n    test(101, 24, &[1762821248, 4294967294]);\n    // - n_to_bit(SEED_LIMIT + 1) >= Limb::WIDTH in first_block_primesieve\n    // - bit_array[index] & mask == 0 in first_block_primesieve\n    // - lindex <= bits first time in first_block_primesieve\n    // - lindex > bits second time in first_block_primesieve\n    // - lindex > bits first time in first_block_primesieve\n    test(121, 28, &[1762821248, 4294967264]);\n    // - lindex <= bits second time in first_block_primesieve\n    test(187, 40, &[1762821248, 4069837280]);\n    // - limbs != 0 first time in fill_bitpattern\n    // - limbs == 0 second time in fill_bitpattern\n    test(197, 43, &[1762821248, 848611808, 4294967294]);\n    // - limbs != 0 second time in fill_bitpattern\n    test(293, 60, &[1762821248, 848611808, 3299549660, 4294967294]);\n    // - bit_array[index] & mask != 0 in first_block_primesieve\n    test(\n        529,\n        97,\n        &[1762821248, 848611808, 3299549660, 2510511646, 3093902182, 4294954649],\n    );\n    test(\n        10000,\n        1227,\n        &[\n            1762821248, 848611808, 3299549660, 2510511646, 3093902182, 1255657113, 1921893675,\n            1704310490, 2276511454, 3933052807, 3442636201, 1062642164, 1957128923, 4248324347,\n            2716726959, 3686403537, 3525810597, 3469209982, 3144777046, 3941341117, 1482358003,\n            990820275, 2682219599, 3848526070, 2757661436, 4267419563, 1005886333, 361623151,\n            3991325978, 3193600964, 3397105325, 3613891391, 535771113, 3287706519, 969495549,\n            1870576883, 3526745072, 3584421084, 3585498683, 3975838511, 3365889969, 3532586489,\n            1037283151, 3414129786, 4285215436, 4005484237, 1590667644, 3585963000, 3148695799,\n            570277455, 4005035495, 1580573621, 2816195785, 3656121683, 788406134, 4288601775,\n            3209020842, 1475950840, 3242065846, 4101944926, 1238805919, 2074062642, 2532965119,\n            3010383198, 4133027549, 1790162093, 3623277869, 1878747087, 3720235807, 3033363191,\n            4214476775, 2614931297, 3853071358, 3216472538, 3950886702, 2080282321, 2138895219,\n            667676511, 2805099227, 1743386524, 4235696025, 1592700903, 3706043128, 3619639167,\n            2080028206, 4197678553, 2138431973, 2627728235, 2372861911, 1911355103, 1566205629,\n            3013582698, 1609955564, 4047489974, 4125088590, 3923174885, 3200773946, 3589010553,\n            3953720370, 2080348909, 1828150423, 2537461567, 2647369563, 4126591959, 4294967295,\n        ],\n    );\n    // - size > BLOCK_SIZE << 1\n    // - offset != 0 first time in fill_bitpattern\n    // - offset != 0 second time in fill_bitpattern\n    // - offset <= Limb::WIDTH in fill_bitpattern\n    // - offset != Limb::WIDTH in fill_bitpattern\n    // - offset > 70 - 2 * Limb::WIDTH in fill_bitpattern\n    // - sieve[index] & mask == 0 in block_resieve\n    // - lindex <= bits + off in block_resieve\n    // - lindex < off first time in block_resieve\n    // - lindex < off second time in block_resieve\n    // - sieve[index] & mask != 0 in block_resieve\n    // - lindex >= off first time in block_resieve\n    // - lindex >= off second time in block_resieve\n    // - lindex > bits + off in block_resieve\n    // - off >= size\n    test_large(400000, 33858);\n    // - Limb::WIDTH < offset < 2 * Limb::WIDTH in fill_bitpattern\n    // - offset > 70 - Limb::WIDTH in fill_bitpattern\n    test_large(400037, 33861);\n    // - offset <= 70 - 2 * Limb::WIDTH in fill_bitpattern\n    test_large(400325, 33885);\n    // - offset <= 70 - Limb::WIDTH in fill_bitpattern\n    // - offset != 70 - Limb::WIDTH in fill_bitpattern\n    test_large(400421, 33891);\n    // - offset >= 2 * Limb::WIDTH in fill_bitpattern\n    test_large(400517, 33896);\n    // - offset == 70 - Limb::WIDTH in fill_bitpattern\n    test_large(401477, 33963);\n    // - offset == 0 second time in fill_bitpattern\n    test_large(401573, 33969);\n    // - offset == Limb::WIDTH in fill_bitpattern\n    test_large(401669, 33975);\n}\n\n#[test]\nfn test_limbs_prime_sieve_u64() {\n    let test = |n, out, out_sieve: &[u64]| {\n        let mut sieve = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_u64(&mut sieve, n), out);\n        assert_eq!(sieve, out_sieve);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_naive_1(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_naive_2(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n    };\n    let test_large = |n, out| {\n        let mut sieve = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_u64(&mut sieve, n), out);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_naive_1(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_naive_2(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n    };\n    // - offset == 0 first time in fill_bitpattern\n    // - limbs == 0 first time in fill_bitpattern\n    // - limbs != 0 first time in fill_bitpattern\n    // - limbs == 0 second time in fill_bitpattern\n    // - limbs != 0 second time in fill_bitpattern\n    test(197, 43, &[3644759964122252416, 18446744073709551614]);\n    test(\n        10000,\n        1227,\n        &[\n            3644759964122252416,\n            10782565419096678876,\n            5393006238418678630,\n            7319957818701628715,\n            16892333181782511326,\n            4564013345173304745,\n            18246414135122684635,\n            15832982633990452911,\n            14900143419172559269,\n            16927931203039886678,\n            4255540678821084403,\n            16529293611135626319,\n            18328427464153273084,\n            1553159608027356029,\n            13716411700845399322,\n            15521545339038054061,\n            14120591978486773737,\n            8034066538108113917,\n            15394971334399613936,\n            17076096382507834939,\n            15172343443912353713,\n            14663575776206761807,\n            17203423806843728588,\n            15401593811256715644,\n            2449323022019807479,\n            6788512015120334311,\n            15702923061497674953,\n            18419404369980956534,\n            6339160591512749482,\n            17617719310405205942,\n            8908031218484161951,\n            12929497386370857727,\n            7688687648106938077,\n            8069157299743544621,\n            13028195705955437343,\n            11231044406116339687,\n            13814644363045188606,\n            8934744539092860718,\n            2867648781191279475,\n            7487788107672218331,\n            6840598294930364313,\n            15546231849291725560,\n            18028892106335630894,\n            11286006834239234533,\n            8209207660800573399,\n            12943239133267650237,\n            17383837070827845868,\n            16849907831688649550,\n            15414682953334648634,\n            8935030532378000434,\n            10898314446950063255,\n            17723577510488942427,\n            18446744073709551615,\n        ],\n    );\n    // - offset != 0 first time in fill_bitpattern\n    // - m21 != 0 in fill_bitpattern\n    // - m21 < Limb::WIDTH in fill_bitpattern\n    // - m21 <= 110 - Limb::WIDTH in fill_bitpattern\n    // - offset != 0 second time in fill_bitpattern\n    // - offset >= 2 * Limb::WIDTH in fill_bitpattern\n    test_large(800000, 63949);\n    // - m21 >= Limb::WIDTH in fill_bitpattern\n    // - offset <= Limb::WIDTH in fill_bitpattern\n    // - offset != Limb::WIDTH in fill_bitpattern\n    // - offset <= 182 - 2 * Limb::WIDTH in fill_bitpattern\n    test_large(800069, 63953);\n    // - m21 > 110 - Limb::WIDTH in fill_bitpattern\n    // - Limb::WIDTH < offset < 2 * Limb::WIDTH in fill_bitpattern\n    // - offset <= 182 - Limb::WIDTH in fill_bitpattern\n    // - offset != 182 - Limb::WIDTH in fill_bitpattern\n    test_large(800261, 63971);\n    // - offset > 182 - 2 * Limb::WIDTH in fill_bitpattern\n    test_large(801797, 64088);\n    // - offset > 182 - Limb::WIDTH in fill_bitpattern\n    test_large(801989, 64100);\n    // - m21 == 0 in fill_bitpattern\n    test_large(805061, 64323);\n    // - off < size\n    // - offset == Limb::WIDTH in fill_bitpattern\n    test_large(1800005, 135070);\n    // - offset == 182 - Limb::WIDTH in fill_bitpattern\n    test_large(1808261, 135646);\n    // - offset == 0 second time in fill_bitpattern\n    test_large(1808453, 135656);\n}\n\n#[test]\nfn limbs_prime_sieve_properties() {\n    unsigned_gen_var_26().test_properties(|n: u64| {\n        let mut sieve = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        let out = limbs_prime_sieve_u32(&mut sieve, n);\n        assert!(out < n);\n\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_naive_1::<u32>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u32>(n)];\n        assert_eq!(limbs_prime_sieve_naive_2::<u32>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n\n        let mut sieve = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        let out = limbs_prime_sieve_u64(&mut sieve, n);\n        assert!(out < n);\n\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_naive_1::<u64>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n\n        let mut sieve_alt = vec![0; limbs_prime_sieve_size::<u64>(n)];\n        assert_eq!(limbs_prime_sieve_naive_2::<u64>(&mut sieve_alt, n), out);\n        assert_eq!(sieve, sieve_alt);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/primes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::comparison::is_strictly_ascending;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::factorization::traits::{IsPrime, Primes};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_5, unsigned_pair_gen_var_28, unsigned_triple_gen_var_24,\n};\nuse malachite_base::test_util::num::factorization::primes::primes_naive;\n\nfn test_primes_less_than_helper<T: PrimitiveUnsigned>() {\n    let test = |n: u8, out: &[u8]| {\n        let n = T::from(n);\n        let out = out.iter().map(|&x| T::from(x)).collect_vec();\n        assert_eq!(T::primes_less_than(&n).collect_vec(), out);\n        assert_eq!(T::primes().take_while(|&p| p < n).collect_vec(), out);\n        assert_eq!(\n            primes_naive::<T>().take_while(|&p| p < n).collect_vec(),\n            out\n        );\n    };\n    test(0, &[]);\n    test(1, &[]);\n    test(2, &[]);\n    test(3, &[2]);\n    test(4, &[2, 3]);\n    test(5, &[2, 3]);\n    test(6, &[2, 3, 5]);\n    test(7, &[2, 3, 5]);\n    test(8, &[2, 3, 5, 7]);\n    test(9, &[2, 3, 5, 7]);\n    test(10, &[2, 3, 5, 7]);\n    test(\n        100,\n        &[\n            2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n            89, 97,\n        ],\n    );\n}\n\n#[test]\nfn test_primes_less_than() {\n    apply_fn_to_unsigneds!(test_primes_less_than_helper);\n}\n\nfn test_primes_less_than_or_equal_to_helper<T: PrimitiveUnsigned>() {\n    let test = |n: u8, out: &[u8]| {\n        let n = T::from(n);\n        let out = out.iter().map(|&x| T::from(x)).collect_vec();\n        assert_eq!(T::primes_less_than_or_equal_to(&n).collect_vec(), out);\n        assert_eq!(T::primes().take_while(|&p| p <= n).collect_vec(), out);\n        assert_eq!(\n            primes_naive::<T>().take_while(|&p| p <= n).collect_vec(),\n            out\n        );\n    };\n    test(0, &[]);\n    test(1, &[]);\n    test(2, &[2]);\n    test(3, &[2, 3]);\n    test(4, &[2, 3]);\n    test(5, &[2, 3, 5]);\n    test(6, &[2, 3, 5]);\n    test(7, &[2, 3, 5, 7]);\n    test(8, &[2, 3, 5, 7]);\n    test(9, &[2, 3, 5, 7]);\n    test(10, &[2, 3, 5, 7]);\n    test(\n        100,\n        &[\n            2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,\n            89, 97,\n        ],\n    );\n}\n\n#[test]\nfn test_primes_less_than_or_equal_to() {\n    apply_fn_to_unsigneds!(test_primes_less_than_or_equal_to_helper);\n}\n\n#[test]\nfn test_primes() {\n    let expected = &[\n        2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89,\n        97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,\n        191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,\n        283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,\n        401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,\n        509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619,\n        631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743,\n        751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,\n        877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,\n        1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093,\n        1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213,\n        1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303,\n        1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439,\n        1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543,\n        1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627,\n        1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753,\n        1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877,\n        1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999,\n        2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111,\n        2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239,\n        2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347,\n        2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447,\n        2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593,\n        2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699,\n        2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801,\n        2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927,\n        2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061,\n        3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203,\n        3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323,\n        3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457,\n        3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557,\n        3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673,\n        3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797,\n        3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919,\n        3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049,\n        4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159,\n        4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283,\n        4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441,\n        4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561,\n        4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679,\n        4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813,\n        4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957,\n        4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077,\n        5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209,\n        5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351,\n        5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477,\n        5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591,\n        5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717,\n        5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849,\n        5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987,\n        6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121,\n        6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257,\n        6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359,\n        6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521,\n        6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659,\n        6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781,\n        6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907,\n        6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019,\n        7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187,\n        7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321,\n        7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487,\n        7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583,\n        7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703,\n        7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867,\n        7873, 7877, 7879, 7883, 7901, 7907, 7919,\n    ];\n    for p in expected {\n        assert!(p.is_prime());\n    }\n    assert_eq!(u16::primes().take(1000).collect_vec(), expected);\n    assert_eq!(primes_naive::<u16>().take(1000).collect_vec(), expected);\n\n    assert_eq!(u8::primes().count(), 54);\n    assert_eq!(u16::primes().count(), 6542);\n\n    const U32_PRIME_COUNT: usize = 203280221;\n    assert_eq!(u32::primes().count(), U32_PRIME_COUNT);\n    assert_eq!(\n        u32::primes_less_than_or_equal_to(&u32::MAX).count(),\n        U32_PRIME_COUNT\n    );\n    assert_eq!(\n        u64::primes_less_than_or_equal_to(&u64::wrapping_from(u32::MAX)).count(),\n        U32_PRIME_COUNT\n    );\n}\n\nfn primes_less_than_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_5::<T>().test_properties(|n| {\n        let ps = T::primes_less_than(&n).collect_vec();\n        for p in &ps {\n            let p: u64 = p.wrapping_into();\n            assert!(p.is_prime());\n        }\n        assert!(is_strictly_ascending(ps.iter()));\n        assert_eq!(\n            T::primes_less_than_or_equal_to(&n.saturating_sub(T::ONE)).collect_vec(),\n            ps\n        );\n        assert_eq!(T::primes().take_while(|&p| p < n).collect_vec(), ps);\n        assert_eq!(primes_naive::<T>().take_while(|&p| p < n).collect_vec(), ps);\n    });\n}\n\n#[test]\nfn primes_less_than_properties() {\n    apply_fn_to_unsigneds!(primes_less_than_properties_helper);\n}\n\nfn primes_less_than_or_equal_to_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_5::<T>().test_properties(|n| {\n        let ps = T::primes_less_than_or_equal_to(&n).collect_vec();\n        for p in &ps {\n            let p: u64 = p.wrapping_into();\n            assert!(p.is_prime());\n        }\n        assert!(is_strictly_ascending(ps.iter()));\n        assert_eq!(\n            T::primes_less_than(&n.saturating_add(T::ONE)).collect_vec(),\n            ps\n        );\n        assert_eq!(T::primes().take_while(|&p| p <= n).collect_vec(), ps);\n        assert_eq!(\n            primes_naive::<T>().take_while(|&p| p <= n).collect_vec(),\n            ps\n        );\n    });\n}\n\n#[test]\nfn primes_less_than_or_equal_to_properties() {\n    apply_fn_to_unsigneds!(primes_less_than_or_equal_to_properties_helper);\n}\n\n// TODO replace with real version once available\nfn next_prime_after<T: IsPrime + PrimitiveUnsigned>(mut n: T) -> T {\n    loop {\n        n += T::ONE;\n        if n.is_prime() {\n            return n;\n        }\n    }\n}\n\nfn primes_less_than_jump_after_properties_helper<T: IsPrime + PrimitiveUnsigned>() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 10000);\n    unsigned_triple_gen_var_24::<T, usize>().test_properties_with_config(\n        &config,\n        |(size, jump, skip)| {\n            let mut ps = T::primes_less_than(&size);\n            for _ in 0..skip {\n                ps.next();\n            }\n            if ps.jump_after(jump) {\n                let p = ps.next().unwrap();\n                assert!(p.is_prime());\n                assert_eq!(p, next_prime_after(jump));\n            } else {\n                assert!(ps.next().is_none());\n            }\n        },\n    );\n}\n\n#[test]\nfn primes_less_than_jump_after_properties() {\n    primes_less_than_jump_after_properties_helper::<u8>();\n    primes_less_than_jump_after_properties_helper::<u16>();\n    primes_less_than_jump_after_properties_helper::<u32>();\n    primes_less_than_jump_after_properties_helper::<u64>();\n    primes_less_than_jump_after_properties_helper::<usize>();\n}\n\nfn primes_jump_after_properties_helper<T: IsPrime + PrimitiveUnsigned>() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 10000);\n    unsigned_pair_gen_var_28::<T, usize>().test_properties_with_config(&config, |(jump, skip)| {\n        let mut ps = T::primes();\n        for _ in 0..skip {\n            ps.next();\n        }\n        if ps.jump_after(jump) {\n            let p = ps.next().unwrap();\n            assert!(p.is_prime());\n            assert_eq!(p, next_prime_after(jump));\n        } else {\n            assert!(ps.next().is_none());\n        }\n    });\n}\n\n#[test]\nfn primes_jump_after_properties() {\n    let mut primes = u16::primes();\n    assert_eq!(primes.jump_after(u16::MAX), false);\n\n    primes_jump_after_properties_helper::<u8>();\n    primes_jump_after_properties_helper::<u16>();\n    primes_jump_after_properties_helper::<u32>();\n    primes_jump_after_properties_helper::<u64>();\n    primes_jump_after_properties_helper::<usize>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/factorization/primitive_root_prime.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::factorization::traits::{IsPrime, PrimitiveRootPrime};\nuse malachite_base::test_util::generators::unsigned_gen_var_29;\nuse std::fmt::Debug;\nuse std::panic::catch_unwind;\n\nfn primitive_root_prime_helper<T: PrimitiveRootPrime<Output = T> + PrimitiveUnsigned>() {\n    let test = |n: u64, out| {\n        if let (Ok(n), Ok(out)) = (T::try_from(n), T::try_from(out)) {\n            assert_eq!(n.primitive_root_prime(), out);\n        }\n    };\n    test(2, 1);\n    test(3, 2);\n    test(5, 2);\n    test(7, 3);\n    test(11, 2);\n    test(191, 19);\n\n    test(9223372036854775807, 2);\n    test(8760810010780182161, 3);\n}\n\n#[test]\nfn test_primitive_root_prime() {\n    primitive_root_prime_helper::<u8>();\n    primitive_root_prime_helper::<u16>();\n    primitive_root_prime_helper::<u32>();\n    primitive_root_prime_helper::<u64>();\n    primitive_root_prime_helper::<usize>();\n}\n\nfn primitive_root_prime_fail_helper<T: PrimitiveRootPrime + PrimitiveUnsigned>() {\n    assert_panic!(T::ZERO.primitive_root_prime());\n}\n\n#[test]\npub fn primitive_root_prime_fail() {\n    primitive_root_prime_fail_helper::<u8>();\n    primitive_root_prime_fail_helper::<u16>();\n    primitive_root_prime_fail_helper::<u32>();\n    primitive_root_prime_fail_helper::<u64>();\n    primitive_root_prime_fail_helper::<usize>();\n}\n\nfn primitive_root_prime_properties_helper<T: IsPrime + PrimitiveRootPrime + PrimitiveUnsigned>()\nwhere\n    <T as PrimitiveRootPrime>::Output: Copy + Debug + PartialOrd<T>,\n{\n    unsigned_gen_var_29::<T>().test_properties(|n| {\n        let primitive_root = n.primitive_root_prime();\n        assert_ne!(primitive_root, T::ZERO);\n        if n > T::TWO {\n            assert_ne!(primitive_root, T::ONE);\n        }\n        assert!(primitive_root < n);\n    });\n}\n\n#[test]\nfn primitive_root_prime_properties() {\n    primitive_root_prime_properties_helper::<u8>();\n    primitive_root_prime_properties_helper::<u16>();\n    primitive_root_prime_properties_helper::<u32>();\n    primitive_root_prime_properties_helper::<u64>();\n    primitive_root_prime_properties_helper::<usize>();\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/abs_negative_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen;\n\nfn abs_negative_zero_helper<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        let out = NiceFloat(out);\n\n        assert_eq!(NiceFloat(n.abs_negative_zero()), out);\n\n        let mut n = n;\n        n.abs_negative_zero_assign();\n        assert_eq!(NiceFloat(n), out);\n    };\n    test(T::ZERO, T::ZERO);\n    test(T::NEGATIVE_ZERO, T::ZERO);\n    test(T::NAN, T::NAN);\n    test(T::INFINITY, T::INFINITY);\n    test(T::NEGATIVE_INFINITY, T::NEGATIVE_INFINITY);\n    test(T::ONE, T::ONE);\n    test(T::NEGATIVE_ONE, T::NEGATIVE_ONE);\n    test(T::from(1.234), T::from(1.234));\n    test(T::from(-1.234), T::from(-1.234));\n}\n\n#[test]\nfn test_abs_negative_zero() {\n    apply_fn_to_primitive_floats!(abs_negative_zero_helper);\n}\n\nfn abs_negative_zero_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|x| {\n        let y = x.abs_negative_zero();\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        assert!(x == y || x == NiceFloat(T::NEGATIVE_ZERO) && y == NiceFloat(T::ZERO));\n        assert_eq!(NiceFloat(y.0.abs_negative_zero()), y);\n\n        let mut x = x.0;\n        x.abs_negative_zero_assign();\n        assert_eq!(NiceFloat(x), y);\n    });\n}\n\n#[test]\nfn abs_negative_zero_properties() {\n    apply_fn_to_primitive_floats!(abs_negative_zero_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/from_ordered_representation.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{unsigned_gen_var_13, unsigned_pair_gen_var_22};\nuse std::panic::catch_unwind;\n\n#[allow(clippy::approx_constant)]\n#[test]\npub fn test_from_ordered_representation() {\n    fn test<T: PrimitiveFloat>(n: u64, out: T) {\n        assert_eq!(NiceFloat(T::from_ordered_representation(n)), NiceFloat(out));\n    }\n    test::<f32>(0, f32::NEGATIVE_INFINITY);\n    test::<f32>(1, -f32::MAX_FINITE);\n    test::<f32>(1000000000, -458.42188);\n    test::<f32>(1046478848, -10.0);\n    test::<f32>(1060565029, -core::f32::consts::PI);\n    test::<f32>(1073741824, -1.0);\n    test::<f32>(1102263091, -0.1);\n    test::<f32>(2130706432, -f32::MIN_POSITIVE_NORMAL);\n    test::<f32>(2130706433, -f32::MAX_SUBNORMAL);\n    test::<f32>(2139095039, -f32::MIN_POSITIVE_SUBNORMAL);\n    test::<f32>(2139095040, -0.0);\n    test::<f32>(2139095041, 0.0);\n    test::<f32>(2139095042, f32::MIN_POSITIVE_SUBNORMAL);\n    test::<f32>(2147483648, f32::MAX_SUBNORMAL);\n    test::<f32>(2147483649, f32::MIN_POSITIVE_NORMAL);\n    test::<f32>(3175926990, 0.1);\n    test::<f32>(3204448256, 0.99999994);\n    test::<f32>(3204448257, 1.0);\n    test::<f32>(3204448258, 1.0000001);\n    test::<f32>(3217625051, 3.1415925);\n    test::<f32>(3217625052, core::f32::consts::PI);\n    test::<f32>(3217625053, 3.141593);\n    test::<f32>(3231711233, 10.0);\n    test::<f32>(4278190080, f32::MAX_FINITE);\n    test::<f32>(4278190081, f32::INFINITY);\n\n    test::<f64>(0, f64::NEGATIVE_INFINITY);\n    test::<f64>(1, -f64::MAX_FINITE);\n    test::<f64>(4597049319638433792, -10.0);\n    test::<f64>(4604611780675359464, -core::f64::consts::PI);\n    test::<f64>(4611686018427387904, -1.0);\n    test::<f64>(4626998257160447590, -0.1);\n    test::<f64>(9214364837600034816, -f64::MIN_POSITIVE_NORMAL);\n    test::<f64>(9214364837600034817, -f64::MAX_SUBNORMAL);\n    test::<f64>(9218868437227405311, -f64::MIN_POSITIVE_SUBNORMAL);\n    test::<f64>(9218868437227405312, -0.0);\n    test::<f64>(9218868437227405313, 0.0);\n    test::<f64>(9218868437227405314, f64::MIN_POSITIVE_SUBNORMAL);\n    test::<f64>(9223372036854775808, f64::MAX_SUBNORMAL);\n    test::<f64>(9223372036854775809, f64::MIN_POSITIVE_NORMAL);\n    test::<f64>(10000000000000000000, 1.9261352099337372e-256);\n    test::<f64>(13810738617294363035, 0.1);\n    test::<f64>(13826050856027422720, 0.9999999999999999);\n    test::<f64>(13826050856027422721, 1.0);\n    test::<f64>(13826050856027422722, 1.0000000000000002);\n    test::<f64>(13833125093779451160, 3.1415926535897927);\n    test::<f64>(13833125093779451161, core::f64::consts::PI);\n    test::<f64>(13833125093779451162, 3.1415926535897936);\n    test::<f64>(13840687554816376833, 10.0);\n    test::<f64>(18437736874454810624, f64::MAX_FINITE);\n    test::<f64>(18437736874454810625, f64::INFINITY);\n}\n\n#[test]\npub fn from_ordered_representation_fail() {\n    assert_panic!(f32::from_ordered_representation(4278190082));\n    assert_panic!(f32::from_ordered_representation(u64::MAX));\n    assert_panic!(f64::from_ordered_representation(18437736874454810626));\n    assert_panic!(f64::from_ordered_representation(u64::MAX));\n}\n\nfn from_ordered_representation_properties_helper<T: PrimitiveFloat>() {\n    unsigned_gen_var_13::<T>().test_properties(|x| {\n        let f = T::from_ordered_representation(x);\n        assert!(!f.is_nan());\n        assert_eq!(f.to_ordered_representation(), x);\n    });\n\n    unsigned_pair_gen_var_22::<T>().test_properties(|(x, y)| {\n        assert_eq!(\n            x.cmp(&y),\n            NiceFloat(T::from_ordered_representation(x))\n                .cmp(&NiceFloat(T::from_ordered_representation(y)))\n        );\n    });\n}\n\n#[test]\nfn from_ordered_representation_properties() {\n    apply_fn_to_primitive_floats!(from_ordered_representation_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/is_negative_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen;\n\nfn is_negative_zero_helper<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(n.is_negative_zero(), out);\n    };\n    test(T::ZERO, false);\n    test(T::NEGATIVE_ZERO, true);\n    test(T::NAN, false);\n    test(T::INFINITY, false);\n    test(T::NEGATIVE_INFINITY, false);\n    test(T::ONE, false);\n    test(T::NEGATIVE_ONE, false);\n    test(T::from(1.234), false);\n    test(T::from(-1.234), false);\n}\n\n#[test]\nfn test_is_negative_zero() {\n    apply_fn_to_primitive_floats!(is_negative_zero_helper);\n}\n\nfn is_negative_zero_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|x| {\n        assert_eq!(\n            x.is_negative_zero(),\n            NiceFloat(x) != NiceFloat(x.abs_negative_zero())\n        );\n    });\n}\n\n#[test]\nfn is_negative_zero_properties() {\n    apply_fn_to_primitive_floats!(is_negative_zero_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/max_precision_for_sci_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::signed_gen_var_11;\nuse std::panic::catch_unwind;\n\n#[test]\nfn max_precision_for_sci_exponent() {\n    fn test<T: PrimitiveFloat>(n: i64, out: u64) {\n        assert_eq!(T::max_precision_for_sci_exponent(n), out);\n    }\n    test::<f32>(0, 24);\n    test::<f32>(127, 24);\n    test::<f32>(-149, 1);\n    test::<f32>(-148, 2);\n    test::<f32>(-147, 3);\n\n    test::<f64>(0, 53);\n    test::<f64>(1023, 53);\n    test::<f64>(-1074, 1);\n    test::<f64>(-1073, 2);\n    test::<f64>(-1072, 3);\n}\n\nfn max_precision_for_sci_exponent_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::max_precision_for_sci_exponent(10000));\n    assert_panic!(T::max_precision_for_sci_exponent(-10000));\n}\n\n#[test]\npub fn max_precision_for_sci_exponent_fail() {\n    apply_fn_to_primitive_floats!(max_precision_for_sci_exponent_fail_helper);\n}\n\nfn max_precision_for_sci_exponent_properties_helper<T: PrimitiveFloat>() {\n    signed_gen_var_11::<T>().test_properties(|exp| {\n        let p = T::max_precision_for_sci_exponent(exp);\n        assert_ne!(p, 0);\n        assert!(p <= u64::exact_from(T::MAX_EXPONENT));\n    });\n}\n\n#[test]\nfn max_precision_for_sci_exponent_properties() {\n    apply_fn_to_primitive_floats!(max_precision_for_sci_exponent_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/next_higher.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen_var_9;\nuse std::panic::catch_unwind;\n\n#[allow(clippy::approx_constant)]\n#[test]\npub fn test_next_higher() {\n    fn test<T: PrimitiveFloat>(x: T, out: T) {\n        assert_eq!(NiceFloat(x.next_higher()), NiceFloat(out));\n    }\n    test::<f32>(f32::NEGATIVE_INFINITY, -f32::MAX_FINITE);\n    test::<f32>(-f32::MAX_FINITE, -3.4028233e38);\n    test::<f32>(-458.42188, -458.42184);\n    test::<f32>(-10.0, -9.999999);\n    test::<f32>(-core::f32::consts::PI, -3.1415925);\n    test::<f32>(-1.0, -0.99999994);\n    test::<f32>(-0.1, -0.099999994);\n    test::<f32>(-f32::MIN_POSITIVE_NORMAL, -f32::MAX_SUBNORMAL);\n    test::<f32>(-f32::MAX_SUBNORMAL, -1.1754941e-38);\n    test::<f32>(-f32::MIN_POSITIVE_SUBNORMAL, -0.0);\n    test::<f32>(-0.0, 0.0);\n    test::<f32>(0.0, f32::MIN_POSITIVE_SUBNORMAL);\n    test::<f32>(f32::MIN_POSITIVE_SUBNORMAL, 3.0e-45);\n    test::<f32>(f32::MAX_SUBNORMAL, f32::MIN_POSITIVE_NORMAL);\n    test::<f32>(f32::MIN_POSITIVE_NORMAL, 1.1754945e-38);\n    test::<f32>(0.1, 0.10000001);\n    test::<f32>(0.99999994, 1.0);\n    test::<f32>(1.0, 1.0000001);\n    test::<f32>(1.0000001, 1.0000002);\n    test::<f32>(3.1415925, core::f32::consts::PI);\n    test::<f32>(core::f32::consts::PI, 3.141593);\n    test::<f32>(3.141593, 3.1415932);\n    test::<f32>(10.0, 10.000001);\n    test::<f32>(f32::MAX_FINITE, f32::INFINITY);\n\n    test::<f64>(f64::NEGATIVE_INFINITY, -f64::MAX_FINITE);\n    test::<f64>(-f64::MAX_FINITE, -1.7976931348623155e308);\n    test::<f64>(-10.0, -9.999999999999998);\n    test::<f64>(-core::f64::consts::PI, -3.1415926535897927);\n    test::<f64>(-1.0, -0.9999999999999999);\n    test::<f64>(-0.1, -0.09999999999999999);\n    test::<f64>(-f64::MIN_POSITIVE_NORMAL, -f64::MAX_SUBNORMAL);\n    test::<f64>(-f64::MAX_SUBNORMAL, -2.2250738585072004e-308);\n    test::<f64>(-f64::MIN_POSITIVE_SUBNORMAL, -0.0);\n    test::<f64>(-0.0, 0.0);\n    test::<f64>(0.0, f64::MIN_POSITIVE_SUBNORMAL);\n    test::<f64>(f64::MIN_POSITIVE_SUBNORMAL, 1.0e-323);\n    test::<f64>(f64::MAX_SUBNORMAL, f64::MIN_POSITIVE_NORMAL);\n    test::<f64>(f64::MIN_POSITIVE_NORMAL, 2.225073858507202e-308);\n    test::<f64>(1.9261352099337372e-256, 1.9261352099337375e-256);\n    test::<f64>(0.1, 0.10000000000000002);\n    test::<f64>(0.9999999999999999, 1.0);\n    test::<f64>(1.0, 1.0000000000000002);\n    test::<f64>(1.0000000000000002, 1.0000000000000004);\n    test::<f64>(3.1415926535897927, core::f64::consts::PI);\n    test::<f64>(core::f64::consts::PI, 3.1415926535897936);\n    test::<f64>(3.1415926535897936, 3.141592653589794);\n    test::<f64>(10.0, 10.000000000000002);\n    test::<f64>(f64::MAX_FINITE, f64::INFINITY);\n}\n\nfn next_higher_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::NAN.next_higher());\n    assert_panic!(T::INFINITY.next_higher());\n}\n\n#[test]\npub fn next_higher_fail() {\n    apply_fn_to_primitive_floats!(next_higher_fail_helper);\n}\n\nfn next_higher_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen_var_9::<T>().test_properties(|x| {\n        let y = x.next_higher();\n        assert_eq!(\n            x.to_ordered_representation() + 1,\n            y.to_ordered_representation()\n        );\n        assert_eq!(NiceFloat(y.next_lower()), NiceFloat(x));\n    });\n}\n\n#[test]\nfn next_higher_properties() {\n    apply_fn_to_primitive_floats!(next_higher_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/next_lower.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen_var_10;\nuse std::panic::catch_unwind;\n\n#[allow(clippy::approx_constant)]\n#[test]\npub fn test_next_lower() {\n    fn test<T: PrimitiveFloat>(x: T, out: T) {\n        assert_eq!(NiceFloat(x.next_lower()), NiceFloat(out));\n    }\n    test::<f32>(-f32::MAX_FINITE, f32::NEGATIVE_INFINITY);\n    test::<f32>(-458.42188, -458.4219);\n    test::<f32>(-10.0, -10.000001);\n    test::<f32>(-core::f32::consts::PI, -3.141593);\n    test::<f32>(-1.0, -1.0000001);\n    test::<f32>(-0.1, -0.10000001);\n    test::<f32>(-f32::MIN_POSITIVE_NORMAL, -1.1754945e-38);\n    test::<f32>(-f32::MAX_SUBNORMAL, -f32::MIN_POSITIVE_NORMAL);\n    test::<f32>(-f32::MIN_POSITIVE_SUBNORMAL, -3.0e-45);\n    test::<f32>(-0.0, -f32::MIN_POSITIVE_SUBNORMAL);\n    test::<f32>(0.0, -0.0);\n    test::<f32>(f32::MIN_POSITIVE_SUBNORMAL, 0.0);\n    test::<f32>(f32::MAX_SUBNORMAL, 1.1754941e-38);\n    test::<f32>(f32::MIN_POSITIVE_NORMAL, f32::MAX_SUBNORMAL);\n    test::<f32>(0.1, 0.099999994);\n    test::<f32>(0.99999994, 0.9999999);\n    test::<f32>(1.0, 0.99999994);\n    test::<f32>(1.0000001, 1.0);\n    test::<f32>(3.1415925, 3.1415923);\n    test::<f32>(core::f32::consts::PI, 3.1415925);\n    test::<f32>(3.141593, core::f32::consts::PI);\n    test::<f32>(10.0, 9.999999);\n    test::<f32>(f32::MAX_FINITE, 3.4028233e38);\n    test::<f32>(f32::INFINITY, f32::MAX_FINITE);\n\n    test::<f64>(-f64::MAX_FINITE, f64::NEGATIVE_INFINITY);\n    test::<f64>(-10.0, -10.000000000000002);\n    test::<f64>(-core::f64::consts::PI, -3.1415926535897936);\n    test::<f64>(-1.0, -1.0000000000000002);\n    test::<f64>(-0.1, -0.10000000000000002);\n    test::<f64>(-f64::MIN_POSITIVE_NORMAL, -2.225073858507202e-308);\n    test::<f64>(-f64::MAX_SUBNORMAL, -f64::MIN_POSITIVE_NORMAL);\n    test::<f64>(-f64::MIN_POSITIVE_SUBNORMAL, -1.0e-323);\n    test::<f64>(-0.0, -f64::MIN_POSITIVE_SUBNORMAL);\n    test::<f64>(0.0, -0.0);\n    test::<f64>(f64::MIN_POSITIVE_SUBNORMAL, 0.0);\n    test::<f64>(f64::MAX_SUBNORMAL, 2.2250738585072004e-308);\n    test::<f64>(f64::MIN_POSITIVE_NORMAL, f64::MAX_SUBNORMAL);\n    test::<f64>(1.9261352099337372e-256, 1.926135209933737e-256);\n    test::<f64>(0.1, 0.09999999999999999);\n    test::<f64>(0.9999999999999999, 0.9999999999999998);\n    test::<f64>(1.0, 0.9999999999999999);\n    test::<f64>(1.0000000000000002, 1.0);\n    test::<f64>(3.1415926535897927, 3.1415926535897922);\n    test::<f64>(core::f64::consts::PI, 3.1415926535897927);\n    test::<f64>(3.1415926535897936, core::f64::consts::PI);\n    test::<f64>(10.0, 9.999999999999998);\n    test::<f64>(f64::MAX_FINITE, 1.7976931348623155e308);\n    test::<f64>(f64::INFINITY, f64::MAX_FINITE);\n}\n\nfn next_lower_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::NAN.next_lower());\n    assert_panic!(T::NEGATIVE_INFINITY.next_lower());\n}\n\n#[test]\npub fn next_lower_fail() {\n    apply_fn_to_primitive_floats!(next_lower_fail_helper);\n}\n\nfn next_lower_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen_var_10::<T>().test_properties(|x| {\n        let y = x.next_lower();\n        assert_eq!(\n            x.to_ordered_representation() - 1,\n            y.to_ordered_representation()\n        );\n        assert_eq!(NiceFloat(y.next_higher()), NiceFloat(x));\n    });\n}\n\n#[test]\nfn next_lower_properties() {\n    apply_fn_to_primitive_floats!(next_lower_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::test_util::generators::primitive_float_gen_var_12;\nuse std::panic::catch_unwind;\n\nfn precision_helper<T: PrimitiveFloat>() {\n    let test = |n: T, out| {\n        assert_eq!(n.precision(), out);\n    };\n    test(T::ONE, 1);\n    test(T::NEGATIVE_ONE, 1);\n    test(T::from(3.0), 2);\n    test(T::from(1.5), 2);\n    test(T::from(1.234), 23);\n    test(T::from(-1.234), 23);\n}\n\n#[test]\nfn test_precision() {\n    apply_fn_to_primitive_floats!(precision_helper);\n}\n\nfn precision_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::NAN.precision());\n    assert_panic!(T::INFINITY.precision());\n    assert_panic!(T::NEGATIVE_INFINITY.precision());\n    assert_panic!(T::ZERO.precision());\n    assert_panic!(T::NEGATIVE_ZERO.precision());\n}\n\n#[test]\npub fn precision_fail() {\n    apply_fn_to_primitive_floats!(precision_fail_helper);\n}\n\nfn precision_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen_var_12::<T>().test_properties(|x| {\n        let precision = x.precision();\n        assert_ne!(precision, 0);\n        assert!(precision <= T::max_precision_for_sci_exponent(x.sci_exponent()));\n        assert_eq!((-x).precision(), precision);\n    });\n}\n\n#[test]\nfn precision_properties() {\n    apply_fn_to_primitive_floats!(precision_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/basic/to_ordered_representation.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_11, primitive_float_pair_gen_var_1,\n};\nuse std::panic::catch_unwind;\n\n#[allow(clippy::approx_constant)]\n#[test]\npub fn test_to_ordered_representation() {\n    fn test<T: PrimitiveFloat>(x: T, out: u64) {\n        assert_eq!(x.to_ordered_representation(), out);\n    }\n    test::<f32>(f32::NEGATIVE_INFINITY, 0);\n    test::<f32>(-f32::MAX_FINITE, 1);\n    test::<f32>(-458.42188, 1000000000);\n    test::<f32>(-10.0, 1046478848);\n    test::<f32>(-core::f32::consts::PI, 1060565029);\n    test::<f32>(-1.0, 1073741824);\n    test::<f32>(-0.1, 1102263091);\n    test::<f32>(-f32::MIN_POSITIVE_NORMAL, 2130706432);\n    test::<f32>(-f32::MAX_SUBNORMAL, 2130706433);\n    test::<f32>(-f32::MIN_POSITIVE_SUBNORMAL, 2139095039);\n    test::<f32>(-0.0, 2139095040);\n    test::<f32>(0.0, 2139095041);\n    test::<f32>(f32::MIN_POSITIVE_SUBNORMAL, 2139095042);\n    test::<f32>(f32::MAX_SUBNORMAL, 2147483648);\n    test::<f32>(f32::MIN_POSITIVE_NORMAL, 2147483649);\n    test::<f32>(0.1, 3175926990);\n    test::<f32>(0.99999994, 3204448256);\n    test::<f32>(1.0, 3204448257);\n    test::<f32>(1.0000001, 3204448258);\n    test::<f32>(3.1415925, 3217625051);\n    test::<f32>(core::f32::consts::PI, 3217625052);\n    test::<f32>(3.141593, 3217625053);\n    test::<f32>(10.0, 3231711233);\n    test::<f32>(f32::MAX_FINITE, 4278190080);\n    test::<f32>(f32::INFINITY, 4278190081);\n\n    test::<f64>(f64::NEGATIVE_INFINITY, 0);\n    test::<f64>(-f64::MAX_FINITE, 1);\n    test::<f64>(-10.0, 4597049319638433792);\n    test::<f64>(-core::f64::consts::PI, 4604611780675359464);\n    test::<f64>(-1.0, 4611686018427387904);\n    test::<f64>(-0.1, 4626998257160447590);\n    test::<f64>(-f64::MIN_POSITIVE_NORMAL, 9214364837600034816);\n    test::<f64>(-f64::MAX_SUBNORMAL, 9214364837600034817);\n    test::<f64>(-f64::MIN_POSITIVE_SUBNORMAL, 9218868437227405311);\n    test::<f64>(-0.0, 9218868437227405312);\n    test::<f64>(0.0, 9218868437227405313);\n    test::<f64>(f64::MIN_POSITIVE_SUBNORMAL, 9218868437227405314);\n    test::<f64>(f64::MAX_SUBNORMAL, 9223372036854775808);\n    test::<f64>(f64::MIN_POSITIVE_NORMAL, 9223372036854775809);\n    test::<f64>(1.9261352099337372e-256, 10000000000000000000);\n    test::<f64>(0.1, 13810738617294363035);\n    test::<f64>(0.9999999999999999, 13826050856027422720);\n    test::<f64>(1.0, 13826050856027422721);\n    test::<f64>(1.0000000000000002, 13826050856027422722);\n    test::<f64>(3.1415926535897927, 13833125093779451160);\n    test::<f64>(core::f64::consts::PI, 13833125093779451161);\n    test::<f64>(3.1415926535897936, 13833125093779451162);\n    test::<f64>(10.0, 13840687554816376833);\n    test::<f64>(f64::MAX_FINITE, 18437736874454810624);\n    test::<f64>(f64::INFINITY, 18437736874454810625);\n}\n\nfn to_ordered_representation_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(T::NAN.to_ordered_representation());\n}\n\n#[test]\npub fn to_ordered_representation_fail() {\n    apply_fn_to_primitive_floats!(to_ordered_representation_fail_helper);\n}\n\nfn to_ordered_representation_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen_var_11::<T>().test_properties(|x| {\n        let i = x.to_ordered_representation();\n        assert!(i <= T::LARGEST_ORDERED_REPRESENTATION);\n        assert_eq!(NiceFloat(T::from_ordered_representation(i)), NiceFloat(x));\n    });\n\n    primitive_float_pair_gen_var_1::<T>().test_properties(|(x, y)| {\n        assert_eq!(\n            NiceFloat(x).cmp(&NiceFloat(y)),\n            x.to_ordered_representation()\n                .cmp(&y.to_ordered_representation())\n        );\n    });\n}\n\n#[test]\nfn to_ordered_representation_properties() {\n    apply_fn_to_primitive_floats!(to_ordered_representation_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/nice_float/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::common::test_cmp_helper;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_pair_gen, primitive_float_triple_gen,\n};\nuse std::cmp::Ordering::*;\n\nconst TEST_STRINGS: [&str; 7] = [\"-Infinity\", \"-5.0e5\", \"-0.0\", \"NaN\", \"0.0\", \"0.123\", \"Infinity\"];\n\n#[test]\npub fn test_cmp() {\n    test_cmp_helper::<NiceFloat<f32>>(&TEST_STRINGS);\n    test_cmp_helper::<NiceFloat<f64>>(&TEST_STRINGS);\n}\n\nfn cmp_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        let ord = x.cmp(&y);\n        assert_eq!(y.cmp(&x).reverse(), ord);\n        assert_eq!(NiceFloat(-y.0).cmp(&NiceFloat(-x.0)), ord);\n    });\n\n    primitive_float_gen::<T>().test_properties(|x| {\n        let x = NiceFloat(x);\n        assert_eq!(x.cmp(&x), Equal);\n    });\n\n    primitive_float_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        let z = NiceFloat(z);\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n}\n\n#[test]\npub fn cmp_properties() {\n    apply_fn_to_primitive_floats!(cmp_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/nice_float/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_pair_gen, primitive_float_triple_gen,\n};\nuse std::cmp::Ordering::*;\n\n#[test]\npub fn test_cmp_abs() {\n    let test = |s, t, cmp| {\n        let u = NiceFloat(s);\n        let v = NiceFloat(t);\n        assert_eq!(u.cmp_abs(&v), cmp);\n        assert_eq!(v.cmp_abs(&u), cmp.reverse());\n\n        assert_eq!(u.lt_abs(&v), cmp == Less);\n        assert_eq!(u.gt_abs(&v), cmp == Greater);\n        assert_eq!(u.le_abs(&v), cmp != Greater);\n        assert_eq!(u.ge_abs(&v), cmp != Less);\n    };\n    test(0.0, 0.0, Equal);\n    test(0.0, f64::NAN, Greater);\n    test(0.0, f64::INFINITY, Less);\n    test(0.0, 5.0, Less);\n    test(123.0, 123.0, Equal);\n    test(123.0, 124.0, Less);\n    test(123.0, 122.0, Greater);\n    test(1000000000000.0, 123.0, Greater);\n    test(123.0, 1000000000000.0, Less);\n    test(1000000000000.0, 1000000000000.0, Equal);\n    test(1000000000000.0, 0.0, Greater);\n    test(0.5, 0.0, Greater);\n    test(0.5, 0.5, Equal);\n\n    test(0.0, -0.0, Equal);\n    test(0.0, f64::NEGATIVE_INFINITY, Less);\n    test(0.0, -5.0, Less);\n    test(123.0, -123.0, Equal);\n    test(123.0, -124.0, Less);\n    test(123.0, -122.0, Greater);\n    test(1000000000000.0, -123.0, Greater);\n    test(123.0, -1000000000000.0, Less);\n    test(1000000000000.0, -1000000000000.0, Equal);\n    test(1000000000000.0, -0.0, Greater);\n    test(0.5, -0.0, Greater);\n    test(0.5, -0.5, Equal);\n\n    test(-0.0, 0.0, Equal);\n    test(-0.0, f64::NAN, Greater);\n    test(-0.0, f64::INFINITY, Less);\n    test(-0.0, 5.0, Less);\n    test(-123.0, 123.0, Equal);\n    test(-123.0, 124.0, Less);\n    test(-123.0, 122.0, Greater);\n    test(-1000000000000.0, 123.0, Greater);\n    test(-123.0, 1000000000000.0, Less);\n    test(-1000000000000.0, 1000000000000.0, Equal);\n    test(-1000000000000.0, 0.0, Greater);\n    test(-0.5, 0.0, Greater);\n    test(-0.5, 0.5, Equal);\n\n    test(-0.0, -0.0, Equal);\n    test(-0.0, f64::NEGATIVE_INFINITY, Less);\n    test(-0.0, -5.0, Less);\n    test(-123.0, -123.0, Equal);\n    test(-123.0, -124.0, Less);\n    test(-123.0, -122.0, Greater);\n    test(-1000000000000.0, -123.0, Greater);\n    test(-123.0, -1000000000000.0, Less);\n    test(-1000000000000.0, -1000000000000.0, Equal);\n    test(-1000000000000.0, -0.0, Greater);\n    test(-0.5, -0.0, Greater);\n    test(-0.5, -0.5, Equal);\n}\n\nfn cmp_abs_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        let cmp = x.cmp_abs(&y);\n        assert_eq!(y.cmp_abs(&x).reverse(), cmp);\n        assert_eq!(NiceFloat(-x.0).cmp_abs(&NiceFloat(-y.0)), cmp);\n\n        assert_eq!(x.lt_abs(&y), cmp == Less);\n        assert_eq!(x.gt_abs(&y), cmp == Greater);\n        assert_eq!(x.le_abs(&y), cmp != Greater);\n        assert_eq!(x.ge_abs(&y), cmp != Less);\n    });\n\n    primitive_float_gen::<T>().test_properties(|x| {\n        let x = NiceFloat(x);\n        assert_eq!(x.cmp_abs(&x), Equal);\n    });\n\n    primitive_float_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        let z = NiceFloat(z);\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n}\n\n#[test]\npub fn cmp_abs_properties() {\n    apply_fn_to_primitive_floats!(cmp_abs_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/nice_float/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::common::test_eq_helper;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_pair_gen, primitive_float_triple_gen,\n};\n\nconst TEST_STRINGS: [&str; 7] = [\"-Infinity\", \"-5.0e5\", \"-0.0\", \"NaN\", \"0.0\", \"0.123\", \"Infinity\"];\n\n#[test]\npub fn test_eq() {\n    test_eq_helper::<NiceFloat<f32>>(&TEST_STRINGS);\n    test_eq_helper::<NiceFloat<f64>>(&TEST_STRINGS);\n}\n\n#[allow(clippy::eq_op)]\nfn eq_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        assert_eq!(x == y, y == x);\n    });\n\n    primitive_float_gen::<T>().test_properties(|x| {\n        let x = NiceFloat(x);\n        assert_eq!(x, x);\n    });\n\n    primitive_float_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        let z = NiceFloat(z);\n        if x == y && x == z {\n            assert_eq!(x, z);\n        }\n    });\n}\n\n#[test]\npub fn eq_properties() {\n    apply_fn_to_primitive_floats!(eq_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/nice_float/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_pair_gen, primitive_float_triple_gen,\n};\n\n#[test]\nfn test_eq_abs() {\n    let test = |s, t, eq| {\n        let u = NiceFloat(s);\n        let v = NiceFloat(t);\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(0.0, 0.0, true);\n    test(0.0, f64::NAN, false);\n    test(0.0, f64::NEGATIVE_INFINITY, false);\n    test(0.0, 5.0, false);\n    test(123.0, 123.0, true);\n    test(123.0, 124.0, false);\n    test(123.0, 122.0, false);\n    test(1000000000000.0, 123.0, false);\n    test(123.0, 1000000000000.0, false);\n    test(1000000000000.0, 1000000000000.0, true);\n    test(1000000000000.0, 0.0, false);\n    test(0.5, 0.0, false);\n    test(0.5, 0.5, true);\n\n    test(0.0, -0.0, true);\n    test(0.0, -f64::NAN, false);\n    test(0.0, -f64::NEGATIVE_INFINITY, false);\n    test(0.0, -5.0, false);\n    test(123.0, -123.0, true);\n    test(123.0, -124.0, false);\n    test(123.0, -122.0, false);\n    test(1000000000000.0, -123.0, false);\n    test(123.0, -1000000000000.0, false);\n    test(1000000000000.0, -1000000000000.0, true);\n    test(1000000000000.0, -0.0, false);\n    test(0.5, -0.0, false);\n    test(0.5, -0.5, true);\n\n    test(-0.0, 0.0, true);\n    test(-0.0, f64::NAN, false);\n    test(-0.0, f64::NEGATIVE_INFINITY, false);\n    test(-0.0, 5.0, false);\n    test(-123.0, 123.0, true);\n    test(-123.0, 124.0, false);\n    test(-123.0, 122.0, false);\n    test(-1000000000000.0, 123.0, false);\n    test(-123.0, 1000000000000.0, false);\n    test(-1000000000000.0, 1000000000000.0, true);\n    test(-1000000000000.0, 0.0, false);\n    test(-0.5, 0.0, false);\n    test(-0.5, 0.5, true);\n\n    test(-0.0, -0.0, true);\n    test(-0.0, -f64::NAN, false);\n    test(-0.0, -f64::NEGATIVE_INFINITY, false);\n    test(-0.0, -5.0, false);\n    test(-123.0, -123.0, true);\n    test(-123.0, -124.0, false);\n    test(-123.0, -122.0, false);\n    test(-1000000000000.0, -123.0, false);\n    test(-123.0, -1000000000000.0, false);\n    test(-1000000000000.0, -1000000000000.0, true);\n    test(-1000000000000.0, -0.0, false);\n    test(-0.5, -0.0, false);\n    test(-0.5, -0.5, true);\n}\n\n#[allow(clippy::eq_op)]\nfn eq_abs_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        let eq = x.eq_abs(&y);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!(NiceFloat(x.0.abs()) == NiceFloat(y.0.abs()), eq);\n    });\n\n    primitive_float_gen::<T>().test_properties(|x| {\n        let x = NiceFloat(x);\n        assert!(x.eq_abs(&x));\n    });\n\n    primitive_float_triple_gen::<T>().test_properties(|(x, y, z)| {\n        let x = NiceFloat(x);\n        let y = NiceFloat(y);\n        let z = NiceFloat(z);\n        if x.eq_abs(&y) && x.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n}\n\n#[test]\npub fn eq_properties() {\n    apply_fn_to_primitive_floats!(eq_abs_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/nice_float/from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_10};\nuse std::fmt::Debug;\nuse std::str::FromStr;\n\n#[allow(clippy::approx_constant)]\n#[test]\nfn test_from_str() {\n    fn test_ok<T: PrimitiveFloat>(s: &str, out: NiceFloat<T>)\n    where\n        <T as FromStr>::Err: Debug,\n    {\n        assert_eq!(NiceFloat::<T>::from_str(s).unwrap(), out);\n    }\n    test_ok::<f32>(\"NaN\", NiceFloat(f32::NAN));\n    test_ok::<f32>(\"Infinity\", NiceFloat(f32::INFINITY));\n    test_ok::<f32>(\"-Infinity\", NiceFloat(f32::NEGATIVE_INFINITY));\n    test_ok::<f32>(\"0\", NiceFloat(0.0));\n    test_ok::<f32>(\"00\", NiceFloat(0.0));\n    test_ok::<f32>(\"0.\", NiceFloat(0.0));\n    test_ok::<f32>(\".0\", NiceFloat(0.0));\n    test_ok::<f32>(\"1\", NiceFloat(1.0));\n    test_ok::<f32>(\"1.0\", NiceFloat(1.0));\n    test_ok::<f32>(\"1.0000\", NiceFloat(1.0));\n    test_ok::<f32>(\"3.14\", NiceFloat(3.14));\n    test_ok::<f32>(\"1e2\", NiceFloat(100.0));\n    test_ok::<f32>(\"1e20\", NiceFloat(1.0e20));\n    test_ok::<f32>(\"1.0e1000\", NiceFloat(f32::INFINITY));\n    test_ok::<f32>(\"1.0e-1000\", NiceFloat(0.0));\n    test_ok::<f32>(\"-0\", NiceFloat(-0.0));\n    test_ok::<f32>(\"-00\", NiceFloat(-0.0));\n    test_ok::<f32>(\"-0.\", NiceFloat(-0.0));\n    test_ok::<f32>(\"-.0\", NiceFloat(-0.0));\n    test_ok::<f32>(\"-1\", NiceFloat(-1.0));\n    test_ok::<f32>(\"-1.0\", NiceFloat(-1.0));\n    test_ok::<f32>(\"-1.0000\", NiceFloat(-1.0));\n    test_ok::<f32>(\"-3.14\", NiceFloat(-3.14));\n    test_ok::<f32>(\"-1e2\", NiceFloat(-100.0));\n    test_ok::<f32>(\"-1e20\", NiceFloat(-1.0e20));\n    test_ok::<f32>(\"-1.0e1000\", NiceFloat(f32::NEGATIVE_INFINITY));\n    test_ok::<f32>(\"-1.0e-1000\", NiceFloat(-0.0));\n\n    test_ok::<f64>(\"NaN\", NiceFloat(f64::NAN));\n    test_ok::<f64>(\"Infinity\", NiceFloat(f64::INFINITY));\n    test_ok::<f64>(\"-Infinity\", NiceFloat(f64::NEGATIVE_INFINITY));\n    test_ok::<f64>(\"0\", NiceFloat(0.0));\n    test_ok::<f64>(\"00\", NiceFloat(0.0));\n    test_ok::<f64>(\"0.\", NiceFloat(0.0));\n    test_ok::<f64>(\".0\", NiceFloat(0.0));\n    test_ok::<f64>(\"1\", NiceFloat(1.0));\n    test_ok::<f64>(\"1.0\", NiceFloat(1.0));\n    test_ok::<f64>(\"1.0000\", NiceFloat(1.0));\n    test_ok::<f64>(\"3.14\", NiceFloat(3.14));\n    test_ok::<f64>(\"1e2\", NiceFloat(100.0));\n    test_ok::<f64>(\"1e20\", NiceFloat(1.0e20));\n    test_ok::<f64>(\"1.0e1000\", NiceFloat(f64::INFINITY));\n    test_ok::<f64>(\"1.0e-1000\", NiceFloat(0.0));\n    test_ok::<f64>(\"-0\", NiceFloat(-0.0));\n    test_ok::<f64>(\"-00\", NiceFloat(-0.0));\n    test_ok::<f64>(\"-0.\", NiceFloat(-0.0));\n    test_ok::<f64>(\"-.0\", NiceFloat(-0.0));\n    test_ok::<f64>(\"-1\", NiceFloat(-1.0));\n    test_ok::<f64>(\"-1.0\", NiceFloat(-1.0));\n    test_ok::<f64>(\"-1.0000\", NiceFloat(-1.0));\n    test_ok::<f64>(\"-3.14\", NiceFloat(-3.14));\n    test_ok::<f64>(\"-1e2\", NiceFloat(-100.0));\n    test_ok::<f64>(\"-1e20\", NiceFloat(-1.0e20));\n    test_ok::<f64>(\"-1.0e1000\", NiceFloat(f64::NEGATIVE_INFINITY));\n    test_ok::<f64>(\"-1.0e-1000\", NiceFloat(-0.0));\n\n    let test_err = |s| {\n        assert!(NiceFloat::<f32>::from_str(s).is_err());\n        assert!(NiceFloat::<f64>::from_str(s).is_err());\n    };\n    test_err(\"-\");\n    test_err(\".\");\n    test_err(\"e\");\n    test_err(\"z\");\n    test_err(\"0x01\");\n    test_err(\" 0 \");\n}\n\n#[allow(unused_must_use)]\nfn from_str_helper<T: PrimitiveFloat>() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_length_d\", 1);\n    string_gen().test_properties_with_config(&config, |s| {\n        NiceFloat::<T>::from_str(&s);\n    });\n    string_gen_var_10().test_properties_with_config(&config, |s| {\n        NiceFloat::<T>::from_str(&s);\n    });\n}\n\n#[test]\nfn from_str_properties() {\n    apply_fn_to_primitive_floats!(from_str_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/nice_float/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::hash::hash;\n\nfn hash_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_gen::<T>().test_properties(|x| {\n        let x = NiceFloat(x);\n        assert_eq!(hash(&x), hash(&x.clone()));\n    });\n}\n\n#[test]\nfn hash_properties() {\n    apply_fn_to_primitive_floats!(hash_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/float/nice_float/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::num::float::PRIMITIVE_FLOAT_CHARS;\nuse std::fmt::Debug;\nuse std::str::FromStr;\n\n#[test]\npub fn test_to_string() {\n    fn test<T: PrimitiveFloat>(x: T, out: &str) {\n        assert_eq!(NiceFloat(x).to_string(), out);\n    }\n    test::<f32>(f32::NAN, \"NaN\");\n    test::<f32>(f32::INFINITY, \"Infinity\");\n    test::<f32>(f32::NEGATIVE_INFINITY, \"-Infinity\");\n    test::<f32>(0.0, \"0.0\");\n    test::<f32>(-0.0, \"-0.0\");\n    test::<f32>(1.0, \"1.0\");\n    test::<f32>(-1.0, \"-1.0\");\n    test::<f32>(123.0, \"123.0\");\n    test::<f32>(0.123, \"0.123\");\n    test::<f32>(1000.0, \"1000.0\");\n    test::<f32>(1000000.0, \"1000000.0\");\n    test::<f32>(1.0e20, \"1.0e20\");\n    test::<f32>(f32::MIN_POSITIVE_SUBNORMAL, \"1.0e-45\");\n    test::<f32>(f32::MAX_SUBNORMAL, \"1.1754942e-38\");\n    test::<f32>(f32::MIN_POSITIVE_NORMAL, \"1.1754944e-38\");\n    test::<f32>(f32::MAX_FINITE, \"3.4028235e38\");\n    test::<f32>(2.0f32.sqrt(), \"1.4142135\");\n    test::<f32>(std::f32::consts::E, \"2.7182817\");\n    test::<f32>(std::f32::consts::PI, \"3.1415927\");\n\n    test::<f64>(f64::NAN, \"NaN\");\n    test::<f64>(f64::INFINITY, \"Infinity\");\n    test::<f64>(f64::NEGATIVE_INFINITY, \"-Infinity\");\n    test::<f64>(0.0, \"0.0\");\n    test::<f64>(-0.0, \"-0.0\");\n    test::<f64>(1.0, \"1.0\");\n    test::<f64>(-1.0, \"-1.0\");\n    test::<f64>(123.0, \"123.0\");\n    test::<f64>(0.123, \"0.123\");\n    test::<f64>(1000.0, \"1000.0\");\n    test::<f64>(1000000.0, \"1000000.0\");\n    test::<f64>(1.0e100, \"1.0e100\");\n    test::<f64>(f64::MIN_POSITIVE_SUBNORMAL, \"5.0e-324\");\n    test::<f64>(f64::MAX_SUBNORMAL, \"2.225073858507201e-308\");\n    test::<f64>(f64::MIN_POSITIVE_NORMAL, \"2.2250738585072014e-308\");\n    test::<f64>(f64::MAX_FINITE, \"1.7976931348623157e308\");\n    test::<f64>(2.0f64.sqrt(), \"1.4142135623730951\");\n    test::<f64>(std::f64::consts::E, \"2.718281828459045\");\n    test::<f64>(std::f64::consts::PI, \"3.141592653589793\");\n}\n\nfn to_string_properties_helper<T: PrimitiveFloat>()\nwhere\n    <T as FromStr>::Err: Debug,\n{\n    primitive_float_gen::<T>().test_properties(|f| {\n        let s = NiceFloat(f).to_string();\n        assert_eq!(NiceFloat::from_str(&s).unwrap(), NiceFloat(f));\n        assert!(string_is_subset(&s, PRIMITIVE_FLOAT_CHARS));\n        if f.is_finite() {\n            assert!(s.contains('.'));\n            assert_eq!(NiceFloat(T::from_str(&s).unwrap()), NiceFloat(f));\n        }\n    });\n}\n\n#[test]\nfn to_string_properties() {\n    apply_fn_to_primitive_floats!(to_string_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/iterators/bit_distributor_sequence.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\nuse malachite_base::num::iterators::bit_distributor_sequence;\n\nfn bit_distributor_sequence_helper(\n    x_output_type: BitDistributorOutputType,\n    y_output_type: BitDistributorOutputType,\n    out: &[usize],\n) {\n    assert_eq!(\n        bit_distributor_sequence(x_output_type, y_output_type)\n            .take(50)\n            .collect_vec(),\n        out\n    );\n}\n\n#[test]\nfn test_bit_distributor_sequence() {\n    bit_distributor_sequence_helper(\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        &[\n            0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 4, 5, 4, 5, 6,\n            7, 6, 7, 0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3, 4, 5,\n        ],\n    );\n    bit_distributor_sequence_helper(\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(2),\n        &[\n            0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2,\n            3, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 0, 1,\n        ],\n    );\n    bit_distributor_sequence_helper(\n        BitDistributorOutputType::normal(2),\n        BitDistributorOutputType::normal(1),\n        &[\n            0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 11, 8, 9, 10, 11, 12, 13, 14,\n            15, 12, 13, 14, 15, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 9,\n        ],\n    );\n    bit_distributor_sequence_helper(\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n        &[\n            0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4,\n            5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1,\n        ],\n    );\n    bit_distributor_sequence_helper(\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        &[\n            0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 3,\n            3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6,\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn test_bit_distributor_sequence_fail() {\n    bit_distributor_sequence(\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/iterators/iterator_to_bit_chunks.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::iterators::iterator_to_bit_chunks;\nuse std::panic::{RefUnwindSafe, catch_unwind};\n\nfn iterator_to_bit_chunks_helper<T: PrimitiveUnsigned, U: PrimitiveUnsigned + WrappingFrom<T>>(\n    xs: &[T],\n    in_chunk_size: u64,\n    out_chunk_size: u64,\n    out: &[U],\n) {\n    assert_eq!(\n        iterator_to_bit_chunks::<_, T, U>(xs.iter().copied(), in_chunk_size, out_chunk_size)\n            .map(Option::unwrap)\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n}\n\n#[test]\nfn test_iterator_to_bit_chunks() {\n    iterator_to_bit_chunks_helper::<u16, u16>(&[123, 456], 10, 10, &[123, 456]);\n    iterator_to_bit_chunks_helper::<u16, u32>(&[123, 456], 10, 10, &[123, 456]);\n    iterator_to_bit_chunks_helper::<u32, u16>(&[123, 456], 10, 10, &[123, 456]);\n\n    iterator_to_bit_chunks_helper::<u16, u16>(\n        &[0b000111111, 0b110010010],\n        9,\n        3,\n        &[0b111, 0b111, 0b000, 0b010, 0b010, 0b110],\n    );\n    iterator_to_bit_chunks_helper::<u16, u32>(\n        &[0b000111111, 0b110010010],\n        9,\n        3,\n        &[0b111, 0b111, 0b000, 0b010, 0b010, 0b110],\n    );\n    iterator_to_bit_chunks_helper::<u32, u16>(\n        &[0b000111111, 0b110010010],\n        9,\n        3,\n        &[0b111, 0b111, 0b000, 0b010, 0b010, 0b110],\n    );\n\n    iterator_to_bit_chunks_helper::<u16, u16>(\n        &[0b111, 0b111, 0b000, 0b010, 0b010, 0b110],\n        3,\n        9,\n        &[0b000111111, 0b110010010],\n    );\n    iterator_to_bit_chunks_helper::<u16, u32>(\n        &[0b111, 0b111, 0b000, 0b010, 0b010, 0b110],\n        3,\n        9,\n        &[0b000111111, 0b110010010],\n    );\n    iterator_to_bit_chunks_helper::<u32, u16>(\n        &[0b111, 0b111, 0b000, 0b010, 0b010, 0b110],\n        3,\n        9,\n        &[0b000111111, 0b110010010],\n    );\n\n    iterator_to_bit_chunks_helper::<u16, u16>(\n        &[0b1010101, 0b1111101, 0b0100001, 0b110010],\n        7,\n        6,\n        &[0b010101, 0b111011, 0b000111, 0b010010, 0b110],\n    );\n    iterator_to_bit_chunks_helper::<u16, u32>(\n        &[0b1010101, 0b1111101, 0b0100001, 0b110010],\n        7,\n        6,\n        &[0b010101, 0b111011, 0b000111, 0b010010, 0b110],\n    );\n    iterator_to_bit_chunks_helper::<u32, u16>(\n        &[0b1010101, 0b1111101, 0b0100001, 0b110010],\n        7,\n        6,\n        &[0b010101, 0b111011, 0b000111, 0b010010, 0b110],\n    );\n\n    iterator_to_bit_chunks_helper::<u16, u16>(\n        &[0b010101, 0b111011, 0b000111, 0b010010, 0b110],\n        6,\n        7,\n        &[0b1010101, 0b1111101, 0b0100001, 0b110010],\n    );\n    iterator_to_bit_chunks_helper::<u16, u32>(\n        &[0b010101, 0b111011, 0b000111, 0b010010, 0b110],\n        6,\n        7,\n        &[0b1010101, 0b1111101, 0b0100001, 0b110010],\n    );\n    iterator_to_bit_chunks_helper::<u32, u16>(\n        &[0b010101, 0b111011, 0b000111, 0b010010, 0b110],\n        6,\n        7,\n        &[0b1010101, 0b1111101, 0b0100001, 0b110010],\n    );\n\n    // The output may have trailing zero chunks.\n    iterator_to_bit_chunks_helper::<u32, u16>(&[0b100], 32, 8, &[0b100, 0, 0, 0]);\n}\n\nfn test_iterator_to_bit_chunks_fail_helper<\n    T: PrimitiveUnsigned + RefUnwindSafe,\n    U: PrimitiveUnsigned + WrappingFrom<T>,\n>() {\n    let xs = [T::exact_from(12), T::exact_from(34)];\n    assert_panic!({\n        iterator_to_bit_chunks::<_, T, U>(xs.iter().copied(), 0, 4);\n    });\n    assert_panic!({\n        iterator_to_bit_chunks::<_, T, U>(xs.iter().copied(), 4, 0);\n    });\n    assert_panic!({\n        iterator_to_bit_chunks::<_, T, U>(xs.iter().copied(), T::WIDTH + 1, 4);\n    });\n    assert_panic!({\n        iterator_to_bit_chunks::<_, T, U>(xs.iter().copied(), 4, U::WIDTH + 1);\n    });\n}\n\n#[test]\nfn iterator_to_bit_chunks_fail() {\n    apply_fn_to_unsigneds_and_unsigneds!(test_iterator_to_bit_chunks_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/iterators/ruler_sequence.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::iterators::ruler_sequence;\n\n#[test]\npub fn test_ruler_sequence() {\n    assert_eq!(\n        ruler_sequence::<u32>().take(100).collect_vec(),\n        &[\n            0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0,\n            1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1,\n            0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0,\n            3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2\n        ]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_access/assign_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_bool_triple_gen_var_1, unsigned_unsigned_bool_triple_gen_var_1,\n};\nuse std::panic::catch_unwind;\n\nfn assign_bit_helper_unsigned<T: PrimitiveInt>() {\n    let test = |n: u64, index, bit, out: u64| {\n        let mut n = T::exact_from(n);\n        n.assign_bit(index, bit);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(100, 0, true, 101);\n    test(0, 10, false, 0);\n    test(0, 100, false, 0);\n    test(101, 0, false, 100);\n    if T::WIDTH >= u16::WIDTH {\n        test(0, 10, true, 1024);\n        test(1024, 10, false, 0);\n    }\n    if T::WIDTH >= u64::WIDTH {\n        test(1000000000000, 10, true, 1000000001024);\n        test(1000000001024, 10, false, 1000000000000);\n        test(1000000001024, 100, false, 1000000001024);\n    }\n}\n\nfn assign_bit_helper_signed<T: PrimitiveSigned>() {\n    assign_bit_helper_unsigned::<T>();\n\n    let test = |n: i64, index, bit, out: i64| {\n        let mut n = T::exact_from(n);\n        n.assign_bit(index, bit);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(-1, 5, true, -1);\n    test(-1, 100, true, -1);\n    test(-33, 5, true, -1);\n    test(-32, 0, true, -31);\n    test(-1, 5, false, -33);\n    test(-31, 0, false, -32);\n\n    if T::WIDTH >= u64::WIDTH {\n        test(-1000000000000, 10, true, -999999998976);\n        test(-1000000000000, 100, true, -1000000000000);\n        test(-999999998976, 10, false, -1000000000000);\n    }\n\n    let mut n = T::ZERO;\n    n.assign_bit(T::WIDTH - 1, true);\n    assert_eq!(n, T::MIN);\n\n    let mut n = T::MIN;\n    n.assign_bit(T::WIDTH - 1, false);\n    assert_eq!(n, T::ZERO);\n}\n\n#[test]\nfn test_assign_bit() {\n    apply_fn_to_unsigneds!(assign_bit_helper_unsigned);\n    apply_fn_to_signeds!(assign_bit_helper_signed);\n}\n\nfn assign_bit_fail_helper<T: PrimitiveInt>() {\n    assert_panic!({\n        let mut n = T::exact_from(5);\n        n.assign_bit(200, true);\n    });\n}\n\nfn assign_bit_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!({\n        let mut n = T::NEGATIVE_ONE;\n        n.assign_bit(200, false);\n    });\n}\n\n#[test]\nfn assign_bit_fail() {\n    apply_fn_to_primitive_ints!(assign_bit_fail_helper);\n    apply_fn_to_signeds!(assign_bit_fail_helper_signed);\n}\n\nfn properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_unsigned_bool_triple_gen_var_1::<T>().test_properties(|(mut n, index, bit)| {\n        n.assign_bit(index, bit);\n    });\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_bool_triple_gen_var_1::<T>().test_properties(|(mut n, index, bit)| {\n        n.assign_bit(index, bit);\n    });\n}\n\n#[test]\nfn assign_bit_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_access/clear_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_4, unsigned_pair_gen_var_2,\n};\nuse std::panic::catch_unwind;\n\nfn clear_bit_helper_unsigned<T: PrimitiveInt>() {\n    let test = |n: u64, index, out: u64| {\n        let mut n = T::exact_from(n);\n        n.clear_bit(index);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(0, 10, 0);\n    test(0, 100, 0);\n    test(101, 0, 100);\n    if T::WIDTH >= u16::WIDTH {\n        test(1024, 10, 0);\n    }\n    if T::WIDTH >= u64::WIDTH {\n        test(1000000001024, 10, 1000000000000);\n        test(1000000001024, 100, 1000000001024);\n    }\n}\n\nfn clear_bit_helper_signed<T: PrimitiveSigned>() {\n    clear_bit_helper_unsigned::<T>();\n\n    let test = |n: i64, index, out: i64| {\n        let mut n = T::exact_from(n);\n        n.clear_bit(index);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(-1, 5, -33);\n    test(-31, 0, -32);\n\n    if T::WIDTH >= u64::WIDTH {\n        test(-999999998976, 10, -1000000000000);\n    }\n\n    let mut n = T::MIN;\n    n.clear_bit(T::WIDTH - 1);\n    assert_eq!(n, T::ZERO);\n}\n\n#[test]\nfn test_clear_bit() {\n    apply_fn_to_unsigneds!(clear_bit_helper_unsigned);\n    apply_fn_to_signeds!(clear_bit_helper_signed);\n}\n\nfn clear_bit_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!({\n        let mut n = T::NEGATIVE_ONE;\n        n.clear_bit(200);\n    });\n}\n\n#[test]\nfn clear_bit_fail() {\n    apply_fn_to_signeds!(clear_bit_fail_helper);\n}\n\nfn properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(mut n, index)| {\n        let old_n = n;\n        n.clear_bit(index);\n        let result = n;\n\n        let mut n = old_n;\n        n.assign_bit(index, false);\n        assert_eq!(n, result);\n\n        assert!(result <= old_n);\n        if old_n.get_bit(index) {\n            assert_ne!(result, old_n);\n            let mut n = result;\n            n.set_bit(index);\n            assert_eq!(n, old_n);\n        } else {\n            assert_eq!(result, old_n);\n        }\n    });\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_4::<T>().test_properties(|(mut n, index)| {\n        let old_n = n;\n        n.clear_bit(index);\n        let result = n;\n\n        let mut n = old_n;\n        n.assign_bit(index, false);\n        assert_eq!(n, result);\n\n        if old_n < T::ZERO && index == T::WIDTH - 1 {\n            assert!(result >= T::ZERO);\n        } else {\n            assert!(result <= old_n);\n        }\n        if old_n.get_bit(index) {\n            assert_ne!(result, old_n);\n            let mut n = result;\n            n.set_bit(index);\n            assert_eq!(n, old_n);\n        } else {\n            assert_eq!(result, old_n);\n        }\n\n        let mut n = !old_n;\n        n.set_bit(index);\n        n.not_assign();\n        assert_eq!(n, result);\n    });\n}\n\n#[test]\nfn clear_bit_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_access/flip_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_2, unsigned_pair_gen_var_3,\n};\nuse std::panic::catch_unwind;\n\nfn flip_bit_helper_unsigned<T: PrimitiveInt>() {\n    let test = |n: u64, index, out: u64| {\n        let mut n = T::exact_from(n);\n        n.flip_bit(index);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(100, 0, 101);\n    test(101, 0, 100);\n    if T::WIDTH >= u16::WIDTH {\n        test(0, 10, 1024);\n        test(1024, 10, 0);\n    }\n    if T::WIDTH >= u64::WIDTH {\n        test(1000000000000, 10, 1000000001024);\n        test(1000000001024, 10, 1000000000000);\n    }\n}\n\nfn flip_bit_helper_signed<T: PrimitiveSigned>() {\n    flip_bit_helper_unsigned::<T>();\n\n    let test = |n: i64, index, out: i64| {\n        let mut n = T::exact_from(n);\n        n.flip_bit(index);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(-1, 5, -33);\n    test(-33, 5, -1);\n    test(-32, 0, -31);\n    test(-31, 0, -32);\n\n    if T::WIDTH >= u64::WIDTH {\n        test(-1000000000000, 10, -999999998976);\n        test(-999999998976, 10, -1000000000000);\n    }\n\n    let mut n = T::ZERO;\n    n.flip_bit(T::WIDTH - 1);\n    assert_eq!(n, T::MIN);\n\n    let mut n = T::MIN;\n    n.flip_bit(T::WIDTH - 1);\n    assert_eq!(n, T::ZERO);\n}\n\n#[test]\nfn test_flip_bit() {\n    apply_fn_to_unsigneds!(flip_bit_helper_unsigned);\n    apply_fn_to_signeds!(flip_bit_helper_signed);\n}\n\nfn flip_bit_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::exact_from(5).flip_bit(200));\n}\n\nfn flip_bit_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::exact_from(5).flip_bit(200));\n    assert_panic!({\n        let mut n = T::NEGATIVE_ONE;\n        n.flip_bit(200);\n    });\n}\n\n#[test]\nfn flip_bit_fail() {\n    apply_fn_to_unsigneds!(flip_bit_fail_helper_unsigned);\n    apply_fn_to_signeds!(flip_bit_fail_helper_signed);\n}\n\nfn properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_3::<T>().test_properties(|(mut n, index)| {\n        let old_n = n;\n        n.flip_bit(index);\n        assert_ne!(n, old_n);\n\n        n.flip_bit(index);\n        assert_eq!(n, old_n);\n    });\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_2::<T>().test_properties(|(mut n, index)| {\n        let old_n = n;\n        n.flip_bit(index);\n        assert_ne!(n, old_n);\n\n        n.flip_bit(index);\n        assert_eq!(n, old_n);\n    });\n}\n\n#[test]\nfn flip_bit_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_access/get_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_gen, unsigned_pair_gen_var_2,\n};\n\nfn test_helper_primitive_int<T: PrimitiveInt>() {\n    let test = |n: u64, index, out| {\n        assert_eq!(T::exact_from(n).get_bit(index), out);\n    };\n\n    test(0, 0, false);\n    test(0, 100, false);\n    test(123, 2, false);\n    test(123, 3, true);\n    test(123, 100, false);\n    if T::WIDTH >= u64::WIDTH {\n        test(1000000000000, 12, true);\n        test(1000000000000, 100, false);\n    }\n}\n\nfn test_helper_signed<T: PrimitiveSigned>() {\n    let test = |n: i64, index, out| {\n        assert_eq!(T::exact_from(n).get_bit(index), out);\n    };\n\n    test(-123, 0, true);\n    test(-123, 1, false);\n    test(-123, 100, true);\n    if T::WIDTH >= u64::WIDTH {\n        test(-1000000000000, 12, true);\n        test(-1000000000000, 100, true);\n        test(-i64::from(u32::MAX), 0, true);\n        test(-i64::from(u32::MAX), 1, false);\n        test(-i64::from(u32::MAX), 31, false);\n        test(-i64::from(u32::MAX), 32, true);\n        test(-i64::from(u32::MAX), 33, true);\n        test(-i64::from(u32::MAX) - 1, 0, false);\n        test(-i64::from(u32::MAX) - 1, 31, false);\n        test(-i64::from(u32::MAX) - 1, 32, true);\n        test(-i64::from(u32::MAX) - 1, 33, true);\n    }\n}\n\n#[test]\nfn test_get_bit() {\n    apply_fn_to_primitive_ints!(test_helper_primitive_int);\n    apply_fn_to_signeds!(test_helper_signed);\n}\n\nfn properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, _>().test_properties(|(n, index)| {\n        let bit = n.get_bit(index);\n        if index >= T::WIDTH {\n            assert!(!bit);\n        } else {\n            assert_eq!(bit, !(!n).get_bit(index));\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        let significant_bits = n.significant_bits();\n        assert!(!n.get_bit(significant_bits));\n        if n != T::ZERO {\n            assert!(n.get_bit(significant_bits - 1));\n        }\n    });\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_1::<T, _>().test_properties(|(n, index)| {\n        let bit = n.get_bit(index);\n        if index >= T::WIDTH {\n            assert_eq!(bit, n < T::ZERO);\n        } else {\n            assert_eq!(bit, !(!n).get_bit(index));\n        }\n    });\n}\n\n#[test]\nfn get_bit_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_access/set_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_3, unsigned_pair_gen_var_3,\n};\nuse std::panic::catch_unwind;\n\nfn set_bit_helper_unsigned<T: PrimitiveInt>() {\n    let test = |n: u64, index, out: u64| {\n        let mut n = T::exact_from(n);\n        n.set_bit(index);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(100, 0, 101);\n    if T::WIDTH >= u16::WIDTH {\n        test(0, 10, 1024);\n    }\n    if T::WIDTH >= u64::WIDTH {\n        test(1000000000000, 10, 1000000001024);\n    }\n}\n\nfn set_bit_helper_signed<T: PrimitiveSigned>() {\n    set_bit_helper_unsigned::<T>();\n\n    let test = |n: i64, index, out: i64| {\n        let mut n = T::exact_from(n);\n        n.set_bit(index);\n        assert_eq!(n, T::exact_from(out));\n    };\n\n    test(-1, 5, -1);\n    test(-1, 100, -1);\n    test(-33, 5, -1);\n    test(-32, 0, -31);\n\n    if T::WIDTH >= u64::WIDTH {\n        test(-1000000000000, 10, -999999998976);\n        test(-1000000000000, 100, -1000000000000);\n    }\n\n    let mut n = T::ZERO;\n    n.set_bit(T::WIDTH - 1);\n    assert_eq!(n, T::MIN);\n}\n\n#[test]\nfn test_set_bit() {\n    apply_fn_to_unsigneds!(set_bit_helper_unsigned);\n    apply_fn_to_signeds!(set_bit_helper_signed);\n}\n\nfn set_bit_fail_helper<T: PrimitiveInt>() {\n    assert_panic!({\n        let mut n = T::exact_from(5);\n        n.set_bit(200);\n    });\n}\n\n#[test]\nfn set_bit_fail() {\n    apply_fn_to_primitive_ints!(set_bit_fail_helper);\n}\n\nfn properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_3::<T>().test_properties(|(mut n, index)| {\n        let old_n = n;\n        n.set_bit(index);\n        let result = n;\n\n        let mut n = old_n;\n        n.assign_bit(index, true);\n        assert_eq!(n, result);\n\n        assert_ne!(result, T::ZERO);\n        assert!(result >= old_n);\n        if old_n.get_bit(index) {\n            assert_eq!(result, old_n);\n        } else {\n            assert_ne!(result, old_n);\n            let mut n = result;\n            n.clear_bit(index);\n            assert_eq!(n, old_n);\n        }\n    });\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_3::<T>().test_properties(|(mut n, index)| {\n        let old_n = n;\n        n.set_bit(index);\n        let result = n;\n\n        let mut n = old_n;\n        n.assign_bit(index, true);\n        assert_eq!(n, result);\n\n        assert_ne!(result, T::ZERO);\n        if old_n >= T::ZERO && index == T::WIDTH - 1 {\n            assert!(result < T::ZERO);\n        } else {\n            assert!(result >= old_n);\n        }\n        if old_n.get_bit(index) {\n            assert_eq!(result, old_n);\n        } else {\n            assert_ne!(result, old_n);\n            let mut n = result;\n            n.clear_bit(index);\n            assert_eq!(n, old_n);\n        }\n\n        let mut n = !old_n;\n        n.clear_bit(index);\n        n.not_assign();\n        assert_eq!(n, result);\n    });\n}\n\n#[test]\nfn set_bit_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_block_access/assign_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, signed_unsigned_unsigned_triple_gen_var_1,\n    signed_unsigned_unsigned_unsigned_quadruple_gen_var_1, unsigned_pair_gen_var_2,\n    unsigned_pair_gen_var_7, unsigned_quadruple_gen_var_1, unsigned_triple_gen_var_4,\n};\nuse malachite_base::test_util::num::logic::bit_block_access::assign_bits_naive;\nuse std::cmp::min;\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_assign_bits_unsigned() {\n    fn test<T: BitBlockAccess<Bits = T> + PrimitiveUnsigned>(\n        x_in: T,\n        start: u64,\n        end: u64,\n        bits: T,\n        x_out: T,\n    ) {\n        let mut x = x_in;\n        x.assign_bits(start, end, &bits);\n        assert_eq!(x, x_out);\n\n        let mut x = x_in;\n        assign_bits_naive(&mut x, start, end, &bits);\n        assert_eq!(x, x_out);\n    }\n    // - assign partially\n    test(0xab5du16, 4, 8, 0xc, 0xabcd);\n    test(0x5bcdu16, 12, 100, 0xa, 0xabcd);\n    test(0xabcdu16, 5, 9, 10, 43853);\n    test(0xabcdu16, 5, 5, 123, 0xabcd);\n    // - assign zeros above width\n    test(0xabcdu16, 100, 200, 0, 0xabcd);\n    test(0xabcdu16, 8, 24, 0, 0xcd);\n    // - assign everything\n    test(0xabcdu16, 0, 100, 0x1234, 0x1234);\n\n    test(0xab5du64, 4, 8, 0xc, 0xabcd);\n    test(0x5bcdu64, 12, 100, 0xa, 0xabcd);\n    test(0xabcdu64, 5, 9, 10, 43853);\n    test(0xabcdu64, 5, 5, 123, 0xabcd);\n    test(0xabcdu64, 100, 200, 0, 0xabcd);\n    test(0xabcdu64, 0, 100, 0x1234, 0x1234);\n}\n\n#[test]\npub fn test_assign_bits_signed() {\n    fn test<T: BitBlockAccess<Bits = U> + PrimitiveSigned, U: PrimitiveUnsigned>(\n        x_in: T,\n        start: u64,\n        end: u64,\n        bits: U,\n        x_out: T,\n    ) {\n        let mut x = x_in;\n        x.assign_bits(start, end, &bits);\n        assert_eq!(x, x_out);\n\n        let mut x = x_in;\n        assign_bits_naive(&mut x, start, end, &bits);\n        assert_eq!(x, x_out);\n    }\n    // - *self >= 0\n    test(0x2b5di16, 4, 8, 0xc, 0x2bcd);\n    // - *self < 0\n    // - assign within width\n    test(-0x5413i16, 4, 8, 0xc, -0x5433);\n    test(-0x54a3i16, 5, 9, 14, -21539);\n    test(-0x5433i16, 5, 5, 0, -0x5433);\n    // - assign ones above width\n    test(-0x5433i16, 100, 104, 0xf, -0x5433);\n    // - assign everything\n    test(-57i8, 0, 8, 0xff, -1);\n\n    test(0x2b5di64, 4, 8, 0xc, 0x2bcd);\n    test(-0x5413i64, 4, 8, 0xc, -0x5433);\n    test(-0x54a3i64, 5, 9, 14, -21539);\n    test(-0x5433i64, 5, 5, 0, -0x5433);\n    test(-0x5433i64, 100, 104, 0xf, -0x5433);\n    test(-57i64, 0, 64, u64::MAX, -1);\n}\n\nfn assign_bits_fail_helper_unsigned<T: BitBlockAccess<Bits = T> + PrimitiveUnsigned>() {\n    assert_panic!(T::exact_from(100).assign_bits(10, 5, &T::exact_from(3)));\n    assert_panic!(T::exact_from(100).assign_bits(3, T::WIDTH + 3, &T::MAX));\n}\n\nfn assign_bits_fail_helper_signed<\n    U: PrimitiveUnsigned,\n    S: BitBlockAccess<Bits = U> + PrimitiveSigned,\n>() {\n    assert_panic!(S::exact_from(100).assign_bits(7, 5, &U::exact_from(3)));\n    assert_panic!(S::exact_from(100).assign_bits(0, S::WIDTH, &U::MAX));\n    assert_panic!(S::exact_from(-100).assign_bits(0, S::WIDTH + 1, &U::ZERO));\n    assert_panic!(S::exact_from(-100).assign_bits(S::WIDTH + 1, S::WIDTH + 2, &U::ZERO));\n    assert_panic!({\n        let half_width = S::WIDTH >> 1;\n        S::exact_from(-100).assign_bits(half_width, 3 * half_width - 4, &U::ZERO);\n    });\n}\n\n#[test]\nfn assign_bits_fail() {\n    apply_fn_to_unsigneds!(assign_bits_fail_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(assign_bits_fail_helper_signed);\n}\n\nfn properties_helper_unsigned<T: BitBlockAccess<Bits = T> + PrimitiveUnsigned>() {\n    unsigned_quadruple_gen_var_1::<T, T>().test_properties(|(n, start, end, bits)| {\n        let mut mut_n = n;\n        mut_n.assign_bits(start, end, &bits);\n        let mut mut_n_alt = mut_n;\n        mut_n_alt.assign_bits(start, end, &bits);\n        assert_eq!(mut_n_alt, mut_n);\n        let mut mut_n_alt = n;\n        assign_bits_naive::<T, T>(&mut mut_n_alt, start, end, &bits);\n        assert_eq!(mut_n_alt, mut_n);\n        assert_eq!(mut_n.get_bits(start, end), bits.mod_power_of_2(end - start));\n    });\n\n    unsigned_triple_gen_var_4::<T, u64>().test_properties(|(n, bits, start)| {\n        let mut mut_n = n;\n        mut_n.assign_bits(start, start, &bits);\n        assert_eq!(mut_n, n);\n    });\n\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, start)| {\n        let mut mut_n = n;\n        mut_n.assign_bits(start + T::WIDTH, start + (T::WIDTH << 1), &T::ZERO);\n        assert_eq!(mut_n, n);\n    });\n\n    unsigned_pair_gen_var_7::<u64>().test_properties(|(start, end)| {\n        let mut n = T::ZERO;\n        n.assign_bits(start, end, &T::ZERO);\n        assert_eq!(n, T::ZERO);\n    });\n}\n\nfn properties_helper_signed<\n    U: BitBlockAccess<Bits = U> + PrimitiveUnsigned,\n    T: BitBlockAccess<Bits = U> + PrimitiveSigned + UnsignedAbs<Output = U>,\n>() {\n    signed_unsigned_unsigned_unsigned_quadruple_gen_var_1::<T, U>().test_properties(\n        |(n, start, end, bits)| {\n            let mut mut_n = n;\n            mut_n.assign_bits(start, end, &bits);\n            let mut mut_n_alt = mut_n;\n            mut_n_alt.assign_bits(start, end, &bits);\n            assert_eq!(mut_n_alt, mut_n);\n            let mut mut_n_alt = n;\n            assign_bits_naive::<T, U>(&mut mut_n_alt, start, end, &bits);\n            assert_eq!(mut_n_alt, mut_n);\n            assert_eq!(mut_n.get_bits(start, end), bits.mod_power_of_2(end - start));\n            assert_eq!(mut_n >= T::ZERO, n >= T::ZERO);\n        },\n    );\n\n    signed_unsigned_unsigned_triple_gen_var_1::<T, U, u64>().test_properties(|(n, bits, start)| {\n        let mut mut_n = n;\n        mut_n.assign_bits(start, start, &bits);\n        assert_eq!(mut_n, n);\n    });\n\n    signed_unsigned_pair_gen_var_1::<T, u64>().test_properties(|(n, start)| {\n        let mut mut_n = n;\n        mut_n.assign_bits(\n            start + T::WIDTH - 1,\n            start + (T::WIDTH << 1) - 1,\n            &(if n >= T::ZERO { U::ZERO } else { U::MAX }),\n        );\n        assert_eq!(mut_n, n);\n    });\n\n    unsigned_pair_gen_var_7().test_properties(|(start, end)| {\n        let mut n = T::ZERO;\n        n.assign_bits(start, end, &U::ZERO);\n        assert_eq!(n, T::ZERO);\n\n        let mut n = T::NEGATIVE_ONE;\n        n.assign_bits(start, min(end, start.saturating_add(T::WIDTH)), &U::MAX);\n        assert_eq!(n, T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\nfn assign_bits_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_block_access/get_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, signed_unsigned_unsigned_triple_gen_var_2, unsigned_gen_var_5,\n    unsigned_pair_gen_var_2, unsigned_pair_gen_var_7, unsigned_triple_gen_var_5,\n};\nuse malachite_base::test_util::num::logic::bit_block_access::get_bits_naive;\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_get_bits_unsigned() {\n    fn test<T: BitBlockAccess<Bits = T> + PrimitiveUnsigned>(x: T, start: u64, end: u64, out: T) {\n        assert_eq!(x.get_bits(start, end), out);\n        assert_eq!(get_bits_naive::<T, T>(&x, start, end), out);\n    }\n    test(0xabcdu16, 4, 8, 0xc);\n    test(0xabcdu16, 12, 100, 0xa);\n    test(0xabcdu16, 5, 9, 14);\n    test(0xabcdu16, 5, 5, 0);\n    test(0xabcdu16, 100, 200, 0);\n\n    test(0xabcdu64, 4, 8, 0xc);\n    test(0xabcdu64, 12, 100, 0xa);\n    test(0xabcdu64, 5, 9, 14);\n    test(0xabcdu64, 5, 5, 0);\n    test(0xabcdu64, 100, 200, 0);\n}\n\n#[test]\npub fn test_get_bits_signed() {\n    fn test<T: BitBlockAccess<Bits = U> + PrimitiveSigned, U: PrimitiveUnsigned>(\n        x: T,\n        start: u64,\n        end: u64,\n        out: U,\n    ) {\n        assert_eq!(x.get_bits(start, end), out);\n        assert_eq!(get_bits_naive::<T, U>(&x, start, end), out);\n    }\n    test(-0x5433i16, 4, 8, 0xc);\n    test(-0x5433i16, 5, 9, 14);\n    test(-0x5433i16, 5, 5, 0);\n    test(-0x5433i16, 100, 104, 0xf);\n\n    test(-0x5433i64, 4, 8, 0xc);\n    test(-0x5433i64, 5, 9, 14);\n    test(-0x5433i64, 5, 5, 0);\n    test(-0x5433i64, 100, 104, 0xf);\n\n    test(-1i8, 0, 8, 0xff);\n}\n\nfn get_bits_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::exact_from(100).get_bits(10, 5));\n}\n\nfn get_bits_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::exact_from(-100).get_bits(100, 300));\n}\n\n#[test]\nfn get_bits_fail() {\n    apply_fn_to_primitive_ints!(get_bits_fail_helper);\n    apply_fn_to_signeds!(get_bits_fail_helper_signed);\n}\n\nfn properties_helper_unsigned<T: BitBlockAccess<Bits = T> + PrimitiveUnsigned>() {\n    unsigned_triple_gen_var_5::<T, _>().test_properties(|(n, start, end)| {\n        let bits = n.get_bits(start, end);\n        assert_eq!(get_bits_naive::<T, T>(&n, start, end), bits);\n        assert!(bits <= n);\n        assert_eq!(n.get_bits(start + T::WIDTH, end + T::WIDTH), T::ZERO);\n        let mut n_alt = n;\n        n_alt.assign_bits(start, end, &bits);\n        assert_eq!(n_alt, n);\n    });\n\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, start)| {\n        assert_eq!(n.get_bits(start, start), T::ZERO);\n    });\n\n    unsigned_pair_gen_var_7().test_properties(|(start, end)| {\n        assert_eq!(T::ZERO.get_bits(start, end), T::ZERO);\n    });\n}\n\nfn properties_helper_signed<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: BitBlockAccess<Bits = U> + PrimitiveSigned + WrappingFrom<U>,\n>() {\n    signed_unsigned_unsigned_triple_gen_var_2::<U, S, u64>().test_properties(|(n, start, end)| {\n        let bits = n.get_bits(start, end);\n        assert_eq!(get_bits_naive::<S, U>(&n, start, end), bits);\n        let mut n_alt = n;\n        n_alt.assign_bits(start, end, &bits);\n        assert_eq!(n_alt, n);\n    });\n\n    signed_unsigned_pair_gen_var_1::<S, _>().test_properties(|(n, start)| {\n        assert_eq!(n.get_bits(start, start), U::ZERO);\n        assert_eq!(\n            n.get_bits(start + S::WIDTH, start + (S::WIDTH << 1)),\n            if n >= S::ZERO { U::ZERO } else { U::MAX }\n        );\n    });\n\n    unsigned_pair_gen_var_7().test_properties(|(start, end)| {\n        assert_eq!(S::ZERO.get_bits(start, end), U::ZERO);\n    });\n\n    unsigned_gen_var_5().test_properties(|start| {\n        assert_eq!(S::NEGATIVE_ONE.get_bits(start, start + S::WIDTH), U::MAX);\n    });\n}\n\n#[test]\nfn get_bits_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_unsigned_signed_pairs!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_convertible/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::repeat_n;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    bool_vec_gen_var_1, bool_vec_gen_var_2, bool_vec_gen_var_3, bool_vec_gen_var_4,\n    unsigned_gen_var_5,\n};\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    from_bits_asc_alt, from_bits_asc_signed_naive, from_bits_asc_unsigned_naive, from_bits_desc_alt,\n};\nuse std::iter::once;\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_from_bits_asc() {\n    fn test_unsigned<T: PrimitiveUnsigned>(bits: &[bool], out: T) {\n        assert_eq!(T::from_bits_asc(bits.iter().copied()), out);\n        assert_eq!(\n            from_bits_asc_unsigned_naive::<T, _>(bits.iter().copied()),\n            out\n        );\n        assert_eq!(from_bits_asc_alt::<T, _>(bits.iter().copied()), out);\n    }\n    test_unsigned(&[], 0u8);\n    test_unsigned(&[false], 0u8);\n    test_unsigned(&[false, false, false], 0u8);\n    test_unsigned(&[false; 100], 0u8);\n    test_unsigned(&[true], 1u16);\n    test_unsigned(&[false, true], 2u32);\n    test_unsigned(&[true, true], 3u64);\n    test_unsigned(&[true, true, false, true, true, true, true], 123u16);\n    test_unsigned(\n        &[true, true, false, true, true, true, true, false, false, false],\n        123u16,\n    );\n    test_unsigned(&[true; 8], u8::MAX);\n\n    fn test_signed<T: PrimitiveSigned>(bits: &[bool], out: T) {\n        assert_eq!(T::from_bits_asc(bits.iter().copied()), out);\n        assert_eq!(\n            from_bits_asc_signed_naive::<T, _>(bits.iter().copied()),\n            out\n        );\n        assert_eq!(from_bits_asc_alt::<T, _>(bits.iter().copied()), out);\n    }\n    test_signed(&[], 0i8);\n    test_signed(&[false], 0i8);\n    test_signed(&[false, false, false], 0i8);\n    test_signed(&[false; 100], 0i8);\n    test_signed(&[true, false], 1i16);\n    test_signed(&[false, true, false], 2i32);\n    test_signed(&[true, true, false], 3i64);\n    test_signed(&[true], -1i16);\n    test_signed(&[true, true, true], -1i16);\n    test_signed(&[true; 100], -1i16);\n    test_signed(&[false, true], -2i32);\n    test_signed(&[true, false, true], -3i64);\n    test_signed(&[true, true, false, true, true, true, true, false], 123i16);\n    test_signed(\n        &[true, true, false, true, true, true, true, false, false, false, false],\n        123i16,\n    );\n    test_signed(\n        &[true, false, true, false, false, false, false, true],\n        -123i16,\n    );\n    test_signed(\n        &[true, false, true, false, false, false, false, true, true, true, true],\n        -123i16,\n    );\n    test_signed(&[true, true, true, true, true, true, true, false], i8::MAX);\n    test_signed(\n        &[false, false, false, false, false, false, false, true],\n        i8::MIN,\n    );\n}\n\nfn from_bits_asc_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::from_bits_asc(repeat_n(true, 200)));\n}\n\nfn from_bits_asc_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::from_bits_asc(\n        repeat_n(false, 200).chain([true, false].iter().copied())\n    ));\n    assert_panic!(T::from_bits_asc(repeat_n(false, 200).chain(once(true))));\n}\n\n#[test]\nfn from_bits_asc_fail() {\n    apply_fn_to_unsigneds!(from_bits_asc_fail_helper_unsigned);\n    apply_fn_to_signeds!(from_bits_asc_fail_helper_signed);\n}\n\n#[test]\npub fn test_from_bits_desc() {\n    fn test_unsigned<T: PrimitiveUnsigned>(bits: &[bool], out: T) {\n        assert_eq!(T::from_bits_desc(bits.iter().copied()), out);\n        assert_eq!(from_bits_desc_alt::<T, _>(bits.iter().copied()), out);\n    }\n    test_unsigned(&[], 0u8);\n    test_unsigned(&[false], 0u8);\n    test_unsigned(&[false, false, false], 0u8);\n    test_unsigned(&[false; 100], 0u8);\n    test_unsigned(&[true], 1u16);\n    test_unsigned(&[true, false], 2u32);\n    test_unsigned(&[true, true], 3u64);\n    test_unsigned(&[true, true, true, true, false, true, true], 123u16);\n    test_unsigned(\n        &[false, false, false, true, true, true, true, false, true, true],\n        123u16,\n    );\n    test_unsigned(&[true; 8], u8::MAX);\n\n    fn test_signed<T: PrimitiveSigned>(bits: &[bool], out: T) {\n        assert_eq!(T::from_bits_desc(bits.iter().copied()), out);\n        assert_eq!(from_bits_desc_alt::<T, _>(bits.iter().copied()), out);\n    }\n    test_signed(&[], 0i8);\n    test_signed(&[false], 0i8);\n    test_signed(&[false, false, false], 0i8);\n    test_signed(&[false; 100], 0i8);\n    test_signed(&[false, true], 1i16);\n    test_signed(&[false, true, false], 2i32);\n    test_signed(&[false, true, true], 3i64);\n    test_signed(&[true], -1i16);\n    test_signed(&[true, true, true], -1i16);\n    test_signed(&[true; 100], -1i16);\n    test_signed(&[true, false], -2i32);\n    test_signed(&[true, false, true], -3i64);\n    test_signed(&[false, true, true, true, true, false, true, true], 123i16);\n    test_signed(\n        &[false, false, false, false, true, true, true, true, false, true, true],\n        123i16,\n    );\n    test_signed(\n        &[true, false, false, false, false, true, false, true],\n        -123i16,\n    );\n    test_signed(\n        &[true, true, true, true, false, false, false, false, true, false, true],\n        -123i16,\n    );\n    test_signed(&[false, true, true, true, true, true, true, true], i8::MAX);\n    test_signed(\n        &[true, false, false, false, false, false, false, false],\n        i8::MIN,\n    );\n}\n\nfn from_bits_desc_fail_helper_unsigned<T: PrimitiveUnsigned>() {\n    assert_panic!(T::from_bits_desc(repeat_n(true, 200)));\n}\n\nfn from_bits_desc_fail_helper_signed<T: PrimitiveSigned>() {\n    assert_panic!(T::from_bits_desc(\n        [false, true].iter().copied().chain(repeat_n(false, 200))\n    ));\n    assert_panic!(T::from_bits_desc(once(true).chain(repeat_n(false, 200))));\n}\n\n#[test]\nfn from_bits_desc_fail() {\n    apply_fn_to_unsigneds!(from_bits_desc_fail_helper_unsigned);\n    apply_fn_to_signeds!(from_bits_desc_fail_helper_signed);\n}\n\nfn from_bits_asc_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    bool_vec_gen_var_1::<T>().test_properties(|bs| {\n        let n = T::from_bits_asc(bs.iter().copied());\n        assert_eq!(from_bits_asc_unsigned_naive::<T, _>(bs.iter().copied()), n);\n        assert_eq!(from_bits_asc_alt::<T, _>(bs.iter().copied()), n);\n        let trailing_falses = bs.iter().rev().take_while(|&&bit| !bit).count();\n        let trimmed_bits = bs[..bs.len() - trailing_falses].to_vec();\n        assert_eq!(n.to_bits_asc(), trimmed_bits);\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(T::from_bits_desc(repeat_n(false, u)), T::ZERO);\n    });\n}\n\nfn from_bits_asc_properties_helper_signed<T: PrimitiveSigned>() {\n    bool_vec_gen_var_2::<T>().test_properties(|bs| {\n        let n = T::from_bits_asc(bs.iter().copied());\n        assert_eq!(from_bits_asc_signed_naive::<T, _>(bs.iter().copied()), n);\n        assert_eq!(from_bits_asc_alt::<T, _>(bs.iter().copied()), n);\n        let trimmed_bits = if bs.iter().all(|&bit| !bit) {\n            Vec::new()\n        } else {\n            let sign_bits = if *bs.last().unwrap() {\n                bs.iter().rev().take_while(|&&bit| bit).count()\n            } else {\n                bs.iter().rev().take_while(|&&bit| !bit).count()\n            };\n            bs[..=bs.len() - sign_bits].to_vec()\n        };\n        assert_eq!(n.to_bits_asc(), trimmed_bits);\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(T::from_bits_asc(repeat_n(false, u)), T::ZERO);\n        assert_eq!(T::from_bits_asc(repeat_n(true, u + 1)), T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\nfn from_bits_asc_properties() {\n    apply_fn_to_unsigneds!(from_bits_asc_properties_helper_unsigned);\n    apply_fn_to_signeds!(from_bits_asc_properties_helper_signed);\n}\n\nfn from_bits_desc_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    bool_vec_gen_var_3::<T>().test_properties(|bs| {\n        let n = T::from_bits_desc(bs.iter().copied());\n        assert_eq!(from_bits_desc_alt::<T, _>(bs.iter().copied()), n);\n        let leading_falses = bs.iter().take_while(|&&bit| !bit).count();\n        let trimmed_bits = bs[leading_falses..].to_vec();\n        assert_eq!(n.to_bits_desc(), trimmed_bits);\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(T::from_bits_desc(repeat_n(false, u)), T::ZERO);\n    });\n}\n\nfn from_bits_desc_properties_helper_signed<T: PrimitiveSigned>() {\n    bool_vec_gen_var_4::<T>().test_properties(|bs| {\n        let n = T::from_bits_desc(bs.iter().copied());\n        assert_eq!(from_bits_desc_alt::<T, _>(bs.iter().copied()), n);\n        let trimmed_bits = if bs.iter().all(|&bit| !bit) {\n            Vec::new()\n        } else {\n            let sign_bits = if bs[0] {\n                bs.iter().take_while(|&&bit| bit).count()\n            } else {\n                bs.iter().take_while(|&&bit| !bit).count()\n            };\n            bs[sign_bits - 1..].to_vec()\n        };\n        assert_eq!(n.to_bits_desc(), trimmed_bits);\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(T::from_bits_desc(repeat_n(false, u)), T::ZERO);\n        assert_eq!(T::from_bits_desc(repeat_n(true, u + 1)), T::NEGATIVE_ONE);\n    });\n}\n\n#[test]\nfn from_bits_desc_properties() {\n    apply_fn_to_unsigneds!(from_bits_desc_properties_helper_unsigned);\n    apply_fn_to_signeds!(from_bits_desc_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_convertible/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    to_bits_asc_alt, to_bits_asc_signed_naive, to_bits_asc_unsigned_naive, to_bits_desc_alt,\n    to_bits_desc_signed_naive, to_bits_desc_unsigned_naive,\n};\n\n#[test]\npub fn test_to_bits_asc() {\n    fn test_unsigned<T: PrimitiveUnsigned>(x: T, out: &[bool]) {\n        assert_eq!(x.to_bits_asc(), out);\n        assert_eq!(to_bits_asc_unsigned_naive(x), out);\n        assert_eq!(to_bits_asc_alt(&x), out);\n        assert_eq!(x.bits().collect_vec(), out);\n    }\n    test_unsigned(0u8, &[]);\n    test_unsigned(1u16, &[true]);\n    test_unsigned(2u32, &[false, true]);\n    test_unsigned(3u64, &[true, true]);\n    test_unsigned(123u16, &[true, true, false, true, true, true, true]);\n    test_unsigned(u8::MAX, &[true; 8]);\n\n    fn test_signed<T: PrimitiveSigned>(x: T, out: &[bool]) {\n        assert_eq!(x.to_bits_asc(), out);\n        assert_eq!(to_bits_asc_signed_naive(x), out);\n        assert_eq!(to_bits_asc_alt(&x), out);\n        assert_eq!(x.bits().collect_vec(), out);\n    }\n    test_signed(0i8, &[]);\n    test_signed(1i16, &[true, false]);\n    test_signed(2i32, &[false, true, false]);\n    test_signed(3i64, &[true, true, false]);\n    test_signed(-1i16, &[true]);\n    test_signed(-2i32, &[false, true]);\n    test_signed(-3i64, &[true, false, true]);\n    test_signed(123i16, &[true, true, false, true, true, true, true, false]);\n    test_signed(\n        -123i16,\n        &[true, false, true, false, false, false, false, true],\n    );\n    test_signed(i8::MAX, &[true, true, true, true, true, true, true, false]);\n    test_signed(\n        i8::MIN,\n        &[false, false, false, false, false, false, false, true],\n    );\n}\n\n#[test]\npub fn test_to_bits_desc() {\n    fn test_unsigned<T: PrimitiveUnsigned>(x: T, out: &[bool]) {\n        assert_eq!(x.to_bits_desc(), out);\n        assert_eq!(to_bits_desc_unsigned_naive(x), out);\n        assert_eq!(to_bits_desc_alt(&x), out);\n        assert_eq!(x.bits().rev().collect_vec(), out);\n    }\n    test_unsigned(0u8, &[]);\n    test_unsigned(1u16, &[true]);\n    test_unsigned(2u32, &[true, false]);\n    test_unsigned(3u64, &[true, true]);\n    test_unsigned(123u16, &[true, true, true, true, false, true, true]);\n    test_unsigned(u8::MAX, &[true; 8]);\n\n    fn test_signed<T: PrimitiveSigned>(x: T, out: &[bool]) {\n        assert_eq!(x.to_bits_desc(), out);\n        assert_eq!(to_bits_desc_signed_naive(x), out);\n        assert_eq!(to_bits_desc_alt(&x), out);\n        assert_eq!(x.bits().rev().collect_vec(), out);\n    }\n    test_signed(0i8, &[]);\n    test_signed(1i16, &[false, true]);\n    test_signed(2i32, &[false, true, false]);\n    test_signed(3i64, &[false, true, true]);\n    test_signed(-1i16, &[true]);\n    test_signed(-2i32, &[true, false]);\n    test_signed(-3i64, &[true, false, true]);\n    test_signed(123i16, &[false, true, true, true, true, false, true, true]);\n    test_signed(\n        -123i16,\n        &[true, false, false, false, false, true, false, true],\n    );\n    test_signed(i8::MAX, &[false, true, true, true, true, true, true, true]);\n    test_signed(\n        i8::MIN,\n        &[true, false, false, false, false, false, false, false],\n    );\n}\n\nfn to_bits_asc_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|u| {\n        let bits = u.to_bits_asc();\n        assert_eq!(to_bits_asc_unsigned_naive(u), bits);\n        assert_eq!(to_bits_asc_alt(&u), bits);\n        assert_eq!(u.bits().collect::<Vec<bool>>(), bits);\n        assert_eq!(\n            bits.iter().copied().rev().collect::<Vec<bool>>(),\n            u.to_bits_desc()\n        );\n        assert_eq!(T::from_bits_asc(bits.iter().copied()), u);\n        if u != T::ZERO {\n            assert_eq!(*bits.last().unwrap(), true);\n        }\n        assert_eq!(bits.len(), usize::exact_from(u.significant_bits()));\n    });\n}\n\nfn to_bits_asc_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|i| {\n        let bits = i.to_bits_asc();\n        assert_eq!(to_bits_asc_signed_naive(i), bits);\n        assert_eq!(to_bits_asc_alt(&i), bits);\n        assert_eq!(i.bits().collect::<Vec<bool>>(), bits);\n        assert_eq!(\n            bits.iter().copied().rev().collect::<Vec<bool>>(),\n            i.to_bits_desc()\n        );\n        assert_eq!(T::from_bits_asc(bits.iter().copied()), i);\n        if i != T::ZERO {\n            assert_eq!(*bits.last().unwrap(), i < T::ZERO);\n        }\n        let bit_len = bits.len();\n        assert!(bit_len <= usize::exact_from(T::WIDTH));\n        if bit_len > 1 {\n            assert_ne!(bits[bit_len - 1], bits[bit_len - 2]);\n        }\n    });\n}\n\n#[test]\nfn to_bits_asc_properties() {\n    apply_fn_to_unsigneds!(to_bits_asc_properties_helper_unsigned);\n    apply_fn_to_signeds!(to_bits_asc_properties_helper_signed);\n}\n\nfn to_bits_desc_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|u| {\n        let bits = u.to_bits_desc();\n        assert_eq!(to_bits_desc_unsigned_naive(u), bits);\n        assert_eq!(to_bits_desc_alt(&u), bits);\n        assert_eq!(u.bits().rev().collect::<Vec<bool>>(), bits);\n        assert_eq!(\n            bits.iter().copied().rev().collect::<Vec<bool>>(),\n            u.to_bits_asc()\n        );\n        assert_eq!(T::from_bits_desc(bits.iter().copied()), u);\n        if u != T::ZERO {\n            assert_eq!(bits[0], true);\n        }\n        assert_eq!(bits.len(), usize::exact_from(u.significant_bits()));\n    });\n}\n\nfn to_bits_desc_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|i| {\n        let bits = i.to_bits_desc();\n        assert_eq!(to_bits_desc_signed_naive(i), bits);\n        assert_eq!(to_bits_desc_alt(&i), bits);\n        assert_eq!(i.bits().rev().collect::<Vec<bool>>(), bits);\n        assert_eq!(\n            bits.iter().copied().rev().collect::<Vec<bool>>(),\n            i.to_bits_asc()\n        );\n        assert_eq!(T::from_bits_desc(bits.iter().copied()), i);\n        if i != T::ZERO {\n            assert_eq!(bits[0], i < T::ZERO);\n        }\n        let bit_len = bits.len();\n        assert!(bit_len <= usize::exact_from(T::WIDTH));\n        if bit_len > 1 {\n            assert_ne!(bits[0], bits[1]);\n        }\n    });\n}\n\n#[test]\nfn to_bits_desc_properties() {\n    apply_fn_to_unsigneds!(to_bits_desc_properties_helper_unsigned);\n    apply_fn_to_signeds!(to_bits_desc_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::{BitIterable, SignificantBits};\nuse malachite_base::test_util::common::test_double_ended_iterator_size_hint;\nuse malachite_base::test_util::generators::{\n    signed_bool_vec_pair_gen_var_1, signed_gen, signed_unsigned_pair_gen_var_1,\n    unsigned_bool_vec_pair_gen_var_1, unsigned_gen, unsigned_gen_var_5, unsigned_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\nuse std::ops::Index;\n\n#[test]\npub fn test_bits() {\n    let mut bits = 105u8.bits();\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n\n    assert_eq!(bits[0], true);\n    assert_eq!(bits[1], false);\n    assert_eq!(bits[2], false);\n    assert_eq!(bits[3], true);\n    assert_eq!(bits[4], false);\n    assert_eq!(bits[5], true);\n    assert_eq!(bits[6], true);\n    assert_eq!(bits[7], false);\n    assert_eq!(bits[8], false);\n\n    let mut bits = 105u32.bits();\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n\n    let mut bits = (-105i8).bits();\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n\n    assert_eq!(bits[0], true);\n    assert_eq!(bits[1], true);\n    assert_eq!(bits[2], true);\n    assert_eq!(bits[3], false);\n    assert_eq!(bits[4], true);\n    assert_eq!(bits[5], false);\n    assert_eq!(bits[6], false);\n    assert_eq!(bits[7], true);\n    assert_eq!(bits[8], true);\n\n    let mut bits = (-105i32).bits();\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n}\n\nfn bits_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    T::BitIterator: Clone + Index<u64, Output = bool>,\n{\n    unsigned_gen::<T>().test_properties(|n| {\n        test_double_ended_iterator_size_hint(n.bits(), usize::exact_from(n.significant_bits()));\n    });\n\n    unsigned_bool_vec_pair_gen_var_1::<T>().test_properties(|(n, bs)| {\n        let mut bits = n.bits();\n        let mut bit_vec = Vec::new();\n        let mut i = 0;\n        for b in bs {\n            if b {\n                bit_vec.insert(i, bits.next().unwrap());\n                i += 1;\n            } else {\n                bit_vec.insert(i, bits.next_back().unwrap());\n            }\n        }\n        assert!(bits.next().is_none());\n        assert!(bits.next_back().is_none());\n        assert_eq!(n.to_bits_asc(), bit_vec);\n    });\n\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, u)| {\n        if u < n.significant_bits() {\n            assert_eq!(n.bits()[u], n.to_bits_asc()[usize::exact_from(u)]);\n        } else {\n            assert_eq!(n.bits()[u], false);\n        }\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(T::ZERO.bits()[u], false);\n    });\n}\n\nfn bits_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    T::BitIterator: Clone + Index<u64, Output = bool>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned + WrappingFrom<T>,\n{\n    signed_gen::<T>().test_properties(|i| {\n        let unsigned = <T as UnsignedAbs>::Output::wrapping_from(i);\n        let significant_bits = match i.sign() {\n            Equal => 0,\n            Greater => unsigned.significant_bits() + 1,\n            Less => (!unsigned).significant_bits() + 1,\n        };\n        test_double_ended_iterator_size_hint(i.bits(), usize::exact_from(significant_bits));\n    });\n\n    signed_bool_vec_pair_gen_var_1::<T>().test_properties(|(n, bs)| {\n        let mut bits = n.bits();\n        let mut bit_vec = Vec::new();\n        let mut i = 0;\n        for b in bs {\n            if b {\n                bit_vec.insert(i, bits.next().unwrap());\n                i += 1;\n            } else {\n                bit_vec.insert(i, bits.next_back().unwrap());\n            }\n        }\n        assert!(bits.next().is_none());\n        assert!(bits.next_back().is_none());\n        assert_eq!(n.to_bits_asc(), bit_vec);\n    });\n\n    signed_unsigned_pair_gen_var_1::<T, u64>().test_properties(|(n, u)| {\n        if u < n.significant_bits() {\n            assert_eq!(n.bits()[u], n.to_bits_asc()[usize::exact_from(u)]);\n        } else {\n            assert_eq!(n.bits()[u], n < T::ZERO);\n        }\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(T::ZERO.bits()[u], false);\n    });\n}\n\n#[test]\nfn bits_properties() {\n    apply_fn_to_unsigneds!(bits_properties_helper_unsigned);\n    apply_fn_to_signeds!(bits_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_scan/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::test_util::generators::{\n    signed_gen_var_3, signed_unsigned_pair_gen_var_1, unsigned_gen, unsigned_pair_gen_var_2,\n};\n\n#[test]\npub fn test_index_of_next_false_bit() {\n    fn test_unsigned<T: PrimitiveUnsigned>(x: T, start: u64, out: Option<u64>) {\n        assert_eq!(x.index_of_next_false_bit(start), out);\n    }\n    test_unsigned(0xb00000000u64, 0, Some(0));\n    test_unsigned(0xb00000000u64, 20, Some(20));\n    test_unsigned(0xb00000000u64, 31, Some(31));\n    test_unsigned(0xb00000000u64, 32, Some(34));\n    test_unsigned(0xb00000000u64, 33, Some(34));\n    test_unsigned(0xb00000000u64, 34, Some(34));\n    test_unsigned(0xb00000000u64, 35, Some(36));\n    test_unsigned(0xb00000000u64, 100, Some(100));\n\n    test_unsigned(0xb00000000u128, 0, Some(0));\n    test_unsigned(0xb00000000u128, 20, Some(20));\n    test_unsigned(0xb00000000u128, 31, Some(31));\n    test_unsigned(0xb00000000u128, 32, Some(34));\n    test_unsigned(0xb00000000u128, 33, Some(34));\n    test_unsigned(0xb00000000u128, 34, Some(34));\n    test_unsigned(0xb00000000u128, 35, Some(36));\n    test_unsigned(0xb00000000u128, 100, Some(100));\n\n    fn test_signed<T: PrimitiveSigned>(x: T, start: u64, out: Option<u64>) {\n        assert_eq!(x.index_of_next_false_bit(start), out);\n    }\n    test_signed(-0x500000000i64, 0, Some(0));\n    test_signed(-0x500000000i64, 20, Some(20));\n    test_signed(-0x500000000i64, 31, Some(31));\n    test_signed(-0x500000000i64, 32, Some(34));\n    test_signed(-0x500000000i64, 33, Some(34));\n    test_signed(-0x500000000i64, 34, Some(34));\n    test_signed(-0x500000000i64, 35, None);\n    test_signed(-0x500000000i64, 100, None);\n\n    test_signed(-0x500000000i128, 0, Some(0));\n    test_signed(-0x500000000i128, 20, Some(20));\n    test_signed(-0x500000000i128, 31, Some(31));\n    test_signed(-0x500000000i128, 32, Some(34));\n    test_signed(-0x500000000i128, 33, Some(34));\n    test_signed(-0x500000000i128, 34, Some(34));\n    test_signed(-0x500000000i128, 35, None);\n    test_signed(-0x500000000i128, 100, None);\n}\n\nfn properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, u)| {\n        let result = n.index_of_next_false_bit(u).unwrap();\n        assert!(result >= u);\n        assert!(!n.get_bit(result));\n        assert_eq!(result == u, !n.get_bit(u));\n        assert_eq!(\n            (!n).index_of_next_true_bit(u),\n            if result < T::WIDTH {\n                Some(result)\n            } else {\n                None\n            }\n        );\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        assert_eq!(\n            n.index_of_next_false_bit(0),\n            Some(TrailingZeros::trailing_zeros(!n))\n        );\n    });\n\n    unsigned_gen::<u64>().test_properties(|u| {\n        assert_eq!(T::ZERO.index_of_next_false_bit(u), Some(u));\n    });\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_1::<T, u64>().test_properties(|(n, u)| {\n        let result = n.index_of_next_false_bit(u);\n        assert_eq!(\n            result.is_some(),\n            if u >= T::WIDTH {\n                n >= T::ZERO\n            } else {\n                n | T::low_mask(u) != T::NEGATIVE_ONE\n            }\n        );\n        if let Some(result) = result {\n            assert!(result >= u);\n            assert!(!n.get_bit(result));\n            assert_eq!(result == u, !n.get_bit(u));\n        }\n        assert_eq!((!n).index_of_next_true_bit(u), result);\n    });\n\n    signed_gen_var_3::<T>().test_properties(|n| {\n        assert_eq!(\n            n.index_of_next_false_bit(0),\n            Some(TrailingZeros::trailing_zeros(!n))\n        );\n    });\n\n    unsigned_gen::<u64>().test_properties(|u| {\n        assert_eq!(T::ZERO.index_of_next_false_bit(u), Some(u));\n        assert_eq!(T::NEGATIVE_ONE.index_of_next_false_bit(u), None);\n    });\n}\n\n#[test]\nfn index_of_next_false_bit_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/bit_scan/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::test_util::generators::{\n    signed_gen_var_3, signed_unsigned_pair_gen_var_1, unsigned_gen, unsigned_gen_var_1,\n    unsigned_pair_gen_var_2,\n};\n\n#[test]\npub fn test_index_of_next_true_bit() {\n    fn test_unsigned<T: PrimitiveUnsigned>(x: T, start: u64, out: Option<u64>) {\n        assert_eq!(x.index_of_next_true_bit(start), out);\n    }\n    test_unsigned(0xb00000000u64, 0, Some(32));\n    test_unsigned(0xb00000000u64, 20, Some(32));\n    test_unsigned(0xb00000000u64, 31, Some(32));\n    test_unsigned(0xb00000000u64, 32, Some(32));\n    test_unsigned(0xb00000000u64, 33, Some(33));\n    test_unsigned(0xb00000000u64, 34, Some(35));\n    test_unsigned(0xb00000000u64, 35, Some(35));\n    test_unsigned(0xb00000000u64, 36, None);\n    test_unsigned(0xb00000000u64, 100, None);\n\n    test_unsigned(0xb00000000u128, 0, Some(32));\n    test_unsigned(0xb00000000u128, 20, Some(32));\n    test_unsigned(0xb00000000u128, 31, Some(32));\n    test_unsigned(0xb00000000u128, 32, Some(32));\n    test_unsigned(0xb00000000u128, 33, Some(33));\n    test_unsigned(0xb00000000u128, 34, Some(35));\n    test_unsigned(0xb00000000u128, 35, Some(35));\n    test_unsigned(0xb00000000u128, 36, None);\n    test_unsigned(0xb00000000u128, 100, None);\n\n    fn test_signed<T: PrimitiveSigned>(x: T, start: u64, out: Option<u64>) {\n        assert_eq!(x.index_of_next_true_bit(start), out);\n    }\n    test_signed(-0x500000000i64, 0, Some(32));\n    test_signed(-0x500000000i64, 20, Some(32));\n    test_signed(-0x500000000i64, 31, Some(32));\n    test_signed(-0x500000000i64, 32, Some(32));\n    test_signed(-0x500000000i64, 33, Some(33));\n    test_signed(-0x500000000i64, 34, Some(35));\n    test_signed(-0x500000000i64, 35, Some(35));\n    test_signed(-0x500000000i64, 36, Some(36));\n    test_signed(-0x500000000i64, 100, Some(100));\n\n    test_signed(-0x500000000i128, 0, Some(32));\n    test_signed(-0x500000000i128, 20, Some(32));\n    test_signed(-0x500000000i128, 31, Some(32));\n    test_signed(-0x500000000i128, 32, Some(32));\n    test_signed(-0x500000000i128, 33, Some(33));\n    test_signed(-0x500000000i128, 34, Some(35));\n    test_signed(-0x500000000i128, 35, Some(35));\n    test_signed(-0x500000000i128, 36, Some(36));\n    test_signed(-0x500000000i128, 100, Some(100));\n}\n\nfn properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_2::<T, u64>().test_properties(|(n, u)| {\n        let result = n.index_of_next_true_bit(u);\n        assert_eq!(result.is_some(), u < n.significant_bits());\n        if let Some(result) = result {\n            assert!(result >= u);\n            assert!(n.get_bit(result));\n            assert_eq!(result == u, n.get_bit(u));\n        }\n    });\n\n    unsigned_gen_var_1::<T>().test_properties(|n| {\n        assert_eq!(\n            n.index_of_next_true_bit(0),\n            Some(TrailingZeros::trailing_zeros(n))\n        );\n    });\n\n    unsigned_gen::<u64>().test_properties(|u| {\n        assert_eq!(T::ZERO.index_of_next_true_bit(u), None);\n    });\n}\n\nfn properties_helper_signed<T: PrimitiveSigned>() {\n    signed_unsigned_pair_gen_var_1::<T, u64>().test_properties(|(n, u)| {\n        let result = n.index_of_next_true_bit(u);\n        assert_eq!(\n            result.is_some(),\n            if u >= T::WIDTH {\n                n < T::ZERO\n            } else {\n                n >> u != T::ZERO\n            }\n        );\n        if let Some(result) = result {\n            assert!(result >= u);\n            assert!(n.get_bit(result));\n            assert_eq!(result == u, n.get_bit(u));\n        }\n        assert_eq!((!n).index_of_next_false_bit(u), result);\n    });\n\n    signed_gen_var_3::<T>().test_properties(|n| {\n        assert_eq!(\n            n.index_of_next_true_bit(0),\n            Some(TrailingZeros::trailing_zeros(n))\n        );\n    });\n\n    unsigned_gen::<u64>().test_properties(|u| {\n        assert_eq!(T::ZERO.index_of_next_true_bit(u), None);\n        assert_eq!(T::NEGATIVE_ONE.index_of_next_true_bit(u), Some(u));\n    });\n}\n\n#[test]\nfn index_of_next_true_bit_properties() {\n    apply_fn_to_unsigneds!(properties_helper_unsigned);\n    apply_fn_to_signeds!(properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/get_highest_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\n#[test]\npub fn test_get_highest_bit() {\n    assert_eq!(0u8.get_highest_bit(), false);\n    assert_eq!(123u32.get_highest_bit(), false);\n    assert_eq!(4000000000u32.get_highest_bit(), true);\n    assert_eq!(2000000000i32.get_highest_bit(), false);\n    assert_eq!((-2000000000i32).get_highest_bit(), true);\n}\n\nfn get_highest_bit_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(u.get_highest_bit(), u >= T::power_of_2(T::WIDTH - 1));\n    });\n}\n\nfn get_highest_bit_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|i| {\n        assert_eq!(i.get_highest_bit(), i < T::ZERO);\n    });\n}\n\n#[test]\nfn get_highest_bit_properties() {\n    apply_fn_to_unsigneds!(get_highest_bit_properties_helper_unsigned);\n    apply_fn_to_signeds!(get_highest_bit_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::logic::traits::{CountOnes, CountZeros};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_2, signed_gen_var_4, signed_pair_gen, signed_pair_gen_var_1,\n    signed_triple_gen_var_3, unsigned_gen, unsigned_pair_gen_var_27, unsigned_triple_gen_var_19,\n};\n\n#[test]\npub fn test_hamming_distance() {\n    fn test<T: PrimitiveUnsigned>(x: T, y: T, out: u64) {\n        assert_eq!(x.hamming_distance(y), out);\n    }\n    test(123u16, 456u16, 6);\n    test(0xffffu32, 0xffff0000u32, 32);\n    test(0xffffu32, u32::MAX, 16);\n    test(0xffff0000u32, u32::MAX, 16);\n}\n\n#[test]\npub fn test_checked_hamming_distance() {\n    fn test<T: PrimitiveSigned>(x: T, y: T, out: Option<u64>) {\n        assert_eq!(x.checked_hamming_distance(y), out);\n    }\n    test(123i32, 456i32, Some(6));\n    test(-123i32, -456i32, Some(7));\n    test(0i8, 127i8, Some(7));\n    test(0i8, -1i8, None);\n    test(-1i8, -128i8, Some(7));\n    test(0i128, i128::MAX, Some(127));\n    test(0i128, -1i128, None);\n    test(-1i128, i128::MIN, Some(127));\n    test(0xffffi32, 0x7fff0000i32, Some(31));\n    test(0xffffi32, i32::MAX, Some(15));\n    test(0x7fff0000i32, i32::MAX, Some(16));\n}\n\nfn hamming_distance_properties_helper<T: PrimitiveUnsigned>() {\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        let distance = x.hamming_distance(y);\n        assert_eq!(y.hamming_distance(x), distance);\n        assert_eq!(distance == 0, x == y);\n        assert_eq!(CountOnes::count_ones(x ^ y), distance);\n        assert_eq!((!x).hamming_distance(!y), distance);\n    });\n\n    unsigned_triple_gen_var_19::<T>().test_properties(|(x, y, z)| {\n        assert!(x.hamming_distance(z) <= x.hamming_distance(y) + y.hamming_distance(z));\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_eq!(x.hamming_distance(x), 0);\n        assert_eq!(x.hamming_distance(!x), T::WIDTH);\n        assert_eq!(x.hamming_distance(T::ZERO), CountOnes::count_ones(x));\n        assert_eq!(T::ZERO.hamming_distance(x), CountOnes::count_ones(x));\n    });\n}\n\n#[test]\nfn hamming_distance_properties() {\n    apply_fn_to_unsigneds!(hamming_distance_properties_helper);\n}\n\nfn checked_hamming_distance_properties_helper<T: PrimitiveSigned>() {\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let distance = x.checked_hamming_distance(y);\n        assert_eq!(y.checked_hamming_distance(x), distance);\n        assert_eq!(distance == Some(0), x == y);\n        assert_eq!((!x).checked_hamming_distance(!y), distance);\n    });\n\n    signed_pair_gen_var_1::<T>().test_properties(|(x, y)| {\n        let distance = x.checked_hamming_distance(y).unwrap();\n        assert_eq!(y.checked_hamming_distance(x).unwrap(), distance);\n        assert_eq!(distance == 0, x == y);\n        assert_eq!(CountOnes::count_ones(x ^ y), distance);\n        assert_eq!((!x).checked_hamming_distance(!y).unwrap(), distance);\n    });\n\n    signed_triple_gen_var_3::<T>().test_properties(|(x, y, z)| {\n        assert!(\n            x.checked_hamming_distance(z).unwrap()\n                <= x.checked_hamming_distance(y).unwrap() + y.checked_hamming_distance(z).unwrap()\n        );\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_eq!(x.checked_hamming_distance(x), Some(0));\n        assert_eq!(x.checked_hamming_distance(!x), None);\n    });\n\n    signed_gen_var_2::<T>().test_properties(|x| {\n        assert_eq!(\n            x.checked_hamming_distance(T::ZERO),\n            Some(CountOnes::count_ones(x))\n        );\n        assert_eq!(\n            T::ZERO.checked_hamming_distance(x),\n            Some(CountOnes::count_ones(x))\n        );\n    });\n\n    signed_gen_var_4::<T>().test_properties(|x| {\n        assert_eq!(\n            x.checked_hamming_distance(T::NEGATIVE_ONE),\n            Some(CountZeros::count_zeros(x))\n        );\n        assert_eq!(\n            T::NEGATIVE_ONE.checked_hamming_distance(x),\n            Some(CountZeros::count_zeros(x))\n        );\n    });\n}\n\n#[test]\nfn checked_hamming_distance_properties() {\n    apply_fn_to_signeds!(checked_hamming_distance_properties_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::unsigned_gen_var_9;\nuse std::panic::catch_unwind;\n\nfn low_mask_primitive_helper<T: PrimitiveInt>() {\n    let test = |bits, out| {\n        assert_eq!(T::low_mask(bits), out);\n    };\n    test(0, T::ZERO);\n    test(1, T::ONE);\n    test(2, T::exact_from(3));\n    test(3, T::exact_from(7));\n}\n\nfn low_mask_unsigned_helper<T: PrimitiveUnsigned>() {\n    let test = |bits, out| {\n        assert_eq!(T::low_mask(bits), out);\n    };\n    test(T::WIDTH - 1, (T::ONE << (T::WIDTH - 1)) - T::ONE);\n    test(T::WIDTH, T::MAX);\n}\n\nfn low_mask_signed_helper<T: PrimitiveSigned>() {\n    let test = |bits, out| {\n        assert_eq!(T::low_mask(bits), out);\n    };\n    test(T::WIDTH - 1, T::MAX);\n    test(T::WIDTH, T::NEGATIVE_ONE);\n}\n\n#[test]\nfn test_low_mask() {\n    apply_fn_to_primitive_ints!(low_mask_primitive_helper);\n    apply_fn_to_unsigneds!(low_mask_unsigned_helper);\n    apply_fn_to_signeds!(low_mask_signed_helper);\n}\n\nfn low_mask_fail_helper<T: PrimitiveInt>() {\n    assert_panic!(T::low_mask(T::WIDTH + 1));\n}\n\n#[test]\nfn low_mask_fail() {\n    apply_fn_to_primitive_ints!(low_mask_fail_helper);\n}\n\nfn low_mask_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen_var_9::<T>().test_properties(|bits| {\n        let n = T::low_mask(bits);\n        assert_eq!(n.count_ones(), bits);\n        assert_eq!(n.index_of_next_false_bit(0), Some(bits));\n    });\n}\n\nfn low_mask_properties_helper_signed<T: PrimitiveSigned>() {\n    unsigned_gen_var_9::<T>().test_properties(|bits| {\n        let n = T::low_mask(bits);\n        assert_eq!(n.count_ones(), bits);\n        assert_eq!(\n            n.index_of_next_false_bit(0),\n            if bits == T::WIDTH { None } else { Some(bits) }\n        );\n    });\n}\n\n#[test]\nfn low_mask_properties() {\n    apply_fn_to_unsigneds!(low_mask_properties_helper_unsigned);\n    apply_fn_to_signeds!(low_mask_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/not_assign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\nfn not_assign_helper<T: PrimitiveInt>() {\n    let test = |n: T| {\n        let mut x = n;\n        x.not_assign();\n        assert_eq!(x, !n);\n    };\n    test(T::ZERO);\n    test(T::ONE);\n    test(T::exact_from(2));\n    test(T::exact_from(3));\n    test(T::exact_from(4));\n    test(T::exact_from(5));\n    test(T::exact_from(100));\n    test(T::exact_from(63));\n    test(T::exact_from(64));\n    test(T::MIN);\n    test(T::MAX);\n}\n\n#[test]\nfn test_not_assign() {\n    apply_fn_to_primitive_ints!(not_assign_helper);\n}\n\nfn not_assign_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|u| {\n        let mut x = u;\n        x.not_assign();\n        assert_eq!(x, !u);\n        x.not_assign();\n        assert_eq!(x, u);\n    });\n}\n\nfn not_assign_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|i| {\n        let mut x = i;\n        x.not_assign();\n        assert_eq!(x, !i);\n        x.not_assign();\n        assert_eq!(x, i);\n    });\n}\n\n#[test]\nfn not_assign_properties() {\n    apply_fn_to_unsigneds!(not_assign_properties_helper_unsigned);\n    apply_fn_to_signeds!(not_assign_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\n\nfn significant_bits_helper<T: PrimitiveInt>() {\n    let test = |n, out| {\n        assert_eq!(T::exact_from(n).significant_bits(), out);\n    };\n    test(0, 0);\n    test(1, 1);\n    test(2, 2);\n    test(3, 2);\n    test(4, 3);\n    test(5, 3);\n    test(100, 7);\n    test(63, 6);\n    test(64, 7);\n}\n\nfn significant_bits_helper_unsigned<T: PrimitiveUnsigned>() {\n    let test = |n: T, out: u64| {\n        assert_eq!(n.significant_bits(), out);\n    };\n    test(T::MAX, T::WIDTH);\n}\n\nfn significant_bits_helper_signed<T: PrimitiveSigned>() {\n    let test = |n: T, out: u64| {\n        assert_eq!(n.significant_bits(), out);\n    };\n    test(T::MAX, T::WIDTH - 1);\n    test(T::MIN, T::WIDTH);\n}\n\n#[test]\nfn test_significant_bits() {\n    apply_fn_to_primitive_ints!(significant_bits_helper);\n    apply_fn_to_unsigneds!(significant_bits_helper_unsigned);\n    apply_fn_to_signeds!(significant_bits_helper_signed);\n}\n\nfn significant_bits_properties_helper_unsigned<T: PrimitiveUnsigned>() {\n    unsigned_gen::<T>().test_properties(|u| {\n        let significant_bits = u.significant_bits();\n        assert!(significant_bits <= T::WIDTH);\n        assert_eq!(significant_bits == 0, u == T::ZERO);\n        if u != T::ZERO {\n            assert_eq!(significant_bits, u.floor_log_base_2() + 1);\n        }\n    });\n}\n\nfn significant_bits_properties_helper_signed<T: PrimitiveSigned>() {\n    signed_gen::<T>().test_properties(|i| {\n        let significant_bits = i.significant_bits();\n        assert!(significant_bits <= T::WIDTH);\n        assert_eq!(significant_bits == 0, i == T::ZERO);\n        assert_eq!(significant_bits == T::WIDTH, i == T::MIN);\n        assert_eq!(i.wrapping_neg().significant_bits(), significant_bits);\n    });\n}\n\n#[test]\nfn significant_bits_properties() {\n    apply_fn_to_unsigneds!(significant_bits_properties_helper_unsigned);\n    apply_fn_to_signeds!(significant_bits_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_natural_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_natural_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_natural_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    truncated_geometric_dist_assertions(\n        geometric_random_natural_signeds::<T>(EXAMPLE_SEED, um_numerator, um_denominator),\n        T::ZERO,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_natural_signeds() {\n    // i64, um = 1 / 64\n    let values = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];\n    let common_values = &[(0, 984537), (1, 15210), (2, 253)];\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.015624999999999944),\n        standard_deviation: NiceFloat(0.12597277731716458),\n        skewness: NiceFloat(8.186292482887549),\n        excess_kurtosis: NiceFloat(69.01538461538773),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.015716000000000004),\n        standard_deviation: NiceFloat(0.1263923388462427),\n        skewness: NiceFloat(8.160460378454996),\n        excess_kurtosis: NiceFloat(68.31033619043119),\n    };\n    geometric_random_natural_signeds_helper::<i64>(\n        1,\n        64,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 1\n    let values = &[1, 0, 0, 3, 4, 4, 1, 0, 0, 1, 0, 0, 2, 2, 0, 0, 1, 0, 3, 1];\n    let common_values = &[\n        (0, 500085),\n        (1, 249510),\n        (2, 125328),\n        (3, 62428),\n        (4, 31280),\n        (5, 15676),\n        (6, 7853),\n        (7, 3994),\n        (8, 1932),\n        (9, 942),\n    ];\n    let pop_median = (0, Some(1));\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.0),\n        standard_deviation: NiceFloat(std::f64::consts::SQRT_2),\n        skewness: NiceFloat(2.1213203435596424),\n        excess_kurtosis: NiceFloat(6.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0006159999999573),\n        standard_deviation: NiceFloat(1.414547850547892),\n        skewness: NiceFloat(2.1140569440125403),\n        excess_kurtosis: NiceFloat(6.4341815215340805),\n    };\n    geometric_random_natural_signeds_helper::<i64>(\n        1,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 12345/10000\n    let values = &[1, 3, 8, 2, 2, 0, 1, 1, 0, 0, 0, 0, 1, 1, 7, 0, 0, 3, 0, 0];\n    let common_values = &[\n        (0, 446911),\n        (1, 246858),\n        (2, 137217),\n        (3, 75488),\n        (4, 41605),\n        (5, 23149),\n        (6, 12981),\n        (7, 7024),\n        (8, 3848),\n        (9, 2206),\n    ];\n    let pop_median = (1, None);\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.2344999999999997),\n        standard_deviation: NiceFloat(1.6608703290744884),\n        skewness: NiceFloat(2.088663960860256),\n        excess_kurtosis: NiceFloat(6.362517141396456),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.2380129999999983),\n        standard_deviation: NiceFloat(1.6649767517832197),\n        skewness: NiceFloat(2.0942793135700466),\n        excess_kurtosis: NiceFloat(6.469904862333731),\n    };\n    geometric_random_natural_signeds_helper::<i64>(\n        12345,\n        10000,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 64\n    let values = &[53, 90, 125, 70, 18, 41, 109, 5, 96, 93, 33, 18, 89, 6, 17, 1, 1, 2, 123, 6];\n    let common_values = &[\n        (0, 17832),\n        (1, 17626),\n        (2, 17520),\n        (3, 16976),\n        (4, 16636),\n        (5, 16395),\n        (6, 16282),\n        (7, 16231),\n        (8, 15823),\n        (9, 15338),\n    ];\n    let pop_median = (36, None);\n    let sample_median = (36, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(43.60377071780361),\n        standard_deviation: NiceFloat(33.66417209656191),\n        skewness: NiceFloat(0.6750025251723596),\n        excess_kurtosis: NiceFloat(-0.5593715461161066),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(43.58636099999891),\n        standard_deviation: NiceFloat(33.66410490492275),\n        skewness: NiceFloat(0.6756300365723926),\n        excess_kurtosis: NiceFloat(-0.5577628868956519),\n    };\n    geometric_random_natural_signeds_helper::<i8>(\n        64,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 1000\n    let values =\n        &[24, 115, 120, 25, 104, 87, 80, 112, 37, 35, 68, 76, 40, 37, 117, 65, 124, 119, 0, 91];\n    let common_values = &[\n        (0, 8435),\n        (4, 8343),\n        (1, 8333),\n        (5, 8306),\n        (18, 8302),\n        (8, 8298),\n        (11, 8272),\n        (2, 8267),\n        (7, 8259),\n        (3, 8248),\n    ];\n    let pop_median = (61, None);\n    let sample_median = (61, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(62.13580429363961),\n        standard_deviation: NiceFloat(36.93417606567501),\n        skewness: NiceFloat(0.044319234592297266),\n        excess_kurtosis: NiceFloat(-1.197434568717292),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(62.1484240000004),\n        standard_deviation: NiceFloat(36.919219186555864),\n        skewness: NiceFloat(0.04244530182494719),\n        excess_kurtosis: NiceFloat(-1.196858045789015),\n    };\n    geometric_random_natural_signeds_helper::<i8>(\n        1000,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_natural_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(geometric_random_natural_signeds::<T>(EXAMPLE_SEED, 0, 1));\n    assert_panic!(geometric_random_natural_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(geometric_random_natural_signeds::<T>(\n        EXAMPLE_SEED,\n        u64::MAX,\n        u64::MAX - 1\n    ));\n}\n\n#[test]\nfn geometric_random_natural_signeds_fail() {\n    apply_fn_to_signeds!(geometric_random_natural_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_negative_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_negative_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, negative_truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_negative_signeds_helper<\n    U: CheckedToF64 + PrimitiveUnsigned,\n    S: CheckedToF64 + PrimitiveSigned + UnsignedAbs<Output = U> + WrappingFrom<U>,\n>(\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n    expected_values: &[S],\n    expected_common_values: &[(S, usize)],\n    expected_pop_median: (S, Option<S>),\n    expected_sample_median: (S, Option<S>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    negative_truncated_geometric_dist_assertions(\n        geometric_random_negative_signeds::<S>(EXAMPLE_SEED, abs_um_numerator, abs_um_denominator),\n        S::NEGATIVE_ONE,\n        S::MIN,\n        abs_um_numerator,\n        abs_um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_negative_signeds() {\n    // i64, um = -65 / 64\n    let values = &[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2];\n    let common_values = &[(-1, 984537), (-2, 15210), (-3, 253)];\n    let pop_median = (-1, None);\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-1.015625),\n        standard_deviation: NiceFloat(0.12597277731716458),\n        skewness: NiceFloat(-8.186292482887549),\n        excess_kurtosis: NiceFloat(69.01538461538773),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0157160000000027),\n        standard_deviation: NiceFloat(0.12639233884624257),\n        skewness: NiceFloat(-8.160460378454992),\n        excess_kurtosis: NiceFloat(68.31033619043166),\n    };\n    geometric_random_negative_signeds_helper::<_, i64>(\n        65,\n        64,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = -12345/10000\n    let values = &[-1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1];\n    let common_values = &[\n        (-1, 809395),\n        (-2, 154707),\n        (-3, 29037),\n        (-4, 5577),\n        (-5, 1053),\n        (-6, 185),\n        (-7, 40),\n        (-8, 5),\n        (-9, 1),\n    ];\n    let pop_median = (-1, None);\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-1.2345),\n        standard_deviation: NiceFloat(0.538042981554448),\n        skewness: NiceFloat(-2.730265146765687),\n        excess_kurtosis: NiceFloat(9.45434777164341),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.2349320000000084),\n        standard_deviation: NiceFloat(0.5376590410783139),\n        skewness: NiceFloat(-2.716807176148366),\n        excess_kurtosis: NiceFloat(9.308727522629948),\n    };\n    geometric_random_negative_signeds_helper::<_, i64>(\n        12345,\n        10000,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = -2\n    let values = &[-2, -1, -1, -4, -5, -5, -2, -1, -1, -2, -1, -1, -3, -3, -1, -1, -2, -1, -4, -2];\n    let common_values = &[\n        (-1, 500085),\n        (-2, 249510),\n        (-3, 125328),\n        (-4, 62428),\n        (-5, 31280),\n        (-6, 15676),\n        (-7, 7853),\n        (-8, 3994),\n        (-9, 1932),\n        (-10, 942),\n    ];\n    let pop_median = (-2, Some(-1));\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-2.0),\n        standard_deviation: NiceFloat(std::f64::consts::SQRT_2),\n        skewness: NiceFloat(-2.1213203435596424),\n        excess_kurtosis: NiceFloat(6.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.0006159999998947),\n        standard_deviation: NiceFloat(1.414547850547892),\n        skewness: NiceFloat(-2.114056944012543),\n        excess_kurtosis: NiceFloat(6.4341815215340645),\n    };\n    geometric_random_negative_signeds_helper::<_, i64>(\n        2,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = -64\n    let values = &[\n        -53, -56, -71, -20, -113, -87, -55, -44, -4, -17, -44, -36, -5, -25, -55, -9, -114, -24,\n        -15, -76,\n    ];\n    let common_values = &[\n        (-1, 18323),\n        (-2, 17814),\n        (-3, 17620),\n        (-4, 17269),\n        (-5, 17057),\n        (-6, 16684),\n        (-7, 16509),\n        (-8, 16164),\n        (-9, 15914),\n        (-10, 15665),\n    ];\n    let pop_median = (-37, None);\n    let sample_median = (-37, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-44.32782748571844),\n        standard_deviation: NiceFloat(33.57033730453578),\n        skewness: NiceFloat(-0.6852077716881376),\n        excess_kurtosis: NiceFloat(-0.5394700086619175),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-44.31098999999839),\n        standard_deviation: NiceFloat(33.572216166252275),\n        skewness: NiceFloat(-0.6830069791725721),\n        excess_kurtosis: NiceFloat(-0.5435066974705061),\n    };\n    geometric_random_negative_signeds_helper::<_, i8>(\n        64,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = -1000\n    let values = &[\n        -25, -111, -118, -26, -101, -88, -81, -112, -38, -36, -68, -76, -41, -36, -118, -66, -123,\n        -120, -128, -92,\n    ];\n    let common_values = &[\n        (-1, 8409),\n        (-6, 8360),\n        (-2, 8357),\n        (-7, 8328),\n        (-5, 8309),\n        (-14, 8300),\n        (-22, 8268),\n        (-12, 8262),\n        (-18, 8254),\n        (-9, 8249),\n    ];\n    let pop_median = (-62, None);\n    let sample_median = (-63, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-63.134440160748206),\n        standard_deviation: NiceFloat(36.934145822824206),\n        skewness: NiceFloat(-0.04436357375743275),\n        excess_kurtosis: NiceFloat(-1.1974286638022889),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-63.15733700000316),\n        standard_deviation: NiceFloat(36.91734106024568),\n        skewness: NiceFloat(-0.04254845146202895),\n        excess_kurtosis: NiceFloat(-1.1968222027376492),\n    };\n    geometric_random_negative_signeds_helper::<_, i8>(\n        1000,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_negative_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(geometric_random_negative_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(geometric_random_negative_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn geometric_random_negative_signeds_fail() {\n    apply_fn_to_signeds!(geometric_random_negative_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_nonzero_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_nonzero_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, double_nonzero_truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_nonzero_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_abs_mean: NiceFloat<f64>,\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    double_nonzero_truncated_geometric_dist_assertions(\n        geometric_random_nonzero_signeds::<T>(EXAMPLE_SEED, um_numerator, um_denominator),\n        T::MIN,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_abs_mean,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_nonzero_signeds() {\n    // i64, um = 65 / 64\n    let values = &[-1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1];\n    let common_values =\n        &[(1, 492630), (-1, 491792), (2, 7695), (-2, 7623), (-3, 130), (3, 128), (4, 1), (-4, 1)];\n    let abs_mean = NiceFloat(1.0158400000000025);\n    let pop_median = (-1, Some(1));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0),\n        standard_deviation: NiceFloat(1.0234076808633008),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.863403263403264),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0009760000000000123),\n        standard_deviation: NiceFloat(1.0237422016660624),\n        skewness: NiceFloat(-0.0015925396363277624),\n        excess_kurtosis: NiceFloat(-1.8611455716465144),\n    };\n    geometric_random_nonzero_signeds_helper::<i64>(\n        65,\n        64,\n        values,\n        common_values,\n        abs_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 12345/10000\n    let values = &[-3, -1, -1, 2, -1, 1, -1, -1, -1, 1, 3, 2, -2, -1, 1, -1, -2, -1, -1, -1];\n    let common_values = &[\n        (1, 405592),\n        (-1, 404788),\n        (2, 76970),\n        (-2, 76657),\n        (-3, 14659),\n        (3, 14550),\n        (-4, 2798),\n        (4, 2694),\n        (5, 525),\n        (-5, 504),\n    ];\n    let abs_mean = NiceFloat(1.2340139999999655);\n    let pop_median = (-1, Some(1));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0),\n        standard_deviation: NiceFloat(1.3466553011071538),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-0.5329853284885049),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0006879999999999908),\n        standard_deviation: NiceFloat(1.3459834093804237),\n        skewness: NiceFloat(-0.004555831860856982),\n        excess_kurtosis: NiceFloat(-0.5314899892072216),\n    };\n    geometric_random_nonzero_signeds_helper::<i64>(\n        12345,\n        10000,\n        values,\n        common_values,\n        abs_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 2\n    let values = &[-2, -2, -2, 2, -3, 2, -1, -1, -1, 1, 1, 1, -2, -1, 1, -2, -1, -1, -2, -1];\n    let common_values = &[\n        (1, 250123),\n        (-1, 250114),\n        (2, 125321),\n        (-2, 124779),\n        (3, 62655),\n        (-3, 62429),\n        (4, 31220),\n        (-4, 30972),\n        (-5, 15670),\n        (5, 15610),\n    ];\n    let abs_mean = NiceFloat(1.9985919999999855);\n    let pop_median = (-1, Some(1));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0),\n        standard_deviation: NiceFloat(2.449489742783178),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(1.166666666666667),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0027099999999999395),\n        standard_deviation: NiceFloat(2.4473305141166697),\n        skewness: NiceFloat(0.003736776778462254),\n        excess_kurtosis: NiceFloat(1.1584370930225818),\n    };\n    geometric_random_nonzero_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        abs_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 64\n    let values = &[\n        -3, -45, -90, 30, -33, -38, -25, 15, 40, -20, 42, -34, -74, -110, -15, 12, -76, -2, -6, -76,\n    ];\n    let common_values = &[\n        (1, 9067),\n        (-1, 9026),\n        (-2, 8948),\n        (2, 8915),\n        (-3, 8837),\n        (3, 8719),\n        (5, 8571),\n        (4, 8530),\n        (-4, 8430),\n        (6, 8385),\n    ];\n    let abs_mean = NiceFloat(44.16314300000121);\n    let pop_median = (-1, None);\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.15631902384873833),\n        standard_deviation: NiceFloat(55.4586923219402),\n        skewness: NiceFloat(-0.006558922726586753),\n        excess_kurtosis: NiceFloat(-0.4026097866721505),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.15813500000000466),\n        standard_deviation: NiceFloat(55.40978289585497),\n        skewness: NiceFloat(-0.008649136036163145),\n        excess_kurtosis: NiceFloat(-0.39765880957469824),\n    };\n    geometric_random_nonzero_signeds_helper::<i8>(\n        64,\n        1,\n        values,\n        common_values,\n        abs_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 1000\n    let values =\n        &[29, -58, 40, 58, 29, 21, -101, 50, 126, -3, 13, 22, 22, 69, 70, 62, -82, -67, 91, 87];\n    let common_values = &[\n        (3, 4314),\n        (-1, 4293),\n        (-4, 4243),\n        (2, 4240),\n        (10, 4233),\n        (-12, 4223),\n        (-26, 4220),\n        (7, 4203),\n        (-7, 4198),\n        (-19, 4196),\n    ];\n    let abs_mean = NiceFloat(62.86584099999888);\n    let pop_median = (-1, None);\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.4706257221678366),\n        standard_deviation: NiceFloat(72.86493046408025),\n        skewness: NiceFloat(-0.0005545932485799438),\n        excess_kurtosis: NiceFloat(-1.1684399210707623),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5576419999999735),\n        standard_deviation: NiceFloat(72.84782263187428),\n        skewness: NiceFloat(0.0014314361576379332),\n        excess_kurtosis: NiceFloat(-1.1671979175710692),\n    };\n    geometric_random_nonzero_signeds_helper::<i8>(\n        1000,\n        1,\n        values,\n        common_values,\n        abs_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_nonzero_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(geometric_random_nonzero_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(geometric_random_nonzero_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn geometric_random_nonzero_signeds_fail() {\n    apply_fn_to_signeds!(geometric_random_nonzero_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_positive_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_positive_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_positive_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    truncated_geometric_dist_assertions(\n        geometric_random_positive_signeds::<T>(EXAMPLE_SEED, um_numerator, um_denominator),\n        T::ONE,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_positive_signeds() {\n    // i64, um = 65 / 64\n    let values = &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2];\n    let common_values = &[(1, 984537), (2, 15210), (3, 253)];\n    let pop_median = (1, None);\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.015625),\n        standard_deviation: NiceFloat(0.12597277731716458),\n        skewness: NiceFloat(8.186292482887549),\n        excess_kurtosis: NiceFloat(69.01538461538773),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0157160000000027),\n        standard_deviation: NiceFloat(0.12639233884624257),\n        skewness: NiceFloat(8.160460378454992),\n        excess_kurtosis: NiceFloat(68.31033619043166),\n    };\n    geometric_random_positive_signeds_helper::<i64>(\n        65,\n        64,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 12345/10000\n    let values = &[1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1];\n    let common_values = &[\n        (1, 809395),\n        (2, 154707),\n        (3, 29037),\n        (4, 5577),\n        (5, 1053),\n        (6, 185),\n        (7, 40),\n        (8, 5),\n        (9, 1),\n    ];\n    let pop_median = (1, None);\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.2345),\n        standard_deviation: NiceFloat(0.538042981554448),\n        skewness: NiceFloat(2.730265146765687),\n        excess_kurtosis: NiceFloat(9.45434777164341),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.2349320000000084),\n        standard_deviation: NiceFloat(0.5376590410783139),\n        skewness: NiceFloat(2.716807176148366),\n        excess_kurtosis: NiceFloat(9.308727522629948),\n    };\n    geometric_random_positive_signeds_helper::<i64>(\n        12345,\n        10000,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 2\n    let values = &[2, 1, 1, 4, 5, 5, 2, 1, 1, 2, 1, 1, 3, 3, 1, 1, 2, 1, 4, 2];\n    let common_values = &[\n        (1, 500085),\n        (2, 249510),\n        (3, 125328),\n        (4, 62428),\n        (5, 31280),\n        (6, 15676),\n        (7, 7853),\n        (8, 3994),\n        (9, 1932),\n        (10, 942),\n    ];\n    let pop_median = (1, Some(2));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2.0),\n        standard_deviation: NiceFloat(std::f64::consts::SQRT_2),\n        skewness: NiceFloat(2.1213203435596424),\n        excess_kurtosis: NiceFloat(6.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0006159999998947),\n        standard_deviation: NiceFloat(1.414547850547892),\n        skewness: NiceFloat(2.114056944012543),\n        excess_kurtosis: NiceFloat(6.4341815215340645),\n    };\n    geometric_random_positive_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 64\n    let values = &[53, 56, 71, 20, 113, 87, 55, 44, 4, 17, 44, 36, 5, 25, 55, 9, 114, 24, 15, 76];\n    let common_values = &[\n        (1, 18322),\n        (2, 17831),\n        (3, 17675),\n        (4, 17346),\n        (5, 17077),\n        (6, 16664),\n        (7, 16584),\n        (8, 16201),\n        (9, 15917),\n        (10, 15785),\n    ];\n    let pop_median = (36, None);\n    let sample_median = (36, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(44.12320959250907),\n        standard_deviation: NiceFloat(33.35507189836844),\n        skewness: NiceFloat(0.6800692970056713),\n        excess_kurtosis: NiceFloat(-0.5495345339552125),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(44.11083399999909),\n        standard_deviation: NiceFloat(33.35932545284804),\n        skewness: NiceFloat(0.6778762972570164),\n        excess_kurtosis: NiceFloat(-0.5537033314075828),\n    };\n    geometric_random_positive_signeds_helper::<i8>(\n        64,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 1000\n    let values =\n        &[29, 119, 12, 28, 113, 91, 84, 117, 46, 36, 71, 83, 43, 50, 127, 69, 5, 124, 10, 95];\n    let common_values = &[\n        (3, 8464),\n        (11, 8429),\n        (9, 8411),\n        (26, 8407),\n        (6, 8397),\n        (12, 8387),\n        (2, 8383),\n        (8, 8363),\n        (1, 8326),\n        (14, 8313),\n    ];\n    let pop_median = (62, None);\n    let sample_median = (62, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(62.65568926722266),\n        standard_deviation: NiceFloat(36.64581386503865),\n        skewness: NiceFloat(0.04401709622102498),\n        excess_kurtosis: NiceFloat(-1.1974732777225838),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(62.68774500000057),\n        standard_deviation: NiceFloat(36.63525108357442),\n        skewness: NiceFloat(0.041814478066591894),\n        excess_kurtosis: NiceFloat(-1.1973932602500912),\n    };\n    geometric_random_positive_signeds_helper::<i8>(\n        1000,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_positive_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(geometric_random_positive_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(geometric_random_positive_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn geometric_random_positive_signeds_fail() {\n    apply_fn_to_signeds!(geometric_random_positive_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_positive_unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_positive_unsigneds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_positive_unsigneds_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    truncated_geometric_dist_assertions(\n        geometric_random_positive_unsigneds::<T>(EXAMPLE_SEED, um_numerator, um_denominator),\n        T::ONE,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_positive_unsigneds() {\n    // u64, um = 65 / 64\n    let values = &[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2];\n    let common_values = &[(1, 984537), (2, 15210), (3, 253)];\n    let pop_median = (1, None);\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.015625),\n        standard_deviation: NiceFloat(0.12597277731716458),\n        skewness: NiceFloat(8.186292482887549),\n        excess_kurtosis: NiceFloat(69.01538461538773),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0157160000000027),\n        standard_deviation: NiceFloat(0.12639233884624257),\n        skewness: NiceFloat(8.160460378454992),\n        excess_kurtosis: NiceFloat(68.31033619043166),\n    };\n    geometric_random_positive_unsigneds_helper::<u64>(\n        65,\n        64,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64, um = 12345/10000\n    let values = &[1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1];\n    let common_values = &[\n        (1, 809395),\n        (2, 154707),\n        (3, 29037),\n        (4, 5577),\n        (5, 1053),\n        (6, 185),\n        (7, 40),\n        (8, 5),\n        (9, 1),\n    ];\n    let pop_median = (1, None);\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.2345),\n        standard_deviation: NiceFloat(0.538042981554448),\n        skewness: NiceFloat(2.730265146765687),\n        excess_kurtosis: NiceFloat(9.45434777164341),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.2349320000000084),\n        standard_deviation: NiceFloat(0.5376590410783139),\n        skewness: NiceFloat(2.716807176148366),\n        excess_kurtosis: NiceFloat(9.308727522629948),\n    };\n    geometric_random_positive_unsigneds_helper::<u64>(\n        12345,\n        10000,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64, um = 2\n    let values = &[2, 1, 1, 4, 5, 5, 2, 1, 1, 2, 1, 1, 3, 3, 1, 1, 2, 1, 4, 2];\n    let common_values = &[\n        (1, 500085),\n        (2, 249510),\n        (3, 125328),\n        (4, 62428),\n        (5, 31280),\n        (6, 15676),\n        (7, 7853),\n        (8, 3994),\n        (9, 1932),\n        (10, 942),\n    ];\n    let pop_median = (1, Some(2));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2.0),\n        standard_deviation: NiceFloat(std::f64::consts::SQRT_2),\n        skewness: NiceFloat(2.1213203435596424),\n        excess_kurtosis: NiceFloat(6.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0006159999998947),\n        standard_deviation: NiceFloat(1.414547850547892),\n        skewness: NiceFloat(2.114056944012543),\n        excess_kurtosis: NiceFloat(6.4341815215340645),\n    };\n    geometric_random_positive_unsigneds_helper::<u64>(\n        2,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, um = 64\n    let values = &[53, 56, 71, 20, 113, 87, 55, 44, 4, 17, 44, 36, 5, 25, 55, 9, 114, 24, 15, 76];\n    let common_values = &[\n        (1, 16172),\n        (2, 15695),\n        (3, 15520),\n        (4, 15241),\n        (5, 15089),\n        (6, 14676),\n        (7, 14543),\n        (8, 14211),\n        (9, 13961),\n        (10, 13836),\n    ];\n    let pop_median = (43, None);\n    let sample_median = (43, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(59.318470051671945),\n        standard_deviation: NiceFloat(53.06875861106282),\n        skewness: NiceFloat(1.275790253790931),\n        excess_kurtosis: NiceFloat(1.21378930742857),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(59.312081000000006),\n        standard_deviation: NiceFloat(53.01872774251563),\n        skewness: NiceFloat(1.2706951236419683),\n        excess_kurtosis: NiceFloat(1.1982916278084028),\n    };\n    geometric_random_positive_unsigneds_helper::<u8>(\n        64,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, um = 1000\n    let values =\n        &[27, 115, 1, 27, 107, 217, 210, 242, 42, 36, 197, 207, 42, 43, 250, 195, 255, 122, 5, 221];\n    let common_values = &[\n        (6, 4501),\n        (2, 4490),\n        (8, 4461),\n        (21, 4453),\n        (10, 4449),\n        (3, 4446),\n        (11, 4440),\n        (13, 4422),\n        (12, 4415),\n        (25, 4407),\n    ];\n    let pop_median = (120, None);\n    let sample_median = (120, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(122.58449448192029),\n        standard_deviation: NiceFloat(73.49201840569208),\n        skewness: NiceFloat(0.08835569448221604),\n        excess_kurtosis: NiceFloat(-1.1892531716440173),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(122.63144799999775),\n        standard_deviation: NiceFloat(73.49633071884523),\n        skewness: NiceFloat(0.08793356388157667),\n        excess_kurtosis: NiceFloat(-1.1900100973541539),\n    };\n    geometric_random_positive_unsigneds_helper::<u8>(\n        1000,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_positive_unsigneds_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(geometric_random_positive_unsigneds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(geometric_random_positive_unsigneds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn geometric_random_positive_unsigneds_fail() {\n    apply_fn_to_unsigneds!(geometric_random_positive_unsigneds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_signed_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_signed_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, double_truncated_geometric_dist_assertions,\n    negative_truncated_geometric_dist_assertions, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_signed_inclusive_range_helper<\n    U: CheckedToF64 + PrimitiveUnsigned,\n    S: CheckedToF64\n        + PrimitiveSigned\n        + UnsignedAbs<Output = U>\n        + WrappingFrom<<S as UnsignedAbs>::Output>,\n>(\n    a: S,\n    b: S,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n    expected_values: &[S],\n    expected_common_values: &[(S, usize)],\n    expected_natural_mean: Option<NiceFloat<f64>>,\n    expected_pop_median: (S, Option<S>),\n    expected_sample_median: (S, Option<S>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = geometric_random_signed_inclusive_range::<S>(\n        EXAMPLE_SEED,\n        a,\n        b,\n        abs_um_numerator,\n        abs_um_denominator,\n    );\n    if a >= S::ZERO {\n        assert!(expected_natural_mean.is_none());\n        truncated_geometric_dist_assertions(\n            xs,\n            a,\n            b,\n            abs_um_numerator,\n            abs_um_denominator,\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats,\n        );\n    } else if b <= S::ONE {\n        assert!(expected_natural_mean.is_none());\n        negative_truncated_geometric_dist_assertions(\n            xs,\n            b,\n            a,\n            abs_um_numerator,\n            abs_um_denominator,\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats,\n        );\n    } else {\n        double_truncated_geometric_dist_assertions(\n            xs,\n            a,\n            b,\n            abs_um_numerator,\n            abs_um_denominator,\n            expected_values,\n            expected_common_values,\n            expected_natural_mean.unwrap(),\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats,\n        );\n    }\n}\n\n#[test]\nfn test_geometric_random_signed_inclusive_range() {\n    // i8, 5, 5, um = 10 (um is irrelevant here)\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    geometric_random_signed_inclusive_range_helper::<_, i8>(\n        5,\n        5,\n        10,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16, 1, 6, um = 3\n    let values = &[2, 5, 2, 3, 4, 2, 5, 6, 1, 2, 4, 3, 3, 2, 4, 2, 5, 1, 5, 4];\n    let common_values =\n        &[(1, 365286), (2, 243368), (3, 162008), (4, 108422), (5, 72522), (6, 48394)];\n    let pop_median = (2, None);\n    let sample_median = (2, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2.4225563909774435),\n        standard_deviation: NiceFloat(1.4838791137635392),\n        skewness: NiceFloat(0.8646161570662343),\n        excess_kurtosis: NiceFloat(-0.2650814667635877),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.4247080000000336),\n        standard_deviation: NiceFloat(1.4858025852532333),\n        skewness: NiceFloat(0.8627980859656847),\n        excess_kurtosis: NiceFloat(-0.27185507049284263),\n    };\n    geometric_random_signed_inclusive_range_helper::<_, i16>(\n        1,\n        6,\n        3,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32, 10, 19, um = 30\n    let values = &[18, 13, 12, 14, 11, 14, 16, 12, 12, 12, 11, 11, 12, 16, 10, 12, 13, 17, 19, 18];\n    let common_values = &[\n        (10, 123089),\n        (11, 117792),\n        (12, 111339),\n        (13, 106927),\n        (14, 102009),\n        (15, 96319),\n        (16, 92170),\n        (17, 86830),\n        (18, 83895),\n        (19, 79630),\n    ];\n    let pop_median = (14, None);\n    let sample_median = (14, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.099085006908673),\n        standard_deviation: NiceFloat(2.8551273967321666),\n        skewness: NiceFloat(0.17141556508548922),\n        excess_kurtosis: NiceFloat(-1.1843121480092598),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.099542000000508),\n        standard_deviation: NiceFloat(2.8550785526337443),\n        skewness: NiceFloat(0.17230969046968866),\n        excess_kurtosis: NiceFloat(-1.183362703825652),\n    };\n    geometric_random_signed_inclusive_range_helper::<_, i32>(\n        10,\n        19,\n        30,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, -20, -11, um = 30\n    let values = &[\n        -17, -14, -12, -14, -12, -15, -16, -13, -12, -13, -19, -11, -11, -17, -11, -19, -13, -16,\n        -20, -19,\n    ];\n    let common_values = &[\n        (-11, 124528),\n        (-12, 118758),\n        (-13, 112479),\n        (-14, 107215),\n        (-15, 101400),\n        (-16, 96120),\n        (-17, 91622),\n        (-18, 86347),\n        (-19, 82852),\n        (-20, 78679),\n    ];\n    let pop_median = (-15, None);\n    let sample_median = (-15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-15.078692813090253),\n        standard_deviation: NiceFloat(2.853334884793182),\n        skewness: NiceFloat(-0.18019334055480088),\n        excess_kurtosis: NiceFloat(-1.1801134249293568),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-15.076649000000186),\n        standard_deviation: NiceFloat(2.8539222266332365),\n        skewness: NiceFloat(-0.18245914264956217),\n        excess_kurtosis: NiceFloat(-1.1796684829530097),\n    };\n    geometric_random_signed_inclusive_range_helper::<_, i64>(\n        -20,\n        -11,\n        30,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, -100, 99, um = 30\n    let values =\n        &[-32, -31, -88, 52, -40, 64, -36, -1, -7, 46, 14, 48, -61, -60, 21, -55, -69, -26, -44, 6];\n    let common_values = &[\n        (0, 16949),\n        (-1, 16668),\n        (1, 16340),\n        (-2, 15893),\n        (2, 15885),\n        (-3, 15421),\n        (3, 15350),\n        (4, 14937),\n        (-4, 14913),\n        (5, 14576),\n    ];\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.06416536680865222),\n        standard_deviation: NiceFloat(35.06981580711165),\n        skewness: NiceFloat(-0.009387535787624381),\n        excess_kurtosis: NiceFloat(0.331207115680745),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.031523999999998706),\n        standard_deviation: NiceFloat(34.99870187802065),\n        skewness: NiceFloat(-0.009330685977635587),\n        excess_kurtosis: NiceFloat(0.33242667080464994),\n    };\n    geometric_random_signed_inclusive_range_helper::<_, i8>(\n        -100,\n        99,\n        30,\n        1,\n        values,\n        common_values,\n        Some(NiceFloat(26.065423999999997)),\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, i8::MIN, i8::MAX, um = 30\n    let values =\n        &[-32, -31, -88, 52, -40, 64, -36, -1, -7, 46, 14, 48, -61, -60, 21, -55, -69, -26, -44, 6];\n    let common_values = &[\n        (0, 16612),\n        (1, 16170),\n        (-1, 16142),\n        (2, 15527),\n        (-2, 15450),\n        (-3, 15004),\n        (3, 14998),\n        (4, 14694),\n        (-4, 14522),\n        (5, 14226),\n    ];\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.03203944371479178),\n        standard_deviation: NiceFloat(38.608914337623204),\n        skewness: NiceFloat(-0.006631455473213565),\n        excess_kurtosis: NiceFloat(0.885187645693085),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.006649000000000714),\n        standard_deviation: NiceFloat(38.52435386760686),\n        skewness: NiceFloat(-0.002824821494549616),\n        excess_kurtosis: NiceFloat(0.8938770112620578),\n    };\n    geometric_random_signed_inclusive_range_helper::<_, i8>(\n        i8::MIN,\n        i8::MAX,\n        30,\n        1,\n        values,\n        common_values,\n        Some(NiceFloat(28.03693899999907)),\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_signed_inclusive_range_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(geometric_random_signed_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::ONE,\n        1,\n        1\n    ));\n    assert_panic!(geometric_random_signed_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ZERO,\n        1,\n        1\n    ));\n    assert_panic!(geometric_random_signed_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        1,\n        0\n    ));\n    assert_panic!(geometric_random_signed_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::exact_from(10),\n        9,\n        10\n    ));\n    assert_panic!(geometric_random_signed_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::exact_from(-10),\n        T::NEGATIVE_ONE,\n        9,\n        10\n    ));\n    assert_panic!(geometric_random_signed_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        u64::MAX,\n        u64::MAX - 1\n    ));\n}\n\n#[test]\nfn geometric_random_signed_inclusive_range_fail() {\n    apply_fn_to_signeds!(geometric_random_signed_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_signed_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_signed_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, double_truncated_geometric_dist_assertions,\n    negative_truncated_geometric_dist_assertions, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_signed_range_helper<\n    U: CheckedToF64 + PrimitiveUnsigned,\n    S: CheckedToF64\n        + PrimitiveSigned\n        + UnsignedAbs<Output = U>\n        + WrappingFrom<<S as UnsignedAbs>::Output>,\n>(\n    a: S,\n    b: S,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n    expected_values: &[S],\n    expected_common_values: &[(S, usize)],\n    expected_natural_mean: Option<NiceFloat<f64>>,\n    expected_pop_median: (S, Option<S>),\n    expected_sample_median: (S, Option<S>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = geometric_random_signed_range::<S>(\n        EXAMPLE_SEED,\n        a,\n        b,\n        abs_um_numerator,\n        abs_um_denominator,\n    );\n    if a >= S::ZERO {\n        assert!(expected_natural_mean.is_none());\n        truncated_geometric_dist_assertions(\n            xs,\n            a,\n            b - S::ONE,\n            abs_um_numerator,\n            abs_um_denominator,\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats,\n        );\n    } else if b <= S::ONE {\n        assert!(expected_natural_mean.is_none());\n        negative_truncated_geometric_dist_assertions(\n            xs,\n            b - S::ONE,\n            a,\n            abs_um_numerator,\n            abs_um_denominator,\n            expected_values,\n            expected_common_values,\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats,\n        );\n    } else {\n        double_truncated_geometric_dist_assertions(\n            xs,\n            a,\n            b - S::ONE,\n            abs_um_numerator,\n            abs_um_denominator,\n            expected_values,\n            expected_common_values,\n            expected_natural_mean.unwrap(),\n            expected_pop_median,\n            expected_sample_median,\n            expected_pop_moment_stats,\n            expected_sample_moment_stats,\n        );\n    }\n}\n\n#[test]\nfn test_geometric_random_signed_range() {\n    // i8, 5, 6, um = 10 (um is irrelevant here)\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    geometric_random_signed_range_helper::<_, i8>(\n        5,\n        6,\n        10,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16, 1, 7, um = 3\n    let values = &[2, 5, 2, 3, 4, 2, 5, 6, 1, 2, 4, 3, 3, 2, 4, 2, 5, 1, 5, 4];\n    let common_values =\n        &[(1, 365286), (2, 243368), (3, 162008), (4, 108422), (5, 72522), (6, 48394)];\n    let pop_median = (2, None);\n    let sample_median = (2, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2.4225563909774435),\n        standard_deviation: NiceFloat(1.4838791137635392),\n        skewness: NiceFloat(0.8646161570662343),\n        excess_kurtosis: NiceFloat(-0.2650814667635877),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.4247080000000336),\n        standard_deviation: NiceFloat(1.4858025852532333),\n        skewness: NiceFloat(0.8627980859656847),\n        excess_kurtosis: NiceFloat(-0.27185507049284263),\n    };\n    geometric_random_signed_range_helper::<_, i16>(\n        1,\n        7,\n        3,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32, 10, 20, um = 30\n    let values = &[18, 13, 12, 14, 11, 14, 16, 12, 12, 12, 11, 11, 12, 16, 10, 12, 13, 17, 19, 18];\n    let common_values = &[\n        (10, 123089),\n        (11, 117792),\n        (12, 111339),\n        (13, 106927),\n        (14, 102009),\n        (15, 96319),\n        (16, 92170),\n        (17, 86830),\n        (18, 83895),\n        (19, 79630),\n    ];\n    let pop_median = (14, None);\n    let sample_median = (14, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.099085006908673),\n        standard_deviation: NiceFloat(2.8551273967321666),\n        skewness: NiceFloat(0.17141556508548922),\n        excess_kurtosis: NiceFloat(-1.1843121480092598),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.099542000000508),\n        standard_deviation: NiceFloat(2.8550785526337443),\n        skewness: NiceFloat(0.17230969046968866),\n        excess_kurtosis: NiceFloat(-1.183362703825652),\n    };\n    geometric_random_signed_range_helper::<_, i32>(\n        10,\n        20,\n        30,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, -20, -10, um = 30\n    let values = &[\n        -17, -14, -12, -14, -12, -15, -16, -13, -12, -13, -19, -11, -11, -17, -11, -19, -13, -16,\n        -20, -19,\n    ];\n    let common_values = &[\n        (-11, 124528),\n        (-12, 118758),\n        (-13, 112479),\n        (-14, 107215),\n        (-15, 101400),\n        (-16, 96120),\n        (-17, 91622),\n        (-18, 86347),\n        (-19, 82852),\n        (-20, 78679),\n    ];\n    let pop_median = (-15, None);\n    let sample_median = (-15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-15.078692813090253),\n        standard_deviation: NiceFloat(2.853334884793182),\n        skewness: NiceFloat(-0.18019334055480088),\n        excess_kurtosis: NiceFloat(-1.1801134249293568),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-15.076649000000186),\n        standard_deviation: NiceFloat(2.8539222266332365),\n        skewness: NiceFloat(-0.18245914264956217),\n        excess_kurtosis: NiceFloat(-1.1796684829530097),\n    };\n    geometric_random_signed_range_helper::<_, i64>(\n        -20,\n        -10,\n        30,\n        1,\n        values,\n        common_values,\n        None,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, -100, 100, um = 30\n    let values =\n        &[-32, -31, -88, 52, -40, 64, -36, -1, -7, 46, 14, 48, -61, -60, 21, -55, -69, -26, -44, 6];\n    let common_values = &[\n        (0, 16949),\n        (-1, 16668),\n        (1, 16340),\n        (-2, 15893),\n        (2, 15885),\n        (-3, 15421),\n        (3, 15350),\n        (4, 14937),\n        (-4, 14913),\n        (5, 14576),\n    ];\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.06416536680865222),\n        standard_deviation: NiceFloat(35.06981580711165),\n        skewness: NiceFloat(-0.009387535787624381),\n        excess_kurtosis: NiceFloat(0.331207115680745),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.031523999999998706),\n        standard_deviation: NiceFloat(34.99870187802065),\n        skewness: NiceFloat(-0.009330685977635587),\n        excess_kurtosis: NiceFloat(0.33242667080464994),\n    };\n    geometric_random_signed_range_helper::<_, i8>(\n        -100,\n        100,\n        30,\n        1,\n        values,\n        common_values,\n        Some(NiceFloat(26.065423999999997)),\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, i8::MIN, i8::MAX, um = 30\n    let values =\n        &[-32, -31, -88, 52, -40, 64, -36, -1, -7, 46, 14, 48, -61, -60, 21, -55, -69, -26, -44, 6];\n    let common_values = &[\n        (0, 16586),\n        (1, 16346),\n        (-1, 15948),\n        (2, 15598),\n        (-2, 15440),\n        (-3, 15044),\n        (3, 14965),\n        (-4, 14646),\n        (4, 14519),\n        (-5, 14228),\n    ];\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.06490500492128823),\n        standard_deviation: NiceFloat(38.55979597281242),\n        skewness: NiceFloat(-0.013352031588210264),\n        excess_kurtosis: NiceFloat(0.8755072180683543),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.025164000000001106),\n        standard_deviation: NiceFloat(38.48004061181062),\n        skewness: NiceFloat(-0.009040591966747374),\n        excess_kurtosis: NiceFloat(0.8847001181957856),\n    };\n    geometric_random_signed_range_helper::<_, i8>(\n        i8::MIN,\n        i8::MAX,\n        30,\n        1,\n        values,\n        common_values,\n        Some(NiceFloat(27.9829300000005)),\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_signed_range_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(geometric_random_signed_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ONE,\n        1,\n        1\n    ));\n    assert_panic!(geometric_random_signed_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ZERO,\n        1,\n        1\n    ));\n    assert_panic!(geometric_random_signed_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        1,\n        0\n    ));\n    assert_panic!(geometric_random_signed_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::exact_from(10),\n        9,\n        10\n    ));\n    assert_panic!(geometric_random_signed_range::<T>(\n        EXAMPLE_SEED,\n        T::exact_from(-10),\n        T::NEGATIVE_ONE,\n        9,\n        10\n    ));\n    assert_panic!(geometric_random_signed_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        u64::MAX,\n        u64::MAX - 1\n    ));\n}\n\n#[test]\nfn geometric_random_signed_range_fail() {\n    apply_fn_to_signeds!(geometric_random_signed_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, double_truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_natural_mean: NiceFloat<f64>,\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    double_truncated_geometric_dist_assertions(\n        geometric_random_signeds::<T>(EXAMPLE_SEED, um_numerator, um_denominator),\n        T::MIN,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_natural_mean,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_signeds() {\n    // i64, um = 1 / 64\n    let values = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n    let common_values =\n        &[(0, 969281), (-1, 15234), (1, 14983), (-2, 267), (2, 230), (3, 3), (-3, 2)];\n    let natural_mean = NiceFloat(0.01570299999999922);\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0),\n        standard_deviation: NiceFloat(0.17815241017173997),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(34.507692307692416),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0003219999999999915),\n        standard_deviation: NiceFloat(0.17958265107166738),\n        skewness: NiceFloat(-0.08440731496142939),\n        excess_kurtosis: NiceFloat(34.08776956313593),\n    };\n    geometric_random_signeds_helper::<i64>(\n        1,\n        64,\n        values,\n        common_values,\n        natural_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 12345/10000\n    let values = &[-1, -1, 0, -3, 1, 0, 0, -4, 0, -6, 1, 4, 0, 1, -2, 4, -3, -3, 1, -3];\n    let common_values = &[\n        (0, 288130),\n        (1, 159322),\n        (-1, 158541),\n        (-2, 88726),\n        (2, 88078),\n        (3, 48713),\n        (-3, 48584),\n        (-4, 26933),\n        (4, 26804),\n        (-5, 14960),\n    ];\n    let natural_mean = NiceFloat(1.233504000000006);\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0),\n        standard_deviation: NiceFloat(2.3488253447202068),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(3.181258570698229),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0021609999999999915),\n        standard_deviation: NiceFloat(2.3469592749549535),\n        skewness: NiceFloat(-0.007388197841520547),\n        excess_kurtosis: NiceFloat(3.1771115107088255),\n    };\n    geometric_random_signeds_helper::<i64>(\n        12345,\n        10000,\n        values,\n        common_values,\n        natural_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, um = 2\n    let values = &[-5, 0, 0, 1, -1, -1, -4, 2, 4, 6, -2, -2, 0, -1, -9, -13, 0, -2, 0, -7];\n    let common_values = &[\n        (0, 200052),\n        (-1, 133433),\n        (1, 133168),\n        (2, 89079),\n        (-2, 88845),\n        (3, 59306),\n        (-3, 59229),\n        (-4, 39537),\n        (4, 39457),\n        (-5, 26287),\n    ];\n    let natural_mean = NiceFloat(1.9983939999999663);\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.0),\n        standard_deviation: NiceFloat(3.4641016151377553),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(3.0833333333333304),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.004637999999999956),\n        standard_deviation: NiceFloat(3.462957476064434),\n        skewness: NiceFloat(-0.0014668264694796887),\n        excess_kurtosis: NiceFloat(3.1056798270038826),\n    };\n    geometric_random_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        natural_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 64\n    let values = &[\n        -58, -18, 80, -31, -85, -74, 114, 29, 46, -28, -5, -54, -73, -67, 96, 74, -67, -20, 93, -95,\n    ];\n    let common_values = &[\n        (0, 8916),\n        (1, 8897),\n        (-1, 8830),\n        (3, 8811),\n        (-2, 8800),\n        (2, 8757),\n        (-4, 8491),\n        (4, 8459),\n        (-3, 8413),\n        (-5, 8336),\n    ];\n    let natural_mean = NiceFloat(43.609158999998506);\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.15811030451314936),\n        standard_deviation: NiceFloat(55.48244935032745),\n        skewness: NiceFloat(-0.006618243685084806),\n        excess_kurtosis: NiceFloat(-0.3947891766587368),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.09556800000000087),\n        standard_deviation: NiceFloat(55.48675459546383),\n        skewness: NiceFloat(-0.007283472641276268),\n        excess_kurtosis: NiceFloat(-0.3961004797032963),\n    };\n    geometric_random_signeds_helper::<i8>(\n        64,\n        1,\n        values,\n        common_values,\n        natural_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, um = 1000\n    let values =\n        &[25, -53, 39, 32, 26, 13, -94, 45, 125, 119, 11, 15, 66, 68, 60, -71, -54, 83, 76, -33];\n    let common_values = &[\n        (-2, 4277),\n        (1, 4263),\n        (9, 4217),\n        (-1, 4213),\n        (5, 4207),\n        (-4, 4207),\n        (0, 4206),\n        (-6, 4200),\n        (19, 4199),\n        (8, 4179),\n    ];\n    let natural_mean = NiceFloat(62.13860000000173);\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.4686977489785049),\n        standard_deviation: NiceFloat(72.71434769926142),\n        skewness: NiceFloat(-0.0006359350720949359),\n        excess_kurtosis: NiceFloat(-1.1608263148064384),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.446604999999992),\n        standard_deviation: NiceFloat(72.6977982881445),\n        skewness: NiceFloat(-0.0006088230606281416),\n        excess_kurtosis: NiceFloat(-1.1593850084998423),\n    };\n    geometric_random_signeds_helper::<i8>(\n        1000,\n        1,\n        values,\n        common_values,\n        natural_mean,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(geometric_random_signeds::<T>(EXAMPLE_SEED, 0, 1));\n    assert_panic!(geometric_random_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(geometric_random_signeds::<T>(\n        EXAMPLE_SEED,\n        u64::MAX,\n        u64::MAX - 1\n    ));\n}\n\n#[test]\nfn geometric_random_signeds_fail() {\n    apply_fn_to_signeds!(geometric_random_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_unsigned_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_unsigned_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_unsigned_inclusive_range_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    a: T,\n    b: T,\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    truncated_geometric_dist_assertions(\n        geometric_random_unsigned_inclusive_range::<T>(\n            EXAMPLE_SEED,\n            a,\n            b,\n            um_numerator,\n            um_denominator,\n        ),\n        a,\n        b,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_unsigned_inclusive_range() {\n    // u8, 5, 5, um = 10 (um is irrelevant here)\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    geometric_random_unsigned_inclusive_range_helper::<u8>(\n        5,\n        5,\n        10,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16, 1, 6, um = 3\n    let values = &[2, 5, 2, 3, 4, 2, 5, 6, 1, 2, 4, 3, 3, 2, 4, 2, 5, 1, 5, 4];\n    let common_values =\n        &[(1, 365286), (2, 243368), (3, 162008), (4, 108422), (5, 72522), (6, 48394)];\n    let pop_median = (2, None);\n    let sample_median = (2, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2.4225563909774435),\n        standard_deviation: NiceFloat(1.4838791137635392),\n        skewness: NiceFloat(0.8646161570662343),\n        excess_kurtosis: NiceFloat(-0.2650814667635877),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.4247080000000336),\n        standard_deviation: NiceFloat(1.4858025852532333),\n        skewness: NiceFloat(0.8627980859656847),\n        excess_kurtosis: NiceFloat(-0.27185507049284263),\n    };\n    geometric_random_unsigned_inclusive_range_helper::<u16>(\n        1,\n        6,\n        3,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32, 10, 19, um = 30\n    let values = &[18, 13, 12, 14, 11, 14, 16, 12, 12, 12, 11, 11, 12, 16, 10, 12, 13, 17, 19, 18];\n    let common_values = &[\n        (10, 123089),\n        (11, 117792),\n        (12, 111339),\n        (13, 106927),\n        (14, 102009),\n        (15, 96319),\n        (16, 92170),\n        (17, 86830),\n        (18, 83895),\n        (19, 79630),\n    ];\n    let pop_median = (14, None);\n    let sample_median = (14, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.099085006908673),\n        standard_deviation: NiceFloat(2.8551273967321666),\n        skewness: NiceFloat(0.17141556508548922),\n        excess_kurtosis: NiceFloat(-1.1843121480092598),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.099542000000508),\n        standard_deviation: NiceFloat(2.8550785526337443),\n        skewness: NiceFloat(0.17230969046968866),\n        excess_kurtosis: NiceFloat(-1.183362703825652),\n    };\n    geometric_random_unsigned_inclusive_range_helper::<u32>(\n        10,\n        19,\n        30,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, 0, u8::MAX, um = 1\n    let values = &[1, 0, 0, 3, 4, 4, 1, 0, 0, 1, 0, 0, 2, 2, 0, 0, 1, 0, 3, 1];\n    let common_values = &[\n        (0, 500085),\n        (1, 249510),\n        (2, 125328),\n        (3, 62428),\n        (4, 31280),\n        (5, 15676),\n        (6, 7853),\n        (7, 3994),\n        (8, 1932),\n        (9, 942),\n    ];\n    let pop_median = (0, Some(1));\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.0),\n        standard_deviation: NiceFloat(std::f64::consts::SQRT_2),\n        skewness: NiceFloat(2.1213203435596424),\n        excess_kurtosis: NiceFloat(6.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0006159999999573),\n        standard_deviation: NiceFloat(1.414547850547892),\n        skewness: NiceFloat(2.1140569440125403),\n        excess_kurtosis: NiceFloat(6.4341815215340805),\n    };\n    geometric_random_unsigned_inclusive_range_helper::<u8>(\n        0,\n        u8::MAX,\n        1,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_unsigned_inclusive_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(geometric_random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::ONE,\n        1,\n        1\n    ));\n    assert_panic!(geometric_random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        1,\n        0\n    ));\n    assert_panic!(geometric_random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::exact_from(10),\n        9,\n        10\n    ));\n    assert_panic!(geometric_random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        u64::MAX,\n        u64::MAX - 1\n    ));\n}\n\n#[test]\nfn geometric_random_unsigned_inclusive_range_fail() {\n    apply_fn_to_unsigneds!(geometric_random_unsigned_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_unsigned_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_unsigned_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_unsigned_range_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    a: T,\n    b: T,\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    truncated_geometric_dist_assertions(\n        geometric_random_unsigned_range::<T>(EXAMPLE_SEED, a, b, um_numerator, um_denominator),\n        a,\n        b - T::ONE,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_unsigned_range() {\n    // u8, 5, 6, um = 10 (um is irrelevant here)\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    geometric_random_unsigned_range_helper::<u8>(\n        5,\n        6,\n        10,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16, 1, 7, um = 3\n    let values = &[2, 5, 2, 3, 4, 2, 5, 6, 1, 2, 4, 3, 3, 2, 4, 2, 5, 1, 5, 4];\n    let common_values =\n        &[(1, 365286), (2, 243368), (3, 162008), (4, 108422), (5, 72522), (6, 48394)];\n    let pop_median = (2, None);\n    let sample_median = (2, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2.4225563909774435),\n        standard_deviation: NiceFloat(1.4838791137635392),\n        skewness: NiceFloat(0.8646161570662343),\n        excess_kurtosis: NiceFloat(-0.2650814667635877),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.4247080000000336),\n        standard_deviation: NiceFloat(1.4858025852532333),\n        skewness: NiceFloat(0.8627980859656847),\n        excess_kurtosis: NiceFloat(-0.27185507049284263),\n    };\n    geometric_random_unsigned_range_helper::<u16>(\n        1,\n        7,\n        3,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32, 10, 20, um = 30\n    let values = &[18, 13, 12, 14, 11, 14, 16, 12, 12, 12, 11, 11, 12, 16, 10, 12, 13, 17, 19, 18];\n    let common_values = &[\n        (10, 123089),\n        (11, 117792),\n        (12, 111339),\n        (13, 106927),\n        (14, 102009),\n        (15, 96319),\n        (16, 92170),\n        (17, 86830),\n        (18, 83895),\n        (19, 79630),\n    ];\n    let pop_median = (14, None);\n    let sample_median = (14, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.099085006908673),\n        standard_deviation: NiceFloat(2.8551273967321666),\n        skewness: NiceFloat(0.17141556508548922),\n        excess_kurtosis: NiceFloat(-1.1843121480092598),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.099542000000508),\n        standard_deviation: NiceFloat(2.8550785526337443),\n        skewness: NiceFloat(0.17230969046968866),\n        excess_kurtosis: NiceFloat(-1.183362703825652),\n    };\n    geometric_random_unsigned_range_helper::<u32>(\n        10,\n        20,\n        30,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, 0, u8::MAX, um = 1\n    let values = &[1, 0, 0, 3, 4, 4, 1, 0, 0, 1, 0, 0, 2, 2, 0, 0, 1, 0, 3, 1];\n    let common_values = &[\n        (0, 500085),\n        (1, 249510),\n        (2, 125328),\n        (3, 62428),\n        (4, 31280),\n        (5, 15676),\n        (6, 7853),\n        (7, 3994),\n        (8, 1932),\n        (9, 942),\n    ];\n    let pop_median = (0, Some(1));\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.0),\n        standard_deviation: NiceFloat(std::f64::consts::SQRT_2),\n        skewness: NiceFloat(2.1213203435596424),\n        excess_kurtosis: NiceFloat(6.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0006159999999573),\n        standard_deviation: NiceFloat(1.414547850547892),\n        skewness: NiceFloat(2.1140569440125403),\n        excess_kurtosis: NiceFloat(6.4341815215340805),\n    };\n    geometric_random_unsigned_range_helper::<u8>(\n        0,\n        u8::MAX,\n        1,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_unsigned_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(geometric_random_unsigned_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ONE,\n        1,\n        1\n    ));\n    assert_panic!(geometric_random_unsigned_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ZERO,\n        1,\n        1\n    ));\n    assert_panic!(geometric_random_unsigned_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        1,\n        0\n    ));\n    assert_panic!(geometric_random_unsigned_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::exact_from(10),\n        9,\n        10\n    ));\n    assert_panic!(geometric_random_unsigned_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::exact_from(10),\n        u64::MAX,\n        u64::MAX - 1\n    ));\n}\n\n#[test]\nfn geometric_random_unsigned_range_fail() {\n    apply_fn_to_unsigneds!(geometric_random_unsigned_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/geometric_random_unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, truncated_geometric_dist_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn geometric_random_unsigneds_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    um_numerator: u64,\n    um_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    truncated_geometric_dist_assertions(\n        geometric_random_unsigneds::<T>(EXAMPLE_SEED, um_numerator, um_denominator),\n        T::ZERO,\n        T::MAX,\n        um_numerator,\n        um_denominator,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_geometric_random_unsigneds() {\n    // u64, um = 1 / 64\n    let values = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];\n    let common_values = &[(0, 984537), (1, 15210), (2, 253)];\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.015624999999999944),\n        standard_deviation: NiceFloat(0.12597277731716458),\n        skewness: NiceFloat(8.186292482887549),\n        excess_kurtosis: NiceFloat(69.01538461538773),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.015716000000000004),\n        standard_deviation: NiceFloat(0.1263923388462427),\n        skewness: NiceFloat(8.160460378454996),\n        excess_kurtosis: NiceFloat(68.31033619043119),\n    };\n    geometric_random_unsigneds_helper::<u64>(\n        1,\n        64,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64, um = 1\n    let values = &[1, 0, 0, 3, 4, 4, 1, 0, 0, 1, 0, 0, 2, 2, 0, 0, 1, 0, 3, 1];\n    let common_values = &[\n        (0, 500085),\n        (1, 249510),\n        (2, 125328),\n        (3, 62428),\n        (4, 31280),\n        (5, 15676),\n        (6, 7853),\n        (7, 3994),\n        (8, 1932),\n        (9, 942),\n    ];\n    let pop_median = (0, Some(1));\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.0),\n        standard_deviation: NiceFloat(std::f64::consts::SQRT_2),\n        skewness: NiceFloat(2.1213203435596424),\n        excess_kurtosis: NiceFloat(6.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0006159999999573),\n        standard_deviation: NiceFloat(1.414547850547892),\n        skewness: NiceFloat(2.1140569440125403),\n        excess_kurtosis: NiceFloat(6.4341815215340805),\n    };\n    geometric_random_unsigneds_helper::<u64>(\n        1,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64, um = 12345/10000\n    let values = &[1, 3, 8, 2, 2, 0, 1, 1, 0, 0, 0, 0, 1, 1, 7, 0, 0, 3, 0, 0];\n    let common_values = &[\n        (0, 446911),\n        (1, 246858),\n        (2, 137217),\n        (3, 75488),\n        (4, 41605),\n        (5, 23149),\n        (6, 12981),\n        (7, 7024),\n        (8, 3848),\n        (9, 2206),\n    ];\n    let pop_median = (1, None);\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.2344999999999997),\n        standard_deviation: NiceFloat(1.6608703290744884),\n        skewness: NiceFloat(2.088663960860256),\n        excess_kurtosis: NiceFloat(6.362517141396456),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.2380129999999983),\n        standard_deviation: NiceFloat(1.6649767517832197),\n        skewness: NiceFloat(2.0942793135700466),\n        excess_kurtosis: NiceFloat(6.469904862333731),\n    };\n    geometric_random_unsigneds_helper::<u64>(\n        12345,\n        10000,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, um = 64\n    let values =\n        &[181, 90, 125, 70, 146, 41, 109, 5, 224, 93, 33, 18, 89, 6, 17, 1, 129, 2, 123, 134];\n    let common_values = &[\n        (0, 15734),\n        (1, 15591),\n        (2, 15469),\n        (3, 14917),\n        (4, 14672),\n        (5, 14340),\n        (6, 14329),\n        (7, 14274),\n        (8, 13841),\n        (9, 13586),\n    ];\n    let pop_median = (43, None);\n    let sample_median = (43, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(59.070796734994865),\n        standard_deviation: NiceFloat(53.608086324088696),\n        skewness: NiceFloat(1.2637908431790819),\n        excess_kurtosis: NiceFloat(1.1650093560615717),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(59.03148100000193),\n        standard_deviation: NiceFloat(53.60145056863821),\n        skewness: NiceFloat(1.2649824077121026),\n        excess_kurtosis: NiceFloat(1.1705093182268955),\n    };\n    geometric_random_unsigneds_helper::<u8>(\n        64,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, um = 1000\n    let values = &[\n        24, 115, 248, 25, 104, 215, 208, 240, 37, 35, 196, 204, 40, 37, 245, 193, 252, 119, 0, 219,\n    ];\n    let common_values = &[\n        (18, 4482),\n        (11, 4469),\n        (6, 4431),\n        (25, 4426),\n        (0, 4424),\n        (3, 4415),\n        (5, 4400),\n        (8, 4400),\n        (20, 4396),\n        (10, 4386),\n    ];\n    let pop_median = (119, None);\n    let sample_median = (119, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(122.04742583121647),\n        standard_deviation: NiceFloat(73.7795264500733),\n        skewness: NiceFloat(0.08861336552406392),\n        excess_kurtosis: NiceFloat(-1.1891899016227028),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(122.12244000000315),\n        standard_deviation: NiceFloat(73.78371977939058),\n        skewness: NiceFloat(0.08799741904573245),\n        excess_kurtosis: NiceFloat(-1.1900813344800518),\n    };\n    geometric_random_unsigneds_helper::<u8>(\n        1000,\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn geometric_random_unsigneds_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(geometric_random_unsigneds::<T>(EXAMPLE_SEED, 0, 1));\n    assert_panic!(geometric_random_unsigneds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(geometric_random_unsigneds::<T>(\n        EXAMPLE_SEED,\n        u64::MAX,\n        u64::MAX - 1\n    ));\n}\n\n#[test]\nfn geometric_random_unsigneds_fail() {\n    apply_fn_to_unsigneds!(geometric_random_unsigneds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/get_geometric_random_signed_from_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::num::random::geometric::get_geometric_random_signed_from_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\n\nfn get_geometric_random_signed_from_inclusive_range_helper(\n    a: i32,\n    b: i32,\n    abs_um_numerator: u64,\n    abs_um_denominator: u64,\n    out: i32,\n) {\n    assert_eq!(\n        get_geometric_random_signed_from_inclusive_range(\n            &mut VariableRangeGenerator::new(EXAMPLE_SEED),\n            a,\n            b,\n            abs_um_numerator,\n            abs_um_denominator\n        ),\n        out\n    );\n}\n\n#[test]\nfn test_get_geometric_random_signed_from_inclusive_range() {\n    get_geometric_random_signed_from_inclusive_range_helper(0, 0, 2, 1, 0);\n    get_geometric_random_signed_from_inclusive_range_helper(0, 1, 2, 1, 1);\n    get_geometric_random_signed_from_inclusive_range_helper(0, 10, 2, 1, 1);\n    get_geometric_random_signed_from_inclusive_range_helper(0, 10, 10, 1, 2);\n    get_geometric_random_signed_from_inclusive_range_helper(-10, 10, 2, 1, -3);\n    get_geometric_random_signed_from_inclusive_range_helper(-10, 10, 10, 1, 8);\n    get_geometric_random_signed_from_inclusive_range_helper(100, 110, 101, 1, 101);\n    get_geometric_random_signed_from_inclusive_range_helper(100, 110, 500, 1, 109);\n    get_geometric_random_signed_from_inclusive_range_helper(-110, -100, 101, 1, -101);\n    get_geometric_random_signed_from_inclusive_range_helper(-110, -100, 500, 1, -109);\n}\n\n#[test]\n#[should_panic]\nfn get_geometric_random_signed_from_inclusive_range_fail_1() {\n    get_geometric_random_signed_from_inclusive_range(\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED),\n        1,\n        0,\n        1,\n        2,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_geometric_random_signed_from_inclusive_range_fail_2() {\n    get_geometric_random_signed_from_inclusive_range(\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED),\n        1,\n        2,\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_geometric_random_signed_from_inclusive_range_fail_3() {\n    get_geometric_random_signed_from_inclusive_range(\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED),\n        1,\n        2,\n        0,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_geometric_random_signed_from_inclusive_range_fail_4() {\n    get_geometric_random_signed_from_inclusive_range(\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED),\n        1,\n        2,\n        1,\n        2,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/geometric/mean.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::num::random::geometric::{\n    adjusted_mean_to_unadjusted_mean, unadjusted_mean_to_adjusted_mean,\n};\n\n#[test]\npub fn test_unadjusted_mean_to_adjusted_mean() {\n    let test = |unadjusted_mean, limit, adjusted_mean| {\n        assert_eq!(\n            NiceFloat(unadjusted_mean_to_adjusted_mean(unadjusted_mean, limit)),\n            NiceFloat(adjusted_mean)\n        );\n    };\n    test(1.0e-45, 255.0, 0.0);\n    test(0.001, 255.0, 0.000999999999999855);\n    test(1.0, 255.0, 1.0);\n    test(10.0, 255.0, 9.999999993517946);\n    test(50.0, 255.0, 48.38067332601502);\n    test(100.0, 255.0, 78.25417704300385);\n    test(255.0, 255.0, 106.4745261876895);\n    test(1000000.0, 255.0, 127.49458799160993);\n\n    test(1.0000000000000002, 255.0, 1.0);\n    test(10.000000006482054, 255.0, 10.000000000000002);\n    test(51.95952531604177, 255.0, 50.0);\n    test(192.50163549359422, 255.0, 100.00000000000001);\n    test(10921.900023504326, 255.0, 127.0000000000199);\n    test(546163.2639224805, 255.0, 127.49000008135106);\n}\n\n#[test]\npub fn test_adjusted_mean_to_unadjusted_mean() {\n    let test = |adjusted_mean, limit, unadjusted_mean| {\n        assert_eq!(\n            NiceFloat(adjusted_mean_to_unadjusted_mean(adjusted_mean, limit)),\n            NiceFloat(unadjusted_mean)\n        );\n    };\n    test(1.0, 255.0, 1.0000000000000002);\n    test(10.0, 255.0, 10.000000006482054);\n    test(50.0, 255.0, 51.95952531604177);\n    test(100.0, 255.0, 192.50163549359422);\n    test(127.0, 255.0, 10921.900023504326);\n    test(127.49, 255.0, 546163.2639224805);\n\n    test(0.000999999999999855, 255.0, 0.0009999999999998803);\n    test(1.0, 255.0, 1.0000000000000002);\n    test(9.999999993517946, 255.0, 10.0);\n    test(48.38067332601502, 255.0, 50.0);\n    test(78.25417704300385, 255.0, 100.0);\n    test(106.4745261876895, 255.0, 255.0);\n    test(127.49458799160993, 255.0, 1006078.1813340919);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_finite_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_finite_primitive_floats() {\n    // f32\n    let values = &[\n        -2.3484663e-27,\n        2.287989e-18,\n        -2.0729893e-12,\n        3.360012e28,\n        -9.021723e-32,\n        3564911.2,\n        -0.0000133769445,\n        -1.8855448e18,\n        8.2494555e-29,\n        2.2178014e-38,\n        -6.3067724e-34,\n        5.1996016e31,\n        7.613263e33,\n        0.00015323666,\n        9.476819e36,\n        -0.0005665586,\n        8.8733265e-30,\n        0.09273135,\n        -7.7748304e33,\n        4.3156234e-8,\n    ];\n    let common_values = &[\n        (-66476.9, 2),\n        (34.61204, 2),\n        (73439.86, 2),\n        (780.0361, 2),\n        (-66297.14, 2),\n        (0.2084277, 2),\n        (13200.072, 2),\n        (224535.31, 2),\n        (3306.3638, 2),\n        (5.7126203, 2),\n    ];\n    let sample_median = (4.601795e-39, Some(4.606578e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.871800306879315e34),\n        standard_deviation: NiceFloat(1.8597574252028948e37),\n        skewness: NiceFloat(-0.04588142291892213),\n        excess_kurtosis: NiceFloat(174.30920632007357),\n    };\n    random_finite_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        3.1062066405583414e-146,\n        7.268713316268922e223,\n        1.1685126708702853e48,\n        -1.0824685183946233e146,\n        3.1146051606615834e-306,\n        2.2453015573637678e249,\n        1.2548860979388688e-35,\n        -8.287939157477945e-27,\n        2.1255041535787168e-13,\n        4.815129234795049e-64,\n        1.3850402674408149e-17,\n        -1.2535717707589619e207,\n        -1.4941028004491903e142,\n        4.3666119614549075e-51,\n        -7.063699168119983e17,\n        -7.062565582436956e90,\n        1.1662950933663384e-221,\n        2.1976577668343595e-97,\n        -2.821294426687019e-137,\n        1.225091633874841e-222,\n    ];\n    let common_values = &[\n        (3.637321705391, 1),\n        (30.80883877248, 1),\n        (915366460504.2, 1),\n        (9256888.416622, 1),\n        (-737164661.2491, 1),\n        (-81413.95043198, 1),\n        (-994938.9166069, 1),\n        (1.4299272196643, 1),\n        (12812252.479435, 1),\n        (1598038.5592174, 1),\n    ];\n    let sample_median = (2.7723065921722726e-308, Some(2.782073119497922e-308));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.922018643581054e303),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_finite_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_highest_bit_set_unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_highest_bit_set_unsigneds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\n\nfn random_highest_bit_set_unsigneds_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_highest_bit_set_unsigneds(EXAMPLE_SEED),\n        T::power_of_2(T::WIDTH - 1),\n        T::MAX,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_highest_bit_set_unsigneds() {\n    // u8\n    let values = &[\n        241, 222, 151, 226, 198, 220, 180, 212, 161, 175, 129, 241, 182, 138, 175, 145, 217, 220,\n        247, 194,\n    ];\n    let common_values = &[\n        (130, 8077),\n        (249, 8039),\n        (176, 8015),\n        (241, 7966),\n        (136, 7937),\n        (205, 7933),\n        (178, 7928),\n        (219, 7927),\n        (210, 7925),\n        (230, 7924),\n    ];\n    let pop_median = (191, Some(192));\n    let sample_median = (191, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(191.5),\n        standard_deviation: NiceFloat(36.94928957368463),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2001464933162425),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(191.47808899999873),\n        standard_deviation: NiceFloat(36.961138429895456),\n        skewness: NiceFloat(-0.00045403607545687984),\n        excess_kurtosis: NiceFloat(-1.1998683031732567),\n    };\n    random_highest_bit_set_unsigneds_helper::<u8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16\n    let values = &[\n        61297, 55435, 52113, 36166, 34170, 60868, 44820, 44177, 56814, 43920, 62926, 52397, 56477,\n        62030, 53767, 54475, 41390, 52238, 49476, 64068,\n    ];\n    let common_values = &[\n        (45680, 55),\n        (43149, 54),\n        (51767, 54),\n        (41030, 53),\n        (49628, 52),\n        (51621, 52),\n        (59748, 52),\n        (62186, 52),\n        (34198, 51),\n        (36279, 51),\n    ];\n    let pop_median = (49151, Some(49152));\n    let sample_median = (49162, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(49151.5),\n        standard_deviation: NiceFloat(9459.306805997996),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000000022351742),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(49155.96401899928),\n        standard_deviation: NiceFloat(9454.356832489304),\n        skewness: NiceFloat(-0.0012474540243074795),\n        excess_kurtosis: NiceFloat(-1.1990519661334587),\n    };\n    random_highest_bit_set_unsigneds_helper::<u16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32\n    let values = &[\n        3964006257, 3276907976, 3451421022, 4073264610, 3109848542, 3140663214, 2279906674,\n        3612658596, 3508930337, 3808334112, 3115296257, 2693817273, 3135713082, 2512715495,\n        2304388648, 3178397234, 4176627051, 3554614631, 3618567415, 3594534402,\n    ];\n    let common_values = &[\n        (2148512502, 2),\n        (2152753653, 2),\n        (2199919756, 2),\n        (2200926180, 2),\n        (2201533159, 2),\n        (2203162873, 2),\n        (2204334486, 2),\n        (2243577040, 2),\n        (2248172201, 2),\n        (2250885871, 2),\n    ];\n    let pop_median = (3221225471, Some(3221225472));\n    let sample_median = (3220111243, Some(3220113439));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(3221225471.5),\n        standard_deviation: NiceFloat(619925131.1265597),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3220061212.7312818),\n        standard_deviation: NiceFloat(620056431.3063867),\n        skewness: NiceFloat(0.0014601286400032912),\n        excess_kurtosis: NiceFloat(-1.1999609793276904),\n    };\n    random_highest_bit_set_unsigneds_helper::<u32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64\n    let values = &[\n        11648792314704686961,\n        15902849618696487087,\n        12062424265687245175,\n        10193137694460908462,\n        9734517988917403762,\n        17618716774223412528,\n        12117930945561730236,\n        13095749177794802780,\n        13684732338925793861,\n        17489043124220843898,\n        18428543530713567946,\n        9663508144831389154,\n        14291728674867306832,\n        14157636121372894287,\n        11041743053466742106,\n        11652479517924728358,\n        15926995443195260196,\n        10797926927713903617,\n        9340643919610687288,\n        13527331835876139736,\n    ];\n    let common_values = &[\n        (9223375360960685195, 1),\n        (9223375840468297219, 1),\n        (9223377246635142855, 1),\n        (9223378573599571464, 1),\n        (9223392818083847604, 1),\n        (9223397883812499659, 1),\n        (9223410046446842059, 1),\n        (9223414297499376833, 1),\n        (9223420250639904388, 1),\n        (9223423782640535515, 1),\n    ];\n    let pop_median = (13835058055282163711, Some(13835058055282163712));\n    let sample_median = (13835015978121017591, Some(13835016964896634362));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.3835058055282164e19),\n        standard_deviation: NiceFloat(2.6625581641570857e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.3835207839699462e19),\n        standard_deviation: NiceFloat(2.6620357716239826e18),\n        skewness: NiceFloat(-0.001163213633403464),\n        excess_kurtosis: NiceFloat(-1.1990763518455725),\n    };\n    random_highest_bit_set_unsigneds_helper::<u64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u128\n    let values = &[\n        316819081939861044636107404782286008177,\n        259684029915037091022230980152781410491,\n        274570122163304294029662138603390933020,\n        227774850171603602876471193044002894743,\n        228075138265181566710552389938690625316,\n        212803339921546589345359493671973554838,\n        290482805477667929731925894842607922053,\n        194242323025343149803496343896337025882,\n        273877696450250650298202452211959786285,\n        202950956103661145939707262718357071703,\n        278510113161417516359560622970606220871,\n        245612405407790906538437072159901074531,\n        192996213236671200977298813427044737421,\n        311381173222019982206270836087375053399,\n        176738900463469569991939158243641249503,\n        288268669295331405536678348099056207715,\n        204463485514563745612349536646478672573,\n        185187345061019841391010982362414546856,\n        234567239495355551510783097995427525513,\n        322415362730128827224032220814663383318,\n    ];\n    let common_values = &[\n        (170141233166538297897770214998043520489, 1),\n        (170141477709687108748255943535626236844, 1),\n        (170141963031764576849655827097535573872, 1),\n        (170142211761517152257367037557307192382, 1),\n        (170142224955858751899306474848524651318, 1),\n        (170142344567707776674180030986486606478, 1),\n        (170142519806846123597203111583658441461, 1),\n        (170142677117909400976523007761944910786, 1),\n        (170142818348199748232299322264932053448, 1),\n        (170143268636071676474898792639923408007, 1),\n    ];\n    let pop_median = (\n        255211775190703847597530955573826158591,\n        Some(255211775190703847597530955573826158592),\n    );\n    let sample_median = (\n        255126542430357640405925855455171138421,\n        Some(255126579172819401755185863236353147245),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2.5521177519070385e38),\n        standard_deviation: NiceFloat(4.91155290355717e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.5515158317195176e38),\n        standard_deviation: NiceFloat(4.910082612813729e37),\n        skewness: NiceFloat(0.0016680470828693357),\n        excess_kurtosis: NiceFloat(-1.199401614583425),\n    };\n    random_highest_bit_set_unsigneds_helper::<u128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_natural_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_natural_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\n\nfn random_natural_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_natural_signeds::<T>(EXAMPLE_SEED),\n        T::ZERO,\n        T::MAX,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_natural_signeds() {\n    // i8\n    let values =\n        &[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, 1, 113, 54, 10, 47, 17, 89, 92, 119, 66];\n    let common_values = &[\n        (2, 8077),\n        (121, 8039),\n        (48, 8015),\n        (113, 7966),\n        (8, 7937),\n        (77, 7933),\n        (50, 7928),\n        (91, 7927),\n        (82, 7925),\n        (102, 7924),\n    ];\n    let pop_median = (63, Some(64));\n    let sample_median = (63, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(63.5),\n        standard_deviation: NiceFloat(36.94928957368463),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2001464933162425),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.478088999999315),\n        standard_deviation: NiceFloat(36.96113842989552),\n        skewness: NiceFloat(-0.000454036075457304),\n        excess_kurtosis: NiceFloat(-1.1998683031732713),\n    };\n    random_natural_signeds_helper::<i8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16\n    let values = &[\n        28529, 22667, 19345, 3398, 1402, 28100, 12052, 11409, 24046, 11152, 30158, 19629, 23709,\n        29262, 20999, 21707, 8622, 19470, 16708, 31300,\n    ];\n    let common_values = &[\n        (12912, 55),\n        (10381, 54),\n        (18999, 54),\n        (8262, 53),\n        (16860, 52),\n        (18853, 52),\n        (26980, 52),\n        (29418, 52),\n        (1430, 51),\n        (3511, 51),\n    ];\n    let pop_median = (16383, Some(16384));\n    let sample_median = (16394, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(16383.5),\n        standard_deviation: NiceFloat(9459.306805997996),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000000022351742),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(16387.96401900046),\n        standard_deviation: NiceFloat(9454.356832489306),\n        skewness: NiceFloat(-0.0012474540243073533),\n        excess_kurtosis: NiceFloat(-1.199051966133461),\n    };\n    random_natural_signeds_helper::<i16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32\n    let values = &[\n        1816522609, 1129424328, 1303937374, 1925780962, 962364894, 993179566, 132423026,\n        1465174948, 1361446689, 1660850464, 967812609, 546333625, 988229434, 365231847, 156905000,\n        1030913586, 2029143403, 1407130983, 1471083767, 1447050754,\n    ];\n    let common_values = &[\n        (1028854, 2),\n        (5270005, 2),\n        (52436108, 2),\n        (53442532, 2),\n        (54049511, 2),\n        (55679225, 2),\n        (56850838, 2),\n        (96093392, 2),\n        (100688553, 2),\n        (103402223, 2),\n    ];\n    let pop_median = (1073741823, Some(1073741824));\n    let sample_median = (1072627595, Some(1072629791));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1073741823.5),\n        standard_deviation: NiceFloat(619925131.1265597),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1072577564.7313439),\n        standard_deviation: NiceFloat(620056431.3063871),\n        skewness: NiceFloat(0.0014601286400032305),\n        excess_kurtosis: NiceFloat(-1.1999609793276922),\n    };\n    random_natural_signeds_helper::<i32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64\n    let values = &[\n        2425420277849911153,\n        6679477581841711279,\n        2839052228832469367,\n        969765657606132654,\n        511145952062627954,\n        8395344737368636720,\n        2894558908706954428,\n        3872377140940026972,\n        4461360302071018053,\n        8265671087366068090,\n        9205171493858792138,\n        440136107976613346,\n        5068356638012531024,\n        4934264084518118479,\n        1818371016611966298,\n        2429107481069952550,\n        6703623406340484388,\n        1574554890859127809,\n        117271882755911480,\n        4303959799021363928,\n    ];\n    let common_values = &[\n        (3324105909387, 1),\n        (3803613521411, 1),\n        (5209780367047, 1),\n        (6536744795656, 1),\n        (20781229071796, 1),\n        (25846957723851, 1),\n        (38009592066251, 1),\n        (42260644601025, 1),\n        (48213785128580, 1),\n        (51745785759707, 1),\n    ];\n    let pop_median = (4611686018427387903, Some(4611686018427387904));\n    let sample_median = (4611643941266241783, Some(4611644928041858554));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(4.611686018427388e18),\n        standard_deviation: NiceFloat(2.6625581641570857e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.611835802844851e18),\n        standard_deviation: NiceFloat(2.6620357716239764e18),\n        skewness: NiceFloat(-0.0011632136334031786),\n        excess_kurtosis: NiceFloat(-1.1990763518455585),\n    };\n    random_natural_signeds_helper::<i64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i128\n    let values = &[\n        146677898479391812904420101066401902449,\n        89542846454567859290543676436897304763,\n        104428938702835062297974834887506827292,\n        57633666711134371144783889328118789015,\n        57933954804712334978865086222806519588,\n        42662156461077357613672189956089449110,\n        120341622017198698000238591126723816325,\n        24101139564873918071809040180452920154,\n        103736512989781418566515148496075680557,\n        32809772643191914208019959002472965975,\n        108368929700948284627873319254722115143,\n        75471221947321674806749768444016968803,\n        22855029776201969245611509711160631693,\n        141239989761550750474583532371490947671,\n        6597717003000338260251854527757143775,\n        118127485834862173804991044383172101987,\n        34322302054094513880662232930594566845,\n        15046161600550609659323678646530441128,\n        64426056034886319779095794279543419785,\n        152274179269659595492344917098779277590,\n    ];\n    let common_values = &[\n        (49706069066166082911282159414761, 1),\n        (294249217877016568639819742131116, 1),\n        (779571295345117968523381651468144, 1),\n        (1028301047920525679733841423086654, 1),\n        (1041495389520167619171132640545590, 1),\n        (1161107238544942492727270602500750, 1),\n        (1336346376891865515807867774335733, 1),\n        (1493657440169244835704046060805058, 1),\n        (1634887730516500612018549047947720, 1),\n        (2085175602444743211488924039302279, 1),\n    ];\n    let pop_median = (\n        85070591730234615865843651857942052863,\n        Some(85070591730234615865843651857942052864),\n    );\n    let sample_median = (\n        84985358969888408674238551739287032693,\n        Some(84985395712350170023498559520469041517),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(8.507059173023462e37),\n        standard_deviation: NiceFloat(4.91155290355717e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.501039971148385e37),\n        standard_deviation: NiceFloat(4.910082612813726e37),\n        skewness: NiceFloat(0.0016680470828691063),\n        excess_kurtosis: NiceFloat(-1.199401614583414),\n    };\n    random_natural_signeds_helper::<i128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_negative_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_negative_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_negative_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_negative_finite_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_negative_finite_primitive_floats() {\n    // f32\n    let values = &[\n        -2.3484663e-27,\n        -0.010641626,\n        -5.8060583e-9,\n        -2.8182442e-31,\n        -10462.532,\n        -821.12994,\n        -6.303163e33,\n        -9.50376e-15,\n        -4.9561126e-11,\n        -8.565163e-22,\n        -6667.249,\n        -8.632876e18,\n        -1222.524,\n        -2.8259287e25,\n        -8.408057e32,\n        -35.37676,\n        -5.3312457e-35,\n        -1.1431576e-12,\n        -5.8021113e-15,\n        -4.2578778e-14,\n    ];\n    let common_values = &[\n        (-2.915314, 2),\n        (-0.7262628, 2),\n        (-1.3261845, 2),\n        (-10.318969, 2),\n        (-12496.082, 2),\n        (-15.058022, 2),\n        (-2.5221732, 2),\n        (-20.562862, 2),\n        (-203818.36, 2),\n        (-26.077845, 2),\n    ];\n    let sample_median = (-1.6313586, Some(-1.6313426));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.9935686121103762e36),\n        standard_deviation: NiceFloat(1.8605029843851628e37),\n        skewness: NiceFloat(-12.384333043431482),\n        excess_kurtosis: NiceFloat(170.5284644692483),\n    };\n    random_negative_finite_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        -1.4470055025606618e146,\n        -6.2410386896936294e-139,\n        -3.235416846271215e118,\n        -2.8486059576132576e243,\n        -1.3007593490666564e274,\n        -1.267802986597089e-253,\n        -6.298463311550517e114,\n        -2.71148919055391e49,\n        -11845642624.881702,\n        -6.049786340671396e-245,\n        -9.268165817801774e-308,\n        -7.204960592983619e278,\n        -3.152983742246857e-31,\n        -2.9080351183768945e-22,\n        -5.397630931761668e186,\n        -8.140466543599511e145,\n        -1.5709219762031943e-140,\n        -1.0805614483727634e203,\n        -2.6257467421064505e300,\n        -3.922358679765479e20,\n    ];\n    let common_values = &[\n        (-4081294.15273, 1),\n        (-75856946.7859, 1),\n        (-0.785631131986, 1),\n        (-10.70965140303, 1),\n        (-306424.6626443, 1),\n        (-314701.8184209, 1),\n        (-449320.3879786, 1),\n        (-590754505.6957, 1),\n        (-642882447.5536, 1),\n        (-88637.71469077, 1),\n    ];\n    let sample_median = (-1.5131202036927986, Some(-1.511917932803396));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.3244537383462707e305),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_finite_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_negative_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_negative_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_negative_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_negative_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_negative_primitive_floats() {\n    // f32\n    let values = &[\n        -2.3484665e-27,\n        -0.010641627,\n        -5.8060587e-9,\n        -2.8182444e-31,\n        -10462.533,\n        -821.13,\n        -6.3031636e33,\n        -9.5037605e-15,\n        -4.956113e-11,\n        -8.565164e-22,\n        -6667.2495,\n        -8.6328766e18,\n        -1222.5242,\n        -2.825929e25,\n        -8.408058e32,\n        -35.376762,\n        -5.331246e-35,\n        -1.1431577e-12,\n        -5.8021117e-15,\n        -4.257878e-14,\n    ];\n    let common_values = &[\n        (-10.31897, 2),\n        (-539.9892, 2),\n        (-60148.51, 2),\n        (-7.546873, 2),\n        (-7606.816, 2),\n        (-776.3078, 2),\n        (-1.3261846, 2),\n        (-12496.083, 2),\n        (-2.5221734, 2),\n        (-2.9153142, 2),\n    ];\n    let sample_median = (-1.6313587, Some(-1.6313428));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.9935687709301062e36),\n        standard_deviation: NiceFloat(1.8605031273250459e37),\n        skewness: NiceFloat(-12.384332949727417),\n        excess_kurtosis: NiceFloat(170.5284612507418),\n    };\n    random_negative_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        -1.447005502560662e146,\n        -6.24103868969363e-139,\n        -3.2354168462712154e118,\n        -2.848605957613258e243,\n        -1.3007593490666566e274,\n        -1.2678029865970891e-253,\n        -6.298463311550518e114,\n        -2.7114891905539105e49,\n        -11845642624.881704,\n        -6.049786340671397e-245,\n        -9.268165817801776e-308,\n        -7.20496059298362e278,\n        -3.1529837422468573e-31,\n        -2.908035118376895e-22,\n        -5.397630931761669e186,\n        -8.140466543599512e145,\n        -1.5709219762031945e-140,\n        -1.0805614483727636e203,\n        -2.6257467421064508e300,\n        -3.9223586797654796e20,\n    ];\n    let common_values = &[\n        (-8417229.77625, 1),\n        (-2.510958896e45, 1),\n        (-3208093286.102, 1),\n        (-362.2025556776, 1),\n        (-46.55187627446, 1),\n        (-466061517.8385, 1),\n        (-5.171759573816, 1),\n        (-6666772552.184, 1),\n        (-675858.2909992, 1),\n        (-732009733280.7, 1),\n    ];\n    let sample_median = (-1.5131202036927989, Some(-1.5119179328033963));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.324453738346271e305),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_negative_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_negative_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\n\nfn random_negative_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_negative_signeds::<T>(EXAMPLE_SEED),\n        T::MIN,\n        T::NEGATIVE_ONE,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_negative_signeds() {\n    // i8\n    let values = &[\n        -15, -34, -105, -30, -58, -36, -76, -44, -95, -81, -127, -15, -74, -118, -81, -111, -39,\n        -36, -9, -62,\n    ];\n    let common_values = &[\n        (-126, 8077),\n        (-7, 8039),\n        (-80, 8015),\n        (-15, 7966),\n        (-120, 7937),\n        (-51, 7933),\n        (-78, 7928),\n        (-37, 7927),\n        (-46, 7925),\n        (-26, 7924),\n    ];\n    let pop_median = (-65, Some(-64));\n    let sample_median = (-65, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-64.5),\n        standard_deviation: NiceFloat(36.94928957368463),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2001464933162425),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-64.5219110000005),\n        standard_deviation: NiceFloat(36.96113842989553),\n        skewness: NiceFloat(-0.00045403607545706974),\n        excess_kurtosis: NiceFloat(-1.1998683031732797),\n    };\n    random_negative_signeds_helper::<i8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16\n    let values = &[\n        -4239, -10101, -13423, -29370, -31366, -4668, -20716, -21359, -8722, -21616, -2610, -13139,\n        -9059, -3506, -11769, -11061, -24146, -13298, -16060, -1468,\n    ];\n    let common_values = &[\n        (-19856, 55),\n        (-13769, 54),\n        (-22387, 54),\n        (-24506, 53),\n        (-3350, 52),\n        (-5788, 52),\n        (-13915, 52),\n        (-15908, 52),\n        (-4224, 51),\n        (-6649, 51),\n    ];\n    let pop_median = (-16385, Some(-16384));\n    let sample_median = (-16374, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-16384.5),\n        standard_deviation: NiceFloat(9459.306805997996),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000000022351742),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-16380.035980999151),\n        standard_deviation: NiceFloat(9454.356832489315),\n        skewness: NiceFloat(-0.0012474540243074617),\n        excess_kurtosis: NiceFloat(-1.1990519661334669),\n    };\n    random_negative_signeds_helper::<i16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32\n    let values = &[\n        -330961039,\n        -1018059320,\n        -843546274,\n        -221702686,\n        -1185118754,\n        -1154304082,\n        -2015060622,\n        -682308700,\n        -786036959,\n        -486633184,\n        -1179671039,\n        -1601150023,\n        -1159254214,\n        -1782251801,\n        -1990578648,\n        -1116570062,\n        -118340245,\n        -740352665,\n        -676399881,\n        -700432894,\n    ];\n    let common_values = &[\n        (-2599452, 2),\n        (-30488905, 2),\n        (-41127657, 2),\n        (-47856776, 2),\n        (-48474862, 2),\n        (-49257777, 2),\n        (-60585238, 2),\n        (-63413113, 2),\n        (-90112461, 2),\n        (-92925255, 2),\n    ];\n    let pop_median = (-1073741825, Some(-1073741824));\n    let sample_median = (-1074856053, Some(-1074853857));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-1073741824.5),\n        standard_deviation: NiceFloat(619925131.1265597),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1074906083.2686987),\n        standard_deviation: NiceFloat(620056431.3063879),\n        skewness: NiceFloat(0.0014601286400033587),\n        excess_kurtosis: NiceFloat(-1.199960979327699),\n    };\n    random_negative_signeds_helper::<i32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64\n    let values = &[\n        -6797951759004864655,\n        -2543894455013064529,\n        -6384319808022306441,\n        -8253606379248643154,\n        -8712226084792147854,\n        -828027299486139088,\n        -6328813128147821380,\n        -5350994895914748836,\n        -4762011734783757755,\n        -957700949488707718,\n        -18200542995983670,\n        -8783235928878162462,\n        -4155015398842244784,\n        -4289107952336657329,\n        -7405001020242809510,\n        -6794264555784823258,\n        -2519748630514291420,\n        -7648817145995647999,\n        -9106100154098864328,\n        -4919412237833411880,\n    ];\n    let common_values = &[\n        (-32633775716835, 1),\n        (-33530332767202, 1),\n        (-40083601698629, 1),\n        (-54667548368563, 1),\n        (-55711023537196, 1),\n        (-57995675195609, 1),\n        (-60421027989814, 1),\n        (-63506819698059, 1),\n        (-68934218411234, 1),\n        (-96764893067540, 1),\n    ];\n    let pop_median = (-4611686018427387905, Some(-4611686018427387904));\n    let sample_median = (-4611728095588534025, Some(-4611727108812917254));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-4.611686018427388e18),\n        standard_deviation: NiceFloat(2.6625581641570857e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.6115362340100536e18),\n        standard_deviation: NiceFloat(2.662035771623978e18),\n        skewness: NiceFloat(-0.0011632136334032948),\n        excess_kurtosis: NiceFloat(-1.199076351845568),\n    };\n    random_negative_signeds_helper::<i64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i128\n    let values = &[\n        -23463284981077418827267202649482203279,\n        -80598337005901372441143627278986800965,\n        -65712244757634169433712468828377278436,\n        -112507516749334860586903414387765316713,\n        -112207228655756896752822217493077586140,\n        -127479026999391874118015113759794656618,\n        -49799561443270533731448712589160289403,\n        -146040043895595313659878263535431185574,\n        -66404670470687813165172155219808425171,\n        -137331410817277317523667344713411139753,\n        -61772253759520947103813984461161990585,\n        -94669961513147556924937535271867136925,\n        -147286153684267262486075794004723474035,\n        -28901193698918481257103771344393158057,\n        -163543466457468893471435449188126961953,\n        -52013697625607057926696259332712003741,\n        -135818881406374717851025070785289538883,\n        -155095021859918622072363625069353664600,\n        -105715127425582911952591509436340685943,\n        -17867004190809636239342386617104828138,\n    ];\n    let common_values = &[\n        (-5142203300700144436674870612888, 1),\n        (-182426925066696407144329295811271, 1),\n        (-609085828667135587396424148113815, 1),\n        (-709584458395955034053916159170888, 1),\n        (-793734383127263040096517829674535, 1),\n        (-1015040108753864759296367578696398, 1),\n        (-1102384056888326002883014030016669, 1),\n        (-1302359298776052550565920555095243, 1),\n        (-1597976831171503518058570309070626, 1),\n        (-1756747886524482972001931222767918, 1),\n    ];\n    let pop_median = (\n        -85070591730234615865843651857942052865,\n        Some(-85070591730234615865843651857942052864),\n    );\n    let sample_median = (\n        -85155824490580823057448751976597073035,\n        Some(-85155787748119061708188744195415064211),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-8.507059173023462e37),\n        standard_deviation: NiceFloat(4.91155290355717e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.513078374898942e37),\n        standard_deviation: NiceFloat(4.9100826128137265e37),\n        skewness: NiceFloat(0.001668047082869008),\n        excess_kurtosis: NiceFloat(-1.1994016145834168),\n    };\n    random_negative_signeds_helper::<i128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_nonzero_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_nonzero_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_nonzero_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_nonzero_finite_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_nonzero_finite_primitive_floats() {\n    // f32\n    let values = &[\n        -2.3484663e-27,\n        2.287989e-18,\n        -2.0729893e-12,\n        3.360012e28,\n        -9.021723e-32,\n        3564911.2,\n        -0.0000133769445,\n        -1.8855448e18,\n        8.2494555e-29,\n        2.2178014e-38,\n        -6.3067724e-34,\n        5.1996016e31,\n        7.613263e33,\n        0.00015323666,\n        9.476819e36,\n        -0.0005665586,\n        8.8733265e-30,\n        0.09273135,\n        -7.7748304e33,\n        4.3156234e-8,\n    ];\n    let common_values = &[\n        (-66476.9, 2),\n        (34.61204, 2),\n        (73439.86, 2),\n        (780.0361, 2),\n        (-66297.14, 2),\n        (0.2084277, 2),\n        (13200.072, 2),\n        (224535.31, 2),\n        (3306.3638, 2),\n        (5.7126203, 2),\n    ];\n    let sample_median = (4.601795e-39, Some(4.606578e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.871800306879315e34),\n        standard_deviation: NiceFloat(1.8597574252028948e37),\n        skewness: NiceFloat(-0.04588142291892213),\n        excess_kurtosis: NiceFloat(174.30920632007357),\n    };\n    random_nonzero_finite_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        3.1062066405583414e-146,\n        7.268713316268922e223,\n        1.1685126708702853e48,\n        -1.0824685183946233e146,\n        3.1146051606615834e-306,\n        2.2453015573637678e249,\n        1.2548860979388688e-35,\n        -8.287939157477945e-27,\n        2.1255041535787168e-13,\n        4.815129234795049e-64,\n        1.3850402674408149e-17,\n        -1.2535717707589619e207,\n        -1.4941028004491903e142,\n        4.3666119614549075e-51,\n        -7.063699168119983e17,\n        -7.062565582436956e90,\n        1.1662950933663384e-221,\n        2.1976577668343595e-97,\n        -2.821294426687019e-137,\n        1.225091633874841e-222,\n    ];\n    let common_values = &[\n        (3.637321705391, 1),\n        (30.80883877248, 1),\n        (915366460504.2, 1),\n        (9256888.416622, 1),\n        (-737164661.2491, 1),\n        (-81413.95043198, 1),\n        (-994938.9166069, 1),\n        (1.4299272196643, 1),\n        (12812252.479435, 1),\n        (1598038.5592174, 1),\n    ];\n    let sample_median = (2.7723065921722726e-308, Some(2.782073119497922e-308));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.922018643581054e303),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_finite_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_nonzero_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_nonzero_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_nonzero_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_nonzero_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_nonzero_primitive_floats() {\n    // f32\n    let values = &[\n        -2.3484665e-27,\n        2.2879888e-18,\n        -2.0729896e-12,\n        3.3600117e28,\n        -9.0217234e-32,\n        3564911.0,\n        -0.000013376945,\n        -1.885545e18,\n        8.249455e-29,\n        2.2178013e-38,\n        -6.306773e-34,\n        5.199601e31,\n        7.6132625e33,\n        0.00015323664,\n        9.4768183e36,\n        -0.0005665587,\n        8.873326e-30,\n        0.09273134,\n        -7.774831e33,\n        4.315623e-8,\n    ];\n    let common_values = &[\n        (5.71262, 2),\n        (780.036, 2),\n        (224535.3, 2),\n        (58.67172, 2),\n        (73439.85, 2),\n        (-58.01006, 2),\n        (-66297.15, 2),\n        (-66476.91, 2),\n        (13200.071, 2),\n        (3306.3635, 2),\n    ];\n    let sample_median = (4.601794e-39, Some(4.606577e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.871815997376882e34),\n        standard_deviation: NiceFloat(1.8597574260800838e37),\n        skewness: NiceFloat(-0.04588420234596291),\n        excess_kurtosis: NiceFloat(174.30920609573673),\n    };\n    random_nonzero_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        3.106206640558341e-146,\n        7.268713316268921e223,\n        1.1685126708702852e48,\n        -1.0824685183946236e146,\n        3.114605160661583e-306,\n        2.2453015573637674e249,\n        1.2548860979388685e-35,\n        -8.287939157477947e-27,\n        2.1255041535787165e-13,\n        4.815129234795048e-64,\n        1.3850402674408148e-17,\n        -1.253571770758962e207,\n        -1.4941028004491906e142,\n        4.366611961454907e-51,\n        -7.063699168119985e17,\n        -7.062565582436957e90,\n        1.1662950933663382e-221,\n        2.1976577668343592e-97,\n        -2.8212944266870196e-137,\n        1.2250916338748408e-222,\n    ];\n    let common_values = &[\n        (-9967188.16722, 1),\n        (1808.830612999, 1),\n        (32578528203.69, 1),\n        (5643444.695113, 1),\n        (812845035127.8, 1),\n        (-13741970740.45, 1),\n        (-1434325.082519, 1),\n        (-33781527.93352, 1),\n        (-374012916597.5, 1),\n        (-46629353341.91, 1),\n    ];\n    let sample_median = (2.772306592172272e-308, Some(2.7820731194979217e-308));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.922018643581038e303),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_nonzero_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_nonzero_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, deleted_uniform_primitive_int_assertions,\n};\n\nfn random_nonzero_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    deleted_uniform_primitive_int_assertions(\n        random_nonzero_signeds::<T>(EXAMPLE_SEED),\n        T::MIN,\n        T::MAX,\n        T::ZERO,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_nonzero_signeds() {\n    // i8\n    let values = &[\n        113, -17, 69, 108, -28, -46, -88, -95, 87, 32, 110, 83, -68, 34, 89, -18, 93, -56, -107,\n        115,\n    ];\n    let common_values = &[\n        (-42, 4112),\n        (86, 4092),\n        (-90, 4063),\n        (22, 4061),\n        (126, 4061),\n        (93, 4054),\n        (55, 4053),\n        (-65, 4052),\n        (36, 4049),\n        (42, 4047),\n    ];\n    let pop_median = (-1, None);\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5019607843137255),\n        standard_deviation: NiceFloat(74.04502469734098),\n        skewness: NiceFloat(0.00007944171209676364),\n        excess_kurtosis: NiceFloat(-1.207067080672989),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5131950000000044),\n        standard_deviation: NiceFloat(74.04373630744782),\n        skewness: NiceFloat(-0.00024235105395531954),\n        excess_kurtosis: NiceFloat(-1.2065292546223),\n    };\n    random_nonzero_signeds_helper::<i8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16\n    let values = &[\n        -4239, 27717, -11548, -24152, 8279, 21358, 8892, -4519, -14243, 29589, -27203, -13863,\n        -28043, 18463, -22121, 8622, 9735, -28591, 32584, -32655,\n    ];\n    let common_values = &[\n        (27447, 34),\n        (-898, 33),\n        (5606, 33),\n        (5836, 33),\n        (-15023, 33),\n        (-197, 32),\n        (3582, 32),\n        (-7314, 32),\n        (19279, 32),\n        (20588, 32),\n    ];\n    let pop_median = (-1, None);\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5000076295109483),\n        standard_deviation: NiceFloat(18918.757957822254),\n        skewness: NiceFloat(1.2098327432880512e-9),\n        excess_kurtosis: NiceFloat(-1.200027466379059),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.019281000000275),\n        standard_deviation: NiceFloat(18918.558463263365),\n        skewness: NiceFloat(-0.0001978759287576409),\n        excess_kurtosis: NiceFloat(-1.1998315900739762),\n    };\n    random_nonzero_signeds_helper::<i16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32\n    let values = &[\n        1816522609,\n        -1582771484,\n        1399726167,\n        -296148292,\n        1939195997,\n        -908487235,\n        1210028661,\n        565094807,\n        -1873730041,\n        -2140045496,\n        1999530985,\n        -207351284,\n        -147083662,\n        -1197429209,\n        -60545688,\n        1164671716,\n        -1900807950,\n        -1120015889,\n        130045419,\n        -1296475448,\n    ];\n    let common_values = &[\n        (20095656, 2),\n        (29107328, 2),\n        (83328146, 2),\n        (96543416, 2),\n        (-59532811, 2),\n        (-72250103, 2),\n        (-88423413, 2),\n        (109257003, 2),\n        (132308363, 2),\n        (140940582, 2),\n    ];\n    let pop_median = (-1, None);\n    let sample_median = (-3037682, Some(-3035621));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5000000001164153),\n        standard_deviation: NiceFloat(1239850262.3974571),\n        skewness: NiceFloat(2.8168398703367104e-19),\n        excess_kurtosis: NiceFloat(-1.2000000004190956),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1708075.0735549931),\n        standard_deviation: NiceFloat(1239705769.0057693),\n        skewness: NiceFloat(0.0016706713036923025),\n        excess_kurtosis: NiceFloat(-1.2008047456655335),\n    };\n    random_nonzero_signeds_helper::<i32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64\n    let values = &[\n        -6797951759004864655,\n        -1271947227506532265,\n        -3901922961219270563,\n        2427063716414460533,\n        -9191425414850861561,\n        -890566981564077079,\n        -5142919287782265230,\n        5002226935030621544,\n        -4810431611861206798,\n        -5568319649096903189,\n        -4872912570782646188,\n        1513424385005459611,\n        2484972586252155822,\n        -5374443828107932323,\n        4344958725064805398,\n        3252798961345668310,\n        -7926092317508205845,\n        -6066899635121005951,\n        6654913321726770291,\n        -7940875872878966649,\n    ];\n    let common_values = &[\n        (26914038281329, 1),\n        (32553719576594, 1),\n        (53892651831494, 1),\n        (66354421349686, 1),\n        (86226284907602, 1),\n        (89837182726049, 1),\n        (95691351770484, 1),\n        (-45554336062456, 1),\n        (-45700426911569, 1),\n        (-50232881235535, 1),\n    ];\n    let pop_median = (-1, None);\n    let sample_median = (-5305218289400184, Some(-5271053954352614));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(5.325116328314171e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.1999999999999997),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5606718482239710.0),\n        standard_deviation: NiceFloat(5.325063903618647e18),\n        skewness: NiceFloat(0.0011248693866288532),\n        excess_kurtosis: NiceFloat(-1.200551786344892),\n    };\n    random_nonzero_signeds_helper::<i64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i128\n    let values = &[\n        -23463284981077418827267202649482203279,\n        44771423227283929645271838218448652381,\n        -16428061189408542358428117207094319609,\n        92274800069126412258941638023956901490,\n        -102717367487498748896125496933502158606,\n        27917752305106984883503397141734686804,\n        -99140989835634876684435608594951128146,\n        60003549963171791765607325839025294358,\n        -111914544889959057594096246794876321045,\n        -146483304948093240780207189413481284493,\n        -153586157979719815495295783806580152035,\n        33018320828004690757952445968579104952,\n        24887066387352849554815992782110776358,\n        79085537771456044427857440036467563654,\n        19637669411666889498466854442215856999,\n        -102694834600182680427466985752932389987,\n        -85298529075242965442847250193117638905,\n        -67944983823469089095474618642592431761,\n        105189689748742230503365861545668092951,\n        -81854971460639281226116917410207070376,\n    ];\n    let common_values = &[\n        (68570815139656170990830410045915, 1),\n        (381682482227926990846204728028719, 1),\n        (565207126752383841908924745713103, 1),\n        (717866653939818807939025508430762, 1),\n        (775173738585689418081884794376186, 1),\n        (818497230601034032775791540657915, 1),\n        (-307666299724089175945459600408325, 1),\n        (-413570452196184856884474016102340, 1),\n        (-789195894019805665974324122519229, 1),\n        (-843024079296967638987633859098218, 1),\n    ];\n    let pop_median = (-1, None);\n    let sample_median = (\n        -10072503186589325235371920356302834,\n        Some(-9899574809150113239535729822182407),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(9.82310580711434e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.1999999999999997),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.651168263124604e34),\n        standard_deviation: NiceFloat(9.82707680675722e37),\n        skewness: NiceFloat(0.00010083962773749455),\n        excess_kurtosis: NiceFloat(-1.2019920806441844),\n    };\n    random_nonzero_signeds_helper::<i128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_positive_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_positive_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_positive_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_positive_finite_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_finite_primitive_floats() {\n    // f32\n    let values = &[\n        9.5715654e26,\n        209.6476,\n        386935780.0,\n        7.965817e30,\n        0.00021030706,\n        0.0027270128,\n        3.4398167e-34,\n        2.3397111e14,\n        44567765000.0,\n        2.3479653e21,\n        0.00033502287,\n        2.4460542e-19,\n        0.0017637977,\n        7.956594e-26,\n        2.62625e-33,\n        0.059202384,\n        3.9310746e34,\n        1916542100000.0,\n        3.847343e14,\n        5.2843143e13,\n    ];\n    let common_values = &[\n        (59.25553, 2),\n        (68.23402, 2),\n        (75936.53, 2),\n        (9.581732, 2),\n        (0.7711715, 2),\n        (0.8694567, 2),\n        (1.6738155, 2),\n        (1168060.5, 2),\n        (12.359466, 2),\n        (146.89862, 2),\n    ];\n    let sample_median = (1.3686414, Some(1.3686574));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0305910210122042e36),\n        standard_deviation: NiceFloat(1.8908940416475047e37),\n        skewness: NiceFloat(12.30495721768228),\n        excess_kurtosis: NiceFloat(168.0100163146302),\n    };\n    random_positive_finite_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        1.553103320279171e-146,\n        3.399767269777243e138,\n        6.920999672956352e-119,\n        7.798612728071752e-244,\n        1.7297528302435229e-274,\n        1.6730698009459568e253,\n        3.494622700146595e-115,\n        7.870553878200458e-50,\n        1.88707572126009e-10,\n        3.680784346523073e244,\n        2.2006770848831818e307,\n        3.0495236892779565e-279,\n        7.105167957384262e30,\n        7.68196442827874e21,\n        4.043761560817649e-187,\n        2.743276189070554e-146,\n        1.4322725127932769e140,\n        2.0686074901798122e-203,\n        7.761683804525804e-301,\n        5.6617484237282776e-21,\n    ];\n    let common_values = &[\n        (66730.2435683, 1),\n        (2.857475472056, 1),\n        (2042187757.012, 1),\n        (206.7039373431, 1),\n        (2621701.092576, 1),\n        (27.03018555735, 1),\n        (3.025032765206, 1),\n        (454348736.2729, 1),\n        (5683730270.934, 1),\n        (79306986.55539, 1),\n    ];\n    let sample_median = (1.4868797963072014, Some(1.488082067196604));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.3252967815615318e305),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_finite_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_positive_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_positive_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_positive_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_positive_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_primitive_floats() {\n    // f32\n    let values = &[\n        9.5715654e26,\n        209.6476,\n        386935780.0,\n        7.965817e30,\n        0.00021030706,\n        0.0027270128,\n        3.4398167e-34,\n        2.3397111e14,\n        44567765000.0,\n        2.3479653e21,\n        0.00033502287,\n        2.4460542e-19,\n        0.0017637977,\n        7.956594e-26,\n        2.62625e-33,\n        0.059202384,\n        3.9310746e34,\n        1916542100000.0,\n        3.847343e14,\n        5.2843143e13,\n    ];\n    let common_values = &[\n        (59.25553, 2),\n        (68.23402, 2),\n        (75936.53, 2),\n        (9.581732, 2),\n        (0.7711715, 2),\n        (0.8694567, 2),\n        (1.6738155, 2),\n        (1168060.5, 2),\n        (12.359466, 2),\n        (146.89862, 2),\n    ];\n    let sample_median = (1.3686414, Some(1.3686574));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0305910210122042e36),\n        standard_deviation: NiceFloat(1.8908940416475047e37),\n        skewness: NiceFloat(12.30495721768228),\n        excess_kurtosis: NiceFloat(168.0100163146302),\n    };\n    random_positive_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        1.553103320279171e-146,\n        3.399767269777243e138,\n        6.920999672956352e-119,\n        7.798612728071752e-244,\n        1.7297528302435229e-274,\n        1.6730698009459568e253,\n        3.494622700146595e-115,\n        7.870553878200458e-50,\n        1.88707572126009e-10,\n        3.680784346523073e244,\n        2.2006770848831818e307,\n        3.0495236892779565e-279,\n        7.105167957384262e30,\n        7.68196442827874e21,\n        4.043761560817649e-187,\n        2.743276189070554e-146,\n        1.4322725127932769e140,\n        2.0686074901798122e-203,\n        7.761683804525804e-301,\n        5.6617484237282776e-21,\n    ];\n    let common_values = &[\n        (66730.2435683, 1),\n        (2.857475472056, 1),\n        (2042187757.012, 1),\n        (206.7039373431, 1),\n        (2621701.092576, 1),\n        (27.03018555735, 1),\n        (3.025032765206, 1),\n        (454348736.2729, 1),\n        (5683730270.934, 1),\n        (79306986.55539, 1),\n    ];\n    let sample_median = (1.4868797963072014, Some(1.488082067196604));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.3252967815615318e305),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_positive_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_positive_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\n\nfn random_positive_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_positive_signeds::<T>(EXAMPLE_SEED),\n        T::ONE,\n        T::MAX,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_signeds() {\n    // i8\n    let values =\n        &[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, 1, 113, 54, 10, 47, 17, 89, 92, 119, 66];\n    let common_values = &[\n        (2, 8156),\n        (121, 8095),\n        (48, 8062),\n        (113, 8024),\n        (78, 8003),\n        (8, 7997),\n        (91, 7995),\n        (77, 7994),\n        (50, 7990),\n        (102, 7989),\n    ];\n    let pop_median = (64, None);\n    let sample_median = (64, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(64.0),\n        standard_deviation: NiceFloat(36.66060555964672),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2001488095238095),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.982919000001765),\n        standard_deviation: NiceFloat(36.67212767326611),\n        skewness: NiceFloat(-0.0007589869063919588),\n        excess_kurtosis: NiceFloat(-1.1997242130732357),\n    };\n    random_positive_signeds_helper::<i8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16\n    let values = &[\n        28529, 22667, 19345, 3398, 1402, 28100, 12052, 11409, 24046, 11152, 30158, 19629, 23709,\n        29262, 20999, 21707, 8622, 19470, 16708, 31300,\n    ];\n    let common_values = &[\n        (12912, 55),\n        (10381, 54),\n        (18999, 54),\n        (8262, 53),\n        (16860, 52),\n        (18853, 52),\n        (26980, 52),\n        (29418, 52),\n        (1430, 51),\n        (3511, 51),\n    ];\n    let pop_median = (16384, None);\n    let sample_median = (16394, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(16384.0),\n        standard_deviation: NiceFloat(9459.018130863265),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000000022353106),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(16388.51686199981),\n        standard_deviation: NiceFloat(9454.07106153838),\n        skewness: NiceFloat(-0.0012487208201804533),\n        excess_kurtosis: NiceFloat(-1.1990539374536704),\n    };\n    random_positive_signeds_helper::<i16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32\n    let values = &[\n        1816522609, 1129424328, 1303937374, 1925780962, 962364894, 993179566, 132423026,\n        1465174948, 1361446689, 1660850464, 967812609, 546333625, 988229434, 365231847, 156905000,\n        1030913586, 2029143403, 1407130983, 1471083767, 1447050754,\n    ];\n    let common_values = &[\n        (1028854, 2),\n        (5270005, 2),\n        (52436108, 2),\n        (53442532, 2),\n        (54049511, 2),\n        (55679225, 2),\n        (56850838, 2),\n        (96093392, 2),\n        (100688553, 2),\n        (103402223, 2),\n    ];\n    let pop_median = (1073741824, None);\n    let sample_median = (1072627595, Some(1072629791));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1073741824.0),\n        standard_deviation: NiceFloat(619925130.8378847),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1072577564.7313439),\n        standard_deviation: NiceFloat(620056431.3063871),\n        skewness: NiceFloat(0.0014601286400032305),\n        excess_kurtosis: NiceFloat(-1.1999609793276922),\n    };\n    random_positive_signeds_helper::<i32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64\n    let values = &[\n        2425420277849911153,\n        6679477581841711279,\n        2839052228832469367,\n        969765657606132654,\n        511145952062627954,\n        8395344737368636720,\n        2894558908706954428,\n        3872377140940026972,\n        4461360302071018053,\n        8265671087366068090,\n        9205171493858792138,\n        440136107976613346,\n        5068356638012531024,\n        4934264084518118479,\n        1818371016611966298,\n        2429107481069952550,\n        6703623406340484388,\n        1574554890859127809,\n        117271882755911480,\n        4303959799021363928,\n    ];\n    let common_values = &[\n        (3324105909387, 1),\n        (3803613521411, 1),\n        (5209780367047, 1),\n        (6536744795656, 1),\n        (20781229071796, 1),\n        (25846957723851, 1),\n        (38009592066251, 1),\n        (42260644601025, 1),\n        (48213785128580, 1),\n        (51745785759707, 1),\n    ];\n    let pop_median = (4611686018427387904, None);\n    let sample_median = (4611643941266241783, Some(4611644928041858554));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(4.611686018427388e18),\n        standard_deviation: NiceFloat(2.6625581641570857e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.611835802844851e18),\n        standard_deviation: NiceFloat(2.6620357716239764e18),\n        skewness: NiceFloat(-0.0011632136334031786),\n        excess_kurtosis: NiceFloat(-1.1990763518455585),\n    };\n    random_positive_signeds_helper::<i64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i128\n    let values = &[\n        146677898479391812904420101066401902449,\n        89542846454567859290543676436897304763,\n        104428938702835062297974834887506827292,\n        57633666711134371144783889328118789015,\n        57933954804712334978865086222806519588,\n        42662156461077357613672189956089449110,\n        120341622017198698000238591126723816325,\n        24101139564873918071809040180452920154,\n        103736512989781418566515148496075680557,\n        32809772643191914208019959002472965975,\n        108368929700948284627873319254722115143,\n        75471221947321674806749768444016968803,\n        22855029776201969245611509711160631693,\n        141239989761550750474583532371490947671,\n        6597717003000338260251854527757143775,\n        118127485834862173804991044383172101987,\n        34322302054094513880662232930594566845,\n        15046161600550609659323678646530441128,\n        64426056034886319779095794279543419785,\n        152274179269659595492344917098779277590,\n    ];\n    let common_values = &[\n        (49706069066166082911282159414761, 1),\n        (294249217877016568639819742131116, 1),\n        (779571295345117968523381651468144, 1),\n        (1028301047920525679733841423086654, 1),\n        (1041495389520167619171132640545590, 1),\n        (1161107238544942492727270602500750, 1),\n        (1336346376891865515807867774335733, 1),\n        (1493657440169244835704046060805058, 1),\n        (1634887730516500612018549047947720, 1),\n        (2085175602444743211488924039302279, 1),\n    ];\n    let pop_median = (85070591730234615865843651857942052864, None);\n    let sample_median = (\n        84985358969888408674238551739287032693,\n        Some(84985395712350170023498559520469041517),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(8.507059173023462e37),\n        standard_deviation: NiceFloat(4.91155290355717e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.501039971148385e37),\n        standard_deviation: NiceFloat(4.910082612813726e37),\n        skewness: NiceFloat(0.0016680470828691063),\n        excess_kurtosis: NiceFloat(-1.199401614583414),\n    };\n    random_positive_signeds_helper::<i128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_positive_unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_positive_unsigneds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\n\nfn random_positive_unsigneds_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_positive_unsigneds::<T>(EXAMPLE_SEED),\n        T::ONE,\n        T::MAX,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_unsigneds() {\n    // u8\n    let values = &[\n        113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149, 115,\n    ];\n    let common_values = &[\n        (214, 4112),\n        (86, 4092),\n        (166, 4063),\n        (22, 4061),\n        (126, 4061),\n        (93, 4054),\n        (55, 4053),\n        (191, 4052),\n        (36, 4049),\n        (42, 4047),\n    ];\n    let pop_median = (128, None);\n    let sample_median = (128, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(128.0),\n        standard_deviation: NiceFloat(73.6115932898254),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000369094488188),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.95426100000232),\n        standard_deviation: NiceFloat(73.62056563848995),\n        skewness: NiceFloat(0.0005293443118466251),\n        excess_kurtosis: NiceFloat(-1.2003369218920343),\n    };\n    random_positive_unsigneds_helper::<u8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16\n    let values = &[\n        61297, 27717, 53988, 41384, 8279, 21358, 8892, 61017, 51293, 29589, 38333, 51673, 37493,\n        18463, 43415, 8622, 9735, 36945, 32584, 32881,\n    ];\n    let common_values = &[\n        (27447, 34),\n        (5606, 33),\n        (5836, 33),\n        (50513, 33),\n        (64638, 33),\n        (3582, 32),\n        (19279, 32),\n        (20588, 32),\n        (27377, 32),\n        (40163, 32),\n    ];\n    let pop_median = (32768, None);\n    let sample_median = (32764, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(32768.0),\n        standard_deviation: NiceFloat(18918.32494346861),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000000005588105),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(32769.087121000004),\n        standard_deviation: NiceFloat(18919.668065423208),\n        skewness: NiceFloat(0.00005282326597264531),\n        excess_kurtosis: NiceFloat(-1.2002448370280603),\n    };\n    random_positive_unsigneds_helper::<u16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32\n    let values = &[\n        1816522609, 2712195812, 1399726167, 3998819004, 1939195997, 3386480061, 1210028661,\n        565094807, 2421237255, 2154921800, 1999530985, 4087616012, 4147883634, 3097538087,\n        4234421608, 1164671716, 2394159346, 3174951407, 130045419, 2998491848,\n    ];\n    let common_values = &[\n        (20095656, 2),\n        (29107328, 2),\n        (83328146, 2),\n        (96543416, 2),\n        (109257003, 2),\n        (132308363, 2),\n        (140940582, 2),\n        (168698132, 2),\n        (182460287, 2),\n        (184573980, 2),\n    ];\n    let pop_median = (2147483648, None);\n    let sample_median = (2150296456, Some(2150302375));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2147483648.0),\n        standard_deviation: NiceFloat(1239850261.9644444),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2148696150.6876254),\n        standard_deviation: NiceFloat(1239453907.667566),\n        skewness: NiceFloat(-0.0016842295222180032),\n        excess_kurtosis: NiceFloat(-1.2007050556559806),\n    };\n    random_positive_unsigneds_helper::<u32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64\n    let values = &[\n        11648792314704686961,\n        17174796846203019351,\n        14544821112490281053,\n        2427063716414460533,\n        9255318658858690055,\n        17556177092145474537,\n        13303824785927286386,\n        5002226935030621544,\n        13636312461848344818,\n        12878424424612648427,\n        13573831502926905428,\n        1513424385005459611,\n        2484972586252155822,\n        13072300245601619293,\n        4344958725064805398,\n        3252798961345668310,\n        10520651756201345771,\n        12379844438588545665,\n        6654913321726770291,\n        10505868200830584967,\n    ];\n    let common_values = &[\n        (26914038281329, 1),\n        (32553719576594, 1),\n        (53892651831494, 1),\n        (66354421349686, 1),\n        (86226284907602, 1),\n        (89837182726049, 1),\n        (95691351770484, 1),\n        (166741761063383, 1),\n        (171574734234584, 1),\n        (212518263578065, 1),\n    ];\n    let pop_median = (9223372036854775808, None);\n    let sample_median = (9228795451400314170, Some(9228799993322832549));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(9.223372036854776e18),\n        standard_deviation: NiceFloat(5.325116328314171e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.223151767642118e18),\n        standard_deviation: NiceFloat(5.323459825978695e18),\n        skewness: NiceFloat(-0.0007960342667556958),\n        excess_kurtosis: NiceFloat(-1.2005689675667335),\n    };\n    random_positive_unsigneds_helper::<u64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u128\n    let values = &[\n        316819081939861044636107404782286008177,\n        44771423227283929645271838218448652381,\n        323854305731529921104946490224673891847,\n        92274800069126412258941638023956901490,\n        237564999433439714567249110498266052850,\n        27917752305106984883503397141734686804,\n        241141377085303586778938998836817083310,\n        60003549963171791765607325839025294358,\n        228367822030979405869278360636891890411,\n        193799061972845222683167418018286926963,\n        186696208941218647968078823625188059421,\n        33018320828004690757952445968579104952,\n        24887066387352849554815992782110776358,\n        79085537771456044427857440036467563654,\n        19637669411666889498466854442215856999,\n        237587532320755783035907621678835821469,\n        254983837845695498020527357238650572551,\n        272337383097469374367899988789175779695,\n        105189689748742230503365861545668092951,\n        258427395460299182237257690021561141080,\n    ];\n    let common_values = &[\n        (68570815139656170990830410045915, 1),\n        (381682482227926990846204728028719, 1),\n        (565207126752383841908924745713103, 1),\n        (717866653939818807939025508430762, 1),\n        (775173738585689418081884794376186, 1),\n        (818497230601034032775791540657915, 1),\n        (1224023028796761386468452212527255, 1),\n        (1379103576141836593923341631562888, 1),\n        (1765193876177447622538546939111747, 1),\n        (2049979073093489039458791025727172, 1),\n    ];\n    let pop_median = (170141183460469231731687303715884105728, None);\n    let sample_median = (\n        170151864710150847082485192587168481404,\n        Some(170151925651660504506169909296979843840),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.7014118346046923e38),\n        standard_deviation: NiceFloat(9.82310580711434e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.702375633317502e38),\n        standard_deviation: NiceFloat(9.815169783582294e37),\n        skewness: NiceFloat(-0.0005571163134867303),\n        excess_kurtosis: NiceFloat(-1.1992896928276262),\n    };\n    random_positive_unsigneds_helper::<u128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_primitive_float_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_primitive_float_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn random_primitive_float_inclusive_range_helper<T: CheckedToF64 + PrimitiveFloat>(\n    a: T,\n    b: T,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_primitive_float_inclusive_range::<T>(EXAMPLE_SEED, a, b),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_primitive_float_inclusive_range() {\n    // f32, a = 1.0, b = 2.0\n    let values = &[\n        1.5463697, 1.6846209, 1.6517982, 1.6963725, 1.246657, 1.0557153, 1.8866968, 1.8430634,\n        1.0973871, 1.4662611, 1.8181343, 1.8396878, 1.7092294, 1.6617042, 1.7495066, 1.1922526,\n        1.9193928, 1.1640857, 1.2869775, 1.7921972,\n    ];\n    let common_values = &[\n        (1.262395, 4),\n        (1.619045, 4),\n        (1.942131, 4),\n        (1.0062196, 4),\n        (1.0075867, 4),\n        (1.0664382, 4),\n        (1.0932482, 4),\n        (1.1049225, 4),\n        (1.1625684, 4),\n        (1.1672009, 4),\n    ];\n    let sample_median = (1.4996792, Some(1.4996796));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.4997834476890244),\n        standard_deviation: NiceFloat(0.2887567306490316),\n        skewness: NiceFloat(0.001395347389592521),\n        excess_kurtosis: NiceFloat(-1.2017290675577252),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        1.0,\n        2.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.1, b = 0.1\n    let values = &[\n        5.664681e-11,\n        1.2492925e-35,\n        2.3242339e-29,\n        4.699183e-7,\n        -2.8244436e-36,\n        -2.264039e-37,\n        -0.0000017299129,\n        1.40616e-23,\n        2.7418007e-27,\n        1.5418819e-16,\n        -1.8473076e-36,\n        -2.4935917e-21,\n        -3.373897e-37,\n        -7.5386525e-15,\n        -2.2595721e-7,\n        -8.293393e-39,\n        0.0025248893,\n        1.1819218e-25,\n        2.3384073e-23,\n        3.1464167e-24,\n    ];\n    let common_values = &[\n        (0.02590246, 2),\n        (-0.09233444, 2),\n        (0.001610253, 2),\n        (0.010553952, 2),\n        (0.020663222, 2),\n        (0.031000609, 2),\n        (1.30495e-38, 2),\n        (1.409154e-8, 2),\n        (2.599722e-7, 2),\n        (3.67508e-29, 2),\n    ];\n    let sample_median = (-1.472737e-39, Some(-1.471169e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.190292459186594e-6),\n        standard_deviation: NiceFloat(0.007506907081695582),\n        skewness: NiceFloat(-0.02559343794273501),\n        excess_kurtosis: NiceFloat(84.97988219106435),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        -0.1,\n        0.1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = e, b = π\n    let values = &[\n        2.811021, 3.0798163, 2.8497639, 2.9021935, 3.0803769, 3.0796993, 3.088304, 2.872187,\n        2.8092258, 2.7708528, 3.0054183, 2.7851858, 2.745991, 2.9290476, 2.913056, 2.899723,\n        2.9672115, 2.875196, 3.01054, 3.0299006,\n    ];\n    let common_values = &[\n        (2.7395, 7),\n        (2.7335808, 7),\n        (2.8363338, 7),\n        (3.0879333, 7),\n        (2.760186, 6),\n        (2.799341, 6),\n        (2.933202, 6),\n        (2.978166, 6),\n        (3.012332, 6),\n        (3.034496, 6),\n    ];\n    let sample_median = (2.9301434, Some(2.930144));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9300705904196347),\n        standard_deviation: NiceFloat(0.12218018336191779),\n        skewness: NiceFloat(-0.0024072138827345158),\n        excess_kurtosis: NiceFloat(-1.1980037439170255),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 100.0, b = 101.0\n    let values = &[\n        100.96766, 100.552864, 100.684616, 100.34195, 100.725746, 100.24665, 100.79547, 100.21028,\n        100.7486, 100.09738, 100.360596, 100.518265, 100.83968, 100.47318, 100.16781, 100.6617,\n        100.48242, 100.192245, 100.84114, 100.095436,\n    ];\n    let common_values = &[\n        (100.32666, 22),\n        (100.33122, 22),\n        (100.60651, 22),\n        (100.29688, 21),\n        (100.51455, 21),\n        (100.75446, 21),\n        (100.672554, 21),\n        (100.863556, 21),\n        (100.125, 20),\n        (100.06987, 20),\n    ];\n    let sample_median = (100.50014, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.5000247275421),\n        standard_deviation: NiceFloat(0.2887172501103727),\n        skewness: NiceFloat(0.0005303743867281354),\n        excess_kurtosis: NiceFloat(-1.2019547226159832),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        100.0,\n        101.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 1.0e38, b = Infinity\n    let values = &[\n        1.4647999e38,\n        3.1018272e38,\n        1.582411e38,\n        1.5544886e38,\n        1.5924082e38,\n        2.9619212e38,\n        2.8168304e38,\n        2.9816339e38,\n        1.2098325e38,\n        2.5528384e38,\n        1.0473973e38,\n        2.2168899e38,\n        1.8072246e38,\n        1.732986e38,\n        1.0828477e38,\n        1.3966511e38,\n        2.61352e38,\n        1.6959917e38,\n        1.727243e38,\n        2.8140436e38,\n    ];\n    let common_values = &[\n        (1.223221e38, 4),\n        (1.372136e38, 4),\n        (1.0892582e38, 4),\n        (1.4897022e38, 4),\n        (1.5085965e38, 4),\n        (1.5266252e38, 4),\n        (1.8360457e38, 4),\n        (2.5784374e38, 4),\n        (2.6144523e38, 4),\n        (2.7852527e38, 4),\n    ];\n    let sample_median = (1.8507265e38, Some(1.8507311e38));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0095713198371904e38),\n        standard_deviation: NiceFloat(7.129528670871142e37),\n        skewness: NiceFloat(0.37808793164351623),\n        excess_kurtosis: NiceFloat(-1.168840184381319),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = f32::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        -0.0, -1.0e-45, 1.0e-45, -0.0, 1.0e-45, 1.0e-45, 0.0, 1.0e-45, -0.0, -0.0, -1.0e-45, -0.0,\n        -1.0e-45, 1.0e-45, 0.0, -0.0, -1.0e-45, -0.0, 0.0, 1.0e-45,\n    ];\n    let common_values = &[(-0.0, 250314), (1.0e-45, 250015), (0.0, 249955), (-1.0e-45, 249716)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.18988240833055e-49),\n        standard_deviation: NiceFloat(9.90601474026171e-46),\n        skewness: NiceFloat(-0.00042250825585668007),\n        excess_kurtosis: NiceFloat(-0.9989230633891024),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = f32::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        0.0, -0.0, 0.0, 1.0e-45, 0.0, 0.0, -0.0, 0.0, -0.0, 1.0e-45, 0.0, -0.0, 0.0, 1.0e-45,\n        1.0e-45, -0.0, 0.0, -0.0, 1.0e-45, 1.0e-45,\n    ];\n    let common_values = &[(0.0, 333784), (1.0e-45, 333516), (-0.0, 332700)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.673554586277644e-46),\n        standard_deviation: NiceFloat(6.606692048548519e-46),\n        skewness: NiceFloat(0.7062350975867705),\n        excess_kurtosis: NiceFloat(-1.5012319869365465),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        -0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 0.0, b = 0.0\n    let values = &[0.0; 20];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        0.0,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = -f32::MIN_POSITIVE_SUBNORMAL\n    let values = &[-1.0e-45; 20];\n    let common_values = &[(-1.0e-45, 1000000)];\n    let sample_median = (-1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.401298464324817e-45),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = 0.0\n    let values = &[\n        -0.0, -1.0e-45, -0.0, 0.0, -0.0, -0.0, -1.0e-45, -0.0, -1.0e-45, 0.0, -0.0, -1.0e-45, -0.0,\n        0.0, 0.0, -1.0e-45, -0.0, -1.0e-45, 0.0, 0.0,\n    ];\n    let common_values = &[(-0.0, 333784), (0.0, 333516), (-1.0e-45, 332700)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.662119990808644e-46),\n        standard_deviation: NiceFloat(6.602643154251322e-46),\n        skewness: NiceFloat(-0.7101318209186737),\n        excess_kurtosis: NiceFloat(-1.4957127969187527),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -Infinity, b = Infinity\n    let values = &[\n        -2.3484665e-27,\n        2.2879888e-18,\n        -2.0729896e-12,\n        3.3600117e28,\n        -9.0217234e-32,\n        3564911.0,\n        -0.000013376945,\n        -1.885545e18,\n        8.249455e-29,\n        2.2178013e-38,\n        -6.306773e-34,\n        5.199601e31,\n        7.6132625e33,\n        0.00015323664,\n        9.4768183e36,\n        -0.0005665587,\n        8.873326e-30,\n        0.09273134,\n        -7.774831e33,\n        4.315623e-8,\n    ];\n    let common_values = &[\n        (5.71262, 2),\n        (780.036, 2),\n        (224535.3, 2),\n        (58.67172, 2),\n        (73439.85, 2),\n        (-58.01006, 2),\n        (-66297.15, 2),\n        (-66476.91, 2),\n        (13200.071, 2),\n        (3306.3635, 2),\n    ];\n    let sample_median = (4.601794e-39, Some(4.606577e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.871815997376882e34),\n        standard_deviation: NiceFloat(1.8597574260800838e37),\n        skewness: NiceFloat(-0.04588420234596291),\n        excess_kurtosis: NiceFloat(174.30920609573673),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = -0.0\n    let values = &[-0.0; 20];\n    let common_values = &[(-0.0, 1000000)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f32>(\n        -0.0,\n        -0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0, b = 2.0\n    let values = &[\n        1.5514873723431857,\n        1.027857700733222,\n        1.0138546387920868,\n        1.3122324563791183,\n        1.3405051829686652,\n        1.035872192413254,\n        1.1044047458079171,\n        1.1492076100807012,\n        1.6654435140088601,\n        1.0970321240173933,\n        1.7768534778894969,\n        1.7596944738316886,\n        1.4195592641558248,\n        1.6870312410839399,\n        1.6389477926482805,\n        1.7596601473487807,\n        1.5802838577448093,\n        1.6118733984422406,\n        1.6845629053029185,\n        1.7184068862055195,\n    ];\n    let common_values = &[\n        (1.403773233, 1),\n        (1.4279826281, 1),\n        (1.00013172472, 1),\n        (1.12691284792, 1),\n        (1.18903919511, 1),\n        (1.19748472183, 1),\n        (1.22623118845, 1),\n        (1.28755110409, 1),\n        (1.29488660814, 1),\n        (1.29653599853, 1),\n    ];\n    let sample_median = (1.5009930608108493, Some(1.5009982675741425));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5004909167990677),\n        standard_deviation: NiceFloat(0.288665614327161),\n        skewness: NiceFloat(-0.0026087726173027),\n        excess_kurtosis: NiceFloat(-1.199166529481062),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        1.0,\n        2.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.1, b = 0.1\n    let values = &[\n        -7.283095678343042e-164,\n        4.085787276271492e-169,\n        -1.6885972585325658e-191,\n        -1.5059586906723643e-66,\n        -6.637230143944272e-36,\n        2.0111059084569595e-54,\n        -3.2171834547379634e-195,\n        -1.4304898186595632e-260,\n        -5.910214544689135e-300,\n        4.248352948466203e-63,\n        -3.6882240870537675e-31,\n        8.12900376877632e-277,\n        8.630695763640745e-286,\n        -2.7842211494385523e-123,\n        -4.271131813514248e-164,\n        1.613930919542087e-167,\n        -5.39182068994581e-107,\n        -1.4532461060667818e-9,\n        -1.9793582955127234e-289,\n        5.420373932282823e-196,\n    ];\n    let common_values = &[\n        (5.62015686679e-6, 1),\n        (-0.09576016351376, 1),\n        (-3.9141428595e-60, 1),\n        (-4.5355157777e-28, 1),\n        (0.008342058495796, 1),\n        (0.012335893098144, 1),\n        (0.014079819535342, 1),\n        (0.014718940078426, 1),\n        (0.031741597598458, 1),\n        (0.033991243007763, 1),\n    ];\n    let sample_median = (1.566509212534917e-309, Some(1.56863192120459e-309));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.4695816858634463e-7),\n        standard_deviation: NiceFloat(0.002635102953882735),\n        skewness: NiceFloat(0.27772415900587566),\n        excess_kurtosis: NiceFloat(707.152044677798),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        -0.1,\n        0.1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = e, b = π\n    let values = &[\n        2.8212565731454164,\n        3.103466176726195,\n        2.888459041537496,\n        2.94833744629582,\n        2.9285662350147255,\n        3.059002590500268,\n        2.808432051804475,\n        3.077033595571352,\n        3.0898242789403123,\n        3.093937352570613,\n        2.7596383425151814,\n        3.1049928702292573,\n        2.7453107067232327,\n        3.0779370799622736,\n        2.9748071250720396,\n        2.927927166467895,\n        2.81511226878185,\n        2.928920013122519,\n        2.964625285981546,\n        3.046598518604858,\n    ];\n    let common_values = &[\n        (2.7683806707, 1),\n        (2.8058681766, 1),\n        (2.8522842725, 1),\n        (2.8873246989, 1),\n        (2.72492950364, 1),\n        (2.73164898148, 1),\n        (2.73476073924, 1),\n        (2.73598990929, 1),\n        (2.73653142351, 1),\n        (2.74563905301, 1),\n    ];\n    let sample_median = (2.930132942011006, Some(2.9301336276615912));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.929964069913902),\n        standard_deviation: NiceFloat(0.12226749948876238),\n        skewness: NiceFloat(-0.0013881669668324012),\n        excess_kurtosis: NiceFloat(-1.2003731669148405),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 100.0, b = 101.0\n    let values = &[\n        100.60719315639041,\n        100.52293238466861,\n        100.39773606616421,\n        100.15849325452957,\n        100.62446491275823,\n        100.00756963969552,\n        100.87724201202582,\n        100.41761898323166,\n        100.61748356221035,\n        100.19203505270988,\n        100.00337267247278,\n        100.15603343751732,\n        100.23002386168925,\n        100.77135404787671,\n        100.23327285882462,\n        100.27432542366292,\n        100.63224218858957,\n        100.47879402977489,\n        100.50368945395086,\n        100.4540267175569,\n    ];\n    let common_values = &[\n        (100.49174834, 1),\n        (100.95678412, 1),\n        (100.029622688, 1),\n        (100.110761848, 1),\n        (100.163351429, 1),\n        (100.241016737, 1),\n        (100.334091318, 1),\n        (100.374320788, 1),\n        (100.375142847, 1),\n        (100.403842534, 1),\n    ];\n    let sample_median = (100.49938135068814, Some(100.49938267498312));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.49957670089151),\n        standard_deviation: NiceFloat(0.28876054194108447),\n        skewness: NiceFloat(0.00047268031818767473),\n        excess_kurtosis: NiceFloat(-1.2008323763153763),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        100.0,\n        101.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0e38, b = Infinity\n    let values = &[\n        1.3219190533477493e200,\n        3.652437632585123e180,\n        2.0420353527516904e248,\n        2.505458962964126e276,\n        2.659899792371364e116,\n        2.7125386559147274e90,\n        9.536479965391043e185,\n        9.567216720381635e239,\n        5.16993041287954e245,\n        4.939547529284952e179,\n        3.1175116898205872e224,\n        1.7555281884088452e42,\n        5.429209768108731e84,\n        1.0447670959436904e299,\n        1.9580250342195754e105,\n        8.848423533619703e204,\n        3.4434065546244285e79,\n        3.6093218170205304e216,\n        8.464035133686624e293,\n        1.22423660941592e120,\n    ];\n    let common_values = &[\n        (2.141438721e116, 1),\n        (8.7676954155e86, 1),\n        (1.28439118539e55, 1),\n        (1.79171075176e53, 1),\n        (2.10333657725e74, 1),\n        (2.3236426209e231, 1),\n        (2.95823857742e58, 1),\n        (3.1078914828e141, 1),\n        (3.38975629714e61, 1),\n        (4.28790184556e74, 1),\n    ];\n    let sample_median = (1.2523958970084127e173, Some(1.2542732495420994e173));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.939399538027295e305),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        1.0e38,\n        f64::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = f64::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        -0.0, -5.0e-324, 5.0e-324, -0.0, 5.0e-324, 5.0e-324, 0.0, 5.0e-324, -0.0, -0.0, -5.0e-324,\n        -0.0, -5.0e-324, 5.0e-324, 0.0, -0.0, -5.0e-324, -0.0, 0.0, 5.0e-324,\n    ];\n    let common_values = &[(-0.0, 250314), (5.0e-324, 250015), (0.0, 249955), (-5.0e-324, 249716)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = f64::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        0.0, -0.0, 0.0, 5.0e-324, 0.0, 0.0, -0.0, 0.0, -0.0, 5.0e-324, 0.0, -0.0, 0.0, 5.0e-324,\n        5.0e-324, -0.0, 0.0, -0.0, 5.0e-324, 5.0e-324,\n    ];\n    let common_values = &[(0.0, 333784), (5.0e-324, 333516), (-0.0, 332700)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        -0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 0.0, b = 0.0\n    let values = &[0.0; 20];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        0.0,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = -f64::MIN_POSITIVE_SUBNORMAL\n    let values = &[-5.0e-324; 20];\n    let common_values = &[(-5.0e-324, 1000000)];\n    let sample_median = (-5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = 0.0\n    let values = &[\n        -0.0, -5.0e-324, -0.0, 0.0, -0.0, -0.0, -5.0e-324, -0.0, -5.0e-324, 0.0, -0.0, -5.0e-324,\n        -0.0, 0.0, 0.0, -5.0e-324, -0.0, -5.0e-324, 0.0, 0.0,\n    ];\n    let common_values = &[(-0.0, 333784), (0.0, 333516), (-5.0e-324, 332700)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -Infinity, b = Infinity\n    let values = &[\n        3.106206640558341e-146,\n        7.268713316268921e223,\n        1.1685126708702852e48,\n        -1.0824685183946236e146,\n        3.114605160661583e-306,\n        2.2453015573637674e249,\n        1.2548860979388685e-35,\n        -8.287939157477947e-27,\n        2.1255041535787165e-13,\n        4.815129234795048e-64,\n        1.3850402674408148e-17,\n        -1.253571770758962e207,\n        -1.4941028004491906e142,\n        4.366611961454907e-51,\n        -7.063699168119985e17,\n        -7.062565582436957e90,\n        1.1662950933663382e-221,\n        2.1976577668343592e-97,\n        -2.8212944266870196e-137,\n        1.2250916338748408e-222,\n    ];\n    let common_values = &[\n        (-9967188.16722, 1),\n        (1808.830612999, 1),\n        (32578528203.69, 1),\n        (5643444.695113, 1),\n        (812845035127.8, 1),\n        (-13741970740.45, 1),\n        (-1434325.082519, 1),\n        (-33781527.93352, 1),\n        (-374012916597.5, 1),\n        (-46629353341.91, 1),\n    ];\n    let sample_median = (2.772306592172272e-308, Some(2.7820731194979217e-308));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.922018643581038e303),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = 0.0\n    let values = &[\n        0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0,\n        -0.0, 0.0, -0.0,\n    ];\n    let common_values = &[(0.0, 500473), (-0.0, 499527)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_inclusive_range_helper::<f64>(\n        -0.0,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn random_primitive_float_inclusive_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ZERO\n    ));\n    assert_panic!(random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::NAN\n    ));\n}\n\n#[test]\nfn random_primitive_float_inclusive_range_fail() {\n    apply_fn_to_primitive_floats!(random_primitive_float_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_primitive_float_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_primitive_float_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn random_primitive_float_range_helper<T: CheckedToF64 + PrimitiveFloat>(\n    a: T,\n    b: T,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_primitive_float_range::<T>(EXAMPLE_SEED, a, b),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_primitive_float_range() {\n    // f32, a = 1.0, b = 2.0\n    let values = &[\n        1.5463697, 1.2951918, 1.7384838, 1.2143862, 1.1419607, 1.0917295, 1.7257521, 1.849941,\n        1.1442195, 1.363777, 1.052571, 1.0717841, 1.9104315, 1.3754328, 1.590667, 1.0705026,\n        1.8980603, 1.8630176, 1.0212592, 1.3380667,\n    ];\n    let common_values = &[\n        (1.9376882, 5),\n        (1.012385, 4),\n        (1.439915, 4),\n        (1.709473, 4),\n        (1.754993, 4),\n        (1.944844, 4),\n        (1.971242, 4),\n        (1.978845, 4),\n        (1.0289025, 4),\n        (1.0466498, 4),\n    ];\n    let sample_median = (1.499921, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.49979057649457),\n        standard_deviation: NiceFloat(0.2887387766808365),\n        skewness: NiceFloat(0.0002622267624830283),\n        excess_kurtosis: NiceFloat(-1.1997935828388204),\n    };\n    random_primitive_float_range_helper::<f32>(\n        1.0,\n        2.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.1, b = 0.1\n    let values = &[\n        5.664681e-11,\n        1.2492925e-35,\n        2.3242339e-29,\n        4.699183e-7,\n        -2.8244436e-36,\n        -2.264039e-37,\n        -0.0000017299129,\n        1.40616e-23,\n        2.7418007e-27,\n        1.5418819e-16,\n        -1.8473076e-36,\n        -2.4935917e-21,\n        -3.373897e-37,\n        -7.5386525e-15,\n        -2.2595721e-7,\n        -8.293393e-39,\n        0.0025248893,\n        1.1819218e-25,\n        2.3384073e-23,\n        3.1464167e-24,\n    ];\n    let common_values = &[\n        (0.02590246, 2),\n        (-0.09233444, 2),\n        (0.001610253, 2),\n        (0.010553952, 2),\n        (0.020663222, 2),\n        (0.031000609, 2),\n        (1.30495e-38, 2),\n        (1.409154e-8, 2),\n        (2.599722e-7, 2),\n        (3.67508e-29, 2),\n    ];\n    let sample_median = (-1.472737e-39, Some(-1.471169e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.190292459186594e-6),\n        standard_deviation: NiceFloat(0.007506907081695582),\n        skewness: NiceFloat(-0.02559343794273501),\n        excess_kurtosis: NiceFloat(84.97988219106435),\n    };\n    random_primitive_float_range_helper::<f32>(\n        -0.1,\n        0.1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = e, b = π\n    let values = &[\n        2.811021, 3.0798163, 2.8497639, 2.9021935, 3.0803769, 3.0796993, 3.088304, 2.872187,\n        2.8092258, 2.7708528, 3.0054183, 2.7851858, 2.745991, 2.9290476, 2.913056, 2.899723,\n        2.9672115, 2.875196, 3.01054, 3.0299006,\n    ];\n    let common_values = &[\n        (2.7395, 7),\n        (2.7335808, 7),\n        (2.8363338, 7),\n        (3.0879333, 7),\n        (2.760186, 6),\n        (2.799341, 6),\n        (2.933202, 6),\n        (2.978166, 6),\n        (3.012332, 6),\n        (3.034496, 6),\n    ];\n    let sample_median = (2.9301434, Some(2.930144));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9300705904196347),\n        standard_deviation: NiceFloat(0.12218018336191779),\n        skewness: NiceFloat(-0.0024072138827345158),\n        excess_kurtosis: NiceFloat(-1.1980037439170255),\n    };\n    random_primitive_float_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 100.0, b = 101.0\n    let values = &[\n        100.96766, 100.10573, 100.102974, 100.47697, 100.441444, 100.94259, 100.696365, 100.36691,\n        100.79254, 100.435005, 100.23124, 100.153755, 100.25385, 100.64986, 100.26314, 100.148544,\n        100.28187, 100.3743, 100.18771, 100.901344,\n    ];\n    let common_values = &[\n        (100.15877, 24),\n        (100.081535, 22),\n        (100.26679, 21),\n        (100.56587, 21),\n        (100.894196, 21),\n        (100.3593, 20),\n        (100.4054, 20),\n        (100.30979, 20),\n        (100.45853, 20),\n        (100.49529, 20),\n    ];\n    let sample_median = (100.50088, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.50054111846543),\n        standard_deviation: NiceFloat(0.2888116297082562),\n        skewness: NiceFloat(-0.003221278138738849),\n        excess_kurtosis: NiceFloat(-1.2016989304148467),\n    };\n    random_primitive_float_range_helper::<f32>(\n        100.0,\n        101.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 1.0e38, b = Infinity\n    let values = &[\n        1.4647999e38,\n        3.1018272e38,\n        1.582411e38,\n        1.5544886e38,\n        1.5924082e38,\n        2.9619212e38,\n        2.8168304e38,\n        2.9816339e38,\n        1.2098325e38,\n        2.5528384e38,\n        1.0473973e38,\n        2.2168899e38,\n        1.8072246e38,\n        1.732986e38,\n        1.0828477e38,\n        1.3966511e38,\n        2.61352e38,\n        1.6959917e38,\n        1.727243e38,\n        2.8140436e38,\n    ];\n    let common_values = &[\n        (1.223221e38, 4),\n        (1.372136e38, 4),\n        (1.0892582e38, 4),\n        (1.4897022e38, 4),\n        (1.5085965e38, 4),\n        (1.5266252e38, 4),\n        (1.8360457e38, 4),\n        (2.5784374e38, 4),\n        (2.6144523e38, 4),\n        (2.7852527e38, 4),\n    ];\n    let sample_median = (1.8507265e38, Some(1.8507311e38));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0095713198371904e38),\n        standard_deviation: NiceFloat(7.129528670871142e37),\n        skewness: NiceFloat(0.37808793164351623),\n        excess_kurtosis: NiceFloat(-1.168840184381319),\n    };\n    random_primitive_float_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = f32::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        -0.0, -1.0e-45, -0.0, 0.0, -0.0, -0.0, -1.0e-45, -0.0, -1.0e-45, 0.0, -0.0, -1.0e-45, -0.0,\n        0.0, 0.0, -1.0e-45, -0.0, -1.0e-45, 0.0, 0.0,\n    ];\n    let common_values = &[(-0.0, 333784), (0.0, 333516), (-1.0e-45, 332700)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.662119990808644e-46),\n        standard_deviation: NiceFloat(6.602643154251322e-46),\n        skewness: NiceFloat(-0.7101318209186737),\n        excess_kurtosis: NiceFloat(-1.4957127969187527),\n    };\n    random_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = f32::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0,\n        -0.0, 0.0, -0.0,\n    ];\n    let common_values = &[(0.0, 500473), (-0.0, 499527)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f32>(\n        -0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 0.0, b = f32::MIN_POSITIVE_SUBNORMAL\n    let values = &[0.0; 20];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f32>(\n        0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = -0.0\n    let values = &[-1.0e-45; 20];\n    let common_values = &[(-1.0e-45, 1000000)];\n    let sample_median = (-1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.401298464324817e-45),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = 0.0\n    let values = &[\n        -0.0, -1.0e-45, -1.0e-45, -1.0e-45, -0.0, -0.0, -0.0, -1.0e-45, -0.0, -0.0, -0.0, -0.0,\n        -1.0e-45, -0.0, -0.0, -0.0, -0.0, -1.0e-45, -0.0, -1.0e-45,\n    ];\n    let common_values = &[(-0.0, 500473), (-1.0e-45, 499527)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-6.9998641798878095e-46),\n        standard_deviation: NiceFloat(7.006492689759787e-46),\n        skewness: NiceFloat(-0.0018920008465908337),\n        excess_kurtosis: NiceFloat(-1.9999964203328955),\n    };\n    random_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -Infinity, b = Infinity\n    let values = &[\n        -2.3484665e-27,\n        2.2879888e-18,\n        -2.0729896e-12,\n        3.3600117e28,\n        -9.0217234e-32,\n        3564911.0,\n        -0.000013376945,\n        -1.885545e18,\n        8.249455e-29,\n        2.2178013e-38,\n        -6.306773e-34,\n        5.199601e31,\n        7.6132625e33,\n        0.00015323664,\n        9.4768183e36,\n        -0.0005665587,\n        8.873326e-30,\n        0.09273134,\n        -7.774831e33,\n        4.315623e-8,\n    ];\n    let common_values = &[\n        (5.71262, 2),\n        (780.036, 2),\n        (224535.3, 2),\n        (58.67172, 2),\n        (73439.85, 2),\n        (-58.01006, 2),\n        (-66297.15, 2),\n        (-66476.91, 2),\n        (13200.071, 2),\n        (3306.3635, 2),\n    ];\n    let sample_median = (4.601794e-39, Some(4.606577e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.871815997376882e34),\n        standard_deviation: NiceFloat(1.8597574260800838e37),\n        skewness: NiceFloat(-0.04588420234596291),\n        excess_kurtosis: NiceFloat(174.30920609573673),\n    };\n    random_primitive_float_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = 0.0\n    let values = &[-0.0; 20];\n    let common_values = &[(-0.0, 1000000)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f32>(\n        -0.0,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0, b = 2.0\n    let values = &[\n        1.5514873723431857,\n        1.7356480435333936,\n        1.2240680379087014,\n        1.5721098095143498,\n        1.445723211731554,\n        1.443348441346778,\n        1.128043347677334,\n        1.9657544165271619,\n        1.259133073045527,\n        1.9463717627559034,\n        1.827615676661706,\n        1.3546147198266414,\n        1.3547277462886724,\n        1.6644379935168552,\n        1.7300004987549573,\n        1.1347106338290753,\n        1.6337434960012935,\n        1.9398684976828995,\n        1.5480087631774717,\n        1.5114010060819247,\n    ];\n    let common_values = &[\n        (1.3443697926, 1),\n        (1.3820769412, 1),\n        (1.4136496448, 1),\n        (1.05230401048, 1),\n        (1.06345642396, 1),\n        (1.08636222403, 1),\n        (1.08890959097, 1),\n        (1.10364420294, 1),\n        (1.17100333598, 1),\n        (1.21003284406, 1),\n    ];\n    let sample_median = (1.4997587655631748, Some(1.4997590736389839));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5002317198585347),\n        standard_deviation: NiceFloat(0.2886284765385832),\n        skewness: NiceFloat(0.0005691088300059665),\n        excess_kurtosis: NiceFloat(-1.1997562526471726),\n    };\n    random_primitive_float_range_helper::<f64>(\n        1.0,\n        2.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.1, b = 0.1\n    let values = &[\n        -7.283095678343042e-164,\n        4.085787276271492e-169,\n        -1.6885972585325658e-191,\n        -1.5059586906723643e-66,\n        -6.637230143944272e-36,\n        2.0111059084569595e-54,\n        -3.2171834547379634e-195,\n        -1.4304898186595632e-260,\n        -5.910214544689135e-300,\n        4.248352948466203e-63,\n        -3.6882240870537675e-31,\n        8.12900376877632e-277,\n        8.630695763640745e-286,\n        -2.7842211494385523e-123,\n        -4.271131813514248e-164,\n        1.613930919542087e-167,\n        -5.39182068994581e-107,\n        -1.4532461060667818e-9,\n        -1.9793582955127234e-289,\n        5.420373932282823e-196,\n    ];\n    let common_values = &[\n        (5.62015686679e-6, 1),\n        (-0.09576016351376, 1),\n        (-3.9141428595e-60, 1),\n        (-4.5355157777e-28, 1),\n        (0.008342058495796, 1),\n        (0.012335893098144, 1),\n        (0.014079819535342, 1),\n        (0.014718940078426, 1),\n        (0.031741597598458, 1),\n        (0.033991243007763, 1),\n    ];\n    let sample_median = (1.566509212534917e-309, Some(1.56863192120459e-309));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.4695816858634463e-7),\n        standard_deviation: NiceFloat(0.002635102953882735),\n        skewness: NiceFloat(0.27772415900587566),\n        excess_kurtosis: NiceFloat(707.152044677798),\n    };\n    random_primitive_float_range_helper::<f64>(\n        -0.1,\n        0.1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = e, b = π\n    let values = &[\n        2.8212565731454164,\n        3.103466176726195,\n        2.888459041537496,\n        2.94833744629582,\n        2.9285662350147255,\n        3.059002590500268,\n        2.808432051804475,\n        3.077033595571352,\n        3.0898242789403123,\n        3.093937352570613,\n        2.7596383425151814,\n        3.1049928702292573,\n        2.7453107067232327,\n        3.0779370799622736,\n        2.9748071250720396,\n        2.927927166467895,\n        2.81511226878185,\n        2.928920013122519,\n        2.964625285981546,\n        3.046598518604858,\n    ];\n    let common_values = &[\n        (2.7683806707, 1),\n        (2.8058681766, 1),\n        (2.8522842725, 1),\n        (2.8873246989, 1),\n        (2.72492950364, 1),\n        (2.73164898148, 1),\n        (2.73476073924, 1),\n        (2.73598990929, 1),\n        (2.73653142351, 1),\n        (2.74563905301, 1),\n    ];\n    let sample_median = (2.930132942011006, Some(2.9301336276615912));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.929964069913902),\n        standard_deviation: NiceFloat(0.12226749948876238),\n        skewness: NiceFloat(-0.0013881669668324012),\n        excess_kurtosis: NiceFloat(-1.2003731669148405),\n    };\n    random_primitive_float_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 100.0, b = 101.0\n    let values = &[\n        100.29519182996388,\n        100.21438631278083,\n        100.09172953867444,\n        100.84994110175992,\n        100.36377705862755,\n        100.07178414494646,\n        100.37543295746225,\n        100.07050270922983,\n        100.86301766610865,\n        100.33806669965496,\n        100.35496099272225,\n        100.93577122524063,\n        100.00524419289253,\n        100.29363379918549,\n        100.98421354539467,\n        100.68228296091216,\n        100.93250012468873,\n        100.1553701412652,\n        100.95333990532461,\n        100.2218641465098,\n    ];\n    let common_values = &[\n        (100.10137554, 1),\n        (100.34387327, 1),\n        (100.223865218, 1),\n        (100.237336607, 1),\n        (100.241016737, 1),\n        (100.358275298, 1),\n        (100.490668361, 1),\n        (100.563824325, 1),\n        (100.567992111, 1),\n        (100.619353436, 1),\n    ];\n    let sample_median = (100.49999381186375, Some(100.49999461609349));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.4998603968099),\n        standard_deviation: NiceFloat(0.28878031747138194),\n        skewness: NiceFloat(-0.00018856944159801264),\n        excess_kurtosis: NiceFloat(-1.2006169795569301),\n    };\n    random_primitive_float_range_helper::<f64>(\n        100.0,\n        101.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0e38, b = Infinity\n    let values = &[\n        1.3219190533477493e200,\n        3.652437632585123e180,\n        2.0420353527516904e248,\n        2.505458962964126e276,\n        2.659899792371364e116,\n        2.7125386559147274e90,\n        9.536479965391043e185,\n        9.567216720381635e239,\n        5.16993041287954e245,\n        4.939547529284952e179,\n        3.1175116898205872e224,\n        1.7555281884088452e42,\n        5.429209768108731e84,\n        1.0447670959436904e299,\n        1.9580250342195754e105,\n        8.848423533619703e204,\n        3.4434065546244285e79,\n        3.6093218170205304e216,\n        8.464035133686624e293,\n        1.22423660941592e120,\n    ];\n    let common_values = &[\n        (2.141438721e116, 1),\n        (8.7676954155e86, 1),\n        (1.28439118539e55, 1),\n        (1.79171075176e53, 1),\n        (2.10333657725e74, 1),\n        (2.3236426209e231, 1),\n        (2.95823857742e58, 1),\n        (3.1078914828e141, 1),\n        (3.38975629714e61, 1),\n        (4.28790184556e74, 1),\n    ];\n    let sample_median = (1.2523958970084127e173, Some(1.2542732495420994e173));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.939399538027295e305),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        1.0e38,\n        f64::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = f64::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        -0.0, -5.0e-324, -0.0, 0.0, -0.0, -0.0, -5.0e-324, -0.0, -5.0e-324, 0.0, -0.0, -5.0e-324,\n        -0.0, 0.0, 0.0, -5.0e-324, -0.0, -5.0e-324, 0.0, 0.0,\n    ];\n    let common_values = &[(-0.0, 333784), (0.0, 333516), (-5.0e-324, 332700)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = f64::MIN_POSITIVE_SUBNORMAL\n    let values = &[\n        0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0,\n        -0.0, 0.0, -0.0,\n    ];\n    let common_values = &[(0.0, 500473), (-0.0, 499527)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        -0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 0.0, b = f64::MIN_POSITIVE_SUBNORMAL\n    let values = &[0.0; 20];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = -0.0\n    let values = &[-5.0e-324; 20];\n    let common_values = &[(-5.0e-324, 1000000)];\n    let sample_median = (-5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = 0.0\n    let values = &[\n        -0.0, -5.0e-324, -5.0e-324, -5.0e-324, -0.0, -0.0, -0.0, -5.0e-324, -0.0, -0.0, -0.0, -0.0,\n        -5.0e-324, -0.0, -0.0, -0.0, -0.0, -5.0e-324, -0.0, -5.0e-324,\n    ];\n    let common_values = &[(-0.0, 500473), (-5.0e-324, 499527)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -Infinity, b = Infinity\n    let values = &[\n        3.106206640558341e-146,\n        7.268713316268921e223,\n        1.1685126708702852e48,\n        -1.0824685183946236e146,\n        3.114605160661583e-306,\n        2.2453015573637674e249,\n        1.2548860979388685e-35,\n        -8.287939157477947e-27,\n        2.1255041535787165e-13,\n        4.815129234795048e-64,\n        1.3850402674408148e-17,\n        -1.253571770758962e207,\n        -1.4941028004491906e142,\n        4.366611961454907e-51,\n        -7.063699168119985e17,\n        -7.062565582436957e90,\n        1.1662950933663382e-221,\n        2.1976577668343592e-97,\n        -2.8212944266870196e-137,\n        1.2250916338748408e-222,\n    ];\n    let common_values = &[\n        (-9967188.16722, 1),\n        (1808.830612999, 1),\n        (32578528203.69, 1),\n        (5643444.695113, 1),\n        (812845035127.8, 1),\n        (-13741970740.45, 1),\n        (-1434325.082519, 1),\n        (-33781527.93352, 1),\n        (-374012916597.5, 1),\n        (-46629353341.91, 1),\n    ];\n    let sample_median = (2.772306592172272e-308, Some(2.7820731194979217e-308));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.922018643581038e303),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = 0.0\n    let values = &[-0.0; 20];\n    let common_values = &[(-0.0, 1000000)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_float_range_helper::<f64>(\n        -0.0,\n        0.0,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn random_primitive_float_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ZERO,\n        T::ZERO\n    ));\n    assert_panic!(random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ZERO\n    ));\n    assert_panic!(random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::NAN\n    ));\n}\n\n#[test]\nfn random_primitive_float_range_fail() {\n    apply_fn_to_primitive_floats!(random_primitive_float_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\n\nfn random_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    random_primitive_floats_helper_helper(\n        random_primitive_floats::<T>(EXAMPLE_SEED),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_primitive_floats() {\n    // f32\n    let values = &[\n        -2.3484665e-27,\n        2.2879888e-18,\n        -2.0729896e-12,\n        3.3600117e28,\n        -9.0217234e-32,\n        3564911.0,\n        -0.000013376945,\n        -1.885545e18,\n        8.249455e-29,\n        2.2178013e-38,\n        -6.306773e-34,\n        5.199601e31,\n        7.6132625e33,\n        0.00015323664,\n        9.4768183e36,\n        -0.0005665587,\n        8.873326e-30,\n        0.09273134,\n        -7.774831e33,\n        4.315623e-8,\n    ];\n    let common_values = &[\n        (5.71262, 2),\n        (780.036, 2),\n        (224535.3, 2),\n        (58.67172, 2),\n        (73439.85, 2),\n        (-58.01006, 2),\n        (-66297.15, 2),\n        (-66476.91, 2),\n        (13200.071, 2),\n        (3306.3635, 2),\n    ];\n    let sample_median = (4.601794e-39, Some(4.606577e-39));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.871815997376882e34),\n        standard_deviation: NiceFloat(1.8597574260800838e37),\n        skewness: NiceFloat(-0.04588420234596291),\n        excess_kurtosis: NiceFloat(174.30920609573673),\n    };\n    random_primitive_floats_helper::<f32>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64\n    let values = &[\n        3.106206640558341e-146,\n        7.268713316268921e223,\n        1.1685126708702852e48,\n        -1.0824685183946236e146,\n        3.114605160661583e-306,\n        2.2453015573637674e249,\n        1.2548860979388685e-35,\n        -8.287939157477947e-27,\n        2.1255041535787165e-13,\n        4.815129234795048e-64,\n        1.3850402674408148e-17,\n        -1.253571770758962e207,\n        -1.4941028004491906e142,\n        4.366611961454907e-51,\n        -7.063699168119985e17,\n        -7.062565582436957e90,\n        1.1662950933663382e-221,\n        2.1976577668343592e-97,\n        -2.8212944266870196e-137,\n        1.2250916338748408e-222,\n    ];\n    let common_values = &[\n        (-9967188.16722, 1),\n        (1808.830612999, 1),\n        (32578528203.69, 1),\n        (5643444.695113, 1),\n        (812845035127.8, 1),\n        (-13741970740.45, 1),\n        (-1434325.082519, 1),\n        (-33781527.93352, 1),\n        (-374012916597.5, 1),\n        (-46629353341.91, 1),\n    ];\n    let sample_median = (2.772306592172272e-308, Some(2.7820731194979217e-308));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.922018643581038e303),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_primitive_floats_helper::<f64>(\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_primitive_ints.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\n\nfn random_primitive_ints_helper<T: CheckedToF64 + PrimitiveInt>(\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_primitive_ints(EXAMPLE_SEED),\n        T::MIN,\n        T::MAX,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_primitive_ints() {\n    // u8\n    let values = &[\n        113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149, 115,\n    ];\n    let common_values = &[\n        (214, 4097),\n        (86, 4078),\n        (166, 4049),\n        (22, 4048),\n        (126, 4047),\n        (55, 4040),\n        (93, 4037),\n        (191, 4036),\n        (36, 4035),\n        (42, 4032),\n    ];\n    let pop_median = (127, Some(128));\n    let sample_median = (127, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(127.5),\n        standard_deviation: NiceFloat(73.90027063549903),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.200036621652552),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.4588370000015),\n        standard_deviation: NiceFloat(73.908735397844),\n        skewness: NiceFloat(0.0004407839380447086),\n        excess_kurtosis: NiceFloat(-1.200418003526934),\n    };\n    random_primitive_ints_helper::<u8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16\n    let values = &[\n        61297, 27717, 53988, 41384, 8279, 21358, 8892, 61017, 51293, 29589, 38333, 51673, 37493,\n        18463, 43415, 8622, 9735, 36945, 32584, 32881,\n    ];\n    let common_values = &[\n        (27447, 34),\n        (5606, 33),\n        (5836, 33),\n        (50513, 33),\n        (64638, 33),\n        (3582, 32),\n        (19279, 32),\n        (20588, 32),\n        (27377, 32),\n        (40163, 32),\n    ];\n    let pop_median = (32767, Some(32768));\n    let sample_median = (32764, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(32767.5),\n        standard_deviation: NiceFloat(18918.61361860324),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000000005587934),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(32768.5946480003),\n        standard_deviation: NiceFloat(18919.97151989925),\n        skewness: NiceFloat(0.00005872108073206368),\n        excess_kurtosis: NiceFloat(-1.200244178722062),\n    };\n    random_primitive_ints_helper::<u16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32\n    let values = &[\n        1816522609, 2712195812, 1399726167, 3998819004, 1939195997, 3386480061, 1210028661,\n        565094807, 2421237255, 2154921800, 1999530985, 4087616012, 4147883634, 3097538087,\n        4234421608, 1164671716, 2394159346, 3174951407, 130045419, 2998491848,\n    ];\n    let common_values = &[\n        (20095656, 2),\n        (29107328, 2),\n        (83328146, 2),\n        (96543416, 2),\n        (109257003, 2),\n        (132308363, 2),\n        (140940582, 2),\n        (168698132, 2),\n        (182460287, 2),\n        (184573980, 2),\n    ];\n    let pop_median = (2147483647, Some(2147483648));\n    let sample_median = (2150296456, Some(2150302375));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(2147483647.5),\n        standard_deviation: NiceFloat(1239850262.2531195),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2148696150.6876254),\n        standard_deviation: NiceFloat(1239453907.667566),\n        skewness: NiceFloat(-0.0016842295222180032),\n        excess_kurtosis: NiceFloat(-1.2007050556559806),\n    };\n    random_primitive_ints_helper::<u32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64\n    let values = &[\n        11648792314704686961,\n        17174796846203019351,\n        14544821112490281053,\n        2427063716414460533,\n        9255318658858690055,\n        17556177092145474537,\n        13303824785927286386,\n        5002226935030621544,\n        13636312461848344818,\n        12878424424612648427,\n        13573831502926905428,\n        1513424385005459611,\n        2484972586252155822,\n        13072300245601619293,\n        4344958725064805398,\n        3252798961345668310,\n        10520651756201345771,\n        12379844438588545665,\n        6654913321726770291,\n        10505868200830584967,\n    ];\n    let common_values = &[\n        (26914038281329, 1),\n        (32553719576594, 1),\n        (53892651831494, 1),\n        (66354421349686, 1),\n        (86226284907602, 1),\n        (89837182726049, 1),\n        (95691351770484, 1),\n        (166741761063383, 1),\n        (171574734234584, 1),\n        (212518263578065, 1),\n    ];\n    let pop_median = (9223372036854775807, Some(9223372036854775808));\n    let sample_median = (9228795451400314170, Some(9228799993322832549));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(9.223372036854776e18),\n        standard_deviation: NiceFloat(5.325116328314171e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.223151767642118e18),\n        standard_deviation: NiceFloat(5.323459825978695e18),\n        skewness: NiceFloat(-0.0007960342667556958),\n        excess_kurtosis: NiceFloat(-1.2005689675667335),\n    };\n    random_primitive_ints_helper::<u64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u128\n    let values = &[\n        316819081939861044636107404782286008177,\n        44771423227283929645271838218448652381,\n        323854305731529921104946490224673891847,\n        92274800069126412258941638023956901490,\n        237564999433439714567249110498266052850,\n        27917752305106984883503397141734686804,\n        241141377085303586778938998836817083310,\n        60003549963171791765607325839025294358,\n        228367822030979405869278360636891890411,\n        193799061972845222683167418018286926963,\n        186696208941218647968078823625188059421,\n        33018320828004690757952445968579104952,\n        24887066387352849554815992782110776358,\n        79085537771456044427857440036467563654,\n        19637669411666889498466854442215856999,\n        237587532320755783035907621678835821469,\n        254983837845695498020527357238650572551,\n        272337383097469374367899988789175779695,\n        105189689748742230503365861545668092951,\n        258427395460299182237257690021561141080,\n    ];\n    let common_values = &[\n        (68570815139656170990830410045915, 1),\n        (381682482227926990846204728028719, 1),\n        (565207126752383841908924745713103, 1),\n        (717866653939818807939025508430762, 1),\n        (775173738585689418081884794376186, 1),\n        (818497230601034032775791540657915, 1),\n        (1224023028796761386468452212527255, 1),\n        (1379103576141836593923341631562888, 1),\n        (1765193876177447622538546939111747, 1),\n        (2049979073093489039458791025727172, 1),\n    ];\n    let pop_median = (\n        170141183460469231731687303715884105727,\n        Some(170141183460469231731687303715884105728),\n    );\n    let sample_median = (\n        170151864710150847082485192587168481404,\n        Some(170151925651660504506169909296979843840),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.7014118346046923e38),\n        standard_deviation: NiceFloat(9.82310580711434e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.702375633317502e38),\n        standard_deviation: NiceFloat(9.815169783582294e37),\n        skewness: NiceFloat(-0.0005571163134867303),\n        excess_kurtosis: NiceFloat(-1.1992896928276262),\n    };\n    random_primitive_ints_helper::<u128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8\n    let values = &[\n        113, -17, 69, 108, -28, -46, -88, -95, 87, 32, 110, 83, -68, 34, 89, -18, 93, -56, -107,\n        115,\n    ];\n    let common_values = &[\n        (-42, 4097),\n        (86, 4078),\n        (-90, 4049),\n        (22, 4048),\n        (126, 4047),\n        (55, 4040),\n        (93, 4037),\n        (-65, 4036),\n        (36, 4035),\n        (42, 4032),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5),\n        standard_deviation: NiceFloat(73.90027063549903),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.200036621652552),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5135149999999996),\n        standard_deviation: NiceFloat(73.89764871907164),\n        skewness: NiceFloat(-0.00024093275514460485),\n        excess_kurtosis: NiceFloat(-1.199484141789355),\n    };\n    random_primitive_ints_helper::<i8>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16\n    let values = &[\n        -4239, 27717, -11548, -24152, 8279, 21358, 8892, -4519, -14243, 29589, -27203, -13863,\n        -28043, 18463, -22121, 8622, 9735, -28591, 32584, -32655,\n    ];\n    let common_values = &[\n        (27447, 34),\n        (-898, 33),\n        (5606, 33),\n        (5836, 33),\n        (-15023, 33),\n        (-197, 32),\n        (3582, 32),\n        (-7314, 32),\n        (19279, 32),\n        (20588, 32),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5),\n        standard_deviation: NiceFloat(18918.61361860324),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000000005587934),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.11663199999982),\n        standard_deviation: NiceFloat(18918.420140333936),\n        skewness: NiceFloat(-0.00020582179614538415),\n        excess_kurtosis: NiceFloat(-1.19980156293678),\n    };\n    random_primitive_ints_helper::<i16>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32\n    let values = &[\n        1816522609,\n        -1582771484,\n        1399726167,\n        -296148292,\n        1939195997,\n        -908487235,\n        1210028661,\n        565094807,\n        -1873730041,\n        -2140045496,\n        1999530985,\n        -207351284,\n        -147083662,\n        -1197429209,\n        -60545688,\n        1164671716,\n        -1900807950,\n        -1120015889,\n        130045419,\n        -1296475448,\n    ];\n    let common_values = &[\n        (20095656, 2),\n        (29107328, 2),\n        (83328146, 2),\n        (96543416, 2),\n        (-59532811, 2),\n        (-72250103, 2),\n        (-88423413, 2),\n        (109257003, 2),\n        (132308363, 2),\n        (140940582, 2),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (-3037682, Some(-3035621));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5),\n        standard_deviation: NiceFloat(1239850262.2531195),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1708075.0735549931),\n        standard_deviation: NiceFloat(1239705769.0057693),\n        skewness: NiceFloat(0.0016706713036923025),\n        excess_kurtosis: NiceFloat(-1.2008047456655335),\n    };\n    random_primitive_ints_helper::<i32>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64\n    let values = &[\n        -6797951759004864655,\n        -1271947227506532265,\n        -3901922961219270563,\n        2427063716414460533,\n        -9191425414850861561,\n        -890566981564077079,\n        -5142919287782265230,\n        5002226935030621544,\n        -4810431611861206798,\n        -5568319649096903189,\n        -4872912570782646188,\n        1513424385005459611,\n        2484972586252155822,\n        -5374443828107932323,\n        4344958725064805398,\n        3252798961345668310,\n        -7926092317508205845,\n        -6066899635121005951,\n        6654913321726770291,\n        -7940875872878966649,\n    ];\n    let common_values = &[\n        (26914038281329, 1),\n        (32553719576594, 1),\n        (53892651831494, 1),\n        (66354421349686, 1),\n        (86226284907602, 1),\n        (89837182726049, 1),\n        (95691351770484, 1),\n        (-45554336062456, 1),\n        (-45700426911569, 1),\n        (-50232881235535, 1),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (-5305218289400184, Some(-5271053954352614));\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(5.325116328314171e18),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5606718482239710.0),\n        standard_deviation: NiceFloat(5.325063903618647e18),\n        skewness: NiceFloat(0.0011248693866288532),\n        excess_kurtosis: NiceFloat(-1.200551786344892),\n    };\n    random_primitive_ints_helper::<i64>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i128\n    let values = &[\n        -23463284981077418827267202649482203279,\n        44771423227283929645271838218448652381,\n        -16428061189408542358428117207094319609,\n        92274800069126412258941638023956901490,\n        -102717367487498748896125496933502158606,\n        27917752305106984883503397141734686804,\n        -99140989835634876684435608594951128146,\n        60003549963171791765607325839025294358,\n        -111914544889959057594096246794876321045,\n        -146483304948093240780207189413481284493,\n        -153586157979719815495295783806580152035,\n        33018320828004690757952445968579104952,\n        24887066387352849554815992782110776358,\n        79085537771456044427857440036467563654,\n        19637669411666889498466854442215856999,\n        -102694834600182680427466985752932389987,\n        -85298529075242965442847250193117638905,\n        -67944983823469089095474618642592431761,\n        105189689748742230503365861545668092951,\n        -81854971460639281226116917410207070376,\n    ];\n    let common_values = &[\n        (68570815139656170990830410045915, 1),\n        (381682482227926990846204728028719, 1),\n        (565207126752383841908924745713103, 1),\n        (717866653939818807939025508430762, 1),\n        (775173738585689418081884794376186, 1),\n        (818497230601034032775791540657915, 1),\n        (-307666299724089175945459600408325, 1),\n        (-413570452196184856884474016102340, 1),\n        (-789195894019805665974324122519229, 1),\n        (-843024079296967638987633859098218, 1),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (\n        -10072503186589325235371920356302834,\n        Some(-9899574809150113239535729822182407),\n    );\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(9.82310580711434e37),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.651168263124604e34),\n        standard_deviation: NiceFloat(9.82707680675722e37),\n        skewness: NiceFloat(0.00010083962773749455),\n        excess_kurtosis: NiceFloat(-1.2019920806441844),\n    };\n    random_primitive_ints_helper::<i128>(\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_signed_bit_chunks.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::{Itertools, assert_equal, repeat_n};\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_signed_bit_chunks;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn random_signed_bit_chunks_helper<T: CheckedToF64 + PrimitiveSigned>(\n    chunk_size: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    let (min, max) = if chunk_size < T::WIDTH {\n        (T::ZERO, T::low_mask(chunk_size))\n    } else {\n        (T::MIN, T::MAX)\n    };\n    let xs = random_signed_bit_chunks(EXAMPLE_SEED, chunk_size);\n    uniform_primitive_int_assertions(\n        xs.clone(),\n        min,\n        max,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n    if chunk_size != 0 {\n        assert_equal(\n            random_bools(EXAMPLE_SEED)\n                .chunks(usize::exact_from(chunk_size))\n                .into_iter()\n                .take(1000000)\n                .map(|bs| {\n                    T::from_bits_asc(\n                        bs.chain(repeat_n(false, usize::exact_from(T::WIDTH - chunk_size))),\n                    )\n                }),\n            xs.take(1000000),\n        );\n    }\n}\n\n#[test]\nfn test_random_signed_bit_chunks() {\n    // i16, chunk_size = 1\n    let values = &[1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0];\n    let common_values = &[(1, 500473), (0, 499527)];\n    let pop_median = (0, Some(1));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.5),\n        standard_deviation: NiceFloat(0.5),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.9999999999999998),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.5004730000000077),\n        standard_deviation: NiceFloat(0.5000000262710417),\n        skewness: NiceFloat(-0.0018920008465908307),\n        excess_kurtosis: NiceFloat(-1.999996420332894),\n    };\n    random_signed_bit_chunks_helper::<i16>(\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32, chunk_size = 2\n    let values = &[1, 0, 3, 1, 3, 3, 2, 3, 1, 1, 0, 1, 0, 3, 2, 1, 0, 1, 2, 3];\n    let common_values = &[(1, 250314), (3, 250015), (2, 249955), (0, 249716)];\n    let pop_median = (1, Some(2));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.5),\n        standard_deviation: NiceFloat(1.118033988749895),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.3599999999999999),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5002690000000294),\n        standard_deviation: NiceFloat(1.117793888470597),\n        skewness: NiceFloat(-0.00003155128630032229),\n        excess_kurtosis: NiceFloat(-1.3594490446207492),\n    };\n    random_signed_bit_chunks_helper::<i32>(\n        2,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, chunk_size = 3\n    let values = &[1, 6, 5, 7, 6, 3, 1, 2, 4, 5, 1, 2, 6, 5, 4, 6, 0, 5, 6, 0];\n    let common_values = &[\n        (3, 125437),\n        (6, 125372),\n        (7, 125322),\n        (4, 125116),\n        (0, 125049),\n        (5, 124759),\n        (2, 124542),\n        (1, 124403),\n    ];\n    let pop_median = (3, Some(4));\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(3.5),\n        standard_deviation: NiceFloat(2.29128784747792),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.238095238095238),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.503543000000029),\n        standard_deviation: NiceFloat(2.291658067611209),\n        skewness: NiceFloat(-0.002350008016990765),\n        excess_kurtosis: NiceFloat(-1.2376569368178467),\n    };\n    random_signed_bit_chunks_helper::<i64>(\n        3,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i128, chunk_size = 7\n    let values =\n        &[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, 1, 113, 54, 10, 47, 17, 89, 92, 119, 66];\n    let common_values = &[\n        (2, 8077),\n        (121, 8039),\n        (48, 8015),\n        (113, 7966),\n        (8, 7937),\n        (77, 7933),\n        (50, 7928),\n        (91, 7927),\n        (82, 7925),\n        (102, 7924),\n    ];\n    let pop_median = (63, Some(64));\n    let sample_median = (63, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(63.5),\n        standard_deviation: NiceFloat(36.94928957368463),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2001464933162425),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.478088999999315),\n        standard_deviation: NiceFloat(36.96113842989552),\n        skewness: NiceFloat(-0.000454036075457304),\n        excess_kurtosis: NiceFloat(-1.1998683031732713),\n    };\n    random_signed_bit_chunks_helper::<i128>(\n        7,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, chunk_size = 8\n    let values = &[\n        113, -17, 69, 108, -28, -46, -88, -95, 87, 32, 110, 83, -68, 34, 89, -18, 93, -56, -107,\n        115,\n    ];\n    let common_values = &[\n        (-42, 4097),\n        (86, 4078),\n        (-90, 4049),\n        (22, 4048),\n        (126, 4047),\n        (55, 4040),\n        (93, 4037),\n        (-65, 4036),\n        (36, 4035),\n        (42, 4032),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5),\n        standard_deviation: NiceFloat(73.90027063549903),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.200036621652552),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5135149999999996),\n        standard_deviation: NiceFloat(73.89764871907164),\n        skewness: NiceFloat(-0.00024093275514460485),\n        excess_kurtosis: NiceFloat(-1.199484141789355),\n    };\n    random_signed_bit_chunks_helper::<i8>(\n        8,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn random_signed_bit_chunks_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(random_signed_bit_chunks::<T>(EXAMPLE_SEED, 0));\n    assert_panic!(random_signed_bit_chunks::<T>(EXAMPLE_SEED, T::WIDTH + 1));\n}\n\n#[test]\nfn random_signed_bit_chunks_fail() {\n    apply_fn_to_signeds!(random_signed_bit_chunks_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_signed_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_signed_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn random_signed_inclusive_range_helper<T: CheckedToF64 + PrimitiveSigned>(\n    a: T,\n    b: T,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_signed_inclusive_range::<T>(EXAMPLE_SEED, a, b),\n        a,\n        b,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_signed_inclusive_range() {\n    // i8, 5, 5\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_signed_inclusive_range_helper::<i8>(\n        5,\n        5,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16, 1, 6\n    let values = &[2, 6, 4, 2, 3, 5, 6, 2, 3, 6, 5, 1, 6, 1, 3, 6, 3, 1, 5, 1];\n    let common_values =\n        &[(4, 167408), (1, 167104), (5, 166935), (6, 166549), (3, 166068), (2, 165936)];\n    let pop_median = (3, Some(4));\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(3.5),\n        standard_deviation: NiceFloat(1.707825127659933),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2685714285714285),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5007809999998676),\n        standard_deviation: NiceFloat(1.7081165966354217),\n        skewness: NiceFloat(-0.0024015945144963404),\n        excess_kurtosis: NiceFloat(-1.2685533575767198),\n    };\n    random_signed_inclusive_range_helper::<i16>(\n        1,\n        6,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32, 10, 19\n    let values = &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, 15, 10, 12, 16, 13, 15, 12, 12, 19, 15];\n    let common_values = &[\n        (15, 100442),\n        (12, 100144),\n        (16, 100118),\n        (18, 100047),\n        (11, 100023),\n        (14, 100011),\n        (10, 99996),\n        (19, 99936),\n        (17, 99715),\n        (13, 99568),\n    ];\n    let pop_median = (14, Some(15));\n    let sample_median = (15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.5),\n        standard_deviation: NiceFloat(2.8722813232690143),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2242424242424241),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.49978199999957),\n        standard_deviation: NiceFloat(2.8719356191409076),\n        skewness: NiceFloat(-0.00016199543215732692),\n        excess_kurtosis: NiceFloat(-1.2237431734377722),\n    };\n    random_signed_inclusive_range_helper::<i32>(\n        10,\n        19,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, -20, -11\n    let values = &[\n        -19, -13, -15, -16, -14, -16, -18, -12, -19, -13, -15, -20, -18, -14, -17, -15, -18, -18,\n        -11, -15,\n    ];\n    let common_values = &[\n        (-15, 100442),\n        (-18, 100144),\n        (-14, 100118),\n        (-12, 100047),\n        (-19, 100023),\n        (-16, 100011),\n        (-20, 99996),\n        (-11, 99936),\n        (-13, 99715),\n        (-17, 99568),\n    ];\n    let pop_median = (-16, Some(-15));\n    let sample_median = (-15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-15.5),\n        standard_deviation: NiceFloat(2.8722813232690143),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2242424242424241),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-15.50021800000043),\n        standard_deviation: NiceFloat(2.8719356191409076),\n        skewness: NiceFloat(-0.00016199543215732692),\n        excess_kurtosis: NiceFloat(-1.2237431734377722),\n    };\n    random_signed_inclusive_range_helper::<i64>(\n        -20,\n        -11,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, -100, 99\n    let values =\n        &[13, -31, 8, 68, 61, -13, -68, 10, -17, 88, -66, -11, -7, 49, 15, 89, 49, 17, 46, -69];\n    let common_values = &[\n        (-33, 5190),\n        (66, 5182),\n        (87, 5176),\n        (-73, 5172),\n        (-7, 5169),\n        (91, 5167),\n        (-84, 5136),\n        (26, 5132),\n        (-12, 5125),\n        (-14, 5125),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5),\n        standard_deviation: NiceFloat(57.73430522661548),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000600015000376),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5228260000000045),\n        standard_deviation: NiceFloat(57.74415076317745),\n        skewness: NiceFloat(0.00018970091170297907),\n        excess_kurtosis: NiceFloat(-1.2011004127418898),\n    };\n    random_signed_inclusive_range_helper::<i8>(\n        -100,\n        99,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, i8::MIN, i8::MAX\n    let values = &[\n        -15, 111, -59, -20, 100, 82, 40, 33, -41, -96, -18, -45, 60, -94, -39, 110, -35, 72, 21,\n        -13,\n    ];\n    let common_values = &[\n        (86, 4097),\n        (-42, 4078),\n        (38, 4049),\n        (-106, 4048),\n        (-2, 4047),\n        (-73, 4040),\n        (-35, 4037),\n        (63, 4036),\n        (-92, 4035),\n        (-86, 4032),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5),\n        standard_deviation: NiceFloat(73.90027063549903),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.200036621652552),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5411629999999936),\n        standard_deviation: NiceFloat(73.90873539784404),\n        skewness: NiceFloat(0.00044078393804460487),\n        excess_kurtosis: NiceFloat(-1.200418003526936),\n    };\n    random_signed_inclusive_range_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn random_signed_inclusive_range_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(random_signed_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::ONE\n    ));\n}\n\n#[test]\nfn random_signed_inclusive_range_fail() {\n    apply_fn_to_signeds!(random_signed_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_signed_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_signed_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn random_signed_range_helper<T: CheckedToF64 + PrimitiveSigned>(\n    a: T,\n    b: T,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_signed_range::<T>(EXAMPLE_SEED, a, b),\n        a,\n        b - T::ONE,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_signed_range() {\n    // i8, 5, 6\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_signed_range_helper::<i8>(\n        5,\n        6,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i16, 1, 7\n    let values = &[2, 6, 4, 2, 3, 5, 6, 2, 3, 6, 5, 1, 6, 1, 3, 6, 3, 1, 5, 1];\n    let common_values =\n        &[(4, 167408), (1, 167104), (5, 166935), (6, 166549), (3, 166068), (2, 165936)];\n    let pop_median = (3, Some(4));\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(3.5),\n        standard_deviation: NiceFloat(1.707825127659933),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2685714285714285),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5007809999998676),\n        standard_deviation: NiceFloat(1.7081165966354217),\n        skewness: NiceFloat(-0.0024015945144963404),\n        excess_kurtosis: NiceFloat(-1.2685533575767198),\n    };\n    random_signed_range_helper::<i16>(\n        1,\n        7,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i32, 10, 20\n    let values = &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, 15, 10, 12, 16, 13, 15, 12, 12, 19, 15];\n    let common_values = &[\n        (15, 100442),\n        (12, 100144),\n        (16, 100118),\n        (18, 100047),\n        (11, 100023),\n        (14, 100011),\n        (10, 99996),\n        (19, 99936),\n        (17, 99715),\n        (13, 99568),\n    ];\n    let pop_median = (14, Some(15));\n    let sample_median = (15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.5),\n        standard_deviation: NiceFloat(2.8722813232690143),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2242424242424241),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.49978199999957),\n        standard_deviation: NiceFloat(2.8719356191409076),\n        skewness: NiceFloat(-0.00016199543215732692),\n        excess_kurtosis: NiceFloat(-1.2237431734377722),\n    };\n    random_signed_range_helper::<i32>(\n        10,\n        20,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i64, -20, -10\n    let values = &[\n        -19, -13, -15, -16, -14, -16, -18, -12, -19, -13, -15, -20, -18, -14, -17, -15, -18, -18,\n        -11, -15,\n    ];\n    let common_values = &[\n        (-15, 100442),\n        (-18, 100144),\n        (-14, 100118),\n        (-12, 100047),\n        (-19, 100023),\n        (-16, 100011),\n        (-20, 99996),\n        (-11, 99936),\n        (-13, 99715),\n        (-17, 99568),\n    ];\n    let pop_median = (-16, Some(-15));\n    let sample_median = (-15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-15.5),\n        standard_deviation: NiceFloat(2.8722813232690143),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2242424242424241),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-15.50021800000043),\n        standard_deviation: NiceFloat(2.8719356191409076),\n        skewness: NiceFloat(-0.00016199543215732692),\n        excess_kurtosis: NiceFloat(-1.2237431734377722),\n    };\n    random_signed_range_helper::<i64>(\n        -20,\n        -10,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, -100, 100\n    let values =\n        &[13, -31, 8, 68, 61, -13, -68, 10, -17, 88, -66, -11, -7, 49, 15, 89, 49, 17, 46, -69];\n    let common_values = &[\n        (-33, 5190),\n        (66, 5182),\n        (87, 5176),\n        (-73, 5172),\n        (-7, 5169),\n        (91, 5167),\n        (-84, 5136),\n        (26, 5132),\n        (-12, 5125),\n        (-14, 5125),\n    ];\n    let pop_median = (-1, Some(0));\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5),\n        standard_deviation: NiceFloat(57.73430522661548),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000600015000376),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5228260000000045),\n        standard_deviation: NiceFloat(57.74415076317745),\n        skewness: NiceFloat(0.00018970091170297907),\n        excess_kurtosis: NiceFloat(-1.2011004127418898),\n    };\n    random_signed_range_helper::<i8>(\n        -100,\n        100,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // i8, i8::MIN, i8::MAX\n    let values = &[\n        -15, 111, -59, -20, 100, 82, 40, 33, -41, -96, -18, -45, 60, -94, -39, 110, -35, 72, 21,\n        -13,\n    ];\n    let common_values = &[\n        (86, 4112),\n        (-42, 4092),\n        (38, 4063),\n        (-2, 4061),\n        (-106, 4061),\n        (-35, 4054),\n        (-73, 4054),\n        (63, 4052),\n        (-92, 4049),\n        (-86, 4047),\n    ];\n    let pop_median = (-1, None);\n    let sample_median = (-1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0),\n        standard_deviation: NiceFloat(73.6115932898254),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000369094488188),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0481689999999793),\n        standard_deviation: NiceFloat(73.61930013623301),\n        skewness: NiceFloat(0.0005380412105164722),\n        excess_kurtosis: NiceFloat(-1.2003531635142872),\n    };\n    random_signed_range_helper::<i8>(\n        i8::MIN,\n        i8::MAX,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn random_signed_range_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(random_signed_range::<T>(EXAMPLE_SEED, T::TWO, T::TWO));\n}\n\n#[test]\nfn random_signed_range_fail() {\n    apply_fn_to_signeds!(random_signed_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_unsigned_bit_chunks.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::{Itertools, assert_equal};\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_unsigned_bit_chunks;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn random_unsigned_bit_chunks_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    chunk_size: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = random_unsigned_bit_chunks(EXAMPLE_SEED, chunk_size);\n    uniform_primitive_int_assertions(\n        xs.clone(),\n        T::ZERO,\n        T::low_mask(chunk_size),\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n    if chunk_size != 0 {\n        assert_equal(\n            random_bools(EXAMPLE_SEED)\n                .chunks(usize::exact_from(chunk_size))\n                .into_iter()\n                .take(1000000)\n                .map(T::from_bits_asc),\n            xs.take(1000000),\n        );\n    }\n}\n\n#[test]\nfn test_random_unsigned_bit_chunks() {\n    // u16, chunk_size = 1\n    let values = &[1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0];\n    let common_values = &[(1, 500473), (0, 499527)];\n    let pop_median = (0, Some(1));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.5),\n        standard_deviation: NiceFloat(0.5),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.9999999999999998),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.5004730000000077),\n        standard_deviation: NiceFloat(0.5000000262710417),\n        skewness: NiceFloat(-0.0018920008465908307),\n        excess_kurtosis: NiceFloat(-1.999996420332894),\n    };\n    random_unsigned_bit_chunks_helper::<u16>(\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32, chunk_size = 2\n    let values = &[1, 0, 3, 1, 3, 3, 2, 3, 1, 1, 0, 1, 0, 3, 2, 1, 0, 1, 2, 3];\n    let common_values = &[(1, 250314), (3, 250015), (2, 249955), (0, 249716)];\n    let pop_median = (1, Some(2));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.5),\n        standard_deviation: NiceFloat(1.118033988749895),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.3599999999999999),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5002690000000294),\n        standard_deviation: NiceFloat(1.117793888470597),\n        skewness: NiceFloat(-0.00003155128630032229),\n        excess_kurtosis: NiceFloat(-1.3594490446207492),\n    };\n    random_unsigned_bit_chunks_helper::<u32>(\n        2,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64, chunk_size = 3\n    let values = &[1, 6, 5, 7, 6, 3, 1, 2, 4, 5, 1, 2, 6, 5, 4, 6, 0, 5, 6, 0];\n    let common_values = &[\n        (3, 125437),\n        (6, 125372),\n        (7, 125322),\n        (4, 125116),\n        (0, 125049),\n        (5, 124759),\n        (2, 124542),\n        (1, 124403),\n    ];\n    let pop_median = (3, Some(4));\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(3.5),\n        standard_deviation: NiceFloat(2.29128784747792),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.238095238095238),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.503543000000029),\n        standard_deviation: NiceFloat(2.291658067611209),\n        skewness: NiceFloat(-0.002350008016990765),\n        excess_kurtosis: NiceFloat(-1.2376569368178467),\n    };\n    random_unsigned_bit_chunks_helper::<u64>(\n        3,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u128, chunk_size = 7\n    let values =\n        &[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, 1, 113, 54, 10, 47, 17, 89, 92, 119, 66];\n    let common_values = &[\n        (2, 8077),\n        (121, 8039),\n        (48, 8015),\n        (113, 7966),\n        (8, 7937),\n        (77, 7933),\n        (50, 7928),\n        (91, 7927),\n        (82, 7925),\n        (102, 7924),\n    ];\n    let pop_median = (63, Some(64));\n    let sample_median = (63, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(63.5),\n        standard_deviation: NiceFloat(36.94928957368463),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2001464933162425),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.478088999999315),\n        standard_deviation: NiceFloat(36.96113842989552),\n        skewness: NiceFloat(-0.000454036075457304),\n        excess_kurtosis: NiceFloat(-1.1998683031732713),\n    };\n    random_unsigned_bit_chunks_helper::<u128>(\n        7,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, chunk_size = 8\n    let values = &[\n        113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149, 115,\n    ];\n    let common_values = &[\n        (214, 4097),\n        (86, 4078),\n        (166, 4049),\n        (22, 4048),\n        (126, 4047),\n        (55, 4040),\n        (93, 4037),\n        (191, 4036),\n        (36, 4035),\n        (42, 4032),\n    ];\n    let pop_median = (127, Some(128));\n    let sample_median = (127, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(127.5),\n        standard_deviation: NiceFloat(73.90027063549903),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.200036621652552),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.4588370000015),\n        standard_deviation: NiceFloat(73.908735397844),\n        skewness: NiceFloat(0.0004407839380447086),\n        excess_kurtosis: NiceFloat(-1.200418003526934),\n    };\n    random_unsigned_bit_chunks_helper::<u8>(\n        8,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn random_unsigned_bit_chunks_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(random_unsigned_bit_chunks::<T>(EXAMPLE_SEED, 0));\n    assert_panic!(random_unsigned_bit_chunks::<T>(EXAMPLE_SEED, T::WIDTH + 1));\n}\n\n#[test]\nfn random_unsigned_bit_chunks_fail() {\n    apply_fn_to_unsigneds!(random_unsigned_bit_chunks_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_unsigned_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_unsigned_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn random_unsigned_inclusive_range_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    a: T,\n    b: T,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_unsigned_inclusive_range::<T>(EXAMPLE_SEED, a, b),\n        a,\n        b,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_unsigned_inclusive_range() {\n    // u8, 5, 5\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_unsigned_inclusive_range_helper::<u8>(\n        5,\n        5,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16, 1, 6\n    let values = &[2, 6, 4, 2, 3, 5, 6, 2, 3, 6, 5, 1, 6, 1, 3, 6, 3, 1, 5, 1];\n    let common_values =\n        &[(4, 167408), (1, 167104), (5, 166935), (6, 166549), (3, 166068), (2, 165936)];\n    let pop_median = (3, Some(4));\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(3.5),\n        standard_deviation: NiceFloat(1.707825127659933),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2685714285714285),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5007809999998676),\n        standard_deviation: NiceFloat(1.7081165966354217),\n        skewness: NiceFloat(-0.0024015945144963404),\n        excess_kurtosis: NiceFloat(-1.2685533575767198),\n    };\n    random_unsigned_inclusive_range_helper::<u16>(\n        1,\n        6,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32, 10, 19\n    let values = &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, 15, 10, 12, 16, 13, 15, 12, 12, 19, 15];\n    let common_values = &[\n        (15, 100442),\n        (12, 100144),\n        (16, 100118),\n        (18, 100047),\n        (11, 100023),\n        (14, 100011),\n        (10, 99996),\n        (19, 99936),\n        (17, 99715),\n        (13, 99568),\n    ];\n    let pop_median = (14, Some(15));\n    let sample_median = (15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.5),\n        standard_deviation: NiceFloat(2.8722813232690143),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2242424242424241),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.49978199999957),\n        standard_deviation: NiceFloat(2.8719356191409076),\n        skewness: NiceFloat(-0.00016199543215732692),\n        excess_kurtosis: NiceFloat(-1.2237431734377722),\n    };\n    random_unsigned_inclusive_range_helper::<u32>(\n        10,\n        19,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, 0, u8::MAX\n    let values = &[\n        113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149, 115,\n    ];\n    let common_values = &[\n        (214, 4097),\n        (86, 4078),\n        (166, 4049),\n        (22, 4048),\n        (126, 4047),\n        (55, 4040),\n        (93, 4037),\n        (191, 4036),\n        (36, 4035),\n        (42, 4032),\n    ];\n    let pop_median = (127, Some(128));\n    let sample_median = (127, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(127.5),\n        standard_deviation: NiceFloat(73.90027063549903),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.200036621652552),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.4588370000015),\n        standard_deviation: NiceFloat(73.908735397844),\n        skewness: NiceFloat(0.0004407839380447086),\n        excess_kurtosis: NiceFloat(-1.200418003526934),\n    };\n    random_unsigned_inclusive_range_helper::<u8>(\n        0,\n        u8::MAX,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn random_unsigned_inclusive_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::ONE\n    ));\n}\n\n#[test]\nfn random_unsigned_inclusive_range_fail() {\n    apply_fn_to_unsigneds!(random_unsigned_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_unsigned_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_unsigned_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn random_unsigned_range_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    a: T,\n    b: T,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_unsigned_range::<T>(EXAMPLE_SEED, a, b),\n        a,\n        b - T::ONE,\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_unsigned_range() {\n    // u8, 5, 6\n    let values = &[5; 20];\n    let common_values = &[(5, 1000000)];\n    let pop_median = (5, None);\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_unsigned_range_helper::<u8>(\n        5,\n        6,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16, 1, 7\n    let values = &[2, 6, 4, 2, 3, 5, 6, 2, 3, 6, 5, 1, 6, 1, 3, 6, 3, 1, 5, 1];\n    let common_values =\n        &[(4, 167408), (1, 167104), (5, 166935), (6, 166549), (3, 166068), (2, 165936)];\n    let pop_median = (3, Some(4));\n    let sample_median = (4, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(3.5),\n        standard_deviation: NiceFloat(1.707825127659933),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2685714285714285),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5007809999998676),\n        standard_deviation: NiceFloat(1.7081165966354217),\n        skewness: NiceFloat(-0.0024015945144963404),\n        excess_kurtosis: NiceFloat(-1.2685533575767198),\n    };\n    random_unsigned_range_helper::<u16>(\n        1,\n        7,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32, 10, 20\n    let values = &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, 15, 10, 12, 16, 13, 15, 12, 12, 19, 15];\n    let common_values = &[\n        (15, 100442),\n        (12, 100144),\n        (16, 100118),\n        (18, 100047),\n        (11, 100023),\n        (14, 100011),\n        (10, 99996),\n        (19, 99936),\n        (17, 99715),\n        (13, 99568),\n    ];\n    let pop_median = (14, Some(15));\n    let sample_median = (15, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(14.5),\n        standard_deviation: NiceFloat(2.8722813232690143),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2242424242424241),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(14.49978199999957),\n        standard_deviation: NiceFloat(2.8719356191409076),\n        skewness: NiceFloat(-0.00016199543215732692),\n        excess_kurtosis: NiceFloat(-1.2237431734377722),\n    };\n    random_unsigned_range_helper::<u32>(\n        10,\n        20,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u8, 0, u8::MAX\n    let values = &[\n        113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149, 115,\n    ];\n    let common_values = &[\n        (214, 4112),\n        (86, 4092),\n        (166, 4063),\n        (22, 4061),\n        (126, 4061),\n        (55, 4054),\n        (93, 4054),\n        (191, 4052),\n        (36, 4049),\n        (42, 4047),\n    ];\n    let pop_median = (127, None);\n    let sample_median = (127, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(127.0),\n        standard_deviation: NiceFloat(73.6115932898254),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2000369094488188),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(126.95183099999818),\n        standard_deviation: NiceFloat(73.61930013623306),\n        skewness: NiceFloat(0.0005380412105163868),\n        excess_kurtosis: NiceFloat(-1.200353163514298),\n    };\n    random_unsigned_range_helper::<u8>(\n        0,\n        u8::MAX,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn random_unsigned_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(random_unsigned_range::<T>(EXAMPLE_SEED, T::TWO, T::TWO));\n}\n\n#[test]\nfn random_unsigned_range_fail() {\n    apply_fn_to_unsigneds!(random_unsigned_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/random_unsigneds_less_than.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::random_unsigneds_less_than;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::{\n    CheckedToF64, MomentStats, uniform_primitive_int_assertions,\n};\nuse std::panic::catch_unwind;\n\nfn random_unsigneds_less_than_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    limit: T,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_pop_median: (T, Option<T>),\n    expected_sample_median: (T, Option<T>),\n    expected_pop_moment_stats: MomentStats,\n    expected_sample_moment_stats: MomentStats,\n) {\n    uniform_primitive_int_assertions(\n        random_unsigneds_less_than(EXAMPLE_SEED, limit),\n        T::ZERO,\n        limit.wrapping_sub(T::ONE),\n        expected_values,\n        expected_common_values,\n        expected_pop_median,\n        expected_sample_median,\n        expected_pop_moment_stats,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_unsigneds_less_than() {\n    // u8, limit = 1\n    let values = &[0; 20];\n    let common_values = &[(0, 1000000)];\n    let pop_median = (0, None);\n    let sample_median = (0, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_unsigneds_less_than_helper::<u8>(\n        1,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u16, limit = 2\n    let values = &[1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0];\n    let common_values = &[(1, 500473), (0, 499527)];\n    let pop_median = (0, Some(1));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(0.5),\n        standard_deviation: NiceFloat(0.5),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.9999999999999998),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.5004730000000077),\n        standard_deviation: NiceFloat(0.5000000262710417),\n        skewness: NiceFloat(-0.0018920008465908307),\n        excess_kurtosis: NiceFloat(-1.999996420332894),\n    };\n    random_unsigneds_less_than_helper::<u16>(\n        2,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u32, limit = 3\n    let values = &[1, 0, 1, 2, 1, 1, 0, 1, 0, 2, 1, 0, 1, 2, 2, 0, 1, 0, 2, 2];\n    let common_values = &[(1, 333784), (2, 333516), (0, 332700)];\n    let pop_median = (1, None);\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.0),\n        standard_deviation: NiceFloat(0.816496580927726),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.5),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0008159999999369),\n        standard_deviation: NiceFloat(0.8162205586482172),\n        skewness: NiceFloat(-0.0014985805078073927),\n        excess_kurtosis: NiceFloat(-1.498982317720307),\n    };\n    random_unsigneds_less_than_helper::<u32>(\n        3,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u64, limit = 4\n    let values = &[1, 0, 3, 1, 3, 3, 2, 3, 1, 1, 0, 1, 0, 3, 2, 1, 0, 1, 2, 3];\n    let common_values = &[(1, 250314), (3, 250015), (2, 249955), (0, 249716)];\n    let pop_median = (1, Some(2));\n    let sample_median = (1, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(1.5),\n        standard_deviation: NiceFloat(1.118033988749895),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.3599999999999999),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5002690000000294),\n        standard_deviation: NiceFloat(1.117793888470597),\n        skewness: NiceFloat(-0.00003155128630032229),\n        excess_kurtosis: NiceFloat(-1.3594490446207492),\n    };\n    random_unsigneds_less_than_helper::<u64>(\n        4,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n\n    // u128, limit = 10\n    let values = &[1, 7, 5, 4, 6, 4, 2, 8, 1, 7, 5, 0, 2, 6, 3, 5, 2, 2, 9, 5];\n    let common_values = &[\n        (5, 100442),\n        (2, 100144),\n        (6, 100118),\n        (8, 100047),\n        (1, 100023),\n        (4, 100011),\n        (0, 99996),\n        (9, 99936),\n        (7, 99715),\n        (3, 99568),\n    ];\n    let pop_median = (4, Some(5));\n    let sample_median = (5, None);\n    let pop_moment_stats = MomentStats {\n        mean: NiceFloat(4.5),\n        standard_deviation: NiceFloat(2.8722813232690143),\n        skewness: NiceFloat(0.0),\n        excess_kurtosis: NiceFloat(-1.2242424242424241),\n    };\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.499781999999947),\n        standard_deviation: NiceFloat(2.8719356191409156),\n        skewness: NiceFloat(-0.00016199543215745585),\n        excess_kurtosis: NiceFloat(-1.2237431734377897),\n    };\n    random_unsigneds_less_than_helper::<u128>(\n        10,\n        values,\n        common_values,\n        pop_median,\n        sample_median,\n        pop_moment_stats,\n        sample_moment_stats,\n    );\n}\n\nfn random_unsigneds_less_than_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(random_unsigneds_less_than::<T>(EXAMPLE_SEED, T::ZERO));\n}\n\n#[test]\nfn random_unsigneds_less_than_fail() {\n    apply_fn_to_unsigneds!(random_unsigneds_less_than_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::special_random_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn special_random_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_finite_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_finite_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64, mean zero P = 1/4\n    let values = &[\n        0.0, 1.0, 1.0, -0.0, 1.0, -1.0, 0.0, -1.0, 0.0, -0.0, -1.0, -0.0, -1.0, 1.0, 1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 0.5, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0,\n        0.0, -1.5, -0.0, 0.0, -1.0, 1.0, -1.0, -1.0, -1.0, 0.0, 1.0, -1.0, -0.5, -1.0, -0.0, 0.0,\n        0.0, 1.0,\n    ];\n    let common_values = &[\n        (1.0, 358244),\n        (-1.0, 357926),\n        (0.0, 125637),\n        (-0.0, 124572),\n        (2.0, 5538),\n        (1.5, 5500),\n        (0.5, 5497),\n        (-1.5, 5454),\n        (-2.0, 5379),\n        (-0.5, 5357),\n        (0.75, 102),\n        (3.0, 98),\n        (-4.0, 95),\n        (-0.25, 91),\n        (-0.75, 87),\n        (-3.0, 86),\n        (0.25, 79),\n        (4.0, 75),\n        (-1.25, 48),\n        (1.75, 44),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0007401249999999665),\n        standard_deviation: NiceFloat(0.8901654924701277),\n        skewness: NiceFloat(-0.00169030138949471),\n        excess_kurtosis: NiceFloat(-1.371049776159086),\n    };\n    special_random_finite_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        1.0, 1.25, 3.0, 0.0, -1.0, -1.0, -2.0, -3.5, 1.0, 2.0, -1.5, -2.5, -2.0, -0.0, -6.5, -1.0,\n        -1.0, 0.0, 3.0, -0.21875, -1.0, 0.25, 1.5, 5.25, -4.0, 7.0, -0.5, 0.1875, 1.25, 0.0,\n        -0.1875, -7.5, -0.0, 0.75, -7.0, -6.0, -3.0, 0.234375, -2.0, -0.875, -0.75, 6.0, -24.0,\n        24.0, -2.0, 1.5, -0.0, -1.25, 14.0, 5.0,\n    ];\n    let common_values = &[\n        (1.0, 74789),\n        (-1.0, 74702),\n        (0.0, 50351),\n        (-0.0, 49873),\n        (1.5, 38119),\n        (-0.5, 37713),\n        (2.0, 37640),\n        (-1.5, 37613),\n        (-2.0, 37333),\n        (0.5, 37027),\n        (0.75, 19050),\n        (4.0, 18892),\n        (0.25, 18875),\n        (-3.0, 18866),\n        (3.0, 18821),\n        (-0.75, 18725),\n        (-4.0, 18663),\n        (-0.25, 18537),\n        (0.125, 9445),\n        (-0.375, 9395),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.8271329178933905),\n        standard_deviation: NiceFloat(427.372166726293),\n        skewness: NiceFloat(-141.119016305626),\n        excess_kurtosis: NiceFloat(144205.19930780405),\n    };\n    special_random_finite_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        0.65625,\n        0.0000014255784,\n        0.013183594,\n        -0.8125,\n        -74240.0,\n        -0.0078125,\n        -0.03060913,\n        3.331552,\n        4.75,\n        -0.000038146973,\n        -0.3125,\n        -27136.0,\n        -59392.0,\n        -1.75,\n        -41.1875,\n        0.30940247,\n        -0.0009765625,\n        -1536.0,\n        0.2109375,\n        0.0014648438,\n        2.1129381e-8,\n        -0.037109375,\n        5242880.0,\n        -0.21386719,\n        134.21094,\n        4.184082,\n        -1561370.0,\n        -2.1420419e-7,\n        0.38085938,\n        -0.007003784,\n        -37748736.0,\n        -6448.0,\n        28.25,\n        -6.703125,\n        -4.483364,\n        -3.1757812,\n        0.000003915804,\n        -0.020751953,\n        0.00011110306,\n        -0.000053405256,\n        0.00019985437,\n        -35.40625,\n        0.005859375,\n        0.0078125,\n        28.25,\n        30.0,\n        -0.20776367,\n        -144.0,\n        -0.109375,\n        -6144.0,\n    ];\n    let common_values = &[\n        (0.0, 5098),\n        (-0.0, 4891),\n        (1.0, 2559),\n        (-1.0, 2528),\n        (0.5, 2362),\n        (-2.0, 2312),\n        (-1.5, 2306),\n        (2.0, 2304),\n        (1.5, 2275),\n        (-0.5, 2243),\n        (-3.0, 2204),\n        (-4.0, 2163),\n        (-0.25, 2129),\n        (0.75, 2103),\n        (3.0, 2081),\n        (0.25, 2070),\n        (-0.75, 2047),\n        (4.0, 2038),\n        (-6.0, 1943),\n        (-8.0, 1918),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.736310580536276e31),\n        standard_deviation: NiceFloat(6.494074857946111e34),\n        skewness: NiceFloat(-779.0012319222365),\n        excess_kurtosis: NiceFloat(633402.0042901832),\n    };\n    special_random_finite_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64, mean zero P = 1/4\n    let values = &[\n        0.0, 1.0, 1.0, -0.0, 1.0, -1.0, 0.0, -1.0, 0.0, -0.0, -1.0, -0.0, -1.0, 1.0, 1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 0.5, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0,\n        0.0, -1.5, -0.0, 0.0, -1.0, 1.0, -1.0, -1.0, -1.0, 0.0, 1.0, -1.0, -0.5, -1.0, -0.0, 0.0,\n        0.0, 1.0,\n    ];\n    let common_values = &[\n        (1.0, 358244),\n        (-1.0, 357926),\n        (0.0, 125637),\n        (-0.0, 124572),\n        (2.0, 5538),\n        (1.5, 5500),\n        (0.5, 5497),\n        (-1.5, 5454),\n        (-2.0, 5379),\n        (-0.5, 5357),\n        (0.75, 102),\n        (3.0, 98),\n        (-4.0, 95),\n        (-0.25, 91),\n        (-0.75, 87),\n        (-3.0, 86),\n        (0.25, 79),\n        (4.0, 75),\n        (-1.25, 48),\n        (1.75, 44),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0007401249999999665),\n        standard_deviation: NiceFloat(0.8901654924701277),\n        skewness: NiceFloat(-0.00169030138949471),\n        excess_kurtosis: NiceFloat(-1.371049776159086),\n    };\n    special_random_finite_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        1.0, 1.25, 3.0, 0.0, -1.0, -1.0, -2.0, -3.5, 1.0, 2.0, -1.5, -2.5, -2.0, -0.0, -6.5, -1.0,\n        -1.0, 0.0, 3.0, -0.21875, -1.0, 0.25, 1.5, 5.25, -4.0, 7.0, -0.5, 0.1875, 1.25, 0.0,\n        -0.1875, -7.5, -0.0, 0.75, -7.0, -6.0, -3.0, 0.234375, -2.0, -0.875, -0.75, 6.0, -24.0,\n        24.0, -2.0, 1.5, -0.0, -1.25, 14.0, 5.0,\n    ];\n    let common_values = &[\n        (1.0, 74789),\n        (-1.0, 74702),\n        (0.0, 50351),\n        (-0.0, 49873),\n        (1.5, 38119),\n        (-0.5, 37713),\n        (2.0, 37640),\n        (-1.5, 37613),\n        (-2.0, 37333),\n        (0.5, 37027),\n        (0.75, 19050),\n        (4.0, 18892),\n        (0.25, 18875),\n        (-3.0, 18866),\n        (3.0, 18821),\n        (-0.75, 18725),\n        (-4.0, 18663),\n        (-0.25, 18537),\n        (0.125, 9445),\n        (-0.375, 9395),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.8271329178933905),\n        standard_deviation: NiceFloat(427.372166726293),\n        skewness: NiceFloat(-141.119016305626),\n        excess_kurtosis: NiceFloat(144205.19930780405),\n    };\n    special_random_finite_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        0.7709910366684198,\n        1.2504315236583352e-6,\n        0.00830078125,\n        -0.8125,\n        -85504.0,\n        -0.0078125,\n        -0.018890380859375,\n        2.5721821784973145,\n        5.75,\n        -0.00003814697265625,\n        -0.4375,\n        -24064.0,\n        -43008.0,\n        -1.75,\n        -54.6875,\n        0.4641265869140625,\n        -0.0014760522753931582,\n        -1536.0,\n        0.1484375,\n        0.00146484375,\n        1.9383151084184647e-8,\n        -0.060546875,\n        7340032.0,\n        -0.1982421875,\n        203.0546875,\n        4.57177734375,\n        -1555162.0,\n        -2.0675361156463623e-7,\n        0.279296875,\n        -0.0045928955078125,\n        -46137344.0,\n        -5712.0,\n        17.75,\n        -5.265625,\n        -7.966220855712891,\n        -2.99609375,\n        5.397188942879438e-6,\n        -0.017333984375,\n        0.00011491775512695312,\n        -0.00005845972555107437,\n        0.00020831823348999023,\n        -46.78125,\n        0.005859375,\n        0.0078125,\n        27.25,\n        30.0,\n        -0.175537109375,\n        -208.0,\n        -0.109375,\n        -6144.0,\n    ];\n    let common_values = &[\n        (0.0, 5098),\n        (-0.0, 4891),\n        (1.0, 2396),\n        (-1.0, 2336),\n        (-2.0, 2200),\n        (-1.5, 2169),\n        (0.5, 2116),\n        (2.0, 2108),\n        (-0.5, 2101),\n        (1.5, 2085),\n        (-3.0, 2000),\n        (4.0, 1993),\n        (3.0, 1969),\n        (-0.25, 1955),\n        (0.75, 1946),\n        (0.25, 1917),\n        (-4.0, 1882),\n        (-0.75, 1863),\n        (8.0, 1826),\n        (-6.0, 1782),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.053229374417263e38),\n        standard_deviation: NiceFloat(7.053232003373143e41),\n        skewness: NiceFloat(-999.9984999989927),\n        excess_kurtosis: NiceFloat(999995.0000005187),\n    };\n    special_random_finite_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn special_random_finite_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0,\n        1,\n        10\n    ));\n    assert_panic!(special_random_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        1,\n        0\n    ));\n    assert_panic!(special_random_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        2,\n        1\n    ));\n}\n\n#[test]\nfn special_random_finite_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_finite_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_negative_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::special_random_negative_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn special_random_negative_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_negative_finite_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_negative_finite_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64\n    let values = &[\n        -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -0.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -0.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -1.0,\n    ];\n    let common_values = &[\n        (-1.0, 954991),\n        (-1.5, 14672),\n        (-2.0, 14586),\n        (-0.5, 14578),\n        (-3.0, 243),\n        (-0.25, 228),\n        (-4.0, 226),\n        (-0.75, 207),\n        (-1.25, 127),\n        (-1.75, 118),\n        (-6.0, 6),\n        (-0.125, 4),\n        (-2.5, 3),\n        (-8.0, 3),\n        (-0.625, 3),\n        (-0.375, 2),\n        (-0.875, 2),\n        (-3.5, 1),\n    ];\n    let sample_median = (-1.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0157463749999305),\n        standard_deviation: NiceFloat(0.15870215416222863),\n        skewness: NiceFloat(-5.805128395366302),\n        excess_kurtosis: NiceFloat(73.03005686221248),\n    };\n    special_random_negative_finite_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2\n    let values = &[\n        -1.0, -1.5, -3.125, -1.0, -1.0, -2.0, -2.0, -1.0, -3.0, -1.0, -2.0, -3.0, -4.0, -1.5,\n        -1.625, -2.0, -0.125, -1.0, -0.375, -1.5, -6.375, -4.0, -6.875, -0.5, -0.234375, -1.0,\n        -0.2421875, -6.0, -0.75, -6.0, -6.0, -2.0, -0.21875, -2.0, -0.875, -0.875, -6.0, -16.0,\n        -27.0, -2.25, -1.5, -1.5, -8.75, -4.0, -0.25, -1.5, -0.375, -0.375, -1.0, -0.09375,\n    ];\n    let common_values = &[\n        (-1.0, 166355),\n        (-2.0, 83686),\n        (-0.5, 83270),\n        (-1.5, 82925),\n        (-3.0, 41733),\n        (-0.75, 41659),\n        (-4.0, 41550),\n        (-0.25, 41388),\n        (-1.75, 21006),\n        (-6.0, 20858),\n        (-0.125, 20779),\n        (-8.0, 20769),\n        (-0.375, 20764),\n        (-1.25, 20753),\n        (-12.0, 10512),\n        (-2.5, 10508),\n        (-0.0625, 10447),\n        (-0.625, 10414),\n        (-0.1875, 10394),\n        (-16.0, 10354),\n    ];\n    let sample_median = (-1.03125, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.654060290573151),\n        standard_deviation: NiceFloat(374.2183970257817),\n        skewness: NiceFloat(-257.0774178486101),\n        excess_kurtosis: NiceFloat(79059.24924350459),\n    };\n    special_random_negative_finite_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10\n    let values = &[\n        -0.80126953,\n        -0.0000013709068,\n        -0.015609741,\n        -0.98552704,\n        -65536.0,\n        -0.008257866,\n        -0.017333984,\n        -2.25,\n        -7.7089844,\n        -0.00004425831,\n        -0.40625,\n        -24576.0,\n        -37249.0,\n        -1.1991882,\n        -32.085938,\n        -0.4375,\n        -0.0012359619,\n        -1536.0,\n        -0.22912993,\n        -0.0015716553,\n        -1.6662057e-8,\n        -0.044523954,\n        -5694464.0,\n        -0.125,\n        -180.0,\n        -5.625,\n        -1572864.0,\n        -1.9092113e-7,\n        -0.28466797,\n        -0.0068359375,\n        -56737790.0,\n        -4813.375,\n        -20.954966,\n        -4.0,\n        -7.3125,\n        -3.6040926,\n        -0.000007293769,\n        -0.018554688,\n        -0.00009602308,\n        -0.000038146973,\n        -0.00022888184,\n        -36.324017,\n        -0.0068359375,\n        -0.008168057,\n        -20.0,\n        -21.398438,\n        -0.21679688,\n        -176.0,\n        -0.11355591,\n        -6144.0,\n    ];\n    let common_values = &[\n        (-1.0, 5117),\n        (-1.5, 4684),\n        (-2.0, 4643),\n        (-0.5, 4592),\n        (-3.0, 4327),\n        (-0.75, 4245),\n        (-0.25, 4231),\n        (-4.0, 4186),\n        (-8.0, 3995),\n        (-0.375, 3923),\n        (-6.0, 3869),\n        (-0.125, 3864),\n        (-0.0625, 3534),\n        (-16.0, 3502),\n        (-0.1875, 3489),\n        (-12.0, 3418),\n        (-24.0, 3293),\n        (-32.0, 3244),\n        (-0.09375, 3209),\n        (-0.03125, 3152),\n    ];\n    let sample_median = (-1.4882812, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.110316815188854e31),\n        standard_deviation: NiceFloat(5.291057687231236e34),\n        skewness: NiceFloat(-817.3228282694379),\n        excess_kurtosis: NiceFloat(702102.631759681),\n    };\n    special_random_negative_finite_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64\n    let values = &[\n        -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -0.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -0.5, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,\n        -1.0, -1.0, -1.0, -1.0, -1.0,\n    ];\n    let common_values = &[\n        (-1.0, 954991),\n        (-1.5, 14672),\n        (-2.0, 14586),\n        (-0.5, 14578),\n        (-3.0, 243),\n        (-0.25, 228),\n        (-4.0, 226),\n        (-0.75, 207),\n        (-1.25, 127),\n        (-1.75, 118),\n        (-6.0, 6),\n        (-0.125, 4),\n        (-2.5, 3),\n        (-8.0, 3),\n        (-0.625, 3),\n        (-0.375, 2),\n        (-0.875, 2),\n        (-3.5, 1),\n    ];\n    let sample_median = (-1.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0157463749999305),\n        standard_deviation: NiceFloat(0.15870215416222863),\n        skewness: NiceFloat(-5.805128395366302),\n        excess_kurtosis: NiceFloat(73.03005686221248),\n    };\n    special_random_negative_finite_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2\n    let values = &[\n        -1.0, -1.5, -3.125, -1.0, -1.0, -2.0, -2.0, -1.0, -3.0, -1.0, -2.0, -3.0, -4.0, -1.5,\n        -1.625, -2.0, -0.125, -1.0, -0.375, -1.5, -6.375, -4.0, -6.875, -0.5, -0.234375, -1.0,\n        -0.2421875, -6.0, -0.75, -6.0, -6.0, -2.0, -0.21875, -2.0, -0.875, -0.875, -6.0, -16.0,\n        -27.0, -2.25, -1.5, -1.5, -8.75, -4.0, -0.25, -1.5, -0.375, -0.375, -1.0, -0.09375,\n    ];\n    let common_values = &[\n        (-1.0, 166355),\n        (-2.0, 83686),\n        (-0.5, 83270),\n        (-1.5, 82925),\n        (-3.0, 41733),\n        (-0.75, 41659),\n        (-4.0, 41550),\n        (-0.25, 41388),\n        (-1.75, 21006),\n        (-6.0, 20858),\n        (-0.125, 20779),\n        (-8.0, 20769),\n        (-0.375, 20764),\n        (-1.25, 20753),\n        (-12.0, 10512),\n        (-2.5, 10508),\n        (-0.0625, 10447),\n        (-0.625, 10414),\n        (-0.1875, 10394),\n        (-16.0, 10354),\n    ];\n    let sample_median = (-1.03125, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.654060290573151),\n        standard_deviation: NiceFloat(374.2183970257817),\n        skewness: NiceFloat(-257.0774178486101),\n        excess_kurtosis: NiceFloat(79059.24924350459),\n    };\n    special_random_negative_finite_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10\n    let values = &[\n        -0.80126953125,\n        -1.3709068298339844e-6,\n        -0.0156097412109375,\n        -0.9855270385742188,\n        -86113.82421875,\n        -0.012808799743652344,\n        -0.028076171875,\n        -2.75,\n        -7.009765625,\n        -0.000045569613575935364,\n        -0.34375,\n        -24576.0,\n        -33101.0,\n        -1.066680908203125,\n        -53.0390625,\n        -0.3125,\n        -0.0018768310546875,\n        -1536.0,\n        -0.15994291007518768,\n        -0.0014495849609375,\n        -2.5660824576334562e-8,\n        -0.04374957084655762,\n        -6583296.0,\n        -0.125,\n        -156.0,\n        -7.125,\n        -1572864.0,\n        -1.525198978780118e-7,\n        -0.32763671875,\n        -0.0048828125,\n        -47710208.0,\n        -6821.875,\n        -19.824071884155273,\n        -4.0,\n        -4.6875,\n        -2.3686094284057617,\n        -6.33427407592535e-6,\n        -0.0185546875,\n        -0.00007218122482299805,\n        -0.00003814697265625,\n        -0.0001373291015625,\n        -36.43232345581055,\n        -0.0048828125,\n        -0.011424465501870706,\n        -28.0,\n        -18.0546875,\n        -0.2207733978284523,\n        -144.0,\n        -0.083648681640625,\n        -4360.2293701171875,\n    ];\n    let common_values = &[\n        (-1.0, 4779),\n        (-1.5, 4356),\n        (-2.0, 4315),\n        (-0.5, 4233),\n        (-3.0, 4023),\n        (-0.25, 3931),\n        (-0.75, 3911),\n        (-4.0, 3866),\n        (-8.0, 3705),\n        (-0.375, 3612),\n        (-6.0, 3588),\n        (-0.125, 3538),\n        (-0.0625, 3271),\n        (-16.0, 3264),\n        (-0.1875, 3199),\n        (-12.0, 3152),\n        (-24.0, 3033),\n        (-32.0, 2974),\n        (-0.09375, 2963),\n        (-0.03125, 2937),\n    ];\n    let sample_median = (-1.484375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.352183416672257e38),\n        standard_deviation: NiceFloat(5.3521788476440196e41),\n        skewness: NiceFloat(-999.9984999986674),\n        excess_kurtosis: NiceFloat(999995.0000000936),\n    };\n    special_random_negative_finite_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn special_random_negative_finite_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_negative_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1\n    ));\n    assert_panic!(special_random_negative_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1\n    ));\n    assert_panic!(special_random_negative_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1\n    ));\n    assert_panic!(special_random_negative_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0\n    ));\n}\n\n#[test]\nfn special_random_negative_finite_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_negative_finite_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_negative_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::random::special_random_negative_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, NAN_MOMENT_STATS};\nuse std::panic::catch_unwind;\n\nfn special_random_negative_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_negative_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_special_p_numerator,\n            mean_special_p_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_negative_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f32::NEGATIVE_INFINITY,\n        -1.5,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n    ];\n    let common_values = &[\n        (-1.0, 716268),\n        (f32::NEGATIVE_INFINITY, 250209),\n        (-2.0, 10938),\n        (-0.5, 10888),\n        (-1.5, 10871),\n        (-4.0, 172),\n        (-0.25, 165),\n        (-3.0, 161),\n        (-0.75, 155),\n        (-1.25, 75),\n        (-1.75, 74),\n        (-0.375, 6),\n        (-3.5, 4),\n        (-0.125, 4),\n        (-8.0, 3),\n        (-0.875, 2),\n        (-1.875, 2),\n        (-6.0, 1),\n        (-0.625, 1),\n        (-1.125, 1),\n    ];\n    let sample_median = (-1.0, None);\n    special_random_negative_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        -1.0,\n        -1.0,\n        -3.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -2.0,\n        -2.0,\n        -1.0,\n        -3.0,\n        -1.0,\n        -3.0,\n        -3.0,\n        f32::NEGATIVE_INFINITY,\n        -6.0,\n        -1.125,\n        -1.25,\n        f32::NEGATIVE_INFINITY,\n        -3.0,\n        -0.125,\n        -1.0,\n        -0.25,\n        -1.75,\n        -4.0,\n        -4.0,\n        -4.0,\n        -0.75,\n        -0.125,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -0.125,\n        -6.0,\n        f32::NEGATIVE_INFINITY,\n        -0.5,\n        -4.0,\n        -6.5,\n        -2.0,\n        -0.21875,\n        -2.0,\n        -0.5,\n        -0.5,\n        -4.0,\n        -16.0,\n        -16.0,\n        -3.0,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        -10.0,\n        -6.0,\n    ];\n    let common_values = &[\n        (-1.0, 151036),\n        (f32::NEGATIVE_INFINITY, 100224),\n        (-0.5, 75239),\n        (-2.0, 74939),\n        (-1.5, 74396),\n        (-0.25, 37669),\n        (-0.75, 37538),\n        (-3.0, 37523),\n        (-4.0, 37411),\n        (-0.375, 18737),\n        (-6.0, 18708),\n        (-0.125, 18698),\n        (-1.25, 18586),\n        (-8.0, 18570),\n        (-1.75, 18339),\n        (-3.5, 9676),\n        (-0.0625, 9668),\n        (-16.0, 9474),\n        (-0.875, 9416),\n        (-12.0, 9376),\n    ];\n    let sample_median = (-1.5, None);\n    special_random_negative_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        -0.6328125,\n        -9.536743e-7,\n        -0.013671875,\n        -0.6875,\n        -70208.0,\n        -0.01550293,\n        -0.028625488,\n        -3.3095703,\n        -5.775879,\n        -0.000034958124,\n        -0.4375,\n        -31678.0,\n        -49152.0,\n        -1.0,\n        -49.885254,\n        -0.40625,\n        -0.0015869141,\n        -1889.5625,\n        -0.14140439,\n        -0.001449585,\n        -1.4901161e-8,\n        -0.03125,\n        -5750784.0,\n        -0.17578125,\n        -248.0,\n        -5.4375,\n        -1892352.0,\n        -1.5280966e-7,\n        -0.2826419,\n        -0.0057373047,\n        -51642370.0,\n        -6384.0,\n        -27.875542,\n        -6.152041,\n        -6.0,\n        -2.796875,\n        -0.0000057816505,\n        -0.029174805,\n        -0.00011384487,\n        -0.000039815903,\n        -0.00012207031,\n        -48.0,\n        -0.00390625,\n        -0.01171875,\n        -20.0,\n        -21.625,\n        -0.171875,\n        -197.0,\n        -0.11743164,\n        -5532.0,\n    ];\n    let common_values = &[\n        (f32::NEGATIVE_INFINITY, 9989),\n        (-1.0, 5059),\n        (-2.0, 4689),\n        (-0.5, 4622),\n        (-1.5, 4576),\n        (-4.0, 4280),\n        (-3.0, 4153),\n        (-0.25, 4130),\n        (-0.75, 4105),\n        (-8.0, 3912),\n        (-6.0, 3841),\n        (-0.125, 3772),\n        (-0.375, 3663),\n        (-16.0, 3536),\n        (-0.1875, 3530),\n        (-0.0625, 3441),\n        (-12.0, 3433),\n        (-0.09375, 3185),\n        (-0.03125, 3176),\n        (-32.0, 3094),\n    ];\n    let sample_median = (-1.5, None);\n    special_random_negative_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f64::NEGATIVE_INFINITY,\n        -1.5,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n    ];\n    let common_values = &[\n        (-1.0, 716268),\n        (f64::NEGATIVE_INFINITY, 250209),\n        (-2.0, 10938),\n        (-0.5, 10888),\n        (-1.5, 10871),\n        (-4.0, 172),\n        (-0.25, 165),\n        (-3.0, 161),\n        (-0.75, 155),\n        (-1.25, 75),\n        (-1.75, 74),\n        (-0.375, 6),\n        (-3.5, 4),\n        (-0.125, 4),\n        (-8.0, 3),\n        (-0.875, 2),\n        (-1.875, 2),\n        (-6.0, 1),\n        (-0.625, 1),\n        (-1.125, 1),\n    ];\n    let sample_median = (-1.0, None);\n    special_random_negative_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        -1.0,\n        -1.0,\n        -3.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        -1.0,\n        -2.0,\n        -2.0,\n        -1.0,\n        -3.0,\n        -1.0,\n        -3.0,\n        -3.0,\n        f64::NEGATIVE_INFINITY,\n        -6.0,\n        -1.125,\n        -1.25,\n        f64::NEGATIVE_INFINITY,\n        -3.0,\n        -0.125,\n        -1.0,\n        -0.25,\n        -1.75,\n        -4.0,\n        -4.0,\n        -4.0,\n        -0.75,\n        -0.125,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -0.125,\n        -6.0,\n        f64::NEGATIVE_INFINITY,\n        -0.5,\n        -4.0,\n        -6.5,\n        -2.0,\n        -0.21875,\n        -2.0,\n        -0.5,\n        -0.5,\n        -4.0,\n        -16.0,\n        -16.0,\n        -3.0,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        -10.0,\n        -6.0,\n    ];\n    let common_values = &[\n        (-1.0, 151036),\n        (f64::NEGATIVE_INFINITY, 100224),\n        (-0.5, 75239),\n        (-2.0, 74939),\n        (-1.5, 74396),\n        (-0.25, 37669),\n        (-0.75, 37538),\n        (-3.0, 37523),\n        (-4.0, 37411),\n        (-0.375, 18737),\n        (-6.0, 18708),\n        (-0.125, 18698),\n        (-1.25, 18586),\n        (-8.0, 18570),\n        (-1.75, 18339),\n        (-3.5, 9676),\n        (-0.0625, 9668),\n        (-16.0, 9474),\n        (-0.875, 9416),\n        (-12.0, 9376),\n    ];\n    let sample_median = (-1.5, None);\n    special_random_negative_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        -0.6328125,\n        -9.5367431640625e-7,\n        -0.013671875,\n        -0.6875,\n        -70208.0,\n        -0.0155029296875,\n        -0.02862548828125,\n        -3.3095703125,\n        -5.77587890625,\n        -0.0000349581241607666,\n        -0.4375,\n        -31678.0,\n        -49152.0,\n        -1.0,\n        -49.88525390625,\n        -0.40625,\n        -0.0015869140625,\n        -1889.5625,\n        -0.141404390335083,\n        -0.0014495849609375,\n        -1.4901161193847656e-8,\n        -0.03125,\n        -5750784.0,\n        -0.17578125,\n        -248.0,\n        -5.4375,\n        -1892352.0,\n        -1.528096618130803e-7,\n        -0.2826418876647949,\n        -0.0057373046875,\n        -51642368.0,\n        -6384.0,\n        -27.87554168701172,\n        -6.152040958404541,\n        -6.0,\n        -2.796875,\n        -5.781650543212891e-6,\n        -0.0291748046875,\n        -0.0001138448715209961,\n        -0.00003981590270996094,\n        -0.0001220703125,\n        -48.0,\n        -0.00390625,\n        -0.01171875,\n        -20.0,\n        -21.625,\n        -0.171875,\n        -205.175663292408,\n        -0.118408203125,\n        -6436.0,\n    ];\n    let common_values = &[\n        (f64::NEGATIVE_INFINITY, 9989),\n        (-1.0, 4750),\n        (-2.0, 4357),\n        (-0.5, 4257),\n        (-1.5, 4256),\n        (-4.0, 3955),\n        (-3.0, 3844),\n        (-0.25, 3812),\n        (-0.75, 3799),\n        (-8.0, 3628),\n        (-6.0, 3535),\n        (-0.125, 3447),\n        (-0.375, 3398),\n        (-16.0, 3257),\n        (-0.1875, 3234),\n        (-12.0, 3202),\n        (-0.0625, 3182),\n        (-0.09375, 2957),\n        (-0.03125, 2919),\n        (-32.0, 2805),\n    ];\n    let sample_median = (-1.516387939453125, Some(-1.5162887573242188));\n    special_random_negative_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n}\n\nfn special_random_negative_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_negative_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_negative_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_negative_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_negative_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0,\n        1,\n        10\n    ));\n    assert_panic!(special_random_negative_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        1,\n        0\n    ));\n    assert_panic!(special_random_negative_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        2,\n        1\n    ));\n}\n\n#[test]\nfn special_random_negative_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_negative_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_nonzero_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::special_random_nonzero_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn special_random_nonzero_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_nonzero_finite_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_nonzero_finite_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64\n    let values = &[\n        -1.5, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0,\n        -1.0, -1.0, -1.0, -0.5, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0,\n        -1.0, 1.0, 0.5, -1.0, 1.0, -1.5, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.5, 1.0, -1.0, 1.0, 1.0,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 478216),\n        (-1.0, 476955),\n        (-2.0, 7440),\n        (-1.5, 7332),\n        (0.5, 7303),\n        (-0.5, 7275),\n        (1.5, 7189),\n        (2.0, 7170),\n        (0.25, 120),\n        (4.0, 116),\n        (-4.0, 114),\n        (3.0, 111),\n        (-3.0, 107),\n        (0.75, 105),\n        (-0.25, 103),\n        (-0.75, 103),\n        (-1.25, 62),\n        (1.75, 61),\n        (1.25, 50),\n        (-1.75, 39),\n    ];\n    let sample_median = (0.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.000541124999999992),\n        standard_deviation: NiceFloat(1.0278732889234226),\n        skewness: NiceFloat(-0.0043076036065952585),\n        excess_kurtosis: NiceFloat(-1.7844456265500606),\n    };\n    special_random_nonzero_finite_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2\n    let values = &[\n        -1.0, -1.0, -3.0, 1.0, -1.0, 2.0, -2.0, -1.0, -3.0, 1.0, 3.0, 3.0, -6.0, -1.125, 1.25,\n        -3.0, -0.125, -1.0, -0.25, -1.75, 4.0, 4.0, -4.0, -0.75, 0.125, -1.0, -0.125, 6.0, 0.5,\n        -4.0, -6.5, 2.0, -0.21875, 2.0, 0.5, -0.5, 4.0, -16.0, 16.0, -3.0, 1.0, 1.0, 10.0, -6.0,\n        0.25, 1.0, -0.390625, 0.375, 1.5, 0.09375,\n    ];\n    let common_values = &[\n        (1.0, 84345),\n        (-1.0, 83427),\n        (-0.5, 42050),\n        (2.0, 41730),\n        (-2.0, 41718),\n        (0.5, 41631),\n        (1.5, 41446),\n        (-1.5, 41312),\n        (3.0, 20932),\n        (-0.25, 20908),\n        (-3.0, 20854),\n        (-0.75, 20853),\n        (-4.0, 20831),\n        (0.25, 20819),\n        (0.75, 20775),\n        (4.0, 20696),\n        (0.125, 10518),\n        (0.375, 10492),\n        (-6.0, 10471),\n        (8.0, 10359),\n    ];\n    let sample_median = (0.001953125, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.14825837830007416),\n        standard_deviation: NiceFloat(371.086277437807),\n        skewness: NiceFloat(-124.2604097831067),\n        excess_kurtosis: NiceFloat(123898.81502837151),\n    };\n    special_random_nonzero_finite_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10\n    let values = &[\n        -0.6328125,\n        -9.536743e-7,\n        -0.013671875,\n        0.6875,\n        -70208.0,\n        0.01550293,\n        -0.028625488,\n        -3.3095703,\n        -5.775879,\n        0.000034958124,\n        0.4375,\n        31678.0,\n        -49152.0,\n        -1.0,\n        49.885254,\n        -0.40625,\n        -0.0015869141,\n        -1889.5625,\n        -0.14140439,\n        -0.001449585,\n        1.4901161e-8,\n        0.03125,\n        -5750784.0,\n        -0.17578125,\n        248.0,\n        -5.4375,\n        -1892352.0,\n        1.5280966e-7,\n        0.2826419,\n        -0.0057373047,\n        -51642370.0,\n        6384.0,\n        -27.875542,\n        6.152041,\n        6.0,\n        -2.796875,\n        0.0000057816505,\n        -0.029174805,\n        0.00011384487,\n        -0.000039815903,\n        0.00012207031,\n        48.0,\n        0.00390625,\n        -0.01171875,\n        20.0,\n        21.625,\n        -0.171875,\n        197.0,\n        0.11743164,\n        5532.0,\n    ];\n    let common_values = &[\n        (-1.0, 2552),\n        (1.0, 2548),\n        (2.0, 2409),\n        (-0.5, 2367),\n        (-2.0, 2335),\n        (1.5, 2326),\n        (0.5, 2308),\n        (-1.5, 2290),\n        (-4.0, 2193),\n        (4.0, 2130),\n        (-3.0, 2106),\n        (3.0, 2096),\n        (0.25, 2092),\n        (-0.25, 2085),\n        (-0.75, 2084),\n        (0.75, 2065),\n        (8.0, 2008),\n        (6.0, 1972),\n        (-8.0, 1945),\n        (-0.125, 1922),\n    ];\n    let sample_median = (1.6940659e-20, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.7799889499291132e31),\n        standard_deviation: NiceFloat(6.206676176137639e34),\n        skewness: NiceFloat(-784.8389177089807),\n        excess_kurtosis: NiceFloat(789333.7989913624),\n    };\n    special_random_nonzero_finite_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64\n    let values = &[\n        -1.5, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0,\n        -1.0, -1.0, -1.0, -0.5, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0,\n        -1.0, 1.0, 0.5, -1.0, 1.0, -1.5, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.5, 1.0, -1.0, 1.0, 1.0,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 478216),\n        (-1.0, 476955),\n        (-2.0, 7440),\n        (-1.5, 7332),\n        (0.5, 7303),\n        (-0.5, 7275),\n        (1.5, 7189),\n        (2.0, 7170),\n        (0.25, 120),\n        (4.0, 116),\n        (-4.0, 114),\n        (3.0, 111),\n        (-3.0, 107),\n        (0.75, 105),\n        (-0.25, 103),\n        (-0.75, 103),\n        (-1.25, 62),\n        (1.75, 61),\n        (1.25, 50),\n        (-1.75, 39),\n    ];\n    let sample_median = (0.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.000541124999999992),\n        standard_deviation: NiceFloat(1.0278732889234226),\n        skewness: NiceFloat(-0.0043076036065952585),\n        excess_kurtosis: NiceFloat(-1.7844456265500606),\n    };\n    special_random_nonzero_finite_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2\n    let values = &[\n        -1.0, -1.0, -3.0, 1.0, -1.0, 2.0, -2.0, -1.0, -3.0, 1.0, 3.0, 3.0, -6.0, -1.125, 1.25,\n        -3.0, -0.125, -1.0, -0.25, -1.75, 4.0, 4.0, -4.0, -0.75, 0.125, -1.0, -0.125, 6.0, 0.5,\n        -4.0, -6.5, 2.0, -0.21875, 2.0, 0.5, -0.5, 4.0, -16.0, 16.0, -3.0, 1.0, 1.0, 10.0, -6.0,\n        0.25, 1.0, -0.390625, 0.375, 1.5, 0.09375,\n    ];\n    let common_values = &[\n        (1.0, 84345),\n        (-1.0, 83427),\n        (-0.5, 42050),\n        (2.0, 41730),\n        (-2.0, 41718),\n        (0.5, 41631),\n        (1.5, 41446),\n        (-1.5, 41312),\n        (3.0, 20932),\n        (-0.25, 20908),\n        (-3.0, 20854),\n        (-0.75, 20853),\n        (-4.0, 20831),\n        (0.25, 20819),\n        (0.75, 20775),\n        (4.0, 20696),\n        (0.125, 10518),\n        (0.375, 10492),\n        (-6.0, 10471),\n        (8.0, 10359),\n    ];\n    let sample_median = (0.001953125, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.14825837830007416),\n        standard_deviation: NiceFloat(371.086277437807),\n        skewness: NiceFloat(-124.2604097831067),\n        excess_kurtosis: NiceFloat(123898.81502837151),\n    };\n    special_random_nonzero_finite_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10\n    let values = &[\n        -0.6328125,\n        -9.5367431640625e-7,\n        -0.013671875,\n        0.6875,\n        -70208.0,\n        0.0155029296875,\n        -0.02862548828125,\n        -3.3095703125,\n        -5.77587890625,\n        0.0000349581241607666,\n        0.4375,\n        31678.0,\n        -49152.0,\n        -1.0,\n        49.88525390625,\n        -0.40625,\n        -0.0015869140625,\n        -1889.5625,\n        -0.141404390335083,\n        -0.0014495849609375,\n        1.4901161193847656e-8,\n        0.03125,\n        -5750784.0,\n        -0.17578125,\n        248.0,\n        -5.4375,\n        -1892352.0,\n        1.528096618130803e-7,\n        0.2826418876647949,\n        -0.0057373046875,\n        -51642368.0,\n        6384.0,\n        -27.87554168701172,\n        6.152040958404541,\n        6.0,\n        -2.796875,\n        5.781650543212891e-6,\n        -0.0291748046875,\n        0.0001138448715209961,\n        -0.00003981590270996094,\n        0.0001220703125,\n        48.0,\n        0.00390625,\n        -0.01171875,\n        20.0,\n        21.625,\n        -0.171875,\n        205.175663292408,\n        0.118408203125,\n        6436.0,\n    ];\n    let common_values = &[\n        (-1.0, 2444),\n        (1.0, 2346),\n        (2.0, 2250),\n        (1.5, 2165),\n        (-0.5, 2156),\n        (-2.0, 2155),\n        (0.5, 2150),\n        (-1.5, 2135),\n        (4.0, 2036),\n        (-4.0, 1965),\n        (0.75, 1957),\n        (-0.25, 1953),\n        (3.0, 1950),\n        (-3.0, 1943),\n        (0.25, 1899),\n        (-0.75, 1878),\n        (8.0, 1866),\n        (6.0, 1819),\n        (-8.0, 1804),\n        (0.125, 1779),\n    ];\n    let sample_median = (2.3597808514912774e-20, Some(2.371692252312041e-20));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.965455610813376e38),\n        standard_deviation: NiceFloat(5.9654493406037485e41),\n        skewness: NiceFloat(999.998499997817),\n        excess_kurtosis: NiceFloat(999994.9999989544),\n    };\n    special_random_nonzero_finite_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn special_random_nonzero_finite_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_nonzero_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1\n    ));\n    assert_panic!(special_random_nonzero_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1\n    ));\n    assert_panic!(special_random_nonzero_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1\n    ));\n    assert_panic!(special_random_nonzero_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0\n    ));\n}\n\n#[test]\nfn special_random_nonzero_finite_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_nonzero_finite_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_nonzero_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::random::special_random_nonzero_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, NAN_MOMENT_STATS};\nuse std::panic::catch_unwind;\n\nfn special_random_nonzero_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_nonzero_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_special_p_numerator,\n            mean_special_p_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_nonzero_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f32::INFINITY,\n        1.0,\n        1.0,\n        f32::NEGATIVE_INFINITY,\n        1.0,\n        -1.0,\n        f32::INFINITY,\n        -1.0,\n        f32::INFINITY,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        -1.0,\n        1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        0.5,\n        1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        1.0,\n        1.0,\n        f32::INFINITY,\n        -1.5,\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        f32::INFINITY,\n        1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        f32::INFINITY,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 358244),\n        (-1.0, 357926),\n        (f32::INFINITY, 125637),\n        (f32::NEGATIVE_INFINITY, 124572),\n        (2.0, 5538),\n        (1.5, 5500),\n        (0.5, 5497),\n        (-1.5, 5454),\n        (-2.0, 5379),\n        (-0.5, 5357),\n        (0.75, 102),\n        (3.0, 98),\n        (-4.0, 95),\n        (-0.25, 91),\n        (-0.75, 87),\n        (-3.0, 86),\n        (0.25, 79),\n        (4.0, 75),\n        (-1.25, 48),\n        (1.75, 44),\n    ];\n    let sample_median = (0.5, None);\n    special_random_nonzero_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        1.0,\n        1.25,\n        3.0,\n        f32::INFINITY,\n        -1.0,\n        -1.0,\n        -2.0,\n        -3.5,\n        1.0,\n        2.0,\n        -1.5,\n        -2.5,\n        -2.0,\n        f32::NEGATIVE_INFINITY,\n        -6.5,\n        -1.0,\n        -1.0,\n        f32::INFINITY,\n        3.0,\n        -0.21875,\n        -1.0,\n        0.25,\n        1.5,\n        5.25,\n        -4.0,\n        7.0,\n        -0.5,\n        0.1875,\n        1.25,\n        f32::INFINITY,\n        -0.1875,\n        -7.5,\n        f32::NEGATIVE_INFINITY,\n        0.75,\n        -7.0,\n        -6.0,\n        -3.0,\n        0.234375,\n        -2.0,\n        -0.875,\n        -0.75,\n        6.0,\n        -24.0,\n        24.0,\n        -2.0,\n        1.5,\n        f32::NEGATIVE_INFINITY,\n        -1.25,\n        14.0,\n        5.0,\n    ];\n    let common_values = &[\n        (1.0, 74789),\n        (-1.0, 74702),\n        (f32::INFINITY, 50351),\n        (f32::NEGATIVE_INFINITY, 49873),\n        (1.5, 38119),\n        (-0.5, 37713),\n        (2.0, 37640),\n        (-1.5, 37613),\n        (-2.0, 37333),\n        (0.5, 37027),\n        (0.75, 19050),\n        (4.0, 18892),\n        (0.25, 18875),\n        (-3.0, 18866),\n        (3.0, 18821),\n        (-0.75, 18725),\n        (-4.0, 18663),\n        (-0.25, 18537),\n        (0.125, 9445),\n        (-0.375, 9395),\n    ];\n    let sample_median = (0.0048828125, None);\n    special_random_nonzero_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        0.65625,\n        0.0000014255784,\n        0.013183594,\n        -0.8125,\n        -74240.0,\n        -0.0078125,\n        -0.03060913,\n        3.331552,\n        4.75,\n        -0.000038146973,\n        -0.3125,\n        -27136.0,\n        -59392.0,\n        -1.75,\n        -41.1875,\n        0.30940247,\n        -0.0009765625,\n        -1536.0,\n        0.2109375,\n        0.0014648438,\n        2.1129381e-8,\n        -0.037109375,\n        5242880.0,\n        -0.21386719,\n        134.21094,\n        4.184082,\n        -1561370.0,\n        -2.1420419e-7,\n        0.38085938,\n        -0.007003784,\n        -37748736.0,\n        -6448.0,\n        28.25,\n        -6.703125,\n        -4.483364,\n        -3.1757812,\n        0.000003915804,\n        -0.020751953,\n        0.00011110306,\n        -0.000053405256,\n        0.00019985437,\n        -35.40625,\n        0.005859375,\n        0.0078125,\n        28.25,\n        30.0,\n        -0.20776367,\n        -144.0,\n        -0.109375,\n        -6144.0,\n    ];\n    let common_values = &[\n        (f32::INFINITY, 5098),\n        (f32::NEGATIVE_INFINITY, 4891),\n        (1.0, 2559),\n        (-1.0, 2528),\n        (0.5, 2362),\n        (-2.0, 2312),\n        (-1.5, 2306),\n        (2.0, 2304),\n        (1.5, 2275),\n        (-0.5, 2243),\n        (-3.0, 2204),\n        (-4.0, 2163),\n        (-0.25, 2129),\n        (0.75, 2103),\n        (3.0, 2081),\n        (0.25, 2070),\n        (-0.75, 2047),\n        (4.0, 2038),\n        (-6.0, 1943),\n        (-8.0, 1918),\n    ];\n    let sample_median = (2.1684043e-19, None);\n    special_random_nonzero_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f64::INFINITY,\n        1.0,\n        1.0,\n        f64::NEGATIVE_INFINITY,\n        1.0,\n        -1.0,\n        f64::INFINITY,\n        -1.0,\n        f64::INFINITY,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        -1.0,\n        1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        0.5,\n        1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        1.0,\n        1.0,\n        f64::INFINITY,\n        -1.5,\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        f64::INFINITY,\n        1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        f64::INFINITY,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 358244),\n        (-1.0, 357926),\n        (f64::INFINITY, 125637),\n        (f64::NEGATIVE_INFINITY, 124572),\n        (2.0, 5538),\n        (1.5, 5500),\n        (0.5, 5497),\n        (-1.5, 5454),\n        (-2.0, 5379),\n        (-0.5, 5357),\n        (0.75, 102),\n        (3.0, 98),\n        (-4.0, 95),\n        (-0.25, 91),\n        (-0.75, 87),\n        (-3.0, 86),\n        (0.25, 79),\n        (4.0, 75),\n        (-1.25, 48),\n        (1.75, 44),\n    ];\n    let sample_median = (0.5, None);\n    special_random_nonzero_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        1.0,\n        1.25,\n        3.0,\n        f64::INFINITY,\n        -1.0,\n        -1.0,\n        -2.0,\n        -3.5,\n        1.0,\n        2.0,\n        -1.5,\n        -2.5,\n        -2.0,\n        f64::NEGATIVE_INFINITY,\n        -6.5,\n        -1.0,\n        -1.0,\n        f64::INFINITY,\n        3.0,\n        -0.21875,\n        -1.0,\n        0.25,\n        1.5,\n        5.25,\n        -4.0,\n        7.0,\n        -0.5,\n        0.1875,\n        1.25,\n        f64::INFINITY,\n        -0.1875,\n        -7.5,\n        f64::NEGATIVE_INFINITY,\n        0.75,\n        -7.0,\n        -6.0,\n        -3.0,\n        0.234375,\n        -2.0,\n        -0.875,\n        -0.75,\n        6.0,\n        -24.0,\n        24.0,\n        -2.0,\n        1.5,\n        f64::NEGATIVE_INFINITY,\n        -1.25,\n        14.0,\n        5.0,\n    ];\n    let common_values = &[\n        (1.0, 74789),\n        (-1.0, 74702),\n        (f64::INFINITY, 50351),\n        (f64::NEGATIVE_INFINITY, 49873),\n        (1.5, 38119),\n        (-0.5, 37713),\n        (2.0, 37640),\n        (-1.5, 37613),\n        (-2.0, 37333),\n        (0.5, 37027),\n        (0.75, 19050),\n        (4.0, 18892),\n        (0.25, 18875),\n        (-3.0, 18866),\n        (3.0, 18821),\n        (-0.75, 18725),\n        (-4.0, 18663),\n        (-0.25, 18537),\n        (0.125, 9445),\n        (-0.375, 9395),\n    ];\n    let sample_median = (0.0048828125, None);\n    special_random_nonzero_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        0.7709910366684198,\n        1.2504315236583352e-6,\n        0.00830078125,\n        -0.8125,\n        -85504.0,\n        -0.0078125,\n        -0.018890380859375,\n        2.5721821784973145,\n        5.75,\n        -0.00003814697265625,\n        -0.4375,\n        -24064.0,\n        -43008.0,\n        -1.75,\n        -54.6875,\n        0.4641265869140625,\n        -0.0014760522753931582,\n        -1536.0,\n        0.1484375,\n        0.00146484375,\n        1.9383151084184647e-8,\n        -0.060546875,\n        7340032.0,\n        -0.1982421875,\n        203.0546875,\n        4.57177734375,\n        -1555162.0,\n        -2.0675361156463623e-7,\n        0.279296875,\n        -0.0045928955078125,\n        -46137344.0,\n        -5712.0,\n        17.75,\n        -5.265625,\n        -7.966220855712891,\n        -2.99609375,\n        5.397188942879438e-6,\n        -0.017333984375,\n        0.00011491775512695312,\n        -0.00005845972555107437,\n        0.00020831823348999023,\n        -46.78125,\n        0.005859375,\n        0.0078125,\n        27.25,\n        30.0,\n        -0.175537109375,\n        -208.0,\n        -0.109375,\n        -6144.0,\n    ];\n    let common_values = &[\n        (f64::INFINITY, 5098),\n        (f64::NEGATIVE_INFINITY, 4891),\n        (1.0, 2396),\n        (-1.0, 2336),\n        (-2.0, 2200),\n        (-1.5, 2169),\n        (0.5, 2116),\n        (2.0, 2108),\n        (-0.5, 2101),\n        (1.5, 2085),\n        (-3.0, 2000),\n        (4.0, 1993),\n        (3.0, 1969),\n        (-0.25, 1955),\n        (0.75, 1946),\n        (0.25, 1917),\n        (-4.0, 1882),\n        (-0.75, 1863),\n        (8.0, 1826),\n        (-6.0, 1782),\n    ];\n    let sample_median = (2.1519930816179568e-19, Some(2.168404344971009e-19));\n    special_random_nonzero_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n}\n\nfn special_random_nonzero_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_nonzero_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_nonzero_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_nonzero_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_nonzero_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0,\n        1,\n        10\n    ));\n    assert_panic!(special_random_nonzero_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        1,\n        0\n    ));\n    assert_panic!(special_random_nonzero_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        2,\n        1\n    ));\n}\n\n#[test]\nfn special_random_nonzero_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_nonzero_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_positive_finite_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::special_random_positive_finite_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn special_random_positive_finite_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_positive_finite_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_positive_finite_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64\n    let values = &[\n        1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,\n        1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 1.0,\n        1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,\n    ];\n    let common_values = &[\n        (1.0, 954991),\n        (1.5, 14672),\n        (2.0, 14586),\n        (0.5, 14578),\n        (3.0, 243),\n        (0.25, 228),\n        (4.0, 226),\n        (0.75, 207),\n        (1.25, 127),\n        (1.75, 118),\n        (6.0, 6),\n        (0.125, 4),\n        (2.5, 3),\n        (8.0, 3),\n        (0.625, 3),\n        (0.375, 2),\n        (0.875, 2),\n        (3.5, 1),\n    ];\n    let sample_median = (1.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0157463749999305),\n        standard_deviation: NiceFloat(0.15870215416222863),\n        skewness: NiceFloat(5.805128395366302),\n        excess_kurtosis: NiceFloat(73.03005686221248),\n    };\n    special_random_positive_finite_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2\n    let values = &[\n        1.0, 1.5, 3.125, 1.0, 1.0, 2.0, 2.0, 1.0, 3.0, 1.0, 2.0, 3.0, 4.0, 1.5, 1.625, 2.0, 0.125,\n        1.0, 0.375, 1.5, 6.375, 4.0, 6.875, 0.5, 0.234375, 1.0, 0.2421875, 6.0, 0.75, 6.0, 6.0,\n        2.0, 0.21875, 2.0, 0.875, 0.875, 6.0, 16.0, 27.0, 2.25, 1.5, 1.5, 8.75, 4.0, 0.25, 1.5,\n        0.375, 0.375, 1.0, 0.09375,\n    ];\n    let common_values = &[\n        (1.0, 166355),\n        (2.0, 83686),\n        (0.5, 83270),\n        (1.5, 82925),\n        (3.0, 41733),\n        (0.75, 41659),\n        (4.0, 41550),\n        (0.25, 41388),\n        (1.75, 21006),\n        (6.0, 20858),\n        (0.125, 20779),\n        (8.0, 20769),\n        (0.375, 20764),\n        (1.25, 20753),\n        (12.0, 10512),\n        (2.5, 10508),\n        (0.0625, 10447),\n        (0.625, 10414),\n        (0.1875, 10394),\n        (16.0, 10354),\n    ];\n    let sample_median = (1.03125, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.654060290573151),\n        standard_deviation: NiceFloat(374.2183970257817),\n        skewness: NiceFloat(257.0774178486101),\n        excess_kurtosis: NiceFloat(79059.24924350459),\n    };\n    special_random_positive_finite_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10\n    let values = &[\n        0.80126953,\n        0.0000013709068,\n        0.015609741,\n        0.98552704,\n        65536.0,\n        0.008257866,\n        0.017333984,\n        2.25,\n        7.7089844,\n        0.00004425831,\n        0.40625,\n        24576.0,\n        37249.0,\n        1.1991882,\n        32.085938,\n        0.4375,\n        0.0012359619,\n        1536.0,\n        0.22912993,\n        0.0015716553,\n        1.6662057e-8,\n        0.044523954,\n        5694464.0,\n        0.125,\n        180.0,\n        5.625,\n        1572864.0,\n        1.9092113e-7,\n        0.28466797,\n        0.0068359375,\n        56737790.0,\n        4813.375,\n        20.954966,\n        4.0,\n        7.3125,\n        3.6040926,\n        0.000007293769,\n        0.018554688,\n        0.00009602308,\n        0.000038146973,\n        0.00022888184,\n        36.324017,\n        0.0068359375,\n        0.008168057,\n        20.0,\n        21.398438,\n        0.21679688,\n        176.0,\n        0.11355591,\n        6144.0,\n    ];\n    let common_values = &[\n        (1.0, 5117),\n        (1.5, 4684),\n        (2.0, 4643),\n        (0.5, 4592),\n        (3.0, 4327),\n        (0.75, 4245),\n        (0.25, 4231),\n        (4.0, 4186),\n        (8.0, 3995),\n        (0.375, 3923),\n        (6.0, 3869),\n        (0.125, 3864),\n        (0.0625, 3534),\n        (16.0, 3502),\n        (0.1875, 3489),\n        (12.0, 3418),\n        (24.0, 3293),\n        (32.0, 3244),\n        (0.09375, 3209),\n        (0.03125, 3152),\n    ];\n    let sample_median = (1.4882812, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.110316815188854e31),\n        standard_deviation: NiceFloat(5.291057687231236e34),\n        skewness: NiceFloat(817.3228282694379),\n        excess_kurtosis: NiceFloat(702102.631759681),\n    };\n    special_random_positive_finite_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64\n    let values = &[\n        1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,\n        1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 1.0,\n        1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,\n    ];\n    let common_values = &[\n        (1.0, 954991),\n        (1.5, 14672),\n        (2.0, 14586),\n        (0.5, 14578),\n        (3.0, 243),\n        (0.25, 228),\n        (4.0, 226),\n        (0.75, 207),\n        (1.25, 127),\n        (1.75, 118),\n        (6.0, 6),\n        (0.125, 4),\n        (2.5, 3),\n        (8.0, 3),\n        (0.625, 3),\n        (0.375, 2),\n        (0.875, 2),\n        (3.5, 1),\n    ];\n    let sample_median = (1.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0157463749999305),\n        standard_deviation: NiceFloat(0.15870215416222863),\n        skewness: NiceFloat(5.805128395366302),\n        excess_kurtosis: NiceFloat(73.03005686221248),\n    };\n    special_random_positive_finite_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2\n    let values = &[\n        1.0, 1.5, 3.125, 1.0, 1.0, 2.0, 2.0, 1.0, 3.0, 1.0, 2.0, 3.0, 4.0, 1.5, 1.625, 2.0, 0.125,\n        1.0, 0.375, 1.5, 6.375, 4.0, 6.875, 0.5, 0.234375, 1.0, 0.2421875, 6.0, 0.75, 6.0, 6.0,\n        2.0, 0.21875, 2.0, 0.875, 0.875, 6.0, 16.0, 27.0, 2.25, 1.5, 1.5, 8.75, 4.0, 0.25, 1.5,\n        0.375, 0.375, 1.0, 0.09375,\n    ];\n    let common_values = &[\n        (1.0, 166355),\n        (2.0, 83686),\n        (0.5, 83270),\n        (1.5, 82925),\n        (3.0, 41733),\n        (0.75, 41659),\n        (4.0, 41550),\n        (0.25, 41388),\n        (1.75, 21006),\n        (6.0, 20858),\n        (0.125, 20779),\n        (8.0, 20769),\n        (0.375, 20764),\n        (1.25, 20753),\n        (12.0, 10512),\n        (2.5, 10508),\n        (0.0625, 10447),\n        (0.625, 10414),\n        (0.1875, 10394),\n        (16.0, 10354),\n    ];\n    let sample_median = (1.03125, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.654060290573151),\n        standard_deviation: NiceFloat(374.2183970257817),\n        skewness: NiceFloat(257.0774178486101),\n        excess_kurtosis: NiceFloat(79059.24924350459),\n    };\n    special_random_positive_finite_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10\n    let values = &[\n        0.80126953125,\n        1.3709068298339844e-6,\n        0.0156097412109375,\n        0.9855270385742188,\n        86113.82421875,\n        0.012808799743652344,\n        0.028076171875,\n        2.75,\n        7.009765625,\n        0.000045569613575935364,\n        0.34375,\n        24576.0,\n        33101.0,\n        1.066680908203125,\n        53.0390625,\n        0.3125,\n        0.0018768310546875,\n        1536.0,\n        0.15994291007518768,\n        0.0014495849609375,\n        2.5660824576334562e-8,\n        0.04374957084655762,\n        6583296.0,\n        0.125,\n        156.0,\n        7.125,\n        1572864.0,\n        1.525198978780118e-7,\n        0.32763671875,\n        0.0048828125,\n        47710208.0,\n        6821.875,\n        19.824071884155273,\n        4.0,\n        4.6875,\n        2.3686094284057617,\n        6.33427407592535e-6,\n        0.0185546875,\n        0.00007218122482299805,\n        0.00003814697265625,\n        0.0001373291015625,\n        36.43232345581055,\n        0.0048828125,\n        0.011424465501870706,\n        28.0,\n        18.0546875,\n        0.2207733978284523,\n        144.0,\n        0.083648681640625,\n        4360.2293701171875,\n    ];\n    let common_values = &[\n        (1.0, 4779),\n        (1.5, 4356),\n        (2.0, 4315),\n        (0.5, 4233),\n        (3.0, 4023),\n        (0.25, 3931),\n        (0.75, 3911),\n        (4.0, 3866),\n        (8.0, 3705),\n        (0.375, 3612),\n        (6.0, 3588),\n        (0.125, 3538),\n        (0.0625, 3271),\n        (16.0, 3264),\n        (0.1875, 3199),\n        (12.0, 3152),\n        (24.0, 3033),\n        (32.0, 2974),\n        (0.09375, 2963),\n        (0.03125, 2937),\n    ];\n    let sample_median = (1.484375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.352183416672257e38),\n        standard_deviation: NiceFloat(5.3521788476440196e41),\n        skewness: NiceFloat(999.9984999986674),\n        excess_kurtosis: NiceFloat(999995.0000000936),\n    };\n    special_random_positive_finite_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn special_random_positive_finite_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_positive_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1\n    ));\n    assert_panic!(special_random_positive_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1\n    ));\n    assert_panic!(special_random_positive_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1\n    ));\n    assert_panic!(special_random_positive_finite_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0\n    ));\n}\n\n#[test]\nfn special_random_positive_finite_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_positive_finite_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_positive_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::random::special_random_positive_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, NAN_MOMENT_STATS};\nuse std::panic::catch_unwind;\n\nfn special_random_positive_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_positive_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_special_p_numerator,\n            mean_special_p_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_positive_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f32::INFINITY,\n        1.5,\n        1.0,\n        f32::INFINITY,\n        1.0,\n        1.0,\n        f32::INFINITY,\n        1.0,\n        f32::INFINITY,\n        f32::INFINITY,\n        1.0,\n        f32::INFINITY,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        0.5,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        f32::INFINITY,\n        1.0,\n        f32::INFINITY,\n        f32::INFINITY,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        f32::INFINITY,\n        1.0,\n        1.0,\n        0.5,\n        1.0,\n        f32::INFINITY,\n        f32::INFINITY,\n        f32::INFINITY,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 716268),\n        (f32::INFINITY, 250209),\n        (2.0, 10938),\n        (0.5, 10888),\n        (1.5, 10871),\n        (4.0, 172),\n        (0.25, 165),\n        (3.0, 161),\n        (0.75, 155),\n        (1.25, 75),\n        (1.75, 74),\n        (0.375, 6),\n        (3.5, 4),\n        (0.125, 4),\n        (8.0, 3),\n        (0.875, 2),\n        (1.875, 2),\n        (6.0, 1),\n        (0.625, 1),\n        (1.125, 1),\n    ];\n    let sample_median = (1.0, None);\n    special_random_positive_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        1.0,\n        1.0,\n        3.0,\n        f32::INFINITY,\n        1.0,\n        1.0,\n        2.0,\n        2.0,\n        1.0,\n        3.0,\n        1.0,\n        3.0,\n        3.0,\n        f32::INFINITY,\n        6.0,\n        1.125,\n        1.25,\n        f32::INFINITY,\n        3.0,\n        0.125,\n        1.0,\n        0.25,\n        1.75,\n        4.0,\n        4.0,\n        4.0,\n        0.75,\n        0.125,\n        1.0,\n        f32::INFINITY,\n        0.125,\n        6.0,\n        f32::INFINITY,\n        0.5,\n        4.0,\n        6.5,\n        2.0,\n        0.21875,\n        2.0,\n        0.5,\n        0.5,\n        4.0,\n        16.0,\n        16.0,\n        3.0,\n        1.0,\n        f32::INFINITY,\n        1.0,\n        10.0,\n        6.0,\n    ];\n    let common_values = &[\n        (1.0, 151036),\n        (f32::INFINITY, 100224),\n        (0.5, 75239),\n        (2.0, 74939),\n        (1.5, 74396),\n        (0.25, 37669),\n        (0.75, 37538),\n        (3.0, 37523),\n        (4.0, 37411),\n        (0.375, 18737),\n        (6.0, 18708),\n        (0.125, 18698),\n        (1.25, 18586),\n        (8.0, 18570),\n        (1.75, 18339),\n        (3.5, 9676),\n        (0.0625, 9668),\n        (16.0, 9474),\n        (0.875, 9416),\n        (12.0, 9376),\n    ];\n    let sample_median = (1.5, None);\n    special_random_positive_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        0.6328125,\n        9.536743e-7,\n        0.013671875,\n        0.6875,\n        70208.0,\n        0.01550293,\n        0.028625488,\n        3.3095703,\n        5.775879,\n        0.000034958124,\n        0.4375,\n        31678.0,\n        49152.0,\n        1.0,\n        49.885254,\n        0.40625,\n        0.0015869141,\n        1889.5625,\n        0.14140439,\n        0.001449585,\n        1.4901161e-8,\n        0.03125,\n        5750784.0,\n        0.17578125,\n        248.0,\n        5.4375,\n        1892352.0,\n        1.5280966e-7,\n        0.2826419,\n        0.0057373047,\n        51642370.0,\n        6384.0,\n        27.875542,\n        6.152041,\n        6.0,\n        2.796875,\n        0.0000057816505,\n        0.029174805,\n        0.00011384487,\n        0.000039815903,\n        0.00012207031,\n        48.0,\n        0.00390625,\n        0.01171875,\n        20.0,\n        21.625,\n        0.171875,\n        197.0,\n        0.11743164,\n        5532.0,\n    ];\n    let common_values = &[\n        (f32::INFINITY, 9989),\n        (1.0, 5059),\n        (2.0, 4689),\n        (0.5, 4622),\n        (1.5, 4576),\n        (4.0, 4280),\n        (3.0, 4153),\n        (0.25, 4130),\n        (0.75, 4105),\n        (8.0, 3912),\n        (6.0, 3841),\n        (0.125, 3772),\n        (0.375, 3663),\n        (16.0, 3536),\n        (0.1875, 3530),\n        (0.0625, 3441),\n        (12.0, 3433),\n        (0.09375, 3185),\n        (0.03125, 3176),\n        (32.0, 3094),\n    ];\n    let sample_median = (1.5, None);\n    special_random_positive_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f64::INFINITY,\n        1.5,\n        1.0,\n        f64::INFINITY,\n        1.0,\n        1.0,\n        f64::INFINITY,\n        1.0,\n        f64::INFINITY,\n        f64::INFINITY,\n        1.0,\n        f64::INFINITY,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        0.5,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        f64::INFINITY,\n        1.0,\n        f64::INFINITY,\n        f64::INFINITY,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        1.0,\n        f64::INFINITY,\n        1.0,\n        1.0,\n        0.5,\n        1.0,\n        f64::INFINITY,\n        f64::INFINITY,\n        f64::INFINITY,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 716268),\n        (f64::INFINITY, 250209),\n        (2.0, 10938),\n        (0.5, 10888),\n        (1.5, 10871),\n        (4.0, 172),\n        (0.25, 165),\n        (3.0, 161),\n        (0.75, 155),\n        (1.25, 75),\n        (1.75, 74),\n        (0.375, 6),\n        (3.5, 4),\n        (0.125, 4),\n        (8.0, 3),\n        (0.875, 2),\n        (1.875, 2),\n        (6.0, 1),\n        (0.625, 1),\n        (1.125, 1),\n    ];\n    let sample_median = (1.0, None);\n    special_random_positive_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        1.0,\n        1.0,\n        3.0,\n        f64::INFINITY,\n        1.0,\n        1.0,\n        2.0,\n        2.0,\n        1.0,\n        3.0,\n        1.0,\n        3.0,\n        3.0,\n        f64::INFINITY,\n        6.0,\n        1.125,\n        1.25,\n        f64::INFINITY,\n        3.0,\n        0.125,\n        1.0,\n        0.25,\n        1.75,\n        4.0,\n        4.0,\n        4.0,\n        0.75,\n        0.125,\n        1.0,\n        f64::INFINITY,\n        0.125,\n        6.0,\n        f64::INFINITY,\n        0.5,\n        4.0,\n        6.5,\n        2.0,\n        0.21875,\n        2.0,\n        0.5,\n        0.5,\n        4.0,\n        16.0,\n        16.0,\n        3.0,\n        1.0,\n        f64::INFINITY,\n        1.0,\n        10.0,\n        6.0,\n    ];\n    let common_values = &[\n        (1.0, 151036),\n        (f64::INFINITY, 100224),\n        (0.5, 75239),\n        (2.0, 74939),\n        (1.5, 74396),\n        (0.25, 37669),\n        (0.75, 37538),\n        (3.0, 37523),\n        (4.0, 37411),\n        (0.375, 18737),\n        (6.0, 18708),\n        (0.125, 18698),\n        (1.25, 18586),\n        (8.0, 18570),\n        (1.75, 18339),\n        (3.5, 9676),\n        (0.0625, 9668),\n        (16.0, 9474),\n        (0.875, 9416),\n        (12.0, 9376),\n    ];\n    let sample_median = (1.5, None);\n    special_random_positive_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        0.6328125,\n        9.5367431640625e-7,\n        0.013671875,\n        0.6875,\n        70208.0,\n        0.0155029296875,\n        0.02862548828125,\n        3.3095703125,\n        5.77587890625,\n        0.0000349581241607666,\n        0.4375,\n        31678.0,\n        49152.0,\n        1.0,\n        49.88525390625,\n        0.40625,\n        0.0015869140625,\n        1889.5625,\n        0.141404390335083,\n        0.0014495849609375,\n        1.4901161193847656e-8,\n        0.03125,\n        5750784.0,\n        0.17578125,\n        248.0,\n        5.4375,\n        1892352.0,\n        1.528096618130803e-7,\n        0.2826418876647949,\n        0.0057373046875,\n        51642368.0,\n        6384.0,\n        27.87554168701172,\n        6.152040958404541,\n        6.0,\n        2.796875,\n        5.781650543212891e-6,\n        0.0291748046875,\n        0.0001138448715209961,\n        0.00003981590270996094,\n        0.0001220703125,\n        48.0,\n        0.00390625,\n        0.01171875,\n        20.0,\n        21.625,\n        0.171875,\n        205.175663292408,\n        0.118408203125,\n        6436.0,\n    ];\n    let common_values = &[\n        (f64::INFINITY, 9989),\n        (1.0, 4750),\n        (2.0, 4357),\n        (0.5, 4257),\n        (1.5, 4256),\n        (4.0, 3955),\n        (3.0, 3844),\n        (0.25, 3812),\n        (0.75, 3799),\n        (8.0, 3628),\n        (6.0, 3535),\n        (0.125, 3447),\n        (0.375, 3398),\n        (16.0, 3257),\n        (0.1875, 3234),\n        (12.0, 3202),\n        (0.0625, 3182),\n        (0.09375, 2957),\n        (0.03125, 2919),\n        (32.0, 2805),\n    ];\n    let sample_median = (1.5162887573242188, Some(1.516387939453125));\n    special_random_positive_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n}\n\nfn special_random_positive_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_positive_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_positive_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_positive_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_positive_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0,\n        1,\n        10\n    ));\n    assert_panic!(special_random_positive_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        1,\n        0\n    ));\n    assert_panic!(special_random_positive_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        2,\n        1\n    ));\n}\n\n#[test]\nfn special_random_positive_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_positive_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_primitive_float_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::special_random_primitive_float_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn special_random_primitive_float_inclusive_range_helper<T: CheckedToF64 + PrimitiveFloat>(\n    a: T,\n    b: T,\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_primitive_float_inclusive_range::<T>(\n            EXAMPLE_SEED,\n            a,\n            b,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_primitive_float_inclusive_range() {\n    // f32, a = 1.0, b = 2.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        2.0, 2.0, 2.0, 1.0, 1.5, 2.0, 1.0, 1.0, 1.5, 2.0, 1.28125, 1.0, 2.0, 1.0, 1.4375, 1.8125,\n        1.6875, 1.0, 1.75, 1.875, 2.0, 1.0, 2.0, 1.0, 1.75, 2.0, 2.0, 2.0, 2.0, 1.75, 2.0, 1.5,\n        1.484375, 2.0, 1.0, 2.0, 1.75, 2.0, 1.25, 1.0, 1.5, 1.25, 1.546875, 1.0, 2.0, 2.0, 2.0,\n        1.4921875, 2.0, 2.0,\n    ];\n    let common_values = &[\n        (2.0, 332566),\n        (1.0, 222413),\n        (1.5, 148427),\n        (1.25, 49546),\n        (1.75, 49274),\n        (1.875, 16717),\n        (1.125, 16593),\n        (1.375, 16567),\n        (1.625, 16551),\n        (1.8125, 5566),\n        (1.5625, 5553),\n        (1.9375, 5543),\n        (1.1875, 5451),\n        (1.4375, 5383),\n        (1.6875, 5367),\n        (1.3125, 5361),\n        (1.0625, 5322),\n        (1.21875, 1873),\n        (1.34375, 1871),\n        (1.40625, 1865),\n    ];\n    let sample_median = (1.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5553208489836596),\n        standard_deviation: NiceFloat(0.3974073963635055),\n        skewness: NiceFloat(-0.20042532167244795),\n        excess_kurtosis: NiceFloat(-1.5078861004584492),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        1.0,\n        2.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 1.0, b = 2.0, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        2.0, 2.0, 1.0, 1.640625, 1.375, 2.0, 1.90625, 2.0, 2.0, 1.25, 1.0, 2.0, 2.0, 1.9375, 1.5,\n        2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.96875, 2.0, 1.1479492, 1.4569855, 1.2559814,\n        1.5579834, 2.0, 2.0, 1.2250977, 1.1882324, 1.5, 2.0, 1.6498959, 2.0, 1.1252441, 2.0, 2.0,\n        2.0, 1.0336914, 2.0, 2.0, 2.0, 2.0, 1.5, 1.375, 2.0, 1.0, 1.125,\n    ];\n    let common_values = &[\n        (2.0, 476330),\n        (1.0, 52792),\n        (1.5, 47801),\n        (1.25, 22022),\n        (1.75, 21892),\n        (1.875, 10017),\n        (1.625, 9986),\n        (1.375, 9985),\n        (1.125, 9951),\n        (1.8125, 4622),\n        (1.4375, 4596),\n        (1.1875, 4577),\n        (1.9375, 4552),\n        (1.5625, 4549),\n        (1.3125, 4532),\n        (1.0625, 4507),\n        (1.6875, 4455),\n        (1.96875, 2147),\n        (1.15625, 2105),\n        (1.28125, 2098),\n    ];\n    let sample_median = (1.9371719, Some(1.9371796));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.712172784260269),\n        standard_deviation: NiceFloat(0.34826759681331443),\n        skewness: NiceFloat(-0.7989590190130814),\n        excess_kurtosis: NiceFloat(-0.8454122824548973),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        1.0,\n        2.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.1, b = 0.1, mean abs of exponent = 5, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        0.09375,\n        0.01171875,\n        0.01171875,\n        -0.0,\n        -0.09375,\n        -0.01171875,\n        -0.01171875,\n        -0.03125,\n        0.03125,\n        0.0625,\n        -0.0625,\n        -0.07525635,\n        -0.0625,\n        0.0,\n        -0.09375,\n        -0.09375,\n        -0.09375,\n        -0.0,\n        0.07525635,\n        -0.078125,\n        -0.05078125,\n        0.0625,\n        0.09375,\n        0.09375,\n        -0.024414062,\n        0.09375,\n        -0.001953125,\n        0.078125,\n        0.05078125,\n        -0.0,\n        -0.0625,\n        -0.09375,\n        0.0,\n        0.024414062,\n        -0.03125,\n        -0.0043945312,\n        -0.09375,\n        0.001953125,\n        -0.09375,\n        -0.003540039,\n        -0.03125,\n        0.0625,\n        -0.046875,\n        0.09375,\n        -0.0625,\n        0.03125,\n        0.0,\n        -0.0146484375,\n        0.0043945312,\n        0.09375,\n    ];\n    let common_values = &[\n        (0.0625, 74962),\n        (-0.0625, 74736),\n        (-0.0, 50351),\n        (0.09375, 50309),\n        (-0.09375, 50178),\n        (0.0, 49873),\n        (0.03125, 37782),\n        (-0.03125, 37678),\n        (0.078125, 33219),\n        (-0.078125, 33138),\n        (0.046875, 25130),\n        (-0.046875, 25053),\n        (0.015625, 18743),\n        (-0.015625, 18692),\n        (0.0234375, 12593),\n        (-0.0234375, 12549),\n        (0.0703125, 11091),\n        (0.0859375, 11088),\n        (-0.0859375, 11060),\n        (-0.0703125, 11055),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0000674789649248169),\n        standard_deviation: NiceFloat(0.05672019953597066),\n        skewness: NiceFloat(-0.001702872258409426),\n        excess_kurtosis: NiceFloat(-1.109977309372344),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        -0.1,\n        0.1,\n        5,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.1, b = 0.1, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        0.0041503906,\n        0.0625,\n        0.00042547443,\n        -0.0041503906,\n        -0.0625,\n        -0.00042547443,\n        -0.0027618408,\n        0.0027618408,\n        0.09375,\n        -0.09375,\n        -0.083244324,\n        -0.076171875,\n        -0.00023269653,\n        -0.00043609738,\n        -0.0029296875,\n        0.083244324,\n        -0.011459351,\n        -0.05419922,\n        0.076171875,\n        0.00023269653,\n        0.00043609738,\n        -0.000006198883,\n        0.0029296875,\n        -0.0008621216,\n        0.011459351,\n        0.05419922,\n        -0.00035095215,\n        -0.0625,\n        0.000006198883,\n        -0.0008010864,\n        -0.00030517578,\n        -0.00008274312,\n        0.0008621216,\n        -0.0029296875,\n        -0.04892564,\n        -0.013671875,\n        0.00035095215,\n        -0.0009398293,\n        0.0625,\n        -0.07344723,\n        0.0008010864,\n        -0.01953125,\n        0.00030517578,\n        0.00008274312,\n        0.0029296875,\n        0.04892564,\n        -0.006134033,\n        -0.0070343018,\n        -0.005493164,\n        -0.0000029057264,\n    ];\n    let common_values = &[\n        (0.0625, 7060),\n        (-0.0625, 7045),\n        (0.09375, 6481),\n        (-0.09375, 6468),\n        (0.03125, 6186),\n        (-0.03125, 6171),\n        (0.078125, 5831),\n        (-0.078125, 5813),\n        (0.046875, 5527),\n        (-0.046875, 5516),\n        (0.015625, 5112),\n        (-0.015625, 5103),\n        (-0.0, 5098),\n        (0.0, 4891),\n        (0.0234375, 4821),\n        (-0.0234375, 4810),\n        (0.0078125, 4681),\n        (-0.0078125, 4678),\n        (0.01171875, 4123),\n        (-0.01171875, 4120),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.000022248151599295377),\n        standard_deviation: NiceFloat(0.035382441406785786),\n        skewness: NiceFloat(0.0002929225243710825),\n        excess_kurtosis: NiceFloat(1.5823949638933827),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        -0.1,\n        0.1,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = e, b = π, mean abs of exponent = 3, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        3.0, 2.859375, 3.0234375, 3.0, 2.75, 3.0, 3.0, 3.0, 2.75, 2.75, 3.078125, 3.0, 3.0, 3.0,\n        2.84375, 2.84375, 2.96875, 3.0, 3.125, 2.8125, 3.0, 3.0, 3.03125, 3.0, 3.125, 3.125, 2.875,\n        3.0, 2.75, 2.875, 3.0, 2.75, 2.9140625, 2.734375, 3.0, 3.0, 3.125, 2.9257812, 3.125, 3.0,\n        2.75, 3.125, 2.9921875, 3.0, 2.75, 3.0, 3.0, 3.0195312, 3.0, 2.8125,\n    ];\n    let common_values = &[\n        (3.0, 333251),\n        (2.75, 222162),\n        (3.125, 74149),\n        (2.875, 74011),\n        (3.0625, 33262),\n        (2.8125, 33146),\n        (2.9375, 33097),\n        (2.90625, 9548),\n        (2.78125, 9377),\n        (2.71875, 9327),\n        (3.03125, 9327),\n        (3.09375, 9323),\n        (2.84375, 9315),\n        (2.96875, 9265),\n        (2.859375, 3186),\n        (3.015625, 3185),\n        (2.796875, 3180),\n        (3.046875, 3160),\n        (3.140625, 3157),\n        (2.765625, 3152),\n    ];\n    let sample_median = (3.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.923236772231216),\n        standard_deviation: NiceFloat(0.12616339323242115),\n        skewness: NiceFloat(-0.17689588042510748),\n        excess_kurtosis: NiceFloat(-1.2738593390011854),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        3,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = e, b = π, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        2.9238281, 2.953125, 3.0, 2.8671875, 2.8125, 3.125, 3.015625, 2.8462658, 3.140625, 2.875,\n        3.0, 2.75, 3.0, 2.71875, 2.75, 3.0214844, 2.970642, 3.0179443, 2.968872, 2.75, 2.9763536,\n        2.875, 2.890625, 2.8388672, 2.7814941, 3.087654, 3.1065063, 2.817566, 2.8125, 2.7746582,\n        2.746338, 3.0207214, 2.75, 2.9852295, 3.0, 2.9980469, 3.006958, 2.875, 2.8632812,\n        2.9277344, 3.088623, 2.8376465, 3.0, 3.0, 3.0117188, 2.75, 2.8125, 3.0, 3.0, 3.140625,\n    ];\n    let common_values = &[\n        (3.0, 103073),\n        (2.75, 94168),\n        (2.875, 43152),\n        (3.125, 42886),\n        (3.0625, 26213),\n        (2.8125, 25982),\n        (2.9375, 25799),\n        (2.90625, 10203),\n        (2.71875, 10186),\n        (2.84375, 10149),\n        (3.09375, 10141),\n        (3.03125, 10134),\n        (2.78125, 10085),\n        (2.96875, 10085),\n        (3.046875, 4666),\n        (2.734375, 4649),\n        (2.765625, 4649),\n        (3.109375, 4629),\n        (2.859375, 4606),\n        (3.140625, 4590),\n    ];\n    let sample_median = (2.9375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.925577550306893),\n        standard_deviation: NiceFloat(0.12565616542944752),\n        skewness: NiceFloat(-0.016691773531483878),\n        excess_kurtosis: NiceFloat(-1.2405888218124512),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 100.0, b = 101.0, mean abs of exponent = 7, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        100.0, 100.5625, 100.40625, 100.0, 101.0, 100.0, 100.0, 100.0, 101.0, 101.0, 100.8125,\n        100.0, 100.0, 100.0, 100.375, 100.875, 100.875, 100.0, 100.5, 100.75, 100.0, 100.0,\n        100.875, 100.0, 100.5, 100.5, 100.5, 100.0, 101.0, 100.5, 100.0, 101.0, 100.46875,\n        100.1875, 100.0, 100.0, 100.5, 100.546875, 100.5, 100.0, 101.0, 100.5, 100.96875, 100.0,\n        101.0, 100.0, 100.0, 100.296875, 100.0, 100.75,\n    ];\n    let common_values = &[\n        (100.0, 333338),\n        (101.0, 222241),\n        (100.5, 148191),\n        (100.75, 49867),\n        (100.25, 49679),\n        (100.625, 16568),\n        (100.875, 16322),\n        (100.125, 16318),\n        (100.375, 16281),\n        (100.6875, 5585),\n        (100.3125, 5557),\n        (100.5625, 5547),\n        (100.1875, 5520),\n        (100.9375, 5484),\n        (100.0625, 5464),\n        (100.8125, 5438),\n        (100.4375, 5236),\n        (100.71875, 1933),\n        (100.09375, 1868),\n        (100.34375, 1863),\n    ];\n    let sample_median = (100.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.44460313228277),\n        standard_deviation: NiceFloat(0.3974843507339211),\n        skewness: NiceFloat(0.19977351658386902),\n        excess_kurtosis: NiceFloat(-1.5086143196425152),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        100.0,\n        101.0,\n        7,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 100.0, b = 101.0, mean abs of exponent = 10, mean precision = 10, mean zero P =\n    // 1/100\n    let values = &[\n        100.82031, 100.5625, 100.0, 100.71875, 100.75, 100.5, 100.9375, 100.88427, 100.9375, 100.5,\n        100.0, 101.0, 100.0, 100.125, 101.0, 100.46094, 100.51196, 100.46338, 100.80127, 101.0,\n        100.0, 100.5, 100.1875, 100.01172, 100.569336, 100.59958, 100.50122, 100.06665, 100.25,\n        100.31543, 100.47949, 100.94539, 101.0, 100.47705, 100.75, 100.72206, 100.59912, 100.5,\n        100.796875, 100.44531, 100.44629, 100.42285, 100.0, 100.0, 100.802734, 101.0, 100.25,\n        100.75, 100.0, 100.13281,\n    ];\n    let common_values = &[\n        (100.0, 108217),\n        (101.0, 98713),\n        (100.5, 90150),\n        (100.75, 40946),\n        (100.25, 40858),\n        (100.875, 18753),\n        (100.125, 18677),\n        (100.625, 18429),\n        (100.375, 18424),\n        (100.1875, 8582),\n        (100.6875, 8505),\n        (100.5625, 8500),\n        (100.8125, 8480),\n        (100.9375, 8342),\n        (100.4375, 8341),\n        (100.0625, 8329),\n        (100.3125, 8269),\n        (100.90625, 3936),\n        (100.28125, 3920),\n        (100.21875, 3910),\n    ];\n    let sample_median = (100.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.49535768898696),\n        standard_deviation: NiceFloat(0.32868306867221864),\n        skewness: NiceFloat(0.008975981158852992),\n        excess_kurtosis: NiceFloat(-1.221929691547448),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        100.0,\n        101.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 1.0e38, b = Infinity, mean abs of exponent = 129, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        2.5521178e38,\n        1.0633824e38,\n        1.0633824e38,\n        f32::INFINITY,\n        1.2760589e38,\n        1.7014118e38,\n        1.2349359e38,\n        1.7014118e38,\n        1.0633824e38,\n        1.4887354e38,\n        1.0633824e38,\n        1.1697206e38,\n        1.329228e38,\n        f32::INFINITY,\n        1.3026434e38,\n        1.2760589e38,\n        1.2760589e38,\n        f32::INFINITY,\n        1.4887354e38,\n        1.7014118e38,\n        1.5419045e38,\n        2.5521178e38,\n        2.5521178e38,\n        3.2964854e38,\n        1.7014118e38,\n        1.0633824e38,\n        1.2760589e38,\n        1.2228898e38,\n        1.3823971e38,\n        f32::INFINITY,\n        1.1763668e38,\n        1.2760589e38,\n        f32::INFINITY,\n        1.5950736e38,\n        1.4887354e38,\n        1.2760589e38,\n        2.9774707e38,\n        2.179934e38,\n        2.3394413e38,\n        2.5521178e38,\n        2.1267648e38,\n        2.9774707e38,\n        1.0633824e38,\n        1.7014118e38,\n        1.7014118e38,\n        1.2760589e38,\n        f32::INFINITY,\n        1.5809505e38,\n        1.1697206e38,\n        2.7647942e38,\n    ];\n    let common_values = &[\n        (1.2760589e38, 171851),\n        (1.7014118e38, 128688),\n        (f32::INFINITY, 100224),\n        (2.5521178e38, 85928),\n        (1.4887354e38, 57285),\n        (1.0633824e38, 57158),\n        (2.9774707e38, 28779),\n        (2.1267648e38, 28453),\n        (1.1697206e38, 25497),\n        (1.3823971e38, 25299),\n        (1.5950736e38, 25002),\n        (2.3394413e38, 9529),\n        (1.9140883e38, 9502),\n        (3.1901472e38, 9420),\n        (2.7647942e38, 9406),\n        (1.1165515e38, 7388),\n        (1.329228e38, 7368),\n        (1.2228898e38, 7328),\n        (1.4355662e38, 7281),\n        (1.6482427e38, 7214),\n    ];\n    let sample_median = (1.6482427e38, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        129,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = f32::MIN_POSITIVE_SUBNORMAL, mean abs of exponent\n    // = 150, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        1.0e-45, 1.0e-45, 1.0e-45, -0.0, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 1.0e-45, 1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, 0.0, -1.0e-45, -1.0e-45, -1.0e-45, -0.0, 1.0e-45, -1.0e-45,\n        -1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, 1.0e-45, -0.0,\n        -1.0e-45, -1.0e-45, 0.0, 1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45,\n        -1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, 0.0, -1.0e-45, 1.0e-45,\n        1.0e-45,\n    ];\n    let common_values = &[(1.0e-45, 450531), (-1.0e-45, 449245), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.8020698251216835e-48),\n        standard_deviation: NiceFloat(1.3292224464360085e-45),\n        skewness: NiceFloat(-0.0025604536978191587),\n        excess_kurtosis: NiceFloat(-1.8886053342505447),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = f32::MIN_POSITIVE_SUBNORMAL, mean abs of exponent = 150, mean precision =\n    // 2, mean zero P = 1/10\n    let values = &[\n        1.0e-45, 1.0e-45, 1.0e-45, -0.0, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45,\n        1.0e-45, 1.0e-45, 1.0e-45, 0.0, 1.0e-45, 1.0e-45, 1.0e-45, -0.0, 1.0e-45, 1.0e-45, 1.0e-45,\n        1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, -0.0, 1.0e-45,\n        1.0e-45, 0.0, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45,\n        1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 0.0, 1.0e-45, 1.0e-45, 1.0e-45,\n    ];\n    let common_values = &[(1.0e-45, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.2608547270363571e-45),\n        standard_deviation: NiceFloat(4.2080794564999146e-46),\n        skewness: NiceFloat(-2.662524701673921),\n        excess_kurtosis: NiceFloat(5.089037787023615),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        -0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 0.0, b = 0.0, mean abs of exponent = 150, mean precision = 2, mean zero P = 1/10\n    let values = &[0.0; 50];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        0.0,\n        0.0,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // -f32::MIN_POSITIVE_SUBNORMAL, b = -f32::MIN_POSITIVE_SUBNORMAL, mean abs of exponent = 150,\n    // mean precision = 2, mean zero P = 1/10\n    let values = &[-1.0e-45; 50];\n    let common_values = &[(-1.0e-45, 1000000)];\n    let sample_median = (-1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.401298464324817e-45),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = 0.0, mean abs of exponent = 150, mean precision =\n    // 2, mean zero P = 1/10\n    let values = &[\n        -1.0e-45, -1.0e-45, -1.0e-45, -0.0, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 0.0, -1.0e-45, -1.0e-45, -1.0e-45, -0.0, -1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45,\n        -1.0e-45, -0.0, -1.0e-45, -1.0e-45, 0.0, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 0.0,\n        -1.0e-45, -1.0e-45, -1.0e-45,\n    ];\n    let common_values = &[(-1.0e-45, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (-1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.2608547270363571e-45),\n        standard_deviation: NiceFloat(4.2080794564999146e-46),\n        skewness: NiceFloat(2.662524701673921),\n        excess_kurtosis: NiceFloat(5.089037787023615),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -Infinity, b = Infinity, mean abs of exponent = 1, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        12.0,\n        1.5,\n        0.75,\n        -0.0,\n        -12.0,\n        -1.5,\n        -0.75,\n        -4.0,\n        4.0,\n        2.0,\n        -2.0,\n        -1.2041016,\n        -2.0,\n        f32::NEGATIVE_INFINITY,\n        -0.75,\n        -0.75,\n        -3.0,\n        0.0,\n        1.2041016,\n        -40.0,\n        -0.6875,\n        2.0,\n        0.75,\n        0.75,\n        -1.3125,\n        3.0,\n        -2.0,\n        40.0,\n        0.6875,\n        -0.0,\n        -0.5,\n        -1.5,\n        f32::NEGATIVE_INFINITY,\n        1.3125,\n        -0.125,\n        -1.125,\n        -0.046875,\n        2.0,\n        -1.5,\n        -1.9375,\n        -1.0,\n        0.5,\n        -0.75,\n        1.5,\n        -1.0,\n        0.125,\n        f32::INFINITY,\n        -1.875,\n        1.125,\n        0.046875,\n    ];\n    let common_values = &[\n        (1.0, 49888),\n        (-1.0, 49745),\n        (1.5, 33700),\n        (-1.5, 33609),\n        (f32::NEGATIVE_INFINITY, 25322),\n        (0.5, 25189),\n        (-0.0, 25144),\n        (-0.5, 25121),\n        (f32::INFINITY, 24924),\n        (0.0, 24834),\n        (2.0, 24770),\n        (-2.0, 24716),\n        (3.0, 16990),\n        (-3.0, 16941),\n        (0.75, 16655),\n        (-0.75, 16611),\n        (4.0, 12510),\n        (0.25, 12465),\n        (-4.0, 12461),\n        (-0.25, 12430),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = -0.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[-0.0; 50];\n    let common_values = &[(-0.0, 1000000)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f32>(\n        -0.0,\n        -0.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0, b = 2.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        2.0, 2.0, 2.0, 1.0, 1.5, 2.0, 1.0, 1.0, 1.5, 2.0, 1.28125, 1.0, 2.0, 1.0, 1.4375, 1.8125,\n        1.6875, 1.0, 1.75, 1.875, 2.0, 1.0, 2.0, 1.0, 1.75, 2.0, 2.0, 2.0, 2.0, 1.75, 2.0, 1.5,\n        1.484375, 2.0, 1.0, 2.0, 1.75, 2.0, 1.25, 1.0, 1.5, 1.25, 1.546875, 1.0, 2.0, 2.0, 2.0,\n        1.4921875, 2.0, 2.0,\n    ];\n    let common_values = &[\n        (2.0, 332566),\n        (1.0, 222394),\n        (1.5, 148417),\n        (1.75, 49426),\n        (1.25, 49385),\n        (1.375, 16729),\n        (1.625, 16608),\n        (1.125, 16560),\n        (1.875, 16529),\n        (1.8125, 5619),\n        (1.5625, 5582),\n        (1.6875, 5424),\n        (1.9375, 5418),\n        (1.4375, 5415),\n        (1.0625, 5401),\n        (1.3125, 5359),\n        (1.1875, 5325),\n        (1.09375, 1909),\n        (1.65625, 1901),\n        (1.96875, 1893),\n    ];\n    let sample_median = (1.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5552951797578527),\n        standard_deviation: NiceFloat(0.39732291679015563),\n        skewness: NiceFloat(-0.2001600069371136),\n        excess_kurtosis: NiceFloat(-1.5071515332005163),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        1.0,\n        2.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0, b = 2.0, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        2.0,\n        2.0,\n        1.0,\n        1.640625,\n        1.375,\n        2.0,\n        1.90625,\n        2.0,\n        2.0,\n        1.25,\n        1.0,\n        2.0,\n        2.0,\n        1.9375,\n        1.5,\n        2.0,\n        2.0,\n        2.0,\n        2.0,\n        2.0,\n        2.0,\n        2.0,\n        1.96875,\n        2.0,\n        1.14794921875,\n        1.4569854736328125,\n        1.2559814453125,\n        1.5579833984375,\n        2.0,\n        2.0,\n        1.22509765625,\n        1.0812369697232498,\n        1.5,\n        2.0,\n        1.1291658878326416,\n        2.0,\n        1.666259765625,\n        2.0,\n        2.0,\n        2.0,\n        1.03857421875,\n        2.0,\n        2.0,\n        2.0,\n        2.0,\n        1.5,\n        1.125,\n        2.0,\n        1.0,\n        1.4247607216238976,\n    ];\n    let common_values = &[\n        (2.0, 476330),\n        (1.0, 47627),\n        (1.5, 43214),\n        (1.75, 19860),\n        (1.25, 19849),\n        (1.875, 9069),\n        (1.625, 9023),\n        (1.125, 8975),\n        (1.375, 8966),\n        (1.5625, 4216),\n        (1.4375, 4204),\n        (1.3125, 4172),\n        (1.1875, 4093),\n        (1.9375, 4059),\n        (1.8125, 4047),\n        (1.6875, 4030),\n        (1.0625, 4007),\n        (1.09375, 1944),\n        (1.28125, 1938),\n        (1.53125, 1903),\n    ];\n    let sample_median = (1.9375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.714502436478215),\n        standard_deviation: NiceFloat(0.34632959887726134),\n        skewness: NiceFloat(-0.804949565136136),\n        excess_kurtosis: NiceFloat(-0.8346071411985774),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        1.0,\n        2.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.1, b = 0.1, mean abs of exponent = 5, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        0.09375,\n        0.01171875,\n        0.01171875,\n        -0.0,\n        -0.09375,\n        -0.01171875,\n        -0.01171875,\n        -0.03125,\n        0.03125,\n        0.0625,\n        -0.0625,\n        -0.07525634765625,\n        -0.0625,\n        0.0,\n        -0.09375,\n        -0.09375,\n        -0.09375,\n        -0.0,\n        0.07525634765625,\n        -0.078125,\n        -0.05078125,\n        0.0625,\n        0.09375,\n        0.09375,\n        -0.0244140625,\n        0.09375,\n        -0.001953125,\n        0.078125,\n        0.05078125,\n        -0.0,\n        -0.0625,\n        -0.09375,\n        0.0,\n        0.0244140625,\n        -0.03125,\n        -0.00439453125,\n        -0.09375,\n        0.001953125,\n        -0.09375,\n        -0.0035400390625,\n        -0.03125,\n        0.0625,\n        -0.046875,\n        0.09375,\n        -0.0625,\n        0.03125,\n        0.0,\n        -0.0146484375,\n        0.00439453125,\n        0.09375,\n    ];\n    let common_values = &[\n        (0.0625, 74957),\n        (-0.0625, 74731),\n        (-0.0, 50351),\n        (0.09375, 50307),\n        (-0.09375, 50176),\n        (0.0, 49873),\n        (0.03125, 37778),\n        (-0.03125, 37674),\n        (0.078125, 33218),\n        (-0.078125, 33137),\n        (0.046875, 25128),\n        (-0.046875, 25051),\n        (0.015625, 18742),\n        (-0.015625, 18691),\n        (0.0234375, 12592),\n        (-0.0234375, 12548),\n        (0.0859375, 11149),\n        (-0.0859375, 11121),\n        (0.0703125, 11027),\n        (-0.0703125, 10991),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.00006747896492481727),\n        standard_deviation: NiceFloat(0.05672798899804289),\n        skewness: NiceFloat(-0.001703150825150012),\n        excess_kurtosis: NiceFloat(-1.1100263487007116),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        -0.1,\n        0.1,\n        5,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.1, b = 0.1, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        0.005245480002486147,\n        0.0625,\n        0.00037892110412940383,\n        -0.005245480002486147,\n        -0.0625,\n        -0.00037892110412940383,\n        -0.0025482177734375,\n        0.0025482177734375,\n        0.08385447226464748,\n        -0.08385447226464748,\n        -0.07456207275390625,\n        -0.076171875,\n        -0.000156402587890625,\n        -0.0004252493381500244,\n        -0.0029296875,\n        0.07456207275390625,\n        -0.012820055672818853,\n        -0.05615234375,\n        0.076171875,\n        0.000156402587890625,\n        0.0004252493381500244,\n        -6.198883056640625e-6,\n        0.0029296875,\n        -0.00057220458984375,\n        0.012820055672818853,\n        0.05615234375,\n        -0.0003814697265625,\n        -0.0625,\n        6.198883056640625e-6,\n        -0.00092315673828125,\n        -0.00030517578125,\n        -0.00007461127825081348,\n        0.00057220458984375,\n        -0.0029296875,\n        -0.05444455146789551,\n        -0.009765625,\n        0.0003814697265625,\n        -0.0007852371782064438,\n        0.0625,\n        -0.07266771433324948,\n        0.00092315673828125,\n        -0.02317537716589868,\n        0.00030517578125,\n        0.00007461127825081348,\n        0.0029296875,\n        0.05444455146789551,\n        -0.007110595703125,\n        -0.00537109375,\n        -0.0072021484375,\n        -2.2798776626586914e-6,\n    ];\n    let common_values = &[\n        (0.0625, 6407),\n        (-0.0625, 6393),\n        (0.09375, 5870),\n        (-0.09375, 5858),\n        (0.03125, 5626),\n        (-0.03125, 5611),\n        (0.078125, 5277),\n        (-0.078125, 5260),\n        (-0.0, 5098),\n        (0.046875, 4988),\n        (-0.046875, 4978),\n        (0.0, 4891),\n        (0.015625, 4680),\n        (-0.015625, 4672),\n        (0.0234375, 4384),\n        (-0.0234375, 4374),\n        (0.0078125, 4263),\n        (-0.0078125, 4260),\n        (0.01171875, 3729),\n        (-0.01171875, 3726),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.000022298181036079024),\n        standard_deviation: NiceFloat(0.035440202565071834),\n        skewness: NiceFloat(0.00030138197742575316),\n        excess_kurtosis: NiceFloat(1.5712669731678002),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        -0.1,\n        0.1,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = e, b = π, mean abs of exponent = 3, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        3.0, 2.859375, 3.0234375, 3.0, 2.75, 3.0, 3.0, 3.0, 2.75, 2.75, 3.078125, 3.0, 3.0, 3.0,\n        2.84375, 2.84375, 2.96875, 3.0, 3.125, 2.8125, 3.0, 3.0, 3.03125, 3.0, 3.125, 3.125, 2.875,\n        3.0, 2.75, 2.875, 3.0, 2.75, 2.9140625, 2.734375, 3.0, 3.0, 3.125, 2.92578125, 3.125, 3.0,\n        2.75, 3.125, 2.9921875, 3.0, 2.75, 3.0, 3.0, 3.01953125, 3.0, 2.8125,\n    ];\n    let common_values = &[\n        (3.0, 333198),\n        (2.75, 222142),\n        (3.125, 74385),\n        (2.875, 73751),\n        (2.9375, 33356),\n        (2.8125, 33246),\n        (3.0625, 32891),\n        (3.03125, 9479),\n        (2.71875, 9381),\n        (2.84375, 9352),\n        (2.90625, 9344),\n        (2.78125, 9342),\n        (2.96875, 9313),\n        (3.09375, 9258),\n        (2.765625, 3221),\n        (2.921875, 3214),\n        (3.015625, 3204),\n        (3.046875, 3175),\n        (2.859375, 3165),\n        (2.734375, 3163),\n    ];\n    let sample_median = (3.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9232526079986494),\n        standard_deviation: NiceFloat(0.1262248827883599),\n        skewness: NiceFloat(-0.17691898540367232),\n        excess_kurtosis: NiceFloat(-1.2742881322265622),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        3,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = e, b = π, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        2.923828125,\n        2.953125,\n        3.0,\n        2.8671875,\n        2.8125,\n        3.125,\n        3.015625,\n        2.8462657928466797,\n        3.140625,\n        2.875,\n        3.0,\n        2.75,\n        3.0,\n        2.71875,\n        2.75,\n        3.021484375,\n        2.97064208984375,\n        3.0179443359375,\n        2.9688720703125,\n        2.75,\n        2.97635555267334,\n        2.875,\n        2.890625,\n        2.8388671875,\n        2.781494140625,\n        3.0876541137695312,\n        3.10650634765625,\n        2.81756591796875,\n        2.8125,\n        2.774658203125,\n        2.746337890625,\n        3.086890615457378,\n        2.75,\n        2.7857666015625,\n        2.9739707708358765,\n        2.7529093623161316,\n        2.7723388671875,\n        3.125,\n        2.94140625,\n        2.916015625,\n        2.776611328125,\n        2.823486328125,\n        3.0,\n        3.0,\n        3.135541538707912,\n        2.75,\n        3.0625,\n        2.734408974647522,\n        3.0,\n        2.789327871054411,\n    ];\n    let common_values = &[\n        (3.0, 91105),\n        (2.75, 83336),\n        (2.875, 38014),\n        (3.125, 37964),\n        (3.0625, 23196),\n        (2.9375, 22929),\n        (2.8125, 22922),\n        (3.09375, 9177),\n        (2.78125, 9003),\n        (2.84375, 8943),\n        (2.90625, 8936),\n        (2.71875, 8920),\n        (3.03125, 8913),\n        (2.96875, 8854),\n        (2.765625, 4212),\n        (2.859375, 4171),\n        (2.953125, 4126),\n        (2.890625, 4119),\n        (3.015625, 4090),\n        (2.984375, 4082),\n    ];\n    let sample_median = (2.9375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9261256924208183),\n        standard_deviation: NiceFloat(0.12519730680807895),\n        skewness: NiceFloat(-0.016892719700380622),\n        excess_kurtosis: NiceFloat(-1.2338524787684633),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 100.0, b = 101.0, mean abs of exponent = 7, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        100.0, 100.5625, 100.40625, 100.0, 101.0, 100.0, 100.0, 100.0, 101.0, 101.0, 100.8125,\n        100.0, 100.0, 100.0, 100.375, 100.875, 100.875, 100.0, 100.5, 100.75, 100.0, 100.0,\n        100.875, 100.0, 100.5, 100.5, 100.5, 100.0, 101.0, 100.5, 100.0, 101.0, 100.46875,\n        100.1875, 100.0, 100.0, 100.5, 100.546875, 100.5, 100.0, 101.0, 100.5, 100.96875, 100.0,\n        101.0, 100.0, 100.0, 100.296875, 100.0, 100.75,\n    ];\n    let common_values = &[\n        (100.0, 333198),\n        (101.0, 222142),\n        (100.5, 148136),\n        (100.75, 49930),\n        (100.25, 49563),\n        (100.375, 16456),\n        (100.875, 16346),\n        (100.625, 16343),\n        (100.125, 16324),\n        (100.6875, 5638),\n        (100.5625, 5588),\n        (100.1875, 5508),\n        (100.8125, 5478),\n        (100.4375, 5449),\n        (100.3125, 5420),\n        (100.9375, 5417),\n        (100.0625, 5309),\n        (100.71875, 1910),\n        (100.21875, 1891),\n        (100.09375, 1867),\n    ];\n    let sample_median = (100.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.44459040083368),\n        standard_deviation: NiceFloat(0.39739652839770573),\n        skewness: NiceFloat(0.20000867844534617),\n        excess_kurtosis: NiceFloat(-1.5079346005477923),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        100.0,\n        101.0,\n        7,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 100.0, b = 101.0, mean abs of exponent = 10, mean precision = 10, mean zero P =\n    // 1/100\n    let values = &[\n        100.8203125,\n        100.5625,\n        100.0,\n        100.71875,\n        100.75,\n        100.5,\n        100.9375,\n        100.88426971435547,\n        100.9375,\n        100.5,\n        100.0,\n        101.0,\n        100.0,\n        100.125,\n        101.0,\n        100.4609375,\n        100.511962890625,\n        100.46337890625,\n        100.80126953125,\n        101.0,\n        100.27350997924805,\n        100.5,\n        100.8125,\n        100.37109375,\n        100.3251953125,\n        100.13284301757812,\n        100.032470703125,\n        100.916748046875,\n        100.75,\n        100.0087890625,\n        100.2373046875,\n        100.59933795747929,\n        101.0,\n        100.89990234375,\n        100.71137285232544,\n        100.55885925889015,\n        100.15478515625,\n        100.5,\n        100.421875,\n        100.3671875,\n        100.8330078125,\n        100.9619140625,\n        100.0,\n        100.0,\n        100.72769894078374,\n        101.0,\n        100.25,\n        100.2837815284729,\n        100.0,\n        100.6954902857542,\n    ];\n    let common_values = &[\n        (100.0, 91387),\n        (101.0, 83529),\n        (100.5, 76188),\n        (100.25, 34644),\n        (100.75, 34560),\n        (100.375, 15817),\n        (100.875, 15798),\n        (100.125, 15698),\n        (100.625, 15638),\n        (100.6875, 7188),\n        (100.9375, 7169),\n        (100.5625, 7154),\n        (100.1875, 7093),\n        (100.0625, 7081),\n        (100.3125, 7073),\n        (100.8125, 7055),\n        (100.4375, 6967),\n        (100.34375, 3371),\n        (100.59375, 3321),\n        (100.21875, 3291),\n    ];\n    let sample_median = (100.5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.49597550384374),\n        standard_deviation: NiceFloat(0.3229907369466344),\n        skewness: NiceFloat(0.007882298769431025),\n        excess_kurtosis: NiceFloat(-1.2073173945999414),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        100.0,\n        101.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0e38, b = Infinity, mean abs of exponent = 129, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        4.0833884030512616e39,\n        1.0633823966279327e38,\n        1.0633823966279327e38,\n        f64::INFINITY,\n        1.2760588759535192e38,\n        2.722258935367508e39,\n        2.1121432853022313e39,\n        1.0889035741470031e40,\n        3.2667107224410092e40,\n        1.0633823966279327e38,\n        1.0633823966279327e38,\n        1.3823971156163125e38,\n        3.828176627860558e38,\n        f64::INFINITY,\n        1.3026434358692176e38,\n        3.402823669209385e38,\n        1.361129467683754e39,\n        f64::INFINITY,\n        2.0416942015256308e39,\n        6.80564733841877e38,\n        1.5419044751105024e38,\n        4.0833884030512616e39,\n        2.5521177519070385e38,\n        1.1484529883581673e39,\n        1.7014118346046923e38,\n        1.4887353552791058e38,\n        1.361129467683754e39,\n        6.380294379767596e38,\n        4.253529586511731e38,\n        f64::INFINITY,\n        4.519375185668714e38,\n        3.402823669209385e38,\n        f64::INFINITY,\n        1.3823971156163125e38,\n        3.2667107224410092e40,\n        3.48449143727041e41,\n        2.9774707105582116e38,\n        7.443676776395529e38,\n        3.190147189883798e38,\n        2.5521177519070385e38,\n        1.9055812547572554e40,\n        3.4028236692093846e39,\n        1.0633823966279327e38,\n        6.80564733841877e38,\n        1.7014118346046923e38,\n        1.2760588759535192e38,\n        f64::INFINITY,\n        1.4879045877817402e38,\n        1.595073594941899e38,\n        8.166776806102523e40,\n    ];\n    let common_values = &[\n        (f64::INFINITY, 100224),\n        (1.2760588759535192e38, 74870),\n        (1.7014118346046923e38, 56023),\n        (3.402823669209385e38, 42298),\n        (2.5521177519070385e38, 37662),\n        (6.80564733841877e38, 31926),\n        (5.104235503814077e38, 28139),\n        (1.0633823966279327e38, 25142),\n        (1.4887353552791058e38, 25038),\n        (1.361129467683754e39, 23671),\n        (1.0208471007628154e39, 21048),\n        (2.722258935367508e39, 17641),\n        (2.0416942015256308e39, 15983),\n        (5.444517870735016e39, 13496),\n        (2.1267647932558654e38, 12408),\n        (2.9774707105582116e38, 12336),\n        (4.0833884030512616e39, 11938),\n        (1.169720636290726e38, 11049),\n        (1.595073594941899e38, 10950),\n        (1.3823971156163125e38, 10907),\n    ];\n    let sample_median = (5.84860318145363e38, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        1.0e38,\n        f64::INFINITY,\n        129,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = f64::MIN_POSITIVE_SUBNORMAL, mean abs of exponent\n    // = 1075, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        5.0e-324, 5.0e-324, 5.0e-324, -0.0, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 5.0e-324,\n        5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 0.0, -5.0e-324, -5.0e-324, -5.0e-324, -0.0,\n        5.0e-324, -5.0e-324, -5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, -5.0e-324, 5.0e-324,\n        -5.0e-324, 5.0e-324, 5.0e-324, -0.0, -5.0e-324, -5.0e-324, 0.0, 5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, 5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 5.0e-324, -5.0e-324,\n        5.0e-324, -5.0e-324, 5.0e-324, 0.0, -5.0e-324, 5.0e-324, 5.0e-324,\n    ];\n    let common_values = &[(5.0e-324, 450531), (-5.0e-324, 449245), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = f64::MIN_POSITIVE_SUBNORMAL, mean abs of exponent = 1075, mean precision =\n    // 2, mean zero P = 1/10\n    let values = &[\n        5.0e-324, 5.0e-324, 5.0e-324, -0.0, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324,\n        5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 0.0, 5.0e-324, 5.0e-324, 5.0e-324, -0.0, 5.0e-324,\n        5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324,\n        5.0e-324, -0.0, 5.0e-324, 5.0e-324, 0.0, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324,\n        5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 0.0,\n        5.0e-324, 5.0e-324, 5.0e-324,\n    ];\n    let common_values = &[(5.0e-324, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        -0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 0.0, b = 0.0, mean abs of exponent = 1075, mean precision = 2, mean zero P = 1/10\n    let values = &[0.0; 50];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        0.0,\n        0.0,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // -f64::MIN_POSITIVE_SUBNORMAL, b = -f64::MIN_POSITIVE_SUBNORMAL, mean abs of exponent = 1075,\n    // mean precision = 2, mean zero P = 1/10\n    let values = &[-5.0e-324; 50];\n    let common_values = &[(-5.0e-324, 1000000)];\n    let sample_median = (-5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = 0.0, mean abs of exponent = 1075, mean precision =\n    // 2, mean zero P = 1/10\n    let values = &[\n        -5.0e-324, -5.0e-324, -5.0e-324, -0.0, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 0.0, -5.0e-324, -5.0e-324,\n        -5.0e-324, -0.0, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -0.0, -5.0e-324, -5.0e-324, 0.0,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 0.0, -5.0e-324, -5.0e-324,\n        -5.0e-324,\n    ];\n    let common_values = &[(-5.0e-324, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (-5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        0.0,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -Infinity, b = Infinity, mean abs of exponent = 1, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        12.0,\n        1.5,\n        0.75,\n        -0.0,\n        -12.0,\n        -1.5,\n        -0.75,\n        -4.0,\n        4.0,\n        2.0,\n        -2.0,\n        -1.2041015625,\n        -2.0,\n        f64::NEGATIVE_INFINITY,\n        -0.75,\n        -0.75,\n        -3.0,\n        0.0,\n        1.2041015625,\n        -40.0,\n        -0.6875,\n        2.0,\n        0.75,\n        0.75,\n        -1.3125,\n        3.0,\n        -2.0,\n        40.0,\n        0.6875,\n        -0.0,\n        -0.5,\n        -1.5,\n        f64::NEGATIVE_INFINITY,\n        1.3125,\n        -0.125,\n        -1.125,\n        -0.046875,\n        2.0,\n        -1.5,\n        -1.9375,\n        -1.0,\n        0.5,\n        -0.75,\n        1.5,\n        -1.0,\n        0.125,\n        f64::INFINITY,\n        -1.875,\n        1.125,\n        0.046875,\n    ];\n    let common_values = &[\n        (1.0, 49883),\n        (-1.0, 49740),\n        (1.5, 33699),\n        (-1.5, 33608),\n        (f64::NEGATIVE_INFINITY, 25322),\n        (0.5, 25188),\n        (-0.0, 25144),\n        (-0.5, 25120),\n        (f64::INFINITY, 24924),\n        (0.0, 24834),\n        (2.0, 24765),\n        (-2.0, 24711),\n        (3.0, 16988),\n        (-3.0, 16939),\n        (0.75, 16654),\n        (-0.75, 16610),\n        (4.0, 12510),\n        (0.25, 12465),\n        (-4.0, 12461),\n        (-0.25, 12430),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = -0.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[-0.0; 50];\n    let common_values = &[(-0.0, 1000000)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_inclusive_range_helper::<f64>(\n        -0.0,\n        -0.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn special_random_primitive_float_inclusive_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ZERO,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::NAN,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        0,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        0,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::from(100.0),\n        T::from(101.0),\n        6,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        1,\n        2,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        1,\n        0,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        2,\n        1,\n        2,\n        1\n    ));\n    assert_panic!(special_random_primitive_float_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        2,\n        1,\n        1,\n        0\n    ));\n}\n\n#[test]\nfn special_random_primitive_float_inclusive_range_fail() {\n    apply_fn_to_primitive_floats!(special_random_primitive_float_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_primitive_float_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::special_random_primitive_float_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats};\nuse std::panic::catch_unwind;\n\nfn special_random_primitive_float_range_helper<T: CheckedToF64 + PrimitiveFloat>(\n    a: T,\n    b: T,\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_primitive_float_range::<T>(\n            EXAMPLE_SEED,\n            a,\n            b,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_primitive_float_range() {\n    // f32, a = 1.0, b = 2.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        1.0, 1.28125, 1.609375, 1.0, 1.5, 1.0, 1.0, 1.0, 1.5, 1.5, 1.71875, 1.0, 1.0, 1.0, 1.9375,\n        1.9375, 1.9375, 1.0, 1.25, 1.375, 1.0, 1.0, 1.3125, 1.0, 1.25, 1.25, 1.75, 1.0, 1.5, 1.75,\n        1.0, 1.5, 1.484375, 1.65625, 1.0, 1.0, 1.75, 1.5234375, 1.75, 1.0, 1.5, 1.25, 1.515625,\n        1.0, 1.5, 1.0, 1.0, 1.4140625, 1.0, 1.875,\n    ];\n    let common_values = &[\n        (1.0, 333222),\n        (1.5, 222154),\n        (1.75, 74130),\n        (1.25, 74019),\n        (1.375, 25091),\n        (1.875, 24869),\n        (1.625, 24805),\n        (1.125, 24731),\n        (1.4375, 8353),\n        (1.8125, 8307),\n        (1.5625, 8208),\n        (1.6875, 8156),\n        (1.0625, 8145),\n        (1.3125, 8117),\n        (1.1875, 8108),\n        (1.9375, 8080),\n        (1.03125, 2799),\n        (1.96875, 2798),\n        (1.15625, 2785),\n        (1.28125, 2779),\n    ];\n    let sample_median = (1.3359375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.3333245906621964),\n        standard_deviation: NiceFloat(0.29800120914228473),\n        skewness: NiceFloat(0.27868047434467813),\n        excess_kurtosis: NiceFloat(-1.2068148586621514),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        1.0,\n        2.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 1.0, b = 2.0, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        1.4101562, 1.90625, 1.0, 1.953125, 1.875, 1.75, 1.46875, 1.3115959, 1.46875, 1.25, 1.0,\n        1.5, 1.0, 1.5625, 1.5, 1.5117188, 1.1158447, 1.2253418, 1.1882324, 1.5, 1.1991673, 1.75,\n        1.15625, 1.2519531, 1.0668945, 1.6660919, 1.0096436, 1.2796631, 1.875, 1.6987305,\n        1.8608398, 1.3996582, 1.5, 1.1125488, 1.419461, 1.25, 1.0681152, 1.75, 1.1171875,\n        1.4804688, 1.7055664, 1.3237305, 1.0, 1.0, 1.84375, 1.5, 1.125, 1.3097513, 1.0, 1.375,\n    ];\n    let common_values = &[\n        (1.0, 100845),\n        (1.5, 91973),\n        (1.75, 42129),\n        (1.25, 41726),\n        (1.125, 19270),\n        (1.625, 19149),\n        (1.875, 19012),\n        (1.375, 18836),\n        (1.8125, 8852),\n        (1.1875, 8822),\n        (1.3125, 8722),\n        (1.0625, 8692),\n        (1.4375, 8630),\n        (1.6875, 8623),\n        (1.9375, 8620),\n        (1.5625, 8431),\n        (1.71875, 4047),\n        (1.09375, 3974),\n        (1.40625, 3949),\n        (1.90625, 3941),\n    ];\n    let sample_median = (1.4912109, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.449574181673412),\n        standard_deviation: NiceFloat(0.29612085814559613),\n        skewness: NiceFloat(0.029341331332504897),\n        excess_kurtosis: NiceFloat(-1.1487737412063284),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        1.0,\n        2.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.1, b = 0.1, mean abs of exponent = 5, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        0.09375,\n        0.01171875,\n        0.01171875,\n        -0.0,\n        -0.09375,\n        -0.01171875,\n        -0.01171875,\n        -0.03125,\n        0.03125,\n        0.0625,\n        -0.0625,\n        -0.07525635,\n        -0.0625,\n        0.0,\n        -0.09375,\n        -0.09375,\n        -0.09375,\n        -0.0,\n        0.07525635,\n        -0.078125,\n        -0.05078125,\n        0.0625,\n        0.09375,\n        0.09375,\n        -0.024414062,\n        0.09375,\n        -0.001953125,\n        0.078125,\n        0.05078125,\n        -0.0,\n        -0.0625,\n        -0.09375,\n        0.0,\n        0.024414062,\n        -0.03125,\n        -0.0043945312,\n        -0.09375,\n        0.001953125,\n        -0.09375,\n        -0.003540039,\n        -0.03125,\n        0.0625,\n        -0.046875,\n        0.09375,\n        -0.0625,\n        0.03125,\n        0.0,\n        -0.0146484375,\n        0.0043945312,\n        0.09375,\n    ];\n    let common_values = &[\n        (0.0625, 74962),\n        (-0.0625, 74736),\n        (-0.0, 50351),\n        (0.09375, 50309),\n        (-0.09375, 50178),\n        (0.0, 49873),\n        (0.03125, 37782),\n        (-0.03125, 37678),\n        (0.078125, 33219),\n        (-0.078125, 33138),\n        (0.046875, 25130),\n        (-0.046875, 25053),\n        (0.015625, 18743),\n        (-0.015625, 18692),\n        (0.0234375, 12593),\n        (-0.0234375, 12549),\n        (0.0703125, 11091),\n        (0.0859375, 11088),\n        (-0.0859375, 11060),\n        (-0.0703125, 11055),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0000674789649248169),\n        standard_deviation: NiceFloat(0.05672019953597066),\n        skewness: NiceFloat(-0.001702872258409426),\n        excess_kurtosis: NiceFloat(-1.109977309372344),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        -0.1,\n        0.1,\n        5,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.1, b = 0.1, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        0.0041503906,\n        0.0625,\n        0.00042547443,\n        -0.0041503906,\n        -0.0625,\n        -0.00042547443,\n        -0.0027618408,\n        0.0027618408,\n        0.09375,\n        -0.09375,\n        -0.083244324,\n        -0.076171875,\n        -0.00023269653,\n        -0.00043609738,\n        -0.0029296875,\n        0.083244324,\n        -0.011459351,\n        -0.05419922,\n        0.076171875,\n        0.00023269653,\n        0.00043609738,\n        -0.000006198883,\n        0.0029296875,\n        -0.0008621216,\n        0.011459351,\n        0.05419922,\n        -0.00035095215,\n        -0.0625,\n        0.000006198883,\n        -0.0008010864,\n        -0.00030517578,\n        -0.00008274312,\n        0.0008621216,\n        -0.0029296875,\n        -0.04892564,\n        -0.013671875,\n        0.00035095215,\n        -0.0009398293,\n        0.0625,\n        -0.07344723,\n        0.0008010864,\n        -0.01953125,\n        0.00030517578,\n        0.00008274312,\n        0.0029296875,\n        0.04892564,\n        -0.006134033,\n        -0.0070343018,\n        -0.005493164,\n        -0.0000029057264,\n    ];\n    let common_values = &[\n        (0.0625, 7060),\n        (-0.0625, 7045),\n        (0.09375, 6481),\n        (-0.09375, 6468),\n        (0.03125, 6186),\n        (-0.03125, 6171),\n        (0.078125, 5831),\n        (-0.078125, 5813),\n        (0.046875, 5527),\n        (-0.046875, 5516),\n        (0.015625, 5112),\n        (-0.015625, 5103),\n        (-0.0, 5098),\n        (0.0, 4891),\n        (0.0234375, 4821),\n        (-0.0234375, 4810),\n        (0.0078125, 4681),\n        (-0.0078125, 4678),\n        (0.01171875, 4123),\n        (-0.01171875, 4120),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.000022248151599295377),\n        standard_deviation: NiceFloat(0.035382441406785786),\n        skewness: NiceFloat(0.0002929225243710825),\n        excess_kurtosis: NiceFloat(1.5823949638933827),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        -0.1,\n        0.1,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = e, b = π, mean abs of exponent = 3, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        3.0, 2.859375, 3.0234375, 3.0, 2.75, 3.0, 3.0, 3.0, 2.75, 2.75, 3.078125, 3.0, 3.0, 3.0,\n        2.84375, 2.84375, 2.96875, 3.0, 3.125, 2.8125, 3.0, 3.0, 3.03125, 3.0, 3.125, 3.125, 2.875,\n        3.0, 2.75, 2.875, 3.0, 2.75, 2.9140625, 2.734375, 3.0, 3.0, 3.125, 2.9257812, 3.125, 3.0,\n        2.75, 3.125, 2.9921875, 3.0, 2.75, 3.0, 3.0, 3.0195312, 3.0, 2.8125,\n    ];\n    let common_values = &[\n        (3.0, 333251),\n        (2.75, 222162),\n        (3.125, 74149),\n        (2.875, 74011),\n        (3.0625, 33262),\n        (2.8125, 33146),\n        (2.9375, 33097),\n        (2.90625, 9548),\n        (2.78125, 9377),\n        (2.71875, 9327),\n        (3.03125, 9327),\n        (3.09375, 9323),\n        (2.84375, 9315),\n        (2.96875, 9265),\n        (2.859375, 3186),\n        (3.015625, 3185),\n        (2.796875, 3180),\n        (3.046875, 3160),\n        (3.140625, 3157),\n        (2.765625, 3152),\n    ];\n    let sample_median = (3.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.923236772231216),\n        standard_deviation: NiceFloat(0.12616339323242115),\n        skewness: NiceFloat(-0.17689588042510748),\n        excess_kurtosis: NiceFloat(-1.2738593390011854),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        3,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = e, b = π, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        2.9238281, 2.953125, 3.0, 2.8671875, 2.8125, 3.125, 3.015625, 2.8462658, 3.140625, 2.875,\n        3.0, 2.75, 3.0, 2.71875, 2.75, 3.0214844, 2.970642, 3.0179443, 2.968872, 2.75, 2.9763536,\n        2.875, 2.890625, 2.8388672, 2.7814941, 3.087654, 3.1065063, 2.817566, 2.8125, 2.7746582,\n        2.746338, 3.0207214, 2.75, 2.9852295, 3.0, 2.9980469, 3.006958, 2.875, 2.8632812,\n        2.9277344, 3.088623, 2.8376465, 3.0, 3.0, 3.0117188, 2.75, 2.8125, 3.0, 3.0, 3.140625,\n    ];\n    let common_values = &[\n        (3.0, 103073),\n        (2.75, 94168),\n        (2.875, 43152),\n        (3.125, 42886),\n        (3.0625, 26213),\n        (2.8125, 25982),\n        (2.9375, 25799),\n        (2.90625, 10203),\n        (2.71875, 10186),\n        (2.84375, 10149),\n        (3.09375, 10141),\n        (3.03125, 10134),\n        (2.78125, 10085),\n        (2.96875, 10085),\n        (3.046875, 4666),\n        (2.734375, 4649),\n        (2.765625, 4649),\n        (3.109375, 4629),\n        (2.859375, 4606),\n        (3.140625, 4590),\n    ];\n    let sample_median = (2.9375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.925577550306893),\n        standard_deviation: NiceFloat(0.12565616542944752),\n        skewness: NiceFloat(-0.016691773531483878),\n        excess_kurtosis: NiceFloat(-1.2405888218124512),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        core::f32::consts::E,\n        core::f32::consts::PI,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 100.0, b = 101.0, mean abs of exponent = 7, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        100.0, 100.28125, 100.609375, 100.0, 100.5, 100.0, 100.0, 100.0, 100.5, 100.5, 100.71875,\n        100.0, 100.0, 100.0, 100.9375, 100.9375, 100.9375, 100.0, 100.25, 100.375, 100.0, 100.0,\n        100.3125, 100.0, 100.25, 100.25, 100.75, 100.0, 100.5, 100.75, 100.0, 100.5, 100.484375,\n        100.65625, 100.0, 100.0, 100.75, 100.52344, 100.75, 100.0, 100.5, 100.25, 100.515625,\n        100.0, 100.5, 100.0, 100.0, 100.41406, 100.0, 100.875,\n    ];\n    let common_values = &[\n        (100.0, 333428),\n        (100.5, 222283),\n        (100.25, 74406),\n        (100.75, 73829),\n        (100.375, 25079),\n        (100.625, 25046),\n        (100.875, 24767),\n        (100.125, 24656),\n        (100.3125, 8323),\n        (100.8125, 8256),\n        (100.4375, 8240),\n        (100.1875, 8213),\n        (100.9375, 8177),\n        (100.5625, 8174),\n        (100.0625, 8080),\n        (100.6875, 8059),\n        (100.34375, 2831),\n        (100.90625, 2811),\n        (100.84375, 2797),\n        (100.03125, 2781),\n    ];\n    let sample_median = (100.33276, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.3331636999286),\n        standard_deviation: NiceFloat(0.29794394613548436),\n        skewness: NiceFloat(0.27963401436978874),\n        excess_kurtosis: NiceFloat(-1.2056484413996),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        100.0,\n        101.0,\n        7,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 100.0, b = 101.0, mean abs of exponent = 10, mean precision = 10, mean zero P =\n    // 1/100\n    let values = &[\n        100.41016, 100.90625, 100.0, 100.953125, 100.875, 100.75, 100.46875, 100.0, 100.59375,\n        100.25, 100.0, 100.5, 100.0, 100.5625, 100.5, 100.24609, 100.3822, 100.41431, 100.40991,\n        100.5, 100.5, 100.25, 100.46875, 100.009766, 100.78467, 100.64989, 100.06262, 100.12927,\n        100.125, 100.833496, 100.01904, 100.0, 100.5, 100.11841, 100.6875, 100.75, 100.849365,\n        100.25, 100.44531, 100.58984, 100.3999, 100.13916, 100.0, 100.0, 100.382324, 100.5,\n        100.875, 100.3125, 100.0, 100.70117,\n    ];\n    let common_values = &[\n        (100.0, 110530),\n        (100.5, 100839),\n        (100.75, 45914),\n        (100.25, 45828),\n        (100.625, 20971),\n        (100.875, 20919),\n        (100.125, 20849),\n        (100.375, 20809),\n        (100.8125, 9612),\n        (100.3125, 9504),\n        (100.9375, 9489),\n        (100.1875, 9482),\n        (100.0625, 9475),\n        (100.6875, 9471),\n        (100.4375, 9432),\n        (100.5625, 9376),\n        (100.40625, 4413),\n        (100.59375, 4409),\n        (100.03125, 4369),\n        (100.21875, 4315),\n    ];\n    let sample_median = (100.48999, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.44491497797223),\n        standard_deviation: NiceFloat(0.29627860462288247),\n        skewness: NiceFloat(0.0334721390871067),\n        excess_kurtosis: NiceFloat(-1.1467496174419634),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        100.0,\n        101.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 1.0e38, b = Infinity, mean abs of exponent = 129, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        1.7014118e38,\n        2.179934e38,\n        2.7382097e38,\n        1.2760589e38,\n        1.4887354e38,\n        1.2760589e38,\n        1.2760589e38,\n        1.2760589e38,\n        1.4887354e38,\n        1.0633824e38,\n        1.5020276e38,\n        1.7014118e38,\n        1.7014118e38,\n        1.7014118e38,\n        1.80775e38,\n        3.2964854e38,\n        3.2964854e38,\n        1.2760589e38,\n        1.1697206e38,\n        2.3394413e38,\n        1.2760589e38,\n        1.7014118e38,\n        1.4089817e38,\n        1.2760589e38,\n        2.1267648e38,\n        1.1697206e38,\n        1.1697206e38,\n        1.7014118e38,\n        2.5521178e38,\n        2.1267648e38,\n        1.7014118e38,\n        1.0633824e38,\n        2.2596876e38,\n        1.4754431e38,\n        1.2760589e38,\n        1.7014118e38,\n        2.1267648e38,\n        3.0705167e38,\n        2.9774707e38,\n        1.2760589e38,\n        1.0633824e38,\n        2.1267648e38,\n        1.0168594e38,\n        1.7014118e38,\n        2.5521178e38,\n        1.2760589e38,\n        1.2760589e38,\n        1.4654739e38,\n        1.7014118e38,\n        1.9140883e38,\n    ];\n    let common_values = &[\n        (1.2760589e38, 190486),\n        (1.7014118e38, 142730),\n        (2.5521178e38, 95012),\n        (1.4887354e38, 63724),\n        (1.0633824e38, 63427),\n        (2.1267648e38, 31749),\n        (2.9774707e38, 31613),\n        (1.3823971e38, 28489),\n        (1.1697206e38, 28187),\n        (1.5950736e38, 28108),\n        (1.9140883e38, 10758),\n        (3.1901472e38, 10750),\n        (2.3394413e38, 10610),\n        (2.7647942e38, 10493),\n        (1.329228e38, 8248),\n        (1.1165515e38, 8201),\n        (1.5419045e38, 8177),\n        (1.0102133e38, 8147),\n        (1.4355662e38, 8096),\n        (1.6482427e38, 8021),\n    ];\n    let sample_median = (1.5286122e38, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.7213254069804385e38),\n        standard_deviation: NiceFloat(5.915470456567596e37),\n        skewness: NiceFloat(1.0016210709928859),\n        excess_kurtosis: NiceFloat(-0.11636872848929292),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        1.0e38,\n        f32::INFINITY,\n        129,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = 3.0e-45, mean abs of exponent = 150, mean\n    // precision = 2, mean zero P = 1/10\n    let values = &[\n        1.0e-45, 1.0e-45, 1.0e-45, -0.0, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 1.0e-45, 1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, 0.0, -1.0e-45, -1.0e-45, -1.0e-45, -0.0, 1.0e-45, -1.0e-45,\n        -1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, 1.0e-45, -0.0,\n        -1.0e-45, -1.0e-45, 0.0, 1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45,\n        -1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, -1.0e-45, 1.0e-45, 0.0, -1.0e-45, 1.0e-45,\n        1.0e-45,\n    ];\n    let common_values = &[(1.0e-45, 450531), (-1.0e-45, 449245), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.8020698251216835e-48),\n        standard_deviation: NiceFloat(1.3292224464360085e-45),\n        skewness: NiceFloat(-0.0025604536978191587),\n        excess_kurtosis: NiceFloat(-1.8886053342505447),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        3.0e-45,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = 3.0e-45, mean abs of exponent = 150, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        1.0e-45, 1.0e-45, 1.0e-45, -0.0, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45,\n        1.0e-45, 1.0e-45, 1.0e-45, 0.0, 1.0e-45, 1.0e-45, 1.0e-45, -0.0, 1.0e-45, 1.0e-45, 1.0e-45,\n        1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, -0.0, 1.0e-45,\n        1.0e-45, 0.0, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45,\n        1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 1.0e-45, 0.0, 1.0e-45, 1.0e-45, 1.0e-45,\n    ];\n    let common_values = &[(1.0e-45, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.2608547270363571e-45),\n        standard_deviation: NiceFloat(4.2080794564999146e-46),\n        skewness: NiceFloat(-2.662524701673921),\n        excess_kurtosis: NiceFloat(5.089037787023615),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        -0.0,\n        3.0e-45,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = 0.0, b = f32::MIN_POSITIVE_SUBNORMAL, mean abs of exponent = 150, mean precision =\n    // 2, mean zero P = 1/10\n    let values = &[0.0; 50];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        0.0,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // -f32::MIN_POSITIVE_SUBNORMAL, b = -0.0, mean abs of exponent = 150, mean precision = 2, mean\n    // zero P = 1/10\n    let values = &[-1.0e-45; 50];\n    let common_values = &[(-1.0e-45, 1000000)];\n    let sample_median = (-1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.401298464324817e-45),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -f32::MIN_POSITIVE_SUBNORMAL, b = f32::MIN_POSITIVE_SUBNORMAL, mean abs of exponent\n    // = 150, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        -1.0e-45, -1.0e-45, -1.0e-45, -0.0, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 0.0, -1.0e-45, -1.0e-45, -1.0e-45, -0.0, -1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45,\n        -1.0e-45, -0.0, -1.0e-45, -1.0e-45, 0.0, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45,\n        -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, -1.0e-45, 0.0,\n        -1.0e-45, -1.0e-45, -1.0e-45,\n    ];\n    let common_values = &[(-1.0e-45, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (-1.0e-45, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.2608547270363571e-45),\n        standard_deviation: NiceFloat(4.2080794564999146e-46),\n        skewness: NiceFloat(2.662524701673921),\n        excess_kurtosis: NiceFloat(5.089037787023615),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        f32::MIN_POSITIVE_SUBNORMAL,\n        150,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -Infinity, b = Infinity, mean abs of exponent = 1, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        12.0,\n        1.5,\n        0.75,\n        0.0,\n        -12.0,\n        -1.5,\n        -0.75,\n        -4.0,\n        4.0,\n        2.0,\n        -2.0,\n        -1.2041016,\n        -2.0,\n        f32::NEGATIVE_INFINITY,\n        -0.75,\n        -0.75,\n        -3.0,\n        0.0,\n        1.2041016,\n        -40.0,\n        -0.6875,\n        2.0,\n        0.75,\n        0.75,\n        -1.3125,\n        3.0,\n        -2.0,\n        40.0,\n        0.6875,\n        f32::NEGATIVE_INFINITY,\n        -0.5,\n        -1.5,\n        -0.0,\n        1.3125,\n        -0.125,\n        -1.125,\n        -0.046875,\n        2.0,\n        -1.5,\n        -1.9375,\n        -1.0,\n        0.5,\n        -0.75,\n        1.5,\n        -1.0,\n        0.125,\n        0.0,\n        -1.875,\n        1.125,\n        0.046875,\n    ];\n    let common_values = &[\n        (1.0, 49888),\n        (-1.0, 49745),\n        (1.5, 33700),\n        (f32::NEGATIVE_INFINITY, 33640),\n        (-1.5, 33609),\n        (0.0, 33393),\n        (-0.0, 33191),\n        (0.5, 25189),\n        (-0.5, 25121),\n        (2.0, 24770),\n        (-2.0, 24716),\n        (3.0, 16990),\n        (-3.0, 16941),\n        (0.75, 16655),\n        (-0.75, 16611),\n        (4.0, 12510),\n        (0.25, 12465),\n        (-4.0, 12461),\n        (-0.25, 12430),\n        (1.75, 11179),\n    ];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f32, a = -0.0, b = 0.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[-0.0; 50];\n    let common_values = &[(-0.0, 1000000)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f32>(\n        -0.0,\n        0.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0, b = 2.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        1.0, 1.28125, 1.609375, 1.0, 1.5, 1.0, 1.0, 1.0, 1.5, 1.5, 1.71875, 1.0, 1.0, 1.0, 1.9375,\n        1.9375, 1.9375, 1.0, 1.25, 1.375, 1.0, 1.0, 1.3125, 1.0, 1.25, 1.25, 1.75, 1.0, 1.5, 1.75,\n        1.0, 1.5, 1.484375, 1.65625, 1.0, 1.0, 1.75, 1.5234375, 1.75, 1.0, 1.5, 1.25, 1.515625,\n        1.0, 1.5, 1.0, 1.0, 1.4140625, 1.0, 1.875,\n    ];\n    let common_values = &[\n        (1.0, 333198),\n        (1.5, 222142),\n        (1.25, 74116),\n        (1.75, 74020),\n        (1.625, 24916),\n        (1.375, 24899),\n        (1.875, 24889),\n        (1.125, 24789),\n        (1.8125, 8258),\n        (1.0625, 8253),\n        (1.9375, 8239),\n        (1.5625, 8179),\n        (1.6875, 8158),\n        (1.1875, 8148),\n        (1.4375, 8140),\n        (1.3125, 8094),\n        (1.40625, 2826),\n        (1.84375, 2825),\n        (1.34375, 2802),\n        (1.78125, 2781),\n    ];\n    let sample_median = (1.3359375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.3334110677410675),\n        standard_deviation: NiceFloat(0.29815058562815744),\n        skewness: NiceFloat(0.27918114410601663),\n        excess_kurtosis: NiceFloat(-1.206767297925903),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        1.0,\n        2.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0, b = 2.0, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        1.41015625,\n        1.90625,\n        1.0,\n        1.953125,\n        1.875,\n        1.75,\n        1.46875,\n        1.3115959167480469,\n        1.46875,\n        1.25,\n        1.0,\n        1.5,\n        1.0,\n        1.5625,\n        1.5,\n        1.51171875,\n        1.1158447265625,\n        1.225341796875,\n        1.188232421875,\n        1.5,\n        1.199167251586914,\n        1.75,\n        1.15625,\n        1.251953125,\n        1.06689453125,\n        1.6660919189453125,\n        1.0096435546875,\n        1.2796630859375,\n        1.875,\n        1.69873046875,\n        1.86083984375,\n        1.3819717407022836,\n        1.5,\n        1.802490234375,\n        1.909928560256958,\n        1.2957243919372559,\n        1.401123046875,\n        1.75,\n        1.3671875,\n        1.95703125,\n        1.14501953125,\n        1.59130859375,\n        1.0,\n        1.0,\n        1.825472442433238,\n        1.5,\n        1.375,\n        1.7292792797088623,\n        1.0,\n        1.852405808866024,\n    ];\n    let common_values = &[\n        (1.0, 90973),\n        (1.5, 83219),\n        (1.75, 38074),\n        (1.25, 37805),\n        (1.875, 17372),\n        (1.375, 17334),\n        (1.625, 17115),\n        (1.125, 17095),\n        (1.3125, 7927),\n        (1.6875, 7879),\n        (1.4375, 7873),\n        (1.5625, 7861),\n        (1.9375, 7859),\n        (1.8125, 7831),\n        (1.1875, 7812),\n        (1.0625, 7625),\n        (1.84375, 3620),\n        (1.34375, 3611),\n        (1.28125, 3607),\n        (1.15625, 3558),\n    ];\n    let sample_median = (1.4921875, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.4546223996766015),\n        standard_deviation: NiceFloat(0.29563414647088554),\n        skewness: NiceFloat(0.02445210407687687),\n        excess_kurtosis: NiceFloat(-1.1474911308258557),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        1.0,\n        2.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.1, b = 0.1, mean abs of exponent = 5, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        0.09375,\n        0.01171875,\n        0.01171875,\n        -0.0,\n        -0.09375,\n        -0.01171875,\n        -0.01171875,\n        -0.03125,\n        0.03125,\n        0.0625,\n        -0.0625,\n        -0.07525634765625,\n        -0.0625,\n        0.0,\n        -0.09375,\n        -0.09375,\n        -0.09375,\n        -0.0,\n        0.07525634765625,\n        -0.078125,\n        -0.05078125,\n        0.0625,\n        0.09375,\n        0.09375,\n        -0.0244140625,\n        0.09375,\n        -0.001953125,\n        0.078125,\n        0.05078125,\n        -0.0,\n        -0.0625,\n        -0.09375,\n        0.0,\n        0.0244140625,\n        -0.03125,\n        -0.00439453125,\n        -0.09375,\n        0.001953125,\n        -0.09375,\n        -0.0035400390625,\n        -0.03125,\n        0.0625,\n        -0.046875,\n        0.09375,\n        -0.0625,\n        0.03125,\n        0.0,\n        -0.0146484375,\n        0.00439453125,\n        0.09375,\n    ];\n    let common_values = &[\n        (0.0625, 74957),\n        (-0.0625, 74731),\n        (-0.0, 50351),\n        (0.09375, 50307),\n        (-0.09375, 50176),\n        (0.0, 49873),\n        (0.03125, 37778),\n        (-0.03125, 37674),\n        (0.078125, 33218),\n        (-0.078125, 33137),\n        (0.046875, 25128),\n        (-0.046875, 25051),\n        (0.015625, 18742),\n        (-0.015625, 18691),\n        (0.0234375, 12592),\n        (-0.0234375, 12548),\n        (0.0859375, 11149),\n        (-0.0859375, 11121),\n        (0.0703125, 11027),\n        (-0.0703125, 10991),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.00006747896492481727),\n        standard_deviation: NiceFloat(0.05672798899804289),\n        skewness: NiceFloat(-0.001703150825150012),\n        excess_kurtosis: NiceFloat(-1.1100263487007116),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        -0.1,\n        0.1,\n        5,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.1, b = 0.1, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        0.005245480002486147,\n        0.0625,\n        0.00037892110412940383,\n        -0.005245480002486147,\n        -0.0625,\n        -0.00037892110412940383,\n        -0.0025482177734375,\n        0.0025482177734375,\n        0.08385447226464748,\n        -0.08385447226464748,\n        -0.07456207275390625,\n        -0.076171875,\n        -0.000156402587890625,\n        -0.0004252493381500244,\n        -0.0029296875,\n        0.07456207275390625,\n        -0.012820055672818853,\n        -0.05615234375,\n        0.076171875,\n        0.000156402587890625,\n        0.0004252493381500244,\n        -6.198883056640625e-6,\n        0.0029296875,\n        -0.00057220458984375,\n        0.012820055672818853,\n        0.05615234375,\n        -0.0003814697265625,\n        -0.0625,\n        6.198883056640625e-6,\n        -0.00092315673828125,\n        -0.00030517578125,\n        -0.00007461127825081348,\n        0.00057220458984375,\n        -0.0029296875,\n        -0.05444455146789551,\n        -0.009765625,\n        0.0003814697265625,\n        -0.0007852371782064438,\n        0.0625,\n        -0.07266771433324948,\n        0.00092315673828125,\n        -0.02317537716589868,\n        0.00030517578125,\n        0.00007461127825081348,\n        0.0029296875,\n        0.05444455146789551,\n        -0.007110595703125,\n        -0.00537109375,\n        -0.0072021484375,\n        -2.2798776626586914e-6,\n    ];\n    let common_values = &[\n        (0.0625, 6407),\n        (-0.0625, 6393),\n        (0.09375, 5870),\n        (-0.09375, 5858),\n        (0.03125, 5626),\n        (-0.03125, 5611),\n        (0.078125, 5277),\n        (-0.078125, 5260),\n        (-0.0, 5098),\n        (0.046875, 4988),\n        (-0.046875, 4978),\n        (0.0, 4891),\n        (0.015625, 4680),\n        (-0.015625, 4672),\n        (0.0234375, 4384),\n        (-0.0234375, 4374),\n        (0.0078125, 4263),\n        (-0.0078125, 4260),\n        (0.01171875, 3729),\n        (-0.01171875, 3726),\n    ];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.000022298181036079024),\n        standard_deviation: NiceFloat(0.035440202565071834),\n        skewness: NiceFloat(0.00030138197742575316),\n        excess_kurtosis: NiceFloat(1.5712669731678002),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        -0.1,\n        0.1,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = e, b = π, mean abs of exponent = 3, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        3.0, 2.859375, 3.0234375, 3.0, 2.75, 3.0, 3.0, 3.0, 2.75, 2.75, 3.078125, 3.0, 3.0, 3.0,\n        2.84375, 2.84375, 2.96875, 3.0, 3.125, 2.8125, 3.0, 3.0, 3.03125, 3.0, 3.125, 3.125, 2.875,\n        3.0, 2.75, 2.875, 3.0, 2.75, 2.9140625, 2.734375, 3.0, 3.0, 3.125, 2.92578125, 3.125, 3.0,\n        2.75, 3.125, 2.9921875, 3.0, 2.75, 3.0, 3.0, 3.01953125, 3.0, 2.8125,\n    ];\n    let common_values = &[\n        (3.0, 333198),\n        (2.75, 222142),\n        (3.125, 74385),\n        (2.875, 73751),\n        (2.9375, 33356),\n        (2.8125, 33246),\n        (3.0625, 32891),\n        (3.03125, 9479),\n        (2.71875, 9381),\n        (2.84375, 9352),\n        (2.90625, 9344),\n        (2.78125, 9342),\n        (2.96875, 9313),\n        (3.09375, 9258),\n        (2.765625, 3221),\n        (2.921875, 3214),\n        (3.015625, 3204),\n        (3.046875, 3175),\n        (2.859375, 3165),\n        (2.734375, 3163),\n    ];\n    let sample_median = (3.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9232526079986494),\n        standard_deviation: NiceFloat(0.1262248827883599),\n        skewness: NiceFloat(-0.17691898540367232),\n        excess_kurtosis: NiceFloat(-1.2742881322265622),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        3,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = e, b = π, mean abs of exponent = 10, mean precision = 10, mean zero P = 1/100\n    let values = &[\n        2.923828125,\n        2.953125,\n        3.0,\n        2.8671875,\n        2.8125,\n        3.125,\n        3.015625,\n        2.8462657928466797,\n        3.140625,\n        2.875,\n        3.0,\n        2.75,\n        3.0,\n        2.71875,\n        2.75,\n        3.021484375,\n        2.97064208984375,\n        3.0179443359375,\n        2.9688720703125,\n        2.75,\n        2.97635555267334,\n        2.875,\n        2.890625,\n        2.8388671875,\n        2.781494140625,\n        3.0876541137695312,\n        3.10650634765625,\n        2.81756591796875,\n        2.8125,\n        2.774658203125,\n        2.746337890625,\n        3.086890615457378,\n        2.75,\n        2.7857666015625,\n        2.9739707708358765,\n        2.7529093623161316,\n        2.7723388671875,\n        3.125,\n        2.94140625,\n        2.916015625,\n        2.776611328125,\n        2.823486328125,\n        3.0,\n        3.0,\n        3.135541538707912,\n        2.75,\n        3.0625,\n        2.734408974647522,\n        3.0,\n        2.789327871054411,\n    ];\n    let common_values = &[\n        (3.0, 91105),\n        (2.75, 83336),\n        (2.875, 38014),\n        (3.125, 37964),\n        (3.0625, 23196),\n        (2.9375, 22929),\n        (2.8125, 22922),\n        (3.09375, 9177),\n        (2.78125, 9003),\n        (2.84375, 8943),\n        (2.90625, 8936),\n        (2.71875, 8920),\n        (3.03125, 8913),\n        (2.96875, 8854),\n        (2.765625, 4212),\n        (2.859375, 4171),\n        (2.953125, 4126),\n        (2.890625, 4119),\n        (3.015625, 4090),\n        (2.984375, 4082),\n    ];\n    let sample_median = (2.9375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9261256924208183),\n        standard_deviation: NiceFloat(0.12519730680807895),\n        skewness: NiceFloat(-0.016892719700380622),\n        excess_kurtosis: NiceFloat(-1.2338524787684633),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        core::f64::consts::E,\n        core::f64::consts::PI,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 100.0, b = 101.0, mean abs of exponent = 7, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        100.0,\n        100.28125,\n        100.609375,\n        100.0,\n        100.5,\n        100.0,\n        100.0,\n        100.0,\n        100.5,\n        100.5,\n        100.71875,\n        100.0,\n        100.0,\n        100.0,\n        100.9375,\n        100.9375,\n        100.9375,\n        100.0,\n        100.25,\n        100.375,\n        100.0,\n        100.0,\n        100.3125,\n        100.0,\n        100.25,\n        100.25,\n        100.75,\n        100.0,\n        100.5,\n        100.75,\n        100.0,\n        100.5,\n        100.484375,\n        100.65625,\n        100.0,\n        100.0,\n        100.75,\n        100.5234375,\n        100.75,\n        100.0,\n        100.5,\n        100.25,\n        100.515625,\n        100.0,\n        100.5,\n        100.0,\n        100.0,\n        100.4140625,\n        100.0,\n        100.875,\n    ];\n    let common_values = &[\n        (100.0, 333198),\n        (100.5, 222142),\n        (100.25, 74116),\n        (100.75, 74020),\n        (100.625, 24916),\n        (100.375, 24899),\n        (100.875, 24889),\n        (100.125, 24789),\n        (100.8125, 8258),\n        (100.0625, 8253),\n        (100.9375, 8239),\n        (100.5625, 8179),\n        (100.6875, 8158),\n        (100.1875, 8148),\n        (100.4375, 8140),\n        (100.3125, 8094),\n        (100.40625, 2826),\n        (100.84375, 2825),\n        (100.34375, 2802),\n        (100.78125, 2781),\n    ];\n    let sample_median = (100.3359375, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.33341106774094),\n        standard_deviation: NiceFloat(0.29815058562814944),\n        skewness: NiceFloat(0.27918114410604106),\n        excess_kurtosis: NiceFloat(-1.2067672979256399),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        100.0,\n        101.0,\n        7,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 100.0, b = 101.0, mean abs of exponent = 10, mean precision = 10, mean zero P =\n    // 1/100\n    let values = &[\n        100.41015625,\n        100.90625,\n        100.0,\n        100.953125,\n        100.875,\n        100.75,\n        100.46875,\n        100.31159591674805,\n        100.46875,\n        100.25,\n        100.0,\n        100.5,\n        100.0,\n        100.5625,\n        100.5,\n        100.51171875,\n        100.1158447265625,\n        100.225341796875,\n        100.188232421875,\n        100.5,\n        100.19916725158691,\n        100.75,\n        100.15625,\n        100.251953125,\n        100.06689453125,\n        100.66609191894531,\n        100.0096435546875,\n        100.2796630859375,\n        100.875,\n        100.69873046875,\n        100.86083984375,\n        100.38197174070228,\n        100.5,\n        100.802490234375,\n        100.90992856025696,\n        100.83274569362402,\n        100.740478515625,\n        100.25,\n        100.9140625,\n        100.32421875,\n        100.45556640625,\n        100.36865234375,\n        100.0,\n        100.0,\n        100.09102300740778,\n        100.5,\n        100.125,\n        100.27702021598816,\n        100.0,\n        100.45081884413958,\n    ];\n    let common_values = &[\n        (100.0, 91410),\n        (100.5, 83666),\n        (100.25, 38155),\n        (100.75, 38107),\n        (100.625, 17631),\n        (100.125, 17378),\n        (100.375, 17229),\n        (100.875, 17035),\n        (100.6875, 7968),\n        (100.1875, 7924),\n        (100.5625, 7918),\n        (100.3125, 7917),\n        (100.4375, 7914),\n        (100.8125, 7806),\n        (100.0625, 7786),\n        (100.9375, 7756),\n        (100.40625, 3664),\n        (100.59375, 3645),\n        (100.71875, 3629),\n        (100.09375, 3596),\n    ];\n    let sample_median = (100.4921875, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(100.45411484815686),\n        standard_deviation: NiceFloat(0.2957014655624591),\n        skewness: NiceFloat(0.026064278269824867),\n        excess_kurtosis: NiceFloat(-1.1480623934899934),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        100.0,\n        101.0,\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 1.0e38, b = Infinity, mean abs of exponent = 129, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        1.78405961588245e44,\n        2.2322523270013563e41,\n        7.009816758571332e40,\n        2.1778071482940062e40,\n        1.4887353552791058e38,\n        5.575186299632656e42,\n        1.2760588759535192e38,\n        3.402823669209385e38,\n        8.166776806102523e39,\n        2.0416942015256308e39,\n        6.424531087467318e41,\n        1.7014118346046923e38,\n        2.722258935367508e39,\n        2.722258935367508e39,\n        5.274376687274546e39,\n        3.2964854295465914e38,\n        2.4457795122442452e38,\n        1.361129467683754e39,\n        2.3819765684465692e39,\n        1.914088313930279e38,\n        1.2760588759535192e38,\n        6.80564733841877e38,\n        1.089966956543631e38,\n        3.402823669209385e38,\n        2.9774707105582116e38,\n        5.954941421116423e38,\n        1.169720636290726e38,\n        1.7014118346046923e38,\n        1.6333553612205046e40,\n        2.9774707105582116e38,\n        2.722258935367508e39,\n        2.0416942015256308e39,\n        3.9557825154559096e39,\n        8.336917989562992e39,\n        5.444517870735016e39,\n        4.3556142965880123e40,\n        1.9055812547572554e40,\n        1.026164012745955e39,\n        3.4028236692093846e39,\n        1.2760588759535192e38,\n        1.3066842889764037e41,\n        4.7639531368931385e39,\n        1.2295358961010472e38,\n        1.7014118346046923e38,\n        1.6725558898897967e43,\n        1.2760588759535192e38,\n        1.2760588759535192e38,\n        1.6098350440189294e44,\n        1.7014118346046923e38,\n        3.743106036130323e39,\n    ];\n    let common_values = &[\n        (1.2760588759535192e38, 83417),\n        (1.7014118346046923e38, 62258),\n        (3.402823669209385e38, 46943),\n        (2.5521177519070385e38, 41660),\n        (6.80564733841877e38, 35196),\n        (5.104235503814077e38, 31368),\n        (1.4887353552791058e38, 27818),\n        (1.0633823966279327e38, 27639),\n        (1.361129467683754e39, 26292),\n        (1.0208471007628154e39, 23299),\n        (2.722258935367508e39, 19745),\n        (2.0416942015256308e39, 17625),\n        (5.444517870735016e39, 14949),\n        (2.9774707105582116e38, 13963),\n        (2.1267647932558654e38, 13727),\n        (4.0833884030512616e39, 13082),\n        (1.169720636290726e38, 12430),\n        (1.3823971156163125e38, 12379),\n        (1.595073594941899e38, 12359),\n        (1.0889035741470031e40, 11070),\n    ];\n    let sample_median = (4.253529586511731e38, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.5180886046975516e45),\n        standard_deviation: NiceFloat(1.9464007021815662e48),\n        skewness: NiceFloat(500.41964668581875),\n        excess_kurtosis: NiceFloat(285116.05539365485),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        1.0e38,\n        f64::INFINITY,\n        129,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = 1.0e-323, mean abs of exponent = 1075, mean\n    // precision = 2, mean zero P = 1/10\n    let values = &[\n        5.0e-324, 5.0e-324, 5.0e-324, -0.0, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 5.0e-324,\n        5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 0.0, -5.0e-324, -5.0e-324, -5.0e-324, -0.0,\n        5.0e-324, -5.0e-324, -5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, -5.0e-324, 5.0e-324,\n        -5.0e-324, 5.0e-324, 5.0e-324, -0.0, -5.0e-324, -5.0e-324, 0.0, 5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, 5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 5.0e-324, -5.0e-324,\n        5.0e-324, -5.0e-324, 5.0e-324, 0.0, -5.0e-324, 5.0e-324, 5.0e-324,\n    ];\n    let common_values = &[(5.0e-324, 450531), (-5.0e-324, 449245), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        1.0e-323,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = 1.0e-323, mean abs of exponent = 1075, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        5.0e-324, 5.0e-324, 5.0e-324, -0.0, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324,\n        5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 0.0, 5.0e-324, 5.0e-324, 5.0e-324, -0.0, 5.0e-324,\n        5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324,\n        5.0e-324, -0.0, 5.0e-324, 5.0e-324, 0.0, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324,\n        5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 5.0e-324, 0.0,\n        5.0e-324, 5.0e-324, 5.0e-324,\n    ];\n    let common_values = &[(5.0e-324, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        -0.0,\n        1.0e-323,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = 0.0, b = f64::MIN_POSITIVE_SUBNORMAL, mean abs of exponent = 1075, mean precision =\n    // 2, mean zero P = 1/10\n    let values = &[0.0; 50];\n    let common_values = &[(0.0, 1000000)];\n    let sample_median = (0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        0.0,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // -f64::MIN_POSITIVE_SUBNORMAL, b = -0.0, mean abs of exponent = 1075, mean precision = 2, mean\n    // zero P = 1/10\n    let values = &[-5.0e-324; 50];\n    let common_values = &[(-5.0e-324, 1000000)];\n    let sample_median = (-5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        -0.0,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -f64::MIN_POSITIVE_SUBNORMAL, b = f64::MIN_POSITIVE_SUBNORMAL, mean abs of exponent\n    // = 1075, mean precision = 2, mean zero P = 1/10\n    let values = &[\n        -5.0e-324, -5.0e-324, -5.0e-324, -0.0, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 0.0, -5.0e-324, -5.0e-324,\n        -5.0e-324, -0.0, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -0.0, -5.0e-324, -5.0e-324, 0.0,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324,\n        -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, -5.0e-324, 0.0, -5.0e-324, -5.0e-324,\n        -5.0e-324,\n    ];\n    let common_values = &[(-5.0e-324, 899776), (-0.0, 50351), (0.0, 49873)];\n    let sample_median = (-5.0e-324, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.0e-324),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        f64::MIN_POSITIVE_SUBNORMAL,\n        1075,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -Infinity, b = Infinity, mean abs of exponent = 1, mean precision = 2, mean zero P =\n    // 1/10\n    let values = &[\n        12.0,\n        1.5,\n        0.75,\n        0.0,\n        -12.0,\n        -1.5,\n        -0.75,\n        -4.0,\n        4.0,\n        2.0,\n        -2.0,\n        -1.2041015625,\n        -2.0,\n        f64::NEGATIVE_INFINITY,\n        -0.75,\n        -0.75,\n        -3.0,\n        0.0,\n        1.2041015625,\n        -40.0,\n        -0.6875,\n        2.0,\n        0.75,\n        0.75,\n        -1.3125,\n        3.0,\n        -2.0,\n        40.0,\n        0.6875,\n        f64::NEGATIVE_INFINITY,\n        -0.5,\n        -1.5,\n        -0.0,\n        1.3125,\n        -0.125,\n        -1.125,\n        -0.046875,\n        2.0,\n        -1.5,\n        -1.9375,\n        -1.0,\n        0.5,\n        -0.75,\n        1.5,\n        -1.0,\n        0.125,\n        0.0,\n        -1.875,\n        1.125,\n        0.046875,\n    ];\n    let common_values = &[\n        (1.0, 49883),\n        (-1.0, 49740),\n        (1.5, 33699),\n        (f64::NEGATIVE_INFINITY, 33640),\n        (-1.5, 33608),\n        (0.0, 33393),\n        (-0.0, 33191),\n        (0.5, 25188),\n        (-0.5, 25120),\n        (2.0, 24765),\n        (-2.0, 24711),\n        (3.0, 16988),\n        (-3.0, 16939),\n        (0.75, 16654),\n        (-0.75, 16610),\n        (4.0, 12510),\n        (0.25, 12465),\n        (-4.0, 12461),\n        (-0.25, 12430),\n        (1.75, 11176),\n    ];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // f64, a = -0.0, b = 0.0, mean abs of exponent = 1, mean precision = 2, mean zero P = 1/10\n    let values = &[-0.0; 50];\n    let common_values = &[(-0.0, 1000000)];\n    let sample_median = (-0.0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    special_random_primitive_float_range_helper::<f64>(\n        -0.0,\n        0.0,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn special_random_primitive_float_range_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ZERO,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::ONE,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::NAN,\n        1,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        0,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        0,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::from(100.0),\n        T::from(101.0),\n        6,\n        1,\n        2,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        1,\n        2,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        1,\n        0,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        2,\n        1,\n        2,\n        1\n    ));\n    assert_panic!(special_random_primitive_float_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n        2,\n        1,\n        1,\n        0\n    ));\n}\n\n#[test]\nfn special_random_primitive_float_range_fail() {\n    apply_fn_to_primitive_floats!(special_random_primitive_float_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/special_random_primitive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::random::special_random_primitive_floats;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::num::random::special_random_primitive_floats_helper_helper;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, NAN_MOMENT_STATS};\nuse std::panic::catch_unwind;\n\nfn special_random_primitive_floats_helper<T: CheckedToF64 + PrimitiveFloat>(\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n    expected_values: &[T],\n    expected_common_values: &[(T, usize)],\n    expected_median: (T, Option<T>),\n    expected_moment_stats: MomentStats,\n) {\n    special_random_primitive_floats_helper_helper(\n        special_random_primitive_floats::<T>(\n            EXAMPLE_SEED,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_special_p_numerator,\n            mean_special_p_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_special_random_primitive_floats() {\n    // f32, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f32::INFINITY,\n        1.0,\n        1.0,\n        f32::INFINITY,\n        1.0,\n        -1.0,\n        f32::INFINITY,\n        -1.0,\n        f32::INFINITY,\n        0.0,\n        -1.0,\n        f32::INFINITY,\n        -1.0,\n        1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        0.5,\n        1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        1.0,\n        1.0,\n        0.0,\n        -1.5,\n        f32::NEGATIVE_INFINITY,\n        0.0,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -0.0,\n        1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        f32::INFINITY,\n        f32::NEGATIVE_INFINITY,\n        f32::INFINITY,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 358244),\n        (-1.0, 357926),\n        (f32::INFINITY, 50304),\n        (f32::NEGATIVE_INFINITY, 50127),\n        (-0.0, 49984),\n        (f32::NAN, 49926),\n        (0.0, 49868),\n        (2.0, 5538),\n        (1.5, 5500),\n        (0.5, 5497),\n        (-1.5, 5454),\n        (-2.0, 5379),\n        (-0.5, 5357),\n        (0.75, 102),\n        (3.0, 98),\n        (-4.0, 95),\n        (-0.25, 91),\n        (-0.75, 87),\n        (-3.0, 86),\n        (0.25, 79),\n    ];\n    let sample_median = (f32::NAN, None);\n    special_random_primitive_floats_helper::<f32>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        1.0,\n        1.25,\n        3.0,\n        f32::INFINITY,\n        -1.0,\n        -1.0,\n        -2.0,\n        -3.5,\n        1.0,\n        2.0,\n        -1.5,\n        -2.5,\n        -2.0,\n        f32::INFINITY,\n        -6.5,\n        -1.0,\n        -1.0,\n        f32::INFINITY,\n        3.0,\n        -0.21875,\n        -1.0,\n        0.25,\n        1.5,\n        5.25,\n        -4.0,\n        7.0,\n        -0.5,\n        0.1875,\n        1.25,\n        f32::INFINITY,\n        -0.1875,\n        -7.5,\n        0.0,\n        0.75,\n        -7.0,\n        -6.0,\n        -3.0,\n        0.234375,\n        -2.0,\n        -0.875,\n        -0.75,\n        6.0,\n        -24.0,\n        24.0,\n        -2.0,\n        1.5,\n        f32::INFINITY,\n        -1.25,\n        14.0,\n        5.0,\n    ];\n    let common_values = &[\n        (1.0, 74789),\n        (-1.0, 74702),\n        (1.5, 38119),\n        (-0.5, 37713),\n        (2.0, 37640),\n        (-1.5, 37613),\n        (-2.0, 37333),\n        (0.5, 37027),\n        (f32::NEGATIVE_INFINITY, 20096),\n        (0.0, 20064),\n        (f32::INFINITY, 20042),\n        (-0.0, 20022),\n        (f32::NAN, 20000),\n        (0.75, 19050),\n        (4.0, 18892),\n        (0.25, 18875),\n        (-3.0, 18866),\n        (3.0, 18821),\n        (-0.75, 18725),\n        (-4.0, 18663),\n    ];\n    let sample_median = (f32::NAN, None);\n    special_random_primitive_floats_helper::<f32>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f32, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        0.65625,\n        0.0000014255784,\n        0.013183594,\n        -0.8125,\n        -74240.0,\n        -0.0078125,\n        -0.03060913,\n        3.331552,\n        4.75,\n        -0.000038146973,\n        -0.3125,\n        -27136.0,\n        -59392.0,\n        -1.75,\n        -41.1875,\n        0.30940247,\n        -0.0009765625,\n        -1536.0,\n        0.2109375,\n        0.0014648438,\n        2.1129381e-8,\n        -0.037109375,\n        5242880.0,\n        -0.21386719,\n        134.21094,\n        4.184082,\n        -1561370.0,\n        -2.1420419e-7,\n        0.38085938,\n        -0.007003784,\n        -37748736.0,\n        -6448.0,\n        28.25,\n        -6.703125,\n        -4.483364,\n        -3.1757812,\n        0.000003915804,\n        -0.020751953,\n        0.00011110306,\n        -0.000053405256,\n        0.00019985437,\n        -35.40625,\n        0.005859375,\n        0.0078125,\n        28.25,\n        30.0,\n        -0.20776367,\n        -144.0,\n        -0.109375,\n        -6144.0,\n    ];\n    let common_values = &[\n        (1.0, 2559),\n        (-1.0, 2528),\n        (0.5, 2362),\n        (-2.0, 2312),\n        (-1.5, 2306),\n        (2.0, 2304),\n        (1.5, 2275),\n        (-0.5, 2243),\n        (-3.0, 2204),\n        (-4.0, 2163),\n        (-0.25, 2129),\n        (0.75, 2103),\n        (3.0, 2081),\n        (0.25, 2070),\n        (f32::INFINITY, 2053),\n        (-0.75, 2047),\n        (4.0, 2038),\n        (0.0, 2034),\n        (f32::NEGATIVE_INFINITY, 1982),\n        (-0.0, 1961),\n    ];\n    let sample_median = (f32::NAN, None);\n    special_random_primitive_floats_helper::<f32>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1/64, mean precision = 65/64, mean special P = 1/4\n    let values = &[\n        f64::INFINITY,\n        1.0,\n        1.0,\n        f64::INFINITY,\n        1.0,\n        -1.0,\n        f64::INFINITY,\n        -1.0,\n        f64::INFINITY,\n        0.0,\n        -1.0,\n        f64::INFINITY,\n        -1.0,\n        1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        1.0,\n        0.5,\n        1.0,\n        -1.0,\n        1.0,\n        -1.0,\n        1.0,\n        1.0,\n        0.0,\n        -1.5,\n        f64::NEGATIVE_INFINITY,\n        0.0,\n        -1.0,\n        1.0,\n        -1.0,\n        -1.0,\n        -1.0,\n        -0.0,\n        1.0,\n        -1.0,\n        -0.5,\n        -1.0,\n        f64::INFINITY,\n        f64::NEGATIVE_INFINITY,\n        f64::INFINITY,\n        1.0,\n    ];\n    let common_values = &[\n        (1.0, 358244),\n        (-1.0, 357926),\n        (f64::INFINITY, 50304),\n        (f64::NEGATIVE_INFINITY, 50127),\n        (-0.0, 49984),\n        (f64::NAN, 49926),\n        (0.0, 49868),\n        (2.0, 5538),\n        (1.5, 5500),\n        (0.5, 5497),\n        (-1.5, 5454),\n        (-2.0, 5379),\n        (-0.5, 5357),\n        (0.75, 102),\n        (3.0, 98),\n        (-4.0, 95),\n        (-0.25, 91),\n        (-0.75, 87),\n        (-3.0, 86),\n        (0.25, 79),\n    ];\n    let sample_median = (f64::NAN, None);\n    special_random_primitive_floats_helper::<f64>(\n        1,\n        64,\n        65,\n        64,\n        1,\n        4,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 1, mean precision = 2, mean special P = 1/10\n    let values = &[\n        1.0,\n        1.25,\n        3.0,\n        f64::INFINITY,\n        -1.0,\n        -1.0,\n        -2.0,\n        -3.5,\n        1.0,\n        2.0,\n        -1.5,\n        -2.5,\n        -2.0,\n        f64::INFINITY,\n        -6.5,\n        -1.0,\n        -1.0,\n        f64::INFINITY,\n        3.0,\n        -0.21875,\n        -1.0,\n        0.25,\n        1.5,\n        5.25,\n        -4.0,\n        7.0,\n        -0.5,\n        0.1875,\n        1.25,\n        f64::INFINITY,\n        -0.1875,\n        -7.5,\n        0.0,\n        0.75,\n        -7.0,\n        -6.0,\n        -3.0,\n        0.234375,\n        -2.0,\n        -0.875,\n        -0.75,\n        6.0,\n        -24.0,\n        24.0,\n        -2.0,\n        1.5,\n        f64::INFINITY,\n        -1.25,\n        14.0,\n        5.0,\n    ];\n    let common_values = &[\n        (1.0, 74789),\n        (-1.0, 74702),\n        (1.5, 38119),\n        (-0.5, 37713),\n        (2.0, 37640),\n        (-1.5, 37613),\n        (-2.0, 37333),\n        (0.5, 37027),\n        (f64::NEGATIVE_INFINITY, 20096),\n        (0.0, 20064),\n        (f64::INFINITY, 20042),\n        (-0.0, 20022),\n        (f64::NAN, 20000),\n        (0.75, 19050),\n        (4.0, 18892),\n        (0.25, 18875),\n        (-3.0, 18866),\n        (3.0, 18821),\n        (-0.75, 18725),\n        (-4.0, 18663),\n    ];\n    let sample_median = (f64::NAN, None);\n    special_random_primitive_floats_helper::<f64>(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n\n    // f64, mean abs of exponent = 10, mean precision = 10, mean special P = 1/100\n    let values = &[\n        0.7709910366684198,\n        1.2504315236583352e-6,\n        0.00830078125,\n        -0.8125,\n        -85504.0,\n        -0.0078125,\n        -0.018890380859375,\n        2.5721821784973145,\n        5.75,\n        -0.00003814697265625,\n        -0.4375,\n        -24064.0,\n        -43008.0,\n        -1.75,\n        -54.6875,\n        0.4641265869140625,\n        -0.0014760522753931582,\n        -1536.0,\n        0.1484375,\n        0.00146484375,\n        1.9383151084184647e-8,\n        -0.060546875,\n        7340032.0,\n        -0.1982421875,\n        203.0546875,\n        4.57177734375,\n        -1555162.0,\n        -2.0675361156463623e-7,\n        0.279296875,\n        -0.0045928955078125,\n        -46137344.0,\n        -5712.0,\n        17.75,\n        -5.265625,\n        -7.966220855712891,\n        -2.99609375,\n        5.397188942879438e-6,\n        -0.017333984375,\n        0.00011491775512695312,\n        -0.00005845972555107437,\n        0.00020831823348999023,\n        -46.78125,\n        0.005859375,\n        0.0078125,\n        27.25,\n        30.0,\n        -0.175537109375,\n        -208.0,\n        -0.109375,\n        -6144.0,\n    ];\n    let common_values = &[\n        (1.0, 2396),\n        (-1.0, 2336),\n        (-2.0, 2200),\n        (-1.5, 2169),\n        (0.5, 2116),\n        (2.0, 2108),\n        (-0.5, 2101),\n        (1.5, 2085),\n        (f64::INFINITY, 2053),\n        (0.0, 2034),\n        (-3.0, 2000),\n        (4.0, 1993),\n        (f64::NEGATIVE_INFINITY, 1982),\n        (3.0, 1969),\n        (-0.0, 1961),\n        (f64::NAN, 1959),\n        (-0.25, 1955),\n        (0.75, 1946),\n        (0.25, 1917),\n        (-4.0, 1882),\n    ];\n    let sample_median = (f64::NAN, None);\n    special_random_primitive_floats_helper::<f64>(\n        10,\n        1,\n        10,\n        1,\n        1,\n        100,\n        values,\n        common_values,\n        sample_median,\n        NAN_MOMENT_STATS,\n    );\n}\n\nfn special_random_primitive_floats_fail_helper<T: PrimitiveFloat>() {\n    assert_panic!(special_random_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        0,\n        1,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        1,\n        0,\n        10,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        1,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        1,\n        0,\n        1,\n        10\n    ));\n    assert_panic!(special_random_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        1,\n        0\n    ));\n    assert_panic!(special_random_primitive_floats::<T>(\n        EXAMPLE_SEED,\n        10,\n        1,\n        10,\n        1,\n        2,\n        1\n    ));\n}\n\n#[test]\nfn special_random_primitive_floats_fail() {\n    apply_fn_to_primitive_floats!(special_random_primitive_floats_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/get_striped_bool_vec.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::random::striped::{StripedBitSource, get_striped_bool_vec};\nuse malachite_base::random::EXAMPLE_SEED;\n\npub(crate) fn bool_slice_to_string(bs: &[bool]) -> String {\n    bs.iter().map(|&b| if b { '1' } else { '0' }).collect()\n}\n\nfn get_striped_bool_vec_helper(m_numerator: u64, m_denominator: u64, len: u64, out: &str) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, m_numerator, m_denominator);\n    let bits = bool_slice_to_string(&get_striped_bool_vec(&mut bit_source, len));\n    assert_eq!(bits, out);\n}\n\n#[test]\nfn test_get_striped_bool_vec() {\n    get_striped_bool_vec_helper(2, 1, 0, \"\");\n    get_striped_bool_vec_helper(\n        2,\n        1,\n        50,\n        \"00110011000110101010010110100100000110000111010111\",\n    );\n    get_striped_bool_vec_helper(\n        10,\n        1,\n        50,\n        \"00011111111111000000011111111111111000000000001111\",\n    );\n    get_striped_bool_vec_helper(\n        11,\n        10,\n        50,\n        \"01010101010101101000111001010101010101111010101010\",\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/get_striped_unsigned_vec.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::striped::{StripedBitSource, get_striped_unsigned_vec};\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\n\nfn get_striped_unsigned_vec_helper<T: PrimitiveUnsigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    len: u64,\n    out: &[&str],\n) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, m_numerator, m_denominator);\n    let xs = get_striped_unsigned_vec::<T>(&mut bit_source, len)\n        .iter()\n        .map(T::to_binary_string)\n        .collect_vec();\n    assert_eq!(xs, out);\n}\n\n#[test]\nfn test_get_striped_unsigned_vec() {\n    get_striped_unsigned_vec_helper::<u8>(2, 1, 0, &[]);\n    get_striped_unsigned_vec_helper::<u8>(\n        2,\n        1,\n        100,\n        &[\n            \"11001100\", \"1011000\", \"10100101\", \"100101\", \"11000\", \"10101110\", \"100111\", \"11000000\",\n            \"10010001\", \"11000\", \"11000100\", \"10001011\", \"1001\",\n        ],\n    );\n    get_striped_unsigned_vec_helper::<u8>(\n        10,\n        1,\n        100,\n        &[\n            \"11111000\", \"111111\", \"11100000\", \"11111111\", \"111\", \"11000000\", \"11111111\", \"0\", \"0\",\n            \"11111000\", \"11111111\", \"11111111\", \"11\",\n        ],\n    );\n    get_striped_unsigned_vec_helper::<u8>(\n        11,\n        10,\n        100,\n        &[\n            \"10101010\", \"1101010\", \"1110001\", \"10101010\", \"11101010\", \"1010101\", \"1010101\",\n            \"10101011\", \"1010101\", \"1010101\", \"1010101\", \"1101101\", \"1101\",\n        ],\n    );\n    get_striped_unsigned_vec_helper::<u64>(\n        2,\n        1,\n        130,\n        &[\n            \"1100000000100111101011100001100000100101101001010101100011001100\",\n            \"1100110010001011010100110100110001011110001000001100010010001\",\n            \"10\",\n        ],\n    );\n    get_striped_unsigned_vec_helper::<u64>(\n        10,\n        1,\n        130,\n        &[\n            \"11111111110000000000011111111111111000000011111111111000\",\n            \"1100000111111111111111000000001111111111111111111111100000000000\",\n            \"11\",\n        ],\n    );\n    get_striped_unsigned_vec_helper::<u64>(\n        11,\n        10,\n        130,\n        &[\n            \"1010101101010101010101011110101010101010011100010110101010101010\",\n            \"101101010101011010110101001110101101101010101010101010101010101\",\n            \"1\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_bit_source.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\n\nconst BIT_STRING_LENGTH: usize = 80;\n\nfn generate_string(bit_source: &mut StripedBitSource) -> String {\n    let mut string = String::with_capacity(BIT_STRING_LENGTH);\n    for bit in bit_source.take(BIT_STRING_LENGTH) {\n        if bit {\n            string.push('1');\n        } else {\n            string.push('0');\n        }\n    }\n    string\n}\n\nfn striped_bit_source_helper(m_numerator: u64, m_denominator: u64, bit_string: &str) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, m_numerator, m_denominator);\n    assert_eq!(generate_string(&mut bit_source), bit_string);\n}\n\n#[test]\npub fn test_striped_bit_source() {\n    striped_bit_source_helper(\n        4,\n        1,\n        \"00000001011001100000000111100000000011111111110000111011000000000000111111111111\",\n    );\n    striped_bit_source_helper(\n        10,\n        1,\n        \"00011111111111000000011111111111111000000000001111111111000000000000000000011111\",\n    );\n    striped_bit_source_helper(\n        1000000,\n        1,\n        \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n    );\n\n    striped_bit_source_helper(\n        2,\n        1,\n        \"00110011000110101010010110100100000110000111010111100100000000111000100100011000\",\n    );\n\n    striped_bit_source_helper(\n        5,\n        4,\n        \"01010010110101001100101101011010101010001010101011010010101010010001101000010000\",\n    );\n    striped_bit_source_helper(\n        11,\n        10,\n        \"01010101010101101000111001010101010101111010101010101010110101011010101010101010\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn new_fail_1() {\n    StripedBitSource::new(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn new_fail_2() {\n    StripedBitSource::new(EXAMPLE_SEED, 1, 1);\n}\n\n#[test]\n#[should_panic]\nfn new_fail_3() {\n    StripedBitSource::new(EXAMPLE_SEED, 2, 3);\n}\n\n#[test]\npub fn test_end_block() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 1000000, 1);\n    let mut strings = Vec::with_capacity(5);\n    for _ in 0..5 {\n        strings.push(generate_string(&mut bit_source));\n        bit_source.end_block();\n    }\n    assert_eq!(\n        strings,\n        &[\n            \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n            \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n            \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n            \"11111111111111111111111111111111111111111111111111111111111111111111111111111111\",\n            \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n        ]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_bool_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::striped::get_striped_bool_vec::bool_slice_to_string;\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::striped_random_bool_vecs;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_bool_vecs_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let xs = striped_random_bool_vecs(\n        EXAMPLE_SEED,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xs\n        .clone()\n        .take(20)\n        .map(|bs| bool_slice_to_string(&bs))\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(bs, freq)| (bool_slice_to_string(&bs), freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.take(1000000));\n    let median_lo = bool_slice_to_string(&median_lo);\n    let median_hi = median_hi.map(|bs| bool_slice_to_string(&bs));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_bool_vecs() {\n    striped_random_bool_vecs_helper(\n        2,\n        1,\n        4,\n        1,\n        &[\n            \"\",\n            \"00110011000110\",\n            \"0001\",\n            \"0110\",\n            \"0\",\n            \"\",\n            \"00111\",\n            \"10\",\n            \"0100\",\n            \"\",\n            \"111010\",\n            \"\",\n            \"\",\n            \"01111101000\",\n            \"11001100\",\n            \"\",\n            \"100\",\n            \"\",\n            \"01011\",\n            \"000111111\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"1\", 80247),\n            (\"0\", 79926),\n            (\"10\", 32241),\n            (\"00\", 32110),\n            (\"11\", 31988),\n            (\"01\", 31834),\n            (\"001\", 12991),\n            (\"111\", 12989),\n            (\"010\", 12807),\n        ],\n        (\"0100011111011\", None),\n    );\n    striped_random_bool_vecs_helper(\n        10,\n        1,\n        4,\n        1,\n        &[\n            \"\",\n            \"00000000000000\",\n            \"0000\",\n            \"0001\",\n            \"0\",\n            \"\",\n            \"00011\",\n            \"11\",\n            \"0000\",\n            \"\",\n            \"111111\",\n            \"\",\n            \"\",\n            \"01111111100\",\n            \"11111000\",\n            \"\",\n            \"111\",\n            \"\",\n            \"00000\",\n            \"000111111\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"1\", 80247),\n            (\"0\", 79926),\n            (\"11\", 57775),\n            (\"00\", 57583),\n            (\"000\", 41616),\n            (\"111\", 41544),\n            (\"0000\", 29747),\n            (\"1111\", 29589),\n            (\"11111\", 21524),\n        ],\n        (\"00000001111\", None),\n    );\n    striped_random_bool_vecs_helper(\n        11,\n        10,\n        4,\n        1,\n        &[\n            \"\",\n            \"01011010101010\",\n            \"0110\",\n            \"0101\",\n            \"0\",\n            \"\",\n            \"01101\",\n            \"10\",\n            \"0101\",\n            \"\",\n            \"100101\",\n            \"\",\n            \"\",\n            \"01101011010\",\n            \"10101010\",\n            \"\",\n            \"101\",\n            \"\",\n            \"01010\",\n            \"010101001\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"1\", 80247),\n            (\"0\", 79926),\n            (\"10\", 58377),\n            (\"01\", 58287),\n            (\"010\", 42404),\n            (\"101\", 42353),\n            (\"1010\", 30704),\n            (\"0101\", 30613),\n            (\"10101\", 22466),\n        ],\n        (\"010101\", None),\n    );\n    striped_random_bool_vecs_helper(\n        2,\n        1,\n        10,\n        1,\n        &[\n            \"0011001100011000100110001011\",\n            \"000101000001011110\",\n            \"0011001101000011111\",\n            \"000\",\n            \"011011101100\",\n            \"1\",\n            \"00111100000001010011001111101\",\n            \"11110\",\n            \"01\",\n            \"10110001011\",\n            \"111100001101100101000100011011\",\n            \"01010\",\n            \"0111\",\n            \"00110101\",\n            \"11111011001\",\n            \"0011\",\n            \"110111111\",\n            \"000101101\",\n            \"0110111011110110011001000\",\n            \"1\",\n        ],\n        &[\n            (\"\", 90709),\n            (\"0\", 41449),\n            (\"1\", 41338),\n            (\"00\", 18773),\n            (\"10\", 18748),\n            (\"11\", 18731),\n            (\"01\", 18531),\n            (\"001\", 8685),\n            (\"111\", 8639),\n            (\"010\", 8624),\n        ],\n        (\"011011101010\", None),\n    );\n    striped_random_bool_vecs_helper(\n        10,\n        1,\n        10,\n        1,\n        &[\n            \"0000000000000000000111000000\",\n            \"000000111111110000\",\n            \"0001111111111100000\",\n            \"000\",\n            \"000000000000\",\n            \"1\",\n            \"00000000000001111111111111111\",\n            \"11111\",\n            \"00\",\n            \"10000001111\",\n            \"111111111101111111111111000000\",\n            \"00000\",\n            \"0000\",\n            \"00000000\",\n            \"11000011111\",\n            \"0001\",\n            \"111111111\",\n            \"000000000\",\n            \"0000000001100111111111111\",\n            \"1\",\n        ],\n        &[\n            (\"\", 90709),\n            (\"0\", 41449),\n            (\"1\", 41338),\n            (\"00\", 33629),\n            (\"11\", 33603),\n            (\"111\", 27832),\n            (\"000\", 27669),\n            (\"1111\", 22666),\n            (\"0000\", 22522),\n            (\"11111\", 18708),\n        ],\n        (\n            \"00111111111110000000000011111000000001\",\n            Some(\"001111111111100000000000111110011111\"),\n        ),\n    );\n    striped_random_bool_vecs_helper(\n        11,\n        10,\n        10,\n        1,\n        &[\n            \"0101101010101011010100101010\",\n            \"011010110101101010\",\n            \"0101010101010101011\",\n            \"010\",\n            \"010110101010\",\n            \"1\",\n            \"01010101001101011010101010101\",\n            \"10101\",\n            \"01\",\n            \"10101010101\",\n            \"101101010110101001010101001010\",\n            \"01010\",\n            \"0101\",\n            \"01010101\",\n            \"10101101010\",\n            \"0101\",\n            \"101011010\",\n            \"010010101\",\n            \"0101010101010101010101011\",\n            \"1\",\n        ],\n        &[\n            (\"\", 90709),\n            (\"0\", 41449),\n            (\"1\", 41338),\n            (\"10\", 34030),\n            (\"01\", 33878),\n            (\"010\", 28388),\n            (\"101\", 28324),\n            (\"1010\", 23483),\n            (\"0101\", 23162),\n            (\"10101\", 19518),\n        ],\n        (\"01011010\", None),\n    );\n    striped_random_bool_vecs_helper(\n        2,\n        1,\n        1,\n        4,\n        &[\"\", \"\", \"0\", \"0\", \"00\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"01\", \"0\", \"\", \"11\", \"\", \"\", \"\", \"\"],\n        &[\n            (\"\", 800023),\n            (\"1\", 80189),\n            (\"0\", 79739),\n            (\"00\", 8218),\n            (\"01\", 8023),\n            (\"11\", 7972),\n            (\"10\", 7920),\n            (\"001\", 819),\n            (\"110\", 812),\n            (\"101\", 810),\n        ],\n        (\"\", None),\n    );\n    striped_random_bool_vecs_helper(\n        10,\n        1,\n        1,\n        4,\n        &[\"\", \"\", \"0\", \"0\", \"00\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"00\", \"0\", \"\", \"11\", \"\", \"\", \"\", \"\"],\n        &[\n            (\"\", 800023),\n            (\"1\", 80189),\n            (\"0\", 79739),\n            (\"00\", 14590),\n            (\"11\", 14351),\n            (\"000\", 2591),\n            (\"111\", 2530),\n            (\"01\", 1651),\n            (\"10\", 1541),\n            (\"1111\", 460),\n        ],\n        (\"\", None),\n    );\n    striped_random_bool_vecs_helper(\n        11,\n        10,\n        1,\n        4,\n        &[\"\", \"\", \"0\", \"0\", \"01\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"01\", \"0\", \"\", \"10\", \"\", \"\", \"\", \"\"],\n        &[\n            (\"\", 800023),\n            (\"1\", 80189),\n            (\"0\", 79739),\n            (\"01\", 14758),\n            (\"10\", 14493),\n            (\"101\", 2640),\n            (\"010\", 2614),\n            (\"00\", 1483),\n            (\"11\", 1399),\n            (\"0101\", 467),\n        ],\n        (\"\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_fail_1() {\n    striped_random_bool_vecs(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_fail_2() {\n    striped_random_bool_vecs(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_fail_3() {\n    striped_random_bool_vecs(EXAMPLE_SEED, 4, 1, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_fail_4() {\n    striped_random_bool_vecs(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_fail_5() {\n    striped_random_bool_vecs(EXAMPLE_SEED, 4, 1, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_bool_vecs_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::striped::get_striped_bool_vec::bool_slice_to_string;\nuse itertools::Itertools;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::striped::striped_random_bool_vecs_from_length_iterator;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::vecs::random_values_from_vec;\nuse std::iter::repeat;\n\nfn striped_random_bool_vecs_from_length_iterator_helper<I: Clone + Iterator<Item = u64>>(\n    lengths_gen: &dyn Fn(Seed) -> I,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let xs = striped_random_bool_vecs_from_length_iterator(\n        EXAMPLE_SEED,\n        lengths_gen,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xs\n        .clone()\n        .take(20)\n        .map(|bs| bool_slice_to_string(&bs))\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(bs, freq)| (bool_slice_to_string(&bs), freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.take(1000000));\n    let median_lo = bool_slice_to_string(&median_lo);\n    let median_hi = median_hi.map(|bs| bool_slice_to_string(&bs));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_bool_vecs_from_length_iterator() {\n    striped_random_bool_vecs_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n        2,\n        1,\n        &[\n            \"00\", \"0110\", \"00\", \"0110\", \"0001\", \"11\", \"\", \"01\", \"\", \"1110\", \"0110\", \"11\", \"1000\",\n            \"01\", \"0100\", \"0001\", \"1010\", \"\", \"0000\", \"\",\n        ],\n        &[\n            (\"\", 333820),\n            (\"00\", 83428),\n            (\"10\", 83346),\n            (\"11\", 83184),\n            (\"01\", 83167),\n            (\"0010\", 20955),\n            (\"0001\", 20940),\n            (\"1110\", 20921),\n            (\"1011\", 20912),\n            (\"0011\", 20870),\n        ],\n        (\"0011\", None),\n    );\n    striped_random_bool_vecs_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n        10,\n        1,\n        &[\n            \"00\", \"0000\", \"00\", \"0000\", \"0000\", \"11\", \"\", \"00\", \"\", \"1111\", \"0001\", \"11\", \"1100\",\n            \"00\", \"0000\", \"0000\", \"1110\", \"\", \"0000\", \"\",\n        ],\n        &[\n            (\"\", 333820),\n            (\"11\", 149822),\n            (\"00\", 149788),\n            (\"0000\", 121534),\n            (\"1111\", 121330),\n            (\"01\", 16807),\n            (\"10\", 16708),\n            (\"0011\", 13644),\n            (\"1110\", 13490),\n            (\"0001\", 13454),\n        ],\n        (\"0000\", None),\n    );\n    striped_random_bool_vecs_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n        11,\n        10,\n        &[\n            \"01\", \"0100\", \"01\", \"0101\", \"0101\", \"10\", \"\", \"01\", \"\", \"1001\", \"0101\", \"10\", \"1101\",\n            \"01\", \"0101\", \"0110\", \"1010\", \"\", \"0010\", \"\",\n        ],\n        &[\n            (\"\", 333820),\n            (\"01\", 151459),\n            (\"10\", 151370),\n            (\"0101\", 125515),\n            (\"1010\", 124901),\n            (\"11\", 15160),\n            (\"00\", 15136),\n            (\"0010\", 12625),\n            (\"1011\", 12598),\n            (\"1001\", 12494),\n        ],\n        (\"01\", None),\n    );\n    striped_random_bool_vecs_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        2,\n        1,\n        &[\n            \"001100110001\",\n            \"00\",\n            \"0111011001110100\",\n            \"00\",\n            \"0010100000101111001100110100\",\n            \"\",\n            \"1110000000\",\n            \"01101110\",\n            \"10\",\n            \"\",\n            \"001110000111\",\n            \"1111\",\n            \"\",\n            \"\",\n            \"11\",\n            \"010100\",\n            \"\",\n            \"01\",\n            \"\",\n            \"00\",\n        ],\n        &[\n            (\"\", 333981),\n            (\"11\", 56301),\n            (\"01\", 55922),\n            (\"00\", 55472),\n            (\"10\", 55087),\n            (\"0101\", 9537),\n            (\"0100\", 9341),\n            (\"0010\", 9326),\n            (\"1011\", 9314),\n            (\"0001\", 9297),\n        ],\n        (\"00111111100101\", Some(\"0011111110010100\")),\n    );\n    striped_random_bool_vecs_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        10,\n        1,\n        &[\n            \"000000000000\",\n            \"00\",\n            \"0000000111000000\",\n            \"00\",\n            \"0000011111111000000111111111\",\n            \"\",\n            \"1110000000\",\n            \"00000000\",\n            \"11\",\n            \"\",\n            \"000000000000\",\n            \"1111\",\n            \"\",\n            \"\",\n            \"11\",\n            \"011111\",\n            \"\",\n            \"00\",\n            \"\",\n            \"00\",\n        ],\n        &[\n            (\"\", 333981),\n            (\"00\", 100383),\n            (\"11\", 100353),\n            (\"1111\", 53920),\n            (\"0000\", 53883),\n            (\"000000\", 29226),\n            (\"111111\", 29014),\n            (\"00000000\", 15928),\n            (\"11111111\", 15670),\n            (\"10\", 11035),\n        ],\n        (\"000000\", None),\n    );\n    striped_random_bool_vecs_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        11,\n        10,\n        &[\n            \"010110101010\",\n            \"01\",\n            \"0100101011010101\",\n            \"01\",\n            \"0010100101001010101010101010\",\n            \"\",\n            \"1010101101\",\n            \"01011010\",\n            \"10\",\n            \"\",\n            \"010101010101\",\n            \"1100\",\n            \"\",\n            \"\",\n            \"10\",\n            \"010110\",\n            \"\",\n            \"01\",\n            \"\",\n            \"01\",\n        ],\n        &[\n            (\"\", 333981),\n            (\"10\", 101326),\n            (\"01\", 101218),\n            (\"0101\", 55895),\n            (\"1010\", 55433),\n            (\"101010\", 30661),\n            (\"010101\", 30567),\n            (\"01010101\", 17148),\n            (\"10101010\", 16775),\n            (\"00\", 10176),\n        ],\n        (\"0101\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_from_length_iterator_fail_1() {\n    striped_random_bool_vecs_from_length_iterator(EXAMPLE_SEED, &|_| repeat(1), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_from_length_iterator_fail_2() {\n    striped_random_bool_vecs_from_length_iterator(EXAMPLE_SEED, &|_| repeat(1), 2, 3);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_bool_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::striped::get_striped_bool_vec::bool_slice_to_string;\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::striped_random_bool_vecs_length_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_bool_vecs_length_inclusive_range_helper(\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let xs = striped_random_bool_vecs_length_inclusive_range(\n        EXAMPLE_SEED,\n        a,\n        b,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xs\n        .clone()\n        .take(20)\n        .map(|bs| bool_slice_to_string(&bs))\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(bs, freq)| (bool_slice_to_string(&bs), freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.take(1000000));\n    let median_lo = bool_slice_to_string(&median_lo);\n    let median_hi = median_hi.map(|bs| bool_slice_to_string(&bs));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_bool_vecs_length_inclusive_range() {\n    striped_random_bool_vecs_length_inclusive_range_helper(\n        3,\n        9,\n        2,\n        1,\n        &[\n            \"00110011\",\n            \"01110011\",\n            \"00100110\",\n            \"00010111\",\n            \"001010000\",\n            \"110\",\n            \"0100\",\n            \"1110011\",\n            \"011001011\",\n            \"111000\",\n            \"111110010\",\n            \"0001001\",\n            \"00011110\",\n            \"00000\",\n            \"1110101\",\n            \"0011001\",\n            \"11111\",\n            \"01000010\",\n            \"01001110\",\n            \"10111\",\n        ],\n        &[\n            (\"001\", 18041),\n            (\"110\", 18008),\n            (\"111\", 17919),\n            (\"100\", 17906),\n            (\"011\", 17905),\n            (\"000\", 17819),\n            (\"010\", 17792),\n            (\"101\", 17782),\n            (\"0111\", 9023),\n            (\"1011\", 9023),\n        ],\n        (\"100\", None),\n    );\n    striped_random_bool_vecs_length_inclusive_range_helper(\n        3,\n        9,\n        10,\n        1,\n        &[\n            \"00000000\",\n            \"00000000\",\n            \"00000111\",\n            \"01111111\",\n            \"000001111\",\n            \"111\",\n            \"0001\",\n            \"1111110\",\n            \"000000000\",\n            \"111000\",\n            \"111111111\",\n            \"0000000\",\n            \"00000000\",\n            \"00000\",\n            \"1110000\",\n            \"0000000\",\n            \"11111\",\n            \"00000000\",\n            \"01111110\",\n            \"11111\",\n        ],\n        &[\n            (\"000\", 58009),\n            (\"111\", 57974),\n            (\"1111\", 52110),\n            (\"0000\", 51905),\n            (\"00000\", 47047),\n            (\"11111\", 46660),\n            (\"111111\", 42411),\n            (\"000000\", 41880),\n            (\"0000000\", 38018),\n            (\"1111111\", 37708),\n        ],\n        (\"100\", None),\n    );\n    striped_random_bool_vecs_length_inclusive_range_helper(\n        3,\n        9,\n        11,\n        10,\n        &[\n            \"01011010\",\n            \"01010101\",\n            \"00101011\",\n            \"01010101\",\n            \"001010010\",\n            \"101\",\n            \"0010\",\n            \"1010101\",\n            \"010101010\",\n            \"101010\",\n            \"100101011\",\n            \"0101010\",\n            \"01010101\",\n            \"01001\",\n            \"1101011\",\n            \"0101010\",\n            \"10101\",\n            \"01010101\",\n            \"01010101\",\n            \"10101\",\n        ],\n        &[\n            (\"010\", 59241),\n            (\"101\", 59092),\n            (\"1010\", 53578),\n            (\"0101\", 53360),\n            (\"01010\", 48685),\n            (\"10101\", 48527),\n            (\"010101\", 44471),\n            (\"101010\", 44350),\n            (\"0101010\", 40536),\n            (\"1010101\", 40115),\n        ],\n        (\"100\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_length_inclusive_range_fail_1() {\n    striped_random_bool_vecs_length_inclusive_range(EXAMPLE_SEED, 3, 10, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_length_inclusive_range_fail_2() {\n    striped_random_bool_vecs_length_inclusive_range(EXAMPLE_SEED, 3, 10, 2, 3);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_length_inclusive_range_fail_3() {\n    striped_random_bool_vecs_length_inclusive_range(EXAMPLE_SEED, 2, 1, 4, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_bool_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::striped::get_striped_bool_vec::bool_slice_to_string;\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::striped_random_bool_vecs_length_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_bool_vecs_length_range_helper(\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let xs = striped_random_bool_vecs_length_range(\n        EXAMPLE_SEED,\n        a,\n        b,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xs\n        .clone()\n        .take(20)\n        .map(|bs| bool_slice_to_string(&bs))\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(bs, freq)| (bool_slice_to_string(&bs), freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.take(1000000));\n    let median_lo = bool_slice_to_string(&median_lo);\n    let median_hi = median_hi.map(|bs| bool_slice_to_string(&bs));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_bool_vecs_length_range() {\n    striped_random_bool_vecs_length_range_helper(\n        3,\n        10,\n        2,\n        1,\n        &[\n            \"00110011\",\n            \"01110011\",\n            \"00100110\",\n            \"00010111\",\n            \"001010000\",\n            \"110\",\n            \"0100\",\n            \"1110011\",\n            \"011001011\",\n            \"111000\",\n            \"111110010\",\n            \"0001001\",\n            \"00011110\",\n            \"00000\",\n            \"1110101\",\n            \"0011001\",\n            \"11111\",\n            \"01000010\",\n            \"01001110\",\n            \"10111\",\n        ],\n        &[\n            (\"001\", 18041),\n            (\"110\", 18008),\n            (\"111\", 17919),\n            (\"100\", 17906),\n            (\"011\", 17905),\n            (\"000\", 17819),\n            (\"010\", 17792),\n            (\"101\", 17782),\n            (\"0111\", 9023),\n            (\"1011\", 9023),\n        ],\n        (\"100\", None),\n    );\n    striped_random_bool_vecs_length_range_helper(\n        3,\n        10,\n        10,\n        1,\n        &[\n            \"00000000\",\n            \"00000000\",\n            \"00000111\",\n            \"01111111\",\n            \"000001111\",\n            \"111\",\n            \"0001\",\n            \"1111110\",\n            \"000000000\",\n            \"111000\",\n            \"111111111\",\n            \"0000000\",\n            \"00000000\",\n            \"00000\",\n            \"1110000\",\n            \"0000000\",\n            \"11111\",\n            \"00000000\",\n            \"01111110\",\n            \"11111\",\n        ],\n        &[\n            (\"000\", 58009),\n            (\"111\", 57974),\n            (\"1111\", 52110),\n            (\"0000\", 51905),\n            (\"00000\", 47047),\n            (\"11111\", 46660),\n            (\"111111\", 42411),\n            (\"000000\", 41880),\n            (\"0000000\", 38018),\n            (\"1111111\", 37708),\n        ],\n        (\"100\", None),\n    );\n    striped_random_bool_vecs_length_range_helper(\n        3,\n        10,\n        11,\n        10,\n        &[\n            \"01011010\",\n            \"01010101\",\n            \"00101011\",\n            \"01010101\",\n            \"001010010\",\n            \"101\",\n            \"0010\",\n            \"1010101\",\n            \"010101010\",\n            \"101010\",\n            \"100101011\",\n            \"0101010\",\n            \"01010101\",\n            \"01001\",\n            \"1101011\",\n            \"0101010\",\n            \"10101\",\n            \"01010101\",\n            \"01010101\",\n            \"10101\",\n        ],\n        &[\n            (\"010\", 59241),\n            (\"101\", 59092),\n            (\"1010\", 53578),\n            (\"0101\", 53360),\n            (\"01010\", 48685),\n            (\"10101\", 48527),\n            (\"010101\", 44471),\n            (\"101010\", 44350),\n            (\"0101010\", 40536),\n            (\"1010101\", 40115),\n        ],\n        (\"100\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_length_range_fail_1() {\n    striped_random_bool_vecs_length_range(EXAMPLE_SEED, 3, 10, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_length_range_fail_2() {\n    striped_random_bool_vecs_length_range(EXAMPLE_SEED, 3, 10, 2, 3);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_length_range_fail_3() {\n    striped_random_bool_vecs_length_range(EXAMPLE_SEED, 1, 1, 4, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_bool_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::striped::get_striped_bool_vec::bool_slice_to_string;\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::striped_random_bool_vecs_min_length;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_bool_vecs_min_length_helper(\n    min_length: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let xs = striped_random_bool_vecs_min_length(\n        EXAMPLE_SEED,\n        min_length,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xs\n        .clone()\n        .take(20)\n        .map(|bs| bool_slice_to_string(&bs))\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(bs, freq)| (bool_slice_to_string(&bs), freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.take(1000000));\n    let median_lo = bool_slice_to_string(&median_lo);\n    let median_hi = median_hi.map(|bs| bool_slice_to_string(&bs));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_bool_vecs_min_length() {\n    striped_random_bool_vecs_min_length_helper(\n        0,\n        2,\n        1,\n        4,\n        1,\n        &[\n            \"\",\n            \"00110011000110\",\n            \"0001\",\n            \"0110\",\n            \"0\",\n            \"\",\n            \"00111\",\n            \"10\",\n            \"0100\",\n            \"\",\n            \"111010\",\n            \"\",\n            \"\",\n            \"01111101000\",\n            \"11001100\",\n            \"\",\n            \"100\",\n            \"\",\n            \"01011\",\n            \"000111111\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"1\", 80247),\n            (\"0\", 79926),\n            (\"10\", 32241),\n            (\"00\", 32110),\n            (\"11\", 31988),\n            (\"01\", 31834),\n            (\"001\", 12991),\n            (\"111\", 12989),\n            (\"010\", 12807),\n        ],\n        (\"0100011111011\", None),\n    );\n    striped_random_bool_vecs_min_length_helper(\n        3,\n        10,\n        1,\n        4,\n        1,\n        &[\n            \"0000\", \"00000\", \"00000\", \"00000\", \"0000\", \"10001\", \"000\", \"111\", \"0000\", \"111\", \"110\",\n            \"000\", \"0000\", \"0001111\", \"111\", \"01111\", \"111\", \"00000011\", \"0000\", \"1111\",\n        ],\n        &[\n            (\"000\", 202463),\n            (\"111\", 202257),\n            (\"0000\", 91181),\n            (\"1111\", 91085),\n            (\"00000\", 41060),\n            (\"11111\", 41041),\n            (\"100\", 22693),\n            (\"110\", 22484),\n            (\"001\", 22434),\n            (\"011\", 22270),\n        ],\n        (\"100\", None),\n    );\n    striped_random_bool_vecs_min_length_helper(\n        0,\n        11,\n        10,\n        4,\n        1,\n        &[\n            \"\",\n            \"01011010101010\",\n            \"0110\",\n            \"0101\",\n            \"0\",\n            \"\",\n            \"01101\",\n            \"10\",\n            \"0101\",\n            \"\",\n            \"100101\",\n            \"\",\n            \"\",\n            \"01101011010\",\n            \"10101010\",\n            \"\",\n            \"101\",\n            \"\",\n            \"01010\",\n            \"010101001\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"1\", 80247),\n            (\"0\", 79926),\n            (\"10\", 58377),\n            (\"01\", 58287),\n            (\"010\", 42404),\n            (\"101\", 42353),\n            (\"1010\", 30704),\n            (\"0101\", 30613),\n            (\"10101\", 22466),\n        ],\n        (\"010101\", None),\n    );\n    striped_random_bool_vecs_min_length_helper(\n        3,\n        2,\n        1,\n        10,\n        1,\n        &[\n            \"00110011\",\n            \"01110011101100111010000101\",\n            \"011111010000\",\n            \"01100110010\",\n            \"0111\",\n            \"110\",\n            \"000000011\",\n            \"101110\",\n            \"011000111100000\",\n            \"111\",\n            \"101011001100\",\n            \"0000\",\n            \"010\",\n            \"000010100111010000011\",\n            \"1110010011010111\",\n            \"010\",\n            \"11100100\",\n            \"010\",\n            \"010111100101\",\n            \"10000010011001110111111110100\",\n        ],\n        &[\n            (\"011\", 15722),\n            (\"101\", 15676),\n            (\"110\", 15638),\n            (\"100\", 15613),\n            (\"010\", 15610),\n            (\"111\", 15603),\n            (\"000\", 15516),\n            (\"001\", 15471),\n            (\"0110\", 7099),\n            (\"1010\", 6906),\n        ],\n        (\"100\", None),\n    );\n    striped_random_bool_vecs_min_length_helper(\n        0,\n        10,\n        1,\n        10,\n        1,\n        &[\n            \"0000000000000000000111000000\",\n            \"000000111111110000\",\n            \"0001111111111100000\",\n            \"000\",\n            \"000000000000\",\n            \"1\",\n            \"00000000000001111111111111111\",\n            \"11111\",\n            \"00\",\n            \"10000001111\",\n            \"111111111101111111111111000000\",\n            \"00000\",\n            \"0000\",\n            \"00000000\",\n            \"11000011111\",\n            \"0001\",\n            \"111111111\",\n            \"000000000\",\n            \"0000000001100111111111111\",\n            \"1\",\n        ],\n        &[\n            (\"\", 90709),\n            (\"0\", 41449),\n            (\"1\", 41338),\n            (\"00\", 33629),\n            (\"11\", 33603),\n            (\"111\", 27832),\n            (\"000\", 27669),\n            (\"1111\", 22666),\n            (\"0000\", 22522),\n            (\"11111\", 18708),\n        ],\n        (\n            \"00111111111110000000000011111000000001\",\n            Some(\"001111111111100000000000111110011111\"),\n        ),\n    );\n    striped_random_bool_vecs_min_length_helper(\n        3,\n        11,\n        10,\n        10,\n        1,\n        &[\n            \"01011010\",\n            \"01010101101010010101011010\",\n            \"011010110101\",\n            \"01010101010\",\n            \"0101\",\n            \"101\",\n            \"010110101\",\n            \"100101\",\n            \"010101010101001\",\n            \"110\",\n            \"101001010101\",\n            \"0101\",\n            \"010\",\n            \"010101010101010101101\",\n            \"1010110101001010\",\n            \"010\",\n            \"10110101\",\n            \"010\",\n            \"010101010101\",\n            \"10101001010101010100101011010\",\n        ],\n        &[\n            (\"101\", 51809),\n            (\"010\", 51385),\n            (\"0101\", 41252),\n            (\"1010\", 40909),\n            (\"01010\", 33103),\n            (\"10101\", 32685),\n            (\"101010\", 25995),\n            (\"010101\", 25896),\n            (\"0101010\", 20699),\n            (\"1010101\", 20622),\n        ],\n        (\"100\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_min_length_fail_1() {\n    striped_random_bool_vecs_min_length(EXAMPLE_SEED, 3, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_min_length_fail_2() {\n    striped_random_bool_vecs_min_length(EXAMPLE_SEED, 3, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_min_length_fail_3() {\n    striped_random_bool_vecs_min_length(EXAMPLE_SEED, 3, 4, 1, 3, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_min_length_fail_4() {\n    striped_random_bool_vecs_min_length(EXAMPLE_SEED, 1, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_bool_vecs_min_length_fail_5() {\n    striped_random_bool_vecs_min_length(EXAMPLE_SEED, 0, 4, 1, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_fixed_length_bool_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::num::random::striped::get_striped_bool_vec::bool_slice_to_string;\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::striped_random_fixed_length_bool_vecs;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_fixed_length_bool_vecs_helper(\n    len: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let xs = striped_random_fixed_length_bool_vecs(\n        EXAMPLE_SEED,\n        len,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xs\n        .clone()\n        .take(20)\n        .map(|bs| bool_slice_to_string(&bs))\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(bs, freq)| (bool_slice_to_string(&bs), freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.take(1000000));\n    let median_lo = bool_slice_to_string(&median_lo);\n    let median_hi = median_hi.map(|bs| bool_slice_to_string(&bs));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_fixed_length_bool_vecs() {\n    striped_random_fixed_length_bool_vecs_helper(0, 10, 1, &[\"\"; 20], &[(\"\", 1000000)], (\"\", None));\n    striped_random_fixed_length_bool_vecs_helper(\n        1,\n        10,\n        1,\n        &[\n            \"0\", \"0\", \"0\", \"0\", \"0\", \"1\", \"0\", \"1\", \"0\", \"1\", \"1\", \"0\", \"0\", \"0\", \"1\", \"0\", \"1\",\n            \"0\", \"0\", \"1\",\n        ],\n        &[(\"1\", 500079), (\"0\", 499921)],\n        (\"1\", None),\n    );\n    striped_random_fixed_length_bool_vecs_helper(\n        2,\n        10,\n        1,\n        &[\n            \"00\", \"00\", \"00\", \"00\", \"00\", \"11\", \"00\", \"11\", \"00\", \"11\", \"11\", \"00\", \"00\", \"00\",\n            \"11\", \"00\", \"11\", \"00\", \"01\", \"11\",\n        ],\n        &[(\"11\", 449989), (\"00\", 449537), (\"01\", 50384), (\"10\", 50090)],\n        (\"10\", None),\n    );\n    striped_random_fixed_length_bool_vecs_helper(\n        5,\n        10,\n        1,\n        &[\n            \"00000\", \"00000\", \"00000\", \"00000\", \"00011\", \"11000\", \"00000\", \"11111\", \"01111\",\n            \"11111\", \"10000\", \"00011\", \"00000\", \"00000\", \"11000\", \"00000\", \"11111\", \"00000\",\n            \"00000\", \"11111\",\n        ],\n        &[\n            (\"11111\", 328176),\n            (\"00000\", 327532),\n            (\"00001\", 36685),\n            (\"10000\", 36616),\n            (\"00111\", 36602),\n            (\"01111\", 36495),\n            (\"11110\", 36487),\n            (\"11000\", 36446),\n            (\"00011\", 36354),\n            (\"11100\", 36250),\n        ],\n        (\"10000\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_fixed_length_bool_vecs_fail_1() {\n    striped_random_fixed_length_bool_vecs(EXAMPLE_SEED, 5, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_fixed_length_bool_vecs_fail_2() {\n    striped_random_fixed_length_bool_vecs(EXAMPLE_SEED, 5, 2, 3);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_fixed_length_unsigned_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::striped::striped_random_fixed_length_unsigned_vecs;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_fixed_length_unsigned_vecs_helper<T: PrimitiveUnsigned>(\n    len: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&[&str]],\n    expected_common_values: &[(&[&str], usize)],\n    expected_median: (&[&str], Option<&[&str]>),\n) {\n    let xss = striped_random_fixed_length_unsigned_vecs::<T>(\n        EXAMPLE_SEED,\n        len,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xss\n        .clone()\n        .take(20)\n        .map(|xs| {\n            xs.into_iter()\n                .map(|x: T| x.to_binary_string())\n                .collect_vec()\n        })\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xss.clone())\n        .into_iter()\n        .map(|(xs, freq)| {\n            (\n                xs.into_iter()\n                    .map(|x: T| x.to_binary_string())\n                    .collect_vec(),\n                freq,\n            )\n        })\n        .collect_vec();\n    let (median_lo, median_hi) = median(xss.take(1000000));\n    let median_lo = median_lo\n        .into_iter()\n        .map(|x: T| x.to_binary_string())\n        .collect_vec();\n    let median_hi = median_hi.map(|xs| {\n        xs.into_iter()\n            .map(|x: T| x.to_binary_string())\n            .collect_vec()\n    });\n\n    let values = values\n        .iter()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec())\n        .collect_vec();\n    let common_values = common_values\n        .iter()\n        .map(|(xs, freq)| (xs.iter().map(String::as_str).collect_vec(), *freq))\n        .collect_vec();\n    let median_lo = median_lo.iter().map(String::as_str).collect_vec();\n    let median_hi = median_hi\n        .as_ref()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec());\n    assert_eq!(\n        (\n            values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(xs, f)| (xs.as_slice(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_slice(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_fixed_length_unsigned_vecs() {\n    striped_random_fixed_length_unsigned_vecs_helper::<u8>(\n        0,\n        10,\n        1,\n        &[&[][..]; 20],\n        &[(&[], 1000000)],\n        (&[], None),\n    );\n    striped_random_fixed_length_unsigned_vecs_helper::<u8>(\n        1,\n        10,\n        1,\n        &[\n            &[\"0\"],\n            &[\"0\"],\n            &[\"11100000\"],\n            &[\"11111110\"],\n            &[\"11100000\"],\n            &[\"111111\"],\n            &[\"11100000\"],\n            &[\"11111111\"],\n            &[\"11111100\"],\n            &[\"11111111\"],\n            &[\"11111111\"],\n            &[\"0\"],\n            &[\"11110000\"],\n            &[\"0\"],\n            &[\"11111111\"],\n            &[\"11110000\"],\n            &[\"111\"],\n            &[\"0\"],\n            &[\"100\"],\n            &[\"11111111\"],\n        ],\n        &[\n            (&[\"0\"], 238932),\n            (&[\"11111111\"], 238695),\n            (&[\"11100000\"], 26922),\n            (&[\"1111111\"], 26791),\n            (&[\"11000000\"], 26775),\n            (&[\"11\"], 26754),\n            (&[\"111\"], 26726),\n            (&[\"11110000\"], 26662),\n            (&[\"11111\"], 26607),\n            (&[\"1111\"], 26594),\n        ],\n        (&[\"1111111\"], None),\n    );\n    striped_random_fixed_length_unsigned_vecs_helper::<u8>(\n        2,\n        10,\n        1,\n        &[\n            &[\"0\", \"0\"],\n            &[\"1110000\", \"0\"],\n            &[\"11111000\", \"111\"],\n            &[\"11111100\", \"11111\"],\n            &[\"0\", \"0\"],\n            &[\"11111111\", \"11111\"],\n            &[\"0\", \"0\"],\n            &[\"1111\", \"11111100\"],\n            &[\"0\", \"1\"],\n            &[\"1111111\", \"0\"],\n            &[\"11111111\", \"11111\"],\n            &[\"11111100\", \"1\"],\n            &[\"0\", \"0\"],\n            &[\"110000\", \"11111111\"],\n            &[\"11111\", \"0\"],\n            &[\"0\", \"0\"],\n            &[\"11111111\", \"11111111\"],\n            &[\"0\", \"0\"],\n            &[\"1000\", \"0\"],\n            &[\"11111111\", \"11111111\"],\n        ],\n        &[\n            (&[\"0\", \"0\"], 103184),\n            (&[\"11111111\", \"11111111\"], 102963),\n            (&[\"0\", \"11111111\"], 11776),\n            (&[\"11111000\", \"11111111\"], 11585),\n            (&[\"0\", \"11111110\"], 11579),\n            (&[\"11111110\", \"11111111\"], 11542),\n            (&[\"11000000\", \"11111111\"], 11499),\n            (&[\"1111\", \"0\"], 11487),\n            (&[\"11111111\", \"1111111\"], 11483),\n            (&[\"11111111\", \"1\"], 11459),\n        ],\n        (&[\"1111111\", \"11111111\"], None),\n    );\n    striped_random_fixed_length_unsigned_vecs_helper::<u8>(\n        5,\n        10,\n        1,\n        &[\n            &[\"0\", \"0\", \"111000\", \"0\", \"11111110\"],\n            &[\"11111100\", \"0\", \"11111000\", \"11111111\", \"11111111\"],\n            &[\"0\", \"11111100\", \"11111111\", \"1111111\", \"11100000\"],\n            &[\"0\", \"1000\", \"0\", \"11111110\", \"11111111\"],\n            &[\"10000000\", \"111\", \"11111100\", \"11111111\", \"11111111\"],\n            &[\"11001111\", \"0\", \"11110000\", \"11111111\", \"11111111\"],\n            &[\"0\", \"0\", \"0\", \"0\", \"10000000\"],\n            &[\"1\", \"0\", \"0\", \"11100000\", \"11111111\"],\n            &[\"0\", \"0\", \"0\", \"0\", \"11111100\"],\n            &[\"1110111\", \"0\", \"11110000\", \"1110\", \"11010000\"],\n            &[\"1111101\", \"11111111\", \"11111111\", \"11111111\", \"111111\"],\n            &[\"0\", \"1111\", \"100000\", \"11111111\", \"11\"],\n            &[\"10000000\", \"11111111\", \"11101111\", \"11111111\", \"11111111\"],\n            &[\"11111100\", \"111111\", \"0\", \"0\", \"1111\"],\n            &[\"11111111\", \"1\", \"11111111\", \"11111111\", \"11111\"],\n            &[\"0\", \"11100000\", \"11111111\", \"1\", \"1100\"],\n            &[\"11111111\", \"1110111\", \"0\", \"11111100\", \"1\"],\n            &[\"11111110\", \"111\", \"0\", \"0\", \"0\"],\n            &[\"11110000\", \"11\", \"10000000\", \"11111111\", \"11000011\"],\n            &[\"1\", \"10000000\", \"11111111\", \"11111111\", \"111\"],\n        ],\n        &[\n            (&[\"0\", \"0\", \"0\", \"0\", \"0\"], 8118),\n            (\n                &[\"11111111\", \"11111111\", \"11111111\", \"11111111\", \"11111111\"],\n                8057,\n            ),\n            (&[\"0\", \"11000000\", \"11111111\", \"11111111\", \"11111111\"], 972),\n            (&[\"11111111\", \"11111111\", \"11111111\", \"111\", \"0\"], 961),\n            (&[\"11111111\", \"11111111\", \"11111111\", \"11111\", \"0\"], 955),\n            (\n                &[\"11111100\", \"11111111\", \"11111111\", \"11111111\", \"11111111\"],\n                948,\n            ),\n            (&[\"0\", \"0\", \"0\", \"0\", \"11111110\"], 947),\n            (&[\"0\", \"0\", \"10000000\", \"11111111\", \"11111111\"], 946),\n            (&[\"11111111\", \"1111\", \"0\", \"0\", \"0\"], 944),\n            (&[\"0\", \"0\", \"0\", \"11111111\", \"11111111\"], 944),\n        ],\n        (\n            &[\"1111111\", \"11111111\", \"11111111\", \"10000001\", \"11111100\"],\n            Some(&[\"1111111\", \"11111111\", \"11111111\", \"10000001\", \"11111111\"]),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_fixed_length_unsigned_vecs_fail_1() {\n    striped_random_fixed_length_unsigned_vecs::<u8>(EXAMPLE_SEED, 5, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_fixed_length_unsigned_vecs_fail_2() {\n    striped_random_fixed_length_unsigned_vecs::<u8>(EXAMPLE_SEED, 5, 2, 3);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_natural_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_natural_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_natural_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_natural_signeds::<T>(EXAMPLE_SEED, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_natural_signeds() {\n    // i8, m = 4\n    let values = &[\n        \"0\", \"101100\", \"110000\", \"1111100\", \"1111\", \"1111110\", \"0\", \"111\", \"11101\", \"1100000\",\n        \"1111111\", \"1100000\", \"0\", \"10\", \"1000011\", \"111111\", \"1\", \"0\", \"1111\", \"1\",\n    ];\n    let common_values = &[\n        (\"0\", 89042),\n        (\"1111111\", 88624),\n        (\"11111\", 29871),\n        (\"1111000\", 29848),\n        (\"1000000\", 29802),\n        (\"1111110\", 29796),\n        (\"1100000\", 29664),\n        (\"1110000\", 29649),\n        (\"111\", 29644),\n        (\"111111\", 29621),\n    ];\n    let sample_median = (64, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.526448000001764),\n        standard_deviation: NiceFloat(47.66137677522695),\n        skewness: NiceFloat(-0.0011056592983105758),\n        excess_kurtosis: NiceFloat(-1.5649370173869874),\n    };\n    striped_random_natural_signeds_helper::<i8>(\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 2\n    let values = &[\n        \"11001\", \"11100\", \"101010\", \"1001011\", \"101101\", \"1111100\", \"111100\", \"10100\", \"1101\",\n        \"1111111\", \"1100011\", \"1101101\", \"1100\", \"100\", \"1100001\", \"100011\", \"110100\", \"110101\",\n        \"110100\", \"10011\",\n    ];\n    let common_values = &[\n        (\"11010\", 8131),\n        (\"1111\", 8059),\n        (\"1010101\", 8004),\n        (\"1001101\", 7998),\n        (\"11011\", 7993),\n        (\"1110111\", 7978),\n        (\"1010100\", 7959),\n        (\"111\", 7958),\n        (\"1011010\", 7953),\n        (\"1100011\", 7947),\n    ];\n    let sample_median = (64, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.555225000001755),\n        standard_deviation: NiceFloat(36.938359582441294),\n        skewness: NiceFloat(-0.0007106807748730345),\n        excess_kurtosis: NiceFloat(-1.2008391146615376),\n    };\n    striped_random_natural_signeds_helper::<i8>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 5/4\n    let values = &[\n        \"101001\", \"100101\", \"100110\", \"1101001\", \"101101\", \"1010101\", \"111010\", \"101010\", \"10110\",\n        \"1010101\", \"1001000\", \"1001011\", \"1000\", \"11100\", \"1111010\", \"101101\", \"110101\", \"101010\",\n        \"100101\", \"100010\",\n    ];\n    let common_values = &[\n        (\"101010\", 131212),\n        (\"1010101\", 131202),\n        (\"1001010\", 33119),\n        (\"1011010\", 33073),\n        (\"10101\", 32947),\n        (\"100101\", 32868),\n        (\"1010010\", 32851),\n        (\"101011\", 32817),\n        (\"101001\", 32765),\n        (\"110101\", 32761),\n    ];\n    let sample_median = (65, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.51375499999882),\n        standard_deviation: NiceFloat(27.10334306669828),\n        skewness: NiceFloat(-0.0017292127163026868),\n        excess_kurtosis: NiceFloat(-1.1007498380278757),\n    };\n    striped_random_natural_signeds_helper::<i8>(\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 32\n    let values = &[\n        \"11111111111111111111111111111\",\n        \"111111111111111111111111111111111111111111111111111111111\",\n        \"1111111111111111111111111111\",\n        \"111111111111111111111111110000000000000000000000000000000000000\",\n        \"111111111111111111111111111111111111111111111111111111111\",\n        \"111111111000000000000000000000000000000000000001100000000111111\",\n        \"11111111111111100000\",\n        \"11111111111111111\",\n        \"111111111111\",\n        \"111111111111111111111111111111111111111111111111111100000000000\",\n        \"111111111111100000000000000000000000000000000000000000000000000\",\n        \"111111111000000000000000000000000000000000000000000000000000000\",\n        \"1111111111111111111111111111100000000000000\",\n        \"1000000011111111111111111111\",\n        \"111111000000000000000111111111111111111111111111111111111111111\",\n        \"0\",\n        \"11111111111100000000000000000000000000000000000000\",\n        \"111111111111111111111110000000000000000001111111\",\n        \"1111111111111111111111111111111111111111111111111111111111111\",\n        \"1111111\",\n    ];\n    let common_values = &[\n        (\n            \"111111111111111111111111111111111111111111111111111111111111111\",\n            69948,\n        ),\n        (\"0\", 69809),\n        (\n            \"111111111111111111111111111111111111111111111111111111111111000\",\n            2383,\n        ),\n        (\n            \"11111111111111111111111111111111111111111111111111111111111\",\n            2362,\n        ),\n        (\"11111111111111111111111\", 2334),\n        (\n            \"111111111111111100000000000000000000000000000000000000000000000\",\n            2334,\n        ),\n        (\n            \"100000000000000000000000000000000000000000000000000000000000000\",\n            2328,\n        ),\n        (\n            \"111111111111111111111111111111100000000000000000000000000000000\",\n            2327,\n        ),\n        (\"111111111\", 2320),\n        (\"11\", 2318),\n    ];\n    let sample_median = (4611686018427387904, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.614976015729421e18),\n        standard_deviation: NiceFloat(4.4270184647985137e18),\n        skewness: NiceFloat(-0.0014267894129673844),\n        excess_kurtosis: NiceFloat(-1.9430528242638783),\n    };\n    striped_random_natural_signeds_helper::<i64>(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 2\n    let values = &[\n        \"1100110001101010100101101001000001100001110101111001000000001\",\n        \"111011011100111110111000010111001101001101010010111011001100\",\n        \"11110000010100111000110001101100111001001010101110001000100000\",\n        \"110010001100111101011100111111100001001110001100001001000000011\",\n        \"1100110011001011000001001111001010100010110100011010010001\",\n        \"111000101110010000110100101010100100111001100100001101010011011\",\n        \"10000011110001100010001010101101101100100000010011101111010\",\n        \"1110110110110011010011011010000111001101110110010001101011110\",\n        \"11010010000001101100111000010011100101110010101101001100110000\",\n        \"110000010001000110001011100111001101110010001111000110001111001\",\n        \"100011101111011001001101101011100000110001110100111011011011111\",\n        \"111101111100000110000001010001001101011110011110110100010110010\",\n        \"1010001010011101001011011111100101110000001010101000111100001\",\n        \"11110011011100110101011110010001110100010111001010000100011101\",\n        \"110001001100111101011111000100111101011110111101110011010100111\",\n        \"1111011101101101011111011010011011001011010001101011100101\",\n        \"11111101110101010010000100011110100110100000110100101000110111\",\n        \"10101011010100000101011100111011000001101010001000101111111010\",\n        \"110000111110001111000001110011101110100001101011111010100110\",\n        \"1101010111111111000111001111000111110001111110100101000001111\",\n    ];\n    let common_values = &[\n        (\"10101000110110101100110011001101011011101\", 1),\n        (\"1110100010100111110111100000011111000010100\", 1),\n        (\"10011111100110010100000010001100001001111011\", 1),\n        (\"10111110110011101010110111100010100101101100\", 1),\n        (\"110101001100100110010011010000011100100111011\", 1),\n        (\"1001000111011010110011001111101001111101110011\", 1),\n        (\"1010101100111011110111011011011100011101010101\", 1),\n        (\"1100110000110110000100011110000110101010110010\", 1),\n        (\"1100110011000110101101111111111110111011101001\", 1),\n        (\"1101011001000111111110011010000001001001000110\", 1),\n    ];\n    let sample_median = (4616064909372870741, Some(4616067528870766644));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.614689648935556e18),\n        standard_deviation: NiceFloat(2.6622250799886193e18),\n        skewness: NiceFloat(-0.0006757801147527129),\n        excess_kurtosis: NiceFloat(-1.199752325803772),\n    };\n    striped_random_natural_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 33/32\n    let values = &[\n        \"10101010101010101010101101010101010101010101010101010101010101\",\n        \"10101010101010100010101010010101101010101010101011010101011010\",\n        \"10101010010101011010101010101010101101010101010101010101010101\",\n        \"101010101010101010101101010101010101010101010101010101010101010\",\n        \"10101010101010101010101011010101010101001010010101001010101010\",\n        \"101010101010101010101010101010101010100101010010101010110101010\",\n        \"10101010101010101010101010101010101010101010101010110101010101\",\n        \"10101010101010101010010101010101010101010101010101010101010101\",\n        \"10101010010101010101010101010101010101010101010101010101010101\",\n        \"101010101100101010101010101010101010101010101010101010010101010\",\n        \"101010101010101010101010101010101011001010101010101101010101010\",\n        \"101101010101010011010101010101010101010101010101010101010101010\",\n        \"10101001010101010101011010101010101010101010101010101010101010\",\n        \"10101010101010101011010010010110101010101010101010101010101010\",\n        \"101010101010101010110101010101010101010101010010101010101010101\",\n        \"10101010101010101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101010101010101010101010101011010101010101\",\n        \"10101010101010101010101010101010101010101101010101010101010101\",\n        \"10101010101010101011011010100101010101001010101010101010101010\",\n        \"10101010101010101010101010101011010101010101010101010101010101\",\n    ];\n    let common_values = &[\n        (\n            \"101010101010101010101010101010101010101010101010101010101010101\",\n            74299,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010101010\",\n            74072,\n        ),\n        (\n            \"101010101010101010101010010101010101010101010101010101010101010\",\n            2429,\n        ),\n        (\n            \"101010101010101010101010101010101010101010101010101010101011010\",\n            2419,\n        ),\n        (\n            \"101010101011010101010101010101010101010101010101010101010101010\",\n            2419,\n        ),\n        (\n            \"101010101010101010101001010101010101010101010101010101010101010\",\n            2411,\n        ),\n        (\n            \"101010101010101010101010101010101010101010101010010101010101010\",\n            2393,\n        ),\n        (\n            \"101010101001010101010101010101010101010101010101010101010101010\",\n            2390,\n        ),\n        (\n            \"10101010101010101010101010101001010101010101010101010101010101\",\n            2389,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010100101\",\n            2389,\n        ),\n    ];\n    let sample_median = (5281221163029801642, Some(5281221163029804373));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.613154278246113e18),\n        standard_deviation: NiceFloat(1.599140542162029e18),\n        skewness: NiceFloat(-0.0019511120341977268),\n        excess_kurtosis: NiceFloat(-1.7372862317601716),\n    };\n    striped_random_natural_signeds_helper::<i64>(\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_natural_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(striped_random_natural_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(striped_random_natural_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn striped_random_natural_signeds_fail() {\n    apply_fn_to_signeds!(striped_random_natural_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_negative_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_negative_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_negative_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_negative_signeds::<T>(EXAMPLE_SEED, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_negative_signeds() {\n    // i8, m = 4\n    let values = &[\n        \"10000000\", \"10101100\", \"10110000\", \"11111100\", \"10001111\", \"11111110\", \"10000000\",\n        \"10000111\", \"10011101\", \"11100000\", \"11111111\", \"11100000\", \"10000000\", \"10000010\",\n        \"11000011\", \"10111111\", \"10000001\", \"10000000\", \"10001111\", \"10000001\",\n    ];\n    let common_values = &[\n        (\"10000000\", 89042),\n        (\"11111111\", 88624),\n        (\"10011111\", 29871),\n        (\"11111000\", 29848),\n        (\"11000000\", 29802),\n        (\"11111110\", 29796),\n        (\"11100000\", 29664),\n        (\"11110000\", 29649),\n        (\"10000111\", 29644),\n        (\"10111111\", 29621),\n    ];\n    let sample_median = (-64, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-64.47355199999896),\n        standard_deviation: NiceFloat(47.66137677522698),\n        skewness: NiceFloat(-0.0011056592983105659),\n        excess_kurtosis: NiceFloat(-1.5649370173869896),\n    };\n    striped_random_negative_signeds_helper::<i8>(\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 2\n    let values = &[\n        \"10011001\", \"10011100\", \"10101010\", \"11001011\", \"10101101\", \"11111100\", \"10111100\",\n        \"10010100\", \"10001101\", \"11111111\", \"11100011\", \"11101101\", \"10001100\", \"10000100\",\n        \"11100001\", \"10100011\", \"10110100\", \"10110101\", \"10110100\", \"10010011\",\n    ];\n    let common_values = &[\n        (\"10011010\", 8131),\n        (\"10001111\", 8059),\n        (\"11010101\", 8004),\n        (\"11001101\", 7998),\n        (\"10011011\", 7993),\n        (\"11110111\", 7978),\n        (\"11010100\", 7959),\n        (\"10000111\", 7958),\n        (\"11011010\", 7953),\n        (\"11100011\", 7947),\n    ];\n    let sample_median = (-64, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-64.44477500000217),\n        standard_deviation: NiceFloat(36.93835958244133),\n        skewness: NiceFloat(-0.0007106807748731826),\n        excess_kurtosis: NiceFloat(-1.2008391146615451),\n    };\n    striped_random_negative_signeds_helper::<i8>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 5/4\n    let values = &[\n        \"10101001\", \"10100101\", \"10100110\", \"11101001\", \"10101101\", \"11010101\", \"10111010\",\n        \"10101010\", \"10010110\", \"11010101\", \"11001000\", \"11001011\", \"10001000\", \"10011100\",\n        \"11111010\", \"10101101\", \"10110101\", \"10101010\", \"10100101\", \"10100010\",\n    ];\n    let common_values = &[\n        (\"10101010\", 131212),\n        (\"11010101\", 131202),\n        (\"11001010\", 33119),\n        (\"11011010\", 33073),\n        (\"10010101\", 32947),\n        (\"10100101\", 32868),\n        (\"11010010\", 32851),\n        (\"10101011\", 32817),\n        (\"10101001\", 32765),\n        (\"10110101\", 32761),\n    ];\n    let sample_median = (-63, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-64.48624499999755),\n        standard_deviation: NiceFloat(27.103343066698287),\n        skewness: NiceFloat(-0.0017292127163029483),\n        excess_kurtosis: NiceFloat(-1.1007498380278833),\n    };\n    striped_random_negative_signeds_helper::<i8>(\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 32\n    let values = &[\n        \"1000000000000000000000000000000000011111111111111111111111111111\",\n        \"1000000111111111111111111111111111111111111111111111111111111111\",\n        \"1000000000000000000000000000000000001111111111111111111111111111\",\n        \"1111111111111111111111111110000000000000000000000000000000000000\",\n        \"1000000111111111111111111111111111111111111111111111111111111111\",\n        \"1111111111000000000000000000000000000000000000001100000000111111\",\n        \"1000000000000000000000000000000000000000000011111111111111100000\",\n        \"1000000000000000000000000000000000000000000000011111111111111111\",\n        \"1000000000000000000000000000000000000000000000000000111111111111\",\n        \"1111111111111111111111111111111111111111111111111111100000000000\",\n        \"1111111111111100000000000000000000000000000000000000000000000000\",\n        \"1111111111000000000000000000000000000000000000000000000000000000\",\n        \"1000000000000000000001111111111111111111111111111100000000000000\",\n        \"1000000000000000000000000000000000001000000011111111111111111111\",\n        \"1111111000000000000000111111111111111111111111111111111111111111\",\n        \"1000000000000000000000000000000000000000000000000000000000000000\",\n        \"1000000000000011111111111100000000000000000000000000000000000000\",\n        \"1000000000000000111111111111111111111110000000000000000001111111\",\n        \"1001111111111111111111111111111111111111111111111111111111111111\",\n        \"1000000000000000000000000000000000000000000000000000000001111111\",\n    ];\n    let common_values = &[\n        (\n            \"1111111111111111111111111111111111111111111111111111111111111111\",\n            69948,\n        ),\n        (\n            \"1000000000000000000000000000000000000000000000000000000000000000\",\n            69809,\n        ),\n        (\n            \"1111111111111111111111111111111111111111111111111111111111111000\",\n            2383,\n        ),\n        (\n            \"1000011111111111111111111111111111111111111111111111111111111111\",\n            2362,\n        ),\n        (\n            \"1111111111111111100000000000000000000000000000000000000000000000\",\n            2334,\n        ),\n        (\n            \"1000000000000000000000000000000000000000011111111111111111111111\",\n            2334,\n        ),\n        (\n            \"1100000000000000000000000000000000000000000000000000000000000000\",\n            2328,\n        ),\n        (\n            \"1111111111111111111111111111111100000000000000000000000000000000\",\n            2327,\n        ),\n        (\n            \"1000000000000000000000000000000000000000000000000000000111111111\",\n            2320,\n        ),\n        (\n            \"1000000000000000000000000000000000000000000000000000000000000011\",\n            2318,\n        ),\n    ];\n    let sample_median = (-4611686018427387904, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.608396021125303e18),\n        standard_deviation: NiceFloat(4.4270184647985106e18),\n        skewness: NiceFloat(-0.0014267894129673469),\n        excess_kurtosis: NiceFloat(-1.9430528242638716),\n    };\n    striped_random_negative_signeds_helper::<i64>(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 2\n    let values = &[\n        \"1001100110001101010100101101001000001100001110101111001000000001\",\n        \"1000111011011100111110111000010111001101001101010010111011001100\",\n        \"1011110000010100111000110001101100111001001010101110001000100000\",\n        \"1110010001100111101011100111111100001001110001100001001000000011\",\n        \"1000001100110011001011000001001111001010100010110100011010010001\",\n        \"1111000101110010000110100101010100100111001100100001101010011011\",\n        \"1000010000011110001100010001010101101101100100000010011101111010\",\n        \"1001110110110110011010011011010000111001101110110010001101011110\",\n        \"1011010010000001101100111000010011100101110010101101001100110000\",\n        \"1110000010001000110001011100111001101110010001111000110001111001\",\n        \"1100011101111011001001101101011100000110001110100111011011011111\",\n        \"1111101111100000110000001010001001101011110011110110100010110010\",\n        \"1001010001010011101001011011111100101110000001010101000111100001\",\n        \"1011110011011100110101011110010001110100010111001010000100011101\",\n        \"1110001001100111101011111000100111101011110111101110011010100111\",\n        \"1000001111011101101101011111011010011011001011010001101011100101\",\n        \"1011111101110101010010000100011110100110100000110100101000110111\",\n        \"1010101011010100000101011100111011000001101010001000101111111010\",\n        \"1000110000111110001111000001110011101110100001101011111010100110\",\n        \"1001101010111111111000111001111000111110001111110100101000001111\",\n    ];\n    let common_values = &[\n        (\n            \"1111111111111111111101100100101101000010000101001100011100001011\",\n            1,\n        ),\n        (\n            \"1111111111111111111101010010001100000001111011100011001110010101\",\n            1,\n        ),\n        (\n            \"1111111111111111111101000101011100111011001010001100011011001010\",\n            1,\n        ),\n        (\n            \"1111111111111111111100101001000100000101110101000111010111100101\",\n            1,\n        ),\n        (\n            \"1111111111111111111100000101111010110010101111000000001111000010\",\n            1,\n        ),\n        (\n            \"1111111111111111111010001000001010110110111101111011110111000001\",\n            1,\n        ),\n        (\n            \"1111111111111111110111101001011000111000100110110000000111010011\",\n            1,\n        ),\n        (\n            \"1111111111111111110110001001110101000111010110110110001100010111\",\n            1,\n        ),\n        (\n            \"1111111111111111110101100100101011001110101010101111101001011101\",\n            1,\n        ),\n        (\n            \"1111111111111111101110111110101110101010000001001011010001101111\",\n            1,\n        ),\n    ];\n    let sample_median = (-4607307127481905067, Some(-4607304507984009164));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.6086823879191747e18),\n        standard_deviation: NiceFloat(2.66222507998862e18),\n        skewness: NiceFloat(-0.0006757801147528804),\n        excess_kurtosis: NiceFloat(-1.1997523258037708),\n    };\n    striped_random_negative_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 33/32\n    let values = &[\n        \"1010101010101010101010101101010101010101010101010101010101010101\",\n        \"1010101010101010100010101010010101101010101010101011010101011010\",\n        \"1010101010010101011010101010101010101101010101010101010101010101\",\n        \"1101010101010101010101101010101010101010101010101010101010101010\",\n        \"1010101010101010101010101011010101010101001010010101001010101010\",\n        \"1101010101010101010101010101010101010100101010010101010110101010\",\n        \"1010101010101010101010101010101010101010101010101010110101010101\",\n        \"1010101010101010101010010101010101010101010101010101010101010101\",\n        \"1010101010010101010101010101010101010101010101010101010101010101\",\n        \"1101010101100101010101010101010101010101010101010101010010101010\",\n        \"1101010101010101010101010101010101011001010101010101101010101010\",\n        \"1101101010101010011010101010101010101010101010101010101010101010\",\n        \"1010101001010101010101011010101010101010101010101010101010101010\",\n        \"1010101010101010101011010010010110101010101010101010101010101010\",\n        \"1101010101010101010110101010101010101010101010010101010101010101\",\n        \"1010101010101010101010101010101010101010101010101010101010101010\",\n        \"1010101010101010101010101010101010101010101010101011010101010101\",\n        \"1010101010101010101010101010101010101010101101010101010101010101\",\n        \"1010101010101010101011011010100101010101001010101010101010101010\",\n        \"1010101010101010101010101010101011010101010101010101010101010101\",\n    ];\n    let common_values = &[\n        (\n            \"1101010101010101010101010101010101010101010101010101010101010101\",\n            74299,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010101010\",\n            74072,\n        ),\n        (\n            \"1101010101010101010101010010101010101010101010101010101010101010\",\n            2429,\n        ),\n        (\n            \"1101010101011010101010101010101010101010101010101010101010101010\",\n            2419,\n        ),\n        (\n            \"1101010101010101010101010101010101010101010101010101010101011010\",\n            2419,\n        ),\n        (\n            \"1101010101010101010101001010101010101010101010101010101010101010\",\n            2411,\n        ),\n        (\n            \"1101010101010101010101010101010101010101010101010010101010101010\",\n            2393,\n        ),\n        (\n            \"1101010101001010101010101010101010101010101010101010101010101010\",\n            2390,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010100101\",\n            2389,\n        ),\n        (\n            \"1010101010101010101010101010101001010101010101010101010101010101\",\n            2389,\n        ),\n    ];\n    let sample_median = (-3942150873824974166, Some(-3942150873824971435));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.610217758608903e18),\n        standard_deviation: NiceFloat(1.5991405421620288e18),\n        skewness: NiceFloat(-0.0019511120341977582),\n        excess_kurtosis: NiceFloat(-1.7372862317601778),\n    };\n    striped_random_negative_signeds_helper::<i64>(\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_negative_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(striped_random_negative_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(striped_random_negative_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn striped_random_negative_signeds_fail() {\n    apply_fn_to_signeds!(striped_random_negative_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_nonzero_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_nonzero_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_nonzero_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_nonzero_signeds::<T>(EXAMPLE_SEED, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_nonzero_signeds() {\n    // i8, m = 4\n    let values = &[\n        \"1100001\", \"1000000\", \"1100000\", \"10000111\", \"1111\", \"10000001\", \"1111000\", \"100011\",\n        \"111101\", \"11111100\", \"11111111\", \"11100001\", \"1\", \"101111\", \"10111000\", \"111111\",\n        \"1101100\", \"1111110\", \"111100\", \"1\",\n    ];\n    let common_values = &[\n        (\"1111111\", 46633),\n        (\"11111111\", 46592),\n        (\"10000000\", 46404),\n        (\"11000000\", 15765),\n        (\"11111100\", 15719),\n        (\"10011111\", 15717),\n        (\"111111\", 15661),\n        (\"1111100\", 15658),\n        (\"11111\", 15657),\n        (\"1111\", 15644),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.47311899999999013),\n        standard_deviation: NiceFloat(81.62164912267556),\n        skewness: NiceFloat(0.0008208424524866476),\n        excess_kurtosis: NiceFloat(-1.1132122689325452),\n    };\n    striped_random_nonzero_signeds_helper::<i8>(\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 2\n    let values = &[\n        \"1110111\", \"1000010\", \"1010011\", \"10011100\", \"10110\", \"10000100\", \"1100001\", \"100110\",\n        \"11101\", \"11100110\", \"11100000\", \"11111010\", \"11011\", \"101100\", \"10101011\", \"10110\",\n        \"1011110\", \"1110101\", \"10001\", \"10100\",\n    ];\n    let common_values = &[\n        (\"11010110\", 4078),\n        (\"1100000\", 4059),\n        (\"1100100\", 4058),\n        (\"11000100\", 4050),\n        (\"11100100\", 4049),\n        (\"11101011\", 4048),\n        (\"10011000\", 4048),\n        (\"11111110\", 4044),\n        (\"1010111\", 4040),\n        (\"11110100\", 4039),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5178119999999826),\n        standard_deviation: NiceFloat(74.01861596576973),\n        skewness: NiceFloat(0.000735155416319748),\n        excess_kurtosis: NiceFloat(-1.2058601704389202),\n    };\n    striped_random_nonzero_signeds_helper::<i8>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 5/4\n    let values = &[\n        \"1010100\", \"1001010\", \"1101101\", \"10010101\", \"110101\", \"10101010\", \"1000010\", \"101001\",\n        \"110110\", \"11011101\", \"11011001\", \"11110101\", \"1010\", \"10101\", \"10110101\", \"111010\",\n        \"1101001\", \"1101010\", \"100110\", \"101001\",\n    ];\n    let common_values = &[\n        (\"11010101\", 66214),\n        (\"10101010\", 65618),\n        (\"1010101\", 65486),\n        (\"101010\", 65185),\n        (\"10100101\", 16584),\n        (\"11010010\", 16518),\n        (\"1011010\", 16486),\n        (\"1101010\", 16481),\n        (\"110101\", 16475),\n        (\"10010101\", 16471),\n    ];\n    let sample_median = (-5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5124420000000011),\n        standard_deviation: NiceFloat(69.49222913654884),\n        skewness: NiceFloat(0.0016761512574253166),\n        excess_kurtosis: NiceFloat(-1.4630127076308237),\n    };\n    striped_random_nonzero_signeds_helper::<i8>(\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 32\n    let values = &[\n        \"111000000000000000000000000000001111111111111111111111111111111\",\n        \"111111111111111111111111111111111111111111111111111111111111111\",\n        \"111111111111111111111111111111111100000000000000000000000000011\",\n        \"1000000000000000011111111111111111111111111111111111111111111111\",\n        \"111111111111111111111111111111100000000000000000000000000\",\n        \"1000000000000000000000000000000001111111000000000000000000011111\",\n        \"111111111111111111111000000000000000000011111111111111111111111\",\n        \"111111111111111000000000010000001111111111\",\n        \"1000000000000000\",\n        \"1111111111001111111111111111111111111111111111111111111110000000\",\n        \"1111111111111111111111111111111111111111111111111111111111111111\",\n        \"1100000000000000000000000000000000000000000000000000000000000000\",\n        \"11111111111111111111111111111000000000000000001111111\",\n        \"111111111111111111111111111111111111111111111111111111\",\n        \"1000000000000001111111100000011111111111111111111111111111000000\",\n        \"111111111111111111000\",\n        \"111111110000001000000000000000000000000000000000000000000000000\",\n        \"111111111111111111111111111111111111111100000000000001111111111\",\n        \"111111111111111111111111111111111111111\",\n        \"1111111111111111111111111111111111111111111\",\n    ];\n    let common_values = &[\n        (\n            \"1111111111111111111111111111111111111111111111111111111111111111\",\n            36249,\n        ),\n        (\n            \"1000000000000000000000000000000000000000000000000000000000000000\",\n            35940,\n        ),\n        (\n            \"111111111111111111111111111111111111111111111111111111111111111\",\n            35831,\n        ),\n        (\n            \"111111111111111111111111111111111111111111111111111000000000000\",\n            1244,\n        ),\n        (\n            \"1000000000000000000000000000000000000000111111111111111111111111\",\n            1243,\n        ),\n        (\n            \"111111111111111111100000000000000000000000000000000000000000000\",\n            1236,\n        ),\n        (\n            \"1000000000000000000000000000000000000001111111111111111111111111\",\n            1231,\n        ),\n        (\n            \"111111111111111111111110000000000000000000000000000000000000000\",\n            1229,\n        ),\n        (\n            \"1000000000000000000000000000000111111111111111111111111111111111\",\n            1228,\n        ),\n        (\n            \"1111111111111111111111111111111111000000000000000000000000000000\",\n            1226,\n        ),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4290456766772419.0),\n        standard_deviation: NiceFloat(6.503574909103916e18),\n        skewness: NiceFloat(-0.0008033470716056729),\n        excess_kurtosis: NiceFloat(-1.0564362595467798),\n    };\n    striped_random_nonzero_signeds_helper::<i64>(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 2\n    let values = &[\n        \"111011100001010110001110001011000010001111010011001110110011001\",\n        \"111111110100110110100110101000101101000011101011011100101000100\",\n        \"110111111101001101101001110111101010101111111011100100000100111\",\n        \"1000110000101001011011100011110101111000101110000001001010011110\",\n        \"1111111001111100000101110010111000110111101100000010010000110\",\n        \"1011101011101000100100010110110000010100100110010000101111101011\",\n        \"110111111011000111010100010011001001010111010010000110110001011\",\n        \"1110111111011000100010000110111111011111000110110100101011011\",\n        \"11001110010100010000000011111011101000011001110000011101001011\",\n        \"1111111000011000100101100000001111001100100011111000000011001110\",\n        \"1101011111111010011011100100011000000100001100111000011000011010\",\n        \"1101101001110110010110110101111101111010001011011100001000011111\",\n        \"1101110000100110011011100110000000011010100111111110001010\",\n        \"1011001000101100011000110011000001110001101010111010010000100\",\n        \"1000111011101001000111101001100000111100100111100111001010111100\",\n        \"11101000100000101100011100101110111000100010100001001101110000\",\n        \"110100010100010101000011000111011101000100100100011111010000011\",\n        \"100000011111110101100111000100100111101101110010011101110110001\",\n        \"10100101100000110010110100110100011010011101101100010\",\n        \"10111110011011000011000011001010101000101001100001001000000110\",\n    ];\n    let common_values = &[\n        (\"1000001000001111111111101100101100110101100101\", 1),\n        (\"1101011110010101110000100010110110000010001101\", 1),\n        (\"1101111000110100001101000000011011000101001001\", 1),\n        (\"1111000011101100001000100110000111101110100011\", 1),\n        (\"10011000001111100110100111011000010001100001111\", 1),\n        (\n            \"1111111111111111101111101000011101000100001010110001100101110110\",\n            1,\n        ),\n        (\n            \"1111111111111111101011111111000001110100011010010001100100101000\",\n            1,\n        ),\n        (\"11010000001000101001101001110011011011010000011\", 1),\n        (\"11101111110000011100000111100110000000001011010\", 1),\n        (\"100011011110110010100010110100001001100100001000\", 1),\n    ];\n    let sample_median = (-8123231271792388, Some(-8096687505746509));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(91581052023966.92),\n        standard_deviation: NiceFloat(5.31973124263762e18),\n        skewness: NiceFloat(0.0012453230455855707),\n        excess_kurtosis: NiceFloat(-1.1981323295909574),\n    };\n    striped_random_nonzero_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 33/32\n    let values = &[\n        \"101010100101010101010101010101010101010101010101010101010101010\",\n        \"101010101010101010101010101010110101010101010101010101010101010\",\n        \"101010100101010101010101010101010101010101010101010101010101010\",\n        \"1010101010010101010101010101010101010101010101010101010101010110\",\n        \"11010101010101010101010101010101010101010101010101010101011010\",\n        \"1010101010101010101010101011010100101010101010101010100101010101\",\n        \"101010110101010101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101001010101010101010101010101010101010101\",\n        \"10101010101010101010101010101010101010101010101001101010101010\",\n        \"1101010101010101010101010101010101010011010101101010101010101010\",\n        \"1101010101010101011010101010101010101010101010101010101010101010\",\n        \"1101010101010101010101010101010101010101010101010101010101010101\",\n        \"10101010101010101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101010101010101010101010101010101010101010\",\n        \"1010101010101010101010101010101010101010101010101011010101010101\",\n        \"10100101010101010101010101010101010101010101010101010101010101\",\n        \"101001010101010101010101010101010101010101010101010101010101101\",\n        \"101010101010101010111010101010110101010101010101010101010101010\",\n        \"10101010101101010101010101010101010101010101010101010101010101\",\n        \"10101010101010101010101101010010101010110101010101101010101010\",\n    ];\n    let common_values = &[\n        (\n            \"101010101010101010101010101010101010101010101010101010101010101\",\n            37342,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010101010\",\n            37241,\n        ),\n        (\n            \"1101010101010101010101010101010101010101010101010101010101010101\",\n            37189,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010101010\",\n            37109,\n        ),\n        (\n            \"1010101010101010101010101010101010101001010101010101010101010101\",\n            1241,\n        ),\n        (\n            \"1101010101010101010101010101010101010110101010101010101010101010\",\n            1239,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010100101\",\n            1235,\n        ),\n        (\n            \"1010101010101010101010101010101010101011010101010101010101010101\",\n            1233,\n        ),\n        (\n            \"1101011010101010101010101010101010101010101010101010101010101010\",\n            1231,\n        ),\n        (\n            \"1101010101010101010101010101010101010101010101010101010101010010\",\n            1227,\n        ),\n    ];\n    let sample_median = (-1489184412743849302, Some(-1489184412721829206));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2366723010422570.0),\n        standard_deviation: NiceFloat(4.878981868385203e18),\n        skewness: NiceFloat(0.0014056588570288651),\n        excess_kurtosis: NiceFloat(-1.6132504884076841),\n    };\n    striped_random_nonzero_signeds_helper::<i64>(\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_nonzero_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(striped_random_nonzero_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(striped_random_nonzero_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn striped_random_nonzero_signeds_fail() {\n    apply_fn_to_signeds!(striped_random_nonzero_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_positive_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_positive_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_positive_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_positive_signeds::<T>(EXAMPLE_SEED, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_positive_signeds() {\n    // i8, m = 4\n    let values = &[\n        \"101100\", \"110000\", \"1111100\", \"1111\", \"1111110\", \"111\", \"11101\", \"1100000\", \"1111111\",\n        \"1100000\", \"10\", \"1000011\", \"111111\", \"1\", \"1111\", \"1\", \"1111111\", \"1111111\", \"111111\",\n        \"101\",\n    ];\n    let common_values = &[\n        (\"1111111\", 97287),\n        (\"1111000\", 32824),\n        (\"11111\", 32718),\n        (\"1111110\", 32708),\n        (\"1000000\", 32633),\n        (\"1100000\", 32625),\n        (\"111111\", 32619),\n        (\"1110000\", 32582),\n        (\"1111\", 32563),\n        (\"111\", 32542),\n    ];\n    let sample_median = (67, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(69.74119900000126),\n        standard_deviation: NiceFloat(45.39301881973154),\n        skewness: NiceFloat(-0.14669679109094702),\n        excess_kurtosis: NiceFloat(-1.4928149640100892),\n    };\n    striped_random_positive_signeds_helper::<i8>(\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 2\n    let values = &[\n        \"11001\", \"11100\", \"101010\", \"1001011\", \"101101\", \"1111100\", \"111100\", \"10100\", \"1101\",\n        \"1111111\", \"1100011\", \"1101101\", \"1100\", \"100\", \"1100001\", \"100011\", \"110100\", \"110101\",\n        \"110100\", \"10011\",\n    ];\n    let common_values = &[\n        (\"11010\", 8196),\n        (\"1111\", 8123),\n        (\"1001101\", 8065),\n        (\"11011\", 8056),\n        (\"1010101\", 8053),\n        (\"1110111\", 8043),\n        (\"1010100\", 8019),\n        (\"111\", 8015),\n        (\"101100\", 8003),\n        (\"1111010\", 8002),\n    ];\n    let sample_median = (64, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(64.04460499999882),\n        standard_deviation: NiceFloat(36.65530083091763),\n        skewness: NiceFloat(-0.0005788615669167611),\n        excess_kurtosis: NiceFloat(-1.2009597413001147),\n    };\n    striped_random_positive_signeds_helper::<i8>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 5/4\n    let values = &[\n        \"101001\", \"100101\", \"100110\", \"1101001\", \"101101\", \"1010101\", \"111010\", \"101010\", \"10110\",\n        \"1010101\", \"1001000\", \"1001011\", \"1000\", \"11100\", \"1111010\", \"101101\", \"110101\", \"101010\",\n        \"100101\", \"100010\",\n    ];\n    let common_values = &[\n        (\"101010\", 131218),\n        (\"1010101\", 131204),\n        (\"1001010\", 33121),\n        (\"1011010\", 33074),\n        (\"10101\", 32947),\n        (\"100101\", 32868),\n        (\"1010010\", 32851),\n        (\"101011\", 32817),\n        (\"101001\", 32765),\n        (\"110101\", 32762),\n    ];\n    let sample_median = (65, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(63.51510099999881),\n        standard_deviation: NiceFloat(27.102051665528496),\n        skewness: NiceFloat(-0.0016063884661944201),\n        excess_kurtosis: NiceFloat(-1.1009870884906956),\n    };\n    striped_random_positive_signeds_helper::<i8>(\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 32\n    let values = &[\n        \"11111111111111111111111111111\",\n        \"111111111111111111111111111111111111111111111111111111111\",\n        \"1111111111111111111111111111\",\n        \"111111111111111111111111110000000000000000000000000000000000000\",\n        \"111111111111111111111111111111111111111111111111111111111\",\n        \"111111111000000000000000000000000000000000000001100000000111111\",\n        \"11111111111111100000\",\n        \"11111111111111111\",\n        \"111111111111\",\n        \"111111111111111111111111111111111111111111111111111100000000000\",\n        \"111111111111100000000000000000000000000000000000000000000000000\",\n        \"111111111000000000000000000000000000000000000000000000000000000\",\n        \"1111111111111111111111111111100000000000000\",\n        \"1000000011111111111111111111\",\n        \"111111000000000000000111111111111111111111111111111111111111111\",\n        \"11111111111100000000000000000000000000000000000000\",\n        \"111111111111111111111110000000000000000001111111\",\n        \"1111111111111111111111111111111111111111111111111111111111111\",\n        \"1111111\",\n        \"111111111111111111100000000000000000000000000000000000000000000\",\n    ];\n    let common_values = &[\n        (\n            \"111111111111111111111111111111111111111111111111111111111111111\",\n            75198,\n        ),\n        (\n            \"111111111111111111111111111111111111111111111111111111111111000\",\n            2569,\n        ),\n        (\n            \"11111111111111111111111111111111111111111111111111111111111\",\n            2529,\n        ),\n        (\n            \"111111111111111100000000000000000000000000000000000000000000000\",\n            2513,\n        ),\n        (\"11111111111111111111111\", 2507),\n        (\"111111111\", 2503),\n        (\n            \"100000000000000000000000000000000000000000000000000000000000000\",\n            2502,\n        ),\n        (\n            \"111111111111111110000000000000000000000000000000000000000000000\",\n            2501,\n        ),\n        (\"111111111111111111111111111\", 2500),\n        (\n            \"111111111110000000000000000000000000000000000000000000000000000\",\n            2491,\n        ),\n    ];\n    let sample_median = (8070450532250024960, Some(8070450532250024967));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.959974637374284e18),\n        standard_deviation: NiceFloat(4.3991106930140626e18),\n        skewness: NiceFloat(-0.15099815742030892),\n        excess_kurtosis: NiceFloat(-1.9150786144831098),\n    };\n    striped_random_positive_signeds_helper::<i64>(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 2\n    let values = &[\n        \"1100110001101010100101101001000001100001110101111001000000001\",\n        \"111011011100111110111000010111001101001101010010111011001100\",\n        \"11110000010100111000110001101100111001001010101110001000100000\",\n        \"110010001100111101011100111111100001001110001100001001000000011\",\n        \"1100110011001011000001001111001010100010110100011010010001\",\n        \"111000101110010000110100101010100100111001100100001101010011011\",\n        \"10000011110001100010001010101101101100100000010011101111010\",\n        \"1110110110110011010011011010000111001101110110010001101011110\",\n        \"11010010000001101100111000010011100101110010101101001100110000\",\n        \"110000010001000110001011100111001101110010001111000110001111001\",\n        \"100011101111011001001101101011100000110001110100111011011011111\",\n        \"111101111100000110000001010001001101011110011110110100010110010\",\n        \"1010001010011101001011011111100101110000001010101000111100001\",\n        \"11110011011100110101011110010001110100010111001010000100011101\",\n        \"110001001100111101011111000100111101011110111101110011010100111\",\n        \"1111011101101101011111011010011011001011010001101011100101\",\n        \"11111101110101010010000100011110100110100000110100101000110111\",\n        \"10101011010100000101011100111011000001101010001000101111111010\",\n        \"110000111110001111000001110011101110100001101011111010100110\",\n        \"1101010111111111000111001111000111110001111110100101000001111\",\n    ];\n    let common_values = &[\n        (\"10101000110110101100110011001101011011101\", 1),\n        (\"1110100010100111110111100000011111000010100\", 1),\n        (\"10011111100110010100000010001100001001111011\", 1),\n        (\"10111110110011101010110111100010100101101100\", 1),\n        (\"110101001100100110010011010000011100100111011\", 1),\n        (\"1001000111011010110011001111101001111101110011\", 1),\n        (\"1010101100111011110111011011011100011101010101\", 1),\n        (\"1100110000110110000100011110000110101010110010\", 1),\n        (\"1100110011000110101101111111111110111011101001\", 1),\n        (\"1101011001000111111110011010000001001001000110\", 1),\n    ];\n    let sample_median = (4616064909372870741, Some(4616067528870766644));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.614689648935556e18),\n        standard_deviation: NiceFloat(2.6622250799886193e18),\n        skewness: NiceFloat(-0.0006757801147527129),\n        excess_kurtosis: NiceFloat(-1.199752325803772),\n    };\n    striped_random_positive_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 33/32\n    let values = &[\n        \"10101010101010101010101101010101010101010101010101010101010101\",\n        \"10101010101010100010101010010101101010101010101011010101011010\",\n        \"10101010010101011010101010101010101101010101010101010101010101\",\n        \"101010101010101010101101010101010101010101010101010101010101010\",\n        \"10101010101010101010101011010101010101001010010101001010101010\",\n        \"101010101010101010101010101010101010100101010010101010110101010\",\n        \"10101010101010101010101010101010101010101010101010110101010101\",\n        \"10101010101010101010010101010101010101010101010101010101010101\",\n        \"10101010010101010101010101010101010101010101010101010101010101\",\n        \"101010101100101010101010101010101010101010101010101010010101010\",\n        \"101010101010101010101010101010101011001010101010101101010101010\",\n        \"101101010101010011010101010101010101010101010101010101010101010\",\n        \"10101001010101010101011010101010101010101010101010101010101010\",\n        \"10101010101010101011010010010110101010101010101010101010101010\",\n        \"101010101010101010110101010101010101010101010010101010101010101\",\n        \"10101010101010101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101010101010101010101010101011010101010101\",\n        \"10101010101010101010101010101010101010101101010101010101010101\",\n        \"10101010101010101011011010100101010101001010101010101010101010\",\n        \"10101010101010101010101010101011010101010101010101010101010101\",\n    ];\n    let common_values = &[\n        (\n            \"101010101010101010101010101010101010101010101010101010101010101\",\n            74299,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010101010\",\n            74072,\n        ),\n        (\n            \"101010101010101010101010010101010101010101010101010101010101010\",\n            2429,\n        ),\n        (\n            \"101010101010101010101010101010101010101010101010101010101011010\",\n            2419,\n        ),\n        (\n            \"101010101011010101010101010101010101010101010101010101010101010\",\n            2419,\n        ),\n        (\n            \"101010101010101010101001010101010101010101010101010101010101010\",\n            2411,\n        ),\n        (\n            \"101010101010101010101010101010101010101010101010010101010101010\",\n            2393,\n        ),\n        (\n            \"101010101001010101010101010101010101010101010101010101010101010\",\n            2390,\n        ),\n        (\n            \"10101010101010101010101010101001010101010101010101010101010101\",\n            2389,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010100101\",\n            2389,\n        ),\n    ];\n    let sample_median = (5281221163029801642, Some(5281221163029804373));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.613154278246113e18),\n        standard_deviation: NiceFloat(1.599140542162029e18),\n        skewness: NiceFloat(-0.0019511120341977268),\n        excess_kurtosis: NiceFloat(-1.7372862317601716),\n    };\n    striped_random_positive_signeds_helper::<i64>(\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_positive_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(striped_random_positive_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(striped_random_positive_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn striped_random_positive_signeds_fail() {\n    apply_fn_to_signeds!(striped_random_positive_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_positive_unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_positive_unsigneds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_positive_unsigneds_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_positive_unsigneds::<T>(EXAMPLE_SEED, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_positive_unsigneds() {\n    // u8, m = 4\n    let values = &[\n        \"1\", \"1001100\", \"1111111\", \"11000011\", \"10000000\", \"1111\", \"1110110\", \"11111000\",\n        \"11111111\", \"11111101\", \"1111001\", \"11110000\", \"11\", \"1111111\", \"1\", \"11010011\",\n        \"10000111\", \"111\", \"1111001\", \"10110000\",\n    ];\n    let common_values = &[\n        (\"11111111\", 71334),\n        (\"11110000\", 24018),\n        (\"11100000\", 24001),\n        (\"11111\", 23981),\n        (\"11111110\", 23965),\n        (\"111111\", 23924),\n        (\"11111100\", 23919),\n        (\"1111\", 23888),\n        (\"11\", 23829),\n        (\"111\", 23815),\n    ];\n    let sample_median = (131, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(136.63338500000273),\n        standard_deviation: NiceFloat(92.21339578256648),\n        skewness: NiceFloat(-0.10902316932402645),\n        excess_kurtosis: NiceFloat(-1.5167077828673536),\n    };\n    striped_random_positive_unsigneds_helper::<u8>(\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, m = 2\n    let values = &[\n        \"110011\", \"1110010\", \"1010110\", \"10110100\", \"1000001\", \"11000011\", \"101000\", \"110111\",\n        \"11\", \"11000100\", \"10111001\", \"11111011\", \"111101\", \"1110011\", \"10100110\", \"1010010\",\n        \"1110110\", \"110011\", \"11111\", \"1010011\",\n    ];\n    let common_values = &[\n        (\"1000100\", 4120),\n        (\"10100100\", 4099),\n        (\"11100100\", 4077),\n        (\"10100010\", 4054),\n        (\"11011010\", 4054),\n        (\"1010100\", 4051),\n        (\"10010010\", 4044),\n        (\"10001011\", 4041),\n        (\"11100011\", 4032),\n        (\"10110\", 4028),\n    ];\n    let sample_median = (128, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(128.1168509999991),\n        standard_deviation: NiceFloat(73.48547444875528),\n        skewness: NiceFloat(-0.0006394544560910719),\n        excess_kurtosis: NiceFloat(-1.1968013589588233),\n    };\n    striped_random_positive_unsigneds_helper::<u8>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, m = 5/4\n    let values = &[\n        \"1010010\", \"1101010\", \"110010\", \"10010100\", \"1010101\", \"10111010\", \"1010100\", \"1011010\",\n        \"1010110\", \"10001101\", \"10000100\", \"11100011\", \"1010\", \"1001011\", \"10101010\", \"1010110\",\n        \"1010001\", \"1010100\", \"1010101\", \"1010101\",\n    ];\n    let common_values = &[\n        (\"1010101\", 105176),\n        (\"10101010\", 104735),\n        (\"10101101\", 26535),\n        (\"11010101\", 26470),\n        (\"1010010\", 26421),\n        (\"101010\", 26383),\n        (\"1001010\", 26310),\n        (\"10010101\", 26290),\n        (\"10110101\", 26230),\n        (\"10101001\", 26220),\n    ];\n    let sample_median = (130, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.53545100000133),\n        standard_deviation: NiceFloat(54.22647275765827),\n        skewness: NiceFloat(-0.0014575581250140023),\n        excess_kurtosis: NiceFloat(-1.1009413456646224),\n    };\n    striped_random_positive_unsigneds_helper::<u8>(\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u64, m = 32\n    let values = &[\n        \"111111111111111111111111111111\",\n        \"11111111111111111111111111111111111111111111111111111111111\",\n        \"1111111111111111111111111111111\",\n        \"1111111111111111111111100000000000000000000000000000000000000000\",\n        \"11111111111111111111111111111111111111111111111111111111111111\",\n        \"1111000000000000000000000000000000000000001100000000111111111111\",\n        \"111111111111111000000000000\",\n        \"1111111111111111111111111\",\n        \"111111111111111111111\",\n        \"1111111111111111111111111111111111111111111000000000000000000000\",\n        \"1110000000000000000000000000000000000000000000000000000000000111\",\n        \"1111111111111111111111111111111111111111111111111111111111111111\",\n        \"11111111111111111111111111111000000000000000000000000000\",\n        \"100000001111111111111111111111111000000000\",\n        \"1111111000000000000000000000000000000000000000000000000000000000\",\n        \"1111\",\n        \"1111111111111111111111111111111111111111111111111111000\",\n        \"1111111111111111110000000011111111111111111\",\n        \"111111111111111111111111100\",\n        \"1111111111111111111111111111111111111111111111111111111111111111\",\n    ];\n    let common_values = &[\n        (\n            \"1111111111111111111111111111111111111111111111111111111111111111\",\n            72952,\n        ),\n        (\"111111111111111111111111111111\", 2474),\n        (\n            \"1111111111111111111111111110000000000000000000000000000000000000\",\n            2456,\n        ),\n        (\"111111111\", 2437),\n        (\"11111111111111111111111111111111111\", 2417),\n        (\n            \"1111111111111111111111111111111111111111111111100000000000000000\",\n            2414,\n        ),\n        (\n            \"1111111000000000000000000000000000000000000000000000000000000000\",\n            2410,\n        ),\n        (\"111111111111111111111111111111111111\", 2408),\n        (\"111111111111111111111111111111111111111111111111111\", 2404),\n        (\n            \"1111111111111111111111111111111111111111111111111111111111111100\",\n            2399,\n        ),\n    ];\n    let sample_median = (16140901064496103427, Some(16140901064496103487));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.903368730390014e18),\n        standard_deviation: NiceFloat(8.801310214580938e18),\n        skewness: NiceFloat(-0.14740544458518143),\n        excess_kurtosis: NiceFloat(-1.916675806061043),\n    };\n    striped_random_positive_unsigneds_helper::<u64>(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u64, m = 2\n    let values = &[\n        \"11001100011010101001011010010000011000011101011110010000000011\",\n        \"11101101110011111011100001011100110100110101001011101100110011\",\n        \"1111101011000111001110010011000110110101010001110111011111100\",\n        \"1011100110000101000110000000111101100011100111101101111111000000\",\n        \"110011001100101100000100111100101010001011010001101001000111000\",\n        \"1010001101111001011010101011011000110011011110010101100100000100\",\n        \"111100011000100010101011011011001000000100111011110100111011\",\n        \"100100110010110010010111100011001000100110111001010000100101101\",\n        \"1101100111000010011100101110010101101001100110000011111011\",\n        \"1101110011101000110001100100011011100001110011100001101110001000\",\n        \"1101100100110110101110000011000111010011101101101111111101111100\",\n        \"1111001111110101110110010100001100001001011101001101101011101011\",\n        \"111010010110111111001011100000010101010001111000010000110010001\",\n        \"11010101111001000111010001011100101000010001110110001001100111\",\n        \"1101011111000100111101011110111101110011010100111111100001000100\",\n        \"100101000001001011001001101001011100101000110101111110111010101\",\n        \"110111101110000101100101111100101101011100100010101011010100000\",\n        \"101011100111011000001101010001000101111111010001100001111100011\",\n        \"1111100011000100010111100101000001010110011001010100000000011\",\n        \"11100111100011111000111111010010100000111110101001010111011001\",\n    ];\n    let common_values = &[\n        (\"11011011101110000001110101101011110010111101\", 1),\n        (\"111100000110100100110100100001100010110000010\", 1),\n        (\"1011110101111010110111100110111101111101111011\", 1),\n        (\"1110100010111110000100101010110100101101110111\", 1),\n        (\"10111011110000001110101010110111111001011011100\", 1),\n        (\"11000001010110011001100110101011001100000111111\", 1),\n        (\"100100100011101001001000001010010111100010110100\", 1),\n        (\"100110100101010111001000010010100111110111010110\", 1),\n        (\"110110101100010110011100011100110111001111000000\", 1),\n        (\"111001100010011111010011111010110100101110001000\", 1),\n    ];\n    let sample_median = (9232300347074497346, Some(9232359143244030439));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.22650235650532e18),\n        standard_deviation: NiceFloat(5.325785817923598e18),\n        skewness: NiceFloat(-0.0012562071401776408),\n        excess_kurtosis: NiceFloat(-1.1996143045434082),\n    };\n    striped_random_positive_unsigneds_helper::<u64>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u64, m = 33/32\n    let values = &[\n        \"101010101010101010101011010101010101010101010101010101010101010\",\n        \"101010101010101110101010110101001010101010101010010101010010101\",\n        \"101010010101011010101010101010101101010101010101010101010101010\",\n        \"1010101010101010100101010101010101010101010101010101010101010101\",\n        \"101010101010101010101101010101010100101001010100101010101010101\",\n        \"1010101010101010101010101010101011010101101010101001010101010101\",\n        \"101010101010101010101010101010101010101010101101010101010101010\",\n        \"101010101010110101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101010101010101010101010101010101010101011\",\n        \"1001010101010101010101010101010101010101010100101010101010101010\",\n        \"1010101010101010101010101100101010101010110101010101010010101010\",\n        \"1010011010101010101010101010101010101010101010101010101010010101\",\n        \"101010101001010101010101010101010101010101010101010101010101010\",\n        \"101010010110110100101010101010101010101010101010101010101010101\",\n        \"1010110101010101010101010101010010101010101010101010101010101010\",\n        \"101010101010101010101010101010101010101010101010101010101010101\",\n        \"101010101010101010101010101010101101010101010101010101010101010\",\n        \"101010101010101010101010010101010101010101010101010101010101010\",\n        \"110110101001010101010010101010101010101010101010101010101010101\",\n        \"101010101010010101010101010101010101010101010101010101010101010\",\n    ];\n    let common_values = &[\n        (\n            \"101010101010101010101010101010101010101010101010101010101010101\",\n            72208,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010101010\",\n            71633,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010101001\",\n            2387,\n        ),\n        (\n            \"101010101010101010101010101010101010110101010101010101010101010\",\n            2371,\n        ),\n        (\n            \"101010101010101010101001010101010101010101010101010101010101010\",\n            2350,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010100101\",\n            2343,\n        ),\n        (\n            \"1010101010101010101010101010101001010101010101010101010101010101\",\n            2321,\n        ),\n        (\n            \"101010101010101010101010101010101010101001010101010101010101010\",\n            2317,\n        ),\n        (\n            \"1010101010101010101010101010101010101010100101010101010101010101\",\n            2316,\n        ),\n        (\n            \"1010101010101010101101010101010101010101010101010101010101010101\",\n            2314,\n        ),\n    ];\n    let sample_median = (10184128240689698133, Some(10184139957360479594));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.22742898450889e18),\n        standard_deviation: NiceFloat(3.1984799302251884e18),\n        skewness: NiceFloat(-0.0008313832988426654),\n        excess_kurtosis: NiceFloat(-1.7364190763714287),\n    };\n    striped_random_positive_unsigneds_helper::<u64>(\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_positive_unsigneds_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(striped_random_positive_unsigneds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(striped_random_positive_unsigneds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn striped_random_positive_unsigneds_fail() {\n    apply_fn_to_unsigneds!(striped_random_positive_unsigneds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_signed_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_signed_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_signed_inclusive_range_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: CheckedToF64 + PrimitiveSigned + WrappingFrom<U>,\n>(\n    a: S,\n    b: S,\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (S, Option<S>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_signed_inclusive_range::<U, S>(\n        EXAMPLE_SEED,\n        a,\n        b,\n        m_numerator,\n        m_denominator,\n    );\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_signed_inclusive_range() {\n    // i16, 50, 200, m = 4\n    let values = &[\n        \"110010\", \"11000000\", \"10100110\", \"110111\", \"111111\", \"11001000\", \"1111000\", \"111111\",\n        \"110010\", \"1111111\", \"111110\", \"11000001\", \"111101\", \"110111\", \"11001000\", \"110011\",\n        \"111111\", \"11000011\", \"11000000\", \"11000000\",\n    ];\n    let common_values = &[\n        (\"11001000\", 187162),\n        (\"11000000\", 79165),\n        (\"111111\", 78685),\n        (\"110010\", 70343),\n        (\"110011\", 70101),\n        (\"110111\", 26718),\n        (\"111100\", 26467),\n        (\"111110\", 26443),\n        (\"111000\", 26309),\n        (\"11000001\", 26222),\n    ];\n    let sample_median = (128, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(126.78841600000145),\n        standard_deviation: NiceFloat(62.97286483710745),\n        skewness: NiceFloat(-0.01241704115437865),\n        excess_kurtosis: NiceFloat(-1.7551228249647437),\n    };\n    striped_random_signed_inclusive_range_helper::<u16, i16>(\n        50,\n        200,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i16, -200, -50, m = 4\n    let values = &[\n        \"1111111111001110\",\n        \"1111111101000000\",\n        \"1111111101011010\",\n        \"1111111111001001\",\n        \"1111111111000001\",\n        \"1111111100111000\",\n        \"1111111110001000\",\n        \"1111111111000001\",\n        \"1111111111001110\",\n        \"1111111110000001\",\n        \"1111111111000010\",\n        \"1111111100111111\",\n        \"1111111111000011\",\n        \"1111111111001001\",\n        \"1111111100111000\",\n        \"1111111111001101\",\n        \"1111111111000001\",\n        \"1111111100111101\",\n        \"1111111101000000\",\n        \"1111111101000000\",\n    ];\n    let common_values = &[\n        (\"1111111100111000\", 187162),\n        (\"1111111101000000\", 79165),\n        (\"1111111111000001\", 78685),\n        (\"1111111111001110\", 70343),\n        (\"1111111111001101\", 70101),\n        (\"1111111111001001\", 26718),\n        (\"1111111111000100\", 26467),\n        (\"1111111111000010\", 26443),\n        (\"1111111111001000\", 26309),\n        (\"1111111100111111\", 26222),\n    ];\n    let sample_median = (-128, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-126.78841600000145),\n        standard_deviation: NiceFloat(62.97286483710745),\n        skewness: NiceFloat(0.01241704115437865),\n        excess_kurtosis: NiceFloat(-1.7551228249647437),\n    };\n    striped_random_signed_inclusive_range_helper::<u16, i16>(\n        -200,\n        -50,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i16, -50, 200, m = 4\n    let values = &[\n        \"1111111111001110\",\n        \"1111111111001111\",\n        \"11000111\",\n        \"11111\",\n        \"1111111111111111\",\n        \"11000011\",\n        \"1000000\",\n        \"11000001\",\n        \"1111111\",\n        \"11000011\",\n        \"11000100\",\n        \"1111111111111111\",\n        \"11001000\",\n        \"1111111111010010\",\n        \"1111111111110100\",\n        \"1111111111011111\",\n        \"1111111111111111\",\n        \"1111111111001111\",\n        \"1111111111111111\",\n        \"1111111111010000\",\n    ];\n    let common_values = &[\n        (\"1111111111001110\", 93920),\n        (\"11001000\", 93547),\n        (\"1111111111111111\", 79262),\n        (\"1111111111010000\", 70793),\n        (\"11000000\", 39521),\n        (\"0\", 33351),\n        (\"1111111111001111\", 23264),\n        (\"1111111111111001\", 19879),\n        (\"1111111111100000\", 19842),\n        (\"1111111111110001\", 19780),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(42.632988000001404),\n        standard_deviation: NiceFloat(91.45288785939469),\n        skewness: NiceFloat(0.7466366203634324),\n        excess_kurtosis: NiceFloat(-1.0394231672402725),\n    };\n    striped_random_signed_inclusive_range_helper::<u16, i16>(\n        -50,\n        200,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_signed_inclusive_range_fail_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    assert_panic!(striped_random_signed_inclusive_range::<U, S>(\n        EXAMPLE_SEED,\n        S::TWO,\n        S::ONE,\n        5,\n        1,\n    ));\n    assert_panic!(striped_random_signed_inclusive_range::<U, S>(\n        EXAMPLE_SEED,\n        S::NEGATIVE_ONE,\n        S::from(-2i8),\n        5,\n        1,\n    ));\n    assert_panic!(striped_random_signed_inclusive_range::<U, S>(\n        EXAMPLE_SEED,\n        S::ONE,\n        S::TWO,\n        1,\n        1,\n    ));\n}\n\n#[test]\nfn striped_random_signed_inclusive_range_fail() {\n    apply_fn_to_unsigned_signed_pairs!(striped_random_signed_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_signed_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_signed_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_signed_range_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: CheckedToF64 + PrimitiveSigned + WrappingFrom<U>,\n>(\n    a: S,\n    b: S,\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (S, Option<S>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_signed_range::<U, S>(EXAMPLE_SEED, a, b, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_signed_range() {\n    // i16, 50, 201, m = 4\n    let values = &[\n        \"110010\", \"11000000\", \"10100110\", \"110111\", \"111111\", \"11001000\", \"1111000\", \"111111\",\n        \"110010\", \"1111111\", \"111110\", \"11000001\", \"111101\", \"110111\", \"11001000\", \"110011\",\n        \"111111\", \"11000011\", \"11000000\", \"11000000\",\n    ];\n    let common_values = &[\n        (\"11001000\", 187162),\n        (\"11000000\", 79165),\n        (\"111111\", 78685),\n        (\"110010\", 70343),\n        (\"110011\", 70101),\n        (\"110111\", 26718),\n        (\"111100\", 26467),\n        (\"111110\", 26443),\n        (\"111000\", 26309),\n        (\"11000001\", 26222),\n    ];\n    let sample_median = (128, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(126.78841600000145),\n        standard_deviation: NiceFloat(62.97286483710745),\n        skewness: NiceFloat(-0.01241704115437865),\n        excess_kurtosis: NiceFloat(-1.7551228249647437),\n    };\n    striped_random_signed_range_helper::<u16, i16>(\n        50,\n        201,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i16, -200, -49, m = 4\n    let values = &[\n        \"1111111111001110\",\n        \"1111111101000000\",\n        \"1111111101011010\",\n        \"1111111111001001\",\n        \"1111111111000001\",\n        \"1111111100111000\",\n        \"1111111110001000\",\n        \"1111111111000001\",\n        \"1111111111001110\",\n        \"1111111110000001\",\n        \"1111111111000010\",\n        \"1111111100111111\",\n        \"1111111111000011\",\n        \"1111111111001001\",\n        \"1111111100111000\",\n        \"1111111111001101\",\n        \"1111111111000001\",\n        \"1111111100111101\",\n        \"1111111101000000\",\n        \"1111111101000000\",\n    ];\n    let common_values = &[\n        (\"1111111100111000\", 187162),\n        (\"1111111101000000\", 79165),\n        (\"1111111111000001\", 78685),\n        (\"1111111111001110\", 70343),\n        (\"1111111111001101\", 70101),\n        (\"1111111111001001\", 26718),\n        (\"1111111111000100\", 26467),\n        (\"1111111111000010\", 26443),\n        (\"1111111111001000\", 26309),\n        (\"1111111100111111\", 26222),\n    ];\n    let sample_median = (-128, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-126.78841600000145),\n        standard_deviation: NiceFloat(62.97286483710745),\n        skewness: NiceFloat(0.01241704115437865),\n        excess_kurtosis: NiceFloat(-1.7551228249647437),\n    };\n    striped_random_signed_range_helper::<u16, i16>(\n        -200,\n        -49,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i16, -50, 201, m = 4\n    let values = &[\n        \"1111111111001110\",\n        \"1111111111001111\",\n        \"11000111\",\n        \"11111\",\n        \"1111111111111111\",\n        \"11000011\",\n        \"1000000\",\n        \"11000001\",\n        \"1111111\",\n        \"11000011\",\n        \"11000100\",\n        \"1111111111111111\",\n        \"11001000\",\n        \"1111111111010010\",\n        \"1111111111110100\",\n        \"1111111111011111\",\n        \"1111111111111111\",\n        \"1111111111001111\",\n        \"1111111111111111\",\n        \"1111111111010000\",\n    ];\n    let common_values = &[\n        (\"1111111111001110\", 93920),\n        (\"11001000\", 93547),\n        (\"1111111111111111\", 79262),\n        (\"1111111111010000\", 70793),\n        (\"11000000\", 39521),\n        (\"0\", 33351),\n        (\"1111111111001111\", 23264),\n        (\"1111111111111001\", 19879),\n        (\"1111111111100000\", 19842),\n        (\"1111111111110001\", 19780),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(42.632988000001404),\n        standard_deviation: NiceFloat(91.45288785939469),\n        skewness: NiceFloat(0.7466366203634324),\n        excess_kurtosis: NiceFloat(-1.0394231672402725),\n    };\n    striped_random_signed_range_helper::<u16, i16>(\n        -50,\n        201,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_signed_range_fail_helper<\n    U: PrimitiveUnsigned + WrappingFrom<S>,\n    S: PrimitiveSigned + WrappingFrom<U>,\n>() {\n    assert_panic!(striped_random_signed_range::<U, S>(\n        EXAMPLE_SEED,\n        S::TWO,\n        S::TWO,\n        5,\n        1,\n    ));\n    assert_panic!(striped_random_signed_range::<U, S>(\n        EXAMPLE_SEED,\n        S::NEGATIVE_ONE,\n        S::NEGATIVE_ONE,\n        5,\n        1,\n    ));\n    assert_panic!(striped_random_signed_range::<U, S>(\n        EXAMPLE_SEED,\n        S::ONE,\n        S::TWO,\n        1,\n        1,\n    ));\n}\n\n#[test]\nfn striped_random_signed_range_fail() {\n    apply_fn_to_unsigned_signed_pairs!(striped_random_signed_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_signeds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_signeds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_signeds_helper<T: CheckedToF64 + PrimitiveSigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_signeds::<T>(EXAMPLE_SEED, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_signeds() {\n    // i8, m = 4\n    let values = &[\n        \"1100001\", \"1000000\", \"1100000\", \"10000111\", \"1111\", \"10000001\", \"1111000\", \"100011\",\n        \"111101\", \"11111100\", \"11111111\", \"11100001\", \"1\", \"101111\", \"10111000\", \"111111\",\n        \"1101100\", \"1111110\", \"111100\", \"1\",\n    ];\n    let common_values = &[\n        (\"11111111\", 44563),\n        (\"1111111\", 44533),\n        (\"0\", 44507),\n        (\"10000000\", 44366),\n        (\"11000000\", 15052),\n        (\"10011111\", 15027),\n        (\"111111\", 15014),\n        (\"11111100\", 15003),\n        (\"1111100\", 14976),\n        (\"1111\", 14944),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.4694119999999954),\n        standard_deviation: NiceFloat(79.79176643677252),\n        skewness: NiceFloat(0.00030165230376920274),\n        excess_kurtosis: NiceFloat(-1.0255715724465873),\n    };\n    striped_random_signeds_helper::<i8>(\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 2\n    let values = &[\n        \"1110111\", \"1000010\", \"1010011\", \"10011100\", \"10110\", \"10000100\", \"1100001\", \"100110\",\n        \"11101\", \"11100110\", \"11100000\", \"11111010\", \"11011\", \"101100\", \"10101011\", \"10110\",\n        \"1011110\", \"1110101\", \"10001\", \"10100\",\n    ];\n    let common_values = &[\n        (\"11010110\", 4062),\n        (\"1100000\", 4043),\n        (\"1100100\", 4038),\n        (\"11100100\", 4031),\n        (\"11000100\", 4030),\n        (\"11111110\", 4027),\n        (\"111110\", 4027),\n        (\"11110100\", 4027),\n        (\"10011000\", 4026),\n        (\"1010111\", 4025),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5196209999999974),\n        standard_deviation: NiceFloat(73.87620855668304),\n        skewness: NiceFloat(0.0007310111483160227),\n        excess_kurtosis: NiceFloat(-1.1989696073332987),\n    };\n    striped_random_signeds_helper::<i8>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i8, m = 5/4\n    let values = &[\n        \"1010100\", \"1001010\", \"1101101\", \"10010101\", \"110101\", \"10101010\", \"1000010\", \"101001\",\n        \"110110\", \"11011101\", \"11011001\", \"11110101\", \"1010\", \"10101\", \"10110101\", \"111010\",\n        \"1101001\", \"1101010\", \"100110\", \"101001\",\n    ];\n    let common_values = &[\n        (\"11010101\", 66213),\n        (\"10101010\", 65616),\n        (\"1010101\", 65484),\n        (\"101010\", 65183),\n        (\"10100101\", 16584),\n        (\"11010010\", 16518),\n        (\"1011010\", 16486),\n        (\"1101010\", 16481),\n        (\"110101\", 16475),\n        (\"10010101\", 16471),\n    ];\n    let sample_median = (-5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.512405000000015),\n        standard_deviation: NiceFloat(69.49166061626981),\n        skewness: NiceFloat(0.0016729618125163213),\n        excess_kurtosis: NiceFloat(-1.4629834926857006),\n    };\n    striped_random_signeds_helper::<i8>(\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 32\n    let values = &[\n        \"111000000000000000000000000000001111111111111111111111111111111\",\n        \"111111111111111111111111111111111111111111111111111111111111111\",\n        \"111111111111111111111111111111111100000000000000000000000000011\",\n        \"1000000000000000011111111111111111111111111111111111111111111111\",\n        \"111111111111111111111111111111100000000000000000000000000\",\n        \"1000000000000000000000000000000001111111000000000000000000011111\",\n        \"111111111111111111111000000000000000000011111111111111111111111\",\n        \"111111111111111000000000010000001111111111\",\n        \"1000000000000000\",\n        \"1111111111001111111111111111111111111111111111111111111110000000\",\n        \"1111111111111111111111111111111111111111111111111111111111111111\",\n        \"1100000000000000000000000000000000000000000000000000000000000000\",\n        \"11111111111111111111111111111000000000000000001111111\",\n        \"111111111111111111111111111111111111111111111111111111\",\n        \"1000000000000001111111100000011111111111111111111111111111000000\",\n        \"111111111111111111000\",\n        \"111111110000001000000000000000000000000000000000000000000000000\",\n        \"111111111111111111111111111111111111111100000000000001111111111\",\n        \"111111111111111111111111111111111111111\",\n        \"1111111111111111111111111111111111111111111\",\n    ];\n    let common_values = &[\n        (\n            \"1111111111111111111111111111111111111111111111111111111111111111\",\n            35069,\n        ),\n        (\n            \"1000000000000000000000000000000000000000000000000000000000000000\",\n            34751,\n        ),\n        (\"0\", 34639),\n        (\n            \"111111111111111111111111111111111111111111111111111111111111111\",\n            34560,\n        ),\n        (\n            \"111111111111111111111111111111111111111111111111111000000000000\",\n            1200,\n        ),\n        (\n            \"111111111111111111100000000000000000000000000000000000000000000\",\n            1194,\n        ),\n        (\n            \"1000000000000000000000000000000000000000111111111111111111111111\",\n            1192,\n        ),\n        (\n            \"111111111111111111111110000000000000000000000000000000000000000\",\n            1188,\n        ),\n        (\n            \"1000000000000000000000000000000000000000000000000000000000000111\",\n            1188,\n        ),\n        (\n            \"1000000000000000000000000000000111111111111111111111111111111111\",\n            1187,\n        ),\n    ];\n    let sample_median = (-1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1478194767948927.5),\n        standard_deviation: NiceFloat(6.390112936152263e18),\n        skewness: NiceFloat(-0.00034103406624165104),\n        excess_kurtosis: NiceFloat(-0.9868005073632049),\n    };\n    striped_random_signeds_helper::<i64>(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 2\n    let values = &[\n        \"111011100001010110001110001011000010001111010011001110110011001\",\n        \"111111110100110110100110101000101101000011101011011100101000100\",\n        \"110111111101001101101001110111101010101111111011100100000100111\",\n        \"1000110000101001011011100011110101111000101110000001001010011110\",\n        \"1111111001111100000101110010111000110111101100000010010000110\",\n        \"1011101011101000100100010110110000010100100110010000101111101011\",\n        \"110111111011000111010100010011001001010111010010000110110001011\",\n        \"1110111111011000100010000110111111011111000110110100101011011\",\n        \"11001110010100010000000011111011101000011001110000011101001011\",\n        \"1111111000011000100101100000001111001100100011111000000011001110\",\n        \"1101011111111010011011100100011000000100001100111000011000011010\",\n        \"1101101001110110010110110101111101111010001011011100001000011111\",\n        \"1101110000100110011011100110000000011010100111111110001010\",\n        \"1011001000101100011000110011000001110001101010111010010000100\",\n        \"1000111011101001000111101001100000111100100111100111001010111100\",\n        \"11101000100000101100011100101110111000100010100001001101110000\",\n        \"110100010100010101000011000111011101000100100100011111010000011\",\n        \"100000011111110101100111000100100111101101110010011101110110001\",\n        \"10100101100000110010110100110100011010011101101100010\",\n        \"10111110011011000011000011001010101000101001100001001000000110\",\n    ];\n    let common_values = &[\n        (\"1000001000001111111111101100101100110101100101\", 1),\n        (\"1101011110010101110000100010110110000010001101\", 1),\n        (\"1101111000110100001101000000011011000101001001\", 1),\n        (\"1111000011101100001000100110000111101110100011\", 1),\n        (\"10011000001111100110100111011000010001100001111\", 1),\n        (\n            \"1111111111111111101111101000011101000100001010110001100101110110\",\n            1,\n        ),\n        (\n            \"1111111111111111101011111111000001110100011010010001100100101000\",\n            1,\n        ),\n        (\"11010000001000101001101001110011011011010000011\", 1),\n        (\"11101111110000011100000111100110000000001011010\", 1),\n        (\"100011011110110010100010110100001001100100001000\", 1),\n    ];\n    let sample_median = (-8123231271792388, Some(-8096687505746509));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(91581052023966.92),\n        standard_deviation: NiceFloat(5.31973124263762e18),\n        skewness: NiceFloat(0.0012453230455855707),\n        excess_kurtosis: NiceFloat(-1.1981323295909574),\n    };\n    striped_random_signeds_helper::<i64>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // i64, m = 33/32\n    let values = &[\n        \"101010100101010101010101010101010101010101010101010101010101010\",\n        \"101010101010101010101010101010110101010101010101010101010101010\",\n        \"101010100101010101010101010101010101010101010101010101010101010\",\n        \"1010101010010101010101010101010101010101010101010101010101010110\",\n        \"11010101010101010101010101010101010101010101010101010101011010\",\n        \"1010101010101010101010101011010100101010101010101010100101010101\",\n        \"101010110101010101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101001010101010101010101010101010101010101\",\n        \"10101010101010101010101010101010101010101010101001101010101010\",\n        \"1101010101010101010101010101010101010011010101101010101010101010\",\n        \"1101010101010101011010101010101010101010101010101010101010101010\",\n        \"1101010101010101010101010101010101010101010101010101010101010101\",\n        \"10101010101010101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101010101010101010101010101010101010101010\",\n        \"1010101010101010101010101010101010101010101010101011010101010101\",\n        \"10100101010101010101010101010101010101010101010101010101010101\",\n        \"101001010101010101010101010101010101010101010101010101010101101\",\n        \"101010101010101010111010101010110101010101010101010101010101010\",\n        \"10101010101101010101010101010101010101010101010101010101010101\",\n        \"10101010101010101010101101010010101010110101010101101010101010\",\n    ];\n    let common_values = &[\n        (\n            \"101010101010101010101010101010101010101010101010101010101010101\",\n            37342,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010101010\",\n            37241,\n        ),\n        (\n            \"1101010101010101010101010101010101010101010101010101010101010101\",\n            37189,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010101010\",\n            37109,\n        ),\n        (\n            \"1010101010101010101010101010101010101001010101010101010101010101\",\n            1241,\n        ),\n        (\n            \"1101010101010101010101010101010101010110101010101010101010101010\",\n            1239,\n        ),\n        (\n            \"10101010101010101010101010101010101010101010101010101010100101\",\n            1235,\n        ),\n        (\n            \"1010101010101010101010101010101010101011010101010101010101010101\",\n            1233,\n        ),\n        (\n            \"1101011010101010101010101010101010101010101010101010101010101010\",\n            1231,\n        ),\n        (\n            \"1101010101010101010101010101010101010101010101010101010101010010\",\n            1227,\n        ),\n    ];\n    let sample_median = (-1489184412743849302, Some(-1489184412721829206));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2366723010422570.0),\n        standard_deviation: NiceFloat(4.878981868385203e18),\n        skewness: NiceFloat(0.0014056588570288651),\n        excess_kurtosis: NiceFloat(-1.6132504884076841),\n    };\n    striped_random_signeds_helper::<i64>(\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_signeds_fail_helper<T: PrimitiveSigned>() {\n    assert_panic!(striped_random_signeds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(striped_random_signeds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn striped_random_signeds_fail() {\n    apply_fn_to_signeds!(striped_random_signeds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_bit_chunks.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_unsigned_bit_chunks;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_unsigned_bit_chunks_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    chunk_size: u64,\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_unsigned_bit_chunks::<T>(\n        EXAMPLE_SEED,\n        chunk_size,\n        m_numerator,\n        m_denominator,\n    );\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_bit_chunks() {\n    // u8, chunk_size = 0, m = 4\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (0, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_unsigned_bit_chunks_helper::<u8>(\n        0,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, chunk_size = 3, m = 4\n    let values = &[\n        \"0\", \"0\", \"0\", \"101\", \"11\", \"100\", \"11\", \"11\", \"0\", \"111\", \"111\", \"100\", \"0\", \"11\", \"111\",\n        \"0\", \"0\", \"1\", \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"111\", 281415),\n        (\"0\", 280832),\n        (\"110\", 94370),\n        (\"11\", 93804),\n        (\"100\", 93374),\n        (\"1\", 93351),\n        (\"10\", 31559),\n        (\"101\", 31295),\n    ];\n    let sample_median = (4, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5039770000000354),\n        standard_deviation: NiceFloat(2.8721055747415143),\n        skewness: NiceFloat(-0.0024668908296986798),\n        excess_kurtosis: NiceFloat(-1.6474519863189017),\n    };\n    striped_random_unsigned_bit_chunks_helper::<u8>(\n        3,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // chunk_size = 1, u8, m = 2\n    let values = &[\n        \"0\", \"0\", \"0\", \"1\", \"0\", \"1\", \"0\", \"0\", \"0\", \"1\", \"1\", \"1\", \"0\", \"0\", \"1\", \"0\", \"0\", \"0\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[(\"1\", 500454), (\"0\", 499546)];\n    let sample_median = (1, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.500454000000004),\n        standard_deviation: NiceFloat(0.5000000438840368),\n        skewness: NiceFloat(-0.0018160007486136712),\n        excess_kurtosis: NiceFloat(-1.9999967021412284),\n    };\n    striped_random_unsigned_bit_chunks_helper::<u8>(\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // chunk_size = 6, u8, m = 5/4\n    let values = &[\n        \"10100\", \"10110\", \"10100\", \"100110\", \"10010\", \"101101\", \"10101\", \"10001\", \"10101\",\n        \"101001\", \"101101\", \"101010\", \"11011\", \"1101\", \"100001\", \"11110\", \"111\", \"101\", \"10110\",\n        \"10010\",\n    ];\n    let common_values = &[\n        (\"101010\", 164180),\n        (\"10101\", 164004),\n        (\"101011\", 41169),\n        (\"101101\", 41127),\n        (\"10010\", 41114),\n        (\"100101\", 40919),\n        (\"1010\", 40893),\n        (\"110101\", 40851),\n        (\"10110\", 40844),\n        (\"101001\", 40812),\n    ];\n    let sample_median = (32, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(31.51096499999948),\n        standard_deviation: NiceFloat(13.555827954398234),\n        skewness: NiceFloat(-0.0016679039370573313),\n        excess_kurtosis: NiceFloat(-1.0970963271830174),\n    };\n    striped_random_unsigned_bit_chunks_helper::<u8>(\n        6,\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // chunk_size = 45, u64, m = 32\n    let values = &[\n        \"11111111111\",\n        \"111111111111111111111\",\n        \"0\",\n        \"111111111111111111111111111000000000000000000\",\n        \"111111111\",\n        \"111111111111111111111111111111111100000000000\",\n        \"0\",\n        \"1111111111111111111111111111111111\",\n        \"1100000000111111111111111111111111111111\",\n        \"111111111111111111100000000000000011111111111\",\n        \"111111111111111111111111111111111111111100000\",\n        \"111111111111111111111111111111111111111111111\",\n        \"11111111111111111111111111\",\n        \"1111111\",\n        \"111111111111111110000000000000000000000000000\",\n        \"11111111111111\",\n        \"0\",\n        \"11111111111111111111111111111\",\n        \"11111111111111111111111111111111111111111111\",\n        \"1000000011111111111111111111111110000000\",\n    ];\n    let common_values = &[\n        (\"0\", 123843),\n        (\"111111111111111111111111111111111111111111111\", 123659),\n        (\"111111111111111100000000000000000000000000000\", 4110),\n        (\"111111110000000000000000000000000000000000000\", 4093),\n        (\"111111111111111111111111111111111\", 4092),\n        (\"1111111111111111111111111111111111\", 4081),\n        (\"11111111111111111111111111111111111111\", 4078),\n        (\"1111111\", 4072),\n        (\"111111111111111111111000000000000000000000000\", 4057),\n        (\"111111111111111111111111111111111111111110000\", 4051),\n    ];\n    let sample_median = (17592186044416, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(17607908125347.086),\n        standard_deviation: NiceFloat(16886338134364.322),\n        skewness: NiceFloat(-0.0018748788166730555),\n        excess_kurtosis: NiceFloat(-1.9429442153094645),\n    };\n    striped_random_unsigned_bit_chunks_helper::<u64>(\n        45,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // chunk_size = 4, u64, m = 2\n    let values = &[\n        \"11\", \"110\", \"11\", \"1100\", \"101\", \"1010\", \"110\", \"100\", \"101\", \"1101\", \"1111\", \"1100\",\n        \"111\", \"11\", \"1101\", \"100\", \"1\", \"10\", \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"1110\", 62873),\n        (\"1010\", 62820),\n        (\"1000\", 62739),\n        (\"100\", 62694),\n        (\"1001\", 62689),\n        (\"110\", 62619),\n        (\"1011\", 62601),\n        (\"11\", 62507),\n        (\"1100\", 62467),\n        (\"101\", 62457),\n    ];\n    let sample_median = (8, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.5009610000000775),\n        standard_deviation: NiceFloat(4.606733799393635),\n        skewness: NiceFloat(-0.0007329768450960305),\n        excess_kurtosis: NiceFloat(-1.20818908668768),\n    };\n    striped_random_unsigned_bit_chunks_helper::<u64>(\n        4,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // chunk_size = 10, u64, m = 33/32\n    let values = &[\n        \"101010101\",\n        \"101010101\",\n        \"101011010\",\n        \"1010101010\",\n        \"101010101\",\n        \"1010101010\",\n        \"101010101\",\n        \"101010101\",\n        \"101010001\",\n        \"1010101001\",\n        \"1010110101\",\n        \"1010101010\",\n        \"101101010\",\n        \"101101010\",\n        \"1010101101\",\n        \"101011010\",\n        \"101010101\",\n        \"101010010\",\n        \"101010101\",\n        \"101010101\",\n    ];\n    let common_values = &[\n        (\"1010101010\", 379066),\n        (\"101010101\", 378152),\n        (\"1010110101\", 12071),\n        (\"101011010\", 12069),\n        (\"101001010\", 12042),\n        (\"1011010101\", 11977),\n        (\"101010110\", 11960),\n        (\"1001010101\", 11941),\n        (\"1010010101\", 11934),\n        (\"100101010\", 11903),\n    ];\n    let sample_median = (565, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(511.639053000003),\n        standard_deviation: NiceFloat(177.48758065877436),\n        skewness: NiceFloat(-0.0017256448985827214),\n        excess_kurtosis: NiceFloat(-1.734924505103183),\n    };\n    striped_random_unsigned_bit_chunks_helper::<u64>(\n        10,\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_unsigned_bit_chunks_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(striped_random_unsigned_bit_chunks::<T>(\n        EXAMPLE_SEED,\n        4,\n        1,\n        0\n    ));\n    assert_panic!(striped_random_unsigned_bit_chunks::<T>(\n        EXAMPLE_SEED,\n        4,\n        2,\n        3\n    ));\n    assert_panic!(striped_random_unsigned_bit_chunks::<T>(\n        EXAMPLE_SEED,\n        200,\n        4,\n        1\n    ));\n}\n\n#[test]\nfn striped_random_unsigned_bit_chunks_fail() {\n    apply_fn_to_unsigneds!(striped_random_unsigned_bit_chunks_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_unsigned_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_unsigned_inclusive_range_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    a: T,\n    b: T,\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        a,\n        b,\n        m_numerator,\n        m_denominator,\n    );\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_inclusive_range() {\n    // u8, 5, 5, m = 4\n    let values = &[\"101\"; 20];\n    let common_values = &[(\"101\", 1000000)];\n    let sample_median = (5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_unsigned_inclusive_range_helper::<u8>(\n        5,\n        5,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, 0, 7, m = 4\n    let values = &[\n        \"0\", \"0\", \"0\", \"101\", \"11\", \"100\", \"11\", \"11\", \"0\", \"111\", \"111\", \"100\", \"0\", \"11\", \"111\",\n        \"0\", \"0\", \"1\", \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"111\", 281415),\n        (\"0\", 280832),\n        (\"110\", 94370),\n        (\"11\", 93804),\n        (\"100\", 93374),\n        (\"1\", 93351),\n        (\"10\", 31559),\n        (\"101\", 31295),\n    ];\n    let sample_median = (4, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5039770000000354),\n        standard_deviation: NiceFloat(2.8721055747415143),\n        skewness: NiceFloat(-0.0024668908296986798),\n        excess_kurtosis: NiceFloat(-1.6474519863189017),\n    };\n    striped_random_unsigned_inclusive_range_helper::<u8>(\n        0,\n        7,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, 1, 6, m = 4\n    let values = &[\n        \"1\", \"1\", \"1\", \"110\", \"1\", \"110\", \"10\", \"11\", \"11\", \"100\", \"100\", \"110\", \"1\", \"1\", \"110\",\n        \"1\", \"1\", \"11\", \"1\", \"1\",\n    ];\n    let common_values = &[\n        (\"110\", 375034),\n        (\"1\", 374765),\n        (\"100\", 93832),\n        (\"11\", 93634),\n        (\"101\", 31588),\n        (\"10\", 31147),\n    ];\n    let sample_median = (4, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5014329999999694),\n        standard_deviation: NiceFloat(2.207774177939804),\n        skewness: NiceFloat(-0.0014160236801414635),\n        excess_kurtosis: NiceFloat(-1.753353488243057),\n    };\n    striped_random_unsigned_inclusive_range_helper::<u8>(\n        1,\n        6,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u16, 10000, 20000, m = 4\n    let values = &[\n        \"10011100011111\",\n        \"11010011001111\",\n        \"10011100011100\",\n        \"100111000011111\",\n        \"11111100000000\",\n        \"10011100111100\",\n        \"10011110110000\",\n        \"100000000000111\",\n        \"11111111111111\",\n        \"10101111001111\",\n        \"100111000000000\",\n        \"11000000000111\",\n        \"11111111000000\",\n        \"100000000001111\",\n        \"100000000101100\",\n        \"100011110000000\",\n        \"100100011110010\",\n        \"100011000000111\",\n        \"100110111111111\",\n        \"11111111110100\",\n    ];\n    let common_values = &[\n        (\"100111000100000\", 70337),\n        (\"100111000000000\", 16785),\n        (\"10011111111111\", 12552),\n        (\"10011100010000\", 11029),\n        (\"10011100011111\", 11017),\n        (\"100000000000000\", 10528),\n        (\"11111111111111\", 8012),\n        (\"100111000000111\", 5466),\n        (\"100111000000001\", 5462),\n        (\"100111000001111\", 5448),\n    ];\n    let sample_median = (16383, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(15546.241523000184),\n        standard_deviation: NiceFloat(3460.441923849274),\n        skewness: NiceFloat(-0.39481033379336405),\n        excess_kurtosis: NiceFloat(-1.1600583805474893),\n    };\n    striped_random_unsigned_inclusive_range_helper::<u16>(\n        10000,\n        20000,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_unsigned_inclusive_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(striped_random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::ONE,\n        5,\n        1,\n    ));\n    assert_panic!(striped_random_unsigned_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n    ));\n}\n\n#[test]\nfn striped_random_unsigned_inclusive_range_fail() {\n    apply_fn_to_unsigneds!(striped_random_unsigned_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_unsigned_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_unsigned_range_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    a: T,\n    b: T,\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_unsigned_range::<T>(EXAMPLE_SEED, a, b, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_range() {\n    // u8, 5, 6, m = 4\n    let values = &[\"101\"; 20];\n    let common_values = &[(\"101\", 1000000)];\n    let sample_median = (5, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_unsigned_range_helper::<u8>(\n        5,\n        6,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, 0, 8, m = 4\n    let values = &[\n        \"0\", \"0\", \"0\", \"101\", \"11\", \"100\", \"11\", \"11\", \"0\", \"111\", \"111\", \"100\", \"0\", \"11\", \"111\",\n        \"0\", \"0\", \"1\", \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"111\", 281415),\n        (\"0\", 280832),\n        (\"110\", 94370),\n        (\"11\", 93804),\n        (\"100\", 93374),\n        (\"1\", 93351),\n        (\"10\", 31559),\n        (\"101\", 31295),\n    ];\n    let sample_median = (4, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5039770000000354),\n        standard_deviation: NiceFloat(2.8721055747415143),\n        skewness: NiceFloat(-0.0024668908296986798),\n        excess_kurtosis: NiceFloat(-1.6474519863189017),\n    };\n    striped_random_unsigned_range_helper::<u8>(\n        0,\n        8,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, 1, 7, m = 4\n    let values = &[\n        \"1\", \"1\", \"1\", \"110\", \"1\", \"110\", \"10\", \"11\", \"11\", \"100\", \"100\", \"110\", \"1\", \"1\", \"110\",\n        \"1\", \"1\", \"11\", \"1\", \"1\",\n    ];\n    let common_values = &[\n        (\"110\", 375034),\n        (\"1\", 374765),\n        (\"100\", 93832),\n        (\"11\", 93634),\n        (\"101\", 31588),\n        (\"10\", 31147),\n    ];\n    let sample_median = (4, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.5014329999999694),\n        standard_deviation: NiceFloat(2.207774177939804),\n        skewness: NiceFloat(-0.0014160236801414635),\n        excess_kurtosis: NiceFloat(-1.753353488243057),\n    };\n    striped_random_unsigned_range_helper::<u8>(\n        1,\n        7,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u16, 10000, 20001, m = 4\n    let values = &[\n        \"10011100011111\",\n        \"11010011001111\",\n        \"10011100011100\",\n        \"100111000011111\",\n        \"11111100000000\",\n        \"10011100111100\",\n        \"10011110110000\",\n        \"100000000000111\",\n        \"11111111111111\",\n        \"10101111001111\",\n        \"100111000000000\",\n        \"11000000000111\",\n        \"11111111000000\",\n        \"100000000001111\",\n        \"100000000101100\",\n        \"100011110000000\",\n        \"100100011110010\",\n        \"100011000000111\",\n        \"100110111111111\",\n        \"11111111110100\",\n    ];\n    let common_values = &[\n        (\"100111000100000\", 70337),\n        (\"100111000000000\", 16785),\n        (\"10011111111111\", 12552),\n        (\"10011100010000\", 11029),\n        (\"10011100011111\", 11017),\n        (\"100000000000000\", 10528),\n        (\"11111111111111\", 8012),\n        (\"100111000000111\", 5466),\n        (\"100111000000001\", 5462),\n        (\"100111000001111\", 5448),\n    ];\n    let sample_median = (16383, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(15546.241523000184),\n        standard_deviation: NiceFloat(3460.441923849274),\n        skewness: NiceFloat(-0.39481033379336405),\n        excess_kurtosis: NiceFloat(-1.1600583805474893),\n    };\n    striped_random_unsigned_range_helper::<u16>(\n        10000,\n        20001,\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_unsigned_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(striped_random_unsigned_range::<T>(\n        EXAMPLE_SEED,\n        T::TWO,\n        T::TWO,\n        5,\n        1,\n    ));\n    assert_panic!(striped_random_unsigned_range::<T>(\n        EXAMPLE_SEED,\n        T::ONE,\n        T::TWO,\n        1,\n        1,\n    ));\n}\n\n#[test]\nfn striped_random_unsigned_range_fail() {\n    apply_fn_to_unsigneds!(striped_random_unsigned_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::striped::striped_random_unsigned_vecs;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_unsigned_vecs_helper<T: PrimitiveUnsigned>(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[&str]],\n    expected_common_values: &[(&[&str], usize)],\n    expected_median: (&[&str], Option<&[&str]>),\n) {\n    let xss = striped_random_unsigned_vecs::<T>(\n        EXAMPLE_SEED,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xss\n        .clone()\n        .take(20)\n        .map(|xs| {\n            xs.into_iter()\n                .map(|x: T| x.to_binary_string())\n                .collect_vec()\n        })\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xss.clone())\n        .into_iter()\n        .map(|(xs, freq)| {\n            (\n                xs.into_iter()\n                    .map(|x: T| x.to_binary_string())\n                    .collect_vec(),\n                freq,\n            )\n        })\n        .collect_vec();\n    let (median_lo, median_hi) = median(xss.take(1000000));\n    let median_lo = median_lo\n        .into_iter()\n        .map(|x: T| x.to_binary_string())\n        .collect_vec();\n    let median_hi = median_hi.map(|xs| {\n        xs.into_iter()\n            .map(|x: T| x.to_binary_string())\n            .collect_vec()\n    });\n\n    let values = values\n        .iter()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec())\n        .collect_vec();\n    let common_values = common_values\n        .iter()\n        .map(|(xs, freq)| (xs.iter().map(String::as_str).collect_vec(), *freq))\n        .collect_vec();\n    let median_lo = median_lo.iter().map(String::as_str).collect_vec();\n    let median_hi = median_hi\n        .as_ref()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec());\n    assert_eq!(\n        (\n            values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(xs, f)| (xs.as_slice(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_slice(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_vecs() {\n    striped_random_unsigned_vecs_helper::<u8>(\n        2,\n        1,\n        4,\n        1,\n        &[\n            &[],\n            &[\n                \"11001100\", \"11000\", \"11001\", \"10111101\", \"10111110\", \"110000\", \"11010011\", \"11\",\n                \"1110110\", \"11100011\", \"1\", \"1100101\", \"10111110\", \"11010111\",\n            ],\n            &[\"101110\", \"1111000\", \"10110010\", \"11101110\"],\n            &[\"10110110\", \"11000010\", \"11111010\", \"1100110\"],\n            &[\"1000\"],\n            &[],\n            &[\"10100000\", \"100101\", \"1000010\", \"1100110\", \"11000111\"],\n            &[\"111\", \"11100001\"],\n            &[\"1010110\", \"10101110\", \"10111000\", \"10111101\"],\n            &[],\n            &[\"101011\", \"10\", \"1110101\", \"1110001\", \"11101111\", \"10001001\"],\n            &[],\n            &[],\n            &[\n                \"10000100\", \"11110101\", \"11011100\", \"10011111\", \"10001000\", \"11001111\", \"1111000\",\n                \"11010111\", \"1101001\", \"111110\", \"1100100\",\n            ],\n            &[\n                \"10101\", \"11011001\", \"10100000\", \"10100001\", \"1101100\", \"1101111\", \"10100011\",\n                \"11110101\",\n            ],\n            &[],\n            &[\"10111111\", \"100111\", \"1111110\"],\n            &[],\n            &[\"11000\", \"11110010\", \"11111\", \"1110011\", \"11110011\"],\n            &[\n                \"10001110\", \"10011\", \"1100101\", \"111100\", \"10110111\", \"1101110\", \"100001\",\n                \"10000000\", \"10101100\",\n            ],\n        ],\n        &[\n            (&[], 199913),\n            (&[\"11010010\"], 689),\n            (&[\"11\"], 688),\n            (&[\"11110111\"], 681),\n            (&[\"10000110\"], 673),\n            (&[\"110010\"], 672),\n            (&[\"11101111\"], 671),\n            (&[\"1000100\"], 670),\n            (&[\"1111101\"], 670),\n            (&[\"11110010\"], 670),\n        ],\n        (&[\"1100000\"], None),\n    );\n    striped_random_unsigned_vecs_helper::<u8>(\n        10,\n        1,\n        4,\n        1,\n        &[\n            &[],\n            &[\n                \"0\", \"0\", \"111000\", \"0\", \"11111110\", \"10000001\", \"11111111\", \"11\", \"0\", \"0\", \"0\",\n                \"11111111\", \"11111111\", \"11111\",\n            ],\n            &[\"11110000\", \"11111111\", \"11111101\", \"1111111\"],\n            &[\"0\", \"0\", \"11100000\", \"1\"],\n            &[\"11111110\"],\n            &[],\n            &[\"0\", \"0\", \"10011000\", \"11111111\", \"111\"],\n            &[\"11111111\", \"11111111\"],\n            &[\"0\", \"0\", \"0\", \"0\"],\n            &[],\n            &[\"11111111\", \"11111110\", \"11111111\", \"11111111\", \"11111\", \"0\"],\n            &[],\n            &[],\n            &[\n                \"0\", \"0\", \"0\", \"0\", \"11111100\", \"111011\", \"0\", \"1111000\", \"111\", \"1101000\",\n                \"11011111\",\n            ],\n            &[\n                \"11111111\", \"11111111\", \"11111111\", \"11111\", \"11000000\", \"11\", \"11001000\",\n                \"11111111\",\n            ],\n            &[],\n            &[\"1\", \"11100000\", \"11111111\"],\n            &[],\n            &[\"1000\", \"0\", \"0\", \"11111111\", \"1111\"],\n            &[\"0\", \"10000000\", \"111\", \"10000000\", \"111111\", \"0\", \"0\", \"11111000\", \"11111111\"],\n        ],\n        &[\n            (&[], 199913),\n            (&[\"0\"], 38129),\n            (&[\"11111111\"], 38051),\n            (&[\"0\", \"0\"], 13204),\n            (&[\"11111111\", \"11111111\"], 13153),\n            (&[\"0\", \"0\", \"0\"], 4662),\n            (&[\"11111111\", \"11111111\", \"11111111\"], 4549),\n            (&[\"1\"], 4369),\n            (&[\"11111100\"], 4338),\n            (&[\"11111\"], 4311),\n        ],\n        (&[\"11100\", \"11111110\", \"111111\", \"0\"], None),\n    );\n    striped_random_unsigned_vecs_helper::<u8>(\n        11,\n        10,\n        4,\n        1,\n        &[\n            &[],\n            &[\n                \"1011010\", \"11010101\", \"1001010\", \"10110101\", \"11010110\", \"10101010\", \"10101010\",\n                \"1101010\", \"10100101\", \"10101010\", \"10011010\", \"1010010\", \"1010101\", \"1010101\",\n            ],\n            &[\"10101010\", \"1010110\", \"101011\", \"1010101\"],\n            &[\"1010100\", \"1010101\", \"1010101\", \"10101010\"],\n            &[\"1101010\"],\n            &[],\n            &[\"1001010\", \"1010101\", \"1010101\", \"1010101\", \"1001001\"],\n            &[\"10101011\", \"10101010\"],\n            &[\"10101010\", \"10101101\", \"10101010\", \"1011010\"],\n            &[],\n            &[\"10101011\", \"10101010\", \"10101010\", \"11010\", \"11010\", \"1010111\"],\n            &[],\n            &[],\n            &[\n                \"10101010\", \"1001011\", \"11010101\", \"1010010\", \"1010101\", \"10101010\", \"101010\",\n                \"1010101\", \"10101001\", \"1101010\", \"1010101\",\n            ],\n            &[\n                \"1010101\", \"1010101\", \"1010101\", \"10110101\", \"10100100\", \"10110100\", \"10101010\",\n                \"10101010\",\n            ],\n            &[],\n            &[\"1010101\", \"10100101\", \"10101010\"],\n            &[],\n            &[\"10101010\", \"1010100\", \"1101010\", \"10100101\", \"1001010\"],\n            &[\n                \"10101100\", \"10101010\", \"10101010\", \"10010101\", \"10101010\", \"10101101\", \"10101010\",\n                \"1001010\", \"1010101\",\n            ],\n        ],\n        &[\n            (&[], 199913),\n            (&[\"1010101\"], 41088),\n            (&[\"10101010\"], 40900),\n            (&[\"1010101\", \"1010101\"], 15274),\n            (&[\"10101010\", \"10101010\"], 15212),\n            (&[\"10101010\", \"10101010\", \"10101010\"], 5901),\n            (&[\"1010101\", \"1010101\", \"1010101\"], 5641),\n            (&[\"10101001\"], 4206),\n            (&[\"10100101\"], 4201),\n            (&[\"10101101\"], 4181),\n        ],\n        (&[\"1010101\", \"10110101\"], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_fail_1() {\n    striped_random_unsigned_vecs::<u8>(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_fail_2() {\n    striped_random_unsigned_vecs::<u8>(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_fail_3() {\n    striped_random_unsigned_vecs::<u8>(EXAMPLE_SEED, 4, 1, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_fail_4() {\n    striped_random_unsigned_vecs::<u8>(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_fail_5() {\n    striped_random_unsigned_vecs::<u8>(EXAMPLE_SEED, 4, 1, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_vecs_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::striped::striped_random_unsigned_vecs_from_length_iterator;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::vecs::random_values_from_vec;\nuse std::iter::repeat;\n\nfn striped_random_unsigned_vecs_from_length_iterator_helper<\n    T: PrimitiveUnsigned,\n    I: Clone + Iterator<Item = u64>,\n>(\n    lengths_gen: &dyn Fn(Seed) -> I,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&[&str]],\n    expected_common_values: &[(&[&str], usize)],\n    expected_median: (&[&str], Option<&[&str]>),\n) {\n    let xss = striped_random_unsigned_vecs_from_length_iterator::<T, _>(\n        EXAMPLE_SEED,\n        lengths_gen,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xss\n        .clone()\n        .take(20)\n        .map(|xs| {\n            xs.into_iter()\n                .map(|x: T| x.to_binary_string())\n                .collect_vec()\n        })\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xss.clone())\n        .into_iter()\n        .map(|(xs, freq)| {\n            (\n                xs.into_iter()\n                    .map(|x: T| x.to_binary_string())\n                    .collect_vec(),\n                freq,\n            )\n        })\n        .collect_vec();\n    let (median_lo, median_hi) = median(xss.take(1000000));\n    let median_lo = median_lo\n        .into_iter()\n        .map(|x: T| x.to_binary_string())\n        .collect_vec();\n    let median_hi = median_hi.map(|xs| {\n        xs.into_iter()\n            .map(|x: T| x.to_binary_string())\n            .collect_vec()\n    });\n\n    let values = values\n        .iter()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec())\n        .collect_vec();\n    let common_values = common_values\n        .iter()\n        .map(|(xs, freq)| (xs.iter().map(String::as_str).collect_vec(), *freq))\n        .collect_vec();\n    let median_lo = median_lo.iter().map(String::as_str).collect_vec();\n    let median_hi = median_hi\n        .as_ref()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec());\n    assert_eq!(\n        (\n            values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(xs, f)| (xs.as_slice(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_slice(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_vecs_from_length_iterator() {\n    striped_random_unsigned_vecs_from_length_iterator_helper::<u8, _>(\n        &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n        2,\n        1,\n        &[\n            &[\"11001100\", \"11000\"],\n            &[\"110010\", \"1111010\", \"1111101\", \"1100001\"],\n            &[\"1001100\", \"1111\"],\n            &[\"10110000\", \"11011\", \"1111\", \"101000\"],\n            &[\"11100110\", \"1111011\", \"10001101\", \"111110\"],\n            &[\"100111\", \"11101011\"],\n            &[],\n            &[\"1100010\", \"101011\"],\n            &[],\n            &[\"10100111\", \"100000\", \"1110011\", \"11111111\"],\n            &[\"1011010\", \"100010\", \"1100100\", \"1110110\"],\n            &[\"10000111\", \"11101111\"],\n            &[\"1100011\", \"11100101\", \"10001010\", \"11011011\"],\n            &[\"1001000\", \"11011101\"],\n            &[\"10100000\", \"101110\", \"11101110\", \"111101\"],\n            &[\"1100010\", \"1001111\", \"1100001\", \"100\"],\n            &[\"100111\", \"11100010\", \"110011\", \"11011110\"],\n            &[],\n            &[\"10100\", \"11001011\", \"11100000\", \"1001101\"],\n            &[],\n        ],\n        &[\n            (&[], 333820),\n            (&[\"11110010\", \"1100111\"], 17),\n            (&[\"10010101\", \"101\"], 16),\n            (&[\"11010100\", \"1100001\"], 16),\n            (&[\"1111101\", \"11100000\"], 16),\n            (&[\"11111111\", \"1111000\"], 16),\n            (&[\"101100\", \"110101\"], 15),\n            (&[\"1010111\", \"1010000\"], 15),\n            (&[\"10101\", \"1111110\"], 15),\n            (&[\"11110111\", \"10000\"], 15),\n        ],\n        (\n            &[\"111111\", \"11110001\", \"11111010\", \"10100110\"],\n            Some(&[\"111111\", \"11110010\"]),\n        ),\n    );\n    striped_random_unsigned_vecs_from_length_iterator_helper::<u8, _>(\n        &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n        10,\n        1,\n        &[\n            &[\"0\", \"0\"],\n            &[\"1110000\", \"0\", \"11111100\", \"11\"],\n            &[\"11111110\", \"1111\"],\n            &[\"0\", \"0\", \"0\", \"11111000\"],\n            &[\"0\", \"0\", \"1111110\", \"0\"],\n            &[\"11011111\", \"11111111\"],\n            &[],\n            &[\"11110000\", \"11111111\"],\n            &[],\n            &[\"11111111\", \"11000011\", \"11111\", \"0\"],\n            &[\"0\", \"10000000\", \"11111001\", \"1111111\"],\n            &[\"11111111\", \"11111111\"],\n            &[\"11111111\", \"11111111\", \"11111111\", \"11111111\"],\n            &[\"0\", \"10000\"],\n            &[\"0\", \"0\", \"0\", \"11111100\"],\n            &[\"0\", \"0\", \"0\", \"0\"],\n            &[\"11111111\", \"0\", \"11110001\", \"11111111\"],\n            &[],\n            &[\"10111100\", \"11\", \"10110100\", \"11101111\"],\n            &[],\n        ],\n        &[\n            (&[], 333820),\n            (&[\"11111111\", \"11111111\"], 34254),\n            (&[\"0\", \"0\"], 34215),\n            (&[\"11111111\", \"11111111\", \"11111111\", \"11111111\"], 6413),\n            (&[\"0\", \"0\", \"0\", \"0\"], 6336),\n            (&[\"11111111\", \"11111\"], 3951),\n            (&[\"111111\", \"0\"], 3891),\n            (&[\"11111110\", \"11111111\"], 3890),\n            (&[\"11111111\", \"0\"], 3889),\n            (&[\"11111111\", \"1111\"], 3878),\n        ],\n        (&[\"1\", \"0\", \"11111110\", \"11111111\"], None),\n    );\n    striped_random_unsigned_vecs_from_length_iterator_helper::<u8, _>(\n        &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n        11,\n        10,\n        &[\n            &[\"1011010\", \"11010101\"],\n            &[\"1101010\", \"10010101\", \"1010010\", \"10101010\"],\n            &[\"10101010\", \"10101010\"],\n            &[\"11010100\", \"10101010\", \"101010\", \"1101011\"],\n            &[\"10101010\", \"10101010\", \"10101010\", \"1001010\"],\n            &[\"10110101\", \"1010010\"],\n            &[],\n            &[\"1001010\", \"1010101\"],\n            &[],\n            &[\"1010101\", \"10110101\", \"10101010\", \"1010110\"],\n            &[\"1010100\", \"1010101\", \"1010101\", \"10010101\"],\n            &[\"1001001\", \"1010101\"],\n            &[\"1010101\", \"100101\", \"1010101\", \"1010101\"],\n            &[\"10110100\", \"10101010\"],\n            &[\"10101010\", \"10101010\", \"10111100\", \"11100\"],\n            &[\"10101010\", \"10001010\", \"1010110\", \"10100101\"],\n            &[\"10101011\", \"1101010\", \"1010101\", \"10110101\"],\n            &[],\n            &[\"10101010\", \"1010100\", \"10110101\", \"10101010\"],\n            &[],\n        ],\n        &[\n            (&[], 333820),\n            (&[\"1010101\", \"1010101\"], 39945),\n            (&[\"10101010\", \"10101010\"], 39772),\n            (&[\"1010101\", \"1010101\", \"1010101\", \"1010101\"], 8708),\n            (&[\"10101010\", \"10101010\", \"10101010\", \"10101010\"], 8700),\n            (&[\"1010010\", \"1010101\"], 4100),\n            (&[\"1010101\", \"10110101\"], 4090),\n            (&[\"1010101\", \"11010101\"], 4089),\n            (&[\"1010101\", \"10101101\"], 4080),\n            (&[\"1010110\", \"1010101\"], 4060),\n        ],\n        (&[\"1010101\", \"1010101\", \"1010101\", \"10110101\"], None),\n    );\n    striped_random_unsigned_vecs_from_length_iterator_helper::<u8, _>(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        2,\n        1,\n        &[\n            &[\n                \"11001100\", \"11000\", \"11001\", \"10111101\", \"10111110\", \"110000\", \"11010011\", \"11\",\n                \"1110110\", \"11100011\", \"1\", \"1100101\",\n            ],\n            &[\"1111100\", \"10101111\"],\n            &[\n                \"1011100\", \"11110000\", \"1100100\", \"11011101\", \"1001001\", \"111101\", \"101\",\n                \"10011001\", \"11111011\", \"10010111\", \"1110110\", \"1101111\", \"100110\", \"1110\",\n                \"11011111\", \"1100011\",\n            ],\n            &[\"11001010\", \"10101\"],\n            &[\n                \"1101110\", \"1101111\", \"1000101\", \"10100000\", \"101110\", \"11101110\", \"111101\",\n                \"10110001\", \"10100111\", \"110000\", \"10\", \"1110110\", \"111\", \"1110011\", \"10001000\",\n                \"1100010\", \"11001\", \"10111100\", \"10101001\", \"11001000\", \"110\", \"1101\", \"1100101\",\n                \"1111011\", \"11011\", \"10101101\", \"11111111\", \"10011110\",\n            ],\n            &[],\n            &[\n                \"11110001\", \"1100011\", \"11001000\", \"1111111\", \"11001100\", \"11001101\", \"11100011\",\n                \"11011000\", \"110101\", \"10000111\",\n            ],\n            &[\n                \"11011100\", \"10111010\", \"10000101\", \"0\", \"10110010\", \"10010010\", \"10111000\",\n                \"10010100\",\n            ],\n            &[\"11010001\", \"1111000\"],\n            &[],\n            &[\n                \"1010100\", \"10101110\", \"1000001\", \"1001011\", \"1011100\", \"10110100\", \"11001000\",\n                \"1101\", \"10010101\", \"10111011\", \"1111000\", \"1011\",\n            ],\n            &[\"1010011\", \"111001\", \"10101111\", \"1100101\"],\n            &[],\n            &[],\n            &[\"10010001\", \"11010001\"],\n            &[\"10111110\", \"11101111\", \"11101011\", \"10010\", \"1101101\", \"1010110\"],\n            &[],\n            &[\"100110\", \"10001010\"],\n            &[],\n            &[\"1101100\", \"11000\"],\n        ],\n        &[\n            (&[], 333981),\n            (&[\"1\", \"10011100\"], 13),\n            (&[\"11111011\", \"110100\"], 13),\n            (&[\"110000\", \"10110111\"], 13),\n            (&[\"1100110\", \"10011000\"], 13),\n            (&[\"11101100\", \"11011100\"], 13),\n            (&[\"1\", \"100101\"], 12),\n            (&[\"100010\", \"101100\"], 12),\n            (&[\"1010\", \"11000011\"], 12),\n            (&[\"1100101\", \"1001101\"], 12),\n        ],\n        (&[\"111111\", \"10101111\"], None),\n    );\n    striped_random_unsigned_vecs_from_length_iterator_helper::<u8, _>(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        10,\n        1,\n        &[\n            &[\n                \"0\", \"0\", \"111000\", \"0\", \"11111110\", \"10000001\", \"11111111\", \"11\", \"0\", \"0\", \"0\",\n                \"11111111\",\n            ],\n            &[\"0\", \"11000000\"],\n            &[\n                \"11100000\", \"11111111\", \"11111011\", \"11111111\", \"0\", \"0\", \"11100000\", \"1\",\n                \"11111111\", \"11111111\", \"11111111\", \"11001\", \"0\", \"11111110\", \"11111111\",\n                \"11111111\",\n            ],\n            &[\"0\", \"0\"],\n            &[\n                \"0\", \"0\", \"100000\", \"0\", \"0\", \"0\", \"11111100\", \"11111111\", \"11111111\", \"11111111\",\n                \"11111111\", \"111111\", \"1000000\", \"11111100\", \"1111111\", \"10001000\", \"1111111\",\n                \"1001\", \"10\", \"0\", \"0\", \"0\", \"11111111\", \"11100001\", \"10111111\", \"1\", \"11111000\",\n                \"1111111\",\n            ],\n            &[],\n            &[\n                \"11111111\", \"11011111\", \"11111111\", \"11111111\", \"11\", \"11000000\", \"11111111\",\n                \"11111111\", \"11110000\", \"11111111\",\n            ],\n            &[\"11111110\", \"0\", \"0\", \"11100000\", \"11111111\", \"1111\", \"0\", \"11111111\"],\n            &[\"11110011\", \"11111111\"],\n            &[],\n            &[\n                \"10001000\", \"11111111\", \"11\", \"11111110\", \"0\", \"11111100\", \"11111111\", \"11111111\",\n                \"11111111\", \"11\", \"11111111\", \"11111\",\n            ],\n            &[\"11111111\", \"1100001\", \"0\", \"11100000\"],\n            &[],\n            &[],\n            &[\"11111111\", \"11111111\"],\n            &[\"11111000\", \"1111111\", \"0\", \"10000000\", \"111\", \"1111\"],\n            &[],\n            &[\"0\", \"0\"],\n            &[],\n            &[\"0\", \"0\"],\n        ],\n        &[\n            (&[], 333981),\n            (&[\"0\", \"0\"], 22998),\n            (&[\"11111111\", \"11111111\"], 22759),\n            (&[\"11111111\", \"11111111\", \"11111111\", \"11111111\"], 2851),\n            (&[\"0\", \"0\", \"0\", \"0\"], 2788),\n            (&[\"11111111\", \"111111\"], 2626),\n            (&[\"1111\", \"0\"], 2620),\n            (&[\"111\", \"0\"], 2615),\n            (&[\"111111\", \"0\"], 2608),\n            (&[\"11111000\", \"11111111\"], 2608),\n        ],\n        (\n            &[\"1\", \"0\", \"11111000\", \"1\", \"1111100\", \"0\", \"0\", \"100000\"],\n            Some(&[\"1\", \"0\", \"11111000\", \"1\", \"10000000\", \"11111111\", \"11111111\", \"11111111\"]),\n        ),\n    );\n    striped_random_unsigned_vecs_from_length_iterator_helper::<u8, _>(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        11,\n        10,\n        &[\n            &[\n                \"1011010\", \"11010101\", \"1001010\", \"10110101\", \"11010110\", \"10101010\", \"10101010\",\n                \"1101010\", \"10100101\", \"10101010\", \"10011010\", \"1010010\",\n            ],\n            &[\"10101010\", \"10101010\"],\n            &[\n                \"10101010\", \"1010010\", \"10101001\", \"1010101\", \"10101011\", \"10101010\", \"10101010\",\n                \"1010101\", \"10110101\", \"1010010\", \"1010101\", \"1010101\", \"1010101\", \"10010010\",\n                \"10101010\", \"10101010\",\n            ],\n            &[\"1001010\", \"10101010\"],\n            &[\n                \"10101010\", \"10010110\", \"10101010\", \"10101010\", \"10101010\", \"10111100\", \"11100\",\n                \"1010101\", \"1000101\", \"10101011\", \"11010010\", \"10101010\", \"1011010\", \"1010101\",\n                \"10101101\", \"1101010\", \"1010101\", \"10101001\", \"10101010\", \"10101010\", \"10101010\",\n                \"10101010\", \"100101\", \"10100101\", \"1010101\", \"1010101\", \"1010101\", \"10010101\",\n            ],\n            &[],\n            &[\n                \"1010101\", \"1010101\", \"10101101\", \"1010110\", \"1101010\", \"11010101\", \"10100110\",\n                \"10101010\", \"10101010\", \"11010100\",\n            ],\n            &[\n                \"10101010\", \"10110110\", \"10101010\", \"101010\", \"1010101\", \"1010101\", \"10101010\",\n                \"10101010\",\n            ],\n            &[\"10010101\", \"10101010\"],\n            &[],\n            &[\n                \"10101010\", \"1001010\", \"1010101\", \"1011101\", \"10010101\", \"10101010\", \"10101010\",\n                \"10101010\", \"10101010\", \"10110101\", \"10010100\", \"1010101\",\n            ],\n            &[\"1010101\", \"1010101\", \"1010101\", \"1010101\"],\n            &[],\n            &[],\n            &[\"1010101\", \"1001010\"],\n            &[\"1001010\", \"10101101\", \"11010010\", \"10101010\", \"1101010\", \"1010101\"],\n            &[],\n            &[\"10000100\", \"10101010\"],\n            &[],\n            &[\"10101010\", \"101010\"],\n        ],\n        &[\n            (&[], 333981),\n            (&[\"10101010\", \"10101010\"], 26752),\n            (&[\"1010101\", \"1010101\"], 26461),\n            (&[\"10101010\", \"10101010\", \"10101010\", \"10101010\"], 3857),\n            (&[\"1010101\", \"1010101\", \"1010101\", \"1010101\"], 3852),\n            (&[\"10101010\", \"1010010\"], 2802),\n            (&[\"1010110\", \"1010101\"], 2776),\n            (&[\"1010101\", \"10100101\"], 2768),\n            (&[\"1010101\", \"10010101\"], 2739),\n            (&[\"10101011\", \"10101010\"], 2730),\n        ],\n        (&[\"1010101\", \"1010101\", \"10010101\", \"10101010\"], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_from_length_iterator_fail_1() {\n    striped_random_unsigned_vecs_from_length_iterator::<u8, _>(EXAMPLE_SEED, &|_| repeat(1), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_from_length_iterator_fail_2() {\n    striped_random_unsigned_vecs_from_length_iterator::<u8, _>(EXAMPLE_SEED, &|_| repeat(1), 2, 3);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::striped::striped_random_unsigned_vecs_length_inclusive_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_unsigned_vecs_length_inclusive_range_helper<T: PrimitiveUnsigned>(\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&[&str]],\n    expected_common_values: &[(&[&str], usize)],\n    expected_median: (&[&str], Option<&[&str]>),\n) {\n    let xss = striped_random_unsigned_vecs_length_inclusive_range::<T>(\n        EXAMPLE_SEED,\n        a,\n        b,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xss\n        .clone()\n        .take(20)\n        .map(|xs| {\n            xs.into_iter()\n                .map(|x: T| x.to_binary_string())\n                .collect_vec()\n        })\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xss.clone())\n        .into_iter()\n        .map(|(xs, freq)| {\n            (\n                xs.into_iter()\n                    .map(|x: T| x.to_binary_string())\n                    .collect_vec(),\n                freq,\n            )\n        })\n        .collect_vec();\n    let (median_lo, median_hi) = median(xss.take(1000000));\n    let median_lo = median_lo\n        .into_iter()\n        .map(|x: T| x.to_binary_string())\n        .collect_vec();\n    let median_hi = median_hi.map(|xs| {\n        xs.into_iter()\n            .map(|x: T| x.to_binary_string())\n            .collect_vec()\n    });\n\n    let values = values\n        .iter()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec())\n        .collect_vec();\n    let common_values = common_values\n        .iter()\n        .map(|(xs, freq)| (xs.iter().map(String::as_str).collect_vec(), *freq))\n        .collect_vec();\n    let median_lo = median_lo.iter().map(String::as_str).collect_vec();\n    let median_hi = median_hi\n        .as_ref()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec());\n    assert_eq!(\n        (\n            values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(xs, f)| (xs.as_slice(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_slice(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_vecs_length_inclusive_range() {\n    striped_random_unsigned_vecs_length_inclusive_range_helper::<u8>(\n        3,\n        5,\n        2,\n        1,\n        &[\n            &[\"11001100\", \"11000\", \"11001\", \"10111101\"],\n            &[\"10000010\", \"10011110\", \"1011001\", \"11111000\", \"10011\"],\n            &[\"1110010\", \"11111000\", \"1101011\", \"110\"],\n            &[\"1000010\", \"10111001\", \"11100000\", \"11001001\", \"10111010\"],\n            &[\"11011000\", \"1010\", \"11101011\", \"10011011\", \"10001\"],\n            &[\"10111111\", \"10110100\", \"1111011\", \"110011\"],\n            &[\"11100010\", \"11110000\", \"111101\"],\n            &[\"1010011\", \"10100011\", \"10001110\", \"10000100\"],\n            &[\"1010110\", \"100\", \"11101010\"],\n            &[\"11000101\", \"10111101\", \"100111\", \"11110110\", \"10100\"],\n            &[\"1110011\", \"1111111\", \"100010\", \"111110\", \"11100011\"],\n            &[\"1000100\", \"10110001\", \"1100\", \"11011110\"],\n            &[\"1010110\", \"110111\", \"11111001\", \"11110010\", \"10011010\"],\n            &[\"11110110\", \"110110\", \"1011010\", \"11111111\"],\n            &[\"1111011\", \"11100010\", \"11000111\", \"10010000\", \"11111111\"],\n            &[\"11001110\", \"11001000\", \"1110000\", \"10011100\", \"101000\"],\n            &[\"111001\", \"10001100\", \"10100\", \"11101001\", \"11111101\"],\n            &[\"10010000\", \"10010101\", \"11000100\"],\n            &[\"10110100\", \"1110110\", \"111001\", \"10101100\", \"1000110\"],\n            &[\"1101\", \"1011010\", \"11100010\"],\n        ],\n        &[\n            (&[\"1001110\", \"1011\", \"11000\"], 3),\n            (&[\"1011010\", \"10011\", \"100010\"], 3),\n            (&[\"1100010\", \"101000\", \"1000010\"], 3),\n            (&[\"1110111\", \"101000\", \"100101\"], 3),\n            (&[\"10110\", \"1100010\", \"10011111\"], 3),\n            (&[\"11001\", \"1011\", \"10110011\"], 3),\n            (&[\"11001\", \"1110010\", \"1000101\"], 3),\n            (&[\"101001\", \"101000\", \"1110000\"], 3),\n            (&[\"1100101\", \"1111001\", \"11100\"], 3),\n            (&[\"10010000\", \"1110110\", \"1011111\"], 3),\n        ],\n        (\n            &[\"1111111\", \"11110100\", \"1010100\", \"1100\"],\n            Some(&[\"1111111\", \"11110100\", \"1100001\"]),\n        ),\n    );\n    striped_random_unsigned_vecs_length_inclusive_range_helper::<u8>(\n        3,\n        5,\n        10,\n        1,\n        &[\n            &[\"0\", \"0\", \"111000\", \"0\"],\n            &[\"11111100\", \"11\", \"11111111\", \"111\", \"0\"],\n            &[\"0\", \"0\", \"11111100\", \"11111111\"],\n            &[\"0\", \"111111\", \"0\", \"1000\", \"0\"],\n            &[\"11111100\", \"11111111\", \"1111111\", \"11111000\", \"11\"],\n            &[\"11111111\", \"11111111\", \"11001111\", \"0\"],\n            &[\"11100000\", \"11111111\", \"11111111\"],\n            &[\"11111111\", \"11111111\", \"11111111\", \"11111111\"],\n            &[\"0\", \"10\", \"0\"],\n            &[\"11111111\", \"1111111\", \"0\", \"0\", \"0\"],\n            &[\"11111111\", \"11111111\", \"1111\", \"10000\", \"11111111\"],\n            &[\"11000000\", \"111011\", \"1000000\", \"11111011\"],\n            &[\"10\", \"0\", \"0\", \"0\", \"11111111\"],\n            &[\"111100\", \"10000000\", \"11111100\", \"1111\"],\n            &[\"11111111\", \"1\", \"1000000\", \"0\", \"0\"],\n            &[\"11110000\", \"11111111\", \"0\", \"0\", \"111100\"],\n            &[\"11111111\", \"111\", \"11111100\", \"11111111\", \"1111111\"],\n            &[\"0\", \"10000000\", \"11111111\"],\n            &[\"11110000\", \"10011111\", \"11111111\", \"11011111\", \"1\"],\n            &[\"11111\", \"11110000\", \"111\"],\n        ],\n        &[\n            (&[\"0\", \"0\", \"0\"], 14915),\n            (&[\"11111111\", \"11111111\", \"11111111\"], 14783),\n            (&[\"0\", \"0\", \"0\", \"0\"], 6456),\n            (&[\"11111111\", \"11111111\", \"11111111\", \"11111111\"], 6260),\n            (&[\"0\", \"0\", \"0\", \"0\", \"0\"], 2738),\n            (\n                &[\"11111111\", \"11111111\", \"11111111\", \"11111111\", \"11111111\"],\n                2722,\n            ),\n            (&[\"11111111\", \"111111\", \"0\"], 1721),\n            (&[\"11111111\", \"11111111\", \"1111\"], 1717),\n            (&[\"0\", \"0\", \"10000000\"], 1708),\n            (&[\"11110000\", \"11111111\", \"11111111\"], 1707),\n        ],\n        (&[\"10000000\", \"0\", \"0\"], None),\n    );\n    striped_random_unsigned_vecs_length_inclusive_range_helper::<u8>(\n        3,\n        5,\n        11,\n        10,\n        &[\n            &[\"1011010\", \"11010101\", \"1001010\", \"10110101\"],\n            &[\"1010010\", \"10101010\", \"10101010\", \"101010\", \"10110101\"],\n            &[\"10101010\", \"1101010\", \"1001010\", \"1010101\"],\n            &[\"10101010\", \"10101010\", \"1011010\", \"10101101\", \"1010100\"],\n            &[\"1010010\", \"1010101\", \"1010101\", \"10101001\", \"101010\"],\n            &[\"10010101\", \"10101010\", \"10101010\", \"10101010\"],\n            &[\"11011010\", \"1010110\", \"1010101\"],\n            &[\"1010101\", \"1011011\", \"1010101\", \"10110101\"],\n            &[\"1010110\", \"1010101\", \"1010101\"],\n            &[\"10010101\", \"10010111\", \"10100011\", \"10101010\", \"1101000\"],\n            &[\"1010101\", \"1001011\", \"1010101\", \"10101001\", \"10101010\"],\n            &[\"1010110\", \"10110101\", \"10101010\", \"1010100\"],\n            &[\"10101010\", \"10101010\", \"10101010\", \"10101010\", \"100101\"],\n            &[\"1001010\", \"10101011\", \"10101010\", \"10101010\"],\n            &[\"1010101\", \"10101010\", \"10101010\", \"1011010\", \"10101101\"],\n            &[\"1010110\", \"10101010\", \"1100100\", \"1010101\", \"1010101\"],\n            &[\"10100101\", \"1010110\", \"100101\", \"1010101\", \"1010101\"],\n            &[\"1010110\", \"1010101\", \"10101101\"],\n            &[\"10101010\", \"10101010\", \"1010100\", \"1010101\", \"11010101\"],\n            &[\"1010101\", \"10101\", \"1010101\"],\n        ],\n        &[\n            (&[\"10101010\", \"10101010\", \"10101010\"], 18583),\n            (&[\"1010101\", \"1010101\", \"1010101\"], 18554),\n            (&[\"1010101\", \"1010101\", \"1010101\", \"1010101\"], 8801),\n            (&[\"10101010\", \"10101010\", \"10101010\", \"10101010\"], 8734),\n            (\n                &[\"1010101\", \"1010101\", \"1010101\", \"1010101\", \"1010101\"],\n                4002,\n            ),\n            (\n                &[\"10101010\", \"10101010\", \"10101010\", \"10101010\", \"10101010\"],\n                3983,\n            ),\n            (&[\"1101010\", \"1010101\", \"1010101\"], 1971),\n            (&[\"10110101\", \"10101010\", \"10101010\"], 1953),\n            (&[\"1010101\", \"10101101\", \"10101010\"], 1936),\n            (&[\"1010101\", \"10110101\", \"10101010\"], 1934),\n        ],\n        (\n            &[\"10000101\", \"101010\", \"10101010\"],\n            Some(&[\"10000101\", \"1001010\", \"1001001\", \"100101\"]),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_length_inclusive_range_fail_1() {\n    striped_random_unsigned_vecs_length_inclusive_range::<u8>(EXAMPLE_SEED, 3, 10, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_length_inclusive_range_fail_2() {\n    striped_random_unsigned_vecs_length_inclusive_range::<u8>(EXAMPLE_SEED, 3, 10, 2, 3);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_length_inclusive_range_fail_3() {\n    striped_random_unsigned_vecs_length_inclusive_range::<u8>(EXAMPLE_SEED, 2, 1, 4, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::striped::striped_random_unsigned_vecs_length_range;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_unsigned_vecs_length_range_helper<T: PrimitiveUnsigned>(\n    a: u64,\n    b: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&[&str]],\n    expected_common_values: &[(&[&str], usize)],\n    expected_median: (&[&str], Option<&[&str]>),\n) {\n    let xss = striped_random_unsigned_vecs_length_range::<T>(\n        EXAMPLE_SEED,\n        a,\n        b,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let values = xss\n        .clone()\n        .take(20)\n        .map(|xs| {\n            xs.into_iter()\n                .map(|x: T| x.to_binary_string())\n                .collect_vec()\n        })\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xss.clone())\n        .into_iter()\n        .map(|(xs, freq)| {\n            (\n                xs.into_iter()\n                    .map(|x: T| x.to_binary_string())\n                    .collect_vec(),\n                freq,\n            )\n        })\n        .collect_vec();\n    let (median_lo, median_hi) = median(xss.take(1000000));\n    let median_lo = median_lo\n        .into_iter()\n        .map(|x: T| x.to_binary_string())\n        .collect_vec();\n    let median_hi = median_hi.map(|xs| {\n        xs.into_iter()\n            .map(|x: T| x.to_binary_string())\n            .collect_vec()\n    });\n\n    let values = values\n        .iter()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec())\n        .collect_vec();\n    let common_values = common_values\n        .iter()\n        .map(|(xs, freq)| (xs.iter().map(String::as_str).collect_vec(), *freq))\n        .collect_vec();\n    let median_lo = median_lo.iter().map(String::as_str).collect_vec();\n    let median_hi = median_hi\n        .as_ref()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec());\n    assert_eq!(\n        (\n            values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(xs, f)| (xs.as_slice(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_slice(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_vecs_length_range() {\n    striped_random_unsigned_vecs_length_range_helper::<u8>(\n        3,\n        6,\n        2,\n        1,\n        &[\n            &[\"11001100\", \"11000\", \"11001\", \"10111101\"],\n            &[\"10000010\", \"10011110\", \"1011001\", \"11111000\", \"10011\"],\n            &[\"1110010\", \"11111000\", \"1101011\", \"110\"],\n            &[\"1000010\", \"10111001\", \"11100000\", \"11001001\", \"10111010\"],\n            &[\"11011000\", \"1010\", \"11101011\", \"10011011\", \"10001\"],\n            &[\"10111111\", \"10110100\", \"1111011\", \"110011\"],\n            &[\"11100010\", \"11110000\", \"111101\"],\n            &[\"1010011\", \"10100011\", \"10001110\", \"10000100\"],\n            &[\"1010110\", \"100\", \"11101010\"],\n            &[\"11000101\", \"10111101\", \"100111\", \"11110110\", \"10100\"],\n            &[\"1110011\", \"1111111\", \"100010\", \"111110\", \"11100011\"],\n            &[\"1000100\", \"10110001\", \"1100\", \"11011110\"],\n            &[\"1010110\", \"110111\", \"11111001\", \"11110010\", \"10011010\"],\n            &[\"11110110\", \"110110\", \"1011010\", \"11111111\"],\n            &[\"1111011\", \"11100010\", \"11000111\", \"10010000\", \"11111111\"],\n            &[\"11001110\", \"11001000\", \"1110000\", \"10011100\", \"101000\"],\n            &[\"111001\", \"10001100\", \"10100\", \"11101001\", \"11111101\"],\n            &[\"10010000\", \"10010101\", \"11000100\"],\n            &[\"10110100\", \"1110110\", \"111001\", \"10101100\", \"1000110\"],\n            &[\"1101\", \"1011010\", \"11100010\"],\n        ],\n        &[\n            (&[\"1001110\", \"1011\", \"11000\"], 3),\n            (&[\"1011010\", \"10011\", \"100010\"], 3),\n            (&[\"1100010\", \"101000\", \"1000010\"], 3),\n            (&[\"1110111\", \"101000\", \"100101\"], 3),\n            (&[\"10110\", \"1100010\", \"10011111\"], 3),\n            (&[\"11001\", \"1011\", \"10110011\"], 3),\n            (&[\"11001\", \"1110010\", \"1000101\"], 3),\n            (&[\"101001\", \"101000\", \"1110000\"], 3),\n            (&[\"1100101\", \"1111001\", \"11100\"], 3),\n            (&[\"10010000\", \"1110110\", \"1011111\"], 3),\n        ],\n        (\n            &[\"1111111\", \"11110100\", \"1010100\", \"1100\"],\n            Some(&[\"1111111\", \"11110100\", \"1100001\"]),\n        ),\n    );\n    striped_random_unsigned_vecs_length_range_helper::<u8>(\n        3,\n        6,\n        10,\n        1,\n        &[\n            &[\"0\", \"0\", \"111000\", \"0\"],\n            &[\"11111100\", \"11\", \"11111111\", \"111\", \"0\"],\n            &[\"0\", \"0\", \"11111100\", \"11111111\"],\n            &[\"0\", \"111111\", \"0\", \"1000\", \"0\"],\n            &[\"11111100\", \"11111111\", \"1111111\", \"11111000\", \"11\"],\n            &[\"11111111\", \"11111111\", \"11001111\", \"0\"],\n            &[\"11100000\", \"11111111\", \"11111111\"],\n            &[\"11111111\", \"11111111\", \"11111111\", \"11111111\"],\n            &[\"0\", \"10\", \"0\"],\n            &[\"11111111\", \"1111111\", \"0\", \"0\", \"0\"],\n            &[\"11111111\", \"11111111\", \"1111\", \"10000\", \"11111111\"],\n            &[\"11000000\", \"111011\", \"1000000\", \"11111011\"],\n            &[\"10\", \"0\", \"0\", \"0\", \"11111111\"],\n            &[\"111100\", \"10000000\", \"11111100\", \"1111\"],\n            &[\"11111111\", \"1\", \"1000000\", \"0\", \"0\"],\n            &[\"11110000\", \"11111111\", \"0\", \"0\", \"111100\"],\n            &[\"11111111\", \"111\", \"11111100\", \"11111111\", \"1111111\"],\n            &[\"0\", \"10000000\", \"11111111\"],\n            &[\"11110000\", \"10011111\", \"11111111\", \"11011111\", \"1\"],\n            &[\"11111\", \"11110000\", \"111\"],\n        ],\n        &[\n            (&[\"0\", \"0\", \"0\"], 14915),\n            (&[\"11111111\", \"11111111\", \"11111111\"], 14783),\n            (&[\"0\", \"0\", \"0\", \"0\"], 6456),\n            (&[\"11111111\", \"11111111\", \"11111111\", \"11111111\"], 6260),\n            (&[\"0\", \"0\", \"0\", \"0\", \"0\"], 2738),\n            (\n                &[\"11111111\", \"11111111\", \"11111111\", \"11111111\", \"11111111\"],\n                2722,\n            ),\n            (&[\"11111111\", \"111111\", \"0\"], 1721),\n            (&[\"11111111\", \"11111111\", \"1111\"], 1717),\n            (&[\"0\", \"0\", \"10000000\"], 1708),\n            (&[\"11110000\", \"11111111\", \"11111111\"], 1707),\n        ],\n        (&[\"10000000\", \"0\", \"0\"], None),\n    );\n    striped_random_unsigned_vecs_length_range_helper::<u8>(\n        3,\n        6,\n        11,\n        10,\n        &[\n            &[\"1011010\", \"11010101\", \"1001010\", \"10110101\"],\n            &[\"1010010\", \"10101010\", \"10101010\", \"101010\", \"10110101\"],\n            &[\"10101010\", \"1101010\", \"1001010\", \"1010101\"],\n            &[\"10101010\", \"10101010\", \"1011010\", \"10101101\", \"1010100\"],\n            &[\"1010010\", \"1010101\", \"1010101\", \"10101001\", \"101010\"],\n            &[\"10010101\", \"10101010\", \"10101010\", \"10101010\"],\n            &[\"11011010\", \"1010110\", \"1010101\"],\n            &[\"1010101\", \"1011011\", \"1010101\", \"10110101\"],\n            &[\"1010110\", \"1010101\", \"1010101\"],\n            &[\"10010101\", \"10010111\", \"10100011\", \"10101010\", \"1101000\"],\n            &[\"1010101\", \"1001011\", \"1010101\", \"10101001\", \"10101010\"],\n            &[\"1010110\", \"10110101\", \"10101010\", \"1010100\"],\n            &[\"10101010\", \"10101010\", \"10101010\", \"10101010\", \"100101\"],\n            &[\"1001010\", \"10101011\", \"10101010\", \"10101010\"],\n            &[\"1010101\", \"10101010\", \"10101010\", \"1011010\", \"10101101\"],\n            &[\"1010110\", \"10101010\", \"1100100\", \"1010101\", \"1010101\"],\n            &[\"10100101\", \"1010110\", \"100101\", \"1010101\", \"1010101\"],\n            &[\"1010110\", \"1010101\", \"10101101\"],\n            &[\"10101010\", \"10101010\", \"1010100\", \"1010101\", \"11010101\"],\n            &[\"1010101\", \"10101\", \"1010101\"],\n        ],\n        &[\n            (&[\"10101010\", \"10101010\", \"10101010\"], 18583),\n            (&[\"1010101\", \"1010101\", \"1010101\"], 18554),\n            (&[\"1010101\", \"1010101\", \"1010101\", \"1010101\"], 8801),\n            (&[\"10101010\", \"10101010\", \"10101010\", \"10101010\"], 8734),\n            (\n                &[\"1010101\", \"1010101\", \"1010101\", \"1010101\", \"1010101\"],\n                4002,\n            ),\n            (\n                &[\"10101010\", \"10101010\", \"10101010\", \"10101010\", \"10101010\"],\n                3983,\n            ),\n            (&[\"1101010\", \"1010101\", \"1010101\"], 1971),\n            (&[\"10110101\", \"10101010\", \"10101010\"], 1953),\n            (&[\"1010101\", \"10101101\", \"10101010\"], 1936),\n            (&[\"1010101\", \"10110101\", \"10101010\"], 1934),\n        ],\n        (\n            &[\"10000101\", \"101010\", \"10101010\"],\n            Some(&[\"10000101\", \"1001010\", \"1001001\", \"100101\"]),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_length_range_fail_1() {\n    striped_random_unsigned_vecs_length_range::<u8>(EXAMPLE_SEED, 3, 10, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_length_range_fail_2() {\n    striped_random_unsigned_vecs_length_range::<u8>(EXAMPLE_SEED, 3, 10, 2, 3);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_length_range_fail_3() {\n    striped_random_unsigned_vecs_length_range::<u8>(EXAMPLE_SEED, 1, 1, 4, 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigned_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::striped::striped_random_unsigned_vecs_min_length;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn striped_random_unsigned_vecs_min_length_helper<T: PrimitiveUnsigned>(\n    min_length: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[&str]],\n    expected_common_values: &[(&[&str], usize)],\n    expected_median: (&[&str], Option<&[&str]>),\n) {\n    let xss = striped_random_unsigned_vecs_min_length::<T>(\n        EXAMPLE_SEED,\n        min_length,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xss\n        .clone()\n        .take(20)\n        .map(|xs| {\n            xs.into_iter()\n                .map(|x: T| x.to_binary_string())\n                .collect_vec()\n        })\n        .collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xss.clone())\n        .into_iter()\n        .map(|(xs, freq)| {\n            (\n                xs.into_iter()\n                    .map(|x: T| x.to_binary_string())\n                    .collect_vec(),\n                freq,\n            )\n        })\n        .collect_vec();\n    let (median_lo, median_hi) = median(xss.take(1000000));\n    let median_lo = median_lo\n        .into_iter()\n        .map(|x: T| x.to_binary_string())\n        .collect_vec();\n    let median_hi = median_hi.map(|xs| {\n        xs.into_iter()\n            .map(|x: T| x.to_binary_string())\n            .collect_vec()\n    });\n\n    let values = values\n        .iter()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec())\n        .collect_vec();\n    let common_values = common_values\n        .iter()\n        .map(|(xs, freq)| (xs.iter().map(String::as_str).collect_vec(), *freq))\n        .collect_vec();\n    let median_lo = median_lo.iter().map(String::as_str).collect_vec();\n    let median_hi = median_hi\n        .as_ref()\n        .map(|xs| xs.iter().map(String::as_str).collect_vec());\n    assert_eq!(\n        (\n            values.iter().map(Vec::as_slice).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(xs, f)| (xs.as_slice(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_slice(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_striped_random_unsigned_vecs() {\n    striped_random_unsigned_vecs_min_length_helper::<u8>(\n        0,\n        2,\n        1,\n        4,\n        1,\n        &[\n            &[],\n            &[\n                \"11001100\", \"11000\", \"11001\", \"10111101\", \"10111110\", \"110000\", \"11010011\", \"11\",\n                \"1110110\", \"11100011\", \"1\", \"1100101\", \"10111110\", \"11010111\",\n            ],\n            &[\"101110\", \"1111000\", \"10110010\", \"11101110\"],\n            &[\"10110110\", \"11000010\", \"11111010\", \"1100110\"],\n            &[\"1000\"],\n            &[],\n            &[\"10100000\", \"100101\", \"1000010\", \"1100110\", \"11000111\"],\n            &[\"111\", \"11100001\"],\n            &[\"1010110\", \"10101110\", \"10111000\", \"10111101\"],\n            &[],\n            &[\"101011\", \"10\", \"1110101\", \"1110001\", \"11101111\", \"10001001\"],\n            &[],\n            &[],\n            &[\n                \"10000100\", \"11110101\", \"11011100\", \"10011111\", \"10001000\", \"11001111\", \"1111000\",\n                \"11010111\", \"1101001\", \"111110\", \"1100100\",\n            ],\n            &[\n                \"10101\", \"11011001\", \"10100000\", \"10100001\", \"1101100\", \"1101111\", \"10100011\",\n                \"11110101\",\n            ],\n            &[],\n            &[\"10111111\", \"100111\", \"1111110\"],\n            &[],\n            &[\"11000\", \"11110010\", \"11111\", \"1110011\", \"11110011\"],\n            &[\n                \"10001110\", \"10011\", \"1100101\", \"111100\", \"10110111\", \"1101110\", \"100001\",\n                \"10000000\", \"10101100\",\n            ],\n        ],\n        &[\n            (&[], 199913),\n            (&[\"11010010\"], 689),\n            (&[\"11\"], 688),\n            (&[\"11110111\"], 681),\n            (&[\"10000110\"], 673),\n            (&[\"110010\"], 672),\n            (&[\"11101111\"], 671),\n            (&[\"1000100\"], 670),\n            (&[\"1111101\"], 670),\n            (&[\"11110010\"], 670),\n        ],\n        (&[\"1100000\"], None),\n    );\n    striped_random_unsigned_vecs_min_length_helper::<u8>(\n        3,\n        2,\n        1,\n        4,\n        1,\n        &[\n            &[\"11001100\", \"11000\", \"11001\", \"10111101\"],\n            &[\"10000010\", \"10011110\", \"1011001\", \"11111000\", \"10011\"],\n            &[\"1110010\", \"11111000\", \"1101011\", \"110\", \"10100001\"],\n            &[\"1000110\", \"11111\", \"110110\", \"1000101\", \"1101100\"],\n            &[\"1010\", \"11101011\", \"10011011\", \"10001\"],\n            &[\"10111111\", \"10110100\", \"1111011\", \"110011\", \"1110001\"],\n            &[\"11110000\", \"111101\", \"1010110\"],\n            &[\"10100011\", \"10001110\", \"10000100\"],\n            &[\"1010110\", \"100\", \"11101010\", \"11100010\"],\n            &[\"10111101\", \"100111\", \"11110110\"],\n            &[\"101001\", \"10001100\", \"10000000\"],\n            &[\"1000100\", \"1111100\", \"11000110\"],\n            &[\"10001000\", \"1100010\", \"11001\", \"10111100\"],\n            &[\"10101100\", \"1101110\", \"11110010\", \"11100101\", \"110101\", \"1001\", \"11001001\"],\n            &[\"1001011\", \"1\", \"10000100\"],\n            &[\"11000100\", \"10001111\", \"100001\", \"11111111\", \"110001\"],\n            &[\"10010001\", \"11100001\", \"111000\"],\n            &[\n                \"10100010\", \"10001100\", \"11100111\", \"11010110\", \"101101\", \"100\", \"10010000\",\n                \"10010101\",\n            ],\n            &[\"1110110\", \"10110100\", \"1110110\", \"111001\"],\n            &[\"10100111\", \"1110010\", \"1101\", \"1011010\"],\n        ],\n        &[\n            (&[\"111100\", \"11\", \"1111\"], 3),\n            (&[\"10000111\", \"100011\", \"110\"], 3),\n            (&[\"10101011\", \"1001101\", \"1\"], 3),\n            (&[\"10011\", \"1111000\", \"111\"], 3),\n            (&[\"10\", \"10111\", \"11111000\"], 3),\n            (&[\"11010000\", \"1001010\", \"11\"], 3),\n            (&[\"101\", \"1001110\", \"1110111\"], 3),\n            (&[\"101\", \"1001111\", \"10111101\"], 3),\n            (&[\"111000\", \"1010011\", \"1010\"], 3),\n            (&[\"111011\", \"0\", \"1110101\"], 3),\n        ],\n        (\n            &[\"1111111\", \"11011110\", \"10110011\"],\n            Some(&[\"1111111\", \"11011110\", \"10111100\"]),\n        ),\n    );\n    striped_random_unsigned_vecs_min_length_helper::<u8>(\n        0,\n        10,\n        1,\n        4,\n        1,\n        &[\n            &[],\n            &[\n                \"0\", \"0\", \"111000\", \"0\", \"11111110\", \"10000001\", \"11111111\", \"11\", \"0\", \"0\", \"0\",\n                \"11111111\", \"11111111\", \"11111\",\n            ],\n            &[\"11110000\", \"11111111\", \"11111101\", \"1111111\"],\n            &[\"0\", \"0\", \"11100000\", \"1\"],\n            &[\"11111110\"],\n            &[],\n            &[\"0\", \"0\", \"10011000\", \"11111111\", \"111\"],\n            &[\"11111111\", \"11111111\"],\n            &[\"0\", \"0\", \"0\", \"0\"],\n            &[],\n            &[\"11111111\", \"11111110\", \"11111111\", \"11111111\", \"11111\", \"0\"],\n            &[],\n            &[],\n            &[\n                \"0\", \"0\", \"0\", \"0\", \"11111100\", \"111011\", \"0\", \"1111000\", \"111\", \"1101000\",\n                \"11011111\",\n            ],\n            &[\n                \"11111111\", \"11111111\", \"11111111\", \"11111\", \"11000000\", \"11\", \"11001000\",\n                \"11111111\",\n            ],\n            &[],\n            &[\"1\", \"11100000\", \"11111111\"],\n            &[],\n            &[\"1000\", \"0\", \"0\", \"11111111\", \"1111\"],\n            &[\"0\", \"10000000\", \"111\", \"10000000\", \"111111\", \"0\", \"0\", \"11111000\", \"11111111\"],\n        ],\n        &[\n            (&[], 199913),\n            (&[\"0\"], 38129),\n            (&[\"11111111\"], 38051),\n            (&[\"0\", \"0\"], 13204),\n            (&[\"11111111\", \"11111111\"], 13153),\n            (&[\"0\", \"0\", \"0\"], 4662),\n            (&[\"11111111\", \"11111111\", \"11111111\"], 4549),\n            (&[\"1\"], 4369),\n            (&[\"11111100\"], 4338),\n            (&[\"11111\"], 4311),\n        ],\n        (&[\"11100\", \"11111110\", \"111111\", \"0\"], None),\n    );\n    striped_random_unsigned_vecs_min_length_helper::<u8>(\n        3,\n        10,\n        1,\n        4,\n        1,\n        &[\n            &[\"0\", \"0\", \"111000\", \"0\"],\n            &[\"11111100\", \"11\", \"11111111\", \"111\", \"0\"],\n            &[\"0\", \"0\", \"11111100\", \"11111111\", \"1111111\"],\n            &[\"11000000\", \"11111111\", \"11110111\", \"11111111\", \"1\"],\n            &[\"0\", \"10000000\", \"111\", \"11111100\"],\n            &[\"11111111\", \"11111111\", \"11001111\", \"0\", \"11110000\"],\n            &[\"0\", \"0\", \"0\"],\n            &[\"11111111\", \"11111111\", \"11111111\"],\n            &[\"0\", \"10\", \"0\", \"0\"],\n            &[\"1111111\", \"0\", \"0\"],\n            &[\"11111111\", \"11111111\", \"11111111\"],\n            &[\"11100000\", \"11011111\", \"1\"],\n            &[\"10000000\", \"1110111\", \"10000000\", \"11110110\"],\n            &[\"100\", \"0\", \"0\", \"0\", \"11111110\", \"11000011\", \"1111111\"],\n            &[\"11111001\", \"11111\", \"0\"],\n            &[\"11111100\", \"1111111\", \"11111111\", \"11111111\", \"1111\"],\n            &[\"11111111\", \"1\", \"0\"],\n            &[\"11110000\", \"0\", \"11110000\", \"111\", \"0\", \"0\", \"11111111\", \"1111111\"],\n            &[\"0\", \"11110000\", \"10011111\", \"11111111\"],\n            &[\"10111111\", \"11\", \"11100000\", \"1111\"],\n        ],\n        &[\n            (&[\"0\", \"0\", \"0\"], 22115),\n            (&[\"11111111\", \"11111111\", \"11111111\"], 21981),\n            (&[\"0\", \"0\", \"0\", \"0\"], 4887),\n            (&[\"11111111\", \"11111111\", \"11111111\", \"11111111\"], 4789),\n            (&[\"0\", \"11000000\", \"11111111\"], 2545),\n            (&[\"11110000\", \"11111111\", \"11111111\"], 2537),\n            (&[\"11111111\", \"11111111\", \"1111\"], 2536),\n            (&[\"1111111\", \"0\", \"0\"], 2524),\n            (&[\"11111111\", \"111111\", \"0\"], 2524),\n            (&[\"10000000\", \"11111111\", \"11111111\"], 2524),\n        ],\n        (\n            &[\"10000000\", \"0\", \"0\", \"0\", \"100\", \"0\", \"0\", \"11111000\", \"11111111\"],\n            Some(&[\"10000000\", \"0\", \"0\", \"0\", \"100\", \"11111110\", \"11111111\", \"11111\", \"11100000\"]),\n        ),\n    );\n    striped_random_unsigned_vecs_min_length_helper::<u8>(\n        0,\n        11,\n        10,\n        4,\n        1,\n        &[\n            &[],\n            &[\n                \"1011010\", \"11010101\", \"1001010\", \"10110101\", \"11010110\", \"10101010\", \"10101010\",\n                \"1101010\", \"10100101\", \"10101010\", \"10011010\", \"1010010\", \"1010101\", \"1010101\",\n            ],\n            &[\"10101010\", \"1010110\", \"101011\", \"1010101\"],\n            &[\"1010100\", \"1010101\", \"1010101\", \"10101010\"],\n            &[\"1101010\"],\n            &[],\n            &[\"1001010\", \"1010101\", \"1010101\", \"1010101\", \"1001001\"],\n            &[\"10101011\", \"10101010\"],\n            &[\"10101010\", \"10101101\", \"10101010\", \"1011010\"],\n            &[],\n            &[\"10101011\", \"10101010\", \"10101010\", \"11010\", \"11010\", \"1010111\"],\n            &[],\n            &[],\n            &[\n                \"10101010\", \"1001011\", \"11010101\", \"1010010\", \"1010101\", \"10101010\", \"101010\",\n                \"1010101\", \"10101001\", \"1101010\", \"1010101\",\n            ],\n            &[\n                \"1010101\", \"1010101\", \"1010101\", \"10110101\", \"10100100\", \"10110100\", \"10101010\",\n                \"10101010\",\n            ],\n            &[],\n            &[\"1010101\", \"10100101\", \"10101010\"],\n            &[],\n            &[\"10101010\", \"1010100\", \"1101010\", \"10100101\", \"1001010\"],\n            &[\n                \"10101100\", \"10101010\", \"10101010\", \"10010101\", \"10101010\", \"10101101\", \"10101010\",\n                \"1001010\", \"1010101\",\n            ],\n        ],\n        &[\n            (&[], 199913),\n            (&[\"1010101\"], 41088),\n            (&[\"10101010\"], 40900),\n            (&[\"1010101\", \"1010101\"], 15274),\n            (&[\"10101010\", \"10101010\"], 15212),\n            (&[\"10101010\", \"10101010\", \"10101010\"], 5901),\n            (&[\"1010101\", \"1010101\", \"1010101\"], 5641),\n            (&[\"10101001\"], 4206),\n            (&[\"10100101\"], 4201),\n            (&[\"10101101\"], 4181),\n        ],\n        (&[\"1010101\", \"10110101\"], None),\n    );\n    striped_random_unsigned_vecs_min_length_helper::<u8>(\n        3,\n        11,\n        10,\n        4,\n        1,\n        &[\n            &[\"1011010\", \"11010101\", \"1001010\", \"10110101\"],\n            &[\"1010010\", \"10101010\", \"10101010\", \"101010\", \"10110101\"],\n            &[\"10101010\", \"1101010\", \"1001010\", \"1010101\", \"1010101\"],\n            &[\"10101010\", \"1011010\", \"10101101\", \"1010100\", \"10101001\"],\n            &[\"10101010\", \"10101010\", \"1010110\", \"11010101\"],\n            &[\"10010101\", \"10101010\", \"10101010\", \"10101010\", \"10010010\"],\n            &[\"1010110\", \"1010101\", \"1010101\"],\n            &[\"1011011\", \"1010101\", \"10110101\"],\n            &[\"1010110\", \"1010101\", \"1010101\", \"110101\"],\n            &[\"10010111\", \"10100011\", \"10101010\"],\n            &[\"11010001\", \"10101010\", \"10110100\"],\n            &[\"10101010\", \"1010010\", \"1010101\"],\n            &[\"1010010\", \"10010101\", \"10101010\", \"1010110\"],\n            &[\"10101010\", \"10101010\", \"10101010\", \"10101010\", \"10110100\", \"10110101\", \"1010100\"],\n            &[\"1010101\", \"1010101\", \"1010101\"],\n            &[\"1010100\", \"1010101\", \"10110101\", \"1011010\", \"10101001\"],\n            &[\"10101011\", \"110110\", \"1010101\"],\n            &[\n                \"10101010\", \"1001010\", \"10101101\", \"1001010\", \"10101010\", \"10101010\", \"1010110\",\n                \"1010101\",\n            ],\n            &[\"1011010\", \"1010101\", \"1010101\", \"10101011\"],\n            &[\"1010101\", \"1010101\", \"10101010\", \"11101010\"],\n        ],\n        &[\n            (&[\"10101010\", \"10101010\", \"10101010\"], 27990),\n            (&[\"1010101\", \"1010101\", \"1010101\"], 27615),\n            (&[\"10101010\", \"10101010\", \"10101010\", \"10101010\"], 6458),\n            (&[\"1010101\", \"1010101\", \"1010101\", \"1010101\"], 6439),\n            (&[\"10101010\", \"1011010\", \"1010101\"], 2932),\n            (&[\"10101010\", \"10101010\", \"101010\"], 2904),\n            (&[\"10100101\", \"10101010\", \"10101010\"], 2904),\n            (&[\"10110101\", \"10101010\", \"10101010\"], 2878),\n            (&[\"1010101\", \"1010101\", \"10010101\"], 2877),\n            (&[\"10101010\", \"10101010\", \"1001010\"], 2864),\n        ],\n        (\n            &[\"10001001\", \"10101010\", \"11010100\", \"1010010\", \"1010101\"],\n            Some(&[\"10001001\", \"10101010\", \"11010110\", \"10101010\", \"10101010\"]),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_min_length_fail_1() {\n    striped_random_unsigned_vecs_min_length::<u8>(EXAMPLE_SEED, 3, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_min_length_fail_2() {\n    striped_random_unsigned_vecs_min_length::<u8>(EXAMPLE_SEED, 3, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_min_length_fail_3() {\n    striped_random_unsigned_vecs_min_length::<u8>(EXAMPLE_SEED, 3, 4, 1, 3, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_min_length_fail_4() {\n    striped_random_unsigned_vecs_min_length::<u8>(EXAMPLE_SEED, 1, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_unsigned_vecs_min_length_fail_5() {\n    striped_random_unsigned_vecs_min_length::<u8>(EXAMPLE_SEED, 0, 4, 1, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/striped/striped_random_unsigneds.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::random::striped::striped_random_unsigneds;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToBinaryString;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{CheckedToF64, MomentStats, moment_stats};\nuse std::panic::catch_unwind;\n\nfn striped_random_unsigneds_helper<T: CheckedToF64 + PrimitiveUnsigned>(\n    m_numerator: u64,\n    m_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (T, Option<T>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let xs = striped_random_unsigneds::<T>(EXAMPLE_SEED, m_numerator, m_denominator);\n    let actual_values = xs\n        .clone()\n        .map(|x| x.to_binary_string())\n        .take(20)\n        .collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .iter()\n        .map(|(x, frequency)| (x.to_binary_string(), *frequency))\n        .collect_vec();\n    let actual_sample_median = median(xs.clone().take(1000000));\n    let actual_sample_moment_stats = moment_stats(xs.take(1000000));\n    assert_eq!(\n        (\n            actual_values,\n            actual_common_values,\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values\n                .iter()\n                .map(ToString::to_string)\n                .collect_vec(),\n            expected_common_values\n                .iter()\n                .map(|(x, frequency)| (x.to_string(), *frequency))\n                .collect_vec(),\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n#[test]\nfn test_striped_random_unsigneds() {\n    // u8, m = 4\n    let values = &[\n        \"1\", \"1001100\", \"1111111\", \"11000011\", \"0\", \"10000000\", \"1111\", \"1110110\", \"0\", \"11111000\",\n        \"11111111\", \"11111101\", \"1111001\", \"0\", \"11110000\", \"11\", \"0\", \"1111111\", \"1\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 66602),\n        (\"11111111\", 66546),\n        (\"11100000\", 22466),\n        (\"11110000\", 22460),\n        (\"11111\", 22373),\n        (\"111111\", 22356),\n        (\"11111100\", 22356),\n        (\"11111110\", 22352),\n        (\"1111\", 22281),\n        (\"11000000\", 22273),\n    ];\n    let sample_median = (128, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.56886100000068),\n        standard_deviation: NiceFloat(95.37976309187316),\n        skewness: NiceFloat(-0.0013289716890443589),\n        excess_kurtosis: NiceFloat(-1.5650405989826497),\n    };\n    striped_random_unsigneds_helper::<u8>(\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, m = 2\n    let values = &[\n        \"110011\", \"1110010\", \"1010110\", \"10110100\", \"1000001\", \"11000011\", \"101000\", \"110111\",\n        \"11\", \"11000100\", \"10111001\", \"11111011\", \"111101\", \"1110011\", \"10100110\", \"1010010\",\n        \"1110110\", \"110011\", \"11111\", \"1010011\",\n    ];\n    let common_values = &[\n        (\"1000100\", 4102),\n        (\"10100100\", 4091),\n        (\"11100100\", 4062),\n        (\"10100010\", 4038),\n        (\"11011010\", 4037),\n        (\"1010100\", 4028),\n        (\"10001011\", 4028),\n        (\"10010010\", 4024),\n        (\"11100011\", 4019),\n        (\"1101011\", 4010),\n    ];\n    let sample_median = (128, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.61267700000472),\n        standard_deviation: NiceFloat(73.77702717610372),\n        skewness: NiceFloat(-0.0007666301824401424),\n        excess_kurtosis: NiceFloat(-1.196710018532242),\n    };\n    striped_random_unsigneds_helper::<u8>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u8, m = 5/4\n    let values = &[\n        \"1010010\", \"1101010\", \"110010\", \"10010100\", \"1010101\", \"10111010\", \"1010100\", \"1011010\",\n        \"1010110\", \"10001101\", \"10000100\", \"11100011\", \"1010\", \"1001011\", \"10101010\", \"1010110\",\n        \"1010001\", \"1010100\", \"1010101\", \"1010101\",\n    ];\n    let common_values = &[\n        (\"1010101\", 105174),\n        (\"10101010\", 104734),\n        (\"10101101\", 26535),\n        (\"11010101\", 26470),\n        (\"1010010\", 26420),\n        (\"101010\", 26383),\n        (\"1001010\", 26310),\n        (\"10010101\", 26290),\n        (\"10110101\", 26229),\n        (\"10101001\", 26220),\n    ];\n    let sample_median = (130, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(127.53448699999743),\n        standard_deviation: NiceFloat(54.22754686756281),\n        skewness: NiceFloat(-0.0015080269385326522),\n        excess_kurtosis: NiceFloat(-1.1008502131352262),\n    };\n    striped_random_unsigneds_helper::<u8>(\n        5,\n        4,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u64, m = 32\n    let values = &[\n        \"111111111111111111111111111111\",\n        \"11111111111111111111111111111111111111111111111111111111111\",\n        \"1111111111111111111111111111111\",\n        \"1111111111111111111111100000000000000000000000000000000000000000\",\n        \"11111111111111111111111111111111111111111111111111111111111111\",\n        \"1111000000000000000000000000000000000000001100000000111111111111\",\n        \"111111111111111000000000000\",\n        \"1111111111111111111111111\",\n        \"111111111111111111111\",\n        \"1111111111111111111111111111111111111111111000000000000000000000\",\n        \"1110000000000000000000000000000000000000000000000000000000000111\",\n        \"1111111111111111111111111111111111111111111111111111111111111111\",\n        \"11111111111111111111111111111000000000000000000000000000\",\n        \"100000001111111111111111111111111000000000\",\n        \"1111111000000000000000000000000000000000000000000000000000000000\",\n        \"1111\",\n        \"1111111111111111111111111111111111111111111111111111000\",\n        \"1111111111111111110000000011111111111111111\",\n        \"0\",\n        \"111111111111111111111111100\",\n    ];\n    let common_values = &[\n        (\n            \"1111111111111111111111111111111111111111111111111111111111111111\",\n            68034,\n        ),\n        (\"0\", 67854),\n        (\"111111111111111111111111111111\", 2299),\n        (\n            \"1111111111111111111111111110000000000000000000000000000000000000\",\n            2298,\n        ),\n        (\"111111111\", 2270),\n        (\"111111111111111111111111111111111111\", 2255),\n        (\"111111111111\", 2254),\n        (\n            \"1111111111111111111111111111111111111111111111100000000000000000\",\n            2245,\n        ),\n        (\n            \"1111111111111110000000000000000000000000000000000000000000000000\",\n            2240,\n        ),\n        (\n            \"1111111111111111111111111111111111111111111111111111111111000000\",\n            2237,\n        ),\n    ];\n    let sample_median = (9223372036854775808, None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.232321508867713e18),\n        standard_deviation: NiceFloat(8.854393011414399e18),\n        skewness: NiceFloat(-0.00195547778002319),\n        excess_kurtosis: NiceFloat(-1.9432719051653975),\n    };\n    striped_random_unsigneds_helper::<u64>(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u64, m = 2\n    let values = &[\n        \"11001100011010101001011010010000011000011101011110010000000011\",\n        \"11101101110011111011100001011100110100110101001011101100110011\",\n        \"1111101011000111001110010011000110110101010001110111011111100\",\n        \"1011100110000101000110000000111101100011100111101101111111000000\",\n        \"110011001100101100000100111100101010001011010001101001000111000\",\n        \"1010001101111001011010101011011000110011011110010101100100000100\",\n        \"111100011000100010101011011011001000000100111011110100111011\",\n        \"100100110010110010010111100011001000100110111001010000100101101\",\n        \"1101100111000010011100101110010101101001100110000011111011\",\n        \"1101110011101000110001100100011011100001110011100001101110001000\",\n        \"1101100100110110101110000011000111010011101101101111111101111100\",\n        \"1111001111110101110110010100001100001001011101001101101011101011\",\n        \"111010010110111111001011100000010101010001111000010000110010001\",\n        \"11010101111001000111010001011100101000010001110110001001100111\",\n        \"1101011111000100111101011110111101110011010100111111100001000100\",\n        \"100101000001001011001001101001011100101000110101111110111010101\",\n        \"110111101110000101100101111100101101011100100010101011010100000\",\n        \"101011100111011000001101010001000101111111010001100001111100011\",\n        \"1111100011000100010111100101000001010110011001010100000000011\",\n        \"11100111100011111000111111010010100000111110101001010111011001\",\n    ];\n    let common_values = &[\n        (\"11011011101110000001110101101011110010111101\", 1),\n        (\"111100000110100100110100100001100010110000010\", 1),\n        (\"1011110101111010110111100110111101111101111011\", 1),\n        (\"1110100010111110000100101010110100101101110111\", 1),\n        (\"10111011110000001110101010110111111001011011100\", 1),\n        (\"11000001010110011001100110101011001100000111111\", 1),\n        (\"100100100011101001001000001010010111100010110100\", 1),\n        (\"100110100101010111001000010010100111110111010110\", 1),\n        (\"110110101100010110011100011100110111001111000000\", 1),\n        (\"111001100010011111010011111010110100101110001000\", 1),\n    ];\n    let sample_median = (9232300347074497346, Some(9232359143244030439));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.22650235650532e18),\n        standard_deviation: NiceFloat(5.325785817923598e18),\n        skewness: NiceFloat(-0.0012562071401776408),\n        excess_kurtosis: NiceFloat(-1.1996143045434082),\n    };\n    striped_random_unsigneds_helper::<u64>(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    // u64, m = 33/32\n    let values = &[\n        \"101010101010101010101011010101010101010101010101010101010101010\",\n        \"101010101010101110101010110101001010101010101010010101010010101\",\n        \"101010010101011010101010101010101101010101010101010101010101010\",\n        \"1010101010101010100101010101010101010101010101010101010101010101\",\n        \"101010101010101010101101010101010100101001010100101010101010101\",\n        \"1010101010101010101010101010101011010101101010101001010101010101\",\n        \"101010101010101010101010101010101010101010101101010101010101010\",\n        \"101010101010110101010101010101010101010101010101010101010101010\",\n        \"10101010101010101010101010101010101010101010101010101010101011\",\n        \"1001010101010101010101010101010101010101010100101010101010101010\",\n        \"1010101010101010101010101100101010101010110101010101010010101010\",\n        \"1010011010101010101010101010101010101010101010101010101010010101\",\n        \"101010101001010101010101010101010101010101010101010101010101010\",\n        \"101010010110110100101010101010101010101010101010101010101010101\",\n        \"1010110101010101010101010101010010101010101010101010101010101010\",\n        \"101010101010101010101010101010101010101010101010101010101010101\",\n        \"101010101010101010101010101010101101010101010101010101010101010\",\n        \"101010101010101010101010010101010101010101010101010101010101010\",\n        \"110110101001010101010010101010101010101010101010101010101010101\",\n        \"101010101010010101010101010101010101010101010101010101010101010\",\n    ];\n    let common_values = &[\n        (\n            \"101010101010101010101010101010101010101010101010101010101010101\",\n            72208,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010101010\",\n            71633,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010101001\",\n            2387,\n        ),\n        (\n            \"101010101010101010101010101010101010110101010101010101010101010\",\n            2371,\n        ),\n        (\n            \"101010101010101010101001010101010101010101010101010101010101010\",\n            2350,\n        ),\n        (\n            \"1010101010101010101010101010101010101010101010101010101010100101\",\n            2343,\n        ),\n        (\n            \"1010101010101010101010101010101001010101010101010101010101010101\",\n            2321,\n        ),\n        (\n            \"101010101010101010101010101010101010101001010101010101010101010\",\n            2317,\n        ),\n        (\n            \"1010101010101010101010101010101010101010100101010101010101010101\",\n            2316,\n        ),\n        (\n            \"1010101010101010101101010101010101010101010101010101010101010101\",\n            2314,\n        ),\n    ];\n    let sample_median = (10184128240689698133, Some(10184139957360479594));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.22742898450889e18),\n        standard_deviation: NiceFloat(3.1984799302251884e18),\n        skewness: NiceFloat(-0.0008313832988426654),\n        excess_kurtosis: NiceFloat(-1.7364190763714287),\n    };\n    striped_random_unsigneds_helper::<u64>(\n        33,\n        32,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\nfn striped_random_unsigneds_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!(striped_random_unsigneds::<T>(EXAMPLE_SEED, 1, 0));\n    assert_panic!(striped_random_unsigneds::<T>(EXAMPLE_SEED, 2, 3));\n}\n\n#[test]\nfn striped_random_unsigneds_fail() {\n    apply_fn_to_unsigneds!(striped_random_unsigneds_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/variable_range_generator/next_bit_chunk.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::random::EXAMPLE_SEED;\nuse std::panic::catch_unwind;\n\nfn next_bit_chunk_helper<T: PrimitiveUnsigned>(chunk_size: u64, expected_values: &[T]) {\n    let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    let mut xs = Vec::with_capacity(20);\n    for _ in 0..20 {\n        xs.push(range_generator.next_bit_chunk::<T>(chunk_size));\n    }\n    assert_eq!(xs, expected_values);\n}\n\n#[test]\nfn test_next_bit_chunk() {\n    next_bit_chunk_helper::<u16>(\n        1,\n        &[1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0],\n    );\n    next_bit_chunk_helper::<u32>(\n        2,\n        &[1, 0, 3, 1, 3, 3, 2, 3, 1, 1, 0, 1, 0, 3, 2, 1, 0, 1, 2, 3],\n    );\n    next_bit_chunk_helper::<u64>(\n        3,\n        &[1, 6, 5, 7, 6, 3, 1, 2, 4, 5, 1, 2, 6, 5, 4, 6, 0, 5, 6, 0],\n    );\n    next_bit_chunk_helper::<u128>(\n        7,\n        &[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, 1, 113, 54, 10, 47, 17, 89, 92, 119, 66],\n    );\n    next_bit_chunk_helper::<u8>(\n        8,\n        &[\n            113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149,\n            115,\n        ],\n    );\n}\n\nfn next_bit_chunk_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n        range_generator.next_bit_chunk::<T>(0)\n    });\n    assert_panic!({\n        let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n        range_generator.next_bit_chunk::<T>(T::WIDTH + 1)\n    });\n}\n\n#[test]\nfn next_bit_chunk_fail() {\n    apply_fn_to_unsigneds!(next_bit_chunk_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/variable_range_generator/next_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::random::EXAMPLE_SEED;\n\n#[test]\nfn test_next_bool() {\n    let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    let mut xs = Vec::with_capacity(100);\n    for _ in 0..100 {\n        xs.push(range_generator.next_bool());\n    }\n    assert_eq!(\n        xs,\n        &[\n            true, false, true, false, true, true, true, true, true, false, true, false, false,\n            true, false, false, false, true, true, false, false, true, true, true, false, false,\n            true, false, false, false, false, true, true, false, true, false, true, false, true,\n            true, true, true, true, false, false, false, true, true, false, false, false, true,\n            false, true, true, false, true, false, true, false, true, false, false, true, true,\n            false, true, false, true, false, true, false, true, true, false, false, false, false,\n            true, true, false, true, true, false, false, true, true, true, true, false, true, true,\n            true, false, true, false, true, false, true, true\n        ]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/variable_range_generator/next_in_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::random::EXAMPLE_SEED;\nuse std::panic::catch_unwind;\n\nfn next_in_inclusive_range_helper<T: PrimitiveUnsigned>(a: T, b: T, expected_values: &[T]) {\n    let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    let mut xs = Vec::with_capacity(20);\n    for _ in 0..20 {\n        xs.push(range_generator.next_in_inclusive_range(a, b));\n    }\n    assert_eq!(xs, expected_values);\n}\n\n#[test]\nfn test_next_in_inclusive_range() {\n    next_in_inclusive_range_helper::<u8>(5, 5, &[5; 20]);\n    next_in_inclusive_range_helper::<u16>(\n        1,\n        6,\n        &[2, 6, 4, 2, 3, 5, 6, 2, 3, 6, 5, 1, 6, 1, 3, 6, 3, 1, 5, 1],\n    );\n    next_in_inclusive_range_helper::<u32>(\n        10,\n        19,\n        &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, 15, 10, 12, 16, 13, 15, 12, 12, 19, 15],\n    );\n    next_in_inclusive_range_helper::<u8>(\n        0,\n        u8::MAX,\n        &[\n            113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149,\n            115,\n        ],\n    );\n}\n\nfn next_in_inclusive_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n        range_generator.next_in_inclusive_range(T::TWO, T::ONE);\n    });\n}\n\n#[test]\nfn next_in_inclusive_range_fail() {\n    apply_fn_to_unsigneds!(next_in_inclusive_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/variable_range_generator/next_in_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::random::EXAMPLE_SEED;\nuse std::panic::catch_unwind;\n\nfn next_in_range_helper<T: PrimitiveUnsigned>(a: T, b: T, expected_values: &[T]) {\n    let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    let mut xs = Vec::with_capacity(20);\n    for _ in 0..20 {\n        xs.push(range_generator.next_in_range(a, b));\n    }\n    assert_eq!(xs, expected_values);\n}\n\n#[test]\nfn test_next_in_range() {\n    next_in_range_helper::<u8>(5, 6, &[5; 20]);\n    next_in_range_helper::<u16>(\n        1,\n        7,\n        &[2, 6, 4, 2, 3, 5, 6, 2, 3, 6, 5, 1, 6, 1, 3, 6, 3, 1, 5, 1],\n    );\n    next_in_range_helper::<u32>(\n        10,\n        20,\n        &[11, 17, 15, 14, 16, 14, 12, 18, 11, 17, 15, 10, 12, 16, 13, 15, 12, 12, 19, 15],\n    );\n    next_in_range_helper::<u8>(\n        0,\n        u8::MAX,\n        &[\n            113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149,\n            115,\n        ],\n    );\n}\n\nfn next_in_range_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n        range_generator.next_in_range(T::TWO, T::TWO);\n    });\n}\n\n#[test]\nfn next_in_range_fail() {\n    apply_fn_to_unsigneds!(next_in_range_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/num/random/variable_range_generator/next_less_than.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::random::EXAMPLE_SEED;\nuse std::panic::catch_unwind;\n\nfn next_less_than_helper<T: PrimitiveUnsigned>(limit: T, expected_values: &[T]) {\n    let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n    let mut xs = Vec::with_capacity(20);\n    for _ in 0..20 {\n        xs.push(range_generator.next_less_than(limit));\n    }\n    assert_eq!(xs, expected_values);\n}\n\n#[test]\nfn test_next_less_than() {\n    next_less_than_helper::<u8>(1, &[0; 20]);\n    next_less_than_helper::<u16>(\n        2,\n        &[1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0],\n    );\n    next_less_than_helper::<u32>(\n        3,\n        &[1, 0, 1, 2, 1, 1, 0, 1, 0, 2, 1, 0, 1, 2, 2, 0, 1, 0, 2, 2],\n    );\n    next_less_than_helper::<u64>(\n        4,\n        &[1, 0, 3, 1, 3, 3, 2, 3, 1, 1, 0, 1, 0, 3, 2, 1, 0, 1, 2, 3],\n    );\n    next_less_than_helper::<u128>(\n        10,\n        &[1, 7, 5, 4, 6, 4, 2, 8, 1, 7, 5, 0, 2, 6, 3, 5, 2, 2, 9, 5],\n    );\n}\n\nfn next_less_than_fail_helper<T: PrimitiveUnsigned>() {\n    assert_panic!({\n        let mut range_generator = VariableRangeGenerator::new(EXAMPLE_SEED);\n        range_generator.next_less_than(T::ZERO);\n    });\n}\n\n#[test]\nfn next_less_than_fail() {\n    apply_fn_to_unsigneds!(next_less_than_fail_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/options/exhaustive/exhaustive_options.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::nevers::Never;\nuse malachite_base::options::exhaustive::exhaustive_options;\nuse std::fmt::Debug;\n\nfn exhaustive_options_helper<T: Clone + Debug + Eq>(xs: &[T], out: &[Option<T>]) {\n    assert_eq!(\n        exhaustive_options(xs.iter().cloned())\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n}\n\n#[test]\nfn test_exhaustive_options() {\n    exhaustive_options_helper::<Never>(&[], &[None]);\n    exhaustive_options_helper(&[5], &[None, Some(5)]);\n    exhaustive_options_helper(&[1, 2, 3], &[None, Some(1), Some(2), Some(3)]);\n    exhaustive_options_helper(\n        &[Some(2), None, Some(5)],\n        &[None, Some(Some(2)), Some(None), Some(Some(5))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/options/exhaustive/exhaustive_somes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::nevers::Never;\nuse malachite_base::options::exhaustive::exhaustive_somes;\nuse std::fmt::Debug;\n\nfn exhaustive_somes_helper<T: Clone + Debug + Eq>(xs: &[T], out: &[Option<T>]) {\n    assert_eq!(\n        exhaustive_somes(xs.iter().cloned())\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n}\n\n#[test]\nfn test_exhaustive_somes() {\n    exhaustive_somes_helper::<Never>(&[], &[]);\n    exhaustive_somes_helper(&[5], &[Some(5)]);\n    exhaustive_somes_helper(&[1, 2, 3], &[Some(1), Some(2), Some(3)]);\n    exhaustive_somes_helper(\n        &[Some(2), None, Some(5)],\n        &[Some(Some(2)), Some(None), Some(Some(5))],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/options/option_from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::nevers::Never;\nuse malachite_base::options::{option_from_str, option_from_str_custom};\nuse malachite_base::orderings::ordering_from_str;\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::str::FromStr;\n\n#[allow(clippy::needless_pass_by_value)]\nfn option_from_str_helper<T: Debug + Eq + FromStr>(s: &str, out: Option<Option<T>>) {\n    assert_eq!(option_from_str(s), out);\n}\n\n#[test]\nfn test_option_from_str() {\n    option_from_str_helper::<bool>(\"Some(false)\", Some(Some(false)));\n    option_from_str_helper::<u32>(\"Some(5)\", Some(Some(5)));\n    option_from_str_helper::<Never>(\"None\", Some(None));\n    option_from_str_helper::<u32>(\"Some(hi)\", None);\n    option_from_str_helper::<bool>(\"abc\", None);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn option_from_str_custom_helper<T: Debug + Eq>(\n    f: &dyn Fn(&str) -> Option<T>,\n    s: &str,\n    out: Option<Option<T>>,\n) {\n    assert_eq!(option_from_str_custom(f, s), out);\n}\n\n#[test]\nfn test_option_from_str_custom() {\n    option_from_str_custom_helper(&ordering_from_str, \"Some(Less)\", Some(Some(Less)));\n    option_from_str_custom_helper(\n        &option_from_str,\n        \"Some(Some(false))\",\n        Some(Some(Some(false))),\n    );\n    option_from_str_custom_helper(&option_from_str::<bool>, \"Some(None)\", Some(Some(None)));\n    option_from_str_custom_helper(&option_from_str::<bool>, \"None\", Some(None));\n    option_from_str_custom_helper(&ordering_from_str, \"Some(hi)\", None);\n    option_from_str_custom_helper(&ordering_from_str, \"abc\", None);\n}\n"
  },
  {
    "path": "malachite-base/tests/options/random/random_options.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::options::random::random_options;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::fmt::Debug;\n\nfn random_options_helper<I: Clone + Iterator>(\n    p_none_numerator: u64,\n    p_none_denominator: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[Option<I::Item>],\n    expected_common_values: &[(Option<I::Item>, usize)],\n    expected_median: (Option<I::Item>, Option<Option<I::Item>>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_options(EXAMPLE_SEED, p_none_numerator, p_none_denominator, xs_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_options() {\n    // p = 1/2\n    random_options_helper(\n        1,\n        2,\n        &random_primitive_ints::<u8>,\n        &[\n            Some(85),\n            Some(11),\n            Some(136),\n            None,\n            Some(200),\n            None,\n            Some(235),\n            Some(134),\n            Some(203),\n            None,\n            None,\n            None,\n            Some(223),\n            Some(38),\n            None,\n            Some(235),\n            Some(217),\n            Some(177),\n            Some(162),\n            Some(32),\n        ],\n        &[\n            (None, 500454),\n            (Some(81), 2076),\n            (Some(208), 2066),\n            (Some(35), 2065),\n            (Some(211), 2045),\n            (Some(112), 2042),\n            (Some(143), 2039),\n            (Some(162), 2037),\n            (Some(170), 2036),\n            (Some(58), 2035),\n        ],\n        (None, None),\n    );\n    // p = 50/51\n    random_options_helper(\n        50,\n        51,\n        &random_primitive_ints::<u8>,\n        &[None; 20],\n        &[\n            (None, 980283),\n            (Some(18), 102),\n            (Some(25), 99),\n            (Some(237), 98),\n            (Some(116), 97),\n            (Some(226), 97),\n            (Some(23), 95),\n            (Some(185), 95),\n            (Some(30), 94),\n            (Some(73), 94),\n        ],\n        (None, None),\n    );\n    // p = 1/51\n    random_options_helper(\n        1,\n        51,\n        &random_primitive_ints::<u8>,\n        &[\n            Some(85),\n            Some(11),\n            Some(136),\n            Some(200),\n            Some(235),\n            Some(134),\n            Some(203),\n            Some(223),\n            Some(38),\n            Some(235),\n            Some(217),\n            Some(177),\n            Some(162),\n            Some(32),\n            Some(166),\n            Some(234),\n            Some(30),\n            Some(218),\n            Some(90),\n            Some(106),\n        ],\n        &[\n            (None, 19543),\n            (Some(58), 4030),\n            (Some(81), 4001),\n            (Some(194), 3981),\n            (Some(66), 3973),\n            (Some(64), 3969),\n            (Some(143), 3965),\n            (Some(4), 3964),\n            (Some(196), 3952),\n            (Some(208), 3941),\n        ],\n        (Some(125), None),\n    );\n    // p = 1/11\n    random_options_helper(\n        1,\n        11,\n        &|seed| random_options(seed, 1, 11, &random_primitive_ints::<u8>),\n        &[\n            Some(Some(229)),\n            Some(Some(58)),\n            Some(Some(126)),\n            Some(Some(192)),\n            Some(Some(140)),\n            Some(Some(235)),\n            Some(Some(50)),\n            Some(Some(162)),\n            Some(Some(5)),\n            Some(Some(14)),\n            Some(Some(107)),\n            Some(Some(218)),\n            Some(Some(96)),\n            Some(Some(86)),\n            Some(Some(51)),\n            None,\n            Some(Some(240)),\n            Some(Some(186)),\n            Some(Some(180)),\n            Some(Some(152)),\n        ],\n        &[\n            (None, 90592),\n            (Some(None), 83007),\n            (Some(Some(186)), 3385),\n            (Some(Some(193)), 3377),\n            (Some(Some(83)), 3366),\n            (Some(Some(55)), 3365),\n            (Some(Some(245)), 3362),\n            (Some(Some(148)), 3354),\n            (Some(Some(143)), 3345),\n            (Some(Some(136)), 3341),\n        ],\n        (Some(Some(101)), None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_options_fail_1() {\n    random_options(EXAMPLE_SEED, 1, 0, &random_primitive_ints::<u8>);\n}\n\n#[test]\n#[should_panic]\nfn random_options_fail_2() {\n    random_options(EXAMPLE_SEED, 2, 1, &random_primitive_ints::<u8>);\n}\n"
  },
  {
    "path": "malachite-base/tests/options/random/random_somes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::options::random::random_somes;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::fmt::Debug;\n\nfn random_somes_helper<I: Clone + Iterator>(\n    xs: I,\n    expected_values: &[Option<I::Item>],\n    expected_common_values: &[(Option<I::Item>, usize)],\n    expected_median: (Option<I::Item>, Option<Option<I::Item>>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_somes(xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_somes() {\n    random_somes_helper(\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            Some(113),\n            Some(239),\n            Some(69),\n            Some(108),\n            Some(228),\n            Some(210),\n            Some(168),\n            Some(161),\n            Some(87),\n            Some(32),\n            Some(110),\n            Some(83),\n            Some(188),\n            Some(34),\n            Some(89),\n            Some(238),\n            Some(93),\n            Some(200),\n            Some(149),\n            Some(115),\n        ],\n        &[\n            (Some(214), 4097),\n            (Some(86), 4078),\n            (Some(166), 4049),\n            (Some(22), 4048),\n            (Some(126), 4047),\n            (Some(55), 4040),\n            (Some(93), 4037),\n            (Some(191), 4036),\n            (Some(36), 4035),\n            (Some(42), 4032),\n        ],\n        (Some(127), None),\n    );\n    random_somes_helper(\n        random_somes(random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            Some(Some(113)),\n            Some(Some(239)),\n            Some(Some(69)),\n            Some(Some(108)),\n            Some(Some(228)),\n            Some(Some(210)),\n            Some(Some(168)),\n            Some(Some(161)),\n            Some(Some(87)),\n            Some(Some(32)),\n            Some(Some(110)),\n            Some(Some(83)),\n            Some(Some(188)),\n            Some(Some(34)),\n            Some(Some(89)),\n            Some(Some(238)),\n            Some(Some(93)),\n            Some(Some(200)),\n            Some(Some(149)),\n            Some(Some(115)),\n        ],\n        &[\n            (Some(Some(214)), 4097),\n            (Some(Some(86)), 4078),\n            (Some(Some(166)), 4049),\n            (Some(Some(22)), 4048),\n            (Some(Some(126)), 4047),\n            (Some(Some(55)), 4040),\n            (Some(Some(93)), 4037),\n            (Some(Some(191)), 4036),\n            (Some(Some(36)), 4035),\n            (Some(Some(42)), 4032),\n        ],\n        (Some(Some(127)), None),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/orderings/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::orderings::exhaustive::{exhaustive_orderings, orderings_increasing};\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_orderings_increasing() {\n    assert_eq!(\n        orderings_increasing().collect_vec(),\n        &[Less, Equal, Greater]\n    );\n}\n\n#[test]\nfn test_exhaustive_orderings() {\n    assert_eq!(\n        exhaustive_orderings().collect_vec(),\n        &[Equal, Less, Greater]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/orderings/ordering_from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::orderings::ordering_from_str;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_from_str() {\n    let test = |s, out| {\n        assert_eq!(ordering_from_str(s), out);\n    };\n    test(\"Equal\", Some(Equal));\n    test(\"Less\", Some(Less));\n    test(\"Greater\", Some(Greater));\n\n    test(\"\", None);\n    test(\"abc\", None);\n    test(\"Lesser\", None);\n}\n"
  },
  {
    "path": "malachite-base/tests/orderings/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::orderings::random::random_orderings;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_random_orderings() {\n    let xs = random_orderings(EXAMPLE_SEED);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (\n            &[\n                Less, Equal, Less, Greater, Less, Less, Equal, Less, Equal, Greater, Less, Equal,\n                Less, Greater, Greater, Equal, Less, Equal, Greater, Greater\n            ][..],\n            &[(Less, 333784), (Greater, 333516), (Equal, 332700)][..],\n            (Equal, None)\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/random/fork.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\n\n#[test]\nfn test_fork() {\n    assert_eq!(\n        EXAMPLE_SEED.fork(\"first\"),\n        Seed::from_bytes([\n            0x20, 0x18, 0x1, 0x3d, 0x96, 0x4d, 0x3e, 0x98, 0x10, 0x9d, 0x35, 0x75, 0x22, 0x89,\n            0xf7, 0xe9, 0xbe, 0x2f, 0x9c, 0x15, 0x95, 0x42, 0x1a, 0x79, 0x52, 0xf, 0x56, 0x9a,\n            0x7b, 0x8c, 0xd9, 0x34\n        ])\n    );\n    assert_eq!(\n        EXAMPLE_SEED.fork(\"second\"),\n        Seed::from_bytes([\n            0xe0, 0x36, 0x88, 0x58, 0x6d, 0x67, 0x33, 0xea, 0xf2, 0x1c, 0x88, 0xf9, 0xe3, 0xbd,\n            0x52, 0xc0, 0xe5, 0xad, 0x61, 0x81, 0x21, 0xd8, 0x2f, 0x8e, 0xcd, 0xf, 0x89, 0x9d,\n            0x32, 0xc5, 0x35, 0x83\n        ])\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/random/from_bytes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::random::Seed;\n\n#[test]\nfn test_from_bytes() {\n    assert_eq!(Seed::from_bytes(EXAMPLE_SEED.bytes), EXAMPLE_SEED);\n}\n"
  },
  {
    "path": "malachite-base/tests/random/get_rng.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::random::EXAMPLE_SEED;\nuse rand_chacha::rand_core::RngCore;\n\n#[test]\nfn test_get_rng() {\n    let mut bytes = [0; 32];\n    EXAMPLE_SEED.get_rng().fill_bytes(&mut bytes);\n    assert_eq!(\n        bytes,\n        [\n            113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149,\n            115, 189, 149, 217, 201, 117, 146, 31, 72, 151, 169, 174, 33\n        ]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/random/next.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\n\n#[test]\nfn test_next() {\n    assert_eq!(\n        EXAMPLE_SEED.next(),\n        Seed::from_bytes([\n            113, 239, 69, 108, 228, 210, 168, 161, 87, 32, 110, 83, 188, 34, 89, 238, 93, 200, 149,\n            115, 189, 149, 217, 201, 117, 146, 31, 72, 151, 169, 174, 33\n        ])\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/access/get.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{\n    unsigned_rational_sequence_unsigned_pair_gen_var_1,\n    unsigned_rational_sequence_unsigned_pair_gen_var_2,\n};\n\n#[test]\npub fn test_get() {\n    fn test(non_repeating: &[u8], repeating: &[u8], index: usize, out: Option<&u8>) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(xs.get(index), out);\n    }\n    test(&[], &[], 0, None);\n    test(&[1, 2, 3], &[], 0, Some(&1));\n    test(&[1, 2, 3], &[], 1, Some(&2));\n    test(&[1, 2, 3], &[], 2, Some(&3));\n    test(&[1, 2, 3], &[], 3, None);\n    test(&[1, 2, 3], &[4], 3, Some(&4));\n    test(&[1, 2, 3], &[4], 100, Some(&4));\n}\n\n#[test]\npub fn test_index() {\n    fn test(non_repeating: &[u8], repeating: &[u8], index: usize, out: u8) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(xs[index], out);\n    }\n    test(&[1, 2, 3], &[], 0, 1);\n    test(&[1, 2, 3], &[], 1, 2);\n    test(&[1, 2, 3], &[], 2, 3);\n    test(&[1, 2, 3], &[4], 3, 4);\n    test(&[1, 2, 3], &[4], 100, 4);\n}\n\n#[allow(clippy::unnecessary_operation)]\n#[test]\n#[should_panic]\nfn index_fail_1() {\n    RationalSequence::<u8>::from_vec(vec![])[0];\n}\n\n#[allow(clippy::unnecessary_operation)]\n#[test]\n#[should_panic]\nfn index_fail_2() {\n    RationalSequence::from_vec(vec![1, 2, 3])[3];\n}\n\n#[test]\nfn get_properties() {\n    unsigned_rational_sequence_unsigned_pair_gen_var_1::<u8, usize>().test_properties(\n        |(xs, index)| {\n            assert_eq!(xs.get(index), xs.iter().nth(index));\n        },\n    );\n}\n\n#[test]\nfn index_properties() {\n    unsigned_rational_sequence_unsigned_pair_gen_var_2::<u8>().test_properties(|(xs, index)| {\n        let x = xs[index];\n        assert_eq!(xs.iter().nth(index).unwrap(), &x);\n        assert_eq!(xs.get(index), Some(&x));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/access/mutate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::large_type_gen_var_22;\n\n#[test]\npub fn test_mutate() {\n    fn test(\n        non_repeating: &[u8],\n        repeating: &[u8],\n        index: usize,\n        new_value: u8,\n        out: u8,\n        non_repeating_out: &[u8],\n        repeating_out: &[u8],\n    ) {\n        let mut xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(\n            xs.mutate(index, |x| {\n                *x = new_value;\n                out\n            }),\n            out\n        );\n        assert_eq!(\n            xs,\n            RationalSequence::from_slices(non_repeating_out, repeating_out)\n        );\n    }\n    test(&[1, 2, 3], &[], 0, 5, 6, &[5, 2, 3], &[]);\n    test(&[1, 2, 3], &[], 1, 5, 6, &[1, 5, 3], &[]);\n    test(&[1, 2, 3], &[], 2, 5, 6, &[1, 2, 5], &[]);\n    test(\n        &[1, 2, 3],\n        &[4, 5, 6],\n        3,\n        100,\n        6,\n        &[1, 2, 3, 100],\n        &[5, 6, 4],\n    );\n    test(\n        &[1, 2, 3],\n        &[4, 5, 6],\n        10,\n        100,\n        6,\n        &[1, 2, 3, 4, 5, 6, 4, 5, 6, 4, 100],\n        &[6, 4, 5],\n    );\n}\n\n#[test]\n#[should_panic]\nfn mutate_fail_1() {\n    RationalSequence::<u8>::from_vec(vec![]).mutate(0, |_| {});\n}\n\n#[test]\n#[should_panic]\nfn mutate_fail_2() {\n    RationalSequence::from_vec(vec![1, 2, 3]).mutate(3, |_| {});\n}\n\n#[test]\nfn mutate_properties() {\n    large_type_gen_var_22::<u8>().test_properties(|(mut xs, index, y, z)| {\n        let xs_old = xs.clone();\n        let x_old = xs[index];\n        assert_eq!(\n            xs.mutate(index, |x| {\n                *x = y;\n                z\n            }),\n            z\n        );\n        assert_eq!(xs[index], y);\n        xs.mutate(index, |x| {\n            *x = x_old;\n        });\n        assert_eq!(xs, xs_old);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/basic/component_len.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{unsigned_rational_sequence_gen, unsigned_vec_gen};\n\n#[test]\npub fn test_component_len() {\n    fn test(non_repeating: &[u8], repeating: &[u8], out: usize) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(xs.component_len(), out);\n    }\n    test(&[], &[], 0);\n    test(&[1, 2, 3], &[], 3);\n    test(&[], &[1, 2, 3], 3);\n    test(&[1, 2, 3], &[4, 5, 6], 6);\n}\n\n#[test]\nfn component_len_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        xs.component_len();\n    });\n\n    unsigned_vec_gen::<u8>().test_properties(|xs| {\n        assert_eq!(RationalSequence::from_slice(&xs).component_len(), xs.len());\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/basic/is_empty.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\n\n#[test]\npub fn test_is_empty() {\n    fn test(non_repeating: &[u8], repeating: &[u8], out: bool) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(xs.is_empty(), out);\n    }\n    test(&[], &[], true);\n    test(&[1, 2, 3], &[], false);\n    test(&[], &[1, 2, 3], false);\n    test(&[1, 2, 3], &[4, 5, 6], false);\n}\n\n#[test]\nfn is_empty_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        let empty = xs.is_empty();\n        assert_eq!(empty, xs == RationalSequence::from_vec(vec![]));\n        assert_eq!(empty, xs.component_len() == 0);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/basic/is_finite.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{unsigned_rational_sequence_gen, unsigned_vec_gen};\n\n#[test]\npub fn test_is_finite() {\n    fn test(non_repeating: &[u8], repeating: &[u8], out: bool) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(xs.is_finite(), out);\n    }\n    test(&[], &[], true);\n    test(&[1, 2, 3], &[], true);\n    test(&[], &[1, 2, 3], false);\n    test(&[1, 2, 3], &[4, 5, 6], false);\n}\n\n#[test]\nfn is_finite_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        assert_eq!(xs.is_finite(), xs.slices_ref().1.is_empty());\n    });\n\n    unsigned_vec_gen::<u8>().test_properties(|xs| {\n        assert!(RationalSequence::from_slice(&xs).is_finite());\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/basic/iter.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::{count_is_at_least, prefix_to_string};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{unsigned_rational_sequence_gen, unsigned_vec_gen};\n\n#[test]\npub fn test_iter() {\n    fn test(non_repeating: &[u8], repeating: &[u8], out: &str) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(prefix_to_string(xs.iter(), 10), out);\n    }\n    test(&[], &[], \"[]\");\n    test(&[1, 2, 3], &[], \"[1, 2, 3]\");\n    test(&[], &[1, 2, 3], \"[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, ...]\");\n    test(\n        &[1, 2, 3],\n        &[4, 5, 6],\n        \"[1, 2, 3, 4, 5, 6, 4, 5, 6, 4, ...]\",\n    );\n}\n\n#[test]\nfn iter_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        let mut it = xs.iter();\n        if let Some(len) = xs.len() {\n            assert_eq!(it.count(), len);\n        } else {\n            assert!(count_is_at_least(&mut it, 20));\n        }\n\n        let non_rep_len = xs.slices_ref().0.len();\n        let rep_len = xs.slices_ref().1.len();\n        assert!(Iterator::eq(\n            xs.iter().take(non_rep_len),\n            xs.slices_ref().0.iter()\n        ));\n        assert!(Iterator::eq(\n            xs.iter().skip(non_rep_len).take(rep_len),\n            xs.slices_ref().1.iter()\n        ));\n    });\n\n    unsigned_vec_gen::<u8>().test_properties(|xs| {\n        assert!(Iterator::eq(\n            xs.iter(),\n            RationalSequence::from_slice(&xs).iter()\n        ));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/basic/len.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{unsigned_rational_sequence_gen, unsigned_vec_gen};\n\n#[test]\npub fn test_len() {\n    fn test(non_repeating: &[u8], repeating: &[u8], out: Option<usize>) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(xs.len(), out);\n    }\n    test(&[], &[], Some(0));\n    test(&[1, 2, 3], &[], Some(3));\n    test(&[], &[1, 2, 3], None);\n    test(&[1, 2, 3], &[4, 5, 6], None);\n}\n\n#[test]\nfn len_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        assert_eq!(xs.len().is_some(), xs.is_finite());\n    });\n\n    unsigned_vec_gen::<u8>().test_properties(|xs| {\n        assert_eq!(RationalSequence::from_slice(&xs).len(), Some(xs.len()));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{\n    unsigned_rational_sequence_gen, unsigned_rational_sequence_pair_gen,\n    unsigned_rational_sequence_triple_gen,\n};\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_cmp() {\n    let xs = &[\n        RationalSequence::from_vec(vec![]),\n        RationalSequence::from_vec(vec![1, 2, 3]),\n        RationalSequence::from_vecs(vec![], vec![1, 2, 3]),\n        RationalSequence::from_vecs(vec![1, 2, 3], vec![4, 5, 6]),\n        RationalSequence::from_vec(vec![1, 2, 4]),\n    ];\n    for (i, x) in xs.iter().enumerate() {\n        for (j, y) in xs.iter().enumerate() {\n            assert_eq!(i.cmp(&j), x.clone().cmp(&y.clone()));\n        }\n    }\n}\n\n#[test]\nfn cmp_properties() {\n    unsigned_rational_sequence_pair_gen::<u8>().test_properties(|(xs, ys)| {\n        let ord = xs.cmp(&ys);\n        assert_eq!(ys.cmp(&xs).reverse(), ord);\n        assert_eq!(xs == ys, xs.cmp(&ys) == Equal);\n    });\n\n    let empty = RationalSequence::from_vec(vec![]);\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        assert_eq!(xs.cmp(&xs), Equal);\n        assert!(xs >= empty);\n    });\n\n    unsigned_rational_sequence_triple_gen::<u8>().test_properties(|(xs, ys, zs)| {\n        if xs < ys && ys < zs {\n            assert!(xs < zs);\n        } else if xs > ys && ys > zs {\n            assert!(xs > zs);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{\n    unsigned_rational_sequence_gen, unsigned_rational_sequence_pair_gen,\n    unsigned_rational_sequence_triple_gen,\n};\n\n#[test]\nfn test_eq() {\n    let xs = &[\n        RationalSequence::from_vec(vec![]),\n        RationalSequence::from_vec(vec![1, 2, 3]),\n        RationalSequence::from_vecs(vec![], vec![1, 2, 3]),\n        RationalSequence::from_vecs(vec![1, 2, 3], vec![4, 5, 6]),\n    ];\n    for (i, x) in xs.iter().enumerate() {\n        for (j, y) in xs.iter().enumerate() {\n            assert_eq!(i == j, x.clone() == y.clone());\n        }\n    }\n}\n\n#[test]\nfn eq_properties() {\n    unsigned_rational_sequence_pair_gen::<u8>().test_properties(|(xs, ys)| {\n        assert_eq!(xs == ys, ys == xs);\n    });\n\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        assert_eq!(xs, xs);\n    });\n\n    unsigned_rational_sequence_triple_gen::<u8>().test_properties(|(xs, ys, zs)| {\n        if xs == ys && ys == zs {\n            assert_eq!(xs, zs);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\nuse malachite_base::test_util::hash::hash;\n\n#[test]\nfn hash_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        assert_eq!(hash(&xs), hash(&xs.clone()));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::{\n    unsigned_rational_sequence_gen, unsigned_rational_sequence_pair_gen,\n};\n\n#[test]\n#[allow(clippy::redundant_clone)]\nfn test_clone() {\n    let test = |nr: &[u8], r: &[u8]| {\n        let xs = RationalSequence::from_slices(nr, r);\n        let xs_clone = xs.clone();\n        assert!(xs.is_valid());\n        assert_eq!(xs_clone, xs);\n    };\n    test(&[], &[]);\n    test(&[1, 2, 3], &[]);\n    test(&[], &[1, 2, 3]);\n    test(&[1, 2, 3], &[4, 5, 5]);\n}\n\n#[test]\nfn test_clone_from() {\n    let test = |nr_1: &[u8], r_1: &[u8], nr_2: &[u8], r_2: &[u8]| {\n        let mut x = RationalSequence::from_slices(nr_1, r_1);\n        let y = RationalSequence::from_slices(nr_2, r_2);\n        x.clone_from(&y);\n        assert!(x.is_valid());\n        assert_eq!(x, y);\n    };\n    test(&[], &[], &[1, 2, 3], &[4, 5, 6]);\n    test(&[], &[1, 2, 3], &[1, 2, 3], &[]);\n}\n\n#[allow(clippy::redundant_clone)]\n#[test]\nfn clone_and_clone_from_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        let mut_xs = xs.clone();\n        assert!(mut_xs.is_valid());\n        assert_eq!(mut_xs, xs);\n    });\n\n    unsigned_rational_sequence_pair_gen::<u8>().test_properties(|(xs, ys)| {\n        let mut mut_xs = xs.clone();\n        mut_xs.clone_from(&ys);\n        assert!(mut_xs.is_valid());\n        assert_eq!(mut_xs, ys);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/conversion/from_vec.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\n\n#[test]\npub fn test_from_vec_and_from_slice() {\n    fn test(non_repeating: &[u8], out: &str) {\n        assert_eq!(RationalSequence::from_slice(non_repeating).to_string(), out);\n        assert_eq!(\n            RationalSequence::from_vec(non_repeating.to_vec()).to_string(),\n            out\n        );\n    }\n    test(&[], \"[]\");\n    test(&[1, 2, 3], \"[1, 2, 3]\");\n}\n\n#[test]\nfn from_vec_and_from_slice_properties() {\n    unsigned_vec_gen::<u8>().test_properties(|xs| {\n        let rs = RationalSequence::from_slice(&xs);\n        assert!(rs.is_valid());\n        assert_eq!(rs.to_string(), xs.to_debug_string());\n        assert!(rs.is_finite());\n        assert_eq!(RationalSequence::from_vec(xs), rs);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/conversion/from_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::{RationalSequence, rational_sequence_is_reduced};\nuse malachite_base::test_util::generators::unsigned_vec_pair_gen;\n\n#[test]\npub fn test_from_vecs_and_from_slices() {\n    fn test(non_repeating: &[u8], repeating: &[u8], out: &str) {\n        assert_eq!(\n            RationalSequence::from_slices(non_repeating, repeating).to_string(),\n            out\n        );\n        assert_eq!(\n            RationalSequence::from_vecs(non_repeating.to_vec(), repeating.to_vec()).to_string(),\n            out\n        );\n    }\n    test(&[], &[], \"[]\");\n    test(&[1, 2, 3], &[], \"[1, 2, 3]\");\n    test(&[], &[1, 2, 3], \"[[1, 2, 3]]\");\n    test(&[1, 2, 3], &[4, 5, 6], \"[1, 2, 3, [4, 5, 6]]\");\n    test(&[1, 2], &[3, 4, 3, 4], \"[1, 2, [3, 4]]\");\n    test(&[1, 2, 3], &[4, 3, 4, 3], \"[1, 2, [3, 4]]\");\n    test(&[1, 2, 3, 4], &[3, 4, 3, 4], \"[1, 2, [3, 4]]\");\n}\n\n#[test]\nfn from_vec_and_from_slice_properties() {\n    unsigned_vec_pair_gen::<u8>().test_properties(|(xs, ys)| {\n        let rs = RationalSequence::from_slices(&xs, &ys);\n        assert!(rs.is_valid());\n        assert_eq!(RationalSequence::from_vecs(xs.clone(), ys.clone()), rs);\n        if rational_sequence_is_reduced(&xs, &ys) {\n            assert_eq!(rs.into_vecs(), (xs, ys));\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/conversion/to_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::generators::unsigned_rational_sequence_gen;\n\n#[test]\npub fn test_to_vecs_into_vecs_and_slices_ref() {\n    fn test(non_repeating: &[u8], repeating: &[u8], o_xs: &[u8], o_ys: &[u8]) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        let (out_xs, out_ys) = xs.to_vecs();\n        assert_eq!(out_xs, o_xs);\n        assert_eq!(out_ys, o_ys);\n        let (out_xs, out_ys) = xs.clone().into_vecs();\n        assert_eq!(out_xs, o_xs);\n        assert_eq!(out_ys, o_ys);\n        let (out_xs, out_ys) = xs.slices_ref();\n        assert_eq!(out_xs, o_xs);\n        assert_eq!(out_ys, o_ys);\n    }\n    test(&[], &[], &[], &[]);\n    test(&[1, 2, 3], &[], &[1, 2, 3], &[]);\n    test(&[], &[1, 2, 3], &[], &[1, 2, 3]);\n    test(&[1, 2, 3], &[4, 5, 6], &[1, 2, 3], &[4, 5, 6]);\n}\n\n#[test]\nfn to_vecs_into_vecs_and_slices_ref_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|rxs| {\n        let (xs, ys) = rxs.to_vecs();\n        let (xs_alt, ys_alt) = rxs.clone().into_vecs();\n        assert_eq!(xs_alt, xs);\n        assert_eq!(ys_alt, ys);\n        let (xs_alt, ys_alt) = rxs.slices_ref();\n        assert_eq!(xs_alt, xs);\n        assert_eq!(ys_alt, ys);\n        assert_eq!(RationalSequence::from_vecs(xs, ys), rxs);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::rational_sequences::exhaustive::exhaustive_rational_sequences;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::fmt::{Display, Formatter, Result};\n\n#[derive(Clone, Eq, PartialEq)]\nstruct Unit(());\n\nimpl Display for Unit {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        f.write_str(\"()\")\n    }\n}\n\n#[test]\nfn test_exhaustive_rational_sequences() {\n    assert_eq!(\n        exhaustive_rational_sequences(nevers())\n            .collect_vec()\n            .to_debug_string(),\n        \"[[]]\"\n    );\n    assert_eq!(\n        exhaustive_rational_sequences(exhaustive_units().map(Unit))\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[[], [[()]], [()], [(), ()], [(), (), (), ()], [(), (), ()], [(), (), (), (), ()], \\\n        [(), (), (), (), (), ()], [(), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), ()], [(), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()], \\\n        [(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()]]\"\n    );\n    assert_eq!(\n        exhaustive_rational_sequences(exhaustive_bools())\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[[], [[false]], [false], [[true]], [false, [true]], [true], [true, [false]], \\\n        [false, false, false], [false, false, false, [true]], [[false, false, true]], \\\n        [false, [false, false, true]], [[false, true]], [false, [false, true]], \\\n        [false, false, false, [false, false, true]], [false, false, false, [false, true]], \\\n        [false, false], [false, false, true], [false, false, true, [false]], \\\n        [false, false, [true]], [false, true]]\"\n    );\n    assert_eq!(\n        exhaustive_rational_sequences(exhaustive_unsigneds::<u8>())\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[[], [[0]], [0], [[1]], [0, [1]], [1], [1, [0]], [0, 0, 0], [0, 0, 0, [1]], [[2]], \\\n        [0, [2]], [[3]], [0, [3]], [1, [2]], [0, 0, 0, [2]], [1, [3]], [0, 0, 0, [3]], [2], \\\n        [2, [0]], [0, 0]]\"\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::rational_sequences::random::random_rational_sequences;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\n\n#[test]\nfn test_random_rational_sequences() {\n    let xs = random_rational_sequences(EXAMPLE_SEED, &random_primitive_ints::<u8>, 4, 1);\n    let values = xs\n        .clone()\n        .map(|x| RationalSequence::to_string(&x))\n        .take(20)\n        .collect_vec();\n    let values = values.iter().map(String::as_str).collect_vec();\n    let common_values = common_values_map(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(x, freq)| (x.to_string(), freq))\n        .collect_vec();\n    let common_values = common_values\n        .iter()\n        .map(|(x, freq)| (x.as_str(), *freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.take(1000000));\n    let (median_lo, median_hi) = (\n        median_lo.to_string(),\n        median_hi.map(|x| RationalSequence::to_string(&x)),\n    );\n    let actual_median = (median_lo.as_str(), median_hi.as_deref());\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), actual_median),\n        (\n            &[\n                \"[[85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32]]\",\n                \"[166, 234, 30, 218, [90, 106, 9, 216]]\",\n                \"[204]\",\n                \"[151, 213, 97, 253, 78, [91, 39]]\",\n                \"[191, 175, 170, 232]\",\n                \"[233, 2, 35, 22, 217, 198]\",\n                \"[[114, 17, 32, 173, 114, 65, 121, 222, 173, 25, 144]]\",\n                \"[148, 79, 115, 52, 73, 69, 137, 91]\",\n                \"[153, 178, 112]\",\n                \"[34, 95, 106, 167, 197, [130, 168, 122, 207, 172, 177, 86, 150, 221]]\",\n                \"[218, [101]]\",\n                \"[115, 74, 9, 123, 109, 52, 201]\",\n                \"[159, 247, 250, 48, 133, 235, 196, 40, [97]]\",\n                \"[104, 68, 190, [216, 7, 216, 157, 43, 43, 112]]\",\n                \"[]\",\n                \"[217, 24, 11, 103, 211, [84, 135]]\",\n                \"[[55, 29, 206, 89, 65, 191, 51, 9, 79]]\",\n                \"[[148, 34]]\",\n                \"[22, 22, 62, 3, 114, 118, 20, 47, 194, 50, 32, [120, 176, 166, 23]]\",\n                \"[204, 248, 177, 238, 237, 222, 154, 113, [225, 65]]\"\n            ][..],\n            &[\n                (\"[]\", 39885),\n                (\"[[243]]\", 157),\n                (\"[68]\", 154),\n                (\"[1]\", 153),\n                (\"[120]\", 153),\n                (\"[71]\", 152),\n                (\"[[40]]\", 152),\n                (\"[[158]]\", 151),\n                (\"[[169]]\", 151),\n                (\"[[183]]\", 151)\n            ][..],\n            (\n                \"[122, 194, 41, 122, [232]]\",\n                Some(\"[[122, 194, 89, 228, 124, 219]]\")\n            )\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/rational_sequences/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::{unsigned_rational_sequence_gen, unsigned_vec_gen};\n\n#[test]\npub fn test_to_string() {\n    fn test(non_repeating: &[u8], repeating: &[u8], out: &str) {\n        let xs = RationalSequence::from_slices(non_repeating, repeating);\n        assert_eq!(xs.to_string(), out);\n        assert_eq!(xs.to_debug_string(), out);\n    }\n    test(&[], &[], \"[]\");\n    test(&[1, 2, 3], &[], \"[1, 2, 3]\");\n    test(&[], &[1, 2, 3], \"[[1, 2, 3]]\");\n    test(&[1, 2, 3], &[4, 5, 6], \"[1, 2, 3, [4, 5, 6]]\");\n}\n\n#[test]\nfn to_string_properties() {\n    unsigned_rational_sequence_gen::<u8>().test_properties(|xs| {\n        let s = xs.to_string();\n        assert_eq!(xs.to_debug_string(), s);\n        assert!(string_is_subset(&s, \" ,0123456789[]\"));\n    });\n\n    unsigned_vec_gen::<u8>().test_properties(|xs| {\n        assert_eq!(\n            RationalSequence::from_slice(&xs).to_string(),\n            xs.to_debug_string()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{rounding_mode_gen, rounding_mode_pair_gen};\n\n#[test]\n#[allow(clippy::clone_on_copy)]\nfn test_clone() {\n    let test = |rm: RoundingMode| {\n        let cloned = rm.clone();\n        assert_eq!(cloned, rm);\n    };\n    test(Down);\n    test(Up);\n    test(Floor);\n    test(Ceiling);\n    test(Nearest);\n    test(Exact);\n}\n\n#[test]\nfn test_clone_from() {\n    let test = |mut x: RoundingMode, y: RoundingMode| {\n        x.clone_from(&y);\n        assert_eq!(x, y);\n    };\n    test(Exact, Floor);\n    test(Up, Ceiling);\n}\n\n#[test]\nfn clone_and_clone_from_properties() {\n    rounding_mode_gen().test_properties(|rm| {\n        assert_eq!(rm.clone(), rm);\n    });\n\n    rounding_mode_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x;\n        mut_x.clone_from(&y);\n        assert_eq!(mut_x, y);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_base::test_util::common::test_cmp_helper;\nuse malachite_base::test_util::generators::{\n    rounding_mode_gen, rounding_mode_pair_gen, rounding_mode_triple_gen,\n};\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_cmp() {\n    test_cmp_helper::<RoundingMode>(&[\"Down\", \"Up\", \"Floor\", \"Ceiling\", \"Nearest\", \"Exact\"]);\n}\n\n#[test]\nfn cmp_properties() {\n    rounding_mode_pair_gen().test_properties(|(x, y)| {\n        let ord = x.cmp(&y);\n        assert_eq!(y.cmp(&x).reverse(), ord);\n    });\n\n    rounding_mode_gen().test_properties(|x| {\n        assert_eq!(x.cmp(&x), Equal);\n    });\n\n    rounding_mode_triple_gen().test_properties(|(x, y, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_base::test_util::common::test_eq_helper;\nuse malachite_base::test_util::generators::{\n    rounding_mode_gen, rounding_mode_pair_gen, rounding_mode_triple_gen,\n};\n\n#[test]\nfn test_eq() {\n    test_eq_helper::<RoundingMode>(&[\"Down\", \"Up\", \"Floor\", \"Ceiling\", \"Nearest\", \"Exact\"]);\n}\n\n#[test]\n#[allow(clippy::eq_op)]\nfn eq_properties() {\n    rounding_mode_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(x == y, y == x);\n    });\n\n    rounding_mode_gen().test_properties(|rm| {\n        assert_eq!(rm, rm);\n    });\n\n    rounding_mode_triple_gen().test_properties(|(x, y, z)| {\n        if x == y && x == z {\n            assert_eq!(x, z);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\n\n#[test]\nfn test_exhaustive_rounding_modes() {\n    assert_eq!(\n        exhaustive_rounding_modes().collect_vec(),\n        &[Down, Up, Floor, Ceiling, Nearest, Exact]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_2};\nuse std::str::FromStr;\n\n#[test]\nfn test_from_str() {\n    let test = |s, out| {\n        assert_eq!(RoundingMode::from_str(s), out);\n    };\n    test(\"Down\", Ok(Down));\n    test(\"Up\", Ok(Up));\n    test(\"Floor\", Ok(Floor));\n    test(\"Ceiling\", Ok(Ceiling));\n    test(\"Nearest\", Ok(Nearest));\n    test(\"Exact\", Ok(Exact));\n\n    test(\"\", Err(\"\".to_string()));\n    test(\"abc\", Err(\"abc\".to_string()));\n    test(\"Uptown\", Err(\"Uptown\".to_string()));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn from_str_helper(s: String) {\n    let result = RoundingMode::from_str(&s);\n    if let Ok(result) = result {\n        assert_eq!(result.to_string(), s);\n    }\n}\n\n#[test]\nfn from_str_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_length_d\", 1);\n    string_gen().test_properties_with_config(&config, from_str_helper);\n    string_gen_var_2().test_properties_with_config(&config, from_str_helper);\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::rounding_mode_gen;\nuse malachite_base::test_util::hash::hash;\n\n#[test]\nfn hash_properties() {\n    rounding_mode_gen().test_properties(|rm| {\n        assert_eq!(hash(&rm), hash(&rm.clone()));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::rounding_mode_gen;\n\n#[test]\nfn test_neg() {\n    let test = |mut rm: RoundingMode, out| {\n        assert_eq!(-rm, out);\n        rm.neg_assign();\n        assert_eq!(rm, out);\n    };\n    test(Down, Down);\n    test(Up, Up);\n    test(Floor, Ceiling);\n    test(Ceiling, Floor);\n    test(Nearest, Nearest);\n    test(Exact, Exact);\n}\n\n#[test]\nfn neg_properties() {\n    rounding_mode_gen().test_properties(|rm| {\n        assert_eq!(-(-rm), rm);\n        let mut rm_alt = rm;\n        rm_alt.neg_assign();\n        assert_eq!(rm_alt, -rm);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::rounding_modes::random::random_rounding_modes;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\n\n#[test]\nfn test_random_rounding_modes() {\n    let xs = random_rounding_modes(EXAMPLE_SEED);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map(1000000, 10, xs.clone());\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice()),\n        (\n            &[\n                Up, Exact, Ceiling, Up, Floor, Nearest, Exact, Up, Floor, Exact, Nearest, Down,\n                Exact, Down, Floor, Exact, Floor, Down, Nearest, Down\n            ][..],\n            &[\n                (Ceiling, 167408),\n                (Down, 167104),\n                (Nearest, 166935),\n                (Exact, 166549),\n                (Floor, 166068),\n                (Up, 165936)\n            ][..]\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/size.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode;\nuse std::mem::size_of;\n\n#[test]\nfn test_size() {\n    assert_eq!(size_of::<RoundingMode>(), 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/rounding_modes/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::rounding_mode_gen;\nuse malachite_base::test_util::rounding_modes::ROUNDING_MODE_CHARS;\nuse std::str::FromStr;\n\n#[test]\nfn test_to_string() {\n    let test = |rm: RoundingMode, out| {\n        assert_eq!(rm.to_string(), out);\n    };\n    test(Down, \"Down\");\n    test(Up, \"Up\");\n    test(Floor, \"Floor\");\n    test(Ceiling, \"Ceiling\");\n    test(Nearest, \"Nearest\");\n    test(Exact, \"Exact\");\n}\n\n#[test]\nfn to_string_properties() {\n    rounding_mode_gen().test_properties(|rm| {\n        let s = rm.to_string();\n        assert_eq!(RoundingMode::from_str(&s), Ok(rm));\n        assert!(string_is_subset(&s, ROUNDING_MODE_CHARS));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_b_tree_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_b_tree_sets;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn exhaustive_b_tree_sets_helper<I: Clone + Iterator>(xs: I, out: &[BTreeSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(exhaustive_b_tree_sets(xs), out);\n}\n\nfn exhaustive_b_tree_sets_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(exhaustive_b_tree_sets(xs), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_b_tree_sets() {\n    exhaustive_b_tree_sets_small_helper(nevers(), 1, &[btreeset! {}]);\n    exhaustive_b_tree_sets_small_helper(exhaustive_units(), 2, &[btreeset! {}, btreeset! {()}]);\n    exhaustive_b_tree_sets_small_helper(\n        exhaustive_bools(),\n        4,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}, btreeset! {false, true}],\n    );\n    exhaustive_b_tree_sets_small_helper(\n        1..=6,\n        64,\n        &[\n            btreeset! {},\n            btreeset! {1},\n            btreeset! {2},\n            btreeset! {1, 2},\n            btreeset! {3},\n            btreeset! {1, 3},\n            btreeset! {2, 3},\n            btreeset! {1, 2, 3},\n            btreeset! {4},\n            btreeset! {1, 4},\n            btreeset! {2, 4},\n            btreeset! {1, 2, 4},\n            btreeset! {3, 4},\n            btreeset! {1, 3, 4},\n            btreeset! {2, 3, 4},\n            btreeset! {1, 2, 3, 4},\n            btreeset! {5},\n            btreeset! {1, 5},\n            btreeset! {2, 5},\n            btreeset! {1, 2, 5},\n        ],\n    );\n    exhaustive_b_tree_sets_small_helper(\n        'a'..='c',\n        8,\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'a', 'b'},\n            btreeset! {'c'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n        ],\n    );\n    exhaustive_b_tree_sets_helper(\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'a', 'b'},\n            btreeset! {'c'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'d'},\n            btreeset! {'a', 'd'},\n            btreeset! {'b', 'd'},\n            btreeset! {'a', 'b', 'd'},\n            btreeset! {'c', 'd'},\n            btreeset! {'a', 'c', 'd'},\n            btreeset! {'b', 'c', 'd'},\n            btreeset! {'a', 'b', 'c', 'd'},\n            btreeset! {'e'},\n            btreeset! {'a', 'e'},\n            btreeset! {'b', 'e'},\n            btreeset! {'a', 'b', 'e'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_b_tree_sets_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::sets::exhaustive::exhaustive_b_tree_sets_fixed_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_fixed_length;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn exhaustive_b_tree_sets_fixed_length_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(exhaustive_b_tree_sets_fixed_length(len, xs), out);\n}\n\nfn exhaustive_b_tree_sets_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        exhaustive_b_tree_sets_fixed_length(len, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_b_tree_sets_fixed_length() {\n    // This demonstrates that 0 ^ 0 == 1:\n    exhaustive_b_tree_sets_fixed_length_small_helper(0, nevers(), 1, &[btreeset! {}]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(1, nevers(), 0, &[]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(2, nevers(), 0, &[]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(5, nevers(), 0, &[]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(1, exhaustive_units(), 1, &[btreeset! {()}]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(\n        0,\n        exhaustive_unsigneds::<u8>(),\n        1,\n        &[btreeset! {}],\n    );\n    exhaustive_b_tree_sets_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            btreeset! {0},\n            btreeset! {1},\n            btreeset! {2},\n            btreeset! {3},\n            btreeset! {4},\n            btreeset! {5},\n            btreeset! {6},\n            btreeset! {7},\n            btreeset! {8},\n            btreeset! {9},\n            btreeset! {10},\n            btreeset! {11},\n            btreeset! {12},\n            btreeset! {13},\n            btreeset! {14},\n            btreeset! {15},\n            btreeset! {16},\n            btreeset! {17},\n            btreeset! {18},\n            btreeset! {19},\n        ],\n    );\n    exhaustive_b_tree_sets_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            btreeset! {0},\n            btreeset! {1},\n            btreeset! {2},\n            btreeset! {3},\n            btreeset! {4},\n            btreeset! {5},\n            btreeset! {6},\n            btreeset! {7},\n            btreeset! {8},\n            btreeset! {9},\n            btreeset! {10},\n            btreeset! {11},\n            btreeset! {12},\n            btreeset! {13},\n            btreeset! {14},\n            btreeset! {15},\n            btreeset! {16},\n            btreeset! {17},\n            btreeset! {18},\n            btreeset! {19},\n        ],\n    );\n    exhaustive_b_tree_sets_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            btreeset! {0, 1},\n            btreeset! {0, 2},\n            btreeset! {1, 2},\n            btreeset! {0, 3},\n            btreeset! {1, 3},\n            btreeset! {2, 3},\n            btreeset! {0, 4},\n            btreeset! {1, 4},\n            btreeset! {2, 4},\n            btreeset! {3, 4},\n            btreeset! {0, 5},\n            btreeset! {1, 5},\n            btreeset! {2, 5},\n            btreeset! {3, 5},\n            btreeset! {4, 5},\n            btreeset! {0, 6},\n            btreeset! {1, 6},\n            btreeset! {2, 6},\n            btreeset! {3, 6},\n            btreeset! {4, 6},\n        ],\n    );\n    exhaustive_b_tree_sets_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            btreeset! {0, 1, 2},\n            btreeset! {0, 1, 3},\n            btreeset! {0, 2, 3},\n            btreeset! {1, 2, 3},\n            btreeset! {0, 1, 4},\n            btreeset! {0, 2, 4},\n            btreeset! {1, 2, 4},\n            btreeset! {0, 3, 4},\n            btreeset! {1, 3, 4},\n            btreeset! {2, 3, 4},\n            btreeset! {0, 1, 5},\n            btreeset! {0, 2, 5},\n            btreeset! {1, 2, 5},\n            btreeset! {0, 3, 5},\n            btreeset! {1, 3, 5},\n            btreeset! {2, 3, 5},\n            btreeset! {0, 4, 5},\n            btreeset! {1, 4, 5},\n            btreeset! {2, 4, 5},\n            btreeset! {3, 4, 5},\n        ],\n    );\n    exhaustive_b_tree_sets_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'd'},\n            btreeset! {'b', 'd'},\n            btreeset! {'c', 'd'},\n            btreeset! {'a', 'e'},\n            btreeset! {'b', 'e'},\n            btreeset! {'c', 'e'},\n            btreeset! {'d', 'e'},\n            btreeset! {'a', 'f'},\n            btreeset! {'b', 'f'},\n            btreeset! {'c', 'f'},\n            btreeset! {'d', 'f'},\n            btreeset! {'e', 'f'},\n            btreeset! {'a', 'g'},\n            btreeset! {'b', 'g'},\n            btreeset! {'c', 'g'},\n            btreeset! {'d', 'g'},\n            btreeset! {'e', 'g'},\n        ],\n    );\n    exhaustive_b_tree_sets_fixed_length_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[btreeset! {false}, btreeset! {true}],\n    );\n    exhaustive_b_tree_sets_fixed_length_small_helper(\n        2,\n        exhaustive_bools(),\n        1,\n        &[btreeset! {false, true}],\n    );\n    exhaustive_b_tree_sets_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    exhaustive_b_tree_sets_fixed_length_small_helper(\n        4,\n        1..=6,\n        15,\n        &[\n            btreeset! {1, 2, 3, 4},\n            btreeset! {1, 2, 3, 5},\n            btreeset! {1, 2, 4, 5},\n            btreeset! {1, 3, 4, 5},\n            btreeset! {2, 3, 4, 5},\n            btreeset! {1, 2, 3, 6},\n            btreeset! {1, 2, 4, 6},\n            btreeset! {1, 3, 4, 6},\n            btreeset! {2, 3, 4, 6},\n            btreeset! {1, 2, 5, 6},\n            btreeset! {1, 3, 5, 6},\n            btreeset! {2, 3, 5, 6},\n            btreeset! {1, 4, 5, 6},\n            btreeset! {2, 4, 5, 6},\n            btreeset! {3, 4, 5, 6},\n        ],\n    );\n    exhaustive_b_tree_sets_fixed_length_helper(\n        2,\n        exhaustive_ordered_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            btreeset! {vec![0, 1], vec![0, 2]},\n            btreeset! {vec![0, 1], vec![1, 2]},\n            btreeset! {vec![0, 2], vec![1, 2]},\n            btreeset! {vec![0, 1], vec![0, 3]},\n            btreeset! {vec![0, 2], vec![0, 3]},\n            btreeset! {vec![1, 2], vec![0, 3]},\n            btreeset! {vec![0, 1], vec![1, 3]},\n            btreeset! {vec![0, 2], vec![1, 3]},\n            btreeset! {vec![1, 2], vec![1, 3]},\n            btreeset! {vec![0, 3], vec![1, 3]},\n            btreeset! {vec![0, 1], vec![2, 3]},\n            btreeset! {vec![0, 2], vec![2, 3]},\n            btreeset! {vec![1, 2], vec![2, 3]},\n            btreeset! {vec![0, 3], vec![2, 3]},\n            btreeset! {vec![1, 3], vec![2, 3]},\n            btreeset! {vec![0, 1], vec![0, 4]},\n            btreeset! {vec![0, 2], vec![0, 4]},\n            btreeset! {vec![1, 2], vec![0, 4]},\n            btreeset! {vec![0, 3], vec![0, 4]},\n            btreeset! {vec![1, 3], vec![0, 4]},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_b_tree_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_b_tree_sets_length_inclusive_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_b_tree_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn exhaustive_b_tree_sets_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        exhaustive_b_tree_sets_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_b_tree_sets_length_inclusive_range() {\n    exhaustive_b_tree_sets_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[btreeset! {}]);\n    exhaustive_b_tree_sets_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    exhaustive_b_tree_sets_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    exhaustive_b_tree_sets_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    exhaustive_b_tree_sets_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}],\n    );\n    exhaustive_b_tree_sets_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[btreeset! {false, true}],\n    );\n    exhaustive_b_tree_sets_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[btreeset! {'a'}, btreeset! {'b'}, btreeset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_b_tree_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_b_tree_sets_length_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_b_tree_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn exhaustive_b_tree_sets_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        exhaustive_b_tree_sets_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_b_tree_sets_length_range() {\n    exhaustive_b_tree_sets_length_range_small_helper(0, 5, nevers(), 1, &[btreeset! {}]);\n    exhaustive_b_tree_sets_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    exhaustive_b_tree_sets_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    exhaustive_b_tree_sets_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    exhaustive_b_tree_sets_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    exhaustive_b_tree_sets_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}],\n    );\n    exhaustive_b_tree_sets_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[btreeset! {false, true}],\n    );\n    exhaustive_b_tree_sets_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[btreeset! {'a'}, btreeset! {'b'}, btreeset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_b_tree_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_b_tree_sets_min_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn exhaustive_b_tree_sets_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(exhaustive_b_tree_sets_min_length(min_length, xs), out);\n}\n\nfn exhaustive_b_tree_sets_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        exhaustive_b_tree_sets_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_b_tree_sets_min_length() {\n    exhaustive_b_tree_sets_min_length_small_helper(0, nevers(), 1, &[btreeset! {}]);\n    exhaustive_b_tree_sets_min_length_small_helper(4, nevers(), 0, &[]);\n    exhaustive_b_tree_sets_min_length_small_helper(\n        0,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    exhaustive_b_tree_sets_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_b_tree_sets_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}, btreeset! {false, true}],\n    );\n    exhaustive_b_tree_sets_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {false}, btreeset! {true}, btreeset! {false, true}],\n    );\n    exhaustive_b_tree_sets_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'a', 'b'},\n            btreeset! {'c'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n        ],\n    );\n    exhaustive_b_tree_sets_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n        ],\n    );\n    exhaustive_b_tree_sets_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'a', 'b'},\n            btreeset! {'c'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'d'},\n            btreeset! {'a', 'd'},\n            btreeset! {'b', 'd'},\n            btreeset! {'a', 'b', 'd'},\n            btreeset! {'c', 'd'},\n            btreeset! {'a', 'c', 'd'},\n            btreeset! {'b', 'c', 'd'},\n            btreeset! {'a', 'b', 'c', 'd'},\n            btreeset! {'e'},\n            btreeset! {'a', 'e'},\n            btreeset! {'b', 'e'},\n            btreeset! {'a', 'b', 'e'},\n        ],\n    );\n    exhaustive_b_tree_sets_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'b', 'd'},\n            btreeset! {'a', 'c', 'd'},\n            btreeset! {'b', 'c', 'd'},\n            btreeset! {'a', 'b', 'c', 'd'},\n            btreeset! {'a', 'b', 'e'},\n            btreeset! {'a', 'c', 'e'},\n            btreeset! {'b', 'c', 'e'},\n            btreeset! {'a', 'b', 'c', 'e'},\n            btreeset! {'a', 'd', 'e'},\n            btreeset! {'b', 'd', 'e'},\n            btreeset! {'a', 'b', 'd', 'e'},\n            btreeset! {'c', 'd', 'e'},\n            btreeset! {'a', 'c', 'd', 'e'},\n            btreeset! {'b', 'c', 'd', 'e'},\n            btreeset! {'a', 'b', 'c', 'd', 'e'},\n            btreeset! {'a', 'b', 'f'},\n            btreeset! {'a', 'c', 'f'},\n            btreeset! {'b', 'c', 'f'},\n            btreeset! {'a', 'b', 'c', 'f'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_hash_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_hash_sets;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn exhaustive_hash_sets_helper<I: Clone + Iterator>(xs: I, out: &[HashSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(exhaustive_hash_sets(xs), out);\n}\n\nfn exhaustive_hash_sets_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(exhaustive_hash_sets(xs), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_hash_sets() {\n    exhaustive_hash_sets_small_helper(nevers(), 1, &[hashset! {}]);\n    exhaustive_hash_sets_small_helper(exhaustive_units(), 2, &[hashset! {}, hashset! {()}]);\n    exhaustive_hash_sets_small_helper(\n        exhaustive_bools(),\n        4,\n        &[hashset! {}, hashset! {false}, hashset! {true}, hashset! {false, true}],\n    );\n    exhaustive_hash_sets_small_helper(\n        1..=6,\n        64,\n        &[\n            hashset! {},\n            hashset! {1},\n            hashset! {2},\n            hashset! {1, 2},\n            hashset! {3},\n            hashset! {1, 3},\n            hashset! {2, 3},\n            hashset! {1, 2, 3},\n            hashset! {4},\n            hashset! {1, 4},\n            hashset! {2, 4},\n            hashset! {1, 2, 4},\n            hashset! {3, 4},\n            hashset! {1, 3, 4},\n            hashset! {2, 3, 4},\n            hashset! {1, 2, 3, 4},\n            hashset! {5},\n            hashset! {1, 5},\n            hashset! {2, 5},\n            hashset! {1, 2, 5},\n        ],\n    );\n    exhaustive_hash_sets_small_helper(\n        'a'..='c',\n        8,\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'a', 'b'},\n            hashset! {'c'},\n            hashset! {'a', 'c'},\n            hashset! {'b', 'c'},\n            hashset! {'a', 'b', 'c'},\n        ],\n    );\n    exhaustive_hash_sets_helper(\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'a', 'b'},\n            hashset! {'c'},\n            hashset! {'a', 'c'},\n            hashset! {'b', 'c'},\n            hashset! {'a', 'b', 'c'},\n            hashset! {'d'},\n            hashset! {'a', 'd'},\n            hashset! {'b', 'd'},\n            hashset! {'a', 'b', 'd'},\n            hashset! {'c', 'd'},\n            hashset! {'a', 'c', 'd'},\n            hashset! {'b', 'c', 'd'},\n            hashset! {'a', 'b', 'c', 'd'},\n            hashset! {'e'},\n            hashset! {'a', 'e'},\n            hashset! {'b', 'e'},\n            hashset! {'a', 'b', 'e'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_hash_sets_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::sets::exhaustive::exhaustive_hash_sets_fixed_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_fixed_length;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn exhaustive_hash_sets_fixed_length_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(exhaustive_hash_sets_fixed_length(len, xs), out);\n}\n\nfn exhaustive_hash_sets_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        exhaustive_hash_sets_fixed_length(len, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_hash_sets_fixed_length() {\n    // This demonstrates that 0 ^ 0 == 1:\n    exhaustive_hash_sets_fixed_length_small_helper(0, nevers(), 1, &[hashset! {}]);\n    exhaustive_hash_sets_fixed_length_small_helper(1, nevers(), 0, &[]);\n    exhaustive_hash_sets_fixed_length_small_helper(2, nevers(), 0, &[]);\n    exhaustive_hash_sets_fixed_length_small_helper(5, nevers(), 0, &[]);\n    exhaustive_hash_sets_fixed_length_small_helper(1, exhaustive_units(), 1, &[hashset! {()}]);\n    exhaustive_hash_sets_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    exhaustive_hash_sets_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_hash_sets_fixed_length_small_helper(\n        0,\n        exhaustive_unsigneds::<u8>(),\n        1,\n        &[hashset! {}],\n    );\n    exhaustive_hash_sets_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            hashset! {0},\n            hashset! {1},\n            hashset! {2},\n            hashset! {3},\n            hashset! {4},\n            hashset! {5},\n            hashset! {6},\n            hashset! {7},\n            hashset! {8},\n            hashset! {9},\n            hashset! {10},\n            hashset! {11},\n            hashset! {12},\n            hashset! {13},\n            hashset! {14},\n            hashset! {15},\n            hashset! {16},\n            hashset! {17},\n            hashset! {18},\n            hashset! {19},\n        ],\n    );\n    exhaustive_hash_sets_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            hashset! {0},\n            hashset! {1},\n            hashset! {2},\n            hashset! {3},\n            hashset! {4},\n            hashset! {5},\n            hashset! {6},\n            hashset! {7},\n            hashset! {8},\n            hashset! {9},\n            hashset! {10},\n            hashset! {11},\n            hashset! {12},\n            hashset! {13},\n            hashset! {14},\n            hashset! {15},\n            hashset! {16},\n            hashset! {17},\n            hashset! {18},\n            hashset! {19},\n        ],\n    );\n    exhaustive_hash_sets_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            hashset! {0, 1},\n            hashset! {0, 2},\n            hashset! {1, 2},\n            hashset! {0, 3},\n            hashset! {1, 3},\n            hashset! {2, 3},\n            hashset! {0, 4},\n            hashset! {1, 4},\n            hashset! {2, 4},\n            hashset! {3, 4},\n            hashset! {0, 5},\n            hashset! {1, 5},\n            hashset! {2, 5},\n            hashset! {3, 5},\n            hashset! {4, 5},\n            hashset! {0, 6},\n            hashset! {1, 6},\n            hashset! {2, 6},\n            hashset! {3, 6},\n            hashset! {4, 6},\n        ],\n    );\n    exhaustive_hash_sets_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            hashset! {0, 1, 2},\n            hashset! {0, 1, 3},\n            hashset! {0, 2, 3},\n            hashset! {1, 2, 3},\n            hashset! {0, 1, 4},\n            hashset! {0, 2, 4},\n            hashset! {1, 2, 4},\n            hashset! {0, 3, 4},\n            hashset! {1, 3, 4},\n            hashset! {2, 3, 4},\n            hashset! {0, 1, 5},\n            hashset! {0, 2, 5},\n            hashset! {1, 2, 5},\n            hashset! {0, 3, 5},\n            hashset! {1, 3, 5},\n            hashset! {2, 3, 5},\n            hashset! {0, 4, 5},\n            hashset! {1, 4, 5},\n            hashset! {2, 4, 5},\n            hashset! {3, 4, 5},\n        ],\n    );\n    exhaustive_hash_sets_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            hashset! {'a', 'b'},\n            hashset! {'a', 'c'},\n            hashset! {'b', 'c'},\n            hashset! {'a', 'd'},\n            hashset! {'b', 'd'},\n            hashset! {'c', 'd'},\n            hashset! {'a', 'e'},\n            hashset! {'b', 'e'},\n            hashset! {'c', 'e'},\n            hashset! {'d', 'e'},\n            hashset! {'a', 'f'},\n            hashset! {'b', 'f'},\n            hashset! {'c', 'f'},\n            hashset! {'d', 'f'},\n            hashset! {'e', 'f'},\n            hashset! {'a', 'g'},\n            hashset! {'b', 'g'},\n            hashset! {'c', 'g'},\n            hashset! {'d', 'g'},\n            hashset! {'e', 'g'},\n        ],\n    );\n    exhaustive_hash_sets_fixed_length_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[hashset! {false}, hashset! {true}],\n    );\n    exhaustive_hash_sets_fixed_length_small_helper(\n        2,\n        exhaustive_bools(),\n        1,\n        &[hashset! {false, true}],\n    );\n    exhaustive_hash_sets_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    exhaustive_hash_sets_fixed_length_small_helper(\n        4,\n        1..=6,\n        15,\n        &[\n            hashset! {1, 2, 3, 4},\n            hashset! {1, 2, 3, 5},\n            hashset! {1, 2, 4, 5},\n            hashset! {1, 3, 4, 5},\n            hashset! {2, 3, 4, 5},\n            hashset! {1, 2, 3, 6},\n            hashset! {1, 2, 4, 6},\n            hashset! {1, 3, 4, 6},\n            hashset! {2, 3, 4, 6},\n            hashset! {1, 2, 5, 6},\n            hashset! {1, 3, 5, 6},\n            hashset! {2, 3, 5, 6},\n            hashset! {1, 4, 5, 6},\n            hashset! {2, 4, 5, 6},\n            hashset! {3, 4, 5, 6},\n        ],\n    );\n    exhaustive_hash_sets_fixed_length_helper(\n        2,\n        exhaustive_ordered_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            hashset! {vec![0, 1], vec![0, 2]},\n            hashset! {vec![0, 1], vec![1, 2]},\n            hashset! {vec![0, 2], vec![1, 2]},\n            hashset! {vec![0, 1], vec![0, 3]},\n            hashset! {vec![0, 2], vec![0, 3]},\n            hashset! {vec![1, 2], vec![0, 3]},\n            hashset! {vec![0, 1], vec![1, 3]},\n            hashset! {vec![0, 2], vec![1, 3]},\n            hashset! {vec![1, 2], vec![1, 3]},\n            hashset! {vec![0, 3], vec![1, 3]},\n            hashset! {vec![0, 1], vec![2, 3]},\n            hashset! {vec![0, 2], vec![2, 3]},\n            hashset! {vec![1, 2], vec![2, 3]},\n            hashset! {vec![0, 3], vec![2, 3]},\n            hashset! {vec![1, 3], vec![2, 3]},\n            hashset! {vec![0, 1], vec![0, 4]},\n            hashset! {vec![0, 2], vec![0, 4]},\n            hashset! {vec![1, 2], vec![0, 4]},\n            hashset! {vec![0, 3], vec![0, 4]},\n            hashset! {vec![1, 3], vec![0, 4]},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_hash_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_hash_sets_length_inclusive_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_hash_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn exhaustive_hash_sets_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        exhaustive_hash_sets_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_hash_sets_length_inclusive_range() {\n    exhaustive_hash_sets_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[hashset! {}]);\n    exhaustive_hash_sets_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    exhaustive_hash_sets_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    exhaustive_hash_sets_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    exhaustive_hash_sets_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[hashset! {}, hashset! {false}, hashset! {true}],\n    );\n    exhaustive_hash_sets_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[hashset! {false, true}],\n    );\n    exhaustive_hash_sets_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[hashset! {'a'}, hashset! {'b'}, hashset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_hash_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_hash_sets_length_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_hash_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn exhaustive_hash_sets_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        exhaustive_hash_sets_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_hash_sets_length_range() {\n    exhaustive_hash_sets_length_range_small_helper(0, 5, nevers(), 1, &[hashset! {}]);\n    exhaustive_hash_sets_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    exhaustive_hash_sets_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    exhaustive_hash_sets_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    exhaustive_hash_sets_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    exhaustive_hash_sets_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[hashset! {}, hashset! {false}, hashset! {true}],\n    );\n    exhaustive_hash_sets_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[hashset! {false, true}],\n    );\n    exhaustive_hash_sets_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[hashset! {'a'}, hashset! {'b'}, hashset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/exhaustive_hash_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::exhaustive_hash_sets_min_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn exhaustive_hash_sets_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(exhaustive_hash_sets_min_length(min_length, xs), out);\n}\n\nfn exhaustive_hash_sets_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        exhaustive_hash_sets_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_hash_sets_min_length() {\n    exhaustive_hash_sets_min_length_small_helper(0, nevers(), 1, &[hashset! {}]);\n    exhaustive_hash_sets_min_length_small_helper(4, nevers(), 0, &[]);\n    exhaustive_hash_sets_min_length_small_helper(\n        0,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    exhaustive_hash_sets_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_hash_sets_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[hashset! {}, hashset! {false}, hashset! {true}, hashset! {false, true}],\n    );\n    exhaustive_hash_sets_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[hashset! {false}, hashset! {true}, hashset! {false, true}],\n    );\n    exhaustive_hash_sets_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'a', 'b'},\n            hashset! {'c'},\n            hashset! {'a', 'c'},\n            hashset! {'b', 'c'},\n            hashset! {'a', 'b', 'c'},\n        ],\n    );\n    exhaustive_hash_sets_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[hashset! {'a', 'b'}, hashset! {'a', 'c'}, hashset! {'b', 'c'}, hashset! {'a', 'b', 'c'}],\n    );\n    exhaustive_hash_sets_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'a', 'b'},\n            hashset! {'c'},\n            hashset! {'a', 'c'},\n            hashset! {'b', 'c'},\n            hashset! {'a', 'b', 'c'},\n            hashset! {'d'},\n            hashset! {'a', 'd'},\n            hashset! {'b', 'd'},\n            hashset! {'a', 'b', 'd'},\n            hashset! {'c', 'd'},\n            hashset! {'a', 'c', 'd'},\n            hashset! {'b', 'c', 'd'},\n            hashset! {'a', 'b', 'c', 'd'},\n            hashset! {'e'},\n            hashset! {'a', 'e'},\n            hashset! {'b', 'e'},\n            hashset! {'a', 'b', 'e'},\n        ],\n    );\n    exhaustive_hash_sets_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {'a', 'b', 'c'},\n            hashset! {'a', 'b', 'd'},\n            hashset! {'a', 'c', 'd'},\n            hashset! {'b', 'c', 'd'},\n            hashset! {'a', 'b', 'c', 'd'},\n            hashset! {'a', 'b', 'e'},\n            hashset! {'a', 'c', 'e'},\n            hashset! {'b', 'c', 'e'},\n            hashset! {'a', 'b', 'c', 'e'},\n            hashset! {'a', 'd', 'e'},\n            hashset! {'b', 'd', 'e'},\n            hashset! {'a', 'b', 'd', 'e'},\n            hashset! {'c', 'd', 'e'},\n            hashset! {'a', 'c', 'd', 'e'},\n            hashset! {'b', 'c', 'd', 'e'},\n            hashset! {'a', 'b', 'c', 'd', 'e'},\n            hashset! {'a', 'b', 'f'},\n            hashset! {'a', 'c', 'f'},\n            hashset! {'b', 'c', 'f'},\n            hashset! {'a', 'b', 'c', 'f'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_b_tree_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_b_tree_sets;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn lex_b_tree_sets_helper<I: Clone + Iterator>(xs: I, out: &[BTreeSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(lex_b_tree_sets(xs), out);\n}\n\nfn lex_b_tree_sets_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(lex_b_tree_sets(xs), out_len, out);\n}\n\n#[test]\nfn test_lex_b_tree_sets() {\n    lex_b_tree_sets_small_helper(nevers(), 1, &[btreeset! {}]);\n    lex_b_tree_sets_small_helper(exhaustive_units(), 2, &[btreeset! {}, btreeset! {()}]);\n    lex_b_tree_sets_small_helper(\n        exhaustive_bools(),\n        4,\n        &[btreeset! {}, btreeset! {false}, btreeset! {false, true}, btreeset! {true}],\n    );\n    lex_b_tree_sets_small_helper(\n        1..=6,\n        64,\n        &[\n            btreeset! {},\n            btreeset! {1},\n            btreeset! {1, 2},\n            btreeset! {1, 2, 3},\n            btreeset! {1, 2, 3, 4},\n            btreeset! {1, 2, 3, 4, 5},\n            btreeset! {1, 2, 3, 4, 5, 6},\n            btreeset! {1, 2, 3, 4, 6},\n            btreeset! {1, 2, 3, 5},\n            btreeset! {1, 2, 3, 5, 6},\n            btreeset! {1, 2, 3, 6},\n            btreeset! {1, 2, 4},\n            btreeset! {1, 2, 4, 5},\n            btreeset! {1, 2, 4, 5, 6},\n            btreeset! {1, 2, 4, 6},\n            btreeset! {1, 2, 5},\n            btreeset! {1, 2, 5, 6},\n            btreeset! {1, 2, 6},\n            btreeset! {1, 3},\n            btreeset! {1, 3, 4},\n        ],\n    );\n    lex_b_tree_sets_small_helper(\n        'a'..='c',\n        8,\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b'},\n            btreeset! {'b', 'c'},\n            btreeset! {'c'},\n        ],\n    );\n    lex_b_tree_sets_helper(\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'b', 'c', 'd'},\n            btreeset! {'a', 'b', 'c', 'd', 'e'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'},\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            },\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_b_tree_sets_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::sets::exhaustive::lex_b_tree_sets_fixed_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_fixed_length;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn lex_b_tree_sets_fixed_length_helper<I: Iterator>(len: u64, xs: I, out: &[BTreeSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(lex_b_tree_sets_fixed_length(len, xs), out);\n}\n\nfn lex_b_tree_sets_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(lex_b_tree_sets_fixed_length(len, xs), out_len, out);\n}\n\n#[test]\nfn test_lex_b_tree_sets_fixed_length() {\n    lex_b_tree_sets_fixed_length_small_helper(0, nevers(), 1, &[btreeset! {}]);\n    lex_b_tree_sets_fixed_length_small_helper(1, nevers(), 0, &[]);\n    lex_b_tree_sets_fixed_length_small_helper(2, nevers(), 0, &[]);\n    lex_b_tree_sets_fixed_length_small_helper(5, nevers(), 0, &[]);\n    lex_b_tree_sets_fixed_length_small_helper(1, exhaustive_units(), 1, &[btreeset! {()}]);\n    lex_b_tree_sets_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    lex_b_tree_sets_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_b_tree_sets_fixed_length_small_helper(0, exhaustive_unsigneds::<u8>(), 1, &[btreeset! {}]);\n    lex_b_tree_sets_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            btreeset! {0},\n            btreeset! {1},\n            btreeset! {2},\n            btreeset! {3},\n            btreeset! {4},\n            btreeset! {5},\n            btreeset! {6},\n            btreeset! {7},\n            btreeset! {8},\n            btreeset! {9},\n            btreeset! {10},\n            btreeset! {11},\n            btreeset! {12},\n            btreeset! {13},\n            btreeset! {14},\n            btreeset! {15},\n            btreeset! {16},\n            btreeset! {17},\n            btreeset! {18},\n            btreeset! {19},\n        ],\n    );\n    lex_b_tree_sets_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            btreeset! {0},\n            btreeset! {1},\n            btreeset! {2},\n            btreeset! {3},\n            btreeset! {4},\n            btreeset! {5},\n            btreeset! {6},\n            btreeset! {7},\n            btreeset! {8},\n            btreeset! {9},\n            btreeset! {10},\n            btreeset! {11},\n            btreeset! {12},\n            btreeset! {13},\n            btreeset! {14},\n            btreeset! {15},\n            btreeset! {16},\n            btreeset! {17},\n            btreeset! {18},\n            btreeset! {19},\n        ],\n    );\n    lex_b_tree_sets_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            btreeset! {0, 1},\n            btreeset! {0, 2},\n            btreeset! {0, 3},\n            btreeset! {0, 4},\n            btreeset! {0, 5},\n            btreeset! {0, 6},\n            btreeset! {0, 7},\n            btreeset! {0, 8},\n            btreeset! {0, 9},\n            btreeset! {0, 10},\n            btreeset! {0, 11},\n            btreeset! {0, 12},\n            btreeset! {0, 13},\n            btreeset! {0, 14},\n            btreeset! {0, 15},\n            btreeset! {0, 16},\n            btreeset! {0, 17},\n            btreeset! {0, 18},\n            btreeset! {0, 19},\n            btreeset! {0, 20},\n        ],\n    );\n    lex_b_tree_sets_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            btreeset! {0, 1, 2},\n            btreeset! {0, 1, 3},\n            btreeset! {0, 1, 4},\n            btreeset! {0, 1, 5},\n            btreeset! {0, 1, 6},\n            btreeset! {0, 1, 7},\n            btreeset! {0, 1, 8},\n            btreeset! {0, 1, 9},\n            btreeset! {0, 1, 10},\n            btreeset! {0, 1, 11},\n            btreeset! {0, 1, 12},\n            btreeset! {0, 1, 13},\n            btreeset! {0, 1, 14},\n            btreeset! {0, 1, 15},\n            btreeset! {0, 1, 16},\n            btreeset! {0, 1, 17},\n            btreeset! {0, 1, 18},\n            btreeset! {0, 1, 19},\n            btreeset! {0, 1, 20},\n            btreeset! {0, 1, 21},\n        ],\n    );\n    lex_b_tree_sets_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'c'},\n            btreeset! {'a', 'd'},\n            btreeset! {'a', 'e'},\n            btreeset! {'a', 'f'},\n            btreeset! {'a', 'g'},\n            btreeset! {'a', 'h'},\n            btreeset! {'a', 'i'},\n            btreeset! {'a', 'j'},\n            btreeset! {'a', 'k'},\n            btreeset! {'a', 'l'},\n            btreeset! {'a', 'm'},\n            btreeset! {'a', 'n'},\n            btreeset! {'a', 'o'},\n            btreeset! {'a', 'p'},\n            btreeset! {'a', 'q'},\n            btreeset! {'a', 'r'},\n            btreeset! {'a', 's'},\n            btreeset! {'a', 't'},\n            btreeset! {'a', 'u'},\n        ],\n    );\n    lex_b_tree_sets_fixed_length_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[btreeset! {false}, btreeset! {true}],\n    );\n    lex_b_tree_sets_fixed_length_small_helper(2, exhaustive_bools(), 1, &[btreeset! {false, true}]);\n    lex_b_tree_sets_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    lex_b_tree_sets_fixed_length_small_helper(\n        4,\n        1..=6,\n        15,\n        &[\n            btreeset! {1, 2, 3, 4},\n            btreeset! {1, 2, 3, 5},\n            btreeset! {1, 2, 3, 6},\n            btreeset! {1, 2, 4, 5},\n            btreeset! {1, 2, 4, 6},\n            btreeset! {1, 2, 5, 6},\n            btreeset! {1, 3, 4, 5},\n            btreeset! {1, 3, 4, 6},\n            btreeset! {1, 3, 5, 6},\n            btreeset! {1, 4, 5, 6},\n            btreeset! {2, 3, 4, 5},\n            btreeset! {2, 3, 4, 6},\n            btreeset! {2, 3, 5, 6},\n            btreeset! {2, 4, 5, 6},\n            btreeset! {3, 4, 5, 6},\n        ],\n    );\n    lex_b_tree_sets_fixed_length_helper(\n        2,\n        lex_ordered_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            btreeset! {vec![0, 1], vec![0, 2]},\n            btreeset! {vec![0, 1], vec![0, 3]},\n            btreeset! {vec![0, 1], vec![0, 4]},\n            btreeset! {vec![0, 1], vec![0, 5]},\n            btreeset! {vec![0, 1], vec![0, 6]},\n            btreeset! {vec![0, 1], vec![0, 7]},\n            btreeset! {vec![0, 1], vec![0, 8]},\n            btreeset! {vec![0, 1], vec![0, 9]},\n            btreeset! {vec![0, 1], vec![0, 10]},\n            btreeset! {vec![0, 1], vec![0, 11]},\n            btreeset! {vec![0, 1], vec![0, 12]},\n            btreeset! {vec![0, 1], vec![0, 13]},\n            btreeset! {vec![0, 1], vec![0, 14]},\n            btreeset! {vec![0, 1], vec![0, 15]},\n            btreeset! {vec![0, 1], vec![0, 16]},\n            btreeset! {vec![0, 1], vec![0, 17]},\n            btreeset! {vec![0, 1], vec![0, 18]},\n            btreeset! {vec![0, 1], vec![0, 19]},\n            btreeset! {vec![0, 1], vec![0, 20]},\n            btreeset! {vec![0, 1], vec![0, 21]},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_b_tree_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_b_tree_sets_length_inclusive_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_b_tree_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn lex_b_tree_sets_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        lex_b_tree_sets_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_b_tree_sets_length_inclusive_range() {\n    lex_b_tree_sets_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[btreeset! {}]);\n    lex_b_tree_sets_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    lex_b_tree_sets_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    lex_b_tree_sets_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_b_tree_sets_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}],\n    );\n    lex_b_tree_sets_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[btreeset! {false, true}],\n    );\n    lex_b_tree_sets_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[btreeset! {'a'}, btreeset! {'b'}, btreeset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_b_tree_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_b_tree_sets_length_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_b_tree_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn lex_b_tree_sets_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        lex_b_tree_sets_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_b_tree_sets_length_range() {\n    lex_b_tree_sets_length_range_small_helper(0, 5, nevers(), 1, &[btreeset! {}]);\n    lex_b_tree_sets_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    lex_b_tree_sets_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    lex_b_tree_sets_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_b_tree_sets_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    lex_b_tree_sets_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}],\n    );\n    lex_b_tree_sets_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[btreeset! {false, true}],\n    );\n    lex_b_tree_sets_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[btreeset! {'a'}, btreeset! {'b'}, btreeset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_b_tree_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_b_tree_sets_min_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn lex_b_tree_sets_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(lex_b_tree_sets_min_length(min_length, xs), out);\n}\n\nfn lex_b_tree_sets_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        lex_b_tree_sets_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_b_tree_sets_min_length() {\n    lex_b_tree_sets_min_length_small_helper(0, nevers(), 1, &[btreeset! {}]);\n    lex_b_tree_sets_min_length_small_helper(4, nevers(), 0, &[]);\n    lex_b_tree_sets_min_length_small_helper(\n        0,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    lex_b_tree_sets_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_b_tree_sets_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[btreeset! {}, btreeset! {false}, btreeset! {false, true}, btreeset! {true}],\n    );\n    lex_b_tree_sets_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {false}, btreeset! {false, true}, btreeset! {true}],\n    );\n    lex_b_tree_sets_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b'},\n            btreeset! {'b', 'c'},\n            btreeset! {'c'},\n        ],\n    );\n    lex_b_tree_sets_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n        ],\n    );\n    lex_b_tree_sets_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'b', 'c', 'd'},\n            btreeset! {'a', 'b', 'c', 'd', 'e'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'},\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            },\n        ],\n    );\n    lex_b_tree_sets_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'b', 'c', 'd'},\n            btreeset! {'a', 'b', 'c', 'd', 'e'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'},\n            btreeset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'},\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't',\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u',\n            },\n            btreeset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u', 'v',\n            },\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_hash_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_hash_sets;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn lex_hash_sets_helper<I: Clone + Iterator>(xs: I, out: &[HashSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(lex_hash_sets(xs), out);\n}\n\nfn lex_hash_sets_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[HashSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(lex_hash_sets(xs), out_len, out);\n}\n\n#[test]\nfn test_lex_hash_sets() {\n    lex_hash_sets_small_helper(nevers(), 1, &[hashset! {}]);\n    lex_hash_sets_small_helper(exhaustive_units(), 2, &[hashset! {}, hashset! {()}]);\n    lex_hash_sets_small_helper(\n        exhaustive_bools(),\n        4,\n        &[hashset! {}, hashset! {false}, hashset! {false, true}, hashset! {true}],\n    );\n    lex_hash_sets_small_helper(\n        1..=6,\n        64,\n        &[\n            hashset! {},\n            hashset! {1},\n            hashset! {1, 2},\n            hashset! {1, 2, 3},\n            hashset! {1, 2, 3, 4},\n            hashset! {1, 2, 3, 4, 5},\n            hashset! {1, 2, 3, 4, 5, 6},\n            hashset! {1, 2, 3, 4, 6},\n            hashset! {1, 2, 3, 5},\n            hashset! {1, 2, 3, 5, 6},\n            hashset! {1, 2, 3, 6},\n            hashset! {1, 2, 4},\n            hashset! {1, 2, 4, 5},\n            hashset! {1, 2, 4, 5, 6},\n            hashset! {1, 2, 4, 6},\n            hashset! {1, 2, 5},\n            hashset! {1, 2, 5, 6},\n            hashset! {1, 2, 6},\n            hashset! {1, 3},\n            hashset! {1, 3, 4},\n        ],\n    );\n    lex_hash_sets_small_helper(\n        'a'..='c',\n        8,\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'a', 'b'},\n            hashset! {'a', 'b', 'c'},\n            hashset! {'a', 'c'},\n            hashset! {'b'},\n            hashset! {'b', 'c'},\n            hashset! {'c'},\n        ],\n    );\n    lex_hash_sets_helper(\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'a', 'b'},\n            hashset! {'a', 'b', 'c'},\n            hashset! {'a', 'b', 'c', 'd'},\n            hashset! {'a', 'b', 'c', 'd', 'e'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'},\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            },\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_hash_sets_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::sets::exhaustive::lex_hash_sets_fixed_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_fixed_length;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn lex_hash_sets_fixed_length_helper<I: Iterator>(len: u64, xs: I, out: &[HashSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(lex_hash_sets_fixed_length(len, xs), out);\n}\n\nfn lex_hash_sets_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(lex_hash_sets_fixed_length(len, xs), out_len, out);\n}\n\n#[test]\nfn test_lex_hash_sets_fixed_length() {\n    lex_hash_sets_fixed_length_small_helper(0, nevers(), 1, &[hashset! {}]);\n    lex_hash_sets_fixed_length_small_helper(1, nevers(), 0, &[]);\n    lex_hash_sets_fixed_length_small_helper(2, nevers(), 0, &[]);\n    lex_hash_sets_fixed_length_small_helper(5, nevers(), 0, &[]);\n    lex_hash_sets_fixed_length_small_helper(1, exhaustive_units(), 1, &[hashset! {()}]);\n    lex_hash_sets_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    lex_hash_sets_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_hash_sets_fixed_length_small_helper(0, exhaustive_unsigneds::<u8>(), 1, &[hashset! {}]);\n    lex_hash_sets_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            hashset! {0},\n            hashset! {1},\n            hashset! {2},\n            hashset! {3},\n            hashset! {4},\n            hashset! {5},\n            hashset! {6},\n            hashset! {7},\n            hashset! {8},\n            hashset! {9},\n            hashset! {10},\n            hashset! {11},\n            hashset! {12},\n            hashset! {13},\n            hashset! {14},\n            hashset! {15},\n            hashset! {16},\n            hashset! {17},\n            hashset! {18},\n            hashset! {19},\n        ],\n    );\n    lex_hash_sets_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            hashset! {0},\n            hashset! {1},\n            hashset! {2},\n            hashset! {3},\n            hashset! {4},\n            hashset! {5},\n            hashset! {6},\n            hashset! {7},\n            hashset! {8},\n            hashset! {9},\n            hashset! {10},\n            hashset! {11},\n            hashset! {12},\n            hashset! {13},\n            hashset! {14},\n            hashset! {15},\n            hashset! {16},\n            hashset! {17},\n            hashset! {18},\n            hashset! {19},\n        ],\n    );\n    lex_hash_sets_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            hashset! {0, 1},\n            hashset! {0, 2},\n            hashset! {0, 3},\n            hashset! {0, 4},\n            hashset! {0, 5},\n            hashset! {0, 6},\n            hashset! {0, 7},\n            hashset! {0, 8},\n            hashset! {0, 9},\n            hashset! {0, 10},\n            hashset! {0, 11},\n            hashset! {0, 12},\n            hashset! {0, 13},\n            hashset! {0, 14},\n            hashset! {0, 15},\n            hashset! {0, 16},\n            hashset! {0, 17},\n            hashset! {0, 18},\n            hashset! {0, 19},\n            hashset! {0, 20},\n        ],\n    );\n    lex_hash_sets_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            hashset! {0, 1, 2},\n            hashset! {0, 1, 3},\n            hashset! {0, 1, 4},\n            hashset! {0, 1, 5},\n            hashset! {0, 1, 6},\n            hashset! {0, 1, 7},\n            hashset! {0, 1, 8},\n            hashset! {0, 1, 9},\n            hashset! {0, 1, 10},\n            hashset! {0, 1, 11},\n            hashset! {0, 1, 12},\n            hashset! {0, 1, 13},\n            hashset! {0, 1, 14},\n            hashset! {0, 1, 15},\n            hashset! {0, 1, 16},\n            hashset! {0, 1, 17},\n            hashset! {0, 1, 18},\n            hashset! {0, 1, 19},\n            hashset! {0, 1, 20},\n            hashset! {0, 1, 21},\n        ],\n    );\n    lex_hash_sets_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            hashset! {'a', 'b'},\n            hashset! {'a', 'c'},\n            hashset! {'a', 'd'},\n            hashset! {'a', 'e'},\n            hashset! {'a', 'f'},\n            hashset! {'a', 'g'},\n            hashset! {'a', 'h'},\n            hashset! {'a', 'i'},\n            hashset! {'a', 'j'},\n            hashset! {'a', 'k'},\n            hashset! {'a', 'l'},\n            hashset! {'a', 'm'},\n            hashset! {'a', 'n'},\n            hashset! {'a', 'o'},\n            hashset! {'a', 'p'},\n            hashset! {'a', 'q'},\n            hashset! {'a', 'r'},\n            hashset! {'a', 's'},\n            hashset! {'a', 't'},\n            hashset! {'a', 'u'},\n        ],\n    );\n    lex_hash_sets_fixed_length_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[hashset! {false}, hashset! {true}],\n    );\n    lex_hash_sets_fixed_length_small_helper(2, exhaustive_bools(), 1, &[hashset! {false, true}]);\n    lex_hash_sets_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    lex_hash_sets_fixed_length_small_helper(\n        4,\n        1..=6,\n        15,\n        &[\n            hashset! {1, 2, 3, 4},\n            hashset! {1, 2, 3, 5},\n            hashset! {1, 2, 3, 6},\n            hashset! {1, 2, 4, 5},\n            hashset! {1, 2, 4, 6},\n            hashset! {1, 2, 5, 6},\n            hashset! {1, 3, 4, 5},\n            hashset! {1, 3, 4, 6},\n            hashset! {1, 3, 5, 6},\n            hashset! {1, 4, 5, 6},\n            hashset! {2, 3, 4, 5},\n            hashset! {2, 3, 4, 6},\n            hashset! {2, 3, 5, 6},\n            hashset! {2, 4, 5, 6},\n            hashset! {3, 4, 5, 6},\n        ],\n    );\n    lex_hash_sets_fixed_length_helper(\n        2,\n        lex_ordered_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            hashset! {vec![0, 1], vec![0, 2]},\n            hashset! {vec![0, 1], vec![0, 3]},\n            hashset! {vec![0, 1], vec![0, 4]},\n            hashset! {vec![0, 1], vec![0, 5]},\n            hashset! {vec![0, 1], vec![0, 6]},\n            hashset! {vec![0, 1], vec![0, 7]},\n            hashset! {vec![0, 1], vec![0, 8]},\n            hashset! {vec![0, 1], vec![0, 9]},\n            hashset! {vec![0, 1], vec![0, 10]},\n            hashset! {vec![0, 1], vec![0, 11]},\n            hashset! {vec![0, 1], vec![0, 12]},\n            hashset! {vec![0, 1], vec![0, 13]},\n            hashset! {vec![0, 1], vec![0, 14]},\n            hashset! {vec![0, 1], vec![0, 15]},\n            hashset! {vec![0, 1], vec![0, 16]},\n            hashset! {vec![0, 1], vec![0, 17]},\n            hashset! {vec![0, 1], vec![0, 18]},\n            hashset! {vec![0, 1], vec![0, 19]},\n            hashset! {vec![0, 1], vec![0, 20]},\n            hashset! {vec![0, 1], vec![0, 21]},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_hash_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_hash_sets_length_inclusive_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_hash_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn lex_hash_sets_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        lex_hash_sets_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_hash_sets_length_inclusive_range() {\n    lex_hash_sets_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[hashset! {}]);\n    lex_hash_sets_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    lex_hash_sets_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    lex_hash_sets_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_hash_sets_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[hashset! {}, hashset! {false}, hashset! {true}],\n    );\n    lex_hash_sets_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[hashset! {false, true}],\n    );\n    lex_hash_sets_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[hashset! {'a'}, hashset! {'b'}, hashset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_hash_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_hash_sets_length_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_hash_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn lex_hash_sets_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(lex_hash_sets_length_range(a, b, xs), out_len, out);\n}\n\n#[test]\nfn test_lex_hash_sets_length_range() {\n    lex_hash_sets_length_range_small_helper(0, 5, nevers(), 1, &[hashset! {}]);\n    lex_hash_sets_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    lex_hash_sets_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    lex_hash_sets_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_hash_sets_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    lex_hash_sets_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[hashset! {}, hashset! {false}, hashset! {true}],\n    );\n    lex_hash_sets_length_range_small_helper(2, 4, exhaustive_bools(), 1, &[hashset! {false, true}]);\n    lex_hash_sets_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[hashset! {'a'}, hashset! {'b'}, hashset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/lex_hash_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::lex_hash_sets_min_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn lex_hash_sets_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(lex_hash_sets_min_length(min_length, xs), out);\n}\n\nfn lex_hash_sets_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        lex_hash_sets_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_hash_sets_min_length() {\n    lex_hash_sets_min_length_small_helper(0, nevers(), 1, &[hashset! {}]);\n    lex_hash_sets_min_length_small_helper(4, nevers(), 0, &[]);\n    lex_hash_sets_min_length_small_helper(0, exhaustive_units(), 2, &[hashset! {}, hashset! {()}]);\n    lex_hash_sets_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_hash_sets_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[hashset! {}, hashset! {false}, hashset! {false, true}, hashset! {true}],\n    );\n    lex_hash_sets_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[hashset! {false}, hashset! {false, true}, hashset! {true}],\n    );\n    lex_hash_sets_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'a', 'b'},\n            hashset! {'a', 'b', 'c'},\n            hashset! {'a', 'c'},\n            hashset! {'b'},\n            hashset! {'b', 'c'},\n            hashset! {'c'},\n        ],\n    );\n    lex_hash_sets_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[hashset! {'a', 'b'}, hashset! {'a', 'b', 'c'}, hashset! {'a', 'c'}, hashset! {'b', 'c'}],\n    );\n    lex_hash_sets_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'a', 'b'},\n            hashset! {'a', 'b', 'c'},\n            hashset! {'a', 'b', 'c', 'd'},\n            hashset! {'a', 'b', 'c', 'd', 'e'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'},\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            },\n        ],\n    );\n    lex_hash_sets_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {'a', 'b', 'c'},\n            hashset! {'a', 'b', 'c', 'd'},\n            hashset! {'a', 'b', 'c', 'd', 'e'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'},\n            hashset! {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'},\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't',\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u',\n            },\n            hashset! {\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u', 'v',\n            },\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_b_tree_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_b_tree_sets;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn shortlex_b_tree_sets_helper<I: Clone + Iterator>(xs: I, out: &[BTreeSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(shortlex_b_tree_sets(xs), out);\n}\n\nfn shortlex_b_tree_sets_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(shortlex_b_tree_sets(xs), out_len, out);\n}\n\n#[test]\nfn test_shortlex_b_tree_sets() {\n    shortlex_b_tree_sets_small_helper(nevers(), 1, &[btreeset! {}]);\n    shortlex_b_tree_sets_small_helper(exhaustive_units(), 2, &[btreeset! {}, btreeset! {()}]);\n    shortlex_b_tree_sets_small_helper(\n        exhaustive_bools(),\n        4,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}, btreeset! {false, true}],\n    );\n    shortlex_b_tree_sets_small_helper(\n        1..=6,\n        64,\n        &[\n            btreeset! {},\n            btreeset! {1},\n            btreeset! {2},\n            btreeset! {3},\n            btreeset! {4},\n            btreeset! {5},\n            btreeset! {6},\n            btreeset! {1, 2},\n            btreeset! {1, 3},\n            btreeset! {1, 4},\n            btreeset! {1, 5},\n            btreeset! {1, 6},\n            btreeset! {2, 3},\n            btreeset! {2, 4},\n            btreeset! {2, 5},\n            btreeset! {2, 6},\n            btreeset! {3, 4},\n            btreeset! {3, 5},\n            btreeset! {3, 6},\n            btreeset! {4, 5},\n        ],\n    );\n    shortlex_b_tree_sets_small_helper(\n        'a'..='c',\n        8,\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'c'},\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n        ],\n    );\n    shortlex_b_tree_sets_helper(\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'c'},\n            btreeset! {'d'},\n            btreeset! {'e'},\n            btreeset! {'f'},\n            btreeset! {'g'},\n            btreeset! {'h'},\n            btreeset! {'i'},\n            btreeset! {'j'},\n            btreeset! {'k'},\n            btreeset! {'l'},\n            btreeset! {'m'},\n            btreeset! {'n'},\n            btreeset! {'o'},\n            btreeset! {'p'},\n            btreeset! {'q'},\n            btreeset! {'r'},\n            btreeset! {'s'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_b_tree_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_b_tree_sets_length_inclusive_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_b_tree_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn shortlex_b_tree_sets_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        shortlex_b_tree_sets_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_b_tree_sets_length_inclusive_range() {\n    shortlex_b_tree_sets_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[btreeset! {}]);\n    shortlex_b_tree_sets_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    shortlex_b_tree_sets_length_inclusive_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    shortlex_b_tree_sets_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    shortlex_b_tree_sets_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}],\n    );\n    shortlex_b_tree_sets_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[btreeset! {false, true}],\n    );\n    shortlex_b_tree_sets_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[btreeset! {'a'}, btreeset! {'b'}, btreeset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_b_tree_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_b_tree_sets_length_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_b_tree_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn shortlex_b_tree_sets_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        shortlex_b_tree_sets_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_b_tree_sets_length_range() {\n    shortlex_b_tree_sets_length_range_small_helper(0, 5, nevers(), 1, &[btreeset! {}]);\n    shortlex_b_tree_sets_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    shortlex_b_tree_sets_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    shortlex_b_tree_sets_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    shortlex_b_tree_sets_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    shortlex_b_tree_sets_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}],\n    );\n    shortlex_b_tree_sets_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[btreeset! {false, true}],\n    );\n    shortlex_b_tree_sets_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[btreeset! {'a'}, btreeset! {'b'}, btreeset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_b_tree_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_b_tree_sets_min_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_b_tree_sets_helper_helper, exhaustive_b_tree_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn shortlex_b_tree_sets_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_helper_helper(shortlex_b_tree_sets_min_length(min_length, xs), out);\n}\n\nfn shortlex_b_tree_sets_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[BTreeSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Ord,\n{\n    exhaustive_b_tree_sets_small_helper_helper(\n        shortlex_b_tree_sets_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_b_tree_sets_min_length() {\n    shortlex_b_tree_sets_min_length_small_helper(0, nevers(), 1, &[btreeset! {}]);\n    shortlex_b_tree_sets_min_length_small_helper(4, nevers(), 0, &[]);\n    shortlex_b_tree_sets_min_length_small_helper(\n        0,\n        exhaustive_units(),\n        2,\n        &[btreeset! {}, btreeset! {()}],\n    );\n    shortlex_b_tree_sets_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    shortlex_b_tree_sets_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[btreeset! {}, btreeset! {false}, btreeset! {true}, btreeset! {false, true}],\n    );\n    shortlex_b_tree_sets_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[btreeset! {false}, btreeset! {true}, btreeset! {false, true}],\n    );\n    shortlex_b_tree_sets_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'c'},\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n        ],\n    );\n    shortlex_b_tree_sets_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[\n            btreeset! {'a', 'b'},\n            btreeset! {'a', 'c'},\n            btreeset! {'b', 'c'},\n            btreeset! {'a', 'b', 'c'},\n        ],\n    );\n    shortlex_b_tree_sets_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {},\n            btreeset! {'a'},\n            btreeset! {'b'},\n            btreeset! {'c'},\n            btreeset! {'d'},\n            btreeset! {'e'},\n            btreeset! {'f'},\n            btreeset! {'g'},\n            btreeset! {'h'},\n            btreeset! {'i'},\n            btreeset! {'j'},\n            btreeset! {'k'},\n            btreeset! {'l'},\n            btreeset! {'m'},\n            btreeset! {'n'},\n            btreeset! {'o'},\n            btreeset! {'p'},\n            btreeset! {'q'},\n            btreeset! {'r'},\n            btreeset! {'s'},\n        ],\n    );\n    shortlex_b_tree_sets_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            btreeset! {'a', 'b', 'c'},\n            btreeset! {'a', 'b', 'd'},\n            btreeset! {'a', 'b', 'e'},\n            btreeset! {'a', 'b', 'f'},\n            btreeset! {'a', 'b', 'g'},\n            btreeset! {'a', 'b', 'h'},\n            btreeset! {'a', 'b', 'i'},\n            btreeset! {'a', 'b', 'j'},\n            btreeset! {'a', 'b', 'k'},\n            btreeset! {'a', 'b', 'l'},\n            btreeset! {'a', 'b', 'm'},\n            btreeset! {'a', 'b', 'n'},\n            btreeset! {'a', 'b', 'o'},\n            btreeset! {'a', 'b', 'p'},\n            btreeset! {'a', 'b', 'q'},\n            btreeset! {'a', 'b', 'r'},\n            btreeset! {'a', 'b', 's'},\n            btreeset! {'a', 'b', 't'},\n            btreeset! {'a', 'b', 'u'},\n            btreeset! {'a', 'b', 'v'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_hash_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_hash_sets;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn shortlex_hash_sets_helper<I: Clone + Iterator>(xs: I, out: &[HashSet<I::Item>])\nwhere\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(shortlex_hash_sets(xs).take(20), out);\n}\n\nfn shortlex_hash_sets_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(shortlex_hash_sets(xs), out_len, out);\n}\n\n#[test]\nfn test_shortlex_hash_sets() {\n    shortlex_hash_sets_small_helper(nevers(), 1, &[hashset! {}]);\n    shortlex_hash_sets_small_helper(exhaustive_units(), 2, &[hashset! {}, hashset! {()}]);\n    shortlex_hash_sets_small_helper(\n        exhaustive_bools(),\n        4,\n        &[hashset! {}, hashset! {false}, hashset! {true}, hashset! {false, true}],\n    );\n    shortlex_hash_sets_small_helper(\n        1..=6,\n        64,\n        &[\n            hashset! {},\n            hashset! {1},\n            hashset! {2},\n            hashset! {3},\n            hashset! {4},\n            hashset! {5},\n            hashset! {6},\n            hashset! {1, 2},\n            hashset! {1, 3},\n            hashset! {1, 4},\n            hashset! {1, 5},\n            hashset! {1, 6},\n            hashset! {2, 3},\n            hashset! {2, 4},\n            hashset! {2, 5},\n            hashset! {2, 6},\n            hashset! {3, 4},\n            hashset! {3, 5},\n            hashset! {3, 6},\n            hashset! {4, 5},\n        ],\n    );\n    shortlex_hash_sets_small_helper(\n        'a'..='c',\n        8,\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'c'},\n            hashset! {'a', 'b'},\n            hashset! {'a', 'c'},\n            hashset! {'b', 'c'},\n            hashset! {'a', 'b', 'c'},\n        ],\n    );\n    shortlex_hash_sets_helper(\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'c'},\n            hashset! {'d'},\n            hashset! {'e'},\n            hashset! {'f'},\n            hashset! {'g'},\n            hashset! {'h'},\n            hashset! {'i'},\n            hashset! {'j'},\n            hashset! {'k'},\n            hashset! {'l'},\n            hashset! {'m'},\n            hashset! {'n'},\n            hashset! {'o'},\n            hashset! {'p'},\n            hashset! {'q'},\n            hashset! {'r'},\n            hashset! {'s'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_hash_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_hash_sets_length_inclusive_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_hash_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn shortlex_hash_sets_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        shortlex_hash_sets_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_hash_sets_length_inclusive_range() {\n    shortlex_hash_sets_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[hashset! {}]);\n    shortlex_hash_sets_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    shortlex_hash_sets_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    shortlex_hash_sets_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    shortlex_hash_sets_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[hashset! {}, hashset! {false}, hashset! {true}],\n    );\n    shortlex_hash_sets_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[hashset! {false, true}],\n    );\n    shortlex_hash_sets_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[hashset! {'a'}, hashset! {'b'}, hashset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_hash_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_hash_sets_length_range;\nuse malachite_base::test_util::sets::exhaustive::exhaustive_hash_sets_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn shortlex_hash_sets_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        shortlex_hash_sets_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_hash_sets_length_range() {\n    shortlex_hash_sets_length_range_small_helper(0, 5, nevers(), 1, &[hashset! {}]);\n    shortlex_hash_sets_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    shortlex_hash_sets_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    shortlex_hash_sets_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    shortlex_hash_sets_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    shortlex_hash_sets_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[hashset! {}, hashset! {false}, hashset! {true}],\n    );\n    shortlex_hash_sets_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[hashset! {false, true}],\n    );\n    shortlex_hash_sets_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[hashset! {'a'}, hashset! {'b'}, hashset! {'c'}],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/exhaustive/shortlex_hash_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::sets::exhaustive::shortlex_hash_sets_min_length;\nuse malachite_base::test_util::sets::exhaustive::{\n    exhaustive_hash_sets_helper_helper, exhaustive_hash_sets_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn shortlex_hash_sets_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_helper_helper(shortlex_hash_sets_min_length(min_length, xs), out);\n}\n\nfn shortlex_hash_sets_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[HashSet<I::Item>],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n{\n    exhaustive_hash_sets_small_helper_helper(\n        shortlex_hash_sets_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_hash_sets_min_length() {\n    shortlex_hash_sets_min_length_small_helper(0, nevers(), 1, &[hashset! {}]);\n    shortlex_hash_sets_min_length_small_helper(4, nevers(), 0, &[]);\n    shortlex_hash_sets_min_length_small_helper(\n        0,\n        exhaustive_units(),\n        2,\n        &[hashset! {}, hashset! {()}],\n    );\n    shortlex_hash_sets_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    shortlex_hash_sets_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[hashset! {}, hashset! {false}, hashset! {true}, hashset! {false, true}],\n    );\n    shortlex_hash_sets_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[hashset! {false}, hashset! {true}, hashset! {false, true}],\n    );\n    shortlex_hash_sets_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'c'},\n            hashset! {'a', 'b'},\n            hashset! {'a', 'c'},\n            hashset! {'b', 'c'},\n            hashset! {'a', 'b', 'c'},\n        ],\n    );\n    shortlex_hash_sets_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[hashset! {'a', 'b'}, hashset! {'a', 'c'}, hashset! {'b', 'c'}, hashset! {'a', 'b', 'c'}],\n    );\n    shortlex_hash_sets_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {},\n            hashset! {'a'},\n            hashset! {'b'},\n            hashset! {'c'},\n            hashset! {'d'},\n            hashset! {'e'},\n            hashset! {'f'},\n            hashset! {'g'},\n            hashset! {'h'},\n            hashset! {'i'},\n            hashset! {'j'},\n            hashset! {'k'},\n            hashset! {'l'},\n            hashset! {'m'},\n            hashset! {'n'},\n            hashset! {'o'},\n            hashset! {'p'},\n            hashset! {'q'},\n            hashset! {'r'},\n            hashset! {'s'},\n        ],\n    );\n    shortlex_hash_sets_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            hashset! {'a', 'b', 'c'},\n            hashset! {'a', 'b', 'd'},\n            hashset! {'a', 'b', 'e'},\n            hashset! {'a', 'b', 'f'},\n            hashset! {'a', 'b', 'g'},\n            hashset! {'a', 'b', 'h'},\n            hashset! {'a', 'b', 'i'},\n            hashset! {'a', 'b', 'j'},\n            hashset! {'a', 'b', 'k'},\n            hashset! {'a', 'b', 'l'},\n            hashset! {'a', 'b', 'm'},\n            hashset! {'a', 'b', 'n'},\n            hashset! {'a', 'b', 'o'},\n            hashset! {'a', 'b', 'p'},\n            hashset! {'a', 'b', 'q'},\n            hashset! {'a', 'b', 'r'},\n            hashset! {'a', 'b', 's'},\n            hashset! {'a', 'b', 't'},\n            hashset! {'a', 'b', 'u'},\n            hashset! {'a', 'b', 'v'},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_b_tree_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_b_tree_sets;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn random_b_tree_sets_helper<T: Clone + Debug + Eq + Hash + Ord, I: Clone + Iterator<Item = T>>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[BTreeSet<T>],\n    expected_common_values: &[(BTreeSet<T>, usize)],\n    expected_median: (BTreeSet<T>, Option<BTreeSet<T>>),\n) {\n    let xs = random_b_tree_sets(\n        EXAMPLE_SEED,\n        xs_gen,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_b_tree_sets() {\n    random_b_tree_sets_helper(\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            btreeset! {},\n            btreeset! {11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235},\n            btreeset! {30, 90, 218, 234},\n            btreeset! {9, 106, 204, 216},\n            btreeset! {151},\n            btreeset! {},\n            btreeset! {78, 91, 97, 213, 253},\n            btreeset! {39, 191},\n            btreeset! {170, 175, 232, 233},\n            btreeset! {},\n            btreeset! {2, 22, 35, 114, 198, 217},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222},\n            btreeset! {52, 69, 73, 91, 115, 137, 153, 178},\n            btreeset! {},\n            btreeset! {34, 95, 112},\n            btreeset! {},\n            btreeset! {106, 130, 167, 168, 197},\n            btreeset! {86, 101, 122, 150, 172, 177, 207, 218, 221},\n        ],\n        &[\n            (btreeset! {}, 199913),\n            (btreeset! {7}, 705),\n            (btreeset! {25}, 689),\n            (btreeset! {184}, 681),\n            (btreeset! {213}, 681),\n            (btreeset! {255}, 676),\n            (btreeset! {215}, 675),\n            (btreeset! {54}, 673),\n            (btreeset! {122}, 672),\n            (btreeset! {207}, 672),\n        ],\n        (\n            btreeset! {27, 31, 211, 238},\n            Some(btreeset! {27, 31, 247, 251}),\n        ),\n    );\n    random_b_tree_sets_helper(\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            btreeset! {},\n            btreeset! {1, 9, 12, 14, 16, 17, 19, 21, 41, 42, 68, 79, 124, 141},\n            btreeset! {0, 1, 10, 99},\n            btreeset! {2, 12, 36, 77},\n            btreeset! {1},\n            btreeset! {},\n            btreeset! {1, 5, 9, 19, 103},\n            btreeset! {6, 7},\n            btreeset! {15, 18, 51, 159},\n            btreeset! {},\n            btreeset! {2, 26, 40, 52, 64, 75},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {3, 4, 5, 7, 30, 31, 34, 43, 49, 51, 67},\n            btreeset! {1, 14, 16, 24, 29, 41, 47, 52},\n            btreeset! {},\n            btreeset! {11, 13, 62},\n            btreeset! {},\n            btreeset! {3, 14, 42, 47, 109},\n            btreeset! {5, 13, 16, 25, 37, 41, 42, 86, 96},\n        ],\n        &[\n            (btreeset! {}, 199913),\n            (btreeset! {0}, 4861),\n            (btreeset! {1}, 4593),\n            (btreeset! {2}, 4498),\n            (btreeset! {3}, 4405),\n            (btreeset! {4}, 4330),\n            (btreeset! {5}, 4078),\n            (btreeset! {6}, 4050),\n            (btreeset! {7}, 3858),\n            (btreeset! {8}, 3848),\n        ],\n        (\n            btreeset! {3, 9, 14, 22, 36, 56, 107},\n            Some(btreeset! {3, 9, 14, 22, 42, 54, 73, 150}),\n        ),\n    );\n    random_b_tree_sets_helper(\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            btreeset! {},\n            btreeset! {},\n            btreeset! {85},\n            btreeset! {11},\n            btreeset! {136, 200},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {134, 235},\n            btreeset! {203},\n            btreeset! {},\n            btreeset! {38, 223},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n        ],\n        &[\n            (btreeset! {}, 800023),\n            (btreeset! {162}, 692),\n            (btreeset! {235}, 690),\n            (btreeset! {90}, 688),\n            (btreeset! {65}, 687),\n            (btreeset! {249}, 686),\n            (btreeset! {175}, 684),\n            (btreeset! {108}, 683),\n            (btreeset! {211}, 682),\n            (btreeset! {237}, 680),\n        ],\n        (btreeset! {}, None),\n    );\n    random_b_tree_sets_helper(\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            btreeset! {},\n            btreeset! {'g', 'q', '³', '»', 'À', 'Á', 'Ã', 'È', 'á', 'â', 'ì', 'ñ', 'Ā', 'ą'},\n            btreeset! {'ª', '´', 'Ã', 'ä'},\n            btreeset! {'½', 'Á', 'Ï', 'ý'},\n            btreeset! {'j'},\n            btreeset! {},\n            btreeset! {'u', '½', 'Â', 'Ñ', 'ï'},\n            btreeset! {'x', 'õ'},\n            btreeset! {'¡', 'Â', 'ù', 'Ċ'},\n            btreeset! {},\n            btreeset! {'b', 'r', 's', '¬', 'Â', 'Ñ'},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {'j', 'n', 't', '¬', 'º', '¿', 'Á', 'Ø', 'Þ', 'ô', 'ü'},\n            btreeset! {'b', 'k', '±', 'Î', 'Ü', 'æ', 'è', 'ā'},\n            btreeset! {},\n            btreeset! {'«', '¹', 'Î'},\n            btreeset! {},\n            btreeset! {'~', '¯', '´', 'Ý', 'â'},\n            btreeset! {'g', '¼', 'Ç', 'Î', 'Ü', 'Þ', 'æ', 'é', 'ö'},\n        ],\n        &[\n            (btreeset! {}, 199913),\n            (btreeset! {'Ó'}, 1270),\n            (btreeset! {'Â'}, 1249),\n            (btreeset! {'§'}, 1244),\n            (btreeset! {'¿'}, 1243),\n            (btreeset! {'õ'}, 1241),\n            (btreeset! {'ĉ'}, 1234),\n            (btreeset! {'¤'}, 1232),\n            (btreeset! {'¼'}, 1232),\n            (btreeset! {'Ì'}, 1229),\n        ],\n        (\n            btreeset! {'o', 'v', '¢', '±', 'Ä', 'Ć'},\n            Some(btreeset! {'o', 'v', '¢', '³', 'ã'}),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_fail_1() {\n    random_b_tree_sets(EXAMPLE_SEED, &random_primitive_ints::<u32>, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_fail_2() {\n    random_b_tree_sets(EXAMPLE_SEED, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_fail_3() {\n    random_b_tree_sets(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_b_tree_sets_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::{Itertools, repeat_n};\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::sets::random::random_b_tree_sets_fixed_length;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn random_b_tree_sets_fixed_length_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    expected_values: &[BTreeSet<I::Item>],\n    expected_common_values: &[(BTreeSet<I::Item>, usize)],\n    expected_median: (BTreeSet<I::Item>, Option<BTreeSet<I::Item>>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_b_tree_sets_fixed_length(len, xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_b_tree_sets_fixed_length() {\n    random_b_tree_sets_fixed_length_helper(\n        0,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &repeat_n(btreeset! {}, 20).collect_vec(),\n        &[(btreeset! {}, 1000000)],\n        (btreeset! {}, None),\n    );\n    random_b_tree_sets_fixed_length_helper(\n        1,\n        random_bools(EXAMPLE_SEED),\n        &[\n            btreeset! {true},\n            btreeset! {false},\n            btreeset! {false},\n            btreeset! {false},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {false},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {false},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {true},\n            btreeset! {false},\n            btreeset! {true},\n            btreeset! {false},\n        ],\n        &[(btreeset! {true}, 500473), (btreeset! {false}, 499527)],\n        (btreeset! {true}, None),\n    );\n    random_b_tree_sets_fixed_length_helper(\n        3,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            btreeset! {69, 113, 239},\n            btreeset! {108, 210, 228},\n            btreeset! {87, 161, 168},\n            btreeset! {32, 83, 110},\n            btreeset! {34, 89, 188},\n            btreeset! {93, 200, 238},\n            btreeset! {115, 149, 189},\n            btreeset! {149, 201, 217},\n            btreeset! {31, 117, 146},\n            btreeset! {72, 151, 169},\n            btreeset! {7, 33, 174},\n            btreeset! {38, 81, 144},\n            btreeset! {72, 113, 127},\n            btreeset! {107, 128, 233},\n            btreeset! {12, 46, 119},\n            btreeset! {18, 164, 243},\n            btreeset! {59, 114, 174},\n            btreeset! {39, 174, 247},\n            btreeset! {104, 160, 184},\n            btreeset! {37, 100, 252},\n        ],\n        &[\n            (btreeset! {57, 142, 207}, 7),\n            (btreeset! {32, 68, 169}, 6),\n            (btreeset! {36, 70, 195}, 6),\n            (btreeset! {125, 168, 194}, 6),\n            (btreeset! {0, 97, 205}, 5),\n            (btreeset! {2, 33, 227}, 5),\n            (btreeset! {5, 46, 239}, 5),\n            (btreeset! {9, 68, 189}, 5),\n            (btreeset! {9, 78, 240}, 5),\n            (btreeset! {1, 110, 203}, 5),\n        ],\n        (btreeset! {52, 133, 241}, Some(btreeset! {52, 133, 242})),\n    );\n    random_b_tree_sets_fixed_length_helper(\n        2,\n        random_b_tree_sets_fixed_length(2, random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            btreeset! {btreeset!{69, 108}, btreeset!{113, 239}},\n            btreeset! {btreeset!{161, 168}, btreeset!{210, 228}},\n            btreeset! {btreeset!{32, 87}, btreeset!{83, 110}},\n            btreeset! {btreeset!{34, 188}, btreeset!{89, 238}},\n            btreeset! {btreeset!{93, 200}, btreeset!{115, 149}},\n            btreeset! {btreeset!{149, 189}, btreeset!{201, 217}},\n            btreeset! {btreeset!{31, 72}, btreeset!{117, 146}},\n            btreeset! {btreeset!{33, 174}, btreeset!{151, 169}},\n            btreeset! {btreeset!{7, 38}, btreeset!{81, 144}},\n            btreeset! {btreeset!{72, 127}, btreeset!{113, 128}},\n            btreeset! {btreeset!{46, 119}, btreeset!{107, 233}},\n            btreeset! {btreeset!{12, 18}, btreeset!{164, 243}},\n            btreeset! {btreeset!{59, 247}, btreeset!{114, 174}},\n            btreeset! {btreeset!{39, 174}, btreeset!{160, 184}},\n            btreeset! {btreeset!{37, 104}, btreeset!{100, 252}},\n            btreeset! {btreeset!{69, 107}, btreeset!{122, 228}},\n            btreeset! {btreeset!{142, 179}, btreeset!{242, 248}},\n            btreeset! {btreeset!{61, 189}, btreeset!{233, 239}},\n            btreeset! {btreeset!{7, 192}, btreeset!{85, 235}},\n            btreeset! {btreeset!{90, 200}, btreeset!{178, 185}},\n        ],\n        &[\n            (btreeset! {btreeset!{0, 78}, btreeset!{34, 52}}, 2),\n            (btreeset! {btreeset!{1, 58}, btreeset!{6, 112}}, 2),\n            (btreeset! {btreeset!{1, 63}, btreeset!{8, 154}}, 2),\n            (btreeset! {btreeset!{1, 97}, btreeset!{7, 250}}, 2),\n            (btreeset! {btreeset!{2, 33}, btreeset!{40, 81}}, 2),\n            (btreeset! {btreeset!{3, 160}, btreeset!{7, 29}}, 2),\n            (btreeset! {btreeset!{3, 32}, btreeset!{12, 60}}, 2),\n            (btreeset! {btreeset!{6, 130}, btreeset!{7, 20}}, 2),\n            (btreeset! {btreeset!{6, 68}, btreeset!{7, 126}}, 2),\n            (btreeset! {btreeset!{6, 77}, btreeset!{36, 54}}, 2),\n        ],\n        (\n            btreeset! {btreeset!{40, 193}, btreeset!{94, 142}},\n            Some(btreeset! {btreeset!{40, 193}, btreeset!{97, 243}}),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_b_tree_sets_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_b_tree_sets_from_length_iterator;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::vecs::random_values_from_vec;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn random_b_tree_sets_from_length_iterator_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[BTreeSet<T>],\n    expected_common_values: &[(BTreeSet<T>, usize)],\n    expected_median: (BTreeSet<T>, Option<BTreeSet<T>>),\n) {\n    let xs = random_b_tree_sets_from_length_iterator(EXAMPLE_SEED, lengths_gen, xs_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_b_tree_sets_from_length_iterator() {\n    random_b_tree_sets_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2]),\n        &random_bools,\n        &[\n            btreeset! {false, true},\n            btreeset! {},\n            btreeset! {false, true},\n            btreeset! {false, true},\n            btreeset! {},\n            btreeset! {false, true},\n            btreeset! {false, true},\n            btreeset! {},\n            btreeset! {false, true},\n            btreeset! {false, true},\n            btreeset! {},\n            btreeset! {false, true},\n            btreeset! {},\n            btreeset! {false, true},\n            btreeset! {false, true},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {false, true},\n            btreeset! {},\n        ],\n        &[(btreeset! {false, true}, 500363), (btreeset! {}, 499637)],\n        (btreeset! {false, true}, None),\n    );\n    random_b_tree_sets_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        &random_primitive_ints::<u8>,\n        &[\n            btreeset! {11, 38, 85, 134, 136, 162, 177, 200, 203, 217, 223, 235},\n            btreeset! {32, 166},\n            btreeset! {9, 30, 39, 78, 90, 91, 97, 106, 151, 191, 204, 213, 216, 218, 234, 253},\n            btreeset! {170, 175},\n            btreeset! {\n                2, 17, 22, 25, 32, 34, 35, 52, 65, 69, 73, 79, 91, 112, 114, 115, 121, 137, 144,\n                148, 153, 173, 178, 198, 217, 222, 232, 233,\n            },\n            btreeset! {},\n            btreeset! {95, 106, 122, 130, 167, 168, 172, 177, 197, 207},\n            btreeset! {9, 74, 86, 101, 115, 150, 218, 221},\n            btreeset! {109, 123},\n            btreeset! {},\n            btreeset! {40, 48, 52, 97, 104, 133, 159, 196, 201, 235, 247, 250},\n            btreeset! {7, 68, 190, 216},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {157, 216},\n            btreeset! {11, 24, 43, 103, 112, 217},\n            btreeset! {},\n            btreeset! {84, 211},\n            btreeset! {},\n            btreeset! {55, 135},\n        ],\n        &[\n            (btreeset! {}, 333981),\n            (btreeset! {33, 163}, 22),\n            (btreeset! {76, 233}, 19),\n            (btreeset! {5, 42}, 18),\n            (btreeset! {76, 79}, 18),\n            (btreeset! {32, 134}, 18),\n            (btreeset! {69, 234}, 18),\n            (btreeset! {74, 164}, 18),\n            (btreeset! {86, 192}, 18),\n            (btreeset! {99, 145}, 18),\n        ],\n        (btreeset! {12, 190}, None),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_b_tree_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_b_tree_sets_length_inclusive_range;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn random_b_tree_sets_length_inclusive_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[BTreeSet<T>],\n    expected_common_values: &[(BTreeSet<T>, usize)],\n    expected_median: (BTreeSet<T>, Option<BTreeSet<T>>),\n) {\n    let xs = random_b_tree_sets_length_inclusive_range(EXAMPLE_SEED, a, b, xs_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_b_tree_sets_length_inclusive_range() {\n    random_b_tree_sets_length_inclusive_range_helper(\n        2,\n        3,\n        &random_primitive_ints::<u8>,\n        &[\n            btreeset! {11, 85, 136},\n            btreeset! {200, 235},\n            btreeset! {134, 203, 223},\n            btreeset! {38, 217, 235},\n            btreeset! {162, 177},\n            btreeset! {32, 166, 234},\n            btreeset! {30, 90, 218},\n            btreeset! {9, 106},\n            btreeset! {151, 204, 216},\n            btreeset! {97, 213, 253},\n            btreeset! {78, 91},\n            btreeset! {39, 175, 191},\n            btreeset! {170, 232},\n            btreeset! {2, 35, 233},\n            btreeset! {22, 198, 217},\n            btreeset! {17, 114},\n            btreeset! {32, 173},\n            btreeset! {65, 114},\n            btreeset! {121, 173, 222},\n            btreeset! {25, 144},\n        ],\n        &[\n            (btreeset! {106, 108}, 34),\n            (btreeset! {224, 237}, 34),\n            (btreeset! {51, 132}, 32),\n            (btreeset! {82, 117}, 32),\n            (btreeset! {72, 108}, 31),\n            (btreeset! {142, 194}, 31),\n            (btreeset! {0, 34}, 30),\n            (btreeset! {12, 208}, 30),\n            (btreeset! {15, 141}, 30),\n            (btreeset! {30, 248}, 30),\n        ],\n        (btreeset! {62, 131, 203}, Some(btreeset! {62, 131, 205})),\n    );\n    random_b_tree_sets_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            btreeset! {0, 1, 5},\n            btreeset! {1, 4},\n            btreeset! {2, 4, 6},\n            btreeset! {0, 1, 2},\n            btreeset! {9, 13},\n            btreeset! {0, 2, 7},\n            btreeset! {4, 6, 7},\n            btreeset! {0, 6},\n            btreeset! {0, 1, 3},\n            btreeset! {1, 2, 5},\n            btreeset! {0, 1},\n            btreeset! {0, 1, 4},\n            btreeset! {0, 2},\n            btreeset! {0, 2, 12},\n            btreeset! {1, 2, 3},\n            btreeset! {3, 9},\n            btreeset! {0, 1},\n            btreeset! {1, 2},\n            btreeset! {0, 1, 11},\n            btreeset! {1, 6},\n        ],\n        &[\n            (btreeset! {0, 1}, 103032),\n            (btreeset! {0, 1, 2}, 84142),\n            (btreeset! {0, 2}, 66185),\n            (btreeset! {0, 1, 3}, 52638),\n            (btreeset! {0, 3}, 42990),\n            (btreeset! {1, 2}, 40380),\n            (btreeset! {0, 1, 4}, 33815),\n            (btreeset! {0, 2, 3}, 31257),\n            (btreeset! {0, 4}, 28088),\n            (btreeset! {1, 3}, 26214),\n        ],\n        (btreeset! {0, 3}, None),\n    );\n    random_b_tree_sets_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            btreeset! {'c', 'q', 'v'},\n            btreeset! {'e', 'i'},\n            btreeset! {'g', 'p', 's'},\n            btreeset! {'m', 'n', 't'},\n            btreeset! {'o', 'z'},\n            btreeset! {'f', 'k', 'm'},\n            btreeset! {'q', 'u', 'y'},\n            btreeset! {'k', 'x'},\n            btreeset! {'h', 'n', 'u'},\n            btreeset! {'a', 'j', 'n'},\n            btreeset! {'w', 'z'},\n            btreeset! {'b', 'l', 'w'},\n            btreeset! {'l', 'u'},\n            btreeset! {'e', 'l', 'n'},\n            btreeset! {'k', 'u', 'v'},\n            btreeset! {'c', 'h'},\n            btreeset! {'i', 'y'},\n            btreeset! {'m', 'r'},\n            btreeset! {'m', 's', 'y'},\n            btreeset! {'e', 'l'},\n        ],\n        &[\n            (btreeset! {'l', 'x'}, 1640),\n            (btreeset! {'o', 't'}, 1636),\n            (btreeset! {'b', 'p'}, 1630),\n            (btreeset! {'m', 'v'}, 1623),\n            (btreeset! {'h', 'u'}, 1621),\n            (btreeset! {'a', 'x'}, 1614),\n            (btreeset! {'d', 'f'}, 1613),\n            (btreeset! {'e', 'r'}, 1613),\n            (btreeset! {'o', 'p'}, 1612),\n            (btreeset! {'c', 'i'}, 1611),\n        ],\n        (btreeset! {'g', 'j'}, None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_length_inclusive_range_fail() {\n    random_b_tree_sets_length_inclusive_range(EXAMPLE_SEED, 2, 1, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_b_tree_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_b_tree_sets_length_range;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn random_b_tree_sets_length_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[BTreeSet<T>],\n    expected_common_values: &[(BTreeSet<T>, usize)],\n    expected_median: (BTreeSet<T>, Option<BTreeSet<T>>),\n) {\n    let xs = random_b_tree_sets_length_range(EXAMPLE_SEED, a, b, xs_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_b_tree_sets_length_range() {\n    random_b_tree_sets_length_range_helper(\n        2,\n        4,\n        &random_primitive_ints::<u8>,\n        &[\n            btreeset! {11, 85, 136},\n            btreeset! {200, 235},\n            btreeset! {134, 203, 223},\n            btreeset! {38, 217, 235},\n            btreeset! {162, 177},\n            btreeset! {32, 166, 234},\n            btreeset! {30, 90, 218},\n            btreeset! {9, 106},\n            btreeset! {151, 204, 216},\n            btreeset! {97, 213, 253},\n            btreeset! {78, 91},\n            btreeset! {39, 175, 191},\n            btreeset! {170, 232},\n            btreeset! {2, 35, 233},\n            btreeset! {22, 198, 217},\n            btreeset! {17, 114},\n            btreeset! {32, 173},\n            btreeset! {65, 114},\n            btreeset! {121, 173, 222},\n            btreeset! {25, 144},\n        ],\n        &[\n            (btreeset! {106, 108}, 34),\n            (btreeset! {224, 237}, 34),\n            (btreeset! {51, 132}, 32),\n            (btreeset! {82, 117}, 32),\n            (btreeset! {72, 108}, 31),\n            (btreeset! {142, 194}, 31),\n            (btreeset! {0, 34}, 30),\n            (btreeset! {12, 208}, 30),\n            (btreeset! {15, 141}, 30),\n            (btreeset! {30, 248}, 30),\n        ],\n        (btreeset! {62, 131, 203}, Some(btreeset! {62, 131, 205})),\n    );\n    random_b_tree_sets_length_range_helper(\n        2,\n        4,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            btreeset! {0, 1, 5},\n            btreeset! {1, 4},\n            btreeset! {2, 4, 6},\n            btreeset! {0, 1, 2},\n            btreeset! {9, 13},\n            btreeset! {0, 2, 7},\n            btreeset! {4, 6, 7},\n            btreeset! {0, 6},\n            btreeset! {0, 1, 3},\n            btreeset! {1, 2, 5},\n            btreeset! {0, 1},\n            btreeset! {0, 1, 4},\n            btreeset! {0, 2},\n            btreeset! {0, 2, 12},\n            btreeset! {1, 2, 3},\n            btreeset! {3, 9},\n            btreeset! {0, 1},\n            btreeset! {1, 2},\n            btreeset! {0, 1, 11},\n            btreeset! {1, 6},\n        ],\n        &[\n            (btreeset! {0, 1}, 103032),\n            (btreeset! {0, 1, 2}, 84142),\n            (btreeset! {0, 2}, 66185),\n            (btreeset! {0, 1, 3}, 52638),\n            (btreeset! {0, 3}, 42990),\n            (btreeset! {1, 2}, 40380),\n            (btreeset! {0, 1, 4}, 33815),\n            (btreeset! {0, 2, 3}, 31257),\n            (btreeset! {0, 4}, 28088),\n            (btreeset! {1, 3}, 26214),\n        ],\n        (btreeset! {0, 3}, None),\n    );\n    random_b_tree_sets_length_range_helper(\n        2,\n        4,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            btreeset! {'c', 'q', 'v'},\n            btreeset! {'e', 'i'},\n            btreeset! {'g', 'p', 's'},\n            btreeset! {'m', 'n', 't'},\n            btreeset! {'o', 'z'},\n            btreeset! {'f', 'k', 'm'},\n            btreeset! {'q', 'u', 'y'},\n            btreeset! {'k', 'x'},\n            btreeset! {'h', 'n', 'u'},\n            btreeset! {'a', 'j', 'n'},\n            btreeset! {'w', 'z'},\n            btreeset! {'b', 'l', 'w'},\n            btreeset! {'l', 'u'},\n            btreeset! {'e', 'l', 'n'},\n            btreeset! {'k', 'u', 'v'},\n            btreeset! {'c', 'h'},\n            btreeset! {'i', 'y'},\n            btreeset! {'m', 'r'},\n            btreeset! {'m', 's', 'y'},\n            btreeset! {'e', 'l'},\n        ],\n        &[\n            (btreeset! {'l', 'x'}, 1640),\n            (btreeset! {'o', 't'}, 1636),\n            (btreeset! {'b', 'p'}, 1630),\n            (btreeset! {'m', 'v'}, 1623),\n            (btreeset! {'h', 'u'}, 1621),\n            (btreeset! {'a', 'x'}, 1614),\n            (btreeset! {'d', 'f'}, 1613),\n            (btreeset! {'e', 'r'}, 1613),\n            (btreeset! {'o', 'p'}, 1612),\n            (btreeset! {'c', 'i'}, 1611),\n        ],\n        (btreeset! {'g', 'j'}, None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_length_range_fail() {\n    random_b_tree_sets_length_range(EXAMPLE_SEED, 2, 2, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_b_tree_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_b_tree_sets_min_length;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::collections::BTreeSet;\nuse std::fmt::Debug;\n\nfn random_b_tree_sets_min_length_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[BTreeSet<T>],\n    expected_common_values: &[(BTreeSet<T>, usize)],\n    expected_median: (BTreeSet<T>, Option<BTreeSet<T>>),\n) {\n    let xs = random_b_tree_sets_min_length(\n        EXAMPLE_SEED,\n        min_length,\n        xs_gen,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_b_tree_sets_min_length() {\n    random_b_tree_sets_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            btreeset! {},\n            btreeset! {11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235},\n            btreeset! {30, 90, 218, 234},\n            btreeset! {9, 106, 204, 216},\n            btreeset! {151},\n            btreeset! {},\n            btreeset! {78, 91, 97, 213, 253},\n            btreeset! {39, 191},\n            btreeset! {170, 175, 232, 233},\n            btreeset! {},\n            btreeset! {2, 22, 35, 114, 198, 217},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222},\n            btreeset! {52, 69, 73, 91, 115, 137, 153, 178},\n            btreeset! {},\n            btreeset! {34, 95, 112},\n            btreeset! {},\n            btreeset! {106, 130, 167, 168, 197},\n            btreeset! {86, 101, 122, 150, 172, 177, 207, 218, 221},\n        ],\n        &[\n            (btreeset! {}, 199913),\n            (btreeset! {7}, 705),\n            (btreeset! {25}, 689),\n            (btreeset! {184}, 681),\n            (btreeset! {213}, 681),\n            (btreeset! {255}, 676),\n            (btreeset! {215}, 675),\n            (btreeset! {54}, 673),\n            (btreeset! {122}, 672),\n            (btreeset! {207}, 672),\n        ],\n        (\n            btreeset! {27, 31, 211, 238},\n            Some(btreeset! {27, 31, 247, 251}),\n        ),\n    );\n    random_b_tree_sets_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        7,\n        1,\n        &[\n            btreeset! {11, 85, 136},\n            btreeset! {\n                9, 30, 32, 38, 90, 106, 134, 162, 166, 177, 200, 203, 217, 218, 223, 234, 235\n            },\n            btreeset! {78, 97, 151, 204, 213, 216, 253},\n            btreeset! {39, 91, 170, 175, 191, 232, 233},\n            btreeset! {2, 22, 35, 217},\n            btreeset! {17, 114, 198},\n            btreeset! {25, 32, 65, 114, 121, 144, 173, 222},\n            btreeset! {52, 73, 79, 115, 148},\n            btreeset! {34, 69, 91, 112, 137, 153, 178},\n            btreeset! {95, 106, 167},\n            btreeset! {86, 122, 130, 150, 168, 172, 177, 197, 207},\n            btreeset! {101, 218, 221},\n            btreeset! {9, 74, 115},\n            btreeset! {40, 48, 52, 97, 104, 109, 123, 133, 159, 196, 201, 235, 247, 250},\n            btreeset! {7, 11, 24, 43, 68, 103, 112, 157, 190, 216, 217},\n            btreeset! {84, 135, 211},\n            btreeset! {29, 55, 65, 89, 191, 206},\n            btreeset! {9, 51, 79},\n            btreeset! {3, 20, 22, 34, 62, 114, 118, 148},\n            btreeset! {23, 32, 47, 50, 120, 166, 176, 177, 194, 204, 238, 248},\n        ],\n        &[\n            (btreeset! {5, 128, 142}, 4),\n            (btreeset! {137, 145, 160}, 4),\n            (btreeset! {2, 4, 52}, 3),\n            (btreeset! {1, 5, 192}, 3),\n            (btreeset! {12, 41, 58}, 3),\n            (btreeset! {2, 95, 171}, 3),\n            (btreeset! {20, 86, 94}, 3),\n            (btreeset! {21, 43, 50}, 3),\n            (btreeset! {3, 81, 122}, 3),\n            (btreeset! {31, 54, 79}, 3),\n        ],\n        (\n            btreeset! {26, 138, 167},\n            Some(btreeset! {26, 138, 167, 173, 211}),\n        ),\n    );\n    random_b_tree_sets_min_length_helper(\n        0,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            btreeset! {},\n            btreeset! {1, 9, 12, 14, 16, 17, 19, 21, 41, 42, 68, 79, 124, 141},\n            btreeset! {0, 1, 10, 99},\n            btreeset! {2, 12, 36, 77},\n            btreeset! {1},\n            btreeset! {},\n            btreeset! {1, 5, 9, 19, 103},\n            btreeset! {6, 7},\n            btreeset! {15, 18, 51, 159},\n            btreeset! {},\n            btreeset! {2, 26, 40, 52, 64, 75},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {3, 4, 5, 7, 30, 31, 34, 43, 49, 51, 67},\n            btreeset! {1, 14, 16, 24, 29, 41, 47, 52},\n            btreeset! {},\n            btreeset! {11, 13, 62},\n            btreeset! {},\n            btreeset! {3, 14, 42, 47, 109},\n            btreeset! {5, 13, 16, 25, 37, 41, 42, 86, 96},\n        ],\n        &[\n            (btreeset! {}, 199913),\n            (btreeset! {0}, 4861),\n            (btreeset! {1}, 4593),\n            (btreeset! {2}, 4498),\n            (btreeset! {3}, 4405),\n            (btreeset! {4}, 4330),\n            (btreeset! {5}, 4078),\n            (btreeset! {6}, 4050),\n            (btreeset! {7}, 3858),\n            (btreeset! {8}, 3848),\n        ],\n        (\n            btreeset! {3, 9, 14, 22, 36, 56, 107},\n            Some(btreeset! {3, 9, 14, 22, 42, 54, 73, 150}),\n        ),\n    );\n    random_b_tree_sets_min_length_helper(\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        7,\n        1,\n        &[\n            btreeset! {1, 14, 42},\n            btreeset! {0, 1, 9, 10, 12, 16, 17, 19, 21, 36, 41, 68, 77, 79, 99, 124, 141},\n            btreeset! {1, 2, 5, 9, 12, 19, 103},\n            btreeset! {6, 7, 15, 18, 51, 52, 159},\n            btreeset! {2, 40, 64, 75},\n            btreeset! {26, 34, 67},\n            btreeset! {4, 5, 7, 30, 31, 43, 49, 51},\n            btreeset! {3, 14, 16, 24, 47},\n            btreeset! {1, 11, 13, 29, 41, 52, 62},\n            btreeset! {3, 47, 109},\n            btreeset! {13, 14, 16, 25, 37, 41, 42, 86, 96},\n            btreeset! {5, 20, 42},\n            btreeset! {2, 74, 82},\n            btreeset! {3, 6, 7, 11, 17, 20, 36, 45, 56, 66, 76, 80, 89, 127},\n            btreeset! {1, 6, 10, 13, 19, 23, 25, 32, 41, 43, 97},\n            btreeset! {7, 41, 134},\n            btreeset! {9, 10, 25, 26, 47, 105},\n            btreeset! {68, 94, 109},\n            btreeset! {1, 3, 9, 13, 28, 43, 44, 84},\n            btreeset! {0, 4, 5, 6, 7, 13, 31, 32, 37, 42, 50, 75},\n        ],\n        &[\n            (btreeset! {0, 2, 5}, 42),\n            (btreeset! {0, 1, 8}, 39),\n            (btreeset! {0, 3, 4}, 38),\n            (btreeset! {1, 3, 9}, 38),\n            (btreeset! {0, 1, 7}, 35),\n            (btreeset! {0, 2, 8}, 34),\n            (btreeset! {1, 2, 12}, 34),\n            (btreeset! {0, 1, 2}, 33),\n            (btreeset! {1, 2, 3}, 33),\n            (btreeset! {1, 3, 4}, 33),\n        ],\n        (\n            btreeset! {3, 8, 14, 19, 25, 36, 52, 64, 71},\n            Some(btreeset! {3, 8, 14, 19, 25, 38, 58, 61}),\n        ),\n    );\n    random_b_tree_sets_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            btreeset! {},\n            btreeset! {},\n            btreeset! {85},\n            btreeset! {11},\n            btreeset! {136, 200},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {134, 235},\n            btreeset! {203},\n            btreeset! {},\n            btreeset! {38, 223},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {},\n        ],\n        &[\n            (btreeset! {}, 800023),\n            (btreeset! {162}, 692),\n            (btreeset! {235}, 690),\n            (btreeset! {90}, 688),\n            (btreeset! {65}, 687),\n            (btreeset! {249}, 686),\n            (btreeset! {175}, 684),\n            (btreeset! {108}, 683),\n            (btreeset! {211}, 682),\n            (btreeset! {237}, 680),\n        ],\n        (btreeset! {}, None),\n    );\n    random_b_tree_sets_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        13,\n        4,\n        &[\n            btreeset! {11, 85, 136},\n            btreeset! {134, 200, 235},\n            btreeset! {38, 203, 223, 235},\n            btreeset! {32, 162, 177, 217},\n            btreeset! {30, 90, 166, 218, 234},\n            btreeset! {9, 106, 216},\n            btreeset! {151, 204, 213},\n            btreeset! {78, 97, 253},\n            btreeset! {39, 91, 191},\n            btreeset! {170, 175, 232},\n            btreeset! {2, 35, 233},\n            btreeset! {22, 198, 217},\n            btreeset! {17, 32, 65, 114, 173},\n            btreeset! {25, 121, 173, 222},\n            btreeset! {79, 144, 148},\n            btreeset! {52, 69, 73, 115, 137},\n            btreeset! {91, 153, 178},\n            btreeset! {34, 95, 112},\n            btreeset! {106, 167, 197},\n            btreeset! {122, 130, 168},\n        ],\n        &[\n            (btreeset! {10, 87, 204}, 6),\n            (btreeset! {15, 40, 115}, 6),\n            (btreeset! {108, 193, 199}, 6),\n            (btreeset! {1, 22, 70}, 5),\n            (btreeset! {1, 8, 212}, 5),\n            (btreeset! {2, 40, 169}, 5),\n            (btreeset! {2, 58, 211}, 5),\n            (btreeset! {3, 29, 186}, 5),\n            (btreeset! {3, 97, 112}, 5),\n            (btreeset! {11, 66, 140}, 5),\n        ],\n        (btreeset! {49, 78, 193}, Some(btreeset! {49, 78, 193, 215})),\n    );\n    random_b_tree_sets_min_length_helper(\n        0,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            btreeset! {},\n            btreeset! {'g', 'q', '³', '»', 'À', 'Á', 'Ã', 'È', 'á', 'â', 'ì', 'ñ', 'Ā', 'ą'},\n            btreeset! {'ª', '´', 'Ã', 'ä'},\n            btreeset! {'½', 'Á', 'Ï', 'ý'},\n            btreeset! {'j'},\n            btreeset! {},\n            btreeset! {'u', '½', 'Â', 'Ñ', 'ï'},\n            btreeset! {'x', 'õ'},\n            btreeset! {'¡', 'Â', 'ù', 'Ċ'},\n            btreeset! {},\n            btreeset! {'b', 'r', 's', '¬', 'Â', 'Ñ'},\n            btreeset! {},\n            btreeset! {},\n            btreeset! {'j', 'n', 't', '¬', 'º', '¿', 'Á', 'Ø', 'Þ', 'ô', 'ü'},\n            btreeset! {'b', 'k', '±', 'Î', 'Ü', 'æ', 'è', 'ā'},\n            btreeset! {},\n            btreeset! {'«', '¹', 'Î'},\n            btreeset! {},\n            btreeset! {'~', '¯', '´', 'Ý', 'â'},\n            btreeset! {'g', '¼', 'Ç', 'Î', 'Ü', 'Þ', 'æ', 'é', 'ö'},\n        ],\n        &[\n            (btreeset! {}, 199913),\n            (btreeset! {'Ó'}, 1270),\n            (btreeset! {'Â'}, 1249),\n            (btreeset! {'§'}, 1244),\n            (btreeset! {'¿'}, 1243),\n            (btreeset! {'õ'}, 1241),\n            (btreeset! {'ĉ'}, 1234),\n            (btreeset! {'¤'}, 1232),\n            (btreeset! {'¼'}, 1232),\n            (btreeset! {'Ì'}, 1229),\n        ],\n        (\n            btreeset! {'o', 'v', '¢', '±', 'Ä', 'Ć'},\n            Some(btreeset! {'o', 'v', '¢', '³', 'ã'}),\n        ),\n    );\n    random_b_tree_sets_min_length_helper(\n        3,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        7,\n        1,\n        &[\n            btreeset! {'g', 'q', 'á'},\n            btreeset! {\n                'g', 'ª', '³', '´', '»', '½', 'À', 'Á', 'Ã', 'È', 'Ï', 'â', 'ä', 'ì', 'ñ', 'Ā', 'ą',\n            },\n            btreeset! {'j', 'u', '½', 'Â', 'Ñ', 'ï', 'ý'},\n            btreeset! {'x', '¡', '¬', 'Â', 'õ', 'ù', 'Ċ'},\n            btreeset! {'b', 's', '¬', 'Ñ'},\n            btreeset! {'n', 'r', 'Â'},\n            btreeset! {'t', '¬', 'º', '¿', 'Ø', 'Þ', 'ô', 'ü'},\n            btreeset! {'j', 'k', '±', 'Á', 'è'},\n            btreeset! {'b', '«', '¹', 'Î', 'Ü', 'æ', 'ā'},\n            btreeset! {'~', '´', 'Î'},\n            btreeset! {'g', '¯', 'Î', 'Ý', 'Þ', 'â', 'æ', 'é', 'ö'},\n            btreeset! {'¼', 'Ç', 'Ü'},\n            btreeset! {'¡', '§', 'Ì'},\n            btreeset! {'d', 'm', 'z', '{', '¨', '®', '±', '¼', 'Ë', 'Ü', 'ê', 'ì', 'ý', 'þ'},\n            btreeset! {'x', 'ª', '½', 'À', 'Õ', 'ì', 'ï', 'û', 'ă', 'Ą', 'ċ'},\n            btreeset! {'¢', '«', 'Ć'},\n            btreeset! {'{', '¢', '½', 'È', 'ä', 'ÿ'},\n            btreeset! {'Ë', 'Õ', 'ê'},\n            btreeset! {'p', '¨', '°', 'º', 'Å', 'Ó', '×', 'ü'},\n            btreeset! {'d', 'k', 'o', 'v', '¥', '±', 'Ä', 'È', 'Ê', 'ß', 'æ', 'Ć'},\n        ],\n        &[\n            (btreeset! {'m', 'u', 'w'}, 6),\n            (btreeset! {'b', 'n', 'Ã'}, 6),\n            (btreeset! {'g', '®', 'Ý'}, 6),\n            (btreeset! {'x', 'Ä', 'î'}, 6),\n            (btreeset! {'º', 'Ú', '÷'}, 6),\n            (btreeset! {'a', 'w', 'ø'}, 5),\n            (btreeset! {'c', 'e', 'Þ'}, 5),\n            (btreeset! {'d', 't', 'Ã'}, 5),\n            (btreeset! {'m', 'r', 'È'}, 5),\n            (btreeset! {'w', '{', '³'}, 5),\n        ],\n        (\n            btreeset! {'o', 's', '×', 'Ý', 'Þ', 'ß', 'î', 'ù'},\n            Some(btreeset! {'o', 's', '×', 'à', 'ã', 'ò', 'ċ'}),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_min_length_fail_1() {\n    random_b_tree_sets_min_length(EXAMPLE_SEED, 3, &random_primitive_ints::<u32>, 3, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_min_length_fail_2() {\n    random_b_tree_sets_min_length(EXAMPLE_SEED, 1, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_b_tree_sets_min_length_fail_3() {\n    random_b_tree_sets_min_length(\n        EXAMPLE_SEED,\n        0,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_hash_sets.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_hash_sets;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\n\nfn random_hash_sets_helper<T: Clone + Debug + Eq + Hash + Ord, I: Clone + Iterator<Item = T>>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[HashSet<T>],\n) {\n    let xs = random_hash_sets(\n        EXAMPLE_SEED,\n        xs_gen,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xs.take(20).collect_vec();\n    assert_eq!(values.as_slice(), expected_values);\n}\n\n#[test]\nfn test_random_hash_sets() {\n    random_hash_sets_helper(\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            hashset! {},\n            hashset! {11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235},\n            hashset! {30, 90, 218, 234},\n            hashset! {9, 106, 204, 216},\n            hashset! {151},\n            hashset! {},\n            hashset! {78, 91, 97, 213, 253},\n            hashset! {39, 191},\n            hashset! {170, 175, 232, 233},\n            hashset! {},\n            hashset! {2, 22, 35, 114, 198, 217},\n            hashset! {},\n            hashset! {},\n            hashset! {17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222},\n            hashset! {52, 69, 73, 91, 115, 137, 153, 178},\n            hashset! {},\n            hashset! {34, 95, 112},\n            hashset! {},\n            hashset! {106, 130, 167, 168, 197},\n            hashset! {86, 101, 122, 150, 172, 177, 207, 218, 221},\n        ],\n    );\n    random_hash_sets_helper(\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            hashset! {},\n            hashset! {1, 9, 12, 14, 16, 17, 19, 21, 41, 42, 68, 79, 124, 141},\n            hashset! {0, 1, 10, 99},\n            hashset! {2, 12, 36, 77},\n            hashset! {1},\n            hashset! {},\n            hashset! {1, 5, 9, 19, 103},\n            hashset! {6, 7},\n            hashset! {15, 18, 51, 159},\n            hashset! {},\n            hashset! {2, 26, 40, 52, 64, 75},\n            hashset! {},\n            hashset! {},\n            hashset! {3, 4, 5, 7, 30, 31, 34, 43, 49, 51, 67},\n            hashset! {1, 14, 16, 24, 29, 41, 47, 52},\n            hashset! {},\n            hashset! {11, 13, 62},\n            hashset! {},\n            hashset! {3, 14, 42, 47, 109},\n            hashset! {5, 13, 16, 25, 37, 41, 42, 86, 96},\n        ],\n    );\n    random_hash_sets_helper(\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            hashset! {},\n            hashset! {},\n            hashset! {85},\n            hashset! {11},\n            hashset! {136, 200},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {134, 235},\n            hashset! {203},\n            hashset! {},\n            hashset! {38, 223},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n        ],\n    );\n    random_hash_sets_helper(\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            hashset! {},\n            hashset! {'g', 'q', '³', '»', 'À', 'Á', 'Ã', 'È', 'á', 'â', 'ì', 'ñ', 'Ā', 'ą'},\n            hashset! {'ª', '´', 'Ã', 'ä'},\n            hashset! {'½', 'Á', 'Ï', 'ý'},\n            hashset! {'j'},\n            hashset! {},\n            hashset! {'u', '½', 'Â', 'Ñ', 'ï'},\n            hashset! {'x', 'õ'},\n            hashset! {'¡', 'Â', 'ù', 'Ċ'},\n            hashset! {},\n            hashset! {'b', 'r', 's', '¬', 'Â', 'Ñ'},\n            hashset! {},\n            hashset! {},\n            hashset! {'j', 'n', 't', '¬', 'º', '¿', 'Á', 'Ø', 'Þ', 'ô', 'ü'},\n            hashset! {'b', 'k', '±', 'Î', 'Ü', 'æ', 'è', 'ā'},\n            hashset! {},\n            hashset! {'«', '¹', 'Î'},\n            hashset! {},\n            hashset! {'~', '¯', '´', 'Ý', 'â'},\n            hashset! {'g', '¼', 'Ç', 'Î', 'Ü', 'Þ', 'æ', 'é', 'ö'},\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_fail_1() {\n    random_hash_sets(EXAMPLE_SEED, &random_primitive_ints::<u32>, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_fail_2() {\n    random_hash_sets(EXAMPLE_SEED, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_fail_3() {\n    random_hash_sets(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_hash_sets_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::{Itertools, repeat_n};\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::sets::random::random_hash_sets_fixed_length;\nuse malachite_base::vecs::random::random_ordered_unique_vecs_fixed_length;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn random_hash_sets_fixed_length_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    expected_values: &[HashSet<I::Item>],\n) where\n    I::Item: Debug + Eq + Hash,\n{\n    let xs = random_hash_sets_fixed_length(len, xs);\n    let values = xs.take(20).collect_vec();\n    assert_eq!(values.as_slice(), expected_values);\n}\n\n#[test]\nfn test_random_hash_sets_fixed_length() {\n    random_hash_sets_fixed_length_helper(\n        0,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &repeat_n(hashset! {}, 20).collect_vec(),\n    );\n    random_hash_sets_fixed_length_helper(\n        1,\n        random_bools(EXAMPLE_SEED),\n        &[\n            hashset! {true},\n            hashset! {false},\n            hashset! {false},\n            hashset! {false},\n            hashset! {true},\n            hashset! {true},\n            hashset! {true},\n            hashset! {false},\n            hashset! {true},\n            hashset! {true},\n            hashset! {true},\n            hashset! {true},\n            hashset! {false},\n            hashset! {true},\n            hashset! {true},\n            hashset! {true},\n            hashset! {true},\n            hashset! {false},\n            hashset! {true},\n            hashset! {false},\n        ],\n    );\n    random_hash_sets_fixed_length_helper(\n        3,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            hashset! {69, 113, 239},\n            hashset! {108, 210, 228},\n            hashset! {87, 161, 168},\n            hashset! {32, 83, 110},\n            hashset! {34, 89, 188},\n            hashset! {93, 200, 238},\n            hashset! {115, 149, 189},\n            hashset! {149, 201, 217},\n            hashset! {31, 117, 146},\n            hashset! {72, 151, 169},\n            hashset! {7, 33, 174},\n            hashset! {38, 81, 144},\n            hashset! {72, 113, 127},\n            hashset! {107, 128, 233},\n            hashset! {12, 46, 119},\n            hashset! {18, 164, 243},\n            hashset! {59, 114, 174},\n            hashset! {39, 174, 247},\n            hashset! {104, 160, 184},\n            hashset! {37, 100, 252},\n        ],\n    );\n    random_hash_sets_fixed_length_helper(\n        2,\n        random_ordered_unique_vecs_fixed_length(2, random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            hashset! {vec![69, 108], vec![113, 239]},\n            hashset! {vec![161, 168], vec![210, 228]},\n            hashset! {vec![32, 87], vec![83, 110]},\n            hashset! {vec![34, 188], vec![89, 238]},\n            hashset! {vec![93, 200], vec![115, 149]},\n            hashset! {vec![149, 189], vec![201, 217]},\n            hashset! {vec![31, 72], vec![117, 146]},\n            hashset! {vec![33, 174], vec![151, 169]},\n            hashset! {vec![7, 38], vec![81, 144]},\n            hashset! {vec![72, 127], vec![113, 128]},\n            hashset! {vec![46, 119], vec![107, 233]},\n            hashset! {vec![12, 18], vec![164, 243]},\n            hashset! {vec![59, 247], vec![114, 174]},\n            hashset! {vec![39, 174], vec![160, 184]},\n            hashset! {vec![37, 104], vec![100, 252]},\n            hashset! {vec![69, 107], vec![122, 228]},\n            hashset! {vec![142, 179], vec![242, 248]},\n            hashset! {vec![61, 189], vec![233, 239]},\n            hashset! {vec![7, 192], vec![85, 235]},\n            hashset! {vec![90, 200], vec![178, 185]},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_hash_sets_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_hash_sets_from_length_iterator;\nuse malachite_base::vecs::random_values_from_vec;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\nuse std::hash::Hash;\n\nfn random_hash_sets_from_length_iterator_helper<\n    T: Clone + Debug + Eq + Hash,\n    I: Clone + Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[HashSet<T>],\n) {\n    let xs = random_hash_sets_from_length_iterator(EXAMPLE_SEED, lengths_gen, xs_gen);\n    let values = xs.take(20).collect_vec();\n    assert_eq!(values.as_slice(), expected_values);\n}\n\n#[test]\nfn test_random_hash_sets_from_length_iterator() {\n    random_hash_sets_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2]),\n        &random_bools,\n        &[\n            hashset! {false, true},\n            hashset! {},\n            hashset! {false, true},\n            hashset! {false, true},\n            hashset! {},\n            hashset! {false, true},\n            hashset! {false, true},\n            hashset! {},\n            hashset! {false, true},\n            hashset! {false, true},\n            hashset! {},\n            hashset! {false, true},\n            hashset! {},\n            hashset! {false, true},\n            hashset! {false, true},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {false, true},\n            hashset! {},\n        ],\n    );\n    random_hash_sets_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        &random_primitive_ints::<u8>,\n        &[\n            hashset! {11, 38, 85, 134, 136, 162, 177, 200, 203, 217, 223, 235},\n            hashset! {32, 166},\n            hashset! {9, 30, 39, 78, 90, 91, 97, 106, 151, 191, 204, 213, 216, 218, 234, 253},\n            hashset! {170, 175},\n            hashset! {\n                2, 17, 22, 25, 32, 34, 35, 52, 65, 69, 73, 79, 91, 112, 114, 115, 121, 137, 144,\n                148, 153, 173, 178, 198, 217, 222, 232, 233,\n            },\n            hashset! {},\n            hashset! {95, 106, 122, 130, 167, 168, 172, 177, 197, 207},\n            hashset! {9, 74, 86, 101, 115, 150, 218, 221},\n            hashset! {109, 123},\n            hashset! {},\n            hashset! {40, 48, 52, 97, 104, 133, 159, 196, 201, 235, 247, 250},\n            hashset! {7, 68, 190, 216},\n            hashset! {},\n            hashset! {},\n            hashset! {157, 216},\n            hashset! {11, 24, 43, 103, 112, 217},\n            hashset! {},\n            hashset! {84, 211},\n            hashset! {},\n            hashset! {55, 135},\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_hash_sets_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_hash_sets_length_inclusive_range;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\n\nfn random_hash_sets_length_inclusive_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[HashSet<T>],\n) {\n    let xs = random_hash_sets_length_inclusive_range(EXAMPLE_SEED, a, b, xs_gen);\n    let values = xs.take(20).collect_vec();\n    assert_eq!(values.as_slice(), expected_values);\n}\n\n#[test]\nfn test_random_hash_sets_length_inclusive_range() {\n    random_hash_sets_length_inclusive_range_helper(\n        2,\n        3,\n        &random_primitive_ints::<u8>,\n        &[\n            hashset! {11, 85, 136},\n            hashset! {200, 235},\n            hashset! {134, 203, 223},\n            hashset! {38, 217, 235},\n            hashset! {162, 177},\n            hashset! {32, 166, 234},\n            hashset! {30, 90, 218},\n            hashset! {9, 106},\n            hashset! {151, 204, 216},\n            hashset! {97, 213, 253},\n            hashset! {78, 91},\n            hashset! {39, 175, 191},\n            hashset! {170, 232},\n            hashset! {2, 35, 233},\n            hashset! {22, 198, 217},\n            hashset! {17, 114},\n            hashset! {32, 173},\n            hashset! {65, 114},\n            hashset! {121, 173, 222},\n            hashset! {25, 144},\n        ],\n    );\n    random_hash_sets_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            hashset! {0, 1, 5},\n            hashset! {1, 4},\n            hashset! {2, 4, 6},\n            hashset! {0, 1, 2},\n            hashset! {9, 13},\n            hashset! {0, 2, 7},\n            hashset! {4, 6, 7},\n            hashset! {0, 6},\n            hashset! {0, 1, 3},\n            hashset! {1, 2, 5},\n            hashset! {0, 1},\n            hashset! {0, 1, 4},\n            hashset! {0, 2},\n            hashset! {0, 2, 12},\n            hashset! {1, 2, 3},\n            hashset! {3, 9},\n            hashset! {0, 1},\n            hashset! {1, 2},\n            hashset! {0, 1, 11},\n            hashset! {1, 6},\n        ],\n    );\n    random_hash_sets_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            hashset! {'c', 'q', 'v'},\n            hashset! {'e', 'i'},\n            hashset! {'g', 'p', 's'},\n            hashset! {'m', 'n', 't'},\n            hashset! {'o', 'z'},\n            hashset! {'f', 'k', 'm'},\n            hashset! {'q', 'u', 'y'},\n            hashset! {'k', 'x'},\n            hashset! {'h', 'n', 'u'},\n            hashset! {'a', 'j', 'n'},\n            hashset! {'w', 'z'},\n            hashset! {'b', 'l', 'w'},\n            hashset! {'l', 'u'},\n            hashset! {'e', 'l', 'n'},\n            hashset! {'k', 'u', 'v'},\n            hashset! {'c', 'h'},\n            hashset! {'i', 'y'},\n            hashset! {'m', 'r'},\n            hashset! {'m', 's', 'y'},\n            hashset! {'e', 'l'},\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_length_inclusive_range_fail() {\n    random_hash_sets_length_inclusive_range(EXAMPLE_SEED, 2, 1, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_hash_sets_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_hash_sets_length_range;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\n\nfn random_hash_sets_length_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[HashSet<T>],\n) {\n    let xs = random_hash_sets_length_range(EXAMPLE_SEED, a, b, xs_gen);\n    let values = xs.take(20).collect_vec();\n    assert_eq!(values.as_slice(), expected_values);\n}\n\n#[test]\nfn test_random_hash_sets_length_range() {\n    random_hash_sets_length_range_helper(\n        2,\n        4,\n        &random_primitive_ints::<u8>,\n        &[\n            hashset! {11, 85, 136},\n            hashset! {200, 235},\n            hashset! {134, 203, 223},\n            hashset! {38, 217, 235},\n            hashset! {162, 177},\n            hashset! {32, 166, 234},\n            hashset! {30, 90, 218},\n            hashset! {9, 106},\n            hashset! {151, 204, 216},\n            hashset! {97, 213, 253},\n            hashset! {78, 91},\n            hashset! {39, 175, 191},\n            hashset! {170, 232},\n            hashset! {2, 35, 233},\n            hashset! {22, 198, 217},\n            hashset! {17, 114},\n            hashset! {32, 173},\n            hashset! {65, 114},\n            hashset! {121, 173, 222},\n            hashset! {25, 144},\n        ],\n    );\n    random_hash_sets_length_range_helper(\n        2,\n        4,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            hashset! {0, 1, 5},\n            hashset! {1, 4},\n            hashset! {2, 4, 6},\n            hashset! {0, 1, 2},\n            hashset! {9, 13},\n            hashset! {0, 2, 7},\n            hashset! {4, 6, 7},\n            hashset! {0, 6},\n            hashset! {0, 1, 3},\n            hashset! {1, 2, 5},\n            hashset! {0, 1},\n            hashset! {0, 1, 4},\n            hashset! {0, 2},\n            hashset! {0, 2, 12},\n            hashset! {1, 2, 3},\n            hashset! {3, 9},\n            hashset! {0, 1},\n            hashset! {1, 2},\n            hashset! {0, 1, 11},\n            hashset! {1, 6},\n        ],\n    );\n    random_hash_sets_length_range_helper(\n        2,\n        4,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            hashset! {'c', 'q', 'v'},\n            hashset! {'e', 'i'},\n            hashset! {'g', 'p', 's'},\n            hashset! {'m', 'n', 't'},\n            hashset! {'o', 'z'},\n            hashset! {'f', 'k', 'm'},\n            hashset! {'q', 'u', 'y'},\n            hashset! {'k', 'x'},\n            hashset! {'h', 'n', 'u'},\n            hashset! {'a', 'j', 'n'},\n            hashset! {'w', 'z'},\n            hashset! {'b', 'l', 'w'},\n            hashset! {'l', 'u'},\n            hashset! {'e', 'l', 'n'},\n            hashset! {'k', 'u', 'v'},\n            hashset! {'c', 'h'},\n            hashset! {'i', 'y'},\n            hashset! {'m', 'r'},\n            hashset! {'m', 's', 'y'},\n            hashset! {'e', 'l'},\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_length_range_fail() {\n    random_hash_sets_length_range(EXAMPLE_SEED, 2, 2, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/sets/random/random_hash_sets_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::sets::random::random_hash_sets_min_length;\nuse std::collections::HashSet;\nuse std::fmt::Debug;\n\nfn random_hash_sets_min_length_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[HashSet<T>],\n) {\n    let xs = random_hash_sets_min_length(\n        EXAMPLE_SEED,\n        min_length,\n        xs_gen,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = xs.take(20).collect_vec();\n    assert_eq!(values.as_slice(), expected_values);\n}\n\n#[test]\nfn test_random_hash_sets_min_length() {\n    random_hash_sets_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            hashset! {},\n            hashset! {11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235},\n            hashset! {30, 90, 218, 234},\n            hashset! {9, 106, 204, 216},\n            hashset! {151},\n            hashset! {},\n            hashset! {78, 91, 97, 213, 253},\n            hashset! {39, 191},\n            hashset! {170, 175, 232, 233},\n            hashset! {},\n            hashset! {2, 22, 35, 114, 198, 217},\n            hashset! {},\n            hashset! {},\n            hashset! {17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222},\n            hashset! {52, 69, 73, 91, 115, 137, 153, 178},\n            hashset! {},\n            hashset! {34, 95, 112},\n            hashset! {},\n            hashset! {106, 130, 167, 168, 197},\n            hashset! {86, 101, 122, 150, 172, 177, 207, 218, 221},\n        ],\n    );\n    random_hash_sets_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        7,\n        1,\n        &[\n            hashset! {11, 85, 136},\n            hashset! {\n                9, 30, 32, 38, 90, 106, 134, 162, 166, 177, 200, 203, 217, 218, 223, 234, 235\n            },\n            hashset! {78, 97, 151, 204, 213, 216, 253},\n            hashset! {39, 91, 170, 175, 191, 232, 233},\n            hashset! {2, 22, 35, 217},\n            hashset! {17, 114, 198},\n            hashset! {25, 32, 65, 114, 121, 144, 173, 222},\n            hashset! {52, 73, 79, 115, 148},\n            hashset! {34, 69, 91, 112, 137, 153, 178},\n            hashset! {95, 106, 167},\n            hashset! {86, 122, 130, 150, 168, 172, 177, 197, 207},\n            hashset! {101, 218, 221},\n            hashset! {9, 74, 115},\n            hashset! {40, 48, 52, 97, 104, 109, 123, 133, 159, 196, 201, 235, 247, 250},\n            hashset! {7, 11, 24, 43, 68, 103, 112, 157, 190, 216, 217},\n            hashset! {84, 135, 211},\n            hashset! {29, 55, 65, 89, 191, 206},\n            hashset! {9, 51, 79},\n            hashset! {3, 20, 22, 34, 62, 114, 118, 148},\n            hashset! {23, 32, 47, 50, 120, 166, 176, 177, 194, 204, 238, 248},\n        ],\n    );\n    random_hash_sets_min_length_helper(\n        0,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            hashset! {},\n            hashset! {1, 9, 12, 14, 16, 17, 19, 21, 41, 42, 68, 79, 124, 141},\n            hashset! {0, 1, 10, 99},\n            hashset! {2, 12, 36, 77},\n            hashset! {1},\n            hashset! {},\n            hashset! {1, 5, 9, 19, 103},\n            hashset! {6, 7},\n            hashset! {15, 18, 51, 159},\n            hashset! {},\n            hashset! {2, 26, 40, 52, 64, 75},\n            hashset! {},\n            hashset! {},\n            hashset! {3, 4, 5, 7, 30, 31, 34, 43, 49, 51, 67},\n            hashset! {1, 14, 16, 24, 29, 41, 47, 52},\n            hashset! {},\n            hashset! {11, 13, 62},\n            hashset! {},\n            hashset! {3, 14, 42, 47, 109},\n            hashset! {5, 13, 16, 25, 37, 41, 42, 86, 96},\n        ],\n    );\n    random_hash_sets_min_length_helper(\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        7,\n        1,\n        &[\n            hashset! {1, 14, 42},\n            hashset! {0, 1, 9, 10, 12, 16, 17, 19, 21, 36, 41, 68, 77, 79, 99, 124, 141},\n            hashset! {1, 2, 5, 9, 12, 19, 103},\n            hashset! {6, 7, 15, 18, 51, 52, 159},\n            hashset! {2, 40, 64, 75},\n            hashset! {26, 34, 67},\n            hashset! {4, 5, 7, 30, 31, 43, 49, 51},\n            hashset! {3, 14, 16, 24, 47},\n            hashset! {1, 11, 13, 29, 41, 52, 62},\n            hashset! {3, 47, 109},\n            hashset! {13, 14, 16, 25, 37, 41, 42, 86, 96},\n            hashset! {5, 20, 42},\n            hashset! {2, 74, 82},\n            hashset! {3, 6, 7, 11, 17, 20, 36, 45, 56, 66, 76, 80, 89, 127},\n            hashset! {1, 6, 10, 13, 19, 23, 25, 32, 41, 43, 97},\n            hashset! {7, 41, 134},\n            hashset! {9, 10, 25, 26, 47, 105},\n            hashset! {68, 94, 109},\n            hashset! {1, 3, 9, 13, 28, 43, 44, 84},\n            hashset! {0, 4, 5, 6, 7, 13, 31, 32, 37, 42, 50, 75},\n        ],\n    );\n    random_hash_sets_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            hashset! {},\n            hashset! {},\n            hashset! {85},\n            hashset! {11},\n            hashset! {136, 200},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {134, 235},\n            hashset! {203},\n            hashset! {},\n            hashset! {38, 223},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n            hashset! {},\n        ],\n    );\n    random_hash_sets_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        13,\n        4,\n        &[\n            hashset! {11, 85, 136},\n            hashset! {134, 200, 235},\n            hashset! {38, 203, 223, 235},\n            hashset! {32, 162, 177, 217},\n            hashset! {30, 90, 166, 218, 234},\n            hashset! {9, 106, 216},\n            hashset! {151, 204, 213},\n            hashset! {78, 97, 253},\n            hashset! {39, 91, 191},\n            hashset! {170, 175, 232},\n            hashset! {2, 35, 233},\n            hashset! {22, 198, 217},\n            hashset! {17, 32, 65, 114, 173},\n            hashset! {25, 121, 173, 222},\n            hashset! {79, 144, 148},\n            hashset! {52, 69, 73, 115, 137},\n            hashset! {91, 153, 178},\n            hashset! {34, 95, 112},\n            hashset! {106, 167, 197},\n            hashset! {122, 130, 168},\n        ],\n    );\n    random_hash_sets_min_length_helper(\n        0,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            hashset! {},\n            hashset! {'g', 'q', '³', '»', 'À', 'Á', 'Ã', 'È', 'á', 'â', 'ì', 'ñ', 'Ā', 'ą'},\n            hashset! {'ª', '´', 'Ã', 'ä'},\n            hashset! {'½', 'Á', 'Ï', 'ý'},\n            hashset! {'j'},\n            hashset! {},\n            hashset! {'u', '½', 'Â', 'Ñ', 'ï'},\n            hashset! {'x', 'õ'},\n            hashset! {'¡', 'Â', 'ù', 'Ċ'},\n            hashset! {},\n            hashset! {'b', 'r', 's', '¬', 'Â', 'Ñ'},\n            hashset! {},\n            hashset! {},\n            hashset! {'j', 'n', 't', '¬', 'º', '¿', 'Á', 'Ø', 'Þ', 'ô', 'ü'},\n            hashset! {'b', 'k', '±', 'Î', 'Ü', 'æ', 'è', 'ā'},\n            hashset! {},\n            hashset! {'«', '¹', 'Î'},\n            hashset! {},\n            hashset! {'~', '¯', '´', 'Ý', 'â'},\n            hashset! {'g', '¼', 'Ç', 'Î', 'Ü', 'Þ', 'æ', 'é', 'ö'},\n        ],\n    );\n    random_hash_sets_min_length_helper(\n        3,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        7,\n        1,\n        &[\n            hashset! {'g', 'q', 'á'},\n            hashset! {\n                'g', 'ª', '³', '´', '»', '½', 'À', 'Á', 'Ã', 'È', 'Ï', 'â', 'ä', 'ì', 'ñ', 'Ā', 'ą',\n            },\n            hashset! {'j', 'u', '½', 'Â', 'Ñ', 'ï', 'ý'},\n            hashset! {'x', '¡', '¬', 'Â', 'õ', 'ù', 'Ċ'},\n            hashset! {'b', 's', '¬', 'Ñ'},\n            hashset! {'n', 'r', 'Â'},\n            hashset! {'t', '¬', 'º', '¿', 'Ø', 'Þ', 'ô', 'ü'},\n            hashset! {'j', 'k', '±', 'Á', 'è'},\n            hashset! {'b', '«', '¹', 'Î', 'Ü', 'æ', 'ā'},\n            hashset! {'~', '´', 'Î'},\n            hashset! {'g', '¯', 'Î', 'Ý', 'Þ', 'â', 'æ', 'é', 'ö'},\n            hashset! {'¼', 'Ç', 'Ü'},\n            hashset! {'¡', '§', 'Ì'},\n            hashset! {'d', 'm', 'z', '{', '¨', '®', '±', '¼', 'Ë', 'Ü', 'ê', 'ì', 'ý', 'þ'},\n            hashset! {'x', 'ª', '½', 'À', 'Õ', 'ì', 'ï', 'û', 'ă', 'Ą', 'ċ'},\n            hashset! {'¢', '«', 'Ć'},\n            hashset! {'{', '¢', '½', 'È', 'ä', 'ÿ'},\n            hashset! {'Ë', 'Õ', 'ê'},\n            hashset! {'p', '¨', '°', 'º', 'Å', 'Ó', '×', 'ü'},\n            hashset! {'d', 'k', 'o', 'v', '¥', '±', 'Ä', 'È', 'Ê', 'ß', 'æ', 'Ć'},\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_min_length_fail_1() {\n    random_hash_sets_min_length(EXAMPLE_SEED, 3, &random_primitive_ints::<u32>, 3, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_min_length_fail_2() {\n    random_hash_sets_min_length(EXAMPLE_SEED, 1, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_hash_sets_min_length_fail_3() {\n    random_hash_sets_min_length(\n        EXAMPLE_SEED,\n        0,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/exhaustive_slice_permutations.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Factorial;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::slices::exhaustive_slice_permutations;\n\nfn exhaustive_slice_permutations_helper(cs: &str, out: &[&str]) {\n    let cs = cs.chars().collect_vec();\n    let css: Vec<String> = exhaustive_slice_permutations(&cs)\n        .map(|ds| ds.into_iter().copied().collect())\n        .collect();\n    assert_eq!(css.len(), usize::factorial(u64::wrapping_from(cs.len())));\n    assert_eq!(css.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_exhaustive_slice_permutations() {\n    exhaustive_slice_permutations_helper(\"\", &[\"\"]);\n    exhaustive_slice_permutations_helper(\"1\", &[\"1\"]);\n    exhaustive_slice_permutations_helper(\"12\", &[\"12\", \"21\"]);\n    exhaustive_slice_permutations_helper(\"123\", &[\"123\", \"132\", \"213\", \"231\", \"312\", \"321\"]);\n    exhaustive_slice_permutations_helper(\n        \"1234\",\n        &[\n            \"1234\", \"1243\", \"1324\", \"1342\", \"1423\", \"1432\", \"2134\", \"2143\", \"2314\", \"2341\", \"2413\",\n            \"2431\", \"3124\", \"3142\", \"3214\", \"3241\", \"3412\", \"3421\", \"4123\", \"4132\", \"4213\", \"4231\",\n            \"4312\", \"4321\",\n        ],\n    );\n    exhaustive_slice_permutations_helper(\n        \"12345\",\n        &[\n            \"12345\", \"12354\", \"12435\", \"12453\", \"12534\", \"12543\", \"13245\", \"13254\", \"13425\",\n            \"13452\", \"13524\", \"13542\", \"14235\", \"14253\", \"14325\", \"14352\", \"14523\", \"14532\",\n            \"15234\", \"15243\", \"15324\", \"15342\", \"15423\", \"15432\", \"21345\", \"21354\", \"21435\",\n            \"21453\", \"21534\", \"21543\", \"23145\", \"23154\", \"23415\", \"23451\", \"23514\", \"23541\",\n            \"24135\", \"24153\", \"24315\", \"24351\", \"24513\", \"24531\", \"25134\", \"25143\", \"25314\",\n            \"25341\", \"25413\", \"25431\", \"31245\", \"31254\", \"31425\", \"31452\", \"31524\", \"31542\",\n            \"32145\", \"32154\", \"32415\", \"32451\", \"32514\", \"32541\", \"34125\", \"34152\", \"34215\",\n            \"34251\", \"34512\", \"34521\", \"35124\", \"35142\", \"35214\", \"35241\", \"35412\", \"35421\",\n            \"41235\", \"41253\", \"41325\", \"41352\", \"41523\", \"41532\", \"42135\", \"42153\", \"42315\",\n            \"42351\", \"42513\", \"42531\", \"43125\", \"43152\", \"43215\", \"43251\", \"43512\", \"43521\",\n            \"45123\", \"45132\", \"45213\", \"45231\", \"45312\", \"45321\", \"51234\", \"51243\", \"51324\",\n            \"51342\", \"51423\", \"51432\", \"52134\", \"52143\", \"52314\", \"52341\", \"52413\", \"52431\",\n            \"53124\", \"53142\", \"53214\", \"53241\", \"53412\", \"53421\", \"54123\", \"54132\", \"54213\",\n            \"54231\", \"54312\", \"54321\",\n        ],\n    );\n    exhaustive_slice_permutations_helper(\n        \"abcd\",\n        &[\n            \"abcd\", \"abdc\", \"acbd\", \"acdb\", \"adbc\", \"adcb\", \"bacd\", \"badc\", \"bcad\", \"bcda\", \"bdac\",\n            \"bdca\", \"cabd\", \"cadb\", \"cbad\", \"cbda\", \"cdab\", \"cdba\", \"dabc\", \"dacb\", \"dbac\", \"dbca\",\n            \"dcab\", \"dcba\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/min_repeating_len.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::min_repeating_len;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_vec_gen_var_4};\n\n#[test]\nfn test_min_repeating_len() {\n    let test = |xs: &[u32], out| {\n        assert_eq!(min_repeating_len(xs), out);\n    };\n    test(&[1, 2, 1, 2, 1, 2], 2);\n    test(&[1, 2, 1, 2, 1, 3], 6);\n    test(&[5, 5, 5], 1);\n    test(&[100], 1);\n}\n\n#[test]\n#[should_panic]\nfn min_repeating_len_fail() {\n    min_repeating_len::<u8>(&[]);\n}\n\n#[test]\nfn min_repeating_len_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_gen_var_4::<u8>().test_properties_with_config(&config, |xs| {\n        let len = xs.len();\n        let repeating_len = min_repeating_len(&xs);\n        assert_ne!(repeating_len, 0);\n        assert!(len.divisible_by(repeating_len));\n        let rep = &xs[..repeating_len];\n        assert_eq!(min_repeating_len(rep), repeating_len);\n        assert!(Iterator::eq(rep.iter().cycle().take(len), xs.iter()));\n    });\n\n    unsigned_gen::<u8>().test_properties_with_config(&config, |x| {\n        assert_eq!(min_repeating_len(&[x]), 1);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/random_slice_permutations.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::slices::random_slice_permutations;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\n\nfn random_slice_permutations_helper(\n    cs: &str,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let cs = cs.chars().collect_vec();\n    let ss =\n        random_slice_permutations(EXAMPLE_SEED, &cs).map(|ds| ds.into_iter().copied().collect());\n    let values = ss.clone().take(20).collect_vec();\n    let common_values = common_values_map(1000000, 10, ss.clone());\n    let (median_lo, median_hi) = median(ss.take(1000000));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_slice_permutations() {\n    random_slice_permutations_helper(\"\", &[\"\"; 20], &[(\"\", 1000000)], (\"\", None));\n    random_slice_permutations_helper(\"a\", &[\"a\"; 20], &[(\"a\", 1000000)], (\"a\", None));\n    random_slice_permutations_helper(\n        \"ab\",\n        &[\n            \"ba\", \"ab\", \"ab\", \"ab\", \"ab\", \"ba\", \"ba\", \"ba\", \"ba\", \"ab\", \"ba\", \"ab\", \"ab\", \"ba\",\n            \"ab\", \"ab\", \"ba\", \"ab\", \"ba\", \"ab\",\n        ],\n        &[(\"ba\", 500291), (\"ab\", 499709)],\n        (\"ba\", None),\n    );\n    random_slice_permutations_helper(\n        \"abc\",\n        &[\n            \"bac\", \"cba\", \"cba\", \"cba\", \"cba\", \"acb\", \"acb\", \"bca\", \"acb\", \"bac\", \"abc\", \"bac\",\n            \"bac\", \"acb\", \"cba\", \"abc\", \"bca\", \"cab\", \"acb\", \"bac\",\n        ],\n        &[\n            (\"abc\", 167957),\n            (\"bac\", 167073),\n            (\"cba\", 166362),\n            (\"acb\", 166331),\n            (\"cab\", 166166),\n            (\"bca\", 166111),\n        ],\n        (\"bac\", None),\n    );\n    random_slice_permutations_helper(\n        \"abcd\",\n        &[\n            \"dacb\", \"cbad\", \"cdab\", \"cbad\", \"cdab\", \"bcda\", \"bcda\", \"acbd\", \"bcda\", \"dbca\", \"bdac\",\n            \"dbac\", \"dbca\", \"bcad\", \"cadb\", \"dacb\", \"acbd\", \"dbac\", \"bdca\", \"abdc\",\n        ],\n        &[\n            (\"dbca\", 41992),\n            (\"bcda\", 41855),\n            (\"cdab\", 41827),\n            (\"dcab\", 41818),\n            (\"abcd\", 41809),\n            (\"badc\", 41804),\n            (\"cadb\", 41803),\n            (\"adbc\", 41763),\n            (\"cbad\", 41706),\n            (\"dbac\", 41697),\n        ],\n        (\"bdca\", None),\n    );\n    random_slice_permutations_helper(\n        \"abcdefghij\",\n        &[\n            \"daiehfcbjg\",\n            \"bhagejicdf\",\n            \"fdaibchgje\",\n            \"bicdfhgaej\",\n            \"bdfihjagec\",\n            \"chdjbafeig\",\n            \"cgajbfdieh\",\n            \"jecbhafgid\",\n            \"aedjgchfbi\",\n            \"hacjiefdgb\",\n            \"ahgdfcbije\",\n            \"cibdehfjag\",\n            \"fgdebchjai\",\n            \"gieajbdfch\",\n            \"deagfjihcb\",\n            \"hjfgdbacie\",\n            \"jdghacbfie\",\n            \"cebaihjfdg\",\n            \"jgdbchfeai\",\n            \"cjahbegdif\",\n        ],\n        &[\n            (\"afdhbciejg\", 5),\n            (\"afegijbcdh\", 5),\n            (\"afgcedhjbi\", 5),\n            (\"agbijhcfde\", 5),\n            (\"ahejcigbfd\", 5),\n            (\"ahjcgfdebi\", 5),\n            (\"aihecgdfbj\", 5),\n            (\"ajfghdcbei\", 5),\n            (\"badicjhgfe\", 5),\n            (\"bfdacehijg\", 5),\n        ],\n        (\"ejicadfgbh\", Some(\"ejicadgbfh\")),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/random_values_from_slice.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::nevers::Never;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::slices::random_values_from_slice;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\n#[test]\nfn test_random_values_from_slice() {\n    let test = |slice: &[u32],\n                values: &[u32],\n                common_values: &[(u32, usize)],\n                actual_median: (u32, Option<u32>)| {\n        let xs = random_values_from_slice(EXAMPLE_SEED, slice).cloned();\n        let expected_values = xs.clone().take(20).collect_vec();\n        let expected_common_values = common_values_map_debug(1000000, 10, xs.clone());\n        let expected_median = median(xs.take(1000000));\n        assert_eq!(\n            (\n                expected_values.as_slice(),\n                expected_common_values.as_slice(),\n                expected_median\n            ),\n            (values, common_values, actual_median)\n        );\n    };\n    test(&[5], &[5; 20], &[(5, 1000000)], (5, None));\n    test(\n        &[0, 1],\n        &[1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0],\n        &[(1, 500473), (0, 499527)],\n        (1, None),\n    );\n    test(\n        &[1, 1, 1, 10],\n        &[\n            1, 1, 10, 1, 10, 10, 1, 10, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 10,\n        ],\n        &[(1, 749985), (10, 250015)],\n        (1, None),\n    );\n    test(\n        &[2, 3, 5, 7, 11],\n        &[\n            3, 7, 3, 5, 11, 3, 5, 11, 2, 2, 5, 5, 2, 11, 2, 11, 5, 11, 5, 3,\n        ],\n        &[\n            (2, 200420),\n            (7, 200369),\n            (11, 200347),\n            (5, 199589),\n            (3, 199275),\n        ],\n        (5, None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_values_from_slice_fail() {\n    random_values_from_slice::<Never>(EXAMPLE_SEED, &[]);\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/slice_leading_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::{slice_leading_zeros, slice_test_zero, slice_trailing_zeros};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\n\n#[test]\nfn test_slice_leading_zeros() {\n    let test = |xs: &[u32], out| {\n        assert_eq!(slice_leading_zeros(xs), out);\n    };\n    test(&[], 0);\n    test(&[0], 1);\n    test(&[0, 0, 0], 3);\n    test(&[123], 0);\n    test(&[123, 0], 0);\n    test(&[0, 123, 0, 0, 0], 1);\n    test(&[1, 2, 3], 0);\n    test(&[0, 0, 0, 1, 2, 3], 3);\n}\n\n#[test]\nfn slice_leading_zeros_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_gen::<u8>().test_properties_with_config(&config, |xs| {\n        let leading_zeros = slice_leading_zeros(&xs);\n        assert!(leading_zeros <= xs.len());\n        assert_eq!(leading_zeros == xs.len(), slice_test_zero(&xs));\n        let mut new_xs = xs;\n        new_xs.reverse();\n        assert_eq!(slice_trailing_zeros(&new_xs), leading_zeros);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/slice_move_left.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::slice_move_left;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_vec_gen, unsigned_vec_unsigned_pair_gen_var_1,\n};\nuse malachite_base::test_util::slices::slice_move_left_naive;\n\n#[test]\nfn test_slice_move_left() {\n    let test = |xs_in: &[u32], amount, xs_out: &[u32]| {\n        let mut xs = xs_in.to_vec();\n        slice_move_left(&mut xs, amount);\n        assert_eq!(xs, xs_out);\n\n        let mut xs = xs_in.to_vec();\n        slice_move_left_naive::<u32>(&mut xs, amount);\n        assert_eq!(xs, xs_out);\n    };\n    test(&[], 0, &[]);\n    test(&[1], 0, &[1]);\n    test(&[1], 1, &[1]);\n    test(&[1, 2, 3], 0, &[1, 2, 3]);\n    test(&[1, 2, 3], 1, &[2, 3, 3]);\n    test(&[1, 2, 3], 2, &[3, 2, 3]);\n    test(&[1, 2, 3], 3, &[1, 2, 3]);\n    test(&[1, 2, 3, 4, 5, 6], 2, &[3, 4, 5, 6, 5, 6]);\n}\n\n#[test]\n#[should_panic]\nfn slice_move_left_fail_1() {\n    let xs = &mut [];\n    slice_move_left::<u32>(xs, 1);\n}\n\n#[test]\n#[should_panic]\nfn slice_move_left_fail_2() {\n    let xs = &mut [1, 2, 3];\n    slice_move_left::<u32>(xs, 4);\n}\n\n#[test]\nfn slice_move_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_unsigned_pair_gen_var_1::<u8>().test_properties_with_config(\n        &config,\n        |(mut xs, amount)| {\n            let old_xs = xs.clone();\n            slice_move_left(&mut xs, amount);\n            let boundary = old_xs.len() - amount;\n            let (xs_lo, xs_hi) = xs.split_at(boundary);\n            assert_eq!(xs_lo, &old_xs[amount..]);\n            assert_eq!(xs_hi, &old_xs[boundary..]);\n\n            let mut xs_alt = old_xs;\n            slice_move_left_naive(&mut xs_alt, amount);\n            assert_eq!(xs_alt, xs);\n        },\n    );\n\n    unsigned_vec_gen::<u8>().test_properties_with_config(&config, |mut xs| {\n        let old_xs = xs.clone();\n        slice_move_left(&mut xs, 0);\n        assert_eq!(xs, old_xs);\n\n        let mut xs = old_xs.clone();\n        slice_move_left(&mut xs, old_xs.len());\n        assert_eq!(xs, old_xs);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/slice_set_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::{slice_set_zero, slice_test_zero};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\n\n#[test]\nfn test_slice_set_zero() {\n    let test = |xs: &[u32], out: &[u32]| {\n        let mut mut_xs = xs.to_vec();\n        slice_set_zero(&mut mut_xs);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[], &[]);\n    test(&[0], &[0]);\n    test(&[0, 0, 0], &[0, 0, 0]);\n    test(&[123], &[0]);\n    test(&[123, 0], &[0, 0]);\n    test(&[0, 123, 0, 0, 0], &[0, 0, 0, 0, 0]);\n}\n\n#[test]\nfn slice_set_zero_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_gen::<u8>().test_properties_with_config(&config, |mut xs| {\n        let old_xs = xs.clone();\n        slice_set_zero(&mut xs);\n        assert_eq!(old_xs.len(), xs.len());\n        assert!(slice_test_zero(&xs));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/slice_test_zero.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::{slice_set_zero, slice_test_zero};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\n\n#[test]\nfn test_slice_test_zero() {\n    let test = |xs: &[u32], out| {\n        assert_eq!(slice_test_zero(xs), out);\n    };\n    test(&[], true);\n    test(&[0], true);\n    test(&[0, 0, 0], true);\n    test(&[123], false);\n    test(&[123, 0], false);\n    test(&[0, 123, 0, 0, 0], false);\n}\n\n#[test]\nfn slice_test_zero_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_gen::<u8>().test_properties_with_config(&config, |xs| {\n        let xs_are_zero = slice_test_zero(&xs);\n        let mut new_xs = xs.clone();\n        slice_set_zero(&mut new_xs);\n        assert_eq!(xs == new_xs, xs_are_zero);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/slice_trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::{slice_leading_zeros, slice_test_zero, slice_trailing_zeros};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\n\n#[test]\nfn test_slice_trailing_zeros() {\n    let test = |xs: &[u32], out| {\n        assert_eq!(slice_trailing_zeros(xs), out);\n    };\n    test(&[], 0);\n    test(&[0], 1);\n    test(&[0, 0, 0], 3);\n    test(&[123], 0);\n    test(&[123, 0], 1);\n    test(&[0, 123, 0, 0, 0], 3);\n    test(&[1, 2, 3], 0);\n    test(&[1, 2, 3, 0, 0, 0], 3);\n}\n\n#[test]\nfn slice_trailing_zeros_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_gen::<u8>().test_properties_with_config(&config, |xs| {\n        let trailing_zeros = slice_trailing_zeros(&xs);\n        assert!(trailing_zeros <= xs.len());\n        assert_eq!(trailing_zeros == xs.len(), slice_test_zero(&xs));\n        let mut new_xs = xs;\n        new_xs.reverse();\n        assert_eq!(slice_leading_zeros(&new_xs), trailing_zeros);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/slices/split_into_chunks.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::slice_set_zero;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_unsigned_triple_gen_var_2;\n\n#[test]\nfn test_split_into_chunks() {\n    let xs = &[0, 1, 2, 3, 4, 5, 6, 7];\n    split_into_chunks!(xs, 3, [xs_1, xs_2], xs_3);\n    assert_eq!(xs_1, &[0, 1, 2]);\n    assert_eq!(xs_2, &[3, 4, 5]);\n    assert_eq!(xs_3, &[6, 7]);\n\n    split_into_chunks!(xs, 3, [xs_1], xs_2);\n    assert_eq!(xs_1, &[0, 1, 2]);\n    assert_eq!(xs_2, &[3, 4, 5, 6, 7]);\n\n    split_into_chunks!(xs, 1, [xs_1, xs_2], xs_3);\n    assert_eq!(xs_1, &[0]);\n    assert_eq!(xs_2, &[1]);\n    assert_eq!(xs_3, &[2, 3, 4, 5, 6, 7]);\n\n    split_into_chunks!(xs, 0, [xs_1, xs_2], xs_3);\n    assert_eq!(xs_1, &[]);\n    assert_eq!(xs_2, &[]);\n    assert_eq!(xs_3, &[0, 1, 2, 3, 4, 5, 6, 7]);\n\n    split_into_chunks!(xs, 5, [], xs_1);\n    assert_eq!(xs_1, &[0, 1, 2, 3, 4, 5, 6, 7]);\n}\n\n#[test]\n#[should_panic]\nfn split_into_chunks_fail() {\n    let xs = &[0, 1, 2, 3, 4, 5, 6, 7];\n    split_into_chunks!(xs, 5, [_xs_1, _xs_2], _xs_3);\n}\n\n#[test]\nfn test_split_into_chunks_mut() {\n    let xs = &mut [0, 1, 2, 3, 4, 5, 6, 7];\n    split_into_chunks_mut!(xs, 3, [xs_1, xs_2], xs_3);\n    assert_eq!(xs_1, &[0, 1, 2]);\n    assert_eq!(xs_2, &[3, 4, 5]);\n    assert_eq!(xs_3, &[6, 7]);\n\n    split_into_chunks_mut!(xs, 3, [xs_1], xs_2);\n    assert_eq!(xs_1, &[0, 1, 2]);\n    assert_eq!(xs_2, &[3, 4, 5, 6, 7]);\n\n    split_into_chunks_mut!(xs, 1, [xs_1, xs_2], xs_3);\n    assert_eq!(xs_1, &[0]);\n    assert_eq!(xs_2, &[1]);\n    assert_eq!(xs_3, &[2, 3, 4, 5, 6, 7]);\n\n    split_into_chunks_mut!(xs, 0, [xs_1, xs_2], xs_3);\n    assert_eq!(xs_1, &[]);\n    assert_eq!(xs_2, &[]);\n    assert_eq!(xs_3, &[0, 1, 2, 3, 4, 5, 6, 7]);\n\n    split_into_chunks_mut!(xs, 5, [], xs_1);\n    assert_eq!(xs_1, &[0, 1, 2, 3, 4, 5, 6, 7]);\n\n    split_into_chunks_mut!(xs, 3, [_xs_1, xs_2], _xs_3);\n    slice_set_zero(xs_2);\n    assert_eq!(xs, &[0, 1, 2, 0, 0, 0, 6, 7]);\n}\n\n#[test]\n#[should_panic]\nfn split_into_chunks_mut_fail() {\n    let xs = &mut [0, 1, 2, 3, 4, 5, 6, 7];\n    split_into_chunks_mut!(xs, 5, [_xs_1, _xs_2], _xs_3);\n}\n\nmacro_rules! split_into_chunks_helper {\n    ($xs: expr, $len: expr, $n: expr, [$($xs_i: ident),*], $xs_last: ident) => {{\n        split_into_chunks!($xs, $len, [$($xs_i),*], $xs_last);\n        $(\n            assert_eq!($xs_i.len(), $len);\n        )*\n        assert_eq!($xs_last.len(), $xs.len() - ($n - 1) * $len);\n        let mut xs_alt = Vec::with_capacity($xs.len());\n        $(\n            xs_alt.extend($xs_i.iter().cloned());\n        )*\n        xs_alt.extend($xs_last.iter().cloned());\n        assert_eq!(xs_alt, $xs);\n   }}\n}\n\n#[test]\nfn split_into_chunks_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"small_unsigned_mean_n\", 8);\n    config.insert(\"small_unsigned_mean_d\", 1);\n    config.insert(\"mean_stripe_n\", u8::WIDTH << 1);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_2::<u8>().test_properties_with_config(\n        &config,\n        |(xs, len, n)| match n {\n            0 => split_into_chunks_helper!(xs, len, 1, [], xs_1),\n            1 => split_into_chunks_helper!(xs, len, 2, [xs_1], xs_2),\n            2 => split_into_chunks_helper!(xs, len, 3, [xs_1, xs_2], xs_3),\n            3 => {\n                split_into_chunks_helper!(xs, len, 4, [xs_1, xs_2, xs_3], xs_4);\n            }\n            4 => {\n                split_into_chunks_helper!(xs, len, 5, [xs_1, xs_2, xs_3, xs_4], xs_5);\n            }\n            5 => split_into_chunks_helper!(xs, len, 6, [xs_1, xs_2, xs_3, xs_4, xs_5], xs_6),\n            6 => split_into_chunks_helper!(xs, len, 7, [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6], xs_7),\n            7 => split_into_chunks_helper!(\n                xs,\n                len,\n                8,\n                [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6, xs_7],\n                xs_8\n            ),\n            _ => {}\n        },\n    );\n}\n\nmacro_rules! split_into_chunks_mut_helper {\n    ($xs: expr, $len: expr, $n: expr, [$($xs_i: ident),*], $xs_last: ident) => {{\n        let xs_len = $xs.len();\n        split_into_chunks_mut!($xs, $len, [$($xs_i),*], $xs_last);\n        $(\n            assert_eq!($xs_i.len(), $len);\n        )*\n        assert_eq!($xs_last.len(), xs_len - ($n - 1) * $len);\n        let mut xs_alt = Vec::with_capacity(xs_len);\n        $(\n            xs_alt.extend($xs_i.iter().cloned());\n        )*\n        xs_alt.extend($xs_last.iter().cloned());\n        assert_eq!(xs_alt, $xs);\n   }}\n}\n\n#[test]\nfn split_into_chunks_mut_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"small_unsigned_mean_n\", 8);\n    config.insert(\"small_unsigned_mean_d\", 1);\n    config.insert(\"mean_stripe_n\", u8::WIDTH << 1);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_2::<u8>().test_properties_with_config(\n        &config,\n        |(mut xs, len, n)| match n {\n            0 => split_into_chunks_mut_helper!(xs, len, 1, [], xs_1),\n            1 => split_into_chunks_mut_helper!(xs, len, 2, [xs_1], xs_2),\n            2 => split_into_chunks_mut_helper!(xs, len, 3, [xs_1, xs_2], xs_3),\n            3 => {\n                split_into_chunks_mut_helper!(xs, len, 4, [xs_1, xs_2, xs_3], xs_4);\n            }\n            4 => {\n                split_into_chunks_mut_helper!(xs, len, 5, [xs_1, xs_2, xs_3, xs_4], xs_5);\n            }\n            5 => split_into_chunks_mut_helper!(xs, len, 6, [xs_1, xs_2, xs_3, xs_4, xs_5], xs_6),\n            6 => {\n                split_into_chunks_mut_helper!(\n                    xs,\n                    len,\n                    7,\n                    [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6],\n                    xs_7\n                );\n            }\n            7 => split_into_chunks_mut_helper!(\n                xs,\n                len,\n                8,\n                [xs_1, xs_2, xs_3, xs_4, xs_5, xs_6, xs_7],\n                xs_8\n            ),\n            _ => {}\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/exhaustive_fixed_length_strings.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::exhaustive::exhaustive_fixed_length_strings;\n\nfn exhaustive_fixed_length_strings_helper(len: u64, out: &[&str]) {\n    let css = exhaustive_fixed_length_strings(len).take(20).collect_vec();\n    assert_eq!(css.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_exhaustive_fixed_length_strings() {\n    exhaustive_fixed_length_strings_helper(0, &[\"\"]);\n    exhaustive_fixed_length_strings_helper(\n        1,\n        &[\n            \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\",\n            \"r\", \"s\", \"t\",\n        ],\n    );\n    exhaustive_fixed_length_strings_helper(\n        2,\n        &[\n            \"aa\", \"ab\", \"ba\", \"bb\", \"ac\", \"ad\", \"bc\", \"bd\", \"ca\", \"cb\", \"da\", \"db\", \"cc\", \"cd\",\n            \"dc\", \"dd\", \"ae\", \"af\", \"be\", \"bf\",\n        ],\n    );\n    exhaustive_fixed_length_strings_helper(\n        3,\n        &[\n            \"aaa\", \"aab\", \"aba\", \"abb\", \"baa\", \"bab\", \"bba\", \"bbb\", \"aac\", \"aad\", \"abc\", \"abd\",\n            \"bac\", \"bad\", \"bbc\", \"bbd\", \"aca\", \"acb\", \"ada\", \"adb\",\n        ],\n    );\n    exhaustive_fixed_length_strings_helper(\n        10,\n        &[\n            \"aaaaaaaaaa\",\n            \"aaaaaaaaab\",\n            \"aaaaaaaaba\",\n            \"aaaaaaaabb\",\n            \"aaaaaaabaa\",\n            \"aaaaaaabab\",\n            \"aaaaaaabba\",\n            \"aaaaaaabbb\",\n            \"aaaaaabaaa\",\n            \"aaaaaabaab\",\n            \"aaaaaababa\",\n            \"aaaaaababb\",\n            \"aaaaaabbaa\",\n            \"aaaaaabbab\",\n            \"aaaaaabbba\",\n            \"aaaaaabbbb\",\n            \"aaaaabaaaa\",\n            \"aaaaabaaab\",\n            \"aaaaabaaba\",\n            \"aaaaabaabb\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/exhaustive_fixed_length_strings_using_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::exhaustive::exhaustive_fixed_length_strings_using_chars;\nuse std::iter::{empty, once};\n\nfn exhaustive_fixed_length_strings_using_chars_helper<I: Iterator<Item = char>>(\n    len: u64,\n    cs: I,\n    out: &[&str],\n) {\n    let css = exhaustive_fixed_length_strings_using_chars(len, cs)\n        .take(20)\n        .collect_vec();\n    assert_eq!(css.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_exhaustive_fixed_length_strings_using_chars() {\n    exhaustive_fixed_length_strings_using_chars_helper(0, empty(), &[\"\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(1, empty(), &[]);\n    exhaustive_fixed_length_strings_using_chars_helper(0, once('q'), &[\"\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(1, once('q'), &[\"q\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(2, once('q'), &[\"qq\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(3, once('q'), &[\"qqq\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(10, once('q'), &[\"qqqqqqqqqq\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(0, ['x', 'y'].iter().copied(), &[\"\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(1, ['x', 'y'].iter().copied(), &[\"x\", \"y\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(\n        2,\n        ['x', 'y'].iter().copied(),\n        &[\"xx\", \"xy\", \"yx\", \"yy\"],\n    );\n    exhaustive_fixed_length_strings_using_chars_helper(\n        3,\n        ['x', 'y'].iter().copied(),\n        &[\"xxx\", \"xxy\", \"xyx\", \"xyy\", \"yxx\", \"yxy\", \"yyx\", \"yyy\"],\n    );\n    exhaustive_fixed_length_strings_using_chars_helper(\n        10,\n        ['x', 'y'].iter().copied(),\n        &[\n            \"xxxxxxxxxx\",\n            \"xxxxxxxxxy\",\n            \"xxxxxxxxyx\",\n            \"xxxxxxxxyy\",\n            \"xxxxxxxyxx\",\n            \"xxxxxxxyxy\",\n            \"xxxxxxxyyx\",\n            \"xxxxxxxyyy\",\n            \"xxxxxxyxxx\",\n            \"xxxxxxyxxy\",\n            \"xxxxxxyxyx\",\n            \"xxxxxxyxyy\",\n            \"xxxxxxyyxx\",\n            \"xxxxxxyyxy\",\n            \"xxxxxxyyyx\",\n            \"xxxxxxyyyy\",\n            \"xxxxxyxxxx\",\n            \"xxxxxyxxxy\",\n            \"xxxxxyxxyx\",\n            \"xxxxxyxxyy\",\n        ],\n    );\n    exhaustive_fixed_length_strings_using_chars_helper(0, ['c', 'a', 't'].iter().copied(), &[\"\"]);\n    exhaustive_fixed_length_strings_using_chars_helper(\n        1,\n        ['c', 'a', 't'].iter().copied(),\n        &[\"c\", \"a\", \"t\"],\n    );\n    exhaustive_fixed_length_strings_using_chars_helper(\n        2,\n        ['c', 'a', 't'].iter().copied(),\n        &[\"cc\", \"ca\", \"ac\", \"aa\", \"ct\", \"at\", \"tc\", \"ta\", \"tt\"],\n    );\n    exhaustive_fixed_length_strings_using_chars_helper(\n        3,\n        ['c', 'a', 't'].iter().copied(),\n        &[\n            \"ccc\", \"cca\", \"cac\", \"caa\", \"acc\", \"aca\", \"aac\", \"aaa\", \"cct\", \"cat\", \"act\", \"aat\",\n            \"ctc\", \"cta\", \"atc\", \"ata\", \"ctt\", \"att\", \"tcc\", \"tca\",\n        ],\n    );\n    exhaustive_fixed_length_strings_using_chars_helper(\n        10,\n        ['c', 'a', 't'].iter().copied(),\n        &[\n            \"cccccccccc\",\n            \"ccccccccca\",\n            \"ccccccccac\",\n            \"ccccccccaa\",\n            \"cccccccacc\",\n            \"cccccccaca\",\n            \"cccccccaac\",\n            \"cccccccaaa\",\n            \"ccccccaccc\",\n            \"ccccccacca\",\n            \"ccccccacac\",\n            \"ccccccacaa\",\n            \"ccccccaacc\",\n            \"ccccccaaca\",\n            \"ccccccaaac\",\n            \"ccccccaaaa\",\n            \"cccccacccc\",\n            \"cccccaccca\",\n            \"cccccaccac\",\n            \"cccccaccaa\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/exhaustive_strings.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::exhaustive::exhaustive_strings;\n\n#[test]\nfn test_exhaustive_strings() {\n    let ss = exhaustive_strings().take(20).collect_vec();\n    assert_eq!(\n        ss.iter().map(String::as_str).collect_vec().as_slice(),\n        &[\n            \"\", \"a\", \"b\", \"aaa\", \"c\", \"aa\", \"d\", \"aaaa\", \"e\", \"ab\", \"f\", \"aab\", \"g\", \"ba\", \"h\",\n            \"aaaaa\", \"i\", \"bb\", \"j\", \"aba\"\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/exhaustive_strings_using_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::strings::exhaustive::exhaustive_strings_using_chars;\nuse std::iter::{empty, once};\n\nfn exhaustive_strings_using_chars_helper<I: Clone + Iterator<Item = char>>(cs: I, out: &[&str]) {\n    let ss = exhaustive_strings_using_chars(cs).take(20).collect_vec();\n    assert_eq!(ss.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_exhaustive_strings_using_chars() {\n    exhaustive_strings_using_chars_helper(empty(), &[\"\"]);\n    exhaustive_strings_using_chars_helper(\n        once('a'),\n        &[\n            \"\",\n            \"a\",\n            \"aa\",\n            \"aaaa\",\n            \"aaa\",\n            \"aaaaa\",\n            \"aaaaaa\",\n            \"aaaaaaaaa\",\n            \"aaaaaaa\",\n            \"aaaaaaaa\",\n            \"aaaaaaaaaa\",\n            \"aaaaaaaaaaaa\",\n            \"aaaaaaaaaaa\",\n            \"aaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaaaaa\",\n        ],\n    );\n    exhaustive_strings_using_chars_helper(\n        \"ab\".chars(),\n        &[\n            \"\", \"a\", \"b\", \"aaa\", \"aa\", \"aab\", \"ab\", \"aaaaa\", \"ba\", \"aba\", \"bb\", \"aaaa\", \"abb\",\n            \"aaab\", \"baa\", \"aaaaaaa\", \"bab\", \"aaba\", \"bba\", \"aaaab\",\n        ],\n    );\n    exhaustive_strings_using_chars_helper(\n        \"xyz\".chars(),\n        &[\n            \"\", \"x\", \"y\", \"xxx\", \"z\", \"xx\", \"xy\", \"xxxxx\", \"yx\", \"xxy\", \"yy\", \"xxxx\", \"xz\", \"xyx\",\n            \"yz\", \"xxxxxx\", \"zx\", \"xyy\", \"zy\", \"xxxy\",\n        ],\n    );\n    exhaustive_strings_using_chars_helper(\n        exhaustive_ascii_chars(),\n        &[\n            \"\", \"a\", \"b\", \"aaa\", \"c\", \"aa\", \"d\", \"aaaa\", \"e\", \"ab\", \"f\", \"aab\", \"g\", \"ba\", \"h\",\n            \"aaaaa\", \"i\", \"bb\", \"j\", \"aba\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/lex_fixed_length_strings.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::exhaustive::lex_fixed_length_strings;\n\nfn lex_fixed_length_strings_helper(len: u64, out: &[&str]) {\n    let css = lex_fixed_length_strings(len).take(20).collect_vec();\n    assert_eq!(css.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_lex_fixed_length_strings() {\n    lex_fixed_length_strings_helper(0, &[\"\"]);\n    lex_fixed_length_strings_helper(\n        1,\n        &[\n            \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\",\n            \"r\", \"s\", \"t\",\n        ],\n    );\n    lex_fixed_length_strings_helper(\n        2,\n        &[\n            \"aa\", \"ab\", \"ac\", \"ad\", \"ae\", \"af\", \"ag\", \"ah\", \"ai\", \"aj\", \"ak\", \"al\", \"am\", \"an\",\n            \"ao\", \"ap\", \"aq\", \"ar\", \"as\", \"at\",\n        ],\n    );\n    lex_fixed_length_strings_helper(\n        3,\n        &[\n            \"aaa\", \"aab\", \"aac\", \"aad\", \"aae\", \"aaf\", \"aag\", \"aah\", \"aai\", \"aaj\", \"aak\", \"aal\",\n            \"aam\", \"aan\", \"aao\", \"aap\", \"aaq\", \"aar\", \"aas\", \"aat\",\n        ],\n    );\n    lex_fixed_length_strings_helper(\n        10,\n        &[\n            \"aaaaaaaaaa\",\n            \"aaaaaaaaab\",\n            \"aaaaaaaaac\",\n            \"aaaaaaaaad\",\n            \"aaaaaaaaae\",\n            \"aaaaaaaaaf\",\n            \"aaaaaaaaag\",\n            \"aaaaaaaaah\",\n            \"aaaaaaaaai\",\n            \"aaaaaaaaaj\",\n            \"aaaaaaaaak\",\n            \"aaaaaaaaal\",\n            \"aaaaaaaaam\",\n            \"aaaaaaaaan\",\n            \"aaaaaaaaao\",\n            \"aaaaaaaaap\",\n            \"aaaaaaaaaq\",\n            \"aaaaaaaaar\",\n            \"aaaaaaaaas\",\n            \"aaaaaaaaat\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/lex_fixed_length_strings_using_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::exhaustive::lex_fixed_length_strings_using_chars;\nuse std::iter::{empty, once};\n\nfn lex_fixed_length_strings_using_chars_helper<I: Iterator<Item = char>>(\n    len: u64,\n    cs: I,\n    out: &[&str],\n) {\n    let css = lex_fixed_length_strings_using_chars(len, cs)\n        .take(20)\n        .collect_vec();\n    assert_eq!(css.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_lex_fixed_length_strings_using_chars() {\n    lex_fixed_length_strings_using_chars_helper(0, empty(), &[\"\"]);\n    lex_fixed_length_strings_using_chars_helper(1, empty(), &[]);\n    lex_fixed_length_strings_using_chars_helper(0, once('q'), &[\"\"]);\n    lex_fixed_length_strings_using_chars_helper(1, once('q'), &[\"q\"]);\n    lex_fixed_length_strings_using_chars_helper(2, once('q'), &[\"qq\"]);\n    lex_fixed_length_strings_using_chars_helper(3, once('q'), &[\"qqq\"]);\n    lex_fixed_length_strings_using_chars_helper(10, once('q'), &[\"qqqqqqqqqq\"]);\n    lex_fixed_length_strings_using_chars_helper(0, ['x', 'y'].iter().copied(), &[\"\"]);\n    lex_fixed_length_strings_using_chars_helper(1, ['x', 'y'].iter().copied(), &[\"x\", \"y\"]);\n    lex_fixed_length_strings_using_chars_helper(\n        2,\n        ['x', 'y'].iter().copied(),\n        &[\"xx\", \"xy\", \"yx\", \"yy\"],\n    );\n    lex_fixed_length_strings_using_chars_helper(\n        3,\n        ['x', 'y'].iter().copied(),\n        &[\"xxx\", \"xxy\", \"xyx\", \"xyy\", \"yxx\", \"yxy\", \"yyx\", \"yyy\"],\n    );\n    lex_fixed_length_strings_using_chars_helper(\n        10,\n        ['x', 'y'].iter().copied(),\n        &[\n            \"xxxxxxxxxx\",\n            \"xxxxxxxxxy\",\n            \"xxxxxxxxyx\",\n            \"xxxxxxxxyy\",\n            \"xxxxxxxyxx\",\n            \"xxxxxxxyxy\",\n            \"xxxxxxxyyx\",\n            \"xxxxxxxyyy\",\n            \"xxxxxxyxxx\",\n            \"xxxxxxyxxy\",\n            \"xxxxxxyxyx\",\n            \"xxxxxxyxyy\",\n            \"xxxxxxyyxx\",\n            \"xxxxxxyyxy\",\n            \"xxxxxxyyyx\",\n            \"xxxxxxyyyy\",\n            \"xxxxxyxxxx\",\n            \"xxxxxyxxxy\",\n            \"xxxxxyxxyx\",\n            \"xxxxxyxxyy\",\n        ],\n    );\n    lex_fixed_length_strings_using_chars_helper(0, ['c', 'a', 't'].iter().copied(), &[\"\"]);\n    lex_fixed_length_strings_using_chars_helper(\n        1,\n        ['c', 'a', 't'].iter().copied(),\n        &[\"c\", \"a\", \"t\"],\n    );\n    lex_fixed_length_strings_using_chars_helper(\n        2,\n        ['c', 'a', 't'].iter().copied(),\n        &[\"cc\", \"ca\", \"ct\", \"ac\", \"aa\", \"at\", \"tc\", \"ta\", \"tt\"],\n    );\n    lex_fixed_length_strings_using_chars_helper(\n        3,\n        ['c', 'a', 't'].iter().copied(),\n        &[\n            \"ccc\", \"cca\", \"cct\", \"cac\", \"caa\", \"cat\", \"ctc\", \"cta\", \"ctt\", \"acc\", \"aca\", \"act\",\n            \"aac\", \"aaa\", \"aat\", \"atc\", \"ata\", \"att\", \"tcc\", \"tca\",\n        ],\n    );\n    lex_fixed_length_strings_using_chars_helper(\n        10,\n        ['c', 'a', 't'].iter().copied(),\n        &[\n            \"cccccccccc\",\n            \"ccccccccca\",\n            \"ccccccccct\",\n            \"ccccccccac\",\n            \"ccccccccaa\",\n            \"ccccccccat\",\n            \"cccccccctc\",\n            \"ccccccccta\",\n            \"cccccccctt\",\n            \"cccccccacc\",\n            \"cccccccaca\",\n            \"cccccccact\",\n            \"cccccccaac\",\n            \"cccccccaaa\",\n            \"cccccccaat\",\n            \"cccccccatc\",\n            \"cccccccata\",\n            \"cccccccatt\",\n            \"ccccccctcc\",\n            \"ccccccctca\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/shortlex_strings.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::exhaustive::shortlex_strings;\n\n#[test]\nfn test_shortlex_strings() {\n    let ss = shortlex_strings().take(20).collect_vec();\n    assert_eq!(\n        ss.iter().map(String::as_str).collect_vec().as_slice(),\n        &[\n            \"\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\",\n            \"q\", \"r\", \"s\",\n        ]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/exhaustive/shortlex_strings_using_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::strings::exhaustive::shortlex_strings_using_chars;\nuse std::iter::{empty, once};\n\nfn shortlex_strings_using_chars_helper<I: Clone + Iterator<Item = char>>(cs: I, out: &[&str]) {\n    let ss = shortlex_strings_using_chars(cs).take(20).collect_vec();\n    assert_eq!(ss.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_shortlex_strings_using_chars() {\n    shortlex_strings_using_chars_helper(empty(), &[\"\"]);\n    shortlex_strings_using_chars_helper(\n        once('a'),\n        &[\n            \"\",\n            \"a\",\n            \"aa\",\n            \"aaa\",\n            \"aaaa\",\n            \"aaaaa\",\n            \"aaaaaa\",\n            \"aaaaaaa\",\n            \"aaaaaaaa\",\n            \"aaaaaaaaa\",\n            \"aaaaaaaaaa\",\n            \"aaaaaaaaaaa\",\n            \"aaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaaaa\",\n            \"aaaaaaaaaaaaaaaaaaa\",\n        ],\n    );\n    shortlex_strings_using_chars_helper(\n        \"ab\".chars(),\n        &[\n            \"\", \"a\", \"b\", \"aa\", \"ab\", \"ba\", \"bb\", \"aaa\", \"aab\", \"aba\", \"abb\", \"baa\", \"bab\", \"bba\",\n            \"bbb\", \"aaaa\", \"aaab\", \"aaba\", \"aabb\", \"abaa\",\n        ],\n    );\n    shortlex_strings_using_chars_helper(\n        \"xyz\".chars(),\n        &[\n            \"\", \"x\", \"y\", \"z\", \"xx\", \"xy\", \"xz\", \"yx\", \"yy\", \"yz\", \"zx\", \"zy\", \"zz\", \"xxx\", \"xxy\",\n            \"xxz\", \"xyx\", \"xyy\", \"xyz\", \"xzx\",\n        ],\n    );\n    shortlex_strings_using_chars_helper(\n        exhaustive_ascii_chars(),\n        &[\n            \"\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\",\n            \"q\", \"r\", \"s\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/random/random_fixed_length_strings.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::random::random_fixed_length_strings;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\n\nfn random_fixed_length_strings_helper(\n    len: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let ss = random_fixed_length_strings(EXAMPLE_SEED, len);\n    let values = ss.clone().take(20).collect_vec();\n    let common_values = common_values_map(1000000, 10, ss.clone());\n    let (median_lo, median_hi) = median(ss.take(1000000));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_fixed_length_strings() {\n    random_fixed_length_strings_helper(0, &[\"\"; 20], &[(\"\", 1000000)], (\"\", None));\n    random_fixed_length_strings_helper(\n        1,\n        &[\n            \"\\u{5f771}\",\n            \"\\u{87234}\",\n            \"\\u{bcd36}\",\n            \"\\u{9e195}\",\n            \"\\u{5da07}\",\n            \"\\u{36553}\",\n            \"\\u{45028}\",\n            \"\\u{1cdfd}\",\n            \"\\u{d8530}\",\n            \"\\u{c7f2e}\",\n            \"\\u{ba4bc}\",\n            \"\\u{ff677}\",\n            \"\\u{a12e2}\",\n            \"\\u{d775c}\",\n            \"\\u{f827b}\",\n            \"\\u{bdf7a}\",\n            \"簅\",\n            \"\\u{15aca}\",\n            \"\\u{4e5e2}\",\n            \"\\u{bb286}\",\n        ],\n        &[\n            (\"\\u{1e21d}\", 8),\n            (\"\\u{bd934}\", 8),\n            (\"\\u{dc941}\", 8),\n            (\"䄡\", 7),\n            (\"霜\", 7),\n            (\"\\u{ee5a}\", 7),\n            (\"𐊩\", 7),\n            (\"\\u{163a4}\", 7),\n            (\"\\u{1e7ff}\", 7),\n            (\"𣡝\", 7),\n        ],\n        (\"\\u{88629}\", Some(\"\\u{8862a}\")),\n    );\n    random_fixed_length_strings_helper(\n        2,\n        &[\n            \"\\u{5f771}\\u{87234}\",\n            \"\\u{bcd36}\\u{9e195}\",\n            \"\\u{5da07}\\u{36553}\",\n            \"\\u{45028}\\u{1cdfd}\",\n            \"\\u{d8530}\\u{c7f2e}\",\n            \"\\u{ba4bc}\\u{ff677}\",\n            \"\\u{a12e2}\\u{d775c}\",\n            \"\\u{f827b}\\u{bdf7a}\",\n            \"簅\\u{15aca}\",\n            \"\\u{4e5e2}\\u{bb286}\",\n            \"\\u{18eeb}\\u{bac4f}\",\n            \"\\u{5b55a}\\u{65709}\",\n            \"\\u{b2626}\\u{31a93}\",\n            \"\\u{8757b}\\u{b3524}\",\n            \"\\u{fcc17}\\u{32c01}\",\n            \"\\u{aada8}\\u{57e7c}\",\n            \"\\u{eb738}栨\",\n            \"\\u{51a21}\\u{ef6af}\",\n            \"\\u{b9caa}\\u{d5099}\",\n            \"\\u{e397f}\\u{32518}\",\n        ],\n        &[\n            (\"\\u{6}욵\", 1),\n            (\"\\u{19}此\", 1),\n            (\"\\u{1c}훶\", 1),\n            (\"+쳭\", 1),\n            (\">\\u{f454}\", 1),\n            (\"B韧\", 1),\n            (\"¦×\", 1),\n            (\"Ϊǔ\", 1),\n            (\"ӚĐ\", 1),\n            (\"ۥä\", 1),\n        ],\n        (\"\\u{882fd}\\u{b44d9}\", Some(\"\\u{882fe}\\u{6d6a7}\")),\n    );\n    random_fixed_length_strings_helper(\n        3,\n        &[\n            \"\\u{5f771}\\u{87234}\\u{bcd36}\",\n            \"\\u{9e195}\\u{5da07}\\u{36553}\",\n            \"\\u{45028}\\u{1cdfd}\\u{d8530}\",\n            \"\\u{c7f2e}\\u{ba4bc}\\u{ff677}\",\n            \"\\u{a12e2}\\u{d775c}\\u{f827b}\",\n            \"\\u{bdf7a}簅\\u{15aca}\",\n            \"\\u{4e5e2}\\u{bb286}\\u{18eeb}\",\n            \"\\u{bac4f}\\u{5b55a}\\u{65709}\",\n            \"\\u{b2626}\\u{31a93}\\u{8757b}\",\n            \"\\u{b3524}\\u{fcc17}\\u{32c01}\",\n            \"\\u{aada8}\\u{57e7c}\\u{eb738}\",\n            \"栨\\u{51a21}\\u{ef6af}\",\n            \"\\u{b9caa}\\u{d5099}\\u{e397f}\",\n            \"\\u{32518}\\u{6952d}\\u{93ad5}\",\n            \"\\u{65c6e}\\u{dc7bd}\\u{aec4c}\",\n            \"\\u{dd524}\\u{c0bc1}\\u{795d0}\",\n            \"\\u{dbb9d}\\u{a50fb}紐\",\n            \"\\u{4effe}\\u{794af}\\u{1b5a0}\",\n            \"\\u{56be3}\\u{78fc9}\\u{5870a}\",\n            \"\\u{106f48}\\u{dfffa}\\u{3cc01}\",\n        ],\n        &[\n            (\"\\u{19}此\\u{2f2bd}\", 1),\n            (\"(\\u{6c2b8}\\u{f70}\", 1),\n            (\"+쳭\\u{93ded}\", 1),\n            (\",\\u{e5cc2}\\u{ea33}\", 1),\n            (\"6\\u{a341e}엕\", 1),\n            (\">\\u{f454}\\u{5e168}\", 1),\n            (\"G\\u{47b77}䊹\", 1),\n            (\"K\\u{58609}\\u{e08e}\", 1),\n            (\"O┑\\u{37d86}\", 1),\n            (\"R\\u{f41e}\\u{41c45}\", 1),\n        ],\n        (\n            \"\\u{884b7}\\u{6ad70}\\u{3d86d}\",\n            Some(\"\\u{884b8}\\u{10f66a}\\u{da539}\"),\n        ),\n    );\n    random_fixed_length_strings_helper(\n        10,\n        &[\n            \"\\u{5f771}\\u{87234}\\u{bcd36}\\u{9e195}\\u{5da07}\\u{36553}\\u{45028}\\u{1cdfd}\\u{d8530}\\\n            \\u{c7f2e}\",\n            \"\\u{ba4bc}\\u{ff677}\\u{a12e2}\\u{d775c}\\u{f827b}\\u{bdf7a}簅\\u{15aca}\\u{4e5e2}\\u{bb286}\",\n            \"\\u{18eeb}\\u{bac4f}\\u{5b55a}\\u{65709}\\u{b2626}\\u{31a93}\\u{8757b}\\u{b3524}\\u{fcc17}\\\n            \\u{32c01}\",\n            \"\\u{aada8}\\u{57e7c}\\u{eb738}栨\\u{51a21}\\u{ef6af}\\u{b9caa}\\u{d5099}\\u{e397f}\\u{32518}\",\n            \"\\u{6952d}\\u{93ad5}\\u{65c6e}\\u{dc7bd}\\u{aec4c}\\u{dd524}\\u{c0bc1}\\u{795d0}\\u{dbb9d}\\\n            \\u{a50fb}\",\n            \"紐\\u{4effe}\\u{794af}\\u{1b5a0}\\u{56be3}\\u{78fc9}\\u{5870a}\\u{106f48}\\u{dfffa}\\u{3cc01}\",\n            \"\\u{91290}\\u{4628e}\\u{bee71}\\u{70e90}\\u{b48bb}\\u{3a445}\\u{10a645}𬆠\\u{e59de}\\u{61b5a}\",\n            \"\\u{f4783}\\u{c5ab2}幔\\u{fdb07}\\u{abccb}\\u{ba750}\\u{88d5a}\\u{a706e}\\u{969a2}\\u{1089e3}\",\n            \"\\u{102189}\\u{5f066}\\u{10ea66}\\u{435bb}\\u{bcbd6}\\u{4bc59}𱆞\\u{f50a0}\\u{47bc1}\\u{5fd98}\",\n            \"\\u{91a7a}\\u{100a8d}\\u{e0017}\\u{9db06}\\u{1ab04}\\u{780f6}ㅚ\\u{5fc0a}\\u{fb714}\\u{c62cd}\",\n            \"\\u{b22dc}\\u{10364e}\\u{ee477}\\u{f0983}\\u{b5c36}\\u{41f7b}\\u{bdf28}\\u{b27f7}\\u{94dc8}\\\n            \\u{73381}\",\n            \"\\u{34609}\\u{52911}\\u{e56bf}\\u{100af4}\\u{396ff}\\u{1051a8}𬅑\\u{815dc}\\u{fd1e7}\\u{e6e9c}\",\n            \"攠\\u{eceaa}\\u{10029d}\\u{5e236}\\u{d963b}\\u{bbb1a}\\u{108b67}\\u{e5bc3}\\u{97108}𢔱\",\n            \"\\u{9f166}\\u{dedb4}\\u{52752}\\u{45bf5}\\u{86d73}\\u{ff2fd}쫵\\u{78f74}\\u{93bc0}\\u{c308f}\",\n            \"\\u{e8b6}\\u{89619}\\u{1cdf9}\\u{b9c86}\\u{9f375}\\u{c2487}\\u{e1c3e}\\u{f6e29}\\u{79cc5}𬑎\",\n            \"\\u{9a803}\\u{bf22e}\\u{7e88e}\\u{c50e8}\\u{58c32}\\u{79248}𰥦\\u{b238b}\\u{104b92}\\u{8cc78}\",\n            \"\\u{eecc5}𢇡\\u{e1fb6}\\u{625ab}\\u{a1988}䮨\\u{bbaa5}\\u{143be}\\u{a12d4}\\u{1028e1}\",\n            \"\\u{1c105}\\u{9493f}\\u{efa70}\\u{13487}紋\\u{b1948}\\u{89052}\\u{8c3cb}\\u{b82d2}\\u{729c3}\",\n            \"\\u{10c5ba}\\u{dec07}𰢫\\u{d277f}\\u{3e5dc}\\u{52431}\\u{4867e}\\u{75774}𪲨\\u{b865a}\",\n            \"\\u{105191}\\u{93891}\\u{c4975}\\u{c2f58}\\u{d387c}\\u{157dd}\\u{77a83}\\u{d6eec}\\u{b2581}\\\n            \\u{9bb09}\",\n        ],\n        &[\n            (\"崕浆\\u{3da8f}뽑\\u{d3fa5}\\u{3139e}X\\u{48918}\\u{108376}♟\", 1),\n            (\"馑霸\\u{fdd49}\\u{d2b16}튞ଓ儳輋韨\\u{be78f}\", 1),\n            (\"𨟿\\u{a025e}\\u{4d531}席ےᥒ\\\"𤭉\\u{b30a9}\\u{988d4}\", 1),\n            (\n                \"\\u{c6771}\\u{c979e}᳇\\u{f4e2}能Ŷ\\u{474f6}\\u{f872}窚\\u{6ad4b}\",\n                1,\n            ),\n            (\"+쳭\\u{93ded}\\u{84fa9}㱆\\u{b3aac}곖𦸌\\u{593c4}\\u{57c2f}\", 1),\n            (\n                \"w\\u{6bb08}\\u{e8b68}\\u{f961c}\\u{c362e}\\u{2e6b}\\u{95326}\\u{7ff5b}受\\u{f715}\",\n                1,\n            ),\n            (\n                \"ȵ\\u{48470}\\u{104dcc}扞×ⴞ\\u{1ebce}\\u{1065e4}\\u{34780}\\u{46560}\",\n                1,\n            ),\n            (\"ɿ\\u{13f25}\\u{bb3ca}垾\\u{7f077}酓\\u{3f2d3}\\u{86f0b}壪床\", 1),\n            (\n                \"ӯ\\u{83676}\\u{d50cb}ꧏ\\u{f9dcd}\\u{d1466}\\u{1de8e}\\u{13bb5}搜\\u{592}\",\n                1,\n            ),\n            (\n                \"\\u{5cb}\\u{cc480}ⶺǠ\\u{95c2c}\\u{6d588}㬪𪮊\\u{147b9}\\u{d7fa9}\",\n                1,\n            ),\n        ],\n        (\n            \"\\u{880b8}\\u{7ba91}\\u{615f9}𝟂\\u{1a34d}\\u{4bb86}\\u{363e3}\\u{f113b}\\u{fada1}\\u{88aa9}\",\n            Some(\"\\u{880b8}\\u{9f3aa}\\u{d7dab}𪿾\\u{100550}\\u{fd341}𬐿鄓𬫦\\u{e718}\"),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/random/random_fixed_length_strings_using_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::random::{random_ascii_chars, random_char_inclusive_range};\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::random::random_fixed_length_strings_using_chars;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse std::iter::repeat;\n\nfn random_fixed_length_strings_using_chars_helper<I: Clone + Iterator<Item = char>>(\n    len: u64,\n    cs: I,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let ss = random_fixed_length_strings_using_chars(len, cs);\n    let values = ss.clone().take(20).collect_vec();\n    let common_values = common_values_map(1000000, 10, ss.clone());\n    let (median_lo, median_hi) = median(ss.take(1000000));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_fixed_length_strings_using_chars() {\n    random_fixed_length_strings_using_chars_helper(\n        0,\n        repeat('a'),\n        &[\"\"; 20],\n        &[(\"\", 1000000)],\n        (\"\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        1,\n        repeat('a'),\n        &[\"a\"; 20],\n        &[(\"a\", 1000000)],\n        (\"a\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        2,\n        repeat('a'),\n        &[\"aa\"; 20],\n        &[(\"aa\", 1000000)],\n        (\"aa\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        3,\n        repeat('a'),\n        &[\"aaa\"; 20],\n        &[(\"aaa\", 1000000)],\n        (\"aaa\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        10,\n        repeat('a'),\n        &[\"aaaaaaaaaa\"; 20],\n        &[(\"aaaaaaaaaa\", 1000000)],\n        (\"aaaaaaaaaa\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        1,\n        random_char_inclusive_range(EXAMPLE_SEED, 'a', 'c'),\n        &[\n            \"b\", \"a\", \"b\", \"c\", \"b\", \"b\", \"a\", \"b\", \"a\", \"c\", \"b\", \"a\", \"b\", \"c\", \"c\", \"a\", \"b\",\n            \"a\", \"c\", \"c\",\n        ],\n        &[(\"b\", 333784), (\"c\", 333516), (\"a\", 332700)],\n        (\"b\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        2,\n        random_char_inclusive_range(EXAMPLE_SEED, 'a', 'c'),\n        &[\n            \"ba\", \"bc\", \"bb\", \"ab\", \"ac\", \"ba\", \"bc\", \"ca\", \"ba\", \"cc\", \"cb\", \"ac\", \"cb\", \"bb\",\n            \"aa\", \"ca\", \"cc\", \"ba\", \"bb\", \"ac\",\n        ],\n        &[\n            (\"cb\", 111755),\n            (\"aa\", 111436),\n            (\"cc\", 111255),\n            (\"bb\", 111161),\n            (\"ab\", 111154),\n            (\"ba\", 111089),\n            (\"ca\", 110836),\n            (\"bc\", 110731),\n            (\"ac\", 110583),\n        ],\n        (\"bb\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        3,\n        random_char_inclusive_range(EXAMPLE_SEED, 'a', 'c'),\n        &[\n            \"bab\", \"cbb\", \"aba\", \"cba\", \"bcc\", \"aba\", \"ccc\", \"bac\", \"cbb\", \"baa\", \"cac\", \"cba\",\n            \"bba\", \"cca\", \"cab\", \"cbb\", \"ccb\", \"bba\", \"cab\", \"bbc\",\n        ],\n        &[\n            (\"bab\", 37526),\n            (\"ccb\", 37346),\n            (\"acb\", 37337),\n            (\"bca\", 37271),\n            (\"cbb\", 37251),\n            (\"bba\", 37211),\n            (\"aab\", 37170),\n            (\"caa\", 37142),\n            (\"bbb\", 37096),\n            (\"abc\", 37095),\n        ],\n        (\"bbb\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        10,\n        random_char_inclusive_range(EXAMPLE_SEED, 'a', 'c'),\n        &[\n            \"babcbbabac\",\n            \"babccabacc\",\n            \"cbaccbbbaa\",\n            \"caccbabbac\",\n            \"cacabcbbcc\",\n            \"bbbacabbbc\",\n            \"abbcbbbcbc\",\n            \"bbcabbbcab\",\n            \"cbaacabbbc\",\n            \"bccccccbac\",\n            \"abaacbcaba\",\n            \"bbaabcacab\",\n            \"bbabaaacbc\",\n            \"cccbccabba\",\n            \"aacabaabcc\",\n            \"acabccccab\",\n            \"bcacccaacc\",\n            \"accaccbbbc\",\n            \"aabcbaabcc\",\n            \"cbccbbbabc\",\n        ],\n        &[\n            (\"caacabbbba\", 38),\n            (\"cbaaacbaab\", 37),\n            (\"bcacbbabca\", 36),\n            (\"bcbacaabba\", 36),\n            (\"aabaaccbaa\", 35),\n            (\"abcbccaaab\", 35),\n            (\"bcbcbbbbba\", 35),\n            (\"aabccaaaca\", 34),\n            (\"abacaaabba\", 34),\n            (\"baccbabbcb\", 34),\n        ],\n        (\"bbbbbbbacc\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        1,\n        random_ascii_chars(EXAMPLE_SEED),\n        &[\n            \"q\", \"^\", \"\\u{17}\", \"b\", \"F\", \"\\\\\", \"4\", \"T\", \"!\", \"/\", \"\\u{1}\", \"q\", \"6\", \"\\n\", \"/\",\n            \"\\u{11}\", \"Y\", \"\\\\\", \"w\", \"B\",\n        ],\n        &[\n            (\"\\u{2}\", 8077),\n            (\"y\", 8039),\n            (\"0\", 8015),\n            (\"q\", 7966),\n            (\"\\u{8}\", 7937),\n            (\"M\", 7933),\n            (\"2\", 7928),\n            (\"[\", 7927),\n            (\"R\", 7925),\n            (\"f\", 7924),\n        ],\n        (\"?\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        2,\n        random_ascii_chars(EXAMPLE_SEED),\n        &[\n            \"q^\", \"\\u{17}b\", \"F\\\\\", \"4T\", \"!/\", \"\\u{1}q\", \"6\\n\", \"/\\u{11}\", \"Y\\\\\", \"wB\", \"\\\\r\",\n            \"\\\\^\", \"\\u{15}3\", \"\\'.\", \"\\'r\", \"\\u{7}$\", \"\\u{17}S\", \":\\r\", \"r@\", \"I(\",\n        ],\n        &[\n            (\"c5\", 91),\n            (\"\\u{1c} \", 90),\n            (\"GN\", 90),\n            (\"a2\", 90),\n            (\"\\u{13}%\", 89),\n            (\"o\\u{14}\", 89),\n            (\"(u\", 88),\n            (\"X2\", 88),\n            (\"\\u{10}e\", 87),\n            (\"\\u{1e}f\", 87),\n        ],\n        (\"@\\u{2}\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        3,\n        random_ascii_chars(EXAMPLE_SEED),\n        &[\n            \"q^\\u{17}\",\n            \"bF\\\\\",\n            \"4T!\",\n            \"/\\u{1}q\",\n            \"6\\n/\",\n            \"\\u{11}Y\\\\\",\n            \"wB\\\\\",\n            \"r\\\\^\",\n            \"\\u{15}3\\'\",\n            \".\\'r\",\n            \"\\u{7}$\\u{17}\",\n            \"S:\\r\",\n            \"r@I\",\n            \"(\\u{10}\\u{11}\",\n            \"}\\u{b}\\u{7}\",\n            \"0z5\",\n            \".n1\",\n            \"\\u{10}At\",\n            \"<9.\",\n            \"w\\\\?\",\n        ],\n        &[\n            (\"$7\\u{5}\", 7),\n            (\"*\\u{1c}\\u{1e}\", 7),\n            (\"\\u{e}sb\", 6),\n            (\"\\u{10}+g\", 6),\n            (\"\\u{13}`\\u{14}\", 6),\n            (\"\\u{13}oF\", 6),\n            (\"\\u{15}[[\", 6),\n            (\"\\u{1c}Ve\", 6),\n            (\"\\u{1e}<7\", 6),\n            (\"\\\"*K\", 6),\n        ],\n        (\"?}^\", None),\n    );\n    random_fixed_length_strings_using_chars_helper(\n        10,\n        random_ascii_chars(EXAMPLE_SEED),\n        &[\n            \"q^\\u{17}bF\\\\4T!/\",\n            \"\\u{1}q6\\n/\\u{11}Y\\\\wB\",\n            \"\\\\r\\\\^\\u{15}3\\'.\\'r\",\n            \"\\u{7}$\\u{17}S:\\rr@I(\",\n            \"\\u{10}\\u{11}}\\u{b}\\u{7}0z5.n\",\n            \"1\\u{10}At<9.w\\\\?\",\n            \"b\\u{15}(\\\\hJ\\u{10}cO\\\\\",\n            \"^5Edc\\u{1f}kq{t\",\n            \"=z./\\u{5}x\\u{1}dZr\",\n            \"J%\\u{5}`=VU_\\u{7f}b\",\n            \";\\u{13}\\u{6}U.k\\r\\u{6}PB\",\n            \"k]$p\\u{1a}+FOH.\",\n            \"\\r,a\\u{1}=DZZ\\u{16}\\u{18}\",\n            \"cY\\t\\u{1e}\\u{19}&<,\\u{13}%\",\n            \"\\u{c}{Z!$Z,\\u{17}\\u{8}?\",\n            \"\\u{3}\\u{4}]\\u{1}H\\u{c}(K*|\",\n            \"l\\u{15}8^:\\u{e}\\u{7f}D(P\",\n            \"\\u{1}XEk!$\\u{14}/];\",\n            \"E9d\\u{e})|v\\u{e}W*\",\n            \").\\u{19}\\u{11}5\\u{7f}b8\\u{18}:\",\n        ],\n        &[\n            (\"\\u{0}\\u{0}\\u{1})\\u{19}\\\\\\u{10};bj\", 1),\n            (\"\\u{0}\\u{0}\\u{3}\\u{7};sV\\u{e}2}\", 1),\n            (\"\\u{0}\\u{0}\\u{5}\\tmrh\\u{1f}{E\", 1),\n            (\"\\u{0}\\u{0}\\n\\n\\u{2}\\\"\\u{13}ftF\", 1),\n            (\"\\u{0}\\u{0}\\r+I^a\\u{6}>R\", 1),\n            (\"\\u{0}\\u{0}\\ry#hUV8+\", 1),\n            (\"\\u{0}\\u{0}\\u{e}\\\"^\\u{6},+\\u{10}[\", 1),\n            (\"\\u{0}\\u{0}\\u{11}J\\u{0}\\u{11}5kiy\", 1),\n            (\"\\u{0}\\u{0}\\u{12}\\u{4}txo}{7\", 1),\n            (\"\\u{0}\\u{0}\\u{13}Gb;}ex|\", 1),\n        ],\n        (\n            \"@\\u{b}\\u{c}t\\u{11}\\u{b}\\u{e}NV&\",\n            Some(\"@\\u{b}\\u{e}FN+o}X\\u{4}\"),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/random/random_strings.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::random::random_strings;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\n\nfn random_strings_helper(\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let ss = random_strings(EXAMPLE_SEED, mean_length_numerator, mean_length_denominator);\n    let values = ss.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, ss.clone());\n    let (median_lo, median_hi) = median(ss.take(1000000));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_strings() {\n    random_strings_helper(\n        4,\n        1,\n        &[\n            \"\",\n            \"\\u{81355}\\u{a331d}\\u{b707b}\\u{1354b}\\u{b16ac}𣙘\\u{67377}\\u{4aaa4}\\u{a6d6e}\\u{45616}\\\n            \\u{7725f}\\u{41e2d}\\u{d6b59}\\u{de165}\",\n            \"\\u{c2d29}\\u{695af}\\u{98fd7}\\u{10ca51}\",\n            \"\\u{bec46}\\u{c0bec}\\u{cb677}\\u{71318}\",\n            \"\\u{755e1}\",\n            \"\",\n            \"𫮜\\u{a2f84}柂\\u{f5560}\\u{6737b}\",\n            \"\\u{8442e}\\u{a6883}\",\n            \"\\u{49cf2}\\u{32d2b}\\u{1e6e5}\\u{1084bd}\",\n            \"\",\n            \"\\u{85172}\\u{103bd2}\\u{bffa3}\\u{c792c}\\u{4c421}\\u{905ef}\",\n            \"\",\n            \"\",\n            \"\\u{c0f92}匥\\u{105164}𦤃\\u{8ebb2}\\u{9e650}\\u{399cd}\\u{51328}\\u{61706}\\u{1096f6}\\\n            \\u{d9e03}\",\n            \"\\u{ac5ce}\\u{db625}\\u{f1185}\\u{f170e}\\u{b7772}\\u{dfa6f}\\u{f65d0}\\u{10c939}\",\n            \"\",\n            \"\\u{3e110}𪐛\\u{84380}\",\n            \"\",\n            \"\\u{46189}\\u{5832d}ꌍ𫁜\\u{1083cd}\",\n            \"\\u{102636}\\u{c0f80}\\u{cacb1}\\u{89486}\\u{1ad3c}𖢸\\u{b7896}\\u{3dadc}\\u{82b15}\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"姑\", 4),\n            (\"\\u{36097}\", 4),\n            (\"\\u{3d772}\", 4),\n            (\"\\u{40698}\", 4),\n            (\"\\u{6e63c}\", 4),\n            (\"\\u{7d354}\", 4),\n            (\"\\u{8465e}\", 4),\n            (\"\\u{9090b}\", 4),\n            (\"\\u{929c5}\", 4),\n        ],\n        (\n            \"\\u{667cc}\\u{850e8}\\u{42572}𪩋\\u{637c9}\\u{ef6f1}\",\n            Some(\"\\u{667cc}\\u{a3e1a}\\u{bead8}𢰏\\u{d2d0b}\"),\n        ),\n    );\n    random_strings_helper(\n        10,\n        1,\n        &[\n            \"\\u{81355}\\u{a331d}\\u{b707b}\\u{1354b}\\u{b16ac}𣙘\\u{67377}\\u{4aaa4}\\u{a6d6e}\\u{45616}\\\n            \\u{7725f}\\u{41e2d}\\u{d6b59}\\u{de165}\\u{c2d29}\\u{695af}\\u{98fd7}\\u{10ca51}\\u{bec46}\\\n            \\u{c0bec}\\u{cb677}\\u{71318}\\u{755e1}𫮜\\u{a2f84}柂\\u{f5560}\\u{6737b}\",\n            \"\\u{8442e}\\u{a6883}\\u{49cf2}\\u{32d2b}\\u{1e6e5}\\u{1084bd}\\u{85172}\\u{103bd2}\\u{bffa3}\\\n            \\u{c792c}\\u{4c421}\\u{905ef}\\u{c0f92}匥\\u{105164}𦤃\\u{8ebb2}\\u{9e650}\",\n            \"\\u{399cd}\\u{51328}\\u{61706}\\u{1096f6}\\u{d9e03}\\u{ac5ce}\\u{db625}\\u{f1185}\\u{f170e}\\\n            \\u{b7772}\\u{dfa6f}\\u{f65d0}\\u{10c939}\\u{3e110}𪐛\\u{84380}\\u{46189}\\u{5832d}ꌍ\",\n            \"𫁜\\u{1083cd}\\u{102636}\",\n            \"\\u{c0f80}\\u{cacb1}\\u{89486}\\u{1ad3c}𖢸\\u{b7896}\\u{3dadc}\\u{82b15}\\u{e01b7}\\u{53091}\\\n            \\u{eafa3}\\u{e6a8c}\",\n            \"\\u{af3e0}\",\n            \"\\u{56c4c}\\u{b06f5}\\u{76039}\\u{49cbf}\\u{103396}\\u{99695}\\u{fb2c5}\\u{1269b}\\u{d63a8}\\\n            \\u{7b2ad}\\u{62abc}\\u{426cf}\\u{917bd}\\u{3ef1e}\\u{900a7}𤧏\\u{1079f9}\\u{41860}\\u{9861d}\\\n            \\u{cbfd1}\\u{48859}\\u{5826c}\\u{b5d68}\\u{9d637}\\u{10039d}\\u{8e8d5}𡩔\\u{50c19}\\u{b9d8e}\",\n            \"\\u{f97c0}\\u{5e025}\\u{71838}\\u{bdfd5}\\u{d2042}\",\n            \"\\u{bdb07}\\u{54a51}\",\n            \"𞠮\\u{f718c}轜\\u{511f8}\\u{d45cc}\\u{cdcb6}\\u{51127}\\u{62ef1}𗛜\\u{5a889}\\u{4f824}\",\n            \"\\u{e4fc5}𛂮\\u{67155}\\u{990bb}\\u{54368}\\u{1ec21}\\u{155e9}\\u{cda02}𥵯\\u{ac392}\\u{41517}\\\n            \\u{6d7f1}\\u{101067}\\u{127d7}\\u{76266}\\u{e4c58}\\u{ba16f}\\u{50d46}\\u{69b8a}\\u{b8556}\\\n            \\u{e2a57}\\u{c71bb}\\u{b2276}\\u{db65b}\\u{72eba}\\u{9ce32}𨚕쬽\\u{b14b4}\\u{721f3}\",\n            \"\\u{e92d0}\\u{79265}\\u{3413c}\\u{8a37b}\\u{3b281}\",\n            \"\\u{1038bc}\\u{105572}\\u{60004}\\u{2f067}\",\n            \"\\u{8d937}\\u{a77ba}\\u{5cdfa}\\u{d281b}\\u{4fad0}\\u{926dd}탘\\u{589d1}\",\n            \"\\u{4c96e}\\u{31c01}\\u{d7b70}\\u{3b41a}\\u{fa158}\\u{37ba2}\\u{f7772}\\u{51268}\\u{a5a58}\\\n            \\u{6dac7}\\u{13515}\",\n            \"\\u{94c1f}\\u{72cc7}\\u{4e95e}\\u{ce473}\",\n            \"\\u{10125f}\\u{e1343}\\u{ff236}\\u{883de}凴\\u{6274f}\\u{ada6c}\\u{b0b8b}\\u{7f144}\",\n            \"𠛾\\u{72db9}\\u{a49b2}𓅹\\u{7fe45}\\u{fb3c5}\\u{86a5e}\\u{b91ae}\\u{7ef4b}\",\n            \"\\u{4e11e}\\u{48ae3}\\u{8e62a}\\u{6a125}\\u{692a6}\\u{d811f}\\u{1a0d4}\\u{70978}\\u{1b985}\\\n            \\u{d83b6}\\u{82dff}\\u{41a7f}\\u{94b31}깥\\u{87f4b}\\u{aa0ce}\\u{f6b18}⠋\\u{ded9c}𬟺\\u{10df0a}\\\n            \\u{b9982}\\u{adaaa}𠰮\\u{10db78}\",\n            \"\\u{1c15b}\",\n        ],\n        &[\n            (\"\", 90709),\n            (\"瞁\", 4),\n            (\"\\u{7cb3d}\", 4),\n            (\"\\u{844e7}\", 4),\n            (\"摄\", 3),\n            (\"覨\", 3),\n            (\"霮\", 3),\n            (\"鬻\", 3),\n            (\"뀳\", 3),\n            (\"𥛋\", 3),\n        ],\n        (\n            \"\\u{7abb9}⼥\\u{8df6b}\\u{6f616}\\u{7661d}\\u{68c62}\",\n            Some(\n                \"\\u{7abb9}\\u{6e013}\\u{10c6dc}\\u{5be7a}\\u{99103}\\u{f9c20}\\u{108e71}\\u{12917}\\\n                \\u{9f018}𥱗\",\n            ),\n        ),\n    );\n    random_strings_helper(\n        1,\n        4,\n        &[\n            \"\",\n            \"\",\n            \"\\u{81355}\",\n            \"\\u{a331d}\",\n            \"\\u{b707b}\\u{1354b}\",\n            \"\",\n            \"\",\n            \"\",\n            \"\",\n            \"\",\n            \"\",\n            \"\",\n            \"\\u{b16ac}𣙘\",\n            \"\\u{67377}\",\n            \"\",\n            \"\\u{4aaa4}\\u{a6d6e}\",\n            \"\",\n            \"\",\n            \"\",\n            \"\",\n        ],\n        &[\n            (\"\", 800023),\n            (\"\\u{4a9ab}\", 5),\n            (\"悧\", 4),\n            (\"𦹝\", 4),\n            (\"𱩖\", 4),\n            (\"\\u{1b9f0}\", 4),\n            (\"\\u{56b1b}\", 4),\n            (\"\\u{61e16}\", 4),\n            (\"\\u{8a520}\", 4),\n            (\"\\u{959f7}\", 4),\n        ],\n        (\"\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_strings_fail_1() {\n    random_strings(EXAMPLE_SEED, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_strings_fail_2() {\n    random_strings(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_strings_fail_3() {\n    random_strings(EXAMPLE_SEED, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/random/random_strings_using_chars.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::random::{random_ascii_chars, random_char_inclusive_range};\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::strings::random::random_strings_using_chars;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse std::iter::repeat;\n\nfn random_strings_using_chars_helper<I: Clone + Iterator<Item = char>>(\n    cs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let ss = random_strings_using_chars(\n        EXAMPLE_SEED,\n        cs_gen,\n        mean_length_numerator,\n        mean_length_denominator,\n    );\n    let values = ss.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, ss.clone());\n    let (median_lo, median_hi) = median(ss.take(1000000));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_strings_using_chars() {\n    random_strings_using_chars_helper(\n        &|_| repeat('a'),\n        4,\n        1,\n        &[\n            \"\",\n            \"aaaaaaaaaaaaaa\",\n            \"aaaa\",\n            \"aaaa\",\n            \"a\",\n            \"\",\n            \"aaaaa\",\n            \"aa\",\n            \"aaaa\",\n            \"\",\n            \"aaaaaa\",\n            \"\",\n            \"\",\n            \"aaaaaaaaaaa\",\n            \"aaaaaaaa\",\n            \"\",\n            \"aaa\",\n            \"\",\n            \"aaaaa\",\n            \"aaaaaaaaa\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"a\", 160173),\n            (\"aa\", 128173),\n            (\"aaa\", 102460),\n            (\"aaaa\", 81463),\n            (\"aaaaa\", 65695),\n            (\"aaaaaa\", 52495),\n            (\"aaaaaaa\", 41943),\n            (\"aaaaaaaa\", 33396),\n            (\"aaaaaaaaa\", 27035),\n        ],\n        (\"aaa\", None),\n    );\n    random_strings_using_chars_helper(\n        &|seed| random_char_inclusive_range(seed, 'a', 'c'),\n        4,\n        1,\n        &[\n            \"\",\n            \"bbbbcaaacacaca\",\n            \"cccb\",\n            \"acca\",\n            \"b\",\n            \"\",\n            \"cbcac\",\n            \"cb\",\n            \"cbba\",\n            \"\",\n            \"ccacca\",\n            \"\",\n            \"\",\n            \"acacbcccccc\",\n            \"baccbccb\",\n            \"\",\n            \"bcc\",\n            \"\",\n            \"cbbca\",\n            \"aacbaabbc\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"c\", 53448),\n            (\"a\", 53374),\n            (\"b\", 53351),\n            (\"ab\", 14396),\n            (\"aa\", 14370),\n            (\"cb\", 14345),\n            (\"cc\", 14252),\n            (\"ba\", 14240),\n            (\"ac\", 14237),\n        ],\n        (\"b\", None),\n    );\n    random_strings_using_chars_helper(\n        &random_ascii_chars,\n        4,\n        1,\n        &[\n            \"\",\n            \"U\\u{16} D<]ae_M,O\\u{1d}V\",\n            \"(\\u{10}&U\",\n            \"{P-K\",\n            \"Z\",\n            \"\",\n            \"\\u{4}X\\u{19}_,\",\n            \"\\u{1d},\",\n            \"?\\'[N\",\n            \"\",\n            \"|}*\\u{15}zt\",\n            \"\",\n            \"\",\n            \"\\u{2}FXHmX\\\\\\u{8} ZJ\",\n            \"\\u{b}\\u{14}OwV\\u{19} R\",\n            \"\",\n            \"|4\\u{e}\",\n            \"\",\n            \"M$E\\u{12}n\",\n            \"J)\\u{16}\\u{1c}\\u{11}_T\\u{1d}-\",\n        ],\n        &[\n            (\"\", 199913),\n            (\"\\u{c}\", 1334),\n            (\"~\", 1322),\n            (\"R\", 1318),\n            (\"o\", 1312),\n            (\"=\", 1310),\n            (\"\\u{1d}\", 1310),\n            (\"}\", 1308),\n            (\"\\u{10}\", 1306),\n            (\"\\u{1e}\", 1306),\n        ],\n        (\"/x\\u{b}\", Some(\"/x\\u{f}\")),\n    );\n    random_strings_using_chars_helper(\n        &random_ascii_chars,\n        1,\n        4,\n        &[\n            \"\", \"\", \"U\", \"\\u{16}\", \" D\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"<]\", \"a\", \"\", \"e_\", \"\", \"\",\n            \"\", \"\",\n        ],\n        &[\n            (\"\", 800023),\n            (\"<\", 1334),\n            (\"$\", 1329),\n            (\"\\u{b}\", 1319),\n            (\"%\", 1313),\n            (\"v\", 1309),\n            (\"A\", 1308),\n            (\"\\u{1a}\", 1308),\n            (\"d\", 1307),\n            (\"B\", 1306),\n        ],\n        (\"\", None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_strings_using_chars_fail_1() {\n    random_strings_using_chars(EXAMPLE_SEED, &random_ascii_chars, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_strings_using_chars_fail_2() {\n    random_strings_using_chars(EXAMPLE_SEED, &random_ascii_chars, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_strings_using_chars_fail_3() {\n    random_strings_using_chars(EXAMPLE_SEED, &random_ascii_chars, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/string_is_subset.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::{string_is_subset, string_sort, string_unique};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::string_pair_gen;\n\n#[test]\nfn test_string_is_subset() {\n    let test = |s, t, out| {\n        assert_eq!(string_is_subset(s, t), out);\n    };\n    test(\"\", \"Hello, world!\", true);\n    test(\"o, well\", \"Hello, world!\", true);\n    test(\"MMM\", \"Mississippi\", true);\n    test(\"Hello, World!\", \"Hello, world!\", false);\n    test(\"j\", \"Mississippi\", false);\n    test(\n        \"abcdefghijklmnopqrstuvwxyz\",\n        \"A quick brown fox jumps over the lazy dog\",\n        true,\n    );\n}\n\n#[test]\nfn string_is_subset_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_length_d\", 1);\n    string_pair_gen().test_properties_with_config(&config, |(s, t)| {\n        let is_subset = string_is_subset(&s, &t);\n        assert_eq!(\n            string_is_subset(&string_sort(&s), &string_sort(&t)),\n            is_subset\n        );\n        assert_eq!(\n            string_is_subset(&string_unique(&s), &string_unique(&t)),\n            is_subset\n        );\n        assert_eq!(\n            is_subset && string_is_subset(&t, &s),\n            string_sort(&string_unique(&s)) == string_sort(&string_unique(&t))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/string_sort.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::comparison::is_weakly_ascending;\nuse malachite_base::strings::{string_is_subset, string_sort, string_unique};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::string_gen;\n\n#[test]\nfn test_string_sort() {\n    let test = |s, out| {\n        assert_eq!(string_sort(s), out);\n    };\n    test(\"\", \"\");\n    test(\"x\", \"x\");\n    test(\"Hello, world!\", \" !,Hdellloorw\");\n    test(\"Mississippi\", \"Miiiippssss\");\n    test(\n        \"A quick brown fox jumps over the lazy dog\",\n        \"        Aabcdeefghijklmnoooopqrrstuuvwxyz\",\n    );\n}\n\n#[test]\nfn string_sort_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_length_d\", 1);\n    string_gen().test_properties_with_config(&config, |s| {\n        let t = string_sort(&s);\n        assert!(is_weakly_ascending(t.chars()));\n        assert_eq!(s.len(), t.len());\n        assert_eq!(string_sort(&t), t);\n        assert_eq!(string_unique(&t), string_sort(&string_unique(&s)));\n        assert!(string_is_subset(&s, &t));\n        assert!(string_is_subset(&t, &s));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/string_unique.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::is_unique;\nuse malachite_base::strings::{string_is_subset, string_unique};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::string_gen;\n\n#[test]\nfn test_string_unique() {\n    let test = |s, out| {\n        assert_eq!(string_unique(s), out);\n    };\n    test(\"\", \"\");\n    test(\"x\", \"x\");\n    test(\"xxxxxxxxx\", \"x\");\n    test(\"Hello, world!\", \"Helo, wrd!\");\n    test(\"Mississippi\", \"Misp\");\n    test(\n        \"A quick brown fox jumps over the lazy dog\",\n        \"A quickbrownfxjmpsvethlazydg\",\n    );\n}\n\n#[test]\nfn string_unique_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_length_d\", 1);\n    string_gen().test_properties_with_config(&config, |s| {\n        let t = string_unique(&s);\n        assert!(is_unique(t.chars()));\n        assert!(t.len() <= s.len());\n        assert_eq!(string_unique(&t), t);\n        assert!(string_is_subset(&s, &t));\n        assert!(string_is_subset(&t, &s));\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/strings_from_char_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::strings_from_char_vecs;\nuse std::iter::repeat;\n\nfn strings_from_char_vecs_helper<I: Iterator<Item = Vec<char>>>(css: I, out: &[&str]) {\n    let css = strings_from_char_vecs(css).take(20).collect_vec();\n    assert_eq!(css.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_strings_from_char_vecs() {\n    strings_from_char_vecs_helper([].iter().cloned(), &[]);\n    strings_from_char_vecs_helper([vec!['a']].iter().cloned(), &[\"a\"]);\n    strings_from_char_vecs_helper(\n        [vec!['a', 'b'], vec!['c', 'd']].iter().cloned(),\n        &[\"ab\", \"cd\"],\n    );\n    strings_from_char_vecs_helper(\n        repeat(vec!['c', 'a', 't']),\n        &[\n            \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\",\n            \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\", \"cat\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/to_binary_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToBinaryString;\n\n#[test]\npub fn test_to_binary_string() {\n    assert_eq!(5u32.to_binary_string(), \"101\");\n    assert_eq!(\n        (-5i32).to_binary_string(),\n        \"11111111111111111111111111111011\"\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/to_debug_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToDebugString;\n\n#[test]\npub fn test_to_debug_string() {\n    let empty: &[Option<bool>] = &[];\n    assert_eq!(empty.to_debug_string(), \"[]\");\n    assert_eq!([1, 2, 3].to_debug_string(), \"[1, 2, 3]\");\n    assert_eq!(\n        [vec![2, 3], vec![], vec![4]].to_debug_string(),\n        \"[[2, 3], [], [4]]\"\n    );\n    assert_eq!(Some(5).to_debug_string(), \"Some(5)\");\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/to_lower_hex_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToLowerHexString;\n\n#[test]\npub fn test_to_lower_hex_string() {\n    assert_eq!(50u32.to_lower_hex_string(), \"32\");\n    assert_eq!((-100i32).to_lower_hex_string(), \"ffffff9c\");\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/to_octal_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToOctalString;\n\n#[test]\npub fn test_to_octal_string() {\n    assert_eq!(50u32.to_octal_string(), \"62\");\n    assert_eq!((-100i32).to_octal_string(), \"37777777634\");\n}\n"
  },
  {
    "path": "malachite-base/tests/strings/to_upper_hex_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToUpperHexString;\n\n#[test]\npub fn test_to_upper_hex_string() {\n    assert_eq!(50u32.to_upper_hex_string(), \"32\");\n    assert_eq!((-100i32).to_upper_hex_string(), \"FFFFFF9C\");\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_custom_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::SAMPLE_OUTPUT_TYPES_3;\nuse crate::extra_variadic::{\n    exhaustive_triples_from_single, exhaustive_triples_xxy, exhaustive_triples_xxy_custom_output,\n    exhaustive_triples_xyx, exhaustive_triples_xyx_custom_output,\n};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::tuples::exhaustive::exhaustive_pairs;\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::once;\n\n#[allow(clippy::needless_pass_by_value)]\nfn exhaustive_triples_xxy_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[(X, X, Y)],\n) {\n    let ts = exhaustive_triples_xxy(xs.clone(), ys.clone());\n    assert_eq!(ts.clone().take(20).collect_vec(), out);\n    assert_eq!(ts.count(), out_len);\n\n    let output_types = SAMPLE_OUTPUT_TYPES_3;\n    let ts = exhaustive_triples_xxy_custom_output(\n        xs.clone(),\n        ys.clone(),\n        output_types[0][0],\n        output_types[0][1],\n        output_types[0][2],\n    );\n    let ts_prefix = ts.clone().take(20).collect_vec();\n    assert_eq!(ts_prefix.as_slice(), out);\n    assert_eq!(ts.count(), out_len);\n    for alt_output_types in &output_types[1..] {\n        let ts = exhaustive_triples_xxy_custom_output(\n            xs.clone(),\n            ys.clone(),\n            alt_output_types[0],\n            alt_output_types[1],\n            alt_output_types[2],\n        );\n        ts.clone().take(20).for_each(drop);\n        assert_eq!(ts.count(), out_len);\n    }\n}\n\n#[test]\nfn test_exhaustive_triples_xxy() {\n    exhaustive_triples_xxy_helper(nevers(), nevers(), 0, &[]);\n    exhaustive_triples_xxy_helper(nevers(), 0..4, 0, &[]);\n    exhaustive_triples_xxy_helper(once('a'), once(1), 1, &[('a', 'a', 1)]);\n    exhaustive_triples_xxy_helper(\n        once('a'),\n        0..4,\n        4,\n        &[('a', 'a', 0), ('a', 'a', 1), ('a', 'a', 2), ('a', 'a', 3)],\n    );\n    exhaustive_triples_xxy_helper(\n        exhaustive_unsigneds::<u8>(),\n        'a'..'e',\n        1 << 18,\n        &[\n            (0, 0, 'a'),\n            (0, 0, 'b'),\n            (0, 1, 'a'),\n            (0, 1, 'b'),\n            (1, 0, 'a'),\n            (1, 0, 'b'),\n            (1, 1, 'a'),\n            (1, 1, 'b'),\n            (0, 0, 'c'),\n            (0, 0, 'd'),\n            (0, 1, 'c'),\n            (0, 1, 'd'),\n            (1, 0, 'c'),\n            (1, 0, 'd'),\n            (1, 1, 'c'),\n            (1, 1, 'd'),\n            (0, 2, 'a'),\n            (0, 2, 'b'),\n            (0, 3, 'a'),\n            (0, 3, 'b'),\n        ],\n    );\n    exhaustive_triples_xxy_helper(\n        exhaustive_bools(),\n        0..4,\n        16,\n        &[\n            (false, false, 0),\n            (false, false, 1),\n            (false, true, 0),\n            (false, true, 1),\n            (true, false, 0),\n            (true, false, 1),\n            (true, true, 0),\n            (true, true, 1),\n            (false, false, 2),\n            (false, false, 3),\n            (false, true, 2),\n            (false, true, 3),\n            (true, false, 2),\n            (true, false, 3),\n            (true, true, 2),\n            (true, true, 3),\n        ],\n    );\n    exhaustive_triples_xxy_helper(\n        'a'..'f',\n        0..3,\n        75,\n        &[\n            ('a', 'a', 0),\n            ('a', 'a', 1),\n            ('a', 'b', 0),\n            ('a', 'b', 1),\n            ('b', 'a', 0),\n            ('b', 'a', 1),\n            ('b', 'b', 0),\n            ('b', 'b', 1),\n            ('a', 'a', 2),\n            ('a', 'b', 2),\n            ('b', 'a', 2),\n            ('b', 'b', 2),\n            ('a', 'c', 0),\n            ('a', 'c', 1),\n            ('a', 'd', 0),\n            ('a', 'd', 1),\n            ('b', 'c', 0),\n            ('b', 'c', 1),\n            ('b', 'd', 0),\n            ('b', 'd', 1),\n        ],\n    );\n    exhaustive_triples_xxy_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        27,\n        &[\n            ('a', 'a', Equal),\n            ('a', 'a', Less),\n            ('a', 'b', Equal),\n            ('a', 'b', Less),\n            ('b', 'a', Equal),\n            ('b', 'a', Less),\n            ('b', 'b', Equal),\n            ('b', 'b', Less),\n            ('a', 'a', Greater),\n            ('a', 'b', Greater),\n            ('b', 'a', Greater),\n            ('b', 'b', Greater),\n            ('a', 'c', Equal),\n            ('a', 'c', Less),\n            ('b', 'c', Equal),\n            ('b', 'c', Less),\n            ('a', 'c', Greater),\n            ('b', 'c', Greater),\n            ('c', 'a', Equal),\n            ('c', 'a', Less),\n        ],\n    );\n    exhaustive_triples_xxy_helper(\n        exhaustive_pairs(exhaustive_orderings(), exhaustive_bools()),\n        exhaustive_triples_from_single([Less, Greater].iter().copied()),\n        288,\n        &[\n            ((Equal, false), (Equal, false), (Less, Less, Less)),\n            ((Equal, false), (Equal, false), (Less, Less, Greater)),\n            ((Equal, false), (Equal, true), (Less, Less, Less)),\n            ((Equal, false), (Equal, true), (Less, Less, Greater)),\n            ((Equal, true), (Equal, false), (Less, Less, Less)),\n            ((Equal, true), (Equal, false), (Less, Less, Greater)),\n            ((Equal, true), (Equal, true), (Less, Less, Less)),\n            ((Equal, true), (Equal, true), (Less, Less, Greater)),\n            ((Equal, false), (Equal, false), (Less, Greater, Less)),\n            ((Equal, false), (Equal, false), (Less, Greater, Greater)),\n            ((Equal, false), (Equal, true), (Less, Greater, Less)),\n            ((Equal, false), (Equal, true), (Less, Greater, Greater)),\n            ((Equal, true), (Equal, false), (Less, Greater, Less)),\n            ((Equal, true), (Equal, false), (Less, Greater, Greater)),\n            ((Equal, true), (Equal, true), (Less, Greater, Less)),\n            ((Equal, true), (Equal, true), (Less, Greater, Greater)),\n            ((Equal, false), (Less, false), (Less, Less, Less)),\n            ((Equal, false), (Less, false), (Less, Less, Greater)),\n            ((Equal, false), (Less, true), (Less, Less, Less)),\n            ((Equal, false), (Less, true), (Less, Less, Greater)),\n        ],\n    );\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn exhaustive_triples_xyx_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[(X, Y, X)],\n) {\n    let ts = exhaustive_triples_xyx(xs.clone(), ys.clone());\n    assert_eq!(ts.clone().take(20).collect_vec(), out);\n    assert_eq!(ts.count(), out_len);\n\n    let output_types = SAMPLE_OUTPUT_TYPES_3;\n    let ts = exhaustive_triples_xyx_custom_output(\n        xs.clone(),\n        ys.clone(),\n        output_types[0][0],\n        output_types[0][1],\n        output_types[0][2],\n    );\n    let ts_prefix = ts.clone().take(20).collect_vec();\n    assert_eq!(ts_prefix.as_slice(), out);\n    assert_eq!(ts.count(), out_len);\n    for alt_output_types in &output_types[1..] {\n        let ts = exhaustive_triples_xyx_custom_output(\n            xs.clone(),\n            ys.clone(),\n            alt_output_types[0],\n            alt_output_types[1],\n            alt_output_types[2],\n        );\n        ts.clone().take(20).for_each(drop);\n        assert_eq!(ts.count(), out_len);\n    }\n}\n\n#[test]\nfn test_exhaustive_triples_xyx() {\n    exhaustive_triples_xyx_helper(nevers(), nevers(), 0, &[]);\n    exhaustive_triples_xyx_helper(nevers(), 0..4, 0, &[]);\n    exhaustive_triples_xyx_helper(once('a'), once(1), 1, &[('a', 1, 'a')]);\n    exhaustive_triples_xyx_helper(\n        once('a'),\n        0..4,\n        4,\n        &[('a', 0, 'a'), ('a', 1, 'a'), ('a', 2, 'a'), ('a', 3, 'a')],\n    );\n    exhaustive_triples_xyx_helper(\n        exhaustive_unsigneds::<u8>(),\n        'a'..'e',\n        1 << 18,\n        &[\n            (0, 'a', 0),\n            (0, 'a', 1),\n            (0, 'b', 0),\n            (0, 'b', 1),\n            (1, 'a', 0),\n            (1, 'a', 1),\n            (1, 'b', 0),\n            (1, 'b', 1),\n            (0, 'a', 2),\n            (0, 'a', 3),\n            (0, 'b', 2),\n            (0, 'b', 3),\n            (1, 'a', 2),\n            (1, 'a', 3),\n            (1, 'b', 2),\n            (1, 'b', 3),\n            (0, 'c', 0),\n            (0, 'c', 1),\n            (0, 'd', 0),\n            (0, 'd', 1),\n        ],\n    );\n    exhaustive_triples_xyx_helper(\n        exhaustive_bools(),\n        0..4,\n        16,\n        &[\n            (false, 0, false),\n            (false, 0, true),\n            (false, 1, false),\n            (false, 1, true),\n            (true, 0, false),\n            (true, 0, true),\n            (true, 1, false),\n            (true, 1, true),\n            (false, 2, false),\n            (false, 2, true),\n            (false, 3, false),\n            (false, 3, true),\n            (true, 2, false),\n            (true, 2, true),\n            (true, 3, false),\n            (true, 3, true),\n        ],\n    );\n    exhaustive_triples_xyx_helper(\n        'a'..'f',\n        0..3,\n        75,\n        &[\n            ('a', 0, 'a'),\n            ('a', 0, 'b'),\n            ('a', 1, 'a'),\n            ('a', 1, 'b'),\n            ('b', 0, 'a'),\n            ('b', 0, 'b'),\n            ('b', 1, 'a'),\n            ('b', 1, 'b'),\n            ('a', 0, 'c'),\n            ('a', 0, 'd'),\n            ('a', 1, 'c'),\n            ('a', 1, 'd'),\n            ('b', 0, 'c'),\n            ('b', 0, 'd'),\n            ('b', 1, 'c'),\n            ('b', 1, 'd'),\n            ('a', 2, 'a'),\n            ('a', 2, 'b'),\n            ('b', 2, 'a'),\n            ('b', 2, 'b'),\n        ],\n    );\n    exhaustive_triples_xyx_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        27,\n        &[\n            ('a', Equal, 'a'),\n            ('a', Equal, 'b'),\n            ('a', Less, 'a'),\n            ('a', Less, 'b'),\n            ('b', Equal, 'a'),\n            ('b', Equal, 'b'),\n            ('b', Less, 'a'),\n            ('b', Less, 'b'),\n            ('a', Equal, 'c'),\n            ('a', Less, 'c'),\n            ('b', Equal, 'c'),\n            ('b', Less, 'c'),\n            ('a', Greater, 'a'),\n            ('a', Greater, 'b'),\n            ('b', Greater, 'a'),\n            ('b', Greater, 'b'),\n            ('a', Greater, 'c'),\n            ('b', Greater, 'c'),\n            ('c', Equal, 'a'),\n            ('c', Equal, 'b'),\n        ],\n    );\n    exhaustive_triples_xyx_helper(\n        exhaustive_pairs(exhaustive_orderings(), exhaustive_bools()),\n        exhaustive_triples_from_single([Less, Greater].iter().copied()),\n        288,\n        &[\n            ((Equal, false), (Less, Less, Less), (Equal, false)),\n            ((Equal, false), (Less, Less, Less), (Equal, true)),\n            ((Equal, false), (Less, Less, Greater), (Equal, false)),\n            ((Equal, false), (Less, Less, Greater), (Equal, true)),\n            ((Equal, true), (Less, Less, Less), (Equal, false)),\n            ((Equal, true), (Less, Less, Less), (Equal, true)),\n            ((Equal, true), (Less, Less, Greater), (Equal, false)),\n            ((Equal, true), (Less, Less, Greater), (Equal, true)),\n            ((Equal, false), (Less, Less, Less), (Less, false)),\n            ((Equal, false), (Less, Less, Less), (Less, true)),\n            ((Equal, false), (Less, Less, Greater), (Less, false)),\n            ((Equal, false), (Less, Less, Greater), (Less, true)),\n            ((Equal, true), (Less, Less, Less), (Less, false)),\n            ((Equal, true), (Less, Less, Less), (Less, true)),\n            ((Equal, true), (Less, Less, Greater), (Less, false)),\n            ((Equal, true), (Less, Less, Greater), (Less, true)),\n            ((Equal, false), (Less, Greater, Less), (Equal, false)),\n            ((Equal, false), (Less, Greater, Less), (Equal, true)),\n            ((Equal, false), (Less, Greater, Greater), (Equal, false)),\n            ((Equal, false), (Less, Greater, Greater), (Equal, true)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_dependent_pairs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::{Itertools, chain};\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\nuse malachite_base::num::exhaustive::exhaustive_positive_primitive_ints;\nuse malachite_base::num::iterators::{bit_distributor_sequence, ruler_sequence};\nuse malachite_base::tuples::exhaustive::{\n    ExhaustiveDependentPairsYsGenerator, exhaustive_dependent_pairs,\n    exhaustive_dependent_pairs_stop_after_empty_ys,\n};\nuse std::collections::HashMap;\nuse std::fmt::Debug;\nuse std::iter::{Cloned, once, repeat};\nuse std::slice::Iter;\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveGeneratorFromMap<X: Clone + Eq + Hash, Y: 'static + Clone> {\n    map: HashMap<X, &'static [Y]>,\n}\n\nimpl<X: Clone + Eq + Hash, Y: 'static + Clone>\n    ExhaustiveDependentPairsYsGenerator<X, Y, Cloned<Iter<'static, Y>>>\n    for ExhaustiveGeneratorFromMap<X, Y>\n{\n    #[inline]\n    fn get_ys(&self, x: &X) -> Cloned<Iter<'static, Y>> {\n        self.map[x].iter().cloned()\n    }\n}\n\nfn exhaustive_dependent_pairs_finite_ys_helper<I: Clone + Iterator, Y>(\n    xs: I,\n    map: HashMap<I::Item, &'static [Y]>,\n    out_ruler: &[(I::Item, Y)],\n    out_normal_normal: &[(I::Item, Y)],\n    out_tiny_normal: &[(I::Item, Y)],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n    Y: Clone + Debug + Eq,\n{\n    let xss_ruler = exhaustive_dependent_pairs(\n        ruler_sequence(),\n        xs.clone(),\n        ExhaustiveGeneratorFromMap { map: map.clone() },\n    )\n    .take(20)\n    .collect_vec();\n    assert_eq!(xss_ruler.as_slice(), out_ruler);\n    let xss_normal_normal = exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        xs.clone(),\n        ExhaustiveGeneratorFromMap { map: map.clone() },\n    )\n    .take(20)\n    .collect_vec();\n    assert_eq!(xss_normal_normal.as_slice(), out_normal_normal);\n    let xss_tiny_normal = exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        ),\n        xs,\n        ExhaustiveGeneratorFromMap { map },\n    )\n    .take(20)\n    .collect_vec();\n    assert_eq!(xss_tiny_normal.as_slice(), out_tiny_normal);\n}\n\n#[test]\nfn test_exhaustive_dependent_pairs() {\n    exhaustive_dependent_pairs_finite_ys_helper(\n        [1, 2, 3].iter().copied(),\n        hashmap! {\n            1 => &[100, 101, 102][..],\n            2 => &[200, 201, 202][..],\n            3 => &[300, 301, 302][..]\n        },\n        &[(1, 100), (2, 200), (1, 101), (3, 300), (1, 102), (2, 201), (2, 202), (3, 301), (3, 302)],\n        &[(1, 100), (2, 200), (1, 101), (2, 201), (3, 300), (1, 102), (3, 301), (3, 302), (2, 202)],\n        &[(1, 100), (2, 200), (3, 300), (1, 101), (1, 102), (2, 201), (3, 301), (3, 302), (2, 202)],\n    );\n    exhaustive_dependent_pairs_finite_ys_helper(\n        [\"cat\", \"dog\", \"mouse\", \"dog\", \"cat\"].iter().copied(),\n        hashmap! { \"cat\" => &[2, 3, 4][..], \"dog\" => &[20][..], \"mouse\" => &[30, 40][..] },\n        &[\n            (\"cat\", 2),\n            (\"dog\", 20),\n            (\"cat\", 3),\n            (\"mouse\", 30),\n            (\"cat\", 4),\n            (\"mouse\", 40),\n            (\"dog\", 20),\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n        ],\n        &[\n            (\"cat\", 2),\n            (\"dog\", 20),\n            (\"cat\", 3),\n            (\"mouse\", 30),\n            (\"dog\", 20),\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n            (\"mouse\", 40),\n            (\"cat\", 4),\n        ],\n        &[\n            (\"cat\", 2),\n            (\"dog\", 20),\n            (\"mouse\", 30),\n            (\"dog\", 20),\n            (\"cat\", 3),\n            (\"mouse\", 40),\n            (\"cat\", 2),\n            (\"cat\", 4),\n            (\"cat\", 3),\n            (\"cat\", 4),\n        ],\n    );\n    exhaustive_dependent_pairs_finite_ys_helper(\n        [1, 2, 3, 2, 3, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[(1, 100), (3, 300), (1, 101), (3, 300), (1, 102), (3, 301), (3, 302), (3, 301), (3, 302)],\n        &[(1, 100), (3, 300), (1, 101), (3, 301), (3, 300), (1, 102), (3, 301), (3, 302), (3, 302)],\n        &[(1, 100), (3, 300), (3, 300), (1, 101), (1, 102), (3, 301), (3, 301), (3, 302), (3, 302)],\n    );\n    exhaustive_dependent_pairs_finite_ys_helper(\n        [].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n        &[],\n        &[],\n    );\n    exhaustive_dependent_pairs_finite_ys_helper(\n        [2, 2, 2, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n        &[],\n        &[],\n    );\n}\n\nfn exhaustive_dependent_pairs_finite_ys_stop_after_empty_ys_helper<I: Clone + Iterator, Y>(\n    xs: I,\n    map: HashMap<I::Item, &'static [Y]>,\n    out_ruler: &[(I::Item, Y)],\n    out_normal_normal: &[(I::Item, Y)],\n    out_tiny_normal: &[(I::Item, Y)],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n    Y: Clone + Debug + Eq,\n{\n    let xss_ruler = exhaustive_dependent_pairs_stop_after_empty_ys(\n        ruler_sequence(),\n        xs.clone(),\n        ExhaustiveGeneratorFromMap { map: map.clone() },\n    )\n    .take(20)\n    .collect_vec();\n    assert_eq!(xss_ruler.as_slice(), out_ruler);\n    let xss_normal_normal = exhaustive_dependent_pairs_stop_after_empty_ys(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        xs.clone(),\n        ExhaustiveGeneratorFromMap { map: map.clone() },\n    )\n    .take(20)\n    .collect_vec();\n    assert_eq!(xss_normal_normal.as_slice(), out_normal_normal);\n    let xss_tiny_normal = exhaustive_dependent_pairs_stop_after_empty_ys(\n        bit_distributor_sequence(\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        ),\n        xs,\n        ExhaustiveGeneratorFromMap { map },\n    )\n    .take(20)\n    .collect_vec();\n    assert_eq!(xss_tiny_normal.as_slice(), out_tiny_normal);\n}\n\n#[test]\nfn test_exhaustive_dependent_pairs_stop_after_empty_ys() {\n    exhaustive_dependent_pairs_finite_ys_stop_after_empty_ys_helper(\n        [1, 2, 3].iter().copied(),\n        hashmap! {\n            1 => &[100, 101, 102][..],\n            2 => &[200, 201, 202][..],\n            3 => &[300, 301, 302][..]\n        },\n        &[(1, 100), (2, 200), (1, 101), (3, 300), (1, 102), (2, 201), (2, 202), (3, 301), (3, 302)],\n        &[(1, 100), (2, 200), (1, 101), (2, 201), (3, 300), (1, 102), (3, 301), (3, 302), (2, 202)],\n        &[(1, 100), (2, 200), (3, 300), (1, 101), (1, 102), (2, 201), (3, 301), (3, 302), (2, 202)],\n    );\n    exhaustive_dependent_pairs_finite_ys_stop_after_empty_ys_helper(\n        [\"cat\", \"dog\", \"mouse\", \"dog\", \"cat\"].iter().copied(),\n        hashmap! { \"cat\" => &[2, 3, 4][..], \"dog\" => &[20][..], \"mouse\" => &[30, 40][..] },\n        &[\n            (\"cat\", 2),\n            (\"dog\", 20),\n            (\"cat\", 3),\n            (\"mouse\", 30),\n            (\"cat\", 4),\n            (\"mouse\", 40),\n            (\"dog\", 20),\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n        ],\n        &[\n            (\"cat\", 2),\n            (\"dog\", 20),\n            (\"cat\", 3),\n            (\"mouse\", 30),\n            (\"dog\", 20),\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n            (\"mouse\", 40),\n            (\"cat\", 4),\n        ],\n        &[\n            (\"cat\", 2),\n            (\"dog\", 20),\n            (\"mouse\", 30),\n            (\"dog\", 20),\n            (\"cat\", 3),\n            (\"mouse\", 40),\n            (\"cat\", 2),\n            (\"cat\", 4),\n            (\"cat\", 3),\n            (\"cat\", 4),\n        ],\n    );\n    // Notice difference from `exhaustive_dependent_pairs`\n    exhaustive_dependent_pairs_finite_ys_stop_after_empty_ys_helper(\n        [1, 2, 3, 2, 3, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[(1, 100)],\n        &[(1, 100)],\n        &[(1, 100)],\n    );\n    exhaustive_dependent_pairs_finite_ys_stop_after_empty_ys_helper(\n        [].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n        &[],\n        &[],\n    );\n    exhaustive_dependent_pairs_finite_ys_stop_after_empty_ys_helper(\n        [2, 2, 2, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n        &[],\n        &[],\n    );\n    // With `exhaustive_dependent_pairs` this would hang\n    exhaustive_dependent_pairs_finite_ys_stop_after_empty_ys_helper(\n        chain(once(3), repeat(2)),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[(3, 300)],\n        &[(3, 300)],\n        &[(3, 300)],\n    );\n}\n\n#[derive(Clone, Debug)]\nstruct MultiplesGeneratorHelper {\n    u: u64,\n    step: u64,\n}\n\nimpl Iterator for MultiplesGeneratorHelper {\n    type Item = u64;\n\n    fn next(&mut self) -> Option<u64> {\n        let next = self.u;\n        self.u += self.step;\n        Some(next)\n    }\n}\n\n#[derive(Clone, Debug)]\nstruct MultiplesGenerator {}\n\nimpl ExhaustiveDependentPairsYsGenerator<u64, u64, MultiplesGeneratorHelper>\n    for MultiplesGenerator\n{\n    #[inline]\n    fn get_ys(&self, x: &u64) -> MultiplesGeneratorHelper {\n        MultiplesGeneratorHelper { u: *x, step: *x }\n    }\n}\n\n#[test]\nfn test_exhaustive_dependent_pairs_infinite() {\n    let xs = exhaustive_positive_primitive_ints::<u64>();\n    let xss_ruler = exhaustive_dependent_pairs(ruler_sequence(), xs.clone(), MultiplesGenerator {})\n        .take(50)\n        .collect_vec();\n    assert_eq!(\n        xss_ruler.as_slice(),\n        &[\n            (1, 1),\n            (2, 2),\n            (1, 2),\n            (3, 3),\n            (1, 3),\n            (2, 4),\n            (1, 4),\n            (4, 4),\n            (1, 5),\n            (2, 6),\n            (1, 6),\n            (3, 6),\n            (1, 7),\n            (2, 8),\n            (1, 8),\n            (5, 5),\n            (1, 9),\n            (2, 10),\n            (1, 10),\n            (3, 9),\n            (1, 11),\n            (2, 12),\n            (1, 12),\n            (4, 8),\n            (1, 13),\n            (2, 14),\n            (1, 14),\n            (3, 12),\n            (1, 15),\n            (2, 16),\n            (1, 16),\n            (6, 6),\n            (1, 17),\n            (2, 18),\n            (1, 18),\n            (3, 15),\n            (1, 19),\n            (2, 20),\n            (1, 20),\n            (4, 12),\n            (1, 21),\n            (2, 22),\n            (1, 22),\n            (3, 18),\n            (1, 23),\n            (2, 24),\n            (1, 24),\n            (5, 10),\n            (1, 25),\n            (2, 26)\n        ]\n    );\n    let xss_normal_normal = exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        xs.clone(),\n        MultiplesGenerator {},\n    )\n    .take(50)\n    .collect_vec();\n    assert_eq!(\n        xss_normal_normal.as_slice(),\n        &[\n            (1, 1),\n            (2, 2),\n            (1, 2),\n            (2, 4),\n            (3, 3),\n            (4, 4),\n            (3, 6),\n            (4, 8),\n            (1, 3),\n            (2, 6),\n            (1, 4),\n            (2, 8),\n            (3, 9),\n            (4, 12),\n            (3, 12),\n            (4, 16),\n            (5, 5),\n            (6, 6),\n            (5, 10),\n            (6, 12),\n            (7, 7),\n            (8, 8),\n            (7, 14),\n            (8, 16),\n            (5, 15),\n            (6, 18),\n            (5, 20),\n            (6, 24),\n            (7, 21),\n            (8, 24),\n            (7, 28),\n            (8, 32),\n            (1, 5),\n            (2, 10),\n            (1, 6),\n            (2, 12),\n            (3, 15),\n            (4, 20),\n            (3, 18),\n            (4, 24),\n            (1, 7),\n            (2, 14),\n            (1, 8),\n            (2, 16),\n            (3, 21),\n            (4, 28),\n            (3, 24),\n            (4, 32),\n            (5, 25),\n            (6, 30)\n        ]\n    );\n    let xss_tiny_normal = exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::normal(1),\n        ),\n        xs,\n        MultiplesGenerator {},\n    )\n    .take(50)\n    .collect_vec();\n    assert_eq!(\n        xss_tiny_normal.as_slice(),\n        &[\n            (1, 1),\n            (2, 2),\n            (3, 3),\n            (4, 4),\n            (1, 2),\n            (2, 4),\n            (3, 6),\n            (4, 8),\n            (5, 5),\n            (6, 6),\n            (7, 7),\n            (8, 8),\n            (5, 10),\n            (6, 12),\n            (7, 14),\n            (8, 16),\n            (1, 3),\n            (2, 6),\n            (3, 9),\n            (4, 12),\n            (1, 4),\n            (2, 8),\n            (3, 12),\n            (4, 16),\n            (5, 15),\n            (6, 18),\n            (7, 21),\n            (8, 24),\n            (5, 20),\n            (6, 24),\n            (7, 28),\n            (8, 32),\n            (1, 5),\n            (2, 10),\n            (3, 15),\n            (4, 20),\n            (1, 6),\n            (2, 12),\n            (3, 18),\n            (4, 24),\n            (5, 25),\n            (6, 30),\n            (7, 35),\n            (8, 40),\n            (5, 30),\n            (6, 36),\n            (7, 42),\n            (8, 48),\n            (1, 7),\n            (2, 14)\n        ]\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_ordered_unique_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{\n    exhaustive_ordered_unique_quadruples, exhaustive_ordered_unique_quintuples,\n    exhaustive_ordered_unique_triples,\n};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::tuples::exhaustive::{exhaustive_ordered_unique_pairs, exhaustive_units};\nuse std::fmt::Debug;\n\nmacro_rules! helpers {\n    ($t: ty, $ts: ident, $ts_helper: ident, $ts_small_helper: ident) => {\n        fn $ts_helper<I: Iterator>(xs: I, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs).take(20).collect_vec();\n            assert_eq!(ts.as_slice(), out);\n        }\n\n        fn $ts_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs);\n            let ts_prefix = ts.clone().take(20).collect_vec();\n            assert_eq!(ts_prefix.as_slice(), out);\n            assert_eq!(ts.count(), out_len);\n        }\n    };\n}\nhelpers!(\n    (I::Item, I::Item),\n    exhaustive_ordered_unique_pairs,\n    _exhaustive_ordered_unique_pairs_helper,\n    exhaustive_ordered_unique_pairs_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item),\n    exhaustive_ordered_unique_triples,\n    exhaustive_ordered_unique_triples_helper,\n    _exhaustive_ordered_unique_triples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item),\n    exhaustive_ordered_unique_quadruples,\n    _exhaustive_ordered_unique_quadruples_helper,\n    exhaustive_ordered_unique_quadruples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    exhaustive_ordered_unique_quintuples,\n    _exhaustive_ordered_unique_quintuples_helper,\n    exhaustive_ordered_unique_quintuples_small_helper\n);\n\n#[test]\nfn test_exhaustive_ordered_unique_tuples() {\n    exhaustive_ordered_unique_pairs_small_helper(nevers(), 0, &[]);\n    exhaustive_ordered_unique_quintuples_small_helper(nevers(), 0, &[]);\n    exhaustive_ordered_unique_pairs_small_helper(exhaustive_units(), 0, &[]);\n    exhaustive_ordered_unique_quintuples_small_helper(exhaustive_units(), 0, &[]);\n    exhaustive_ordered_unique_pairs_small_helper(\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            (0, 1),\n            (0, 2),\n            (1, 2),\n            (0, 3),\n            (1, 3),\n            (2, 3),\n            (0, 4),\n            (1, 4),\n            (2, 4),\n            (3, 4),\n            (0, 5),\n            (1, 5),\n            (2, 5),\n            (3, 5),\n            (4, 5),\n            (0, 6),\n            (1, 6),\n            (2, 6),\n            (3, 6),\n            (4, 6),\n        ],\n    );\n    exhaustive_ordered_unique_triples_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 1, 2),\n            (0, 1, 3),\n            (0, 2, 3),\n            (1, 2, 3),\n            (0, 1, 4),\n            (0, 2, 4),\n            (1, 2, 4),\n            (0, 3, 4),\n            (1, 3, 4),\n            (2, 3, 4),\n            (0, 1, 5),\n            (0, 2, 5),\n            (1, 2, 5),\n            (0, 3, 5),\n            (1, 3, 5),\n            (2, 3, 5),\n            (0, 4, 5),\n            (1, 4, 5),\n            (2, 4, 5),\n            (3, 4, 5),\n        ],\n    );\n    exhaustive_ordered_unique_pairs_small_helper(\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            ('a', 'b'),\n            ('a', 'c'),\n            ('b', 'c'),\n            ('a', 'd'),\n            ('b', 'd'),\n            ('c', 'd'),\n            ('a', 'e'),\n            ('b', 'e'),\n            ('c', 'e'),\n            ('d', 'e'),\n            ('a', 'f'),\n            ('b', 'f'),\n            ('c', 'f'),\n            ('d', 'f'),\n            ('e', 'f'),\n            ('a', 'g'),\n            ('b', 'g'),\n            ('c', 'g'),\n            ('d', 'g'),\n            ('e', 'g'),\n        ],\n    );\n    exhaustive_ordered_unique_pairs_small_helper(exhaustive_bools(), 1, &[(false, true)]);\n    exhaustive_ordered_unique_quadruples_small_helper(\n        1..=6,\n        15,\n        &[\n            (1, 2, 3, 4),\n            (1, 2, 3, 5),\n            (1, 2, 4, 5),\n            (1, 3, 4, 5),\n            (2, 3, 4, 5),\n            (1, 2, 3, 6),\n            (1, 2, 4, 6),\n            (1, 3, 4, 6),\n            (2, 3, 4, 6),\n            (1, 2, 5, 6),\n            (1, 3, 5, 6),\n            (2, 3, 5, 6),\n            (1, 4, 5, 6),\n            (2, 4, 5, 6),\n            (3, 4, 5, 6),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_tuples_1_input.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::exhaustive_triples_1_input;\nuse crate::{SAMPLE_OUTPUT_TYPES_2, SAMPLE_OUTPUT_TYPES_3};\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::{exhaustive_positive_primitive_ints, exhaustive_unsigneds};\nuse malachite_base::tuples::exhaustive::exhaustive_pairs_1_input;\nuse std::fmt::Debug;\n\nfn exhaustive_pairs_1_input_helper<T, I: Clone + Iterator<Item = T>>(\n    xs: &I,\n    out_len: Option<usize>,\n    out: &[(T, T)],\n) where\n    T: Clone + Debug + Eq,\n{\n    let output_types = SAMPLE_OUTPUT_TYPES_2;\n    let ps = exhaustive_pairs_1_input(xs.clone(), output_types[0][0], output_types[0][1]);\n    assert_eq!(ps.clone().take(20).collect_vec(), out);\n    if let Some(out_len) = out_len {\n        assert_eq!(ps.count(), out_len);\n    }\n    for alt_output_types in &output_types[1..] {\n        let ps = exhaustive_pairs_1_input(xs.clone(), alt_output_types[0], alt_output_types[1]);\n        ps.clone().take(20).for_each(drop);\n        if let Some(out_len) = out_len {\n            assert_eq!(ps.count(), out_len);\n        }\n    }\n}\n\n#[test]\nfn test_exhaustive_pairs_1_input() {\n    exhaustive_pairs_1_input_helper(&nevers(), Some(0), &[]);\n    exhaustive_pairs_1_input_helper(\n        &exhaustive_unsigneds::<u8>(),\n        Some(1 << 16),\n        &[\n            (0, 0),\n            (0, 1),\n            (1, 0),\n            (1, 1),\n            (0, 2),\n            (0, 3),\n            (1, 2),\n            (1, 3),\n            (2, 0),\n            (2, 1),\n            (3, 0),\n            (3, 1),\n            (2, 2),\n            (2, 3),\n            (3, 2),\n            (3, 3),\n            (0, 4),\n            (0, 5),\n            (1, 4),\n            (1, 5),\n        ],\n    );\n    exhaustive_pairs_1_input_helper(\n        &exhaustive_positive_primitive_ints::<u64>(),\n        None,\n        &[\n            (1, 1),\n            (1, 2),\n            (2, 1),\n            (2, 2),\n            (1, 3),\n            (1, 4),\n            (2, 3),\n            (2, 4),\n            (3, 1),\n            (3, 2),\n            (4, 1),\n            (4, 2),\n            (3, 3),\n            (3, 4),\n            (4, 3),\n            (4, 4),\n            (1, 5),\n            (1, 6),\n            (2, 5),\n            (2, 6),\n        ],\n    );\n    exhaustive_pairs_1_input_helper(\n        &['x', 'y', 'z'].iter().copied(),\n        Some(9),\n        &[\n            ('x', 'x'),\n            ('x', 'y'),\n            ('y', 'x'),\n            ('y', 'y'),\n            ('x', 'z'),\n            ('y', 'z'),\n            ('z', 'x'),\n            ('z', 'y'),\n            ('z', 'z'),\n        ],\n    );\n}\n\nfn exhaustive_triples_1_input_helper<T, I: Clone + Iterator<Item = T>>(\n    xs: &I,\n    out_len: Option<usize>,\n    out: &[(T, T, T)],\n) where\n    T: Clone + Debug + Eq,\n{\n    let output_types = SAMPLE_OUTPUT_TYPES_3;\n    let ps = exhaustive_triples_1_input(\n        xs.clone(),\n        output_types[0][0],\n        output_types[0][1],\n        output_types[0][2],\n    );\n    assert_eq!(ps.clone().take(20).collect_vec(), out);\n    if let Some(out_len) = out_len {\n        assert_eq!(ps.count(), out_len);\n    }\n    for alt_output_types in &output_types[1..] {\n        let ps = exhaustive_triples_1_input(\n            xs.clone(),\n            alt_output_types[0],\n            alt_output_types[1],\n            alt_output_types[2],\n        );\n        ps.clone().take(20).for_each(drop);\n        if let Some(out_len) = out_len {\n            assert_eq!(ps.count(), out_len);\n        }\n    }\n}\n\n#[test]\nfn test_exhaustive_triples_1_input() {\n    exhaustive_triples_1_input_helper(\n        &['x', 'y', 'z'].iter().copied(),\n        Some(27),\n        &[\n            ('x', 'x', 'x'),\n            ('x', 'x', 'y'),\n            ('x', 'y', 'x'),\n            ('x', 'y', 'y'),\n            ('y', 'x', 'x'),\n            ('y', 'x', 'y'),\n            ('y', 'y', 'x'),\n            ('y', 'y', 'y'),\n            ('x', 'x', 'z'),\n            ('x', 'y', 'z'),\n            ('y', 'x', 'z'),\n            ('y', 'y', 'z'),\n            ('x', 'z', 'x'),\n            ('x', 'z', 'y'),\n            ('y', 'z', 'x'),\n            ('y', 'z', 'y'),\n            ('x', 'z', 'z'),\n            ('y', 'z', 'z'),\n            ('z', 'x', 'x'),\n            ('z', 'x', 'y'),\n        ],\n    );\n    exhaustive_triples_1_input_helper(\n        &exhaustive_ascii_chars(),\n        None,\n        &[\n            ('a', 'a', 'a'),\n            ('a', 'a', 'b'),\n            ('a', 'b', 'a'),\n            ('a', 'b', 'b'),\n            ('b', 'a', 'a'),\n            ('b', 'a', 'b'),\n            ('b', 'b', 'a'),\n            ('b', 'b', 'b'),\n            ('a', 'a', 'c'),\n            ('a', 'a', 'd'),\n            ('a', 'b', 'c'),\n            ('a', 'b', 'd'),\n            ('b', 'a', 'c'),\n            ('b', 'a', 'd'),\n            ('b', 'b', 'c'),\n            ('b', 'b', 'd'),\n            ('a', 'c', 'a'),\n            ('a', 'c', 'b'),\n            ('a', 'd', 'a'),\n            ('a', 'd', 'b'),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_tuples_custom_output.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::exhaustive_triples_from_single;\nuse crate::{SAMPLE_OUTPUT_TYPES_2, SAMPLE_OUTPUT_TYPES_3};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::options::exhaustive::exhaustive_somes;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::tuples::exhaustive::{\n    exhaustive_pairs, exhaustive_pairs_custom_output, exhaustive_pairs_from_single,\n    exhaustive_triples, exhaustive_triples_custom_output,\n};\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::once;\n\n#[allow(clippy::needless_pass_by_value)]\nfn exhaustive_pairs_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[(X, Y)],\n) {\n    let ps = exhaustive_pairs(xs.clone(), ys.clone());\n    assert_eq!(ps.clone().take(20).collect_vec(), out);\n    assert_eq!(ps.count(), out_len);\n\n    let output_types = SAMPLE_OUTPUT_TYPES_2;\n    let ps = exhaustive_pairs_custom_output(\n        xs.clone(),\n        ys.clone(),\n        output_types[0][0],\n        output_types[0][1],\n    );\n    assert_eq!(ps.clone().take(20).collect_vec(), out);\n    assert_eq!(ps.count(), out_len);\n    for alt_output_types in &output_types[1..] {\n        let ps = exhaustive_pairs_custom_output(\n            xs.clone(),\n            ys.clone(),\n            alt_output_types[0],\n            alt_output_types[1],\n        );\n        ps.clone().take(20).for_each(drop);\n        assert_eq!(ps.count(), out_len);\n    }\n}\n\n#[test]\nfn test_exhaustive_pairs_and_exhaustive_pairs_custom_output() {\n    exhaustive_pairs_helper(nevers(), nevers(), 0, &[]);\n    exhaustive_pairs_helper(nevers(), 0..4, 0, &[]);\n    exhaustive_pairs_helper(once('a'), once(1), 1, &[('a', 1)]);\n    exhaustive_pairs_helper(\n        once('a'),\n        0..4,\n        4,\n        &[('a', 0), ('a', 1), ('a', 2), ('a', 3)],\n    );\n    exhaustive_pairs_helper(\n        exhaustive_unsigneds::<u8>(),\n        'a'..'e',\n        1024,\n        &[\n            (0, 'a'),\n            (0, 'b'),\n            (1, 'a'),\n            (1, 'b'),\n            (0, 'c'),\n            (0, 'd'),\n            (1, 'c'),\n            (1, 'd'),\n            (2, 'a'),\n            (2, 'b'),\n            (3, 'a'),\n            (3, 'b'),\n            (2, 'c'),\n            (2, 'd'),\n            (3, 'c'),\n            (3, 'd'),\n            (4, 'a'),\n            (4, 'b'),\n            (5, 'a'),\n            (5, 'b'),\n        ],\n    );\n    exhaustive_pairs_helper(\n        exhaustive_bools(),\n        0..4,\n        8,\n        &[\n            (false, 0),\n            (false, 1),\n            (true, 0),\n            (true, 1),\n            (false, 2),\n            (false, 3),\n            (true, 2),\n            (true, 3),\n        ],\n    );\n    exhaustive_pairs_helper(\n        'a'..'f',\n        0..3,\n        15,\n        &[\n            ('a', 0),\n            ('a', 1),\n            ('b', 0),\n            ('b', 1),\n            ('a', 2),\n            ('b', 2),\n            ('c', 0),\n            ('c', 1),\n            ('d', 0),\n            ('d', 1),\n            ('c', 2),\n            ('d', 2),\n            ('e', 0),\n            ('e', 1),\n            ('e', 2),\n        ],\n    );\n    exhaustive_pairs_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        9,\n        &[\n            ('a', Equal),\n            ('a', Less),\n            ('b', Equal),\n            ('b', Less),\n            ('a', Greater),\n            ('b', Greater),\n            ('c', Equal),\n            ('c', Less),\n            ('c', Greater),\n        ],\n    );\n    exhaustive_pairs_helper(\n        exhaustive_pairs(exhaustive_orderings(), exhaustive_bools()),\n        exhaustive_triples_from_single([Less, Greater].iter().copied()),\n        48,\n        &[\n            ((Equal, false), (Less, Less, Less)),\n            ((Equal, false), (Less, Less, Greater)),\n            ((Equal, true), (Less, Less, Less)),\n            ((Equal, true), (Less, Less, Greater)),\n            ((Equal, false), (Less, Greater, Less)),\n            ((Equal, false), (Less, Greater, Greater)),\n            ((Equal, true), (Less, Greater, Less)),\n            ((Equal, true), (Less, Greater, Greater)),\n            ((Less, false), (Less, Less, Less)),\n            ((Less, false), (Less, Less, Greater)),\n            ((Less, true), (Less, Less, Less)),\n            ((Less, true), (Less, Less, Greater)),\n            ((Less, false), (Less, Greater, Less)),\n            ((Less, false), (Less, Greater, Greater)),\n            ((Less, true), (Less, Greater, Less)),\n            ((Less, true), (Less, Greater, Greater)),\n            ((Equal, false), (Greater, Less, Less)),\n            ((Equal, false), (Greater, Less, Greater)),\n            ((Equal, true), (Greater, Less, Less)),\n            ((Equal, true), (Greater, Less, Greater)),\n        ],\n    );\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn exhaustive_triples_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n    Z: Clone + Debug + Eq,\n    K: Clone + Iterator<Item = Z>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out_len: usize,\n    out: &[(X, Y, Z)],\n) {\n    let ts = exhaustive_triples(xs.clone(), ys.clone(), zs.clone());\n    assert_eq!(ts.clone().take(20).collect_vec(), out);\n    assert_eq!(ts.count(), out_len);\n\n    let output_types = SAMPLE_OUTPUT_TYPES_3;\n    let ts = exhaustive_triples_custom_output(\n        xs.clone(),\n        ys.clone(),\n        zs.clone(),\n        output_types[0][0],\n        output_types[0][1],\n        output_types[0][2],\n    );\n    assert_eq!(ts.clone().take(20).collect_vec(), out);\n    assert_eq!(ts.count(), out_len);\n    for alt_output_types in &output_types[1..] {\n        let ts = exhaustive_triples_custom_output(\n            xs.clone(),\n            ys.clone(),\n            zs.clone(),\n            alt_output_types[0],\n            alt_output_types[1],\n            alt_output_types[2],\n        );\n        ts.clone().take(20).for_each(drop);\n        assert_eq!(ts.count(), out_len);\n    }\n}\n\n#[test]\nfn test_exhaustive_triples_and_exhaustive_triples_custom_output() {\n    exhaustive_triples_helper(nevers(), nevers(), nevers(), 0, &[]);\n    exhaustive_triples_helper(nevers(), 0..4, 'a'..'f', 0, &[]);\n    exhaustive_triples_helper(once('a'), once(false), once(5), 1, &[('a', false, 5)]);\n    exhaustive_triples_helper(\n        once('a'),\n        once(false),\n        0..4,\n        4,\n        &[('a', false, 0), ('a', false, 1), ('a', false, 2), ('a', false, 3)],\n    );\n    exhaustive_triples_helper(\n        exhaustive_unsigneds::<u8>(),\n        exhaustive_pairs_from_single(exhaustive_bools()),\n        'a'..'e',\n        4096,\n        &[\n            (0, (false, false), 'a'),\n            (0, (false, false), 'b'),\n            (0, (false, true), 'a'),\n            (0, (false, true), 'b'),\n            (1, (false, false), 'a'),\n            (1, (false, false), 'b'),\n            (1, (false, true), 'a'),\n            (1, (false, true), 'b'),\n            (0, (false, false), 'c'),\n            (0, (false, false), 'd'),\n            (0, (false, true), 'c'),\n            (0, (false, true), 'd'),\n            (1, (false, false), 'c'),\n            (1, (false, false), 'd'),\n            (1, (false, true), 'c'),\n            (1, (false, true), 'd'),\n            (0, (true, false), 'a'),\n            (0, (true, false), 'b'),\n            (0, (true, true), 'a'),\n            (0, (true, true), 'b'),\n        ],\n    );\n    exhaustive_triples_helper(\n        exhaustive_bools(),\n        0..3,\n        'a'..'d',\n        18,\n        &[\n            (false, 0, 'a'),\n            (false, 0, 'b'),\n            (false, 1, 'a'),\n            (false, 1, 'b'),\n            (true, 0, 'a'),\n            (true, 0, 'b'),\n            (true, 1, 'a'),\n            (true, 1, 'b'),\n            (false, 0, 'c'),\n            (false, 1, 'c'),\n            (true, 0, 'c'),\n            (true, 1, 'c'),\n            (false, 2, 'a'),\n            (false, 2, 'b'),\n            (true, 2, 'a'),\n            (true, 2, 'b'),\n            (false, 2, 'c'),\n            (true, 2, 'c'),\n        ],\n    );\n    exhaustive_triples_helper(\n        0..11,\n        exhaustive_somes(0..12),\n        'a'..'n',\n        1716,\n        &[\n            (0, Some(0), 'a'),\n            (0, Some(0), 'b'),\n            (0, Some(1), 'a'),\n            (0, Some(1), 'b'),\n            (1, Some(0), 'a'),\n            (1, Some(0), 'b'),\n            (1, Some(1), 'a'),\n            (1, Some(1), 'b'),\n            (0, Some(0), 'c'),\n            (0, Some(0), 'd'),\n            (0, Some(1), 'c'),\n            (0, Some(1), 'd'),\n            (1, Some(0), 'c'),\n            (1, Some(0), 'd'),\n            (1, Some(1), 'c'),\n            (1, Some(1), 'd'),\n            (0, Some(2), 'a'),\n            (0, Some(2), 'b'),\n            (0, Some(3), 'a'),\n            (0, Some(3), 'b'),\n        ],\n    );\n    exhaustive_triples_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        [\"xx\", \"yy\", \"zz\"].iter().copied(),\n        0..3,\n        27,\n        &[\n            ('a', \"xx\", 0),\n            ('a', \"xx\", 1),\n            ('a', \"yy\", 0),\n            ('a', \"yy\", 1),\n            ('b', \"xx\", 0),\n            ('b', \"xx\", 1),\n            ('b', \"yy\", 0),\n            ('b', \"yy\", 1),\n            ('a', \"xx\", 2),\n            ('a', \"yy\", 2),\n            ('b', \"xx\", 2),\n            ('b', \"yy\", 2),\n            ('a', \"zz\", 0),\n            ('a', \"zz\", 1),\n            ('b', \"zz\", 0),\n            ('b', \"zz\", 1),\n            ('a', \"zz\", 2),\n            ('b', \"zz\", 2),\n            ('c', \"xx\", 0),\n            ('c', \"xx\", 1),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_tuples_from_single.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{\n    exhaustive_octuples_from_single, exhaustive_quadruples_from_single,\n    exhaustive_quintuples_from_single, exhaustive_triples_from_single,\n};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::tuples::exhaustive::{exhaustive_pairs_from_single, exhaustive_units};\nuse std::fmt::Debug;\n\nmacro_rules! helpers {\n    ($t: ty, $ts: ident, $ts_helper: ident, $ts_small_helper: ident) => {\n        fn $ts_helper<I: Iterator>(xs: I, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs).take(20).collect_vec();\n            assert_eq!(ts.as_slice(), out);\n        }\n\n        fn $ts_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs);\n            let ts_prefix = ts.clone().take(20).collect_vec();\n            assert_eq!(ts_prefix.as_slice(), out);\n            assert_eq!(ts.count(), out_len);\n        }\n    };\n}\nhelpers!(\n    (I::Item, I::Item),\n    exhaustive_pairs_from_single,\n    exhaustive_pairs_from_single_helper,\n    exhaustive_pairs_from_single_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item),\n    exhaustive_triples_from_single,\n    exhaustive_triples_from_single_helper,\n    _exhaustive_triples_from_single_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item),\n    exhaustive_quadruples_from_single,\n    _exhaustive_quadruples_from_single_helper,\n    exhaustive_quadruples_from_single_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    exhaustive_quintuples_from_single,\n    _exhaustive_quintuples_from_single_helper,\n    exhaustive_quintuples_from_single_small_helper\n);\nhelpers!(\n    (\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item\n    ),\n    exhaustive_octuples_from_single,\n    _exhaustive_octuples_from_single_helper,\n    exhaustive_octuples_from_single_small_helper\n);\n\n#[test]\nfn test_exhaustive_tuples_from_single() {\n    exhaustive_pairs_from_single_small_helper(nevers(), 0, &[]);\n    exhaustive_quintuples_from_single_small_helper(nevers(), 0, &[]);\n    exhaustive_pairs_from_single_small_helper(exhaustive_units(), 1, &[((), ())]);\n    exhaustive_quintuples_from_single_small_helper(exhaustive_units(), 1, &[((), (), (), (), ())]);\n    exhaustive_pairs_from_single_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 0),\n            (0, 1),\n            (1, 0),\n            (1, 1),\n            (0, 2),\n            (0, 3),\n            (1, 2),\n            (1, 3),\n            (2, 0),\n            (2, 1),\n            (3, 0),\n            (3, 1),\n            (2, 2),\n            (2, 3),\n            (3, 2),\n            (3, 3),\n            (0, 4),\n            (0, 5),\n            (1, 4),\n            (1, 5),\n        ],\n    );\n    exhaustive_triples_from_single_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 0, 0),\n            (0, 0, 1),\n            (0, 1, 0),\n            (0, 1, 1),\n            (1, 0, 0),\n            (1, 0, 1),\n            (1, 1, 0),\n            (1, 1, 1),\n            (0, 0, 2),\n            (0, 0, 3),\n            (0, 1, 2),\n            (0, 1, 3),\n            (1, 0, 2),\n            (1, 0, 3),\n            (1, 1, 2),\n            (1, 1, 3),\n            (0, 2, 0),\n            (0, 2, 1),\n            (0, 3, 0),\n            (0, 3, 1),\n        ],\n    );\n    exhaustive_pairs_from_single_small_helper(\n        exhaustive_ascii_chars(),\n        0x4000,\n        &[\n            ('a', 'a'),\n            ('a', 'b'),\n            ('b', 'a'),\n            ('b', 'b'),\n            ('a', 'c'),\n            ('a', 'd'),\n            ('b', 'c'),\n            ('b', 'd'),\n            ('c', 'a'),\n            ('c', 'b'),\n            ('d', 'a'),\n            ('d', 'b'),\n            ('c', 'c'),\n            ('c', 'd'),\n            ('d', 'c'),\n            ('d', 'd'),\n            ('a', 'e'),\n            ('a', 'f'),\n            ('b', 'e'),\n            ('b', 'f'),\n        ],\n    );\n    exhaustive_pairs_from_single_small_helper(\n        exhaustive_bools(),\n        4,\n        &[(false, false), (false, true), (true, false), (true, true)],\n    );\n    exhaustive_quadruples_from_single_small_helper(\n        exhaustive_bools(),\n        16,\n        &[\n            (false, false, false, false),\n            (false, false, false, true),\n            (false, false, true, false),\n            (false, false, true, true),\n            (false, true, false, false),\n            (false, true, false, true),\n            (false, true, true, false),\n            (false, true, true, true),\n            (true, false, false, false),\n            (true, false, false, true),\n            (true, false, true, false),\n            (true, false, true, true),\n            (true, true, false, false),\n            (true, true, false, true),\n            (true, true, true, false),\n            (true, true, true, true),\n        ],\n    );\n    exhaustive_octuples_from_single_small_helper(\n        exhaustive_bools(),\n        256,\n        &[\n            (false, false, false, false, false, false, false, false),\n            (false, false, false, false, false, false, false, true),\n            (false, false, false, false, false, false, true, false),\n            (false, false, false, false, false, false, true, true),\n            (false, false, false, false, false, true, false, false),\n            (false, false, false, false, false, true, false, true),\n            (false, false, false, false, false, true, true, false),\n            (false, false, false, false, false, true, true, true),\n            (false, false, false, false, true, false, false, false),\n            (false, false, false, false, true, false, false, true),\n            (false, false, false, false, true, false, true, false),\n            (false, false, false, false, true, false, true, true),\n            (false, false, false, false, true, true, false, false),\n            (false, false, false, false, true, true, false, true),\n            (false, false, false, false, true, true, true, false),\n            (false, false, false, false, true, true, true, true),\n            (false, false, false, true, false, false, false, false),\n            (false, false, false, true, false, false, false, true),\n            (false, false, false, true, false, false, true, false),\n            (false, false, false, true, false, false, true, true),\n        ],\n    );\n    exhaustive_octuples_from_single_small_helper(\n        0..3,\n        6561,\n        &[\n            (0, 0, 0, 0, 0, 0, 0, 0),\n            (0, 0, 0, 0, 0, 0, 0, 1),\n            (0, 0, 0, 0, 0, 0, 1, 0),\n            (0, 0, 0, 0, 0, 0, 1, 1),\n            (0, 0, 0, 0, 0, 1, 0, 0),\n            (0, 0, 0, 0, 0, 1, 0, 1),\n            (0, 0, 0, 0, 0, 1, 1, 0),\n            (0, 0, 0, 0, 0, 1, 1, 1),\n            (0, 0, 0, 0, 1, 0, 0, 0),\n            (0, 0, 0, 0, 1, 0, 0, 1),\n            (0, 0, 0, 0, 1, 0, 1, 0),\n            (0, 0, 0, 0, 1, 0, 1, 1),\n            (0, 0, 0, 0, 1, 1, 0, 0),\n            (0, 0, 0, 0, 1, 1, 0, 1),\n            (0, 0, 0, 0, 1, 1, 1, 0),\n            (0, 0, 0, 0, 1, 1, 1, 1),\n            (0, 0, 0, 1, 0, 0, 0, 0),\n            (0, 0, 0, 1, 0, 0, 0, 1),\n            (0, 0, 0, 1, 0, 0, 1, 0),\n            (0, 0, 0, 1, 0, 0, 1, 1),\n        ],\n    );\n    exhaustive_pairs_from_single_helper(\n        exhaustive_pairs_from_single(exhaustive_unsigneds::<u8>()),\n        &[\n            ((0, 0), (0, 0)),\n            ((0, 0), (0, 1)),\n            ((0, 1), (0, 0)),\n            ((0, 1), (0, 1)),\n            ((0, 0), (1, 0)),\n            ((0, 0), (1, 1)),\n            ((0, 1), (1, 0)),\n            ((0, 1), (1, 1)),\n            ((1, 0), (0, 0)),\n            ((1, 0), (0, 1)),\n            ((1, 1), (0, 0)),\n            ((1, 1), (0, 1)),\n            ((1, 0), (1, 0)),\n            ((1, 0), (1, 1)),\n            ((1, 1), (1, 0)),\n            ((1, 1), (1, 1)),\n            ((0, 0), (0, 2)),\n            ((0, 0), (0, 3)),\n            ((0, 1), (0, 2)),\n            ((0, 1), (0, 3)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_unique_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{\n    exhaustive_unique_quadruples, exhaustive_unique_quintuples, exhaustive_unique_triples,\n};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::tuples::exhaustive::{exhaustive_unique_pairs, exhaustive_units};\nuse std::fmt::Debug;\n\nmacro_rules! helpers {\n    ($t: ty, $ts: ident, $ts_helper: ident, $ts_small_helper: ident) => {\n        fn $ts_helper<I: Iterator>(xs: I, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs).take(20).collect_vec();\n            assert_eq!(ts.as_slice(), out);\n        }\n\n        fn $ts_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs);\n            let ts_prefix = ts.clone().take(20).collect_vec();\n            assert_eq!(ts_prefix.as_slice(), out);\n            assert_eq!(ts.count(), out_len);\n        }\n    };\n}\nhelpers!(\n    (I::Item, I::Item),\n    exhaustive_unique_pairs,\n    _exhaustive_unique_pairs_helper,\n    exhaustive_unique_pairs_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item),\n    exhaustive_unique_triples,\n    exhaustive_unique_triples_helper,\n    _exhaustive_unique_triples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item),\n    exhaustive_unique_quadruples,\n    _exhaustive_unique_quadruples_helper,\n    exhaustive_unique_quadruples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    exhaustive_unique_quintuples,\n    _exhaustive_unique_quintuples_helper,\n    exhaustive_unique_quintuples_small_helper\n);\n\n#[test]\nfn test_exhaustive_unique_tuples() {\n    exhaustive_unique_pairs_small_helper(nevers(), 0, &[]);\n    exhaustive_unique_quintuples_small_helper(nevers(), 0, &[]);\n    exhaustive_unique_pairs_small_helper(exhaustive_units(), 0, &[]);\n    exhaustive_unique_quintuples_small_helper(exhaustive_units(), 0, &[]);\n    exhaustive_unique_pairs_small_helper(\n        exhaustive_unsigneds::<u8>(),\n        65280,\n        &[\n            (0, 1),\n            (1, 0),\n            (0, 2),\n            (2, 0),\n            (1, 2),\n            (2, 1),\n            (0, 3),\n            (3, 0),\n            (1, 3),\n            (3, 1),\n            (2, 3),\n            (3, 2),\n            (0, 4),\n            (4, 0),\n            (1, 4),\n            (4, 1),\n            (2, 4),\n            (4, 2),\n            (3, 4),\n            (4, 3),\n        ],\n    );\n    exhaustive_unique_triples_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 1, 2),\n            (0, 1, 3),\n            (0, 2, 1),\n            (0, 2, 3),\n            (1, 0, 2),\n            (0, 3, 1),\n            (1, 2, 0),\n            (1, 2, 3),\n            (2, 0, 1),\n            (1, 0, 3),\n            (2, 1, 0),\n            (0, 3, 2),\n            (1, 3, 0),\n            (2, 0, 3),\n            (3, 0, 1),\n            (0, 2, 4),\n            (3, 1, 0),\n            (2, 3, 0),\n            (3, 0, 2),\n            (0, 1, 4),\n        ],\n    );\n    exhaustive_unique_pairs_small_helper(\n        exhaustive_ascii_chars(),\n        16256,\n        &[\n            ('a', 'b'),\n            ('b', 'a'),\n            ('a', 'c'),\n            ('c', 'a'),\n            ('b', 'c'),\n            ('c', 'b'),\n            ('a', 'd'),\n            ('d', 'a'),\n            ('b', 'd'),\n            ('d', 'b'),\n            ('c', 'd'),\n            ('d', 'c'),\n            ('a', 'e'),\n            ('e', 'a'),\n            ('b', 'e'),\n            ('e', 'b'),\n            ('c', 'e'),\n            ('e', 'c'),\n            ('d', 'e'),\n            ('e', 'd'),\n        ],\n    );\n    exhaustive_unique_pairs_small_helper(exhaustive_bools(), 2, &[(false, true), (true, false)]);\n    exhaustive_unique_quadruples_small_helper(\n        1..=6,\n        360,\n        &[\n            (1, 2, 3, 4),\n            (1, 2, 3, 5),\n            (1, 2, 4, 3),\n            (1, 2, 4, 5),\n            (1, 3, 2, 4),\n            (1, 2, 5, 3),\n            (1, 3, 4, 2),\n            (1, 3, 4, 5),\n            (1, 4, 2, 3),\n            (1, 3, 2, 5),\n            (1, 4, 3, 2),\n            (1, 2, 5, 4),\n            (2, 1, 3, 4),\n            (1, 3, 5, 2),\n            (2, 1, 4, 3),\n            (2, 3, 4, 5),\n            (2, 3, 1, 4),\n            (1, 5, 2, 3),\n            (2, 3, 4, 1),\n            (1, 4, 2, 5),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/exhaustive_units.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\n\n#[test]\nfn test_exhaustive_units() {\n    assert_eq!(exhaustive_units().collect_vec(), &[()]);\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/lex_custom_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{lex_triples_from_single, lex_triples_xxy, lex_triples_xyx};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::tuples::exhaustive::lex_pairs;\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::once;\n\nfn lex_triples_xxy_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[(X, X, Y)],\n) {\n    let ts = lex_triples_xxy(xs, ys);\n    let ts_prefix = ts.clone().take(20).collect_vec();\n    assert_eq!(ts_prefix.as_slice(), out);\n    assert_eq!(ts.count(), out_len);\n}\n\n#[test]\nfn test_lex_triples_xxy() {\n    lex_triples_xxy_helper(nevers(), nevers(), 0, &[]);\n    lex_triples_xxy_helper(nevers(), 0..4, 0, &[]);\n    lex_triples_xxy_helper(once('a'), once(1), 1, &[('a', 'a', 1)]);\n    lex_triples_xxy_helper(\n        once('a'),\n        0..4,\n        4,\n        &[('a', 'a', 0), ('a', 'a', 1), ('a', 'a', 2), ('a', 'a', 3)],\n    );\n    lex_triples_xxy_helper(\n        exhaustive_unsigneds::<u8>(),\n        'a'..'e',\n        1 << 18,\n        &[\n            (0, 0, 'a'),\n            (0, 0, 'b'),\n            (0, 0, 'c'),\n            (0, 0, 'd'),\n            (0, 1, 'a'),\n            (0, 1, 'b'),\n            (0, 1, 'c'),\n            (0, 1, 'd'),\n            (0, 2, 'a'),\n            (0, 2, 'b'),\n            (0, 2, 'c'),\n            (0, 2, 'd'),\n            (0, 3, 'a'),\n            (0, 3, 'b'),\n            (0, 3, 'c'),\n            (0, 3, 'd'),\n            (0, 4, 'a'),\n            (0, 4, 'b'),\n            (0, 4, 'c'),\n            (0, 4, 'd'),\n        ],\n    );\n    lex_triples_xxy_helper(\n        exhaustive_bools(),\n        0..4,\n        16,\n        &[\n            (false, false, 0),\n            (false, false, 1),\n            (false, false, 2),\n            (false, false, 3),\n            (false, true, 0),\n            (false, true, 1),\n            (false, true, 2),\n            (false, true, 3),\n            (true, false, 0),\n            (true, false, 1),\n            (true, false, 2),\n            (true, false, 3),\n            (true, true, 0),\n            (true, true, 1),\n            (true, true, 2),\n            (true, true, 3),\n        ],\n    );\n    lex_triples_xxy_helper(\n        'a'..'f',\n        0..3,\n        75,\n        &[\n            ('a', 'a', 0),\n            ('a', 'a', 1),\n            ('a', 'a', 2),\n            ('a', 'b', 0),\n            ('a', 'b', 1),\n            ('a', 'b', 2),\n            ('a', 'c', 0),\n            ('a', 'c', 1),\n            ('a', 'c', 2),\n            ('a', 'd', 0),\n            ('a', 'd', 1),\n            ('a', 'd', 2),\n            ('a', 'e', 0),\n            ('a', 'e', 1),\n            ('a', 'e', 2),\n            ('b', 'a', 0),\n            ('b', 'a', 1),\n            ('b', 'a', 2),\n            ('b', 'b', 0),\n            ('b', 'b', 1),\n        ],\n    );\n    lex_triples_xxy_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        27,\n        &[\n            ('a', 'a', Equal),\n            ('a', 'a', Less),\n            ('a', 'a', Greater),\n            ('a', 'b', Equal),\n            ('a', 'b', Less),\n            ('a', 'b', Greater),\n            ('a', 'c', Equal),\n            ('a', 'c', Less),\n            ('a', 'c', Greater),\n            ('b', 'a', Equal),\n            ('b', 'a', Less),\n            ('b', 'a', Greater),\n            ('b', 'b', Equal),\n            ('b', 'b', Less),\n            ('b', 'b', Greater),\n            ('b', 'c', Equal),\n            ('b', 'c', Less),\n            ('b', 'c', Greater),\n            ('c', 'a', Equal),\n            ('c', 'a', Less),\n        ],\n    );\n    lex_triples_xxy_helper(\n        lex_pairs(exhaustive_orderings(), exhaustive_bools()),\n        lex_triples_from_single([Less, Greater].iter().copied()),\n        288,\n        &[\n            ((Equal, false), (Equal, false), (Less, Less, Less)),\n            ((Equal, false), (Equal, false), (Less, Less, Greater)),\n            ((Equal, false), (Equal, false), (Less, Greater, Less)),\n            ((Equal, false), (Equal, false), (Less, Greater, Greater)),\n            ((Equal, false), (Equal, false), (Greater, Less, Less)),\n            ((Equal, false), (Equal, false), (Greater, Less, Greater)),\n            ((Equal, false), (Equal, false), (Greater, Greater, Less)),\n            ((Equal, false), (Equal, false), (Greater, Greater, Greater)),\n            ((Equal, false), (Equal, true), (Less, Less, Less)),\n            ((Equal, false), (Equal, true), (Less, Less, Greater)),\n            ((Equal, false), (Equal, true), (Less, Greater, Less)),\n            ((Equal, false), (Equal, true), (Less, Greater, Greater)),\n            ((Equal, false), (Equal, true), (Greater, Less, Less)),\n            ((Equal, false), (Equal, true), (Greater, Less, Greater)),\n            ((Equal, false), (Equal, true), (Greater, Greater, Less)),\n            ((Equal, false), (Equal, true), (Greater, Greater, Greater)),\n            ((Equal, false), (Less, false), (Less, Less, Less)),\n            ((Equal, false), (Less, false), (Less, Less, Greater)),\n            ((Equal, false), (Less, false), (Less, Greater, Less)),\n            ((Equal, false), (Less, false), (Less, Greater, Greater)),\n        ],\n    );\n}\n\nfn lex_triples_xyx_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[(X, Y, X)],\n) {\n    let ts = lex_triples_xyx(xs, ys);\n    let ts_prefix = ts.clone().take(20).collect_vec();\n    assert_eq!(ts_prefix.as_slice(), out);\n    assert_eq!(ts.count(), out_len);\n}\n\n#[test]\nfn test_lex_triples_xyx() {\n    lex_triples_xyx_helper(nevers(), nevers(), 0, &[]);\n    lex_triples_xyx_helper(nevers(), 0..4, 0, &[]);\n    lex_triples_xyx_helper(once('a'), once(1), 1, &[('a', 1, 'a')]);\n    lex_triples_xyx_helper(\n        once('a'),\n        0..4,\n        4,\n        &[('a', 0, 'a'), ('a', 1, 'a'), ('a', 2, 'a'), ('a', 3, 'a')],\n    );\n    lex_triples_xyx_helper(\n        exhaustive_unsigneds::<u8>(),\n        'a'..'e',\n        1 << 18,\n        &[\n            (0, 'a', 0),\n            (0, 'a', 1),\n            (0, 'a', 2),\n            (0, 'a', 3),\n            (0, 'a', 4),\n            (0, 'a', 5),\n            (0, 'a', 6),\n            (0, 'a', 7),\n            (0, 'a', 8),\n            (0, 'a', 9),\n            (0, 'a', 10),\n            (0, 'a', 11),\n            (0, 'a', 12),\n            (0, 'a', 13),\n            (0, 'a', 14),\n            (0, 'a', 15),\n            (0, 'a', 16),\n            (0, 'a', 17),\n            (0, 'a', 18),\n            (0, 'a', 19),\n        ],\n    );\n    lex_triples_xyx_helper(\n        exhaustive_bools(),\n        0..4,\n        16,\n        &[\n            (false, 0, false),\n            (false, 0, true),\n            (false, 1, false),\n            (false, 1, true),\n            (false, 2, false),\n            (false, 2, true),\n            (false, 3, false),\n            (false, 3, true),\n            (true, 0, false),\n            (true, 0, true),\n            (true, 1, false),\n            (true, 1, true),\n            (true, 2, false),\n            (true, 2, true),\n            (true, 3, false),\n            (true, 3, true),\n        ],\n    );\n    lex_triples_xyx_helper(\n        'a'..'f',\n        0..3,\n        75,\n        &[\n            ('a', 0, 'a'),\n            ('a', 0, 'b'),\n            ('a', 0, 'c'),\n            ('a', 0, 'd'),\n            ('a', 0, 'e'),\n            ('a', 1, 'a'),\n            ('a', 1, 'b'),\n            ('a', 1, 'c'),\n            ('a', 1, 'd'),\n            ('a', 1, 'e'),\n            ('a', 2, 'a'),\n            ('a', 2, 'b'),\n            ('a', 2, 'c'),\n            ('a', 2, 'd'),\n            ('a', 2, 'e'),\n            ('b', 0, 'a'),\n            ('b', 0, 'b'),\n            ('b', 0, 'c'),\n            ('b', 0, 'd'),\n            ('b', 0, 'e'),\n        ],\n    );\n    lex_triples_xyx_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        27,\n        &[\n            ('a', Equal, 'a'),\n            ('a', Equal, 'b'),\n            ('a', Equal, 'c'),\n            ('a', Less, 'a'),\n            ('a', Less, 'b'),\n            ('a', Less, 'c'),\n            ('a', Greater, 'a'),\n            ('a', Greater, 'b'),\n            ('a', Greater, 'c'),\n            ('b', Equal, 'a'),\n            ('b', Equal, 'b'),\n            ('b', Equal, 'c'),\n            ('b', Less, 'a'),\n            ('b', Less, 'b'),\n            ('b', Less, 'c'),\n            ('b', Greater, 'a'),\n            ('b', Greater, 'b'),\n            ('b', Greater, 'c'),\n            ('c', Equal, 'a'),\n            ('c', Equal, 'b'),\n        ],\n    );\n    lex_triples_xyx_helper(\n        lex_pairs(exhaustive_orderings(), exhaustive_bools()),\n        lex_triples_from_single([Less, Greater].iter().copied()),\n        288,\n        &[\n            ((Equal, false), (Less, Less, Less), (Equal, false)),\n            ((Equal, false), (Less, Less, Less), (Equal, true)),\n            ((Equal, false), (Less, Less, Less), (Less, false)),\n            ((Equal, false), (Less, Less, Less), (Less, true)),\n            ((Equal, false), (Less, Less, Less), (Greater, false)),\n            ((Equal, false), (Less, Less, Less), (Greater, true)),\n            ((Equal, false), (Less, Less, Greater), (Equal, false)),\n            ((Equal, false), (Less, Less, Greater), (Equal, true)),\n            ((Equal, false), (Less, Less, Greater), (Less, false)),\n            ((Equal, false), (Less, Less, Greater), (Less, true)),\n            ((Equal, false), (Less, Less, Greater), (Greater, false)),\n            ((Equal, false), (Less, Less, Greater), (Greater, true)),\n            ((Equal, false), (Less, Greater, Less), (Equal, false)),\n            ((Equal, false), (Less, Greater, Less), (Equal, true)),\n            ((Equal, false), (Less, Greater, Less), (Less, false)),\n            ((Equal, false), (Less, Greater, Less), (Less, true)),\n            ((Equal, false), (Less, Greater, Less), (Greater, false)),\n            ((Equal, false), (Less, Greater, Less), (Greater, true)),\n            ((Equal, false), (Less, Greater, Greater), (Equal, false)),\n            ((Equal, false), (Less, Greater, Greater), (Equal, true)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/lex_dependent_pairs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::{Itertools, chain};\nuse malachite_base::tuples::exhaustive::{\n    ExhaustiveDependentPairsYsGenerator, lex_dependent_pairs,\n    lex_dependent_pairs_stop_after_empty_ys,\n};\nuse std::collections::HashMap;\nuse std::fmt::Debug;\nuse std::iter::{Cloned, once, repeat};\nuse std::slice::Iter;\n\n#[derive(Clone, Debug)]\nstruct DPGeneratorFromMap<X: Clone + Eq + Hash, Y: 'static + Clone> {\n    map: HashMap<X, &'static [Y]>,\n}\n\nimpl<X: Clone + Eq + Hash, Y: 'static + Clone>\n    ExhaustiveDependentPairsYsGenerator<X, Y, Cloned<Iter<'static, Y>>>\n    for DPGeneratorFromMap<X, Y>\n{\n    #[inline]\n    fn get_ys(&self, x: &X) -> Cloned<Iter<'static, Y>> {\n        self.map[x].iter().cloned()\n    }\n}\n\nfn lex_dependent_pairs_helper<I: Iterator, Y>(\n    xs: I,\n    map: HashMap<I::Item, &'static [Y]>,\n    out: &[(I::Item, Y)],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n    Y: Clone + Debug + Eq,\n{\n    let xss = lex_dependent_pairs(xs, DPGeneratorFromMap { map })\n        .take(20)\n        .collect_vec();\n    assert_eq!(xss.as_slice(), out);\n}\n\n#[test]\nfn test_lex_dependent_pairs() {\n    lex_dependent_pairs_helper(\n        [1, 2, 3].iter().copied(),\n        hashmap! {\n            1 => &[100, 101, 102][..],\n            2 => &[200, 201, 202][..],\n            3 => &[300, 301, 302][..]\n        },\n        &[(1, 100), (1, 101), (1, 102), (2, 200), (2, 201), (2, 202), (3, 300), (3, 301), (3, 302)],\n    );\n    lex_dependent_pairs_helper(\n        [\"cat\", \"dog\", \"mouse\", \"dog\", \"cat\"].iter().copied(),\n        hashmap! { \"cat\" => &[2, 3, 4][..], \"dog\" => &[20][..], \"mouse\" => &[30, 40][..] },\n        &[\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n            (\"dog\", 20),\n            (\"mouse\", 30),\n            (\"mouse\", 40),\n            (\"dog\", 20),\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n        ],\n    );\n    lex_dependent_pairs_helper(\n        [1, 2, 3, 2, 3, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[(1, 100), (1, 101), (1, 102), (3, 300), (3, 301), (3, 302), (3, 300), (3, 301), (3, 302)],\n    );\n    lex_dependent_pairs_helper(\n        [].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n    );\n    lex_dependent_pairs_helper(\n        [2, 2, 2, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n    );\n}\n\nfn lex_dependent_pairs_stop_after_empty_ys_helper<I: Iterator, Y>(\n    xs: I,\n    map: HashMap<I::Item, &'static [Y]>,\n    out: &[(I::Item, Y)],\n) where\n    I::Item: Clone + Debug + Eq + Hash,\n    Y: Clone + Debug + Eq,\n{\n    let xss = lex_dependent_pairs_stop_after_empty_ys(xs, DPGeneratorFromMap { map })\n        .take(20)\n        .collect_vec();\n    assert_eq!(xss.as_slice(), out);\n}\n\n#[test]\nfn test_lex_dependent_pairs_stop_after_empty_ys() {\n    lex_dependent_pairs_stop_after_empty_ys_helper(\n        [1, 2, 3].iter().copied(),\n        hashmap! {\n            1 => &[100, 101, 102][..],\n            2 => &[200, 201, 202][..],\n            3 => &[300, 301, 302][..]\n        },\n        &[(1, 100), (1, 101), (1, 102), (2, 200), (2, 201), (2, 202), (3, 300), (3, 301), (3, 302)],\n    );\n    lex_dependent_pairs_stop_after_empty_ys_helper(\n        [\"cat\", \"dog\", \"mouse\", \"dog\", \"cat\"].iter().copied(),\n        hashmap! { \"cat\" => &[2, 3, 4][..], \"dog\" => &[20][..], \"mouse\" => &[30, 40][..] },\n        &[\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n            (\"dog\", 20),\n            (\"mouse\", 30),\n            (\"mouse\", 40),\n            (\"dog\", 20),\n            (\"cat\", 2),\n            (\"cat\", 3),\n            (\"cat\", 4),\n        ],\n    );\n    // Notice difference from `lex_dependent_pairs`\n    lex_dependent_pairs_stop_after_empty_ys_helper(\n        [1, 2, 3, 2, 3, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[(1, 100), (1, 101), (1, 102)],\n    );\n    lex_dependent_pairs_stop_after_empty_ys_helper(\n        [].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n    );\n    lex_dependent_pairs_stop_after_empty_ys_helper(\n        [2, 2, 2, 2, 2].iter().copied(),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[],\n    );\n    // With `lex_dependent_pairs` this would hang\n    lex_dependent_pairs_stop_after_empty_ys_helper(\n        chain(once(3), repeat(2)),\n        hashmap! { 1 => &[100, 101, 102][..], 2 => &[][..], 3 => &[300, 301, 302][..] },\n        &[(3, 300), (3, 301), (3, 302)],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/lex_ordered_unique_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{\n    lex_ordered_unique_quadruples, lex_ordered_unique_quintuples, lex_ordered_unique_triples,\n};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::tuples::exhaustive::{exhaustive_units, lex_ordered_unique_pairs};\nuse std::fmt::Debug;\n\nmacro_rules! helpers {\n    ($t: ty, $ts: ident, $ts_helper: ident, $ts_small_helper: ident) => {\n        fn $ts_helper<I: Iterator>(xs: I, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs).take(20).collect_vec();\n            assert_eq!(ts.as_slice(), out);\n        }\n\n        fn $ts_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs);\n            let ts_prefix = ts.clone().take(20).collect_vec();\n            assert_eq!(ts_prefix.as_slice(), out);\n            assert_eq!(ts.count(), out_len);\n        }\n    };\n}\nhelpers!(\n    (I::Item, I::Item),\n    lex_ordered_unique_pairs,\n    _lex_ordered_unique_pairs_helper,\n    lex_ordered_unique_pairs_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item),\n    lex_ordered_unique_triples,\n    lex_ordered_unique_triples_helper,\n    _lex_ordered_unique_triples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item),\n    lex_ordered_unique_quadruples,\n    _lex_ordered_unique_quadruples_helper,\n    lex_ordered_unique_quadruples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    lex_ordered_unique_quintuples,\n    _lex_ordered_unique_quintuples_helper,\n    lex_ordered_unique_quintuples_small_helper\n);\n\n#[test]\nfn test_lex_ordered_unique_tuples() {\n    lex_ordered_unique_pairs_small_helper(nevers(), 0, &[]);\n    lex_ordered_unique_quintuples_small_helper(nevers(), 0, &[]);\n    lex_ordered_unique_pairs_small_helper(exhaustive_units(), 0, &[]);\n    lex_ordered_unique_quintuples_small_helper(exhaustive_units(), 0, &[]);\n    lex_ordered_unique_pairs_small_helper(\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            (0, 1),\n            (0, 2),\n            (0, 3),\n            (0, 4),\n            (0, 5),\n            (0, 6),\n            (0, 7),\n            (0, 8),\n            (0, 9),\n            (0, 10),\n            (0, 11),\n            (0, 12),\n            (0, 13),\n            (0, 14),\n            (0, 15),\n            (0, 16),\n            (0, 17),\n            (0, 18),\n            (0, 19),\n            (0, 20),\n        ],\n    );\n    lex_ordered_unique_triples_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 1, 2),\n            (0, 1, 3),\n            (0, 1, 4),\n            (0, 1, 5),\n            (0, 1, 6),\n            (0, 1, 7),\n            (0, 1, 8),\n            (0, 1, 9),\n            (0, 1, 10),\n            (0, 1, 11),\n            (0, 1, 12),\n            (0, 1, 13),\n            (0, 1, 14),\n            (0, 1, 15),\n            (0, 1, 16),\n            (0, 1, 17),\n            (0, 1, 18),\n            (0, 1, 19),\n            (0, 1, 20),\n            (0, 1, 21),\n        ],\n    );\n    lex_ordered_unique_pairs_small_helper(\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            ('a', 'b'),\n            ('a', 'c'),\n            ('a', 'd'),\n            ('a', 'e'),\n            ('a', 'f'),\n            ('a', 'g'),\n            ('a', 'h'),\n            ('a', 'i'),\n            ('a', 'j'),\n            ('a', 'k'),\n            ('a', 'l'),\n            ('a', 'm'),\n            ('a', 'n'),\n            ('a', 'o'),\n            ('a', 'p'),\n            ('a', 'q'),\n            ('a', 'r'),\n            ('a', 's'),\n            ('a', 't'),\n            ('a', 'u'),\n        ],\n    );\n    lex_ordered_unique_pairs_small_helper(exhaustive_bools(), 1, &[(false, true)]);\n    lex_ordered_unique_quadruples_small_helper(\n        1..=6,\n        15,\n        &[\n            (1, 2, 3, 4),\n            (1, 2, 3, 5),\n            (1, 2, 3, 6),\n            (1, 2, 4, 5),\n            (1, 2, 4, 6),\n            (1, 2, 5, 6),\n            (1, 3, 4, 5),\n            (1, 3, 4, 6),\n            (1, 3, 5, 6),\n            (1, 4, 5, 6),\n            (2, 3, 4, 5),\n            (2, 3, 4, 6),\n            (2, 3, 5, 6),\n            (2, 4, 5, 6),\n            (3, 4, 5, 6),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/lex_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{lex_triples, lex_triples_from_single};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::options::exhaustive::exhaustive_somes;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::tuples::exhaustive::{lex_pairs, lex_pairs_from_single};\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::once;\n\nfn lex_pairs_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[(X, Y)],\n) {\n    let ps = lex_pairs(xs, ys);\n    let ps_prefix = ps.clone().take(20).collect_vec();\n    assert_eq!(ps_prefix.as_slice(), out);\n    assert_eq!(ps.count(), out_len);\n}\n\n#[test]\nfn test_lex_pairs() {\n    lex_pairs_helper(nevers(), nevers(), 0, &[]);\n    lex_pairs_helper(nevers(), 0..4, 0, &[]);\n    lex_pairs_helper(once('a'), once(1), 1, &[('a', 1)]);\n    lex_pairs_helper(\n        once('a'),\n        0..4,\n        4,\n        &[('a', 0), ('a', 1), ('a', 2), ('a', 3)],\n    );\n    lex_pairs_helper(\n        exhaustive_unsigneds::<u8>(),\n        'a'..'e',\n        1024,\n        &[\n            (0, 'a'),\n            (0, 'b'),\n            (0, 'c'),\n            (0, 'd'),\n            (1, 'a'),\n            (1, 'b'),\n            (1, 'c'),\n            (1, 'd'),\n            (2, 'a'),\n            (2, 'b'),\n            (2, 'c'),\n            (2, 'd'),\n            (3, 'a'),\n            (3, 'b'),\n            (3, 'c'),\n            (3, 'd'),\n            (4, 'a'),\n            (4, 'b'),\n            (4, 'c'),\n            (4, 'd'),\n        ],\n    );\n    lex_pairs_helper(\n        exhaustive_bools(),\n        0..4,\n        8,\n        &[\n            (false, 0),\n            (false, 1),\n            (false, 2),\n            (false, 3),\n            (true, 0),\n            (true, 1),\n            (true, 2),\n            (true, 3),\n        ],\n    );\n    lex_pairs_helper(\n        'a'..'f',\n        0..3,\n        15,\n        &[\n            ('a', 0),\n            ('a', 1),\n            ('a', 2),\n            ('b', 0),\n            ('b', 1),\n            ('b', 2),\n            ('c', 0),\n            ('c', 1),\n            ('c', 2),\n            ('d', 0),\n            ('d', 1),\n            ('d', 2),\n            ('e', 0),\n            ('e', 1),\n            ('e', 2),\n        ],\n    );\n    lex_pairs_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        9,\n        &[\n            ('a', Equal),\n            ('a', Less),\n            ('a', Greater),\n            ('b', Equal),\n            ('b', Less),\n            ('b', Greater),\n            ('c', Equal),\n            ('c', Less),\n            ('c', Greater),\n        ],\n    );\n    lex_pairs_helper(\n        lex_pairs(exhaustive_orderings(), exhaustive_bools()),\n        lex_triples_from_single([Less, Greater].iter().copied()),\n        48,\n        &[\n            ((Equal, false), (Less, Less, Less)),\n            ((Equal, false), (Less, Less, Greater)),\n            ((Equal, false), (Less, Greater, Less)),\n            ((Equal, false), (Less, Greater, Greater)),\n            ((Equal, false), (Greater, Less, Less)),\n            ((Equal, false), (Greater, Less, Greater)),\n            ((Equal, false), (Greater, Greater, Less)),\n            ((Equal, false), (Greater, Greater, Greater)),\n            ((Equal, true), (Less, Less, Less)),\n            ((Equal, true), (Less, Less, Greater)),\n            ((Equal, true), (Less, Greater, Less)),\n            ((Equal, true), (Less, Greater, Greater)),\n            ((Equal, true), (Greater, Less, Less)),\n            ((Equal, true), (Greater, Less, Greater)),\n            ((Equal, true), (Greater, Greater, Less)),\n            ((Equal, true), (Greater, Greater, Greater)),\n            ((Less, false), (Less, Less, Less)),\n            ((Less, false), (Less, Less, Greater)),\n            ((Less, false), (Less, Greater, Less)),\n            ((Less, false), (Less, Greater, Greater)),\n        ],\n    );\n}\n\nfn lex_triples_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n    Z: Clone + Debug + Eq,\n    K: Clone + Iterator<Item = Z>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out_len: usize,\n    out: &[(X, Y, Z)],\n) {\n    let ts = lex_triples(xs, ys, zs);\n    let ts_prefix = ts.clone().take(20).collect_vec();\n    assert_eq!(ts_prefix.as_slice(), out);\n    assert_eq!(ts.count(), out_len);\n}\n\n#[test]\nfn test_lex_triples() {\n    lex_triples_helper(nevers(), nevers(), nevers(), 0, &[]);\n    lex_triples_helper(nevers(), 0..4, 'a'..'f', 0, &[]);\n    lex_triples_helper(once('a'), once(false), once(5), 1, &[('a', false, 5)]);\n    lex_triples_helper(\n        once('a'),\n        once(false),\n        0..4,\n        4,\n        &[('a', false, 0), ('a', false, 1), ('a', false, 2), ('a', false, 3)],\n    );\n    lex_triples_helper(\n        exhaustive_unsigneds::<u8>(),\n        lex_pairs_from_single(exhaustive_bools()),\n        'a'..'e',\n        4096,\n        &[\n            (0, (false, false), 'a'),\n            (0, (false, false), 'b'),\n            (0, (false, false), 'c'),\n            (0, (false, false), 'd'),\n            (0, (false, true), 'a'),\n            (0, (false, true), 'b'),\n            (0, (false, true), 'c'),\n            (0, (false, true), 'd'),\n            (0, (true, false), 'a'),\n            (0, (true, false), 'b'),\n            (0, (true, false), 'c'),\n            (0, (true, false), 'd'),\n            (0, (true, true), 'a'),\n            (0, (true, true), 'b'),\n            (0, (true, true), 'c'),\n            (0, (true, true), 'd'),\n            (1, (false, false), 'a'),\n            (1, (false, false), 'b'),\n            (1, (false, false), 'c'),\n            (1, (false, false), 'd'),\n        ],\n    );\n    lex_triples_helper(\n        exhaustive_bools(),\n        0..3,\n        'a'..'d',\n        18,\n        &[\n            (false, 0, 'a'),\n            (false, 0, 'b'),\n            (false, 0, 'c'),\n            (false, 1, 'a'),\n            (false, 1, 'b'),\n            (false, 1, 'c'),\n            (false, 2, 'a'),\n            (false, 2, 'b'),\n            (false, 2, 'c'),\n            (true, 0, 'a'),\n            (true, 0, 'b'),\n            (true, 0, 'c'),\n            (true, 1, 'a'),\n            (true, 1, 'b'),\n            (true, 1, 'c'),\n            (true, 2, 'a'),\n            (true, 2, 'b'),\n            (true, 2, 'c'),\n        ],\n    );\n    lex_triples_helper(\n        0..11,\n        exhaustive_somes(0..12),\n        'a'..'n',\n        1716,\n        &[\n            (0, Some(0), 'a'),\n            (0, Some(0), 'b'),\n            (0, Some(0), 'c'),\n            (0, Some(0), 'd'),\n            (0, Some(0), 'e'),\n            (0, Some(0), 'f'),\n            (0, Some(0), 'g'),\n            (0, Some(0), 'h'),\n            (0, Some(0), 'i'),\n            (0, Some(0), 'j'),\n            (0, Some(0), 'k'),\n            (0, Some(0), 'l'),\n            (0, Some(0), 'm'),\n            (0, Some(1), 'a'),\n            (0, Some(1), 'b'),\n            (0, Some(1), 'c'),\n            (0, Some(1), 'd'),\n            (0, Some(1), 'e'),\n            (0, Some(1), 'f'),\n            (0, Some(1), 'g'),\n        ],\n    );\n    lex_triples_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        [\"xx\", \"yy\", \"zz\"].iter().copied(),\n        0..3,\n        27,\n        &[\n            ('a', \"xx\", 0),\n            ('a', \"xx\", 1),\n            ('a', \"xx\", 2),\n            ('a', \"yy\", 0),\n            ('a', \"yy\", 1),\n            ('a', \"yy\", 2),\n            ('a', \"zz\", 0),\n            ('a', \"zz\", 1),\n            ('a', \"zz\", 2),\n            ('b', \"xx\", 0),\n            ('b', \"xx\", 1),\n            ('b', \"xx\", 2),\n            ('b', \"yy\", 0),\n            ('b', \"yy\", 1),\n            ('b', \"yy\", 2),\n            ('b', \"zz\", 0),\n            ('b', \"zz\", 1),\n            ('b', \"zz\", 2),\n            ('c', \"xx\", 0),\n            ('c', \"xx\", 1),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/lex_tuples_from_single.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{\n    lex_octuples_from_single, lex_quadruples_from_single, lex_quintuples_from_single,\n    lex_triples_from_single,\n};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::tuples::exhaustive::{exhaustive_units, lex_pairs_from_single};\nuse std::fmt::Debug;\n\nmacro_rules! helpers {\n    ($t: ty, $ts: ident, $ts_helper: ident, $ts_small_helper: ident) => {\n        fn $ts_helper<I: Iterator>(xs: I, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs).take(20).collect_vec();\n            assert_eq!(ts.as_slice(), out);\n        }\n\n        fn $ts_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs);\n            let ts_prefix = ts.clone().take(20).collect_vec();\n            assert_eq!(ts_prefix.as_slice(), out);\n            assert_eq!(ts.count(), out_len);\n        }\n    };\n}\nhelpers!(\n    (I::Item, I::Item),\n    lex_pairs_from_single,\n    lex_pairs_from_single_helper,\n    lex_pairs_from_single_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item),\n    lex_triples_from_single,\n    lex_triples_from_single_helper,\n    _lex_triples_from_single_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item),\n    lex_quadruples_from_single,\n    _lex_quadruples_from_single_helper,\n    lex_quadruples_from_single_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    lex_quintuples_from_single,\n    _lex_quintuples_from_single_helper,\n    lex_quintuples_from_single_small_helper\n);\nhelpers!(\n    (\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item,\n        I::Item\n    ),\n    lex_octuples_from_single,\n    _lex_octuples_from_single_helper,\n    lex_octuples_from_single_small_helper\n);\n\n#[test]\nfn test_lex_tuples_from_single() {\n    lex_pairs_from_single_small_helper(nevers(), 0, &[]);\n    lex_quintuples_from_single_small_helper(nevers(), 0, &[]);\n    lex_pairs_from_single_small_helper(exhaustive_units(), 1, &[((), ())]);\n    lex_quintuples_from_single_small_helper(exhaustive_units(), 1, &[((), (), (), (), ())]);\n    lex_pairs_from_single_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 0),\n            (0, 1),\n            (0, 2),\n            (0, 3),\n            (0, 4),\n            (0, 5),\n            (0, 6),\n            (0, 7),\n            (0, 8),\n            (0, 9),\n            (0, 10),\n            (0, 11),\n            (0, 12),\n            (0, 13),\n            (0, 14),\n            (0, 15),\n            (0, 16),\n            (0, 17),\n            (0, 18),\n            (0, 19),\n        ],\n    );\n    lex_triples_from_single_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 0, 0),\n            (0, 0, 1),\n            (0, 0, 2),\n            (0, 0, 3),\n            (0, 0, 4),\n            (0, 0, 5),\n            (0, 0, 6),\n            (0, 0, 7),\n            (0, 0, 8),\n            (0, 0, 9),\n            (0, 0, 10),\n            (0, 0, 11),\n            (0, 0, 12),\n            (0, 0, 13),\n            (0, 0, 14),\n            (0, 0, 15),\n            (0, 0, 16),\n            (0, 0, 17),\n            (0, 0, 18),\n            (0, 0, 19),\n        ],\n    );\n    lex_pairs_from_single_small_helper(\n        exhaustive_ascii_chars(),\n        0x4000,\n        &[\n            ('a', 'a'),\n            ('a', 'b'),\n            ('a', 'c'),\n            ('a', 'd'),\n            ('a', 'e'),\n            ('a', 'f'),\n            ('a', 'g'),\n            ('a', 'h'),\n            ('a', 'i'),\n            ('a', 'j'),\n            ('a', 'k'),\n            ('a', 'l'),\n            ('a', 'm'),\n            ('a', 'n'),\n            ('a', 'o'),\n            ('a', 'p'),\n            ('a', 'q'),\n            ('a', 'r'),\n            ('a', 's'),\n            ('a', 't'),\n        ],\n    );\n    lex_pairs_from_single_small_helper(\n        exhaustive_bools(),\n        4,\n        &[(false, false), (false, true), (true, false), (true, true)],\n    );\n    lex_quadruples_from_single_small_helper(\n        exhaustive_bools(),\n        16,\n        &[\n            (false, false, false, false),\n            (false, false, false, true),\n            (false, false, true, false),\n            (false, false, true, true),\n            (false, true, false, false),\n            (false, true, false, true),\n            (false, true, true, false),\n            (false, true, true, true),\n            (true, false, false, false),\n            (true, false, false, true),\n            (true, false, true, false),\n            (true, false, true, true),\n            (true, true, false, false),\n            (true, true, false, true),\n            (true, true, true, false),\n            (true, true, true, true),\n        ],\n    );\n    lex_octuples_from_single_small_helper(\n        exhaustive_bools(),\n        256,\n        &[\n            (false, false, false, false, false, false, false, false),\n            (false, false, false, false, false, false, false, true),\n            (false, false, false, false, false, false, true, false),\n            (false, false, false, false, false, false, true, true),\n            (false, false, false, false, false, true, false, false),\n            (false, false, false, false, false, true, false, true),\n            (false, false, false, false, false, true, true, false),\n            (false, false, false, false, false, true, true, true),\n            (false, false, false, false, true, false, false, false),\n            (false, false, false, false, true, false, false, true),\n            (false, false, false, false, true, false, true, false),\n            (false, false, false, false, true, false, true, true),\n            (false, false, false, false, true, true, false, false),\n            (false, false, false, false, true, true, false, true),\n            (false, false, false, false, true, true, true, false),\n            (false, false, false, false, true, true, true, true),\n            (false, false, false, true, false, false, false, false),\n            (false, false, false, true, false, false, false, true),\n            (false, false, false, true, false, false, true, false),\n            (false, false, false, true, false, false, true, true),\n        ],\n    );\n    lex_octuples_from_single_small_helper(\n        0..3,\n        6561,\n        &[\n            (0, 0, 0, 0, 0, 0, 0, 0),\n            (0, 0, 0, 0, 0, 0, 0, 1),\n            (0, 0, 0, 0, 0, 0, 0, 2),\n            (0, 0, 0, 0, 0, 0, 1, 0),\n            (0, 0, 0, 0, 0, 0, 1, 1),\n            (0, 0, 0, 0, 0, 0, 1, 2),\n            (0, 0, 0, 0, 0, 0, 2, 0),\n            (0, 0, 0, 0, 0, 0, 2, 1),\n            (0, 0, 0, 0, 0, 0, 2, 2),\n            (0, 0, 0, 0, 0, 1, 0, 0),\n            (0, 0, 0, 0, 0, 1, 0, 1),\n            (0, 0, 0, 0, 0, 1, 0, 2),\n            (0, 0, 0, 0, 0, 1, 1, 0),\n            (0, 0, 0, 0, 0, 1, 1, 1),\n            (0, 0, 0, 0, 0, 1, 1, 2),\n            (0, 0, 0, 0, 0, 1, 2, 0),\n            (0, 0, 0, 0, 0, 1, 2, 1),\n            (0, 0, 0, 0, 0, 1, 2, 2),\n            (0, 0, 0, 0, 0, 2, 0, 0),\n            (0, 0, 0, 0, 0, 2, 0, 1),\n        ],\n    );\n    lex_pairs_from_single_helper(\n        lex_pairs_from_single(exhaustive_unsigneds::<u8>()),\n        &[\n            ((0, 0), (0, 0)),\n            ((0, 0), (0, 1)),\n            ((0, 0), (0, 2)),\n            ((0, 0), (0, 3)),\n            ((0, 0), (0, 4)),\n            ((0, 0), (0, 5)),\n            ((0, 0), (0, 6)),\n            ((0, 0), (0, 7)),\n            ((0, 0), (0, 8)),\n            ((0, 0), (0, 9)),\n            ((0, 0), (0, 10)),\n            ((0, 0), (0, 11)),\n            ((0, 0), (0, 12)),\n            ((0, 0), (0, 13)),\n            ((0, 0), (0, 14)),\n            ((0, 0), (0, 15)),\n            ((0, 0), (0, 16)),\n            ((0, 0), (0, 17)),\n            ((0, 0), (0, 18)),\n            ((0, 0), (0, 19)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/exhaustive/lex_unique_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{lex_unique_quadruples, lex_unique_quintuples, lex_unique_triples};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::tuples::exhaustive::{exhaustive_units, lex_unique_pairs};\nuse std::fmt::Debug;\n\nmacro_rules! helpers {\n    ($t: ty, $ts: ident, $ts_helper: ident, $ts_small_helper: ident) => {\n        fn $ts_helper<I: Iterator>(xs: I, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs).take(20).collect_vec();\n            assert_eq!(ts.as_slice(), out);\n        }\n\n        fn $ts_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[$t])\n        where\n            I::Item: Clone + Debug + Eq,\n        {\n            let ts = $ts(xs);\n            let ts_prefix = ts.clone().take(20).collect_vec();\n            assert_eq!(ts_prefix.as_slice(), out);\n            assert_eq!(ts.count(), out_len);\n        }\n    };\n}\nhelpers!(\n    (I::Item, I::Item),\n    lex_unique_pairs,\n    _lex_unique_pairs_helper,\n    lex_unique_pairs_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item),\n    lex_unique_triples,\n    lex_unique_triples_helper,\n    _lex_unique_triples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item),\n    lex_unique_quadruples,\n    _lex_unique_quadruples_helper,\n    lex_unique_quadruples_small_helper\n);\nhelpers!(\n    (I::Item, I::Item, I::Item, I::Item, I::Item),\n    lex_unique_quintuples,\n    _lex_unique_quintuples_helper,\n    lex_unique_quintuples_small_helper\n);\n\n#[test]\nfn test_lex_unique_tuples() {\n    lex_unique_pairs_small_helper(nevers(), 0, &[]);\n    lex_unique_quintuples_small_helper(nevers(), 0, &[]);\n    lex_unique_pairs_small_helper(exhaustive_units(), 0, &[]);\n    lex_unique_quintuples_small_helper(exhaustive_units(), 0, &[]);\n    lex_unique_pairs_small_helper(\n        exhaustive_unsigneds::<u8>(),\n        65280,\n        &[\n            (0, 1),\n            (0, 2),\n            (0, 3),\n            (0, 4),\n            (0, 5),\n            (0, 6),\n            (0, 7),\n            (0, 8),\n            (0, 9),\n            (0, 10),\n            (0, 11),\n            (0, 12),\n            (0, 13),\n            (0, 14),\n            (0, 15),\n            (0, 16),\n            (0, 17),\n            (0, 18),\n            (0, 19),\n            (0, 20),\n        ],\n    );\n    lex_unique_triples_helper(\n        exhaustive_unsigneds::<u8>(),\n        &[\n            (0, 1, 2),\n            (0, 1, 3),\n            (0, 1, 4),\n            (0, 1, 5),\n            (0, 1, 6),\n            (0, 1, 7),\n            (0, 1, 8),\n            (0, 1, 9),\n            (0, 1, 10),\n            (0, 1, 11),\n            (0, 1, 12),\n            (0, 1, 13),\n            (0, 1, 14),\n            (0, 1, 15),\n            (0, 1, 16),\n            (0, 1, 17),\n            (0, 1, 18),\n            (0, 1, 19),\n            (0, 1, 20),\n            (0, 1, 21),\n        ],\n    );\n    lex_unique_pairs_small_helper(\n        exhaustive_ascii_chars(),\n        16256,\n        &[\n            ('a', 'b'),\n            ('a', 'c'),\n            ('a', 'd'),\n            ('a', 'e'),\n            ('a', 'f'),\n            ('a', 'g'),\n            ('a', 'h'),\n            ('a', 'i'),\n            ('a', 'j'),\n            ('a', 'k'),\n            ('a', 'l'),\n            ('a', 'm'),\n            ('a', 'n'),\n            ('a', 'o'),\n            ('a', 'p'),\n            ('a', 'q'),\n            ('a', 'r'),\n            ('a', 's'),\n            ('a', 't'),\n            ('a', 'u'),\n        ],\n    );\n    lex_unique_pairs_small_helper(exhaustive_bools(), 2, &[(false, true), (true, false)]);\n    lex_unique_quadruples_small_helper(\n        1..=6,\n        360,\n        &[\n            (1, 2, 3, 4),\n            (1, 2, 3, 5),\n            (1, 2, 3, 6),\n            (1, 2, 4, 3),\n            (1, 2, 4, 5),\n            (1, 2, 4, 6),\n            (1, 2, 5, 3),\n            (1, 2, 5, 4),\n            (1, 2, 5, 6),\n            (1, 2, 6, 3),\n            (1, 2, 6, 4),\n            (1, 2, 6, 5),\n            (1, 3, 2, 4),\n            (1, 3, 2, 5),\n            (1, 3, 2, 6),\n            (1, 3, 4, 2),\n            (1, 3, 4, 5),\n            (1, 3, 4, 6),\n            (1, 3, 5, 2),\n            (1, 3, 5, 4),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/random/random_custom_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{random_triples_from_single, random_triples_xxy, random_triples_xyx};\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::tuples::random::random_pairs_from_single;\nuse std::fmt::Debug;\n\n#[allow(clippy::type_complexity)]\nfn random_triples_xxy_helper<\n    X: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq + Hash + Ord,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[(X, X, Y)],\n    expected_common_values: &[((X, X, Y), usize)],\n    expected_median: ((X, X, Y), Option<(X, X, Y)>),\n) {\n    let xs = random_triples_xxy(EXAMPLE_SEED, xs_gen, ys_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_triples_xxy() {\n    random_triples_xxy_helper(\n        &random_primitive_ints::<u8>,\n        &random_bools,\n        &[\n            (85, 11, false),\n            (136, 200, true),\n            (235, 134, false),\n            (203, 223, false),\n            (38, 235, false),\n            (217, 177, true),\n            (162, 32, true),\n            (166, 234, false),\n            (30, 218, false),\n            (90, 106, false),\n            (9, 216, false),\n            (204, 151, true),\n            (213, 97, false),\n            (253, 78, true),\n            (91, 39, false),\n            (191, 175, true),\n            (170, 232, false),\n            (233, 2, true),\n            (35, 22, true),\n            (217, 198, false),\n        ],\n        &[\n            ((87, 70, false), 23),\n            ((36, 187, false), 23),\n            ((228, 249, false), 22),\n            ((130, 73, true), 20),\n            ((67, 187, true), 20),\n            ((89, 216, true), 20),\n            ((132, 195, true), 20),\n            ((145, 23, false), 20),\n            ((24, 126, false), 20),\n            ((146, 106, false), 20),\n        ],\n        ((127, 197, true), None),\n    );\n    random_triples_xxy_helper(\n        &|seed| random_pairs_from_single(random_primitive_ints::<u8>(seed)),\n        &|seed| random_triples_from_single(random_primitive_ints::<i8>(seed)),\n        &[\n            ((85, 11), (136, 200), (98, -88, -58)),\n            ((235, 134), (203, 223), (40, 20, -4)),\n            ((38, 235), (217, 177), (47, 87, -124)),\n            ((162, 32), (166, 234), (72, 77, 63)),\n            ((30, 218), (90, 106), (91, 108, 127)),\n            ((9, 216), (204, 151), (53, -115, 84)),\n            ((213, 97), (253, 78), (18, 10, 112)),\n            ((91, 39), (191, 175), (-102, 104, 53)),\n            ((170, 232), (233, 2), (75, -18, -107)),\n            ((35, 22), (217, 198), (-66, 51, -109)),\n            ((114, 17), (32, 173), (100, 114, -116)),\n            ((114, 65), (121, 222), (2, 63, -67)),\n            ((173, 25), (144, 148), (-34, 67, 119)),\n            ((79, 115), (52, 73), (0, -33, 5)),\n            ((69, 137), (91, 153), (-20, -24, 50)),\n            ((178, 112), (34, 95), (44, -15, 21)),\n            ((106, 167), (197, 130), (22, 94, 27)),\n            ((168, 122), (207, 172), (-128, -36, 25)),\n            ((177, 86), (150, 221), (-5, -13, 50)),\n            ((218, 101), (115, 74), (-119, -21, 46)),\n        ],\n        &[\n            (((8, 24), (5, 3), (0, 54, 59)), 1),\n            (((8, 72), (11, 57), (6, 5, 9)), 1),\n            (((80, 9), (9, 5), (84, 9, 10)), 1),\n            (((86, 2), (49, 4), (2, 0, 27)), 1),\n            (((0, 2), (92, 5), (-49, 31, 7)), 1),\n            (((1, 15), (12, 5), (51, 5, 47)), 1),\n            (((1, 25), (3, 66), (70, 65, 7)), 1),\n            (((1, 72), (2, 1), (8, 49, -10)), 1),\n            (((1, 82), (6, 26), (86, 3, 70)), 1),\n            (((1, 85), (14, 92), (3, 5, 53)), 1),\n        ],\n        (\n            ((128, 20), (243, 155), (-90, 7, -77)),\n            Some(((128, 21), (19, 63), (52, 113, -21))),\n        ),\n    );\n}\n\n#[allow(clippy::type_complexity)]\nfn random_triples_xyx_helper<\n    X: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq + Hash + Ord,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[(X, Y, X)],\n    expected_common_values: &[((X, Y, X), usize)],\n    expected_median: ((X, Y, X), Option<(X, Y, X)>),\n) {\n    let xs = random_triples_xyx(EXAMPLE_SEED, xs_gen, ys_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_triples_xyx() {\n    random_triples_xyx_helper(\n        &random_primitive_ints::<u8>,\n        &random_bools,\n        &[\n            (85, false, 11),\n            (136, true, 200),\n            (235, false, 134),\n            (203, false, 223),\n            (38, false, 235),\n            (217, true, 177),\n            (162, true, 32),\n            (166, false, 234),\n            (30, false, 218),\n            (90, false, 106),\n            (9, false, 216),\n            (204, true, 151),\n            (213, false, 97),\n            (253, true, 78),\n            (91, false, 39),\n            (191, true, 175),\n            (170, false, 232),\n            (233, true, 2),\n            (35, true, 22),\n            (217, false, 198),\n        ],\n        &[\n            ((87, false, 70), 23),\n            ((36, false, 187), 23),\n            ((228, false, 249), 22),\n            ((130, true, 73), 20),\n            ((67, true, 187), 20),\n            ((89, true, 216), 20),\n            ((132, true, 195), 20),\n            ((145, false, 23), 20),\n            ((24, false, 126), 20),\n            ((146, false, 106), 20),\n        ],\n        ((127, true, 141), None),\n    );\n    random_triples_xyx_helper(\n        &|seed| random_pairs_from_single(random_primitive_ints::<u8>(seed)),\n        &|seed| random_triples_from_single(random_primitive_ints::<i8>(seed)),\n        &[\n            ((85, 11), (98, -88, -58), (136, 200)),\n            ((235, 134), (40, 20, -4), (203, 223)),\n            ((38, 235), (47, 87, -124), (217, 177)),\n            ((162, 32), (72, 77, 63), (166, 234)),\n            ((30, 218), (91, 108, 127), (90, 106)),\n            ((9, 216), (53, -115, 84), (204, 151)),\n            ((213, 97), (18, 10, 112), (253, 78)),\n            ((91, 39), (-102, 104, 53), (191, 175)),\n            ((170, 232), (75, -18, -107), (233, 2)),\n            ((35, 22), (-66, 51, -109), (217, 198)),\n            ((114, 17), (100, 114, -116), (32, 173)),\n            ((114, 65), (2, 63, -67), (121, 222)),\n            ((173, 25), (-34, 67, 119), (144, 148)),\n            ((79, 115), (0, -33, 5), (52, 73)),\n            ((69, 137), (-20, -24, 50), (91, 153)),\n            ((178, 112), (44, -15, 21), (34, 95)),\n            ((106, 167), (22, 94, 27), (197, 130)),\n            ((168, 122), (-128, -36, 25), (207, 172)),\n            ((177, 86), (-5, -13, 50), (150, 221)),\n            ((218, 101), (-119, -21, 46), (115, 74)),\n        ],\n        &[\n            (((8, 24), (0, 54, 59), (5, 3)), 1),\n            (((8, 72), (6, 5, 9), (11, 57)), 1),\n            (((80, 9), (84, 9, 10), (9, 5)), 1),\n            (((86, 2), (2, 0, 27), (49, 4)), 1),\n            (((0, 2), (-49, 31, 7), (92, 5)), 1),\n            (((1, 15), (51, 5, 47), (12, 5)), 1),\n            (((1, 25), (70, 65, 7), (3, 66)), 1),\n            (((1, 72), (8, 49, -10), (2, 1)), 1),\n            (((1, 82), (86, 3, 70), (6, 26)), 1),\n            (((1, 85), (3, 5, 53), (14, 92)), 1),\n        ],\n        (\n            ((128, 20), (118, 50, 18), (55, 110)),\n            Some(((128, 21), (-107, 66, -82), (216, 142))),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/random/random_ordered_unique_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::random_ordered_unique_triples;\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::tuples::random::random_ordered_unique_pairs;\nuse std::fmt::Debug;\n\n#[allow(clippy::type_complexity)]\nfn random_ordered_unique_pairs_helper<I: Clone + Iterator>(\n    xs: I,\n    expected_values: &[(I::Item, I::Item)],\n    expected_common_values: &[((I::Item, I::Item), usize)],\n    expected_median: ((I::Item, I::Item), Option<(I::Item, I::Item)>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_ordered_unique_pairs(xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[allow(clippy::type_complexity)]\nfn random_ordered_unique_triples_helper<I: Clone + Iterator>(\n    xs: I,\n    expected_values: &[(I::Item, I::Item, I::Item)],\n    expected_common_values: &[((I::Item, I::Item, I::Item), usize)],\n    expected_median: (\n        (I::Item, I::Item, I::Item),\n        Option<(I::Item, I::Item, I::Item)>,\n    ),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_ordered_unique_triples(xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_ordered_unique_tuples() {\n    random_ordered_unique_triples_helper(\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            (69, 113, 239),\n            (108, 210, 228),\n            (87, 161, 168),\n            (32, 83, 110),\n            (34, 89, 188),\n            (93, 200, 238),\n            (115, 149, 189),\n            (149, 201, 217),\n            (31, 117, 146),\n            (72, 151, 169),\n            (7, 33, 174),\n            (38, 81, 144),\n            (72, 113, 127),\n            (107, 128, 233),\n            (12, 46, 119),\n            (18, 164, 243),\n            (59, 114, 174),\n            (39, 174, 247),\n            (104, 160, 184),\n            (37, 100, 252),\n        ],\n        &[\n            ((57, 142, 207), 7),\n            ((32, 68, 169), 6),\n            ((36, 70, 195), 6),\n            ((125, 168, 194), 6),\n            ((0, 97, 205), 5),\n            ((2, 33, 227), 5),\n            ((5, 46, 239), 5),\n            ((9, 68, 189), 5),\n            ((9, 78, 240), 5),\n            ((1, 110, 203), 5),\n        ],\n        ((52, 133, 241), Some((52, 133, 242))),\n    );\n    random_ordered_unique_pairs_helper(\n        random_ordered_unique_pairs(random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            ((69, 108), (113, 239)),\n            ((161, 168), (210, 228)),\n            ((32, 87), (83, 110)),\n            ((34, 188), (89, 238)),\n            ((93, 200), (115, 149)),\n            ((149, 189), (201, 217)),\n            ((31, 72), (117, 146)),\n            ((33, 174), (151, 169)),\n            ((7, 38), (81, 144)),\n            ((72, 127), (113, 128)),\n            ((46, 119), (107, 233)),\n            ((12, 18), (164, 243)),\n            ((59, 247), (114, 174)),\n            ((39, 174), (160, 184)),\n            ((37, 104), (100, 252)),\n            ((69, 107), (122, 228)),\n            ((142, 179), (242, 248)),\n            ((61, 189), (233, 239)),\n            ((7, 192), (85, 235)),\n            ((90, 200), (178, 185)),\n        ],\n        &[\n            (((0, 78), (34, 52)), 2),\n            (((1, 58), (6, 112)), 2),\n            (((1, 63), (8, 154)), 2),\n            (((1, 97), (7, 250)), 2),\n            (((2, 33), (40, 81)), 2),\n            (((3, 160), (7, 29)), 2),\n            (((3, 32), (12, 60)), 2),\n            (((6, 130), (7, 20)), 2),\n            (((6, 68), (7, 126)), 2),\n            (((6, 77), (36, 54)), 2),\n        ],\n        (((40, 193), (94, 142)), Some(((40, 193), (97, 243)))),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/random/random_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::{random_triples, random_triples_from_single};\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::chars::random::random_ascii_chars;\nuse malachite_base::num::random::geometric::geometric_random_signeds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::tuples::random::{random_pairs, random_pairs_from_single};\nuse malachite_base::tuples::singletons;\nuse std::fmt::Debug;\n\nfn random_pairs_helper<\n    X: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq + Hash + Ord,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[(X, Y)],\n    expected_common_values: &[((X, Y), usize)],\n    expected_median: ((X, Y), Option<(X, Y)>),\n) {\n    let xs = random_pairs(EXAMPLE_SEED, xs_gen, ys_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_pairs() {\n    random_pairs_helper(\n        &random_primitive_ints::<u8>,\n        &random_bools,\n        &[\n            (85, false),\n            (11, true),\n            (136, false),\n            (200, false),\n            (235, false),\n            (134, true),\n            (203, true),\n            (223, false),\n            (38, false),\n            (235, false),\n            (217, false),\n            (177, true),\n            (162, false),\n            (32, true),\n            (166, false),\n            (234, true),\n            (30, false),\n            (218, true),\n            (90, true),\n            (106, false),\n        ],\n        &[\n            ((81, true), 2077),\n            ((58, false), 2074),\n            ((220, false), 2064),\n            ((14, false), 2053),\n            ((194, true), 2050),\n            ((66, false), 2050),\n            ((71, true), 2049),\n            ((208, false), 2043),\n            ((7, true), 2041),\n            ((64, true), 2038),\n        ],\n        ((127, true), None),\n    );\n    random_pairs_helper(\n        &|seed| random_pairs_from_single(random_primitive_ints::<u8>(seed)),\n        &|seed| random_triples_from_single(random_primitive_ints::<i8>(seed)),\n        &[\n            ((85, 11), (98, -88, -58)),\n            ((136, 200), (40, 20, -4)),\n            ((235, 134), (47, 87, -124)),\n            ((203, 223), (72, 77, 63)),\n            ((38, 235), (91, 108, 127)),\n            ((217, 177), (53, -115, 84)),\n            ((162, 32), (18, 10, 112)),\n            ((166, 234), (-102, 104, 53)),\n            ((30, 218), (75, -18, -107)),\n            ((90, 106), (-66, 51, -109)),\n            ((9, 216), (100, 114, -116)),\n            ((204, 151), (2, 63, -67)),\n            ((213, 97), (-34, 67, 119)),\n            ((253, 78), (0, -33, 5)),\n            ((91, 39), (-20, -24, 50)),\n            ((191, 175), (44, -15, 21)),\n            ((170, 232), (22, 94, 27)),\n            ((233, 2), (-128, -36, 25)),\n            ((35, 22), (-5, -13, 50)),\n            ((217, 198), (-119, -21, 46)),\n        ],\n        &[\n            (((0, 5), (6, 7, 42)), 1),\n            (((8, 8), (18, 5, 6)), 1),\n            (((9, 1), (5, 3, 23)), 1),\n            (((0, 0), (97, 7, 73)), 1),\n            (((0, 2), (12, 20, 6)), 1),\n            (((0, 99), (20, 8, 6)), 1),\n            (((1, 81), (3, 21, 3)), 1),\n            (((1, 83), (-6, 8, 8)), 1),\n            (((1, 9), (-37, 9, 7)), 1),\n            (((1, 9), (4, 95, 15)), 1),\n        ],\n        (\n            ((127, 197), (-18, 55, -20)),\n            Some(((127, 197), (-8, -68, 49))),\n        ),\n    );\n}\n\n#[allow(clippy::type_complexity)]\nfn random_triples_helper<\n    X: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq + Hash + Ord,\n    J: Clone + Iterator<Item = Y>,\n    Z: Clone + Debug + Eq + Hash + Ord,\n    K: Clone + Iterator<Item = Z>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    zs_gen: &dyn Fn(Seed) -> K,\n    expected_values: &[(X, Y, Z)],\n    expected_common_values: &[((X, Y, Z), usize)],\n    expected_median: ((X, Y, Z), Option<(X, Y, Z)>),\n) {\n    let xs = random_triples(EXAMPLE_SEED, xs_gen, ys_gen, zs_gen);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_triples() {\n    random_triples_helper(\n        &random_primitive_ints::<u8>,\n        &random_ascii_chars,\n        &|seed| geometric_random_signeds::<i8>(seed, 10, 1),\n        &[\n            (85, 'b', 0),\n            (11, 'P', -6),\n            (136, '\\u{1a}', -6),\n            (200, 'F', 8),\n            (235, 'B', 0),\n            (134, '\\u{2}', -3),\n            (203, '\\u{7f}', -17),\n            (223, '\\u{17}', 2),\n            (38, 'W', 0),\n            (235, '\\u{8}', 2),\n            (217, '\\\"', 9),\n            (177, 'j', -6),\n            (162, 't', 20),\n            (32, 'g', -20),\n            (166, '\\u{16}', 43),\n            (234, '6', 9),\n            (30, '\\u{7f}', -7),\n            (218, 'j', -16),\n            (90, '4', -29),\n            (106, '$', -2),\n        ],\n        &[\n            ((54, '*', -1), 9),\n            ((252, '\\u{c}', 0), 9),\n            ((253, '\\u{6}', 0), 9),\n            ((4, '~', 0), 8),\n            ((51, '1', 1), 8),\n            ((131, '!', 1), 8),\n            ((138, 'i', 1), 8),\n            ((185, 'q', 1), 8),\n            ((58, '?', -2), 8),\n            ((225, 'k', -4), 8),\n        ],\n        ((127, 'x', -2), None),\n    );\n    random_triples_helper(\n        &|seed| singletons(random_bools(seed)),\n        &|seed| random_pairs_from_single(random_primitive_ints::<u8>(seed)),\n        &|seed| random_triples_from_single(random_ascii_chars(seed)),\n        &[\n            ((true,), (98, 168), ('(', '\\u{15}', 'h')),\n            ((false,), (198, 40), ('\\u{7f}', '%', '\\u{7f}')),\n            ((true,), (20, 252), ('\\u{13}', '\\u{2}', '+')),\n            ((false,), (47, 87), ('\\u{1b}', 'v', '\\r')),\n            ((true,), (132, 72), ('\\u{1b}', '\\u{15}', 'I')),\n            ((false,), (77, 63), ('$', '\\u{1a}', '}')),\n            ((true,), (91, 108), ('(', '\\u{e}', '1')),\n            ((false,), (127, 53), ('$', '/', 'O')),\n            ((true,), (141, 84), ('\\u{1f}', 'Z', '>')),\n            ((true,), (18, 10), ('}', '\\u{13}', '\\\\')),\n            ((false,), (112, 154), ('\\u{1a}', '\\u{14}', 't')),\n            ((true,), (104, 53), (' ', '`', '\\u{2}')),\n            ((false,), (75, 238), ('\\u{17}', 'a', '8')),\n            ((false,), (149, 190), ('H', ']', '*')),\n            ((false,), (51, 147), ('i', '2', '}')),\n            ((false,), (100, 114), ('\\u{3}', '\\u{f}', '\\u{7f}')),\n            ((false,), (140, 2), ('\\u{f}', 'Y', 'D')),\n            ((false,), (63, 189), ('m', '\\\\', '8')),\n            ((false,), (222, 67), ('M', '\\u{7}', '8')),\n            ((true,), (119, 0), ('\\u{13}', '.', '\\\"')),\n        ],\n        &[\n            (((true,), (57, 9), ('R', '}', 'Q')), 2),\n            (((true,), (233, 229), ('t', '\\u{b}', 'Q')), 2),\n            (((false,), (236, 203), ('b', '\\u{e}', '\\u{e}')), 2),\n            (((true,), (0, 0), ('{', '{', '4')), 1),\n            (((true,), (0, 2), ('-', 'S', '{')), 1),\n            (((true,), (0, 2), ('N', 'E', '-')), 1),\n            (((true,), (0, 2), ('O', '3', 'S')), 1),\n            (((true,), (0, 3), ('\"', '/', 'P')), 1),\n            (((true,), (0, 3), (';', 'M', 'W')), 1),\n            (((true,), (0, 3), ('i', ']', 'P')), 1),\n        ],\n        (\n            ((false,), (255, 175), ('g', '\\u{1e}', '4')),\n            Some(((false,), (255, 176), ('\\u{10}', 's', '\\''))),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/random/random_tuples_from_single.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::random_triples_from_single;\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::tuples::random::random_pairs_from_single;\nuse std::fmt::Debug;\n\n#[allow(clippy::type_complexity)]\nfn random_pairs_from_single_helper<I: Clone + Iterator>(\n    xs: I,\n    expected_values: &[(I::Item, I::Item)],\n    expected_common_values: &[((I::Item, I::Item), usize)],\n    expected_median: ((I::Item, I::Item), Option<(I::Item, I::Item)>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_pairs_from_single(xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[allow(clippy::type_complexity)]\nfn random_triples_from_single_helper<I: Clone + Iterator>(\n    xs: I,\n    expected_values: &[(I::Item, I::Item, I::Item)],\n    expected_common_values: &[((I::Item, I::Item, I::Item), usize)],\n    expected_median: (\n        (I::Item, I::Item, I::Item),\n        Option<(I::Item, I::Item, I::Item)>,\n    ),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_triples_from_single(xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_tuples_from_single() {\n    random_triples_from_single_helper(\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            (113, 239, 69),\n            (108, 228, 210),\n            (168, 161, 87),\n            (32, 110, 83),\n            (188, 34, 89),\n            (238, 93, 200),\n            (149, 115, 189),\n            (149, 217, 201),\n            (117, 146, 31),\n            (72, 151, 169),\n            (174, 33, 7),\n            (38, 81, 144),\n            (72, 127, 113),\n            (128, 233, 107),\n            (46, 119, 12),\n            (18, 164, 243),\n            (114, 174, 59),\n            (247, 39, 174),\n            (160, 184, 104),\n            (37, 100, 252),\n        ],\n        &[\n            ((222, 60, 79), 4),\n            ((26, 110, 13), 4),\n            ((41, 254, 55), 4),\n            ((109, 134, 76), 4),\n            ((165, 174, 73), 4),\n            ((236, 57, 174), 4),\n            ((73, 168, 192), 4),\n            ((89, 197, 244), 4),\n            ((91, 170, 115), 4),\n            ((142, 168, 231), 4),\n        ],\n        ((127, 253, 76), Some((127, 253, 86))),\n    );\n    random_pairs_from_single_helper(\n        random_pairs_from_single(random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            ((113, 239), (69, 108)),\n            ((228, 210), (168, 161)),\n            ((87, 32), (110, 83)),\n            ((188, 34), (89, 238)),\n            ((93, 200), (149, 115)),\n            ((189, 149), (217, 201)),\n            ((117, 146), (31, 72)),\n            ((151, 169), (174, 33)),\n            ((7, 38), (81, 144)),\n            ((72, 127), (113, 128)),\n            ((233, 107), (46, 119)),\n            ((12, 18), (164, 243)),\n            ((114, 174), (59, 247)),\n            ((39, 174), (160, 184)),\n            ((104, 37), (100, 252)),\n            ((228, 122), (107, 69)),\n            ((242, 248), (179, 142)),\n            ((239, 233), (61, 189)),\n            ((235, 85), (192, 7)),\n            ((200, 90), (185, 178)),\n        ],\n        &[\n            (((28, 96), (0, 11)), 2),\n            (((2, 43), (64, 233)), 2),\n            (((20, 33), (14, 10)), 2),\n            (((223, 84), (7, 22)), 2),\n            (((43, 33), (131, 6)), 2),\n            (((6, 233), (45, 89)), 2),\n            (((65, 26), (6, 146)), 2),\n            (((71, 80), (68, 88)), 2),\n            (((9, 85), (186, 55)), 2),\n            (((96, 254), (9, 37)), 2),\n        ],\n        (((127, 243), (125, 130)), Some(((127, 243), (134, 100)))),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/random/random_unique_tuples.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::random_unique_triples;\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::tuples::random::random_unique_pairs;\nuse std::fmt::Debug;\n\n#[allow(clippy::type_complexity)]\nfn random_unique_pairs_helper<I: Clone + Iterator>(\n    xs: I,\n    expected_values: &[(I::Item, I::Item)],\n    expected_common_values: &[((I::Item, I::Item), usize)],\n    expected_median: ((I::Item, I::Item), Option<(I::Item, I::Item)>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_unique_pairs(xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[allow(clippy::type_complexity)]\nfn random_unique_triples_helper<I: Clone + Iterator>(\n    xs: I,\n    expected_values: &[(I::Item, I::Item, I::Item)],\n    expected_common_values: &[((I::Item, I::Item, I::Item), usize)],\n    expected_median: (\n        (I::Item, I::Item, I::Item),\n        Option<(I::Item, I::Item, I::Item)>,\n    ),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    let xs = random_unique_triples(xs);\n    let values = xs.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, xs.clone());\n    let median = median(xs.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_unique_tuples() {\n    random_unique_triples_helper(\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            (113, 239, 69),\n            (108, 228, 210),\n            (168, 161, 87),\n            (32, 110, 83),\n            (188, 34, 89),\n            (238, 93, 200),\n            (149, 115, 189),\n            (149, 217, 201),\n            (117, 146, 31),\n            (72, 151, 169),\n            (174, 33, 7),\n            (38, 81, 144),\n            (72, 127, 113),\n            (128, 233, 107),\n            (46, 119, 12),\n            (18, 164, 243),\n            (114, 174, 59),\n            (247, 39, 174),\n            (160, 184, 104),\n            (37, 100, 252),\n        ],\n        &[\n            ((205, 0, 97), 4),\n            ((102, 18, 19), 4),\n            ((105, 70, 13), 4),\n            ((22, 45, 192), 4),\n            ((87, 100, 26), 4),\n            ((15, 107, 109), 4),\n            ((134, 245, 157), 4),\n            ((138, 164, 179), 4),\n            ((219, 253, 196), 4),\n            ((237, 197, 239), 4),\n        ],\n        ((128, 16, 107), Some((128, 16, 116))),\n    );\n    random_unique_pairs_helper(\n        random_unique_pairs(random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            ((113, 239), (69, 108)),\n            ((228, 210), (168, 161)),\n            ((87, 32), (110, 83)),\n            ((188, 34), (89, 238)),\n            ((93, 200), (149, 115)),\n            ((189, 149), (217, 201)),\n            ((117, 146), (31, 72)),\n            ((151, 169), (174, 33)),\n            ((7, 38), (81, 144)),\n            ((72, 127), (113, 128)),\n            ((233, 107), (46, 119)),\n            ((12, 18), (164, 243)),\n            ((114, 174), (59, 247)),\n            ((39, 174), (160, 184)),\n            ((104, 37), (100, 252)),\n            ((228, 122), (107, 69)),\n            ((242, 248), (179, 142)),\n            ((239, 233), (61, 189)),\n            ((235, 85), (192, 7)),\n            ((200, 90), (185, 178)),\n        ],\n        &[\n            (((60, 12), (3, 32)), 2),\n            (((0, 80), (88, 210)), 2),\n            (((1, 3), (216, 183)), 2),\n            (((159, 0), (69, 30)), 2),\n            (((199, 6), (95, 79)), 2),\n            (((2, 98), (221, 19)), 2),\n            (((212, 65), (99, 2)), 2),\n            (((3, 14), (61, 170)), 2),\n            (((41, 155), (3, 72)), 2),\n            (((47, 85), (69, 66)), 2),\n        ],\n        (((128, 41), (252, 44)), Some(((128, 42), (8, 241)))),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/random/random_units.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::tuples::random::random_units;\n\n#[test]\nfn test_random_units() {\n    assert_eq!(random_units().take(20).collect_vec(), &[(); 20]);\n}\n"
  },
  {
    "path": "malachite-base/tests/tuples/singletons.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::nevers::Never;\nuse malachite_base::tuples::singletons;\nuse std::fmt::Debug;\n\nfn singletons_helper<T: Clone + Debug + Eq>(xs: &[T], out: &[(T,)]) {\n    assert_eq!(singletons(xs.iter().cloned()).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_singletons() {\n    singletons_helper::<Never>(&[], &[]);\n    singletons_helper(&[5], &[(5,)]);\n    singletons_helper(&[1, 2, 3], &[(1,), (2,), (3,)]);\n    singletons_helper(&[(2,), (1,), (5,)], &[((2,),), ((1,),), ((5,),)]);\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::unions::Union2;\n\n#[allow(clippy::redundant_clone)]\n#[test]\nfn test_clone() {\n    let test = |u: Union2<Vec<char>, u32>| {\n        let cloned = u.clone();\n        assert_eq!(cloned, u);\n    };\n    test(Union2::A(vec![]));\n    test(Union2::A(vec!['a', 'b', 'c']));\n    test(Union2::B(5));\n}\n\n#[test]\nfn test_clone_from() {\n    let test = |mut u: Union2<Vec<char>, u32>, v: Union2<Vec<char>, u32>| {\n        u.clone_from(&v);\n        assert_eq!(u, v);\n    };\n    test(Union2::A(vec!['a', 'b', 'c']), Union2::A(vec![]));\n    test(Union2::A(vec![]), Union2::A(vec!['a', 'b', 'c']));\n    test(Union2::B(5), Union2::B(6));\n    test(Union2::A(vec!['a', 'b', 'c']), Union2::B(6));\n    test(Union2::B(6), Union2::A(vec!['a', 'b', 'c']));\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/debug.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::unions::Union2;\n\n#[test]\nfn test_to_debug() {\n    let test = |u: Union2<Vec<char>, u32>, out| {\n        assert_eq!(u.to_debug_string(), out);\n    };\n    test(Union2::A(vec![]), \"A([])\");\n    test(Union2::A(vec!['a', 'b', 'c']), \"A(['a', 'b', 'c'])\");\n    test(Union2::B(5), \"B(5)\");\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/display.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\n\n#[test]\nfn test_to_string() {\n    let test = |u: Union3<char, u32, bool>, out| {\n        assert_eq!(u.to_string(), out);\n    };\n    test(Union3::A('a'), \"A(a)\");\n    test(Union3::B(5), \"B(5)\");\n    test(Union3::C(false), \"C(false)\");\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\nuse malachite_base::test_util::common::test_eq_helper;\n\n#[test]\nfn test_eq() {\n    test_eq_helper::<Union3<char, u32, bool>>(&[\n        \"B(8)\", \"A(d)\", \"C(true)\", \"B(5)\", \"C(false)\", \"A(a)\",\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/exhaustive/exhaustive_unions.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\nuse crate::extra_variadic::exhaustive_union3s;\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::options::exhaustive::exhaustive_somes;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::unions::Union2;\nuse malachite_base::unions::exhaustive::exhaustive_union2s;\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::once;\n\nfn exhaustive_union2s_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[Union2<X, Y>],\n) {\n    let us = exhaustive_union2s(xs, ys);\n    let us_prefix = us.clone().take(20).collect_vec();\n    assert_eq!(us_prefix.as_slice(), out);\n    assert_eq!(us.count(), out_len);\n}\n\n#[test]\nfn test_exhaustive_union2s() {\n    exhaustive_union2s_helper(nevers(), nevers(), 0, &[]);\n    exhaustive_union2s_helper(\n        nevers(),\n        0..4,\n        4,\n        &[Union2::B(0), Union2::B(1), Union2::B(2), Union2::B(3)],\n    );\n    exhaustive_union2s_helper(once('a'), once(1), 2, &[Union2::A('a'), Union2::B(1)]);\n    exhaustive_union2s_helper(\n        once('a'),\n        0..4,\n        5,\n        &[Union2::A('a'), Union2::B(0), Union2::B(1), Union2::B(2), Union2::B(3)],\n    );\n    exhaustive_union2s_helper(\n        'a'..'e',\n        exhaustive_unsigneds::<u8>(),\n        260,\n        &[\n            Union2::A('a'),\n            Union2::B(0),\n            Union2::A('b'),\n            Union2::B(1),\n            Union2::A('c'),\n            Union2::B(2),\n            Union2::A('d'),\n            Union2::B(3),\n            Union2::B(4),\n            Union2::B(5),\n            Union2::B(6),\n            Union2::B(7),\n            Union2::B(8),\n            Union2::B(9),\n            Union2::B(10),\n            Union2::B(11),\n            Union2::B(12),\n            Union2::B(13),\n            Union2::B(14),\n            Union2::B(15),\n        ],\n    );\n    exhaustive_union2s_helper(\n        exhaustive_bools(),\n        0..4,\n        6,\n        &[\n            Union2::A(false),\n            Union2::B(0),\n            Union2::A(true),\n            Union2::B(1),\n            Union2::B(2),\n            Union2::B(3),\n        ],\n    );\n    exhaustive_union2s_helper(\n        'a'..'f',\n        0..3,\n        8,\n        &[\n            Union2::A('a'),\n            Union2::B(0),\n            Union2::A('b'),\n            Union2::B(1),\n            Union2::A('c'),\n            Union2::B(2),\n            Union2::A('d'),\n            Union2::A('e'),\n        ],\n    );\n    exhaustive_union2s_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        6,\n        &[\n            Union2::A('a'),\n            Union2::B(Equal),\n            Union2::A('b'),\n            Union2::B(Less),\n            Union2::A('c'),\n            Union2::B(Greater),\n        ],\n    );\n}\n\nfn exhaustive_union3s_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n    Z: Clone + Debug + Eq,\n    K: Clone + Iterator<Item = Z>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out_len: usize,\n    out: &[Union3<X, Y, Z>],\n) {\n    let ts = exhaustive_union3s(xs, ys, zs);\n    let ts_prefix = ts.clone().take(20).collect_vec();\n    assert_eq!(ts_prefix.as_slice(), out);\n    assert_eq!(ts.count(), out_len);\n}\n\n#[test]\nfn test_exhaustive_union3s() {\n    exhaustive_union3s_helper(nevers(), nevers(), nevers(), 0, &[]);\n    exhaustive_union3s_helper(\n        nevers(),\n        0..4,\n        'a'..'f',\n        9,\n        &[\n            Union3::B(0),\n            Union3::C('a'),\n            Union3::B(1),\n            Union3::C('b'),\n            Union3::B(2),\n            Union3::C('c'),\n            Union3::B(3),\n            Union3::C('d'),\n            Union3::C('e'),\n        ],\n    );\n    exhaustive_union3s_helper(\n        once('a'),\n        once(false),\n        once(5),\n        3,\n        &[Union3::A('a'), Union3::B(false), Union3::C(5)],\n    );\n    exhaustive_union3s_helper(\n        once('a'),\n        once(false),\n        0..4,\n        6,\n        &[Union3::A('a'), Union3::B(false), Union3::C(0), Union3::C(1), Union3::C(2), Union3::C(3)],\n    );\n    exhaustive_union3s_helper(\n        exhaustive_bools(),\n        0..3,\n        'a'..'d',\n        8,\n        &[\n            Union3::A(false),\n            Union3::B(0),\n            Union3::C('a'),\n            Union3::A(true),\n            Union3::B(1),\n            Union3::C('b'),\n            Union3::B(2),\n            Union3::C('c'),\n        ],\n    );\n    exhaustive_union3s_helper(\n        0..11,\n        exhaustive_somes(0..12),\n        'a'..'n',\n        36,\n        &[\n            Union3::A(0),\n            Union3::B(Some(0)),\n            Union3::C('a'),\n            Union3::A(1),\n            Union3::B(Some(1)),\n            Union3::C('b'),\n            Union3::A(2),\n            Union3::B(Some(2)),\n            Union3::C('c'),\n            Union3::A(3),\n            Union3::B(Some(3)),\n            Union3::C('d'),\n            Union3::A(4),\n            Union3::B(Some(4)),\n            Union3::C('e'),\n            Union3::A(5),\n            Union3::B(Some(5)),\n            Union3::C('f'),\n            Union3::A(6),\n            Union3::B(Some(6)),\n        ],\n    );\n    exhaustive_union3s_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        [\"xx\", \"yy\", \"zz\"].iter().copied(),\n        0..3,\n        9,\n        &[\n            Union3::A('a'),\n            Union3::B(\"xx\"),\n            Union3::C(0),\n            Union3::A('b'),\n            Union3::B(\"yy\"),\n            Union3::C(1),\n            Union3::A('c'),\n            Union3::B(\"zz\"),\n            Union3::C(2),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/exhaustive/lex_unions.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\nuse crate::extra_variadic::lex_union3s;\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::options::exhaustive::exhaustive_somes;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::unions::Union2;\nuse malachite_base::unions::exhaustive::lex_union2s;\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::once;\n\nfn lex_union2s_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[Union2<X, Y>],\n) {\n    let us = lex_union2s(xs, ys);\n    let us_prefix = us.clone().take(20).collect_vec();\n    assert_eq!(us_prefix.as_slice(), out);\n    assert_eq!(us.count(), out_len);\n}\n\n#[test]\nfn test_lex_union2s() {\n    lex_union2s_helper(nevers(), nevers(), 0, &[]);\n    lex_union2s_helper(\n        nevers(),\n        0..4,\n        4,\n        &[Union2::B(0), Union2::B(1), Union2::B(2), Union2::B(3)],\n    );\n    lex_union2s_helper(once('a'), once(1), 2, &[Union2::A('a'), Union2::B(1)]);\n    lex_union2s_helper(\n        once('a'),\n        0..4,\n        5,\n        &[Union2::A('a'), Union2::B(0), Union2::B(1), Union2::B(2), Union2::B(3)],\n    );\n    lex_union2s_helper(\n        'a'..'e',\n        exhaustive_unsigneds::<u8>(),\n        260,\n        &[\n            Union2::A('a'),\n            Union2::A('b'),\n            Union2::A('c'),\n            Union2::A('d'),\n            Union2::B(0),\n            Union2::B(1),\n            Union2::B(2),\n            Union2::B(3),\n            Union2::B(4),\n            Union2::B(5),\n            Union2::B(6),\n            Union2::B(7),\n            Union2::B(8),\n            Union2::B(9),\n            Union2::B(10),\n            Union2::B(11),\n            Union2::B(12),\n            Union2::B(13),\n            Union2::B(14),\n            Union2::B(15),\n        ],\n    );\n    lex_union2s_helper(\n        exhaustive_bools(),\n        0..4,\n        6,\n        &[\n            Union2::A(false),\n            Union2::A(true),\n            Union2::B(0),\n            Union2::B(1),\n            Union2::B(2),\n            Union2::B(3),\n        ],\n    );\n    lex_union2s_helper(\n        'a'..'f',\n        0..3,\n        8,\n        &[\n            Union2::A('a'),\n            Union2::A('b'),\n            Union2::A('c'),\n            Union2::A('d'),\n            Union2::A('e'),\n            Union2::B(0),\n            Union2::B(1),\n            Union2::B(2),\n        ],\n    );\n    lex_union2s_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        exhaustive_orderings(),\n        6,\n        &[\n            Union2::A('a'),\n            Union2::A('b'),\n            Union2::A('c'),\n            Union2::B(Equal),\n            Union2::B(Less),\n            Union2::B(Greater),\n        ],\n    );\n}\n\nfn lex_union3s_helper<\n    X: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq,\n    J: Clone + Iterator<Item = Y>,\n    Z: Clone + Debug + Eq,\n    K: Clone + Iterator<Item = Z>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out_len: usize,\n    out: &[Union3<X, Y, Z>],\n) {\n    let ts = lex_union3s(xs, ys, zs);\n    let ts_prefix = ts.clone().take(20).collect_vec();\n    assert_eq!(ts_prefix.as_slice(), out);\n    assert_eq!(ts.count(), out_len);\n}\n\n#[test]\nfn test_lex_union3s() {\n    lex_union3s_helper(nevers(), nevers(), nevers(), 0, &[]);\n    lex_union3s_helper(\n        nevers(),\n        0..4,\n        'a'..'f',\n        9,\n        &[\n            Union3::B(0),\n            Union3::B(1),\n            Union3::B(2),\n            Union3::B(3),\n            Union3::C('a'),\n            Union3::C('b'),\n            Union3::C('c'),\n            Union3::C('d'),\n            Union3::C('e'),\n        ],\n    );\n    lex_union3s_helper(\n        once('a'),\n        once(false),\n        once(5),\n        3,\n        &[Union3::A('a'), Union3::B(false), Union3::C(5)],\n    );\n    lex_union3s_helper(\n        once('a'),\n        once(false),\n        0..4,\n        6,\n        &[Union3::A('a'), Union3::B(false), Union3::C(0), Union3::C(1), Union3::C(2), Union3::C(3)],\n    );\n    lex_union3s_helper(\n        exhaustive_bools(),\n        0..3,\n        'a'..'d',\n        8,\n        &[\n            Union3::A(false),\n            Union3::A(true),\n            Union3::B(0),\n            Union3::B(1),\n            Union3::B(2),\n            Union3::C('a'),\n            Union3::C('b'),\n            Union3::C('c'),\n        ],\n    );\n    lex_union3s_helper(\n        0..11,\n        exhaustive_somes(0..12),\n        'a'..'n',\n        36,\n        &[\n            Union3::A(0),\n            Union3::A(1),\n            Union3::A(2),\n            Union3::A(3),\n            Union3::A(4),\n            Union3::A(5),\n            Union3::A(6),\n            Union3::A(7),\n            Union3::A(8),\n            Union3::A(9),\n            Union3::A(10),\n            Union3::B(Some(0)),\n            Union3::B(Some(1)),\n            Union3::B(Some(2)),\n            Union3::B(Some(3)),\n            Union3::B(Some(4)),\n            Union3::B(Some(5)),\n            Union3::B(Some(6)),\n            Union3::B(Some(7)),\n            Union3::B(Some(8)),\n        ],\n    );\n    lex_union3s_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        [\"xx\", \"yy\", \"zz\"].iter().copied(),\n        0..3,\n        9,\n        &[\n            Union3::A('a'),\n            Union3::A('b'),\n            Union3::A('c'),\n            Union3::B(\"xx\"),\n            Union3::B(\"yy\"),\n            Union3::B(\"zz\"),\n            Union3::C(0),\n            Union3::C(1),\n            Union3::C(2),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\nuse malachite_base::unions::UnionFromStrError;\nuse std::result::Result;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_str() {\n    let test = |s, out| {\n        assert_eq!(Union3::from_str(s), out);\n    };\n    test(\"A(a)\", Ok(Union3::A('a')));\n    test(\"B(5)\", Ok(Union3::B(5)));\n    test(\"C(false)\", Ok(Union3::C(false)));\n\n    test(\"\", Err(UnionFromStrError::Generic(String::new())));\n    test(\"xyz\", Err(UnionFromStrError::Generic(\"xyz\".to_string())));\n    test(\"D(a)\", Err(UnionFromStrError::Generic(\"D(a)\".to_string())));\n    test(\"A(a\", Err(UnionFromStrError::Generic(\"A(a\".to_string())));\n\n    let result: Result<Union3<char, u32, bool>, _> = Union3::from_str(\"A(ab)\");\n    if let Err(UnionFromStrError::Specific(Union3::A(_e))) = result {\n    } else {\n        panic!(\"wrong error variant\")\n    }\n\n    let result: Result<Union3<char, u32, bool>, _> = Union3::from_str(\"B(-1)\");\n    if let Err(UnionFromStrError::Specific(Union3::B(_e))) = result {\n    } else {\n        panic!(\"wrong error variant\")\n    }\n\n    let result: Result<Union3<char, u32, bool>, _> = Union3::from_str(\"C(tralse)\");\n    if let Err(UnionFromStrError::Specific(Union3::C(_e))) = result {\n    } else {\n        panic!(\"wrong error variant\")\n    }\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/ord.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\nuse malachite_base::test_util::common::test_cmp_helper;\n\n#[test]\nfn test_cmp() {\n    test_cmp_helper::<Union3<char, u32, bool>>(&[\n        \"A(a)\", \"A(d)\", \"B(5)\", \"B(8)\", \"C(false)\", \"C(true)\",\n    ]);\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/random/random_unions.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\nuse crate::extra_variadic::random_union3s;\nuse core::hash::Hash;\nuse itertools::Itertools;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_unsigned_inclusive_range;\nuse malachite_base::orderings::random::random_orderings;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::strings::random::random_strings_using_chars;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::unions::Union2;\nuse malachite_base::unions::random::random_union2s;\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\n\nfn random_union2s_helper<\n    X: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq + Hash + Ord,\n    J: Clone + Iterator<Item = Y>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[Union2<X, Y>],\n    expected_common_values: &[(Union2<X, Y>, usize)],\n    expected_median: (Union2<X, Y>, Option<Union2<X, Y>>),\n) {\n    let us = random_union2s(EXAMPLE_SEED, xs_gen, ys_gen);\n    let values = us.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, us.clone());\n    let median = median(us.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_union2s() {\n    random_union2s_helper(\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &|seed| random_unsigned_inclusive_range::<u32>(seed, 1, 10),\n        &[\n            Union2::A('v'),\n            Union2::B(3),\n            Union2::A('c'),\n            Union2::A('q'),\n            Union2::A('i'),\n            Union2::A('e'),\n            Union2::A('p'),\n            Union2::A('g'),\n            Union2::A('s'),\n            Union2::B(7),\n            Union2::A('n'),\n            Union2::A('t'),\n            Union2::B(9),\n            Union2::A('m'),\n            Union2::A('z'),\n            Union2::B(7),\n            Union2::B(9),\n            Union2::A('o'),\n            Union2::A('m'),\n            Union2::B(3),\n        ],\n        &[\n            (Union2::B(5), 50535),\n            (Union2::B(4), 50190),\n            (Union2::B(10), 50183),\n            (Union2::B(3), 50068),\n            (Union2::B(9), 50064),\n            (Union2::B(6), 50002),\n            (Union2::B(2), 49882),\n            (Union2::B(1), 49807),\n            (Union2::B(7), 49533),\n            (Union2::B(8), 49495),\n        ],\n        (Union2::A('z'), None),\n    );\n    random_union2s_helper(\n        &random_bools,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 4, 1),\n        &[\n            Union2::A(true),\n            Union2::B(6),\n            Union2::A(false),\n            Union2::A(true),\n            Union2::A(false),\n            Union2::A(true),\n            Union2::A(false),\n            Union2::A(true),\n            Union2::A(false),\n            Union2::B(0),\n            Union2::A(true),\n            Union2::A(true),\n            Union2::B(2),\n            Union2::A(false),\n            Union2::A(true),\n            Union2::B(2),\n            Union2::B(2),\n            Union2::A(false),\n            Union2::A(false),\n            Union2::B(8),\n        ],\n        &[\n            (Union2::A(false), 250462),\n            (Union2::A(true), 249779),\n            (Union2::B(0), 100190),\n            (Union2::B(1), 79510),\n            (Union2::B(2), 63929),\n            (Union2::B(3), 51260),\n            (Union2::B(4), 41099),\n            (Union2::B(5), 32494),\n            (Union2::B(6), 26037),\n            (Union2::B(7), 21139),\n        ],\n        (Union2::A(true), None),\n    );\n}\n\n#[allow(clippy::type_complexity)]\nfn random_union3s_helper<\n    X: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = X>,\n    Y: Clone + Debug + Eq + Hash + Ord,\n    J: Clone + Iterator<Item = Y>,\n    Z: Clone + Debug + Eq + Hash + Ord,\n    K: Clone + Iterator<Item = Z>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    zs_gen: &dyn Fn(Seed) -> K,\n    expected_values: &[Union3<X, Y, Z>],\n    expected_common_values: &[(Union3<X, Y, Z>, usize)],\n    expected_median: (Union3<X, Y, Z>, Option<Union3<X, Y, Z>>),\n) {\n    let us = random_union3s(EXAMPLE_SEED, xs_gen, ys_gen, zs_gen);\n    let values = us.clone().take(20).collect_vec();\n    let common_values = common_values_map_debug(1000000, 10, us.clone());\n    let median = median(us.take(1000000));\n    assert_eq!(\n        (values.as_slice(), common_values.as_slice(), median),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_union3s() {\n    random_union3s_helper(\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &|seed| random_unsigned_inclusive_range::<u32>(seed, 1, 10),\n        &random_orderings,\n        &[\n            Union3::C(Equal),\n            Union3::A('v'),\n            Union3::A('c'),\n            Union3::A('q'),\n            Union3::C(Greater),\n            Union3::A('i'),\n            Union3::B(3),\n            Union3::C(Greater),\n            Union3::B(7),\n            Union3::C(Greater),\n            Union3::C(Greater),\n            Union3::C(Greater),\n            Union3::B(9),\n            Union3::C(Equal),\n            Union3::A('e'),\n            Union3::A('p'),\n            Union3::A('g'),\n            Union3::A('s'),\n            Union3::C(Equal),\n            Union3::A('n'),\n        ],\n        &[\n            (Union3::C(Less), 111378),\n            (Union3::C(Greater), 111191),\n            (Union3::C(Equal), 110903),\n            (Union3::B(5), 33724),\n            (Union3::B(10), 33503),\n            (Union3::B(4), 33375),\n            (Union3::B(9), 33348),\n            (Union3::B(2), 33347),\n            (Union3::B(6), 33288),\n            (Union3::B(7), 33283),\n        ],\n        (Union3::B(5), None),\n    );\n    random_union3s_helper(\n        &random_bools,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 4, 1),\n        &|seed| {\n            random_strings_using_chars(\n                seed,\n                &|seed_2| random_char_inclusive_range(seed_2, 'a', 'z'),\n                4,\n                1,\n            )\n        },\n        &[\n            Union3::C(\"qvfm\".to_string()),\n            Union3::A(true),\n            Union3::A(false),\n            Union3::A(true),\n            Union3::C(\"kt\".to_string()),\n            Union3::A(false),\n            Union3::B(6),\n            Union3::C(\"auqoox\".to_string()),\n            Union3::B(0),\n            Union3::C(\"ak\".to_string()),\n            Union3::C(\"\".to_string()),\n            Union3::C(\"dz\".to_string()),\n            Union3::B(2),\n            Union3::C(\"ebaq\".to_string()),\n            Union3::A(true),\n            Union3::A(false),\n            Union3::A(true),\n            Union3::A(false),\n            Union3::C(\"gvqmloscuftfzjrn\".to_string()),\n            Union3::A(true),\n        ],\n        &[\n            (Union3::A(false), 166833),\n            (Union3::A(true), 166495),\n            (Union3::B(0), 66610),\n            (Union3::C(\"\".to_string()), 66483),\n            (Union3::B(1), 53004),\n            (Union3::B(2), 42754),\n            (Union3::B(3), 34312),\n            (Union3::B(4), 27360),\n            (Union3::B(5), 21599),\n            (Union3::B(6), 17332),\n        ],\n        (Union3::B(3), None),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/unions/unwrap.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::Union3;\n\n#[test]\nfn test_unwrap() {\n    let test = |u: Union3<char, char, char>, out| {\n        assert_eq!(u.unwrap(), out);\n    };\n    test(Union3::A('a'), 'a');\n    test(Union3::B('b'), 'b');\n    test(Union3::C('c'), 'c');\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_combined_k_compositions.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::vecs::exhaustive::exhaustive_combined_k_compositions;\n\nfn exhaustive_combined_k_compositions_helper(\n    n_min: usize,\n    n_max: usize,\n    k: usize,\n    out: &[&[usize]],\n) {\n    let xss = exhaustive_combined_k_compositions(n_min, n_max, k).collect_vec();\n    assert_eq!(xss.iter().map(Vec::as_slice).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_exhaustive_combined_k_compositions() {\n    exhaustive_combined_k_compositions_helper(\n        3,\n        5,\n        3,\n        &[\n            &[1, 1, 1],\n            &[1, 1, 2],\n            &[1, 2, 1],\n            &[2, 1, 1],\n            &[1, 1, 3],\n            &[1, 2, 2],\n            &[1, 3, 1],\n            &[2, 1, 2],\n            &[2, 2, 1],\n            &[3, 1, 1],\n        ],\n    );\n    exhaustive_combined_k_compositions_helper(\n        6,\n        8,\n        5,\n        &[\n            &[1, 1, 1, 1, 2],\n            &[1, 1, 1, 1, 3],\n            &[1, 1, 1, 2, 1],\n            &[1, 1, 1, 1, 4],\n            &[1, 1, 2, 1, 1],\n            &[1, 1, 1, 2, 2],\n            &[1, 2, 1, 1, 1],\n            &[2, 1, 1, 1, 1],\n            &[1, 1, 1, 3, 1],\n            &[1, 1, 1, 2, 3],\n            &[1, 1, 2, 1, 2],\n            &[1, 1, 2, 2, 1],\n            &[1, 1, 3, 1, 1],\n            &[1, 1, 1, 3, 2],\n            &[1, 2, 1, 1, 2],\n            &[1, 2, 1, 2, 1],\n            &[1, 2, 2, 1, 1],\n            &[1, 1, 1, 4, 1],\n            &[1, 3, 1, 1, 1],\n            &[2, 1, 1, 1, 2],\n            &[2, 1, 1, 2, 1],\n            &[1, 1, 2, 1, 3],\n            &[2, 1, 2, 1, 1],\n            &[1, 1, 2, 2, 2],\n            &[2, 2, 1, 1, 1],\n            &[1, 1, 2, 3, 1],\n            &[3, 1, 1, 1, 1],\n            &[1, 1, 3, 1, 2],\n            &[1, 1, 3, 2, 1],\n            &[1, 1, 4, 1, 1],\n            &[1, 2, 1, 1, 3],\n            &[1, 2, 1, 2, 2],\n            &[1, 2, 1, 3, 1],\n            &[1, 2, 2, 1, 2],\n            &[1, 2, 2, 2, 1],\n            &[1, 2, 3, 1, 1],\n            &[1, 3, 1, 1, 2],\n            &[1, 3, 1, 2, 1],\n            &[1, 3, 2, 1, 1],\n            &[1, 4, 1, 1, 1],\n            &[2, 1, 1, 1, 3],\n            &[2, 1, 1, 2, 2],\n            &[2, 1, 1, 3, 1],\n            &[2, 1, 2, 1, 2],\n            &[2, 1, 2, 2, 1],\n            &[2, 1, 3, 1, 1],\n            &[2, 2, 1, 1, 2],\n            &[2, 2, 1, 2, 1],\n            &[2, 2, 2, 1, 1],\n            &[2, 3, 1, 1, 1],\n            &[3, 1, 1, 1, 2],\n            &[3, 1, 1, 2, 1],\n            &[3, 1, 2, 1, 1],\n            &[3, 2, 1, 1, 1],\n            &[4, 1, 1, 1, 1],\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_combined_k_compositions_fail() {\n    exhaustive_combined_k_compositions(2, 1, 3);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_ordered_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs;\nuse std::fmt::Debug;\n\nfn exhaustive_ordered_unique_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_ordered_unique_vecs(xs), out);\n}\n\nfn exhaustive_ordered_unique_vecs_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(exhaustive_ordered_unique_vecs(xs), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_ordered_unique_vecs() {\n    exhaustive_ordered_unique_vecs_small_helper(nevers(), 1, &[&[]]);\n    exhaustive_ordered_unique_vecs_small_helper(exhaustive_units(), 2, &[&[], &[()]]);\n    exhaustive_ordered_unique_vecs_small_helper(\n        exhaustive_bools(),\n        4,\n        &[&[], &[false], &[true], &[false, true]],\n    );\n    exhaustive_ordered_unique_vecs_small_helper(\n        1..=6,\n        64,\n        &[\n            &[],\n            &[1],\n            &[2],\n            &[1, 2],\n            &[3],\n            &[1, 3],\n            &[2, 3],\n            &[1, 2, 3],\n            &[4],\n            &[1, 4],\n            &[2, 4],\n            &[1, 2, 4],\n            &[3, 4],\n            &[1, 3, 4],\n            &[2, 3, 4],\n            &[1, 2, 3, 4],\n            &[5],\n            &[1, 5],\n            &[2, 5],\n            &[1, 2, 5],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_small_helper(\n        'a'..='c',\n        8,\n        &[&[], &['a'], &['b'], &['a', 'b'], &['c'], &['a', 'c'], &['b', 'c'], &['a', 'b', 'c']],\n    );\n    exhaustive_ordered_unique_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['a', 'b'],\n            &['c'],\n            &['a', 'c'],\n            &['b', 'c'],\n            &['a', 'b', 'c'],\n            &['d'],\n            &['a', 'd'],\n            &['b', 'd'],\n            &['a', 'b', 'd'],\n            &['c', 'd'],\n            &['a', 'c', 'd'],\n            &['b', 'c', 'd'],\n            &['a', 'b', 'c', 'd'],\n            &['e'],\n            &['a', 'e'],\n            &['b', 'e'],\n            &['a', 'b', 'e'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_ordered_unique_vecs_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_fixed_length;\nuse std::fmt::Debug;\n\nfn exhaustive_ordered_unique_vecs_fixed_length_helper<I: Iterator>(\n    len: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_ordered_unique_vecs_fixed_length(len, xs), out);\n}\n\nfn exhaustive_ordered_unique_vecs_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_ordered_unique_vecs_fixed_length(len, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_ordered_unique_vecs_fixed_length() {\n    // This demonstrates that 0 ^ 0 == 1:\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(0, nevers(), 1, &[&[]]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(1, nevers(), 0, &[]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(2, nevers(), 0, &[]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(5, nevers(), 0, &[]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(1, exhaustive_units(), 1, &[&[()]]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(\n        0,\n        exhaustive_unsigneds::<u8>(),\n        1,\n        &[&[]],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            &[0, 1],\n            &[0, 2],\n            &[1, 2],\n            &[0, 3],\n            &[1, 3],\n            &[2, 3],\n            &[0, 4],\n            &[1, 4],\n            &[2, 4],\n            &[3, 4],\n            &[0, 5],\n            &[1, 5],\n            &[2, 5],\n            &[3, 5],\n            &[4, 5],\n            &[0, 6],\n            &[1, 6],\n            &[2, 6],\n            &[3, 6],\n            &[4, 6],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[0, 2, 3],\n            &[1, 2, 3],\n            &[0, 1, 4],\n            &[0, 2, 4],\n            &[1, 2, 4],\n            &[0, 3, 4],\n            &[1, 3, 4],\n            &[2, 3, 4],\n            &[0, 1, 5],\n            &[0, 2, 5],\n            &[1, 2, 5],\n            &[0, 3, 5],\n            &[1, 3, 5],\n            &[2, 3, 5],\n            &[0, 4, 5],\n            &[1, 4, 5],\n            &[2, 4, 5],\n            &[3, 4, 5],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'c'],\n            &['a', 'd'],\n            &['b', 'd'],\n            &['c', 'd'],\n            &['a', 'e'],\n            &['b', 'e'],\n            &['c', 'e'],\n            &['d', 'e'],\n            &['a', 'f'],\n            &['b', 'f'],\n            &['c', 'f'],\n            &['d', 'f'],\n            &['e', 'f'],\n            &['a', 'g'],\n            &['b', 'g'],\n            &['c', 'g'],\n            &['d', 'g'],\n            &['e', 'g'],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[&[false], &[true]],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_bools(),\n        1,\n        &[&[false, true]],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    exhaustive_ordered_unique_vecs_fixed_length_small_helper(\n        4,\n        1..=6,\n        15,\n        &[\n            &[1, 2, 3, 4],\n            &[1, 2, 3, 5],\n            &[1, 2, 4, 5],\n            &[1, 3, 4, 5],\n            &[2, 3, 4, 5],\n            &[1, 2, 3, 6],\n            &[1, 2, 4, 6],\n            &[1, 3, 4, 6],\n            &[2, 3, 4, 6],\n            &[1, 2, 5, 6],\n            &[1, 3, 5, 6],\n            &[2, 3, 5, 6],\n            &[1, 4, 5, 6],\n            &[2, 4, 5, 6],\n            &[3, 4, 5, 6],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_fixed_length_helper(\n        2,\n        exhaustive_ordered_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            &[vec![0, 1], vec![0, 2]],\n            &[vec![0, 1], vec![1, 2]],\n            &[vec![0, 2], vec![1, 2]],\n            &[vec![0, 1], vec![0, 3]],\n            &[vec![0, 2], vec![0, 3]],\n            &[vec![1, 2], vec![0, 3]],\n            &[vec![0, 1], vec![1, 3]],\n            &[vec![0, 2], vec![1, 3]],\n            &[vec![1, 2], vec![1, 3]],\n            &[vec![0, 3], vec![1, 3]],\n            &[vec![0, 1], vec![2, 3]],\n            &[vec![0, 2], vec![2, 3]],\n            &[vec![1, 2], vec![2, 3]],\n            &[vec![0, 3], vec![2, 3]],\n            &[vec![1, 3], vec![2, 3]],\n            &[vec![0, 1], vec![0, 4]],\n            &[vec![0, 2], vec![0, 4]],\n            &[vec![1, 2], vec![0, 4]],\n            &[vec![0, 3], vec![0, 4]],\n            &[vec![1, 3], vec![0, 4]],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_ordered_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_ordered_unique_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_ordered_unique_vecs_length_inclusive_range() {\n    exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[&[], &[()]],\n    );\n    exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        0,\n        exhaustive_bools(),\n        0,\n        &[],\n    );\n    exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[&[false, true]],\n    );\n    exhaustive_ordered_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_ordered_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn exhaustive_ordered_unique_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_ordered_unique_vecs_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_ordered_unique_vecs_length_range() {\n    exhaustive_ordered_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    exhaustive_ordered_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    exhaustive_ordered_unique_vecs_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[&[], &[()]],\n    );\n    exhaustive_ordered_unique_vecs_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    exhaustive_ordered_unique_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    exhaustive_ordered_unique_vecs_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    exhaustive_ordered_unique_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[&[false, true]],\n    );\n    exhaustive_ordered_unique_vecs_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_ordered_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_ordered_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn exhaustive_ordered_unique_vecs_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(\n        exhaustive_ordered_unique_vecs_min_length(min_length, xs),\n        out,\n    );\n}\n\nfn exhaustive_ordered_unique_vecs_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_ordered_unique_vecs_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_ordered_unique_vecs_min_length() {\n    exhaustive_ordered_unique_vecs_min_length_small_helper(0, nevers(), 1, &[&[]]);\n    exhaustive_ordered_unique_vecs_min_length_small_helper(4, nevers(), 0, &[]);\n    exhaustive_ordered_unique_vecs_min_length_small_helper(0, exhaustive_units(), 2, &[&[], &[()]]);\n    exhaustive_ordered_unique_vecs_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_ordered_unique_vecs_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[&[], &[false], &[true], &[false, true]],\n    );\n    exhaustive_ordered_unique_vecs_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[false], &[true], &[false, true]],\n    );\n    exhaustive_ordered_unique_vecs_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[&[], &['a'], &['b'], &['a', 'b'], &['c'], &['a', 'c'], &['b', 'c'], &['a', 'b', 'c']],\n    );\n    exhaustive_ordered_unique_vecs_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[&['a', 'b'], &['a', 'c'], &['b', 'c'], &['a', 'b', 'c']],\n    );\n    exhaustive_ordered_unique_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['a', 'b'],\n            &['c'],\n            &['a', 'c'],\n            &['b', 'c'],\n            &['a', 'b', 'c'],\n            &['d'],\n            &['a', 'd'],\n            &['b', 'd'],\n            &['a', 'b', 'd'],\n            &['c', 'd'],\n            &['a', 'c', 'd'],\n            &['b', 'c', 'd'],\n            &['a', 'b', 'c', 'd'],\n            &['e'],\n            &['a', 'e'],\n            &['b', 'e'],\n            &['a', 'b', 'e'],\n        ],\n    );\n    exhaustive_ordered_unique_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'b', 'c'],\n            &['a', 'b', 'd'],\n            &['a', 'c', 'd'],\n            &['b', 'c', 'd'],\n            &['a', 'b', 'c', 'd'],\n            &['a', 'b', 'e'],\n            &['a', 'c', 'e'],\n            &['b', 'c', 'e'],\n            &['a', 'b', 'c', 'e'],\n            &['a', 'd', 'e'],\n            &['b', 'd', 'e'],\n            &['a', 'b', 'd', 'e'],\n            &['c', 'd', 'e'],\n            &['a', 'c', 'd', 'e'],\n            &['b', 'c', 'd', 'e'],\n            &['a', 'b', 'c', 'd', 'e'],\n            &['a', 'b', 'f'],\n            &['a', 'c', 'f'],\n            &['b', 'c', 'f'],\n            &['a', 'b', 'c', 'f'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_unique_vecs;\nuse std::fmt::Debug;\n\nfn exhaustive_unique_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_unique_vecs(xs), out);\n}\n\nfn exhaustive_unique_vecs_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(exhaustive_unique_vecs(xs), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_unique_vecs() {\n    exhaustive_unique_vecs_small_helper(nevers(), 1, &[&[]]);\n    exhaustive_unique_vecs_small_helper(exhaustive_units(), 2, &[&[], &[()]]);\n    exhaustive_unique_vecs_small_helper(\n        exhaustive_bools(),\n        5,\n        &[&[], &[false], &[true], &[false, true], &[true, false]],\n    );\n    exhaustive_unique_vecs_small_helper(\n        1..=6,\n        1957,\n        &[\n            &[],\n            &[1],\n            &[2],\n            &[3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 1],\n            &[1, 2, 3],\n            &[3, 1],\n            &[2, 3],\n            &[3, 2],\n            &[4],\n            &[1, 3, 2],\n            &[1, 4],\n            &[2, 1, 3],\n            &[3, 4],\n            &[2, 3, 1],\n            &[4, 1],\n            &[3, 1, 2],\n            &[2, 4],\n        ],\n    );\n    exhaustive_unique_vecs_small_helper(\n        'a'..='c',\n        16,\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['a', 'b', 'c'],\n            &['c', 'a'],\n            &['b', 'c'],\n            &['c', 'b'],\n            &['a', 'c', 'b'],\n            &['b', 'a', 'c'],\n            &['b', 'c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    exhaustive_unique_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['a', 'b', 'c'],\n            &['c', 'a'],\n            &['b', 'c'],\n            &['c', 'b'],\n            &['d'],\n            &['a', 'c', 'b'],\n            &['a', 'd'],\n            &['b', 'a', 'c'],\n            &['c', 'd'],\n            &['b', 'c', 'a'],\n            &['d', 'a'],\n            &['c', 'a', 'b'],\n            &['b', 'd'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_unique_vecs_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_unique_vecs_fixed_length;\nuse std::fmt::Debug;\n\nfn exhaustive_unique_vecs_fixed_length_helper<I: Iterator>(len: u64, xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_unique_vecs_fixed_length(len, xs), out);\n}\n\nfn exhaustive_unique_vecs_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(exhaustive_unique_vecs_fixed_length(len, xs), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_unique_vecs_fixed_length() {\n    // This demonstrates that 0 ^ 0 == 1:\n    exhaustive_unique_vecs_fixed_length_small_helper(0, nevers(), 1, &[&[]]);\n    exhaustive_unique_vecs_fixed_length_small_helper(1, nevers(), 0, &[]);\n    exhaustive_unique_vecs_fixed_length_small_helper(2, nevers(), 0, &[]);\n    exhaustive_unique_vecs_fixed_length_small_helper(5, nevers(), 0, &[]);\n    exhaustive_unique_vecs_fixed_length_small_helper(1, exhaustive_units(), 1, &[&[()]]);\n    exhaustive_unique_vecs_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    exhaustive_unique_vecs_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_unique_vecs_fixed_length_small_helper(0, exhaustive_unsigneds::<u8>(), 1, &[&[]]);\n    exhaustive_unique_vecs_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    exhaustive_unique_vecs_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    exhaustive_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        65280,\n        &[\n            &[0, 1],\n            &[1, 0],\n            &[0, 2],\n            &[2, 0],\n            &[1, 2],\n            &[2, 1],\n            &[0, 3],\n            &[3, 0],\n            &[1, 3],\n            &[3, 1],\n            &[2, 3],\n            &[3, 2],\n            &[0, 4],\n            &[4, 0],\n            &[1, 4],\n            &[4, 1],\n            &[2, 4],\n            &[4, 2],\n            &[3, 4],\n            &[4, 3],\n        ],\n    );\n    exhaustive_unique_vecs_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[0, 2, 1],\n            &[0, 2, 3],\n            &[1, 0, 2],\n            &[0, 3, 1],\n            &[1, 2, 0],\n            &[1, 2, 3],\n            &[2, 0, 1],\n            &[1, 0, 3],\n            &[2, 1, 0],\n            &[0, 3, 2],\n            &[1, 3, 0],\n            &[2, 0, 3],\n            &[3, 0, 1],\n            &[0, 2, 4],\n            &[3, 1, 0],\n            &[2, 3, 0],\n            &[3, 0, 2],\n            &[0, 1, 4],\n        ],\n    );\n    exhaustive_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        16256,\n        &[\n            &['a', 'b'],\n            &['b', 'a'],\n            &['a', 'c'],\n            &['c', 'a'],\n            &['b', 'c'],\n            &['c', 'b'],\n            &['a', 'd'],\n            &['d', 'a'],\n            &['b', 'd'],\n            &['d', 'b'],\n            &['c', 'd'],\n            &['d', 'c'],\n            &['a', 'e'],\n            &['e', 'a'],\n            &['b', 'e'],\n            &['e', 'b'],\n            &['c', 'e'],\n            &['e', 'c'],\n            &['d', 'e'],\n            &['e', 'd'],\n        ],\n    );\n    exhaustive_unique_vecs_fixed_length_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[&[false], &[true]],\n    );\n    exhaustive_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    exhaustive_unique_vecs_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    exhaustive_unique_vecs_fixed_length_small_helper(\n        4,\n        1..=6,\n        360,\n        &[\n            &[1, 2, 3, 4],\n            &[1, 2, 3, 5],\n            &[1, 2, 4, 3],\n            &[1, 2, 4, 5],\n            &[1, 3, 2, 4],\n            &[1, 2, 5, 3],\n            &[1, 3, 4, 2],\n            &[1, 3, 4, 5],\n            &[1, 4, 2, 3],\n            &[1, 3, 2, 5],\n            &[1, 4, 3, 2],\n            &[1, 2, 5, 4],\n            &[2, 1, 3, 4],\n            &[1, 3, 5, 2],\n            &[2, 1, 4, 3],\n            &[2, 3, 4, 5],\n            &[2, 3, 1, 4],\n            &[1, 5, 2, 3],\n            &[2, 3, 4, 1],\n            &[1, 4, 2, 5],\n        ],\n    );\n    exhaustive_unique_vecs_fixed_length_helper(\n        2,\n        exhaustive_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            &[vec![0, 1], vec![1, 0]],\n            &[vec![1, 0], vec![0, 1]],\n            &[vec![0, 1], vec![0, 2]],\n            &[vec![0, 2], vec![0, 1]],\n            &[vec![1, 0], vec![0, 2]],\n            &[vec![0, 2], vec![1, 0]],\n            &[vec![0, 1], vec![2, 0]],\n            &[vec![2, 0], vec![0, 1]],\n            &[vec![1, 0], vec![2, 0]],\n            &[vec![2, 0], vec![1, 0]],\n            &[vec![0, 2], vec![2, 0]],\n            &[vec![2, 0], vec![0, 2]],\n            &[vec![0, 1], vec![1, 2]],\n            &[vec![1, 2], vec![0, 1]],\n            &[vec![1, 0], vec![1, 2]],\n            &[vec![1, 2], vec![1, 0]],\n            &[vec![0, 2], vec![1, 2]],\n            &[vec![1, 2], vec![0, 2]],\n            &[vec![2, 0], vec![1, 2]],\n            &[vec![1, 2], vec![2, 0]],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn exhaustive_unique_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_unique_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_unique_vecs_length_inclusive_range() {\n    exhaustive_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    exhaustive_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    exhaustive_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[&[], &[()]],\n    );\n    exhaustive_unique_vecs_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    exhaustive_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    exhaustive_unique_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    exhaustive_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn exhaustive_unique_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_unique_vecs_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_unique_vecs_length_range() {\n    exhaustive_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    exhaustive_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    exhaustive_unique_vecs_length_range_small_helper(0, 5, exhaustive_units(), 2, &[&[], &[()]]);\n    exhaustive_unique_vecs_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    exhaustive_unique_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    exhaustive_unique_vecs_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    exhaustive_unique_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    exhaustive_unique_vecs_length_range_small_helper(1, 2, 'a'..='c', 3, &[&['a'], &['b'], &['c']]);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn exhaustive_unique_vecs_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_unique_vecs_min_length(min_length, xs), out);\n}\n\nfn exhaustive_unique_vecs_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_unique_vecs_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_unique_vecs_min_length() {\n    exhaustive_unique_vecs_min_length_small_helper(0, nevers(), 1, &[&[]]);\n    exhaustive_unique_vecs_min_length_small_helper(4, nevers(), 0, &[]);\n    exhaustive_unique_vecs_min_length_small_helper(0, exhaustive_units(), 2, &[&[], &[()]]);\n    exhaustive_unique_vecs_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    exhaustive_unique_vecs_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        5,\n        &[&[], &[false], &[true], &[false, true], &[true, false]],\n    );\n    exhaustive_unique_vecs_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        4,\n        &[&[false], &[true], &[false, true], &[true, false]],\n    );\n    exhaustive_unique_vecs_min_length_small_helper(\n        0,\n        'a'..='c',\n        16,\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['a', 'b', 'c'],\n            &['c', 'a'],\n            &['b', 'c'],\n            &['c', 'b'],\n            &['a', 'c', 'b'],\n            &['b', 'a', 'c'],\n            &['b', 'c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    exhaustive_unique_vecs_min_length_small_helper(\n        2,\n        'a'..='c',\n        12,\n        &[\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['b', 'c'],\n            &['c', 'a'],\n            &['c', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c', 'b'],\n            &['b', 'a', 'c'],\n            &['b', 'c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    exhaustive_unique_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['a', 'b', 'c'],\n            &['c', 'a'],\n            &['b', 'c'],\n            &['c', 'b'],\n            &['d'],\n            &['a', 'c', 'b'],\n            &['a', 'd'],\n            &['b', 'a', 'c'],\n            &['c', 'd'],\n            &['b', 'c', 'a'],\n            &['d', 'a'],\n            &['c', 'a', 'b'],\n            &['b', 'd'],\n        ],\n    );\n    exhaustive_unique_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'b', 'c'],\n            &['a', 'b', 'd'],\n            &['a', 'c', 'b'],\n            &['a', 'c', 'd'],\n            &['b', 'a', 'c'],\n            &['a', 'd', 'b'],\n            &['b', 'c', 'a'],\n            &['b', 'c', 'd'],\n            &['c', 'a', 'b'],\n            &['b', 'a', 'd'],\n            &['c', 'b', 'a'],\n            &['a', 'd', 'c'],\n            &['b', 'd', 'a'],\n            &['c', 'a', 'd'],\n            &['d', 'a', 'b'],\n            &['a', 'b', 'e'],\n            &['d', 'b', 'a'],\n            &['c', 'd', 'a'],\n            &['d', 'a', 'c'],\n            &['a', 'b', 'c', 'd'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_vecs;\nuse std::fmt::Debug;\n\nfn exhaustive_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs(xs), out);\n}\n\n#[test]\nfn test_exhaustive_vecs() {\n    exhaustive_vecs_helper(nevers(), &[&[]]);\n    exhaustive_vecs_helper(\n        exhaustive_units(),\n        &[\n            &[],\n            &[()],\n            &[(), ()],\n            &[(), (), (), ()],\n            &[(), (), ()],\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n        ],\n    );\n    exhaustive_vecs_helper(\n        exhaustive_bools(),\n        &[\n            &[],\n            &[false],\n            &[true],\n            &[false, false, false],\n            &[false, false],\n            &[false, false, true],\n            &[false, true],\n            &[false, false, false, false, false],\n            &[true, false],\n            &[false, true, false],\n            &[true, true],\n            &[false, false, false, false],\n            &[false, true, true],\n            &[false, false, false, true],\n            &[true, false, false],\n            &[false, false, false, false, false, false, false],\n            &[true, false, true],\n            &[false, false, true, false],\n            &[true, true, false],\n            &[false, false, false, false, true],\n        ],\n    );\n    exhaustive_vecs_helper(\n        'a'..='c',\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['a', 'a', 'a'],\n            &['c'],\n            &['a', 'a'],\n            &['a', 'b'],\n            &['a', 'a', 'a', 'a', 'a'],\n            &['b', 'a'],\n            &['a', 'a', 'b'],\n            &['b', 'b'],\n            &['a', 'a', 'a', 'a'],\n            &['a', 'c'],\n            &['a', 'b', 'a'],\n            &['b', 'c'],\n            &['a', 'a', 'a', 'a', 'a', 'a'],\n            &['c', 'a'],\n            &['a', 'b', 'b'],\n            &['c', 'b'],\n            &['a', 'a', 'a', 'b'],\n        ],\n    );\n    exhaustive_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['a', 'a', 'a'],\n            &['c'],\n            &['a', 'a'],\n            &['d'],\n            &['a', 'a', 'a', 'a'],\n            &['e'],\n            &['a', 'b'],\n            &['f'],\n            &['a', 'a', 'b'],\n            &['g'],\n            &['b', 'a'],\n            &['h'],\n            &['a', 'a', 'a', 'a', 'a'],\n            &['i'],\n            &['b', 'b'],\n            &['j'],\n            &['a', 'b', 'a'],\n        ],\n    );\n    exhaustive_vecs_helper(\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[],\n            &[0],\n            &[1],\n            &[0, 0, 0],\n            &[2],\n            &[0, 0],\n            &[3],\n            &[0, 0, 0, 0],\n            &[4],\n            &[0, 1],\n            &[5],\n            &[0, 0, 1],\n            &[6],\n            &[1, 0],\n            &[7],\n            &[0, 0, 0, 0, 0],\n            &[8],\n            &[1, 1],\n            &[9],\n            &[0, 1, 0],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs_fixed_length_from_single.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_vecs_fixed_length_from_single;\nuse std::fmt::Debug;\n\nfn exhaustive_vecs_fixed_length_from_single_helper<I: Iterator>(len: u64, xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs_fixed_length_from_single(len, xs), out);\n}\n\nfn exhaustive_vecs_fixed_length_from_single_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_vecs_fixed_length_from_single(len, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_vecs_fixed_length_from_single() {\n    // This demonstrates that 0 ^ 0 == 1:\n    exhaustive_vecs_fixed_length_from_single_small_helper(0, nevers(), 1, &[&[]]);\n    exhaustive_vecs_fixed_length_from_single_small_helper(1, nevers(), 0, &[]);\n    exhaustive_vecs_fixed_length_from_single_small_helper(2, nevers(), 0, &[]);\n    exhaustive_vecs_fixed_length_from_single_small_helper(5, nevers(), 0, &[]);\n    exhaustive_vecs_fixed_length_from_single_small_helper(1, exhaustive_units(), 1, &[&[()]]);\n    exhaustive_vecs_fixed_length_from_single_small_helper(2, exhaustive_units(), 1, &[&[(), ()]]);\n    exhaustive_vecs_fixed_length_from_single_small_helper(5, exhaustive_units(), 1, &[&[(); 5]]);\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        0,\n        exhaustive_unsigneds::<u8>(),\n        1,\n        &[&[]],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        0x10000,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[0, 4],\n            &[0, 5],\n            &[1, 4],\n            &[1, 5],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[1, 0, 2],\n            &[1, 0, 3],\n            &[1, 1, 2],\n            &[1, 1, 3],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 3, 0],\n            &[0, 3, 1],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        0x4000,\n        &[\n            &['a', 'a'],\n            &['a', 'b'],\n            &['b', 'a'],\n            &['b', 'b'],\n            &['a', 'c'],\n            &['a', 'd'],\n            &['b', 'c'],\n            &['b', 'd'],\n            &['c', 'a'],\n            &['c', 'b'],\n            &['d', 'a'],\n            &['d', 'b'],\n            &['c', 'c'],\n            &['c', 'd'],\n            &['d', 'c'],\n            &['d', 'd'],\n            &['a', 'e'],\n            &['a', 'f'],\n            &['b', 'e'],\n            &['b', 'f'],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[&[false], &[true]],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        2,\n        exhaustive_bools(),\n        4,\n        &[&[false, false], &[false, true], &[true, false], &[true, true]],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        4,\n        exhaustive_bools(),\n        16,\n        &[\n            &[false, false, false, false],\n            &[false, false, false, true],\n            &[false, false, true, false],\n            &[false, false, true, true],\n            &[false, true, false, false],\n            &[false, true, false, true],\n            &[false, true, true, false],\n            &[false, true, true, true],\n            &[true, false, false, false],\n            &[true, false, false, true],\n            &[true, false, true, false],\n            &[true, false, true, true],\n            &[true, true, false, false],\n            &[true, true, false, true],\n            &[true, true, true, false],\n            &[true, true, true, true],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        10,\n        exhaustive_bools(),\n        1024,\n        &[\n            &[false, false, false, false, false, false, false, false, false, false],\n            &[false, false, false, false, false, false, false, false, false, true],\n            &[false, false, false, false, false, false, false, false, true, false],\n            &[false, false, false, false, false, false, false, false, true, true],\n            &[false, false, false, false, false, false, false, true, false, false],\n            &[false, false, false, false, false, false, false, true, false, true],\n            &[false, false, false, false, false, false, false, true, true, false],\n            &[false, false, false, false, false, false, false, true, true, true],\n            &[false, false, false, false, false, false, true, false, false, false],\n            &[false, false, false, false, false, false, true, false, false, true],\n            &[false, false, false, false, false, false, true, false, true, false],\n            &[false, false, false, false, false, false, true, false, true, true],\n            &[false, false, false, false, false, false, true, true, false, false],\n            &[false, false, false, false, false, false, true, true, false, true],\n            &[false, false, false, false, false, false, true, true, true, false],\n            &[false, false, false, false, false, false, true, true, true, true],\n            &[false, false, false, false, false, true, false, false, false, false],\n            &[false, false, false, false, false, true, false, false, false, true],\n            &[false, false, false, false, false, true, false, false, true, false],\n            &[false, false, false, false, false, true, false, false, true, true],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_small_helper(\n        10,\n        0..3,\n        59049,\n        &[\n            &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 1, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 0, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 1, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 1, 1],\n            &[0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n            &[0, 0, 0, 0, 0, 0, 1, 0, 0, 1],\n            &[0, 0, 0, 0, 0, 0, 1, 0, 1, 0],\n            &[0, 0, 0, 0, 0, 0, 1, 0, 1, 1],\n            &[0, 0, 0, 0, 0, 0, 1, 1, 0, 0],\n            &[0, 0, 0, 0, 0, 0, 1, 1, 0, 1],\n            &[0, 0, 0, 0, 0, 0, 1, 1, 1, 0],\n            &[0, 0, 0, 0, 0, 0, 1, 1, 1, 1],\n            &[0, 0, 0, 0, 0, 1, 0, 0, 0, 0],\n            &[0, 0, 0, 0, 0, 1, 0, 0, 0, 1],\n            &[0, 0, 0, 0, 0, 1, 0, 0, 1, 0],\n            &[0, 0, 0, 0, 0, 1, 0, 0, 1, 1],\n        ],\n    );\n    exhaustive_vecs_fixed_length_from_single_helper(\n        2,\n        exhaustive_vecs_fixed_length_from_single(2, exhaustive_unsigneds::<u8>()),\n        &[\n            &[vec![0, 0], vec![0, 0]],\n            &[vec![0, 0], vec![0, 1]],\n            &[vec![0, 1], vec![0, 0]],\n            &[vec![0, 1], vec![0, 1]],\n            &[vec![0, 0], vec![1, 0]],\n            &[vec![0, 0], vec![1, 1]],\n            &[vec![0, 1], vec![1, 0]],\n            &[vec![0, 1], vec![1, 1]],\n            &[vec![1, 0], vec![0, 0]],\n            &[vec![1, 0], vec![0, 1]],\n            &[vec![1, 1], vec![0, 0]],\n            &[vec![1, 1], vec![0, 1]],\n            &[vec![1, 0], vec![1, 0]],\n            &[vec![1, 0], vec![1, 1]],\n            &[vec![1, 1], vec![1, 0]],\n            &[vec![1, 1], vec![1, 1]],\n            &[vec![0, 0], vec![0, 2]],\n            &[vec![0, 0], vec![0, 3]],\n            &[vec![0, 1], vec![0, 2]],\n            &[vec![0, 1], vec![0, 3]],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs_fixed_length_m_inputs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::{SAMPLE_OUTPUT_TYPES_2, SAMPLE_OUTPUT_TYPES_3};\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::{exhaustive_positive_primitive_ints, exhaustive_unsigneds};\nuse malachite_base::vecs::exhaustive::{\n    exhaustive_vecs_fixed_length_1_input, exhaustive_vecs_fixed_length_2_inputs,\n};\nuse std::fmt::Debug;\nuse std::iter::empty;\n\nfn exhaustive_vecs_fixed_length_1_input_helper<T, I: Clone + Iterator<Item = T>>(\n    xs: &I,\n    len: usize,\n    out_len: Option<usize>,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    let xss = if len == 2 {\n        exhaustive_vecs_fixed_length_1_input(xs.clone(), &SAMPLE_OUTPUT_TYPES_2[0])\n    } else {\n        assert_eq!(len, 3);\n        exhaustive_vecs_fixed_length_1_input(xs.clone(), &SAMPLE_OUTPUT_TYPES_3[0])\n    };\n    let xss_prefix = xss.clone().take(20).collect_vec();\n    assert_eq!(\n        xss_prefix\n            .iter()\n            .map(Vec::as_slice)\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n    if let Some(out_len) = out_len {\n        assert_eq!(xss.count(), out_len);\n    }\n    if len == 2 {\n        for alt_output_types in &SAMPLE_OUTPUT_TYPES_2[1..] {\n            let xss = exhaustive_vecs_fixed_length_1_input(xs.clone(), alt_output_types);\n            xss.clone().take(20).for_each(drop);\n            if let Some(out_len) = out_len {\n                assert_eq!(xss.count(), out_len);\n            }\n        }\n    } else {\n        assert_eq!(len, 3);\n        for alt_output_types in &SAMPLE_OUTPUT_TYPES_3[1..] {\n            let xss = exhaustive_vecs_fixed_length_1_input(xs.clone(), alt_output_types);\n            xss.clone().take(20).for_each(drop);\n            if let Some(out_len) = out_len {\n                assert_eq!(xss.count(), out_len);\n            }\n        }\n    }\n}\n\n#[test]\nfn test_exhaustive_vecs_fixed_length_1_input() {\n    exhaustive_vecs_fixed_length_1_input_helper(&nevers(), 2, Some(0), &[]);\n    exhaustive_vecs_fixed_length_1_input_helper(\n        &exhaustive_unsigneds::<u8>(),\n        2,\n        Some(1 << 16),\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[0, 4],\n            &[0, 5],\n            &[1, 4],\n            &[1, 5],\n        ],\n    );\n    exhaustive_vecs_fixed_length_1_input_helper(\n        &exhaustive_positive_primitive_ints::<u64>(),\n        2,\n        None,\n        &[\n            &[1, 1],\n            &[1, 2],\n            &[2, 1],\n            &[2, 2],\n            &[1, 3],\n            &[1, 4],\n            &[2, 3],\n            &[2, 4],\n            &[3, 1],\n            &[3, 2],\n            &[4, 1],\n            &[4, 2],\n            &[3, 3],\n            &[3, 4],\n            &[4, 3],\n            &[4, 4],\n            &[1, 5],\n            &[1, 6],\n            &[2, 5],\n            &[2, 6],\n        ],\n    );\n    exhaustive_vecs_fixed_length_1_input_helper(\n        &['x', 'y', 'z'].iter().copied(),\n        2,\n        Some(9),\n        &[\n            &['x', 'x'],\n            &['x', 'y'],\n            &['y', 'x'],\n            &['y', 'y'],\n            &['x', 'z'],\n            &['y', 'z'],\n            &['z', 'x'],\n            &['z', 'y'],\n            &['z', 'z'],\n        ],\n    );\n    exhaustive_vecs_fixed_length_1_input_helper(\n        &['x', 'y', 'z'].iter().copied(),\n        3,\n        Some(27),\n        &[\n            &['x', 'x', 'x'],\n            &['x', 'x', 'y'],\n            &['x', 'y', 'x'],\n            &['x', 'y', 'y'],\n            &['y', 'x', 'x'],\n            &['y', 'x', 'y'],\n            &['y', 'y', 'x'],\n            &['y', 'y', 'y'],\n            &['x', 'x', 'z'],\n            &['x', 'y', 'z'],\n            &['y', 'x', 'z'],\n            &['y', 'y', 'z'],\n            &['x', 'z', 'x'],\n            &['x', 'z', 'y'],\n            &['y', 'z', 'x'],\n            &['y', 'z', 'y'],\n            &['x', 'z', 'z'],\n            &['y', 'z', 'z'],\n            &['z', 'x', 'x'],\n            &['z', 'x', 'y'],\n        ],\n    );\n    exhaustive_vecs_fixed_length_1_input_helper(\n        &exhaustive_ascii_chars(),\n        3,\n        None,\n        &[\n            &['a', 'a', 'a'],\n            &['a', 'a', 'b'],\n            &['a', 'b', 'a'],\n            &['a', 'b', 'b'],\n            &['b', 'a', 'a'],\n            &['b', 'a', 'b'],\n            &['b', 'b', 'a'],\n            &['b', 'b', 'b'],\n            &['a', 'a', 'c'],\n            &['a', 'a', 'd'],\n            &['a', 'b', 'c'],\n            &['a', 'b', 'd'],\n            &['b', 'a', 'c'],\n            &['b', 'a', 'd'],\n            &['b', 'b', 'c'],\n            &['b', 'b', 'd'],\n            &['a', 'c', 'a'],\n            &['a', 'c', 'b'],\n            &['a', 'd', 'a'],\n            &['a', 'd', 'b'],\n        ],\n    );\n}\n\nfn exhaustive_vecs_fixed_length_2_inputs_helper<\n    T,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs: &I,\n    ys: &J,\n    len: usize,\n    input_indices: &[usize],\n    out_len: Option<usize>,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    let output_configs: Vec<(BitDistributorOutputType, usize)> = if len == 2 {\n        SAMPLE_OUTPUT_TYPES_2[0]\n            .iter()\n            .copied()\n            .zip(input_indices.iter().copied())\n            .collect()\n    } else {\n        SAMPLE_OUTPUT_TYPES_3[0]\n            .iter()\n            .copied()\n            .zip(input_indices.iter().copied())\n            .collect()\n    };\n    let xss = exhaustive_vecs_fixed_length_2_inputs(xs.clone(), ys.clone(), &output_configs);\n    let xss_prefix = xss.clone().take(20).collect_vec();\n    assert_eq!(\n        xss_prefix\n            .iter()\n            .map(Vec::as_slice)\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n    if let Some(out_len) = out_len {\n        assert_eq!(xss.count(), out_len);\n    }\n    if len == 2 {\n        for alt_output_types in &SAMPLE_OUTPUT_TYPES_2[1..] {\n            let output_configs: Vec<(BitDistributorOutputType, usize)> = alt_output_types\n                .iter()\n                .copied()\n                .zip(input_indices.iter().copied())\n                .collect();\n            let xss =\n                exhaustive_vecs_fixed_length_2_inputs(xs.clone(), ys.clone(), &output_configs);\n            xss.clone().take(20).for_each(drop);\n            if let Some(out_len) = out_len {\n                assert_eq!(xss.count(), out_len);\n            }\n        }\n    } else {\n        assert_eq!(len, 3);\n        for alt_output_types in &SAMPLE_OUTPUT_TYPES_3[1..] {\n            let output_configs: Vec<(BitDistributorOutputType, usize)> = alt_output_types\n                .iter()\n                .copied()\n                .zip(input_indices.iter().copied())\n                .collect();\n            let xss =\n                exhaustive_vecs_fixed_length_2_inputs(xs.clone(), ys.clone(), &output_configs);\n            xss.clone().take(20).for_each(drop);\n            if let Some(out_len) = out_len {\n                assert_eq!(xss.count(), out_len);\n            }\n        }\n    }\n}\n\n#[test]\nfn test_exhaustive_vecs_fixed_length_2_inputs() {\n    exhaustive_vecs_fixed_length_2_inputs_helper(&nevers(), &nevers(), 2, &[0, 1], Some(0), &[]);\n    exhaustive_vecs_fixed_length_2_inputs_helper(\n        &empty(),\n        &exhaustive_unsigneds::<u8>(),\n        2,\n        &[0, 1],\n        Some(0),\n        &[],\n    );\n    exhaustive_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_unsigneds::<u64>(),\n        &exhaustive_positive_primitive_ints::<u64>(),\n        2,\n        &[0, 1],\n        None,\n        &[\n            &[0, 1],\n            &[0, 2],\n            &[1, 1],\n            &[1, 2],\n            &[0, 3],\n            &[0, 4],\n            &[1, 3],\n            &[1, 4],\n            &[2, 1],\n            &[2, 2],\n            &[3, 1],\n            &[3, 2],\n            &[2, 3],\n            &[2, 4],\n            &[3, 3],\n            &[3, 4],\n            &[0, 5],\n            &[0, 6],\n            &[1, 5],\n            &[1, 6],\n        ],\n    );\n    exhaustive_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_ascii_chars(),\n        &['x', 'y', 'z'].iter().copied(),\n        2,\n        &[0, 1],\n        Some(384),\n        &[\n            &['a', 'x'],\n            &['a', 'y'],\n            &['b', 'x'],\n            &['b', 'y'],\n            &['a', 'z'],\n            &['b', 'z'],\n            &['c', 'x'],\n            &['c', 'y'],\n            &['d', 'x'],\n            &['d', 'y'],\n            &['c', 'z'],\n            &['d', 'z'],\n            &['e', 'x'],\n            &['e', 'y'],\n            &['f', 'x'],\n            &['f', 'y'],\n            &['e', 'z'],\n            &['f', 'z'],\n            &['g', 'x'],\n            &['g', 'y'],\n        ],\n    );\n    exhaustive_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_ascii_chars(),\n        &['x', 'y', 'z'].iter().copied(),\n        3,\n        &[0, 1, 1],\n        Some(1152),\n        &[\n            &['a', 'x', 'x'],\n            &['a', 'x', 'y'],\n            &['a', 'y', 'x'],\n            &['a', 'y', 'y'],\n            &['b', 'x', 'x'],\n            &['b', 'x', 'y'],\n            &['b', 'y', 'x'],\n            &['b', 'y', 'y'],\n            &['a', 'x', 'z'],\n            &['a', 'y', 'z'],\n            &['b', 'x', 'z'],\n            &['b', 'y', 'z'],\n            &['a', 'z', 'x'],\n            &['a', 'z', 'y'],\n            &['b', 'z', 'x'],\n            &['b', 'z', 'y'],\n            &['a', 'z', 'z'],\n            &['b', 'z', 'z'],\n            &['c', 'x', 'x'],\n            &['c', 'x', 'y'],\n        ],\n    );\n    exhaustive_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_ascii_chars(),\n        &['x', 'y', 'z'].iter().copied(),\n        3,\n        &[0, 1, 0],\n        Some(49152),\n        &[\n            &['a', 'x', 'a'],\n            &['a', 'x', 'b'],\n            &['a', 'y', 'a'],\n            &['a', 'y', 'b'],\n            &['b', 'x', 'a'],\n            &['b', 'x', 'b'],\n            &['b', 'y', 'a'],\n            &['b', 'y', 'b'],\n            &['a', 'x', 'c'],\n            &['a', 'x', 'd'],\n            &['a', 'y', 'c'],\n            &['a', 'y', 'd'],\n            &['b', 'x', 'c'],\n            &['b', 'x', 'd'],\n            &['b', 'y', 'c'],\n            &['b', 'y', 'd'],\n            &['a', 'z', 'a'],\n            &['a', 'z', 'b'],\n            &['b', 'z', 'a'],\n            &['b', 'z', 'b'],\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_vecs_fixed_length_2_inputs_fail_1() {\n    exhaustive_vecs_fixed_length_2_inputs(0..2, 0..3, &[]);\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_vecs_fixed_length_2_inputs_fail_2() {\n    exhaustive_vecs_fixed_length_2_inputs(0..2, 0..3, &[(BitDistributorOutputType::normal(1), 0)]);\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_vecs_fixed_length_2_inputs_fail_3() {\n    exhaustive_vecs_fixed_length_2_inputs(0..2, 0..3, &[(BitDistributorOutputType::normal(1), 1)]);\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_vecs_fixed_length_2_inputs_fail_4() {\n    exhaustive_vecs_fixed_length_2_inputs(\n        0..2,\n        0..3,\n        &[\n            (BitDistributorOutputType::normal(1), 0),\n            (BitDistributorOutputType::normal(1), 1),\n            (BitDistributorOutputType::normal(1), 2),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_helper_helper;\nuse malachite_base::vecs::exhaustive::exhaustive_vecs_from_length_iterator;\nuse std::fmt::Debug;\nuse std::iter::empty;\n\nfn exhaustive_vecs_from_element_iterator_helper<I: Iterator<Item = u64>, J: Clone + Iterator>(\n    lengths: I,\n    xs: J,\n    out: &[&[J::Item]],\n) where\n    J::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs_from_length_iterator(lengths, xs), out);\n}\n\n#[test]\nfn test_exhaustive_vecs_from_element_iterator() {\n    exhaustive_vecs_from_element_iterator_helper(empty(), exhaustive_bools(), &[]);\n    exhaustive_vecs_from_element_iterator_helper(\n        [2, 1, 2].iter().copied(),\n        exhaustive_bools(),\n        &[\n            &[false, false],\n            &[false],\n            &[false, true],\n            &[false, false],\n            &[true, false],\n            &[true],\n            &[true, true],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n        ],\n    );\n    exhaustive_vecs_from_element_iterator_helper(\n        exhaustive_unsigneds::<u64>().map(|u| u << 1),\n        exhaustive_bools(),\n        &[\n            &[],\n            &[false, false],\n            &[false, true],\n            &[false, false, false, false, false, false],\n            &[true, false],\n            &[false, false, false, false],\n            &[true, true],\n            &[false, false, false, false, false, false, false, false],\n            &[false, false, false, true],\n            &[false, false, false, false, false, true],\n            &[false, false, true, false],\n            &[false, false, false, false, false, false, false, true],\n            &[false, false, true, true],\n            &[false, false, false, false, true, false],\n            &[false, true, false, false],\n            &[false, false, false, false, false, false, false, false, false, false, false, false],\n            &[false, true, false, true],\n            &[false, false, false, false, true, true],\n            &[false, true, true, false],\n            &[false, false, false, false, false, false, true, false],\n        ],\n    );\n    exhaustive_vecs_from_element_iterator_helper(\n        [2, 1, 0, 2].iter().copied(),\n        exhaustive_bools(),\n        &[\n            &[false, false],\n            &[false],\n            &[false, true],\n            &[],\n            &[true, false],\n            &[true],\n            &[true, true],\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n        ],\n    );\n    exhaustive_vecs_from_element_iterator_helper(empty(), exhaustive_unsigneds::<u32>(), &[]);\n    exhaustive_vecs_from_element_iterator_helper(\n        [2, 1, 2].iter().copied(),\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[0, 0],\n            &[0],\n            &[0, 1],\n            &[0, 0],\n            &[1, 0],\n            &[1],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[2],\n            &[1, 2],\n            &[0, 1],\n            &[1, 3],\n            &[3],\n            &[2, 0],\n            &[4],\n            &[2, 1],\n            &[5],\n            &[3, 0],\n            &[1, 0],\n        ],\n    );\n    exhaustive_vecs_from_element_iterator_helper(\n        exhaustive_unsigneds::<u64>().map(|u| u << 1),\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[],\n            &[0, 0],\n            &[0, 1],\n            &[0, 0, 0, 0, 0, 0],\n            &[1, 0],\n            &[0, 0, 0, 0],\n            &[1, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 0],\n            &[0, 2],\n            &[0, 0, 0, 1],\n            &[0, 3],\n            &[0, 0, 0, 0, 0, 1],\n            &[1, 2],\n            &[0, 0, 1, 0],\n            &[1, 3],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n            &[2, 0],\n            &[0, 0, 1, 1],\n            &[2, 1],\n            &[0, 0, 0, 0, 1, 0],\n        ],\n    );\n    exhaustive_vecs_from_element_iterator_helper(\n        [2, 1, 0, 2].iter().copied(),\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[0, 0],\n            &[0],\n            &[0, 1],\n            &[],\n            &[1, 0],\n            &[1],\n            &[1, 1],\n            &[0, 0],\n            &[0, 2],\n            &[2],\n            &[0, 3],\n            &[0, 1],\n            &[1, 2],\n            &[3],\n            &[1, 3],\n            &[4],\n            &[2, 0],\n            &[5],\n            &[2, 1],\n            &[1, 0],\n        ],\n    );\n    // Stops after first empty ys\n    exhaustive_vecs_from_element_iterator_helper(\n        [0, 0, 1, 0].iter().copied(),\n        nevers(),\n        &[&[], &[]],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn exhaustive_vecs_length_inclusive_range_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs_length_inclusive_range(a, b, xs), out);\n}\n\nfn exhaustive_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        exhaustive_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_exhaustive_vecs_length_inclusive_range() {\n    exhaustive_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    exhaustive_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    exhaustive_vecs_length_inclusive_range_small_helper(5, 3, exhaustive_bools(), 0, &[]);\n    exhaustive_vecs_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        5,\n        &[&[], &[()], &[(), ()], &[(), (), (), ()], &[(), (), ()]],\n    );\n    exhaustive_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        exhaustive_bools(),\n        2,\n        &[&[false], &[true]],\n    );\n    exhaustive_vecs_length_inclusive_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        7,\n        &[&[], &[false], &[true], &[false, false], &[false, true], &[true, false], &[true, true]],\n    );\n    exhaustive_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        12,\n        &[\n            &[false, false],\n            &[false, false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false, false, true],\n            &[false, true, false],\n            &[false, true, true],\n            &[true, false, false],\n            &[true, false, true],\n            &[true, true, false],\n            &[true, true, true],\n        ],\n    );\n    exhaustive_vecs_length_inclusive_range_small_helper(\n        5,\n        7,\n        'a'..='c',\n        3159,\n        &[\n            &['a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'b', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'b', 'b'],\n            &['a', 'a', 'b', 'a', 'a'],\n            &['a', 'a', 'b', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'b', 'a'],\n            &['a', 'a', 'b', 'b', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'b', 'b', 'b'],\n            &['a', 'a', 'a', 'a', 'b', 'b'],\n            &['a', 'b', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'b', 'a', 'a'],\n            &['a', 'b', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'b', 'a', 'b'],\n            &['a', 'b', 'a', 'b', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'b', 'a'],\n        ],\n    );\n    exhaustive_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[0, 0],\n            &[0, 0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 0, 1],\n            &[0, 2],\n            &[0, 1, 0],\n            &[0, 3],\n            &[0, 1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[1, 0, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[1, 0, 1],\n            &[2, 2],\n            &[2, 3],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs_length_n.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::exhaustive_vecs_length_3;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::vecs::exhaustive::{\n    exhaustive_vecs_fixed_length_from_single, exhaustive_vecs_length_2,\n};\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::{empty, once};\n\nfn exhaustive_vecs_length_2_helper<T, I: Iterator<Item = T>, J: Iterator<Item = T>>(\n    xs: I,\n    ys: J,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs_length_2(xs, ys), out);\n}\n\nfn exhaustive_vecs_length_2_finite_helper<\n    T,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(exhaustive_vecs_length_2(xs, ys), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_vecs_length_2() {\n    exhaustive_vecs_length_2_finite_helper(nevers(), nevers(), 0, &[]);\n    exhaustive_vecs_length_2_finite_helper(empty(), 0..4, 0, &[]);\n    exhaustive_vecs_length_2_finite_helper(once(0), once(1), 1, &[&[0, 1]]);\n    exhaustive_vecs_length_2_finite_helper(once(0), 0..4, 4, &[&[0, 0], &[0, 1], &[0, 2], &[0, 3]]);\n    exhaustive_vecs_length_2_finite_helper(\n        exhaustive_unsigneds::<u8>(),\n        0..4,\n        1024,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[4, 0],\n            &[4, 1],\n            &[5, 0],\n            &[5, 1],\n        ],\n    );\n    exhaustive_vecs_length_2_helper(\n        exhaustive_unsigneds::<u64>(),\n        0..4,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 2],\n            &[3, 3],\n            &[4, 0],\n            &[4, 1],\n            &[5, 0],\n            &[5, 1],\n        ],\n    );\n    exhaustive_vecs_length_2_finite_helper(\n        0..2,\n        0..4,\n        8,\n        &[&[0, 0], &[0, 1], &[1, 0], &[1, 1], &[0, 2], &[0, 3], &[1, 2], &[1, 3]],\n    );\n    exhaustive_vecs_length_2_finite_helper(\n        0..5,\n        0..3,\n        15,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 2],\n            &[1, 2],\n            &[2, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[2, 2],\n            &[3, 2],\n            &[4, 0],\n            &[4, 1],\n            &[4, 2],\n        ],\n    );\n    exhaustive_vecs_length_2_finite_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        ['x', 'y', 'z'].iter().copied(),\n        9,\n        &[\n            &['a', 'x'],\n            &['a', 'y'],\n            &['b', 'x'],\n            &['b', 'y'],\n            &['a', 'z'],\n            &['b', 'z'],\n            &['c', 'x'],\n            &['c', 'y'],\n            &['c', 'z'],\n        ],\n    );\n    exhaustive_vecs_length_2_finite_helper(\n        exhaustive_vecs_length_2(exhaustive_orderings(), [Less, Greater].iter().copied()),\n        exhaustive_vecs_fixed_length_from_single(3, [Less, Greater].iter().copied()),\n        48,\n        &[\n            &[vec![Equal, Less], vec![Less, Less, Less]],\n            &[vec![Equal, Less], vec![Less, Less, Greater]],\n            &[vec![Equal, Greater], vec![Less, Less, Less]],\n            &[vec![Equal, Greater], vec![Less, Less, Greater]],\n            &[vec![Equal, Less], vec![Less, Greater, Less]],\n            &[vec![Equal, Less], vec![Less, Greater, Greater]],\n            &[vec![Equal, Greater], vec![Less, Greater, Less]],\n            &[vec![Equal, Greater], vec![Less, Greater, Greater]],\n            &[vec![Less, Less], vec![Less, Less, Less]],\n            &[vec![Less, Less], vec![Less, Less, Greater]],\n            &[vec![Less, Greater], vec![Less, Less, Less]],\n            &[vec![Less, Greater], vec![Less, Less, Greater]],\n            &[vec![Less, Less], vec![Less, Greater, Less]],\n            &[vec![Less, Less], vec![Less, Greater, Greater]],\n            &[vec![Less, Greater], vec![Less, Greater, Less]],\n            &[vec![Less, Greater], vec![Less, Greater, Greater]],\n            &[vec![Equal, Less], vec![Greater, Less, Less]],\n            &[vec![Equal, Less], vec![Greater, Less, Greater]],\n            &[vec![Equal, Greater], vec![Greater, Less, Less]],\n            &[vec![Equal, Greater], vec![Greater, Less, Greater]],\n        ],\n    );\n}\n\nfn exhaustive_vecs_length_3_helper<\n    T,\n    I: Iterator<Item = T>,\n    J: Iterator<Item = T>,\n    K: Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs_length_3(xs, ys, zs), out);\n}\n\nfn exhaustive_vecs_length_3_finite_helper<\n    T,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n    K: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out_len: usize,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(exhaustive_vecs_length_3(xs, ys, zs), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_vecs_length_3() {\n    exhaustive_vecs_length_3_finite_helper(nevers(), nevers(), nevers(), 0, &[]);\n    exhaustive_vecs_length_3_finite_helper(empty(), 0..4, 0..5, 0, &[]);\n    exhaustive_vecs_length_3_finite_helper(once(0), once(1), once(5), 1, &[&[0, 1, 5]]);\n    exhaustive_vecs_length_3_finite_helper(\n        once(0),\n        once(3),\n        0..4,\n        4,\n        &[&[0, 3, 0], &[0, 3, 1], &[0, 3, 2], &[0, 3, 3]],\n    );\n    exhaustive_vecs_length_3_finite_helper(\n        exhaustive_unsigneds::<u8>(),\n        0..4,\n        0..4,\n        4096,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[1, 0, 2],\n            &[1, 0, 3],\n            &[1, 1, 2],\n            &[1, 1, 3],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 3, 0],\n            &[0, 3, 1],\n        ],\n    );\n    exhaustive_vecs_length_3_helper(\n        exhaustive_unsigneds::<u64>(),\n        0..4,\n        0..4,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[1, 0, 2],\n            &[1, 0, 3],\n            &[1, 1, 2],\n            &[1, 1, 3],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 3, 0],\n            &[0, 3, 1],\n        ],\n    );\n    exhaustive_vecs_length_3_finite_helper(\n        0..2,\n        0..3,\n        0..3,\n        18,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 1, 2],\n            &[1, 0, 2],\n            &[1, 1, 2],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[1, 2, 0],\n            &[1, 2, 1],\n            &[0, 2, 2],\n            &[1, 2, 2],\n        ],\n    );\n    exhaustive_vecs_length_3_finite_helper(\n        0..11,\n        0..12,\n        0..13,\n        1716,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[1, 0, 2],\n            &[1, 0, 3],\n            &[1, 1, 2],\n            &[1, 1, 3],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 3, 0],\n            &[0, 3, 1],\n        ],\n    );\n    exhaustive_vecs_length_3_finite_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        ['x', 'y', 'z'].iter().copied(),\n        ['0', '1', '2'].iter().copied(),\n        27,\n        &[\n            &['a', 'x', '0'],\n            &['a', 'x', '1'],\n            &['a', 'y', '0'],\n            &['a', 'y', '1'],\n            &['b', 'x', '0'],\n            &['b', 'x', '1'],\n            &['b', 'y', '0'],\n            &['b', 'y', '1'],\n            &['a', 'x', '2'],\n            &['a', 'y', '2'],\n            &['b', 'x', '2'],\n            &['b', 'y', '2'],\n            &['a', 'z', '0'],\n            &['a', 'z', '1'],\n            &['b', 'z', '0'],\n            &['b', 'z', '1'],\n            &['a', 'z', '2'],\n            &['b', 'z', '2'],\n            &['c', 'x', '0'],\n            &['c', 'x', '1'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_vecs_length_range;\nuse std::fmt::Debug;\n\nfn exhaustive_vecs_length_range_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs_length_range(a, b, xs), out);\n}\n\nfn exhaustive_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(exhaustive_vecs_length_range(a, b, xs), out_len, out);\n}\n\n#[test]\nfn test_exhaustive_vecs_length_range() {\n    exhaustive_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    exhaustive_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    exhaustive_vecs_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        5,\n        &[&[], &[()], &[(), ()], &[(), (), (), ()], &[(), (), ()]],\n    );\n    exhaustive_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    exhaustive_vecs_length_range_small_helper(5, 3, exhaustive_bools(), 0, &[]);\n    exhaustive_vecs_length_range_small_helper(\n        0,\n        3,\n        exhaustive_bools(),\n        7,\n        &[&[], &[false], &[true], &[false, false], &[false, true], &[true, false], &[true, true]],\n    );\n    exhaustive_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        12,\n        &[\n            &[false, false],\n            &[false, false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false, false, true],\n            &[false, true, false],\n            &[false, true, true],\n            &[true, false, false],\n            &[true, false, true],\n            &[true, true, false],\n            &[true, true, true],\n        ],\n    );\n    exhaustive_vecs_length_range_small_helper(\n        5,\n        8,\n        'a'..='c',\n        3159,\n        &[\n            &['a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'b', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'b', 'b'],\n            &['a', 'a', 'b', 'a', 'a'],\n            &['a', 'a', 'b', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'b', 'a'],\n            &['a', 'a', 'b', 'b', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'b', 'b', 'b'],\n            &['a', 'a', 'a', 'a', 'b', 'b'],\n            &['a', 'b', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'b', 'a', 'a'],\n            &['a', 'b', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'b', 'a', 'b'],\n            &['a', 'b', 'a', 'b', 'a'],\n            &['a', 'a', 'a', 'a', 'a', 'b', 'a'],\n        ],\n    );\n    exhaustive_vecs_length_range_helper(\n        2,\n        4,\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[0, 0],\n            &[0, 0, 0],\n            &[0, 1],\n            &[1, 0],\n            &[1, 1],\n            &[0, 0, 1],\n            &[0, 2],\n            &[0, 1, 0],\n            &[0, 3],\n            &[0, 1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[1, 0, 0],\n            &[2, 1],\n            &[3, 0],\n            &[3, 1],\n            &[1, 0, 1],\n            &[2, 2],\n            &[2, 3],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/exhaustive_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::exhaustive_vecs_min_length;\nuse std::fmt::Debug;\n\nfn exhaustive_vecs_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(exhaustive_vecs_min_length(min_length, xs), out);\n}\n\n#[test]\nfn test_exhaustive_vecs_min_length() {\n    exhaustive_vecs_min_length_helper(0, nevers(), &[&[]]);\n    exhaustive_vecs_min_length_helper(4, nevers(), &[]);\n    exhaustive_vecs_min_length_helper(\n        0,\n        exhaustive_units(),\n        &[\n            &[],\n            &[()],\n            &[(), ()],\n            &[(), (), (), ()],\n            &[(), (), ()],\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        5,\n        exhaustive_units(),\n        &[\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n            ],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n            ],\n            &[\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n                (),\n            ],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        0,\n        exhaustive_bools(),\n        &[\n            &[],\n            &[false],\n            &[true],\n            &[false, false, false],\n            &[false, false],\n            &[false, false, true],\n            &[false, true],\n            &[false, false, false, false, false],\n            &[true, false],\n            &[false, true, false],\n            &[true, true],\n            &[false, false, false, false],\n            &[false, true, true],\n            &[false, false, false, true],\n            &[true, false, false],\n            &[false, false, false, false, false, false, false],\n            &[true, false, true],\n            &[false, false, true, false],\n            &[true, true, false],\n            &[false, false, false, false, true],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        3,\n        exhaustive_bools(),\n        &[\n            &[false, false, false],\n            &[false, false, false, false],\n            &[false, false, true],\n            &[false, false, false, false, false],\n            &[false, true, false],\n            &[false, false, false, true],\n            &[false, true, true],\n            &[false, false, false, false, false, false],\n            &[true, false, false],\n            &[false, false, true, false],\n            &[true, false, true],\n            &[false, false, false, false, true],\n            &[true, true, false],\n            &[false, false, true, true],\n            &[true, true, true],\n            &[false, false, false, false, false, false, false],\n            &[false, true, false, false],\n            &[false, false, false, true, false],\n            &[false, true, false, true],\n            &[false, false, false, false, false, true],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        0,\n        'a'..='c',\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['a', 'a', 'a'],\n            &['c'],\n            &['a', 'a'],\n            &['a', 'b'],\n            &['a', 'a', 'a', 'a', 'a'],\n            &['b', 'a'],\n            &['a', 'a', 'b'],\n            &['b', 'b'],\n            &['a', 'a', 'a', 'a'],\n            &['a', 'c'],\n            &['a', 'b', 'a'],\n            &['b', 'c'],\n            &['a', 'a', 'a', 'a', 'a', 'a'],\n            &['c', 'a'],\n            &['a', 'b', 'b'],\n            &['c', 'b'],\n            &['a', 'a', 'a', 'b'],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        3,\n        'a'..='c',\n        &[\n            &['a', 'a', 'a'],\n            &['a', 'a', 'a', 'a'],\n            &['a', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'a'],\n            &['a', 'b', 'a'],\n            &['a', 'a', 'a', 'b'],\n            &['a', 'b', 'b'],\n            &['a', 'a', 'a', 'a', 'a', 'a'],\n            &['b', 'a', 'a'],\n            &['a', 'a', 'b', 'a'],\n            &['b', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'b'],\n            &['b', 'b', 'a'],\n            &['a', 'a', 'b', 'b'],\n            &['b', 'b', 'b'],\n            &['a', 'a', 'a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'c'],\n            &['a', 'b', 'a', 'a'],\n            &['a', 'b', 'c'],\n            &['a', 'a', 'a', 'b', 'a'],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['a', 'a', 'a'],\n            &['c'],\n            &['a', 'a'],\n            &['d'],\n            &['a', 'a', 'a', 'a'],\n            &['e'],\n            &['a', 'b'],\n            &['f'],\n            &['a', 'a', 'b'],\n            &['g'],\n            &['b', 'a'],\n            &['h'],\n            &['a', 'a', 'a', 'a', 'a'],\n            &['i'],\n            &['b', 'b'],\n            &['j'],\n            &['a', 'b', 'a'],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'a', 'a'],\n            &['a', 'a', 'a', 'a'],\n            &['a', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'a'],\n            &['a', 'b', 'a'],\n            &['a', 'a', 'a', 'b'],\n            &['a', 'b', 'b'],\n            &['a', 'a', 'a', 'a', 'a', 'a'],\n            &['b', 'a', 'a'],\n            &['a', 'a', 'b', 'a'],\n            &['b', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'b'],\n            &['b', 'b', 'a'],\n            &['a', 'a', 'b', 'b'],\n            &['b', 'b', 'b'],\n            &['a', 'a', 'a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'c'],\n            &['a', 'b', 'a', 'a'],\n            &['a', 'a', 'd'],\n            &['a', 'a', 'a', 'b', 'a'],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        0,\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[],\n            &[0],\n            &[1],\n            &[0, 0, 0],\n            &[2],\n            &[0, 0],\n            &[3],\n            &[0, 0, 0, 0],\n            &[4],\n            &[0, 1],\n            &[5],\n            &[0, 0, 1],\n            &[6],\n            &[1, 0],\n            &[7],\n            &[0, 0, 0, 0, 0],\n            &[8],\n            &[1, 1],\n            &[9],\n            &[0, 1, 0],\n        ],\n    );\n    exhaustive_vecs_min_length_helper(\n        3,\n        exhaustive_unsigneds::<u32>(),\n        &[\n            &[0, 0, 0],\n            &[0, 0, 0, 0],\n            &[0, 0, 1],\n            &[0, 0, 0, 0, 0],\n            &[0, 1, 0],\n            &[0, 0, 0, 1],\n            &[0, 1, 1],\n            &[0, 0, 0, 0, 0, 0],\n            &[1, 0, 0],\n            &[0, 0, 1, 0],\n            &[1, 0, 1],\n            &[0, 0, 0, 0, 1],\n            &[1, 1, 0],\n            &[0, 0, 1, 1],\n            &[1, 1, 1],\n            &[0, 0, 0, 0, 0, 0, 0],\n            &[0, 0, 2],\n            &[0, 1, 0, 0],\n            &[0, 0, 3],\n            &[0, 0, 0, 1, 0],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_k_compositions.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::vecs::exhaustive::lex_k_compositions;\n\nfn lex_k_compositions_helper(n: usize, k: usize, out: &[&[usize]]) {\n    let xss = lex_k_compositions(n, k).collect_vec();\n    assert_eq!(xss.iter().map(Vec::as_slice).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_lex_k_compositions() {\n    lex_k_compositions_helper(0, 0, &[&[]]);\n    lex_k_compositions_helper(0, 1, &[]);\n    lex_k_compositions_helper(1, 0, &[]);\n    lex_k_compositions_helper(1, 1, &[&[1]]);\n    lex_k_compositions_helper(1, 2, &[]);\n    lex_k_compositions_helper(2, 0, &[]);\n    lex_k_compositions_helper(2, 1, &[&[2]]);\n    lex_k_compositions_helper(2, 2, &[&[1, 1]]);\n    lex_k_compositions_helper(2, 3, &[]);\n\n    lex_k_compositions_helper(5, 0, &[]);\n    lex_k_compositions_helper(5, 1, &[&[5]]);\n    lex_k_compositions_helper(5, 2, &[&[1, 4], &[2, 3], &[3, 2], &[4, 1]]);\n    lex_k_compositions_helper(\n        5,\n        3,\n        &[&[1, 1, 3], &[1, 2, 2], &[1, 3, 1], &[2, 1, 2], &[2, 2, 1], &[3, 1, 1]],\n    );\n    lex_k_compositions_helper(\n        5,\n        4,\n        &[&[1, 1, 1, 2], &[1, 1, 2, 1], &[1, 2, 1, 1], &[2, 1, 1, 1]],\n    );\n    lex_k_compositions_helper(5, 5, &[&[1, 1, 1, 1, 1]]);\n    lex_k_compositions_helper(5, 6, &[]);\n\n    lex_k_compositions_helper(\n        10,\n        5,\n        &[\n            &[1, 1, 1, 1, 6],\n            &[1, 1, 1, 2, 5],\n            &[1, 1, 1, 3, 4],\n            &[1, 1, 1, 4, 3],\n            &[1, 1, 1, 5, 2],\n            &[1, 1, 1, 6, 1],\n            &[1, 1, 2, 1, 5],\n            &[1, 1, 2, 2, 4],\n            &[1, 1, 2, 3, 3],\n            &[1, 1, 2, 4, 2],\n            &[1, 1, 2, 5, 1],\n            &[1, 1, 3, 1, 4],\n            &[1, 1, 3, 2, 3],\n            &[1, 1, 3, 3, 2],\n            &[1, 1, 3, 4, 1],\n            &[1, 1, 4, 1, 3],\n            &[1, 1, 4, 2, 2],\n            &[1, 1, 4, 3, 1],\n            &[1, 1, 5, 1, 2],\n            &[1, 1, 5, 2, 1],\n            &[1, 1, 6, 1, 1],\n            &[1, 2, 1, 1, 5],\n            &[1, 2, 1, 2, 4],\n            &[1, 2, 1, 3, 3],\n            &[1, 2, 1, 4, 2],\n            &[1, 2, 1, 5, 1],\n            &[1, 2, 2, 1, 4],\n            &[1, 2, 2, 2, 3],\n            &[1, 2, 2, 3, 2],\n            &[1, 2, 2, 4, 1],\n            &[1, 2, 3, 1, 3],\n            &[1, 2, 3, 2, 2],\n            &[1, 2, 3, 3, 1],\n            &[1, 2, 4, 1, 2],\n            &[1, 2, 4, 2, 1],\n            &[1, 2, 5, 1, 1],\n            &[1, 3, 1, 1, 4],\n            &[1, 3, 1, 2, 3],\n            &[1, 3, 1, 3, 2],\n            &[1, 3, 1, 4, 1],\n            &[1, 3, 2, 1, 3],\n            &[1, 3, 2, 2, 2],\n            &[1, 3, 2, 3, 1],\n            &[1, 3, 3, 1, 2],\n            &[1, 3, 3, 2, 1],\n            &[1, 3, 4, 1, 1],\n            &[1, 4, 1, 1, 3],\n            &[1, 4, 1, 2, 2],\n            &[1, 4, 1, 3, 1],\n            &[1, 4, 2, 1, 2],\n            &[1, 4, 2, 2, 1],\n            &[1, 4, 3, 1, 1],\n            &[1, 5, 1, 1, 2],\n            &[1, 5, 1, 2, 1],\n            &[1, 5, 2, 1, 1],\n            &[1, 6, 1, 1, 1],\n            &[2, 1, 1, 1, 5],\n            &[2, 1, 1, 2, 4],\n            &[2, 1, 1, 3, 3],\n            &[2, 1, 1, 4, 2],\n            &[2, 1, 1, 5, 1],\n            &[2, 1, 2, 1, 4],\n            &[2, 1, 2, 2, 3],\n            &[2, 1, 2, 3, 2],\n            &[2, 1, 2, 4, 1],\n            &[2, 1, 3, 1, 3],\n            &[2, 1, 3, 2, 2],\n            &[2, 1, 3, 3, 1],\n            &[2, 1, 4, 1, 2],\n            &[2, 1, 4, 2, 1],\n            &[2, 1, 5, 1, 1],\n            &[2, 2, 1, 1, 4],\n            &[2, 2, 1, 2, 3],\n            &[2, 2, 1, 3, 2],\n            &[2, 2, 1, 4, 1],\n            &[2, 2, 2, 1, 3],\n            &[2, 2, 2, 2, 2],\n            &[2, 2, 2, 3, 1],\n            &[2, 2, 3, 1, 2],\n            &[2, 2, 3, 2, 1],\n            &[2, 2, 4, 1, 1],\n            &[2, 3, 1, 1, 3],\n            &[2, 3, 1, 2, 2],\n            &[2, 3, 1, 3, 1],\n            &[2, 3, 2, 1, 2],\n            &[2, 3, 2, 2, 1],\n            &[2, 3, 3, 1, 1],\n            &[2, 4, 1, 1, 2],\n            &[2, 4, 1, 2, 1],\n            &[2, 4, 2, 1, 1],\n            &[2, 5, 1, 1, 1],\n            &[3, 1, 1, 1, 4],\n            &[3, 1, 1, 2, 3],\n            &[3, 1, 1, 3, 2],\n            &[3, 1, 1, 4, 1],\n            &[3, 1, 2, 1, 3],\n            &[3, 1, 2, 2, 2],\n            &[3, 1, 2, 3, 1],\n            &[3, 1, 3, 1, 2],\n            &[3, 1, 3, 2, 1],\n            &[3, 1, 4, 1, 1],\n            &[3, 2, 1, 1, 3],\n            &[3, 2, 1, 2, 2],\n            &[3, 2, 1, 3, 1],\n            &[3, 2, 2, 1, 2],\n            &[3, 2, 2, 2, 1],\n            &[3, 2, 3, 1, 1],\n            &[3, 3, 1, 1, 2],\n            &[3, 3, 1, 2, 1],\n            &[3, 3, 2, 1, 1],\n            &[3, 4, 1, 1, 1],\n            &[4, 1, 1, 1, 3],\n            &[4, 1, 1, 2, 2],\n            &[4, 1, 1, 3, 1],\n            &[4, 1, 2, 1, 2],\n            &[4, 1, 2, 2, 1],\n            &[4, 1, 3, 1, 1],\n            &[4, 2, 1, 1, 2],\n            &[4, 2, 1, 2, 1],\n            &[4, 2, 2, 1, 1],\n            &[4, 3, 1, 1, 1],\n            &[5, 1, 1, 1, 2],\n            &[5, 1, 1, 2, 1],\n            &[5, 1, 2, 1, 1],\n            &[5, 2, 1, 1, 1],\n            &[6, 1, 1, 1, 1],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_ordered_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs;\nuse std::fmt::Debug;\n\nfn lex_ordered_unique_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_ordered_unique_vecs(xs), out);\n}\n\nfn lex_ordered_unique_vecs_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(lex_ordered_unique_vecs(xs), out_len, out);\n}\n\n#[test]\nfn test_lex_ordered_unique_vecs() {\n    lex_ordered_unique_vecs_small_helper(nevers(), 1, &[&[]]);\n    lex_ordered_unique_vecs_small_helper(exhaustive_units(), 2, &[&[], &[()]]);\n    lex_ordered_unique_vecs_small_helper(\n        exhaustive_bools(),\n        4,\n        &[&[], &[false], &[false, true], &[true]],\n    );\n    lex_ordered_unique_vecs_small_helper(\n        1..=6,\n        64,\n        &[\n            &[],\n            &[1],\n            &[1, 2],\n            &[1, 2, 3],\n            &[1, 2, 3, 4],\n            &[1, 2, 3, 4, 5],\n            &[1, 2, 3, 4, 5, 6],\n            &[1, 2, 3, 4, 6],\n            &[1, 2, 3, 5],\n            &[1, 2, 3, 5, 6],\n            &[1, 2, 3, 6],\n            &[1, 2, 4],\n            &[1, 2, 4, 5],\n            &[1, 2, 4, 5, 6],\n            &[1, 2, 4, 6],\n            &[1, 2, 5],\n            &[1, 2, 5, 6],\n            &[1, 2, 6],\n            &[1, 3],\n            &[1, 3, 4],\n        ],\n    );\n    lex_ordered_unique_vecs_small_helper(\n        'a'..='c',\n        8,\n        &[&[], &['a'], &['a', 'b'], &['a', 'b', 'c'], &['a', 'c'], &['b'], &['b', 'c'], &['c']],\n    );\n    lex_ordered_unique_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['a', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'b', 'c', 'd'],\n            &['a', 'b', 'c', 'd', 'e'],\n            &['a', 'b', 'c', 'd', 'e', 'f'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            ],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_ordered_unique_vecs_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_fixed_length;\nuse std::fmt::Debug;\n\nfn lex_ordered_unique_vecs_fixed_length_helper<I: Iterator>(len: u64, xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_ordered_unique_vecs_fixed_length(len, xs), out);\n}\n\nfn lex_ordered_unique_vecs_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        lex_ordered_unique_vecs_fixed_length(len, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_ordered_unique_vecs_fixed_length() {\n    // This demonstrates that 0 ^ 0 == 1:\n    lex_ordered_unique_vecs_fixed_length_small_helper(0, nevers(), 1, &[&[]]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(1, nevers(), 0, &[]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(2, nevers(), 0, &[]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(5, nevers(), 0, &[]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(1, exhaustive_units(), 1, &[&[()]]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(0, exhaustive_unsigneds::<u8>(), 1, &[&[]]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    lex_ordered_unique_vecs_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    lex_ordered_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        32640,\n        &[\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[0, 8],\n            &[0, 9],\n            &[0, 10],\n            &[0, 11],\n            &[0, 12],\n            &[0, 13],\n            &[0, 14],\n            &[0, 15],\n            &[0, 16],\n            &[0, 17],\n            &[0, 18],\n            &[0, 19],\n            &[0, 20],\n        ],\n    );\n    lex_ordered_unique_vecs_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[0, 1, 4],\n            &[0, 1, 5],\n            &[0, 1, 6],\n            &[0, 1, 7],\n            &[0, 1, 8],\n            &[0, 1, 9],\n            &[0, 1, 10],\n            &[0, 1, 11],\n            &[0, 1, 12],\n            &[0, 1, 13],\n            &[0, 1, 14],\n            &[0, 1, 15],\n            &[0, 1, 16],\n            &[0, 1, 17],\n            &[0, 1, 18],\n            &[0, 1, 19],\n            &[0, 1, 20],\n            &[0, 1, 21],\n        ],\n    );\n    lex_ordered_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        8128,\n        &[\n            &['a', 'b'],\n            &['a', 'c'],\n            &['a', 'd'],\n            &['a', 'e'],\n            &['a', 'f'],\n            &['a', 'g'],\n            &['a', 'h'],\n            &['a', 'i'],\n            &['a', 'j'],\n            &['a', 'k'],\n            &['a', 'l'],\n            &['a', 'm'],\n            &['a', 'n'],\n            &['a', 'o'],\n            &['a', 'p'],\n            &['a', 'q'],\n            &['a', 'r'],\n            &['a', 's'],\n            &['a', 't'],\n            &['a', 'u'],\n        ],\n    );\n    lex_ordered_unique_vecs_fixed_length_small_helper(\n        1,\n        exhaustive_bools(),\n        2,\n        &[&[false], &[true]],\n    );\n    lex_ordered_unique_vecs_fixed_length_small_helper(2, exhaustive_bools(), 1, &[&[false, true]]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    lex_ordered_unique_vecs_fixed_length_small_helper(\n        4,\n        1..=6,\n        15,\n        &[\n            &[1, 2, 3, 4],\n            &[1, 2, 3, 5],\n            &[1, 2, 3, 6],\n            &[1, 2, 4, 5],\n            &[1, 2, 4, 6],\n            &[1, 2, 5, 6],\n            &[1, 3, 4, 5],\n            &[1, 3, 4, 6],\n            &[1, 3, 5, 6],\n            &[1, 4, 5, 6],\n            &[2, 3, 4, 5],\n            &[2, 3, 4, 6],\n            &[2, 3, 5, 6],\n            &[2, 4, 5, 6],\n            &[3, 4, 5, 6],\n        ],\n    );\n    lex_ordered_unique_vecs_fixed_length_helper(\n        2,\n        lex_ordered_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            &[vec![0, 1], vec![0, 2]],\n            &[vec![0, 1], vec![0, 3]],\n            &[vec![0, 1], vec![0, 4]],\n            &[vec![0, 1], vec![0, 5]],\n            &[vec![0, 1], vec![0, 6]],\n            &[vec![0, 1], vec![0, 7]],\n            &[vec![0, 1], vec![0, 8]],\n            &[vec![0, 1], vec![0, 9]],\n            &[vec![0, 1], vec![0, 10]],\n            &[vec![0, 1], vec![0, 11]],\n            &[vec![0, 1], vec![0, 12]],\n            &[vec![0, 1], vec![0, 13]],\n            &[vec![0, 1], vec![0, 14]],\n            &[vec![0, 1], vec![0, 15]],\n            &[vec![0, 1], vec![0, 16]],\n            &[vec![0, 1], vec![0, 17]],\n            &[vec![0, 1], vec![0, 18]],\n            &[vec![0, 1], vec![0, 19]],\n            &[vec![0, 1], vec![0, 20]],\n            &[vec![0, 1], vec![0, 21]],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_ordered_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn lex_ordered_unique_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        lex_ordered_unique_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_ordered_unique_vecs_length_inclusive_range() {\n    lex_ordered_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    lex_ordered_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    lex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[&[], &[()]],\n    );\n    lex_ordered_unique_vecs_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    lex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[&[false, true]],\n    );\n    lex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_ordered_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn lex_ordered_unique_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        lex_ordered_unique_vecs_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_ordered_unique_vecs_length_range() {\n    lex_ordered_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    lex_ordered_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    lex_ordered_unique_vecs_length_range_small_helper(0, 5, exhaustive_units(), 2, &[&[], &[()]]);\n    lex_ordered_unique_vecs_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_ordered_unique_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    lex_ordered_unique_vecs_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    lex_ordered_unique_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[&[false, true]],\n    );\n    lex_ordered_unique_vecs_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_ordered_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn lex_ordered_unique_vecs_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_ordered_unique_vecs_min_length(min_length, xs), out);\n}\n\nfn lex_ordered_unique_vecs_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        lex_ordered_unique_vecs_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_ordered_unique_vecs_min_length() {\n    lex_ordered_unique_vecs_min_length_small_helper(0, nevers(), 1, &[&[]]);\n    lex_ordered_unique_vecs_min_length_small_helper(4, nevers(), 0, &[]);\n    lex_ordered_unique_vecs_min_length_small_helper(0, exhaustive_units(), 2, &[&[], &[()]]);\n    lex_ordered_unique_vecs_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_ordered_unique_vecs_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[&[], &[false], &[false, true], &[true]],\n    );\n    lex_ordered_unique_vecs_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[false], &[false, true], &[true]],\n    );\n    lex_ordered_unique_vecs_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[&[], &['a'], &['a', 'b'], &['a', 'b', 'c'], &['a', 'c'], &['b'], &['b', 'c'], &['c']],\n    );\n    lex_ordered_unique_vecs_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[&['a', 'b'], &['a', 'b', 'c'], &['a', 'c'], &['b', 'c']],\n    );\n    lex_ordered_unique_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['a', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'b', 'c', 'd'],\n            &['a', 'b', 'c', 'd', 'e'],\n            &['a', 'b', 'c', 'd', 'e', 'f'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            ],\n        ],\n    );\n    lex_ordered_unique_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'b', 'c'],\n            &['a', 'b', 'c', 'd'],\n            &['a', 'b', 'c', 'd', 'e'],\n            &['a', 'b', 'c', 'd', 'e', 'f'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u', 'v',\n            ],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_unique_vecs;\nuse std::fmt::Debug;\n\nfn lex_unique_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_unique_vecs(xs), out);\n}\n\nfn lex_unique_vecs_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(lex_unique_vecs(xs), out_len, out);\n}\n\n#[test]\nfn test_lex_unique_vecs() {\n    lex_unique_vecs_small_helper(nevers(), 1, &[&[]]);\n    lex_unique_vecs_small_helper(exhaustive_units(), 2, &[&[], &[()]]);\n    lex_unique_vecs_small_helper(\n        exhaustive_bools(),\n        5,\n        &[&[], &[false], &[false, true], &[true], &[true, false]],\n    );\n    lex_unique_vecs_small_helper(\n        1..=6,\n        1957,\n        &[\n            &[],\n            &[1],\n            &[1, 2],\n            &[1, 2, 3],\n            &[1, 2, 3, 4],\n            &[1, 2, 3, 4, 5],\n            &[1, 2, 3, 4, 5, 6],\n            &[1, 2, 3, 4, 6],\n            &[1, 2, 3, 4, 6, 5],\n            &[1, 2, 3, 5],\n            &[1, 2, 3, 5, 4],\n            &[1, 2, 3, 5, 4, 6],\n            &[1, 2, 3, 5, 6],\n            &[1, 2, 3, 5, 6, 4],\n            &[1, 2, 3, 6],\n            &[1, 2, 3, 6, 4],\n            &[1, 2, 3, 6, 4, 5],\n            &[1, 2, 3, 6, 5],\n            &[1, 2, 3, 6, 5, 4],\n            &[1, 2, 4],\n        ],\n    );\n    lex_unique_vecs_small_helper(\n        'a'..='c',\n        16,\n        &[\n            &[],\n            &['a'],\n            &['a', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c'],\n            &['a', 'c', 'b'],\n            &['b'],\n            &['b', 'a'],\n            &['b', 'a', 'c'],\n            &['b', 'c'],\n            &['b', 'c', 'a'],\n            &['c'],\n            &['c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    lex_unique_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['a', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'b', 'c', 'd'],\n            &['a', 'b', 'c', 'd', 'e'],\n            &['a', 'b', 'c', 'd', 'e', 'f'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            ],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_unique_vecs_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_unique_vecs_fixed_length;\nuse std::fmt::Debug;\n\nfn lex_unique_vecs_fixed_length_helper<I: Iterator>(len: u64, xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_unique_vecs_fixed_length(len, xs), out);\n}\n\nfn lex_unique_vecs_fixed_length_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(lex_unique_vecs_fixed_length(len, xs), out_len, out);\n}\n\n#[test]\nfn test_lex_unique_vecs_fixed_length() {\n    // This demonstrates that 0 ^ 0 == 1:\n    lex_unique_vecs_fixed_length_small_helper(0, nevers(), 1, &[&[]]);\n    lex_unique_vecs_fixed_length_small_helper(1, nevers(), 0, &[]);\n    lex_unique_vecs_fixed_length_small_helper(2, nevers(), 0, &[]);\n    lex_unique_vecs_fixed_length_small_helper(5, nevers(), 0, &[]);\n    lex_unique_vecs_fixed_length_small_helper(1, exhaustive_units(), 1, &[&[()]]);\n    lex_unique_vecs_fixed_length_small_helper(2, exhaustive_units(), 0, &[]);\n    lex_unique_vecs_fixed_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_unique_vecs_fixed_length_small_helper(0, exhaustive_unsigneds::<u8>(), 1, &[&[]]);\n    lex_unique_vecs_fixed_length_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    lex_unique_vecs_fixed_length_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    lex_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        65280,\n        &[\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[0, 8],\n            &[0, 9],\n            &[0, 10],\n            &[0, 11],\n            &[0, 12],\n            &[0, 13],\n            &[0, 14],\n            &[0, 15],\n            &[0, 16],\n            &[0, 17],\n            &[0, 18],\n            &[0, 19],\n            &[0, 20],\n        ],\n    );\n    lex_unique_vecs_fixed_length_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[0, 1, 4],\n            &[0, 1, 5],\n            &[0, 1, 6],\n            &[0, 1, 7],\n            &[0, 1, 8],\n            &[0, 1, 9],\n            &[0, 1, 10],\n            &[0, 1, 11],\n            &[0, 1, 12],\n            &[0, 1, 13],\n            &[0, 1, 14],\n            &[0, 1, 15],\n            &[0, 1, 16],\n            &[0, 1, 17],\n            &[0, 1, 18],\n            &[0, 1, 19],\n            &[0, 1, 20],\n            &[0, 1, 21],\n        ],\n    );\n    lex_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        16256,\n        &[\n            &['a', 'b'],\n            &['a', 'c'],\n            &['a', 'd'],\n            &['a', 'e'],\n            &['a', 'f'],\n            &['a', 'g'],\n            &['a', 'h'],\n            &['a', 'i'],\n            &['a', 'j'],\n            &['a', 'k'],\n            &['a', 'l'],\n            &['a', 'm'],\n            &['a', 'n'],\n            &['a', 'o'],\n            &['a', 'p'],\n            &['a', 'q'],\n            &['a', 'r'],\n            &['a', 's'],\n            &['a', 't'],\n            &['a', 'u'],\n        ],\n    );\n    lex_unique_vecs_fixed_length_small_helper(1, exhaustive_bools(), 2, &[&[false], &[true]]);\n    lex_unique_vecs_fixed_length_small_helper(\n        2,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    lex_unique_vecs_fixed_length_small_helper(4, exhaustive_bools(), 0, &[]);\n    lex_unique_vecs_fixed_length_small_helper(\n        4,\n        1..=6,\n        360,\n        &[\n            &[1, 2, 3, 4],\n            &[1, 2, 3, 5],\n            &[1, 2, 3, 6],\n            &[1, 2, 4, 3],\n            &[1, 2, 4, 5],\n            &[1, 2, 4, 6],\n            &[1, 2, 5, 3],\n            &[1, 2, 5, 4],\n            &[1, 2, 5, 6],\n            &[1, 2, 6, 3],\n            &[1, 2, 6, 4],\n            &[1, 2, 6, 5],\n            &[1, 3, 2, 4],\n            &[1, 3, 2, 5],\n            &[1, 3, 2, 6],\n            &[1, 3, 4, 2],\n            &[1, 3, 4, 5],\n            &[1, 3, 4, 6],\n            &[1, 3, 5, 2],\n            &[1, 3, 5, 4],\n        ],\n    );\n    lex_unique_vecs_fixed_length_helper(\n        2,\n        lex_unique_vecs_fixed_length(2, exhaustive_unsigneds::<u8>()),\n        &[\n            &[vec![0, 1], vec![0, 2]],\n            &[vec![0, 1], vec![0, 3]],\n            &[vec![0, 1], vec![0, 4]],\n            &[vec![0, 1], vec![0, 5]],\n            &[vec![0, 1], vec![0, 6]],\n            &[vec![0, 1], vec![0, 7]],\n            &[vec![0, 1], vec![0, 8]],\n            &[vec![0, 1], vec![0, 9]],\n            &[vec![0, 1], vec![0, 10]],\n            &[vec![0, 1], vec![0, 11]],\n            &[vec![0, 1], vec![0, 12]],\n            &[vec![0, 1], vec![0, 13]],\n            &[vec![0, 1], vec![0, 14]],\n            &[vec![0, 1], vec![0, 15]],\n            &[vec![0, 1], vec![0, 16]],\n            &[vec![0, 1], vec![0, 17]],\n            &[vec![0, 1], vec![0, 18]],\n            &[vec![0, 1], vec![0, 19]],\n            &[vec![0, 1], vec![0, 20]],\n            &[vec![0, 1], vec![0, 21]],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn lex_unique_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        lex_unique_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_lex_unique_vecs_length_inclusive_range() {\n    lex_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    lex_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    lex_unique_vecs_length_inclusive_range_small_helper(0, 4, exhaustive_units(), 2, &[&[], &[()]]);\n    lex_unique_vecs_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    lex_unique_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    lex_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn lex_unique_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(lex_unique_vecs_length_range(a, b, xs), out_len, out);\n}\n\n#[test]\nfn test_lex_unique_vecs_length_range() {\n    lex_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    lex_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    lex_unique_vecs_length_range_small_helper(0, 5, exhaustive_units(), 2, &[&[], &[()]]);\n    lex_unique_vecs_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    lex_unique_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    lex_unique_vecs_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    lex_unique_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    lex_unique_vecs_length_range_small_helper(1, 2, 'a'..='c', 3, &[&['a'], &['b'], &['c']]);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn lex_unique_vecs_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_unique_vecs_min_length(min_length, xs), out);\n}\n\nfn lex_unique_vecs_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(lex_unique_vecs_min_length(min_length, xs), out_len, out);\n}\n\n#[test]\nfn test_lex_unique_vecs_min_length() {\n    lex_unique_vecs_min_length_small_helper(0, nevers(), 1, &[&[]]);\n    lex_unique_vecs_min_length_small_helper(4, nevers(), 0, &[]);\n    lex_unique_vecs_min_length_small_helper(0, exhaustive_units(), 2, &[&[], &[()]]);\n    lex_unique_vecs_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    lex_unique_vecs_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        5,\n        &[&[], &[false], &[false, true], &[true], &[true, false]],\n    );\n    lex_unique_vecs_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        4,\n        &[&[false], &[false, true], &[true], &[true, false]],\n    );\n    lex_unique_vecs_min_length_small_helper(\n        0,\n        'a'..='c',\n        16,\n        &[\n            &[],\n            &['a'],\n            &['a', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c'],\n            &['a', 'c', 'b'],\n            &['b'],\n            &['b', 'a'],\n            &['b', 'a', 'c'],\n            &['b', 'c'],\n            &['b', 'c', 'a'],\n            &['c'],\n            &['c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    lex_unique_vecs_min_length_small_helper(\n        2,\n        'a'..='c',\n        12,\n        &[\n            &['a', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c'],\n            &['a', 'c', 'b'],\n            &['b', 'a'],\n            &['b', 'a', 'c'],\n            &['b', 'c'],\n            &['b', 'c', 'a'],\n            &['c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    lex_unique_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['a', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'b', 'c', 'd'],\n            &['a', 'b', 'c', 'd', 'e'],\n            &['a', 'b', 'c', 'd', 'e', 'f'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            ],\n        ],\n    );\n    lex_unique_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'b', 'c'],\n            &['a', 'b', 'c', 'd'],\n            &['a', 'b', 'c', 'd', 'e'],\n            &['a', 'b', 'c', 'd', 'e', 'f'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],\n            &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u',\n            ],\n            &[\n                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\n                'q', 'r', 's', 't', 'u', 'v',\n            ],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_vecs_fixed_length_from_single.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::lex_vecs_fixed_length_from_single;\nuse std::fmt::Debug;\n\nfn lex_vecs_fixed_length_from_single_helper<I: Iterator>(len: u64, xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_vecs_fixed_length_from_single(len, xs), out);\n}\n\nfn lex_vecs_fixed_length_from_single_small_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(lex_vecs_fixed_length_from_single(len, xs), out_len, out);\n}\n\n#[test]\nfn test_lex_vecs_fixed_length_from_single() {\n    // This demonstrates that 0 ^ 0 == 1:\n    lex_vecs_fixed_length_from_single_small_helper(0, nevers(), 1, &[&[]]);\n    lex_vecs_fixed_length_from_single_small_helper(1, nevers(), 0, &[]);\n    lex_vecs_fixed_length_from_single_small_helper(2, nevers(), 0, &[]);\n    lex_vecs_fixed_length_from_single_small_helper(5, nevers(), 0, &[]);\n    lex_vecs_fixed_length_from_single_small_helper(1, exhaustive_units(), 1, &[&[()]]);\n    lex_vecs_fixed_length_from_single_small_helper(2, exhaustive_units(), 1, &[&[(), ()]]);\n    lex_vecs_fixed_length_from_single_small_helper(5, exhaustive_units(), 1, &[&[(); 5]]);\n    lex_vecs_fixed_length_from_single_small_helper(0, exhaustive_unsigneds::<u8>(), 1, &[&[]]);\n    lex_vecs_fixed_length_from_single_small_helper(\n        1,\n        exhaustive_unsigneds::<u8>(),\n        256,\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_helper(\n        1,\n        exhaustive_unsigneds::<u64>(),\n        &[\n            &[0],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[7],\n            &[8],\n            &[9],\n            &[10],\n            &[11],\n            &[12],\n            &[13],\n            &[14],\n            &[15],\n            &[16],\n            &[17],\n            &[18],\n            &[19],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_small_helper(\n        2,\n        exhaustive_unsigneds::<u8>(),\n        0x10000,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[0, 8],\n            &[0, 9],\n            &[0, 10],\n            &[0, 11],\n            &[0, 12],\n            &[0, 13],\n            &[0, 14],\n            &[0, 15],\n            &[0, 16],\n            &[0, 17],\n            &[0, 18],\n            &[0, 19],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_helper(\n        3,\n        exhaustive_unsigneds::<u8>(),\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 0, 4],\n            &[0, 0, 5],\n            &[0, 0, 6],\n            &[0, 0, 7],\n            &[0, 0, 8],\n            &[0, 0, 9],\n            &[0, 0, 10],\n            &[0, 0, 11],\n            &[0, 0, 12],\n            &[0, 0, 13],\n            &[0, 0, 14],\n            &[0, 0, 15],\n            &[0, 0, 16],\n            &[0, 0, 17],\n            &[0, 0, 18],\n            &[0, 0, 19],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_small_helper(\n        2,\n        exhaustive_ascii_chars(),\n        0x4000,\n        &[\n            &['a', 'a'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['a', 'd'],\n            &['a', 'e'],\n            &['a', 'f'],\n            &['a', 'g'],\n            &['a', 'h'],\n            &['a', 'i'],\n            &['a', 'j'],\n            &['a', 'k'],\n            &['a', 'l'],\n            &['a', 'm'],\n            &['a', 'n'],\n            &['a', 'o'],\n            &['a', 'p'],\n            &['a', 'q'],\n            &['a', 'r'],\n            &['a', 's'],\n            &['a', 't'],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_small_helper(1, exhaustive_bools(), 2, &[&[false], &[true]]);\n    lex_vecs_fixed_length_from_single_small_helper(\n        2,\n        exhaustive_bools(),\n        4,\n        &[&[false, false], &[false, true], &[true, false], &[true, true]],\n    );\n    lex_vecs_fixed_length_from_single_small_helper(\n        4,\n        exhaustive_bools(),\n        16,\n        &[\n            &[false, false, false, false],\n            &[false, false, false, true],\n            &[false, false, true, false],\n            &[false, false, true, true],\n            &[false, true, false, false],\n            &[false, true, false, true],\n            &[false, true, true, false],\n            &[false, true, true, true],\n            &[true, false, false, false],\n            &[true, false, false, true],\n            &[true, false, true, false],\n            &[true, false, true, true],\n            &[true, true, false, false],\n            &[true, true, false, true],\n            &[true, true, true, false],\n            &[true, true, true, true],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_small_helper(\n        10,\n        exhaustive_bools(),\n        1024,\n        &[\n            &[false, false, false, false, false, false, false, false, false, false],\n            &[false, false, false, false, false, false, false, false, false, true],\n            &[false, false, false, false, false, false, false, false, true, false],\n            &[false, false, false, false, false, false, false, false, true, true],\n            &[false, false, false, false, false, false, false, true, false, false],\n            &[false, false, false, false, false, false, false, true, false, true],\n            &[false, false, false, false, false, false, false, true, true, false],\n            &[false, false, false, false, false, false, false, true, true, true],\n            &[false, false, false, false, false, false, true, false, false, false],\n            &[false, false, false, false, false, false, true, false, false, true],\n            &[false, false, false, false, false, false, true, false, true, false],\n            &[false, false, false, false, false, false, true, false, true, true],\n            &[false, false, false, false, false, false, true, true, false, false],\n            &[false, false, false, false, false, false, true, true, false, true],\n            &[false, false, false, false, false, false, true, true, true, false],\n            &[false, false, false, false, false, false, true, true, true, true],\n            &[false, false, false, false, false, true, false, false, false, false],\n            &[false, false, false, false, false, true, false, false, false, true],\n            &[false, false, false, false, false, true, false, false, true, false],\n            &[false, false, false, false, false, true, false, false, true, true],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_small_helper(\n        10,\n        0..3,\n        59049,\n        &[\n            &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 0, 2],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 1, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 1, 2],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 2, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 2, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 2, 2],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 0, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 0, 2],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 1, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 1, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 1, 2],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 2, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 2, 1],\n            &[0, 0, 0, 0, 0, 0, 0, 1, 2, 2],\n            &[0, 0, 0, 0, 0, 0, 0, 2, 0, 0],\n            &[0, 0, 0, 0, 0, 0, 0, 2, 0, 1],\n        ],\n    );\n    lex_vecs_fixed_length_from_single_helper(\n        2,\n        lex_vecs_fixed_length_from_single(2, exhaustive_unsigneds::<u8>()),\n        &[\n            &[vec![0, 0], vec![0, 0]],\n            &[vec![0, 0], vec![0, 1]],\n            &[vec![0, 0], vec![0, 2]],\n            &[vec![0, 0], vec![0, 3]],\n            &[vec![0, 0], vec![0, 4]],\n            &[vec![0, 0], vec![0, 5]],\n            &[vec![0, 0], vec![0, 6]],\n            &[vec![0, 0], vec![0, 7]],\n            &[vec![0, 0], vec![0, 8]],\n            &[vec![0, 0], vec![0, 9]],\n            &[vec![0, 0], vec![0, 10]],\n            &[vec![0, 0], vec![0, 11]],\n            &[vec![0, 0], vec![0, 12]],\n            &[vec![0, 0], vec![0, 13]],\n            &[vec![0, 0], vec![0, 14]],\n            &[vec![0, 0], vec![0, 15]],\n            &[vec![0, 0], vec![0, 16]],\n            &[vec![0, 0], vec![0, 17]],\n            &[vec![0, 0], vec![0, 18]],\n            &[vec![0, 0], vec![0, 19]],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_vecs_fixed_length_m_inputs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::{exhaustive_positive_primitive_ints, exhaustive_unsigneds};\nuse malachite_base::vecs::exhaustive::lex_vecs_fixed_length_2_inputs;\nuse std::fmt::Debug;\nuse std::iter::empty;\n\nfn lex_vecs_fixed_length_2_inputs_helper<\n    T: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs: &I,\n    ys: &J,\n    output_to_input_map: &[usize],\n    out_len: Option<usize>,\n    out: &[&[T]],\n) {\n    let xss = lex_vecs_fixed_length_2_inputs(xs.clone(), ys.clone(), output_to_input_map);\n    let xss_prefix = xss.clone().take(20).collect_vec();\n    assert_eq!(\n        xss_prefix\n            .iter()\n            .map(Vec::as_slice)\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n    if let Some(out_len) = out_len {\n        assert_eq!(xss.count(), out_len);\n    }\n}\n\n#[test]\nfn test_lex_vecs_fixed_length_2_inputs() {\n    lex_vecs_fixed_length_2_inputs_helper(&nevers(), &nevers(), &[0, 1], Some(0), &[]);\n    lex_vecs_fixed_length_2_inputs_helper(\n        &empty(),\n        &exhaustive_unsigneds::<u8>(),\n        &[0, 1],\n        Some(0),\n        &[],\n    );\n    lex_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_unsigneds::<u64>(),\n        &exhaustive_positive_primitive_ints::<u64>(),\n        &[0, 1],\n        None,\n        &[\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[0, 4],\n            &[0, 5],\n            &[0, 6],\n            &[0, 7],\n            &[0, 8],\n            &[0, 9],\n            &[0, 10],\n            &[0, 11],\n            &[0, 12],\n            &[0, 13],\n            &[0, 14],\n            &[0, 15],\n            &[0, 16],\n            &[0, 17],\n            &[0, 18],\n            &[0, 19],\n            &[0, 20],\n        ],\n    );\n    lex_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_ascii_chars(),\n        &['x', 'y', 'z'].iter().copied(),\n        &[0, 1],\n        Some(384),\n        &[\n            &['a', 'x'],\n            &['a', 'y'],\n            &['a', 'z'],\n            &['b', 'x'],\n            &['b', 'y'],\n            &['b', 'z'],\n            &['c', 'x'],\n            &['c', 'y'],\n            &['c', 'z'],\n            &['d', 'x'],\n            &['d', 'y'],\n            &['d', 'z'],\n            &['e', 'x'],\n            &['e', 'y'],\n            &['e', 'z'],\n            &['f', 'x'],\n            &['f', 'y'],\n            &['f', 'z'],\n            &['g', 'x'],\n            &['g', 'y'],\n        ],\n    );\n    lex_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_ascii_chars(),\n        &['x', 'y', 'z'].iter().copied(),\n        &[0, 1, 1],\n        Some(1152),\n        &[\n            &['a', 'x', 'x'],\n            &['a', 'x', 'y'],\n            &['a', 'x', 'z'],\n            &['a', 'y', 'x'],\n            &['a', 'y', 'y'],\n            &['a', 'y', 'z'],\n            &['a', 'z', 'x'],\n            &['a', 'z', 'y'],\n            &['a', 'z', 'z'],\n            &['b', 'x', 'x'],\n            &['b', 'x', 'y'],\n            &['b', 'x', 'z'],\n            &['b', 'y', 'x'],\n            &['b', 'y', 'y'],\n            &['b', 'y', 'z'],\n            &['b', 'z', 'x'],\n            &['b', 'z', 'y'],\n            &['b', 'z', 'z'],\n            &['c', 'x', 'x'],\n            &['c', 'x', 'y'],\n        ],\n    );\n    lex_vecs_fixed_length_2_inputs_helper(\n        &exhaustive_ascii_chars(),\n        &['x', 'y', 'z'].iter().copied(),\n        &[0, 1, 0],\n        Some(49152),\n        &[\n            &['a', 'x', 'a'],\n            &['a', 'x', 'b'],\n            &['a', 'x', 'c'],\n            &['a', 'x', 'd'],\n            &['a', 'x', 'e'],\n            &['a', 'x', 'f'],\n            &['a', 'x', 'g'],\n            &['a', 'x', 'h'],\n            &['a', 'x', 'i'],\n            &['a', 'x', 'j'],\n            &['a', 'x', 'k'],\n            &['a', 'x', 'l'],\n            &['a', 'x', 'm'],\n            &['a', 'x', 'n'],\n            &['a', 'x', 'o'],\n            &['a', 'x', 'p'],\n            &['a', 'x', 'q'],\n            &['a', 'x', 'r'],\n            &['a', 'x', 's'],\n            &['a', 'x', 't'],\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn lex_vecs_fixed_length_2_inputs_fail_1() {\n    lex_vecs_fixed_length_2_inputs(0..2, 0..3, &[]);\n}\n\n#[test]\n#[should_panic]\nfn lex_vecs_fixed_length_2_inputs_fail_2() {\n    lex_vecs_fixed_length_2_inputs(0..2, 0..3, &[0]);\n}\n\n#[test]\n#[should_panic]\nfn lex_vecs_fixed_length_2_inputs_fail_3() {\n    lex_vecs_fixed_length_2_inputs(0..2, 0..3, &[1]);\n}\n\n#[test]\n#[should_panic]\nfn lex_vecs_fixed_length_2_inputs_fail_4() {\n    lex_vecs_fixed_length_2_inputs(0..2, 0..3, &[0, 1, 2]);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/lex_vecs_length_n.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::lex_vecs_length_3;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::vecs::exhaustive::{\n    exhaustive_vecs_fixed_length_from_single, lex_vecs_length_2,\n};\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::iter::{empty, once};\n\nfn lex_vecs_length_2_helper<T: Clone + Debug + Eq, I: Iterator<Item = T>, J: Iterator<Item = T>>(\n    xs: I,\n    ys: J,\n    out: &[&[T]],\n) {\n    exhaustive_vecs_helper_helper(lex_vecs_length_2(xs, ys), out);\n}\n\nfn lex_vecs_length_2_finite_helper<\n    T: Clone + Debug + Eq,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n    out_len: usize,\n    out: &[&[T]],\n) {\n    exhaustive_vecs_small_helper_helper(lex_vecs_length_2(xs, ys), out_len, out);\n}\n\n#[test]\nfn test_lex_vecs_length_2() {\n    lex_vecs_length_2_finite_helper(nevers(), nevers(), 0, &[]);\n    lex_vecs_length_2_finite_helper(empty(), 0..4, 0, &[]);\n    lex_vecs_length_2_finite_helper(once(0), once(1), 1, &[&[0, 1]]);\n    lex_vecs_length_2_finite_helper(once(0), 0..4, 4, &[&[0, 0], &[0, 1], &[0, 2], &[0, 3]]);\n    lex_vecs_length_2_finite_helper(\n        exhaustive_unsigneds::<u8>(),\n        0..4,\n        1024,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 0],\n            &[3, 1],\n            &[3, 2],\n            &[3, 3],\n            &[4, 0],\n            &[4, 1],\n            &[4, 2],\n            &[4, 3],\n        ],\n    );\n    lex_vecs_length_2_helper(\n        exhaustive_unsigneds::<u64>(),\n        0..4,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[0, 3],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[1, 3],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[2, 3],\n            &[3, 0],\n            &[3, 1],\n            &[3, 2],\n            &[3, 3],\n            &[4, 0],\n            &[4, 1],\n            &[4, 2],\n            &[4, 3],\n        ],\n    );\n    lex_vecs_length_2_finite_helper(\n        0..2,\n        0..4,\n        8,\n        &[&[0, 0], &[0, 1], &[0, 2], &[0, 3], &[1, 0], &[1, 1], &[1, 2], &[1, 3]],\n    );\n    lex_vecs_length_2_finite_helper(\n        0..5,\n        0..3,\n        15,\n        &[\n            &[0, 0],\n            &[0, 1],\n            &[0, 2],\n            &[1, 0],\n            &[1, 1],\n            &[1, 2],\n            &[2, 0],\n            &[2, 1],\n            &[2, 2],\n            &[3, 0],\n            &[3, 1],\n            &[3, 2],\n            &[4, 0],\n            &[4, 1],\n            &[4, 2],\n        ],\n    );\n    lex_vecs_length_2_finite_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        ['x', 'y', 'z'].iter().copied(),\n        9,\n        &[\n            &['a', 'x'],\n            &['a', 'y'],\n            &['a', 'z'],\n            &['b', 'x'],\n            &['b', 'y'],\n            &['b', 'z'],\n            &['c', 'x'],\n            &['c', 'y'],\n            &['c', 'z'],\n        ],\n    );\n    lex_vecs_length_2_finite_helper(\n        lex_vecs_length_2(exhaustive_orderings(), [Less, Greater].iter().copied()),\n        exhaustive_vecs_fixed_length_from_single(3, [Less, Greater].iter().copied()),\n        48,\n        &[\n            &[vec![Equal, Less], vec![Less, Less, Less]],\n            &[vec![Equal, Less], vec![Less, Less, Greater]],\n            &[vec![Equal, Less], vec![Less, Greater, Less]],\n            &[vec![Equal, Less], vec![Less, Greater, Greater]],\n            &[vec![Equal, Less], vec![Greater, Less, Less]],\n            &[vec![Equal, Less], vec![Greater, Less, Greater]],\n            &[vec![Equal, Less], vec![Greater, Greater, Less]],\n            &[vec![Equal, Less], vec![Greater, Greater, Greater]],\n            &[vec![Equal, Greater], vec![Less, Less, Less]],\n            &[vec![Equal, Greater], vec![Less, Less, Greater]],\n            &[vec![Equal, Greater], vec![Less, Greater, Less]],\n            &[vec![Equal, Greater], vec![Less, Greater, Greater]],\n            &[vec![Equal, Greater], vec![Greater, Less, Less]],\n            &[vec![Equal, Greater], vec![Greater, Less, Greater]],\n            &[vec![Equal, Greater], vec![Greater, Greater, Less]],\n            &[vec![Equal, Greater], vec![Greater, Greater, Greater]],\n            &[vec![Less, Less], vec![Less, Less, Less]],\n            &[vec![Less, Less], vec![Less, Less, Greater]],\n            &[vec![Less, Less], vec![Less, Greater, Less]],\n            &[vec![Less, Less], vec![Less, Greater, Greater]],\n        ],\n    );\n}\n\nfn lex_vecs_length_3_helper<\n    T,\n    I: Iterator<Item = T>,\n    J: Iterator<Item = T>,\n    K: Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(lex_vecs_length_3(xs, ys, zs), out);\n}\n\nfn lex_vecs_length_3_finite_helper<\n    T,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n    K: Clone + Iterator<Item = T>,\n>(\n    xs: I,\n    ys: J,\n    zs: K,\n    out_len: usize,\n    out: &[&[T]],\n) where\n    T: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(lex_vecs_length_3(xs, ys, zs), out_len, out);\n}\n\n#[test]\nfn test_lex_vecs_length_3() {\n    lex_vecs_length_3_finite_helper(nevers(), nevers(), nevers(), 0, &[]);\n    lex_vecs_length_3_finite_helper(empty(), 0..4, 0..5, 0, &[]);\n    lex_vecs_length_3_finite_helper(once(0), once(1), once(5), 1, &[&[0, 1, 5]]);\n    lex_vecs_length_3_finite_helper(\n        once(0),\n        once(3),\n        0..4,\n        4,\n        &[&[0, 3, 0], &[0, 3, 1], &[0, 3, 2], &[0, 3, 3]],\n    );\n    lex_vecs_length_3_finite_helper(\n        exhaustive_unsigneds::<u8>(),\n        0..4,\n        0..4,\n        4096,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 2, 2],\n            &[0, 2, 3],\n            &[0, 3, 0],\n            &[0, 3, 1],\n            &[0, 3, 2],\n            &[0, 3, 3],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 0, 2],\n            &[1, 0, 3],\n        ],\n    );\n    lex_vecs_length_3_helper(\n        exhaustive_unsigneds::<u64>(),\n        0..4,\n        0..4,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 2, 2],\n            &[0, 2, 3],\n            &[0, 3, 0],\n            &[0, 3, 1],\n            &[0, 3, 2],\n            &[0, 3, 3],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 0, 2],\n            &[1, 0, 3],\n        ],\n    );\n    lex_vecs_length_3_finite_helper(\n        0..2,\n        0..3,\n        0..3,\n        18,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 0, 2],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[0, 1, 2],\n            &[0, 2, 0],\n            &[0, 2, 1],\n            &[0, 2, 2],\n            &[1, 0, 0],\n            &[1, 0, 1],\n            &[1, 0, 2],\n            &[1, 1, 0],\n            &[1, 1, 1],\n            &[1, 1, 2],\n            &[1, 2, 0],\n            &[1, 2, 1],\n            &[1, 2, 2],\n        ],\n    );\n    lex_vecs_length_3_finite_helper(\n        0..11,\n        0..12,\n        0..13,\n        1716,\n        &[\n            &[0, 0, 0],\n            &[0, 0, 1],\n            &[0, 0, 2],\n            &[0, 0, 3],\n            &[0, 0, 4],\n            &[0, 0, 5],\n            &[0, 0, 6],\n            &[0, 0, 7],\n            &[0, 0, 8],\n            &[0, 0, 9],\n            &[0, 0, 10],\n            &[0, 0, 11],\n            &[0, 0, 12],\n            &[0, 1, 0],\n            &[0, 1, 1],\n            &[0, 1, 2],\n            &[0, 1, 3],\n            &[0, 1, 4],\n            &[0, 1, 5],\n            &[0, 1, 6],\n        ],\n    );\n    lex_vecs_length_3_finite_helper(\n        ['a', 'b', 'c'].iter().copied(),\n        ['x', 'y', 'z'].iter().copied(),\n        ['0', '1', '2'].iter().copied(),\n        27,\n        &[\n            &['a', 'x', '0'],\n            &['a', 'x', '1'],\n            &['a', 'x', '2'],\n            &['a', 'y', '0'],\n            &['a', 'y', '1'],\n            &['a', 'y', '2'],\n            &['a', 'z', '0'],\n            &['a', 'z', '1'],\n            &['a', 'z', '2'],\n            &['b', 'x', '0'],\n            &['b', 'x', '1'],\n            &['b', 'x', '2'],\n            &['b', 'y', '0'],\n            &['b', 'y', '1'],\n            &['b', 'y', '2'],\n            &['b', 'z', '0'],\n            &['b', 'z', '1'],\n            &['b', 'z', '2'],\n            &['c', 'x', '0'],\n            &['c', 'x', '1'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/next_bit_pattern.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::repeat_n;\nuse malachite_base::num::arithmetic::traits::BinomialCoefficient;\nuse malachite_base::vecs::exhaustive::next_bit_pattern;\n\nfn pattern_to_string(pattern: &[bool]) -> String {\n    let mut s = String::with_capacity(pattern.len());\n    for &b in pattern.iter().rev() {\n        s.push(if b { '1' } else { '0' });\n    }\n    s\n}\n\nfn next_bit_pattern_helper(\n    width: usize,\n    min_bits: usize,\n    max_bits: usize,\n    expected_patterns: &[&'static str],\n) {\n    assert!(min_bits <= max_bits);\n    assert_ne!(max_bits, 0);\n    assert!(width >= min_bits);\n    let mut pattern: Vec<bool> = repeat_n(false, width).collect();\n    for b in &mut pattern[..min_bits] {\n        *b = true;\n    }\n    let mut bit_count = min_bits;\n    let mut patterns = Vec::new();\n    while pattern.len() == width {\n        assert_eq!(pattern.iter().filter(|&&b| b).count(), bit_count);\n        assert!(bit_count >= min_bits);\n        assert!(bit_count <= max_bits);\n        patterns.push(pattern_to_string(&pattern));\n        next_bit_pattern(&mut pattern, &mut bit_count, min_bits, max_bits);\n    }\n    assert_eq!(\n        patterns.len(),\n        (min_bits..=max_bits)\n            .map(|b| usize::binomial_coefficient(width, b))\n            .sum()\n    );\n    assert_eq!(patterns, expected_patterns);\n}\n\n#[test]\nfn test_next_bit_pattern() {\n    next_bit_pattern_helper(5, 1, 1, &[\"00001\", \"00010\", \"00100\", \"01000\", \"10000\"]);\n    next_bit_pattern_helper(\n        5,\n        2,\n        2,\n        &[\"00011\", \"00101\", \"00110\", \"01001\", \"01010\", \"01100\", \"10001\", \"10010\", \"10100\", \"11000\"],\n    );\n    next_bit_pattern_helper(\n        5,\n        3,\n        3,\n        &[\"00111\", \"01011\", \"01101\", \"01110\", \"10011\", \"10101\", \"10110\", \"11001\", \"11010\", \"11100\"],\n    );\n    next_bit_pattern_helper(5, 4, 4, &[\"01111\", \"10111\", \"11011\", \"11101\", \"11110\"]);\n    next_bit_pattern_helper(5, 5, 5, &[\"11111\"]);\n\n    next_bit_pattern_helper(\n        5,\n        0,\n        1,\n        &[\"00000\", \"00001\", \"00010\", \"00100\", \"01000\", \"10000\"],\n    );\n    next_bit_pattern_helper(\n        5,\n        1,\n        2,\n        &[\n            \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"01000\", \"01001\", \"01010\",\n            \"01100\", \"10000\", \"10001\", \"10010\", \"10100\", \"11000\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        2,\n        3,\n        &[\n            \"00011\", \"00101\", \"00110\", \"00111\", \"01001\", \"01010\", \"01011\", \"01100\", \"01101\",\n            \"01110\", \"10001\", \"10010\", \"10011\", \"10100\", \"10101\", \"10110\", \"11000\", \"11001\",\n            \"11010\", \"11100\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        3,\n        4,\n        &[\n            \"00111\", \"01011\", \"01101\", \"01110\", \"01111\", \"10011\", \"10101\", \"10110\", \"10111\",\n            \"11001\", \"11010\", \"11011\", \"11100\", \"11101\", \"11110\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        4,\n        5,\n        &[\"01111\", \"10111\", \"11011\", \"11101\", \"11110\", \"11111\"],\n    );\n\n    next_bit_pattern_helper(\n        5,\n        0,\n        2,\n        &[\n            \"00000\", \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"01000\", \"01001\",\n            \"01010\", \"01100\", \"10000\", \"10001\", \"10010\", \"10100\", \"11000\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        1,\n        3,\n        &[\n            \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"00111\", \"01000\", \"01001\",\n            \"01010\", \"01011\", \"01100\", \"01101\", \"01110\", \"10000\", \"10001\", \"10010\", \"10011\",\n            \"10100\", \"10101\", \"10110\", \"11000\", \"11001\", \"11010\", \"11100\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        2,\n        4,\n        &[\n            \"00011\", \"00101\", \"00110\", \"00111\", \"01001\", \"01010\", \"01011\", \"01100\", \"01101\",\n            \"01110\", \"01111\", \"10001\", \"10010\", \"10011\", \"10100\", \"10101\", \"10110\", \"10111\",\n            \"11000\", \"11001\", \"11010\", \"11011\", \"11100\", \"11101\", \"11110\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        3,\n        5,\n        &[\n            \"00111\", \"01011\", \"01101\", \"01110\", \"01111\", \"10011\", \"10101\", \"10110\", \"10111\",\n            \"11001\", \"11010\", \"11011\", \"11100\", \"11101\", \"11110\", \"11111\",\n        ],\n    );\n\n    next_bit_pattern_helper(\n        5,\n        0,\n        3,\n        &[\n            \"00000\", \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"00111\", \"01000\",\n            \"01001\", \"01010\", \"01011\", \"01100\", \"01101\", \"01110\", \"10000\", \"10001\", \"10010\",\n            \"10011\", \"10100\", \"10101\", \"10110\", \"11000\", \"11001\", \"11010\", \"11100\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        1,\n        4,\n        &[\n            \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"00111\", \"01000\", \"01001\",\n            \"01010\", \"01011\", \"01100\", \"01101\", \"01110\", \"01111\", \"10000\", \"10001\", \"10010\",\n            \"10011\", \"10100\", \"10101\", \"10110\", \"10111\", \"11000\", \"11001\", \"11010\", \"11011\",\n            \"11100\", \"11101\", \"11110\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        2,\n        5,\n        &[\n            \"00011\", \"00101\", \"00110\", \"00111\", \"01001\", \"01010\", \"01011\", \"01100\", \"01101\",\n            \"01110\", \"01111\", \"10001\", \"10010\", \"10011\", \"10100\", \"10101\", \"10110\", \"10111\",\n            \"11000\", \"11001\", \"11010\", \"11011\", \"11100\", \"11101\", \"11110\", \"11111\",\n        ],\n    );\n\n    next_bit_pattern_helper(\n        5,\n        0,\n        4,\n        &[\n            \"00000\", \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"00111\", \"01000\",\n            \"01001\", \"01010\", \"01011\", \"01100\", \"01101\", \"01110\", \"01111\", \"10000\", \"10001\",\n            \"10010\", \"10011\", \"10100\", \"10101\", \"10110\", \"10111\", \"11000\", \"11001\", \"11010\",\n            \"11011\", \"11100\", \"11101\", \"11110\",\n        ],\n    );\n    next_bit_pattern_helper(\n        5,\n        1,\n        5,\n        &[\n            \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"00111\", \"01000\", \"01001\",\n            \"01010\", \"01011\", \"01100\", \"01101\", \"01110\", \"01111\", \"10000\", \"10001\", \"10010\",\n            \"10011\", \"10100\", \"10101\", \"10110\", \"10111\", \"11000\", \"11001\", \"11010\", \"11011\",\n            \"11100\", \"11101\", \"11110\", \"11111\",\n        ],\n    );\n\n    next_bit_pattern_helper(\n        5,\n        0,\n        5,\n        &[\n            \"00000\", \"00001\", \"00010\", \"00011\", \"00100\", \"00101\", \"00110\", \"00111\", \"01000\",\n            \"01001\", \"01010\", \"01011\", \"01100\", \"01101\", \"01110\", \"01111\", \"10000\", \"10001\",\n            \"10010\", \"10011\", \"10100\", \"10101\", \"10110\", \"10111\", \"11000\", \"11001\", \"11010\",\n            \"11011\", \"11100\", \"11101\", \"11110\", \"11111\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_ordered_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs;\nuse std::fmt::Debug;\n\nfn shortlex_ordered_unique_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(shortlex_ordered_unique_vecs(xs), out);\n}\n\nfn shortlex_ordered_unique_vecs_small_helper<I: Clone + Iterator>(\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(shortlex_ordered_unique_vecs(xs), out_len, out);\n}\n\n#[test]\nfn test_shortlex_ordered_unique_vecs() {\n    shortlex_ordered_unique_vecs_small_helper(nevers(), 1, &[&[]]);\n    shortlex_ordered_unique_vecs_small_helper(exhaustive_units(), 2, &[&[], &[()]]);\n    shortlex_ordered_unique_vecs_small_helper(\n        exhaustive_bools(),\n        4,\n        &[&[], &[false], &[true], &[false, true]],\n    );\n    shortlex_ordered_unique_vecs_small_helper(\n        1..=6,\n        64,\n        &[\n            &[],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[1, 2],\n            &[1, 3],\n            &[1, 4],\n            &[1, 5],\n            &[1, 6],\n            &[2, 3],\n            &[2, 4],\n            &[2, 5],\n            &[2, 6],\n            &[3, 4],\n            &[3, 5],\n            &[3, 6],\n            &[4, 5],\n        ],\n    );\n    shortlex_ordered_unique_vecs_small_helper(\n        'a'..='c',\n        8,\n        &[&[], &['a'], &['b'], &['c'], &['a', 'b'], &['a', 'c'], &['b', 'c'], &['a', 'b', 'c']],\n    );\n    shortlex_ordered_unique_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['d'],\n            &['e'],\n            &['f'],\n            &['g'],\n            &['h'],\n            &['i'],\n            &['j'],\n            &['k'],\n            &['l'],\n            &['m'],\n            &['n'],\n            &['o'],\n            &['p'],\n            &['q'],\n            &['r'],\n            &['s'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_ordered_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn shortlex_ordered_unique_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        shortlex_ordered_unique_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_ordered_unique_vecs_length_inclusive_range() {\n    shortlex_ordered_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    shortlex_ordered_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    shortlex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[&[], &[()]],\n    );\n    shortlex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        0,\n        exhaustive_bools(),\n        0,\n        &[],\n    );\n    shortlex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    shortlex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        1,\n        &[&[false, true]],\n    );\n    shortlex_ordered_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_ordered_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn shortlex_ordered_unique_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        shortlex_ordered_unique_vecs_length_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_ordered_unique_vecs_length_range() {\n    shortlex_ordered_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    shortlex_ordered_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    shortlex_ordered_unique_vecs_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        2,\n        &[&[], &[()]],\n    );\n    shortlex_ordered_unique_vecs_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    shortlex_ordered_unique_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    shortlex_ordered_unique_vecs_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    shortlex_ordered_unique_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        1,\n        &[&[false, true]],\n    );\n    shortlex_ordered_unique_vecs_length_range_small_helper(\n        1,\n        2,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_ordered_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_ordered_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn shortlex_ordered_unique_vecs_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(shortlex_ordered_unique_vecs_min_length(min_length, xs), out);\n}\n\nfn shortlex_ordered_unique_vecs_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        shortlex_ordered_unique_vecs_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_ordered_unique_vecs_min_length() {\n    shortlex_ordered_unique_vecs_min_length_small_helper(0, nevers(), 1, &[&[]]);\n    shortlex_ordered_unique_vecs_min_length_small_helper(4, nevers(), 0, &[]);\n    shortlex_ordered_unique_vecs_min_length_small_helper(0, exhaustive_units(), 2, &[&[], &[()]]);\n    shortlex_ordered_unique_vecs_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    shortlex_ordered_unique_vecs_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        4,\n        &[&[], &[false], &[true], &[false, true]],\n    );\n    shortlex_ordered_unique_vecs_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[false], &[true], &[false, true]],\n    );\n    shortlex_ordered_unique_vecs_min_length_small_helper(\n        0,\n        'a'..='c',\n        8,\n        &[&[], &['a'], &['b'], &['c'], &['a', 'b'], &['a', 'c'], &['b', 'c'], &['a', 'b', 'c']],\n    );\n    shortlex_ordered_unique_vecs_min_length_small_helper(\n        2,\n        'a'..='c',\n        4,\n        &[&['a', 'b'], &['a', 'c'], &['b', 'c'], &['a', 'b', 'c']],\n    );\n    shortlex_ordered_unique_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['d'],\n            &['e'],\n            &['f'],\n            &['g'],\n            &['h'],\n            &['i'],\n            &['j'],\n            &['k'],\n            &['l'],\n            &['m'],\n            &['n'],\n            &['o'],\n            &['p'],\n            &['q'],\n            &['r'],\n            &['s'],\n        ],\n    );\n    shortlex_ordered_unique_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'b', 'c'],\n            &['a', 'b', 'd'],\n            &['a', 'b', 'e'],\n            &['a', 'b', 'f'],\n            &['a', 'b', 'g'],\n            &['a', 'b', 'h'],\n            &['a', 'b', 'i'],\n            &['a', 'b', 'j'],\n            &['a', 'b', 'k'],\n            &['a', 'b', 'l'],\n            &['a', 'b', 'm'],\n            &['a', 'b', 'n'],\n            &['a', 'b', 'o'],\n            &['a', 'b', 'p'],\n            &['a', 'b', 'q'],\n            &['a', 'b', 'r'],\n            &['a', 'b', 's'],\n            &['a', 'b', 't'],\n            &['a', 'b', 'u'],\n            &['a', 'b', 'v'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_unique_vecs;\nuse std::fmt::Debug;\n\nfn shortlex_unique_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(shortlex_unique_vecs(xs), out);\n}\n\nfn shortlex_unique_vecs_small_helper<I: Clone + Iterator>(xs: I, out_len: usize, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(shortlex_unique_vecs(xs), out_len, out);\n}\n\n#[test]\nfn test_shortlex_unique_vecs() {\n    shortlex_unique_vecs_small_helper(nevers(), 1, &[&[]]);\n    shortlex_unique_vecs_small_helper(exhaustive_units(), 2, &[&[], &[()]]);\n    shortlex_unique_vecs_small_helper(\n        exhaustive_bools(),\n        5,\n        &[&[], &[false], &[true], &[false, true], &[true, false]],\n    );\n    shortlex_unique_vecs_small_helper(\n        1..=6,\n        1957,\n        &[\n            &[],\n            &[1],\n            &[2],\n            &[3],\n            &[4],\n            &[5],\n            &[6],\n            &[1, 2],\n            &[1, 3],\n            &[1, 4],\n            &[1, 5],\n            &[1, 6],\n            &[2, 1],\n            &[2, 3],\n            &[2, 4],\n            &[2, 5],\n            &[2, 6],\n            &[3, 1],\n            &[3, 2],\n            &[3, 4],\n        ],\n    );\n    shortlex_unique_vecs_small_helper(\n        'a'..='c',\n        16,\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['b', 'c'],\n            &['c', 'a'],\n            &['c', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c', 'b'],\n            &['b', 'a', 'c'],\n            &['b', 'c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    shortlex_unique_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['d'],\n            &['e'],\n            &['f'],\n            &['g'],\n            &['h'],\n            &['i'],\n            &['j'],\n            &['k'],\n            &['l'],\n            &['m'],\n            &['n'],\n            &['o'],\n            &['p'],\n            &['q'],\n            &['r'],\n            &['s'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn shortlex_unique_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        shortlex_unique_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_unique_vecs_length_inclusive_range() {\n    shortlex_unique_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    shortlex_unique_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    shortlex_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        2,\n        &[&[], &[()]],\n    );\n    shortlex_unique_vecs_length_inclusive_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    shortlex_unique_vecs_length_inclusive_range_small_helper(\n        0,\n        1,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    shortlex_unique_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    shortlex_unique_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        'a'..='c',\n        3,\n        &[&['a'], &['b'], &['c']],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn shortlex_unique_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(shortlex_unique_vecs_length_range(a, b, xs), out_len, out);\n}\n\n#[test]\nfn test_shortlex_unique_vecs_length_range() {\n    shortlex_unique_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    shortlex_unique_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    shortlex_unique_vecs_length_range_small_helper(0, 5, exhaustive_units(), 2, &[&[], &[()]]);\n    shortlex_unique_vecs_length_range_small_helper(1, 0, exhaustive_bools(), 0, &[]);\n    shortlex_unique_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    shortlex_unique_vecs_length_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        3,\n        &[&[], &[false], &[true]],\n    );\n    shortlex_unique_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        2,\n        &[&[false, true], &[true, false]],\n    );\n    shortlex_unique_vecs_length_range_small_helper(1, 2, 'a'..='c', 3, &[&['a'], &['b'], &['c']]);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::{\n    exhaustive_vecs_helper_helper, exhaustive_vecs_small_helper_helper,\n};\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn shortlex_unique_vecs_min_length_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(shortlex_unique_vecs_min_length(min_length, xs), out);\n}\n\nfn shortlex_unique_vecs_min_length_small_helper<I: Clone + Iterator>(\n    min_length: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        shortlex_unique_vecs_min_length(min_length, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_unique_vecs_min_length() {\n    shortlex_unique_vecs_min_length_small_helper(0, nevers(), 1, &[&[]]);\n    shortlex_unique_vecs_min_length_small_helper(4, nevers(), 0, &[]);\n    shortlex_unique_vecs_min_length_small_helper(0, exhaustive_units(), 2, &[&[], &[()]]);\n    shortlex_unique_vecs_min_length_small_helper(5, exhaustive_units(), 0, &[]);\n    shortlex_unique_vecs_min_length_small_helper(\n        0,\n        exhaustive_bools(),\n        5,\n        &[&[], &[false], &[true], &[false, true], &[true, false]],\n    );\n    shortlex_unique_vecs_min_length_small_helper(\n        1,\n        exhaustive_bools(),\n        4,\n        &[&[false], &[true], &[false, true], &[true, false]],\n    );\n    shortlex_unique_vecs_min_length_small_helper(\n        0,\n        'a'..='c',\n        16,\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['b', 'c'],\n            &['c', 'a'],\n            &['c', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c', 'b'],\n            &['b', 'a', 'c'],\n            &['b', 'c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    shortlex_unique_vecs_min_length_small_helper(\n        2,\n        'a'..='c',\n        12,\n        &[\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['b', 'c'],\n            &['c', 'a'],\n            &['c', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c', 'b'],\n            &['b', 'a', 'c'],\n            &['b', 'c', 'a'],\n            &['c', 'a', 'b'],\n            &['c', 'b', 'a'],\n        ],\n    );\n    shortlex_unique_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['d'],\n            &['e'],\n            &['f'],\n            &['g'],\n            &['h'],\n            &['i'],\n            &['j'],\n            &['k'],\n            &['l'],\n            &['m'],\n            &['n'],\n            &['o'],\n            &['p'],\n            &['q'],\n            &['r'],\n            &['s'],\n        ],\n    );\n    shortlex_unique_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'b', 'c'],\n            &['a', 'b', 'd'],\n            &['a', 'b', 'e'],\n            &['a', 'b', 'f'],\n            &['a', 'b', 'g'],\n            &['a', 'b', 'h'],\n            &['a', 'b', 'i'],\n            &['a', 'b', 'j'],\n            &['a', 'b', 'k'],\n            &['a', 'b', 'l'],\n            &['a', 'b', 'm'],\n            &['a', 'b', 'n'],\n            &['a', 'b', 'o'],\n            &['a', 'b', 'p'],\n            &['a', 'b', 'q'],\n            &['a', 'b', 'r'],\n            &['a', 'b', 's'],\n            &['a', 'b', 't'],\n            &['a', 'b', 'u'],\n            &['a', 'b', 'v'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_vecs;\nuse std::fmt::Debug;\n\nfn shortlex_vecs_helper<I: Clone + Iterator>(xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(shortlex_vecs(xs), out);\n}\n\n#[test]\nfn test_shortlex_vecs() {\n    shortlex_vecs_helper(nevers(), &[&[]]);\n    shortlex_vecs_helper(\n        exhaustive_units(),\n        &[\n            &[],\n            &[()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), (), ()],\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(); 16],\n            &[(); 17],\n            &[(); 18],\n            &[(); 19],\n        ],\n    );\n    shortlex_vecs_helper(\n        exhaustive_bools(),\n        &[\n            &[],\n            &[false],\n            &[true],\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false, false, false],\n            &[false, false, true],\n            &[false, true, false],\n            &[false, true, true],\n            &[true, false, false],\n            &[true, false, true],\n            &[true, true, false],\n            &[true, true, true],\n            &[false, false, false, false],\n            &[false, false, false, true],\n            &[false, false, true, false],\n            &[false, false, true, true],\n            &[false, true, false, false],\n        ],\n    );\n    shortlex_vecs_helper(\n        'a'..='c',\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'a'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['b', 'b'],\n            &['b', 'c'],\n            &['c', 'a'],\n            &['c', 'b'],\n            &['c', 'c'],\n            &['a', 'a', 'a'],\n            &['a', 'a', 'b'],\n            &['a', 'a', 'c'],\n            &['a', 'b', 'a'],\n            &['a', 'b', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c', 'a'],\n        ],\n    );\n    shortlex_vecs_helper(\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['d'],\n            &['e'],\n            &['f'],\n            &['g'],\n            &['h'],\n            &['i'],\n            &['j'],\n            &['k'],\n            &['l'],\n            &['m'],\n            &['n'],\n            &['o'],\n            &['p'],\n            &['q'],\n            &['r'],\n            &['s'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_vecs_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::num::exhaustive::exhaustive_unsigneds;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_helper_helper;\nuse malachite_base::vecs::exhaustive::shortlex_vecs_from_length_iterator;\nuse std::fmt::Debug;\nuse std::iter::empty;\n\nfn shortlex_vecs_from_element_iterator_helper<I: Iterator<Item = u64>, J: Clone + Iterator>(\n    lengths: I,\n    xs: J,\n    out: &[&[J::Item]],\n) where\n    J::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(shortlex_vecs_from_length_iterator(lengths, xs), out);\n}\n\n#[test]\nfn test_shortlex_vecs_from_element_iterator() {\n    shortlex_vecs_from_element_iterator_helper(empty(), exhaustive_bools(), &[]);\n    shortlex_vecs_from_element_iterator_helper(\n        [2, 1, 2].iter().copied(),\n        exhaustive_bools(),\n        &[\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false],\n            &[true],\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n        ],\n    );\n    shortlex_vecs_from_element_iterator_helper(\n        exhaustive_unsigneds::<u64>().map(|u| u << 1),\n        exhaustive_bools(),\n        &[\n            &[],\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false, false, false, false],\n            &[false, false, false, true],\n            &[false, false, true, false],\n            &[false, false, true, true],\n            &[false, true, false, false],\n            &[false, true, false, true],\n            &[false, true, true, false],\n            &[false, true, true, true],\n            &[true, false, false, false],\n            &[true, false, false, true],\n            &[true, false, true, false],\n            &[true, false, true, true],\n            &[true, true, false, false],\n            &[true, true, false, true],\n            &[true, true, true, false],\n        ],\n    );\n    shortlex_vecs_from_element_iterator_helper(\n        [2, 1, 0, 2].iter().copied(),\n        exhaustive_bools(),\n        &[\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false],\n            &[true],\n            &[],\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n        ],\n    );\n    // Stops after first empty ys\n    shortlex_vecs_from_element_iterator_helper([0, 0, 1, 0].iter().copied(), nevers(), &[&[], &[]]);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn shortlex_vecs_length_inclusive_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(\n        shortlex_vecs_length_inclusive_range(a, b, xs),\n        out_len,\n        out,\n    );\n}\n\n#[test]\nfn test_shortlex_vecs_length_inclusive_range() {\n    shortlex_vecs_length_inclusive_range_small_helper(0, 4, nevers(), 1, &[&[]]);\n    shortlex_vecs_length_inclusive_range_small_helper(6, 9, nevers(), 0, &[]);\n    shortlex_vecs_length_inclusive_range_small_helper(5, 3, exhaustive_bools(), 0, &[]);\n    shortlex_vecs_length_inclusive_range_small_helper(\n        0,\n        4,\n        exhaustive_units(),\n        5,\n        &[&[], &[()], &[(), ()], &[(), (), ()], &[(), (), (), ()]],\n    );\n    shortlex_vecs_length_inclusive_range_small_helper(\n        1,\n        1,\n        exhaustive_bools(),\n        2,\n        &[&[false], &[true]],\n    );\n    shortlex_vecs_length_inclusive_range_small_helper(\n        0,\n        2,\n        exhaustive_bools(),\n        7,\n        &[&[], &[false], &[true], &[false, false], &[false, true], &[true, false], &[true, true]],\n    );\n    shortlex_vecs_length_inclusive_range_small_helper(\n        2,\n        3,\n        exhaustive_bools(),\n        12,\n        &[\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false, false, false],\n            &[false, false, true],\n            &[false, true, false],\n            &[false, true, true],\n            &[true, false, false],\n            &[true, false, true],\n            &[true, true, false],\n            &[true, true, true],\n        ],\n    );\n    shortlex_vecs_length_inclusive_range_small_helper(\n        5,\n        7,\n        'a'..='c',\n        3159,\n        &[\n            &['a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'c'],\n            &['a', 'a', 'a', 'b', 'a'],\n            &['a', 'a', 'a', 'b', 'b'],\n            &['a', 'a', 'a', 'b', 'c'],\n            &['a', 'a', 'a', 'c', 'a'],\n            &['a', 'a', 'a', 'c', 'b'],\n            &['a', 'a', 'a', 'c', 'c'],\n            &['a', 'a', 'b', 'a', 'a'],\n            &['a', 'a', 'b', 'a', 'b'],\n            &['a', 'a', 'b', 'a', 'c'],\n            &['a', 'a', 'b', 'b', 'a'],\n            &['a', 'a', 'b', 'b', 'b'],\n            &['a', 'a', 'b', 'b', 'c'],\n            &['a', 'a', 'b', 'c', 'a'],\n            &['a', 'a', 'b', 'c', 'b'],\n            &['a', 'a', 'b', 'c', 'c'],\n            &['a', 'a', 'c', 'a', 'a'],\n            &['a', 'a', 'c', 'a', 'b'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_small_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_vecs_length_range;\nuse std::fmt::Debug;\n\nfn shortlex_vecs_length_range_small_helper<I: Clone + Iterator>(\n    a: u64,\n    b: u64,\n    xs: I,\n    out_len: usize,\n    out: &[&[I::Item]],\n) where\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_small_helper_helper(shortlex_vecs_length_range(a, b, xs), out_len, out);\n}\n\n#[test]\nfn test_shortlex_vecs_length_range() {\n    shortlex_vecs_length_range_small_helper(0, 5, nevers(), 1, &[&[]]);\n    shortlex_vecs_length_range_small_helper(6, 10, nevers(), 0, &[]);\n    shortlex_vecs_length_range_small_helper(\n        0,\n        5,\n        exhaustive_units(),\n        5,\n        &[&[], &[()], &[(), ()], &[(), (), ()], &[(), (), (), ()]],\n    );\n    shortlex_vecs_length_range_small_helper(1, 1, exhaustive_bools(), 0, &[]);\n    shortlex_vecs_length_range_small_helper(5, 3, exhaustive_bools(), 0, &[]);\n    shortlex_vecs_length_range_small_helper(\n        0,\n        3,\n        exhaustive_bools(),\n        7,\n        &[&[], &[false], &[true], &[false, false], &[false, true], &[true, false], &[true, true]],\n    );\n    shortlex_vecs_length_range_small_helper(\n        2,\n        4,\n        exhaustive_bools(),\n        12,\n        &[\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false, false, false],\n            &[false, false, true],\n            &[false, true, false],\n            &[false, true, true],\n            &[true, false, false],\n            &[true, false, true],\n            &[true, true, false],\n            &[true, true, true],\n        ],\n    );\n    shortlex_vecs_length_range_small_helper(\n        5,\n        8,\n        'a'..='c',\n        3159,\n        &[\n            &['a', 'a', 'a', 'a', 'a'],\n            &['a', 'a', 'a', 'a', 'b'],\n            &['a', 'a', 'a', 'a', 'c'],\n            &['a', 'a', 'a', 'b', 'a'],\n            &['a', 'a', 'a', 'b', 'b'],\n            &['a', 'a', 'a', 'b', 'c'],\n            &['a', 'a', 'a', 'c', 'a'],\n            &['a', 'a', 'a', 'c', 'b'],\n            &['a', 'a', 'a', 'c', 'c'],\n            &['a', 'a', 'b', 'a', 'a'],\n            &['a', 'a', 'b', 'a', 'b'],\n            &['a', 'a', 'b', 'a', 'c'],\n            &['a', 'a', 'b', 'b', 'a'],\n            &['a', 'a', 'b', 'b', 'b'],\n            &['a', 'a', 'b', 'b', 'c'],\n            &['a', 'a', 'b', 'c', 'a'],\n            &['a', 'a', 'b', 'c', 'b'],\n            &['a', 'a', 'b', 'c', 'c'],\n            &['a', 'a', 'c', 'a', 'a'],\n            &['a', 'a', 'c', 'a', 'b'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive/shortlex_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::bools::exhaustive::exhaustive_bools;\nuse malachite_base::chars::exhaustive::exhaustive_ascii_chars;\nuse malachite_base::nevers::nevers;\nuse malachite_base::test_util::vecs::exhaustive::exhaustive_vecs_helper_helper;\nuse malachite_base::tuples::exhaustive::exhaustive_units;\nuse malachite_base::vecs::exhaustive::shortlex_vecs_min_length;\nuse std::fmt::Debug;\n\nfn shortlex_vecs_min_length_helper<I: Clone + Iterator>(min_length: u64, xs: I, out: &[&[I::Item]])\nwhere\n    I::Item: Clone + Debug + Eq,\n{\n    exhaustive_vecs_helper_helper(shortlex_vecs_min_length(min_length, xs), out);\n}\n\n#[test]\nfn test_shortlex_vecs_min_length() {\n    shortlex_vecs_min_length_helper(0, nevers(), &[&[]]);\n    shortlex_vecs_min_length_helper(4, nevers(), &[]);\n    shortlex_vecs_min_length_helper(\n        0,\n        exhaustive_units(),\n        &[\n            &[],\n            &[()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), (), ()],\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(); 16],\n            &[(); 17],\n            &[(); 18],\n            &[(); 19],\n        ],\n    );\n    shortlex_vecs_min_length_helper(\n        5,\n        exhaustive_units(),\n        &[\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(); 16],\n            &[(); 17],\n            &[(); 18],\n            &[(); 19],\n            &[(); 20],\n            &[(); 21],\n            &[(); 22],\n            &[(); 23],\n            &[(); 24],\n        ],\n    );\n    shortlex_vecs_min_length_helper(\n        0,\n        exhaustive_bools(),\n        &[\n            &[],\n            &[false],\n            &[true],\n            &[false, false],\n            &[false, true],\n            &[true, false],\n            &[true, true],\n            &[false, false, false],\n            &[false, false, true],\n            &[false, true, false],\n            &[false, true, true],\n            &[true, false, false],\n            &[true, false, true],\n            &[true, true, false],\n            &[true, true, true],\n            &[false, false, false, false],\n            &[false, false, false, true],\n            &[false, false, true, false],\n            &[false, false, true, true],\n            &[false, true, false, false],\n        ],\n    );\n    shortlex_vecs_min_length_helper(\n        3,\n        exhaustive_bools(),\n        &[\n            &[false, false, false],\n            &[false, false, true],\n            &[false, true, false],\n            &[false, true, true],\n            &[true, false, false],\n            &[true, false, true],\n            &[true, true, false],\n            &[true, true, true],\n            &[false, false, false, false],\n            &[false, false, false, true],\n            &[false, false, true, false],\n            &[false, false, true, true],\n            &[false, true, false, false],\n            &[false, true, false, true],\n            &[false, true, true, false],\n            &[false, true, true, true],\n            &[true, false, false, false],\n            &[true, false, false, true],\n            &[true, false, true, false],\n            &[true, false, true, true],\n        ],\n    );\n    shortlex_vecs_min_length_helper(\n        0,\n        'a'..='c',\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['a', 'a'],\n            &['a', 'b'],\n            &['a', 'c'],\n            &['b', 'a'],\n            &['b', 'b'],\n            &['b', 'c'],\n            &['c', 'a'],\n            &['c', 'b'],\n            &['c', 'c'],\n            &['a', 'a', 'a'],\n            &['a', 'a', 'b'],\n            &['a', 'a', 'c'],\n            &['a', 'b', 'a'],\n            &['a', 'b', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c', 'a'],\n        ],\n    );\n    shortlex_vecs_min_length_helper(\n        3,\n        'a'..='c',\n        &[\n            &['a', 'a', 'a'],\n            &['a', 'a', 'b'],\n            &['a', 'a', 'c'],\n            &['a', 'b', 'a'],\n            &['a', 'b', 'b'],\n            &['a', 'b', 'c'],\n            &['a', 'c', 'a'],\n            &['a', 'c', 'b'],\n            &['a', 'c', 'c'],\n            &['b', 'a', 'a'],\n            &['b', 'a', 'b'],\n            &['b', 'a', 'c'],\n            &['b', 'b', 'a'],\n            &['b', 'b', 'b'],\n            &['b', 'b', 'c'],\n            &['b', 'c', 'a'],\n            &['b', 'c', 'b'],\n            &['b', 'c', 'c'],\n            &['c', 'a', 'a'],\n            &['c', 'a', 'b'],\n        ],\n    );\n    shortlex_vecs_min_length_helper(\n        0,\n        exhaustive_ascii_chars(),\n        &[\n            &[],\n            &['a'],\n            &['b'],\n            &['c'],\n            &['d'],\n            &['e'],\n            &['f'],\n            &['g'],\n            &['h'],\n            &['i'],\n            &['j'],\n            &['k'],\n            &['l'],\n            &['m'],\n            &['n'],\n            &['o'],\n            &['p'],\n            &['q'],\n            &['r'],\n            &['s'],\n        ],\n    );\n    shortlex_vecs_min_length_helper(\n        3,\n        exhaustive_ascii_chars(),\n        &[\n            &['a', 'a', 'a'],\n            &['a', 'a', 'b'],\n            &['a', 'a', 'c'],\n            &['a', 'a', 'd'],\n            &['a', 'a', 'e'],\n            &['a', 'a', 'f'],\n            &['a', 'a', 'g'],\n            &['a', 'a', 'h'],\n            &['a', 'a', 'i'],\n            &['a', 'a', 'j'],\n            &['a', 'a', 'k'],\n            &['a', 'a', 'l'],\n            &['a', 'a', 'm'],\n            &['a', 'a', 'n'],\n            &['a', 'a', 'o'],\n            &['a', 'a', 'p'],\n            &['a', 'a', 'q'],\n            &['a', 'a', 'r'],\n            &['a', 'a', 's'],\n            &['a', 'a', 't'],\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/exhaustive_vec_permutations.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::vecs::exhaustive_vec_permutations;\n\nfn exhaustive_vec_permutations_helper(cs: &str, out: &[&str]) {\n    let cs = cs.chars().collect_vec();\n    let css: Vec<String> = exhaustive_vec_permutations(cs)\n        .map(|ds| ds.into_iter().collect())\n        .collect();\n    assert_eq!(css.iter().map(String::as_str).collect_vec().as_slice(), out);\n}\n\n#[test]\nfn test_exhaustive_vec_permutations() {\n    exhaustive_vec_permutations_helper(\"\", &[\"\"]);\n    exhaustive_vec_permutations_helper(\"1\", &[\"1\"]);\n    exhaustive_vec_permutations_helper(\"12\", &[\"12\", \"21\"]);\n    exhaustive_vec_permutations_helper(\"123\", &[\"123\", \"132\", \"213\", \"231\", \"312\", \"321\"]);\n    exhaustive_vec_permutations_helper(\n        \"1234\",\n        &[\n            \"1234\", \"1243\", \"1324\", \"1342\", \"1423\", \"1432\", \"2134\", \"2143\", \"2314\", \"2341\", \"2413\",\n            \"2431\", \"3124\", \"3142\", \"3214\", \"3241\", \"3412\", \"3421\", \"4123\", \"4132\", \"4213\", \"4231\",\n            \"4312\", \"4321\",\n        ],\n    );\n    exhaustive_vec_permutations_helper(\n        \"12345\",\n        &[\n            \"12345\", \"12354\", \"12435\", \"12453\", \"12534\", \"12543\", \"13245\", \"13254\", \"13425\",\n            \"13452\", \"13524\", \"13542\", \"14235\", \"14253\", \"14325\", \"14352\", \"14523\", \"14532\",\n            \"15234\", \"15243\", \"15324\", \"15342\", \"15423\", \"15432\", \"21345\", \"21354\", \"21435\",\n            \"21453\", \"21534\", \"21543\", \"23145\", \"23154\", \"23415\", \"23451\", \"23514\", \"23541\",\n            \"24135\", \"24153\", \"24315\", \"24351\", \"24513\", \"24531\", \"25134\", \"25143\", \"25314\",\n            \"25341\", \"25413\", \"25431\", \"31245\", \"31254\", \"31425\", \"31452\", \"31524\", \"31542\",\n            \"32145\", \"32154\", \"32415\", \"32451\", \"32514\", \"32541\", \"34125\", \"34152\", \"34215\",\n            \"34251\", \"34512\", \"34521\", \"35124\", \"35142\", \"35214\", \"35241\", \"35412\", \"35421\",\n            \"41235\", \"41253\", \"41325\", \"41352\", \"41523\", \"41532\", \"42135\", \"42153\", \"42315\",\n            \"42351\", \"42513\", \"42531\", \"43125\", \"43152\", \"43215\", \"43251\", \"43512\", \"43521\",\n            \"45123\", \"45132\", \"45213\", \"45231\", \"45312\", \"45321\", \"51234\", \"51243\", \"51324\",\n            \"51342\", \"51423\", \"51432\", \"52134\", \"52143\", \"52314\", \"52341\", \"52413\", \"52431\",\n            \"53124\", \"53142\", \"53214\", \"53241\", \"53412\", \"53421\", \"54123\", \"54132\", \"54213\",\n            \"54231\", \"54312\", \"54321\",\n        ],\n    );\n    exhaustive_vec_permutations_helper(\n        \"abcd\",\n        &[\n            \"abcd\", \"abdc\", \"acbd\", \"acdb\", \"adbc\", \"adcb\", \"bacd\", \"badc\", \"bcad\", \"bcda\", \"bdac\",\n            \"bdca\", \"cabd\", \"cadb\", \"cbad\", \"cbda\", \"cdab\", \"cdba\", \"dabc\", \"dacb\", \"dbac\", \"dbca\",\n            \"dcab\", \"dcba\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_ordered_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_ordered_unique_vecs;\nuse std::fmt::Debug;\n\nfn random_ordered_unique_vecs_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_ordered_unique_vecs(\n            EXAMPLE_SEED,\n            xs_gen,\n            mean_length_numerator,\n            mean_length_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_ordered_unique_vecs() {\n    random_ordered_unique_vecs_helper(\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            &[][..],\n            &[11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235],\n            &[30, 90, 218, 234],\n            &[9, 106, 204, 216],\n            &[151],\n            &[],\n            &[78, 91, 97, 213, 253],\n            &[39, 191],\n            &[170, 175, 232, 233],\n            &[],\n            &[2, 22, 35, 114, 198, 217],\n            &[],\n            &[],\n            &[17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222],\n            &[52, 69, 73, 91, 115, 137, 153, 178],\n            &[],\n            &[34, 95, 112],\n            &[],\n            &[106, 130, 167, 168, 197],\n            &[86, 101, 122, 150, 172, 177, 207, 218, 221],\n        ],\n        &[\n            (&[], 199913),\n            (&[7], 705),\n            (&[25], 689),\n            (&[184], 681),\n            (&[213], 681),\n            (&[255], 676),\n            (&[215], 675),\n            (&[54], 673),\n            (&[122], 672),\n            (&[207], 672),\n        ],\n        (&[27, 31, 211, 238], Some(&[27, 31, 247, 251])),\n    );\n    random_ordered_unique_vecs_helper(\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            &[],\n            &[1, 9, 12, 14, 16, 17, 19, 21, 41, 42, 68, 79, 124, 141],\n            &[0, 1, 10, 99],\n            &[2, 12, 36, 77],\n            &[1],\n            &[],\n            &[1, 5, 9, 19, 103],\n            &[6, 7],\n            &[15, 18, 51, 159],\n            &[],\n            &[2, 26, 40, 52, 64, 75],\n            &[],\n            &[],\n            &[3, 4, 5, 7, 30, 31, 34, 43, 49, 51, 67],\n            &[1, 14, 16, 24, 29, 41, 47, 52],\n            &[],\n            &[11, 13, 62],\n            &[],\n            &[3, 14, 42, 47, 109],\n            &[5, 13, 16, 25, 37, 41, 42, 86, 96],\n        ],\n        &[\n            (&[], 199913),\n            (&[0], 4861),\n            (&[1], 4593),\n            (&[2], 4498),\n            (&[3], 4405),\n            (&[4], 4330),\n            (&[5], 4078),\n            (&[6], 4050),\n            (&[7], 3858),\n            (&[8], 3848),\n        ],\n        (\n            &[3, 9, 14, 22, 36, 56, 107],\n            Some(&[3, 9, 14, 22, 42, 54, 73, 150]),\n        ),\n    );\n    random_ordered_unique_vecs_helper(\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            &[],\n            &[],\n            &[85],\n            &[11],\n            &[136, 200],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[134, 235],\n            &[203],\n            &[],\n            &[38, 223],\n            &[],\n            &[],\n            &[],\n            &[],\n        ],\n        &[\n            (&[], 800023),\n            (&[162], 692),\n            (&[235], 690),\n            (&[90], 688),\n            (&[65], 687),\n            (&[249], 686),\n            (&[175], 684),\n            (&[108], 683),\n            (&[211], 682),\n            (&[237], 680),\n        ],\n        (&[], None),\n    );\n    random_ordered_unique_vecs_helper(\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            &[],\n            &['g', 'q', '³', '»', 'À', 'Á', 'Ã', 'È', 'á', 'â', 'ì', 'ñ', 'Ā', 'ą'],\n            &['ª', '´', 'Ã', 'ä'],\n            &['½', 'Á', 'Ï', 'ý'],\n            &['j'],\n            &[],\n            &['u', '½', 'Â', 'Ñ', 'ï'],\n            &['x', 'õ'],\n            &['¡', 'Â', 'ù', 'Ċ'],\n            &[],\n            &['b', 'r', 's', '¬', 'Â', 'Ñ'],\n            &[],\n            &[],\n            &['j', 'n', 't', '¬', 'º', '¿', 'Á', 'Ø', 'Þ', 'ô', 'ü'],\n            &['b', 'k', '±', 'Î', 'Ü', 'æ', 'è', 'ā'],\n            &[],\n            &['«', '¹', 'Î'],\n            &[],\n            &['~', '¯', '´', 'Ý', 'â'],\n            &['g', '¼', 'Ç', 'Î', 'Ü', 'Þ', 'æ', 'é', 'ö'],\n        ],\n        &[\n            (&[], 199913),\n            (&['Ó'], 1270),\n            (&['Â'], 1249),\n            (&['§'], 1244),\n            (&['¿'], 1243),\n            (&['õ'], 1241),\n            (&['ĉ'], 1234),\n            (&['¤'], 1232),\n            (&['¼'], 1232),\n            (&['Ì'], 1229),\n        ],\n        (\n            &['o', 'v', '¢', '±', 'Ä', 'Ć'],\n            Some(&['o', 'v', '¢', '³', 'ã']),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_fail_1() {\n    random_ordered_unique_vecs(EXAMPLE_SEED, &random_primitive_ints::<u32>, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_fail_2() {\n    random_ordered_unique_vecs(EXAMPLE_SEED, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_fail_3() {\n    random_ordered_unique_vecs(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_ordered_unique_vecs_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::{Itertools, repeat_n};\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_ordered_unique_vecs_fixed_length;\nuse std::fmt::Debug;\n\nfn random_ordered_unique_vecs_fixed_length_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    expected_values: &[&[I::Item]],\n    expected_common_values: &[(&[I::Item], usize)],\n    expected_median: (&[I::Item], Option<&[I::Item]>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    random_vecs_helper_helper(\n        random_ordered_unique_vecs_fixed_length(len, xs),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_ordered_unique_vecs_fixed_length() {\n    random_ordered_unique_vecs_fixed_length_helper(\n        0,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        repeat_n(&[][..], 20).collect_vec().as_slice(),\n        &[(&[], 1000000)],\n        (&[], None),\n    );\n    random_ordered_unique_vecs_fixed_length_helper(\n        1,\n        random_bools(EXAMPLE_SEED),\n        &[\n            &[true],\n            &[false],\n            &[false],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[false],\n        ],\n        &[(&[true], 500473), (&[false], 499527)],\n        (&[true], None),\n    );\n    random_ordered_unique_vecs_fixed_length_helper(\n        3,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            &[69, 113, 239],\n            &[108, 210, 228],\n            &[87, 161, 168],\n            &[32, 83, 110],\n            &[34, 89, 188],\n            &[93, 200, 238],\n            &[115, 149, 189],\n            &[149, 201, 217],\n            &[31, 117, 146],\n            &[72, 151, 169],\n            &[7, 33, 174],\n            &[38, 81, 144],\n            &[72, 113, 127],\n            &[107, 128, 233],\n            &[12, 46, 119],\n            &[18, 164, 243],\n            &[59, 114, 174],\n            &[39, 174, 247],\n            &[104, 160, 184],\n            &[37, 100, 252],\n        ],\n        &[\n            (&[57, 142, 207], 7),\n            (&[32, 68, 169], 6),\n            (&[36, 70, 195], 6),\n            (&[125, 168, 194], 6),\n            (&[0, 97, 205], 5),\n            (&[2, 33, 227], 5),\n            (&[5, 46, 239], 5),\n            (&[9, 68, 189], 5),\n            (&[9, 78, 240], 5),\n            (&[1, 110, 203], 5),\n        ],\n        (&[52, 133, 241], Some(&[52, 133, 242])),\n    );\n    random_ordered_unique_vecs_fixed_length_helper(\n        2,\n        random_ordered_unique_vecs_fixed_length(2, random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            &[vec![69, 108], vec![113, 239]],\n            &[vec![161, 168], vec![210, 228]],\n            &[vec![32, 87], vec![83, 110]],\n            &[vec![34, 188], vec![89, 238]],\n            &[vec![93, 200], vec![115, 149]],\n            &[vec![149, 189], vec![201, 217]],\n            &[vec![31, 72], vec![117, 146]],\n            &[vec![33, 174], vec![151, 169]],\n            &[vec![7, 38], vec![81, 144]],\n            &[vec![72, 127], vec![113, 128]],\n            &[vec![46, 119], vec![107, 233]],\n            &[vec![12, 18], vec![164, 243]],\n            &[vec![59, 247], vec![114, 174]],\n            &[vec![39, 174], vec![160, 184]],\n            &[vec![37, 104], vec![100, 252]],\n            &[vec![69, 107], vec![122, 228]],\n            &[vec![142, 179], vec![242, 248]],\n            &[vec![61, 189], vec![233, 239]],\n            &[vec![7, 192], vec![85, 235]],\n            &[vec![90, 200], vec![178, 185]],\n        ],\n        &[\n            (&[vec![0, 78], vec![34, 52]], 2),\n            (&[vec![1, 58], vec![6, 112]], 2),\n            (&[vec![1, 63], vec![8, 154]], 2),\n            (&[vec![1, 97], vec![7, 250]], 2),\n            (&[vec![2, 33], vec![40, 81]], 2),\n            (&[vec![3, 160], vec![7, 29]], 2),\n            (&[vec![3, 32], vec![12, 60]], 2),\n            (&[vec![6, 130], vec![7, 20]], 2),\n            (&[vec![6, 68], vec![7, 126]], 2),\n            (&[vec![6, 77], vec![36, 54]], 2),\n        ],\n        (\n            &[vec![40, 193], vec![94, 142]],\n            Some(&[vec![40, 193], vec![97, 243]]),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_ordered_unique_vecs_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_ordered_unique_vecs_from_length_iterator;\nuse malachite_base::vecs::random_values_from_vec;\nuse std::fmt::Debug;\n\nfn random_ordered_unique_vecs_from_length_iterator_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_ordered_unique_vecs_from_length_iterator(EXAMPLE_SEED, lengths_gen, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_ordered_unique_vecs_from_length_iterator() {\n    random_ordered_unique_vecs_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2]),\n        &random_bools,\n        &[\n            &[false, true],\n            &[],\n            &[false, true],\n            &[false, true],\n            &[],\n            &[false, true],\n            &[false, true],\n            &[],\n            &[false, true],\n            &[false, true],\n            &[],\n            &[false, true],\n            &[],\n            &[false, true],\n            &[false, true],\n            &[],\n            &[],\n            &[],\n            &[false, true],\n            &[],\n        ],\n        &[(&[false, true], 500363), (&[], 499637)],\n        (&[false, true], None),\n    );\n    random_ordered_unique_vecs_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        &random_primitive_ints::<u8>,\n        &[\n            &[11, 38, 85, 134, 136, 162, 177, 200, 203, 217, 223, 235],\n            &[32, 166],\n            &[9, 30, 39, 78, 90, 91, 97, 106, 151, 191, 204, 213, 216, 218, 234, 253],\n            &[170, 175],\n            &[\n                2, 17, 22, 25, 32, 34, 35, 52, 65, 69, 73, 79, 91, 112, 114, 115, 121, 137, 144,\n                148, 153, 173, 178, 198, 217, 222, 232, 233,\n            ],\n            &[],\n            &[95, 106, 122, 130, 167, 168, 172, 177, 197, 207],\n            &[9, 74, 86, 101, 115, 150, 218, 221],\n            &[109, 123],\n            &[],\n            &[40, 48, 52, 97, 104, 133, 159, 196, 201, 235, 247, 250],\n            &[7, 68, 190, 216],\n            &[],\n            &[],\n            &[157, 216],\n            &[11, 24, 43, 103, 112, 217],\n            &[],\n            &[84, 211],\n            &[],\n            &[55, 135],\n        ],\n        &[\n            (&[], 333981),\n            (&[33, 163], 22),\n            (&[76, 233], 19),\n            (&[5, 42], 18),\n            (&[76, 79], 18),\n            (&[32, 134], 18),\n            (&[69, 234], 18),\n            (&[74, 164], 18),\n            (&[86, 192], 18),\n            (&[99, 145], 18),\n        ],\n        (&[12, 190], None),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_ordered_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_ordered_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn random_ordered_unique_vecs_length_inclusive_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_ordered_unique_vecs_length_inclusive_range(EXAMPLE_SEED, a, b, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_ordered_unique_vecs_length_inclusive_range() {\n    random_ordered_unique_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &random_primitive_ints::<u8>,\n        &[\n            &[11, 85, 136],\n            &[200, 235],\n            &[134, 203, 223],\n            &[38, 217, 235],\n            &[162, 177],\n            &[32, 166, 234],\n            &[30, 90, 218],\n            &[9, 106],\n            &[151, 204, 216],\n            &[97, 213, 253],\n            &[78, 91],\n            &[39, 175, 191],\n            &[170, 232],\n            &[2, 35, 233],\n            &[22, 198, 217],\n            &[17, 114],\n            &[32, 173],\n            &[65, 114],\n            &[121, 173, 222],\n            &[25, 144],\n        ],\n        &[\n            (&[106, 108], 34),\n            (&[224, 237], 34),\n            (&[51, 132], 32),\n            (&[82, 117], 32),\n            (&[72, 108], 31),\n            (&[142, 194], 31),\n            (&[0, 34], 30),\n            (&[12, 208], 30),\n            (&[15, 141], 30),\n            (&[30, 248], 30),\n        ],\n        (&[62, 131, 203], Some(&[62, 131, 205])),\n    );\n    random_ordered_unique_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            &[0, 1, 5],\n            &[1, 4],\n            &[2, 4, 6],\n            &[0, 1, 2],\n            &[9, 13],\n            &[0, 2, 7],\n            &[4, 6, 7],\n            &[0, 6],\n            &[0, 1, 3],\n            &[1, 2, 5],\n            &[0, 1],\n            &[0, 1, 4],\n            &[0, 2],\n            &[0, 2, 12],\n            &[1, 2, 3],\n            &[3, 9],\n            &[0, 1],\n            &[1, 2],\n            &[0, 1, 11],\n            &[1, 6],\n        ],\n        &[\n            (&[0, 1], 103032),\n            (&[0, 1, 2], 84142),\n            (&[0, 2], 66185),\n            (&[0, 1, 3], 52638),\n            (&[0, 3], 42990),\n            (&[1, 2], 40380),\n            (&[0, 1, 4], 33815),\n            (&[0, 2, 3], 31257),\n            (&[0, 4], 28088),\n            (&[1, 3], 26214),\n        ],\n        (&[0, 3], None),\n    );\n    random_ordered_unique_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            &['c', 'q', 'v'],\n            &['e', 'i'],\n            &['g', 'p', 's'],\n            &['m', 'n', 't'],\n            &['o', 'z'],\n            &['f', 'k', 'm'],\n            &['q', 'u', 'y'],\n            &['k', 'x'],\n            &['h', 'n', 'u'],\n            &['a', 'j', 'n'],\n            &['w', 'z'],\n            &['b', 'l', 'w'],\n            &['l', 'u'],\n            &['e', 'l', 'n'],\n            &['k', 'u', 'v'],\n            &['c', 'h'],\n            &['i', 'y'],\n            &['m', 'r'],\n            &['m', 's', 'y'],\n            &['e', 'l'],\n        ],\n        &[\n            (&['l', 'x'], 1640),\n            (&['o', 't'], 1636),\n            (&['b', 'p'], 1630),\n            (&['m', 'v'], 1623),\n            (&['h', 'u'], 1621),\n            (&['a', 'x'], 1614),\n            (&['d', 'f'], 1613),\n            (&['e', 'r'], 1613),\n            (&['o', 'p'], 1612),\n            (&['c', 'i'], 1611),\n        ],\n        (&['g', 'j'], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_length_inclusive_range_fail() {\n    random_ordered_unique_vecs_length_inclusive_range(\n        EXAMPLE_SEED,\n        2,\n        1,\n        &random_primitive_ints::<u32>,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_ordered_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_ordered_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn random_ordered_unique_vecs_length_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_ordered_unique_vecs_length_range(EXAMPLE_SEED, a, b, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_ordered_unique_vecs_length_range() {\n    random_ordered_unique_vecs_length_range_helper(\n        2,\n        4,\n        &random_primitive_ints::<u8>,\n        &[\n            &[11, 85, 136],\n            &[200, 235],\n            &[134, 203, 223],\n            &[38, 217, 235],\n            &[162, 177],\n            &[32, 166, 234],\n            &[30, 90, 218],\n            &[9, 106],\n            &[151, 204, 216],\n            &[97, 213, 253],\n            &[78, 91],\n            &[39, 175, 191],\n            &[170, 232],\n            &[2, 35, 233],\n            &[22, 198, 217],\n            &[17, 114],\n            &[32, 173],\n            &[65, 114],\n            &[121, 173, 222],\n            &[25, 144],\n        ],\n        &[\n            (&[106, 108], 34),\n            (&[224, 237], 34),\n            (&[51, 132], 32),\n            (&[82, 117], 32),\n            (&[72, 108], 31),\n            (&[142, 194], 31),\n            (&[0, 34], 30),\n            (&[12, 208], 30),\n            (&[15, 141], 30),\n            (&[30, 248], 30),\n        ],\n        (&[62, 131, 203], Some(&[62, 131, 205])),\n    );\n    random_ordered_unique_vecs_length_range_helper(\n        2,\n        4,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            &[0, 1, 5],\n            &[1, 4],\n            &[2, 4, 6],\n            &[0, 1, 2],\n            &[9, 13],\n            &[0, 2, 7],\n            &[4, 6, 7],\n            &[0, 6],\n            &[0, 1, 3],\n            &[1, 2, 5],\n            &[0, 1],\n            &[0, 1, 4],\n            &[0, 2],\n            &[0, 2, 12],\n            &[1, 2, 3],\n            &[3, 9],\n            &[0, 1],\n            &[1, 2],\n            &[0, 1, 11],\n            &[1, 6],\n        ],\n        &[\n            (&[0, 1], 103032),\n            (&[0, 1, 2], 84142),\n            (&[0, 2], 66185),\n            (&[0, 1, 3], 52638),\n            (&[0, 3], 42990),\n            (&[1, 2], 40380),\n            (&[0, 1, 4], 33815),\n            (&[0, 2, 3], 31257),\n            (&[0, 4], 28088),\n            (&[1, 3], 26214),\n        ],\n        (&[0, 3], None),\n    );\n    random_ordered_unique_vecs_length_range_helper(\n        2,\n        4,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            &['c', 'q', 'v'],\n            &['e', 'i'],\n            &['g', 'p', 's'],\n            &['m', 'n', 't'],\n            &['o', 'z'],\n            &['f', 'k', 'm'],\n            &['q', 'u', 'y'],\n            &['k', 'x'],\n            &['h', 'n', 'u'],\n            &['a', 'j', 'n'],\n            &['w', 'z'],\n            &['b', 'l', 'w'],\n            &['l', 'u'],\n            &['e', 'l', 'n'],\n            &['k', 'u', 'v'],\n            &['c', 'h'],\n            &['i', 'y'],\n            &['m', 'r'],\n            &['m', 's', 'y'],\n            &['e', 'l'],\n        ],\n        &[\n            (&['l', 'x'], 1640),\n            (&['o', 't'], 1636),\n            (&['b', 'p'], 1630),\n            (&['m', 'v'], 1623),\n            (&['h', 'u'], 1621),\n            (&['a', 'x'], 1614),\n            (&['d', 'f'], 1613),\n            (&['e', 'r'], 1613),\n            (&['o', 'p'], 1612),\n            (&['c', 'i'], 1611),\n        ],\n        (&['g', 'j'], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_length_range_fail() {\n    random_ordered_unique_vecs_length_range(EXAMPLE_SEED, 2, 2, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_ordered_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_ordered_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn random_ordered_unique_vecs_min_length_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_ordered_unique_vecs_min_length(\n            EXAMPLE_SEED,\n            min_length,\n            xs_gen,\n            mean_length_numerator,\n            mean_length_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_ordered_unique_vecs_min_length() {\n    random_ordered_unique_vecs_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            &[],\n            &[11, 32, 38, 85, 134, 136, 162, 166, 177, 200, 203, 217, 223, 235],\n            &[30, 90, 218, 234],\n            &[9, 106, 204, 216],\n            &[151],\n            &[],\n            &[78, 91, 97, 213, 253],\n            &[39, 191],\n            &[170, 175, 232, 233],\n            &[],\n            &[2, 22, 35, 114, 198, 217],\n            &[],\n            &[],\n            &[17, 25, 32, 65, 79, 114, 121, 144, 148, 173, 222],\n            &[52, 69, 73, 91, 115, 137, 153, 178],\n            &[],\n            &[34, 95, 112],\n            &[],\n            &[106, 130, 167, 168, 197],\n            &[86, 101, 122, 150, 172, 177, 207, 218, 221],\n        ],\n        &[\n            (&[], 199913),\n            (&[7], 705),\n            (&[25], 689),\n            (&[184], 681),\n            (&[213], 681),\n            (&[255], 676),\n            (&[215], 675),\n            (&[54], 673),\n            (&[122], 672),\n            (&[207], 672),\n        ],\n        (&[27, 31, 211, 238], Some(&[27, 31, 247, 251])),\n    );\n    random_ordered_unique_vecs_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        7,\n        1,\n        &[\n            &[11, 85, 136],\n            &[9, 30, 32, 38, 90, 106, 134, 162, 166, 177, 200, 203, 217, 218, 223, 234, 235],\n            &[78, 97, 151, 204, 213, 216, 253],\n            &[39, 91, 170, 175, 191, 232, 233],\n            &[2, 22, 35, 217],\n            &[17, 114, 198],\n            &[25, 32, 65, 114, 121, 144, 173, 222],\n            &[52, 73, 79, 115, 148],\n            &[34, 69, 91, 112, 137, 153, 178],\n            &[95, 106, 167],\n            &[86, 122, 130, 150, 168, 172, 177, 197, 207],\n            &[101, 218, 221],\n            &[9, 74, 115],\n            &[40, 48, 52, 97, 104, 109, 123, 133, 159, 196, 201, 235, 247, 250],\n            &[7, 11, 24, 43, 68, 103, 112, 157, 190, 216, 217],\n            &[84, 135, 211],\n            &[29, 55, 65, 89, 191, 206],\n            &[9, 51, 79],\n            &[3, 20, 22, 34, 62, 114, 118, 148],\n            &[23, 32, 47, 50, 120, 166, 176, 177, 194, 204, 238, 248],\n        ],\n        &[\n            (&[5, 128, 142], 4),\n            (&[137, 145, 160], 4),\n            (&[2, 4, 52], 3),\n            (&[1, 5, 192], 3),\n            (&[12, 41, 58], 3),\n            (&[2, 95, 171], 3),\n            (&[20, 86, 94], 3),\n            (&[21, 43, 50], 3),\n            (&[3, 81, 122], 3),\n            (&[31, 54, 79], 3),\n        ],\n        (&[26, 138, 167], Some(&[26, 138, 167, 173, 211])),\n    );\n    random_ordered_unique_vecs_min_length_helper(\n        0,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            &[],\n            &[1, 9, 12, 14, 16, 17, 19, 21, 41, 42, 68, 79, 124, 141],\n            &[0, 1, 10, 99],\n            &[2, 12, 36, 77],\n            &[1],\n            &[],\n            &[1, 5, 9, 19, 103],\n            &[6, 7],\n            &[15, 18, 51, 159],\n            &[],\n            &[2, 26, 40, 52, 64, 75],\n            &[],\n            &[],\n            &[3, 4, 5, 7, 30, 31, 34, 43, 49, 51, 67],\n            &[1, 14, 16, 24, 29, 41, 47, 52],\n            &[],\n            &[11, 13, 62],\n            &[],\n            &[3, 14, 42, 47, 109],\n            &[5, 13, 16, 25, 37, 41, 42, 86, 96],\n        ],\n        &[\n            (&[], 199913),\n            (&[0], 4861),\n            (&[1], 4593),\n            (&[2], 4498),\n            (&[3], 4405),\n            (&[4], 4330),\n            (&[5], 4078),\n            (&[6], 4050),\n            (&[7], 3858),\n            (&[8], 3848),\n        ],\n        (\n            &[3, 9, 14, 22, 36, 56, 107],\n            Some(&[3, 9, 14, 22, 42, 54, 73, 150]),\n        ),\n    );\n    random_ordered_unique_vecs_min_length_helper(\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        7,\n        1,\n        &[\n            &[1, 14, 42],\n            &[0, 1, 9, 10, 12, 16, 17, 19, 21, 36, 41, 68, 77, 79, 99, 124, 141],\n            &[1, 2, 5, 9, 12, 19, 103],\n            &[6, 7, 15, 18, 51, 52, 159],\n            &[2, 40, 64, 75],\n            &[26, 34, 67],\n            &[4, 5, 7, 30, 31, 43, 49, 51],\n            &[3, 14, 16, 24, 47],\n            &[1, 11, 13, 29, 41, 52, 62],\n            &[3, 47, 109],\n            &[13, 14, 16, 25, 37, 41, 42, 86, 96],\n            &[5, 20, 42],\n            &[2, 74, 82],\n            &[3, 6, 7, 11, 17, 20, 36, 45, 56, 66, 76, 80, 89, 127],\n            &[1, 6, 10, 13, 19, 23, 25, 32, 41, 43, 97],\n            &[7, 41, 134],\n            &[9, 10, 25, 26, 47, 105],\n            &[68, 94, 109],\n            &[1, 3, 9, 13, 28, 43, 44, 84],\n            &[0, 4, 5, 6, 7, 13, 31, 32, 37, 42, 50, 75],\n        ],\n        &[\n            (&[0, 2, 5], 42),\n            (&[0, 1, 8], 39),\n            (&[0, 3, 4], 38),\n            (&[1, 3, 9], 38),\n            (&[0, 1, 7], 35),\n            (&[0, 2, 8], 34),\n            (&[1, 2, 12], 34),\n            (&[0, 1, 2], 33),\n            (&[1, 2, 3], 33),\n            (&[1, 3, 4], 33),\n        ],\n        (\n            &[3, 8, 14, 19, 25, 36, 52, 64, 71],\n            Some(&[3, 8, 14, 19, 25, 38, 58, 61]),\n        ),\n    );\n    random_ordered_unique_vecs_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            &[],\n            &[],\n            &[85],\n            &[11],\n            &[136, 200],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[134, 235],\n            &[203],\n            &[],\n            &[38, 223],\n            &[],\n            &[],\n            &[],\n            &[],\n        ],\n        &[\n            (&[], 800023),\n            (&[162], 692),\n            (&[235], 690),\n            (&[90], 688),\n            (&[65], 687),\n            (&[249], 686),\n            (&[175], 684),\n            (&[108], 683),\n            (&[211], 682),\n            (&[237], 680),\n        ],\n        (&[], None),\n    );\n    random_ordered_unique_vecs_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        13,\n        4,\n        &[\n            &[11, 85, 136],\n            &[134, 200, 235],\n            &[38, 203, 223, 235],\n            &[32, 162, 177, 217],\n            &[30, 90, 166, 218, 234],\n            &[9, 106, 216],\n            &[151, 204, 213],\n            &[78, 97, 253],\n            &[39, 91, 191],\n            &[170, 175, 232],\n            &[2, 35, 233],\n            &[22, 198, 217],\n            &[17, 32, 65, 114, 173],\n            &[25, 121, 173, 222],\n            &[79, 144, 148],\n            &[52, 69, 73, 115, 137],\n            &[91, 153, 178],\n            &[34, 95, 112],\n            &[106, 167, 197],\n            &[122, 130, 168],\n        ],\n        &[\n            (&[10, 87, 204], 6),\n            (&[15, 40, 115], 6),\n            (&[108, 193, 199], 6),\n            (&[1, 22, 70], 5),\n            (&[1, 8, 212], 5),\n            (&[2, 40, 169], 5),\n            (&[2, 58, 211], 5),\n            (&[3, 29, 186], 5),\n            (&[3, 97, 112], 5),\n            (&[11, 66, 140], 5),\n        ],\n        (&[49, 78, 193], Some(&[49, 78, 193, 215])),\n    );\n    random_ordered_unique_vecs_min_length_helper(\n        0,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            &[],\n            &['g', 'q', '³', '»', 'À', 'Á', 'Ã', 'È', 'á', 'â', 'ì', 'ñ', 'Ā', 'ą'],\n            &['ª', '´', 'Ã', 'ä'],\n            &['½', 'Á', 'Ï', 'ý'],\n            &['j'],\n            &[],\n            &['u', '½', 'Â', 'Ñ', 'ï'],\n            &['x', 'õ'],\n            &['¡', 'Â', 'ù', 'Ċ'],\n            &[],\n            &['b', 'r', 's', '¬', 'Â', 'Ñ'],\n            &[],\n            &[],\n            &['j', 'n', 't', '¬', 'º', '¿', 'Á', 'Ø', 'Þ', 'ô', 'ü'],\n            &['b', 'k', '±', 'Î', 'Ü', 'æ', 'è', 'ā'],\n            &[],\n            &['«', '¹', 'Î'],\n            &[],\n            &['~', '¯', '´', 'Ý', 'â'],\n            &['g', '¼', 'Ç', 'Î', 'Ü', 'Þ', 'æ', 'é', 'ö'],\n        ],\n        &[\n            (&[][..], 199913),\n            (&['Ó'], 1270),\n            (&['Â'], 1249),\n            (&['§'], 1244),\n            (&['¿'], 1243),\n            (&['õ'], 1241),\n            (&['ĉ'], 1234),\n            (&['¤'], 1232),\n            (&['¼'], 1232),\n            (&['Ì'], 1229),\n        ],\n        (\n            &['o', 'v', '¢', '±', 'Ä', 'Ć'],\n            Some(&['o', 'v', '¢', '³', 'ã']),\n        ),\n    );\n    random_ordered_unique_vecs_min_length_helper(\n        3,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        7,\n        1,\n        &[\n            &['g', 'q', 'á'],\n            &['g', 'ª', '³', '´', '»', '½', 'À', 'Á', 'Ã', 'È', 'Ï', 'â', 'ä', 'ì', 'ñ', 'Ā', 'ą'],\n            &['j', 'u', '½', 'Â', 'Ñ', 'ï', 'ý'],\n            &['x', '¡', '¬', 'Â', 'õ', 'ù', 'Ċ'],\n            &['b', 's', '¬', 'Ñ'],\n            &['n', 'r', 'Â'],\n            &['t', '¬', 'º', '¿', 'Ø', 'Þ', 'ô', 'ü'],\n            &['j', 'k', '±', 'Á', 'è'],\n            &['b', '«', '¹', 'Î', 'Ü', 'æ', 'ā'],\n            &['~', '´', 'Î'],\n            &['g', '¯', 'Î', 'Ý', 'Þ', 'â', 'æ', 'é', 'ö'],\n            &['¼', 'Ç', 'Ü'],\n            &['¡', '§', 'Ì'],\n            &['d', 'm', 'z', '{', '¨', '®', '±', '¼', 'Ë', 'Ü', 'ê', 'ì', 'ý', 'þ'],\n            &['x', 'ª', '½', 'À', 'Õ', 'ì', 'ï', 'û', 'ă', 'Ą', 'ċ'],\n            &['¢', '«', 'Ć'],\n            &['{', '¢', '½', 'È', 'ä', 'ÿ'],\n            &['Ë', 'Õ', 'ê'],\n            &['p', '¨', '°', 'º', 'Å', 'Ó', '×', 'ü'],\n            &['d', 'k', 'o', 'v', '¥', '±', 'Ä', 'È', 'Ê', 'ß', 'æ', 'Ć'],\n        ],\n        &[\n            (&['m', 'u', 'w'], 6),\n            (&['b', 'n', 'Ã'], 6),\n            (&['g', '®', 'Ý'], 6),\n            (&['x', 'Ä', 'î'], 6),\n            (&['º', 'Ú', '÷'], 6),\n            (&['a', 'w', 'ø'], 5),\n            (&['c', 'e', 'Þ'], 5),\n            (&['d', 't', 'Ã'], 5),\n            (&['m', 'r', 'È'], 5),\n            (&['w', '{', '³'], 5),\n        ],\n        (\n            &['o', 's', '×', 'Ý', 'Þ', 'ß', 'î', 'ù'],\n            Some(&['o', 's', '×', 'à', 'ã', 'ò', 'ċ']),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_min_length_fail_1() {\n    random_ordered_unique_vecs_min_length(EXAMPLE_SEED, 3, &random_primitive_ints::<u32>, 3, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_min_length_fail_2() {\n    random_ordered_unique_vecs_min_length(EXAMPLE_SEED, 1, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_ordered_unique_vecs_min_length_fail_3() {\n    random_ordered_unique_vecs_min_length(\n        EXAMPLE_SEED,\n        0,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_unique_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_unique_vecs;\nuse std::fmt::Debug;\n\nfn random_unique_vecs_helper<T: Clone + Debug + Eq + Hash + Ord, I: Clone + Iterator<Item = T>>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_unique_vecs(\n            EXAMPLE_SEED,\n            xs_gen,\n            mean_length_numerator,\n            mean_length_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_unique_vecs() {\n    random_unique_vecs_helper(\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            &[],\n            &[85, 11, 136, 200, 235, 134, 203, 223, 38, 217, 177, 162, 32, 166],\n            &[234, 30, 218, 90],\n            &[106, 9, 216, 204],\n            &[151],\n            &[],\n            &[213, 97, 253, 78, 91],\n            &[39, 191],\n            &[175, 170, 232, 233],\n            &[],\n            &[2, 35, 22, 217, 198, 114],\n            &[],\n            &[],\n            &[17, 32, 173, 114, 65, 121, 222, 25, 144, 148, 79],\n            &[115, 52, 73, 69, 137, 91, 153, 178],\n            &[],\n            &[112, 34, 95],\n            &[],\n            &[106, 167, 197, 130, 168],\n            &[122, 207, 172, 177, 86, 150, 221, 218, 101],\n        ],\n        &[\n            (&[], 199913),\n            (&[7], 705),\n            (&[25], 689),\n            (&[184], 681),\n            (&[213], 681),\n            (&[255], 676),\n            (&[215], 675),\n            (&[54], 673),\n            (&[122], 672),\n            (&[207], 672),\n        ],\n        (&[96], None),\n    );\n    random_unique_vecs_helper(\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            &[],\n            &[1, 14, 42, 12, 141, 19, 9, 68, 16, 79, 21, 17, 41, 124],\n            &[10, 1, 99, 0],\n            &[77, 36, 2, 12],\n            &[1],\n            &[],\n            &[103, 9, 19, 1, 5],\n            &[7, 6],\n            &[51, 159, 15, 18],\n            &[],\n            &[52, 75, 40, 64, 2, 26],\n            &[],\n            &[],\n            &[67, 34, 51, 30, 31, 49, 43, 7, 5, 4, 3],\n            &[14, 47, 24, 16, 52, 29, 1, 41],\n            &[],\n            &[13, 11, 62],\n            &[],\n            &[47, 3, 109, 42, 14],\n            &[37, 86, 25, 96, 41, 13, 16, 42, 5],\n        ],\n        &[\n            (&[], 199913),\n            (&[0], 4861),\n            (&[1], 4593),\n            (&[2], 4498),\n            (&[3], 4405),\n            (&[4], 4330),\n            (&[5], 4078),\n            (&[6], 4050),\n            (&[7], 3858),\n            (&[8], 3848),\n        ],\n        (&[15, 3], None),\n    );\n    random_unique_vecs_helper(\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            &[],\n            &[],\n            &[85],\n            &[11],\n            &[136, 200],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[235, 134],\n            &[203],\n            &[],\n            &[223, 38],\n            &[],\n            &[],\n            &[],\n            &[],\n        ],\n        &[\n            (&[][..], 800023),\n            (&[162], 692),\n            (&[235], 690),\n            (&[90], 688),\n            (&[65], 687),\n            (&[249], 686),\n            (&[175], 684),\n            (&[108], 683),\n            (&[211], 682),\n            (&[237], 680),\n        ],\n        (&[], None),\n    );\n    random_unique_vecs_helper(\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            &[],\n            &['q', 'á', 'g', 'Á', 'À', 'È', '»', 'ì', '³', 'ą', 'â', 'Ã', 'ñ', 'Ā'],\n            &['Ã', 'ª', 'ä', '´'],\n            &['½', 'Á', 'Ï', 'ý'],\n            &['j'],\n            &[],\n            &['ï', 'Ñ', 'u', 'Â', '½'],\n            &['õ', 'x'],\n            &['Â', 'ù', '¡', 'Ċ'],\n            &[],\n            &['¬', 'b', 'Ñ', 's', 'Â', 'r'],\n            &[],\n            &[],\n            &['n', '¿', 'Þ', 'ô', 'Ø', 'º', 'ü', 't', '¬', 'j', 'Á'],\n            &['±', 'è', 'k', 'æ', 'b', 'Î', 'ā', 'Ü'],\n            &[],\n            &['¹', '«', 'Î'],\n            &[],\n            &['~', '´', 'Ý', 'â', '¯'],\n            &['é', 'æ', 'Þ', 'ö', 'g', 'Î', 'Ç', 'Ü', '¼'],\n        ],\n        &[\n            (&[], 199913),\n            (&['Ó'], 1270),\n            (&['Â'], 1249),\n            (&['§'], 1244),\n            (&['¿'], 1243),\n            (&['õ'], 1241),\n            (&['ĉ'], 1234),\n            (&['¤'], 1232),\n            (&['¼'], 1232),\n            (&['Ì'], 1229),\n        ],\n        (\n            &['¶', 'Ă', 'ą', '®', 'Á', 'í', '¬', '¾', '¸', 'Ã', '}', 'ù', 'ý', '½', 'a'],\n            Some(&['¶', 'Ă', 'ć']),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_fail_1() {\n    random_unique_vecs(EXAMPLE_SEED, &random_primitive_ints::<u32>, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_fail_2() {\n    random_unique_vecs(EXAMPLE_SEED, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_fail_3() {\n    random_unique_vecs(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_unique_vecs_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::{Itertools, repeat_n};\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_unique_vecs_fixed_length;\nuse std::fmt::Debug;\n\nfn random_unique_vecs_fixed_length_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    expected_values: &[&[I::Item]],\n    expected_common_values: &[(&[I::Item], usize)],\n    expected_median: (&[I::Item], Option<&[I::Item]>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    random_vecs_helper_helper(\n        random_unique_vecs_fixed_length(len, xs),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_unique_vecs_fixed_length() {\n    random_unique_vecs_fixed_length_helper(\n        0,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        repeat_n(&[][..], 20).collect_vec().as_slice(),\n        &[(&[], 1000000)],\n        (&[], None),\n    );\n    random_unique_vecs_fixed_length_helper(\n        1,\n        random_bools(EXAMPLE_SEED),\n        &[\n            &[true],\n            &[false],\n            &[false],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[false],\n        ],\n        &[(&[true], 500473), (&[false], 499527)],\n        (&[true], None),\n    );\n    random_unique_vecs_fixed_length_helper(\n        3,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            &[113, 239, 69],\n            &[108, 228, 210],\n            &[168, 161, 87],\n            &[32, 110, 83],\n            &[188, 34, 89],\n            &[238, 93, 200],\n            &[149, 115, 189],\n            &[149, 217, 201],\n            &[117, 146, 31],\n            &[72, 151, 169],\n            &[174, 33, 7],\n            &[38, 81, 144],\n            &[72, 127, 113],\n            &[128, 233, 107],\n            &[46, 119, 12],\n            &[18, 164, 243],\n            &[114, 174, 59],\n            &[247, 39, 174],\n            &[160, 184, 104],\n            &[37, 100, 252],\n        ],\n        &[\n            (&[205, 0, 97], 4),\n            (&[102, 18, 19], 4),\n            (&[105, 70, 13], 4),\n            (&[22, 45, 192], 4),\n            (&[87, 100, 26], 4),\n            (&[15, 107, 109], 4),\n            (&[134, 245, 157], 4),\n            (&[138, 164, 179], 4),\n            (&[219, 253, 196], 4),\n            (&[237, 197, 239], 4),\n        ],\n        (&[128, 16, 107], Some(&[128, 16, 116])),\n    );\n    random_unique_vecs_fixed_length_helper(\n        2,\n        random_unique_vecs_fixed_length(2, random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            &[vec![113, 239], vec![69, 108]],\n            &[vec![228, 210], vec![168, 161]],\n            &[vec![87, 32], vec![110, 83]],\n            &[vec![188, 34], vec![89, 238]],\n            &[vec![93, 200], vec![149, 115]],\n            &[vec![189, 149], vec![217, 201]],\n            &[vec![117, 146], vec![31, 72]],\n            &[vec![151, 169], vec![174, 33]],\n            &[vec![7, 38], vec![81, 144]],\n            &[vec![72, 127], vec![113, 128]],\n            &[vec![233, 107], vec![46, 119]],\n            &[vec![12, 18], vec![164, 243]],\n            &[vec![114, 174], vec![59, 247]],\n            &[vec![39, 174], vec![160, 184]],\n            &[vec![104, 37], vec![100, 252]],\n            &[vec![228, 122], vec![107, 69]],\n            &[vec![242, 248], vec![179, 142]],\n            &[vec![239, 233], vec![61, 189]],\n            &[vec![235, 85], vec![192, 7]],\n            &[vec![200, 90], vec![185, 178]],\n        ],\n        &[\n            (&[vec![60, 12], vec![3, 32]], 2),\n            (&[vec![0, 80], vec![88, 210]], 2),\n            (&[vec![1, 3], vec![216, 183]], 2),\n            (&[vec![159, 0], vec![69, 30]], 2),\n            (&[vec![199, 6], vec![95, 79]], 2),\n            (&[vec![2, 98], vec![221, 19]], 2),\n            (&[vec![212, 65], vec![99, 2]], 2),\n            (&[vec![3, 14], vec![61, 170]], 2),\n            (&[vec![41, 155], vec![3, 72]], 2),\n            (&[vec![47, 85], vec![69, 66]], 2),\n        ],\n        (\n            &[vec![128, 41], vec![252, 44]],\n            Some(&[vec![128, 42], vec![8, 241]]),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_unique_vecs_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_unique_vecs_from_length_iterator;\nuse malachite_base::vecs::random_values_from_vec;\nuse std::fmt::Debug;\n\nfn random_unique_vecs_from_length_iterator_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_unique_vecs_from_length_iterator(EXAMPLE_SEED, lengths_gen, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_unique_vecs_from_length_iterator() {\n    random_unique_vecs_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2]),\n        &random_bools,\n        &[\n            &[true, false],\n            &[],\n            &[true, false],\n            &[true, false],\n            &[],\n            &[true, false],\n            &[true, false],\n            &[],\n            &[true, false],\n            &[false, true],\n            &[],\n            &[false, true],\n            &[],\n            &[false, true],\n            &[false, true],\n            &[],\n            &[],\n            &[],\n            &[true, false],\n            &[],\n        ],\n        &[(&[], 499637), (&[false, true], 250413), (&[true, false], 249950)],\n        (&[false, true], None),\n    );\n    random_unique_vecs_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        &random_primitive_ints::<u8>,\n        &[\n            &[85, 11, 136, 200, 235, 134, 203, 223, 38, 217, 177, 162],\n            &[32, 166],\n            &[234, 30, 218, 90, 106, 9, 216, 204, 151, 213, 97, 253, 78, 91, 39, 191],\n            &[175, 170],\n            &[\n                232, 233, 2, 35, 22, 217, 198, 114, 17, 32, 173, 65, 121, 222, 25, 144, 148, 79,\n                115, 52, 73, 69, 137, 91, 153, 178, 112, 34,\n            ],\n            &[],\n            &[95, 106, 167, 197, 130, 168, 122, 207, 172, 177],\n            &[86, 150, 221, 218, 101, 115, 74, 9],\n            &[123, 109],\n            &[],\n            &[52, 201, 159, 247, 250, 48, 133, 235, 196, 40, 97, 104],\n            &[68, 190, 216, 7],\n            &[],\n            &[],\n            &[216, 157],\n            &[43, 112, 217, 24, 11, 103],\n            &[],\n            &[211, 84],\n            &[],\n            &[135, 55],\n        ],\n        &[\n            (&[], 333981),\n            (&[79, 76], 14),\n            (&[234, 129], 14),\n            (&[119, 62], 13),\n            (&[33, 163], 13),\n            (&[5, 42], 12),\n            (&[28, 91], 12),\n            (&[55, 25], 12),\n            (&[152, 55], 12),\n            (&[224, 77], 12),\n        ],\n        (&[63, 197, 169, 69, 240, 201], Some(&[63, 197, 181, 249])),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_unique_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_unique_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn random_unique_vecs_length_inclusive_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_unique_vecs_length_inclusive_range(EXAMPLE_SEED, a, b, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_unique_vecs_length_inclusive_range() {\n    random_unique_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &random_primitive_ints::<u8>,\n        &[\n            &[85, 11, 136],\n            &[200, 235],\n            &[134, 203, 223],\n            &[38, 235, 217],\n            &[177, 162],\n            &[32, 166, 234],\n            &[30, 218, 90],\n            &[106, 9],\n            &[216, 204, 151],\n            &[213, 97, 253],\n            &[78, 91],\n            &[39, 191, 175],\n            &[170, 232],\n            &[233, 2, 35],\n            &[22, 217, 198],\n            &[114, 17],\n            &[32, 173],\n            &[114, 65],\n            &[121, 222, 173],\n            &[25, 144],\n        ],\n        &[\n            (&[149, 194], 23),\n            (&[237, 224], 23),\n            (&[109, 76], 21),\n            (&[187, 29], 21),\n            (&[96, 105], 21),\n            (&[233, 132], 21),\n            (&[25, 96], 20),\n            (&[92, 85], 20),\n            (&[108, 72], 20),\n            (&[128, 48], 20),\n        ],\n        (&[127, 247], None),\n    );\n    random_unique_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            &[5, 0, 1],\n            &[1, 4],\n            &[2, 4, 6],\n            &[2, 0, 1],\n            &[9, 13],\n            &[0, 2, 7],\n            &[4, 6, 7],\n            &[6, 0],\n            &[0, 1, 3],\n            &[5, 1, 2],\n            &[1, 0],\n            &[0, 1, 4],\n            &[2, 0],\n            &[12, 0, 2],\n            &[3, 1, 2],\n            &[3, 9],\n            &[1, 0],\n            &[2, 1],\n            &[11, 1, 0],\n            &[1, 6],\n        ],\n        &[\n            (&[0, 1], 55434),\n            (&[1, 0], 47598),\n            (&[0, 2], 37211),\n            (&[2, 0], 28974),\n            (&[0, 3], 24737),\n            (&[1, 2], 21227),\n            (&[2, 1], 19153),\n            (&[0, 1, 2], 18604),\n            (&[3, 0], 18253),\n            (&[0, 4], 16195),\n        ],\n        (&[1, 4], None),\n    );\n    random_unique_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            &['v', 'c', 'q'],\n            &['i', 'e'],\n            &['p', 'g', 's'],\n            &['n', 't', 'm'],\n            &['z', 'o'],\n            &['m', 'f', 'k'],\n            &['q', 'y', 'u'],\n            &['k', 'x'],\n            &['h', 'u', 'n'],\n            &['n', 'j', 'a'],\n            &['w', 'z'],\n            &['l', 'w', 'b'],\n            &['l', 'u'],\n            &['n', 'e', 'l'],\n            &['v', 'k', 'u'],\n            &['h', 'c'],\n            &['y', 'i'],\n            &['m', 'r'],\n            &['m', 'y', 's'],\n            &['l', 'e'],\n        ],\n        &[\n            (&['i', 'p'], 855),\n            (&['o', 't'], 845),\n            (&['c', 'i'], 842),\n            (&['h', 'u'], 841),\n            (&['x', 'l'], 841),\n            (&['a', 'o'], 833),\n            (&['g', 'h'], 833),\n            (&['z', 'n'], 832),\n            (&['j', 'n'], 831),\n            (&['l', 'c'], 829),\n        ],\n        (&['m', 'z', 'l'], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_length_inclusive_range_fail() {\n    random_unique_vecs_length_inclusive_range(EXAMPLE_SEED, 2, 1, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_unique_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_unique_vecs_length_range;\nuse std::fmt::Debug;\n\nfn random_unique_vecs_length_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_unique_vecs_length_range(EXAMPLE_SEED, a, b, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_unique_vecs_length_range() {\n    random_unique_vecs_length_range_helper(\n        2,\n        4,\n        &random_primitive_ints::<u8>,\n        &[\n            &[85, 11, 136],\n            &[200, 235],\n            &[134, 203, 223],\n            &[38, 235, 217],\n            &[177, 162],\n            &[32, 166, 234],\n            &[30, 218, 90],\n            &[106, 9],\n            &[216, 204, 151],\n            &[213, 97, 253],\n            &[78, 91],\n            &[39, 191, 175],\n            &[170, 232],\n            &[233, 2, 35],\n            &[22, 217, 198],\n            &[114, 17],\n            &[32, 173],\n            &[114, 65],\n            &[121, 222, 173],\n            &[25, 144],\n        ],\n        &[\n            (&[149, 194], 23),\n            (&[237, 224], 23),\n            (&[109, 76], 21),\n            (&[187, 29], 21),\n            (&[96, 105], 21),\n            (&[233, 132], 21),\n            (&[25, 96], 20),\n            (&[92, 85], 20),\n            (&[108, 72], 20),\n            (&[128, 48], 20),\n        ],\n        (&[127, 247], None),\n    );\n    random_unique_vecs_length_range_helper(\n        2,\n        4,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            &[5, 0, 1],\n            &[1, 4],\n            &[2, 4, 6],\n            &[2, 0, 1],\n            &[9, 13],\n            &[0, 2, 7],\n            &[4, 6, 7],\n            &[6, 0],\n            &[0, 1, 3],\n            &[5, 1, 2],\n            &[1, 0],\n            &[0, 1, 4],\n            &[2, 0],\n            &[12, 0, 2],\n            &[3, 1, 2],\n            &[3, 9],\n            &[1, 0],\n            &[2, 1],\n            &[11, 1, 0],\n            &[1, 6],\n        ],\n        &[\n            (&[0, 1], 55434),\n            (&[1, 0], 47598),\n            (&[0, 2], 37211),\n            (&[2, 0], 28974),\n            (&[0, 3], 24737),\n            (&[1, 2], 21227),\n            (&[2, 1], 19153),\n            (&[0, 1, 2], 18604),\n            (&[3, 0], 18253),\n            (&[0, 4], 16195),\n        ],\n        (&[1, 4], None),\n    );\n    random_unique_vecs_length_range_helper(\n        2,\n        4,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            &['v', 'c', 'q'],\n            &['i', 'e'],\n            &['p', 'g', 's'],\n            &['n', 't', 'm'],\n            &['z', 'o'],\n            &['m', 'f', 'k'],\n            &['q', 'y', 'u'],\n            &['k', 'x'],\n            &['h', 'u', 'n'],\n            &['n', 'j', 'a'],\n            &['w', 'z'],\n            &['l', 'w', 'b'],\n            &['l', 'u'],\n            &['n', 'e', 'l'],\n            &['v', 'k', 'u'],\n            &['h', 'c'],\n            &['y', 'i'],\n            &['m', 'r'],\n            &['m', 'y', 's'],\n            &['l', 'e'],\n        ],\n        &[\n            (&['i', 'p'], 855),\n            (&['o', 't'], 845),\n            (&['c', 'i'], 842),\n            (&['h', 'u'], 841),\n            (&['x', 'l'], 841),\n            (&['a', 'o'], 833),\n            (&['g', 'h'], 833),\n            (&['z', 'n'], 832),\n            (&['j', 'n'], 831),\n            (&['l', 'c'], 829),\n        ],\n        (&['m', 'z', 'l'], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_length_range_fail() {\n    random_unique_vecs_length_range(EXAMPLE_SEED, 2, 2, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_unique_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::exhaustive::exhaustive_chars;\nuse malachite_base::chars::random::graphic_weighted_random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_unique_vecs_min_length;\nuse std::fmt::Debug;\n\nfn random_unique_vecs_min_length_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_unique_vecs_min_length(\n            EXAMPLE_SEED,\n            min_length,\n            xs_gen,\n            mean_length_numerator,\n            mean_length_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_unique_vecs_min_length() {\n    random_unique_vecs_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            &[],\n            &[85, 11, 136, 200, 235, 134, 203, 223, 38, 217, 177, 162, 32, 166],\n            &[234, 30, 218, 90],\n            &[106, 9, 216, 204],\n            &[151],\n            &[],\n            &[213, 97, 253, 78, 91],\n            &[39, 191],\n            &[175, 170, 232, 233],\n            &[],\n            &[2, 35, 22, 217, 198, 114],\n            &[],\n            &[],\n            &[17, 32, 173, 114, 65, 121, 222, 25, 144, 148, 79],\n            &[115, 52, 73, 69, 137, 91, 153, 178],\n            &[],\n            &[112, 34, 95],\n            &[],\n            &[106, 167, 197, 130, 168],\n            &[122, 207, 172, 177, 86, 150, 221, 218, 101],\n        ],\n        &[\n            (&[], 199913),\n            (&[7], 705),\n            (&[25], 689),\n            (&[184], 681),\n            (&[213], 681),\n            (&[255], 676),\n            (&[215], 675),\n            (&[54], 673),\n            (&[122], 672),\n            (&[207], 672),\n        ],\n        (&[96], None),\n    );\n    random_unique_vecs_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        7,\n        1,\n        &[\n            &[85, 11, 136],\n            &[200, 235, 134, 203, 223, 38, 217, 177, 162, 32, 166, 234, 30, 218, 90, 106, 9],\n            &[216, 204, 151, 213, 97, 253, 78],\n            &[91, 39, 191, 175, 170, 232, 233],\n            &[2, 35, 22, 217],\n            &[198, 114, 17],\n            &[32, 173, 114, 65, 121, 222, 25, 144],\n            &[148, 79, 115, 52, 73],\n            &[69, 137, 91, 153, 178, 112, 34],\n            &[95, 106, 167],\n            &[197, 130, 168, 122, 207, 172, 177, 86, 150],\n            &[221, 218, 101],\n            &[115, 74, 9],\n            &[123, 109, 52, 201, 159, 247, 250, 48, 133, 235, 196, 40, 97, 104],\n            &[68, 190, 216, 7, 157, 43, 112, 217, 24, 11, 103],\n            &[211, 84, 135],\n            &[55, 29, 206, 89, 65, 191],\n            &[51, 9, 79],\n            &[148, 34, 22, 62, 3, 114, 118, 20],\n            &[47, 194, 50, 32, 120, 176, 166, 23, 204, 248, 177, 238],\n        ],\n        &[\n            (&[8, 94, 244], 3),\n            (&[233, 14, 180], 3),\n            (&[46, 247, 166], 3),\n            (&[84, 118, 223], 3),\n            (&[4, 52, 2], 2),\n            (&[80, 2, 0], 2),\n            (&[1, 116, 5], 2),\n            (&[1, 5, 192], 2),\n            (&[1, 96, 39], 2),\n            (&[20, 10, 9], 2),\n        ],\n        (\n            &[127, 218, 55, 167, 163, 19, 99, 71, 32, 117, 72, 38, 27, 29],\n            Some(&[127, 218, 69, 59, 30, 91]),\n        ),\n    );\n    random_unique_vecs_min_length_helper(\n        0,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        4,\n        1,\n        &[\n            &[],\n            &[1, 14, 42, 12, 141, 19, 9, 68, 16, 79, 21, 17, 41, 124],\n            &[10, 1, 99, 0],\n            &[77, 36, 2, 12],\n            &[1],\n            &[],\n            &[103, 9, 19, 1, 5],\n            &[7, 6],\n            &[51, 159, 15, 18],\n            &[],\n            &[52, 75, 40, 64, 2, 26],\n            &[],\n            &[],\n            &[67, 34, 51, 30, 31, 49, 43, 7, 5, 4, 3],\n            &[14, 47, 24, 16, 52, 29, 1, 41],\n            &[],\n            &[13, 11, 62],\n            &[],\n            &[47, 3, 109, 42, 14],\n            &[37, 86, 25, 96, 41, 13, 16, 42, 5],\n        ],\n        &[\n            (&[], 199913),\n            (&[0], 4861),\n            (&[1], 4593),\n            (&[2], 4498),\n            (&[3], 4405),\n            (&[4], 4330),\n            (&[5], 4078),\n            (&[6], 4050),\n            (&[7], 3858),\n            (&[8], 3848),\n        ],\n        (&[15, 3], None),\n    );\n    random_unique_vecs_min_length_helper(\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 32, 1),\n        7,\n        1,\n        &[\n            &[1, 14, 42],\n            &[12, 141, 19, 9, 68, 16, 79, 21, 17, 41, 124, 10, 1, 99, 0, 77, 36],\n            &[2, 12, 1, 103, 9, 19, 5],\n            &[7, 6, 51, 159, 15, 18, 52],\n            &[75, 40, 64, 2],\n            &[26, 67, 34],\n            &[51, 30, 31, 49, 43, 7, 5, 4],\n            &[3, 14, 47, 24, 16],\n            &[52, 29, 1, 41, 13, 11, 62],\n            &[47, 3, 109],\n            &[42, 14, 37, 86, 25, 96, 41, 13, 16],\n            &[42, 5, 20],\n            &[2, 82, 74],\n            &[7, 76, 11, 17, 127, 36, 20, 56, 89, 45, 6, 80, 3, 66],\n            &[23, 43, 1, 25, 6, 41, 19, 97, 10, 13, 32],\n            &[41, 7, 134],\n            &[47, 105, 26, 10, 9, 25],\n            &[94, 68, 109],\n            &[1, 9, 84, 3, 43, 44, 28, 13],\n            &[13, 5, 0, 31, 50, 75, 32, 4, 7, 37, 42, 6],\n        ],\n        &[\n            (&[0, 1, 7], 13),\n            (&[0, 2, 8], 12),\n            (&[6, 2, 8], 12),\n            (&[0, 2, 5], 11),\n            (&[2, 7, 3], 11),\n            (&[9, 3, 1], 11),\n            (&[0, 9, 2], 10),\n            (&[1, 8, 7], 10),\n            (&[3, 5, 1], 10),\n            (&[5, 0, 2], 10),\n        ],\n        (&[22, 28, 18, 89, 4, 52, 51], Some(&[22, 28, 19])),\n    );\n    random_unique_vecs_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            &[],\n            &[],\n            &[85],\n            &[11],\n            &[136, 200],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[235, 134],\n            &[203],\n            &[],\n            &[223, 38],\n            &[],\n            &[],\n            &[],\n            &[],\n        ],\n        &[\n            (&[], 800023),\n            (&[162], 692),\n            (&[235], 690),\n            (&[90], 688),\n            (&[65], 687),\n            (&[249], 686),\n            (&[175], 684),\n            (&[108], 683),\n            (&[211], 682),\n            (&[237], 680),\n        ],\n        (&[], None),\n    );\n    random_unique_vecs_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        13,\n        4,\n        &[\n            &[85, 11, 136],\n            &[200, 235, 134],\n            &[203, 223, 38, 235],\n            &[217, 177, 162, 32],\n            &[166, 234, 30, 218, 90],\n            &[106, 9, 216],\n            &[204, 151, 213],\n            &[97, 253, 78],\n            &[91, 39, 191],\n            &[175, 170, 232],\n            &[233, 2, 35],\n            &[22, 217, 198],\n            &[114, 17, 32, 173, 65],\n            &[121, 222, 173, 25],\n            &[144, 148, 79],\n            &[115, 52, 73, 69, 137],\n            &[91, 153, 178],\n            &[112, 34, 95],\n            &[106, 167, 197],\n            &[130, 168, 122],\n        ],\n        &[\n            (&[8, 57, 90], 4),\n            (&[185, 30, 26], 4),\n            (&[106, 20, 234], 4),\n            (&[152, 245, 81], 4),\n            (&[108, 192, 235], 4),\n            (&[75, 2, 5], 3),\n            (&[0, 106, 9], 3),\n            (&[2, 91, 90], 3),\n            (&[212, 1, 8], 3),\n            (&[49, 5, 75], 3),\n        ],\n        (&[128, 38, 40], Some(&[128, 38, 42])),\n    );\n    random_unique_vecs_min_length_helper(\n        0,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        4,\n        1,\n        &[\n            &[],\n            &['q', 'á', 'g', 'Á', 'À', 'È', '»', 'ì', '³', 'ą', 'â', 'Ã', 'ñ', 'Ā'],\n            &['Ã', 'ª', 'ä', '´'],\n            &['½', 'Á', 'Ï', 'ý'],\n            &['j'],\n            &[],\n            &['ï', 'Ñ', 'u', 'Â', '½'],\n            &['õ', 'x'],\n            &['Â', 'ù', '¡', 'Ċ'],\n            &[],\n            &['¬', 'b', 'Ñ', 's', 'Â', 'r'],\n            &[],\n            &[],\n            &['n', '¿', 'Þ', 'ô', 'Ø', 'º', 'ü', 't', '¬', 'j', 'Á'],\n            &['±', 'è', 'k', 'æ', 'b', 'Î', 'ā', 'Ü'],\n            &[],\n            &['¹', '«', 'Î'],\n            &[],\n            &['~', '´', 'Ý', 'â', '¯'],\n            &['é', 'æ', 'Þ', 'ö', 'g', 'Î', 'Ç', 'Ü', '¼'],\n        ],\n        &[\n            (&[], 199913),\n            (&['Ó'], 1270),\n            (&['Â'], 1249),\n            (&['§'], 1244),\n            (&['¿'], 1243),\n            (&['õ'], 1241),\n            (&['ĉ'], 1234),\n            (&['¤'], 1232),\n            (&['¼'], 1232),\n            (&['Ì'], 1229),\n        ],\n        (\n            &['¶', 'Ă', 'ą', '®', 'Á', 'í', '¬', '¾', '¸', 'Ã', '}', 'ù', 'ý', '½', 'a'],\n            Some(&['¶', 'Ă', 'ć']),\n        ),\n    );\n    random_unique_vecs_min_length_helper(\n        3,\n        &|seed| {\n            graphic_weighted_random_char_inclusive_range(\n                seed,\n                'a',\n                exhaustive_chars().nth(200).unwrap(),\n                1,\n                1,\n            )\n        },\n        7,\n        1,\n        &[\n            &['q', 'á', 'g'],\n            &['Á', 'À', 'È', '»', 'ì', '³', 'ą', 'â', 'g', 'Ã', 'ñ', 'Ā', 'ª', 'ä', '´', '½', 'Ï'],\n            &['ý', 'j', 'ï', 'Ñ', 'u', 'Â', '½'],\n            &['õ', 'x', 'Â', 'ù', '¡', 'Ċ', '¬'],\n            &['b', 'Ñ', '¬', 's'],\n            &['Â', 'r', 'n'],\n            &['¿', 'Þ', 'ô', 'Ø', 'º', 'ü', 't', '¬'],\n            &['j', 'Á', '±', 'è', 'k'],\n            &['æ', 'b', 'Î', 'ā', 'Ü', '¹', '«'],\n            &['Î', '~', '´'],\n            &['Ý', 'â', '¯', 'é', 'æ', 'Þ', 'ö', 'g', 'Î'],\n            &['Ç', 'Ü', '¼'],\n            &['¡', '§', 'Ì'],\n            &['±', 'd', 'ê', 'm', '®', 'ì', '¨', 'ý', 'þ', 'Ë', '{', 'Ü', 'z', '¼'],\n            &['ï', 'ă', 'Ą', 'û', 'ª', 'ċ', 'x', 'À', 'ì', 'Õ', '½'],\n            &['¢', '«', 'Ć'],\n            &['{', 'È', 'ÿ', '½', '¢', 'ä'],\n            &['Ë', 'Õ', 'ê'],\n            &['º', 'ü', '×', '¨', 'Å', 'p', '°', 'Ó'],\n            &['d', 'Ê', 'æ', 'ß', 'v', 'Ć', 'k', 'Ä', '±', 'È', '¥', 'o'],\n        ],\n        &[\n            (&['a', 'Ã', '¤'], 4),\n            (&['Ā', 'Ì', 'k'], 4),\n            (&['w', 'm', 'u'], 3),\n            (&['a', 'k', 'Ä'], 3),\n            (&['b', 'Ã', 'n'], 3),\n            (&['c', '|', 'Æ'], 3),\n            (&['d', 'm', 'ï'], 3),\n            (&['d', 'z', '¢'], 3),\n            (&['d', '¯', 't'], 3),\n            (&['f', 'g', '¹'], 3),\n        ],\n        (\n            &['Ç', 'Ĉ', 's', 'ò', 'c', '¿', 'Å', 'Ô', 'Æ'],\n            Some(&['Ç', 'Ĉ', 'v', '³', 'ò']),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_min_length_fail_1() {\n    random_unique_vecs_min_length(EXAMPLE_SEED, 3, &random_primitive_ints::<u32>, 3, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_min_length_fail_2() {\n    random_unique_vecs_min_length(EXAMPLE_SEED, 1, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_unique_vecs_min_length_fail_3() {\n    random_unique_vecs_min_length(\n        EXAMPLE_SEED,\n        0,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::tuples::random::random_units;\nuse malachite_base::vecs::random::random_vecs;\nuse std::fmt::Debug;\n\nfn random_vecs_helper<T: Clone + Debug + Eq + Hash + Ord, I: Clone + Iterator<Item = T>>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs(\n            EXAMPLE_SEED,\n            xs_gen,\n            mean_length_numerator,\n            mean_length_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs() {\n    random_vecs_helper(\n        &|_| random_units(),\n        4,\n        1,\n        &[\n            &[],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), ()],\n            &[(), (), (), ()],\n            &[()],\n            &[],\n            &[(), (), (), (), ()],\n            &[(), ()],\n            &[(), (), (), ()],\n            &[],\n            &[(), (), (), (), (), ()],\n            &[],\n            &[],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[],\n            &[(), (), ()],\n            &[],\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n        ],\n        &[\n            (&[], 199913),\n            (&[()], 160173),\n            (&[(), ()], 128173),\n            (&[(), (), ()], 102460),\n            (&[(), (), (), ()], 81463),\n            (&[(), (), (), (), ()], 65695),\n            (&[(), (), (), (), (), ()], 52495),\n            (&[(), (), (), (), (), (), ()], 41943),\n            (&[(), (), (), (), (), (), (), ()], 33396),\n            (&[(), (), (), (), (), (), (), (), ()], 27035),\n        ],\n        (&[(), (), ()], None),\n    );\n    random_vecs_helper(\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            &[],\n            &[85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32],\n            &[166, 234, 30, 218],\n            &[90, 106, 9, 216],\n            &[204],\n            &[],\n            &[151, 213, 97, 253, 78],\n            &[91, 39],\n            &[191, 175, 170, 232],\n            &[],\n            &[233, 2, 35, 22, 217, 198],\n            &[],\n            &[],\n            &[114, 17, 32, 173, 114, 65, 121, 222, 173, 25, 144],\n            &[148, 79, 115, 52, 73, 69, 137, 91],\n            &[],\n            &[153, 178, 112],\n            &[],\n            &[34, 95, 106, 167, 197],\n            &[130, 168, 122, 207, 172, 177, 86, 150, 221],\n        ],\n        &[\n            (&[], 199913),\n            (&[146], 693),\n            (&[26], 692),\n            (&[185], 688),\n            (&[58], 683),\n            (&[196], 683),\n            (&[81], 678),\n            (&[229], 675),\n            (&[192], 673),\n            (&[233], 673),\n        ],\n        (&[96], None),\n    );\n    random_vecs_helper(\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        4,\n        1,\n        &[\n            &[],\n            &[5, 0, 0, 1, 1, 1, 4, 2, 4, 6, 2, 2, 0, 1],\n            &[9, 13, 0, 0],\n            &[2, 0, 7, 4],\n            &[6],\n            &[],\n            &[7, 6, 0, 0, 0],\n            &[1, 3],\n            &[5, 1, 2, 1],\n            &[],\n            &[0, 0, 1, 4, 2, 0],\n            &[],\n            &[],\n            &[12, 0, 0, 2, 3, 1, 1, 1, 2, 3, 3],\n            &[9, 1, 0, 2, 1, 11, 1, 0],\n            &[],\n            &[1, 6, 0],\n            &[],\n            &[3, 18, 3, 3, 0],\n            &[5, 1, 2, 5, 0, 0, 2, 3, 1],\n        ],\n        &[\n            (&[], 199913),\n            (&[0], 53462),\n            (&[1], 35352),\n            (&[2], 23512),\n            (&[3], 16118),\n            (&[0, 0], 14371),\n            (&[4], 10594),\n            (&[0, 1], 9566),\n            (&[1, 0], 9409),\n            (&[5], 7157),\n        ],\n        (&[1], None),\n    );\n    random_vecs_helper(\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            &[],\n            &[],\n            &[85],\n            &[11],\n            &[136, 200],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[235, 134],\n            &[203],\n            &[],\n            &[223, 38],\n            &[],\n            &[],\n            &[],\n            &[],\n        ],\n        &[\n            (&[], 800023),\n            (&[8], 704),\n            (&[162], 691),\n            (&[81], 690),\n            (&[211], 690),\n            (&[108], 688),\n            (&[235], 688),\n            (&[35], 687),\n            (&[65], 682),\n            (&[208], 679),\n        ],\n        (&[], None),\n    );\n    random_vecs_helper(\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        4,\n        1,\n        &[\n            &[],\n            &['v', 'c', 'q', 'i', 'e', 'p', 'g', 's', 'n', 't', 'm', 'z', 'o', 'm'],\n            &['f', 'k', 'q', 'y'],\n            &['u', 'k', 'x', 'h'],\n            &['u'],\n            &[],\n            &['n', 'n', 'j', 'n', 'j'],\n            &['a', 'w'],\n            &['z', 'l', 'w', 'b'],\n            &[],\n            &['l', 'u', 'n', 'e', 'l', 'v'],\n            &[],\n            &[],\n            &['k', 'u', 'h', 'c', 'y', 'i', 'm', 'r', 'm', 'y', 's'],\n            &['l', 'e', 'a', 's', 'w', 'k', 'o', 'b'],\n            &[],\n            &['k', 'w', 'g'],\n            &[],\n            &['d', 'q', 'e', 'f', 'u'],\n            &['z', 'r', 'g', 'j', 'k', 'r', 's', 'y', 'n'],\n        ],\n        &[\n            (&[], 199913),\n            (&['o'], 6313),\n            (&['y'], 6262),\n            (&['q'], 6261),\n            (&['j'], 6245),\n            (&['p'], 6244),\n            (&['g'], 6219),\n            (&['x'], 6215),\n            (&['e'], 6200),\n            (&['t'], 6188),\n        ],\n        (&['j', 's', 'z'], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_fail_1() {\n    random_vecs(EXAMPLE_SEED, &random_primitive_ints::<u32>, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_fail_2() {\n    random_vecs(EXAMPLE_SEED, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_fail_3() {\n    random_vecs(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs_fixed_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::extra_variadic::random_vecs_length_3;\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::{random_primitive_ints, random_unsigned_range};\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::{random_vecs_fixed_length_from_single, random_vecs_length_2};\nuse std::fmt::Debug;\n\nfn random_vecs_length_2_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs_length_2(EXAMPLE_SEED, xs_gen, ys_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_length_2() {\n    random_vecs_length_2_helper(\n        &random_primitive_ints::<u8>,\n        &|seed| random_unsigned_range(seed, 0, 10),\n        &[\n            &[85, 2],\n            &[11, 6],\n            &[136, 8],\n            &[200, 6],\n            &[235, 8],\n            &[134, 2],\n            &[203, 4],\n            &[223, 1],\n            &[38, 2],\n            &[235, 7],\n            &[217, 5],\n            &[177, 4],\n            &[162, 8],\n            &[32, 8],\n            &[166, 4],\n            &[234, 4],\n            &[30, 3],\n            &[218, 5],\n            &[90, 6],\n            &[106, 7],\n        ],\n        &[\n            (&[196, 6], 466),\n            (&[162, 5], 457),\n            (&[132, 5], 455),\n            (&[200, 2], 455),\n            (&[61, 3], 454),\n            (&[117, 5], 453),\n            (&[28, 0], 446),\n            (&[148, 5], 446),\n            (&[194, 9], 446),\n            (&[44, 3], 444),\n        ],\n        (&[127, 9], None),\n    );\n    random_vecs_length_2_helper(\n        &|seed| random_vecs_fixed_length_from_single(2, random_primitive_ints::<u8>(seed)),\n        &|seed| random_vecs_fixed_length_from_single(3, random_primitive_ints::<u8>(seed)),\n        &[\n            &[vec![85, 11], vec![98, 168, 198]],\n            &[vec![136, 200], vec![40, 20, 252]],\n            &[vec![235, 134], vec![47, 87, 132]],\n            &[vec![203, 223], vec![72, 77, 63]],\n            &[vec![38, 235], vec![91, 108, 127]],\n            &[vec![217, 177], vec![53, 141, 84]],\n            &[vec![162, 32], vec![18, 10, 112]],\n            &[vec![166, 234], vec![154, 104, 53]],\n            &[vec![30, 218], vec![75, 238, 149]],\n            &[vec![90, 106], vec![190, 51, 147]],\n            &[vec![9, 216], vec![100, 114, 140]],\n            &[vec![204, 151], vec![2, 63, 189]],\n            &[vec![213, 97], vec![222, 67, 119]],\n            &[vec![253, 78], vec![0, 223, 5]],\n            &[vec![91, 39], vec![236, 232, 50]],\n            &[vec![191, 175], vec![44, 241, 21]],\n            &[vec![170, 232], vec![22, 94, 27]],\n            &[vec![233, 2], vec![128, 220, 25]],\n            &[vec![35, 22], vec![251, 243, 50]],\n            &[vec![217, 198], vec![137, 235, 46]],\n        ],\n        &[\n            (&[vec![0, 5], vec![6, 7, 42]], 1),\n            (&[vec![8, 8], vec![18, 5, 6]], 1),\n            (&[vec![9, 1], vec![5, 3, 23]], 1),\n            (&[vec![0, 0], vec![97, 7, 73]], 1),\n            (&[vec![0, 2], vec![12, 20, 6]], 1),\n            (&[vec![0, 99], vec![20, 8, 6]], 1),\n            (&[vec![1, 81], vec![3, 21, 3]], 1),\n            (&[vec![1, 9], vec![219, 9, 7]], 1),\n            (&[vec![1, 9], vec![4, 95, 15]], 1),\n            (&[vec![15, 2], vec![56, 0, 8]], 1),\n        ],\n        (\n            &[vec![127, 197], vec![162, 123, 217]],\n            Some(&[vec![127, 197], vec![163, 170, 161]]),\n        ),\n    );\n}\n\nfn random_vecs_length_3_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n    K: Clone + Iterator<Item = T>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    zs_gen: &dyn Fn(Seed) -> K,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs_length_3(EXAMPLE_SEED, xs_gen, ys_gen, zs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_length_3() {\n    random_vecs_length_3_helper(\n        &|seed| random_char_inclusive_range(seed, 'a', 'c'),\n        &|seed| random_char_inclusive_range(seed, 'd', 'f'),\n        &|seed| random_char_inclusive_range(seed, 'g', 'i'),\n        &[\n            &['b', 'f', 'g'],\n            &['b', 'd', 'i'],\n            &['b', 'f', 'i'],\n            &['b', 'e', 'i'],\n            &['c', 'd', 'i'],\n            &['a', 'f', 'i'],\n            &['a', 'f', 'g'],\n            &['a', 'f', 'g'],\n            &['c', 'f', 'i'],\n            &['a', 'e', 'i'],\n            &['c', 'd', 'h'],\n            &['a', 'd', 'h'],\n            &['c', 'f', 'i'],\n            &['a', 'f', 'i'],\n            &['c', 'd', 'g'],\n            &['c', 'd', 'h'],\n            &['c', 'e', 'g'],\n            &['b', 'e', 'h'],\n            &['a', 'd', 'g'],\n            &['c', 'd', 'g'],\n        ],\n        &[\n            (&['b', 'f', 'i'], 37416),\n            (&['a', 'f', 'g'], 37345),\n            (&['c', 'd', 'i'], 37278),\n            (&['b', 'f', 'g'], 37274),\n            (&['a', 'd', 'h'], 37207),\n            (&['b', 'f', 'h'], 37188),\n            (&['b', 'd', 'i'], 37153),\n            (&['b', 'e', 'g'], 37117),\n            (&['a', 'd', 'g'], 37092),\n            (&['c', 'f', 'g'], 37068),\n        ],\n        (&['b', 'e', 'h'], None),\n    );\n    random_vecs_length_3_helper(\n        &|seed| random_vecs_fixed_length_from_single(1, random_primitive_ints::<u8>(seed)),\n        &|seed| random_vecs_fixed_length_from_single(2, random_primitive_ints::<u8>(seed)),\n        &|seed| random_vecs_fixed_length_from_single(3, random_primitive_ints::<u8>(seed)),\n        &[\n            &[vec![85], vec![98, 168], vec![168, 10, 250]],\n            &[vec![11], vec![198, 40], vec![95, 250, 79]],\n            &[vec![136], vec![20, 252], vec![4, 171, 141]],\n            &[vec![200], vec![47, 87], vec![189, 177, 169]],\n            &[vec![235], vec![132, 72], vec![36, 73, 154]],\n            &[vec![134], vec![77, 63], vec![62, 202, 17]],\n            &[vec![203], vec![91, 108], vec![35, 189, 158]],\n            &[vec![223], vec![127, 53], vec![31, 173, 175]],\n            &[vec![38], vec![141, 84], vec![63, 225, 106]],\n            &[vec![235], vec![18, 10], vec![40, 116, 16]],\n            &[vec![217], vec![112, 154], vec![88, 112, 9]],\n            &[vec![177], vec![104, 53], vec![227, 144, 93]],\n            &[vec![162], vec![75, 238], vec![85, 90, 214]],\n            &[vec![32], vec![149, 190], vec![31, 60, 254]],\n            &[vec![166], vec![51, 147], vec![143, 44, 177]],\n            &[vec![234], vec![100, 114], vec![205, 197, 53]],\n            &[vec![30], vec![140, 2], vec![15, 184, 137]],\n            &[vec![218], vec![63, 189], vec![75, 116, 140]],\n            &[vec![90], vec![222, 67], vec![19, 119, 60]],\n            &[vec![106], vec![119, 0], vec![219, 21, 164]],\n        ],\n        &[\n            (&[vec![0], vec![47, 4], vec![31, 6, 1]], 1),\n            (&[vec![0], vec![5, 12], vec![9, 6, 54]], 1),\n            (&[vec![6], vec![99, 35], vec![3, 2, 3]], 1),\n            (&[vec![7], vec![7, 56], vec![6, 3, 76]], 1),\n            (&[vec![7], vec![9, 5], vec![148, 1, 1]], 1),\n            (&[vec![9], vec![61, 7], vec![9, 60, 8]], 1),\n            (&[vec![0], vec![0, 55], vec![1, 12, 83]], 1),\n            (&[vec![0], vec![1, 57], vec![60, 4, 55]], 1),\n            (&[vec![0], vec![1, 8], vec![235, 0, 27]], 1),\n            (&[vec![0], vec![73, 15], vec![0, 2, 11]], 1),\n        ],\n        (\n            &[vec![127], vec![241, 129], vec![232, 173, 11]],\n            Some(&[vec![127], vec![241, 149], vec![219, 172, 49]]),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs_fixed_length_from_single.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse itertools::{Itertools, repeat_n};\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_vecs_fixed_length_from_single;\nuse std::fmt::Debug;\n\nfn random_vecs_fixed_length_from_single_helper<I: Clone + Iterator>(\n    len: u64,\n    xs: I,\n    expected_values: &[&[I::Item]],\n    expected_common_values: &[(&[I::Item], usize)],\n    expected_median: (&[I::Item], Option<&[I::Item]>),\n) where\n    I::Item: Clone + Debug + Eq + Hash + Ord,\n{\n    random_vecs_helper_helper(\n        random_vecs_fixed_length_from_single(len, xs),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_fixed_length_from_single() {\n    random_vecs_fixed_length_from_single_helper(\n        0,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        repeat_n(&[][..], 20).collect_vec().as_slice(),\n        &[(&[], 1000000)],\n        (&[], None),\n    );\n    random_vecs_fixed_length_from_single_helper(\n        1,\n        random_bools(EXAMPLE_SEED),\n        &[\n            &[true],\n            &[false],\n            &[false],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[true],\n            &[true],\n            &[true],\n            &[false],\n            &[true],\n            &[false],\n        ],\n        &[(&[true], 500473), (&[false], 499527)],\n        (&[true], None),\n    );\n    random_vecs_fixed_length_from_single_helper(\n        3,\n        random_primitive_ints::<u8>(EXAMPLE_SEED),\n        &[\n            &[113, 239, 69],\n            &[108, 228, 210],\n            &[168, 161, 87],\n            &[32, 110, 83],\n            &[188, 34, 89],\n            &[238, 93, 200],\n            &[149, 115, 189],\n            &[149, 217, 201],\n            &[117, 146, 31],\n            &[72, 151, 169],\n            &[174, 33, 7],\n            &[38, 81, 144],\n            &[72, 127, 113],\n            &[128, 233, 107],\n            &[46, 119, 12],\n            &[18, 164, 243],\n            &[114, 174, 59],\n            &[247, 39, 174],\n            &[160, 184, 104],\n            &[37, 100, 252],\n        ],\n        &[\n            (&[222, 60, 79], 4),\n            (&[26, 110, 13], 4),\n            (&[41, 254, 55], 4),\n            (&[109, 134, 76], 4),\n            (&[165, 174, 73], 4),\n            (&[236, 57, 174], 4),\n            (&[73, 168, 192], 4),\n            (&[89, 197, 244], 4),\n            (&[91, 170, 115], 4),\n            (&[142, 168, 231], 4),\n        ],\n        (&[127, 253, 76], Some(&[127, 253, 86])),\n    );\n    random_vecs_fixed_length_from_single_helper(\n        2,\n        random_vecs_fixed_length_from_single(2, random_primitive_ints::<u8>(EXAMPLE_SEED)),\n        &[\n            &[vec![113, 239], vec![69, 108]],\n            &[vec![228, 210], vec![168, 161]],\n            &[vec![87, 32], vec![110, 83]],\n            &[vec![188, 34], vec![89, 238]],\n            &[vec![93, 200], vec![149, 115]],\n            &[vec![189, 149], vec![217, 201]],\n            &[vec![117, 146], vec![31, 72]],\n            &[vec![151, 169], vec![174, 33]],\n            &[vec![7, 38], vec![81, 144]],\n            &[vec![72, 127], vec![113, 128]],\n            &[vec![233, 107], vec![46, 119]],\n            &[vec![12, 18], vec![164, 243]],\n            &[vec![114, 174], vec![59, 247]],\n            &[vec![39, 174], vec![160, 184]],\n            &[vec![104, 37], vec![100, 252]],\n            &[vec![228, 122], vec![107, 69]],\n            &[vec![242, 248], vec![179, 142]],\n            &[vec![239, 233], vec![61, 189]],\n            &[vec![235, 85], vec![192, 7]],\n            &[vec![200, 90], vec![185, 178]],\n        ],\n        &[\n            (&[vec![28, 96], vec![0, 11]], 2),\n            (&[vec![2, 43], vec![64, 233]], 2),\n            (&[vec![20, 33], vec![14, 10]], 2),\n            (&[vec![223, 84], vec![7, 22]], 2),\n            (&[vec![43, 33], vec![131, 6]], 2),\n            (&[vec![6, 233], vec![45, 89]], 2),\n            (&[vec![65, 26], vec![6, 146]], 2),\n            (&[vec![71, 80], vec![68, 88]], 2),\n            (&[vec![9, 85], vec![186, 55]], 2),\n            (&[vec![96, 254], vec![9, 37]], 2),\n        ],\n        (\n            &[vec![127, 243], vec![125, 130]],\n            Some(&[vec![127, 243], vec![134, 100]]),\n        ),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs_fixed_length_m_inputs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::num::random::{random_primitive_ints, random_unsigned_range};\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::{\n    random_vecs_fixed_length_2_inputs, random_vecs_fixed_length_from_single,\n};\nuse std::fmt::Debug;\n\nfn random_vecs_fixed_length_2_inputs_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n    J: Clone + Iterator<Item = T>,\n>(\n    xs_gen: &dyn Fn(Seed) -> I,\n    ys_gen: &dyn Fn(Seed) -> J,\n    output_to_input_map: &[usize],\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs_fixed_length_2_inputs(EXAMPLE_SEED, xs_gen, ys_gen, output_to_input_map),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_fixed_length_2_inputs() {\n    random_vecs_fixed_length_2_inputs_helper(\n        &random_primitive_ints::<u8>,\n        &|seed| random_unsigned_range(seed, 0, 10),\n        &[0, 0, 1],\n        &[\n            &[85, 11, 2],\n            &[136, 200, 6],\n            &[235, 134, 8],\n            &[203, 223, 6],\n            &[38, 235, 8],\n            &[217, 177, 2],\n            &[162, 32, 4],\n            &[166, 234, 1],\n            &[30, 218, 2],\n            &[90, 106, 7],\n            &[9, 216, 5],\n            &[204, 151, 4],\n            &[213, 97, 8],\n            &[253, 78, 8],\n            &[91, 39, 4],\n            &[191, 175, 4],\n            &[170, 232, 3],\n            &[233, 2, 5],\n            &[35, 22, 6],\n            &[217, 198, 7],\n        ],\n        &[\n            (&[156, 162, 3], 11),\n            (&[248, 1, 7], 10),\n            (&[178, 121, 1], 10),\n            (&[36, 97, 6], 9),\n            (&[46, 27, 2], 9),\n            (&[64, 75, 6], 9),\n            (&[135, 80, 5], 9),\n            (&[215, 11, 3], 9),\n            (&[39, 178, 7], 9),\n            (&[75, 164, 6], 9),\n        ],\n        (&[127, 197, 7], None),\n    );\n    random_vecs_fixed_length_2_inputs_helper(\n        &|seed| random_vecs_fixed_length_from_single(2, random_primitive_ints::<u8>(seed)),\n        &|seed| random_vecs_fixed_length_from_single(3, random_primitive_ints::<u8>(seed)),\n        &[0, 1, 0],\n        &[\n            &[vec![85, 11], vec![98, 168, 198], vec![136, 200]],\n            &[vec![235, 134], vec![40, 20, 252], vec![203, 223]],\n            &[vec![38, 235], vec![47, 87, 132], vec![217, 177]],\n            &[vec![162, 32], vec![72, 77, 63], vec![166, 234]],\n            &[vec![30, 218], vec![91, 108, 127], vec![90, 106]],\n            &[vec![9, 216], vec![53, 141, 84], vec![204, 151]],\n            &[vec![213, 97], vec![18, 10, 112], vec![253, 78]],\n            &[vec![91, 39], vec![154, 104, 53], vec![191, 175]],\n            &[vec![170, 232], vec![75, 238, 149], vec![233, 2]],\n            &[vec![35, 22], vec![190, 51, 147], vec![217, 198]],\n            &[vec![114, 17], vec![100, 114, 140], vec![32, 173]],\n            &[vec![114, 65], vec![2, 63, 189], vec![121, 222]],\n            &[vec![173, 25], vec![222, 67, 119], vec![144, 148]],\n            &[vec![79, 115], vec![0, 223, 5], vec![52, 73]],\n            &[vec![69, 137], vec![236, 232, 50], vec![91, 153]],\n            &[vec![178, 112], vec![44, 241, 21], vec![34, 95]],\n            &[vec![106, 167], vec![22, 94, 27], vec![197, 130]],\n            &[vec![168, 122], vec![128, 220, 25], vec![207, 172]],\n            &[vec![177, 86], vec![251, 243, 50], vec![150, 221]],\n            &[vec![218, 101], vec![137, 235, 46], vec![115, 74]],\n        ],\n        &[\n            (&[vec![8, 24], vec![0, 54, 59], vec![5, 3]], 1),\n            (&[vec![8, 72], vec![6, 5, 9], vec![11, 57]], 1),\n            (&[vec![80, 9], vec![84, 9, 10], vec![9, 5]], 1),\n            (&[vec![86, 2], vec![2, 0, 27], vec![49, 4]], 1),\n            (&[vec![0, 2], vec![207, 31, 7], vec![92, 5]], 1),\n            (&[vec![1, 15], vec![51, 5, 47], vec![12, 5]], 1),\n            (&[vec![1, 25], vec![70, 65, 7], vec![3, 66]], 1),\n            (&[vec![1, 72], vec![8, 49, 246], vec![2, 1]], 1),\n            (&[vec![1, 82], vec![86, 3, 70], vec![6, 26]], 1),\n            (&[vec![1, 85], vec![3, 5, 53], vec![14, 92]], 1),\n        ],\n        (\n            &[vec![128, 20], vec![252, 3, 74], vec![108, 132]],\n            Some(&[vec![128, 21], vec![6, 87, 236], vec![223, 197]]),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_fixed_length_2_inputs_fail_1() {\n    random_vecs_fixed_length_2_inputs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_range::<u32>(seed, 0, 10),\n        &|seed| random_unsigned_range(seed, 0, 5),\n        &[],\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_fixed_length_2_inputs_fail_2() {\n    random_vecs_fixed_length_2_inputs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_range::<u32>(seed, 0, 10),\n        &|seed| random_unsigned_range(seed, 0, 5),\n        &[0],\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_fixed_length_2_inputs_fail_3() {\n    random_vecs_fixed_length_2_inputs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_range::<u32>(seed, 0, 10),\n        &|seed| random_unsigned_range(seed, 0, 5),\n        &[1],\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_fixed_length_2_inputs_fail_4() {\n    random_vecs_fixed_length_2_inputs(\n        EXAMPLE_SEED,\n        &|seed| random_unsigned_range::<u32>(seed, 0, 10),\n        &|seed| random_unsigned_range(seed, 0, 5),\n        &[0, 1, 2],\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs_from_length_iterator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::vecs::random::random_vecs_from_length_iterator;\nuse malachite_base::vecs::random_values_from_vec;\nuse std::fmt::Debug;\n\nfn random_vecs_from_length_iterator_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = u64>,\n    J: Clone + Iterator<Item = T>,\n>(\n    lengths_gen: &dyn Fn(Seed) -> I,\n    xs_gen: &dyn Fn(Seed) -> J,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs_from_length_iterator(EXAMPLE_SEED, lengths_gen, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_from_length_iterator() {\n    random_vecs_from_length_iterator_helper(\n        &|seed| random_values_from_vec(seed, vec![0, 2, 4]),\n        &random_bools,\n        &[\n            &[true, false],\n            &[true, false, true, false],\n            &[true, false],\n            &[true, true, false, true],\n            &[false, false, false, false],\n            &[false, false],\n            &[],\n            &[false, true],\n            &[],\n            &[false, false, false, true],\n            &[false, false, false, true],\n            &[false, false],\n            &[true, true, true, true],\n            &[false, true],\n            &[false, true, true, true],\n            &[false, true, true, false],\n            &[false, false, false, true],\n            &[],\n            &[true, true, false, true],\n            &[],\n        ],\n        &[\n            (&[], 333820),\n            (&[true, false], 83553),\n            (&[false, false], 83348),\n            (&[false, true], 83319),\n            (&[true, true], 82905),\n            (&[true, true, true, false], 21126),\n            (&[false, false, false, true], 20940),\n            (&[false, false, true, false], 20931),\n            (&[true, true, false, true], 20925),\n            (&[true, false, false, false], 20899),\n        ],\n        (&[false, false, true, true], None),\n    );\n    random_vecs_from_length_iterator_helper(\n        &|seed| geometric_random_unsigneds::<u64>(seed, 2, 1).map(|x| x << 1),\n        &random_primitive_ints::<u8>,\n        &[\n            &[85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177],\n            &[162, 32],\n            &[166, 234, 30, 218, 90, 106, 9, 216, 204, 151, 213, 97, 253, 78, 91, 39],\n            &[191, 175],\n            &[\n                170, 232, 233, 2, 35, 22, 217, 198, 114, 17, 32, 173, 114, 65, 121, 222, 173, 25,\n                144, 148, 79, 115, 52, 73, 69, 137, 91, 153,\n            ],\n            &[],\n            &[178, 112, 34, 95, 106, 167, 197, 130, 168, 122],\n            &[207, 172, 177, 86, 150, 221, 218, 101],\n            &[115, 74],\n            &[],\n            &[9, 123, 109, 52, 201, 159, 247, 250, 48, 133, 235, 196],\n            &[40, 97, 104, 68],\n            &[],\n            &[],\n            &[190, 216],\n            &[7, 216, 157, 43, 43, 112],\n            &[],\n            &[217, 24],\n            &[],\n            &[11, 103],\n        ],\n        &[\n            (&[], 333981),\n            (&[198, 47], 13),\n            (&[203, 121], 13),\n            (&[77, 29], 12),\n            (&[97, 58], 12),\n            (&[174, 43], 12),\n            (&[80, 107], 12),\n            (&[100, 118], 12),\n            (&[176, 218], 12),\n            (&[203, 110], 12),\n        ],\n        (&[63, 135], None),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs_length_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::tuples::random::random_units;\nuse malachite_base::vecs::random::random_vecs_length_inclusive_range;\nuse std::fmt::Debug;\n\nfn random_vecs_length_inclusive_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs_length_inclusive_range(EXAMPLE_SEED, a, b, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_length_inclusive_range() {\n    random_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &|_| random_units(),\n        &[\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), ()],\n        ],\n        &[(&[(), (), ()], 500363), (&[(), ()], 499637)],\n        (&[(), (), ()], None),\n    );\n    random_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &random_primitive_ints::<u8>,\n        &[\n            &[85, 11, 136],\n            &[200, 235],\n            &[134, 203, 223],\n            &[38, 235, 217],\n            &[177, 162],\n            &[32, 166, 234],\n            &[30, 218, 90],\n            &[106, 9],\n            &[216, 204, 151],\n            &[213, 97, 253],\n            &[78, 91],\n            &[39, 191, 175],\n            &[170, 232],\n            &[233, 2, 35],\n            &[22, 217, 198],\n            &[114, 17],\n            &[32, 173],\n            &[114, 65],\n            &[121, 222, 173],\n            &[25, 144],\n        ],\n        &[\n            (&[234, 192], 23),\n            (&[0, 40], 19),\n            (&[68, 88], 19),\n            (&[188, 21], 19),\n            (&[215, 22], 19),\n            (&[221, 92], 19),\n            (&[255, 26], 19),\n            (&[34, 253], 19),\n            (&[61, 159], 19),\n            (&[155, 140], 19),\n        ],\n        (&[128, 5, 208], Some(&[128, 5, 239])),\n    );\n    random_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            &[5, 0, 0],\n            &[1, 1],\n            &[1, 4, 2],\n            &[4, 6, 2],\n            &[2, 0],\n            &[1, 9, 13],\n            &[0, 0, 2],\n            &[0, 7],\n            &[4, 6, 7],\n            &[6, 0, 0],\n            &[0, 1],\n            &[3, 5, 1],\n            &[2, 1],\n            &[0, 0, 1],\n            &[4, 2, 0],\n            &[12, 0],\n            &[0, 2],\n            &[3, 1],\n            &[1, 1, 2],\n            &[3, 3],\n        ],\n        &[\n            (&[0, 0], 55357),\n            (&[0, 1], 37179),\n            (&[1, 0], 37106),\n            (&[0, 2], 24784),\n            (&[2, 0], 24772),\n            (&[1, 1], 24686),\n            (&[0, 0, 0], 18703),\n            (&[3, 0], 16656),\n            (&[2, 1], 16622),\n            (&[1, 2], 16275),\n        ],\n        (&[1, 3], None),\n    );\n    random_vecs_length_inclusive_range_helper(\n        2,\n        3,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            &['v', 'c', 'q'],\n            &['i', 'e'],\n            &['p', 'g', 's'],\n            &['n', 't', 'm'],\n            &['z', 'o'],\n            &['m', 'f', 'k'],\n            &['q', 'y', 'u'],\n            &['k', 'x'],\n            &['h', 'u', 'n'],\n            &['n', 'j', 'n'],\n            &['j', 'a'],\n            &['w', 'z', 'l'],\n            &['w', 'b'],\n            &['l', 'u', 'n'],\n            &['e', 'l', 'v'],\n            &['k', 'u'],\n            &['h', 'c'],\n            &['y', 'i'],\n            &['m', 'r', 'm'],\n            &['y', 's'],\n        ],\n        &[\n            (&['w', 'o'], 822),\n            (&['f', 's'], 814),\n            (&['w', 'u'], 810),\n            (&['g', 'c'], 806),\n            (&['w', 'f'], 806),\n            (&['m', 'z'], 805),\n            (&['q', 'k'], 805),\n            (&['i', 'b'], 802),\n            (&['u', 'k'], 800),\n            (&['h', 'p'], 798),\n        ],\n        (&['m', 'z', 'w'], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_length_inclusive_range_fail() {\n    random_vecs_length_inclusive_range(EXAMPLE_SEED, 2, 1, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs_length_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::tuples::random::random_units;\nuse malachite_base::vecs::random::random_vecs_length_range;\nuse std::fmt::Debug;\n\nfn random_vecs_length_range_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    a: u64,\n    b: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs_length_range(EXAMPLE_SEED, a, b, xs_gen),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_length_range() {\n    random_vecs_length_range_helper(\n        2,\n        4,\n        &|_| random_units(),\n        &[\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), ()],\n            &[(), ()],\n            &[(), ()],\n            &[(), (), ()],\n            &[(), ()],\n        ],\n        &[(&[(), (), ()], 500363), (&[(), ()], 499637)],\n        (&[(), (), ()], None),\n    );\n    random_vecs_length_range_helper(\n        2,\n        4,\n        &random_primitive_ints::<u8>,\n        &[\n            &[85, 11, 136],\n            &[200, 235],\n            &[134, 203, 223],\n            &[38, 235, 217],\n            &[177, 162],\n            &[32, 166, 234],\n            &[30, 218, 90],\n            &[106, 9],\n            &[216, 204, 151],\n            &[213, 97, 253],\n            &[78, 91],\n            &[39, 191, 175],\n            &[170, 232],\n            &[233, 2, 35],\n            &[22, 217, 198],\n            &[114, 17],\n            &[32, 173],\n            &[114, 65],\n            &[121, 222, 173],\n            &[25, 144],\n        ],\n        &[\n            (&[234, 192], 23),\n            (&[0, 40], 19),\n            (&[68, 88], 19),\n            (&[188, 21], 19),\n            (&[215, 22], 19),\n            (&[221, 92], 19),\n            (&[255, 26], 19),\n            (&[34, 253], 19),\n            (&[61, 159], 19),\n            (&[155, 140], 19),\n        ],\n        (&[128, 5, 208], Some(&[128, 5, 239])),\n    );\n    random_vecs_length_range_helper(\n        2,\n        4,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        &[\n            &[5, 0, 0],\n            &[1, 1],\n            &[1, 4, 2],\n            &[4, 6, 2],\n            &[2, 0],\n            &[1, 9, 13],\n            &[0, 0, 2],\n            &[0, 7],\n            &[4, 6, 7],\n            &[6, 0, 0],\n            &[0, 1],\n            &[3, 5, 1],\n            &[2, 1],\n            &[0, 0, 1],\n            &[4, 2, 0],\n            &[12, 0],\n            &[0, 2],\n            &[3, 1],\n            &[1, 1, 2],\n            &[3, 3],\n        ],\n        &[\n            (&[0, 0], 55357),\n            (&[0, 1], 37179),\n            (&[1, 0], 37106),\n            (&[0, 2], 24784),\n            (&[2, 0], 24772),\n            (&[1, 1], 24686),\n            (&[0, 0, 0], 18703),\n            (&[3, 0], 16656),\n            (&[2, 1], 16622),\n            (&[1, 2], 16275),\n        ],\n        (&[1, 3], None),\n    );\n    random_vecs_length_range_helper(\n        2,\n        4,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        &[\n            &['v', 'c', 'q'],\n            &['i', 'e'],\n            &['p', 'g', 's'],\n            &['n', 't', 'm'],\n            &['z', 'o'],\n            &['m', 'f', 'k'],\n            &['q', 'y', 'u'],\n            &['k', 'x'],\n            &['h', 'u', 'n'],\n            &['n', 'j', 'n'],\n            &['j', 'a'],\n            &['w', 'z', 'l'],\n            &['w', 'b'],\n            &['l', 'u', 'n'],\n            &['e', 'l', 'v'],\n            &['k', 'u'],\n            &['h', 'c'],\n            &['y', 'i'],\n            &['m', 'r', 'm'],\n            &['y', 's'],\n        ],\n        &[\n            (&['w', 'o'], 822),\n            (&['f', 's'], 814),\n            (&['w', 'u'], 810),\n            (&['g', 'c'], 806),\n            (&['w', 'f'], 806),\n            (&['m', 'z'], 805),\n            (&['q', 'k'], 805),\n            (&['i', 'b'], 802),\n            (&['u', 'k'], 800),\n            (&['h', 'p'], 798),\n        ],\n        (&['m', 'z', 'w'], None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_length_range_fail() {\n    random_vecs_length_range(EXAMPLE_SEED, 2, 2, &random_primitive_ints::<u32>);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random/random_vecs_min_length.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::hash::Hash;\nuse malachite_base::chars::random::random_char_inclusive_range;\nuse malachite_base::num::random::geometric::geometric_random_unsigneds;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::test_util::vecs::random::random_vecs_helper_helper;\nuse malachite_base::tuples::random::random_units;\nuse malachite_base::vecs::random::random_vecs_min_length;\nuse std::fmt::Debug;\n\nfn random_vecs_min_length_helper<\n    T: Clone + Debug + Eq + Hash + Ord,\n    I: Clone + Iterator<Item = T>,\n>(\n    min_length: u64,\n    xs_gen: &dyn Fn(Seed) -> I,\n    mean_length_numerator: u64,\n    mean_length_denominator: u64,\n    expected_values: &[&[T]],\n    expected_common_values: &[(&[T], usize)],\n    expected_median: (&[T], Option<&[T]>),\n) {\n    random_vecs_helper_helper(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            min_length,\n            xs_gen,\n            mean_length_numerator,\n            mean_length_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_median,\n    );\n}\n\n#[test]\nfn test_random_vecs_min_length() {\n    random_vecs_min_length_helper(\n        0,\n        &|_| random_units(),\n        4,\n        1,\n        &[\n            &[],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), ()],\n            &[(), (), (), ()],\n            &[()],\n            &[],\n            &[(), (), (), (), ()],\n            &[(), ()],\n            &[(), (), (), ()],\n            &[],\n            &[(), (), (), (), (), ()],\n            &[],\n            &[],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[],\n            &[(), (), ()],\n            &[],\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n        ],\n        &[\n            (&[], 199913),\n            (&[()], 160173),\n            (&[(), ()], 128173),\n            (&[(), (), ()], 102460),\n            (&[(), (), (), ()], 81463),\n            (&[(), (), (), (), ()], 65695),\n            (&[(), (), (), (), (), ()], 52495),\n            (&[(), (), (), (), (), (), ()], 41943),\n            (&[(), (), (), (), (), (), (), ()], 33396),\n            (&[(), (), (), (), (), (), (), (), ()], 27035),\n        ],\n        (&[(), (), ()], None),\n    );\n    random_vecs_min_length_helper(\n        3,\n        &|_| random_units(),\n        7,\n        1,\n        &[\n            &[(), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), (), ()],\n            &[(), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), ()],\n            &[(), (), (), (), (), (), ()],\n            &[(), (), ()],\n            &[(), (), (), (), (), (), (), (), ()],\n            &[(), (), ()],\n            &[(), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), ()],\n            &[(), (), ()],\n            &[(), (), (), (), (), ()],\n            &[(), (), ()],\n            &[(), (), (), (), (), (), (), ()],\n            &[(), (), (), (), (), (), (), (), (), (), (), ()],\n        ],\n        &[\n            (&[(), (), ()], 199913),\n            (&[(), (), (), ()], 160173),\n            (&[(), (), (), (), ()], 128173),\n            (&[(), (), (), (), (), ()], 102460),\n            (&[(), (), (), (), (), (), ()], 81463),\n            (&[(), (), (), (), (), (), (), ()], 65695),\n            (&[(), (), (), (), (), (), (), (), ()], 52495),\n            (&[(), (), (), (), (), (), (), (), (), ()], 41943),\n            (&[(), (), (), (), (), (), (), (), (), (), ()], 33396),\n            (&[(), (), (), (), (), (), (), (), (), (), (), ()], 27035),\n        ],\n        (&[(), (), (), (), (), ()], None),\n    );\n    random_vecs_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        4,\n        1,\n        &[\n            &[],\n            &[85, 11, 136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32],\n            &[166, 234, 30, 218],\n            &[90, 106, 9, 216],\n            &[204],\n            &[],\n            &[151, 213, 97, 253, 78],\n            &[91, 39],\n            &[191, 175, 170, 232],\n            &[],\n            &[233, 2, 35, 22, 217, 198],\n            &[],\n            &[],\n            &[114, 17, 32, 173, 114, 65, 121, 222, 173, 25, 144],\n            &[148, 79, 115, 52, 73, 69, 137, 91],\n            &[],\n            &[153, 178, 112],\n            &[],\n            &[34, 95, 106, 167, 197],\n            &[130, 168, 122, 207, 172, 177, 86, 150, 221],\n        ],\n        &[\n            (&[], 199913),\n            (&[146], 693),\n            (&[26], 692),\n            (&[185], 688),\n            (&[58], 683),\n            (&[196], 683),\n            (&[81], 678),\n            (&[229], 675),\n            (&[192], 673),\n            (&[233], 673),\n        ],\n        (&[96], None),\n    );\n    random_vecs_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        7,\n        1,\n        &[\n            &[85, 11, 136],\n            &[200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32, 166, 234, 30, 218, 90, 106],\n            &[9, 216, 204, 151, 213, 97, 253],\n            &[78, 91, 39, 191, 175, 170, 232],\n            &[233, 2, 35, 22],\n            &[217, 198, 114],\n            &[17, 32, 173, 114, 65, 121, 222, 173],\n            &[25, 144, 148, 79, 115],\n            &[52, 73, 69, 137, 91, 153, 178],\n            &[112, 34, 95],\n            &[106, 167, 197, 130, 168, 122, 207, 172, 177],\n            &[86, 150, 221],\n            &[218, 101, 115],\n            &[74, 9, 123, 109, 52, 201, 159, 247, 250, 48, 133, 235, 196, 40],\n            &[97, 104, 68, 190, 216, 7, 216, 157, 43, 43, 112],\n            &[217, 24, 11],\n            &[103, 211, 84, 135, 55, 29],\n            &[206, 89, 65],\n            &[191, 51, 9, 79, 148, 34, 22, 22],\n            &[62, 3, 114, 118, 20, 47, 194, 50, 32, 120, 176, 166],\n        ],\n        &[\n            (&[65, 71, 68], 3),\n            (&[34, 39, 234], 3),\n            (&[207, 218, 62], 3),\n            (&[89, 175, 228], 3),\n            (&[198, 166, 242], 3),\n            (&[2, 94, 4], 2),\n            (&[3, 91, 9], 2),\n            (&[6, 3, 61], 2),\n            (&[0, 18, 20], 2),\n            (&[1, 48, 93], 2),\n        ],\n        (&[128, 11, 100, 4, 101, 167, 125], Some(&[128, 11, 104])),\n    );\n    random_vecs_min_length_helper(\n        0,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        4,\n        1,\n        &[\n            &[],\n            &[5, 0, 0, 1, 1, 1, 4, 2, 4, 6, 2, 2, 0, 1],\n            &[9, 13, 0, 0],\n            &[2, 0, 7, 4],\n            &[6],\n            &[],\n            &[7, 6, 0, 0, 0],\n            &[1, 3],\n            &[5, 1, 2, 1],\n            &[],\n            &[0, 0, 1, 4, 2, 0],\n            &[],\n            &[],\n            &[12, 0, 0, 2, 3, 1, 1, 1, 2, 3, 3],\n            &[9, 1, 0, 2, 1, 11, 1, 0],\n            &[],\n            &[1, 6, 0],\n            &[],\n            &[3, 18, 3, 3, 0],\n            &[5, 1, 2, 5, 0, 0, 2, 3, 1],\n        ],\n        &[\n            (&[], 199913),\n            (&[0], 53462),\n            (&[1], 35352),\n            (&[2], 23512),\n            (&[3], 16118),\n            (&[0, 0], 14371),\n            (&[4], 10594),\n            (&[0, 1], 9566),\n            (&[1, 0], 9409),\n            (&[5], 7157),\n        ],\n        (&[1], None),\n    );\n    random_vecs_min_length_helper(\n        3,\n        &|seed| geometric_random_unsigneds::<u32>(seed, 2, 1),\n        7,\n        1,\n        &[\n            &[5, 0, 0],\n            &[1, 1, 1, 4, 2, 4, 6, 2, 2, 0, 1, 9, 13, 0, 0, 2, 0],\n            &[7, 4, 6, 7, 6, 0, 0],\n            &[0, 1, 3, 5, 1, 2, 1],\n            &[0, 0, 1, 4],\n            &[2, 0, 12],\n            &[0, 0, 2, 3, 1, 1, 1, 2],\n            &[3, 3, 9, 1, 0],\n            &[2, 1, 11, 1, 0, 1, 6],\n            &[0, 3, 18],\n            &[3, 3, 0, 5, 1, 2, 5, 0, 0],\n            &[2, 3, 1],\n            &[0, 2, 1],\n            &[2, 3, 1, 3, 3, 0, 0, 7, 2, 0, 0, 4, 2, 1],\n            &[0, 3, 1, 4, 2, 2, 1, 5, 0, 2, 0],\n            &[2, 0, 0],\n            &[1, 4, 1, 3, 3, 1],\n            &[0, 0, 0],\n            &[1, 4, 2, 1, 1, 0, 1, 0],\n            &[0, 0, 1, 0, 2, 0, 7, 0, 0, 0, 2, 12],\n        ],\n        &[\n            (&[0, 0, 0], 7500),\n            (&[1, 0, 0], 5048),\n            (&[0, 0, 1], 4956),\n            (&[0, 1, 0], 4876),\n            (&[0, 0, 2], 3336),\n            (&[0, 2, 0], 3320),\n            (&[1, 1, 0], 3305),\n            (&[2, 0, 0], 3303),\n            (&[0, 1, 1], 3242),\n            (&[1, 0, 1], 3239),\n        ],\n        (\n            &[1, 3, 1, 1, 4, 0, 2, 3],\n            Some(&[1, 3, 1, 1, 4, 0, 4, 0, 0]),\n        ),\n    );\n    random_vecs_min_length_helper(\n        0,\n        &random_primitive_ints::<u8>,\n        1,\n        4,\n        &[\n            &[],\n            &[],\n            &[85],\n            &[11],\n            &[136, 200],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[],\n            &[235, 134],\n            &[203],\n            &[],\n            &[223, 38],\n            &[],\n            &[],\n            &[],\n            &[],\n        ],\n        &[\n            (&[], 800023),\n            (&[8], 704),\n            (&[162], 691),\n            (&[81], 690),\n            (&[211], 690),\n            (&[108], 688),\n            (&[235], 688),\n            (&[35], 687),\n            (&[65], 682),\n            (&[208], 679),\n        ],\n        (&[], None),\n    );\n    random_vecs_min_length_helper(\n        3,\n        &random_primitive_ints::<u8>,\n        13,\n        4,\n        &[\n            &[85, 11, 136],\n            &[200, 235, 134],\n            &[203, 223, 38, 235],\n            &[217, 177, 162, 32],\n            &[166, 234, 30, 218, 90],\n            &[106, 9, 216],\n            &[204, 151, 213],\n            &[97, 253, 78],\n            &[91, 39, 191],\n            &[175, 170, 232],\n            &[233, 2, 35],\n            &[22, 217, 198],\n            &[114, 17, 32, 173, 114],\n            &[65, 121, 222, 173],\n            &[25, 144, 148],\n            &[79, 115, 52, 73, 69],\n            &[137, 91, 153],\n            &[178, 112, 34],\n            &[95, 106, 167],\n            &[197, 130, 168],\n        ],\n        &[\n            (&[34, 248, 94], 4),\n            (&[155, 89, 108], 4),\n            (&[232, 167, 146], 4),\n            (&[255, 244, 186], 4),\n            (&[0, 70, 96], 3),\n            (&[18, 1, 93], 3),\n            (&[30, 0, 90], 3),\n            (&[50, 3, 37], 3),\n            (&[82, 1, 99], 3),\n            (&[9, 42, 49], 3),\n        ],\n        (&[127, 228, 182], Some(&[127, 228, 193])),\n    );\n    random_vecs_min_length_helper(\n        0,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        4,\n        1,\n        &[\n            &[],\n            &['v', 'c', 'q', 'i', 'e', 'p', 'g', 's', 'n', 't', 'm', 'z', 'o', 'm'],\n            &['f', 'k', 'q', 'y'],\n            &['u', 'k', 'x', 'h'],\n            &['u'],\n            &[],\n            &['n', 'n', 'j', 'n', 'j'],\n            &['a', 'w'],\n            &['z', 'l', 'w', 'b'],\n            &[],\n            &['l', 'u', 'n', 'e', 'l', 'v'],\n            &[],\n            &[],\n            &['k', 'u', 'h', 'c', 'y', 'i', 'm', 'r', 'm', 'y', 's'],\n            &['l', 'e', 'a', 's', 'w', 'k', 'o', 'b'],\n            &[],\n            &['k', 'w', 'g'],\n            &[],\n            &['d', 'q', 'e', 'f', 'u'],\n            &['z', 'r', 'g', 'j', 'k', 'r', 's', 'y', 'n'],\n        ],\n        &[\n            (&[], 199913),\n            (&['o'], 6313),\n            (&['y'], 6262),\n            (&['q'], 6261),\n            (&['j'], 6245),\n            (&['p'], 6244),\n            (&['g'], 6219),\n            (&['x'], 6215),\n            (&['e'], 6200),\n            (&['t'], 6188),\n        ],\n        (&['j', 's', 'z'], None),\n    );\n    random_vecs_min_length_helper(\n        3,\n        &|seed| random_char_inclusive_range(seed, 'a', 'z'),\n        7,\n        1,\n        &[\n            &['v', 'c', 'q'],\n            &['i', 'e', 'p', 'g', 's', 'n', 't', 'm', 'z', 'o', 'm', 'f', 'k', 'q', 'y', 'u', 'k'],\n            &['x', 'h', 'u', 'n', 'n', 'j', 'n'],\n            &['j', 'a', 'w', 'z', 'l', 'w', 'b'],\n            &['l', 'u', 'n', 'e'],\n            &['l', 'v', 'k'],\n            &['u', 'h', 'c', 'y', 'i', 'm', 'r', 'm'],\n            &['y', 's', 'l', 'e', 'a'],\n            &['s', 'w', 'k', 'o', 'b', 'k', 'w'],\n            &['g', 'd', 'q'],\n            &['e', 'f', 'u', 'z', 'r', 'g', 'j', 'k', 'r'],\n            &['s', 'y', 'n'],\n            &['f', 't', 's'],\n            &['f', 'e', 's', 'p', 'j', 'n', 'h', 'n', 'r', 'f', 'i', 'u', 'k', 'p'],\n            &['p', 'g', 'l', 'd', 'l', 'l', 'z', 's', 'w', 'w', 'l'],\n            &['w', 'z', 'j'],\n            &['j', 'j', 'y', 'g', 'e', 'z'],\n            &['v', 'p', 'y'],\n            &['u', 'q', 'l', 'h', 'r', 'r', 's', 'q'],\n            &['b', 'n', 'e', 's', 'p', 'r', 'd', 'a', 'k', 'w', 'c', 'y'],\n        ],\n        &[\n            (&['b', 'c', 'j'], 25),\n            (&['e', 'k', 'd'], 25),\n            (&['a', 'x', 'n'], 24),\n            (&['b', 'e', 'z'], 24),\n            (&['c', 'c', 'b'], 24),\n            (&['d', 'g', 'h'], 24),\n            (&['g', 'l', 'i'], 24),\n            (&['i', 'w', 'n'], 24),\n            (&['j', 'd', 'w'], 24),\n            (&['m', 'y', 'a'], 24),\n        ],\n        (\n            &['m', 'z', 'z', 'r', 'e', 'r'],\n            Some(&['m', 'z', 'z', 'r', 'g', 'i']),\n        ),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_min_length_fail_1() {\n    random_vecs_min_length(EXAMPLE_SEED, 3, &random_primitive_ints::<u32>, 3, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_min_length_fail_2() {\n    random_vecs_min_length(EXAMPLE_SEED, 1, &random_primitive_ints::<u32>, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_vecs_min_length_fail_3() {\n    random_vecs_min_length(\n        EXAMPLE_SEED,\n        0,\n        &random_primitive_ints::<u32>,\n        u64::MAX,\n        u64::MAX - 1,\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random_values_from_vec.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::nevers::Never;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map_debug;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::vecs::random_values_from_vec;\n\n#[test]\nfn test_random_values_from_vec() {\n    let test = |vec: Vec<u32>,\n                values: &[u32],\n                common_values: &[(u32, usize)],\n                actual_median: (u32, Option<u32>)| {\n        let xs = random_values_from_vec(EXAMPLE_SEED, vec);\n        let expected_values = xs.clone().take(20).collect_vec();\n        let expected_common_values = common_values_map_debug(1000000, 10, xs.clone());\n        let expected_median = median(xs.take(1000000));\n        assert_eq!(\n            (\n                expected_values.as_slice(),\n                expected_common_values.as_slice(),\n                expected_median\n            ),\n            (values, common_values, actual_median)\n        );\n    };\n    test(vec![5], &[5; 20], &[(5, 1000000)], (5, None));\n    test(\n        vec![0, 1],\n        &[1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0],\n        &[(1, 500473), (0, 499527)],\n        (1, None),\n    );\n    test(\n        vec![1, 1, 1, 10],\n        &[1, 1, 10, 1, 10, 10, 1, 10, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 10],\n        &[(1, 749985), (10, 250015)],\n        (1, None),\n    );\n    test(\n        vec![2, 3, 5, 7, 11],\n        &[3, 7, 3, 5, 11, 3, 5, 11, 2, 2, 5, 5, 2, 11, 2, 11, 5, 11, 5, 3],\n        &[(2, 200420), (7, 200369), (11, 200347), (5, 199589), (3, 199275)],\n        (5, None),\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_values_from_vec_fail() {\n    random_values_from_vec::<Never>(EXAMPLE_SEED, vec![]);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/random_vec_permutations.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::vecs::random_vec_permutations;\n\nfn random_vec_permutations_helper(\n    cs: &str,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n) {\n    let ss = random_vec_permutations(EXAMPLE_SEED, cs.chars().collect_vec())\n        .map(|ds| ds.into_iter().collect());\n    let values = ss.clone().take(20).collect_vec();\n    let common_values = common_values_map(1000000, 10, ss.clone());\n    let (median_lo, median_hi) = median(ss.take(1000000));\n    assert_eq!(\n        (\n            values.iter().map(String::as_str).collect_vec().as_slice(),\n            common_values\n                .iter()\n                .map(|(s, f)| (s.as_str(), *f))\n                .collect_vec()\n                .as_slice(),\n            (median_lo.as_str(), median_hi.as_deref())\n        ),\n        (expected_values, expected_common_values, expected_median)\n    );\n}\n\n#[test]\nfn test_random_vec_permutations() {\n    random_vec_permutations_helper(\"\", &[\"\"; 20], &[(\"\", 1000000)], (\"\", None));\n    random_vec_permutations_helper(\"a\", &[\"a\"; 20], &[(\"a\", 1000000)], (\"a\", None));\n    random_vec_permutations_helper(\n        \"ab\",\n        &[\n            \"ba\", \"ab\", \"ab\", \"ab\", \"ab\", \"ba\", \"ba\", \"ba\", \"ba\", \"ab\", \"ba\", \"ab\", \"ab\", \"ba\",\n            \"ab\", \"ab\", \"ba\", \"ab\", \"ba\", \"ab\",\n        ],\n        &[(\"ba\", 500291), (\"ab\", 499709)],\n        (\"ba\", None),\n    );\n    random_vec_permutations_helper(\n        \"abc\",\n        &[\n            \"bac\", \"cba\", \"cba\", \"cba\", \"cba\", \"acb\", \"acb\", \"bca\", \"acb\", \"bac\", \"abc\", \"bac\",\n            \"bac\", \"acb\", \"cba\", \"abc\", \"bca\", \"cab\", \"acb\", \"bac\",\n        ],\n        &[\n            (\"abc\", 167957),\n            (\"bac\", 167073),\n            (\"cba\", 166362),\n            (\"acb\", 166331),\n            (\"cab\", 166166),\n            (\"bca\", 166111),\n        ],\n        (\"bac\", None),\n    );\n    random_vec_permutations_helper(\n        \"abcd\",\n        &[\n            \"dacb\", \"cbad\", \"cdab\", \"cbad\", \"cdab\", \"bcda\", \"bcda\", \"acbd\", \"bcda\", \"dbca\", \"bdac\",\n            \"dbac\", \"dbca\", \"bcad\", \"cadb\", \"dacb\", \"acbd\", \"dbac\", \"bdca\", \"abdc\",\n        ],\n        &[\n            (\"dbca\", 41992),\n            (\"bcda\", 41855),\n            (\"cdab\", 41827),\n            (\"dcab\", 41818),\n            (\"abcd\", 41809),\n            (\"badc\", 41804),\n            (\"cadb\", 41803),\n            (\"adbc\", 41763),\n            (\"cbad\", 41706),\n            (\"dbac\", 41697),\n        ],\n        (\"bdca\", None),\n    );\n    random_vec_permutations_helper(\n        \"abcdefghij\",\n        &[\n            \"daiehfcbjg\",\n            \"bhagejicdf\",\n            \"fdaibchgje\",\n            \"bicdfhgaej\",\n            \"bdfihjagec\",\n            \"chdjbafeig\",\n            \"cgajbfdieh\",\n            \"jecbhafgid\",\n            \"aedjgchfbi\",\n            \"hacjiefdgb\",\n            \"ahgdfcbije\",\n            \"cibdehfjag\",\n            \"fgdebchjai\",\n            \"gieajbdfch\",\n            \"deagfjihcb\",\n            \"hjfgdbacie\",\n            \"jdghacbfie\",\n            \"cebaihjfdg\",\n            \"jgdbchfeai\",\n            \"cjahbegdif\",\n        ],\n        &[\n            (\"afdhbciejg\", 5),\n            (\"afegijbcdh\", 5),\n            (\"afgcedhjbi\", 5),\n            (\"agbijhcfde\", 5),\n            (\"ahejcigbfd\", 5),\n            (\"ahjcgfdebi\", 5),\n            (\"aihecgdfbj\", 5),\n            (\"ajfghdcbei\", 5),\n            (\"badicjhgfe\", 5),\n            (\"bfdacehijg\", 5),\n        ],\n        (\"ejicadfgbh\", Some(\"ejicadgbfh\")),\n    );\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/vec_delete_left.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_vec_gen, unsigned_vec_unsigned_pair_gen_var_1,\n};\nuse malachite_base::vecs::vec_delete_left;\n\n#[test]\nfn test_vec_delete_left() {\n    let test = |xs: &[u32], delete_size: usize, out: &[u32]| {\n        let mut mut_xs = xs.to_vec();\n        vec_delete_left(&mut mut_xs, delete_size);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[], 0, &[]);\n    test(&[1, 2, 3, 4, 5], 0, &[1, 2, 3, 4, 5]);\n    test(&[1, 2, 3, 4, 5], 3, &[4, 5]);\n    test(&[1, 2, 3, 4, 5], 5, &[]);\n}\n\n#[test]\n#[should_panic]\nfn vec_delete_left_fail_1() {\n    let mut xs: Vec<u32> = Vec::new();\n    vec_delete_left(&mut xs, 1);\n}\n\n#[test]\n#[should_panic]\nfn vec_delete_left_fail_2() {\n    let mut xs: Vec<u32> = vec![1, 2, 3];\n    vec_delete_left(&mut xs, 4);\n}\n\n#[test]\nfn vec_delete_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_unsigned_pair_gen_var_1::<u8>().test_properties_with_config(\n        &config,\n        |(mut xs, amount)| {\n            let old_xs = xs.clone();\n            vec_delete_left(&mut xs, amount);\n            assert_eq!(xs == old_xs, amount == 0);\n            assert_eq!(xs.is_empty(), amount == old_xs.len());\n            assert_eq!(xs.len(), old_xs.len() - amount);\n            assert_eq!(&old_xs[amount..], xs);\n        },\n    );\n\n    unsigned_vec_gen::<u8>().test_properties_with_config(&config, |mut xs| {\n        let old_xs = xs.clone();\n        vec_delete_left(&mut xs, old_xs.len());\n        assert!(xs.is_empty());\n\n        let mut xs = old_xs.clone();\n        vec_delete_left(&mut xs, 0);\n        assert_eq!(xs, old_xs);\n    });\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/vec_from_str.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::nevers::Never;\nuse malachite_base::options::option_from_str;\nuse malachite_base::orderings::ordering_from_str;\nuse malachite_base::vecs::{vec_from_str, vec_from_str_custom};\nuse std::cmp::Ordering::*;\nuse std::fmt::Debug;\nuse std::str::FromStr;\n\n#[allow(clippy::needless_pass_by_value)]\nfn vec_from_str_helper<T: Debug + Eq + FromStr>(s: &str, out: Option<Vec<T>>) {\n    assert_eq!(vec_from_str(s), out);\n}\n\n#[test]\nfn test_vec_from_str() {\n    vec_from_str_helper::<Never>(\"[]\", Some(vec![]));\n    vec_from_str_helper::<u32>(\"[5]\", Some(vec![5]));\n    vec_from_str_helper::<u32>(\"[5, 6, 7]\", Some(vec![5, 6, 7]));\n    vec_from_str_helper::<bool>(\"[false, false, true]\", Some(vec![false, false, true]));\n    vec_from_str_helper::<String>(\"[a, b]\", Some(vec![\"a\".to_string(), \"b\".to_string()]));\n    vec_from_str_helper::<String>(\"[a,  b]\", Some(vec![\"a\".to_string(), \" b\".to_string()]));\n    vec_from_str_helper::<String>(\"[a , b]\", Some(vec![\"a \".to_string(), \"b\".to_string()]));\n    vec_from_str_helper::<String>(\"[a,, b]\", Some(vec![\"a,\".to_string(), \"b\".to_string()]));\n    vec_from_str_helper::<String>(\"[a ,,b]\", Some(vec![\"a ,,b\".to_string()]));\n    vec_from_str_helper::<String>(\"[a,b]\", Some(vec![\"a,b\".to_string()]));\n    vec_from_str_helper::<bool>(\"[\", None);\n    vec_from_str_helper::<bool>(\"\", None);\n    vec_from_str_helper::<bool>(\"abc\", None);\n    vec_from_str_helper::<bool>(\"[false, false, true\", None);\n    vec_from_str_helper::<bool>(\"[false, false,  true]\", None);\n    vec_from_str_helper::<bool>(\"[false, false, true,]\", None);\n    vec_from_str_helper::<bool>(\"[false, false, true] \", None);\n    vec_from_str_helper::<bool>(\"[false, false, true ]\", None);\n    vec_from_str_helper::<bool>(\"[false, false, rue]\", None);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn vec_from_str_custom_helper<T: Debug + Eq>(\n    f: &dyn Fn(&str) -> Option<T>,\n    s: &str,\n    out: Option<Vec<T>>,\n) {\n    assert_eq!(vec_from_str_custom(f, s), out);\n}\n\n#[test]\nfn test_vec_from_str_custom() {\n    vec_from_str_custom_helper(\n        &ordering_from_str,\n        \"[Less, Greater]\",\n        Some(vec![Less, Greater]),\n    );\n    vec_from_str_custom_helper(\n        &option_from_str,\n        \"[Some(false), None]\",\n        Some(vec![Some(false), None]),\n    );\n    vec_from_str_custom_helper(\n        &vec_from_str,\n        \"[[], [3], [2, 5]]\",\n        Some(vec![vec![], vec![3], vec![2, 5]]),\n    );\n    vec_from_str_custom_helper(&option_from_str::<bool>, \"[Some(fals), None]\", None);\n    vec_from_str_custom_helper(&vec_from_str::<u32>, \"[[], [3], [2, 5,]]\", None);\n    vec_from_str_custom_helper(&vec_from_str::<u32>, \"[[], 3, [2, 5]]\", None);\n    vec_from_str_custom_helper(&vec_from_str::<u32>, \"[[], [3], [true]]\", None);\n}\n"
  },
  {
    "path": "malachite-base/tests/vecs/vec_pad_left.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_1,\n};\nuse malachite_base::vecs::{vec_delete_left, vec_pad_left};\n\n#[test]\nfn test_vec_pad_left() {\n    let test = |xs: &[u32], pad_size: usize, pad_value: u32, out: &[u32]| {\n        let mut mut_xs = xs.to_vec();\n        vec_pad_left(&mut mut_xs, pad_size, pad_value);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[], 3, 6, &[6, 6, 6]);\n    test(&[1, 2, 3], 0, 10, &[1, 2, 3]);\n    test(&[1, 2, 3], 5, 10, &[10, 10, 10, 10, 10, 1, 2, 3]);\n}\n\n#[test]\nfn vec_pad_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    config.insert(\"mean_stripe_n\", 16 << u8::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    config.insert(\"small_unsigned_length_n\", 32);\n    config.insert(\"small_unsigned_length_d\", 1);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_1::<u8, usize, u8>().test_properties_with_config(\n        &config,\n        |(mut xs, pad_size, pad_value)| {\n            let old_xs = xs.clone();\n            vec_pad_left(&mut xs, pad_size, pad_value);\n            assert_eq!(xs == old_xs, pad_size == 0);\n            assert_eq!(xs.len(), old_xs.len() + pad_size);\n            assert!(xs[..pad_size].iter().all(|&x| x == pad_value));\n            assert_eq!(&xs[pad_size..], old_xs);\n            vec_delete_left(&mut xs, pad_size);\n            assert_eq!(xs, old_xs);\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen::<u8, u8>().test_properties_with_config(\n        &config,\n        |(mut xs, pad_value)| {\n            let old_xs = xs.clone();\n            vec_pad_left(&mut xs, 0, pad_value);\n            assert_eq!(xs, old_xs);\n        },\n    );\n\n    unsigned_pair_gen_var_2::<u8, usize>().test_properties_with_config(\n        &config,\n        |(pad_value, pad_size)| {\n            let mut xs = Vec::new();\n            vec_pad_left(&mut xs, pad_size, pad_value);\n            assert_eq!(xs, vec![pad_value; pad_size]);\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-bigint/Cargo.toml",
    "content": "[package]\nname = \"malachite-bigint\"\nversion = \"0.9.1\"\nauthors = [\"Steve Shi <shikangzhi@gmail.com>\"]\nrust-version.workspace = true\nedition.workspace = true\nlicense = \"LGPL-3.0-only\"\ndescription = \"A drop-in num-bigint replacement based on malachite\"\nrepository = \"https://github.com/mhogrefe/malachite\"\n\n[dependencies]\nmalachite-base = { version = \"0.9.1\", path = \"../malachite-base\", default-features = false }\nmalachite-nz = { version = \"0.9.1\", path = \"../malachite-nz\", default-features = false }\n\nnum-traits = { version = \"0.2.19\", default-features = false, features = [\"i128\"] }\nnum-integer = { version = \"0.1.46\", default-features = false, features = [\"i128\"] }\npaste = \"1.0.15\"\nnum-bigint = { version = \"0.4\", default-features = false, optional = true }\n\n[dev-dependencies]\nnum-bigint = \"0.4\"\n\n[features]\ndefault = [\"std\"]\nstd = [\"malachite-base/std\", \"malachite-nz/std\"]\n"
  },
  {
    "path": "malachite-bigint/README.md",
    "content": "# malachite-bigint\n\nA drop-in replacement for rust [num-bigint](https://github.com/rust-num/num-bigint) based on [malachite](https://github.com/mhogrefe/malachite) `Natural`.\n\nThis is not an official malachite project. Please directly use malachite unless you need num-bigint compatibility.\n\n# Performance\n\nSee https://github.com/tczajka/bigint-benchmark-rs\n\n# Acknowledgement\n\n`malachite-bigint` was created by [Steve Shi](https://github.com/qingshi163) to provide an alternative bigint implementation for [RustPython](https://github.com/RustPython/RustPython.git).\n\nThis project is contributed to the malachite project and will be integrated to malachite 0.5.0.\n"
  },
  {
    "path": "malachite-bigint/src/bigint.rs",
    "content": "// Copyright © 2026 Steve Shi\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse alloc::string::String;\nuse alloc::vec::Vec;\nuse core::{\n    cmp::Ordering,\n    fmt::Debug,\n    iter::{Product, Sum},\n    ops::{\n        Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div,\n        DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,\n        SubAssign,\n    },\n    str::FromStr,\n};\nuse malachite_base::{\n    num::{\n        arithmetic::traits::{\n            Abs, DivRem, DivRound, DivisibleBy, FloorRoot, Mod, Parity, UnsignedAbs,\n        },\n        conversion::traits::{RoundingInto, ToStringBase},\n        logic::traits::BitAccess,\n    },\n    rounding_modes::RoundingMode,\n};\nuse malachite_nz::integer::Integer;\nuse num_integer::Roots;\nuse num_traits::{\n    CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Num, One, Pow, Signed,\n    ToPrimitive, Zero,\n};\nuse paste::paste;\n\nuse crate::{\n    BigUint, ParseBigIntError,\n    Sign::{Minus, NoSign, Plus},\n    ToBigUint, TryFromBigIntError, U32Digits, U64Digits,\n};\n\npub trait ToBigInt {\n    fn to_bigint(&self) -> Option<BigInt>;\n}\n\napply_to_primitives!(impl_primitive_convert{BigInt, _});\nimpl_primitive_convert!(BigInt, f32);\nimpl_primitive_convert!(BigInt, f64);\n\n#[derive(PartialEq, PartialOrd, Eq, Ord, Copy, Clone, Debug, Hash)]\npub enum Sign {\n    Minus,\n    NoSign,\n    Plus,\n}\n\nimpl Neg for Sign {\n    type Output = Self;\n\n    #[inline]\n    fn neg(self) -> Self::Output {\n        match self {\n            Minus => Plus,\n            NoSign => NoSign,\n            Plus => Minus,\n        }\n    }\n}\n\n#[repr(transparent)]\n#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]\npub struct BigInt(Integer);\n\napply_to_primitives!(forward_from{BigInt, _});\napply_to_primitives!(forward_try_into{BigInt, _});\n\nimpl_from!(BigInt, Integer);\n\nforward_unary_op!(BigInt, Not, not);\nforward_unary_op!(BigInt, Neg, neg);\n\nforward_binary_self!(BigInt, Add, add);\nforward_binary_self!(BigInt, Sub, sub);\nforward_binary_self!(BigInt, Mul, mul);\nforward_binary_self!(BigInt, Div, div);\nforward_binary_self!(BigInt, Rem, rem);\nforward_binary_self!(BigInt, BitAnd, bitand);\nforward_binary_self!(BigInt, BitOr, bitor);\nforward_binary_self!(BigInt, BitXor, bitxor);\n\nforward_assign_self!(BigInt, AddAssign, add_assign);\nforward_assign_self!(BigInt, SubAssign, sub_assign);\nforward_assign_self!(BigInt, MulAssign, mul_assign);\nforward_assign_self!(BigInt, DivAssign, div_assign);\nforward_assign_self!(BigInt, RemAssign, rem_assign);\nforward_assign_self!(BigInt, BitAndAssign, bitand_assign);\nforward_assign_self!(BigInt, BitOrAssign, bitor_assign);\nforward_assign_self!(BigInt, BitXorAssign, bitxor_assign);\n\nforward_pow_biguint!(BigInt);\n\napply_to_primitives!(forward_binary_right_primitive_into{BigInt, _, Add, add});\napply_to_primitives!(forward_binary_right_primitive_into{BigInt, _, Sub, sub});\napply_to_primitives!(forward_binary_right_primitive_into{BigInt, _, Mul, mul});\napply_to_primitives!(forward_binary_right_primitive_into{BigInt, _, Div, div});\napply_to_primitives!(forward_binary_right_primitive_into{BigInt, _, Rem, rem});\n\napply_to_primitives!(forward_binary_left_primitive_into{_, BigInt, Add, add});\napply_to_primitives!(forward_binary_left_primitive_into{_, BigInt, Sub, sub});\napply_to_primitives!(forward_binary_left_primitive_into{_, BigInt, Mul, mul});\napply_to_primitives!(forward_binary_left_primitive_into{_, BigInt, Div, div});\napply_to_primitives!(forward_binary_left_primitive_into{_, BigInt, Rem, rem});\n\napply_to_primitives!(forward_binary_right_primitive{BigInt, _, Shl, shl});\napply_to_primitives!(forward_binary_right_primitive{BigInt, _, Shr, shr});\n\napply_to_primitives!(forward_assign_primitive_into{BigInt, _, AddAssign, add_assign});\napply_to_primitives!(forward_assign_primitive_into{BigInt, _, SubAssign, sub_assign});\napply_to_primitives!(forward_assign_primitive_into{BigInt, _, MulAssign, mul_assign});\napply_to_primitives!(forward_assign_primitive_into{BigInt, _, DivAssign, div_assign});\napply_to_primitives!(forward_assign_primitive_into{BigInt, _, RemAssign, rem_assign});\n\napply_to_primitives!(forward_assign_primitive{BigInt, _, ShlAssign, shl_assign});\napply_to_primitives!(forward_assign_primitive{BigInt, _, ShrAssign, shr_assign});\n\napply_to_unsigneds!(forward_pow_primitive{BigInt, _});\n\nimpl_product_iter_type!(BigInt);\nimpl_sum_iter_type!(BigInt);\n\nforward_fmt!(BigInt, Debug, Display, Binary, Octal, LowerHex, UpperHex);\n\nimpl CheckedAdd for BigInt {\n    #[inline]\n    fn checked_add(&self, v: &Self) -> Option<Self> {\n        Some(self.add(v))\n    }\n}\n\nimpl CheckedSub for BigInt {\n    #[inline]\n    fn checked_sub(&self, v: &Self) -> Option<Self> {\n        Some(self.sub(v))\n    }\n}\n\nimpl CheckedMul for BigInt {\n    #[inline]\n    fn checked_mul(&self, v: &Self) -> Option<Self> {\n        Some(self.mul(v))\n    }\n}\n\nimpl CheckedDiv for BigInt {\n    #[inline]\n    fn checked_div(&self, v: &Self) -> Option<Self> {\n        (!v.is_zero()).then(|| self.div(v))\n    }\n}\n\nimpl ToBigInt for BigInt {\n    #[inline]\n    fn to_bigint(&self) -> Option<BigInt> {\n        Some(self.clone())\n    }\n}\n\nimpl ToBigUint for BigInt {\n    #[inline]\n    fn to_biguint(&self) -> Option<BigUint> {\n        (!self.is_negative()).then(|| self.magnitude().clone())\n    }\n}\n\nimpl ToPrimitive for BigInt {\n    apply_to_primitives!(impl_to_primitive_fn_try_into{_});\n    impl_to_primitive_fn_float!(f32);\n    impl_to_primitive_fn_float!(f64);\n}\n\nimpl FromPrimitive for BigInt {\n    apply_to_primitives!(impl_from_primitive_fn_infallible{_});\n    impl_from_primitive_fn_float!(f32);\n    impl_from_primitive_fn_float!(f64);\n}\n\nimpl From<BigUint> for BigInt {\n    #[inline]\n    fn from(value: BigUint) -> Self {\n        Integer::from(value.0).into()\n    }\n}\n\nimpl Zero for BigInt {\n    #[inline]\n    fn zero() -> Self {\n        Self(<Integer as malachite_base::num::basic::traits::Zero>::ZERO)\n    }\n\n    #[inline]\n    fn is_zero(&self) -> bool {\n        self.sign() == NoSign\n    }\n}\n\nimpl One for BigInt {\n    #[inline]\n    fn one() -> Self {\n        Self(<Integer as malachite_base::num::basic::traits::One>::ONE)\n    }\n}\n\nimpl Signed for BigInt {\n    #[inline]\n    fn abs(&self) -> Self {\n        (&self.0).abs().into()\n    }\n\n    #[inline]\n    fn abs_sub(&self, other: &Self) -> Self {\n        if self <= other {\n            Self::zero()\n        } else {\n            self - other\n        }\n    }\n\n    #[inline]\n    fn signum(&self) -> Self {\n        match self.sign() {\n            Minus => -Self::one(),\n            NoSign => Self::zero(),\n            Plus => Self::one(),\n        }\n    }\n\n    #[inline]\n    fn is_positive(&self) -> bool {\n        self.sign() == Plus\n    }\n\n    #[inline]\n    fn is_negative(&self) -> bool {\n        self.sign() == Minus\n    }\n}\n\nimpl Num for BigInt {\n    type FromStrRadixErr = ParseBigIntError;\n\n    #[inline]\n    fn from_str_radix(mut s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr> {\n        let sign = if s.starts_with('-') {\n            let tail = &s[1..];\n            if !tail.starts_with('+') {\n                s = tail;\n            }\n            Minus\n        } else {\n            Plus\n        };\n        let u = BigUint::from_str_radix(s, radix)?;\n        Ok(Self::from_biguint(sign, u))\n    }\n}\n\nimpl num_integer::Integer for BigInt {\n    #[inline]\n    fn div_floor(&self, other: &Self) -> Self {\n        (&self.0).div_round(&other.0, RoundingMode::Floor).0.into()\n    }\n\n    #[inline]\n    fn mod_floor(&self, other: &Self) -> Self {\n        (&self.0).mod_op(&other.0).into()\n    }\n\n    #[inline]\n    fn gcd(&self, other: &Self) -> Self {\n        self.magnitude().gcd(other.magnitude()).into()\n    }\n\n    #[inline]\n    fn lcm(&self, other: &Self) -> Self {\n        self.magnitude().lcm(other.magnitude()).into()\n    }\n\n    #[inline]\n    fn divides(&self, other: &Self) -> bool {\n        Self::is_multiple_of(self, other)\n    }\n\n    #[inline]\n    fn is_multiple_of(&self, other: &Self) -> bool {\n        (&self.0).divisible_by(&other.0)\n    }\n\n    #[inline]\n    fn is_even(&self) -> bool {\n        self.0.even()\n    }\n\n    #[inline]\n    fn is_odd(&self) -> bool {\n        self.0.odd()\n    }\n\n    #[inline]\n    fn div_rem(&self, other: &Self) -> (Self, Self) {\n        let (div, rem) = (&self.0).div_rem(&other.0);\n        (div.into(), rem.into())\n    }\n}\n\nimpl Roots for BigInt {\n    #[inline]\n    fn nth_root(&self, n: u32) -> Self {\n        (&self.0).floor_root(u64::from(n)).into()\n    }\n}\n\nimpl FromStr for BigInt {\n    type Err = ParseBigIntError;\n\n    #[inline]\n    fn from_str(s: &str) -> Result<Self, Self::Err> {\n        Self::from_str_radix(s, 10)\n    }\n}\n\nimpl BigInt {\n    #[inline]\n    pub fn new(sign: Sign, digits: Vec<u32>) -> Self {\n        Self::from_biguint(sign, BigUint::new(digits))\n    }\n\n    #[inline]\n    pub fn from_biguint(sign: Sign, mut abs: BigUint) -> Self {\n        if sign == NoSign {\n            abs = BigUint::zero();\n        }\n\n        Integer::from_sign_and_abs(sign != Minus, abs.0).into()\n    }\n\n    #[inline]\n    pub fn from_slice(sign: Sign, slice: &[u32]) -> Self {\n        Self::from_biguint(sign, BigUint::from_slice(slice))\n    }\n\n    #[inline]\n    pub fn assign_from_slice(&mut self, sign: Sign, slice: &[u32]) {\n        if sign == NoSign {\n            self.set_zero();\n        } else {\n            *self = Self::from_slice(sign, slice);\n        }\n    }\n\n    #[inline]\n    pub fn from_bytes_be(sign: Sign, bytes: &[u8]) -> Self {\n        Self::from_biguint(sign, BigUint::from_bytes_be(bytes))\n    }\n\n    #[inline]\n    pub fn from_bytes_le(sign: Sign, bytes: &[u8]) -> Self {\n        Self::from_biguint(sign, BigUint::from_bytes_le(bytes))\n    }\n\n    #[inline]\n    pub fn from_signed_bytes_be(digits: &[u8]) -> Self {\n        let is_negative = match digits.first().copied() {\n            Some(x) => x > 0x7f,\n            None => return Self::zero(),\n        };\n\n        if is_negative {\n            let mut v = Vec::from(digits);\n            twos_complement_be(&mut v);\n            let u = BigUint::from_bytes_be(v.as_slice());\n            Self::from_biguint(Minus, u)\n        } else {\n            let u = BigUint::from_bytes_be(digits);\n            Self::from_biguint(Plus, u)\n        }\n    }\n\n    #[inline]\n    pub fn from_signed_bytes_le(digits: &[u8]) -> Self {\n        let is_negative = match digits.last().copied() {\n            Some(x) => x > 0x7f,\n            None => return Self::zero(),\n        };\n\n        if is_negative {\n            let mut v = Vec::from(digits);\n            twos_complement_le(&mut v);\n            let u = BigUint::from_bytes_le(v.as_slice());\n            Self::from_biguint(Minus, u)\n        } else {\n            let u = BigUint::from_bytes_le(digits);\n            Self::from_biguint(Plus, u)\n        }\n    }\n\n    #[inline]\n    pub fn parse_bytes(bytes: &[u8], radix: u32) -> Option<Self> {\n        let s = core::str::from_utf8(bytes).ok()?;\n        Self::from_str_radix(s, radix).ok()\n    }\n\n    #[inline]\n    pub fn from_radix_be(sign: Sign, buf: &[u8], radix: u32) -> Option<Self> {\n        BigUint::from_radix_be(buf, radix).map(|u| Self::from_biguint(sign, u))\n    }\n\n    #[inline]\n    pub fn from_radix_le(sign: Sign, buf: &[u8], radix: u32) -> Option<Self> {\n        BigUint::from_radix_le(buf, radix).map(|u| Self::from_biguint(sign, u))\n    }\n\n    #[inline]\n    pub fn to_bytes_be(&self) -> (Sign, Vec<u8>) {\n        (self.sign(), self.magnitude().to_bytes_be())\n    }\n\n    #[inline]\n    pub fn to_bytes_le(&self) -> (Sign, Vec<u8>) {\n        (self.sign(), self.magnitude().to_bytes_le())\n    }\n\n    #[inline]\n    pub fn to_u32_digits(&self) -> (Sign, Vec<u32>) {\n        (self.sign(), self.magnitude().to_u32_digits())\n    }\n\n    #[inline]\n    pub fn to_u64_digits(&self) -> (Sign, Vec<u64>) {\n        (self.sign(), self.magnitude().to_u64_digits())\n    }\n\n    #[inline]\n    pub fn iter_u32_digits(&self) -> U32Digits<'_> {\n        self.magnitude().iter_u32_digits()\n    }\n\n    #[inline]\n    pub fn iter_u64_digits(&self) -> U64Digits<'_> {\n        self.magnitude().iter_u64_digits()\n    }\n\n    #[inline]\n    pub fn to_signed_bytes_be(&self) -> Vec<u8> {\n        let mut bytes = self.magnitude().to_bytes_be();\n        let first_byte = bytes.first().copied().unwrap_or(0);\n        let is_negative = self.is_negative();\n        if first_byte > 0x7f\n            && !(first_byte == 0x80 && bytes.iter().skip(1).all(Zero::is_zero) && is_negative)\n        {\n            // msb used by magnitude, extend by 1 byte\n            bytes.insert(0, 0);\n        }\n        if self.is_negative() {\n            twos_complement_be(&mut bytes);\n        }\n        bytes\n    }\n\n    #[inline]\n    pub fn to_signed_bytes_le(&self) -> Vec<u8> {\n        let mut bytes = self.magnitude().to_bytes_le();\n        let is_negative = self.is_negative();\n        let last_byte = bytes.last().copied().unwrap_or(0);\n        if last_byte > 0x7f\n            && !(last_byte == 0x80 && bytes.iter().rev().skip(1).all(Zero::is_zero) && is_negative)\n        {\n            // msb used by magnitude, extend by 1 byte\n            bytes.push(0);\n        }\n        if self.is_negative() {\n            twos_complement_le(&mut bytes);\n        }\n        bytes\n    }\n\n    #[inline]\n    pub fn to_str_radix(&self, radix: u32) -> String {\n        self.0.to_string_base(radix as u8)\n    }\n\n    #[inline]\n    pub fn to_radix_be(&self, radix: u32) -> (Sign, Vec<u8>) {\n        (self.sign(), self.magnitude().to_radix_be(radix))\n    }\n\n    #[inline]\n    pub fn to_radix_le(&self, radix: u32) -> (Sign, Vec<u8>) {\n        (self.sign(), self.magnitude().to_radix_le(radix))\n    }\n\n    #[inline]\n    pub fn sign(&self) -> Sign {\n        match <_ as malachite_base::num::arithmetic::traits::Sign>::sign(&self.0) {\n            Ordering::Less => Minus,\n            Ordering::Equal => NoSign,\n            Ordering::Greater => Plus,\n        }\n    }\n\n    #[inline]\n    pub fn magnitude(&self) -> &BigUint {\n        unsafe { core::mem::transmute(self.0.unsigned_abs_ref()) }\n    }\n\n    #[inline]\n    pub fn into_parts(self) -> (Sign, BigUint) {\n        (self.sign(), self.0.unsigned_abs().into())\n    }\n\n    #[inline]\n    pub fn bits(&self) -> u64 {\n        self.magnitude().bits()\n    }\n\n    #[inline]\n    pub fn to_biguint(&self) -> Option<BigUint> {\n        match self.sign() {\n            Plus => Some(self.magnitude().clone()),\n            NoSign => Some(BigUint::zero()),\n            Minus => None,\n        }\n    }\n\n    #[inline]\n    pub fn checked_add(&self, v: &Self) -> Option<Self> {\n        Some(self + v)\n    }\n\n    #[inline]\n    pub fn checked_sub(&self, v: &Self) -> Option<Self> {\n        Some(self - v)\n    }\n\n    #[inline]\n    pub fn checked_mul(&self, v: &Self) -> Option<Self> {\n        Some(self * v)\n    }\n\n    #[inline]\n    pub fn checked_div(&self, v: &Self) -> Option<Self> {\n        if v.is_zero() {\n            return None;\n        }\n        Some(self / v)\n    }\n\n    #[inline]\n    pub fn pow(&self, exponent: u32) -> Self {\n        Pow::pow(self, exponent)\n    }\n\n    #[inline]\n    pub fn modpow(&self, exponent: &Self, modulus: &Self) -> Self {\n        assert!(\n            !exponent.is_negative(),\n            \"negative exponentiation is not supported!\"\n        );\n        assert!(\n            !modulus.is_zero(),\n            \"attempt to calculate with zero modulus!\"\n        );\n\n        let mut abs = self\n            .magnitude()\n            .modpow(exponent.magnitude(), modulus.magnitude());\n\n        if abs.is_zero() {\n            return Self::zero();\n        }\n\n        if (self.is_negative() && exponent.0.odd()) != modulus.is_negative() {\n            abs = modulus.magnitude() - abs;\n        }\n\n        Self::from_biguint(modulus.sign(), abs)\n    }\n\n    #[inline]\n    pub fn sqrt(&self) -> Self {\n        Roots::sqrt(self)\n    }\n\n    #[inline]\n    pub fn cbrt(&self) -> Self {\n        Roots::cbrt(self)\n    }\n\n    #[inline]\n    pub fn nth_root(&self, n: u32) -> Self {\n        Roots::nth_root(self, n)\n    }\n\n    #[inline]\n    pub fn trailing_zeros(&self) -> Option<u64> {\n        self.magnitude().trailing_zeros()\n    }\n\n    #[inline]\n    pub fn bit(&self, bit: u64) -> bool {\n        self.0.get_bit(bit)\n    }\n\n    #[inline]\n    pub fn set_bit(&mut self, bit: u64, value: bool) {\n        if value {\n            self.0.set_bit(bit);\n        } else {\n            self.0.clear_bit(bit);\n        }\n    }\n}\n/// Perform in-place two's complement of the given binary representation, in little-endian byte\n/// order.\n#[inline]\nfn twos_complement_le(digits: &mut [u8]) {\n    twos_complement(digits);\n}\n\n/// Perform in-place two's complement of the given binary representation in big-endian byte order.\n#[inline]\nfn twos_complement_be(digits: &mut [u8]) {\n    twos_complement(digits.iter_mut().rev());\n}\n\n/// Perform in-place two's complement of the given digit iterator starting from the least\n/// significant byte.\n#[inline]\nfn twos_complement<'a, I>(digits: I)\nwhere\n    I: IntoIterator<Item = &'a mut u8>,\n{\n    let mut carry = true;\n    for d in digits {\n        *d = !*d;\n        if carry {\n            *d = d.wrapping_add(1);\n            carry = d.is_zero();\n        }\n    }\n}\n\n#[cfg(test)]\nmod test {\n    use super::*;\n    use alloc::{format, string::ToString};\n\n    #[test]\n    fn test_float_convert_nearest() {\n        let n25 = \"10000000000000000000000000\";\n        let val = BigInt::from_str(n25).unwrap();\n        let f = val.to_f64().unwrap();\n        assert_eq!(f.to_string(), n25);\n    }\n\n    #[test]\n    fn test_to_f64() {\n        use num_traits::ToPrimitive as NumToPrimitive;\n\n        let test_cases = [\n            \"123456789012345678901234567890\",\n            \"999999999999999999999999999999\",\n            \"170141183460469231731687303715884105727\",\n            \"340282366920938463463374607431768211455\",\n            \"12345678901234567890123456789012345678901234567890\",\n            \"-123456789012345678901234567890\",\n            \"-999999999999999999999999999999\",\n            \"-170141183460469231731687303715884105728\",\n            \"-12345678901234567890123456789012345678901234567890\",\n            \"1208925819614629174706176\",\n            \"1329227995784915872903807060280344576\",\n            \"-1208925819614629174706176\",\n            \"-1329227995784915872903807060280344576\",\n            // Overflow cases\n            \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            99999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            99999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            9999999999999999999999999999999999999999999999999999\",\n            \"-999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            99999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            99999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            99999999999999999999999999999999999999999999999999999\",\n        ];\n\n        for test_str in &test_cases {\n            let malachite_val = BigInt::from_str(test_str).unwrap();\n            let num_bigint_val = num_bigint::BigInt::from_str(test_str).unwrap();\n\n            assert_eq!(\n                malachite_val.to_f64(),\n                num_bigint_val.to_f64(),\n                \"to_f64 mismatch for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_to_f32() {\n        use num_traits::ToPrimitive as NumToPrimitive;\n\n        let test_cases = [\n            \"12345678901234567890\",\n            \"999999999999999999999999\",\n            \"-12345678901234567890\",\n            \"-999999999999999999999999\",\n            \"340282366920938463463374607431768211455\",\n        ];\n\n        for test_str in &test_cases {\n            let malachite_val = BigInt::from_str(test_str).unwrap();\n            let num_bigint_val = num_bigint::BigInt::from_str(test_str).unwrap();\n\n            assert_eq!(\n                malachite_val.to_f32(),\n                num_bigint_val.to_f32(),\n                \"to_f32 mismatch for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_to_i64() {\n        use num_traits::ToPrimitive as NumToPrimitive;\n\n        let test_cases = [\n            \"0\",\n            \"123\",\n            \"-456\",\n            \"9223372036854775807\",  // i64::MAX\n            \"-9223372036854775808\", // i64::MIN\n            \"9223372036854775808\",  // overflow\n            \"-9223372036854775809\", // overflow\n        ];\n\n        for test_str in &test_cases {\n            let malachite_val = BigInt::from_str(test_str).unwrap();\n            let num_bigint_val = num_bigint::BigInt::from_str(test_str).unwrap();\n\n            assert_eq!(\n                malachite_val.to_i64(),\n                num_bigint_val.to_i64(),\n                \"to_i64 mismatch for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_to_u64() {\n        use num_traits::ToPrimitive as NumToPrimitive;\n\n        let test_cases = [\n            \"0\",\n            \"123\",\n            \"18446744073709551615\", // u64::MAX\n            \"18446744073709551616\", // overflow\n            \"-1\",                   // negative\n        ];\n\n        for test_str in &test_cases {\n            let malachite_val = BigInt::from_str(test_str).unwrap();\n            let num_bigint_val = num_bigint::BigInt::from_str(test_str).unwrap();\n\n            assert_eq!(\n                malachite_val.to_u64(),\n                num_bigint_val.to_u64(),\n                \"to_u64 mismatch for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_arithmetic() {\n        let test_cases = [\n            (\"123456789\", \"987654321\"),\n            (\"999999999999999999\", \"1\"),\n            (\"-123456789\", \"987654321\"),\n            (\"123456789\", \"-987654321\"),\n            (\"-123456789\", \"-987654321\"),\n        ];\n\n        for (a_str, b_str) in &test_cases {\n            let ma = BigInt::from_str(a_str).unwrap();\n            let mb = BigInt::from_str(b_str).unwrap();\n            let na = num_bigint::BigInt::from_str(a_str).unwrap();\n            let nb = num_bigint::BigInt::from_str(b_str).unwrap();\n\n            assert_eq!((&ma + &mb).to_string(), (&na + &nb).to_string(), \"add\");\n            assert_eq!((&ma - &mb).to_string(), (&na - &nb).to_string(), \"sub\");\n            assert_eq!((&ma * &mb).to_string(), (&na * &nb).to_string(), \"mul\");\n            if *b_str != \"0\" {\n                assert_eq!((&ma / &mb).to_string(), (&na / &nb).to_string(), \"div\");\n                assert_eq!((&ma % &mb).to_string(), (&na % &nb).to_string(), \"rem\");\n            }\n        }\n    }\n\n    #[test]\n    fn test_checked_arithmetic() {\n        let test_cases = [\n            (\"123456789\", \"987654321\"),\n            (\"999999999999999999\", \"1\"),\n            (\"-123456789\", \"987654321\"),\n        ];\n\n        for (a_str, b_str) in &test_cases {\n            let ma = BigInt::from_str(a_str).unwrap();\n            let mb = BigInt::from_str(b_str).unwrap();\n            let na = num_bigint::BigInt::from_str(a_str).unwrap();\n            let nb = num_bigint::BigInt::from_str(b_str).unwrap();\n\n            assert_eq!(\n                ma.checked_add(&mb).map(|v| v.to_string()),\n                na.checked_add(&nb).map(|v| v.to_string()),\n                \"checked_add\"\n            );\n            assert_eq!(\n                ma.checked_sub(&mb).map(|v| v.to_string()),\n                na.checked_sub(&nb).map(|v| v.to_string()),\n                \"checked_sub\"\n            );\n            assert_eq!(\n                ma.checked_mul(&mb).map(|v| v.to_string()),\n                na.checked_mul(&nb).map(|v| v.to_string()),\n                \"checked_mul\"\n            );\n            assert_eq!(\n                ma.checked_div(&mb).map(|v| v.to_string()),\n                na.checked_div(&nb).map(|v| v.to_string()),\n                \"checked_div\"\n            );\n        }\n    }\n\n    #[test]\n    fn test_sign() {\n        use num_traits::Signed;\n\n        let test_cases = [\n            \"0\",\n            \"123\",\n            \"-456\",\n            \"999999999999999999\",\n            \"-999999999999999999\",\n        ];\n\n        for test_str in &test_cases {\n            let ma = BigInt::from_str(test_str).unwrap();\n            let na = num_bigint::BigInt::from_str(test_str).unwrap();\n\n            assert_eq!(\n                ma.is_positive(),\n                na.is_positive(),\n                \"is_positive for {test_str}\",\n            );\n            assert_eq!(\n                ma.is_negative(),\n                na.is_negative(),\n                \"is_negative for {test_str}\",\n            );\n            assert_eq!(\n                ma.abs().to_string(),\n                na.abs().to_string(),\n                \"abs for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_pow() {\n        use num_traits::Pow;\n\n        let test_cases = [(\"2\", 10u32), (\"10\", 20u32), (\"-3\", 5u32), (\"123\", 4u32)];\n\n        for (base_str, exp) in &test_cases {\n            let ma = BigInt::from_str(base_str).unwrap();\n            let na = num_bigint::BigInt::from_str(base_str).unwrap();\n\n            assert_eq!(\n                ma.pow(*exp).to_string(),\n                na.pow(*exp).to_string(),\n                \"pow for {base_str}^{exp}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_to_signed_bytes() {\n        let sysmax = i64::MAX;\n        let i = BigInt::from(sysmax);\n        let b = i.to_signed_bytes_le();\n        let i2 = BigInt::from_signed_bytes_le(&b);\n        assert_eq!(i, i2);\n    }\n\n    #[test]\n    fn test_display_bigint() {\n        let n = BigInt::from_str(\"1234567890\").unwrap();\n        assert_eq!(format!(\"{n}\"), \"1234567890\");\n    }\n}\n"
  },
  {
    "path": "malachite-bigint/src/biguint.rs",
    "content": "// Copyright © 2026 Steve Shi\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse alloc::string::String;\nuse alloc::vec::Vec;\nuse core::{\n    cmp::Ordering::{Equal, Greater, Less},\n    iter::{Product, Sum},\n    ops::{\n        Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div,\n        DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign,\n    },\n    str::FromStr,\n};\nuse malachite_base::{\n    num::{\n        arithmetic::traits::{\n            DivRem, DivRound, DivisibleBy, FloorRoot, Gcd, Lcm, Mod, ModPow, Parity,\n        },\n        conversion::traits::{Digits, FromStringBase, PowerOf2Digits, RoundingInto, ToStringBase},\n        logic::traits::{BitAccess, BitIterable, CountOnes, SignificantBits},\n    },\n    rounding_modes::RoundingMode,\n};\nuse malachite_nz::{integer::Integer, natural::Natural};\nuse num_integer::Roots;\nuse num_traits::{\n    CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Num, One, Pow, ToPrimitive,\n    Unsigned, Zero,\n};\nuse paste::paste;\n\nuse crate::{ParseBigIntError, ToBigInt, TryFromBigIntError, U32Digits, U64Digits};\n\npub trait ToBigUint {\n    fn to_biguint(&self) -> Option<BigUint>;\n}\n\napply_to_primitives!(impl_primitive_convert{BigUint, _});\nimpl_primitive_convert!(BigUint, f32);\nimpl_primitive_convert!(BigUint, f64);\n\n#[repr(transparent)]\n#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]\npub struct BigUint(pub(crate) Natural);\n\napply_to_unsigneds!(forward_from{BigUint, _});\napply_to_signeds!(forward_try_from{BigUint, _});\napply_to_primitives!(forward_try_into{BigUint, _});\n\nimpl_from!(BigUint, Natural);\n\nforward_binary_self!(BigUint, Add, add);\nforward_binary_self!(BigUint, Sub, sub);\nforward_binary_self!(BigUint, Mul, mul);\nforward_binary_self!(BigUint, Div, div);\nforward_binary_self!(BigUint, Rem, rem);\nforward_binary_self!(BigUint, BitAnd, bitand);\nforward_binary_self!(BigUint, BitOr, bitor);\nforward_binary_self!(BigUint, BitXor, bitxor);\n\nforward_assign_self!(BigUint, AddAssign, add_assign);\nforward_assign_self!(BigUint, SubAssign, sub_assign);\nforward_assign_self!(BigUint, MulAssign, mul_assign);\nforward_assign_self!(BigUint, DivAssign, div_assign);\nforward_assign_self!(BigUint, RemAssign, rem_assign);\nforward_assign_self!(BigUint, BitAndAssign, bitand_assign);\nforward_assign_self!(BigUint, BitOrAssign, bitor_assign);\nforward_assign_self!(BigUint, BitXorAssign, bitxor_assign);\n\nforward_pow_biguint!(BigUint);\n\napply_to_unsigneds!(forward_binary_right_primitive_into{BigUint, _, Add, add});\napply_to_unsigneds!(forward_binary_right_primitive_into{BigUint, _, Sub, sub});\napply_to_unsigneds!(forward_binary_right_primitive_into{BigUint, _, Mul, mul});\napply_to_unsigneds!(forward_binary_right_primitive_into{BigUint, _, Div, div});\napply_to_unsigneds!(forward_binary_right_primitive_into{BigUint, _, Rem, rem});\n\napply_to_unsigneds!(forward_binary_left_primitive_into{_, BigUint, Add, add});\napply_to_unsigneds!(forward_binary_left_primitive_into{_, BigUint, Sub, sub});\napply_to_unsigneds!(forward_binary_left_primitive_into{_, BigUint, Mul, mul});\napply_to_unsigneds!(forward_binary_left_primitive_into{_, BigUint, Div, div});\napply_to_unsigneds!(forward_binary_left_primitive_into{_, BigUint, Rem, rem});\n\napply_to_primitives!(forward_binary_right_primitive{BigUint, _, Shl, shl});\napply_to_primitives!(forward_binary_right_primitive{BigUint, _, Shr, shr});\n\napply_to_unsigneds!(forward_assign_primitive_into{BigUint, _, AddAssign, add_assign});\napply_to_unsigneds!(forward_assign_primitive_into{BigUint, _, SubAssign, sub_assign});\napply_to_unsigneds!(forward_assign_primitive_into{BigUint, _, MulAssign, mul_assign});\napply_to_unsigneds!(forward_assign_primitive_into{BigUint, _, DivAssign, div_assign});\napply_to_unsigneds!(forward_assign_primitive_into{BigUint, _, RemAssign, rem_assign});\n\napply_to_primitives!(forward_assign_primitive{BigUint, _, ShlAssign, shl_assign});\napply_to_primitives!(forward_assign_primitive{BigUint, _, ShrAssign, shr_assign});\n\napply_to_unsigneds!(forward_pow_primitive{BigUint, _});\n\nimpl_product_iter_type!(BigUint);\nimpl_sum_iter_type!(BigUint);\n\nforward_fmt!(BigUint, Debug, Display, Binary, Octal, LowerHex, UpperHex);\n\nimpl CheckedAdd for BigUint {\n    #[inline]\n    fn checked_add(&self, v: &Self) -> Option<Self> {\n        Some(self.add(v))\n    }\n}\n\nimpl CheckedSub for BigUint {\n    #[inline]\n    fn checked_sub(&self, v: &Self) -> Option<Self> {\n        match self.cmp(v) {\n            Less => None,\n            Equal => Some(Self::zero()),\n            Greater => Some(self.sub(v)),\n        }\n    }\n}\n\nimpl CheckedMul for BigUint {\n    #[inline]\n    fn checked_mul(&self, v: &Self) -> Option<Self> {\n        Some(self.mul(v))\n    }\n}\n\nimpl CheckedDiv for BigUint {\n    #[inline]\n    fn checked_div(&self, v: &Self) -> Option<Self> {\n        (!v.is_zero()).then(|| self.div(v))\n    }\n}\n\nimpl ToBigUint for BigUint {\n    #[inline]\n    fn to_biguint(&self) -> Option<BigUint> {\n        Some(self.clone())\n    }\n}\n\nimpl ToBigInt for BigUint {\n    #[inline]\n    fn to_bigint(&self) -> Option<crate::BigInt> {\n        Some(Integer::from(&self.0).into())\n    }\n}\n\nimpl ToPrimitive for BigUint {\n    apply_to_primitives!(impl_to_primitive_fn_try_into{_});\n    impl_to_primitive_fn_float!(f32);\n    impl_to_primitive_fn_float!(f64);\n}\n\nimpl FromPrimitive for BigUint {\n    apply_to_signeds!(impl_from_primitive_fn_try_from{_});\n    apply_to_unsigneds!(impl_from_primitive_fn_infallible{_});\n    impl_from_primitive_fn_float!(f32);\n    impl_from_primitive_fn_float!(f64);\n}\n\nimpl Zero for BigUint {\n    #[inline]\n    fn zero() -> Self {\n        Self(<Natural as malachite_base::num::basic::traits::Zero>::ZERO)\n    }\n\n    #[inline]\n    fn is_zero(&self) -> bool {\n        *self == Self::zero()\n    }\n}\n\nimpl One for BigUint {\n    #[inline]\n    fn one() -> Self {\n        Self(<Natural as malachite_base::num::basic::traits::One>::ONE)\n    }\n}\n\nimpl Unsigned for BigUint {}\n\nimpl Num for BigUint {\n    type FromStrRadixErr = ParseBigIntError;\n\n    fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr> {\n        let mut s = s;\n        if s.starts_with('+') {\n            let tail = &s[1..];\n            if !tail.starts_with('+') {\n                s = tail;\n            }\n        }\n\n        // FIXME: workaround, remove the check if malachite issue fixed\n        // https://github.com/mhogrefe/malachite/issues/20\n        if radix == 16\n            && s.bytes().any(|x| {\n                !matches!(x,\n                    b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F' | b'_'\n                )\n            })\n        {\n            return Err(ParseBigIntError::invalid());\n        }\n\n        // fast path\n        if let Some(val) = Natural::from_string_base(radix as u8, s) {\n            return Ok(val.into());\n        }\n\n        if s.is_empty() {\n            return Err(ParseBigIntError::empty());\n        }\n\n        if s.starts_with('_') {\n            // Must lead with a real digit!\n            return Err(ParseBigIntError::invalid());\n        }\n\n        let v: Vec<u8> = s.bytes().filter(|&x| x != b'_').collect();\n        let s = core::str::from_utf8(v.as_slice()).map_err(|_| ParseBigIntError::invalid())?;\n        Natural::from_string_base(radix as u8, s)\n            .map(Self)\n            .ok_or_else(ParseBigIntError::invalid)\n    }\n}\n\nimpl num_integer::Integer for BigUint {\n    #[inline]\n    fn div_floor(&self, other: &Self) -> Self {\n        (&self.0).div_round(&other.0, RoundingMode::Floor).0.into()\n    }\n\n    #[inline]\n    fn mod_floor(&self, other: &Self) -> Self {\n        (&self.0).mod_op(&other.0).into()\n    }\n\n    #[inline]\n    fn gcd(&self, other: &Self) -> Self {\n        (&self.0).gcd(&other.0).into()\n    }\n\n    #[inline]\n    fn lcm(&self, other: &Self) -> Self {\n        (&self.0).lcm(&other.0).into()\n    }\n\n    #[inline]\n    fn divides(&self, other: &Self) -> bool {\n        Self::is_multiple_of(self, other)\n    }\n\n    #[inline]\n    fn is_multiple_of(&self, other: &Self) -> bool {\n        (&self.0).divisible_by(&other.0)\n    }\n\n    #[inline]\n    fn is_even(&self) -> bool {\n        self.0.even()\n    }\n\n    #[inline]\n    fn is_odd(&self) -> bool {\n        self.0.odd()\n    }\n\n    #[inline]\n    fn div_rem(&self, other: &Self) -> (Self, Self) {\n        let (div, rem) = (&self.0).div_rem(&other.0);\n        (div.into(), rem.into())\n    }\n}\n\nimpl Roots for BigUint {\n    #[inline]\n    fn nth_root(&self, n: u32) -> Self {\n        (&self.0).floor_root(u64::from(n)).into()\n    }\n}\n\nimpl FromStr for BigUint {\n    type Err = ParseBigIntError;\n\n    #[inline]\n    fn from_str(s: &str) -> Result<Self, Self::Err> {\n        Self::from_str_radix(s, 10)\n    }\n}\n\nimpl BigUint {\n    // TODO consider passing &[u32] instead (breaking change)\n    #[allow(clippy::needless_pass_by_value)]\n    #[inline]\n    pub fn new(digits: Vec<u32>) -> Self {\n        Self::from_slice(digits.as_slice())\n    }\n\n    #[inline]\n    pub fn from_slice(slice: &[u32]) -> Self {\n        let mut uint = Self::zero();\n        uint.assign_from_slice(slice);\n        uint\n    }\n\n    #[inline]\n    pub fn assign_from_slice(&mut self, slice: &[u32]) {\n        // SAFETY: &[u32] cannot have any digit greater than 2^32\n        self.0 = unsafe {\n            Natural::from_power_of_2_digits_asc(32, slice.iter().copied()).unwrap_unchecked()\n        };\n    }\n\n    #[inline]\n    pub fn from_bytes_be(bytes: &[u8]) -> Self {\n        // SAFETY: &[u8] cannot have any digit greater than 2^8\n        Self(unsafe {\n            Natural::from_power_of_2_digits_desc(8, bytes.iter().copied()).unwrap_unchecked()\n        })\n    }\n\n    #[inline]\n    pub fn from_bytes_le(bytes: &[u8]) -> Self {\n        // SAFETY: &[u8] cannot have any digit greater than 2^8\n        Self(unsafe {\n            Natural::from_power_of_2_digits_asc(8, bytes.iter().copied()).unwrap_unchecked()\n        })\n    }\n\n    #[inline]\n    pub fn parse_bytes(bytes: &[u8], radix: u32) -> Option<Self> {\n        let s = core::str::from_utf8(bytes).ok()?;\n        Self::from_str_radix(s, radix).ok()\n    }\n\n    #[inline]\n    pub fn from_radix_be(bytes: &[u8], radix: u32) -> Option<Self> {\n        if radix == 256 {\n            Some(Self::from_bytes_be(bytes))\n        } else {\n            Natural::from_digits_desc(&(radix as u8), bytes.iter().copied()).map(Self)\n        }\n    }\n\n    #[inline]\n    pub fn from_radix_le(bytes: &[u8], radix: u32) -> Option<Self> {\n        if radix == 256 {\n            Some(Self::from_bytes_le(bytes))\n        } else {\n            Natural::from_digits_asc(&(radix as u8), bytes.iter().copied()).map(Self)\n        }\n    }\n\n    #[inline]\n    pub fn to_bytes_be(&self) -> Vec<u8> {\n        self.0.to_power_of_2_digits_desc(8)\n    }\n\n    #[inline]\n    pub fn to_bytes_le(&self) -> Vec<u8> {\n        self.0.to_power_of_2_digits_asc(8)\n    }\n\n    #[inline]\n    pub fn to_u32_digits(&self) -> Vec<u32> {\n        self.0.to_power_of_2_digits_asc(32)\n    }\n\n    #[inline]\n    pub fn to_u64_digits(&self) -> Vec<u64> {\n        self.0.to_limbs_asc()\n    }\n\n    #[inline]\n    pub fn iter_u32_digits(&self) -> U32Digits<'_> {\n        U32Digits::new(self.0.limbs())\n    }\n\n    #[inline]\n    pub fn iter_u64_digits(&self) -> U64Digits<'_> {\n        U64Digits::new(self.0.limbs())\n    }\n\n    #[inline]\n    pub fn to_str_radix(&self, radix: u32) -> String {\n        self.0.to_string_base(radix as u8)\n    }\n\n    #[inline]\n    pub fn to_radix_be(&self, radix: u32) -> Vec<u8> {\n        debug_assert!(radix <= 256);\n        if radix == 256 {\n            self.to_bytes_be()\n        } else {\n            self.0.to_digits_desc(&(radix as u8))\n        }\n    }\n\n    #[inline]\n    pub fn to_radix_le(&self, radix: u32) -> Vec<u8> {\n        debug_assert!(radix <= 256);\n        if radix == 256 {\n            self.to_bytes_le()\n        } else {\n            self.0.to_digits_asc(&(radix as u8))\n        }\n    }\n\n    #[inline]\n    pub fn bits(&self) -> u64 {\n        self.0.significant_bits()\n    }\n\n    #[inline]\n    pub fn pow(&self, exponent: u32) -> Self {\n        Pow::pow(self, exponent)\n    }\n\n    #[inline]\n    pub fn modpow(&self, exponent: &Self, modulus: &Self) -> Self {\n        if self >= modulus {\n            let x = self % modulus;\n            x.0.mod_pow(&exponent.0, &modulus.0).into()\n        } else {\n            (&self.0).mod_pow(&exponent.0, &modulus.0).into()\n        }\n    }\n\n    #[inline]\n    pub fn cbrt(&self) -> Self {\n        Roots::cbrt(self)\n    }\n\n    #[inline]\n    pub fn nth_root(&self, n: u32) -> Self {\n        Roots::nth_root(self, n)\n    }\n\n    #[inline]\n    pub fn trailing_zeros(&self) -> Option<u64> {\n        self.0.trailing_zeros()\n    }\n\n    #[inline]\n    pub fn trailing_ones(&self) -> u64 {\n        self.0.bits().take_while(|&x| x).count() as u64\n    }\n\n    #[inline]\n    pub fn count_ones(&self) -> u64 {\n        self.0.count_ones()\n    }\n\n    #[inline]\n    pub fn bit(&self, bit: u64) -> bool {\n        self.0.get_bit(bit)\n    }\n\n    #[inline]\n    pub fn set_bit(&mut self, bit: u64, value: bool) {\n        if value {\n            self.0.set_bit(bit);\n        } else {\n            self.0.clear_bit(bit);\n        }\n    }\n}\n\n#[cfg(test)]\nmod test {\n    use super::*;\n    use alloc::format;\n\n    #[test]\n    fn test_from_string_base() {\n        assert!(BigUint::from_str_radix(\"1000000000000000111111100112abcdefg\", 16).is_err());\n    }\n\n    #[test]\n    fn test_display_biguint() {\n        let x = BigUint::from_str_radix(\"1234567890\", 10).unwrap();\n        assert_eq!(format!(\"{x}\"), \"1234567890\");\n    }\n\n    #[test]\n    fn test_to_f64() {\n        use num_traits::ToPrimitive;\n\n        let test_cases = [\n            \"123456789012345678901234567890\",\n            \"999999999999999999999999999999\",\n            \"340282366920938463463374607431768211455\",\n            \"12345678901234567890123456789012345678901234567890\",\n            \"1208925819614629174706176\",\n            \"1329227995784915872903807060280344576\",\n            \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            99999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            99999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n            9999999999999999999999999999999999999999999999999999\",\n        ];\n\n        for test_str in &test_cases {\n            let malachite_val = BigUint::from_str(test_str).unwrap();\n            let num_bigint_val = num_bigint::BigUint::from_str(test_str).unwrap();\n\n            assert_eq!(\n                malachite_val.to_f64(),\n                num_bigint_val.to_f64(),\n                \"to_f64 mismatch for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_to_f32() {\n        use num_traits::ToPrimitive;\n\n        let test_cases = [\n            \"12345678901234567890\",\n            \"999999999999999999999999\",\n            \"340282366920938463463374607431768211455\",\n        ];\n\n        for test_str in &test_cases {\n            let malachite_val = BigUint::from_str(test_str).unwrap();\n            let num_bigint_val = num_bigint::BigUint::from_str(test_str).unwrap();\n\n            assert_eq!(\n                malachite_val.to_f32(),\n                num_bigint_val.to_f32(),\n                \"to_f32 mismatch for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_to_u64() {\n        use num_traits::ToPrimitive;\n\n        let test_cases = [\"0\", \"123\", \"18446744073709551615\", \"18446744073709551616\"];\n\n        for test_str in &test_cases {\n            let malachite_val = BigUint::from_str(test_str).unwrap();\n            let num_bigint_val = num_bigint::BigUint::from_str(test_str).unwrap();\n\n            assert_eq!(\n                malachite_val.to_u64(),\n                num_bigint_val.to_u64(),\n                \"to_u64 mismatch for {test_str}\",\n            );\n        }\n    }\n\n    #[test]\n    fn test_arithmetic() {\n        let test_cases = [\n            (\"123456789\", \"987654321\"),\n            (\"999999999999999999\", \"1\"),\n            (\"1000000000000000000\", \"999999999999999999\"),\n        ];\n\n        for (a_str, b_str) in &test_cases {\n            let ma = BigUint::from_str(a_str).unwrap();\n            let mb = BigUint::from_str(b_str).unwrap();\n            let na = num_bigint::BigUint::from_str(a_str).unwrap();\n            let nb = num_bigint::BigUint::from_str(b_str).unwrap();\n\n            assert_eq!((&ma + &mb).to_string(), (&na + &nb).to_string(), \"add\");\n            assert_eq!((&ma * &mb).to_string(), (&na * &nb).to_string(), \"mul\");\n            if ma >= mb {\n                assert_eq!((&ma - &mb).to_string(), (&na - &nb).to_string(), \"sub\");\n            }\n            if *b_str != \"0\" {\n                assert_eq!((&ma / &mb).to_string(), (&na / &nb).to_string(), \"div\");\n                assert_eq!((&ma % &mb).to_string(), (&na % &nb).to_string(), \"rem\");\n            }\n        }\n    }\n\n    #[test]\n    fn test_pow() {\n        use num_traits::Pow;\n\n        let test_cases = [(\"2\", 10u32), (\"10\", 20u32), (\"123\", 4u32)];\n\n        for (base_str, exp) in &test_cases {\n            let ma = BigUint::from_str(base_str).unwrap();\n            let na = num_bigint::BigUint::from_str(base_str).unwrap();\n\n            assert_eq!(\n                ma.pow(*exp).to_string(),\n                na.pow(*exp).to_string(),\n                \"pow for {base_str}^{exp}\",\n            );\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-bigint/src/error.rs",
    "content": "// Copyright © 2026 Steve Shi\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub struct ParseBigIntError {\n    kind: BigIntErrorKind,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nenum BigIntErrorKind {\n    Empty,\n    InvalidDigit,\n}\n\nimpl ParseBigIntError {\n    const fn __description(&self) -> &str {\n        use BigIntErrorKind::*;\n        match self.kind {\n            Empty => \"cannot parse integer from empty string\",\n            InvalidDigit => \"invalid digit found in string\",\n        }\n    }\n\n    pub(crate) const fn empty() -> Self {\n        Self {\n            kind: BigIntErrorKind::Empty,\n        }\n    }\n\n    pub(crate) const fn invalid() -> Self {\n        Self {\n            kind: BigIntErrorKind::InvalidDigit,\n        }\n    }\n}\n\nimpl core::fmt::Display for ParseBigIntError {\n    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {\n        self.__description().fmt(f)\n    }\n}\n\nimpl core::error::Error for ParseBigIntError {\n    fn description(&self) -> &str {\n        self.__description()\n    }\n}\n\n#[derive(Debug, Copy, Clone, PartialEq, Eq)]\npub struct TryFromBigIntError<T> {\n    original: T,\n}\n\nimpl<T> TryFromBigIntError<T> {\n    pub(crate) const fn new(original: T) -> Self {\n        Self { original }\n    }\n\n    #[allow(clippy::unused_self)]\n    const fn __description(&self) -> &str {\n        \"out of range conversion regarding big integer attempted\"\n    }\n\n    pub fn into_original(self) -> T {\n        self.original\n    }\n}\n\nimpl<T> core::error::Error for TryFromBigIntError<T>\nwhere\n    T: core::fmt::Debug,\n{\n    fn description(&self) -> &str {\n        self.__description()\n    }\n}\n\nimpl<T> core::fmt::Display for TryFromBigIntError<T> {\n    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {\n        self.__description().fmt(f)\n    }\n}\n"
  },
  {
    "path": "malachite-bigint/src/iter.rs",
    "content": "// Copyright © 2026 Steve Shi\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::iter::FusedIterator;\n\nuse malachite_nz::natural::conversion::to_limbs::LimbIterator;\n\npub struct U32Digits<'a> {\n    iter: LimbIterator<'a>,\n    next_hi: Option<u32>,\n    last_hi_is_zero: bool,\n    len: usize,\n}\n\nimpl<'a> U32Digits<'a> {\n    #[inline]\n    pub(crate) fn new(iter: LimbIterator<'a>) -> Self {\n        let iter_len = iter.len();\n        let last_hi_is_zero = iter_len != 0 && (iter[iter_len - 1] >> 32) == 0;\n        let len = iter_len * 2 - usize::from(last_hi_is_zero);\n        Self {\n            iter,\n            next_hi: None,\n            last_hi_is_zero,\n            len,\n        }\n    }\n}\n\nimpl Iterator for U32Digits<'_> {\n    type Item = u32;\n\n    #[inline]\n    fn next(&mut self) -> Option<u32> {\n        if self.len == 0 {\n            return None;\n        }\n        self.len -= 1;\n\n        self.next_hi.take().or_else(|| {\n            let limb = self.iter.next()?;\n            let hi = (limb >> 32) as u32;\n            let lo = limb as u32;\n\n            self.next_hi = Some(hi);\n            Some(lo)\n        })\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        let len = self.len();\n        (len, Some(len))\n    }\n\n    #[inline]\n    fn count(self) -> usize {\n        self.len()\n    }\n\n    #[inline]\n    fn last(self) -> Option<Self::Item> {\n        self.iter.most_significant().map(|limb| {\n            if self.last_hi_is_zero {\n                limb as u32\n            } else {\n                (limb >> 32) as u32\n            }\n        })\n    }\n}\n\nimpl ExactSizeIterator for U32Digits<'_> {\n    #[inline]\n    fn len(&self) -> usize {\n        self.len\n    }\n}\n\n// TODO: DoubleEndedIterator\n\nimpl FusedIterator for U32Digits<'_> {}\n\npub struct U64Digits<'a> {\n    iter: LimbIterator<'a>,\n}\n\nimpl<'a> U64Digits<'a> {\n    #[inline]\n    pub(crate) const fn new(iter: LimbIterator<'a>) -> Self {\n        Self { iter }\n    }\n}\n\nimpl Iterator for U64Digits<'_> {\n    type Item = u64;\n\n    #[inline]\n    fn next(&mut self) -> Option<u64> {\n        self.iter.next()\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        self.iter.size_hint()\n    }\n\n    #[inline]\n    fn nth(&mut self, n: usize) -> Option<u64> {\n        self.iter.nth(n)\n    }\n\n    #[inline]\n    fn last(self) -> Option<u64> {\n        self.iter.most_significant()\n    }\n\n    #[inline]\n    fn count(self) -> usize {\n        self.iter.count()\n    }\n}\n\nimpl DoubleEndedIterator for U64Digits<'_> {\n    fn next_back(&mut self) -> Option<Self::Item> {\n        self.iter.next_back()\n    }\n}\n\nimpl ExactSizeIterator for U64Digits<'_> {\n    #[inline]\n    fn len(&self) -> usize {\n        self.iter.len()\n    }\n}\n\nimpl FusedIterator for U64Digits<'_> {}\n\n#[test]\nfn test_iter_u32_digits() {\n    let n = super::BigUint::from(5u8);\n    let mut it = n.iter_u32_digits();\n    assert_eq!(it.len(), 1);\n    assert_eq!(it.next(), Some(5));\n    assert_eq!(it.len(), 0);\n    assert_eq!(it.next(), None);\n    assert_eq!(it.len(), 0);\n    assert_eq!(it.next(), None);\n\n    let n = super::BigUint::from(112500000000u64);\n    let mut it = n.iter_u32_digits();\n    assert_eq!(it.len(), 2);\n    assert_eq!(it.next(), Some(830850304));\n    assert_eq!(it.len(), 1);\n    assert_eq!(it.next(), Some(26));\n    assert_eq!(it.len(), 0);\n    assert_eq!(it.next(), None);\n}\n\n#[test]\nfn test_iter_u64_digits() {\n    let n = super::BigUint::from(5u8);\n    let mut it = n.iter_u64_digits();\n    assert_eq!(it.len(), 1);\n    assert_eq!(it.next(), Some(5));\n    assert_eq!(it.len(), 0);\n    assert_eq!(it.next(), None);\n    assert_eq!(it.len(), 0);\n    assert_eq!(it.next(), None);\n\n    let n = super::BigUint::from(18_446_744_073_709_551_616u128);\n    let mut it = n.iter_u64_digits();\n    assert_eq!(it.len(), 2);\n    assert_eq!(it.next(), Some(0));\n    assert_eq!(it.len(), 1);\n    assert_eq!(it.next(), Some(1));\n    assert_eq!(it.len(), 0);\n    assert_eq!(it.next(), None);\n}\n"
  },
  {
    "path": "malachite-bigint/src/lib.rs",
    "content": "// Copyright © 2026 Steve Shi\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n\nextern crate alloc;\n\n#[macro_use]\nmod macros;\nmod bigint;\nmod biguint;\nmod error;\nmod iter;\n#[cfg(feature = \"num-bigint\")]\nmod num_bigint_conversion;\n\npub use bigint::{BigInt, Sign, ToBigInt};\npub use biguint::{BigUint, ToBigUint};\npub use error::{ParseBigIntError, TryFromBigIntError};\npub use iter::{U32Digits, U64Digits};\n"
  },
  {
    "path": "malachite-bigint/src/macros.rs",
    "content": "// Copyright © 2026 Steve Shi\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nmacro_rules! apply_to_unsigneds {\n    ($m:tt{_$(,$args:ident)*}) => {\n        $m!(u8 $(,$args)*);\n        $m!(u16 $(,$args)*);\n        $m!(u32 $(,$args)*);\n        $m!(u64 $(,$args)*);\n        $m!(usize $(,$args)*);\n        $m!(u128 $(,$args)*);\n    };\n    ($m:tt{$arg0:tt,_$(,$args:tt)*}) => {\n        $m!($arg0, u8 $(,$args)*);\n        $m!($arg0, u16 $(,$args)*);\n        $m!($arg0, u32 $(,$args)*);\n        $m!($arg0, u64 $(,$args)*);\n        $m!($arg0, usize $(,$args)*);\n        $m!($arg0, u128 $(,$args)*);\n    }\n}\n\nmacro_rules! apply_to_signeds {\n    ($m:tt{_$(,$args:ident)*}) => {\n        $m!(i8 $(,$args)*);\n        $m!(i16 $(,$args)*);\n        $m!(i32 $(,$args)*);\n        $m!(i64 $(,$args)*);\n        $m!(isize $(,$args)*);\n        $m!(i128 $(,$args)*);\n    };\n    ($m:tt{$arg0:tt,_$(,$args:tt)*}) => {\n        $m!($arg0, i8 $(,$args)*);\n        $m!($arg0, i16 $(,$args)*);\n        $m!($arg0, i32 $(,$args)*);\n        $m!($arg0, i64 $(,$args)*);\n        $m!($arg0, isize $(,$args)*);\n        $m!($arg0, i128 $(,$args)*);\n    }\n}\n\nmacro_rules! apply_to_primitives {\n    ($m:tt{_$(,$args:ident)*}) => {\n        apply_to_signeds!($m{_$(,$args)*});\n        apply_to_unsigneds!($m{_$(,$args)*});\n    };\n    ($m:tt{$arg0:tt,_$(,$args:tt)*}) => {\n        apply_to_signeds!($m{$arg0, _$(,$args)*});\n        apply_to_unsigneds!($m{$arg0, _$(,$args)*});\n    };\n}\n\nmacro_rules! forward_from {\n    ($lhs:ty, $rhs:ty) => {\n        impl From<$rhs> for $lhs {\n            #[inline]\n            fn from(value: $rhs) -> Self {\n                Self(<_ as From<_>>::from(value))\n            }\n        }\n    };\n}\n\nmacro_rules! forward_try_from {\n    ($lhs:ty, $rhs:ty) => {\n        impl TryFrom<$rhs> for $lhs {\n            type Error = TryFromBigIntError<()>;\n\n            #[inline]\n            fn try_from(value: $rhs) -> Result<Self, Self::Error> {\n                <_ as TryFrom<_>>::try_from(value)\n                    .map_err(|_| Self::Error::new(()))\n                    .map(Self)\n            }\n        }\n    };\n}\n\nmacro_rules! forward_try_into {\n    ($res:ty, $t:ty) => {\n        impl TryFrom<$res> for $t {\n            type Error = TryFromBigIntError<$res>;\n\n            #[inline]\n            fn try_from(value: $res) -> Result<Self, Self::Error> {\n                <$t>::try_from(&value.0).map_err(|_| Self::Error::new(value))\n            }\n        }\n\n        impl TryFrom<&$res> for $t {\n            type Error = TryFromBigIntError<()>;\n\n            #[inline]\n            fn try_from(value: &$res) -> Result<Self, Self::Error> {\n                <$t>::try_from(&value.0).map_err(|_| Self::Error::new(()))\n            }\n        }\n    };\n}\n\nmacro_rules! forward_unary_op {\n    ($struct:tt, $trait:tt, $fn:ident) => {\n        impl $trait for $struct {\n            type Output = $struct;\n\n            #[inline]\n            fn $fn(mut self) -> Self::Output {\n                self.0 = $trait::$fn(self.0);\n                self\n            }\n        }\n\n        impl $trait for &$struct {\n            type Output = $struct;\n\n            #[inline]\n            fn $fn(self) -> Self::Output {\n                $struct($trait::$fn(&self.0))\n            }\n        }\n    };\n}\n\nmacro_rules! impl_binary_op {\n    ($lhs:ty, $rhs:ty, $output:ty, $trait:tt, $fn:ident, $expr:expr) => {\n        impl $trait<$rhs> for $lhs {\n            type Output = $output;\n\n            #[inline]\n            fn $fn(self, rhs: $rhs) -> Self::Output {\n                $expr(self, rhs)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_assign_op {\n    ($lhs:ty, $rhs:ty, $trait:tt, $fn:ident, $expr:expr) => {\n        impl $trait<$rhs> for $lhs {\n            #[inline]\n            fn $fn(&mut self, rhs: $rhs) {\n                $expr(self, rhs)\n            }\n        }\n    };\n}\n\nmacro_rules! forward_binary_self {\n    ($struct:ty, $trait:tt, $fn:ident) => {\n        impl_binary_op!(\n            $struct,\n            $struct,\n            $struct,\n            $trait,\n            $fn,\n            |lhs: $struct, rhs: $struct| { $trait::$fn(lhs.0, rhs.0).into() }\n        );\n        impl_binary_op!(\n            &$struct,\n            $struct,\n            $struct,\n            $trait,\n            $fn,\n            |lhs: &$struct, rhs: $struct| { $trait::$fn(&lhs.0, rhs.0).into() }\n        );\n        impl_binary_op!(\n            $struct,\n            &$struct,\n            $struct,\n            $trait,\n            $fn,\n            |lhs: $struct, rhs: &$struct| { $trait::$fn(lhs.0, &rhs.0).into() }\n        );\n        impl_binary_op!(\n            &$struct,\n            &$struct,\n            $struct,\n            $trait,\n            $fn,\n            |lhs: &$struct, rhs: &$struct| { $trait::$fn(&lhs.0, &rhs.0).into() }\n        );\n    };\n}\n\nmacro_rules! forward_binary_right_primitive {\n    ($lhs:ty, $rhs:ty, $trait:tt, $fn:ident) => {\n        impl_binary_op!($lhs, $rhs, $lhs, $trait, $fn, |lhs: $lhs, rhs: $rhs| {\n            $trait::$fn(lhs.0, rhs).into()\n        });\n        impl_binary_op!(&$lhs, $rhs, $lhs, $trait, $fn, |lhs: &$lhs, rhs: $rhs| {\n            $trait::$fn(&lhs.0, rhs).into()\n        });\n        impl_binary_op!($lhs, &$rhs, $lhs, $trait, $fn, |lhs: $lhs, rhs: &$rhs| {\n            $trait::$fn(lhs.0, *rhs).into()\n        });\n        impl_binary_op!(&$lhs, &$rhs, $lhs, $trait, $fn, |lhs: &$lhs, rhs: &$rhs| {\n            $trait::$fn(&lhs.0, *rhs).into()\n        });\n    };\n}\n\nmacro_rules! forward_binary_right_primitive_into {\n    ($lhs:ty, $rhs:ty, $trait:tt, $fn:ident) => {\n        impl_binary_op!($lhs, $rhs, $lhs, $trait, $fn, |lhs: $lhs, rhs: $rhs| {\n            $trait::$fn(lhs.0, <$lhs>::from(rhs).0).into()\n        });\n        impl_binary_op!(&$lhs, $rhs, $lhs, $trait, $fn, |lhs: &$lhs, rhs: $rhs| {\n            $trait::$fn(&lhs.0, <$lhs>::from(rhs).0).into()\n        });\n        impl_binary_op!($lhs, &$rhs, $lhs, $trait, $fn, |lhs: $lhs, rhs: &$rhs| {\n            $trait::$fn(lhs.0, <$lhs>::from(*rhs).0).into()\n        });\n        impl_binary_op!(&$lhs, &$rhs, $lhs, $trait, $fn, |lhs: &$lhs, rhs: &$rhs| {\n            $trait::$fn(&lhs.0, <$lhs>::from(*rhs).0).into()\n        });\n    };\n}\n\nmacro_rules! forward_binary_left_primitive_into {\n    ($lhs:ty, $rhs:ty, $trait:tt, $fn:ident) => {\n        impl_binary_op!($lhs, $rhs, $rhs, $trait, $fn, |lhs: $lhs, rhs: $rhs| {\n            $trait::$fn(<$rhs>::from(lhs).0, rhs.0).into()\n        });\n        impl_binary_op!(&$lhs, $rhs, $rhs, $trait, $fn, |lhs: &$lhs, rhs: $rhs| {\n            $trait::$fn(<$rhs>::from(*lhs).0, rhs.0).into()\n        });\n        impl_binary_op!($lhs, &$rhs, $rhs, $trait, $fn, |lhs: $lhs, rhs: &$rhs| {\n            $trait::$fn(<$rhs>::from(lhs).0, &rhs.0).into()\n        });\n        impl_binary_op!(&$lhs, &$rhs, $rhs, $trait, $fn, |lhs: &$lhs, rhs: &$rhs| {\n            $trait::$fn(<$rhs>::from(*lhs).0, &rhs.0).into()\n        });\n    };\n}\n\nmacro_rules! forward_assign_self {\n    ($struct:ty, $trait:tt, $fn:ident) => {\n        impl_assign_op!(\n            $struct,\n            $struct,\n            $trait,\n            $fn,\n            |lhs: &mut $struct, rhs: $struct| { $trait::$fn(&mut lhs.0, rhs.0).into() }\n        );\n        impl_assign_op!(\n            $struct,\n            &$struct,\n            $trait,\n            $fn,\n            |lhs: &mut $struct, rhs: &$struct| { $trait::$fn(&mut lhs.0, &rhs.0).into() }\n        );\n    };\n}\n\nmacro_rules! forward_assign_primitive {\n    ($lhs:ty, $rhs:ty, $trait:tt, $fn:ident) => {\n        impl_assign_op!($lhs, $rhs, $trait, $fn, |lhs: &mut $lhs, rhs: $rhs| {\n            $trait::$fn(&mut lhs.0, rhs).into()\n        });\n        impl_assign_op!($lhs, &$rhs, $trait, $fn, |lhs: &mut $lhs, rhs: &$rhs| {\n            $trait::$fn(&mut lhs.0, *rhs).into()\n        });\n    };\n}\n\nmacro_rules! forward_assign_primitive_into {\n    ($lhs:ty, $rhs:ty, $trait:tt, $fn:ident) => {\n        impl_assign_op!($lhs, $rhs, $trait, $fn, |lhs: &mut $lhs, rhs: $rhs| {\n            $trait::$fn(&mut lhs.0, <$lhs>::from(rhs).0).into()\n        });\n        impl_assign_op!($lhs, &$rhs, $trait, $fn, |lhs: &mut $lhs, rhs: &$rhs| {\n            $trait::$fn(&mut lhs.0, <$lhs>::from(*rhs).0).into()\n        });\n    };\n}\n\nmacro_rules! forward_pow_primitive {\n    ($lhs:ty, $rhs:ty) => {\n        impl_binary_op!($lhs, $rhs, $lhs, Pow, pow, |lhs: $lhs, rhs: $rhs| {\n            #[allow(clippy::cast_lossless)]\n            <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(lhs.0, rhs as _).into()\n        });\n        impl_binary_op!(&$lhs, $rhs, $lhs, Pow, pow, |lhs: &$lhs, rhs: $rhs| {\n            #[allow(clippy::cast_lossless)]\n            <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(&lhs.0, rhs as _).into()\n        });\n        impl_binary_op!($lhs, &$rhs, $lhs, Pow, pow, |lhs: $lhs, rhs: &$rhs| {\n            #[allow(clippy::cast_lossless)]\n            <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(lhs.0, *rhs as _).into()\n        });\n        impl_binary_op!(&$lhs, &$rhs, $lhs, Pow, pow, |lhs: &$lhs, rhs: &$rhs| {\n            #[allow(clippy::cast_lossless)]\n            <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(&lhs.0, *rhs as _).into()\n        });\n    };\n}\n\nmacro_rules! forward_pow_biguint {\n    ($lhs:ty) => {\n        impl_binary_op!($lhs, BigUint, $lhs, Pow, pow, |lhs: $lhs, rhs: BigUint| {\n            let exp =\n                malachite_base::num::conversion::traits::SaturatingFrom::saturating_from(&rhs.0);\n            <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(lhs.0, exp).into()\n        });\n        impl_binary_op!(\n            &$lhs,\n            BigUint,\n            $lhs,\n            Pow,\n            pow,\n            |lhs: &$lhs, rhs: BigUint| {\n                let exp = malachite_base::num::conversion::traits::SaturatingFrom::saturating_from(\n                    &rhs.0,\n                );\n                <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(&lhs.0, exp).into()\n            }\n        );\n        impl_binary_op!(\n            $lhs,\n            &BigUint,\n            $lhs,\n            Pow,\n            pow,\n            |lhs: $lhs, rhs: &BigUint| {\n                let exp = malachite_base::num::conversion::traits::SaturatingFrom::saturating_from(\n                    &rhs.0,\n                );\n                <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(lhs.0, exp).into()\n            }\n        );\n        impl_binary_op!(\n            &$lhs,\n            &BigUint,\n            $lhs,\n            Pow,\n            pow,\n            |lhs: &$lhs, rhs: &BigUint| {\n                let exp = malachite_base::num::conversion::traits::SaturatingFrom::saturating_from(\n                    &rhs.0,\n                );\n                <_ as malachite_base::num::arithmetic::traits::Pow<u64>>::pow(&lhs.0, exp).into()\n            }\n        );\n    };\n}\n\nmacro_rules! impl_sum_iter_type {\n    ($res:ty) => {\n        impl<T> Sum<T> for $res\n        where\n            $res: Add<T, Output = $res>,\n        {\n            #[inline]\n            fn sum<I>(iter: I) -> Self\n            where\n                I: Iterator<Item = T>,\n            {\n                iter.fold(Zero::zero(), <$res>::add)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_product_iter_type {\n    ($res:ty) => {\n        impl<T> Product<T> for $res\n        where\n            $res: Mul<T, Output = $res>,\n        {\n            #[inline]\n            fn product<I>(iter: I) -> Self\n            where\n                I: Iterator<Item = T>,\n            {\n                iter.fold(One::one(), <$res>::mul)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_primitive_fn_infallible {\n    ($t:ty) => {\n        paste! {\n            #[inline]\n            fn [<from_ $t>](n: $t) -> Option<Self> {\n                Some(Self::from(n))\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_primitive_fn_try_from {\n    ($t:ty) => {\n        paste! {\n            #[inline]\n            fn [<from_ $t>](n: $t) -> Option<Self> {\n                Self::try_from(n).ok()\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_primitive_fn_float {\n    ($t:ty) => {\n        paste! {\n            #[inline]\n            fn [<from_ $t>](n: $t) -> Option<Self> {\n                if !n.is_finite() {\n                    return None;\n                }\n                Some(Self(n.rounding_into(RoundingMode::Down).0))\n            }\n        }\n    };\n}\n\nmacro_rules! impl_primitive_convert {\n    ($res:ty, $t:ty) => {\n        paste! {\n            impl [<To $res>] for $t {\n                #[inline]\n                fn [<to_ $res:lower>](&self) -> Option<$res> {\n                    $res::[<from_ $t>](*self)\n                }\n            }\n        }\n    };\n}\n\nmacro_rules! impl_to_primitive_fn_try_into {\n    ($t:ty) => {\n        paste! {\n            #[inline]\n            fn [<to_ $t>](&self)-> Option<$t> {\n                self.try_into().ok()\n            }\n        }\n    };\n}\n\nmacro_rules! impl_to_primitive_fn_float {\n    ($t:ty) => {\n        paste! {\n            #[inline]\n            fn [<to_ $t>](&self) -> Option<$t> {\n                match (&self.0).rounding_into(RoundingMode::Nearest) {\n                    // returned value is $t::MAX but still less than the original\n                    (val, core::cmp::Ordering::Less) if val == $t::MAX => None,\n                    // returned value is $t::MIN but still greater than the original\n                    (val, core::cmp::Ordering::Greater) if val == $t::MIN => None,\n                    (val, _) => Some(val),\n                }\n            }\n        }\n    };\n}\n\nmacro_rules! forward_fmt {\n    ($t:ty, $($trait:ident),*) => {\n        $(impl core::fmt::$trait for $t {\n            fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {\n                core::fmt::$trait::fmt(&self.0, f)\n            }\n        })*\n    }\n}\n\nmacro_rules! impl_from {\n    ($wrapper:ty, $inner: ty) => {\n        impl From<$inner> for $wrapper {\n            fn from(value: $inner) -> Self {\n                Self(value)\n            }\n        }\n        impl From<$wrapper> for $inner {\n            #[inline]\n            fn from(value: $wrapper) -> Self {\n                value.0\n            }\n        }\n        impl<'a> From<&'a $wrapper> for &'a $inner {\n            #[inline]\n            fn from(value: &'a $wrapper) -> Self {\n                &value.0\n            }\n        }\n        impl<'a> From<&'a mut $wrapper> for &'a mut $inner {\n            #[inline]\n            fn from(value: &'a mut $wrapper) -> Self {\n                &mut value.0\n            }\n        }\n    };\n}\n"
  },
  {
    "path": "malachite-bigint/src/num_bigint_conversion.rs",
    "content": "// Copyright © 2026 Steve Shi\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::{\n    BigInt, BigUint,\n    Sign::{self, Minus, NoSign, Plus},\n};\nuse malachite_nz::natural::Natural;\nuse num_traits::ToPrimitive;\n\nimpl From<num_bigint::BigUint> for BigUint {\n    #[inline]\n    fn from(value: num_bigint::BigUint) -> Self {\n        if let Some(x) = value.to_u64() {\n            Self::from(x)\n        } else {\n            let limbs = value.to_u64_digits();\n            Self(Natural::from_owned_limbs_asc(limbs))\n        }\n    }\n}\n\nimpl From<BigUint> for num_bigint::BigUint {\n    #[inline]\n    fn from(value: BigUint) -> Self {\n        if let Some(x) = value.to_u64() {\n            Self::from(x)\n        } else {\n            let digits = value.to_u32_digits();\n            Self::new(digits)\n        }\n    }\n}\n\nimpl From<num_bigint::Sign> for Sign {\n    #[inline]\n    fn from(value: num_bigint::Sign) -> Self {\n        match value {\n            num_bigint::Sign::Minus => Minus,\n            num_bigint::Sign::NoSign => NoSign,\n            num_bigint::Sign::Plus => Plus,\n        }\n    }\n}\n\nimpl From<Sign> for num_bigint::Sign {\n    #[inline]\n    fn from(value: Sign) -> Self {\n        match value {\n            Minus => num_bigint::Sign::Minus,\n            NoSign => num_bigint::Sign::NoSign,\n            Plus => num_bigint::Sign::Plus,\n        }\n    }\n}\n\nimpl From<num_bigint::BigInt> for BigInt {\n    #[inline]\n    fn from(value: num_bigint::BigInt) -> Self {\n        let (sign, abs) = value.into_parts();\n        Self::from_biguint(sign.into(), abs.into())\n    }\n}\n\nimpl From<BigInt> for num_bigint::BigInt {\n    #[inline]\n    fn from(value: BigInt) -> Self {\n        let (sign, abs) = value.into_parts();\n        Self::from_biguint(sign.into(), abs.into())\n    }\n}\n\n#[test]\nfn num_bigint_conversion_test() {\n    let tester = |val: BigInt| {\n        let numval = num_bigint::BigInt::from(val.clone());\n        let val2 = BigInt::from(numval);\n        assert_eq!(val, val2);\n    };\n\n    tester(50723.into());\n    tester(BigInt::from(-52321));\n    tester(0.into());\n    tester(BigInt::from(core::u64::MAX).pow(1000u32));\n    tester(BigInt::from(core::i64::MIN).pow(1000u32));\n}\n"
  },
  {
    "path": "malachite-criterion-bench/Cargo.toml",
    "content": "[package]\nname = \"malachite-criterion-bench\"\nversion = \"0.8.1\"\nauthors = [\"Mikhail Hogrefe <mikhailhogrefe@gmail.com>\"]\nautobenches = false\nrust-version.workspace = true\nedition.workspace = true\n\n[dependencies]\nmalachite-base = { version = \"0.9.1\", path = \"../malachite-base\" }\nmalachite-nz = { version = \"0.9.1\", default-features = false, path = \"../malachite-nz\" }\nnum = \"0.4.3\"\nrug = { version = \"1.28.1\", default-features = false, features = [\"integer\", \"serde\"] }\n\n[dev-dependencies]\ncriterion = \"0.3\"\n\n[[bench]]\nname = \"natural_mul\"\nharness = false\n"
  },
  {
    "path": "malachite-criterion-bench/benches/bin.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\ncriterion_group!{\n    name = benches;\n    config = Criterion::default().significance_level(0.1).sample_size(10);\n    targets = bench_mul\n}\n"
  },
  {
    "path": "malachite-criterion-bench/benches/natural_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nextern crate criterion;\nextern crate malachite_base;\nextern crate malachite_nz;\nextern crate num;\nextern crate rug;\n\nuse criterion::*;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_nz::natural::random::get_random_natural_with_bits;\nuse malachite_nz::natural::Natural;\nuse num::BigUint;\nuse std::str::FromStr;\n\npub fn BigUint::from(n: &Natural) -> BigUint {\n    BigUint::from_str(n.to_string().as_ref()).unwrap()\n}\n\npub fn rug::Integer::from(n: &Natural) -> rug::Integer {\n    rug::Integer::from_str(n.to_string().as_ref()).unwrap()\n}\n\nfn bench_div(c: &mut Criterion) {\n    let mut group = c.benchmark_group(\"Natural / Natural\");\n    let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic);\n    group.plot_config(plot_config);\n\n    for &i in [1u64, 10, 100, 1000, 10000, 100000, 1000000, 10000000].iter() {\n        let x = get_random_natural_with_bits(\n            &mut random_primitive_ints(EXAMPLE_SEED.fork(\"a\")),\n            i << 1,\n        );\n        let y = get_random_natural_with_bits(&mut random_primitive_ints(EXAMPLE_SEED.fork(\"b\")), i);\n        let x_num = BigUint::from(&x);\n        let y_num = BigUint::from(&y);\n        let x_rug = rug::Integer::from(&x);\n        let y_rug = rug::Integer::from(&y);\n        group.bench_function(BenchmarkId::new(\"malachite\", i), |b| {\n            b.iter_with_setup(|| (x.clone(), y.clone()), |(x, y)| x / y)\n        });\n        group.bench_function(BenchmarkId::new(\"num\", i), |b| {\n            b.iter_with_setup(|| (x_num.clone(), y_num.clone()), |(x, y)| x / y)\n        });\n        group.bench_function(BenchmarkId::new(\"rug\", i), |b| {\n            b.iter_with_setup(|| (x_rug.clone(), y_rug.clone()), |(x, y)| x / y)\n        });\n    }\n    group.finish();\n}\n"
  },
  {
    "path": "malachite-criterion-bench/benches/natural_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nextern crate criterion;\nextern crate malachite_base;\nextern crate malachite_nz;\nextern crate num;\nextern crate rug;\n\nuse criterion::*;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::get_random_natural_with_bits;\nuse num::BigUint;\nuse std::str::FromStr;\n\npub fn natural_to_biguint(n: &Natural) -> BigUint {\n    BigUint::from_str(n.to_string().as_ref()).unwrap()\n}\n\npub fn natural_to_rug_integer(n: &Natural) -> rug::Integer {\n    rug::Integer::from_str(n.to_string().as_ref()).unwrap()\n}\n\nfn bench_mul(c: &mut Criterion) {\n    let mut group = c.benchmark_group(\"Natural * Natural\");\n    let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic);\n    group.plot_config(plot_config);\n    let sizes = [\n        1u64, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000,\n    ];\n    for &i in sizes.iter() {\n        let x = get_random_natural_with_bits(&mut random_primitive_ints(EXAMPLE_SEED.fork(\"a\")), i);\n        let y = get_random_natural_with_bits(&mut random_primitive_ints(EXAMPLE_SEED.fork(\"b\")), i);\n        let x_num = natural_to_biguint(&x);\n        let y_num = natural_to_biguint(&y);\n        let x_rug = natural_to_rug_integer(&x);\n        let y_rug = natural_to_rug_integer(&y);\n        group.bench_function(BenchmarkId::new(\"malachite\", i), |b| {\n            b.iter_with_setup(|| (x.clone(), y.clone()), |(x, y)| x * y)\n        });\n        group.bench_function(BenchmarkId::new(\"num\", i), |b| {\n            b.iter_with_setup(|| (x_num.clone(), y_num.clone()), |(x, y)| x * y)\n        });\n        group.bench_function(BenchmarkId::new(\"rug\", i), |b| {\n            b.iter_with_setup(|| (x_rug.clone(), y_rug.clone()), |(x, y)| x * y)\n        });\n    }\n    group.finish();\n}\ncriterion_group! {\n    name = benches;\n    config = Criterion::default().significance_level(0.1).sample_size(10);\n    targets = bench_mul\n}\ncriterion_main!(benches);\n"
  },
  {
    "path": "malachite-float/Cargo.toml",
    "content": "[package]\nname = \"malachite-float\"\nversion = \"0.9.1\"\nauthors = [\"Mikhail Hogrefe <mikhailhogrefe@gmail.com>\"]\nrust-version.workspace = true\nedition.workspace = true\ndescription = \"The arbitrary-precision floating-point type Float, with efficient algorithms partially derived from MPFR.\"\nreadme = \"README.md\"\nhomepage = \"https://malachite.rs/\"\nrepository = \"https://github.com/mhogrefe/malachite\"\nlicense = \"LGPL-3.0-only\"\nkeywords = [\"mathematics\", \"math\", \"numerics\", \"bignum\"]\ncategories = [\"mathematics\"]\n\n[lib]\nname = \"malachite_float\"\npath = \"src/lib.rs\"\n\n[[bin]]\nname = \"malachite_float_main\"\npath = \"src/bin.rs\"\n\n[dependencies]\nitertools = { version = \"0.14.0\", default-features = false, features = [\"use_alloc\"] }\nmalachite-base = { version = \"0.9.1\", default-features = false, path = \"../malachite-base\" }\nmalachite-nz = { version = \"0.9.1\", default-features = false, features = [\"float_helpers\"], path = \"../malachite-nz\" }\nmalachite-q = { version = \"0.9.1\", default-features = false, path = \"../malachite-q\" }\nserde = { version = \"1.0.188\", optional = true, default-features = false, features = [\"alloc\", \"derive\"] }\n\nserde_json = { version = \"1.0.149\", optional = true }\nnum = { version = \"0.4.3\", optional = true, features = [\"serde\"] }\nrug = { version = \"1.28.1\", default-features = false, optional = true, features = [\"float\", \"serde\"] }\n\n[dev-dependencies]\nmalachite-float = { path = \".\", features = [\"test_build\"] }\n\n[features]\ndefault = [\"std\"]\nstd = [\"malachite-base/std\", \"malachite-nz/std\", \"malachite-q/std\"]\nenable_serde = [\"serde\", \"malachite-nz/enable_serde\", \"malachite-q/enable_serde\"]\nrandom = [\"malachite-base/random\", \"malachite-nz/random\", \"malachite-q/random\"]\n32_bit_limbs = [\"malachite-nz/32_bit_limbs\", \"malachite-q/32_bit_limbs\"]\ntest_build = [\"malachite-base/test_build\", \"malachite-nz/test_build\", \"malachite-q/test_build\", \"random\", \"serde\", \"serde_json\", \"num\", \"rug\"]\nbin_build = [\"test_build\"]\n\n[package.metadata.docs.rs]\nfeatures = [\"random\"]\nrustdoc-args = [ \"--html-in-header\", \"katex-header.html\" ]\n"
  },
  {
    "path": "malachite-float/README.md",
    "content": "- [crates.io](https://crates.io/crates/malachite-float)\n- [docs.rs](https://docs.rs/malachite-float/latest/malachite_float/)\n\nRather than using this crate directly, use the\n[`malachite`](https://crates.io/crates/malachite) meta-crate. It re-exports all of this crate's\npublic members.\n\nIn `malachite-float`'s doctests you will frequently see import paths beginning with\n`malachite_float::`. When using the `malachite` crate, replace this part of the paths with\n`malachite::`.\n\nThe import path of the `Float` type is shortened to `malachite::Float`.\n\n# malachite-float\nThis crate defines\n[`Float`](https://docs.rs/malachite-float/latest/malachite_float/struct.Float.html)s.\n\nTODO\n\nMalachite is developed by Mikhail Hogrefe. Thanks to b4D8, florian1345, konstin, Rowan Hart, YunWon Jeong, Park Joon-Kyu, Antonio Mamić, OliverNChalk, shekohex, and skycloudd for additional contributions.\n\nCopyright © 2026 Mikhail Hogrefe\n"
  },
  {
    "path": "malachite-float/katex-header.html",
    "content": "<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css\" integrity=\"sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y\" crossorigin=\"anonymous\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js\"                  integrity=\"sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js\"    integrity=\"sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe\" crossorigin=\"anonymous\"></script>\n<script>\n    document.addEventListener(\"DOMContentLoaded\", function() {\n        renderMathInElement(document.body, {\n            delimiters: [\n                {left: \"$$\", right: \"$$\", display: true},\n                {left: \"\\\\(\", right: \"\\\\)\", display: false},\n                {left: \"$\", right: \"$\", display: false},\n                {left: \"\\\\[\", right: \"\\\\]\", display: true}\n            ]\n        });\n    });\n</script>\n"
  },
  {
    "path": "malachite-float/rustfmt.toml",
    "content": "max_width = 100\narray_width = 100\n"
  },
  {
    "path": "malachite-float/src/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{\n    Float, float_either_infinity, float_either_zero, float_infinity, float_nan,\n    float_negative_zero, float_zero,\n};\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign};\n\nimpl Float {\n    /// If `self` is negative zero, returns positive zero; otherwise, returns `self`, taking `self`\n    /// by value.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NAN.abs_negative_zero()),\n    ///     ComparableFloat(Float::NAN)\n    /// );\n    /// assert_eq!(Float::INFINITY.abs_negative_zero(), Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY.abs_negative_zero(),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(Float::ZERO.abs_negative_zero()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NEGATIVE_ZERO.abs_negative_zero()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(Float::ONE.abs_negative_zero(), Float::ONE);\n    /// assert_eq!(Float::NEGATIVE_ONE.abs_negative_zero(), Float::NEGATIVE_ONE);\n    /// ```\n    #[inline]\n    pub const fn abs_negative_zero(mut self) -> Self {\n        self.abs_negative_zero_assign();\n        self\n    }\n\n    /// If `self` is negative zero, returns positive zero; otherwise, returns `self`, taking `self`\n    /// by reference.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NAN.abs_negative_zero_ref()),\n    ///     ComparableFloat(Float::NAN)\n    /// );\n    /// assert_eq!(Float::INFINITY.abs_negative_zero_ref(), Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY.abs_negative_zero_ref(),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(Float::ZERO.abs_negative_zero_ref()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NEGATIVE_ZERO.abs_negative_zero_ref()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(Float::ONE.abs_negative_zero_ref(), Float::ONE);\n    /// assert_eq!(\n    ///     Float::NEGATIVE_ONE.abs_negative_zero_ref(),\n    ///     Float::NEGATIVE_ONE\n    /// );\n    /// ```\n    pub fn abs_negative_zero_ref(&self) -> Self {\n        match self {\n            float_negative_zero!() => float_zero!(),\n            x => x.clone(),\n        }\n    }\n\n    /// If `self` is negative zero, replaces it with positive zero; otherwise, does nothing.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// let mut x = Float::NAN;\n    /// x.abs_negative_zero_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::NAN));\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.abs_negative_zero_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.abs_negative_zero_assign();\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::ZERO;\n    /// x.abs_negative_zero_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::ZERO));\n    ///\n    /// let mut x = Float::NEGATIVE_ZERO;\n    /// x.abs_negative_zero_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::ZERO));\n    ///\n    /// let mut x = Float::ONE;\n    /// x.abs_negative_zero_assign();\n    /// assert_eq!(x, Float::ONE);\n    ///\n    /// let mut x = Float::NEGATIVE_ONE;\n    /// x.abs_negative_zero_assign();\n    /// assert_eq!(x, Float::NEGATIVE_ONE);\n    /// ```\n    pub const fn abs_negative_zero_assign(&mut self) {\n        if let Self(Zero { sign }) = self {\n            *sign = true;\n        }\n    }\n}\n\nimpl Abs for Float {\n    type Output = Self;\n\n    /// Takes the absolute value of a [`Float`], taking the [`Float`] by value.\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN}) = \\text{NaN}$\n    /// - $f(\\infty) = f(-\\infty) = \\infty$\n    /// - $f(0.0) = f(-0.0) = 0.0$\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Abs;\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NAN.abs()),\n    ///     ComparableFloat(Float::NAN)\n    /// );\n    /// assert_eq!(Float::INFINITY.abs(), Float::INFINITY);\n    /// assert_eq!(Float::NEGATIVE_INFINITY.abs(), Float::INFINITY);\n    /// assert_eq!(\n    ///     ComparableFloat(Float::ZERO.abs()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NEGATIVE_ZERO.abs()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(Float::ONE.abs(), Float::ONE);\n    /// assert_eq!(Float::NEGATIVE_ONE.abs(), Float::ONE);\n    /// ```\n    #[inline]\n    fn abs(mut self) -> Self {\n        self.abs_assign();\n        self\n    }\n}\n\nimpl Abs for &Float {\n    type Output = Float;\n\n    /// Takes the absolute value of a [`Float`], taking the [`Float`] by reference.\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN}) = \\text{NaN}$\n    /// - $f(\\infty) = f(-\\infty) = \\infty$\n    /// - $f(0.0) = f(-0.0) = 0.0$\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Abs;\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(\n    ///     ComparableFloat((&Float::NAN).abs()),\n    ///     ComparableFloat(Float::NAN)\n    /// );\n    /// assert_eq!((&Float::INFINITY).abs(), Float::INFINITY);\n    /// assert_eq!((&Float::NEGATIVE_INFINITY).abs(), Float::INFINITY);\n    /// assert_eq!(\n    ///     ComparableFloat((&Float::ZERO).abs()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat((&Float::NEGATIVE_ZERO).abs()),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!((&Float::ONE).abs(), Float::ONE);\n    /// assert_eq!((&Float::NEGATIVE_ONE).abs(), Float::ONE);\n    /// ```\n    fn abs(self) -> Float {\n        match self {\n            float_nan!() => float_nan!(),\n            float_either_infinity!() => float_infinity!(),\n            float_either_zero!() => float_zero!(),\n            Float(Finite {\n                exponent,\n                precision,\n                significand,\n                ..\n            }) => Float(Finite {\n                sign: true,\n                exponent: *exponent,\n                precision: *precision,\n                significand: significand.clone(),\n            }),\n        }\n    }\n}\n\nimpl AbsAssign for Float {\n    /// Replaces a [`Float`] with its absolute value.\n    ///\n    /// $$\n    /// x \\gets |x|.\n    /// $$\n    ///\n    /// Special cases:\n    /// - $\\text{NaN} \\gets \\text{NaN}$\n    /// - $\\infty \\gets \\infty$\n    /// - $-\\infty \\gets \\infty$\n    /// - $0.0 \\gets 0.0$\n    /// - $-0.0 \\gets 0.0$\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsAssign;\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// let mut x = Float::NAN;\n    /// x.abs_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::NAN));\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.abs_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.abs_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::ZERO;\n    /// x.abs_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::ZERO));\n    ///\n    /// let mut x = Float::NEGATIVE_ZERO;\n    /// x.abs_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::ZERO));\n    ///\n    /// let mut x = Float::ONE;\n    /// x.abs_assign();\n    /// assert_eq!(x, Float::ONE);\n    ///\n    /// let mut x = Float::NEGATIVE_ONE;\n    /// x.abs_assign();\n    /// assert_eq!(x, Float::ONE);\n    /// ```\n    fn abs_assign(&mut self) {\n        if let Self(Infinity { sign } | Zero { sign } | Finite { sign, .. }) = self {\n            *sign = true;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 2001, 2003-2022 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{\n    Float, float_either_zero, float_infinity, float_nan, float_negative_infinity,\n    float_negative_zero, float_zero,\n};\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse core::mem::swap;\nuse core::ops::{Add, AddAssign};\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase2, IsPowerOf2, NegAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::{ExactFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::{NotAssign, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_add::{\n    add_float_significands_in_place, add_float_significands_in_place_ref,\n    add_float_significands_ref_ref,\n};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::natural::arithmetic::float_sub::{\n    sub_float_significands_in_place, sub_float_significands_in_place_ref,\n    sub_float_significands_ref_ref,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\n// x and y must be finite, nonzero, and not sum to zero\nfn float_rational_sum_exponent_range(x: &Float, y: &Rational) -> (i64, i64) {\n    let log_x_abs = i64::from(x.get_exponent().unwrap() - 1);\n    let log_y_abs = y.floor_log_base_2_abs();\n    let m = max(log_x_abs, log_y_abs);\n    if (*x > 0) == (*y > 0) {\n        (m, m + 1)\n    } else if log_x_abs.abs_diff(log_y_abs) > 1 {\n        (m - 1, m)\n    } else {\n        let mut log_x_denominator = i64::exact_from(x.get_prec().unwrap())\n            .saturating_sub(log_x_abs)\n            .saturating_sub(1);\n        if log_x_denominator < 0 {\n            log_x_denominator = 0;\n        }\n        let log_y_denominator = i64::exact_from(y.denominator_ref().ceiling_log_base_2());\n        let min_exp = log_x_denominator\n            .checked_neg()\n            .unwrap()\n            .checked_sub(log_y_denominator)\n            .unwrap();\n        if log_x_abs == log_y_abs {\n            (min_exp, m - 1)\n        } else {\n            (min_exp, m)\n        }\n    }\n}\n\n// x and y must be finite, nonzero, and not sum to zero\nfn float_rational_sum_sign(x: &Float, y: &Rational) -> bool {\n    match ((*x > 0), (*y > 0)) {\n        (true, true) => true,\n        (false, false) => false,\n        _ => {\n            if x.gt_abs(y) {\n                *x > 0\n            } else {\n                *y > 0\n            }\n        }\n    }\n}\n\nfn add_rational_prec_round_naive_ref_val(\n    x: &Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (x @ Float(NaN | Infinity { .. }), _) => (x.clone(), Equal),\n        (float_negative_zero!(), y) => {\n            if y == 0u32 {\n                (float_negative_zero!(), Equal)\n            } else {\n                Float::from_rational_prec_round(y, prec, rm)\n            }\n        }\n        (float_zero!(), y) => Float::from_rational_prec_round(y, prec, rm),\n        (x, y) => {\n            let (mut sum, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) + y, prec, rm);\n            if rm == Floor && sum == 0u32 {\n                sum.neg_assign();\n            }\n            (sum, o)\n        }\n    }\n}\n\nfn add_rational_prec_round_naive_ref_ref(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (x @ Float(NaN | Infinity { .. }), _) => (x.clone(), Equal),\n        (float_negative_zero!(), y) => {\n            if *y == 0u32 {\n                (float_negative_zero!(), Equal)\n            } else {\n                Float::from_rational_prec_round_ref(y, prec, rm)\n            }\n        }\n        (float_zero!(), y) => Float::from_rational_prec_round_ref(y, prec, rm),\n        (x, y) => {\n            let (mut sum, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) + y, prec, rm);\n            if rm == Floor && sum == 0u32 {\n                sum.neg_assign();\n            }\n            (sum, o)\n        }\n    }\n}\n\nimpl Float {\n    pub(crate) fn add_prec_round_assign_helper(\n        &mut self,\n        other: Self,\n        prec: u64,\n        rm: RoundingMode,\n        subtract: bool,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other, subtract) {\n            (float_nan!(), _, _)\n            | (_, float_nan!(), _)\n            | (float_infinity!(), float_negative_infinity!(), false)\n            | (float_negative_infinity!(), float_infinity!(), false)\n            | (float_infinity!(), float_infinity!(), true)\n            | (float_negative_infinity!(), float_negative_infinity!(), true) => {\n                *self = float_nan!();\n                Equal\n            }\n            (float_infinity!(), _, _)\n            | (_, float_infinity!(), false)\n            | (_, float_negative_infinity!(), true) => {\n                *self = float_infinity!();\n                Equal\n            }\n            (float_negative_infinity!(), _, _)\n            | (_, float_negative_infinity!(), false)\n            | (_, float_infinity!(), true) => {\n                *self = float_negative_infinity!();\n                Equal\n            }\n            (float_zero!(), float_negative_zero!(), false)\n            | (float_negative_zero!(), float_zero!(), false)\n            | (float_zero!(), float_zero!(), true)\n            | (float_negative_zero!(), float_negative_zero!(), true) => {\n                *self = if rm == Floor {\n                    float_negative_zero!()\n                } else {\n                    float_zero!()\n                };\n                Equal\n            }\n            (float_either_zero!(), mut z, subtract) => {\n                if subtract {\n                    z.neg_assign();\n                }\n                let o = z.set_prec_round(prec, rm);\n                *self = z;\n                o\n            }\n            (z, float_either_zero!(), _) => z.set_prec_round(prec, rm),\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: mut y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: mut y,\n                }),\n                subtract,\n            ) => {\n                if subtract {\n                    y_sign.not_assign();\n                }\n                let (o, swapped) = if *x_sign == y_sign {\n                    let (o, swapped) = add_float_significands_in_place(\n                        x,\n                        x_exp,\n                        *x_prec,\n                        &mut y,\n                        y_exp,\n                        y_prec,\n                        prec,\n                        if *x_sign { rm } else { -rm },\n                    );\n                    if *x_exp > Self::MAX_EXPONENT {\n                        return match (*x_sign, rm) {\n                            (_, Exact) => panic!(\"Inexact float addition\"),\n                            (true, Ceiling | Up | Nearest) => {\n                                *self = float_infinity!();\n                                Greater\n                            }\n                            (true, _) => {\n                                *self = Self::max_finite_value_with_prec(prec);\n                                Less\n                            }\n                            (false, Floor | Up | Nearest) => {\n                                *self = float_negative_infinity!();\n                                Less\n                            }\n                            (false, _) => {\n                                *self = -Self::max_finite_value_with_prec(prec);\n                                Greater\n                            }\n                        };\n                    }\n                    (o, swapped)\n                } else {\n                    let (o, swapped, neg) = sub_float_significands_in_place(\n                        x,\n                        x_exp,\n                        *x_prec,\n                        &mut y,\n                        y_exp,\n                        y_prec,\n                        prec,\n                        if *x_sign { rm } else { -rm },\n                    );\n                    if *x_exp < Self::MIN_EXPONENT {\n                        let sign = *x_sign != neg;\n                        return if rm == Nearest\n                            && *x_exp == Self::MIN_EXPONENT - 1\n                            && (o == Less\n                                || !(if swapped {\n                                    y.is_power_of_2()\n                                } else {\n                                    x.is_power_of_2()\n                                }))\n                        {\n                            if sign {\n                                *self = Self::min_positive_value_prec(prec);\n                                Greater\n                            } else {\n                                *self = -Self::min_positive_value_prec(prec);\n                                Less\n                            }\n                        } else {\n                            match (sign, rm) {\n                                (_, Exact) => panic!(\"Inexact float subtraction\"),\n                                (true, Ceiling | Up) => {\n                                    *self = Self::min_positive_value_prec(prec);\n                                    Greater\n                                }\n                                (true, _) => {\n                                    *self = float_zero!();\n                                    Less\n                                }\n                                (false, Floor | Up) => {\n                                    *self = -Self::min_positive_value_prec(prec);\n                                    Less\n                                }\n                                (false, _) => {\n                                    *self = float_negative_zero!();\n                                    Greater\n                                }\n                            }\n                        };\n                    }\n                    if *x_exp > Self::MAX_EXPONENT {\n                        return match (*x_sign != neg, rm) {\n                            (_, Exact) => panic!(\"Inexact float subtraction\"),\n                            (true, Ceiling | Up | Nearest) => {\n                                *self = float_infinity!();\n                                Greater\n                            }\n                            (false, Floor | Up | Nearest) => {\n                                *self = float_negative_infinity!();\n                                Less\n                            }\n                            _ => panic!(\"Invalid state\"),\n                        };\n                    }\n                    if *x == 0u32 {\n                        *self = if rm == Floor {\n                            float_negative_zero!()\n                        } else {\n                            float_zero!()\n                        };\n                        return o;\n                    }\n                    if neg {\n                        x_sign.not_assign();\n                    }\n                    (o, swapped)\n                };\n                if swapped {\n                    swap(x, &mut y);\n                }\n                *x_prec = prec;\n                if *x_sign { o } else { o.reverse() }\n            }\n        }\n    }\n\n    pub(crate) fn add_prec_round_assign_ref_helper(\n        &mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n        subtract: bool,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other, subtract) {\n            (x @ float_nan!(), _, _)\n            | (x, float_nan!(), _)\n            | (x @ float_infinity!(), float_negative_infinity!(), false)\n            | (x @ float_negative_infinity!(), float_infinity!(), false)\n            | (x @ float_infinity!(), float_infinity!(), true)\n            | (x @ float_negative_infinity!(), float_negative_infinity!(), true) => {\n                *x = float_nan!();\n                Equal\n            }\n            (x @ float_infinity!(), _, _)\n            | (x, float_infinity!(), false)\n            | (x, float_negative_infinity!(), true) => {\n                *x = float_infinity!();\n                Equal\n            }\n            (x @ float_negative_infinity!(), _, _)\n            | (x, float_negative_infinity!(), false)\n            | (x, float_infinity!(), true) => {\n                *x = float_negative_infinity!();\n                Equal\n            }\n            (x @ float_zero!(), float_negative_zero!(), false)\n            | (x @ float_negative_zero!(), float_zero!(), false)\n            | (x @ float_zero!(), float_zero!(), true)\n            | (x @ float_negative_zero!(), float_negative_zero!(), true) => {\n                *x = if rm == Floor {\n                    float_negative_zero!()\n                } else {\n                    float_zero!()\n                };\n                Equal\n            }\n            (x @ float_either_zero!(), z, subtract) => {\n                let (new_x, mut o) =\n                    Self::from_float_prec_round_ref(z, prec, if subtract { -rm } else { rm });\n                *x = new_x;\n                if subtract {\n                    x.neg_assign();\n                    o = o.reverse();\n                }\n                o\n            }\n            (z, float_either_zero!(), _) => z.set_prec_round(prec, rm),\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: y,\n                }),\n                subtract,\n            ) => {\n                let mut y_sign = *y_sign;\n                if subtract {\n                    y_sign.not_assign();\n                }\n                let o = if *x_sign == y_sign {\n                    let o = add_float_significands_in_place_ref(\n                        x,\n                        x_exp,\n                        *x_prec,\n                        y,\n                        *y_exp,\n                        *y_prec,\n                        prec,\n                        if *x_sign { rm } else { -rm },\n                    );\n                    if *x_exp > Self::MAX_EXPONENT {\n                        return match (x_sign, rm) {\n                            (_, Exact) => panic!(\"Inexact float addition\"),\n                            (true, Ceiling | Up | Nearest) => {\n                                *self = float_infinity!();\n                                Greater\n                            }\n                            (true, _) => {\n                                *self = Self::max_finite_value_with_prec(prec);\n                                Less\n                            }\n                            (false, Floor | Up | Nearest) => {\n                                *self = float_negative_infinity!();\n                                Less\n                            }\n                            (false, _) => {\n                                *self = -Self::max_finite_value_with_prec(prec);\n                                Greater\n                            }\n                        };\n                    }\n                    o\n                } else {\n                    let (o, neg) = sub_float_significands_in_place_ref(\n                        x,\n                        x_exp,\n                        *x_prec,\n                        y,\n                        *y_exp,\n                        *y_prec,\n                        prec,\n                        if *x_sign { rm } else { -rm },\n                    );\n                    if *x_exp < Self::MIN_EXPONENT {\n                        let sign = *x_sign != neg;\n                        return if rm == Nearest\n                            && *x_exp == Self::MIN_EXPONENT - 1\n                            && (o == Less || !x.is_power_of_2())\n                        {\n                            if sign {\n                                *self = Self::min_positive_value_prec(prec);\n                                Greater\n                            } else {\n                                *self = -Self::min_positive_value_prec(prec);\n                                Less\n                            }\n                        } else {\n                            match (sign, rm) {\n                                (_, Exact) => panic!(\"Inexact float subtraction\"),\n                                (true, Ceiling | Up) => {\n                                    *self = Self::min_positive_value_prec(prec);\n                                    Greater\n                                }\n                                (true, _) => {\n                                    *self = float_zero!();\n                                    Less\n                                }\n                                (false, Floor | Up) => {\n                                    *self = -Self::min_positive_value_prec(prec);\n                                    Less\n                                }\n                                (false, _) => {\n                                    *self = float_negative_zero!();\n                                    Greater\n                                }\n                            }\n                        };\n                    }\n                    if *x_exp > Self::MAX_EXPONENT {\n                        return match (*x_sign != neg, rm) {\n                            (_, Exact) => panic!(\"Inexact float subtraction\"),\n                            (true, Ceiling | Up | Nearest) => {\n                                *self = float_infinity!();\n                                Greater\n                            }\n                            (false, Floor | Up | Nearest) => {\n                                *self = float_negative_infinity!();\n                                Less\n                            }\n                            _ => panic!(\"Invalid state\"),\n                        };\n                    }\n                    if *x == 0u32 {\n                        *self = if rm == Floor {\n                            float_negative_zero!()\n                        } else {\n                            float_zero!()\n                        };\n                        return o;\n                    }\n                    if neg {\n                        x_sign.not_assign();\n                    }\n                    o\n                };\n                *x_prec = prec;\n                if *x_sign { o } else { o.reverse() }\n            }\n        }\n    }\n\n    pub(crate) fn add_prec_round_ref_ref_helper(\n        &self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n        subtract: bool,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other, subtract) {\n            (float_nan!(), _, _)\n            | (_, float_nan!(), _)\n            | (float_infinity!(), float_negative_infinity!(), false)\n            | (float_negative_infinity!(), float_infinity!(), false)\n            | (float_infinity!(), float_infinity!(), true)\n            | (float_negative_infinity!(), float_negative_infinity!(), true) => {\n                (float_nan!(), Equal)\n            }\n            (float_infinity!(), _, _)\n            | (_, float_infinity!(), false)\n            | (_, float_negative_infinity!(), true) => (float_infinity!(), Equal),\n            (float_negative_infinity!(), _, _)\n            | (_, float_negative_infinity!(), false)\n            | (_, float_infinity!(), true) => (float_negative_infinity!(), Equal),\n            (float_zero!(), float_negative_zero!(), false)\n            | (float_negative_zero!(), float_zero!(), false)\n            | (float_zero!(), float_zero!(), true)\n            | (float_negative_zero!(), float_negative_zero!(), true) => (\n                if rm == Floor {\n                    float_negative_zero!()\n                } else {\n                    float_zero!()\n                },\n                Equal,\n            ),\n            (float_either_zero!(), z, subtract) => {\n                let (mut x, mut o) =\n                    Self::from_float_prec_round_ref(z, prec, if subtract { -rm } else { rm });\n                if subtract {\n                    x.neg_assign();\n                    o = o.reverse();\n                }\n                (x, o)\n            }\n            (z, float_either_zero!(), _) => Self::from_float_prec_round_ref(z, prec, rm),\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: y,\n                }),\n                subtract,\n            ) => {\n                let mut y_sign = *y_sign;\n                if subtract {\n                    y_sign.not_assign();\n                }\n                if *x_sign == y_sign {\n                    let (sum, sum_exp, o) = add_float_significands_ref_ref(\n                        x,\n                        *x_exp,\n                        *x_prec,\n                        y,\n                        *y_exp,\n                        *y_prec,\n                        prec,\n                        if *x_sign { rm } else { -rm },\n                    );\n                    if sum_exp > Self::MAX_EXPONENT {\n                        return match (*x_sign, rm) {\n                            (_, Exact) => panic!(\"Inexact float addition\"),\n                            (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                            (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                            (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                            (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                        };\n                    }\n                    let sum = Self(Finite {\n                        sign: *x_sign,\n                        exponent: sum_exp,\n                        precision: prec,\n                        significand: sum,\n                    });\n                    (sum, if *x_sign { o } else { o.reverse() })\n                } else {\n                    let (diff, diff_exp, o, neg) = sub_float_significands_ref_ref(\n                        x,\n                        *x_exp,\n                        *x_prec,\n                        y,\n                        *y_exp,\n                        *y_prec,\n                        prec,\n                        if *x_sign { rm } else { -rm },\n                    );\n                    if diff_exp < Self::MIN_EXPONENT {\n                        let sign = *x_sign != neg;\n                        return if rm == Nearest\n                            && diff_exp == Self::MIN_EXPONENT - 1\n                            && (o == Less || !diff.is_power_of_2())\n                        {\n                            if sign {\n                                (Self::min_positive_value_prec(prec), Greater)\n                            } else {\n                                (-Self::min_positive_value_prec(prec), Less)\n                            }\n                        } else {\n                            match (sign, rm) {\n                                (_, Exact) => panic!(\"Inexact float subtraction\"),\n                                (true, Ceiling | Up) => {\n                                    (Self::min_positive_value_prec(prec), Greater)\n                                }\n                                (true, _) => (float_zero!(), Less),\n                                (false, Floor | Up) => (-Self::min_positive_value_prec(prec), Less),\n                                (false, _) => (float_negative_zero!(), Greater),\n                            }\n                        };\n                    }\n                    if diff_exp > Self::MAX_EXPONENT {\n                        return match (*x_sign != neg, rm) {\n                            (_, Exact) => panic!(\"Inexact float subtraction\"),\n                            (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                            (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                            _ => panic!(\"Invalid state\"),\n                        };\n                    }\n                    if diff == 0u32 {\n                        (\n                            if rm == Floor {\n                                float_negative_zero!()\n                            } else {\n                                float_zero!()\n                            },\n                            o,\n                        )\n                    } else {\n                        let diff = Self(Finite {\n                            sign: *x_sign != neg,\n                            exponent: diff_exp,\n                            precision: prec,\n                            significand: diff,\n                        });\n                        (diff, if *x_sign == neg { o.reverse() } else { o })\n                    }\n                }\n            }\n        }\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the specified precision and with the specified\n    /// rounding mode. Both [`Float`]s are taken by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded sum is less than, equal to, or greater than the exact sum.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,-\\infty,p,m)=f(-\\infty,\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p,m)=0.0$\n    /// - $f(-0.0,-0.0,p,m)=-0.0$\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_prec`] instead. If you\n    /// know that your target precision is the maximum of the precisions of the two inputs, consider\n    /// using [`Float::add_round`] instead. If both of these things are true, consider using `+`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round(Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round(Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"6.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round(Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round(Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round(Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.85988\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round(Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec_round(mut self, other: Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.add_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the specified precision and with the specified\n    /// rounding mode. The first [`Float`] is taken by value and the second by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,-\\infty,p,m)=f(-\\infty,\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p,m)=0.0$\n    /// - $f(-0.0,-0.0,p,m)=-0.0$\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_prec_val_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::add_round_val_ref`] instead. If both of these things are true,\n    /// consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_val_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_val_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"6.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_val_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_val_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_val_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.85988\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_val_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec_round_val_ref(\n        mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.add_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the specified precision and with the specified\n    /// rounding mode. The first [`Float`] is taken by reference and the second by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,-\\infty,p,m)=f(-\\infty,\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p,m)=0.0$\n    /// - $f(-0.0,-0.0,p,m)=-0.0$\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_prec_ref_val`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::add_round_ref_val`] instead. If both of these things are true,\n    /// consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_val_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_val(Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"6.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_val(Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_val(Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_val(Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.85988\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_val(Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec_round_ref_val(\n        &self,\n        mut other: Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = other.add_prec_round_assign_ref(self, prec, rm);\n        (other, o)\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the specified precision and with the specified\n    /// rounding mode. Both [`Float`]s are taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded sum is less than, equal to, or greater than the exact sum.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,-\\infty,p,m)=f(-\\infty,\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p,m)=0.0$\n    /// - $f(-0.0,-0.0,p,m)=-0.0$\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,p,m)=f(-0.0,0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_prec_ref_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::add_round_ref_ref`] instead. If both of these things are true,\n    /// consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"6.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.85988\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_round_ref_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec_round_ref_ref(\n        &self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        self.add_prec_round_ref_ref_helper(other, prec, rm, false)\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// Both [`Float`]s are taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded sum is less than, equal to, or greater than the exact sum. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,-\\infty,p)=f(-\\infty,\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p)=0.0$\n    /// - $f(-0.0,-0.0,p)=-0.0$\n    /// - $f(0.0,-0.0,p)=f(-0.0,0.0,p)=0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_round`] instead. If you know that your target precision is the maximum of\n    /// the precisions of the two inputs, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec(Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec(Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec(self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.add_prec_round(other, prec, Nearest)\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// The first [`Float`] is taken by value and the second by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,-\\infty,p)=f(-\\infty,\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p)=0.0$\n    /// - $f(-0.0,-0.0,p)=-0.0$\n    /// - $f(0.0,-0.0,p)=f(-0.0,0.0,p)=0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_round_val_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_val_ref(&Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_prec_val_ref(&Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec_val_ref(self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.add_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// The first [`Float`] is taken by reference and the second by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,-\\infty,p)=f(-\\infty,\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p)=0.0$\n    /// - $f(-0.0,-0.0,p)=-0.0$\n    /// - $f(0.0,-0.0,p)=f(-0.0,0.0,p)=0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_round_ref_val`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = (&Float::from(PI)).add_prec_ref_val(Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = (&Float::from(PI)).add_prec_ref_val(Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec_ref_val(&self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.add_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Adds two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// Both [`Float`]s are taken by reference. An [`Ordering`] is also returned, indicating whether\n    /// the rounded sum is less than, equal to, or greater than the exact sum. Although `NaN`s are\n    /// not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,-\\infty,p)=f(-\\infty,\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,p)=0.0$\n    /// - $f(-0.0,-0.0,p)=-0.0$\n    /// - $f(0.0,-0.0,p)=f(-0.0,0.0,p)=0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_round_ref_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = (&Float::from(PI)).add_prec_ref_ref(&Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"5.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = (&Float::from(PI)).add_prec_ref_ref(&Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"5.85987\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.add_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Adds two [`Float`]s, rounding the result with the specified rounding mode. Both [`Float`]s\n    /// are taken by value. An [`Ordering`] is also returned, indicating whether the rounded sum is\n    /// less than, equal to, or greater than the exact sum. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,-\\infty,m)=f(-\\infty,\\infty,m)= \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,m)=0.0$\n    /// - $f(-0.0,-0.0,m)=-0.0$\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(0.0,x,m)=f(x,0.0,m)=f(-0.0,x,m)=f(x,-0.0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::add_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `+`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_round(Float::from(E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_round(Float::from(E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_round(Float::from(E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_round(self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round(other, prec, rm)\n    }\n\n    /// Adds two [`Float`]s, rounding the result with the specified rounding mode. The first\n    /// [`Float`] is taken by value and the second by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded sum is less than, equal to, or greater than the exact sum.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,-\\infty,m)=f(-\\infty,\\infty,m)= \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,m)=0.0$\n    /// - $f(-0.0,-0.0,m)=-0.0$\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(0.0,x,m)=f(x,0.0,m)=f(-0.0,x,m)=f(x,-0.0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::add_prec_round_val_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `+`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_round_val_ref(&Float::from(E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_round_val_ref(&Float::from(E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_round_val_ref(&Float::from(E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_round_val_ref(self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Adds two [`Float`]s, rounding the result with the specified rounding mode. The first\n    /// [`Float`] is taken by reference and the second by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded sum is less than, equal to, or greater than the exact sum.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,-\\infty,m)=f(-\\infty,\\infty,m)= \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,m)=0.0$\n    /// - $f(-0.0,-0.0,m)=-0.0$\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(0.0,x,m)=f(x,0.0,m)=f(-0.0,x,m)=f(x,-0.0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::add_prec_round_ref_val`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `+`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = (&Float::from(PI)).add_round_ref_val(Float::from(E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = (&Float::from(PI)).add_round_ref_val(Float::from(E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = (&Float::from(PI)).add_round_ref_val(Float::from(E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_round_ref_val(&self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Adds two [`Float`]s, rounding the result with the specified rounding mode. Both [`Float`]s\n    /// are taken by reference. An [`Ordering`] is also returned, indicating whether the rounded sum\n    /// is less than, equal to, or greater than the exact sum. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,-\\infty,m)=f(-\\infty,\\infty,m)= \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0,m)=0.0$\n    /// - $f(-0.0,-0.0,m)=-0.0$\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,-0.0,m)=f(-0.0,0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(0.0,x,m)=f(x,0.0,m)=f(-0.0,x,m)=f(x,-0.0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::add_prec_round_ref_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `+`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_round_ref_ref(&Float::from(E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_round_ref_ref(&Float::from(E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_round_ref_ref(&Float::from(E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_round_ref_ref(&self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Adds a [`Float`] to a [`Float`] in place, rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] on the right-hand side is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_prec_assign`] instead. If\n    /// you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::add_round_assign`] instead. If both of these things are true,\n    /// consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_round_assign(Float::from(E), 5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"5.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_round_assign(Float::from(E), 5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"6.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_round_assign(Float::from(E), 5, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"5.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_round_assign(Float::from(E), 20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"5.85987\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_prec_round_assign(Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"5.85988\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_round_assign(Float::from(E), 20, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"5.85987\");\n    /// ```\n    #[inline]\n    pub fn add_prec_round_assign(&mut self, other: Self, prec: u64, rm: RoundingMode) -> Ordering {\n        self.add_prec_round_assign_helper(other, prec, rm, false)\n    }\n\n    /// Adds a [`Float`] to a [`Float`] in place, rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] on the right-hand side is taken by\n    /// reference. An [`Ordering`] is returned, indicating whether the rounded sum is less than,\n    /// equal to, or greater than the exact sum. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_prec_assign_ref`]\n    /// instead. If you know that your target precision is the maximum of the precisions of the two\n    /// inputs, consider using [`Float::add_round_assign_ref`] instead. If both of these things are\n    /// true, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_round_assign_ref(&Float::from(E), 5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"5.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_prec_round_assign_ref(&Float::from(E), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"6.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_prec_round_assign_ref(&Float::from(E), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"5.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_prec_round_assign_ref(&Float::from(E), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"5.85987\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_prec_round_assign_ref(&Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"5.85988\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_prec_round_assign_ref(&Float::from(E), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"5.85987\");\n    /// ```\n    #[inline]\n    pub fn add_prec_round_assign_ref(\n        &mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        self.add_prec_round_assign_ref_helper(other, prec, rm, false)\n    }\n\n    /// Adds a [`Float`] to a [`Float`] in place, rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] on the right-hand side is taken by value. An [`Ordering`]\n    /// is returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_round_assign`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_assign(Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"5.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_assign(Float::from(E), 20), Less);\n    /// assert_eq!(x.to_string(), \"5.85987\");\n    /// ```\n    #[inline]\n    pub fn add_prec_assign(&mut self, other: Self, prec: u64) -> Ordering {\n        self.add_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Adds a [`Float`] to a [`Float`] in place, rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] on the right-hand side is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_round_assign_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_assign_ref(&Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"5.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_prec_assign_ref(&Float::from(E), 20), Less);\n    /// assert_eq!(x.to_string(), \"5.85987\");\n    /// ```\n    #[inline]\n    pub fn add_prec_assign_ref(&mut self, other: &Self, prec: u64) -> Ordering {\n        self.add_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Adds a [`Float`] to a [`Float`] in place, rounding the result with the specified rounding\n    /// mode. The [`Float`] on the right-hand side is taken by value. An [`Ordering`] is returned,\n    /// indicating whether the rounded sum is less than, equal to, or greater than the exact sum.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::add_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::add_prec_round_assign`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `+=`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_round_assign(Float::from(E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_round_assign(Float::from(E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"5.859874482048839\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_round_assign(Float::from(E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    /// ```\n    #[inline]\n    pub fn add_round_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_assign(other, prec, rm)\n    }\n\n    /// Adds a [`Float`] to a [`Float`] in place, rounding the result with the specified rounding\n    /// mode. The [`Float`] on the right-hand side is taken by reference. An [`Ordering`] is\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::add_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::add_prec_round_assign_ref`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_round_assign_ref(&Float::from(E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_round_assign_ref(&Float::from(E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"5.859874482048839\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.add_round_assign_ref(&Float::from(E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    /// ```\n    #[inline]\n    pub fn add_round_assign_ref(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_assign_ref(other, prec, rm)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the specified precision and with\n    /// the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_rational_prec`] instead.\n    /// If you know that your target precision is the precision of the [`Float`] input, consider\n    /// using [`Float::add_rational_round`] instead. If both of these things are true, consider\n    /// using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"3.4\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"3.474922\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_round(\n        mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.add_rational_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the specified precision and with\n    /// the specified rounding mode. The [`Float`] is taken by value and the [`Rational`] by\n    /// reference. An  [`Ordering`] is also returned, indicating whether the rounded sum is less\n    /// than, equal to, or greater than the exact sum. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_rational_prec_val_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::add_rational_round_val_ref`] instead. If both of these things are\n    /// true, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.4\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474922\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_round_val_ref(\n        mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.add_rational_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the specified precision and with\n    /// the specified rounding mode. The [`Float`] is taken by reference and the [`Rational`] by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded sum is less than,\n    /// equal to, or greater than the exact sum. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_rational_prec_ref_val`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::add_rational_round_ref_val`] instead. If both of these things are\n    /// true, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.4\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474922\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_round_ref_val(\n        &self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _) => (float_nan!(), Equal),\n            (float_infinity!(), _) => (float_infinity!(), Equal),\n            (float_negative_infinity!(), _) => (float_negative_infinity!(), Equal),\n            (float_negative_zero!(), y) => {\n                if y == 0u32 {\n                    (float_negative_zero!(), Equal)\n                } else {\n                    Self::from_rational_prec_round(y, prec, rm)\n                }\n            }\n            (float_zero!(), y) => Self::from_rational_prec_round(y, prec, rm),\n            (_, y) if y == 0 => Self::from_float_prec_round_ref(self, prec, rm),\n            (x, y) => {\n                if (*x > 0) != (y > 0) && x.eq_abs(&y) {\n                    return (\n                        if rm == Floor {\n                            float_negative_zero!()\n                        } else {\n                            float_zero!()\n                        },\n                        Equal,\n                    );\n                }\n                let (min_exponent, max_exponent) = float_rational_sum_exponent_range(x, &y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float addition\");\n                    return match (float_rational_sum_sign(x, &y), rm) {\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    return add_rational_prec_round_naive_ref_val(x, y, prec, rm);\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                // working_prec grows as O([(1 + sqrt(3)) / 2] ^ n) ≈ O(1.366 ^ n).\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(&y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can add it directly!\n                        return self.add_prec_round_ref_val(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let mut t = x.add_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            let o = t.set_prec_round(prec, rm);\n                            return (t, o);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the specified precision and with\n    /// the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by reference.\n    /// An [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to,\n    /// or greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,-x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_rational_prec_ref_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::add_rational_round_ref_ref`] instead. If both of these things are\n    /// true, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.4\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474922\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"3.474926\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_round_ref_ref(\n        &self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _) => (float_nan!(), Equal),\n            (float_infinity!(), _) => (float_infinity!(), Equal),\n            (float_negative_infinity!(), _) => (float_negative_infinity!(), Equal),\n            (float_negative_zero!(), y) => {\n                if *y == 0u32 {\n                    (float_negative_zero!(), Equal)\n                } else {\n                    Self::from_rational_prec_round_ref(y, prec, rm)\n                }\n            }\n            (float_zero!(), y) => Self::from_rational_prec_round_ref(y, prec, rm),\n            (_, y) if *y == 0 => Self::from_float_prec_round_ref(self, prec, rm),\n            (x, y) => {\n                if (*x > 0) != (*y > 0) && x.eq_abs(y) {\n                    return (\n                        if rm == Floor {\n                            float_negative_zero!()\n                        } else {\n                            float_zero!()\n                        },\n                        Equal,\n                    );\n                }\n                let (min_exponent, max_exponent) = float_rational_sum_exponent_range(x, y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float addition\");\n                    return match (float_rational_sum_sign(x, y), rm) {\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    return add_rational_prec_round_naive_ref_ref(x, y, prec, rm);\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                // working_prec grows as O([(1 + sqrt(3)) / 2] ^ n) ≈ O(1.366 ^ n).\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can add it directly!\n                        return self.add_prec_round_ref_val(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let mut t = x.add_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            let o = t.set_prec_round(prec, rm);\n                            return (t, o);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_round`] instead. If you know that your target precision is the\n    /// precision of the [`Float`] input, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec(Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec(Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"4.641594\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec(self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.add_rational_prec_round(other, prec, Nearest)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by value and the [`Rational`] by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_round_val_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_val_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_val_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"4.641594\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_val_ref(self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.add_rational_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by reference and the [`Rational`] by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_round_ref_val`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_ref_val(Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_ref_val(Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"4.641594\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_ref_val(&self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.add_rational_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,-x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_round_ref_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_ref_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_prec_ref_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"4.641594\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_ref_ref(&self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.add_rational_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] and the [`Rational`] are both are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(0.0,x,m)=f(x,0,m)=f(-0.0,x,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::add_rational_prec_round`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).add_rational_round(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"3.474925986923129\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_rational_round(self, other: Rational, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round(other, prec, rm)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] is taken by value and the [`Rational`] by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(0.0,x,m)=f(x,0,m)=f(-0.0,x,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::add_rational_prec_round_val_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"3.474925986923129\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_rational_round_val_ref(\n        self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] is taken by reference and the [`Float`] by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(0.0,x,m)=f(x,0,m)=f(-0.0,x,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::add_rational_prec_round_ref_val`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"3.474925986923129\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_rational_round_ref_val(\n        &self,\n        other: Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Adds a [`Float`] and a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] and the [`Rational`] are both are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(0.0,x,m)=f(x,0,m)=f(-0.0,x,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,-x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::add_rational_prec_round_ref_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `+` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"3.474925986923129\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).add_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"3.474925986923125\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn add_rational_round_ref_ref(\n        &self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Adds a [`Rational`] to a [`Float`] in place, rounding the result to the specified precision\n    /// and with the specified rounding mode. The [`Rational`] is taken by value. An [`Ordering`] is\n    /// returned, indicating whether the rounded sum is less than, equal to, or greater than the\n    /// exact sum. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::add_rational_prec_assign`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::add_rational_round_assign`] instead. If both of these things are\n    /// true, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.4\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474922\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474926\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474926\");\n    /// ```\n    ///\n    /// This is mpfr_add_q from gmp_op.c, MPFR 4.2.0.\n    #[inline]\n    pub fn add_rational_prec_round_assign(\n        &mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (Self(NaN | Infinity { .. }), _) => Equal,\n            (float_negative_zero!(), y) => {\n                if y == 0u32 {\n                    Equal\n                } else {\n                    let o;\n                    (*self, o) = Self::from_rational_prec_round(y, prec, rm);\n                    o\n                }\n            }\n            (float_zero!(), y) => {\n                let o;\n                (*self, o) = Self::from_rational_prec_round(y, prec, rm);\n                o\n            }\n            (_, y) if y == 0 => self.set_prec_round(prec, rm),\n            (x, y) => {\n                if (*x > 0) != (y > 0) && x.eq_abs(&y) {\n                    *self = if rm == Floor {\n                        float_negative_zero!()\n                    } else {\n                        float_zero!()\n                    };\n                    return Equal;\n                }\n                let (min_exponent, max_exponent) = float_rational_sum_exponent_range(x, &y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float addition\");\n                    return match (float_rational_sum_sign(x, &y), rm) {\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    let (sum, o) = add_rational_prec_round_naive_ref_val(&*x, y, prec, rm);\n                    *self = sum;\n                    return o;\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(&y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can add it directly!\n                        return self.add_prec_round_assign(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let t = x.add_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            *self = t;\n                            return self.set_prec_round(prec, rm);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Adds a [`Rational`] to a [`Float`] in place, rounding the result to the specified precision\n    /// and with the specified rounding mode. The [`Rational`] is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded sum is less than, equal to, or\n    /// greater than the exact sum. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$.\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::add_rational_prec_assign_ref`] instead. If you know that your target precision is\n    /// the precision of the [`Float`] input, consider using\n    /// [`Float::add_rational_round_assign_ref`] instead. If both of these things are true, consider\n    /// using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact addition.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.4\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474922\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474926\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474926\");\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (Self(NaN | Infinity { .. }), _) => Equal,\n            (float_negative_zero!(), y) => {\n                if *y == 0u32 {\n                    Equal\n                } else {\n                    let o;\n                    (*self, o) = Self::from_rational_prec_round_ref(y, prec, rm);\n                    o\n                }\n            }\n            (float_zero!(), y) => {\n                let o;\n                (*self, o) = Self::from_rational_prec_round_ref(y, prec, rm);\n                o\n            }\n            (_, y) if *y == 0 => self.set_prec_round(prec, rm),\n            (x, y) => {\n                if (*x > 0) != (*y > 0) && x.eq_abs(y) {\n                    *self = if rm == Floor {\n                        float_negative_zero!()\n                    } else {\n                        float_zero!()\n                    };\n                    return Equal;\n                }\n                let (min_exponent, max_exponent) = float_rational_sum_exponent_range(x, y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float addition\");\n                    return match (float_rational_sum_sign(x, y), rm) {\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    let (sum, o) = add_rational_prec_round_naive_ref_ref(&*x, y, prec, rm);\n                    *self = sum;\n                    return o;\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                // working_prec grows as O([(1 + sqrt(3)) / 2] ^ n) ≈ O(1.366 ^ n).\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can add it directly!\n                        return self.add_prec_round_assign(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let t = x.add_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            *self = t;\n                            return self.set_prec_round(prec, rm);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Adds a [`Rational`] to a [`Float`] in place, rounding the result to the nearest value of the\n    /// specified precision. The [`Rational`] is taken by value. An [`Ordering`] is returned,\n    /// indicating whether the rounded sum is less than, equal to, or greater than the exact sum.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_rational_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_round_assign`] instead. If you know that your target precision is\n    /// the maximum of the precisions of the two inputs, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_assign(Rational::exact_from(1.5), 5),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"4.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_assign(Rational::exact_from(1.5), 20),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"4.641594\");\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_assign(&mut self, other: Rational, prec: u64) -> Ordering {\n        self.add_rational_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Adds a [`Rational`] to a [`Float`] in place, rounding the result to the nearest value of the\n    /// specified precision. The [`Rational`] is taken by reference. An [`Ordering`] is returned,\n    /// indicating whether the rounded sum is less than, equal to, or greater than the exact sum.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the sum is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::add_rational_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_round_assign_ref`] instead. If you know that your target\n    /// precision is the maximum of the precisions of the two inputs, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_assign_ref(&Rational::exact_from(1.5), 5),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"4.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_prec_assign_ref(&Rational::exact_from(1.5), 20),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"4.641594\");\n    /// ```\n    #[inline]\n    pub fn add_rational_prec_assign_ref(&mut self, other: &Rational, prec: u64) -> Ordering {\n        self.add_rational_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Adds a [`Rational`] to a [`Float`] in place, rounding the result with the specified rounding\n    /// mode. The [`Rational`] is taken by value. An [`Ordering`] is returned, indicating whether\n    /// the rounded sum is less than, equal to, or greater than the exact sum. Although `NaN`s are\n    /// not comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::add_rational_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::add_rational_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_round_assign(Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474925986923125\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_round_assign(Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474925986923129\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_round_assign(Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474925986923125\");\n    /// ```\n    #[inline]\n    pub fn add_rational_round_assign(&mut self, other: Rational, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_assign(other, prec, rm)\n    }\n\n    /// Adds a [`Rational`] to a [`Float`] in place, rounding the result with the specified rounding\n    /// mode. The [`Rational`] is taken by reference. An [`Ordering`] is returned, indicating\n    /// whether the rounded sum is less than, equal to, or greater than the exact sum. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function sets the [`Float`] to\n    /// `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x+y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::add_rational_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::add_rational_prec_round_assign_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `+=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474925986923125\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474925986923129\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.add_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"3.474925986923125\");\n    /// ```\n    #[inline]\n    pub fn add_rational_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> Ordering {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_assign_ref(other, prec, rm)\n    }\n}\n\nimpl Add<Self> for Float {\n    type Output = Self;\n\n    /// Adds two [`Float`]s, taking both by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the sum\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,-\\infty)=f(-\\infty,\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0)=0.0$\n    /// - $f(-0.0,-0.0)=-0.0$\n    /// - $f(0.0,-0.0)=f(-0.0,0.0)=0.0$\n    /// - $f(0.0,x)=f(x,0.0)=f(-0.0,x)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::add_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::add_round`].\n    /// If you want both of these things, consider using [`Float::add_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) + Float::NAN).is_nan());\n    /// assert_eq!(Float::from(1.5) + Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::from(1.5) + Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert!((Float::INFINITY + Float::NEGATIVE_INFINITY).is_nan());\n    ///\n    /// assert_eq!(Float::from(1.5) + Float::from(2.5), 4.0);\n    /// assert_eq!(Float::from(1.5) + Float::from(-2.5), -1.0);\n    /// assert_eq!(Float::from(-1.5) + Float::from(2.5), 1.0);\n    /// assert_eq!(Float::from(-1.5) + Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Add<&Self> for Float {\n    type Output = Self;\n\n    /// Adds two [`Float`]s, taking the first by value and the second by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the sum\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,-\\infty)=f(-\\infty,\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0)=0.0$\n    /// - $f(-0.0,-0.0)=-0.0$\n    /// - $f(0.0,-0.0)=f(-0.0,0.0)=0.0$\n    /// - $f(0.0,x)=f(x,0.0)=f(-0.0,x)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_val_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::add_round_val_ref`]. If you want both of these things, consider using\n    /// [`Float::add_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) + &Float::NAN).is_nan());\n    /// assert_eq!(Float::from(1.5) + &Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::from(1.5) + &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert!((Float::INFINITY + &Float::NEGATIVE_INFINITY).is_nan());\n    ///\n    /// assert_eq!(Float::from(1.5) + &Float::from(2.5), 4.0);\n    /// assert_eq!(Float::from(1.5) + &Float::from(-2.5), -1.0);\n    /// assert_eq!(Float::from(-1.5) + &Float::from(2.5), 1.0);\n    /// assert_eq!(Float::from(-1.5) + &Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: &Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Add<Float> for &Float {\n    type Output = Float;\n\n    /// Adds two [`Float`]s, taking the first by reference and the second by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the sum\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,-\\infty)=f(-\\infty,\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0)=0.0$\n    /// - $f(-0.0,-0.0)=-0.0$\n    /// - $f(0.0,-0.0)=f(-0.0,0.0)=0.0$\n    /// - $f(0.0,x)=f(x,0.0)=f(-0.0,x)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_ref_val`] instead. If you want to specify the output precision, consider\n    /// using [`Float::add_round_ref_val`]. If you want both of these things, consider using\n    /// [`Float::add_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) + Float::NAN).is_nan());\n    /// assert_eq!(&Float::from(1.5) + Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Float::from(1.5) + Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert!((&Float::INFINITY + Float::NEGATIVE_INFINITY).is_nan());\n    ///\n    /// assert_eq!(&Float::from(1.5) + Float::from(2.5), 4.0);\n    /// assert_eq!(&Float::from(1.5) + Float::from(-2.5), -1.0);\n    /// assert_eq!(&Float::from(-1.5) + Float::from(2.5), 1.0);\n    /// assert_eq!(&Float::from(-1.5) + Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Add<&Float> for &Float {\n    type Output = Float;\n\n    /// Adds two [`Float`]s, taking both by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the sum\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,-\\infty)=f(-\\infty,\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0.0)=0.0$\n    /// - $f(-0.0,-0.0)=-0.0$\n    /// - $f(0.0,-0.0)=f(-0.0,0.0)=0.0$\n    /// - $f(0.0,x)=f(x,0.0)=f(-0.0,x)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,-x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_ref_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::add_round_ref_ref`]. If you want both of these things, consider using\n    /// [`Float::add_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) + &Float::NAN).is_nan());\n    /// assert_eq!(&Float::from(1.5) + &Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Float::from(1.5) + &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert!((&Float::INFINITY + &Float::NEGATIVE_INFINITY).is_nan());\n    ///\n    /// assert_eq!(&Float::from(1.5) + &Float::from(2.5), 4.0);\n    /// assert_eq!(&Float::from(1.5) + &Float::from(-2.5), -1.0);\n    /// assert_eq!(&Float::from(-1.5) + &Float::from(2.5), 1.0);\n    /// assert_eq!(&Float::from(-1.5) + &Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: &Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl AddAssign<Self> for Float {\n    /// Adds a [`Float`] to a [`Float`] in place, taking the [`Float`] on the right-hand side by\n    /// value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the sum\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `+` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::add_round_assign`]. If you want both of these things, consider using\n    /// [`Float::add_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += Float::INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x += Float::NEGATIVE_INFINITY;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += Float::from(2.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += Float::from(-2.5);\n    /// assert_eq!(x, -1.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x += Float::from(2.5);\n    /// assert_eq!(x, 1.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x += Float::from(-2.5);\n    /// assert_eq!(x, -4.0);\n    /// ```\n    #[inline]\n    fn add_assign(&mut self, other: Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl AddAssign<&Self> for Float {\n    /// Adds a [`Float`] to a [`Float`] in place, taking the [`Float`] on the right-hand side by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the sum\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `+` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_prec_assign_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::add_round_assign_ref`]. If you want both of these things, consider\n    /// using [`Float::add_prec_round_assign_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += &Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += &Float::INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += &Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x += &Float::NEGATIVE_INFINITY;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += &Float::from(2.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x += &Float::from(-2.5);\n    /// assert_eq!(x, -1.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x += &Float::from(2.5);\n    /// assert_eq!(x, 1.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x += &Float::from(-2.5);\n    /// assert_eq!(x, -4.0);\n    /// ```\n    #[inline]\n    fn add_assign(&mut self, other: &Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.add_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Add<Rational> for Float {\n    type Output = Self;\n\n    /// Adds a [`Float`] and a [`Rational`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(0.0,x)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec`] instead. If you want to specify the output precision, consider\n    /// using [`Float::add_rational_round`]. If you want both of these things, consider using\n    /// [`Float::add_rational_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN + Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(Float::INFINITY + Rational::exact_from(1.5), Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY + Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(Float::from(2.5) + Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(Float::from(2.5) + Rational::exact_from(-1.5), 1.0);\n    /// assert_eq!(Float::from(-2.5) + Rational::exact_from(1.5), -1.0);\n    /// assert_eq!(Float::from(-2.5) + Rational::exact_from(-1.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: Rational) -> Self {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Add<&Rational> for Float {\n    type Output = Self;\n\n    /// Adds a [`Float`] and a [`Rational`], taking the [`Float`] by value and the [`Rational`] by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(0.0,x)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_val_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::add_rational_round_val_ref`]. If you want both of these things,\n    /// consider using [`Float::add_rational_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN + &Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     Float::INFINITY + &Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY + &Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(Float::from(2.5) + &Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(Float::from(2.5) + &Rational::exact_from(-1.5), 1.0);\n    /// assert_eq!(Float::from(-2.5) + &Rational::exact_from(1.5), -1.0);\n    /// assert_eq!(Float::from(-2.5) + &Rational::exact_from(-1.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: &Rational) -> Self {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Add<Rational> for &Float {\n    type Output = Float;\n\n    /// Adds a [`Float`] and a [`Rational`], taking the [`Float`] by reference and the [`Rational`]\n    /// by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(0.0,x)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_ref_val`] instead. If you want to specify the output precision,\n    /// consider using [`Float::add_rational_round_ref_val`]. If you want both of these things,\n    /// consider using [`Float::add_rational_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN + Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY + Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY + Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Float::from(2.5) + Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(&Float::from(2.5) + Rational::exact_from(-1.5), 1.0);\n    /// assert_eq!(&Float::from(-2.5) + Rational::exact_from(1.5), -1.0);\n    /// assert_eq!(&Float::from(-2.5) + Rational::exact_from(-1.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: Rational) -> Float {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Add<&Rational> for &Float {\n    type Output = Float;\n\n    /// Adds a [`Float`] and a [`Rational`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(0.0,x)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_ref_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::add_rational_round_ref_ref`]. If you want both of these things,\n    /// consider using [`Float::add_rational_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN + &Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY + &Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY + &Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Float::from(2.5) + &Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(&Float::from(2.5) + &Rational::exact_from(-1.5), 1.0);\n    /// assert_eq!(&Float::from(-2.5) + &Rational::exact_from(1.5), -1.0);\n    /// assert_eq!(&Float::from(-2.5) + &Rational::exact_from(-1.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: &Rational) -> Float {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl AddAssign<Rational> for Float {\n    /// Adds a [`Rational`] to a [`Float`] in place, taking the [`Rational`] by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `+` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_assign`] instead. If you want to specify the output precision,\n    /// consider using [`Float::add_rational_round_assign`]. If you want both of these things,\n    /// consider using [`Float::add_rational_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x += Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x += Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x += Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x += Rational::exact_from(1.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x += Rational::exact_from(-1.5);\n    /// assert_eq!(x, 1.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x += Rational::exact_from(1.5);\n    /// assert_eq!(x, -1.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x += Rational::exact_from(-1.5);\n    /// assert_eq!(x, -4.0);\n    /// ```\n    #[inline]\n    fn add_assign(&mut self, other: Rational) {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl AddAssign<&Rational> for Float {\n    /// Adds a [`Rational`] to a [`Float`] in place, taking the [`Rational`] by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `+` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::add_rational_prec_assign`] instead. If you want to specify the output precision,\n    /// consider using [`Float::add_rational_round_assign`]. If you want both of these things,\n    /// consider using [`Float::add_rational_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x += &Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x += &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x += &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x += &Rational::exact_from(1.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x += &Rational::exact_from(-1.5);\n    /// assert_eq!(x, 1.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x += &Rational::exact_from(1.5);\n    /// assert_eq!(x, -1.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x += &Rational::exact_from(-1.5);\n    /// assert_eq!(x, -4.0);\n    /// ```\n    #[inline]\n    fn add_assign(&mut self, other: &Rational) {\n        let prec = self.significant_bits();\n        self.add_rational_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Add<Float> for Rational {\n    type Output = Float;\n\n    /// Adds a [`Rational`] and a [`Float`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$\n    /// - $f(x,-\\infty)=-\\infty$\n    /// - $f(0,0.0)=0.0$\n    /// - $f(0,-0.0)=-0.0$\n    /// - $f(x,0.0)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) + Float::NAN).is_nan());\n    /// assert_eq!(Rational::exact_from(1.5) + Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) + Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(Rational::exact_from(1.5) + Float::from(2.5), 4.0);\n    /// assert_eq!(Rational::exact_from(1.5) + Float::from(-2.5), -1.0);\n    /// assert_eq!(Rational::exact_from(-1.5) + Float::from(2.5), 1.0);\n    /// assert_eq!(Rational::exact_from(-1.5) + Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        other.add_rational_prec_round(self, prec, Nearest).0\n    }\n}\n\nimpl Add<&Float> for Rational {\n    type Output = Float;\n\n    /// Adds a [`Rational`] and a [`Float`], taking the [`Rational`] by value and the [`Float`] by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$\n    /// - $f(x,-\\infty)=-\\infty$\n    /// - $f(0,0.0)=0.0$\n    /// - $f(0,-0.0)=-0.0$\n    /// - $f(x,0.0)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) + &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) + &Float::INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) + &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(Rational::exact_from(1.5) + &Float::from(2.5), 4.0);\n    /// assert_eq!(Rational::exact_from(1.5) + &Float::from(-2.5), -1.0);\n    /// assert_eq!(Rational::exact_from(-1.5) + &Float::from(2.5), 1.0);\n    /// assert_eq!(Rational::exact_from(-1.5) + &Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        other.add_rational_prec_round_ref_val(self, prec, Nearest).0\n    }\n}\n\nimpl Add<Float> for &Rational {\n    type Output = Float;\n\n    /// Adds a [`Rational`] and a [`Float`], taking the [`Rational`] by reference and the [`Float`]\n    /// by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$\n    /// - $f(x,-\\infty)=-\\infty$\n    /// - $f(0,0.0)=0.0$\n    /// - $f(0,-0.0)=-0.0$\n    /// - $f(x,0.0)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) + Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) + Float::INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) + Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Rational::exact_from(1.5) + Float::from(2.5), 4.0);\n    /// assert_eq!(&Rational::exact_from(1.5) + Float::from(-2.5), -1.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) + Float::from(2.5), 1.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) + Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        other.add_rational_prec_round_val_ref(self, prec, Nearest).0\n    }\n}\n\nimpl Add<&Float> for &Rational {\n    type Output = Float;\n\n    /// Adds a [`Rational`] and a [`Float`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the sum is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x+y+\\varepsilon.\n    /// $$\n    /// - If $x+y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x+y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x+y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$\n    /// - $f(x,-\\infty)=-\\infty$\n    /// - $f(0,0.0)=0.0$\n    /// - $f(0,-0.0)=-0.0$\n    /// - $f(x,0.0)=f(x,0)=f(-0.0,x)=x$\n    /// - $f(x,-x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) + &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) + &Float::INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) + &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Rational::exact_from(1.5) + &Float::from(2.5), 4.0);\n    /// assert_eq!(&Rational::exact_from(1.5) + &Float::from(-2.5), -1.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) + &Float::from(2.5), 1.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) + &Float::from(-2.5), -4.0);\n    /// ```\n    #[inline]\n    fn add(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        other.add_rational_prec_round_ref_ref(self, prec, Nearest).0\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/agm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::basic::extended::{ExtendedFloat, agm_prec_round_normal_extended};\nuse crate::{\n    Float, emulate_float_float_to_float_fn, emulate_rational_rational_to_float_fn,\n    float_either_infinity, float_either_zero, float_infinity, float_nan, float_zero, test_overflow,\n    test_underflow,\n};\nuse alloc::borrow::Cow;\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    Agm, AgmAssign, CeilingLogBase2, ShrRoundAssign, Sign, Sqrt, SqrtAssign,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero as ZeroTrait;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::natural::arithmetic::float_sub::exponent_shift_compare;\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\n// This is mpfr_cmp2 from cmp2.c, MPFR 4.3.0.\nfn cmp2_helper(b: &Float, c: &Float, cancel: &mut u64) -> Ordering {\n    match (b, c) {\n        (\n            Float(Finite {\n                exponent: x_exp,\n                precision: x_prec,\n                significand: x,\n                ..\n            }),\n            Float(Finite {\n                exponent: y_exp,\n                precision: y_prec,\n                significand: y,\n                ..\n            }),\n        ) => {\n            let (o, c) = exponent_shift_compare(\n                x.as_limbs_asc(),\n                i64::from(*x_exp),\n                *x_prec,\n                y.as_limbs_asc(),\n                i64::from(*y_exp),\n                *y_prec,\n            );\n            *cancel = c;\n            o\n        }\n        _ => panic!(),\n    }\n}\n\nfn agm_prec_round_normal(\n    mut a: Float,\n    mut b: Float,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if a < 0u32 || b < 0u32 {\n        return (float_nan!(), Equal);\n    }\n    let mut working_prec = prec + prec.ceiling_log_base_2() + 15;\n    // b (op2) and a (op1) are the 2 operands but we want b >= a\n    match a.partial_cmp(&b).unwrap() {\n        Equal => return Float::from_float_prec_round(a, prec, rm),\n        Greater => swap(&mut a, &mut b),\n        _ => {}\n    }\n    let mut scaleop = 0;\n    let mut increment = Limb::WIDTH;\n    let mut v;\n    let mut scaleit;\n    loop {\n        let mut err: u64 = 0;\n        let mut u;\n        loop {\n            let u_o;\n            let v_o;\n            (u, u_o) = a.mul_prec_ref_ref(&b, working_prec);\n            (v, v_o) = a.add_prec_ref_ref(&b, working_prec);\n            let u_overflow = test_overflow(&u, u_o);\n            let v_overflow = test_overflow(&v, v_o);\n            if u_overflow || v_overflow || test_underflow(&u, u_o) || test_underflow(&v, v_o) {\n                assert_eq!(scaleop, 0);\n                let e1 = a.get_exponent().unwrap();\n                let e2 = b.get_exponent().unwrap();\n                if u_overflow || v_overflow {\n                    // Let's recall that emin <= e1 <= e2 <= emax. There has been an overflow. Thus\n                    // e2 >= emax/2. If the mpfr_mul overflowed, then e1 + e2 > emax. If the\n                    // mpfr_add overflowed, then e2 = emax. We want: (e1 + scale) + (e2 + scale) <=\n                    // emax, i.e. scale <= (emax - e1 - e2) / 2. Let's take scale = min(floor((emax\n                    // - e1 - e2) / 2), -1). This is OK, as:\n                    // ```\n                    // - emin <= scale <= -1.\n                    // - e1 + scale >= emin. Indeed:\n                    //    * If e1 + e2 > emax, then\n                    //      e1 + scale >= e1 + (emax - e1 - e2) / 2 - 1\n                    //                 >= (emax + e1 - emax) / 2 - 1\n                    //                 >= e1 / 2 - 1 >= emin.\n                    //    * Otherwise, mpfr_mul didn't overflow, therefore\n                    //      mpfr_add overflowed and e2 = emax, so that\n                    //      e1 > emin (see restriction below).\n                    //      e1 + scale > emin - 1, thus e1 + scale >= emin.\n                    // - e2 + scale <= emax, since scale < 0.\n                    // ```\n                    let e_agm = e1 + e2;\n                    if e_agm > Float::MAX_EXPONENT {\n                        scaleop = -((e_agm - Float::MAX_EXPONENT + 1) / 2);\n                        assert!(scaleop < 0);\n                    } else {\n                        // The addition necessarily overflowed.\n                        assert_eq!(e2, Float::MAX_EXPONENT);\n                        // The case where e1 = emin and e2 = emax is not supported here. This would\n                        // mean that the precision of e2 would be huge (and possibly not supported\n                        // in practice anyway).\n                        assert!(e1 > Float::MIN_EXPONENT);\n                        // Note: this case is probably impossible to have in practice since we need\n                        // e2 = emax, and no overflow in the product. Since the product is >=\n                        // 2^(e1+e2-2), it implies e1 + e2 - 2 <= emax, thus e1 <= 2. Now to get an\n                        // overflow we need op1 >= 1/2 ulp(op2), which implies that the precision of\n                        // op2 should be at least emax-2. On a 64-bit computer this is impossible to\n                        // have, and would require a huge amount of memory on a 32-bit computer.\n                        scaleop = -1;\n                    }\n                } else {\n                    // underflow only (in the multiplication)\n                    //\n                    // We have e1 + e2 <= emin (so, e1 <= e2 <= 0). We want: (e1 + scale) + (e2 +\n                    // scale) >= emin + 1, i.e. scale >= (emin + 1 - e1 - e2) / 2. let's take scale\n                    // = ceil((emin + 1 - e1 - e2) / 2). This is OK, as: 1. 1 <= scale <= emax. 2.\n                    // e1 + scale >= emin + 1 >= emin. 3. e2 + scale <= scale <= emax.\n                    assert!(e1 <= e2 && e2 <= 0);\n                    scaleop = (Float::MIN_EXPONENT + 2 - e1 - e2) / 2;\n                    assert!(scaleop > 0);\n                }\n                a <<= scaleop;\n                b <<= scaleop;\n            } else {\n                break;\n            }\n        }\n        u.sqrt_assign();\n        v >>= 1u32;\n        scaleit = 0;\n        let mut n: u64 = 1;\n        let mut eq = 0;\n        'mid: while cmp2_helper(&u, &v, &mut eq) != Equal && eq <= working_prec - 2 {\n            let mut uf;\n            let mut vf;\n            loop {\n                vf = (&u + &v) >> 1;\n                // See proof in algorithms.tex\n                if eq > working_prec >> 2 {\n                    // vf = V(k)\n                    let low_p = (working_prec + 1) >> 1;\n                    let (mut w, o) = v.sub_prec_ref_ref(&u, low_p); // e = V(k-1)-U(k-1)\n                    let mut underflow = test_underflow(&w, o);\n                    let o = w.square_round_assign(Nearest); // e = e^2\n                    underflow |= test_underflow(&w, o);\n                    let o = w.shr_round_assign(4, Nearest); // e*= (1/2)^2*1/4\n                    underflow |= test_underflow(&w, o);\n                    let o = w.div_prec_assign_ref(&vf, low_p); // 1/4*e^2/V(k)\n                    underflow |= test_underflow(&w, o);\n                    let vf_exp = vf.get_exponent().unwrap();\n                    if !underflow {\n                        v = vf.sub_prec(w, working_prec).0;\n                        // 0 or 1\n                        err = u64::exact_from(vf_exp - v.get_exponent().unwrap());\n                        break 'mid;\n                    }\n                    // There has been an underflow because of the cancellation between V(k-1) and\n                    // U(k-1). Let's use the conventional method.\n                }\n                // U(k) increases, so that U.V can overflow (but not underflow).\n                uf = &u * &v;\n                // For multiplication using Nearest, is_infinite is sufficient for overflow checking\n                if uf.is_infinite() {\n                    let scale2 = -(((u.get_exponent().unwrap() + v.get_exponent().unwrap())\n                        - Float::MAX_EXPONENT\n                        + 1)\n                        / 2);\n                    u <<= scale2;\n                    v <<= scale2;\n                    scaleit += scale2;\n                } else {\n                    break;\n                }\n            }\n            u = uf.sqrt();\n            swap(&mut v, &mut vf);\n            n += 1;\n        }\n        // the error on v is bounded by (18n+51) ulps, or twice if there was an exponent loss in the\n        // final subtraction\n        //\n        // 18n+51 should not overflow since n is about log(p)\n        err += (18 * n + 51).ceiling_log_base_2();\n        // we should have n+2 <= 2^(p/4) [see algorithms.tex]\n        if (n + 2).ceiling_log_base_2() <= working_prec >> 2\n            && float_can_round(v.significand_ref().unwrap(), working_prec - err, prec, rm)\n        {\n            break;\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n    v.shr_prec_round(scaleop + scaleit, prec, rm)\n}\n\nfn agm_prec_round_ref_ref_normal(\n    a: &Float,\n    b: &Float,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if *a < 0u32 || *b < 0u32 {\n        return (float_nan!(), Equal);\n    }\n    let mut working_prec = prec + prec.ceiling_log_base_2() + 15;\n    let mut a = Cow::Borrowed(a);\n    let mut b = Cow::Borrowed(b);\n    // b (op2) and a (op1) are the 2 operands but we want b >= a\n    match a.partial_cmp(&b).unwrap() {\n        Equal => return Float::from_float_prec_round_ref(a.as_ref(), prec, rm),\n        Greater => swap(&mut a, &mut b),\n        _ => {}\n    }\n    let mut scaleop = 0;\n    let mut increment = Limb::WIDTH;\n    let mut v;\n    let mut scaleit;\n    loop {\n        let mut err: u64 = 0;\n        let mut u;\n        loop {\n            let u_o;\n            let v_o;\n            (u, u_o) = a.mul_prec_ref_ref(&b, working_prec);\n            (v, v_o) = a.add_prec_ref_ref(&b, working_prec);\n            let u_overflow = test_overflow(&u, u_o);\n            let v_overflow = test_overflow(&v, v_o);\n            if u_overflow || v_overflow || test_underflow(&u, u_o) || test_underflow(&v, v_o) {\n                assert_eq!(scaleop, 0);\n                let e1 = a.get_exponent().unwrap();\n                let e2 = b.get_exponent().unwrap();\n                if u_overflow || v_overflow {\n                    // Let's recall that emin <= e1 <= e2 <= emax. There has been an overflow. Thus\n                    // e2 >= emax/2. If the mpfr_mul overflowed, then e1 + e2 > emax. If the\n                    // mpfr_add overflowed, then e2 = emax. We want: (e1 + scale) + (e2 + scale) <=\n                    // emax, i.e. scale <= (emax - e1 - e2) / 2. Let's take scale = min(floor((emax\n                    // - e1 - e2) / 2), -1). This is OK, as:\n                    // ```\n                    // - emin <= scale <= -1.\n                    // - e1 + scale >= emin. Indeed:\n                    //    * If e1 + e2 > emax, then\n                    //      e1 + scale >= e1 + (emax - e1 - e2) / 2 - 1\n                    //                 >= (emax + e1 - emax) / 2 - 1\n                    //                 >= e1 / 2 - 1 >= emin.\n                    //    * Otherwise, mpfr_mul didn't overflow, therefore\n                    //      mpfr_add overflowed and e2 = emax, so that\n                    //      e1 > emin (see restriction below).\n                    //      e1 + scale > emin - 1, thus e1 + scale >= emin.\n                    // - e2 + scale <= emax, since scale < 0.\n                    // ```\n                    let e_agm = e1 + e2;\n                    if e_agm > Float::MAX_EXPONENT {\n                        scaleop = -((e_agm - Float::MAX_EXPONENT + 1) / 2);\n                        assert!(scaleop < 0);\n                    } else {\n                        // The addition necessarily overflowed.\n                        assert_eq!(e2, Float::MAX_EXPONENT);\n                        // The case where e1 = emin and e2 = emax is not supported here. This would\n                        // mean that the precision of e2 would be huge (and possibly not supported\n                        // in practice anyway).\n                        assert!(e1 > Float::MIN_EXPONENT);\n                        // Note: this case is probably impossible to have in practice since we need\n                        // e2 = emax, and no overflow in the product. Since the product is >=\n                        // 2^(e1+e2-2), it implies e1 + e2 - 2 <= emax, thus e1 <= 2. Now to get an\n                        // overflow we need op1 >= 1/2 ulp(op2), which implies that the precision of\n                        // op2 should be at least emax-2. On a 64-bit computer this is impossible to\n                        // have, and would require a huge amount of memory on a 32-bit computer.\n                        scaleop = -1;\n                    }\n                } else {\n                    // underflow only (in the multiplication)\n                    //\n                    // We have e1 + e2 <= emin (so, e1 <= e2 <= 0). We want: (e1 + scale) + (e2 +\n                    // scale) >= emin + 1, i.e. scale >= (emin + 1 - e1 - e2) / 2. let's take scale\n                    // = ceil((emin + 1 - e1 - e2) / 2). This is OK, as: 1. 1 <= scale <= emax. 2.\n                    // e1 + scale >= emin + 1 >= emin. 3. e2 + scale <= scale <= emax.\n                    assert!(e1 <= e2 && e2 <= 0);\n                    scaleop = (Float::MIN_EXPONENT + 2 - e1 - e2) / 2;\n                    assert!(scaleop > 0);\n                }\n                *a.to_mut() <<= scaleop;\n                *b.to_mut() <<= scaleop;\n            } else {\n                break;\n            }\n        }\n        u.sqrt_assign();\n        v >>= 1u32;\n        scaleit = 0;\n        let mut n: u64 = 1;\n        let mut eq = 0;\n        'mid: while cmp2_helper(&u, &v, &mut eq) != Equal && eq <= working_prec - 2 {\n            let mut uf;\n            let mut vf;\n            loop {\n                vf = (&u + &v) >> 1;\n                // See proof in algorithms.tex\n                if eq > working_prec >> 2 {\n                    // vf = V(k)\n                    let low_p = (working_prec + 1) >> 1;\n                    let (mut w, o) = v.sub_prec_ref_ref(&u, low_p); // e = V(k-1)-U(k-1)\n                    let mut underflow = test_underflow(&w, o);\n                    let o = w.square_round_assign(Nearest); // e = e^2\n                    underflow |= test_underflow(&w, o);\n                    let o = w.shr_round_assign(4, Nearest); // e*= (1/2)^2*1/4\n                    underflow |= test_underflow(&w, o);\n                    let o = w.div_prec_assign_ref(&vf, low_p); // 1/4*e^2/V(k)\n                    underflow |= test_underflow(&w, o);\n                    let vf_exp = vf.get_exponent().unwrap();\n                    if !underflow {\n                        v = vf.sub_prec(w, working_prec).0;\n                        // 0 or 1\n                        err = u64::exact_from(vf_exp - v.get_exponent().unwrap());\n                        break 'mid;\n                    }\n                    // There has been an underflow because of the cancellation between V(k-1) and\n                    // U(k-1). Let's use the conventional method.\n                }\n                // U(k) increases, so that U.V can overflow (but not underflow).\n                uf = &u * &v;\n                // For multiplication using Nearest, is_infinite is sufficient for overflow checking\n                if uf.is_infinite() {\n                    let scale2 = -(((u.get_exponent().unwrap() + v.get_exponent().unwrap())\n                        - Float::MAX_EXPONENT\n                        + 1)\n                        / 2);\n                    u <<= scale2;\n                    v <<= scale2;\n                    scaleit += scale2;\n                } else {\n                    break;\n                }\n            }\n            u = uf.sqrt();\n            swap(&mut v, &mut vf);\n            n += 1;\n        }\n        // the error on v is bounded by (18n+51) ulps, or twice if there was an exponent loss in the\n        // final subtraction\n        //\n        // 18n+51 should not overflow since n is about log(p)\n        err += (18 * n + 51).ceiling_log_base_2();\n        // we should have n+2 <= 2^(p/4) [see algorithms.tex]\n        if (n + 2).ceiling_log_base_2() <= working_prec >> 2\n            && float_can_round(v.significand_ref().unwrap(), working_prec - err, prec, rm)\n        {\n            break;\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n    v.shr_prec_round(scaleop + scaleit, prec, rm)\n}\n\nfn agm_rational_helper(\n    x: &Rational,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let (x_lo, x_o) = Float::from_rational_prec_round_ref(x, working_prec, Floor);\n        let (y_lo, y_o) = Float::from_rational_prec_round_ref(y, working_prec, Floor);\n        if x_o == Equal && y_o == Equal {\n            return agm_prec_round_normal(x_lo, y_lo, prec, rm);\n        }\n        let mut x_hi = x_lo.clone();\n        if x_o != Equal {\n            x_hi.increment();\n        }\n        let mut y_hi = y_lo.clone();\n        if y_o != Equal {\n            y_hi.increment();\n        }\n        let (agm_lo, mut o_lo) = agm_prec_round_normal(x_lo, y_lo, prec, rm);\n        let (agm_hi, mut o_hi) = agm_prec_round_normal(x_hi, y_hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && agm_lo == agm_hi {\n            return (agm_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\nfn agm_rational_helper_extended(\n    x: &Rational,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let (x_lo, x_o) = ExtendedFloat::from_rational_prec_round_ref(x, working_prec, Floor);\n        let (y_lo, y_o) = ExtendedFloat::from_rational_prec_round_ref(y, working_prec, Floor);\n        if x_o == Equal && y_o == Equal {\n            let (agm, o) = agm_prec_round_normal_extended(x_lo, y_lo, prec, rm);\n            return agm.into_float_helper(prec, rm, o);\n        }\n        let mut x_hi = x_lo.clone();\n        if x_o != Equal {\n            x_hi.increment();\n        }\n        let mut y_hi = y_lo.clone();\n        if y_o != Equal {\n            y_hi.increment();\n        }\n        let (agm_lo, mut o_lo) = agm_prec_round_normal_extended(x_lo, y_lo, prec, rm);\n        let (agm_hi, mut o_hi) = agm_prec_round_normal_extended(x_hi, y_hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && agm_lo == agm_hi {\n            return agm_lo.into_float_helper(prec, rm, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\nimpl Float {\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// specified precision and with the specified rounding mode. Both [`Float`]s are taken by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded AGM is less than,\n    /// equal to, or greater than the exact AGM. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p,m)=\\infty$\n    /// - $f(\\pm0.0,x,p,m)=f(x,\\pm0.0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_prec`] instead. If you\n    /// know that your target precision is the maximum of the precisions of the two inputs, consider\n    /// using [`Float::agm_round`] instead. If both of these things are true, consider using\n    /// [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round(Float::from(6), 5, Floor);\n    /// assert_eq!(agm.to_string(), \"13.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round(Float::from(6), 5, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round(Float::from(6), 5, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round(Float::from(6), 20, Floor);\n    /// assert_eq!(agm.to_string(), \"13.45816\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round(Float::from(6), 20, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round(Float::from(6), 20, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_prec_round(self, other: Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (&self, &other) {\n            (float_nan!(), _) | (_, float_nan!()) => (float_nan!(), Equal),\n            (float_infinity!(), x) | (x, float_infinity!()) if *x > 0.0 => {\n                (float_infinity!(), Equal)\n            }\n            (float_either_infinity!(), _) | (_, float_either_infinity!()) => (float_nan!(), Equal),\n            (float_either_zero!(), _) | (_, float_either_zero!()) => (float_zero!(), Equal),\n            _ => agm_prec_round_normal(self, other, prec, rm),\n        }\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// specified precision and with the specified rounding mode. The first [`Float`] is taken by\n    /// value and the second by reference. An [`Ordering`] is also returned, indicating whether the\n    /// rounded AGM is less than, equal to, or greater than the exact AGM. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p,m)=\\infty$\n    /// - $f(\\pm0.0,x,p,m)=f(x,\\pm0.0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_prec_val_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::agm_round_val_ref`] instead. If both of these things are true,\n    /// consider using [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_val_ref(&Float::from(6), 5, Floor);\n    /// assert_eq!(agm.to_string(), \"13.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_val_ref(&Float::from(6), 5, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_val_ref(&Float::from(6), 5, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_val_ref(&Float::from(6), 20, Floor);\n    /// assert_eq!(agm.to_string(), \"13.45816\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_val_ref(&Float::from(6), 20, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_val_ref(&Float::from(6), 20, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_prec_round_val_ref(\n        mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.agm_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// specified precision and with the specified rounding mode. The first [`Float`] is taken by\n    /// reference and the second by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded AGM is less than, equal to, or greater than the exact AGM. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p,m)=\\infty$\n    /// - $f(\\pm0.0,x,p,m)=f(x,\\pm0.0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_prec_ref_val`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::agm_round_ref_val`] instead. If both of these things are true,\n    /// consider using [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_val_ref(&Float::from(6), 5, Floor);\n    /// assert_eq!(agm.to_string(), \"13.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_val(Float::from(6), 5, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_val(Float::from(6), 5, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_val(Float::from(6), 20, Floor);\n    /// assert_eq!(agm.to_string(), \"13.45816\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_val(Float::from(6), 20, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_val(Float::from(6), 20, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_prec_round_ref_val(\n        &self,\n        mut other: Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = other.agm_prec_round_assign_ref(self, prec, rm);\n        (other, o)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// specified precision and with the specified rounding mode. Both [`Float`]s are taken by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded AGM is less\n    /// than, equal to, or greater than the exact AGM. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p,m)=\\infty$\n    /// - $f(\\pm0.0,x,p,m)=f(x,\\pm0.0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_prec_ref_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::agm_round_ref_ref`] instead. If both of these things are true,\n    /// consider using [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_ref(&Float::from(6), 5, Floor);\n    /// assert_eq!(agm.to_string(), \"13.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_ref(&Float::from(6), 5, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_ref(&Float::from(6), 5, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_ref(&Float::from(6), 20, Floor);\n    /// assert_eq!(agm.to_string(), \"13.45816\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_ref(&Float::from(6), 20, Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_round_ref_ref(&Float::from(6), 20, Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    ///\n    /// This is mpfr_agm from agm.c, MPFR 4.3.0.\n    #[inline]\n    pub fn agm_prec_round_ref_ref(\n        &self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _) | (_, float_nan!()) => (float_nan!(), Equal),\n            (float_infinity!(), x) | (x, float_infinity!()) if *x > 0.0 => {\n                (float_infinity!(), Equal)\n            }\n            (float_either_infinity!(), _) | (_, float_either_infinity!()) => (float_nan!(), Equal),\n            (float_either_zero!(), _) | (_, float_either_zero!()) => (float_zero!(), Equal),\n            _ => agm_prec_round_ref_ref_normal(self, other, prec, rm),\n        }\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// nearest value of the specified precision. Both [`Float`]s are taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded AGM is less than, equal to, or\n    /// greater than the exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the agm is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(-\\infty,x,p)=f(x,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p)=\\infty$\n    /// - $f(\\pm0.0,x,p)=f(x,\\pm0.0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_round`] instead. If you know that your target precision is the maximum of\n    /// the precisions of the two inputs, consider using [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec(Float::from(6), 5);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec(Float::from(6), 20);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_prec(self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.agm_prec_round(other, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// nearest value of the specified precision. The first [`Float`] is taken by value and the\n    /// second by reference. An [`Ordering`] is also returned, indicating whether the rounded AGM is\n    /// less than, equal to, or greater than the exact AGM. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the agm is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(-\\infty,x,p)=f(x,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p)=\\infty$\n    /// - $f(\\pm0.0,x,p)=f(x,\\pm0.0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_round_val_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_val_ref(&Float::from(6), 5);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from(24).agm_prec_val_ref(&Float::from(6), 20);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_prec_val_ref(self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.agm_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// nearest value of the specified precision. The first [`Float`] is taken by reference and the\n    /// second by value. An [`Ordering`] is also returned, indicating whether the rounded AGM is\n    /// less than, equal to, or greater than the exact AGM. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the agm is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(-\\infty,x,p)=f(x,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p)=\\infty$\n    /// - $f(\\pm0.0,x,p)=f(x,\\pm0.0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_round_ref_val`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = (&Float::from(24)).agm_prec_ref_val(Float::from(6), 5);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = (&Float::from(24)).agm_prec_ref_val(Float::from(6), 20);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_prec_ref_val(&self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.agm_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result to the\n    /// nearest value of the specified precision. Both [`Float`]s are taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded AGM is less than, equal to, or\n    /// greater than the exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the agm is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(-\\infty,x,p)=f(x,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,p)=\\infty$\n    /// - $f(\\pm0.0,x,p)=f(x,\\pm0.0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_round_ref_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = (&Float::from(24)).agm_prec_ref_ref(&Float::from(6), 5);\n    /// assert_eq!(agm.to_string(), \"13.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = (&Float::from(24)).agm_prec_ref_ref(&Float::from(6), 20);\n    /// assert_eq!(agm.to_string(), \"13.45818\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.agm_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result with the\n    /// specified rounding mode. Both [`Float`]s are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded AGM is less than, equal to, or greater than the\n    /// exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(-\\infty,x,m)=f(x,-\\infty,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,m)=\\infty$\n    /// - $f(\\pm0.0,x,m)=f(x,\\pm0.0,m)=0.0$\n    /// - $f(x,y,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::agm_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round(Float::from(6), Floor);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315696\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round(Float::from(6), Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round(Float::from(6), Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_round(self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round(other, prec, rm)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result with the\n    /// specified rounding mode. The first [`Float`] is taken by value and the second by reference.\n    /// An [`Ordering`] is also returned, indicating whether the rounded AGM is less than, equal to,\n    /// or greater than the exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(-\\infty,x,m)=f(x,-\\infty,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,m)=\\infty$\n    /// - $f(\\pm0.0,x,m)=f(x,\\pm0.0,m)=0.0$\n    /// - $f(x,y,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::agm_prec_round_val_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round_val_ref(&Float::from(6), Floor);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315696\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round_val_ref(&Float::from(6), Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round_val_ref(&Float::from(6), Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_round_val_ref(self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result with the\n    /// specified rounding mode. The first [`Float`] is taken by reference and the second by value.\n    /// An [`Ordering`] is also returned, indicating whether the rounded AGM is less than, equal to,\n    /// or greater than the exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(-\\infty,x,m)=f(x,-\\infty,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,m)=\\infty$\n    /// - $f(\\pm0.0,x,m)=f(x,\\pm0.0,m)=0.0$\n    /// - $f(x,y,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::agm_prec_round_ref_val`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) =\n    ///     (&Float::from_unsigned_prec(24u8, 100).0).agm_round_ref_val(Float::from(6), Floor);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315696\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) =\n    ///     (&Float::from_unsigned_prec(24u8, 100).0).agm_round_ref_val(Float::from(6), Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) =\n    ///     (&Float::from_unsigned_prec(24u8, 100).0).agm_round_ref_val(Float::from(6), Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_round_ref_val(&self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, rounding the result with the\n    /// specified rounding mode. Both [`Float`]s are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded AGM is less than, equal to, or greater than the\n    /// exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(-\\infty,x,m)=f(x,-\\infty,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty,m)=\\infty$\n    /// - $f(\\pm0.0,x,m)=f(x,\\pm0.0,m)=0.0$\n    /// - $f(x,y,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::agm_prec_round_ref_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::agm`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round_ref_ref(&Float::from(6), Floor);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315696\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round_ref_ref(&Float::from(6), Ceiling);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::from_unsigned_prec(24u8, 100)\n    ///     .0\n    ///     .agm_round_ref_ref(&Float::from(6), Nearest);\n    /// assert_eq!(agm.to_string(), \"13.45817148172561542076681315698\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_round_ref_ref(&self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and rounding the result to the specified precision and with the specified rounding\n    /// mode. The [`Float`] on the right-hand side is taken by value. An [`Ordering`] is returned,\n    /// indicating whether the rounded AGM is less than, equal to, or greater than the exact AGM.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::agm_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_prec_assign`] instead. If\n    /// you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::agm_round_assign`] instead. If both of these things are true,\n    /// consider using [`Float::agm_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_round_assign(Float::from(6), 5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"13.0\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_round_assign(Float::from(6), 5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"13.5\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_round_assign(Float::from(6), 5, Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"13.5\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_round_assign(Float::from(6), 20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"13.45816\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(\n    ///     x.agm_prec_round_assign(Float::from(6), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"13.45818\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(\n    ///     x.agm_prec_round_assign(Float::from(6), 20, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"13.45818\");\n    /// ```\n    #[inline]\n    pub fn agm_prec_round_assign(&mut self, other: Self, prec: u64, rm: RoundingMode) -> Ordering {\n        let o;\n        let mut x = Self::ZERO;\n        swap(&mut x, self);\n        (*self, o) = x.agm_prec_round(other, prec, rm);\n        o\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and rounding the result to the specified precision and with the specified rounding\n    /// mode. The [`Float`] on the right-hand side is taken by reference. An [`Ordering`] is\n    /// returned, indicating whether the rounded AGM is less than, equal to, or greater than the\n    /// exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::agm_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_prec_assign_ref`]\n    /// instead. If you know that your target precision is the maximum of the precisions of the two\n    /// inputs, consider using [`Float::agm_round_assign_ref`] instead. If both of these things are\n    /// true, consider using [`Float::agm_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_round_assign_ref(&Float::from(6), 5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"13.0\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(\n    ///     x.agm_prec_round_assign_ref(&Float::from(6), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"13.5\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(\n    ///     x.agm_prec_round_assign_ref(&Float::from(6), 5, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"13.5\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(\n    ///     x.agm_prec_round_assign_ref(&Float::from(6), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"13.45816\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(\n    ///     x.agm_prec_round_assign_ref(&Float::from(6), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"13.45818\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(\n    ///     x.agm_prec_round_assign_ref(&Float::from(6), 20, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"13.45818\");\n    /// ```\n    #[inline]\n    pub fn agm_prec_round_assign_ref(\n        &mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        let o;\n        (*self, o) = self.agm_prec_round_ref_ref(other, prec, rm);\n        o\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and rounding the result to the nearest value of the specified precision. The\n    /// [`Float`] on the right-hand side is taken by value. An [`Ordering`] is returned, indicating\n    /// whether the rounded AGM is less than, equal to, or greater than the exact AGM. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function sets the [`Float`] to\n    /// `NaN` it also returns `Equal`.\n    ///\n    /// If the agm is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::agm_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_round_assign`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using [`Float::agm_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_assign(Float::from(6), 5), Greater);\n    /// assert_eq!(x.to_string(), \"13.5\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_assign(Float::from(6), 20), Greater);\n    /// assert_eq!(x.to_string(), \"13.45818\");\n    /// ```\n    #[inline]\n    pub fn agm_prec_assign(&mut self, other: Self, prec: u64) -> Ordering {\n        self.agm_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and rounding the result to the nearest value of the specified precision. The\n    /// [`Float`] on the right-hand side is taken by reference. An [`Ordering`] is returned,\n    /// indicating whether the rounded AGM is less than, equal to, or greater than the exact AGM.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the agm is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::agm_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_round_assign_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using [`Float::agm_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_assign_ref(&Float::from(6), 5), Greater);\n    /// assert_eq!(x.to_string(), \"13.5\");\n    ///\n    /// let mut x = Float::from(24);\n    /// assert_eq!(x.agm_prec_assign_ref(&Float::from(6), 20), Greater);\n    /// assert_eq!(x.to_string(), \"13.45818\");\n    /// ```\n    #[inline]\n    pub fn agm_prec_assign_ref(&mut self, other: &Self, prec: u64) -> Ordering {\n        self.agm_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and rounding the result with the specified rounding mode. The [`Float`] on the\n    /// right-hand side is taken by value. An [`Ordering`] is returned, indicating whether the\n    /// rounded AGM is less than, equal to, or greater than the exact AGM. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::agm_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::agm_prec_round_assign`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::agm_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// assert_eq!(x.agm_round_assign(Float::from(6), Floor), Less);\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315696\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// assert_eq!(x.agm_round_assign(Float::from(6), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315698\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// assert_eq!(x.agm_round_assign(Float::from(6), Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315698\");\n    /// ```\n    #[inline]\n    pub fn agm_round_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_assign(other, prec, rm)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and rounding the result with the specified rounding mode. The [`Float`] on the\n    /// right-hand side is taken by reference. An [`Ordering`] is returned, indicating whether the\n    /// rounded AGM is less than, equal to, or greater than the exact AGM. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::agm_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::agm_prec_round_assign_ref`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using [`Float::agm_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Float`] arguments are positive and distinct (and the\n    /// exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// assert_eq!(x.agm_round_assign_ref(&Float::from(6), Floor), Less);\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315696\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// assert_eq!(x.agm_round_assign_ref(&Float::from(6), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315698\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// assert_eq!(x.agm_round_assign_ref(&Float::from(6), Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315698\");\n    /// ```\n    #[inline]\n    pub fn agm_round_assign_ref(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_assign_ref(other, prec, rm)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the specified precision and with the specified rounding mode, and returning the result as a\n    /// [`Float`]. Both [`Rational`]s are taken by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded AGM is less than, equal to, or greater than the exact AGM.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p,m)=f(x,0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,t,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_rational_prec`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985109\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[allow(clippy::needless_pass_by_value)]\n    #[inline]\n    pub fn agm_rational_prec_round(\n        x: Rational,\n        y: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        Self::agm_rational_prec_round_val_ref(x, &y, prec, rm)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the specified precision and with the specified rounding mode, and returning the result as a\n    /// [`Float`]. The first [`Rational`]s is taken by value and the second by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded AGM is less than, equal to, or\n    /// greater than the exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p,m)=f(x,0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,t,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_rational_prec_val_ref`]\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_val_ref(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985109\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_val_ref(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_val_ref(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn agm_rational_prec_round_val_ref(\n        x: Rational,\n        y: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (x.sign(), y.sign()) {\n            (Equal, _) | (_, Equal) => return (float_zero!(), Equal),\n            (Less, _) | (_, Less) => return (float_nan!(), Equal),\n            _ => {}\n        }\n        if x == *y {\n            return Self::from_rational_prec_round(x, prec, rm);\n        }\n        assert_ne!(rm, Exact, \"Inexact AGM\");\n        let x_exp = i32::saturating_from(x.floor_log_base_2_abs()).saturating_add(1);\n        let y_exp = i32::saturating_from(y.floor_log_base_2_abs()).saturating_add(1);\n        let x_overflow = x_exp > Self::MAX_EXPONENT;\n        let y_overflow = y_exp > Self::MAX_EXPONENT;\n        let x_underflow = x_exp < Self::MIN_EXPONENT;\n        let y_underflow = y_exp < Self::MIN_EXPONENT;\n        match (x_overflow, y_overflow, x_underflow, y_underflow) {\n            (true, true, _, _) => Self::from_rational_prec_round(x, prec, rm),\n            (_, _, true, true)\n                if rm != Nearest\n                    || x_exp < Self::MIN_EXPONENT - 1 && y_exp < Self::MIN_EXPONENT - 1 =>\n            {\n                Self::from_rational_prec_round(x, prec, rm)\n            }\n            (false, false, false, false)\n                if x_exp < Self::MAX_EXPONENT && y_exp < Self::MAX_EXPONENT =>\n            {\n                agm_rational_helper(&x, y, prec, rm)\n            }\n            _ => agm_rational_helper_extended(&x, y, prec, rm),\n        }\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the specified precision and with the specified rounding mode, and returning the result as a\n    /// [`Float`]. The first [`Rational`]s is taken by reference and the second by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded AGM is less than, equal to, or\n    /// greater than the exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p,m)=f(x,0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,t,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_rational_prec_ref_val`]\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_ref_val(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985109\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_ref_val(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_ref_val(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn agm_rational_prec_round_ref_val(\n        x: &Rational,\n        y: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (x.sign(), y.sign()) {\n            (Equal, _) | (_, Equal) => return (float_zero!(), Equal),\n            (Less, _) | (_, Less) => return (float_nan!(), Equal),\n            _ => {}\n        }\n        if *x == y {\n            return Self::from_rational_prec_round(y, prec, rm);\n        }\n        assert_ne!(rm, Exact, \"Inexact AGM\");\n        let x_exp = i32::saturating_from(x.floor_log_base_2_abs()).saturating_add(1);\n        let y_exp = i32::saturating_from(y.floor_log_base_2_abs()).saturating_add(1);\n        let x_overflow = x_exp > Self::MAX_EXPONENT;\n        let y_overflow = y_exp > Self::MAX_EXPONENT;\n        let x_underflow = x_exp < Self::MIN_EXPONENT;\n        let y_underflow = y_exp < Self::MIN_EXPONENT;\n        match (x_overflow, y_overflow, x_underflow, y_underflow) {\n            (true, true, _, _) => Self::from_rational_prec_round(y, prec, rm),\n            (_, _, true, true)\n                if rm != Nearest\n                    || x_exp < Self::MIN_EXPONENT - 1 && y_exp < Self::MIN_EXPONENT - 1 =>\n            {\n                Self::from_rational_prec_round(y, prec, rm)\n            }\n            (false, false, false, false)\n                if x_exp < Self::MAX_EXPONENT && y_exp < Self::MAX_EXPONENT =>\n            {\n                agm_rational_helper(x, &y, prec, rm)\n            }\n            _ => agm_rational_helper_extended(x, &y, prec, rm),\n        }\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the specified precision and with the specified rounding mode, and returning the result as a\n    /// [`Float`]. Both [`Rational`]s are taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded AGM is less than, equal to, or greater than the exact AGM.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p,m)=f(x,0,p,m)=0.0$\n    /// - $f(x,y,p,m)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,t,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::agm_rational_prec_ref_ref`]\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985109\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn agm_rational_prec_round_ref_ref(\n        x: &Rational,\n        y: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (x.sign(), y.sign()) {\n            (Equal, _) | (_, Equal) => return (float_zero!(), Equal),\n            (Less, _) | (_, Less) => return (float_nan!(), Equal),\n            _ => {}\n        }\n        if x == y {\n            return Self::from_rational_prec_round_ref(x, prec, rm);\n        }\n        assert_ne!(rm, Exact, \"Inexact AGM\");\n        let x_exp = i32::saturating_from(x.floor_log_base_2_abs()).saturating_add(1);\n        let y_exp = i32::saturating_from(y.floor_log_base_2_abs()).saturating_add(1);\n        let x_overflow = x_exp > Self::MAX_EXPONENT;\n        let y_overflow = y_exp > Self::MAX_EXPONENT;\n        let x_underflow = x_exp < Self::MIN_EXPONENT;\n        let y_underflow = y_exp < Self::MIN_EXPONENT;\n        match (x_overflow, y_overflow, x_underflow, y_underflow) {\n            (true, true, _, _) => Self::from_rational_prec_round_ref(x, prec, rm),\n            (_, _, true, true)\n                if rm != Nearest\n                    || x_exp < Self::MIN_EXPONENT - 1 && y_exp < Self::MIN_EXPONENT - 1 =>\n            {\n                Self::from_rational_prec_round_ref(x, prec, rm)\n            }\n            (false, false, false, false)\n                if x_exp < Self::MAX_EXPONENT && y_exp < Self::MAX_EXPONENT =>\n            {\n                agm_rational_helper(x, y, prec, rm)\n            }\n            _ => agm_rational_helper_extended(x, y, prec, rm),\n        }\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the nearest value of the specified precision, and returning the result as a [`Float`]. Both\n    /// [`Rational`]s are taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded AGM is less than, equal to, or greater than the exact AGM. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p)=f(x,0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Up`, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_rational_prec_round`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[allow(clippy::needless_pass_by_value)]\n    #[inline]\n    pub fn agm_rational_prec(x: Rational, y: Rational, prec: u64) -> (Self, Ordering) {\n        Self::agm_rational_prec_round_val_ref(x, &y, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the nearest value of the specified precision, and returning the result as a [`Float`]. The\n    /// first [`Rational`] is taken by value and the second by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded AGM is less than, equal to, or greater than the\n    /// exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p)=f(x,0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Up`, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_rational_prec_round_val_ref`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_val_ref(\n    ///     Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_rational_prec_val_ref(x: Rational, y: &Rational, prec: u64) -> (Self, Ordering) {\n        Self::agm_rational_prec_round_val_ref(x, y, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the nearest value of the specified precision, and returning the result as a [`Float`]. The\n    /// first [`Rational`] is taken by reference and the second by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded AGM is less than, equal to, or greater than the\n    /// exact AGM. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p)=f(x,0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Up`, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_rational_prec_round_ref_val`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_ref_val(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_rational_prec_ref_val(x: &Rational, y: Rational, prec: u64) -> (Self, Ordering) {\n        Self::agm_rational_prec_round_ref_val(x, y, prec, Nearest)\n    }\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, rounding the result to\n    /// the nearest value of the specified precision, and returning the result as a [`Float`]. Both\n    /// [`Rational`]s are taken by reference. An [`Ordering`] is also returned, indicating whether\n    /// the rounded AGM is less than, equal to, or greater than the exact AGM. Although `NaN`s are\n    /// not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon|\n    ///   < 2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p+1}$.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\text{AGM}(x,y)\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0,x,p)=f(x,0,p)=0.0$\n    /// - $f(x,y,p)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Up`, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_rational_prec_round_ref_ref`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the two [`Rational`] arguments are positive and distinct (and\n    /// the exact result is therefore irrational).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (agm, o) = Float::agm_rational_prec_ref_ref(\n    ///     &Rational::from_unsigneds(2u8, 3),\n    ///     &Rational::from_unsigneds(1u8, 5),\n    ///     20,\n    /// );\n    /// assert_eq!(agm.to_string(), \"0.3985114\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn agm_rational_prec_ref_ref(x: &Rational, y: &Rational, prec: u64) -> (Self, Ordering) {\n        Self::agm_rational_prec_round_ref_ref(x, y, prec, Nearest)\n    }\n}\n\nimpl Agm<Self> for Float {\n    type Output = Self;\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, taking both by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the agm\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(-\\infty,x)=f(x,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty)=\\infty$\n    /// - $f(\\pm0.0,x)=f(x,\\pm0.0)=0.0$\n    /// - $f(x,y)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::agm_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::agm_round`].\n    /// If you want both of these things, consider using [`Float::agm_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Agm;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(\n    ///     Float::from_unsigned_prec(24u8, 100)\n    ///         .0\n    ///         .agm(Float::from(6))\n    ///         .to_string(),\n    ///     \"13.45817148172561542076681315698\"\n    /// );\n    /// ```\n    #[inline]\n    fn agm(self, other: Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Agm<&Self> for Float {\n    type Output = Self;\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, taking the first by value\n    /// and the second by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the agm\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(-\\infty,x)=f(x,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty)=\\infty$\n    /// - $f(\\pm0.0,x)=f(x,\\pm0.0)=0.0$\n    /// - $f(x,y)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_val_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::agm_round_val_ref`]. If you want both of these things, consider using\n    /// [`Float::agm_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Agm;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(\n    ///     Float::from_unsigned_prec(24u8, 100)\n    ///         .0\n    ///         .agm(&Float::from(6))\n    ///         .to_string(),\n    ///     \"13.45817148172561542076681315698\"\n    /// );\n    /// ```\n    #[inline]\n    fn agm(self, other: &Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Agm<Float> for &Float {\n    type Output = Float;\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, taking the first by\n    /// reference and the second by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the agm\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(-\\infty,x)=f(x,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty)=\\infty$\n    /// - $f(\\pm0.0,x)=f(x,\\pm0.0)=0.0$\n    /// - $f(x,y)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_ref_val`] instead. If you want to specify the output precision, consider\n    /// using [`Float::agm_round_ref_val`]. If you want both of these things, consider using\n    /// [`Float::agm_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Agm;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(\n    ///     (&Float::from_unsigned_prec(24u8, 100).0)\n    ///         .agm(Float::from(6))\n    ///         .to_string(),\n    ///     \"13.45817148172561542076681315698\"\n    /// );\n    /// ```\n    #[inline]\n    fn agm(self, other: Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Agm<&Float> for &Float {\n    type Output = Float;\n\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, taking both by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the agm\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(-\\infty,x)=f(x,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\text{NaN}$ if $x\\neq\\infty$\n    /// - $f(\\infty,\\infty)=\\infty$\n    /// - $f(\\pm0.0,x)=f(x,\\pm0.0)=0.0$\n    /// - $f(x,y)=\\text{NaN}$ if $x<0$ or $y<0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_ref_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::agm_round_ref_ref`]. If you want both of these things, consider using\n    /// [`Float::agm_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Agm;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(\n    ///     (&Float::from_unsigned_prec(24u8, 100).0)\n    ///         .agm(&Float::from(6))\n    ///         .to_string(),\n    ///     \"13.45817148172561542076681315698\"\n    /// );\n    /// ```\n    #[inline]\n    fn agm(self, other: &Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl AgmAssign<Self> for Float {\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and taking the [`Float`] on the right-hand side by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the agm\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the [`Float::agm`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::agm_round_assign`]. If you want both of these things, consider using\n    /// [`Float::agm_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AgmAssign;\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// x.agm_assign(Float::from(6));\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315698\");\n    /// ```\n    #[inline]\n    fn agm_assign(&mut self, other: Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl AgmAssign<&Self> for Float {\n    /// Computes the arithmetic-geometric mean (AGM) of two [`Float`]s, mutating the first one in\n    /// place, and taking the [`Float`] on the right-hand side by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the agm\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = \\text{AGM}(x,y)+\\varepsilon\n    /// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n    /// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n    /// $$\n    /// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed\n    ///   to be 0.\n    /// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the [`Float::agm`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::agm_prec_assign_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::agm_round_assign_ref`]. If you want both of these things, consider\n    /// using [`Float::agm_prec_round_assign_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AgmAssign;\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from_unsigned_prec(24u8, 100).0;\n    /// x.agm_assign(&Float::from(6));\n    /// assert_eq!(x.to_string(), \"13.45817148172561542076681315698\");\n    /// ```\n    #[inline]\n    fn agm_assign(&mut self, other: &Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.agm_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\n/// Computes the arithmetic-geometric mean (AGM) of two primitive floats.\n///\n/// $$\n/// f(x,y) = \\text{AGM}(x,y)+\\varepsilon\n/// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n/// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n/// $$\n/// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to\n///   be 0.\n/// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is precision of the output (typically 24 if `T` is a\n///   [`f32`] and 53 if `T` is a [`f64`], but less if the output is subnormal).\n///\n/// Special cases:\n/// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(-\\infty,x)=f(x,-\\infty)=\\text{NaN}$\n/// - $f(\\infty,x)=f(x,\\infty)=\\text{NaN}$ if $x\\neq\\infty$\n/// - $f(\\infty,\\infty)=\\infty$\n/// - $f(\\pm0.0,x)=f(x,\\pm0.0)=0.0$\n/// - $f(x,y)=\\text{NaN}$ if $x<0$ or $y<0$\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::arithmetic::agm::primitive_float_agm;\n///\n/// assert_eq!(\n///     NiceFloat(primitive_float_agm(24.0, 6.0)),\n///     NiceFloat(13.458171481725616)\n/// );\n/// ```\n#[allow(clippy::type_repetition_in_bounds)]\n#[inline]\npub fn primitive_float_agm<T: PrimitiveFloat>(x: T, y: T) -> T\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    emulate_float_float_to_float_fn(Float::agm_prec, x, y)\n}\n\n/// Computes the arithmetic-geometric mean (AGM) of two [`Rational`]s, returning the result as a\n/// primitive float.\n///\n/// $$\n/// f(x,y) = \\text{AGM}(x,y)+\\varepsilon\n/// =\\frac{\\pi}{2}\\left(\\int_0^{\\frac{\\pi}{2}}\\frac{\\mathrm{d}\\theta}\n/// {\\sqrt{x^2\\cos^2\\theta+y^2\\sin^2\\theta}}\\right)^{-1}+\\varepsilon.\n/// $$\n/// - If $\\text{AGM}(x,y)$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to\n///   be 0.\n/// - If $\\text{AGM}(x,y)$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n///   \\text{AGM}(x,y)\\rfloor-p}$, where $p$ is precision of the output (typically 24 if `T` is a\n///   [`f32`] and 53 if `T` is a [`f64`], but less if the output is subnormal).\n///\n/// Special cases:\n/// - $f(0,x)=f(x,0)=0.0$\n/// - $f(x,y)=\\text{NaN}$ if $x<0$ or $y<0$\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::arithmetic::agm::primitive_float_agm_rational;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     NiceFloat(primitive_float_agm_rational::<f64>(\n///         &Rational::from_unsigneds(2u8, 3),\n///         &Rational::from_unsigneds(1u8, 5)\n///     )),\n///     NiceFloat(0.3985113702200345)\n/// );\n/// ```\n#[allow(clippy::type_repetition_in_bounds)]\n#[inline]\npub fn primitive_float_agm_rational<T: PrimitiveFloat>(x: &Rational, y: &Rational) -> T\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    emulate_rational_rational_to_float_fn(Float::agm_rational_prec_ref_ref, x, y)\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::arithmetic::is_power_of_2::abs_is_power_of_2;\nuse crate::conversion::from_natural::{from_natural_zero_exponent, from_natural_zero_exponent_ref};\nuse crate::{\n    Float, float_either_infinity, float_either_zero, float_infinity, float_nan,\n    float_negative_infinity, float_negative_zero, float_zero,\n};\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse core::mem::swap;\nuse core::ops::{Div, DivAssign};\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, FloorLogBase2, IsPowerOf2, NegAssign, Sign,\n};\nuse malachite_base::num::basic::traits::{\n    Infinity as InfinityTrait, NaN as NaNTrait, NegativeInfinity, NegativeZero, Zero as ZeroTrait,\n};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{NotAssign, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_div::{\n    div_float_significands_in_place, div_float_significands_in_place_ref,\n    div_float_significands_ref_ref, div_float_significands_ref_val,\n};\nuse malachite_q::Rational;\n\nconst DIV_RATIONAL_THRESHOLD: u64 = 50;\nconst RATIONAL_DIV_THRESHOLD: u64 = 50;\n\nfn div_rational_prec_round_assign_naive(\n    x: &mut Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    match (&mut *x, y) {\n        (float_nan!(), _) => Equal,\n        (Float(Infinity { sign }), y) => {\n            if y < 0 {\n                sign.not_assign();\n            };\n            Equal\n        }\n        (Float(Zero { sign }), y) => {\n            match y.sign() {\n                Equal => *x = float_nan!(),\n                Greater => {}\n                Less => sign.not_assign(),\n            }\n            Equal\n        }\n        (x, y) => {\n            if y == 0 {\n                *x = Float(Infinity { sign: *x > 0u32 });\n                Equal\n            } else {\n                let not_sign = *x < 0;\n                let mut z = Float::ZERO;\n                swap(x, &mut z);\n                let (mut quotient, o) =\n                    Float::from_rational_prec_round(Rational::exact_from(z) / y, prec, rm);\n                if quotient == 0u32 && not_sign {\n                    quotient.neg_assign();\n                }\n                *x = quotient;\n                o\n            }\n        }\n    }\n}\n\nfn div_rational_prec_round_assign_naive_ref(\n    x: &mut Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    match (&mut *x, y) {\n        (float_nan!(), _) => Equal,\n        (Float(Infinity { sign }), y) => {\n            if *y < 0 {\n                sign.not_assign();\n            };\n            Equal\n        }\n        (Float(Zero { sign }), y) => {\n            match y.sign() {\n                Equal => *x = float_nan!(),\n                Greater => {}\n                Less => sign.not_assign(),\n            }\n            Equal\n        }\n        (x, y) => {\n            if *y == 0 {\n                *x = Float(Infinity { sign: *x > 0u32 });\n                Equal\n            } else {\n                let not_sign = *x < 0;\n                let mut z = Float::ZERO;\n                swap(x, &mut z);\n                let (mut quotient, o) =\n                    Float::from_rational_prec_round(Rational::exact_from(z) / y, prec, rm);\n                if quotient == 0u32 && not_sign {\n                    quotient.neg_assign();\n                }\n                *x = quotient;\n                o\n            }\n        }\n    }\n}\n\npub_test! {div_rational_prec_round_naive(\n    mut x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = div_rational_prec_round_assign_naive(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {div_rational_prec_round_naive_val_ref(\n    mut x: Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = div_rational_prec_round_assign_naive_ref(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {div_rational_prec_round_naive_ref_val(\n    x: &Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (float_nan!(), _) => (float_nan!(), Equal),\n        (Float(Infinity { sign }), y) => (\n            if y >= 0u32 {\n                Float(Infinity { sign: *sign })\n            } else {\n                Float(Infinity { sign: !*sign })\n            },\n            Equal,\n        ),\n        (Float(Zero { sign }), y) => (\n            match y.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Zero { sign: *sign }),\n                Less => Float(Zero { sign: !*sign }),\n            },\n            Equal,\n        ),\n        (x, y) => {\n            if y == 0 {\n                (Float(Infinity { sign: *x > 0u32 }), Equal)\n            } else {\n                let (mut quotient, o) =\n                    Float::from_rational_prec_round(Rational::exact_from(x) / y, prec, rm);\n                if quotient == 0u32 && *x < 0 {\n                    quotient.neg_assign();\n                }\n                (quotient, o)\n            }\n        }\n    }\n}}\n\npub_test! {div_rational_prec_round_naive_ref_ref(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (float_nan!(), _) => (float_nan!(), Equal),\n        (Float(Infinity { sign }), y) => (\n            if *y >= 0u32 {\n                Float(Infinity { sign: *sign })\n            } else {\n                Float(Infinity { sign: !*sign })\n            },\n            Equal,\n        ),\n        (Float(Zero { sign }), y) => (\n            match y.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Zero { sign: *sign }),\n                Less => Float(Zero { sign: !*sign }),\n            },\n            Equal,\n        ),\n        (x, y) => {\n            if *y == 0 {\n                (Float(Infinity { sign: *x > 0u32 }), Equal)\n            } else {\n                let (mut quotient, o) =\n                    Float::from_rational_prec_round(Rational::exact_from(x) / y, prec, rm);\n                if quotient == 0u32 && *x < 0 {\n                    quotient.neg_assign();\n                }\n                (quotient, o)\n            }\n        }\n    }\n}}\n\nfn div_rational_prec_round_assign_direct(\n    x: &mut Float,\n    y: Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    if y == 0u32 {\n        *x = match (*x).partial_cmp(&0u32) {\n            Some(Greater) => Float::INFINITY,\n            Some(Less) => Float::NEGATIVE_INFINITY,\n            _ => Float::NAN,\n        };\n        return Equal;\n    }\n    let sign = y >= 0;\n    let (n, d) = y.into_numerator_and_denominator();\n    if !sign {\n        rm.neg_assign();\n    }\n    let o = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_assign(i128::from(log_d) - i128::from(log_n), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent(n), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(log_d) - 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent(d), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(log_n) + i128::from(d_exp) + 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent(n);\n            let d = from_natural_zero_exponent(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + d.significant_bits();\n            *x >>= x_exp;\n            x.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = x.div_prec_round_assign(n, prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            )\n        }\n    };\n    if sign {\n        o\n    } else {\n        x.neg_assign();\n        o.reverse()\n    }\n}\n\nfn div_rational_prec_round_assign_direct_ref(\n    x: &mut Float,\n    y: &Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    if *y == 0u32 {\n        *x = match (*x).partial_cmp(&0u32) {\n            Some(Greater) => Float::INFINITY,\n            Some(Less) => Float::NEGATIVE_INFINITY,\n            _ => Float::NAN,\n        };\n        return Equal;\n    }\n    let sign = *y >= 0;\n    let (n, d) = y.numerator_and_denominator_ref();\n    if !sign {\n        rm.neg_assign();\n    }\n    let o = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_assign(i128::from(log_d) - i128::from(log_n), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent_ref(n), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(log_d) - 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent_ref(d), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(log_n) + i128::from(d_exp) + 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent_ref(n);\n            let d = from_natural_zero_exponent_ref(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + d.significant_bits();\n            *x >>= x_exp;\n            x.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = x.div_prec_round_assign(n, prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            )\n        }\n    };\n    if sign {\n        o\n    } else {\n        x.neg_assign();\n        o.reverse()\n    }\n}\n\npub_test! {div_rational_prec_round_direct(\n    mut x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = div_rational_prec_round_assign_direct(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {div_rational_prec_round_direct_val_ref(\n    mut x: Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = div_rational_prec_round_assign_direct_ref(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {div_rational_prec_round_direct_ref_val(\n    x: &Float,\n    y: Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    let sign = y >= 0;\n    if y == 0u32 {\n        return (\n            match x.partial_cmp(&0u32) {\n                Some(Greater) => Float::INFINITY,\n                Some(Less) => Float::NEGATIVE_INFINITY,\n                _ => Float::NAN,\n            },\n            Equal,\n        );\n    }\n    let (n, d) = y.into_numerator_and_denominator();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (quotient, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_ref(i128::from(log_d) - i128::from(log_n), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent(n), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(log_d) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent(d), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(log_n) + i128::from(d_exp) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent(n);\n            let d = from_natural_zero_exponent(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + d.significant_bits();\n            let mut x = x >> x_exp;\n            x.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = x.div_prec_round_assign(n, prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n    };\n    if sign {\n        (quotient, o)\n    } else {\n        (-quotient, o.reverse())\n    }\n}}\n\npub_test! {div_rational_prec_round_direct_ref_ref(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if *y == 0u32 {\n        return (\n            match x.partial_cmp(&0u32) {\n                Some(Greater) => Float::INFINITY,\n                Some(Less) => Float::NEGATIVE_INFINITY,\n                _ => Float::NAN,\n            },\n            Equal,\n        );\n    }\n    let sign = *y >= 0;\n    let (n, d) = y.numerator_and_denominator_ref();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (quotient, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_ref(i128::from(log_d) - i128::from(log_n), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent_ref(n), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(log_d) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent_ref(d), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(log_n) + i128::from(d_exp) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent_ref(n);\n            let d = from_natural_zero_exponent_ref(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + d.significant_bits();\n            let mut x = x >> x_exp;\n            x.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = x.div_prec_round_assign(n, prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) - i128::from(n_exp) + i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n    };\n    if sign {\n        (quotient, o)\n    } else {\n        (-quotient, o.reverse())\n    }\n}}\n\npub_test! {rational_div_float_prec_round_naive(\n    x: Rational,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (_, float_nan!()) => (float_nan!(), Equal),\n        (x, Float(Infinity { sign })) => (\n            if x >= 0u32 {\n                Float(Zero { sign })\n            } else {\n                Float(Zero { sign: !sign })\n            },\n            Equal,\n        ),\n        (x, Float(Zero { sign })) => (\n            match x.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Infinity { sign }),\n                Less => Float(Infinity { sign: !sign }),\n            },\n            Equal,\n        ),\n        (x, y) => {\n            let not_sign = y < 0;\n            let (mut quotient, o) =\n                Float::from_rational_prec_round(x / Rational::exact_from(y), prec, rm);\n            if quotient == 0u32 && not_sign {\n                quotient.neg_assign();\n            }\n            (quotient, o)\n        }\n    }\n}}\n\npub_test! {rational_div_float_prec_round_naive_val_ref(\n    x: Rational,\n    y: &Float,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (_, float_nan!()) => (float_nan!(), Equal),\n        (x, Float(Infinity { sign })) => (\n            if x >= 0u32 {\n                Float(Zero { sign: *sign })\n            } else {\n                Float(Zero { sign: !*sign })\n            },\n            Equal,\n        ),\n        (x, Float(Zero { sign })) => (\n            match x.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Infinity { sign: *sign }),\n                Less => Float(Infinity { sign: !*sign }),\n            },\n            Equal,\n        ),\n        (x, y) => {\n            let (mut quotient, o) =\n                Float::from_rational_prec_round(x / Rational::exact_from(y), prec, rm);\n            if quotient == 0u32 && *y < 0 {\n                quotient.neg_assign();\n            }\n            (quotient, o)\n        }\n    }\n}}\n\npub_test! {rational_div_float_prec_round_naive_ref_val(\n    x: &Rational,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (_, float_nan!()) => (float_nan!(), Equal),\n        (x, Float(Infinity { sign })) => (\n            if *x >= 0u32 {\n                Float(Zero { sign })\n            } else {\n                Float(Zero { sign: !sign })\n            },\n            Equal,\n        ),\n        (x, Float(Zero { sign })) => (\n            match x.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Infinity { sign }),\n                Less => Float(Infinity { sign: !sign }),\n            },\n            Equal,\n        ),\n        (x, y) => {\n            let not_sign = y < 0;\n            let (mut quotient, o) =\n                Float::from_rational_prec_round(x / Rational::exact_from(y), prec, rm);\n            if quotient == 0u32 && not_sign {\n                quotient.neg_assign();\n            }\n            (quotient, o)\n        }\n    }\n}}\n\npub_test! {rational_div_float_prec_round_naive_ref_ref(\n    x: &Rational,\n    y: &Float,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (_, float_nan!()) => (float_nan!(), Equal),\n        (x, Float(Infinity { sign })) => (\n            if *x >= 0u32 {\n                Float(Zero { sign: *sign })\n            } else {\n                Float(Zero { sign: !*sign })\n            },\n            Equal,\n        ),\n        (x, Float(Zero { sign })) => (\n            match x.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Infinity { sign: *sign }),\n                Less => Float(Infinity { sign: !*sign }),\n            },\n            Equal,\n        ),\n        (x, y) => {\n            let (mut quotient, o) =\n                Float::from_rational_prec_round(x / Rational::exact_from(y), prec, rm);\n            if quotient == 0u32 && *y < 0 {\n                quotient.neg_assign();\n            }\n            (quotient, o)\n        }\n    }\n}}\n\npub_test! {rational_div_float_prec_round_direct(\n    x: Rational,\n    y: Float,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if x == 0u32 {\n        return (\n            if y > 0u32 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            },\n            Equal,\n        );\n    }\n    let sign = x >= 0;\n    let (n, d) = x.into_numerator_and_denominator();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (quotient, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let (mut quotient, o) = (y >> y_exp).reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(log_d) - i128::from(y_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent(n);\n            let o = quotient.div_prec_round_assign(y >> y_exp, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(n_exp) - i128::from(log_d) - i128::from(y_exp) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (Some(log_n), None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut y = y >> y_exp;\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            y.mul_prec_round_assign(from_natural_zero_exponent(d), mul_prec, Floor);\n            let (mut quotient, o) = y.reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(d_exp) - i128::from(y_exp) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent(n);\n            let d = from_natural_zero_exponent(d);\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            let mut y = y >> y_exp;\n            y.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = quotient.div_prec_round_assign(y, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                -i128::from(y_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n    };\n    if sign {\n        (quotient, o)\n    } else {\n        (-quotient, o.reverse())\n    }\n}}\n\npub_test! {rational_div_float_prec_round_direct_val_ref(\n    x: Rational,\n    y: &Float,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if x == 0u32 {\n        return (\n            if *y > 0u32 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            },\n            Equal,\n        );\n    }\n    let sign = x >= 0;\n    let (n, d) = x.into_numerator_and_denominator();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (quotient, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let (mut quotient, o) = (y >> y_exp).reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(log_d) - i128::from(y_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent(n);\n            let o = quotient.div_prec_round_assign(y >> y_exp, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(n_exp) - i128::from(log_d) - i128::from(y_exp) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (Some(log_n), None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut y = y >> y_exp;\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            y.mul_prec_round_assign(from_natural_zero_exponent(d), mul_prec, Floor);\n            let (mut quotient, o) = y.reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(d_exp) - i128::from(y_exp) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent(n);\n            let d = from_natural_zero_exponent(d);\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            let mut y = y >> y_exp;\n            y.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = quotient.div_prec_round_assign(y, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                -i128::from(y_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n    };\n    if sign {\n        (quotient, o)\n    } else {\n        (-quotient, o.reverse())\n    }\n}}\n\npub_test! {rational_div_float_prec_round_direct_ref_val(\n    x: &Rational,\n    y: Float,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if *x == 0u32 {\n        return (\n            if y > 0u32 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            },\n            Equal,\n        );\n    }\n    let sign = *x >= 0;\n    let (n, d) = x.numerator_and_denominator_ref();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (quotient, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let (mut quotient, o) = (y >> y_exp).reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(log_d) - i128::from(y_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent_ref(n);\n            let o = quotient.div_prec_round_assign(y >> y_exp, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(n_exp) - i128::from(log_d) - i128::from(y_exp) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (Some(log_n), None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut y = y >> y_exp;\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            y.mul_prec_round_assign(from_natural_zero_exponent_ref(d), mul_prec, Floor);\n            let (mut quotient, o) = y.reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(d_exp) - i128::from(y_exp) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent_ref(n);\n            let d = from_natural_zero_exponent_ref(d);\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            let mut y = y >> y_exp;\n            y.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = quotient.div_prec_round_assign(y, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                -i128::from(y_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n    };\n    if sign {\n        (quotient, o)\n    } else {\n        (-quotient, o.reverse())\n    }\n}}\n\npub_test! {rational_div_float_prec_round_direct_ref_ref(\n    x: &Rational,\n    y: &Float,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if *x == 0u32 {\n        return (\n            if *y > 0u32 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            },\n            Equal,\n        );\n    }\n    let sign = *x >= 0;\n    let (n, d) = x.numerator_and_denominator_ref();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (quotient, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let (mut quotient, o) = (y >> y_exp).reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(log_d) - i128::from(y_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, Some(log_d)) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent_ref(n);\n            let o = quotient.div_prec_round_assign(y >> y_exp, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(n_exp) - i128::from(log_d) - i128::from(y_exp) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (Some(log_n), None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut y = y >> y_exp;\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            y.mul_prec_round_assign(from_natural_zero_exponent_ref(d), mul_prec, Floor);\n            let (mut quotient, o) = y.reciprocal_prec_round(prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(d_exp) - i128::from(y_exp) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n        (None, None) => {\n            let y_exp = y.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let mut quotient = from_natural_zero_exponent_ref(n);\n            let d = from_natural_zero_exponent_ref(d);\n            let mul_prec = y.get_min_prec().unwrap_or(1) + d.significant_bits();\n            let mut y = y >> y_exp;\n            y.mul_prec_round_assign(d, mul_prec, Floor);\n            let o = quotient.div_prec_round_assign(y, prec, rm);\n            let o = quotient.shl_prec_round_assign_helper(\n                -i128::from(y_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (quotient, o)\n        }\n    };\n    if sign {\n        (quotient, o)\n    } else {\n        (-quotient, o.reverse())\n    }\n}}\n\nimpl Float {\n    /// Divides two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. Both [`Float`]s are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_prec`] instead. If you\n    /// know that your target precision is the maximum of the precisions of the two inputs, consider\n    /// using [`Float::div_round`] instead. If both of these things are true, consider using `/`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round(Float::from(E), 5, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round(Float::from(E), 5, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.19\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round(Float::from(E), 5, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round(Float::from(E), 20, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.155725\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round(Float::from(E), 20, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round(Float::from(E), 20, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec_round(mut self, other: Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.div_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Divides two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. The first [`Float`] is are taken by value and the second by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_prec_val_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::div_round_val_ref`] instead. If both of these things are true,\n    /// consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_val_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_val_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.19\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_val_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_val_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.155725\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_val_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_val_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec_round_val_ref(\n        mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.div_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Divides two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. The first [`Float`] is are taken by reference and the second by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_prec_ref_val`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::div_round_ref_val`] instead. If both of these things are true,\n    /// consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_val(Float::from(E), 5, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_val(Float::from(E), 5, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.19\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_val(Float::from(E), 5, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_val(Float::from(E), 20, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.155725\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_val(Float::from(E), 20, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_val(Float::from(E), 20, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec_round_ref_val(\n        &self,\n        other: Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _)\n            | (_, float_nan!())\n            | (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => (float_nan!(), Equal),\n            (\n                Self(Infinity { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Zero { sign: y_sign })) => (\n                Self(Infinity {\n                    sign: *x_sign == y_sign,\n                }),\n                Equal,\n            ),\n            (\n                Self(Zero { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Infinity { sign: y_sign })) => (\n                Self(Zero {\n                    sign: *x_sign == y_sign,\n                }),\n                Equal,\n            ),\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: mut y,\n                }),\n            ) => {\n                if y.is_power_of_2() {\n                    let (mut quotient, mut o) =\n                        self.shr_prec_round_ref(y_exp - 1, prec, if y_sign { rm } else { -rm });\n                    if !y_sign {\n                        quotient.neg_assign();\n                        o = o.reverse();\n                    }\n                    return (quotient, o);\n                }\n                let sign = *x_sign == y_sign;\n                let exp_diff = *x_exp - y_exp;\n                if exp_diff > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                } else if exp_diff + 2 < Self::MIN_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up) => (Self::min_positive_value_prec(prec), Greater),\n                        (true, _) => (float_zero!(), Less),\n                        (false, Floor | Up) => (-Self::min_positive_value_prec(prec), Less),\n                        (false, _) => (float_negative_zero!(), Greater),\n                    };\n                }\n                let (quotient, exp_offset, o) = div_float_significands_ref_val(\n                    x,\n                    *x_prec,\n                    &mut y,\n                    y_prec,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                let exp = exp_diff.checked_add(i32::exact_from(exp_offset)).unwrap();\n                if exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                } else if exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !quotient.is_power_of_2())\n                    {\n                        if sign {\n                            (Self::min_positive_value_prec(prec), Greater)\n                        } else {\n                            (-Self::min_positive_value_prec(prec), Less)\n                        }\n                    } else {\n                        match (sign, rm) {\n                            (_, Exact) => panic!(\"Inexact Float division\"),\n                            (true, Ceiling | Up) => (Self::min_positive_value_prec(prec), Greater),\n                            (true, _) => (float_zero!(), Less),\n                            (false, Floor | Up) => (-Self::min_positive_value_prec(prec), Less),\n                            (false, _) => (float_negative_zero!(), Greater),\n                        }\n                    };\n                }\n                (\n                    Self(Finite {\n                        sign,\n                        exponent: exp,\n                        precision: prec,\n                        significand: quotient,\n                    }),\n                    if sign { o } else { o.reverse() },\n                )\n            }\n        }\n    }\n\n    /// Divides two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. Both [`Float`]s are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_prec_ref_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::div_round_ref_ref`] instead. If both of these things are true,\n    /// consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.19\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(quotient.to_string(), \"1.155725\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_round_ref_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec_round_ref_ref(\n        &self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _)\n            | (_, float_nan!())\n            | (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => (float_nan!(), Equal),\n            (\n                Self(Infinity { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Zero { sign: y_sign })) => (\n                Self(Infinity {\n                    sign: x_sign == y_sign,\n                }),\n                Equal,\n            ),\n            (\n                Self(Zero { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Infinity { sign: y_sign })) => (\n                Self(Zero {\n                    sign: x_sign == y_sign,\n                }),\n                Equal,\n            ),\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: y,\n                }),\n            ) => {\n                if y.is_power_of_2() {\n                    let (mut quotient, mut o) =\n                        self.shr_prec_round_ref(y_exp - 1, prec, if *y_sign { rm } else { -rm });\n                    if !*y_sign {\n                        quotient.neg_assign();\n                        o = o.reverse();\n                    }\n                    return (quotient, o);\n                }\n                let sign = x_sign == y_sign;\n                let exp_diff = *x_exp - y_exp;\n                if exp_diff > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                } else if exp_diff + 2 < Self::MIN_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up) => (Self::min_positive_value_prec(prec), Greater),\n                        (true, _) => (float_zero!(), Less),\n                        (false, Floor | Up) => (-Self::min_positive_value_prec(prec), Less),\n                        (false, _) => (float_negative_zero!(), Greater),\n                    };\n                }\n                let (quotient, exp_offset, o) = div_float_significands_ref_ref(\n                    x,\n                    *x_prec,\n                    y,\n                    *y_prec,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                let exp = exp_diff.checked_add(i32::exact_from(exp_offset)).unwrap();\n                if exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                } else if exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !quotient.is_power_of_2())\n                    {\n                        if sign {\n                            (Self::min_positive_value_prec(prec), Greater)\n                        } else {\n                            (-Self::min_positive_value_prec(prec), Less)\n                        }\n                    } else {\n                        match (sign, rm) {\n                            (_, Exact) => panic!(\"Inexact Float division\"),\n                            (true, Ceiling | Up) => (Self::min_positive_value_prec(prec), Greater),\n                            (true, _) => (float_zero!(), Less),\n                            (false, Floor | Up) => (-Self::min_positive_value_prec(prec), Less),\n                            (false, _) => (float_negative_zero!(), Greater),\n                        }\n                    };\n                }\n                (\n                    Self(Finite {\n                        sign,\n                        exponent: exp,\n                        precision: prec,\n                        significand: quotient,\n                    }),\n                    if sign { o } else { o.reverse() },\n                )\n            }\n        }\n    }\n\n    /// Divides two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// Both [`Float`]s are taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded quotient is less than, equal to, or greater than the exact quotient. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_round`] instead. If you know that your target precision is the maximum of\n    /// the precisions of the two inputs, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec(Float::from(E), 5);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec(Float::from(E), 20);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec(self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.div_prec_round(other, prec, Nearest)\n    }\n\n    /// Divides two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// The first [`Float`] is taken by value and the second by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_round_val_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_val_ref(&Float::from(E), 5);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_val_ref(&Float::from(E), 20);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec_val_ref(self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.div_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Divides two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// The first [`Float`] is taken by reference and the second by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_round_ref_val`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_ref_val(Float::from(E), 5);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_ref_val(Float::from(E), 20);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec_ref_val(&self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.div_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Divides two [`Float`]s, rounding the result to the nearest value of the specified precision.\n    /// Both [`Float`]s are taken by reference. An [`Ordering`] is also returned, indicating whether\n    /// the rounded quotient is less than, equal to, or greater than the exact quotient. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,p)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,p)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,p)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,p)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,p)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,p)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_round_ref_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_ref_ref(&Float::from(E), 5);\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_prec_ref_ref(&Float::from(E), 20);\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn div_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.div_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Divides two [`Float`]s, rounding the result with the specified rounding mode. Both\n    /// [`Float`]s are taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded quotient is less than, equal to, or greater than the exact quotient. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::div_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `/`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round(Float::from(E), Floor);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round(Float::from(E), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727349790922\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round(Float::from(E), Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_round(self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round(other, prec, rm)\n    }\n\n    /// Divides two [`Float`]s, rounding the result with the specified rounding mode. The first\n    /// [`Float`] is taken by value and the second by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded quotient is less than, equal to, or greater than the exact\n    /// quotient. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::div_prec_round_val_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `/`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_val_ref(&Float::from(E), Floor);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_val_ref(&Float::from(E), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727349790922\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_val_ref(&Float::from(E), Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_round_val_ref(self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Divides two [`Float`]s, rounding the result with the specified rounding mode. The first\n    /// [`Float`] is taken by reference and the second by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded quotient is less than, equal to, or greater than the exact\n    /// quotient. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::div_prec_round_ref_val`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `/`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_ref_val(Float::from(E), Floor);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_ref_val(Float::from(E), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727349790922\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_ref_val(Float::from(E), Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_round_ref_val(&self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Divides two [`Float`]s, rounding the result with the specified rounding mode. Both\n    /// [`Float`]s are taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// rounded quotient is less than, equal to, or greater than the exact quotient. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm\\infty,p,m)=f(\\pm0.0,\\pm0.0,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x,m)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0,m)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x,m)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0,m)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x,m)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x,m)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::div_prec_round_ref_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `/`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_ref_ref(&Float::from(E), Floor);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_ref_ref(&Float::from(E), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"1.155727349790922\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_round_ref_ref(&Float::from(E), Nearest);\n    /// assert_eq!(quotient.to_string(), \"1.1557273497909217\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_round_ref_ref(&self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Float`] in place, rounding the result to the specified precision\n    /// and with the specified rounding mode. The [`Float`] on the right-hand side is taken by\n    /// value. An [`Ordering`] is returned, indicating whether the rounded quotient is less than,\n    /// equal to, or greater than the exact quotient. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_prec_assign`] instead. If\n    /// you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::div_round_assign`] instead. If both of these things are true,\n    /// consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign(Float::from(E), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign(Float::from(E), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.19\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign(Float::from(E), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign(Float::from(E), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.155725\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign(Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign(Float::from(E), 20, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// ```\n    #[inline]\n    pub fn div_prec_round_assign(&mut self, other: Self, prec: u64, rm: RoundingMode) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (float_nan!(), _)\n            | (_, float_nan!())\n            | (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => {\n                *self = float_nan!();\n                Equal\n            }\n            (\n                Self(Infinity { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Zero { sign: y_sign })) => {\n                *self = Self(Infinity {\n                    sign: *x_sign == y_sign,\n                });\n                Equal\n            }\n            (\n                Self(Zero { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Infinity { sign: y_sign })) => {\n                *self = Self(Zero {\n                    sign: *x_sign == y_sign,\n                });\n                Equal\n            }\n            (_, y) if abs_is_power_of_2(&y) => {\n                let sign = y >= 0;\n                let mut o = self.shr_prec_round_assign(\n                    y.get_exponent().unwrap() - 1,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                if !sign {\n                    self.neg_assign();\n                    o = o.reverse();\n                }\n                o\n            }\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: mut y,\n                }),\n            ) => {\n                let sign = *x_sign == y_sign;\n                let exp_diff = *x_exp - y_exp;\n                if exp_diff > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if exp_diff + 2 < Self::MIN_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up) => {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = float_zero!();\n                            Less\n                        }\n                        (false, Floor | Up) => {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                        (false, _) => {\n                            *self = float_negative_zero!();\n                            Greater\n                        }\n                    };\n                }\n                let (exp_offset, o) = div_float_significands_in_place(\n                    x,\n                    *x_prec,\n                    &mut y,\n                    y_prec,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                *x_exp = exp_diff.checked_add(i32::exact_from(exp_offset)).unwrap();\n                if *x_exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if *x_exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && *x_exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !x.is_power_of_2())\n                    {\n                        if sign {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        } else {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                    } else {\n                        match (sign, rm) {\n                            (_, Exact) => panic!(\"Inexact Float division\"),\n                            (true, Ceiling | Up) => {\n                                *self = Self::min_positive_value_prec(prec);\n                                Greater\n                            }\n                            (true, _) => {\n                                *self = float_zero!();\n                                Less\n                            }\n                            (false, Floor | Up) => {\n                                *self = -Self::min_positive_value_prec(prec);\n                                Less\n                            }\n                            (false, _) => {\n                                *self = float_negative_zero!();\n                                Greater\n                            }\n                        }\n                    };\n                }\n                *x_sign = sign;\n                *x_prec = prec;\n                if sign { o } else { o.reverse() }\n            }\n        }\n    }\n\n    /// Divides a [`Float`] by a [`Float`] in place, rounding the result to the specified precision\n    /// and with the specified rounding mode. The [`Float`] on the right-hand side is taken by\n    /// reference. An [`Ordering`] is returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_prec_assign_ref`]\n    /// instead. If you know that your target precision is the maximum of the precisions of the two\n    /// inputs, consider using [`Float::div_round_assign_ref`] instead. If both of these things are\n    /// true, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign_ref(&Float::from(E), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign_ref(&Float::from(E), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.19\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign_ref(&Float::from(E), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.12\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign_ref(&Float::from(E), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.155725\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign_ref(&Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    ///\n    /// let mut quotient = Float::from(PI);\n    /// assert_eq!(\n    ///     quotient.div_prec_round_assign_ref(&Float::from(E), 20, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(quotient.to_string(), \"1.155727\");\n    /// ```\n    #[inline]\n    pub fn div_prec_round_assign_ref(\n        &mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (float_nan!(), _)\n            | (_, float_nan!())\n            | (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => {\n                *self = float_nan!();\n                Equal\n            }\n            (\n                Self(Infinity { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Zero { sign: y_sign })) => {\n                *self = Self(Infinity {\n                    sign: x_sign == y_sign,\n                });\n                Equal\n            }\n            (\n                Self(Zero { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Infinity { sign: y_sign })) => {\n                *self = Self(Zero {\n                    sign: x_sign == y_sign,\n                });\n                Equal\n            }\n            (_, y) if abs_is_power_of_2(y) => {\n                let sign = *y >= 0;\n                let mut o = self.shr_prec_round_assign(\n                    y.get_exponent().unwrap() - 1,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                if !sign {\n                    self.neg_assign();\n                    o = o.reverse();\n                }\n                o\n            }\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: y,\n                }),\n            ) => {\n                let sign = x_sign == y_sign;\n                let exp_diff = *x_exp - y_exp;\n                if exp_diff > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if exp_diff + 2 < Self::MIN_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up) => {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = float_zero!();\n                            Less\n                        }\n                        (false, Floor | Up) => {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                        (false, _) => {\n                            *self = float_negative_zero!();\n                            Greater\n                        }\n                    };\n                }\n                let (exp_offset, o) = div_float_significands_in_place_ref(\n                    x,\n                    *x_prec,\n                    y,\n                    *y_prec,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                *x_exp = exp_diff.checked_add(i32::exact_from(exp_offset)).unwrap();\n                if *x_exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float division\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if *x_exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && *x_exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !x.is_power_of_2())\n                    {\n                        if sign {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        } else {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                    } else {\n                        match (sign, rm) {\n                            (_, Exact) => panic!(\"Inexact Float division\"),\n                            (true, Ceiling | Up) => {\n                                *self = Self::min_positive_value_prec(prec);\n                                Greater\n                            }\n                            (true, _) => {\n                                *self = float_zero!();\n                                Less\n                            }\n                            (false, Floor | Up) => {\n                                *self = -Self::min_positive_value_prec(prec);\n                                Less\n                            }\n                            (false, _) => {\n                                *self = float_negative_zero!();\n                                Greater\n                            }\n                        }\n                    };\n                }\n                *x_sign = sign;\n                *x_prec = prec;\n                if sign { o } else { o.reverse() }\n            }\n        }\n    }\n\n    /// Divides a [`Float`] by a [`Float`] in place, rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] on the right-hand side is taken by value. An [`Ordering`]\n    /// is returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_round_assign`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_prec_assign(Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"1.12\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_prec_assign(Float::from(E), 20), Greater);\n    /// assert_eq!(x.to_string(), \"1.155727\");\n    /// ```\n    #[inline]\n    pub fn div_prec_assign(&mut self, other: Self, prec: u64) -> Ordering {\n        self.div_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Float`] in place, rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] on the right-hand side is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded quotient is less than, equal to, or\n    /// greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_round_assign_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), `prec`)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_prec_assign_ref(&Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"1.12\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_prec_assign_ref(&Float::from(E), 20), Greater);\n    /// assert_eq!(x.to_string(), \"1.155727\");\n    /// ```\n    #[inline]\n    pub fn div_prec_assign_ref(&mut self, other: &Self, prec: u64) -> Ordering {\n        self.div_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Float`] in place, rounding the result with the specified rounding\n    /// mode. The [`Float`] on the right-hand side is taken by value. An [`Ordering`] is returned,\n    /// indicating whether the rounded quotient is less than, equal to, or greater than the exact\n    /// quotient. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::div_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::div_prec_round_assign`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `/=`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_round_assign(Float::from(E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"1.1557273497909217\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_round_assign(Float::from(E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"1.155727349790922\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_round_assign(Float::from(E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"1.1557273497909217\");\n    /// ```\n    #[inline]\n    pub fn div_round_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_assign(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Float`] in place, rounding the result with the specified rounding\n    /// mode. The [`Float`] on the right-hand side is taken by reference. An [`Ordering`] is\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::div_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::div_prec_round_assign_ref`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_round_assign_ref(&Float::from(E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"1.1557273497909217\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_round_assign_ref(&Float::from(E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"1.155727349790922\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.div_round_assign_ref(&Float::from(E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"1.1557273497909217\");\n    /// ```\n    #[inline]\n    pub fn div_round_assign_ref(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_assign_ref(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=f(\\pm0.0,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_rational_prec`] instead.\n    /// If you know that your target precision is the precision of the [`Float`] input, consider\n    /// using [`Float::div_rational_round`] instead. If both of these things are true, consider\n    /// using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Floor);\n    /// assert_eq!(quotient.to_string(), \"9.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Nearest);\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Floor);\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"9.42479\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Nearest);\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_round(\n        mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.div_rational_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by value and the [`Rational`] by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=f(\\pm0.0,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_rational_prec_val_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::div_rational_round_val_ref`] instead. If both of these things are\n    /// true, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42479\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_round_val_ref(\n        mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.div_rational_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by reference and the [`Rational`]\n    /// by value. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=f(\\pm0.0,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_rational_prec_ref_val`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::div_rational_round_ref_val`] instead. If both of these things are\n    /// true, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42479\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_round_ref_val(\n        &self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < DIV_RATIONAL_THRESHOLD\n        {\n            div_rational_prec_round_naive_ref_val(self, other, prec, rm)\n        } else {\n            div_rational_prec_round_direct_ref_val(self, other, prec, rm)\n        }\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=f(\\pm0.0,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_rational_prec_ref_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::div_rational_round_ref_ref`] instead. If both of these things are\n    /// true, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42479\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"9.42477\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_round_ref_ref(\n        &self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < DIV_RATIONAL_THRESHOLD\n        {\n            div_rational_prec_round_naive_ref_ref(self, other, prec, rm)\n        } else {\n            div_rational_prec_round_direct_ref_ref(self, other, prec, rm)\n        }\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=f(\\pm0.0,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x>0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_round`] instead. If you know that your target precision is the\n    /// precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec(Rational::exact_from(1.5), 5);\n    /// assert_eq!(quotient.to_string(), \"2.1\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec(Rational::exact_from(1.5), 20);\n    /// assert_eq!(quotient.to_string(), \"2.094395\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec(self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.div_rational_prec_round(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by value and the [`Rational`] by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=f(\\pm0.0,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x>0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_round_val_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_val_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(quotient.to_string(), \"2.1\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_val_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(quotient.to_string(), \"2.094395\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_val_ref(self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.div_rational_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by reference and the [`Rational`] by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=f(\\pm0.0,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x>0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_round_ref_val`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::from(PI).div_rational_prec_ref_val(Rational::exact_from(1.5), 5);\n    /// assert_eq!(quotient.to_string(), \"2.1\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_ref_val(Rational::exact_from(1.5), 20);\n    /// assert_eq!(quotient.to_string(), \"2.094395\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_ref_val(&self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.div_rational_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=f(\\pm0.0,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x>0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_round_ref_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_ref_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(quotient.to_string(), \"2.1\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_prec_ref_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(quotient.to_string(), \"2.094395\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_ref_ref(&self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.div_rational_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] and the [`Rational`] are both are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=f(\\pm0.0,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::div_rational_prec_round`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076939\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_round(self, other: Rational, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] is taken by value and the [`Rational`] by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=f(\\pm0.0,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::div_rational_prec_round_val_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076939\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_round_val_ref(\n        self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] is taken by reference and the [`Rational`] by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=f(\\pm0.0,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::div_rational_prec_round_ref_val`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076939\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_round_ref_val(\n        &self,\n        other: Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`], rounding the result with the specified rounding mode.\n    /// The [`Float`] and the [`Rational`] are both are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=f(\\pm0.0,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x>0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x>0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::div_rational_prec_round_ref_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076939\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::from(PI).div_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(quotient.to_string(), \"9.42477796076938\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn div_rational_round_ref_ref(\n        &self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Rational`] is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the rounded quotient is less than, equal to, or\n    /// greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::div_rational_prec_assign`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::div_rational_round_assign`] instead. If both of these things are\n    /// true, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42479\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477\");\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_round_assign(\n        &mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < DIV_RATIONAL_THRESHOLD\n        {\n            div_rational_prec_round_assign_naive(self, other, prec, rm)\n        } else {\n            div_rational_prec_round_assign_direct(self, other, prec, rm)\n        }\n    }\n\n    /// Divides a [`Float`] by a [`Rational`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Rational`] is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded quotient is less than, equal to, or\n    /// greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::div_rational_prec_assign_ref`] instead. If you know that your target precision is\n    /// the precision of the [`Float`] input, consider using\n    /// [`Float::div_rational_round_assign_ref`] instead. If both of these things are true, consider\n    /// using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42479\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477\");\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < DIV_RATIONAL_THRESHOLD\n        {\n            div_rational_prec_round_assign_naive_ref(self, other, prec, rm)\n        } else {\n            div_rational_prec_round_assign_direct_ref(self, other, prec, rm)\n        }\n    }\n\n    /// Divides a [`Float`] by a [`Rational`] in place, rounding the result to the nearest value of\n    /// the specified precision. The [`Rational`] is taken by value. An [`Ordering`] is returned,\n    /// indicating whether the rounded quotient is less than, equal to, or greater than the exact\n    /// quotient. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_rational_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_round_assign`] instead. If you know that your target precision is\n    /// the maximum of the precisions of the two inputs, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_assign(Rational::exact_from(1.5), 5),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.1\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_assign(Rational::exact_from(1.5), 20),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.094395\");\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_assign(&mut self, other: Rational, prec: u64) -> Ordering {\n        self.div_rational_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`] in place, rounding the result to the nearest value of\n    /// the specified precision. The [`Rational`] is taken by reference. An [`Ordering`] is\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::div_rational_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_round_assign`] instead. If you know that your target precision is\n    /// the maximum of the precisions of the two inputs, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_assign_ref(&Rational::exact_from(1.5), 5),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.1\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_prec_assign_ref(&Rational::exact_from(1.5), 20),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.094395\");\n    /// ```\n    #[inline]\n    pub fn div_rational_prec_assign_ref(&mut self, other: &Rational, prec: u64) -> Ordering {\n        self.div_rational_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`] in place, rounding the result with the specified\n    /// rounding mode. The [`Rational`] is taken by value. An [`Ordering`] is returned, indicating\n    /// whether the rounded quotient is less than, equal to, or greater than the exact quotient.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::div_rational_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::div_rational_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_round_assign(Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477796076938\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_round_assign(Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477796076939\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_round_assign(Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477796076938\");\n    /// ```\n    #[inline]\n    pub fn div_rational_round_assign(&mut self, other: Rational, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_assign(other, prec, rm)\n    }\n\n    /// Divides a [`Float`] by a [`Rational`] in place, rounding the result with the specified\n    /// rounding mode. The [`Rational`] is taken by reference. An [`Ordering`] is returned,\n    /// indicating whether the rounded quotient is less than, equal to, or greater than the exact\n    /// quotient. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::div_rational_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::div_rational_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `/=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477796076938\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477796076939\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.div_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"9.42477796076938\");\n    /// ```\n    #[inline]\n    pub fn div_rational_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> Ordering {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_assign_ref(other, prec, rm)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Rational`] and the [`Float`] are both taken by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::rational_div_float_prec`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::rational_div_float_round`] instead. If both of these things are\n    /// true, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_round(Rational::from(3), Float::from(PI), 5, Floor);\n    /// assert_eq!(quotient.to_string(), \"0.94\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_round(Rational::from(3), Float::from(PI), 5, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_round(Rational::from(3), Float::from(PI), 5, Nearest);\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_round(Rational::from(3), Float::from(PI), 20, Floor);\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_round(Rational::from(3), Float::from(PI), 20, Ceiling);\n    /// assert_eq!(quotient.to_string(), \"0.95493\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_round(Rational::from(3), Float::from(PI), 20, Nearest);\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec_round(\n        x: Rational,\n        y: Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !y.is_normal() || max(x.significant_bits(), y.complexity()) < RATIONAL_DIV_THRESHOLD {\n            rational_div_float_prec_round_naive(x, y, prec, rm)\n        } else {\n            rational_div_float_prec_round_direct(x, y, prec, rm)\n        }\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Rational`] is taken by value and the [`Float`] by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::rational_div_float_prec_val_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using\n    /// [`Float::rational_div_float_round_val_ref`] instead. If both of these things are true,\n    /// consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_val_ref(\n    ///     Rational::from(3),\n    ///     &Float::from(PI),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.94\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_val_ref(\n    ///     Rational::from(3),\n    ///     &Float::from(PI),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_val_ref(\n    ///     Rational::from(3),\n    ///     &Float::from(PI),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_val_ref(\n    ///     Rational::from(3),\n    ///     &Float::from(PI),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_val_ref(\n    ///     Rational::from(3),\n    ///     &Float::from(PI),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.95493\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_val_ref(\n    ///     Rational::from(3),\n    ///     &Float::from(PI),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec_round_val_ref(\n        x: Rational,\n        y: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !y.is_normal() || max(x.significant_bits(), y.complexity()) < RATIONAL_DIV_THRESHOLD {\n            rational_div_float_prec_round_naive_val_ref(x, y, prec, rm)\n        } else {\n            rational_div_float_prec_round_direct_val_ref(x, y, prec, rm)\n        }\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Rational`] is taken by reference and the [`Float`]\n    /// by value. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::rational_div_float_prec_ref_val`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using\n    /// [`Float::rational_div_float_round_ref_val`] instead. If both of these things are true,\n    /// consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_val(\n    ///     &Rational::from(3),\n    ///     Float::from(PI),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.94\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_val(\n    ///     &Rational::from(3),\n    ///     Float::from(PI),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_val(\n    ///     &Rational::from(3),\n    ///     Float::from(PI),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_val(\n    ///     &Rational::from(3),\n    ///     Float::from(PI),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_val(\n    ///     &Rational::from(3),\n    ///     Float::from(PI),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.95493\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_val(\n    ///     &Rational::from(3),\n    ///     Float::from(PI),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec_round_ref_val(\n        x: &Rational,\n        y: Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !y.is_normal() || max(x.significant_bits(), y.complexity()) < RATIONAL_DIV_THRESHOLD {\n            rational_div_float_prec_round_naive_ref_val(x, y, prec, rm)\n        } else {\n            rational_div_float_prec_round_direct_ref_val(x, y, prec, rm)\n        }\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Rational`] and the [`Float`] are both taken by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded quotient is less\n    /// than, equal to, or greater than the exact quotient. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$.\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::rational_div_float_prec_ref_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using\n    /// [`Float::rational_div_float_round_ref_ref`] instead. If both of these things are true,\n    /// consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact division.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_ref(\n    ///     &Rational::from(3),\n    ///     &Float::from(PI),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.94\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_ref(\n    ///     &Rational::from(3),\n    ///     &Float::from(PI),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_ref(\n    ///     &Rational::from(3),\n    ///     &Float::from(PI),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_ref(\n    ///     &Rational::from(3),\n    ///     &Float::from(PI),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_ref(\n    ///     &Rational::from(3),\n    ///     &Float::from(PI),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.95493\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec_round_ref_ref(\n    ///     &Rational::from(3),\n    ///     &Float::from(PI),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec_round_ref_ref(\n        x: &Rational,\n        y: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !y.is_normal() || max(x.significant_bits(), y.complexity()) < RATIONAL_DIV_THRESHOLD {\n            rational_div_float_prec_round_naive_ref_ref(x, y, prec, rm)\n        } else {\n            rational_div_float_prec_round_direct_ref_ref(x, y, prec, rm)\n        }\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Rational`] and the [`Float`] are both are taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p)=f(0,\\pm0.0,p)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p)=0.0$ if $x>0$\n    /// - $f(0,x,p)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::rational_div_float_prec_round`] instead. If you know that your target precision is\n    /// the precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec(Rational::from(3), Float::from(PI), 5);\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) = Float::rational_div_float_prec(Rational::from(3), Float::from(PI), 20);\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec(x: Rational, y: Self, prec: u64) -> (Self, Ordering) {\n        Self::rational_div_float_prec_round(x, y, prec, Nearest)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Rational`] is taken by value and the [`Float`] by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p)=f(0,\\pm0.0,p)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p)=0.0$ if $x>0$\n    /// - $f(0,x,p)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::rational_div_float_prec_round_val_ref`] instead. If you know that your target\n    /// precision is the precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_val_ref(Rational::from(3), &Float::from(PI), 5);\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_val_ref(Rational::from(3), &Float::from(PI), 20);\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec_val_ref(x: Rational, y: &Self, prec: u64) -> (Self, Ordering) {\n        Self::rational_div_float_prec_round_val_ref(x, y, prec, Nearest)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Rational`] is taken by reference and the [`Float`] by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p)=f(0,\\pm0.0,p)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p)=0.0$ if $x>0$\n    /// - $f(0,x,p)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::rational_div_float_prec_round_ref_val`] instead. If you know that your target\n    /// precision is the precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_ref_val(&Rational::from(3), Float::from(PI), 5);\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_ref_val(&Rational::from(3), Float::from(PI), 20);\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec_ref_val(x: &Rational, y: Self, prec: u64) -> (Self, Ordering) {\n        Self::rational_div_float_prec_round_ref_val(x, y, prec, Nearest)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Rational`] and the [`Float`] are both are taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded quotient is less than, equal\n    /// to, or greater than the exact quotient. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the quotient is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p)=f(0,\\pm0.0,p)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p)=0.0$ if $x>0$\n    /// - $f(0,x,p)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::rational_div_float_prec_round_ref_ref`] instead. If you know that your target\n    /// precision is the precision of the [`Float`] input, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_ref_ref(&Rational::from(3), &Float::from(PI), 5);\n    /// assert_eq!(quotient.to_string(), \"0.97\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_prec_ref_ref(&Rational::from(3), &Float::from(PI), 20);\n    /// assert_eq!(quotient.to_string(), \"0.954929\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_prec_ref_ref(x: &Rational, y: &Self, prec: u64) -> (Self, Ordering) {\n        Self::rational_div_float_prec_round_ref_ref(x, y, prec, Nearest)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result with the specified rounding mode.\n    /// The [`Rational`] and the [`Float`] are both are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},m)=f(0,\\pm0.0,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,m)=0.0$ if $x>0$\n    /// - $f(0,x,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::rational_div_float_prec_round`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round(Rational::from(3), Float::from(PI), Floor);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513716\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round(Rational::from(3), Float::from(PI), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round(Rational::from(3), Float::from(PI), Nearest);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_round(x: Rational, y: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = y.significant_bits();\n        Self::rational_div_float_prec_round(x, y, prec, rm)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result with the specified rounding mode.\n    /// The [`Rational`] is taken by value and the [`Float`] by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},m)=f(0,\\pm0.0,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,m)=0.0$ if $x>0$\n    /// - $f(0,x,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::rational_div_float_prec_round_val_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_val_ref(Rational::from(3), &Float::from(PI), Floor);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513716\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_val_ref(Rational::from(3), &Float::from(PI), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_val_ref(Rational::from(3), &Float::from(PI), Nearest);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_round_val_ref(\n        x: Rational,\n        y: &Self,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = y.significant_bits();\n        Self::rational_div_float_prec_round_val_ref(x, y, prec, rm)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result with the specified rounding mode.\n    /// The [`Rational`] is taken by reference and the [`Float`] by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},m)=f(0,\\pm0.0,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,m)=0.0$ if $x>0$\n    /// - $f(0,x,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::rational_div_float_prec_round_ref_val`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_ref_val(&Rational::from(3), Float::from(PI), Floor);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513716\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_ref_val(&Rational::from(3), Float::from(PI), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_ref_val(&Rational::from(3), Float::from(PI), Nearest);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_round_ref_val(\n        x: &Rational,\n        y: Self,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = y.significant_bits();\n        Self::rational_div_float_prec_round_ref_val(x, y, prec, rm)\n    }\n\n    /// Divides a [`Rational`] by a [`Float`], rounding the result with the specified rounding mode.\n    /// The [`Rational`] and the [`Float`] are both are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded quotient is less than, equal to, or greater than\n    /// the exact quotient. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x/y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},m)=f(0,\\pm0.0,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,m)=0.0$ if $x>0$\n    /// - $f(0,x,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::rational_div_float_prec_round_ref_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `/` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_ref_ref(&Rational::from(3), &Float::from(PI), Floor);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513716\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_ref_ref(&Rational::from(3), &Float::from(PI), Ceiling);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (quotient, o) =\n    ///     Float::rational_div_float_round_ref_ref(&Rational::from(3), &Float::from(PI), Nearest);\n    /// assert_eq!(quotient.to_string(), \"0.9549296585513725\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn rational_div_float_round_ref_ref(\n        x: &Rational,\n        y: &Self,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = y.significant_bits();\n        Self::rational_div_float_prec_round_ref_ref(x, y, prec, rm)\n    }\n}\n\nimpl Div<Self> for Float {\n    type Output = Self;\n\n    /// Divides two [`Float`]s, taking both by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// quotient is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm\\infty)=f(\\pm0.0,\\pm0.0) = \\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::div_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::div_round`].\n    /// If you want both of these things, consider using [`Float::div_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) / Float::NAN).is_nan());\n    /// assert_eq!(Float::from(1.5) / Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::from(1.5) / Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(Float::from(-1.5) / Float::ZERO, Float::NEGATIVE_INFINITY);\n    /// assert_eq!(Float::from(-1.5) / Float::NEGATIVE_ZERO, Float::INFINITY);\n    /// assert!((Float::ZERO / Float::ZERO).is_nan());\n    ///\n    /// assert_eq!((Float::from(1.5) / Float::from(2.5)).to_string(), \"0.6\");\n    /// assert_eq!((Float::from(1.5) / Float::from(-2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((Float::from(-1.5) / Float::from(2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((Float::from(-1.5) / Float::from(-2.5)).to_string(), \"0.6\");\n    /// ```\n    #[inline]\n    fn div(self, other: Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Div<&Self> for Float {\n    type Output = Self;\n\n    /// Divides two [`Float`]s, taking the first by value and the second by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// quotient is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm\\infty)=f(\\pm0.0,\\pm0.0) = \\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_val_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::div_round_val_ref`]. If you want both of these things, consider using\n    /// [`Float::div_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) / &Float::NAN).is_nan());\n    /// assert_eq!(Float::from(1.5) / &Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::from(1.5) / &Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(Float::from(-1.5) / &Float::ZERO, Float::NEGATIVE_INFINITY);\n    /// assert_eq!(Float::from(-1.5) / &Float::NEGATIVE_ZERO, Float::INFINITY);\n    /// assert!((Float::ZERO / &Float::ZERO).is_nan());\n    ///\n    /// assert_eq!((Float::from(1.5) / &Float::from(2.5)).to_string(), \"0.6\");\n    /// assert_eq!((Float::from(1.5) / &Float::from(-2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((Float::from(-1.5) / &Float::from(2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((Float::from(-1.5) / &Float::from(-2.5)).to_string(), \"0.6\");\n    /// ```\n    #[inline]\n    fn div(self, other: &Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Div<Float> for &Float {\n    type Output = Float;\n\n    /// Divides two [`Float`]s, taking the first by reference and the second by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// quotient is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm\\infty)=f(\\pm0.0,\\pm0.0) = \\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_ref_val`] instead. If you want to specify the output precision, consider\n    /// using [`Float::div_round_ref_val`]. If you want both of these things, consider using\n    /// [`Float::div_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) / Float::NAN).is_nan());\n    /// assert_eq!(&Float::from(1.5) / Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Float::from(1.5) / Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(&Float::from(-1.5) / Float::ZERO, Float::NEGATIVE_INFINITY);\n    /// assert_eq!(&Float::from(-1.5) / Float::NEGATIVE_ZERO, Float::INFINITY);\n    /// assert!((&Float::ZERO / Float::ZERO).is_nan());\n    ///\n    /// assert_eq!((&Float::from(1.5) / Float::from(2.5)).to_string(), \"0.6\");\n    /// assert_eq!((&Float::from(1.5) / Float::from(-2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((&Float::from(-1.5) / Float::from(2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((&Float::from(-1.5) / Float::from(-2.5)).to_string(), \"0.6\");\n    /// ```\n    #[inline]\n    fn div(self, other: Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Div<&Float> for &Float {\n    type Output = Float;\n\n    /// Divides two [`Float`]s, taking both by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// quotient is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm\\infty)=f(\\pm0.0,\\pm0.0) = \\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $0.0<x<\\infty$\n    /// - $f(\\infty,x)=-\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,0.0)=\\infty$ if $x>0.0$\n    /// - $f(x,0.0)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=-\\infty$ if $0.0<x<\\infty$\n    /// - $f(-\\infty,x)=\\infty$ if $-\\infty<x<0.0$\n    /// - $f(x,-0.0)=-\\infty$ if $x>0.0$\n    /// - $f(x,-0.0)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(0.0,x)=-0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=-0.0$ if $x$ is not NaN and $x>0.0$\n    /// - $f(-0.0,x)=0.0$ if $x$ is not NaN and $x<0.0$\n    /// - $f(x,-\\infty)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(x,-\\infty)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_ref_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::div_round_ref_ref`]. If you want both of these things, consider using\n    /// [`Float::div_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) / &Float::NAN).is_nan());\n    /// assert_eq!(&Float::from(1.5) / &Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Float::from(1.5) / &Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(&Float::from(-1.5) / &Float::ZERO, Float::NEGATIVE_INFINITY);\n    /// assert_eq!(&Float::from(-1.5) / &Float::NEGATIVE_ZERO, Float::INFINITY);\n    /// assert!((&Float::ZERO / &Float::ZERO).is_nan());\n    ///\n    /// assert_eq!((&Float::from(1.5) / &Float::from(2.5)).to_string(), \"0.6\");\n    /// assert_eq!((&Float::from(1.5) / &Float::from(-2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((&Float::from(-1.5) / &Float::from(2.5)).to_string(), \"-0.6\");\n    /// assert_eq!((&Float::from(-1.5) / &Float::from(-2.5)).to_string(), \"0.6\");\n    /// ```\n    #[inline]\n    fn div(self, other: &Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl DivAssign<Self> for Float {\n    /// Divides a [`Float`] by a [`Float`] in place, taking the [`Float`] on the right-hand side by\n    /// value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// quotient is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `/` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::div_round_assign`]. If you want both of these things, consider using\n    /// [`Float::div_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= Float::ZERO;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= Float::NEGATIVE_ZERO;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= Float::ZERO;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= Float::NEGATIVE_ZERO;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x /= Float::INFINITY;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= Float::from(2.5);\n    /// assert_eq!(x.to_string(), \"0.6\");\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= Float::from(-2.5);\n    /// assert_eq!(x.to_string(), \"-0.6\");\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= Float::from(2.5);\n    /// assert_eq!(x.to_string(), \"-0.6\");\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= Float::from(-2.5);\n    /// assert_eq!(x.to_string(), \"0.6\");\n    /// ```\n    #[inline]\n    fn div_assign(&mut self, other: Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl DivAssign<&Self> for Float {\n    /// Divides a [`Float`] by a [`Float`] in place, taking the [`Float`] on the right-hand side by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// quotient is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `/` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::div_round_assign`]. If you want both of these things, consider using\n    /// [`Float::div_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= &Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= &Float::ZERO;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= &Float::NEGATIVE_ZERO;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= &Float::ZERO;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= &Float::NEGATIVE_ZERO;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x /= &Float::INFINITY;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= &Float::from(2.5);\n    /// assert_eq!(x.to_string(), \"0.6\");\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x /= &Float::from(-2.5);\n    /// assert_eq!(x.to_string(), \"-0.6\");\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= &Float::from(2.5);\n    /// assert_eq!(x.to_string(), \"-0.6\");\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x /= &Float::from(-2.5);\n    /// assert_eq!(x.to_string(), \"0.6\");\n    /// ```\n    #[inline]\n    fn div_assign(&mut self, other: &Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.div_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Div<Rational> for Float {\n    type Output = Self;\n\n    /// Divides a [`Float`] by a [`Rational`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=f(\\pm0.0,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x>0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x>0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec`] instead. If you want to specify the output precision, consider\n    /// using [`Float::div_rational_round`]. If you want both of these things, consider using\n    /// [`Float::div_rational_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN / Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(Float::INFINITY / Rational::exact_from(1.5), Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY / Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::INFINITY / Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY / Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (Float::from(2.5) / Rational::exact_from(1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (Float::from(2.5) / Rational::exact_from(-1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (Float::from(-2.5) / Rational::exact_from(1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (Float::from(-2.5) / Rational::exact_from(-1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: Rational) -> Self {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Div<&Rational> for Float {\n    type Output = Self;\n\n    /// Divides a [`Float`] by a [`Rational`], taking the first by value and the second by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=f(\\pm0.0,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x>0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x>0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_val_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::div_rational_round_val_ref`]. If you want both of these things,\n    /// consider using [`Float::div_rational_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN / &Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     Float::INFINITY / &Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY / &Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::INFINITY / &Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY / &Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (Float::from(2.5) / &Rational::exact_from(1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (Float::from(2.5) / &Rational::exact_from(-1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (Float::from(-2.5) / &Rational::exact_from(1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (Float::from(-2.5) / &Rational::exact_from(-1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: &Rational) -> Self {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Div<Rational> for &Float {\n    type Output = Float;\n\n    /// Divides a [`Float`] by a [`Rational`], taking the first by reference and the second by\n    /// value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=f(\\pm0.0,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x>0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x>0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_ref_val`] instead. If you want to specify the output precision,\n    /// consider using [`Float::div_rational_round_ref_val`]. If you want both of these things,\n    /// consider using [`Float::div_rational_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN / Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY / Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY / Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::INFINITY / Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY / Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Float::from(2.5) / Rational::exact_from(1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from(2.5) / Rational::exact_from(-1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from(-2.5) / Rational::exact_from(1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from(-2.5) / Rational::exact_from(-1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: Rational) -> Float {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Div<&Rational> for &Float {\n    type Output = Float;\n\n    /// Divides a [`Float`] by a [`Rational`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=f(\\pm0.0,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x\\geq 0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x\\geq 0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x>0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x>0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_ref_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::div_rational_round_ref_ref`]. If you want both of these things,\n    /// consider using [`Float::div_rational_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN / &Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY / &Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY / &Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::INFINITY / &Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY / &Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Float::from(2.5) / &Rational::exact_from(1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from(2.5) / &Rational::exact_from(-1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from(-2.5) / &Rational::exact_from(1.5)).to_string(),\n    ///     \"-1.8\"\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from(-2.5) / &Rational::exact_from(-1.5)).to_string(),\n    ///     \"1.8\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: &Rational) -> Float {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl DivAssign<Rational> for Float {\n    /// Divides a [`Float`] by a [`Rational`] in place, taking the [`Rational`] by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `/` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_assign`] instead. If you want to specify the output precision,\n    /// consider using [`Float::div_rational_round_assign`]. If you want both of these things,\n    /// consider using [`Float::div_rational_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x /= Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x /= Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x /= Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x /= Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x /= Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x /= Rational::exact_from(1.5);\n    /// assert_eq!(x.to_string(), \"1.8\");\n    /// ```\n    #[inline]\n    fn div_assign(&mut self, other: Rational) {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl DivAssign<&Rational> for Float {\n    /// Divides a [`Float`] by a [`Rational`] in place, taking the [`Rational`] by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `/` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::div_rational_prec_assign_ref`] instead. If you want to specify the output\n    /// precision, consider using [`Float::div_rational_round_assign_ref`]. If you want both of\n    /// these things, consider using [`Float::div_rational_prec_round_assign_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x /= &Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x /= &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x /= &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x /= &Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x /= &Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x /= &Rational::exact_from(1.5);\n    /// assert_eq!(x.to_string(), \"1.8\");\n    /// ```\n    #[inline]\n    fn div_assign(&mut self, other: &Rational) {\n        let prec = self.significant_bits();\n        self.div_rational_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Div<Float> for Rational {\n    type Output = Float;\n\n    /// Divides a [`Rational`] by a [`Float`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) / Float::NAN).is_nan());\n    /// assert_eq!(Rational::exact_from(1.5) / Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) / Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) / Float::ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) / Float::NEGATIVE_ZERO,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (Rational::exact_from(1.5) / Float::from(2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (Rational::exact_from(-1.5) / Float::from(2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (Rational::exact_from(1.5) / Float::from(-2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (Rational::exact_from(-1.5) / Float::from(-2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        Float::rational_div_float_prec_round(self, other, prec, Nearest).0\n    }\n}\n\nimpl Div<&Float> for Rational {\n    type Output = Float;\n\n    /// Divides a [`Rational`] by a [`Float`], taking the [`Rational`] by value and the [`Float`] by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) / &Float::NAN).is_nan());\n    /// assert_eq!(Rational::exact_from(1.5) / &Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) / &Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) / &Float::ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) / &Float::NEGATIVE_ZERO,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (Rational::exact_from(1.5) / &Float::from(2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (Rational::exact_from(-1.5) / &Float::from(2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (Rational::exact_from(1.5) / &Float::from(-2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (Rational::exact_from(-1.5) / &Float::from(-2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        Float::rational_div_float_prec_round_val_ref(self, other, prec, Nearest).0\n    }\n}\n\nimpl Div<Float> for &Rational {\n    type Output = Float;\n\n    /// Divides a [`Rational`] by a [`Float`], taking the [`Rational`] by reference and the\n    /// [`Float`] by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) / Float::NAN).is_nan());\n    /// assert_eq!(&Rational::exact_from(1.5) / Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) / Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) / Float::ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) / Float::NEGATIVE_ZERO,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Rational::exact_from(1.5) / Float::from(2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::exact_from(-1.5) / Float::from(2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::exact_from(1.5) / Float::from(-2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::exact_from(-1.5) / Float::from(-2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        Float::rational_div_float_prec_round_ref_val(self, other, prec, Nearest).0\n    }\n}\n\nimpl Div<&Float> for &Rational {\n    type Output = Float;\n\n    /// Divides a [`Rational`] by a [`Float`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the quotient\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x/y+\\varepsilon.\n    /// $$\n    /// - If $x/y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x/y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x/y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN},p,m)=f(0,\\pm0.0,p,m)=\\text{NaN}$\n    /// - $f(x,\\infty,x,p,m)=0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,\\infty,x,p,m)=-0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(x,-\\infty,x,p,m)=-0.0$ if $x>0.0$ or $x=0.0$\n    /// - $f(x,-\\infty,x,p,m)=0.0$ if $x<0.0$ or $x=-0.0$\n    /// - $f(0,x,p,m)=0.0$ if $x>0$\n    /// - $f(0,x,p,m)=-0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeZero, Zero,\n    /// };\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) / &Float::NAN).is_nan());\n    /// assert_eq!(&Rational::exact_from(1.5) / &Float::ZERO, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) / &Float::NEGATIVE_ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) / &Float::ZERO,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) / &Float::NEGATIVE_ZERO,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Rational::exact_from(1.5) / &Float::from(2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::exact_from(-1.5) / &Float::from(2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::exact_from(1.5) / &Float::from(-2.5)).to_string(),\n    ///     \"-0.6\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::exact_from(-1.5) / &Float::from(-2.5)).to_string(),\n    ///     \"0.6\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        Float::rational_div_float_prec_round_ref_ref(self, other, prec, Nearest).0\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_nz::natural::LIMB_HIGH_BIT;\n\nimpl IsPowerOf2 for Float {\n    /// Determines whether a [`Float`] is an integer power of 2.\n    ///\n    /// $f(x) = (\\exists n \\in \\Z : 2^n = x)$.\n    ///\n    /// [`Float`]s that are NaN, infinite, or zero are not powers of 2.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::IsPowerOf2;\n    /// use malachite_base::num::basic::traits::{NaN, One, OneHalf, Two};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_power_of_2(), false);\n    ///\n    /// assert_eq!(Float::ONE.is_power_of_2(), true);\n    /// assert_eq!(Float::TWO.is_power_of_2(), true);\n    /// assert_eq!(Float::ONE_HALF.is_power_of_2(), true);\n    /// assert_eq!(Float::from(1024).is_power_of_2(), true);\n    ///\n    /// assert_eq!(Float::from(3).is_power_of_2(), false);\n    /// assert_eq!(Float::from(1025).is_power_of_2(), false);\n    /// assert_eq!(Float::from(0.1f64).is_power_of_2(), false);\n    /// ```\n    fn is_power_of_2(&self) -> bool {\n        match self {\n            Self(Finite {\n                sign: true,\n                significand,\n                ..\n            }) => {\n                let mut first = true;\n                for x in significand.limbs().rev() {\n                    if first {\n                        if x != LIMB_HIGH_BIT {\n                            return false;\n                        }\n                        first = false;\n                    } else if x != 0 {\n                        return false;\n                    }\n                }\n                true\n            }\n            _ => false,\n        }\n    }\n}\n\npub(crate) fn abs_is_power_of_2(x: &Float) -> bool {\n    match x {\n        Float(Finite { significand, .. }) => {\n            let mut first = true;\n            for x in significand.limbs().rev() {\n                if first {\n                    if x != LIMB_HIGH_BIT {\n                        return false;\n                    }\n                    first = false;\n                } else if x != 0 {\n                    return false;\n                }\n            }\n            true\n        }\n        _ => false,\n    }\n}\n\npub(crate) fn float_is_signed_min<T: PrimitiveSigned>(f: &Float) -> bool {\n    match f {\n        Float(Finite {\n            sign: false,\n            exponent,\n            significand,\n            ..\n        }) => {\n            if *exponent != T::WIDTH as i32 {\n                return false;\n            }\n            let mut first = true;\n            for x in significand.limbs().rev() {\n                if first {\n                    if x != LIMB_HIGH_BIT {\n                        return false;\n                    }\n                    first = false;\n                } else if x != 0 {\n                    return false;\n                }\n            }\n            true\n        }\n        _ => false,\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/ln.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999-2026 Free Software Foundation, Inc.\n//\n//      Contributed by the Pascaline and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::basic::extended::ExtendedFloat;\nuse crate::{\n    Float, emulate_float_to_float_fn, emulate_rational_to_float_fn, float_either_zero,\n    float_infinity, float_nan, float_negative_infinity, float_zero,\n};\nuse core::cmp::Ordering::{self, *};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    Agm, CeilingLogBase2, IsPowerOf2, Ln, LnAssign, Sign,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero as ZeroTrait};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\n// The computation of log(x) is done using the formula: if we want p bits of the result,\n// ```\n//                    pi\n//      log(x) ~ ------------- - m log 2\n//               2 AG(1,4 / s)\n// ```\n// where s = x 2^m > 2^(p/2).\n//\n// More precisely, if F(x) = int(1 / ln(1 - (1 - x ^ 2) * sin(t) ^ 2), t = 0..pi / 2), then for s >=\n// 1.26 we have log(s) < F(4 / s) < log(s) * (1 + 4 / s ^ 2) from which we deduce pi / 2 / AG(1, 4 /\n// s) * (1 - 4 / s ^ 2) < log(s) < pi / 2 / AG(1, 4 / s) so the relative error 4 / s ^ 2 is < 4 / 2\n// ^ p i.e. 4 ulps.\n//\n// This is mpfr_log from log.c, MPFR 4.2.0.\nfn ln_prec_round_normal_ref(x: &Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    if *x == 1u32 {\n        return (Float::ZERO, Equal);\n    }\n    assert_ne!(rm, Exact, \"Inexact ln\");\n    let x_exp = i64::from(x.get_exponent().unwrap());\n    // use initial precision about q + 2 * lg(q) + cte\n    let mut working_prec = prec + (prec.ceiling_log_base_2() << 1) + 10;\n    let mut increment = Limb::WIDTH;\n    let mut previous_m = 0;\n    let mut x = x.clone();\n    loop {\n        // Calculus of m (depends on p)\n        let m = i64::exact_from((working_prec + 3) >> 1)\n            .checked_sub(x_exp)\n            .unwrap();\n        x <<= m - previous_m;\n        previous_m = m;\n        assert!(x.is_normal());\n        let tmp2 = Float::pi_prec(working_prec).0\n            / (Float::ONE.agm(\n                const { Float::const_from_unsigned(4) }\n                    .div_prec_round_val_ref(&x, working_prec, Floor)\n                    .0,\n            ) << 1u32);\n        let exp2 = tmp2.get_exponent();\n        let tmp1 = tmp2\n            - Float::ln_2_prec(working_prec)\n                .0\n                .mul_prec(Float::from(m), working_prec)\n                .0;\n        if let (Some(exp1), Some(exp2)) = (tmp1.get_exponent(), exp2) {\n            let cancel = u64::saturating_from(exp2 - exp1);\n            // we have 7 ulps of error from the above roundings, 4 ulps from the 4 / s ^ 2 second\n            // order term, plus the canceled bits\n            if float_can_round(\n                tmp1.significand_ref().unwrap(),\n                working_prec.saturating_sub(cancel).saturating_sub(4),\n                prec,\n                rm,\n            ) {\n                return Float::from_float_prec_round(tmp1, prec, rm);\n            }\n            working_prec += cancel + working_prec.ceiling_log_base_2();\n        } else {\n            working_prec += working_prec.ceiling_log_base_2();\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\n// This is mpfr_log from log.c, MPFR 4.2.0.\nfn ln_prec_round_normal(mut x: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    if x == 1u32 {\n        return (Float::ZERO, Equal);\n    }\n    assert_ne!(rm, Exact, \"Inexact ln\");\n    let x_exp = i64::from(x.get_exponent().unwrap());\n    // use initial precision about q + 2 * lg(q) + cte\n    let mut working_prec = prec + (prec.ceiling_log_base_2() << 1) + 10;\n    let mut increment = Limb::WIDTH;\n    let mut previous_m = 0;\n    loop {\n        // Calculus of m (depends on p)\n        let m = i64::exact_from((working_prec + 3) >> 1)\n            .checked_sub(x_exp)\n            .unwrap();\n        x <<= m - previous_m;\n        previous_m = m;\n        assert!(x.is_normal());\n        let tmp2 = Float::pi_prec(working_prec).0\n            / (Float::ONE.agm(\n                const { Float::const_from_unsigned(4) }\n                    .div_prec_round_val_ref(&x, working_prec, Floor)\n                    .0,\n            ) << 1u32);\n        let exp2 = tmp2.get_exponent();\n        let tmp1 = tmp2\n            - Float::ln_2_prec(working_prec)\n                .0\n                .mul_prec(Float::from(m), working_prec)\n                .0;\n        if let (Some(exp1), Some(exp2)) = (tmp1.get_exponent(), exp2) {\n            let cancel = u64::saturating_from(exp2 - exp1);\n            // we have 7 ulps of error from the above roundings, 4 ulps from the 4 / s ^ 2 second\n            // order term, plus the canceled bits\n            if float_can_round(\n                tmp1.significand_ref().unwrap(),\n                working_prec.saturating_sub(cancel).saturating_sub(4),\n                prec,\n                rm,\n            ) {\n                return Float::from_float_prec_round(tmp1, prec, rm);\n            }\n            working_prec += cancel + working_prec.ceiling_log_base_2();\n        } else {\n            working_prec += working_prec.ceiling_log_base_2();\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\npub(crate) fn ln_prec_round_normal_extended(\n    x: ExtendedFloat,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if x.exp == 1 && x.x.is_power_of_2() {\n        return (Float::ZERO, Equal);\n    }\n    assert_ne!(rm, Exact, \"Inexact ln\");\n    let x_exp = x.exp;\n    // use initial precision about q + 2 * lg(q) + cte\n    let mut working_prec = prec + (prec.ceiling_log_base_2() << 1) + 10;\n    let mut increment = Limb::WIDTH;\n    let mut m = i64::exact_from((working_prec + 3) >> 1)\n        .checked_sub(x.exp)\n        .unwrap();\n    let mut previous_m = m;\n    let mut x = Float::exact_from(x << m);\n    let mut first = true;\n    loop {\n        if first {\n            first = false;\n        } else {\n            // Calculus of m (depends on p)\n            m = i64::exact_from((working_prec + 3) >> 1)\n                .checked_sub(x_exp)\n                .unwrap();\n            x <<= m - previous_m;\n            previous_m = m;\n        }\n        assert!(x.is_normal());\n        let tmp2 = Float::pi_prec(working_prec).0\n            / (Float::ONE.agm(\n                const { Float::const_from_unsigned(4) }\n                    .div_prec_round_val_ref(&x, working_prec, Floor)\n                    .0,\n            ) << 1u32);\n        let exp2 = tmp2.get_exponent();\n        let tmp1 = tmp2\n            - Float::ln_2_prec(working_prec)\n                .0\n                .mul_prec(Float::from(m), working_prec)\n                .0;\n        if let (Some(exp1), Some(exp2)) = (tmp1.get_exponent(), exp2) {\n            let cancel = u64::saturating_from(exp2 - exp1);\n            // we have 7 ulps of error from the above roundings, 4 ulps from the 4 / s ^ 2 second\n            // order term, plus the canceled bits\n            if float_can_round(\n                tmp1.significand_ref().unwrap(),\n                working_prec.saturating_sub(cancel).saturating_sub(4),\n                prec,\n                rm,\n            ) {\n                return Float::from_float_prec_round(tmp1, prec, rm);\n            }\n            working_prec += cancel + working_prec.ceiling_log_base_2();\n        } else {\n            working_prec += working_prec.ceiling_log_base_2();\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\nfn ln_rational_helper(x: &Rational, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let (x_lo, x_o) = Float::from_rational_prec_round_ref(x, working_prec, Floor);\n        if x_o == Equal {\n            return ln_prec_round_normal(x_lo, prec, rm);\n        }\n        let mut x_hi = x_lo.clone();\n        x_hi.increment();\n        let (ln_lo, mut o_lo) = ln_prec_round_normal(x_lo, prec, rm);\n        let (ln_hi, mut o_hi) = ln_prec_round_normal(x_hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && ln_lo == ln_hi {\n            return (ln_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\nfn ln_rational_helper_extended(x: &Rational, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let (x_lo, x_o) = ExtendedFloat::from_rational_prec_round_ref(x, working_prec, Floor);\n        if x_o == Equal {\n            return ln_prec_round_normal_extended(x_lo, prec, rm);\n        }\n        let mut x_hi = x_lo.clone();\n        x_hi.increment();\n        let (ln_lo, mut o_lo) = ln_prec_round_normal_extended(x_lo, prec, rm);\n        let (ln_hi, mut o_hi) = ln_prec_round_normal_extended(x_hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && ln_lo == ln_hi {\n            return (ln_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\nimpl Float {\n    /// Computes the natural logarithm of a [`Float`], rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Float`] is taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded logarithm is less than, equal\n    /// to, or greater than the exact logarithm. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p+1}$.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=\\infty$\n    /// - $f(-\\infty,p,m)=\\text{NaN}$\n    /// - $f(\\pm0.0,p,m)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::ln_prec`] instead. If you\n    /// know that your target precision is the precision of the input, consider using\n    /// [`Float::ln_round`] instead. If both of these things are true, consider using [`Float::ln`]\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round(5, Floor);\n    /// assert_eq!(ln.to_string(), \"2.2\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round(5, Ceiling);\n    /// assert_eq!(ln.to_string(), \"2.4\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round(5, Nearest);\n    /// assert_eq!(ln.to_string(), \"2.2\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round(20, Floor);\n    /// assert_eq!(ln.to_string(), \"2.302582\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round(20, Ceiling);\n    /// assert_eq!(ln.to_string(), \"2.302586\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round(20, Nearest);\n    /// assert_eq!(ln.to_string(), \"2.302586\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn ln_prec_round(self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match self {\n            Self(NaN | Infinity { sign: false } | Finite { sign: false, .. }) => {\n                (float_nan!(), Equal)\n            }\n            float_either_zero!() => (float_negative_infinity!(), Equal),\n            float_infinity!() => (float_infinity!(), Equal),\n            _ => ln_prec_round_normal(self, prec, rm),\n        }\n    }\n\n    /// Computes the natural logarithm of a [`Float`], rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Float`] is taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded logarithm is less than, equal\n    /// to, or greater than the exact logarithm. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p+1}$.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=\\infty$\n    /// - $f(-\\infty,p,m)=\\text{NaN}$\n    /// - $f(\\pm0.0,p,m)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::ln_prec_ref`] instead. If you\n    /// know that your target precision is the precision of the input, consider using\n    /// [`Float::ln_round_ref`] instead. If both of these things are true, consider using\n    /// `(&Float).ln()`instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round_ref(5, Floor);\n    /// assert_eq!(ln.to_string(), \"2.2\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round_ref(5, Ceiling);\n    /// assert_eq!(ln.to_string(), \"2.4\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round_ref(5, Nearest);\n    /// assert_eq!(ln.to_string(), \"2.2\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round_ref(20, Floor);\n    /// assert_eq!(ln.to_string(), \"2.302582\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round_ref(20, Ceiling);\n    /// assert_eq!(ln.to_string(), \"2.302586\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_prec_round_ref(20, Nearest);\n    /// assert_eq!(ln.to_string(), \"2.302586\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn ln_prec_round_ref(&self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match self {\n            Self(NaN | Infinity { sign: false } | Finite { sign: false, .. }) => {\n                (float_nan!(), Equal)\n            }\n            float_either_zero!() => (float_negative_infinity!(), Equal),\n            float_infinity!() => (float_infinity!(), Equal),\n            _ => ln_prec_round_normal_ref(self, prec, rm),\n        }\n    }\n\n    /// Computes the natural logarithm of a [`Float`], rounding the result to the nearest value of\n    /// the specified precision. The [`Float`] is taken by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded logarithm is less than, equal to, or greater than the exact\n    /// logarithm. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// If the logarithm is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\ln{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=\\infty$\n    /// - $f(-\\infty,p,m)=\\text{NaN}$\n    /// - $f(\\pm0.0,p,m)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::ln_prec_round`] instead. If you know that your target precision is the precision of\n    /// the input, consider using [`Float::ln`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_prec(5);\n    /// assert_eq!(ln.to_string(), \"2.2\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_prec(20);\n    /// assert_eq!(ln.to_string(), \"2.302586\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn ln_prec(self, prec: u64) -> (Self, Ordering) {\n        self.ln_prec_round(prec, Nearest)\n    }\n\n    /// Computes the natural logarithm of a [`Float`], rounding the result to the nearest value of\n    /// the specified precision. The [`Float`] is taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded logarithm is less than, equal to, or greater than\n    /// the exact logarithm. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// If the logarithm is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\ln{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\infty,p)=\\infty$\n    /// - $f(-\\infty,p)=\\text{NaN}$\n    /// - $f(\\pm0.0,p)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::ln_prec_round_ref`] instead. If you know that your target precision is the\n    /// precision of the input, consider using `(&Float).ln()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_prec_ref(5);\n    /// assert_eq!(ln.to_string(), \"2.2\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_prec_ref(20);\n    /// assert_eq!(ln.to_string(), \"2.302586\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn ln_prec_ref(&self, prec: u64) -> (Self, Ordering) {\n        self.ln_prec_round_ref(prec, Nearest)\n    }\n\n    /// Computes the natural logarithm of a [`Float`], rounding the result with the specified\n    /// rounding mode. The [`Float`] is taken by value. An [`Ordering`] is also returned, indicating\n    /// whether the rounded logarithm is less than, equal to, or greater than the exact logarithm.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=\\infty$\n    /// - $f(-\\infty,m)=\\text{NaN}$\n    /// - $f(\\pm0.0,m)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::ln_prec_round`] instead.\n    /// If you know you'll be using the `Nearest` rounding mode, consider using [`Float::ln`]\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_round(Floor);\n    /// assert_eq!(ln.to_string(), \"2.302585092994045684017991454684\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_round(Ceiling);\n    /// assert_eq!(ln.to_string(), \"2.302585092994045684017991454687\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_round(Nearest);\n    /// assert_eq!(ln.to_string(), \"2.302585092994045684017991454684\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn ln_round(self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.ln_prec_round(prec, rm)\n    }\n\n    /// Computes the natural logarithm of a [`Float`], rounding the result with the specified\n    /// rounding mode. The [`Float`] is taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded logarithm is less than, equal to, or greater than the exact\n    /// logarithm. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=\\infty$\n    /// - $f(-\\infty,m)=\\text{NaN}$\n    /// - $f(\\pm0.0,m)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::ln_prec_round_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// `(&Float).ln()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100).0.ln_round_ref(Floor);\n    /// assert_eq!(ln.to_string(), \"2.302585092994045684017991454684\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_round_ref(Ceiling);\n    /// assert_eq!(ln.to_string(), \"2.302585092994045684017991454687\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::from_unsigned_prec(10u32, 100)\n    ///     .0\n    ///     .ln_round_ref(Nearest);\n    /// assert_eq!(ln.to_string(), \"2.302585092994045684017991454684\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn ln_round_ref(&self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.ln_prec_round_ref(prec, rm)\n    }\n\n    /// Computes the natural logarithm of a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. An [`Ordering`] is returned, indicating\n    /// whether the rounded logarithm is less than, equal to, or greater than the exact logarithm.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::ln_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::ln_prec_assign`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::ln_round_assign`] instead. If both of these things are true, consider using\n    /// [`Float::ln_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_round_assign(5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"2.2\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_round_assign(5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"2.4\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_round_assign(5, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"2.2\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_round_assign(20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"2.302582\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_round_assign(20, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"2.302586\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_round_assign(20, Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"2.302586\");\n    /// ```\n    #[inline]\n    pub fn ln_prec_round_assign(&mut self, prec: u64, rm: RoundingMode) -> Ordering {\n        let mut x = Self::ZERO;\n        swap(self, &mut x);\n        let o;\n        (*self, o) = x.ln_prec_round(prec, rm);\n        o\n    }\n\n    /// Computes the natural logarithm of a [`Float`] in place, rounding the result to the nearest\n    /// value of the specified precision. An [`Ordering`] is returned, indicating whether the\n    /// rounded logarithm is less than, equal to, or greater than the exact logarithm. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function sets the [`Float`] to\n    /// `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// If the logarithm is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\ln{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::ln_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::ln_prec_round_assign`] instead. If you know that your target precision is the\n    /// precision of the input, consider using [`Float::ln`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_assign(5), Less);\n    /// assert_eq!(x.to_string(), \"2.2\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_prec_assign(20), Greater);\n    /// assert_eq!(x.to_string(), \"2.302586\");\n    /// ```\n    #[inline]\n    pub fn ln_prec_assign(&mut self, prec: u64) -> Ordering {\n        self.ln_prec_round_assign(prec, Nearest)\n    }\n\n    /// Computes the natural logarithm of a [`Float`] in place, rounding the result with the\n    /// specified rounding mode. An [`Ordering`] is returned, indicating whether the rounded\n    /// logarithm is less than, equal to, or greater than the exact logarithm. Although `NaN`s are\n    /// not comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\|ln{x}|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// See the [`Float::ln_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::ln_prec_round_assign`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::ln_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_round_assign(Floor), Less);\n    /// assert_eq!(x.to_string(), \"2.302585092994045684017991454684\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_round_assign(Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"2.302585092994045684017991454687\");\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// assert_eq!(x.ln_round_assign(Nearest), Less);\n    /// assert_eq!(x.to_string(), \"2.302585092994045684017991454684\");\n    /// ```\n    #[inline]\n    pub fn ln_round_assign(&mut self, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.ln_prec_round_assign(prec, rm)\n    }\n\n    /// Computes the natural logarithm of a [`Rational`], rounding the result to the specified\n    /// precision and with the specified rounding mode and returning the result as a [`Float`]. The\n    /// [`Rational`] is taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded logarithm is less than, equal to, or greater than the exact logarithm. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |\\ln{x}|\\rfloor-p+1}$.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |\\ln{x}|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p,m)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::ln_rational_prec`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_round(Rational::from_unsigneds(3u8, 5), 5, Floor);\n    /// assert_eq!(ln.to_string(), \"-0.53\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_round(Rational::from_unsigneds(3u8, 5), 5, Ceiling);\n    /// assert_eq!(ln.to_string(), \"-0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_round(Rational::from_unsigneds(3u8, 5), 5, Nearest);\n    /// assert_eq!(ln.to_string(), \"-0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_round(Rational::from_unsigneds(3u8, 5), 20, Floor);\n    /// assert_eq!(ln.to_string(), \"-0.510826\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_round(Rational::from_unsigneds(3u8, 5), 20, Ceiling);\n    /// assert_eq!(ln.to_string(), \"-0.510825\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_round(Rational::from_unsigneds(3u8, 5), 20, Nearest);\n    /// assert_eq!(ln.to_string(), \"-0.510825\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[allow(clippy::needless_pass_by_value)]\n    #[inline]\n    pub fn ln_rational_prec_round(x: Rational, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        Self::ln_rational_prec_round_ref(&x, prec, rm)\n    }\n\n    /// Computes the natural logarithm of a [`Rational`], rounding the result to the specified\n    /// precision and with the specified rounding mode and returning the result as a [`Float`]. The\n    /// [`Rational`] is taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// rounded logarithm is less than, equal to, or greater than the exact logarithm. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |\\ln{x}|\\rfloor-p+1}$.\n    /// - If $\\ln{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |\\ln{x}|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p,m)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::ln_rational_prec_ref`]\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) =\n    ///     Float::ln_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 5, Floor);\n    /// assert_eq!(ln.to_string(), \"-0.53\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) =\n    ///     Float::ln_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 5, Ceiling);\n    /// assert_eq!(ln.to_string(), \"-0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) =\n    ///     Float::ln_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 5, Nearest);\n    /// assert_eq!(ln.to_string(), \"-0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) =\n    ///     Float::ln_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 20, Floor);\n    /// assert_eq!(ln.to_string(), \"-0.510826\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (ln, o) =\n    ///     Float::ln_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 20, Ceiling);\n    /// assert_eq!(ln.to_string(), \"-0.510825\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) =\n    ///     Float::ln_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 20, Nearest);\n    /// assert_eq!(ln.to_string(), \"-0.510825\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn ln_rational_prec_round_ref(\n        x: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match x.sign() {\n            Equal => return (float_negative_infinity!(), Equal),\n            Less => return (float_nan!(), Equal),\n            Greater => {}\n        }\n        if *x == 1u32 {\n            return (float_zero!(), Equal);\n        }\n        assert_ne!(rm, Exact, \"Inexact ln\");\n        let x_exp = i32::saturating_from(x.floor_log_base_2_abs()).saturating_add(1);\n        if x_exp >= Self::MAX_EXPONENT - 1 || x_exp <= Self::MIN_EXPONENT + 1 {\n            ln_rational_helper_extended(x, prec, rm)\n        } else {\n            ln_rational_helper(x, prec, rm)\n        }\n    }\n\n    /// Computes the natural logarithm of a [`Rational`], rounding the result to the nearest value\n    /// of the specified precision and returning the result as a [`Float`]. The [`Rational`] is\n    /// taken by value. An [`Ordering`] is also returned, indicating whether the rounded logarithm\n    /// is less than, equal to, or greater than the exact logarithm. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// If the logarithm is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   |\\ln{x}|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::ln_rational_prec_round`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::ln_rational_prec(Rational::from_unsigneds(3u8, 5), 5);\n    /// assert_eq!(ln.to_string(), \"-0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::ln_rational_prec(Rational::from_unsigneds(3u8, 5), 20);\n    /// assert_eq!(ln.to_string(), \"-0.510825\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn ln_rational_prec(x: Rational, prec: u64) -> (Self, Ordering) {\n        Self::ln_rational_prec_round(x, prec, Nearest)\n    }\n\n    /// Computes the natural logarithm of a [`Rational`], rounding the result to the nearest value\n    /// of the specified precision and returning the result as a [`Float`]. The [`Rational`] is\n    /// taken by reference. An [`Ordering`] is also returned, indicating whether the rounded\n    /// logarithm is less than, equal to, or greater than the exact logarithm. Although `NaN`s are\n    /// not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// If the logarithm is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   |\\ln{x}|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::ln_rational_prec_round_ref`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_ref(&Rational::from_unsigneds(3u8, 5), 5);\n    /// assert_eq!(ln.to_string(), \"-0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (ln, o) = Float::ln_rational_prec_ref(&Rational::from_unsigneds(3u8, 5), 20);\n    /// assert_eq!(ln.to_string(), \"-0.510825\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn ln_rational_prec_ref(x: &Rational, prec: u64) -> (Self, Ordering) {\n        Self::ln_rational_prec_round_ref(x, prec, Nearest)\n    }\n}\n\nimpl Ln for Float {\n    type Output = Self;\n\n    /// Computes the natural logarithm of a [`Float`], taking it by value.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the logarithm is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// $$\n    /// f(x) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\ln{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=\\infty$\n    /// - $f(-\\infty)=\\text{NaN}$\n    /// - $f(\\pm0.0)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::ln_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::ln_round`]. If\n    /// you want both of these things, consider using [`Float::ln_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Ln;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!(Float::NAN.ln().is_nan());\n    /// assert_eq!(Float::INFINITY.ln(), Float::INFINITY);\n    /// assert!(Float::NEGATIVE_INFINITY.ln().is_nan());\n    /// assert_eq!(\n    ///     Float::from_unsigned_prec(10u32, 100).0.ln().to_string(),\n    ///     \"2.302585092994045684017991454684\"\n    /// );\n    /// assert!(Float::from_signed_prec(-10, 100).0.ln().is_nan());\n    /// ```\n    #[inline]\n    fn ln(self) -> Self {\n        let prec = self.significant_bits();\n        self.ln_prec_round(prec, Nearest).0\n    }\n}\n\nimpl Ln for &Float {\n    type Output = Float;\n\n    /// Computes the natural logarithm of a [`Float`], taking it by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the logarithm is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// $$\n    /// f(x) = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\ln{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=\\infty$\n    /// - $f(-\\infty)=\\text{NaN}$\n    /// - $f(\\pm0.0)=-\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::ln_prec_ref`] instead. If you want to specify the output precision, consider using\n    /// [`Float::ln_round_ref`]. If you want both of these things, consider using\n    /// [`Float::ln_prec_round_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Ln;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::NAN).ln().is_nan());\n    /// assert_eq!((&Float::INFINITY).ln(), Float::INFINITY);\n    /// assert!((&Float::NEGATIVE_INFINITY).ln().is_nan());\n    /// assert_eq!(\n    ///     (&Float::from_unsigned_prec(10u32, 100).0).ln().to_string(),\n    ///     \"2.302585092994045684017991454684\"\n    /// );\n    /// assert!((&Float::from_signed_prec(-10, 100).0).ln().is_nan());\n    /// ```\n    #[inline]\n    fn ln(self) -> Float {\n        let prec = self.significant_bits();\n        self.ln_prec_round_ref(prec, Nearest).0\n    }\n}\n\nimpl LnAssign for Float {\n    /// Computes the natural logarithm of a [`Float`] in place.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the logarithm is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// The logarithm of any nonzero negative number is `NaN`.\n    ///\n    /// $$\n    /// x\\gets = \\ln{x}+\\varepsilon.\n    /// $$\n    /// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\ln{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the [`Float::ln`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::ln_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::ln_round_assign`]. If you want both of these things, consider using\n    /// [`Float::ln_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LnAssign;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::NAN;\n    /// x.ln_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.ln_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.ln_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from_unsigned_prec(10u32, 100).0;\n    /// x.ln_assign();\n    /// assert_eq!(x.to_string(), \"2.302585092994045684017991454684\");\n    ///\n    /// let mut x = Float::from_signed_prec(-10, 100).0;\n    /// x.ln_assign();\n    /// assert!(x.is_nan());\n    /// ```\n    #[inline]\n    fn ln_assign(&mut self) {\n        let prec = self.significant_bits();\n        self.ln_prec_round_assign(prec, Nearest);\n    }\n}\n\n/// Computes the natural logarithm of a primitive float. Using this function is more accurate than\n/// using the default `log` function or the one provided by `libm`.\n///\n/// The reciprocal logarithm of any nonzero negative number is `NaN`.\n///\n/// $$\n/// f(x) = \\ln x+\\varepsilon.\n/// $$\n/// - If $\\ln x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n/// - If $\\ln x$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 \\ln x\\rfloor-p}$,\n///   where $p$ is precision of the output (typically 24 if `T` is a [`f32`] and 53 if `T` is a\n///   [`f64`], but less if the output is subnormal).\n///\n/// Special cases:\n/// - $f(\\text{NaN})=\\text{NaN}$\n/// - $f(\\infty)=\\infty$\n/// - $f(-\\infty)=\\text{NaN}$\n/// - $f(\\pm0.0)=-\\infty$\n///\n/// Neither overflow nor underflow is possible.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::arithmetic::ln::primitive_float_ln;\n///\n/// assert!(primitive_float_ln(f32::NAN).is_nan());\n/// assert_eq!(\n///     NiceFloat(primitive_float_ln(f32::INFINITY)),\n///     NiceFloat(f32::INFINITY)\n/// );\n/// assert!(primitive_float_ln(f32::NEGATIVE_INFINITY).is_nan());\n/// assert_eq!(NiceFloat(primitive_float_ln(10.0f32)), NiceFloat(2.3025851));\n/// assert!(primitive_float_ln(-10.0f32).is_nan());\n/// ```\n#[inline]\n#[allow(clippy::type_repetition_in_bounds)]\npub fn primitive_float_ln<T: PrimitiveFloat>(x: T) -> T\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    emulate_float_to_float_fn(Float::ln_prec, x)\n}\n\n/// Computes the natural logarithm of a [`Rational`], returning a primitive float result.\n///\n/// If the logarithm is equidistant from two primitive floats, the primitive float with fewer 1s in\n/// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest` rounding\n/// mode.\n///\n/// The logarithm of any negative number is `NaN`.\n///\n/// $$\n/// f(x) = \\ln{x}+\\varepsilon.\n/// $$\n/// - If $\\ln{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n/// - If $\\ln{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |\\ln{x}|\\rfloor-p}$,\n///   where $p$ is precision of the output (typically 24 if `T` is a [`f32`] and 53 if `T` is a\n///   [`f64`], but less if the output is subnormal).\n///\n/// Special cases:\n/// - $f(0)=-\\infty$\n///\n/// Neither overflow nor underflow is possible.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::{NegativeInfinity, Zero};\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::arithmetic::ln::primitive_float_ln_rational;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     NiceFloat(primitive_float_ln_rational::<f64>(&Rational::ZERO)),\n///     NiceFloat(f64::NEGATIVE_INFINITY)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_ln_rational::<f64>(\n///         &Rational::from_unsigneds(1u8, 3)\n///     )),\n///     NiceFloat(-1.0986122886681098)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_ln_rational::<f64>(&Rational::from(10000))),\n///     NiceFloat(9.210340371976184)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_ln_rational::<f64>(&Rational::from(-10000))),\n///     NiceFloat(f64::NAN)\n/// );\n/// ```\n#[inline]\n#[allow(clippy::type_repetition_in_bounds)]\npub fn primitive_float_ln_rational<T: PrimitiveFloat>(x: &Rational) -> T\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    emulate_rational_to_float_fn(Float::ln_rational_prec_ref, x)\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Absolute value of [`Float`](super::Float)s.\npub mod abs;\n/// Addition of [`Float`](super::Float)s, and of [`Float`](super::Float)s with\n/// [`Rational`](malachite_q::Rational)s.\npub mod add;\n/// Taking the AGM (arithmetic-geometric mean) of two [`Float`](super::Float)s, and of\n/// [`Float`](super::Float)s with [`Rational`](malachite_q::Rational)s.\npub mod agm;\n/// Division of [`Float`](super::Float)s, of [`Float`](super::Float)s by\n/// [`Rational`](malachite_q::Rational)s, and of [`Rational`](malachite_q::Rational)s by\n/// [`Float`](super::Float)s.\npub mod div;\n/// An implementation of [`IsPowerOf2`](malachite_base::num::arithmetic::traits::IsPowerOf2), a\n/// trait for determining whether a number is an integer power of 2.\npub mod is_power_of_2;\n/// [`Ln`](malachite_base::num::arithmetic::traits::Ln) and\n/// [`SqrtAssign`](malachite_base::num::arithmetic::traits::LnAssign), traits for computing the\n/// natural logarithm of [`Float`](super::Float)s.\npub mod ln;\n/// Multiplication of [`Float`](super::Float)s, and of [`Float`](super::Float)s with\n/// [`Rational`](malachite_q::Rational)s.\npub mod mul;\n/// Negation of [`Float`](super::Float)s.\npub mod neg;\n/// Implementations of [`PowerOf2`](malachite_base::num::arithmetic::traits::PowerOf2), a trait for\n/// computing a power of 2.\npub mod power_of_2;\n/// Implementations of [`Reciprocal`](malachite_base::num::arithmetic::traits::Reciprocal) and\n/// [`ReciprocalAssign`](malachite_base::num::arithmetic::traits::ReciprocalAssign), traits for\n/// computing the reciprocal of a number.\npub mod reciprocal;\n/// [`ReciprocalSqrt`](malachite_base::num::arithmetic::traits::ReciprocalSqrt) and\n/// [`ReciprocalSqrtAssign`](malachite_base::num::arithmetic::traits::ReciprocalSqrtAssign), traits\n/// for computing the reciprocal of the square root of [`Float`](super::Float)s.\npub mod reciprocal_sqrt;\n/// Left-shifting a [`Float`](super::Float) (multiplying it by a power of 2).\n///\n/// # shl\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, Zero};\n/// use malachite_float::Float;\n///\n/// assert_eq!(Float::ZERO << 10, 0);\n/// assert_eq!(Float::INFINITY << 10, Float::INFINITY);\n/// assert_eq!(\n///     (Float::from(std::f64::consts::PI) << 10u8).to_string(),\n///     \"3216.990877275948\"\n/// );\n/// assert_eq!(\n///     (Float::from(std::f64::consts::PI) << -10i8).to_string(),\n///     \"0.003067961575771282\"\n/// );\n///\n/// assert_eq!(&Float::ZERO << 10, 0);\n/// assert_eq!(&Float::INFINITY << 10, Float::INFINITY);\n/// assert_eq!(\n///     (&Float::from(std::f64::consts::PI) << 10u8).to_string(),\n///     \"3216.990877275948\"\n/// );\n/// assert_eq!(\n///     (&Float::from(std::f64::consts::PI) << -10i8).to_string(),\n///     \"0.003067961575771282\"\n/// );\n/// ```\n///\n/// # shl_assign\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, Zero};\n/// use malachite_float::Float;\n///\n/// let mut x = Float::ZERO;\n/// x <<= 10;\n/// assert_eq!(x, 0);\n///\n/// let mut x = Float::INFINITY;\n/// x <<= 10;\n/// assert_eq!(x, Float::INFINITY);\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// x <<= 10;\n/// assert_eq!(x.to_string(), \"3216.990877275948\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// x <<= -10;\n/// assert_eq!(x.to_string(), \"0.003067961575771282\");\n/// ```\npub mod shl;\n/// Implementations of [`ShlRound`](malachite_base::num::arithmetic::traits::ShlRound) and\n/// [`ShlRoundAssign`](malachite_base::num::arithmetic::traits::ShlRoundAssign), traits for\n/// multiplying a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode). For [`Float`](super::Float)s,\n/// rounding is only necessary in the cases of overflow and underflow.\n///\n/// # shl_prec_round\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(10u8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(-10i8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(u32::MAX, 10, Floor);\n/// assert_eq!(shifted.to_string(), \"too_big\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(u32::MAX, 10, Ceiling);\n/// assert_eq!(shifted.to_string(), \"Infinity\");\n/// assert_eq!(o, Greater);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(10u8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(-10i8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(u32::MAX, 10, Floor);\n/// assert_eq!(shifted.to_string(), \"too_big\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(u32::MAX, 10, Ceiling);\n/// assert_eq!(shifted.to_string(), \"Infinity\");\n/// assert_eq!(o, Greater);\n/// ```\n///\n/// # shl_prec_round_assign\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_prec_round_assign(10u8, 10, Nearest), Less);\n/// assert_eq!(x.to_string(), \"3216.0\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_prec_round_assign(-10i8, 10, Nearest), Less);\n/// assert_eq!(x.to_string(), \"0.003067\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_prec_round_assign(u32::MAX, 10, Floor), Less);\n/// assert_eq!(x.to_string(), \"too_big\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_prec_round_assign(u32::MAX, 10, Ceiling), Greater);\n/// assert_eq!(x.to_string(), \"Infinity\");\n/// ```\n///\n/// # shl_prec\n/// ```\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec(10u8, 10);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec(-10i8, 10);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec(u32::MAX, 10);\n/// assert_eq!(shifted.to_string(), \"Infinity\");\n/// assert_eq!(o, Greater);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_ref(10u8, 10);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_ref(-10i8, 10);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_ref(u32::MAX, 10);\n/// assert_eq!(shifted.to_string(), \"Infinity\");\n/// assert_eq!(o, Greater);\n/// ```\n///\n/// # shl_prec_assign\n/// ```\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_prec_assign(10u8, 10), Less);\n/// assert_eq!(x.to_string(), \"3216.0\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_prec_assign(-10i8, 10), Less);\n/// assert_eq!(x.to_string(), \"0.003067\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_prec_assign(u32::MAX, 10), Greater);\n/// assert_eq!(x.to_string(), \"Infinity\");\n/// ```\n///\n/// # shl_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShlRound;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(10u8, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.990877275948\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(-10i8, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067961575771282\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(u32::MAX, Floor);\n/// assert_eq!(shifted.to_string(), \"too_big\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(u32::MAX, Ceiling);\n/// assert_eq!(shifted.to_string(), \"Infinity\");\n/// assert_eq!(o, Greater);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(10u8, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.990877275948\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(-10i8, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067961575771282\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(u32::MAX, Floor);\n/// assert_eq!(shifted.to_string(), \"too_big\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(u32::MAX, Ceiling);\n/// assert_eq!(shifted.to_string(), \"Infinity\");\n/// assert_eq!(o, Greater);\n/// ```\n///\n/// # shl_round_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShlRoundAssign;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_round_assign(10u8, Nearest), Equal);\n/// assert_eq!(x.to_string(), \"3216.990877275948\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_round_assign(-10i8, Nearest), Equal);\n/// assert_eq!(x.to_string(), \"0.003067961575771282\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_round_assign(u32::MAX, Floor), Less);\n/// assert_eq!(x.to_string(), \"too_big\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shl_round_assign(u32::MAX, Ceiling), Greater);\n/// assert_eq!(x.to_string(), \"Infinity\");\n/// ```\npub mod shl_round;\n/// Right-shifting a [`Float`](super::Float) (dividing it by a power of 2).\n///\n/// # shr\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, Zero};\n/// use malachite_float::Float;\n///\n/// assert_eq!(Float::ZERO >> 10, 0);\n/// assert_eq!(Float::INFINITY >> 10, Float::INFINITY);\n/// assert_eq!(\n///     (Float::from(std::f64::consts::PI) >> 10u8).to_string(),\n///     \"0.003067961575771282\"\n/// );\n/// assert_eq!(\n///     (Float::from(std::f64::consts::PI) >> -10i8).to_string(),\n///     \"3216.990877275948\"\n/// );\n///\n/// assert_eq!(&Float::ZERO >> 10, 0);\n/// assert_eq!(&Float::INFINITY >> 10, Float::INFINITY);\n/// assert_eq!(\n///     (&Float::from(std::f64::consts::PI) >> 10u8).to_string(),\n///     \"0.003067961575771282\"\n/// );\n/// assert_eq!(\n///     (&Float::from(std::f64::consts::PI) >> -10i8).to_string(),\n///     \"3216.990877275948\"\n/// );\n/// ```\n///\n/// # shr_assign\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, Zero};\n/// use malachite_float::Float;\n///\n/// let mut x = Float::ZERO;\n/// x >>= 10;\n/// assert_eq!(x, 0);\n///\n/// let mut x = Float::INFINITY;\n/// x >>= 10;\n/// assert_eq!(x, Float::INFINITY);\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// x >>= 10;\n/// assert_eq!(x.to_string(), \"0.003067961575771282\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// x >>= -10;\n/// assert_eq!(x.to_string(), \"3216.990877275948\");\n/// ```\npub mod shr;\n/// Implementations of [`ShlRound`](malachite_base::num::arithmetic::traits::ShrRound) and\n/// [`ShrRoundAssign`](malachite_base::num::arithmetic::traits::ShrRoundAssign), traits for dividing\n/// a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode). For [`Float`](super::Float)s,\n/// rounding is only necessary in the cases of overflow and underflow.\n///\n/// # shr_prec_round\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(10u8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(-10i8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(u32::MAX, 10, Floor);\n/// assert_eq!(shifted.to_string(), \"0.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(u32::MAX, 10, Ceiling);\n/// assert_eq!(shifted.to_string(), \"too_small\");\n/// assert_eq!(o, Greater);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(10u8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(-10i8, 10, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(u32::MAX, 10, Floor);\n/// assert_eq!(shifted.to_string(), \"0.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(u32::MAX, 10, Ceiling);\n/// assert_eq!(shifted.to_string(), \"too_small\");\n/// assert_eq!(o, Greater);\n/// ```\n///\n/// # shr_prec_round_assign\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_prec_round_assign(10u8, 10, Nearest), Less);\n/// assert_eq!(x.to_string(), \"0.003067\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_prec_round_assign(-10i8, 10, Nearest), Less);\n/// assert_eq!(x.to_string(), \"3216.0\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_prec_round_assign(u32::MAX, 10, Floor), Less);\n/// assert_eq!(x.to_string(), \"0.0\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_prec_round_assign(u32::MAX, 10, Ceiling), Greater);\n/// assert_eq!(x.to_string(), \"too_small\");\n/// ```\n///\n/// # shr_prec\n/// ```\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec(10u8, 10);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec(-10i8, 10);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec(u32::MAX, 10);\n/// assert_eq!(shifted.to_string(), \"0.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_ref(10u8, 10);\n/// assert_eq!(shifted.to_string(), \"0.003067\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_ref(-10i8, 10);\n/// assert_eq!(shifted.to_string(), \"3216.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_ref(u32::MAX, 10);\n/// assert_eq!(shifted.to_string(), \"0.0\");\n/// assert_eq!(o, Less);\n/// ```\n///\n/// # shr_prec_assign\n/// ```\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_prec_assign(10u8, 10), Less);\n/// assert_eq!(x.to_string(), \"0.003067\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_prec_assign(-10i8, 10), Less);\n/// assert_eq!(x.to_string(), \"3216.0\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_prec_assign(u32::MAX, 10), Less);\n/// assert_eq!(x.to_string(), \"0.0\");\n/// ```\n///\n/// # shr_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShrRound;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(10u8, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067961575771282\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(-10i8, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.990877275948\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(u32::MAX, Floor);\n/// assert_eq!(shifted.to_string(), \"0.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(u32::MAX, Ceiling);\n/// assert_eq!(shifted.to_string(), \"too_small\");\n/// assert_eq!(o, Greater);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(10u8, Nearest);\n/// assert_eq!(shifted.to_string(), \"0.003067961575771282\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(-10i8, Nearest);\n/// assert_eq!(shifted.to_string(), \"3216.990877275948\");\n/// assert_eq!(o, Equal);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(u32::MAX, Floor);\n/// assert_eq!(shifted.to_string(), \"0.0\");\n/// assert_eq!(o, Less);\n///\n/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(u32::MAX, Ceiling);\n/// assert_eq!(shifted.to_string(), \"too_small\");\n/// assert_eq!(o, Greater);\n/// ```\n///\n/// # shr_round_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShrRoundAssign;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_round_assign(10u8, Nearest), Equal);\n/// assert_eq!(x.to_string(), \"0.003067961575771282\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_round_assign(-10i8, Nearest), Equal);\n/// assert_eq!(x.to_string(), \"3216.990877275948\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_round_assign(u32::MAX, Floor), Less);\n/// assert_eq!(x.to_string(), \"0.0\");\n///\n/// let mut x = Float::from(std::f64::consts::PI);\n/// assert_eq!(x.shr_round_assign(u32::MAX, Ceiling), Greater);\n/// assert_eq!(x.to_string(), \"too_small\");\n/// ```\npub mod shr_round;\n/// An implementation of [`Sign`](malachite_base::num::arithmetic::traits::Sign), a trait for\n/// determining the sign of a number.\npub mod sign;\n/// [`Sqrt`](malachite_base::num::arithmetic::traits::Sqrt) and\n/// [`SqrtAssign`](malachite_base::num::arithmetic::traits::SqrtAssign), traits for computing the\n/// square root of [`Float`](super::Float)s.\npub mod sqrt;\n/// Squaring of [`Float`](super::Float)s.\npub mod square;\n/// Subtraction of [`Float`](super::Float)s, of [`Float`](super::Float)s by\n/// [`Rational`](malachite_q::Rational)s, and of [`Rational`](malachite_q::Rational)s by\n/// [`Float`](super::Float)s.\npub mod sub;\n"
  },
  {
    "path": "malachite-float/src/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::conversion::from_natural::{from_natural_zero_exponent, from_natural_zero_exponent_ref};\nuse crate::{\n    Float, float_either_infinity, float_either_zero, float_infinity, float_nan,\n    float_negative_infinity, float_negative_zero, float_zero,\n};\nuse core::cmp::{\n    Ordering::{self, *},\n    max,\n};\nuse core::mem::swap;\nuse core::ops::{Mul, MulAssign};\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, FloorLogBase2, IsPowerOf2, NegAssign, Sign,\n};\nuse malachite_base::num::basic::traits::{NegativeZero, Zero as ZeroTrait};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{NotAssign, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_mul::{\n    mul_float_significands_in_place, mul_float_significands_in_place_ref,\n    mul_float_significands_ref_ref,\n};\nuse malachite_q::Rational;\n\nconst MUL_RATIONAL_THRESHOLD: u64 = 50;\n\nfn mul_rational_prec_round_assign_naive(\n    x: &mut Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    match (&mut *x, y) {\n        (float_nan!(), _) => Equal,\n        (Float(Infinity { sign }), y) => {\n            match y.sign() {\n                Equal => *x = float_nan!(),\n                Greater => {}\n                Less => {\n                    sign.not_assign();\n                }\n            };\n            Equal\n        }\n        (Float(Zero { sign }), y) => {\n            if y < 0 {\n                sign.not_assign();\n            };\n            Equal\n        }\n        (x, y) => {\n            let not_sign = *x < 0;\n            let mut z = Float::ZERO;\n            swap(x, &mut z);\n            let (mut product, o) =\n                Float::from_rational_prec_round(Rational::exact_from(z) * y, prec, rm);\n            if product == 0u32 && not_sign {\n                product.neg_assign();\n            }\n            *x = product;\n            o\n        }\n    }\n}\n\nfn mul_rational_prec_round_assign_naive_ref(\n    x: &mut Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    match (&mut *x, y) {\n        (float_nan!(), _) => Equal,\n        (Float(Infinity { sign }), y) => {\n            match y.sign() {\n                Equal => *x = float_nan!(),\n                Greater => {}\n                Less => {\n                    sign.not_assign();\n                }\n            };\n            Equal\n        }\n        (Float(Zero { sign }), y) => {\n            if *y < 0 {\n                sign.not_assign();\n            };\n            Equal\n        }\n        (x, y) => {\n            let not_sign = *x < 0;\n            let mut z = Float::ZERO;\n            swap(x, &mut z);\n            let (mut product, o) =\n                Float::from_rational_prec_round(Rational::exact_from(z) * y, prec, rm);\n            if product == 0u32 && not_sign {\n                product.neg_assign();\n            }\n            *x = product;\n            o\n        }\n    }\n}\n\npub_test! {mul_rational_prec_round_naive(\n    mut x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = mul_rational_prec_round_assign_naive(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {mul_rational_prec_round_naive_val_ref(\n    mut x: Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = mul_rational_prec_round_assign_naive_ref(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {mul_rational_prec_round_naive_ref_val(\n    x: &Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (float_nan!(), _) => (float_nan!(), Equal),\n        (Float(Infinity { sign }), y) => (\n            match y.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Infinity { sign: *sign }),\n                Less => Float(Infinity { sign: !*sign }),\n            },\n            Equal,\n        ),\n        (Float(Zero { sign }), y) => (\n            if y >= 0u32 {\n                Float(Zero { sign: *sign })\n            } else {\n                Float(Zero { sign: !*sign })\n            },\n            Equal,\n        ),\n        (x, y) => {\n            let (mut product, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) * y, prec, rm);\n            if product == 0u32 && *x < 0 {\n                product.neg_assign();\n            }\n            (product, o)\n        }\n    }\n}}\n\npub_test! {mul_rational_prec_round_naive_ref_ref(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (float_nan!(), _) => (float_nan!(), Equal),\n        (Float(Infinity { sign }), y) => (\n            match y.sign() {\n                Equal => float_nan!(),\n                Greater => Float(Infinity { sign: *sign }),\n                Less => Float(Infinity { sign: !*sign }),\n            },\n            Equal,\n        ),\n        (Float(Zero { sign }), y) => (\n            if *y >= 0u32 {\n                Float(Zero { sign: *sign })\n            } else {\n                Float(Zero { sign: !*sign })\n            },\n            Equal,\n        ),\n        (x, y) => {\n            let (mut product, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) * y, prec, rm);\n            if product == 0u32 && *x < 0 {\n                product.neg_assign();\n            }\n            (product, o)\n        }\n    }\n}}\n\nfn mul_rational_prec_round_assign_direct(\n    x: &mut Float,\n    y: Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    if y == 0u32 {\n        *x = if *x > 0u32 {\n            Float::ZERO\n        } else {\n            Float::NEGATIVE_ZERO\n        };\n        return Equal;\n    }\n    let sign = y >= 0;\n    let (n, d) = y.into_numerator_and_denominator();\n    if !sign {\n        rm.neg_assign();\n    }\n    let o = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_assign(i128::from(log_n) - i128::from(log_d), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent(n), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(log_d) + 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent(d), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(log_n) - i128::from(d_exp) - 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent(n);\n            let d = from_natural_zero_exponent(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + n.significant_bits();\n            *x >>= x_exp;\n            x.mul_prec_round_assign(n, mul_prec, Floor);\n            let o = x.div_prec_round_assign(d, prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            )\n        }\n    };\n    if sign {\n        o\n    } else {\n        x.neg_assign();\n        o.reverse()\n    }\n}\n\nfn mul_rational_prec_round_assign_direct_ref(\n    x: &mut Float,\n    y: &Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> Ordering {\n    assert_ne!(prec, 0);\n    if *y == 0u32 {\n        *x = if *x > 0u32 {\n            Float::ZERO\n        } else {\n            Float::NEGATIVE_ZERO\n        };\n        return Equal;\n    }\n    let sign = *y >= 0;\n    let (n, d) = y.numerator_and_denominator_ref();\n    if !sign {\n        rm.neg_assign();\n    }\n    let o = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_assign(i128::from(log_n) - i128::from(log_d), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent_ref(n), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(log_d) + 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            *x >>= x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent_ref(d), prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(log_n) - i128::from(d_exp) - 1,\n                prec,\n                rm,\n                o,\n            )\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent_ref(n);\n            let d = from_natural_zero_exponent_ref(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + n.significant_bits();\n            *x >>= x_exp;\n            x.mul_prec_round_assign(n, mul_prec, Floor);\n            let o = x.div_prec_round_assign(d, prec, rm);\n            x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            )\n        }\n    };\n    if sign {\n        o\n    } else {\n        x.neg_assign();\n        o.reverse()\n    }\n}\n\npub_test! {mul_rational_prec_round_direct(\n    mut x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = mul_rational_prec_round_assign_direct(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {mul_rational_prec_round_direct_val_ref(\n    mut x: Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let o = mul_rational_prec_round_assign_direct_ref(&mut x, y, prec, rm);\n    (x, o)\n}}\n\npub_test! {mul_rational_prec_round_direct_ref_val(\n    x: &Float,\n    y: Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if y == 0u32 {\n        return (\n            if *x > 0u32 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            },\n            Equal,\n        );\n    }\n    let sign = y >= 0;\n    let (n, d) = y.into_numerator_and_denominator();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (product, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_ref(i128::from(log_n) - i128::from(log_d), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent(n), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(log_d) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent(d), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(log_n) - i128::from(d_exp) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent(n);\n            let d = from_natural_zero_exponent(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + n.significant_bits();\n            let mut x = x >> x_exp;\n            x.mul_prec_round_assign(n, mul_prec, Floor);\n            let o = x.div_prec_round_assign(d, prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n    };\n    if sign {\n        (product, o)\n    } else {\n        (-product, o.reverse())\n    }\n}}\n\npub_test! {mul_rational_prec_round_direct_ref_ref(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if *y == 0u32 {\n        return (\n            if *x > 0u32 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            },\n            Equal,\n        );\n    }\n    let sign = *y >= 0;\n    let (n, d) = y.numerator_and_denominator_ref();\n    if !sign {\n        rm.neg_assign();\n    }\n    let (product, o) = match (n.checked_log_base_2(), d.checked_log_base_2()) {\n        (Some(log_n), Some(log_d)) => {\n            x.shl_prec_round_ref(i128::from(log_n) - i128::from(log_d), prec, rm)\n        }\n        (None, Some(log_d)) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.mul_prec_round_assign(from_natural_zero_exponent_ref(n), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(log_d) + 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (Some(log_n), None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let d_exp = d.floor_log_base_2();\n            let mut x = x >> x_exp;\n            let o = x.div_prec_round_assign(from_natural_zero_exponent_ref(d), prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(log_n) - i128::from(d_exp) - 1,\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n        (None, None) => {\n            let x_exp = x.get_exponent().unwrap();\n            let n_exp = n.floor_log_base_2();\n            let d_exp = d.floor_log_base_2();\n            let n = from_natural_zero_exponent_ref(n);\n            let d = from_natural_zero_exponent_ref(d);\n            let mul_prec = x.get_min_prec().unwrap_or(1) + n.significant_bits();\n            let mut x = x >> x_exp;\n            x.mul_prec_round_assign(n, mul_prec, Floor);\n            let o = x.div_prec_round_assign(d, prec, rm);\n            let o = x.shl_prec_round_assign_helper(\n                i128::from(x_exp) + i128::from(n_exp) - i128::from(d_exp),\n                prec,\n                rm,\n                o,\n            );\n            (x, o)\n        }\n    };\n    if sign {\n        (product, o)\n    } else {\n        (-product, o.reverse())\n    }\n}}\n\nimpl Float {\n    /// Multiplies two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. Both [`Float`]s are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded product is less than, equal to, or greater than the\n    /// exact product. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm0.0,p,m)=f(\\pm0.0,\\pm\\infty,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_prec`] instead. If you\n    /// know that your target precision is the maximum of the precisions of the two inputs, consider\n    /// using [`Float::mul_round`] instead. If both of these things are true, consider using `*`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round(Float::from(E), 5, Floor);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round(Float::from(E), 5, Ceiling);\n    /// assert_eq!(product.to_string(), \"9.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round(Float::from(E), 5, Nearest);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round(Float::from(E), 20, Floor);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round(Float::from(E), 20, Ceiling);\n    /// assert_eq!(product.to_string(), \"8.53975\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round(Float::from(E), 20, Nearest);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec_round(mut self, other: Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.mul_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. The first [`Float`] is are taken by value and the second by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded product is less\n    /// than, equal to, or greater than the exact product. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm0.0,p,m)=f(\\pm0.0,\\pm\\infty,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_prec_val_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::mul_round_val_ref`] instead. If both of these things are true,\n    /// consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_val_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_val_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(product.to_string(), \"9.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_val_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_val_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_val_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(product.to_string(), \"8.53975\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_val_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec_round_val_ref(\n        mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.mul_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. The first [`Float`] is are taken by reference and the second by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded product is less\n    /// than, equal to, or greater than the exact product. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm0.0,p,m)=f(\\pm0.0,\\pm\\infty,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_prec_ref_val`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::mul_round_ref_val`] instead. If both of these things are true,\n    /// consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_val(Float::from(E), 5, Floor);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_val(Float::from(E), 5, Ceiling);\n    /// assert_eq!(product.to_string(), \"9.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_val(Float::from(E), 5, Nearest);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_val(Float::from(E), 20, Floor);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_val(Float::from(E), 20, Ceiling);\n    /// assert_eq!(product.to_string(), \"8.53975\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_val(Float::from(E), 20, Nearest);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec_round_ref_val(\n        &self,\n        mut other: Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = other.mul_prec_round_assign_ref(self, prec, rm);\n        (other, o)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. Both [`Float`]s are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded product is less than, equal to, or greater than the\n    /// exact product. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\pm\\infty,\\pm0.0,p,m)=f(\\pm0.0,\\pm\\infty,p,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p,m)=f(x,\\infty,p,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p,m)=f(x,-\\infty,p,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(0.0,x,p,m)=f(x,0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or\n    ///   $x>0.0$\n    /// - $f(-0.0,x,p,m)=f(x,-0.0,p,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or\n    ///   $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_prec_ref_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::mul_round_ref_ref`] instead. If both of these things are true,\n    /// consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(product.to_string(), \"9.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(product.to_string(), \"8.53975\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_round_ref_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec_round_ref_ref(\n        &self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _)\n            | (_, float_nan!())\n            | (float_either_infinity!(), float_either_zero!())\n            | (float_either_zero!(), float_either_infinity!()) => (float_nan!(), Equal),\n            (\n                Self(Infinity { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Infinity { sign: y_sign })) => (\n                Self(Infinity {\n                    sign: x_sign == y_sign,\n                }),\n                Equal,\n            ),\n            (\n                Self(Zero { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Zero { sign: y_sign })) => (\n                Self(Zero {\n                    sign: x_sign == y_sign,\n                }),\n                Equal,\n            ),\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: y,\n                }),\n            ) => {\n                let sign = x_sign == y_sign;\n                let exp_sum = x_exp + y_exp;\n                if exp_sum - 1 > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                } else if exp_sum < Self::MIN_EXPONENT - 1 {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Floor | Down | Nearest) => (float_zero!(), Less),\n                        (true, _) => (Self::min_positive_value_prec(prec), Greater),\n                        (false, Ceiling | Down | Nearest) => (float_negative_zero!(), Greater),\n                        (false, _) => (-Self::min_positive_value_prec(prec), Less),\n                    };\n                }\n                let (product, exp_offset, o) = mul_float_significands_ref_ref(\n                    x,\n                    *x_prec,\n                    y,\n                    *y_prec,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                let exp = exp_sum.checked_add(exp_offset).unwrap();\n                if exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                } else if exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !product.is_power_of_2())\n                    {\n                        if sign {\n                            (Self::min_positive_value_prec(prec), Greater)\n                        } else {\n                            (-Self::min_positive_value_prec(prec), Less)\n                        }\n                    } else {\n                        match (sign, rm) {\n                            (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                            (true, Ceiling | Up) => (Self::min_positive_value_prec(prec), Greater),\n                            (true, _) => (float_zero!(), Less),\n                            (false, Floor | Up) => (-Self::min_positive_value_prec(prec), Less),\n                            (false, _) => (float_negative_zero!(), Greater),\n                        }\n                    };\n                }\n                (\n                    Self(Finite {\n                        sign,\n                        exponent: exp,\n                        precision: prec,\n                        significand: product,\n                    }),\n                    if sign { o } else { o.reverse() },\n                )\n            }\n        }\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. Both [`Float`]s are taken by value. An [`Ordering`] is also returned, indicating\n    /// whether the rounded product is less than, equal to, or greater than the exact product.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm0.0,p)=f(\\pm0.0,\\pm\\infty,p) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_round`] instead. If you know that your target precision is the maximum of\n    /// the precisions of the two inputs, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec(Float::from(E), 5);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec(Float::from(E), 20);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec(self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.mul_prec_round(other, prec, Nearest)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. The first [`Float`] is taken by value and the second by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded product is less than, equal\n    /// to, or greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm0.0,p)=f(\\pm0.0,\\pm\\infty,p) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_round_val_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_val_ref(&Float::from(E), 5);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_val_ref(&Float::from(E), 20);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec_val_ref(self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.mul_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. The first [`Float`] is taken by reference and the second by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded product is less than, equal\n    /// to, or greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm0.0,p)=f(\\pm0.0,\\pm\\infty,p) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_round_ref_val`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_ref_val(Float::from(E), 5);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_ref_val(Float::from(E), 20);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec_ref_val(&self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.mul_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. Both [`Float`]s are taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded product is less than, equal to, or greater than the exact\n    /// product. Although `NaN`s are not comparable to any [`Float`], whenever this function returns\n    /// a `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\pm\\infty,\\pm0.0,p)=f(\\pm0.0,\\pm\\infty,p) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,p)=f(x,\\infty,p)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,p)=f(x,-\\infty,p)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,p)=f(x,0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,p)=f(x,-0.0,p)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_round_ref_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_ref_ref(&Float::from(E), 5);\n    /// assert_eq!(product.to_string(), \"8.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_prec_ref_ref(&Float::from(E), 20);\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.mul_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result with the specified rounding mode. Both\n    /// [`Float`]s are taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded product is less than, equal to, or greater than the exact product. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\pm\\infty,\\pm0.0,m)=f(\\pm0.0,\\pm\\infty,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::mul_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `*`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_round(Float::from(E), Floor);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round(Float::from(E), Ceiling);\n    /// assert_eq!(product.to_string(), \"8.539734222673568\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round(Float::from(E), Nearest);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_round(self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round(other, prec, rm)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result with the specified rounding mode. The first\n    /// [`Float`] is taken by value and the second by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded product is less than, equal to, or greater than the exact\n    /// product. Although `NaN`s are not comparable to any [`Float`], whenever this function returns\n    /// a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\pm\\infty,\\pm0.0,m)=f(\\pm0.0,\\pm\\infty,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::mul_prec_round_val_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `*`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_val_ref(&Float::from(E), Floor);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_val_ref(&Float::from(E), Ceiling);\n    /// assert_eq!(product.to_string(), \"8.539734222673568\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_val_ref(&Float::from(E), Nearest);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_round_val_ref(self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result with the specified rounding mode. The first\n    /// [`Float`] is taken by reference and the second by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded product is less than, equal to, or greater than the exact\n    /// product. Although `NaN`s are not comparable to any [`Float`], whenever this function returns\n    /// a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\pm\\infty,\\pm0.0,m)=f(\\pm0.0,\\pm\\infty,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::mul_prec_round_ref_val`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `*`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_ref_val(Float::from(E), Floor);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_ref_val(Float::from(E), Ceiling);\n    /// assert_eq!(product.to_string(), \"8.539734222673568\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_ref_val(Float::from(E), Nearest);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_round_ref_val(&self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Multiplies two [`Float`]s, rounding the result with the specified rounding mode. Both\n    /// [`Float`]s are taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// rounded product is less than, equal to, or greater than the exact product. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\pm\\infty,\\pm0.0,m)=f(\\pm0.0,\\pm\\infty,m) =\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x,m)=f(x,\\infty,m)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x,m)=f(x,-\\infty,m)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x,m)=f(x,0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x,m)=f(x,-0.0,m)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::mul_prec_round_ref_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `*`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_ref_ref(&Float::from(E), Floor);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_ref_ref(&Float::from(E), Ceiling);\n    /// assert_eq!(product.to_string(), \"8.539734222673568\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_round_ref_ref(&Float::from(E), Nearest);\n    /// assert_eq!(product.to_string(), \"8.539734222673566\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_round_ref_ref(&self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Float`] on the right-hand side is\n    /// taken by value. An [`Ordering`] is returned, indicating whether the rounded product is less\n    /// than, equal to, or greater than the exact product. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_prec_assign`] instead. If\n    /// you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::mul_round_assign`] instead. If both of these things are true,\n    /// consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign(Float::from(E), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.5\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign(Float::from(E), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(product.to_string(), \"9.0\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign(Float::from(E), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.5\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign(Float::from(E), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign(Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(product.to_string(), \"8.53975\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign(Float::from(E), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// ```\n    #[inline]\n    pub fn mul_prec_round_assign(&mut self, other: Self, prec: u64, rm: RoundingMode) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (float_nan!(), _)\n            | (_, float_nan!())\n            | (float_either_infinity!(), float_either_zero!())\n            | (float_either_zero!(), float_either_infinity!()) => {\n                *self = float_nan!();\n                Equal\n            }\n            (\n                Self(Infinity { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Infinity { sign: y_sign })) => {\n                *self = Self(Infinity {\n                    sign: *x_sign == y_sign,\n                });\n                Equal\n            }\n            (\n                Self(Zero { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Zero { sign: y_sign })) => {\n                *self = Self(Zero {\n                    sign: *x_sign == y_sign,\n                });\n                Equal\n            }\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: mut y,\n                }),\n            ) => {\n                let sign = *x_sign == y_sign;\n                let exp_sum = *x_exp + y_exp;\n                if exp_sum - 1 > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if exp_sum < Self::MIN_EXPONENT - 1 {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Floor | Down | Nearest) => {\n                            *self = float_zero!();\n                            Less\n                        }\n                        (true, _) => {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        }\n                        (false, Ceiling | Down | Nearest) => {\n                            *self = float_negative_zero!();\n                            Greater\n                        }\n                        (false, _) => {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                    };\n                }\n                let (exp_offset, o) = mul_float_significands_in_place(\n                    x,\n                    *x_prec,\n                    &mut y,\n                    y_prec,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                *x_exp = exp_sum.checked_add(exp_offset).unwrap();\n                if *x_exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if *x_exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && *x_exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !x.is_power_of_2())\n                    {\n                        if sign {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        } else {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                    } else {\n                        match (sign, rm) {\n                            (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                            (true, Ceiling | Up) => {\n                                *self = Self::min_positive_value_prec(prec);\n                                Greater\n                            }\n                            (true, _) => {\n                                *self = float_zero!();\n                                Less\n                            }\n                            (false, Floor | Up) => {\n                                *self = -Self::min_positive_value_prec(prec);\n                                Less\n                            }\n                            (false, _) => {\n                                *self = float_negative_zero!();\n                                Greater\n                            }\n                        }\n                    };\n                }\n                *x_sign = sign;\n                *x_prec = prec;\n                if sign { o } else { o.reverse() }\n            }\n        }\n    }\n\n    /// Multiplies a [`Float`] by a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Float`] on the right-hand side is\n    /// taken by reference. An [`Ordering`] is returned, indicating whether the rounded product is\n    /// less than, equal to, or greater than the exact product. Although `NaN`s are not comparable\n    /// to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_prec_assign_ref`]\n    /// instead. If you know that your target precision is the maximum of the precisions of the two\n    /// inputs, consider using [`Float::mul_round_assign_ref`] instead. If both of these things are\n    /// true, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign_ref(&Float::from(E), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.5\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign_ref(&Float::from(E), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(product.to_string(), \"9.0\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign_ref(&Float::from(E), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.5\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign_ref(&Float::from(E), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign_ref(&Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(product.to_string(), \"8.53975\");\n    ///\n    /// let mut product = Float::from(PI);\n    /// assert_eq!(\n    ///     product.mul_prec_round_assign_ref(&Float::from(E), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(product.to_string(), \"8.53973\");\n    /// ```\n    #[inline]\n    pub fn mul_prec_round_assign_ref(\n        &mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (float_nan!(), _)\n            | (_, float_nan!())\n            | (float_either_infinity!(), float_either_zero!())\n            | (float_either_zero!(), float_either_infinity!()) => {\n                *self = float_nan!();\n                Equal\n            }\n            (\n                Self(Infinity { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Infinity { sign: y_sign })) => {\n                *self = Self(Infinity {\n                    sign: *x_sign == *y_sign,\n                });\n                Equal\n            }\n            (\n                Self(Zero { sign: x_sign }),\n                Self(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n            )\n            | (Self(Finite { sign: x_sign, .. }), Self(Zero { sign: y_sign })) => {\n                *self = Self(Zero {\n                    sign: *x_sign == *y_sign,\n                });\n                Equal\n            }\n            (\n                Self(Finite {\n                    sign: x_sign,\n                    exponent: x_exp,\n                    precision: x_prec,\n                    significand: x,\n                }),\n                Self(Finite {\n                    sign: y_sign,\n                    exponent: y_exp,\n                    precision: y_prec,\n                    significand: y,\n                }),\n            ) => {\n                let sign = x_sign == y_sign;\n                let exp_sum = *x_exp + y_exp;\n                if exp_sum - 1 > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if exp_sum < Self::MIN_EXPONENT - 1 {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Floor | Down | Nearest) => {\n                            *self = float_zero!();\n                            Less\n                        }\n                        (true, _) => {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        }\n                        (false, Ceiling | Down | Nearest) => {\n                            *self = float_negative_zero!();\n                            Greater\n                        }\n                        (false, _) => {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                    };\n                }\n                let (exp_offset, o) = mul_float_significands_in_place_ref(\n                    x,\n                    *x_prec,\n                    y,\n                    *y_prec,\n                    prec,\n                    if sign { rm } else { -rm },\n                );\n                *x_exp = exp_sum.checked_add(exp_offset).unwrap();\n                if *x_exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                } else if *x_exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && *x_exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !x.is_power_of_2())\n                    {\n                        if sign {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        } else {\n                            *self = -Self::min_positive_value_prec(prec);\n                            Less\n                        }\n                    } else {\n                        match (sign, rm) {\n                            (_, Exact) => panic!(\"Inexact Float multiplication\"),\n                            (true, Ceiling | Up) => {\n                                *self = Self::min_positive_value_prec(prec);\n                                Greater\n                            }\n                            (true, _) => {\n                                *self = float_zero!();\n                                Less\n                            }\n                            (false, Floor | Up) => {\n                                *self = -Self::min_positive_value_prec(prec);\n                                Less\n                            }\n                            (false, _) => {\n                                *self = float_negative_zero!();\n                                Greater\n                            }\n                        }\n                    };\n                }\n                *x_sign = sign;\n                *x_prec = prec;\n                if sign { o } else { o.reverse() }\n            }\n        }\n    }\n\n    /// Multiplies a [`Float`] by a [`Float`] in place, rounding the result to the nearest value of\n    /// the specified precision. The [`Float`] on the right-hand side is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the rounded product is less than, equal to, or\n    /// greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_round_assign`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_prec_assign(Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"8.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_prec_assign(Float::from(E), 20), Less);\n    /// assert_eq!(x.to_string(), \"8.53973\");\n    /// ```\n    #[inline]\n    pub fn mul_prec_assign(&mut self, other: Self, prec: u64) -> Ordering {\n        self.mul_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Float`] in place, rounding the result to the nearest value of\n    /// the specified precision. The [`Float`] on the right-hand side is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded product is less than, equal to, or\n    /// greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_round_assign_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_prec_assign_ref(&Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"8.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_prec_assign_ref(&Float::from(E), 20), Less);\n    /// assert_eq!(x.to_string(), \"8.53973\");\n    /// ```\n    #[inline]\n    pub fn mul_prec_assign_ref(&mut self, other: &Self, prec: u64) -> Ordering {\n        self.mul_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. The [`Float`] on the right-hand side is taken by value. An [`Ordering`] is\n    /// returned, indicating whether the rounded product is less than, equal to, or greater than the\n    /// exact product. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::mul_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::mul_prec_round_assign`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `*=`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_round_assign(Float::from(E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"8.539734222673566\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_round_assign(Float::from(E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"8.539734222673568\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_round_assign(Float::from(E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"8.539734222673566\");\n    /// ```\n    #[inline]\n    pub fn mul_round_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_assign(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. The [`Float`] on the right-hand side is taken by reference. An [`Ordering`]\n    /// is returned, indicating whether the rounded product is less than, equal to, or greater than\n    /// the exact product. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::mul_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::mul_prec_round_assign_ref`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_round_assign_ref(&Float::from(E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"8.539734222673566\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_round_assign_ref(&Float::from(E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"8.539734222673568\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.mul_round_assign_ref(&Float::from(E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"8.539734222673566\");\n    /// ```\n    #[inline]\n    pub fn mul_round_assign_ref(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_assign_ref(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded product is less\n    /// than, equal to, or greater than the exact product. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_rational_prec`] instead.\n    /// If you know that your target precision is the precision of the [`Float`] input, consider\n    /// using [`Float::mul_rational_round`] instead. If both of these things are true, consider\n    /// using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Floor);\n    /// assert_eq!(product.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Ceiling);\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Nearest);\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Floor);\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Ceiling);\n    /// assert_eq!(product.to_string(), \"1.047199\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Nearest);\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_round(\n        mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.mul_rational_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by value and the [`Rational`] by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded product is less\n    /// than, equal to, or greater than the exact product. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_rational_prec_val_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::mul_rational_round_val_ref`] instead. If both of these things are\n    /// true, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047199\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_round_val_ref(\n        mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.mul_rational_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by reference and the [`Rational`]\n    /// by value. An [`Ordering`] is also returned, indicating whether the rounded product is less\n    /// than, equal to, or greater than the exact product. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_rational_prec_ref_val`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::mul_rational_round_ref_val`] instead. If both of these things are\n    /// true, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047199\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_round_ref_val(\n        &self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < MUL_RATIONAL_THRESHOLD\n        {\n            mul_rational_prec_round_naive_ref_val(self, other, prec, rm)\n        } else {\n            mul_rational_prec_round_direct_ref_val(self, other, prec, rm)\n        }\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded product is less\n    /// than, equal to, or greater than the exact product. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(\\pm\\infty,0,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_rational_prec_ref_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::mul_rational_round_ref_ref`] instead. If both of these things are\n    /// true, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.06\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047199\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(product.to_string(), \"1.047197\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_round_ref_ref(\n        &self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < MUL_RATIONAL_THRESHOLD\n        {\n            mul_rational_prec_round_naive_ref_ref(self, other, prec, rm)\n        } else {\n            mul_rational_prec_round_direct_ref_ref(self, other, prec, rm)\n        }\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded product is less than, equal\n    /// to, or greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_round`] instead. If you know that your target precision is the\n    /// precision of the [`Float`] input, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec(Rational::exact_from(1.5), 5);\n    /// assert_eq!(product.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec(Rational::exact_from(1.5), 20);\n    /// assert_eq!(product.to_string(), \"4.712387\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec(self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.mul_rational_prec_round(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by value and the [`Rational`] by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded product is less than, equal\n    /// to, or greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_round_val_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_val_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(product.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_val_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(product.to_string(), \"4.712387\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_val_ref(self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.mul_rational_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by reference and the [`Rational`] by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded product is less than, equal\n    /// to, or greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_round_ref_val`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_ref_val(Rational::exact_from(1.5), 5);\n    /// assert_eq!(product.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_ref_val(Rational::exact_from(1.5), 20);\n    /// assert_eq!(product.to_string(), \"4.712387\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_ref_val(&self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.mul_rational_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded product is less than, equal\n    /// to, or greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(\\pm\\infty,0,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,p)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,p)=\\infty$ if $x<0$\n    /// - $f(0.0,x,p)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,p)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,p)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,p)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_round_ref_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) = Float::from(PI).mul_rational_prec_ref_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(product.to_string(), \"4.8\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_prec_ref_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(product.to_string(), \"4.712387\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_ref_ref(&self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.mul_rational_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] and the [`Rational`] are both are taken by value. An [`Ordering`] is\n    /// also returned, indicating whether the rounded product is less than, equal to, or greater\n    /// than the exact product. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::mul_rational_prec_round`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(product.to_string(), \"1.047197551196597\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn mul_rational_round(self, other: Rational, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] is taken by value and the [`Rational`] by reference. An [`Ordering`] is\n    /// also returned, indicating whether the rounded product is less than, equal to, or greater\n    /// than the exact product. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::mul_rational_prec_round_val_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(product.to_string(), \"1.047197551196597\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn mul_rational_round_val_ref(\n        self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] is taken by reference and the [`Rational`] by value. An [`Ordering`] is\n    /// also returned, indicating whether the rounded product is less than, equal to, or greater\n    /// than the exact product. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::mul_rational_prec_round_ref_val`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(product.to_string(), \"1.047197551196597\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn mul_rational_round_ref_val(\n        &self,\n        other: Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] and the [`Rational`] are both are taken by reference. An [`Ordering`] is\n    /// also returned, indicating whether the rounded product is less than, equal to, or greater\n    /// than the exact product. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(\\pm\\infty,0,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x>0$\n    /// - $f(\\infty,x,m)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x,m)=\\infty$ if $x<0$\n    /// - $f(0.0,x,m)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x,m)=-0.0$ if $x<0$\n    /// - $f(-0.0,x,m)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x,m)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::mul_rational_prec_round_ref_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `*` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(product.to_string(), \"1.047197551196597\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (product, o) =\n    ///     Float::from(PI).mul_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(product.to_string(), \"1.047197551196598\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn mul_rational_round_ref_ref(\n        &self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Rational`] is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the rounded product is less than, equal to, or\n    /// greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::mul_rational_prec_assign`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::mul_rational_round_assign`] instead. If both of these things are\n    /// true, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.06\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.06\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047199\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197\");\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_round_assign(\n        &mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < MUL_RATIONAL_THRESHOLD\n        {\n            mul_rational_prec_round_assign_naive(self, other, prec, rm)\n        } else {\n            mul_rational_prec_round_assign_direct(self, other, prec, rm)\n        }\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Rational`] is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded product is less than, equal to, or\n    /// greater than the exact product. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::mul_rational_prec_assign_ref`] instead. If you know that your target precision is\n    /// the precision of the [`Float`] input, consider using\n    /// [`Float::mul_rational_round_assign_ref`] instead. If both of these things are true, consider\n    /// using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact multiplication.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.06\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.06\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047199\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197\");\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        if !self.is_normal()\n            || max(self.complexity(), other.significant_bits()) < MUL_RATIONAL_THRESHOLD\n        {\n            mul_rational_prec_round_assign_naive_ref(self, other, prec, rm)\n        } else {\n            mul_rational_prec_round_assign_direct_ref(self, other, prec, rm)\n        }\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`] in place, rounding the result to the nearest value\n    /// of the specified precision. The [`Rational`] is taken by value. An [`Ordering`] is returned,\n    /// indicating whether the rounded product is less than, equal to, or greater than the exact\n    /// product. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_rational_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_round_assign`] instead. If you know that your target precision is\n    /// the maximum of the precisions of the two inputs, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_assign(Rational::exact_from(1.5), 5),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"4.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_assign(Rational::exact_from(1.5), 20),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"4.712387\");\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_assign(&mut self, other: Rational, prec: u64) -> Ordering {\n        self.mul_rational_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`] in place, rounding the result to the nearest value\n    /// of the specified precision. The [`Rational`] is taken by reference. An [`Ordering`] is\n    /// returned, indicating whether the rounded product is less than, equal to, or greater than the\n    /// exact product. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the product is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::mul_rational_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_round_assign`] instead. If you know that your target precision is\n    /// the maximum of the precisions of the two inputs, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_assign_ref(&Rational::exact_from(1.5), 5),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"4.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_prec_assign_ref(&Rational::exact_from(1.5), 20),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"4.712387\");\n    /// ```\n    #[inline]\n    pub fn mul_rational_prec_assign_ref(&mut self, other: &Rational, prec: u64) -> Ordering {\n        self.mul_rational_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`] in place, rounding the result with the specified\n    /// rounding mode. The [`Rational`] is taken by value. An [`Ordering`] is returned, indicating\n    /// whether the rounded product is less than, equal to, or greater than the exact product.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::mul_rational_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::mul_rational_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_round_assign(Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197551196597\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_round_assign(Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197551196598\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_round_assign(Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197551196598\");\n    /// ```\n    #[inline]\n    pub fn mul_rational_round_assign(&mut self, other: Rational, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_assign(other, prec, rm)\n    }\n\n    /// Multiplies a [`Float`] by a [`Rational`] in place, rounding the result with the specified\n    /// rounding mode. The [`Rational`] is taken by reference. An [`Ordering`] is returned,\n    /// indicating whether the rounded product is less than, equal to, or greater than the exact\n    /// product. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $xy$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::mul_rational_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::mul_rational_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `*=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197551196597\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197551196598\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.mul_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"1.047197551196598\");\n    /// ```\n    #[inline]\n    pub fn mul_rational_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> Ordering {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_assign_ref(other, prec, rm)\n    }\n}\n\nimpl Mul<Self> for Float {\n    type Output = Self;\n\n    /// Multiplies two [`Float`]s, taking both by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// product is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm0.0)=f(\\pm0.0,\\pm\\infty) = \\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x)=f(x,\\infty)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=f(x,0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x)=f(x,0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::mul_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::mul_round`].\n    /// If you want both of these things, consider using [`Float::mul_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) * Float::NAN).is_nan());\n    /// assert_eq!(Float::from(1.5) * Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::from(1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::from(-1.5) * Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::from(-1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert!((Float::INFINITY * Float::ZERO).is_nan());\n    ///\n    /// assert_eq!(Float::from(1.5) * Float::from(2.5), 4.0);\n    /// assert_eq!(Float::from(1.5) * Float::from(-2.5), -4.0);\n    /// assert_eq!(Float::from(-1.5) * Float::from(2.5), -4.0);\n    /// assert_eq!(Float::from(-1.5) * Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Mul<&Self> for Float {\n    type Output = Self;\n\n    /// Multiplies two [`Float`]s, taking the first by value and the second by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// product is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm0.0)=f(\\pm0.0,\\pm\\infty) = \\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x)=f(x,\\infty)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=f(x,0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x)=f(x,0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_val_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::mul_round_val_ref`]. If you want both of these things, consider using\n    /// [`Float::mul_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) * &Float::NAN).is_nan());\n    /// assert_eq!(Float::from(1.5) * &Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::from(1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::from(-1.5) * &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::from(-1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert!((Float::INFINITY * &Float::ZERO).is_nan());\n    ///\n    /// assert_eq!(Float::from(1.5) * &Float::from(2.5), 4.0);\n    /// assert_eq!(Float::from(1.5) * &Float::from(-2.5), -4.0);\n    /// assert_eq!(Float::from(-1.5) * &Float::from(2.5), -4.0);\n    /// assert_eq!(Float::from(-1.5) * &Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: &Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Mul<Float> for &Float {\n    type Output = Float;\n\n    /// Multiplies two [`Float`]s, taking the first by reference and the second by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// product is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm0.0)=f(\\pm0.0,\\pm\\infty) = \\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x)=f(x,\\infty)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=f(x,0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x)=f(x,0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_ref_val`] instead. If you want to specify the output precision, consider\n    /// using [`Float::mul_round_ref_val`]. If you want both of these things, consider using\n    /// [`Float::mul_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) * Float::NAN).is_nan());\n    /// assert_eq!(&Float::from(1.5) * Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Float::from(1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::from(-1.5) * Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::from(-1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert!((&Float::INFINITY * Float::ZERO).is_nan());\n    ///\n    /// assert_eq!(&Float::from(1.5) * Float::from(2.5), 4.0);\n    /// assert_eq!(&Float::from(1.5) * Float::from(-2.5), -4.0);\n    /// assert_eq!(&Float::from(-1.5) * Float::from(2.5), -4.0);\n    /// assert_eq!(&Float::from(-1.5) * Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Mul<&Float> for &Float {\n    type Output = Float;\n\n    /// Multiplies two [`Float`]s, taking both by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// product is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\pm\\infty,\\pm0.0)=f(\\pm0.0,\\pm\\infty) = \\text{NaN}$\n    /// - $f(\\infty,x)=f(x,\\infty)=\\infty$ if $x>0.0$\n    /// - $f(\\infty,x)=f(x,\\infty)=-\\infty$ if $x<0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=-\\infty$ if $x>0.0$\n    /// - $f(-\\infty,x)=f(x,-\\infty)=\\infty$ if $x<0.0$\n    /// - $f(0.0,x)=f(x,0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(0.0,x)=f(x,0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=-0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=0.0$ or $x>0.0$\n    /// - $f(-0.0,x)=f(x,-0.0)=0.0$ if $x$ is not NaN or $\\pm\\infty$, and if $x=-0.0$ or $x<0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_ref_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::mul_round_ref_ref`]. If you want both of these things, consider using\n    /// [`Float::mul_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) * &Float::NAN).is_nan());\n    /// assert_eq!(&Float::from(1.5) * &Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     &Float::from(1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::from(-1.5) * &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::from(-1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert!((&Float::INFINITY * &Float::ZERO).is_nan());\n    ///\n    /// assert_eq!(&Float::from(1.5) * &Float::from(2.5), 4.0);\n    /// assert_eq!(&Float::from(1.5) * &Float::from(-2.5), -4.0);\n    /// assert_eq!(&Float::from(-1.5) * &Float::from(2.5), -4.0);\n    /// assert_eq!(&Float::from(-1.5) * &Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: &Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl MulAssign<Self> for Float {\n    /// Multiplies a [`Float`] by a [`Float`] in place, taking the [`Float`] on the right-hand side\n    /// by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// product is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x\\gets = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `*` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::mul_round_assign`]. If you want both of these things, consider using\n    /// [`Float::mul_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= Float::INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= Float::INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x *= Float::ZERO;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= Float::from(2.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= Float::from(-2.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= Float::from(2.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= Float::from(-2.5);\n    /// assert_eq!(x, 4.0);\n    /// ```\n    #[inline]\n    fn mul_assign(&mut self, other: Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl MulAssign<&Self> for Float {\n    /// Multiplies a [`Float`] by a [`Float`] in place, taking the [`Float`] on the right-hand side\n    /// by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// product is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x\\gets = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `*` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::mul_round_assign`]. If you want both of these things, consider using\n    /// [`Float::mul_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= &Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= &Float::INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= &Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= &Float::INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= &Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x *= &Float::ZERO;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= &Float::from(2.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x *= &Float::from(-2.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= &Float::from(2.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x *= &Float::from(-2.5);\n    /// assert_eq!(x, 4.0);\n    /// ```\n    #[inline]\n    fn mul_assign(&mut self, other: &Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.mul_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Mul<Rational> for Float {\n    type Output = Self;\n\n    /// Multiplies a [`Float`] by a [`Rational`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x>0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec`] instead. If you want to specify the output precision, consider\n    /// using [`Float::mul_rational_round`]. If you want both of these things, consider using\n    /// [`Float::mul_rational_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN * Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(Float::INFINITY * Rational::exact_from(1.5), Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY * Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::INFINITY * Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY * Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(Float::from(2.5) * Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(Float::from(2.5) * Rational::exact_from(-1.5), -4.0);\n    /// assert_eq!(Float::from(-2.5) * Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(Float::from(-2.5) * Rational::exact_from(-1.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: Rational) -> Self {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Mul<&Rational> for Float {\n    type Output = Self;\n\n    /// Multiplies a [`Float`] by a [`Rational`], taking the first by value and the second by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x>0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_val_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::mul_rational_round_val_ref`]. If you want both of these things,\n    /// consider using [`Float::mul_rational_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN * &Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     Float::INFINITY * &Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY * &Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::INFINITY * &Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY * &Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(Float::from(2.5) * &Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(Float::from(2.5) * &Rational::exact_from(-1.5), -4.0);\n    /// assert_eq!(Float::from(-2.5) * &Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(Float::from(-2.5) * &Rational::exact_from(-1.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: &Rational) -> Self {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Mul<Rational> for &Float {\n    type Output = Float;\n\n    /// Multiplies a [`Float`] by a [`Rational`], taking the first by reference and the second by\n    /// value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x>0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_ref_val`] instead. If you want to specify the output precision,\n    /// consider using [`Float::mul_rational_round_ref_val`]. If you want both of these things,\n    /// consider using [`Float::mul_rational_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN * Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY * Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY * Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::INFINITY * Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY * Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Float::from(2.5) * Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(&Float::from(2.5) * Rational::exact_from(-1.5), -4.0);\n    /// assert_eq!(&Float::from(-2.5) * Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(&Float::from(-2.5) * Rational::exact_from(-1.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: Rational) -> Float {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Mul<&Rational> for &Float {\n    type Output = Float;\n\n    /// Multiplies a [`Float`] by a [`Rational`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(\\pm\\infty,0)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x>0$\n    /// - $f(\\infty,x)=-\\infty$ if $x<0$\n    /// - $f(-\\infty,x)=-\\infty$ if $x>0$\n    /// - $f(-\\infty,x)=\\infty$ if $x<0$\n    /// - $f(0.0,x)=0.0$ if $x\\geq0$\n    /// - $f(0.0,x)=-0.0$ if $x<0$\n    /// - $f(-0.0,x)=-0.0$ if $x\\geq0$\n    /// - $f(-0.0,x)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_ref_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::mul_rational_round_ref_ref`]. If you want both of these things,\n    /// consider using [`Float::mul_rational_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN * &Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY * &Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY * &Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::INFINITY * &Rational::exact_from(-1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY * &Rational::exact_from(-1.5),\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Float::from(2.5) * &Rational::exact_from(1.5), 4.0);\n    /// assert_eq!(&Float::from(2.5) * &Rational::exact_from(-1.5), -4.0);\n    /// assert_eq!(&Float::from(-2.5) * &Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(&Float::from(-2.5) * &Rational::exact_from(-1.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: &Rational) -> Float {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl MulAssign<Rational> for Float {\n    /// Multiplies a [`Float`] by a [`Rational`] in place, taking the [`Rational`] by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `*` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_assign`] instead. If you want to specify the output precision,\n    /// consider using [`Float::mul_rational_round_assign`]. If you want both of these things,\n    /// consider using [`Float::mul_rational_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x *= Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x *= Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x *= Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x *= Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x *= Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x *= Rational::exact_from(1.5);\n    /// assert_eq!(x, 4.0);\n    /// ```\n    #[inline]\n    fn mul_assign(&mut self, other: Rational) {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl MulAssign<&Rational> for Float {\n    /// Multiplies a [`Float`] by a [`Rational`] in place, taking the [`Rational`] by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `*` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::mul_rational_prec_assign_ref`] instead. If you want to specify the output\n    /// precision, consider using [`Float::mul_rational_round_assign_ref`]. If you want both of\n    /// these things, consider using [`Float::mul_rational_prec_round_assign_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x *= &Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x *= &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x *= &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x *= &Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x *= &Rational::exact_from(-1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x *= &Rational::exact_from(1.5);\n    /// assert_eq!(x, 4.0);\n    /// ```\n    #[inline]\n    fn mul_assign(&mut self, other: &Rational) {\n        let prec = self.significant_bits();\n        self.mul_rational_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Mul<Float> for Rational {\n    type Output = Float;\n\n    /// Multiplies a [`Rational`] by a [`Float`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=f(0,\\pm\\infty)=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$ if $x>0$\n    /// - $f(x,\\infty)=-\\infty$ if $x<0$\n    /// - $f(x,-\\infty)=-\\infty$ if $x>0$\n    /// - $f(x,-\\infty)=\\infty$ if $x<0$\n    /// - $f(x,0.0)=0.0$ if $x\\geq0$\n    /// - $f(x,0.0)=-0.0$ if $x<0$\n    /// - $f(x,-0.0)=-0.0$ if $x\\geq0$\n    /// - $f(x,-0.0)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) * Float::NAN).is_nan());\n    /// assert_eq!(Rational::exact_from(1.5) * Float::INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) * Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(Rational::exact_from(1.5) * Float::from(2.5), 4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) * Float::from(2.5), -4.0);\n    /// assert_eq!(Rational::exact_from(1.5) * Float::from(-2.5), -4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) * Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        other.mul_rational_prec_round(self, prec, Nearest).0\n    }\n}\n\nimpl Mul<&Float> for Rational {\n    type Output = Float;\n\n    /// Multiplies a [`Rational`] by a [`Float`], taking the [`Rational`] by value and the [`Float`]\n    /// by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=f(0,\\pm\\infty)=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$ if $x>0$\n    /// - $f(x,\\infty)=-\\infty$ if $x<0$\n    /// - $f(x,-\\infty)=-\\infty$ if $x>0$\n    /// - $f(x,-\\infty)=\\infty$ if $x<0$\n    /// - $f(x,0.0)=0.0$ if $x\\geq0$\n    /// - $f(x,0.0)=-0.0$ if $x<0$\n    /// - $f(x,-0.0)=-0.0$ if $x\\geq0$\n    /// - $f(x,-0.0)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) * &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) * &Float::INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) * &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(-1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(Rational::exact_from(1.5) * &Float::from(2.5), 4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) * &Float::from(2.5), -4.0);\n    /// assert_eq!(Rational::exact_from(1.5) * &Float::from(-2.5), -4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) * &Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        other.mul_rational_prec_round_ref_val(self, prec, Nearest).0\n    }\n}\n\nimpl Mul<Float> for &Rational {\n    type Output = Float;\n\n    /// Multiplies a [`Rational`] by a [`Float`], taking the [`Rational`] by reference and the\n    /// [`Float`] by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=f(0,\\pm\\infty)=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$ if $x>0$\n    /// - $f(x,\\infty)=-\\infty$ if $x<0$\n    /// - $f(x,-\\infty)=-\\infty$ if $x>0$\n    /// - $f(x,-\\infty)=\\infty$ if $x<0$\n    /// - $f(x,0.0)=0.0$ if $x\\geq0$\n    /// - $f(x,0.0)=-0.0$ if $x<0$\n    /// - $f(x,-0.0)=-0.0$ if $x\\geq0$\n    /// - $f(x,-0.0)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) * Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) * Float::INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) * Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) * Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Rational::exact_from(1.5) * Float::from(2.5), 4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) * Float::from(2.5), -4.0);\n    /// assert_eq!(&Rational::exact_from(1.5) * Float::from(-2.5), -4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) * Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        other.mul_rational_prec_round_val_ref(self, prec, Nearest).0\n    }\n}\n\nimpl Mul<&Float> for &Rational {\n    type Output = Float;\n\n    /// Multiplies a [`Rational`] by a [`Float`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the product is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = xy+\\varepsilon.\n    /// $$\n    /// - If $xy$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $xy$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |xy|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=f(0,\\pm\\infty)=\\text{NaN}$\n    /// - $f(x,\\infty)=\\infty$ if $x>0$\n    /// - $f(x,\\infty)=-\\infty$ if $x<0$\n    /// - $f(x,-\\infty)=-\\infty$ if $x>0$\n    /// - $f(x,-\\infty)=\\infty$ if $x<0$\n    /// - $f(x,0.0)=0.0$ if $x\\geq0$\n    /// - $f(x,0.0)=-0.0$ if $x<0$\n    /// - $f(x,-0.0)=-0.0$ if $x\\geq0$\n    /// - $f(x,-0.0)=0.0$ if $x<0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) * &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) * &Float::INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) * &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(-1.5) * &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Rational::exact_from(1.5) * &Float::from(2.5), 4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) * &Float::from(2.5), -4.0);\n    /// assert_eq!(&Rational::exact_from(1.5) * &Float::from(-2.5), -4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) * &Float::from(-2.5), 4.0);\n    /// ```\n    #[inline]\n    fn mul(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        other.mul_rational_prec_round_ref_ref(self, prec, Nearest).0\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::float_nan;\nuse core::ops::Neg;\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::logic::traits::NotAssign;\n\nimpl Neg for Float {\n    type Output = Self;\n\n    /// Negates a [`Float`], taking it by value.\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN}) = \\text{NaN}$\n    /// - $f(\\infty) = -\\infty$\n    /// - $f(-\\infty) = \\infty$\n    /// - $f(0.0) = -0.0$\n    /// - $f(-0.0) = 0.0$\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(ComparableFloat(-Float::NAN), ComparableFloat(Float::NAN));\n    /// assert_eq!(-Float::INFINITY, Float::NEGATIVE_INFINITY);\n    /// assert_eq!(-Float::NEGATIVE_INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     ComparableFloat(-Float::ZERO),\n    ///     ComparableFloat(Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(-Float::NEGATIVE_ZERO),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(-Float::ONE, Float::NEGATIVE_ONE);\n    /// assert_eq!(-Float::NEGATIVE_ONE, Float::ONE);\n    /// ```\n    #[inline]\n    fn neg(mut self) -> Self {\n        self.neg_assign();\n        self\n    }\n}\n\nimpl Neg for &Float {\n    type Output = Float;\n\n    /// Negates a [`Float`], taking it by reference.\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN}) = \\text{NaN}$\n    /// - $f(\\infty) = -\\infty$\n    /// - $f(-\\infty) = \\infty$\n    /// - $f(0.0) = -0.0$\n    /// - $f(-0.0) = 0.0$\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(ComparableFloat(-&Float::NAN), ComparableFloat(Float::NAN));\n    /// assert_eq!(-&Float::INFINITY, Float::NEGATIVE_INFINITY);\n    /// assert_eq!(-&Float::NEGATIVE_INFINITY, Float::INFINITY);\n    /// assert_eq!(\n    ///     ComparableFloat(-&Float::ZERO),\n    ///     ComparableFloat(Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(-&Float::NEGATIVE_ZERO),\n    ///     ComparableFloat(Float::ZERO)\n    /// );\n    /// assert_eq!(-&Float::ONE, Float::NEGATIVE_ONE);\n    /// assert_eq!(-&Float::NEGATIVE_ONE, Float::ONE);\n    /// ```\n    fn neg(self) -> Float {\n        match self {\n            float_nan!() => float_nan!(),\n            Float(Infinity { sign }) => Float(Infinity { sign: !*sign }),\n            Float(Zero { sign }) => Float(Zero { sign: !*sign }),\n            Float(Finite {\n                sign,\n                exponent,\n                precision,\n                significand,\n            }) => Float(Finite {\n                sign: !*sign,\n                exponent: *exponent,\n                precision: *precision,\n                significand: significand.clone(),\n            }),\n        }\n    }\n}\n\nimpl NegAssign for Float {\n    /// Negates a [`Float`] in place.\n    ///\n    /// $$\n    /// x \\gets -x.\n    /// $$\n    ///\n    /// Special cases:\n    /// - $\\text{NaN} \\gets \\text{NaN}$\n    /// - $\\infty \\gets -\\infty$\n    /// - $-\\infty \\gets \\infty$\n    /// - $0.0 \\gets -0.0$\n    /// - $-0.0 \\gets 0.0$\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NegAssign;\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// let mut x = Float::NAN;\n    /// x.neg_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::NAN));\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.neg_assign();\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.neg_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::ZERO;\n    /// x.neg_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::NEGATIVE_ZERO));\n    ///\n    /// let mut x = Float::NEGATIVE_ZERO;\n    /// x.neg_assign();\n    /// assert_eq!(ComparableFloat(x), ComparableFloat(Float::ZERO));\n    ///\n    /// let mut x = Float::ONE;\n    /// x.neg_assign();\n    /// assert_eq!(x, Float::NEGATIVE_ONE);\n    ///\n    /// let mut x = Float::NEGATIVE_ONE;\n    /// x.neg_assign();\n    /// assert_eq!(x, Float::ONE);\n    /// ```\n    fn neg_assign(&mut self) {\n        if let Self(Infinity { sign } | Zero { sign } | Finite { sign, .. }) = self {\n            sign.not_assign();\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{PowerOf2, RoundToMultipleOfPowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, Zero};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Raises 2 to an integer power, returning a [`Float`] with the specified precision and with\n    /// the specified rounding mode. An [`Ordering`] is also returned, indicating whether the\n    /// returned power is less than, equal to, or greater than the exact power. The ordering is\n    /// usually `Equal`, but is `Less` or `Greater` if overflow or underflow occurs.\n    ///\n    /// $f(k) = 2^k$, and the result has precision `prec`.\n    ///\n    /// - If `pow` is greater than $2^{30}-2$ and `rm` is `Floor` or `Down`, the largest\n    ///   representable `Float` with the given precision is returned.\n    /// - If `pow` is greater than $2^{30}-2$ and `rm` is `Ceiling` or `Up`, or `Nearest`, $\\infty$\n    ///   is returned.\n    /// - If `pow` is less than $-2^{30}$ and `rm` is `Floor`, `Down`, or `Nearest`, positive zero\n    ///   is returned.\n    /// - If `pow` is less than $-2^{30}$ and `rm` is `Ceiling` or `Up`, the smallest positive\n    ///   `Float` is returned.\n    ///\n    /// If you want the behavior of `Nearest` (that is, returning $\\infty$ on overflow and positive\n    /// zero on underflow), you can use `Float::power_of_2_prec` instead.\n    ///\n    /// If you need a [`Float`] with precision 1, then the [`PowerOf2`] implementation may be used\n    /// instead.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and `pow` is greater than $2^{30}-2$ or less\n    /// than $-2^{30}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(0, 1, Nearest);\n    /// assert_eq!(p.to_string(), \"1.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(0, 100, Nearest);\n    /// assert_eq!(p.to_string(), \"1.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(100, 1, Nearest);\n    /// assert_eq!(p.to_string(), \"1.0e30\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(100, 100, Nearest);\n    /// assert_eq!(p.to_string(), \"1267650600228229401496703205376.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(-100, 1, Nearest);\n    /// assert_eq!(p.to_string(), \"8.0e-31\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(-100, 100, Nearest);\n    /// assert_eq!(p.to_string(), \"7.88860905221011805411728565283e-31\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(i64::power_of_2(30) - 1, 10, Floor);\n    /// assert_eq!(p.to_string(), \"too_big\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(i64::power_of_2(30) - 1, 10, Ceiling);\n    /// assert_eq!(p.to_string(), \"Infinity\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(-i64::power_of_2(30) - 1, 10, Floor);\n    /// assert_eq!(p.to_string(), \"0.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (p, o) = Float::power_of_2_prec_round(-i64::power_of_2(30) - 1, 10, Ceiling);\n    /// assert_eq!(p.to_string(), \"too_small\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn power_of_2_prec_round(pow: i64, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if let Ok(exponent) = i32::try_from(pow)\n            && let Some(exponent) = exponent.checked_add(1)\n            && (Self::MIN_EXPONENT..=Self::MAX_EXPONENT).contains(&exponent)\n        {\n            return (\n                Self(Finite {\n                    sign: true,\n                    exponent,\n                    precision: prec,\n                    significand: Natural::power_of_2(\n                        prec.round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                            .0\n                            - 1,\n                    ),\n                }),\n                Equal,\n            );\n        }\n        match (pow > 0, rm) {\n            (_, Exact) => panic!(\"Inexact power_of_2\"),\n            (true, Ceiling | Up | Nearest) => (Self::INFINITY, Greater),\n            (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n            (false, Floor | Down | Nearest) => (Self::ZERO, Less),\n            (false, Ceiling | Up) => (Self::min_positive_value_prec(prec), Greater),\n        }\n    }\n\n    /// Raises 2 to an integer power, returning a [`Float`] with the specified precision. An\n    /// [`Ordering`] is also returned, indicating whether the returned power is less than, equal to,\n    /// or greater than the exact power. The ordering is usually `Equal`, but is `Greater` in the\n    /// case of overflow and `Less` in the case of underflow.\n    ///\n    /// $f(k) = 2^k$, and the result has precision `prec`.\n    ///\n    /// If `pow` is greater than $2^{30}-2$, $\\infty$ is returned. If `pow` is less than $-2^{30}$,\n    /// positive zero is returned. If you want different overflow and underflow behavior, try using\n    /// `Float::power_of_2_prec_round` instead.\n    ///\n    /// If you need a [`Float`] with precision 1, then the [`PowerOf2`] implementation may be used\n    /// instead.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (p, o) = Float::power_of_2_prec(0, 1);\n    /// assert_eq!(p.to_string(), \"1.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec(0, 100);\n    /// assert_eq!(p.to_string(), \"1.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec(100, 1);\n    /// assert_eq!(p.to_string(), \"1.0e30\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec(100, 100);\n    /// assert_eq!(p.to_string(), \"1267650600228229401496703205376.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec(-100, 1);\n    /// assert_eq!(p.to_string(), \"8.0e-31\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec(-100, 100);\n    /// assert_eq!(p.to_string(), \"7.88860905221011805411728565283e-31\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (p, o) = Float::power_of_2_prec(i64::power_of_2(30) - 1, 10);\n    /// assert_eq!(p.to_string(), \"Infinity\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (p, o) = Float::power_of_2_prec(-i64::power_of_2(30) - 1, 10);\n    /// assert_eq!(p.to_string(), \"0.0\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn power_of_2_prec(pow: i64, prec: u64) -> (Self, Ordering) {\n        Self::power_of_2_prec_round(pow, prec, Nearest)\n    }\n}\n\nimpl PowerOf2<u64> for Float {\n    /// Raises 2 to an integer power, returning a [`Float`] with precision 1.\n    ///\n    /// To get a [`Float`] with a higher precision, try [`Float::power_of_2_prec`].\n    ///\n    /// $f(k) = 2^k$.\n    ///\n    /// If `pow` is greater than $2^{30}-2$, $\\infty$ is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::power_of_2(0u64).to_string(), \"1.0\");\n    /// assert_eq!(Float::power_of_2(3u64).to_string(), \"8.0\");\n    /// assert_eq!(Float::power_of_2(100u64).to_string(), \"1.0e30\");\n    /// assert_eq!(\n    ///     Float::power_of_2(u64::power_of_2(30) - 1).to_string(),\n    ///     \"Infinity\"\n    /// );\n    /// ```\n    fn power_of_2(pow: u64) -> Self {\n        if let Ok(exponent) = i32::try_from(pow)\n            && let Some(exponent) = exponent.checked_add(1)\n            && exponent <= Self::MAX_EXPONENT\n        {\n            return Self(Finite {\n                sign: true,\n                exponent,\n                precision: 1,\n                significand: Natural::HIGH_BIT,\n            });\n        }\n        Self::INFINITY\n    }\n}\n\nimpl PowerOf2<i64> for Float {\n    /// Raises 2 to an integer power, returning a [`Float`] with precision 1.\n    ///\n    /// To get a [`Float`] with a higher precision, try [`Float::power_of_2_prec`].\n    ///\n    /// $f(k) = 2^k$.\n    ///\n    /// If `pow` is greater than $2^{30}-2$, $\\infty$ is returned. If `pow` is less than $-2^{30}$,\n    /// positive zero is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::power_of_2(0i64).to_string(), \"1.0\");\n    /// assert_eq!(Float::power_of_2(3i64).to_string(), \"8.0\");\n    /// assert_eq!(Float::power_of_2(100i64).to_string(), \"1.0e30\");\n    /// assert_eq!(Float::power_of_2(-3i64).to_string(), \"0.1\");\n    /// assert_eq!(Float::power_of_2(-100i64).to_string(), \"8.0e-31\");\n    /// assert_eq!(\n    ///     Float::power_of_2(i64::power_of_2(30) - 1).to_string(),\n    ///     \"Infinity\"\n    /// );\n    /// assert_eq!(\n    ///     Float::power_of_2(-i64::power_of_2(30) - 1).to_string(),\n    ///     \"0.0\"\n    /// );\n    /// ```\n    #[inline]\n    fn power_of_2(pow: i64) -> Self {\n        if let Ok(exponent) = i32::try_from(pow)\n            && let Some(exponent) = exponent.checked_add(1)\n            && (Self::MIN_EXPONENT..=Self::MAX_EXPONENT).contains(&exponent)\n        {\n            return Self(Finite {\n                sign: true,\n                exponent,\n                precision: 1,\n                significand: Natural::HIGH_BIT,\n            });\n        }\n        if pow > 0 { Self::INFINITY } else { Self::ZERO }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{Float, float_infinity, float_nan, float_negative_infinity};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    IsPowerOf2, NegAssign, Reciprocal, ReciprocalAssign,\n};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_reciprocal::reciprocal_float_significand_ref;\n\nimpl Float {\n    /// Takes the reciprocal of a [`Float`], rounding the result to the specified precision and with\n    /// the specified rounding mode. The [`Float`] is taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded reciprocal is less than, equal to, or greater than\n    /// the exact reciprocal. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p+1}$.\n    /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=0.0$\n    /// - $f(-\\infty,p,m)=-0.0$\n    /// - $f(0.0,p,m)=\\infty$\n    /// - $f(-0.0,p,m)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::reciprocal_prec`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::reciprocal_round`] instead. If both of these things are true, consider using\n    /// [`Float::reciprocal`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact reciprocation.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round(5, Floor);\n    /// assert_eq!(reciprocal.to_string(), \"0.31\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round(5, Ceiling);\n    /// assert_eq!(reciprocal.to_string(), \"0.33\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round(5, Nearest);\n    /// assert_eq!(reciprocal.to_string(), \"0.31\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round(20, Floor);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round(20, Ceiling);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183103\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round(20, Nearest);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn reciprocal_prec_round(mut self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.reciprocal_prec_round_assign(prec, rm);\n        (self, o)\n    }\n\n    /// Takes the reciprocal of a [`Float`], rounding the result to the specified precision and with\n    /// the specified rounding mode. The [`Float`] is taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded reciprocal is less than, equal to, or greater than\n    /// the exact reciprocal. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p+1}$.\n    /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=0.0$\n    /// - $f(-\\infty,p,m)=-0.0$\n    /// - $f(0.0,p,m)=\\infty$\n    /// - $f(-0.0,p,m)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::reciprocal_prec_ref`]\n    /// instead. If you know that your target precision is the precision of the input, consider\n    /// using [`Float::reciprocal_round_ref`] instead. If both of these things are true, consider\n    /// using `(&Float)::reciprocal()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact reciprocation.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round_ref(5, Floor);\n    /// assert_eq!(reciprocal.to_string(), \"0.31\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round_ref(5, Ceiling);\n    /// assert_eq!(reciprocal.to_string(), \"0.33\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round_ref(5, Nearest);\n    /// assert_eq!(reciprocal.to_string(), \"0.31\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round_ref(20, Floor);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round_ref(20, Ceiling);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183103\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_round_ref(20, Nearest);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn reciprocal_prec_round_ref(&self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match self {\n            float_nan!() => (float_nan!(), Equal),\n            Self(Zero { sign }) => (Self(Infinity { sign: *sign }), Equal),\n            Self(Infinity { sign }) => (Self(Zero { sign: *sign }), Equal),\n            Self(Finite {\n                sign,\n                exponent: exp,\n                precision: x_prec,\n                significand: x,\n            }) => {\n                if x.is_power_of_2() {\n                    let (reciprocal, o) = Self::ONE.shl_prec_round(\n                        i64::from(1 - exp),\n                        prec,\n                        if *sign { rm } else { -rm },\n                    );\n                    return if *sign {\n                        (reciprocal, o)\n                    } else {\n                        (-reciprocal, o.reverse())\n                    };\n                }\n                let sign = *sign;\n                let (reciprocal, exp_offset, o) =\n                    reciprocal_float_significand_ref(x, *x_prec, prec, if sign { rm } else { -rm });\n                let exp = (1 - *exp).checked_add(i32::exact_from(exp_offset)).unwrap();\n                if exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float reciprocation\"),\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                }\n                (\n                    Self(Finite {\n                        sign,\n                        exponent: exp,\n                        precision: prec,\n                        significand: reciprocal,\n                    }),\n                    if sign { o } else { o.reverse() },\n                )\n            }\n        }\n    }\n\n    /// Takes the reciprocal of a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded reciprocal is less than, equal to, or greater than the exact\n    /// reciprocal. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the reciprocal is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\infty,p)=0.0$\n    /// - $f(-\\infty,p)=-0.0$\n    /// - $f(0.0,p)=\\infty$\n    /// - $f(-0.0,p)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_prec_round`] instead. If you know that your target precision is the\n    /// precision of the input, consider using [`Float::reciprocal`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec(5);\n    /// assert_eq!(reciprocal.to_string(), \"0.31\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec(20);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn reciprocal_prec(self, prec: u64) -> (Self, Ordering) {\n        self.reciprocal_prec_round(prec, Nearest)\n    }\n\n    /// Takes the reciprocal of a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded reciprocal is less than, equal to, or greater than the exact\n    /// reciprocal. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the reciprocal is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\infty,p)=0.0$\n    /// - $f(-\\infty,p)=-0.0$\n    /// - $f(0.0,p)=\\infty$\n    /// - $f(-0.0,p)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_prec_round_ref`] instead. If you know that your target precision is the\n    /// precision of the input, consider using `(&Float)::reciprocal()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_ref(5);\n    /// assert_eq!(reciprocal.to_string(), \"0.31\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_prec_ref(20);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn reciprocal_prec_ref(&self, prec: u64) -> (Self, Ordering) {\n        self.reciprocal_prec_round_ref(prec, Nearest)\n    }\n\n    /// Takes the reciprocal of a [`Float`], rounding the result with the specified rounding mode.\n    /// The [`Float`] is taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded reciprocal is less than, equal to, or greater than the exact reciprocal. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=0.0$\n    /// - $f(-\\infty,m)=-0.0$\n    /// - $f(0.0,m)=\\infty$\n    /// - $f(-0.0,m)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::reciprocal_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::reciprocal`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input is not high enough to represent the\n    /// output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_round(Floor);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098861837905\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_round(Ceiling);\n    /// assert_eq!(reciprocal.to_string(), \"0.318309886183791\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_round(Nearest);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098861837905\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn reciprocal_round(self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.reciprocal_prec_round(prec, rm)\n    }\n\n    /// Takes the reciprocal of a [`Float`], rounding the result with the specified rounding mode.\n    /// The [`Float`] is taken by reference. An [`Ordering`] is also returned, indicating whether\n    /// the rounded reciprocal is less than, equal to, or greater than the exact reciprocal.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=0.0$\n    /// - $f(-\\infty,m)=-0.0$\n    /// - $f(0.0,m)=\\infty$\n    /// - $f(-0.0,m)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::reciprocal_prec_round_ref`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `(&Float)::reciprocal()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input is not high enough to represent the\n    /// output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_round_ref(Floor);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098861837905\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_round_ref(Ceiling);\n    /// assert_eq!(reciprocal.to_string(), \"0.318309886183791\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal, o) = Float::from(PI).reciprocal_round_ref(Nearest);\n    /// assert_eq!(reciprocal.to_string(), \"0.3183098861837905\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn reciprocal_round_ref(&self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.reciprocal_prec_round_ref(prec, rm)\n    }\n\n    /// Takes the reciprocal of a [`Float`] in place, rounding the result to the specified precision\n    /// and with the specified rounding mode. An [`Ordering`] is returned, indicating whether the\n    /// rounded reciprocal is less than, equal to, or greater than the exact reciprocal. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function sets the [`Float`] to\n    /// `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::reciprocal_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::reciprocal_prec_assign`]\n    /// instead. If you know that your target precision is the precision of the input, consider\n    /// using [`Float::reciprocal_round_assign`] instead. If both of these things are true, consider\n    /// using [`Float::reciprocal_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact reciprocation;\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_round_assign(5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.31\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_round_assign(5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.33\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_round_assign(5, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"0.31\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_round_assign(20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.3183098\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_round_assign(20, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.3183103\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_round_assign(20, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"0.3183098\");\n    /// ```\n    #[inline]\n    pub fn reciprocal_prec_round_assign(&mut self, prec: u64, rm: RoundingMode) -> Ordering {\n        assert_ne!(prec, 0);\n        match &mut *self {\n            float_nan!() => Equal,\n            Self(Zero { sign }) => {\n                *self = Self(Infinity { sign: *sign });\n                Equal\n            }\n            Self(Infinity { sign }) => {\n                *self = Self(Zero { sign: *sign });\n                Equal\n            }\n            Self(Finite {\n                sign,\n                exponent: exp,\n                precision: x_prec,\n                significand: x,\n            }) => {\n                if x.is_power_of_2() {\n                    let sign = *sign;\n                    let o;\n                    (*self, o) = Self::ONE.shl_prec_round(\n                        i64::from(1 - *exp),\n                        prec,\n                        if sign { rm } else { -rm },\n                    );\n                    return if sign {\n                        o\n                    } else {\n                        self.neg_assign();\n                        o.reverse()\n                    };\n                }\n                let sign = *sign;\n                let (reciprocal, exp_offset, o) =\n                    reciprocal_float_significand_ref(x, *x_prec, prec, if sign { rm } else { -rm });\n                *exp = (1 - *exp).checked_add(i32::exact_from(exp_offset)).unwrap();\n                if *exp > Self::MAX_EXPONENT {\n                    return match (sign, rm) {\n                        (_, Exact) => panic!(\"Inexact Float reciprocation\"),\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                }\n                *x_prec = prec;\n                *x = reciprocal;\n                if sign { o } else { o.reverse() }\n            }\n        }\n    }\n\n    /// Takes the reciprocal of a [`Float`] in place, rounding the result to the nearest value of\n    /// the specified precision. An [`Ordering`] is returned, indicating whether the rounded\n    /// reciprocal is less than, equal to, or greater than the exact reciprocal. Although `NaN`s are\n    /// not comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// If the reciprocal is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::reciprocal_prec`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_prec_round_assign`] instead. If you know that your target precision is\n    /// the precision of the input, consider using [`Float::reciprocal`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_assign(5), Less);\n    /// assert_eq!(x.to_string(), \"0.31\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_prec_assign(20), Less);\n    /// assert_eq!(x.to_string(), \"0.3183098\");\n    /// ```\n    #[inline]\n    pub fn reciprocal_prec_assign(&mut self, prec: u64) -> Ordering {\n        self.reciprocal_prec_round_assign(prec, Nearest)\n    }\n\n    /// Takes the reciprocal of a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. An [`Ordering`] is returned, indicating whether the rounded reciprocal is\n    /// less than, equal to, or greater than the exact reciprocal. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $1/x$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// See the [`Float::reciprocal_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::reciprocal_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using [`Float::reciprocal_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input is not high enough to represent the\n    /// output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_round_assign(Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.3183098861837905\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_round_assign(Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.318309886183791\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_round_assign(Nearest), Less);\n    /// assert_eq!(x.to_string(), \"0.3183098861837905\");\n    /// ```\n    #[inline]\n    pub fn reciprocal_round_assign(&mut self, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.reciprocal_prec_round_assign(prec, rm)\n    }\n}\n\nimpl Reciprocal for Float {\n    type Output = Self;\n\n    /// Takes the reciprocal of a [`Float`], taking it by value.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the reciprocal is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=0.0$\n    /// - $f(-\\infty)=-0.0$\n    /// - $f(0.0)=\\infty$\n    /// - $f(-0.0)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_prec`] instead. If you want to specify the output precision, consider\n    /// using [`Float::reciprocal_round`]. If you want both of these things, consider using\n    /// [`Float::reciprocal_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Reciprocal;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!(Float::NAN.reciprocal().is_nan());\n    /// assert_eq!(Float::INFINITY.reciprocal().to_string(), \"0.0\");\n    /// assert_eq!(Float::NEGATIVE_INFINITY.reciprocal().to_string(), \"-0.0\");\n    /// assert_eq!(Float::from(1.5).reciprocal().to_string(), \"0.8\");\n    /// assert_eq!(Float::from(-1.5).reciprocal().to_string(), \"-0.8\");\n    /// ```\n    #[inline]\n    fn reciprocal(self) -> Self {\n        let prec = self.significant_bits();\n        self.reciprocal_prec_round(prec, Nearest).0\n    }\n}\n\nimpl Reciprocal for &Float {\n    type Output = Float;\n\n    /// Takes the reciprocal of a [`Float`], taking it by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the reciprocal is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=0.0$\n    /// - $f(-\\infty)=-0.0$\n    /// - $f(0.0)=\\infty$\n    /// - $f(-0.0)=-\\infty$\n    ///\n    /// Overflow:\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    ///\n    /// This function cannot underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_prec_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::reciprocal_round_ref`]. If you want both of these things, consider\n    /// using [`Float::reciprocal_prec_round_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Reciprocal;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::NAN).reciprocal().is_nan());\n    /// assert_eq!((&Float::INFINITY).reciprocal().to_string(), \"0.0\");\n    /// assert_eq!((&Float::NEGATIVE_INFINITY).reciprocal().to_string(), \"-0.0\");\n    /// assert_eq!((&Float::from(1.5)).reciprocal().to_string(), \"0.8\");\n    /// assert_eq!((&Float::from(-1.5)).reciprocal().to_string(), \"-0.8\");\n    /// ```\n    #[inline]\n    fn reciprocal(self) -> Float {\n        let prec = self.significant_bits();\n        self.reciprocal_prec_round_ref(prec, Nearest).0\n    }\n}\n\nimpl ReciprocalAssign for Float {\n    /// Takes the reciprocal of a [`Float`] in place.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the reciprocal is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = 1/x+\\varepsilon.\n    /// $$\n    /// - If $1/x$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $1/x$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |1/x|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the [`Float::reciprocal`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_prec_assign`] instead. If you want to specify the output precision,\n    /// consider using [`Float::reciprocal_round_assign`]. If you want both of these things,\n    /// consider using [`Float::reciprocal_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ReciprocalAssign;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::NAN;\n    /// x.reciprocal_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.reciprocal_assign();\n    /// assert_eq!(x.to_string(), \"0.0\");\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.reciprocal_assign();\n    /// assert_eq!(x.to_string(), \"-0.0\");\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x.reciprocal_assign();\n    /// assert_eq!(x.to_string(), \"0.8\");\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x.reciprocal_assign();\n    /// assert_eq!(x.to_string(), \"-0.8\");\n    /// ```\n    #[inline]\n    fn reciprocal_assign(&mut self) {\n        let prec = self.significant_bits();\n        self.reciprocal_prec_round_assign(prec, Nearest);\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/reciprocal_sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 2008-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::arithmetic::sqrt::generic_sqrt_rational;\nuse crate::conversion::from_natural::{\n    from_natural_prec_round_zero_exponent_ref, from_natural_zero_exponent,\n    from_natural_zero_exponent_ref,\n};\nuse crate::conversion::from_rational::FROM_RATIONAL_THRESHOLD;\nuse crate::{\n    Float, emulate_float_to_float_fn, emulate_rational_to_float_fn, float_either_zero,\n    float_infinity, float_nan, float_zero, significand_bits,\n};\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, CheckedSqrt, FloorLogBase2, IsPowerOf2, NegAssign, NegModPowerOf2, Parity,\n    PowerOf2, Reciprocal, ReciprocalAssign, ReciprocalSqrt, ReciprocalSqrtAssign,\n    RoundToMultipleOfPowerOf2, Sqrt, UnsignedAbs,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity as InfinityTrait, NaN as NaNTrait, NegativeInfinity, NegativeZero, Zero as ZeroTrait,\n};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::LIMB_HIGH_BIT;\nuse malachite_nz::natural::arithmetic::float_extras::{\n    float_can_round, limbs_float_can_round, limbs_significand_slice_add_limb_in_place,\n};\nuse malachite_nz::natural::arithmetic::float_reciprocal_sqrt::limbs_reciprocal_sqrt;\nuse malachite_nz::natural::{Natural, bit_to_limb_count_ceiling, limb_to_bit_count};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\nfn from_reciprocal_rational_prec_round_ref_direct(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    let sign = *x >= 0;\n    if let Some(pow) = x.numerator_ref().checked_log_base_2() {\n        let n = x.denominator_ref();\n        let n_bits = n.significant_bits();\n        let (mut y, mut o) =\n            from_natural_prec_round_zero_exponent_ref(n, prec, if sign { rm } else { -rm });\n        o = y.shr_prec_round_assign_helper(\n            i128::from(pow) - i128::from(n_bits),\n            prec,\n            if sign { rm } else { -rm },\n            o,\n        );\n        assert!(\n            rm != Exact || o == Equal,\n            \"Inexact conversion from Rational to Float\"\n        );\n        if sign { (y, o) } else { (-y, o.reverse()) }\n    } else {\n        let x = x.reciprocal();\n        let mut exponent = i32::saturating_from(x.floor_log_base_2_abs());\n        if exponent >= Float::MAX_EXPONENT {\n            return match (sign, rm) {\n                (true, Up | Ceiling | Nearest) => (Float::INFINITY, Greater),\n                (true, Floor | Down) => (Float::max_finite_value_with_prec(prec), Less),\n                (false, Up | Floor | Nearest) => (Float::NEGATIVE_INFINITY, Less),\n                (false, Ceiling | Down) => (-Float::max_finite_value_with_prec(prec), Greater),\n                (_, Exact) => panic!(\"Inexact conversion from Rational to Float\"),\n            };\n        }\n        let (significand, o) =\n            Integer::rounding_from(x << (i128::exact_from(prec) - i128::from(exponent) - 1), rm);\n        let sign = significand >= 0;\n        let mut significand = significand.unsigned_abs();\n        let away_from_0 = if sign { Greater } else { Less };\n        if o == away_from_0 && significand.is_power_of_2() {\n            exponent += 1;\n            if exponent >= Float::MAX_EXPONENT {\n                return if sign {\n                    (Float::INFINITY, Greater)\n                } else {\n                    (Float::NEGATIVE_INFINITY, Less)\n                };\n            }\n        }\n        exponent += 1;\n        if exponent < Float::MIN_EXPONENT {\n            assert!(rm != Exact, \"Inexact conversion from Rational to Float\");\n            return if rm == Nearest\n                && exponent == Float::MIN_EXPONENT - 1\n                && (o == away_from_0.reverse() || !significand.is_power_of_2())\n            {\n                if sign {\n                    (Float::min_positive_value_prec(prec), Greater)\n                } else {\n                    (-Float::min_positive_value_prec(prec), Less)\n                }\n            } else {\n                match (sign, rm) {\n                    (true, Up | Ceiling) => (Float::min_positive_value_prec(prec), Greater),\n                    (true, Floor | Down | Nearest) => (Float::ZERO, Less),\n                    (false, Up | Floor) => (-Float::min_positive_value_prec(prec), Less),\n                    (false, Ceiling | Down | Nearest) => (Float::NEGATIVE_ZERO, Greater),\n                    (_, Exact) => unreachable!(),\n                }\n            };\n        }\n        significand <<= significand\n            .significant_bits()\n            .neg_mod_power_of_2(Limb::LOG_WIDTH);\n        let target_bits = prec\n            .round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n            .0;\n        let current_bits = significand_bits(&significand);\n        if current_bits > target_bits {\n            significand >>= current_bits - target_bits;\n        }\n        (\n            Float(Finite {\n                sign,\n                exponent,\n                precision: prec,\n                significand,\n            }),\n            o,\n        )\n    }\n}\n\nfn from_reciprocal_rational_prec_round_ref_using_div(\n    x: &Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    let sign = *x >= 0;\n    if !sign {\n        rm.neg_assign();\n    }\n    let (d, n) = x.numerator_and_denominator_ref();\n    let is_zero = *n == 0;\n    let (f, o) = match (\n        if is_zero {\n            None\n        } else {\n            n.checked_log_base_2()\n        },\n        d.checked_log_base_2(),\n    ) {\n        (Some(log_n), Some(log_d)) => Float::power_of_2_prec_round(\n            i64::saturating_from(i128::from(log_n) - i128::from(log_d)),\n            prec,\n            rm,\n        ),\n        (None, Some(log_d)) => {\n            let (mut f, mut o) = from_natural_prec_round_zero_exponent_ref(n, prec, rm);\n            o = f.shr_prec_round_assign_helper(\n                i128::from(log_d) - i128::from(n.significant_bits()),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n        (Some(log_n), None) => {\n            let (mut f, mut o) = from_natural_zero_exponent_ref(d).reciprocal_prec_round(prec, rm);\n            o = f.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(d.significant_bits()),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n        (None, None) => {\n            let (mut f, mut o) = from_natural_zero_exponent_ref(n).div_prec_round(\n                from_natural_zero_exponent_ref(d),\n                prec,\n                rm,\n            );\n            o = f.shl_prec_round_assign_helper(\n                i128::from(n.significant_bits()) - i128::from(d.significant_bits()),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n    };\n    if sign { (f, o) } else { (-f, o.reverse()) }\n}\n\npub_crate_test! {\n#[inline]\nfrom_reciprocal_rational_prec_round_ref(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if max(x.significant_bits(), prec) < FROM_RATIONAL_THRESHOLD {\n        from_reciprocal_rational_prec_round_ref_direct(x, prec, rm)\n    } else {\n        from_reciprocal_rational_prec_round_ref_using_div(x, prec, rm)\n    }\n}}\n\npub_crate_test! {\ngeneric_reciprocal_sqrt_rational_ref(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode\n) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    let mut end_shift = x.floor_log_base_2();\n    let x2;\n    let reduced_x: &Rational;\n    if end_shift.gt_abs(&0x3fff_0000) {\n        end_shift &= !1;\n        x2 = x >> end_shift;\n        reduced_x = &x2;\n    } else {\n        end_shift = 0;\n        reduced_x = x;\n    }\n    loop {\n        let sqrt = from_reciprocal_rational_prec_round_ref(reduced_x, working_prec, Floor).0.sqrt();\n        // See algorithms.tex. Since we rounded down when computing fx, the absolute error of the\n        // square root is bounded by (c_sqrt + k_fx)ulp(sqrt) <= 2ulp(sqrt).\n        //\n        // Experiments suggest that `working_prec` is low enough (that is, that the error is at most\n        // 1 ulp), but I can only prove `working_prec - 1`.\n        if float_can_round(sqrt.significand_ref().unwrap(), working_prec - 1, prec, rm) {\n            let (mut sqrt, mut o) = Float::from_float_prec_round(sqrt, prec, rm);\n            if end_shift != 0 {\n                o = sqrt.shr_prec_round_assign_helper(end_shift >> 1, prec, rm, o);\n            }\n            return (sqrt, o);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}}\n\nimpl Float {\n    /// Computes the reciprocal of the square root of a [`Float`], rounding the result to the\n    /// specified precision and with the specified rounding mode. The [`Float`] is taken by value.\n    /// An [`Ordering`] is also returned, indicating whether the rounded reciprocal square root is\n    /// less than, equal to, or greater than the exact square root. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p+1}$.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=0.0$\n    /// - $f(-\\infty,p,m)=\\text{NaN}$\n    /// - $f(0.0,p,m)=\\infty$\n    /// - $f(-0.0,p,m)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::reciprocal_sqrt_prec`]\n    /// instead. If you know that your target precision is the precision of the input, consider\n    /// using [`Float::reciprocal_sqrt_round`] instead. If both of these things are true, consider\n    /// using [`Float::reciprocal_sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round(5, Floor);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round(5, Ceiling);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.59\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round(5, Nearest);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round(20, Floor);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round(20, Ceiling);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56419\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round(20, Nearest);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56419\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_prec_round(self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        self.reciprocal_sqrt_prec_round_ref(prec, rm)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`], rounding the result to the\n    /// specified precision and with the specified rounding mode. The [`Float`] is taken by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded reciprocal\n    /// square root is less than, equal to, or greater than the exact square root. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p+1}$.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=0.0$\n    /// - $f(-\\infty,p,m)=\\text{NaN}$\n    /// - $f(0.0,p,m)=\\infty$\n    /// - $f(-0.0,p,m)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::reciprocal_sqrt_prec_ref`]\n    /// instead. If you know that your target precision is the precision of the input, consider\n    /// using [`Float::reciprocal_sqrt_round_ref`] instead. If both of these things are true,\n    /// consider using `(&Float).reciprocal_sqrt()`instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round_ref(5, Floor);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round_ref(5, Ceiling);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.59\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round_ref(5, Nearest);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round_ref(20, Floor);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round_ref(20, Ceiling);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56419\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_round_ref(20, Nearest);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56419\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    ///\n    /// This is mpfr_rec_sqrt from rec_sqrt.c, MPFR 4.3.0.\n    #[inline]\n    pub fn reciprocal_sqrt_prec_round_ref(&self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match self {\n            Self(NaN | Infinity { sign: false }) => (float_nan!(), Equal),\n            float_infinity!() => (float_zero!(), Equal),\n            float_either_zero!() => (float_infinity!(), Equal),\n            Self(Finite {\n                sign,\n                exponent: x_exp,\n                precision: x_prec,\n                significand: x,\n                ..\n            }) => {\n                if !sign {\n                    return (float_nan!(), Equal);\n                }\n                // Let u = U*2^e, where e = EXP(u), and 1/2 <= U < 1. If e is even, we compute an\n                // approximation of X of (4U)^{-1/2}, and the result is X*2^(-(e-2)/2) [case s=1].\n                // If e is odd, we compute an approximation of X of (2U)^{-1/2}, and the result is\n                // X*2^(-(e-1)/2) [case s=0].\n                //\n                // parity of the exponent of u\n                let mut s = i32::from(x_exp.even());\n                let in_len = bit_to_limb_count_ceiling(prec);\n                // for the first iteration, if rp + 11 fits into rn limbs, we round up up to a full\n                // limb to maximize the chance of rounding, while avoiding to allocate extra space\n                let mut working_prec = max(prec + 11, limb_to_bit_count(in_len));\n                let mut increment = Limb::WIDTH;\n                let mut out;\n                loop {\n                    let working_limbs = bit_to_limb_count_ceiling(working_prec);\n                    out = alloc::vec![0; working_limbs];\n                    limbs_reciprocal_sqrt(\n                        &mut out,\n                        working_prec,\n                        x.as_limbs_asc(),\n                        *x_prec,\n                        s == 1,\n                    );\n                    // If the input was not truncated, the error is at most one ulp; if the input\n                    // was truncated, the error is at most two ulps (see algorithms.tex).\n                    if limbs_float_can_round(\n                        &out,\n                        working_prec - u64::from(working_prec < *x_prec),\n                        prec,\n                        rm,\n                    ) {\n                        assert_ne!(rm, Exact, \"Inexact float reciprocal square root\");\n                        break;\n                    }\n                    // We detect only now the exact case where u = 2 ^ (2e), to avoid slowing down\n                    // the average case. This can happen only when the mantissa is exactly 1 / 2 and\n                    // the exponent is odd.\n                    if s == 0 && x.is_power_of_2() {\n                        let pl = limb_to_bit_count(working_limbs) - working_prec;\n                        // we should have x=111...111\n                        limbs_significand_slice_add_limb_in_place(&mut out, Limb::power_of_2(pl));\n                        *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n                        s = 2;\n                        break;\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n                let reciprocal_sqrt = Self(Finite {\n                    sign: true,\n                    exponent: (s + 1 - x_exp) >> 1,\n                    precision: working_prec,\n                    significand: Natural::from_owned_limbs_asc(out),\n                });\n                Self::from_float_prec_round(reciprocal_sqrt, prec, rm)\n            }\n        }\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`], rounding the result to the\n    /// nearest value of the specified precision. The [`Float`] is taken by value. An [`Ordering`]\n    /// is also returned, indicating whether the rounded reciprocal square root is less than, equal\n    /// to, or greater than the exact square root. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// If the reciprocal square root is equidistant from two [`Float`]s with the specified\n    /// precision, the [`Float`] with fewer 1s in its binary expansion is chosen. See\n    /// [`RoundingMode`] for a description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\infty,p)=0.0$\n    /// - $f(-\\infty,p)=\\text{NaN}$\n    /// - $f(0.0,p)=\\infty$\n    /// - $f(-0.0,p)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_prec_round`] instead. If you know that your target precision is the\n    /// precision of the input, consider using [`Float::reciprocal_sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec(5);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec(20);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56419\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_prec(self, prec: u64) -> (Self, Ordering) {\n        self.reciprocal_sqrt_prec_round(prec, Nearest)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`], rounding the result to the\n    /// nearest value of the specified precision. The [`Float`] is taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded reciprocal square root is less\n    /// than, equal to, or greater than the exact square root. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// If the reciprocal square root is equidistant from two [`Float`]s with the specified\n    /// precision, the [`Float`] with fewer 1s in its binary expansion is chosen. See\n    /// [`RoundingMode`] for a description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\infty,p)=0.0$\n    /// - $f(-\\infty,p)=\\text{NaN}$\n    /// - $f(0.0,p)=\\infty$\n    /// - $f(-0.0,p)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_prec_round_ref`] instead. If you know that your target precision is\n    /// the precision of the input, consider using `(&Float).reciprocal_sqrt()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_ref(5);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_prec_ref(20);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.56419\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_prec_ref(&self, prec: u64) -> (Self, Ordering) {\n        self.reciprocal_sqrt_prec_round_ref(prec, Nearest)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`], rounding the result with the\n    /// specified rounding mode. The [`Float`] is taken by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded reciprocal square root is less than, equal to, or greater\n    /// than the exact square root. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=0.0$\n    /// - $f(-\\infty,m)=\\text{NaN}$\n    /// - $f(0.0,m)=\\infty$\n    /// - $f(-0.0,m)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::reciprocal_sqrt_prec_round`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using [`Float::reciprocal_sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_round(Floor);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189583547756\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_round(Ceiling);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189583547757\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_round(Nearest);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189583547757\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_round(self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.reciprocal_sqrt_prec_round(prec, rm)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`], rounding the result with the\n    /// specified rounding mode. The [`Float`] is taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded reciprocal square root is less than, equal to, or\n    /// greater than the exact square root. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=0.0$\n    /// - $f(-\\infty,m)=\\text{NaN}$\n    /// - $f(0.0,m)=\\infty$\n    /// - $f(-0.0,m)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::reciprocal_sqrt_prec_round_ref`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `(&Float).reciprocal_sqrt()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_round_ref(Floor);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189583547756\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_round_ref(Ceiling);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189583547757\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (reciprocal_sqrt, o) = Float::from(PI).reciprocal_sqrt_round_ref(Nearest);\n    /// assert_eq!(reciprocal_sqrt.to_string(), \"0.564189583547757\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_round_ref(&self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.reciprocal_sqrt_prec_round_ref(prec, rm)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`] in place, rounding the result to\n    /// the specified precision and with the specified rounding mode. An [`Ordering`] is returned,\n    /// indicating whether the rounded reciprocal square root is less than, equal to, or greater\n    /// than the exact square root. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::reciprocal_sqrt_prec_round`] documentation for information on special\n    /// cases, overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::reciprocal_sqrt_prec_assign`]\n    /// instead. If you know that your target precision is the precision of the input, consider\n    /// using [`Float::reciprocal_sqrt_round_assign`] instead. If both of these things are true,\n    /// consider using [`Float::reciprocal_sqrt_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_round_assign(5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.56\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_round_assign(5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.59\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_round_assign(5, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"0.56\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_round_assign(20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.564189\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_round_assign(20, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.56419\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_round_assign(20, Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"0.56419\");\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_prec_round_assign(&mut self, prec: u64, rm: RoundingMode) -> Ordering {\n        let (reciprocal_sqrt, o) = self.reciprocal_sqrt_prec_round_ref(prec, rm);\n        *self = reciprocal_sqrt;\n        o\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`] in place, rounding the result to\n    /// the nearest value of the specified precision. An [`Ordering`] is returned, indicating\n    /// whether the rounded square root is less than, equal to, or greater than the exact square\n    /// root. Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// If the reciprocal square root is equidistant from two [`Float`]s with the specified\n    /// precision, the [`Float`] with fewer 1s in its binary expansion is chosen. See\n    /// [`RoundingMode`] for a description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::reciprocal_sqrt_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_prec_round_assign`] instead. If you know that your target precision\n    /// is the precision of the input, consider using [`Float::reciprocal_sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_assign(5), Less);\n    /// assert_eq!(x.to_string(), \"0.56\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_prec_assign(20), Greater);\n    /// assert_eq!(x.to_string(), \"0.56419\");\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_prec_assign(&mut self, prec: u64) -> Ordering {\n        self.reciprocal_sqrt_prec_round_assign(prec, Nearest)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Float`] in place, rounding the result with\n    /// the specified rounding mode. An [`Ordering`] is returned, indicating whether the rounded\n    /// reciprocal square root is less than, equal to, or greater than the exact square root.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p+1}$, where $p$ is the maximum precision of the\n    ///   inputs.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// See the [`Float::reciprocal_sqrt_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::reciprocal_sqrt_prec_round_assign`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using [`Float::reciprocal_sqrt_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_round_assign(Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.564189583547756\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_round_assign(Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.564189583547757\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.reciprocal_sqrt_round_assign(Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"0.564189583547757\");\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_round_assign(&mut self, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.reciprocal_sqrt_prec_round_assign(prec, rm)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Rational`], rounding the result to the\n    /// specified precision and with the specified rounding mode and returning the result as a\n    /// [`Float`]. The [`Rational`] is taken by value. An [`Ordering`] is also returned, indicating\n    /// whether the rounded reciprocal square root is less than, equal to, or greater than the exact\n    /// reciprocal square root. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p+1}$.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p,m)=\\infty$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_rational_prec`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) =\n    ///     Float::reciprocal_sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 5, Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.25\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round(\n    ///     Rational::from_unsigneds(3u8, 5),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.3\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round(\n    ///     Rational::from_unsigneds(3u8, 5),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.3\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::reciprocal_sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 20, Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.290993\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round(\n    ///     Rational::from_unsigneds(3u8, 5),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.290995\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round(\n    ///     Rational::from_unsigneds(3u8, 5),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.290995\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn reciprocal_sqrt_rational_prec_round(\n        mut x: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if x == 0u32 {\n            return (Self::INFINITY, Equal);\n        } else if x < 0u32 {\n            return (Self::NAN, Equal);\n        }\n        x.reciprocal_assign();\n        if let Some(sqrt) = (&x).checked_sqrt() {\n            return Self::from_rational_prec_round(sqrt, prec, rm);\n        }\n        let (n, d) = x.numerator_and_denominator_ref();\n        match (n.checked_log_base_2(), d.checked_log_base_2()) {\n            (_, Some(log_d)) if log_d.even() => {\n                let n = x.into_numerator();\n                let n_exp = n.significant_bits();\n                let mut n = from_natural_zero_exponent(n);\n                if n_exp.odd() {\n                    n <<= 1u32;\n                }\n                let (mut sqrt, o) = Self::exact_from(n).sqrt_prec_round(prec, rm);\n                let o = sqrt.shr_prec_round_assign_helper(\n                    i128::from(log_d >> 1) - i128::from(n_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (sqrt, o)\n            }\n            (Some(log_n), _) if log_n.even() => {\n                let d = x.into_denominator();\n                let d_exp = d.significant_bits();\n                let mut d = from_natural_zero_exponent(d);\n                if d_exp.odd() {\n                    d <<= 1u32;\n                }\n                let (mut reciprocal_sqrt, o) =\n                    Self::exact_from(d).reciprocal_sqrt_prec_round(prec, rm);\n                let o = reciprocal_sqrt.shl_prec_round_assign_helper(\n                    i128::from(log_n >> 1) - i128::from(d_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (reciprocal_sqrt, o)\n            }\n            _ => generic_sqrt_rational(x, prec, rm),\n        }\n    }\n\n    /// Computes the reciprocal of the square root of a [`Rational`], rounding the result to the\n    /// specified precision and with the specified rounding mode and returning the result as a\n    /// [`Float`]. The [`Rational`] is taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded reciprocal square root is less than, equal to, or greater\n    /// than the exact reciprocal square root. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p+1}$.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p,m)=\\infty$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_rational_prec_ref`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(\n    ///     &Rational::from_unsigneds(3u8, 5),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.25\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(\n    ///     &Rational::from_unsigneds(3u8, 5),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.3\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(\n    ///     &Rational::from_unsigneds(3u8, 5),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.3\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(\n    ///     &Rational::from_unsigneds(3u8, 5),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.290993\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(\n    ///     &Rational::from_unsigneds(3u8, 5),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.290995\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(\n    ///     &Rational::from_unsigneds(3u8, 5),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sqrt.to_string(), \"1.290995\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn reciprocal_sqrt_rational_prec_round_ref(\n        x: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if *x == 0u32 {\n            return (Self::INFINITY, Equal);\n        } else if *x < 0u32 {\n            return (Self::NAN, Equal);\n        }\n        if let Some(sqrt) = x.checked_sqrt() {\n            return Self::from_rational_prec_round(sqrt.reciprocal(), prec, rm);\n        }\n        let (d, n) = x.numerator_and_denominator_ref();\n        match (n.checked_log_base_2(), d.checked_log_base_2()) {\n            (_, Some(log_d)) if log_d.even() => {\n                let n_exp = n.significant_bits();\n                let mut n = from_natural_zero_exponent_ref(n);\n                if n_exp.odd() {\n                    n <<= 1u32;\n                }\n                let (mut sqrt, o) = Self::exact_from(n).sqrt_prec_round(prec, rm);\n                let o = sqrt.shr_prec_round_assign_helper(\n                    i128::from(log_d >> 1) - i128::from(n_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (sqrt, o)\n            }\n            (Some(log_n), _) if log_n.even() => {\n                let d_exp = d.significant_bits();\n                let mut d = from_natural_zero_exponent_ref(d);\n                if d_exp.odd() {\n                    d <<= 1u32;\n                }\n                let (mut reciprocal_sqrt, o) =\n                    Self::exact_from(d).reciprocal_sqrt_prec_round(prec, rm);\n                let o = reciprocal_sqrt.shl_prec_round_assign_helper(\n                    i128::from(log_n >> 1) - i128::from(d_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (reciprocal_sqrt, o)\n            }\n            _ => generic_reciprocal_sqrt_rational_ref(x, prec, rm),\n        }\n    }\n\n    /// Computes the reciprocal of the square root of a [`Rational`], rounding the result to the\n    /// nearest value of the specified precision and returning the result as a [`Float`]. The\n    /// [`Rational`] is taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded reciprocal square root is less than, equal to, or greater than the exact reciprocal\n    /// square root. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// If the reciprocal square root is equidistant from two [`Float`]s with the specified\n    /// precision, the [`Float`] with fewer 1s in its binary expansion is chosen. See\n    /// [`RoundingMode`] for a description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p)=\\infty$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_rational_prec_round`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec(Rational::from_unsigneds(3u8, 5), 5);\n    /// assert_eq!(sqrt.to_string(), \"1.3\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::reciprocal_sqrt_rational_prec(Rational::from_unsigneds(3u8, 5), 20);\n    /// assert_eq!(sqrt.to_string(), \"1.290995\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_rational_prec(x: Rational, prec: u64) -> (Self, Ordering) {\n        Self::reciprocal_sqrt_rational_prec_round(x, prec, Nearest)\n    }\n\n    /// Computes the reciprocal of the square root of a [`Rational`], rounding the result to the\n    /// nearest value of the specified precision and returning the result as a [`Float`]. The\n    /// [`Rational`] is taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// rounded reciprocal square root is less than, equal to, or greater than the exact reciprocal\n    /// square root. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// If the reciprocal square root is equidistant from two [`Float`]s with the specified\n    /// precision, the [`Float`] with fewer 1s in its binary expansion is chosen. See\n    /// [`RoundingMode`] for a description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p)=\\infty$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_rational_prec_round_ref`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) =\n    ///     Float::reciprocal_sqrt_rational_prec_ref(&Rational::from_unsigneds(3u8, 5), 5);\n    /// assert_eq!(sqrt.to_string(), \"1.3\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::reciprocal_sqrt_rational_prec_ref(&Rational::from_unsigneds(3u8, 5), 20);\n    /// assert_eq!(sqrt.to_string(), \"1.290995\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn reciprocal_sqrt_rational_prec_ref(x: &Rational, prec: u64) -> (Self, Ordering) {\n        Self::reciprocal_sqrt_rational_prec_round_ref(x, prec, Nearest)\n    }\n}\n\nimpl ReciprocalSqrt for Float {\n    type Output = Self;\n\n    /// Computes the reciprocal of the square root of a [`Float`], taking it by value.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the reciprocal square\n    /// root is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// $$\n    /// f(x) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=0.0$\n    /// - $f(-\\infty)=\\text{NaN}$\n    /// - $f(0.0)=\\infty$\n    /// - $f(-0.0)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_prec`] instead. If you want to specify the output precision,\n    /// consider using [`Float::reciprocal_sqrt_round`]. If you want both of these things, consider\n    /// using [`Float::reciprocal_sqrt_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ReciprocalSqrt;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert!(Float::NAN.reciprocal_sqrt().is_nan());\n    /// assert_eq!(Float::INFINITY.reciprocal_sqrt(), Float::ZERO);\n    /// assert!(Float::NEGATIVE_INFINITY.reciprocal_sqrt().is_nan());\n    /// assert_eq!(Float::from(1.5).reciprocal_sqrt().to_string(), \"0.8\");\n    /// assert!(Float::from(-1.5).reciprocal_sqrt().is_nan());\n    /// ```\n    #[inline]\n    fn reciprocal_sqrt(self) -> Self {\n        let prec = self.significant_bits();\n        self.reciprocal_sqrt_prec_round(prec, Nearest).0\n    }\n}\n\nimpl ReciprocalSqrt for &Float {\n    type Output = Float;\n\n    /// Computes the reciprocal of the square root of a [`Float`], taking it by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the reciprocal square\n    /// root is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// $$\n    /// f(x) = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=0.0$\n    /// - $f(-\\infty)=\\text{NaN}$\n    /// - $f(0.0)=\\infty$\n    /// - $f(-0.0)=\\infty$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_prec_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::reciprocal_sqrt_round_ref`]. If you want both of these things,\n    /// consider using [`Float::reciprocal_sqrt_prec_round_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ReciprocalSqrt;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::NAN).reciprocal_sqrt().is_nan());\n    /// assert_eq!((&Float::INFINITY).reciprocal_sqrt(), Float::ZERO);\n    /// assert!((&Float::NEGATIVE_INFINITY).reciprocal_sqrt().is_nan());\n    /// assert_eq!((&Float::from(1.5)).reciprocal_sqrt().to_string(), \"0.8\");\n    /// assert!((&Float::from(-1.5)).reciprocal_sqrt().is_nan());\n    /// ```\n    #[inline]\n    fn reciprocal_sqrt(self) -> Float {\n        let prec = self.significant_bits();\n        self.reciprocal_sqrt_prec_round_ref(prec, Nearest).0\n    }\n}\n\nimpl ReciprocalSqrtAssign for Float {\n    /// Computes the reciprocal of the square root of a [`Float`] in place.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the reciprocal square\n    /// root is equidistant from two [`Float`]s with the specified precision, the [`Float`] with\n    /// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n    /// `Nearest` rounding mode.\n    ///\n    /// The reciprocal square root of any nonzero negative number is `NaN`.\n    ///\n    /// Using this function is more accurate than taking the square root and then the reciprocal, or\n    /// vice versa.\n    ///\n    /// $$\n    /// x\\gets = 1/\\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   1/\\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the [`Float::reciprocal_sqrt`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::reciprocal_sqrt_prec_assign`] instead. If you want to specify the output precision,\n    /// consider using [`Float::reciprocal_sqrt_round_assign`]. If you want both of these things,\n    /// consider using [`Float::reciprocal_sqrt_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ReciprocalSqrtAssign;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::NAN;\n    /// x.reciprocal_sqrt_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.reciprocal_sqrt_assign();\n    /// assert_eq!(x, Float::ZERO);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.reciprocal_sqrt_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x.reciprocal_sqrt_assign();\n    /// assert_eq!(x.to_string(), \"0.8\");\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x.reciprocal_sqrt_assign();\n    /// assert!(x.is_nan());\n    /// ```\n    #[inline]\n    fn reciprocal_sqrt_assign(&mut self) {\n        let prec = self.significant_bits();\n        self.reciprocal_sqrt_prec_round_assign(prec, Nearest);\n    }\n}\n\n/// Computes the reciprocal of the square root of a primitive float. Using this function is more\n/// accurate than using `powf(0.5)` or taking the square root and then the reciprocal, or vice\n/// versa.\n///\n/// If the reciprocal square root is equidistant from two primitive floats, the primitive float with\n/// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n/// `Nearest` rounding mode.\n///\n/// The reciprocal square root of any nonzero negative number is `NaN`.\n///\n/// $$\n/// f(x) = 1/\\sqrt{x}+\\varepsilon.\n/// $$\n/// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n/// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n///   1/\\sqrt{x}\\rfloor-p}$, where $p$ is precision of the output (typically 24 if `T` is a [`f32`]\n///   and 53 if `T` is a [`f64`], but less if the output is subnormal).\n///\n/// Special cases:\n/// - $f(\\text{NaN})=\\text{NaN}$\n/// - $f(\\infty)=0.0$\n/// - $f(-\\infty)=\\text{NaN}$\n/// - $f(0.0)=\\infty$\n/// - $f(-0.0)=\\infty$\n///\n/// Neither overflow nor underflow is possible.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::arithmetic::reciprocal_sqrt::primitive_float_reciprocal_sqrt;\n///\n/// assert!(primitive_float_reciprocal_sqrt(f32::NAN).is_nan());\n/// assert_eq!(\n///     NiceFloat(primitive_float_reciprocal_sqrt(f32::INFINITY)),\n///     NiceFloat(0.0)\n/// );\n/// assert!(primitive_float_reciprocal_sqrt(f32::NEGATIVE_INFINITY).is_nan());\n/// assert_eq!(\n///     NiceFloat(primitive_float_reciprocal_sqrt(3.0f32)),\n///     NiceFloat(0.57735026)\n/// );\n/// assert!(primitive_float_reciprocal_sqrt(-3.0f32).is_nan());\n/// ```\n#[inline]\n#[allow(clippy::type_repetition_in_bounds)]\npub fn primitive_float_reciprocal_sqrt<T: PrimitiveFloat>(x: T) -> T\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    emulate_float_to_float_fn(Float::reciprocal_sqrt_prec, x)\n}\n\n/// Computes the reciprocal of the square root of a [`Rational`], returning a primitive float\n/// result.\n///\n/// If the reciprocal square root is equidistant from two primitive floats, the primitive float with\n/// fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of the\n/// `Nearest` rounding mode.\n///\n/// The reciprocal square root of any negative number is `NaN`.\n///\n/// $$\n/// f(x) = 1/\\sqrt{x}+\\varepsilon.\n/// $$\n/// - If $1/\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n/// - If $1/\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n///   1/\\sqrt{x}\\rfloor-p}$, where $p$ is precision of the output (typically 24 if `T` is a [`f32`]\n///   and 53 if `T` is a [`f64`], but less if the output is subnormal).\n///\n/// Special cases:\n/// - $f(0)=\\infty$\n///\n/// Overflow:\n/// - If the absolute value of the result is too large to represent, $\\infty$ is returned instead.\n/// - If the absolute value of the result is too small to represent, 0.0 is returned instead.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::arithmetic::reciprocal_sqrt::primitive_float_reciprocal_sqrt_rational;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     NiceFloat(primitive_float_reciprocal_sqrt_rational::<f64>(\n///         &Rational::ZERO\n///     )),\n///     NiceFloat(f64::INFINITY)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_reciprocal_sqrt_rational::<f64>(\n///         &Rational::from_unsigneds(1u8, 3)\n///     )),\n///     NiceFloat(1.7320508075688772)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_reciprocal_sqrt_rational::<f64>(\n///         &Rational::from(10000)\n///     )),\n///     NiceFloat(0.01)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_reciprocal_sqrt_rational::<f64>(\n///         &Rational::from(-10000)\n///     )),\n///     NiceFloat(f64::NAN)\n/// );\n/// ```\n#[inline]\n#[allow(clippy::type_repetition_in_bounds)]\npub fn primitive_float_reciprocal_sqrt_rational<T: PrimitiveFloat>(x: &Rational) -> T\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    emulate_rational_to_float_fn(Float::reciprocal_sqrt_rational_prec_ref, x)\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::arithmetic::traits::{ShlRound, ShlRoundAssign};\nuse core::ops::{Shl, ShlAssign};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nmacro_rules! impl_shl {\n    ($t:ident) => {\n        impl Shl<$t> for Float {\n            type Output = Float;\n\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// - If $f(x,k)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n            /// - If $f(x,k)\\leq -2^{2^{30}-1}$, $-\\infty$ is returned instead.\n            /// - If $0<f(x,k)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k)<0$, $-0.0$ is returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n            ///\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Float {\n                self.shl_round(bits, Nearest).0\n            }\n        }\n\n        impl Shl<$t> for &Float {\n            type Output = Float;\n\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// - If $f(x,k)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n            /// - If $f(x,k)\\leq -2^{2^{30}-1}$, $-\\infty$ is returned instead.\n            /// - If $0<f(x,k)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k)<0$, $-0.0$ is returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n            ///\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Float {\n                self.shl_round(bits, Nearest).0\n            }\n        }\n\n        impl ShlAssign<$t> for Float {\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), in place. If the [`Float`]\n            /// has a precision, the precision is unchanged.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged.\n            ///\n            /// $$\n            /// x \\gets x2^k.\n            /// $$\n            ///\n            /// - If $f(x,k)\\geq 2^{2^{30}-1}$, $\\infty$ is assigned instead.\n            /// - If $f(x,k)\\leq -2^{2^{30}-1}$, $-\\infty$ is assigned instead.\n            /// - If $0<f(x,k)\\leq2^{-2^{30}-1}$, $0.0$ is assigned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k)<2^{-2^{30}}$, $2^{-2^{30}}$ is assigned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k)<0$, $-0.0$ is assigned instead.\n            /// - If $-2^{-2^{30}}<f(x,k)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is assigned instead.\n            ///\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl_assign).\n            #[inline]\n            fn shl_assign(&mut self, bits: $t) {\n                self.shl_round_assign(bits, Nearest);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_shl);\n"
  },
  {
    "path": "malachite-float/src/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse crate::malachite_base::num::logic::traits::SignificantBits;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, ShlRound, ShlRoundAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::conversion::traits::SaturatingInto;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    pub(crate) fn shl_prec_round_assign_helper<T: PrimitiveInt>(\n        &mut self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n        previous_o: Ordering,\n    ) -> Ordering {\n        if let Self(Finite {\n            significand,\n            exponent,\n            sign,\n            precision,\n        }) = self\n        {\n            let mut possibly_just_under_min = false;\n            if let Ok(bits) = bits.try_into()\n                && let Some(new_exponent) = exponent.checked_add(bits)\n            {\n                possibly_just_under_min = true;\n                if (Self::MIN_EXPONENT..=Self::MAX_EXPONENT).contains(&new_exponent) {\n                    *exponent = new_exponent;\n                    return previous_o;\n                }\n            }\n            assert!(rm != Exact, \"Inexact Float left-shift\");\n            if bits > T::ZERO {\n                match (*sign, rm) {\n                    (true, Up | Ceiling | Nearest) => {\n                        *self = Self::INFINITY;\n                        Greater\n                    }\n                    (true, Floor | Down) => {\n                        *self = Self::max_finite_value_with_prec(prec);\n                        Less\n                    }\n                    (false, Up | Floor | Nearest) => {\n                        *self = Self::NEGATIVE_INFINITY;\n                        Less\n                    }\n                    (false, Ceiling | Down) => {\n                        *self = -Self::max_finite_value_with_prec(prec);\n                        Greater\n                    }\n                    (_, Exact) => unreachable!(),\n                }\n            } else if rm == Nearest\n                && possibly_just_under_min\n                && *exponent + <T as SaturatingInto<i32>>::saturating_into(bits)\n                    == Self::MIN_EXPONENT - 1\n                && (previous_o == if *sign { Less } else { Greater }\n                    || !significand.is_power_of_2())\n            {\n                if *sign {\n                    *self = Self::min_positive_value_prec(*precision);\n                    Greater\n                } else {\n                    *self = -Self::min_positive_value_prec(*precision);\n                    Less\n                }\n            } else {\n                match (*sign, rm) {\n                    (true, Up | Ceiling) => {\n                        *self = Self::min_positive_value_prec(prec);\n                        Greater\n                    }\n                    (true, Floor | Down | Nearest) => {\n                        *self = Self::ZERO;\n                        Less\n                    }\n                    (false, Up | Floor) => {\n                        *self = -Self::min_positive_value_prec(prec);\n                        Less\n                    }\n                    (false, Ceiling | Down | Nearest) => {\n                        *self = Self::NEGATIVE_ZERO;\n                        Greater\n                    }\n                    (_, Exact) => unreachable!(),\n                }\n            }\n        } else {\n            Equal\n        }\n    }\n\n    /// Left-shifts a [`Float`] (multiplies it by a power of 2), rounding the result with the\n    /// specified rounding mode and precision, and taking the [`Float`] by value.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p,m) = x2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is `prec`.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,k,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::shl_prec`] instead. If you\n    /// know that your target precision is the precision of the input, consider using\n    /// [`Float::shl_round`] instead. If both of these things are true, or you don't care about\n    /// overflow or underflow behavior, consider using `<<` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` and the result overflows or underflows, or cannot be expressed\n    /// exactly with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::shl_round#shl_prec_round).\n    pub fn shl_prec_round<T: PrimitiveInt>(\n        mut self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.shl_prec_round_assign(bits, prec, rm);\n        (self, o)\n    }\n\n    /// Left-shifts a [`Float`] (multiplies it by a power of 2), rounding the result with the\n    /// specified rounding mode and precision, and taking the [`Float`] by reference.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p,m) = x2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is `prec`.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,k,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::shl_prec_ref`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::shl_round`] instead. If both of these things are true, or you don't care about\n    /// overflow or underflow behavior, consider using `<<` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` and the result overflows or underflows, or cannot be expressed\n    /// exactly with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::shl_round#shl_prec_round).\n    pub fn shl_prec_round_ref<T: PrimitiveInt>(\n        &self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let mut x = self.clone();\n        let o = x.shl_prec_round_assign(bits, prec, rm);\n        (x, o)\n    }\n\n    /// Left-shifts a [`Float`] (multiplies it by a power of 2) in place, rounding the result with\n    /// the specified rounding mode and precision.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// x \\gets x2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is `prec`.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,k,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::shl_prec_assign`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::shl_round_assign`] instead. If both of these things are true, or you don't care\n    /// about overflow or underflow behavior, consider using `<<=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` and the result overflows or underflows, or cannot be expressed\n    /// exactly with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::shl_round#shl_prec_round).\n    pub fn shl_prec_round_assign<T: PrimitiveInt>(\n        &mut self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        if let Self(Finite { exponent, .. }) = self {\n            let old_exponent = *exponent;\n            *exponent = 0;\n            let o = self.set_prec_round(prec, rm);\n            self.shl_prec_round_assign_helper(\n                <T as SaturatingInto<i32>>::saturating_into(bits).saturating_add(old_exponent),\n                prec,\n                rm,\n                o,\n            )\n        } else {\n            Equal\n        }\n    }\n\n    /// Left-shifts a [`Float`] (multiplies it by a power of 2), rounding the result with the\n    /// specified precision, and taking the [`Float`] by value.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p) = x2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,k,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you know that your target precision is the precision of the input, or you don't care\n    /// about overflow or underflow behavior, consider using `<<` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::shl_round#shl_prec).\n    #[inline]\n    pub fn shl_prec<T: PrimitiveInt>(self, bits: T, prec: u64) -> (Self, Ordering) {\n        self.shl_prec_round(bits, prec, Nearest)\n    }\n\n    /// Left-shifts a [`Float`] (multiplies it by a power of 2), rounding the result with the\n    /// specified precision, and taking the [`Float`] by reference.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p) = x2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,k,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you know that your target precision is the precision of the input, or you don't care\n    /// about overflow or underflow behavior, consider using `<<` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::shl_round#shl_prec).\n    #[inline]\n    pub fn shl_prec_ref<T: PrimitiveInt>(&self, bits: T, prec: u64) -> (Self, Ordering) {\n        self.shl_prec_round_ref(bits, prec, Nearest)\n    }\n\n    /// Left-shifts a [`Float`] (multiplies it by a power of 2) in place, rounding the result with\n    /// the specified precision.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// x \\gets x2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,k,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you know that your target precision is the precision of the input, or you don't care\n    /// about overflow or underflow behavior, consider using `<<=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::shl_round#shl_prec).\n    #[inline]\n    pub fn shl_prec_assign<T: PrimitiveInt>(&mut self, bits: T, prec: u64) -> Ordering {\n        self.shl_prec_round_assign(bits, prec, Nearest)\n    }\n}\n\nfn shl_round_primitive_int_ref<T: PrimitiveInt>(\n    x: &Float,\n    bits: T,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if let Float(Finite {\n        significand,\n        exponent,\n        sign,\n        precision,\n    }) = x\n    {\n        let mut possibly_just_under_min = false;\n        if let Ok(bits) = bits.try_into()\n            && let Some(new_exponent) = exponent.checked_add(bits)\n        {\n            possibly_just_under_min = true;\n            if (Float::MIN_EXPONENT..=Float::MAX_EXPONENT).contains(&new_exponent) {\n                return (\n                    Float(Finite {\n                        significand: significand.clone(),\n                        exponent: new_exponent,\n                        sign: *sign,\n                        precision: *precision,\n                    }),\n                    Equal,\n                );\n            }\n        }\n        assert!(rm != Exact, \"Inexact Float left-shift\");\n        if bits > T::ZERO {\n            match (*sign, rm) {\n                (true, Up | Ceiling | Nearest) => (Float::INFINITY, Greater),\n                (true, Floor | Down) => (Float::max_finite_value_with_prec(*precision), Less),\n                (false, Up | Floor | Nearest) => (Float::NEGATIVE_INFINITY, Less),\n                (false, Ceiling | Down) => {\n                    (-Float::max_finite_value_with_prec(*precision), Greater)\n                }\n                (_, Exact) => unreachable!(),\n            }\n        } else if rm == Nearest\n            && possibly_just_under_min\n            && *exponent + <T as SaturatingInto<i32>>::saturating_into(bits)\n                == Float::MIN_EXPONENT - 1\n            && !significand.is_power_of_2()\n        {\n            if *sign {\n                (Float::min_positive_value_prec(*precision), Greater)\n            } else {\n                (-Float::min_positive_value_prec(*precision), Less)\n            }\n        } else {\n            match (*sign, rm) {\n                (true, Up | Ceiling) => (Float::min_positive_value_prec(*precision), Greater),\n                (true, Floor | Down | Nearest) => (Float::ZERO, Less),\n                (false, Up | Floor) => (-Float::min_positive_value_prec(*precision), Less),\n                (false, Ceiling | Down | Nearest) => (Float::NEGATIVE_ZERO, Greater),\n                (_, Exact) => unreachable!(),\n            }\n        }\n    } else {\n        (x.clone(), Equal)\n    }\n}\n\n#[inline]\nfn shl_round_assign_primitive_int<T: PrimitiveInt>(\n    x: &mut Float,\n    bits: T,\n    rm: RoundingMode,\n) -> Ordering {\n    x.shl_prec_round_assign_helper(bits, x.significant_bits(), rm, Equal)\n}\n\nmacro_rules! impl_natural_shl_round {\n    ($t:ident) => {\n        impl ShlRound<$t> for Float {\n            type Output = Float;\n\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), rounding the result with\n            /// the specified rounding mode and taking the [`Float`] by value.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x,k,m) = x2^k.\n            /// $$\n            ///\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`,\n            ///   $(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n            ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned\n            ///   instead.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $0<f(x,k,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            ///\n            /// If you don't care about overflow or underflow behavior, or only want the behavior of\n            /// the `Nearest` rounding mode, you can just use `<<` instead.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the result overflows or underflows and `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round).\n            #[inline]\n            fn shl_round(mut self, bits: $t, rm: RoundingMode) -> (Float, Ordering) {\n                let o = self.shl_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl ShlRound<$t> for &Float {\n            type Output = Float;\n\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), rounding the result with\n            /// the specified rounding mode and taking the [`Float`] by reference.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x,k,m) = x2^k.\n            /// $$\n            ///\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`,\n            ///   $(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n            ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned\n            ///   instead.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $0<f(x,k,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            ///\n            /// If you don't care about overflow or underflow behavior, or only want the behavior of\n            /// the `Nearest` rounding mode, you can just use `<<` instead.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the result overflows or underflows and `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round).\n            #[inline]\n            fn shl_round(self, bits: $t, rm: RoundingMode) -> (Float, Ordering) {\n                shl_round_primitive_int_ref(self, bits, rm)\n            }\n        }\n\n        impl ShlRoundAssign<$t> for Float {\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), in place, rounding the\n            /// result with the specified rounding mode.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// precision is unchanged.\n            ///\n            /// $$\n            /// x\\gets x2^k.\n            /// $$\n            ///\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`,\n            ///   $(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n            ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned\n            ///   instead.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $0<f(x,k,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            ///\n            /// If you don't care about overflow or underflow behavior, or only want the behavior of\n            /// the `Nearest` rounding mode, you can just use `<<=` instead.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the result overflows or underflows and `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round_assign).\n            #[inline]\n            fn shl_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shl_round_assign_primitive_int(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_natural_shl_round);\n"
  },
  {
    "path": "malachite-float/src/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::arithmetic::traits::{ShrRound, ShrRoundAssign};\nuse core::ops::{Shr, ShrAssign};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nmacro_rules! impl_shr {\n    ($t:ident) => {\n        impl Shr<$t> for Float {\n            type Output = Float;\n\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x, k) = x/2^k.\n            /// $$\n            ///\n            /// - If $f(x,k)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n            /// - If $f(x,k)\\leq -2^{2^{30}-1}$, $-\\infty$ is returned instead.\n            /// - If $0<f(x,k)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k)<0$, $-0.0$ is returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n            ///\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Float {\n                self.shr_round(bits, Nearest).0\n            }\n        }\n\n        impl Shr<$t> for &Float {\n            type Output = Float;\n\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x, k) = x/2^k.\n            /// $$\n            ///\n            /// - If $f(x,k)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n            /// - If $f(x,k)\\leq -2^{2^{30}-1}$, $-\\infty$ is returned instead.\n            /// - If $0<f(x,k)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k)<0$, $-0.0$ is returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n            ///\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Float {\n                self.shr_round(bits, Nearest).0\n            }\n        }\n\n        impl ShrAssign<$t> for Float {\n            /// Left-shifts a [`Float`] (multiplies it by a power of 2), in place.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// precision is unchanged.\n            ///\n            /// $$\n            /// x \\gets x/2^k.\n            /// $$\n            ///\n            /// - If $f(x,k)\\geq 2^{2^{30}-1}$, $\\infty$ is assigned instead.\n            /// - If $f(x,k)\\leq -2^{2^{30}-1}$, $-\\infty$ is assigned instead.\n            /// - If $0<f(x,k)\\leq2^{-2^{30}-1}$, $0.0$ is assigned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k)<2^{-2^{30}}$, $2^{-2^{30}}$ is assigned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k)<0$, $-0.0$ is assigned instead.\n            /// - If $-2^{-2^{30}}<f(x,k)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is assigned instead.\n            ///\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr_assign).\n            #[inline]\n            fn shr_assign(&mut self, bits: $t) {\n                self.shr_round_assign(bits, Nearest);\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_shr);\n"
  },
  {
    "path": "malachite-float/src/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, ShrRound, ShrRoundAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::conversion::traits::SaturatingInto;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    pub(crate) fn shr_prec_round_assign_helper<T: PrimitiveInt>(\n        &mut self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n        previous_o: Ordering,\n    ) -> Ordering {\n        if let Self(Finite {\n            significand,\n            exponent,\n            sign,\n            precision,\n        }) = self\n        {\n            let mut possibly_just_under_min = false;\n            if let Ok(bits) = bits.try_into()\n                && let Some(new_exponent) = exponent.checked_sub(bits)\n            {\n                possibly_just_under_min = true;\n                if (Self::MIN_EXPONENT..=Self::MAX_EXPONENT).contains(&new_exponent) {\n                    *exponent = new_exponent;\n                    return previous_o;\n                }\n            }\n            assert!(rm != Exact, \"Inexact Float right-shift\");\n            if bits < T::ZERO {\n                match (*sign, rm) {\n                    (true, Up | Ceiling | Nearest) => {\n                        *self = Self::INFINITY;\n                        Greater\n                    }\n                    (true, Floor | Down) => {\n                        *self = Self::max_finite_value_with_prec(prec);\n                        Less\n                    }\n                    (false, Up | Floor | Nearest) => {\n                        *self = Self::NEGATIVE_INFINITY;\n                        Less\n                    }\n                    (false, Ceiling | Down) => {\n                        *self = -Self::max_finite_value_with_prec(prec);\n                        Greater\n                    }\n                    (_, Exact) => unreachable!(),\n                }\n            } else if rm == Nearest\n                && possibly_just_under_min\n                && *exponent - <T as SaturatingInto<i32>>::saturating_into(bits)\n                    == Self::MIN_EXPONENT - 1\n                && (previous_o == if *sign { Less } else { Greater }\n                    || !significand.is_power_of_2())\n            {\n                if *sign {\n                    *self = Self::min_positive_value_prec(*precision);\n                    Greater\n                } else {\n                    *self = -Self::min_positive_value_prec(*precision);\n                    Less\n                }\n            } else {\n                match (*sign, rm) {\n                    (true, Up | Ceiling) => {\n                        *self = Self::min_positive_value_prec(prec);\n                        Greater\n                    }\n                    (true, Floor | Down | Nearest) => {\n                        *self = Self::ZERO;\n                        Less\n                    }\n                    (false, Up | Floor) => {\n                        *self = -Self::min_positive_value_prec(prec);\n                        Less\n                    }\n                    (false, Ceiling | Down | Nearest) => {\n                        *self = Self::NEGATIVE_ZERO;\n                        Greater\n                    }\n                    (_, Exact) => unreachable!(),\n                }\n            }\n        } else {\n            Equal\n        }\n    }\n\n    /// Right-shifts a [`Float`] (divides it by a power of 2), rounding the result with the\n    /// specified rounding mode and precision, and taking the [`Float`] by value.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p,m) = x/2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is `prec`.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,k,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::shr_prec`] instead. If you\n    /// know that your target precision is the precision of the input, consider using\n    /// [`Float::shr_round`] instead. If both of these things are true, or you don't care about\n    /// overflow or underflow behavior, consider using `>>` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` and the result overflows or underflows, or cannot be expressed\n    /// exactly with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::shr_round#shr_prec_round).\n    pub fn shr_prec_round<T: PrimitiveInt>(\n        mut self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.shr_prec_round_assign(bits, prec, rm);\n        (self, o)\n    }\n\n    /// Right-shifts a [`Float`] (divides it by a power of 2), rounding the result with the\n    /// specified rounding mode and precision, and taking the [`Float`] by reference.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p,m) = x/2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is `prec`.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,k,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::shr_prec_ref`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::shr_round`] instead. If both of these things are true, or you don't care about\n    /// overflow or underflow behavior, consider using `>>` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` and the result overflows or underflows, or cannot be expressed\n    /// exactly with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::shr_round#shr_prec_round).\n    pub fn shr_prec_round_ref<T: PrimitiveInt>(\n        &self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let mut x = self.clone();\n        let o = x.shr_prec_round_assign(bits, prec, rm);\n        (x, o)\n    }\n\n    /// Right-shifts a [`Float`] (divides it by a power of 2) in place, rounding the result with the\n    /// specified rounding mode and precision.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// x \\gets x/2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,k,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is `prec`.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,k,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::shr_prec_assign`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::shr_round_assign`] instead. If both of these things are true, or you don't care\n    /// about overflow or underflow behavior, consider using `>>=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` and the result overflows or underflows, or cannot be expressed\n    /// exactly with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::shr_round#shr_prec_round).\n    pub fn shr_prec_round_assign<T: PrimitiveInt>(\n        &mut self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        if let Self(Finite { exponent, .. }) = self {\n            let old_exponent = *exponent;\n            *exponent = 0;\n            let o = self.set_prec_round(prec, rm);\n            self.shr_prec_round_assign_helper(\n                <T as SaturatingInto<i32>>::saturating_into(bits).saturating_sub(old_exponent),\n                prec,\n                rm,\n                o,\n            )\n        } else {\n            Equal\n        }\n    }\n\n    /// Right-shifts a [`Float`] (divides it by a power of 2), rounding the result with the\n    /// specified precision, and taking the [`Float`] by value.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p) = x/2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,k,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you know that your target precision is the precision of the input, or you don't care\n    /// about overflow or underflow behavior, consider using `>>` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::shr_round#shr_prec).\n    #[inline]\n    pub fn shr_prec<T: PrimitiveInt>(self, bits: T, prec: u64) -> (Self, Ordering) {\n        self.shr_prec_round(bits, prec, Nearest)\n    }\n\n    /// Right-shifts a [`Float`] (divides it by a power of 2), rounding the result with the\n    /// specified precision, and taking the [`Float`] by reference.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// f(x,k,p) = x/2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,k,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you know that your target precision is the precision of the input, or you don't care\n    /// about overflow or underflow behavior, consider using `>>` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::shr_round#shr_prec).\n    #[inline]\n    pub fn shr_prec_ref<T: PrimitiveInt>(&self, bits: T, prec: u64) -> (Self, Ordering) {\n        self.shr_prec_round_ref(bits, prec, Nearest)\n    }\n\n    /// Right-shifts a [`Float`] (divides it by a power of 2) in place, rounding the result with the\n    /// specified precision.\n    ///\n    /// `NaN`, infinities, and zeros are unchanged. If the output has a precision, it is `prec`.\n    ///\n    /// $$\n    /// x \\gets x/2^k.\n    /// $$\n    ///\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,k,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,k,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,k,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,k,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,k,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you know that your target precision is the precision of the input, or you don't care\n    /// about overflow or underflow behavior, consider using `>>=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// See [here](super::shr_round#shr_prec).\n    #[inline]\n    pub fn shr_prec_assign<T: PrimitiveInt>(&mut self, bits: T, prec: u64) -> Ordering {\n        self.shr_prec_round_assign(bits, prec, Nearest)\n    }\n}\n\nfn shr_round_primitive_int_ref<T: PrimitiveInt>(\n    x: &Float,\n    bits: T,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if let Float(Finite {\n        significand,\n        exponent,\n        sign,\n        precision,\n    }) = x\n    {\n        let mut possibly_just_under_min = false;\n        if let Ok(bits) = bits.try_into()\n            && let Some(new_exponent) = exponent.checked_sub(bits)\n        {\n            possibly_just_under_min = true;\n            if (Float::MIN_EXPONENT..=Float::MAX_EXPONENT).contains(&new_exponent) {\n                return (\n                    Float(Finite {\n                        significand: significand.clone(),\n                        exponent: new_exponent,\n                        sign: *sign,\n                        precision: *precision,\n                    }),\n                    Equal,\n                );\n            }\n        }\n        assert!(rm != Exact, \"Inexact Float right-shift\");\n        if bits < T::ZERO {\n            match (*sign, rm) {\n                (true, Up | Ceiling | Nearest) => (Float::INFINITY, Greater),\n                (true, Floor | Down) => (Float::max_finite_value_with_prec(*precision), Less),\n                (false, Up | Floor | Nearest) => (Float::NEGATIVE_INFINITY, Less),\n                (false, Ceiling | Down) => {\n                    (-Float::max_finite_value_with_prec(*precision), Greater)\n                }\n                (_, Exact) => unreachable!(),\n            }\n        } else if rm == Nearest\n            && possibly_just_under_min\n            && *exponent - <T as SaturatingInto<i32>>::saturating_into(bits)\n                == Float::MIN_EXPONENT - 1\n            && !significand.is_power_of_2()\n        {\n            if *sign {\n                (Float::min_positive_value_prec(*precision), Greater)\n            } else {\n                (-Float::min_positive_value_prec(*precision), Less)\n            }\n        } else {\n            match (*sign, rm) {\n                (true, Up | Ceiling) => (Float::min_positive_value_prec(*precision), Greater),\n                (true, Floor | Down | Nearest) => (Float::ZERO, Less),\n                (false, Up | Floor) => (-Float::min_positive_value_prec(*precision), Less),\n                (false, Ceiling | Down | Nearest) => (Float::NEGATIVE_ZERO, Greater),\n                (_, Exact) => unreachable!(),\n            }\n        }\n    } else {\n        (x.clone(), Equal)\n    }\n}\n\nfn shr_round_assign_primitive_int<T: PrimitiveInt>(\n    x: &mut Float,\n    bits: T,\n    rm: RoundingMode,\n) -> Ordering {\n    x.shr_prec_round_assign_helper(bits, x.significant_bits(), rm, Equal)\n}\n\nmacro_rules! impl_natural_shr_round {\n    ($t:ident) => {\n        impl ShrRound<$t> for Float {\n            type Output = Float;\n\n            /// Right-shifts a [`Float`] (divides it by a power of 2), rounding the result with the\n            /// specified rounding mode and taking the [`Float`] by value.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x,k,m) = x/2^k.\n            /// $$\n            ///\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`,\n            ///   $(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n            ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned\n            ///   instead.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $0<f(x,k,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            ///\n            /// If you don't care about overflow or underflow behavior, or only want the behavior of\n            /// the `Nearest` rounding mode, you can just use `>>` instead.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the result overflows or underflows and `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(mut self, bits: $t, rm: RoundingMode) -> (Float, Ordering) {\n                let o = self.shr_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl ShrRound<$t> for &Float {\n            type Output = Float;\n\n            /// Right-shifts a [`Float`] (divides it by a power of 2), rounding the result with the\n            /// specified rounding mode and taking the [`Float`] by reference.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// output has the same precision.\n            ///\n            /// $$\n            /// f(x,k,m) = x/2^k.\n            /// $$\n            ///\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`,\n            ///   $(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n            ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned\n            ///   instead.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $0<f(x,k,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            ///\n            /// If you don't care about overflow or underflow behavior, or only want the behavior of\n            /// the `Nearest` rounding mode, you can just use `>>` instead.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the result overflows or underflows and `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(self, bits: $t, rm: RoundingMode) -> (Float, Ordering) {\n                shr_round_primitive_int_ref(self, bits, rm)\n            }\n        }\n\n        impl ShrRoundAssign<$t> for Float {\n            /// Right-shifts a [`Float`] (divides it by a power of 2), in place, rounding the result\n            /// with the specified rounding mode.\n            ///\n            /// `NaN`, infinities, and zeros are unchanged. If the [`Float`] has a precision, the\n            /// precision is unchanged.\n            ///\n            /// $$\n            /// x\\gets x/2^k.\n            /// $$\n            ///\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`,\n            ///   $(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$\n            ///   is returned instead.\n            /// - If $f(x,k,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n            ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the\n            ///   input.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned\n            ///   instead.\n            /// - If $0<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $0<f(x,k,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n            /// - If $2^{-2^{30}-1}<f(x,k,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            /// - If $-2^{-2^{30}-1}\\leq f(x,k,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned\n            ///   instead.\n            /// - If $-2^{-2^{30}}<f(x,k,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n            ///   returned instead.\n            ///\n            /// If you don't care about overflow or underflow behavior, or only want the behavior of\n            /// the `Nearest` rounding mode, you can just use `>>=` instead.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the result overflows or underflows and `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round_assign).\n            #[inline]\n            fn shr_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shr_round_assign_primitive_int(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_primitive_ints!(impl_natural_shr_round);\n"
  },
  {
    "path": "malachite-float/src/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\n\nimpl Sign for Float {\n    /// Returns the sign of a [`Float`].\n    ///\n    /// Returns `Greater` if the sign is positive and `Less` if the sign is negative. Never returns\n    /// `Equal`. $\\infty$ and positive zero have a positive sign, and $-\\infty$ and negative zero\n    /// have a negative sign.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is NaN.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Sign;\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(Float::INFINITY.sign(), Greater);\n    /// assert_eq!(Float::NEGATIVE_INFINITY.sign(), Less);\n    /// assert_eq!(Float::ZERO.sign(), Greater);\n    /// assert_eq!(Float::NEGATIVE_ZERO.sign(), Less);\n    /// assert_eq!(Float::ONE.sign(), Greater);\n    /// assert_eq!(Float::NEGATIVE_ONE.sign(), Less);\n    /// ```\n    fn sign(&self) -> Ordering {\n        if let Self(Infinity { sign } | Zero { sign } | Finite { sign, .. }) = self {\n            if *sign { Greater } else { Less }\n        } else {\n            panic!()\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::conversion::from_natural::{from_natural_zero_exponent, from_natural_zero_exponent_ref};\nuse crate::{\n    Float, emulate_rational_to_float_fn, float_infinity, float_nan, float_negative_infinity,\n    float_negative_zero, float_zero,\n};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, CheckedSqrt, FloorLogBase2, Parity, Sqrt, SqrtAssign,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::NaN as NanTrait;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::natural::arithmetic::float_sqrt::{\n    sqrt_float_significand_in_place, sqrt_float_significand_ref,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\npub_crate_test! {\ngeneric_sqrt_rational_ref(x: &Rational, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    let mut end_shift = x.floor_log_base_2();\n    let x2;\n    let reduced_x: &Rational;\n    if end_shift.gt_abs(&0x3fff_0000) {\n        end_shift &= !1;\n        x2 = x >> end_shift;\n        reduced_x = &x2;\n    } else {\n        end_shift = 0;\n        reduced_x = x;\n    }\n    loop {\n        let sqrt = Float::from_rational_prec_round_ref(reduced_x, working_prec, Floor).0.sqrt();\n        // See algorithms.tex. Since we rounded down when computing fx, the absolute error of the\n        // square root is bounded by (c_sqrt + k_fx)ulp(sqrt) <= 2ulp(sqrt).\n        //\n        // Experiments suggest that `working_prec` is low enough (that is, that the error is at most\n        // 1 ulp), but I can only prove `working_prec - 1`.\n        if float_can_round(sqrt.significand_ref().unwrap(), working_prec - 1, prec, rm) {\n            let (mut sqrt, mut o) = Float::from_float_prec_round(sqrt, prec, rm);\n            if end_shift != 0 {\n                o = sqrt.shl_prec_round_assign_helper(end_shift >> 1, prec, rm, o);\n            }\n            return (sqrt, o);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}}\n\npub(crate) fn generic_sqrt_rational(\n    mut x: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    let mut end_shift = x.floor_log_base_2();\n    if end_shift.gt_abs(&0x3fff_0000) {\n        end_shift &= !1;\n        x >>= end_shift;\n    } else {\n        end_shift = 0;\n    }\n    loop {\n        let sqrt = Float::from_rational_prec_round_ref(&x, working_prec, Floor)\n            .0\n            .sqrt();\n        // See algorithms.tex. Since we rounded down when computing fx, the absolute error of the\n        // square root is bounded by (c_sqrt + k_fx)ulp(sqrt) <= 2ulp(sqrt).\n        //\n        // Experiments suggest that `working_prec` is low enough (that is, that the error is at most\n        // 1 ulp), but I can only prove `working_prec - 1`.\n        if float_can_round(sqrt.significand_ref().unwrap(), working_prec - 1, prec, rm) {\n            let (mut sqrt, mut o) = Float::from_float_prec_round(sqrt, prec, rm);\n            if end_shift != 0 {\n                o = sqrt.shl_prec_round_assign_helper(end_shift >> 1, prec, rm, o);\n            }\n            return (sqrt, o);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n\nimpl Float {\n    /// Computes the square root of a [`Float`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded square root is less than, equal to, or greater than\n    /// the exact square root. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p+1}$.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=\\infty$\n    /// - $f(-\\infty,p,m)=\\text{NaN}$\n    /// - $f(0.0,p,m)=0.0$\n    /// - $f(-0.0,p,m)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sqrt_prec`] instead. If you\n    /// know that your target precision is the precision of the input, consider using\n    /// [`Float::sqrt_round`] instead. If both of these things are true, consider using\n    /// [`Float::sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round(5, Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round(5, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"1.81\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round(5, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"1.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round(20, Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.772453\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round(20, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"1.772455\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round(20, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"1.772453\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_prec_round(mut self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.sqrt_prec_round_assign(prec, rm);\n        (self, o)\n    }\n\n    /// Computes the square root of a [`Float`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by reference. An [`Ordering`] is\n    /// also returned, indicating whether the rounded square root is less than, equal to, or greater\n    /// than the exact square root. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p+1}$.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\infty,p,m)=\\infty$\n    /// - $f(-\\infty,p,m)=\\text{NaN}$\n    /// - $f(0.0,p,m)=0.0$\n    /// - $f(-0.0,p,m)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sqrt_prec_ref`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::sqrt_round_ref`] instead. If both of these things are true, consider using\n    /// `(&Float).sqrt()`instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round_ref(5, Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round_ref(5, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"1.81\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round_ref(5, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"1.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round_ref(20, Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.772453\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round_ref(20, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"1.772455\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_round_ref(20, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"1.772453\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_prec_round_ref(&self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match self {\n            Self(NaN | Infinity { sign: false }) => (float_nan!(), Equal),\n            float_infinity!() => (float_infinity!(), Equal),\n            float_zero!() => (float_zero!(), Equal),\n            float_negative_zero!() => (float_negative_zero!(), Equal),\n            Self(Finite {\n                sign,\n                exponent: x_exp,\n                precision: x_prec,\n                significand: x,\n                ..\n            }) => {\n                if !sign {\n                    return (float_nan!(), Equal);\n                }\n                let (sqrt, exp, o) = sqrt_float_significand_ref(x, *x_exp, *x_prec, prec, rm);\n                (\n                    Self(Finite {\n                        sign: true,\n                        exponent: exp,\n                        precision: prec,\n                        significand: sqrt,\n                    }),\n                    o,\n                )\n            }\n        }\n    }\n\n    /// Computes the square root of a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by value. An [`Ordering`] is also returned,\n    /// indicating whether the rounded square root is less than, equal to, or greater than the exact\n    /// square root. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// If the square root is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\infty,p)=\\infty$\n    /// - $f(-\\infty,p)=\\text{NaN}$\n    /// - $f(0.0,p)=0.0$\n    /// - $f(-0.0,p)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sqrt_prec_round`] instead. If you know that your target precision is the precision\n    /// of the input, consider using [`Float::sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec(5);\n    /// assert_eq!(sqrt.to_string(), \"1.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec(20);\n    /// assert_eq!(sqrt.to_string(), \"1.772453\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_prec(self, prec: u64) -> (Self, Ordering) {\n        self.sqrt_prec_round(prec, Nearest)\n    }\n\n    /// Computes the square root of a [`Float`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded square root is less than, equal to, or greater than the exact\n    /// square root. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// If the square root is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\infty,p)=\\infty$\n    /// - $f(-\\infty,p)=\\text{NaN}$\n    /// - $f(0.0,p)=0.0$\n    /// - $f(-0.0,p)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sqrt_prec_round_ref`] instead. If you know that your target precision is the\n    /// precision of the input, consider using `(&Float).sqrt()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_ref(5);\n    /// assert_eq!(sqrt.to_string(), \"1.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_prec_ref(20);\n    /// assert_eq!(sqrt.to_string(), \"1.772453\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_prec_ref(&self, prec: u64) -> (Self, Ordering) {\n        self.sqrt_prec_round_ref(prec, Nearest)\n    }\n\n    /// Computes the square root of a [`Float`], rounding the result with the specified rounding\n    /// mode. The [`Float`] is taken by value. An [`Ordering`] is also returned, indicating whether\n    /// the rounded square root is less than, equal to, or greater than the exact square root.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=\\infty$\n    /// - $f(-\\infty,m)=\\text{NaN}$\n    /// - $f(0.0,m)=0.0$\n    /// - $f(-0.0,m)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sqrt_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_round(Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.772453850905515\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_round(Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"1.772453850905517\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_round(Nearest);\n    /// assert_eq!(sqrt.to_string(), \"1.772453850905515\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_round(self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.sqrt_prec_round(prec, rm)\n    }\n\n    /// Computes the square root of a [`Float`], rounding the result with the specified rounding\n    /// mode. The [`Float`] is taken by reference. An [`Ordering`] is also returned, indicating\n    /// whether the rounded square root is less than, equal to, or greater than the exact square\n    /// root. Although `NaN`s are not comparable to any [`Float`], whenever this function returns a\n    /// `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\infty,m)=\\infty$\n    /// - $f(-\\infty,m)=\\text{NaN}$\n    /// - $f(0.0,m)=0.0$\n    /// - $f(-0.0,m)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sqrt_prec_round_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// `(&Float).sqrt()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_round_ref(Floor);\n    /// assert_eq!(sqrt.to_string(), \"1.772453850905515\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_round_ref(Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"1.772453850905517\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::from(PI).sqrt_round_ref(Nearest);\n    /// assert_eq!(sqrt.to_string(), \"1.772453850905515\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_round_ref(&self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.sqrt_prec_round_ref(prec, rm)\n    }\n\n    /// Computes the square root of a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. An [`Ordering`] is returned, indicating\n    /// whether the rounded square root is less than, equal to, or greater than the exact square\n    /// root. Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sqrt_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sqrt_prec_assign`] instead.\n    /// If you know that your target precision is the precision of the input, consider using\n    /// [`Float::sqrt_round_assign`] instead. If both of these things are true, consider using\n    /// [`Float::sqrt_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_round_assign(5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"1.75\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_round_assign(5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"1.81\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_round_assign(5, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"1.75\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_round_assign(20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"1.772453\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_round_assign(20, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"1.772455\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_round_assign(20, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"1.772453\");\n    /// ```\n    #[inline]\n    pub fn sqrt_prec_round_assign(&mut self, prec: u64, rm: RoundingMode) -> Ordering {\n        assert_ne!(prec, 0);\n        match self {\n            Self(NaN | Infinity { sign: true } | Zero { .. }) => Equal,\n            float_negative_infinity!() => {\n                *self = float_nan!();\n                Equal\n            }\n            Self(Finite {\n                sign,\n                exponent: x_exp,\n                precision: x_prec,\n                significand: x,\n                ..\n            }) => {\n                if !*sign {\n                    *self = float_nan!();\n                    return Equal;\n                }\n                let o;\n                (*x_exp, o) = sqrt_float_significand_in_place(x, *x_exp, *x_prec, prec, rm);\n                *x_prec = prec;\n                o\n            }\n        }\n    }\n\n    /// Computes the square root of a [`Float`] in place, rounding the result to the nearest value\n    /// of the specified precision. An [`Ordering`] is returned, indicating whether the rounded\n    /// square root is less than, equal to, or greater than the exact square root. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it\n    /// also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// If the square root is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sqrt_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sqrt_prec_round_assign`] instead. If you know that your target precision is the\n    /// precision of the input, consider using [`Float::sqrt`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_assign(5), Less);\n    /// assert_eq!(x.to_string(), \"1.75\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_prec_assign(20), Less);\n    /// assert_eq!(x.to_string(), \"1.772453\");\n    /// ```\n    #[inline]\n    pub fn sqrt_prec_assign(&mut self, prec: u64) -> Ordering {\n        self.sqrt_prec_round_assign(prec, Nearest)\n    }\n\n    /// Computes the square root of a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. An [`Ordering`] is returned, indicating whether the rounded square root is\n    /// less than, equal to, or greater than the exact square root. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// See the [`Float::sqrt_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sqrt_prec_round_assign`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::sqrt_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the input\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_round_assign(Floor), Less);\n    /// assert_eq!(x.to_string(), \"1.772453850905515\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_round_assign(Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"1.772453850905517\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sqrt_round_assign(Nearest), Less);\n    /// assert_eq!(x.to_string(), \"1.772453850905515\");\n    /// ```\n    #[inline]\n    pub fn sqrt_round_assign(&mut self, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.sqrt_prec_round_assign(prec, rm)\n    }\n\n    /// Computes the square root of a [`Rational`], rounding the result to the specified precision\n    /// and with the specified rounding mode and returning the result as a [`Float`]. The\n    /// [`Rational`] is taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded square root is less than, equal to, or greater than the exact square root. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p+1}$.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p,m)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sqrt_rational_prec`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 5, Floor);\n    /// assert_eq!(sqrt.to_string(), \"0.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 5, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"0.78\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 5, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"0.78\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 20, Floor);\n    /// assert_eq!(sqrt.to_string(), \"0.774596\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 20, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"0.774597\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round(Rational::from_unsigneds(3u8, 5), 20, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"0.774596\");\n    /// assert_eq!(o, Less);\n    /// ```\n    pub fn sqrt_rational_prec_round(x: Rational, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if x < 0u32 {\n            return (Self::NAN, Equal);\n        }\n        if let Some(sqrt) = (&x).checked_sqrt() {\n            return Self::from_rational_prec_round(sqrt, prec, rm);\n        }\n        let (n, d) = x.numerator_and_denominator_ref();\n        match (n.checked_log_base_2(), d.checked_log_base_2()) {\n            (_, Some(log_d)) if log_d.even() => {\n                let n = x.into_numerator();\n                let n_exp = n.significant_bits();\n                let mut n = from_natural_zero_exponent(n);\n                if n_exp.odd() {\n                    n <<= 1u32;\n                }\n                let (mut sqrt, o) = Self::exact_from(n).sqrt_prec_round(prec, rm);\n                let o = sqrt.shr_prec_round_assign_helper(\n                    i128::from(log_d >> 1) - i128::from(n_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (sqrt, o)\n            }\n            (Some(log_n), _) if log_n.even() => {\n                let d = x.into_denominator();\n                let d_exp = d.significant_bits();\n                let mut d = from_natural_zero_exponent(d);\n                if d_exp.odd() {\n                    d <<= 1u32;\n                }\n                let (mut reciprocal_sqrt, o) =\n                    Self::exact_from(d).reciprocal_sqrt_prec_round(prec, rm);\n                let o = reciprocal_sqrt.shl_prec_round_assign_helper(\n                    i128::from(log_n >> 1) - i128::from(d_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (reciprocal_sqrt, o)\n            }\n            _ => generic_sqrt_rational(x, prec, rm),\n        }\n    }\n\n    /// Computes the square root of a [`Rational`], rounding the result to the specified precision\n    /// and with the specified rounding mode and returning the result as a [`Float`]. The\n    /// [`Rational`] is taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// rounded square root is less than, equal to, or greater than the exact square root. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p+1}$.\n    /// - If $\\sqrt{x}$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p,m)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sqrt_rational_prec_ref`]\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the result cannot be represented exactly with the given\n    /// precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 5, Floor);\n    /// assert_eq!(sqrt.to_string(), \"0.75\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 5, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"0.78\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 5, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"0.78\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 20, Floor);\n    /// assert_eq!(sqrt.to_string(), \"0.774596\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 20, Ceiling);\n    /// assert_eq!(sqrt.to_string(), \"0.774597\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) =\n    ///     Float::sqrt_rational_prec_round_ref(&Rational::from_unsigneds(3u8, 5), 20, Nearest);\n    /// assert_eq!(sqrt.to_string(), \"0.774596\");\n    /// assert_eq!(o, Less);\n    /// ```\n    pub fn sqrt_rational_prec_round_ref(\n        x: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if *x < 0u32 {\n            return (Self::NAN, Equal);\n        }\n        if let Some(sqrt) = x.checked_sqrt() {\n            return Self::from_rational_prec_round(sqrt, prec, rm);\n        }\n        let (n, d) = x.numerator_and_denominator_ref();\n        match (n.checked_log_base_2(), d.checked_log_base_2()) {\n            (_, Some(log_d)) if log_d.even() => {\n                let n_exp = n.significant_bits();\n                let mut n = from_natural_zero_exponent_ref(n);\n                if n_exp.odd() {\n                    n <<= 1u32;\n                }\n                let (mut sqrt, o) = Self::exact_from(n).sqrt_prec_round(prec, rm);\n                let o = sqrt.shr_prec_round_assign_helper(\n                    i128::from(log_d >> 1) - i128::from(n_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (sqrt, o)\n            }\n            (Some(log_n), _) if log_n.even() => {\n                let d_exp = d.significant_bits();\n                let mut d = from_natural_zero_exponent_ref(d);\n                if d_exp.odd() {\n                    d <<= 1u32;\n                }\n                let (mut reciprocal_sqrt, o) =\n                    Self::exact_from(d).reciprocal_sqrt_prec_round(prec, rm);\n                let o = reciprocal_sqrt.shl_prec_round_assign_helper(\n                    i128::from(log_n >> 1) - i128::from(d_exp >> 1),\n                    prec,\n                    rm,\n                    o,\n                );\n                (reciprocal_sqrt, o)\n            }\n            _ => generic_sqrt_rational_ref(x, prec, rm),\n        }\n    }\n\n    /// Computes the square root of a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision and returning the result as a [`Float`]. The [`Rational`] is taken by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded square root is less\n    /// than, equal to, or greater than the exact square root. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// If the square root is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sqrt_rational_prec_round`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::sqrt_rational_prec(Rational::from_unsigneds(3u8, 5), 5);\n    /// assert_eq!(sqrt.to_string(), \"0.78\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::sqrt_rational_prec(Rational::from_unsigneds(3u8, 5), 20);\n    /// assert_eq!(sqrt.to_string(), \"0.774596\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_rational_prec(x: Rational, prec: u64) -> (Self, Ordering) {\n        Self::sqrt_rational_prec_round(x, prec, Nearest)\n    }\n\n    /// Computes the square root of a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision and returning the result as a [`Float`]. The [`Rational`] is taken by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded square root is\n    /// less than, equal to, or greater than the exact square root. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// If the square root is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(0.0,p)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sqrt_rational_prec_round_ref`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt, o) = Float::sqrt_rational_prec_ref(&Rational::from_unsigneds(3u8, 5), 5);\n    /// assert_eq!(sqrt.to_string(), \"0.78\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt, o) = Float::sqrt_rational_prec_ref(&Rational::from_unsigneds(3u8, 5), 20);\n    /// assert_eq!(sqrt.to_string(), \"0.774596\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_rational_prec_ref(x: &Rational, prec: u64) -> (Self, Ordering) {\n        Self::sqrt_rational_prec_round_ref(x, prec, Nearest)\n    }\n}\n\nimpl Sqrt for Float {\n    type Output = Self;\n\n    /// Computes the square root of a [`Float`], taking it by value.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the square root is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// $$\n    /// f(x) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=\\infty$\n    /// - $f(-\\infty)=\\text{NaN}$\n    /// - $f(0.0)=0.0$\n    /// - $f(-0.0)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::sqrt_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::sqrt_round`].\n    /// If you want both of these things, consider using [`Float::sqrt_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Sqrt;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!(Float::NAN.sqrt().is_nan());\n    /// assert_eq!(Float::INFINITY.sqrt(), Float::INFINITY);\n    /// assert!(Float::NEGATIVE_INFINITY.sqrt().is_nan());\n    /// assert_eq!(Float::from(1.5).sqrt(), 1.0);\n    /// assert!(Float::from(-1.5).sqrt().is_nan());\n    /// ```\n    #[inline]\n    fn sqrt(self) -> Self {\n        let prec = self.significant_bits();\n        self.sqrt_prec_round(prec, Nearest).0\n    }\n}\n\nimpl Sqrt for &Float {\n    type Output = Float;\n\n    /// Computes the square root of a [`Float`], taking it by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the square root is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// $$\n    /// f(x) = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\infty)=\\infty$\n    /// - $f(-\\infty)=\\text{NaN}$\n    /// - $f(0.0)=0.0$\n    /// - $f(-0.0)=-0.0$\n    ///\n    /// Neither overflow nor underflow is possible.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sqrt_prec_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::sqrt_round_ref`]. If you want both of these things, consider using\n    /// [`Float::sqrt_prec_round_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Sqrt;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::NAN).sqrt().is_nan());\n    /// assert_eq!((&Float::INFINITY).sqrt(), Float::INFINITY);\n    /// assert!((&Float::NEGATIVE_INFINITY).sqrt().is_nan());\n    /// assert_eq!((&Float::from(1.5)).sqrt(), 1.0);\n    /// assert!((&Float::from(-1.5)).sqrt().is_nan());\n    /// ```\n    #[inline]\n    fn sqrt(self) -> Float {\n        let prec = self.significant_bits();\n        self.sqrt_prec_round_ref(prec, Nearest).0\n    }\n}\n\nimpl SqrtAssign for Float {\n    /// Computes the square root of a [`Float`] in place.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the square root is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// The square root of any nonzero negative number is `NaN`.\n    ///\n    /// $$\n    /// x\\gets = \\sqrt{x}+\\varepsilon.\n    /// $$\n    /// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be\n    ///   0.\n    /// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n    ///   \\sqrt{x}\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the [`Float::sqrt`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sqrt_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::sqrt_round_assign`]. If you want both of these things, consider using\n    /// [`Float::sqrt_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.get_prec()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SqrtAssign;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::NAN;\n    /// x.sqrt_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.sqrt_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.sqrt_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x.sqrt_assign();\n    /// assert_eq!(x, 1.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x.sqrt_assign();\n    /// assert!(x.is_nan());\n    /// ```\n    #[inline]\n    fn sqrt_assign(&mut self) {\n        let prec = self.significant_bits();\n        self.sqrt_prec_round_assign(prec, Nearest);\n    }\n}\n\n/// Computes the square root of a [`Rational`], returning a primitive float result.\n///\n/// If the square root is equidistant from two primitive floats, the primitive float with fewer 1s\n/// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n/// rounding mode.\n///\n/// The square root of any negative number is `NaN`.\n///\n/// $$\n/// f(x) = \\sqrt{x}+\\varepsilon.\n/// $$\n/// - If $\\sqrt{x}$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n/// - If $\\sqrt{x}$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2\n///   \\sqrt{x}\\rfloor-p}$, where $p$ is precision of the output (typically 24 if `T` is a [`f32`]\n///   and 53 if `T` is a [`f64`], but less if the output is subnormal).\n///\n/// Special cases:\n/// - $f(0)=0.0$\n///\n/// Overflow:\n/// - If the absolute value of the result is too large to represent, $\\infty$ is returned instead.\n/// - If the absolute value of the result is too small to represent, 0.0 is returned instead.\n///\n/// # Worst-case complexity\n/// Constant time and additional memory.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::arithmetic::sqrt::primitive_float_sqrt_rational;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     NiceFloat(primitive_float_sqrt_rational::<f64>(&Rational::ZERO)),\n///     NiceFloat(0.0)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_sqrt_rational::<f64>(\n///         &Rational::from_unsigneds(1u8, 3)\n///     )),\n///     NiceFloat(0.5773502691896257)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_sqrt_rational::<f64>(&Rational::from(10000))),\n///     NiceFloat(100.0)\n/// );\n/// assert_eq!(\n///     NiceFloat(primitive_float_sqrt_rational::<f64>(&Rational::from(\n///         -10000\n///     ))),\n///     NiceFloat(f64::NAN)\n/// );\n/// ```\n#[inline]\n#[allow(clippy::type_repetition_in_bounds)]\npub fn primitive_float_sqrt_rational<T: PrimitiveFloat>(x: &Rational) -> T\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    emulate_rational_to_float_fn(Float::sqrt_rational_prec_ref, x)\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{\n    Float, float_either_infinity, float_either_zero, float_infinity, float_nan, float_zero,\n};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, IsPowerOf2, Square, SquareAssign,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_square::{\n    square_float_significand_in_place, square_float_significand_ref,\n};\n\nimpl Float {\n    /// Squares a [`Float`], rounding the result to the specified precision and with the specified\n    /// rounding mode. The [`Float`] is taken by value. An [`Ordering`] is also returned, indicating\n    /// whether the rounded square is less than, equal to, or greater than the exact square.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p+1}$.\n    /// - If $x^2$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\pm\\infty,p,m)=\\infty$\n    /// - $f(\\pm0.0,p,m)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::square_prec`] instead. If you\n    /// know that your target precision is the precision of the input, consider using\n    /// [`Float::square_round`] instead. If both of these things are true, consider using\n    /// [`Float::square`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact squaring.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round(5, Floor);\n    /// assert_eq!(square.to_string(), \"9.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round(5, Ceiling);\n    /// assert_eq!(square.to_string(), \"10.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round(5, Nearest);\n    /// assert_eq!(square.to_string(), \"10.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round(20, Floor);\n    /// assert_eq!(square.to_string(), \"9.8696\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round(20, Ceiling);\n    /// assert_eq!(square.to_string(), \"9.86961\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round(20, Nearest);\n    /// assert_eq!(square.to_string(), \"9.8696\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn square_prec_round(mut self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.square_prec_round_assign(prec, rm);\n        (self, o)\n    }\n\n    /// Squares a [`Float`], rounding the result to the specified precision and with the specified\n    /// rounding mode. The [`Float`] is taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded square is less than, equal to, or greater than the exact\n    /// square. Although `NaN`s are not comparable to any [`Float`], whenever this function returns\n    /// a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,p,m) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p+1}$.\n    /// - If $x^2$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p,m)=\\text{NaN}$\n    /// - $f(\\pm\\infty,p,m)=\\infty$\n    /// - $f(\\pm0.0,p,m)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::square_prec_ref`] instead. If\n    /// you know that your target precision is the precision of the input, consider using\n    /// [`Float::square_round_ref`] instead. If both of these things are true, consider using\n    /// `(&Float).square()`instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact squaring.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round_ref(5, Floor);\n    /// assert_eq!(square.to_string(), \"9.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round_ref(5, Ceiling);\n    /// assert_eq!(square.to_string(), \"10.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round_ref(5, Nearest);\n    /// assert_eq!(square.to_string(), \"10.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round_ref(20, Floor);\n    /// assert_eq!(square.to_string(), \"9.8696\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round_ref(20, Ceiling);\n    /// assert_eq!(square.to_string(), \"9.86961\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_round_ref(20, Nearest);\n    /// assert_eq!(square.to_string(), \"9.8696\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn square_prec_round_ref(&self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match self {\n            float_nan!() => (float_nan!(), Equal),\n            float_either_infinity!() => (float_infinity!(), Equal),\n            float_either_zero!() => (float_zero!(), Equal),\n            Self(Finite {\n                exponent: x_exp,\n                precision: x_prec,\n                significand: x,\n                ..\n            }) => {\n                let twice_exp = x_exp << 1;\n                if twice_exp - 1 > Self::MAX_EXPONENT {\n                    assert!(rm != Exact, \"Inexact Float squaring\");\n                    return match rm {\n                        Ceiling | Up | Nearest => (float_infinity!(), Greater),\n                        _ => (Self::max_finite_value_with_prec(prec), Less),\n                    };\n                } else if twice_exp < Self::MIN_EXPONENT - 1 {\n                    assert!(rm != Exact, \"Inexact Float squaring\");\n                    return match rm {\n                        Floor | Down | Nearest => (float_zero!(), Less),\n                        _ => (Self::min_positive_value_prec(prec), Greater),\n                    };\n                }\n                let (square, exp_offset, o) = square_float_significand_ref(x, *x_prec, prec, rm);\n                let exp = x_exp\n                    .arithmetic_checked_shl(1u32)\n                    .unwrap()\n                    .checked_add(exp_offset)\n                    .unwrap();\n                if exp > Self::MAX_EXPONENT {\n                    assert!(rm != Exact, \"Inexact Float squaring\");\n                    return match rm {\n                        Ceiling | Up | Nearest => (float_infinity!(), Greater),\n                        _ => (Self::max_finite_value_with_prec(prec), Less),\n                    };\n                } else if exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !square.is_power_of_2())\n                    {\n                        (Self::min_positive_value_prec(prec), Greater)\n                    } else {\n                        match rm {\n                            Exact => panic!(\"Inexact float squaring\"),\n                            Ceiling | Up => (Self::min_positive_value_prec(prec), Greater),\n                            _ => (float_zero!(), Less),\n                        }\n                    };\n                }\n                (\n                    Self(Finite {\n                        sign: true,\n                        exponent: exp,\n                        precision: prec,\n                        significand: square,\n                    }),\n                    o,\n                )\n            }\n        }\n    }\n\n    /// Squares a [`Float`], rounding the result to the nearest value of the specified precision.\n    /// The [`Float`] is taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded square is less than, equal to, or greater than the exact square. Although `NaN`s are\n    /// not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// If the square is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\pm\\infty,p)=\\infty$\n    /// - $f(\\pm0.0,p)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::square_prec_round`] instead. If you know that your target precision is the\n    /// precision of the input, consider using [`Float::square`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (square, o) = Float::from(PI).square_prec(5);\n    /// assert_eq!(square.to_string(), \"10.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec(20);\n    /// assert_eq!(square.to_string(), \"9.8696\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn square_prec(self, prec: u64) -> (Self, Ordering) {\n        self.square_prec_round(prec, Nearest)\n    }\n\n    /// Squares a [`Float`], rounding the result to the nearest value of the specified precision.\n    /// The [`Float`] is taken by reference. An [`Ordering`] is also returned, indicating whether\n    /// the rounded square is less than, equal to, or greater than the exact square. Although `NaN`s\n    /// are not comparable to any [`Float`], whenever this function returns a `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// If the square is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,p) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},p)=\\text{NaN}$\n    /// - $f(\\pm\\infty,p)=\\infty$\n    /// - $f(\\pm0.0,p)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::square_prec_round_ref`] instead. If you know that your target precision is the\n    /// precision of the input, consider using `(&Float).square()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_ref(5);\n    /// assert_eq!(square.to_string(), \"10.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_prec_ref(20);\n    /// assert_eq!(square.to_string(), \"9.8696\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn square_prec_ref(&self, prec: u64) -> (Self, Ordering) {\n        self.square_prec_round_ref(prec, Nearest)\n    }\n\n    /// Squares a [`Float`], rounding the result with the specified rounding mode. The [`Float`] is\n    /// taken by value. An [`Ordering`] is also returned, indicating whether the rounded square is\n    /// less than, equal to, or greater than the exact square. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $x^2$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\pm\\infty,m)=\\infty$\n    /// - $f(\\pm0.0,m)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::square_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// [`Float::square`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input is not high enough to represent the\n    /// output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (square, o) = Float::from(PI).square_round(Floor);\n    /// assert_eq!(square.to_string(), \"9.86960440108935\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (square, o) = Float::from(PI).square_round(Ceiling);\n    /// assert_eq!(square.to_string(), \"9.86960440108936\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_round(Nearest);\n    /// assert_eq!(square.to_string(), \"9.86960440108936\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn square_round(self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.square_prec_round(prec, rm)\n    }\n\n    /// Squares a [`Float`], rounding the result with the specified rounding mode. The [`Float`] is\n    /// taken by reference. An [`Ordering`] is also returned, indicating whether the rounded square\n    /// is less than, equal to, or greater than the exact square. Although `NaN`s are not comparable\n    /// to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,m) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p+1}$, where $p$ is the precision of the input.\n    /// - If $x^2$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$, where $p$ is the precision of the input.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},m)=\\text{NaN}$\n    /// - $f(\\pm\\infty,m)=\\infty$\n    /// - $f(\\pm0.0,m)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is returned\n    ///   instead.\n    /// - If $f(x,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::square_prec_round_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using\n    /// `(&Float).square()` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input is not high enough to represent the\n    /// output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (square, o) = Float::from(PI).square_round_ref(Floor);\n    /// assert_eq!(square.to_string(), \"9.86960440108935\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (square, o) = Float::from(PI).square_round_ref(Ceiling);\n    /// assert_eq!(square.to_string(), \"9.86960440108936\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (square, o) = Float::from(PI).square_round_ref(Nearest);\n    /// assert_eq!(square.to_string(), \"9.86960440108936\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn square_round_ref(&self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.square_prec_round_ref(prec, rm)\n    }\n\n    /// Squares a [`Float`] in place, rounding the result to the specified precision and with the\n    /// specified rounding mode. An [`Ordering`] is returned, indicating whether the rounded square\n    /// is less than, equal to, or greater than the exact square. Although `NaN`s are not comparable\n    /// to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also returns\n    /// `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |xy|\\rfloor-p+1}$.\n    /// - If $x^2$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::square_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::square_prec_assign`] instead.\n    /// If you know that your target precision is the precision of the input, consider using\n    /// [`Float::square_round_assign`] instead. If both of these things are true, consider using\n    /// [`Float::square_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact squaring;\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_round_assign(5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"9.5\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_round_assign(5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"10.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_round_assign(5, Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"10.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_round_assign(20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"9.8696\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_round_assign(20, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"9.86961\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_round_assign(20, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"9.8696\");\n    /// ```\n    #[inline]\n    pub fn square_prec_round_assign(&mut self, prec: u64, rm: RoundingMode) -> Ordering {\n        assert_ne!(prec, 0);\n        match self {\n            float_nan!() => Equal,\n            Self(Infinity { sign } | Zero { sign }) => {\n                *sign = true;\n                Equal\n            }\n            Self(Finite {\n                sign: x_sign,\n                exponent: x_exp,\n                precision: x_prec,\n                significand: x,\n            }) => {\n                let twice_exp = *x_exp << 1;\n                if twice_exp - 1 > Self::MAX_EXPONENT {\n                    assert!(rm != Exact, \"Inexact Float squaring\");\n                    return match rm {\n                        Ceiling | Up | Nearest => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        _ => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                    };\n                } else if twice_exp < Self::MIN_EXPONENT - 1 {\n                    assert!(rm != Exact, \"Inexact Float squaring\");\n                    return match rm {\n                        Floor | Down | Nearest => {\n                            *self = float_zero!();\n                            Less\n                        }\n                        _ => {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        }\n                    };\n                }\n                let (exp_offset, o) = square_float_significand_in_place(x, *x_prec, prec, rm);\n                *x_exp = x_exp\n                    .arithmetic_checked_shl(1u32)\n                    .unwrap()\n                    .checked_add(exp_offset)\n                    .unwrap();\n                if *x_exp > Self::MAX_EXPONENT {\n                    assert!(rm != Exact, \"Inexact Float squaring\");\n                    return match rm {\n                        Ceiling | Up | Nearest => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        _ => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                    };\n                } else if *x_exp < Self::MIN_EXPONENT {\n                    return if rm == Nearest\n                        && *x_exp == Self::MIN_EXPONENT - 1\n                        && (o == Less || !x.is_power_of_2())\n                    {\n                        {\n                            *self = Self::min_positive_value_prec(prec);\n                            Greater\n                        }\n                    } else {\n                        match rm {\n                            Exact => panic!(\"Inexact float squaring\"),\n                            Ceiling | Up => {\n                                *self = Self::min_positive_value_prec(prec);\n                                Greater\n                            }\n                            _ => {\n                                *self = float_zero!();\n                                Less\n                            }\n                        }\n                    };\n                }\n                *x_sign = true;\n                *x_prec = prec;\n                o\n            }\n        }\n    }\n\n    /// Squares a [`Float`] in place, rounding the result to the nearest value of the specified\n    /// precision. An [`Ordering`] is returned, indicating whether the rounded square is less than,\n    /// equal to, or greater than the exact square. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the square is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::square_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::square_prec_round_assign`] instead. If you know that your target precision is the\n    /// precision of the input, consider using [`Float::square`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n \\log n \\log\\log n + m)$\n    ///\n    /// $M(n, m) = O(n \\log n + m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_assign(5), Greater);\n    /// assert_eq!(x.to_string(), \"10.0\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_prec_assign(20), Less);\n    /// assert_eq!(x.to_string(), \"9.8696\");\n    /// ```\n    #[inline]\n    pub fn square_prec_assign(&mut self, prec: u64) -> Ordering {\n        self.square_prec_round_assign(prec, Nearest)\n    }\n\n    /// Squares a [`Float`] in place, rounding the result with the specified rounding mode. An\n    /// [`Ordering`] is returned, indicating whether the rounded square is less than, equal to, or\n    /// greater than the exact square. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input. See [`RoundingMode`] for a\n    /// description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x^2$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the precision of the input.\n    ///\n    /// See the [`Float::square_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::square_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using [`Float::square_assign`] instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input is not high enough to represent the\n    /// output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_round_assign(Floor), Less);\n    /// assert_eq!(x.to_string(), \"9.86960440108935\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_round_assign(Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"9.86960440108936\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.square_round_assign(Nearest), Greater);\n    /// assert_eq!(x.to_string(), \"9.86960440108936\");\n    /// ```\n    #[inline]\n    pub fn square_round_assign(&mut self, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.square_prec_round_assign(prec, rm)\n    }\n}\n\nimpl Square for Float {\n    type Output = Self;\n\n    /// Squares a [`Float`], taking it by value.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the square is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\pm\\infty)=\\infty$\n    /// - $f(\\pm0.0)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::square_prec`] instead. If you want to specify the output precision, consider using\n    /// [`Float::square_round`]. If you want both of these things, consider using\n    /// [`Float::square_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!(Float::NAN.square().is_nan());\n    /// assert_eq!(Float::INFINITY.square(), Float::INFINITY);\n    /// assert_eq!(Float::NEGATIVE_INFINITY.square(), Float::INFINITY);\n    /// assert_eq!(Float::from(1.5).square(), 2.0);\n    /// assert_eq!(Float::from(-1.5).square(), 2.0);\n    /// ```\n    #[inline]\n    fn square(self) -> Self {\n        let prec = self.significant_bits();\n        self.square_prec_round(prec, Nearest).0\n    }\n}\n\nimpl Square for &Float {\n    type Output = Float;\n\n    /// Squares a [`Float`], taking it by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the square is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x) = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN})=\\text{NaN}$\n    /// - $f(\\pm\\infty)=\\infty$\n    /// - $f(\\pm0.0)=0.0$\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::square_prec_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::square_round_ref`]. If you want both of these things, consider using\n    /// [`Float::square_prec_round_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::NAN).square().is_nan());\n    /// assert_eq!((&Float::INFINITY).square(), Float::INFINITY);\n    /// assert_eq!((&Float::NEGATIVE_INFINITY).square(), Float::INFINITY);\n    /// assert_eq!((&Float::from(1.5)).square(), 2.0);\n    /// assert_eq!((&Float::from(-1.5)).square(), 2.0);\n    /// ```\n    #[inline]\n    fn square(self) -> Float {\n        let prec = self.significant_bits();\n        self.square_prec_round_ref(prec, Nearest).0\n    }\n}\n\nimpl SquareAssign for Float {\n    /// Squares a [`Float`] in place.\n    ///\n    /// If the output has a precision, it is the precision of the input. If the square is\n    /// equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s in\n    /// its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x^2+\\varepsilon.\n    /// $$\n    /// - If $x^2$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x^2$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x^2|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the [`Float::square`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::square_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::square_round_assign`]. If you want both of these things, consider using\n    /// [`Float::square_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SquareAssign;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::NAN;\n    /// x.square_assign();\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x.square_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x.square_assign();\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x.square_assign();\n    /// assert_eq!(x, 2.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x.square_assign();\n    /// assert_eq!(x, 2.0);\n    /// ```\n    #[inline]\n    fn square_assign(&mut self) {\n        let prec = self.significant_bits();\n        self.square_prec_round_assign(prec, Nearest);\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 2001, 2003-2022 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Infinity, NaN, Zero};\nuse crate::{\n    Float, float_infinity, float_nan, float_negative_infinity, float_negative_zero, float_zero,\n};\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse core::ops::{Sub, SubAssign};\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase2, NegAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\n// x and y must be finite, nonzero, and not equal\nfn float_rational_diff_exponent_range(x: &Float, y: &Rational) -> (i64, i64) {\n    let log_x_abs = i64::from(x.get_exponent().unwrap() - 1);\n    let log_y_abs = y.floor_log_base_2_abs();\n    let m = max(log_x_abs, log_y_abs);\n    if (*x > 0) != (*y > 0) {\n        (m, m + 1)\n    } else if log_x_abs.abs_diff(log_y_abs) > 1 {\n        (m - 1, m)\n    } else {\n        let mut log_x_denominator = i64::exact_from(x.get_prec().unwrap())\n            .saturating_sub(log_x_abs)\n            .saturating_sub(1);\n        if log_x_denominator < 0 {\n            log_x_denominator = 0;\n        }\n        let log_y_denominator = i64::exact_from(y.denominator_ref().ceiling_log_base_2());\n        let min_exp = log_x_denominator\n            .checked_neg()\n            .unwrap()\n            .checked_sub(log_y_denominator)\n            .unwrap();\n        if log_x_abs == log_y_abs {\n            (min_exp, m - 1)\n        } else {\n            (min_exp, m)\n        }\n    }\n}\n\n// x and y must be finite, nonzero, and not sum to zero\nfn float_rational_diff_sign(x: &Float, y: &Rational) -> bool {\n    match ((*x > 0), (*y < 0)) {\n        (true, true) => true,\n        (false, false) => false,\n        _ => {\n            if x.gt_abs(y) {\n                *x > 0\n            } else {\n                *y < 0\n            }\n        }\n    }\n}\n\nfn sub_rational_prec_round_naive_ref_val(\n    x: &Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (x @ Float(NaN | Infinity { .. }), _) => (x.clone(), Equal),\n        (float_negative_zero!(), y) => {\n            if y == 0u32 {\n                (float_negative_zero!(), Equal)\n            } else {\n                Float::from_rational_prec_round(-y, prec, rm)\n            }\n        }\n        (float_zero!(), y) => Float::from_rational_prec_round(-y, prec, rm),\n        (x, y) => {\n            let (mut sum, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) - y, prec, rm);\n            if rm == Floor && sum == 0u32 {\n                sum.neg_assign();\n            }\n            (sum, o)\n        }\n    }\n}\n\nfn sub_rational_prec_round_naive_ref_ref(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (x @ Float(NaN | Infinity { .. }), _) => (x.clone(), Equal),\n        (float_negative_zero!(), y) => {\n            if *y == 0u32 {\n                (float_negative_zero!(), Equal)\n            } else {\n                let (f, o) = Float::from_rational_prec_round_ref(y, prec, -rm);\n                (-f, o.reverse())\n            }\n        }\n        (float_zero!(), y) => {\n            let (f, o) = Float::from_rational_prec_round_ref(y, prec, -rm);\n            (-f, o.reverse())\n        }\n        (x, y) => {\n            let (mut sum, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) - y, prec, rm);\n            if rm == Floor && sum == 0u32 {\n                sum.neg_assign();\n            }\n            (sum, o)\n        }\n    }\n}\n\nimpl Float {\n    /// Subtracts two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. Both [`Float`]s are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded difference is less than, equal to, or greater than\n    /// the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,\\infty,p,m)=f(-\\infty,-\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p,m)=0.0$\n    /// - $f(-0.0,0.0,p,m)=-0.0$\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_prec`] instead. If you\n    /// know that your target precision is the maximum of the precisions of the two inputs, consider\n    /// using [`Float::sub_round`] instead. If both of these things are true, consider using `-`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round(Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round(Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.44\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round(Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round(Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round(Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.4233112\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round(Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec_round(mut self, other: Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.sub_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. The first [`Float`] is taken by value and the second by reference.\n    /// An [`Ordering`] is also returned, indicating whether the rounded difference is less than,\n    /// equal to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,\\infty,p,m)=f(-\\infty,-\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p,m)=0.0$\n    /// - $f(-0.0,0.0,p,m)=-0.0$\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_prec_val_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::sub_round_val_ref`] instead. If both of these things are true,\n    /// consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_val_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_val_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.44\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_val_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_val_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_val_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.4233112\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_val_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec_round_val_ref(\n        mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.sub_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. The first [`Float`] is taken by reference and the second by value.\n    /// An [`Ordering`] is also returned, indicating whether the rounded difference is less than,\n    /// equal to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,\\infty,p,m)=f(-\\infty,-\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p,m)=0.0$\n    /// - $f(-0.0,0.0,p,m)=-0.0$\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_prec_ref_val`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::sub_round_ref_val`] instead. If both of these things are true,\n    /// consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_val(Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_val(Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.44\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_val(Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_val(Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_val(Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.4233112\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_val(Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec_round_ref_val(\n        &self,\n        other: Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        self.add_prec_round_ref_val(-other, prec, rm)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result to the specified precision and with the\n    /// specified rounding mode. Both [`Float`]s are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded difference is less than, equal to, or greater than\n    /// the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=f(x,\\text{NaN},p,m)=f(\\infty,\\infty,p,m)=f(-\\infty,-\\infty,p,m)=\n    ///   \\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p,m)=0.0$\n    /// - $f(-0.0,0.0,p,m)=-0.0$\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p,m)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_prec_ref_ref`] instead.\n    /// If you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::sub_round_ref_ref`] instead. If both of these things are true,\n    /// consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_ref(&Float::from(E), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_ref(&Float::from(E), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.44\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_ref(&Float::from(E), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_ref(&Float::from(E), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_ref(&Float::from(E), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"0.4233112\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_round_ref_ref(&Float::from(E), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec_round_ref_ref(\n        &self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        self.add_prec_round_ref_ref_helper(other, prec, rm, true)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. Both [`Float`]s are taken by value. An [`Ordering`] is also returned, indicating\n    /// whether the rounded difference is less than, equal to, or greater than the exact difference.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN`\n    /// it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,\\infty,p)=f(-\\infty,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p)=0.0$\n    /// - $f(-0.0,0.0,p)=-0.0$\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_round`] instead. If you know that your target precision is the maximum of\n    /// the precisions of the two inputs, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec(Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec(Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec(self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.sub_prec_round(other, prec, Nearest)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. The first [`Float`] is taken by value and the second by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded difference is less than, equal\n    /// to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,\\infty,p)=f(-\\infty,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p)=0.0$\n    /// - $f(-0.0,0.0,p)=-0.0$\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_round_val_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_val_ref(&Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_val_ref(&Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec_val_ref(self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.sub_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. The first [`Float`] is taken by reference and the second by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded difference is less than, equal\n    /// to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,\\infty,p)=f(-\\infty,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p)=0.0$\n    /// - $f(-0.0,0.0,p)=-0.0$\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_round_ref_val`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_ref_val(Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_ref_val(Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec_ref_val(&self, other: Self, prec: u64) -> (Self, Ordering) {\n        self.sub_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result to the nearest value of the specified\n    /// precision. Both [`Float`]s are taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the rounded difference is less than, equal to, or greater than the exact\n    /// difference. Although `NaN`s are not comparable to any [`Float`], whenever this function\n    /// returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=f(x,\\text{NaN},p)=f(\\infty,\\infty,p)=f(-\\infty,-\\infty,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,p)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,p)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,p)=0.0$\n    /// - $f(-0.0,0.0,p)=-0.0$\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,p)=f(-0.0,-0.0,p,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,p)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_round_ref_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_ref_ref(&Float::from(E), 5);\n    /// assert_eq!(sum.to_string(), \"0.42\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_prec_ref_ref(&Float::from(E), 20);\n    /// assert_eq!(sum.to_string(), \"0.4233108\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        self.sub_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result with the specified rounding mode. Both\n    /// [`Float`]s are taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// rounded difference is less than, equal to, or greater than the exact difference. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,\\infty,m)=f(-\\infty,-\\infty,m)= \\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,m)=0.0$\n    /// - $f(-0.0,0.0,m)=-0.0$\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sub_prec_round`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `-`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round(Float::from(-E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round(Float::from(-E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round(Float::from(-E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_round(self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        Self::sub_prec_round(self, other, prec, rm)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result with the specified rounding mode. The\n    /// [`Float`] is taken by value and the [`Rational`] by reference. An [`Ordering`] is also\n    /// returned, indicating whether the rounded difference is less than, equal to, or greater than\n    /// the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,\\infty,m)=f(-\\infty,-\\infty,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,m)=0.0$\n    /// - $f(-0.0,0.0,m)=-0.0$\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sub_prec_round_val_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `-`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_val_ref(&Float::from(-E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_val_ref(&Float::from(-E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_val_ref(&Float::from(-E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_round_val_ref(self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result with the specified rounding mode. The\n    /// [`Float`] is taken by reference and the [`Rational`] by value. An [`Ordering`] is also\n    /// returned, indicating whether the rounded difference is less than, equal to, or greater than\n    /// the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,\\infty,m)=f(-\\infty,-\\infty,m)= \\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,m)=0.0$\n    /// - $f(-0.0,0.0,m)=-0.0$\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sub_prec_round_ref_val`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `-`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_ref_val(Float::from(-E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_ref_val(Float::from(-E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_ref_val(Float::from(-E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_round_ref_val(&self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Subtracts two [`Float`]s, rounding the result with the specified rounding mode. Both\n    /// [`Float`]s are taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// rounded difference is less than, equal to, or greater than the exact difference. Although\n    /// `NaN`s are not comparable to any [`Float`], whenever this function returns a `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=f(x,\\text{NaN},m)=f(\\infty,\\infty,m)=f(-\\infty,-\\infty,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0,m)=0.0$\n    /// - $f(-0.0,0.0,m)=-0.0$\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=0.0$ if $m$ is not `Floor`\n    /// - $f(0.0,0.0,m)=f(-0.0,-0.0,m)=-0.0$ if $m$ is `Floor`\n    /// - $f(x,x,m)=0.0$ if $x$ is finite and nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is finite and nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sub_prec_round_ref_ref`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `-`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_ref_ref(&Float::from(-E), Floor);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_ref_ref(&Float::from(-E), Ceiling);\n    /// assert_eq!(sum.to_string(), \"5.859874482048839\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_round_ref_ref(&Float::from(-E), Nearest);\n    /// assert_eq!(sum.to_string(), \"5.859874482048838\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_round_ref_ref(&self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Subtracts a [`Float`] by a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Float`] on the right-hand side is\n    /// taken by value. An [`Ordering`] is returned, indicating whether the rounded difference is\n    /// less than, equal to, or greater than the exact difference. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_prec_assign`] instead. If\n    /// you know that your target precision is the maximum of the precisions of the two inputs,\n    /// consider using [`Float::sub_round_assign`] instead. If both of these things are true,\n    /// consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_round_assign(Float::from(E), 5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.42\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_round_assign(Float::from(E), 5, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.44\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_round_assign(Float::from(E), 5, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"0.42\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_round_assign(Float::from(E), 20, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.4233108\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_prec_round_assign(Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"0.4233112\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_round_assign(Float::from(E), 20, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"0.4233108\");\n    /// ```\n    #[inline]\n    pub fn sub_prec_round_assign(&mut self, other: Self, prec: u64, rm: RoundingMode) -> Ordering {\n        self.add_prec_round_assign_helper(other, prec, rm, true)\n    }\n\n    /// Subtracts a [`Float`] by a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Float`] on the right-hand side is\n    /// taken by reference. An [`Ordering`] is returned, indicating whether the rounded difference\n    /// is less than, equal to, or greater than the exact difference. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function sets the [`Float`] to `NaN` it also\n    /// returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_prec_round`] documentation for information on special cases, overflow,\n    /// and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_prec_assign_ref`]\n    /// instead. If you know that your target precision is the maximum of the precisions of the two\n    /// inputs, consider using [`Float::sub_round_assign`] instead. If both of these things are\n    /// true, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_round_assign_ref(&Float::from(E), 5, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.42\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_prec_round_assign_ref(&Float::from(E), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"0.44\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_prec_round_assign_ref(&Float::from(E), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"0.42\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_prec_round_assign_ref(&Float::from(E), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"0.4233108\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_prec_round_assign_ref(&Float::from(E), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"0.4233112\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_prec_round_assign_ref(&Float::from(E), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"0.4233108\");\n    /// ```\n    #[inline]\n    pub fn sub_prec_round_assign_ref(\n        &mut self,\n        other: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        self.add_prec_round_assign_ref_helper(other, prec, rm, true)\n    }\n\n    /// Subtracts a [`Float`] by a [`Float`] in place, rounding the result to the nearest value of\n    /// the specified precision. The [`Float`] on the right-hand side is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the rounded difference is less than, equal to,\n    /// or greater than the exact difference. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_round_assign`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_assign(Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"0.42\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_assign(Float::from(E), 20), Less);\n    /// assert_eq!(x.to_string(), \"0.4233108\");\n    /// ```\n    #[inline]\n    pub fn sub_prec_assign(&mut self, other: Self, prec: u64) -> Ordering {\n        self.sub_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Float`] by a [`Float`] in place, rounding the result to the nearest value of\n    /// the specified precision. The [`Float`] on the right-hand side is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded difference is less than, equal to,\n    /// or greater than the exact difference. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_prec`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_round_assign_ref`] instead. If you know that your target precision is the\n    /// maximum of the precisions of the two inputs, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_assign_ref(&Float::from(E), 5), Less);\n    /// assert_eq!(x.to_string(), \"0.42\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_prec_assign_ref(&Float::from(E), 20), Less);\n    /// assert_eq!(x.to_string(), \"0.4233108\");\n    /// ```\n    #[inline]\n    pub fn sub_prec_assign_ref(&mut self, other: &Self, prec: u64) -> Ordering {\n        self.sub_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Float`] by a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. The [`Float`] on the right-hand side is taken by value. An [`Ordering`] is\n    /// returned, indicating whether the rounded difference is less than, equal to, or greater than\n    /// the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::sub_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using [`Float::sub_prec_round_assign`]\n    /// instead. If you know you'll be using the `Nearest` rounding mode, consider using `-=`\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_round_assign(Float::from(-E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_round_assign(Float::from(-E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"5.859874482048839\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_round_assign(Float::from(-E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    /// ```\n    #[inline]\n    pub fn sub_round_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_assign(other, prec, rm)\n    }\n\n    /// Subtracts a [`Float`] by a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. The [`Float`] on the right-hand side is taken by reference. An [`Ordering`]\n    /// is returned, indicating whether the rounded difference is less than, equal to, or greater\n    /// than the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the maximum of the precision of the inputs. See\n    /// [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the maximum precision of the inputs.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the maximum precision of the inputs.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs.\n    ///\n    /// See the [`Float::sub_round`] documentation for information on special cases, overflow, and\n    /// underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::sub_prec_round_assign_ref`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the maximum precision of the inputs is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::{E, PI};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_round_assign_ref(&Float::from(-E), Floor), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_round_assign_ref(&Float::from(-E), Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"5.859874482048839\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(x.sub_round_assign_ref(&Float::from(-E), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"5.859874482048838\");\n    /// ```\n    #[inline]\n    pub fn sub_round_assign_ref(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_assign_ref(other, prec, rm)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by\n    /// value. An [`Ordering`] is also returned, indicating whether the rounded difference is less\n    /// than, equal to, or greater than the exact difference. Although `NaN`s are not comparable to\n    /// any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_rational_prec`] instead.\n    /// If you know that your target precision is the precision of the [`Float`] input, consider\n    /// using [`Float::sub_rational_round`] instead. If both of these things are true, consider\n    /// using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Floor);\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Ceiling);\n    /// assert_eq!(sum.to_string(), \"2.9\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_prec_round(Rational::from_unsigneds(1u8, 3), 5, Nearest);\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Floor);\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Ceiling);\n    /// assert_eq!(sum.to_string(), \"2.808262\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_prec_round(Rational::from_unsigneds(1u8, 3), 20, Nearest);\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_round(\n        mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.sub_rational_prec_round_assign(other, prec, rm);\n        (self, o)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by value and the [`Rational`] by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded difference is\n    /// less than, equal to, or greater than the exact difference. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_rational_prec_val_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::sub_rational_round_val_ref`] instead. If both of these things are\n    /// true, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.9\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808262\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_val_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_round_val_ref(\n        mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let o = self.sub_rational_prec_round_assign_ref(other, prec, rm);\n        (self, o)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] is taken by reference and the [`Rational`]\n    /// by value. An [`Ordering`] is also returned, indicating whether the rounded difference is\n    /// less than, equal to, or greater than the exact difference. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_rational_prec_ref_val`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::sub_rational_round_ref_val`] instead. If both of these things are\n    /// true, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.9\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808262\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_val(\n    ///     Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_round_ref_val(\n        &self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _) => (float_nan!(), Equal),\n            (float_infinity!(), _) => (float_infinity!(), Equal),\n            (float_negative_infinity!(), _) => (float_negative_infinity!(), Equal),\n            (float_negative_zero!(), y) => {\n                let (diff, o) = Self::from_rational_prec_round(y, prec, -rm);\n                (-diff, o.reverse())\n            }\n            (float_zero!(), y) => {\n                if y == 0u32 {\n                    (float_zero!(), Equal)\n                } else {\n                    let (diff, o) = Self::from_rational_prec_round(y, prec, -rm);\n                    (-diff, o.reverse())\n                }\n            }\n            (_, y) if y == 0 => Self::from_float_prec_round_ref(self, prec, rm),\n            (x, y) => {\n                if *x == y {\n                    return (\n                        if rm == Floor {\n                            float_negative_zero!()\n                        } else {\n                            float_zero!()\n                        },\n                        Equal,\n                    );\n                }\n                let (min_exponent, max_exponent) = float_rational_diff_exponent_range(x, &y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float subtraction\");\n                    return match (float_rational_diff_sign(x, &y), rm) {\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    return sub_rational_prec_round_naive_ref_val(x, y, prec, rm);\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                // working_prec grows as O([(1 + sqrt(3)) / 2] ^ n) ≈ O(1.366 ^ n).\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(&y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can subtract it directly!\n                        return self.sub_prec_round_ref_val(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let mut t = x.sub_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            let o = t.set_prec_round(prec, rm);\n                            return (t, o);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the specified precision and\n    /// with the specified rounding mode. The [`Float`] and the [`Rational`] are both taken by\n    /// reference. An [`Ordering`] is also returned, indicating whether the rounded difference is\n    /// less than, equal to, or greater than the exact difference. Although `NaN`s are not\n    /// comparable to any [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,p,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p,m)=\\text{NaN}$\n    /// - $f(\\infty,x,p,m)=\\infty$\n    /// - $f(-\\infty,x,p,m)=-\\infty$\n    /// - $f(0.0,0,p,m)=0.0$\n    /// - $f(-0.0,0,p,m)=-0.0$\n    /// - $f(x,x,p,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,p,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,p,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`,\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,p,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_rational_prec_ref_ref`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::sub_rational_round_ref_ref`] instead. If both of these things are\n    /// true, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.9\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     5,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.8\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Floor,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Ceiling,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808262\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_round_ref_ref(\n    ///     &Rational::from_unsigneds(1u8, 3),\n    ///     20,\n    ///     Nearest,\n    /// );\n    /// assert_eq!(sum.to_string(), \"2.808258\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_round_ref_ref(\n        &self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        match (self, other) {\n            (float_nan!(), _) => (float_nan!(), Equal),\n            (float_infinity!(), _) => (float_infinity!(), Equal),\n            (float_negative_infinity!(), _) => (float_negative_infinity!(), Equal),\n            (float_negative_zero!(), y) => {\n                let (diff, o) = Self::from_rational_prec_round_ref(y, prec, -rm);\n                (-diff, o.reverse())\n            }\n            (float_zero!(), y) => {\n                if *y == 0u32 {\n                    (float_zero!(), Equal)\n                } else {\n                    let (diff, o) = Self::from_rational_prec_round_ref(y, prec, -rm);\n                    (-diff, o.reverse())\n                }\n            }\n            (_, y) if *y == 0 => Self::from_float_prec_round_ref(self, prec, rm),\n            (x, y) => {\n                if x == y {\n                    return (\n                        if rm == Floor {\n                            float_negative_zero!()\n                        } else {\n                            float_zero!()\n                        },\n                        Equal,\n                    );\n                }\n                let (min_exponent, max_exponent) = float_rational_diff_exponent_range(x, y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float subtraction\");\n                    return match (float_rational_diff_sign(x, y), rm) {\n                        (true, Ceiling | Up | Nearest) => (float_infinity!(), Greater),\n                        (true, _) => (Self::max_finite_value_with_prec(prec), Less),\n                        (false, Floor | Up | Nearest) => (float_negative_infinity!(), Less),\n                        (false, _) => (-Self::max_finite_value_with_prec(prec), Greater),\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    return sub_rational_prec_round_naive_ref_ref(x, y, prec, rm);\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                // working_prec grows as O([(1 + sqrt(3)) / 2] ^ n) ≈ O(1.366 ^ n).\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can subtract it directly!\n                        return self.sub_prec_round_ref_val(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let mut t = x.sub_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            let o = t.set_prec_round(prec, rm);\n                            return (t, o);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded difference is less than, equal\n    /// to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_round`] instead. If you know that your target precision is the\n    /// precision of the [`Float`] input, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec(Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"1.62\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec(Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"1.641592\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec(self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.sub_rational_prec_round(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by value and the [`Rational`] by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded difference is less than, equal\n    /// to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_round_val_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_val_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"1.62\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_val_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"1.641592\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_val_ref(self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.sub_rational_prec_round_val_ref(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] is taken by reference and the [`Rational`] by value. An\n    /// [`Ordering`] is also returned, indicating whether the rounded difference is less than, equal\n    /// to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_round_ref_val`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_ref_val(Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"1.62\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_ref_val(Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"1.641592\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_ref_val(&self, other: Rational, prec: u64) -> (Self, Ordering) {\n        self.sub_rational_prec_round_ref_val(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result to the nearest value of the\n    /// specified precision. The [`Float`] and the [`Rational`] are both are taken by reference. An\n    /// [`Ordering`] is also returned, indicating whether the rounded difference is less than, equal\n    /// to, or greater than the exact difference. Although `NaN`s are not comparable to any\n    /// [`Float`], whenever this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y,p) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,p)=\\text{NaN}$\n    /// - $f(\\infty,x,p)=\\infty$\n    /// - $f(-\\infty,x,p)=-\\infty$\n    /// - $f(0.0,0,p)=0.0$\n    /// - $f(-0.0,0,p)=-0.0$\n    /// - $f(x,x,p)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y,p)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y,p)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,p)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,p)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,p)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_round_ref_ref`] instead. If you know that your target precision\n    /// is the precision of the [`Float`] input, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_ref_ref(&Rational::exact_from(1.5), 5);\n    /// assert_eq!(sum.to_string(), \"1.62\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_prec_ref_ref(&Rational::exact_from(1.5), 20);\n    /// assert_eq!(sum.to_string(), \"1.641592\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_ref_ref(&self, other: &Rational, prec: u64) -> (Self, Ordering) {\n        self.sub_rational_prec_round_ref_ref(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] and the [`Rational`] are both are taken by value. An [`Ordering`] is\n    /// also returned, indicating whether the rounded difference is less than, equal to, or greater\n    /// than the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(x,0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x,m)=f(-0.0,x,m)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::sub_rational_prec_round`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) = Float::from(PI).sub_rational_round(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"2.808259320256457\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sub_rational_round(self, other: Rational, rm: RoundingMode) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round(other, prec, rm)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] is taken by value and the [`Rational`] by reference. An [`Ordering`] is\n    /// also returned, indicating whether the rounded difference is less than, equal to, or greater\n    /// than the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(x,0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x,m)=f(-0.0,x,m)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::sub_rational_prec_round_val_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"2.808259320256457\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_val_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sub_rational_round_val_ref(\n        self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_val_ref(other, prec, rm)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] is taken by reference and the [`Rational`] by value. An [`Ordering`] is\n    /// also returned, indicating whether the rounded difference is less than, equal to, or greater\n    /// than the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(x,0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x,m)=f(-0.0,x,m)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::sub_rational_prec_round_ref_val`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"2.808259320256457\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_ref_val(Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sub_rational_round_ref_val(\n        &self,\n        other: Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_ref_val(other, prec, rm)\n    }\n\n    /// Subtracts a [`Float`] by a [`Rational`], rounding the result with the specified rounding\n    /// mode. The [`Float`] and the [`Rational`] are both are taken by reference. An [`Ordering`] is\n    /// also returned, indicating whether the rounded difference is less than, equal to, or greater\n    /// than the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever\n    /// this function returns a `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the [`Float`] input. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// f(x,y,m) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the [`Float`] input.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x,m)=\\text{NaN}$\n    /// - $f(\\infty,x,m)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x,m)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,0,m)=0.0$\n    /// - $f(-0.0,0,m)=-0.0$\n    /// - $f(x,0,m)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x,m)=f(-0.0,x,m)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x,m)=0.0$ if $x$ is nonzero and $m$ is not `Floor`\n    /// - $f(x,x,m)=-0.0$ if $x$ is nonzero and $m$ is `Floor`\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling`, `Up`, or `Nearest`, $\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor` or `Down`, $(1-(1/2)^p)2^{2^{30}-1}$ is\n    ///   returned instead, where `p` is the precision of the input.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Floor`, `Up`, or `Nearest`, $-\\infty$ is\n    ///   returned instead.\n    /// - If $f(x,y,m)\\geq 2^{2^{30}-1}$ and $m$ is `Ceiling` or `Down`, $-(1-(1/2)^p)2^{2^{30}-1}$\n    ///   is returned instead, where `p` is the precision of the input.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Floor` or `Down`, $0.0$ is returned instead.\n    /// - If $0<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Ceiling` or `Up`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $0<f(x,y,m)\\leq2^{-2^{30}-1}$, and $m$ is `Nearest`, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y,m)<2^{-2^{30}}$, and $m$ is `Nearest`, $2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Ceiling` or `Down`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<0$, and $m$ is `Floor` or `Up`, $-2^{-2^{30}}$ is returned\n    ///   instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y,m)<0$, and $m$ is `Nearest`, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y,m)<-2^{-2^{30}-1}$, and $m$ is `Nearest`, $-2^{-2^{30}}$ is\n    ///   returned instead.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::sub_rational_prec_round_ref_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `-` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the [`Float`] input is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Floor);\n    /// assert_eq!(sum.to_string(), \"2.808259320256457\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Ceiling);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sum, o) =\n    ///     Float::from(PI).sub_rational_round_ref_ref(&Rational::from_unsigneds(1u8, 3), Nearest);\n    /// assert_eq!(sum.to_string(), \"2.808259320256461\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sub_rational_round_ref_ref(\n        &self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_ref_ref(other, prec, rm)\n    }\n\n    /// Subtracts a [`Rational`] by a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Rational`] is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the rounded difference is less than, equal to,\n    /// or greater than the exact difference. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using [`Float::sub_rational_prec_assign`]\n    /// instead. If you know that your target precision is the precision of the [`Float`] input,\n    /// consider using [`Float::sub_rational_round_assign`] instead. If both of these things are\n    /// true, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.9\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808258\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808262\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign(Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808258\");\n    /// ```\n    ///\n    /// This is mpfr_sub_q from gmp_op.c, MPFR 4.2.0.\n    #[inline]\n    pub fn sub_rational_prec_round_assign(\n        &mut self,\n        other: Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (Self(NaN | Infinity { .. }), _) => Equal,\n            (float_negative_zero!(), y) => {\n                let o;\n                (*self, o) = Self::from_rational_prec_round(y, prec, -rm);\n                self.neg_assign();\n                o.reverse()\n            }\n            (float_zero!(), y) => {\n                if y == 0u32 {\n                    Equal\n                } else {\n                    let o;\n                    (*self, o) = Self::from_rational_prec_round(y, prec, -rm);\n                    self.neg_assign();\n                    o.reverse()\n                }\n            }\n            (_, y) if y == 0 => self.set_prec_round(prec, rm),\n            (x, y) => {\n                if *x == y {\n                    *self = if rm == Floor {\n                        float_negative_zero!()\n                    } else {\n                        float_zero!()\n                    };\n                    return Equal;\n                }\n                let (min_exponent, max_exponent) = float_rational_diff_exponent_range(x, &y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float subtraction\");\n                    return match (float_rational_diff_sign(x, &y), rm) {\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    let (diff, o) = sub_rational_prec_round_naive_ref_val(&*x, y, prec, rm);\n                    *self = diff;\n                    return o;\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                // working_prec grows as O([(1 + sqrt(3)) / 2] ^ n) ≈ O(1.366 ^ n).\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(&y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can subtract it directly!\n                        return self.sub_prec_round_assign(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let t = x.sub_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            *self = t;\n                            return self.set_prec_round(prec, rm);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Subtracts a [`Rational`] by a [`Float`] in place, rounding the result to the specified\n    /// precision and with the specified rounding mode. The [`Rational`] is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the rounded difference is less than, equal to,\n    /// or greater than the exact difference. Although `NaN`s are not comparable to any [`Float`],\n    /// whenever this function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// See [`RoundingMode`] for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$.\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_rational_prec_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you know you'll be using `Nearest`, consider using\n    /// [`Float::sub_rational_prec_assign_ref`] instead. If you know that your target precision is\n    /// the precision of the [`Float`] input, consider using\n    /// [`Float::sub_rational_round_assign_ref`] instead. If both of these things are true, consider\n    /// using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but `prec` is too small for an exact subtraction.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.9\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 5, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.8\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808258\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808262\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_round_assign_ref(&Rational::from_unsigneds(1u8, 3), 20, Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808258\");\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> Ordering {\n        assert_ne!(prec, 0);\n        match (&mut *self, other) {\n            (Self(NaN | Infinity { .. }), _) => Equal,\n            (float_negative_zero!(), y) => {\n                let o;\n                (*self, o) = Self::from_rational_prec_round_ref(y, prec, -rm);\n                self.neg_assign();\n                o.reverse()\n            }\n            (float_zero!(), y) => {\n                if *y == 0u32 {\n                    Equal\n                } else {\n                    let o;\n                    (*self, o) = Self::from_rational_prec_round_ref(y, prec, -rm);\n                    self.neg_assign();\n                    o.reverse()\n                }\n            }\n            (_, y) if *y == 0 => self.set_prec_round(prec, rm),\n            (x, y) => {\n                if *x == *y {\n                    *self = if rm == Floor {\n                        float_negative_zero!()\n                    } else {\n                        float_zero!()\n                    };\n                    return Equal;\n                }\n                let (min_exponent, max_exponent) = float_rational_diff_exponent_range(x, y);\n                if min_exponent >= i64::from(Self::MAX_EXPONENT) {\n                    assert!(rm != Exact, \"Inexact Float subtraction\");\n                    return match (float_rational_diff_sign(x, y), rm) {\n                        (true, Ceiling | Up | Nearest) => {\n                            *self = float_infinity!();\n                            Greater\n                        }\n                        (true, _) => {\n                            *self = Self::max_finite_value_with_prec(prec);\n                            Less\n                        }\n                        (false, Floor | Up | Nearest) => {\n                            *self = float_negative_infinity!();\n                            Less\n                        }\n                        (false, _) => {\n                            *self = -Self::max_finite_value_with_prec(prec);\n                            Greater\n                        }\n                    };\n                }\n                if max_exponent > i64::from(Self::MAX_EXPONENT) - 2\n                    || min_exponent < i64::from(Self::MIN_EXPONENT - 2)\n                {\n                    // If we can't rule out overflow or underflow, use slow-but-correct naive\n                    // algorithm.\n                    let (diff, o) = sub_rational_prec_round_naive_ref_ref(&*x, y, prec, rm);\n                    *self = diff;\n                    return o;\n                }\n                let mut working_prec = prec + 10;\n                let mut increment = Limb::WIDTH;\n                // working_prec grows as O([(1 + sqrt(3)) / 2] ^ n) ≈ O(1.366 ^ n).\n                loop {\n                    // Error <= 1/2 ulp(q)\n                    let (q, o) = Self::from_rational_prec_ref(y, working_prec);\n                    if o == Equal {\n                        // Result is exact so we can subtract it directly!\n                        return self.sub_prec_round_assign(q, prec, rm);\n                    }\n                    let q_exp = q.get_exponent().unwrap();\n                    let t = x.sub_prec_ref_val(q, working_prec).0;\n                    // Error on t is <= 1/2 ulp(t).\n                    // ```\n                    // Error / ulp(t)      <= 1/2 + 1/2 * 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)>0, <= 2^(EXP(q)-EXP(t)-1)*(1+2^-(EXP(q)-EXP(t)))\n                    //                     <= 2^(EXP(q)-EXP(t))\n                    // If EXP(q)-EXP(t)<0, <= 2^0\n                    // ```\n                    // We can get 0, but we can't round since q is inexact\n                    if t != 0 {\n                        let m = u64::saturating_from(q_exp - t.get_exponent().unwrap())\n                            .checked_add(1)\n                            .unwrap();\n                        if working_prec >= m\n                            && float_can_round(\n                                t.significand_ref().unwrap(),\n                                working_prec - m,\n                                prec,\n                                rm,\n                            )\n                        {\n                            *self = t;\n                            return self.set_prec_round(prec, rm);\n                        }\n                    }\n                    working_prec += increment;\n                    increment = working_prec >> 1;\n                }\n            }\n        }\n    }\n\n    /// Subtracts a [`Rational`] by a [`Float`] in place, rounding the result to the nearest value\n    /// of the specified precision. The [`Rational`] is taken by value. An [`Ordering`] is returned,\n    /// indicating whether the rounded difference is less than, equal to, or greater than the exact\n    /// difference. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_rational_prec`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_round_assign`] instead. If you know that your target precision is\n    /// the maximum of the precisions of the two inputs, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_assign(Rational::exact_from(1.5), 5),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.62\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_assign(Rational::exact_from(1.5), 20),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.641592\");\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_assign(&mut self, other: Rational, prec: u64) -> Ordering {\n        self.sub_rational_prec_round_assign(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Rational`] by a [`Float`] in place, rounding the result to the nearest value\n    /// of the specified precision. The [`Rational`] is taken by reference. An [`Ordering`] is\n    /// returned, indicating whether the rounded difference is less than, equal to, or greater than\n    /// the exact difference. Although `NaN`s are not comparable to any [`Float`], whenever this\n    /// function sets the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// If the difference is equidistant from two [`Float`]s with the specified precision, the\n    /// [`Float`] with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a\n    /// description of the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$.\n    ///\n    /// If the output has a precision, it is `prec`.\n    ///\n    /// See the [`Float::sub_rational_prec_val_ref`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_round_assign_ref`] instead. If you know that your target\n    /// precision is the maximum of the precisions of the two inputs, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(other.significant_bits(),\n    /// prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_assign_ref(&Rational::exact_from(1.5), 5),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.62\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_prec_assign_ref(&Rational::exact_from(1.5), 20),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"1.641592\");\n    /// ```\n    #[inline]\n    pub fn sub_rational_prec_assign_ref(&mut self, other: &Rational, prec: u64) -> Ordering {\n        self.sub_rational_prec_round_assign_ref(other, prec, Nearest)\n    }\n\n    /// Subtracts a [`Rational`] by a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. The [`Rational`] is taken by value. An [`Ordering`] is returned, indicating\n    /// whether the rounded difference is less than, equal to, or greater than the exact difference.\n    /// Although `NaN`s are not comparable to any [`Float`], whenever this function sets the\n    /// [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::sub_rational_round`] documentation for information on special cases,\n    /// overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::sub_rational_prec_round_assign`] instead. If you know you'll be using the `Nearest`\n    /// rounding mode, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_round_assign(Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808259320256457\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_round_assign(Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808259320256461\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_round_assign(Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808259320256461\");\n    /// ```\n    #[inline]\n    pub fn sub_rational_round_assign(&mut self, other: Rational, rm: RoundingMode) -> Ordering {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_assign(other, prec, rm)\n    }\n\n    /// Subtracts a [`Rational`] by a [`Float`] in place, rounding the result with the specified\n    /// rounding mode. The [`Rational`] is taken by reference. An [`Ordering`] is returned,\n    /// indicating whether the rounded difference is less than, equal to, or greater than the exact\n    /// difference. Although `NaN`s are not comparable to any [`Float`], whenever this function sets\n    /// the [`Float`] to `NaN` it also returns `Equal`.\n    ///\n    /// The precision of the output is the precision of the input [`Float`]. See [`RoundingMode`]\n    /// for a description of the possible rounding modes.\n    ///\n    /// $$\n    /// x \\gets x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, and $m$ is not `Nearest`, then $|\\varepsilon| <\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p+1}$, where $p$ is the precision of the input [`Float`].\n    /// - If $x-y$ is finite and nonzero, and $m$ is `Nearest`, then $|\\varepsilon| \\leq\n    ///   2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$, where $p$ is the precision of the input [`Float`].\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`].\n    ///\n    /// See the [`Float::sub_rational_round_val_ref`] documentation for information on special\n    /// cases, overflow, and underflow.\n    ///\n    /// If you want to specify an output precision, consider using\n    /// [`Float::sub_rational_prec_round_assign_ref`] instead. If you know you'll be using the\n    /// `Nearest` rounding mode, consider using `-=` instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact` but the precision of the input [`Float`] is not high enough to\n    /// represent the output.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::f64::consts::PI;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Floor),\n    ///     Less\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808259320256457\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808259320256461\");\n    ///\n    /// let mut x = Float::from(PI);\n    /// assert_eq!(\n    ///     x.sub_rational_round_assign_ref(&Rational::from_unsigneds(1u8, 3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"2.808259320256461\");\n    /// ```\n    #[inline]\n    pub fn sub_rational_round_assign_ref(\n        &mut self,\n        other: &Rational,\n        rm: RoundingMode,\n    ) -> Ordering {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_assign_ref(other, prec, rm)\n    }\n}\n\nimpl Sub<Self> for Float {\n    type Output = Self;\n\n    /// Subtracts two [`Float`]s, taking both by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// difference is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,\\infty)=f(-\\infty,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0)=0.0$\n    /// - $f(-0.0,0.0)=-0.0$\n    /// - $f(0.0,0.0)=f(-0.0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x)=f(-0.0,x)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::sub_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::sub_round`].\n    /// If you want both of these things, consider using [`Float::sub_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) - Float::NAN).is_nan());\n    /// assert_eq!(Float::from(1.5) - Float::INFINITY, Float::NEGATIVE_INFINITY);\n    /// assert_eq!(Float::from(1.5) - Float::NEGATIVE_INFINITY, Float::INFINITY);\n    /// assert!((Float::INFINITY - Float::INFINITY).is_nan());\n    ///\n    /// assert_eq!(Float::from(1.5) - Float::from(2.5), -1.0);\n    /// assert_eq!(Float::from(1.5) - Float::from(-2.5), 4.0);\n    /// assert_eq!(Float::from(-1.5) - Float::from(2.5), -4.0);\n    /// assert_eq!(Float::from(-1.5) - Float::from(-2.5), 1.0);\n    /// ```\n    ///\n    #[inline]\n    fn sub(self, other: Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Sub<&Self> for Float {\n    type Output = Self;\n\n    /// Subtracts two [`Float`]s, taking the first by value and the second by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// difference is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,\\infty)=f(-\\infty,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0)=0.0$\n    /// - $f(-0.0,0.0)=-0.0$\n    /// - $f(0.0,0.0)=f(-0.0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x)=f(-0.0,x)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_val_ref`] instead. If you want to specify the output precision, consider\n    /// using [`Float::sub_round_val_ref`]. If you want both of these things, consider using\n    /// [`Float::sub_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((Float::from(1.5) - &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     Float::from(1.5) - &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::from(1.5) - &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert!((Float::INFINITY - &Float::INFINITY).is_nan());\n    ///\n    /// assert_eq!(Float::from(1.5) - &Float::from(2.5), -1.0);\n    /// assert_eq!(Float::from(1.5) - &Float::from(-2.5), 4.0);\n    /// assert_eq!(Float::from(-1.5) - &Float::from(2.5), -4.0);\n    /// assert_eq!(Float::from(-1.5) - &Float::from(-2.5), 1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: &Self) -> Self {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Sub<Float> for &Float {\n    type Output = Float;\n\n    /// Subtracts two [`Float`]s, taking the first by reference and the second by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// difference is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,\\infty)=f(-\\infty,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0)=0.0$\n    /// - $f(-0.0,0.0)=-0.0$\n    /// - $f(0.0,0.0)=f(-0.0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x)=f(-0.0,x)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_ref_val`] instead. If you want to specify the output precision, consider\n    /// using [`Float::sub_round_ref_val`]. If you want both of these things, consider using\n    /// [`Float::sub_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) - Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Float::from(1.5) - Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::from(1.5) - Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert!((&Float::INFINITY - Float::INFINITY).is_nan());\n    ///\n    /// assert_eq!(&Float::from(1.5) - Float::from(2.5), -1.0);\n    /// assert_eq!(&Float::from(1.5) - Float::from(-2.5), 4.0);\n    /// assert_eq!(&Float::from(-1.5) - Float::from(2.5), -4.0);\n    /// assert_eq!(&Float::from(-1.5) - Float::from(-2.5), 1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Sub<&Float> for &Float {\n    type Output = Float;\n\n    /// Subtracts two [`Float`]s, taking both by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// difference is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=f(x,\\text{NaN})=f(\\infty,\\infty)=f(-\\infty,-\\infty)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(x,-\\infty)=\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(-\\infty,x)=-\\infty$ if $x$ is not NaN or $-\\infty$\n    /// - $f(x,\\infty)=-\\infty$ if $x$ is not NaN or $\\infty$\n    /// - $f(0.0,-0.0)=0.0$\n    /// - $f(-0.0,0.0)=-0.0$\n    /// - $f(0.0,0.0)=f(-0.0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(0.0,x)=f(-0.0,x)=-x$ if $x$ is not NaN and $x$ is nonzero\n    /// - $f(x,x)=0.0$ if $x$ is finite and nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using [`Float::sub_prec`]\n    /// instead. If you want to specify the output precision, consider using [`Float::sub_round`].\n    /// If you want both of these things, consider using [`Float::sub_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// assert!((&Float::from(1.5) - &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Float::from(1.5) - &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::from(1.5) - &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    /// assert!((&Float::INFINITY - &Float::INFINITY).is_nan());\n    ///\n    /// assert_eq!(&Float::from(1.5) - &Float::from(2.5), -1.0);\n    /// assert_eq!(&Float::from(1.5) - &Float::from(-2.5), 4.0);\n    /// assert_eq!(&Float::from(-1.5) - &Float::from(2.5), -4.0);\n    /// assert_eq!(&Float::from(-1.5) - &Float::from(-2.5), 1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: &Float) -> Float {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl SubAssign<Self> for Float {\n    /// Subtracts a [`Float`] by a [`Float`] in place, taking the [`Float`] on the right-hand side\n    /// by value.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// difference is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `-` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::sub_round_assign`]. If you want both of these things, consider using\n    /// [`Float::sub_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= Float::INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x -= Float::INFINITY;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= Float::from(2.5);\n    /// assert_eq!(x, -1.0);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= Float::from(-2.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x -= Float::from(2.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x -= Float::from(-2.5);\n    /// assert_eq!(x, 1.0);\n    /// ```\n    #[inline]\n    fn sub_assign(&mut self, other: Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl SubAssign<&Self> for Float {\n    /// Subtracts a [`Float`] by a [`Float`] in place, taking the [`Float`] on the right-hand side\n    /// by reference.\n    ///\n    /// If the output has a precision, it is the maximum of the precisions of the inputs. If the\n    /// difference is equidistant from two [`Float`]s with the specified precision, the [`Float`]\n    /// with fewer 1s in its binary expansion is chosen. See [`RoundingMode`] for a description of\n    /// the `Nearest` rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the maximum precision of the inputs.\n    ///\n    /// See the `-` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_prec_assign`] instead. If you want to specify the output precision, consider\n    /// using [`Float::sub_round_assign`]. If you want both of these things, consider using\n    /// [`Float::sub_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= &Float::NAN;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= &Float::INFINITY;\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= &Float::NEGATIVE_INFINITY;\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x -= &Float::INFINITY;\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= &Float::from(2.5);\n    /// assert_eq!(x, -1.0);\n    ///\n    /// let mut x = Float::from(1.5);\n    /// x -= &Float::from(-2.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x -= &Float::from(2.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-1.5);\n    /// x -= &Float::from(-2.5);\n    /// assert_eq!(x, 1.0);\n    /// ```\n    #[inline]\n    fn sub_assign(&mut self, other: &Self) {\n        let prec = max(self.significant_bits(), other.significant_bits());\n        self.sub_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Sub<Rational> for Float {\n    type Output = Self;\n\n    /// Subtracts a [`Float`] by a [`Rational`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(x,0)=x$\n    /// - $f(0.0,x)=f(-0.0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec`] instead. If you want to specify the output precision, consider\n    /// using [`Float::sub_rational_round`]. If you want both of these things, consider using\n    /// [`Float::sub_rational_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN - Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(Float::INFINITY - Rational::exact_from(1.5), Float::INFINITY);\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY - Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(Float::from(2.5) - Rational::exact_from(1.5), 1.0);\n    /// assert_eq!(Float::from(2.5) - Rational::exact_from(-1.5), 4.0);\n    /// assert_eq!(Float::from(-2.5) - Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(Float::from(-2.5) - Rational::exact_from(-1.5), -1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: Rational) -> Self {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round(other, prec, Nearest).0\n    }\n}\n\nimpl Sub<&Rational> for Float {\n    type Output = Self;\n\n    /// Subtracts a [`Float`] by a [`Rational`], taking the first by value and the second by\n    /// reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(x,0)=x$\n    /// - $f(0.0,x)=f(-0.0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_val_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::sub_rational_round_val_ref`]. If you want both of these things,\n    /// consider using [`Float::sub_rational_prec_round_val_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Float::NAN - &Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     Float::INFINITY - &Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Float::NEGATIVE_INFINITY - &Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(Float::from(2.5) - &Rational::exact_from(1.5), 1.0);\n    /// assert_eq!(Float::from(2.5) - &Rational::exact_from(-1.5), 4.0);\n    /// assert_eq!(Float::from(-2.5) - &Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(Float::from(-2.5) - &Rational::exact_from(-1.5), -1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: &Rational) -> Self {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_val_ref(other, prec, Nearest).0\n    }\n}\n\nimpl Sub<Rational> for &Float {\n    type Output = Float;\n\n    /// Subtracts a [`Float`] by a [`Rational`], taking the first by reference and the second by\n    /// value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(x,0)=x$\n    /// - $f(0.0,x)=f(-0.0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_ref_val`] instead. If you want to specify the output precision,\n    /// consider using [`Float::sub_rational_round_ref_val`]. If you want both of these things,\n    /// consider using [`Float::sub_rational_prec_round_ref_val`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN - Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY - Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY - Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Float::from(2.5) - Rational::exact_from(1.5), 1.0);\n    /// assert_eq!(&Float::from(2.5) - Rational::exact_from(-1.5), 4.0);\n    /// assert_eq!(&Float::from(-2.5) - Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(&Float::from(-2.5) - Rational::exact_from(-1.5), -1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: Rational) -> Float {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_ref_val(other, prec, Nearest).0\n    }\n}\n\nimpl Sub<&Rational> for &Float {\n    type Output = Float;\n\n    /// Subtracts a [`Float`] by a [`Rational`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(\\text{NaN},x)=\\text{NaN}$\n    /// - $f(\\infty,x)=\\infty$\n    /// - $f(-\\infty,x)=-\\infty$\n    /// - $f(0.0,0)=0.0$\n    /// - $f(-0.0,0)=-0.0$\n    /// - $f(x,0)=x$\n    /// - $f(0.0,x)=f(-0.0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_ref_ref`] instead. If you want to specify the output precision,\n    /// consider using [`Float::sub_rational_round_ref_ref`]. If you want both of these things,\n    /// consider using [`Float::sub_rational_prec_round_ref_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Float::NAN - Rational::exact_from(1.5)).is_nan());\n    /// assert_eq!(\n    ///     &Float::INFINITY - Rational::exact_from(1.5),\n    ///     Float::INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Float::NEGATIVE_INFINITY - Rational::exact_from(1.5),\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Float::from(2.5) - &Rational::exact_from(1.5), 1.0);\n    /// assert_eq!(&Float::from(2.5) - &Rational::exact_from(-1.5), 4.0);\n    /// assert_eq!(&Float::from(-2.5) - &Rational::exact_from(1.5), -4.0);\n    /// assert_eq!(&Float::from(-2.5) - &Rational::exact_from(-1.5), -1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: &Rational) -> Float {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_ref_ref(other, prec, Nearest).0\n    }\n}\n\nimpl SubAssign<Rational> for Float {\n    /// Subtracts a [`Rational`] by a [`Float`] in place, taking the [`Rational`] by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `-` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_assign`] instead. If you want to specify the output precision,\n    /// consider using [`Float::sub_rational_round_assign`]. If you want both of these things,\n    /// consider using [`Float::sub_rational_prec_round_assign`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x -= Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x -= Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x -= Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x -= Rational::exact_from(1.5);\n    /// assert_eq!(x, 1.0);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x -= Rational::exact_from(-1.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x -= Rational::exact_from(1.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x -= Rational::exact_from(-1.5);\n    /// assert_eq!(x, -1.0);\n    /// ```\n    #[inline]\n    fn sub_assign(&mut self, other: Rational) {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_assign(other, prec, Nearest);\n    }\n}\n\nimpl SubAssign<&Rational> for Float {\n    /// Subtracts a [`Rational`] by a [`Float`] in place, taking the [`Rational`] by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// x\\gets = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// See the `-` documentation for information on special cases, overflow, and underflow.\n    ///\n    /// If you want to use a rounding mode other than `Nearest`, consider using\n    /// [`Float::sub_rational_prec_assign_ref`] instead. If you want to specify the output\n    /// precision, consider using [`Float::sub_rational_round_assign_ref`]. If you want both of\n    /// these things, consider using [`Float::sub_rational_prec_round_assign_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Float::NAN;\n    /// x -= &Rational::exact_from(1.5);\n    /// assert!(x.is_nan());\n    ///\n    /// let mut x = Float::INFINITY;\n    /// x -= &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::INFINITY);\n    ///\n    /// let mut x = Float::NEGATIVE_INFINITY;\n    /// x -= &Rational::exact_from(1.5);\n    /// assert_eq!(x, Float::NEGATIVE_INFINITY);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x -= &Rational::exact_from(1.5);\n    /// assert_eq!(x, 1.0);\n    ///\n    /// let mut x = Float::from(2.5);\n    /// x -= &Rational::exact_from(-1.5);\n    /// assert_eq!(x, 4.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x -= &Rational::exact_from(1.5);\n    /// assert_eq!(x, -4.0);\n    ///\n    /// let mut x = Float::from(-2.5);\n    /// x -= &Rational::exact_from(-1.5);\n    /// assert_eq!(x, -1.0);\n    /// ```\n    #[inline]\n    fn sub_assign(&mut self, other: &Rational) {\n        let prec = self.significant_bits();\n        self.sub_rational_prec_round_assign_ref(other, prec, Nearest);\n    }\n}\n\nimpl Sub<Float> for Rational {\n    type Output = Float;\n\n    /// Subtracts a [`Rational`] by a [`Float`], taking both by value.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=-\\infty$\n    /// - $f(x,-\\infty)=\\infty$\n    /// - $f(0,0.0)=-0.0$\n    /// - $f(0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$\n    /// - $f(0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) - Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) - Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) - Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(Rational::exact_from(1.5) - Float::from(2.5), -1.0);\n    /// assert_eq!(Rational::exact_from(1.5) - Float::from(-2.5), 4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) - Float::from(2.5), -4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) - Float::from(-2.5), 1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        -other.sub_rational_prec_round(self, prec, Nearest).0\n    }\n}\n\nimpl Sub<&Float> for Rational {\n    type Output = Float;\n\n    /// Subtracts a [`Rational`] by a [`Float`], taking the [`Rational`] by value and the [`Float`]\n    /// by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=-\\infty$\n    /// - $f(x,-\\infty)=\\infty$\n    /// - $f(0,0.0)=-0.0$\n    /// - $f(0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$\n    /// - $f(0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((Rational::exact_from(1.5) - &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) - &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     Rational::exact_from(1.5) - &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(Rational::exact_from(1.5) - &Float::from(2.5), -1.0);\n    /// assert_eq!(Rational::exact_from(1.5) - &Float::from(-2.5), 4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) - &Float::from(2.5), -4.0);\n    /// assert_eq!(Rational::exact_from(-1.5) - &Float::from(-2.5), 1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        -other.sub_rational_prec_round_ref_val(self, prec, Nearest).0\n    }\n}\n\nimpl Sub<Float> for &Rational {\n    type Output = Float;\n\n    /// Subtracts a [`Rational`] by a [`Float`], taking the [`Rational`] by value and the [`Float`]\n    /// by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=-\\infty$\n    /// - $f(x,-\\infty)=\\infty$\n    /// - $f(0,0.0)=-0.0$\n    /// - $f(0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$\n    /// - $f(0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) - Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) - Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) - Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Rational::exact_from(1.5) - Float::from(2.5), -1.0);\n    /// assert_eq!(&Rational::exact_from(1.5) - Float::from(-2.5), 4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) - Float::from(2.5), -4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) - Float::from(-2.5), 1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: Float) -> Float {\n        let prec = other.significant_bits();\n        -other.sub_rational_prec_round_val_ref(self, prec, Nearest).0\n    }\n}\n\nimpl Sub<&Float> for &Rational {\n    type Output = Float;\n\n    /// Subtracts a [`Rational`] by a [`Float`], taking both by reference.\n    ///\n    /// If the output has a precision, it is the precision of the input [`Float`]. If the difference\n    /// is equidistant from two [`Float`]s with the specified precision, the [`Float`] with fewer 1s\n    /// in its binary expansion is chosen. See [`RoundingMode`] for a description of the `Nearest`\n    /// rounding mode.\n    ///\n    /// $$\n    /// f(x,y) = x-y+\\varepsilon.\n    /// $$\n    /// - If $x-y$ is infinite, zero, or `NaN`, $\\varepsilon$ may be ignored or assumed to be 0.\n    /// - If $x-y$ is finite and nonzero, then $|\\varepsilon| < 2^{\\lfloor\\log_2 |x-y|\\rfloor-p}$,\n    ///   where $p$ is the precision of the input [`Float`].\n    ///\n    /// Special cases:\n    /// - $f(x,\\text{NaN})=\\text{NaN}$\n    /// - $f(x,\\infty)=-\\infty$\n    /// - $f(x,-\\infty)=\\infty$\n    /// - $f(0,0.0)=-0.0$\n    /// - $f(0,-0.0)=0.0$\n    /// - $f(x,0.0)=f(x,-0.0)=x$\n    /// - $f(0,x)=-x$\n    /// - $f(x,x)=0.0$ if $x$ is nonzero\n    ///\n    /// Overflow and underflow:\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $\\infty$ is returned instead.\n    /// - If $f(x,y)\\geq 2^{2^{30}-1}$, $-\\infty$ is returned instead.\n    /// - If $0<f(x,y)\\leq2^{-2^{30}-1}$, $0.0$ is returned instead.\n    /// - If $2^{-2^{30}-1}<f(x,y)<2^{-2^{30}}$, $2^{-2^{30}}$ is returned instead.\n    /// - If $-2^{-2^{30}-1}\\leq f(x,y)<0$, $-0.0$ is returned instead.\n    /// - If $-2^{-2^{30}}<f(x,y)<-2^{-2^{30}-1}$, $-2^{-2^{30}}$ is returned instead.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!((&Rational::exact_from(1.5) - &Float::NAN).is_nan());\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) - &Float::INFINITY,\n    ///     Float::NEGATIVE_INFINITY\n    /// );\n    /// assert_eq!(\n    ///     &Rational::exact_from(1.5) - &Float::NEGATIVE_INFINITY,\n    ///     Float::INFINITY\n    /// );\n    ///\n    /// assert_eq!(&Rational::exact_from(1.5) - &Float::from(2.5), -1.0);\n    /// assert_eq!(&Rational::exact_from(1.5) - &Float::from(-2.5), 4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) - &Float::from(2.5), -4.0);\n    /// assert_eq!(&Rational::exact_from(-1.5) - &Float::from(-2.5), 1.0);\n    /// ```\n    #[inline]\n    fn sub(self, other: &Float) -> Float {\n        let prec = other.significant_bits();\n        -other.sub_rational_prec_round_ref_ref(self, prec, Nearest).0\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/basic/classification.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{Float, float_either_zero};\nuse crate::{float_either_infinity, float_finite, float_nan, float_negative_zero, float_zero};\nuse core::num::FpCategory;\n\nimpl Float {\n    /// Determines whether a [`Float`] is NaN.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NaN, One};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_nan(), true);\n    /// assert_eq!(Float::ONE.is_nan(), false);\n    /// ```\n    #[inline]\n    pub const fn is_nan(&self) -> bool {\n        matches!(self, float_nan!())\n    }\n\n    /// Determines whether a [`Float`] is finite.\n    ///\n    /// NaN is not finite.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, One};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_finite(), false);\n    /// assert_eq!(Float::INFINITY.is_finite(), false);\n    /// assert_eq!(Float::ONE.is_finite(), true);\n    /// ```\n    #[inline]\n    pub const fn is_finite(&self) -> bool {\n        matches!(self, Self(Zero { .. } | Finite { .. }))\n    }\n\n    /// Determines whether a [`Float`] is infinite.\n    ///\n    /// NaN is not infinite.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, One};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_infinite(), false);\n    /// assert_eq!(Float::INFINITY.is_infinite(), true);\n    /// assert_eq!(Float::ONE.is_infinite(), false);\n    /// ```\n    #[inline]\n    pub const fn is_infinite(&self) -> bool {\n        matches!(self, float_either_infinity!())\n    }\n\n    /// Determines whether a [`Float`] is positive zero.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_positive_zero(), false);\n    /// assert_eq!(Float::INFINITY.is_positive_zero(), false);\n    /// assert_eq!(Float::ONE.is_positive_zero(), false);\n    /// assert_eq!(Float::ZERO.is_positive_zero(), true);\n    /// assert_eq!(Float::NEGATIVE_ZERO.is_positive_zero(), false);\n    /// ```\n    #[inline]\n    pub const fn is_positive_zero(&self) -> bool {\n        matches!(self, float_zero!())\n    }\n\n    /// Determines whether a [`Float`] is negative zero.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_negative_zero(), false);\n    /// assert_eq!(Float::INFINITY.is_negative_zero(), false);\n    /// assert_eq!(Float::ONE.is_negative_zero(), false);\n    /// assert_eq!(Float::ZERO.is_negative_zero(), false);\n    /// assert_eq!(Float::NEGATIVE_ZERO.is_negative_zero(), true);\n    /// ```\n    #[inline]\n    pub const fn is_negative_zero(&self) -> bool {\n        matches!(self, float_negative_zero!())\n    }\n\n    /// Determines whether a [`Float`] is zero (positive or negative).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_zero(), false);\n    /// assert_eq!(Float::INFINITY.is_zero(), false);\n    /// assert_eq!(Float::ONE.is_zero(), false);\n    /// assert_eq!(Float::ZERO.is_zero(), true);\n    /// assert_eq!(Float::NEGATIVE_ZERO.is_zero(), true);\n    /// ```\n    #[inline]\n    pub const fn is_zero(&self) -> bool {\n        matches!(self, float_either_zero!())\n    }\n\n    /// Determines whether a [`Float`] is normal, that is, finite and nonzero.\n    ///\n    /// There is no notion of subnormal [`Float`]s.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_normal(), false);\n    /// assert_eq!(Float::INFINITY.is_normal(), false);\n    /// assert_eq!(Float::ZERO.is_normal(), false);\n    /// assert_eq!(Float::NEGATIVE_ZERO.is_normal(), false);\n    /// assert_eq!(Float::ONE.is_normal(), true);\n    /// ```\n    pub const fn is_normal(&self) -> bool {\n        matches!(self, float_finite!())\n    }\n\n    /// Determines whether a [`Float`]'s sign is positive.\n    ///\n    /// A NaN has no sign, so this function returns false when given a NaN.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_sign_positive(), false);\n    /// assert_eq!(Float::INFINITY.is_sign_positive(), true);\n    /// assert_eq!(Float::NEGATIVE_INFINITY.is_sign_positive(), false);\n    /// assert_eq!(Float::ZERO.is_sign_positive(), true);\n    /// assert_eq!(Float::NEGATIVE_ZERO.is_sign_positive(), false);\n    /// assert_eq!(Float::ONE.is_sign_positive(), true);\n    /// assert_eq!(Float::NEGATIVE_ONE.is_sign_positive(), false);\n    /// ```\n    pub const fn is_sign_positive(&self) -> bool {\n        match self {\n            float_nan!() => false,\n            Self(Infinity { sign } | Finite { sign, .. } | Zero { sign, .. }) => *sign,\n        }\n    }\n\n    /// Determines whether a [`Float`]'s sign is negative.\n    ///\n    /// A NaN has no sign, so this function returns false when given a NaN.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.is_sign_negative(), false);\n    /// assert_eq!(Float::INFINITY.is_sign_negative(), false);\n    /// assert_eq!(Float::NEGATIVE_INFINITY.is_sign_negative(), true);\n    /// assert_eq!(Float::ZERO.is_sign_negative(), false);\n    /// assert_eq!(Float::NEGATIVE_ZERO.is_sign_negative(), true);\n    /// assert_eq!(Float::ONE.is_sign_negative(), false);\n    /// assert_eq!(Float::NEGATIVE_ONE.is_sign_negative(), true);\n    /// ```\n    pub const fn is_sign_negative(&self) -> bool {\n        match self {\n            float_nan!() => false,\n            Self(Infinity { sign } | Finite { sign, .. } | Zero { sign, .. }) => !*sign,\n        }\n    }\n\n    /// Classifies a [`Float`] into one of several categories.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n    /// };\n    /// use malachite_float::Float;\n    /// use std::num::FpCategory;\n    ///\n    /// assert_eq!(Float::NAN.classify(), FpCategory::Nan);\n    /// assert_eq!(Float::INFINITY.classify(), FpCategory::Infinite);\n    /// assert_eq!(Float::NEGATIVE_INFINITY.classify(), FpCategory::Infinite);\n    /// assert_eq!(Float::ZERO.classify(), FpCategory::Zero);\n    /// assert_eq!(Float::NEGATIVE_ZERO.classify(), FpCategory::Zero);\n    /// assert_eq!(Float::ONE.classify(), FpCategory::Normal);\n    /// assert_eq!(Float::NEGATIVE_ONE.classify(), FpCategory::Normal);\n    /// ```\n    pub const fn classify(&self) -> FpCategory {\n        match self {\n            float_nan!() => FpCategory::Nan,\n            float_either_infinity!() => FpCategory::Infinite,\n            Self(Zero { .. }) => FpCategory::Zero,\n            _ => FpCategory::Normal,\n        }\n    }\n\n    /// Turns a NaN into a `None` and wraps any non-NaN [`Float`] with a `Some`. The [`Float`] is\n    /// taken by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.into_non_nan(), None);\n    /// assert_eq!(Float::INFINITY.into_non_nan(), Some(Float::INFINITY));\n    /// assert_eq!(Float::ZERO.into_non_nan(), Some(Float::ZERO));\n    /// assert_eq!(\n    ///     Float::NEGATIVE_ZERO.into_non_nan(),\n    ///     Some(Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_eq!(Float::ONE.into_non_nan(), Some(Float::ONE));\n    /// ```\n    #[allow(clippy::missing_const_for_fn)] // destructor doesn't work with const\n    pub fn into_non_nan(self) -> Option<Self> {\n        match self {\n            float_nan!() => None,\n            x => Some(x),\n        }\n    }\n\n    /// Turns a NaN into a `None` and wraps any non-NaN [`Float`] with a `Some`. The [`Float`] is\n    /// taken by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.to_non_nan(), None);\n    /// assert_eq!(Float::INFINITY.to_non_nan(), Some(Float::INFINITY));\n    /// assert_eq!(Float::ZERO.to_non_nan(), Some(Float::ZERO));\n    /// assert_eq!(\n    ///     Float::NEGATIVE_ZERO.to_non_nan(),\n    ///     Some(Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_eq!(Float::ONE.to_non_nan(), Some(Float::ONE));\n    /// ```\n    #[allow(clippy::missing_const_for_fn)] // destructor doesn't work with const\n    pub fn to_non_nan(&self) -> Option<Self> {\n        match self {\n            float_nan!() => None,\n            x => Some(x.clone()),\n        }\n    }\n\n    /// Turns any [`Float`] that's NaN or infinite into a `None` and wraps any finite [`Float`] with\n    /// a `Some`. The [`Float`] is taken by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.into_finite(), None);\n    /// assert_eq!(Float::INFINITY.into_finite(), None);\n    /// assert_eq!(Float::ZERO.into_finite(), Some(Float::ZERO));\n    /// assert_eq!(\n    ///     Float::NEGATIVE_ZERO.into_finite(),\n    ///     Some(Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_eq!(Float::ONE.into_finite(), Some(Float::ONE));\n    /// ```\n    #[allow(clippy::missing_const_for_fn)] // destructor doesn't work with const\n    pub fn into_finite(self) -> Option<Self> {\n        match self {\n            Self(NaN | Infinity { .. }) => None,\n            x => Some(x),\n        }\n    }\n\n    /// Turns any [`Float`] that's NaN or infinite into a `None` and wraps any finite [`Float`] with\n    /// a `Some`. The [`Float`] is taken by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeZero, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.to_finite(), None);\n    /// assert_eq!(Float::INFINITY.to_finite(), None);\n    /// assert_eq!(Float::ZERO.to_finite(), Some(Float::ZERO));\n    /// assert_eq!(Float::NEGATIVE_ZERO.to_finite(), Some(Float::NEGATIVE_ZERO));\n    /// assert_eq!(Float::ONE.to_finite(), Some(Float::ONE));\n    /// ```\n    pub fn to_finite(&self) -> Option<Self> {\n        match self {\n            Self(NaN | Infinity { .. }) => None,\n            x => Some(x.clone()),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/basic/complexity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse core::cmp::max;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nimpl Float {\n    /// Determines a [`Float`]'s complexity. The complexity is defined as follows:\n    ///\n    /// $$\n    /// f(\\text{NaN}) = f(\\pm\\infty) = f(\\pm 0.0) = 1,\n    /// $$\n    ///\n    /// and, if $x$ is finite and nonzero,\n    ///\n    /// $$\n    /// f(x) = \\max(|\\lfloor \\log_2 x\\rfloor|, p),\n    /// $$\n    ///\n    /// where $p$ is the precision of $x$.\n    ///\n    /// Informally, the complexity is proportional to the number of characters you would need to\n    /// write the [`Float`] out without using exponents.\n    ///\n    /// See also the [`Float`] implementation of [`SignificantBits`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::num::basic::traits::{NaN, One};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.complexity(), 1);\n    /// assert_eq!(Float::ONE.complexity(), 1);\n    /// assert_eq!(Float::one_prec(100).complexity(), 100);\n    /// assert_eq!(Float::from(std::f64::consts::PI).complexity(), 50);\n    /// assert_eq!(Float::power_of_2(100u64).complexity(), 100);\n    /// assert_eq!(Float::power_of_2(-100i64).complexity(), 100);\n    /// ```\n    pub fn complexity(&self) -> u64 {\n        match self {\n            Self(Finite {\n                exponent,\n                precision,\n                ..\n            }) => max(u64::from((exponent - 1).unsigned_abs()), *precision),\n            _ => 1,\n        }\n    }\n}\n\nimpl SignificantBits for &Float {\n    /// Returns the number of significant bits of a [`Float`]. This is defined as follows:\n    ///\n    /// $$\n    /// f(\\text{NaN}) = f(\\pm\\infty) = f(\\pm 0.0) = 1,\n    /// $$\n    ///\n    /// and, if $x$ is finite and nonzero,\n    ///\n    /// $$\n    /// f(x) = p,\n    /// $$\n    ///\n    /// where $p$ is the precision of $x$.\n    ///\n    /// See also the [`complexity`](Float::complexity) function.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::num::basic::traits::{NaN, One};\n    /// use malachite_base::num::logic::traits::SignificantBits;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.significant_bits(), 1);\n    /// assert_eq!(Float::ONE.significant_bits(), 1);\n    /// assert_eq!(Float::one_prec(100).significant_bits(), 100);\n    /// assert_eq!(Float::from(std::f64::consts::PI).significant_bits(), 50);\n    /// assert_eq!(Float::power_of_2(100u64).significant_bits(), 1);\n    /// assert_eq!(Float::power_of_2(-100i64).significant_bits(), 1);\n    /// ```\n    fn significant_bits(self) -> u64 {\n        match self {\n            Float(Finite { precision, .. }) => *precision,\n            _ => 1,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/basic/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse malachite_base::comparison::traits::{Max, Min};\nuse malachite_base::named::Named;\nuse malachite_base::num::arithmetic::traits::{\n    IsPowerOf2, NegModPowerOf2, PowerOf2, RoundToMultipleOfPowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity as InfinityTrait, NaN as NaNTrait, NegativeInfinity, NegativeOne, NegativeZero, One,\n    OneHalf, Two, Zero as ZeroTrait,\n};\nuse malachite_base::num::logic::traits::{BitScan, LowMask};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_zero {\n    () => {\n        Float(Zero { sign: true })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_one {\n    () => {\n        Float(Finite {\n            sign: true,\n            exponent: 1,\n            precision: 1,\n            significand: Natural::HIGH_BIT,\n        })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_two {\n    () => {\n        Float(Finite {\n            sign: true,\n            exponent: 2,\n            precision: 1,\n            significand: Natural::HIGH_BIT,\n        })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_negative_one {\n    () => {\n        Float(Finite {\n            sign: false,\n            exponent: 1,\n            precision: 1,\n            significand: Natural::HIGH_BIT,\n        })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_one_half {\n    () => {\n        Float(Finite {\n            sign: true,\n            exponent: 0,\n            precision: 1,\n            significand: Natural::HIGH_BIT,\n        })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_negative_zero {\n    () => {\n        Float(Zero { sign: false })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_infinity {\n    () => {\n        Float(Infinity { sign: true })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_negative_infinity {\n    () => {\n        Float(Infinity { sign: false })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_nan {\n    () => {\n        Float(NaN)\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_finite {\n    () => {\n        Float(Finite { .. })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_either_infinity {\n    () => {\n        Float(Infinity { .. })\n    };\n}\n\n#[doc(hidden)]\n#[macro_export]\nmacro_rules! float_either_zero {\n    () => {\n        Float(Zero { .. })\n    };\n}\n\n/// The constant 0.0 (positive zero), with precision 1.\nimpl ZeroTrait for Float {\n    const ZERO: Self = float_zero!();\n}\n\n/// The constant 1.0, with precision 1.\nimpl One for Float {\n    const ONE: Self = float_one!();\n}\n\n/// The constant 2.0, with precision 1.\nimpl Two for Float {\n    const TWO: Self = float_two!();\n}\n\n/// The constant -1.0, with precision 1.\nimpl NegativeOne for Float {\n    const NEGATIVE_ONE: Self = float_negative_one!();\n}\n\n/// The constant 0.5, with precision 1.\nimpl OneHalf for Float {\n    const ONE_HALF: Self = float_one_half!();\n}\n\n/// The constant -0.0, with precision 1.\nimpl NegativeZero for Float {\n    const NEGATIVE_ZERO: Self = float_negative_zero!();\n}\n\n/// The constant $\\infty$.\nimpl InfinityTrait for Float {\n    const INFINITY: Self = float_infinity!();\n}\n\n/// The constant $-\\infty$.\nimpl NegativeInfinity for Float {\n    const NEGATIVE_INFINITY: Self = float_negative_infinity!();\n}\n\n/// The constant NaN.\nimpl NaNTrait for Float {\n    const NAN: Self = float_nan!();\n}\n\nimpl Default for Float {\n    /// The default value of a [`Float`], NaN.\n    fn default() -> Self {\n        Self::NAN\n    }\n}\n\n/// The lowest value representable by this type, $-\\infty$.\nimpl Min for Float {\n    const MIN: Self = Self::NEGATIVE_INFINITY;\n}\n\n/// The highest value representable by this type, $\\infty$.\nimpl Max for Float {\n    const MAX: Self = Self::INFINITY;\n}\n\n// Implements `Named` for `Float`.\nimpl_named!(Float);\n\nimpl Float {\n    /// The minimum representable positive value, or $2^{-2^{30}}$, with precision 1.\n    pub const MIN_POSITIVE: Self = Self(Finite {\n        sign: true,\n        exponent: Self::MIN_EXPONENT,\n        precision: 1,\n        significand: Natural::HIGH_BIT,\n    });\n\n    /// Returns the minimum representable positive value, or $2^{-2^{30}}$, with the given\n    /// precision.\n    ///\n    /// $$\n    /// f(p) = 2^{-2^{30}},\n    /// $$\n    ///\n    /// and the output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::min_positive_value_prec(1).to_string(), \"too_small\");\n    /// assert_eq!(Float::min_positive_value_prec(10).to_string(), \"too_small\");\n    /// assert_eq!(Float::min_positive_value_prec(100).to_string(), \"too_small\");\n    ///\n    /// assert_eq!(Float::min_positive_value_prec(1).get_prec(), Some(1));\n    /// assert_eq!(Float::min_positive_value_prec(10).get_prec(), Some(10));\n    /// assert_eq!(Float::min_positive_value_prec(100).get_prec(), Some(100));\n    /// ```\n    pub fn min_positive_value_prec(prec: u64) -> Self {\n        assert_ne!(prec, 0);\n        Self(Finite {\n            sign: true,\n            exponent: Self::MIN_EXPONENT,\n            precision: prec,\n            significand: Natural::power_of_2(\n                prec.round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                    .0\n                    - 1,\n            ),\n        })\n    }\n\n    /// Returns whether the absolute value of a `Float` is equal to the minimum representable\n    /// positive value, or $2^{-2^{30}}$.\n    ///\n    /// $$\n    /// f(x) = (|x|=2^{-2^{30}}).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert!(Float::min_positive_value_prec(100).abs_is_min_positive_value());\n    /// assert!((-Float::min_positive_value_prec(100)).abs_is_min_positive_value());\n    /// assert!(!(Float::min_positive_value_prec(100) << 1u32).abs_is_min_positive_value());\n    /// ```\n    pub fn abs_is_min_positive_value(&self) -> bool {\n        self.get_exponent() == Some(Self::MIN_EXPONENT)\n            && self.significand_ref().unwrap().is_power_of_2()\n    }\n\n    /// There is no maximum finite [`Float`], but there is one for any given precision. This\n    /// function returns that [`Float`].\n    ///\n    /// $$\n    /// f(p) = (1-(1/2)^p)2^{2^{30}-1},\n    /// $$\n    /// where $p$ is `prec`. The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::max_finite_value_with_prec(1).to_string(), \"too_big\");\n    /// assert_eq!(Float::max_finite_value_with_prec(10).to_string(), \"too_big\");\n    /// assert_eq!(\n    ///     Float::max_finite_value_with_prec(100).to_string(),\n    ///     \"too_big\"\n    /// );\n    ///\n    /// assert_eq!(Float::max_finite_value_with_prec(1).get_prec(), Some(1));\n    /// assert_eq!(Float::max_finite_value_with_prec(10).get_prec(), Some(10));\n    /// assert_eq!(Float::max_finite_value_with_prec(100).get_prec(), Some(100));\n    /// ```\n    pub fn max_finite_value_with_prec(prec: u64) -> Self {\n        assert_ne!(prec, 0);\n        Self(Finite {\n            sign: true,\n            exponent: Self::MAX_EXPONENT,\n            precision: prec,\n            significand: Natural::low_mask(prec) << prec.neg_mod_power_of_2(Limb::LOG_WIDTH),\n        })\n    }\n\n    /// Returns whether the absolute value of a `Float` is equal to the maximum representable finite\n    /// value with that precision.\n    ///\n    /// $$\n    /// f(x) = (|x|=(1-(1/2)^p)2^{2^{30}-1}),\n    /// $$\n    /// where $p$ is the precision of the $x$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert!(Float::max_finite_value_with_prec(100).abs_is_max_finite_value_with_prec());\n    /// assert!((-Float::max_finite_value_with_prec(100)).abs_is_max_finite_value_with_prec());\n    /// assert!(\n    ///     !(Float::max_finite_value_with_prec(100) >> 1u32).abs_is_max_finite_value_with_prec()\n    /// );\n    /// ```\n    pub fn abs_is_max_finite_value_with_prec(&self) -> bool {\n        if self.get_exponent() != Some(Self::MAX_EXPONENT) {\n            return false;\n        }\n        let prec = self.get_prec().unwrap();\n        let lowest_1_index = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n        self.significand_ref()\n            .unwrap()\n            .index_of_next_false_bit(lowest_1_index)\n            .unwrap()\n            == prec\n                .round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                .0\n    }\n\n    /// Returns the number 1, with the given precision.\n    ///\n    /// $$\n    /// f(p) = 1,\n    /// $$\n    ///\n    /// and the output has precision $p$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::one_prec(1), 1);\n    /// assert_eq!(Float::one_prec(10), 1);\n    /// assert_eq!(Float::one_prec(100), 1);\n    ///\n    /// assert_eq!(Float::one_prec(1).get_prec(), Some(1));\n    /// assert_eq!(Float::one_prec(10).get_prec(), Some(10));\n    /// assert_eq!(Float::one_prec(100).get_prec(), Some(100));\n    /// ```\n    pub fn one_prec(prec: u64) -> Self {\n        assert_ne!(prec, 0);\n        Self(Finite {\n            sign: true,\n            exponent: 1,\n            precision: prec,\n            significand: Natural::power_of_2(\n                prec.round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                    .0\n                    - 1,\n            ),\n        })\n    }\n\n    /// Returns the number 2, with the given precision.\n    ///\n    /// $$\n    /// f(p) = 2,\n    /// $$\n    ///\n    /// and the output has precision $p$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::two_prec(1), 2);\n    /// assert_eq!(Float::two_prec(10), 2);\n    /// assert_eq!(Float::two_prec(100), 2);\n    ///\n    /// assert_eq!(Float::two_prec(1).get_prec(), Some(1));\n    /// assert_eq!(Float::two_prec(10).get_prec(), Some(10));\n    /// assert_eq!(Float::two_prec(100).get_prec(), Some(100));\n    /// ```\n    pub fn two_prec(prec: u64) -> Self {\n        assert_ne!(prec, 0);\n        Self(Finite {\n            sign: true,\n            exponent: 2,\n            precision: prec,\n            significand: Natural::power_of_2(\n                prec.round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                    .0\n                    - 1,\n            ),\n        })\n    }\n\n    /// Returns the number $-1$, with the given precision.\n    ///\n    /// $$\n    /// f(p) = -1,\n    /// $$\n    ///\n    /// and the output has precision $p$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::negative_one_prec(1), -1);\n    /// assert_eq!(Float::negative_one_prec(10), -1);\n    /// assert_eq!(Float::negative_one_prec(100), -1);\n    ///\n    /// assert_eq!(Float::negative_one_prec(1).get_prec(), Some(1));\n    /// assert_eq!(Float::negative_one_prec(10).get_prec(), Some(10));\n    /// assert_eq!(Float::negative_one_prec(100).get_prec(), Some(100));\n    /// ```\n    pub fn negative_one_prec(prec: u64) -> Self {\n        assert_ne!(prec, 0);\n        Self(Finite {\n            sign: false,\n            exponent: 1,\n            precision: prec,\n            significand: Natural::power_of_2(\n                prec.round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                    .0\n                    - 1,\n            ),\n        })\n    }\n\n    /// Returns the number 0.5, with the given precision.\n    ///\n    /// $$\n    /// f(p) = 0.5,\n    /// $$\n    ///\n    /// and the output has precision $p$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::one_half_prec(1), 0.5);\n    /// assert_eq!(Float::one_half_prec(10), 0.5);\n    /// assert_eq!(Float::one_half_prec(100), 0.5);\n    ///\n    /// assert_eq!(Float::one_half_prec(1).get_prec(), Some(1));\n    /// assert_eq!(Float::one_half_prec(10).get_prec(), Some(10));\n    /// assert_eq!(Float::one_half_prec(100).get_prec(), Some(100));\n    /// ```\n    pub fn one_half_prec(prec: u64) -> Self {\n        assert_ne!(prec, 0);\n        Self(Finite {\n            sign: true,\n            exponent: 0,\n            precision: prec,\n            significand: Natural::power_of_2(\n                prec.round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                    .0\n                    - 1,\n            ),\n        })\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/basic/extended.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, NaN};\nuse crate::conversion::primitive_float_from_float::FloatFromFloatError;\nuse crate::conversion::rational_from_float::RationalFromFloatError;\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse core::mem::swap;\nuse core::ops::{Add, Mul, Shl, ShlAssign, Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase2, Parity, Sqrt, SqrtAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ExactFrom, SaturatingInto};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::natural::arithmetic::float_sub::exponent_shift_compare;\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\npub_crate_test_struct! {\n#[derive(Clone)]\nExtendedFloat {\n    pub(crate) x: Float,\n    pub(crate) exp: i64,\n}}\n\nimpl ExtendedFloat {\n    fn is_valid(&self) -> bool {\n        if self.x == 0u32 && self.exp != 0 {\n            return false;\n        }\n        let exp = self.x.get_exponent();\n        exp.is_none() || exp == Some(0)\n    }\n\n    fn from_rational_prec_round(value: Rational, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        if value == 0 {\n            return (\n                Self {\n                    x: Float::ZERO,\n                    exp: 0,\n                },\n                Equal,\n            );\n        }\n        let exp = value.floor_log_base_2_abs() + 1;\n        let (x, o) = Float::from_rational_prec_round(value >> exp, prec, rm);\n        let new_exp = x.get_exponent().unwrap();\n        (\n            Self {\n                x: x >> new_exp,\n                exp: i64::from(new_exp) + exp,\n            },\n            o,\n        )\n    }\n\n    pub(crate) fn from_rational_prec_round_ref(\n        value: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if *value == 0 {\n            return (\n                Self {\n                    x: Float::ZERO,\n                    exp: 0,\n                },\n                Equal,\n            );\n        }\n        let exp = value.floor_log_base_2_abs() + 1;\n        if exp >= i64::from(Float::MIN_EXPONENT) && exp <= i64::from(Float::MAX_EXPONENT) {\n            let (x, o) = Float::from_rational_prec_round_ref(value, prec, rm);\n            let exp = x.get_exponent().unwrap();\n            return (\n                Self {\n                    x: x >> exp,\n                    exp: i64::from(exp),\n                },\n                o,\n            );\n        }\n        let (x, o) = Float::from_rational_prec_round(value >> exp, prec, rm);\n        let new_exp = x.get_exponent().unwrap();\n        (\n            Self {\n                x: x >> new_exp,\n                exp: i64::from(new_exp) + exp,\n            },\n            o,\n        )\n    }\n\n    fn add_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        assert!(self.is_valid());\n        assert!(other.is_valid());\n        assert!(self.x.is_normal());\n        assert!(other.x.is_normal());\n        Self::from_rational_prec_round(\n            Rational::exact_from(self) + Rational::exact_from(other),\n            prec,\n            Nearest,\n        )\n    }\n\n    fn sub_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        assert!(self.is_valid());\n        assert!(other.is_valid());\n        assert!(self.x.is_normal());\n        assert!(other.x.is_normal());\n        Self::from_rational_prec_round(\n            Rational::exact_from(self) - Rational::exact_from(other),\n            prec,\n            Nearest,\n        )\n    }\n\n    fn sub_prec(self, other: Self, prec: u64) -> (Self, Ordering) {\n        assert!(self.is_valid());\n        assert!(other.is_valid());\n        assert!(self.x.is_normal());\n        assert!(other.x.is_normal());\n        Self::from_rational_prec_round(\n            Rational::exact_from(self) - Rational::exact_from(other),\n            prec,\n            Nearest,\n        )\n    }\n\n    fn mul_prec_ref_ref(&self, other: &Self, prec: u64) -> (Self, Ordering) {\n        assert!(self.is_valid());\n        assert!(other.is_valid());\n        assert!(self.x.is_normal());\n        assert!(other.x.is_normal());\n        let (mut product, o) = self.x.mul_prec_ref_ref(&other.x, prec);\n        let mut product_exp = self.exp + other.exp;\n        let extra_exp = product.get_exponent().unwrap();\n        product >>= extra_exp;\n        product_exp = product_exp.checked_add(i64::from(extra_exp)).unwrap();\n        (\n            Self {\n                x: product,\n                exp: product_exp,\n            },\n            o,\n        )\n    }\n\n    fn div_prec_val_ref(self, other: &Self, prec: u64) -> (Self, Ordering) {\n        assert!(self.is_valid());\n        assert!(other.is_valid());\n        assert!(self.x.is_normal());\n        assert!(other.x.is_normal());\n        let (mut quotient, o) = self.x.div_prec_ref_ref(&other.x, prec);\n        let mut quotient_exp = self.exp - other.exp;\n        let extra_exp = quotient.get_exponent().unwrap();\n        quotient >>= extra_exp;\n        quotient_exp = quotient_exp.checked_add(i64::from(extra_exp)).unwrap();\n        (\n            Self {\n                x: quotient,\n                exp: quotient_exp,\n            },\n            o,\n        )\n    }\n\n    fn div_prec_assign_ref(&mut self, other: &Self, prec: u64) -> Ordering {\n        let mut x = Self {\n            x: Float::ZERO,\n            exp: 0,\n        };\n        swap(self, &mut x);\n        let (q, o) = x.div_prec_val_ref(other, prec);\n        *self = q;\n        o\n    }\n\n    fn square_round_assign(&mut self, rm: RoundingMode) -> Ordering {\n        let mut x = Self {\n            x: Float::ZERO,\n            exp: 0,\n        };\n        swap(self, &mut x);\n        let (mut square, o) = x.x.square_round(rm);\n        let mut square_exp = x.exp << 1;\n        let extra_exp = square.get_exponent().unwrap();\n        square >>= extra_exp;\n        square_exp = square_exp.checked_add(i64::from(extra_exp)).unwrap();\n        *self = Self {\n            x: square,\n            exp: square_exp,\n        };\n        o\n    }\n\n    fn from_extended_float_prec_round(x: Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        if let Ok(x) = Rational::try_from(&x) {\n            Self::from_rational_prec_round(x, prec, rm)\n        } else {\n            (x, Equal)\n        }\n    }\n\n    pub_crate_test! {from_extended_float_prec_round_ref(\n        x: &Self,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if let Ok(x) = Rational::try_from(x) {\n            Self::from_rational_prec_round(x, prec, rm)\n        } else {\n            (x.clone(), Equal)\n        }\n    }}\n\n    fn shr_prec_round<T: PrimitiveInt>(\n        self,\n        bits: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        // assumes no overflow or underflow\n        let (out_x, o) = Self::from_extended_float_prec_round(self, prec, rm);\n        let out_exp =\n            i64::exact_from(i128::from(out_x.exp) - SaturatingInto::<i128>::saturating_into(bits));\n        (\n            Self {\n                x: out_x.x,\n                exp: out_exp,\n            },\n            o,\n        )\n    }\n\n    fn shr_round_assign<T: PrimitiveInt>(&mut self, bits: T, _rm: RoundingMode) -> Ordering {\n        // assumes no overflow or underflow\n        if self.x.is_normal() {\n            let out_exp = i64::exact_from(\n                i128::from(self.exp) - SaturatingInto::<i128>::saturating_into(bits),\n            );\n            self.exp = out_exp;\n        }\n        Equal\n    }\n\n    fn shl_round<T: PrimitiveInt>(mut self, bits: T, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.shl_round_assign(bits, rm);\n        (self, o)\n    }\n\n    fn shl_round_ref<T: PrimitiveInt>(&self, bits: T, _rm: RoundingMode) -> (Self, Ordering) {\n        // assumes no overflow or underflow\n        if self.x.is_normal() {\n            let out_exp = i64::exact_from(\n                i128::from(self.exp) + SaturatingInto::<i128>::saturating_into(bits),\n            );\n            (\n                Self {\n                    x: self.x.clone(),\n                    exp: out_exp,\n                },\n                Equal,\n            )\n        } else {\n            (self.clone(), Equal)\n        }\n    }\n\n    fn shl_round_assign<T: PrimitiveInt>(&mut self, bits: T, _rm: RoundingMode) -> Ordering {\n        // assumes no overflow or underflow\n        if self.x.is_normal() {\n            let out_exp = i64::exact_from(\n                i128::from(self.exp) + SaturatingInto::<i128>::saturating_into(bits),\n            );\n            self.exp = out_exp;\n        }\n        Equal\n    }\n\n    pub(crate) fn into_float_helper(\n        mut self,\n        prec: u64,\n        rm: RoundingMode,\n        previous_o: Ordering,\n    ) -> (Float, Ordering) {\n        let o = self\n            .x\n            .shl_prec_round_assign_helper(self.exp, prec, rm, previous_o);\n        (self.x, o)\n    }\n\n    pub(crate) fn increment(&mut self) {\n        self.x.increment();\n        if let Some(exp) = self.x.get_exponent()\n            && exp == 1\n        {\n            self.x >>= 1u32;\n            self.exp = 0;\n        }\n    }\n}\n\nimpl From<Float> for ExtendedFloat {\n    fn from(value: Float) -> Self {\n        if let Some(exp) = value.get_exponent() {\n            Self {\n                x: value >> exp,\n                exp: i64::from(exp),\n            }\n        } else {\n            Self { x: value, exp: 0 }\n        }\n    }\n}\n\nimpl TryFrom<ExtendedFloat> for Float {\n    type Error = FloatFromFloatError;\n\n    fn try_from(value: ExtendedFloat) -> Result<Self, Self::Error> {\n        if value.x.is_normal() {\n            let y = value.x << value.exp;\n            if y.is_normal() {\n                Ok(y)\n            } else {\n                Err(if value.exp > 0 {\n                    FloatFromFloatError::Overflow\n                } else {\n                    FloatFromFloatError::Underflow\n                })\n            }\n        } else {\n            Ok(value.x)\n        }\n    }\n}\n\nimpl TryFrom<ExtendedFloat> for Rational {\n    type Error = RationalFromFloatError;\n\n    fn try_from(value: ExtendedFloat) -> Result<Self, Self::Error> {\n        Self::try_from(value.x).map(|x| x << value.exp)\n    }\n}\n\nimpl<'a> TryFrom<&'a ExtendedFloat> for Rational {\n    type Error = RationalFromFloatError;\n\n    fn try_from(value: &'a ExtendedFloat) -> Result<Self, Self::Error> {\n        Self::try_from(&value.x).map(|x| x << value.exp)\n    }\n}\n\nimpl PartialEq for ExtendedFloat {\n    fn eq(&self, other: &Self) -> bool {\n        self.x == other.x && self.exp == other.exp\n    }\n}\n\nimpl PartialOrd for ExtendedFloat {\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        assert!(self.is_valid());\n        assert!(other.is_valid());\n        let self_sign = self.x > 0u32;\n        let other_sign = other.x > 0u32;\n        match self_sign.cmp(&other_sign) {\n            Greater => Some(Greater),\n            Less => Some(Less),\n            Equal => match self.exp.cmp(&other.exp) {\n                Greater => Some(if self_sign { Greater } else { Less }),\n                Less => Some(if self_sign { Less } else { Greater }),\n                Equal => self.x.partial_cmp(&other.x),\n            },\n        }\n    }\n}\n\nimpl Add<&ExtendedFloat> for &ExtendedFloat {\n    type Output = ExtendedFloat;\n\n    fn add(self, other: &ExtendedFloat) -> Self::Output {\n        let prec = max(self.x.significant_bits(), other.x.significant_bits());\n        self.add_prec_ref_ref(other, prec).0\n    }\n}\n\nimpl Mul<&ExtendedFloat> for &ExtendedFloat {\n    type Output = ExtendedFloat;\n\n    fn mul(self, other: &ExtendedFloat) -> Self::Output {\n        let prec = max(self.x.significant_bits(), other.x.significant_bits());\n        self.mul_prec_ref_ref(other, prec).0\n    }\n}\n\nimpl SqrtAssign for ExtendedFloat {\n    fn sqrt_assign(&mut self) {\n        if self.exp.odd() {\n            self.x <<= 1;\n            self.exp = self.exp.checked_sub(1).unwrap();\n        }\n        self.x.sqrt_assign();\n        self.exp >>= 1;\n        if let Some(new_exp) = self.x.get_exponent() {\n            self.exp = self.exp.checked_add(i64::from(new_exp)).unwrap();\n            self.x >>= new_exp;\n        }\n        assert!(self.is_valid());\n    }\n}\n\nimpl Sqrt for ExtendedFloat {\n    type Output = Self;\n\n    fn sqrt(mut self) -> Self::Output {\n        self.sqrt_assign();\n        self\n    }\n}\n\nimpl Shr<u32> for ExtendedFloat {\n    type Output = Self;\n\n    fn shr(mut self, bits: u32) -> Self::Output {\n        self.shr_round_assign(bits, Nearest);\n        self\n    }\n}\n\nimpl ShrAssign<u32> for ExtendedFloat {\n    fn shr_assign(&mut self, bits: u32) {\n        self.shr_round_assign(bits, Nearest);\n    }\n}\n\nimpl ShlAssign<u32> for ExtendedFloat {\n    fn shl_assign(&mut self, bits: u32) {\n        self.shl_round_assign(bits, Nearest);\n    }\n}\n\nimpl<T: PrimitiveInt> Shl<T> for &ExtendedFloat {\n    type Output = ExtendedFloat;\n\n    fn shl(self, bits: T) -> ExtendedFloat {\n        self.shl_round_ref(bits, Nearest).0\n    }\n}\n\nimpl<T: PrimitiveInt> Shl<T> for ExtendedFloat {\n    type Output = Self;\n\n    fn shl(self, bits: T) -> Self {\n        self.shl_round(bits, Nearest).0\n    }\n}\n\nfn cmp2_helper_extended(b: &ExtendedFloat, c: &ExtendedFloat, cancel: &mut u64) -> Ordering {\n    match (&b.x, &c.x) {\n        (\n            Float(Finite {\n                precision: x_prec,\n                significand: x,\n                ..\n            }),\n            Float(Finite {\n                precision: y_prec,\n                significand: y,\n                ..\n            }),\n        ) => {\n            let (o, c) = exponent_shift_compare(\n                x.as_limbs_asc(),\n                b.exp,\n                *x_prec,\n                y.as_limbs_asc(),\n                c.exp,\n                *y_prec,\n            );\n            *cancel = c;\n            o\n        }\n        _ => panic!(),\n    }\n}\n\npub(crate) fn agm_prec_round_normal_extended(\n    mut a: ExtendedFloat,\n    mut b: ExtendedFloat,\n    prec: u64,\n    rm: RoundingMode,\n) -> (ExtendedFloat, Ordering) {\n    if a.x < 0u32 || b.x < 0u32 {\n        return (\n            ExtendedFloat {\n                x: float_nan!(),\n                exp: 0,\n            },\n            Equal,\n        );\n    }\n    let q = prec;\n    let mut working_prec = q + q.ceiling_log_base_2() + 15;\n    // b (op2) and a (op1) are the 2 operands but we want b >= a\n    match a.partial_cmp(&b).unwrap() {\n        Equal => return ExtendedFloat::from_extended_float_prec_round(a, prec, rm),\n        Greater => swap(&mut a, &mut b),\n        _ => {}\n    }\n    let mut increment = Limb::WIDTH;\n    let mut v;\n    let mut scaleit;\n    loop {\n        let mut err: u64 = 0;\n        let mut u = a.mul_prec_ref_ref(&b, working_prec).0;\n        v = a.add_prec_ref_ref(&b, working_prec).0;\n        u.sqrt_assign();\n        v >>= 1u32;\n        scaleit = 0;\n        let mut n: u64 = 1;\n        let mut eq = 0;\n        while cmp2_helper_extended(&u, &v, &mut eq) != Equal && eq <= working_prec - 2 {\n            let mut vf;\n            vf = (&u + &v) >> 1;\n            // See proof in algorithms.tex\n            if eq > working_prec >> 2 {\n                // vf = V(k)\n                let low_p = (working_prec + 1) >> 1;\n                let mut w = v.sub_prec_ref_ref(&u, low_p).0; // e = V(k-1)-U(k-1)\n                w.square_round_assign(Nearest); // e = e^2\n                w.shr_round_assign(4, Nearest); // e*= (1/2)^2*1/4\n                w.div_prec_assign_ref(&vf, low_p); // 1/4*e^2/V(k)\n                let vf_exp = vf.exp;\n                v = vf.sub_prec(w, working_prec).0;\n                // 0 or 1\n                err = u64::exact_from(vf_exp - v.exp);\n                break;\n            }\n            let uf = &u * &v;\n            u = uf.sqrt();\n            swap(&mut v, &mut vf);\n            n += 1;\n        }\n        // the error on v is bounded by (18n+51) ulps, or twice if there was an exponent loss in the\n        // final subtraction\n        //\n        // 18n+51 should not overflow since n is about log(p)\n        err += (18 * n + 51).ceiling_log_base_2();\n        // we should have n+2 <= 2^(p/4) [see algorithms.tex]\n        if (n + 2).ceiling_log_base_2() <= working_prec >> 2\n            && float_can_round(v.x.significand_ref().unwrap(), working_prec - err, q, rm)\n        {\n            break;\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n    v.shr_prec_round(scaleit, prec, rm)\n}\n\npub_crate_test! {agm_prec_round_normal_ref_ref_extended<'a>(\n    mut a: &'a ExtendedFloat,\n    mut b: &'a ExtendedFloat,\n    prec: u64,\n    rm: RoundingMode,\n) -> (ExtendedFloat, Ordering) {\n    if a.x < 0u32 || b.x < 0u32 {\n        return (\n            ExtendedFloat {\n                x: float_nan!(),\n                exp: 0,\n            },\n            Equal,\n        );\n    }\n    let q = prec;\n    let mut working_prec = q + q.ceiling_log_base_2() + 15;\n    // b (op2) and a (op1) are the 2 operands but we want b >= a\n    match a.partial_cmp(b).unwrap() {\n        Equal => return ExtendedFloat::from_extended_float_prec_round_ref(a, prec, rm),\n        Greater => swap(&mut a, &mut b),\n        _ => {}\n    }\n    let mut increment = Limb::WIDTH;\n    let mut v;\n    let mut scaleit;\n    loop {\n        let mut err: u64 = 0;\n        let mut u = a.mul_prec_ref_ref(b, working_prec).0;\n        v = a.add_prec_ref_ref(b, working_prec).0;\n        u.sqrt_assign();\n        v >>= 1u32;\n        scaleit = 0;\n        let mut n: u64 = 1;\n        let mut eq = 0;\n        while cmp2_helper_extended(&u, &v, &mut eq) != Equal && eq <= working_prec - 2 {\n            let mut vf;\n            vf = (&u + &v) >> 1;\n            // See proof in algorithms.tex\n            if eq > working_prec >> 2 {\n                // vf = V(k)\n                let low_p = (working_prec + 1) >> 1;\n                let mut w = v.sub_prec_ref_ref(&u, low_p).0; // e = V(k-1)-U(k-1)\n                assert!(w.is_valid());\n                assert!(w.x.is_normal());\n                w.square_round_assign(Nearest); // e = e^2\n                assert!(w.is_valid());\n                assert!(w.x.is_normal());\n                w.shr_round_assign(4, Nearest); // e*= (1/2)^2*1/4\n                assert!(w.is_valid());\n                assert!(w.x.is_normal());\n                w.div_prec_assign_ref(&vf, low_p); // 1/4*e^2/V(k)\n                let vf_exp = vf.exp;\n                v = vf.sub_prec(w, working_prec).0;\n                // 0 or 1\n                err = u64::exact_from(vf_exp - v.exp);\n                break;\n            }\n            let uf = &u * &v;\n            u = uf.sqrt();\n            swap(&mut v, &mut vf);\n            n += 1;\n        }\n        // the error on v is bounded by (18n+51) ulps, or twice if there was an exponent loss in the\n        // final subtraction\n        //\n        // 18n+51 should not overflow since n is about log(p)\n        err += (18 * n + 51).ceiling_log_base_2();\n        // we should have n+2 <= 2^(p/4) [see algorithms.tex]\n        if (n + 2).ceiling_log_base_2() <= working_prec >> 2\n            && float_can_round(v.x.significand_ref().unwrap(), working_prec - err, q, rm)\n        {\n            break;\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n    v.shr_prec_round(scaleit, prec, rm)\n}}\n"
  },
  {
    "path": "malachite-float/src/basic/get_and_set.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::Finite;\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    NegAssign, RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\nconst PREC_ROUND_THRESHOLD: u64 = 1500;\n\nimpl Float {\n    /// Gets the significand of a [`Float`], taking the [`Float`] by value.\n    ///\n    /// The significand is the smallest positive integer which is some power of 2 times the\n    /// [`Float`], and whose number of significant bits is a multiple of the limb width. If the\n    /// [`Float`] is NaN, infinite, or zero, then `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_float::Float;\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Float::NAN.to_significand(), None);\n    /// assert_eq!(Float::INFINITY.to_significand(), None);\n    /// assert_eq!(Float::ZERO.to_significand(), None);\n    ///\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// {\n    ///     assert_eq!(Float::ONE.to_significand(), Some(Natural::power_of_2(63)));\n    ///     assert_eq!(\n    ///         Float::from(std::f64::consts::PI).to_significand().unwrap(),\n    ///         14488038916154245120u64\n    ///     );\n    /// }\n    /// ```\n    #[inline]\n    pub fn to_significand(&self) -> Option<Natural> {\n        match self {\n            Self(Finite { significand, .. }) => Some(significand.clone()),\n            _ => None,\n        }\n    }\n\n    /// Gets the significand of a [`Float`], taking the [`Float`] by reference.\n    ///\n    /// The significand is the smallest positive integer which is some power of 2 times the\n    /// [`Float`], and whose number of significant bits is a multiple of the limb width. If the\n    /// [`Float`] is NaN, infinite, or zero, then `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_float::Float;\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Float::NAN.into_significand(), None);\n    /// assert_eq!(Float::INFINITY.into_significand(), None);\n    /// assert_eq!(Float::ZERO.into_significand(), None);\n    ///\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// {\n    ///     assert_eq!(Float::ONE.into_significand(), Some(Natural::power_of_2(63)));\n    ///     assert_eq!(\n    ///         Float::from(std::f64::consts::PI)\n    ///             .into_significand()\n    ///             .unwrap(),\n    ///         14488038916154245120u64\n    ///     );\n    /// }\n    /// ```\n    #[allow(clippy::missing_const_for_fn)] // destructor doesn't work with const\n    #[inline]\n    pub fn into_significand(self) -> Option<Natural> {\n        match self {\n            Self(Finite { significand, .. }) => Some(significand),\n            _ => None,\n        }\n    }\n\n    /// Returns a reference to the significand of a [`Float`].\n    ///\n    /// The significand is the smallest positive integer which is some power of 2 times the\n    /// [`Float`], and whose number of significant bits is a multiple of the limb width. If the\n    /// [`Float`] is NaN, infinite, or zero, then `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_float::Float;\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Float::NAN.significand_ref(), None);\n    /// assert_eq!(Float::INFINITY.significand_ref(), None);\n    /// assert_eq!(Float::ZERO.significand_ref(), None);\n    ///\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// {\n    ///     assert_eq!(\n    ///         *Float::ONE.significand_ref().unwrap(),\n    ///         Natural::power_of_2(63)\n    ///     );\n    ///     assert_eq!(\n    ///         *Float::from(std::f64::consts::PI).significand_ref().unwrap(),\n    ///         14488038916154245120u64\n    ///     );\n    /// }\n    /// ```\n    #[inline]\n    pub const fn significand_ref(&self) -> Option<&Natural> {\n        match self {\n            Self(Finite { significand, .. }) => Some(significand),\n            _ => None,\n        }\n    }\n\n    /// Returns a [`Float`]'s exponent.\n    ///\n    /// $$\n    /// f(\\text{NaN}) = f(\\pm\\infty) = f(\\pm 0.0) = \\text{None},\n    /// $$\n    ///\n    /// and, if $x$ is finite and nonzero,\n    ///\n    /// $$\n    /// f(x) = \\operatorname{Some}(\\lfloor \\log_2 |x| \\rfloor + 1).\n    /// $$\n    ///\n    /// The output is in the range $[-(2^{30}-1), 2^{30}-1]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.get_exponent(), None);\n    /// assert_eq!(Float::INFINITY.get_exponent(), None);\n    /// assert_eq!(Float::ZERO.get_exponent(), None);\n    ///\n    /// assert_eq!(Float::ONE.get_exponent(), Some(1));\n    /// assert_eq!(Float::from(std::f64::consts::PI).get_exponent(), Some(2));\n    /// assert_eq!(Float::power_of_2(100u64).get_exponent(), Some(101));\n    /// assert_eq!(Float::power_of_2(-100i64).get_exponent(), Some(-99));\n    /// ```\n    #[inline]\n    pub const fn get_exponent(&self) -> Option<i32> {\n        match self {\n            Self(Finite { exponent, .. }) => Some(*exponent),\n            _ => None,\n        }\n    }\n\n    /// Returns a [`Float`]'s precision. The precision is a positive integer denoting how many of\n    /// the [`Float`]'s bits are significant.\n    ///\n    /// Only [`Float`]s that are finite and nonzero have a precision. For other [`Float`]s, `None`\n    /// is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.get_prec(), None);\n    /// assert_eq!(Float::INFINITY.get_prec(), None);\n    /// assert_eq!(Float::ZERO.get_prec(), None);\n    ///\n    /// assert_eq!(Float::ONE.get_prec(), Some(1));\n    /// assert_eq!(Float::one_prec(100).get_prec(), Some(100));\n    /// assert_eq!(Float::from(std::f64::consts::PI).get_prec(), Some(50));\n    /// ```\n    #[inline]\n    pub const fn get_prec(&self) -> Option<u64> {\n        match self {\n            Self(Finite { precision, .. }) => Some(*precision),\n            _ => None,\n        }\n    }\n\n    /// Returns the minimum precision necessary to represent the given [`Float`]'s value.\n    ///\n    /// For example, `Float:one_prec(100)` has a precision of 100, but its minimum precision is 1,\n    /// because that's all that's necessary to represent the value 1.\n    ///\n    /// The minimum precision is always less than or equal to the actual precision.\n    ///\n    /// Only [`Float`]s that are finite and nonzero have a minimum precision. For other [`Float`]s,\n    /// `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.get_min_prec(), None);\n    /// assert_eq!(Float::INFINITY.get_min_prec(), None);\n    /// assert_eq!(Float::ZERO.get_min_prec(), None);\n    ///\n    /// assert_eq!(Float::ONE.get_min_prec(), Some(1));\n    /// assert_eq!(Float::one_prec(100).get_min_prec(), Some(1));\n    /// assert_eq!(Float::from(std::f64::consts::PI).get_min_prec(), Some(50));\n    /// ```\n    pub fn get_min_prec(&self) -> Option<u64> {\n        match self {\n            Self(Finite { significand, .. }) => {\n                Some(significand_bits(significand) - significand.trailing_zeros().unwrap())\n            }\n            _ => None,\n        }\n    }\n\n    /// Changes a [`Float`]'s precision. If the precision decreases, rounding may be necessary, and\n    /// will use the provided [`RoundingMode`].\n    ///\n    /// Returns an [`Ordering`], indicating whether the final value is less than, greater than, or\n    /// equal to the original value.\n    ///\n    /// If the [`Float`] originally had the maximum exponent, it is possible for this function to\n    /// overflow. This is even possible if `rm` is `Nearest`, even though infinity is never nearer\n    /// to the exact result than any finite [`Float`] is. This is to match the behavior of MPFR.\n    ///\n    /// This function never underflows.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is [`Exact`] but setting the desired precision requires\n    /// rounding.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let original_x = Float::from(1.0f64 / 3.0);\n    /// assert_eq!(original_x.to_string(), \"0.33333333333333331\");\n    /// assert_eq!(original_x.get_prec(), Some(53));\n    ///\n    /// let mut x = original_x.clone();\n    /// assert_eq!(x.set_prec_round(100, Exact), Equal);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333148296162562474\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    ///\n    /// let mut x = original_x.clone();\n    /// assert_eq!(x.set_prec_round(10, Floor), Less);\n    /// assert_eq!(x.to_string(), \"0.333\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    ///\n    /// let mut x = original_x.clone();\n    /// assert_eq!(x.set_prec_round(10, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// ```\n    pub fn set_prec_round(&mut self, prec: u64, rm: RoundingMode) -> Ordering {\n        assert_ne!(prec, 0);\n        match self {\n            Self(Finite {\n                sign,\n                exponent,\n                precision,\n                significand,\n            }) => {\n                let target_bits = prec\n                    .round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n                    .0;\n                let significant_bits = significand_bits(significand);\n                let o;\n                if target_bits > significant_bits {\n                    *significand <<= target_bits - significant_bits;\n                    o = Equal;\n                } else {\n                    let limb_count = significand.limb_count();\n                    let abs_rm = if *sign { rm } else { -rm };\n                    o = significand\n                        .round_to_multiple_of_power_of_2_assign(significant_bits - prec, abs_rm);\n                    if significand.limb_count() > limb_count {\n                        if *exponent == Self::MAX_EXPONENT {\n                            return if *sign {\n                                *self = Self::INFINITY;\n                                Greater\n                            } else {\n                                *self = Self::NEGATIVE_INFINITY;\n                                Less\n                            };\n                        }\n                        *significand >>= 1;\n                        *exponent += 1;\n                    }\n                    *significand >>= significant_bits - target_bits;\n                }\n                *precision = prec;\n                if *sign { o } else { o.reverse() }\n            }\n            _ => Equal,\n        }\n    }\n\n    /// Changes a [`Float`]'s precision. If the precision decreases, rounding may be necessary, and\n    /// [`Nearest`] will be used.\n    ///\n    /// Returns an [`Ordering`], indicating whether the final value is less than, greater than, or\n    /// equal to the original value.\n    ///\n    /// If the [`Float`] originally had the maximum exponent, it is possible for this function to\n    /// overflow, even though infinity is never nearer to the exact result than any finite [`Float`]\n    /// is. This is to match the behavior of MPFR.\n    ///\n    /// This function never underflows.\n    ///\n    /// To use a different rounding mode, try [`Float::set_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let original_x = Float::from(1.0f64 / 3.0);\n    /// assert_eq!(original_x.to_string(), \"0.33333333333333331\");\n    /// assert_eq!(original_x.get_prec(), Some(53));\n    ///\n    /// let mut x = original_x.clone();\n    /// assert_eq!(x.set_prec(100), Equal);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333148296162562474\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    ///\n    /// let mut x = original_x.clone();\n    /// assert_eq!(x.set_prec(10), Greater);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// ```\n    #[inline]\n    pub fn set_prec(&mut self, p: u64) -> Ordering {\n        self.set_prec_round(p, Nearest)\n    }\n\n    /// Creates a [`Float`] from another [`Float`], possibly with a different precision. If the\n    /// precision decreases, rounding may be necessary, and will use the provided [`RoundingMode`].\n    /// The input [`Float`] is taken by value.\n    ///\n    /// Returns an [`Ordering`], indicating whether the final value is less than, greater than, or\n    /// equal to the original value.\n    ///\n    /// If the input [`Float`] has the maximum exponent, it is possible for this function to\n    /// overflow. This is even possible if `rm` is `Nearest`, even though infinity is never nearer\n    /// to the exact result than any finite [`Float`] is. This is to match the behavior of MPFR.\n    ///\n    /// This function never underflows.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is [`Exact`] but setting the desired precision requires\n    /// rounding.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let original_x = Float::from(1.0f64 / 3.0);\n    /// assert_eq!(original_x.to_string(), \"0.33333333333333331\");\n    /// assert_eq!(original_x.get_prec(), Some(53));\n    ///\n    /// let (x, o) = Float::from_float_prec_round(original_x.clone(), 100, Exact);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333148296162562474\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_float_prec_round(original_x.clone(), 10, Floor);\n    /// assert_eq!(x.to_string(), \"0.333\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_float_prec_round(original_x.clone(), 10, Ceiling);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_float_prec_round(mut x: Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = x.set_prec_round(prec, rm);\n        (x, o)\n    }\n\n    /// Creates a [`Float`] from another [`Float`], possibly with a different precision. If the\n    /// precision decreases, rounding may be necessary, and will use the provided [`RoundingMode`].\n    /// The input [`Float`] is taken by reference.\n    ///\n    /// Returns an [`Ordering`], indicating whether the final value is less than, greater than, or\n    /// equal to the original value.\n    ///\n    /// If the input [`Float`] has the maximum exponent, it is possible for this function to\n    /// overflow. This is even possible if `rm` is `Nearest`, even though infinity is never nearer\n    /// to the exact result than any finite [`Float`] is. This is to match the behavior of MPFR.\n    ///\n    /// This function never underflows.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is [`Exact`] but setting the desired precision requires\n    /// rounding.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let original_x = Float::from(1.0f64 / 3.0);\n    /// assert_eq!(original_x.to_string(), \"0.33333333333333331\");\n    /// assert_eq!(original_x.get_prec(), Some(53));\n    ///\n    /// let (x, o) = Float::from_float_prec_round_ref(&original_x, 100, Exact);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333148296162562474\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_float_prec_round_ref(&original_x, 10, Floor);\n    /// assert_eq!(x.to_string(), \"0.333\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_float_prec_round_ref(&original_x, 10, Ceiling);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn from_float_prec_round_ref(x: &Self, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        if x.significant_bits() < PREC_ROUND_THRESHOLD {\n            let mut x = x.clone();\n            let o = x.set_prec_round(prec, rm);\n            return (x, o);\n        }\n        match x {\n            Self(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                let (mut y, mut o) = Self::from_natural_prec_round_ref(\n                    significand,\n                    prec,\n                    if *sign { rm } else { -rm },\n                );\n                if !sign {\n                    y.neg_assign();\n                    o = o.reverse();\n                }\n                (\n                    y >> (i32::exact_from(significand_bits(significand)) - exponent),\n                    o,\n                )\n            }\n            _ => (x.clone(), Equal),\n        }\n    }\n\n    /// Creates a [`Float`] from another [`Float`], possibly with a different precision. If the\n    /// precision decreases, rounding may be necessary, and will use [`Nearest`]. The input\n    /// [`Float`] is taken by value.\n    ///\n    /// Returns an [`Ordering`], indicating whether the final value is less than, greater than, or\n    /// equal to the original value.\n    ///\n    /// If the [`Float`] originally had the maximum exponent, it is possible for this function to\n    /// overflow, even though infinity is never nearer to the exact result than any finite [`Float`]\n    /// is. This is to match the behavior of MPFR.\n    ///\n    /// This function never underflows.\n    ///\n    /// To use a different rounding mode, try [`Float::from_float_prec_round`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let original_x = Float::from(1.0f64 / 3.0);\n    /// assert_eq!(original_x.to_string(), \"0.33333333333333331\");\n    /// assert_eq!(original_x.get_prec(), Some(53));\n    ///\n    /// let (x, o) = Float::from_float_prec(original_x.clone(), 100);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333148296162562474\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_float_prec(original_x.clone(), 10);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_float_prec(mut x: Self, prec: u64) -> (Self, Ordering) {\n        let o = x.set_prec(prec);\n        (x, o)\n    }\n\n    /// Creates a [`Float`] from another [`Float`], possibly with a different precision. If the\n    /// precision decreases, rounding may be necessary, and will use [`Nearest`]. The input\n    /// [`Float`] is taken by reference.\n    ///\n    /// Returns an [`Ordering`], indicating whether the final value is less than, greater than, or\n    /// equal to the original value.\n    ///\n    /// If the [`Float`] originally had the maximum exponent, it is possible for this function to\n    /// overflow, even though infinity is never nearer to the exact result than any finite [`Float`]\n    /// is. This is to match the behavior of MPFR.\n    ///\n    /// This function never underflows.\n    ///\n    /// To use a different rounding mode, try [`Float::from_float_prec_round_ref`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let original_x = Float::from(1.0f64 / 3.0);\n    /// assert_eq!(original_x.to_string(), \"0.33333333333333331\");\n    /// assert_eq!(original_x.get_prec(), Some(53));\n    ///\n    /// let (x, o) = Float::from_float_prec_ref(&original_x, 100);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333148296162562474\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_float_prec_ref(&original_x, 10);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_float_prec_ref(x: &Self, prec: u64) -> (Self, Ordering) {\n        Self::from_float_prec_round_ref(x, prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/basic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Classification of a [`Float`](super::Float) into several kinds.\npub mod classification;\n/// Measuring the complexity to a [`Float`](super::Float).\npub mod complexity;\n/// Various [`Float`](super::Float) constants. This module contains actual Rust constants like\n/// [`One`](super::Float#impl-One-for-Float), and functions like [`one`](super::Float::one_prec)\n/// which accept a precision.\n#[macro_use]\npub mod constants;\n/// Floating-point numbers with a greater exponent range; for internal use only.\npub mod extended;\n/// Getting and setting the components of a [`Float`](super::Float).\npub mod get_and_set;\n/// Getting [`Float`](super::Float)'s ulp (unit in the last place).\npub mod ulp;\n"
  },
  {
    "path": "malachite-float/src/basic/ulp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::Finite;\nuse crate::{Float, significand_bits};\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, NegAssign, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, Zero};\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::bit_to_limb_count_floor;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Gets a [`Float`]'s ulp (unit in last place, or unit of least precision).\n    ///\n    /// If the [`Float`] is positive, its ulp is the distance to the next-largest [`Float`] with the\n    /// same precision; if it is negative, the next-smallest. (This definition works even if the\n    /// [`Float`] is the largest in its binade. If the [`Float`] is the largest in its binade and\n    /// has the maximum exponent, we can define its ulp to be the distance to the next-smallest\n    /// [`Float`] with the same precision if positive, and to the next-largest [`Float`] with the\n    /// same precision if negative.)\n    ///\n    /// If the [`Float`] is NaN, infinite, or zero, then `None` is returned.\n    ///\n    /// This function does not overflow or underflow, technically. But it is possible that a\n    /// [`Float`]'s ulp is too small to represent, for example if the [`Float`] has the minimum\n    /// exponent and its precision is greater than 1, or if the precision is extremely large in\n    /// general. In such cases, `None` is returned.\n    ///\n    /// $$\n    /// f(\\text{NaN}) = f(\\pm\\infty) = f(\\pm 0.0) = \\text{None},\n    /// $$\n    ///\n    /// and, if $x$ is finite and nonzero,\n    ///\n    /// $$\n    /// f(x) = \\operatorname{Some}(2^{\\lfloor \\log_2 |x| \\rfloor-p+1}),\n    /// $$\n    /// where $p$ is the precision of $x$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, NegativeOne, One, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::NAN.ulp(), None);\n    /// assert_eq!(Float::INFINITY.ulp(), None);\n    /// assert_eq!(Float::ZERO.ulp(), None);\n    ///\n    /// let s = Float::ONE.ulp().map(|x| x.to_string());\n    /// assert_eq!(s.as_ref().map(|s| s.as_str()), Some(\"1.0\"));\n    ///\n    /// let s = Float::one_prec(100).ulp().map(|x| x.to_string());\n    /// assert_eq!(s.as_ref().map(|s| s.as_str()), Some(\"2.0e-30\"));\n    ///\n    /// let s = Float::from(std::f64::consts::PI)\n    ///     .ulp()\n    ///     .map(|x| x.to_string());\n    /// assert_eq!(s.as_ref().map(|s| s.as_str()), Some(\"4.0e-15\"));\n    ///\n    /// let s = Float::power_of_2(100u64).ulp().map(|x| x.to_string());\n    /// assert_eq!(s.as_ref().map(|s| s.as_str()), Some(\"1.0e30\"));\n    ///\n    /// let s = Float::power_of_2(-100i64).ulp().map(|x| x.to_string());\n    /// assert_eq!(s.as_ref().map(|s| s.as_str()), Some(\"8.0e-31\"));\n    ///\n    /// let s = Float::NEGATIVE_ONE.ulp().map(|x| x.to_string());\n    /// assert_eq!(s.as_ref().map(|s| s.as_str()), Some(\"1.0\"));\n    /// ```\n    pub fn ulp(&self) -> Option<Self> {\n        match self {\n            Self(Finite {\n                exponent,\n                precision,\n                ..\n            }) => {\n                let ulp_exponent =\n                    i64::from(*exponent).checked_sub(i64::try_from(*precision).ok()?)?;\n                if i32::try_from(ulp_exponent).ok()? >= Self::MIN_EXPONENT - 1 {\n                    Some(Self::power_of_2(ulp_exponent))\n                } else {\n                    None\n                }\n            }\n            _ => None,\n        }\n    }\n\n    /// Increments a [`Float`] by its ulp. See [`Float::ulp`] for details.\n    ///\n    /// If the [`Float`] is positive and is the largest [`Float`] in its binade with its precision,\n    /// then\n    /// - If its exponent is not the maximum exponent, it will become the smallest [`Float`] in the\n    ///   next-higher binade, and its precision will increase by 1 (so that its ulp remains the\n    ///   same);\n    /// - If its exponent is the maximum exponent, it will become $\\infty$.\n    ///\n    /// If the [`Float`] is negative and is closer to zero than any other [`Float`] in its binade\n    /// with its precision, then\n    /// - If its precision is 1, it will become negative zero.\n    /// - If its precision is greater than 1 and its exponent is not the minimum exponent, it will\n    ///   become the farthest-from-zero [`Float`] in the next-lower binade, and its precision will\n    ///   decrease by 1 (so that its ulp remains the same).\n    /// - If its precision is greater than 1 and its exponent is the minimum exponent, it will\n    ///   become negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is NaN, infinite, or zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::ONE;\n    /// assert_eq!(x.to_string(), \"1.0\");\n    /// x.increment();\n    /// assert_eq!(x.to_string(), \"2.0\");\n    ///\n    /// let mut x = Float::one_prec(100);\n    /// assert_eq!(x.to_string(), \"1.0\");\n    /// x.increment();\n    /// assert_eq!(x.to_string(), \"1.000000000000000000000000000002\");\n    ///\n    /// let mut x = Float::from(std::f64::consts::PI);\n    /// assert_eq!(x.to_string(), \"3.141592653589793\");\n    /// x.increment();\n    /// assert_eq!(x.to_string(), \"3.141592653589797\");\n    ///\n    /// let mut x = Float::power_of_2(100u64);\n    /// assert_eq!(x.to_string(), \"1.0e30\");\n    /// x.increment();\n    /// assert_eq!(x.to_string(), \"3.0e30\");\n    ///\n    /// let mut x = Float::power_of_2(-100i64);\n    /// assert_eq!(x.to_string(), \"8.0e-31\");\n    /// x.increment();\n    /// assert_eq!(x.to_string(), \"1.6e-30\");\n    ///\n    /// let mut x = Float::NEGATIVE_ONE;\n    /// assert_eq!(x.to_string(), \"-1.0\");\n    /// x.increment();\n    /// assert_eq!(x.to_string(), \"-0.0\");\n    /// ```\n    pub fn increment(&mut self) {\n        if self.is_sign_negative() {\n            self.neg_assign();\n            self.decrement();\n            self.neg_assign();\n        } else if let Self(Finite {\n            exponent,\n            precision,\n            significand,\n            ..\n        }) = self\n        {\n            let ulp = Limb::power_of_2(significand_bits(significand) - *precision);\n            let limb_count = significand.limb_count();\n            significand.add_assign_at_limb(\n                usize::wrapping_from(limb_count) - 1 - bit_to_limb_count_floor(*precision - 1),\n                ulp,\n            );\n            if significand.limb_count() > limb_count {\n                if *exponent == Self::MAX_EXPONENT {\n                    *self = Self::INFINITY;\n                    return;\n                }\n                *significand >>= 1;\n                *exponent += 1;\n                if precision.divisible_by_power_of_2(Limb::LOG_WIDTH) {\n                    *significand <<= Limb::WIDTH;\n                }\n                *precision = precision.checked_add(1).unwrap();\n            }\n        } else {\n            panic!(\"Cannot increment float is non-finite or zero\");\n        }\n    }\n\n    /// Decrements a [`Float`] by its ulp. See [`Float::ulp`] for details.\n    ///\n    /// If the [`Float`] is negative and is the largest [`Float`] in its binade with its precision,\n    /// then\n    /// - If its exponent is not the maximum exponent, it will become the closest-to-zero [`Float`]\n    ///   in the next-higher binade, and its precision will increase by 1 (so that its ulp remains\n    ///   the same);\n    /// - If its exponent is the maximum exponent, it will become $-\\infty$.\n    ///\n    /// If the [`Float`] is positive and is smaller than any other [`Float`] in its binade with its\n    /// precision, then\n    /// - If its precision is 1, it will become positive zero.\n    /// - If its precision is greater than 1 and its exponent is not the minimum exponent, it will\n    ///   become the largest [`Float`] in the next-lower binade, and its precision will decrease by\n    ///   1 (so that its ulp remains the same).\n    /// - If its precision is greater than 1 and its exponent is the minimum exponent, it will\n    ///   become positive zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is NaN, infinite, or zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_float::Float;\n    ///\n    /// let mut x = Float::ONE;\n    /// assert_eq!(x.to_string(), \"1.0\");\n    /// x.decrement();\n    /// assert_eq!(x.to_string(), \"0.0\");\n    ///\n    /// let mut x = Float::one_prec(100);\n    /// assert_eq!(x.to_string(), \"1.0\");\n    /// x.decrement();\n    /// assert_eq!(x.to_string(), \"0.999999999999999999999999999998\");\n    ///\n    /// let mut x = Float::from(std::f64::consts::PI);\n    /// assert_eq!(x.to_string(), \"3.141592653589793\");\n    /// x.decrement();\n    /// assert_eq!(x.to_string(), \"3.14159265358979\");\n    ///\n    /// let mut x = Float::power_of_2(100u64);\n    /// assert_eq!(x.to_string(), \"1.0e30\");\n    /// x.decrement();\n    /// assert_eq!(x.to_string(), \"0.0\");\n    ///\n    /// let mut x = Float::power_of_2(-100i64);\n    /// assert_eq!(x.to_string(), \"8.0e-31\");\n    /// x.decrement();\n    /// assert_eq!(x.to_string(), \"0.0\");\n    ///\n    /// let mut x = Float::NEGATIVE_ONE;\n    /// assert_eq!(x.to_string(), \"-1.0\");\n    /// x.decrement();\n    /// assert_eq!(x.to_string(), \"-2.0\");\n    /// ```\n    pub fn decrement(&mut self) {\n        if self.is_sign_negative() {\n            self.neg_assign();\n            self.increment();\n            self.neg_assign();\n        } else if let Self(Finite {\n            exponent,\n            precision,\n            significand,\n            ..\n        }) = self\n        {\n            let bits = significand_bits(significand);\n            let ulp = Limb::power_of_2(bits - *precision);\n            significand.sub_assign_at_limb(\n                usize::wrapping_from(significand.limb_count())\n                    - 1\n                    - bit_to_limb_count_floor(*precision - 1),\n                ulp,\n            );\n            if *significand == 0u32 {\n                *self = Self::ZERO;\n            } else if significand.significant_bits() < bits {\n                if *exponent == Self::MIN_EXPONENT {\n                    *self = Self::ZERO;\n                    return;\n                }\n                *significand <<= 1;\n                *exponent -= 1;\n                *precision = precision.checked_sub(1).unwrap();\n                if bits - *precision == Limb::WIDTH {\n                    *significand >>= Limb::WIDTH;\n                }\n            }\n        } else {\n            panic!(\"Cannot decrement float that is non-finite or zero\");\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/bin.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n\n#[cfg(feature = \"bin_build\")]\nextern crate itertools;\n#[cfg(feature = \"bin_build\")]\n#[macro_use]\nextern crate malachite_base;\n#[cfg(feature = \"bin_build\")]\nextern crate malachite_nz;\n#[cfg(feature = \"bin_build\")]\nextern crate malachite_q;\n#[cfg(feature = \"bin_build\")]\nextern crate num;\n#[cfg(feature = \"bin_build\")]\nextern crate rug;\n#[cfg(feature = \"bin_build\")]\nextern crate serde;\n#[cfg(feature = \"bin_build\")]\nextern crate serde_json;\n\n#[cfg(feature = \"bin_build\")]\nuse crate::bin_util::demo_and_bench::register;\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::Runner;\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::cmd::read_command_line_arguments;\n\n// Examples: TODO\n//\n// ```\n// cargo run --release --features bin_build -- -l 10000 -m special_random -d demo_from_naturals\n//      -c \"mean_bits_n 128 mean_bits_d 1\"\n// ```\n#[cfg(feature = \"bin_build\")]\nfn main() {\n    let args = read_command_line_arguments(\"malachite-float test utils\");\n    let mut runner = Runner::new();\n    register(&mut runner);\n    if let Some(demo_key) = args.demo_key {\n        runner.run_demo(&demo_key, args.generation_mode, &args.config, args.limit);\n    } else if let Some(bench_key) = args.bench_key {\n        runner.run_bench(\n            &bench_key,\n            args.generation_mode,\n            &args.config,\n            args.limit,\n            &args.out,\n        );\n    } else {\n        panic!();\n    }\n}\n\n#[cfg(not(feature = \"bin_build\"))]\nfn main() {}\n\n#[cfg(feature = \"bin_build\")]\npub mod bin_util {\n    pub mod demo_and_bench;\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_2_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{float_gen, float_gen_rm, float_gen_var_12};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_abs_negative_zero);\n    register_demo!(runner, demo_float_abs_negative_zero_debug);\n    register_demo!(runner, demo_float_abs_negative_zero_extreme);\n    register_demo!(runner, demo_float_abs_negative_zero_extreme_debug);\n    register_demo!(runner, demo_float_abs_negative_zero_ref);\n    register_demo!(runner, demo_float_abs_negative_zero_ref_debug);\n    register_demo!(runner, demo_float_abs_negative_zero_assign);\n    register_demo!(runner, demo_float_abs_negative_zero_assign_debug);\n    register_demo!(runner, demo_float_abs);\n    register_demo!(runner, demo_float_abs_debug);\n    register_demo!(runner, demo_float_abs_extreme);\n    register_demo!(runner, demo_float_abs_extreme_debug);\n    register_demo!(runner, demo_float_abs_ref);\n    register_demo!(runner, demo_float_abs_ref_debug);\n    register_demo!(runner, demo_float_abs_assign);\n    register_demo!(runner, demo_float_abs_assign_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_abs_negative_zero_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_abs_negative_zero_assign);\n    register_bench!(runner, benchmark_float_abs_library_comparison);\n    register_bench!(runner, benchmark_float_abs_evaluation_strategy);\n    register_bench!(runner, benchmark_float_abs_assign);\n}\n\nfn demo_float_abs_negative_zero(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"abs_negative_zero({}) = {}\",\n            n.clone(),\n            n.abs_negative_zero()\n        );\n    }\n}\n\nfn demo_float_abs_negative_zero_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"abs_negative_zero({:#x}) = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(n.abs_negative_zero())\n        );\n    }\n}\n\nfn demo_float_abs_negative_zero_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"abs_negative_zero({}) = {}\",\n            n.clone(),\n            n.abs_negative_zero()\n        );\n    }\n}\n\nfn demo_float_abs_negative_zero_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"abs_negative_zero({:#x}) = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(n.abs_negative_zero())\n        );\n    }\n}\n\nfn demo_float_abs_negative_zero_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"abs_negative_zero_ref(&{}) = {}\",\n            n,\n            n.abs_negative_zero_ref()\n        );\n    }\n}\n\nfn demo_float_abs_negative_zero_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"abs_negative_zero(&{:#x}) = {:#x}\",\n            ComparableFloatRef(&n),\n            ComparableFloat(n.abs_negative_zero_ref())\n        );\n    }\n}\n\nfn demo_float_abs_negative_zero_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in float_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.abs_negative_zero_assign();\n        println!(\"n := {n_old}; n.abs_negative_zero_assign(); n = {n}\");\n    }\n}\n\nfn demo_float_abs_negative_zero_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in float_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.abs_negative_zero_assign();\n        println!(\n            \"n := {:#x}; n.abs_negative_zero_assign(); n = {:#x}\",\n            ComparableFloat(n_old),\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\"|{}| = {}\", n.clone(), n.abs());\n    }\n}\n\nfn demo_float_abs_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"|{:#x}| = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(n.abs())\n        );\n    }\n}\n\nfn demo_float_abs_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"|{}| = {}\", n.clone(), n.abs());\n    }\n}\n\nfn demo_float_abs_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"|{:#x}| = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(n.abs())\n        );\n    }\n}\n\nfn demo_float_abs_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\"|&{}| = {}\", n, (&n).abs());\n    }\n}\n\nfn demo_float_abs_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"|&{:#x}| = {:#x}\",\n            ComparableFloatRef(&n),\n            ComparableFloat((&n).abs())\n        );\n    }\n}\n\nfn demo_float_abs_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in float_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.abs_assign();\n        println!(\"n := {n_old}; n.abs_assign(); n = {n}\");\n    }\n}\n\nfn demo_float_abs_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in float_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.abs_assign();\n        println!(\n            \"n := {:#x}; n.abs_assign(); n = {:#x}\",\n            ComparableFloat(n_old),\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn benchmark_float_abs_negative_zero_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs_negative_zero()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Rational.abs_negative_zero()\", &mut |n| {\n                no_out!(n.abs_negative_zero());\n            }),\n            (\"(&Rational).abs_negative_zero_ref()\", &mut |n| {\n                no_out!(n.abs_negative_zero_ref());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_abs_negative_zero_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs_negative_zero_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.abs_negative_zero_assign())],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_abs_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(n.abs())),\n            (\"rug\", &mut |(n, _)| no_out!(n.abs())),\n        ],\n    );\n}\n\nfn benchmark_float_abs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Rational.abs()\", &mut |n| no_out!(n.abs())),\n            (\"(&Rational).abs()\", &mut |n| no_out!((&n).abs())),\n        ],\n    );\n}\n\nfn benchmark_float_abs_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.abs_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.abs_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::add::{\n    add_prec_round_naive, add_rational_prec_round_naive, rug_add, rug_add_prec, rug_add_prec_round,\n    rug_add_rational, rug_add_rational_prec, rug_add_rational_prec_round, rug_add_rational_round,\n    rug_add_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer, pair_2_pair_float_rational_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_max_complexity_bucketer,\n    pair_2_triple_1_2_float_rational_max_complexity_bucketer,\n    pair_2_triple_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_float_rational_primitive_int_max_complexity_bucketer,\n    pair_float_max_complexity_bucketer, pair_float_rational_max_complexity_bucketer,\n    quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_max_complexity_bucketer, triple_1_2_float_rational_max_complexity_bucketer,\n    triple_float_float_primitive_int_max_complexity_bucketer,\n    triple_float_rational_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_1, float_float_rounding_mode_triple_gen_var_1_rm,\n    float_float_rounding_mode_triple_gen_var_29,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_1_rm,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_5, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_1_rm, float_float_unsigned_triple_gen_var_2,\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10, float_rational_pair_gen,\n    float_rational_pair_gen_rm, float_rational_pair_gen_var_2,\n    float_rational_rounding_mode_triple_gen_var_1,\n    float_rational_rounding_mode_triple_gen_var_3_rm,\n    float_rational_rounding_mode_triple_gen_var_7,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_1_rm,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_6,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_1_rm,\n    float_rational_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse std::cmp::max;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_add);\n    register_demo!(runner, demo_float_add_debug);\n    register_demo!(runner, demo_float_add_extreme);\n    register_demo!(runner, demo_float_add_extreme_debug);\n    register_demo!(runner, demo_float_add_val_ref);\n    register_demo!(runner, demo_float_add_val_ref_debug);\n    register_demo!(runner, demo_float_add_ref_val);\n    register_demo!(runner, demo_float_add_ref_val_debug);\n    register_demo!(runner, demo_float_add_ref_ref);\n    register_demo!(runner, demo_float_add_ref_ref_debug);\n    register_demo!(runner, demo_float_add_assign);\n    register_demo!(runner, demo_float_add_assign_debug);\n    register_demo!(runner, demo_float_add_assign_ref);\n    register_demo!(runner, demo_float_add_assign_ref_debug);\n    register_demo!(runner, demo_float_add_prec);\n    register_demo!(runner, demo_float_add_prec_debug);\n    register_demo!(runner, demo_float_add_prec_extreme);\n    register_demo!(runner, demo_float_add_prec_extreme_debug);\n    register_demo!(runner, demo_float_add_prec_val_ref);\n    register_demo!(runner, demo_float_add_prec_val_ref_debug);\n    register_demo!(runner, demo_float_add_prec_ref_val);\n    register_demo!(runner, demo_float_add_prec_ref_val_debug);\n    register_demo!(runner, demo_float_add_prec_ref_ref);\n    register_demo!(runner, demo_float_add_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_add_prec_assign);\n    register_demo!(runner, demo_float_add_prec_assign_debug);\n    register_demo!(runner, demo_float_add_prec_assign_ref);\n    register_demo!(runner, demo_float_add_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_add_round);\n    register_demo!(runner, demo_float_add_round_debug);\n    register_demo!(runner, demo_float_add_round_extreme);\n    register_demo!(runner, demo_float_add_round_extreme_debug);\n    register_demo!(runner, demo_float_add_round_val_ref);\n    register_demo!(runner, demo_float_add_round_val_ref_debug);\n    register_demo!(runner, demo_float_add_round_ref_val);\n    register_demo!(runner, demo_float_add_round_ref_val_debug);\n    register_demo!(runner, demo_float_add_round_ref_ref);\n    register_demo!(runner, demo_float_add_round_ref_ref_debug);\n    register_demo!(runner, demo_float_add_round_assign);\n    register_demo!(runner, demo_float_add_round_assign_debug);\n    register_demo!(runner, demo_float_add_round_assign_ref);\n    register_demo!(runner, demo_float_add_round_assign_ref_debug);\n    register_demo!(runner, demo_float_add_prec_round);\n    register_demo!(runner, demo_float_add_prec_round_debug);\n    register_demo!(runner, demo_float_add_prec_round_extreme);\n    register_demo!(runner, demo_float_add_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_add_prec_round_val_ref);\n    register_demo!(runner, demo_float_add_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_add_prec_round_ref_val);\n    register_demo!(runner, demo_float_add_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_add_prec_round_ref_ref);\n    register_demo!(runner, demo_float_add_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_add_prec_round_assign);\n    register_demo!(runner, demo_float_add_prec_round_assign_debug);\n    register_demo!(runner, demo_float_add_prec_round_assign_ref);\n    register_demo!(runner, demo_float_add_prec_round_assign_ref_debug);\n    register_demo!(runner, demo_float_add_rational);\n    register_demo!(runner, demo_float_add_rational_debug);\n    register_demo!(runner, demo_float_add_rational_extreme);\n    register_demo!(runner, demo_float_add_rational_extreme_debug);\n    register_demo!(runner, demo_float_add_rational_val_ref);\n    register_demo!(runner, demo_float_add_rational_val_ref_debug);\n    register_demo!(runner, demo_float_add_rational_ref_val);\n    register_demo!(runner, demo_float_add_rational_ref_val_debug);\n    register_demo!(runner, demo_float_add_rational_ref_ref);\n    register_demo!(runner, demo_float_add_rational_ref_ref_debug);\n    register_demo!(runner, demo_float_add_rational_assign);\n    register_demo!(runner, demo_float_add_rational_assign_debug);\n    register_demo!(runner, demo_float_add_rational_assign_ref);\n    register_demo!(runner, demo_float_add_rational_assign_ref_debug);\n    register_demo!(runner, demo_rational_add_float);\n    register_demo!(runner, demo_rational_add_float_debug);\n    register_demo!(runner, demo_rational_add_float_extreme);\n    register_demo!(runner, demo_rational_add_float_extreme_debug);\n    register_demo!(runner, demo_rational_add_float_val_ref);\n    register_demo!(runner, demo_rational_add_float_val_ref_debug);\n    register_demo!(runner, demo_rational_add_float_ref_val);\n    register_demo!(runner, demo_rational_add_float_ref_val_debug);\n    register_demo!(runner, demo_rational_add_float_ref_ref);\n    register_demo!(runner, demo_rational_add_float_ref_ref_debug);\n    register_demo!(runner, demo_float_add_rational_prec);\n    register_demo!(runner, demo_float_add_rational_prec_debug);\n    register_demo!(runner, demo_float_add_rational_prec_extreme);\n    register_demo!(runner, demo_float_add_rational_prec_extreme_debug);\n    register_demo!(runner, demo_float_add_rational_prec_val_ref);\n    register_demo!(runner, demo_float_add_rational_prec_val_ref_debug);\n    register_demo!(runner, demo_float_add_rational_prec_ref_val);\n    register_demo!(runner, demo_float_add_rational_prec_ref_val_debug);\n    register_demo!(runner, demo_float_add_rational_prec_ref_ref);\n    register_demo!(runner, demo_float_add_rational_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_add_rational_prec_assign);\n    register_demo!(runner, demo_float_add_rational_prec_assign_debug);\n    register_demo!(runner, demo_float_add_rational_prec_assign_ref);\n    register_demo!(runner, demo_float_add_rational_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_add_rational_round);\n    register_demo!(runner, demo_float_add_rational_round_debug);\n    register_demo!(runner, demo_float_add_rational_round_extreme);\n    register_demo!(runner, demo_float_add_rational_round_extreme_debug);\n    register_demo!(runner, demo_float_add_rational_round_val_ref);\n    register_demo!(runner, demo_float_add_rational_round_val_ref_debug);\n    register_demo!(runner, demo_float_add_rational_round_ref_val);\n    register_demo!(runner, demo_float_add_rational_round_ref_val_debug);\n    register_demo!(runner, demo_float_add_rational_round_ref_ref);\n    register_demo!(runner, demo_float_add_rational_round_ref_ref_debug);\n    register_demo!(runner, demo_float_add_rational_round_assign);\n    register_demo!(runner, demo_float_add_rational_round_assign_debug);\n    register_demo!(runner, demo_float_add_rational_round_assign_ref);\n    register_demo!(runner, demo_float_add_rational_round_assign_ref_debug);\n    register_demo!(runner, demo_float_add_rational_prec_round);\n    register_demo!(runner, demo_float_add_rational_prec_round_debug);\n    register_demo!(runner, demo_float_add_rational_prec_round_extreme);\n    register_demo!(runner, demo_float_add_rational_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_add_rational_prec_round_val_ref);\n    register_demo!(runner, demo_float_add_rational_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_add_rational_prec_round_ref_val);\n    register_demo!(runner, demo_float_add_rational_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_add_rational_prec_round_ref_ref);\n    register_demo!(runner, demo_float_add_rational_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_add_rational_prec_round_assign);\n    register_demo!(runner, demo_float_add_rational_prec_round_assign_debug);\n    register_demo!(runner, demo_float_add_rational_prec_round_assign_ref);\n    register_demo!(runner, demo_float_add_rational_prec_round_assign_ref_debug);\n\n    register_bench!(runner, benchmark_float_add_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_library_comparison);\n    register_bench!(runner, benchmark_float_add_algorithms);\n    register_bench!(runner, benchmark_float_add_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_prec_library_comparison);\n    register_bench!(runner, benchmark_float_add_prec_algorithms);\n    register_bench!(runner, benchmark_float_add_prec_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_round_library_comparison);\n    register_bench!(runner, benchmark_float_add_round_algorithms);\n    register_bench!(runner, benchmark_float_add_round_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_add_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_add_prec_round_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_add_rational_evaluation_strategy);\n    register_bench!(runner, benchmark_float_add_rational_library_comparison);\n    register_bench!(runner, benchmark_float_add_rational_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_add_float_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_add_float_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_prec_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_add_rational_prec_library_comparison);\n    register_bench!(runner, benchmark_float_add_rational_prec_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_prec_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_add_rational_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_round_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_add_rational_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_add_rational_prec_round_assign_evaluation_strategy\n    );\n}\n\nfn demo_float_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_float_add_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} + {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x + y)\n        );\n    }\n}\n\nfn demo_float_add_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_float_add_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} + {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x + y)\n        );\n    }\n}\n\nfn demo_float_add_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} + &{} = {}\", x_old, y, x + &y);\n    }\n}\n\nfn demo_float_add_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} + &{:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloatRef(&y),\n            ComparableFloat(x + &y)\n        );\n    }\n}\n\nfn demo_float_add_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} + {} = {}\", x, y_old, &x + y);\n    }\n}\n\nfn demo_float_add_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} + {:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat(y_old),\n            ComparableFloat(&x + y)\n        );\n    }\n}\n\nfn demo_float_add_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} + &{} = {}\", x, y, &x + &y);\n    }\n}\n\nfn demo_float_add_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} + &{:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloatRef(&y),\n            ComparableFloat(&x + &y)\n        );\n    }\n}\n\nfn demo_float_add_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\"x := {x_old}; x += {y}; x = {x}\");\n    }\n}\n\nfn demo_float_add_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\n            \"x := {:#x}; x += {:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\"x := {x_old}; x += &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_add_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\n            \"x := {:#x}; x += &{:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.add_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_add_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_prec(y, prec);\n        println!(\n            \"({:#x}).add_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.add_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_add_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_prec(y, prec);\n        println!(\n            \"({:#x}).add_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).add_prec_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.add_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_add_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.add_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).add_prec_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).add_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.add_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_add_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.add_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).add_prec_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).add_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.add_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_add_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.add_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).add_prec_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.add_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.add_prec_assign({y_old}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_add_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.add_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.add_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.add_prec_assign({y}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_add_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.add_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.add_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_add_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_round(y, rm);\n        println!(\n            \"({:#x}).add_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_29()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.add_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_add_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_29()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_round(y, rm);\n        println!(\n            \"({:#x}).add_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).add_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.add_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_add_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.add_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).add_round_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).add_round_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.add_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_add_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.add_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).add_round_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).add_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.add_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_add_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.add_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).add_round_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.add_round_assign(y, rm);\n        println!(\"x := {x_old}; x.add_round_assign({y_old}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_add_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.add_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.add_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.add_round_assign({y}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_add_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.add_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.add_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).add_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.add_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).add_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).add_prec_round(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.add_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.add_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).add_prec_round_val_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).add_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.add_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.add_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).add_prec_round_ref_val({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).add_prec_round({}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.add_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.add_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).add_prec_round_ref_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_prec_round_assign(y, prec, rm);\n        println!(\"x := {x_old}; x.add_prec_round({y_old}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_add_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.add_prec_round({:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_prec_round_assign_ref(&y, prec, rm);\n        println!(\"x := {x_old}; x.add_prec_round_ref(&{y}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_add_prec_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.add_prec_round_ref(&{:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_float_add_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} + {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x + y)\n        );\n    }\n}\n\nfn demo_float_add_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_float_add_rational_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} + {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x + y)\n        );\n    }\n}\n\nfn demo_float_add_rational_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} + &{} = {}\", x_old, y, x + &y);\n    }\n}\n\nfn demo_float_add_rational_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} + {} = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x + &y)\n        );\n    }\n}\n\nfn demo_float_add_rational_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} + {} = {}\", x, y_old, &x + y);\n    }\n}\n\nfn demo_float_add_rational_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} + {} = {:#x}\",\n            ComparableFloatRef(&x),\n            y_old,\n            ComparableFloat(&x + y)\n        );\n    }\n}\n\nfn demo_float_add_rational_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} + &{} = {}\", x, y, &x + &y);\n    }\n}\n\nfn demo_float_add_rational_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} + &{} = {:#x}\",\n            ComparableFloatRef(&x),\n            y,\n            ComparableFloat(&x + &y)\n        );\n    }\n}\n\nfn demo_float_add_rational_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\"x := {x_old}; x += {y}; x = {x}\");\n    }\n}\n\nfn demo_float_add_rational_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\n            \"x := {:#x}; x += {}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_rational_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\"x := {x_old}; x += &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_add_rational_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\n            \"x := {:#x}; x += &{}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_rational_add_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_rational_add_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} + {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x + y)\n        );\n    }\n}\n\nfn demo_rational_add_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_rational_add_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} + {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x + y)\n        );\n    }\n}\n\nfn demo_rational_add_float_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} + &{} = {}\", x_old, y, x + &y);\n    }\n}\n\nfn demo_rational_add_float_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{} + &{:#x} = {:#x}\",\n            x_old,\n            ComparableFloatRef(&y),\n            ComparableFloat(x + &y)\n        );\n    }\n}\n\nfn demo_rational_add_float_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} + {} = {}\", x, y_old, &x + y);\n    }\n}\n\nfn demo_rational_add_float_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{} + {:#x} = {:#x}\",\n            x,\n            ComparableFloat(y_old),\n            ComparableFloat(&x + y)\n        );\n    }\n}\n\nfn demo_rational_add_float_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} + &{} = {}\", x, y, &x + &y);\n    }\n}\n\nfn demo_rational_add_float_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{} + &{:#x} = {:#x}\",\n            x,\n            ComparableFloatRef(&y),\n            ComparableFloat(&x + &y)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.add_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_prec(y, prec);\n        println!(\n            \"({:#x}).add_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.add_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_prec(y, prec);\n        println!(\n            \"({:#x}).add_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).add_rational_prec({}, &{}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.add_rational_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.add_rational_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).add_rational_prec_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).add_rational_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.add_rational_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).add_rational_prec_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).add_rational_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.add_rational_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.add_rational_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).add_rational_prec_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_rational_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.add_rational_prec_assign({y_old}, {prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_add_rational_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_rational_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.add_rational_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_rational_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.add_rational_prec_assign_ref({y}, &{prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_add_rational_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_rational_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.add_rational_prec_assign(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_rational_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.add_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_round(y, rm);\n        println!(\n            \"({:#x}).add_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.add_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_round(y, rm);\n        println!(\n            \"({:#x}).add_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).add_rational_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.add_rational_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.add_rational_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).add_rational_round_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).add_rational_round_ref_val(&{}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.add_rational_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).add_rational_round_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).add_rational_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.add_rational_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.add_rational_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).add_rational_round_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_rational_round_assign(y, rm);\n        println!(\"x := {x_old}; x.add_rational_round_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_add_rational_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_rational_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.add_rational_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_rational_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_rational_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.add_rational_round_assign_ref(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_add_rational_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_rational_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.add_rational_round_assign_ref(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.add_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).add_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).add_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.add_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).add_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).add_rational_prec_round_val_ref(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.add_rational_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.add_rational_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).add_rational_prec_round_val_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).add_rational_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.add_rational_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.add_rational_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).add_rational_prec_round_ref_val({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).add_rational_prec_round_ref_ref(&{}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.add_rational_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.add_rational_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"(&{:#x}).add_rational_prec_round_ref_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {x_old}; x.add_rational_prec_round_assign({y_old}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.add_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.add_rational_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {x_old}; x.add_rational_prec_round_assign_ref(&{y}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_add_rational_prec_round_assign_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.add_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.add_rational_prec_round_assign_ref(&{}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_add_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float + Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float + Float\", &mut |(x, y)| no_out!(x + y)),\n            (\"Float + &Float\", &mut |(x, y)| no_out!(x + &y)),\n            (\"&Float + Float\", &mut |(x, y)| no_out!(&x + y)),\n            (\"&Float + &Float\", &mut |(x, y)| no_out!(&x + &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_add_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float + Float\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x + &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_add(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_add_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float + Float\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x + y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(add_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float += Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float += Float\", &mut |(mut x, y)| x += y),\n            (\"Float += &Float\", &mut |(mut x, y)| x += &y),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.add_prec(Float, u64)\", &mut |(x, y, prec)| {\n                no_out!(x.add_prec(y, prec));\n            }),\n            (\"Float.add_prec_val_ref(&Float, u64)\", &mut |(\n                x,\n                y,\n                prec,\n            )| {\n                no_out!(x.add_prec_val_ref(&y, prec));\n            }),\n            (\n                \"(&Float).add_prec_ref_val(Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.add_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).add_prec_ref_ref(&Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.add_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec(Float, u64)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| no_out!(x.add_prec(y, prec))),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(add_prec_round_naive(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec(Float, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.add_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_add_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec_assign(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.add_prec_assign(Float, u64)\", &mut |(\n                mut x,\n                y,\n                prec,\n            )| {\n                no_out!(x.add_prec_assign(y, prec));\n            }),\n            (\n                \"Float.add_prec_assign_ref(&Float, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.add_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_round(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float.add_round(Float, RoundingMode)\", &mut |(x, y, rm)| {\n                no_out!(x.add_round(y, rm));\n            }),\n            (\n                \"Float.add_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.add_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).add_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.add_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).add_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.add_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_round(Float, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_rounding_mode_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.add_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_add_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_round(Float, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| no_out!(x.add_round(y, rm))),\n            (\"naive\", &mut |(x, y, rm)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                add_prec_round_naive(x, y, max(xsb, ysb), rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_round_assign(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.add_round_assign(Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.add_round_assign(y, rm)),\n            ),\n            (\n                \"Float.add_round_assign_ref(&Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.add_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.add_prec_round(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.add_prec_round_val_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).add_prec_round_ref_val(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).add_prec_round_ref_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.add_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_add_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.add_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(add_prec_round_naive(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_prec_round_assign(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.add_prec_round_assign(Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.add_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.add_prec_round_assign_ref(&Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.add_prec_round_assign_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_add_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float + Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float + Rational\", &mut |(x, y)| no_out!(x + y)),\n            (\"Float + &Rational\", &mut |(x, y)| no_out!(x + &y)),\n            (\"&Float + Rational\", &mut |(x, y)| no_out!(&x + y)),\n            (\"&Float + &Rational\", &mut |(x, y)| no_out!(&x + &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_add_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float + Rational\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x + &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_add_rational(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_add_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float + Rational\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x + y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(add_rational_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float += Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float += Rational\", &mut |(mut x, y)| x += y),\n            (\"Float += &Rational\", &mut |(mut x, y)| x += &y),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_add_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational + Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Rational + Float\", &mut |(y, x)| no_out!(x + y)),\n            (\"Rational + &Float\", &mut |(y, x)| no_out!(x + &y)),\n            (\"&Rational + Float\", &mut |(y, x)| no_out!(&x + y)),\n            (\"&Rational + &Float\", &mut |(y, x)| no_out!(&x + &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_add_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational + Float\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(&x + &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_add_rational(&x, &y))),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.add_rational_prec(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.add_rational_prec(y, prec)),\n            ),\n            (\n                \"Float.add_rational_prec_val_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.add_rational_prec_val_ref(&y, prec)),\n            ),\n            (\n                \"(&Float).add_rational_prec_ref_val(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.add_rational_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).add_rational_prec_ref_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.add_rational_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec(Rational, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.add_rational_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_add_rational_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec(Rational, u64)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| {\n                no_out!(x.add_rational_prec(y, prec));\n            }),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(add_rational_prec_round_naive(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec_assign(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.add_rational_prec_assign(Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.add_rational_prec_assign(y, prec)),\n            ),\n            (\n                \"Float.add_rational_prec_assign_ref(&Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.add_rational_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.add_rational_round(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.add_rational_round(y, rm)),\n            ),\n            (\n                \"Float.add_rational_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.add_rational_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).add_rational_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.add_rational_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).add_rational_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.add_rational_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_rounding_mode_triple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.add_rational_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_add_rational_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.add_rational_round(y, rm));\n            }),\n            (\"naive\", &mut |(x, y, rm)| {\n                let ysb = y.significant_bits();\n                add_rational_prec_round_naive(x, y, ysb, rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_round_assign(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.add_rational_round_assign(Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.add_rational_round_assign(y, rm)),\n            ),\n            (\n                \"Float.add_rational_round_assign_ref(&Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.add_rational_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.add_rational_prec_round(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_rational_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.add_rational_prec_round_val_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_rational_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).add_rational_prec_round_ref_val(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_rational_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).add_rational_prec_round_ref_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.add_rational_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\n            \"x\", \"y\", \"prec\",\n        ),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.add_rational_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_add_rational_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.add_rational_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(add_rational_prec_round_naive(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_add_rational_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.add_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.add_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.add_rational_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.add_rational_prec_round_assign_ref(&Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| {\n                    no_out!(x.add_rational_prec_round_assign_ref(&y, prec, rm));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/agm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Agm, AgmAssign};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::pair_max_primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::arithmetic::agm::{primitive_float_agm, primitive_float_agm_rational};\nuse malachite_float::basic::extended::ExtendedFloat;\nuse malachite_float::basic::extended::agm_prec_round_normal_ref_ref_extended;\nuse malachite_float::test_util::arithmetic::agm::{\n    rug_agm, rug_agm_prec, rug_agm_prec_round, rug_agm_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_max_complexity_bucketer,\n    pair_2_triple_float_float_primitive_int_max_complexity_bucketer,\n    pair_float_max_complexity_bucketer,\n    quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_max_complexity_bucketer,\n    triple_float_float_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_33, float_float_rounding_mode_triple_gen_var_33_rm,\n    float_float_rounding_mode_triple_gen_var_34,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_9,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_9_rm,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_10, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_1_rm, float_float_unsigned_triple_gen_var_2,\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10,\n    rational_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::test_util::bench::bucketers::{\n    pair_rational_max_bit_bucketer,\n    quadruple_1_2_3_rational_rational_primitive_int_max_bit_bucketer,\n    triple_rational_rational_primitive_int_max_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_pair_gen, rational_rational_unsigned_triple_gen_var_2,\n};\nuse std::cmp::max;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_agm);\n    register_demo!(runner, demo_float_agm_debug);\n    register_demo!(runner, demo_float_agm_extreme);\n    register_demo!(runner, demo_float_agm_extreme_debug);\n    register_demo!(runner, demo_float_agm_val_ref);\n    register_demo!(runner, demo_float_agm_val_ref_debug);\n    register_demo!(runner, demo_float_agm_ref_val);\n    register_demo!(runner, demo_float_agm_ref_val_debug);\n    register_demo!(runner, demo_float_agm_ref_ref);\n    register_demo!(runner, demo_float_agm_ref_ref_debug);\n    register_demo!(runner, demo_float_agm_assign);\n    register_demo!(runner, demo_float_agm_assign_debug);\n    register_demo!(runner, demo_float_agm_assign_ref);\n    register_demo!(runner, demo_float_agm_assign_ref_debug);\n    register_demo!(runner, demo_float_agm_prec);\n    register_demo!(runner, demo_float_agm_prec_debug);\n    register_demo!(runner, demo_float_agm_prec_extreme);\n    register_demo!(runner, demo_float_agm_prec_extreme_debug);\n    register_demo!(runner, demo_float_agm_prec_val_ref);\n    register_demo!(runner, demo_float_agm_prec_val_ref_debug);\n    register_demo!(runner, demo_float_agm_prec_ref_val);\n    register_demo!(runner, demo_float_agm_prec_ref_val_debug);\n    register_demo!(runner, demo_float_agm_prec_ref_ref);\n    register_demo!(runner, demo_float_agm_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_agm_prec_assign);\n    register_demo!(runner, demo_float_agm_prec_assign_debug);\n    register_demo!(runner, demo_float_agm_prec_assign_ref);\n    register_demo!(runner, demo_float_agm_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_agm_round);\n    register_demo!(runner, demo_float_agm_round_debug);\n    register_demo!(runner, demo_float_agm_round_extreme);\n    register_demo!(runner, demo_float_agm_round_extreme_debug);\n    register_demo!(runner, demo_float_agm_round_val_ref);\n    register_demo!(runner, demo_float_agm_round_val_ref_debug);\n    register_demo!(runner, demo_float_agm_round_ref_val);\n    register_demo!(runner, demo_float_agm_round_ref_val_debug);\n    register_demo!(runner, demo_float_agm_round_ref_ref);\n    register_demo!(runner, demo_float_agm_round_ref_ref_debug);\n    register_demo!(runner, demo_float_agm_round_assign);\n    register_demo!(runner, demo_float_agm_round_assign_debug);\n    register_demo!(runner, demo_float_agm_round_assign_ref);\n    register_demo!(runner, demo_float_agm_round_assign_ref_debug);\n    register_demo!(runner, demo_float_agm_prec_round);\n    register_demo!(runner, demo_float_agm_prec_round_debug);\n    register_demo!(runner, demo_float_agm_prec_round_extreme);\n    register_demo!(runner, demo_float_agm_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_agm_prec_round_val_ref);\n    register_demo!(runner, demo_float_agm_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_agm_prec_round_ref_val);\n    register_demo!(runner, demo_float_agm_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_agm_prec_round_ref_ref);\n    register_demo!(runner, demo_float_agm_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_agm_prec_round_assign);\n    register_demo!(runner, demo_float_agm_prec_round_assign_debug);\n    register_demo!(runner, demo_float_agm_prec_round_assign_ref);\n    register_demo!(runner, demo_float_agm_prec_round_assign_ref_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_agm);\n    register_demo!(runner, demo_agm_rational_prec);\n    register_demo!(runner, demo_agm_rational_prec_debug);\n    register_demo!(runner, demo_agm_rational_prec_val_ref);\n    register_demo!(runner, demo_agm_rational_prec_val_ref_debug);\n    register_demo!(runner, demo_agm_rational_prec_ref_val);\n    register_demo!(runner, demo_agm_rational_prec_ref_val_debug);\n    register_demo!(runner, demo_agm_rational_prec_ref_ref);\n    register_demo!(runner, demo_agm_rational_prec_ref_ref_debug);\n    register_demo!(runner, demo_agm_rational_prec_round);\n    register_demo!(runner, demo_agm_rational_prec_round_debug);\n    register_demo!(runner, demo_agm_rational_prec_round_val_ref);\n    register_demo!(runner, demo_agm_rational_prec_round_val_ref_debug);\n    register_demo!(runner, demo_agm_rational_prec_round_ref_val);\n    register_demo!(runner, demo_agm_rational_prec_round_ref_val_debug);\n    register_demo!(runner, demo_agm_rational_prec_round_ref_ref);\n    register_demo!(runner, demo_agm_rational_prec_round_ref_ref_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_agm_rational);\n\n    register_bench!(runner, benchmark_float_agm_evaluation_strategy);\n    register_bench!(runner, benchmark_float_agm_algorithms);\n    register_bench!(runner, benchmark_float_agm_library_comparison);\n    register_bench!(runner, benchmark_float_agm_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_agm_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_agm_prec_algorithms);\n    register_bench!(runner, benchmark_float_agm_prec_library_comparison);\n    register_bench!(runner, benchmark_float_agm_prec_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_agm_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_agm_round_algorithms);\n    register_bench!(runner, benchmark_float_agm_round_library_comparison);\n    register_bench!(runner, benchmark_float_agm_round_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_agm_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_agm_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_agm_prec_round_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_float_agm_prec_round_assign_evaluation_strategy\n    );\n    register_primitive_float_benches!(runner, benchmark_primitive_float_agm);\n    register_bench!(runner, benchmark_agm_rational_prec_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_agm_rational_prec_round_evaluation_strategy\n    );\n    register_primitive_float_benches!(runner, benchmark_primitive_float_agm_rational);\n}\n\nfn demo_float_agm(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"agm({}, {}) = {}\", x_old, y_old, x.agm(y));\n    }\n}\n\nfn demo_float_agm_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"agm({:#x}, {:#x}) = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x.agm(y))\n        );\n    }\n}\n\nfn demo_float_agm_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"agm({}, {}) = {}\", x_old, y_old, x.agm(y));\n    }\n}\n\nfn demo_float_agm_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"agm({:#x}, {:#x}) = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x.agm(y))\n        );\n    }\n}\n\nfn demo_float_agm_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"agm({}, &{}) = {}\", x_old, y, x.agm(&y));\n    }\n}\n\nfn demo_float_agm_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"agm({:#x}, &{:#x}) = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloatRef(&y),\n            ComparableFloat(x.agm(&y))\n        );\n    }\n}\n\nfn demo_float_agm_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"agm(&{}, {}) = {}\", x, y_old, (&x).agm(y));\n    }\n}\n\nfn demo_float_agm_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"agm(&{:#x}, {:#x}) = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat(y_old),\n            ComparableFloat((&x).agm(y))\n        );\n    }\n}\n\nfn demo_float_agm_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\"agm(&{}, &{}) = {}\", x, y, (&x).agm(&y));\n    }\n}\n\nfn demo_float_agm_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"agm(&{:#x}, &{:#x}) = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloatRef(&y),\n            ComparableFloat((&x).agm(&y))\n        );\n    }\n}\n\nfn demo_float_agm_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.agm_assign(y.clone());\n        println!(\"x := {x_old}; x.agm_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_float_agm_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.agm_assign(y.clone());\n        println!(\n            \"x := {:#x}; x.agm_assign({:#x}); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_agm_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.agm_assign(&y);\n        println!(\"x := {x_old}; x.agm_assign(&{y}); x = {x}\");\n    }\n}\n\nfn demo_float_agm_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.agm_assign(&y);\n        println!(\n            \"x := {:#x}; x.agm_assign(&{:#x}); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_agm_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).agm_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.agm_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_agm_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = x.agm_prec(y, prec);\n        println!(\n            \"({:#x}).agm_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).agm_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.agm_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_agm_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = x.agm_prec(y, prec);\n        println!(\n            \"({:#x}).agm_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).agm_prec_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.agm_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_agm_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (agm, o) = x.agm_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).agm_prec_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).agm_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.agm_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_agm_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (agm, o) = x.agm_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).agm_prec_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).agm_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.agm_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_agm_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (agm, o) = x.agm_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).agm_prec_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.agm_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.agm_prec_assign({y_old}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_agm_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.agm_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.agm_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_agm_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.agm_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.agm_prec_assign({y}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_agm_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.agm_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.agm_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_agm_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).agm_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.agm_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_agm_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = x.agm_round(y, rm);\n        println!(\n            \"({:#x}).agm_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).agm_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.agm_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_agm_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = x.agm_round(y, rm);\n        println!(\n            \"({:#x}).agm_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).agm_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.agm_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_agm_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (agm, o) = x.agm_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).agm_round_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).agm_round_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.agm_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_agm_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (agm, o) = x.agm_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).agm_round_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).agm_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.agm_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_agm_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (agm, o) = x.agm_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).agm_round_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.agm_round_assign(y, rm);\n        println!(\"x := {x_old}; x.agm_round_assign({y_old}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_agm_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.agm_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.agm_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_agm_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.agm_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.agm_round_assign({y}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_agm_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_33()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.agm_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.agm_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_agm_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).agm_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.agm_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = x.agm_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).agm_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).agm_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.agm_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = x.agm_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).agm_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).agm_prec_round(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.agm_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (agm, o) = x.agm_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).agm_prec_round_val_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).agm_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.agm_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (agm, o) = x.agm_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).agm_prec_round_ref_val({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).agm_prec_round({}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.agm_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (agm, o) = x.agm_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).agm_prec_round_ref_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.agm_prec_round_assign(y, prec, rm);\n        println!(\"x := {x_old}; x.agm_prec_round({y_old}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_agm_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.agm_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.agm_prec_round({:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_agm_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.agm_prec_round_assign_ref(&y, prec, rm);\n        println!(\"x := {x_old}; x.agm_prec_round_ref(&{y}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_agm_prec_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.agm_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.agm_prec_round_ref(&{:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_agm<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, y) in primitive_float_pair_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"primitive_float_agm({}, {}) = {}\",\n            NiceFloat(x),\n            NiceFloat(y),\n            NiceFloat(primitive_float_agm(x, y))\n        );\n    }\n}\n\nfn demo_agm_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"agm_rational_prec({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            Float::agm_rational_prec(x, y, prec)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = Float::agm_rational_prec(x, y, prec);\n        println!(\n            \"agm_rational_prec({}, {}, {}) = ({:#x}, {:?})\",\n            x_old,\n            y_old,\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_agm_rational_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"agm_rational_prec_val_ref({}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            Float::agm_rational_prec_val_ref(x, &y, prec)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (agm, o) = Float::agm_rational_prec_val_ref(x, &y, prec);\n        println!(\n            \"agm_rational_prec_val_ref({}, {}, {}) = ({:#x}, {:?})\",\n            x_old,\n            y,\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_agm_rational_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"agm_rational_prec_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            Float::agm_rational_prec_ref_val(&x, y, prec)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (agm, o) = Float::agm_rational_prec_ref_val(&x, y, prec);\n        println!(\n            \"agm_rational_prec_ref_val({}, {}, {}) = ({:#x}, {:?})\",\n            x,\n            y_old,\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_agm_rational_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"agm_rational_prec_ref_ref({}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            Float::agm_rational_prec_ref_ref(&x, &y, prec)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in rational_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = Float::agm_rational_prec(x, y, prec);\n        println!(\n            \"agm_rational_prec({}, {}, {}) = ({:#x}, {:?})\",\n            x_old,\n            y_old,\n            prec,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"agm_rational_prec_round({}, {}, {}, {:?}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            Float::agm_rational_prec_round(x, y, prec, rm)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (agm, o) = Float::agm_rational_prec_round(x, y, prec, rm);\n        println!(\n            \"agm_rational_prec_round({}, {}, {}, {:?}) = ({:#x}, {:?})\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"agm_rational_prec_round_val_ref({}, {}, {}, {:?}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            Float::agm_rational_prec_round_val_ref(x, &y, prec, rm)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (agm, o) = Float::agm_rational_prec_round_val_ref(x, &y, prec, rm);\n        println!(\n            \"agm_rational_prec_round_val_ref({}, {}, {}, {:?}) = ({:#x}, {:?})\",\n            x_old,\n            y,\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"agm_rational_prec_round_ref_val({}, {}, {}, {:?}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            Float::agm_rational_prec_round_ref_val(&x, y, prec, rm)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (agm, o) = Float::agm_rational_prec_round_ref_val(&x, y, prec, rm);\n        println!(\n            \"agm_rational_prec_round_ref_val({}, {}, {}, {:?}) = ({:#x}, {:?})\",\n            x,\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"agm_rational_prec_round_ref_ref({}, {}, {}, {:?}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            Float::agm_rational_prec_round_ref_ref(&x, &y, prec, rm)\n        );\n    }\n}\n\nfn demo_agm_rational_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (agm, o) = Float::agm_rational_prec_round_ref_ref(&x, &y, prec, rm);\n        println!(\n            \"agm_rational_prec_round_ref_ref({}, {}, {}, {:?}) = ({:#x}, {:?})\",\n            x,\n            y,\n            prec,\n            rm,\n            ComparableFloat(agm),\n            o\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_agm_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"primitive_float_agm_rational({}, {}) = {}\",\n            x,\n            y,\n            NiceFloat(primitive_float_agm_rational::<T>(&x, &y))\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_agm_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm(Float)\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float.agm(Float)\", &mut |(x, y)| no_out!(x.agm(y))),\n            (\"Float.agm(&Float)\", &mut |(x, y)| no_out!(x.agm(&y))),\n            (\"(&Float).agm(Float)\", &mut |(x, y)| no_out!((&x).agm(y))),\n            (\"(&Float).agm(&Float)\", &mut |(x, y)| no_out!((&x).agm(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_agm_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.agm(Float)\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.agm(y))),\n            (\"extended\", &mut |(x, y)| {\n                let prec = max(x.significant_bits(), y.significant_bits());\n                agm_prec_round_normal_ref_ref_extended(\n                    &ExtendedFloat::from(x.clone()),\n                    &ExtendedFloat::from(y.clone()),\n                    prec,\n                    Nearest,\n                );\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_agm_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm(Float)\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!((&x).agm(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_agm(&x, &y))),\n        ],\n    );\n}\n\nfn benchmark_float_agm_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_assign(Float)\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float.agm_assign(Float)\", &mut |(mut x, y)| x.agm_assign(y)),\n            (\"Float.agm_assign(&Float)\", &mut |(mut x, y)| {\n                x.agm_assign(&y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.agm_prec(Float, u64)\", &mut |(x, y, prec)| {\n                no_out!(x.agm_prec(y, prec));\n            }),\n            (\"Float.agm_prec_val_ref(&Float, u64)\", &mut |(\n                x,\n                y,\n                prec,\n            )| {\n                no_out!(x.agm_prec_val_ref(&y, prec));\n            }),\n            (\n                \"(&Float).agm_prec_ref_val(Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.agm_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).agm_prec_ref_ref(&Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.agm_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec(Float, u64)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| {\n                no_out!(x.agm_prec(y, prec));\n            }),\n            (\"extended\", &mut |(x, y, prec)| {\n                agm_prec_round_normal_ref_ref_extended(\n                    &ExtendedFloat::from(x.clone()),\n                    &ExtendedFloat::from(y.clone()),\n                    prec,\n                    Nearest,\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec(Float, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.agm_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_agm_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec_assign(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.agm_prec_assign(Float, u64)\", &mut |(\n                mut x,\n                y,\n                prec,\n            )| {\n                no_out!(x.agm_prec_assign(y, prec));\n            }),\n            (\n                \"Float.agm_prec_assign_ref(&Float, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.agm_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_agm_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_round(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_33().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float.agm_round(Float, RoundingMode)\", &mut |(x, y, rm)| {\n                no_out!(x.agm_round(y, rm));\n            }),\n            (\n                \"Float.agm_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.agm_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).agm_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.agm_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).agm_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.agm_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_agm_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_round(Float, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_rounding_mode_triple_gen_var_33().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.agm_round(y, rm));\n            }),\n            (\"extended\", &mut |(x, y, rm)| {\n                let prec = max(x.significant_bits(), y.significant_bits());\n                agm_prec_round_normal_ref_ref_extended(\n                    &ExtendedFloat::from(x.clone()),\n                    &ExtendedFloat::from(y.clone()),\n                    prec,\n                    rm,\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_agm_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_round(Float, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_rounding_mode_triple_gen_var_33_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.agm_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_agm_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_agm_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_round_assign(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_33().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.agm_round_assign(Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.agm_round_assign(y, rm)),\n            ),\n            (\n                \"Float.agm_round_assign_ref(&Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.agm_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.agm_prec_round(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.agm_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.agm_prec_round_val_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.agm_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).agm_prec_round_ref_val(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.agm_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).agm_prec_round_ref_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.agm_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.agm_prec_round(y, prec, rm));\n            }),\n            (\"extended\", &mut |(x, y, prec, rm)| {\n                agm_prec_round_normal_ref_ref_extended(\n                    &ExtendedFloat::from(x.clone()),\n                    &ExtendedFloat::from(y.clone()),\n                    prec,\n                    rm,\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_9_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.agm_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_agm_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_agm_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.agm_prec_round_assign(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.agm_prec_round_assign(Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.agm_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.agm_prec_round_assign_ref(&Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.agm_prec_round_assign_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_agm<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"primitive_float_agm({})\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_primitive_float_bucketer(\"x\", \"y\"),\n        &mut [(\"malachite\", &mut |(x, y)| {\n            no_out!(primitive_float_agm(x, y));\n        })],\n    );\n}\n\nfn benchmark_agm_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::agm_rational_prec(Rational, Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_rational_unsigned_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_rational_rational_primitive_int_max_bit_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float::agm_rational_prec(Rational, Rational, u64)\",\n                &mut |(x, y, prec)| {\n                    no_out!(Float::agm_rational_prec(x, y, prec));\n                },\n            ),\n            (\n                \"Float::agm_rational_prec_val_ref(Rational, &Rational, u64)\",\n                &mut |(x, y, prec)| {\n                    no_out!(Float::agm_rational_prec_val_ref(x, &y, prec));\n                },\n            ),\n            (\n                \"Float::agm_rational_prec_ref_val(&Rational, Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(Float::agm_rational_prec_ref_val(&x, y, prec)),\n            ),\n            (\n                \"Float::agm_rational_prec_ref_ref(&Rational, &Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(Float::agm_rational_prec_ref_ref(&x, &y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_agm_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::agm_rational_prec_round(Rational, Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_rational_unsigned_rounding_mode_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_rational_rational_primitive_int_max_bit_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float::agm_rational_prec_round(Rational, Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| {\n                    no_out!(Float::agm_rational_prec_round(x, y, prec, rm));\n                },\n            ),\n            (\n                \"Float::agm_rational_prec_round_val_ref(Rational, &Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| {\n                    no_out!(Float::agm_rational_prec_round_val_ref(x, &y, prec, rm));\n                },\n            ),\n            (\n                \"Float::agm_rational_prec_round_ref_val(&Rational, Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| {\n                    no_out!(Float::agm_rational_prec_round_ref_val(&x, y, prec, rm));\n                },\n            ),\n            (\n                \"Float::agm_rational_prec_round_ref_ref(&Rational, &Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| {\n                    no_out!(Float::agm_rational_prec_round_ref_ref(&x, &y, prec, rm));\n                },\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_agm_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\n            \"primitive_float_agm_rational_prec::<{}>(Rational, Rational)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(primitive_float_agm_rational::<T>(&x, &y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::max;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::arithmetic::div::{\n    div_rational_prec_round_direct, div_rational_prec_round_direct_ref_ref,\n    div_rational_prec_round_direct_ref_val, div_rational_prec_round_direct_val_ref,\n    div_rational_prec_round_naive, div_rational_prec_round_naive_ref_ref,\n    div_rational_prec_round_naive_ref_val, div_rational_prec_round_naive_val_ref,\n    rational_div_float_prec_round_direct, rational_div_float_prec_round_direct_ref_ref,\n    rational_div_float_prec_round_direct_ref_val, rational_div_float_prec_round_direct_val_ref,\n    rational_div_float_prec_round_naive, rational_div_float_prec_round_naive_ref_ref,\n    rational_div_float_prec_round_naive_ref_val, rational_div_float_prec_round_naive_val_ref,\n};\nuse malachite_float::test_util::arithmetic::div::{\n    div_prec_round_naive, rug_div, rug_div_prec, rug_div_prec_round, rug_div_rational,\n    rug_div_rational_prec, rug_div_rational_prec_round, rug_div_rational_round, rug_div_round,\n    rug_rational_div_float_prec, rug_rational_div_float_prec_round, rug_rational_div_float_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer, pair_2_pair_float_rational_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_max_complexity_bucketer,\n    pair_2_triple_1_2_float_rational_max_complexity_bucketer,\n    pair_2_triple_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_float_rational_primitive_int_max_complexity_bucketer,\n    pair_float_max_complexity_bucketer, pair_float_rational_max_complexity_bucketer,\n    quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_max_complexity_bucketer, triple_1_2_float_rational_max_complexity_bucketer,\n    triple_float_float_primitive_int_max_complexity_bucketer,\n    triple_float_rational_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_23, float_float_rounding_mode_triple_gen_var_23_rm,\n    float_float_rounding_mode_triple_gen_var_32,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_4_rm,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_8, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_1_rm, float_float_unsigned_triple_gen_var_2,\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10, float_rational_pair_gen,\n    float_rational_pair_gen_rm, float_rational_pair_gen_var_2,\n    float_rational_rounding_mode_triple_gen_var_3_rm,\n    float_rational_rounding_mode_triple_gen_var_5, float_rational_rounding_mode_triple_gen_var_6,\n    float_rational_rounding_mode_triple_gen_var_6_rm,\n    float_rational_rounding_mode_triple_gen_var_10, float_rational_rounding_mode_triple_gen_var_11,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_4_rm,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_5,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_5_rm,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_9,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_10,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_1_rm,\n    float_rational_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_div);\n    register_demo!(runner, demo_float_div_debug);\n    register_demo!(runner, demo_float_div_extreme);\n    register_demo!(runner, demo_float_div_extreme_debug);\n    register_demo!(runner, demo_float_div_val_ref);\n    register_demo!(runner, demo_float_div_val_ref_debug);\n    register_demo!(runner, demo_float_div_ref_val);\n    register_demo!(runner, demo_float_div_ref_val_debug);\n    register_demo!(runner, demo_float_div_ref_ref);\n    register_demo!(runner, demo_float_div_ref_ref_debug);\n    register_demo!(runner, demo_float_div_assign);\n    register_demo!(runner, demo_float_div_assign_debug);\n    register_demo!(runner, demo_float_div_assign_ref);\n    register_demo!(runner, demo_float_div_assign_ref_debug);\n    register_demo!(runner, demo_float_div_prec);\n    register_demo!(runner, demo_float_div_prec_debug);\n    register_demo!(runner, demo_float_div_prec_extreme);\n    register_demo!(runner, demo_float_div_prec_extreme_debug);\n    register_demo!(runner, demo_float_div_prec_val_ref);\n    register_demo!(runner, demo_float_div_prec_val_ref_debug);\n    register_demo!(runner, demo_float_div_prec_ref_val);\n    register_demo!(runner, demo_float_div_prec_ref_val_debug);\n    register_demo!(runner, demo_float_div_prec_ref_ref);\n    register_demo!(runner, demo_float_div_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_div_prec_assign);\n    register_demo!(runner, demo_float_div_prec_assign_debug);\n    register_demo!(runner, demo_float_div_prec_assign_ref);\n    register_demo!(runner, demo_float_div_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_div_round);\n    register_demo!(runner, demo_float_div_round_debug);\n    register_demo!(runner, demo_float_div_round_extreme);\n    register_demo!(runner, demo_float_div_round_extreme_debug);\n    register_demo!(runner, demo_float_div_round_val_ref);\n    register_demo!(runner, demo_float_div_round_val_ref_debug);\n    register_demo!(runner, demo_float_div_round_ref_val);\n    register_demo!(runner, demo_float_div_round_ref_val_debug);\n    register_demo!(runner, demo_float_div_round_ref_ref);\n    register_demo!(runner, demo_float_div_round_ref_ref_debug);\n    register_demo!(runner, demo_float_div_round_assign);\n    register_demo!(runner, demo_float_div_round_assign_debug);\n    register_demo!(runner, demo_float_div_round_assign_ref);\n    register_demo!(runner, demo_float_div_round_assign_ref_debug);\n    register_demo!(runner, demo_float_div_prec_round);\n    register_demo!(runner, demo_float_div_prec_round_debug);\n    register_demo!(runner, demo_float_div_prec_round_extreme);\n    register_demo!(runner, demo_float_div_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_div_prec_round_val_ref);\n    register_demo!(runner, demo_float_div_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_div_prec_round_ref_val);\n    register_demo!(runner, demo_float_div_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_div_prec_round_ref_ref);\n    register_demo!(runner, demo_float_div_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_div_prec_round_assign);\n    register_demo!(runner, demo_float_div_prec_round_assign_debug);\n    register_demo!(runner, demo_float_div_prec_round_assign_ref);\n    register_demo!(runner, demo_float_div_prec_round_assign_ref_debug);\n    register_demo!(runner, demo_float_div_rational);\n    register_demo!(runner, demo_float_div_rational_debug);\n    register_demo!(runner, demo_float_div_rational_extreme);\n    register_demo!(runner, demo_float_div_rational_extreme_debug);\n    register_demo!(runner, demo_float_div_rational_val_ref);\n    register_demo!(runner, demo_float_div_rational_val_ref_debug);\n    register_demo!(runner, demo_float_div_rational_ref_val);\n    register_demo!(runner, demo_float_div_rational_ref_val_debug);\n    register_demo!(runner, demo_float_div_rational_ref_ref);\n    register_demo!(runner, demo_float_div_rational_ref_ref_debug);\n    register_demo!(runner, demo_float_div_rational_assign);\n    register_demo!(runner, demo_float_div_rational_assign_debug);\n    register_demo!(runner, demo_float_div_rational_assign_ref);\n    register_demo!(runner, demo_float_div_rational_assign_ref_debug);\n    register_demo!(runner, demo_rational_div_float);\n    register_demo!(runner, demo_rational_div_float_debug);\n    register_demo!(runner, demo_rational_div_float_extreme);\n    register_demo!(runner, demo_rational_div_float_extreme_debug);\n    register_demo!(runner, demo_rational_div_float_val_ref);\n    register_demo!(runner, demo_rational_div_float_val_ref_debug);\n    register_demo!(runner, demo_rational_div_float_ref_val);\n    register_demo!(runner, demo_rational_div_float_ref_val_debug);\n    register_demo!(runner, demo_rational_div_float_ref_ref);\n    register_demo!(runner, demo_rational_div_float_ref_ref_debug);\n    register_demo!(runner, demo_float_div_rational_prec);\n    register_demo!(runner, demo_float_div_rational_prec_debug);\n    register_demo!(runner, demo_float_div_rational_prec_extreme);\n    register_demo!(runner, demo_float_div_rational_prec_extreme_debug);\n    register_demo!(runner, demo_float_div_rational_prec_val_ref);\n    register_demo!(runner, demo_float_div_rational_prec_val_ref_debug);\n    register_demo!(runner, demo_float_div_rational_prec_ref_val);\n    register_demo!(runner, demo_float_div_rational_prec_ref_val_debug);\n    register_demo!(runner, demo_float_div_rational_prec_ref_ref);\n    register_demo!(runner, demo_float_div_rational_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_div_rational_prec_assign);\n    register_demo!(runner, demo_float_div_rational_prec_assign_debug);\n    register_demo!(runner, demo_float_div_rational_prec_assign_ref);\n    register_demo!(runner, demo_float_div_rational_prec_assign_ref_debug);\n    register_demo!(runner, demo_rational_div_float_prec);\n    register_demo!(runner, demo_rational_div_float_prec_debug);\n    register_demo!(runner, demo_rational_div_float_prec_extreme);\n    register_demo!(runner, demo_rational_div_float_prec_extreme_debug);\n    register_demo!(runner, demo_rational_div_float_prec_val_ref);\n    register_demo!(runner, demo_rational_div_float_prec_val_ref_debug);\n    register_demo!(runner, demo_rational_div_float_prec_ref_val);\n    register_demo!(runner, demo_rational_div_float_prec_ref_val_debug);\n    register_demo!(runner, demo_rational_div_float_prec_ref_ref);\n    register_demo!(runner, demo_rational_div_float_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_div_rational_round);\n    register_demo!(runner, demo_float_div_rational_round_debug);\n    register_demo!(runner, demo_float_div_rational_round_extreme);\n    register_demo!(runner, demo_float_div_rational_round_extreme_debug);\n    register_demo!(runner, demo_float_div_rational_round_val_ref);\n    register_demo!(runner, demo_float_div_rational_round_val_ref_debug);\n    register_demo!(runner, demo_float_div_rational_round_ref_val);\n    register_demo!(runner, demo_float_div_rational_round_ref_val_debug);\n    register_demo!(runner, demo_float_div_rational_round_ref_ref);\n    register_demo!(runner, demo_float_div_rational_round_ref_ref_debug);\n    register_demo!(runner, demo_float_div_rational_round_assign);\n    register_demo!(runner, demo_float_div_rational_round_assign_debug);\n    register_demo!(runner, demo_float_div_rational_round_assign_ref);\n    register_demo!(runner, demo_float_div_rational_round_assign_ref_debug);\n    register_demo!(runner, demo_rational_div_float_round);\n    register_demo!(runner, demo_rational_div_float_round_debug);\n    register_demo!(runner, demo_rational_div_float_round_extreme);\n    register_demo!(runner, demo_rational_div_float_round_extreme_debug);\n    register_demo!(runner, demo_rational_div_float_round_val_ref);\n    register_demo!(runner, demo_rational_div_float_round_val_ref_debug);\n    register_demo!(runner, demo_rational_div_float_round_ref_val);\n    register_demo!(runner, demo_rational_div_float_round_ref_val_debug);\n    register_demo!(runner, demo_rational_div_float_round_ref_ref);\n    register_demo!(runner, demo_rational_div_float_round_ref_ref_debug);\n    register_demo!(runner, demo_float_div_rational_prec_round);\n    register_demo!(runner, demo_float_div_rational_prec_round_debug);\n    register_demo!(runner, demo_float_div_rational_prec_round_extreme);\n    register_demo!(runner, demo_float_div_rational_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_div_rational_prec_round_val_ref);\n    register_demo!(runner, demo_float_div_rational_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_div_rational_prec_round_ref_val);\n    register_demo!(runner, demo_float_div_rational_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_div_rational_prec_round_ref_ref);\n    register_demo!(runner, demo_float_div_rational_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_div_rational_prec_round_assign);\n    register_demo!(runner, demo_float_div_rational_prec_round_assign_debug);\n    register_demo!(runner, demo_float_div_rational_prec_round_assign_ref);\n    register_demo!(runner, demo_float_div_rational_prec_round_assign_ref_debug);\n    register_demo!(runner, demo_rational_div_float_prec_round);\n    register_demo!(runner, demo_rational_div_float_prec_round_debug);\n    register_demo!(runner, demo_rational_div_float_prec_round_extreme);\n    register_demo!(runner, demo_rational_div_float_prec_round_extreme_debug);\n    register_demo!(runner, demo_rational_div_float_prec_round_val_ref);\n    register_demo!(runner, demo_rational_div_float_prec_round_val_ref_debug);\n    register_demo!(runner, demo_rational_div_float_prec_round_ref_val);\n    register_demo!(runner, demo_rational_div_float_prec_round_ref_val_debug);\n    register_demo!(runner, demo_rational_div_float_prec_round_ref_ref);\n    register_demo!(runner, demo_rational_div_float_prec_round_ref_ref_debug);\n\n    register_bench!(runner, benchmark_float_div_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_library_comparison);\n    register_bench!(runner, benchmark_float_div_algorithms);\n    register_bench!(runner, benchmark_float_div_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_prec_library_comparison);\n    register_bench!(runner, benchmark_float_div_prec_algorithms);\n    register_bench!(runner, benchmark_float_div_prec_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_round_library_comparison);\n    register_bench!(runner, benchmark_float_div_round_algorithms);\n    register_bench!(runner, benchmark_float_div_round_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_div_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_div_prec_round_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_div_rational_evaluation_strategy);\n    register_bench!(runner, benchmark_float_div_rational_library_comparison);\n    register_bench!(runner, benchmark_float_div_rational_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_div_rational_prec_library_comparison);\n    register_bench!(runner, benchmark_float_div_rational_prec_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_div_rational_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_round_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_div_rational_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_round_val_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_round_ref_val_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_round_ref_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_div_rational_prec_round_assign_evaluation_strategy\n    );\n\n    register_bench!(runner, benchmark_rational_div_float_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_div_float_library_comparison);\n    register_bench!(runner, benchmark_rational_div_float_algorithms);\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_prec_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_div_float_prec_library_comparison);\n    register_bench!(runner, benchmark_rational_div_float_prec_algorithms);\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_round_library_comparison\n    );\n    register_bench!(runner, benchmark_rational_div_float_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_rational_div_float_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_prec_round_val_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_prec_round_ref_val_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_div_float_prec_round_ref_ref_algorithms\n    );\n}\n\nfn demo_float_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_float_div_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} / {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x / y)\n        );\n    }\n}\n\nfn demo_float_div_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_float_div_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} / {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x / y)\n        );\n    }\n}\n\nfn demo_float_div_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} / &{} = {}\", x_old, y, x / &y);\n    }\n}\n\nfn demo_float_div_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} / &{:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloatRef(&y),\n            ComparableFloat(x / &y)\n        );\n    }\n}\n\nfn demo_float_div_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} / {} = {}\", x, y_old, &x / y);\n    }\n}\n\nfn demo_float_div_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} / {:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat(y_old),\n            ComparableFloat(&x / y)\n        );\n    }\n}\n\nfn demo_float_div_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} / &{} = {}\", x, y, &x / &y);\n    }\n}\n\nfn demo_float_div_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} / &{:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloatRef(&y),\n            ComparableFloat(&x / &y)\n        );\n    }\n}\n\nfn demo_float_div_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= y.clone();\n        println!(\"x := {x_old}; x /= {y}; x = {x}\");\n    }\n}\n\nfn demo_float_div_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= y.clone();\n        println!(\n            \"x := {:#x}; x /= {:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= &y;\n        println!(\"x := {x_old}; x /= &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_div_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= &y;\n        println!(\n            \"x := {:#x}; x /= &{:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.div_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_div_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_prec(y, prec);\n        println!(\n            \"({:#x}).div_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.div_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_div_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_prec(y, prec);\n        println!(\n            \"({:#x}).div_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).div_prec_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.div_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_div_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.div_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).div_prec_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.div_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_div_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.div_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).div_prec_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).div_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.div_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_div_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.div_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).div_prec_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.div_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.div_prec_assign({y_old}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_div_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.div_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.div_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.div_prec_assign({y}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_div_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.div_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.div_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_div_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_round(y, rm);\n        println!(\n            \"({:#x}).div_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_32()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.div_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_div_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_32()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_round(y, rm);\n        println!(\n            \"({:#x}).div_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).div_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.div_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_div_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.div_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).div_round_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_round_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.div_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_div_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.div_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).div_round_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).div_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.div_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_div_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.div_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).div_round_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.div_round_assign(y, rm);\n        println!(\"x := {x_old}; x.div_round_assign({y_old}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_div_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.div_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.div_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.div_round_assign({y}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_div_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.div_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.div_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).div_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.div_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).div_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).div_prec_round(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.div_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.div_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).div_prec_round_val_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.div_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.div_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).div_prec_round_ref_val({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).div_prec_round({}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.div_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.div_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).div_prec_round_ref_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_prec_round_assign(y, prec, rm);\n        println!(\"x := {x_old}; x.div_prec_round({y_old}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_div_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.div_prec_round({:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_prec_round_assign_ref(&y, prec, rm);\n        println!(\"x := {x_old}; x.div_prec_round_ref(&{y}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_div_prec_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.div_prec_round_ref(&{:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_float_div_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} / {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x / y)\n        );\n    }\n}\n\nfn demo_float_div_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_float_div_rational_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} / {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x / y)\n        );\n    }\n}\n\nfn demo_float_div_rational_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} / &{} = {}\", x_old, y, x / &y);\n    }\n}\n\nfn demo_float_div_rational_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} / {} = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x / &y)\n        );\n    }\n}\n\nfn demo_float_div_rational_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} / {} = {}\", x, y_old, &x / y);\n    }\n}\n\nfn demo_float_div_rational_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} / {} = {:#x}\",\n            ComparableFloatRef(&x),\n            y_old,\n            ComparableFloat(&x / y)\n        );\n    }\n}\n\nfn demo_float_div_rational_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} / &{} = {}\", x, y, &x / &y);\n    }\n}\n\nfn demo_float_div_rational_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} / &{} = {:#x}\",\n            ComparableFloatRef(&x),\n            y,\n            ComparableFloat(&x / &y)\n        );\n    }\n}\n\nfn demo_float_div_rational_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= y.clone();\n        println!(\"x := {x_old}; x /= {y}; x = {x}\");\n    }\n}\n\nfn demo_float_div_rational_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= y.clone();\n        println!(\n            \"x := {:#x}; x /= {}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_rational_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= &y;\n        println!(\"x := {x_old}; x /= &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_div_rational_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= &y;\n        println!(\n            \"x := {:#x}; x /= &{}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_rational_div_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_rational_div_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} / {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x / y)\n        );\n    }\n}\n\nfn demo_rational_div_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_rational_div_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} / {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x / y)\n        );\n    }\n}\n\nfn demo_rational_div_float_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} / &{} = {}\", x_old, y, x / &y);\n    }\n}\n\nfn demo_rational_div_float_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{} / &{:#x} = {:#x}\",\n            x_old,\n            ComparableFloatRef(&y),\n            ComparableFloat(x / &y)\n        );\n    }\n}\n\nfn demo_rational_div_float_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} / {} = {}\", x, y_old, &x / y);\n    }\n}\n\nfn demo_rational_div_float_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{} / {:#x} = {:#x}\",\n            x,\n            ComparableFloat(y_old),\n            ComparableFloat(&x / y)\n        );\n    }\n}\n\nfn demo_rational_div_float_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} / &{} = {}\", x, y, &x / &y);\n    }\n}\n\nfn demo_rational_div_float_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{} / &{:#x} = {:#x}\",\n            x,\n            ComparableFloatRef(&y),\n            ComparableFloat(&x / &y)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.div_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_prec(y, prec);\n        println!(\n            \"({:#x}).div_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.div_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_prec(y, prec);\n        println!(\n            \"({:#x}).div_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).div_rational_prec({}, &{}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.div_rational_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.div_rational_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).div_rational_prec_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_rational_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.div_rational_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).div_rational_prec_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).div_rational_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.div_rational_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.div_rational_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).div_rational_prec_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_rational_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.div_rational_prec_assign({y_old}, {prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_div_rational_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_rational_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.div_rational_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_rational_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.div_rational_prec_assign_ref({y}, &{prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_div_rational_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_rational_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.div_rational_prec_assign(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_prec({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            Float::rational_div_float_prec(x, y, prec)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_prec(x, y, prec);\n        println!(\n            \"rational_div_float_prec({}, {:#x}, {}) = ({:#x}, {:?})\",\n            x_old,\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_prec({}, {}, {}) = {:?}\",\n            y_old,\n            x_old,\n            prec,\n            Float::rational_div_float_prec(y, x, prec)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_prec(y, x, prec);\n        println!(\n            \"rational_div_float_prec({}, {:#x}, {}) = ({:#x}, {:?})\",\n            y_old,\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"rational_div_float_prec({}, &{}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            Float::rational_div_float_prec_val_ref(x, &y, prec)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = Float::rational_div_float_prec_val_ref(x, &y, prec);\n        println!(\n            \"rational_div_float_prec_val_ref({}, &{:#x}, {}) = ({:#x}, {:?})\",\n            x_old,\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_prec_ref_val(&{}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            Float::rational_div_float_prec_ref_val(&x, y, prec)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_prec_ref_val(&x, y, prec);\n        println!(\n            \"rational_div_float_prec_ref_val(&{}, {:#x}, {}) = ({:#x}, {:?})\",\n            x,\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"rational_div_float_prec_ref_ref(&{}, &{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            Float::rational_div_float_prec_ref_ref(&x, &y, prec)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = Float::rational_div_float_prec_ref_ref(&x, &y, prec);\n        println!(\n            \"rational_div_float_prec_ref_ref(&{}, &{:#x}, {}) = ({:#x}, {:?})\",\n            x,\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.div_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_round(y, rm);\n        println!(\n            \"({:#x}).div_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.div_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_round(y, rm);\n        println!(\n            \"({:#x}).div_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).div_rational_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.div_rational_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.div_rational_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).div_rational_round_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_rational_round_ref_val(&{}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.div_rational_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).div_rational_round_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).div_rational_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.div_rational_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.div_rational_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).div_rational_round_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_rational_round_assign(y, rm);\n        println!(\"x := {x_old}; x.div_rational_round_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_div_rational_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_rational_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.div_rational_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_rational_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_rational_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.div_rational_round_assign_ref(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_div_rational_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_rational_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.div_rational_round_assign_ref(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_rational_div_float_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            Float::rational_div_float_round(x, y, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_round(x, y, rm);\n        println!(\n            \"rational_div_float_round({}, {:#x}, {}) = ({:#x}, {:?})\",\n            x_old,\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_round({}, {}, {}) = {:?}\",\n            y_old,\n            x_old,\n            rm,\n            Float::rational_div_float_round(y, x, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_round(y, x, rm);\n        println!(\n            \"rational_div_float_round({}, {:#x}, {}) = ({:#x}, {:?})\",\n            y_old,\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"rational_div_float_round_val_ref({}, &{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            Float::rational_div_float_round_val_ref(x, &y, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = Float::rational_div_float_round_val_ref(x, &y, rm);\n        println!(\n            \"rational_div_float_round_val_ref({}, &{:#x}, {}) = ({:#x}, {:?})\",\n            x_old,\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_round_ref_val(&{}, &{}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            Float::rational_div_float_round_ref_val(&x, y, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_round_ref_val(&x, y, rm);\n        println!(\n            \"rational_div_float_round_ref_val(&{}, {:#x}, {}) = ({:#x}, {:?})\",\n            x,\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"rational_div_float_round_ref_ref(&{}, &{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            Float::rational_div_float_round_ref_ref(&x, &y, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, rm) in float_rational_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = Float::rational_div_float_round_ref_ref(&x, &y, rm);\n        println!(\n            \"rational_div_float_round_ref_ref(&{}, &{:#x}, {}) = ({:#x}, {:?})\",\n            x,\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.div_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).div_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).div_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.div_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).div_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).div_rational_prec_round_val_ref(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.div_rational_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.div_rational_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).div_rational_prec_round_val_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_rational_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.div_rational_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.div_rational_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).div_rational_prec_round_ref_val({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).div_rational_prec_round_ref_ref(&{}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.div_rational_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.div_rational_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"(&{:#x}).div_rational_prec_round_ref_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {x_old}; x.div_rational_prec_round_assign({y_old}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.div_rational_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {x_old}; x.div_rational_prec_round_assign_ref(&{y}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_div_rational_prec_round_assign_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.div_rational_prec_round_assign_ref(&{}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_prec_round({}, {}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            Float::rational_div_float_prec_round(x, y, prec, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_prec_round(x, y, prec, rm);\n        println!(\n            \"rational_div_float_rational_prec_round({}, {:#x}, {}, {}) = ({:#x}, {:?})\",\n            x_old,\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_prec_round({}, {}, {}, {}) = {:?}\",\n            y_old,\n            x_old,\n            prec,\n            rm,\n            Float::rational_div_float_prec_round(y, x, prec, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_prec_round(y, x, prec, rm);\n        println!(\n            \"rational_div_float_prec_round({}, ({:#x}), {}, {}) = ({:#x}, {:?})\",\n            y_old,\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"Float::rational_div_float_prec_round_val_ref(&{}, {}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            Float::rational_div_float_prec_round_val_ref(x, &y, prec, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = Float::rational_div_float_prec_round_val_ref(x, &y, prec, rm);\n        println!(\n            \"rational_div_float_prec_round_val_ref({}, &{:#x}, {}, {}) = ({:#x}, {:?})\",\n            x_old,\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"rational_div_float_prec_round_ref_val(&{}, {}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            Float::rational_div_float_prec_round_ref_val(&x, y, prec, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = Float::rational_div_float_prec_round_ref_val(&x, y, prec, rm);\n        println!(\n            \"rational_div_float_prec_round_ref_val(&{}, {:#x}, {}, {}) = ({:#x}, {:?})\",\n            x,\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"rational_div_float_prec_round_ref_ref(&{}, &{}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            Float::rational_div_float_prec_round_ref_ref(&x, &y, prec, rm)\n        );\n    }\n}\n\nfn demo_rational_div_float_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = Float::rational_div_float_prec_round_ref_ref(&x, &y, prec, rm);\n        println!(\n            \"rational_div_float_prec_round_ref_ref(&{}, &{:#x}, {}, {}) = ({:#x}, {:?})\",\n            x,\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float / Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float / Float\", &mut |(x, y)| no_out!(x / y)),\n            (\"Float / &Float\", &mut |(x, y)| no_out!(x / &y)),\n            (\"&Float / Float\", &mut |(x, y)| no_out!(&x / y)),\n            (\"&Float / &Float\", &mut |(x, y)| no_out!(&x / &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_div_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float / Float\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x / &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_div(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_div_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float / Float\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x / y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(div_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float /= Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float /= Float\", &mut |(mut x, y)| x /= y),\n            (\"Float /= &Float\", &mut |(mut x, y)| x /= &y),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.div_prec(Float, u64)\", &mut |(x, y, prec)| {\n                no_out!(x.div_prec(y, prec));\n            }),\n            (\"Float.div_prec_val_ref(&Float, u64)\", &mut |(\n                x,\n                y,\n                prec,\n            )| {\n                no_out!(x.div_prec_val_ref(&y, prec));\n            }),\n            (\n                \"(&Float).div_prec_ref_val(Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.div_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).div_prec_ref_ref(&Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.div_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec(Float, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.div_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_div_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec(Float, u64)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| no_out!(x.div_prec(y, prec))),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(div_prec_round_naive(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec_assign(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.div_prec_assign(Float, u64)\", &mut |(\n                mut x,\n                y,\n                prec,\n            )| {\n                no_out!(x.div_prec_assign(y, prec));\n            }),\n            (\n                \"Float.div_prec_assign_ref(&Float, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.div_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_round(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_23().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float.div_round(Float, RoundingMode)\", &mut |(x, y, rm)| {\n                no_out!(x.div_round(y, rm));\n            }),\n            (\n                \"Float.div_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).div_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).div_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_round(Float, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_rounding_mode_triple_gen_var_23_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.div_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_div_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_round(Float, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_rounding_mode_triple_gen_var_23().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| no_out!(x.div_round(y, rm))),\n            (\"naive\", &mut |(x, y, rm)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                div_prec_round_naive(x, y, max(xsb, ysb), rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_round_assign(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_23().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.div_round_assign(Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_round_assign(y, rm)),\n            ),\n            (\n                \"Float.div_round_assign_ref(&Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.div_prec_round(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.div_prec_round_val_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).div_prec_round_ref_val(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).div_prec_round_ref_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_4_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.div_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_div_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.div_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(div_prec_round_naive(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_prec_round_assign(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.div_prec_round_assign(Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.div_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.div_prec_round_assign_ref(&Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.div_prec_round_assign_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_div_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float / Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float / Rational\", &mut |(x, y)| no_out!(x / y)),\n            (\"Float / &Rational\", &mut |(x, y)| no_out!(x / &y)),\n            (\"&Float / Rational\", &mut |(x, y)| no_out!(&x / y)),\n            (\"&Float / &Rational\", &mut |(x, y)| no_out!(&x / &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_div_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float / Rational\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x / &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_div_rational(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_div_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float / Rational\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x / y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(div_rational_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n            (\"direct\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(div_rational_prec_round_direct(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float /= Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float /= Rational\", &mut |(mut x, y)| x /= y),\n            (\"Float /= &Rational\", &mut |(mut x, y)| x /= &y),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.div_rational_prec(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.div_rational_prec(y, prec)),\n            ),\n            (\n                \"Float.div_rational_prec_val_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.div_rational_prec_val_ref(&y, prec)),\n            ),\n            (\n                \"(&Float).div_rational_prec_ref_val(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.div_rational_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).div_rational_prec_ref_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.div_rational_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec(Rational, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.div_rational_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_div_rational_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec(Rational, u64)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| {\n                no_out!(x.div_rational_prec(y, prec));\n            }),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(div_rational_prec_round_naive(x, y, prec, Nearest));\n            }),\n            (\"direct\", &mut |(x, y, prec)| {\n                no_out!(div_rational_prec_round_direct(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_assign(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.div_rational_prec_assign(Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.div_rational_prec_assign(y, prec)),\n            ),\n            (\n                \"Float.div_rational_prec_assign_ref(&Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.div_rational_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.div_rational_round(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_rational_round(y, rm)),\n            ),\n            (\n                \"Float.div_rational_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_rational_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).div_rational_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_rational_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).div_rational_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_rational_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_rounding_mode_triple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.div_rational_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_div_rational_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_rounding_mode_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.div_rational_round(y, rm));\n            }),\n            (\"naive\", &mut |(x, y, rm)| {\n                let ysb = y.significant_bits();\n                div_rational_prec_round_naive(x, y, ysb, rm);\n            }),\n            (\"direct\", &mut |(x, y, rm)| {\n                let ysb = y.significant_bits();\n                div_rational_prec_round_direct(x, y, ysb, rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_round_assign(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.div_rational_round_assign(Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_rational_round_assign(y, rm)),\n            ),\n            (\n                \"Float.div_rational_round_assign_ref(&Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_rational_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.div_rational_prec_round(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_rational_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.div_rational_prec_round_val_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_rational_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).div_rational_prec_round_ref_val(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_rational_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).div_rational_prec_round_ref_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.div_rational_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_4_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\n            \"x\", \"y\", \"prec\",\n        ),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.div_rational_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_div_rational_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.div_rational_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_naive(x, y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_direct(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_round_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_round_val_ref(&Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.div_rational_prec_round_val_ref(&y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_naive_val_ref(x, &y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_direct_val_ref(x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_round_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_round_ref_val(Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.div_rational_prec_round_ref_val(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_naive_ref_val(&x, y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_direct_ref_val(&x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_round_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_round_ref_ref(&Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.div_rational_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_naive_ref_ref(&x, &y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(div_rational_prec_round_direct_ref_ref(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_div_rational_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.div_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.div_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.div_rational_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.div_rational_prec_round_assign_ref(&Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| {\n                    no_out!(x.div_rational_prec_round_assign_ref(&y, prec, rm));\n                },\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_div_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational / Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Rational / Float\", &mut |(y, x)| no_out!(x / y)),\n            (\"Rational / &Float\", &mut |(y, x)| no_out!(x / &y)),\n            (\"&Rational / Float\", &mut |(y, x)| no_out!(&x / y)),\n            (\"&Rational / &Float\", &mut |(y, x)| no_out!(&x / &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_div_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational / Float\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(&x / &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_div_rational(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_div_float_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational / Float\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x / y)),\n            (\"naive\", &mut |(y, x)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(rational_div_float_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n            (\"direct\", &mut |(y, x)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(rational_div_float_prec_round_direct(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_prec(Rational, Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float::rational_div_float_prec(Rational, Float, u64)\",\n                &mut |(y, x, prec)| no_out!(Float::rational_div_float_prec(x, y, prec)),\n            ),\n            (\n                \"Float::rational_div_float_prec_val_ref(Rational, &Float, u64)\",\n                &mut |(y, x, prec)| no_out!(Float::rational_div_float_prec_val_ref(x, &y, prec)),\n            ),\n            (\n                \"Float::rational_div_float_prec_ref_val(&Rational, Float, u64)\",\n                &mut |(y, x, prec)| no_out!(Float::rational_div_float_prec_ref_val(&x, y, prec)),\n            ),\n            (\n                \"Float::rational_div_float_prec_ref_ref(&Rational, &Float, u64)\",\n                &mut |(y, x, prec)| no_out!(Float::rational_div_float_prec_ref_ref(&x, &y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.rational_div_float_prec(Rational, Float, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x, prec))| {\n                no_out!(Float::rational_div_float_prec_ref_ref(&x, &y, prec));\n            }),\n            (\"rug\", &mut |((y, x, prec), _)| {\n                no_out!(rug_rational_div_float_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_prec(Rational, Float, u64)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(y, x, prec)| {\n                no_out!(Float::rational_div_float_prec(x, y, prec));\n            }),\n            (\"naive\", &mut |(y, x, prec)| {\n                no_out!(rational_div_float_prec_round_naive(x, y, prec, Nearest));\n            }),\n            (\"direct\", &mut |(y, x, prec)| {\n                no_out!(rational_div_float_prec_round_direct(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_round(Rational, Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float::rational_div_float_round(Rational, Float, RoundingMode)\",\n                &mut |(y, x, rm)| no_out!(Float::rational_div_float_round(x, y, rm)),\n            ),\n            (\n                \"Float::rational_div_float_round_val_ref(Rational, &Float, RoundingMode)\",\n                &mut |(y, x, rm)| no_out!(Float::rational_div_float_round_val_ref(x, &y, rm)),\n            ),\n            (\n                \"Float::rational_div_float_round_ref_val(&Rational, Float, RoundingMode)\",\n                &mut |(y, x, rm)| no_out!(Float::rational_div_float_round_ref_val(&x, y, rm)),\n            ),\n            (\n                \"Float::rational_div_float_round_ref_ref(&Rational, &Float, RoundingMode)\",\n                &mut |(y, x, rm)| no_out!(Float::rational_div_float_round_ref_ref(&x, &y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.rational_div_float_round(Rational, Float, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_rounding_mode_triple_gen_var_6_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x, rm))| {\n                no_out!(Float::rational_div_float_round_ref_ref(&x, &y, rm));\n            }),\n            (\"rug\", &mut |((y, x, rm), _)| {\n                no_out!(rug_rational_div_float_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_round(Float, Float, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_rounding_mode_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(y, x, rm)| {\n                no_out!(Float::rational_div_float_round(x, y, rm));\n            }),\n            (\"naive\", &mut |(y, x, rm)| {\n                let ysb = y.significant_bits();\n                rational_div_float_prec_round_naive(x, y, ysb, rm);\n            }),\n            (\"direct\", &mut |(y, x, rm)| {\n                let ysb = y.significant_bits();\n                rational_div_float_prec_round_direct(x, y, ysb, rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_prec_round(Rational, Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float::rational_div_float_prec_round\\\n                (Rational, Float, u64, RoundingMode)\",\n                &mut |(y, x, prec, rm)| {\n                    no_out!(Float::rational_div_float_prec_round(x, y, prec, rm));\n                },\n            ),\n            (\n                \"Float::rational_div_float_prec_round_val_ref\\\n                (Rational, &Float, u64, RoundingMode)\",\n                &mut |(y, x, prec, rm)| {\n                    no_out!(Float::rational_div_float_prec_round_val_ref(\n                        x, &y, prec, rm\n                    ));\n                },\n            ),\n            (\n                \"Float::rational_div_float_prec_round_ref_val\\\n                (&Rational, Float, u64, RoundingMode)\",\n                &mut |(y, x, prec, rm)| {\n                    no_out!(Float::rational_div_float_prec_round_ref_val(\n                        &x, y, prec, rm\n                    ));\n                },\n            ),\n            (\n                \"Float::rational_div_float_prec_round_ref_ref\\\n                (&Rational, &Float, u64, RoundingMode)\",\n                &mut |(y, x, prec, rm)| {\n                    no_out!(Float::rational_div_float_prec_round_ref_ref(\n                        &x, &y, prec, rm\n                    ));\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.rational_div_float_prec_round(Rational, Float, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_5_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\n            \"x\", \"y\", \"prec\",\n        ),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x, prec, rm))| {\n                no_out!(Float::rational_div_float_prec_round_ref_ref(\n                    &x, &y, prec, rm\n                ));\n            }),\n            (\"rug\", &mut |((y, x, prec, rm), _)| {\n                no_out!(rug_rational_div_float_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_prec_round(Rational, Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(y, x, prec, rm)| {\n                no_out!(Float::rational_div_float_prec_round(x, y, prec, rm));\n            }),\n            (\"naive\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_naive(x, y, prec, rm));\n            }),\n            (\"direct\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_direct(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_round_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_prec_round_val_ref(Rational, &Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(y, x, prec, rm)| {\n                no_out!(Float::rational_div_float_prec_round_val_ref(\n                    x, &y, prec, rm\n                ));\n            }),\n            (\"naive\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_naive_val_ref(x, &y, prec, rm));\n            }),\n            (\"direct\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_direct_val_ref(\n                    x, &y, prec, rm\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_round_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_prec_round_ref_val(&Rational, Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(y, x, prec, rm)| {\n                no_out!(Float::rational_div_float_prec_round_ref_val(\n                    &x, y, prec, rm\n                ));\n            }),\n            (\"naive\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_naive_ref_val(&x, y, prec, rm));\n            }),\n            (\"direct\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_direct_ref_val(\n                    &x, y, prec, rm\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_div_float_prec_round_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::rational_div_float_prec_round_ref_ref(&Rational, &Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(y, x, prec, rm)| {\n                no_out!(Float::rational_div_float_prec_round_ref_ref(\n                    &x, &y, prec, rm\n                ));\n            }),\n            (\"naive\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_naive_ref_ref(\n                    &x, &y, prec, rm\n                ));\n            }),\n            (\"direct\", &mut |(y, x, prec, rm)| {\n                no_out!(rational_div_float_prec_round_direct_ref_ref(\n                    &x, &y, prec, rm\n                ));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_is_power_of_2);\n    register_demo!(runner, demo_float_is_power_of_2_debug);\n    register_demo!(runner, demo_float_is_power_of_2_extreme);\n    register_demo!(runner, demo_float_is_power_of_2_extreme_debug);\n\n    register_bench!(runner, benchmark_float_is_power_of_2);\n}\n\nfn demo_float_is_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        if n.is_power_of_2() {\n            println!(\"{n} is a power of 2\");\n        } else {\n            println!(\"{n} is not a power of 2\");\n        }\n    }\n}\n\nfn demo_float_is_power_of_2_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        if n.is_power_of_2() {\n            println!(\"{:#x} is a power of 2\", ComparableFloat(n));\n        } else {\n            println!(\"{:#x} is not a power of 2\", ComparableFloat(n));\n        }\n    }\n}\n\nfn demo_float_is_power_of_2_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        if n.is_power_of_2() {\n            println!(\"{n} is a power of 2\");\n        } else {\n            println!(\"{n} is not a power of 2\");\n        }\n    }\n}\n\nfn demo_float_is_power_of_2_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        if n.is_power_of_2() {\n            println!(\"{:#x} is a power of 2\", ComparableFloat(n));\n        } else {\n            println!(\"{:#x} is not a power of 2\", ComparableFloat(n));\n        }\n    }\n}\n\nfn benchmark_float_is_power_of_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.is_power_of_2()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.is_power_of_2()))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/ln.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ln, LnAssign};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::Float;\nuse malachite_float::arithmetic::ln::{primitive_float_ln, primitive_float_ln_rational};\nuse malachite_float::test_util::arithmetic::ln::{\n    rug_ln, rug_ln_prec, rug_ln_prec_round, rug_ln_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer, pair_2_float_complexity_bucketer,\n    pair_2_pair_1_float_complexity_bucketer,\n    pair_2_pair_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer,\n    pair_float_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_rm, float_gen_var_12, float_rounding_mode_pair_gen_var_34,\n    float_rounding_mode_pair_gen_var_34_rm, float_rounding_mode_pair_gen_var_35,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_1_rm, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_19,\n    float_unsigned_rounding_mode_triple_gen_var_19_rm,\n    float_unsigned_rounding_mode_triple_gen_var_20,\n    rational_unsigned_rounding_mode_triple_gen_var_6,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse malachite_q::test_util::bench::bucketers::{\n    pair_rational_bit_u64_max_bucketer, rational_bit_bucketer,\n    triple_1_2_rational_bit_u64_max_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_ln);\n    register_demo!(runner, demo_float_ln_debug);\n    register_demo!(runner, demo_float_ln_extreme);\n    register_demo!(runner, demo_float_ln_extreme_debug);\n    register_demo!(runner, demo_float_ln_ref);\n    register_demo!(runner, demo_float_ln_ref_debug);\n    register_demo!(runner, demo_float_ln_assign);\n    register_demo!(runner, demo_float_ln_assign_debug);\n    register_demo!(runner, demo_float_ln_prec);\n    register_demo!(runner, demo_float_ln_prec_debug);\n    register_demo!(runner, demo_float_ln_prec_extreme);\n    register_demo!(runner, demo_float_ln_prec_extreme_debug);\n    register_demo!(runner, demo_float_ln_prec_ref);\n    register_demo!(runner, demo_float_ln_prec_ref_debug);\n    register_demo!(runner, demo_float_ln_prec_assign);\n    register_demo!(runner, demo_float_ln_prec_assign_debug);\n    register_demo!(runner, demo_float_ln_round);\n    register_demo!(runner, demo_float_ln_round_debug);\n    register_demo!(runner, demo_float_ln_round_extreme);\n    register_demo!(runner, demo_float_ln_round_extreme_debug);\n    register_demo!(runner, demo_float_ln_round_ref);\n    register_demo!(runner, demo_float_ln_round_ref_debug);\n    register_demo!(runner, demo_float_ln_round_assign);\n    register_demo!(runner, demo_float_ln_round_assign_debug);\n    register_demo!(runner, demo_float_ln_prec_round);\n    register_demo!(runner, demo_float_ln_prec_round_debug);\n    register_demo!(runner, demo_float_ln_prec_round_extreme);\n    register_demo!(runner, demo_float_ln_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_ln_prec_round_ref);\n    register_demo!(runner, demo_float_ln_prec_round_ref_debug);\n    register_demo!(runner, demo_float_ln_prec_round_assign);\n    register_demo!(runner, demo_float_ln_prec_round_assign_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_ln);\n    register_demo!(runner, demo_float_ln_rational_prec);\n    register_demo!(runner, demo_float_ln_rational_prec_debug);\n    register_demo!(runner, demo_float_ln_rational_prec_ref);\n    register_demo!(runner, demo_float_ln_rational_prec_ref_debug);\n    register_demo!(runner, demo_float_ln_rational_prec_round);\n    register_demo!(runner, demo_float_ln_rational_prec_round_debug);\n    register_demo!(runner, demo_float_ln_rational_prec_round_ref);\n    register_demo!(runner, demo_float_ln_rational_prec_round_ref_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_ln_rational);\n\n    register_bench!(runner, benchmark_float_ln_evaluation_strategy);\n    register_bench!(runner, benchmark_float_ln_library_comparison);\n    register_bench!(runner, benchmark_float_ln_assign);\n    register_bench!(runner, benchmark_float_ln_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_ln_prec_library_comparison);\n    register_bench!(runner, benchmark_float_ln_prec_assign);\n    register_bench!(runner, benchmark_float_ln_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_ln_round_library_comparison);\n    register_bench!(runner, benchmark_float_ln_round_assign);\n    register_bench!(runner, benchmark_float_ln_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_ln_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_ln_prec_round_assign);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_ln);\n    register_bench!(runner, benchmark_float_ln_rational_prec_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_float_ln_rational_prec_round_evaluation_strategy\n    );\n    register_primitive_float_benches!(runner, benchmark_primitive_float_ln_rational);\n}\n\nfn demo_float_ln(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).ln() = {}\", x_old, x.ln());\n    }\n}\n\nfn demo_float_ln_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).ln() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.ln())\n        );\n    }\n}\n\nfn demo_float_ln_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).ln() = {}\", x_old, x.ln());\n    }\n}\n\nfn demo_float_ln_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).ln() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.ln())\n        );\n    }\n}\n\nfn demo_float_ln_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).ln() = {}\", x, (&x).ln());\n    }\n}\n\nfn demo_float_ln_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).ln() = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat((&x).ln())\n        );\n    }\n}\n\nfn demo_float_ln_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.ln_assign();\n        println!(\"x := {x_old}; x.ln_assign(); x = {x}\");\n    }\n}\n\nfn demo_float_ln_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.ln_assign();\n        println!(\n            \"x := {:#x}; x.ln_assign(); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_ln_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).ln_prec({}) = {:?}\", x_old, prec, x.ln_prec(prec));\n    }\n}\n\nfn demo_float_ln_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.ln_prec(prec);\n        println!(\n            \"({:#x}).ln_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).ln_prec({}) = {:?}\", x_old, prec, x.ln_prec(prec));\n    }\n}\n\nfn demo_float_ln_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.ln_prec(prec);\n        println!(\n            \"({:#x}).ln_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"(&{}).ln_prec_ref({}) = {:?}\", x, prec, x.ln_prec_ref(prec));\n    }\n}\n\nfn demo_float_ln_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (sum, o) = x.ln_prec_ref(prec);\n        println!(\n            \"(&{:#x}).ln_prec_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.ln_prec_assign(prec);\n        println!(\"x := {x_old}; x.ln_prec_assign({prec}); x = {x}\");\n    }\n}\n\nfn demo_float_ln_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let o = x.ln_prec_assign(prec);\n        println!(\n            \"x := {:#x}; x.ln_prec_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_ln_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\"({}).ln_round({}) = {:?}\", x_old, rm, x.ln_round(rm));\n    }\n}\n\nfn demo_float_ln_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.ln_round(rm);\n        println!(\n            \"({:#x}).ln_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_35()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\"({}).ln_round({}) = {:?}\", x_old, rm, x.ln_round(rm));\n    }\n}\n\nfn demo_float_ln_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_35()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.ln_round(rm);\n        println!(\n            \"({:#x}).ln_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).ln_round_ref({}) = {:?}\", x, rm, x.ln_round_ref(rm));\n    }\n}\n\nfn demo_float_ln_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.ln_round_ref(rm);\n        println!(\n            \"(&{:#x}).ln_round_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.ln_round_assign(rm);\n        println!(\"x := {x_old}; x.ln_round_assign({rm}); x = {x}\");\n    }\n}\n\nfn demo_float_ln_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_34()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.ln_round_assign(rm);\n        println!(\n            \"x := {:#x}; x.ln_round_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_ln_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).ln_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.ln_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_ln_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.ln_prec_round(prec, rm);\n        println!(\n            \"({:#x}).ln_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).ln_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.ln_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_ln_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.ln_prec_round(prec, rm);\n        println!(\n            \"({:#x}).ln_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).ln_prec_round_ref({}, {}) = {:?}\",\n            x,\n            prec,\n            rm,\n            x.ln_prec_round_ref(prec, rm)\n        );\n    }\n}\n\nfn demo_float_ln_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.ln_prec_round_ref(prec, rm);\n        println!(\n            \"({:#x}).ln_prec_round_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.ln_prec_round_assign(prec, rm);\n        println!(\"x := {x_old}; x.ln_prec_round({prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_ln_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.ln_prec_round_assign(prec, rm);\n        println!(\n            \"x := {:#x}; x.ln_prec_round({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_ln<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"primitive_float_ln({}) = {}\",\n            NiceFloat(x),\n            NiceFloat(primitive_float_ln(x))\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::ln_rational_prec({}, {}) = {:?}\",\n            n.clone(),\n            p,\n            Float::ln_rational_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::ln_rational_prec(n.clone(), p);\n        println!(\n            \"Float::ln_rational_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::ln_rational_prec_ref(&{}, {}) = {:?}\",\n            n,\n            p,\n            Float::ln_rational_prec_ref(&n, p)\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::ln_rational_prec_ref(&n, p);\n        println!(\n            \"Float::ln_rational_prec_ref(&{}, {}) = {:x?}\",\n            n,\n            p,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::ln_rational_prec_round({}, {}, {:?}) = {:?}\",\n            n.clone(),\n            p,\n            rm,\n            Float::ln_rational_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::ln_rational_prec_round(n.clone(), p, rm);\n        println!(\n            \"Float::ln_rational_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::ln_rational_prec_round_ref(&{}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::ln_rational_prec_round_ref(&n, p, rm)\n        );\n    }\n}\n\nfn demo_float_ln_rational_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::ln_rational_prec_round_ref(&n, p, rm);\n        println!(\n            \"Float::ln_rational_prec_round_ref(&{}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_ln_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"primitive_float_ln_rational({}) = {:?}\",\n            x,\n            NiceFloat(primitive_float_ln_rational::<T>(&x))\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_ln_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.ln()\", &mut |x| no_out!(x.ln())),\n            (\"(&Float).ln()\", &mut |x| no_out!((&x).ln())),\n        ],\n    );\n}\n\nfn benchmark_float_ln_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!((&x).ln())),\n            (\"rug\", &mut |(x, _)| no_out!(rug_ln(&x))),\n        ],\n    );\n}\n\nfn benchmark_float_ln_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.ln_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.ln_assign()\", &mut |mut x| x.ln_assign())],\n    );\n}\n\nfn benchmark_float_ln_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln_prec(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Float.ln_prec(u64)\", &mut |(x, prec)| {\n                no_out!(x.ln_prec(prec));\n            }),\n            (\"(&Float).ln_prec_ref(u64)\", &mut |(x, prec)| {\n                no_out!(x.ln_prec_ref(prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_ln_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec))| {\n                no_out!(x.ln_prec_ref(prec));\n            }),\n            (\"rug\", &mut |((x, prec), _)| {\n                no_out!(rug_ln_prec(&x, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_ln_prec_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.ln_prec_assign(u64)\",\n        BenchmarkType::Single,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\"Float.ln_prec_assign(u64)\", &mut |(mut x, prec)| {\n            no_out!(x.ln_prec_assign(prec));\n        })],\n    );\n}\n\nfn benchmark_float_ln_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln_round(RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_34().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.ln_round(RoundingMode)\", &mut |(x, rm)| {\n                no_out!(x.ln_round(rm));\n            }),\n            (\"(&Float).ln_round_ref(RoundingMode)\", &mut |(x, rm)| {\n                no_out!(x.ln_round_ref(rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_ln_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln_round(RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rounding_mode_pair_gen_var_34_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, rm))| {\n                no_out!(x.ln_round_ref(rm));\n            }),\n            (\"rug\", &mut |((x, rm), _)| no_out!(rug_ln_round(&x, rm))),\n        ],\n    );\n}\n\nfn benchmark_float_ln_round_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.ln_round_assign(RoundingMode)\",\n        BenchmarkType::Single,\n        float_rounding_mode_pair_gen_var_34().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.ln_round_assign(RoundingMode)\", &mut |(mut x, rm)| {\n            no_out!(x.ln_round_assign(rm));\n        })],\n    );\n}\n\nfn benchmark_float_ln_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln_prec_round(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\n                \"Float.ln_prec_round(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.ln_prec_round(prec, rm)),\n            ),\n            (\n                \"(&Float).ln_prec_round_ref(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.ln_prec_round_ref(prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_ln_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_19_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec, rm))| {\n                no_out!(x.ln_prec_round_ref(prec, rm));\n            }),\n            (\"rug\", &mut |((x, prec, rm), _)| {\n                no_out!(rug_ln_prec_round(&x, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_ln_prec_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.ln_prec_round_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        float_unsigned_rounding_mode_triple_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\n            \"Float.ln_prec_round_assign(u64, RoundingMode)\",\n            &mut |(mut x, prec, rm)| no_out!(x.ln_prec_round_assign(prec, rm)),\n        )],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_ln<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"primitive_float_ln({})\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"malachite\", &mut |x| {\n            no_out!(primitive_float_ln(x));\n        })],\n    );\n}\n\nfn benchmark_float_ln_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::ln_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::ln_rational_prec(Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::ln_rational_prec(n, prec)),\n            ),\n            (\n                \"Float::ln_rational_prec_ref(&Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::ln_rational_prec_ref(&n, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_ln_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::ln_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::ln_rational_prec(Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::ln_rational_prec_round(n, prec, rm)),\n            ),\n            (\n                \"Float::ln_rational_prec_ref(&Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::ln_rational_prec_round_ref(&n, prec, rm)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_ln_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"primitive_float_ln_rational_prec::<{}>(Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(primitive_float_ln_rational::<T>(&x));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    abs::register(runner);\n    add::register(runner);\n    agm::register(runner);\n    div::register(runner);\n    is_power_of_2::register(runner);\n    ln::register(runner);\n    mul::register(runner);\n    neg::register(runner);\n    power_of_2::register(runner);\n    reciprocal::register(runner);\n    reciprocal_sqrt::register(runner);\n    shl::register(runner);\n    shl_round::register(runner);\n    shr::register(runner);\n    shr_round::register(runner);\n    sign::register(runner);\n    sqrt::register(runner);\n    square::register(runner);\n    sub::register(runner);\n}\n\nmod abs;\nmod add;\nmod agm;\nmod div;\nmod is_power_of_2;\nmod ln;\nmod mul;\nmod neg;\nmod power_of_2;\nmod reciprocal;\nmod reciprocal_sqrt;\nmod shl;\nmod shl_round;\nmod shr;\nmod shr_round;\nmod sign;\nmod sqrt;\nmod square;\nmod sub;\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::arithmetic::mul::{\n    mul_rational_prec_round_direct, mul_rational_prec_round_direct_ref_ref,\n    mul_rational_prec_round_direct_ref_val, mul_rational_prec_round_direct_val_ref,\n    mul_rational_prec_round_naive, mul_rational_prec_round_naive_ref_ref,\n    mul_rational_prec_round_naive_ref_val, mul_rational_prec_round_naive_val_ref,\n};\nuse malachite_float::test_util::arithmetic::mul::{\n    mul_prec_round_naive, rug_mul, rug_mul_prec, rug_mul_prec_round, rug_mul_rational,\n    rug_mul_rational_prec, rug_mul_rational_prec_round, rug_mul_rational_round, rug_mul_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer, pair_2_pair_float_rational_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_max_complexity_bucketer,\n    pair_2_triple_1_2_float_rational_max_complexity_bucketer,\n    pair_2_triple_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_float_rational_primitive_int_max_complexity_bucketer,\n    pair_float_max_complexity_bucketer, pair_float_rational_max_complexity_bucketer,\n    quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_max_complexity_bucketer, triple_1_2_float_rational_max_complexity_bucketer,\n    triple_float_float_primitive_int_max_complexity_bucketer,\n    triple_float_rational_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_16, float_float_rounding_mode_triple_gen_var_16_rm,\n    float_float_rounding_mode_triple_gen_var_31,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_3_rm,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_7, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_1_rm, float_float_unsigned_triple_gen_var_2,\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10, float_rational_pair_gen,\n    float_rational_pair_gen_rm, float_rational_pair_gen_var_2,\n    float_rational_rounding_mode_triple_gen_var_3_rm,\n    float_rational_rounding_mode_triple_gen_var_4, float_rational_rounding_mode_triple_gen_var_9,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_3_rm,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_8,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_1_rm,\n    float_rational_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse std::cmp::max;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_mul);\n    register_demo!(runner, demo_float_mul_debug);\n    register_demo!(runner, demo_float_mul_extreme);\n    register_demo!(runner, demo_float_mul_extreme_debug);\n    register_demo!(runner, demo_float_mul_val_ref);\n    register_demo!(runner, demo_float_mul_val_ref_debug);\n    register_demo!(runner, demo_float_mul_ref_val);\n    register_demo!(runner, demo_float_mul_ref_val_debug);\n    register_demo!(runner, demo_float_mul_ref_ref);\n    register_demo!(runner, demo_float_mul_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_assign);\n    register_demo!(runner, demo_float_mul_assign_debug);\n    register_demo!(runner, demo_float_mul_assign_ref);\n    register_demo!(runner, demo_float_mul_assign_ref_debug);\n    register_demo!(runner, demo_float_mul_prec);\n    register_demo!(runner, demo_float_mul_prec_debug);\n    register_demo!(runner, demo_float_mul_prec_extreme);\n    register_demo!(runner, demo_float_mul_prec_extreme_debug);\n    register_demo!(runner, demo_float_mul_prec_val_ref);\n    register_demo!(runner, demo_float_mul_prec_val_ref_debug);\n    register_demo!(runner, demo_float_mul_prec_ref_val);\n    register_demo!(runner, demo_float_mul_prec_ref_val_debug);\n    register_demo!(runner, demo_float_mul_prec_ref_ref);\n    register_demo!(runner, demo_float_mul_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_prec_assign);\n    register_demo!(runner, demo_float_mul_prec_assign_debug);\n    register_demo!(runner, demo_float_mul_prec_assign_ref);\n    register_demo!(runner, demo_float_mul_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_mul_round);\n    register_demo!(runner, demo_float_mul_round_debug);\n    register_demo!(runner, demo_float_mul_round_extreme);\n    register_demo!(runner, demo_float_mul_round_extreme_debug);\n    register_demo!(runner, demo_float_mul_round_val_ref);\n    register_demo!(runner, demo_float_mul_round_val_ref_debug);\n    register_demo!(runner, demo_float_mul_round_ref_val);\n    register_demo!(runner, demo_float_mul_round_ref_val_debug);\n    register_demo!(runner, demo_float_mul_round_ref_ref);\n    register_demo!(runner, demo_float_mul_round_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_round_assign);\n    register_demo!(runner, demo_float_mul_round_assign_debug);\n    register_demo!(runner, demo_float_mul_round_assign_ref);\n    register_demo!(runner, demo_float_mul_round_assign_ref_debug);\n    register_demo!(runner, demo_float_mul_prec_round);\n    register_demo!(runner, demo_float_mul_prec_round_debug);\n    register_demo!(runner, demo_float_mul_prec_round_extreme);\n    register_demo!(runner, demo_float_mul_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_mul_prec_round_val_ref);\n    register_demo!(runner, demo_float_mul_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_mul_prec_round_ref_val);\n    register_demo!(runner, demo_float_mul_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_mul_prec_round_ref_ref);\n    register_demo!(runner, demo_float_mul_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_prec_round_assign);\n    register_demo!(runner, demo_float_mul_prec_round_assign_debug);\n    register_demo!(runner, demo_float_mul_prec_round_assign_ref);\n    register_demo!(runner, demo_float_mul_prec_round_assign_ref_debug);\n    register_demo!(runner, demo_float_mul_rational);\n    register_demo!(runner, demo_float_mul_rational_debug);\n    register_demo!(runner, demo_float_mul_rational_extreme);\n    register_demo!(runner, demo_float_mul_rational_extreme_debug);\n    register_demo!(runner, demo_float_mul_rational_val_ref);\n    register_demo!(runner, demo_float_mul_rational_val_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_ref_val);\n    register_demo!(runner, demo_float_mul_rational_ref_val_debug);\n    register_demo!(runner, demo_float_mul_rational_ref_ref);\n    register_demo!(runner, demo_float_mul_rational_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_assign);\n    register_demo!(runner, demo_float_mul_rational_assign_debug);\n    register_demo!(runner, demo_float_mul_rational_assign_ref);\n    register_demo!(runner, demo_float_mul_rational_assign_ref_debug);\n    register_demo!(runner, demo_rational_mul_float);\n    register_demo!(runner, demo_rational_mul_float_debug);\n    register_demo!(runner, demo_rational_mul_float_extreme);\n    register_demo!(runner, demo_rational_mul_float_extreme_debug);\n    register_demo!(runner, demo_rational_mul_float_val_ref);\n    register_demo!(runner, demo_rational_mul_float_val_ref_debug);\n    register_demo!(runner, demo_rational_mul_float_ref_val);\n    register_demo!(runner, demo_rational_mul_float_ref_val_debug);\n    register_demo!(runner, demo_rational_mul_float_ref_ref);\n    register_demo!(runner, demo_rational_mul_float_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_prec);\n    register_demo!(runner, demo_float_mul_rational_prec_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_extreme);\n    register_demo!(runner, demo_float_mul_rational_prec_extreme_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_val_ref);\n    register_demo!(runner, demo_float_mul_rational_prec_val_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_ref_val);\n    register_demo!(runner, demo_float_mul_rational_prec_ref_val_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_ref_ref);\n    register_demo!(runner, demo_float_mul_rational_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_assign);\n    register_demo!(runner, demo_float_mul_rational_prec_assign_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_assign_ref);\n    register_demo!(runner, demo_float_mul_rational_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_round);\n    register_demo!(runner, demo_float_mul_rational_round_debug);\n    register_demo!(runner, demo_float_mul_rational_round_extreme);\n    register_demo!(runner, demo_float_mul_rational_round_extreme_debug);\n    register_demo!(runner, demo_float_mul_rational_round_val_ref);\n    register_demo!(runner, demo_float_mul_rational_round_val_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_round_ref_val);\n    register_demo!(runner, demo_float_mul_rational_round_ref_val_debug);\n    register_demo!(runner, demo_float_mul_rational_round_ref_ref);\n    register_demo!(runner, demo_float_mul_rational_round_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_round_assign);\n    register_demo!(runner, demo_float_mul_rational_round_assign_debug);\n    register_demo!(runner, demo_float_mul_rational_round_assign_ref);\n    register_demo!(runner, demo_float_mul_rational_round_assign_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_round);\n    register_demo!(runner, demo_float_mul_rational_prec_round_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_round_extreme);\n    register_demo!(runner, demo_float_mul_rational_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_round_val_ref);\n    register_demo!(runner, demo_float_mul_rational_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_round_ref_val);\n    register_demo!(runner, demo_float_mul_rational_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_round_ref_ref);\n    register_demo!(runner, demo_float_mul_rational_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_round_assign);\n    register_demo!(runner, demo_float_mul_rational_prec_round_assign_debug);\n    register_demo!(runner, demo_float_mul_rational_prec_round_assign_ref);\n    register_demo!(runner, demo_float_mul_rational_prec_round_assign_ref_debug);\n\n    register_bench!(runner, benchmark_float_mul_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_library_comparison);\n    register_bench!(runner, benchmark_float_mul_algorithms);\n    register_bench!(runner, benchmark_float_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_prec_library_comparison);\n    register_bench!(runner, benchmark_float_mul_prec_algorithms);\n    register_bench!(runner, benchmark_float_mul_prec_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_round_library_comparison);\n    register_bench!(runner, benchmark_float_mul_round_algorithms);\n    register_bench!(runner, benchmark_float_mul_round_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_mul_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_mul_prec_round_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_mul_rational_evaluation_strategy);\n    register_bench!(runner, benchmark_float_mul_rational_library_comparison);\n    register_bench!(runner, benchmark_float_mul_rational_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_mul_float_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_mul_float_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_mul_rational_prec_library_comparison);\n    register_bench!(runner, benchmark_float_mul_rational_prec_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_mul_rational_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_round_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_mul_rational_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_round_val_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_round_ref_val_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_round_ref_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_mul_rational_prec_round_assign_evaluation_strategy\n    );\n}\n\nfn demo_float_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_float_mul_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} * {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x * y)\n        );\n    }\n}\n\nfn demo_float_mul_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_float_mul_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} * {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x * y)\n        );\n    }\n}\n\nfn demo_float_mul_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} * &{} = {}\", x_old, y, x * &y);\n    }\n}\n\nfn demo_float_mul_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} * &{:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloatRef(&y),\n            ComparableFloat(x * &y)\n        );\n    }\n}\n\nfn demo_float_mul_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} * {} = {}\", x, y_old, &x * y);\n    }\n}\n\nfn demo_float_mul_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} * {:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat(y_old),\n            ComparableFloat(&x * y)\n        );\n    }\n}\n\nfn demo_float_mul_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} * &{} = {}\", x, y, &x * &y);\n    }\n}\n\nfn demo_float_mul_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} * &{:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloatRef(&y),\n            ComparableFloat(&x * &y)\n        );\n    }\n}\n\nfn demo_float_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\"x := {x_old}; x *= {y}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\n            \"x := {:#x}; x *= {:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\"x := {x_old}; x *= &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\n            \"x := {:#x}; x *= &{:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.mul_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_prec(y, prec);\n        println!(\n            \"({:#x}).mul_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.mul_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_prec(y, prec);\n        println!(\n            \"({:#x}).mul_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).mul_prec_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.mul_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.mul_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).mul_prec_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).mul_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.mul_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.mul_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).mul_prec_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mul_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.mul_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.mul_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).mul_prec_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mul_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.mul_prec_assign({y_old}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_mul_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.mul_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.mul_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.mul_prec_assign({y}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_mul_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.mul_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.mul_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_round(y, rm);\n        println!(\n            \"({:#x}).mul_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_31()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.mul_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_31()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_round(y, rm);\n        println!(\n            \"({:#x}).mul_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).mul_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.mul_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.mul_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).mul_round_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).mul_round_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.mul_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.mul_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).mul_round_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mul_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.mul_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.mul_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).mul_round_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mul_round_assign(y, rm);\n        println!(\"x := {x_old}; x.mul_round_assign({y_old}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_mul_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.mul_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.mul_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.mul_round_assign({y}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_mul_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.mul_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.mul_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).mul_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.mul_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).mul_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).mul_prec_round(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.mul_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.mul_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).mul_prec_round_val_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).mul_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.mul_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.mul_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).mul_prec_round_ref_val({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).mul_prec_round({}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.mul_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.mul_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).mul_prec_round_ref_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_prec_round_assign(y, prec, rm);\n        println!(\"x := {x_old}; x.mul_prec_round({y_old}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.mul_prec_round({:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_prec_round_assign_ref(&y, prec, rm);\n        println!(\"x := {x_old}; x.mul_prec_round_ref(&{y}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_prec_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.mul_prec_round_ref(&{:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_float_mul_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} * {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x * y)\n        );\n    }\n}\n\nfn demo_float_mul_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_float_mul_rational_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} * {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x * y)\n        );\n    }\n}\n\nfn demo_float_mul_rational_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} * &{} = {}\", x_old, y, x * &y);\n    }\n}\n\nfn demo_float_mul_rational_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} * {} = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x * &y)\n        );\n    }\n}\n\nfn demo_float_mul_rational_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} * {} = {}\", x, y_old, &x * y);\n    }\n}\n\nfn demo_float_mul_rational_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} * {} = {:#x}\",\n            ComparableFloatRef(&x),\n            y_old,\n            ComparableFloat(&x * y)\n        );\n    }\n}\n\nfn demo_float_mul_rational_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} * &{} = {}\", x, y, &x * &y);\n    }\n}\n\nfn demo_float_mul_rational_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} * &{} = {:#x}\",\n            ComparableFloatRef(&x),\n            y,\n            ComparableFloat(&x * &y)\n        );\n    }\n}\n\nfn demo_float_mul_rational_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\"x := {x_old}; x *= {y}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_rational_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\n            \"x := {:#x}; x *= {}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_rational_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\"x := {x_old}; x *= &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_rational_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\n            \"x := {:#x}; x *= &{}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_rational_mul_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_rational_mul_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} * {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x * y)\n        );\n    }\n}\n\nfn demo_rational_mul_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_rational_mul_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} * {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x * y)\n        );\n    }\n}\n\nfn demo_rational_mul_float_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} * &{} = {}\", x_old, y, x * &y);\n    }\n}\n\nfn demo_rational_mul_float_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{} * &{:#x} = {:#x}\",\n            x_old,\n            ComparableFloatRef(&y),\n            ComparableFloat(x * &y)\n        );\n    }\n}\n\nfn demo_rational_mul_float_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} * {} = {}\", x, y_old, &x * y);\n    }\n}\n\nfn demo_rational_mul_float_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{} * {:#x} = {:#x}\",\n            x,\n            ComparableFloat(y_old),\n            ComparableFloat(&x * y)\n        );\n    }\n}\n\nfn demo_rational_mul_float_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} * &{} = {}\", x, y, &x * &y);\n    }\n}\n\nfn demo_rational_mul_float_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{} * &{:#x} = {:#x}\",\n            x,\n            ComparableFloatRef(&y),\n            ComparableFloat(&x * &y)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.mul_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_prec(y, prec);\n        println!(\n            \"({:#x}).mul_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.mul_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_prec(y, prec);\n        println!(\n            \"({:#x}).mul_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).mul_rational_prec({}, &{}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.mul_rational_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.mul_rational_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).mul_rational_prec_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).mul_rational_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.mul_rational_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).mul_rational_prec_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mul_rational_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.mul_rational_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.mul_rational_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).mul_rational_prec_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_rational_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.mul_rational_prec_assign({y_old}, {prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_rational_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_rational_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.mul_rational_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_rational_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.mul_rational_prec_assign_ref({y}, &{prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_rational_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_rational_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.mul_rational_prec_assign(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_rational_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.mul_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_round(y, rm);\n        println!(\n            \"({:#x}).mul_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.mul_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_round(y, rm);\n        println!(\n            \"({:#x}).mul_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).mul_rational_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.mul_rational_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.mul_rational_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).mul_rational_round_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).mul_rational_round_ref_val(&{}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.mul_rational_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).mul_rational_round_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mul_rational_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.mul_rational_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.mul_rational_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).mul_rational_round_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_rational_round_assign(y, rm);\n        println!(\"x := {x_old}; x.mul_rational_round_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_rational_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_rational_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.mul_rational_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_rational_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_rational_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.mul_rational_round_assign_ref(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_mul_rational_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_rational_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.mul_rational_round_assign_ref(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.mul_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).mul_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).mul_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.mul_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).mul_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).mul_rational_prec_round_val_ref(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.mul_rational_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.mul_rational_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).mul_rational_prec_round_val_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).mul_rational_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.mul_rational_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (sum, o) = x.mul_rational_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).mul_rational_prec_round_ref_val({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mul_rational_prec_round_ref_ref(&{}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.mul_rational_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.mul_rational_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"(&{:#x}).mul_rational_prec_round_ref_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {x_old}; x.mul_rational_prec_round_assign({y_old}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.mul_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.mul_rational_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {x_old}; x.mul_rational_prec_round_assign_ref(&{y}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_mul_rational_prec_round_assign_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.mul_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.mul_rational_prec_round_assign_ref(&{}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float * Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float * Float\", &mut |(x, y)| no_out!(x * y)),\n            (\"Float * &Float\", &mut |(x, y)| no_out!(x * &y)),\n            (\"&Float * Float\", &mut |(x, y)| no_out!(&x * y)),\n            (\"&Float * &Float\", &mut |(x, y)| no_out!(&x * &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_mul_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float * Float\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x * &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_mul(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_mul_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float * Float\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x * y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(mul_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float *= Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float *= Float\", &mut |(mut x, y)| x *= y),\n            (\"Float *= &Float\", &mut |(mut x, y)| x *= &y),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.mul_prec(Float, u64)\", &mut |(x, y, prec)| {\n                no_out!(x.mul_prec(y, prec));\n            }),\n            (\"Float.mul_prec_val_ref(&Float, u64)\", &mut |(\n                x,\n                y,\n                prec,\n            )| {\n                no_out!(x.mul_prec_val_ref(&y, prec));\n            }),\n            (\n                \"(&Float).mul_prec_ref_val(Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.mul_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).mul_prec_ref_ref(&Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.mul_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec(Float, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.mul_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_mul_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec(Float, u64)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| no_out!(x.mul_prec(y, prec))),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(mul_prec_round_naive(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec_assign(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.mul_prec_assign(Float, u64)\", &mut |(\n                mut x,\n                y,\n                prec,\n            )| {\n                no_out!(x.mul_prec_assign(y, prec));\n            }),\n            (\n                \"Float.mul_prec_assign_ref(&Float, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.mul_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_round(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float.mul_round(Float, RoundingMode)\", &mut |(x, y, rm)| {\n                no_out!(x.mul_round(y, rm));\n            }),\n            (\n                \"Float.mul_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.mul_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).mul_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.mul_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).mul_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.mul_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_round(Float, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_rounding_mode_triple_gen_var_16_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.mul_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_mul_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_round(Float, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_rounding_mode_triple_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| no_out!(x.mul_round(y, rm))),\n            (\"naive\", &mut |(x, y, rm)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                mul_prec_round_naive(x, y, max(xsb, ysb), rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_round_assign(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.mul_round_assign(Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.mul_round_assign(y, rm)),\n            ),\n            (\n                \"Float.mul_round_assign_ref(&Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.mul_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.mul_prec_round(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.mul_prec_round_val_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).mul_prec_round_ref_val(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).mul_prec_round_ref_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.mul_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_mul_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.mul_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_prec_round_naive(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_prec_round_assign(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.mul_prec_round_assign(Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.mul_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.mul_prec_round_assign_ref(&Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.mul_prec_round_assign_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_mul_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float * Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float * Rational\", &mut |(x, y)| no_out!(x * y)),\n            (\"Float * &Rational\", &mut |(x, y)| no_out!(x * &y)),\n            (\"&Float * Rational\", &mut |(x, y)| no_out!(&x * y)),\n            (\"&Float * &Rational\", &mut |(x, y)| no_out!(&x * &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_mul_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float * Rational\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x * &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_mul_rational(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_mul_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float * Rational\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x * y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(mul_rational_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n            (\"direct\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(mul_rational_prec_round_direct(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float *= Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float *= Rational\", &mut |(mut x, y)| x *= y),\n            (\"Float *= &Rational\", &mut |(mut x, y)| x *= &y),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_mul_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational * Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Rational * Float\", &mut |(y, x)| no_out!(x * y)),\n            (\"Rational * &Float\", &mut |(y, x)| no_out!(x * &y)),\n            (\"&Rational * Float\", &mut |(y, x)| no_out!(&x * y)),\n            (\"&Rational * &Float\", &mut |(y, x)| no_out!(&x * &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_mul_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational * Float\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(&x * &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_mul_rational(&x, &y))),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.mul_rational_prec(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.mul_rational_prec(y, prec)),\n            ),\n            (\n                \"Float.mul_rational_prec_val_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.mul_rational_prec_val_ref(&y, prec)),\n            ),\n            (\n                \"(&Float).mul_rational_prec_ref_val(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.mul_rational_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).mul_rational_prec_ref_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.mul_rational_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec(Rational, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.mul_rational_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_mul_rational_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec(Rational, u64)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| {\n                no_out!(x.mul_rational_prec(y, prec));\n            }),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(mul_rational_prec_round_naive(x, y, prec, Nearest));\n            }),\n            (\"direct\", &mut |(x, y, prec)| {\n                no_out!(mul_rational_prec_round_direct(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec_assign(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.mul_rational_prec_assign(Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.mul_rational_prec_assign(y, prec)),\n            ),\n            (\n                \"Float.mul_rational_prec_assign_ref(&Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.mul_rational_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.mul_rational_round(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.mul_rational_round(y, rm)),\n            ),\n            (\n                \"Float.mul_rational_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.mul_rational_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).mul_rational_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.mul_rational_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).mul_rational_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.mul_rational_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_rounding_mode_triple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.mul_rational_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_mul_rational_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_rounding_mode_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.mul_rational_round(y, rm));\n            }),\n            (\"naive\", &mut |(x, y, rm)| {\n                let ysb = y.significant_bits();\n                mul_rational_prec_round_naive(x, y, ysb, rm);\n            }),\n            (\"direct\", &mut |(x, y, rm)| {\n                let ysb = y.significant_bits();\n                mul_rational_prec_round_direct(x, y, ysb, rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_round_assign(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.mul_rational_round_assign(Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.mul_rational_round_assign(y, rm)),\n            ),\n            (\n                \"Float.mul_rational_round_assign_ref(&Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.mul_rational_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.mul_rational_prec_round(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_rational_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.mul_rational_prec_round_val_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_rational_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).mul_rational_prec_round_ref_val(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_rational_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).mul_rational_prec_round_ref_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.mul_rational_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\n            \"x\", \"y\", \"prec\",\n        ),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.mul_rational_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_mul_rational_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.mul_rational_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_naive(x, y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_direct(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_round_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec_round_val_ref(&Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.mul_rational_prec_round_val_ref(&y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_naive_val_ref(x, &y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_direct_val_ref(x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_round_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Float).mul_rational_prec_round_ref_val(Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.mul_rational_prec_round_ref_val(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_naive_ref_val(&x, y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_direct_ref_val(&x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_round_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec_round_ref_ref(&Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.mul_rational_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_naive_ref_ref(&x, &y, prec, rm));\n            }),\n            (\"direct\", &mut |(x, y, prec, rm)| {\n                no_out!(mul_rational_prec_round_direct_ref_ref(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_mul_rational_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.mul_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.mul_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.mul_rational_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.mul_rational_prec_round_assign_ref(&Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| {\n                    no_out!(x.mul_rational_prec_round_assign_ref(&y, prec, rm));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_2_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{float_gen, float_gen_rm, float_gen_var_12};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_neg);\n    register_demo!(runner, demo_float_neg_debug);\n    register_demo!(runner, demo_float_neg_extreme);\n    register_demo!(runner, demo_float_neg_extreme_debug);\n    register_demo!(runner, demo_float_neg_ref);\n    register_demo!(runner, demo_float_neg_ref_debug);\n    register_demo!(runner, demo_float_neg_assign);\n    register_demo!(runner, demo_float_neg_assign_debug);\n\n    register_bench!(runner, benchmark_float_neg_library_comparison);\n    register_bench!(runner, benchmark_float_neg_evaluation_strategy);\n    register_bench!(runner, benchmark_float_neg_assign);\n}\n\nfn demo_float_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\"-({}) = {}\", n.clone(), -n);\n    }\n}\n\nfn demo_float_neg_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"-({:#x}) = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(-n)\n        );\n    }\n}\n\nfn demo_float_neg_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"-({}) = {}\", n.clone(), -n);\n    }\n}\n\nfn demo_float_neg_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"-({:#x}) = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(-n)\n        );\n    }\n}\n\nfn demo_float_neg_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\"-(&{}) = {}\", n, -&n);\n    }\n}\n\nfn demo_float_neg_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"-(&{:#x}) = {:#x}\",\n            ComparableFloatRef(&n),\n            ComparableFloat(-&n)\n        );\n    }\n}\n\nfn demo_float_neg_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in float_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.neg_assign();\n        println!(\"n := {n_old}; n.neg_assign(); n = {n}\");\n    }\n}\n\nfn demo_float_neg_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in float_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.neg_assign();\n        println!(\n            \"n := {:#x}; n.neg_assign(); n = {:#x}\",\n            ComparableFloat(n_old),\n            ComparableFloat(n)\n        );\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_neg_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Float\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(_, n)| no_out!(-n)), (\"rug\", &mut |(n, _)| no_out!(-n))],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_neg_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.neg()\", &mut |n| no_out!(-n)), (\"(&Float).neg()\", &mut |n| no_out!(-&n))],\n    );\n}\n\nfn benchmark_float_neg_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.neg_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.neg_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::test_util::bench::bucketers::{\n    abs_pair_usize_convertible_max_bucketer, abs_triple_1_2_usize_convertible_max_bucketer,\n    signed_abs_bucketer, unsigned_direct_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_gen_var_5, signed_unsigned_pair_gen_var_19, unsigned_gen_var_5,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::power_of_2::{\n    power_of_2_i64_naive, power_of_2_prec_naive, power_of_2_prec_round_naive, power_of_2_u64_naive,\n};\nuse malachite_float::test_util::generators::signed_unsigned_rounding_mode_triple_gen_var_5;\nuse malachite_float::{ComparableFloat, Float};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_power_of_2_prec_round);\n    register_demo!(runner, demo_float_power_of_2_prec_round_debug);\n    register_demo!(runner, demo_float_power_of_2_prec);\n    register_demo!(runner, demo_float_power_of_2_prec_debug);\n    register_demo!(runner, demo_float_power_of_2_u64);\n    register_demo!(runner, demo_float_power_of_2_u64_debug);\n    register_demo!(runner, demo_float_power_of_2_i64);\n    register_demo!(runner, demo_float_power_of_2_i64_debug);\n\n    register_bench!(runner, benchmark_float_power_of_2_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_power_of_2_prec_algorithms);\n    register_bench!(runner, benchmark_float_power_of_2_u64_algorithms);\n    register_bench!(runner, benchmark_float_power_of_2_i64_algorithms);\n}\n\nfn demo_float_power_of_2_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in signed_unsigned_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::power_of_2_prec_round({}, {}, {:?}) = {:?}\",\n            x,\n            prec,\n            rm,\n            Float::power_of_2_prec_round(x, prec, rm)\n        );\n    }\n}\n\nfn demo_float_power_of_2_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in signed_unsigned_rounding_mode_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (p, o) = Float::power_of_2_prec_round(x, prec, rm);\n        println!(\n            \"Float::power_of_2_prec_round({}, {}, {:?}) = ({:#x}, {:?})\",\n            x,\n            prec,\n            rm,\n            ComparableFloat(p),\n            o\n        );\n    }\n}\n\nfn demo_float_power_of_2_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in signed_unsigned_pair_gen_var_19::<i64, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::power_of_2_prec({}, {}) = {:?}\",\n            x,\n            prec,\n            Float::power_of_2_prec(x, prec)\n        );\n    }\n}\n\nfn demo_float_power_of_2_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in signed_unsigned_pair_gen_var_19::<i64, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (p, o) = Float::power_of_2_prec(x, prec);\n        println!(\n            \"Float::power_of_2_prec({}, {}) = ({:#x}, {:?})\",\n            x,\n            prec,\n            ComparableFloat(p),\n            o\n        );\n    }\n}\n\nfn demo_float_power_of_2_u64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen_var_5::<u64>().get(gm, config).take(limit) {\n        println!(\"Float::power_of_2({}) = {}\", x, Float::power_of_2(x));\n    }\n}\n\nfn demo_float_power_of_2_u64_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen_var_5::<u64>().get(gm, config).take(limit) {\n        println!(\n            \"Float::power_of_2({}) = {:#x}\",\n            x,\n            ComparableFloat(Float::power_of_2(x))\n        );\n    }\n}\n\nfn demo_float_power_of_2_i64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in signed_gen_var_5::<i64>().get(gm, config).take(limit) {\n        println!(\"Float::power_of_2({}) = {}\", x, Float::power_of_2(x));\n    }\n}\n\nfn demo_float_power_of_2_i64_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in signed_gen_var_5::<i64>().get(gm, config).take(limit) {\n        println!(\n            \"Float::power_of_2({}) = {:#x}\",\n            x,\n            ComparableFloat(Float::power_of_2(x))\n        );\n    }\n}\n\nfn benchmark_float_power_of_2_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.power_of_2_prec_round(i64, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        signed_unsigned_rounding_mode_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &abs_triple_1_2_usize_convertible_max_bucketer(\"i\", \"p\"),\n        &mut [\n            (\"default\", &mut |(i, p, rm)| {\n                no_out!(Float::power_of_2_prec_round(i, p, rm));\n            }),\n            (\"naive\", &mut |(i, p, rm)| {\n                no_out!(power_of_2_prec_round_naive(i, p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_power_of_2_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.power_of_2_prec(i64, u64)\",\n        BenchmarkType::Algorithms,\n        signed_unsigned_pair_gen_var_19::<i64, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &abs_pair_usize_convertible_max_bucketer(\"i\", \"p\"),\n        &mut [\n            (\"default\", &mut |(i, p)| {\n                no_out!(Float::power_of_2_prec(i, p));\n            }),\n            (\"naive\", &mut |(i, p)| no_out!(power_of_2_prec_naive(i, p))),\n        ],\n    );\n}\n\nfn benchmark_float_power_of_2_u64_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.power_of_2(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |u| no_out!(Float::power_of_2(u))),\n            (\"naive\", &mut |u| no_out!(power_of_2_u64_naive(u))),\n        ],\n    );\n}\n\nfn benchmark_float_power_of_2_i64_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.power_of_2(i64)\",\n        BenchmarkType::Algorithms,\n        signed_gen_var_5::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_abs_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |i| no_out!(Float::power_of_2(i))),\n            (\"naive\", &mut |i| no_out!(power_of_2_i64_naive(i))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Reciprocal, ReciprocalAssign};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::reciprocal::{\n    reciprocal_prec_round_naive_1, reciprocal_prec_round_naive_2, rug_reciprocal,\n    rug_reciprocal_prec, rug_reciprocal_prec_round, rug_reciprocal_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer, pair_2_float_complexity_bucketer,\n    pair_2_pair_1_float_complexity_bucketer,\n    pair_2_pair_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer,\n    pair_float_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_rm, float_gen_var_12, float_rounding_mode_pair_gen_var_13,\n    float_rounding_mode_pair_gen_var_13_rm, float_rounding_mode_pair_gen_var_23,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_1_rm, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_3,\n    float_unsigned_rounding_mode_triple_gen_var_3_rm,\n    float_unsigned_rounding_mode_triple_gen_var_12,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_reciprocal);\n    register_demo!(runner, demo_float_reciprocal_debug);\n    register_demo!(runner, demo_float_reciprocal_extreme);\n    register_demo!(runner, demo_float_reciprocal_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_ref);\n    register_demo!(runner, demo_float_reciprocal_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_assign);\n    register_demo!(runner, demo_float_reciprocal_assign_debug);\n    register_demo!(runner, demo_float_reciprocal_prec);\n    register_demo!(runner, demo_float_reciprocal_prec_debug);\n    register_demo!(runner, demo_float_reciprocal_prec_extreme);\n    register_demo!(runner, demo_float_reciprocal_prec_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_prec_ref);\n    register_demo!(runner, demo_float_reciprocal_prec_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_prec_assign);\n    register_demo!(runner, demo_float_reciprocal_prec_assign_debug);\n    register_demo!(runner, demo_float_reciprocal_round);\n    register_demo!(runner, demo_float_reciprocal_round_debug);\n    register_demo!(runner, demo_float_reciprocal_round_extreme);\n    register_demo!(runner, demo_float_reciprocal_round_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_round_ref);\n    register_demo!(runner, demo_float_reciprocal_round_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_round_assign);\n    register_demo!(runner, demo_float_reciprocal_round_assign_debug);\n    register_demo!(runner, demo_float_reciprocal_prec_round);\n    register_demo!(runner, demo_float_reciprocal_prec_round_debug);\n    register_demo!(runner, demo_float_reciprocal_prec_round_extreme);\n    register_demo!(runner, demo_float_reciprocal_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_prec_round_ref);\n    register_demo!(runner, demo_float_reciprocal_prec_round_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_prec_round_assign);\n    register_demo!(runner, demo_float_reciprocal_prec_round_assign_debug);\n\n    register_bench!(runner, benchmark_float_reciprocal_evaluation_strategy);\n    register_bench!(runner, benchmark_float_reciprocal_library_comparison);\n    register_bench!(runner, benchmark_float_reciprocal_algorithms);\n    register_bench!(runner, benchmark_float_reciprocal_assign);\n    register_bench!(runner, benchmark_float_reciprocal_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_reciprocal_prec_library_comparison);\n    register_bench!(runner, benchmark_float_reciprocal_prec_algorithms);\n    register_bench!(runner, benchmark_float_reciprocal_prec_assign);\n    register_bench!(runner, benchmark_float_reciprocal_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_reciprocal_round_library_comparison);\n    register_bench!(runner, benchmark_float_reciprocal_round_algorithms);\n    register_bench!(runner, benchmark_float_reciprocal_round_assign);\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_reciprocal_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_reciprocal_prec_round_assign);\n}\n\nfn demo_float_reciprocal(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).reciprocal() = {}\", x_old, x.reciprocal());\n    }\n}\n\nfn demo_float_reciprocal_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).reciprocal() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.reciprocal())\n        );\n    }\n}\n\nfn demo_float_reciprocal_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).reciprocal() = {}\", x_old, x.reciprocal());\n    }\n}\n\nfn demo_float_reciprocal_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).reciprocal() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.reciprocal())\n        );\n    }\n}\n\nfn demo_float_reciprocal_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).reciprocal() = {}\", x, (&x).reciprocal());\n    }\n}\n\nfn demo_float_reciprocal_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).reciprocal() = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat((&x).reciprocal())\n        );\n    }\n}\n\nfn demo_float_reciprocal_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.reciprocal_assign();\n        println!(\"x := {x_old}; x.reciprocal_assign(); x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.reciprocal_assign();\n        println!(\n            \"x := {:#x}; x.reciprocal_assign(); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_prec({}) = {:?}\",\n            x_old,\n            prec,\n            x.reciprocal_prec(prec)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_prec(prec);\n        println!(\n            \"({:#x}).reciprocal_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_prec({}) = {:?}\",\n            x_old,\n            prec,\n            x.reciprocal_prec(prec)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_prec(prec);\n        println!(\n            \"({:#x}).reciprocal_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).reciprocal_prec_ref({}) = {:?}\",\n            x,\n            prec,\n            x.reciprocal_prec_ref(prec)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (sum, o) = x.reciprocal_prec_ref(prec);\n        println!(\n            \"(&{:#x}).reciprocal_prec_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.reciprocal_prec_assign(prec);\n        println!(\"x := {x_old}; x.reciprocal_prec_assign({prec}); x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let o = x.reciprocal_prec_assign(prec);\n        println!(\n            \"x := {:#x}; x.reciprocal_prec_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_reciprocal_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_round({}) = {:?}\",\n            x_old,\n            rm,\n            x.reciprocal_round(rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_round(rm);\n        println!(\n            \"({:#x}).reciprocal_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_round({}) = {:?}\",\n            x_old,\n            rm,\n            x.reciprocal_round(rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_round(rm);\n        println!(\n            \"({:#x}).reciprocal_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).reciprocal_round_ref({}) = {:?}\",\n            x,\n            rm,\n            x.reciprocal_round_ref(rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.reciprocal_round_ref(rm);\n        println!(\n            \"(&{:#x}).reciprocal_round_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.reciprocal_round_assign(rm);\n        println!(\"x := {x_old}; x.reciprocal_round_assign({rm}); x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.reciprocal_round_assign(rm);\n        println!(\n            \"x := {:#x}; x.reciprocal_round_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.reciprocal_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_prec_round(prec, rm);\n        println!(\n            \"({:#x}).reciprocal_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_12()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.reciprocal_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_12()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_prec_round(prec, rm);\n        println!(\n            \"({:#x}).reciprocal_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).reciprocal_prec_round_ref({}, {}) = {:?}\",\n            x,\n            prec,\n            rm,\n            x.reciprocal_prec_round_ref(prec, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.reciprocal_prec_round_ref(prec, rm);\n        println!(\n            \"({:#x}).reciprocal_prec_round_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.reciprocal_prec_round_assign(prec, rm);\n        println!(\"x := {x_old}; x.reciprocal_prec_round({prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.reciprocal_prec_round_assign(prec, rm);\n        println!(\n            \"x := {:#x}; x.reciprocal_prec_round({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn benchmark_float_reciprocal_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.reciprocal()\", &mut |x| no_out!(x.reciprocal())),\n            (\"(&Float).reciprocal()\", &mut |x| no_out!((&x).reciprocal())),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!((&x).reciprocal())),\n            (\"rug\", &mut |(x, _)| no_out!(rug_reciprocal(&x))),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal()\",\n        BenchmarkType::Algorithms,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.reciprocal())),\n            (\"naive 1\", &mut |x| {\n                let xsb = x.significant_bits();\n                no_out!(reciprocal_prec_round_naive_1(x, xsb, Nearest).0);\n            }),\n            (\"naive 2\", &mut |x| {\n                let xsb = x.significant_bits();\n                no_out!(reciprocal_prec_round_naive_2(x, xsb, Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.reciprocal_assign()\", &mut |mut x| {\n            x.reciprocal_assign();\n        })],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Float.reciprocal_prec(u64)\", &mut |(x, prec)| {\n                no_out!(x.reciprocal_prec(prec));\n            }),\n            (\"(&Float).reciprocal_prec_ref(u64)\", &mut |(x, prec)| {\n                no_out!(x.reciprocal_prec_ref(prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec))| {\n                no_out!(x.reciprocal_prec_ref(prec));\n            }),\n            (\"rug\", &mut |((x, prec), _)| {\n                no_out!(rug_reciprocal_prec(&x, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec(u64)\",\n        BenchmarkType::Algorithms,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, prec)| no_out!(x.reciprocal_prec(prec))),\n            (\"naive 1\", &mut |(x, prec)| {\n                no_out!(reciprocal_prec_round_naive_1(x, prec, Nearest));\n            }),\n            (\"naive 2\", &mut |(x, prec)| {\n                no_out!(reciprocal_prec_round_naive_2(x, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec_assign(u64)\",\n        BenchmarkType::Single,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\"Float.reciprocal_prec_assign(u64)\", &mut |(mut x, prec)| {\n            no_out!(x.reciprocal_prec_assign(prec));\n        })],\n    );\n}\n\nfn benchmark_float_reciprocal_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_round(RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.reciprocal_round(RoundingMode)\", &mut |(x, rm)| {\n                no_out!(x.reciprocal_round(rm));\n            }),\n            (\n                \"(&Float).reciprocal_round_ref(RoundingMode)\",\n                &mut |(x, rm)| no_out!(x.reciprocal_round_ref(rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rounding_mode_pair_gen_var_13_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, rm))| {\n                no_out!(x.reciprocal_round_ref(rm));\n            }),\n            (\"rug\", &mut |((x, rm), _)| {\n                no_out!(rug_reciprocal_round(&x, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_round(RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rounding_mode_pair_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, rm)| no_out!(x.reciprocal_round(rm))),\n            (\"naive 1\", &mut |(x, rm)| {\n                let xsb = x.significant_bits();\n                reciprocal_prec_round_naive_1(x, xsb, rm);\n            }),\n            (\"naive 2\", &mut |(x, rm)| {\n                let xsb = x.significant_bits();\n                reciprocal_prec_round_naive_2(x, xsb, rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_round_assign(RoundingMode)\",\n        BenchmarkType::Single,\n        float_rounding_mode_pair_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\n            \"Float.reciprocal_round_assign(RoundingMode)\",\n            &mut |(mut x, rm)| no_out!(x.reciprocal_round_assign(rm)),\n        )],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec_round(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\n                \"Float.reciprocal_prec_round(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.reciprocal_prec_round(prec, rm)),\n            ),\n            (\n                \"(&Float).reciprocal_prec_round_ref(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.reciprocal_prec_round_ref(prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec, rm))| {\n                no_out!(x.reciprocal_prec_round_ref(prec, rm));\n            }),\n            (\"rug\", &mut |((x, prec, rm), _)| {\n                no_out!(rug_reciprocal_prec_round(&x, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_unsigned_rounding_mode_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, prec, rm)| {\n                no_out!(x.reciprocal_prec_round(prec, rm));\n            }),\n            (\"naive 1\", &mut |(x, prec, rm)| {\n                no_out!(reciprocal_prec_round_naive_1(x, prec, rm));\n            }),\n            (\"naive 2\", &mut |(x, prec, rm)| {\n                no_out!(reciprocal_prec_round_naive_2(x, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_prec_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_prec_round_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        float_unsigned_rounding_mode_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\n            \"Float.reciprocal_prec_round_assign(u64, RoundingMode)\",\n            &mut |(mut x, prec, rm)| no_out!(x.reciprocal_prec_round_assign(prec, rm)),\n        )],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/reciprocal_sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ReciprocalSqrt, ReciprocalSqrtAssign};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::arithmetic::reciprocal_sqrt::{\n    primitive_float_reciprocal_sqrt, primitive_float_reciprocal_sqrt_rational,\n};\nuse malachite_float::test_util::arithmetic::reciprocal_sqrt::{\n    reciprocal_sqrt_rational_prec_round_generic, reciprocal_sqrt_rational_prec_round_simple,\n    rug_reciprocal_sqrt, rug_reciprocal_sqrt_prec, rug_reciprocal_sqrt_prec_round,\n    rug_reciprocal_sqrt_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer, pair_2_float_complexity_bucketer,\n    pair_2_pair_1_float_complexity_bucketer,\n    pair_2_pair_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer,\n    pair_float_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_rm, float_gen_var_12, float_rounding_mode_pair_gen_var_30,\n    float_rounding_mode_pair_gen_var_30_rm, float_rounding_mode_pair_gen_var_31,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_1_rm, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_15,\n    float_unsigned_rounding_mode_triple_gen_var_15_rm,\n    float_unsigned_rounding_mode_triple_gen_var_16,\n    rational_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::test_util::bench::bucketers::{\n    pair_rational_bit_u64_max_bucketer, rational_bit_bucketer,\n    triple_1_2_rational_bit_u64_max_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_reciprocal_sqrt);\n    register_demo!(runner, demo_float_reciprocal_sqrt_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_extreme);\n    register_demo!(runner, demo_float_reciprocal_sqrt_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_ref);\n    register_demo!(runner, demo_float_reciprocal_sqrt_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_assign);\n    register_demo!(runner, demo_float_reciprocal_sqrt_assign_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_extreme);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_ref);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_assign);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_assign_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round_extreme);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round_ref);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round_assign);\n    register_demo!(runner, demo_float_reciprocal_sqrt_round_assign_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round_extreme);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round_ref);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round_assign);\n    register_demo!(runner, demo_float_reciprocal_sqrt_prec_round_assign_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_reciprocal_sqrt);\n    register_demo!(runner, demo_float_reciprocal_sqrt_rational_prec);\n    register_demo!(runner, demo_float_reciprocal_sqrt_rational_prec_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_rational_prec_ref);\n    register_demo!(runner, demo_float_reciprocal_sqrt_rational_prec_ref_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_rational_prec_round);\n    register_demo!(runner, demo_float_reciprocal_sqrt_rational_prec_round_debug);\n    register_demo!(runner, demo_float_reciprocal_sqrt_rational_prec_round_ref);\n    register_demo!(\n        runner,\n        demo_float_reciprocal_sqrt_rational_prec_round_ref_debug\n    );\n    register_primitive_float_demos!(runner, demo_primitive_float_reciprocal_sqrt_rational);\n\n    register_bench!(runner, benchmark_float_reciprocal_sqrt_evaluation_strategy);\n    register_bench!(runner, benchmark_float_reciprocal_sqrt_library_comparison);\n    register_bench!(runner, benchmark_float_reciprocal_sqrt_assign);\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_prec_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_prec_library_comparison\n    );\n    register_bench!(runner, benchmark_float_reciprocal_sqrt_prec_assign);\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_reciprocal_sqrt_round_assign);\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_reciprocal_sqrt_prec_round_assign);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_reciprocal_sqrt);\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_rational_prec_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_rational_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_reciprocal_sqrt_rational_prec_round_algorithms\n    );\n    register_primitive_float_benches!(runner, benchmark_primitive_float_reciprocal_sqrt_rational);\n}\n\nfn demo_float_reciprocal_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).reciprocal_sqrt() = {}\", x_old, x.reciprocal_sqrt());\n    }\n}\n\nfn demo_float_reciprocal_sqrt_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).reciprocal_sqrt() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.reciprocal_sqrt())\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).reciprocal_sqrt() = {}\", x_old, x.reciprocal_sqrt());\n    }\n}\n\nfn demo_float_reciprocal_sqrt_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).reciprocal_sqrt() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.reciprocal_sqrt())\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).reciprocal_sqrt() = {}\", x, (&x).reciprocal_sqrt());\n    }\n}\n\nfn demo_float_reciprocal_sqrt_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).reciprocal_sqrt() = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat((&x).reciprocal_sqrt())\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.reciprocal_sqrt_assign();\n        println!(\"x := {x_old}; x.reciprocal_sqrt_assign(); x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_sqrt_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.reciprocal_sqrt_assign();\n        println!(\n            \"x := {:#x}; x.reciprocal_sqrt_assign(); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_sqrt_prec({}) = {:?}\",\n            x_old,\n            prec,\n            x.reciprocal_sqrt_prec(prec)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_sqrt_prec(prec);\n        println!(\n            \"({:#x}).reciprocal_sqrt_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_sqrt_prec({}) = {:?}\",\n            x_old,\n            prec,\n            x.reciprocal_sqrt_prec(prec)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_sqrt_prec(prec);\n        println!(\n            \"({:#x}).reciprocal_sqrt_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).reciprocal_sqrt_prec_ref({}) = {:?}\",\n            x,\n            prec,\n            x.reciprocal_sqrt_prec_ref(prec)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (sum, o) = x.reciprocal_sqrt_prec_ref(prec);\n        println!(\n            \"(&{:#x}).reciprocal_sqrt_prec_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.reciprocal_sqrt_prec_assign(prec);\n        println!(\"x := {x_old}; x.reciprocal_sqrt_prec_assign({prec}); x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let o = x.reciprocal_sqrt_prec_assign(prec);\n        println!(\n            \"x := {:#x}; x.reciprocal_sqrt_prec_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_sqrt_round({}) = {:?}\",\n            x_old,\n            rm,\n            x.reciprocal_sqrt_round(rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_sqrt_round(rm);\n        println!(\n            \"({:#x}).reciprocal_sqrt_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_31()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_sqrt_round({}) = {:?}\",\n            x_old,\n            rm,\n            x.reciprocal_sqrt_round(rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_31()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_sqrt_round(rm);\n        println!(\n            \"({:#x}).reciprocal_sqrt_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).reciprocal_sqrt_round_ref({}) = {:?}\",\n            x,\n            rm,\n            x.reciprocal_sqrt_round_ref(rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.reciprocal_sqrt_round_ref(rm);\n        println!(\n            \"(&{:#x}).reciprocal_sqrt_round_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.reciprocal_sqrt_round_assign(rm);\n        println!(\"x := {x_old}; x.reciprocal_sqrt_round_assign({rm}); x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_sqrt_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.reciprocal_sqrt_round_assign(rm);\n        println!(\n            \"x := {:#x}; x.reciprocal_sqrt_round_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_sqrt_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.reciprocal_sqrt_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_sqrt_prec_round(prec, rm);\n        println!(\n            \"({:#x}).reciprocal_sqrt_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).reciprocal_sqrt_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.reciprocal_sqrt_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round_extreme_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.reciprocal_sqrt_prec_round(prec, rm);\n        println!(\n            \"({:#x}).reciprocal_sqrt_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).reciprocal_sqrt_prec_round_ref({}, {}) = {:?}\",\n            x,\n            prec,\n            rm,\n            x.reciprocal_sqrt_prec_round_ref(prec, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.reciprocal_sqrt_prec_round_ref(prec, rm);\n        println!(\n            \"({:#x}).reciprocal_sqrt_prec_round_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.reciprocal_sqrt_prec_round_assign(prec, rm);\n        println!(\"x := {x_old}; x.reciprocal_sqrt_prec_round({prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_reciprocal_sqrt_prec_round_assign_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.reciprocal_sqrt_prec_round_assign(prec, rm);\n        println!(\n            \"x := {:#x}; x.reciprocal_sqrt_prec_round({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_reciprocal_sqrt<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"primitive_float_reciprocal_sqrt({}) = {}\",\n            NiceFloat(x),\n            NiceFloat(primitive_float_reciprocal_sqrt(x))\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec({}, {}) = {:?}\",\n            n.clone(),\n            p,\n            Float::reciprocal_sqrt_rational_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::reciprocal_sqrt_rational_prec(n.clone(), p);\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec_ref(&{}, {}) = {:?}\",\n            n,\n            p,\n            Float::reciprocal_sqrt_rational_prec_ref(&n, p)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::reciprocal_sqrt_rational_prec_ref(&n, p);\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec_ref(&{}, {}) = {:x?}\",\n            n,\n            p,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec_round({}, {}, {:?}) = {:?}\",\n            n.clone(),\n            p,\n            rm,\n            Float::reciprocal_sqrt_rational_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec_round_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::reciprocal_sqrt_rational_prec_round(n.clone(), p, rm);\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec_round_ref(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec_round_ref(&{}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::reciprocal_sqrt_rational_prec_round_ref(&n, p, rm)\n        );\n    }\n}\n\nfn demo_float_reciprocal_sqrt_rational_prec_round_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::reciprocal_sqrt_rational_prec_round_ref(&n, p, rm);\n        println!(\n            \"Float::reciprocal_sqrt_rational_prec_round_ref(&{}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_reciprocal_sqrt_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"primitive_float_reciprocal_sqrt_rational({}) = {:?}\",\n            x,\n            NiceFloat(primitive_float_reciprocal_sqrt_rational::<T>(&x))\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_reciprocal_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.reciprocal_sqrt()\", &mut |x| {\n                no_out!(x.reciprocal_sqrt());\n            }),\n            (\"(&Float).reciprocal_sqrt()\", &mut |x| {\n                no_out!((&x).reciprocal_sqrt());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!((&x).reciprocal_sqrt())),\n            (\"rug\", &mut |(x, _)| no_out!(rug_reciprocal_sqrt(&x))),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.reciprocal_sqrt_assign()\", &mut |mut x| {\n            x.reciprocal_sqrt_assign();\n        })],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_prec(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Float.reciprocal_sqrt_prec(u64)\", &mut |(x, prec)| {\n                no_out!(x.reciprocal_sqrt_prec(prec));\n            }),\n            (\n                \"(&Float).reciprocal_sqrt_prec_ref(u64)\",\n                &mut |(x, prec)| {\n                    no_out!(x.reciprocal_sqrt_prec_ref(prec));\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec))| {\n                no_out!(x.reciprocal_sqrt_prec_ref(prec));\n            }),\n            (\"rug\", &mut |((x, prec), _)| {\n                no_out!(rug_reciprocal_sqrt_prec(&x, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_prec_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_prec_assign(u64)\",\n        BenchmarkType::Single,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\"Float.reciprocal_sqrt_prec_assign(u64)\", &mut |(\n            mut x,\n            prec,\n        )| {\n            no_out!(x.reciprocal_sqrt_prec_assign(prec));\n        })],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_round(RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_30().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\n                \"Float.reciprocal_sqrt_round(RoundingMode)\",\n                &mut |(x, rm)| {\n                    no_out!(x.reciprocal_sqrt_round(rm));\n                },\n            ),\n            (\n                \"(&Float).reciprocal_sqrt_round_ref(RoundingMode)\",\n                &mut |(x, rm)| {\n                    no_out!(x.reciprocal_sqrt_round_ref(rm));\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_round(RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rounding_mode_pair_gen_var_30_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, rm))| {\n                no_out!(x.reciprocal_sqrt_round_ref(rm));\n            }),\n            (\"rug\", &mut |((x, rm), _)| {\n                no_out!(rug_reciprocal_sqrt_round(&x, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_round_assign(RoundingMode)\",\n        BenchmarkType::Single,\n        float_rounding_mode_pair_gen_var_30().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\n            \"Float.reciprocal_sqrt_round_assign(RoundingMode)\",\n            &mut |(mut x, rm)| {\n                no_out!(x.reciprocal_sqrt_round_assign(rm));\n            },\n        )],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_prec_round(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\n                \"Float.reciprocal_sqrt_prec_round(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.reciprocal_sqrt_prec_round(prec, rm)),\n            ),\n            (\n                \"(&Float).reciprocal_sqrt_prec_round_ref(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.reciprocal_sqrt_prec_round_ref(prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_15_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec, rm))| {\n                no_out!(x.reciprocal_sqrt_prec_round_ref(prec, rm));\n            }),\n            (\"rug\", &mut |((x, prec, rm), _)| {\n                no_out!(rug_reciprocal_sqrt_prec_round(&x, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_prec_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.reciprocal_sqrt_prec_round_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        float_unsigned_rounding_mode_triple_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\n            \"Float.reciprocal_sqrt_prec_round_assign(u64, RoundingMode)\",\n            &mut |(mut x, prec, rm)| no_out!(x.reciprocal_sqrt_prec_round_assign(prec, rm)),\n        )],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_reciprocal_sqrt<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"primitive_float_reciprocal_sqrt({})\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [(\"malachite\", &mut |x| {\n            no_out!(primitive_float_reciprocal_sqrt(x));\n        })],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::reciprocal_sqrt_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::reciprocal_sqrt_rational_prec(Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::reciprocal_sqrt_rational_prec(n, prec)),\n            ),\n            (\n                \"Float::reciprocal_sqrt_rational_prec_ref(&Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::reciprocal_sqrt_rational_prec_ref(&n, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::reciprocal_sqrt_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::reciprocal_sqrt_rational_prec(Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| {\n                    no_out!(Float::reciprocal_sqrt_rational_prec_round(n, prec, rm));\n                },\n            ),\n            (\n                \"Float::reciprocal_sqrt_rational_prec_ref(&Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| {\n                    no_out!(Float::reciprocal_sqrt_rational_prec_round_ref(&n, prec, rm));\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_reciprocal_sqrt_rational_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::reciprocal_sqrt_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(n, prec, rm)| {\n                no_out!(Float::reciprocal_sqrt_rational_prec_round_ref(&n, prec, rm));\n            }),\n            (\"generic\", &mut |(n, prec, rm)| {\n                no_out!(reciprocal_sqrt_rational_prec_round_generic(&n, prec, rm));\n            }),\n            (\"simple\", &mut |(n, prec, rm)| {\n                no_out!(reciprocal_sqrt_rational_prec_round_simple(&n, prec, rm));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_reciprocal_sqrt_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\n            \"primitive_float_reciprocal_sqrt_rational::<{}>(Rational)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(primitive_float_reciprocal_sqrt_rational::<T>(&x));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::shl::shl_naive;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_1_float_complexity_bucketer, pair_2_pair_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen_var_2, float_signed_pair_gen_var_2_rm, float_signed_pair_gen_var_3,\n    float_unsigned_pair_gen_var_2, float_unsigned_pair_gen_var_2_rm, float_unsigned_pair_gen_var_3,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse std::ops::{Shl, ShlAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_shl_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shl_assign_signed);\n    register_signed_demos!(runner, demo_float_shl_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shl_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shl_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shl_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shl_signed);\n    register_signed_demos!(runner, demo_float_shl_signed_debug);\n    register_signed_demos!(runner, demo_float_shl_signed_extreme);\n    register_signed_demos!(runner, demo_float_shl_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shl_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shl_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shl_signed_ref);\n    register_signed_demos!(runner, demo_float_shl_signed_ref_debug);\n\n    register_unsigned_benches!(runner, benchmark_float_shl_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shl_assign_signed);\n    register_unsigned_benches!(runner, benchmark_float_shl_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_float_shl_signed_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_float_shl_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shl_signed_algorithms);\n\n    register_bench!(runner, benchmark_float_shl_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_float_shl_u32_library_comparison);\n    register_bench!(runner, benchmark_float_shl_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_float_shl_i32_library_comparison);\n}\n\nfn demo_float_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlAssign<T>,\n{\n    for (mut n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= u;\n        println!(\"x := {n_old}; x <<= {u}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlAssign<T>,\n{\n    for (mut n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= u;\n        println!(\n            \"x := {:#x}; x <<= {u}; x = {:#x}\",\n            ComparableFloat(n_old),\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: ShlAssign<T>,\n{\n    for (mut n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= i;\n        println!(\"x := {n_old}; x <<= {i}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlAssign<T>,\n{\n    for (mut n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= i;\n        println!(\n            \"x := {:#x}; x <<= {i}; x = {:#x}\",\n            ComparableFloat(n_old),\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shl<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, u, n << u);\n    }\n}\n\nfn demo_float_shl_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shl<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} << {} = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            ComparableFloat(n << u)\n        );\n    }\n}\n\nfn demo_float_shl_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shl<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, u, n << u);\n    }\n}\n\nfn demo_float_shl_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shl<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} << {} = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            ComparableFloat(n << u)\n        );\n    }\n}\n\nfn demo_float_shl_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shl<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, i, n << i);\n    }\n}\n\nfn demo_float_shl_signed_debug<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shl<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} << {} = {:#x}\",\n            ComparableFloat(n_old),\n            i,\n            ComparableFloat(n << i)\n        );\n    }\n}\n\nfn demo_float_shl_signed_extreme<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shl<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, i, n << i);\n    }\n}\n\nfn demo_float_shl_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shl<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} << {} = {:#x}\",\n            ComparableFloat(n_old),\n            i,\n            ComparableFloat(n << i)\n        );\n    }\n}\n\nfn demo_float_shl_unsigned_ref<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, u, &n << u);\n    }\n}\n\nfn demo_float_shl_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"&{:#x} << {} = {:#x}\",\n            ComparableFloatRef(&n),\n            u,\n            ComparableFloatRef(&(&n << u))\n        );\n    }\n}\n\nfn demo_float_shl_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, i, &n << i);\n    }\n}\n\nfn demo_float_shl_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"&{:#x} << {} = {:#x}\",\n            ComparableFloatRef(&n),\n            i,\n            ComparableFloatRef(&(&n << i))\n        );\n    }\n}\n\nfn benchmark_float_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        float_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n <<= u)],\n    );\n}\n\nfn benchmark_float_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        float_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, i)| n <<= i)],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shl_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shl<T, Output = Float>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Float << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Float << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shl_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shl<T, Output = Float>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Float << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Float << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shl_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shl<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x << y)),\n            (\"naive\", &mut |(x, y)| no_out!(shl_naive(x, y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shl_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shl<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x << y)),\n            (\"naive\", &mut |(x, y)| no_out!(shl_naive(x, y))),\n        ],\n    );\n}\n\nfn benchmark_float_shl_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float <<= u32\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_shl_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float << u32\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n\nfn benchmark_float_shl_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float <<= i32\",\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_shl_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float << i32\",\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShlRound, ShlRoundAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::shl_round::{\n    rug_shl_prec_round_signed, rug_shl_prec_round_unsigned, rug_shl_prec_signed,\n    rug_shl_prec_unsigned, rug_shl_round_signed, rug_shl_round_unsigned, shl_prec_naive,\n    shl_prec_round_naive, shl_round_naive,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_quadruple_1_float_complexity_bucketer, pair_2_triple_1_float_complexity_bucketer,\n    quadruple_1_float_complexity_bucketer, triple_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_rounding_mode_triple_gen_var_1, float_signed_rounding_mode_triple_gen_var_2,\n    float_signed_rounding_mode_triple_gen_var_3_rm,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_1_rm,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_signed_unsigned_triple_gen_var_1, float_signed_unsigned_triple_gen_var_1_rm,\n    float_signed_unsigned_triple_gen_var_2, float_unsigned_rounding_mode_triple_gen_var_5,\n    float_unsigned_rounding_mode_triple_gen_var_6,\n    float_unsigned_rounding_mode_triple_gen_var_7_rm,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1_rm,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_unsigned_unsigned_triple_gen_var_1, float_unsigned_unsigned_triple_gen_var_1_rm,\n    float_unsigned_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse std::ops::Shl;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_shl_prec_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_prec_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_assign_signed);\n    register_signed_demos!(runner, demo_float_shl_prec_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shl_prec_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_prec_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shl_prec_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shl_prec_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_signed);\n    register_signed_demos!(runner, demo_float_shl_prec_signed_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_signed_extreme);\n    register_signed_demos!(runner, demo_float_shl_prec_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shl_prec_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shl_prec_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_signed_ref);\n    register_signed_demos!(runner, demo_float_shl_prec_signed_ref_debug);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_round_assign_signed);\n    register_signed_demos!(runner, demo_float_shl_prec_round_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_round_signed);\n    register_signed_demos!(runner, demo_float_shl_prec_round_signed_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_round_signed_extreme);\n    register_signed_demos!(runner, demo_float_shl_prec_round_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shl_prec_round_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shl_prec_round_signed_ref);\n    register_signed_demos!(runner, demo_float_shl_prec_round_signed_ref_debug);\n    register_unsigned_demos!(runner, demo_float_shl_round_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_round_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shl_round_assign_signed);\n    register_signed_demos!(runner, demo_float_shl_round_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shl_round_unsigned);\n    register_unsigned_demos!(runner, demo_float_shl_round_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shl_round_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shl_round_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shl_round_signed);\n    register_signed_demos!(runner, demo_float_shl_round_signed_debug);\n    register_signed_demos!(runner, demo_float_shl_round_signed_extreme);\n    register_signed_demos!(runner, demo_float_shl_round_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shl_round_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shl_round_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shl_round_signed_ref);\n    register_signed_demos!(runner, demo_float_shl_round_signed_ref_debug);\n\n    register_unsigned_benches!(runner, benchmark_float_shl_prec_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shl_prec_assign_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_shl_prec_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_float_shl_prec_signed_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_float_shl_prec_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shl_prec_signed_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_shl_prec_assign_u32_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_shl_prec_assign_i32_library_comparison\n    );\n    register_unsigned_benches!(runner, benchmark_float_shl_prec_round_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shl_prec_round_assign_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_shl_prec_round_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_float_shl_prec_round_signed_evaluation_strategy\n    );\n    register_unsigned_benches!(runner, benchmark_float_shl_prec_round_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shl_prec_round_signed_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_shl_prec_round_assign_u32_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_shl_prec_round_assign_i32_library_comparison\n    );\n    register_unsigned_benches!(runner, benchmark_float_shl_round_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shl_round_assign_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_shl_round_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_float_shl_round_signed_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_float_shl_round_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shl_round_signed_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_shl_round_assign_u32_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_shl_round_assign_i32_library_comparison\n    );\n}\n\nfn demo_float_shl_prec_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_assign(u, prec);\n        println!(\"x := {n_old}; x.shl_prec_assign({u}, {prec}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_prec_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_assign(u, prec);\n        println!(\n            \"x := {:#x}; x.shl_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_prec_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_assign(u, prec);\n        println!(\"x := {n_old}; x.shl_prec_assign({u}, {prec}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_prec_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_assign(u, prec);\n        println!(\n            \"x := {:#x}; x.shl_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_prec_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shl_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shl_prec_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec(u, prec);\n        println!(\n            \"{:#x}.shl_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shl_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shl_prec_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec(u, prec);\n        println!(\n            \"{:#x}.shl_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shl_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shl_prec_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec(u, prec);\n        println!(\n            \"{:#x}.shl_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shl_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shl_prec_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec(u, prec);\n        println!(\n            \"{:#x}.shl_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shl_prec_ref({}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            n.shl_prec_ref(u, prec)\n        );\n    }\n}\n\nfn demo_float_shl_prec_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shl_prec_ref(u, prec);\n        println!(\n            \"{:#x}.shl_prec_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shl_prec_ref({}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            n.shl_prec_ref(u, prec)\n        );\n    }\n}\n\nfn demo_float_shl_prec_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shl_prec_ref(u, prec);\n        println!(\n            \"{:#x}.shl_prec_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_round_assign(u, prec, rm);\n        println!(\"x := {n_old}; x.shl_prec_round_assign({u}, {prec}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_prec_round_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_round_assign(u, prec, rm);\n        println!(\n            \"x := {:#x}; x.shl_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_round_assign(u, prec, rm);\n        println!(\"x := {n_old}; x.shl_prec_round_assign({u}, {prec}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_prec_round_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_prec_round_assign(u, prec, rm);\n        println!(\n            \"x := {:#x}; x.shl_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shl_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shl_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shl_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shl_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shl_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shl_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shl_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shl_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shl_prec_round_ref({}, {}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            rm,\n            n.shl_prec_round_ref(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shl_prec_round_ref(u, prec, rm);\n        println!(\n            \"{:#x}.shl_prec_round_ref({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shl_prec_round_ref({}, {}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            rm,\n            n.shl_prec_round_ref(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shl_prec_round_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shl_prec_round_ref(u, prec, rm);\n        println!(\n            \"{:#x}.shl_prec_round_ref({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRoundAssign<T>,\n{\n    for (mut n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_round_assign(u, rm);\n        println!(\"x := {n_old}; x.shl_round_assign({u}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_round_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRoundAssign<T>,\n{\n    for (mut n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_round_assign(u, rm);\n        println!(\n            \"x := {:#x}; x.shl_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRoundAssign<T>,\n{\n    for (mut n, i, rm) in float_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_round_assign(i, rm);\n        println!(\"x := {n_old}; x.shl_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shl_round_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRoundAssign<T>,\n{\n    for (mut n, i, rm) in float_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_round_assign(i, rm);\n        println!(\n            \"x := {:#x}; x.shl_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            i,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shl_round_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_round({}, {}) = {:?}\",\n            n_old,\n            u,\n            rm,\n            n.shl_round(u, rm)\n        );\n    }\n}\n\nfn demo_float_shl_round_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_round(u, rm);\n        println!(\n            \"{:#x}.shl_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_round_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_round({}, {}) = {:?}\",\n            n_old,\n            u,\n            rm,\n            n.shl_round(u, rm)\n        );\n    }\n}\n\nfn demo_float_shl_round_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_round(u, rm);\n        println!(\n            \"{:#x}.shl_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_round_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shl_round(i, rm)\n        );\n    }\n}\n\nfn demo_float_shl_round_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_round(i, rm);\n        println!(\n            \"{:#x}.shl_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            i,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_round_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shl_round(i, rm)\n        );\n    }\n}\n\nfn demo_float_shl_round_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShlRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shl_round(i, rm);\n        println!(\n            \"{:#x}.shl_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            i,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_round_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shl_round({}, {}) = {:?}\",\n            n,\n            u,\n            rm,\n            (&n).shl_round(u, rm)\n        );\n    }\n}\n\nfn demo_float_shl_round_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = (&n).shl_round(u, rm);\n        println!(\n            \"(&{:#x}.shl_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloatRef(&n),\n            u,\n            rm,\n            ComparableFloatRef(&shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shl_round_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shl_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            (&n).shl_round(i, rm)\n        );\n    }\n}\n\nfn demo_float_shl_round_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = (&n).shl_round(i, rm);\n        println!(\n            \"(&{:#x}).shl_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloatRef(&n),\n            i,\n            rm,\n            ComparableFloatRef(&shifted),\n            o\n        );\n    }\n}\n\nfn benchmark_float_shl_prec_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shl_prec_assign({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        float_unsigned_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec)| {\n            no_out!(n.shl_prec_assign(u, prec));\n        })],\n    );\n}\n\nfn benchmark_float_shl_prec_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shl_prec_assign({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        float_signed_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec)| {\n            no_out!(n.shl_prec_assign(u, prec));\n        })],\n    );\n}\n\nfn benchmark_float_shl_prec_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shl_prec({}, u64)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shl_prec({}, u64)\", T::NAME),\n                &mut |(n, u, prec)| no_out!(n.shl_prec(u, prec)),\n            ),\n            (\n                &format!(\"Float.shl_prec_ref({}, u64)\", T::NAME),\n                &mut |(n, u, prec)| no_out!(n.shl_prec_ref(u, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shl_prec({}, u64)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shl_prec({}, u64)\", T::NAME),\n                &mut |(n, i, prec)| no_out!(n.shl_prec(i, prec)),\n            ),\n            (\n                &format!(\"Float.shl_prec_ref({}, u64)\", T::NAME),\n                &mut |(n, i, prec)| no_out!(n.shl_prec_ref(i, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shl<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_prec({}, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec)| no_out!(n.shl_prec(u, prec))),\n            (\"naive\", &mut |(n, u, prec)| {\n                no_out!(shl_prec_naive(n, u, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shl<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_prec({}, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec)| no_out!(n.shl_prec(u, prec))),\n            (\"naive\", &mut |(n, u, prec)| {\n                no_out!(shl_prec_naive(n, u, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shl_prec(i32, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, u, prec))| {\n                no_out!(n.shl_prec(u, prec));\n            }),\n            (\"rug\", &mut |((n, u, prec), _)| {\n                no_out!(rug_shl_prec_unsigned(&n, u, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shl_prec(i32, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_signed_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, i, prec))| {\n                no_out!(n.shl_prec(i, prec));\n            }),\n            (\"rug\", &mut |((n, i, prec), _)| {\n                no_out!(rug_shl_prec_signed(&n, i, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"Float.shl_prec_round_assign({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec, rm)| {\n            no_out!(n.shl_prec_round_assign(u, prec, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shl_prec_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"Float.shl_prec_round_assign({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec, rm)| {\n            no_out!(n.shl_prec_round_assign(u, prec, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shl_prec_round_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shl_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shl_prec_round({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, u, prec, rm)| no_out!(n.shl_prec_round(u, prec, rm)),\n            ),\n            (\n                &format!(\"Float.shl_prec_round_ref({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, u, prec, rm)| no_out!(n.shl_prec_round_ref(u, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_round_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shl_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shl_prec_round({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, i, prec, rm)| no_out!(n.shl_prec_round(i, prec, rm)),\n            ),\n            (\n                &format!(\"Float.shl_prec_round_ref({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, i, prec, rm)| no_out!(n.shl_prec_round_ref(i, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_round_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shl<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec, rm)| {\n                no_out!(n.shl_prec_round(u, prec, rm));\n            }),\n            (\"naive\", &mut |(n, u, prec, rm)| {\n                no_out!(shl_prec_round_naive(n, u, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_round_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shl<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec, rm)| {\n                no_out!(n.shl_prec_round(u, prec, rm));\n            }),\n            (\"naive\", &mut |(n, u, prec, rm)| {\n                no_out!(shl_prec_round_naive(n, u, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_round_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shl_prec_round(i32, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, u, prec, rm))| {\n                no_out!(n.shl_prec_round(u, prec, rm));\n            }),\n            (\"rug\", &mut |((n, u, prec, rm), _)| {\n                no_out!(rug_shl_prec_round_unsigned(&n, u, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_prec_round_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shl_prec_round(i32, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, i, prec, rm))| {\n                no_out!(n.shl_prec_round(i, prec, rm));\n            }),\n            (\"rug\", &mut |((n, i, prec, rm), _)| {\n                no_out!(rug_shl_prec_round_signed(&n, i, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlRoundAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        float_unsigned_rounding_mode_triple_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, rm)| {\n            no_out!(n.shl_round_assign(u, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shl_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlRoundAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        float_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, rm)| {\n            no_out!(n.shl_round_assign(u, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shl_round_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlRound<T>,\n    for<'a> &'a Float: ShlRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, u, rm)| no_out!(n.shl_round(u, rm)),\n            ),\n            (\n                &format!(\"(&Float).shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, u, rm)| no_out!((&n).shl_round(u, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shl_round_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlRound<T>,\n    for<'a> &'a Float: ShlRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, i, rm)| no_out!(n.shl_round(i, rm)),\n            ),\n            (\n                &format!(\"(&Float).shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, i, rm)| no_out!((&n).shl_round(i, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shl_round_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlRound<T>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_rounding_mode_triple_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, rm)| no_out!(n.shl_round(u, rm))),\n            (\"naive\", &mut |(n, u, rm)| {\n                no_out!(shl_round_naive(n, u, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_round_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShlRound<T>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shl_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, rm)| no_out!(n.shl_round(u, rm))),\n            (\"naive\", &mut |(n, u, rm)| {\n                no_out!(shl_round_naive(n, u, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_round_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shl_round(i32, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_7_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, u, rm))| {\n                no_out!((&n).shl_round(u, rm));\n            }),\n            (\"rug\", &mut |((n, u, rm), _)| {\n                no_out!(rug_shl_round_unsigned(&n, u, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shl_round_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shl_round(i32, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_signed_rounding_mode_triple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, i, rm))| {\n                no_out!((&n).shl_round(i, rm));\n            }),\n            (\"rug\", &mut |((n, i, rm), _)| {\n                no_out!(rug_shl_round_signed(&n, i, rm));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::shr::shr_naive;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_1_float_complexity_bucketer, pair_2_pair_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen_var_2, float_signed_pair_gen_var_2_rm, float_signed_pair_gen_var_3,\n    float_unsigned_pair_gen_var_2, float_unsigned_pair_gen_var_2_rm, float_unsigned_pair_gen_var_3,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse std::ops::{Shr, ShrAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_shr_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shr_assign_signed);\n    register_signed_demos!(runner, demo_float_shr_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shr_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shr_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shr_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shr_signed);\n    register_signed_demos!(runner, demo_float_shr_signed_debug);\n    register_signed_demos!(runner, demo_float_shr_signed_extreme);\n    register_signed_demos!(runner, demo_float_shr_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shr_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shr_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shr_signed_ref);\n    register_signed_demos!(runner, demo_float_shr_signed_ref_debug);\n\n    register_unsigned_benches!(runner, benchmark_float_shr_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shr_assign_signed);\n    register_unsigned_benches!(runner, benchmark_float_shr_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_float_shr_signed_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_float_shr_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shr_signed_algorithms);\n\n    register_bench!(runner, benchmark_float_shr_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_float_shr_u32_library_comparison);\n    register_bench!(runner, benchmark_float_shr_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_float_shr_i32_library_comparison);\n}\n\nfn demo_float_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrAssign<T>,\n{\n    for (mut n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= u;\n        println!(\"x := {n_old}; x >>= {u}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrAssign<T>,\n{\n    for (mut n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= u;\n        println!(\n            \"x := {:#x}; x >>= {u}; x = {:#x}\",\n            ComparableFloat(n_old),\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: ShrAssign<T>,\n{\n    for (mut n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= i;\n        println!(\"x := {n_old}; x >>= {i}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrAssign<T>,\n{\n    for (mut n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= i;\n        println!(\n            \"x := {:#x}; x >>= {i}; x = {:#x}\",\n            ComparableFloat(n_old),\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shr<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, u, n >> u);\n    }\n}\n\nfn demo_float_shr_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shr<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} >> {} = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            ComparableFloat(n >> u)\n        );\n    }\n}\n\nfn demo_float_shr_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shr<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, u, n >> u);\n    }\n}\n\nfn demo_float_shr_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shr<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} >> {} = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            ComparableFloat(n >> u)\n        );\n    }\n}\n\nfn demo_float_shr_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shr<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, i, n >> i);\n    }\n}\n\nfn demo_float_shr_signed_debug<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shr<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} >> {} = {:#x}\",\n            ComparableFloat(n_old),\n            i,\n            ComparableFloat(n >> i)\n        );\n    }\n}\n\nfn demo_float_shr_signed_extreme<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: Shr<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, i, n >> i);\n    }\n}\n\nfn demo_float_shr_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: Shr<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{:#x} >> {} = {:#x}\",\n            ComparableFloat(n_old),\n            i,\n            ComparableFloat(n >> i)\n        );\n    }\n}\n\nfn demo_float_shr_unsigned_ref<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, u, &n >> u);\n    }\n}\n\nfn demo_float_shr_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    for (n, u) in float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"&{:#x} >> {} = {:#x}\",\n            ComparableFloatRef(&n),\n            u,\n            ComparableFloatRef(&(&n >> u))\n        );\n    }\n}\n\nfn demo_float_shr_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, i, &n >> i);\n    }\n}\n\nfn demo_float_shr_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    for (n, i) in float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"&{:#x} >> {} = {:#x}\",\n            ComparableFloatRef(&n),\n            i,\n            ComparableFloatRef(&(&n >> i))\n        );\n    }\n}\n\nfn benchmark_float_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        float_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n >>= u)],\n    );\n}\n\nfn benchmark_float_shr_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        float_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, i)| n >>= i)],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shr_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shr<T, Output = Float>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Float >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Float >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shr_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shr<T, Output = Float>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Float >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Float >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shr_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shr<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x >> y)),\n            (\"naive\", &mut |(x, y)| no_out!(shr_naive(x, y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_shr_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: Shr<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    run_benchmark(\n        &format!(\"Float >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x >> y)),\n            (\"naive\", &mut |(x, y)| no_out!(shr_naive(x, y))),\n        ],\n    );\n}\n\nfn benchmark_float_shr_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float >>= u32\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_shr_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float >> u32\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n\nfn benchmark_float_shr_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float >>= i32\",\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_shr_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float >> i32\",\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShrRound, ShrRoundAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::shr_round::{\n    rug_shr_prec_round_signed, rug_shr_prec_round_unsigned, rug_shr_prec_signed,\n    rug_shr_prec_unsigned, rug_shr_round_signed, rug_shr_round_unsigned, shr_prec_naive,\n    shr_prec_round_naive, shr_round_naive,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_quadruple_1_float_complexity_bucketer, pair_2_triple_1_float_complexity_bucketer,\n    quadruple_1_float_complexity_bucketer, triple_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_rounding_mode_triple_gen_var_4, float_signed_rounding_mode_triple_gen_var_5,\n    float_signed_rounding_mode_triple_gen_var_6_rm,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_3_rm,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_signed_unsigned_triple_gen_var_1, float_signed_unsigned_triple_gen_var_1_rm,\n    float_signed_unsigned_triple_gen_var_2, float_unsigned_rounding_mode_triple_gen_var_8,\n    float_unsigned_rounding_mode_triple_gen_var_9,\n    float_unsigned_rounding_mode_triple_gen_var_10_rm,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3_rm,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_unsigned_unsigned_triple_gen_var_1, float_unsigned_unsigned_triple_gen_var_1_rm,\n    float_unsigned_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse std::ops::Shr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_shr_prec_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_prec_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_assign_signed);\n    register_signed_demos!(runner, demo_float_shr_prec_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shr_prec_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_prec_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shr_prec_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shr_prec_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_signed);\n    register_signed_demos!(runner, demo_float_shr_prec_signed_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_signed_extreme);\n    register_signed_demos!(runner, demo_float_shr_prec_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shr_prec_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shr_prec_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_signed_ref);\n    register_signed_demos!(runner, demo_float_shr_prec_signed_ref_debug);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_round_assign_signed);\n    register_signed_demos!(runner, demo_float_shr_prec_round_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_round_signed);\n    register_signed_demos!(runner, demo_float_shr_prec_round_signed_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_round_signed_extreme);\n    register_signed_demos!(runner, demo_float_shr_prec_round_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shr_prec_round_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shr_prec_round_signed_ref);\n    register_signed_demos!(runner, demo_float_shr_prec_round_signed_ref_debug);\n    register_unsigned_demos!(runner, demo_float_shr_round_assign_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_round_assign_unsigned_debug);\n    register_signed_demos!(runner, demo_float_shr_round_assign_signed);\n    register_signed_demos!(runner, demo_float_shr_round_assign_signed_debug);\n    register_unsigned_demos!(runner, demo_float_shr_round_unsigned);\n    register_unsigned_demos!(runner, demo_float_shr_round_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_shr_round_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_shr_round_unsigned_extreme_debug);\n    register_signed_demos!(runner, demo_float_shr_round_signed);\n    register_signed_demos!(runner, demo_float_shr_round_signed_debug);\n    register_signed_demos!(runner, demo_float_shr_round_signed_extreme);\n    register_signed_demos!(runner, demo_float_shr_round_signed_extreme_debug);\n    register_unsigned_demos!(runner, demo_float_shr_round_unsigned_ref);\n    register_unsigned_demos!(runner, demo_float_shr_round_unsigned_ref_debug);\n    register_signed_demos!(runner, demo_float_shr_round_signed_ref);\n    register_signed_demos!(runner, demo_float_shr_round_signed_ref_debug);\n\n    register_unsigned_benches!(runner, benchmark_float_shr_prec_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shr_prec_assign_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_shr_prec_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_float_shr_prec_signed_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_float_shr_prec_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shr_prec_signed_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_shr_prec_assign_u32_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_shr_prec_assign_i32_library_comparison\n    );\n    register_unsigned_benches!(runner, benchmark_float_shr_prec_round_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shr_prec_round_assign_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_shr_prec_round_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_float_shr_prec_round_signed_evaluation_strategy\n    );\n    register_unsigned_benches!(runner, benchmark_float_shr_prec_round_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shr_prec_round_signed_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_shr_prec_round_assign_u32_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_shr_prec_round_assign_i32_library_comparison\n    );\n    register_unsigned_benches!(runner, benchmark_float_shr_round_assign_unsigned);\n    register_signed_benches!(runner, benchmark_float_shr_round_assign_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_shr_round_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_float_shr_round_signed_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_float_shr_round_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_float_shr_round_signed_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_shr_round_assign_u32_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_shr_round_assign_i32_library_comparison\n    );\n}\n\nfn demo_float_shr_prec_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_assign(u, prec);\n        println!(\"x := {n_old}; x.shr_prec_assign({u}, {prec}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_prec_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_assign(u, prec);\n        println!(\n            \"x := {:#x}; x.shr_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_prec_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_assign(u, prec);\n        println!(\"x := {n_old}; x.shr_prec_assign({u}, {prec}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_prec_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_assign(u, prec);\n        println!(\n            \"x := {:#x}; x.shr_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_prec_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shr_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shr_prec_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec(u, prec);\n        println!(\n            \"{:#x}.shr_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shr_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shr_prec_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec(u, prec);\n        println!(\n            \"{:#x}.shr_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shr_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shr_prec_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec(u, prec);\n        println!(\n            \"{:#x}.shr_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec({}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            n.shr_prec(u, prec)\n        );\n    }\n}\n\nfn demo_float_shr_prec_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_2::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec(u, prec);\n        println!(\n            \"{:#x}.shr_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shr_prec_ref({}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            n.shr_prec_ref(u, prec)\n        );\n    }\n}\n\nfn demo_float_shr_prec_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_unsigned_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shr_prec_ref(u, prec);\n        println!(\n            \"{:#x}.shr_prec_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shr_prec_ref({}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            n.shr_prec_ref(u, prec)\n        );\n    }\n}\n\nfn demo_float_shr_prec_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec) in float_signed_unsigned_triple_gen_var_1::<T, _>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shr_prec_ref(u, prec);\n        println!(\n            \"{:#x}.shr_prec_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_round_assign(u, prec, rm);\n        println!(\"x := {n_old}; x.shr_prec_round_assign({u}, {prec}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_prec_round_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_round_assign(u, prec, rm);\n        println!(\n            \"x := {:#x}; x.shr_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_round_assign(u, prec, rm);\n        println!(\"x := {n_old}; x.shr_prec_round_assign({u}, {prec}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_prec_round_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_prec_round_assign(u, prec, rm);\n        println!(\n            \"x := {:#x}; x.shr_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shr_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shr_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shr_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shr_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shr_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shr_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_prec_round({}, {}, {}) = {:?}\",\n            n_old,\n            u,\n            prec,\n            rm,\n            n.shr_prec_round(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_prec_round(u, prec, rm);\n        println!(\n            \"{:#x}.shr_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shr_prec_round_ref({}, {}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            rm,\n            n.shr_prec_round_ref(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shr_prec_round_ref(u, prec, rm);\n        println!(\n            \"{:#x}.shr_prec_round_ref({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.shr_prec_round_ref({}, {}, {}) = {:?}\",\n            n,\n            u,\n            prec,\n            rm,\n            n.shr_prec_round_ref(u, prec, rm)\n        );\n    }\n}\n\nfn demo_float_shr_prec_round_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u, prec, rm) in float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = n.shr_prec_round_ref(u, prec, rm);\n        println!(\n            \"{:#x}.shr_prec_round_ref({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n),\n            u,\n            prec,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRoundAssign<T>,\n{\n    for (mut n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_8::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(u, rm);\n        println!(\"x := {n_old}; x.shr_round_assign({u}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_round_assign_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRoundAssign<T>,\n{\n    for (mut n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_8::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(u, rm);\n        println!(\n            \"x := {:#x}; x.shr_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            u,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRoundAssign<T>,\n{\n    for (mut n, i, rm) in float_signed_rounding_mode_triple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(i, rm);\n        println!(\"x := {n_old}; x.shr_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_float_shr_round_assign_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRoundAssign<T>,\n{\n    for (mut n, i, rm) in float_signed_rounding_mode_triple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(i, rm);\n        println!(\n            \"x := {:#x}; x.shr_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(n_old),\n            i,\n            rm,\n            o,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_shr_round_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_8::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            u,\n            rm,\n            n.shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_float_shr_round_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_8::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_round(u, rm);\n        println!(\n            \"{:#x}.shr_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_round_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_9::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            u,\n            rm,\n            n.shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_float_shr_round_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_8::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_round(u, rm);\n        println!(\n            \"{:#x}.shr_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            u,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_round_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shr_round(i, rm)\n        );\n    }\n}\n\nfn demo_float_shr_round_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_round(i, rm);\n        println!(\n            \"{:#x}.shr_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            i,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_round_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shr_round(i, rm)\n        );\n    }\n}\n\nfn demo_float_shr_round_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: ShrRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let (shifted, o) = n.shr_round(i, rm);\n        println!(\n            \"{:#x}.shr_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(n_old),\n            i,\n            rm,\n            ComparableFloat(shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_round_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_8::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shr_round({}, {}) = {:?}\",\n            n,\n            u,\n            rm,\n            (&n).shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_float_shr_round_unsigned_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    for (n, u, rm) in float_unsigned_rounding_mode_triple_gen_var_8::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = (&n).shr_round(u, rm);\n        println!(\n            \"(&{:#x}.shr_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloatRef(&n),\n            u,\n            rm,\n            ComparableFloatRef(&shifted),\n            o\n        );\n    }\n}\n\nfn demo_float_shr_round_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shr_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            (&n).shr_round(i, rm)\n        );\n    }\n}\n\nfn demo_float_shr_round_signed_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    for (n, i, rm) in float_signed_rounding_mode_triple_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (shifted, o) = (&n).shr_round(i, rm);\n        println!(\n            \"(&{:#x}).shr_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloatRef(&n),\n            i,\n            rm,\n            ComparableFloatRef(&shifted),\n            o\n        );\n    }\n}\n\nfn benchmark_float_shr_prec_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shr_prec_assign({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        float_unsigned_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec)| {\n            no_out!(n.shr_prec_assign(u, prec));\n        })],\n    );\n}\n\nfn benchmark_float_shr_prec_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shr_prec_assign({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        float_signed_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec)| {\n            no_out!(n.shr_prec_assign(u, prec));\n        })],\n    );\n}\n\nfn benchmark_float_shr_prec_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shr_prec({}, u64)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shr_prec({}, u64)\", T::NAME),\n                &mut |(n, u, prec)| no_out!(n.shr_prec(u, prec)),\n            ),\n            (\n                &format!(\"Float.shr_prec_ref({}, u64)\", T::NAME),\n                &mut |(n, u, prec)| no_out!(n.shr_prec_ref(u, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shr_prec({}, u64)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shr_prec({}, u64)\", T::NAME),\n                &mut |(n, i, prec)| no_out!(n.shr_prec(i, prec)),\n            ),\n            (\n                &format!(\"Float.shr_prec_ref({}, u64)\", T::NAME),\n                &mut |(n, i, prec)| no_out!(n.shr_prec_ref(i, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shr<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_prec({}, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec)| no_out!(n.shr_prec(u, prec))),\n            (\"naive\", &mut |(n, u, prec)| {\n                no_out!(shr_prec_naive(n, u, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shr<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_prec({}, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_unsigned_triple_gen_var_1::<T, _>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec)| no_out!(n.shr_prec(u, prec))),\n            (\"naive\", &mut |(n, u, prec)| {\n                no_out!(shr_prec_naive(n, u, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shr_prec(i32, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, u, prec))| {\n                no_out!(n.shr_prec(u, prec));\n            }),\n            (\"rug\", &mut |((n, u, prec), _)| {\n                no_out!(rug_shr_prec_unsigned(&n, u, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shr_prec(i32, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_signed_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, i, prec))| {\n                no_out!(n.shr_prec(i, prec));\n            }),\n            (\"rug\", &mut |((n, i, prec), _)| {\n                no_out!(rug_shr_prec_signed(&n, i, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"Float.shr_prec_round_assign({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec, rm)| {\n            no_out!(n.shr_prec_round_assign(u, prec, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shr_prec_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"Float.shr_prec_round_assign({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, prec, rm)| {\n            no_out!(n.shr_prec_round_assign(u, prec, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shr_prec_round_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shr_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shr_prec_round({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, u, prec, rm)| no_out!(n.shr_prec_round(u, prec, rm)),\n            ),\n            (\n                &format!(\"Float.shr_prec_round_ref({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, u, prec, rm)| no_out!(n.shr_prec_round_ref(u, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_round_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"Float.shr_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shr_prec_round({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, i, prec, rm)| no_out!(n.shr_prec_round(i, prec, rm)),\n            ),\n            (\n                &format!(\"Float.shr_prec_round_ref({}, u64, RoundingMode)\", T::NAME),\n                &mut |(n, i, prec, rm)| no_out!(n.shr_prec_round_ref(i, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_round_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shr<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec, rm)| {\n                no_out!(n.shr_prec_round(u, prec, rm));\n            }),\n            (\"naive\", &mut |(n, u, prec, rm)| {\n                no_out!(shr_prec_round_naive(n, u, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_round_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shr<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_prec_round({}, u64, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, prec, rm)| {\n                no_out!(n.shr_prec_round(u, prec, rm));\n            }),\n            (\"naive\", &mut |(n, u, prec, rm)| {\n                no_out!(shr_prec_round_naive(n, u, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_round_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shr_prec_round(i32, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, u, prec, rm))| {\n                no_out!(n.shr_prec_round(u, prec, rm));\n            }),\n            (\"rug\", &mut |((n, u, prec, rm), _)| {\n                no_out!(rug_shr_prec_round_unsigned(&n, u, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_prec_round_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shr_prec_round(i32, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_signed_unsigned_rounding_mode_quadruple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, i, prec, rm))| {\n                no_out!(n.shr_prec_round(i, prec, rm));\n            }),\n            (\"rug\", &mut |((n, i, prec, rm), _)| {\n                no_out!(rug_shr_prec_round_signed(&n, i, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrRoundAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        float_unsigned_rounding_mode_triple_gen_var_8::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, rm)| {\n            no_out!(n.shr_round_assign(u, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shr_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrRoundAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        float_signed_rounding_mode_triple_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u, rm)| {\n            no_out!(n.shr_round_assign(u, rm));\n        })],\n    );\n}\n\nfn benchmark_float_shr_round_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrRound<T>,\n    for<'a> &'a Float: ShrRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_8::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, u, rm)| no_out!(n.shr_round(u, rm)),\n            ),\n            (\n                &format!(\"(&Float).shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, u, rm)| no_out!((&n).shr_round(u, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shr_round_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrRound<T>,\n    for<'a> &'a Float: ShrRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_signed_rounding_mode_triple_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Float.shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, i, rm)| no_out!(n.shr_round(i, rm)),\n            ),\n            (\n                &format!(\"(&Float).shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(n, i, rm)| no_out!((&n).shr_round(i, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_shr_round_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrRound<T>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_rounding_mode_triple_gen_var_8::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, rm)| no_out!(n.shr_round(u, rm))),\n            (\"naive\", &mut |(n, u, rm)| {\n                no_out!(shr_round_naive(n, u, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_round_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: ShrRound<T>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T>,\n{\n    run_benchmark(\n        &format!(\"Float.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_rounding_mode_triple_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u, rm)| no_out!(n.shr_round(u, rm))),\n            (\"naive\", &mut |(n, u, rm)| {\n                no_out!(shr_round_naive(n, u, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_round_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shr_round(i32, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_10_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, u, rm))| {\n                no_out!((&n).shr_round(u, rm));\n            }),\n            (\"rug\", &mut |((n, u, rm), _)| {\n                no_out!(rug_shr_round_unsigned(&n, u, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_shr_round_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.shr_round(i32, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_signed_rounding_mode_triple_gen_var_6_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_float_complexity_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, i, rm))| {\n                no_out!((&n).shr_round(i, rm));\n            }),\n            (\"rug\", &mut |((n, i, rm), _)| {\n                no_out!(rug_shr_round_signed(&n, i, rm));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_gen_var_2, float_gen_var_14};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sign);\n    register_demo!(runner, demo_float_sign_debug);\n    register_demo!(runner, demo_float_sign_extreme);\n    register_demo!(runner, demo_float_sign_extreme_debug);\n\n    register_bench!(runner, benchmark_float_sign);\n}\n\nfn demo_float_sign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_2().get(gm, config).take(limit) {\n        match n.sign() {\n            Less => println!(\"{n} is negative\"),\n            Equal => println!(\"{n} is zero\"),\n            Greater => println!(\"{n} is positive\"),\n        }\n    }\n}\n\nfn demo_float_sign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_2().get(gm, config).take(limit) {\n        match n.sign() {\n            Less => println!(\"{:#x} is negative\", ComparableFloat(n)),\n            Equal => println!(\"{:#x} is zero\", ComparableFloat(n)),\n            Greater => println!(\"{:#x} is positive\", ComparableFloat(n)),\n        }\n    }\n}\n\nfn demo_float_sign_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_14().get(gm, config).take(limit) {\n        match n.sign() {\n            Less => println!(\"{n} is negative\"),\n            Equal => println!(\"{n} is zero\"),\n            Greater => println!(\"{n} is positive\"),\n        }\n    }\n}\n\nfn demo_float_sign_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_14().get(gm, config).take(limit) {\n        match n.sign() {\n            Less => println!(\"{:#x} is negative\", ComparableFloat(n)),\n            Equal => println!(\"{:#x} is zero\", ComparableFloat(n)),\n            Greater => println!(\"{:#x} is positive\", ComparableFloat(n)),\n        }\n    }\n}\n\nfn benchmark_float_sign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.sign()\",\n        BenchmarkType::Single,\n        float_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.sign()))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Sqrt, SqrtAssign};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::arithmetic::sqrt::primitive_float_sqrt_rational;\nuse malachite_float::test_util::arithmetic::sqrt::{\n    rug_sqrt, rug_sqrt_prec, rug_sqrt_prec_round, rug_sqrt_round, sqrt_rational_prec_round_generic,\n    sqrt_rational_prec_round_simple,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer, pair_2_float_complexity_bucketer,\n    pair_2_pair_1_float_complexity_bucketer,\n    pair_2_pair_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer,\n    pair_float_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_rm, float_gen_var_12, float_rounding_mode_pair_gen_var_24,\n    float_rounding_mode_pair_gen_var_24_rm, float_rounding_mode_pair_gen_var_29,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_1_rm, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_13,\n    float_unsigned_rounding_mode_triple_gen_var_13_rm,\n    float_unsigned_rounding_mode_triple_gen_var_14,\n    rational_unsigned_rounding_mode_triple_gen_var_3,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::test_util::bench::bucketers::{\n    pair_rational_bit_u64_max_bucketer, rational_bit_bucketer,\n    triple_1_2_rational_bit_u64_max_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sqrt);\n    register_demo!(runner, demo_float_sqrt_debug);\n    register_demo!(runner, demo_float_sqrt_extreme);\n    register_demo!(runner, demo_float_sqrt_extreme_debug);\n    register_demo!(runner, demo_float_sqrt_ref);\n    register_demo!(runner, demo_float_sqrt_ref_debug);\n    register_demo!(runner, demo_float_sqrt_assign);\n    register_demo!(runner, demo_float_sqrt_assign_debug);\n    register_demo!(runner, demo_float_sqrt_prec);\n    register_demo!(runner, demo_float_sqrt_prec_debug);\n    register_demo!(runner, demo_float_sqrt_prec_extreme);\n    register_demo!(runner, demo_float_sqrt_prec_extreme_debug);\n    register_demo!(runner, demo_float_sqrt_prec_ref);\n    register_demo!(runner, demo_float_sqrt_prec_ref_debug);\n    register_demo!(runner, demo_float_sqrt_prec_assign);\n    register_demo!(runner, demo_float_sqrt_prec_assign_debug);\n    register_demo!(runner, demo_float_sqrt_round);\n    register_demo!(runner, demo_float_sqrt_round_debug);\n    register_demo!(runner, demo_float_sqrt_round_extreme);\n    register_demo!(runner, demo_float_sqrt_round_extreme_debug);\n    register_demo!(runner, demo_float_sqrt_round_ref);\n    register_demo!(runner, demo_float_sqrt_round_ref_debug);\n    register_demo!(runner, demo_float_sqrt_round_assign);\n    register_demo!(runner, demo_float_sqrt_round_assign_debug);\n    register_demo!(runner, demo_float_sqrt_prec_round);\n    register_demo!(runner, demo_float_sqrt_prec_round_debug);\n    register_demo!(runner, demo_float_sqrt_prec_round_extreme);\n    register_demo!(runner, demo_float_sqrt_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_sqrt_prec_round_ref);\n    register_demo!(runner, demo_float_sqrt_prec_round_ref_debug);\n    register_demo!(runner, demo_float_sqrt_prec_round_assign);\n    register_demo!(runner, demo_float_sqrt_prec_round_assign_debug);\n    register_demo!(runner, demo_float_sqrt_rational_prec);\n    register_demo!(runner, demo_float_sqrt_rational_prec_debug);\n    register_demo!(runner, demo_float_sqrt_rational_prec_ref);\n    register_demo!(runner, demo_float_sqrt_rational_prec_ref_debug);\n    register_demo!(runner, demo_float_sqrt_rational_prec_round);\n    register_demo!(runner, demo_float_sqrt_rational_prec_round_debug);\n    register_demo!(runner, demo_float_sqrt_rational_prec_round_ref);\n    register_demo!(runner, demo_float_sqrt_rational_prec_round_ref_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_sqrt_rational);\n\n    register_bench!(runner, benchmark_float_sqrt_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sqrt_library_comparison);\n    register_bench!(runner, benchmark_float_sqrt_assign);\n    register_bench!(runner, benchmark_float_sqrt_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sqrt_prec_library_comparison);\n    register_bench!(runner, benchmark_float_sqrt_prec_assign);\n    register_bench!(runner, benchmark_float_sqrt_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sqrt_round_library_comparison);\n    register_bench!(runner, benchmark_float_sqrt_round_assign);\n    register_bench!(runner, benchmark_float_sqrt_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sqrt_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_sqrt_prec_round_assign);\n    register_bench!(\n        runner,\n        benchmark_float_sqrt_rational_prec_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sqrt_rational_prec_round_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_sqrt_rational_prec_round_algorithms);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_sqrt_rational);\n}\n\nfn demo_float_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).sqrt() = {}\", x_old, x.sqrt());\n    }\n}\n\nfn demo_float_sqrt_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).sqrt() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.sqrt())\n        );\n    }\n}\n\nfn demo_float_sqrt_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).sqrt() = {}\", x_old, x.sqrt());\n    }\n}\n\nfn demo_float_sqrt_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}).sqrt() = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.sqrt())\n        );\n    }\n}\n\nfn demo_float_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).sqrt() = {}\", x, (&x).sqrt());\n    }\n}\n\nfn demo_float_sqrt_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).sqrt() = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat((&x).sqrt())\n        );\n    }\n}\n\nfn demo_float_sqrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.sqrt_assign();\n        println!(\"x := {x_old}; x.sqrt_assign(); x = {x}\");\n    }\n}\n\nfn demo_float_sqrt_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.sqrt_assign();\n        println!(\n            \"x := {:#x}; x.sqrt_assign(); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sqrt_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).sqrt_prec({}) = {:?}\", x_old, prec, x.sqrt_prec(prec));\n    }\n}\n\nfn demo_float_sqrt_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.sqrt_prec(prec);\n        println!(\n            \"({:#x}).sqrt_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).sqrt_prec({}) = {:?}\", x_old, prec, x.sqrt_prec(prec));\n    }\n}\n\nfn demo_float_sqrt_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.sqrt_prec(prec);\n        println!(\n            \"({:#x}).sqrt_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).sqrt_prec_ref({}) = {:?}\",\n            x,\n            prec,\n            x.sqrt_prec_ref(prec)\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (sum, o) = x.sqrt_prec_ref(prec);\n        println!(\n            \"(&{:#x}).sqrt_prec_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.sqrt_prec_assign(prec);\n        println!(\"x := {x_old}; x.sqrt_prec_assign({prec}); x = {x}\");\n    }\n}\n\nfn demo_float_sqrt_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let o = x.sqrt_prec_assign(prec);\n        println!(\n            \"x := {:#x}; x.sqrt_prec_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sqrt_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_24()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\"({}).sqrt_round({}) = {:?}\", x_old, rm, x.sqrt_round(rm));\n    }\n}\n\nfn demo_float_sqrt_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_24()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.sqrt_round(rm);\n        println!(\n            \"({:#x}).sqrt_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_29()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\"({}).sqrt_round({}) = {:?}\", x_old, rm, x.sqrt_round(rm));\n    }\n}\n\nfn demo_float_sqrt_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_29()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.sqrt_round(rm);\n        println!(\n            \"({:#x}).sqrt_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_24()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).sqrt_round_ref({}) = {:?}\",\n            x,\n            rm,\n            x.sqrt_round_ref(rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_24()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.sqrt_round_ref(rm);\n        println!(\n            \"(&{:#x}).sqrt_round_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_24()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.sqrt_round_assign(rm);\n        println!(\"x := {x_old}; x.sqrt_round_assign({rm}); x = {x}\");\n    }\n}\n\nfn demo_float_sqrt_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_24()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sqrt_round_assign(rm);\n        println!(\n            \"x := {:#x}; x.sqrt_round_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sqrt_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.sqrt_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.sqrt_prec_round(prec, rm);\n        println!(\n            \"({:#x}).sqrt_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sqrt_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.sqrt_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.sqrt_prec_round(prec, rm);\n        println!(\n            \"({:#x}).sqrt_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).sqrt_prec_round_ref({}, {}) = {:?}\",\n            x,\n            prec,\n            rm,\n            x.sqrt_prec_round_ref(prec, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.sqrt_prec_round_ref(prec, rm);\n        println!(\n            \"({:#x}).sqrt_prec_round_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sqrt_prec_round_assign(prec, rm);\n        println!(\"x := {x_old}; x.sqrt_prec_round({prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_sqrt_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sqrt_prec_round_assign(prec, rm);\n        println!(\n            \"x := {:#x}; x.sqrt_prec_round({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::sqrt_rational_prec({}, {}) = {:?}\",\n            n.clone(),\n            p,\n            Float::sqrt_rational_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::sqrt_rational_prec(n.clone(), p);\n        println!(\n            \"Float::sqrt_rational_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::sqrt_rational_prec_ref(&{}, {}) = {:?}\",\n            n,\n            p,\n            Float::sqrt_rational_prec_ref(&n, p)\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::sqrt_rational_prec_ref(&n, p);\n        println!(\n            \"Float::sqrt_rational_prec_ref(&{}, {}) = {:x?}\",\n            n,\n            p,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::sqrt_rational_prec_round({}, {}, {:?}) = {:?}\",\n            n.clone(),\n            p,\n            rm,\n            Float::sqrt_rational_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::sqrt_rational_prec_round(n.clone(), p, rm);\n        println!(\n            \"Float::sqrt_rational_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::sqrt_rational_prec_round_ref(&{}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::sqrt_rational_prec_round_ref(&n, p, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_rational_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::sqrt_rational_prec_round_ref(&n, p, rm);\n        println!(\n            \"Float::sqrt_rational_prec_round_ref(&{}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_sqrt_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"primitive_float_sqrt_rational({}) = {:?}\",\n            x,\n            NiceFloat(primitive_float_sqrt_rational::<T>(&x))\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.sqrt()\", &mut |x| no_out!(x.sqrt())),\n            (\"(&Float).sqrt()\", &mut |x| no_out!((&x).sqrt())),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!((&x).sqrt())),\n            (\"rug\", &mut |(x, _)| no_out!(rug_sqrt(&x))),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.sqrt_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.sqrt_assign()\", &mut |mut x| x.sqrt_assign())],\n    );\n}\n\nfn benchmark_float_sqrt_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_prec(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Float.sqrt_prec(u64)\", &mut |(x, prec)| {\n                no_out!(x.sqrt_prec(prec));\n            }),\n            (\"(&Float).sqrt_prec_ref(u64)\", &mut |(x, prec)| {\n                no_out!(x.sqrt_prec_ref(prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec))| {\n                no_out!(x.sqrt_prec_ref(prec));\n            }),\n            (\"rug\", &mut |((x, prec), _)| {\n                no_out!(rug_sqrt_prec(&x, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_prec_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_prec_assign(u64)\",\n        BenchmarkType::Single,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\"Float.sqrt_prec_assign(u64)\", &mut |(mut x, prec)| {\n            no_out!(x.sqrt_prec_assign(prec));\n        })],\n    );\n}\n\nfn benchmark_float_sqrt_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_round(RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_24().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.sqrt_round(RoundingMode)\", &mut |(x, rm)| {\n                no_out!(x.sqrt_round(rm));\n            }),\n            (\"(&Float).sqrt_round_ref(RoundingMode)\", &mut |(x, rm)| {\n                no_out!(x.sqrt_round_ref(rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_round(RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rounding_mode_pair_gen_var_24_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, rm))| {\n                no_out!(x.sqrt_round_ref(rm));\n            }),\n            (\"rug\", &mut |((x, rm), _)| no_out!(rug_sqrt_round(&x, rm))),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_round_assign(RoundingMode)\",\n        BenchmarkType::Single,\n        float_rounding_mode_pair_gen_var_24().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.sqrt_round_assign(RoundingMode)\", &mut |(\n            mut x,\n            rm,\n        )| {\n            no_out!(x.sqrt_round_assign(rm));\n        })],\n    );\n}\n\nfn benchmark_float_sqrt_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_prec_round(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\n                \"Float.sqrt_prec_round(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.sqrt_prec_round(prec, rm)),\n            ),\n            (\n                \"(&Float).sqrt_prec_round_ref(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.sqrt_prec_round_ref(prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_13_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec, rm))| {\n                no_out!(x.sqrt_prec_round_ref(prec, rm));\n            }),\n            (\"rug\", &mut |((x, prec, rm), _)| {\n                no_out!(rug_sqrt_prec_round(&x, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_prec_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sqrt_prec_round_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        float_unsigned_rounding_mode_triple_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\n            \"Float.sqrt_prec_round_assign(u64, RoundingMode)\",\n            &mut |(mut x, prec, rm)| no_out!(x.sqrt_prec_round_assign(prec, rm)),\n        )],\n    );\n}\n\nfn benchmark_float_sqrt_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::sqrt_rational_prec(Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::sqrt_rational_prec(n, prec)),\n            ),\n            (\n                \"Float::sqrt_rational_prec_ref(&Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::sqrt_rational_prec_ref(&n, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::sqrt_rational_prec(Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::sqrt_rational_prec_round(n, prec, rm)),\n            ),\n            (\n                \"Float::sqrt_rational_prec_ref(&Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::sqrt_rational_prec_round_ref(&n, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_rational_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(n, prec, rm)| {\n                no_out!(Float::sqrt_rational_prec_round_ref(&n, prec, rm));\n            }),\n            (\"generic\", &mut |(n, prec, rm)| {\n                no_out!(sqrt_rational_prec_round_generic(&n, prec, rm));\n            }),\n            (\"simple\", &mut |(n, prec, rm)| {\n                no_out!(sqrt_rational_prec_round_simple(&n, prec, rm));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_sqrt_rational<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\n            \"primitive_float_sqrt_rational_prec::<{}>(Rational)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(primitive_float_sqrt_rational::<T>(&x));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Square, SquareAssign};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::square::{\n    rug_square, rug_square_prec, rug_square_prec_round, rug_square_round, square_prec_round_naive,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer, pair_2_float_complexity_bucketer,\n    pair_2_pair_1_float_complexity_bucketer,\n    pair_2_pair_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer,\n    pair_float_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_rm, float_gen_var_12, float_rounding_mode_pair_gen_var_7,\n    float_rounding_mode_pair_gen_var_7_rm, float_rounding_mode_pair_gen_var_22,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_1_rm, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_2,\n    float_unsigned_rounding_mode_triple_gen_var_2_rm,\n    float_unsigned_rounding_mode_triple_gen_var_11,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_square);\n    register_demo!(runner, demo_float_square_debug);\n    register_demo!(runner, demo_float_square_extreme);\n    register_demo!(runner, demo_float_square_extreme_debug);\n    register_demo!(runner, demo_float_square_ref);\n    register_demo!(runner, demo_float_square_ref_debug);\n    register_demo!(runner, demo_float_square_assign);\n    register_demo!(runner, demo_float_square_assign_debug);\n    register_demo!(runner, demo_float_square_prec);\n    register_demo!(runner, demo_float_square_prec_debug);\n    register_demo!(runner, demo_float_square_prec_extreme);\n    register_demo!(runner, demo_float_square_prec_extreme_debug);\n    register_demo!(runner, demo_float_square_prec_ref);\n    register_demo!(runner, demo_float_square_prec_ref_debug);\n    register_demo!(runner, demo_float_square_prec_assign);\n    register_demo!(runner, demo_float_square_prec_assign_debug);\n    register_demo!(runner, demo_float_square_round);\n    register_demo!(runner, demo_float_square_round_debug);\n    register_demo!(runner, demo_float_square_round_extreme);\n    register_demo!(runner, demo_float_square_round_extreme_debug);\n    register_demo!(runner, demo_float_square_round_ref);\n    register_demo!(runner, demo_float_square_round_ref_debug);\n    register_demo!(runner, demo_float_square_round_assign);\n    register_demo!(runner, demo_float_square_round_assign_debug);\n    register_demo!(runner, demo_float_square_prec_round);\n    register_demo!(runner, demo_float_square_prec_round_debug);\n    register_demo!(runner, demo_float_square_prec_round_extreme);\n    register_demo!(runner, demo_float_square_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_square_prec_round_ref);\n    register_demo!(runner, demo_float_square_prec_round_ref_debug);\n    register_demo!(runner, demo_float_square_prec_round_assign);\n    register_demo!(runner, demo_float_square_prec_round_assign_debug);\n\n    register_bench!(runner, benchmark_float_square_evaluation_strategy);\n    register_bench!(runner, benchmark_float_square_library_comparison);\n    register_bench!(runner, benchmark_float_square_algorithms);\n    register_bench!(runner, benchmark_float_square_assign);\n    register_bench!(runner, benchmark_float_square_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_square_prec_library_comparison);\n    register_bench!(runner, benchmark_float_square_prec_algorithms);\n    register_bench!(runner, benchmark_float_square_prec_assign);\n    register_bench!(runner, benchmark_float_square_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_square_round_library_comparison);\n    register_bench!(runner, benchmark_float_square_round_algorithms);\n    register_bench!(runner, benchmark_float_square_round_assign);\n    register_bench!(\n        runner,\n        benchmark_float_square_prec_round_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_square_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_square_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_square_prec_round_assign);\n}\n\nfn demo_float_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}) ^ 2 = {}\", x_old, x.square());\n    }\n}\n\nfn demo_float_square_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}) ^ 2 = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.square())\n        );\n    }\n}\n\nfn demo_float_square_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}) ^ 2 = {}\", x_old, x.square());\n    }\n}\n\nfn demo_float_square_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({:#x}) ^ 2 = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x.square())\n        );\n    }\n}\n\nfn demo_float_square_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"(&{}) ^ 2 = {}\", x, (&x).square());\n    }\n}\n\nfn demo_float_square_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}) ^ 2 = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat((&x).square())\n        );\n    }\n}\n\nfn demo_float_square_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.square_assign();\n        println!(\"x := {x_old}; x ^= 2; x = {x}\");\n    }\n}\n\nfn demo_float_square_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.square_assign();\n        println!(\n            \"x := {:#x}; x ^= 2; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_square_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({}).square_prec({}) = {:?}\",\n            x_old,\n            prec,\n            x.square_prec(prec)\n        );\n    }\n}\n\nfn demo_float_square_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.square_prec(prec);\n        println!(\n            \"({:#x}).square_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({}).square_prec({}) = {:?}\",\n            x_old,\n            prec,\n            x.square_prec(prec)\n        );\n    }\n}\n\nfn demo_float_square_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let (sum, o) = x.square_prec(prec);\n        println!(\n            \"({:#x}).square_prec({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).square_prec_ref({}) = {:?}\",\n            x,\n            prec,\n            x.square_prec_ref(prec)\n        );\n    }\n}\n\nfn demo_float_square_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (sum, o) = x.square_prec_ref(prec);\n        println!(\n            \"(&{:#x}).square_prec_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.square_prec_assign(prec);\n        println!(\"x := {x_old}; x.square_prec_assign({prec}); x = {x}\");\n    }\n}\n\nfn demo_float_square_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let o = x.square_prec_assign(prec);\n        println!(\n            \"x := {:#x}; x.square_prec_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_square_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).square_round({}) = {:?}\",\n            x_old,\n            rm,\n            x.square_round(rm)\n        );\n    }\n}\n\nfn demo_float_square_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.square_round(rm);\n        println!(\n            \"({:#x}).square_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).square_round({}) = {:?}\",\n            x_old,\n            rm,\n            x.square_round(rm)\n        );\n    }\n}\n\nfn demo_float_square_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.square_round(rm);\n        println!(\n            \"({:#x}).square_round({}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).square_round_ref({}) = {:?}\",\n            x,\n            rm,\n            x.square_round_ref(rm)\n        );\n    }\n}\n\nfn demo_float_square_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in float_rounding_mode_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.square_round_ref(rm);\n        println!(\n            \"(&{:#x}).square_round_ref({}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.square_round_assign(rm);\n        println!(\"x := {x_old}; x.square_round_assign({rm}); x = {x}\");\n    }\n}\n\nfn demo_float_square_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, rm) in float_rounding_mode_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.square_round_assign(rm);\n        println!(\n            \"x := {:#x}; x.square_round_assign({}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_square_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).square_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.square_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_square_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.square_prec_round(prec, rm);\n        println!(\n            \"({:#x}).square_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).square_prec_round({}, {}) = {:?}\",\n            x_old,\n            prec,\n            rm,\n            x.square_prec_round(prec, rm)\n        );\n    }\n}\n\nfn demo_float_square_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (sum, o) = x.square_prec_round(prec, rm);\n        println!(\n            \"({:#x}).square_prec_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).square_prec_round_ref({}, {}) = {:?}\",\n            x,\n            prec,\n            rm,\n            x.square_prec_round_ref(prec, rm)\n        );\n    }\n}\n\nfn demo_float_square_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (sum, o) = x.square_prec_round_ref(prec, rm);\n        println!(\n            \"({:#x}).square_prec_round_ref({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            prec,\n            rm,\n            ComparableFloat(sum),\n            o\n        );\n    }\n}\n\nfn demo_float_square_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.square_prec_round_assign(prec, rm);\n        println!(\"x := {x_old}; x.square_prec_round({prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_square_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.square_prec_round_assign(prec, rm);\n        println!(\n            \"x := {:#x}; x.square_prec_round({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_square_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.square()\", &mut |x| no_out!(x.square())),\n            (\"(&Float).square()\", &mut |x| no_out!((&x).square())),\n        ],\n    );\n}\n\nfn benchmark_float_square_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!((&x).square())),\n            (\"rug\", &mut |(x, _)| no_out!(rug_square(&x))),\n        ],\n    );\n}\n\nfn benchmark_float_square_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square()\",\n        BenchmarkType::Algorithms,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.square())),\n            (\"naive\", &mut |x| {\n                let xsb = x.significant_bits();\n                no_out!(square_prec_round_naive(x, xsb, Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.square_assign()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.square_assign()\", &mut |mut x| x.square_assign())],\n    );\n}\n\nfn benchmark_float_square_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Float.square_prec(u64)\", &mut |(x, prec)| {\n                no_out!(x.square_prec(prec));\n            }),\n            (\"(&Float).square_prec_ref(u64)\", &mut |(x, prec)| {\n                no_out!(x.square_prec_ref(prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec))| {\n                no_out!(x.square_prec_ref(prec));\n            }),\n            (\"rug\", &mut |((x, prec), _)| {\n                no_out!(rug_square_prec(&x, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec(u64)\",\n        BenchmarkType::Algorithms,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, prec)| no_out!(x.square_prec(prec))),\n            (\"naive\", &mut |(x, prec)| {\n                no_out!(square_prec_round_naive(x, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_prec_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec_assign(u64)\",\n        BenchmarkType::Single,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\"Float.square_prec_assign(u64)\", &mut |(mut x, prec)| {\n            no_out!(x.square_prec_assign(prec));\n        })],\n    );\n}\n\nfn benchmark_float_square_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_round(RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.square_round(RoundingMode)\", &mut |(x, rm)| {\n                no_out!(x.square_round(rm));\n            }),\n            (\"(&Float).square_round_ref(RoundingMode)\", &mut |(x, rm)| {\n                no_out!(x.square_round_ref(rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_round(RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rounding_mode_pair_gen_var_7_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, rm))| {\n                no_out!(x.square_round_ref(rm));\n            }),\n            (\"rug\", &mut |((x, rm), _)| no_out!(rug_square_round(&x, rm))),\n        ],\n    );\n}\n\nfn benchmark_float_square_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_round(RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rounding_mode_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, rm)| no_out!(x.square_round(rm))),\n            (\"naive\", &mut |(x, rm)| {\n                let xsb = x.significant_bits();\n                square_prec_round_naive(x, xsb, rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_round_assign(RoundingMode)\",\n        BenchmarkType::Single,\n        float_rounding_mode_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\"Float.square_round_assign(RoundingMode)\", &mut |(\n            mut x,\n            rm,\n        )| {\n            no_out!(x.square_round_assign(rm));\n        })],\n    );\n}\n\nfn benchmark_float_square_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec_round(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\n                \"Float.square_prec_round(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.square_prec_round(prec, rm)),\n            ),\n            (\n                \"(&Float).square_prec_round_ref(u64, RoundingMode)\",\n                &mut |(x, prec, rm)| no_out!(x.square_prec_round_ref(prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_square_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_2_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, prec, rm))| {\n                no_out!(x.square_prec_round_ref(prec, rm));\n            }),\n            (\"rug\", &mut |((x, prec, rm), _)| {\n                no_out!(rug_square_prec_round(&x, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, prec, rm)| {\n                no_out!(x.square_prec_round(prec, rm));\n            }),\n            (\"naive\", &mut |(x, prec, rm)| {\n                no_out!(square_prec_round_naive(x, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_square_prec_round_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.square_prec_round_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        float_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_primitive_int_max_complexity_bucketer(\"x\", \"prec\"),\n        &mut [(\n            \"Float.square_prec_round_assign(u64, RoundingMode)\",\n            &mut |(mut x, prec, rm)| no_out!(x.square_prec_round_assign(prec, rm)),\n        )],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::arithmetic::add::add_prec_round_naive;\nuse malachite_float::test_util::arithmetic::sub::sub_rational_prec_round_naive;\nuse malachite_float::test_util::arithmetic::sub::{\n    rug_sub, rug_sub_prec, rug_sub_prec_round, rug_sub_rational, rug_sub_rational_prec,\n    rug_sub_rational_prec_round, rug_sub_rational_round, rug_sub_round,\n};\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer, pair_2_pair_float_rational_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    pair_2_triple_1_2_float_max_complexity_bucketer,\n    pair_2_triple_1_2_float_rational_max_complexity_bucketer,\n    pair_2_triple_float_float_primitive_int_max_complexity_bucketer,\n    pair_2_triple_float_rational_primitive_int_max_complexity_bucketer,\n    pair_float_max_complexity_bucketer, pair_float_rational_max_complexity_bucketer,\n    quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer,\n    quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer,\n    triple_1_2_float_max_complexity_bucketer, triple_1_2_float_rational_max_complexity_bucketer,\n    triple_float_float_primitive_int_max_complexity_bucketer,\n    triple_float_rational_primitive_int_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_1_rm, float_float_rounding_mode_triple_gen_var_2,\n    float_float_rounding_mode_triple_gen_var_30,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_2_rm,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_6, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_1_rm, float_float_unsigned_triple_gen_var_2,\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10, float_rational_pair_gen,\n    float_rational_pair_gen_rm, float_rational_pair_gen_var_2,\n    float_rational_rounding_mode_triple_gen_var_2,\n    float_rational_rounding_mode_triple_gen_var_3_rm,\n    float_rational_rounding_mode_triple_gen_var_8,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_2_rm,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_7,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_1_rm,\n    float_rational_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse std::cmp::max;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sub);\n    register_demo!(runner, demo_float_sub_debug);\n    register_demo!(runner, demo_float_sub_extreme);\n    register_demo!(runner, demo_float_sub_extreme_debug);\n    register_demo!(runner, demo_float_sub_val_ref);\n    register_demo!(runner, demo_float_sub_val_ref_debug);\n    register_demo!(runner, demo_float_sub_ref_val);\n    register_demo!(runner, demo_float_sub_ref_val_debug);\n    register_demo!(runner, demo_float_sub_ref_ref);\n    register_demo!(runner, demo_float_sub_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_assign);\n    register_demo!(runner, demo_float_sub_assign_debug);\n    register_demo!(runner, demo_float_sub_assign_ref);\n    register_demo!(runner, demo_float_sub_assign_ref_debug);\n    register_demo!(runner, demo_float_sub_prec);\n    register_demo!(runner, demo_float_sub_prec_debug);\n    register_demo!(runner, demo_float_sub_prec_extreme);\n    register_demo!(runner, demo_float_sub_prec_extreme_debug);\n    register_demo!(runner, demo_float_sub_prec_val_ref);\n    register_demo!(runner, demo_float_sub_prec_val_ref_debug);\n    register_demo!(runner, demo_float_sub_prec_ref_val);\n    register_demo!(runner, demo_float_sub_prec_ref_val_debug);\n    register_demo!(runner, demo_float_sub_prec_ref_ref);\n    register_demo!(runner, demo_float_sub_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_prec_assign);\n    register_demo!(runner, demo_float_sub_prec_assign_debug);\n    register_demo!(runner, demo_float_sub_prec_assign_ref);\n    register_demo!(runner, demo_float_sub_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_sub_round);\n    register_demo!(runner, demo_float_sub_round_debug);\n    register_demo!(runner, demo_float_sub_round_extreme);\n    register_demo!(runner, demo_float_sub_round_extreme_debug);\n    register_demo!(runner, demo_float_sub_round_val_ref);\n    register_demo!(runner, demo_float_sub_round_val_ref_debug);\n    register_demo!(runner, demo_float_sub_round_ref_val);\n    register_demo!(runner, demo_float_sub_round_ref_val_debug);\n    register_demo!(runner, demo_float_sub_round_ref_ref);\n    register_demo!(runner, demo_float_sub_round_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_round_assign);\n    register_demo!(runner, demo_float_sub_round_assign_debug);\n    register_demo!(runner, demo_float_sub_round_assign_ref);\n    register_demo!(runner, demo_float_sub_round_assign_ref_debug);\n    register_demo!(runner, demo_float_sub_prec_round);\n    register_demo!(runner, demo_float_sub_prec_round_debug);\n    register_demo!(runner, demo_float_sub_prec_round_extreme);\n    register_demo!(runner, demo_float_sub_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_sub_prec_round_val_ref);\n    register_demo!(runner, demo_float_sub_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_sub_prec_round_ref_val);\n    register_demo!(runner, demo_float_sub_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_sub_prec_round_ref_ref);\n    register_demo!(runner, demo_float_sub_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_prec_round_assign);\n    register_demo!(runner, demo_float_sub_prec_round_assign_debug);\n    register_demo!(runner, demo_float_sub_prec_round_assign_ref);\n    register_demo!(runner, demo_float_sub_prec_round_assign_ref_debug);\n    register_demo!(runner, demo_float_sub_rational);\n    register_demo!(runner, demo_float_sub_rational_debug);\n    register_demo!(runner, demo_float_sub_rational_extreme);\n    register_demo!(runner, demo_float_sub_rational_extreme_debug);\n    register_demo!(runner, demo_float_sub_rational_val_ref);\n    register_demo!(runner, demo_float_sub_rational_val_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_ref_val);\n    register_demo!(runner, demo_float_sub_rational_ref_val_debug);\n    register_demo!(runner, demo_float_sub_rational_ref_ref);\n    register_demo!(runner, demo_float_sub_rational_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_assign);\n    register_demo!(runner, demo_float_sub_rational_assign_debug);\n    register_demo!(runner, demo_float_sub_rational_assign_ref);\n    register_demo!(runner, demo_float_sub_rational_assign_ref_debug);\n    register_demo!(runner, demo_rational_sub_float);\n    register_demo!(runner, demo_rational_sub_float_debug);\n    register_demo!(runner, demo_rational_sub_float_extreme);\n    register_demo!(runner, demo_rational_sub_float_extreme_debug);\n    register_demo!(runner, demo_rational_sub_float_val_ref);\n    register_demo!(runner, demo_rational_sub_float_val_ref_debug);\n    register_demo!(runner, demo_rational_sub_float_ref_val);\n    register_demo!(runner, demo_rational_sub_float_ref_val_debug);\n    register_demo!(runner, demo_rational_sub_float_ref_ref);\n    register_demo!(runner, demo_rational_sub_float_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_prec);\n    register_demo!(runner, demo_float_sub_rational_prec_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_extreme);\n    register_demo!(runner, demo_float_sub_rational_prec_extreme_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_val_ref);\n    register_demo!(runner, demo_float_sub_rational_prec_val_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_ref_val);\n    register_demo!(runner, demo_float_sub_rational_prec_ref_val_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_ref_ref);\n    register_demo!(runner, demo_float_sub_rational_prec_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_assign);\n    register_demo!(runner, demo_float_sub_rational_prec_assign_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_assign_ref);\n    register_demo!(runner, demo_float_sub_rational_prec_assign_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_round);\n    register_demo!(runner, demo_float_sub_rational_round_debug);\n    register_demo!(runner, demo_float_sub_rational_round_extreme);\n    register_demo!(runner, demo_float_sub_rational_round_extreme_debug);\n    register_demo!(runner, demo_float_sub_rational_round_val_ref);\n    register_demo!(runner, demo_float_sub_rational_round_val_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_round_ref_val);\n    register_demo!(runner, demo_float_sub_rational_round_ref_val_debug);\n    register_demo!(runner, demo_float_sub_rational_round_ref_ref);\n    register_demo!(runner, demo_float_sub_rational_round_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_round_assign);\n    register_demo!(runner, demo_float_sub_rational_round_assign_debug);\n    register_demo!(runner, demo_float_sub_rational_round_assign_ref);\n    register_demo!(runner, demo_float_sub_rational_round_assign_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_round);\n    register_demo!(runner, demo_float_sub_rational_prec_round_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_round_extreme);\n    register_demo!(runner, demo_float_sub_rational_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_round_val_ref);\n    register_demo!(runner, demo_float_sub_rational_prec_round_val_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_round_ref_val);\n    register_demo!(runner, demo_float_sub_rational_prec_round_ref_val_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_round_ref_ref);\n    register_demo!(runner, demo_float_sub_rational_prec_round_ref_ref_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_round_assign);\n    register_demo!(runner, demo_float_sub_rational_prec_round_assign_debug);\n    register_demo!(runner, demo_float_sub_rational_prec_round_assign_ref);\n    register_demo!(runner, demo_float_sub_rational_prec_round_assign_ref_debug);\n\n    register_bench!(runner, benchmark_float_sub_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_library_comparison);\n    register_bench!(runner, benchmark_float_sub_algorithms);\n    register_bench!(runner, benchmark_float_sub_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_prec_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_prec_library_comparison);\n    register_bench!(runner, benchmark_float_sub_prec_algorithms);\n    register_bench!(runner, benchmark_float_sub_prec_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_round_library_comparison);\n    register_bench!(runner, benchmark_float_sub_round_algorithms);\n    register_bench!(runner, benchmark_float_sub_round_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_sub_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_sub_prec_round_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_sub_rational_evaluation_strategy);\n    register_bench!(runner, benchmark_float_sub_rational_library_comparison);\n    register_bench!(runner, benchmark_float_sub_rational_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_sub_float_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_sub_float_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_prec_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_sub_rational_prec_library_comparison);\n    register_bench!(runner, benchmark_float_sub_rational_prec_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_prec_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_sub_rational_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_round_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_sub_rational_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_sub_rational_prec_round_assign_evaluation_strategy\n    );\n}\n\nfn demo_float_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_float_sub_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} - {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x - y)\n        );\n    }\n}\n\nfn demo_float_sub_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_float_sub_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} - {:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            ComparableFloat(x - y)\n        );\n    }\n}\n\nfn demo_float_sub_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} - &{} = {}\", x_old, y, x - &y);\n    }\n}\n\nfn demo_float_sub_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} - &{:#x} = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloatRef(&y),\n            ComparableFloat(x - &y)\n        );\n    }\n}\n\nfn demo_float_sub_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} - {} = {}\", x, y_old, &x - y);\n    }\n}\n\nfn demo_float_sub_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} - {:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloat(y_old),\n            ComparableFloat(&x - y)\n        );\n    }\n}\n\nfn demo_float_sub_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} - &{} = {}\", x, y, &x - &y);\n    }\n}\n\nfn demo_float_sub_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} - &{:#x} = {:#x}\",\n            ComparableFloatRef(&x),\n            ComparableFloatRef(&y),\n            ComparableFloat(&x - &y)\n        );\n    }\n}\n\nfn demo_float_sub_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\"x := {x_old}; x += {y}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\n            \"x := {:#x}; x += {:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\"x := {x_old}; x += &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\n            \"x := {:#x}; x += &{:#x}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.sub_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_prec(y, prec);\n        println!(\n            \"({:#x}).sub_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.sub_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_prec(y, prec);\n        println!(\n            \"({:#x}).sub_prec({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sub_prec_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.sub_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (diff, o) = x.sub_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).sub_prec_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).sub_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.sub_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (diff, o) = x.sub_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).sub_prec_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).sub_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.sub_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (diff, o) = x.sub_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).sub_prec_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.sub_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.sub_prec_assign({y_old}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_sub_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.sub_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.sub_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.sub_prec_assign({y}, {prec}); x = {x}\");\n    }\n}\n\nfn demo_float_sub_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_float_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.sub_prec_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.sub_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_round(y, rm);\n        println!(\n            \"({:#x}).sub_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.sub_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_round(y, rm);\n        println!(\n            \"({:#x}).sub_round({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sub_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.sub_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (diff, o) = x.sub_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).sub_round_val_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).sub_round_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.sub_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (diff, o) = x.sub_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).sub_round_ref_val({:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).sub_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.sub_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (diff, o) = x.sub_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).sub_round_ref_ref(&{:#x}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.sub_round_assign(y, rm);\n        println!(\"x := {x_old}; x.sub_round_assign({y_old}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_sub_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.sub_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.sub_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.sub_round_assign({y}, {rm}); x = {x}\");\n    }\n}\n\nfn demo_float_sub_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_float_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.sub_round_assign({:#x}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.sub_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).sub_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.sub_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).sub_prec_round({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sub_prec_round(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.sub_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (diff, o) = x.sub_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).sub_prec_round_val_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).sub_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.sub_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (diff, o) = x.sub_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).sub_prec_round_ref_val({:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).sub_prec_round({}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.sub_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (diff, o) = x.sub_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).sub_prec_round_ref_ref(&{:#x}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            ComparableFloat(y),\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_prec_round_assign(y, prec, rm);\n        println!(\"x := {x_old}; x.sub_prec_round({y_old}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.sub_prec_round({:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y_old),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_prec_round_assign_ref(&y, prec, rm);\n        println!(\"x := {x_old}; x.sub_prec_round_ref(&{y}, {prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_prec_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.sub_prec_round_ref(&{:#x}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_float_sub_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} - {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x - y)\n        );\n    }\n}\n\nfn demo_float_sub_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_float_sub_rational_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{:#x} - {} = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            ComparableFloat(x - y)\n        );\n    }\n}\n\nfn demo_float_sub_rational_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} - &{} = {}\", x_old, y, x - &y);\n    }\n}\n\nfn demo_float_sub_rational_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{:#x} - {} = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x - &y)\n        );\n    }\n}\n\nfn demo_float_sub_rational_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} - {} = {}\", x, y_old, &x - y);\n    }\n}\n\nfn demo_float_sub_rational_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{:#x} - {} = {:#x}\",\n            ComparableFloatRef(&x),\n            y_old,\n            ComparableFloat(&x - y)\n        );\n    }\n}\n\nfn demo_float_sub_rational_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} - &{} = {}\", x, y, &x - &y);\n    }\n}\n\nfn demo_float_sub_rational_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{:#x} - &{} = {:#x}\",\n            ComparableFloatRef(&x),\n            y,\n            ComparableFloat(&x - &y)\n        );\n    }\n}\n\nfn demo_float_sub_rational_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\"x := {x_old}; x += {y}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_rational_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\n            \"x := {:#x}; x += {}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_rational_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\"x := {x_old}; x += &{y}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_rational_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\n            \"x := {:#x}; x += &{}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_rational_sub_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_rational_sub_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} - {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x - y)\n        );\n    }\n}\n\nfn demo_rational_sub_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_rational_sub_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} - {:#x} = {:#x}\",\n            x_old,\n            ComparableFloat(y_old),\n            ComparableFloat(x - y)\n        );\n    }\n}\n\nfn demo_rational_sub_float_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} - &{} = {}\", x_old, y, x - &y);\n    }\n}\n\nfn demo_rational_sub_float_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{} - &{:#x} = {:#x}\",\n            x_old,\n            ComparableFloatRef(&y),\n            ComparableFloat(x - &y)\n        );\n    }\n}\n\nfn demo_rational_sub_float_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} - {} = {}\", x, y_old, &x - y);\n    }\n}\n\nfn demo_rational_sub_float_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"&{} - {:#x} = {:#x}\",\n            x,\n            ComparableFloat(y_old),\n            ComparableFloat(&x - y)\n        );\n    }\n}\n\nfn demo_rational_sub_float_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} - &{} = {}\", x, y, &x - &y);\n    }\n}\n\nfn demo_rational_sub_float_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"&{} - &{:#x} = {:#x}\",\n            x,\n            ComparableFloatRef(&y),\n            ComparableFloat(&x - &y)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.sub_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_prec(y, prec);\n        println!(\n            \"({:#x}).sub_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_rational_prec({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            x.sub_rational_prec(y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_prec(y, prec);\n        println!(\n            \"({:#x}).sub_rational_prec({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sub_rational_prec({}, &{}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            x.sub_rational_prec_val_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (diff, o) = x.sub_rational_prec_val_ref(&y, prec);\n        println!(\n            \"({:#x}).sub_rational_prec_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).sub_rational_prec_ref_val({}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            x.sub_rational_prec_ref_val(y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_prec_ref_val(y, prec);\n        println!(\n            \"(&{:#x}).sub_rational_prec_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).sub_rational_prec_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            x.sub_rational_prec_ref_ref(&y, prec)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (diff, o) = x.sub_rational_prec_ref_ref(&y, prec);\n        println!(\n            \"(&{:#x}).sub_rational_prec_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_rational_prec_assign(y, prec);\n        println!(\"x := {x_old}; x.sub_rational_prec_assign({y_old}, {prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_rational_prec_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_rational_prec_assign(y, prec);\n        println!(\n            \"x := {:#x}; x.sub_rational_prec_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_rational_prec_assign_ref(&y, prec);\n        println!(\"x := {x_old}; x.sub_rational_prec_assign_ref({y}, &{prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_rational_prec_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec) in float_rational_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_rational_prec_assign_ref(&y, prec);\n        println!(\n            \"x := {:#x}; x.sub_rational_prec_assign(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_rational_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.sub_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_round(y, rm);\n        println!(\n            \"({:#x}).sub_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_rational_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.sub_rational_round(y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_round(y, rm);\n        println!(\n            \"({:#x}).sub_rational_round({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sub_rational_round_val_ref(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.sub_rational_round_val_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (diff, o) = x.sub_rational_round_val_ref(&y, rm);\n        println!(\n            \"({:#x}).sub_rational_round_val_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).sub_rational_round_ref_val(&{}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            x.sub_rational_round_ref_val(y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_round_ref_val(y, rm);\n        println!(\n            \"(&{:#x}).sub_rational_round_ref_val({}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).sub_rational_round_ref_ref(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            x.sub_rational_round_ref_ref(&y, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (diff, o) = x.sub_rational_round_ref_ref(&y, rm);\n        println!(\n            \"(&{:#x}).sub_rational_round_ref_ref(&{}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_rational_round_assign(y, rm);\n        println!(\"x := {x_old}; x.sub_rational_round_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_rational_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_rational_round_assign(y, rm);\n        println!(\n            \"x := {:#x}; x.sub_rational_round_assign({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_rational_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_rational_round_assign_ref(&y, rm);\n        println!(\"x := {x_old}; x.sub_rational_round_assign_ref(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_sub_rational_round_assign_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in float_rational_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_rational_round_assign_ref(&y, rm);\n        println!(\n            \"x := {:#x}; x.sub_rational_round_assign_ref(&{}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.sub_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).sub_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).sub_rational_prec_round({}, {}, {}) = {:?}\",\n            x_old,\n            y_old,\n            prec,\n            rm,\n            x.sub_rational_prec_round(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_prec_round(y, prec, rm);\n        println!(\n            \"({:#x}).sub_rational_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).sub_rational_prec_round_val_ref(&{}, {}, {}) = {:?}\",\n            x_old,\n            y,\n            prec,\n            rm,\n            x.sub_rational_prec_round_val_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_val_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let (diff, o) = x.sub_rational_prec_round_val_ref(&y, prec, rm);\n        println!(\n            \"({:#x}).sub_rational_prec_round_val_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).sub_rational_prec_round_ref_val({}, {}, {}) = {:?}\",\n            x,\n            y_old,\n            prec,\n            rm,\n            x.sub_rational_prec_round_ref_val(y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_ref_val_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let (diff, o) = x.sub_rational_prec_round_ref_val(y, prec, rm);\n        println!(\n            \"(&{:#x}).sub_rational_prec_round_ref_val({}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y_old,\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).sub_rational_prec_round_ref_ref(&{}, {}, {}) = {:?}\",\n            x,\n            y,\n            prec,\n            rm,\n            x.sub_rational_prec_round_ref_ref(&y, prec, rm)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_ref_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (diff, o) = x.sub_rational_prec_round_ref_ref(&y, prec, rm);\n        println!(\n            \"(&{:#x}).sub_rational_prec_round_ref_ref(&{}, {}, {}) = ({:#x}, {:?})\",\n            ComparableFloat(x),\n            y,\n            prec,\n            rm,\n            ComparableFloat(diff),\n            o\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {x_old}; x.sub_rational_prec_round_assign({y_old}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_assign_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.sub_rational_prec_round_assign(y, prec, rm);\n        println!(\n            \"x := {:#x}; x.sub_rational_prec_round_assign({}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y_old,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {x_old}; x.sub_rational_prec_round_assign_ref(&{y}, {prec}, {rm}) = {o:?}; \\\n            x = {x}\",\n        );\n    }\n}\n\nfn demo_float_sub_rational_prec_round_assign_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut x, y, prec, rm) in float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.sub_rational_prec_round_assign_ref(&y, prec, rm);\n        println!(\n            \"x := {:#x}; x.sub_rational_prec_round_assign_ref(&{}, {}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(x_old),\n            y,\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float - Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float - Float\", &mut |(x, y)| no_out!(x - y)),\n            (\"Float - &Float\", &mut |(x, y)| no_out!(x - &y)),\n            (\"&Float - Float\", &mut |(x, y)| no_out!(&x - y)),\n            (\"&Float - &Float\", &mut |(x, y)| no_out!(&x - &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_sub_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float - Float\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x - &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_sub(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_sub_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float - Float\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x - y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(add_prec_round_naive(x, -y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float -= Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float -= Float\", &mut |(mut x, y)| x -= y),\n            (\"Float -= &Float\", &mut |(mut x, y)| x -= &y),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.sub_prec(Float, u64)\", &mut |(x, y, prec)| {\n                no_out!(x.sub_prec(y, prec));\n            }),\n            (\"Float.sub_prec_val_ref(&Float, u64)\", &mut |(\n                x,\n                y,\n                prec,\n            )| {\n                no_out!(x.sub_prec_val_ref(&y, prec));\n            }),\n            (\n                \"(&Float).sub_prec_ref_val(Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.sub_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).sub_prec_ref_ref(&Float, u64)\",\n                &mut |(x, y, prec)| no_out!(x.sub_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec(Float, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.sub_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_sub_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec(Float, u64)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| no_out!(x.sub_prec(y, prec))),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(add_prec_round_naive(x, -y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec_assign(Float, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Float.sub_prec_assign(Float, u64)\", &mut |(\n                mut x,\n                y,\n                prec,\n            )| {\n                no_out!(x.sub_prec_assign(y, prec));\n            }),\n            (\n                \"Float.sub_prec_assign_ref(&Float, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.sub_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_round(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float.sub_round(Float, RoundingMode)\", &mut |(x, y, rm)| {\n                no_out!(x.sub_round(y, rm));\n            }),\n            (\n                \"Float.sub_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.sub_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).sub_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.sub_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).sub_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.sub_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_round(Float, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_rounding_mode_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.sub_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_sub_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_round(Float, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| no_out!(x.sub_round(y, rm))),\n            (\"naive\", &mut |(x, y, rm)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                add_prec_round_naive(x, -y, max(xsb, ysb), rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_round_assign(Float, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.sub_round_assign(Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.sub_round_assign(y, rm)),\n            ),\n            (\n                \"Float.sub_round_assign_ref(&Float, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.sub_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.sub_prec_round(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.sub_prec_round_val_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).sub_prec_round_ref_val(Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).sub_prec_round_ref_ref(&Float, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_2_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.sub_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_sub_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec_round(Float, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.sub_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(add_prec_round_naive(x, -y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_prec_round_assign(Float, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_float_unsigned_rounding_mode_quadruple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.sub_prec_round_assign(Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.sub_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.sub_prec_round_assign_ref(&Float, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.sub_prec_round_assign_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_sub_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float - Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float - Rational\", &mut |(x, y)| no_out!(x - y)),\n            (\"Float - &Rational\", &mut |(x, y)| no_out!(x - &y)),\n            (\"&Float - Rational\", &mut |(x, y)| no_out!(&x - y)),\n            (\"&Float - &Rational\", &mut |(x, y)| no_out!(&x - &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_sub_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float - Rational\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(&x - &y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_sub_rational(&x, &y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_float_sub_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float - Rational\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x - y)),\n            (\"naive\", &mut |(x, y)| {\n                let xsb = x.significant_bits();\n                let ysb = y.significant_bits();\n                no_out!(sub_rational_prec_round_naive(x, y, max(xsb, ysb), Nearest).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float -= Rational\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Float -= Rational\", &mut |(mut x, y)| x -= y),\n            (\"Float -= &Rational\", &mut |(mut x, y)| x -= &y),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_sub_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational - Float\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational - Float\", &mut |(y, x)| no_out!(x - y)),\n            (\"Rational - &Float\", &mut |(y, x)| no_out!(x - &y)),\n            (\"&Rational - Float\", &mut |(y, x)| no_out!(&x - y)),\n            (\"&Rational - &Float\", &mut |(y, x)| no_out!(&x - &y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_rational_sub_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational - Float\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(&x - &y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(-rug_sub_rational(&y, &x))),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.sub_rational_prec(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.sub_rational_prec(y, prec)),\n            ),\n            (\n                \"Float.sub_rational_prec_val_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.sub_rational_prec_val_ref(&y, prec)),\n            ),\n            (\n                \"(&Float).sub_rational_prec_ref_val(Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.sub_rational_prec_ref_val(y, prec)),\n            ),\n            (\n                \"(&Float).sub_rational_prec_ref_ref(&Rational, u64)\",\n                &mut |(x, y, prec)| no_out!(x.sub_rational_prec_ref_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec(Rational, u64)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec))| {\n                no_out!(x.sub_rational_prec_ref_ref(&y, prec));\n            }),\n            (\"rug\", &mut |((x, y, prec), _)| {\n                no_out!(rug_sub_rational_prec(&x, &y, prec));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec(Rational, u64)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec)| {\n                no_out!(x.sub_rational_prec(y, prec));\n            }),\n            (\"naive\", &mut |(x, y, prec)| {\n                no_out!(sub_rational_prec_round_naive(x, y, prec, Nearest));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec_assign(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.sub_rational_prec_assign(Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.sub_rational_prec_assign(y, prec)),\n            ),\n            (\n                \"Float.sub_rational_prec_assign_ref(&Rational, u64)\",\n                &mut |(mut x, y, prec)| no_out!(x.sub_rational_prec_assign_ref(&y, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.sub_rational_round(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.sub_rational_round(y, rm)),\n            ),\n            (\n                \"Float.sub_rational_round_val_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.sub_rational_round_val_ref(&y, rm)),\n            ),\n            (\n                \"(&Float).sub_rational_round_ref_val(Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.sub_rational_round_ref_val(y, rm)),\n            ),\n            (\n                \"(&Float).sub_rational_round_ref_ref(&Float, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.sub_rational_round_ref_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_rounding_mode_triple_gen_var_3_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, rm))| {\n                no_out!(x.sub_rational_round_ref_ref(&y, rm));\n            }),\n            (\"rug\", &mut |((x, y, rm), _)| {\n                no_out!(rug_sub_rational_round(&x, &y, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_round(Rational, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.sub_rational_round(y, rm));\n            }),\n            (\"naive\", &mut |(x, y, rm)| {\n                let ysb = y.significant_bits();\n                sub_rational_prec_round_naive(x, y, ysb, rm);\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_round_assign(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Float.sub_rational_round_assign(Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.sub_rational_round_assign(y, rm)),\n            ),\n            (\n                \"Float.sub_rational_round_assign_ref(&Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.sub_rational_round_assign_ref(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.sub_rational_prec_round(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_rational_prec_round(y, prec, rm)),\n            ),\n            (\n                \"Float.sub_rational_prec_round_val_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_rational_prec_round_val_ref(&y, prec, rm)),\n            ),\n            (\n                \"(&Float).sub_rational_prec_round_ref_val(Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_rational_prec_round_ref_val(y, prec, rm)),\n            ),\n            (\n                \"(&Float).sub_rational_prec_round_ref_ref(&Rational, u64, RoundingMode)\",\n                &mut |(x, y, prec, rm)| no_out!(x.sub_rational_prec_round_ref_ref(&y, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_2_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\n            \"x\", \"y\", \"prec\",\n        ),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, prec, rm))| {\n                no_out!(x.sub_rational_prec_round_ref_ref(&y, prec, rm));\n            }),\n            (\"rug\", &mut |((x, y, prec, rm), _)| {\n                no_out!(rug_sub_rational_prec_round(&x, &y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(x, y, prec, rm)| {\n                no_out!(x.sub_rational_prec_round(y, prec, rm));\n            }),\n            (\"naive\", &mut |(x, y, prec, rm)| {\n                no_out!(sub_rational_prec_round_naive(x, y, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sub_rational_prec_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sub_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rational_unsigned_rounding_mode_quadruple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer(\"x\", \"y\", \"prec\"),\n        &mut [\n            (\n                \"Float.sub_rational_prec_round_assign(Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| no_out!(x.sub_rational_prec_round_assign(y, prec, rm)),\n            ),\n            (\n                \"Float.sub_rational_prec_round_assign_ref(&Rational, u64, RoundingMode)\",\n                &mut |(mut x, y, prec, rm)| {\n                    no_out!(x.sub_rational_prec_round_assign_ref(&y, prec, rm));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/basic/classification.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_2_float_complexity_bucketer,\n};\nuse malachite_float::test_util::common::to_hex_string;\nuse malachite_float::test_util::generators::{float_gen, float_gen_rm, float_gen_var_12};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_is_nan);\n    register_demo!(runner, demo_float_is_nan_debug);\n    register_demo!(runner, demo_float_is_nan_extreme);\n    register_demo!(runner, demo_float_is_nan_extreme_debug);\n    register_demo!(runner, demo_float_is_finite);\n    register_demo!(runner, demo_float_is_finite_debug);\n    register_demo!(runner, demo_float_is_finite_extreme);\n    register_demo!(runner, demo_float_is_finite_extreme_debug);\n    register_demo!(runner, demo_float_is_infinite);\n    register_demo!(runner, demo_float_is_infinite_debug);\n    register_demo!(runner, demo_float_is_infinite_extreme);\n    register_demo!(runner, demo_float_is_infinite_extreme_debug);\n    register_demo!(runner, demo_float_is_positive_zero);\n    register_demo!(runner, demo_float_is_positive_zero_debug);\n    register_demo!(runner, demo_float_is_positive_zero_extreme);\n    register_demo!(runner, demo_float_is_positive_zero_extreme_debug);\n    register_demo!(runner, demo_float_is_negative_zero);\n    register_demo!(runner, demo_float_is_negative_zero_debug);\n    register_demo!(runner, demo_float_is_negative_zero_extreme);\n    register_demo!(runner, demo_float_is_negative_zero_extreme_debug);\n    register_demo!(runner, demo_float_is_zero);\n    register_demo!(runner, demo_float_is_zero_debug);\n    register_demo!(runner, demo_float_is_zero_extreme);\n    register_demo!(runner, demo_float_is_zero_extreme_debug);\n    register_demo!(runner, demo_float_is_normal);\n    register_demo!(runner, demo_float_is_normal_debug);\n    register_demo!(runner, demo_float_is_normal_extreme);\n    register_demo!(runner, demo_float_is_normal_extreme_debug);\n    register_demo!(runner, demo_float_is_sign_positive);\n    register_demo!(runner, demo_float_is_sign_positive_debug);\n    register_demo!(runner, demo_float_is_sign_positive_extreme);\n    register_demo!(runner, demo_float_is_sign_positive_extreme_debug);\n    register_demo!(runner, demo_float_is_sign_negative);\n    register_demo!(runner, demo_float_is_sign_negative_debug);\n    register_demo!(runner, demo_float_is_sign_negative_extreme);\n    register_demo!(runner, demo_float_is_sign_negative_extreme_debug);\n    register_demo!(runner, demo_float_classify);\n    register_demo!(runner, demo_float_classify_debug);\n    register_demo!(runner, demo_float_classify_extreme);\n    register_demo!(runner, demo_float_classify_extreme_debug);\n    register_demo!(runner, demo_float_into_non_nan);\n    register_demo!(runner, demo_float_into_non_nan_debug);\n    register_demo!(runner, demo_float_to_non_nan);\n    register_demo!(runner, demo_float_to_non_nan_debug);\n    register_demo!(runner, demo_float_to_non_nan_extreme);\n    register_demo!(runner, demo_float_to_non_nan_extreme_debug);\n    register_demo!(runner, demo_float_into_finite);\n    register_demo!(runner, demo_float_into_finite_debug);\n    register_demo!(runner, demo_float_to_finite);\n    register_demo!(runner, demo_float_to_finite_debug);\n    register_demo!(runner, demo_float_to_finite_extreme);\n    register_demo!(runner, demo_float_to_finite_extreme_debug);\n\n    register_bench!(runner, benchmark_float_is_nan_library_comparison);\n    register_bench!(runner, benchmark_float_is_finite_library_comparison);\n    register_bench!(runner, benchmark_float_is_infinite_library_comparison);\n    register_bench!(runner, benchmark_float_is_positive_zero);\n    register_bench!(runner, benchmark_float_is_negative_zero);\n    register_bench!(runner, benchmark_float_is_zero_library_comparison);\n    register_bench!(runner, benchmark_float_is_normal_library_comparison);\n    register_bench!(runner, benchmark_float_is_sign_positive_library_comparison);\n    register_bench!(runner, benchmark_float_is_sign_negative_library_comparison);\n    register_bench!(runner, benchmark_float_classify_library_comparison);\n    register_bench!(runner, benchmark_float_to_non_nan_evaluation_strategy);\n    register_bench!(runner, benchmark_float_to_finite_evaluation_strategy);\n}\n\nfn demo_float_is_nan(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_nan() {\n            println!(\"{x} is NaN\");\n        } else {\n            println!(\"{x} is not NaN\");\n        }\n    }\n}\n\nfn demo_float_is_nan_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_nan() {\n            println!(\"{:#x} is NaN\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not NaN\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_nan_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_nan() {\n            println!(\"{x} is NaN\");\n        } else {\n            println!(\"{x} is not NaN\");\n        }\n    }\n}\n\nfn demo_float_is_nan_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_nan() {\n            println!(\"{:#x} is NaN\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not NaN\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_finite(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{x} is finite\");\n        } else {\n            println!(\"{x} is not finite\");\n        }\n    }\n}\n\nfn demo_float_is_finite_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is finite\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not finite\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_finite_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{x} is finite\");\n        } else {\n            println!(\"{x} is not finite\");\n        }\n    }\n}\n\nfn demo_float_is_finite_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is finite\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not finite\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_infinite(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{x} is infinite\");\n        } else {\n            println!(\"{x} is not infinite\");\n        }\n    }\n}\n\nfn demo_float_is_infinite_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_infinite() {\n            println!(\"{:#x} is infinite\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not infinite\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_infinite_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{x} is infinite\");\n        } else {\n            println!(\"{x} is not infinite\");\n        }\n    }\n}\n\nfn demo_float_is_infinite_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_infinite() {\n            println!(\"{:#x} is infinite\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not infinite\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_positive_zero(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_zero() {\n            println!(\"{x} is positive zero\");\n        } else {\n            println!(\"{x} is not positive zero\");\n        }\n    }\n}\n\nfn demo_float_is_positive_zero_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is positive zero\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not positive zero\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_positive_zero_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_zero() {\n            println!(\"{x} is positive zero\");\n        } else {\n            println!(\"{x} is not positive zero\");\n        }\n    }\n}\n\nfn demo_float_is_positive_zero_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is positive zero\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not positive zero\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_negative_zero(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_zero() {\n            println!(\"{x} is negative zero\");\n        } else {\n            println!(\"{x} is not negative zero\");\n        }\n    }\n}\n\nfn demo_float_is_negative_zero_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is negative zero\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not negative zero\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_negative_zero_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_zero() {\n            println!(\"{x} is negative zero\");\n        } else {\n            println!(\"{x} is not negative zero\");\n        }\n    }\n}\n\nfn demo_float_is_negative_zero_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is negative zero\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not negative zero\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_zero(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_zero() {\n            println!(\"{x} is zero\");\n        } else {\n            println!(\"{x} is not zero\");\n        }\n    }\n}\n\nfn demo_float_is_zero_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is zero\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not zero\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_zero_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_zero() {\n            println!(\"{x} is zero\");\n        } else {\n            println!(\"{x} is not zero\");\n        }\n    }\n}\n\nfn demo_float_is_zero_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_finite() {\n            println!(\"{:#x} is zero\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not zero\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_normal(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_normal() {\n            println!(\"{x} is normal\");\n        } else {\n            println!(\"{x} is not normal\");\n        }\n    }\n}\n\nfn demo_float_is_normal_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_normal() {\n            println!(\"{:#x} is normal\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not normal\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_normal_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_normal() {\n            println!(\"{x} is normal\");\n        } else {\n            println!(\"{x} is not normal\");\n        }\n    }\n}\n\nfn demo_float_is_normal_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_normal() {\n            println!(\"{:#x} is normal\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} is not normal\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_sign_positive(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_sign_positive() {\n            println!(\"{x} has a positive sign\");\n        } else {\n            println!(\"{x} does not have a positive sign\");\n        }\n    }\n}\n\nfn demo_float_is_sign_positive_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_sign_positive() {\n            println!(\"{:#x} has a positive sign\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} does not have a positive sign\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_sign_positive_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_sign_positive() {\n            println!(\"{x} has a positive sign\");\n        } else {\n            println!(\"{x} does not have a positive sign\");\n        }\n    }\n}\n\nfn demo_float_is_sign_positive_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_sign_positive() {\n            println!(\"{:#x} has a positive sign\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} does not have a positive sign\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_sign_negative(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_sign_negative() {\n            println!(\"{x} has a negative sign\");\n        } else {\n            println!(\"{x} does not have a negative sign\");\n        }\n    }\n}\n\nfn demo_float_is_sign_negative_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.is_sign_negative() {\n            println!(\"{:#x} has a negative sign\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} does not have a negative sign\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_is_sign_negative_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_sign_negative() {\n            println!(\"{x} has a negative sign\");\n        } else {\n            println!(\"{x} does not have a negative sign\");\n        }\n    }\n}\n\nfn demo_float_is_sign_negative_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        if x.is_sign_negative() {\n            println!(\"{:#x} has a negative sign\", ComparableFloat(x));\n        } else {\n            println!(\"{:#x} does not have a negative sign\", ComparableFloat(x));\n        }\n    }\n}\n\nfn demo_float_classify(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"classify({}) = {:?}\", x, x.classify());\n    }\n}\n\nfn demo_float_classify_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"classify({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.classify()\n        );\n    }\n}\n\nfn demo_float_classify_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"classify({}) = {:?}\", x, x.classify());\n    }\n}\n\nfn demo_float_classify_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"classify({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.classify()\n        );\n    }\n}\n\nfn demo_float_into_non_nan(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"into_non_nan({}) = {:?}\", x.clone(), x.into_non_nan());\n    }\n}\n\nfn demo_float_into_non_nan_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"into_non_nan({:#x}) = {:?}\",\n            ComparableFloat(x.clone()),\n            x.into_non_nan()\n                .map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn demo_float_to_non_nan(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"to_non_nan({}) = {:?}\", x, x.to_non_nan());\n    }\n}\n\nfn demo_float_to_non_nan_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"to_non_nan({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.to_non_nan()\n                .map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn demo_float_to_non_nan_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"to_non_nan({}) = {:?}\", x, x.to_non_nan());\n    }\n}\n\nfn demo_float_to_non_nan_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"to_non_nan({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.to_non_nan()\n                .map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn demo_float_into_finite(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"into_finite({}) = {:?}\", x.clone(), x.into_finite());\n    }\n}\n\nfn demo_float_into_finite_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"into_finite({:#x}) = {:?}\",\n            ComparableFloat(x.clone()),\n            x.into_finite()\n                .map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn demo_float_to_finite(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"to_finite({}) = {:?}\", x, x.to_finite());\n    }\n}\n\nfn demo_float_to_finite_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"to_finite({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.to_finite()\n                .map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn demo_float_to_finite_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"to_finite({}) = {:?}\", x, x.to_finite());\n    }\n}\n\nfn demo_float_to_finite_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"to_finite({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.to_finite()\n                .map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn benchmark_float_is_nan_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_nan()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.is_nan())),\n            (\"rug\", &mut |(x, _)| no_out!(x.is_nan())),\n        ],\n    );\n}\n\nfn benchmark_float_is_finite_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_finite()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.is_finite())),\n            (\"rug\", &mut |(x, _)| no_out!(x.is_finite())),\n        ],\n    );\n}\n\nfn benchmark_float_is_infinite_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_infinite()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.is_infinite())),\n            (\"rug\", &mut |(x, _)| no_out!(x.is_infinite())),\n        ],\n    );\n}\n\nfn benchmark_float_is_positive_zero(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_zero()\",\n        BenchmarkType::Single,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(_, x)| no_out!(x.is_positive_zero()))],\n    );\n}\n\nfn benchmark_float_is_negative_zero(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_zero()\",\n        BenchmarkType::Single,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(_, x)| no_out!(x.is_positive_zero()))],\n    );\n}\n\nfn benchmark_float_is_zero_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_zero()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.is_zero())),\n            (\"rug\", &mut |(x, _)| no_out!(x.is_zero())),\n        ],\n    );\n}\n\nfn benchmark_float_is_normal_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_normal()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.is_normal())),\n            (\"rug\", &mut |(x, _)| no_out!(x.is_normal())),\n        ],\n    );\n}\n\nfn benchmark_float_is_sign_positive_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_sign_positive()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.is_sign_positive())),\n            (\"rug\", &mut |(x, _)| {\n                let _ = !x.is_nan() && x.is_sign_positive();\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_is_sign_negative_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.is_sign_negative()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.is_sign_negative())),\n            (\"rug\", &mut |(x, _)| {\n                let _ = !x.is_nan() && x.is_sign_negative();\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_classify_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.classify()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.classify())),\n            (\"rug\", &mut |(x, _)| no_out!(x.classify())),\n        ],\n    );\n}\n\nfn benchmark_float_to_non_nan_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.to_non_nan()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"to_non_nan\", &mut |x| no_out!(x.to_non_nan())),\n            (\"into_non_nan\", &mut |x| no_out!(x.into_non_nan())),\n        ],\n    );\n}\n\nfn benchmark_float_to_finite_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.to_finite()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"to_finite\", &mut |x| no_out!(x.to_finite())),\n            (\"into_finite\", &mut |x| no_out!(x.into_finite())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/basic/complexity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_complexity);\n    register_demo!(runner, demo_float_complexity_debug);\n    register_demo!(runner, demo_float_complexity_extreme);\n    register_demo!(runner, demo_float_complexity_extreme_debug);\n    register_demo!(runner, demo_float_significant_bits);\n    register_demo!(runner, demo_float_significant_bits_debug);\n    register_demo!(runner, demo_float_significant_bits_extreme);\n    register_demo!(runner, demo_float_significant_bits_extreme_debug);\n\n    register_bench!(runner, benchmark_float_complexity);\n    register_bench!(runner, benchmark_float_significant_bits);\n}\n\nfn demo_float_complexity(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"complexity({}) = {}\", x, x.complexity());\n    }\n}\n\nfn demo_float_complexity_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"complexity({:#x}) = {}\",\n            ComparableFloatRef(&x),\n            x.complexity()\n        );\n    }\n}\n\nfn demo_float_complexity_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"complexity({}) = {}\", x, x.complexity());\n    }\n}\n\nfn demo_float_complexity_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"complexity({:#x}) = {}\",\n            ComparableFloatRef(&x),\n            x.complexity()\n        );\n    }\n}\n\nfn demo_float_significant_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"significant_bits({}) = {}\", x, x.significant_bits());\n    }\n}\n\nfn demo_float_significant_bits_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"significant_bits({:#x}) = {}\",\n            ComparableFloatRef(&x),\n            x.significant_bits()\n        );\n    }\n}\n\nfn demo_float_significant_bits_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"significant_bits({}) = {}\", x, x.significant_bits());\n    }\n}\n\nfn demo_float_significant_bits_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"significant_bits({:#x}) = {}\",\n            ComparableFloatRef(&x),\n            x.significant_bits()\n        );\n    }\n}\n\nfn benchmark_float_complexity(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.complexity()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.complexity()))],\n    );\n}\n\nfn benchmark_float_significant_bits(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.significant_bits()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.significant_bits()))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/basic/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_11;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::float_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_min_positive_value_prec);\n    register_demo!(runner, demo_float_min_positive_value_prec_debug);\n    register_demo!(runner, demo_float_abs_is_min_positive_value);\n    register_demo!(runner, demo_float_abs_is_min_positive_value_debug);\n    register_demo!(runner, demo_float_max_finite_value_with_prec);\n    register_demo!(runner, demo_float_max_finite_value_with_prec_debug);\n    register_demo!(runner, demo_float_abs_is_max_finite_value_with_prec);\n    register_demo!(runner, demo_float_abs_is_max_finite_value_with_prec_debug);\n    register_demo!(runner, demo_float_one_prec);\n    register_demo!(runner, demo_float_one_prec_debug);\n    register_demo!(runner, demo_float_two_prec);\n    register_demo!(runner, demo_float_two_prec_debug);\n    register_demo!(runner, demo_float_negative_one_prec);\n    register_demo!(runner, demo_float_negative_one_prec_debug);\n    register_demo!(runner, demo_float_one_half_prec);\n    register_demo!(runner, demo_float_one_half_prec_debug);\n\n    register_bench!(runner, benchmark_float_min_positive_value_prec);\n    register_bench!(runner, benchmark_float_abs_is_min_positive_value);\n    register_bench!(runner, benchmark_float_max_finite_value_with_prec);\n    register_bench!(runner, benchmark_float_abs_is_max_finite_value_with_prec);\n    register_bench!(runner, benchmark_float_one_prec_library_comparison);\n    register_bench!(runner, benchmark_float_two_prec_library_comparison);\n    register_bench!(runner, benchmark_float_negative_one_prec_library_comparison);\n    register_bench!(runner, benchmark_float_one_half_prec_library_comparison);\n}\n\nfn demo_float_min_positive_value_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"min_positive_value_prec({}) = {}\",\n            p,\n            Float::min_positive_value_prec(p)\n        );\n    }\n}\n\nfn demo_float_min_positive_value_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"min_positive_value_prec({}) = {:#x}\",\n            p,\n            ComparableFloat(Float::min_positive_value_prec(p))\n        );\n    }\n}\n\nfn demo_float_abs_is_min_positive_value(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.abs_is_min_positive_value() {\n            println!(\"|{x}| is the minimum positive value\");\n        } else {\n            println!(\"|{x}| is not the minimum positive value\");\n        }\n    }\n}\n\nfn demo_float_abs_is_min_positive_value_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.abs_is_min_positive_value() {\n            println!(\"|{:#x}| is the minimum positive value\", ComparableFloat(x),);\n        } else {\n            println!(\n                \"|{:#x}| is not the minimum positive value\",\n                ComparableFloat(x),\n            );\n        }\n    }\n}\n\nfn demo_float_max_finite_value_with_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"max_finite_value_with_prec({}) = {}\",\n            p,\n            Float::max_finite_value_with_prec(p)\n        );\n    }\n}\n\nfn demo_float_max_finite_value_with_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"max_finite_value_with_prec({}) = {:#x}\",\n            p,\n            ComparableFloat(Float::max_finite_value_with_prec(p))\n        );\n    }\n}\n\nfn demo_float_abs_is_max_finite_value_with_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.abs_is_max_finite_value_with_prec() {\n            println!(\"|{x}| is the maximum positive value with its precision\");\n        } else {\n            println!(\"|{x}| is not the maximum positive value with its precision\");\n        }\n    }\n}\n\nfn demo_float_abs_is_max_finite_value_with_prec_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen().get(gm, config).take(limit) {\n        if x.abs_is_max_finite_value_with_prec() {\n            println!(\n                \"|{:#x}| is the maximum positive value with its precision\",\n                ComparableFloat(x)\n            );\n        } else {\n            println!(\n                \"|{:#x}| is not the maximum positive value with its precision\",\n                ComparableFloat(x)\n            );\n        }\n    }\n}\n\nfn demo_float_one_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"one_prec({}) = {}\", p, Float::one_prec(p));\n    }\n}\n\nfn demo_float_one_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"one_prec({}) = {:#x}\",\n            p,\n            ComparableFloat(Float::one_prec(p))\n        );\n    }\n}\n\nfn demo_float_two_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"two_prec({}) = {}\", p, Float::two_prec(p));\n    }\n}\n\nfn demo_float_two_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"two_prec({}) = {:#x}\",\n            p,\n            ComparableFloat(Float::two_prec(p))\n        );\n    }\n}\n\nfn demo_float_negative_one_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"negative_one_prec({}) = {}\", p, Float::negative_one_prec(p));\n    }\n}\n\nfn demo_float_negative_one_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"negative_one_prec({}) = {:#x}\",\n            p,\n            ComparableFloat(Float::negative_one_prec(p))\n        );\n    }\n}\n\nfn demo_float_one_half_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"one_half_prec({}) = {}\", p, Float::one_half_prec(p));\n    }\n}\n\nfn demo_float_one_half_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"one_half_prec({}) = {:#x}\",\n            p,\n            ComparableFloat(Float::one_half_prec(p))\n        );\n    }\n}\n\nfn benchmark_float_min_positive_value_prec(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.min_positive_value_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| {\n            no_out!(Float::min_positive_value_prec(p));\n        })],\n    );\n}\n\nfn benchmark_float_abs_is_min_positive_value(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.abs_is_min_positive_value()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(x.abs_is_min_positive_value());\n        })],\n    );\n}\n\nfn benchmark_float_max_finite_value_with_prec(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.max_finite_value_with_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| {\n            no_out!(Float::max_finite_value_with_prec(p));\n        })],\n    );\n}\n\nfn benchmark_float_abs_is_max_finite_value_with_prec(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.abs_is_max_positive_value_with_prec()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(x.abs_is_max_finite_value_with_prec());\n        })],\n    );\n}\n\nfn benchmark_float_one_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.one_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::one_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug::Float::with_val(u32::exact_from(p), 1.0));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_two_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.two_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::two_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug::Float::with_val(u32::exact_from(p), 2.0));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_negative_one_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.negative_one_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::negative_one_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug::Float::with_val(u32::exact_from(p), -1.0));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_one_half_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.one_half_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::one_half_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug::Float::with_val(u32::exact_from(p), 0.5));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/basic/get_and_set.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, max_pair_1_complexity_pair_2_bucketer,\n    max_triple_1_float_complexity_triple_2_bucketer, pair_2_float_complexity_bucketer,\n    pair_2_max_pair_1_complexity_pair_2_bucketer,\n    pair_2_max_triple_1_float_complexity_triple_2_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_rm, float_gen_var_12, float_unsigned_pair_gen_var_1,\n    float_unsigned_pair_gen_var_1_rm, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_1,\n    float_unsigned_rounding_mode_triple_gen_var_1_rm,\n    float_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_to_significand);\n    register_demo!(runner, demo_float_to_significand_debug);\n    register_demo!(runner, demo_float_to_significand_extreme);\n    register_demo!(runner, demo_float_to_significand_extreme_debug);\n    register_demo!(runner, demo_float_into_significand);\n    register_demo!(runner, demo_float_into_significand_debug);\n    register_demo!(runner, demo_float_significand_ref);\n    register_demo!(runner, demo_float_significand_ref_debug);\n    register_demo!(runner, demo_float_get_exponent);\n    register_demo!(runner, demo_float_get_exponent_debug);\n    register_demo!(runner, demo_float_get_exponent_extreme);\n    register_demo!(runner, demo_float_get_exponent_extreme_debug);\n    register_demo!(runner, demo_float_get_prec);\n    register_demo!(runner, demo_float_get_prec_debug);\n    register_demo!(runner, demo_float_get_prec_extreme);\n    register_demo!(runner, demo_float_get_prec_extreme_debug);\n    register_demo!(runner, demo_float_get_min_prec);\n    register_demo!(runner, demo_float_get_min_prec_debug);\n    register_demo!(runner, demo_float_get_min_prec_extreme);\n    register_demo!(runner, demo_float_get_min_prec_extreme_debug);\n    register_demo!(runner, demo_float_set_prec_round);\n    register_demo!(runner, demo_float_set_prec_round_debug);\n    register_demo!(runner, demo_float_set_prec_round_extreme);\n    register_demo!(runner, demo_float_set_prec_round_extreme_debug);\n    register_demo!(runner, demo_float_set_prec);\n    register_demo!(runner, demo_float_set_prec_debug);\n    register_demo!(runner, demo_float_set_prec_extreme);\n    register_demo!(runner, demo_float_set_prec_extreme_debug);\n    register_demo!(runner, demo_float_from_float_prec_round);\n    register_demo!(runner, demo_float_from_float_prec_round_debug);\n    register_demo!(runner, demo_float_from_float_prec_round_ref);\n    register_demo!(runner, demo_float_from_float_prec_round_ref_debug);\n    register_demo!(runner, demo_float_from_float_prec);\n    register_demo!(runner, demo_float_from_float_prec_debug);\n    register_demo!(runner, demo_float_from_float_prec_ref);\n    register_demo!(runner, demo_float_from_float_prec_ref_debug);\n\n    register_bench!(runner, benchmark_float_to_significand_evaluation_strategy);\n    register_bench!(runner, benchmark_float_significand_ref_library_comparison);\n    register_bench!(runner, benchmark_float_get_exponent_library_comparison);\n    register_bench!(runner, benchmark_float_get_prec_library_comparison);\n    register_bench!(runner, benchmark_float_get_min_prec);\n    register_bench!(runner, benchmark_float_set_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_set_prec_round_evaluation_strategy);\n    register_bench!(runner, benchmark_float_set_prec_library_comparison);\n    register_bench!(runner, benchmark_float_set_prec_evaluation_strategy);\n}\n\nfn demo_float_to_significand(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"to_significand({}) = {:?}\", x, x.to_significand());\n    }\n}\n\nfn demo_float_to_significand_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"to_significand({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.to_significand()\n        );\n    }\n}\n\nfn demo_float_to_significand_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"to_significand({}) = {:?}\", x, x.to_significand());\n    }\n}\n\nfn demo_float_to_significand_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"to_significand({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.to_significand()\n        );\n    }\n}\n\nfn demo_float_into_significand(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"into_significand({}) = {:?}\",\n            x.clone(),\n            x.into_significand()\n        );\n    }\n}\n\nfn demo_float_into_significand_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"into_significand({:#x}) = {:?}\",\n            ComparableFloat(x.clone()),\n            x.into_significand()\n        );\n    }\n}\n\nfn demo_float_significand_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"significand_ref({}) = {:?}\", x, x.significand_ref());\n    }\n}\n\nfn demo_float_significand_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"significand_ref({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.significand_ref()\n        );\n    }\n}\n\nfn demo_float_get_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"get_exponent({}) = {:?}\", x, x.get_exponent());\n    }\n}\n\nfn demo_float_get_exponent_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_exponent({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.get_exponent()\n        );\n    }\n}\n\nfn demo_float_get_exponent_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"get_exponent({}) = {:?}\", x, x.get_exponent());\n    }\n}\n\nfn demo_float_get_exponent_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"get_exponent({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.get_exponent()\n        );\n    }\n}\n\nfn demo_float_get_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"get_prec({}) = {:?}\", x, x.get_prec());\n    }\n}\n\nfn demo_float_get_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_prec({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.get_prec()\n        );\n    }\n}\n\nfn demo_float_get_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"get_prec({}) = {:?}\", x, x.get_prec());\n    }\n}\n\nfn demo_float_get_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"get_prec({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.get_prec()\n        );\n    }\n}\n\nfn demo_float_get_min_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"get_min_prec({}) = {:?}\", x, x.get_min_prec());\n    }\n}\n\nfn demo_float_get_min_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"get_min_prec({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.get_min_prec()\n        );\n    }\n}\n\nfn demo_float_get_min_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"get_min_prec({}) = {:?}\", x, x.get_min_prec());\n    }\n}\n\nfn demo_float_get_min_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"get_min_prec({:#x}) = {:?}\",\n            ComparableFloatRef(&x),\n            x.get_min_prec()\n        );\n    }\n}\n\nfn demo_float_set_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        let o = x.set_prec_round(prec, rm);\n        println!(\"x := {old_x}; x.set_prec_round({prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_set_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        let o = x.set_prec_round(prec, rm);\n        println!(\n            \"x := {:#x}; x.set_prec_round({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(old_x),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_set_prec_round_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        let o = x.set_prec_round(prec, rm);\n        println!(\"x := {old_x}; x.set_prec_round({prec}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_set_prec_round_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        let o = x.set_prec_round(prec, rm);\n        println!(\n            \"x := {:#x}; x.set_prec_round({}, {}) = {:?}; x = {:#x}\",\n            ComparableFloat(old_x),\n            prec,\n            rm,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_set_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        let o = x.set_prec(prec);\n        println!(\"x := {old_x}; x.set_prec({prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_set_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        let o = x.set_prec(prec);\n        println!(\n            \"x := {:#x}; x.set_prec({}) = {:?}; x = {:#x}\",\n            ComparableFloat(old_x),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_set_prec_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        let o = x.set_prec(prec);\n        println!(\"x := {old_x}; x.set_prec({prec}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_float_set_prec_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, prec) in float_unsigned_pair_gen_var_4().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        let o = x.set_prec(prec);\n        println!(\n            \"x := {:#x}; x.set_prec({}) = {:?}; x = {:#x}\",\n            ComparableFloat(old_x),\n            prec,\n            o,\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_from_float_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (y, o) = Float::from_float_prec_round(x.clone(), prec, rm);\n        println!(\"Float::from_float_prec_round({x}, {prec}, {rm}) = ({y}, {o:?})\");\n    }\n}\n\nfn demo_float_from_float_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (y, o) = Float::from_float_prec_round(x.clone(), prec, rm);\n        println!(\"Float::from_float_prec_round({x:#x}, {prec}, {rm}) = ({y:#x}, {o:?})\");\n    }\n}\n\nfn demo_float_from_float_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (y, o) = Float::from_float_prec_round_ref(&x, prec, rm);\n        println!(\"Float::from_float_prec_round_ref(&{x}, {prec}, {rm}) = ({y}, {o:?})\");\n    }\n}\n\nfn demo_float_from_float_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec, rm) in float_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (y, o) = Float::from_float_prec_round_ref(&x, prec, rm);\n        println!(\"Float::from_float_prec_round_ref(&{x:#x}, {prec}, {rm}) = ({y:#x}, {o:?})\");\n    }\n}\n\nfn demo_float_from_float_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (y, o) = Float::from_float_prec(x.clone(), prec);\n        println!(\"Float::from_float_prec({x}, {prec}) = ({y}, {o:?})\");\n    }\n}\n\nfn demo_float_from_float_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (y, o) = Float::from_float_prec(x.clone(), prec);\n        println!(\"Float::from_float_prec({x:#x}, {prec}) = ({y:#x}, {o:?})\");\n    }\n}\n\nfn demo_float_from_float_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (y, o) = Float::from_float_prec_ref(&x, prec);\n        println!(\"Float::from_float_prec_ref(&{x}, {prec}) = ({y}, {o:?})\");\n    }\n}\n\nfn demo_float_from_float_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, prec) in float_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let (y, o) = Float::from_float_prec_ref(&x, prec);\n        println!(\"Float::from_float_prec_ref(&{x:#x}, {prec}) = ({y:#x}, {o:?})\");\n    }\n}\n\nfn benchmark_float_to_significand_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.to_significand()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.to_significand()\", &mut |x| {\n                no_out!(x.to_significand());\n            }),\n            (\"Float.into_significand()\", &mut |x| {\n                no_out!(x.into_significand());\n            }),\n            (\"Float.significand_ref()\", &mut |x| {\n                no_out!(x.significand_ref());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_significand_ref_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.significand_ref()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.significand_ref())),\n            (\"rug\", &mut |(x, _)| no_out!(x.get_significand())),\n        ],\n    );\n}\n\nfn benchmark_float_get_exponent_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.get_exponent()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.get_exponent())),\n            (\"rug\", &mut |(x, _)| no_out!(x.get_exp())),\n        ],\n    );\n}\n\nfn benchmark_float_get_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.get_prec()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, x)| no_out!(x.get_prec())),\n            (\"rug\", &mut |(x, _)| no_out!(x.prec())),\n        ],\n    );\n}\n\nfn benchmark_float_get_min_prec(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.get_min_prec()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.get_min_prec()))],\n    );\n}\n\nfn benchmark_float_set_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.set_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_rounding_mode_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_max_triple_1_float_complexity_triple_2_bucketer(\"x\", \"precision\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, prec, rm))| {\n                no_out!(x.set_prec_round(prec, rm));\n            }),\n            (\"rug\", &mut |((mut x, prec, rm), _)| {\n                no_out!(x.set_prec_round(u32::exact_from(prec), rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_set_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.set_prec_round(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &max_triple_1_float_complexity_triple_2_bucketer(\"x\", \"precision\"),\n        &mut [\n            (\"Float::set_prec_round\", &mut |(mut x, prec, rm)| {\n                no_out!(x.set_prec_round(prec, rm));\n            }),\n            (\"Float::from_float_prec_round\", &mut |(x, prec, rm)| {\n                no_out!(Float::from_float_prec_round(x, prec, rm));\n            }),\n            (\"Float::from_float_prec_round_ref\", &mut |(x, prec, rm)| {\n                no_out!(Float::from_float_prec_round_ref(&x, prec, rm));\n            }),\n            (\"clone and Float::set_prec_round\", &mut |(x, prec, rm)| {\n                let mut x = x.clone();\n                no_out!(x.set_prec_round(prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_set_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.set_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_max_pair_1_complexity_pair_2_bucketer(\"x\", \"precision\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, prec))| {\n                no_out!(x.set_prec(prec));\n            }),\n            (\"rug\", &mut |((mut x, prec), _)| {\n                no_out!(x.set_prec(u32::exact_from(prec)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_set_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.set_prec(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        float_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &max_pair_1_complexity_pair_2_bucketer(\"x\", \"precision\"),\n        &mut [\n            (\"Float::set_prec\", &mut |(mut x, prec)| {\n                no_out!(x.set_prec(prec));\n            }),\n            (\"Float::from_float_prec\", &mut |(x, prec)| {\n                no_out!(Float::from_float_prec(x, prec));\n            }),\n            (\"Float::from_float_prec_ref\", &mut |(x, prec)| {\n                no_out!(Float::from_float_prec_ref(&x, prec));\n            }),\n            (\"clone and Float::set_prec\", &mut |(x, prec)| {\n                let mut x = x.clone();\n                no_out!(x.set_prec(prec));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/basic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    classification::register(runner);\n    complexity::register(runner);\n    constants::register(runner);\n    get_and_set::register(runner);\n    overflow_and_underflow::register(runner);\n    ulp::register(runner);\n}\n\nmod classification;\nmod complexity;\nmod constants;\nmod get_and_set;\nmod overflow_and_underflow;\nmod ulp;\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/basic/overflow_and_underflow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_1_float_complexity_bucketer;\nuse malachite_float::test_util::generators::float_ordering_pair_gen;\nuse malachite_float::{test_overflow, test_underflow};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_test_overflow);\n    register_demo!(runner, demo_float_test_overflow_debug);\n    register_demo!(runner, demo_float_test_underflow);\n    register_demo!(runner, demo_float_test_underflow_debug);\n\n    register_bench!(runner, benchmark_float_test_overflow);\n    register_bench!(runner, benchmark_float_test_underflow);\n}\n\nfn demo_float_test_overflow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, o) in float_ordering_pair_gen().get(gm, config).take(limit) {\n        println!(\"test_overflow({}, {:?}) = {}\", x, o, test_overflow(&x, o));\n    }\n}\n\nfn demo_float_test_overflow_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, o) in float_ordering_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"test_overflow({:#x}, {:?}) = {}\",\n            ComparableFloatRef(&x),\n            o,\n            test_overflow(&x, o)\n        );\n    }\n}\n\nfn demo_float_test_underflow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, o) in float_ordering_pair_gen().get(gm, config).take(limit) {\n        println!(\"test_underflow({}, {:?}) = {}\", x, o, test_underflow(&x, o));\n    }\n}\n\nfn demo_float_test_underflow_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, o) in float_ordering_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"test_underflow({:#x}, {:?}) = {}\",\n            ComparableFloatRef(&x),\n            o,\n            test_underflow(&x, o)\n        );\n    }\n}\n\nfn benchmark_float_test_overflow(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.ulp()\",\n        BenchmarkType::Single,\n        float_ordering_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, o)| no_out!(test_overflow(&x, o)))],\n    );\n}\n\nfn benchmark_float_test_underflow(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.ulp()\",\n        BenchmarkType::Single,\n        float_ordering_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, o)| no_out!(test_overflow(&x, o)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/basic/ulp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::common::to_hex_string;\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_3, float_gen_var_12, float_gen_var_13,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_ulp);\n    register_demo!(runner, demo_float_ulp_debug);\n    register_demo!(runner, demo_float_ulp_extreme);\n    register_demo!(runner, demo_float_ulp_extreme_debug);\n    register_demo!(runner, demo_float_increment);\n    register_demo!(runner, demo_float_increment_debug);\n    register_demo!(runner, demo_float_increment_extreme);\n    register_demo!(runner, demo_float_increment_extreme_debug);\n    register_demo!(runner, demo_float_decrement);\n    register_demo!(runner, demo_float_decrement_debug);\n    register_demo!(runner, demo_float_decrement_extreme);\n    register_demo!(runner, demo_float_decrement_extreme_debug);\n\n    register_bench!(runner, benchmark_float_ulp);\n    register_bench!(runner, benchmark_float_increment);\n    register_bench!(runner, benchmark_float_decrement);\n}\n\nfn demo_float_ulp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"ulp({}) = {:?}\", x, x.ulp());\n    }\n}\n\nfn demo_float_ulp_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"ulp({:#x}) = {}\",\n            ComparableFloatRef(&x),\n            x.ulp().map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn demo_float_ulp_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"ulp({}) = {:?}\", x, x.ulp());\n    }\n}\n\nfn demo_float_ulp_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"ulp({:#x}) = {}\",\n            ComparableFloatRef(&x),\n            x.ulp().map_or(\"None\".to_string(), |f| to_hex_string(&f))\n        );\n    }\n}\n\nfn demo_float_increment(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_3().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\"x := {old_x}; x.increment(); x = {x}\");\n    }\n}\n\nfn demo_float_increment_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_3().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\n            \"x := {:#x}; x.increment(); x = {:#x}\",\n            ComparableFloat(old_x),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_increment_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_13().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\"x := {old_x}; x.increment(); x = {x}\");\n    }\n}\n\nfn demo_float_increment_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_13().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\n            \"x := {:#x}; x.increment(); x = {:#x}\",\n            ComparableFloat(old_x),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_decrement(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_3().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\"x := {old_x}; x.increment(); x = {x}\");\n    }\n}\n\nfn demo_float_decrement_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_3().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\n            \"x := {:#x}; x.increment(); x = {:#x}\",\n            ComparableFloat(old_x),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_decrement_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_13().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\"x := {old_x}; x.increment(); x = {x}\");\n    }\n}\n\nfn demo_float_decrement_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in float_gen_var_13().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.increment();\n        println!(\n            \"x := {:#x}; x.increment(); x = {:#x}\",\n            ComparableFloat(old_x),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn benchmark_float_ulp(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.ulp()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.ulp()))],\n    );\n}\n\nfn benchmark_float_increment(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.increment()\",\n        BenchmarkType::Single,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.increment())],\n    );\n}\n\nfn benchmark_float_decrement(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.decrement()\",\n        BenchmarkType::Single,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.decrement())],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer, pair_float_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp);\n    register_demo!(runner, demo_float_partial_cmp_debug);\n    register_demo!(runner, demo_float_partial_cmp_extreme);\n    register_demo!(runner, demo_float_partial_cmp_extreme_debug);\n    register_demo!(runner, demo_comparable_float_partial_cmp);\n    register_demo!(runner, demo_comparable_float_partial_cmp_debug);\n    register_demo!(runner, demo_comparable_float_partial_cmp_extreme);\n    register_demo!(runner, demo_comparable_float_partial_cmp_extreme_debug);\n    register_demo!(runner, demo_comparable_float_ref_partial_cmp);\n    register_demo!(runner, demo_comparable_float_ref_partial_cmp_debug);\n\n    register_bench!(runner, benchmark_float_partial_cmp_library_comparison);\n    register_bench!(runner, benchmark_comparable_float_cmp);\n    register_bench!(runner, benchmark_comparable_float_ref_cmp);\n}\n\nfn demo_float_partial_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        match cx.partial_cmp(&cy) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x);\n        let cy = ComparableFloat(y);\n        match cx.partial_cmp(&cy) {\n            None => println!(\"{cx} and {cy} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        match cx.partial_cmp(&cy) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x);\n        let cy = ComparableFloat(y);\n        match cx.partial_cmp(&cy) {\n            None => println!(\"{cx} and {cy} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_comparable_float_ref_partial_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match cx.partial_cmp(&cy) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_comparable_float_ref_partial_cmp_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match cx.partial_cmp(&cy) {\n            None => println!(\"{cx} and {cy} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {cy:#x}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.cmp(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_comparable_float_cmp(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"ComparableFloat.cmp(&ComparableFloat)\",\n        BenchmarkType::Single,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(ComparableFloat(x).cmp(&ComparableFloat(y)));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_comparable_float_ref_cmp(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"ComparableFloatRef.cmp(&ComparableFloatRef)\",\n        BenchmarkType::Single,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(ComparableFloatRef(&x).cmp(&ComparableFloatRef(&y)));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer, pair_float_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp_abs);\n    register_demo!(runner, demo_float_partial_cmp_abs_debug);\n    register_demo!(runner, demo_float_partial_cmp_abs_extreme);\n    register_demo!(runner, demo_float_partial_cmp_abs_extreme_debug);\n    register_demo!(runner, demo_comparable_float_partial_cmp_abs);\n    register_demo!(runner, demo_comparable_float_partial_cmp_abs_debug);\n    register_demo!(runner, demo_comparable_float_partial_cmp_abs_extreme);\n    register_demo!(runner, demo_comparable_float_partial_cmp_abs_extreme_debug);\n    register_demo!(runner, demo_comparable_float_ref_partial_cmp_abs);\n    register_demo!(runner, demo_comparable_float_ref_partial_cmp_abs_debug);\n\n    register_bench!(runner, benchmark_float_partial_cmp_abs_library_comparison);\n    register_bench!(runner, benchmark_float_partial_cmp_abs_algorithms);\n    register_bench!(runner, benchmark_comparable_float_cmp_abs_algorithms);\n    register_bench!(runner, benchmark_comparable_float_ref_cmp_abs_algorithms);\n}\n\nfn demo_float_partial_cmp_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        match cx.partial_cmp_abs(&cy) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp_abs_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x);\n        let cy = ComparableFloat(y);\n        match cx.partial_cmp_abs(&cy) {\n            None => println!(\"|{cx}| and |{cy}| are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp_abs_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        match cx.partial_cmp_abs(&cy) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_comparable_float_partial_cmp_abs_extreme_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x);\n        let cy = ComparableFloat(y);\n        match cx.partial_cmp_abs(&cy) {\n            None => println!(\"|{cx}| and |{cy}| are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_comparable_float_ref_partial_cmp_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match cx.partial_cmp_abs(&cy) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_comparable_float_ref_partial_cmp_abs_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        match cx.partial_cmp_abs(&cy) {\n            None => println!(\"|{cx}| and |{cy}| are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.cmp_abs(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.cmp_abs(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.cmp_abs(&Integer)\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_comparable_float_cmp_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"ComparableFloat.cmp_abs(&ComparableFloat)\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(ComparableFloat(x).cmp_abs(&ComparableFloat(y)));\n            }),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(ComparableFloat(x.abs()).partial_cmp(&ComparableFloat(y.abs())));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_comparable_float_ref_cmp_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"ComparableFloatRef.cmp_abs(&ComparableFloatRef)\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(ComparableFloatRef(&x).cmp_abs(&ComparableFloatRef(&y)));\n            }),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(ComparableFloatRef(&x.abs()).partial_cmp(&ComparableFloatRef(&y.abs())));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_max_complexity_bucketer, pair_float_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_pair_gen, float_pair_gen_rm, float_pair_gen_var_10,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_eq);\n    register_demo!(runner, demo_float_eq_debug);\n    register_demo!(runner, demo_float_eq_extreme);\n    register_demo!(runner, demo_float_eq_extreme_debug);\n    register_demo!(runner, demo_comparable_float_eq);\n    register_demo!(runner, demo_comparable_float_eq_debug);\n    register_demo!(runner, demo_comparable_float_eq_extreme);\n    register_demo!(runner, demo_comparable_float_eq_extreme_debug);\n    register_demo!(runner, demo_comparable_float_ref_eq);\n    register_demo!(runner, demo_comparable_float_ref_eq_debug);\n\n    register_bench!(runner, benchmark_float_eq_library_comparison);\n    register_bench!(runner, benchmark_comparable_float_eq);\n    register_bench!(runner, benchmark_comparable_float_ref_eq);\n}\n\nfn demo_float_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_eq_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{cx:#x} = {cy:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_float_eq_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_eq_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{cx:#x} = {cy:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx == cy {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx == cy {\n            println!(\"{cx:#x} = {cy:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx == cy {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx == cy {\n            println!(\"{cx:#x} = {cy:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_comparable_float_ref_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if cx == cy {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_comparable_float_ref_eq_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if cx == cy {\n            println!(\"{cx:#x} = {cy:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float == Float\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_comparable_float_eq(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"ComparableFloat == ComparableFloat\",\n        BenchmarkType::Single,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(ComparableFloat(x) == ComparableFloat(y));\n        })],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_comparable_float_ref_eq(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"ComparableFloatRef == ComparableFloatRef\",\n        BenchmarkType::Single,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(ComparableFloatRef(&x) == ComparableFloatRef(&y));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::pair_float_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_pair_gen, float_pair_gen_var_10};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_eq_abs);\n    register_demo!(runner, demo_float_eq_abs_debug);\n    register_demo!(runner, demo_float_eq_abs_extreme);\n    register_demo!(runner, demo_float_eq_abs_extreme_debug);\n    register_demo!(runner, demo_comparable_float_eq_abs);\n    register_demo!(runner, demo_comparable_float_eq_abs_debug);\n    register_demo!(runner, demo_comparable_float_eq_abs_extreme);\n    register_demo!(runner, demo_comparable_float_eq_abs_extreme_debug);\n    register_demo!(runner, demo_comparable_float_ref_eq_abs);\n    register_demo!(runner, demo_comparable_float_ref_eq_abs_debug);\n\n    register_bench!(runner, benchmark_float_eq_abs_algorithms);\n    register_bench!(runner, benchmark_comparable_float_eq_abs_algorithms);\n    register_bench!(runner, benchmark_comparable_float_ref_eq_abs_algorithms);\n}\n\nfn demo_float_eq_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx.eq_abs(&cy) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq_abs_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx.eq_abs(&cy) {\n            println!(\"|{cx:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq_abs_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx.eq_abs(&cy) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_comparable_float_eq_abs_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x.clone());\n        let cy = ComparableFloat(y.clone());\n        if cx.eq_abs(&cy) {\n            println!(\"|{cx:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_comparable_float_ref_eq_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if cx.eq_abs(&cy) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_comparable_float_ref_eq_abs_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        if cx.eq_abs(&cy) {\n            println!(\"|{cx:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.eq_abs(&Float)\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_comparable_float_eq_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"ComparableFloat.eq_abs(&ComparableFloat)\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(ComparableFloat(x).eq_abs(&ComparableFloat(y)));\n            }),\n            (\"default\", &mut |(x, y)| {\n                no_out!(ComparableFloat(x.abs()) == ComparableFloat(y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_comparable_float_ref_eq_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"ComparableFloatRef.eq_abs(&ComparableFloatRef)\",\n        BenchmarkType::Algorithms,\n        float_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(ComparableFloatRef(&x).eq_abs(&ComparableFloatRef(&y)));\n            }),\n            (\"default\", &mut |(x, y)| {\n                no_out!(ComparableFloatRef(&x.abs()) == ComparableFloatRef(&y.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/eq_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_float_integer_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_integer_pair_gen, float_integer_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_eq_abs_integer);\n    register_demo!(runner, demo_float_eq_abs_integer_debug);\n    register_demo!(runner, demo_float_eq_abs_integer_extreme);\n    register_demo!(runner, demo_float_eq_abs_integer_extreme_debug);\n    register_demo!(runner, demo_integer_eq_abs_float);\n    register_demo!(runner, demo_integer_eq_abs_float_debug);\n    register_demo!(runner, demo_integer_eq_abs_float_extreme);\n    register_demo!(runner, demo_integer_eq_abs_float_extreme_debug);\n\n    register_bench!(runner, benchmark_float_eq_abs_integer_algorithms);\n    register_bench!(runner, benchmark_integer_eq_abs_float_algorithms);\n}\n\nfn demo_float_eq_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_integer_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:#x}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_integer_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_integer_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:#x}|\");\n        }\n    }\n}\n\nfn demo_integer_eq_abs_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_eq_abs_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_integer_eq_abs_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_eq_abs_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_abs_integer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.eq_abs(&Integer)\",\n        BenchmarkType::Algorithms,\n        float_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_integer_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_eq_abs_float_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_abs(&Float)\",\n        BenchmarkType::Algorithms,\n        float_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_integer_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(y, x)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_float_natural_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_natural_pair_gen, float_natural_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_eq_abs_natural);\n    register_demo!(runner, demo_float_eq_abs_natural_debug);\n    register_demo!(runner, demo_float_eq_abs_natural_extreme);\n    register_demo!(runner, demo_float_eq_abs_natural_extreme_debug);\n    register_demo!(runner, demo_natural_eq_abs_float);\n    register_demo!(runner, demo_natural_eq_abs_float_debug);\n    register_demo!(runner, demo_natural_eq_abs_float_extreme);\n    register_demo!(runner, demo_natural_eq_abs_float_extreme_debug);\n\n    register_bench!(runner, benchmark_float_eq_abs_natural_algorithms);\n    register_bench!(runner, benchmark_natural_eq_abs_float_algorithms);\n}\n\nfn demo_float_eq_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_natural_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:#x}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_natural_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_natural_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:#x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:#x}|\");\n        }\n    }\n}\n\nfn demo_natural_eq_abs_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_natural_eq_abs_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_natural_eq_abs_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_natural_eq_abs_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:#x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:#x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_abs_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.eq_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        float_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_natural_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_eq_abs_float_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_abs(&Float)\",\n        BenchmarkType::Algorithms,\n        float_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_natural_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(y, x)| no_out!(x == y.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::*;\nuse malachite_float::test_util::generators::{\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_eq_abs_primitive_float);\n    register_primitive_float_demos!(runner, demo_float_eq_abs_primitive_float_debug);\n    register_primitive_float_demos!(runner, demo_float_eq_abs_primitive_float_extreme);\n    register_primitive_float_demos!(runner, demo_float_eq_abs_primitive_float_extreme_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_eq_abs_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_eq_abs_float_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_eq_abs_float_extreme);\n    register_primitive_float_demos!(runner, demo_primitive_float_eq_abs_float_extreme_debug);\n\n    register_primitive_float_benches!(runner, benchmark_float_eq_abs_primitive_float_algorithms);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_eq_abs_float_algorithms);\n}\n\nfn demo_float_eq_abs_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{}| = |{}|\", x, NiceFloat(y));\n        } else {\n            println!(\"|{}| ≠ |{}|\", x, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_float_eq_abs_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{:#x}| = |{}|\", cx, NiceFloat(y));\n        } else {\n            println!(\"|{:#x}| ≠ |{}|\", cx, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_float_eq_abs_primitive_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{}| = |{}|\", x, NiceFloat(y));\n        } else {\n            println!(\"|{}| ≠ |{}|\", x, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_float_eq_abs_primitive_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{:#x}| = |{}|\", cx, NiceFloat(y));\n        } else {\n            println!(\"|{:#x}| ≠ |{}|\", cx, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_primitive_float_eq_abs_float<T: EqAbs<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{}| = |{}|\", NiceFloat(x), y);\n        } else {\n            println!(\"|{}| ≠ |{}|\", NiceFloat(x), y);\n        }\n    }\n}\n\nfn demo_primitive_float_eq_abs_float_debug<T: EqAbs<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{}| = |{:#x}|\", NiceFloat(x), cy);\n        } else {\n            println!(\"|{}| ≠ |{:#x}|\", NiceFloat(x), cy);\n        }\n    }\n}\n\nfn demo_primitive_float_eq_abs_float_extreme<T: EqAbs<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{}| = |{}|\", NiceFloat(x), y);\n        } else {\n            println!(\"|{}| ≠ |{}|\", NiceFloat(x), y);\n        }\n    }\n}\n\nfn demo_primitive_float_eq_abs_float_extreme_debug<T: EqAbs<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{}| = |{:#x}|\", NiceFloat(x), cy);\n        } else {\n            println!(\"|{}| ≠ |{:#x}|\", NiceFloat(x), cy);\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_abs_primitive_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: EqAbs<T> + PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Float.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_primitive_float_eq_abs_float_algorithms<\n    T: EqAbs<Float> + PartialEq<Float> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Float)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_float_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(y, x)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_float_signed_max_complexity_bucketer, pair_float_unsigned_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen, float_signed_pair_gen_var_4, float_unsigned_pair_gen,\n    float_unsigned_pair_gen_var_5,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_eq_abs_unsigned);\n    register_unsigned_demos!(runner, demo_float_eq_abs_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_eq_abs_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_eq_abs_unsigned_extreme_debug);\n    register_unsigned_demos!(runner, demo_unsigned_eq_abs_float);\n    register_unsigned_demos!(runner, demo_unsigned_eq_abs_float_debug);\n    register_unsigned_demos!(runner, demo_unsigned_eq_abs_float_extreme);\n    register_unsigned_demos!(runner, demo_unsigned_eq_abs_float_extreme_debug);\n    register_signed_demos!(runner, demo_float_eq_abs_signed);\n    register_signed_demos!(runner, demo_float_eq_abs_signed_debug);\n    register_signed_demos!(runner, demo_float_eq_abs_signed_extreme);\n    register_signed_demos!(runner, demo_float_eq_abs_signed_extreme_debug);\n    register_signed_demos!(runner, demo_signed_eq_abs_float);\n    register_signed_demos!(runner, demo_signed_eq_abs_float_debug);\n    register_signed_demos!(runner, demo_signed_eq_abs_float_extreme);\n    register_signed_demos!(runner, demo_signed_eq_abs_float_extreme_debug);\n\n    register_unsigned_benches!(runner, benchmark_float_eq_abs_unsigned_algorithms);\n    register_unsigned_benches!(runner, benchmark_unsigned_eq_abs_float_algorithms);\n    register_signed_benches!(runner, benchmark_float_eq_abs_signed_algorithms);\n    register_signed_benches!(runner, benchmark_signed_eq_abs_float_algorithms);\n}\n\nfn demo_float_eq_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:x}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:x}|\");\n        }\n    }\n}\n\nfn demo_unsigned_eq_abs_float<T: EqAbs<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_unsigned_eq_abs_float_debug<T: EqAbs<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_unsigned_eq_abs_float_extreme<T: EqAbs<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_unsigned_eq_abs_float_extreme_debug<T: EqAbs<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_signed_debug<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:x}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: EqAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y:x}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y:x}|\");\n        }\n    }\n}\n\nfn demo_signed_eq_abs_float<T: EqAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_signed_eq_abs_float_debug<T: EqAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_signed_eq_abs_float_extreme<T: EqAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_signed_eq_abs_float_extreme_debug<T: EqAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x:x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x:x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_abs_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: EqAbs<T> + PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Float.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_unsigned_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_unsigned_eq_abs_float_algorithms<\n    T: EqAbs<Float> + PartialEq<Float> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Float)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_unsigned_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(y, x)| no_out!(x == y.abs())),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: EqAbs<T> + PartialEq<<T as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"Float.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_signed_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs() == y.unsigned_abs());\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_signed_eq_abs_float_algorithms<T: EqAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PartialEq<Float>,\n{\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Float)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_signed_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(y, x)| {\n                no_out!(x.unsigned_abs() == y.abs());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/eq_abs_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::*;\nuse malachite_float::test_util::generators::{\n    float_rational_pair_gen, float_rational_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_eq_abs_rational);\n    register_demo!(runner, demo_float_eq_abs_rational_debug);\n    register_demo!(runner, demo_float_eq_abs_rational_extreme);\n    register_demo!(runner, demo_float_eq_abs_rational_extreme_debug);\n    register_demo!(runner, demo_rational_eq_abs_float);\n    register_demo!(runner, demo_rational_eq_abs_float_debug);\n    register_demo!(runner, demo_rational_eq_abs_float_extreme);\n    register_demo!(runner, demo_rational_eq_abs_float_extreme_debug);\n\n    register_bench!(runner, benchmark_float_eq_abs_rational_algorithms);\n    register_bench!(runner, benchmark_rational_eq_abs_float_algorithms);\n}\n\nfn demo_float_eq_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_float_eq_abs_rational_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x.eq_abs(&y) {\n            println!(\"|{cx:#x}| = |{y}|\");\n        } else {\n            println!(\"|{cx:#x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_eq_abs_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_eq_abs_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\nfn demo_rational_eq_abs_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_eq_abs_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{cy:#x}|\");\n        } else {\n            println!(\"|{x}| ≠ |{cy:#x}|\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_eq_abs_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.eq_abs(&Rational)\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_eq_abs_float_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.eq_abs(&Float)\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(y, x)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::hash::hash;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_comparable_float_hash);\n    register_demo!(runner, demo_comparable_float_hash_debug);\n    register_demo!(runner, demo_comparable_float_hash_extreme);\n    register_demo!(runner, demo_comparable_float_hash_extreme_debug);\n    register_demo!(runner, demo_comparable_float_ref_hash);\n    register_demo!(runner, demo_comparable_float_ref_hash_debug);\n\n    register_bench!(runner, benchmark_comparable_float_hash);\n    register_bench!(runner, benchmark_comparable_float_ref_hash);\n}\n\nfn demo_comparable_float_hash(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"hash({}) = {}\", x.clone(), hash(&ComparableFloat(x)));\n    }\n}\n\nfn demo_comparable_float_hash_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x);\n        println!(\"hash({:#x}) = {}\", cx, hash(&cx));\n    }\n}\n\nfn demo_comparable_float_hash_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"hash({}) = {}\", x.clone(), hash(&ComparableFloat(x)));\n    }\n}\n\nfn demo_comparable_float_hash_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        let cx = ComparableFloat(x);\n        println!(\"hash({:#x}) = {}\", cx, hash(&cx));\n    }\n}\n\nfn demo_comparable_float_ref_hash(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"hash({}) = {}\", x.clone(), hash(&ComparableFloatRef(&x)));\n    }\n}\n\nfn demo_comparable_float_ref_hash_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in float_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        println!(\"hash({:#x}) = {}\", cx, hash(&cx));\n    }\n}\n\nfn benchmark_comparable_float_hash(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float hash\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(hash(&ComparableFloat(x))))],\n    );\n}\n\nfn benchmark_comparable_float_ref_hash(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float hash\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(hash(&ComparableFloatRef(&x))))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    cmp::register(runner);\n    cmp_abs::register(runner);\n    eq::register(runner);\n    eq_abs::register(runner);\n    eq_abs_integer::register(runner);\n    eq_abs_natural::register(runner);\n    eq_abs_primitive_float::register(runner);\n    eq_abs_primitive_int::register(runner);\n    eq_abs_rational::register(runner);\n    hash::register(runner);\n    partial_cmp_abs_integer::register(runner);\n    partial_cmp_abs_natural::register(runner);\n    partial_cmp_abs_primitive_float::register(runner);\n    partial_cmp_abs_primitive_int::register(runner);\n    partial_cmp_abs_rational::register(runner);\n    partial_cmp_integer::register(runner);\n    partial_cmp_natural::register(runner);\n    partial_cmp_primitive_float::register(runner);\n    partial_cmp_primitive_int::register(runner);\n    partial_cmp_rational::register(runner);\n    partial_eq_integer::register(runner);\n    partial_eq_natural::register(runner);\n    partial_eq_primitive_float::register(runner);\n    partial_eq_primitive_int::register(runner);\n    partial_eq_rational::register(runner);\n}\n\nmod cmp;\nmod cmp_abs;\nmod eq;\nmod eq_abs;\nmod eq_abs_integer;\nmod eq_abs_natural;\nmod eq_abs_primitive_float;\nmod eq_abs_primitive_int;\nmod eq_abs_rational;\nmod hash;\nmod partial_cmp_abs_integer;\nmod partial_cmp_abs_natural;\nmod partial_cmp_abs_primitive_float;\nmod partial_cmp_abs_primitive_int;\nmod partial_cmp_abs_rational;\nmod partial_cmp_integer;\nmod partial_cmp_natural;\nmod partial_cmp_primitive_float;\nmod partial_cmp_primitive_int;\nmod partial_cmp_rational;\nmod partial_eq_integer;\nmod partial_eq_natural;\nmod partial_eq_primitive_float;\nmod partial_eq_primitive_int;\nmod partial_eq_rational;\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_float_integer_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_integer_pair_gen, float_integer_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp_abs_integer);\n    register_demo!(runner, demo_float_partial_cmp_abs_integer_debug);\n    register_demo!(runner, demo_float_partial_cmp_abs_integer_extreme);\n    register_demo!(runner, demo_float_partial_cmp_abs_integer_extreme_debug);\n    register_demo!(runner, demo_integer_partial_cmp_abs_float);\n    register_demo!(runner, demo_integer_partial_cmp_abs_float_debug);\n    register_demo!(runner, demo_integer_partial_cmp_abs_float_extreme);\n    register_demo!(runner, demo_integer_partial_cmp_abs_float_extreme_debug);\n\n    register_bench!(runner, benchmark_float_partial_cmp_abs_integer_algorithms);\n    register_bench!(runner, benchmark_integer_partial_cmp_abs_float_algorithms);\n}\n\nfn demo_float_partial_cmp_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_integer_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_integer_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_integer_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_abs_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_abs_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_abs_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_abs_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_integer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.partial_cmp_abs(&Integer)\",\n        BenchmarkType::Algorithms,\n        float_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_integer_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_partial_cmp_abs_float_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.partial_cmp_abs(&Float)\",\n        BenchmarkType::Algorithms,\n        float_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_integer_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(y, x)| {\n                no_out!(x.abs().partial_cmp_abs(&y.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_float_natural_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_natural_pair_gen, float_natural_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp_abs_natural);\n    register_demo!(runner, demo_float_partial_cmp_abs_natural_debug);\n    register_demo!(runner, demo_float_partial_cmp_abs_natural_extreme);\n    register_demo!(runner, demo_float_partial_cmp_abs_natural_extreme_debug);\n    register_demo!(runner, demo_natural_partial_cmp_abs_float);\n    register_demo!(runner, demo_natural_partial_cmp_abs_float_debug);\n    register_demo!(runner, demo_natural_partial_cmp_abs_float_extreme);\n    register_demo!(runner, demo_natural_partial_cmp_abs_float_extreme_debug);\n\n    register_bench!(runner, benchmark_float_partial_cmp_abs_natural_algorithms);\n    register_bench!(runner, benchmark_natural_partial_cmp_abs_float_algorithms);\n}\n\nfn demo_float_partial_cmp_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_natural_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_natural_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_natural_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_abs_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_abs_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_abs_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_abs_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.partial_cmp_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        float_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_natural_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs().partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_partial_cmp_abs_float_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp_abs(&Float)\",\n        BenchmarkType::Algorithms,\n        float_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_natural_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(y, x)| no_out!(x.partial_cmp(&y.abs()))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::*;\nuse malachite_float::test_util::generators::{\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_var_1,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_abs_primitive_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_abs_primitive_float_debug);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_abs_primitive_float_extreme);\n    register_primitive_float_demos!(\n        runner,\n        demo_float_partial_cmp_abs_primitive_float_extreme_debug\n    );\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_cmp_abs_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_cmp_abs_float_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_cmp_abs_float_extreme);\n    register_primitive_float_demos!(\n        runner,\n        demo_primitive_float_partial_cmp_abs_float_extreme_debug\n    );\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_cmp_abs_primitive_float_algorithms\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_primitive_float_partial_cmp_abs_float_algorithms\n    );\n}\n\nfn demo_float_partial_cmp_abs_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{}| and |{}| are incomparable\", x, NiceFloat(y)),\n            Some(Less) => println!(\"|{}| < |{}|\", x, NiceFloat(y)),\n            Some(Equal) => println!(\"|{}| = |{}|\", x, NiceFloat(y)),\n            Some(Greater) => println!(\"|{}| > |{}|\", x, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"{:#x} and |{}| are incomparable\", cx, NiceFloat(y)),\n            Some(Less) => println!(\"{:#x} < |{}|\", cx, NiceFloat(y)),\n            Some(Equal) => println!(\"{:#x} = |{}|\", cx, NiceFloat(y)),\n            Some(Greater) => println!(\"{:#x} > |{}|\", cx, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_primitive_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{}| and |{}| are incomparable\", x, NiceFloat(y)),\n            Some(Less) => println!(\"|{}| < |{}|\", x, NiceFloat(y)),\n            Some(Equal) => println!(\"|{}| = |{}|\", x, NiceFloat(y)),\n            Some(Greater) => println!(\"|{}| > |{}|\", x, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_primitive_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"{:#x} and |{}| are incomparable\", cx, NiceFloat(y)),\n            Some(Less) => println!(\"{:#x} < |{}|\", cx, NiceFloat(y)),\n            Some(Equal) => println!(\"{:#x} = |{}|\", cx, NiceFloat(y)),\n            Some(Greater) => println!(\"{:#x} > |{}|\", cx, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_abs_float<T: PartialOrdAbs<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{}| and |{}| are incomparable\", NiceFloat(x), y),\n            Some(Less) => println!(\"|{}| < |{}|\", NiceFloat(x), y),\n            Some(Equal) => println!(\"|{}| = |{}|\", NiceFloat(x), y),\n            Some(Greater) => println!(\"|{}| > |{}|\", NiceFloat(x), y),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_abs_float_debug<T: PartialOrdAbs<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{}| and {:#x} are incomparable\", NiceFloat(x), cy),\n            Some(Less) => println!(\"|{}| < {:#x}\", NiceFloat(x), cy),\n            Some(Equal) => println!(\"|{}| = {:#x}\", NiceFloat(x), cy),\n            Some(Greater) => println!(\"|{}| > {:#x}\", NiceFloat(x), cy),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_abs_float_extreme<T: PartialOrdAbs<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{}| and |{}| are incomparable\", NiceFloat(x), y),\n            Some(Less) => println!(\"|{}| < |{}|\", NiceFloat(x), y),\n            Some(Equal) => println!(\"|{}| = |{}|\", NiceFloat(x), y),\n            Some(Greater) => println!(\"|{}| > |{}|\", NiceFloat(x), y),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_abs_float_extreme_debug<\n    T: PartialOrdAbs<Float> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{}| and {:#x} are incomparable\", NiceFloat(x), cy),\n            Some(Less) => println!(\"|{}| < {:#x}\", NiceFloat(x), cy),\n            Some(Equal) => println!(\"|{}| = {:#x}\", NiceFloat(x), cy),\n            Some(Greater) => println!(\"|{}| > {:#x}\", NiceFloat(x), cy),\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_cmp_abs_primitive_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrdAbs<T> + PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_primitive_float_partial_cmp_abs_float_algorithms<\n    T: PartialOrdAbs<Float> + PartialOrd<Float> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Float)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_primitive_float_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(y, x)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_signed_max_complexity_bucketer,\n    pair_2_pair_float_unsigned_max_complexity_bucketer, pair_float_signed_max_complexity_bucketer,\n    pair_float_unsigned_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen, float_signed_pair_gen_rm, float_signed_pair_gen_var_4,\n    float_unsigned_pair_gen, float_unsigned_pair_gen_rm, float_unsigned_pair_gen_var_5,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_partial_cmp_abs_unsigned);\n    register_unsigned_demos!(runner, demo_float_partial_cmp_abs_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_partial_cmp_abs_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_partial_cmp_abs_unsigned_extreme_debug);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_abs_float);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_abs_float_debug);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_abs_float_extreme);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_abs_float_extreme_debug);\n    register_signed_demos!(runner, demo_float_partial_cmp_abs_signed);\n    register_signed_demos!(runner, demo_float_partial_cmp_abs_signed_debug);\n    register_signed_demos!(runner, demo_float_partial_cmp_abs_signed_extreme);\n    register_signed_demos!(runner, demo_float_partial_cmp_abs_signed_extreme_debug);\n    register_signed_demos!(runner, demo_signed_partial_cmp_abs_float);\n    register_signed_demos!(runner, demo_signed_partial_cmp_abs_float_debug);\n    register_signed_demos!(runner, demo_signed_partial_cmp_abs_float_extreme);\n    register_signed_demos!(runner, demo_signed_partial_cmp_abs_float_extreme_debug);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_partial_cmp_abs_unsigned_library_comparison\n    );\n    register_unsigned_benches!(runner, benchmark_float_partial_cmp_abs_unsigned_algorithms);\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_cmp_abs_float_library_comparison\n    );\n    register_unsigned_benches!(runner, benchmark_unsigned_partial_cmp_abs_float_algorithms);\n    register_signed_benches!(\n        runner,\n        benchmark_float_partial_cmp_abs_signed_library_comparison\n    );\n    register_signed_benches!(runner, benchmark_float_partial_cmp_abs_signed_algorithms);\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_cmp_abs_float_library_comparison\n    );\n    register_signed_benches!(runner, benchmark_signed_partial_cmp_abs_float_algorithms);\n}\n\nfn demo_float_partial_cmp_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_abs_float<T: PartialOrdAbs<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_abs_float_debug<T: PartialOrdAbs<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_abs_float_extreme<T: PartialOrdAbs<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_abs_float_extreme_debug<\n    T: PartialOrdAbs<Float> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:#x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrdAbs<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y:#x}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y:#x}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y:#x}|\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_abs_float<T: PartialOrdAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_abs_float_debug<T: PartialOrdAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_abs_float_extreme<T: PartialOrdAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_abs_float_extreme_debug<T: PartialOrdAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x:x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x:#x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x:#x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x:#x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_cmp_abs_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrdAbs<T>,\n    rug::Float: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_unsigned_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.abs().partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrdAbs<T> + PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_unsigned_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs().partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_unsigned_partial_cmp_abs_float_library_comparison<\n    T: PartialOrdAbs<Float> + PartialOrd<rug::Float> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Float)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_unsigned_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"rug\", &mut |((y, x), _)| no_out!(x.partial_cmp(&y.abs()))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_partial_cmp_abs_float_algorithms<\n    T: PartialOrdAbs<Float> + PartialOrd<Float> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Float)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_unsigned_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(y, x)| no_out!(x.partial_cmp(&y.abs()))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_cmp_abs_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrdAbs<T>,\n    rug::Float: PartialOrd<<T as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_signed_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"rug\", &mut |((x, y), _)| {\n                no_out!(x.abs().partial_cmp(&y.unsigned_abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrdAbs<T> + PartialOrd<<T as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_signed_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.unsigned_abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_signed_partial_cmp_abs_float_library_comparison<\n    T: PartialOrdAbs<Float> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PartialOrd<rug::Float>,\n{\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Float)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_signed_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"rug\", &mut |((y, x), _)| {\n                no_out!(x.unsigned_abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_partial_cmp_abs_float_algorithms<T: PartialOrdAbs<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PartialOrd<Float>,\n{\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Float)\", T::NAME),\n        BenchmarkType::Algorithms,\n        float_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_signed_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(y, x)| {\n                no_out!(x.unsigned_abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_float_rational_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_rational_pair_gen, float_rational_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp_abs_rational);\n    register_demo!(runner, demo_float_partial_cmp_abs_rational_debug);\n    register_demo!(runner, demo_float_partial_cmp_abs_rational_extreme);\n    register_demo!(runner, demo_float_partial_cmp_abs_rational_extreme_debug);\n    register_demo!(runner, demo_rational_partial_cmp_abs_float);\n    register_demo!(runner, demo_rational_partial_cmp_abs_float_debug);\n    register_demo!(runner, demo_rational_partial_cmp_abs_float_extreme);\n    register_demo!(runner, demo_rational_partial_cmp_abs_float_extreme_debug);\n\n    register_bench!(runner, benchmark_float_partial_cmp_abs_rational_algorithms);\n    register_bench!(runner, benchmark_rational_partial_cmp_abs_float_algorithms);\n}\n\nfn demo_float_partial_cmp_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_rational_extreme_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{cx:#x}| and {y} are incomparable\"),\n            Some(Less) => println!(\"|{cx:#x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{cx:#x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{cx:#x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_abs_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_abs_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_abs_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{y}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{y}|\"),\n            Some(Equal) => println!(\"|{x}| = |{y}|\"),\n            Some(Greater) => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_abs_float_extreme_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp_abs(&y) {\n            None => println!(\"|{x}| and |{cy:#x}| are incomparable\"),\n            Some(Less) => println!(\"|{x}| < |{cy:#x}|\"),\n            Some(Equal) => println!(\"|{x}| = |{cy:#x}|\"),\n            Some(Greater) => println!(\"|{x}| > |{cy:#x}|\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.partial_cmp_abs(&Rational)\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_partial_cmp_abs_float_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.partial_cmp_abs(&Float)\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"default\", &mut |(y, x)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(y, x)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_2_pair_float_integer_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_integer_pair_gen, float_integer_pair_gen_rm, float_integer_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp_integer);\n    register_demo!(runner, demo_float_partial_cmp_integer_debug);\n    register_demo!(runner, demo_float_partial_cmp_integer_extreme);\n    register_demo!(runner, demo_float_partial_cmp_integer_extreme_debug);\n    register_demo!(runner, demo_integer_partial_cmp_float);\n    register_demo!(runner, demo_integer_partial_cmp_float_debug);\n    register_demo!(runner, demo_integer_partial_cmp_float_extreme);\n    register_demo!(runner, demo_integer_partial_cmp_float_extreme_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_partial_cmp_integer_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_partial_cmp_float_library_comparison\n    );\n}\n\nfn demo_float_partial_cmp_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_integer_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_integer_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_integer_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.partial_cmp(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        float_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_integer_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_partial_cmp_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.partial_cmp(&Float)\",\n        BenchmarkType::LibraryComparison,\n        float_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_integer_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_2_pair_float_natural_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_natural_pair_gen, float_natural_pair_gen_rm, float_natural_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp_natural);\n    register_demo!(runner, demo_float_partial_cmp_natural_debug);\n    register_demo!(runner, demo_float_partial_cmp_natural_extreme);\n    register_demo!(runner, demo_float_partial_cmp_natural_extreme_debug);\n    register_demo!(runner, demo_natural_partial_cmp_float);\n    register_demo!(runner, demo_natural_partial_cmp_float_debug);\n    register_demo!(runner, demo_natural_partial_cmp_float_extreme);\n    register_demo!(runner, demo_natural_partial_cmp_float_extreme_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_partial_cmp_natural_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_partial_cmp_float_library_comparison\n    );\n}\n\nfn demo_float_partial_cmp_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_natural_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_natural_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_natural_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.partial_cmp(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        float_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_natural_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_partial_cmp_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp(&Float)\",\n        BenchmarkType::LibraryComparison,\n        float_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_natural_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::*;\nuse malachite_float::test_util::generators::{\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_rm,\n    float_primitive_float_pair_gen_var_1,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_primitive_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_primitive_float_debug);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_primitive_float_extreme);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_primitive_float_extreme_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_cmp_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_cmp_float_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_cmp_float_extreme);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_cmp_float_extreme_debug);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_cmp_primitive_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_primitive_float_partial_cmp_float_library_comparison\n    );\n}\n\nfn demo_float_partial_cmp_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{} and {} are incomparable\", x, NiceFloat(y)),\n            Some(Less) => println!(\"{} < {}\", x, NiceFloat(y)),\n            Some(Equal) => println!(\"{} = {}\", x, NiceFloat(y)),\n            Some(Greater) => println!(\"{} > {}\", x, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{:#x} and {} are incomparable\", cx, NiceFloat(y)),\n            Some(Less) => println!(\"{:#x} < {}\", cx, NiceFloat(y)),\n            Some(Equal) => println!(\"{:#x} = {}\", cx, NiceFloat(y)),\n            Some(Greater) => println!(\"{:#x} > {}\", cx, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_primitive_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{} and {} are incomparable\", x, NiceFloat(y)),\n            Some(Less) => println!(\"{} < {}\", x, NiceFloat(y)),\n            Some(Equal) => println!(\"{} = {}\", x, NiceFloat(y)),\n            Some(Greater) => println!(\"{} > {}\", x, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_primitive_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{:#x} and {} are incomparable\", cx, NiceFloat(y)),\n            Some(Less) => println!(\"{:#x} < {}\", cx, NiceFloat(y)),\n            Some(Equal) => println!(\"{:#x} = {}\", cx, NiceFloat(y)),\n            Some(Greater) => println!(\"{:#x} > {}\", cx, NiceFloat(y)),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_float<T: PartialOrd<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{} and {} are incomparable\", NiceFloat(x), y),\n            Some(Less) => println!(\"{} < {}\", NiceFloat(x), y),\n            Some(Equal) => println!(\"{} = {}\", NiceFloat(x), y),\n            Some(Greater) => println!(\"{} > {}\", NiceFloat(x), y),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_float_debug<T: PartialOrd<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{} and {:#x} are incomparable\", NiceFloat(x), cy),\n            Some(Less) => println!(\"{} < {:#x}\", NiceFloat(x), cy),\n            Some(Equal) => println!(\"{} = {:#x}\", NiceFloat(x), cy),\n            Some(Greater) => println!(\"{} > {:#x}\", NiceFloat(x), cy),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_float_extreme<T: PartialOrd<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{} and {} are incomparable\", NiceFloat(x), y),\n            Some(Less) => println!(\"{} < {}\", NiceFloat(x), y),\n            Some(Equal) => println!(\"{} = {}\", NiceFloat(x), y),\n            Some(Greater) => println!(\"{} > {}\", NiceFloat(x), y),\n        }\n    }\n}\n\nfn demo_primitive_float_partial_cmp_float_extreme_debug<T: PartialOrd<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{} and {:#x} are incomparable\", NiceFloat(x), cy),\n            Some(Less) => println!(\"{} < {:#x}\", NiceFloat(x), cy),\n            Some(Equal) => println!(\"{} = {:#x}\", NiceFloat(x), cy),\n            Some(Greater) => println!(\"{} > {:#x}\", NiceFloat(x), cy),\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_cmp_primitive_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_primitive_float_partial_cmp_float_library_comparison<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Float)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_float_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((y, x), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_signed_max_complexity_bucketer,\n    pair_2_pair_float_unsigned_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen, float_signed_pair_gen_rm, float_signed_pair_gen_var_4,\n    float_unsigned_pair_gen, float_unsigned_pair_gen_rm, float_unsigned_pair_gen_var_5,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_partial_cmp_unsigned);\n    register_unsigned_demos!(runner, demo_float_partial_cmp_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_partial_cmp_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_partial_cmp_unsigned_extreme_debug);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_float);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_float_debug);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_float_extreme);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_float_extreme_debug);\n    register_signed_demos!(runner, demo_float_partial_cmp_signed);\n    register_signed_demos!(runner, demo_float_partial_cmp_signed_debug);\n    register_signed_demos!(runner, demo_float_partial_cmp_signed_extreme);\n    register_signed_demos!(runner, demo_float_partial_cmp_signed_extreme_debug);\n    register_signed_demos!(runner, demo_signed_partial_cmp_float);\n    register_signed_demos!(runner, demo_signed_partial_cmp_float_debug);\n    register_signed_demos!(runner, demo_signed_partial_cmp_float_extreme);\n    register_signed_demos!(runner, demo_signed_partial_cmp_float_extreme_debug);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_partial_cmp_unsigned_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_cmp_float_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_float_partial_cmp_signed_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_cmp_float_library_comparison\n    );\n}\n\nfn demo_float_partial_cmp_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_float<T: PartialOrd<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_float_debug<T: PartialOrd<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_float_extreme<T: PartialOrd<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_float_extreme_debug<T: PartialOrd<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y:#x} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y:#x}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y:#x}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y:#x}\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_float<T: PartialOrd<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_float_debug<T: PartialOrd<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_float_extreme<T: PartialOrd<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_float_extreme_debug<T: PartialOrd<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x:x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x:#x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x:#x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x:#x} > {cy:#x}\"),\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_cmp_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_unsigned_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_unsigned_partial_cmp_float_library_comparison<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Float)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_unsigned_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((y, x), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_cmp_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Float.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_signed_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_signed_partial_cmp_float_library_comparison<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Float)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_signed_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((y, x), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_cmp_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_rational_max_complexity_bucketer, pair_float_rational_max_complexity_bucketer,\n};\nuse malachite_float::test_util::comparison::partial_cmp_rational::float_partial_cmp_rational_alt;\nuse malachite_float::test_util::generators::{\n    float_rational_pair_gen, float_rational_pair_gen_rm, float_rational_pair_gen_var_2,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_cmp_rational);\n    register_demo!(runner, demo_float_partial_cmp_rational_debug);\n    register_demo!(runner, demo_float_partial_cmp_rational_extreme);\n    register_demo!(runner, demo_float_partial_cmp_rational_extreme_debug);\n    register_demo!(runner, demo_rational_partial_cmp_float);\n    register_demo!(runner, demo_rational_partial_cmp_float_debug);\n    register_demo!(runner, demo_rational_partial_cmp_float_extreme);\n    register_demo!(runner, demo_rational_partial_cmp_float_extreme_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_partial_cmp_rational_library_comparison\n    );\n    register_bench!(runner, benchmark_float_partial_cmp_rational_algorithms);\n    register_bench!(\n        runner,\n        benchmark_rational_partial_cmp_float_library_comparison\n    );\n}\n\nfn demo_float_partial_cmp_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_rational_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        match x.partial_cmp(&y) {\n            None => println!(\"{cx:#x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{cx:#x} < {y}\"),\n            Some(Equal) => println!(\"{cx:#x} = {y}\"),\n            Some(Greater) => println!(\"{cx:#x} > {y}\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x} > {cy:#x}\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {y} are incomparable\"),\n            Some(Less) => println!(\"{x} < {y}\"),\n            Some(Equal) => println!(\"{x} = {y}\"),\n            Some(Greater) => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        match x.partial_cmp(&y) {\n            None => println!(\"{x} and {cy:#x} are incomparable\"),\n            Some(Less) => println!(\"{x} < {cy:#x}\"),\n            Some(Equal) => println!(\"{x} = {cy:#x}\"),\n            Some(Greater) => println!(\"{x} > {cy:#x}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.partial_cmp(&Rational)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.partial_cmp(&Rational)\",\n        BenchmarkType::Algorithms,\n        float_rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp(&y))),\n            (\"alt\", &mut |(x, y)| {\n                no_out!(float_partial_cmp_rational_alt(&x, &y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_partial_cmp_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.partial_cmp(&Float)\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_eq_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_2_pair_float_integer_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_integer_pair_gen, float_integer_pair_gen_rm, float_integer_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_eq_integer);\n    register_demo!(runner, demo_float_partial_eq_integer_debug);\n    register_demo!(runner, demo_float_partial_eq_integer_extreme);\n    register_demo!(runner, demo_float_partial_eq_integer_extreme_debug);\n    register_demo!(runner, demo_integer_partial_eq_float);\n    register_demo!(runner, demo_integer_partial_eq_float_debug);\n    register_demo!(runner, demo_integer_partial_eq_float_extreme);\n    register_demo!(runner, demo_integer_partial_eq_float_extreme_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_partial_eq_integer_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_partial_eq_float_library_comparison\n    );\n}\n\nfn demo_float_partial_eq_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_integer_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:#x}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_integer_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_integer_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:#x}\");\n        }\n    }\n}\n\nfn demo_integer_partial_eq_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_integer_partial_eq_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:#x} = {cy:#x}\");\n        } else {\n            println!(\"{x:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_integer_partial_eq_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_integer_partial_eq_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:#x} = {cy:#x}\");\n        } else {\n            println!(\"{x:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_eq_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float == Integer\",\n        BenchmarkType::LibraryComparison,\n        float_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_integer_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_partial_eq_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer == Float\",\n        BenchmarkType::LibraryComparison,\n        float_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_integer_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::pair_2_pair_float_natural_max_complexity_bucketer;\nuse malachite_float::test_util::generators::{\n    float_natural_pair_gen, float_natural_pair_gen_rm, float_natural_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_eq_natural);\n    register_demo!(runner, demo_float_partial_eq_natural_debug);\n    register_demo!(runner, demo_float_partial_eq_natural_extreme);\n    register_demo!(runner, demo_float_partial_eq_natural_extreme_debug);\n    register_demo!(runner, demo_natural_partial_eq_float);\n    register_demo!(runner, demo_natural_partial_eq_float_debug);\n    register_demo!(runner, demo_natural_partial_eq_float_extreme);\n    register_demo!(runner, demo_natural_partial_eq_float_extreme_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_partial_eq_natural_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_partial_eq_float_library_comparison\n    );\n}\n\nfn demo_float_partial_eq_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_natural_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:#x}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_natural_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_natural_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:#x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:#x}\");\n        }\n    }\n}\n\nfn demo_natural_partial_eq_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_natural_partial_eq_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:#x} = {cy:#x}\");\n        } else {\n            println!(\"{x:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_natural_partial_eq_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_natural_partial_eq_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_natural_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:#x} = {cy:#x}\");\n        } else {\n            println!(\"{x:#x} ≠ {cy:#x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_eq_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float == Natural\",\n        BenchmarkType::LibraryComparison,\n        float_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_natural_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_partial_eq_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural == Float\",\n        BenchmarkType::LibraryComparison,\n        float_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_natural_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::*;\nuse malachite_float::test_util::generators::{\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_rm,\n    float_primitive_float_pair_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_partial_eq_primitive_float);\n    register_primitive_float_demos!(runner, demo_float_partial_eq_primitive_float_debug);\n    register_primitive_float_demos!(runner, demo_float_partial_eq_primitive_float_extreme);\n    register_primitive_float_demos!(runner, demo_float_partial_eq_primitive_float_extreme_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_eq_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_eq_float_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_eq_float_extreme);\n    register_primitive_float_demos!(runner, demo_primitive_float_partial_eq_float_extreme_debug);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_eq_primitive_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_primitive_float_partial_eq_float_library_comparison\n    );\n}\n\nfn demo_float_partial_eq_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{} = {}\", x, NiceFloat(y));\n        } else {\n            println!(\"{} ≠ {}\", x, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_float_partial_eq_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{:#x} = {}\", cx, NiceFloat(y));\n        } else {\n            println!(\"{:#x} ≠ {}\", cx, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_float_partial_eq_primitive_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{} = {}\", x, NiceFloat(y));\n        } else {\n            println!(\"{} ≠ {}\", x, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_float_partial_eq_primitive_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{:#x} = {}\", cx, NiceFloat(y));\n        } else {\n            println!(\"{:#x} ≠ {}\", cx, NiceFloat(y));\n        }\n    }\n}\n\nfn demo_primitive_float_partial_eq_float<T: PartialEq<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{} = {}\", NiceFloat(x), y);\n        } else {\n            println!(\"{} ≠ {}\", NiceFloat(x), y);\n        }\n    }\n}\n\nfn demo_primitive_float_partial_eq_float_debug<T: PartialEq<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{} = {:#x}\", NiceFloat(x), cy);\n        } else {\n            println!(\"{} ≠ {:#x}\", NiceFloat(x), cy);\n        }\n    }\n}\n\nfn demo_primitive_float_partial_eq_float_extreme<T: PartialEq<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{} = {}\", NiceFloat(x), y);\n        } else {\n            println!(\"{} ≠ {}\", NiceFloat(x), y);\n        }\n    }\n}\n\nfn demo_primitive_float_partial_eq_float_extreme_debug<T: PartialEq<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_primitive_float_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{} = {:#x}\", NiceFloat(x), cy);\n        } else {\n            println!(\"{} ≠ {:#x}\", NiceFloat(x), cy);\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_eq_primitive_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialEq<T>,\n    rug::Float: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Float == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_primitive_float_partial_eq_float_library_comparison<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Float\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_primitive_float_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::Float;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_pair_float_signed_max_complexity_bucketer,\n    pair_2_pair_float_unsigned_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen, float_signed_pair_gen_rm, float_signed_pair_gen_var_4,\n    float_unsigned_pair_gen, float_unsigned_pair_gen_rm, float_unsigned_pair_gen_var_5,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_partial_eq_unsigned);\n    register_unsigned_demos!(runner, demo_float_partial_eq_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_partial_eq_unsigned_extreme);\n    register_unsigned_demos!(runner, demo_float_partial_eq_unsigned_extreme_debug);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_float);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_float_debug);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_float_extreme);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_float_extreme_debug);\n    register_signed_demos!(runner, demo_float_partial_eq_signed);\n    register_signed_demos!(runner, demo_float_partial_eq_signed_debug);\n    register_signed_demos!(runner, demo_float_partial_eq_signed_extreme);\n    register_signed_demos!(runner, demo_float_partial_eq_signed_extreme_debug);\n    register_signed_demos!(runner, demo_signed_partial_eq_float);\n    register_signed_demos!(runner, demo_signed_partial_eq_float_debug);\n    register_signed_demos!(runner, demo_signed_partial_eq_float_extreme);\n    register_signed_demos!(runner, demo_signed_partial_eq_float_extreme_debug);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_partial_eq_unsigned_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_eq_float_library_comparison\n    );\n    register_signed_benches!(runner, benchmark_float_partial_eq_signed_library_comparison);\n    register_signed_benches!(runner, benchmark_signed_partial_eq_float_library_comparison);\n}\n\nfn demo_float_partial_eq_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:x}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_unsigned_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_unsigned_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:x}\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_float<T: PartialEq<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_float_debug<T: PartialEq<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:x} = {cy:#x}\");\n        } else {\n            println!(\"{x:x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_float_extreme<T: PartialEq<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_float_extreme_debug<T: PartialEq<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_unsigned_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:x} = {cy:#x}\");\n        } else {\n            println!(\"{x:x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_signed_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:x}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_signed_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_signed_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialEq<T>,\n{\n    for (x, y) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y:x}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y:x}\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_float<T: PartialEq<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_float_debug<T: PartialEq<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:x} = {cy:#x}\");\n        } else {\n            println!(\"{x:x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_float_extreme<T: PartialEq<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_float_extreme_debug<T: PartialEq<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (y, x) in float_signed_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x:x} = {cy:#x}\");\n        } else {\n            println!(\"{x:x} ≠ {cy:#x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_eq_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialEq<T>,\n    rug::Float: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Float == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_unsigned_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_unsigned_partial_eq_float_library_comparison<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Float\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_unsigned_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_eq_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: PartialEq<T>,\n    rug::Float: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Float == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_signed_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_signed_partial_eq_float_library_comparison<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Float\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        float_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_signed_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/comparison/partial_eq_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::bench::bucketers::*;\nuse malachite_float::test_util::generators::{\n    float_rational_pair_gen, float_rational_pair_gen_rm, float_rational_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_partial_eq_rational);\n    register_demo!(runner, demo_float_partial_eq_rational_debug);\n    register_demo!(runner, demo_float_partial_eq_rational_extreme);\n    register_demo!(runner, demo_float_partial_eq_rational_extreme_debug);\n    register_demo!(runner, demo_rational_partial_eq_float);\n    register_demo!(runner, demo_rational_partial_eq_float_debug);\n    register_demo!(runner, demo_rational_partial_eq_float_extreme);\n    register_demo!(runner, demo_rational_partial_eq_float_extreme_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_partial_eq_rational_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_partial_eq_float_library_comparison\n    );\n}\n\nfn demo_float_partial_eq_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_rational_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_float_partial_eq_rational_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cx = ComparableFloatRef(&x);\n        if x == y {\n            println!(\"{cx:#x} = {y}\");\n        } else {\n            println!(\"{cx:#x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_rational_partial_eq_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_rational_partial_eq_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x} = {cy:#x}\");\n        } else {\n            println!(\"{x} ≠ {cy:#x}\");\n        }\n    }\n}\n\nfn demo_rational_partial_eq_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_rational_partial_eq_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (y, x) in float_rational_pair_gen_var_2().get(gm, config).take(limit) {\n        let cy = ComparableFloatRef(&y);\n        if x == y {\n            println!(\"{x} = {cy:#x}\");\n        } else {\n            println!(\"{x} ≠ {cy:#x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_float_partial_eq_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float == Rational\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_partial_eq_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational == Float\",\n        BenchmarkType::LibraryComparison,\n        float_rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_rational_max_complexity_bucketer(\"y\", \"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (y, x))| no_out!(x == y)),\n            (\"rug\", &mut |((y, x), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/gauss_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_gauss_constant_prec_round);\n    register_demo!(runner, demo_float_gauss_constant_prec_round_debug);\n    register_demo!(runner, demo_float_gauss_constant_prec);\n    register_demo!(runner, demo_float_gauss_constant_prec_debug);\n\n    register_bench!(runner, benchmark_float_gauss_constant_prec_round);\n    register_bench!(runner, benchmark_float_gauss_constant_prec);\n}\n\nfn demo_float_gauss_constant_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"gauss_constant_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::gauss_constant_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_gauss_constant_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::gauss_constant_prec_round(p, rm);\n        println!(\n            \"gauss_constant_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_gauss_constant_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"gauss_constant_prec({}) = {:?}\",\n            p,\n            Float::gauss_constant_prec(p)\n        );\n    }\n}\n\nfn demo_float_gauss_constant_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::gauss_constant_prec(p);\n        println!(\n            \"gauss_constant_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_gauss_constant_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::gauss_constant_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::gauss_constant_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_gauss_constant_prec(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::gauss_constant_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::gauss_constant_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/lemniscate_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::lemniscate_constant::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_lemniscate_constant_prec_round);\n    register_demo!(runner, demo_float_lemniscate_constant_prec_round_debug);\n    register_demo!(runner, demo_float_lemniscate_constant_prec);\n    register_demo!(runner, demo_float_lemniscate_constant_prec_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_lemniscate_constant_prec_round_algorithms\n    );\n    register_bench!(runner, benchmark_float_lemniscate_constant_prec_algorithms);\n}\n\nfn demo_float_lemniscate_constant_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"lemniscate_constant_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::lemniscate_constant_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_lemniscate_constant_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::lemniscate_constant_prec_round(p, rm);\n        println!(\n            \"lemniscate_constant_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_lemniscate_constant_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"lemniscate_constant_prec({}) = {:?}\",\n            p,\n            Float::lemniscate_constant_prec(p)\n        );\n    }\n}\n\nfn demo_float_lemniscate_constant_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::lemniscate_constant_prec(p);\n        println!(\n            \"lemniscate_constant_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_lemniscate_constant_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::lemniscate_constant_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::lemniscate_constant_prec_round(p, rm));\n            }),\n            (\"simple\", &mut |(p, rm)| {\n                no_out!(lemniscate_constant_prec_round_simple(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_lemniscate_constant_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::lemniscate_constant_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| {\n                no_out!(Float::lemniscate_constant_prec(p));\n            }),\n            (\"simple\", &mut |p| {\n                no_out!(lemniscate_constant_prec_round_simple(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/ln_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Two;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::rug_round_exact_from_rounding_mode;\nuse malachite_float::test_util::constants::ln_2::rug_ln_2_prec_round;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_ln_2_prec_round);\n    register_demo!(runner, demo_float_ln_2_prec_round_debug);\n    register_demo!(runner, demo_float_ln_2_prec);\n    register_demo!(runner, demo_float_ln_2_prec_debug);\n\n    register_bench!(runner, benchmark_float_ln_2_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_ln_2_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_ln_2_prec_library_comparison);\n    register_bench!(runner, benchmark_float_ln_2_prec_algorithms);\n}\n\nfn demo_float_ln_2_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"ln_2_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::ln_2_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_ln_2_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::ln_2_prec_round(p, rm);\n        println!(\n            \"ln_2_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_ln_2_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"ln_2_prec({}) = {:?}\", p, Float::ln_2_prec(p));\n    }\n}\n\nfn demo_float_ln_2_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::ln_2_prec(p);\n        println!(\"ln_2_prec({}) = ({:#x}, {:?})\", p, ComparableFloat(pc), o);\n    }\n}\n\nfn benchmark_float_ln_2_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::ln_2_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(p, rm)| {\n                no_out!(Float::ln_2_prec_round(p, rm));\n            }),\n            (\"rug\", &mut |(p, rm)| {\n                no_out!(rug_ln_2_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(rm)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_ln_2_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::ln_2_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::ln_2_prec_round(p, rm));\n            }),\n            (\"using ln\", &mut |(p, rm)| {\n                no_out!(Float::ln_prec_round(Float::TWO, p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_ln_2_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::ln_2_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::ln_2_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug_ln_2_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(Nearest)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_ln_2_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::ln_2_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| no_out!(Float::ln_2_prec(p))),\n            (\"using ln\", &mut |p| {\n                no_out!(Float::ln_prec(Float::TWO, p));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/log_2_e.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::log_2_e::log_2_e_prec_round_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_log_2_e_prec_round);\n    register_demo!(runner, demo_float_log_2_e_prec_round_debug);\n    register_demo!(runner, demo_float_log_2_e_prec);\n    register_demo!(runner, demo_float_log_2_e_prec_debug);\n\n    register_bench!(runner, benchmark_float_log_2_e_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_log_2_e_prec_algorithms);\n}\n\nfn demo_float_log_2_e_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"log_2_e_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::log_2_e_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_log_2_e_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::log_2_e_prec_round(p, rm);\n        println!(\n            \"log_2_e_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_log_2_e_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"log_2_e_prec({}) = {:?}\", p, Float::log_2_e_prec(p));\n    }\n}\n\nfn demo_float_log_2_e_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::log_2_e_prec(p);\n        println!(\n            \"log_2_e_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_log_2_e_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::log_2_e_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::log_2_e_prec_round(p, rm));\n            }),\n            (\"simple\", &mut |(p, rm)| {\n                no_out!(log_2_e_prec_round_simple(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_log_2_e_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::log_2_e_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| no_out!(Float::log_2_e_prec(p))),\n            (\"simple\", &mut |p| {\n                no_out!(log_2_e_prec_round_simple(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    gauss_constant::register(runner);\n    lemniscate_constant::register(runner);\n    ln_2::register(runner);\n    log_2_e::register(runner);\n    one_over_pi::register(runner);\n    one_over_sqrt_pi::register(runner);\n    one_over_sqrt_tau::register(runner);\n    phi::register(runner);\n    pi::register(runner);\n    pi_over_2::register(runner);\n    pi_over_3::register(runner);\n    pi_over_4::register(runner);\n    pi_over_6::register(runner);\n    pi_over_8::register(runner);\n    prime_constant::register(runner);\n    prouhet_thue_morse_constant::register(runner);\n    sqrt_2::register(runner);\n    sqrt_2_over_2::register(runner);\n    sqrt_3::register(runner);\n    sqrt_3_over_3::register(runner);\n    sqrt_pi::register(runner);\n    tau::register(runner);\n    two_over_pi::register(runner);\n    two_over_sqrt_pi::register(runner);\n}\n\nmod gauss_constant;\nmod lemniscate_constant;\nmod ln_2;\nmod log_2_e;\nmod one_over_pi;\nmod one_over_sqrt_pi;\nmod one_over_sqrt_tau;\nmod phi;\nmod pi;\nmod pi_over_2;\nmod pi_over_3;\nmod pi_over_4;\nmod pi_over_6;\nmod pi_over_8;\nmod prime_constant;\nmod prouhet_thue_morse_constant;\nmod sqrt_2;\nmod sqrt_2_over_2;\nmod sqrt_3;\nmod sqrt_3_over_3;\nmod sqrt_pi;\nmod tau;\nmod two_over_pi;\nmod two_over_sqrt_pi;\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/one_over_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::one_over_pi::one_over_pi_prec_round_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_one_over_pi_prec_round);\n    register_demo!(runner, demo_float_one_over_pi_prec_round_debug);\n    register_demo!(runner, demo_float_one_over_pi_prec);\n    register_demo!(runner, demo_float_one_over_pi_prec_debug);\n\n    register_bench!(runner, benchmark_float_one_over_pi_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_one_over_pi_prec_algorithms);\n}\n\nfn demo_float_one_over_pi_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"one_over_pi_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::one_over_pi_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_one_over_pi_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::one_over_pi_prec_round(p, rm);\n        println!(\n            \"one_over_pi_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_one_over_pi_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"one_over_pi_prec({}) = {:?}\", p, Float::one_over_pi_prec(p));\n    }\n}\n\nfn demo_float_one_over_pi_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::one_over_pi_prec(p);\n        println!(\n            \"one_over_pi_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_one_over_pi_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::one_over_pi_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::one_over_pi_prec_round(p, rm));\n            }),\n            (\"simple\", &mut |(p, rm)| {\n                no_out!(one_over_pi_prec_round_simple(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_one_over_pi_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::one_over_pi_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| no_out!(Float::one_over_pi_prec(p))),\n            (\"simple\", &mut |p| {\n                no_out!(one_over_pi_prec_round_simple(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/one_over_sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::one_over_sqrt_pi::one_over_sqrt_pi_prec_round_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_one_over_sqrt_pi_prec_round);\n    register_demo!(runner, demo_float_one_over_sqrt_pi_prec_round_debug);\n    register_demo!(runner, demo_float_one_over_sqrt_pi_prec);\n    register_demo!(runner, demo_float_one_over_sqrt_pi_prec_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_one_over_sqrt_pi_prec_round_algorithms\n    );\n    register_bench!(runner, benchmark_float_one_over_sqrt_pi_prec_algorithms);\n}\n\nfn demo_float_one_over_sqrt_pi_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"one_over_sqrt_pi_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::one_over_sqrt_pi_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_one_over_sqrt_pi_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::one_over_sqrt_pi_prec_round(p, rm);\n        println!(\n            \"one_over_sqrt_pi_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_one_over_sqrt_pi_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"one_over_sqrt_pi_prec({}) = {:?}\",\n            p,\n            Float::one_over_sqrt_pi_prec(p)\n        );\n    }\n}\n\nfn demo_float_one_over_sqrt_pi_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::one_over_sqrt_pi_prec(p);\n        println!(\n            \"one_over_sqrt_pi_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_one_over_sqrt_pi_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::one_over_sqrt_pi_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::one_over_sqrt_pi_prec_round(p, rm));\n            }),\n            (\"simple\", &mut |(p, rm)| {\n                no_out!(one_over_sqrt_pi_prec_round_simple(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_one_over_sqrt_pi_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::one_over_sqrt_pi_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| no_out!(Float::one_over_sqrt_pi_prec(p))),\n            (\"simple\", &mut |p| {\n                no_out!(one_over_sqrt_pi_prec_round_simple(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/one_over_sqrt_tau.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::one_over_sqrt_tau::one_over_sqrt_tau_prec_round_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_one_over_sqrt_tau_prec_round);\n    register_demo!(runner, demo_float_one_over_sqrt_tau_prec_round_debug);\n    register_demo!(runner, demo_float_one_over_sqrt_tau_prec);\n    register_demo!(runner, demo_float_one_over_sqrt_tau_prec_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_one_over_sqrt_tau_prec_round_algorithms\n    );\n    register_bench!(runner, benchmark_float_one_over_sqrt_tau_prec_algorithms);\n}\n\nfn demo_float_one_over_sqrt_tau_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"one_over_sqrt_tau_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::one_over_sqrt_tau_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_one_over_sqrt_tau_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::one_over_sqrt_tau_prec_round(p, rm);\n        println!(\n            \"one_over_sqrt_tau_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_one_over_sqrt_tau_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"one_over_sqrt_tau_prec({}) = {:?}\",\n            p,\n            Float::one_over_sqrt_tau_prec(p)\n        );\n    }\n}\n\nfn demo_float_one_over_sqrt_tau_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::one_over_sqrt_tau_prec(p);\n        println!(\n            \"one_over_sqrt_tau_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_one_over_sqrt_tau_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::one_over_sqrt_tau_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::one_over_sqrt_tau_prec_round(p, rm));\n            }),\n            (\"simple\", &mut |(p, rm)| {\n                no_out!(one_over_sqrt_tau_prec_round_simple(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_one_over_sqrt_tau_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::one_over_sqrt_tau_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| {\n                no_out!(Float::one_over_sqrt_tau_prec(p));\n            }),\n            (\"simple\", &mut |p| {\n                no_out!(one_over_sqrt_tau_prec_round_simple(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/phi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_phi_prec_round);\n    register_demo!(runner, demo_float_phi_prec_round_debug);\n    register_demo!(runner, demo_float_phi_prec);\n    register_demo!(runner, demo_float_phi_prec_debug);\n\n    register_bench!(runner, benchmark_float_phi_prec_round);\n    register_bench!(runner, benchmark_float_phi_prec);\n}\n\nfn demo_float_phi_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"phi_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::phi_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_phi_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::phi_prec_round(p, rm);\n        println!(\n            \"phi_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_phi_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"phi_prec({}) = {:?}\", p, Float::phi_prec(p));\n    }\n}\n\nfn demo_float_phi_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::phi_prec(p);\n        println!(\"phi_prec({}) = ({:#x}, {:?})\", p, ComparableFloat(pc), o);\n    }\n}\n\nfn benchmark_float_phi_prec_round(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::phi_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::phi_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_phi_prec(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::phi_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::phi_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::rug_round_exact_from_rounding_mode;\nuse malachite_float::test_util::constants::pi::rug_pi_prec_round;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_pi_prec_round);\n    register_demo!(runner, demo_float_pi_prec_round_debug);\n    register_demo!(runner, demo_float_pi_prec);\n    register_demo!(runner, demo_float_pi_prec_debug);\n\n    register_bench!(runner, benchmark_float_pi_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_pi_prec_library_comparison);\n}\n\nfn demo_float_pi_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"pi_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::pi_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_pi_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::pi_prec_round(p, rm);\n        println!(\n            \"pi_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_pi_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"pi_prec({}) = {:?}\", p, Float::pi_prec(p));\n    }\n}\n\nfn demo_float_pi_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::pi_prec(p);\n        println!(\"pi_prec({}) = ({:#x}, {:?})\", p, ComparableFloat(pc), o);\n    }\n}\n\nfn benchmark_float_pi_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(p, rm)| {\n                no_out!(Float::pi_prec_round(p, rm));\n            }),\n            (\"rug\", &mut |(p, rm)| {\n                no_out!(rug_pi_prec_round(p, rug_round_exact_from_rounding_mode(rm)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_pi_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::pi_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug_pi_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(Nearest)\n                ));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/pi_over_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_pi_over_2_prec_round);\n    register_demo!(runner, demo_float_pi_over_2_prec_round_debug);\n    register_demo!(runner, demo_float_pi_over_2_prec);\n    register_demo!(runner, demo_float_pi_over_2_prec_debug);\n\n    register_bench!(runner, benchmark_float_pi_over_2_prec_round);\n    register_bench!(runner, benchmark_float_pi_over_2_prec);\n}\n\nfn demo_float_pi_over_2_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"pi_over_2_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::pi_over_2_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_pi_over_2_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::pi_over_2_prec_round(p, rm);\n        println!(\n            \"pi_over_2_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_pi_over_2_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"pi_over_2_prec({}) = {:?}\", p, Float::pi_over_2_prec(p));\n    }\n}\n\nfn demo_float_pi_over_2_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::pi_over_2_prec(p);\n        println!(\n            \"pi_over_2_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_pi_over_2_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_over_2_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::pi_over_2_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_pi_over_2_prec(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::pi_over_2_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::pi_over_2_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/pi_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::pi_over_3::pi_over_3_prec_round_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_pi_over_3_prec_round);\n    register_demo!(runner, demo_float_pi_over_3_prec_round_debug);\n    register_demo!(runner, demo_float_pi_over_3_prec);\n    register_demo!(runner, demo_float_pi_over_3_prec_debug);\n\n    register_bench!(runner, benchmark_float_pi_over_3_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_pi_over_3_prec_algorithms);\n}\n\nfn demo_float_pi_over_3_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"pi_over_3_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::pi_over_3_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_pi_over_3_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::pi_over_3_prec_round(p, rm);\n        println!(\n            \"pi_over_3_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_pi_over_3_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"pi_over_3_prec({}) = {:?}\", p, Float::pi_over_3_prec(p));\n    }\n}\n\nfn demo_float_pi_over_3_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::pi_over_3_prec(p);\n        println!(\n            \"pi_over_3_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_pi_over_3_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_over_3_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::pi_over_3_prec_round(p, rm));\n            }),\n            (\"simple\", &mut |(p, rm)| {\n                no_out!(pi_over_3_prec_round_simple(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_pi_over_3_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_over_3_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| no_out!(Float::pi_over_3_prec(p))),\n            (\"simple\", &mut |p| {\n                no_out!(pi_over_3_prec_round_simple(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/pi_over_4.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_pi_over_4_prec_round);\n    register_demo!(runner, demo_float_pi_over_4_prec_round_debug);\n    register_demo!(runner, demo_float_pi_over_4_prec);\n    register_demo!(runner, demo_float_pi_over_4_prec_debug);\n\n    register_bench!(runner, benchmark_float_pi_over_4_prec_round);\n    register_bench!(runner, benchmark_float_pi_over_4_prec);\n}\n\nfn demo_float_pi_over_4_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"pi_over_4_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::pi_over_4_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_pi_over_4_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::pi_over_4_prec_round(p, rm);\n        println!(\n            \"pi_over_4_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_pi_over_4_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"pi_over_4_prec({}) = {:?}\", p, Float::pi_over_4_prec(p));\n    }\n}\n\nfn demo_float_pi_over_4_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::pi_over_4_prec(p);\n        println!(\n            \"pi_over_4_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_pi_over_4_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_over_4_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::pi_over_4_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_pi_over_4_prec(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::pi_over_4_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::pi_over_4_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/pi_over_6.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_pi_over_6_prec_round);\n    register_demo!(runner, demo_float_pi_over_6_prec_round_debug);\n    register_demo!(runner, demo_float_pi_over_6_prec);\n    register_demo!(runner, demo_float_pi_over_6_prec_debug);\n\n    register_bench!(runner, benchmark_float_pi_over_6_prec_round);\n    register_bench!(runner, benchmark_float_pi_over_6_prec);\n}\n\nfn demo_float_pi_over_6_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"pi_over_6_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::pi_over_6_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_pi_over_6_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::pi_over_6_prec_round(p, rm);\n        println!(\n            \"pi_over_6_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_pi_over_6_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"pi_over_6_prec({}) = {:?}\", p, Float::pi_over_6_prec(p));\n    }\n}\n\nfn demo_float_pi_over_6_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::pi_over_6_prec(p);\n        println!(\n            \"pi_over_6_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_pi_over_6_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_over_6_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::pi_over_6_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_pi_over_6_prec(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::pi_over_6_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::pi_over_6_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/pi_over_8.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_pi_over_8_prec_round);\n    register_demo!(runner, demo_float_pi_over_8_prec_round_debug);\n    register_demo!(runner, demo_float_pi_over_8_prec);\n    register_demo!(runner, demo_float_pi_over_8_prec_debug);\n\n    register_bench!(runner, benchmark_float_pi_over_8_prec_round);\n    register_bench!(runner, benchmark_float_pi_over_8_prec);\n}\n\nfn demo_float_pi_over_8_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"pi_over_8_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::pi_over_8_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_pi_over_8_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::pi_over_8_prec_round(p, rm);\n        println!(\n            \"pi_over_8_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_pi_over_8_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"pi_over_8_prec({}) = {:?}\", p, Float::pi_over_8_prec(p));\n    }\n}\n\nfn demo_float_pi_over_8_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::pi_over_8_prec(p);\n        println!(\n            \"pi_over_8_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_pi_over_8_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::pi_over_8_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::pi_over_8_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_pi_over_8_prec(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::pi_over_8_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::pi_over_8_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/prime_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::prime_constant::prime_constant_prec_round_naive;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_prime_constant_prec_round);\n    register_demo!(runner, demo_float_prime_constant_prec_round_debug);\n    register_demo!(runner, demo_float_prime_constant_prec);\n    register_demo!(runner, demo_float_prime_constant_prec_debug);\n\n    register_bench!(runner, benchmark_float_prime_constant_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_prime_constant_prec_algorithms);\n}\n\nfn demo_float_prime_constant_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"prime_constant_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::prime_constant_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_prime_constant_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::prime_constant_prec_round(p, rm);\n        println!(\n            \"prime_constant_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_prime_constant_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"prime_constant_prec({}) = {:?}\",\n            p,\n            Float::prime_constant_prec(p)\n        );\n    }\n}\n\nfn demo_float_prime_constant_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::prime_constant_prec(p);\n        println!(\n            \"prime_constant_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_prime_constant_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::prime_constant_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::prime_constant_prec_round(p, rm));\n            }),\n            (\"naive\", &mut |(p, rm)| {\n                no_out!(prime_constant_prec_round_naive(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_prime_constant_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::prime_constant_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| no_out!(Float::prime_constant_prec(p))),\n            (\"naive\", &mut |p| {\n                no_out!(prime_constant_prec_round_naive(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/prouhet_thue_morse_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::prouhet_thue_morse_constant::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_prouhet_thue_morse_constant_prec_round);\n    register_demo!(\n        runner,\n        demo_float_prouhet_thue_morse_constant_prec_round_debug\n    );\n    register_demo!(runner, demo_float_prouhet_thue_morse_constant_prec);\n    register_demo!(runner, demo_float_prouhet_thue_morse_constant_prec_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_prouhet_thue_morse_constant_prec_round_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_prouhet_thue_morse_constant_prec_algorithms\n    );\n}\n\nfn demo_float_prouhet_thue_morse_constant_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"prouhet_thue_morse_constant_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::prouhet_thue_morse_constant_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_prouhet_thue_morse_constant_prec_round_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (tmc, o) = Float::prouhet_thue_morse_constant_prec_round(p, rm);\n        println!(\n            \"prouhet_thue_morse_constant_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(tmc),\n            o\n        );\n    }\n}\n\nfn demo_float_prouhet_thue_morse_constant_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"prouhet_thue_morse_constant_prec({}) = {:?}\",\n            p,\n            Float::prouhet_thue_morse_constant_prec(p)\n        );\n    }\n}\n\nfn demo_float_prouhet_thue_morse_constant_prec_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (tmc, o) = Float::prouhet_thue_morse_constant_prec(p);\n        println!(\n            \"prouhet_thue_morse_constant_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(tmc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_prouhet_thue_morse_constant_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::prouhet_thue_morse_constant_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::prouhet_thue_morse_constant_prec_round(p, rm));\n            }),\n            (\"naive\", &mut |(p, rm)| {\n                no_out!(prouhet_thue_morse_constant_prec_round_naive(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_prouhet_thue_morse_constant_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::prouhet_thue_morse_constant_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| {\n                no_out!(Float::prouhet_thue_morse_constant_prec(p));\n            }),\n            (\"naive\", &mut |p| {\n                no_out!(prouhet_thue_morse_constant_prec_round_naive(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/sqrt_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::rug_round_exact_from_rounding_mode;\nuse malachite_float::test_util::constants::sqrt_2::rug_sqrt_2_prec_round;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sqrt_2_prec_round);\n    register_demo!(runner, demo_float_sqrt_2_prec_round_debug);\n    register_demo!(runner, demo_float_sqrt_2_prec);\n    register_demo!(runner, demo_float_sqrt_2_prec_debug);\n\n    register_bench!(runner, benchmark_float_sqrt_2_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_sqrt_2_prec_library_comparison);\n}\n\nfn demo_float_sqrt_2_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sqrt_2_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::sqrt_2_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_2_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::sqrt_2_prec_round(p, rm);\n        println!(\n            \"sqrt_2_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_2_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"sqrt_2_prec({}) = {:?}\", p, Float::sqrt_2_prec(p));\n    }\n}\n\nfn demo_float_sqrt_2_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::sqrt_2_prec(p);\n        println!(\"sqrt_2_prec({}) = ({:#x}, {:?})\", p, ComparableFloat(pc), o);\n    }\n}\n\nfn benchmark_float_sqrt_2_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_2_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(p, rm)| {\n                no_out!(Float::sqrt_2_prec_round(p, rm));\n            }),\n            (\"rug\", &mut |(p, rm)| {\n                no_out!(rug_sqrt_2_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(rm)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_2_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_2_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::sqrt_2_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug_sqrt_2_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(Nearest)\n                ));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/sqrt_2_over_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::rug_round_exact_from_rounding_mode;\nuse malachite_float::test_util::constants::sqrt_2_over_2::rug_sqrt_2_over_2_prec_round;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sqrt_2_over_2_prec_round);\n    register_demo!(runner, demo_float_sqrt_2_over_2_prec_round_debug);\n    register_demo!(runner, demo_float_sqrt_2_over_2_prec);\n    register_demo!(runner, demo_float_sqrt_2_over_2_prec_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_sqrt_2_over_2_prec_round_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sqrt_2_over_2_prec_library_comparison\n    );\n}\n\nfn demo_float_sqrt_2_over_2_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sqrt_2_over_2_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::sqrt_2_over_2_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_2_over_2_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::sqrt_2_over_2_prec_round(p, rm);\n        println!(\n            \"sqrt_2_over_2_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_2_over_2_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"sqrt_2_over_2_prec({}) = {:?}\",\n            p,\n            Float::sqrt_2_over_2_prec(p)\n        );\n    }\n}\n\nfn demo_float_sqrt_2_over_2_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::sqrt_2_over_2_prec(p);\n        println!(\n            \"sqrt_2_over_2_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_sqrt_2_over_2_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_2_over_2_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(p, rm)| {\n                no_out!(Float::sqrt_2_over_2_prec_round(p, rm));\n            }),\n            (\"rug\", &mut |(p, rm)| {\n                no_out!(rug_sqrt_2_over_2_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(rm)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_2_over_2_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_2_over_2_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::sqrt_2_over_2_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug_sqrt_2_over_2_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(Nearest)\n                ));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/sqrt_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::rug_round_exact_from_rounding_mode;\nuse malachite_float::test_util::constants::sqrt_3::rug_sqrt_3_prec_round;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sqrt_3_prec_round);\n    register_demo!(runner, demo_float_sqrt_3_prec_round_debug);\n    register_demo!(runner, demo_float_sqrt_3_prec);\n    register_demo!(runner, demo_float_sqrt_3_prec_debug);\n\n    register_bench!(runner, benchmark_float_sqrt_3_prec_round_library_comparison);\n    register_bench!(runner, benchmark_float_sqrt_3_prec_library_comparison);\n}\n\nfn demo_float_sqrt_3_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sqrt_3_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::sqrt_3_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_3_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::sqrt_3_prec_round(p, rm);\n        println!(\n            \"sqrt_3_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_3_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"sqrt_3_prec({}) = {:?}\", p, Float::sqrt_3_prec(p));\n    }\n}\n\nfn demo_float_sqrt_3_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::sqrt_3_prec(p);\n        println!(\"sqrt_3_prec({}) = ({:#x}, {:?})\", p, ComparableFloat(pc), o);\n    }\n}\n\nfn benchmark_float_sqrt_3_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_3_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(p, rm)| {\n                no_out!(Float::sqrt_3_prec_round(p, rm));\n            }),\n            (\"rug\", &mut |(p, rm)| {\n                no_out!(rug_sqrt_3_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(rm)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_3_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_3_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::sqrt_3_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug_sqrt_3_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(Nearest)\n                ));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/sqrt_3_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::rug_round_exact_from_rounding_mode;\nuse malachite_float::test_util::constants::sqrt_3_over_3::rug_sqrt_3_over_3_prec_round;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sqrt_3_over_3_prec_round);\n    register_demo!(runner, demo_float_sqrt_3_over_3_prec_round_debug);\n    register_demo!(runner, demo_float_sqrt_3_over_3_prec);\n    register_demo!(runner, demo_float_sqrt_3_over_3_prec_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_sqrt_3_over_3_prec_round_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sqrt_3_over_3_prec_library_comparison\n    );\n}\n\nfn demo_float_sqrt_3_over_3_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sqrt_3_over_3_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::sqrt_3_over_3_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_3_over_3_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::sqrt_3_over_3_prec_round(p, rm);\n        println!(\n            \"sqrt_3_over_3_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_3_over_3_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"sqrt_3_over_3_prec({}) = {:?}\",\n            p,\n            Float::sqrt_3_over_3_prec(p)\n        );\n    }\n}\n\nfn demo_float_sqrt_3_over_3_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::sqrt_3_over_3_prec(p);\n        println!(\n            \"sqrt_3_over_3_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_sqrt_3_over_3_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_3_over_3_prec_round(u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(p, rm)| {\n                no_out!(Float::sqrt_3_over_3_prec_round(p, rm));\n            }),\n            (\"rug\", &mut |(p, rm)| {\n                no_out!(rug_sqrt_3_over_3_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(rm)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_3_over_3_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_3_over_3_prec(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |p| no_out!(Float::sqrt_3_over_3_prec(p))),\n            (\"rug\", &mut |p| {\n                no_out!(rug_sqrt_3_over_3_prec_round(\n                    p,\n                    rug_round_exact_from_rounding_mode(Nearest)\n                ));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\nuse malachite_float::test_util::constants::sqrt_pi::sqrt_pi_prec_round_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_sqrt_pi_prec_round);\n    register_demo!(runner, demo_float_sqrt_pi_prec_round_debug);\n    register_demo!(runner, demo_float_sqrt_pi_prec);\n    register_demo!(runner, demo_float_sqrt_pi_prec_debug);\n\n    register_bench!(runner, benchmark_float_sqrt_pi_prec_round_algorithms);\n    register_bench!(runner, benchmark_float_sqrt_pi_prec_algorithms);\n}\n\nfn demo_float_sqrt_pi_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sqrt_pi_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::sqrt_pi_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_sqrt_pi_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::sqrt_pi_prec_round(p, rm);\n        println!(\n            \"sqrt_pi_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_sqrt_pi_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"sqrt_pi_prec({}) = {:?}\", p, Float::sqrt_pi_prec(p));\n    }\n}\n\nfn demo_float_sqrt_pi_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::sqrt_pi_prec(p);\n        println!(\n            \"sqrt_pi_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_sqrt_pi_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_pi_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [\n            (\"default\", &mut |(p, rm)| {\n                no_out!(Float::sqrt_pi_prec_round(p, rm));\n            }),\n            (\"simple\", &mut |(p, rm)| {\n                no_out!(sqrt_pi_prec_round_simple(p, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sqrt_pi_prec_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::sqrt_pi_prec(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |p| no_out!(Float::sqrt_pi_prec(p))),\n            (\"simple\", &mut |p| {\n                no_out!(sqrt_pi_prec_round_simple(p, Nearest));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/tau.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_tau_prec_round);\n    register_demo!(runner, demo_float_tau_prec_round_debug);\n    register_demo!(runner, demo_float_tau_prec);\n    register_demo!(runner, demo_float_tau_prec_debug);\n\n    register_bench!(runner, benchmark_float_tau_prec_round);\n    register_bench!(runner, benchmark_float_tau_prec);\n}\n\nfn demo_float_tau_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"tau_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::tau_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_tau_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::tau_prec_round(p, rm);\n        println!(\n            \"tau_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_tau_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"tau_prec({}) = {:?}\", p, Float::tau_prec(p));\n    }\n}\n\nfn demo_float_tau_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::tau_prec(p);\n        println!(\"tau_prec({}) = ({:#x}, {:?})\", p, ComparableFloat(pc), o);\n    }\n}\n\nfn benchmark_float_tau_prec_round(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::tau_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::tau_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_tau_prec(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float::tau_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::tau_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/two_over_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_two_over_pi_prec_round);\n    register_demo!(runner, demo_float_two_over_pi_prec_round_debug);\n    register_demo!(runner, demo_float_two_over_pi_prec);\n    register_demo!(runner, demo_float_two_over_pi_prec_debug);\n\n    register_bench!(runner, benchmark_float_two_over_pi_prec_round);\n    register_bench!(runner, benchmark_float_two_over_pi_prec);\n}\n\nfn demo_float_two_over_pi_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"two_over_pi_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::two_over_pi_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_two_over_pi_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::two_over_pi_prec_round(p, rm);\n        println!(\n            \"two_over_pi_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_two_over_pi_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\"two_over_pi_prec({}) = {:?}\", p, Float::two_over_pi_prec(p));\n    }\n}\n\nfn demo_float_two_over_pi_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::two_over_pi_prec(p);\n        println!(\n            \"two_over_pi_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_two_over_pi_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::two_over_pi_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::two_over_pi_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_two_over_pi_prec(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::two_over_pi_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| no_out!(Float::two_over_pi_prec(p)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/constants/two_over_sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_1_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::Float;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_two_over_sqrt_pi_prec_round);\n    register_demo!(runner, demo_float_two_over_sqrt_pi_prec_round_debug);\n    register_demo!(runner, demo_float_two_over_sqrt_pi_prec);\n    register_demo!(runner, demo_float_two_over_sqrt_pi_prec_debug);\n\n    register_bench!(runner, benchmark_float_two_over_sqrt_pi_prec_round);\n    register_bench!(runner, benchmark_float_two_over_sqrt_pi_prec);\n}\n\nfn demo_float_two_over_sqrt_pi_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"two_over_sqrt_pi_prec_round({}, {}) = {:?}\",\n            p,\n            rm,\n            Float::two_over_sqrt_pi_prec_round(p, rm)\n        );\n    }\n}\n\nfn demo_float_two_over_sqrt_pi_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (p, rm) in unsigned_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (pc, o) = Float::two_over_sqrt_pi_prec_round(p, rm);\n        println!(\n            \"two_over_sqrt_pi_prec_round({}, {}) = ({:#x}, {:?})\",\n            p,\n            rm,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn demo_float_two_over_sqrt_pi_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"two_over_sqrt_pi_prec({}) = {:?}\",\n            p,\n            Float::two_over_sqrt_pi_prec(p)\n        );\n    }\n}\n\nfn demo_float_two_over_sqrt_pi_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for p in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let (pc, o) = Float::two_over_sqrt_pi_prec(p);\n        println!(\n            \"two_over_sqrt_pi_prec({}) = ({:#x}, {:?})\",\n            p,\n            ComparableFloat(pc),\n            o\n        );\n    }\n}\n\nfn benchmark_float_two_over_sqrt_pi_prec_round(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::two_over_sqrt_pi_prec_round(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"prec\"),\n        &mut [(\"Malachite\", &mut |(p, rm)| {\n            no_out!(Float::two_over_sqrt_pi_prec_round(p, rm));\n        })],\n    );\n}\n\nfn benchmark_float_two_over_sqrt_pi_prec(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::two_over_sqrt_pi_prec(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |p| {\n            no_out!(Float::two_over_sqrt_pi_prec(p));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    pair_2_float_complexity_bucketer, pair_2_pair_float_max_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_rm, float_gen_var_12, float_pair_gen, float_pair_gen_rm,\n    float_pair_gen_var_10,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_clone);\n    register_demo!(runner, demo_float_clone_debug);\n    register_demo!(runner, demo_float_clone_extreme);\n    register_demo!(runner, demo_float_clone_extreme_debug);\n    register_demo!(runner, demo_float_clone_from);\n    register_demo!(runner, demo_float_clone_from_debug);\n    register_demo!(runner, demo_float_clone_from_extreme);\n    register_demo!(runner, demo_float_clone_from_extreme_debug);\n\n    register_bench!(runner, benchmark_float_clone_library_comparison);\n    register_bench!(runner, benchmark_float_clone_from_library_comparison);\n}\n\nfn demo_float_clone(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\"clone({}) = {}\", n, n.clone());\n    }\n}\n\nfn demo_float_clone_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"clone({:#x}) = {:#x}\",\n            ComparableFloatRef(&n),\n            ComparableFloat(n.clone())\n        );\n    }\n}\n\nfn demo_float_clone_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\"clone({}) = {}\", n, n.clone());\n    }\n}\n\nfn demo_float_clone_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"clone({:#x}) = {:#x}\",\n            ComparableFloatRef(&n),\n            ComparableFloat(n.clone())\n        );\n    }\n}\n\nfn demo_float_clone_from(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.clone_from(&y);\n        println!(\"x := {x_old}; x.clone_from({y}); x = {x}\");\n    }\n}\n\nfn demo_float_clone_from_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.clone_from(&y);\n        println!(\n            \"x := {:#x}; x.clone_from({:#x}); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\nfn demo_float_clone_from_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.clone_from(&y);\n        println!(\"x := {x_old}; x.clone_from({y}); x = {x}\");\n    }\n}\n\nfn demo_float_clone_from_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in float_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.clone_from(&y);\n        println!(\n            \"x := {:#x}; x.clone_from({:#x}); x = {:#x}\",\n            ComparableFloat(x_old),\n            ComparableFloat(y),\n            ComparableFloat(x)\n        );\n    }\n}\n\n#[allow(clippy::redundant_clone, unused_must_use)]\nfn benchmark_float_clone_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.clone()\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(n.clone())),\n            (\"rug\", &mut |(n, _)| no_out!(n.clone())),\n        ],\n    );\n}\n\nfn benchmark_float_clone_from_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.clone_from(&Float)\",\n        BenchmarkType::LibraryComparison,\n        float_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_float_max_complexity_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x.clone_from(&y)),\n            (\"rug\", &mut |((mut x, y), _)| x.clone_from(&y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::common::rug_round_try_from_rounding_mode;\nuse malachite_float::test_util::generators::{\n    integer_unsigned_rounding_mode_triple_gen_var_3,\n    integer_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse malachite_float::{ComparableFloat, Float};\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_integer_bit_u64_max_bucketer,\n    triple_1_2_integer_bit_u64_max_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_gen, integer_unsigned_pair_gen_var_6};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_from_integer_prec);\n    register_demo!(runner, demo_float_from_integer_prec_debug);\n    register_demo!(runner, demo_float_from_integer_prec_ref);\n    register_demo!(runner, demo_float_from_integer_prec_ref_debug);\n    register_demo!(runner, demo_float_from_integer_prec_round);\n    register_demo!(runner, demo_float_from_integer_prec_round_debug);\n    register_demo!(runner, demo_float_from_integer_prec_round_ref);\n    register_demo!(runner, demo_float_from_integer_prec_round_ref_debug);\n    register_demo!(runner, demo_float_try_from_integer);\n    register_demo!(runner, demo_float_try_from_integer_debug);\n    register_demo!(runner, demo_float_try_from_integer_ref);\n    register_demo!(runner, demo_float_try_from_integer_ref_debug);\n    register_demo!(runner, demo_float_convertible_from_integer);\n\n    register_bench!(\n        runner,\n        benchmark_float_from_integer_prec_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_from_integer_prec_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_float_from_integer_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_from_integer_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_try_from_integer_evaluation_strategy);\n    register_bench!(runner, benchmark_float_convertible_from_integer);\n}\n\nfn demo_float_from_integer_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in integer_unsigned_pair_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_integer_prec({}, {}) = {:?}\",\n            n.clone(),\n            p,\n            Float::from_integer_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_from_integer_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in integer_unsigned_pair_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_integer_prec(n.clone(), p);\n        println!(\n            \"Float::from_integer_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_from_integer_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in integer_unsigned_pair_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_integer_prec_ref(&{}, {}) = {:?}\",\n            n,\n            p,\n            Float::from_integer_prec_ref(&n, p)\n        );\n    }\n}\n\nfn demo_float_from_integer_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in integer_unsigned_pair_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_integer_prec_ref(&n, p);\n        println!(\n            \"Float::from_integer_prec_ref(&{}, {}) = {:x?}\",\n            n,\n            p,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_from_integer_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in integer_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_integer_prec_round({}, {}, {:?}) = {:?}\",\n            n.clone(),\n            p,\n            rm,\n            Float::from_integer_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_integer_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in integer_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_integer_prec_round(n.clone(), p, rm);\n        println!(\n            \"Float::from_integer_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_from_integer_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in integer_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_integer_prec_round_ref(&{}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::from_integer_prec_round_ref(&n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_integer_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in integer_unsigned_rounding_mode_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_integer_prec_round_ref(&n, p, rm);\n        println!(\n            \"Float::from_integer_prec_round_ref(&{}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_try_from_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"Float::try_from({}) = {:?}\", x.clone(), Float::try_from(x));\n    }\n}\n\nfn demo_float_try_from_integer_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::try_from({}) = {:?}\",\n            x.clone(),\n            Float::try_from(x).map(|f| format!(\"{:#x}\", ComparableFloat(f)))\n        );\n    }\n}\n\nfn demo_float_try_from_integer_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"Float::try_from(&{}) = {:?}\", x, Float::try_from(&x));\n    }\n}\n\nfn demo_float_try_from_integer_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::try_from(&{}) = {:?}\",\n            x,\n            Float::try_from(&x).map(|f| format!(\"{:#x}\", ComparableFloat(f)))\n        );\n    }\n}\n\nfn demo_float_convertible_from_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Float\",\n            x,\n            if Float::convertible_from(&x) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn benchmark_float_from_integer_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_integer_prec(Integer, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::from_integer_prec(Integer, u64)\",\n                &mut |(n, prec)| no_out!(Float::from_integer_prec(n, prec)),\n            ),\n            (\n                \"Float::from_integer_prec_ref(&Integer, u64)\",\n                &mut |(n, prec)| no_out!(Float::from_integer_prec_ref(&n, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_from_integer_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_integer_prec(Integer, u64)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec)| {\n                no_out!(Float::from_integer_prec(n, prec));\n            }),\n            (\"rug\", &mut |(n, prec)| {\n                no_out!(rug::Float::with_val(\n                    u32::exact_from(prec),\n                    rug::Integer::from(&n),\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_integer_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_integer_prec_round(Integer, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_rounding_mode_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_integer_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::from_integer_prec(Integer, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::from_integer_prec_round(n, prec, rm)),\n            ),\n            (\n                \"Float::from_integer_prec_ref(&Integer, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::from_integer_prec_round_ref(&n, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_from_integer_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_integer_prec_round(Integer, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_rounding_mode_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_integer_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec, rm)| {\n                no_out!(Float::from_integer_prec_round(n, prec, rm));\n            }),\n            (\"rug\", &mut |(n, prec, rm)| {\n                no_out!(rug::Float::with_val_round(\n                    u32::exact_from(prec),\n                    rug::Integer::from(&n),\n                    rug_round_try_from_rounding_mode(rm).unwrap()\n                ));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_try_from_integer_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::try_from(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Float::try_from(Integer)\", &mut |x| {\n                no_out!(Float::try_from(x));\n            }),\n            (\"Float::try_from(&Integer)\", &mut |x| {\n                no_out!(Float::try_from(&x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_convertible_from_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::convertible_from(Integer)\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(Float::convertible_from(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::common::rug_round_try_from_rounding_mode;\nuse malachite_float::test_util::generators::{\n    natural_unsigned_rounding_mode_triple_gen_var_2,\n    natural_unsigned_rounding_mode_triple_gen_var_3,\n};\nuse malachite_float::{ComparableFloat, Float};\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_natural_bit_u64_max_bucketer,\n    triple_1_2_natural_bit_u64_max_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_7};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_from_natural_prec);\n    register_demo!(runner, demo_float_from_natural_prec_debug);\n    register_demo!(runner, demo_float_from_natural_prec_ref);\n    register_demo!(runner, demo_float_from_natural_prec_ref_debug);\n    register_demo!(runner, demo_float_from_natural_prec_round);\n    register_demo!(runner, demo_float_from_natural_prec_round_debug);\n    register_demo!(runner, demo_float_from_natural_prec_round_ref);\n    register_demo!(runner, demo_float_from_natural_prec_round_ref_debug);\n    register_demo!(runner, demo_float_try_from_natural);\n    register_demo!(runner, demo_float_try_from_natural_debug);\n    register_demo!(runner, demo_float_try_from_natural_ref);\n    register_demo!(runner, demo_float_try_from_natural_ref_debug);\n    register_demo!(runner, demo_float_convertible_from_natural);\n\n    register_bench!(\n        runner,\n        benchmark_float_from_natural_prec_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_from_natural_prec_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_float_from_natural_prec_round_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_from_natural_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_try_from_natural_evaluation_strategy);\n    register_bench!(runner, benchmark_float_convertible_from_natural);\n}\n\nfn demo_float_from_natural_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_natural_prec({}, {}) = {:?}\",\n            n.clone(),\n            p,\n            Float::from_natural_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_from_natural_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_natural_prec(n.clone(), p);\n        println!(\n            \"Float::from_natural_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_from_natural_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_natural_prec_ref(&{}, {}) = {:?}\",\n            n,\n            p,\n            Float::from_natural_prec_ref(&n, p)\n        );\n    }\n}\n\nfn demo_float_from_natural_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_natural_prec_ref(&n, p);\n        println!(\n            \"Float::from_natural_prec_ref(&{}, {}) = {:x?}\",\n            n,\n            p,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_from_natural_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in natural_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_natural_prec_round({}, {}, {:?}) = {:?}\",\n            n.clone(),\n            p,\n            rm,\n            Float::from_natural_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_natural_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in natural_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_natural_prec_round(n.clone(), p, rm);\n        println!(\n            \"Float::from_natural_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_from_natural_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in natural_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_natural_prec_round_ref(&{}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::from_natural_prec_round_ref(&n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_natural_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in natural_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_natural_prec_round_ref(&n, p, rm);\n        println!(\n            \"Float::from_natural_prec_round_ref(&{}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_try_from_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"Float::try_from({}) = {:?}\", x.clone(), Float::try_from(x));\n    }\n}\n\nfn demo_float_try_from_natural_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::try_from({}) = {:?}\",\n            x.clone(),\n            Float::try_from(x).map(|f| format!(\"{:#x}\", ComparableFloat(f)))\n        );\n    }\n}\n\nfn demo_float_try_from_natural_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"Float::try_from(&{}) = {:?}\", x, Float::try_from(&x));\n    }\n}\n\nfn demo_float_try_from_natural_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::try_from(&{}) = {:?}\",\n            x,\n            Float::try_from(&x).map(|f| format!(\"{:#x}\", ComparableFloat(f)))\n        );\n    }\n}\n\nfn demo_float_convertible_from_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Float\",\n            x,\n            if Float::convertible_from(&x) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn benchmark_float_from_natural_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_natural_prec(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::from_natural_prec(Natural, u64)\",\n                &mut |(n, prec)| no_out!(Float::from_natural_prec(n, prec)),\n            ),\n            (\n                \"Float::from_natural_prec_ref(&Natural, u64)\",\n                &mut |(n, prec)| no_out!(Float::from_natural_prec_ref(&n, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_from_natural_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_natural_prec(Natural, u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec)| {\n                no_out!(Float::from_natural_prec(n, prec));\n            }),\n            (\"rug\", &mut |(n, prec)| {\n                no_out!(rug::Float::with_val(\n                    u32::exact_from(prec),\n                    rug::Integer::from(&n),\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_natural_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_natural_prec_round(Natural, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_natural_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::from_natural_prec(Natural, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::from_natural_prec_round(n, prec, rm)),\n            ),\n            (\n                \"Float::from_natural_prec_ref(&Natural, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::from_natural_prec_round_ref(&n, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_from_natural_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_natural_prec_round(Natural, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_rounding_mode_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_natural_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec, rm)| {\n                no_out!(Float::from_natural_prec_round(n, prec, rm));\n            }),\n            (\"rug\", &mut |(n, prec, rm)| {\n                no_out!(rug::Float::with_val_round(\n                    u32::exact_from(prec),\n                    rug::Integer::from(&n),\n                    rug_round_try_from_rounding_mode(rm).unwrap()\n                ));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_try_from_natural_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::try_from(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Float::try_from(Natural)\", &mut |x| {\n                no_out!(Float::try_from(x));\n            }),\n            (\"Float::try_from(&Natural)\", &mut |x| {\n                no_out!(Float::try_from(&x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_convertible_from_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::convertible_from(Natural)\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(Float::convertible_from(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::{SignificantBits, TrailingZeros};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_primitive_float_bit_u64_max_bucketer, primitive_float_bucketer,\n    triple_1_2_primitive_float_bit_u64_max_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_unsigned_pair_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::common::rug_round_try_from_rounding_mode;\nuse malachite_float::test_util::generators::{\n    primitive_float_unsigned_rounding_mode_triple_gen_var_3,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse malachite_float::{ComparableFloat, Float};\nuse rug::Assign;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::{Ordering, max};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_from_primitive_float);\n    register_primitive_float_demos!(runner, demo_float_from_primitive_float_debug);\n    register_primitive_float_demos!(runner, demo_float_from_primitive_float_prec);\n    register_primitive_float_demos!(runner, demo_float_from_primitive_float_prec_debug);\n    register_primitive_float_demos!(runner, demo_float_from_primitive_float_prec_round);\n    register_primitive_float_demos!(runner, demo_float_from_primitive_float_prec_round_debug);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_from_primitive_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_from_primitive_float_prec_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_from_primitive_float_prec_round_library_comparison\n    );\n}\n\nfn demo_float_from_primitive_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: From<T>,\n{\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Float::from({}) = {}\", NiceFloat(x), Float::from(x));\n    }\n}\n\nfn demo_float_from_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T>,\n{\n    for x in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Float::from({}) = {:#x}\",\n            NiceFloat(x),\n            ComparableFloat(Float::from(x))\n        );\n    }\n}\n\nfn demo_float_from_primitive_float_prec<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, prec) in primitive_float_unsigned_pair_gen_var_4::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_primitive_float_prec({}, {}) = {:?}\",\n            NiceFloat(x),\n            prec,\n            Float::from_primitive_float_prec(x, prec)\n        );\n    }\n}\n\nfn demo_float_from_primitive_float_prec_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, prec) in primitive_float_unsigned_pair_gen_var_4::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = Float::from_primitive_float_prec(x, prec);\n        println!(\n            \"Float::from_primitive_float_prec({}, {}) = ({:#x}, {:?})\",\n            NiceFloat(x),\n            prec,\n            ComparableFloat(x_out),\n            o\n        );\n    }\n}\n\nfn demo_float_from_primitive_float_prec_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T>,\n{\n    for (x, prec, rm) in primitive_float_unsigned_rounding_mode_triple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_primitive_float_prec_round({}, {}, {}) = {:?}\",\n            NiceFloat(x),\n            prec,\n            rm,\n            Float::from_primitive_float_prec_round(x, prec, rm)\n        );\n    }\n}\n\nfn demo_float_from_primitive_float_prec_round_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T>,\n{\n    for (x, prec, rm) in primitive_float_unsigned_rounding_mode_triple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = Float::from_primitive_float_prec_round(x, prec, rm);\n        println!(\n            \"Float::from_primitive_float_prec_round({}, {}, {}) = ({:#x}, {:?})\",\n            NiceFloat(x),\n            prec,\n            rm,\n            ComparableFloat(x_out),\n            o\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_from_primitive_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    rug::Float: Assign<T>,\n{\n    run_benchmark(\n        &format!(\"Float::from({})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |x| no_out!(Float::from(x))),\n            (\"rug\", &mut |x| {\n                no_out!(rug::Float::with_val(\n                    if !x.is_finite() || x == T::ZERO {\n                        1\n                    } else {\n                        let n = x.integer_mantissa();\n                        u32::exact_from(n.significant_bits() - TrailingZeros::trailing_zeros(n))\n                    },\n                    x\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_primitive_float_prec_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    rug::Float: Assign<T>,\n{\n    run_benchmark(\n        &format!(\"Float::from_primitive_float_prec({}, u64)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        primitive_float_unsigned_pair_gen_var_4::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_primitive_float_bit_u64_max_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(x, prec)| {\n                no_out!(Float::from_primitive_float_prec(x, prec));\n            }),\n            (\"rug\", &mut |(x, prec)| {\n                no_out!(rug::Float::with_val(max(1, u32::exact_from(prec)), x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_primitive_float_prec_round_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n{\n    run_benchmark(\n        &format!(\n            \"Float::from_primitive_float_prec_round({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::LibraryComparison,\n        primitive_float_unsigned_rounding_mode_triple_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_primitive_float_bit_u64_max_bucketer(\"x\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(x, prec, rm)| {\n                no_out!(Float::from_primitive_float_prec_round(x, prec, rm));\n            }),\n            (\"rug\", &mut |(x, prec, rm)| {\n                no_out!(rug::Float::with_val_round(\n                    max(1, u32::exact_from(prec)),\n                    x,\n                    rug_round_try_from_rounding_mode(rm).unwrap()\n                ));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bit_bucketer, pair_primitive_int_bit_u64_max_bucketer, signed_bit_bucketer,\n    triple_1_2_primitive_int_bit_u64_max_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen_var_2, signed_unsigned_pair_gen_var_20, unsigned_gen,\n    unsigned_pair_gen_var_32, unsigned_signed_pair_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::common::rug_round_try_from_rounding_mode;\nuse malachite_float::test_util::generators::{\n    signed_unsigned_rounding_mode_triple_gen_var_3, signed_unsigned_rounding_mode_triple_gen_var_4,\n    unsigned_unsigned_rounding_mode_triple_gen_var_5,\n    unsigned_unsigned_rounding_mode_triple_gen_var_6,\n};\nuse malachite_float::{ComparableFloat, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse rug::Assign;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_float_from_unsigned);\n    register_unsigned_demos!(runner, demo_float_from_unsigned_debug);\n    register_unsigned_demos!(runner, demo_float_from_unsigned_prec);\n    register_unsigned_demos!(runner, demo_float_from_unsigned_prec_debug);\n    register_unsigned_demos!(runner, demo_float_from_unsigned_prec_round);\n    register_unsigned_demos!(runner, demo_float_from_unsigned_prec_round_debug);\n    register_demo!(runner, demo_float_const_from_unsigned);\n    register_demo!(runner, demo_float_const_from_unsigned_debug);\n    register_demo!(runner, demo_float_const_from_unsigned_times_power_of_2);\n    register_demo!(\n        runner,\n        demo_float_const_from_unsigned_times_power_of_2_debug\n    );\n\n    register_signed_demos!(runner, demo_float_from_signed);\n    register_signed_demos!(runner, demo_float_from_signed_debug);\n    register_signed_demos!(runner, demo_float_from_signed_prec);\n    register_signed_demos!(runner, demo_float_from_signed_prec_debug);\n    register_signed_demos!(runner, demo_float_from_signed_prec_round);\n    register_signed_demos!(runner, demo_float_from_signed_prec_round_debug);\n    register_demo!(runner, demo_float_const_from_signed);\n    register_demo!(runner, demo_float_const_from_signed_debug);\n    register_demo!(runner, demo_float_const_from_signed_times_power_of_2);\n    register_demo!(runner, demo_float_const_from_signed_times_power_of_2_debug);\n\n    register_unsigned_benches!(runner, benchmark_float_from_unsigned_library_comparison);\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_from_unsigned_prec_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_float_from_unsigned_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_const_from_unsigned);\n    register_bench!(runner, benchmark_float_const_from_unsigned_times_power_of_2);\n\n    register_signed_benches!(runner, benchmark_float_from_signed_library_comparison);\n    register_signed_benches!(runner, benchmark_float_from_signed_prec_library_comparison);\n    register_signed_benches!(\n        runner,\n        benchmark_float_from_signed_prec_round_library_comparison\n    );\n    register_bench!(runner, benchmark_float_const_from_signed);\n    register_bench!(runner, benchmark_float_const_from_signed_times_power_of_2);\n}\n\nfn demo_float_from_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: From<T>,\n{\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Float::from({}) = {}\", n, Float::from(n));\n    }\n}\n\nfn demo_float_from_unsigned_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: From<T>,\n{\n    for n in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Float::from({:#x}) = {:#x}\",\n            n,\n            ComparableFloat(Float::from(n))\n        );\n    }\n}\n\nfn demo_float_from_unsigned_prec<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: From<T>,\n{\n    for (n, p) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_unsigned_prec({}, {}) = {:?}\",\n            n,\n            p,\n            Float::from_unsigned_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_from_unsigned_prec_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: From<T>,\n{\n    for (n, p) in unsigned_pair_gen_var_32::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_unsigned_prec(n, p);\n        println!(\n            \"Float::from_unsigned_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_from_unsigned_prec_round<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: From<T>,\n{\n    for (n, p, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_unsigned_prec_round({}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::from_unsigned_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_unsigned_prec_round_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: From<T>,\n{\n    for (n, p, rm) in unsigned_unsigned_rounding_mode_triple_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_unsigned_prec_round(n, p, rm);\n        println!(\n            \"Float::from_unsigned_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_const_from_unsigned(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_unsigned({}) = {}\",\n            n,\n            Float::const_from_unsigned(n)\n        );\n    }\n}\n\nfn demo_float_const_from_unsigned_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_unsigned({:#x}) = {:#x}\",\n            n,\n            ComparableFloat(Float::const_from_unsigned(n))\n        );\n    }\n}\n\nfn demo_float_const_from_unsigned_times_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in unsigned_signed_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_unsigned_times_power_of_2({}, {}) = {}\",\n            n,\n            pow,\n            Float::const_from_unsigned_times_power_of_2(n, pow)\n        );\n    }\n}\n\nfn demo_float_const_from_unsigned_times_power_of_2_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in unsigned_signed_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_unsigned_times_power_of_2({:#x}, {}) = {:#x}\",\n            n,\n            pow,\n            Float::const_from_unsigned_times_power_of_2(n, pow)\n        );\n    }\n}\n\nfn demo_float_from_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: From<T>,\n{\n    for n in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Float::from({}) = {}\", n, Float::from(n));\n    }\n}\n\nfn demo_float_from_signed_debug<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Float: From<T>,\n{\n    for n in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Float::from({:#x}) = {:#x}\",\n            n,\n            ComparableFloat(Float::from(n))\n        );\n    }\n}\n\nfn demo_float_from_signed_prec<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: From<T>,\n{\n    for (n, p) in signed_unsigned_pair_gen_var_20::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_signed_prec({}, {}) = {:?}\",\n            n,\n            p,\n            Float::from_signed_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_from_signed_prec_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: From<T>,\n{\n    for (n, p) in signed_unsigned_pair_gen_var_20::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_signed_prec(n, p);\n        println!(\n            \"Float::from_signed_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_from_signed_prec_round<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: From<T>,\n{\n    for (n, p, rm) in signed_unsigned_rounding_mode_triple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_signed_prec_round({}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::from_signed_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_signed_prec_round_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: From<T>,\n{\n    for (n, p, rm) in signed_unsigned_rounding_mode_triple_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_signed_prec_round(n, p, rm);\n        println!(\n            \"Float::from_signed_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_const_from_signed(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_signed({}) = {}\",\n            n,\n            Float::const_from_signed(n)\n        );\n    }\n}\n\nfn demo_float_const_from_signed_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in signed_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_signed({:#x}) = {:#x}\",\n            n,\n            ComparableFloat(Float::const_from_signed(n))\n        );\n    }\n}\n\nfn demo_float_const_from_signed_times_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in signed_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_signed_times_power_of_2({}, {}) = {}\",\n            n,\n            pow,\n            Float::const_from_signed_times_power_of_2(n, pow)\n        );\n    }\n}\n\nfn demo_float_const_from_signed_times_power_of_2_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow) in signed_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"Float::const_from_signed_times_power_of_2({:#x}, {}) = {:#x}\",\n            n,\n            pow,\n            Float::const_from_signed_times_power_of_2(n, pow)\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_from_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    rug::Float: Assign<T>,\n{\n    run_benchmark(\n        &format!(\"Float::from({})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |n| no_out!(Float::from(n))),\n            (\"rug\", &mut |n| {\n                no_out!(rug::Float::with_val(\n                    if n == T::ZERO {\n                        1\n                    } else {\n                        u32::exact_from(n.significant_bits() - TrailingZeros::trailing_zeros(n))\n                    },\n                    n\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_unsigned_prec_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    Natural: From<T>,\n    rug::Float: Assign<T>,\n{\n    run_benchmark(\n        &format!(\"Float::from_unsigned_prec({}, u64)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        unsigned_pair_gen_var_32::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_primitive_int_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec)| {\n                no_out!(Float::from_unsigned_prec(n, prec));\n            }),\n            (\"rug\", &mut |(n, prec)| {\n                no_out!(rug::Float::with_val(u32::exact_from(prec), n));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_unsigned_prec_round_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    Natural: From<T>,\n    rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n{\n    run_benchmark(\n        &format!(\n            \"Float::from_unsigned_prec_round({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::LibraryComparison,\n        unsigned_unsigned_rounding_mode_triple_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_primitive_int_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec, rm)| {\n                no_out!(Float::from_unsigned_prec_round(n, prec, rm));\n            }),\n            (\"rug\", &mut |(n, prec, rm)| {\n                no_out!(rug::Float::with_val_round(\n                    u32::exact_from(prec),\n                    n,\n                    rug_round_try_from_rounding_mode(rm).unwrap()\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_const_from_unsigned(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::const_from_unsigned(Limb)\",\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(Float::const_from_unsigned(n)))],\n    );\n}\n\nfn benchmark_float_const_from_unsigned_times_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::const_from_unsigned_times_power_of_2(Limb)\",\n        BenchmarkType::Single,\n        unsigned_signed_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(Float::const_from_unsigned_times_power_of_2(n, pow));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_from_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    rug::Float: Assign<T>,\n{\n    run_benchmark(\n        &format!(\"Float::from({})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |n| no_out!(Float::from(n))),\n            (\"rug\", &mut |n| {\n                no_out!(rug::Float::with_val(\n                    if n == T::ZERO {\n                        1\n                    } else {\n                        u32::exact_from(n.significant_bits() - TrailingZeros::trailing_zeros(n))\n                    },\n                    n\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_signed_prec_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    Integer: From<T>,\n    rug::Float: Assign<T>,\n{\n    run_benchmark(\n        &format!(\"Float::from_signed_prec({}, u64)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        signed_unsigned_pair_gen_var_20::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_primitive_int_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec)| {\n                no_out!(Float::from_signed_prec(n, prec));\n            }),\n            (\"rug\", &mut |(n, prec)| {\n                no_out!(rug::Float::with_val(u32::exact_from(prec), n));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_signed_prec_round_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Float: From<T>,\n    Integer: From<T>,\n    rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n{\n    run_benchmark(\n        &format!(\n            \"Float::from_signed_prec_round({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::LibraryComparison,\n        signed_unsigned_rounding_mode_triple_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_primitive_int_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec, rm)| {\n                no_out!(Float::from_signed_prec_round(n, prec, rm));\n            }),\n            (\"rug\", &mut |(n, prec, rm)| {\n                no_out!(rug::Float::with_val_round(\n                    u32::exact_from(prec),\n                    n,\n                    rug_round_try_from_rounding_mode(rm).unwrap()\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_const_from_signed(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::const_from_signed(Limb)\",\n        BenchmarkType::Single,\n        signed_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(Float::const_from_signed(n)))],\n    );\n}\n\nfn benchmark_float_const_from_signed_times_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::const_from_signed_times_power_of_2(Limb)\",\n        BenchmarkType::Single,\n        signed_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(Float::const_from_signed_times_power_of_2(n, pow));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::conversion::from_rational::{\n    from_rational_prec_round_direct, from_rational_prec_round_ref_direct,\n    from_rational_prec_round_ref_using_div, from_rational_prec_round_using_div,\n};\nuse malachite_float::test_util::common::rug_round_try_from_rounding_mode;\nuse malachite_float::test_util::generators::{\n    rational_unsigned_rounding_mode_triple_gen_var_1,\n    rational_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, Float};\nuse malachite_q::test_util::bench::bucketers::{\n    pair_rational_bit_u64_max_bucketer, rational_bit_bucketer,\n    triple_1_2_rational_bit_u64_max_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_from_rational_prec);\n    register_demo!(runner, demo_float_from_rational_prec_debug);\n    register_demo!(runner, demo_float_from_rational_prec_ref);\n    register_demo!(runner, demo_float_from_rational_prec_ref_debug);\n    register_demo!(runner, demo_float_from_rational_prec_round);\n    register_demo!(runner, demo_float_from_rational_prec_round_debug);\n    register_demo!(runner, demo_float_from_rational_prec_round_ref);\n    register_demo!(runner, demo_float_from_rational_prec_round_ref_debug);\n    register_demo!(runner, demo_float_try_from_rational);\n    register_demo!(runner, demo_float_try_from_rational_debug);\n    register_demo!(runner, demo_float_try_from_rational_ref);\n    register_demo!(runner, demo_float_try_from_rational_ref_debug);\n    register_demo!(runner, demo_float_convertible_from_rational);\n\n    register_bench!(\n        runner,\n        benchmark_float_from_rational_prec_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_from_rational_prec_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_from_rational_prec_round_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_from_rational_prec_round_algorithms);\n    register_bench!(\n        runner,\n        benchmark_float_from_rational_prec_round_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_float_from_rational_prec_round_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_float_try_from_rational_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_convertible_from_rational);\n}\n\nfn demo_float_from_rational_prec(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_rational_prec({}, {}) = {:?}\",\n            n.clone(),\n            p,\n            Float::from_rational_prec(n, p)\n        );\n    }\n}\n\nfn demo_float_from_rational_prec_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_rational_prec(n.clone(), p);\n        println!(\n            \"Float::from_rational_prec({}, {}) = ({:#x}, {:?})\",\n            n,\n            p,\n            ComparableFloat(f),\n            o\n        );\n    }\n}\n\nfn demo_float_from_rational_prec_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_rational_prec_ref(&{}, {}) = {:?}\",\n            n,\n            p,\n            Float::from_rational_prec_ref(&n, p)\n        );\n    }\n}\n\nfn demo_float_from_rational_prec_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p) in rational_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_rational_prec_ref(&n, p);\n        println!(\n            \"Float::from_rational_prec_ref(&{}, {}) = {:x?}\",\n            n,\n            p,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_from_rational_prec_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_rational_prec_round({}, {}, {:?}) = {:?}\",\n            n.clone(),\n            p,\n            rm,\n            Float::from_rational_prec_round(n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_rational_prec_round_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_rational_prec_round(n.clone(), p, rm);\n        println!(\n            \"Float::from_rational_prec_round({}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_from_rational_prec_round_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Float::from_rational_prec_round_ref(&{}, {}, {:?}) = {:?}\",\n            n,\n            p,\n            rm,\n            Float::from_rational_prec_round_ref(&n, p, rm)\n        );\n    }\n}\n\nfn demo_float_from_rational_prec_round_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, p, rm) in rational_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = Float::from_rational_prec_round_ref(&n, p, rm);\n        println!(\n            \"Float::from_rational_prec_round_ref(&{}, {}, {:?}) = {:x?}\",\n            n,\n            p,\n            rm,\n            (ComparableFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_try_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"Float::try_from({}) = {:?}\", x.clone(), Float::try_from(x));\n    }\n}\n\nfn demo_float_try_from_rational_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::try_from({}) = {:?}\",\n            x.clone(),\n            Float::try_from(x).map(|f| format!(\"{:#x}\", ComparableFloat(f)))\n        );\n    }\n}\n\nfn demo_float_try_from_rational_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"Float::try_from(&{}) = {:?}\", x, Float::try_from(&x));\n    }\n}\n\nfn demo_float_try_from_rational_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"Float::try_from(&{}) = {:?}\",\n            x,\n            Float::try_from(&x).map(|f| format!(\"{:#x}\", ComparableFloat(f)))\n        );\n    }\n}\n\nfn demo_float_convertible_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Float\",\n            x,\n            if Float::convertible_from(&x) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn benchmark_float_from_rational_prec_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_rational_prec(Rational, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::from_rational_prec(Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::from_rational_prec(n, prec)),\n            ),\n            (\n                \"Float::from_rational_prec_ref(&Rational, u64)\",\n                &mut |(n, prec)| no_out!(Float::from_rational_prec_ref(&n, prec)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_from_rational_prec_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_rational_prec(Rational, u64)\",\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec)| {\n                no_out!(Float::from_rational_prec(n, prec));\n            }),\n            (\"rug\", &mut |(n, prec)| {\n                no_out!(rug::Float::with_val(\n                    u32::exact_from(prec),\n                    rug::Rational::from(&n),\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_rational_prec_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\n                \"Float::from_rational_prec(Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::from_rational_prec_round(n, prec, rm)),\n            ),\n            (\n                \"Float::from_rational_prec_ref(&Rational, u64, RoundingMode)\",\n                &mut |(n, prec, rm)| no_out!(Float::from_rational_prec_round_ref(&n, prec, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_from_rational_prec_round_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(n, prec, rm)| {\n                no_out!(Float::from_rational_prec_round(n, prec, rm));\n            }),\n            (\"direct\", &mut |(n, prec, rm)| {\n                no_out!(from_rational_prec_round_direct(n, prec, rm));\n            }),\n            (\"using div\", &mut |(n, prec, rm)| {\n                no_out!(from_rational_prec_round_using_div(n, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_rational_prec_round_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_rational_prec_round_ref(&Rational, u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"default\", &mut |(n, prec, rm)| {\n                no_out!(Float::from_rational_prec_round_ref(&n, prec, rm));\n            }),\n            (\"direct\", &mut |(n, prec, rm)| {\n                no_out!(from_rational_prec_round_ref_direct(&n, prec, rm));\n            }),\n            (\"using div\", &mut |(n, prec, rm)| {\n                no_out!(from_rational_prec_round_ref_using_div(&n, prec, rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_rational_prec_round_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_rational_prec_round(Rational, u64, RoundingMode)\",\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_u64_max_bucketer(\"n\", \"prec\"),\n        &mut [\n            (\"Malachite\", &mut |(n, prec, rm)| {\n                no_out!(Float::from_rational_prec_round(n, prec, rm));\n            }),\n            (\"rug\", &mut |(n, prec, rm)| {\n                no_out!(rug::Float::with_val_round(\n                    u32::exact_from(prec),\n                    rug::Rational::from(&n),\n                    rug_round_try_from_rounding_mode(rm).unwrap()\n                ));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_try_from_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::try_from(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Float::try_from(Rational)\", &mut |x| {\n                no_out!(Float::try_from(x));\n            }),\n            (\"Float::try_from(&Rational)\", &mut |x| {\n                no_out!(Float::try_from(&x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_convertible_from_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::convertible_from(Rational)\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(Float::convertible_from(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/integer_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{float_gen, float_rounding_mode_pair_gen_var_2};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse malachite_nz::integer::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_rounding_from_float);\n    register_demo!(runner, demo_integer_rounding_from_float_debug);\n    register_demo!(runner, demo_integer_rounding_from_float_ref);\n    register_demo!(runner, demo_integer_rounding_from_float_ref_debug);\n    register_demo!(runner, demo_integer_try_from_float);\n    register_demo!(runner, demo_integer_try_from_float_debug);\n    register_demo!(runner, demo_integer_try_from_float_ref);\n    register_demo!(runner, demo_integer_try_from_float_ref_debug);\n    register_demo!(runner, demo_integer_convertible_from_float);\n    register_demo!(runner, demo_integer_convertible_from_float_debug);\n\n    register_bench!(\n        runner,\n        benchmark_integer_rounding_from_float_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_integer_try_from_float_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_convertible_from_float);\n}\n\nfn demo_integer_rounding_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::rounding_from({}, {}) = {:?}\",\n            f.clone(),\n            rm,\n            Integer::rounding_from(f, rm)\n        );\n    }\n}\n\nfn demo_integer_rounding_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::rounding_from({:#x}, {}) = {:?}\",\n            ComparableFloat(f.clone()),\n            rm,\n            Integer::rounding_from(f, rm)\n        );\n    }\n}\n\nfn demo_integer_rounding_from_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::rounding_from(&{}, {}) = {:?}\",\n            f,\n            rm,\n            Integer::rounding_from(&f, rm)\n        );\n    }\n}\n\nfn demo_integer_rounding_from_float_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::rounding_from(&{:#x}, {}) = {:?}\",\n            ComparableFloatRef(&f),\n            rm,\n            Integer::rounding_from(&f, rm)\n        );\n    }\n}\n\nfn demo_integer_try_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Integer::try_from({}) = {:?}\",\n            f.clone(),\n            Integer::try_from(f)\n        );\n    }\n}\n\nfn demo_integer_try_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Integer::try_from({:#x}) = {:?}\",\n            ComparableFloat(f.clone()),\n            Integer::try_from(f)\n        );\n    }\n}\n\nfn demo_integer_try_from_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\"Integer::try_from(&{}) = {:?}\", f, Integer::try_from(&f));\n    }\n}\n\nfn demo_integer_try_from_float_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Integer::try_from(&{:#x}) = {:?}\",\n            ComparableFloatRef(&f),\n            Integer::try_from(&f)\n        );\n    }\n}\n\nfn demo_integer_convertible_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to an Integer\",\n            f,\n            if Integer::convertible_from(&f) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn demo_integer_convertible_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to an Integer\",\n            ComparableFloatRef(&f),\n            if Integer::convertible_from(&f) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn benchmark_integer_rounding_from_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::rounding_from(Float)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Integer::rounding_from(Float)\", &mut |(f, rm)| {\n                no_out!(Integer::rounding_from(f, rm));\n            }),\n            (\"Integer::rounding_from(&Float)\", &mut |(f, rm)| {\n                no_out!(Integer::rounding_from(&f, rm));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_try_from_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::try_from(Float)\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Integer::try_from(Float)\", &mut |f| {\n                no_out!(Integer::try_from(f));\n            }),\n            (\"Integer::try_from(&Float)\", &mut |f| {\n                no_out!(Integer::try_from(&f));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_convertible_from_float(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::convertible_from(&Float)\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Integer::convertible_from(&f)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/integer_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_gen_var_3, float_gen_var_13};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_signed_pair_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_integer_mantissa_and_exponent);\n    register_demo!(runner, demo_float_integer_mantissa_and_exponent_debug);\n    register_demo!(runner, demo_float_integer_mantissa_and_exponent_extreme);\n    register_demo!(\n        runner,\n        demo_float_integer_mantissa_and_exponent_extreme_debug\n    );\n    register_demo!(runner, demo_float_integer_mantissa_and_exponent_ref);\n    register_demo!(runner, demo_float_integer_mantissa_and_exponent_ref_debug);\n    register_demo!(runner, demo_float_integer_mantissa);\n    register_demo!(runner, demo_float_integer_mantissa_debug);\n    register_demo!(runner, demo_float_integer_mantissa_extreme);\n    register_demo!(runner, demo_float_integer_mantissa_extreme_debug);\n    register_demo!(runner, demo_float_integer_mantissa_ref);\n    register_demo!(runner, demo_float_integer_mantissa_ref_debug);\n    register_demo!(runner, demo_float_integer_exponent);\n    register_demo!(runner, demo_float_integer_exponent_debug);\n    register_demo!(runner, demo_float_integer_exponent_extreme);\n    register_demo!(runner, demo_float_integer_exponent_extreme_debug);\n    register_demo!(runner, demo_float_integer_exponent_ref);\n    register_demo!(runner, demo_float_integer_exponent_ref_debug);\n    register_demo!(runner, demo_float_from_integer_mantissa_and_exponent);\n    register_demo!(runner, demo_float_from_integer_mantissa_and_exponent_debug);\n    register_demo!(runner, demo_float_from_integer_mantissa_and_exponent_ref);\n    register_demo!(\n        runner,\n        demo_float_from_integer_mantissa_and_exponent_ref_debug\n    );\n\n    register_bench!(\n        runner,\n        benchmark_float_integer_mantissa_and_exponent_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_integer_mantissa_evaluation_strategy);\n    register_bench!(runner, benchmark_float_integer_exponent_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_float_from_integer_mantissa_and_exponent_evaluation_strategy\n    );\n}\n\nfn demo_float_integer_mantissa_and_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.integer_mantissa_and_exponent() = {:?}\",\n            n.clone(),\n            n.integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_and_exponent_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.integer_mantissa_and_exponent() = {:?}\",\n            ComparableFloat(n.clone()),\n            n.integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_and_exponent_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.integer_mantissa_and_exponent() = {:?}\",\n            n.clone(),\n            n.integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_and_exponent_extreme_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.integer_mantissa_and_exponent() = {:?}\",\n            ComparableFloat(n.clone()),\n            n.integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_and_exponent_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).integer_mantissa_and_exponent() = {:?}\",\n            n,\n            (&n).integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_and_exponent_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).integer_mantissa_and_exponent() = {:?}\",\n            ComparableFloatRef(&n),\n            (&n).integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.integer_mantissa() = {}\",\n            n.clone(),\n            n.integer_mantissa()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.integer_mantissa() = {:#x}\",\n            ComparableFloat(n.clone()),\n            n.integer_mantissa()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.integer_mantissa() = {}\",\n            n.clone(),\n            n.integer_mantissa()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.integer_mantissa() = {:#x}\",\n            ComparableFloat(n.clone()),\n            n.integer_mantissa()\n        );\n    }\n}\n\nfn demo_float_integer_mantissa_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\"(&{}).integer_mantissa() = {}\", n, (&n).integer_mantissa());\n    }\n}\n\nfn demo_float_integer_mantissa_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).integer_mantissa() = {:#x}\",\n            ComparableFloatRef(&n),\n            (&n).integer_mantissa()\n        );\n    }\n}\n\nfn demo_float_integer_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.integer_exponent() = {}\",\n            n.clone(),\n            n.integer_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_exponent_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.integer_exponent() = {}\",\n            ComparableFloat(n.clone()),\n            n.integer_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_exponent_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.integer_exponent() = {}\",\n            n.clone(),\n            n.integer_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_exponent_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.integer_exponent() = {}\",\n            ComparableFloat(n.clone()),\n            n.integer_exponent()\n        );\n    }\n}\n\nfn demo_float_integer_exponent_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\"{}.integer_exponent() = {}\", n, (&n).integer_exponent());\n    }\n}\n\nfn demo_float_integer_exponent_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.integer_exponent() = {}\",\n            ComparableFloatRef(&n),\n            (&n).integer_exponent()\n        );\n    }\n}\n\nfn demo_float_from_integer_mantissa_and_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_2::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n = <Float as IntegerMantissaAndExponent::<Natural, i64, Float>>\n            ::from_integer_mantissa_and_exponent(mantissa.clone(), exponent);\n        println!(\n            \"Float::from_integer_mantissa_and_exponent({}, {}) = {}\",\n            mantissa,\n            exponent,\n            n.unwrap()\n        );\n    }\n}\n\nfn demo_float_from_integer_mantissa_and_exponent_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_2::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n = <Float as IntegerMantissaAndExponent::<Natural, i64, Float>>\n            ::from_integer_mantissa_and_exponent(mantissa.clone(), exponent);\n        println!(\n            \"Float::from_integer_mantissa_and_exponent({:#x}, {}) = {:#x}\",\n            mantissa,\n            exponent,\n            ComparableFloat(n.unwrap())\n        );\n    }\n}\n\nfn demo_float_from_integer_mantissa_and_exponent_ref(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_2::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n = <&Float as IntegerMantissaAndExponent::<Natural, i64, Float>>\n            ::from_integer_mantissa_and_exponent(mantissa.clone(), exponent);\n        println!(\n            \"Float::from_integer_mantissa_and_exponent({}, {}) = {}\",\n            mantissa,\n            exponent,\n            n.unwrap()\n        );\n    }\n}\n\nfn demo_float_from_integer_mantissa_and_exponent_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_2::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n = <&Float as IntegerMantissaAndExponent::<Natural, i64, Float>>\n            ::from_integer_mantissa_and_exponent(mantissa.clone(), exponent);\n        println!(\n            \"Float::from_integer_mantissa_and_exponent({:#x}, {}) = {:#x}\",\n            mantissa,\n            exponent,\n            ComparableFloat(n.unwrap())\n        );\n    }\n}\n\nfn benchmark_float_integer_mantissa_and_exponent_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.integer_mantissa_and_exponent()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.integer_mantissa_and_exponent()\", &mut |x| {\n                no_out!(x.integer_mantissa_and_exponent());\n            }),\n            (\"(&Float).integer_mantissa_and_exponent()\", &mut |x| {\n                no_out!((&x).integer_mantissa_and_exponent());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_integer_mantissa_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.integer_mantissa()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.integer_mantissa()\", &mut |x| {\n                no_out!(x.integer_mantissa());\n            }),\n            (\"(&Float).integer_mantissa()\", &mut |x| {\n                no_out!((&x).integer_mantissa());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_integer_exponent_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.integer_exponent()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.integer_exponent()\", &mut |x| {\n                no_out!(x.integer_exponent());\n            }),\n            (\"(&Float).integer_exponent()\", &mut |x| {\n                no_out!((&x).integer_exponent());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_integer_mantissa_and_exponent_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_integer_mantissa_and_exponent(Float, i64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_pair_gen_var_2::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Float::from_integer_mantissa_and_exponent(Float, i64)\",\n                &mut |(mantissa, exponent)| {\n                    no_out!(<Float as IntegerMantissaAndExponent::<\n                        Natural,\n                        i64,\n                        Float,\n                    >>::from_integer_mantissa_and_exponent(\n                        mantissa, exponent\n                    ));\n                },\n            ),\n            (\n                \"(&Float)::from_integer_mantissa_and_exponent(Float, i64)\",\n                &mut |(mantissa, exponent)| {\n                    no_out!(<&Float as IntegerMantissaAndExponent::<\n                        Natural,\n                        i64,\n                        Float,\n                    >>::from_integer_mantissa_and_exponent(\n                        mantissa, exponent\n                    ));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloat;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_is_integer);\n    register_demo!(runner, demo_float_is_integer_debug);\n    register_demo!(runner, demo_float_is_integer_extreme);\n    register_demo!(runner, demo_float_is_integer_extreme_debug);\n\n    register_bench!(runner, benchmark_float_is_integer);\n}\n\nfn demo_float_is_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        if n.is_integer() {\n            println!(\"{n} is an integer\");\n        } else {\n            println!(\"{n} is not an integer\");\n        }\n    }\n}\n\nfn demo_float_is_integer_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen().get(gm, config).take(limit) {\n        if n.is_integer() {\n            println!(\"{:#x} is an integer\", ComparableFloat(n));\n        } else {\n            println!(\"{:#x} is not an integer\", ComparableFloat(n));\n        }\n    }\n}\n\nfn demo_float_is_integer_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        if n.is_integer() {\n            println!(\"{n} is an integer\");\n        } else {\n            println!(\"{n} is not an integer\");\n        }\n    }\n}\n\nfn demo_float_is_integer_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_12().get(gm, config).take(limit) {\n        if n.is_integer() {\n            println!(\"{:#x} is an integer\", ComparableFloat(n));\n        } else {\n            println!(\"{:#x} is not an integer\", ComparableFloat(n));\n        }\n    }\n}\n\nfn benchmark_float_is_integer(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Float.is_integer()\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_integer()))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    clone::register(runner);\n    from_integer::register(runner);\n    from_natural::register(runner);\n    from_primitive_float::register(runner);\n    from_primitive_int::register(runner);\n    from_rational::register(runner);\n    integer_from_float::register(runner);\n    integer_mantissa_and_exponent::register(runner);\n    is_integer::register(runner);\n    natural_from_float::register(runner);\n    primitive_float_from_float::register(runner);\n    primitive_int_from_float::register(runner);\n    rational_from_float::register(runner);\n    raw_mantissa_and_exponent::register(runner);\n    sci_mantissa_and_exponent::register(runner);\n    string::register(runner);\n}\n\nmod clone;\nmod from_integer;\nmod from_natural;\nmod from_primitive_float;\nmod from_primitive_int;\nmod from_rational;\nmod integer_from_float;\nmod integer_mantissa_and_exponent;\nmod is_integer;\nmod natural_from_float;\nmod primitive_float_from_float;\nmod primitive_int_from_float;\nmod rational_from_float;\nmod raw_mantissa_and_exponent;\nmod sci_mantissa_and_exponent;\nmod string;\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/natural_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{float_gen, float_rounding_mode_pair_gen_var_1};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse malachite_nz::natural::Natural;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_rounding_from_float);\n    register_demo!(runner, demo_natural_rounding_from_float_debug);\n    register_demo!(runner, demo_natural_rounding_from_float_ref);\n    register_demo!(runner, demo_natural_rounding_from_float_ref_debug);\n    register_demo!(runner, demo_natural_try_from_float);\n    register_demo!(runner, demo_natural_try_from_float_debug);\n    register_demo!(runner, demo_natural_try_from_float_ref);\n    register_demo!(runner, demo_natural_try_from_float_ref_debug);\n    register_demo!(runner, demo_natural_convertible_from_float);\n    register_demo!(runner, demo_natural_convertible_from_float_debug);\n\n    register_bench!(\n        runner,\n        benchmark_natural_rounding_from_float_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_try_from_float_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_convertible_from_float);\n}\n\nfn demo_natural_rounding_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::rounding_from({}, {}) = {:?}\",\n            f.clone(),\n            rm,\n            Natural::rounding_from(f, rm)\n        );\n    }\n}\n\nfn demo_natural_rounding_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::rounding_from({:#x}, {}) = {:?}\",\n            ComparableFloat(f.clone()),\n            rm,\n            Natural::rounding_from(f, rm)\n        );\n    }\n}\n\nfn demo_natural_rounding_from_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::rounding_from(&{}, {}) = {:?}\",\n            f,\n            rm,\n            Natural::rounding_from(&f, rm)\n        );\n    }\n}\n\nfn demo_natural_rounding_from_float_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (f, rm) in float_rounding_mode_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::rounding_from(&{:#x}, {}) = {:?}\",\n            ComparableFloatRef(&f),\n            rm,\n            Natural::rounding_from(&f, rm)\n        );\n    }\n}\n\nfn demo_natural_try_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Natural::try_from({}) = {:?}\",\n            f.clone(),\n            Natural::try_from(f)\n        );\n    }\n}\n\nfn demo_natural_try_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Natural::try_from({:#x}) = {:#x?}\",\n            ComparableFloat(f.clone()),\n            Natural::try_from(f)\n        );\n    }\n}\n\nfn demo_natural_try_from_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\"Natural::try_from(&{}) = {:?}\", f, Natural::try_from(&f));\n    }\n}\n\nfn demo_natural_try_from_float_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Natural::try_from(&{:#x}) = {:#x?}\",\n            ComparableFloatRef(&f),\n            Natural::try_from(&f)\n        );\n    }\n}\n\nfn demo_natural_convertible_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Natural\",\n            f,\n            if Natural::convertible_from(&f) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn demo_natural_convertible_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to a Natural\",\n            ComparableFloatRef(&f),\n            if Natural::convertible_from(&f) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn benchmark_natural_rounding_from_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::rounding_from(Float)\",\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Natural::rounding_from(Float)\", &mut |(f, rm)| {\n                no_out!(Natural::rounding_from(f, rm));\n            }),\n            (\"Natural::rounding_from(&Float)\", &mut |(f, rm)| {\n                no_out!(Natural::rounding_from(&f, rm));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_try_from_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::try_from(Float)\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Natural::try_from(Float)\", &mut |f| {\n                no_out!(Natural::try_from(f));\n            }),\n            (\"Natural::try_from(&Float)\", &mut |f| {\n                no_out!(Natural::try_from(&f));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_convertible_from_float(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::convertible_from(&Float)\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Natural::convertible_from(&f)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/primitive_float_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::conversion::primitive_float_from_float::FloatFromFloatError;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_12, float_rounding_mode_pair_gen_var_6,\n    float_rounding_mode_pair_gen_var_20,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_primitive_float_rounding_from_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_rounding_from_float_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_rounding_from_float_extreme);\n    register_primitive_float_demos!(\n        runner,\n        demo_primitive_float_rounding_from_float_extreme_debug\n    );\n    register_primitive_float_demos!(runner, demo_primitive_float_rounding_from_float_ref);\n    register_primitive_float_demos!(runner, demo_primitive_float_rounding_from_float_ref_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_try_from_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_try_from_float_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_try_from_float_extreme);\n    register_primitive_float_demos!(runner, demo_primitive_float_try_from_float_extreme_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_try_from_float_ref);\n    register_primitive_float_demos!(runner, demo_primitive_float_try_from_float_ref_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_convertible_from_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_convertible_from_float_debug);\n    register_primitive_float_demos!(runner, demo_primitive_float_convertible_from_float_extreme);\n    register_primitive_float_demos!(\n        runner,\n        demo_primitive_float_convertible_from_float_extreme_debug\n    );\n\n    register_primitive_float_benches!(runner, benchmark_primitive_float_try_from_float);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_convertible_from_float);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_rounding_from_float);\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_rounding_from_float<T: PrimitiveFloat + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = T::rounding_from(x.clone(), rm);\n        println!(\n            \"{}::rounding_from({}, {}) = ({}, {:?})\",\n            T::NAME,\n            x,\n            rm,\n            NiceFloat(x_out),\n            o\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_rounding_from_float_debug<T: PrimitiveFloat + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = T::rounding_from(x.clone(), rm);\n        println!(\n            \"{}::rounding_from({:#x}, {}) = ({}, {:?})\",\n            T::NAME,\n            ComparableFloat(x),\n            rm,\n            NiceFloat(x_out),\n            o\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_rounding_from_float_extreme<T: PrimitiveFloat + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_20::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = T::rounding_from(x.clone(), rm);\n        println!(\n            \"{}::rounding_from({}, {}) = ({}, {:?})\",\n            T::NAME,\n            x,\n            rm,\n            NiceFloat(x_out),\n            o\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_rounding_from_float_extreme_debug<T: PrimitiveFloat + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_20::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = T::rounding_from(x.clone(), rm);\n        println!(\n            \"{}::rounding_from({:#x}, {}) = ({}, {:?})\",\n            T::NAME,\n            ComparableFloat(x),\n            rm,\n            NiceFloat(x_out),\n            o\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_rounding_from_float_ref<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = T::rounding_from(&x, rm);\n        println!(\n            \"{}::rounding_from(&{}, {}) = ({}, {:?})\",\n            T::NAME,\n            x,\n            rm,\n            NiceFloat(x_out),\n            o\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_rounding_from_float_ref_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x_out, o) = T::rounding_from(&x, rm);\n        println!(\n            \"{}::rounding_from(&{:#x}, {}) = ({}, {:?})\",\n            T::NAME,\n            ComparableFloatRef(&x),\n            rm,\n            NiceFloat(x_out),\n            o\n        );\n    }\n}\n\nfn demo_primitive_float_try_from_float<\n    T: TryFrom<Float, Error = FloatFromFloatError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            T::try_from(x).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_primitive_float_try_from_float_debug<\n    T: TryFrom<Float, Error = FloatFromFloatError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            T::try_from(x).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_primitive_float_try_from_float_extreme<\n    T: TryFrom<Float, Error = FloatFromFloatError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            T::try_from(x).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_primitive_float_try_from_float_extreme_debug<\n    T: TryFrom<Float, Error = FloatFromFloatError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            T::try_from(x).map(NiceFloat)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_try_from_float_ref<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: TryFrom<&'a Float, Error = FloatFromFloatError>,\n{\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            x,\n            T::try_from(&x).map(NiceFloat)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_try_from_float_ref_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: TryFrom<&'a Float, Error = FloatFromFloatError>,\n{\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloatRef(&x),\n            T::try_from(&x).map(NiceFloat)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_convertible_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to an {}\",\n            f,\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_convertible_from_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to an {}\",\n            ComparableFloatRef(&f),\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_convertible_from_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to an {}\",\n            f,\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_primitive_float_convertible_from_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to an {}\",\n            ComparableFloatRef(&f),\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_primitive_float_try_from_float<T: TryFrom<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::try_from(Float)\", T::NAME),\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(T::try_from(x)))],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_convertible_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"{}::convertible_from(Float)\", T::NAME),\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(T::convertible_from(&x)))],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_primitive_float_rounding_from_float<T: RoundingFrom<Float> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"{}::rounding_from(Float, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        float_rounding_mode_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, rm)| no_out!(T::rounding_from(x, rm)))],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/primitive_int_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::from::{SignedFromFloatError, UnsignedFromFloatError};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_12, float_rounding_mode_pair_gen_var_4,\n    float_rounding_mode_pair_gen_var_5, float_rounding_mode_pair_gen_var_18,\n    float_rounding_mode_pair_gen_var_19,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_unsigned_rounding_from_float);\n    register_unsigned_demos!(runner, demo_unsigned_rounding_from_float_debug);\n    register_unsigned_demos!(runner, demo_unsigned_rounding_from_float_extreme);\n    register_unsigned_demos!(runner, demo_unsigned_rounding_from_float_extreme_debug);\n    register_unsigned_demos!(runner, demo_unsigned_rounding_from_float_ref);\n    register_unsigned_demos!(runner, demo_unsigned_rounding_from_float_ref_debug);\n    register_unsigned_demos!(runner, demo_unsigned_try_from_float);\n    register_unsigned_demos!(runner, demo_unsigned_try_from_float_debug);\n    register_unsigned_demos!(runner, demo_unsigned_try_from_float_extreme);\n    register_unsigned_demos!(runner, demo_unsigned_try_from_float_extreme_debug);\n    register_unsigned_demos!(runner, demo_unsigned_try_from_float_ref);\n    register_unsigned_demos!(runner, demo_unsigned_try_from_float_ref_debug);\n    register_unsigned_demos!(runner, demo_unsigned_convertible_from_float);\n    register_unsigned_demos!(runner, demo_unsigned_convertible_from_float_debug);\n    register_unsigned_demos!(runner, demo_unsigned_convertible_from_float_extreme);\n    register_unsigned_demos!(runner, demo_unsigned_convertible_from_float_extreme_debug);\n\n    register_signed_demos!(runner, demo_signed_rounding_from_float);\n    register_signed_demos!(runner, demo_signed_rounding_from_float_debug);\n    register_signed_demos!(runner, demo_signed_rounding_from_float_ref);\n    register_signed_demos!(runner, demo_signed_rounding_from_float_ref_debug);\n    register_signed_demos!(runner, demo_signed_rounding_from_float_extreme);\n    register_signed_demos!(runner, demo_signed_rounding_from_float_extreme_debug);\n    register_signed_demos!(runner, demo_signed_try_from_float);\n    register_signed_demos!(runner, demo_signed_try_from_float_debug);\n    register_signed_demos!(runner, demo_signed_try_from_float_extreme);\n    register_signed_demos!(runner, demo_signed_try_from_float_extreme_debug);\n    register_signed_demos!(runner, demo_signed_try_from_float_ref);\n    register_signed_demos!(runner, demo_signed_try_from_float_ref_debug);\n    register_signed_demos!(runner, demo_signed_convertible_from_float);\n    register_signed_demos!(runner, demo_signed_convertible_from_float_debug);\n    register_signed_demos!(runner, demo_signed_convertible_from_float_extreme);\n    register_signed_demos!(runner, demo_signed_convertible_from_float_extreme_debug);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_try_from_float_evaluation_strategy\n    );\n    register_unsigned_benches!(runner, benchmark_unsigned_convertible_from_float);\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_rounding_from_float_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_signed_try_from_float_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_signed_convertible_from_float);\n    register_signed_benches!(\n        runner,\n        benchmark_signed_rounding_from_float_evaluation_strategy\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_rounding_from_float<T: PrimitiveUnsigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_rounding_from_float_debug<T: PrimitiveUnsigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({:#x}, {}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_rounding_from_float_extreme<T: PrimitiveUnsigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_18::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_rounding_from_float_extreme_debug<T: PrimitiveUnsigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_18::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({:#x}, {}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_rounding_from_float_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from(&{}, {}) = {:?}\",\n            T::NAME,\n            x,\n            rm,\n            T::rounding_from(&x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_rounding_from_float_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from(&{:#x}, {}) = {:?}\",\n            T::NAME,\n            ComparableFloatRef(&x),\n            rm,\n            T::rounding_from(&x, rm)\n        );\n    }\n}\n\nfn demo_unsigned_try_from_float<\n    T: TryFrom<Float, Error = UnsignedFromFloatError> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            T::try_from(x)\n        );\n    }\n}\n\nfn demo_unsigned_try_from_float_debug<\n    T: TryFrom<Float, Error = UnsignedFromFloatError> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            T::try_from(x)\n        );\n    }\n}\n\nfn demo_unsigned_try_from_float_extreme<\n    T: TryFrom<Float, Error = UnsignedFromFloatError> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            T::try_from(x)\n        );\n    }\n}\n\nfn demo_unsigned_try_from_float_extreme_debug<\n    T: TryFrom<Float, Error = UnsignedFromFloatError> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            T::try_from(x)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_try_from_float_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: TryFrom<&'a Float, Error = UnsignedFromFloatError>,\n{\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"{}::try_from({}) = {:?}\", T::NAME, x, T::try_from(&x));\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_try_from_float_ref_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: TryFrom<&'a Float, Error = UnsignedFromFloatError>,\n{\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloatRef(&x),\n            T::try_from(&x)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_convertible_from_float<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            f,\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_convertible_from_float_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to a {}\",\n            ComparableFloatRef(&f),\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_convertible_from_float_extreme<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            f,\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_unsigned_convertible_from_float_extreme_debug<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to a {}\",\n            ComparableFloatRef(&f),\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_rounding_from_float<T: PrimitiveSigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_rounding_from_float_debug<T: PrimitiveSigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({:#x}, {}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_rounding_from_float_extreme<T: PrimitiveSigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_rounding_from_float_extreme_debug<T: PrimitiveSigned + RoundingFrom<Float>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_19::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({:#x}, {}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            rm,\n            T::rounding_from(x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_rounding_from_float_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from(&{}, {}) = {:?}\",\n            T::NAME,\n            x,\n            rm,\n            T::rounding_from(&x, rm)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_rounding_from_float_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    for (x, rm) in float_rounding_mode_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from(&{:#x}, {}) = {:?}\",\n            T::NAME,\n            ComparableFloatRef(&x),\n            rm,\n            T::rounding_from(&x, rm)\n        );\n    }\n}\n\nfn demo_signed_try_from_float<T: TryFrom<Float, Error = SignedFromFloatError> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            T::try_from(x)\n        );\n    }\n}\n\nfn demo_signed_try_from_float_debug<\n    T: TryFrom<Float, Error = SignedFromFloatError> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            T::try_from(x)\n        );\n    }\n}\n\nfn demo_signed_try_from_float_extreme<\n    T: TryFrom<Float, Error = SignedFromFloatError> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            x.clone(),\n            T::try_from(x)\n        );\n    }\n}\n\nfn demo_signed_try_from_float_extreme_debug<\n    T: TryFrom<Float, Error = SignedFromFloatError> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloat(x.clone()),\n            T::try_from(x)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_try_from_float_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> T: TryFrom<&'a Float, Error = SignedFromFloatError>,\n{\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\"{}::try_from({}) = {:?}\", T::NAME, x, T::try_from(&x));\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_try_from_float_ref_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: TryFrom<&'a Float, Error = SignedFromFloatError>,\n{\n    for x in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({:#x}) = {:?}\",\n            T::NAME,\n            ComparableFloatRef(&x),\n            T::try_from(&x)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_convertible_from_float<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to an {}\",\n            f,\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_convertible_from_float_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to an {}\",\n            ComparableFloatRef(&f),\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_convertible_from_float_extreme<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to an {}\",\n            f,\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn demo_signed_convertible_from_float_extreme_debug<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    for f in float_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to an {}\",\n            ComparableFloatRef(&f),\n            if T::convertible_from(&f) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\n#[allow(unused_must_use, clippy::type_repetition_in_bounds)]\nfn benchmark_unsigned_try_from_float_evaluation_strategy<T: TryFrom<Float> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: TryFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"{}::try_from(Float)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (&format!(\"{}::try_from(Float)\", T::NAME), &mut |x| {\n                no_out!(T::try_from(x));\n            }),\n            (&format!(\"{}::try_from(&Float)\", T::NAME), &mut |x| {\n                no_out!(T::try_from(&x));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_unsigned_convertible_from_float<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"{}::convertible_from(Float)\", T::NAME),\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(T::convertible_from(&x)))],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_unsigned_rounding_from_float_evaluation_strategy<\n    T: RoundingFrom<Float> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n    Float: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"{}::rounding_from(Float)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\n                &format!(\"{}::rounding_from(Float)\", T::NAME),\n                &mut |(x, rm)| no_out!(T::rounding_from(x, rm)),\n            ),\n            (\n                &format!(\"{}::rounding_from(&Float)\", T::NAME),\n                &mut |(x, rm)| no_out!(T::rounding_from(&x, rm)),\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::type_repetition_in_bounds)]\nfn benchmark_signed_try_from_float_evaluation_strategy<T: TryFrom<Float> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: TryFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"{}::try_from(Float)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (&format!(\"{}::try_from(Float)\", T::NAME), &mut |x| {\n                no_out!(T::try_from(x));\n            }),\n            (&format!(\"{}::try_from(&Float)\", T::NAME), &mut |x| {\n                no_out!(T::try_from(&x));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_signed_convertible_from_float<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    run_benchmark(\n        &format!(\"{}::convertible_from(Float)\", T::NAME),\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(T::convertible_from(&x)))],\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn benchmark_signed_rounding_from_float_evaluation_strategy<\n    T: RoundingFrom<Float> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n    Float: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"{}::rounding_from(Float)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        float_rounding_mode_pair_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\n                &format!(\"{}::rounding_from(Float)\", T::NAME),\n                &mut |(x, rm)| no_out!(T::rounding_from(x, rm)),\n            ),\n            (\n                &format!(\"{}::rounding_from(&Float)\", T::NAME),\n                &mut |(x, rm)| no_out!(T::rounding_from(&x, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/rational_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_2_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{float_gen, float_gen_rm};\nuse malachite_float::{ComparableFloat, ComparableFloatRef};\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_try_from_float);\n    register_demo!(runner, demo_rational_try_from_float_debug);\n    register_demo!(runner, demo_rational_try_from_float_ref);\n    register_demo!(runner, demo_rational_try_from_float_ref_debug);\n    register_demo!(runner, demo_rational_convertible_from_float);\n    register_demo!(runner, demo_rational_convertible_from_float_debug);\n\n    register_bench!(\n        runner,\n        benchmark_rational_try_from_float_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_try_from_float_library_comparison);\n    register_bench!(runner, benchmark_rational_convertible_from_float);\n}\n\nfn demo_rational_try_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Rational::try_from({}) = {:?}\",\n            f.clone(),\n            Rational::try_from(f)\n        );\n    }\n}\n\nfn demo_rational_try_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Rational::try_from({:#x}) = {:#x?}\",\n            ComparableFloat(f.clone()),\n            Rational::try_from(f)\n        );\n    }\n}\n\nfn demo_rational_try_from_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\"Rational::try_from(&{}) = {:?}\", f, Rational::try_from(&f));\n    }\n}\n\nfn demo_rational_try_from_float_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"Rational::try_from(&{:#x}) = {:#x?}\",\n            ComparableFloatRef(&f),\n            Rational::try_from(&f)\n        );\n    }\n}\n\nfn demo_rational_convertible_from_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Rational\",\n            f,\n            if Rational::convertible_from(&f) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn demo_rational_convertible_from_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:#x} is {}convertible to a Rational\",\n            ComparableFloatRef(&f),\n            if Rational::convertible_from(&f) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_try_from_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::try_from(Float)\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Rational::try_from(Float)\", &mut |f| {\n                no_out!(Rational::try_from(f));\n            }),\n            (\"Rational::try_from(&Float)\", &mut |f| {\n                no_out!(Rational::try_from(&f));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_try_from_float_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::try_from(Float)\",\n        BenchmarkType::LibraryComparison,\n        float_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, f)| no_out!(Rational::try_from(f))),\n            (\"rug\", &mut |(f, _)| no_out!(rug::Rational::try_from(&f))),\n        ],\n    );\n}\n\nfn benchmark_rational_convertible_from_float(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::convertible_from(&Float)\",\n        BenchmarkType::Single,\n        float_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |f| {\n            no_out!(Rational::convertible_from(&f));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/raw_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::RawMantissaAndExponent;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::float_complexity_bucketer;\nuse malachite_float::test_util::generators::{float_gen_var_3, float_gen_var_13};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_signed_pair_gen_var_4;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_raw_mantissa_and_exponent);\n    register_demo!(runner, demo_float_raw_mantissa_and_exponent_debug);\n    register_demo!(runner, demo_float_raw_mantissa_and_exponent_extreme);\n    register_demo!(runner, demo_float_raw_mantissa_and_exponent_extreme_debug);\n    register_demo!(runner, demo_float_raw_mantissa_and_exponent_ref);\n    register_demo!(runner, demo_float_raw_mantissa_and_exponent_ref_debug);\n    register_demo!(runner, demo_float_raw_mantissa);\n    register_demo!(runner, demo_float_raw_mantissa_debug);\n    register_demo!(runner, demo_float_raw_mantissa_extreme);\n    register_demo!(runner, demo_float_raw_mantissa_extreme_debug);\n    register_demo!(runner, demo_float_raw_mantissa_ref);\n    register_demo!(runner, demo_float_raw_mantissa_ref_debug);\n    register_demo!(runner, demo_float_raw_exponent);\n    register_demo!(runner, demo_float_raw_exponent_debug);\n    register_demo!(runner, demo_float_raw_exponent_extreme);\n    register_demo!(runner, demo_float_raw_exponent_extreme_debug);\n    register_demo!(runner, demo_float_raw_exponent_ref);\n    register_demo!(runner, demo_float_raw_exponent_ref_debug);\n    register_demo!(runner, demo_float_from_raw_mantissa_and_exponent);\n    register_demo!(runner, demo_float_from_raw_mantissa_and_exponent_debug);\n    register_demo!(runner, demo_float_from_raw_mantissa_and_exponent_ref);\n    register_demo!(runner, demo_float_from_raw_mantissa_and_exponent_ref_debug);\n\n    register_bench!(\n        runner,\n        benchmark_float_raw_mantissa_and_exponent_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_float_raw_mantissa_evaluation_strategy);\n    register_bench!(runner, benchmark_float_raw_exponent_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_float_from_raw_mantissa_and_exponent_evaluation_strategy\n    );\n}\n\nfn demo_float_raw_mantissa_and_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.raw_mantissa_and_exponent() = {:?}\",\n            n.clone(),\n            n.raw_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa_and_exponent_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.raw_mantissa_and_exponent() = {:?}\",\n            ComparableFloat(n.clone()),\n            n.raw_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa_and_exponent_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.raw_mantissa_and_exponent() = {:?}\",\n            n.clone(),\n            n.raw_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa_and_exponent_extreme_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.raw_mantissa_and_exponent() = {:?}\",\n            ComparableFloat(n.clone()),\n            n.raw_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa_and_exponent_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).raw_mantissa_and_exponent() = {:?}\",\n            n,\n            (&n).raw_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa_and_exponent_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).raw_mantissa_and_exponent() = {:?}\",\n            ComparableFloatRef(&n),\n            (&n).raw_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\"{}.raw_mantissa() = {}\", n.clone(), n.raw_mantissa());\n    }\n}\n\nfn demo_float_raw_mantissa_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.raw_mantissa() = {:#x}\",\n            ComparableFloat(n.clone()),\n            n.raw_mantissa()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\"{}.raw_mantissa() = {}\", n.clone(), n.raw_mantissa());\n    }\n}\n\nfn demo_float_raw_mantissa_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.raw_mantissa() = {:#x}\",\n            ComparableFloat(n.clone()),\n            n.raw_mantissa()\n        );\n    }\n}\n\nfn demo_float_raw_mantissa_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\"(&{}).raw_mantissa() = {}\", n, (&n).raw_mantissa());\n    }\n}\n\nfn demo_float_raw_mantissa_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).raw_mantissa() = {:#x}\",\n            ComparableFloatRef(&n),\n            (&n).raw_mantissa()\n        );\n    }\n}\n\nfn demo_float_raw_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\"{}.raw_exponent() = {}\", n.clone(), n.raw_exponent());\n    }\n}\n\nfn demo_float_raw_exponent_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.raw_exponent() = {}\",\n            ComparableFloat(n.clone()),\n            n.raw_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_exponent_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\"{}.raw_exponent() = {}\", n.clone(), n.raw_exponent());\n    }\n}\n\nfn demo_float_raw_exponent_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.raw_exponent() = {}\",\n            ComparableFloat(n.clone()),\n            n.raw_exponent()\n        );\n    }\n}\n\nfn demo_float_raw_exponent_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\"{}.raw_exponent() = {}\", n, (&n).raw_exponent());\n    }\n}\n\nfn demo_float_raw_exponent_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.raw_exponent() = {}\",\n            ComparableFloatRef(&n),\n            (&n).raw_exponent()\n        );\n    }\n}\n\nfn demo_float_from_raw_mantissa_and_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_4::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <Float as RawMantissaAndExponent<Natural, i32, Float>>::from_raw_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\"Float::from_raw_mantissa_and_exponent({mantissa}, {exponent}) = {n}\");\n    }\n}\n\nfn demo_float_from_raw_mantissa_and_exponent_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_4::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <Float as RawMantissaAndExponent<Natural, i32, Float>>::from_raw_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\n            \"Float::from_raw_mantissa_and_exponent({:#x}, {}) = {:#x}\",\n            mantissa,\n            exponent,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn demo_float_from_raw_mantissa_and_exponent_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_4::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <&Float as RawMantissaAndExponent<Natural, i32, Float>>::from_raw_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\"Float::from_raw_mantissa_and_exponent({mantissa}, {exponent}) = {n}\");\n    }\n}\n\nfn demo_float_from_raw_mantissa_and_exponent_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in natural_signed_pair_gen_var_4::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <&Float as RawMantissaAndExponent<Natural, i32, Float>>::from_raw_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\n            \"Float::from_raw_mantissa_and_exponent({:#x}, {}) = {:#x}\",\n            mantissa,\n            exponent,\n            ComparableFloat(n)\n        );\n    }\n}\n\nfn benchmark_float_raw_mantissa_and_exponent_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.raw_mantissa_and_exponent()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.raw_mantissa_and_exponent()\", &mut |x| {\n                no_out!(x.raw_mantissa_and_exponent());\n            }),\n            (\"(&Float).raw_mantissa_and_exponent()\", &mut |x| {\n                no_out!((&x).raw_mantissa_and_exponent());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_raw_mantissa_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.raw_mantissa()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.raw_mantissa()\", &mut |x| no_out!(x.raw_mantissa())),\n            (\"(&Float).raw_mantissa()\", &mut |x| {\n                no_out!((&x).raw_mantissa());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_raw_exponent_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.raw_exponent()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.raw_exponent()\", &mut |x| no_out!(x.raw_exponent())),\n            (\"(&Float).raw_exponent()\", &mut |x| {\n                no_out!((&x).raw_exponent());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_raw_mantissa_and_exponent_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_raw_mantissa_and_exponent(Float, i32)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_pair_gen_var_4::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Float::from_raw_mantissa_and_exponent(Float, i32)\",\n                &mut |(mantissa, exponent)| {\n                    no_out!(<Float as RawMantissaAndExponent::<\n                        Natural,\n                        i32,\n                        Float,\n                    >>::from_raw_mantissa_and_exponent(\n                        mantissa, exponent\n                    ));\n                },\n            ),\n            (\n                \"(&Float)::from_raw_mantissa_and_exponent(Float, i32)\",\n                &mut |(mantissa, exponent)| {\n                    no_out!(<&Float as RawMantissaAndExponent::<\n                        Natural,\n                        i32,\n                        Float,\n                    >>::from_raw_mantissa_and_exponent(\n                        mantissa, exponent\n                    ));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/sci_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::pair_1_primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_signed_pair_gen_var_3;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::test_util::bench::bucketers::{\n    float_complexity_bucketer, pair_1_float_complexity_bucketer,\n};\nuse malachite_float::test_util::generators::{\n    float_gen_var_3, float_gen_var_13, float_rounding_mode_pair_gen,\n    float_rounding_mode_pair_gen_var_21, float_signed_pair_gen_var_1,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_sci_mantissa_and_exponent_round);\n    register_primitive_float_demos!(runner, demo_sci_mantissa_and_exponent_round_debug);\n    register_primitive_float_demos!(runner, demo_sci_mantissa_and_exponent_round_extreme);\n    register_primitive_float_demos!(runner, demo_sci_mantissa_and_exponent_round_extreme_debug);\n    register_demo!(runner, demo_float_sci_mantissa_and_exponent_float);\n    register_demo!(runner, demo_float_sci_mantissa_and_exponent_float_debug);\n    register_demo!(runner, demo_float_sci_mantissa_and_exponent_float_extreme);\n    register_demo!(\n        runner,\n        demo_float_sci_mantissa_and_exponent_float_extreme_debug\n    );\n    register_demo!(runner, demo_float_sci_mantissa_and_exponent_float_ref);\n    register_demo!(runner, demo_float_sci_mantissa_and_exponent_float_ref_debug);\n    register_demo!(runner, demo_float_sci_mantissa_float);\n    register_demo!(runner, demo_float_sci_mantissa_float_debug);\n    register_demo!(runner, demo_float_sci_mantissa_float_extreme);\n    register_demo!(runner, demo_float_sci_mantissa_float_extreme_debug);\n    register_demo!(runner, demo_float_sci_mantissa_float_ref);\n    register_demo!(runner, demo_float_sci_mantissa_float_ref_debug);\n    register_demo!(runner, demo_float_sci_exponent_float);\n    register_demo!(runner, demo_float_sci_exponent_float_debug);\n    register_demo!(runner, demo_float_sci_exponent_float_extreme);\n    register_demo!(runner, demo_float_sci_exponent_float_extreme_debug);\n    register_demo!(runner, demo_float_sci_exponent_float_ref);\n    register_demo!(runner, demo_float_sci_exponent_float_ref_debug);\n    register_demo!(runner, demo_float_from_sci_mantissa_and_exponent_float);\n    register_demo!(\n        runner,\n        demo_float_from_sci_mantissa_and_exponent_float_debug\n    );\n    register_demo!(runner, demo_float_from_sci_mantissa_and_exponent_float_ref);\n    register_demo!(\n        runner,\n        demo_float_from_sci_mantissa_and_exponent_float_ref_debug\n    );\n\n    register_primitive_float_demos!(runner, demo_float_sci_mantissa_and_exponent_primitive_float);\n    register_primitive_float_demos!(\n        runner,\n        demo_float_sci_mantissa_and_exponent_primitive_float_debug\n    );\n    register_primitive_float_demos!(\n        runner,\n        demo_float_sci_mantissa_and_exponent_primitive_float_extreme\n    );\n    register_primitive_float_demos!(\n        runner,\n        demo_float_sci_mantissa_and_exponent_primitive_float_extreme_debug\n    );\n    register_primitive_float_demos!(runner, demo_float_sci_mantissa_primitive_float);\n    register_primitive_float_demos!(runner, demo_float_sci_mantissa_primitive_float_debug);\n    register_primitive_float_demos!(runner, demo_float_sci_mantissa_primitive_float_extreme);\n    register_primitive_float_demos!(\n        runner,\n        demo_float_sci_mantissa_primitive_float_extreme_debug\n    );\n    register_primitive_float_demos!(runner, demo_float_sci_exponent_primitive_float);\n    register_primitive_float_demos!(runner, demo_float_sci_exponent_primitive_float_debug);\n    register_primitive_float_demos!(runner, demo_float_sci_exponent_primitive_float_extreme);\n    register_primitive_float_demos!(\n        runner,\n        demo_float_sci_exponent_primitive_float_extreme_debug\n    );\n    register_primitive_float_demos!(\n        runner,\n        demo_float_from_sci_mantissa_and_exponent_primitive_float\n    );\n    register_primitive_float_demos!(\n        runner,\n        demo_float_from_sci_mantissa_and_exponent_primitive_float_debug\n    );\n\n    register_primitive_float_benches!(runner, benchmark_sci_mantissa_and_exponent_round);\n    register_bench!(\n        runner,\n        benchmark_float_sci_mantissa_and_exponent_float_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sci_mantissa_float_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_sci_exponent_float_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_float_from_sci_mantissa_and_exponent_float_evaluation_strategy\n    );\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_sci_mantissa_and_exponent_primitive_float\n    );\n    register_primitive_float_benches!(runner, benchmark_float_sci_mantissa_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_float_sci_exponent_primitive_float);\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_from_sci_mantissa_and_exponent_primitive_float\n    );\n}\n\nfn demo_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in float_rounding_mode_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_mantissa_and_exponent_round({}) = {:?}\",\n            n.clone(),\n            rm,\n            n.sci_mantissa_and_exponent_round::<T>(rm)\n        );\n    }\n}\n\nfn demo_sci_mantissa_and_exponent_round_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in float_rounding_mode_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_mantissa_and_exponent_round({}) = {:?}\",\n            ComparableFloat(n.clone()),\n            rm,\n            n.sci_mantissa_and_exponent_round::<T>(rm)\n        );\n    }\n}\n\nfn demo_sci_mantissa_and_exponent_round_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in float_rounding_mode_pair_gen_var_21()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.sci_mantissa_and_exponent_round({}) = {:?}\",\n            n.clone(),\n            rm,\n            n.sci_mantissa_and_exponent_round::<T>(rm)\n        );\n    }\n}\n\nfn demo_sci_mantissa_and_exponent_round_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in float_rounding_mode_pair_gen_var_21()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{:#x}.sci_mantissa_and_exponent_round({}) = {:?}\",\n            ComparableFloat(n.clone()),\n            rm,\n            n.sci_mantissa_and_exponent_round::<T>(rm)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_mantissa_and_exponent() = {:?}\",\n            n.clone(),\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa_and_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_mantissa_and_exponent() = {:?}\",\n            ComparableFloat(n.clone()),\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa_and_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_float_extreme(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_mantissa_and_exponent() = {:?}\",\n            n.clone(),\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa_and_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_float_extreme_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_mantissa_and_exponent() = {:?}\",\n            ComparableFloat(n.clone()),\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa_and_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).sci_mantissa_and_exponent() = {:?}\",\n            n,\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa_and_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_float_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).sci_mantissa_and_exponent() = {:?}\",\n            ComparableFloatRef(&n),\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa_and_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_mantissa() = {}\",\n            n.clone(),\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa(n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_mantissa() = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(SciMantissaAndExponent::<Float, _, _>::sci_mantissa(n))\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_mantissa() = {}\",\n            n.clone(),\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa(n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_mantissa() = {:#x}\",\n            ComparableFloat(n.clone()),\n            ComparableFloat(SciMantissaAndExponent::<Float, _, _>::sci_mantissa(n))\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).sci_mantissa() = {}\",\n            n,\n            SciMantissaAndExponent::<Float, _, _>::sci_mantissa(&n)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_float_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"(&{:#x}).sci_mantissa() = {:#x}\",\n            ComparableFloatRef(&n),\n            ComparableFloat(SciMantissaAndExponent::<Float, _, _>::sci_mantissa(&n))\n        );\n    }\n}\n\nfn demo_float_sci_exponent_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_exponent() = {}\",\n            n.clone(),\n            SciMantissaAndExponent::<Float, _, _>::sci_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_float_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_exponent() = {}\",\n            ComparableFloat(n.clone()),\n            SciMantissaAndExponent::<Float, _, _>::sci_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_float_extreme(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_exponent() = {}\",\n            n.clone(),\n            SciMantissaAndExponent::<Float, _, _>::sci_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_float_extreme_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_exponent() = {}\",\n            ComparableFloat(n.clone()),\n            SciMantissaAndExponent::<Float, _, _>::sci_exponent(n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_float_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_exponent() = {}\",\n            n,\n            SciMantissaAndExponent::<Float, _, _>::sci_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_float_ref_debug(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_exponent() = {}\",\n            ComparableFloatRef(&n),\n            SciMantissaAndExponent::<Float, _, _>::sci_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_from_sci_mantissa_and_exponent_float(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mantissa, exponent) in float_signed_pair_gen_var_1::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <Float as SciMantissaAndExponent<Float, i32, Float>>::from_sci_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\n            \"Float::from_sci_mantissa_and_exponent({}, {}) = {}\",\n            mantissa,\n            exponent,\n            n.unwrap()\n        );\n    }\n}\n\nfn demo_float_from_sci_mantissa_and_exponent_float_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in float_signed_pair_gen_var_1::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <Float as SciMantissaAndExponent<Float, i32, Float>>::from_sci_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\n            \"Float::from_sci_mantissa_and_exponent({:#x}, {}) = {:#x}\",\n            mantissa,\n            exponent,\n            ComparableFloat(n.unwrap())\n        );\n    }\n}\n\nfn demo_float_from_sci_mantissa_and_exponent_float_ref(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in float_signed_pair_gen_var_1::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <&Float as SciMantissaAndExponent<Float, i32, Float>>::from_sci_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\n            \"Float::from_sci_mantissa_and_exponent({}, {}) = {}\",\n            mantissa,\n            exponent,\n            n.unwrap()\n        );\n    }\n}\n\nfn demo_float_from_sci_mantissa_and_exponent_float_ref_debug(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mantissa, exponent) in float_signed_pair_gen_var_1::<i32>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n =\n            <&Float as SciMantissaAndExponent<Float, i32, Float>>::from_sci_mantissa_and_exponent(\n                mantissa.clone(),\n                exponent,\n            );\n        println!(\n            \"Float::from_sci_mantissa_and_exponent({:#x}, {}) = {:#x}\",\n            mantissa,\n            exponent,\n            ComparableFloat(n.unwrap())\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        let (m, e) = SciMantissaAndExponent::<T, _, _>::sci_mantissa_and_exponent(&n);\n        println!(\n            \"{}.sci_mantissa_and_exponent() = {:?}\",\n            n,\n            (NiceFloat(m), e)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        let (m, e) = SciMantissaAndExponent::<T, _, _>::sci_mantissa_and_exponent(&n);\n        println!(\n            \"{:#x}.sci_mantissa_and_exponent() = {:?}\",\n            ComparableFloatRef(&n),\n            (NiceFloat(m), e)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_primitive_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        let (m, e) = SciMantissaAndExponent::<T, _, _>::sci_mantissa_and_exponent(&n);\n        println!(\n            \"{}.sci_mantissa_and_exponent() = {:?}\",\n            n,\n            (NiceFloat(m), e)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_and_exponent_primitive_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        let (m, e) = SciMantissaAndExponent::<T, _, _>::sci_mantissa_and_exponent(&n);\n        println!(\n            \"{:#x}.sci_mantissa_and_exponent() = {:?}\",\n            ComparableFloatRef(&n),\n            (NiceFloat(m), e)\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_mantissa() = {}\",\n            n,\n            NiceFloat(SciMantissaAndExponent::<T, _, _>::sci_mantissa(&n))\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_mantissa() = {}\",\n            ComparableFloatRef(&n),\n            NiceFloat(SciMantissaAndExponent::<T, _, _>::sci_mantissa(&n))\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_primitive_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_mantissa() = {}\",\n            n,\n            NiceFloat(SciMantissaAndExponent::<T, _, _>::sci_mantissa(&n))\n        );\n    }\n}\n\nfn demo_float_sci_mantissa_primitive_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_mantissa() = {}\",\n            ComparableFloatRef(&n),\n            NiceFloat(SciMantissaAndExponent::<T, _, _>::sci_mantissa(&n))\n        );\n    }\n}\n\nfn demo_float_sci_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_exponent() = {:?}\",\n            n,\n            SciMantissaAndExponent::<T, _, _>::sci_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_exponent() = {:?}\",\n            ComparableFloatRef(&n),\n            SciMantissaAndExponent::<T, _, _>::sci_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_primitive_float_extreme<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{}.sci_exponent() = {:?}\",\n            n,\n            SciMantissaAndExponent::<T, _, _>::sci_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_sci_exponent_primitive_float_extreme_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for n in float_gen_var_13().get(gm, config).take(limit) {\n        println!(\n            \"{:#x}.sci_exponent() = {:?}\",\n            ComparableFloatRef(&n),\n            SciMantissaAndExponent::<T, _, _>::sci_exponent(&n)\n        );\n    }\n}\n\nfn demo_float_from_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for (mantissa, exponent) in primitive_float_signed_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let exponent = i32::exact_from(exponent);\n        let n = <&Float as SciMantissaAndExponent<T, i32, Float>>::from_sci_mantissa_and_exponent(\n            mantissa, exponent,\n        );\n        println!(\n            \"Float::from_sci_mantissa_and_exponent({}, {}) = {}\",\n            NiceFloat(mantissa),\n            exponent,\n            n.unwrap()\n        );\n    }\n}\n\nfn demo_float_from_sci_mantissa_and_exponent_primitive_float_debug<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    for (mantissa, exponent) in primitive_float_signed_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let exponent = i32::exact_from(exponent);\n        let n = <&Float as SciMantissaAndExponent<T, i32, Float>>::from_sci_mantissa_and_exponent(\n            mantissa, exponent,\n        );\n        println!(\n            \"Float::from_sci_mantissa_and_exponent({}, {}) = {:#x}\",\n            NiceFloat(mantissa),\n            exponent,\n            ComparableFloat(n.unwrap())\n        );\n    }\n}\n\nfn benchmark_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sci_mantissa_and_exponent_round(RoundingMode)\",\n        BenchmarkType::Single,\n        float_rounding_mode_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, rm)| {\n            no_out!(x.sci_mantissa_and_exponent_round::<T>(rm));\n        })],\n    );\n}\n\nfn benchmark_float_sci_mantissa_and_exponent_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sci_mantissa_and_exponent()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.sci_mantissa_and_exponent()\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<Float, _, _>::sci_mantissa_and_exponent(x));\n            }),\n            (\"(&Float).sci_mantissa_and_exponent()\", &mut |x| {\n                no_out!(\n                    <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa_and_exponent(&x)\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sci_mantissa_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sci_mantissa()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.sci_mantissa()\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<Float, _, _>::sci_mantissa(x));\n            }),\n            (\"(&Float).sci_mantissa()\", &mut |x| {\n                no_out!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa(&x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_sci_exponent_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float.sci_exponent()\",\n        BenchmarkType::EvaluationStrategy,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [\n            (\"Float.sci_exponent()\", &mut |x| {\n                no_out!(SciMantissaAndExponent::<Float, _, _>::sci_exponent(x));\n            }),\n            (\"(&Float).sci_exponent()\", &mut |x| {\n                no_out!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&x));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_from_sci_mantissa_and_exponent_float_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Float::from_sci_mantissa_and_exponent(Float, i32)\",\n        BenchmarkType::EvaluationStrategy,\n        float_signed_pair_gen_var_1::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_float_complexity_bucketer(\"x\"),\n        &mut [\n            (\n                \"Float::from_sci_mantissa_and_exponent(Float, i32)\",\n                &mut |(mantissa, exponent)| {\n                    no_out!(<Float as SciMantissaAndExponent::<\n                        Float,\n                        i32,\n                        Float,\n                    >>::from_sci_mantissa_and_exponent(\n                        mantissa, exponent\n                    ));\n                },\n            ),\n            (\n                \"(&Float)::from_sci_mantissa_and_exponent(Float, i32)\",\n                &mut |(mantissa, exponent)| {\n                    no_out!(<&Float as SciMantissaAndExponent::<\n                        Float,\n                        i32,\n                        Float,\n                    >>::from_sci_mantissa_and_exponent(\n                        mantissa, exponent\n                    ));\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_float_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    run_benchmark(\n        \"Float.sci_mantissa_and_exponent()\",\n        BenchmarkType::Single,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(SciMantissaAndExponent::<T, _, _>::sci_mantissa_and_exponent(&x));\n        })],\n    );\n}\n\nfn benchmark_float_sci_mantissa_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    run_benchmark(\n        \"Float.sci_mantissa()\",\n        BenchmarkType::Single,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(SciMantissaAndExponent::<T, _, _>::sci_mantissa(&x));\n        })],\n    );\n}\n\nfn benchmark_float_sci_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    run_benchmark(\n        \"Float.sci_exponent()\",\n        BenchmarkType::Single,\n        float_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &float_complexity_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(SciMantissaAndExponent::<T, _, _>::sci_exponent(&x));\n        })],\n    );\n}\n\nfn benchmark_float_from_sci_mantissa_and_exponent_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    run_benchmark(\n        \"Float::from_sci_mantissa_and_exponent(Float, i32)\",\n        BenchmarkType::Single,\n        primitive_float_signed_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\n            &format!(\"Float::from_sci_mantissa_and_exponent({}, i32)\", T::NAME),\n            &mut |(mantissa, exponent)| {\n                let exponent = i32::exact_from(exponent);\n                no_out!(<&Float as SciMantissaAndExponent::<\n                        T,\n                        i32,\n                        Float,\n                    >>::from_sci_mantissa_and_exponent(\n                        mantissa, exponent\n                    )\n                );\n            },\n        )],\n    );\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    to_string::register(runner);\n}\n\nmod to_string;\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_float::ComparableFloatRef;\nuse malachite_float::test_util::generators::float_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_float_to_string);\n}\n\nfn demo_float_to_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for f in float_gen().get(gm, config).take(limit) {\n        println!(\"to_string({:x}) = {}\", ComparableFloatRef(&f), f);\n        println!(\"{}\", rug::Float::exact_from(&f));\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/bin_util/demo_and_bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    arithmetic::register(runner);\n    basic::register(runner);\n    comparison::register(runner);\n    constants::register(runner);\n    conversion::register(runner);\n}\n\nmod arithmetic;\nmod basic;\nmod comparison;\nmod constants;\nmod conversion;\n"
  },
  {
    "path": "malachite-float/src/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{ComparableFloat, ComparableFloatRef, Float};\nuse core::cmp::Ordering::{self, *};\n\nimpl PartialOrd for Float {\n    /// Compares two [`Float`]s.\n    ///\n    /// This implementation follows the IEEE 754 standard. `NaN` is not comparable to anything, not\n    /// even itself. Positive zero is equal to negative zero. [`Float`]s with different precisions\n    /// are equal if they represent the same numeric value.\n    ///\n    /// For different comparison behavior that provides a total order, consider using\n    /// [`ComparableFloat`] or [`ComparableFloatRef`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Zero,\n    /// };\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(Float::NAN.partial_cmp(&Float::NAN), None);\n    /// assert_eq!(Float::ZERO.partial_cmp(&Float::NEGATIVE_ZERO), Some(Equal));\n    /// assert_eq!(Float::ONE.partial_cmp(&Float::one_prec(100)), Some(Equal));\n    /// assert!(Float::INFINITY > Float::ONE);\n    /// assert!(Float::NEGATIVE_INFINITY < Float::ONE);\n    /// assert!(Float::ONE_HALF < Float::ONE);\n    /// assert!(Float::ONE_HALF > Float::NEGATIVE_ONE);\n    /// ```\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) | (_, float_nan!()) => None,\n            (float_infinity!(), float_infinity!())\n            | (float_negative_infinity!(), float_negative_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => Some(Equal),\n            (float_infinity!(), _) | (_, float_negative_infinity!()) => Some(Greater),\n            (float_negative_infinity!(), _) | (_, float_infinity!()) => Some(Less),\n            (Self(Finite { sign, .. }), float_either_zero!()) => {\n                Some(if *sign { Greater } else { Less })\n            }\n            (float_either_zero!(), Self(Finite { sign, .. })) => {\n                Some(if *sign { Less } else { Greater })\n            }\n            (\n                Self(Finite {\n                    sign: s_x,\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                Self(Finite {\n                    sign: s_y,\n                    exponent: e_y,\n                    significand: y,\n                    ..\n                }),\n            ) => Some(s_x.cmp(s_y).then_with(|| {\n                let abs_cmp = e_x.cmp(e_y).then_with(|| x.cmp_normalized_no_shift(y));\n                if *s_x { abs_cmp } else { abs_cmp.reverse() }\n            })),\n        }\n    }\n}\n\nimpl<'a> Ord for ComparableFloatRef<'a> {\n    /// Compares two [`ComparableFloatRef`]s.\n    ///\n    /// This implementation does not follow the IEEE 754 standard. This is how\n    /// [`ComparableFloatRef`]s are ordered, least to greatest:\n    ///   - $-\\infty$\n    ///   - Negative nonzero finite floats\n    ///   - Negative zero\n    ///   - NaN\n    ///   - Positive zero\n    ///   - Positive nonzero finite floats\n    ///   - $\\infty$\n    ///\n    /// When comparing two finite floats with the same numeric value but different precisions, the\n    /// one with greater precision is ordered to be further from zero.\n    ///\n    /// For different comparison behavior that follows the IEEE 754 standard, consider just using\n    /// [`Float`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloatRef, Float};\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::NAN).partial_cmp(&ComparableFloatRef(&Float::NAN)),\n    ///     Some(Equal)\n    /// );\n    /// assert!(ComparableFloatRef(&Float::ZERO) > ComparableFloatRef(&Float::NEGATIVE_ZERO));\n    /// assert!(ComparableFloatRef(&Float::ONE) < ComparableFloatRef(&Float::one_prec(100)));\n    /// assert!(ComparableFloatRef(&Float::INFINITY) > ComparableFloatRef(&Float::ONE));\n    /// assert!(ComparableFloatRef(&Float::NEGATIVE_INFINITY) < ComparableFloatRef(&Float::ONE));\n    /// assert!(ComparableFloatRef(&Float::ONE_HALF) < ComparableFloatRef(&Float::ONE));\n    /// assert!(ComparableFloatRef(&Float::ONE_HALF) > ComparableFloatRef(&Float::NEGATIVE_ONE));\n    /// ```\n    fn cmp(&self, other: &Self) -> Ordering {\n        match (&self.0, &other.0) {\n            (float_nan!(), float_nan!())\n            | (float_infinity!(), float_infinity!())\n            | (float_negative_infinity!(), float_negative_infinity!()) => Equal,\n            (Float(Zero { sign: s_x }), Float(Zero { sign: s_y })) => s_x.cmp(s_y),\n            (float_infinity!(), _) | (_, float_negative_infinity!()) => Greater,\n            (float_negative_infinity!(), _) | (_, float_infinity!()) => Less,\n            (Float(NaN | Zero { .. }), Float(Finite { sign, .. }))\n            | (Float(NaN), Float(Zero { sign })) => {\n                if *sign {\n                    Less\n                } else {\n                    Greater\n                }\n            }\n            (Float(Finite { sign, .. } | Zero { sign }), Float(NaN))\n            | (Float(Finite { sign, .. }), Float(Zero { .. })) => {\n                if *sign {\n                    Greater\n                } else {\n                    Less\n                }\n            }\n            (\n                Float(Finite {\n                    sign: s_x,\n                    exponent: e_x,\n                    precision: p_x,\n                    significand: x,\n                }),\n                Float(Finite {\n                    sign: s_y,\n                    exponent: e_y,\n                    precision: p_y,\n                    significand: y,\n                }),\n            ) => s_x.cmp(s_y).then_with(|| {\n                let abs_cmp = e_x\n                    .cmp(e_y)\n                    .then_with(|| x.cmp_normalized_no_shift(y))\n                    .then_with(|| p_x.cmp(p_y));\n                if *s_x { abs_cmp } else { abs_cmp.reverse() }\n            }),\n        }\n    }\n}\n\nimpl PartialOrd for ComparableFloatRef<'_> {\n    /// Compares two [`ComparableFloatRef`]s.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp(&self, other: &ComparableFloatRef) -> Option<Ordering> {\n        Some(self.cmp(other))\n    }\n}\n\nimpl Ord for ComparableFloat {\n    /// Compares two [`ComparableFloat`]s.\n    ///\n    /// This implementation does not follow the IEEE 754 standard. This is how [`ComparableFloat`]s\n    /// are ordered, least to greatest:\n    ///   - $-\\infty$\n    ///   - Negative nonzero finite floats\n    ///   - Negative zero\n    ///   - NaN\n    ///   - Positive zero\n    ///   - Positive nonzero finite floats\n    ///   - $\\infty$\n    ///\n    /// When comparing two finite floats with the same numeric value but different precisions, the\n    /// one with greater precision is ordered to be further from zero.\n    ///\n    /// For different comparison behavior that follows the IEEE 754 standard, consider just using\n    /// [`Float`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Zero,\n    /// };\n    /// use malachite_float::{ComparableFloat, Float};\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NAN).partial_cmp(&ComparableFloat(Float::NAN)),\n    ///     Some(Equal)\n    /// );\n    /// assert!(ComparableFloat(Float::ZERO) > ComparableFloat(Float::NEGATIVE_ZERO));\n    /// assert!(ComparableFloat(Float::ONE) < ComparableFloat(Float::one_prec(100)));\n    /// assert!(ComparableFloat(Float::INFINITY) > ComparableFloat(Float::ONE));\n    /// assert!(ComparableFloat(Float::NEGATIVE_INFINITY) < ComparableFloat(Float::ONE));\n    /// assert!(ComparableFloat(Float::ONE_HALF) < ComparableFloat(Float::ONE));\n    /// assert!(ComparableFloat(Float::ONE_HALF) > ComparableFloat(Float::NEGATIVE_ONE));\n    /// ```\n    #[inline]\n    fn cmp(&self, other: &Self) -> Ordering {\n        self.as_ref().cmp(&other.as_ref())\n    }\n}\n\n#[allow(clippy::non_canonical_partial_ord_impl)]\nimpl PartialOrd for ComparableFloat {\n    /// Compares two [`ComparableFloat`]s.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        Some(self.as_ref().cmp(&other.as_ref()))\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{ComparableFloat, ComparableFloatRef, Float};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\n\nimpl PartialOrdAbs for Float {\n    /// Compares the absolute values of two [`Float`]s.\n    ///\n    /// This implementation follows the IEEE 754 standard. `NaN` is not comparable to anything, not\n    /// even itself. [`Float`]s with different precisions are equal if they represent the same\n    /// numeric value.\n    ///\n    /// For different comparison behavior that provides a total order, consider using\n    /// [`ComparableFloat`] or [`ComparableFloatRef`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Zero,\n    /// };\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(Float::NAN.partial_cmp_abs(&Float::NAN), None);\n    /// assert_eq!(\n    ///     Float::ZERO.partial_cmp_abs(&Float::NEGATIVE_ZERO),\n    ///     Some(Equal)\n    /// );\n    /// assert_eq!(\n    ///     Float::ONE.partial_cmp_abs(&Float::one_prec(100)),\n    ///     Some(Equal)\n    /// );\n    /// assert!(Float::INFINITY.gt_abs(&Float::ONE));\n    /// assert!(Float::NEGATIVE_INFINITY.gt_abs(&Float::ONE));\n    /// assert!(Float::ONE_HALF.lt_abs(&Float::ONE));\n    /// assert!(Float::ONE_HALF.lt_abs(&Float::NEGATIVE_ONE));\n    /// ```\n    fn partial_cmp_abs(&self, other: &Self) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) | (_, float_nan!()) => None,\n            (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => Some(Equal),\n            (float_either_infinity!(), _) | (_, float_either_zero!()) => Some(Greater),\n            (_, float_either_infinity!()) | (float_either_zero!(), _) => Some(Less),\n            (\n                Self(Finite {\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                Self(Finite {\n                    exponent: e_y,\n                    significand: y,\n                    ..\n                }),\n            ) => Some(e_x.cmp(e_y).then_with(|| x.cmp_normalized_no_shift(y))),\n        }\n    }\n}\n\nimpl<'a> OrdAbs for ComparableFloatRef<'a> {\n    /// Compares the absolute values of two [`ComparableFloatRef`]s.\n    ///\n    /// This implementation does not follow the IEEE 754 standard. This is how\n    /// [`ComparableFloatRef`]s are ordered by absolute value, from least to greatest:\n    ///   - NaN\n    ///   - Positive and negative zero\n    ///   - Nonzero finite floats\n    ///   - $\\infty$ and $-\\infty$\n    ///\n    /// For different comparison behavior that follows the IEEE 754 standard, consider just using\n    /// [`Float`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Zero,\n    /// };\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::{ComparableFloatRef, Float};\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::NAN).partial_cmp_abs(&ComparableFloatRef(&Float::NAN)),\n    ///     Some(Equal)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::ZERO)\n    ///         .partial_cmp_abs(&ComparableFloatRef(&Float::NEGATIVE_ZERO)),\n    ///     Some(Equal)\n    /// );\n    /// assert!(ComparableFloatRef(&Float::ONE).lt_abs(&ComparableFloatRef(&Float::one_prec(100))));\n    /// assert!(ComparableFloatRef(&Float::INFINITY).gt_abs(&ComparableFloatRef(&Float::ONE)));\n    /// assert!(\n    ///     ComparableFloatRef(&Float::NEGATIVE_INFINITY).gt_abs(&ComparableFloatRef(&Float::ONE))\n    /// );\n    /// assert!(ComparableFloatRef(&Float::ONE_HALF).lt_abs(&ComparableFloatRef(&Float::ONE)));\n    /// assert!(\n    ///     ComparableFloatRef(&Float::ONE_HALF).lt_abs(&ComparableFloatRef(&Float::NEGATIVE_ONE))\n    /// );\n    /// ```\n    #[allow(clippy::match_same_arms)]\n    fn cmp_abs(&self, other: &Self) -> Ordering {\n        match (&self.0, &other.0) {\n            (float_nan!(), float_nan!())\n            | (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => Equal,\n            (float_either_infinity!(), _) | (_, float_nan!()) => Greater,\n            (_, float_either_infinity!()) | (float_nan!(), _) => Less,\n            (float_either_zero!(), _) => Less,\n            (_, float_either_zero!()) => Greater,\n            (\n                Float(Finite {\n                    exponent: e_x,\n                    precision: p_x,\n                    significand: x,\n                    ..\n                }),\n                Float(Finite {\n                    exponent: e_y,\n                    precision: p_y,\n                    significand: y,\n                    ..\n                }),\n            ) => e_x\n                .cmp(e_y)\n                .then_with(|| x.cmp_normalized_no_shift(y))\n                .then_with(|| p_x.cmp(p_y)),\n        }\n    }\n}\n\nimpl PartialOrdAbs for ComparableFloatRef<'_> {\n    /// Compares the absolute values of two [`ComparableFloatRef`]s.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp_abs(&self, other: &ComparableFloatRef) -> Option<Ordering> {\n        Some(self.cmp_abs(other))\n    }\n}\n\nimpl OrdAbs for ComparableFloat {\n    /// Compares the absolute values of two [`ComparableFloat`]s.\n    ///\n    /// This implementation does not follow the IEEE 754 standard. This is how [`ComparableFloat`]s\n    /// are ordered by absolute value, from least to greatest:\n    ///   - NaN\n    ///   - Positive and negative zero\n    ///   - Nonzero finite floats\n    ///   - $\\infty$ and $-\\infty$\n    ///\n    /// For different comparison behavior that follows the IEEE 754 standard, consider just using\n    /// [`Float`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{\n    ///     Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Zero,\n    /// };\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::{ComparableFloat, Float};\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NAN).partial_cmp_abs(&ComparableFloat(Float::NAN)),\n    ///     Some(Equal)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloat(Float::ZERO).partial_cmp_abs(&ComparableFloat(Float::NEGATIVE_ZERO)),\n    ///     Some(Equal)\n    /// );\n    /// assert!(ComparableFloat(Float::ONE).lt_abs(&ComparableFloat(Float::one_prec(100))));\n    /// assert!(ComparableFloat(Float::INFINITY).gt_abs(&ComparableFloat(Float::ONE)));\n    /// assert!(ComparableFloat(Float::NEGATIVE_INFINITY).gt_abs(&ComparableFloat(Float::ONE)));\n    /// assert!(ComparableFloat(Float::ONE_HALF).lt_abs(&ComparableFloat(Float::ONE)));\n    /// assert!(ComparableFloat(Float::ONE_HALF).lt_abs(&ComparableFloat(Float::NEGATIVE_ONE)));\n    /// ```\n    #[inline]\n    fn cmp_abs(&self, other: &Self) -> Ordering {\n        self.as_ref().cmp_abs(&other.as_ref())\n    }\n}\n\nimpl PartialOrdAbs for ComparableFloat {\n    /// Compares the absolute values of two [`ComparableFloatRef`]s.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Self) -> Option<Ordering> {\n        Some(self.as_ref().cmp_abs(&other.as_ref()))\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{ComparableFloat, ComparableFloatRef, Float};\nuse core::cmp::Ordering::*;\n\nimpl PartialEq for Float {\n    /// Compares two [`Float`]s for equality.\n    ///\n    /// This implementation follows the IEEE 754 standard. `NaN` is not equal to anything, not even\n    /// itself. Positive zero is equal to negative zero. [`Float`]s with different precisions are\n    /// equal if they represent the same numeric value.\n    ///\n    /// For different equality behavior, consider using [`ComparableFloat`] or\n    /// [`ComparableFloatRef`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NaN, NegativeZero, One, Two, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_ne!(Float::NAN, Float::NAN);\n    /// assert_eq!(Float::ZERO, Float::ZERO);\n    /// assert_eq!(Float::NEGATIVE_ZERO, Float::NEGATIVE_ZERO);\n    /// assert_eq!(Float::ZERO, Float::NEGATIVE_ZERO);\n    ///\n    /// assert_eq!(Float::ONE, Float::ONE);\n    /// assert_ne!(Float::ONE, Float::TWO);\n    /// assert_eq!(Float::ONE, Float::one_prec(100));\n    /// ```\n    fn eq(&self, other: &Self) -> bool {\n        match (self, other) {\n            (Self(Infinity { sign: s_x }), Self(Infinity { sign: s_y })) => s_x == s_y,\n            (float_either_zero!(), float_either_zero!()) => true,\n            (\n                Self(Finite {\n                    sign: s_x,\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                Self(Finite {\n                    sign: s_y,\n                    exponent: e_y,\n                    significand: y,\n                    ..\n                }),\n            ) => e_x == e_y && s_x == s_y && x.cmp_normalized_no_shift(y) == Equal,\n            _ => false,\n        }\n    }\n}\n\nimpl PartialEq for ComparableFloat {\n    /// Compares two [`ComparableFloat`]s for equality.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of an equality operation that\n    /// respects the expected properties of symmetry, reflexivity, and transitivity. Using\n    /// [`ComparableFloat`], `NaN`s are equal to themselves. There is a single, unique `NaN`;\n    /// there's no concept of signalling `NaN`s. Positive and negative zero are two distinct values,\n    /// not equal to each other. [`ComparableFloat`]s with different precisions are unequal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NaN, NegativeZero, One, Two, Zero};\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(ComparableFloat(Float::NAN), ComparableFloat(Float::NAN));\n    /// assert_eq!(ComparableFloat(Float::ZERO), ComparableFloat(Float::ZERO));\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NEGATIVE_ZERO),\n    ///     ComparableFloat(Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloat(Float::ZERO),\n    ///     ComparableFloat(Float::NEGATIVE_ZERO)\n    /// );\n    ///\n    /// assert_eq!(ComparableFloat(Float::ONE), ComparableFloat(Float::ONE));\n    /// assert_ne!(ComparableFloat(Float::ONE), ComparableFloat(Float::TWO));\n    /// assert_ne!(\n    ///     ComparableFloat(Float::ONE),\n    ///     ComparableFloat(Float::one_prec(100))\n    /// );\n    /// ```\n    #[inline]\n    fn eq(&self, other: &Self) -> bool {\n        self.as_ref() == other.as_ref()\n    }\n}\n\nimpl Eq for ComparableFloat {}\n\nimpl<'a> PartialEq<ComparableFloatRef<'a>> for ComparableFloatRef<'_> {\n    /// Compares two [`ComparableFloatRef`]s for equality.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of an equality operation that\n    /// respects the expected properties of symmetry, reflexivity, and transitivity. Using\n    /// [`ComparableFloatRef`], `NaN`s are equal to themselves. There is a single, unique `NaN`;\n    /// there's no concept of signalling `NaN`s. Positive and negative zero are two distinct values,\n    /// not equal to each other. [`ComparableFloatRef`]s with different precisions are unequal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NaN, NegativeZero, One, Two, Zero};\n    /// use malachite_float::{ComparableFloatRef, Float};\n    ///\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::NAN),\n    ///     ComparableFloatRef(&Float::NAN)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::ZERO),\n    ///     ComparableFloatRef(&Float::ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::NEGATIVE_ZERO),\n    ///     ComparableFloatRef(&Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloatRef(&Float::ZERO),\n    ///     ComparableFloatRef(&Float::NEGATIVE_ZERO)\n    /// );\n    ///\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::ONE),\n    ///     ComparableFloatRef(&Float::ONE)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloatRef(&Float::ONE),\n    ///     ComparableFloatRef(&Float::TWO)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloatRef(&Float::ONE),\n    ///     ComparableFloatRef(&Float::one_prec(100))\n    /// );\n    /// ```\n    fn eq(&self, other: &ComparableFloatRef<'a>) -> bool {\n        match (&self.0, &other.0) {\n            (float_nan!(), float_nan!()) => true,\n            (Float(Infinity { sign: s_x }), Float(Infinity { sign: s_y }))\n            | (Float(Zero { sign: s_x }), Float(Zero { sign: s_y })) => s_x == s_y,\n            (\n                Float(Finite {\n                    sign: s_x,\n                    exponent: e_x,\n                    precision: p_x,\n                    significand: x,\n                }),\n                Float(Finite {\n                    sign: s_y,\n                    exponent: e_y,\n                    precision: p_y,\n                    significand: y,\n                }),\n            ) => s_x == s_y && e_x == e_y && p_x == p_y && x == y,\n            _ => false,\n        }\n    }\n}\n\nimpl Eq for ComparableFloatRef<'_> {}\n"
  },
  {
    "path": "malachite-float/src/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{ComparableFloat, ComparableFloatRef, Float};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nimpl EqAbs for Float {\n    /// Compares the absolute values of two [`Float`]s for equality.\n    ///\n    /// This implementation follows the IEEE 754 standard. `NaN` is not equal to anything, not even\n    /// itself. Positive zero is equal to negative zero. [`Float`]s with different precisions are\n    /// equal if they represent the same numeric value.\n    ///\n    /// For different equality behavior, consider using [`ComparableFloat`] or\n    /// [`ComparableFloatRef`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NaN, NegativeZero, One, Two, Zero};\n    /// use malachite_float::Float;\n    ///\n    /// assert_ne!(Float::NAN, Float::NAN);\n    /// assert_eq!(Float::ZERO, Float::ZERO);\n    /// assert_eq!(Float::NEGATIVE_ZERO, Float::NEGATIVE_ZERO);\n    /// assert_eq!(Float::ZERO, Float::NEGATIVE_ZERO);\n    ///\n    /// assert_eq!(Float::ONE, Float::ONE);\n    /// assert_ne!(Float::ONE, Float::TWO);\n    /// assert_eq!(Float::ONE, Float::one_prec(100));\n    /// ```\n    fn eq_abs(&self, other: &Self) -> bool {\n        match (self, other) {\n            (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => true,\n            (\n                Self(Finite {\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                Self(Finite {\n                    exponent: e_y,\n                    significand: y,\n                    ..\n                }),\n            ) => e_x == e_y && x.cmp_normalized_no_shift(y) == Equal,\n            _ => false,\n        }\n    }\n}\n\nimpl EqAbs for ComparableFloat {\n    /// Compares the absolute values of two [`ComparableFloat`]s for equality.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of an equality operation that\n    /// respects the expected properties of symmetry, reflexivity, and transitivity. Using\n    /// [`ComparableFloat`], `NaN`s are equal to themselves. There is a single, unique `NaN`;\n    /// there's no concept of signalling `NaN`s. [`ComparableFloat`]s with different precisions are\n    /// unequal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NaN, NegativeZero, One, Two, Zero};\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// assert_eq!(ComparableFloat(Float::NAN), ComparableFloat(Float::NAN));\n    /// assert_eq!(ComparableFloat(Float::ZERO), ComparableFloat(Float::ZERO));\n    /// assert_eq!(\n    ///     ComparableFloat(Float::NEGATIVE_ZERO),\n    ///     ComparableFloat(Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloat(Float::ZERO),\n    ///     ComparableFloat(Float::NEGATIVE_ZERO)\n    /// );\n    ///\n    /// assert_eq!(ComparableFloat(Float::ONE), ComparableFloat(Float::ONE));\n    /// assert_ne!(ComparableFloat(Float::ONE), ComparableFloat(Float::TWO));\n    /// assert_ne!(\n    ///     ComparableFloat(Float::ONE),\n    ///     ComparableFloat(Float::one_prec(100))\n    /// );\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Self) -> bool {\n        self.as_ref().eq_abs(&other.as_ref())\n    }\n}\n\nimpl<'a> EqAbs<ComparableFloatRef<'a>> for ComparableFloatRef<'_> {\n    /// Compares the absolute values of two [`ComparableFloatRef`]s for equality.\n    ///\n    /// This implementation ignores the IEEE 754 standard in favor of an equality operation that\n    /// respects the expected properties of symmetry, reflexivity, and transitivity. Using\n    /// [`ComparableFloatRef`], `NaN`s are equal to themselves. There is a single, unique `NaN`;\n    /// there's no concept of signalling `NaN`s. [`ComparableFloatRef`]s with different precisions\n    /// are unequal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NaN, NegativeZero, One, Two, Zero};\n    /// use malachite_float::{ComparableFloatRef, Float};\n    ///\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::NAN),\n    ///     ComparableFloatRef(&Float::NAN)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::ZERO),\n    ///     ComparableFloatRef(&Float::ZERO)\n    /// );\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::NEGATIVE_ZERO),\n    ///     ComparableFloatRef(&Float::NEGATIVE_ZERO)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloatRef(&Float::ZERO),\n    ///     ComparableFloatRef(&Float::NEGATIVE_ZERO)\n    /// );\n    ///\n    /// assert_eq!(\n    ///     ComparableFloatRef(&Float::ONE),\n    ///     ComparableFloatRef(&Float::ONE)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloatRef(&Float::ONE),\n    ///     ComparableFloatRef(&Float::TWO)\n    /// );\n    /// assert_ne!(\n    ///     ComparableFloatRef(&Float::ONE),\n    ///     ComparableFloatRef(&Float::one_prec(100))\n    /// );\n    /// ```\n    fn eq_abs(&self, other: &ComparableFloatRef<'a>) -> bool {\n        match (&self.0, &other.0) {\n            (float_nan!(), float_nan!())\n            | (float_either_infinity!(), float_either_infinity!())\n            | (float_either_zero!(), float_either_zero!()) => true,\n            (\n                Float(Finite {\n                    exponent: e_x,\n                    precision: p_x,\n                    significand: x,\n                    ..\n                }),\n                Float(Finite {\n                    exponent: e_y,\n                    precision: p_y,\n                    significand: y,\n                    ..\n                }),\n            ) => e_x == e_y && p_x == p_y && x == y,\n            _ => false,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/eq_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\n\nimpl EqAbs<Integer> for Float {\n    /// Determines whether the absolute value of a [`Float`] is equal to the absolute value of an\n    /// [`Integer`].\n    ///\n    /// $\\infty$, $-\\infty$, and NaN are not equal to any [`Integer`]. Both the [`Float`] zero and\n    /// the [`Float`] negative zero are equal to the [`Integer`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Float::from(123).eq_abs(&Integer::from(123)));\n    /// assert!(Float::from(-123).eq_abs(&Integer::from(-123)));\n    /// assert!(Float::ONE_HALF.ne_abs(&Integer::ONE));\n    /// ```\n    fn eq_abs(&self, other: &Integer) -> bool {\n        match self {\n            float_either_zero!() => *other == 0u32,\n            Self(Finite {\n                exponent,\n                significand,\n                ..\n            }) => {\n                *other != 0u32\n                    && *exponent >= 0\n                    && other.significant_bits() == u64::from(exponent.unsigned_abs())\n                    && significand.cmp_normalized(other.unsigned_abs_ref()) == Equal\n            }\n            _ => false,\n        }\n    }\n}\n\nimpl EqAbs<Float> for Integer {\n    /// Determines whether the absolute value of an [`Integer`] is equal to the absolute value of a\n    /// [`Float`].\n    ///\n    /// No [`Integer`] is equal to $\\infty$, $-\\infty$, or NaN. The [`Integer`] zero is equal to\n    /// both the [`Float`] zero and the [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::from(123).eq_abs(&Float::from(123)));\n    /// assert!(Integer::from(-123).eq_abs(&Float::from(-123)));\n    /// assert!(Integer::ONE.ne_abs(&Float::ONE_HALF));\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Float) -> bool {\n        other.eq_abs(self)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\nimpl EqAbs<Natural> for Float {\n    /// Determines whether the absolute value of a [`Float`] is equal to a [`Natural`].\n    ///\n    /// $\\infty$, $-\\infty$, and NaN are not equal to any [`Natural`]. Both the [`Float`] zero and\n    /// the [`Float`] negative zero are equal to the [`Natural`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Float::from(123).eq_abs(&Natural::from(123u32)));\n    /// assert!(Float::ONE_HALF.ne_abs(&Natural::ONE));\n    /// ```\n    fn eq_abs(&self, other: &Natural) -> bool {\n        match self {\n            float_either_zero!() => *other == 0u32,\n            Self(Finite {\n                exponent,\n                significand,\n                ..\n            }) => {\n                *other != 0u32\n                    && *exponent >= 0\n                    && other.significant_bits() == u64::from(exponent.unsigned_abs())\n                    && significand.cmp_normalized(other) == Equal\n            }\n            _ => false,\n        }\n    }\n}\n\nimpl EqAbs<Float> for Natural {\n    /// Determines whether a [`Natural`] is equal to the absolute value of a [`Float`].\n    ///\n    /// No [`Natural`] is equal to $\\infty$, $-\\infty$, or NaN. The [`Natural`] zero is equal to\n    /// both the [`Float`] zero and the [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(123u32).eq_abs(&Float::from(123)));\n    /// assert!(Natural::ONE.ne_abs(&Float::ONE_HALF));\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Float) -> bool {\n        other.eq_abs(self)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_nz::natural::Natural;\n\nfn float_eq_abs_primitive_float<T: PrimitiveFloat>(x: &Float, y: &T) -> bool {\n    match x {\n        float_nan!() => false,\n        float_either_infinity!() => *y == T::INFINITY || *y == T::NEGATIVE_INFINITY,\n        float_either_zero!() => *y == T::ZERO,\n        Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) => {\n            y.is_finite()\n                && *y != T::ZERO\n                && i64::from(*exponent - 1) == y.sci_exponent()\n                && significand.cmp_normalized(&Natural::from(y.integer_mantissa())) == Equal\n        }\n    }\n}\n\nmacro_rules! impl_eq_abs_primitive_float {\n    ($t: ident) => {\n        impl EqAbs<$t> for Float {\n            /// Determines whether the absolute value of a [`Float`] is equal to the absolute value\n            /// of a primitive float.\n            ///\n            /// The [`Float`] $\\infty$ is equal to the primitive float $\\infty$, and the [`Float`]\n            /// $-\\infty$ is equal to the primitive float $-\\infty$. The [`Float`] NaN is not equal\n            /// to anything, not even the primitive float NaN. Every [`Float`] zero is equal to\n            /// every primitive float zero, regardless of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                float_eq_abs_primitive_float(self, other)\n            }\n        }\n\n        impl EqAbs<Float> for $t {\n            /// Determines whether a primitive float is equal to a [`Float`].\n            ///\n            /// The primitive float $\\infty$ is equal to the [`Float`] $\\infty$, and the primitive\n            /// float $-\\infty$ is equal to the [`Float`] $-\\infty$. The primitive float NaN is not\n            /// equal to anything, not even the [`Float`] NaN. Every primitive float zero is equal\n            /// to every [`Float`] zero, regardless of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Float) -> bool {\n                other.eq_abs(self)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_eq_abs_primitive_float);\n"
  },
  {
    "path": "malachite-float/src/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_nz::natural::Natural;\n\nfn float_eq_abs_unsigned<T: PrimitiveUnsigned>(x: &Float, y: &T) -> bool\nwhere\n    Natural: From<T>,\n{\n    match x {\n        float_either_zero!() => *y == T::ZERO,\n        Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) => {\n            *y != T::ZERO\n                && *exponent >= 0\n                && y.significant_bits() == u64::from(exponent.unsigned_abs())\n                && significand.cmp_normalized(&Natural::from(*y)) == Equal\n        }\n        _ => false,\n    }\n}\n\nmacro_rules! impl_eq_abs_unsigned {\n    ($t: ident) => {\n        impl EqAbs<$t> for Float {\n            /// Determines whether the absolute value of a [`Float`] is equal to an unsigned\n            /// primitive integer.\n            ///\n            /// $\\infty$, $-\\infty$, and NaN are not equal to any primitive integer. Both the\n            /// [`Float`] zero and the [`Float`] negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                float_eq_abs_unsigned(self, other)\n            }\n        }\n\n        impl EqAbs<Float> for $t {\n            /// Determines whether an unsigned primitive integer is equal to the absolute value of a\n            /// [`Float`].\n            ///\n            /// No primitive integer is equal to $\\infty$, $-\\infty$, or NaN. The integer zero is\n            /// equal to both the [`Float`] zero and the [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq_abs(&self, other: &Float) -> bool {\n                other.eq_abs(self)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_eq_abs_unsigned);\n\nfn float_eq_abs_signed<T: PrimitiveSigned>(x: &Float, y: &T) -> bool\nwhere\n    Natural: From<<T as UnsignedAbs>::Output>,\n{\n    match x {\n        float_either_zero!() => *y == T::ZERO,\n        Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) => {\n            *y != T::ZERO\n                && *exponent >= 0\n                && y.significant_bits() == u64::from(exponent.unsigned_abs())\n                && significand.cmp_normalized(&Natural::from(y.unsigned_abs())) == Equal\n        }\n        _ => false,\n    }\n}\n\nmacro_rules! impl_eq_abs_signed {\n    ($t: ident) => {\n        impl EqAbs<$t> for Float {\n            /// Determines whether the absolute value of a [`Float`] is equal to the absolute value\n            /// of a signed primitive integer.\n            ///\n            /// $\\infty$, $-\\infty$, and NaN are not equal to any primitive integer. Both the\n            /// [`Float`] zero and the [`Float`] negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::eq_abs#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                float_eq_abs_signed(self, other)\n            }\n        }\n\n        impl EqAbs<Float> for $t {\n            /// Determines whether the absolute value of a signed primitive integer is equal to the\n            /// absolute value of a [`Float`].\n            ///\n            /// No primitive integer is equal to $\\infty$, $-\\infty$, or NaN. The integer zero is\n            /// equal to both the [`Float`] zero and the [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::eq_abs#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Float) -> bool {\n                other.eq_abs(self)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_eq_abs_signed);\n"
  },
  {
    "path": "malachite-float/src/comparison/eq_abs_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::CheckedLogBase2;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_q::Rational;\n\nimpl EqAbs<Rational> for Float {\n    /// Determines whether the absolute value of a [`Float`] is equal to the absolute value of a\n    /// [`Rational`].\n    ///\n    /// $\\infty$, $-\\infty$, and NaN are not equal to any [`Rational`]. Both the [`Float`] zero and\n    /// the [`Float`] negative zero are equal to the [`Rational`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Float::from(123).eq_abs(&Rational::from(123)));\n    /// assert!(Float::from(-123).eq_abs(&Rational::from(123)));\n    /// assert!(Float::ONE_HALF.eq_abs(&Rational::ONE_HALF));\n    /// assert!(Float::from(1.0f64 / 3.0).ne_abs(&Rational::from_unsigneds(1u8, 3)));\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Rational) -> bool {\n        match self {\n            float_either_zero!() => *other == 0u32,\n            Self(Finite {\n                exponent,\n                significand,\n                ..\n            }) => {\n                *other != 0\n                    && if let Some(log_d) = other.denominator_ref().checked_log_base_2() {\n                        let n = other.numerator_ref();\n                        i64::from(*exponent)\n                            == i64::exact_from(n.significant_bits()) - i64::exact_from(log_d)\n                            && significand.cmp_normalized(n) == Equal\n                    } else {\n                        false\n                    }\n            }\n            _ => false,\n        }\n    }\n}\n\nimpl EqAbs<Float> for Rational {\n    /// Determines whether the absolute value of a [`Rational`] is equal to the absolute value of a\n    /// [`Float`].\n    ///\n    /// No [`Rational`] is equal to $\\infty$, $-\\infty$, or NaN. The [`Rational`] zero is equal to\n    /// both the [`Float`] zero and the [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from(123).eq_abs(&Float::from(123)));\n    /// assert!(Rational::from(-123).eq_abs(&Float::from(123)));\n    /// assert!(Rational::ONE_HALF.eq_abs(&Float::ONE_HALF));\n    /// assert!(Rational::from_unsigneds(1u8, 3).ne_abs(&Float::from(1.0f64 / 3.0)));\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Float) -> bool {\n        other.eq_abs(self)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{ComparableFloat, ComparableFloatRef, Float};\nuse core::hash::{Hash, Hasher};\n\nimpl Hash for ComparableFloat {\n    /// Computes a hash of a `ComparableFloat`.\n    ///\n    /// The hash is compatible with `ComparableFloat` equality: all `NaN`s hash to the same value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    #[inline]\n    fn hash<H: Hasher>(&self, state: &mut H) {\n        self.as_ref().hash(state);\n    }\n}\n\nimpl Hash for ComparableFloatRef<'_> {\n    /// Computes a hash of a `ComparableFloatRef`.\n    ///\n    /// The hash is compatible with `ComparableFloatRef` equality: all `NaN`s hash to the same\n    /// value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    fn hash<H: Hasher>(&self, state: &mut H) {\n        match self.0 {\n            float_nan!() => \"NaN\".hash(state),\n            Float(Infinity { sign }) => {\n                if *sign {\n                    \"Infinity\".hash(state);\n                } else {\n                    \"-Infinity\".hash(state);\n                }\n            }\n            Float(Zero { sign }) => {\n                if *sign {\n                    \"0.0\".hash(state);\n                } else {\n                    \"-0.0\".hash(state);\n                }\n            }\n            Float(Finite {\n                sign,\n                exponent,\n                precision,\n                significand,\n            }) => {\n                sign.hash(state);\n                exponent.hash(state);\n                precision.hash(state);\n                significand.hash(state);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Comparison of [`Float`](crate::Float)s.\npub mod cmp;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// and [`OrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`) (traits for comparing\n/// the absolute values of numbers by order) for [`Float`](crate::Float)s.\npub mod cmp_abs;\n/// Equality of [`Float`](crate::Float)s.\npub mod eq;\n/// Implementations of [`EqAbs`](`malachite_base::num::comparison::traits::EqAbs`) (a trait for\n/// comparing the absolute values of numbers by equality) for [`Float`](crate::Float)s.\npub mod eq_abs;\n/// Implementations of [`EqAbs`](`malachite_base::num::comparison::traits::EqAbs`) (a trait for\n/// comparing the absolute values of numbers for equality) for [`Float`](crate::Float)s and\n/// [`Integer`](malachite_nz::integer::Integer)s.\npub mod eq_abs_integer;\n/// Implementations of [`EqAbs`](`malachite_base::num::comparison::traits::EqAbs`) (a trait for\n/// comparing the absolute values of numbers for equality) for [`Float`](crate::Float)s and\n/// [`Natural`](malachite_nz::natural::Natural)s.\npub mod eq_abs_natural;\n/// Implementations of [`EqAbs`](`malachite_base::num::comparison::traits::EqAbs`) (a trait for\n/// comparing the absolute values of numbers for equality) for [`Float`](crate::Float)s and\n/// primitive floats.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_float::Float;\n///\n/// assert!(Float::from(123).eq_abs(&123.0));\n/// assert!(Float::ONE_HALF.eq_abs(&0.5));\n/// assert!(Float::ONE_HALF.eq_abs(&-0.5));\n/// assert!(Float::ONE_HALF.ne_abs(&0.4));\n///\n/// assert!(123.0.eq_abs(&Float::from(123)));\n/// assert!(0.5.eq_abs(&Float::ONE_HALF));\n/// assert!((-0.5).eq_abs(&Float::ONE_HALF));\n/// assert!(0.4.ne_abs(&Float::ONE_HALF));\n/// ```\npub mod eq_abs_primitive_float;\n/// Implementations of [`EqAbs`](`malachite_base::num::comparison::traits::EqAbs`) (a trait for\n/// comparing the absolute values of numbers for equality) for [`Float`](crate::Float)s and\n/// primitive integers.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_float::Float;\n///\n/// assert!(Float::from(123).eq_abs(&123u64));\n/// assert!(Float::ONE_HALF.ne_abs(&1u64));\n///\n/// assert!(Float::from(123).eq_abs(&123i64));\n/// assert!(Float::from(-123).eq_abs(&123i64));\n/// assert!(Float::ONE_HALF.ne_abs(&-1i64));\n///\n/// assert!(123u64.eq_abs(&Float::from(123)));\n/// assert!(1u64.ne_abs(&Float::ONE_HALF));\n///\n/// assert!(123i64.eq_abs(&Float::from(123)));\n/// assert!(123i64.eq_abs(&Float::from(-123)));\n/// assert!((-1i64).ne_abs(&Float::ONE_HALF));\n/// ```\npub mod eq_abs_primitive_int;\n/// Implementations of [`EqAbs`](`malachite_base::num::comparison::traits::EqAbs`) (a trait for\n/// comparing the absolute values of numbers for equality) for [`Float`](crate::Float)s and\n/// [`Rational`](malachite_q::Rational)s.\npub mod eq_abs_rational;\n/// Hashing of [`Float`](crate::Float)s.\npub mod hash;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for [`Float`](crate::Float)s and\n/// [`Integer`](malachite_nz::integer::Integer)s.\npub mod partial_cmp_abs_integer;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for [`Float`](crate::Float)s and\n/// [`Natural`](malachite_nz::natural::Natural)s.\npub mod partial_cmp_abs_natural;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for [`Float`](crate::Float)s and\n/// primitive floats.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\n/// use malachite_float::Float;\n///\n/// assert!(Float::ONE_HALF.gt_abs(&0.4));\n/// assert!(Float::ONE_HALF.lt_abs(&0.6));\n/// assert!(Float::ONE_HALF.eq_abs(&-0.5));\n///\n/// assert!(0.4.lt_abs(&Float::ONE_HALF));\n/// assert!(0.6.gt_abs(&Float::ONE_HALF));\n/// assert!((-0.5).eq_abs(&Float::ONE_HALF));\n/// ```\npub mod partial_cmp_abs_primitive_float;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for [`Float`](crate::Float)s and\n/// primitive integers.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use malachite_float::Float;\n///\n/// assert!(Float::from(80).lt_abs(&100u64));\n/// assert!(Float::INFINITY.gt_abs(&100u64));\n/// assert!(Float::NEGATIVE_INFINITY.gt_abs(&100u64));\n///\n/// assert!(100u64.gt_abs(&Float::from(80)));\n/// assert!(100u64.lt_abs(&Float::INFINITY));\n/// assert!(100u64.lt_abs(&Float::NEGATIVE_INFINITY));\n///\n/// assert!(Float::from(80).lt_abs(&100i64));\n/// assert!(Float::from(-80).lt_abs(&-100i64));\n/// assert!(Float::INFINITY.gt_abs(&100i64));\n/// assert!(Float::NEGATIVE_INFINITY.gt_abs(&-100i64));\n///\n/// assert!(100i64.gt_abs(&Float::from(80)));\n/// assert!(100i64.lt_abs(&Float::INFINITY));\n/// assert!((-100i64).lt_abs(&Float::INFINITY));\n/// assert!((-100i64).lt_abs(&Float::NEGATIVE_INFINITY));\n/// ```\npub mod partial_cmp_abs_primitive_int;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for [`Float`](crate::Float)s and\n/// [`Rational`](malachite_q::Rational)s.\npub mod partial_cmp_abs_rational;\n/// Comparison of [`Float`](crate::Float)s and [`Integer`](malachite_nz::integer::Integer)s.\npub mod partial_cmp_integer;\n/// Comparison of [`Float`](crate::Float)s and [`Natural`](malachite_nz::natural::Natural)s.\npub mod partial_cmp_natural;\n/// Comparison of [`Float`](crate::Float)s and primitive floats.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_float::Float;\n///\n/// assert!(Float::ONE_HALF > 0.4);\n/// assert!(Float::ONE_HALF < 0.6);\n/// assert!(Float::ONE_HALF > -0.5);\n///\n/// assert!(0.4 < Float::ONE_HALF);\n/// assert!(0.6 > Float::ONE_HALF);\n/// assert!(-0.5 < Float::ONE_HALF);\n/// ```\npub mod partial_cmp_primitive_float;\n/// Comparison of [`Float`](crate::Float)s and primitive integers.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n/// use malachite_float::Float;\n///\n/// assert!(Float::from(80) < 100u64);\n/// assert!(Float::INFINITY > 100u64);\n/// assert!(Float::NEGATIVE_INFINITY < 100u64);\n///\n/// assert!(100u64 > Float::from(80));\n/// assert!(100u64 < Float::INFINITY);\n/// assert!(100u64 > Float::NEGATIVE_INFINITY);\n///\n/// assert!(Float::from(80) < 100i64);\n/// assert!(Float::from(-80) > -100i64);\n/// assert!(Float::INFINITY > 100i64);\n/// assert!(Float::NEGATIVE_INFINITY < -100i64);\n///\n/// assert!(100i64 > Float::from(80));\n/// assert!(-100i64 < Float::from(-80));\n/// assert!(-100i64 < Float::INFINITY);\n/// assert!(-100i64 > Float::NEGATIVE_INFINITY);\n/// ```\npub mod partial_cmp_primitive_int;\n/// Comparison of [`Float`](crate::Float)s and [`Rational`](malachite_q::Rational)s.\npub mod partial_cmp_rational;\n/// Equality of [`Float`](crate::Float)s and [`Integer`](malachite_nz::integer::Integer)s.\npub mod partial_eq_integer;\n/// Equality of [`Float`](crate::Float)s and [`Natural`](malachite_nz::natural::Natural)s.\npub mod partial_eq_natural;\n/// Equality of [`Float`](crate::Float)s and primitive floats.\n///\n/// # partial_eq\n/// ```\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_float::Float;\n///\n/// assert!(Float::from(123) == 123.0);\n/// assert!(Float::ONE_HALF == 0.5);\n/// assert!(Float::ONE_HALF != -0.5);\n/// assert!(Float::ONE_HALF != 0.4);\n///\n/// assert!(123.0 == Float::from(123));\n/// assert!(0.5 == Float::ONE_HALF);\n/// assert!(-0.5 != Float::ONE_HALF);\n/// assert!(0.4 != Float::ONE_HALF);\n/// ```\npub mod partial_eq_primitive_float;\n/// Equality of [`Float`](crate::Float)s and primitive integers.\n///\n/// # partial_eq\n/// ```\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_float::Float;\n///\n/// assert!(Float::from(123) == 123u64);\n/// assert!(Float::ONE_HALF != 1u64);\n///\n/// assert!(Float::from(123) == 123i64);\n/// assert!(Float::from(-123) == -123i64);\n/// assert!(Float::ONE_HALF != -1i64);\n///\n/// assert!(123u64 == Float::from(123));\n/// assert!(1u64 != Float::ONE_HALF);\n///\n/// assert!(123i64 == Float::from(123));\n/// assert!(-123i64 == Float::from(-123));\n/// assert!(-1i64 != Float::ONE_HALF);\n/// ```\npub mod partial_eq_primitive_int;\n/// Equality of [`Float`](crate::Float)s and [`Rational`](malachite_q::Rational)s.\npub mod partial_eq_rational;\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\n\nimpl PartialOrdAbs<Integer> for Float {\n    /// Compares the absolute values of a [`Float`] and an [`Integer`].\n    ///\n    /// NaN is not comparable to any [`Integer`]. $\\infty$ and $-\\infty$ are greater in absolute\n    /// value than any [`Integer`]. Both the [`Float`] zero and the [`Float`] negative zero are\n    /// equal to the [`Integer`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Float::from(80).lt_abs(&Integer::from(100)));\n    /// assert!(Float::from(-80).lt_abs(&Integer::from(-100)));\n    /// assert!(Float::INFINITY.gt_abs(&Integer::from(100)));\n    /// assert!(Float::NEGATIVE_INFINITY.gt_abs(&Integer::from(-100)));\n    /// ```\n    fn partial_cmp_abs(&self, other: &Integer) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) => None,\n            (Self(Infinity { .. }), _) => Some(Greater),\n            (float_either_zero!(), y) => Some(if *y == 0 { Equal } else { Less }),\n            (\n                Self(Finite {\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                y,\n            ) => Some(if *other == 0 {\n                Greater\n            } else if *e_x <= 0 {\n                Less\n            } else {\n                u64::from(e_x.unsigned_abs())\n                    .cmp(&other.significant_bits())\n                    .then_with(|| x.cmp_normalized(y.unsigned_abs_ref()))\n            }),\n        }\n    }\n}\n\nimpl PartialOrdAbs<Float> for Integer {\n    /// Compares the absolute values of an [`Integer`] and a [`Float`].\n    ///\n    /// No [`Integer`] is comparable to NaN. Every [`Integer`] is smaller in absolute value than\n    /// $\\infty$ and $-\\infty$. The [`Integer`] zero is equal to both the [`Float`] zero and the\n    /// [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::from(100).gt_abs(&Float::from(80)));\n    /// assert!(Integer::from(100).lt_abs(&Float::INFINITY));\n    /// assert!(Integer::from(-100).lt_abs(&Float::INFINITY));\n    /// assert!(Integer::from(-100).lt_abs(&Float::NEGATIVE_INFINITY));\n    /// ```\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Float) -> Option<Ordering> {\n        other.partial_cmp_abs(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\nimpl PartialOrdAbs<Natural> for Float {\n    /// Compares the absolute value of a [`Float`] to a [`Natural`].\n    ///\n    /// NaN is not comparable to any [`Natural`]. $\\infty$ and $-\\infty$ are greater in absolute\n    /// value than any [`Natural`]. Both the [`Float`] zero and the [`Float`] negative zero are\n    /// equal to the [`Natural`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Float::from(80).lt_abs(&Natural::from(100u32)));\n    /// assert!(Float::INFINITY.gt_abs(&Natural::from(100u32)));\n    /// assert!(Float::NEGATIVE_INFINITY.gt_abs(&Natural::from(100u32)));\n    /// ```\n    fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) => None,\n            (Self(Infinity { .. }), _) => Some(Greater),\n            (float_either_zero!(), y) => Some(if *y == 0 { Equal } else { Less }),\n            (\n                Self(Finite {\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                y,\n            ) => Some(if *other == 0 {\n                Greater\n            } else if *e_x <= 0 {\n                Less\n            } else {\n                u64::from(e_x.unsigned_abs())\n                    .cmp(&other.significant_bits())\n                    .then_with(|| x.cmp_normalized(y))\n            }),\n        }\n    }\n}\n\nimpl PartialOrdAbs<Float> for Natural {\n    /// Compares a [`Natural`] to the absolute value of a [`Float`].\n    ///\n    /// No [`Natural`] is comparable to NaN. Every [`Natural`] is smaller in absolute value than\n    /// $\\infty$ and $-\\infty$. The [`Natural`] zero is equal to both the [`Float`] zero and the\n    /// [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(100u32).gt_abs(&Float::from(80)));\n    /// assert!(Natural::from(100u32).lt_abs(&Float::INFINITY));\n    /// assert!(Natural::from(100u32).lt_abs(&Float::NEGATIVE_INFINITY));\n    /// ```\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Float) -> Option<Ordering> {\n        other.partial_cmp_abs(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_nz::natural::Natural;\n\nfn float_partial_cmp_abs_primitive_float<T: PrimitiveFloat>(x: &Float, y: &T) -> Option<Ordering> {\n    match (x, y) {\n        (float_nan!(), _) => None,\n        (_, y) if y.is_nan() => None,\n        (Float(Infinity { .. }), y) if !y.is_finite() => Some(Equal),\n        (Float(Infinity { .. }), _) => Some(Greater),\n        (_, y) if !y.is_finite() => Some(Less),\n        (float_either_zero!(), y) => Some(if *y == T::ZERO { Equal } else { Less }),\n        (_, y) if *y == T::ZERO => Some(Greater),\n        (\n            Float(Finite {\n                exponent: e_x,\n                significand: m_x,\n                ..\n            }),\n            y,\n        ) => Some(\n            (i64::from(*e_x) - 1)\n                .cmp(&y.sci_exponent())\n                .then_with(|| m_x.cmp_normalized(&Natural::from(y.integer_mantissa()))),\n        ),\n    }\n}\n\nmacro_rules! impl_partial_cmp_abs_primitive_float {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Float {\n            /// Compares the absolute values of a [`Float`] and a primitive float.\n            ///\n            /// The [`Float`] NaN is not comparable to any primitive float, not even the primitive\n            /// float NaN. Every [`Float`] zero is equal to every primitive float zero, regardless\n            /// of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_abs_primitive_float#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                float_partial_cmp_abs_primitive_float(self, other)\n            }\n        }\n\n        impl PartialOrdAbs<Float> for $t {\n            /// Compares the absolute values of a primitive float and a [`Float`].\n            ///\n            /// The primitive float NaN is not comparable to any primitive float, not even the\n            /// [`Float`] NaN. Every primitive float zero is equal to every [`Float`] zero,\n            /// regardless of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Float) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_partial_cmp_abs_primitive_float);\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_nz::natural::Natural;\n\nfn float_partial_cmp_abs_unsigned<T: PrimitiveUnsigned>(x: &Float, y: &T) -> Option<Ordering>\nwhere\n    Natural: From<T>,\n{\n    match (x, y) {\n        (float_nan!(), _) => None,\n        (Float(Infinity { .. }), _) => Some(Greater),\n        (float_either_zero!(), y) => Some(if *y == T::ZERO { Equal } else { Less }),\n        (\n            Float(Finite {\n                exponent: e_x,\n                significand: sig_x,\n                ..\n            }),\n            y,\n        ) => Some(if *y == T::ZERO {\n            Greater\n        } else if *e_x <= 0 {\n            Less\n        } else {\n            u64::from(e_x.unsigned_abs())\n                .cmp(&y.significant_bits())\n                .then_with(|| sig_x.cmp_normalized(&Natural::from(*y)))\n        }),\n    }\n}\n\nmacro_rules! impl_from_unsigned {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Float {\n            /// Compares the absolute values of a [`Float`] and an unsigned primitive integer.\n            ///\n            /// NaN is not comparable to any primitive integer. $\\infty$ and $-\\infty$ are greater\n            /// in absolute value than any primitive integer. Both the [`Float`] zero and the\n            /// [`Float`] negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                float_partial_cmp_abs_unsigned(self, other)\n            }\n        }\n\n        impl PartialOrdAbs<Float> for $t {\n            /// Compares the absolute values of an unsigned primitive integer and a [`Float`].\n            ///\n            /// No primitive integer is comparable to NaN. Every primitive integer is smaller in\n            /// absolute value than $\\infty$ and $-\\infty$. The integer zero is equal to both the\n            /// [`Float`] zero and the [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Float) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_from_unsigned);\n\nfn float_partial_cmp_abs_signed<T: PrimitiveSigned>(x: &Float, y: &T) -> Option<Ordering>\nwhere\n    Natural: From<<T as UnsignedAbs>::Output>,\n{\n    match (x, y) {\n        (float_nan!(), _) => None,\n        (Float(Infinity { .. }), _) => Some(Greater),\n        (float_either_zero!(), y) => Some(if *y == T::ZERO { Equal } else { Less }),\n        (\n            Float(Finite {\n                exponent: e_x,\n                significand: sig_x,\n                ..\n            }),\n            y,\n        ) => Some(if *y == T::ZERO {\n            Greater\n        } else if *e_x <= 0 {\n            Less\n        } else {\n            u64::from(e_x.unsigned_abs())\n                .cmp(&y.significant_bits())\n                .then_with(|| sig_x.cmp_normalized(&Natural::from(y.unsigned_abs())))\n        }),\n    }\n}\n\nmacro_rules! impl_from_signed {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Float {\n            /// Compares the absolute values of a [`Float`] and a signed primitive integer.\n            ///\n            /// NaN is not comparable to any primitive integer. $\\infty$ and $-\\infty$ are greater\n            /// in absolute value than any primitive integer. Both the [`Float`] zero and the\n            /// [`Float`] negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                float_partial_cmp_abs_signed(self, other)\n            }\n        }\n\n        impl PartialOrdAbs<Float> for $t {\n            /// Compares the absolute values of a signed primitive integer and a [`Float`].\n            ///\n            /// No primitive integer is comparable to NaN. Every primitive integer is smaller in\n            /// absolute value than $\\infty$ and $-\\infty$. The integer zero is equal to both the\n            /// [`Float`] zero and the [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Float) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_from_signed);\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_abs_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_q::Rational;\n\nimpl PartialOrdAbs<Rational> for Float {\n    /// Compares the absolute values of a [`Float`] and a [`Rational`].\n    ///\n    /// NaN is not comparable to any [`Rational`]. $\\infty$ and $-\\infty$ are greater in absolute\n    /// value than any [`Rational`]. Both the [`Float`] zero and the [`Float`] negative zero are\n    /// equal to the [`Rational`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Float::from(80).lt_abs(&Rational::from(100)));\n    /// assert!(Float::from(-80).lt_abs(&Rational::from(-100)));\n    /// assert!(Float::INFINITY.gt_abs(&Rational::from(100)));\n    /// assert!(Float::NEGATIVE_INFINITY.gt_abs(&Rational::from(-100)));\n    /// assert!(Float::from(1.0f64 / 3.0).lt_abs(&Rational::from_unsigneds(1u8, 3)));\n    /// ```\n    fn partial_cmp_abs(&self, other: &Rational) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) => None,\n            (float_either_infinity!(), _) => Some(Greater),\n            (float_either_zero!(), y) => Some(if *y == 0 { Equal } else { Less }),\n            (\n                Self(Finite {\n                    exponent: e_x,\n                    significand: significand_x,\n                    ..\n                }),\n                y,\n            ) => Some(if *y == 0u32 {\n                Greater\n            } else {\n                let e_x = i64::from(*e_x);\n                let exp_cmp = (e_x - 1).cmp(&y.floor_log_base_2_abs());\n                if exp_cmp != Equal {\n                    return Some(exp_cmp);\n                }\n                let shift = e_x - i64::exact_from(significand_bits(significand_x));\n                let abs_shift = shift.unsigned_abs();\n                match shift.sign() {\n                    Equal => (significand_x * other.denominator_ref()).cmp(other.numerator_ref()),\n                    Greater => ((significand_x * other.denominator_ref()) << abs_shift)\n                        .cmp(other.numerator_ref()),\n                    Less => {\n                        let n_trailing_zeros = significand_x.trailing_zeros().unwrap();\n                        if abs_shift <= n_trailing_zeros {\n                            ((significand_x >> abs_shift) * other.denominator_ref())\n                                .cmp(other.numerator_ref())\n                        } else {\n                            ((significand_x >> n_trailing_zeros) * other.denominator_ref())\n                                .cmp(&(other.numerator_ref() << (abs_shift - n_trailing_zeros)))\n                        }\n                    }\n                }\n            }),\n        }\n    }\n}\n\nimpl PartialOrdAbs<Float> for Rational {\n    /// Compares the absolute values of a [`Rational`] and a [`Float`].\n    ///\n    /// No [`Rational`] is comparable to NaN. Every [`Rational`] is smaller in absolute value than\n    /// $\\infty$ and $-\\infty$. The [`Rational`] zero is equal to both the [`Float`] zero and the\n    /// [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from(100).gt_abs(&Float::from(80)));\n    /// assert!(Rational::from(-100).gt_abs(&Float::from(-80)));\n    /// assert!(Rational::from(100).lt_abs(&Float::INFINITY));\n    /// assert!(Rational::from(-100).lt_abs(&Float::NEGATIVE_INFINITY));\n    /// assert!(Rational::from_unsigneds(1u8, 3).gt_abs(&Float::from(1.0f64 / 3.0)));\n    /// ```\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Float) -> Option<Ordering> {\n        other.partial_cmp_abs(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\n\nimpl PartialOrd<Integer> for Float {\n    /// Compares a [`Float`] to an [`Integer`].\n    ///\n    /// NaN is not comparable to any [`Integer`]. $\\infty$ is greater than any [`Integer`], and\n    /// $-\\infty$ is less. Both the [`Float`] zero and the [`Float`] negative zero are equal to the\n    /// [`Integer`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Float::from(80) < Integer::from(100));\n    /// assert!(Float::from(-80) > Integer::from(-100));\n    /// assert!(Float::INFINITY > Integer::from(100));\n    /// assert!(Float::NEGATIVE_INFINITY < Integer::from(-100));\n    /// ```\n    fn partial_cmp(&self, other: &Integer) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) => None,\n            (float_infinity!(), _) => Some(Greater),\n            (float_negative_infinity!(), _) => Some(Less),\n            (float_either_zero!(), y) => 0u32.partial_cmp(y),\n            (\n                Self(Finite {\n                    sign: s_x,\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                y,\n            ) => {\n                let s_y = *other > 0;\n                let s_cmp = s_x.cmp(&s_y);\n                if s_cmp != Equal {\n                    return Some(s_cmp);\n                }\n                let abs_cmp = if *other == 0u32 {\n                    Greater\n                } else if *e_x <= 0 {\n                    Less\n                } else {\n                    u64::from(e_x.unsigned_abs())\n                        .cmp(&other.significant_bits())\n                        .then_with(|| x.cmp_normalized(y.unsigned_abs_ref()))\n                };\n                Some(if s_y { abs_cmp } else { abs_cmp.reverse() })\n            }\n        }\n    }\n}\n\nimpl PartialOrd<Float> for Integer {\n    /// Compares an [`Integer`] to a [`Float`].\n    ///\n    /// No [`Integer`] is comparable to NaN. Every [`Integer`] is smaller than $\\infty$ and greater\n    /// than $-\\infty$. The [`Integer`] zero is equal to both the [`Float`] zero and the [`Float`]\n    /// negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::from(100) > Float::from(80));\n    /// assert!(Integer::from(-100) < Float::from(-80));\n    /// assert!(Integer::from(100) < Float::INFINITY);\n    /// assert!(Integer::from(-100) > Float::NEGATIVE_INFINITY);\n    /// ```\n    #[inline]\n    fn partial_cmp(&self, other: &Float) -> Option<Ordering> {\n        other.partial_cmp(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\nimpl PartialOrd<Natural> for Float {\n    /// Compares a [`Float`] to a [`Natural`].\n    ///\n    /// NaN is not comparable to any [`Natural`]. $\\infty$ is greater than any [`Natural`], and\n    /// $-\\infty$ is less. Both the [`Float`] zero and the [`Float`] negative zero are equal to the\n    /// [`Natural`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Float::from(80) < Natural::from(100u32));\n    /// assert!(Float::INFINITY > Natural::from(100u32));\n    /// assert!(Float::NEGATIVE_INFINITY < Natural::from(100u32));\n    /// ```\n    fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) => None,\n            (float_infinity!(), _) => Some(Greater),\n            (float_negative_infinity!(), _) => Some(Less),\n            (float_either_zero!(), _) => Some(if *other == 0u32 { Equal } else { Less }),\n            (\n                Self(Finite {\n                    sign: s_x,\n                    exponent: e_x,\n                    significand: x,\n                    ..\n                }),\n                y,\n            ) => Some(if !s_x {\n                Less\n            } else if *other == 0u32 {\n                Greater\n            } else if *e_x <= 0 {\n                Less\n            } else {\n                u64::from(e_x.unsigned_abs())\n                    .cmp(&other.significant_bits())\n                    .then_with(|| x.cmp_normalized(y))\n            }),\n        }\n    }\n}\n\nimpl PartialOrd<Float> for Natural {\n    /// Compares a [`Natural`] to a [`Float`].\n    ///\n    /// No [`Natural`] is comparable to NaN. Every [`Natural`] is smaller than $\\infty$ and greater\n    /// than $-\\infty$. The [`Natural`] zero is equal to both the [`Float`] zero and the [`Float`]\n    /// negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(100u32) > Float::from(80));\n    /// assert!(Natural::from(100u32) < Float::INFINITY);\n    /// assert!(Natural::from(100u32) > Float::NEGATIVE_INFINITY);\n    /// ```\n    #[inline]\n    fn partial_cmp(&self, other: &Float) -> Option<Ordering> {\n        other.partial_cmp(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_nz::natural::Natural;\n\nfn float_partial_cmp_primitive_float<T: PrimitiveFloat>(x: &Float, y: &T) -> Option<Ordering> {\n    match (x, y) {\n        (float_nan!(), _) => None,\n        (_, y) if y.is_nan() => None,\n        (float_infinity!(), y) if *y == T::INFINITY => Some(Equal),\n        (float_negative_infinity!(), y) if *y == T::NEGATIVE_INFINITY => Some(Equal),\n        (float_infinity!(), _) => Some(Greater),\n        (float_negative_infinity!(), _) => Some(Less),\n        (_, y) if *y == T::NEGATIVE_INFINITY => Some(Greater),\n        (_, y) if *y == T::INFINITY => Some(Less),\n        (float_either_zero!(), y) => Some(if *y == T::ZERO {\n            Equal\n        } else if y.is_sign_positive() {\n            Less\n        } else {\n            Greater\n        }),\n        (x, y) if *y == T::ZERO => Some(x.sign()),\n        (\n            Float(Finite {\n                sign: s_x,\n                exponent: e_x,\n                significand: m_x,\n                ..\n            }),\n            y,\n        ) => {\n            let s_y = y.is_sign_positive();\n            Some(s_x.cmp(&s_y).then_with(|| {\n                let abs_cmp = (i64::from(*e_x) - 1)\n                    .cmp(&y.sci_exponent())\n                    .then_with(|| m_x.cmp_normalized(&Natural::from(y.integer_mantissa())));\n                if *s_x { abs_cmp } else { abs_cmp.reverse() }\n            }))\n        }\n    }\n}\n\nmacro_rules! impl_partial_cmp_primitive_float {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Float {\n            /// Compares a [`Float`] to a primitive float.\n            ///\n            /// The [`Float`] NaN is not comparable to any primitive float, not even the primitive\n            /// float NaN. Every [`Float`] zero is equal to every primitive float zero, regardless\n            /// of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                float_partial_cmp_primitive_float(self, other)\n            }\n        }\n\n        impl PartialOrd<Float> for $t {\n            /// Compares a primitive float to a [`Float`].\n            ///\n            /// The primitive float NaN is not comparable to any primitive float, not even the\n            /// [`Float`] NaN. Every primitive float zero is equal to every [`Float`] zero,\n            /// regardless of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Float) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_partial_cmp_primitive_float);\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_nz::natural::Natural;\n\nfn float_partial_cmp_unsigned<T: PrimitiveUnsigned>(x: &Float, y: &T) -> Option<Ordering>\nwhere\n    Natural: From<T>,\n{\n    match (x, y) {\n        (float_nan!(), _) => None,\n        (float_infinity!(), _) => Some(Greater),\n        (float_negative_infinity!(), _) => Some(Less),\n        (float_either_zero!(), _) => Some(if *y == T::ZERO { Equal } else { Less }),\n        (\n            Float(Finite {\n                sign: s_x,\n                exponent: e_x,\n                significand: sig_x,\n                ..\n            }),\n            y,\n        ) => Some(if !s_x {\n            Less\n        } else if *y == T::ZERO {\n            Greater\n        } else if *e_x <= 0 {\n            Less\n        } else {\n            u64::from(e_x.unsigned_abs())\n                .cmp(&y.significant_bits())\n                .then_with(|| sig_x.cmp_normalized(&Natural::from(*y)))\n        }),\n    }\n}\n\nmacro_rules! impl_from_unsigned {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Float {\n            /// Compares a [`Float`] to an unsigned primitive integer.\n            ///\n            /// NaN is not comparable to any primitive integer. $\\infty$ is greater than any\n            /// primitive integer, and $-\\infty$ is less. Both the [`Float`] zero and the [`Float`]\n            /// negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                float_partial_cmp_unsigned(self, other)\n            }\n        }\n\n        impl PartialOrd<Float> for $t {\n            /// Compares an unsigned primitive integer to a [`Float`].\n            ///\n            /// No integer is comparable to NaN. Every integer is smaller than $\\infty$ and greater\n            /// than $-\\infty$. The integer zero is equal to both the [`Float`] zero and the\n            /// [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Float) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_from_unsigned);\n\nfn float_partial_cmp_signed<T: PrimitiveSigned>(x: &Float, y: &T) -> Option<Ordering>\nwhere\n    Natural: From<<T as UnsignedAbs>::Output>,\n{\n    match (x, y) {\n        (float_nan!(), _) => None,\n        (float_infinity!(), _) => Some(Greater),\n        (float_negative_infinity!(), _) => Some(Less),\n        (float_either_zero!(), _) => Some(T::ZERO.cmp(y)),\n        (\n            Float(Finite {\n                sign: s_x,\n                exponent: e_x,\n                significand: sig_x,\n                ..\n            }),\n            y,\n        ) => {\n            let s_y = *y > T::ZERO;\n            let s_cmp = s_x.cmp(&s_y);\n            if s_cmp != Equal {\n                return Some(s_cmp);\n            }\n            let abs_cmp = if *y == T::ZERO {\n                Greater\n            } else if *e_x <= 0 {\n                Less\n            } else {\n                u64::from(e_x.unsigned_abs())\n                    .cmp(&y.significant_bits())\n                    .then_with(|| sig_x.cmp_normalized(&Natural::from(y.unsigned_abs())))\n            };\n            Some(if s_y { abs_cmp } else { abs_cmp.reverse() })\n        }\n    }\n}\n\nmacro_rules! impl_from_signed {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Float {\n            /// Compares a [`Float`] to a signed primitive integer.\n            ///\n            /// NaN is not comparable to any primitive integer. $\\infty$ is greater than any\n            /// primitive integer, and $-\\infty$ is less. Both the [`Float`] zero and the [`Float`]\n            /// negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                float_partial_cmp_signed(self, other)\n            }\n        }\n\n        impl PartialOrd<Float> for $t {\n            /// Compares a signed primitive integer to a [`Float`].\n            ///\n            /// No integer is comparable to NaN. Every integer is smaller than $\\infty$ and greater\n            /// than $-\\infty$. The integer zero is equal to both the [`Float`] zero and the\n            /// [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Float) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_from_signed);\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_cmp_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_q::Rational;\n\nimpl PartialOrd<Rational> for Float {\n    /// Compares a [`Float`] to a [`Rational`].\n    ///\n    /// NaN is not comparable to any [`Rational`]. $\\infty$ is greater than any [`Rational`], and\n    /// $-\\infty$ is less. Both the [`Float`] zero and the [`Float`] negative zero are equal to the\n    /// [`Rational`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Float::from(80) < Rational::from(100));\n    /// assert!(Float::from(-80) > Rational::from(-100));\n    /// assert!(Float::INFINITY > Rational::from(100));\n    /// assert!(Float::NEGATIVE_INFINITY < Rational::from(-100));\n    /// assert!(Float::from(1.0f64 / 3.0) < Rational::from_unsigneds(1u8, 3));\n    /// ```\n    fn partial_cmp(&self, other: &Rational) -> Option<Ordering> {\n        match (self, other) {\n            (float_nan!(), _) => None,\n            (float_infinity!(), _) => Some(Greater),\n            (float_negative_infinity!(), _) => Some(Less),\n            (float_either_zero!(), y) => 0u32.partial_cmp(y),\n            (\n                Self(Finite {\n                    sign: s_x,\n                    exponent: e_x,\n                    significand: significand_x,\n                    ..\n                }),\n                y,\n            ) => Some(if *y == 0u32 {\n                if *s_x { Greater } else { Less }\n            } else {\n                let s_cmp = s_x.cmp(&(*y > 0));\n                if s_cmp != Equal {\n                    return Some(s_cmp);\n                }\n                let e_x = i64::from(*e_x);\n                let exp_cmp = (e_x - 1).cmp(&other.floor_log_base_2_abs());\n                if exp_cmp != Equal {\n                    return Some(if *s_x { exp_cmp } else { exp_cmp.reverse() });\n                }\n                let shift = e_x - i64::exact_from(significand_bits(significand_x));\n                let abs_shift = shift.unsigned_abs();\n                let prod_cmp = match shift.sign() {\n                    Equal => (significand_x * other.denominator_ref()).cmp(other.numerator_ref()),\n                    Greater => ((significand_x * other.denominator_ref()) << abs_shift)\n                        .cmp(other.numerator_ref()),\n                    Less => {\n                        let n_trailing_zeros = significand_x.trailing_zeros().unwrap();\n                        if abs_shift <= n_trailing_zeros {\n                            ((significand_x >> abs_shift) * other.denominator_ref())\n                                .cmp(other.numerator_ref())\n                        } else {\n                            ((significand_x >> n_trailing_zeros) * other.denominator_ref())\n                                .cmp(&(other.numerator_ref() << (abs_shift - n_trailing_zeros)))\n                        }\n                    }\n                };\n                if *s_x { prod_cmp } else { prod_cmp.reverse() }\n            }),\n        }\n    }\n}\n\nimpl PartialOrd<Float> for Rational {\n    /// Compares an [`Rational`] to a [`Float`].\n    ///\n    /// No [`Rational`] is comparable to NaN. Every [`Rational`] is smaller than $\\infty$ and\n    /// greater than $-\\infty$. The [`Rational`] zero is equal to both the [`Float`] zero and the\n    /// [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from(100) > Float::from(80));\n    /// assert!(Rational::from(-100) < Float::from(-80));\n    /// assert!(Rational::from(100) < Float::INFINITY);\n    /// assert!(Rational::from(-100) > Float::NEGATIVE_INFINITY);\n    /// assert!(Rational::from_unsigneds(1u8, 3) > Float::from(1.0f64 / 3.0));\n    /// ```\n    #[inline]\n    fn partial_cmp(&self, other: &Float) -> Option<Ordering> {\n        other.partial_cmp(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_eq_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\n\nimpl PartialEq<Integer> for Float {\n    /// Determines whether a [`Float`] is equal to an [`Integer`].\n    ///\n    /// $\\infty$, $-\\infty$, and NaN are not equal to any [`Integer`]. Both the [`Float`] zero and\n    /// the [`Float`] negative zero are equal to the [`Integer`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Float::from(123) == Integer::from(123));\n    /// assert!(Float::from(-123) == Integer::from(-123));\n    /// assert!(Float::ONE_HALF != Integer::ONE);\n    /// ```\n    fn eq(&self, other: &Integer) -> bool {\n        match self {\n            float_either_zero!() => *other == 0u32,\n            Self(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                *other != 0u32\n                    && *sign == (*other >= 0u32)\n                    && *exponent >= 0\n                    && other.significant_bits() == u64::from(exponent.unsigned_abs())\n                    && significand.cmp_normalized(other.unsigned_abs_ref()) == Equal\n            }\n            _ => false,\n        }\n    }\n}\n\nimpl PartialEq<Float> for Integer {\n    /// Determines whether an [`Integer`] is equal to a [`Float`].\n    ///\n    /// No [`Integer`] is equal to $\\infty$, $-\\infty$, or NaN. The [`Integer`] zero is equal to\n    /// both the [`Float`] zero and the [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::from(123) == Float::from(123));\n    /// assert!(Integer::from(-123) == Float::from(-123));\n    /// assert!(Integer::ONE != Float::ONE_HALF);\n    /// ```\n    #[inline]\n    fn eq(&self, other: &Float) -> bool {\n        other == self\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\nimpl PartialEq<Natural> for Float {\n    /// Determines whether a [`Float`] is equal to a [`Natural`].\n    ///\n    /// $\\infty$, $-\\infty$, and NaN are not equal to any [`Natural`]. Both the [`Float`] zero and\n    /// the [`Float`] negative zero are equal to the [`Natural`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Float::from(123) == Natural::from(123u32));\n    /// assert!(Float::ONE_HALF != Natural::ONE);\n    /// ```\n    fn eq(&self, other: &Natural) -> bool {\n        match self {\n            float_either_zero!() => *other == 0u32,\n            Self(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                *sign\n                    && *other != 0u32\n                    && *exponent >= 0\n                    && other.significant_bits() == u64::from(exponent.unsigned_abs())\n                    && significand.cmp_normalized(other) == Equal\n            }\n            _ => false,\n        }\n    }\n}\n\nimpl PartialEq<Float> for Natural {\n    /// Determines whether a [`Natural`] is equal to a [`Float`].\n    ///\n    /// No [`Natural`] is equal to $\\infty$, $-\\infty$, or NaN. The [`Natural`] zero is equal to\n    /// both the [`Float`] zero and the [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(123u32) == Float::from(123));\n    /// assert!(Natural::ONE != Float::ONE_HALF);\n    /// ```\n    #[inline]\n    fn eq(&self, other: &Float) -> bool {\n        other == self\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_nz::natural::Natural;\n\nfn float_partial_eq_primitive_float<T: PrimitiveFloat>(x: &Float, y: &T) -> bool {\n    match x {\n        float_nan!() => false,\n        float_infinity!() => *y == T::INFINITY,\n        float_negative_infinity!() => *y == T::NEGATIVE_INFINITY,\n        float_either_zero!() => *y == T::ZERO,\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            y.is_finite()\n                && *y != T::ZERO\n                && *sign == (*y > T::ZERO)\n                && i64::from(*exponent - 1) == y.sci_exponent()\n                && significand.cmp_normalized(&Natural::from(y.integer_mantissa())) == Equal\n        }\n    }\n}\n\nmacro_rules! impl_partial_eq_primitive_float {\n    ($t: ident) => {\n        impl PartialEq<$t> for Float {\n            /// Determines whether a [`Float`] is equal to a primitive float.\n            ///\n            /// The [`Float`] $\\infty$ is equal to the primitive float $\\infty$, and the [`Float`]\n            /// $-\\infty$ is equal to the primitive float $-\\infty$. The [`Float`] NaN is not equal\n            /// to anything, not even the primitive float NaN. Every [`Float`] zero is equal to\n            /// every primitive float zero, regardless of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            #[inline]\n            fn eq(&self, other: &$t) -> bool {\n                float_partial_eq_primitive_float(self, other)\n            }\n        }\n\n        impl PartialEq<Float> for $t {\n            /// Determines whether a primitive float is equal to a [`Float`].\n            ///\n            /// The primitive float $\\infty$ is equal to the [`Float`] $\\infty$, and the primitive\n            /// float $-\\infty$ is equal to the [`Float`] $-\\infty$. The primitive float NaN is not\n            /// equal to anything, not even the [`Float`] NaN. Every primitive float zero is equal\n            /// to every [`Float`] zero, regardless of sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Float) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_partial_eq_primitive_float);\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_nz::natural::Natural;\n\nfn float_partial_eq_unsigned<T: PrimitiveUnsigned>(x: &Float, y: &T) -> bool\nwhere\n    Natural: From<T>,\n{\n    match x {\n        float_either_zero!() => *y == T::ZERO,\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            *y != T::ZERO\n                && *sign\n                && *exponent >= 0\n                && y.significant_bits() == u64::from(exponent.unsigned_abs())\n                && significand.cmp_normalized(&Natural::from(*y)) == Equal\n        }\n        _ => false,\n    }\n}\n\nmacro_rules! impl_partial_eq_unsigned {\n    ($t: ident) => {\n        impl PartialEq<$t> for Float {\n            /// Determines whether a [`Float`] is equal to an unsigned primitive integer.\n            ///\n            /// $\\infty$, $-\\infty$, and NaN are not equal to any primitive integer. Both the\n            /// [`Float`] zero and the [`Float`] negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &$t) -> bool {\n                float_partial_eq_unsigned(self, other)\n            }\n        }\n\n        impl PartialEq<Float> for $t {\n            /// Determines whether an unsigned primitive integer is equal to a [`Float`].\n            ///\n            /// No primitive integer is equal to $\\infty$, $-\\infty$, or NaN. The integer zero is\n            /// equal to both the [`Float`] zero and the [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Float) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_partial_eq_unsigned);\n\nfn float_partial_eq_signed<T: PrimitiveSigned>(x: &Float, y: &T) -> bool\nwhere\n    Natural: From<<T as UnsignedAbs>::Output>,\n{\n    match x {\n        float_either_zero!() => *y == T::ZERO,\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            *y != T::ZERO\n                && *sign == (*y >= T::ZERO)\n                && *exponent >= 0\n                && y.significant_bits() == u64::from(exponent.unsigned_abs())\n                && significand.cmp_normalized(&Natural::from(y.unsigned_abs())) == Equal\n        }\n        _ => false,\n    }\n}\n\nmacro_rules! impl_partial_eq_signed {\n    ($t: ident) => {\n        impl PartialEq<$t> for Float {\n            /// Determines whether a [`Float`] is equal to a signed primitive integer.\n            ///\n            /// $\\infty$, $-\\infty$, and NaN are not equal to any primitive integer. Both the\n            /// [`Float`] zero and the [`Float`] negative zero are equal to the integer zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &$t) -> bool {\n                float_partial_eq_signed(self, other)\n            }\n        }\n\n        impl PartialEq<Float> for $t {\n            /// Determines whether a signed primitive integer is equal to a [`Float`].\n            ///\n            /// No primitive integer is equal to $\\infty$, $-\\infty$, or NaN. The integer zero is\n            /// equal to both the [`Float`] zero and the [`Float`] negative zero.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Float) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_signeds!(impl_partial_eq_signed);\n"
  },
  {
    "path": "malachite-float/src/comparison/partial_eq_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Zero};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::CheckedLogBase2;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_q::Rational;\n\nimpl PartialEq<Rational> for Float {\n    /// Determines whether a [`Float`] is equal to a [`Rational`].\n    ///\n    /// $\\infty$, $-\\infty$, and NaN are not equal to any [`Rational`]. Both the [`Float`] zero and\n    /// the [`Float`] negative zero are equal to the [`Rational`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Float::from(123) == Rational::from(123));\n    /// assert!(Float::from(-123) == Rational::from(-123));\n    /// assert!(Float::ONE_HALF == Rational::ONE_HALF);\n    /// assert!(Float::from(1.0f64 / 3.0) != Rational::from_unsigneds(1u8, 3));\n    /// ```\n    fn eq(&self, other: &Rational) -> bool {\n        match self {\n            float_either_zero!() => *other == 0u32,\n            Self(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                *other != 0\n                    && *sign == (*other > 0)\n                    && if let Some(log_d) = other.denominator_ref().checked_log_base_2() {\n                        let n = other.numerator_ref();\n                        i64::from(*exponent)\n                            == i64::exact_from(n.significant_bits()) - i64::exact_from(log_d)\n                            && significand.cmp_normalized(n) == Equal\n                    } else {\n                        false\n                    }\n            }\n            _ => false,\n        }\n    }\n}\n\nimpl PartialEq<Float> for Rational {\n    /// Determines whether a [`Rational`] is equal to a [`Float`].\n    ///\n    /// No [`Rational`] is equal to $\\infty$, $-\\infty$, or NaN. The [`Rational`] zero is equal to\n    /// both the [`Float`] zero and the [`Float`] negative zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from(123) == Float::from(123));\n    /// assert!(Rational::from(-123) == Float::from(-123));\n    /// assert!(Rational::ONE_HALF == Float::ONE_HALF);\n    /// assert!(Rational::from_unsigneds(1u8, 3) != Float::from(1.0f64 / 3.0));\n    /// ```\n    #[inline]\n    fn eq(&self, other: &Float) -> bool {\n        other == self\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/gauss_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of Gauss's constant, with the given precision and rounded using the\n    /// given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = G+\\varepsilon=1/\\mathrm{AGM}(1,\\sqrt{2})+\\varepsilon,\n    /// $$\n    /// where AGM is the arithmetic-geometric mean.\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (gauss_constant, o) = Float::gauss_constant_prec_round(100, Floor);\n    /// assert_eq!(\n    ///     gauss_constant.to_string(),\n    ///     \"0.834626841674073186281429732799\"\n    /// );\n    /// assert_eq!(o, Less);\n    ///\n    /// let (gauss_constant, o) = Float::gauss_constant_prec_round(100, Ceiling);\n    /// assert_eq!(gauss_constant.to_string(), \"0.8346268416740731862814297328\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn gauss_constant_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let sqrt_2_lo = Self::sqrt_2_prec_round(working_prec, Floor).0;\n            let mut sqrt_2_hi = sqrt_2_lo.clone();\n            sqrt_2_hi.increment();\n            let lo = Self::ONE\n                .agm_round(sqrt_2_hi, Ceiling)\n                .0\n                .reciprocal_round(Floor)\n                .0;\n            let hi = Self::ONE\n                .agm_round(sqrt_2_lo, Floor)\n                .0\n                .reciprocal_round(Ceiling)\n                .0;\n            let (gauss_constant_lo, mut o_lo) = Self::from_float_prec_round(lo, prec, rm);\n            let (gauss_constant_hi, mut o_hi) = Self::from_float_prec_round(hi, prec, rm);\n            if o_lo == Equal {\n                o_lo = o_hi;\n            }\n            if o_hi == Equal {\n                o_hi = o_lo;\n            }\n            if o_lo == o_hi && gauss_constant_lo == gauss_constant_hi {\n                return (gauss_constant_lo, o_lo);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of Gauss's constant, $G=1/\\mathrm{AGM}(1,\\sqrt{2})$, with the given\n    /// precision and rounded to the nearest [`Float`] of that precision. An [`Ordering`] is also\n    /// returned, indicating whether the rounded value is less than or greater than the exact value\n    /// of the constant. (Since the constant is irrational, the rounded value is never equal to the\n    /// exact value.)\n    ///\n    /// $$\n    /// x=G+\\varepsilon=1/\\mathrm{AGM}(1,\\sqrt{2})+\\varepsilon,\n    /// $$\n    /// where AGM is the arithmetic-geometric mean.\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (gauss_constant, o) = Float::gauss_constant_prec(1);\n    /// assert_eq!(gauss_constant.to_string(), \"1.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (gauss_constant, o) = Float::gauss_constant_prec(10);\n    /// assert_eq!(gauss_constant.to_string(), \"0.835\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (gauss_constant, o) = Float::gauss_constant_prec(100);\n    /// assert_eq!(\n    ///     gauss_constant.to_string(),\n    ///     \"0.834626841674073186281429732799\"\n    /// );\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn gauss_constant_prec(prec: u64) -> (Self, Ordering) {\n        Self::gauss_constant_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/lemniscate_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of the lemniscate constant $\\varpi$, with the given precision and\n    /// rounded using the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\varpi+\\varepsilon=\\pi G+\\varepsilon,\n    /// $$\n    /// where $G$ is Gauss's constant.\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+2}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (lemniscate_constant, o) = Float::lemniscate_constant_prec_round(100, Floor);\n    /// assert_eq!(\n    ///     lemniscate_constant.to_string(),\n    ///     \"2.62205755429211981046483958989\"\n    /// );\n    /// assert_eq!(o, Less);\n    ///\n    /// let (lemniscate_constant, o) = Float::lemniscate_constant_prec_round(100, Ceiling);\n    /// assert_eq!(\n    ///     lemniscate_constant.to_string(),\n    ///     \"2.622057554292119810464839589893\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn lemniscate_constant_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let lemniscate_constant =\n                Self::pi_prec(working_prec).0 * Self::gauss_constant_prec(working_prec).0;\n            if float_can_round(\n                lemniscate_constant.significand_ref().unwrap(),\n                working_prec - 2,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(lemniscate_constant, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of the lemniscate constant $\\varpi$, with the given precision and\n    /// rounded to the nearest [`Float`] of that precision. An [`Ordering`] is also returned,\n    /// indicating whether the rounded value is less than or greater than the exact value of the\n    /// constant. (Since the constant is irrational, the rounded value is never equal to the exact\n    /// value.)\n    ///\n    /// $$\n    /// x = \\varpi+\\varepsilon=\\pi G+\\varepsilon,\n    /// $$\n    /// where $G$ is Gauss's constant.\n    /// - $|\\varepsilon| < 2^{-p+1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (lemniscate_constant, o) = Float::lemniscate_constant_prec(1);\n    /// assert_eq!(lemniscate_constant.to_string(), \"2.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (lemniscate_constant, o) = Float::lemniscate_constant_prec(10);\n    /// assert_eq!(lemniscate_constant.to_string(), \"2.621\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (lemniscate_constant, o) = Float::lemniscate_constant_prec(100);\n    /// assert_eq!(\n    ///     lemniscate_constant.to_string(),\n    ///     \"2.62205755429211981046483958989\"\n    /// );\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn lemniscate_constant_prec(prec: u64) -> (Self, Ordering) {\n        Self::lemniscate_constant_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/ln_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse alloc::vec;\nuse core::cmp::Ordering;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::CeilingLogBase2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\n// Auxiliary function: Compute the terms from n1 to n2 (excluded) 3 / 4 * sum((-1) ^ n * n! ^ 2 / 2\n// ^ n / (2 * n + 1)!, n = n1...n2 - 1).s\n//\n// Numerator is T[0], denominator is Q[0], Compute P[0] only when need_P is non-zero.\n//\n// Need 1 + ceil(log(n2 - n1) / log(2)) cells in T[], P[], Q[].\n//\n// This is S from const_log2.c, MPFR 4.2.0.\nfn sum(t: &mut [Integer], p: &mut [Integer], q: &mut [Integer], n1: u64, n2: u64, need_p: bool) {\n    if n2 == n1 + 1 {\n        p[0] = if n1 == 0 {\n            const { Integer::const_from_unsigned(3) }\n        } else {\n            -Integer::from(n1)\n        };\n        q[0] = ((Integer::from(n1) << 1u32) + Integer::ONE) << 2u32;\n        t[0].clone_from(&p[0]);\n    } else {\n        let m = (n1 >> 1) + (n2 >> 1) + (n1 & 1 & n2);\n        sum(t, p, q, n1, m, true);\n        let (t_head, t_tail) = t.split_first_mut().unwrap();\n        let (p_head, p_tail) = p.split_first_mut().unwrap();\n        let (q_head, q_tail) = q.split_first_mut().unwrap();\n        sum(t_tail, p_tail, q_tail, m, n2, need_p);\n        *t_head *= &q_tail[0];\n        t_tail[0] *= &*p_head;\n        *t_head += &t_tail[0];\n        if need_p {\n            *p_head *= &p_tail[0];\n        }\n        *q_head *= &q_tail[0];\n        // remove common trailing zeros if any\n        let mut tz = t_head.trailing_zeros().unwrap();\n        if tz != 0 {\n            let mut qz = q_head.trailing_zeros().unwrap();\n            if qz < tz {\n                tz = qz;\n            }\n            if need_p {\n                qz = p_head.trailing_zeros().unwrap();\n                if qz < tz {\n                    tz = qz;\n                }\n            }\n            // now tz = min(val(T), val(Q), val(P))\n            if tz != 0 {\n                *t_head >>= tz;\n                *q_head >>= tz;\n                if need_p {\n                    *p_head >>= tz;\n                }\n            }\n        }\n    }\n}\n\nimpl Float {\n    /// Returns an approximation of the natural logarithm of 2, with the given precision and rounded\n    /// using the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\ln 2+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (l2, o) = Float::ln_2_prec_round(100, Floor);\n    /// assert_eq!(l2.to_string(), \"0.693147180559945309417232121458\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (l2, o) = Float::ln_2_prec_round(100, Ceiling);\n    /// assert_eq!(l2.to_string(), \"0.693147180559945309417232121459\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    ///\n    /// This is mpfr_const_log2_internal from const_log2.c, MPFR 4.2.0.\n    pub fn ln_2_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + prec.ceiling_log_base_2() + 3;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let big_n = working_prec / 3 + 1;\n            // the following are needed for error analysis (see algorithms.tex)\n            assert!(working_prec >= 3 && big_n >= 2);\n            let lg_big_n = usize::wrapping_from(big_n.ceiling_log_base_2()) + 1;\n            let mut scratch = vec![Integer::ZERO; 3 * lg_big_n];\n            split_into_chunks_mut!(scratch, lg_big_n, [t, p], q);\n            sum(t, p, q, 0, big_n, false);\n            let mut t0 = Integer::ZERO;\n            let mut q0 = Integer::ZERO;\n            swap(&mut t0, &mut t[0]);\n            swap(&mut q0, &mut q[0]);\n            let ln_2 = Self::from_integer_prec(t0, working_prec).0\n                / Self::from_integer_prec(q0, working_prec).0;\n            if float_can_round(ln_2.significand_ref().unwrap(), working_prec - 2, prec, rm) {\n                return Self::from_float_prec_round(ln_2, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of the natural logarithm of 2, with the given precision and rounded\n    /// to the nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\ln 2+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (l2, o) = Float::ln_2_prec(1);\n    /// assert_eq!(l2.to_string(), \"0.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (l2, o) = Float::ln_2_prec(10);\n    /// assert_eq!(l2.to_string(), \"0.693\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (l2, o) = Float::ln_2_prec(100);\n    /// assert_eq!(l2.to_string(), \"0.693147180559945309417232121458\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn ln_2_prec(prec: u64) -> (Self, Ordering) {\n        Self::ln_2_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/log_2_e.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::Reciprocal;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of the base-2 logarithm of $e$, with the given precision and\n    /// rounded using the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\log_2 e+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (log_2_e, o) = Float::log_2_e_prec_round(100, Floor);\n    /// assert_eq!(log_2_e.to_string(), \"1.442695040888963407359924681001\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (log_2_e, o) = Float::log_2_e_prec_round(100, Ceiling);\n    /// assert_eq!(log_2_e.to_string(), \"1.442695040888963407359924681003\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn log_2_e_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let log_2_e = Self::ln_2_prec_round(working_prec, Floor).0.reciprocal();\n            // See algorithms.tex. Since we rounded down when computing ln_2, the absolute error of\n            // the inverse is bounded by (c_w + 2c_uk_u)ulp(log_e(2)) <= 4ulp(log_e(2)).\n            if float_can_round(\n                log_2_e.significand_ref().unwrap(),\n                working_prec - 2,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(log_2_e, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of the base-2 logarithm of $e$, with the given precision and\n    /// rounded to the nearest [`Float`] of that precision. An [`Ordering`] is also returned,\n    /// indicating whether the rounded value is less than or greater than the exact value of the\n    /// constant. (Since the constant is irrational, the rounded value is never equal to the exact\n    /// value.)\n    ///\n    /// $$\n    /// x = \\log_2 e+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (log_2_e, o) = Float::log_2_e_prec(1);\n    /// assert_eq!(log_2_e.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (log_2_e, o) = Float::log_2_e_prec(10);\n    /// assert_eq!(log_2_e.to_string(), \"1.443\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (log_2_e, o) = Float::log_2_e_prec(100);\n    /// assert_eq!(log_2_e.to_string(), \"1.442695040888963407359924681003\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn log_2_e_prec(prec: u64) -> (Self, Ordering) {\n        Self::log_2_e_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Functions for approximating Gauss's constant, $G=1/\\mathrm{AGM}(1,\\sqrt{2})$.\npub mod gauss_constant;\n/// Functions for approximating the lemniscate constant $\\varpi=\\pi G$, where $G$ is Gauss's\n/// constant.\npub mod lemniscate_constant;\n/// Functions for approximating $\\ln 2$.\npub mod ln_2;\n/// Functions for approximating $\\log_2 e$.\npub mod log_2_e;\n/// Functions for approximating $1/\\pi$.\npub mod one_over_pi;\n/// Functions for approximating $1/\\sqrt{\\pi}$.\npub mod one_over_sqrt_pi;\n/// Functions for approximating $1/\\sqrt{\\tau}=1/\\sqrt{2\\pi}$.\npub mod one_over_sqrt_tau;\n/// Functions for approximating $\\varphi$, the golden ratio.\npub mod phi;\n/// Functions for approximating $\\pi$.\npub mod pi;\n/// Functions for approximating $\\pi/2$.\npub mod pi_over_2;\n/// Functions for approximating $\\pi/3$.\npub mod pi_over_3;\n/// Functions for approximating $\\pi/4$.\npub mod pi_over_4;\n/// Functions for approximating $\\pi/6$.\npub mod pi_over_6;\n/// Functions for approximating $\\pi/8$.\npub mod pi_over_8;\n/// Functions for approximating the prime constant (the constant whose $n$th bit is 1 if and only if\n/// $n$ is prime).\npub mod prime_constant;\n/// Functions for approximating the Prouhet-Thue-Morse constant (the constant whose bits are the\n/// Thue-Morse sequence).\npub mod prouhet_thue_morse_constant;\n/// Functions for approximating $\\sqrt{2}$.\npub mod sqrt_2;\n/// Functions for approximating $\\sqrt{2}/2=\\sqrt{1/2}=1/\\sqrt{2}$.\npub mod sqrt_2_over_2;\n/// Functions for approximating $\\sqrt{3}$.\npub mod sqrt_3;\n/// Functions for approximating $\\sqrt{3}/3=\\sqrt{1/3}=1/\\sqrt{3}$.\npub mod sqrt_3_over_3;\n/// Functions for approximating $\\sqrt{\\pi}$.\npub mod sqrt_pi;\n/// Functions for approximating $\\tau=2\\pi$.\npub mod tau;\n/// Functions for approximating $2/\\pi$.\npub mod two_over_pi;\n/// Functions for approximating $2/\\sqrt{\\pi}$.\npub mod two_over_sqrt_pi;\n"
  },
  {
    "path": "malachite-float/src/constants/one_over_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::Reciprocal;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of $1/\\pi$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 1/\\pi+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (one_over_pi, o) = Float::one_over_pi_prec_round(100, Floor);\n    /// assert_eq!(one_over_pi.to_string(), \"0.3183098861837906715377675267449\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (one_over_pi, o) = Float::one_over_pi_prec_round(100, Ceiling);\n    /// assert_eq!(one_over_pi.to_string(), \"0.3183098861837906715377675267453\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn one_over_pi_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let one_over_pi = Self::pi_prec_round(working_prec, Floor).0.reciprocal();\n            // See algorithms.tex. Since we rounded down when computing pi, the absolute error of\n            // the inverse is bounded by (c_w + 2c_uk_u)ulp(log_e(2)) <= 4ulp(pi).\n            if float_can_round(\n                one_over_pi.significand_ref().unwrap(),\n                working_prec - 2,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(one_over_pi, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of $1/\\pi$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 1/\\pi+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (one_over_pi, o) = Float::one_over_pi_prec(1);\n    /// assert_eq!(one_over_pi.to_string(), \"0.2\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (one_over_pi, o) = Float::one_over_pi_prec(10);\n    /// assert_eq!(one_over_pi.to_string(), \"0.3184\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (one_over_pi, o) = Float::one_over_pi_prec(100);\n    /// assert_eq!(one_over_pi.to_string(), \"0.3183098861837906715377675267449\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn one_over_pi_prec(prec: u64) -> (Self, Ordering) {\n        Self::one_over_pi_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/one_over_sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::ReciprocalSqrt;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of $1/\\sqrt{\\pi}$, with the given precision and rounded using the\n    /// given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 1/\\sqrt{\\pi}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (one_over_sqrt_pi, o) = Float::one_over_sqrt_pi_prec_round(100, Floor);\n    /// assert_eq!(\n    ///     one_over_sqrt_pi.to_string(),\n    ///     \"0.56418958354775628694807945156\"\n    /// );\n    /// assert_eq!(o, Less);\n    ///\n    /// let (one_over_sqrt_pi, o) = Float::one_over_sqrt_pi_prec_round(100, Ceiling);\n    /// assert_eq!(\n    ///     one_over_sqrt_pi.to_string(),\n    ///     \"0.564189583547756286948079451561\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn one_over_sqrt_pi_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let one_over_sqrt_pi = Self::pi_prec_round(working_prec, Floor).0.reciprocal_sqrt();\n            if float_can_round(\n                one_over_sqrt_pi.significand_ref().unwrap(),\n                working_prec - 2,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(one_over_sqrt_pi, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of $1/\\sqrt{\\pi}$, with the given precision and rounded to the\n    /// nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether\n    /// the rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 1/\\sqrt{\\pi}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (one_over_sqrt_pi, o) = Float::one_over_sqrt_pi_prec(1);\n    /// assert_eq!(one_over_sqrt_pi.to_string(), \"0.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (one_over_sqrt_pi, o) = Float::one_over_sqrt_pi_prec(10);\n    /// assert_eq!(one_over_sqrt_pi.to_string(), \"0.564\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (one_over_sqrt_pi, o) = Float::one_over_sqrt_pi_prec(100);\n    /// assert_eq!(\n    ///     one_over_sqrt_pi.to_string(),\n    ///     \"0.564189583547756286948079451561\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn one_over_sqrt_pi_prec(prec: u64) -> (Self, Ordering) {\n        Self::one_over_sqrt_pi_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/one_over_sqrt_tau.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::ReciprocalSqrt;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of $1/\\sqrt{\\tau}=1/\\sqrt{2\\pi}$, with the given precision and\n    /// rounded using the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 1/\\sqrt{\\tau}+\\varepsilon=1/\\sqrt{2\\pi}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (one_over_sqrt_tau, o) = Float::one_over_sqrt_tau_prec_round(100, Floor);\n    /// assert_eq!(\n    ///     one_over_sqrt_tau.to_string(),\n    ///     \"0.3989422804014326779399460599341\"\n    /// );\n    /// assert_eq!(o, Less);\n    ///\n    /// let (one_over_sqrt_tau, o) = Float::one_over_sqrt_tau_prec_round(100, Ceiling);\n    /// assert_eq!(\n    ///     one_over_sqrt_tau.to_string(),\n    ///     \"0.3989422804014326779399460599344\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn one_over_sqrt_tau_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let one_over_sqrt_tau = Self::tau_prec_round(working_prec, Floor)\n                .0\n                .reciprocal_sqrt();\n            if float_can_round(\n                one_over_sqrt_tau.significand_ref().unwrap(),\n                working_prec - 2,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(one_over_sqrt_tau, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of $1/\\sqrt{\\tau}=1/\\sqrt{2\\pi}$, with the given precision and\n    /// rounded to the nearest [`Float`] of that precision. An [`Ordering`] is also returned,\n    /// indicating whether the rounded value is less than or greater than the exact value of the\n    /// constant. (Since the constant is irrational, the rounded value is never equal to the exact\n    /// value.)\n    ///\n    /// $$\n    /// x = 1/\\sqrt{\\tau}+\\varepsilon=1/\\sqrt{2\\pi}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (one_over_sqrt_tau, o) = Float::one_over_sqrt_tau_prec(1);\n    /// assert_eq!(one_over_sqrt_tau.to_string(), \"0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (one_over_sqrt_tau, o) = Float::one_over_sqrt_tau_prec(10);\n    /// assert_eq!(one_over_sqrt_tau.to_string(), \"0.3989\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (one_over_sqrt_tau, o) = Float::one_over_sqrt_tau_prec(100);\n    /// assert_eq!(\n    ///     one_over_sqrt_tau.to_string(),\n    ///     \"0.3989422804014326779399460599344\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn one_over_sqrt_tau_prec(prec: u64) -> (Self, Ordering) {\n        Self::one_over_sqrt_tau_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/phi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of the golden ratio, with the given precision and rounded using the\n    /// given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// \\varphi = \\frac{1+\\sqrt{2}}{2}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (phi, o) = Float::phi_prec_round(100, Floor);\n    /// assert_eq!(phi.to_string(), \"1.618033988749894848204586834364\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (phi, o) = Float::phi_prec_round(100, Ceiling);\n    /// assert_eq!(phi.to_string(), \"1.618033988749894848204586834366\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn phi_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        if prec == 1 {\n            match rm {\n                Floor | Down => (Self::ONE, Less),\n                Ceiling | Up | Nearest => (Self::TWO, Greater),\n                Exact => panic!(\"Inexact float square root\"),\n            }\n        } else {\n            let (sqrt_5, o) =\n                Self::sqrt_prec_round(const { Self::const_from_unsigned(5) }, prec, rm);\n            ((sqrt_5 + Self::ONE) >> 1u32, o)\n        }\n    }\n\n    /// Returns an approximation of the golden ratio, with the given precision and rounded to the\n    /// nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether\n    /// the rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// \\varphi = \\frac{1+\\sqrt{2}}{2}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (phi, o) = Float::phi_prec(1);\n    /// assert_eq!(phi.to_string(), \"2.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (phi, o) = Float::phi_prec(10);\n    /// assert_eq!(phi.to_string(), \"1.617\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (phi, o) = Float::phi_prec(100);\n    /// assert_eq!(phi.to_string(), \"1.618033988749894848204586834366\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn phi_prec(prec: u64) -> (Self, Ordering) {\n        Self::phi_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::{Sqrt, Square};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of $\\pi$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+2}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi, o) = Float::pi_prec_round(100, Floor);\n    /// assert_eq!(pi.to_string(), \"3.141592653589793238462643383279\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi, o) = Float::pi_prec_round(100, Ceiling);\n    /// assert_eq!(pi.to_string(), \"3.141592653589793238462643383282\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    ///\n    // This is mpfr_const_pi_internal from const_pi.c, MPFR 4.2.0.\n    #[inline]\n    pub fn pi_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        // we need 9 * 2 ^ kmax - 4 >= px + 2 * kmax + 8\n        let mut kmax = 2;\n        while ((prec + 2 * kmax + 12) / 9) >> kmax != 0 {\n            kmax += 1;\n        }\n        // guarantees no recomputation for px <= 10000\n        let mut working_prec = prec + 3 * kmax + 14;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let mut a = Self::one_prec(working_prec);\n            let mut big_a = a.clone();\n            let mut big_b = Self::one_half_prec(working_prec);\n            let mut big_d = Self::one_prec(working_prec) >> 2;\n            let mut k = 0;\n            loop {\n                let s = (&big_a + &big_b) >> 2;\n                a = (a + big_b.sqrt()) >> 1;\n                big_a = (&a).square();\n                big_b = (&big_a - s) << 1;\n                let mut s = &big_a - &big_b;\n                assert!(s < 1u32);\n                let ip = i64::exact_from(working_prec);\n                let cancel = if s == 0 {\n                    ip\n                } else {\n                    i64::from(-s.get_exponent().unwrap())\n                };\n                s <<= k;\n                big_d -= s;\n                // stop when |A_k - B_k| <= 2 ^ (k - p) i.e. cancel >= p - k\n                if cancel >= ip - i64::exact_from(k) {\n                    break;\n                }\n                k += 1;\n            }\n            let pi: Self = big_b / big_d;\n            if float_can_round(\n                pi.significand_ref().unwrap(),\n                working_prec - (k << 1) - 8,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(pi, prec, rm);\n            }\n            working_prec += kmax + increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of $\\pi$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p+1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi, o) = Float::pi_prec(1);\n    /// assert_eq!(pi.to_string(), \"4.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (pi, o) = Float::pi_prec(10);\n    /// assert_eq!(pi.to_string(), \"3.141\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi, o) = Float::pi_prec(100);\n    /// assert_eq!(pi.to_string(), \"3.141592653589793238462643383279\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn pi_prec(prec: u64) -> (Self, Ordering) {\n        Self::pi_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/pi_over_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of $\\pi/2$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/2+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_2, o) = Float::pi_over_2_prec_round(100, Floor);\n    /// assert_eq!(pi_over_2.to_string(), \"1.57079632679489661923132169164\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_2, o) = Float::pi_over_2_prec_round(100, Ceiling);\n    /// assert_eq!(pi_over_2.to_string(), \"1.570796326794896619231321691641\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn pi_over_2_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (pi, o) = Self::pi_prec_round(prec, rm);\n        (pi >> 1u32, o)\n    }\n\n    /// Returns an approximation of $\\pi/2$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/2+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_2, o) = Float::pi_over_2_prec(1);\n    /// assert_eq!(pi_over_2.to_string(), \"2.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (pi_over_2, o) = Float::pi_over_2_prec(10);\n    /// assert_eq!(pi_over_2.to_string(), \"1.57\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_2, o) = Float::pi_over_2_prec(100);\n    /// assert_eq!(pi_over_2.to_string(), \"1.57079632679489661923132169164\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn pi_over_2_prec(prec: u64) -> (Self, Ordering) {\n        Self::pi_over_2_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/pi_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of $\\pi/3$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/3+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_3, o) = Float::pi_over_3_prec_round(100, Floor);\n    /// assert_eq!(pi_over_3.to_string(), \"1.047197551196597746154214461092\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_3, o) = Float::pi_over_3_prec_round(100, Ceiling);\n    /// assert_eq!(pi_over_3.to_string(), \"1.047197551196597746154214461094\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn pi_over_3_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        const THREE: Float = Float::const_from_unsigned(3);\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let pi_over_3 = Self::pi_prec(working_prec).0 / THREE;\n            if float_can_round(\n                pi_over_3.significand_ref().unwrap(),\n                working_prec - 1,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(pi_over_3, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of $\\pi/3$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/3+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_3, o) = Float::pi_over_3_prec(1);\n    /// assert_eq!(pi_over_3.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_3, o) = Float::pi_over_3_prec(10);\n    /// assert_eq!(pi_over_3.to_string(), \"1.047\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_3, o) = Float::pi_over_3_prec(100);\n    /// assert_eq!(pi_over_3.to_string(), \"1.047197551196597746154214461094\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn pi_over_3_prec(prec: u64) -> (Self, Ordering) {\n        Self::pi_over_3_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/pi_over_4.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of $\\pi/4$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/4+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_4, o) = Float::pi_over_4_prec_round(100, Floor);\n    /// assert_eq!(pi_over_4.to_string(), \"0.78539816339744830961566084582\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_4, o) = Float::pi_over_4_prec_round(100, Ceiling);\n    /// assert_eq!(pi_over_4.to_string(), \"0.7853981633974483096156608458206\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn pi_over_4_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (pi, o) = Self::pi_prec_round(prec, rm);\n        (pi >> 2u32, o)\n    }\n\n    /// Returns an approximation of $\\pi/4$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/4+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_4, o) = Float::pi_over_4_prec(1);\n    /// assert_eq!(pi_over_4.to_string(), \"1.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (pi_over_4, o) = Float::pi_over_4_prec(10);\n    /// assert_eq!(pi_over_4.to_string(), \"0.785\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_4, o) = Float::pi_over_4_prec(100);\n    /// assert_eq!(pi_over_4.to_string(), \"0.78539816339744830961566084582\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn pi_over_4_prec(prec: u64) -> (Self, Ordering) {\n        Self::pi_over_4_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/pi_over_6.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of $\\pi/6$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/6+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_6, o) = Float::pi_over_6_prec_round(100, Floor);\n    /// assert_eq!(pi_over_6.to_string(), \"0.523598775598298873077107230546\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_6, o) = Float::pi_over_6_prec_round(100, Ceiling);\n    /// assert_eq!(pi_over_6.to_string(), \"0.523598775598298873077107230547\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn pi_over_6_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (pi_over_3, o) = Self::pi_over_3_prec_round(prec, rm);\n        (pi_over_3 >> 1u32, o)\n    }\n\n    /// Returns an approximation of $\\pi/6$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/6+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_6, o) = Float::pi_over_6_prec(1);\n    /// assert_eq!(pi_over_6.to_string(), \"0.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_6, o) = Float::pi_over_6_prec(10);\n    /// assert_eq!(pi_over_6.to_string(), \"0.523\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_6, o) = Float::pi_over_6_prec(100);\n    /// assert_eq!(pi_over_6.to_string(), \"0.523598775598298873077107230547\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn pi_over_6_prec(prec: u64) -> (Self, Ordering) {\n        Self::pi_over_6_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/pi_over_8.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of $\\pi/8$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/8+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_8, o) = Float::pi_over_8_prec_round(100, Floor);\n    /// assert_eq!(pi_over_8.to_string(), \"0.3926990816987241548078304229099\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_8, o) = Float::pi_over_8_prec_round(100, Ceiling);\n    /// assert_eq!(pi_over_8.to_string(), \"0.3926990816987241548078304229103\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn pi_over_8_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (pi, o) = Self::pi_prec_round(prec, rm);\n        (pi >> 3u32, o)\n    }\n\n    /// Returns an approximation of $\\pi/8$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\pi/8+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pi_over_8, o) = Float::pi_over_8_prec(1);\n    /// assert_eq!(pi_over_8.to_string(), \"0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (pi_over_8, o) = Float::pi_over_8_prec(10);\n    /// assert_eq!(pi_over_8.to_string(), \"0.3926\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pi_over_8, o) = Float::pi_over_8_prec(100);\n    /// assert_eq!(pi_over_8.to_string(), \"0.3926990816987241548078304229099\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn pi_over_8_prec(prec: u64) -> (Self, Ordering) {\n        Self::pi_over_8_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/prime_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::factorization::primes::prime_indicator_sequence_less_than_or_equal_to;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of the prime constant, with the given precision and rounded using\n    /// the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// The prime constant is the real number whose $n$th bit is prime if and only if $n$ is prime.\n    /// That is,\n    /// $$\n    /// \\rho = \\sum_{p\\ \\text{prime}\\}2^{-p}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// The constant is irrational. It is unknown whether it is transcendental; see\n    /// <https://mathoverflow.net/questions/114905>.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pc, o) = Float::prime_constant_prec_round(100, Floor);\n    /// assert_eq!(pc.to_string(), \"0.4146825098511116602481096221542\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pc, o) = Float::prime_constant_prec_round(100, Ceiling);\n    /// assert_eq!(pc.to_string(), \"0.4146825098511116602481096221546\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn prime_constant_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        // Strictly speaking, this call violates the preconditions for\n        // `non_dyadic_from_bits_prec_round`, because the iterator passed in is finite. But since we\n        // know exactly how many bits `non_dyadic_from_bits_prec_round` will read, we can get away\n        // with this.\n        Self::non_dyadic_from_bits_prec_round(\n            prime_indicator_sequence_less_than_or_equal_to(if rm == Nearest {\n                prec + 2\n            } else {\n                prec + 1\n            }),\n            prec,\n            rm,\n        )\n    }\n\n    /// Returns an approximation of the prime constant, with the given precision and rounded to the\n    /// nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether\n    /// the rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// The prime constant is the real number whose $n$th bit is prime if and only if $n$ is prime.\n    /// That is,\n    /// $$\n    /// \\rho = \\sum_{p\\ \\text{prime}\\}2^{-p}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// The constant is irrational. It is unknown whether it is transcendental; see\n    /// <https://mathoverflow.net/questions/114905>.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (pc, o) = Float::prime_constant_prec(1);\n    /// assert_eq!(pc.to_string(), \"0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (pc, o) = Float::prime_constant_prec(10);\n    /// assert_eq!(pc.to_string(), \"0.4146\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (pc, o) = Float::prime_constant_prec(100);\n    /// assert_eq!(pc.to_string(), \"0.4146825098511116602481096221542\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn prime_constant_prec(prec: u64) -> (Self, Ordering) {\n        Self::prime_constant_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/prouhet_thue_morse_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse alloc::vec;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::iterators::thue_morse_sequence;\nuse malachite_base::num::arithmetic::traits::{NegModPowerOf2, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::OneHalf;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::{Natural, bit_to_limb_count_ceiling};\nuse malachite_nz::platform::Limb;\n\n#[cfg(feature = \"32_bit_limbs\")]\nconst LIMB_0: Limb = 0xd32d2cd2;\n#[cfg(feature = \"32_bit_limbs\")]\nconst LIMB_1: Limb = 0x2cd2d32c;\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst LIMB_0: Limb = 0xd32d2cd32cd2d32c;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst LIMB_1: Limb = 0x2cd2d32cd32d2cd2;\n\nimpl Float {\n    /// Returns an approximation of the Prouhet-Thue-Morse constant, with the given precision and\n    /// rounded using the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// The Prouhet-Thue-Morse constant is the real number whose bits are the Thue-Morse sequence.\n    /// That is,\n    /// $$\n    /// \\tau = \\sum_{k=0}^\\infty\\frac{t_n}{2^{n+1}}+\\varepsilon,\n    /// where $t_n$ is the Thue-Morse sequence.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// An alternative expression, from <https://mathworld.wolfram.com/Thue-MorseConstant.html>, is\n    /// $$\n    /// \\tau = \\frac{1}{4}\\left[2-\\prod_{k=0}^\\infty\\left(1-\\frac{1}{2^{2^k}}\\right)\\right].\n    /// $$\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (tmc, o) = Float::prouhet_thue_morse_constant_prec_round(100, Floor);\n    /// assert_eq!(tmc.to_string(), \"0.4124540336401075977833613682584\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (tmc, o) = Float::prouhet_thue_morse_constant_prec_round(100, Ceiling);\n    /// assert_eq!(tmc.to_string(), \"0.4124540336401075977833613682588\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn prouhet_thue_morse_constant_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        assert_ne!(rm, Exact);\n        // If the result is 1/2 then the exponent is 0 rather than -1, so we handle that case\n        // separately.\n        if prec == 1 && (rm == Nearest || rm == Ceiling || rm == Up) {\n            return (Self::ONE_HALF, Greater);\n        } else if prec == 2 && (rm == Ceiling || rm == Up) {\n            // TODO implement const_from_unsigned_prec_times_power_of_2\n            return (Self::one_half_prec(2), Greater);\n        }\n        let len = bit_to_limb_count_ceiling(prec);\n        let mut limbs = vec![0; len];\n        let mut tms = thue_morse_sequence();\n        for (i, b) in (0..len).rev().zip(&mut tms) {\n            limbs[i] = if b {\n                limbs[i + 1] |= 1;\n                LIMB_1\n            } else {\n                LIMB_0\n            };\n        }\n        let lsb = Limb::power_of_2(prec.neg_mod_power_of_2(Limb::LOG_WIDTH));\n        let mut next_tms = false;\n        if lsb == 1 {\n            next_tms = tms.next().unwrap();\n            if next_tms {\n                limbs[0] |= 1;\n            }\n        }\n        let increment = match rm {\n            Up | Ceiling => true,\n            Down | Floor => false,\n            Nearest => match lsb {\n                1 => !next_tms,\n                2 => tms.next().unwrap(),\n                _ => limbs[0] & (lsb >> 1) != 0,\n            },\n            Exact => unreachable!(),\n        };\n        limbs[0] &= !(lsb - 1);\n        let mut significand = Natural::from_owned_limbs_asc(limbs);\n        if increment {\n            significand += Natural::from(lsb);\n        }\n        (\n            Self(Finite {\n                sign: true,\n                exponent: -1,\n                precision: prec,\n                significand,\n            }),\n            if increment { Greater } else { Less },\n        )\n    }\n\n    /// Returns an approximation of the Prouhet-Thue-Morse constant, with the given precision and\n    /// rounded to the nearest [`Float`] of that precision. An [`Ordering`] is also returned,\n    /// indicating whether the rounded value is less than or greater than the exact value of the\n    /// constant. (Since the constant is irrational, the rounded value is never equal to the exact\n    /// value.)\n    ///\n    /// The Prouhet-Thue-Morse constant is the real number whose bits are the Thue-Morse sequence.\n    /// That is,\n    /// $$\n    /// \\tau = \\sum_{k=0}^\\infty\\frac{t_n}{2^{n+1}}+\\varepsilon,\n    /// $$\n    /// where $t_n$ is the Thue-Morse sequence.\n    /// - $|\\varepsilon| < 2^{-p-2}$.\n    ///\n    /// An alternative expression, from <https://mathworld.wolfram.com/Thue-MorseConstant.html>, is\n    /// $$\n    /// \\tau = \\frac{1}{4}\\left[2-\\prod_{k=0}^\\infty\\left(1-\\frac{1}{2^{2^k}}\\right)\\right].\n    /// $$\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (tmc, o) = Float::prouhet_thue_morse_constant_prec(1);\n    /// assert_eq!(tmc.to_string(), \"0.5\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (tmc, o) = Float::prouhet_thue_morse_constant_prec(10);\n    /// assert_eq!(tmc.to_string(), \"0.4126\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (tmc, o) = Float::prouhet_thue_morse_constant_prec(100);\n    /// assert_eq!(tmc.to_string(), \"0.4124540336401075977833613682584\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn prouhet_thue_morse_constant_prec(prec: u64) -> (Self, Ordering) {\n        Self::prouhet_thue_morse_constant_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/sqrt_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::basic::traits::Two;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of the square root of 2, with the given precision and rounded using\n    /// the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{2}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_2, o) = Float::sqrt_2_prec_round(100, Floor);\n    /// assert_eq!(sqrt_2.to_string(), \"1.414213562373095048801688724209\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_2, o) = Float::sqrt_2_prec_round(100, Ceiling);\n    /// assert_eq!(sqrt_2.to_string(), \"1.414213562373095048801688724211\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sqrt_2_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        Self::sqrt_prec_round(Self::TWO, prec, rm)\n    }\n\n    /// Returns an approximation of the square root of 2, with the given precision and rounded to\n    /// the nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{2}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_2, o) = Float::sqrt_2_prec(1);\n    /// assert_eq!(sqrt_2.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_2, o) = Float::sqrt_2_prec(10);\n    /// assert_eq!(sqrt_2.to_string(), \"1.414\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_2, o) = Float::sqrt_2_prec(100);\n    /// assert_eq!(sqrt_2.to_string(), \"1.414213562373095048801688724209\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_2_prec(prec: u64) -> (Self, Ordering) {\n        Self::sqrt_2_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/sqrt_2_over_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::basic::traits::Two;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of half of the square root of 2, with the given precision and\n    /// rounded using the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{2}/2+\\varepsilon=\\sqrt{1/2}+\\varepsilon=1/\\sqrt{2}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_2_over_2, o) = Float::sqrt_2_over_2_prec_round(100, Floor);\n    /// assert_eq!(\n    ///     sqrt_2_over_2.to_string(),\n    ///     \"0.7071067811865475244008443621046\"\n    /// );\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_2_over_2, o) = Float::sqrt_2_over_2_prec_round(100, Ceiling);\n    /// assert_eq!(\n    ///     sqrt_2_over_2.to_string(),\n    ///     \"0.7071067811865475244008443621054\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sqrt_2_over_2_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (sqrt_2, o) = Self::sqrt_prec_round(Self::TWO, prec, rm);\n        (sqrt_2 >> 1u32, o)\n    }\n\n    /// Returns an approximation of half of the square root of 2, with the given precision and\n    /// rounded to the nearest [`Float`] of that precision. An [`Ordering`] is also returned,\n    /// indicating whether the rounded value is less than or greater than the exact value of the\n    /// constant. (Since the constant is irrational, the rounded value is never equal to the exact\n    /// value.)\n    ///\n    /// $$\n    /// x = \\sqrt{2}/2+\\varepsilon=\\sqrt{1/2}+\\varepsilon=1/\\sqrt{2}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_2_over_2, o) = Float::sqrt_2_over_2_prec(1);\n    /// assert_eq!(sqrt_2_over_2.to_string(), \"0.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_2_over_2, o) = Float::sqrt_2_over_2_prec(10);\n    /// assert_eq!(sqrt_2_over_2.to_string(), \"0.707\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_2_over_2, o) = Float::sqrt_2_over_2_prec(100);\n    /// assert_eq!(\n    ///     sqrt_2_over_2.to_string(),\n    ///     \"0.7071067811865475244008443621046\"\n    /// );\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn sqrt_2_over_2_prec(prec: u64) -> (Self, Ordering) {\n        Self::sqrt_2_over_2_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/sqrt_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of the square root of 3, with the given precision and rounded using\n    /// the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{3}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_3, o) = Float::sqrt_3_prec_round(100, Floor);\n    /// assert_eq!(sqrt_3.to_string(), \"1.732050807568877293527446341505\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_3, o) = Float::sqrt_3_prec_round(100, Ceiling);\n    /// assert_eq!(sqrt_3.to_string(), \"1.732050807568877293527446341506\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sqrt_3_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        Self::sqrt_prec_round(const { Self::const_from_unsigned(3) }, prec, rm)\n    }\n\n    /// Returns an approximation of the square root of 3, with the given precision and rounded to\n    /// the nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{3}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_3, o) = Float::sqrt_3_prec(1);\n    /// assert_eq!(sqrt_3.to_string(), \"2.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt_3, o) = Float::sqrt_3_prec(10);\n    /// assert_eq!(sqrt_3.to_string(), \"1.732\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt_3, o) = Float::sqrt_3_prec(100);\n    /// assert_eq!(sqrt_3.to_string(), \"1.732050807568877293527446341506\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sqrt_3_prec(prec: u64) -> (Self, Ordering) {\n        Self::sqrt_3_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/sqrt_3_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of one third of the square root of 3, with the given precision and\n    /// rounded using the given [`RoundingMode`]. An [`Ordering`] is also returned, indicating\n    /// whether the rounded value is less than or greater than the exact value of the constant.\n    /// (Since the constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{3}/3+\\varepsilon=\\sqrt{1/3}+\\varepsilon=1/\\sqrt{3}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_3_over_3, o) = Float::sqrt_3_over_3_prec_round(100, Floor);\n    /// assert_eq!(\n    ///     sqrt_3_over_3.to_string(),\n    ///     \"0.577350269189625764509148780501\"\n    /// );\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_3_over_3, o) = Float::sqrt_3_over_3_prec_round(100, Ceiling);\n    /// assert_eq!(\n    ///     sqrt_3_over_3.to_string(),\n    ///     \"0.577350269189625764509148780502\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sqrt_3_over_3_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        Self::reciprocal_sqrt_prec_round(const { Self::const_from_unsigned(3) }, prec, rm)\n    }\n\n    /// Returns an approximation of one third of the square root of 3, with the given precision and\n    /// rounded to the nearest [`Float`] of that precision. An [`Ordering`] is also returned,\n    /// indicating whether the rounded value is less than or greater than the exact value of the\n    /// constant. (Since the constant is irrational, the rounded value is never equal to the exact\n    /// value.)\n    ///\n    /// $$\n    /// x = \\sqrt{3}/3+\\varepsilon=\\sqrt{1/3}+\\varepsilon=1/\\sqrt{3}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and algebraic.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_3_over_3, o) = Float::sqrt_3_over_3_prec(1);\n    /// assert_eq!(sqrt_3_over_3.to_string(), \"0.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_3_over_3, o) = Float::sqrt_3_over_3_prec(10);\n    /// assert_eq!(sqrt_3_over_3.to_string(), \"0.577\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_3_over_3, o) = Float::sqrt_3_over_3_prec(100);\n    /// assert_eq!(\n    ///     sqrt_3_over_3.to_string(),\n    ///     \"0.577350269189625764509148780502\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sqrt_3_over_3_prec(prec: u64) -> (Self, Ordering) {\n        Self::sqrt_3_over_3_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::Sqrt;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::arithmetic::float_extras::float_can_round;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of $\\sqrt{\\pi}$, with the given precision and rounded using the\n    /// given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{\\pi}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_pi, o) = Float::sqrt_pi_prec_round(100, Floor);\n    /// assert_eq!(sqrt_pi.to_string(), \"1.77245385090551602729816748334\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_pi, o) = Float::sqrt_pi_prec_round(100, Ceiling);\n    /// assert_eq!(sqrt_pi.to_string(), \"1.772453850905516027298167483341\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn sqrt_pi_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let mut working_prec = prec + 10;\n        let mut increment = Limb::WIDTH;\n        loop {\n            let sqrt_pi = Self::pi_prec_round(working_prec, Floor).0.sqrt();\n            // See algorithms.tex. Since we rounded down when computing pi, the absolute error of\n            // the square root is bounded by (c_sqrt + k_fx)ulp(sqrt) <= 2ulp(sqrt).\n            if float_can_round(\n                sqrt_pi.significand_ref().unwrap(),\n                working_prec - 1,\n                prec,\n                rm,\n            ) {\n                return Self::from_float_prec_round(sqrt_pi, prec, rm);\n            }\n            working_prec += increment;\n            increment = working_prec >> 1;\n        }\n    }\n\n    /// Returns an approximation of $\\sqrt{\\pi}$, with the given precision and rounded to the\n    /// nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether\n    /// the rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\sqrt{\\pi}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (sqrt_pi, o) = Float::sqrt_pi_prec(1);\n    /// assert_eq!(sqrt_pi.to_string(), \"2.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (sqrt_pi, o) = Float::sqrt_pi_prec(10);\n    /// assert_eq!(sqrt_pi.to_string(), \"1.771\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (sqrt_pi, o) = Float::sqrt_pi_prec(100);\n    /// assert_eq!(sqrt_pi.to_string(), \"1.772453850905516027298167483341\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn sqrt_pi_prec(prec: u64) -> (Self, Ordering) {\n        Self::sqrt_pi_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/tau.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of $\\tau=2\\pi$, with the given precision and rounded using the\n    /// given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\tau=2\\pi+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+3}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p+2}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (tau, o) = Float::tau_prec_round(100, Floor);\n    /// assert_eq!(tau.to_string(), \"6.283185307179586476925286766559\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (tau, o) = Float::tau_prec_round(100, Ceiling);\n    /// assert_eq!(tau.to_string(), \"6.283185307179586476925286766565\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn tau_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (pi, o) = Self::pi_prec_round(prec, rm);\n        (pi << 1u32, o)\n    }\n\n    /// Returns an approximation of $\\tau=2\\pi$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = \\tau=2\\pi+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p+2}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (tau, o) = Float::tau_prec(1);\n    /// assert_eq!(tau.to_string(), \"8.0\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (tau, o) = Float::tau_prec(10);\n    /// assert_eq!(tau.to_string(), \"6.28\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (tau, o) = Float::tau_prec(100);\n    /// assert_eq!(tau.to_string(), \"6.283185307179586476925286766559\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn tau_prec(prec: u64) -> (Self, Ordering) {\n        Self::tau_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/two_over_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of $2/\\pi$, with the given precision and rounded using the given\n    /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded value is\n    /// less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 2/\\pi+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (two_over_pi, o) = Float::two_over_pi_prec_round(100, Floor);\n    /// assert_eq!(two_over_pi.to_string(), \"0.63661977236758134307553505349\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (two_over_pi, o) = Float::two_over_pi_prec_round(100, Ceiling);\n    /// assert_eq!(two_over_pi.to_string(), \"0.6366197723675813430755350534906\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn two_over_pi_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (pi, o) = Self::one_over_pi_prec_round(prec, rm);\n        (pi << 1u32, o)\n    }\n\n    /// Returns an approximation of $2/\\pi$, with the given precision and rounded to the nearest\n    /// [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether the\n    /// rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 2/\\pi+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p-1}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (two_over_pi, o) = Float::two_over_pi_prec(1);\n    /// assert_eq!(two_over_pi.to_string(), \"0.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (two_over_pi, o) = Float::two_over_pi_prec(10);\n    /// assert_eq!(two_over_pi.to_string(), \"0.637\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (two_over_pi, o) = Float::two_over_pi_prec(100);\n    /// assert_eq!(two_over_pi.to_string(), \"0.63661977236758134307553505349\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn two_over_pi_prec(prec: u64) -> (Self, Ordering) {\n        Self::two_over_pi_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/constants/two_over_sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 1999, 2001-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Float {\n    /// Returns an approximation of $2/\\sqrt{pi}$, with the given precision and rounded using the\n    /// given [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the rounded\n    /// value is less than or greater than the exact value of the constant. (Since the constant is\n    /// irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 2/\\sqrt{pi}+\\varepsilon.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or if `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (two_over_sqrt_pi, o) = Float::two_over_sqrt_pi_prec_round(100, Floor);\n    /// assert_eq!(\n    ///     two_over_sqrt_pi.to_string(),\n    ///     \"1.12837916709551257389615890312\"\n    /// );\n    /// assert_eq!(o, Less);\n    ///\n    /// let (two_over_sqrt_pi, o) = Float::two_over_sqrt_pi_prec_round(100, Ceiling);\n    /// assert_eq!(\n    ///     two_over_sqrt_pi.to_string(),\n    ///     \"1.128379167095512573896158903122\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn two_over_sqrt_pi_prec_round(prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let (pi, o) = Self::one_over_sqrt_pi_prec_round(prec, rm);\n        (pi << 1u32, o)\n    }\n\n    /// Returns an approximation of $2/\\sqrt{pi}$, with the given precision and rounded to the\n    /// nearest [`Float`] of that precision. An [`Ordering`] is also returned, indicating whether\n    /// the rounded value is less than or greater than the exact value of the constant. (Since the\n    /// constant is irrational, the rounded value is never equal to the exact value.)\n    ///\n    /// $$\n    /// x = 2/\\sqrt{pi}+\\varepsilon.\n    /// $$\n    /// - $|\\varepsilon| < 2^{-p}$.\n    ///\n    /// The constant is irrational and transcendental.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n (\\log n)^2)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (two_over_sqrt_pi, o) = Float::two_over_sqrt_pi_prec(1);\n    /// assert_eq!(two_over_sqrt_pi.to_string(), \"1.0\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (two_over_sqrt_pi, o) = Float::two_over_sqrt_pi_prec(10);\n    /// assert_eq!(two_over_sqrt_pi.to_string(), \"1.129\");\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (two_over_sqrt_pi, o) = Float::two_over_sqrt_pi_prec(100);\n    /// assert_eq!(\n    ///     two_over_sqrt_pi.to_string(),\n    ///     \"1.128379167095512573896158903122\"\n    /// );\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn two_over_sqrt_pi_prec(prec: u64) -> (Self, Ordering) {\n        Self::two_over_sqrt_pi_prec_round(prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse alloc::vec;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, NegModPowerOf2, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::LIMB_HIGH_BIT;\nuse malachite_nz::natural::{Natural, bit_to_limb_count_ceiling};\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns an approximation of a real number, given the number's bits. To avoid troublesome\n    /// edge cases, the number should not be a dyadic rational (and the iterator of bits should\n    /// therefore be infinite, and not eventually 0 or 1). Given this assumption, the rounding mode\n    /// `Exact` should never be passed.\n    ///\n    /// The approximation has precision `prec` and is rounded according to the provided rounding\n    /// mode.\n    ///\n    /// This function reads `prec + z` bits, or `prec + z + 1` bits if `rm` is `Nearest`, where `z`\n    /// is the number of leading false bits in `bits`.\n    ///\n    /// This function always produces a value in the interval $[1/2,1]$. In particular, it never\n    /// overflows or underflows.\n    ///\n    /// $$\n    /// f((x_k),p,m) = C+\\varepsilon,\n    /// $$\n    /// where\n    /// $$\n    /// C=\\sum_{k=0}^\\infty x_k 2^{-(k+1)}.\n    /// $$\n    /// - If $m$ is not `Nearest`, then $|\\varepsilon| < 2^{\\lfloor\\log_2 C\\rfloor-p+1}$.\n    /// - If $m$ is `Nearest`, then $|\\varepsilon| < 2^{\\lfloor\\log_2 C\\rfloor-p}$.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero or `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// // Produces 10100100010000100000...\n    /// struct Bits {\n    ///     b: bool,\n    ///     k: usize,\n    ///     j: usize,\n    /// }\n    ///\n    /// impl Iterator for Bits {\n    ///     type Item = bool;\n    ///\n    ///     fn next(&mut self) -> Option<bool> {\n    ///         Some(if self.b {\n    ///             self.b = false;\n    ///             self.j = self.k;\n    ///             true\n    ///         } else {\n    ///             self.j -= 1;\n    ///             if self.j == 0 {\n    ///                 self.k += 1;\n    ///                 self.b = true;\n    ///             }\n    ///             false\n    ///         })\n    ///     }\n    /// }\n    ///\n    /// impl Bits {\n    ///     fn new() -> Bits {\n    ///         Bits {\n    ///             b: true,\n    ///             k: 1,\n    ///             j: 1,\n    ///         }\n    ///     }\n    /// }\n    ///\n    /// let (c, o) = Float::non_dyadic_from_bits_prec_round(Bits::new(), 100, Floor);\n    /// assert_eq!(c.to_string(), \"0.6416325606551538662938427702254\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (c, o) = Float::non_dyadic_from_bits_prec_round(Bits::new(), 100, Ceiling);\n    /// assert_eq!(c.to_string(), \"0.641632560655153866293842770226\");\n    /// assert_eq!(o, Greater);\n    /// ```\n    pub fn non_dyadic_from_bits_prec_round<I: Iterator<Item = bool>>(\n        mut bits: I,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        assert_ne!(rm, Exact);\n        let len = bit_to_limb_count_ceiling(prec);\n        let mut limbs = vec![0; len];\n        let mut limbs_it = limbs.iter_mut().rev();\n        let mut x = limbs_it.next().unwrap();\n        let mut mask = LIMB_HIGH_BIT;\n        let mut seen_one = false;\n        let mut exponent: i32 = 0;\n        let mut remaining = prec;\n        for b in &mut bits {\n            if !seen_one {\n                if b {\n                    seen_one = true;\n                } else {\n                    exponent = exponent.checked_sub(1).unwrap();\n                    continue;\n                }\n            }\n            if b {\n                *x |= mask;\n            }\n            remaining -= 1;\n            if remaining == 0 {\n                break;\n            }\n            if mask == 1 {\n                x = limbs_it.next().unwrap();\n                mask = LIMB_HIGH_BIT;\n            } else {\n                mask >>= 1;\n            }\n        }\n        let mut significand = Natural::from_owned_limbs_asc(limbs);\n        let increment = rm == Up || rm == Ceiling || (rm == Nearest && bits.next() == Some(true));\n        if increment {\n            significand +=\n                Natural::from(Limb::power_of_2(prec.neg_mod_power_of_2(Limb::LOG_WIDTH)));\n            if !significand\n                .significant_bits()\n                .divisible_by_power_of_2(Limb::LOG_WIDTH)\n            {\n                significand >>= 1;\n                exponent += 1;\n            }\n        }\n        (\n            Self(Finite {\n                sign: true,\n                exponent,\n                precision: prec,\n                significand,\n            }),\n            if increment { Greater } else { Less },\n        )\n    }\n\n    /// Returns an approximation of a real number, given the number's bits. To avoid troublesome\n    /// edge cases, the number should not be a dyadic rational (and the iterator of bits should\n    /// therefore be infinite, and not eventually 0 or 1).\n    ///\n    /// The approximation has precision `prec` and is rounded according to the `Nearest` rounding\n    /// mode.\n    ///\n    /// This function reads `prec + z + 1` bits, where `z` is the number of leading false bits in\n    /// `bits`.\n    ///\n    /// This function always produces a value in the interval $[1/2,1]$. In particular, it never\n    /// overflows or underflows.\n    ///\n    /// $$\n    /// f((x_k),p,m) = C+\\varepsilon,\n    /// $$\n    /// where\n    /// $$\n    /// C=\\sum_{k=0}^\\infty x_k 2^{-(k+1)}\n    /// $$\n    /// and $|\\varepsilon| < 2^{\\lfloor\\log_2 C\\rfloor-p}$.\n    ///\n    /// The output has precision `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// // Produces 10100100010000100000...\n    /// struct Bits {\n    ///     b: bool,\n    ///     k: usize,\n    ///     j: usize,\n    /// }\n    ///\n    /// impl Iterator for Bits {\n    ///     type Item = bool;\n    ///\n    ///     fn next(&mut self) -> Option<bool> {\n    ///         Some(if self.b {\n    ///             self.b = false;\n    ///             self.j = self.k;\n    ///             true\n    ///         } else {\n    ///             self.j -= 1;\n    ///             if self.j == 0 {\n    ///                 self.k += 1;\n    ///                 self.b = true;\n    ///             }\n    ///             false\n    ///         })\n    ///     }\n    /// }\n    ///\n    /// impl Bits {\n    ///     fn new() -> Bits {\n    ///         Bits {\n    ///             b: true,\n    ///             k: 1,\n    ///             j: 1,\n    ///         }\n    ///     }\n    /// }\n    ///\n    /// let (c, o) = Float::non_dyadic_from_bits_prec(Bits::new(), 1);\n    /// assert_eq!(c.to_string(), \"0.5\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (c, o) = Float::non_dyadic_from_bits_prec(Bits::new(), 10);\n    /// assert_eq!(c.to_string(), \"0.642\");\n    /// assert_eq!(o, Less);\n    ///\n    /// let (c, o) = Float::non_dyadic_from_bits_prec(Bits::new(), 100);\n    /// assert_eq!(c.to_string(), \"0.6416325606551538662938427702254\");\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn non_dyadic_from_bits_prec<I: Iterator<Item = bool>>(\n        bits: I,\n        prec: u64,\n    ) -> (Self, Ordering) {\n        Self::non_dyadic_from_bits_prec_round(bits, prec, Nearest)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::conversion::from_natural::{\n    from_natural_prec_round_zero_exponent, from_natural_zero_exponent,\n};\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::{FloorLogBase2, UnsignedAbs};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, SaturatingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\n\npub(crate) fn from_integer_zero_exponent(n: Integer) -> Float {\n    let sign = n >= 0;\n    let f = from_natural_zero_exponent(n.unsigned_abs());\n    if sign { f } else { -f }\n}\n\npub(crate) fn from_integer_prec_round_zero_exponent(\n    x: Integer,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    let sign = x >= 0;\n    let (f, o) =\n        from_natural_prec_round_zero_exponent(x.unsigned_abs(), prec, if sign { rm } else { -rm });\n    if sign { (f, o) } else { (-f, o.reverse()) }\n}\n\nimpl Float {\n    /// Converts an [`Integer`] to a [`Float`], taking the [`Integer`] by value. If the [`Float`] is\n    /// nonzero, it has the specified precision. If rounding is needed, the specified rounding mode\n    /// is used. An [`Ordering`] is also returned, indicating whether the returned value is less\n    /// than, equal to, or greater than the original value.\n    ///\n    /// If you're only using [`Nearest`], try using [`Float::from_integer_prec`] instead.\n    ///\n    /// - If the [`Integer`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds down\n    ///   to $(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    /// - If the [`Integer`] rounds to a value less than or equal to $-2^{2^{30}-1}$), this function\n    ///   overflows to $-\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds up to\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the `Integer` cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_integer_prec_round(Integer::ZERO, 10, Exact);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round(Integer::from(123), 20, Exact);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round(Integer::from(123), 4, Floor);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round(Integer::from(123), 4, Ceiling);\n    /// assert_eq!(x.to_string(), \"1.3e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round(Integer::from(-123), 20, Exact);\n    /// assert_eq!(x.to_string(), \"-123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round(Integer::from(-123), 4, Floor);\n    /// assert_eq!(x.to_string(), \"-1.3e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round(Integer::from(-123), 4, Ceiling);\n    /// assert_eq!(x.to_string(), \"-1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_integer_prec_round(x: Integer, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let sign = x >= 0;\n        let (f, o) =\n            Self::from_natural_prec_round(x.unsigned_abs(), prec, if sign { rm } else { -rm });\n        if sign { (f, o) } else { (-f, o.reverse()) }\n    }\n\n    /// Converts an [`Integer`] to a [`Float`], taking the [`Integer`] by reference. If the\n    /// [`Float`] is nonzero, it has the specified precision. If rounding is needed, the specified\n    /// rounding mode is used. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// If you're only using [`Nearest`], try using [`Float::from_integer_prec_ref`] instead.\n    ///\n    /// - If the [`Integer`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds down\n    ///   to $(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    /// - If the [`Integer`] rounds to a value less than or equal to $-2^{2^{30}-1}$), this function\n    ///   overflows to $-\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds up to\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the `Integer` cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_integer_prec_round_ref(&Integer::ZERO, 10, Exact);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round_ref(&Integer::from(123), 20, Exact);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round_ref(&Integer::from(123), 4, Floor);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round_ref(&Integer::from(123), 4, Ceiling);\n    /// assert_eq!(x.to_string(), \"1.3e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round_ref(&Integer::from(-123), 20, Exact);\n    /// assert_eq!(x.to_string(), \"-123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round_ref(&Integer::from(-123), 4, Floor);\n    /// assert_eq!(x.to_string(), \"-1.3e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_integer_prec_round_ref(&Integer::from(-123), 4, Ceiling);\n    /// assert_eq!(x.to_string(), \"-1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_integer_prec_round_ref(\n        x: &Integer,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        let sign = *x >= 0;\n        let (f, o) = Self::from_natural_prec_round_ref(\n            x.unsigned_abs_ref(),\n            prec,\n            if sign { rm } else { -rm },\n        );\n        if sign { (f, o) } else { (-f, o.reverse()) }\n    }\n\n    /// Converts an [`Integer`] to a [`Float`], taking the [`Integer`] by value. If the [`Float`] is\n    /// nonzero, it has the specified precision. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// If you want the [`Float`]'s precision to be equal to the [`Integer`]'s number of significant\n    /// bits, try just using `Float::try_from` instead.\n    ///\n    /// Rounding may occur, in which case [`Nearest`] is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_integer_prec_round`].\n    ///\n    /// - If the [`Integer`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$.\n    /// - If the [`Integer`] rounds to a value less than or equal to -$2^{2^{30}-1}$), this function\n    ///   overflows to $\\infty$.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_integer_prec(Integer::ZERO, 10);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec(Integer::from(123), 20);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec(Integer::from(123), 4);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_integer_prec(Integer::from(-123), 20);\n    /// assert_eq!(x.to_string(), \"-123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec(Integer::from(-123), 4);\n    /// assert_eq!(x.to_string(), \"-1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_integer_prec(x: Integer, prec: u64) -> (Self, Ordering) {\n        Self::from_integer_prec_round(x, prec, Nearest)\n    }\n\n    /// Converts an [`Integer`] to a [`Float`], taking the [`Integer`] by reference. If the\n    /// [`Float`] is nonzero, it has the specified precision. An [`Ordering`] is also returned,\n    /// indicating whether the returned value is less than, equal to, or greater than the original\n    /// value.\n    ///\n    /// If you want the [`Float`]'s precision to be equal to the [`Integer`]'s number of significant\n    /// bits, try just using `Float::try_from` instead.\n    ///\n    /// Rounding may occur, in which case [`Nearest`] is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_integer_prec_round_ref`].\n    ///\n    /// - If the [`Integer`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$.\n    /// - If the [`Integer`] rounds to a value less than or equal to -$2^{2^{30}-1}$), this function\n    ///   overflows to $\\infty$.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_integer_prec_ref(&Integer::ZERO, 10);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_ref(&Integer::from(123), 20);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_ref(&Integer::from(123), 4);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_integer_prec_ref(&Integer::from(-123), 20);\n    /// assert_eq!(x.to_string(), \"-123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_integer_prec_ref(&Integer::from(-123), 4);\n    /// assert_eq!(x.to_string(), \"-1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_integer_prec_ref(x: &Integer, prec: u64) -> (Self, Ordering) {\n        let sign = *x >= 0;\n        let (f, o) = Self::from_natural_prec_ref(x.unsigned_abs_ref(), prec);\n        if sign { (f, o) } else { (-f, o.reverse()) }\n    }\n}\n\nimpl TryFrom<Integer> for Float {\n    type Error = FloatConversionError;\n\n    /// Converts an [`Integer`] to a [`Float`], taking the [`Integer`] by value.\n    ///\n    /// If the [`Integer`] is nonzero, the precision of the [`Float`] is the minimum possible\n    /// precision to represent the [`Integer`] exactly. If you want to specify some other precision,\n    /// try [`Float::from_integer_prec`]. This may require rounding, which uses [`Nearest`] by\n    /// default. To specify a rounding mode as well as a precision, try\n    /// [`Float::from_integer_prec_round`].\n    ///\n    /// If the absolue value of the [`Integer`] is greater than or equal to $2^{2^{30}-1}$, this\n    /// function returns an overflow error.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `n.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Float::try_from(Integer::ZERO).unwrap().to_string(), \"0.0\");\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(123)).unwrap().to_string(),\n    ///     \"123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(123)).unwrap().get_prec(),\n    ///     Some(7)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(10)).unwrap().to_string(),\n    ///     \"10.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(10)).unwrap().get_prec(),\n    ///     Some(3)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(-123)).unwrap().to_string(),\n    ///     \"-123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(-123)).unwrap().get_prec(),\n    ///     Some(7)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(-10)).unwrap().to_string(),\n    ///     \"-10.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Integer::from(-10)).unwrap().get_prec(),\n    ///     Some(3)\n    /// );\n    /// ```\n    #[inline]\n    fn try_from(n: Integer) -> Result<Self, Self::Error> {\n        let sign = n >= 0;\n        let abs = Self::try_from(n.unsigned_abs())?;\n        Ok(if sign { abs } else { -abs })\n    }\n}\n\nimpl TryFrom<&Integer> for Float {\n    type Error = FloatConversionError;\n\n    /// Converts an [`Integer`] to a [`Float`], taking the [`Integer`] by reference.\n    ///\n    /// If the [`Integer`] is nonzero, the precision of the [`Float`] is the minimum possible\n    /// precision to represent the [`Integer`] exactly. If you want to specify some other precision,\n    /// try [`Float::from_integer_prec`]. This may require rounding, which uses [`Nearest`] by\n    /// default. To specify a rounding mode as well as a precision, try\n    /// [`Float::from_integer_prec_round`].\n    ///\n    /// If the absolue value of the [`Integer`] is greater than or equal to $2^{2^{30}-1}$, this\n    /// function returns an overflow error.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `n.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Float::try_from(&Integer::ZERO).unwrap().to_string(), \"0.0\");\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(123)).unwrap().to_string(),\n    ///     \"123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(123)).unwrap().get_prec(),\n    ///     Some(7)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(10)).unwrap().to_string(),\n    ///     \"10.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(10)).unwrap().get_prec(),\n    ///     Some(3)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(-123)).unwrap().to_string(),\n    ///     \"-123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(-123)).unwrap().get_prec(),\n    ///     Some(7)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(-10)).unwrap().to_string(),\n    ///     \"-10.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Integer::from(-10)).unwrap().get_prec(),\n    ///     Some(3)\n    /// );\n    /// ```\n    #[inline]\n    fn try_from(n: &Integer) -> Result<Self, Self::Error> {\n        let sign = *n >= 0;\n        let abs = Self::try_from(n.unsigned_abs())?;\n        Ok(if sign { abs } else { -abs })\n    }\n}\n\nimpl ConvertibleFrom<&Integer> for Float {\n    /// Determines whether an [`Integer`] can be converted to an [`Float`], taking the [`Integer`]\n    /// by reference.\n    ///\n    /// The [`Integer`]s that are convertible to [`Float`]s are those whose that would not overflow:\n    /// that is, those whose absolute values are less than $2^{2^{30}-1}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Float::convertible_from(&Integer::ZERO), true);\n    /// assert_eq!(Float::convertible_from(&Integer::from(3u8)), true);\n    /// ```\n    #[inline]\n    fn convertible_from(x: &Integer) -> bool {\n        *x == 0\n            || (Self::MIN_EXPONENT..=Self::MAX_EXPONENT).contains(\n                &i32::saturating_from(x.unsigned_abs_ref().floor_log_base_2()).saturating_add(1),\n            )\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    DivisibleByPowerOf2, FloorLogBase2, ModPowerOf2, NegModPowerOf2, PowerOf2,\n    RoundToMultipleOfPowerOf2Assign, SaturatingSubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, Zero};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::{Natural, bit_to_limb_count_ceiling};\nuse malachite_nz::platform::Limb;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\n\nfn from_natural_prec_round_helper(\n    x: &Natural,\n    prec: u64,\n    rm: RoundingMode,\n    bits: u64,\n) -> (Float, Ordering) {\n    if *x == 0 {\n        return (Float::ZERO, Equal);\n    }\n    let mut exponent = i32::saturating_from(bits);\n    if exponent > Float::MAX_EXPONENT {\n        return match rm {\n            Up | Ceiling | Nearest => (Float::INFINITY, Greater),\n            Floor | Down => (Float::max_finite_value_with_prec(prec), Less),\n            Exact => panic!(\"Inexact conversion from Natural to Float\"),\n        };\n    }\n    let mut needed_bits = prec;\n    let sig_bits_in_highest_limb = bits.mod_power_of_2(Limb::LOG_WIDTH);\n    let mut needed_limbs = 1;\n    needed_bits.saturating_sub_assign(sig_bits_in_highest_limb);\n    if needed_bits != 0 {\n        needed_limbs += bit_to_limb_count_ceiling(needed_bits);\n    }\n    let mut rev_limbs = x.limbs().rev();\n    let mut significand = Natural::from_owned_limbs_desc(\n        (&mut rev_limbs)\n            .take(usize::exact_from(needed_limbs))\n            .collect(),\n    );\n    significand <<= significand\n        .significant_bits()\n        .neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let mut mask_width = significand.significant_bits() - prec;\n    let mut erased_limb = 0;\n    if mask_width >= Limb::WIDTH {\n        erased_limb = significand.limbs()[0];\n        significand >>= Limb::WIDTH;\n        mask_width -= Limb::WIDTH;\n    }\n    let o = match rm {\n        Exact => {\n            let inexact = erased_limb != 0\n                || !significand.divisible_by_power_of_2(mask_width)\n                || rev_limbs.any(|y| y != 0);\n            assert!(!inexact, \"Inexact conversion from Natural\");\n            Equal\n        }\n        Floor | Down => {\n            let inexact = erased_limb != 0\n                || !significand.divisible_by_power_of_2(mask_width)\n                || rev_limbs.any(|y| y != 0);\n            if inexact {\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                Less\n            } else {\n                Equal\n            }\n        }\n        Ceiling | Up => {\n            let inexact = erased_limb != 0\n                || !significand.divisible_by_power_of_2(mask_width)\n                || rev_limbs.any(|y| y != 0);\n            if inexact {\n                let original_limb_count = significand.limb_count();\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                significand += Natural::power_of_2(mask_width);\n                if significand.limb_count() > original_limb_count {\n                    if exponent == Float::MAX_EXPONENT {\n                        return (Float::INFINITY, Greater);\n                    }\n                    significand >>= 1;\n                    exponent += 1;\n                }\n                Greater\n            } else {\n                Equal\n            }\n        }\n        Nearest => {\n            let half_bit = x.get_bit(bits - prec - 1);\n            let inexact_after_half = !x.divisible_by_power_of_2(bits - prec - 1);\n            let inexact = half_bit || inexact_after_half;\n            if half_bit && (inexact_after_half || x.get_bit(bits - prec)) {\n                let original_limb_count = significand.limb_count();\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                significand += Natural::power_of_2(mask_width);\n                if significand.limb_count() > original_limb_count {\n                    if exponent == Float::MAX_EXPONENT {\n                        return (Float::INFINITY, Greater);\n                    }\n                    significand >>= 1;\n                    exponent += 1;\n                }\n                Greater\n            } else if inexact {\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                Less\n            } else {\n                Equal\n            }\n        }\n    };\n    (\n        Float(Finite {\n            sign: true,\n            exponent,\n            precision: prec,\n            significand,\n        }),\n        o,\n    )\n}\n\nfn from_natural_prec_round_helper_zero_exponent(\n    x: &Natural,\n    prec: u64,\n    rm: RoundingMode,\n    bits: u64,\n) -> (Float, Ordering) {\n    let mut needed_bits = prec;\n    let sig_bits_in_highest_limb = bits.mod_power_of_2(Limb::LOG_WIDTH);\n    let mut needed_limbs = 1;\n    needed_bits.saturating_sub_assign(sig_bits_in_highest_limb);\n    if needed_bits != 0 {\n        needed_limbs += bit_to_limb_count_ceiling(needed_bits);\n    }\n    let mut rev_limbs = x.limbs().rev();\n    let mut significand =\n        Natural::from_owned_limbs_desc((&mut rev_limbs).take(needed_limbs).collect());\n    significand <<= significand\n        .significant_bits()\n        .neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let mut mask_width = significand.significant_bits() - prec;\n    let mut erased_limb = 0;\n    if mask_width >= Limb::WIDTH {\n        erased_limb = significand.limbs()[0];\n        significand >>= Limb::WIDTH;\n        mask_width -= Limb::WIDTH;\n    }\n    let mut exponent = 0;\n    let o = match rm {\n        Exact => {\n            let inexact = erased_limb != 0\n                || !significand.divisible_by_power_of_2(mask_width)\n                || rev_limbs.any(|y| y != 0);\n            assert!(!inexact, \"Inexact conversion from Natural\");\n            Equal\n        }\n        Floor | Down => {\n            let inexact = erased_limb != 0\n                || !significand.divisible_by_power_of_2(mask_width)\n                || rev_limbs.any(|y| y != 0);\n            if inexact {\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                Less\n            } else {\n                Equal\n            }\n        }\n        Ceiling | Up => {\n            let inexact = erased_limb != 0\n                || !significand.divisible_by_power_of_2(mask_width)\n                || rev_limbs.any(|y| y != 0);\n            if inexact {\n                let original_limb_count = significand.limb_count();\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                significand += Natural::power_of_2(mask_width);\n                if significand.limb_count() > original_limb_count {\n                    significand >>= 1;\n                    exponent += 1;\n                }\n                Greater\n            } else {\n                Equal\n            }\n        }\n        Nearest => {\n            let half_bit = x.get_bit(bits - prec - 1);\n            let inexact_after_half = !x.divisible_by_power_of_2(bits - prec - 1);\n            let inexact = half_bit || inexact_after_half;\n            if half_bit && (inexact_after_half || x.get_bit(bits - prec)) {\n                let original_limb_count = significand.limb_count();\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                significand += Natural::power_of_2(mask_width);\n                if significand.limb_count() > original_limb_count {\n                    significand >>= 1;\n                    exponent += 1;\n                }\n                Greater\n            } else if inexact {\n                significand.round_to_multiple_of_power_of_2_assign(mask_width, Floor);\n                Less\n            } else {\n                Equal\n            }\n        }\n    };\n    (\n        Float(Finite {\n            sign: true,\n            exponent,\n            precision: prec,\n            significand,\n        }),\n        o,\n    )\n}\n\nfn from_natural_prec_round_helper_no_round_zero_exponent(\n    x: &Natural,\n    prec: u64,\n    bits: u64,\n) -> Float {\n    let mut needed_bits = prec;\n    let sig_bits_in_highest_limb = bits.mod_power_of_2(Limb::LOG_WIDTH);\n    let mut needed_limbs = 1;\n    needed_bits.saturating_sub_assign(sig_bits_in_highest_limb);\n    if needed_bits != 0 {\n        needed_limbs += bit_to_limb_count_ceiling(needed_bits);\n    }\n    let mut rev_limbs = x.limbs().rev();\n    let mut significand =\n        Natural::from_owned_limbs_desc((&mut rev_limbs).take(needed_limbs).collect());\n    significand <<= significand\n        .significant_bits()\n        .neg_mod_power_of_2(Limb::LOG_WIDTH);\n    if significand.significant_bits() - prec >= Limb::WIDTH {\n        significand >>= Limb::WIDTH;\n    }\n    Float(Finite {\n        sign: true,\n        exponent: 0,\n        precision: prec,\n        significand,\n    })\n}\n\npub(crate) fn from_natural_prec_round_zero_exponent(\n    x: Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if x == 0u32 {\n        return (Float::ZERO, Equal);\n    }\n    let bits = x.significant_bits();\n    let mut f = Float(Finite {\n        sign: true,\n        exponent: 0,\n        precision: bits,\n        significand: x << bits.neg_mod_power_of_2(Limb::LOG_WIDTH),\n    });\n    let o = f.set_prec_round(prec, rm);\n    (f, o)\n}\n\npub(crate) fn from_natural_prec_round_zero_exponent_ref(\n    x: &Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    if *x == 0u32 {\n        return (Float::ZERO, Equal);\n    }\n    let bits = x.significant_bits();\n    if bits <= prec {\n        let mut f = Float(Finite {\n            sign: true,\n            exponent: 0,\n            precision: bits,\n            significand: x << bits.neg_mod_power_of_2(Limb::LOG_WIDTH),\n        });\n        let o = f.set_prec_round(prec, rm);\n        (f, o)\n    } else {\n        from_natural_prec_round_helper_zero_exponent(x, prec, rm, bits)\n    }\n}\n\npub(crate) fn from_natural_zero_exponent(x: Natural) -> Float {\n    if x == 0 {\n        Float::ZERO\n    } else {\n        let bits = x.significant_bits();\n        let prec = bits - x.trailing_zeros().unwrap();\n        from_natural_prec_round_zero_exponent(x, prec, Floor).0\n    }\n}\n\npub(crate) fn from_natural_zero_exponent_ref(x: &Natural) -> Float {\n    if *x == 0 {\n        Float::ZERO\n    } else {\n        let bits = x.significant_bits();\n        let prec = bits - x.trailing_zeros().unwrap();\n        from_natural_prec_round_helper_no_round_zero_exponent(x, prec, bits)\n    }\n}\n\nimpl Float {\n    /// Converts a [`Natural`] to a [`Float`], taking the [`Natural`] by value. If the [`Float`] is\n    /// nonzero, it has the specified precision. If rounding is needed, the specified rounding mode\n    /// is used. An [`Ordering`] is also returned, indicating whether the returned value is less\n    /// than, equal to, or greater than the original value.\n    ///\n    /// If you're only using [`Nearest`], try using [`Float::from_natural_prec`] instead.\n    ///\n    /// - If the [`Natural`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds down\n    ///   to $(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the `Natural` cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_natural_prec_round(Natural::ZERO, 10, Exact);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec_round(Natural::from(123u32), 20, Exact);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec_round(Natural::from(123u32), 4, Floor);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_natural_prec_round(Natural::from(123u32), 4, Ceiling);\n    /// assert_eq!(x.to_string(), \"1.3e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_natural_prec_round(x: Natural, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if x == 0u32 {\n            return (Self::ZERO, Equal);\n        }\n        let bits = x.significant_bits();\n        let bits_i32 = i32::saturating_from(bits);\n        if bits_i32 <= Self::MAX_EXPONENT {\n            let mut f = Self(Finite {\n                sign: true,\n                exponent: bits_i32,\n                precision: bits,\n                significand: x << bits.neg_mod_power_of_2(Limb::LOG_WIDTH),\n            });\n            let o = f.set_prec_round(prec, rm);\n            return (f, o);\n        }\n        match rm {\n            Up | Ceiling | Nearest => (Self::INFINITY, Greater),\n            Floor | Down => (Self::max_finite_value_with_prec(prec), Less),\n            Exact => panic!(\"Inexact conversion from Natural to Float\"),\n        }\n    }\n\n    /// Converts a [`Natural`] to a [`Float`], taking the [`Natural`] by reference. If the [`Float`]\n    /// is nonzero, it has the specified precision. If rounding is needed, the specified rounding\n    /// mode is used. An [`Ordering`] is also returned, indicating whether the returned value is\n    /// less than, equal to, or greater than the original value.\n    ///\n    /// If you're only using [`Nearest`], try using [`Float::from_natural_prec_ref`] instead.\n    ///\n    /// - If the [`Natural`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds down\n    ///   to $(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the `Natural` cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_natural_prec_round_ref(&Natural::ZERO, 10, Exact);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec_round_ref(&Natural::from(123u32), 20, Exact);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec_round_ref(&Natural::from(123u32), 4, Floor);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_natural_prec_round_ref(&Natural::from(123u32), 4, Ceiling);\n    /// assert_eq!(x.to_string(), \"1.3e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Greater);\n    /// ```\n    #[inline]\n    pub fn from_natural_prec_round_ref(\n        x: &Natural,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if *x == 0u32 {\n            return (Self::ZERO, Equal);\n        }\n        let bits = x.significant_bits();\n        if bits <= prec {\n            let bits_i32 = i32::saturating_from(bits);\n            if bits_i32 <= Self::MAX_EXPONENT {\n                let mut f = Self(Finite {\n                    sign: true,\n                    exponent: bits_i32,\n                    precision: bits,\n                    significand: x << bits.neg_mod_power_of_2(Limb::LOG_WIDTH),\n                });\n                let o = f.set_prec_round(prec, rm);\n                return (f, o);\n            }\n            match rm {\n                Up | Ceiling | Nearest => (Self::INFINITY, Greater),\n                Floor | Down => (Self::max_finite_value_with_prec(prec), Less),\n                Exact => panic!(\"Inexact conversion from Natural to Float\"),\n            }\n        } else {\n            from_natural_prec_round_helper(x, prec, rm, bits)\n        }\n    }\n\n    /// Converts a [`Natural`] to a [`Float`], taking the [`Natural`] by value. If the [`Float`] is\n    /// nonzero, it has the specified precision. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// If you want the [`Float`]'s precision to be equal to the [`Natural`]'s number of significant\n    /// bits, try just using `Float::try_from` instead.\n    ///\n    /// Rounding may occur, in which case [`Nearest`] is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_natural_prec_round`].\n    ///\n    /// - If the [`Natural`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_natural_prec(Natural::ZERO, 10);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec(Natural::from(123u32), 20);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec(Natural::from(123u32), 4);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn from_natural_prec(x: Natural, prec: u64) -> (Self, Ordering) {\n        Self::from_natural_prec_round(x, prec, Nearest)\n    }\n\n    /// Converts a [`Natural`] to a [`Float`], taking the [`Natural`] by reference. If the [`Float`]\n    /// is nonzero, it has the specified precision. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// If you want the [`Float`]'s precision to be equal to the [`Natural`]'s number of significant\n    /// bits, try just using `Float::try_from` instead.\n    ///\n    /// Rounding may occur, in which case [`Nearest`] is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_natural_prec_round_ref`].\n    ///\n    /// - If the [`Natural`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$.\n    ///\n    /// # Worst-case complexity\n    /// $T(m,n) = O(\\max(m,n))$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $m$ is `n.significant_bits()`, and $n$ is\n    /// `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_natural_prec_ref(&Natural::ZERO, 10);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec_ref(&Natural::from(123u32), 20);\n    /// assert_eq!(x.to_string(), \"123.0\");\n    /// assert_eq!(x.get_prec(), Some(20));\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_natural_prec_ref(&Natural::from(123u32), 4);\n    /// assert_eq!(x.to_string(), \"1.2e2\");\n    /// assert_eq!(x.get_prec(), Some(4));\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn from_natural_prec_ref(x: &Natural, prec: u64) -> (Self, Ordering) {\n        Self::from_natural_prec_round_ref(x, prec, Nearest)\n    }\n}\n\nimpl TryFrom<Natural> for Float {\n    type Error = FloatConversionError;\n\n    /// Converts a [`Natural`] to a [`Float`], taking the [`Natural`] by value.\n    ///\n    /// If the [`Natural`] is nonzero, the precision of the [`Float`] is the minimum possible\n    /// precision to represent the [`Natural`] exactly. If you want to specify some other precision,\n    /// try [`Float::from_natural_prec`]. This may require rounding, which uses [`Nearest`] by\n    /// default. To specify a rounding mode as well as a precision, try\n    /// [`Float::from_natural_prec_round`].\n    ///\n    /// If the [`Natural`] is greater than or equal to $2^{2^{30}-1}$, this function returns an\n    /// overflow error.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `n.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Float::try_from(Natural::ZERO).unwrap().to_string(), \"0.0\");\n    /// assert_eq!(\n    ///     Float::try_from(Natural::from(123u32)).unwrap().to_string(),\n    ///     \"123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Natural::from(123u32)).unwrap().get_prec(),\n    ///     Some(7)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Natural::from(10u32)).unwrap().to_string(),\n    ///     \"10.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Natural::from(10u32)).unwrap().get_prec(),\n    ///     Some(3)\n    /// );\n    /// ```\n    fn try_from(x: Natural) -> Result<Self, Self::Error> {\n        if x == 0 {\n            Ok(Self::ZERO)\n        } else {\n            let bits = x.significant_bits();\n            let prec = bits - x.trailing_zeros().unwrap();\n            let (f, o) = Self::from_natural_prec_round(x, prec, Floor);\n            if o == Equal {\n                Ok(f)\n            } else {\n                Err(FloatConversionError::Overflow)\n            }\n        }\n    }\n}\n\nimpl TryFrom<&Natural> for Float {\n    type Error = FloatConversionError;\n\n    /// Converts a [`Natural`] to a [`Float`], taking the [`Natural`] by reference.\n    ///\n    /// If the [`Natural`] is nonzero, the precision of the [`Float`] is the minimum possible\n    /// precision to represent the [`Natural`] exactly. If you want to specify some other precision,\n    /// try [`Float::from_natural_prec`]. This may require rounding, which uses [`Nearest`] by\n    /// default. To specify a rounding mode as well as a precision, try\n    /// [`Float::from_natural_prec_round`].\n    ///\n    /// If the [`Natural`] is greater than or equal to $2^{2^{30}-1}$, this function returns an\n    /// overflow error.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `n.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Float::try_from(&Natural::ZERO).unwrap().to_string(), \"0.0\");\n    /// assert_eq!(\n    ///     Float::try_from(&Natural::from(123u32)).unwrap().to_string(),\n    ///     \"123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Natural::from(123u32)).unwrap().get_prec(),\n    ///     Some(7)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Natural::from(10u32)).unwrap().to_string(),\n    ///     \"10.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Natural::from(10u32)).unwrap().get_prec(),\n    ///     Some(3)\n    /// );\n    /// ```\n    #[inline]\n    fn try_from(x: &Natural) -> Result<Self, Self::Error> {\n        if *x == 0 {\n            Ok(Self::ZERO)\n        } else {\n            let bits = x.significant_bits();\n            let prec = bits - x.trailing_zeros().unwrap();\n            let (f, o) = Self::from_natural_prec_round_ref(x, prec, Floor);\n            if o == Equal {\n                Ok(f)\n            } else {\n                Err(FloatConversionError::Overflow)\n            }\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Natural> for Float {\n    /// Determines whether a [`Natural`] can be converted to an [`Float`], taking the [`Natural`] by\n    /// reference.\n    ///\n    /// The [`Natural`]s that are convertible to [`Float`]s are those whose that would not overflow:\n    /// that is, those that are less than $2^{2^{30}-1}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Float::convertible_from(&Natural::ZERO), true);\n    /// assert_eq!(Float::convertible_from(&Natural::from(3u8)), true);\n    /// ```\n    #[inline]\n    fn convertible_from(x: &Natural) -> bool {\n        *x == 0\n            || (Self::MIN_EXPONENT..=Self::MAX_EXPONENT)\n                .contains(&i32::saturating_from(x.floor_log_base_2()).saturating_add(1))\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\nuse malachite_base::rounding_modes::RoundingMode;\n\nimpl Float {\n    /// Converts a primitive float to a [`Float`]. If the [`Float`] is nonzero and finite, it has\n    /// the specified precision. If rounding is needed, the specified rounding mode is used. An\n    /// [`Ordering`] is also returned, indicating whether the returned value is less than, equal to,\n    /// or greater than the original value. (Although a NaN is not comparable to any [`Float`],\n    /// converting a NaN to a NaN will also return `Equal`, indicating an exact conversion.)\n    ///\n    /// If you're only using `Nearest`, try using [`Float::from_primitive_float_prec`] instead.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(prec, x.sci_exponent().abs())`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the primitive float cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::from_primitive_float#from_primitive_float_prec_round).\n    #[inline]\n    pub fn from_primitive_float_prec_round<T: PrimitiveFloat>(\n        x: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if x.is_nan() {\n            (Self::NAN, Equal)\n        } else if !x.is_finite() {\n            if x.is_sign_positive() {\n                (Self::INFINITY, Equal)\n            } else {\n                (Self::NEGATIVE_INFINITY, Equal)\n            }\n        } else if x == T::ZERO {\n            if x.is_sign_positive() {\n                (Self::ZERO, Equal)\n            } else {\n                (Self::NEGATIVE_ZERO, Equal)\n            }\n        } else {\n            let (m, e) = x.integer_mantissa_and_exponent();\n            if x.is_sign_positive() {\n                let (f, o) = Self::from_unsigned_prec_round(m, prec, rm);\n                (f << e, o)\n            } else {\n                let (abs, o) = Self::from_unsigned_prec_round(m, prec, -rm);\n                (-(abs << e), o.reverse())\n            }\n        }\n    }\n\n    /// Converts a primitive float to a [`Float`]. If the [`Float`] is nonzero and finite, it has\n    /// the specified precision. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value. (Although a NaN is not\n    /// comparable to any [`Float`], converting a NaN to a NaN will also return `Equal`, indicating\n    /// an exact conversion.)\n    ///\n    /// Rounding may occur, in which case `Nearest` is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_primitive_float_prec_round`].\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(prec, x.sci_exponent().abs())`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::from_primitive_float#from_primitive_float_prec).\n    #[inline]\n    pub fn from_primitive_float_prec<T: PrimitiveFloat>(x: T, prec: u64) -> (Self, Ordering) {\n        assert_ne!(prec, 0);\n        if x.is_nan() {\n            (Self::NAN, Equal)\n        } else if !x.is_finite() {\n            if x.is_sign_positive() {\n                (Self::INFINITY, Equal)\n            } else {\n                (Self::NEGATIVE_INFINITY, Equal)\n            }\n        } else if x == T::ZERO {\n            if x.is_sign_positive() {\n                (Self::ZERO, Equal)\n            } else {\n                (Self::NEGATIVE_ZERO, Equal)\n            }\n        } else {\n            let (m, e) = x.integer_mantissa_and_exponent();\n            if x.is_sign_positive() {\n                let (f, o) = Self::from_unsigned_prec(m, prec);\n                (f << e, o)\n            } else {\n                let (abs, o) = Self::from_unsigned_prec(m, prec);\n                (-(abs << e), o.reverse())\n            }\n        }\n    }\n}\n\nmacro_rules! impl_from_primitive_float {\n    ($t: ident) => {\n        impl From<$t> for Float {\n            /// Converts a primitive float to a [`Float`].\n            ///\n            /// If the primitive float is finite and nonzero, the precision of the [`Float`] is the\n            /// minimum possible precision to represent the primitive float exactly. If you want to\n            /// specify a different precision, try [`Float::from_primitive_float_prec`]. This may\n            /// require rounding, which uses `Nearest` by default. To specify a rounding mode as\n            /// well as a precision, try [`Float::from_primitive_float_prec_round`].\n            ///\n            /// This function does not overflow or underflow.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `x.sci_exponent().abs()`.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#from).\n            #[inline]\n            fn from(x: $t) -> Float {\n                if x.is_nan() {\n                    Float::NAN\n                } else if !x.is_finite() {\n                    if x.is_sign_positive() {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    }\n                } else if x == 0.0 {\n                    if x.is_sign_positive() {\n                        Float::ZERO\n                    } else {\n                        Float::NEGATIVE_ZERO\n                    }\n                } else {\n                    let (m, e) = x.integer_mantissa_and_exponent();\n                    let abs = Float::from(m) << e;\n                    if x.is_sign_positive() { abs } else { -abs }\n                }\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_from_primitive_float);\n"
  },
  {
    "path": "malachite-float/src/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse core::cmp::Ordering;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\n\nconst fn const_limb_significant_bits(x: Limb) -> u64 {\n    Limb::WIDTH - (x.leading_zeros() as u64)\n}\n\nimpl Float {\n    /// Converts an unsigned primitive integer to a [`Float`], after multiplying it by the specified\n    /// power of 2.\n    ///\n    /// The type of the integer is `u64`, unless the `32_bit_limbs` feature is set, in which case\n    /// the type is `u32`.\n    ///\n    /// If the integer is nonzero, the precision of the [`Float`] is the minimum possible precision\n    /// to represent the integer exactly.\n    ///\n    /// If you don't need to use this function in a const context, try just using `from` instead,\n    /// followed by `>>` or `<<`.\n    ///\n    /// $$\n    /// f(x,k) = x2^k.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if the result is too large or too small to be represented by a `Float`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(\n    ///     Float::const_from_unsigned_times_power_of_2(0, 0).to_string(),\n    ///     \"0.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_unsigned_times_power_of_2(123, 0).to_string(),\n    ///     \"123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_unsigned_times_power_of_2(123, 1).to_string(),\n    ///     \"246.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_unsigned_times_power_of_2(123, -1).to_string(),\n    ///     \"61.5\"\n    /// );\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// {\n    ///     assert_eq!(\n    ///         Float::const_from_unsigned_times_power_of_2(884279719003555, -48).to_string(),\n    ///         \"3.141592653589793\"\n    ///     );\n    /// }\n    /// ```\n    pub const fn const_from_unsigned_times_power_of_2(x: Limb, pow: i32) -> Self {\n        if x == 0 {\n            return Self::ZERO;\n        }\n        let bits = const_limb_significant_bits(x);\n        let exponent = (bits as i32).saturating_add(pow);\n        assert!(exponent <= Self::MAX_EXPONENT);\n        assert!(exponent >= Self::MIN_EXPONENT);\n        let prec = bits - x.trailing_zeros() as u64;\n        Self(Finite {\n            sign: true,\n            exponent,\n            precision: prec,\n            significand: Natural::const_from(x << (Limb::WIDTH - bits)),\n        })\n    }\n\n    /// Converts an unsigned primitive integer to a [`Float`].\n    ///\n    /// The type of the integer is `u64`, unless the `32_bit_limbs` feature is set, in which case\n    /// the type is `u32`.\n    ///\n    /// If the integer is nonzero, the precision of the [`Float`] is the minimum possible precision\n    /// to represent the integer exactly.\n    ///\n    /// If you don't need to use this function in a const context, try just using `from` instead; it\n    /// will probably be slightly faster.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::const_from_unsigned(0).to_string(), \"0.0\");\n    /// assert_eq!(Float::const_from_unsigned(123).to_string(), \"123.0\");\n    /// ```\n    #[inline]\n    pub const fn const_from_unsigned(x: Limb) -> Self {\n        Self::const_from_unsigned_times_power_of_2(x, 0)\n    }\n\n    /// Converts a signed primitive integer to a [`Float`], after multiplying it by the specified\n    /// power of 2.\n    ///\n    /// The type of the integer is `i64`, unless the `32_bit_limbs` feature is set, in which case\n    /// the type is `i32`.\n    ///\n    /// If the integer is nonzero, the precision of the [`Float`] is the minimum possible precision\n    /// to represent the integer exactly.\n    ///\n    /// If you don't need to use this function in a const context, try just using `from` instead,\n    /// followed by `>>` or `<<`.\n    ///\n    /// $$\n    /// f(x,k) = x2^k.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if the result is too large or too small to be represented by a `Float`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(\n    ///     Float::const_from_signed_times_power_of_2(0, 0).to_string(),\n    ///     \"0.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_signed_times_power_of_2(123, 0).to_string(),\n    ///     \"123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_signed_times_power_of_2(123, 1).to_string(),\n    ///     \"246.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_signed_times_power_of_2(123, -1).to_string(),\n    ///     \"61.5\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_signed_times_power_of_2(-123, 0).to_string(),\n    ///     \"-123.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_signed_times_power_of_2(-123, 1).to_string(),\n    ///     \"-246.0\"\n    /// );\n    /// assert_eq!(\n    ///     Float::const_from_signed_times_power_of_2(-123, -1).to_string(),\n    ///     \"-61.5\"\n    /// );\n    /// #[cfg(not(feature = \"32_bit_limbs\"))]\n    /// {\n    ///     assert_eq!(\n    ///         Float::const_from_signed_times_power_of_2(884279719003555, -48).to_string(),\n    ///         \"3.141592653589793\"\n    ///     );\n    ///     assert_eq!(\n    ///         Float::const_from_signed_times_power_of_2(-884279719003555, -48).to_string(),\n    ///         \"-3.141592653589793\"\n    ///     );\n    /// }\n    /// ```\n    pub const fn const_from_signed_times_power_of_2(x: SignedLimb, pow: i32) -> Self {\n        if x == 0 {\n            return Self::ZERO;\n        }\n        let x_abs = x.unsigned_abs();\n        let bits = const_limb_significant_bits(x_abs);\n        let exponent = (bits as i32).saturating_add(pow);\n        assert!(exponent <= Self::MAX_EXPONENT);\n        assert!(exponent >= Self::MIN_EXPONENT);\n        let prec = bits - x_abs.trailing_zeros() as u64;\n        Self(Finite {\n            sign: x > 0,\n            exponent,\n            precision: prec,\n            significand: Natural::const_from(x_abs << (Limb::WIDTH - bits)),\n        })\n    }\n\n    /// Converts a signed primitive integer to a [`Float`].\n    ///\n    /// The type of the integer is `i64`, unless the `32_bit_limbs` feature is set, in which case\n    /// the type is `i32`.\n    ///\n    /// If the integer is nonzero, the precision of the [`Float`] is the minimum possible precision\n    /// to represent the integer exactly.\n    ///\n    /// If you don't need to use this function in a const context, try just using `from` instead; it\n    /// will probably be slightly faster.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::const_from_signed(0).to_string(), \"0.0\");\n    /// assert_eq!(Float::const_from_signed(123).to_string(), \"123.0\");\n    /// assert_eq!(Float::const_from_signed(-123).to_string(), \"-123.0\");\n    /// ```\n    #[inline]\n    pub const fn const_from_signed(x: SignedLimb) -> Self {\n        Self::const_from_signed_times_power_of_2(x, 0)\n    }\n\n    /// Converts a primitive unsigned integer to a [`Float`]. If the [`Float`] is nonzero, it has\n    /// the specified precision. If rounding is needed, the specified rounding mode is used. An\n    /// [`Ordering`] is also returned, indicating whether the returned value is less than, equal to,\n    /// or greater than the original value.\n    ///\n    /// If you're only using `Nearest`, try using [`Float::from_unsigned_prec`] instead.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the primitive integer cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::from_primitive_int#from_unsigned_prec_round).\n    #[inline]\n    pub fn from_unsigned_prec_round<T: PrimitiveUnsigned>(\n        x: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering)\n    where\n        Natural: From<T>,\n    {\n        Self::from_natural_prec_round(Natural::from(x), prec, rm)\n    }\n\n    /// Converts an unsigned primitive integer to a [`Float`]. If the [`Float`] is nonzero, it has\n    /// the specified precision. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// If you want the [`Float`]'s precision to be equal to the integer's number of significant\n    /// bits, try just using `Float::from` instead.\n    ///\n    /// Rounding may occur, in which case `Nearest` is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_unsigned_prec_round`].\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::from_primitive_int#from_unsigned_prec).\n    #[inline]\n    pub fn from_unsigned_prec<T: PrimitiveUnsigned>(x: T, prec: u64) -> (Self, Ordering)\n    where\n        Natural: From<T>,\n    {\n        Self::from_natural_prec(Natural::from(x), prec)\n    }\n\n    /// Converts a primitive signed integer to a [`Float`]. If the [`Float`] is nonzero, it has the\n    /// specified precision. If rounding is needed, the specified rounding mode is used. An\n    /// [`Ordering`] is also returned, indicating whether the returned value is less than, equal to,\n    /// or greater than the original value.\n    ///\n    /// If you're only using `Nearest`, try using [`Float::from_signed_prec`] instead.\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the primitive integer cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// See [here](super::from_primitive_int#from_signed_prec_round).\n    #[inline]\n    pub fn from_signed_prec_round<T: PrimitiveSigned>(\n        x: T,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering)\n    where\n        Integer: From<T>,\n    {\n        Self::from_integer_prec_round(Integer::from(x), prec, rm)\n    }\n\n    /// Converts a signed primitive integer to a [`Float`]. If the [`Float`] is nonzero, it has the\n    /// specified precision. An [`Ordering`] is also returned, indicating whether the returned value\n    /// is less than, equal to, or greater than the original value.\n    ///\n    /// If you want the [`Float`]'s precision to be equal to the integer's number of significant\n    /// bits, try just using `Float::from` instead.\n    ///\n    /// Rounding may occur, in which case `Nearest` is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_signed_prec_round`].\n    ///\n    /// This function does not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// See [here](super::from_primitive_int#from_signed_prec).\n    #[inline]\n    pub fn from_signed_prec<T: PrimitiveSigned>(x: T, prec: u64) -> (Self, Ordering)\n    where\n        Integer: From<T>,\n    {\n        Self::from_integer_prec(Integer::from(x), prec)\n    }\n}\n\nmacro_rules! impl_from_unsigned {\n    ($t: ident) => {\n        impl From<$t> for Float {\n            /// Converts an unsigned primitive integer to a [`Float`].\n            ///\n            /// If the integer is nonzero, the precision of the [`Float`] is equal to the integer's\n            /// number of significant bits. If you want to specify a different precision, try\n            /// [`Float::from_unsigned_prec`]. This may require rounding, which uses `Nearest` by\n            /// default. To specify a rounding mode as well as a precision, try\n            /// [`Float::from_unsigned_prec_round`].\n            ///\n            /// If you want to create a [`Float`] from an unsigned primitive integer in a const\n            /// context, try [`Float::const_from_unsigned`] instead.\n            ///\n            /// This function does not overflow or underflow.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(u: $t) -> Float {\n                Float::exact_from(Natural::from(u))\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_from_unsigned);\n\nmacro_rules! impl_from_signed {\n    ($t: ident) => {\n        impl From<$t> for Float {\n            /// Converts a signed primitive integer to a [`Float`].\n            ///\n            /// If the integer is nonzero, the precision of the [`Float`] is equal to the integer's\n            /// number of significant bits. If you want to specify a different precision, try\n            /// [`Float::from_signed_prec`]. This may require rounding, which uses `Nearest` by\n            /// default. To specify a rounding mode as well as a precision, try\n            /// [`Float::from_signed_prec_round`].\n            ///\n            /// If you want to create a [`Float`] from an signed primitive integer in a const\n            /// context, try [`Float::const_from_signed`] instead.\n            ///\n            /// This function does not overflow or underflow.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(i: $t) -> Float {\n                Float::exact_from(Integer::from(i))\n            }\n        }\n    };\n}\napply_to_signeds!(impl_from_signed);\n"
  },
  {
    "path": "malachite-float/src/conversion/from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::Finite;\nuse crate::conversion::from_integer::{\n    from_integer_prec_round_zero_exponent, from_integer_zero_exponent,\n};\nuse crate::conversion::from_natural::{\n    from_natural_prec_round_zero_exponent, from_natural_prec_round_zero_exponent_ref,\n    from_natural_zero_exponent, from_natural_zero_exponent_ref,\n};\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, IsPowerOf2, NegAssign, NegModPowerOf2, RoundToMultipleOfPowerOf2, UnsignedAbs,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, RoundingFrom, SaturatingFrom,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\n\npub_test! {from_rational_prec_round_direct(\n    x: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    let sign = x >= 0;\n    if let Some(pow) = x.denominator_ref().checked_log_base_2() {\n        let n = x.into_numerator();\n        let n_bits = n.significant_bits();\n        let (mut y, mut o) =\n            from_integer_prec_round_zero_exponent(Integer::from_sign_and_abs(sign, n), prec, rm);\n        o = y.shr_prec_round_assign_helper(i128::from(pow) - i128::from(n_bits), prec, rm, o);\n        assert!(rm != Exact || o == Equal, \"Inexact conversion from Rational to Float\");\n        (y, o)\n    } else {\n        let mut exponent = i32::saturating_from(x.floor_log_base_2_abs());\n        if exponent >= Float::MAX_EXPONENT {\n            return match (sign, rm) {\n                (true, Up | Ceiling | Nearest) => (Float::INFINITY, Greater),\n                (true, Floor | Down) => (Float::max_finite_value_with_prec(prec), Less),\n                (false, Up | Floor | Nearest) => (Float::NEGATIVE_INFINITY, Less),\n                (false, Ceiling | Down) => (-Float::max_finite_value_with_prec(prec), Greater),\n                (_, Exact) => panic!(\"Inexact conversion from Rational to Float\"),\n            };\n        }\n        let (significand, o) =\n            Integer::rounding_from(x << (i128::exact_from(prec) - i128::from(exponent) - 1), rm);\n        let sign = significand >= 0;\n        let mut significand = significand.unsigned_abs();\n        let away_from_0 = if sign { Greater } else { Less };\n        if o == away_from_0 && significand.is_power_of_2() {\n            exponent += 1;\n            if exponent >= Float::MAX_EXPONENT {\n                return if sign {\n                    (Float::INFINITY, Greater)\n                } else {\n                    (Float::NEGATIVE_INFINITY, Less)\n                };\n            }\n        }\n        exponent += 1;\n        if exponent < Float::MIN_EXPONENT {\n            assert!(rm != Exact, \"Inexact conversion from Rational to Float\");\n            return if rm == Nearest\n                && exponent == Float::MIN_EXPONENT - 1\n                && (o == away_from_0.reverse() || !significand.is_power_of_2())\n            {\n                if sign {\n                    (Float::min_positive_value_prec(prec), Greater)\n                } else {\n                    (-Float::min_positive_value_prec(prec), Less)\n                }\n            } else {\n                match (sign, rm) {\n                    (true, Up | Ceiling) => (Float::min_positive_value_prec(prec), Greater),\n                    (true, Floor | Down | Nearest) => (Float::ZERO, Less),\n                    (false, Up | Floor) => (-Float::min_positive_value_prec(prec), Less),\n                    (false, Ceiling | Down | Nearest) => (Float::NEGATIVE_ZERO, Greater),\n                    (_, Exact) => unreachable!(),\n                }\n            };\n        }\n        significand <<= significand\n            .significant_bits()\n            .neg_mod_power_of_2(Limb::LOG_WIDTH);\n        let target_bits = prec\n            .round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n            .0;\n        let current_bits = significand_bits(&significand);\n        if current_bits > target_bits {\n            significand >>= current_bits - target_bits;\n        }\n        (\n            Float(Finite {\n                sign,\n                exponent,\n                precision: prec,\n                significand,\n            }),\n            o,\n        )\n    }\n}}\n\npub_test! {from_rational_prec_round_using_div(\n    x: Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    let sign = x >= 0;\n    if !sign {\n        rm.neg_assign();\n    }\n    let (n, d) = x.into_numerator_and_denominator();\n    let is_zero = n == 0;\n    let (f, o) = match (\n        if is_zero {\n            None\n        } else {\n            n.checked_log_base_2()\n        },\n        d.checked_log_base_2(),\n    ) {\n        (Some(log_n), Some(log_d)) => Float::power_of_2_prec_round(\n            i64::saturating_from(i128::from(log_n) - i128::from(log_d)),\n            prec,\n            rm,\n        ),\n        (None, Some(log_d)) => {\n            let bits = n.significant_bits();\n            let (mut f, mut o) = from_natural_prec_round_zero_exponent(n, prec, rm);\n            o = f.shr_prec_round_assign_helper(\n                i128::from(log_d) - i128::from(bits),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n        (Some(log_n), None) => {\n            let bits = d.significant_bits();\n            let (mut f, mut o) =\n                from_natural_zero_exponent(d).reciprocal_prec_round(prec, rm);\n            o = f.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(bits),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n        (None, None) => {\n            let n_bits = n.significant_bits();\n            let d_bits = d.significant_bits();\n            let (mut f, mut o) = from_natural_zero_exponent(n).div_prec_round(\n                from_natural_zero_exponent(d),\n                prec,\n                rm,\n            );\n            o = f.shl_prec_round_assign_helper(\n                i128::from(n_bits) - i128::from(d_bits),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n    };\n    if sign {\n        (f, o)\n    } else {\n        (-f, o.reverse())\n    }\n}}\n\npub_test! {from_rational_prec_round_ref_direct(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    let sign = *x >= 0;\n    if let Some(pow) = x.denominator_ref().checked_log_base_2() {\n        let n = x.numerator_ref();\n        let n_bits = n.significant_bits();\n        let (mut y, mut o) =\n            from_natural_prec_round_zero_exponent_ref(n, prec, if sign { rm } else { -rm });\n        o = y.shr_prec_round_assign_helper(\n            i128::from(pow) - i128::from(n_bits),\n            prec,\n            if sign { rm } else { -rm },\n            o,\n        );\n        assert!(rm != Exact || o == Equal, \"Inexact conversion from Rational to Float\");\n        if sign {\n            (y, o)\n        } else {\n            (-y, o.reverse())\n        }\n    } else {\n        let mut exponent = i32::saturating_from(x.floor_log_base_2_abs());\n        if exponent >= Float::MAX_EXPONENT {\n            return match (sign, rm) {\n                (true, Up | Ceiling | Nearest) => (Float::INFINITY, Greater),\n                (true, Floor | Down) => (Float::max_finite_value_with_prec(prec), Less),\n                (false, Up | Floor | Nearest) => (Float::NEGATIVE_INFINITY, Less),\n                (false, Ceiling | Down) => (-Float::max_finite_value_with_prec(prec), Greater),\n                (_, Exact) => panic!(\"Inexact conversion from Rational to Float\"),\n            };\n        }\n        let (significand, o) =\n            Integer::rounding_from(x << (i128::exact_from(prec) - i128::from(exponent) - 1), rm);\n        let sign = significand >= 0;\n        let mut significand = significand.unsigned_abs();\n        let away_from_0 = if sign { Greater } else { Less };\n        if o == away_from_0 && significand.is_power_of_2() {\n            exponent += 1;\n            if exponent >= Float::MAX_EXPONENT {\n                return if sign {\n                    (Float::INFINITY, Greater)\n                } else {\n                    (Float::NEGATIVE_INFINITY, Less)\n                };\n            }\n        }\n        exponent += 1;\n        if exponent < Float::MIN_EXPONENT {\n            assert!(rm != Exact, \"Inexact conversion from Rational to Float\");\n            return if rm == Nearest\n                && exponent == Float::MIN_EXPONENT - 1\n                && (o == away_from_0.reverse() || !significand.is_power_of_2())\n            {\n                if sign {\n                    (Float::min_positive_value_prec(prec), Greater)\n                } else {\n                    (-Float::min_positive_value_prec(prec), Less)\n                }\n            } else {\n                match (sign, rm) {\n                    (true, Up | Ceiling) => (Float::min_positive_value_prec(prec), Greater),\n                    (true, Floor | Down | Nearest) => (Float::ZERO, Less),\n                    (false, Up | Floor) => (-Float::min_positive_value_prec(prec), Less),\n                    (false, Ceiling | Down | Nearest) => (Float::NEGATIVE_ZERO, Greater),\n                    (_, Exact) => unreachable!(),\n                }\n            };\n        }\n        significand <<= significand\n            .significant_bits()\n            .neg_mod_power_of_2(Limb::LOG_WIDTH);\n        let target_bits = prec\n            .round_to_multiple_of_power_of_2(Limb::LOG_WIDTH, Ceiling)\n            .0;\n        let current_bits = significand_bits(&significand);\n        if current_bits > target_bits {\n            significand >>= current_bits - target_bits;\n        }\n        (\n            Float(Finite {\n                sign,\n                exponent,\n                precision: prec,\n                significand,\n            }),\n            o,\n        )\n    }\n}}\n\npub_test! {from_rational_prec_round_ref_using_div(\n    x: &Rational,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Float, Ordering) {\n    let sign = *x >= 0;\n    if !sign {\n        rm.neg_assign();\n    }\n    let (n, d) = x.numerator_and_denominator_ref();\n    let is_zero = *n == 0;\n    let (f, o) = match (\n        if is_zero {\n            None\n        } else {\n            n.checked_log_base_2()\n        },\n        d.checked_log_base_2(),\n    ) {\n        (Some(log_n), Some(log_d)) => Float::power_of_2_prec_round(\n            i64::saturating_from(i128::from(log_n) - i128::from(log_d)),\n            prec,\n            rm,\n        ),\n        (None, Some(log_d)) => {\n            let (mut f, mut o) = from_natural_prec_round_zero_exponent_ref(n, prec, rm);\n            o = f.shr_prec_round_assign_helper(\n                i128::from(log_d) - i128::from(n.significant_bits()),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n        (Some(log_n), None) => {\n            let (mut f, mut o) =\n                from_natural_zero_exponent_ref(d).reciprocal_prec_round(prec, rm);\n            o = f.shl_prec_round_assign_helper(\n                i128::from(log_n) - i128::from(d.significant_bits()),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n        (None, None) => {\n            let (mut f, mut o) = from_natural_zero_exponent_ref(n).div_prec_round(\n                from_natural_zero_exponent_ref(d),\n                prec,\n                rm,\n            );\n            o = f.shl_prec_round_assign_helper(\n                i128::from(n.significant_bits()) - i128::from(d.significant_bits()),\n                prec,\n                rm,\n                o,\n            );\n            (f, o)\n        }\n    };\n    if sign {\n        (f, o)\n    } else {\n        (-f, o.reverse())\n    }\n}}\n\npub(crate) const FROM_RATIONAL_THRESHOLD: u64 = 100;\n\nimpl Float {\n    /// Converts a [`Rational`] to a [`Float`], taking the [`Rational`] by value. If the [`Float`]\n    /// is nonzero, it has the specified precision. If rounding is needed, the specified rounding\n    /// mode is used. An [`Ordering`] is also returned, indicating whether the returned value is\n    /// less than, equal to, or greater than the original value.\n    ///\n    /// If you're only using [`Nearest`], try using [`Float::from_rational_prec`] instead.\n    ///\n    /// - If the [`Rational`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds down\n    ///   to $(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    /// - If the [`Rational`] rounds to a value less than or equal to $-2^{2^{30}-1}$), this\n    ///   function overflows to $-\\infty$ if `rm` is `Floor`, `Up`, or `Nearest`, and rounds up to\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    /// - If the [`Rational`] rounds to a positive value less than $2^{-2^{30}}$), this function\n    ///   underflows to positive zero if `rm` is `Floor` or `Down`, rounds up to $2^{-2^{30}}$ if\n    ///   `rm` is `Ceiling` or `Up`, underflows to positive zero if `rm` is `Nearest` and the\n    ///   [`Rational`] rounds to a value less than or equal to $2^{-2^{30}-1}$, and rounds up to\n    ///   $2^{-2^{30}}$ if `rm` is `Nearest` and the [`Rational`] rounds to a value greater than\n    ///   $2^{-2^{30}-1}$.\n    /// - If the [`Rational`] rounds to a negative value greater than $-2^{-2^{30}}$), this function\n    ///   underflows to negative zero if `rm` is `Ceiling` or `Down`, rounds down to $-2^{-2^{30}}$\n    ///   if `rm` is `Floor` or `Up`, underflows to negative zero if `rm` is `Nearest` and the\n    ///   [`Rational`] rounds to a value greater than or equal to $-2^{-2^{30}-1}$, and rounds down\n    ///   to $-2^{-2^{30}}$ if `rm` is `Nearest` and the [`Rational`] rounds to a value less than\n    ///   $-2^{-2^{30}-1}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(n.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the `Rational` cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_rational_prec_round(Rational::from_signeds(1, 3), 10, Floor);\n    /// assert_eq!(x.to_string(), \"0.333\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_rational_prec_round(Rational::from_signeds(1, 3), 10, Ceiling);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec_round(Rational::from_signeds(1, 3), 10, Nearest);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec_round(Rational::from_signeds(-1, 3), 10, Floor);\n    /// assert_eq!(x.to_string(), \"-0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_rational_prec_round(Rational::from_signeds(-1, 3), 10, Ceiling);\n    /// assert_eq!(x.to_string(), \"-0.333\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec_round(Rational::from_signeds(-1, 3), 10, Nearest);\n    /// assert_eq!(x.to_string(), \"-0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn from_rational_prec_round(x: Rational, prec: u64, rm: RoundingMode) -> (Self, Ordering) {\n        if max(x.significant_bits(), prec) < FROM_RATIONAL_THRESHOLD {\n            from_rational_prec_round_direct(x, prec, rm)\n        } else {\n            from_rational_prec_round_using_div(x, prec, rm)\n        }\n    }\n\n    /// Converts a [`Rational`] to a [`Float`], taking the [`Rational`] by value. If the [`Float`]\n    /// is nonzero, it has the specified precision. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// If the [`Rational`] is dyadic (its denominator is a power of 2), then you can convert it to\n    /// a [`Float`] using `try_from` instead. The precision of the resulting [`Float`] will be the\n    /// number of significant bits of the [`Rational`]'s numerator.\n    ///\n    /// Rounding may occur, in which case [`Nearest`] is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_rational_prec_round`].\n    ///\n    /// - If the [`Rational`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$.\n    /// - If the [`Rational`] rounds to a value less than or equal to $-2^{2^{30}-1}$), this\n    ///   function overflows to $-\\infty$.\n    /// - If the [`Rational`] rounds to a positive value less than $2^{-2^{30}}$), this function\n    ///   underflows to positive zero if the [`Rational`] rounds to a value less than or equal to\n    ///   $2^{-2^{30}-1}$ and rounds up to $2^{-2^{30}}$ if the [`Rational`] rounds to a value\n    ///   greater than $2^{-2^{30}-1}$.\n    /// - If the [`Rational`] rounds to a negative value greater than $2^{-2^{30}}$), this function\n    ///   underflows to negative zero if the [`Rational`] rounds to a value greater than or equal to\n    ///   $-2^{-2^{30}-1}$ and rounds down to $-2^{-2^{30}}$ if the [`Rational`] rounds to a value\n    ///   less than $-2^{-2^{30}-1}$.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(), prec)`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_rational_prec(Rational::ZERO, 10);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_rational_prec(Rational::from_signeds(1, 3), 10);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec(Rational::from_signeds(1, 3), 100);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333333333333333335\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec(Rational::from_signeds(-1, 3), 10);\n    /// assert_eq!(x.to_string(), \"-0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_rational_prec(Rational::from_signeds(-1, 3), 100);\n    /// assert_eq!(x.to_string(), \"-0.3333333333333333333333333333335\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn from_rational_prec(x: Rational, prec: u64) -> (Self, Ordering) {\n        Self::from_rational_prec_round(x, prec, Nearest)\n    }\n\n    /// Converts a [`Rational`] to a [`Float`], taking the [`Rational`] by reference. If the\n    /// [`Float`] is nonzero, it has the specified precision. If rounding is needed, the specified\n    /// rounding mode is used. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// If you're only using [`Nearest`], try using [`Float::from_rational_prec_ref`] instead.\n    ///\n    /// - If the [`Rational`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$ if `rm` is `Ceiling`, `Up`, or `Nearest`, and rounds down\n    ///   to $(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    /// - If the [`Rational`] rounds to a value less than or equal to $-2^{2^{30}-1}$), this\n    ///   function overflows to $-\\infty$ if `rm` is `Floor`, `Up`, or `Nearest`, and rounds up to\n    ///   $-(1-(1/2)^p)2^{2^{30}-1}$ otherwise, where $p$ is `prec`.\n    /// - If the [`Rational`] rounds to a positive value less than $2^{-2^{30}}$), this function\n    ///   underflows to positive zero if `rm` is `Floor` or `Down`, rounds up to $2^{-2^{30}}$ if\n    ///   `rm` is `Ceiling` or `Up`, underflows to positive zero if `rm` is `Nearest` and the\n    ///   [`Rational`] rounds to a value less than or equal to $2^{-2^{30}-1}$, and rounds up to\n    ///   $2^{-2^{30}}$ if `rm` is `Nearest` and the [`Rational`] rounds to a value greater than\n    ///   $2^{-2^{30}-1}$.\n    /// - If the [`Rational`] rounds to a negative value greater than $-2^{-2^{30}}$), this function\n    ///   underflows to negative zero if `rm` is `Ceiling` or `Down`, rounds down to $-2^{-2^{30}}$\n    ///   if `rm` is `Floor` or `Up`, underflows to negative zero if `rm` is `Nearest` and the\n    ///   [`Rational`] rounds to a value greater than or equal to $-2^{-2^{30}-1}$, and rounds down\n    ///   to $-2^{-2^{30}}$ if `rm` is `Nearest` and the [`Rational`] rounds to a value less than\n    ///   $-2^{-2^{30}-1}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero, or if `rm` is exact and the `Rational` cannot be exactly\n    /// represented with the specified precision.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_rational_prec_round_ref(&Rational::from_signeds(1, 3), 10, Floor);\n    /// assert_eq!(x.to_string(), \"0.333\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) =\n    ///     Float::from_rational_prec_round_ref(&Rational::from_signeds(1, 3), 10, Ceiling);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) =\n    ///     Float::from_rational_prec_round_ref(&Rational::from_signeds(1, 3), 10, Nearest);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec_round_ref(&Rational::from_signeds(-1, 3), 10, Floor);\n    /// assert_eq!(x.to_string(), \"-0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) =\n    ///     Float::from_rational_prec_round_ref(&Rational::from_signeds(-1, 3), 10, Ceiling);\n    /// assert_eq!(x.to_string(), \"-0.333\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) =\n    ///     Float::from_rational_prec_round_ref(&Rational::from_signeds(-1, 3), 10, Nearest);\n    /// assert_eq!(x.to_string(), \"-0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn from_rational_prec_round_ref(\n        x: &Rational,\n        prec: u64,\n        rm: RoundingMode,\n    ) -> (Self, Ordering) {\n        if max(x.significant_bits(), prec) < FROM_RATIONAL_THRESHOLD {\n            from_rational_prec_round_ref_direct(x, prec, rm)\n        } else {\n            from_rational_prec_round_ref_using_div(x, prec, rm)\n        }\n    }\n\n    /// Converts a [`Rational`] to a [`Float`], taking the [`Rational`] by reference. If the\n    /// [`Float`] is nonzero, it has the specified precision. An [`Ordering`] is also returned,\n    /// indicating whether the returned value is less than, equal to, or greater than the original\n    /// value.\n    ///\n    /// If the [`Rational`] is dyadic (its denominator is a power of 2), then you can convert it to\n    /// a [`Float`] using `try_from` instead. The precision of the resulting [`Float`] will be the\n    /// number of significant bits of the [`Rational`]'s numerator.\n    ///\n    /// Rounding may occur, in which case [`Nearest`] is used by default. To specify a rounding mode\n    /// as well as a precision, try [`Float::from_rational_prec_round_ref`].\n    ///\n    /// - If the [`Rational`] rounds to a value greater than or equal to $2^{2^{30}-1}$), this\n    ///   function overflows to $\\infty$.\n    /// - If the [`Rational`] rounds to a value less than or equal to $-2^{2^{30}-1}$), this\n    ///   function overflows to $-\\infty$.\n    /// - If the [`Rational`] rounds to a positive value less than $2^{-2^{30}}$), this function\n    ///   underflows to positive zero if the [`Rational`] rounds to a value less than or equal to\n    ///   $2^{-2^{30}-1}$ and rounds up to $2^{-2^{30}}$ if the [`Rational`] rounds to a value\n    ///   greater than $2^{-2^{30}-1}$.\n    /// - If the [`Rational`] rounds to a negative value greater than $2^{-2^{30}}$), this function\n    ///   underflows to negative zero if the [`Rational`] rounds to a value greater than or equal to\n    ///   $-2^{-2^{30}-1}$ and rounds down to $-2^{-2^{30}}$ if the [`Rational`] rounds to a value\n    ///   less than $-2^{-2^{30}-1}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(), prec)`.\n    ///\n    /// # Panics\n    /// Panics if `prec` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let (x, o) = Float::from_rational_prec_ref(&Rational::ZERO, 10);\n    /// assert_eq!(x.to_string(), \"0.0\");\n    /// assert_eq!(o, Equal);\n    ///\n    /// let (x, o) = Float::from_rational_prec_ref(&Rational::from_signeds(1, 3), 10);\n    /// assert_eq!(x.to_string(), \"0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec_ref(&Rational::from_signeds(1, 3), 100);\n    /// assert_eq!(x.to_string(), \"0.3333333333333333333333333333335\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Greater);\n    ///\n    /// let (x, o) = Float::from_rational_prec_ref(&Rational::from_signeds(-1, 3), 10);\n    /// assert_eq!(x.to_string(), \"-0.3335\");\n    /// assert_eq!(x.get_prec(), Some(10));\n    /// assert_eq!(o, Less);\n    ///\n    /// let (x, o) = Float::from_rational_prec_ref(&Rational::from_signeds(-1, 3), 100);\n    /// assert_eq!(x.to_string(), \"-0.3333333333333333333333333333335\");\n    /// assert_eq!(x.get_prec(), Some(100));\n    /// assert_eq!(o, Less);\n    /// ```\n    #[inline]\n    pub fn from_rational_prec_ref(x: &Rational, prec: u64) -> (Self, Ordering) {\n        Self::from_rational_prec_round_ref(x, prec, Nearest)\n    }\n}\n\nimpl TryFrom<Rational> for Float {\n    type Error = FloatConversionError;\n\n    /// Converts a [`Rational`] to an [`Float`], taking the [`Rational`] by value. If the\n    /// [`Rational`]'s denominator is not a power of 2, or if the [`Rational`] is too far from zero\n    /// or too close to zero to be represented as a [`Float`], an error is returned.\n    ///\n    /// The [`Float`]'s precision is the minimum number of bits needed to exactly represent the\n    /// [`Rational`].\n    ///\n    /// - If the [`Rational`] is greater than or equal to $2^{2^{30}-1}$), this function returns an\n    ///   overflow error.\n    /// - If the [`Rational`] is less than or equal to $-2^{2^{30}-1}$), this function returns an\n    ///   overflow error.\n    /// - If the [`Rational`] is positive and less than $2^{-2^{30}}$), this function returns an\n    ///   underflow error.\n    /// - If the [`Rational`] is negative and greater than $-2^{-2^{30}}$), this function returns an\n    ///   underflow error.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Float::try_from(Rational::ZERO).unwrap(), 0);\n    /// assert_eq!(\n    ///     Float::try_from(Rational::from_signeds(1, 8)).unwrap(),\n    ///     0.125\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Rational::from_signeds(-1, 8)).unwrap(),\n    ///     -0.125\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Float::try_from(Rational::from_signeds(1, 3)),\n    ///     Err(FloatConversionError::Inexact)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(Rational::from_signeds(-1, 3)),\n    ///     Err(FloatConversionError::Inexact)\n    /// );\n    /// ```\n    fn try_from(x: Rational) -> Result<Self, Self::Error> {\n        if x == 0u32 {\n            return Ok(Self::ZERO);\n        }\n        if let Some(log_denominator) = x.denominator_ref().checked_log_base_2() {\n            let exponent = i32::saturating_from(x.floor_log_base_2_abs()).saturating_add(1);\n            if exponent > Self::MAX_EXPONENT {\n                return Err(FloatConversionError::Overflow);\n            } else if exponent < Self::MIN_EXPONENT {\n                return Err(FloatConversionError::Underflow);\n            }\n            let n = Integer::from_sign_and_abs(x >= 0u32, x.into_numerator());\n            let n_bits = n.significant_bits();\n            Ok(from_integer_zero_exponent(n) >> (i128::from(log_denominator) - i128::from(n_bits)))\n        } else {\n            Err(FloatConversionError::Inexact)\n        }\n    }\n}\n\nimpl TryFrom<&Rational> for Float {\n    type Error = FloatConversionError;\n\n    /// Converts a [`Rational`] to an [`Float`], taking the [`Rational`] by reference. If the\n    /// [`Rational`]'s denominator is not a power of 2, or if the [`Rational`] is too far from zero\n    /// or too close to zero to be represented as a [`Float`], an error is returned.\n    ///\n    /// The [`Float`]'s precision is the minimum number of bits needed to exactly represent the\n    /// [`Rational`].\n    ///\n    /// - If the [`Rational`] is greater than or equal to $2^{2^{30}-1}$), this function returns an\n    ///   overflow error.\n    /// - If the [`Rational`] is less than or equal to $-2^{2^{30}-1}$), this function returns an\n    ///   overflow error.\n    /// - If the [`Rational`] is positive and less than $2^{-2^{30}}$), this function returns an\n    ///   underflow error.\n    /// - If the [`Rational`] is negative and greater than $-2^{-2^{30}}$), this function returns an\n    ///   underflow error.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_float::Float;\n    /// use malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Float::try_from(&Rational::ZERO).unwrap(), 0);\n    /// assert_eq!(\n    ///     Float::try_from(&Rational::from_signeds(1, 8)).unwrap(),\n    ///     0.125\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Rational::from_signeds(-1, 8)).unwrap(),\n    ///     -0.125\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Float::try_from(&Rational::from_signeds(1, 3)),\n    ///     Err(FloatConversionError::Inexact)\n    /// );\n    /// assert_eq!(\n    ///     Float::try_from(&Rational::from_signeds(-1, 3)),\n    ///     Err(FloatConversionError::Inexact)\n    /// );\n    /// ```\n    fn try_from(x: &Rational) -> Result<Self, Self::Error> {\n        if *x == 0u32 {\n            return Ok(Self::ZERO);\n        }\n        if let Some(log_denominator) = x.denominator_ref().checked_log_base_2() {\n            let exponent = i32::saturating_from(x.floor_log_base_2_abs()).saturating_add(1);\n            if exponent > Self::MAX_EXPONENT {\n                return Err(FloatConversionError::Overflow);\n            } else if exponent < Self::MIN_EXPONENT {\n                return Err(FloatConversionError::Underflow);\n            }\n            let n = x.numerator_ref();\n            let n_bits = n.significant_bits();\n            let mut n = from_natural_zero_exponent_ref(n);\n            if *x < 0 {\n                n.neg_assign();\n            }\n            Ok(n >> (i128::from(log_denominator) - i128::from(n_bits)))\n        } else {\n            Err(FloatConversionError::Inexact)\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Rational> for Float {\n    /// Determines whether a [`Rational`] can be converted to an [`Float`], taking the [`Rational`]\n    /// by reference.\n    ///\n    /// The [`Rational`]s that are convertible to [`Float`]s are precisely those whose denominators\n    /// are powers of two, and would not overflow or underflow.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Float::convertible_from(&Rational::ZERO), true);\n    /// assert_eq!(Float::convertible_from(&Rational::from_signeds(3, 8)), true);\n    /// assert_eq!(\n    ///     Float::convertible_from(&Rational::from_signeds(-3, 8)),\n    ///     true\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Float::convertible_from(&Rational::from_signeds(1, 3)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Float::convertible_from(&Rational::from_signeds(-1, 3)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn convertible_from(x: &Rational) -> bool {\n        *x == 0\n            || x.denominator_ref().is_power_of_2()\n                && (Self::MIN_EXPONENT..=Self::MAX_EXPONENT)\n                    .contains(&i32::saturating_from(x.floor_log_base_2_abs()).saturating_add(1))\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/integer_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Zero};\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, ShrRound};\nuse malachite_base::num::basic::traits::{One, Zero as ZeroTrait};\nuse malachite_base::num::conversion::from::SignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nimpl RoundingFrom<Float> for Integer {\n    /// Converts a [`Float`] to an [`Integer`], using a specified [`RoundingMode`] and taking the\n    /// [`Float`] by value. An [`Ordering`] is also returned, indicating whether the returned value\n    /// is less than, equal to, or greater than the original value.\n    ///\n    /// If the [`Float`] is NaN or infinite, the function will panic regardless of the rounding\n    /// mode.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`] is NaN or\n    /// infinite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(Float::from(1.5), Floor).to_debug_string(),\n    ///     \"(1, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Float::from(1.5), Ceiling).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Float::from(1.5), Nearest).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(Float::from(-1.5), Floor).to_debug_string(),\n    ///     \"(-2, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Float::from(-1.5), Ceiling).to_debug_string(),\n    ///     \"(-1, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Float::from(-1.5), Nearest).to_debug_string(),\n    ///     \"(-2, Less)\"\n    /// );\n    /// ```\n    fn rounding_from(f: Float, rm: RoundingMode) -> (Self, Ordering) {\n        match f {\n            float_either_zero!() => (Self::ZERO, Equal),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                let abs_rm = if sign { rm } else { -rm };\n                let (abs_i, abs_o) = if exponent < 0 {\n                    match abs_rm {\n                        Floor | Down | Nearest => (Natural::ZERO, Less),\n                        Ceiling | Up => (Natural::ONE, Greater),\n                        Exact => {\n                            panic!(\"Cannot convert Float to Integer using {rm}\")\n                        }\n                    }\n                } else {\n                    let sb = significand_bits(&significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    if sb >= eb {\n                        significand.shr_round(sb - eb, abs_rm)\n                    } else {\n                        (significand << (eb - sb), Equal)\n                    }\n                };\n                if sign {\n                    (Self::from(abs_i), abs_o)\n                } else {\n                    (-abs_i, abs_o.reverse())\n                }\n            }\n            _ => panic!(\"Can't convert {f} to Integer using {rm}\"),\n        }\n    }\n}\n\nimpl RoundingFrom<&Float> for Integer {\n    /// Converts a [`Float`] to an [`Integer`], using a specified [`RoundingMode`] and taking the\n    /// [`Float`] by reference. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// If the [`Float`] is NaN or infinite, the function will panic regardless of the rounding\n    /// mode.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`] is NaN or\n    /// infinite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Float::from(1.5), Floor).to_debug_string(),\n    ///     \"(1, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Float::from(1.5), Ceiling).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Float::from(1.5), Nearest).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Float::from(-1.5), Floor).to_debug_string(),\n    ///     \"(-2, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Float::from(-1.5), Ceiling).to_debug_string(),\n    ///     \"(-1, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Float::from(-1.5), Nearest).to_debug_string(),\n    ///     \"(-2, Less)\"\n    /// );\n    /// ```\n    fn rounding_from(f: &Float, rm: RoundingMode) -> (Self, Ordering) {\n        match f {\n            float_either_zero!() => (Self::ZERO, Equal),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                if *significand == 0u32 {\n                    (Self::ZERO, Equal)\n                } else {\n                    let abs_rm = if *sign { rm } else { -rm };\n                    let (abs_i, abs_o) = if *exponent < 0 {\n                        match abs_rm {\n                            Floor | Down | Nearest => (Natural::ZERO, Less),\n                            Ceiling | Up => (Natural::ONE, Greater),\n                            Exact => {\n                                panic!(\"Cannot convert Float to Integer using {rm}\")\n                            }\n                        }\n                    } else {\n                        let sb = significand_bits(significand);\n                        let eb = u64::from(exponent.unsigned_abs());\n                        if sb >= eb {\n                            significand.shr_round(sb - eb, abs_rm)\n                        } else {\n                            (significand << (eb - sb), Equal)\n                        }\n                    };\n                    if *sign {\n                        (Self::from(abs_i), abs_o)\n                    } else {\n                        (-abs_i, abs_o.reverse())\n                    }\n                }\n            }\n            _ => panic!(\"Can't convert {f} to Integer using {rm}\"),\n        }\n    }\n}\n\nimpl TryFrom<Float> for Integer {\n    type Error = SignedFromFloatError;\n\n    /// Converts a [`Float`] to an [`Integer`], taking the [`Float`] by value. If the [`Float`] is\n    /// not equal to an integer, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_base::num::conversion::from::SignedFromFloatError::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::try_from(Float::ZERO).unwrap(), 0);\n    /// assert_eq!(Integer::try_from(Float::from(123.0)).unwrap(), 123);\n    /// assert_eq!(Integer::try_from(Float::from(-123.0)).unwrap(), -123);\n    ///\n    /// assert_eq!(\n    ///     Integer::try_from(Float::from(1.5)),\n    ///     Err(FloatNonIntegerOrOutOfRange)\n    /// );\n    /// assert_eq!(Integer::try_from(Float::INFINITY), Err(FloatInfiniteOrNan));\n    /// assert_eq!(Integer::try_from(Float::NAN), Err(FloatInfiniteOrNan));\n    /// ```\n    fn try_from(f: Float) -> Result<Self, Self::Error> {\n        match f {\n            Float(Zero { .. }) => Ok(Self::ZERO),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                if exponent <= 0 {\n                    Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                } else {\n                    let sb = significand_bits(&significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    if sb >= eb {\n                        let bits = sb - eb;\n                        if significand.divisible_by_power_of_2(bits) {\n                            Ok(Self::from_sign_and_abs(sign, significand >> bits))\n                        } else {\n                            Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                        }\n                    } else {\n                        Ok(Self::from_sign_and_abs(sign, significand << (eb - sb)))\n                    }\n                }\n            }\n            _ => Err(SignedFromFloatError::FloatInfiniteOrNan),\n        }\n    }\n}\n\nimpl TryFrom<&Float> for Integer {\n    type Error = SignedFromFloatError;\n\n    /// Converts a [`Float`] to an [`Integer`], taking the [`Float`] by reference. If the [`Float`]\n    /// is not equal to an integer, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_base::num::conversion::from::SignedFromFloatError::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::try_from(&Float::ZERO).unwrap(), 0);\n    /// assert_eq!(Integer::try_from(&Float::from(123.0)).unwrap(), 123);\n    /// assert_eq!(Integer::try_from(&Float::from(-123.0)).unwrap(), -123);\n    ///\n    /// assert_eq!(\n    ///     Integer::try_from(&Float::from(1.5)),\n    ///     Err(FloatNonIntegerOrOutOfRange)\n    /// );\n    /// assert_eq!(Integer::try_from(&Float::INFINITY), Err(FloatInfiniteOrNan));\n    /// assert_eq!(Integer::try_from(&Float::NAN), Err(FloatInfiniteOrNan));\n    /// ```\n    fn try_from(f: &Float) -> Result<Self, Self::Error> {\n        match f {\n            Float(Zero { .. }) => Ok(Self::ZERO),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                if *exponent <= 0 {\n                    Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                } else {\n                    let sb = significand_bits(significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    if sb >= eb {\n                        let bits = sb - eb;\n                        if significand.divisible_by_power_of_2(bits) {\n                            Ok(Self::from_sign_and_abs(*sign, significand >> bits))\n                        } else {\n                            Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                        }\n                    } else {\n                        Ok(Self::from_sign_and_abs(*sign, significand << (eb - sb)))\n                    }\n                }\n            }\n            _ => Err(SignedFromFloatError::FloatInfiniteOrNan),\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Float> for Integer {\n    /// Determines whether a [`Float`] can be converted to an [`Integer`], taking the [`Float`] by\n    /// reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_float::Float;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::convertible_from(&Float::ZERO), true);\n    /// assert_eq!(Integer::convertible_from(&Float::from(123.0)), true);\n    /// assert_eq!(Integer::convertible_from(&Float::from(-123.0)), true);\n    ///\n    /// assert_eq!(Integer::convertible_from(&Float::from(1.5)), false);\n    /// assert_eq!(Integer::convertible_from(&Float::INFINITY), false);\n    /// assert_eq!(Integer::convertible_from(&Float::NAN), false);\n    /// ```\n    fn convertible_from(f: &Float) -> bool {\n        match f {\n            Float(Zero { .. }) => true,\n            Float(Finite {\n                exponent,\n                significand,\n                ..\n            }) => {\n                *significand == 0u32\n                    || *exponent > 0 && {\n                        let sb = significand_bits(significand);\n                        let eb = u64::from(exponent.unsigned_abs());\n                        sb < eb || significand.divisible_by_power_of_2(sb - eb)\n                    }\n            }\n            _ => false,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, IsInteger};\nuse malachite_nz::integer::Integer;\n\nimpl IsInteger for &Float {\n    /// Determines whether a [`Float`] is an integer.\n    ///\n    /// $f(x) = x \\in \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, OneHalf, Zero};\n    /// use malachite_base::num::conversion::traits::IsInteger;\n    /// use malachite_float::Float;\n    ///\n    /// assert_eq!(Float::ZERO.is_integer(), true);\n    /// assert_eq!(Float::ONE.is_integer(), true);\n    /// assert_eq!(Float::from(100).is_integer(), true);\n    /// assert_eq!(Float::from(-100).is_integer(), true);\n    /// assert_eq!(Float::ONE_HALF.is_integer(), false);\n    /// assert_eq!((-Float::ONE_HALF).is_integer(), false);\n    /// ```\n    #[inline]\n    fn is_integer(self) -> bool {\n        Integer::convertible_from(self)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse core::cmp::{\n    Ordering::{self, *},\n    min,\n};\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, IntegerMantissaAndExponent, RawMantissaAndExponent, SciMantissaAndExponent,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\nimpl Float {\n    /// Returns a [`Float`]'s scientific mantissa and exponent, rounding according to the specified\n    /// rounding mode. An [`Ordering`] is also returned, indicating whether the mantissa and\n    /// exponent represent a value that is less than, equal to, or greater than the original value.\n    ///\n    /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is\n    /// a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa as a float. The\n    /// conversion might not be exact, so we round to the nearest float using the provided rounding\n    /// mode. If the rounding mode is `Exact` but the conversion is not exact, `None` is returned.\n    /// $$\n    /// f(x, r) \\approx \\left (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}},\n    ///     \\lfloor \\log_2 x \\rfloor\\right ).\n    /// $$\n    ///\n    /// This function does not overflow or underflow. The returned exponent is always in the range\n    /// $[-2^{30}, 2^{30}-1]$. Notice that although a [`Float`]'s maximum scientific exponent is\n    /// $2^{30}-2$, this function may return an exponent one larger than this limit due to rounding.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::num::float::NiceFloat;\n    /// use malachite_base::rounding_modes::RoundingMode::{self, *};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use std::cmp::Ordering::{self, *};\n    ///\n    /// let test = |x: Float, rm: RoundingMode, out: Option<(f32, i32, Ordering)>| {\n    ///     assert_eq!(\n    ///         x.sci_mantissa_and_exponent_round(rm)\n    ///             .map(|(m, e, o)| (NiceFloat(m), e, o)),\n    ///         out.map(|(m, e, o)| (NiceFloat(m), e, o))\n    ///     );\n    /// };\n    /// test(Float::from(3u32), Floor, Some((1.5, 1, Equal)));\n    /// test(Float::from(3u32), Down, Some((1.5, 1, Equal)));\n    /// test(Float::from(3u32), Ceiling, Some((1.5, 1, Equal)));\n    /// test(Float::from(3u32), Up, Some((1.5, 1, Equal)));\n    /// test(Float::from(3u32), Nearest, Some((1.5, 1, Equal)));\n    /// test(Float::from(3u32), Exact, Some((1.5, 1, Equal)));\n    ///\n    /// let x = Float::from(std::f64::consts::PI);\n    /// test(x.clone(), Floor, Some((1.5707963, 1, Less)));\n    /// test(x.clone(), Down, Some((1.5707963, 1, Less)));\n    /// test(x.clone(), Ceiling, Some((1.5707964, 1, Greater)));\n    /// test(x.clone(), Up, Some((1.5707964, 1, Greater)));\n    /// test(x.clone(), Nearest, Some((1.5707964, 1, Greater)));\n    /// test(x.clone(), Exact, None);\n    ///\n    /// test(\n    ///     Float::from(1000000000u32),\n    ///     Nearest,\n    ///     Some((1.8626451, 29, Equal)),\n    /// );\n    /// test(\n    ///     Float::exact_from(Natural::from(10u32).pow(52)),\n    ///     Nearest,\n    ///     Some((1.670478, 172, Greater)),\n    /// );\n    ///\n    /// test(Float::exact_from(Natural::from(10u32).pow(52)), Exact, None);\n    /// ```\n    pub fn sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n        &self,\n        rm: RoundingMode,\n    ) -> Option<(T, i32, Ordering)> {\n        match self {\n            Self(Finite {\n                exponent,\n                significand,\n                ..\n            }) => significand\n                .sci_mantissa_and_exponent_round::<T>(rm)\n                .map(|(m, _, o)| {\n                    (\n                        m,\n                        if o == Greater && m == T::ONE {\n                            *exponent\n                        } else {\n                            exponent - 1\n                        },\n                        o,\n                    )\n                }),\n            _ => None,\n        }\n    }\n}\n\nimpl RawMantissaAndExponent<Natural, i32> for Float {\n    /// Returns the raw mantissa and exponent of a [`Float`], taking the [`Float`] by value.\n    ///\n    /// The raw exponent and raw mantissa are the actual bit patterns used to represent the\n    /// components of `self`. When `self` is finite and nonzero, the raw mantissa is an integer\n    /// whose number of significant bits is a multiple of the limb width, and which is equal to the\n    /// absolute value of `self` multiplied by some integer power of 2. The raw exponent is one more\n    /// than the floor of the base-2 logarithm of the absolute value of `self`.\n    ///\n    /// The inverse operation is [`Self::from_raw_mantissa_and_exponent`].\n    ///\n    /// The raw exponent is in the range $[-(2^{30}-1), 2^{30}-1]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not finite or not zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, RawMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    /// use malachite_q::Rational;\n    ///\n    /// if Limb::WIDTH == u64::WIDTH {\n    ///     let (m, e) = Float::ONE.raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"9223372036854775808\");\n    ///     assert_eq!(e, 1);\n    ///\n    ///     let (m, e) = Float::from(std::f64::consts::PI).raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"14488038916154245120\");\n    ///     assert_eq!(e, 2);\n    ///\n    ///     let (m, e) =\n    ///         Float::exact_from(Natural::from(3u32).pow(50u64)).raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"202070319366191015160784900114134073344\");\n    ///     assert_eq!(e, 80);\n    ///\n    ///     let (m, e) = Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100)\n    ///         .0\n    ///         .raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"286514342137199872022965541161805021184\");\n    ///     assert_eq!(e, -79);\n    /// }\n    /// ```\n    fn raw_mantissa_and_exponent(self) -> (Natural, i32) {\n        if let Self(Finite {\n            exponent,\n            significand,\n            ..\n        }) = self\n        {\n            (significand, exponent)\n        } else {\n            panic!()\n        }\n    }\n\n    /// Returns the raw exponent of a [`Float`], taking the [`Float`] by value.\n    ///\n    /// The raw exponent is one more than the floor of the base-2 logarithm of the absolute value of\n    /// `self`.\n    ///\n    /// The raw exponent is in the range $[-(2^{30}-1), 2^{30}-1]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not finite or not zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, RawMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Float::ONE.raw_exponent(), 1);\n    /// assert_eq!(Float::from(std::f64::consts::PI).raw_exponent(), 2);\n    /// assert_eq!(\n    ///     Float::exact_from(Natural::from(3u32).pow(50u64)).raw_exponent(),\n    ///     80\n    /// );\n    /// assert_eq!(\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100)\n    ///         .0\n    ///         .raw_exponent(),\n    ///     -79\n    /// );\n    /// ```\n    fn raw_exponent(self) -> i32 {\n        if let Self(Finite { exponent, .. }) = self {\n            exponent\n        } else {\n            panic!()\n        }\n    }\n\n    /// Constructs a [`Float`] from its raw mantissa and exponent. The resulting [`Float`] is\n    /// positive and has the smallest precision possible.\n    ///\n    /// The number of significant bits of the raw mantissa must be divisible by the limb width. The\n    /// raw exponent must be in the range $[-(2^{30}-1), 2^{30}-1]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `raw_mantissa` is zero, if its number of significant bits is not divisible by the\n    /// limb width, or if `raw_exponent` is out of range.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::conversion::traits::RawMantissaAndExponent;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// if Limb::WIDTH == u64::WIDTH {\n    ///     assert_eq!(\n    ///         Float::from_raw_mantissa_and_exponent(Natural::from(9223372036854775808u64), 1),\n    ///         1\n    ///     );\n    ///     assert_eq!(\n    ///         Float::from_raw_mantissa_and_exponent(Natural::from(14488038916154245120u64), 2),\n    ///         std::f64::consts::PI\n    ///     );\n    ///     assert_eq!(\n    ///         Float::from_raw_mantissa_and_exponent(\n    ///             Natural::from_str(\"202070319366191015160784900114134073344\").unwrap(),\n    ///             80\n    ///         ),\n    ///         Natural::from(3u32).pow(50u64)\n    ///     );\n    ///     assert_eq!(\n    ///         Float::from_raw_mantissa_and_exponent(\n    ///             Natural::from_str(\"286514342137199872022965541161805021184\").unwrap(),\n    ///             -79\n    ///         ),\n    ///         Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0\n    ///     );\n    /// }\n    /// ```\n    fn from_raw_mantissa_and_exponent(raw_mantissa: Natural, raw_exponent: i32) -> Self {\n        assert!(raw_exponent <= Self::MAX_EXPONENT);\n        assert!(raw_exponent >= Self::MIN_EXPONENT);\n        let bits = raw_mantissa.significant_bits();\n        assert_ne!(bits, 0);\n        assert!(bits.divisible_by_power_of_2(Limb::LOG_WIDTH));\n        let precision = bits - min(raw_mantissa.trailing_zeros().unwrap(), Limb::WIDTH - 1);\n        Self(Finite {\n            sign: true,\n            exponent: raw_exponent,\n            significand: raw_mantissa,\n            precision,\n        })\n    }\n}\n\nimpl RawMantissaAndExponent<Natural, i32, Float> for &Float {\n    /// Returns the raw mantissa and exponent of a [`Float`], taking the [`Float`] by reference.\n    ///\n    /// The raw exponent and raw mantissa are the actual bit patterns used to represent the\n    /// components of `self`. When `self` is finite and nonzero, the raw mantissa is an integer\n    /// whose number of significant bits is a multiple of the limb width, and which is equal to the\n    /// absolute value of `self` multiplied by some integer power of 2. The raw exponent is one more\n    /// than the floor of the base-2 logarithm of the absolute value of `self`.\n    ///\n    /// The raw exponent is in the range $[-(2^{30}-1), 2^{30}-1]$.\n    ///\n    /// The inverse operation is [`Float::from_raw_mantissa_and_exponent`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not finite or not zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, RawMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    /// use malachite_q::Rational;\n    ///\n    /// if Limb::WIDTH == u64::WIDTH {\n    ///     let (m, e) = (&Float::ONE).raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"9223372036854775808\");\n    ///     assert_eq!(e, 1);\n    ///\n    ///     let (m, e) = (&Float::from(std::f64::consts::PI)).raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"14488038916154245120\");\n    ///     assert_eq!(e, 2);\n    ///\n    ///     let (m, e) =\n    ///         (&Float::exact_from(Natural::from(3u32).pow(50u64))).raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"202070319366191015160784900114134073344\");\n    ///     assert_eq!(e, 80);\n    ///\n    ///     let (m, e) = (&Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0)\n    ///         .raw_mantissa_and_exponent();\n    ///     assert_eq!(m.to_string(), \"286514342137199872022965541161805021184\");\n    ///     assert_eq!(e, -79);\n    /// }\n    /// ```\n    fn raw_mantissa_and_exponent(self) -> (Natural, i32) {\n        if let Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) = self\n        {\n            (significand.clone(), *exponent)\n        } else {\n            panic!()\n        }\n    }\n\n    /// Returns the raw exponent of a [`Float`], taking the [`Float`] by reference.\n    ///\n    /// The raw exponent is one more than the floor of the base-2 logarithm of the absolute value of\n    /// `self`.\n    ///\n    /// The raw exponent is in the range $[-(2^{30}-1), 2^{30}-1]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not finite or not zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, RawMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Float::ONE).raw_exponent(), 1);\n    /// assert_eq!((&Float::from(std::f64::consts::PI)).raw_exponent(), 2);\n    /// assert_eq!(\n    ///     (&Float::exact_from(Natural::from(3u32).pow(50u64))).raw_exponent(),\n    ///     80\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0).raw_exponent(),\n    ///     -79\n    /// );\n    /// ```\n    fn raw_exponent(self) -> i32 {\n        if let Float(Finite { exponent, .. }) = self {\n            *exponent\n        } else {\n            panic!()\n        }\n    }\n\n    /// Constructs a [`Float`] from its raw mantissa and exponent. The resulting [`Float`] is\n    /// positive and has the smallest precision possible.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// The number of significant bits of the raw mantissa must be divisible by the limb width. The\n    /// raw exponent must be in the range $[-(2^{30}-1), 2^{30}-1]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `raw_mantissa` is zero, if its number of significant bits is not divisible by the\n    /// limb width, or if `raw_exponent` is out of range.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::conversion::traits::RawMantissaAndExponent;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// if Limb::WIDTH == u64::WIDTH {\n    ///     assert_eq!(\n    ///         <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n    ///             Natural::from(9223372036854775808u64),\n    ///             1\n    ///         ),\n    ///         1\n    ///     );\n    ///     assert_eq!(\n    ///         <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n    ///             Natural::from(14488038916154245120u64),\n    ///             2\n    ///         ),\n    ///         std::f64::consts::PI\n    ///     );\n    ///     assert_eq!(\n    ///         <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n    ///             Natural::from_str(\"202070319366191015160784900114134073344\").unwrap(),\n    ///             80\n    ///         ),\n    ///         Natural::from(3u32).pow(50u64)\n    ///     );\n    ///     assert_eq!(\n    ///         <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n    ///             Natural::from_str(\"286514342137199872022965541161805021184\").unwrap(),\n    ///             -79\n    ///         ),\n    ///         Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0\n    ///     );\n    /// }\n    /// ```\n    #[inline]\n    fn from_raw_mantissa_and_exponent(raw_mantissa: Natural, raw_exponent: i32) -> Float {\n        Float::from_raw_mantissa_and_exponent(raw_mantissa, raw_exponent)\n    }\n}\n\nimpl IntegerMantissaAndExponent<Natural, i64> for Float {\n    /// Returns a [`Float`]'s integer mantissa and exponent, taking the [`Float`] by value.\n    ///\n    /// When $x$ is finite and nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n    /// $m_i$ is an odd integer.\n    /// $$\n    /// f(x) = (\\frac{|x|}{2^{e_i}}, e_i),\n    /// $$\n    /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n    ///\n    /// The inverse operation is\n    /// [`from_integer_mantissa_and_exponent`](IntegerMantissaAndExponent::from_integer_mantissa_and_exponent).\n    ///\n    /// The integer exponent is less than or equal to $2^{30}-2$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, IntegerMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     Float::ONE.integer_mantissa_and_exponent(),\n    ///     (Natural::ONE, 0)\n    /// );\n    /// assert_eq!(\n    ///     Float::from(std::f64::consts::PI).integer_mantissa_and_exponent(),\n    ///     (Natural::from(884279719003555u64), -48)\n    /// );\n    /// assert_eq!(\n    ///     Float::exact_from(Natural::from(3u32).pow(50u64)).integer_mantissa_and_exponent(),\n    ///     (Natural::from_str(\"717897987691852588770249\").unwrap(), 0)\n    /// );\n    /// assert_eq!(\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100)\n    ///         .0\n    ///         .integer_mantissa_and_exponent(),\n    ///     (\n    ///         Natural::from_str(\"1067349099133908271875104088939\").unwrap(),\n    ///         -179\n    ///     )\n    /// );\n    /// ```\n    fn integer_mantissa_and_exponent(self) -> (Natural, i64) {\n        if let Self(Finite {\n            exponent,\n            significand,\n            ..\n        }) = self\n        {\n            let zeros = significand.trailing_zeros().unwrap();\n            let shifted = significand >> zeros;\n            let bits = shifted.significant_bits();\n            (\n                shifted,\n                i64::exact_from(i128::from(exponent) - i128::from(bits)),\n            )\n        } else {\n            panic!()\n        }\n    }\n\n    /// Returns a [`Float`]'s integer exponent, taking the [`Float`] by value.\n    ///\n    /// When $x$ is finite and nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n    /// $m_i$ is an odd integer.\n    /// $$\n    /// f(x) = e_i,\n    /// $$\n    /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n    ///\n    /// The integer exponent is less than or equal to $2^{30}-2$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, IntegerMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Float::ONE.integer_exponent(), 0);\n    /// assert_eq!(Float::from(std::f64::consts::PI).integer_exponent(), -48);\n    /// assert_eq!(\n    ///     Float::exact_from(Natural::from(3u32).pow(50u64)).integer_exponent(),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100)\n    ///         .0\n    ///         .integer_exponent(),\n    ///     -179\n    /// );\n    /// ```\n    fn integer_exponent(self) -> i64 {\n        if let Self(Finite {\n            exponent,\n            significand,\n            ..\n        }) = self\n        {\n            i64::exact_from(\n                i128::from(exponent)\n                    - i128::from(\n                        significand.significant_bits() - significand.trailing_zeros().unwrap(),\n                    ),\n            )\n        } else {\n            panic!()\n        }\n    }\n\n    /// Constructs a [`Float`] from its integer mantissa and exponent.\n    ///\n    /// When $x$ is finite and nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n    /// $m_i$ is an odd integer.\n    ///\n    /// $$\n    /// f(x) = 2^{e_i}m_i.\n    /// $$\n    ///\n    /// The input does not have to be reduced; that is, the mantissa does not have to be odd. If the\n    /// inputs correspond to a number too large in absolute value or too close to zero to be\n    /// represented by a [`Float`], `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `integer_mantissa.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     Float::from_integer_mantissa_and_exponent(Natural::ONE, 0).unwrap(),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Float::from_integer_mantissa_and_exponent(Natural::from(884279719003555u64), -48)\n    ///         .unwrap(),\n    ///     std::f64::consts::PI\n    /// );\n    /// assert_eq!(\n    ///     Float::from_integer_mantissa_and_exponent(\n    ///         Natural::from_str(\"717897987691852588770249\").unwrap(),\n    ///         0\n    ///     )\n    ///     .unwrap(),\n    ///     Natural::from(3u32).pow(50u64)\n    /// );\n    /// assert_eq!(\n    ///     Float::from_integer_mantissa_and_exponent(\n    ///         Natural::from_str(\"1067349099133908271875104088939\").unwrap(),\n    ///         -179\n    ///     )\n    ///     .unwrap(),\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0\n    /// );\n    /// ```\n    fn from_integer_mantissa_and_exponent(\n        integer_mantissa: Natural,\n        integer_exponent: i64,\n    ) -> Option<Self> {\n        let nonzero = integer_mantissa != 0u32;\n        let x = Self::exact_from(integer_mantissa) << integer_exponent;\n        if x.is_infinite() || (nonzero && x == 0) {\n            None\n        } else {\n            Some(x)\n        }\n    }\n}\n\nimpl IntegerMantissaAndExponent<Natural, i64, Float> for &Float {\n    /// Returns a [`Float`]'s integer mantissa and exponent, taking the [`Float`] by reference.\n    ///\n    /// When $x$ is finite and nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n    /// $m_i$ is an odd integer.\n    /// $$\n    /// f(x) = (\\frac{|x|}{2^{e_i}}, e_i),\n    /// $$\n    /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n    ///\n    /// The inverse operation is\n    /// [`from_integer_mantissa_and_exponent`](IntegerMantissaAndExponent::from_integer_mantissa_and_exponent).\n    ///\n    /// The integer exponent is less than or equal to $2^{30}-2$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, IntegerMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     (&Float::ONE).integer_mantissa_and_exponent(),\n    ///     (Natural::ONE, 0)\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from(std::f64::consts::PI)).integer_mantissa_and_exponent(),\n    ///     (Natural::from(884279719003555u64), -48)\n    /// );\n    /// assert_eq!(\n    ///     (&Float::exact_from(Natural::from(3u32).pow(50u64))).integer_mantissa_and_exponent(),\n    ///     (Natural::from_str(\"717897987691852588770249\").unwrap(), 0)\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0)\n    ///         .integer_mantissa_and_exponent(),\n    ///     (\n    ///         Natural::from_str(\"1067349099133908271875104088939\").unwrap(),\n    ///         -179\n    ///     )\n    /// );\n    /// ```\n    fn integer_mantissa_and_exponent(self) -> (Natural, i64) {\n        if let Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) = self\n        {\n            let zeros = significand.trailing_zeros().unwrap();\n            let shifted = significand >> zeros;\n            let bits = shifted.significant_bits();\n            (\n                shifted,\n                i64::exact_from(i128::from(*exponent) - i128::from(bits)),\n            )\n        } else {\n            panic!()\n        }\n    }\n\n    /// Returns a [`Float`]'s integer exponent, taking the [`Float`] by reference.\n    ///\n    /// When $x$ is finite and nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n    /// $m_i$ is an odd integer.\n    /// $$\n    /// f(x) = e_i,\n    /// $$\n    /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n    ///\n    /// The integer exponent is less than or equal to $2^{30}-2$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, IntegerMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Float::ONE).integer_exponent(), 0);\n    /// assert_eq!((&Float::from(std::f64::consts::PI)).integer_exponent(), -48);\n    /// assert_eq!(\n    ///     (&Float::exact_from(Natural::from(3u32).pow(50u64))).integer_exponent(),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0)\n    ///         .integer_exponent(),\n    ///     -179\n    /// );\n    /// ```\n    fn integer_exponent(self) -> i64 {\n        if let Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) = self\n        {\n            i64::exact_from(\n                i128::from(*exponent)\n                    - i128::from(\n                        significand.significant_bits() - significand.trailing_zeros().unwrap(),\n                    ),\n            )\n        } else {\n            panic!()\n        }\n    }\n\n    /// Constructs a [`Float`] from its integer mantissa and exponent.\n    ///\n    /// When $x$ is finite and nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and\n    /// $m_i$ is an odd integer.\n    ///\n    /// $$\n    /// f(x) = 2^{e_i}m_i.\n    /// $$\n    ///\n    /// The input does not have to be reduced; that is, the mantissa does not have to be odd. If the\n    /// inputs correspond to a number too large in absolute value or too close to zero to be\n    /// represented by a [`Float`], `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `integer_mantissa.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     <&Float as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n    ///         Natural::ONE,\n    ///         0\n    ///     )\n    ///     .unwrap(),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     <&Float as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n    ///         Natural::from(884279719003555u64),\n    ///         -48\n    ///     )\n    ///     .unwrap(),\n    ///     std::f64::consts::PI\n    /// );\n    /// assert_eq!(\n    ///     <&Float as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n    ///         Natural::from_str(\"717897987691852588770249\").unwrap(),\n    ///         0\n    ///     )\n    ///     .unwrap(),\n    ///     Natural::from(3u32).pow(50u64)\n    /// );\n    /// assert_eq!(\n    ///     <&Float as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n    ///         Natural::from_str(\"1067349099133908271875104088939\").unwrap(),\n    ///         -179\n    ///     )\n    ///     .unwrap(),\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0\n    /// );\n    /// ```\n    #[inline]\n    fn from_integer_mantissa_and_exponent(\n        integer_mantissa: Natural,\n        integer_exponent: i64,\n    ) -> Option<Float> {\n        Float::from_integer_mantissa_and_exponent(integer_mantissa, integer_exponent)\n    }\n}\n\nimpl SciMantissaAndExponent<Self, i32> for Float {\n    /// Returns a [`Float`]'s scientific mantissa and exponent, taking the [`Float`] by value.\n    ///\n    /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an integer\n    /// and $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa as\n    /// a [`Float`].\n    /// $$\n    /// f(x) = (\\frac{|x|}{2^{\\lfloor \\log_2 |x| \\rfloor}}, \\lfloor \\log_2 |x| \\rfloor).\n    /// $$\n    ///\n    /// The returned exponent is always in the range $[-2^{30}, 2^{30}-2]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Float::ONE.sci_mantissa_and_exponent(), (Float::ONE, 0));\n    ///\n    /// let (m, e) = Float::from(std::f64::consts::PI).sci_mantissa_and_exponent();\n    /// assert_eq!(m.to_string(), \"1.570796326794897\");\n    /// assert_eq!(e, 1);\n    ///\n    /// let (m, e) = Float::exact_from(Natural::from(3u32).pow(50u64)).sci_mantissa_and_exponent();\n    /// assert_eq!(m.to_string(), \"1.187662594419065093441695\");\n    /// assert_eq!(e, 79);\n    ///\n    /// let (m, e) = Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100)\n    ///     .0\n    ///     .sci_mantissa_and_exponent();\n    /// assert_eq!(m.to_string(), \"1.683979953059212693885095551367\");\n    /// assert_eq!(e, -80);\n    /// ```\n    #[inline]\n    fn sci_mantissa_and_exponent(mut self) -> (Self, i32) {\n        if let Self(Finite { sign, exponent, .. }) = &mut self {\n            let old_exponent = *exponent;\n            *exponent = 1;\n            *sign = true;\n            (self, old_exponent - 1)\n        } else {\n            panic!()\n        }\n    }\n\n    /// Returns a [`Float`]'s scientific exponent, taking the [`Float`] by value.\n    ///\n    /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an integer\n    /// and $m_s$ is a rational number with $1 \\leq m_s < 2$.\n    /// $$\n    /// f(x) = \\lfloor \\log_2 |x| \\rfloor.\n    /// $$\n    ///\n    /// The returned exponent is always in the range $[-2^{30}, 2^{30}-2]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Float::ONE.sci_exponent(), 0);\n    /// assert_eq!(Float::from(std::f64::consts::PI).sci_exponent(), 1);\n    /// assert_eq!(\n    ///     Float::exact_from(Natural::from(3u32).pow(50u64)).sci_exponent(),\n    ///     79\n    /// );\n    /// assert_eq!(\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100)\n    ///         .0\n    ///         .sci_exponent(),\n    ///     -80\n    /// );\n    /// ```\n    #[inline]\n    fn sci_exponent(self) -> i32 {\n        self.raw_exponent() - 1\n    }\n\n    /// Constructs a [`Float`] from its scientific mantissa and exponent.\n    ///\n    /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an integer\n    /// and $m_s$ is a rational number with $1 \\leq m_s < 2$.\n    ///\n    /// $$\n    /// f(x) = 2^{e_i}m_i.\n    /// $$\n    ///\n    /// If the mantissa is zero or not finite, this function panics. If it is finite but not in the\n    /// interval $[1, 2)$, `None` is returned. If the inputs correspond to a number too large in\n    /// absolute value or too close to zero to be represented by a [`Float`], `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{FromStringBase, SciMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Float::from_sci_mantissa_and_exponent(Float::ONE, 0).unwrap(),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Float::from_sci_mantissa_and_exponent(\n    ///         Float::from_string_base(16, \"0x1.921fb54442d18#53\").unwrap(),\n    ///         1\n    ///     )\n    ///     .unwrap(),\n    ///     std::f64::consts::PI\n    /// );\n    /// assert_eq!(\n    ///     Float::from_sci_mantissa_and_exponent(\n    ///         Float::from_string_base(16, \"0x1.300aa7e1b65fa13bc792#80\").unwrap(),\n    ///         79\n    ///     )\n    ///     .unwrap(),\n    ///     Natural::from(3u32).pow(50u64)\n    /// );\n    /// assert_eq!(\n    ///     Float::from_sci_mantissa_and_exponent(\n    ///         Float::from_string_base(16, \"0x1.af194f6982497a23f9dc546d6#100\").unwrap(),\n    ///         -80\n    ///     )\n    ///     .unwrap(),\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0\n    /// );\n    /// ```\n    fn from_sci_mantissa_and_exponent(mut sci_mantissa: Self, sci_exponent: i32) -> Option<Self> {\n        assert!(sci_mantissa.is_finite());\n        assert!(!sci_mantissa.is_zero());\n        if sci_mantissa.is_sign_negative()\n            || (&sci_mantissa).raw_exponent() != 1\n            || !(Self::MIN_EXPONENT - 1..=Self::MAX_EXPONENT - 1).contains(&sci_exponent)\n        {\n            return None;\n        }\n        if let Self(Finite { exponent, .. }) = &mut sci_mantissa {\n            *exponent = sci_exponent + 1;\n        } else {\n            panic!()\n        }\n        Some(sci_mantissa)\n    }\n}\n\nimpl SciMantissaAndExponent<Float, i32, Float> for &Float {\n    /// Returns a [`Float`]'s scientific mantissa and exponent, taking the [`Float`] by reference.\n    ///\n    /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an integer\n    /// and $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa as\n    /// a [`Float`].\n    /// $$\n    /// f(x) = (\\frac{|x|}{2^{\\lfloor \\log_2 |x| \\rfloor}}, \\lfloor \\log_2 |x| \\rfloor).\n    /// $$\n    ///\n    /// The returned exponent is always in the range $[-2^{30}, 2^{30}-2]$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Float::ONE).sci_mantissa_and_exponent(), (Float::ONE, 0));\n    ///\n    /// let (m, e): (Float, i32) = (&Float::from(std::f64::consts::PI)).sci_mantissa_and_exponent();\n    /// assert_eq!(m.to_string(), \"1.570796326794897\");\n    /// assert_eq!(e, 1);\n    ///\n    /// let (m, e): (Float, i32) =\n    ///     (&Float::exact_from(Natural::from(3u32).pow(50u64))).sci_mantissa_and_exponent();\n    /// assert_eq!(m.to_string(), \"1.187662594419065093441695\");\n    /// assert_eq!(e, 79);\n    ///\n    /// let (m, e): (Float, i32) =\n    ///     (&Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0)\n    ///         .sci_mantissa_and_exponent();\n    /// assert_eq!(m.to_string(), \"1.683979953059212693885095551367\");\n    /// assert_eq!(e, -80);\n    /// ```\n    #[inline]\n    fn sci_mantissa_and_exponent(self) -> (Float, i32) {\n        if let Float(Finite {\n            exponent,\n            precision,\n            significand,\n            ..\n        }) = self\n        {\n            (\n                Float(Finite {\n                    sign: true,\n                    exponent: 1,\n                    precision: *precision,\n                    significand: significand.clone(),\n                }),\n                exponent - 1,\n            )\n        } else {\n            panic!()\n        }\n    }\n\n    /// Returns a [`Float`]'s scientific exponent, taking the [`Float`] by reference.\n    ///\n    /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an integer\n    /// and $m_s$ is a rational number with $1 \\leq m_s < 2$.\n    /// $$\n    /// f(x) = \\lfloor \\log_2 |x| \\rfloor.\n    /// $$\n    ///\n    /// The returned exponent is always in the range $[-2^{30}, 2^{30}-2]$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero or not finite.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::ONE),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::from(\n    ///         std::f64::consts::PI\n    ///     )),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::exact_from(\n    ///         Natural::from(3u32).pow(50u64)\n    ///     )),\n    ///     79\n    /// );\n    /// assert_eq!(\n    ///     <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(\n    ///         &Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0\n    ///     ),\n    ///     -80\n    /// );\n    /// ```\n    #[inline]\n    fn sci_exponent(self) -> i32 {\n        self.raw_exponent() - 1\n    }\n\n    /// Constructs a [`Float`] from its scientific mantissa and exponent.\n    ///\n    /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an integer\n    /// and $m_s$ is a rational number with $1 \\leq m_s < 2$.\n    ///\n    /// $$\n    /// f(x) = 2^{e_i}m_i.\n    /// $$\n    ///\n    /// If the mantissa is zero or not finite, this function panics. If it is finite but not in the\n    /// interval $[1, 2)$, this function returns `None`.\n    ///\n    /// If the mantissa is zero or not finite, this function panics. If it is finite but not in the\n    /// interval $[1, 2)$, `None` is returned. If the inputs correspond to a number too large in\n    /// absolute value or too close to zero to be represented by a [`Float`], `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::conversion::traits::{FromStringBase, SciMantissaAndExponent};\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Float::from_sci_mantissa_and_exponent(Float::ONE, 0).unwrap(),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     <&Float as SciMantissaAndExponent<Float, _, _>>::from_sci_mantissa_and_exponent(\n    ///         Float::from_string_base(16, \"0x1.921fb54442d18#53\").unwrap(),\n    ///         1\n    ///     )\n    ///     .unwrap(),\n    ///     std::f64::consts::PI\n    /// );\n    /// assert_eq!(\n    ///     <&Float as SciMantissaAndExponent<Float, _, _>>::from_sci_mantissa_and_exponent(\n    ///         Float::from_string_base(16, \"0x1.300aa7e1b65fa13bc792#80\").unwrap(),\n    ///         79\n    ///     )\n    ///     .unwrap(),\n    ///     Natural::from(3u32).pow(50u64)\n    /// );\n    /// assert_eq!(\n    ///     <&Float as SciMantissaAndExponent<Float, _, _>>::from_sci_mantissa_and_exponent(\n    ///         Float::from_string_base(16, \"0x1.af194f6982497a23f9dc546d6#100\").unwrap(),\n    ///         -80\n    ///     )\n    ///     .unwrap(),\n    ///     Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0\n    /// );\n    /// ```\n    #[inline]\n    fn from_sci_mantissa_and_exponent(sci_mantissa: Float, sci_exponent: i32) -> Option<Float> {\n        Float::from_sci_mantissa_and_exponent(sci_mantissa, sci_exponent)\n    }\n}\n\nmacro_rules! impl_mantissa_and_exponent {\n    ($t:ident) => {\n        impl SciMantissaAndExponent<$t, i32, Float> for &Float {\n            /// Returns a [`Float`]'s scientific mantissa and exponent, taking the [`Float`] by\n            /// value.\n            ///\n            /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an\n            /// integer and $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the\n            /// rational mantissa as a primitive float. The conversion might not be exact, so we\n            /// round to the nearest float using the `Nearest` rounding mode. To use other rounding\n            /// modes, use\n            /// [`sci_mantissa_and_exponent_round`](Float::sci_mantissa_and_exponent_round).\n            /// $$\n            /// f(x) \\approx (\\frac{|x|}{2^{\\lfloor \\log_2 |x| \\rfloor}},\n            /// \\lfloor \\log_2 |x| \\rfloor).\n            /// $$\n            ///\n            /// The returned exponent is always in the range $[-2^{30}, 2^{30}-2]$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `self` is zero or not finite.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_mantissa_and_exponent).\n            #[inline]\n            fn sci_mantissa_and_exponent(self) -> ($t, i32) {\n                let (m, e, _) = self.sci_mantissa_and_exponent_round(Nearest).unwrap();\n                (m, e)\n            }\n\n            /// Constructs a [`Float`] from its scientific mantissa and exponent.\n            ///\n            /// When $x$ is finite and nonzero, we can write $|x| = 2^{e_s}m_s$, where $e_s$ is an\n            /// integer and $m_s$ is a rational number with $1 \\leq m_s < 2$.\n            ///\n            /// $$\n            /// f(x) = 2^{e_i}m_i.\n            /// $$\n            ///\n            /// If the mantissa is zero or not finite, this function panics. If it is finite but not\n            /// in the interval $[1, 2)$, `None` is returned. If the inputs correspond to a number\n            /// too large in absolute value or too close to zero to be represented by a [`Float`],\n            /// `None` is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#from_sci_mantissa_and_exponent).\n            #[allow(clippy::manual_range_contains)]\n            #[inline]\n            fn from_sci_mantissa_and_exponent(\n                sci_mantissa: $t,\n                sci_exponent: i32,\n            ) -> Option<Float> {\n                assert!(sci_mantissa.is_finite());\n                assert_ne!(sci_mantissa, 0.0);\n                if sci_mantissa < 1.0\n                    || sci_mantissa >= 2.0\n                    || sci_exponent > Float::MAX_EXPONENT - 1\n                    || sci_exponent < Float::MIN_EXPONENT - 1\n                {\n                    None\n                } else {\n                    let m = sci_mantissa.integer_mantissa();\n                    (Float::from(m)\n                        << (i128::from(sci_exponent) - i128::from(m.significant_bits()) + 1))\n                        .to_finite()\n                }\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_mantissa_and_exponent);\n"
  },
  {
    "path": "malachite-float/src/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Functions for creating a [`Float`](crate::Float) from an infinite iterator of bits.\npub mod from_bits;\n/// Implementations of the [`From`] trait for converting an\n/// [`Integer`](malachite_nz::integer::Integer) to a [`Float`](crate::Float).\npub mod from_integer;\n/// Implementations of the [`From`] trait for converting an\n/// [`Natural`](malachite_nz::natural::Natural) to a [`Float`](crate::Float).\npub mod from_natural;\n/// Various functions and implementations of the [`From`] trait for converting a primitive float to\n/// a [`Float`](crate::Float).\n///\n/// # from\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_float::Float;\n///\n/// assert_eq!(Float::from(f64::NAN).to_string(), \"NaN\");\n/// assert_eq!(Float::from(f64::INFINITY).to_string(), \"Infinity\");\n/// assert_eq!(Float::from(f64::NEGATIVE_INFINITY).to_string(), \"-Infinity\");\n/// assert_eq!(Float::from(0.0).to_string(), \"0.0\");\n/// assert_eq!(Float::from(-0.0).to_string(), \"-0.0\");\n/// assert_eq!(Float::from(123.0).to_string(), \"123.0\");\n/// assert_eq!(Float::from(-123.0).to_string(), \"-123.0\");\n/// ```\n///\n/// # from_primitive_float_prec\n/// ```\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (x, o) = Float::from_primitive_float_prec(f64::NAN, 4);\n/// assert_eq!(x.to_string(), \"NaN\");\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_primitive_float_prec(1.0 / 3.0, 4);\n/// assert_eq!(x.to_string(), \"0.34\");\n/// assert_eq!(o, Greater);\n///\n/// let (x, o) = Float::from_primitive_float_prec(123.0, 4);\n/// assert_eq!(x.to_string(), \"1.2e2\");\n/// assert_eq!(o, Less);\n/// ```\n///\n/// # from_primitive_float_prec_round\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (x, o) = Float::from_primitive_float_prec_round(f64::NAN, 4, Floor);\n/// assert_eq!(x.to_string(), \"NaN\");\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_primitive_float_prec_round(1.0 / 3.0, 4, Floor);\n/// assert_eq!(x.to_string(), \"0.31\");\n/// assert_eq!(o, Less);\n///\n/// let (x, o) = Float::from_primitive_float_prec_round(1.0 / 3.0, 4, Ceiling);\n/// assert_eq!(x.to_string(), \"0.34\");\n/// assert_eq!(o, Greater);\n///\n/// let (x, o) = Float::from_primitive_float_prec_round(1.0 / 3.0, 4, Nearest);\n/// assert_eq!(x.to_string(), \"0.34\");\n/// assert_eq!(o, Greater);\n/// ```\npub mod from_primitive_float;\n/// Various functions and implementations of the [`From`] trait for converting a primitive integer\n/// to a [`Float`](crate::Float).\n///\n/// # from\n/// ```\n/// use malachite_float::Float;\n///\n/// assert_eq!(Float::from(0u32).to_string(), \"0.0\");\n/// assert_eq!(Float::from(123u32).to_string(), \"123.0\");\n/// assert_eq!(Float::from(123u32).get_prec(), Some(7));\n///\n/// assert_eq!(Float::from(0i32).to_string(), \"0.0\");\n/// assert_eq!(Float::from(123i32).to_string(), \"123.0\");\n/// assert_eq!(Float::from(123i32).get_prec(), Some(7));\n/// assert_eq!(Float::from(-123i32).to_string(), \"-123.0\");\n/// ```\n///\n/// # from_unsigned_prec\n/// ```\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (x, o) = Float::from_unsigned_prec(0u32, 10);\n/// assert_eq!(x.to_string(), \"0.0\");\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_unsigned_prec(123u32, 20);\n/// assert_eq!(x.to_string(), \"123.0\");\n/// assert_eq!(x.get_prec(), Some(20));\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_unsigned_prec(123u32, 4);\n/// assert_eq!(x.to_string(), \"1.2e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Less);\n/// ```\n///\n/// # from_signed_prec\n/// ```\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (x, o) = Float::from_signed_prec(0i32, 10);\n/// assert_eq!(x.to_string(), \"0.0\");\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_signed_prec(123i32, 20);\n/// assert_eq!(x.to_string(), \"123.0\");\n/// assert_eq!(x.get_prec(), Some(20));\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_signed_prec(123i32, 4);\n/// assert_eq!(x.to_string(), \"1.2e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Less);\n///\n/// let (x, o) = Float::from_signed_prec(-123i32, 20);\n/// assert_eq!(x.to_string(), \"-123.0\");\n/// assert_eq!(x.get_prec(), Some(20));\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_signed_prec(-123i32, 4);\n/// assert_eq!(x.to_string(), \"-1.2e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Greater);\n/// ```\n///\n/// # from_unsigned_prec_round\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (x, o) = Float::from_unsigned_prec_round(0u32, 10, Exact);\n/// assert_eq!(x.to_string(), \"0.0\");\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_unsigned_prec_round(123u32, 20, Exact);\n/// assert_eq!(x.to_string(), \"123.0\");\n/// assert_eq!(x.get_prec(), Some(20));\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_unsigned_prec_round(123u32, 4, Floor);\n/// assert_eq!(x.to_string(), \"1.2e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Less);\n///\n/// let (x, o) = Float::from_unsigned_prec_round(123u32, 4, Ceiling);\n/// assert_eq!(x.to_string(), \"1.3e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Greater);\n/// ```\n///\n/// # from_signed_prec_round\n/// ```\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// let (x, o) = Float::from_signed_prec_round(0i32, 10, Exact);\n/// assert_eq!(x.to_string(), \"0.0\");\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_signed_prec_round(123i32, 20, Exact);\n/// assert_eq!(x.to_string(), \"123.0\");\n/// assert_eq!(x.get_prec(), Some(20));\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_signed_prec_round(123i32, 4, Floor);\n/// assert_eq!(x.to_string(), \"1.2e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Less);\n///\n/// let (x, o) = Float::from_signed_prec_round(123i32, 4, Ceiling);\n/// assert_eq!(x.to_string(), \"1.3e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Greater);\n///\n/// let (x, o) = Float::from_signed_prec_round(-123i32, 20, Exact);\n/// assert_eq!(x.to_string(), \"-123.0\");\n/// assert_eq!(x.get_prec(), Some(20));\n/// assert_eq!(o, Equal);\n///\n/// let (x, o) = Float::from_signed_prec_round(-123i32, 4, Floor);\n/// assert_eq!(x.to_string(), \"-1.3e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Less);\n///\n/// let (x, o) = Float::from_signed_prec_round(-123i32, 4, Ceiling);\n/// assert_eq!(x.to_string(), \"-1.2e2\");\n/// assert_eq!(x.get_prec(), Some(4));\n/// assert_eq!(o, Greater);\n/// ```\npub mod from_primitive_int;\n/// Implementations of the [`From`] trait for converting a [`Rational`](malachite_q::Rational) to a\n/// [`Float`](crate::Float).\npub mod from_rational;\n/// Implementations of traits for converting a [`Float`](crate::Float) to an\n/// [`Integer`](malachite_nz::integer::Integer).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\npub mod integer_from_float;\n/// An implementation of [`IsInteger`](malachite_base::num::conversion::traits::IsInteger), a trait\n/// for determining whether a number is an integer.\npub mod is_integer;\n/// Implementations of traits for converting [`Float`](crate::Float)s to and from\n/// mantissa-and-exponent representations.\n///\n/// The traits are\n/// [`RawMantissaAndExponent`](malachite_base::num::conversion::traits::RawMantissaAndExponent),\n/// [`IntegerMantissaAndExponent`](malachite_base::num::conversion::traits::IntegerMantissaAndExponent),\n/// and [`SciMantissaAndExponent`](malachite_base::num::conversion::traits::SciMantissaAndExponent).\n///\n/// Here are some examples of the macro-generated functions:\n///\n/// # sci_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::Float;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::Rational;\n///\n/// let (m, e): (f64, i32) = (&Float::ONE).sci_mantissa_and_exponent();\n/// assert_eq!(NiceFloat(m), NiceFloat(1.0));\n/// assert_eq!(e, 0);\n///\n/// let (m, e): (f64, i32) = (&Float::from(std::f64::consts::PI)).sci_mantissa_and_exponent();\n/// assert_eq!(NiceFloat(m), NiceFloat(std::f64::consts::FRAC_PI_2));\n/// assert_eq!(e, 1);\n///\n/// let (m, e): (f64, i32) =\n///     (&Float::exact_from(Natural::from(3u32).pow(50u64))).sci_mantissa_and_exponent();\n/// assert_eq!(NiceFloat(m), NiceFloat(1.187662594419065));\n/// assert_eq!(e, 79);\n///\n/// let (m, e): (f64, i32) = (&Float::from_rational_prec(Rational::from(3u32).pow(-50i64), 100).0)\n///     .sci_mantissa_and_exponent();\n/// assert_eq!(NiceFloat(m), NiceFloat(1.6839799530592128));\n/// assert_eq!(e, -80);\n/// ```\n///\n/// # from_sci_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_float::Float;\n///\n/// assert_eq!(\n///     <&Float as SciMantissaAndExponent<f64, _, _>>::from_sci_mantissa_and_exponent(1.0, 0)\n///         .unwrap()\n///         .to_string(),\n///     \"1.0\"\n/// );\n/// assert_eq!(\n///     <&Float as SciMantissaAndExponent<f64, _, _>>::from_sci_mantissa_and_exponent(\n///         std::f64::consts::FRAC_PI_2,\n///         1\n///     )\n///     .unwrap()\n///     .to_string(),\n///     \"3.141592653589793\"\n/// );\n/// assert_eq!(\n///     <&Float as SciMantissaAndExponent<f64, _, _>>::from_sci_mantissa_and_exponent(\n///         1.187662594419065,\n///         79\n///     )\n///     .unwrap()\n///     .to_string(),\n///     \"7.178979876918526e23\"\n/// );\n/// assert_eq!(\n///     <&Float as SciMantissaAndExponent<f64, _, _>>::from_sci_mantissa_and_exponent(\n///         1.6839799530592128,\n///         -80\n///     )\n///     .unwrap()\n///     .to_string(),\n///     \"1.392955569098538e-24\"\n/// );\n/// ```\npub mod mantissa_and_exponent;\n/// Implementations of traits for converting a [`Float`](crate::Float) to a\n/// [`Natural`](malachite_nz::natural::Natural).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\npub mod natural_from_float;\n/// Functions and implementations of traits for converting a [`Float`](crate::Float) to a primitive\n/// float.\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::PowerOf2;\n/// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_float::Float;\n///\n/// assert_eq!(f32::convertible_from(&Float::NAN), true);\n/// assert_eq!(f32::convertible_from(&Float::INFINITY), true);\n/// assert_eq!(f32::convertible_from(&Float::ZERO), true);\n/// assert_eq!(f32::convertible_from(&Float::from(1.5)), true);\n/// assert_eq!(f32::convertible_from(&Float::from(-1.5)), true);\n/// assert_eq!(f32::convertible_from(&Float::from(123.0)), true);\n/// assert_eq!(f32::convertible_from(&Float::from(-123.0)), true);\n///\n/// // Even though precision is high, the value is just 1.0 and can be converted\n/// assert_eq!(f32::convertible_from(&Float::one_prec(100)), true);\n///\n/// let mut x = Float::one_prec(40);\n/// x.increment();\n///\n/// // precision too high for f32\n/// assert_eq!(f32::convertible_from(&x), false);\n///\n/// // but not for f64\n/// assert_eq!(f64::convertible_from(&x), true);\n///\n/// assert_eq!(f32::convertible_from(&Float::power_of_2(100u64)), true);\n/// assert_eq!(f32::convertible_from(&Float::power_of_2(1000u64)), false);\n/// assert_eq!(f64::convertible_from(&Float::power_of_2(1000u64)), true);\n/// assert_eq!(f64::convertible_from(&Float::power_of_2(10000u64)), false);\n/// ```\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::PowerOf2;\n/// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_float::conversion::primitive_float_from_float::FloatFromFloatError;\n/// use malachite_float::Float;\n///\n/// assert_eq!(\n///     NiceFloat(f32::try_from(Float::NAN).unwrap()),\n///     NiceFloat(f32::NAN)\n/// );\n/// assert_eq!(f32::try_from(Float::INFINITY), Ok(f32::INFINITY));\n/// assert_eq!(f32::try_from(Float::ZERO), Ok(0.0));\n/// assert_eq!(f32::try_from(Float::from(1.5)), Ok(1.5));\n/// assert_eq!(f32::try_from(Float::from(-1.5)), Ok(-1.5));\n/// assert_eq!(f32::try_from(Float::from(123.0)), Ok(123.0));\n/// assert_eq!(f32::try_from(Float::from(-123.0)), Ok(-123.0));\n///\n/// // Even though precision is high, the value is just 1.0 and can be converted\n/// assert_eq!(f32::try_from(Float::one_prec(100)), Ok(1.0));\n///\n/// let mut x = Float::one_prec(40);\n/// x.increment();\n///\n/// // precision too high for f32\n/// assert_eq!(f32::try_from(x.clone()), Err(FloatFromFloatError::Inexact));\n///\n/// // but not for f64\n/// assert_eq!(\n///     NiceFloat(f64::try_from(x).unwrap()),\n///     NiceFloat(1.000000000001819)\n/// );\n///\n/// assert_eq!(\n///     NiceFloat(f32::try_from(Float::power_of_2(100u64)).unwrap()),\n///     NiceFloat(1.2676506e30)\n/// );\n/// assert_eq!(\n///     f32::try_from(Float::power_of_2(1000u64)),\n///     Err(FloatFromFloatError::Overflow)\n/// );\n/// assert_eq!(\n///     NiceFloat(f64::try_from(Float::power_of_2(1000u64)).unwrap()),\n///     NiceFloat(1.0715086071862673e301)\n/// );\n/// assert_eq!(\n///     f64::try_from(Float::power_of_2(10000u64)),\n///     Err(FloatFromFloatError::Overflow)\n/// );\n///\n/// assert_eq!(\n///     NiceFloat(f32::try_from(&Float::NAN).unwrap()),\n///     NiceFloat(f32::NAN)\n/// );\n/// assert_eq!(f32::try_from(&Float::INFINITY), Ok(f32::INFINITY));\n/// assert_eq!(f32::try_from(&Float::ZERO), Ok(0.0));\n/// assert_eq!(f32::try_from(&Float::from(1.5)), Ok(1.5));\n/// assert_eq!(f32::try_from(&Float::from(-1.5)), Ok(-1.5));\n/// assert_eq!(f32::try_from(&Float::from(123.0)), Ok(123.0));\n/// assert_eq!(f32::try_from(&Float::from(-123.0)), Ok(-123.0));\n///\n/// // Even though precision is high, the value is just 1.0 and can be converted\n/// assert_eq!(f32::try_from(&Float::one_prec(100)), Ok(1.0));\n///\n/// let mut x = Float::one_prec(40);\n/// x.increment();\n///\n/// // precision too high for f32\n/// assert_eq!(f32::try_from(&x), Err(FloatFromFloatError::Inexact));\n///\n/// // but not for f64\n/// assert_eq!(\n///     NiceFloat(f64::try_from(&x).unwrap()),\n///     NiceFloat(1.000000000001819)\n/// );\n///\n/// assert_eq!(\n///     NiceFloat(f32::try_from(&Float::power_of_2(100u64)).unwrap()),\n///     NiceFloat(1.2676506e30)\n/// );\n/// assert_eq!(\n///     f32::try_from(&Float::power_of_2(1000u64)),\n///     Err(FloatFromFloatError::Overflow)\n/// );\n/// assert_eq!(\n///     NiceFloat(f64::try_from(&Float::power_of_2(1000u64)).unwrap()),\n///     NiceFloat(1.0715086071862673e301)\n/// );\n/// assert_eq!(\n///     f64::try_from(&Float::power_of_2(10000u64)),\n///     Err(FloatFromFloatError::Overflow)\n/// );\n/// ```\n///\n/// # rounding_from\n/// ```\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use malachite_q::Rational;\n/// use std::cmp::Ordering::*;\n///\n/// let f = Float::from_rational_prec(Rational::from_signeds(1, 3), 100).0;\n///\n/// let (x, o) = f32::rounding_from(f.clone(), Floor);\n/// assert_eq!(NiceFloat(x), NiceFloat(0.3333333));\n/// assert_eq!(o, Less);\n///\n/// let (x, o) = f32::rounding_from(f.clone(), Ceiling);\n/// assert_eq!(NiceFloat(x), NiceFloat(0.33333334));\n/// assert_eq!(o, Greater);\n///\n/// let (x, o) = f32::rounding_from(f.clone(), Nearest);\n/// assert_eq!(NiceFloat(x), NiceFloat(0.33333334));\n/// assert_eq!(o, Greater);\n///\n/// let (x, o) = f32::rounding_from(&f, Floor);\n/// assert_eq!(NiceFloat(x), NiceFloat(0.3333333));\n/// assert_eq!(o, Less);\n///\n/// let (x, o) = f32::rounding_from(&f, Ceiling);\n/// assert_eq!(NiceFloat(x), NiceFloat(0.33333334));\n/// assert_eq!(o, Greater);\n///\n/// let (x, o) = f32::rounding_from(&f, Nearest);\n/// assert_eq!(NiceFloat(x), NiceFloat(0.33333334));\n/// assert_eq!(o, Greater);\n/// ```\npub mod primitive_float_from_float;\n/// Functions and implementations of traits for converting a [`Float`](crate::Float) to a primitive\n/// integer.\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # rounding_from\n/// ```\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_float::Float;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(u8::rounding_from(Float::from(1.5), Floor), (1, Less));\n/// assert_eq!(u8::rounding_from(Float::from(1.5), Ceiling), (2, Greater));\n/// assert_eq!(u8::rounding_from(Float::from(1.5), Nearest), (2, Greater));\n///\n/// assert_eq!(u8::rounding_from(Float::from(256.0), Down), (255, Less));\n/// assert_eq!(u8::rounding_from(Float::from(256.0), Floor), (255, Less));\n/// assert_eq!(u8::rounding_from(Float::from(256.0), Nearest), (255, Less));\n///\n/// assert_eq!(u8::rounding_from(Float::from(-123.0), Down), (0, Greater));\n/// assert_eq!(\n///     u8::rounding_from(Float::from(-123.0), Ceiling),\n///     (0, Greater)\n/// );\n/// assert_eq!(\n///     u8::rounding_from(Float::from(-123.0), Nearest),\n///     (0, Greater)\n/// );\n///\n/// assert_eq!(i8::rounding_from(Float::from(1.5), Floor), (1, Less));\n/// assert_eq!(i8::rounding_from(Float::from(1.5), Ceiling), (2, Greater));\n/// assert_eq!(i8::rounding_from(Float::from(1.5), Nearest), (2, Greater));\n///\n/// assert_eq!(i8::rounding_from(Float::from(-1.5), Floor), (-2, Less));\n/// assert_eq!(i8::rounding_from(Float::from(-1.5), Ceiling), (-1, Greater));\n/// assert_eq!(i8::rounding_from(Float::from(-1.5), Nearest), (-2, Less));\n///\n/// assert_eq!(i8::rounding_from(Float::from(128.0), Down), (127, Less));\n/// assert_eq!(i8::rounding_from(Float::from(128.0), Floor), (127, Less));\n/// assert_eq!(i8::rounding_from(Float::from(128.0), Nearest), (127, Less));\n///\n/// assert_eq!(\n///     i8::rounding_from(Float::from(-129.0), Down),\n///     (-128, Greater)\n/// );\n/// assert_eq!(\n///     i8::rounding_from(Float::from(-129.0), Ceiling),\n///     (-128, Greater)\n/// );\n/// assert_eq!(\n///     i8::rounding_from(Float::from(-129.0), Nearest),\n///     (-128, Greater)\n/// );\n///\n/// assert_eq!(u8::rounding_from(&Float::from(1.5), Floor), (1, Less));\n/// assert_eq!(u8::rounding_from(&Float::from(1.5), Ceiling), (2, Greater));\n/// assert_eq!(u8::rounding_from(&Float::from(1.5), Nearest), (2, Greater));\n///\n/// assert_eq!(u8::rounding_from(&Float::from(256.0), Down), (255, Less));\n/// assert_eq!(u8::rounding_from(&Float::from(256.0), Floor), (255, Less));\n/// assert_eq!(u8::rounding_from(&Float::from(256.0), Nearest), (255, Less));\n///\n/// assert_eq!(u8::rounding_from(&Float::from(-123.0), Down), (0, Greater));\n/// assert_eq!(\n///     u8::rounding_from(&Float::from(-123.0), Ceiling),\n///     (0, Greater)\n/// );\n/// assert_eq!(\n///     u8::rounding_from(&Float::from(-123.0), Nearest),\n///     (0, Greater)\n/// );\n///\n/// assert_eq!(i8::rounding_from(&Float::from(1.5), Floor), (1, Less));\n/// assert_eq!(i8::rounding_from(&Float::from(1.5), Ceiling), (2, Greater));\n/// assert_eq!(i8::rounding_from(&Float::from(1.5), Nearest), (2, Greater));\n///\n/// assert_eq!(i8::rounding_from(&Float::from(-1.5), Floor), (-2, Less));\n/// assert_eq!(\n///     i8::rounding_from(&Float::from(-1.5), Ceiling),\n///     (-1, Greater)\n/// );\n/// assert_eq!(i8::rounding_from(&Float::from(-1.5), Nearest), (-2, Less));\n///\n/// assert_eq!(i8::rounding_from(&Float::from(128.0), Down), (127, Less));\n/// assert_eq!(i8::rounding_from(&Float::from(128.0), Floor), (127, Less));\n/// assert_eq!(i8::rounding_from(&Float::from(128.0), Nearest), (127, Less));\n///\n/// assert_eq!(\n///     i8::rounding_from(&Float::from(-129.0), Down),\n///     (-128, Greater)\n/// );\n/// assert_eq!(\n///     i8::rounding_from(&Float::from(-129.0), Ceiling),\n///     (-128, Greater)\n/// );\n/// assert_eq!(\n///     i8::rounding_from(&Float::from(-129.0), Nearest),\n///     (-128, Greater)\n/// );\n/// ```\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n/// use malachite_base::num::conversion::from::{SignedFromFloatError, UnsignedFromFloatError};\n/// use malachite_float::Float;\n///\n/// assert_eq!(u8::try_from(Float::ZERO).unwrap(), 0);\n/// assert_eq!(u8::try_from(Float::from(123.0)).unwrap(), 123);\n///\n/// assert_eq!(\n///     u8::try_from(Float::from(-123.0)),\n///     Err(UnsignedFromFloatError::FloatNegative)\n/// );\n/// assert_eq!(\n///     u8::try_from(Float::from(256.0)),\n///     Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     u8::try_from(Float::from(1.5)),\n///     Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     u8::try_from(Float::INFINITY),\n///     Err(UnsignedFromFloatError::FloatInfiniteOrNan)\n/// );\n/// assert_eq!(\n///     u8::try_from(Float::NAN),\n///     Err(UnsignedFromFloatError::FloatInfiniteOrNan)\n/// );\n///\n/// assert_eq!(i8::try_from(Float::ZERO).unwrap(), 0);\n/// assert_eq!(i8::try_from(Float::from(123.0)).unwrap(), 123);\n/// assert_eq!(i8::try_from(Float::from(-123.0)).unwrap(), -123);\n///\n/// assert_eq!(\n///     i8::try_from(Float::from(128.0)),\n///     Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     i8::try_from(Float::from(-129.0)),\n///     Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     i8::try_from(Float::from(1.5)),\n///     Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     i8::try_from(Float::INFINITY),\n///     Err(SignedFromFloatError::FloatInfiniteOrNan)\n/// );\n/// assert_eq!(\n///     i8::try_from(Float::NAN),\n///     Err(SignedFromFloatError::FloatInfiniteOrNan)\n/// );\n///\n/// assert_eq!(u8::try_from(&Float::ZERO).unwrap(), 0);\n/// assert_eq!(u8::try_from(&Float::from(123.0)).unwrap(), 123);\n///\n/// assert_eq!(\n///     u8::try_from(&Float::from(-123.0)),\n///     Err(UnsignedFromFloatError::FloatNegative)\n/// );\n/// assert_eq!(\n///     u8::try_from(&Float::from(256.0)),\n///     Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     u8::try_from(&Float::from(1.5)),\n///     Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     u8::try_from(&Float::INFINITY),\n///     Err(UnsignedFromFloatError::FloatInfiniteOrNan)\n/// );\n/// assert_eq!(\n///     u8::try_from(&Float::NAN),\n///     Err(UnsignedFromFloatError::FloatInfiniteOrNan)\n/// );\n///\n/// assert_eq!(i8::try_from(&Float::ZERO).unwrap(), 0);\n/// assert_eq!(i8::try_from(&Float::from(123.0)).unwrap(), 123);\n/// assert_eq!(i8::try_from(&Float::from(-123.0)).unwrap(), -123);\n///\n/// assert_eq!(\n///     i8::try_from(&Float::from(128.0)),\n///     Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     i8::try_from(&Float::from(-129.0)),\n///     Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     i8::try_from(&Float::from(1.5)),\n///     Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n/// );\n/// assert_eq!(\n///     i8::try_from(&Float::INFINITY),\n///     Err(SignedFromFloatError::FloatInfiniteOrNan)\n/// );\n/// assert_eq!(\n///     i8::try_from(&Float::NAN),\n///     Err(SignedFromFloatError::FloatInfiniteOrNan)\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_float::Float;\n///\n/// assert_eq!(u8::convertible_from(&Float::ZERO), true);\n/// assert_eq!(u8::convertible_from(&Float::from(123.0)), true);\n///\n/// assert_eq!(u8::convertible_from(&Float::from(256.0)), false);\n/// assert_eq!(u8::convertible_from(&Float::from(-123.0)), false);\n/// assert_eq!(u8::convertible_from(&Float::from(1.5)), false);\n/// assert_eq!(u8::convertible_from(&Float::INFINITY), false);\n/// assert_eq!(u8::convertible_from(&Float::NAN), false);\n///\n/// assert_eq!(i8::convertible_from(&Float::ZERO), true);\n/// assert_eq!(i8::convertible_from(&Float::from(123.0)), true);\n/// assert_eq!(i8::convertible_from(&Float::from(-123.0)), true);\n///\n/// assert_eq!(i8::convertible_from(&Float::from(128.0)), false);\n/// assert_eq!(i8::convertible_from(&Float::from(-129.0)), false);\n/// assert_eq!(i8::convertible_from(&Float::from(1.5)), false);\n/// assert_eq!(i8::convertible_from(&Float::INFINITY), false);\n/// assert_eq!(i8::convertible_from(&Float::NAN), false);\n/// ```\npub mod primitive_int_from_float;\n/// Implementations of traits for converting a [`Float`](crate::Float) to a\n/// [`Rational`](malachite_q::Rational).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\npub mod rational_from_float;\n/// Implementations of traits for converting [`Float`](crate::Float)s to and from [`String`]s.\n///\n/// Warning: these implementations are unstable and will definitely be changed in the future.\npub mod string;\n"
  },
  {
    "path": "malachite-float/src/conversion/natural_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, Zero};\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, ShrRound};\nuse malachite_base::num::basic::traits::{One, Zero as ZeroTrait};\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::Natural;\n\nimpl RoundingFrom<Float> for Natural {\n    /// Converts a [`Float`] to a [`Natural`], using a specified [`RoundingMode`] and taking the\n    /// [`Float`] by value. An [`Ordering`] is also returned, indicating whether the returned value\n    /// is less than, equal to, or greater than the original value.\n    ///\n    /// If the [`Float`] is negative (including $-\\infty$), then it will be rounded to zero when the\n    /// [`RoundingMode`] is `Ceiling`, `Down`, or `Nearest`. Otherwise, this function will panic.\n    ///\n    /// If the [`Float`] is NaN or $\\infty$, the function will panic regardless of the rounding\n    /// mode.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`] is less\n    /// than zero and `rm` is not `Down`, `Ceiling`, or `Nearest`, or if the [`Float`] is NaN or\n    /// $\\infty$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::NegativeInfinity;\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(Float::from(1.5), Floor).to_debug_string(),\n    ///     \"(1, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Float::from(1.5), Ceiling).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Float::from(1.5), Nearest).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(Float::NEGATIVE_INFINITY, Down).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Float::NEGATIVE_INFINITY, Ceiling).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Float::NEGATIVE_INFINITY, Nearest).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// ```\n    fn rounding_from(f: Float, rm: RoundingMode) -> (Self, Ordering) {\n        match f {\n            float_either_zero!() => (Self::ZERO, Equal),\n            float_negative_infinity!() => match rm {\n                Ceiling | Down | Nearest => (Self::ZERO, Greater),\n                _ => panic!(\"Can't convert -Infinity to Natural using {rm}\"),\n            },\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                if !sign {\n                    match rm {\n                        Ceiling | Down | Nearest => (Self::ZERO, Greater),\n                        _ => panic!(\"Cannot convert negative number to Natural using {rm}\"),\n                    }\n                } else if exponent < 0 {\n                    match rm {\n                        Floor | Down | Nearest => (Self::ZERO, Less),\n                        Ceiling | Up => (Self::ONE, Greater),\n                        Exact => panic!(\"Cannot convert Float to Natural using {rm}\"),\n                    }\n                } else {\n                    let sb = significand_bits(&significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    if sb >= eb {\n                        significand.shr_round(sb - eb, rm)\n                    } else {\n                        (significand << (eb - sb), Equal)\n                    }\n                }\n            }\n            _ => panic!(\"Can't convert {f} to Natural using {rm}\"),\n        }\n    }\n}\n\nimpl RoundingFrom<&Float> for Natural {\n    /// Converts a [`Float`] to a [`Natural`], using a specified [`RoundingMode`] and taking the\n    /// [`Float`] by reference. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// If the [`Float`] is negative (including $-\\infty$), then it will be rounded to zero when the\n    /// [`RoundingMode`] is `Ceiling`, `Down`, or `Nearest`. Otherwise, this function will panic.\n    ///\n    /// If the [`Float`] is NaN or $\\infty$, the function will panic regardless of the rounding\n    /// mode.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`] is less\n    /// than zero and `rm` is not `Down`, `Ceiling`, or `Nearest`, or if the [`Float`] is NaN or\n    /// $\\infty$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::NegativeInfinity;\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Float::from(1.5), Floor).to_debug_string(),\n    ///     \"(1, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Float::from(1.5), Ceiling).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Float::from(1.5), Nearest).to_debug_string(),\n    ///     \"(2, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Float::NEGATIVE_INFINITY, Down).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Float::NEGATIVE_INFINITY, Ceiling).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Float::NEGATIVE_INFINITY, Nearest).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// ```\n    fn rounding_from(f: &Float, rm: RoundingMode) -> (Self, Ordering) {\n        match f {\n            float_either_zero!() => (Self::ZERO, Equal),\n            float_negative_infinity!() => match rm {\n                Ceiling | Down | Nearest => (Self::ZERO, Greater),\n                _ => panic!(\"Can't convert -Infinity to Natural using {rm}\"),\n            },\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                if !sign {\n                    match rm {\n                        Ceiling | Down | Nearest => (Self::ZERO, Greater),\n                        _ => panic!(\"Cannot convert -Infinity to Natural using {rm}\"),\n                    }\n                } else if *exponent < 0 {\n                    match rm {\n                        Floor | Down | Nearest => (Self::ZERO, Less),\n                        Ceiling | Up => (Self::ONE, Greater),\n                        Exact => panic!(\"Cannot convert Float to Natural using {rm}\"),\n                    }\n                } else {\n                    let sb = significand_bits(significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    if sb >= eb {\n                        significand.shr_round(sb - eb, rm)\n                    } else {\n                        (significand << (eb - sb), Equal)\n                    }\n                }\n            }\n            _ => panic!(\"Can't convert {f} to Natural using {rm}\"),\n        }\n    }\n}\n\nimpl TryFrom<Float> for Natural {\n    type Error = UnsignedFromFloatError;\n\n    /// Converts a [`Float`] to a [`Natural`], taking the [`Float`] by value. If the [`Float`] is\n    /// not equal to a non-negative integer, an error is returned.\n    ///\n    /// Both positive and negative zero convert to a [`Natural`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_base::num::conversion::from::UnsignedFromFloatError::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::try_from(Float::ZERO).unwrap(), 0);\n    /// assert_eq!(Natural::try_from(Float::from(123.0)).unwrap(), 123);\n    ///\n    /// assert_eq!(Natural::try_from(Float::from(-123.0)), Err(FloatNegative));\n    /// assert_eq!(\n    ///     Natural::try_from(Float::from(1.5)),\n    ///     Err(FloatNonIntegerOrOutOfRange)\n    /// );\n    /// assert_eq!(Natural::try_from(Float::INFINITY), Err(FloatInfiniteOrNan));\n    /// assert_eq!(Natural::try_from(Float::NAN), Err(FloatInfiniteOrNan));\n    /// ```\n    fn try_from(f: Float) -> Result<Self, Self::Error> {\n        match f {\n            float_either_zero!() => Ok(Self::ZERO),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                if !sign {\n                    Err(UnsignedFromFloatError::FloatNegative)\n                } else if exponent <= 0 {\n                    Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                } else {\n                    let sb = significand_bits(&significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    if sb >= eb {\n                        let bits = sb - eb;\n                        if significand.divisible_by_power_of_2(bits) {\n                            Ok(significand >> bits)\n                        } else {\n                            Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                        }\n                    } else {\n                        Ok(significand << (eb - sb))\n                    }\n                }\n            }\n            _ => Err(UnsignedFromFloatError::FloatInfiniteOrNan),\n        }\n    }\n}\n\nimpl TryFrom<&Float> for Natural {\n    type Error = UnsignedFromFloatError;\n\n    /// Converts a [`Float`] to a [`Natural`], taking the [`Float`] by reference. If the [`Float`]\n    /// is not equal to a non-negative integer, an error is returned.\n    ///\n    /// Both positive and negative zero convert to a [`Natural`] zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.complexity()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_base::num::conversion::from::UnsignedFromFloatError::*;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::try_from(&Float::ZERO).unwrap(), 0);\n    /// assert_eq!(Natural::try_from(&Float::from(123.0)).unwrap(), 123);\n    ///\n    /// assert_eq!(Natural::try_from(&Float::from(-123.0)), Err(FloatNegative));\n    /// assert_eq!(\n    ///     Natural::try_from(&Float::from(1.5)),\n    ///     Err(FloatNonIntegerOrOutOfRange)\n    /// );\n    /// assert_eq!(Natural::try_from(&Float::INFINITY), Err(FloatInfiniteOrNan));\n    /// assert_eq!(Natural::try_from(&Float::NAN), Err(FloatInfiniteOrNan));\n    /// ```\n    fn try_from(f: &Float) -> Result<Self, Self::Error> {\n        match f {\n            float_either_zero!() => Ok(Self::ZERO),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                if !*sign {\n                    Err(UnsignedFromFloatError::FloatNegative)\n                } else if *exponent <= 0 {\n                    Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                } else {\n                    let sb = significand_bits(significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    if sb >= eb {\n                        let bits = sb - eb;\n                        if significand.divisible_by_power_of_2(bits) {\n                            Ok(significand >> bits)\n                        } else {\n                            Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                        }\n                    } else {\n                        Ok(significand << (eb - sb))\n                    }\n                }\n            }\n            _ => Err(UnsignedFromFloatError::FloatInfiniteOrNan),\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Float> for Natural {\n    /// Determines whether a [`Float`] can be converted to a [`Natural`] (when the [`Float`] is\n    /// non-negative and an integer), taking the [`Float`] by reference.\n    ///\n    /// Both positive and negative zero are convertible to a [`Natural`]. (Although negative zero is\n    /// nominally negative, the real number it represents is zero, which is not negative.)\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `f.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_float::Float;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::convertible_from(&Float::ZERO), true);\n    /// assert_eq!(Natural::convertible_from(&Float::from(123.0)), true);\n    ///\n    /// assert_eq!(Natural::convertible_from(&Float::from(-123.0)), false);\n    /// assert_eq!(Natural::convertible_from(&Float::from(1.5)), false);\n    /// assert_eq!(Natural::convertible_from(&Float::INFINITY), false);\n    /// assert_eq!(Natural::convertible_from(&Float::NAN), false);\n    /// ```\n    fn convertible_from(f: &Float) -> bool {\n        match f {\n            float_either_zero!() => true,\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                *sign && *exponent > 0 && {\n                    let sb = significand_bits(significand);\n                    let eb = u64::from(exponent.unsigned_abs());\n                    sb < eb || significand.divisible_by_power_of_2(sb - eb)\n                }\n            }\n            _ => false,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/primitive_float_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, IsPowerOf2, ShrRound};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nfn primitive_float_rounding_from_float<T: PrimitiveFloat>(\n    f: Float,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    match f {\n        float_nan!() => (T::NAN, Equal),\n        float_infinity!() => (T::INFINITY, Equal),\n        float_negative_infinity!() => (T::NEGATIVE_INFINITY, Equal),\n        float_zero!() => (T::ZERO, Equal),\n        float_negative_zero!() => (T::NEGATIVE_ZERO, Equal),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let abs_rm = if sign { rm } else { -rm };\n            let (x, o) = {\n                let exponent = i64::from(exponent) - 1;\n                if exponent < T::MIN_EXPONENT {\n                    match abs_rm {\n                        Floor | Down => (T::ZERO, Less),\n                        Ceiling | Up => (T::MIN_POSITIVE_SUBNORMAL, Greater),\n                        Nearest => {\n                            if exponent == T::MIN_EXPONENT - 1 && !significand.is_power_of_2() {\n                                (T::MIN_POSITIVE_SUBNORMAL, Greater)\n                            } else {\n                                (T::ZERO, Less)\n                            }\n                        }\n                        Exact => panic!(\"Float too small for exact conversion\"),\n                    }\n                } else if exponent > T::MAX_EXPONENT {\n                    match abs_rm {\n                        Floor | Down => (T::MAX_FINITE, Less),\n                        Ceiling | Up | Nearest => (T::INFINITY, Greater),\n                        Exact => panic!(\"Float too large for exact conversion\"),\n                    }\n                } else {\n                    let target_prec = T::max_precision_for_sci_exponent(exponent);\n                    let bits = significand_bits(&significand);\n                    let (mantissa, o) =\n                        significand.shr_round(i128::from(bits) - i128::from(target_prec), abs_rm);\n                    let mantissa = u64::wrapping_from(&mantissa);\n                    if mantissa.significant_bits() > target_prec {\n                        if exponent == T::MAX_EXPONENT {\n                            match abs_rm {\n                                Floor | Down => (T::MAX_FINITE, Less),\n                                Ceiling | Up | Nearest => (T::INFINITY, Greater),\n                                Exact => {\n                                    panic!(\"Float too large for exact conversion\")\n                                }\n                            }\n                        } else {\n                            (\n                                T::from_integer_mantissa_and_exponent(\n                                    mantissa >> 1,\n                                    exponent - i64::wrapping_from(target_prec) + 2,\n                                )\n                                .unwrap(),\n                                o,\n                            )\n                        }\n                    } else {\n                        (\n                            T::from_integer_mantissa_and_exponent(\n                                mantissa,\n                                exponent - i64::wrapping_from(target_prec) + 1,\n                            )\n                            .unwrap(),\n                            o,\n                        )\n                    }\n                }\n            };\n            if sign { (x, o) } else { (-x, o.reverse()) }\n        }\n    }\n}\n\nfn primitive_float_rounding_from_float_ref<T: PrimitiveFloat>(\n    f: &Float,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    match f {\n        float_nan!() => (T::NAN, Equal),\n        float_infinity!() => (T::INFINITY, Equal),\n        float_negative_infinity!() => (T::NEGATIVE_INFINITY, Equal),\n        float_zero!() => (T::ZERO, Equal),\n        float_negative_zero!() => (T::NEGATIVE_ZERO, Equal),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let abs_rm = if *sign { rm } else { -rm };\n            let (x, o) = {\n                let exponent = i64::from(*exponent) - 1;\n                if exponent < T::MIN_EXPONENT {\n                    match abs_rm {\n                        Floor | Down => (T::ZERO, Less),\n                        Ceiling | Up => (T::MIN_POSITIVE_SUBNORMAL, Greater),\n                        Nearest => {\n                            if exponent == T::MIN_EXPONENT - 1 && !significand.is_power_of_2() {\n                                (T::MIN_POSITIVE_SUBNORMAL, Greater)\n                            } else {\n                                (T::ZERO, Less)\n                            }\n                        }\n                        Exact => panic!(\"Float too small for exact conversion\"),\n                    }\n                } else if exponent > T::MAX_EXPONENT {\n                    match abs_rm {\n                        Floor | Down => (T::MAX_FINITE, Less),\n                        Ceiling | Up | Nearest => (T::INFINITY, Greater),\n                        Exact => panic!(\"Float too large for exact conversion\"),\n                    }\n                } else {\n                    let target_prec = T::max_precision_for_sci_exponent(exponent);\n                    let bits = significand_bits(significand);\n                    let (mantissa, o) =\n                        significand.shr_round(i128::from(bits) - i128::from(target_prec), abs_rm);\n                    let mantissa = u64::wrapping_from(&mantissa);\n                    if mantissa.significant_bits() > target_prec {\n                        if exponent == T::MAX_EXPONENT {\n                            match abs_rm {\n                                Floor | Down => (T::MAX_FINITE, Less),\n                                Ceiling | Up | Nearest => (T::INFINITY, Greater),\n\n                                Exact => {\n                                    panic!(\"Float too large for exact conversion\")\n                                }\n                            }\n                        } else {\n                            (\n                                T::from_integer_mantissa_and_exponent(\n                                    mantissa >> 1,\n                                    exponent - i64::wrapping_from(target_prec) + 2,\n                                )\n                                .unwrap(),\n                                o,\n                            )\n                        }\n                    } else {\n                        (\n                            T::from_integer_mantissa_and_exponent(\n                                mantissa,\n                                exponent - i64::wrapping_from(target_prec) + 1,\n                            )\n                            .unwrap(),\n                            o,\n                        )\n                    }\n                }\n            };\n            if *sign { (x, o) } else { (-x, o.reverse()) }\n        }\n    }\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub enum FloatFromFloatError {\n    Overflow,\n    Underflow,\n    Inexact,\n}\n\nfn primitive_float_try_from_float<T: PrimitiveFloat>(f: Float) -> Result<T, FloatFromFloatError> {\n    match f {\n        float_nan!() => Ok(T::NAN),\n        float_infinity!() => Ok(T::INFINITY),\n        float_negative_infinity!() => Ok(T::NEGATIVE_INFINITY),\n        float_zero!() => Ok(T::ZERO),\n        float_negative_zero!() => Ok(T::NEGATIVE_ZERO),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let x = {\n                let exponent = i64::from(exponent) - 1;\n                if exponent < T::MIN_EXPONENT {\n                    return Err(FloatFromFloatError::Underflow);\n                } else if exponent > T::MAX_EXPONENT {\n                    return Err(FloatFromFloatError::Overflow);\n                }\n                let target_prec = T::max_precision_for_sci_exponent(exponent);\n                let bits = significand_bits(&significand);\n                if bits > target_prec && !significand.divisible_by_power_of_2(bits - target_prec) {\n                    return Err(FloatFromFloatError::Inexact);\n                }\n                let mantissa = u64::wrapping_from(\n                    &(significand >> (i128::from(bits) - i128::from(target_prec))),\n                );\n                T::from_integer_mantissa_and_exponent(\n                    mantissa,\n                    exponent - i64::wrapping_from(target_prec) + 1,\n                )\n                .unwrap()\n            };\n            Ok(if sign { x } else { -x })\n        }\n    }\n}\n\nfn primitive_float_try_from_float_ref<T: PrimitiveFloat>(\n    f: &Float,\n) -> Result<T, FloatFromFloatError> {\n    match f {\n        float_nan!() => Ok(T::NAN),\n        float_infinity!() => Ok(T::INFINITY),\n        float_negative_infinity!() => Ok(T::NEGATIVE_INFINITY),\n        float_zero!() => Ok(T::ZERO),\n        float_negative_zero!() => Ok(T::NEGATIVE_ZERO),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let x = if *significand == 0u32 {\n                T::ZERO\n            } else {\n                let exponent = i64::from(*exponent) - 1;\n                if exponent < T::MIN_EXPONENT {\n                    return Err(FloatFromFloatError::Underflow);\n                } else if exponent > T::MAX_EXPONENT {\n                    return Err(FloatFromFloatError::Overflow);\n                }\n                let target_prec = T::max_precision_for_sci_exponent(exponent);\n                let bits = significand_bits(significand);\n                if bits > target_prec && !significand.divisible_by_power_of_2(bits - target_prec) {\n                    return Err(FloatFromFloatError::Inexact);\n                }\n                let mantissa = u64::wrapping_from(\n                    &(significand >> (i128::from(bits) - i128::from(target_prec))),\n                );\n                T::from_integer_mantissa_and_exponent(\n                    mantissa,\n                    exponent - i64::wrapping_from(target_prec) + 1,\n                )\n                .unwrap()\n            };\n            Ok(if *sign { x } else { -x })\n        }\n    }\n}\n\nfn primitive_float_convertible_from_float<T: PrimitiveFloat>(f: &Float) -> bool {\n    match f {\n        Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(*exponent) - 1;\n            exponent >= T::MIN_EXPONENT && exponent <= T::MAX_EXPONENT && {\n                let target_prec = T::max_precision_for_sci_exponent(exponent);\n                let bits = significand_bits(significand);\n                bits <= target_prec || significand.divisible_by_power_of_2(bits - target_prec)\n            }\n        }\n        _ => true,\n    }\n}\n\nmacro_rules! impl_primitive_float_from {\n    ($t: ident) => {\n        impl RoundingFrom<Float> for $t {\n            /// Converts a [`Float`] to a primitive float, using a specified [`RoundingMode`] and\n            /// taking the [`Float`] by value. An [`Ordering`] is also returned, indicating whether\n            /// the returned value is less than, equal to, or greater than the original value.\n            /// (Although a NaN is not comparable to any [`Float`], converting a NaN to a NaN will\n            /// also return `Equal`, indicating an exact conversion.)\n            ///\n            /// Overflow and underflow:\n            /// - If the rounding mode is `Floor`, the largest primitive float less than or equal to\n            ///   the [`Float`] is returned. If the [`Float`] is greater than the maximum finite\n            ///   primitive float, then the maximum finite primitive float is returned. If it is\n            ///   smaller than the minimum finite primitive float, then $-\\infty$ is returned. If it\n            ///   is between zero and the minimum positive primitive float, then positive zero is\n            ///   returned.\n            /// - If the rounding mode is `Ceiling`, the smallest primitive float greater than or\n            ///   equal to the [`Float`] is returned. If the [`Float`] is greater than the maximum\n            ///   finite primitive float, then $\\infty$ is returned. If it is smaller than the\n            ///   minimum finite primitive float, then the minimum finite primitive float is\n            ///   returned. If it is between zero and the maximum negative primitive float, then\n            ///   negative zero is returned.\n            /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor` if the\n            ///   [`Float`] is non-negative and as with `Ceiling` if the [`Float`] is negative. If\n            ///   the [`Float`] is between the maximum negative primitive float and the minimum\n            ///   positive primitive float, then positive zero is returned when the [`Float`] is\n            ///   non-negative and negative zero otherwise.\n            /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling` if the\n            ///   [`Float`] is non-negative and as with `Floor` if the [`Float`] is negative. Zero\n            ///   is only returned when the [`Float`] is zero.\n            /// - If the rounding mode is `Nearest`, then the nearest primitive float is returned.\n            ///   If the [`Float`] is exactly between two primitive floats, the primitive float with\n            ///   the zero least-significant bit in its representation is selected. If the [`Float`]\n            ///   is greater than the maximum finite primitive float, then $\\infty$ is returned. If\n            ///   the [`Float`] is smaller than the minimum finite primitive float, then $-\\infty$\n            ///   is returned. If the [`Float`] is closer to zero than to any other primitive float\n            ///   (or if there is a tie between zero and another float), then positive or negative\n            ///   zero is returned, depending on the [`Float`]'s sign.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the [`Float`] is not exactly equal to any float of the target type, and\n            /// `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_float#rounding_from).\n            #[inline]\n            fn rounding_from(f: Float, rm: RoundingMode) -> ($t, Ordering) {\n                primitive_float_rounding_from_float(f, rm)\n            }\n        }\n\n        impl RoundingFrom<&Float> for $t {\n            /// Converts a [`Float`] to a primitive float, using a specified [`RoundingMode`] and\n            /// taking the [`Float`] by reference. An [`Ordering`] is also returned, indicating\n            /// whether the returned value is less than, equal to, or greater than the original\n            /// value. (Although a NaN is not comparable to any [`Float`], converting a NaN to a NaN\n            /// will also return `Equal`, indicating an exact conversion.)\n            ///\n            /// Overflow and underflow:\n            /// - If the rounding mode is `Floor`, the largest primitive float less than or equal to\n            ///   the [`Float`] is returned. If the [`Float`] is greater than the maximum finite\n            ///   primitive float, then the maximum finite primitive float is returned. If it is\n            ///   smaller than the minimum finite primitive float, then $-\\infty$ is returned. If it\n            ///   is between zero and the minimum positive primitive float, then positive zero is\n            ///   returned.\n            /// - If the rounding mode is `Ceiling`, the smallest primitive float greater than or\n            ///   equal to the [`Float`] is returned. If the [`Float`] is greater than the maximum\n            ///   finite primitive float, then $\\infty$ is returned. If it is smaller than the\n            ///   minimum finite primitive float, then the minimum finite primitive float is\n            ///   returned. If it is between zero and the maximum negative primitive float, then\n            ///   negative zero is returned.\n            /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor` if the\n            ///   [`Float`] is non-negative and as with `Ceiling` if the [`Float`] is negative. If\n            ///   the [`Float`] is between the maximum negative primitive float and the minimum\n            ///   positive primitive float, then positive zero is returned when the [`Float`] is\n            ///   non-negative and negative zero otherwise.\n            /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling` if the\n            ///   [`Float`] is non-negative and as with `Floor` if the [`Float`] is negative. Zero\n            ///   is only returned when the [`Float`] is zero.\n            /// - If the rounding mode is `Nearest`, then the nearest primitive float is returned.\n            ///   If the [`Float`] is exactly between two primitive floats, the primitive float with\n            ///   the zero least-significant bit in its representation is selected. If the [`Float`]\n            ///   is greater than the maximum finite primitive float, then $\\infty$ is returned. If\n            ///   the [`Float`] is smaller than the minimum finite primitive float, then $-\\infty$\n            ///   is returned. If the [`Float`] is closer to zero than to any other primitive float\n            ///   (or if there is a tie between zero and another float), then positive or negative\n            ///   zero is returned, depending on the [`Float`]'s sign.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the [`Float`] is not exactly equal to any float of the target type, and\n            /// `rm` is `Exact`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_float#rounding_from).\n            #[inline]\n            fn rounding_from(f: &Float, rm: RoundingMode) -> ($t, Ordering) {\n                primitive_float_rounding_from_float_ref(f, rm)\n            }\n        }\n\n        impl TryFrom<Float> for $t {\n            type Error = FloatFromFloatError;\n\n            /// Converts a [`Float`] to a primitive float, taking the [`Float`] by value. If the\n            /// [`Float`] is not equal to a primitive float of the given type, an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_float#try_from).\n            #[inline]\n            fn try_from(f: Float) -> Result<$t, Self::Error> {\n                primitive_float_try_from_float(f)\n            }\n        }\n\n        impl TryFrom<&Float> for $t {\n            type Error = FloatFromFloatError;\n\n            /// Converts a [`Float`] to a primitive float, taking the [`Float`] by reference. If the\n            /// [`Float`] is not equal to a primitive float of the given type, an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_float#try_from).\n            #[inline]\n            fn try_from(f: &Float) -> Result<$t, Self::Error> {\n                primitive_float_try_from_float_ref(f)\n            }\n        }\n\n        impl ConvertibleFrom<&Float> for $t {\n            /// Determines whether a [`Float`] can be converted to a primitive float, taking the\n            /// [`Float`] by reference.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_float#convertible_from).\n            #[inline]\n            fn convertible_from(f: &Float) -> bool {\n                primitive_float_convertible_from_float::<$t>(f)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_primitive_float_from);\n"
  },
  {
    "path": "malachite-float/src/conversion/primitive_int_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::arithmetic::is_power_of_2::float_is_signed_min;\nuse crate::{Float, significand_bits};\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, ShrRound};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::from::{SignedFromFloatError, UnsignedFromFloatError};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn unsigned_rounding_from_float<T: PrimitiveUnsigned>(f: Float, rm: RoundingMode) -> (T, Ordering)\nwhere\n    for<'a> T: TryFrom<&'a Natural>,\n{\n    match f {\n        float_nan!() => panic!(\"Can't convert NaN to {}\", T::NAME),\n        float_infinity!() => match rm {\n            Floor | Down | Nearest => (T::MAX, Less),\n            _ => panic!(\"Can't convert Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_negative_infinity!() => match rm {\n            Ceiling | Down | Nearest => (T::ZERO, Greater),\n            _ => panic!(\"Can't convert -Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_either_zero!() => (T::ZERO, Equal),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(exponent);\n            if !sign {\n                match rm {\n                    Ceiling | Down | Nearest => (T::ZERO, Greater),\n                    _ => panic!(\"Cannot convert negative Float to {} using {}\", T::NAME, rm),\n                }\n            } else if exponent < 0 {\n                match rm {\n                    Floor | Down | Nearest => (T::ZERO, Less),\n                    Ceiling | Up => (T::ONE, Greater),\n                    Exact => {\n                        panic!(\"Cannot convert Float to {} using {}\", T::NAME, rm)\n                    }\n                }\n            } else if exponent > i64::wrapping_from(T::WIDTH) {\n                match rm {\n                    Floor | Down | Nearest => (T::MAX, Less),\n                    _ => panic!(\"Cannot convert large Float to {} using {}\", T::NAME, rm),\n                }\n            } else {\n                let sb = significand_bits(&significand);\n                let eb = exponent.unsigned_abs();\n                let (n, o) = if sb >= eb {\n                    significand.shr_round(sb - eb, rm)\n                } else {\n                    (significand << (eb - sb), Equal)\n                };\n                let (n, o) = if let Ok(n) = T::try_from(&n) {\n                    (n, o)\n                } else {\n                    match rm {\n                        Floor | Down | Nearest => (T::MAX, Less),\n                        _ => panic!(\"Cannot convert large Float to {} using {}\", T::NAME, rm),\n                    }\n                };\n                (n, o)\n            }\n        }\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn unsigned_rounding_from_float_ref<T: PrimitiveUnsigned>(\n    f: &Float,\n    rm: RoundingMode,\n) -> (T, Ordering)\nwhere\n    for<'a> T: TryFrom<&'a Natural>,\n{\n    match f {\n        float_nan!() => panic!(\"Can't convert NaN to {}\", T::NAME),\n        float_infinity!() => match rm {\n            Floor | Down | Nearest => (T::MAX, Less),\n            _ => panic!(\"Can't convert Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_negative_infinity!() => match rm {\n            Ceiling | Down | Nearest => (T::ZERO, Greater),\n            _ => panic!(\"Can't convert -Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_either_zero!() => (T::ZERO, Equal),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(*exponent);\n            if !sign {\n                match rm {\n                    Ceiling | Down | Nearest => (T::ZERO, Greater),\n                    _ => panic!(\"Cannot convert negative Float to {} using {}\", T::NAME, rm),\n                }\n            } else if exponent < 0 {\n                match rm {\n                    Floor | Down | Nearest => (T::ZERO, Less),\n                    Ceiling | Up => (T::ONE, Greater),\n                    Exact => {\n                        panic!(\"Cannot convert Float to {} using {}\", T::NAME, rm)\n                    }\n                }\n            } else if exponent > i64::wrapping_from(T::WIDTH) {\n                match rm {\n                    Floor | Down | Nearest => (T::MAX, Less),\n                    _ => panic!(\"Cannot convert large Float to {} using {}\", T::NAME, rm),\n                }\n            } else {\n                let sb = significand_bits(significand);\n                let eb = exponent.unsigned_abs();\n                let (n, o) = if sb >= eb {\n                    significand.shr_round(sb - eb, rm)\n                } else {\n                    (significand << (eb - sb), Equal)\n                };\n                let (n, o) = if let Ok(n) = T::try_from(&n) {\n                    (n, o)\n                } else {\n                    match rm {\n                        Floor | Down | Nearest => (T::MAX, Less),\n                        _ => panic!(\"Cannot convert large Float to {} using {}\", T::NAME, rm),\n                    }\n                };\n                (n, o)\n            }\n        }\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn unsigned_try_from_float<T: PrimitiveUnsigned>(f: Float) -> Result<T, UnsignedFromFloatError>\nwhere\n    for<'a> T: WrappingFrom<&'a Natural>,\n{\n    match f {\n        float_either_zero!() => Ok(T::ZERO),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(exponent);\n            if !sign {\n                Err(UnsignedFromFloatError::FloatNegative)\n            } else if exponent <= 0 || exponent > i64::wrapping_from(T::WIDTH) {\n                Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n            } else {\n                let sb = significand_bits(&significand);\n                let eb = exponent.unsigned_abs();\n                let n = if sb >= eb {\n                    let bits = sb - eb;\n                    if significand.divisible_by_power_of_2(bits) {\n                        Ok(significand >> bits)\n                    } else {\n                        Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                    }\n                } else {\n                    Ok(significand << (eb - sb))\n                };\n                n.map(|n| T::wrapping_from(&n))\n            }\n        }\n        _ => Err(UnsignedFromFloatError::FloatInfiniteOrNan),\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn unsigned_try_from_float_ref<T: PrimitiveUnsigned>(f: &Float) -> Result<T, UnsignedFromFloatError>\nwhere\n    for<'a> T: WrappingFrom<&'a Natural>,\n{\n    match f {\n        float_either_zero!() => Ok(T::ZERO),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(*exponent);\n            if !sign {\n                Err(UnsignedFromFloatError::FloatNegative)\n            } else if exponent <= 0 || exponent > i64::wrapping_from(T::WIDTH) {\n                Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n            } else {\n                let sb = significand_bits(significand);\n                let eb = exponent.unsigned_abs();\n                let n = if sb >= eb {\n                    let bits = sb - eb;\n                    if significand.divisible_by_power_of_2(bits) {\n                        Ok(significand >> bits)\n                    } else {\n                        Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                    }\n                } else {\n                    Ok(significand << (eb - sb))\n                };\n                n.map(|n| T::wrapping_from(&n))\n            }\n        }\n        _ => Err(UnsignedFromFloatError::FloatInfiniteOrNan),\n    }\n}\n\nfn unsigned_convertible_from_float<T: PrimitiveUnsigned>(f: &Float) -> bool {\n    match f {\n        float_either_zero!() => true,\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(*exponent);\n            *sign && exponent > 0 && exponent <= i64::wrapping_from(T::WIDTH) && {\n                let sb = significand_bits(significand);\n                let eb = exponent.unsigned_abs();\n                sb < eb || significand.divisible_by_power_of_2(sb - eb)\n            }\n        }\n        _ => false,\n    }\n}\n\nmacro_rules! impl_unsigned_from {\n    ($t: ident) => {\n        impl RoundingFrom<Float> for $t {\n            /// Converts a [`Float`] to an unsigned primitive integer, using a specified\n            /// [`RoundingMode`] and taking the [`Float`] by value. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the original value.\n            ///\n            /// If the [`Float`] is negative (including $-\\infty$), then it will be rounded to zero\n            /// when the [`RoundingMode`] is `Ceiling`, `Down`, or `Nearest`. Otherwise, this\n            /// function will panic.\n            ///\n            /// If the [`Float`] is greater than the maximum representable value of the unsigned\n            /// type (including $\\infty$), then it will be rounded to the maximum value when the\n            /// [`RoundingMode`] is `Floor`, `Down`, or `Nearest`. Otherwise, this function will\n            /// panic.\n            ///\n            /// If the [`Float`] is NaN, the function will panic regardless of the rounding mode.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`]\n            /// is less than zero and `rm` is not `Down`, `Ceiling`, or `Nearest`, if the [`Float`]\n            /// is greater than the maximum representable value of the unsigned type and `rm` is not\n            /// `Down`, `Floor`, or `Nearest`, or if the [`Float`] is NaN.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#rounding_from).\n            #[inline]\n            fn rounding_from(f: Float, rm: RoundingMode) -> ($t, Ordering) {\n                unsigned_rounding_from_float(f, rm)\n            }\n        }\n\n        impl RoundingFrom<&Float> for $t {\n            /// Converts a [`Float`] to an unsigned primitive integer, using a specified\n            /// [`RoundingMode`] and taking the [`Float`] by reference. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the original value.\n            ///\n            /// If the [`Float`] is negative (including $-\\infty$), then it will be rounded to zero\n            /// when the [`RoundingMode`] is `Ceiling`, `Down`, or `Nearest`. Otherwise, this\n            /// function will panic.\n            ///\n            /// If the [`Float`] is greater than the maximum representable value of the unsigned\n            /// type (including $\\infty$), then it will be rounded to the maximum value when the\n            /// [`RoundingMode`] is `Floor`, `Down`, or `Nearest`. Otherwise, this function will\n            /// panic.\n            ///\n            /// If the [`Float`] is NaN, the function will panic regardless of the rounding mode.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`]\n            /// is less than zero and `rm` is not `Down`, `Ceiling`, or `Nearest`, if the [`Float`]\n            /// is greater than the maximum representable value of the unsigned type and `rm` is not\n            /// `Down`, `Floor`, or `Nearest`, or if the [`Float`] is NaN.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#rounding_from).\n            #[inline]\n            fn rounding_from(f: &Float, rm: RoundingMode) -> ($t, Ordering) {\n                unsigned_rounding_from_float_ref(f, rm)\n            }\n        }\n\n        impl TryFrom<Float> for $t {\n            type Error = UnsignedFromFloatError;\n\n            /// Converts a [`Float`] to a primitive unsigned integer, taking the [`Float`] by value.\n            /// If the [`Float`] is not equal to an unsigned primitive integer of the given type, an\n            /// error is returned.\n            ///\n            /// Both positive and negative zero convert to a primitive unsigned integer zero.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#try_from).\n            #[inline]\n            fn try_from(f: Float) -> Result<$t, Self::Error> {\n                unsigned_try_from_float(f)\n            }\n        }\n\n        impl TryFrom<&Float> for $t {\n            type Error = UnsignedFromFloatError;\n\n            /// Converts a [`Float`] to a primitive unsigned integer, taking the [`Float`] by\n            /// reference. If the [`Float`] is not equal to an unsigned primitive integer of the\n            /// given type, an error is returned.\n            ///\n            /// Both positive and negative zero convert to a primitive unsigned integer zero.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#try_from).\n            #[inline]\n            fn try_from(f: &Float) -> Result<$t, Self::Error> {\n                unsigned_try_from_float_ref(f)\n            }\n        }\n\n        impl ConvertibleFrom<&Float> for $t {\n            /// Determines whether a [`Float`] can be converted to an unsigned primitive integer,\n            /// taking the [`Float`] by reference.\n            ///\n            /// Both positive and negative zero are convertible to any unsigned primitive integer.\n            /// (Although negative zero is nominally negative, the real number it represents is\n            /// zero, which is not negative.)\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#convertible_from).\n            #[inline]\n            fn convertible_from(f: &Float) -> bool {\n                unsigned_convertible_from_float::<$t>(f)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned_from);\n\n#[allow(clippy::trait_duplication_in_bounds, clippy::type_repetition_in_bounds)]\nfn signed_rounding_from_float<T: PrimitiveSigned>(f: Float, rm: RoundingMode) -> (T, Ordering)\nwhere\n    for<'a> T: TryFrom<&'a Natural> + TryFrom<&'a Integer>,\n{\n    match f {\n        float_nan!() => panic!(\"Can't convert NaN to {}\", T::NAME),\n        float_infinity!() => match rm {\n            Floor | Down | Nearest => (T::MAX, Less),\n            _ => panic!(\"Can't convert Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_negative_infinity!() => match rm {\n            Ceiling | Down | Nearest => (T::MIN, Greater),\n            _ => panic!(\"Can't convert -Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_either_zero!() => (T::ZERO, Equal),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(exponent);\n            if sign {\n                if exponent < 0 {\n                    match rm {\n                        Floor | Down | Nearest => (T::ZERO, Less),\n                        Ceiling | Up => (T::ONE, Greater),\n                        Exact => {\n                            panic!(\"Cannot convert Float to Integer using {rm}\")\n                        }\n                    }\n                } else if exponent >= i64::wrapping_from(T::WIDTH) {\n                    match rm {\n                        Floor | Down | Nearest => (T::MAX, Less),\n                        _ => {\n                            panic!(\"Cannot convert Float to Integer using {rm}\")\n                        }\n                    }\n                } else {\n                    let sb = significand_bits(&significand);\n                    let eb = exponent.unsigned_abs();\n                    let (n, o) = if sb >= eb {\n                        significand.shr_round(sb - eb, rm)\n                    } else {\n                        (significand << (eb - sb), Equal)\n                    };\n                    let (n, o) = if let Ok(n) = T::try_from(&n) {\n                        (n, o)\n                    } else {\n                        match rm {\n                            Floor | Down | Nearest => (T::MAX, Less),\n                            _ => {\n                                panic!(\"Cannot convert large Float to {} using {}\", T::NAME, rm)\n                            }\n                        }\n                    };\n                    (n, o)\n                }\n            } else if exponent < 0 {\n                match rm {\n                    Ceiling | Down | Nearest => (T::ZERO, Greater),\n                    Floor | Up => (T::NEGATIVE_ONE, Less),\n                    Exact => {\n                        panic!(\"Cannot convert Float to Integer using {rm}\")\n                    }\n                }\n            } else if exponent > i64::wrapping_from(T::WIDTH) {\n                // This doesn't catch the case where -2^(W+1) < x < -2^W, but that's ok because the\n                // next else block handles it.\n                match rm {\n                    Ceiling | Down | Nearest => (T::MIN, Greater),\n                    _ => {\n                        panic!(\"Cannot convert Float to Integer using {rm}\")\n                    }\n                }\n            } else {\n                let sb = significand_bits(&significand);\n                let eb = exponent.unsigned_abs();\n                let (n, o) = if sb >= eb {\n                    significand.shr_round(sb - eb, -rm)\n                } else {\n                    (significand << (eb - sb), Equal)\n                };\n                let (n, o) = if let Ok(n) = T::try_from(&-n) {\n                    (n, o.reverse())\n                } else {\n                    match rm {\n                        Ceiling | Down | Nearest => (T::MIN, Greater),\n                        _ => panic!(\n                            \"Cannot convert large negative Float to {} using {}\",\n                            T::NAME,\n                            rm\n                        ),\n                    }\n                };\n                (n, o)\n            }\n        }\n    }\n}\n\n#[allow(clippy::trait_duplication_in_bounds, clippy::type_repetition_in_bounds)]\nfn signed_rounding_from_float_ref<T: PrimitiveSigned>(f: &Float, rm: RoundingMode) -> (T, Ordering)\nwhere\n    for<'a> T: TryFrom<&'a Natural> + TryFrom<&'a Integer>,\n{\n    match f {\n        float_nan!() => panic!(\"Can't convert NaN to {}\", T::NAME),\n        float_infinity!() => match rm {\n            Floor | Down | Nearest => (T::MAX, Less),\n            _ => panic!(\"Can't convert Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_negative_infinity!() => match rm {\n            Ceiling | Down | Nearest => (T::MIN, Greater),\n            _ => panic!(\"Can't convert -Infinity to {} using {}\", T::NAME, rm),\n        },\n        float_either_zero!() => (T::ZERO, Equal),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(*exponent);\n            if *sign {\n                if exponent < 0 {\n                    match rm {\n                        Floor | Down | Nearest => (T::ZERO, Less),\n                        Ceiling | Up => (T::ONE, Greater),\n                        Exact => {\n                            panic!(\"Cannot convert Float to Integer using {rm}\")\n                        }\n                    }\n                } else if exponent >= i64::wrapping_from(T::WIDTH) {\n                    match rm {\n                        Floor | Down | Nearest => (T::MAX, Less),\n                        _ => {\n                            panic!(\"Cannot convert Float to Integer using {rm}\")\n                        }\n                    }\n                } else {\n                    let sb = significand_bits(significand);\n                    let eb = exponent.unsigned_abs();\n                    let (n, o) = if sb >= eb {\n                        significand.shr_round(sb - eb, rm)\n                    } else {\n                        (significand << (eb - sb), Equal)\n                    };\n                    let (n, o) = if let Ok(n) = T::try_from(&n) {\n                        (n, o)\n                    } else {\n                        match rm {\n                            Floor | Down | Nearest => (T::MAX, Less),\n                            _ => {\n                                panic!(\"Cannot convert large Float to {} using {}\", T::NAME, rm)\n                            }\n                        }\n                    };\n                    (n, o)\n                }\n            } else if exponent < 0 {\n                match rm {\n                    Ceiling | Down | Nearest => (T::ZERO, Greater),\n                    Floor | Up => (T::NEGATIVE_ONE, Less),\n                    Exact => {\n                        panic!(\"Cannot convert Float to Integer using {rm}\")\n                    }\n                }\n            } else if exponent > i64::wrapping_from(T::WIDTH) {\n                // This doesn't catch the case where -2^(W+1) < x < -2^W, but that's ok because the\n                // next else block handles it.\n                match rm {\n                    Ceiling | Down | Nearest => (T::MIN, Greater),\n                    _ => {\n                        panic!(\"Cannot convert Float to Integer using {rm}\")\n                    }\n                }\n            } else {\n                let sb = significand_bits(significand);\n                let eb = exponent.unsigned_abs();\n                let (n, o) = if sb >= eb {\n                    significand.shr_round(sb - eb, -rm)\n                } else {\n                    (significand << (eb - sb), Equal)\n                };\n                let (n, o) = if let Ok(n) = T::try_from(&-n) {\n                    (n, o.reverse())\n                } else {\n                    match rm {\n                        Ceiling | Down | Nearest => (T::MIN, Greater),\n                        _ => panic!(\n                            \"Cannot convert large negative Float to {} using {}\",\n                            T::NAME,\n                            rm\n                        ),\n                    }\n                };\n                (n, o)\n            }\n        }\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn signed_try_from_float<T: PrimitiveSigned>(f: Float) -> Result<T, SignedFromFloatError>\nwhere\n    for<'a> T: TryFrom<&'a Integer>,\n{\n    match f {\n        float_either_zero!() => Ok(T::ZERO),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(exponent);\n            if exponent <= 0\n                || (sign && exponent >= i64::wrapping_from(T::WIDTH)\n                    || !sign && exponent > i64::wrapping_from(T::WIDTH))\n            {\n                Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n            } else {\n                let sb = significand_bits(&significand);\n                let eb = exponent.unsigned_abs();\n                let i = Integer::from_sign_and_abs(\n                    sign,\n                    if sb >= eb {\n                        let bits = sb - eb;\n                        if significand.divisible_by_power_of_2(bits) {\n                            significand >> bits\n                        } else {\n                            return Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange);\n                        }\n                    } else {\n                        significand << (eb - sb)\n                    },\n                );\n                T::try_from(&i).map_err(|_| SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n            }\n        }\n        _ => Err(SignedFromFloatError::FloatInfiniteOrNan),\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn signed_try_from_float_ref<T: PrimitiveSigned>(f: &Float) -> Result<T, SignedFromFloatError>\nwhere\n    for<'a> T: TryFrom<&'a Integer>,\n{\n    match f {\n        float_either_zero!() => Ok(T::ZERO),\n        Float(Finite {\n            sign,\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(*exponent);\n            if exponent <= 0\n                || (*sign && exponent >= i64::wrapping_from(T::WIDTH)\n                    || !*sign && exponent > i64::wrapping_from(T::WIDTH))\n            {\n                Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n            } else {\n                let sb = significand_bits(significand);\n                let eb = exponent.unsigned_abs();\n                let i = Integer::from_sign_and_abs(\n                    *sign,\n                    if sb >= eb {\n                        let bits = sb - eb;\n                        if significand.divisible_by_power_of_2(bits) {\n                            significand >> bits\n                        } else {\n                            return Err(SignedFromFloatError::FloatNonIntegerOrOutOfRange);\n                        }\n                    } else {\n                        significand << (eb - sb)\n                    },\n                );\n                T::try_from(&i).map_err(|_| SignedFromFloatError::FloatNonIntegerOrOutOfRange)\n            }\n        }\n        _ => Err(SignedFromFloatError::FloatInfiniteOrNan),\n    }\n}\n\nfn signed_convertible_from_float<T: PrimitiveSigned>(f: &Float) -> bool {\n    match f {\n        float_either_zero!() => true,\n        Float(Finite {\n            exponent,\n            significand,\n            ..\n        }) => {\n            let exponent = i64::from(*exponent);\n            if exponent <= 0 {\n                return false;\n            }\n            if exponent >= i64::wrapping_from(T::WIDTH) {\n                float_is_signed_min::<T>(f)\n            } else {\n                let sb = significand_bits(significand);\n                let eb = exponent.unsigned_abs();\n                sb < eb || significand.divisible_by_power_of_2(sb - eb)\n            }\n        }\n        _ => false,\n    }\n}\n\nmacro_rules! impl_signed_from {\n    ($t: ident) => {\n        impl RoundingFrom<Float> for $t {\n            /// Converts a [`Float`] to a signed primitive integer, using a specified\n            /// [`RoundingMode`] and taking the [`Float`] by value. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the original value.\n            ///\n            /// If the [`Float`] is less than the minimum representable value of the signed type\n            /// (including $-\\infty$), then it will be rounded to zero when the [`RoundingMode`] is\n            /// `Ceiling`, `Down`, or `Nearest`. Otherwise, this function will panic.\n            ///\n            /// If the [`Float`] is greater than the maximum representable value of the signed type\n            /// (including $\\infty$), then it will be rounded to the maximum value when the\n            /// [`RoundingMode`] is `Floor`, `Down`, or `Nearest`. Otherwise, this function will\n            /// panic.\n            ///\n            /// If the [`Float`] is NaN, the function will panic regardless of the rounding mode.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`]\n            /// is smaller than the minimum representable value of the signed type and `rm` is not\n            /// `Down`, `Ceiling`, or `Nearest`, if the [`Float`] is greater than the maximum\n            /// representable value of the signed type and `rm` is not `Down`, `Floor`, or\n            /// `Nearest`, or if the [`Float`] is NaN.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#rounding_from).\n            #[inline]\n            fn rounding_from(f: Float, rm: RoundingMode) -> ($t, Ordering) {\n                signed_rounding_from_float(f, rm)\n            }\n        }\n\n        impl RoundingFrom<&Float> for $t {\n            /// Converts a [`Float`] to a signed primitive integer, using a specified\n            /// [`RoundingMode`] and taking the [`Float`] by reference. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the original value.\n            ///\n            /// If the [`Float`] is less than the minimum representable value of the signed type\n            /// (including $-\\infty$), then it will be rounded to zero when the [`RoundingMode`] is\n            /// `Ceiling`, `Down`, or `Nearest`. Otherwise, this function will panic.\n            ///\n            /// If the [`Float`] is greater than the maximum representable value of the signed type\n            /// (including $\\infty$), then it will be rounded to the maximum value when the\n            /// [`RoundingMode`] is `Floor`, `Down`, or `Nearest`. Otherwise, this function will\n            /// panic.\n            ///\n            /// If the [`Float`] is NaN, the function will panic regardless of the rounding mode.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Panics\n            /// Panics if the [`Float`] is not an integer and `rm` is `Exact`, or if the [`Float`]\n            /// is smaller than the minimum representable value of the signed type and `rm` is not\n            /// `Down`, `Ceiling`, or `Nearest`, if the [`Float`] is greater than the maximum\n            /// representable value of the signed type and `rm` is not `Down`, `Floor`, or\n            /// `Nearest`, or if the [`Float`] is NaN.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#rounding_from).\n            #[inline]\n            fn rounding_from(f: &Float, rm: RoundingMode) -> ($t, Ordering) {\n                signed_rounding_from_float_ref(f, rm)\n            }\n        }\n\n        impl TryFrom<Float> for $t {\n            type Error = SignedFromFloatError;\n\n            /// Converts a [`Float`] to a primitive signed integer, taking the [`Float`] by value.\n            /// If the [`Float`] is not equal to a signed primitive integer of the given type, an\n            /// error is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#try_from).\n            #[inline]\n            fn try_from(f: Float) -> Result<$t, Self::Error> {\n                signed_try_from_float(f)\n            }\n        }\n\n        impl TryFrom<&Float> for $t {\n            type Error = SignedFromFloatError;\n\n            /// Converts a [`Float`] to a primitive signed integer, taking the [`Float`] by\n            /// reference. If the [`Float`] is not equal to a signed primitive integer of the given\n            /// type, an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#try_from).\n            #[inline]\n            fn try_from(f: &Float) -> Result<$t, Self::Error> {\n                signed_try_from_float_ref(f)\n            }\n        }\n\n        impl ConvertibleFrom<&Float> for $t {\n            /// Determines whether a [`Float`] can be converted to a signed primitive integer,\n            /// taking the [`Float`] by reference.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_float#convertible_from).\n            #[inline]\n            fn convertible_from(f: &Float) -> bool {\n                signed_convertible_from_float::<$t>(f)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed_from);\n"
  },
  {
    "path": "malachite-float/src/conversion/rational_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Zero};\nuse crate::{Float, significand_bits};\nuse malachite_base::num::basic::traits::Zero as ZeroTrait;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct RationalFromFloatError;\n\nimpl TryFrom<Float> for Rational {\n    type Error = RationalFromFloatError;\n\n    /// Converts a [`Float`] to a [`Rational`], taking the [`Float`] by value. If the [`Float`] is\n    /// not finite, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.complexity()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_float::conversion::rational_from_float::RationalFromFloatError;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::try_from(Float::ZERO).unwrap(), 0);\n    /// assert_eq!(\n    ///     Rational::try_from(Float::from(1.5)).unwrap().to_string(),\n    ///     \"3/2\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::try_from(Float::from(-1.5)).unwrap().to_string(),\n    ///     \"-3/2\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Rational::try_from(Float::INFINITY),\n    ///     Err(RationalFromFloatError)\n    /// );\n    /// assert_eq!(Rational::try_from(Float::NAN), Err(RationalFromFloatError));\n    /// ```\n    fn try_from(x: Float) -> Result<Self, Self::Error> {\n        match x {\n            float_either_zero!() => Ok(Self::ZERO),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                let bits = significand_bits(&significand);\n                Ok(Self::from(Integer::from_sign_and_abs(sign, significand))\n                    << (i128::from(exponent) - i128::from(bits)))\n            }\n            _ => Err(RationalFromFloatError),\n        }\n    }\n}\n\nimpl TryFrom<&Float> for Rational {\n    type Error = RationalFromFloatError;\n\n    /// Converts a [`Float`] to a [`Rational`], taking the [`Float`] by reference. If the [`Float`]\n    /// is not finite, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.complexity()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_float::conversion::rational_from_float::RationalFromFloatError;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::try_from(&Float::ZERO).unwrap(), 0);\n    /// assert_eq!(\n    ///     Rational::try_from(&Float::from(1.5)).unwrap().to_string(),\n    ///     \"3/2\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::try_from(&Float::from(-1.5)).unwrap().to_string(),\n    ///     \"-3/2\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Rational::try_from(&Float::INFINITY),\n    ///     Err(RationalFromFloatError)\n    /// );\n    /// assert_eq!(Rational::try_from(&Float::NAN), Err(RationalFromFloatError));\n    /// ```\n    fn try_from(x: &Float) -> Result<Self, Self::Error> {\n        match x {\n            float_either_zero!() => Ok(Self::ZERO),\n            Float(Finite {\n                sign,\n                exponent,\n                significand,\n                ..\n            }) => {\n                let bits = significand_bits(significand);\n                Ok(\n                    Self::from(Integer::from_sign_and_abs_ref(*sign, significand))\n                        << (i128::from(*exponent) - i128::from(bits)),\n                )\n            }\n            _ => Err(RationalFromFloatError),\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Float> for Rational {\n    /// Determines whether a [`Float`] can be converted to a [`Rational`] (which is when the\n    /// [`Float`] is finite), taking the [`Float`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Infinity, NaN, Zero};\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_float::Float;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::convertible_from(&Float::ZERO), true);\n    /// assert_eq!(Rational::convertible_from(&Float::from(123.0)), true);\n    /// assert_eq!(Rational::convertible_from(&Float::from(-123.0)), true);\n    /// assert_eq!(Rational::convertible_from(&Float::from(1.5)), true);\n    ///\n    /// assert_eq!(Rational::convertible_from(&Float::INFINITY), false);\n    /// assert_eq!(Rational::convertible_from(&Float::NAN), false);\n    /// ```\n    #[inline]\n    fn convertible_from(x: &Float) -> bool {\n        x.is_finite()\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse alloc::string::{String, ToString};\nuse core::str::FromStr;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::num::conversion::traits::{FromSciString, FromStringBase};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_q::Rational;\n\nfn reduce_exponent_in_hex_string(s: &str) -> Option<(String, i32)> {\n    if let Some(exp_index) = s.find('E') {\n        let tail = &s[exp_index + 1..];\n        let hash_index = tail.find('#').unwrap();\n        let tail = &tail[..hash_index];\n        let original_exponent = i32::from_str(tail).unwrap();\n        if original_exponent.unsigned_abs() < 20 {\n            return None;\n        }\n        let mut new_s = s[..=exp_index].to_string();\n        new_s += \"+20\";\n        new_s += &s[exp_index + hash_index + 1..];\n        Some((new_s, (original_exponent << 2) - 80))\n    } else {\n        None\n    }\n}\n\nfn from_hex_string(s: &str) -> Float {\n    match s {\n        \"NaN\" => Float::NAN,\n        \"Infinity\" => Float::INFINITY,\n        \"-Infinity\" => Float::NEGATIVE_INFINITY,\n        \"0x0.0\" => Float::ZERO,\n        \"-0x0.0\" => Float::NEGATIVE_ZERO,\n        s => {\n            let (s, sign) = if let Some(s) = s.strip_prefix('-') {\n                (s, false)\n            } else {\n                (s, true)\n            };\n            let s = s.strip_prefix(\"0x\").unwrap();\n            let hash_index = s.find('#').unwrap();\n            let precision = u64::from_str(&s[hash_index + 1..]).unwrap();\n            let mut options = FromSciStringOptions::default();\n            options.set_base(16);\n            let x = if let Some((alt_s, exp_offset)) = reduce_exponent_in_hex_string(s) {\n                let hash_index = alt_s.find('#').unwrap();\n                Float::from_rational_prec_round(\n                    Rational::from_sci_string_with_options(&alt_s[..hash_index], options).unwrap(),\n                    precision,\n                    Exact,\n                )\n                .0 << exp_offset\n            } else {\n                Float::from_rational_prec_round(\n                    Rational::from_sci_string_with_options(&s[..hash_index], options).unwrap(),\n                    precision,\n                    Exact,\n                )\n                .0\n            };\n            if sign { x } else { -x }\n        }\n    }\n}\n\nimpl FromStringBase for Float {\n    fn from_string_base(base: u8, s: &str) -> Option<Self> {\n        assert_eq!(base, 16);\n        Some(from_hex_string(s))\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod from_string;\npub mod to_string;\n"
  },
  {
    "path": "malachite-float/src/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::alloc::string::ToString;\nuse crate::{ComparableFloat, ComparableFloatRef, Float};\nuse alloc::string::String;\nuse core::fmt::{Debug, Display, Formatter, LowerHex, Result, Write};\nuse malachite_base::num::arithmetic::traits::{\n    Abs, ModPowerOf2, RoundToMultipleOfPowerOf2, ShrRound,\n};\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::traits::{ExactFrom, ToSci, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_q::Rational;\n\nfn replace_exponent_in_hex_string(s: &str, new_exponent: i32) -> String {\n    let exp_index = s.find('E').unwrap_or_else(|| panic!(\"{s}\"));\n    let mut new_s = s[..exp_index].to_string();\n    if new_exponent > 0 {\n        write!(new_s, \"E+{new_exponent}\").unwrap();\n    } else {\n        write!(new_s, \"E{new_exponent}\").unwrap();\n    }\n    new_s\n}\n\nimpl Display for Float {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match self {\n            float_nan!() => write!(f, \"NaN\"),\n            float_infinity!() => write!(f, \"Infinity\"),\n            float_negative_infinity!() => write!(f, \"-Infinity\"),\n            float_zero!() => write!(f, \"0.0\"),\n            float_negative_zero!() => write!(f, \"-0.0\"),\n            _ => {\n                let exp = self.get_exponent().unwrap();\n                if exp.unsigned_abs() > 10000 {\n                    // The current slow implementation would take forever to try to convert a Float\n                    // with a very large or small exponent to a decimal string. Best to\n                    // short-circuit it for now.\n                    if *self < 0u32 {\n                        write!(f, \"-\")?;\n                    }\n                    return write!(f, \"{}\", if exp >= 0 { \"too_big\" } else { \"too_small\" });\n                }\n                let mut lower = self.clone();\n                let mut higher = self.clone();\n                lower.decrement();\n                higher.increment();\n                let self_q = Rational::exact_from(self);\n                let lower_q = Rational::exact_from(lower);\n                let higher_q = Rational::exact_from(higher);\n                let mut options = ToSciOptions::default();\n                for precision in 1.. {\n                    options.set_precision(precision);\n                    let s = self_q.to_sci_with_options(options).to_string();\n                    let s_lower = lower_q.to_sci_with_options(options).to_string();\n                    let s_higher = higher_q.to_sci_with_options(options).to_string();\n                    if s != s_lower && s != s_higher {\n                        return if s.contains('.') {\n                            write!(f, \"{s}\")\n                        } else if let Some(i) = s.find('e') {\n                            write!(f, \"{}.0e{}\", &s[..i], &s[i + 1..])\n                        } else {\n                            write!(f, \"{s}.0\")\n                        };\n                    }\n                }\n                panic!();\n            }\n        }\n    }\n}\n\nimpl Debug for Float {\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n\nimpl LowerHex for Float {\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match self {\n            float_zero!() => f.write_str(if f.alternate() { \"0x0.0\" } else { \"0.0\" }),\n            float_negative_zero!() => f.write_str(if f.alternate() { \"-0x0.0\" } else { \"-0.0\" }),\n            Self(Finite {\n                exponent,\n                precision,\n                ..\n            }) => {\n                if self.is_sign_negative() {\n                    f.write_char('-')?;\n                }\n                let mut options = ToSciOptions::default();\n                options.set_base(16);\n                let m = u64::from(exponent.mod_power_of_2(2));\n                let mut p = precision.saturating_sub(m).shr_round(2, Ceiling).0;\n                if m != 0 {\n                    p += 1;\n                }\n                options.set_precision(p);\n                options.set_e_uppercase();\n                options.set_include_trailing_zeros(true);\n                if f.alternate() {\n                    f.write_str(\"0x\")?;\n                }\n                let pr = precision.round_to_multiple_of_power_of_2(5, Up).0;\n                let s = if u64::from(exponent.unsigned_abs()) > (pr << 2) {\n                    let new_exponent = if *exponent > 0 {\n                        i32::exact_from(pr << 1)\n                    } else {\n                        -i32::exact_from(pr << 1)\n                    } + i32::wrapping_from(exponent.mod_power_of_2(2));\n                    let mut s = Rational::exact_from(self >> (exponent - new_exponent))\n                        .abs()\n                        .to_sci_with_options(options)\n                        .to_string();\n                    s = replace_exponent_in_hex_string(&s, (exponent - 1).shr_round(2, Floor).0);\n                    s\n                } else {\n                    Rational::exact_from(self)\n                        .abs()\n                        .to_sci_with_options(options)\n                        .to_string()\n                };\n                if s.contains('.') {\n                    write!(f, \"{s}\")\n                } else if let Some(i) = s.find('E') {\n                    write!(f, \"{}.0E{}\", &s[..i], &s[i + 1..])\n                } else {\n                    write!(f, \"{s}.0\")\n                }\n            }\n            _ => Display::fmt(&self, f),\n        }\n    }\n}\n\nimpl Display for ComparableFloat {\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(&ComparableFloatRef(&self.0), f)\n    }\n}\n\nimpl Debug for ComparableFloat {\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Debug::fmt(&ComparableFloatRef(&self.0), f)\n    }\n}\n\nimpl LowerHex for ComparableFloat {\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        LowerHex::fmt(&ComparableFloatRef(&self.0), f)\n    }\n}\n\nimpl Display for ComparableFloatRef<'_> {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if let x @ Float(Finite { precision, .. }) = &self.0 {\n            write!(f, \"{x}\")?;\n            f.write_char('#')?;\n            write!(f, \"{precision}\")\n        } else {\n            Display::fmt(&self.0, f)\n        }\n    }\n}\n\nimpl LowerHex for ComparableFloatRef<'_> {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if let x @ Float(Finite { precision, .. }) = &self.0 {\n            if f.alternate() {\n                write!(f, \"{x:#x}\")?;\n            } else {\n                write!(f, \"{x:x}\")?;\n            }\n            f.write_char('#')?;\n            write!(f, \"{precision}\")\n        } else {\n            LowerHex::fmt(&self.0, f)\n        }\n    }\n}\n\nimpl Debug for ComparableFloatRef<'_> {\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse alloc::vec::IntoIter;\nuse core::iter::{Chain, Once, once};\nuse core::mem::swap;\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\nuse malachite_base::num::arithmetic::traits::{NegModPowerOf2, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::exhaustive::{\n    ExhaustiveSignedRange, PrimitiveIntIncreasingRange, exhaustive_signed_inclusive_range,\n    primitive_int_increasing_inclusive_range,\n};\nuse malachite_base::num::iterators::{BitDistributorSequence, bit_distributor_sequence};\nuse malachite_base::num::logic::traits::{LowMask, NotAssign};\nuse malachite_base::tuples::exhaustive::{\n    ExhaustiveDependentPairs, ExhaustiveDependentPairsYsGenerator, LexDependentPairs,\n    exhaustive_dependent_pairs, lex_dependent_pairs,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::{\n    ExhaustiveNaturalRange, exhaustive_natural_inclusive_range,\n};\nuse malachite_nz::platform::Limb;\n\n/// Generates all finite positive [`Float`]s with a specified `sci_exponent` (one less than the raw\n/// exponent) and precision.\n///\n/// This `struct` is created by [`exhaustive_positive_floats_with_sci_exponent_and_precision`]; see\n/// its documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustivePositiveFloatsWithSciExponentAndPrecision {\n    exponent: i32,\n    precision: u64,\n    shift: u64,\n    significands: ExhaustiveNaturalRange,\n}\n\nimpl Iterator for ExhaustivePositiveFloatsWithSciExponentAndPrecision {\n    type Item = Float;\n\n    fn next(&mut self) -> Option<Float> {\n        self.significands.next().map(|s| {\n            Float(Finite {\n                sign: true,\n                exponent: self.exponent,\n                precision: self.precision,\n                significand: s << self.shift,\n            })\n        })\n    }\n}\n\n/// Generates all finite positive [`Float`]s with a specified `sci_exponent` (one less than the raw\n/// exponent) and precision.\n///\n/// Positive and negative zero are both excluded.\n///\n/// A finite positive [`Float`] may be uniquely expressed as $x = m_s2^e_s$, where $1 \\leq m_s < 2$\n/// and $e_s$ is an integer; then $e_s$ is the sci-exponent.\n///\n/// The output length is $2^{p-1}$.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n///\n/// # Panics\n/// Panics if the precision is zero.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_positive_floats_with_sci_exponent_and_precision;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_positive_floats_with_sci_exponent_and_precision(0, 4)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\"1.0#4\", \"1.1#4\", \"1.2#4\", \"1.4#4\", \"1.5#4\", \"1.6#4\", \"1.8#4\", \"1.9#4\"]\n/// );\n///\n/// assert_eq!(\n///     exhaustive_positive_floats_with_sci_exponent_and_precision(2, 5)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"4.0#5\", \"4.2#5\", \"4.5#5\", \"4.8#5\", \"5.0#5\", \"5.2#5\", \"5.5#5\", \"5.8#5\", \"6.0#5\",\n///         \"6.2#5\", \"6.5#5\", \"6.8#5\", \"7.0#5\", \"7.2#5\", \"7.5#5\", \"7.8#5\"\n///     ]\n/// );\n/// ```\npub fn exhaustive_positive_floats_with_sci_exponent_and_precision(\n    sci_exponent: i32,\n    prec: u64,\n) -> ExhaustivePositiveFloatsWithSciExponentAndPrecision {\n    assert!(sci_exponent < Float::MAX_EXPONENT);\n    assert!(sci_exponent >= Float::MIN_EXPONENT - 1);\n    assert_ne!(prec, 0);\n    ExhaustivePositiveFloatsWithSciExponentAndPrecision {\n        exponent: sci_exponent + 1,\n        precision: prec,\n        shift: prec.neg_mod_power_of_2(Limb::LOG_WIDTH),\n        significands: exhaustive_natural_inclusive_range(\n            Natural::power_of_2(prec - 1),\n            Natural::low_mask(prec),\n        ),\n    }\n}\n\n#[derive(Clone, Debug)]\nstruct FloatsWithSciExponentAndPrecisionGenerator {\n    sci_exponent: i32,\n}\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        Float,\n        ExhaustivePositiveFloatsWithSciExponentAndPrecision,\n    > for FloatsWithSciExponentAndPrecisionGenerator\n{\n    #[inline]\n    fn get_ys(&self, &prec: &u64) -> ExhaustivePositiveFloatsWithSciExponentAndPrecision {\n        exhaustive_positive_floats_with_sci_exponent_and_precision(self.sci_exponent, prec)\n    }\n}\n\n#[inline]\nfn exhaustive_positive_floats_with_sci_exponent_helper(\n    sci_exponent: i32,\n) -> LexDependentPairs<\n    u64,\n    Float,\n    FloatsWithSciExponentAndPrecisionGenerator,\n    PrimitiveIntIncreasingRange<u64>,\n    ExhaustivePositiveFloatsWithSciExponentAndPrecision,\n> {\n    lex_dependent_pairs(\n        primitive_int_increasing_inclusive_range(1, u64::MAX),\n        FloatsWithSciExponentAndPrecisionGenerator { sci_exponent },\n    )\n}\n\n/// Generates all finite positive [`Float`]s with a specified `sci_exponent` (one less than the raw\n/// exponent).\n///\n/// This `struct` is created by [`exhaustive_positive_floats_with_sci_exponent`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustivePositiveFloatsWithSciExponent(\n    LexDependentPairs<\n        u64,\n        Float,\n        FloatsWithSciExponentAndPrecisionGenerator,\n        PrimitiveIntIncreasingRange<u64>,\n        ExhaustivePositiveFloatsWithSciExponentAndPrecision,\n    >,\n);\n\nimpl Iterator for ExhaustivePositiveFloatsWithSciExponent {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all finite positive [`Float`]s with a specified `sci_exponent` (one less than the raw\n/// exponent).\n///\n/// Positive and negative zero are both excluded.\n///\n/// A finite positive [`Float`] may be uniquely expressed as $x = m_s2^e_s$, where $1 \\leq m_s < 2$\n/// and $e_s$ is an integer; then $e_s$ is the sci-exponent.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if the precision is zero.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_positive_floats_with_sci_exponent;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_positive_floats_with_sci_exponent(0)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.0#1\", \"1.0#2\", \"1.5#2\", \"1.0#3\", \"1.2#3\", \"1.5#3\", \"1.8#3\", \"1.0#4\", \"1.1#4\",\n///         \"1.2#4\", \"1.4#4\", \"1.5#4\", \"1.6#4\", \"1.8#4\", \"1.9#4\", \"1.0#5\", \"1.06#5\", \"1.12#5\",\n///         \"1.19#5\", \"1.25#5\"\n///     ]\n/// );\n///\n/// assert_eq!(\n///     exhaustive_positive_floats_with_sci_exponent(2)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"4.0#1\", \"4.0#2\", \"6.0#2\", \"4.0#3\", \"5.0#3\", \"6.0#3\", \"7.0#3\", \"4.0#4\", \"4.5#4\",\n///         \"5.0#4\", \"5.5#4\", \"6.0#4\", \"6.5#4\", \"7.0#4\", \"7.5#4\", \"4.0#5\", \"4.2#5\", \"4.5#5\",\n///         \"4.8#5\", \"5.0#5\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_positive_floats_with_sci_exponent(\n    sci_exponent: i32,\n) -> ExhaustivePositiveFloatsWithSciExponent {\n    assert!(sci_exponent < Float::MAX_EXPONENT);\n    assert!(sci_exponent >= Float::MIN_EXPONENT - 1);\n    ExhaustivePositiveFloatsWithSciExponent(exhaustive_positive_floats_with_sci_exponent_helper(\n        sci_exponent,\n    ))\n}\n\n#[derive(Clone, Debug)]\nstruct FloatsWithPrecisionAndSciExponentGenerator {\n    precision: u64,\n}\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        i32,\n        Float,\n        ExhaustivePositiveFloatsWithSciExponentAndPrecision,\n    > for FloatsWithPrecisionAndSciExponentGenerator\n{\n    #[inline]\n    fn get_ys(&self, &exp: &i32) -> ExhaustivePositiveFloatsWithSciExponentAndPrecision {\n        exhaustive_positive_floats_with_sci_exponent_and_precision(exp, self.precision)\n    }\n}\n\n#[inline]\nfn exhaustive_floats_with_precision_helper(\n    prec: u64,\n) -> ExhaustiveDependentPairs<\n    i32,\n    Float,\n    BitDistributorSequence,\n    FloatsWithPrecisionAndSciExponentGenerator,\n    ExhaustiveSignedRange<i32>,\n    ExhaustivePositiveFloatsWithSciExponentAndPrecision,\n> {\n    exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_signed_inclusive_range(Float::MIN_EXPONENT, Float::MAX_EXPONENT),\n        FloatsWithPrecisionAndSciExponentGenerator { precision: prec },\n    )\n}\n\n/// Generates all finite positive [`Float`]s with a specified precision.\n///\n/// This `struct` is created by [`exhaustive_positive_floats_with_precision`]; see its documentation\n/// for more.\n#[derive(Clone, Debug)]\npub struct ExhaustivePositiveFloatsWithPrecision(\n    ExhaustiveDependentPairs<\n        i32,\n        Float,\n        BitDistributorSequence,\n        FloatsWithPrecisionAndSciExponentGenerator,\n        ExhaustiveSignedRange<i32>,\n        ExhaustivePositiveFloatsWithSciExponentAndPrecision,\n    >,\n);\n\nimpl Iterator for ExhaustivePositiveFloatsWithPrecision {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all finite positive [`Float`]s with a specified `precision`.\n///\n/// Positive and negative zero are both excluded.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if the precision is zero.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_positive_floats_with_precision;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_positive_floats_with_precision(1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.0#1\", \"2.0#1\", \"0.5#1\", \"4.0#1\", \"0.2#1\", \"8.0#1\", \"0.1#1\", \"2.0e1#1\", \"0.06#1\",\n///         \"3.0e1#1\", \"0.03#1\", \"6.0e1#1\", \"0.02#1\", \"1.0e2#1\", \"0.008#1\", \"3.0e2#1\", \"0.004#1\",\n///         \"5.0e2#1\", \"0.002#1\", \"1.0e3#1\"\n///     ]\n/// );\n///\n/// assert_eq!(\n///     exhaustive_positive_floats_with_precision(10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.0#10\",\n///         \"2.0#10\",\n///         \"1.002#10\",\n///         \"2.004#10\",\n///         \"0.5#10\",\n///         \"4.0#10\",\n///         \"0.501#10\",\n///         \"4.01#10\",\n///         \"1.004#10\",\n///         \"2.008#10\",\n///         \"1.006#10\",\n///         \"2.012#10\",\n///         \"0.502#10\",\n///         \"4.016#10\",\n///         \"0.503#10\",\n///         \"4.023#10\",\n///         \"0.25#10\",\n///         \"8.0#10\",\n///         \"0.2505#10\",\n///         \"8.02#10\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_positive_floats_with_precision(\n    prec: u64,\n) -> ExhaustivePositiveFloatsWithPrecision {\n    assert_ne!(prec, 0);\n    ExhaustivePositiveFloatsWithPrecision(exhaustive_floats_with_precision_helper(prec))\n}\n\n/// Generates all [`Float`]s with a specified precision. (Since they have a precision, they are\n/// finite and nonzero.)\n///\n/// This `struct` is created by [`exhaustive_floats_with_precision`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveFloatsWithPrecision {\n    toggle: bool,\n    xs: ExhaustivePositiveFloatsWithPrecision,\n    x: Float,\n}\n\nimpl Iterator for ExhaustiveFloatsWithPrecision {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.toggle.not_assign();\n        Some(if self.toggle {\n            self.x = self.xs.next().unwrap();\n            self.x.clone()\n        } else {\n            let mut out = Float::NAN;\n            swap(&mut out, &mut self.x);\n            -out\n        })\n    }\n}\n\n/// Generates all [`Float`]s with a specified precision. (Since they have a precision, they are\n/// finite and nonzero.)\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if the precision is zero.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_floats_with_precision;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_floats_with_precision(1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.0#1\", \"-1.0#1\", \"2.0#1\", \"-2.0#1\", \"0.5#1\", \"-0.5#1\", \"4.0#1\", \"-4.0#1\", \"0.2#1\",\n///         \"-0.2#1\", \"8.0#1\", \"-8.0#1\", \"0.1#1\", \"-0.1#1\", \"2.0e1#1\", \"-2.0e1#1\", \"0.06#1\",\n///         \"-0.06#1\", \"3.0e1#1\", \"-3.0e1#1\"\n///     ]\n/// );\n///\n/// assert_eq!(\n///     exhaustive_floats_with_precision(10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.0#10\",\n///         \"-1.0#10\",\n///         \"2.0#10\",\n///         \"-2.0#10\",\n///         \"1.002#10\",\n///         \"-1.002#10\",\n///         \"2.004#10\",\n///         \"-2.004#10\",\n///         \"0.5#10\",\n///         \"-0.5#10\",\n///         \"4.0#10\",\n///         \"-4.0#10\",\n///         \"0.501#10\",\n///         \"-0.501#10\",\n///         \"4.01#10\",\n///         \"-4.01#10\",\n///         \"1.004#10\",\n///         \"-1.004#10\",\n///         \"2.008#10\",\n///         \"-2.008#10\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_floats_with_precision(prec: u64) -> ExhaustiveFloatsWithPrecision {\n    ExhaustiveFloatsWithPrecision {\n        toggle: false,\n        xs: exhaustive_positive_floats_with_precision(prec),\n        x: Float::NAN,\n    }\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct ExhaustivePositiveFiniteFloatsGenerator;\n\nimpl ExhaustiveDependentPairsYsGenerator<i32, Float, ExhaustivePositiveFloatsWithSciExponent>\n    for ExhaustivePositiveFiniteFloatsGenerator\n{\n    #[inline]\n    fn get_ys(&self, &sci_exponent: &i32) -> ExhaustivePositiveFloatsWithSciExponent {\n        exhaustive_positive_floats_with_sci_exponent(sci_exponent)\n    }\n}\n\n#[inline]\nfn exhaustive_positive_finite_floats_helper() -> ExhaustiveDependentPairs<\n    i32,\n    Float,\n    BitDistributorSequence,\n    ExhaustivePositiveFiniteFloatsGenerator,\n    ExhaustiveSignedRange<i32>,\n    ExhaustivePositiveFloatsWithSciExponent,\n> {\n    exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_signed_inclusive_range(Float::MIN_EXPONENT, Float::MAX_EXPONENT),\n        ExhaustivePositiveFiniteFloatsGenerator,\n    )\n}\n\n/// Generates all positive finite [`Float`]s.\n///\n/// This `struct` is created by [`exhaustive_positive_finite_floats`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct ExhaustivePositiveFiniteFloats(\n    ExhaustiveDependentPairs<\n        i32,\n        Float,\n        BitDistributorSequence,\n        ExhaustivePositiveFiniteFloatsGenerator,\n        ExhaustiveSignedRange<i32>,\n        ExhaustivePositiveFloatsWithSciExponent,\n    >,\n);\n\nimpl Iterator for ExhaustivePositiveFiniteFloats {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all positive finite [`Float`]s.\n///\n/// Positive and negative zero are both excluded.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_positive_finite_floats()\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.0#1\", \"2.0#1\", \"1.0#2\", \"2.0#2\", \"0.5#1\", \"4.0#1\", \"0.5#2\", \"4.0#2\", \"1.5#2\",\n///         \"3.0#2\", \"1.0#3\", \"2.0#3\", \"0.8#2\", \"6.0#2\", \"0.5#3\", \"4.0#3\", \"0.2#1\", \"8.0#1\",\n///         \"0.2#2\", \"8.0#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_positive_finite_floats() -> ExhaustivePositiveFiniteFloats {\n    ExhaustivePositiveFiniteFloats(exhaustive_positive_finite_floats_helper())\n}\n\n/// Generates all negative finite [`Float`]s.\n///\n/// This `struct` is created by [`exhaustive_negative_finite_floats`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveNegativeFiniteFloats(ExhaustivePositiveFiniteFloats);\n\nimpl Iterator for ExhaustiveNegativeFiniteFloats {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.0.next().map(|f| -f)\n    }\n}\n\n/// Generates all negative finite [`Float`]s.\n///\n/// Positive and negative zero are both excluded.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_negative_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_negative_finite_floats()\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-1.0#1\", \"-2.0#1\", \"-1.0#2\", \"-2.0#2\", \"-0.5#1\", \"-4.0#1\", \"-0.5#2\", \"-4.0#2\",\n///         \"-1.5#2\", \"-3.0#2\", \"-1.0#3\", \"-2.0#3\", \"-0.8#2\", \"-6.0#2\", \"-0.5#3\", \"-4.0#3\",\n///         \"-0.2#1\", \"-8.0#1\", \"-0.2#2\", \"-8.0#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_negative_finite_floats() -> ExhaustiveNegativeFiniteFloats {\n    ExhaustiveNegativeFiniteFloats(exhaustive_positive_finite_floats())\n}\n\n/// Generates all nonzero finite [`Float`]s.\n///\n/// This `struct` is created by [`exhaustive_nonzero_finite_floats`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveNonzeroFiniteFloats {\n    toggle: bool,\n    xs: ExhaustivePositiveFiniteFloats,\n    x: Float,\n}\n\nimpl Iterator for ExhaustiveNonzeroFiniteFloats {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.toggle.not_assign();\n        Some(if self.toggle {\n            self.x = self.xs.next().unwrap();\n            self.x.clone()\n        } else {\n            let mut out = Float::NAN;\n            swap(&mut out, &mut self.x);\n            -out\n        })\n    }\n}\n\n/// Generates all nonzero finite [`Float`]s.\n///\n/// Positive and negative zero are both excluded.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_nonzero_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_nonzero_finite_floats()\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.0#1\", \"-1.0#1\", \"2.0#1\", \"-2.0#1\", \"1.0#2\", \"-1.0#2\", \"2.0#2\", \"-2.0#2\", \"0.5#1\",\n///         \"-0.5#1\", \"4.0#1\", \"-4.0#1\", \"0.5#2\", \"-0.5#2\", \"4.0#2\", \"-4.0#2\", \"1.5#2\", \"-1.5#2\",\n///         \"3.0#2\", \"-3.0#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_nonzero_finite_floats() -> ExhaustiveNonzeroFiniteFloats {\n    ExhaustiveNonzeroFiniteFloats {\n        toggle: false,\n        xs: exhaustive_positive_finite_floats(),\n        x: Float::NAN,\n    }\n}\n\ntype ExhaustiveNonNegativeFiniteFloats = Chain<Once<Float>, ExhaustivePositiveFiniteFloats>;\n\n/// Generates all non-negative finite [`Float`]s.\n///\n/// Positive zero is included, but negative zero is not.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_non_negative_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_non_negative_finite_floats()\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"0.0\", \"1.0#1\", \"2.0#1\", \"1.0#2\", \"2.0#2\", \"0.5#1\", \"4.0#1\", \"0.5#2\", \"4.0#2\", \"1.5#2\",\n///         \"3.0#2\", \"1.0#3\", \"2.0#3\", \"0.8#2\", \"6.0#2\", \"0.5#3\", \"4.0#3\", \"0.2#1\", \"8.0#1\",\n///         \"0.2#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_non_negative_finite_floats() -> ExhaustiveNonNegativeFiniteFloats {\n    once(Float::ZERO).chain(exhaustive_positive_finite_floats())\n}\n\ntype ExhaustiveNonPositiveFiniteFloats = Chain<Once<Float>, ExhaustiveNegativeFiniteFloats>;\n\n/// Generates all non-positive finite [`Float`]s.\n///\n/// Negative zero is included, but positive zero is not.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_non_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_non_positive_finite_floats()\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-0.0\", \"-1.0#1\", \"-2.0#1\", \"-1.0#2\", \"-2.0#2\", \"-0.5#1\", \"-4.0#1\", \"-0.5#2\", \"-4.0#2\",\n///         \"-1.5#2\", \"-3.0#2\", \"-1.0#3\", \"-2.0#3\", \"-0.8#2\", \"-6.0#2\", \"-0.5#3\", \"-4.0#3\",\n///         \"-0.2#1\", \"-8.0#1\", \"-0.2#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_non_positive_finite_floats() -> ExhaustiveNonPositiveFiniteFloats {\n    once(Float::NEGATIVE_ZERO).chain(exhaustive_negative_finite_floats())\n}\n\ntype ExhaustiveFloats = Chain<IntoIter<Float>, ExhaustiveNonzeroFiniteFloats>;\n\n/// Generates all finite [`Float`]s.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_finite_floats()\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"0.0\", \"-0.0\", \"1.0#1\", \"-1.0#1\", \"2.0#1\", \"-2.0#1\", \"1.0#2\", \"-1.0#2\", \"2.0#2\",\n///         \"-2.0#2\", \"0.5#1\", \"-0.5#1\", \"4.0#1\", \"-4.0#1\", \"0.5#2\", \"-0.5#2\", \"4.0#2\", \"-4.0#2\",\n///         \"1.5#2\", \"-1.5#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_finite_floats() -> ExhaustiveFloats {\n    alloc::vec![Float::ZERO, Float::NEGATIVE_ZERO]\n        .into_iter()\n        .chain(exhaustive_nonzero_finite_floats())\n}\n\n/// Generates all [`Float`]s.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i)$\n///\n/// $M(i) = O(\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_float::exhaustive::exhaustive_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     exhaustive_floats()\n///         .take(50)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"NaN\",\n///         \"Infinity\",\n///         \"-Infinity\",\n///         \"0.0\",\n///         \"-0.0\",\n///         \"1.0#1\",\n///         \"-1.0#1\",\n///         \"2.0#1\",\n///         \"-2.0#1\",\n///         \"1.0#2\",\n///         \"-1.0#2\",\n///         \"2.0#2\",\n///         \"-2.0#2\",\n///         \"0.5#1\",\n///         \"-0.5#1\",\n///         \"4.0#1\",\n///         \"-4.0#1\",\n///         \"0.5#2\",\n///         \"-0.5#2\",\n///         \"4.0#2\",\n///         \"-4.0#2\",\n///         \"1.5#2\",\n///         \"-1.5#2\",\n///         \"3.0#2\",\n///         \"-3.0#2\",\n///         \"1.0#3\",\n///         \"-1.0#3\",\n///         \"2.0#3\",\n///         \"-2.0#3\",\n///         \"0.8#2\",\n///         \"-0.8#2\",\n///         \"6.0#2\",\n///         \"-6.0#2\",\n///         \"0.5#3\",\n///         \"-0.5#3\",\n///         \"4.0#3\",\n///         \"-4.0#3\",\n///         \"0.2#1\",\n///         \"-0.2#1\",\n///         \"8.0#1\",\n///         \"-8.0#1\",\n///         \"0.2#2\",\n///         \"-0.2#2\",\n///         \"8.0#2\",\n///         \"-8.0#2\",\n///         \"0.1#1\",\n///         \"-0.1#1\",\n///         \"2.0e1#1\",\n///         \"-2.0e1#1\",\n///         \"0.1#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn exhaustive_floats() -> ExhaustiveFloats {\n    alloc::vec![\n        Float::NAN,\n        Float::INFINITY,\n        Float::NEGATIVE_INFINITY,\n        Float::ZERO,\n        Float::NEGATIVE_ZERO\n    ]\n    .into_iter()\n    .chain(exhaustive_nonzero_finite_floats())\n}\n"
  },
  {
    "path": "malachite-float/src/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n//! This crate defines [`Float`]s, which are arbitrary-precision floating-point numbers.\n//!\n//! [`Float`]s are currently experimental. They are missing many important functions. However, the\n//! functions that are currently implemented are thoroughly tested and documented, with the\n//! exception of string conversion functions. The current string conversions are incomplete and\n//! will be changed in the future to match MPFR's behavior.\n//!\n//! # Demos and benchmarks\n//! This crate comes with a `bin` target that can be used for running demos and benchmarks.\n//! - Almost all of the public functions in this crate have an associated demo. Running a demo\n//!   shows you a function's behavior on a large number of inputs. TODO\n//! - You can use a similar command to run benchmarks. TODO\n//!\n//! The list of available demos and benchmarks is not documented anywhere; you must find them by\n//! browsing through\n//! [`bin_util/demo_and_bench`](https://github.com/mhogrefe/malachite/tree/master/malachite-float/src/bin_util/demo_and_bench).\n//!\n//! # Features\n//! - `32_bit_limbs`: Sets the type of [`Limb`](malachite_nz#limbs) to [`u32`] instead of the\n//!   default, [`u64`].\n//! - `test_build`: A large proportion of the code in this crate is only used for testing. For a\n//!   typical user, building this code would result in an unnecessarily long compilation time and\n//!   an unnecessarily large binary. My solution is to only build this code when the `test_build`\n//!   feature is enabled. If you want to run unit tests, you must enable `test_build`. However,\n//!   doctests don't require it, since they only test the public interface.\n//! - `bin_build`: This feature is used to build the code for demos and benchmarks, which also\n//!   takes a long time to build. Enabling this feature also enables `test_build`.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n#![cfg_attr(\n    not(any(feature = \"test_build\", feature = \"random\", feature = \"std\")),\n    no_std\n)]\n\nextern crate alloc;\n\n#[macro_use]\nextern crate malachite_base;\n\n#[cfg(feature = \"test_build\")]\nextern crate itertools;\n\n#[cfg(feature = \"test_build\")]\nuse crate::InnerFloat::Finite;\nuse core::cmp::Ordering::{self, *};\nuse core::ops::Deref;\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom, SciMantissaAndExponent};\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\n\n/// A floating-point number.\n///\n/// `Float`s are currently experimental. They are missing many important functions. However, the\n/// functions that are currently implemented are thoroughly tested and documented, with the\n/// exception of string conversion functions. The current string conversions are incomplete and will\n/// be changed in the future to match MPFR's behavior.\n///\n/// `Float`s are similar to the primitive floats defined by the IEEE 754 standard. They include NaN,\n/// $\\infty$ and $-\\infty$, and positive and negative zero. There is only one NaN; there is no\n/// concept of a NaN payload.\n///\n/// All the finite `Float`s are dyadic rationals (rational numbers whose denominator is a power of\n/// 2). A finite `Float` consists of several fields:\n/// - a sign, which denotes whether the `Float` is positive or negative;\n/// - a significand, which is a [`Natural`] number whose value is equal to the `Float`'s absolute\n///   value multiplied by a power of 2;\n/// - an exponent, which is one more than the floor of the base-2 logarithm of the `Float`'s\n///   absolute value;\n/// - and finally, a precision, which is greater than zero and indicates the number of significant\n///   bits. It is common to think of a `Float` as an approximation of some real number, and the\n///   precision indicates how good the approximation is intended to be.\n///\n/// `Float`s inherit some odd behavior from the IEEE 754 standard regarding comparison. A `NaN` is\n/// not equal to any `Float`, including itself. Positive and negative zero compare as equal, despite\n/// being two distinct values. Additionally, (and this is not IEEE 754's fault), `Float`s with\n/// different precisions compare as equal if they represent the same numeric value.\n///\n/// In many cases, the above behavior is unsatisfactory, so the [`ComparableFloat`] and\n/// [`ComparableFloat`] wrappers are provided. See their documentation for a description of their\n/// comparison behavior.\n///\n/// In documentation, we will use the '$=$' sign to mean that two `Float`s are identical, writing\n/// things like $-\\text{NaN}=\\text{NaN}$ and $-(0.0) = -0.0$.\n///\n/// The `Float` type is designed to be very similar to the `mpfr_t` type in\n/// [MPFR](https://www.mpfr.org/mpfr-current/mpfr.html#Nomenclature-and-Types), and all Malachite\n/// functions produce exactly the same result as their counterparts in MPFR, unless otherwise noted.\n///\n/// Here are the structural difference between `Float` and `mpfr_t`:\n/// - `Float` can only represent a single `NaN` value, with no sign or payload.\n/// - Only finite, nonzero `Float`s have a significand, precision, and exponent. For other `Float`s,\n///   these concepts are undefined. In particular, unlike `mpfr_t` zeros, `Float` zeros do not have\n///   a precision.\n/// - The types of `mpfr_t` components are configuration- and platform-dependent. The types of\n///   `Float` components are platform-independent, although the `Limb` type is\n///   configuration-dependent: it is `u64` by default, but may be changed to `u32` using the\n///   `--32_bit_limbs` compiler flag. The type of the exponent is always `i32` and the type of the\n///   precision is always `u64`. The `Limb` type only has a visible effect on the functions that\n///   extract the raw significand. All other functions have the same interface when compiled with\n///   either `Limb` type.\n///\n/// `Float`s whose precision is 64 bits or less can be represented without any memory allocation.\n/// (Unless Malachite is compiled with `32_bit_limbs`, in which case the limit is 32).\n#[derive(Clone)]\npub struct Float(pub(crate) InnerFloat);\n\n// We want to limit the visibility of the `NaN`, `Zero`, `Infinity`, and `Finite` constructors to\n// within this crate. To do this, we wrap the `InnerFloat` enum in a struct that gets compiled away.\n#[derive(Clone)]\npub(crate) enum InnerFloat {\n    NaN,\n    Infinity {\n        sign: bool,\n    },\n    Zero {\n        sign: bool,\n    },\n    Finite {\n        sign: bool,\n        exponent: i32,\n        precision: u64,\n        significand: Natural,\n    },\n}\n\n#[inline]\npub(crate) fn significand_bits(significand: &Natural) -> u64 {\n    significand.limb_count() << Limb::LOG_WIDTH\n}\n\nimpl Float {\n    /// The maximum raw exponent of any [`Float`], equal to $2^{30}-1$, or $1,073,741,823$. This is\n    /// one more than the maximum scientific exponent. If we write a [`Float`] as $\\pm m2^e$, with\n    /// $1\\leq m<2$ and $e$ an integer, we must have $e\\leq 2^{30}-2$. If the result of a\n    /// calculation would produce a [`Float`] with an exponent larger than this, then $\\pm\\infty$,\n    /// the maximum finite float of the specified precision, or the minimum finite float of the\n    /// specified pecision is returned instead, depending on the rounding mode.\n    pub const MAX_EXPONENT: i32 = 0x3fff_ffff;\n    /// The minimum raw exponent of any [`Float`], equal to $-(2^{30}-1)$, or $-1,073,741,823$. This\n    /// is one more than the minimum scientific exponent. If we write a [`Float`] as $\\pm m2^e$,\n    /// with $1\\leq m<2$ and $e$ an integer, we must have $e\\geq -2^{30}$. If the result of a\n    /// calculation would produce a [`Float`] with an exponent smaller than this, then $\\pm0.0$, the\n    /// minimum positive finite [`Float`], or the maximum negative finite [`Float`] is returned\n    /// instead, depending on the rounding mode.\n    pub const MIN_EXPONENT: i32 = -Self::MAX_EXPONENT;\n\n    #[cfg(feature = \"test_build\")]\n    pub fn is_valid(&self) -> bool {\n        match self {\n            Self(Finite {\n                precision,\n                significand,\n                exponent,\n                ..\n            }) => {\n                if *precision == 0\n                    || !significand.is_valid()\n                    || *exponent > Self::MAX_EXPONENT\n                    || *exponent < Self::MIN_EXPONENT\n                {\n                    return false;\n                }\n                let bits = significand.significant_bits();\n                bits != 0\n                    && bits.divisible_by_power_of_2(Limb::LOG_WIDTH)\n                    && *precision <= bits\n                    && bits - precision < Limb::WIDTH\n                    && significand.divisible_by_power_of_2(bits - precision)\n            }\n            _ => true,\n        }\n    }\n}\n\n/// `ComparableFloat` is a wrapper around a [`Float`], taking the [`Float`] by value.\n///\n/// `CompatableFloat` has different comparison behavior than [`Float`]. See the [`Float`]\n/// documentation for its comparison behavior, which is largely derived from the IEEE 754\n/// specification; the `ComparableFloat` behavior, on the other hand, is more mathematically\n/// well-behaved, and respects the principle that equality should be the finest equivalence\n/// relation: that is, that two equal objects should not be different in any way.\n///\n/// To be more specific: when a [`Float`] is wrapped in a `ComparableFloat`,\n/// - `NaN` is not equal to any other [`Float`], but equal to itself;\n/// - Positive and negative zero are not equal to each other;\n/// - Ordering is total. Negative zero is ordered to be smaller than positive zero, and `NaN` is\n///   arbitrarily ordered to be between the two zeros;\n/// - Two [`Float`]s with different precisions but representing the same value are unequal, and the\n///   one with the greater precision is ordered to be larger;\n/// - The hashing function is compatible with equality.\n///\n/// The analogous wrapper for primitive floats is\n/// [`NiceFloat`](malachite_base::num::float::NiceFloat). However,\n/// [`NiceFloat`](malachite_base::num::float::NiceFloat) also facilitates better string conversion,\n/// something that isn't necessary for [`Float`]s\n///\n/// `ComparableFloat` owns its float. This is useful in many cases, for example if you want to use\n/// [`Float`]s as keys in a hash map. In other situations, it is better to use\n/// [`ComparableFloatRef`], which only has a reference to its float.\n#[derive(Clone)]\npub struct ComparableFloat(pub Float);\n\n/// `ComparableFloatRef` is a wrapper around a [`Float`], taking the [`Float`] be reference.\n///\n/// See the [`ComparableFloat`] documentation for details.\n#[derive(Clone)]\npub struct ComparableFloatRef<'a>(pub &'a Float);\n\nimpl ComparableFloat {\n    pub const fn as_ref(&self) -> ComparableFloatRef<'_> {\n        ComparableFloatRef(&self.0)\n    }\n}\n\nimpl Deref for ComparableFloat {\n    type Target = Float;\n\n    /// Allows a [`ComparableFloat`] to dereference to a [`Float`].\n    ///\n    /// ```\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_float::{ComparableFloat, Float};\n    ///\n    /// let x = ComparableFloat(Float::ONE);\n    /// assert_eq!(*x, Float::ONE);\n    /// ```\n    fn deref(&self) -> &Float {\n        &self.0\n    }\n}\n\nimpl Deref for ComparableFloatRef<'_> {\n    type Target = Float;\n\n    /// Allows a [`ComparableFloatRef`] to dereference to a [`Float`].\n    ///\n    /// ```\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_float::{ComparableFloatRef, Float};\n    ///\n    /// let x = Float::ONE;\n    /// let y = ComparableFloatRef(&x);\n    /// assert_eq!(*y, Float::ONE);\n    /// ```\n    fn deref(&self) -> &Float {\n        self.0\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\n#[doc(hidden)]\npub fn emulate_float_to_float_fn<T: PrimitiveFloat, F: Fn(Float, u64) -> (Float, Ordering)>(\n    f: F,\n    x: T,\n) -> T\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    let x = Float::from(x);\n    let (mut result, o) = f(x.clone(), T::MANTISSA_WIDTH + 1);\n    if !result.is_normal() {\n        return T::exact_from(&result);\n    }\n    let e = i64::from(<&Float as SciMantissaAndExponent<Float, i32, _>>::sci_exponent(&result));\n    if e < T::MIN_NORMAL_EXPONENT {\n        if e < T::MIN_EXPONENT {\n            let rm =\n                if e == T::MIN_EXPONENT - 1 && result.significand_ref().unwrap().is_power_of_2() {\n                    let down = if result > T::ZERO { Less } else { Greater };\n                    if o == down { Up } else { Down }\n                } else {\n                    Nearest\n                };\n            return T::rounding_from(&result, rm).0;\n        }\n        result = f(x, T::max_precision_for_sci_exponent(e)).0;\n    }\n    if result > T::MAX_FINITE {\n        T::INFINITY\n    } else if result < -T::MAX_FINITE {\n        T::NEGATIVE_INFINITY\n    } else {\n        T::exact_from(&result)\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\n#[doc(hidden)]\npub fn emulate_float_float_to_float_fn<\n    T: PrimitiveFloat,\n    F: Fn(Float, Float, u64) -> (Float, Ordering),\n>(\n    f: F,\n    x: T,\n    y: T,\n) -> T\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    let x = Float::from(x);\n    let y = Float::from(y);\n    let (mut result, o) = f(x.clone(), y.clone(), T::MANTISSA_WIDTH + 1);\n    if !result.is_normal() {\n        return T::exact_from(&result);\n    }\n    let e = i64::from(<&Float as SciMantissaAndExponent<Float, i32, _>>::sci_exponent(&result));\n    if e < T::MIN_NORMAL_EXPONENT {\n        if e < T::MIN_EXPONENT {\n            let rm =\n                if e == T::MIN_EXPONENT - 1 && result.significand_ref().unwrap().is_power_of_2() {\n                    let down = if result > T::ZERO { Less } else { Greater };\n                    if o == down { Up } else { Down }\n                } else {\n                    Nearest\n                };\n            return T::rounding_from(&result, rm).0;\n        }\n        result = f(x, y, T::max_precision_for_sci_exponent(e)).0;\n    }\n    if result > T::MAX_FINITE {\n        T::INFINITY\n    } else if result < -T::MAX_FINITE {\n        T::NEGATIVE_INFINITY\n    } else {\n        T::exact_from(&result)\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\n#[doc(hidden)]\npub fn emulate_rational_to_float_fn<T: PrimitiveFloat, F: Fn(&Rational, u64) -> (Float, Ordering)>(\n    f: F,\n    x: &Rational,\n) -> T\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    let (mut result, o) = f(x, T::MANTISSA_WIDTH + 1);\n    if !result.is_normal() {\n        return T::exact_from(&result);\n    }\n    let e = i64::from(<&Float as SciMantissaAndExponent<Float, i32, _>>::sci_exponent(&result));\n    if e < T::MIN_NORMAL_EXPONENT {\n        if e < T::MIN_EXPONENT {\n            let rm =\n                if e == T::MIN_EXPONENT - 1 && result.significand_ref().unwrap().is_power_of_2() {\n                    let down = if result > T::ZERO { Less } else { Greater };\n                    if o == down { Up } else { Down }\n                } else {\n                    Nearest\n                };\n            return T::rounding_from(&result, rm).0;\n        }\n        result = f(x, T::max_precision_for_sci_exponent(e)).0;\n    }\n    if result > T::MAX_FINITE {\n        T::INFINITY\n    } else if result < -T::MAX_FINITE {\n        T::NEGATIVE_INFINITY\n    } else {\n        T::exact_from(&result)\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\n#[doc(hidden)]\npub fn emulate_rational_rational_to_float_fn<\n    T: PrimitiveFloat,\n    F: Fn(&Rational, &Rational, u64) -> (Float, Ordering),\n>(\n    f: F,\n    x: &Rational,\n    y: &Rational,\n) -> T\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    let (mut result, o) = f(x, y, T::MANTISSA_WIDTH + 1);\n    if !result.is_normal() {\n        return T::exact_from(&result);\n    }\n    let e = i64::from(<&Float as SciMantissaAndExponent<Float, i32, _>>::sci_exponent(&result));\n    if e < T::MIN_NORMAL_EXPONENT {\n        if e < T::MIN_EXPONENT {\n            let rm =\n                if e == T::MIN_EXPONENT - 1 && result.significand_ref().unwrap().is_power_of_2() {\n                    let down = if result > T::ZERO { Less } else { Greater };\n                    if o == down { Up } else { Down }\n                } else {\n                    Nearest\n                };\n            return T::rounding_from(&result, rm).0;\n        }\n        result = f(x, y, T::max_precision_for_sci_exponent(e)).0;\n    }\n    if result > T::MAX_FINITE {\n        T::INFINITY\n    } else if result < -T::MAX_FINITE {\n        T::NEGATIVE_INFINITY\n    } else {\n        T::exact_from(&result)\n    }\n}\n\n/// Given the `(Float, Ordering)` result of an operation, determines whether an overflow occurred.\n///\n/// We're defining an overflow to occur whenever the actual result is outside the representable\n/// finite range, and is rounded to either infinity or to the maximum or minimum representable\n/// finite value. An overflow can present itself in four ways:\n/// - The result is $\\infty$ and the `Ordering` is `Greater`\n/// - The result is $-\\infty$ and the `Ordering` is `Less`\n/// - The result is the largest finite value (of any `Float` with its precision) and the `Ordering`\n///   is `Less`\n/// - The result is the smallest (most negative) finite value (of any `Float` with its precision)\n///   and the `Ordering` is `Greater`\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::{Infinity, NegativeInfinity, One};\n/// use malachite_float::{test_overflow, Float};\n/// use std::cmp::Ordering::*;\n///\n/// assert!(test_overflow(&Float::INFINITY, Greater));\n/// assert!(test_overflow(&Float::NEGATIVE_INFINITY, Less));\n/// assert!(test_overflow(&Float::max_finite_value_with_prec(10), Less));\n/// assert!(test_overflow(\n///     &-Float::max_finite_value_with_prec(10),\n///     Greater\n/// ));\n///\n/// assert!(!test_overflow(&Float::INFINITY, Equal));\n/// assert!(!test_overflow(&Float::ONE, Less));\n/// ```\npub fn test_overflow(result: &Float, o: Ordering) -> bool {\n    if o == Equal {\n        return false;\n    }\n    *result == Float::INFINITY && o == Greater\n        || *result == Float::NEGATIVE_INFINITY && o == Less\n        || *result > 0u32 && result.abs_is_max_finite_value_with_prec() && o == Less\n        || *result < 0u32 && result.abs_is_max_finite_value_with_prec() && o == Greater\n}\n\n/// Given the `(Float, Ordering)` result of an operation, determines whether an underflow occurred.\n///\n/// We're defining an underflow to occur whenever the actual result is outside the representable\n/// finite range, and is rounded to zero, to the minimum positive value, or to the maximum negative\n/// value. An underflow can present itself in four ways:\n/// - The result is $0.0$ or $-0.0$ and the `Ordering` is `Less`\n/// - The result is $0.0$ or $-0.0$ and the `Ordering` is `Greater`\n/// - The result is the smallest positive value and the `Ordering` is `Greater`\n/// - The result is the largest (least negative) negative value and the `Ordering` is `Less`\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::{One, Zero};\n/// use malachite_float::{test_underflow, Float};\n/// use std::cmp::Ordering::*;\n///\n/// assert!(test_underflow(&Float::ZERO, Less));\n/// assert!(test_underflow(&Float::ZERO, Greater));\n/// assert!(test_underflow(&Float::min_positive_value_prec(10), Greater));\n/// assert!(test_underflow(&-Float::min_positive_value_prec(10), Less));\n///\n/// assert!(!test_underflow(&Float::ZERO, Equal));\n/// assert!(!test_underflow(&Float::ONE, Less));\n/// ```\npub fn test_underflow(result: &Float, o: Ordering) -> bool {\n    if o == Equal {\n        return false;\n    }\n    *result == 0u32\n        || *result > 0u32 && result.abs_is_min_positive_value() && o == Greater\n        || *result < 0u32 && result.abs_is_min_positive_value() && o == Less\n}\n\n/// Traits for arithmetic.\npub mod arithmetic;\n#[macro_use]\n/// Basic traits for working with [`Float`]s.\npub mod basic;\n/// Traits for comparing [`Float`]s for equality or order.\npub mod comparison;\n/// Functions that produce [`Float`] approximations of mathematical constants, using a given\n/// precision and rounding mode.\npub mod constants;\n/// Traits for converting to and from [`Float`]s, including converting [`Float`]s to and from\n/// strings.\npub mod conversion;\n/// Iterators that generate [`Float`]s without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`Float`]s randomly.\npub mod random;\n\n#[cfg(feature = \"test_build\")]\npub mod test_util;\n"
  },
  {
    "path": "malachite-float/src/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse malachite_base::bools::random::{\n    RandomBools, WeightedRandomBools, random_bools, weighted_random_bools,\n};\nuse malachite_base::iterators::{WithSpecialValues, with_special_values};\nuse malachite_base::num::arithmetic::traits::{NegModPowerOf2, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::logic::traits::{LowMask, SignificantBits};\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomSignedRange,\n    geometric_random_signed_inclusive_range,\n};\nuse malachite_base::random::Seed;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::{\n    RandomNaturals, StripedRandomNaturalInclusiveRange, StripedRandomNaturals,\n    UniformRandomNaturalRange, random_positive_naturals, striped_random_natural_inclusive_range,\n    striped_random_positive_naturals, uniform_random_natural_inclusive_range,\n};\nuse malachite_nz::platform::Limb;\n\n/// Generates random positive finite [`Float`]s.\n///\n/// This `struct` is created by [`random_positive_finite_floats`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomPositiveFiniteFloats<I: Iterator<Item = Natural>> {\n    exponents: GeometricRandomSignedRange<i32>,\n    xs: I,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomPositiveFiniteFloats<I> {\n    type Item = Float;\n\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        let precision = x.significant_bits();\n        assert_ne!(precision, 0);\n        Some(Float(Finite {\n            sign: true,\n            exponent: self.exponents.next().unwrap() + 1,\n            precision,\n            significand: x << precision.neg_mod_power_of_2(Limb::LOG_WIDTH),\n        }))\n    }\n}\n\n/// Generates random positive finite [`Float`]s.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the mean absolute sci-exponent and precision by passing the numerators\n/// and denominators of their means.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_positive_finite_floats(EXAMPLE_SEED, 10, 1, 10, 1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"0.9#3\",\n///         \"1.31e-6#6\",\n///         \"0.008#1\",\n///         \"0.5#1\",\n///         \"8.214e4#13\",\n///         \"0.01558827446#29\",\n///         \"0.02#1\",\n///         \"3.41#7\",\n///         \"4.598171165#33\",\n///         \"0.000033432058#23\",\n///         \"0.339299677376#37\",\n///         \"2.66e4#7\",\n///         \"3.0e4#1\",\n///         \"1.4#8\",\n///         \"37.4#9\",\n///         \"0.2#1\",\n///         \"0.0011108#13\",\n///         \"1066.0#10\",\n///         \"0.184#7\",\n///         \"0.00133230561#28\"\n///     ]\n/// );\n/// ```\npub fn random_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomPositiveFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomPositiveFiniteFloats {\n        exponents: geometric_random_signed_inclusive_range(\n            seed.fork(\"exponents\"),\n            Float::MIN_EXPONENT,\n            Float::MAX_EXPONENT,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        xs: random_positive_naturals(\n            seed.fork(\"significands\"),\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates random positive finite [`Float`]s with a specified precision.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent) are more likely to be chosen. You\n/// can specify the mean absolute sci-exponent by passing the numerators and denominators of its\n/// means.\n///\n/// But note that the specified mean is only approximate, since the distribution we are sampling is\n/// truncated geometric, and its exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual mean is slightly lower than the specified mean.\n/// - However, increasing the specified mean increases the actual mean, so this still works as a\n///   mechanism for controlling the sci-exponent.\n/// - The specified sci-exponent mean must be greater than 0, but it may be as high as you like.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n,) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n///\n/// # Panics\n/// Panics if `prec` is zero.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_positive_floats_with_precision;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_positive_floats_with_precision(EXAMPLE_SEED, 10, 1, 10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"0.959#10\",\n///         \"1.889e-6#10\",\n///         \"0.01291#10\",\n///         \"0.71#10\",\n///         \"1.02e5#10\",\n///         \"0.01181#10\",\n///         \"0.01953#10\",\n///         \"3.082#10\",\n///         \"7.24#10\",\n///         \"0.00005597#10\",\n///         \"0.3877#10\",\n///         \"2.144e4#10\",\n///         \"5.856e4#10\",\n///         \"1.43#10\",\n///         \"62.19#10\",\n///         \"0.4658#10\",\n///         \"0.001659#10\",\n///         \"1914.0#10\",\n///         \"0.136#10\",\n///         \"0.001144#10\"\n///     ]\n/// );\n/// ```\npub fn random_positive_floats_with_precision(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    prec: u64,\n) -> RandomPositiveFiniteFloats<UniformRandomNaturalRange> {\n    assert_ne!(prec, 0);\n    RandomPositiveFiniteFloats {\n        exponents: geometric_random_signed_inclusive_range(\n            seed.fork(\"exponents\"),\n            Float::MIN_EXPONENT,\n            Float::MAX_EXPONENT,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        xs: uniform_random_natural_inclusive_range(\n            seed.fork(\"significands\"),\n            Natural::power_of_2(prec - 1),\n            Natural::low_mask(prec),\n        ),\n    }\n}\n\n/// Generates random negative finite [`Float`]s.\n///\n/// This `struct` is created by [`random_negative_finite_floats`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomNegativeFiniteFloats<I: Iterator<Item = Natural>>(RandomPositiveFiniteFloats<I>);\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomNegativeFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.0.next().map(|f| -f)\n    }\n}\n\n/// Generates random negative finite [`Float`]s.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the mean absolute sci-exponent and precision by passing the numerators\n/// and denominators of their means.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_positive_finite_floats(EXAMPLE_SEED, 10, 1, 10, 1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"0.9#3\",\n///         \"1.31e-6#6\",\n///         \"0.008#1\",\n///         \"0.5#1\",\n///         \"8.214e4#13\",\n///         \"0.01558827446#29\",\n///         \"0.02#1\",\n///         \"3.41#7\",\n///         \"4.598171165#33\",\n///         \"0.000033432058#23\",\n///         \"0.339299677376#37\",\n///         \"2.66e4#7\",\n///         \"3.0e4#1\",\n///         \"1.4#8\",\n///         \"37.4#9\",\n///         \"0.2#1\",\n///         \"0.0011108#13\",\n///         \"1066.0#10\",\n///         \"0.184#7\",\n///         \"0.00133230561#28\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomNegativeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNegativeFiniteFloats(random_positive_finite_floats(\n        seed,\n        mean_sci_exponent_abs_numerator,\n        mean_sci_exponent_abs_denominator,\n        mean_precision_numerator,\n        mean_precision_denominator,\n    ))\n}\n\n/// Generates random non-negative finite [`Float`]s.\n///\n/// This `struct` is created by [`random_non_negative_finite_floats`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct RandomNonNegativeFiniteFloats<I: Iterator<Item = Natural>> {\n    bs: WeightedRandomBools,\n    xs: RandomPositiveFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomNonNegativeFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        if self.bs.next().unwrap() {\n            Some(Float::ZERO)\n        } else {\n            self.xs.next()\n        }\n    }\n}\n\n/// Generates random non-negative finite [`Float`]s.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that a zero will be\n/// generated. You can also specify the mean absolute sci-exponent and precision by passing the\n/// numerators and denominators of their means of the nonzero [`Float`]s.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Positive zero is generated, but negative zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_non_negative_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_non_negative_finite_floats(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"1.11e5#5\",\n///         \"0.0310805#17\",\n///         \"9.594e6#14\",\n///         \"0.0\",\n///         \"0.0127#5\",\n///         \"0.01843#11\",\n///         \"2.0#5\",\n///         \"3.082#10\",\n///         \"0.87495#16\",\n///         \"10288.29527676#38\",\n///         \"9.22#10\",\n///         \"0.030048549#23\",\n///         \"311.452#19\",\n///         \"0.0\",\n///         \"1.07e3#7\",\n///         \"0.000965#9\",\n///         \"59159.522#27\",\n///         \"0.0\",\n///         \"0.000035#6\",\n///         \"2.0e1#1\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_non_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomNonNegativeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNonNegativeFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: random_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates random non-positive finite [`Float`]s.\n///\n/// This `struct` is created by [`random_non_positive_finite_floats`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct RandomNonPositiveFiniteFloats<I: Iterator<Item = Natural>> {\n    bs: WeightedRandomBools,\n    xs: RandomNegativeFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomNonPositiveFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        if self.bs.next().unwrap() {\n            Some(Float::NEGATIVE_ZERO)\n        } else {\n            self.xs.next()\n        }\n    }\n}\n\n/// Generates random non-positive finite [`Float`]s.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that a zero will be\n/// generated. You can also specify the mean absolute sci-exponent and precision by passing the\n/// numerators and denominators of their means of the nonzero [`Float`]s.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Negative zero is generated, but positive zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_non_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_non_positive_finite_floats(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-1.11e5#5\",\n///         \"-0.0310805#17\",\n///         \"-9.594e6#14\",\n///         \"-0.0\",\n///         \"-0.0127#5\",\n///         \"-0.01843#11\",\n///         \"-2.0#5\",\n///         \"-3.082#10\",\n///         \"-0.87495#16\",\n///         \"-10288.29527676#38\",\n///         \"-9.22#10\",\n///         \"-0.030048549#23\",\n///         \"-311.452#19\",\n///         \"-0.0\",\n///         \"-1.07e3#7\",\n///         \"-0.000965#9\",\n///         \"-59159.522#27\",\n///         \"-0.0\",\n///         \"-0.000035#6\",\n///         \"-2.0e1#1\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_non_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomNonPositiveFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNonPositiveFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: random_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates random nonzero finite [`Float`]s.\n///\n/// This `struct` is created by [`random_nonzero_finite_floats`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomNonzeroFiniteFloats<I: Iterator<Item = Natural>> {\n    bs: RandomBools,\n    xs: RandomPositiveFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomNonzeroFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() { x } else { -x })\n    }\n}\n\n/// Generates random nonzero finite [`Float`]s.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the mean absolute sci-exponent and precision by passing the numerators\n/// and denominators of their means.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_nonzero_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_nonzero_finite_floats(EXAMPLE_SEED, 10, 1, 10, 1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-1.11e5#5\",\n///         \"-0.0310805#17\",\n///         \"-9.594e6#14\",\n///         \"0.0127#5\",\n///         \"-0.01843#11\",\n///         \"2.0#5\",\n///         \"-3.082#10\",\n///         \"-0.87495#16\",\n///         \"-10288.29527676#38\",\n///         \"9.22#10\",\n///         \"0.030048549#23\",\n///         \"311.452#19\",\n///         \"-1.07e3#7\",\n///         \"-0.000965#9\",\n///         \"59159.522#27\",\n///         \"-0.000035#6\",\n///         \"-2.0e1#1\",\n///         \"-120.0#5\",\n///         \"-9.6e2#5\",\n///         \"-358.2402#20\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_nonzero_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomNonzeroFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNonzeroFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: random_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates random finite [`Float`]s.\n///\n/// This `struct` is created by [`random_finite_floats`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct RandomFiniteFloats<I: Iterator<Item = Natural>> {\n    bs: RandomBools,\n    xs: RandomNonNegativeFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() { x } else { -x })\n    }\n}\n\n/// Generates random finite [`Float`]s.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that a zero will be\n/// generated. You can also specify the mean absolute sci-exponent and precision by passing the\n/// numerators and denominators of their means of the nonzero [`Float`]s.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// Positive zero and negative zero are both generated. `NaN` is not.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_finite_floats(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-2.44#7\",\n///         \"-2.323395887e-8#30\",\n///         \"-0.086#6\",\n///         \"1009.377#20\",\n///         \"-0.00082#6\",\n///         \"1.98#10\",\n///         \"-1.9e-6#3\",\n///         \"-2.6819e5#14\",\n///         \"-0.0003386#10\",\n///         \"6.0#2\",\n///         \"0.0\",\n///         \"0.1#5\",\n///         \"-1.3665#13\",\n///         \"-3.0e9#2\",\n///         \"0.117#4\",\n///         \"-0.19#2\",\n///         \"-0.03#7\",\n///         \"-4.0e-6#2\",\n///         \"-114.0#6\",\n///         \"-4002.0#13\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: random_non_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n    }\n}\n\n/// Generates random [`Float`]s.\n///\n/// Simpler [`Float`]s (those with a lower absolute sci-exponent or precision) are more likely to be\n/// chosen. You can specify the numerator and denominator of the probability that a zero, an\n/// infinity, or a NaN will be generated. You can also specify the mean absolute sci-exponent and\n/// precision by passing the numerators and denominators of their means of the nonzero [`Float`]s.\n///\n/// But note that the specified means are only approximate, since the distributions we are sampling\n/// are truncated geometric, and their exact means are somewhat annoying to deal with. The practical\n/// implications are that\n/// - The actual means are slightly lower than the specified means.\n/// - However, increasing the specified means increases the actual means, so this still works as a\n///   mechanism for controlling the sci-exponent and precision.\n/// - The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2,\n///   but they may be as high as you like.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::random_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     random_floats(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)\n///         .take(50)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"7.203#10\",\n///         \"39.2#8\",\n///         \"0.0\",\n///         \"NaN\",\n///         \"-0.00003#2\",\n///         \"-5.0e2#1\",\n///         \"-0.0879#8\",\n///         \"-95.12#17\",\n///         \"0.38077#14\",\n///         \"0.000138037#15\",\n///         \"-0.109#7\",\n///         \"-10.312#12\",\n///         \"-13.68396900512259#51\",\n///         \"Infinity\",\n///         \"-0.34#4\",\n///         \"-7.3e-12#5\",\n///         \"-394584.0#16\",\n///         \"NaN\",\n///         \"13.5#5\",\n///         \"-0.0\",\n///         \"-0.0063#5\",\n///         \"0.06#1\",\n///         \"0.18933#12\",\n///         \"0.00004#6\",\n///         \"-4.819e-8#13\",\n///         \"1.15e3#6\",\n///         \"-1.91e7#7\",\n///         \"475.734#17\",\n///         \"1.1e-6#7\",\n///         \"Infinity\",\n///         \"-24.0#3\",\n///         \"-4.0e-15#1\",\n///         \"-Infinity\",\n///         \"0.5039#11\",\n///         \"-1.0e3#3\",\n///         \"-0.0000281#6\",\n///         \"-2.0e5#2\",\n///         \"6.43178e-6#20\",\n///         \"-0.00019#5\",\n///         \"-0.0\",\n///         \"-30.0#4\",\n///         \"0.2#1\",\n///         \"-0.00629938#18\",\n///         \"4.58278771862e-6#38\",\n///         \"-0.0002707085#19\",\n///         \"0.00001313#10\",\n///         \"NaN\",\n///         \"-0.0\",\n///         \"7.0e7#1\",\n///         \"20263.5#16\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn random_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<RandomFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>>> {\n    with_special_values(\n        seed,\n        vec![Float::INFINITY, Float::NEGATIVE_INFINITY, Float::NAN],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            random_finite_floats(\n                seed_2,\n                mean_sci_exponent_abs_numerator,\n                mean_sci_exponent_abs_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n                mean_special_p_numerator,\n                mean_special_p_denominator,\n            )\n        },\n    )\n}\n\n/// Generates striped random positive finite [`Float`]s.\n///\n/// The actual precision is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_sci_exponent_abs_numerator / mean_sci_exponent_abs_denominator`; $m$ must be greater than\n/// 0. A striped bit sequence with the given stripe parameter is generated and truncated at the bit\n/// length. The highest bit is forced to be 1, and the [`Float`] is generated from the sequence and\n/// a random sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_precision_numerator` or `mean_precision_denominator` are\n/// zero, or, if after being reduced to lowest terms, their sum is greater than or equal to\n/// $2^{64}$.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_positive_finite_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"0.94#4\",\n///         \"1.906e-6#11\",\n///         \"0.008#2\",\n///         \"0.5#3\",\n///         \"98332.0#21\",\n///         \"0.01416063310170989651#60\",\n///         \"0.023#2\",\n///         \"2.11#8\",\n///         \"4.00003028288443785#57\",\n///         \"0.000057221276833275#43\",\n///         \"0.25000005983747242139#63\",\n///         \"24576.0#12\",\n///         \"3.0e4#1\",\n///         \"1.98431#16\",\n///         \"33.5#12\",\n///         \"0.2#1\",\n///         \"0.0009768007#23\",\n///         \"1279.5#25\",\n///         \"0.125#7\",\n///         \"0.0014648735386622#42\"\n///     ]\n/// );\n/// ```\npub fn striped_random_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomPositiveFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomPositiveFiniteFloats {\n        exponents: geometric_random_signed_inclusive_range(\n            seed.fork(\"exponents\"),\n            Float::MIN_EXPONENT,\n            Float::MAX_EXPONENT,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        xs: striped_random_positive_naturals(\n            seed.fork(\"significands\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates striped random positive finite [`Float`]s with a specified precision.\n///\n/// A striped bit sequence with the given stripe parameter is generated and truncated at the bit\n/// length. The highest bit is forced to be 1, and the [`Float`] is generated from the sequence and\n/// a random sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `prec`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, or if `prec` is zero.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_positive_finite_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"0.94#4\",\n///         \"1.906e-6#11\",\n///         \"0.008#2\",\n///         \"0.5#3\",\n///         \"98332.0#21\",\n///         \"0.01416063310170989651#60\",\n///         \"0.023#2\",\n///         \"2.11#8\",\n///         \"4.00003028288443785#57\",\n///         \"0.000057221276833275#43\",\n///         \"0.25000005983747242139#63\",\n///         \"24576.0#12\",\n///         \"3.0e4#1\",\n///         \"1.98431#16\",\n///         \"33.5#12\",\n///         \"0.2#1\",\n///         \"0.0009768007#23\",\n///         \"1279.5#25\",\n///         \"0.125#7\",\n///         \"0.0014648735386622#42\"\n///     ]\n/// );\n/// ```\npub fn striped_random_positive_floats_with_precision(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    prec: u64,\n) -> RandomPositiveFiniteFloats<StripedRandomNaturalInclusiveRange> {\n    assert_ne!(prec, 0);\n    RandomPositiveFiniteFloats {\n        exponents: geometric_random_signed_inclusive_range(\n            seed.fork(\"exponents\"),\n            Float::MIN_EXPONENT,\n            Float::MAX_EXPONENT,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        xs: striped_random_natural_inclusive_range(\n            seed.fork(\"significands\"),\n            Natural::power_of_2(prec - 1),\n            Natural::low_mask(prec),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates striped random negative finite [`Float`]s.\n///\n/// The actual precision is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_stripe_numerator / mean_stripe_denominator`; $m$ must be greater than 0. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Float`] is generated from the sequence and a random\n/// sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_precision_numerator` or `mean_precision_denominator` are\n/// zero, or, if after being reduced to lowest terms, their sum is greater than or equal to\n/// $2^{64}$.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_negative_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_negative_finite_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-0.94#4\",\n///         \"-1.906e-6#11\",\n///         \"-0.008#2\",\n///         \"-0.5#3\",\n///         \"-98332.0#21\",\n///         \"-0.01416063310170989651#60\",\n///         \"-0.023#2\",\n///         \"-2.11#8\",\n///         \"-4.00003028288443785#57\",\n///         \"-0.000057221276833275#43\",\n///         \"-0.25000005983747242139#63\",\n///         \"-24576.0#12\",\n///         \"-3.0e4#1\",\n///         \"-1.98431#16\",\n///         \"-33.5#12\",\n///         \"-0.2#1\",\n///         \"-0.0009768007#23\",\n///         \"-1279.5#25\",\n///         \"-0.125#7\",\n///         \"-0.0014648735386622#42\"\n///     ]\n/// );\n/// ```\npub fn striped_random_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomNegativeFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNegativeFiniteFloats(striped_random_positive_finite_floats(\n        seed,\n        mean_sci_exponent_abs_numerator,\n        mean_sci_exponent_abs_denominator,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n        mean_precision_numerator,\n        mean_precision_denominator,\n    ))\n}\n\n/// Generates striped random non-negative finite [`Float`]s.\n///\n/// Positive zero is generated with the specified probability. If the [`Float`] to be generated is\n/// nonzero, then the actual precision is chosen from a geometric distribution with mean $m$, where\n/// $m$ is `mean_stripe_numerator / mean_stripe_denominator`; $m$ must be greater than 0. A striped\n/// bit sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Float`] is generated from the sequence and a random\n/// sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// Positive zero is generated, but negative zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_precision_numerator` or `mean_precision_denominator` are\n/// zero, or, if after being reduced to lowest terms, their sum is greater than or equal to\n/// $2^{64}$.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_non_negative_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_non_negative_finite_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1, 1, 10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"6.6e4#7\",\n///         \"0.021484375#26\",\n///         \"8.40496e6#19\",\n///         \"0.0\",\n///         \"0.0155065#16\",\n///         \"0.03121951#20\",\n///         \"3.94#6\",\n///         \"2.0038#15\",\n///         \"0.6171265#21\",\n///         \"16383.978515147231406#61\",\n///         \"12.0#14\",\n///         \"0.0195310124#31\",\n///         \"380.00023#25\",\n///         \"0.0\",\n///         \"1511.5#12\",\n///         \"0.00091559#14\",\n///         \"32799.999752045#46\",\n///         \"0.0\",\n///         \"0.0000305#6\",\n///         \"24.0#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn striped_random_non_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomNonNegativeFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNonNegativeFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: striped_random_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates striped random non-positive finite [`Float`]s.\n///\n/// Negative zero is generated with the specified probability. If the [`Float`] to be generated is\n/// nonzero, then the actual precision is chosen from a geometric distribution with mean $m$, where\n/// $m$ is `mean_stripe_numerator / mean_stripe_denominator`; $m$ must be greater than 0. A striped\n/// bit sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Float`] is generated from the sequence and a random\n/// sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// Negative zero is generated, but positive zero is not. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_precision_numerator` or `mean_precision_denominator` are\n/// zero, or, if after being reduced to lowest terms, their sum is greater than or equal to\n/// $2^{64}$.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_non_positive_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_non_positive_finite_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1, 1, 10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-6.6e4#7\",\n///         \"-0.021484375#26\",\n///         \"-8.40496e6#19\",\n///         \"-0.0\",\n///         \"-0.0155065#16\",\n///         \"-0.03121951#20\",\n///         \"-3.94#6\",\n///         \"-2.0038#15\",\n///         \"-0.6171265#21\",\n///         \"-16383.978515147231406#61\",\n///         \"-12.0#14\",\n///         \"-0.0195310124#31\",\n///         \"-380.00023#25\",\n///         \"-0.0\",\n///         \"-1511.5#12\",\n///         \"-0.00091559#14\",\n///         \"-32799.999752045#46\",\n///         \"-0.0\",\n///         \"-0.0000305#6\",\n///         \"-24.0#2\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn striped_random_non_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomNonPositiveFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNonPositiveFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: striped_random_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates striped random nonzero finite [`Float`]s.\n///\n/// The actual precision is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_stripe_numerator / mean_stripe_denominator`; $m$ must be greater than 0. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Float`] is generated from the sequence and a random\n/// sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// Neither positive nor negative zero is generated. `NaN` is not generated either.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_precision_numerator` or `mean_precision_denominator` are\n/// zero, or, if after being reduced to lowest terms, their sum is greater than or equal to\n/// $2^{64}$.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_nonzero_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_nonzero_finite_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-6.6e4#7\",\n///         \"-0.021484375#26\",\n///         \"-8.40496e6#19\",\n///         \"0.0155065#16\",\n///         \"-0.03121951#20\",\n///         \"3.94#6\",\n///         \"-2.0038#15\",\n///         \"-0.6171265#21\",\n///         \"-16383.978515147231406#61\",\n///         \"12.0#14\",\n///         \"0.0195310124#31\",\n///         \"380.00023#25\",\n///         \"-1511.5#12\",\n///         \"-0.00091559#14\",\n///         \"32799.999752045#46\",\n///         \"-0.0000305#6\",\n///         \"-24.0#2\",\n///         \"-64.0#9\",\n///         \"-7.6e2#7\",\n///         \"-287.76562497#34\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn striped_random_nonzero_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomNonzeroFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomNonzeroFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: striped_random_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n/// Generates striped random finite [`Float`]s.\n///\n/// Zero is generated with the specified probability. If the [`Float`] to be generated is nonzero,\n/// then the actual precision is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_stripe_numerator / mean_stripe_denominator`; $m$ must be greater than 0. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Float`] is generated from the sequence and a random\n/// sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// Both positive and negative zero are generated. `NaN` is not.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_precision_numerator` or `mean_precision_denominator` are\n/// zero, or, if after being reduced to lowest terms, their sum is greater than or equal to\n/// $2^{64}$.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_finite_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_finite_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1, 1, 10)\n///         .take(20)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"-3.8921#14\",\n///         \"-2.60770320922795e-8#47\",\n///         \"-0.09375#11\",\n///         \"527.999999754#38\",\n///         \"-0.00051#7\",\n///         \"1.00385#17\",\n///         \"-1.9e-6#3\",\n///         \"-5.2427e5#16\",\n///         \"-0.000440707#18\",\n///         \"7.8#5\",\n///         \"0.0\",\n///         \"0.12451#12\",\n///         \"-1.992187#21\",\n///         \"-3.0e9#2\",\n///         \"0.0625#8\",\n///         \"-0.22#3\",\n///         \"-0.01562#11\",\n///         \"-3.8e-6#4\",\n///         \"-64.0#13\",\n///         \"-4064.0#19\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn striped_random_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: striped_random_non_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n    }\n}\n\n/// Generates striped random finite [`Float`]s.\n///\n/// Special values (NaN, infinities, and zeros) are generated with the specified probability. If the\n/// [`Float`] to be generated is finite and nonzero, then the actual precision is chosen from a\n/// geometric distribution with mean $m$, where $m$ is `mean_stripe_numerator /\n/// mean_stripe_denominator`; $m$ must be greater than 0. A striped bit sequence with the given\n/// stripe parameter is generated and truncated at the bit length. The highest bit is forced to be\n/// 1, and the [`Float`] is generated from the sequence and a random sci-exponent.\n///\n/// See [`StripedBitSource`](malachite_base::num::random::striped::StripedBitSource) for information\n/// about generating striped random numbers.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_precision_numerator` or `mean_precision_denominator` are\n/// zero, or, if after being reduced to lowest terms, their sum is greater than or equal to\n/// $2^{64}$.\n///\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_float::random::striped_random_floats;\n/// use malachite_float::ComparableFloat;\n///\n/// // The number after the '#' is the precision.\n/// assert_eq!(\n///     striped_random_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1, 1, 10)\n///         .take(50)\n///         .map(|f| ComparableFloat(f).to_string())\n///         .collect_vec()\n///         .as_slice(),\n///     &[\n///         \"7.9998#15\",\n///         \"32.8#9\",\n///         \"0.0\",\n///         \"NaN\",\n///         \"-0.00005#2\",\n///         \"-5.0e2#1\",\n///         \"-0.1249#10\",\n///         \"-127.4999852#28\",\n///         \"0.4999999#22\",\n///         \"0.000243902209#28\",\n///         \"-0.11719#11\",\n///         \"-9.96875#23\",\n///         \"-15.9844663292160586998132#75\",\n///         \"Infinity\",\n///         \"-0.48#5\",\n///         \"-1.41e-11#5\",\n///         \"-262144.0#21\",\n///         \"NaN\",\n///         \"8.875#12\",\n///         \"-0.0\",\n///         \"-0.00586#7\",\n///         \"0.06#1\",\n///         \"0.12695307#22\",\n///         \"0.00006098#10\",\n///         \"-3.073363e-8#22\",\n///         \"1024.0#9\",\n///         \"-3.1519e7#13\",\n///         \"483.9384763#31\",\n///         \"9.8324e-7#17\",\n///         \"Infinity\",\n///         \"-24.0#6\",\n///         \"-4.0e-15#1\",\n///         \"-Infinity\",\n///         \"0.6083984445#31\",\n///         \"-1.0e3#4\",\n///         \"-0.0000153#7\",\n///         \"-1.0e5#2\",\n///         \"3.8297144e-6#24\",\n///         \"-0.0001235#10\",\n///         \"-0.0\",\n///         \"-23.94#9\",\n///         \"0.2#1\",\n///         \"-0.007326125891#31\",\n///         \"3.818422533722416844e-6#61\",\n///         \"-0.00048828123727#34\",\n///         \"0.0000151538#16\",\n///         \"NaN\",\n///         \"-0.0\",\n///         \"7.0e7#1\",\n///         \"20423.984375#33\"\n///     ]\n/// );\n/// ```\n#[inline]\npub fn striped_random_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<RandomFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>>>\n{\n    with_special_values(\n        seed,\n        vec![Float::INFINITY, Float::NEGATIVE_INFINITY, Float::NAN],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            striped_random_finite_floats(\n                seed_2,\n                mean_sci_exponent_abs_numerator,\n                mean_sci_exponent_abs_denominator,\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n                mean_special_p_numerator,\n                mean_special_p_denominator,\n            )\n        },\n    )\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Infinity, NaN, Zero};\nuse crate::test_util::common::rug_float_significant_bits;\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering::{self, *};\nuse std::cmp::max;\n\npub fn rug_add_prec_round(\n    x: &rug::Float,\n    y: &rug::Float,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut sum = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sum.assign_round(x + y, rm);\n    (sum, o)\n}\n\n#[inline]\npub fn rug_add_round(x: &rug::Float, y: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_add_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        rm,\n    )\n}\n\n#[inline]\npub fn rug_add_prec(x: &rug::Float, y: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_add_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_add(x: &rug::Float, y: &rug::Float) -> rug::Float {\n    rug_add_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        Round::Nearest,\n    )\n    .0\n}\n\npub fn rug_add_rational_prec_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut sum = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sum.assign_round(x + y, rm);\n    (sum, o)\n}\n\npub fn rug_add_rational_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    rug_add_rational_prec_round(x, y, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_add_rational_prec(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n) -> (rug::Float, Ordering) {\n    rug_add_rational_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_add_rational(x: &rug::Float, y: &rug::Rational) -> rug::Float {\n    rug_add_rational_prec_round(x, y, rug_float_significant_bits(x), Round::Nearest).0\n}\n\npub fn add_prec_round_naive(x: Float, y: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (float_nan!(), _)\n        | (_, float_nan!())\n        | (float_infinity!(), float_negative_infinity!())\n        | (float_negative_infinity!(), float_infinity!()) => (float_nan!(), Equal),\n        (float_infinity!(), _) | (_, float_infinity!()) => (float_infinity!(), Equal),\n        (float_negative_infinity!(), _) | (_, float_negative_infinity!()) => {\n            (float_negative_infinity!(), Equal)\n        }\n        (float_zero!(), float_negative_zero!()) | (float_negative_zero!(), float_zero!()) => (\n            if rm == Floor {\n                float_negative_zero!()\n            } else {\n                float_zero!()\n            },\n            Equal,\n        ),\n        (float_either_zero!(), mut z) | (mut z, float_either_zero!()) => {\n            let o = z.set_prec_round(prec, rm);\n            (z, o)\n        }\n        (x, y) => {\n            let (mut sum, o) = Float::from_rational_prec_round(\n                Rational::exact_from(x) + Rational::exact_from(y),\n                prec,\n                rm,\n            );\n            if rm == Floor && o == Equal && sum == 0u32 {\n                sum.neg_assign();\n            }\n            (sum, o)\n        }\n    }\n}\n\npub fn add_rational_prec_round_naive(\n    x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (x @ Float(NaN | Infinity { .. }), _) => (x, Equal),\n        (float_negative_zero!(), y) => {\n            if y == 0u32 {\n                (float_negative_zero!(), Equal)\n            } else {\n                Float::from_rational_prec_round(y, prec, rm)\n            }\n        }\n        (float_zero!(), y) => Float::from_rational_prec_round(y, prec, rm),\n        (x, y) => {\n            let (mut sum, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) + y, prec, rm);\n            if rm == Floor && sum == 0u32 {\n                sum.neg_assign();\n            }\n            (sum, o)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/agm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Infinity, NaN, Zero};\nuse crate::basic::extended::{ExtendedFloat, agm_prec_round_normal_ref_ref_extended};\nuse crate::test_util::common::rug_float_significant_bits;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering::{self, *};\nuse std::cmp::max;\n\npub fn rug_agm_prec_round(\n    x: &rug::Float,\n    y: &rug::Float,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut agm = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = agm.assign_round(x.agm_ref(y), rm);\n    (agm, o)\n}\n\n#[inline]\npub fn rug_agm_round(x: &rug::Float, y: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_agm_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        rm,\n    )\n}\n\n#[inline]\npub fn rug_agm_prec(x: &rug::Float, y: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_agm_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_agm(x: &rug::Float, y: &rug::Float) -> rug::Float {\n    rug_agm_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        Round::Nearest,\n    )\n    .0\n}\n\npub fn agm_prec_round_extended(\n    x: Float,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (&x, &y) {\n        (float_nan!(), _) | (_, float_nan!()) => (float_nan!(), Equal),\n        (float_infinity!(), x) | (x, float_infinity!()) if *x > 0.0 => (float_infinity!(), Equal),\n        (float_either_infinity!(), _) | (_, float_either_infinity!()) => (float_nan!(), Equal),\n        (float_either_zero!(), _) | (_, float_either_zero!()) => (float_zero!(), Equal),\n        _ => {\n            let (x, o) = agm_prec_round_normal_ref_ref_extended(\n                &ExtendedFloat::from(x),\n                &ExtendedFloat::from(y),\n                prec,\n                rm,\n            );\n            x.into_float_helper(prec, rm, o)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::test_util::common::rug_float_significant_bits;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::max;\n\npub fn div_prec_round_naive(x: Float, y: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (float_nan!(), _)\n        | (_, float_nan!())\n        | (float_either_infinity!(), float_either_infinity!())\n        | (float_either_zero!(), float_either_zero!()) => (float_nan!(), Equal),\n        (\n            Float(Infinity { sign: x_sign }),\n            Float(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n        )\n        | (Float(Finite { sign: x_sign, .. }), Float(Zero { sign: y_sign })) => (\n            Float(Infinity {\n                sign: x_sign == y_sign,\n            }),\n            Equal,\n        ),\n        (\n            Float(Zero { sign: x_sign }),\n            Float(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n        )\n        | (Float(Finite { sign: x_sign, .. }), Float(Infinity { sign: y_sign })) => (\n            Float(Zero {\n                sign: x_sign == y_sign,\n            }),\n            Equal,\n        ),\n        (x, y) => {\n            let (mut quotient, o) = Float::from_rational_prec_round(\n                Rational::exact_from(x) / Rational::exact_from(y),\n                prec,\n                rm,\n            );\n            if rm == Floor && o == Equal && quotient == 0u32 {\n                quotient.neg_assign();\n            }\n            (quotient, o)\n        }\n    }\n}\n\npub fn rug_div_prec_round(\n    x: &rug::Float,\n    y: &rug::Float,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut quotient = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = quotient.assign_round(x / y, rm);\n    (quotient, o)\n}\n\n#[inline]\npub fn rug_div_round(x: &rug::Float, y: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_div_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        rm,\n    )\n}\n\n#[inline]\npub fn rug_div_prec(x: &rug::Float, y: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_div_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_div(x: &rug::Float, y: &rug::Float) -> rug::Float {\n    rug_div_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        Round::Nearest,\n    )\n    .0\n}\n\npub fn rug_div_rational_prec_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut quotient = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = quotient.assign_round(x / y, rm);\n    (quotient, o)\n}\n\npub fn rug_div_rational_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    rug_div_rational_prec_round(x, y, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_div_rational_prec(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n) -> (rug::Float, Ordering) {\n    rug_div_rational_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_div_rational(x: &rug::Float, y: &rug::Rational) -> rug::Float {\n    rug_div_rational_prec_round(x, y, rug_float_significant_bits(x), Round::Nearest).0\n}\n\npub fn rug_rational_div_float_prec_round(\n    x: &rug::Rational,\n    y: &rug::Float,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut quotient = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = quotient.assign_round(x / y, rm);\n    (quotient, o)\n}\n\npub fn rug_rational_div_float_round(\n    x: &rug::Rational,\n    y: &rug::Float,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    rug_rational_div_float_prec_round(x, y, rug_float_significant_bits(y), rm)\n}\n\npub fn rug_rational_div_float_prec(\n    x: &rug::Rational,\n    y: &rug::Float,\n    prec: u64,\n) -> (rug::Float, Ordering) {\n    rug_rational_div_float_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_rational_div_float(x: &rug::Rational, y: &rug::Float) -> rug::Float {\n    rug_rational_div_float_prec_round(x, y, rug_float_significant_bits(y), Round::Nearest).0\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/ln.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::arithmetic::ln::ln_prec_round_normal_extended;\nuse crate::basic::extended::ExtendedFloat;\nuse crate::test_util::common::rug_float_significant_bits;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\n\npub fn rug_ln_prec_round(x: &rug::Float, prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut ln = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = ln.assign_round(x.ln_ref(), rm);\n    (ln, o)\n}\n\npub fn rug_ln_prec(x: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_ln_prec_round(x, prec, Round::Nearest)\n}\n\npub fn rug_ln_round(x: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_ln_prec_round(x, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_ln(x: &rug::Float) -> rug::Float {\n    rug_ln_prec_round(x, rug_float_significant_bits(x), Round::Nearest).0\n}\n\npub fn ln_prec_round_extended(x: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match x {\n        Float(NaN | Infinity { sign: false } | Finite { sign: false, .. }) => (float_nan!(), Equal),\n        float_either_zero!() => (float_negative_infinity!(), Equal),\n        float_infinity!() => (float_infinity!(), Equal),\n        _ => ln_prec_round_normal_extended(ExtendedFloat::from(x), prec, rm),\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod add;\npub mod agm;\npub mod div;\npub mod ln;\npub mod mul;\npub mod power_of_2;\npub mod reciprocal;\npub mod reciprocal_sqrt;\npub mod shl;\npub mod shl_round;\npub mod shr;\npub mod shr_round;\npub mod sqrt;\npub mod square;\npub mod sub;\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::malachite_base::num::arithmetic::traits::NegAssign;\nuse crate::test_util::common::rug_float_significant_bits;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::max;\n\npub fn mul_prec_round_naive(x: Float, y: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (float_nan!(), _)\n        | (_, float_nan!())\n        | (float_either_infinity!(), float_either_zero!())\n        | (float_either_zero!(), float_either_infinity!()) => (float_nan!(), Equal),\n        (\n            Float(Infinity { sign: x_sign }),\n            Float(Finite { sign: y_sign, .. } | Infinity { sign: y_sign }),\n        )\n        | (Float(Finite { sign: x_sign, .. }), Float(Infinity { sign: y_sign })) => (\n            Float(Infinity {\n                sign: x_sign == y_sign,\n            }),\n            Equal,\n        ),\n        (\n            Float(Zero { sign: x_sign }),\n            Float(Finite { sign: y_sign, .. } | Zero { sign: y_sign }),\n        )\n        | (Float(Finite { sign: x_sign, .. }), Float(Zero { sign: y_sign })) => (\n            Float(Zero {\n                sign: x_sign == y_sign,\n            }),\n            Equal,\n        ),\n        (x, y) => {\n            let (mut product, o) = Float::from_rational_prec_round(\n                Rational::exact_from(x) * Rational::exact_from(y),\n                prec,\n                rm,\n            );\n            if rm == Floor && o == Equal && product == 0u32 {\n                product.neg_assign();\n            }\n            (product, o)\n        }\n    }\n}\n\npub fn rug_mul_prec_round(\n    x: &rug::Float,\n    y: &rug::Float,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut product = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = product.assign_round(x * y, rm);\n    (product, o)\n}\n\n#[inline]\npub fn rug_mul_round(x: &rug::Float, y: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_mul_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        rm,\n    )\n}\n\n#[inline]\npub fn rug_mul_prec(x: &rug::Float, y: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_mul_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_mul(x: &rug::Float, y: &rug::Float) -> rug::Float {\n    rug_mul_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        Round::Nearest,\n    )\n    .0\n}\n\npub fn rug_mul_rational_prec_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut product = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = product.assign_round(x * y, rm);\n    (product, o)\n}\n\npub fn rug_mul_rational_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    rug_mul_rational_prec_round(x, y, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_mul_rational_prec(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n) -> (rug::Float, Ordering) {\n    rug_mul_rational_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_mul_rational(x: &rug::Float, y: &rug::Rational) -> rug::Float {\n    rug_mul_rational_prec_round(x, y, rug_float_significant_bits(x), Round::Nearest).0\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_q::Rational;\nuse std::cmp::Ordering;\n\npub fn power_of_2_prec_round_naive(pow: i64, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    Float::from_rational_prec_round(Rational::power_of_2(pow), prec, rm)\n}\n\npub fn power_of_2_prec_naive(pow: i64, prec: u64) -> (Float, Ordering) {\n    Float::from_rational_prec_round(Rational::power_of_2(pow), prec, Nearest)\n}\n\npub fn power_of_2_u64_naive(pow: u64) -> Float {\n    Float::from_rational_prec_round(Rational::power_of_2(pow), 1, Nearest).0\n}\n\npub fn power_of_2_i64_naive(pow: i64) -> Float {\n    Float::from_rational_prec_round(Rational::power_of_2(pow), 1, Nearest).0\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::test_util::common::rug_float_significant_bits;\nuse core::cmp::Ordering;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\n\npub fn reciprocal_prec_round_naive_1(x: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    Float::rational_div_float_prec_round(Rational::ONE, x, prec, rm)\n}\n\npub fn reciprocal_prec_round_naive_2(x: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    Float::ONE.div_prec_round(x, prec, rm)\n}\n\npub fn rug_reciprocal_prec_round(x: &rug::Float, prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut sum = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sum.assign_round(rug::Rational::ONE / x, rm);\n    (sum, o)\n}\n\npub fn rug_reciprocal_prec(x: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_reciprocal_prec_round(x, prec, Round::Nearest)\n}\n\npub fn rug_reciprocal_round(x: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_reciprocal_prec_round(x, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_reciprocal(x: &rug::Float) -> rug::Float {\n    rug_reciprocal_prec_round(x, rug_float_significant_bits(x), Round::Nearest).0\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/reciprocal_sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::arithmetic::reciprocal_sqrt::{\n    from_reciprocal_rational_prec_round_ref, generic_reciprocal_sqrt_rational_ref,\n};\nuse crate::test_util::common::rug_float_significant_bits;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{CheckedSqrt, FloorLogBase2, Reciprocal};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{Infinity, NaN};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\n\npub fn rug_reciprocal_sqrt_prec_round(\n    x: &rug::Float,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut sum = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sum.assign_round(x.recip_sqrt_ref(), rm);\n    (sum, o)\n}\n\npub fn rug_reciprocal_sqrt_prec(x: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_reciprocal_sqrt_prec_round(x, prec, Round::Nearest)\n}\n\npub fn rug_reciprocal_sqrt_round(x: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_reciprocal_sqrt_prec_round(x, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_reciprocal_sqrt(x: &rug::Float) -> rug::Float {\n    rug_reciprocal_sqrt_prec_round(x, rug_float_significant_bits(x), Round::Nearest).0\n}\n\npub fn reciprocal_sqrt_rational_prec_round_generic(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if *x == 0u32 {\n        return (Float::INFINITY, Equal);\n    } else if *x < 0u32 {\n        return (Float::NAN, Equal);\n    }\n    if let Some(sqrt) = x.checked_sqrt() {\n        return Float::from_rational_prec_round(sqrt.reciprocal(), prec, rm);\n    }\n    generic_reciprocal_sqrt_rational_ref(x, prec, rm)\n}\n\npub fn reciprocal_sqrt_rational_prec_round_simple(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if *x == 0u32 {\n        return (Float::INFINITY, Equal);\n    } else if *x < 0u32 {\n        return (Float::NAN, Equal);\n    }\n    if let Some(sqrt) = x.checked_sqrt() {\n        return Float::from_rational_prec_round(sqrt.reciprocal(), prec, rm);\n    }\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    let mut end_shift = x.floor_log_base_2();\n    let x2;\n    let reduced_x: &Rational;\n    if end_shift.gt_abs(&0x3fff_0000) {\n        end_shift &= !1;\n        x2 = x >> end_shift;\n        reduced_x = &x2;\n    } else {\n        end_shift = 0;\n        reduced_x = x;\n    }\n    loop {\n        let qx_lower_bound =\n            from_reciprocal_rational_prec_round_ref(reduced_x, working_prec, Floor).0;\n        let mut qx_upper_bound = qx_lower_bound.clone();\n        qx_upper_bound.increment();\n        let lower_bound = qx_lower_bound.sqrt_round(Floor).0;\n        let upper_bound = qx_upper_bound.sqrt_round(Ceiling).0;\n        let (mut sqrt_1, mut o_1) = Float::from_float_prec_round(lower_bound, prec, rm);\n        let (sqrt_2, mut o_2) = Float::from_float_prec_round(upper_bound, prec, rm);\n        if o_1 == Equal {\n            o_1 = o_2;\n        }\n        if o_2 == Equal {\n            o_2 = o_1;\n        }\n        if o_1 == o_2 && sqrt_1 == sqrt_2 {\n            if end_shift != 0 {\n                o_1 = sqrt_1.shr_prec_round_assign_helper(end_shift >> 1, prec, rm, o_1);\n            }\n            return (sqrt_1, o_1);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_q::Rational;\nuse std::ops::Shl;\n\npub fn shl_naive<T: PrimitiveInt>(x: Float, bits: T) -> Float\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    if x.is_normal() {\n        let prec = x.significant_bits();\n        Float::from_rational_prec(Rational::exact_from(x) << bits, prec).0\n    } else {\n        x\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering::{self, *};\nuse std::ops::Shl;\n\npub fn shl_prec_round_naive<T: PrimitiveInt>(\n    x: Float,\n    bits: T,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering)\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    if x.is_normal() {\n        Float::from_rational_prec_round(Rational::exact_from(x) << bits, prec, rm)\n    } else {\n        (x, Equal)\n    }\n}\n\npub fn shl_prec_naive<T: PrimitiveInt>(x: Float, bits: T, prec: u64) -> (Float, Ordering)\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    if x.is_normal() {\n        Float::from_rational_prec_round(Rational::exact_from(x) << bits, prec, Nearest)\n    } else {\n        (x, Equal)\n    }\n}\n\npub fn shl_round_naive<T: PrimitiveInt>(x: Float, bits: T, rm: RoundingMode) -> (Float, Ordering)\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    if x.is_normal() {\n        let prec = x.significant_bits();\n        Float::from_rational_prec_round(Rational::exact_from(x) << bits, prec, rm)\n    } else {\n        (x, Equal)\n    }\n}\n\npub fn rug_shl_prec_round_unsigned(\n    x: &rug::Float,\n    u: u32,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x << u, rm);\n    (shifted, o)\n}\n\npub fn rug_shl_prec_round_signed(\n    x: &rug::Float,\n    i: i32,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x << i, rm);\n    (shifted, o)\n}\n\npub fn rug_shl_prec_unsigned(x: &rug::Float, u: u32, prec: u64) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x << u, Round::Nearest);\n    (shifted, o)\n}\n\npub fn rug_shl_prec_signed(x: &rug::Float, i: i32, prec: u64) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x << i, Round::Nearest);\n    (shifted, o)\n}\n\npub fn rug_shl_round_unsigned(x: &rug::Float, u: u32, rm: Round) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(x.prec(), 0);\n    let o = shifted.assign_round(x << u, rm);\n    (shifted, o)\n}\n\npub fn rug_shl_round_signed(x: &rug::Float, i: i32, rm: Round) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(x.prec(), 0);\n    let o = shifted.assign_round(x << i, rm);\n    (shifted, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_q::Rational;\nuse std::ops::Shr;\n\npub fn shr_naive<T: PrimitiveInt>(x: Float, bits: T) -> Float\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    if x.is_normal() {\n        let prec = x.significant_bits();\n        Float::from_rational_prec(Rational::exact_from(x) >> bits, prec).0\n    } else {\n        x\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering::{self, *};\nuse std::ops::Shr;\n\npub fn shr_prec_round_naive<T: PrimitiveInt>(\n    x: Float,\n    bits: T,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering)\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    if x.is_normal() {\n        Float::from_rational_prec_round(Rational::exact_from(x) >> bits, prec, rm)\n    } else {\n        (x, Equal)\n    }\n}\n\npub fn shr_prec_naive<T: PrimitiveInt>(x: Float, bits: T, prec: u64) -> (Float, Ordering)\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    if x.is_normal() {\n        Float::from_rational_prec_round(Rational::exact_from(x) >> bits, prec, Nearest)\n    } else {\n        (x, Equal)\n    }\n}\n\npub fn shr_round_naive<T: PrimitiveInt>(x: Float, bits: T, rm: RoundingMode) -> (Float, Ordering)\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    if x.is_normal() {\n        let prec = x.significant_bits();\n        Float::from_rational_prec_round(Rational::exact_from(x) >> bits, prec, rm)\n    } else {\n        (x, Equal)\n    }\n}\n\npub fn rug_shr_prec_round_unsigned(\n    x: &rug::Float,\n    u: u32,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x >> u, rm);\n    (shifted, o)\n}\n\npub fn rug_shr_prec_round_signed(\n    x: &rug::Float,\n    i: i32,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x >> i, rm);\n    (shifted, o)\n}\n\npub fn rug_shr_prec_unsigned(x: &rug::Float, u: u32, prec: u64) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x >> u, Round::Nearest);\n    (shifted, o)\n}\n\npub fn rug_shr_prec_signed(x: &rug::Float, i: i32, prec: u64) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = shifted.assign_round(x >> i, Round::Nearest);\n    (shifted, o)\n}\n\npub fn rug_shr_round_unsigned(x: &rug::Float, u: u32, rm: Round) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(x.prec(), 0);\n    let o = shifted.assign_round(x >> u, rm);\n    (shifted, o)\n}\n\npub fn rug_shr_round_signed(x: &rug::Float, i: i32, rm: Round) -> (rug::Float, Ordering) {\n    let mut shifted = rug::Float::with_val(x.prec(), 0);\n    let o = shifted.assign_round(x >> i, rm);\n    (shifted, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::arithmetic::sqrt::generic_sqrt_rational_ref;\nuse crate::malachite_base::num::basic::traits::NaN;\nuse crate::test_util::common::rug_float_significant_bits;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{CheckedSqrt, FloorLogBase2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\n\npub fn rug_sqrt_prec_round(x: &rug::Float, prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut sqrt = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sqrt.assign_round(x.sqrt_ref(), rm);\n    (sqrt, o)\n}\n\npub fn rug_sqrt_prec(x: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_sqrt_prec_round(x, prec, Round::Nearest)\n}\n\npub fn rug_sqrt_round(x: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_sqrt_prec_round(x, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_sqrt(x: &rug::Float) -> rug::Float {\n    rug_sqrt_prec_round(x, rug_float_significant_bits(x), Round::Nearest).0\n}\n\npub fn sqrt_rational_prec_round_generic(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if *x < 0u32 {\n        return (Float::NAN, Equal);\n    }\n    if let Some(sqrt) = x.checked_sqrt() {\n        return Float::from_rational_prec_round(sqrt, prec, rm);\n    }\n    generic_sqrt_rational_ref(x, prec, rm)\n}\n\npub fn sqrt_rational_prec_round_simple(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    if *x < 0u32 {\n        return (Float::NAN, Equal);\n    }\n    if let Some(sqrt) = x.checked_sqrt() {\n        return Float::from_rational_prec_round(sqrt, prec, rm);\n    }\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    let mut end_shift = x.floor_log_base_2();\n    let x2;\n    let reduced_x: &Rational;\n    if end_shift.gt_abs(&0x3fff_0000) {\n        end_shift &= !1;\n        x2 = x >> end_shift;\n        reduced_x = &x2;\n    } else {\n        end_shift = 0;\n        reduced_x = x;\n    }\n    loop {\n        let qx_lower_bound = Float::from_rational_prec_round_ref(reduced_x, working_prec, Floor).0;\n        let mut qx_upper_bound = qx_lower_bound.clone();\n        qx_upper_bound.increment();\n        let lower_bound = qx_lower_bound.sqrt_round(Floor).0;\n        let upper_bound = qx_upper_bound.sqrt_round(Ceiling).0;\n        let (mut sqrt_1, mut o_1) = Float::from_float_prec_round(lower_bound, prec, rm);\n        let (sqrt_2, mut o_2) = Float::from_float_prec_round(upper_bound, prec, rm);\n        if o_1 == Equal {\n            o_1 = o_2;\n        }\n        if o_2 == Equal {\n            o_2 = o_1;\n        }\n        if o_1 == o_2 && sqrt_1 == sqrt_2 {\n            if end_shift != 0 {\n                o_1 = sqrt_1.shl_prec_round_assign_helper(end_shift >> 1, prec, rm, o_1);\n            }\n            return (sqrt_1, o_1);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::test_util::common::rug_float_significant_bits;\nuse core::cmp::Ordering;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\n\npub fn square_prec_round_naive(x: Float, prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    x.clone().mul_prec_round(x, prec, rm)\n}\n\npub fn rug_square_prec_round(x: &rug::Float, prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut square = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = square.assign_round(x.square_ref(), rm);\n    (square, o)\n}\n\npub fn rug_square_prec(x: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_square_prec_round(x, prec, Round::Nearest)\n}\n\npub fn rug_square_round(x: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_square_prec_round(x, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_square(x: &rug::Float) -> rug::Float {\n    rug_square_prec_round(x, rug_float_significant_bits(x), Round::Nearest).0\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Infinity, NaN, Zero};\nuse crate::test_util::common::rug_float_significant_bits;\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_q::Rational;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering::{self, *};\nuse std::cmp::max;\n\npub fn rug_sub_prec_round(\n    x: &rug::Float,\n    y: &rug::Float,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut diff = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = diff.assign_round(x - y, rm);\n    (diff, o)\n}\n\n#[inline]\npub fn rug_sub_round(x: &rug::Float, y: &rug::Float, rm: Round) -> (rug::Float, Ordering) {\n    rug_sub_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        rm,\n    )\n}\n\n#[inline]\npub fn rug_sub_prec(x: &rug::Float, y: &rug::Float, prec: u64) -> (rug::Float, Ordering) {\n    rug_sub_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_sub(x: &rug::Float, y: &rug::Float) -> rug::Float {\n    rug_sub_prec_round(\n        x,\n        y,\n        max(rug_float_significant_bits(x), rug_float_significant_bits(y)),\n        Round::Nearest,\n    )\n    .0\n}\n\npub fn rug_sub_rational_prec_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    let mut diff = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = diff.assign_round(x - y, rm);\n    (diff, o)\n}\n\npub fn rug_sub_rational_round(\n    x: &rug::Float,\n    y: &rug::Rational,\n    rm: Round,\n) -> (rug::Float, Ordering) {\n    rug_sub_rational_prec_round(x, y, rug_float_significant_bits(x), rm)\n}\n\npub fn rug_sub_rational_prec(\n    x: &rug::Float,\n    y: &rug::Rational,\n    prec: u64,\n) -> (rug::Float, Ordering) {\n    rug_sub_rational_prec_round(x, y, prec, Round::Nearest)\n}\n\npub fn rug_sub_rational(x: &rug::Float, y: &rug::Rational) -> rug::Float {\n    rug_sub_rational_prec_round(x, y, rug_float_significant_bits(x), Round::Nearest).0\n}\n\npub fn sub_rational_prec_round_naive(\n    x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    assert_ne!(prec, 0);\n    match (x, y) {\n        (x @ Float(NaN | Infinity { .. }), _) => (x, Equal),\n        (float_negative_zero!(), y) => {\n            if y == 0u32 {\n                (float_negative_zero!(), Equal)\n            } else {\n                Float::from_rational_prec_round(-y, prec, rm)\n            }\n        }\n        (float_zero!(), y) => Float::from_rational_prec_round(-y, prec, rm),\n        (x, y) => {\n            let (mut diff, o) =\n                Float::from_rational_prec_round(Rational::exact_from(x) - y, prec, rm);\n            if rm == Floor && diff == 0u32 {\n                diff.neg_assign();\n            }\n            (diff, o)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/bench/bucketers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::bench::bucketers::{Bucketer, float_size};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse std::cmp::max;\n\npub fn pair_1_float_complexity_bucketer<T>(var_name: &str) -> Bucketer<'_, (Float, T)> {\n    Bucketer {\n        bucketing_function: &|(x, _)| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn pair_2_pair_1_float_complexity_bucketer<T, U>(\n    var_name: &str,\n) -> Bucketer<'_, (T, (Float, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, _))| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn pair_2_float_complexity_bucketer<T>(var_name: &str) -> Bucketer<'_, (T, Float)> {\n    Bucketer {\n        bucketing_function: &|(_, x)| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn triple_1_float_complexity_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (Float, T, U)> {\n    Bucketer {\n        bucketing_function: &|(x, _, _)| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn pair_2_triple_1_float_complexity_bucketer<T, U, V>(\n    var_name: &str,\n) -> Bucketer<'_, (V, (Float, T, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, _, _))| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn quadruple_1_float_complexity_bucketer<T, U, V>(\n    var_name: &str,\n) -> Bucketer<'_, (Float, T, U, V)> {\n    Bucketer {\n        bucketing_function: &|(x, _, _, _)| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn pair_2_quadruple_1_float_complexity_bucketer<T, U, V, W>(\n    var_name: &str,\n) -> Bucketer<'_, (W, (Float, T, U, V))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, _, _, _))| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn float_complexity_bucketer(var_name: &str) -> Bucketer<'_, Float> {\n    Bucketer {\n        bucketing_function: &|x| usize::exact_from(x.complexity()),\n        bucketing_label: format!(\"{var_name}.complexity()\"),\n    }\n}\n\npub fn pair_float_max_complexity_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, Float)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.complexity(), y.complexity())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.complexity())\"),\n    }\n}\n\npub fn triple_1_2_float_max_complexity_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, Float, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| usize::exact_from(max(x.complexity(), y.complexity())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.complexity())\"),\n    }\n}\n\npub fn pair_2_triple_1_2_float_max_complexity_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (U, (Float, Float, T))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, _))| {\n            usize::exact_from(max(x.complexity(), y.complexity()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.complexity())\"),\n    }\n}\n\npub fn triple_1_2_float_rational_max_complexity_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, Rational, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| {\n            usize::exact_from(max(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_triple_1_2_float_rational_max_complexity_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (U, (Float, Rational, T))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, _))| {\n            usize::exact_from(max(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_float_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, T)> {\n    Bucketer {\n        bucketing_function: &|(x, z)| usize::exact_from(max!(x.complexity(), z.significant_bits())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits)\"),\n    }\n}\n\npub fn pair_2_pair_float_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (U, (Float, T))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, z))| {\n            usize::exact_from(max!(x.complexity(), z.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits)\"),\n    }\n}\n\npub fn triple_float_float_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Float, Float, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(x.complexity(), y.complexity(), z.significant_bits()))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.complexity(), {z_name}.significant_bits)\"\n        ),\n    }\n}\n\npub fn pair_2_triple_float_float_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (U, (Float, Float, T))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, z))| {\n            usize::exact_from(max!(x.complexity(), y.complexity(), z.significant_bits()))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.complexity(), {z_name}.significant_bits)\"\n        ),\n    }\n}\n\npub fn triple_1_2_float_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, T, U)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| {\n            usize::exact_from(max!(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_triple_1_2_float_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt, U, V>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (V, (Float, T, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, _))| {\n            usize::exact_from(max!(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Float, Float, T, U)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z, _)| {\n            usize::exact_from(max!(x.complexity(), y.complexity(), z.significant_bits()))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.complexity(), {z_name}.significant_bits())\"\n        ),\n    }\n}\n\npub fn pair_2_quadruple_1_2_3_float_float_primitive_int_max_complexity_bucketer<\n    'a,\n    T: PrimitiveInt,\n    U,\n    V,\n>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (V, (Float, Float, T, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, z, _))| {\n            usize::exact_from(max!(x.complexity(), y.complexity(), z.significant_bits()))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.complexity(), {z_name}.significant_bits())\"\n        ),\n    }\n}\n\npub fn quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer<\n    'a,\n    T: PrimitiveInt,\n    U,\n>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Float, Rational, T, U)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z, _)| {\n            usize::exact_from(max!(\n                x.complexity(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.significant_bits(), {z_name}.significant_bits())\"\n        ),\n    }\n}\n\npub fn pair_2_quadruple_1_2_3_float_rational_primitive_int_max_complexity_bucketer<\n    'a,\n    T: PrimitiveInt,\n    U,\n    V,\n>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (V, (Float, Rational, T, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, z, _))| {\n            usize::exact_from(max!(\n                x.complexity(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.significant_bits(), {z_name}.significant_bits())\"\n        ),\n    }\n}\n\npub fn triple_float_rational_primitive_int_max_complexity_bucketer<'a, T: PrimitiveInt>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Float, Rational, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(\n                x.complexity(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.significant_bits(), {z_name}.significant_bits)\"\n        ),\n    }\n}\n\npub fn pair_2_triple_float_rational_primitive_int_max_complexity_bucketer<\n    'a,\n    T: PrimitiveInt,\n    U,\n>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (U, (Float, Rational, T))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, z))| {\n            usize::exact_from(max!(\n                x.complexity(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.complexity(), {y_name}.significant_bits(), {z_name}.significant_bits)\"\n        ),\n    }\n}\n\npub fn pair_2_pair_float_max_complexity_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, Float))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| usize::exact_from(max(x.complexity(), y.complexity())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.complexity())\"),\n    }\n}\n\npub fn pair_float_integer_max_complexity_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, Integer)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.complexity(), y.significant_bits())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_float_natural_max_complexity_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.complexity(), y.significant_bits())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_float_rational_max_complexity_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, Rational)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.complexity(), y.significant_bits())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_float_unsigned_max_complexity_bucketer<'a, T: PrimitiveUnsigned>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.complexity(), y.significant_bits())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_float_signed_max_complexity_bucketer<'a, T: PrimitiveSigned>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.complexity(), y.significant_bits())),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_float_integer_max_complexity_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, Integer))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_float_natural_max_complexity_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_float_rational_max_complexity_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, Rational))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_float_unsigned_max_complexity_bucketer<'a, T, U: PrimitiveUnsigned>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_float_signed_max_complexity_bucketer<'a, T, U: PrimitiveSigned>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.complexity(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_float_primitive_float_max_complexity_bucketer<'a, T, U: PrimitiveFloat>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.complexity(), u64::exact_from(float_size(*y))))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_float_primitive_float_max_complexity_bucketer<'a, T: PrimitiveFloat>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.complexity(), u64::exact_from(float_size(*y))))\n        },\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn max_triple_1_float_complexity_triple_2_bucketer<'a, T>(\n    x_name: &'a str,\n    p_name: &'a str,\n) -> Bucketer<'a, (Float, u64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, p, _)| usize::exact_from(max(x.complexity(), *p)),\n        bucketing_label: format!(\"max({x_name}.complexity(), {p_name})\"),\n    }\n}\n\npub fn pair_2_max_triple_1_float_complexity_triple_2_bucketer<'a, T, U>(\n    x_name: &'a str,\n    p_name: &'a str,\n) -> Bucketer<'a, (T, (Float, u64, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, p, _))| usize::exact_from(max(x.complexity(), *p)),\n        bucketing_label: format!(\"max({x_name}.complexity(), {p_name})\"),\n    }\n}\n\npub fn max_pair_1_complexity_pair_2_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Float, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.complexity(), *y)),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name})\"),\n    }\n}\n\npub fn pair_2_max_pair_1_complexity_pair_2_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Float, u64))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| usize::exact_from(max(x.complexity(), *y)),\n        bucketing_label: format!(\"max({x_name}.complexity(), {y_name})\"),\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod bucketers;\n"
  },
  {
    "path": "malachite-float/src/test_util/common/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse crate::{ComparableFloatRef, Float, significand_bits};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity as InfinityTrait, NaN as NaNTrait, NegativeInfinity, NegativeZero, Zero as ZeroTrait,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, FromStringBase};\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse rug::float::{Round, Special};\nuse std::cmp::Ordering;\n\n// Can't have From impl due to orphan rule. We could define an impl in malachite-base where\n// RoundingMode is defined, but pulling in rug::float just for that purpose seems overkill.\npub const fn rounding_mode_from_rug_round(rm: Round) -> RoundingMode {\n    match rm {\n        Round::Nearest => Nearest,\n        Round::Zero => Down,\n        Round::Up => Ceiling,\n        Round::Down => Floor,\n        Round::AwayZero => Up,\n        _ => panic!(),\n    }\n}\n\n#[allow(clippy::result_unit_err)]\npub const fn rug_round_try_from_rounding_mode(rm: RoundingMode) -> Result<Round, ()> {\n    match rm {\n        Floor => Ok(Round::Down),\n        Ceiling => Ok(Round::Up),\n        Down => Ok(Round::Zero),\n        Up => Ok(Round::AwayZero),\n        Nearest => Ok(Round::Nearest),\n        Exact => Err(()),\n    }\n}\n\n#[inline]\npub fn rug_round_exact_from_rounding_mode(rm: RoundingMode) -> Round {\n    rug_round_try_from_rounding_mode(rm).unwrap()\n}\n\nimpl From<&rug::Float> for Float {\n    fn from(x: &rug::Float) -> Self {\n        if x.is_nan() {\n            Self::NAN\n        } else if x.is_infinite() {\n            if x.is_sign_positive() {\n                Self::INFINITY\n            } else {\n                Self::NEGATIVE_INFINITY\n            }\n        } else if x.is_zero() {\n            if x.is_sign_positive() {\n                Self::ZERO\n            } else {\n                Self::NEGATIVE_ZERO\n            }\n        } else {\n            let mut significand = Natural::exact_from(&*x.get_significand().unwrap());\n            let precision = u64::from(x.prec());\n            if significand.significant_bits() - precision >= Limb::WIDTH {\n                // can only happen when 32_bit_limbs is set\n                significand >>= Limb::WIDTH;\n            }\n            let result = Self(Finite {\n                sign: x.is_sign_positive(),\n                exponent: x.get_exp().unwrap(),\n                precision,\n                significand,\n            });\n            assert!(result.is_valid());\n            result\n        }\n    }\n}\n\nfn convert_prec(prec: u64) -> Result<u32, ()> {\n    u32::try_from(prec).map_err(|_| ())\n}\n\n#[allow(clippy::unnecessary_wraps)]\nfn special_float(prec: u32, value: Special) -> Result<rug::Float, ()> {\n    Ok(rug::Float::with_val_round(prec, value, Round::Zero).0)\n}\n\npub fn rug_float_significant_bits(x: &rug::Float) -> u64 {\n    if x.is_normal() {\n        u64::from(x.prec())\n    } else {\n        1\n    }\n}\n\nimpl TryFrom<&Float> for rug::Float {\n    type Error = ();\n\n    fn try_from(x: &Float) -> Result<Self, ()> {\n        match x {\n            float_nan!() => special_float(1, Special::Nan),\n            float_infinity!() => special_float(1, Special::Infinity),\n            float_negative_infinity!() => special_float(1, Special::NegInfinity),\n            float_zero!() => special_float(1, Special::Zero),\n            float_negative_zero!() => special_float(1, Special::NegZero),\n            Float(Finite {\n                sign,\n                exponent,\n                precision,\n                significand,\n            }) => {\n                let mut f = Self::with_val_round(\n                    convert_prec(*precision)?,\n                    rug::Integer::from(significand),\n                    Round::Zero,\n                )\n                .0;\n                f >>= i32::try_from(\n                    i64::exact_from(significand_bits(significand)) - i64::from(*exponent),\n                )\n                .map_err(|_| ())?;\n                if !sign {\n                    f = -f;\n                }\n                Ok(f)\n            }\n        }\n    }\n}\n\npub fn parse_hex_string(s_hex: &str) -> Float {\n    let x = Float::from_string_base(16, s_hex).unwrap();\n    assert_eq!(format!(\"{:#x}\", ComparableFloatRef(&x)), s_hex);\n    x\n}\n\npub fn to_hex_string(x: &Float) -> String {\n    format!(\"{:#x}\", ComparableFloatRef(x))\n}\n\npub const ORDERED_FLOAT_STRINGS: [&str; 21] = [\n    \"-Infinity\",\n    \"-3.1415926535897931\",\n    \"-2.0\",\n    \"-1.4142135623730951\",\n    \"-1.0\",\n    \"-1.0\",\n    \"-1.0\",\n    \"-0.5\",\n    \"-0.33333333333333331\",\n    \"-0.0\",\n    \"NaN\",\n    \"0.0\",\n    \"0.33333333333333331\",\n    \"0.5\",\n    \"1.0\",\n    \"1.0\",\n    \"1.0\",\n    \"1.4142135623730951\",\n    \"2.0\",\n    \"3.1415926535897931\",\n    \"Infinity\",\n];\n\npub const ORDERED_FLOAT_HEX_STRINGS: [&str; 21] = [\n    \"-Infinity\",\n    \"-0x3.243f6a8885a30#53\",\n    \"-0x2.0#1\",\n    \"-0x1.6a09e667f3bcd#53\",\n    \"-0x1.0000000000000000000000000#100\",\n    \"-0x1.0#2\",\n    \"-0x1.0#1\",\n    \"-0x0.8#1\",\n    \"-0x0.55555555555554#53\",\n    \"-0x0.0\",\n    \"NaN\",\n    \"0x0.0\",\n    \"0x0.55555555555554#53\",\n    \"0x0.8#1\",\n    \"0x1.0#1\",\n    \"0x1.0#2\",\n    \"0x1.0000000000000000000000000#100\",\n    \"0x1.6a09e667f3bcd#53\",\n    \"0x2.0#1\",\n    \"0x3.243f6a8885a30#53\",\n    \"Infinity\",\n];\n\npub const ORDERED_F32S: [f32; 17] = [\n    f32::NEGATIVE_INFINITY,\n    -std::f32::consts::PI,\n    -2.0,\n    -std::f32::consts::SQRT_2,\n    -1.0,\n    -0.5,\n    -1.0 / 3.0,\n    -0.0,\n    f32::NAN,\n    0.0,\n    1.0 / 3.0,\n    0.5,\n    1.0,\n    std::f32::consts::SQRT_2,\n    2.0,\n    std::f32::consts::PI,\n    f32::INFINITY,\n];\n\npub const ORDERED_F64S: [f64; 17] = [\n    f64::NEGATIVE_INFINITY,\n    -std::f64::consts::PI,\n    -2.0,\n    -std::f64::consts::SQRT_2,\n    -1.0,\n    -0.5,\n    -1.0 / 3.0,\n    -0.0,\n    f64::NAN,\n    0.0,\n    1.0 / 3.0,\n    0.5,\n    1.0,\n    std::f64::consts::SQRT_2,\n    2.0,\n    std::f64::consts::PI,\n    f64::INFINITY,\n];\n\n// Tests that rounding with Floor and gradually increasing precision preserves all previous bits.\npub fn test_constant<F: Fn(u64, RoundingMode) -> (Float, Ordering)>(f: F, limit: u64) {\n    let mut bit_index = Limb::WIDTH - 1;\n    let mut significand = Natural::ZERO;\n    for prec in 1..limit {\n        let x = f(prec, Floor).0;\n        let x_sig = x.significand_ref().unwrap();\n        if *x_sig != significand {\n            significand.set_bit(bit_index);\n            assert_eq!(*x_sig, significand);\n        }\n        if bit_index == 0 {\n            significand <<= Limb::WIDTH;\n            bit_index = Limb::WIDTH - 1;\n        } else {\n            bit_index -= 1;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod partial_cmp_rational;\n"
  },
  {
    "path": "malachite-float/src/test_util/comparison/partial_cmp_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::{Finite, Infinity, NaN, Zero};\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\n\npub fn float_partial_cmp_rational_alt(x: &Float, other: &Rational) -> Option<Ordering> {\n    match (x, other) {\n        (float_nan!(), _) => None,\n        (float_infinity!(), _) => Some(Greater),\n        (float_negative_infinity!(), _) => Some(Less),\n        (float_either_zero!(), y) => 0u32.partial_cmp(y),\n        (\n            Float(Finite {\n                sign: s_x,\n                exponent: e_x,\n                ..\n            }),\n            y,\n        ) => Some(if *y == 0u32 {\n            if *s_x { Greater } else { Less }\n        } else {\n            let s_cmp = s_x.cmp(&(*y > 0));\n            if s_cmp != Equal {\n                return Some(s_cmp);\n            }\n            let ord_cmp = (i64::from(*e_x) - 1).cmp(&other.floor_log_base_2_abs());\n            if ord_cmp == Equal {\n                Rational::try_from(x).unwrap().cmp(other)\n            } else if *s_x {\n                ord_cmp\n            } else {\n                ord_cmp.reverse()\n            }\n        }),\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/lemniscate_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::{self, *};\n\npub fn lemniscate_constant_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let pi_lo = Float::pi_prec_round(working_prec, Floor).0;\n        let mut pi_hi = pi_lo.clone();\n        pi_hi.increment();\n        let g_lo = Float::gauss_constant_prec_round(working_prec, Floor).0;\n        let mut g_hi = g_lo.clone();\n        g_hi.increment();\n        let lo = pi_lo.mul_round(g_lo, Floor).0;\n        let hi = pi_hi.mul_round(g_hi, Ceiling).0;\n        let (lemniscate_constant_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);\n        let (lemniscate_constant_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && lemniscate_constant_lo == lemniscate_constant_hi {\n            return (lemniscate_constant_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/ln_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse rug;\nuse rug::float::{Constant, Round};\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering;\n\npub fn rug_ln_2_prec_round(prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut ln_2 = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = ln_2.assign_round(Constant::Log2, rm);\n    (ln_2, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/log_2_e.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::{self, *};\n\npub fn log_2_e_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let ln_2_lo = Float::ln_2_prec_round(working_prec, Floor).0;\n        let mut ln_2_hi = ln_2_lo.clone();\n        ln_2_hi.increment();\n        let lo = ln_2_hi.reciprocal_round(Floor).0;\n        let hi = ln_2_lo.reciprocal_round(Ceiling).0;\n        let (log_2_e_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);\n        let (log_2_e_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && log_2_e_lo == log_2_e_hi {\n            return (log_2_e_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod lemniscate_constant;\npub mod ln_2;\npub mod log_2_e;\npub mod one_over_pi;\npub mod one_over_sqrt_pi;\npub mod one_over_sqrt_tau;\npub mod pi;\npub mod pi_over_3;\npub mod prime_constant;\npub mod prouhet_thue_morse_constant;\npub mod sqrt_2;\npub mod sqrt_2_over_2;\npub mod sqrt_3;\npub mod sqrt_3_over_3;\npub mod sqrt_pi;\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/one_over_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::{self, *};\n\npub fn one_over_pi_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let pi_lo = Float::pi_prec_round(working_prec, Floor).0;\n        let mut pi_hi = pi_lo.clone();\n        pi_hi.increment();\n        let lo = pi_hi.reciprocal_round(Floor).0;\n        let hi = pi_lo.reciprocal_round(Ceiling).0;\n        let (one_over_pi_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);\n        let (one_over_pi_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && one_over_pi_lo == one_over_pi_hi {\n            return (one_over_pi_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/one_over_sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::{self, *};\n\npub fn one_over_sqrt_pi_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let pi_lo = Float::pi_prec_round(working_prec, Floor).0;\n        let mut pi_hi = pi_lo.clone();\n        pi_hi.increment();\n        let lo = pi_hi.reciprocal_sqrt_round(Floor).0;\n        let hi = pi_lo.reciprocal_sqrt_round(Ceiling).0;\n        let (one_over_sqrt_pi_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);\n        let (one_over_sqrt_pi_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && one_over_sqrt_pi_lo == one_over_sqrt_pi_hi {\n            return (one_over_sqrt_pi_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/one_over_sqrt_tau.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::{self, *};\n\npub fn one_over_sqrt_tau_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let tau_lo = Float::tau_prec_round(working_prec, Floor).0;\n        let mut tau_hi = tau_lo.clone();\n        tau_hi.increment();\n        let lo = tau_hi.reciprocal_sqrt_round(Floor).0;\n        let hi = tau_lo.reciprocal_sqrt_round(Ceiling).0;\n        let (one_over_sqrt_tau_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);\n        let (one_over_sqrt_tau_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && one_over_sqrt_tau_lo == one_over_sqrt_tau_hi {\n            return (one_over_sqrt_tau_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse rug;\nuse rug::float::{Constant, Round};\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering;\n\npub fn rug_pi_prec_round(prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut pi = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = pi.assign_round(Constant::Pi, rm);\n    (pi, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/pi_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::{self, *};\n\npub fn pi_over_3_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    const THREE: Float = Float::const_from_unsigned(3);\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let pi_lo = Float::pi_prec_round(working_prec, Floor).0;\n        let mut pi_hi = pi_lo.clone();\n        pi_hi.increment();\n        let lo = pi_lo.div_round(THREE, Floor).0;\n        let hi = pi_hi.div_round(THREE, Ceiling).0;\n        let (pi_over_3_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);\n        let (pi_over_3_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && pi_over_3_lo == pi_over_3_hi {\n            return (pi_over_3_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/prime_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::num::factorization::primes::prime_indicator_sequence;\nuse malachite_base::rounding_modes::RoundingMode;\nuse std::cmp::Ordering;\n\npub fn prime_constant_prec_round_naive(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    Float::non_dyadic_from_bits_prec_round(prime_indicator_sequence(), prec, rm)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/prouhet_thue_morse_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse malachite_base::iterators::thue_morse_sequence;\nuse malachite_base::rounding_modes::RoundingMode;\nuse std::cmp::Ordering;\n\npub fn prouhet_thue_morse_constant_prec_round_naive(\n    prec: u64,\n    rm: RoundingMode,\n) -> (Float, Ordering) {\n    Float::non_dyadic_from_bits_prec_round(thue_morse_sequence(), prec, rm)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/sqrt_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse rug;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering;\n\npub fn rug_sqrt_2_prec_round(prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut sqrt = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sqrt.assign_round(rug::Float::with_val(1, 2).sqrt_ref(), rm);\n    (sqrt, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/sqrt_2_over_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse rug;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering;\n\npub fn rug_sqrt_2_over_2_prec_round(prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut sqrt = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sqrt.assign_round(rug::Float::with_val(1, 2).sqrt_ref(), rm);\n    (sqrt >> 1, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/sqrt_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse rug;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering;\n\npub fn rug_sqrt_3_prec_round(prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut sqrt = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sqrt.assign_round(rug::Float::with_val(2, 3).sqrt_ref(), rm);\n    (sqrt, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/sqrt_3_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse rug;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering;\n\npub fn rug_sqrt_3_over_3_prec_round(prec: u64, rm: Round) -> (rug::Float, Ordering) {\n    let mut sqrt = rug::Float::with_val(u32::exact_from(prec), 0);\n    let o = sqrt.assign_round(rug::Float::with_val(2, 3).recip_sqrt_ref(), rm);\n    (sqrt, o)\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/constants/sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::{self, *};\n\npub fn sqrt_pi_prec_round_simple(prec: u64, rm: RoundingMode) -> (Float, Ordering) {\n    let mut working_prec = prec + 10;\n    let mut increment = Limb::WIDTH;\n    loop {\n        let pi_lo = Float::pi_prec_round(working_prec, Floor).0;\n        let mut pi_hi = pi_lo.clone();\n        pi_hi.increment();\n        let lo = pi_lo.sqrt_round(Floor).0;\n        let hi = pi_hi.sqrt_round(Ceiling).0;\n        let (sqrt_pi_lo, mut o_lo) = Float::from_float_prec_round(lo, prec, rm);\n        let (sqrt_pi_hi, mut o_hi) = Float::from_float_prec_round(hi, prec, rm);\n        if o_lo == Equal {\n            o_lo = o_hi;\n        }\n        if o_hi == Equal {\n            o_hi = o_lo;\n        }\n        if o_lo == o_hi && sqrt_pi_lo == sqrt_pi_hi {\n            return (sqrt_pi_lo, o_lo);\n        }\n        working_prec += increment;\n        increment = working_prec >> 1;\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\n\n// This differs from the `precision` function provided by `PrimitiveFloat`. That function returns\n// the smallest precision necessary to represent the float, whereas this function returns the\n// maximum precision of any float in the same binade. If the float is non-finite or zero, 1 is\n// returned.\npub fn alt_precision<T: PrimitiveFloat>(x: T) -> u64 {\n    if x.is_finite() && x != T::ZERO {\n        let (mantissa, exponent) = x.raw_mantissa_and_exponent();\n        if exponent == 0 {\n            mantissa.significant_bits()\n        } else {\n            T::MANTISSA_WIDTH + 1\n        }\n    } else {\n        1\n    }\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod from_primitive_float;\n"
  },
  {
    "path": "malachite-float/src/test_util/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::test_util::common::to_hex_string;\nuse itertools::Itertools;\n\npub fn exhaustive_floats_helper_helper_with_limit<I: Clone + Iterator<Item = Float>>(\n    limit: usize,\n    xs: I,\n    out: &[&str],\n    out_hex: &[&str],\n) {\n    let xs_hex = xs.clone();\n    assert_eq!(\n        xs_hex\n            .take(limit)\n            .map(|f| {\n                assert!(f.is_valid());\n                to_hex_string(&f)\n            })\n            .collect_vec()\n            .as_slice(),\n        out_hex\n    );\n    assert_eq!(\n        xs.take(limit)\n            .map(|f| { f.to_string() })\n            .collect_vec()\n            .as_slice(),\n        out\n    );\n}\n\npub fn exhaustive_floats_helper_helper<I: Clone + Iterator<Item = Float>>(\n    xs: I,\n    out: &[&str],\n    out_hex: &[&str],\n) {\n    exhaustive_floats_helper_helper_with_limit(50, xs, out, out_hex);\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/extra_variadic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse malachite_base::iterators::iterator_cache::IteratorCache;\nuse malachite_base::num::arithmetic::traits::CheckedPow;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::random::Seed;\nuse malachite_base::random_tuples;\nuse malachite_base::tuples::random::next_helper;\nuse std::cmp::max;\nuse std::marker::PhantomData;\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n    (a.unwrap(), b.unwrap(), c.unwrap())\n}\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_quadruple<X, Y, Z, W>(\n    (a, b, c, d): (Option<X>, Option<Y>, Option<Z>, Option<W>),\n) -> (X, Y, Z, W) {\n    (a.unwrap(), b.unwrap(), c.unwrap(), d.unwrap())\n}\n\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveTriples1Input,\n    exhaustive_triples_1_input,\n    exhaustive_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveTriplesXXY,\n    (X, X, Y),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xxy,\n    exhaustive_triples_xxy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXXYZ,\n    (X, X, Y, Z),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xxyz,\n    exhaustive_quadruples_xxyz_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]],\n    [Z, K, zs, zs_done, [3, output_type_zs_3]]\n);\n\nrandom_tuples!(\n    (pub(crate)),\n    RandomTriples,\n    RandomTriplesFromSingle,\n    random_triples,\n    random_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen]\n);\nrandom_tuples!(\n    (pub(crate)),\n    RandomQuadruples,\n    RandomQuadruplesFromSingle,\n    random_quadruples,\n    random_quadruples_from_single,\n    (I::Item, I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen],\n    [3, W, L, ws, ws_gen]\n);\n\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXXY,\n    (X, X, Y),\n    random_triples_xxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n    [Y, J, ys, ys_gen, [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXYY,\n    (X, Y, Y),\n    random_triples_xyy,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]]\n);\nrandom_custom_tuples!(\n   (pub(crate)),\n    RandomQuadruplesXXYZ,\n    (X, X, Y, Z),\n    random_quadruples_xxyz,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n    [Y, J, ys, ys_gen, [y_2, y_2]],\n    [Z, K, zs, zs_gen, [z_3, z_3]]\n);\n"
  },
  {
    "path": "malachite-float/src/test_util/generators/common.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::test_util::common::rug_round_exact_from_rounding_mode;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_base::test_util::generators::common::It;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\n\npub fn float_rm(xs: It<Float>) -> It<(rug::Float, Float)> {\n    Box::new(xs.map(|x| (rug::Float::exact_from(&x), x)))\n}\n\npub fn float_pair_rm(xs: It<(Float, Float)>) -> It<((rug::Float, rug::Float), (Float, Float))> {\n    Box::new(xs.map(|(x, y)| {\n        (\n            (rug::Float::exact_from(&x), rug::Float::exact_from(&y)),\n            (x, y),\n        )\n    }))\n}\n\npub fn float_natural_pair_rm(\n    xs: It<(Float, Natural)>,\n) -> It<((rug::Float, rug::Integer), (Float, Natural))> {\n    Box::new(xs.map(|(x, y)| {\n        (\n            (rug::Float::exact_from(&x), rug::Integer::exact_from(&y)),\n            (x, y),\n        )\n    }))\n}\n\npub fn float_integer_pair_rm(\n    xs: It<(Float, Integer)>,\n) -> It<((rug::Float, rug::Integer), (Float, Integer))> {\n    Box::new(xs.map(|(x, y)| {\n        (\n            (rug::Float::exact_from(&x), rug::Integer::exact_from(&y)),\n            (x, y),\n        )\n    }))\n}\n\npub fn float_rational_pair_rm(\n    xs: It<(Float, Rational)>,\n) -> It<((rug::Float, rug::Rational), (Float, Rational))> {\n    Box::new(xs.map(|(x, y)| {\n        (\n            (rug::Float::exact_from(&x), rug::Rational::exact_from(&y)),\n            (x, y),\n        )\n    }))\n}\n\npub fn float_primitive_int_pair_rm<T: PrimitiveInt>(\n    xs: It<(Float, T)>,\n) -> It<((rug::Float, T), (Float, T))> {\n    Box::new(xs.map(|(x, y)| ((rug::Float::exact_from(&x), y), (x, y))))\n}\n\npub fn float_primitive_float_pair_rm<T: PrimitiveFloat>(\n    xs: It<(Float, T)>,\n) -> It<((rug::Float, T), (Float, T))> {\n    Box::new(xs.map(|(x, y)| ((rug::Float::exact_from(&x), y), (x, y))))\n}\n\npub fn float_t_rounding_mode_triple_rm<T: Clone + 'static>(\n    xs: It<(Float, T, RoundingMode)>,\n) -> It<((rug::Float, T, rug::float::Round), (Float, T, RoundingMode))> {\n    Box::new(xs.map(|(x, p, rm)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                p.clone(),\n                rug_round_exact_from_rounding_mode(rm),\n            ),\n            (x, p, rm),\n        )\n    }))\n}\n\npub fn float_t_u_triple_rm<T: Clone + 'static, U: Clone + 'static>(\n    xs: It<(Float, T, U)>,\n) -> It<((rug::Float, T, U), (Float, T, U))> {\n    Box::new(xs.map(|(x, p, q)| {\n        (\n            (rug::Float::exact_from(&x), p.clone(), q.clone()),\n            (x, p, q),\n        )\n    }))\n}\n\npub fn float_t_u_rounding_mode_quadruple_rm<T: Clone + 'static, U: Clone + 'static>(\n    xs: It<(Float, T, U, RoundingMode)>,\n) -> It<(\n    (rug::Float, T, U, rug::float::Round),\n    (Float, T, U, RoundingMode),\n)> {\n    Box::new(xs.map(|(x, p, q, rm)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                p.clone(),\n                q.clone(),\n                rug_round_exact_from_rounding_mode(rm),\n            ),\n            (x, p, q, rm),\n        )\n    }))\n}\n\npub fn float_rounding_mode_pair_rm(\n    xs: It<(Float, RoundingMode)>,\n) -> It<((rug::Float, rug::float::Round), (Float, RoundingMode))> {\n    Box::new(xs.map(|(x, rm)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                rug_round_exact_from_rounding_mode(rm),\n            ),\n            (x, rm),\n        )\n    }))\n}\n\npub fn float_float_rounding_mode_triple_rm(\n    xs: It<(Float, Float, RoundingMode)>,\n) -> It<(\n    (rug::Float, rug::Float, rug::float::Round),\n    (Float, Float, RoundingMode),\n)> {\n    Box::new(xs.map(|(x, y, rm)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                rug::Float::exact_from(&y),\n                rug_round_exact_from_rounding_mode(rm),\n            ),\n            (x, y, rm),\n        )\n    }))\n}\n\npub fn float_float_anything_triple_rm<T: Clone + 'static>(\n    xs: It<(Float, Float, T)>,\n) -> It<((rug::Float, rug::Float, T), (Float, Float, T))> {\n    Box::new(xs.map(|(x, y, z)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                rug::Float::exact_from(&y),\n                z.clone(),\n            ),\n            (x, y, z),\n        )\n    }))\n}\n\npub fn float_rational_anything_triple_rm<T: Clone + 'static>(\n    xs: It<(Float, Rational, T)>,\n) -> It<((rug::Float, rug::Rational, T), (Float, Rational, T))> {\n    Box::new(xs.map(|(x, y, z)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                rug::Rational::exact_from(&y),\n                z.clone(),\n            ),\n            (x, y, z),\n        )\n    }))\n}\n\npub fn float_rational_rounding_mode_triple_rm(\n    xs: It<(Float, Rational, RoundingMode)>,\n) -> It<(\n    (rug::Float, rug::Rational, rug::float::Round),\n    (Float, Rational, RoundingMode),\n)> {\n    Box::new(xs.map(|(x, y, rm)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                rug::Rational::exact_from(&y),\n                rug_round_exact_from_rounding_mode(rm),\n            ),\n            (x, y, rm),\n        )\n    }))\n}\n\npub fn float_float_anything_rounding_mode_quadruple_rm<T: Clone + 'static>(\n    xs: It<(Float, Float, T, RoundingMode)>,\n) -> It<(\n    (rug::Float, rug::Float, T, rug::float::Round),\n    (Float, Float, T, RoundingMode),\n)> {\n    Box::new(xs.map(|(x, y, z, rm)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                rug::Float::exact_from(&y),\n                z.clone(),\n                rug_round_exact_from_rounding_mode(rm),\n            ),\n            (x, y, z, rm),\n        )\n    }))\n}\n\npub fn float_rational_anything_rounding_mode_quadruple_rm<T: Clone + 'static>(\n    xs: It<(Float, Rational, T, RoundingMode)>,\n) -> It<(\n    (rug::Float, rug::Rational, T, rug::float::Round),\n    (Float, Rational, T, RoundingMode),\n)> {\n    Box::new(xs.map(|(x, y, z, rm)| {\n        (\n            (\n                rug::Float::exact_from(&x),\n                rug::Rational::exact_from(&y),\n                z.clone(),\n                rug_round_exact_from_rounding_mode(rm),\n            ),\n            (x, y, z, rm),\n        )\n    }))\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/generators/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::exhaustive::{\n    ExhaustivePositiveFiniteFloatsGenerator, ExhaustivePositiveFloatsWithSciExponent,\n    exhaustive_finite_floats, exhaustive_floats, exhaustive_non_negative_finite_floats,\n    exhaustive_nonzero_finite_floats, exhaustive_positive_finite_floats,\n    exhaustive_positive_floats_with_precision, exhaustive_positive_floats_with_sci_exponent,\n};\nuse crate::test_util::extra_variadic::{\n    exhaustive_triples_from_single, exhaustive_triples_xxy, exhaustive_triples_xxy_custom_output,\n};\nuse crate::{Float, significand_bits};\nuse alloc::vec::IntoIter;\nuse core::cmp::Ordering::*;\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, Reciprocal, Square};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::num::exhaustive::{\n    exhaustive_positive_primitive_ints, exhaustive_primitive_floats, exhaustive_signeds,\n    exhaustive_unsigneds, primitive_int_increasing_inclusive_range,\n};\nuse malachite_base::num::iterators::{BitDistributorSequence, bit_distributor_sequence};\nuse malachite_base::num::logic::traits::{NotAssign, SignificantBits};\nuse malachite_base::orderings::exhaustive::exhaustive_orderings;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::{It, reshape_2_1_to_3, reshape_3_1_to_4};\nuse malachite_base::test_util::generators::exhaustive_pairs_big_tiny;\nuse malachite_base::tuples::exhaustive::{\n    ExhaustiveDependentPairs, ExhaustiveDependentPairsYsGenerator, exhaustive_dependent_pairs,\n};\nuse malachite_base::tuples::exhaustive::{\n    exhaustive_pairs, exhaustive_pairs_from_single, exhaustive_triples,\n    exhaustive_triples_custom_output, exhaustive_triples_xyy, lex_pairs,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::exhaustive_integers;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_naturals;\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::{exhaustive_non_negative_rationals, exhaustive_rationals};\nuse std::cmp::{Ordering, max};\nuse std::iter::Chain;\nuse std::mem::swap;\n\n// -- Float --\n\npub fn exhaustive_float_gen() -> It<Float> {\n    Box::new(exhaustive_floats())\n}\n\npub fn exhaustive_float_gen_var_1() -> It<Float> {\n    Box::new(exhaustive_positive_finite_floats())\n}\n\npub fn exhaustive_float_gen_var_2() -> It<Float> {\n    Box::new(exhaustive_floats().filter(|f| !f.is_nan()))\n}\n\npub fn exhaustive_float_gen_var_3() -> It<Float> {\n    Box::new(exhaustive_nonzero_finite_floats())\n}\n\npub fn exhaustive_float_gen_var_4() -> It<Float> {\n    Box::new(exhaustive_finite_floats())\n}\n\npub fn exhaustive_float_gen_var_5() -> It<Float> {\n    Box::new(exhaustive_non_negative_finite_floats())\n}\n\npub fn exhaustive_float_gen_var_6() -> It<Float> {\n    Box::new(exhaustive_floats_with_precision_inclusive_range(\n        1,\n        Limb::WIDTH - 1,\n    ))\n}\n\npub fn exhaustive_float_gen_var_7() -> It<Float> {\n    Box::new(exhaustive_positive_floats_with_precision(Limb::WIDTH))\n}\n\npub fn exhaustive_float_gen_var_8() -> It<Float> {\n    Box::new(exhaustive_floats_with_precision_inclusive_range(\n        Limb::WIDTH + 1,\n        (Limb::WIDTH << 1) - 1,\n    ))\n}\n\npub fn exhaustive_float_gen_var_9() -> It<Float> {\n    Box::new(exhaustive_positive_floats_with_precision(Limb::WIDTH << 1))\n}\n\npub fn exhaustive_float_gen_var_10() -> It<Float> {\n    Box::new(exhaustive_floats_with_precision_inclusive_range(\n        (Limb::WIDTH << 1) + 1,\n        Limb::WIDTH * 3 - 1,\n    ))\n}\n\npub fn exhaustive_float_gen_var_11() -> It<Float> {\n    Box::new(exhaustive_floats_with_precision_inclusive_range(\n        (Limb::WIDTH << 1) + 1,\n        u64::MAX,\n    ))\n}\n\npub fn exhaustive_float_gen_var_12() -> It<Float> {\n    Box::new(exhaustive_extreme_floats())\n}\n\npub fn exhaustive_float_gen_var_13() -> It<Float> {\n    Box::new(exhaustive_extreme_nonzero_finite_floats())\n}\n\npub fn exhaustive_float_gen_var_14() -> It<Float> {\n    Box::new(exhaustive_extreme_floats().filter(|f| !f.is_nan()))\n}\n\npub fn exhaustive_float_gen_var_15() -> It<Float> {\n    Box::new(exhaustive_floats().filter(|x| *x > 0u32))\n}\n\n#[derive(Clone, Debug)]\npub struct ExhaustiveExtremeExponents {\n    counter: bool,\n    i: i32,\n    end_counter: u8,\n}\n\nimpl Iterator for ExhaustiveExtremeExponents {\n    type Item = i32;\n\n    fn next(&mut self) -> Option<i32> {\n        if self.i == 2 {\n            return match self.end_counter {\n                0 => {\n                    self.end_counter = 1;\n                    Some(-2)\n                }\n                1 => {\n                    self.end_counter = 2;\n                    Some(-1)\n                }\n                2 => {\n                    self.end_counter = 3;\n                    Some(0)\n                }\n                _ => None,\n            };\n        }\n        Some(if self.counter {\n            self.counter = false;\n            self.i - 2\n        } else {\n            self.counter = true;\n            self.i -= 1;\n            -self.i - 1\n        })\n    }\n}\n\npub const fn exhaustive_extreme_exponents() -> ExhaustiveExtremeExponents {\n    ExhaustiveExtremeExponents {\n        counter: true,\n        i: Float::MAX_EXPONENT + 1,\n        end_counter: 0,\n    }\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveMixedExtremeExponents {\n    first: bool,\n    counter: u8,\n    low: i32,\n    high: i32,\n    end_counter: u8,\n}\n\nimpl Iterator for ExhaustiveMixedExtremeExponents {\n    type Item = i32;\n\n    fn next(&mut self) -> Option<i32> {\n        if self.low == self.high {\n            return match self.end_counter {\n                0 => {\n                    self.end_counter = 1;\n                    Some(-self.high)\n                }\n                1 => {\n                    self.end_counter = 2;\n                    Some(-self.high - 1)\n                }\n                _ => None,\n            };\n        }\n        Some(if self.first {\n            self.first = false;\n            0\n        } else {\n            match self.counter {\n                0 => {\n                    self.counter = 1;\n                    self.low\n                }\n                1 => {\n                    self.counter = 2;\n                    self.low += 1;\n                    -self.low + 1\n                }\n                2 => {\n                    self.counter = 3;\n                    self.high - 1\n                }\n                3 => {\n                    self.counter = 0;\n                    self.high -= 1;\n                    -self.high - 2\n                }\n                _ => unreachable!(),\n            }\n        })\n    }\n}\n\nconst fn exhaustive_mixed_extreme_exponents() -> ExhaustiveMixedExtremeExponents {\n    ExhaustiveMixedExtremeExponents {\n        first: true,\n        counter: 0,\n        low: 1,\n        high: Float::MAX_EXPONENT,\n        end_counter: 0,\n    }\n}\n\n#[inline]\nfn exhaustive_extreme_positive_finite_floats_helper() -> ExhaustiveDependentPairs<\n    i32,\n    Float,\n    BitDistributorSequence,\n    ExhaustivePositiveFiniteFloatsGenerator,\n    ExhaustiveExtremeExponents,\n    ExhaustivePositiveFloatsWithSciExponent,\n> {\n    exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_extreme_exponents(),\n        ExhaustivePositiveFiniteFloatsGenerator,\n    )\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveExtremePositiveFiniteFloats(\n    ExhaustiveDependentPairs<\n        i32,\n        Float,\n        BitDistributorSequence,\n        ExhaustivePositiveFiniteFloatsGenerator,\n        ExhaustiveExtremeExponents,\n        ExhaustivePositiveFloatsWithSciExponent,\n    >,\n);\n\nimpl Iterator for ExhaustiveExtremePositiveFiniteFloats {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n#[inline]\nfn exhaustive_extreme_positive_finite_floats() -> ExhaustiveExtremePositiveFiniteFloats {\n    ExhaustiveExtremePositiveFiniteFloats(exhaustive_extreme_positive_finite_floats_helper())\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveExtremeNonzeroFiniteFloats {\n    toggle: bool,\n    xs: ExhaustiveExtremePositiveFiniteFloats,\n    x: Float,\n}\n\nimpl Iterator for ExhaustiveExtremeNonzeroFiniteFloats {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.toggle.not_assign();\n        Some(if self.toggle {\n            self.x = self.xs.next().unwrap();\n            self.x.clone()\n        } else {\n            let mut out = Float::NAN;\n            swap(&mut out, &mut self.x);\n            -out\n        })\n    }\n}\n\n#[inline]\nfn exhaustive_extreme_nonzero_finite_floats() -> ExhaustiveExtremeNonzeroFiniteFloats {\n    ExhaustiveExtremeNonzeroFiniteFloats {\n        toggle: false,\n        xs: exhaustive_extreme_positive_finite_floats(),\n        x: Float::NAN,\n    }\n}\n\ntype ExhaustiveExtremeFloats = Chain<IntoIter<Float>, ExhaustiveExtremeNonzeroFiniteFloats>;\n\n#[inline]\nfn exhaustive_extreme_floats() -> ExhaustiveExtremeFloats {\n    alloc::vec![\n        Float::NAN,\n        Float::INFINITY,\n        Float::NEGATIVE_INFINITY,\n        Float::ZERO,\n        Float::NEGATIVE_ZERO\n    ]\n    .into_iter()\n    .chain(exhaustive_extreme_nonzero_finite_floats())\n}\n\n#[inline]\nfn exhaustive_mixed_extreme_positive_finite_floats_helper() -> ExhaustiveDependentPairs<\n    i32,\n    Float,\n    BitDistributorSequence,\n    ExhaustivePositiveFiniteFloatsGenerator,\n    ExhaustiveMixedExtremeExponents,\n    ExhaustivePositiveFloatsWithSciExponent,\n> {\n    exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_mixed_extreme_exponents(),\n        ExhaustivePositiveFiniteFloatsGenerator,\n    )\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveMixedExtremePositiveFiniteFloats(\n    ExhaustiveDependentPairs<\n        i32,\n        Float,\n        BitDistributorSequence,\n        ExhaustivePositiveFiniteFloatsGenerator,\n        ExhaustiveMixedExtremeExponents,\n        ExhaustivePositiveFloatsWithSciExponent,\n    >,\n);\n\nimpl Iterator for ExhaustiveMixedExtremePositiveFiniteFloats {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n#[inline]\nfn exhaustive_mixed_extreme_positive_finite_floats() -> ExhaustiveMixedExtremePositiveFiniteFloats {\n    ExhaustiveMixedExtremePositiveFiniteFloats(\n        exhaustive_mixed_extreme_positive_finite_floats_helper(),\n    )\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveMixedExtremeNonzeroFiniteFloats {\n    toggle: bool,\n    xs: ExhaustiveMixedExtremePositiveFiniteFloats,\n    x: Float,\n}\n\nimpl Iterator for ExhaustiveMixedExtremeNonzeroFiniteFloats {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        self.toggle.not_assign();\n        Some(if self.toggle {\n            self.x = self.xs.next().unwrap();\n            self.x.clone()\n        } else {\n            let mut out = Float::NAN;\n            swap(&mut out, &mut self.x);\n            -out\n        })\n    }\n}\n\n#[inline]\nfn exhaustive_mixed_extreme_nonzero_finite_floats() -> ExhaustiveMixedExtremeNonzeroFiniteFloats {\n    ExhaustiveMixedExtremeNonzeroFiniteFloats {\n        toggle: false,\n        xs: exhaustive_mixed_extreme_positive_finite_floats(),\n        x: Float::NAN,\n    }\n}\n\ntype ExhaustiveMixedExtremeFloats =\n    Chain<IntoIter<Float>, ExhaustiveMixedExtremeNonzeroFiniteFloats>;\n\n#[inline]\nfn exhaustive_mixed_extreme_floats() -> ExhaustiveMixedExtremeFloats {\n    alloc::vec![\n        Float::NAN,\n        Float::INFINITY,\n        Float::NEGATIVE_INFINITY,\n        Float::ZERO,\n        Float::NEGATIVE_ZERO\n    ]\n    .into_iter()\n    .chain(exhaustive_mixed_extreme_nonzero_finite_floats())\n}\n\nstruct FloatWithPrecisionRangeGenerator;\n\nimpl ExhaustiveDependentPairsYsGenerator<u64, Float, Box<dyn Iterator<Item = Float>>>\n    for FloatWithPrecisionRangeGenerator\n{\n    #[inline]\n    fn get_ys(&self, &prec: &u64) -> Box<dyn Iterator<Item = Float>> {\n        Box::new(exhaustive_positive_floats_with_precision(prec))\n    }\n}\n\nfn exhaustive_floats_with_precision_inclusive_range(prec_lo: u64, prec_hi: u64) -> It<Float> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            primitive_int_increasing_inclusive_range(prec_lo, prec_hi),\n            FloatWithPrecisionRangeGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct FloatPairWithPrecisionRangeGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (Float, Float),\n        Box<dyn Iterator<Item = (Float, Float)>>,\n    > for FloatPairWithPrecisionRangeGenerator\n{\n    #[inline]\n    fn get_ys(&self, &prec: &u64) -> Box<dyn Iterator<Item = (Float, Float)>> {\n        Box::new(exhaustive_pairs_from_single(\n            exhaustive_positive_floats_with_precision(prec),\n        ))\n    }\n}\n\nfn exhaustive_float_pairs_with_precision_inclusive_range(\n    prec_lo: u64,\n    prec_hi: u64,\n) -> It<(Float, Float)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            primitive_int_increasing_inclusive_range(prec_lo, prec_hi),\n            FloatPairWithPrecisionRangeGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct FloatPairWithPrecisionRangesGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        (u64, u64),\n        (Float, Float),\n        Box<dyn Iterator<Item = (Float, Float)>>,\n    > for FloatPairWithPrecisionRangesGenerator\n{\n    #[inline]\n    fn get_ys(&self, &precs: &(u64, u64)) -> Box<dyn Iterator<Item = (Float, Float)>> {\n        Box::new(exhaustive_pairs(\n            exhaustive_positive_floats_with_precision(precs.0),\n            exhaustive_positive_floats_with_precision(precs.1),\n        ))\n    }\n}\n\nfn exhaustive_float_pairs_with_precisions(precisions: It<(u64, u64)>) -> It<(Float, Float)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            precisions,\n            FloatPairWithPrecisionRangesGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\n// -- (Float, Float) --\n\npub fn exhaustive_float_pair_gen() -> It<(Float, Float)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_floats()))\n}\n\npub fn exhaustive_float_pair_gen_var_1() -> It<(Float, Float)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_finite_floats()))\n}\n\npub fn exhaustive_float_pair_gen_var_2() -> It<(Float, Float)> {\n    exhaustive_float_pairs_with_precision_inclusive_range(1, Limb::WIDTH - 1)\n}\n\npub fn exhaustive_float_pair_gen_var_3() -> It<(Float, Float)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_positive_floats_with_precision(Limb::WIDTH),\n    ))\n}\n\npub fn exhaustive_float_pair_gen_var_4() -> It<(Float, Float)> {\n    exhaustive_float_pairs_with_precision_inclusive_range(Limb::WIDTH + 1, (Limb::WIDTH << 1) - 1)\n}\n\npub fn exhaustive_float_pair_gen_var_5() -> It<(Float, Float)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_positive_floats_with_precision(Limb::WIDTH << 1),\n    ))\n}\n\npub fn exhaustive_float_pair_gen_var_6() -> It<(Float, Float)> {\n    exhaustive_float_pairs_with_precision_inclusive_range(\n        (Limb::WIDTH << 1) + 1,\n        (Limb::WIDTH * 3) - 1,\n    )\n}\n\npub fn exhaustive_float_pair_gen_var_7() -> It<(Float, Float)> {\n    exhaustive_float_pairs_with_precision_inclusive_range(Limb::WIDTH * 3, u64::MAX)\n}\n\npub fn exhaustive_float_pair_gen_var_8() -> It<(Float, Float)> {\n    exhaustive_float_pairs_with_precisions(Box::new(\n        exhaustive_pairs(\n            exhaustive_positive_primitive_ints(),\n            primitive_int_increasing_inclusive_range(1, Limb::WIDTH),\n        )\n        .filter(|&(x, y)| x != y),\n    ))\n}\n\npub fn exhaustive_float_pair_gen_var_9() -> It<(Float, Float)> {\n    exhaustive_float_pairs_with_precisions(Box::new(\n        exhaustive_pairs(\n            exhaustive_positive_primitive_ints(),\n            primitive_int_increasing_inclusive_range(Limb::WIDTH + 1, u64::MAX),\n        )\n        .filter(|&(x, y)| x != y),\n    ))\n}\n\npub fn exhaustive_float_pair_gen_var_10() -> It<(Float, Float)> {\n    Box::new(exhaustive_pairs_from_single(\n        exhaustive_mixed_extreme_floats(),\n    ))\n}\n\n// -- (Float, Float, Float) --\n\npub fn exhaustive_float_triple_gen() -> It<(Float, Float, Float)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_floats()))\n}\n\n// -- (Float, Float, Integer) --\n\npub fn exhaustive_float_float_integer_triple_gen() -> It<(Float, Float, Integer)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_floats(),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Float, Float, Natural) --\n\npub fn exhaustive_float_float_natural_triple_gen() -> It<(Float, Float, Natural)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_floats(),\n        exhaustive_naturals(),\n    ))\n}\n\n// -- (Float, Float, PrimitiveFloat) --\n\npub fn exhaustive_float_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Float, Float, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_floats(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Float, Float, PrimitiveSigned) --\n\npub fn exhaustive_float_float_signed_triple_gen<T: PrimitiveSigned>() -> It<(Float, Float, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\n// -- (Float, Float, PrimitiveUnsigned) --\n\npub fn exhaustive_float_float_unsigned_triple_gen<T: PrimitiveUnsigned>() -> It<(Float, Float, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_floats(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_float_float_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Float, Float, T)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_floats(),\n        exhaustive_positive_primitive_ints::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_float_float_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Float, Float, T)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_mixed_extreme_floats(),\n        exhaustive_positive_primitive_ints::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Float, Float, PrimitiveUnsigned, RoundingMode) --\n\npub(crate) fn add_prec_round_valid(\n    x: &Float,\n    y: &Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) -> bool {\n    if rm != Exact {\n        true\n    } else if extreme {\n        x.add_prec_round_ref_ref(y, prec, Floor).1 == Equal\n    } else if let (Ok(rx), Ok(ry)) = (Rational::try_from(x), Rational::try_from(y)) {\n        let sum = Float::exact_from(rx + ry);\n        if let Some(min_prec) = sum.get_min_prec() {\n            prec >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| add_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub(crate) fn sub_prec_round_valid(\n    x: &Float,\n    y: &Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) -> bool {\n    if rm != Exact {\n        return true;\n    }\n    if extreme {\n        x.sub_prec_round_ref_ref(y, prec, Floor).1 == Equal\n    } else if let (Ok(rx), Ok(ry)) = (Rational::try_from(x), Rational::try_from(y)) {\n        let diff = Float::exact_from(rx - ry);\n        if let Some(min_prec) = diff.get_min_prec() {\n            prec >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| sub_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub(crate) fn mul_prec_round_valid(\n    x: &Float,\n    y: &Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) -> bool {\n    if rm != Exact {\n        true\n    } else if extreme {\n        x.mul_prec_round_ref_ref(y, prec, Floor).1 == Equal\n    } else if let (Ok(rx), Ok(ry)) = (Rational::try_from(x), Rational::try_from(y)) {\n        let product = Float::exact_from(rx * ry);\n        if let Some(min_prec) = product.get_min_prec() {\n            prec >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| mul_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub(crate) fn div_prec_round_valid(\n    x: &Float,\n    y: &Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) -> bool {\n    if rm != Exact || *y == 0u32 {\n        true\n    } else if extreme {\n        x.div_prec_round_ref_ref(y, prec, Floor).1 == Equal\n    } else if let (Ok(rx), Ok(ry)) = (Rational::try_from(x), Rational::try_from(y)) {\n        if let Ok(quotient) = Float::try_from(rx / ry) {\n            if let Some(min_prec) = quotient.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| div_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_5()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_mixed_extreme_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| add_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_6()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_mixed_extreme_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| sub_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_7()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_mixed_extreme_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| mul_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_8()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_mixed_extreme_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| div_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn agm_prec_round_valid(x: &Float, y: &Float, prec: u64, rm: RoundingMode) -> bool {\n    rm != Exact\n        || !x.is_normal()\n        || !y.is_normal()\n        || *x < 0u32\n        || *y < 0u32\n        || x == y && Float::from_float_prec_round_ref(x, prec, Floor).1 == Equal\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| agm_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_10()\n-> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_mixed_extreme_floats(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| agm_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Float, Float, Rational) --\n\npub fn exhaustive_float_float_rational_triple_gen() -> It<(Float, Float, Rational)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_floats(),\n        exhaustive_rationals(),\n    ))\n}\n\n// -- (Float, Float, RoundingMode) --\n\npub(crate) fn add_round_valid(x: &Float, y: &Float, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact {\n        true\n    } else if extreme {\n        x.add_round_ref_ref(y, Floor).1 == Equal\n    } else if let (Some(x_prec), Some(y_prec)) = (x.get_prec(), y.get_prec()) {\n        let sum = Float::exact_from(Rational::exact_from(x) + Rational::exact_from(y));\n        if let Some(min_prec) = sum.get_min_prec() {\n            max(x_prec, y_prec) >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_1() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub(crate) fn sub_round_valid(x: &Float, y: &Float, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact {\n        true\n    } else if extreme {\n        x.sub_round_ref_ref(y, Floor).1 == Equal\n    } else if let (Some(x_prec), Some(y_prec)) = (x.get_prec(), y.get_prec()) {\n        let diff = Float::exact_from(Rational::exact_from(x) - Rational::exact_from(y));\n        if let Some(min_prec) = diff.get_min_prec() {\n            max(x_prec, y_prec) >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_2() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_3() -> It<(Float, Float, RoundingMode)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_floats(),\n        exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n    ))\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_4() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_2(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_5() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_3(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_6() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_4(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_7() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_5(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_8() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_6(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_9() -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_7(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_10() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_2(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_11() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_3(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_12() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_4(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_13() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_5(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_14() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_6(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_15() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_7(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub(crate) fn mul_round_valid(x: &Float, y: &Float, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact {\n        true\n    } else if extreme {\n        x.mul_round_ref_ref(y, Floor).1 == Equal\n    } else if let (Some(x_prec), Some(y_prec)) = (x.get_prec(), y.get_prec()) {\n        let product = Float::exact_from(Rational::exact_from(x) * Rational::exact_from(y));\n        if let Some(min_prec) = product.get_min_prec() {\n            max(x_prec, y_prec) >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_16() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_2(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_17() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_2(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_18() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_3(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_19() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_4(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_20() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_5(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_21() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_6(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_22() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_7(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub(crate) fn div_round_valid(x: &Float, y: &Float, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact || *y == 0u32 {\n        true\n    } else if extreme {\n        x.div_round_ref_ref(y, Floor).1 == Equal\n    } else if let (Some(x_prec), Some(y_prec)) = (x.get_prec(), y.get_prec()) {\n        if let Ok(quotient) = Float::try_from(Rational::exact_from(x) / Rational::exact_from(y)) {\n            if let Some(min_prec) = quotient.get_min_prec() {\n                max(x_prec, y_prec) >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_23() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_2(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_24() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_2(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_25() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_3(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_26() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_4(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_27() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_8(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_28() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_float_pair_gen_var_9(),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_29() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_mixed_extreme_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_30() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_mixed_extreme_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_31() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_mixed_extreme_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_32() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_mixed_extreme_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, true)),\n    )\n}\n\npub(crate) fn agm_round_valid(x: &Float, y: &Float, rm: RoundingMode) -> bool {\n    rm != Exact || !x.is_normal() || !y.is_normal() || *x < 0u32 || *y < 0u32 || x == y\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_33() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| agm_round_valid(x, y, *rm)),\n    )\n}\n\npub fn exhaustive_float_float_rounding_mode_triple_gen_var_34() -> It<(Float, Float, RoundingMode)>\n{\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_mixed_extreme_floats()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| agm_round_valid(x, y, *rm)),\n    )\n}\n\n// -- (Float, Integer) --\n\npub fn exhaustive_float_integer_pair_gen() -> It<(Float, Integer)> {\n    Box::new(exhaustive_pairs(exhaustive_floats(), exhaustive_integers()))\n}\n\npub fn exhaustive_float_integer_pair_gen_var_1() -> It<(Float, Integer)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_finite_floats(),\n        exhaustive_integers(),\n    ))\n}\n\npub fn exhaustive_float_integer_pair_gen_var_2() -> It<(Float, Integer)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Float, Integer, Integer) --\n\npub fn exhaustive_float_integer_integer_triple_gen() -> It<(Float, Integer, Integer)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_floats(),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Float, Natural) --\n\npub fn exhaustive_float_natural_pair_gen() -> It<(Float, Natural)> {\n    Box::new(exhaustive_pairs(exhaustive_floats(), exhaustive_naturals()))\n}\n\npub fn exhaustive_float_natural_pair_gen_var_1() -> It<(Float, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_finite_floats(),\n        exhaustive_naturals(),\n    ))\n}\n\npub fn exhaustive_float_natural_pair_gen_var_2() -> It<(Float, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_naturals(),\n    ))\n}\n\n// -- (Float, Natural, Natural) --\n\npub fn exhaustive_float_natural_natural_triple_gen() -> It<(Float, Natural, Natural)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_floats(),\n        exhaustive_naturals(),\n    ))\n}\n\n// -- (Float, Ordering) --\n\npub fn exhaustive_float_ordering_pair_gen() -> It<(Float, Ordering)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_floats(),\n        exhaustive_orderings(),\n    ))\n}\n\npub fn exhaustive_float_ordering_pair_gen_var_1() -> It<(Float, Ordering)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_orderings(),\n    ))\n}\n\n// -- (Float, PrimitiveFloat) --\n\npub fn exhaustive_float_primitive_float_pair_gen<T: PrimitiveFloat>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_floats(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\npub fn exhaustive_float_primitive_float_pair_gen_var_1<T: PrimitiveFloat>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Float, PrimitiveFloat, PrimitiveFloat) --\n\npub fn exhaustive_float_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Float, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_floats(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Float, PrimitiveSigned) --\n\npub fn exhaustive_float_signed_pair_gen<T: PrimitiveSigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs(exhaustive_floats(), exhaustive_signeds()))\n}\n\npub fn exhaustive_float_signed_pair_gen_var_1<T: PrimitiveSigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_floats_with_sci_exponent(0),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_float_signed_pair_gen_var_2<T: PrimitiveSigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_float_signed_pair_gen_var_3<T: PrimitiveSigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_extreme_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_float_signed_pair_gen_var_4<T: PrimitiveSigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveSigned) --\n\npub fn exhaustive_float_signed_signed_triple_gen<T: PrimitiveSigned>() -> It<(Float, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_floats(),\n        exhaustive_signeds(),\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn exhaustive_float_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Float, T, U)> {\n    Box::new(exhaustive_triples(\n        exhaustive_floats(),\n        exhaustive_signeds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_float_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Float, T, U)> {\n    Box::new(exhaustive_triples(\n        exhaustive_extreme_floats(),\n        exhaustive_signeds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_floats(),\n                exhaustive_signeds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_2<T: PrimitiveSigned>()\n-> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_extreme_floats(),\n                exhaustive_signeds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_3<T: PrimitiveSigned>()\n-> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_floats(),\n                exhaustive_signeds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_4<T: PrimitiveSigned>()\n-> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_extreme_floats(),\n                exhaustive_signeds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\n// -- (Float, PrimitiveSigned, RoundingMode) --\n\npub fn exhaustive_float_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_signeds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shl_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_extreme_floats(), exhaustive_signeds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shl_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_rounding_mode_triple_gen_var_3<T: PrimitiveSigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_signeds()),\n            exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n        )\n        .filter(|&((ref x, bits), rm)| shl_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_rounding_mode_triple_gen_var_4<T: PrimitiveSigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_signeds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shr_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_rounding_mode_triple_gen_var_5<T: PrimitiveSigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_extreme_floats(), exhaustive_signeds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shr_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_signed_rounding_mode_triple_gen_var_6<T: PrimitiveSigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_signeds()),\n            exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n        )\n        .filter(|&((ref x, bits), rm)| shr_round_valid(x, bits, rm)),\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned) --\n\npub fn exhaustive_float_unsigned_pair_gen<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_floats(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_floats(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_floats(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_extreme_floats(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_extreme_floats(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_floats().filter(|x| *x > 0u32),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>() -> It<(Float, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_finite_floats(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_float_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> It<(Float, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_floats(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Float, T, U)> {\n    Box::new(exhaustive_triples(\n        exhaustive_floats(),\n        exhaustive_unsigneds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_float_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Float, T, U)> {\n    Box::new(exhaustive_triples(\n        exhaustive_extreme_floats(),\n        exhaustive_unsigneds(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n>() -> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_floats(),\n                exhaustive_unsigneds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2<\n    T: PrimitiveUnsigned,\n>() -> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_extreme_floats(),\n                exhaustive_unsigneds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3<\n    T: PrimitiveUnsigned,\n>() -> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_floats(),\n                exhaustive_unsigneds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4<\n    T: PrimitiveUnsigned,\n>() -> It<(Float, T, u64, RoundingMode)> {\n    reshape_3_1_to_4(Box::new(\n        lex_pairs(\n            exhaustive_triples(\n                exhaustive_extreme_floats(),\n                exhaustive_unsigneds(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits, prec), rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned, RoundingMode) --\n\npub fn set_prec_round_valid(x: &Float, p: u64, rm: RoundingMode) -> bool {\n    rm != Exact || !x.is_finite() || x.is_zero() || x.get_prec().unwrap() <= p || {\n        let significand = x.significand_ref().unwrap();\n        significand_bits(significand) - significand.trailing_zeros().unwrap() <= p\n    }\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_1() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| set_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn square_prec_round_valid(x: &Float, prec: u64, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact {\n        true\n    } else if extreme {\n        x.square_prec_round_ref(prec, Floor).1 == Equal\n    } else if let Ok(rx) = Rational::try_from(x) {\n        let square = Float::exact_from(rx.square());\n        if let Some(min_prec) = square.get_min_prec() {\n            prec >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_2() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| square_prec_round_valid(x, p, rm, false)),\n    ))\n}\n\npub fn reciprocal_prec_round_valid(x: &Float, prec: u64, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact || *x == 0 {\n        true\n    } else if extreme {\n        x.reciprocal_prec_round_ref(prec, Floor).1 == Equal\n    } else if let Ok(rx) = Rational::try_from(x) {\n        if let Ok(reciprocal) = Float::try_from(rx.reciprocal()) {\n            if let Some(min_prec) = reciprocal.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_3() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| reciprocal_prec_round_valid(x, p, rm, false)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_4() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_extreme_floats(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| set_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn shl_round_valid<T: PrimitiveInt>(x: &Float, bits: T, rm: RoundingMode) -> bool {\n    rm != Exact || !x.is_finite() || x.is_zero() || {\n        let exponent = x.get_exponent().unwrap();\n        if let Ok(bits) = bits.try_into()\n            && let Some(new_exponent) = exponent.checked_add(bits)\n        {\n            return (Float::MIN_EXPONENT..=Float::MAX_EXPONENT).contains(&new_exponent);\n        }\n        false\n    }\n}\n\npub fn shl_prec_round_valid<T: PrimitiveInt>(\n    x: &Float,\n    bits: T,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    rm != Exact || !x.is_normal() || x.shl_prec_round_ref(bits, prec, Floor).1 == Equal\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_unsigneds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shl_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_extreme_floats(), exhaustive_unsigneds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shl_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_7<T: PrimitiveUnsigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_unsigneds()),\n            exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n        )\n        .filter(|&((ref x, bits), rm)| shl_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn shr_round_valid<T: PrimitiveInt>(x: &Float, bits: T, rm: RoundingMode) -> bool {\n    rm != Exact || !x.is_finite() || x.is_zero() || {\n        let exponent = x.get_exponent().unwrap();\n        if let Ok(bits) = bits.try_into()\n            && let Some(new_exponent) = exponent.checked_sub(bits)\n        {\n            return (Float::MIN_EXPONENT..=Float::MAX_EXPONENT).contains(&new_exponent);\n        }\n        false\n    }\n}\n\npub fn shr_prec_round_valid<T: PrimitiveInt>(\n    x: &Float,\n    bits: T,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    rm != Exact || !x.is_normal() || x.shr_prec_round_ref(bits, prec, Floor).1 == Equal\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_8<T: PrimitiveUnsigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_unsigneds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shr_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_9<T: PrimitiveUnsigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_extreme_floats(), exhaustive_unsigneds()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, bits), rm)| shr_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_10<T: PrimitiveUnsigned>()\n-> It<(Float, T, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_unsigneds()),\n            exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n        )\n        .filter(|&((ref x, bits), rm)| shr_round_valid(x, bits, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_11() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_extreme_floats(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| square_prec_round_valid(x, p, rm, true)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_12() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_extreme_floats(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| reciprocal_prec_round_valid(x, p, rm, true)),\n    ))\n}\n\npub fn sqrt_prec_round_valid(x: &Float, prec: u64, rm: RoundingMode) -> bool {\n    rm != Exact || x.sqrt_prec_round_ref(prec, Floor).1 == Equal\n}\n\npub fn reciprocal_sqrt_prec_round_valid(x: &Float, prec: u64, rm: RoundingMode) -> bool {\n    rm != Exact || x.reciprocal_sqrt_prec_round_ref(prec, Floor).1 == Equal\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_13() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| sqrt_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_14() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_extreme_floats(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| sqrt_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_15() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| reciprocal_sqrt_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_16() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_extreme_floats(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| reciprocal_sqrt_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_17() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(\n            exhaustive_floats().filter(|x| *x > 0u32),\n            exhaustive_positive_primitive_ints(),\n        ),\n        exhaustive_rounding_modes(),\n    )))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_18() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(\n            exhaustive_finite_floats(),\n            exhaustive_positive_primitive_ints(),\n        ),\n        exhaustive_rounding_modes(),\n    )))\n}\n\npub fn ln_prec_round_valid(x: &Float, _prec: u64, rm: RoundingMode) -> bool {\n    rm != Exact || *x <= 0u32 || *x == 1u32\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_19() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_floats(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| ln_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn exhaustive_float_unsigned_rounding_mode_triple_gen_var_20() -> It<(Float, u64, RoundingMode)>\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_extreme_floats(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref x, p), rm)| ln_prec_round_valid(x, p, rm)),\n    ))\n}\n\n// -- (Float, Rational) --\n\npub fn exhaustive_float_rational_pair_gen() -> It<(Float, Rational)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_floats(),\n        exhaustive_rationals(),\n    ))\n}\n\npub fn exhaustive_float_rational_pair_gen_var_1() -> It<(Float, Rational)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_finite_floats(),\n        exhaustive_rationals(),\n    ))\n}\n\npub fn exhaustive_float_rational_pair_gen_var_2() -> It<(Float, Rational)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_rationals(),\n    ))\n}\n\n// -- (Float, Rational, PrimitiveUnsigned) --\n\npub fn exhaustive_float_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Float, Rational, T)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_floats(),\n        exhaustive_rationals(),\n        exhaustive_positive_primitive_ints::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_float_rational_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Float, Rational, T)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_extreme_floats(),\n        exhaustive_rationals(),\n        exhaustive_positive_primitive_ints::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Float, Rational, PrimitiveUnsigned, RoundingMode) --\n\npub(crate) fn add_rational_prec_round_valid(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    if rm != Exact {\n        return true;\n    }\n    if let Ok(rx) = Rational::try_from(x) {\n        if let Ok(sum) = Float::try_from(rx + y) {\n            if let Some(min_prec) = sum.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| add_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub(crate) fn sub_rational_prec_round_valid(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    if rm != Exact {\n        return true;\n    }\n    if let Ok(rx) = Rational::try_from(x) {\n        if let Ok(diff) = Float::try_from(rx - y) {\n            if let Some(min_prec) = diff.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| sub_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub(crate) fn mul_rational_prec_round_valid(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    if rm != Exact {\n        return true;\n    }\n    if let Ok(rx) = Rational::try_from(x) {\n        if let Ok(product) = Float::try_from(rx * y) {\n            if let Some(min_prec) = product.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| mul_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub(crate) fn div_rational_prec_round_valid(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    if rm != Exact || *y == 0u32 {\n        return true;\n    }\n    if let Ok(rx) = Rational::try_from(x) {\n        if let Ok(quotient) = Float::try_from(rx / y) {\n            if let Some(min_prec) = quotient.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| div_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub(crate) fn rational_div_float_prec_round_valid(\n    x: &Float,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    if rm != Exact || *x == 0u32 {\n        return true;\n    }\n    if let Ok(rx) = Rational::try_from(x) {\n        if let Ok(quotient) = Float::try_from(y / rx) {\n            if let Some(min_prec) = quotient.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| rational_div_float_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_6()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_extreme_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| add_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_7()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_extreme_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| sub_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_8()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_extreme_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| mul_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_9()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_extreme_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| div_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_10()\n-> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_custom_output(\n                exhaustive_extreme_floats(),\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| rational_div_float_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Float, Rational, Rational) --\n\npub fn exhaustive_float_rational_rational_triple_gen() -> It<(Float, Rational, Rational)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_floats(),\n        exhaustive_rationals(),\n    ))\n}\n\n// -- (Float, Rational, RoundingMode) --\n\npub(crate) fn add_rational_round_valid(x: &Float, y: &Rational, rm: RoundingMode) -> bool {\n    if rm != Exact {\n        true\n    } else if let Some(x_prec) = x.get_prec() {\n        if let Ok(sum) = Float::try_from(Rational::exact_from(x) + y) {\n            if let Some(min_prec) = sum.get_min_prec() {\n                x_prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        // y must be representable by precision-1 float\n        y.is_power_of_2()\n    }\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_1()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub(crate) fn sub_rational_round_valid(x: &Float, y: &Rational, rm: RoundingMode) -> bool {\n    if rm != Exact {\n        true\n    } else if let Some(x_prec) = x.get_prec() {\n        if let Ok(diff) = Float::try_from(Rational::exact_from(x) - y) {\n            if let Some(min_prec) = diff.get_min_prec() {\n                x_prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        // y must be representable by precision-1 float\n        y.is_power_of_2()\n    }\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_2()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_3()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(exhaustive_triples(\n        exhaustive_floats(),\n        exhaustive_rationals(),\n        exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n    ))\n}\n\npub(crate) fn mul_rational_round_valid(x: &Float, y: &Rational, rm: RoundingMode) -> bool {\n    if rm != Exact {\n        true\n    } else if let Some(x_prec) = x.get_prec() {\n        if let Ok(product) = Float::try_from(Rational::exact_from(x) * y) {\n            if let Some(min_prec) = product.get_min_prec() {\n                x_prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        // y must be representable by precision-1 float\n        y.is_power_of_2()\n    }\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_4()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub(crate) fn div_rational_round_valid(x: &Float, y: &Rational, rm: RoundingMode) -> bool {\n    if rm != Exact || *y == 0 {\n        true\n    } else if let Some(x_prec) = x.get_prec() {\n        if let Ok(quotient) = Float::try_from(Rational::exact_from(x) / y) {\n            if let Some(min_prec) = quotient.get_min_prec() {\n                x_prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        // y must be representable by precision-1 float\n        y.is_power_of_2()\n    }\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_5()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub(crate) fn rational_div_float_round_valid(x: &Float, y: &Rational, rm: RoundingMode) -> bool {\n    if rm != Exact || *x == 0u32 {\n        true\n    } else if let Some(prec) = x.get_prec() {\n        if let Ok(quotient) = Float::try_from(y / Rational::exact_from(x)) {\n            if let Some(min_prec) = quotient.get_min_prec() {\n                prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_6()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| rational_div_float_round_valid(x, y, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_7()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_extreme_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| add_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_8()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_extreme_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| sub_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_9()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_extreme_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| mul_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_10()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_extreme_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| div_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn exhaustive_float_rational_rounding_mode_triple_gen_var_11()\n-> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(exhaustive_extreme_floats(), exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, rm)| rational_div_float_round_valid(x, y, *rm)),\n    )\n}\n\n// -- (Float, RoundingMode) --\n\npub fn exhaustive_float_rounding_mode_pair_gen() -> It<(Float, RoundingMode)> {\n    Box::new(lex_pairs(exhaustive_floats(), exhaustive_rounding_modes()))\n}\n\npub(crate) fn natural_rounding_from_float_valid(f: &Float, rm: RoundingMode) -> bool {\n    match rm {\n        Down | Ceiling | Nearest => f.is_finite() || *f == Float::NEGATIVE_INFINITY,\n        Up | Floor => f.is_finite() && (f.is_sign_positive() || f.is_negative_zero()),\n        Exact => Natural::convertible_from(f),\n    }\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_1() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| natural_rounding_from_float_valid(f, *rm)),\n    )\n}\n\npub(crate) fn integer_rounding_from_float_valid(f: &Float, rm: RoundingMode) -> bool {\n    if rm == Exact {\n        Integer::convertible_from(f)\n    } else {\n        f.is_finite()\n    }\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_2() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| integer_rounding_from_float_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_3() -> It<(Float, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_nonzero_finite_floats(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub(crate) fn unsigned_rounding_from_float_valid<T: PrimitiveUnsigned>(\n    f: &Float,\n    rm: RoundingMode,\n) -> bool\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    match rm {\n        Floor => f.is_sign_positive() || f.is_negative_zero(),\n        Ceiling => *f <= T::MAX,\n        Down | Nearest => !f.is_nan(),\n        Up => (f.is_sign_positive() || f.is_negative_zero()) && *f <= T::MAX,\n        Exact => T::convertible_from(f),\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn exhaustive_float_rounding_mode_pair_gen_var_4<T: PrimitiveUnsigned>()\n-> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| unsigned_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub(crate) fn signed_rounding_from_float_valid<T: PrimitiveSigned>(\n    f: &Float,\n    rm: RoundingMode,\n) -> bool\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    match rm {\n        Floor => *f >= T::MIN,\n        Ceiling => *f <= T::MAX,\n        Down | Nearest => !f.is_nan(),\n        Up => *f >= T::MIN && *f <= T::MAX,\n        Exact => T::convertible_from(f),\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn exhaustive_float_rounding_mode_pair_gen_var_5<T: PrimitiveSigned>()\n-> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| signed_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn exhaustive_float_rounding_mode_pair_gen_var_6<T: PrimitiveFloat>()\n-> It<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| *rm != Exact || T::convertible_from(f)),\n    )\n}\n\npub(crate) fn square_round_valid(x: &Float, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact {\n        true\n    } else if extreme {\n        x.square_round_ref(Floor).1 == Equal\n    } else if let Some(x_prec) = x.get_prec() {\n        let square = Float::exact_from(Rational::exact_from(x).square());\n        if let Some(min_prec) = square.get_min_prec() {\n            x_prec >= min_prec\n        } else {\n            true\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_7() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_8() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(1, Limb::WIDTH - 1),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_9() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_positive_floats_with_precision(Limb::WIDTH),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_10() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(\n                Limb::WIDTH + 1,\n                (Limb::WIDTH << 1) - 1,\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_11() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_positive_floats_with_precision(Limb::WIDTH << 1),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_12() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(\n                (Limb::WIDTH << 1) + 1,\n                Limb::WIDTH * 3 - 1,\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub(crate) fn reciprocal_round_valid(x: &Float, rm: RoundingMode, extreme: bool) -> bool {\n    if rm != Exact || *x == 0 {\n        true\n    } else if extreme {\n        x.reciprocal_round_ref(Floor).1 == Equal\n    } else if let Some(x_prec) = x.get_prec() {\n        if let Ok(reciprocal) = Float::try_from(Rational::exact_from(x).reciprocal()) {\n            if let Some(min_prec) = reciprocal.get_min_prec() {\n                x_prec >= min_prec\n            } else {\n                true\n            }\n        } else {\n            false\n        }\n    } else {\n        true\n    }\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_13() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_14() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(1, Limb::WIDTH - 1),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_15() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_positive_floats_with_precision(Limb::WIDTH),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_16() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(\n                Limb::WIDTH + 1,\n                (Limb::WIDTH << 1) - 1,\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_17() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(Limb::WIDTH + 1, u64::MAX),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn exhaustive_float_rounding_mode_pair_gen_var_18<T: PrimitiveUnsigned>()\n-> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| unsigned_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn exhaustive_float_rounding_mode_pair_gen_var_19<T: PrimitiveSigned>()\n-> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| signed_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn exhaustive_float_rounding_mode_pair_gen_var_20<T: PrimitiveFloat>()\n-> It<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| *rm != Exact || T::convertible_from(f)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_21() -> It<(Float, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_extreme_floats(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_22() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| square_round_valid(f, *rm, true)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_23() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| reciprocal_round_valid(f, *rm, true)),\n    )\n}\n\npub(crate) fn sqrt_round_valid(x: &Float, rm: RoundingMode) -> bool {\n    rm != Exact || x.sqrt_round_ref(Floor).1 == Equal\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_24() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_25() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(1, Limb::WIDTH - 1),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_26() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_positive_floats_with_precision(Limb::WIDTH),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_27() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range(\n                Limb::WIDTH + 1,\n                (Limb::WIDTH << 1) - 1,\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_28() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(\n            exhaustive_floats_with_precision_inclusive_range((Limb::WIDTH << 1) + 1, u64::MAX),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_29() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub(crate) fn reciprocal_sqrt_round_valid(x: &Float, rm: RoundingMode) -> bool {\n    rm != Exact || x.reciprocal_sqrt_round_ref(Floor).1 == Equal\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_30() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| reciprocal_sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_31() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| reciprocal_sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_32() -> It<(Float, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_floats().filter(|x| *x > 0u32),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_33() -> It<(Float, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_finite_floats(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub(crate) fn ln_round_valid(x: &Float, rm: RoundingMode) -> bool {\n    rm != Exact || *x <= 0u32 || *x == 1u32\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_34() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| ln_round_valid(f, *rm)),\n    )\n}\n\npub fn exhaustive_float_rounding_mode_pair_gen_var_35() -> It<(Float, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_extreme_floats(), exhaustive_rounding_modes())\n            .filter(|(f, rm)| ln_round_valid(f, *rm)),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-nz.\n\npub fn exhaustive_integer_unsigned_rounding_mode_triple_gen_var_3()\n-> It<(Integer, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_integers(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| {\n            rm != Exact || *n == 0u32 || n.significant_bits() - n.trailing_zeros().unwrap() <= prec\n        }),\n    ))\n}\n\npub fn exhaustive_integer_unsigned_rounding_mode_triple_gen_var_4()\n-> It<(Integer, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_integers(), exhaustive_positive_primitive_ints()),\n        exhaustive_rounding_modes().filter(|rm| *rm != Exact),\n    )))\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\n// var 1 is in malachite-nz.\n\npub fn exhaustive_natural_unsigned_rounding_mode_triple_gen_var_2()\n-> It<(Natural, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_naturals(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| {\n            rm != Exact || *n == 0u32 || n.significant_bits() - n.trailing_zeros().unwrap() <= prec\n        }),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_rounding_mode_triple_gen_var_3()\n-> It<(Natural, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_naturals(), exhaustive_positive_primitive_ints()),\n        exhaustive_rounding_modes().filter(|&rm| rm != Exact),\n    )))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\npub fn from_primitive_float_prec_round_valid<T: PrimitiveFloat>(\n    x: T,\n    p: u64,\n    rm: RoundingMode,\n) -> bool\nwhere\n    Float: From<T>,\n{\n    set_prec_round_valid(&Float::from(x), p, rm)\n}\n\npub fn exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveFloat>()\n-> It<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_primitive_floats(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((x, p), rm)| from_primitive_float_prec_round_valid(x, p, rm)),\n    ))\n}\n\npub fn exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveFloat>()\n-> It<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(\n            exhaustive_primitive_floats(),\n            exhaustive_positive_primitive_ints(),\n        ),\n        exhaustive_rounding_modes().filter(|rm| *rm != Exact),\n    )))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\npub fn exhaustive_signed_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveSigned>()\n-> It<(T, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_signeds::<T>(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| {\n            rm != Exact || *n == T::ZERO || n.significant_bits() - n.trailing_zeros() <= prec\n        }),\n    ))\n}\n\npub fn exhaustive_signed_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveSigned>()\n-> It<(T, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(\n            exhaustive_signeds::<T>(),\n            exhaustive_positive_primitive_ints(),\n        ),\n        exhaustive_rounding_modes().filter(|rm| *rm != Exact),\n    )))\n}\n\npub fn exhaustive_signed_unsigned_rounding_mode_triple_gen_var_5() -> It<(i64, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_signeds(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((pow, _), rm)| {\n            rm != Exact\n                || (Float::MIN_EXPONENT..=Float::MAX_EXPONENT)\n                    .contains(&i32::saturating_from(pow).saturating_add(1))\n        }),\n    ))\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 5 are in malachite-base.\n\npub fn exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> It<(T, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_unsigneds::<T>(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| {\n            rm != Exact || *n == T::ZERO || n.significant_bits() - n.trailing_zeros() <= prec\n        }),\n    ))\n}\n\npub fn exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_7<T: PrimitiveUnsigned>()\n-> It<(T, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(\n            exhaustive_unsigneds::<T>(),\n            exhaustive_positive_primitive_ints(),\n        ),\n        exhaustive_rounding_modes().filter(|rm| *rm != Exact),\n    )))\n}\n\n// -- (Rational, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_rational_unsigned_rounding_mode_triple_gen_var_1()\n-> It<(Rational, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_rationals(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2()\n                    && n.numerator_ref().significant_bits() <= prec\n        }),\n    ))\n}\n\npub fn exhaustive_rational_unsigned_rounding_mode_triple_gen_var_2()\n-> It<(Rational, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_rationals(), exhaustive_positive_primitive_ints()),\n        exhaustive_rounding_modes().filter(|rm| *rm != Exact),\n    )))\n}\n\npub fn sqrt_rational_prec_round_valid(x: &Rational, prec: u64, rm: RoundingMode) -> bool {\n    rm != Exact || Float::sqrt_rational_prec_round_ref(x, prec, Floor).1 == Equal\n}\n\npub fn exhaustive_rational_unsigned_rounding_mode_triple_gen_var_3()\n-> It<(Rational, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_rationals(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| sqrt_rational_prec_round_valid(n, prec, rm)),\n    ))\n}\n\npub fn reciprocal_sqrt_rational_prec_round_valid(\n    x: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    rm != Exact || Float::reciprocal_sqrt_rational_prec_round_ref(x, prec, Floor).1 == Equal\n}\n\npub fn exhaustive_rational_unsigned_rounding_mode_triple_gen_var_4()\n-> It<(Rational, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_rationals(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| reciprocal_sqrt_rational_prec_round_valid(n, prec, rm)),\n    ))\n}\n\npub fn agm_rational_prec_round_valid(\n    x: &Rational,\n    y: &Rational,\n    prec: u64,\n    rm: RoundingMode,\n) -> bool {\n    rm != Exact\n        || *x < 0u32\n        || *y < 0u32\n        || x == y && Float::from_rational_prec_round_ref(x, prec, Floor).1 == Equal\n}\n\npub fn exhaustive_rational_unsigned_rounding_mode_triple_gen_var_5()\n-> It<(Rational, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(\n                exhaustive_non_negative_rationals(),\n                exhaustive_positive_primitive_ints(),\n            ),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2()\n                    && n.numerator_ref().significant_bits() <= prec\n        }),\n    ))\n}\n\npub fn ln_rational_prec_round_valid(x: &Rational, _prec: u64, rm: RoundingMode) -> bool {\n    rm != Exact || *x <= 0 || *x == 1u32\n}\n\npub fn exhaustive_rational_unsigned_rounding_mode_triple_gen_var_6()\n-> It<(Rational, u64, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_tiny(exhaustive_rationals(), exhaustive_positive_primitive_ints()),\n            exhaustive_rounding_modes(),\n        )\n        .filter(|&((ref n, prec), rm)| ln_rational_prec_round_valid(n, prec, rm)),\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n-> It<(Rational, Rational, u64, RoundingMode)> {\n    Box::new(\n        reshape_3_1_to_4(Box::new(lex_pairs(\n            exhaustive_triples_xxy_custom_output(\n                exhaustive_rationals(),\n                exhaustive_positive_primitive_ints::<u64>(),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::tiny(),\n            ),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(|(x, y, prec, rm)| agm_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\n// vars 1 through 5 are in malachite-q.\n\npub fn exhaustive_rational_rounding_mode_pair_gen_var_6() -> It<(Rational, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_rationals(), exhaustive_rounding_modes()).filter(|&(ref n, rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2() && n.numerator_ref().significant_bits() <= 1\n        }),\n    )\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/generators/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::test_util::generators::common::{\n    float_float_anything_rounding_mode_quadruple_rm, float_float_anything_triple_rm,\n    float_float_rounding_mode_triple_rm, float_integer_pair_rm, float_natural_pair_rm,\n    float_pair_rm, float_primitive_float_pair_rm, float_primitive_int_pair_rm,\n    float_rational_anything_rounding_mode_quadruple_rm, float_rational_anything_triple_rm,\n    float_rational_pair_rm, float_rational_rounding_mode_triple_rm, float_rm,\n    float_rounding_mode_pair_rm, float_t_rounding_mode_triple_rm,\n    float_t_u_rounding_mode_quadruple_rm, float_t_u_triple_rm,\n};\nuse crate::test_util::generators::exhaustive::*;\nuse crate::test_util::generators::random::*;\nuse crate::test_util::generators::special_random::*;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_base::test_util::generators::common::Generator;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse std::cmp::Ordering;\n\n// -- Float --\n\npub fn float_gen() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen,\n        &random_float_gen,\n        &special_random_float_gen,\n    )\n}\n\npub fn float_gen_rm() -> Generator<(rug::Float, Float)> {\n    Generator::new(\n        &|| float_rm(exhaustive_float_gen()),\n        &|config| float_rm(random_float_gen(config)),\n        &|config| float_rm(special_random_float_gen(config)),\n    )\n}\n\n// All positive finite floats (not including positive zero).\npub fn float_gen_var_1() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_1,\n        &random_float_gen_var_1,\n        &special_random_float_gen_var_1,\n    )\n}\n\n// All floats except NaN.\npub fn float_gen_var_2() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_2,\n        &random_float_gen_var_2,\n        &special_random_float_gen_var_2,\n    )\n}\n\npub fn float_gen_var_2_rm() -> Generator<(rug::Float, Float)> {\n    Generator::new(\n        &|| float_rm(exhaustive_float_gen_var_2()),\n        &|config| float_rm(random_float_gen_var_2(config)),\n        &|config| float_rm(special_random_float_gen_var_2(config)),\n    )\n}\n\n// All nonzero finite floats.\npub fn float_gen_var_3() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_3,\n        &random_float_gen_var_3,\n        &special_random_float_gen_var_3,\n    )\n}\n\n// All finite floats.\npub fn float_gen_var_4() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_4,\n        &random_float_gen_var_4,\n        &special_random_float_gen_var_4,\n    )\n}\n\n// All non-negative finite floats.\npub fn float_gen_var_5() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_5,\n        &random_float_gen_var_5,\n        &special_random_float_gen_var_5,\n    )\n}\n\n// All floats with a precision less than `Limb::WIDTH`.\npub fn float_gen_var_6() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_6,\n        &random_float_gen_var_6,\n        &special_random_float_gen_var_6,\n    )\n}\n\n// All floats with precision `Limb::WIDTH`.\npub fn float_gen_var_7() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_7,\n        &random_float_gen_var_7,\n        &special_random_float_gen_var_7,\n    )\n}\n\n// All floats with a precision greater than `Limb::WIDTH` and less than `Limb::WIDTH` * 2.\npub fn float_gen_var_8() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_8,\n        &random_float_gen_var_8,\n        &special_random_float_gen_var_8,\n    )\n}\n\n// All floats with precision `Limb::WIDTH` * 2.\npub fn float_gen_var_9() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_9,\n        &random_float_gen_var_9,\n        &special_random_float_gen_var_9,\n    )\n}\n\n// All floats with a precision greater than `Limb::WIDTH` * 2 and less than `Limb::WIDTH` * 3.\npub fn float_gen_var_10() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_10,\n        &random_float_gen_var_10,\n        &special_random_float_gen_var_10,\n    )\n}\n\n// All floats with a precision greater than `Limb::WIDTH` * 2.\npub fn float_gen_var_11() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_11,\n        &random_float_gen_var_11,\n        &special_random_float_gen_var_11,\n    )\n}\n\n// Extreme floats.\npub fn float_gen_var_12() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_12,\n        &random_float_gen_var_12,\n        &special_random_float_gen_var_12,\n    )\n}\n\n// Extreme nonzero finite floats.\npub fn float_gen_var_13() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_13,\n        &random_float_gen_var_13,\n        &special_random_float_gen_var_13,\n    )\n}\n\n// All extreme floats except NaN.\npub fn float_gen_var_14() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_14,\n        &random_float_gen_var_14,\n        &special_random_float_gen_var_14,\n    )\n}\n\n// All positive `Float`s.\npub fn float_gen_var_15() -> Generator<Float> {\n    Generator::new(\n        &exhaustive_float_gen_var_15,\n        &random_float_gen_var_15,\n        &special_random_float_gen_var_15,\n    )\n}\n\n// -- (Float, Float) --\n\npub fn float_pair_gen() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen,\n        &random_float_pair_gen,\n        &special_random_float_pair_gen,\n    )\n}\n\npub fn float_pair_gen_rm() -> Generator<((rug::Float, rug::Float), (Float, Float))> {\n    Generator::new(\n        &|| float_pair_rm(exhaustive_float_pair_gen()),\n        &|config| float_pair_rm(random_float_pair_gen(config)),\n        &|config| float_pair_rm(special_random_float_pair_gen(config)),\n    )\n}\n\n// All pairs of finite floats.\npub fn float_pair_gen_var_1() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_1,\n        &random_float_pair_gen_var_1,\n        &special_random_float_pair_gen_var_1,\n    )\n}\n\n// All pairs of positive floats with the same precision, which is greater than zero and less than\n// `Limb::WIDTH`.\npub fn float_pair_gen_var_2() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_2,\n        &random_float_pair_gen_var_2,\n        &special_random_float_pair_gen_var_2,\n    )\n}\n\n// All pairs of positive floats with the same precision, which is `Limb::WIDTH`.\npub fn float_pair_gen_var_3() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_3,\n        &random_float_pair_gen_var_3,\n        &special_random_float_pair_gen_var_3,\n    )\n}\n\n// All pairs of positive floats with the same precision, which is greater than `Limb::WIDTH` and\n// less than twice `Limb::WIDTH`.\npub fn float_pair_gen_var_4() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_4,\n        &random_float_pair_gen_var_4,\n        &special_random_float_pair_gen_var_4,\n    )\n}\n\n// All pairs of positive floats with the same precision, which is twice `Limb::WIDTH`.\npub fn float_pair_gen_var_5() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_5,\n        &random_float_pair_gen_var_5,\n        &special_random_float_pair_gen_var_5,\n    )\n}\n\n// All pairs of positive floats with the same precision, which is greater than twice `Limb::WIDTH`\n// and less than three times `Limb::WIDTH`.\npub fn float_pair_gen_var_6() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_6,\n        &random_float_pair_gen_var_6,\n        &special_random_float_pair_gen_var_6,\n    )\n}\n\n// All pairs of positive floats with the same precision, which is greater than or equal to three\n// times `Limb::WIDTH`.\npub fn float_pair_gen_var_7() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_7,\n        &random_float_pair_gen_var_7,\n        &special_random_float_pair_gen_var_7,\n    )\n}\n\n// All pairs of positive floats with different precisions, such that the precision of the second\n// float is less than or equal to `Limb::WIDTH`.\npub fn float_pair_gen_var_8() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_8,\n        &random_float_pair_gen_var_8,\n        &special_random_float_pair_gen_var_8,\n    )\n}\n\n// All pairs of positive floats with different precisions, such that the precision of the second\n// float is greater than `Limb::WIDTH`.\npub fn float_pair_gen_var_9() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_9,\n        &random_float_pair_gen_var_9,\n        &special_random_float_pair_gen_var_9,\n    )\n}\n\n// All pairs of floats, some of which are extreme.\npub fn float_pair_gen_var_10() -> Generator<(Float, Float)> {\n    Generator::new(\n        &exhaustive_float_pair_gen_var_10,\n        &random_float_pair_gen_var_10,\n        &special_random_float_pair_gen,\n    )\n}\n\n// -- (Float, Float, Float) --\n\npub fn float_triple_gen() -> Generator<(Float, Float, Float)> {\n    Generator::new(\n        &exhaustive_float_triple_gen,\n        &random_float_triple_gen,\n        &special_random_float_triple_gen,\n    )\n}\n\n// -- (Float, Float, Integer) --\n\npub fn float_float_integer_triple_gen() -> Generator<(Float, Float, Integer)> {\n    Generator::new(\n        &exhaustive_float_float_integer_triple_gen,\n        &random_float_float_integer_triple_gen,\n        &special_random_float_float_integer_triple_gen,\n    )\n}\n\n// -- (Float, Float, Natural) --\n\npub fn float_float_natural_triple_gen() -> Generator<(Float, Float, Natural)> {\n    Generator::new(\n        &exhaustive_float_float_natural_triple_gen,\n        &random_float_float_natural_triple_gen,\n        &special_random_float_float_natural_triple_gen,\n    )\n}\n\n// -- (Float, Float, PrimitiveFloat) --\n\npub fn float_float_primitive_float_triple_gen<T: PrimitiveFloat>() -> Generator<(Float, Float, T)> {\n    Generator::new(\n        &exhaustive_float_float_primitive_float_triple_gen,\n        &random_float_float_primitive_float_triple_gen,\n        &special_random_float_float_primitive_float_triple_gen,\n    )\n}\n\n// -- (Float, Float, PrimitiveSigned) --\n\npub fn float_float_signed_triple_gen<T: PrimitiveSigned>() -> Generator<(Float, Float, T)> {\n    Generator::new(\n        &exhaustive_float_float_signed_triple_gen,\n        &random_float_float_primitive_int_triple_gen,\n        &special_random_float_float_signed_triple_gen,\n    )\n}\n\n// -- (Float, Float, PrimitiveUnsigned) --\n\npub fn float_float_unsigned_triple_gen<T: PrimitiveUnsigned>() -> Generator<(Float, Float, T)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_triple_gen,\n        &random_float_float_primitive_int_triple_gen,\n        &special_random_float_float_unsigned_triple_gen,\n    )\n}\n\n// All triples of `(Float, Float, T)`, where `T` is unsigned, small, and positive.\npub fn float_float_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Float, Float, T)>\n{\n    Generator::new(\n        &exhaustive_float_float_unsigned_triple_gen_var_1,\n        &random_float_float_unsigned_triple_gen_var_1,\n        &special_random_float_float_unsigned_triple_gen_var_1,\n    )\n}\n\npub fn float_float_unsigned_triple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Float, rug::Float, T), (Float, Float, T))> {\n    Generator::new(\n        &|| float_float_anything_triple_rm(exhaustive_float_float_unsigned_triple_gen_var_1()),\n        &|config| {\n            float_float_anything_triple_rm(random_float_float_unsigned_triple_gen_var_1(config))\n        },\n        &|config| {\n            float_float_anything_triple_rm(special_random_float_float_unsigned_triple_gen_var_1(\n                config,\n            ))\n        },\n    )\n}\n\n// All triples of `(Float, Float, T)`, where the `Float`s may be extreme and the `T` is unsigned,\n// small, and positive.\npub fn float_float_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Float, Float, T)>\n{\n    Generator::new(\n        &exhaustive_float_float_unsigned_triple_gen_var_2,\n        &random_float_float_unsigned_triple_gen_var_2,\n        &special_random_float_float_unsigned_triple_gen_var_2,\n    )\n}\n\n// -- (Float, Float, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::add_prec_round`.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_1()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_1,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_1,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_1,\n    )\n}\n\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_1_rm() -> Generator<(\n    (rug::Float, rug::Float, u64, rug::float::Round),\n    (Float, Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_1(),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                random_float_float_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::sub_prec_round`.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_2()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_2,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_2,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_2,\n    )\n}\n\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_2_rm() -> Generator<(\n    (rug::Float, rug::Float, u64, rug::float::Round),\n    (Float, Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_2(),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                random_float_float_unsigned_rounding_mode_quadruple_gen_var_2(config),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_2(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::mul_prec_round`.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_3()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_3,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_3,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_3,\n    )\n}\n\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_3_rm() -> Generator<(\n    (rug::Float, rug::Float, u64, rug::float::Round),\n    (Float, Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                random_float_float_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::div_prec_round`.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_4()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_4,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_4,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_4,\n    )\n}\n\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_4_rm() -> Generator<(\n    (rug::Float, rug::Float, u64, rug::float::Round),\n    (Float, Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_4(),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                random_float_float_unsigned_rounding_mode_quadruple_gen_var_4(config),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_4(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::add_prec_round`, where\n// the `Float`s may be extreme.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_5()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_5,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_5,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_5,\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::sub_prec_round`, where\n// the `Float`s may be extreme.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_6()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_6,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_6,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_6,\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::mul_prec_round`, where\n// the `Float`s may be extreme.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_7()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_7,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_7,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_7,\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::div_prec_round`, where\n// the `Float`s may be extreme.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_8()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_8,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_8,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_8,\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::agm_prec_round`.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_9()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_9,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_9,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_9,\n    )\n}\n\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_9_rm() -> Generator<(\n    (rug::Float, rug::Float, u64, rug::float::Round),\n    (Float, Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_9(),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                random_float_float_unsigned_rounding_mode_quadruple_gen_var_9(config),\n            )\n        },\n        &|config| {\n            float_float_anything_rounding_mode_quadruple_rm(\n                special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_9(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, u64, RoundingMode)` that are valid inputs to `Float::agm_prec_round`, where\n// the `Float`s may be extreme.\npub fn float_float_unsigned_rounding_mode_quadruple_gen_var_10()\n-> Generator<(Float, Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_unsigned_rounding_mode_quadruple_gen_var_10,\n        &random_float_float_unsigned_rounding_mode_quadruple_gen_var_10,\n        &special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_10,\n    )\n}\n\n// -- (Float, Float, Rational) --\n\npub fn float_float_rational_triple_gen() -> Generator<(Float, Float, Rational)> {\n    Generator::new(\n        &exhaustive_float_float_rational_triple_gen,\n        &random_float_float_rational_triple_gen,\n        &special_random_float_float_rational_triple_gen,\n    )\n}\n\n// -- (Float, Float, RoundingMode) --\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`.\npub fn float_float_rounding_mode_triple_gen_var_1() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_1,\n        &random_float_float_rounding_mode_triple_gen_var_1,\n        &special_random_float_float_rounding_mode_triple_gen_var_1,\n    )\n}\n\npub fn float_float_rounding_mode_triple_gen_var_1_rm() -> Generator<(\n    (rug::Float, rug::Float, rug::float::Round),\n    (Float, Float, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_rounding_mode_triple_rm(\n                exhaustive_float_float_rounding_mode_triple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(random_float_float_rounding_mode_triple_gen_var_3(\n                config,\n            ))\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(\n                special_random_float_float_rounding_mode_triple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`.\npub fn float_float_rounding_mode_triple_gen_var_2() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_2,\n        &random_float_float_rounding_mode_triple_gen_var_2,\n        &special_random_float_float_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round` or\n// `Float::sub_round`, excluding those with Exact.\npub fn float_float_rounding_mode_triple_gen_var_3_rm() -> Generator<(\n    (rug::Float, rug::Float, rug::float::Round),\n    (Float, Float, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_rounding_mode_triple_rm(\n                exhaustive_float_float_rounding_mode_triple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(random_float_float_rounding_mode_triple_gen_var_3(\n                config,\n            ))\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(\n                special_random_float_float_rounding_mode_triple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`, where the\n// `Float`s have the same precision, which is greater than zero and less than `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_4() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_4,\n        &random_float_float_rounding_mode_triple_gen_var_4,\n        &special_random_float_float_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`, where the\n// `Float`s have the same precision, which is `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_5() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_5,\n        &random_float_float_rounding_mode_triple_gen_var_5,\n        &special_random_float_float_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`, where the\n// `Float`s have the same precision, which is greater than `Limb::WIDTH` and less than twice\n// `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_6() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_6,\n        &random_float_float_rounding_mode_triple_gen_var_6,\n        &special_random_float_float_rounding_mode_triple_gen_var_6,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`, where the\n// `Float`s have the same precision, which is twice `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_7() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_7,\n        &random_float_float_rounding_mode_triple_gen_var_7,\n        &special_random_float_float_rounding_mode_triple_gen_var_7,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`, where the\n// `Float`s have the same precision, which is greater than twice `Limb::WIDTH` and less than three\n// times `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_8() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_8,\n        &random_float_float_rounding_mode_triple_gen_var_8,\n        &special_random_float_float_rounding_mode_triple_gen_var_8,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`, where the\n// `Float`s have the same precision, which is greater than or equal to three times `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_9() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_9,\n        &random_float_float_rounding_mode_triple_gen_var_9,\n        &special_random_float_float_rounding_mode_triple_gen_var_9,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`, where the\n// `Float`s have the same precision, which is greater than zero and less than `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_10() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_10,\n        &random_float_float_rounding_mode_triple_gen_var_10,\n        &special_random_float_float_rounding_mode_triple_gen_var_10,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`, where the\n// `Float`s have the same precision, which is `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_11() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_11,\n        &random_float_float_rounding_mode_triple_gen_var_11,\n        &special_random_float_float_rounding_mode_triple_gen_var_11,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`, where the\n// `Float`s have the same precision, which is greater than `Limb::WIDTH` and less than twice\n// `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_12() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_12,\n        &random_float_float_rounding_mode_triple_gen_var_12,\n        &special_random_float_float_rounding_mode_triple_gen_var_12,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`, where the\n// `Float`s have the same precision, which is twice `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_13() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_13,\n        &random_float_float_rounding_mode_triple_gen_var_13,\n        &special_random_float_float_rounding_mode_triple_gen_var_13,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`, where the\n// `Float`s have the same precision, which is greater than twice `Limb::WIDTH` and less than three\n// times `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_14() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_14,\n        &random_float_float_rounding_mode_triple_gen_var_14,\n        &special_random_float_float_rounding_mode_triple_gen_var_14,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`, where the\n// `Float`s have the same precision, which is greater than or equal to three times `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_15() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_15,\n        &random_float_float_rounding_mode_triple_gen_var_15,\n        &special_random_float_float_rounding_mode_triple_gen_var_15,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`.\npub fn float_float_rounding_mode_triple_gen_var_16() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_16,\n        &random_float_float_rounding_mode_triple_gen_var_16,\n        &special_random_float_float_rounding_mode_triple_gen_var_16,\n    )\n}\n\npub fn float_float_rounding_mode_triple_gen_var_16_rm() -> Generator<(\n    (rug::Float, rug::Float, rug::float::Round),\n    (Float, Float, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_rounding_mode_triple_rm(\n                exhaustive_float_float_rounding_mode_triple_gen_var_16(),\n            )\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(random_float_float_rounding_mode_triple_gen_var_16(\n                config,\n            ))\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(\n                special_random_float_float_rounding_mode_triple_gen_var_16(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`, where the\n// `Float`s have the same precision, which is greater than zero and less than `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_17() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_17,\n        &random_float_float_rounding_mode_triple_gen_var_17,\n        &special_random_float_float_rounding_mode_triple_gen_var_17,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`, where the\n// `Float`s have the same precision, which is `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_18() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_18,\n        &random_float_float_rounding_mode_triple_gen_var_18,\n        &special_random_float_float_rounding_mode_triple_gen_var_18,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`, where the\n// `Float`s have the same precision, which is greater than `Limb::WIDTH` and less than twice\n// `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_19() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_19,\n        &random_float_float_rounding_mode_triple_gen_var_19,\n        &special_random_float_float_rounding_mode_triple_gen_var_19,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`, where the\n// `Float`s have the same precision, which is twice `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_20() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_20,\n        &random_float_float_rounding_mode_triple_gen_var_20,\n        &special_random_float_float_rounding_mode_triple_gen_var_20,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`, where the\n// `Float`s have the same precision, which is greater than twice `Limb::WIDTH` and less than three\n// times `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_21() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_21,\n        &random_float_float_rounding_mode_triple_gen_var_21,\n        &special_random_float_float_rounding_mode_triple_gen_var_21,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`, where the\n// `Float`s have the same precision, which is greater than or equal to three times `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_22() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_22,\n        &random_float_float_rounding_mode_triple_gen_var_22,\n        &special_random_float_float_rounding_mode_triple_gen_var_22,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::div_round`.\npub fn float_float_rounding_mode_triple_gen_var_23() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_23,\n        &random_float_float_rounding_mode_triple_gen_var_23,\n        &special_random_float_float_rounding_mode_triple_gen_var_23,\n    )\n}\n\npub fn float_float_rounding_mode_triple_gen_var_23_rm() -> Generator<(\n    (rug::Float, rug::Float, rug::float::Round),\n    (Float, Float, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_rounding_mode_triple_rm(\n                exhaustive_float_float_rounding_mode_triple_gen_var_23(),\n            )\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(random_float_float_rounding_mode_triple_gen_var_23(\n                config,\n            ))\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(\n                special_random_float_float_rounding_mode_triple_gen_var_23(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::div_round`, where the\n// `Float`s have the same precision, which is greater than zero and less than `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_24() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_24,\n        &random_float_float_rounding_mode_triple_gen_var_24,\n        &special_random_float_float_rounding_mode_triple_gen_var_24,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::div_round`, where the\n// `Float`s have the same precision, which is `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_25() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_25,\n        &random_float_float_rounding_mode_triple_gen_var_25,\n        &special_random_float_float_rounding_mode_triple_gen_var_25,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::div_round`, where the\n// `Float`s have the same precision, which is greater than `Limb::WIDTH` and less than twice\n// `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_26() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_26,\n        &random_float_float_rounding_mode_triple_gen_var_26,\n        &special_random_float_float_rounding_mode_triple_gen_var_26,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::div_round`, where the\n// `Float`s have different precisions and that the precision of the second float is less than or\n// equal to `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_27() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_27,\n        &random_float_float_rounding_mode_triple_gen_var_27,\n        &special_random_float_float_rounding_mode_triple_gen_var_27,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::div_round`, where the\n// `Float`s have different precisions and that the precision of the second float is greater than\n// `Limb::WIDTH`.\npub fn float_float_rounding_mode_triple_gen_var_28() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_28,\n        &random_float_float_rounding_mode_triple_gen_var_28,\n        &special_random_float_float_rounding_mode_triple_gen_var_28,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::add_round`, and the `Float`s\n// may be extreme.\npub fn float_float_rounding_mode_triple_gen_var_29() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_29,\n        &random_float_float_rounding_mode_triple_gen_var_29,\n        &special_random_float_float_rounding_mode_triple_gen_var_29,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::sub_round`, and the `Float`s\n// may be extreme.\npub fn float_float_rounding_mode_triple_gen_var_30() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_30,\n        &random_float_float_rounding_mode_triple_gen_var_30,\n        &special_random_float_float_rounding_mode_triple_gen_var_30,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::mul_round`, and the `Float`s\n// may be extreme.\npub fn float_float_rounding_mode_triple_gen_var_31() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_31,\n        &random_float_float_rounding_mode_triple_gen_var_31,\n        &special_random_float_float_rounding_mode_triple_gen_var_31,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::div_round`, where the\n// `Float`s may be extreme.\npub fn float_float_rounding_mode_triple_gen_var_32() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_32,\n        &random_float_float_rounding_mode_triple_gen_var_32,\n        &special_random_float_float_rounding_mode_triple_gen_var_32,\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::agm_round`.\npub fn float_float_rounding_mode_triple_gen_var_33() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_33,\n        &random_float_float_rounding_mode_triple_gen_var_33,\n        &special_random_float_float_rounding_mode_triple_gen_var_33,\n    )\n}\n\npub fn float_float_rounding_mode_triple_gen_var_33_rm() -> Generator<(\n    (rug::Float, rug::Float, rug::float::Round),\n    (Float, Float, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_float_rounding_mode_triple_rm(\n                exhaustive_float_float_rounding_mode_triple_gen_var_33(),\n            )\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(random_float_float_rounding_mode_triple_gen_var_33(\n                config,\n            ))\n        },\n        &|config| {\n            float_float_rounding_mode_triple_rm(\n                special_random_float_float_rounding_mode_triple_gen_var_33(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Float, RoundingMode)` that are valid inputs to `Float::agm_round`, where the\n// `Float`s may be extreme.\npub fn float_float_rounding_mode_triple_gen_var_34() -> Generator<(Float, Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_float_rounding_mode_triple_gen_var_34,\n        &random_float_float_rounding_mode_triple_gen_var_34,\n        &special_random_float_float_rounding_mode_triple_gen_var_34,\n    )\n}\n\n// -- (Float, Integer) --\n\npub fn float_integer_pair_gen() -> Generator<(Float, Integer)> {\n    Generator::new(\n        &exhaustive_float_integer_pair_gen,\n        &random_float_integer_pair_gen,\n        &special_random_float_integer_pair_gen,\n    )\n}\n\npub fn float_integer_pair_gen_rm() -> Generator<((rug::Float, rug::Integer), (Float, Integer))> {\n    Generator::new(\n        &|| float_integer_pair_rm(exhaustive_float_integer_pair_gen()),\n        &|config| float_integer_pair_rm(random_float_integer_pair_gen(config)),\n        &|config| float_integer_pair_rm(special_random_float_integer_pair_gen(config)),\n    )\n}\n\n// All pairs of finite Floats and Integers.\npub fn float_integer_pair_gen_var_1() -> Generator<(Float, Integer)> {\n    Generator::new(\n        &exhaustive_float_integer_pair_gen_var_1,\n        &random_float_integer_pair_gen_var_1,\n        &special_random_float_integer_pair_gen_var_1,\n    )\n}\n\n// All pairs of Floats and Integers, where the Float is extreme.\npub fn float_integer_pair_gen_var_2() -> Generator<(Float, Integer)> {\n    Generator::new(\n        &exhaustive_float_integer_pair_gen_var_2,\n        &random_float_integer_pair_gen_var_2,\n        &special_random_float_integer_pair_gen_var_2,\n    )\n}\n\n// -- (Float, Integer, Integer) --\n\npub fn float_integer_integer_triple_gen() -> Generator<(Float, Integer, Integer)> {\n    Generator::new(\n        &exhaustive_float_integer_integer_triple_gen,\n        &random_float_integer_integer_triple_gen,\n        &special_random_float_integer_integer_triple_gen,\n    )\n}\n\n// -- (Float, Natural) --\n\npub fn float_natural_pair_gen() -> Generator<(Float, Natural)> {\n    Generator::new(\n        &exhaustive_float_natural_pair_gen,\n        &random_float_natural_pair_gen,\n        &special_random_float_natural_pair_gen,\n    )\n}\n\npub fn float_natural_pair_gen_rm() -> Generator<((rug::Float, rug::Integer), (Float, Natural))> {\n    Generator::new(\n        &|| float_natural_pair_rm(exhaustive_float_natural_pair_gen()),\n        &|config| float_natural_pair_rm(random_float_natural_pair_gen(config)),\n        &|config| float_natural_pair_rm(special_random_float_natural_pair_gen(config)),\n    )\n}\n\n// All pairs of finite Floats and Naturals.\npub fn float_natural_pair_gen_var_1() -> Generator<(Float, Natural)> {\n    Generator::new(\n        &exhaustive_float_natural_pair_gen_var_1,\n        &random_float_natural_pair_gen_var_1,\n        &special_random_float_natural_pair_gen_var_1,\n    )\n}\n\n// All pairs of Floats and Naturals, where the Float is extreme.\npub fn float_natural_pair_gen_var_2() -> Generator<(Float, Natural)> {\n    Generator::new(\n        &exhaustive_float_natural_pair_gen_var_2,\n        &random_float_natural_pair_gen_var_2,\n        &special_random_float_natural_pair_gen_var_2,\n    )\n}\n\n// -- (Float, Natural, Natural) --\n\npub fn float_natural_natural_triple_gen() -> Generator<(Float, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_float_natural_natural_triple_gen,\n        &random_float_natural_natural_triple_gen,\n        &special_random_float_natural_natural_triple_gen,\n    )\n}\n\n// -- (Float, Ordering) --\n\npub fn float_ordering_pair_gen() -> Generator<(Float, Ordering)> {\n    Generator::new(\n        &exhaustive_float_ordering_pair_gen,\n        &random_float_ordering_pair_gen,\n        &special_random_float_ordering_pair_gen,\n    )\n}\n\n// All `(Float, Ordering)` where the `Float` is extreme.\npub fn float_ordering_pair_gen_var_1() -> Generator<(Float, Ordering)> {\n    Generator::new(\n        &exhaustive_float_ordering_pair_gen_var_1,\n        &random_float_ordering_pair_gen_var_1,\n        &special_random_float_ordering_pair_gen_var_1,\n    )\n}\n\n// -- (Float, PrimitiveFloat) --\n\npub fn float_primitive_float_pair_gen<T: PrimitiveFloat>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_primitive_float_pair_gen,\n        &random_float_primitive_float_pair_gen,\n        &special_random_float_primitive_float_pair_gen,\n    )\n}\n\npub fn float_primitive_float_pair_gen_rm<T: PrimitiveFloat>()\n-> Generator<((rug::Float, T), (Float, T))> {\n    Generator::new(\n        &|| float_primitive_float_pair_rm(exhaustive_float_primitive_float_pair_gen()),\n        &|config| float_primitive_float_pair_rm(random_float_primitive_float_pair_gen(config)),\n        &|config| {\n            float_primitive_float_pair_rm(special_random_float_primitive_float_pair_gen(config))\n        },\n    )\n}\n\n// All `(Float, T)` where the Float is extreme and `T` is a primitive float.\npub fn float_primitive_float_pair_gen_var_1<T: PrimitiveFloat>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_primitive_float_pair_gen_var_1,\n        &random_float_primitive_float_pair_gen_var_1,\n        &special_random_float_primitive_float_pair_gen_var_1,\n    )\n}\n\n// -- (Float, PrimitiveFloat, PrimitiveFloat) --\n\npub fn float_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> Generator<(Float, T, T)> {\n    Generator::new(\n        &exhaustive_float_primitive_float_primitive_float_triple_gen,\n        &random_float_primitive_float_primitive_float_triple_gen,\n        &special_random_float_primitive_float_primitive_float_triple_gen,\n    )\n}\n\n// -- (Float, PrimitiveSigned) --\n\npub fn float_signed_pair_gen<T: PrimitiveSigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_signed_pair_gen,\n        &random_float_signed_pair_gen,\n        &special_random_float_signed_pair_gen,\n    )\n}\n\npub fn float_signed_pair_gen_rm<T: PrimitiveSigned>() -> Generator<((rug::Float, T), (Float, T))> {\n    Generator::new(\n        &|| float_primitive_int_pair_rm(exhaustive_float_signed_pair_gen()),\n        &|config| float_primitive_int_pair_rm(random_float_signed_pair_gen(config)),\n        &|config| float_primitive_int_pair_rm(special_random_float_signed_pair_gen(config)),\n    )\n}\n\n// All `(Float, T)` where `T` is signed and small and the `Float` is in the range [1.0, 2.0).\npub fn float_signed_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_signed_pair_gen_var_1,\n        &random_float_signed_pair_gen_var_1,\n        &special_random_float_signed_pair_gen_var_1,\n    )\n}\n\n// All `(Float, T)` where `T` is small and signed.\npub fn float_signed_pair_gen_var_2<T: PrimitiveSigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_signed_pair_gen_var_2,\n        &random_float_signed_pair_gen_var_2,\n        &special_random_float_signed_pair_gen_var_2,\n    )\n}\n\npub fn float_signed_pair_gen_var_2_rm<T: PrimitiveSigned>()\n-> Generator<((rug::Float, T), (Float, T))> {\n    Generator::new(\n        &|| float_primitive_int_pair_rm(exhaustive_float_signed_pair_gen_var_2()),\n        &|config| float_primitive_int_pair_rm(random_float_signed_pair_gen_var_2(config)),\n        &|config| float_primitive_int_pair_rm(special_random_float_signed_pair_gen_var_2(config)),\n    )\n}\n\n// All `(Float, T)` where the Float is extreme and `T` is small and signed.\npub fn float_signed_pair_gen_var_3<T: PrimitiveSigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_signed_pair_gen_var_3,\n        &random_float_signed_pair_gen_var_3,\n        &special_random_float_signed_pair_gen_var_3,\n    )\n}\n\n// All `(Float, T)` where the Float is extreme and `T` is signed.\npub fn float_signed_pair_gen_var_4<T: PrimitiveSigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_signed_pair_gen_var_4,\n        &random_float_signed_pair_gen_var_4,\n        &special_random_float_signed_pair_gen_var_4,\n    )\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveSigned) --\n\npub fn float_signed_signed_triple_gen<T: PrimitiveSigned>() -> Generator<(Float, T, T)> {\n    Generator::new(\n        &exhaustive_float_signed_signed_triple_gen,\n        &random_float_primitive_int_primitive_int_triple_gen,\n        &special_random_float_signed_signed_triple_gen,\n    )\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned) --\n\n// All `(Float, T, U)` where `T` is signed, `U` is unsigned, and the `U` is positive.\npub fn float_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(Float, T, U)> {\n    Generator::new(\n        &exhaustive_float_signed_unsigned_triple_gen_var_1,\n        &random_float_signed_unsigned_triple_gen_var_1,\n        &special_random_float_signed_unsigned_triple_gen_var_1,\n    )\n}\n\npub fn float_signed_unsigned_triple_gen_var_1_rm<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<((rug::Float, T, U), (Float, T, U))> {\n    Generator::new(\n        &|| float_t_u_triple_rm(exhaustive_float_signed_unsigned_triple_gen_var_1()),\n        &|config| float_t_u_triple_rm(random_float_signed_unsigned_triple_gen_var_1(config)),\n        &|config| {\n            float_t_u_triple_rm(special_random_float_signed_unsigned_triple_gen_var_1(\n                config,\n            ))\n        },\n    )\n}\n\n// All `(Float, T, U)` where the `Float` is extreme, `T` is signed, `U` is unsigned, and the `U` is\n// positive.\npub fn float_signed_unsigned_triple_gen_var_2<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(Float, T, U)> {\n    Generator::new(\n        &exhaustive_float_signed_unsigned_triple_gen_var_2,\n        &random_float_signed_unsigned_triple_gen_var_2,\n        &special_random_float_signed_unsigned_triple_gen_var_2,\n    )\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Float, T, u64, RoundingMode)` where `T` is signed and the quadruple is a valid input to\n// `Float::shl_prec_round`.\npub fn float_signed_unsigned_rounding_mode_quadruple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_1,\n        &random_float_signed_unsigned_rounding_mode_quadruple_gen_var_1,\n        &special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_1,\n    )\n}\n\npub fn float_signed_unsigned_rounding_mode_quadruple_gen_var_1_rm<T: PrimitiveSigned>()\n-> Generator<(\n    (rug::Float, T, u64, rug::float::Round),\n    (Float, T, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_u_rounding_mode_quadruple_rm(\n                exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_1(),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                random_float_signed_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n    )\n}\n\n// All `(Float, T, u64, RoundingMode)` where `T` is signed, the `Float` is extreme, and the\n// quadruple is a valid input to `Float::shl_prec_round`.\npub fn float_signed_unsigned_rounding_mode_quadruple_gen_var_2<T: PrimitiveSigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_2,\n        &random_float_signed_unsigned_rounding_mode_quadruple_gen_var_2,\n        &special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_2,\n    )\n}\n\n// All `(Float, T, u64, RoundingMode)` where `T` is signed and the quadruple is a valid input to\n// `Float::shr_prec_round`.\npub fn float_signed_unsigned_rounding_mode_quadruple_gen_var_3<T: PrimitiveSigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_3,\n        &random_float_signed_unsigned_rounding_mode_quadruple_gen_var_3,\n        &special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_3,\n    )\n}\n\npub fn float_signed_unsigned_rounding_mode_quadruple_gen_var_3_rm<T: PrimitiveSigned>()\n-> Generator<(\n    (rug::Float, T, u64, rug::float::Round),\n    (Float, T, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_u_rounding_mode_quadruple_rm(\n                exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                random_float_signed_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, T, u64, RoundingMode)` where `T` is signed, the `Float` is extreme, and the\n// quadruple is a valid input to `Float::shr_prec_round`.\npub fn float_signed_unsigned_rounding_mode_quadruple_gen_var_4<T: PrimitiveSigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_unsigned_rounding_mode_quadruple_gen_var_4,\n        &random_float_signed_unsigned_rounding_mode_quadruple_gen_var_4,\n        &special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_4,\n    )\n}\n\n// -- (Float, PrimitiveSigned, RoundingMode) --\n\n// All `(Float, T, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `Float::shl_round`.\npub fn float_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_rounding_mode_triple_gen_var_1,\n        &random_float_signed_rounding_mode_triple_gen_var_1,\n        &special_random_float_signed_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is signed, the `Float` is extreme, and the triple is a\n// valid input to `Float::shl_round`.\npub fn float_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_rounding_mode_triple_gen_var_2,\n        &random_float_signed_rounding_mode_triple_gen_var_2,\n        &special_random_float_signed_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is signed, the triple is a valid input to\n// `Float::shl_round`, and the `RoundingMode` is not `Exact`.\npub fn float_signed_rounding_mode_triple_gen_var_3<T: PrimitiveSigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_rounding_mode_triple_gen_var_3,\n        &random_float_signed_rounding_mode_triple_gen_var_3,\n        &special_random_float_signed_rounding_mode_triple_gen_var_3,\n    )\n}\n\npub fn float_signed_rounding_mode_triple_gen_var_3_rm() -> Generator<(\n    (rug::Float, i32, rug::float::Round),\n    (Float, i32, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            let ts = exhaustive_float_signed_rounding_mode_triple_gen_var_3();\n            float_t_rounding_mode_triple_rm(ts)\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_signed_rounding_mode_triple_gen_var_3(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_signed_rounding_mode_triple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `Float::shr_round`.\npub fn float_signed_rounding_mode_triple_gen_var_4<T: PrimitiveSigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_rounding_mode_triple_gen_var_4,\n        &random_float_signed_rounding_mode_triple_gen_var_4,\n        &special_random_float_signed_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is signed, the `Float` is extreme, and the triple is a\n// valid input to `Float::shr_round`.\npub fn float_signed_rounding_mode_triple_gen_var_5<T: PrimitiveSigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_rounding_mode_triple_gen_var_5,\n        &random_float_signed_rounding_mode_triple_gen_var_5,\n        &special_random_float_signed_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is signed, the triple is a valid input to\n// `Float::shr_round`, and the `RoundingMode` is not `Exact`.\npub fn float_signed_rounding_mode_triple_gen_var_6<T: PrimitiveSigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_signed_rounding_mode_triple_gen_var_6,\n        &random_float_signed_rounding_mode_triple_gen_var_6,\n        &special_random_float_signed_rounding_mode_triple_gen_var_6,\n    )\n}\n\npub fn float_signed_rounding_mode_triple_gen_var_6_rm() -> Generator<(\n    (rug::Float, i32, rug::float::Round),\n    (Float, i32, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            let ts = exhaustive_float_signed_rounding_mode_triple_gen_var_6();\n            float_t_rounding_mode_triple_rm(ts)\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_signed_rounding_mode_triple_gen_var_6(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_signed_rounding_mode_triple_gen_var_6(config),\n            )\n        },\n    )\n}\n\n// -- (Float, PrimitiveUnsigned) --\n\npub fn float_unsigned_pair_gen<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen,\n        &random_float_unsigned_pair_gen,\n        &special_random_float_unsigned_pair_gen,\n    )\n}\n\ntype GT<T> = Generator<((rug::Float, T), (Float, T))>;\npub fn float_unsigned_pair_gen_rm<T: PrimitiveUnsigned>() -> GT<T> {\n    Generator::new(\n        &|| float_primitive_int_pair_rm(exhaustive_float_unsigned_pair_gen()),\n        &|config| float_primitive_int_pair_rm(random_float_unsigned_pair_gen(config)),\n        &|config| float_primitive_int_pair_rm(special_random_float_unsigned_pair_gen(config)),\n    )\n}\n\n// All `(Float, T)` where `T` is unsigned, small, and positive.\npub fn float_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen_var_1,\n        &random_float_unsigned_pair_gen_var_1,\n        &special_random_float_unsigned_pair_gen_var_1,\n    )\n}\n\npub fn float_unsigned_pair_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Float, T), (Float, T))> {\n    Generator::new(\n        &|| float_primitive_int_pair_rm(exhaustive_float_unsigned_pair_gen_var_1()),\n        &|config| float_primitive_int_pair_rm(random_float_unsigned_pair_gen_var_1(config)),\n        &|config| float_primitive_int_pair_rm(special_random_float_unsigned_pair_gen_var_1(config)),\n    )\n}\n\n// All `(Float, T)` where `T` is small and unsigned.\npub fn float_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen_var_2,\n        &random_float_unsigned_pair_gen_var_2,\n        &special_random_float_unsigned_pair_gen_var_2,\n    )\n}\n\npub fn float_unsigned_pair_gen_var_2_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Float, T), (Float, T))> {\n    Generator::new(\n        &|| float_primitive_int_pair_rm(exhaustive_float_unsigned_pair_gen_var_2()),\n        &|config| float_primitive_int_pair_rm(random_float_unsigned_pair_gen_var_2(config)),\n        &|config| float_primitive_int_pair_rm(special_random_float_unsigned_pair_gen_var_2(config)),\n    )\n}\n\n// All `(Float, T)` where the Float is extreme and `T` is small and unsigned.\npub fn float_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen_var_3,\n        &random_float_unsigned_pair_gen_var_3,\n        &special_random_float_unsigned_pair_gen_var_3,\n    )\n}\n\n// All `(Float, T)` where the `Float` is extreme and the `T` is unsigned, small, and positive.\npub fn float_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen_var_4,\n        &random_float_unsigned_pair_gen_var_4,\n        &special_random_float_unsigned_pair_gen_var_4,\n    )\n}\n\n// All `(Float, T)` where the Float is extreme and `T` is unsigned.\npub fn float_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen_var_5,\n        &random_float_unsigned_pair_gen_var_5,\n        &special_random_float_unsigned_pair_gen_var_5,\n    )\n}\n\n// All `(Float, T)` where the `Float` is positive and the `T` is unsigned, small, and positive.\npub fn float_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen_var_6,\n        &random_float_unsigned_pair_gen_var_6,\n        &special_random_float_unsigned_pair_gen_var_6,\n    )\n}\n\n// All `(Float, T)` where the `Float` is finite and the `T` is unsigned, small, and positive.\npub fn float_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>() -> Generator<(Float, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_pair_gen_var_7,\n        &random_float_unsigned_pair_gen_var_7,\n        &special_random_float_unsigned_pair_gen_var_7,\n    )\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn float_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> Generator<(Float, T, T)> {\n    Generator::new(\n        &exhaustive_float_unsigned_unsigned_triple_gen,\n        &random_float_primitive_int_primitive_int_triple_gen,\n        &special_random_float_unsigned_unsigned_triple_gen,\n    )\n}\n\n// All `(Float, T, U)` where `T` and `U` are unsigned and the `U` is positive and small.\npub fn float_unsigned_unsigned_triple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Float, T, U)> {\n    Generator::new(\n        &exhaustive_float_unsigned_unsigned_triple_gen_var_1,\n        &random_float_unsigned_unsigned_triple_gen_var_1,\n        &special_random_float_unsigned_unsigned_triple_gen_var_1,\n    )\n}\n\npub fn float_unsigned_unsigned_triple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Float, T, u64), (Float, T, u64))> {\n    Generator::new(\n        &|| float_t_u_triple_rm(exhaustive_float_unsigned_unsigned_triple_gen_var_1()),\n        &|config| float_t_u_triple_rm(random_float_unsigned_unsigned_triple_gen_var_1(config)),\n        &|config| {\n            float_t_u_triple_rm(special_random_float_unsigned_unsigned_triple_gen_var_1(\n                config,\n            ))\n        },\n    )\n}\n\n// All `(Float, T, U)` where the `Float` is extreme, the `T` and `U` are unsigned, and the `U` is\n// positive and small.\npub fn float_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Float, T, U)> {\n    Generator::new(\n        &exhaustive_float_unsigned_unsigned_triple_gen_var_2,\n        &random_float_unsigned_unsigned_triple_gen_var_2,\n        &special_random_float_unsigned_unsigned_triple_gen_var_2,\n    )\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Float, T, u64, RoundingMode)` where `T` is unsigned and the quadruple is a valid input to\n// `Float::shl_prec_round`.\npub fn float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1,\n        &random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1,\n        &special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1,\n    )\n}\n\npub fn float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<(\n    (rug::Float, T, u64, rug::float::Round),\n    (Float, T, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_u_rounding_mode_quadruple_rm(\n                exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1(),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n    )\n}\n\n// All `(Float, T, u64, RoundingMode)` where `T` is unsigned, the `Float` is extreme, and the\n// quadruple is a valid input to `Float::shl_prec_round`.\npub fn float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2,\n        &random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2,\n        &special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2,\n    )\n}\n\n// All `(Float, T, u64, RoundingMode)` where `T` is unsigned and the quadruple is a valid input to\n// `Float::shr_prec_round`.\npub fn float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3,\n        &random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3,\n        &special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3,\n    )\n}\n\npub fn float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3_rm<T: PrimitiveUnsigned>()\n-> Generator<(\n    (rug::Float, T, u64, rug::float::Round),\n    (Float, T, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_u_rounding_mode_quadruple_rm(\n                exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n        &|config| {\n            float_t_u_rounding_mode_quadruple_rm(\n                special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, T, u64, RoundingMode)` where `T` is unsigned, the `Float` is extreme, and the\n// quadruple is a valid input to `Float::shr_prec_round`.\npub fn float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4,\n        &random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4,\n        &special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4,\n    )\n}\n\n// -- (Float, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.set_prec_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_1() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_1,\n        &random_float_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_1_rm() -> Generator<(\n    (rug::Float, u64, rug::float::Round),\n    (Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_1(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_1(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_1(config),\n            )\n        },\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.square_prec_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_2() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_2,\n        &random_float_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_2_rm() -> Generator<(\n    (rug::Float, u64, rug::float::Round),\n    (Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_2(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_2(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_2(config),\n            )\n        },\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.reciprocal_prec_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_3() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_3,\n        &random_float_unsigned_rounding_mode_triple_gen_var_3,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_3_rm() -> Generator<(\n    (rug::Float, u64, rug::float::Round),\n    (Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_3(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.set_prec_round`, and the\n// `Float`s are extreme.\npub fn float_unsigned_rounding_mode_triple_gen_var_4() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_4,\n        &random_float_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is unsigned and the triple is a valid input to\n// `Float::shl_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_5,\n        &random_float_unsigned_rounding_mode_triple_gen_var_5,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is unsigned, the `Float` is extreme, and the triple is a\n// valid input to `Float::shl_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_6,\n        &random_float_unsigned_rounding_mode_triple_gen_var_6,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_6,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is unsigned, the triple is a valid input to\n// `Float::shl_round`, and the `RoundingMode` is not `Exact`.\npub fn float_unsigned_rounding_mode_triple_gen_var_7<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_7,\n        &random_float_unsigned_rounding_mode_triple_gen_var_7,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_7,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_7_rm() -> Generator<(\n    (rug::Float, u32, rug::float::Round),\n    (Float, u32, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_7(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_7(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_7(config),\n            )\n        },\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is unsigned and the triple is a valid input to\n// `Float::shr_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_8<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_8,\n        &random_float_unsigned_rounding_mode_triple_gen_var_8,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_8,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is unsigned, the `Float` is extreme, and the triple is a\n// valid input to `Float::shr_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_9<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_9,\n        &random_float_unsigned_rounding_mode_triple_gen_var_9,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_9,\n    )\n}\n\n// All `(Float, T, RoundingMode)` where `T` is unsigned, the triple is a valid input to\n// `Float::shr_round`, and the `RoundingMode` is not `Exact`.\npub fn float_unsigned_rounding_mode_triple_gen_var_10<T: PrimitiveUnsigned>()\n-> Generator<(Float, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_10,\n        &random_float_unsigned_rounding_mode_triple_gen_var_10,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_10,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_10_rm() -> Generator<(\n    (rug::Float, u32, rug::float::Round),\n    (Float, u32, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_10(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_10(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_10(config),\n            )\n        },\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.square_prec_round`, where the\n// `Float` is extreme.\npub fn float_unsigned_rounding_mode_triple_gen_var_11() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_11,\n        &random_float_unsigned_rounding_mode_triple_gen_var_11,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_11,\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.reciprocal_prec_round`, where\n// the `Float` is extreme.\npub fn float_unsigned_rounding_mode_triple_gen_var_12() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_12,\n        &random_float_unsigned_rounding_mode_triple_gen_var_12,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_12,\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.sqrt_prec_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_13() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_13,\n        &random_float_unsigned_rounding_mode_triple_gen_var_13,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_13,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_13_rm() -> Generator<(\n    (rug::Float, u64, rug::float::Round),\n    (Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_13(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_13(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_13(config),\n            )\n        },\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.sqrt_prec_round`, where the\n// `Float` is extreme.\npub fn float_unsigned_rounding_mode_triple_gen_var_14() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_14,\n        &random_float_unsigned_rounding_mode_triple_gen_var_14,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_14,\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.reciprocal_sqrt_prec_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_15() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_15,\n        &random_float_unsigned_rounding_mode_triple_gen_var_15,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_15,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_15_rm() -> Generator<(\n    (rug::Float, u64, rug::float::Round),\n    (Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_15(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_15(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_15(config),\n            )\n        },\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.reciprocal_sqrt_prec_round`,\n// where the `Float` is extreme.\npub fn float_unsigned_rounding_mode_triple_gen_var_16() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_16,\n        &random_float_unsigned_rounding_mode_triple_gen_var_16,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_16,\n    )\n}\n\n// All `(Float, u64, RoundingMode)` where the `u64` is positive and the `Float` is positive.\npub fn float_unsigned_rounding_mode_triple_gen_var_17() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_17,\n        &random_float_unsigned_rounding_mode_triple_gen_var_17,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_17,\n    )\n}\n\n// All `(Float, u64, RoundingMode)` where the `u64` is positive and the `Float` is finite.\npub fn float_unsigned_rounding_mode_triple_gen_var_18() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_18,\n        &random_float_unsigned_rounding_mode_triple_gen_var_18,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_18,\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.ln_prec_round`.\npub fn float_unsigned_rounding_mode_triple_gen_var_19() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_19,\n        &random_float_unsigned_rounding_mode_triple_gen_var_19,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_19,\n    )\n}\n\npub fn float_unsigned_rounding_mode_triple_gen_var_19_rm() -> Generator<(\n    (rug::Float, u64, rug::float::Round),\n    (Float, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_t_rounding_mode_triple_rm(\n                exhaustive_float_unsigned_rounding_mode_triple_gen_var_19(),\n            )\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(random_float_unsigned_rounding_mode_triple_gen_var_19(\n                config,\n            ))\n        },\n        &|config| {\n            float_t_rounding_mode_triple_rm(\n                special_random_float_unsigned_rounding_mode_triple_gen_var_19(config),\n            )\n        },\n    )\n}\n\n// All `(Float, u64, RoundingMode)` that are valid inputs to `Float.ln_prec_round`, where the\n// `Float` is extreme.\npub fn float_unsigned_rounding_mode_triple_gen_var_20() -> Generator<(Float, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_unsigned_rounding_mode_triple_gen_var_20,\n        &random_float_unsigned_rounding_mode_triple_gen_var_20,\n        &special_random_float_unsigned_rounding_mode_triple_gen_var_20,\n    )\n}\n\n// -- (Float, Rational) --\n\npub fn float_rational_pair_gen() -> Generator<(Float, Rational)> {\n    Generator::new(\n        &exhaustive_float_rational_pair_gen,\n        &random_float_rational_pair_gen,\n        &special_random_float_rational_pair_gen,\n    )\n}\n\npub fn float_rational_pair_gen_rm() -> Generator<((rug::Float, rug::Rational), (Float, Rational))> {\n    Generator::new(\n        &|| float_rational_pair_rm(exhaustive_float_rational_pair_gen()),\n        &|config| float_rational_pair_rm(random_float_rational_pair_gen(config)),\n        &|config| float_rational_pair_rm(special_random_float_rational_pair_gen(config)),\n    )\n}\n\n// All pairs of finite Floats and Rationals.\npub fn float_rational_pair_gen_var_1() -> Generator<(Float, Rational)> {\n    Generator::new(\n        &exhaustive_float_rational_pair_gen_var_1,\n        &random_float_rational_pair_gen_var_1,\n        &special_random_float_rational_pair_gen_var_1,\n    )\n}\n\n// All pairs of Floats and Rationals where the Float is extreme.\npub fn float_rational_pair_gen_var_2() -> Generator<(Float, Rational)> {\n    Generator::new(\n        &exhaustive_float_rational_pair_gen_var_2,\n        &random_float_rational_pair_gen_var_2,\n        &special_random_float_rational_pair_gen_var_2,\n    )\n}\n\n// -- (Float, Rational, PrimitiveUnsigned) --\n\n// All `(Float, Rational, T)` where `T` is unsigned, small, and positive.\npub fn float_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Float, Rational, T)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_triple_gen_var_1,\n        &random_float_rational_unsigned_triple_gen_var_1,\n        &special_random_float_rational_unsigned_triple_gen_var_1,\n    )\n}\n\npub fn float_rational_unsigned_triple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Float, rug::Rational, T), (Float, Rational, T))> {\n    Generator::new(\n        &|| {\n            let ef = exhaustive_float_rational_unsigned_triple_gen_var_1();\n            float_rational_anything_triple_rm(ef)\n        },\n        &|config| {\n            float_rational_anything_triple_rm(random_float_rational_unsigned_triple_gen_var_1(\n                config,\n            ))\n        },\n        &|config| {\n            float_rational_anything_triple_rm(\n                special_random_float_rational_unsigned_triple_gen_var_1(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, T)` where the `Float` is extreme and the `T` is unsigned, small, and\n// positive.\npub fn float_rational_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Float, Rational, T)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_triple_gen_var_2,\n        &random_float_rational_unsigned_triple_gen_var_2,\n        &special_random_float_rational_unsigned_triple_gen_var_2,\n    )\n}\n\n// -- (Float, Rational, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::add_rational_prec_round`.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n    )\n}\n\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_1_rm() -> Generator<(\n    (rug::Float, rug::Rational, u64, rug::float::Round),\n    (Float, Rational, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_1(),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                random_float_rational_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_1(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::sub_rational_prec_round`.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_2()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_2,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_2,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_2,\n    )\n}\n\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_2_rm() -> Generator<(\n    (rug::Float, rug::Rational, u64, rug::float::Round),\n    (Float, Rational, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_2(),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                random_float_rational_unsigned_rounding_mode_quadruple_gen_var_2(config),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_2(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::mul_rational_prec_round`.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_3()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_3,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_3,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_3,\n    )\n}\n\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_3_rm() -> Generator<(\n    (rug::Float, rug::Rational, u64, rug::float::Round),\n    (Float, Rational, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                random_float_rational_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::div_prec_round_rational`.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_4()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_4,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_4,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_4,\n    )\n}\n\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_4_rm() -> Generator<(\n    (rug::Float, rug::Rational, u64, rug::float::Round),\n    (Float, Rational, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_4(),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                random_float_rational_unsigned_rounding_mode_quadruple_gen_var_4(config),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_4(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::rational_div_float_prec_round` (with the first two arguments reversed).\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_5()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_5,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_5,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_5,\n    )\n}\n\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_5_rm() -> Generator<(\n    (rug::Float, rug::Rational, u64, rug::float::Round),\n    (Float, Rational, u64, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_5(),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                random_float_rational_unsigned_rounding_mode_quadruple_gen_var_5(config),\n            )\n        },\n        &|config| {\n            float_rational_anything_rounding_mode_quadruple_rm(\n                special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_5(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::add_rational_prec_round`, where the `Float` is extreme.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_6()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_6,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_6,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_6,\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::sub_rational_prec_round`, where the `Float` is extreme.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_7()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_7,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_7,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_7,\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::mul_rational_prec_round`, where the `Float` is extreme.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_8()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_8,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_8,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_8,\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::div_rational_prec_round`, where the `Float` is extreme.\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_9()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_9,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_9,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_9,\n    )\n}\n\n// All `(Float, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::rational_div_float_prec_round`, where the `Float` is extreme (with the first two\n// arguments reversed).\npub fn float_rational_unsigned_rounding_mode_quadruple_gen_var_10()\n-> Generator<(Float, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rational_unsigned_rounding_mode_quadruple_gen_var_10,\n        &random_float_rational_unsigned_rounding_mode_quadruple_gen_var_10,\n        &special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_10,\n    )\n}\n\n// -- (Float, Rational, Rational) --\n\npub fn float_rational_rational_triple_gen() -> Generator<(Float, Rational, Rational)> {\n    Generator::new(\n        &exhaustive_float_rational_rational_triple_gen,\n        &random_float_rational_rational_triple_gen,\n        &special_random_float_rational_rational_triple_gen,\n    )\n}\n\n// -- (Float, Rational, RoundingMode) --\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::add_round_rational`.\npub fn float_rational_rounding_mode_triple_gen_var_1() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_1,\n        &random_float_rational_rounding_mode_triple_gen_var_1,\n        &special_random_float_rational_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::sub_round_rational`.\npub fn float_rational_rounding_mode_triple_gen_var_2() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_2,\n        &random_float_rational_rounding_mode_triple_gen_var_2,\n        &special_random_float_rational_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// All `(Float, Rational, RoundingMode)`, excluding those with `Exact`.\npub fn float_rational_rounding_mode_triple_gen_var_3_rm() -> Generator<(\n    (rug::Float, rug::Rational, rug::float::Round),\n    (Float, Rational, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_rational_rounding_mode_triple_rm(\n                exhaustive_float_rational_rounding_mode_triple_gen_var_3(),\n            )\n        },\n        &|config| {\n            float_rational_rounding_mode_triple_rm(\n                random_float_rational_rounding_mode_triple_gen_var_3(config),\n            )\n        },\n        &|config| {\n            float_rational_rounding_mode_triple_rm(\n                special_random_float_rational_rounding_mode_triple_gen_var_3(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::mul_round_rational`.\npub fn float_rational_rounding_mode_triple_gen_var_4() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_4,\n        &random_float_rational_rounding_mode_triple_gen_var_4,\n        &special_random_float_rational_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::div_round_rational`.\npub fn float_rational_rounding_mode_triple_gen_var_5() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_5,\n        &random_float_rational_rounding_mode_triple_gen_var_5,\n        &special_random_float_rational_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::rational_div_float_round`\n// (with the first two arguments reversed).\npub fn float_rational_rounding_mode_triple_gen_var_6() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_6,\n        &random_float_rational_rounding_mode_triple_gen_var_6,\n        &special_random_float_rational_rounding_mode_triple_gen_var_6,\n    )\n}\n\npub fn float_rational_rounding_mode_triple_gen_var_6_rm() -> Generator<(\n    (rug::Float, rug::Rational, rug::float::Round),\n    (Float, Rational, RoundingMode),\n)> {\n    Generator::new(\n        &|| {\n            float_rational_rounding_mode_triple_rm(\n                exhaustive_float_rational_rounding_mode_triple_gen_var_6(),\n            )\n        },\n        &|config| {\n            float_rational_rounding_mode_triple_rm(\n                random_float_rational_rounding_mode_triple_gen_var_6(config),\n            )\n        },\n        &|config| {\n            float_rational_rounding_mode_triple_rm(\n                special_random_float_rational_rounding_mode_triple_gen_var_6(config),\n            )\n        },\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::add_round_rational`, where\n// the `Float` is extreme.\npub fn float_rational_rounding_mode_triple_gen_var_7() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_7,\n        &random_float_rational_rounding_mode_triple_gen_var_7,\n        &special_random_float_rational_rounding_mode_triple_gen_var_7,\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::sub_round_rational`, where\n// the `Float` is extreme.\npub fn float_rational_rounding_mode_triple_gen_var_8() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_8,\n        &random_float_rational_rounding_mode_triple_gen_var_8,\n        &special_random_float_rational_rounding_mode_triple_gen_var_8,\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::mul_round_rational`, where\n// the `Float` is extreme.\npub fn float_rational_rounding_mode_triple_gen_var_9() -> Generator<(Float, Rational, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_9,\n        &random_float_rational_rounding_mode_triple_gen_var_9,\n        &special_random_float_rational_rounding_mode_triple_gen_var_9,\n    )\n}\n\ntype FRR = Generator<(Float, Rational, RoundingMode)>;\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::div_round_rational`, where\n// the `Float` is extreme.\npub fn float_rational_rounding_mode_triple_gen_var_10() -> FRR {\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_10,\n        &random_float_rational_rounding_mode_triple_gen_var_10,\n        &special_random_float_rational_rounding_mode_triple_gen_var_10,\n    )\n}\n\n// All `(Float, Rational, RoundingMode)` that are valid inputs to `Float::rational_div_float_round`,\n// where the `Float` is extreme (with the first two arguments reversed).\npub fn float_rational_rounding_mode_triple_gen_var_11() -> FRR {\n    Generator::new(\n        &exhaustive_float_rational_rounding_mode_triple_gen_var_11,\n        &random_float_rational_rounding_mode_triple_gen_var_11,\n        &special_random_float_rational_rounding_mode_triple_gen_var_11,\n    )\n}\n\n// -- (Float, RoundingMode) --\n\npub fn float_rounding_mode_pair_gen() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen,\n        &random_float_rounding_mode_pair_gen,\n        &special_random_float_rounding_mode_pair_gen,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `Natural::rounding_from`.\npub fn float_rounding_mode_pair_gen_var_1() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_1,\n        &random_float_rounding_mode_pair_gen_var_1,\n        &special_random_float_rounding_mode_pair_gen_var_1,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `Integer::rounding_from`.\npub fn float_rounding_mode_pair_gen_var_2() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_2,\n        &random_float_rounding_mode_pair_gen_var_2,\n        &special_random_float_rounding_mode_pair_gen_var_2,\n    )\n}\n\n// All `(Float, RoundingMode)` where the float is finite and nonzero.\npub fn float_rounding_mode_pair_gen_var_3() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_3,\n        &random_float_rounding_mode_pair_gen_var_3,\n        &special_random_float_rounding_mode_pair_gen_var_3,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `T::rounding_from`, where `T` is unsigned.\ntype GT2 = Generator<(Float, RoundingMode)>;\n#[allow(clippy::type_repetition_in_bounds)]\npub fn float_rounding_mode_pair_gen_var_4<T: PrimitiveUnsigned>() -> GT2\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_4::<T>,\n        &random_float_rounding_mode_pair_gen_var_4::<T>,\n        &special_random_float_rounding_mode_pair_gen_var_4::<T>,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `T::rounding_from`, where `T` is signed.\n#[allow(clippy::type_repetition_in_bounds)]\npub fn float_rounding_mode_pair_gen_var_5<T: PrimitiveSigned>() -> Generator<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_5::<T>,\n        &random_float_rounding_mode_pair_gen_var_5::<T>,\n        &special_random_float_rounding_mode_pair_gen_var_5::<T>,\n    )\n}\n\n// All `(T, RoundingMode)` that are valid inputs to `T::rounding_from`, where `T` is a primitive\n// float.\n#[allow(clippy::type_repetition_in_bounds)]\npub fn float_rounding_mode_pair_gen_var_6<T: PrimitiveFloat>() -> Generator<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_6::<T>,\n        &random_float_rounding_mode_pair_gen_var_6::<T>,\n        &special_random_float_rounding_mode_pair_gen_var_6::<T>,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `square_round`.\npub fn float_rounding_mode_pair_gen_var_7() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_7,\n        &random_float_rounding_mode_pair_gen_var_7,\n        &special_random_float_rounding_mode_pair_gen_var_7,\n    )\n}\n\npub fn float_rounding_mode_pair_gen_var_7_rm()\n-> Generator<((rug::Float, rug::float::Round), (Float, RoundingMode))> {\n    Generator::new(\n        &|| float_rounding_mode_pair_rm(exhaustive_float_rounding_mode_pair_gen_var_7()),\n        &|config| float_rounding_mode_pair_rm(random_float_rounding_mode_pair_gen_var_7(config)),\n        &|config| {\n            float_rounding_mode_pair_rm(special_random_float_rounding_mode_pair_gen_var_7(config))\n        },\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `square_round`, where the `Float` has a\n// precision less than `Limb::WIDTH`.\npub fn float_rounding_mode_pair_gen_var_8() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_8,\n        &random_float_rounding_mode_pair_gen_var_8,\n        &special_random_float_rounding_mode_pair_gen_var_8,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `square_round`, where the `Float` has\n// precision `Limb::WIDTH`.\npub fn float_rounding_mode_pair_gen_var_9() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_9,\n        &random_float_rounding_mode_pair_gen_var_9,\n        &special_random_float_rounding_mode_pair_gen_var_9,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `square_round`, where the `Float` has a\n// precision greater than `Limb::WIDTH` and less than `Limb::WIDTH` * 2.\npub fn float_rounding_mode_pair_gen_var_10() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_10,\n        &random_float_rounding_mode_pair_gen_var_10,\n        &special_random_float_rounding_mode_pair_gen_var_10,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `square_round`, where the `Float` has\n// precision `Limb::WIDTH` * 2.\npub fn float_rounding_mode_pair_gen_var_11() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_11,\n        &random_float_rounding_mode_pair_gen_var_11,\n        &special_random_float_rounding_mode_pair_gen_var_11,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `square_round`, where the `Float` has a\n// precision greater than `Limb::WIDTH` * 2 and less than `Limb::WIDTH` * 3.\npub fn float_rounding_mode_pair_gen_var_12() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_12,\n        &random_float_rounding_mode_pair_gen_var_12,\n        &special_random_float_rounding_mode_pair_gen_var_12,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_round`.\npub fn float_rounding_mode_pair_gen_var_13() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_13,\n        &random_float_rounding_mode_pair_gen_var_13,\n        &special_random_float_rounding_mode_pair_gen_var_13,\n    )\n}\n\npub fn float_rounding_mode_pair_gen_var_13_rm()\n-> Generator<((rug::Float, rug::float::Round), (Float, RoundingMode))> {\n    Generator::new(\n        &|| float_rounding_mode_pair_rm(exhaustive_float_rounding_mode_pair_gen_var_13()),\n        &|config| float_rounding_mode_pair_rm(random_float_rounding_mode_pair_gen_var_13(config)),\n        &|config| {\n            float_rounding_mode_pair_rm(special_random_float_rounding_mode_pair_gen_var_13(config))\n        },\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_round`, where the `Float` has a\n// precision less than `Limb::WIDTH`.\npub fn float_rounding_mode_pair_gen_var_14() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_14,\n        &random_float_rounding_mode_pair_gen_var_14,\n        &special_random_float_rounding_mode_pair_gen_var_14,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_round`, where the `Float` has\n// precision `Limb::WIDTH`.\npub fn float_rounding_mode_pair_gen_var_15() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_15,\n        &random_float_rounding_mode_pair_gen_var_15,\n        &special_random_float_rounding_mode_pair_gen_var_15,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_round`, where the `Float` has a\n// precision greater than `Limb::WIDTH` and less than `Limb::WIDTH` * 2.\npub fn float_rounding_mode_pair_gen_var_16() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_16,\n        &random_float_rounding_mode_pair_gen_var_16,\n        &special_random_float_rounding_mode_pair_gen_var_16,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_round`, where the `Float` has a\n// precision greater than `Limb::WIDTH` * 2.\npub fn float_rounding_mode_pair_gen_var_17() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_17,\n        &random_float_rounding_mode_pair_gen_var_17,\n        &special_random_float_rounding_mode_pair_gen_var_17,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `T::rounding_from`, where `T` is unsigned\n// and the `Float` is extreme.\n#[allow(clippy::type_repetition_in_bounds)]\npub fn float_rounding_mode_pair_gen_var_18<T: PrimitiveUnsigned>() -> GT2\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_18::<T>,\n        &random_float_rounding_mode_pair_gen_var_18::<T>,\n        &special_random_float_rounding_mode_pair_gen_var_18::<T>,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `T::rounding_from`, where `T` is signed and\n// the `Float` is extreme.\n#[allow(clippy::type_repetition_in_bounds)]\npub fn float_rounding_mode_pair_gen_var_19<T: PrimitiveSigned>() -> Generator<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_19::<T>,\n        &random_float_rounding_mode_pair_gen_var_19::<T>,\n        &special_random_float_rounding_mode_pair_gen_var_19::<T>,\n    )\n}\n\n// All `(T, RoundingMode)` that are valid inputs to `T::rounding_from`, where `T` is a primitive\n// float and the `Float` is extreme.\n#[allow(clippy::type_repetition_in_bounds)]\npub fn float_rounding_mode_pair_gen_var_20<T: PrimitiveFloat>() -> Generator<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_20::<T>,\n        &random_float_rounding_mode_pair_gen_var_20::<T>,\n        &special_random_float_rounding_mode_pair_gen_var_20::<T>,\n    )\n}\n\n// All `(T, RoundingMode)` where the `Float` is extreme.\npub fn float_rounding_mode_pair_gen_var_21() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_21,\n        &random_float_rounding_mode_pair_gen_var_21,\n        &special_random_float_rounding_mode_pair_gen_var_21,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `square_round`, where the `Float` is\n// extreme.\npub fn float_rounding_mode_pair_gen_var_22() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_22,\n        &random_float_rounding_mode_pair_gen_var_22,\n        &special_random_float_rounding_mode_pair_gen_var_22,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_round`, where the `Float` is\n// extreme.\npub fn float_rounding_mode_pair_gen_var_23() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_23,\n        &random_float_rounding_mode_pair_gen_var_23,\n        &special_random_float_rounding_mode_pair_gen_var_23,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `sqrt_round`.\npub fn float_rounding_mode_pair_gen_var_24() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_24,\n        &random_float_rounding_mode_pair_gen_var_24,\n        &special_random_float_rounding_mode_pair_gen_var_24,\n    )\n}\n\npub fn float_rounding_mode_pair_gen_var_24_rm()\n-> Generator<((rug::Float, rug::float::Round), (Float, RoundingMode))> {\n    Generator::new(\n        &|| float_rounding_mode_pair_rm(exhaustive_float_rounding_mode_pair_gen_var_24()),\n        &|config| float_rounding_mode_pair_rm(random_float_rounding_mode_pair_gen_var_24(config)),\n        &|config| {\n            float_rounding_mode_pair_rm(special_random_float_rounding_mode_pair_gen_var_24(config))\n        },\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `sqrt_round`, where the `Float` has a\n// precision less than `Limb::WIDTH`.\npub fn float_rounding_mode_pair_gen_var_25() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_25,\n        &random_float_rounding_mode_pair_gen_var_25,\n        &special_random_float_rounding_mode_pair_gen_var_25,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `sqrt_round`, where the `Float` has\n// precision `Limb::WIDTH`.\npub fn float_rounding_mode_pair_gen_var_26() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_26,\n        &random_float_rounding_mode_pair_gen_var_26,\n        &special_random_float_rounding_mode_pair_gen_var_26,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `sqrt_round`, where the `Float` has a\n// precision greater than `Limb::WIDTH` and less than `Limb::WIDTH` * 2.\npub fn float_rounding_mode_pair_gen_var_27() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_27,\n        &random_float_rounding_mode_pair_gen_var_27,\n        &special_random_float_rounding_mode_pair_gen_var_27,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `sqrt_round`, where the `Float` has a\n// precision greater than `Limb::WIDTH` * 2.\npub fn float_rounding_mode_pair_gen_var_28() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_28,\n        &random_float_rounding_mode_pair_gen_var_28,\n        &special_random_float_rounding_mode_pair_gen_var_28,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `sqrt_round`, where the `Float` is extreme.\npub fn float_rounding_mode_pair_gen_var_29() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_29,\n        &random_float_rounding_mode_pair_gen_var_29,\n        &special_random_float_rounding_mode_pair_gen_var_29,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_sqrt_round`.\npub fn float_rounding_mode_pair_gen_var_30() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_30,\n        &random_float_rounding_mode_pair_gen_var_30,\n        &special_random_float_rounding_mode_pair_gen_var_30,\n    )\n}\n\npub fn float_rounding_mode_pair_gen_var_30_rm()\n-> Generator<((rug::Float, rug::float::Round), (Float, RoundingMode))> {\n    Generator::new(\n        &|| float_rounding_mode_pair_rm(exhaustive_float_rounding_mode_pair_gen_var_30()),\n        &|config| float_rounding_mode_pair_rm(random_float_rounding_mode_pair_gen_var_30(config)),\n        &|config| {\n            float_rounding_mode_pair_rm(special_random_float_rounding_mode_pair_gen_var_30(config))\n        },\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `reciprocal_sqrt_round`, where the `Float`\n// is extreme.\npub fn float_rounding_mode_pair_gen_var_31() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_31,\n        &random_float_rounding_mode_pair_gen_var_31,\n        &special_random_float_rounding_mode_pair_gen_var_31,\n    )\n}\n\n// All `(Float, RoundingMode)` where the `Float` is positive.\npub fn float_rounding_mode_pair_gen_var_32() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_32,\n        &random_float_rounding_mode_pair_gen_var_32,\n        &special_random_float_rounding_mode_pair_gen_var_32,\n    )\n}\n\n// All `(Float, RoundingMode)` where the `Float` is finite.\npub fn float_rounding_mode_pair_gen_var_33() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_33,\n        &random_float_rounding_mode_pair_gen_var_33,\n        &special_random_float_rounding_mode_pair_gen_var_33,\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `ln_round`.\npub fn float_rounding_mode_pair_gen_var_34() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_34,\n        &random_float_rounding_mode_pair_gen_var_34,\n        &special_random_float_rounding_mode_pair_gen_var_34,\n    )\n}\n\npub fn float_rounding_mode_pair_gen_var_34_rm()\n-> Generator<((rug::Float, rug::float::Round), (Float, RoundingMode))> {\n    Generator::new(\n        &|| float_rounding_mode_pair_rm(exhaustive_float_rounding_mode_pair_gen_var_34()),\n        &|config| float_rounding_mode_pair_rm(random_float_rounding_mode_pair_gen_var_34(config)),\n        &|config| {\n            float_rounding_mode_pair_rm(special_random_float_rounding_mode_pair_gen_var_34(config))\n        },\n    )\n}\n\n// All `(Float, RoundingMode)` that are valid inputs to `ln_round`, where the `Float` is extreme.\npub fn float_rounding_mode_pair_gen_var_35() -> Generator<(Float, RoundingMode)> {\n    Generator::new(\n        &exhaustive_float_rounding_mode_pair_gen_var_35,\n        &random_float_rounding_mode_pair_gen_var_35,\n        &special_random_float_rounding_mode_pair_gen_var_35,\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 and 2 are in malachite-nz.\n\n// All `(Integer, u64, RoundingMode)` that are valid inputs to `Float::from_integer_prec_round`.\npub fn integer_unsigned_rounding_mode_triple_gen_var_3() -> Generator<(Integer, u64, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_integer_unsigned_rounding_mode_triple_gen_var_3,\n        &random_integer_unsigned_rounding_mode_triple_gen_var_3,\n        &special_random_integer_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// All `(Integer, u64, RoundingMode)` that are valid inputs to `Float::from_integer_prec_round`,\n// excluding those with `Exact`.\npub fn integer_unsigned_rounding_mode_triple_gen_var_4() -> Generator<(Integer, u64, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_integer_unsigned_rounding_mode_triple_gen_var_4,\n        &random_integer_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_integer_unsigned_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// var 5 is in malachite-nz.\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\n// All `(T, u64, RoundingMode)` that are valid inputs to `from_primitive_float_prec_round`.\npub fn primitive_float_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveFloat>()\n-> Generator<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    Generator::new(\n        &exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_3,\n        &random_primitive_float_unsigned_rounding_mode_triple_gen_var_3,\n        &special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// All `(T, u64, RoundingMode)` that are valid inputs to `from_primitive_float_prec_round`, except\n// for those including `Exact`.\npub fn primitive_float_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveFloat>()\n-> Generator<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    Generator::new(\n        &exhaustive_primitive_float_unsigned_rounding_mode_triple_gen_var_4,\n        &random_primitive_float_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\n// var 1 is in malachite-nz\n\n// All `(Natural, u64, RoundingMode)` that are valid inputs to `Float::from_natural_prec_round`.\npub fn natural_unsigned_rounding_mode_triple_gen_var_2() -> Generator<(Natural, u64, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_natural_unsigned_rounding_mode_triple_gen_var_2,\n        &random_natural_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_natural_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// All `(Natural, u64, RoundingMode)` that are valid inputs to `Float::from_natural_prec_round`,\n// excluding those with `Exact`.\npub fn natural_unsigned_rounding_mode_triple_gen_var_3() -> Generator<(Natural, u64, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_natural_unsigned_rounding_mode_triple_gen_var_3,\n        &random_natural_unsigned_rounding_mode_triple_gen_var_3,\n        &special_random_natural_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\n// All `(T, u64, RoundingMode)` that are valid inputs to `Float::from_signed_prec_round`.\npub fn signed_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveSigned>()\n-> Generator<(T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_3,\n        &random_signed_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_signed_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// All `(T, u64, RoundingMode)` that are valid inputs to `Float::from_signed_prec_round`, excluding\n// those with `Exact`.\npub fn signed_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveSigned>()\n-> Generator<(T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_4,\n        &random_signed_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_signed_unsigned_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// All `(i64, u64, RoundingMode)` that are valid inputs to `Float::power_of_2_prec_round`, where the\n// `u64` is small.\npub fn signed_unsigned_rounding_mode_triple_gen_var_5() -> Generator<(i64, u64, RoundingMode)> {\n    Generator::new_no_special(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_5,\n        &random_signed_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// All `(i64, u64, RoundingMode)` that are valid inputs to `Float::power_of_2_prec_round`.\npub fn signed_unsigned_rounding_mode_triple_gen_var_6() -> Generator<(i64, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_signed_unsigned_rounding_mode_triple_gen_var_5,\n        &random_signed_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_signed_unsigned_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 4 are in malachite-base.\n\n// All `(T, u64, RoundingMode)` that are valid inputs to `Float::from_unsigned_prec_round`\npub fn unsigned_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> Generator<(T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_6,\n        &random_unsigned_unsigned_rounding_mode_triple_gen_var_3,\n        &special_random_unsigned_unsigned_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// All `(T, u64, RoundingMode)` that are valid inputs to `Float::from_unsigned_prec_round`,\n// excluding those with `Exact`.\npub fn unsigned_unsigned_rounding_mode_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> Generator<(T, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_unsigned_unsigned_rounding_mode_triple_gen_var_7,\n        &random_unsigned_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_unsigned_unsigned_rounding_mode_triple_gen_var_6,\n    )\n}\n\n// -- (Rational, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Rational, u64, RoundingMode)` that are valid inputs to `Float::from_rational_prec_round`.\ntype GT3 = Generator<(Rational, u64, RoundingMode)>;\npub fn rational_unsigned_rounding_mode_triple_gen_var_1() -> GT3 {\n    Generator::new(\n        &exhaustive_rational_unsigned_rounding_mode_triple_gen_var_1,\n        &random_rational_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_rational_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// All `(Rational, u64, RoundingMode)` that are valid inputs to `Float::from_rational_prec_round`,\n// excluding those with `Exact`.\npub fn rational_unsigned_rounding_mode_triple_gen_var_2() -> GT3 {\n    Generator::new(\n        &exhaustive_rational_unsigned_rounding_mode_triple_gen_var_2,\n        &random_rational_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_rational_unsigned_rounding_mode_triple_gen_var_3,\n    )\n}\n\n// All `(Rational, u64, RoundingMode)` that are valid inputs to `Float::sqrt_rational_prec_round`.\npub fn rational_unsigned_rounding_mode_triple_gen_var_3() -> GT3 {\n    Generator::new(\n        &exhaustive_rational_unsigned_rounding_mode_triple_gen_var_3,\n        &random_rational_unsigned_rounding_mode_triple_gen_var_3,\n        &special_random_rational_unsigned_rounding_mode_triple_gen_var_4,\n    )\n}\n\n// All `(Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::reciprocal_sqrt_rational_prec_round`.\npub fn rational_unsigned_rounding_mode_triple_gen_var_4() -> GT3 {\n    Generator::new(\n        &exhaustive_rational_unsigned_rounding_mode_triple_gen_var_4,\n        &random_rational_unsigned_rounding_mode_triple_gen_var_4,\n        &special_random_rational_unsigned_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// All `(Rational, u64, RoundingMode)` that are valid inputs to `Float::from_rational_prec_round`,\n// and the `Rational` is non-negative.\npub fn rational_unsigned_rounding_mode_triple_gen_var_5() -> GT3 {\n    Generator::new(\n        &exhaustive_rational_unsigned_rounding_mode_triple_gen_var_5,\n        &random_rational_unsigned_rounding_mode_triple_gen_var_5,\n        &special_random_rational_unsigned_rounding_mode_triple_gen_var_6,\n    )\n}\n\n// All `(Rational, u64, RoundingMode)` that are valid inputs to `Float::ln_rational_prec_round`.\npub fn rational_unsigned_rounding_mode_triple_gen_var_6() -> GT3 {\n    Generator::new(\n        &exhaustive_rational_unsigned_rounding_mode_triple_gen_var_6,\n        &random_rational_unsigned_rounding_mode_triple_gen_var_6,\n        &special_random_rational_unsigned_rounding_mode_triple_gen_var_7,\n    )\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Rational, Rational, u64, RoundingMode)` that are valid inputs to\n// `Float::agm_rational_prec_round`.\npub fn rational_rational_unsigned_rounding_mode_quadruple_gen_var_1()\n-> Generator<(Rational, Rational, u64, RoundingMode)> {\n    Generator::new(\n        &exhaustive_rational_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n        &random_rational_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n        &special_random_rational_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\n// vars 1 through 5 are in malachite-q.\n\n// All `(Rational, u64, RoundingMode)` that are valid inputs to `Float::from_rational_prec_round`,\n// with precision fixed at 1.\npub fn rational_rounding_mode_pair_gen_var_6() -> Generator<(Rational, RoundingMode)> {\n    Generator::new(\n        &exhaustive_rational_rounding_mode_pair_gen_var_6,\n        &random_rational_rounding_mode_pair_gen_var_6,\n        &special_random_rational_rounding_mode_pair_gen_var_6,\n    )\n}\n\npub mod common;\npub mod exhaustive;\npub mod random;\npub mod special_random;\n"
  },
  {
    "path": "malachite-float/src/test_util/generators/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse crate::random::{\n    RandomPositiveFiniteFloats, random_finite_floats, random_floats,\n    random_non_negative_finite_floats, random_nonzero_finite_floats, random_positive_finite_floats,\n    random_positive_floats_with_precision,\n};\nuse crate::test_util::extra_variadic::{\n    random_quadruples, random_quadruples_xxyz, random_triples, random_triples_from_single,\n    random_triples_xxy, random_triples_xyy,\n};\nuse crate::test_util::generators::exhaustive::{\n    add_prec_round_valid, add_rational_prec_round_valid, add_rational_round_valid, add_round_valid,\n    agm_prec_round_valid, agm_rational_prec_round_valid, agm_round_valid, div_prec_round_valid,\n    div_rational_prec_round_valid, div_rational_round_valid, div_round_valid,\n    from_primitive_float_prec_round_valid, integer_rounding_from_float_valid, ln_prec_round_valid,\n    ln_rational_prec_round_valid, ln_round_valid, mul_prec_round_valid,\n    mul_rational_prec_round_valid, mul_rational_round_valid, mul_round_valid,\n    natural_rounding_from_float_valid, rational_div_float_prec_round_valid,\n    rational_div_float_round_valid, reciprocal_prec_round_valid, reciprocal_round_valid,\n    reciprocal_sqrt_prec_round_valid, reciprocal_sqrt_rational_prec_round_valid,\n    reciprocal_sqrt_round_valid, set_prec_round_valid, shl_prec_round_valid, shl_round_valid,\n    shr_prec_round_valid, shr_round_valid, signed_rounding_from_float_valid, sqrt_prec_round_valid,\n    sqrt_rational_prec_round_valid, sqrt_round_valid, square_prec_round_valid, square_round_valid,\n    sub_prec_round_valid, sub_rational_prec_round_valid, sub_rational_round_valid, sub_round_valid,\n    unsigned_rounding_from_float_valid,\n};\nuse malachite_base::bools::random::{\n    RandomBools, WeightedRandomBools, random_bools, weighted_random_bools,\n};\nuse malachite_base::iterators::{WithSpecialValues, with_special_values};\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, NegModPowerOf2};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, geometric_random_natural_signeds,\n    geometric_random_positive_unsigneds, geometric_random_signeds,\n    geometric_random_unsigned_inclusive_range, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::{\n    RandomUnsignedInclusiveRange, random_primitive_ints, random_unsigned_inclusive_range,\n    special_random_primitive_floats,\n};\nuse malachite_base::orderings::random::random_orderings;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::random::random_rounding_modes;\nuse malachite_base::test_util::generators::common::{GenConfig, It, reshape_2_1_to_3};\nuse malachite_base::tuples::random::{random_pairs, random_pairs_from_single};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::random_integers;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::{\n    RandomNaturals, UniformRandomNaturalRange, random_naturals, random_positive_naturals,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::random::{random_non_negative_rationals, random_rationals};\nuse std::cmp::Ordering;\nuse std::collections::HashMap;\n\n// -- Float --\n\npub fn random_float_gen(config: &GenConfig) -> It<Float> {\n    Box::new(random_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\npub fn random_float_gen_var_1(config: &GenConfig) -> It<Float> {\n    Box::new(random_positive_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n    ))\n}\n\npub fn random_float_gen_var_2(config: &GenConfig) -> It<Float> {\n    Box::new(\n        random_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_precision_n\", 64),\n            config.get_or(\"mean_precision_d\", 1),\n            config.get_or(\"mean_zero_p_n\", 1),\n            config.get_or(\"mean_zero_p_d\", 64),\n        )\n        .filter(|f| !f.is_nan()),\n    )\n}\n\npub fn random_float_gen_var_3(config: &GenConfig) -> It<Float> {\n    Box::new(random_nonzero_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n    ))\n}\n\npub fn random_float_gen_var_4(config: &GenConfig) -> It<Float> {\n    Box::new(random_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\npub fn random_float_gen_var_5(config: &GenConfig) -> It<Float> {\n    Box::new(random_non_negative_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\npub fn random_float_gen_var_6(config: &GenConfig) -> It<Float> {\n    random_floats_with_precision_inclusive_range(EXAMPLE_SEED, config, 1, Limb::WIDTH - 1)\n}\n\npub fn random_float_gen_var_7(config: &GenConfig) -> It<Float> {\n    Box::new(random_positive_floats_with_precision(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        Limb::WIDTH,\n    ))\n}\n\npub fn random_float_gen_var_8(config: &GenConfig) -> It<Float> {\n    random_floats_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        Limb::WIDTH + 1,\n        (Limb::WIDTH << 1) - 1,\n    )\n}\n\npub fn random_float_gen_var_9(config: &GenConfig) -> It<Float> {\n    Box::new(random_positive_floats_with_precision(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        Limb::WIDTH << 1,\n    ))\n}\n\npub fn random_float_gen_var_10(config: &GenConfig) -> It<Float> {\n    random_floats_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        (Limb::WIDTH << 1) + 1,\n        Limb::WIDTH * 3 - 1,\n    )\n}\n\npub fn random_float_gen_var_11(config: &GenConfig) -> It<Float> {\n    random_floats_with_precision_inclusive_range_to_infinity(\n        EXAMPLE_SEED,\n        config,\n        (Limb::WIDTH << 1) + 1,\n    )\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct RandomExtremePositiveFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) exponents: GeometricRandomNaturalValues<i32>,\n    pub(crate) exponent_modes: RandomBools,\n    pub(crate) xs: I,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomExtremePositiveFiniteFloats<I> {\n    type Item = Float;\n\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        let precision = x.significant_bits();\n        assert_ne!(precision, 0);\n        let exponent_offset = self.exponents.next().unwrap();\n        let exp = if self.exponent_modes.next().unwrap() {\n            Float::MAX_EXPONENT - exponent_offset\n        } else {\n            Float::MIN_EXPONENT + exponent_offset\n        };\n        Some(Float(Finite {\n            sign: true,\n            exponent: exp,\n            precision,\n            significand: x << precision.neg_mod_power_of_2(Limb::LOG_WIDTH),\n        }))\n    }\n}\n\nfn random_extreme_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomExtremePositiveFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomExtremePositiveFiniteFloats {\n        exponents: geometric_random_natural_signeds(\n            seed.fork(\"exponents\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        exponent_modes: random_bools(seed.fork(\"exponent_modes\")),\n        xs: random_positive_naturals(\n            seed.fork(\"significands\"),\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct RandomExtremeNonNegativeFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) bs: WeightedRandomBools,\n    pub(crate) xs: RandomExtremePositiveFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomExtremeNonNegativeFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        if self.bs.next().unwrap() {\n            Some(Float::ZERO)\n        } else {\n            self.xs.next()\n        }\n    }\n}\n\n#[inline]\nfn random_extreme_non_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomExtremeNonNegativeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomExtremeNonNegativeFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: random_extreme_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct RandomExtremeNonzeroFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) bs: RandomBools,\n    pub(crate) xs: RandomExtremePositiveFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomExtremeNonzeroFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() { x } else { -x })\n    }\n}\n\n#[inline]\nfn random_extreme_nonzero_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomExtremeNonzeroFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomExtremeNonzeroFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: random_extreme_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct RandomExtremeFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) bs: RandomBools,\n    pub(crate) xs: RandomExtremeNonNegativeFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomExtremeFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() { x } else { -x })\n    }\n}\n\n#[inline]\nfn random_extreme_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomExtremeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomExtremeFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: random_extreme_non_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn random_extreme_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<RandomExtremeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>>>\n{\n    with_special_values(\n        seed,\n        vec![Float::INFINITY, Float::NEGATIVE_INFINITY, Float::NAN],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            random_extreme_finite_floats(\n                seed_2,\n                mean_sci_exponent_abs_numerator,\n                mean_sci_exponent_abs_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n                mean_special_p_numerator,\n                mean_special_p_denominator,\n            )\n        },\n    )\n}\n\npub fn random_float_gen_var_12(config: &GenConfig) -> It<Float> {\n    Box::new(random_extreme_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\npub fn random_float_gen_var_13(config: &GenConfig) -> It<Float> {\n    Box::new(random_extreme_nonzero_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n    ))\n}\n\npub fn random_float_gen_var_14(config: &GenConfig) -> It<Float> {\n    Box::new(\n        random_extreme_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_precision_n\", 64),\n            config.get_or(\"mean_precision_d\", 1),\n            config.get_or(\"mean_zero_p_n\", 1),\n            config.get_or(\"mean_zero_p_d\", 64),\n        )\n        .filter(|f| !f.is_nan()),\n    )\n}\n\npub fn random_float_gen_var_15(config: &GenConfig) -> It<Float> {\n    Box::new(\n        random_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_precision_n\", 64),\n            config.get_or(\"mean_precision_d\", 1),\n            config.get_or(\"mean_zero_p_n\", 1),\n            config.get_or(\"mean_zero_p_d\", 64),\n        )\n        .filter(|x| *x > 0u32),\n    )\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct RandomMixedExtremePositiveFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) exponents: GeometricRandomNaturalValues<i32>,\n    pub(crate) exponent_modes: RandomUnsignedInclusiveRange<u8>,\n    pub(crate) xs: I,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomMixedExtremePositiveFiniteFloats<I> {\n    type Item = Float;\n\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        let precision = x.significant_bits();\n        assert_ne!(precision, 0);\n        let exponent_offset = self.exponents.next().unwrap();\n        let exp = match self.exponent_modes.next().unwrap() {\n            0 => exponent_offset,\n            1 => -exponent_offset,\n            2 => Float::MAX_EXPONENT - exponent_offset,\n            3 => Float::MIN_EXPONENT + exponent_offset,\n            _ => unreachable!(),\n        };\n        Some(Float(Finite {\n            sign: true,\n            exponent: exp,\n            precision,\n            significand: x << precision.neg_mod_power_of_2(Limb::LOG_WIDTH),\n        }))\n    }\n}\n\nfn random_mixed_extreme_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomMixedExtremePositiveFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomMixedExtremePositiveFiniteFloats {\n        exponents: geometric_random_natural_signeds(\n            seed.fork(\"exponents\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        exponent_modes: random_unsigned_inclusive_range(seed.fork(\"exponent_modes\"), 0, 3),\n        xs: random_positive_naturals(\n            seed.fork(\"significands\"),\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct RandomMixedExtremeNonNegativeFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) bs: WeightedRandomBools,\n    pub(crate) xs: RandomMixedExtremePositiveFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomMixedExtremeNonNegativeFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        if self.bs.next().unwrap() {\n            Some(Float::ZERO)\n        } else {\n            self.xs.next()\n        }\n    }\n}\n\n#[inline]\nfn random_mixed_extreme_non_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomMixedExtremeNonNegativeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomMixedExtremeNonNegativeFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: random_mixed_extreme_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct _RandomMixedExtremeNonzeroFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) bs: RandomBools,\n    pub(crate) xs: RandomMixedExtremePositiveFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for _RandomMixedExtremeNonzeroFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() { x } else { -x })\n    }\n}\n\n#[inline]\nfn _random_mixed_extreme_nonzero_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> _RandomMixedExtremeNonzeroFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    _RandomMixedExtremeNonzeroFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: random_mixed_extreme_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[derive(Clone, Debug)]\npub(crate) struct RandomMixedExtremeFiniteFloats<I: Iterator<Item = Natural>> {\n    pub(crate) bs: RandomBools,\n    pub(crate) xs: RandomMixedExtremeNonNegativeFiniteFloats<I>,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomMixedExtremeFiniteFloats<I> {\n    type Item = Float;\n\n    #[inline]\n    fn next(&mut self) -> Option<Float> {\n        let x = self.xs.next().unwrap();\n        Some(if self.bs.next().unwrap() { x } else { -x })\n    }\n}\n\n#[inline]\nfn random_mixed_extreme_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomMixedExtremeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomMixedExtremeFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: random_mixed_extreme_non_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn random_mixed_extreme_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<\n    RandomMixedExtremeFiniteFloats<RandomNaturals<GeometricRandomNaturalValues<u64>>>,\n> {\n    with_special_values(\n        seed,\n        vec![Float::INFINITY, Float::NEGATIVE_INFINITY, Float::NAN],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            random_mixed_extreme_finite_floats(\n                seed_2,\n                mean_sci_exponent_abs_numerator,\n                mean_sci_exponent_abs_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n                mean_special_p_numerator,\n                mean_special_p_denominator,\n            )\n        },\n    )\n}\n\nstruct RandomFloatsWithPrecisionUniformInclusiveRange {\n    seed: Seed,\n    mean_exponent_n: u64,\n    mean_exponent_d: u64,\n    precisions: Box<dyn Iterator<Item = u64>>,\n    floats: HashMap<u64, RandomPositiveFiniteFloats<UniformRandomNaturalRange>>,\n}\n\nimpl Iterator for RandomFloatsWithPrecisionUniformInclusiveRange {\n    type Item = Float;\n\n    fn next(&mut self) -> Option<Float> {\n        let prec = self.precisions.next().unwrap();\n        let xs = self\n            .floats\n            .entry(prec)\n            .or_insert(random_positive_floats_with_precision(\n                self.seed.fork(&prec.to_string()),\n                self.mean_exponent_n,\n                self.mean_exponent_d,\n                prec,\n            ));\n        Some(xs.next().unwrap())\n    }\n}\n\nfn random_floats_with_precision_inclusive_range(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n    prec_hi: u64,\n) -> It<Float> {\n    Box::new(RandomFloatsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        precisions: Box::new(random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            prec_hi,\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nfn random_floats_with_precision_inclusive_range_to_infinity(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n) -> It<Float> {\n    let mean_precision = Rational::from_unsigneds(\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 64),\n    ) + Rational::from(prec_lo);\n    let (n, d) = mean_precision.into_numerator_and_denominator();\n    Box::new(RandomFloatsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        precisions: Box::new(geometric_random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            u64::MAX,\n            u64::exact_from(&n),\n            u64::exact_from(&d),\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nstruct RandomFloatPairsWithPrecisionUniformInclusiveRange {\n    seed: Seed,\n    mean_exponent_n: u64,\n    mean_exponent_d: u64,\n    precisions: Box<dyn Iterator<Item = u64>>,\n    floats: HashMap<u64, RandomPositiveFiniteFloats<UniformRandomNaturalRange>>,\n}\n\nimpl Iterator for RandomFloatPairsWithPrecisionUniformInclusiveRange {\n    type Item = (Float, Float);\n\n    fn next(&mut self) -> Option<(Float, Float)> {\n        let prec = self.precisions.next().unwrap();\n        let xs = self\n            .floats\n            .entry(prec)\n            .or_insert(random_positive_floats_with_precision(\n                self.seed.fork(&prec.to_string()),\n                self.mean_exponent_n,\n                self.mean_exponent_d,\n                prec,\n            ));\n        Some((xs.next().unwrap(), xs.next().unwrap()))\n    }\n}\n\nstruct RandomFloatPairsWithPrecisions {\n    seed: Seed,\n    mean_exponent_n: u64,\n    mean_exponent_d: u64,\n    precisions: Box<dyn Iterator<Item = (u64, u64)>>,\n    floats: HashMap<u64, RandomPositiveFiniteFloats<UniformRandomNaturalRange>>,\n}\n\nimpl Iterator for RandomFloatPairsWithPrecisions {\n    type Item = (Float, Float);\n\n    fn next(&mut self) -> Option<(Float, Float)> {\n        let precs = self.precisions.next().unwrap();\n        let xs = self\n            .floats\n            .entry(precs.0)\n            .or_insert(random_positive_floats_with_precision(\n                self.seed.fork(&precs.0.to_string()),\n                self.mean_exponent_n,\n                self.mean_exponent_d,\n                precs.0,\n            ));\n        let x = xs.next().unwrap();\n        let ys = self\n            .floats\n            .entry(precs.1)\n            .or_insert(random_positive_floats_with_precision(\n                self.seed.fork(&precs.1.to_string()),\n                self.mean_exponent_n,\n                self.mean_exponent_d,\n                precs.1,\n            ));\n        let y = ys.next().unwrap();\n        Some((x, y))\n    }\n}\n\nfn random_float_pairs_with_precision_inclusive_range(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n    prec_hi: u64,\n) -> It<(Float, Float)> {\n    Box::new(RandomFloatPairsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        precisions: Box::new(random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            prec_hi,\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nfn random_float_pairs_with_precision_inclusive_range_to_infinity(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n) -> It<(Float, Float)> {\n    let mean_precision = Rational::from_unsigneds(\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 64),\n    ) + Rational::from(prec_lo);\n    let (n, d) = mean_precision.into_numerator_and_denominator();\n    Box::new(RandomFloatPairsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        precisions: Box::new(geometric_random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            u64::MAX,\n            u64::exact_from(&n),\n            u64::exact_from(&d),\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nfn random_float_pairs_with_precisions(\n    seed: Seed,\n    config: &GenConfig,\n    precisions: It<(u64, u64)>,\n) -> It<(Float, Float)> {\n    Box::new(RandomFloatPairsWithPrecisions {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        precisions,\n        floats: HashMap::new(),\n    })\n}\n\n// -- (Float, Float) --\n\npub fn random_float_pair_gen(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(random_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    )))\n}\n\npub fn random_float_pair_gen_var_1(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(random_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    )))\n}\n\npub fn random_float_pair_gen_var_2(config: &GenConfig) -> It<(Float, Float)> {\n    random_float_pairs_with_precision_inclusive_range(EXAMPLE_SEED, config, 1, Limb::WIDTH - 1)\n}\n\npub fn random_float_pair_gen_var_3(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(\n        random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            Limb::WIDTH,\n        ),\n    ))\n}\n\npub fn random_float_pair_gen_var_4(config: &GenConfig) -> It<(Float, Float)> {\n    random_float_pairs_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        Limb::WIDTH + 1,\n        (Limb::WIDTH << 1) - 1,\n    )\n}\n\npub fn random_float_pair_gen_var_5(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(\n        random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            Limb::WIDTH << 1,\n        ),\n    ))\n}\n\npub fn random_float_pair_gen_var_6(config: &GenConfig) -> It<(Float, Float)> {\n    random_float_pairs_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        (Limb::WIDTH << 1) + 1,\n        Limb::WIDTH * 3 - 1,\n    )\n}\n\npub fn random_float_pair_gen_var_7(config: &GenConfig) -> It<(Float, Float)> {\n    random_float_pairs_with_precision_inclusive_range_to_infinity(\n        EXAMPLE_SEED,\n        config,\n        Limb::WIDTH * 3,\n    )\n}\n\npub fn random_float_pair_gen_var_8(config: &GenConfig) -> It<(Float, Float)> {\n    random_float_pairs_with_precisions(\n        EXAMPLE_SEED.fork(\"abc\"),\n        config,\n        Box::new(random_pairs(\n            EXAMPLE_SEED.fork(\"precisions\"),\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    1,\n                    Limb::WIDTH,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n            },\n        )),\n    )\n}\n\npub fn random_float_pair_gen_var_9(config: &GenConfig) -> It<(Float, Float)> {\n    random_float_pairs_with_precisions(\n        EXAMPLE_SEED.fork(\"abc\"),\n        config,\n        Box::new(random_pairs(\n            EXAMPLE_SEED.fork(\"precisions\"),\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n                .map(|p: u64| p + Limb::WIDTH)\n            },\n        )),\n    )\n}\n\npub fn random_float_pair_gen_var_10(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(random_mixed_extreme_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    )))\n}\n\n// -- (Float, Float, Float) --\n\npub fn random_float_triple_gen(config: &GenConfig) -> It<(Float, Float, Float)> {\n    Box::new(random_triples_from_single(random_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    )))\n}\n\n// -- (Float, Float, Integer) --\n\npub fn random_float_float_integer_triple_gen(config: &GenConfig) -> It<(Float, Float, Integer)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, Natural) --\n\npub fn random_float_float_natural_triple_gen(config: &GenConfig) -> It<(Float, Float, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, PrimitiveFloat) --\n\npub fn random_float_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, PrimitiveInt) --\n\npub fn random_float_float_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| random_primitive_ints(seed),\n    ))\n}\n\n// -- (Float, Float, PrimitiveUnsigned) --\n\npub fn random_float_float_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_float_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_mixed_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| agm_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_float_unsigned_rounding_mode_quadruple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| agm_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Float, Float, Rational) --\n\npub fn random_float_float_rational_triple_gen(config: &GenConfig) -> It<(Float, Float, Rational)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, RoundingMode) --\n\npub fn random_float_float_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(seed, config, 1, Limb::WIDTH - 1)\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH << 1,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH * 3,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(seed, config, 1, Limb::WIDTH - 1)\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_12(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_13(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH << 1,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_14(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_15(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH * 3,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_16(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_17(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(seed, config, 1, Limb::WIDTH - 1)\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_18(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_19(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_20(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH << 1,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_21(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_22(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH * 3,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_23(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_24(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(seed, config, 1, Limb::WIDTH - 1)\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_25(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_26(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_27(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precisions(\n                    seed.fork(\"abc\"),\n                    config,\n                    Box::new(random_pairs(\n                        seed.fork(\"precisions\"),\n                        &|seed_2| {\n                            geometric_random_positive_unsigneds(\n                                seed_2,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                        },\n                        &|seed_2| {\n                            geometric_random_unsigned_inclusive_range(\n                                seed_2,\n                                1,\n                                Limb::WIDTH,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                        },\n                    )),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_28(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_float_pairs_with_precisions(\n                    seed.fork(\"abc\"),\n                    config,\n                    Box::new(random_pairs(\n                        seed.fork(\"precisions\"),\n                        &|seed_2| {\n                            geometric_random_positive_unsigneds(\n                                seed_2,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                        },\n                        &|seed_2| {\n                            geometric_random_positive_unsigneds(\n                                seed_2,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                            .map(|p: u64| p + Limb::WIDTH)\n                        },\n                    )),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_29(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_30(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_31(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_32(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_33(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| agm_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_float_rounding_mode_triple_gen_var_34(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| agm_round_valid(x, y, *rm)),\n    )\n}\n\n// -- (Float, Integer) --\n\npub fn random_float_integer_pair_gen(config: &GenConfig) -> It<(Float, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_integer_pair_gen_var_1(config: &GenConfig) -> It<(Float, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_integer_pair_gen_var_2(config: &GenConfig) -> It<(Float, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Integer, Integer) --\n\npub fn random_float_integer_integer_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Integer, Integer)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Natural) --\n\npub fn random_float_natural_pair_gen(config: &GenConfig) -> It<(Float, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_natural_pair_gen_var_1(config: &GenConfig) -> It<(Float, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_natural_pair_gen_var_2(config: &GenConfig) -> It<(Float, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Natural, Natural) --\n\npub fn random_float_natural_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Natural, Natural)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Ordering) --\n\npub fn random_float_ordering_pair_gen(config: &GenConfig) -> It<(Float, Ordering)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_orderings,\n    ))\n}\n\npub fn random_float_ordering_pair_gen_var_1(config: &GenConfig) -> It<(Float, Ordering)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_orderings,\n    ))\n}\n\n// -- (Float, PrimitiveFloat) --\n\npub fn random_float_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n    ))\n}\n\npub fn random_float_primitive_float_pair_gen_var_1<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveFloat, PrimitiveFloat) --\n\npub fn random_float_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveInt, PrimitiveInt) --\n\npub fn random_float_primitive_int_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Float, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| random_primitive_ints(seed),\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn random_float_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_signed_unsigned_triple_gen_var_2<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_float_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveSigned) --\n\npub fn random_float_signed_pair_gen<T: PrimitiveSigned>(config: &GenConfig) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// TODO use ranges\npub fn random_float_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n            )\n            .map(|mut x| {\n                if let Float(Finite { exponent, .. }) = &mut x {\n                    *exponent = 1;\n                }\n                x\n            })\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_signed_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_signed_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_signed_pair_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_float_signed_unsigned_rounding_mode_quadruple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn random_float_signed_unsigned_rounding_mode_quadruple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn random_float_signed_unsigned_rounding_mode_quadruple_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn random_float_signed_unsigned_rounding_mode_quadruple_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\n// -- (Float, PrimitiveSigned, RoundingMode) --\n\npub fn random_float_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_signed_rounding_mode_triple_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_signed_rounding_mode_triple_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_signed_rounding_mode_triple_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_signed_rounding_mode_triple_gen_var_6<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\n// -- (Float, PrimitiveUnsigned) --\n\npub fn random_float_unsigned_pair_gen<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\npub fn random_float_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\npub fn random_float_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n            .filter(|x| *x > 0u32)\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\n// -- (Float, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| set_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| square_prec_round_valid(x, p, rm, false)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_prec_round_valid(x, p, rm, false)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| set_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| square_prec_round_valid(x, p, rm, true)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_12(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_prec_round_valid(x, p, rm, true)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_13(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_14(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_15(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_16(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_17(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n            .filter(|x| *x > 0u32)\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_18(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_19(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| ln_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_float_unsigned_rounding_mode_triple_gen_var_20(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| ln_prec_round_valid(x, p, rm)),\n    )\n}\n\n// -- (Float, Rational) --\n\npub fn random_float_rational_pair_gen(config: &GenConfig) -> It<(Float, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_rational_pair_gen_var_1(config: &GenConfig) -> It<(Float, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_rational_pair_gen_var_2(config: &GenConfig) -> It<(Float, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Rational, PrimitiveUnsigned) --\n\npub fn random_float_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Rational, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_float_rational_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Rational, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Rational, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| rational_div_float_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn random_float_rational_unsigned_rounding_mode_quadruple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| rational_div_float_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Float, Rational, Rational) --\n\npub fn random_float_rational_rational_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Rational, Rational)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Rational, RoundingMode) --\n\npub fn random_float_rational_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n    ))\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| rational_div_float_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn random_float_rational_rounding_mode_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| rational_div_float_round_valid(x, y, *rm)),\n    )\n}\n\n// -- (Float, RoundingMode) --\n\npub fn random_float_rounding_mode_pair_gen(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_float_rounding_mode_pair_gen_var_1(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| natural_rounding_from_float_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_2(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| integer_rounding_from_float_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_3(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_nonzero_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_float_rounding_mode_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| unsigned_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_float_rounding_mode_pair_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| signed_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_float_rounding_mode_pair_gen_var_6<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| *rm != Exact || T::convertible_from(f)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_7(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_8(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| random_floats_with_precision_inclusive_range(seed, config, 1, Limb::WIDTH - 1),\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_9(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_10(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_11(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH << 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_12(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_13(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_14(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| random_floats_with_precision_inclusive_range(seed, config, 1, Limb::WIDTH - 1),\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_15(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_16(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_17(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_float_rounding_mode_pair_gen_var_18<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| unsigned_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_float_rounding_mode_pair_gen_var_19<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| signed_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_float_rounding_mode_pair_gen_var_20<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| *rm != Exact || T::convertible_from(f)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_21(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_float_rounding_mode_pair_gen_var_22(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, true)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_23(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, true)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_24(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_25(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| random_floats_with_precision_inclusive_range(seed, config, 1, Limb::WIDTH - 1),\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_26(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    Limb::WIDTH,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_27(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_28(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_29(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_30(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_31(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_32(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n            .filter(|x| *x > 0u32)\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_float_rounding_mode_pair_gen_var_33(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_float_rounding_mode_pair_gen_var_34(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| ln_round_valid(f, *rm)),\n    )\n}\n\npub fn random_float_rounding_mode_pair_gen_var_35(config: &GenConfig) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| ln_round_valid(f, *rm)),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-nz.\n\npub fn random_integer_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Integer, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == 0u32 || n.significant_bits() - n.trailing_zeros().unwrap() <= prec\n        }),\n    )\n}\n\npub fn random_integer_unsigned_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Integer, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\n// var 1 is in malachite-nz\n\npub fn random_natural_unsigned_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == 0u32 || n.significant_bits() - n.trailing_zeros().unwrap() <= prec\n        }),\n    )\n}\n\npub fn random_natural_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Natural, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\npub fn random_primitive_float_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_primitive_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, p, rm)| from_primitive_float_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn random_primitive_float_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_signed_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == T::ZERO || n.significant_bits() - n.trailing_zeros() <= prec\n        }),\n    )\n}\n\npub fn random_signed_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<T>,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\npub fn random_signed_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(i64, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(pow, _, rm)| {\n            rm != Exact\n                || (Float::MIN_EXPONENT..=Float::MAX_EXPONENT)\n                    .contains(&i32::saturating_from(pow).saturating_add(1))\n        }),\n    )\n}\n\npub fn random_signed_unsigned_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(i64, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints,\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(pow, _, rm)| {\n            rm != Exact\n                || (Float::MIN_EXPONENT..=Float::MAX_EXPONENT)\n                    .contains(&i32::saturating_from(pow).saturating_add(1))\n        }),\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\npub fn random_unsigned_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == T::ZERO || n.significant_bits() - n.trailing_zeros() <= prec\n        }),\n    )\n}\n\npub fn random_unsigned_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_ints::<T>,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\n// -- (Rational, PrimitiveUnsigned, RoundingMode) --\n\n// var 1 is in malachite-nz\n\npub fn random_rational_unsigned_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2()\n                    && n.numerator_ref().significant_bits() <= prec\n        }),\n    )\n}\n\npub fn random_rational_unsigned_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\npub fn random_rational_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| sqrt_rational_prec_round_valid(n, prec, rm)),\n    )\n}\n\npub fn random_rational_unsigned_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| reciprocal_sqrt_rational_prec_round_valid(n, prec, rm)),\n    )\n}\n\npub fn random_rational_unsigned_rounding_mode_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_non_negative_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2()\n                    && n.numerator_ref().significant_bits() <= prec\n        }),\n    )\n}\n\npub fn random_rational_unsigned_rounding_mode_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| ln_rational_prec_round_valid(n, prec, rm)),\n    )\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_rational_rational_unsigned_rounding_mode_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| agm_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\n// vars 1 through 5 are in malachite-q.\n\npub fn random_rational_rounding_mode_pair_gen_var_6(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2() && n.numerator_ref().significant_bits() <= 1\n        }),\n    )\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/generators/special_random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Float;\nuse crate::InnerFloat::Finite;\nuse crate::random::{\n    RandomPositiveFiniteFloats, striped_random_finite_floats, striped_random_floats,\n    striped_random_non_negative_finite_floats, striped_random_nonzero_finite_floats,\n    striped_random_positive_finite_floats, striped_random_positive_floats_with_precision,\n};\nuse crate::test_util::extra_variadic::{\n    random_quadruples, random_quadruples_xxyz, random_triples, random_triples_from_single,\n    random_triples_xxy, random_triples_xyy,\n};\nuse crate::test_util::generators::exhaustive::{\n    add_prec_round_valid, add_rational_prec_round_valid, add_rational_round_valid, add_round_valid,\n    agm_prec_round_valid, agm_rational_prec_round_valid, agm_round_valid, div_prec_round_valid,\n    div_rational_prec_round_valid, div_rational_round_valid, div_round_valid,\n    from_primitive_float_prec_round_valid, integer_rounding_from_float_valid, ln_prec_round_valid,\n    ln_rational_prec_round_valid, ln_round_valid, mul_prec_round_valid,\n    mul_rational_prec_round_valid, mul_rational_round_valid, mul_round_valid,\n    natural_rounding_from_float_valid, rational_div_float_prec_round_valid,\n    rational_div_float_round_valid, reciprocal_prec_round_valid, reciprocal_round_valid,\n    reciprocal_sqrt_prec_round_valid, reciprocal_sqrt_rational_prec_round_valid,\n    reciprocal_sqrt_round_valid, set_prec_round_valid, shl_prec_round_valid, shl_round_valid,\n    shr_prec_round_valid, shr_round_valid, signed_rounding_from_float_valid, sqrt_prec_round_valid,\n    sqrt_rational_prec_round_valid, sqrt_round_valid, square_prec_round_valid, square_round_valid,\n    sub_prec_round_valid, sub_rational_prec_round_valid, sub_rational_round_valid, sub_round_valid,\n    unsigned_rounding_from_float_valid,\n};\nuse crate::test_util::generators::random::{\n    RandomExtremeFiniteFloats, RandomExtremeNonNegativeFiniteFloats,\n    RandomExtremeNonzeroFiniteFloats, RandomExtremePositiveFiniteFloats,\n    RandomMixedExtremeFiniteFloats, RandomMixedExtremeNonNegativeFiniteFloats,\n    RandomMixedExtremePositiveFiniteFloats,\n};\nuse malachite_base::bools::random::{random_bools, weighted_random_bools};\nuse malachite_base::iterators::{WithSpecialValues, with_special_values};\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, geometric_random_natural_signeds,\n    geometric_random_positive_unsigneds, geometric_random_signeds,\n    geometric_random_unsigned_inclusive_range, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::striped::{striped_random_signeds, striped_random_unsigneds};\nuse malachite_base::num::random::{random_primitive_floats, random_unsigned_inclusive_range};\nuse malachite_base::orderings::random::random_orderings;\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::random::random_rounding_modes;\nuse malachite_base::test_util::generators::common::{GenConfig, It, reshape_2_1_to_3};\nuse malachite_base::tuples::random::{random_pairs, random_pairs_from_single};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::striped_random_integers;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::{\n    StripedRandomNaturalInclusiveRange, StripedRandomNaturals, striped_random_naturals,\n    striped_random_positive_naturals,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::random::{striped_random_non_negative_rationals, striped_random_rationals};\nuse std::cmp::Ordering;\nuse std::collections::HashMap;\n\n// -- Float --\n\npub fn special_random_float_gen(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\npub fn special_random_float_gen_var_1(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_positive_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n    ))\n}\n\npub fn special_random_float_gen_var_2(config: &GenConfig) -> It<Float> {\n    Box::new(\n        striped_random_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_precision_n\", 64),\n            config.get_or(\"mean_precision_d\", 1),\n            config.get_or(\"mean_zero_p_n\", 1),\n            config.get_or(\"mean_zero_p_d\", 64),\n        )\n        .filter(|f| !f.is_nan()),\n    )\n}\n\npub fn special_random_float_gen_var_3(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_nonzero_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n    ))\n}\n\npub fn special_random_float_gen_var_4(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\npub fn special_random_float_gen_var_5(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_non_negative_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\npub fn special_random_float_gen_var_6(config: &GenConfig) -> It<Float> {\n    striped_random_floats_with_precision_inclusive_range(EXAMPLE_SEED, config, 1, Limb::WIDTH - 1)\n}\n\npub fn special_random_float_gen_var_7(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_positive_floats_with_precision(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        Limb::WIDTH,\n    ))\n}\n\npub fn special_random_float_gen_var_8(config: &GenConfig) -> It<Float> {\n    striped_random_floats_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        Limb::WIDTH + 1,\n        (Limb::WIDTH << 1) - 1,\n    )\n}\n\npub fn special_random_float_gen_var_9(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_positive_floats_with_precision(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        Limb::WIDTH << 1,\n    ))\n}\n\npub fn special_random_float_gen_var_10(config: &GenConfig) -> It<Float> {\n    striped_random_floats_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        (Limb::WIDTH << 1) + 1,\n        Limb::WIDTH * 3 - 1,\n    )\n}\n\npub fn special_random_float_gen_var_11(config: &GenConfig) -> It<Float> {\n    striped_random_floats_with_precision_inclusive_range_to_infinity(\n        EXAMPLE_SEED,\n        config,\n        (Limb::WIDTH << 1) + 1,\n    )\n}\n\nfn striped_random_extreme_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomExtremePositiveFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomExtremePositiveFiniteFloats {\n        exponents: geometric_random_natural_signeds(\n            seed.fork(\"exponents\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        exponent_modes: random_bools(seed.fork(\"exponent_modes\")),\n        xs: striped_random_positive_naturals(\n            seed.fork(\"significands\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn striped_random_extreme_non_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomExtremeNonNegativeFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>>\n{\n    RandomExtremeNonNegativeFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: striped_random_extreme_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn striped_random_extreme_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomExtremeFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomExtremeFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: striped_random_extreme_non_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn striped_random_extreme_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<\n    RandomExtremeFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>>,\n> {\n    with_special_values(\n        seed,\n        vec![Float::INFINITY, Float::NEGATIVE_INFINITY, Float::NAN],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            striped_random_extreme_finite_floats(\n                seed_2,\n                mean_sci_exponent_abs_numerator,\n                mean_sci_exponent_abs_denominator,\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n                mean_special_p_numerator,\n                mean_special_p_denominator,\n            )\n        },\n    )\n}\n\npub fn special_random_float_gen_var_12(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_extreme_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    ))\n}\n\n#[inline]\nfn striped_random_extreme_nonzero_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomExtremeNonzeroFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomExtremeNonzeroFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: striped_random_extreme_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\npub fn special_random_float_gen_var_13(config: &GenConfig) -> It<Float> {\n    Box::new(striped_random_extreme_nonzero_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n    ))\n}\n\npub fn special_random_float_gen_var_14(config: &GenConfig) -> It<Float> {\n    Box::new(\n        striped_random_extreme_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_precision_n\", 64),\n            config.get_or(\"mean_precision_d\", 1),\n            config.get_or(\"mean_zero_p_n\", 1),\n            config.get_or(\"mean_zero_p_d\", 64),\n        )\n        .filter(|f| !f.is_nan()),\n    )\n}\n\npub fn special_random_float_gen_var_15(config: &GenConfig) -> It<Float> {\n    Box::new(\n        striped_random_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_precision_n\", 64),\n            config.get_or(\"mean_precision_d\", 1),\n            config.get_or(\"mean_zero_p_n\", 1),\n            config.get_or(\"mean_zero_p_d\", 64),\n        )\n        .filter(|x| *x > 0u32),\n    )\n}\n\ntype GRNV = GeometricRandomNaturalValues<u64>;\n\nfn striped_random_mixed_extreme_positive_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n) -> RandomMixedExtremePositiveFiniteFloats<StripedRandomNaturals<GRNV>> {\n    RandomMixedExtremePositiveFiniteFloats {\n        exponents: geometric_random_natural_signeds(\n            seed.fork(\"exponents\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n        ),\n        exponent_modes: random_unsigned_inclusive_range(seed.fork(\"exponent_modes\"), 0, 3),\n        xs: striped_random_positive_naturals(\n            seed.fork(\"significands\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn striped_random_mixed_extreme_non_negative_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomMixedExtremeNonNegativeFiniteFloats<\n    StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n> {\n    RandomMixedExtremeNonNegativeFiniteFloats {\n        bs: weighted_random_bools(seed.fork(\"bs\"), zero_p_numerator, zero_p_denominator),\n        xs: striped_random_mixed_extreme_positive_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn striped_random_mixed_extreme_finite_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n) -> RandomMixedExtremeFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomMixedExtremeFiniteFloats {\n        bs: random_bools(seed.fork(\"bs\")),\n        xs: striped_random_mixed_extreme_non_negative_finite_floats(\n            seed.fork(\"xs\"),\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n    }\n}\n\n#[inline]\nfn striped_random_mixed_extreme_floats(\n    seed: Seed,\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n) -> WithSpecialValues<\n    RandomMixedExtremeFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>>,\n> {\n    with_special_values(\n        seed,\n        vec![Float::INFINITY, Float::NEGATIVE_INFINITY, Float::NAN],\n        mean_special_p_numerator,\n        mean_special_p_denominator,\n        &|seed_2| {\n            striped_random_mixed_extreme_finite_floats(\n                seed_2,\n                mean_sci_exponent_abs_numerator,\n                mean_sci_exponent_abs_denominator,\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n                mean_precision_numerator,\n                mean_precision_denominator,\n                mean_special_p_numerator,\n                mean_special_p_denominator,\n            )\n        },\n    )\n}\n\nstruct StripedRandomFloatsWithPrecisionUniformInclusiveRange {\n    seed: Seed,\n    mean_exponent_n: u64,\n    mean_exponent_d: u64,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n    precisions: Box<dyn Iterator<Item = u64>>,\n    floats: HashMap<u64, RandomPositiveFiniteFloats<StripedRandomNaturalInclusiveRange>>,\n}\n\nimpl Iterator for StripedRandomFloatsWithPrecisionUniformInclusiveRange {\n    type Item = Float;\n\n    fn next(&mut self) -> Option<Float> {\n        let prec = self.precisions.next().unwrap();\n        let xs = self\n            .floats\n            .entry(prec)\n            .or_insert(striped_random_positive_floats_with_precision(\n                self.seed.fork(&prec.to_string()),\n                self.mean_exponent_n,\n                self.mean_exponent_d,\n                self.mean_stripe_n,\n                self.mean_stripe_d,\n                prec,\n            ));\n        Some(xs.next().unwrap())\n    }\n}\n\nfn striped_random_floats_with_precision_inclusive_range(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n    prec_hi: u64,\n) -> It<Float> {\n    Box::new(StripedRandomFloatsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 64),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        precisions: Box::new(random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            prec_hi,\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nfn striped_random_floats_with_precision_inclusive_range_to_infinity(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n) -> It<Float> {\n    let mean_precision = Rational::from_unsigneds(\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 64),\n    ) + Rational::from(prec_lo);\n    let (n, d) = mean_precision.into_numerator_and_denominator();\n    Box::new(StripedRandomFloatsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 64),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        precisions: Box::new(geometric_random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            u64::MAX,\n            u64::exact_from(&n),\n            u64::exact_from(&d),\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nstruct StripedRandomFloatPairsWithPrecisionUniformInclusiveRange {\n    seed: Seed,\n    mean_exponent_n: u64,\n    mean_exponent_d: u64,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n    precisions: Box<dyn Iterator<Item = u64>>,\n    floats: HashMap<u64, RandomPositiveFiniteFloats<StripedRandomNaturalInclusiveRange>>,\n}\n\nimpl Iterator for StripedRandomFloatPairsWithPrecisionUniformInclusiveRange {\n    type Item = (Float, Float);\n\n    fn next(&mut self) -> Option<(Float, Float)> {\n        let prec = self.precisions.next().unwrap();\n        let xs = self\n            .floats\n            .entry(prec)\n            .or_insert(striped_random_positive_floats_with_precision(\n                self.seed.fork(&prec.to_string()),\n                self.mean_exponent_n,\n                self.mean_exponent_d,\n                self.mean_stripe_n,\n                self.mean_stripe_d,\n                prec,\n            ));\n        Some((xs.next().unwrap(), xs.next().unwrap()))\n    }\n}\n\nstruct StripedRandomFloatPairsWithPrecisions {\n    seed: Seed,\n    mean_exponent_n: u64,\n    mean_exponent_d: u64,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n    precisions: Box<dyn Iterator<Item = (u64, u64)>>,\n    floats: HashMap<u64, RandomPositiveFiniteFloats<StripedRandomNaturalInclusiveRange>>,\n}\n\nimpl Iterator for StripedRandomFloatPairsWithPrecisions {\n    type Item = (Float, Float);\n\n    fn next(&mut self) -> Option<(Float, Float)> {\n        let precs = self.precisions.next().unwrap();\n        let xs =\n            self.floats\n                .entry(precs.0)\n                .or_insert(striped_random_positive_floats_with_precision(\n                    self.seed.fork(&precs.0.to_string()),\n                    self.mean_exponent_n,\n                    self.mean_exponent_d,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                    precs.0,\n                ));\n        let x = xs.next().unwrap();\n        let ys =\n            self.floats\n                .entry(precs.1)\n                .or_insert(striped_random_positive_floats_with_precision(\n                    self.seed.fork(&precs.1.to_string()),\n                    self.mean_exponent_n,\n                    self.mean_exponent_d,\n                    self.mean_stripe_n,\n                    self.mean_stripe_d,\n                    precs.1,\n                ));\n        let y = ys.next().unwrap();\n        Some((x, y))\n    }\n}\n\nfn striped_random_float_pairs_with_precision_inclusive_range(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n    prec_hi: u64,\n) -> It<(Float, Float)> {\n    Box::new(StripedRandomFloatPairsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 64),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        precisions: Box::new(random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            prec_hi,\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nfn striped_random_float_pairs_with_precision_inclusive_range_to_infinity(\n    seed: Seed,\n    config: &GenConfig,\n    prec_lo: u64,\n) -> It<(Float, Float)> {\n    let mean_precision = Rational::from_unsigneds(\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 64),\n    ) + Rational::from(prec_lo);\n    let (n, d) = mean_precision.into_numerator_and_denominator();\n    Box::new(StripedRandomFloatPairsWithPrecisionUniformInclusiveRange {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 64),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        precisions: Box::new(geometric_random_unsigned_inclusive_range(\n            seed.fork(\"precisions\"),\n            prec_lo,\n            u64::MAX,\n            u64::exact_from(&n),\n            u64::exact_from(&d),\n        )),\n        floats: HashMap::new(),\n    })\n}\n\nfn striped_random_float_pairs_with_precisions(\n    seed: Seed,\n    config: &GenConfig,\n    precisions: It<(u64, u64)>,\n) -> It<(Float, Float)> {\n    Box::new(StripedRandomFloatPairsWithPrecisions {\n        seed: seed.fork(\"floats\"),\n        mean_exponent_n: config.get_or(\"mean_exponent_n\", 64),\n        mean_exponent_d: config.get_or(\"mean_exponent_d\", 1),\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 64),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        precisions,\n        floats: HashMap::new(),\n    })\n}\n\n// -- (Float, Float) --\n\npub fn special_random_float_pair_gen(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(striped_random_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    )))\n}\n\npub fn special_random_float_pair_gen_var_1(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(striped_random_finite_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    )))\n}\n\npub fn special_random_float_pair_gen_var_2(config: &GenConfig) -> It<(Float, Float)> {\n    striped_random_float_pairs_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        1,\n        Limb::WIDTH - 1,\n    )\n}\n\npub fn special_random_float_pair_gen_var_3(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(\n        striped_random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            Limb::WIDTH,\n        ),\n    ))\n}\n\npub fn special_random_float_pair_gen_var_4(config: &GenConfig) -> It<(Float, Float)> {\n    striped_random_float_pairs_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        Limb::WIDTH + 1,\n        (Limb::WIDTH << 1) - 1,\n    )\n}\n\npub fn special_random_float_pair_gen_var_5(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(\n        striped_random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            Limb::WIDTH << 1,\n        ),\n    ))\n}\n\npub fn special_random_float_pair_gen_var_6(config: &GenConfig) -> It<(Float, Float)> {\n    striped_random_float_pairs_with_precision_inclusive_range(\n        EXAMPLE_SEED,\n        config,\n        (Limb::WIDTH << 1) + 1,\n        Limb::WIDTH * 3 - 1,\n    )\n}\n\npub fn special_random_float_pair_gen_var_7(config: &GenConfig) -> It<(Float, Float)> {\n    striped_random_float_pairs_with_precision_inclusive_range_to_infinity(\n        EXAMPLE_SEED,\n        config,\n        Limb::WIDTH * 3,\n    )\n}\n\npub fn special_random_float_pair_gen_var_8(config: &GenConfig) -> It<(Float, Float)> {\n    striped_random_float_pairs_with_precisions(\n        EXAMPLE_SEED,\n        config,\n        Box::new(random_pairs(\n            EXAMPLE_SEED.fork(\"precisions\"),\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    1,\n                    Limb::WIDTH,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n            },\n        )),\n    )\n}\n\npub fn special_random_float_pair_gen_var_9(config: &GenConfig) -> It<(Float, Float)> {\n    striped_random_float_pairs_with_precisions(\n        EXAMPLE_SEED,\n        config,\n        Box::new(random_pairs(\n            EXAMPLE_SEED.fork(\"precisions\"),\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                )\n                .map(|p: u64| p + Limb::WIDTH)\n            },\n        )),\n    )\n}\n\npub fn special_random_float_pair_gen_var_10(config: &GenConfig) -> It<(Float, Float)> {\n    Box::new(random_pairs_from_single(\n        striped_random_mixed_extreme_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_exponent_n\", 64),\n            config.get_or(\"mean_exponent_d\", 1),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_precision_n\", 64),\n            config.get_or(\"mean_precision_d\", 1),\n            config.get_or(\"mean_zero_p_n\", 1),\n            config.get_or(\"mean_zero_p_d\", 64),\n        ),\n    ))\n}\n\n// -- (Float, Float, Float) --\n\npub fn special_random_float_triple_gen(config: &GenConfig) -> It<(Float, Float, Float)> {\n    Box::new(random_triples_from_single(striped_random_floats(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_exponent_n\", 64),\n        config.get_or(\"mean_exponent_d\", 1),\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_precision_n\", 64),\n        config.get_or(\"mean_precision_d\", 1),\n        config.get_or(\"mean_zero_p_n\", 1),\n        config.get_or(\"mean_zero_p_d\", 64),\n    )))\n}\n\n// -- (Float, Float, Integer) --\n\npub fn special_random_float_float_integer_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Float, Integer)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, Natural) --\n\npub fn special_random_float_float_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Float, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveFloat, PrimitiveFloat) --\n\npub fn special_random_float_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Float, Float, PrimitiveSigned) --\n\npub fn special_random_float_float_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, PrimitiveUnsigned) --\n\npub fn special_random_float_float_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_float_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_float_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Float, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_mixed_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_prec_round_valid(x, y, *prec, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_prec_round_valid(x, y, *prec, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| agm_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_float_unsigned_rounding_mode_quadruple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Float, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| agm_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Float, Float, Rational) --\n\npub fn special_random_float_float_rational_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Float, Rational)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Float, RoundingMode) --\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    1,\n                    Limb::WIDTH - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH << 1,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH * 3,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| add_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    1,\n                    Limb::WIDTH - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_12(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_13(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH << 1,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_14(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_15(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH * 3,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| sub_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_16(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_17(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    1,\n                    Limb::WIDTH - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_18(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_19(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_20(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH << 1,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_21(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_22(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH * 3,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| mul_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_23(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, false)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_24(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    1,\n                    Limb::WIDTH - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_25(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs_from_single(striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH,\n                ))\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_26(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_27(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precisions(\n                    seed,\n                    config,\n                    Box::new(random_pairs(\n                        seed.fork(\"precisions\"),\n                        &|seed_2| {\n                            geometric_random_positive_unsigneds(\n                                seed_2,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                        },\n                        &|seed_2| {\n                            geometric_random_unsigned_inclusive_range(\n                                seed_2,\n                                1,\n                                Limb::WIDTH,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                        },\n                    )),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_28(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    reshape_2_1_to_3(Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_float_pairs_with_precisions(\n                    seed,\n                    config,\n                    Box::new(random_pairs(\n                        seed.fork(\"precisions\"),\n                        &|seed_2| {\n                            geometric_random_positive_unsigneds(\n                                seed_2,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                        },\n                        &|seed_2| {\n                            geometric_random_positive_unsigneds(\n                                seed_2,\n                                config.get_or(\"mean_precision_n\", 64),\n                                config.get_or(\"mean_precision_d\", 1),\n                            )\n                            .map(|p: u64| p + Limb::WIDTH)\n                        },\n                    )),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|((x, y), rm)| div_round_valid(x, y, *rm, false)),\n    ))\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_29(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_30(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_31(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_32(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_round_valid(x, y, *rm, true)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_33(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| agm_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_float_rounding_mode_triple_gen_var_34(\n    config: &GenConfig,\n) -> It<(Float, Float, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_mixed_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| agm_round_valid(x, y, *rm)),\n    )\n}\n\n// -- (Float, Integer) --\n\npub fn special_random_float_integer_pair_gen(config: &GenConfig) -> It<(Float, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_integer_pair_gen_var_1(config: &GenConfig) -> It<(Float, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_integer_pair_gen_var_2(config: &GenConfig) -> It<(Float, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Integer, Integer) --\n\npub fn special_random_float_integer_integer_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Integer, Integer)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Natural) --\n\npub fn special_random_float_natural_pair_gen(config: &GenConfig) -> It<(Float, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_natural_pair_gen_var_1(config: &GenConfig) -> It<(Float, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_natural_pair_gen_var_2(config: &GenConfig) -> It<(Float, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Natural, Natural) --\n\npub fn special_random_float_natural_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Natural, Natural)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Ordering) --\n\npub fn special_random_float_ordering_pair_gen(config: &GenConfig) -> It<(Float, Ordering)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_orderings,\n    ))\n}\n\npub fn special_random_float_ordering_pair_gen_var_1(config: &GenConfig) -> It<(Float, Ordering)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_orderings,\n    ))\n}\n\n// -- (Float, PrimitiveFloat) --\n\npub fn special_random_float_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\npub fn special_random_float_primitive_float_pair_gen_var_1<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Float, PrimitiveFloat, PrimitiveFloat) --\n\npub fn special_random_float_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Float, PrimitiveSigned) --\n\npub fn special_random_float_signed_pair_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// TODO use ranges\npub fn special_random_float_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n            )\n            .map(|mut x| {\n                if let Float(Finite { exponent, .. }) = &mut x {\n                    *exponent = 1;\n                }\n                x\n            })\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_signed_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_signed_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_signed_pair_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveSigned) --\n\npub fn special_random_float_signed_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_float_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_1<\n    T: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_2<\n    T: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_3<\n    T: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn special_random_float_signed_unsigned_rounding_mode_quadruple_gen_var_4<\n    T: PrimitiveSigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\n// -- (Float, PrimitiveSigned, RoundingMode) --\n\npub fn special_random_float_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_signed_rounding_mode_triple_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_signed_rounding_mode_triple_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_signed_rounding_mode_triple_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_signed_rounding_mode_triple_gen_var_6<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\n// -- (Float, PrimitiveUnsigned) --\n\npub fn special_random_float_unsigned_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n            .filter(|x| *x > 0u32)\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_float_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2<\n    T: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shl_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3<\n    T: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4<\n    T: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Float, T, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, prec, rm)| shr_prec_round_valid(x, bits, prec, rm)),\n    )\n}\n\n// -- (Float, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| set_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| square_prec_round_valid(x, p, rm, false)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_prec_round_valid(x, p, rm, false)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| set_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shl_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, T, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n        )\n        .filter(|&(ref x, bits, rm)| shr_round_valid(x, bits, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| square_prec_round_valid(x, p, rm, true)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_12(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_prec_round_valid(x, p, rm, true)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_13(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_14(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_15(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_16(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| reciprocal_sqrt_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_17(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n            .filter(|x| *x > 0u32)\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_18(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_19(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| ln_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_float_unsigned_rounding_mode_triple_gen_var_20(\n    config: &GenConfig,\n) -> It<(Float, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref x, p, rm)| ln_prec_round_valid(x, p, rm)),\n    )\n}\n\n// -- (Float, Rational) --\n\npub fn special_random_float_rational_pair_gen(config: &GenConfig) -> It<(Float, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_rational_pair_gen_var_1(config: &GenConfig) -> It<(Float, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_rational_pair_gen_var_2(config: &GenConfig) -> It<(Float, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Rational, PrimitiveUnsigned) --\n\npub fn special_random_float_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Rational, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_float_rational_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, Rational, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Rational, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| rational_div_float_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| add_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| sub_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| mul_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| div_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\npub fn special_random_float_rational_unsigned_rounding_mode_quadruple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| rational_div_float_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Float, Rational, Rational) --\n\npub fn special_random_float_rational_rational_triple_gen(\n    config: &GenConfig,\n) -> It<(Float, Rational, Rational)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Float, Rational, RoundingMode) --\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n    ))\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| rational_div_float_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| add_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| sub_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| mul_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| div_rational_round_valid(x, y, *rm)),\n    )\n}\n\npub fn special_random_float_rational_rounding_mode_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Float, Rational, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, rm)| rational_div_float_round_valid(x, y, *rm)),\n    )\n}\n\n// -- (Float, RoundingMode) --\n\npub fn special_random_float_rounding_mode_pair_gen(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| natural_rounding_from_float_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| integer_rounding_from_float_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_3(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_nonzero_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_float_rounding_mode_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| unsigned_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_float_rounding_mode_pair_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| signed_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_float_rounding_mode_pair_gen_var_6<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| *rm != Exact || T::convertible_from(f)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_7(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_8(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    1,\n                    Limb::WIDTH - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_9(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_10(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_11(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH << 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_12(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                    Limb::WIDTH * 3 - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_13(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_14(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    1,\n                    Limb::WIDTH - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_15(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_16(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_17(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, false)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_float_rounding_mode_pair_gen_var_18<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| unsigned_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_float_rounding_mode_pair_gen_var_19<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| signed_rounding_from_float_valid::<T>(f, *rm)),\n    )\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_float_rounding_mode_pair_gen_var_20<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| *rm != Exact || T::convertible_from(f)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_21(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_extreme_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_22(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| square_round_valid(f, *rm, true)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_23(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_round_valid(f, *rm, true)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_24(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_25(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    1,\n                    Limb::WIDTH - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_26(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_floats_with_precision(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    Limb::WIDTH,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_27(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range(\n                    seed,\n                    config,\n                    Limb::WIDTH + 1,\n                    (Limb::WIDTH << 1) - 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_28(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats_with_precision_inclusive_range_to_infinity(\n                    seed,\n                    config,\n                    (Limb::WIDTH << 1) + 1,\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_29(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_30(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_31(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| reciprocal_sqrt_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_32(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n            .filter(|x| *x > 0u32)\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_33(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_finite_floats(\n                seed,\n                config.get_or(\"mean_exponent_n\", 64),\n                config.get_or(\"mean_exponent_d\", 1),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_precision_n\", 64),\n                config.get_or(\"mean_precision_d\", 1),\n                config.get_or(\"mean_zero_p_n\", 1),\n                config.get_or(\"mean_zero_p_d\", 64),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_34(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| ln_round_valid(f, *rm)),\n    )\n}\n\npub fn special_random_float_rounding_mode_pair_gen_var_35(\n    config: &GenConfig,\n) -> It<(Float, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_extreme_floats(\n                    seed,\n                    config.get_or(\"mean_exponent_n\", 64),\n                    config.get_or(\"mean_exponent_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_precision_n\", 64),\n                    config.get_or(\"mean_precision_d\", 1),\n                    config.get_or(\"mean_zero_p_n\", 1),\n                    config.get_or(\"mean_zero_p_d\", 64),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(f, rm)| ln_round_valid(f, *rm)),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-nz.\n\npub fn special_random_integer_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Integer, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == 0u32 || n.significant_bits() - n.trailing_zeros().unwrap() <= prec\n        }),\n    )\n}\n\npub fn special_random_integer_unsigned_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Integer, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\n// var 1 is in malachite-nz\n\npub fn special_random_natural_unsigned_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == 0u32 || n.significant_bits() - n.trailing_zeros().unwrap() <= prec\n        }),\n    )\n}\n\npub fn special_random_natural_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Natural, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|&rm| rm != Exact),\n    ))\n}\n\n// -- (PrimitiveFloat, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\npub fn special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &random_primitive_floats,\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(x, p, rm)| from_primitive_float_prec_round_valid(x, p, rm)),\n    )\n}\n\npub fn special_random_primitive_float_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)>\nwhere\n    Float: From<T>,\n{\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &random_primitive_floats,\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\n// -- (PrimitiveSigned, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 2 are in malachite-base.\n\npub fn special_random_signed_unsigned_rounding_mode_triple_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == T::ZERO || n.significant_bits() - n.trailing_zeros() <= prec\n        }),\n    )\n}\n\npub fn special_random_signed_unsigned_rounding_mode_triple_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\npub fn special_random_signed_unsigned_rounding_mode_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(i64, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_signeds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(pow, _, rm)| {\n            rm != Exact\n                || (Float::MIN_EXPONENT..=Float::MAX_EXPONENT)\n                    .contains(&i32::saturating_from(pow).saturating_add(1))\n        }),\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned, RoundingMode) --\n\n// vars 1 through 4 are in malachite-base.\n\npub fn special_random_unsigned_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact || *n == T::ZERO || n.significant_bits() - n.trailing_zeros() <= prec\n        }),\n    )\n}\n\npub fn special_random_unsigned_unsigned_rounding_mode_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(T, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\n// -- (Rational, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_rational_unsigned_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2()\n                    && n.numerator_ref().significant_bits() <= prec\n        }),\n    )\n}\n\npub fn special_random_rational_unsigned_rounding_mode_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n        &|seed| random_rounding_modes(seed).filter(|rm| *rm != Exact),\n    ))\n}\n\npub fn special_random_rational_unsigned_rounding_mode_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| sqrt_rational_prec_round_valid(n, prec, rm)),\n    )\n}\n\npub fn special_random_rational_unsigned_rounding_mode_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| reciprocal_sqrt_rational_prec_round_valid(n, prec, rm)),\n    )\n}\n\npub fn special_random_rational_unsigned_rounding_mode_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_non_negative_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2()\n                    && n.numerator_ref().significant_bits() <= prec\n        }),\n    )\n}\n\npub fn special_random_rational_unsigned_rounding_mode_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Rational, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, prec, rm)| ln_rational_prec_round_valid(n, prec, rm)),\n    )\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_rational_rational_unsigned_rounding_mode_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, u64, RoundingMode)> {\n    Box::new(\n        random_quadruples_xxyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, y, prec, rm)| agm_rational_prec_round_valid(x, y, *prec, *rm)),\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\n// vars 1 through 5 are in malachite-q.\n\npub fn special_random_rational_rounding_mode_pair_gen_var_6(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, rm)| {\n            rm != Exact\n                || n.denominator_ref().is_power_of_2() && n.numerator_ref().significant_bits() <= 1\n        }),\n    )\n}\n"
  },
  {
    "path": "malachite-float/src/test_util/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod arithmetic;\npub mod bench;\npub mod common;\npub mod comparison;\npub mod constants;\npub mod conversion;\npub mod exhaustive;\npub mod extra_variadic;\npub mod generators;\npub mod random;\n"
  },
  {
    "path": "malachite-float/src/test_util/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::itertools::Itertools;\nuse crate::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{MomentStats, moment_stats};\n\npub fn random_floats_helper_helper<I: Clone + Iterator<Item = Float>>(\n    xs: I,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_median_hex: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let comparable_xs = xs.clone().map(ComparableFloat);\n    let raw_actual_values = xs.clone().take(20).collect_vec();\n    let actual_values = raw_actual_values\n        .iter()\n        .map(Float::to_string)\n        .take(20)\n        .collect_vec();\n    let actual_values_hex = raw_actual_values\n        .iter()\n        .map(|x| format!(\"{:#x}\", ComparableFloatRef(x)))\n        .take(20)\n        .collect_vec();\n    let actual_values = actual_values.iter().map(String::as_str).collect_vec();\n    let actual_values_hex = actual_values_hex.iter().map(String::as_str).collect_vec();\n    for x in xs.clone().take(1000000) {\n        assert!(x.is_valid());\n    }\n    let raw_common_values = common_values_map(1000000, 10, comparable_xs.clone())\n        .into_iter()\n        .collect_vec();\n    let actual_common_values = raw_common_values\n        .iter()\n        .map(|(x, freq)| (x.0.to_string(), *freq))\n        .collect_vec();\n    let actual_common_values = actual_common_values\n        .iter()\n        .map(|(x, freq)| (x.as_str(), *freq))\n        .collect_vec();\n    let actual_common_values_hex = raw_common_values\n        .iter()\n        .map(|(x, freq)| (format!(\"{x:#x}\"), *freq))\n        .collect_vec();\n    let actual_common_values_hex = actual_common_values_hex\n        .iter()\n        .map(|(x, freq)| (x.as_str(), *freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(comparable_xs.take(1000000));\n    let (median_lo_hex, median_hi_hex) = (\n        format!(\"{median_lo:#x}\"),\n        median_hi.as_ref().map(|x| format!(\"{x:#x}\")),\n    );\n    let (median_lo, median_hi) = (\n        median_lo.0.to_string(),\n        median_hi.map(|x| Float::to_string(&x.0)),\n    );\n    let actual_sample_median = (median_lo.as_str(), median_hi.as_deref());\n    let actual_sample_median_hex = (median_lo_hex.as_str(), median_hi_hex.as_deref());\n    let actual_sample_moment_stats =\n        moment_stats(xs.take(1000000).map(|x| f64::rounding_from(&x, Nearest).0));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_values_hex.as_slice(),\n            actual_common_values.as_slice(),\n            actual_common_values_hex.as_slice(),\n            actual_sample_median,\n            actual_sample_median_hex,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_values_hex,\n            expected_common_values,\n            expected_common_values_hex,\n            expected_sample_median,\n            expected_sample_median_hex,\n            expected_sample_moment_stats\n        )\n    );\n}\n\n// TODO remove once we have fast to_string\npub fn random_floats_helper_helper_no_common_values<I: Clone + Iterator<Item = Float>>(\n    xs: I,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_median_hex: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let comparable_xs = xs.clone().map(ComparableFloat);\n    let raw_actual_values = xs.clone().take(20).collect_vec();\n    let actual_values = raw_actual_values\n        .iter()\n        .map(Float::to_string)\n        .take(20)\n        .collect_vec();\n    let actual_values_hex = raw_actual_values\n        .iter()\n        .map(|x| format!(\"{:#x}\", ComparableFloatRef(x)))\n        .take(20)\n        .collect_vec();\n    let actual_values = actual_values.iter().map(String::as_str).collect_vec();\n    let actual_values_hex = actual_values_hex.iter().map(String::as_str).collect_vec();\n    for x in xs.clone().take(1000000) {\n        assert!(x.is_valid());\n    }\n    let (median_lo, median_hi) = median(comparable_xs.take(1000000));\n    let (median_lo_hex, median_hi_hex) = (\n        format!(\"{median_lo:#x}\"),\n        median_hi.as_ref().map(|x| format!(\"{x:#x}\")),\n    );\n    let (median_lo, median_hi) = (\n        median_lo.0.to_string(),\n        median_hi.map(|x| Float::to_string(&x.0)),\n    );\n    let actual_sample_median = (median_lo.as_str(), median_hi.as_deref());\n    let actual_sample_median_hex = (median_lo_hex.as_str(), median_hi_hex.as_deref());\n    let actual_sample_moment_stats =\n        moment_stats(xs.take(1000000).map(|x| f64::rounding_from(&x, Nearest).0));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_values_hex.as_slice(),\n            actual_sample_median,\n            actual_sample_median_hex,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_values_hex,\n            expected_sample_median,\n            expected_sample_median_hex,\n            expected_sample_moment_stats\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_4, float_gen_var_12};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\n\n#[test]\nfn test_abs_negative_zero() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let abs = x.clone().abs_negative_zero();\n        assert!(abs.is_valid());\n\n        assert_eq!(abs.to_string(), out);\n        assert_eq!(to_hex_string(&abs), out_hex);\n\n        let abs_alt = x.abs_negative_zero_ref();\n        assert!(abs_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n\n        let mut abs_alt = x;\n        abs_alt.abs_negative_zero_assign();\n        assert!(abs_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"2.0\", \"0x2.0#1\", \"2.0\", \"0x2.0#1\");\n    test(\"0.5\", \"0x0.8#1\", \"0.5\", \"0x0.8#1\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"-1.0\", \"-0x1.0#1\");\n    test(\"-2.0\", \"-0x2.0#1\", \"-2.0\", \"-0x2.0#1\");\n    test(\"-0.5\", \"-0x0.8#1\", \"-0.5\", \"-0x0.8#1\");\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn abs_negative_zero_properties_helper(x: Float) {\n    let abs = x.clone().abs_negative_zero();\n    assert!(abs.is_valid());\n\n    let abs_alt = x.abs_negative_zero_ref();\n    assert!(abs_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n\n    let mut abs_alt = x.clone();\n    abs_alt.abs_negative_zero_assign();\n    assert!(abs_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n\n    if x.is_negative_zero() {\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&Float::ZERO));\n    } else {\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&x));\n    }\n    assert_eq!(\n        ComparableFloat(abs.abs_negative_zero_ref()),\n        ComparableFloat(abs)\n    );\n}\n\n#[test]\nfn abs_negative_zero_properties() {\n    float_gen().test_properties(|x| {\n        abs_negative_zero_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        abs_negative_zero_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_abs() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let abs = x.clone().abs();\n        assert!(abs.is_valid());\n\n        assert_eq!(abs.to_string(), out);\n        assert_eq!(to_hex_string(&abs), out_hex);\n\n        let abs_alt = (&x).abs();\n        assert!(abs_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n\n        let mut abs_alt = x.clone();\n        abs_alt.abs_assign();\n        assert!(abs_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n\n        assert_eq!(\n            ComparableFloat(Float::from(&rug::Float::exact_from(&x).abs())),\n            ComparableFloat(abs)\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"Infinity\", \"Infinity\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"2.0\", \"0x2.0#1\", \"2.0\", \"0x2.0#1\");\n    test(\"0.5\", \"0x0.8#1\", \"0.5\", \"0x0.8#1\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"-2.0\", \"-0x2.0#1\", \"2.0\", \"0x2.0#1\");\n    test(\"-0.5\", \"-0x0.8#1\", \"0.5\", \"0x0.8#1\");\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n}\n\nfn abs_properties_helper(x: Float) {\n    let abs = x.clone().abs();\n    assert!(abs.is_valid());\n\n    let abs_alt = (&x).abs();\n    assert!(abs_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n\n    let mut abs_alt = x.clone();\n    abs_alt.abs_assign();\n    assert!(abs_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&abs_alt));\n\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug::Float::exact_from(&x).abs())),\n        ComparableFloatRef(&abs)\n    );\n\n    if x.is_sign_negative() {\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&-&x));\n    } else {\n        assert_eq!(ComparableFloatRef(&abs), ComparableFloatRef(&x));\n    }\n    assert_eq!(ComparableFloatRef(&(&abs).abs()), ComparableFloatRef(&abs));\n    assert_eq!(ComparableFloat((-x).abs()), ComparableFloat(abs));\n}\n\n#[test]\nfn abs_properties() {\n    float_gen().test_properties(|x| {\n        abs_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        abs_properties_helper(x);\n    });\n\n    float_gen_var_4().test_properties(|x| {\n        assert_eq!(\n            Rational::exact_from((&x).abs()),\n            Rational::exact_from(x).abs()\n        );\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(\n            ComparableFloat(Float::from(x.abs())),\n            ComparableFloat(Float::from(x).abs())\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{NegAssign, PowerOf2};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::emulate_float_float_to_float_fn;\nuse malachite_float::test_util::arithmetic::add::{\n    add_prec_round_naive, add_rational_prec_round_naive, rug_add, rug_add_prec, rug_add_prec_round,\n    rug_add_rational, rug_add_rational_prec, rug_add_rational_prec_round, rug_add_rational_round,\n    rug_add_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_1, float_float_rounding_mode_triple_gen_var_4,\n    float_float_rounding_mode_triple_gen_var_5, float_float_rounding_mode_triple_gen_var_6,\n    float_float_rounding_mode_triple_gen_var_7, float_float_rounding_mode_triple_gen_var_8,\n    float_float_rounding_mode_triple_gen_var_9, float_float_rounding_mode_triple_gen_var_29,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_5, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_2, float_gen, float_pair_gen, float_pair_gen_var_2,\n    float_pair_gen_var_3, float_pair_gen_var_4, float_pair_gen_var_5, float_pair_gen_var_6,\n    float_pair_gen_var_7, float_pair_gen_var_10, float_rational_pair_gen,\n    float_rational_pair_gen_var_2, float_rational_rounding_mode_triple_gen_var_1,\n    float_rational_rounding_mode_triple_gen_var_8,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_7,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_2,\n    float_rounding_mode_pair_gen, float_unsigned_pair_gen_var_1,\n    float_unsigned_rounding_mode_triple_gen_var_1, rational_rounding_mode_pair_gen_var_6,\n    rational_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\nuse std::cmp::{\n    Ordering::{self, *},\n    max,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_add() {\n    let test = |s, s_hex, t, t_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let sum = x.clone() + y.clone();\n        assert!(sum.is_valid());\n\n        assert_eq!(sum.to_string(), out);\n        assert_eq!(to_hex_string(&sum), out_hex);\n\n        let sum_alt = x.clone() + &y;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let sum_alt = &x + y.clone();\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let sum_alt = &x + &y;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n\n        let mut sum_alt = x.clone();\n        sum_alt += y.clone();\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let mut sum_alt = x.clone();\n        sum_alt += &y;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_add(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y)\n            ))),\n            ComparableFloatRef(&sum)\n        );\n\n        let sum_alt = add_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\",\n    );\n\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\");\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", \"123.0\", \"0x7b.0#7\");\n    test(\"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", \"123.0\", \"0x7b.0#7\");\n\n    // - in add_float_significands_same_prec_lt_w\n    // - x_exp < y_exp in add_float_significands_same_prec_lt_w\n    // - exp_diff < shift in add_float_significands_same_prec_lt_w\n    // - exp_diff < shift && !overflow in add_float_significands_same_prec_lt_w\n    // - (round_bit != 0 || sticky_bit == 0) && rm == Nearest in\n    //   add_float_significands_same_prec_lt_w\n    // - round_bit != 0 && (sticky_bit != 0 || (sum & shift_bit) != 0) in\n    //   add_float_significands_same_prec_lt_w\n    // - rm == Nearest && sum == 0 in add_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", \"4.0\", \"0x4.0#1\");\n    // - in add_float_significands_same_prec_general\n    // - out_bits > exp_diff in add_float_significands_same_prec_general\n    // - overlap <= ys_len in add_float_significands_same_prec_general\n    // - shift2 != 0 in add_float_significands_same_prec_general\n    // - out_len - k <= overlap in add_float_significands_same_prec_general\n    // - out_len <= xs_len second time in add_float_significands_same_prec_general\n    // - !y in add_float_significands_same_prec_general\n    // - round_bit == Uninitialized && shift != 0 in add_float_significands_same_prec_general\n    // - shift > 1 in add_float_significands_same_prec_general\n    // - x == 0 second time in add_float_significands_same_prec_general\n    // - xs_len <= out_len && following_bits != True in add_float_significands_same_prec_general\n    // - difw > 0 && difw > ys_len && exp_diff <= out_bits in\n    //   add_float_significands_same_prec_general\n    // - exp_diff_rem != 0 || yi != 0 second time in add_float_significands_same_prec_general\n    // - exp_diff_rem != 0 second time in add_float_significands_same_prec_general\n    // - round_bit != Uninitialized seventh time in add_float_significands_same_prec_general\n    // - yi == 0 second time in add_float_significands_same_prec_general\n    // - in add_float_significands_same_prec_general_round\n    // - following_bits == False && round_bit == False in\n    //   add_float_significands_same_prec_general_round\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", \"3.0\", \"0x3.0#2\");\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", \"3.0\", \"0x3.0#2\");\n    // round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", \"3.0\", \"0x3.0#2\");\n    test(\"1.0\", \"0x1.000#10\", \"2.0\", \"0x2.00#10\", \"3.0\", \"0x3.00#10\");\n\n    // - exp_diff < shift && overflow in add_float_significands_same_prec_lt_w\n    // - round_bit == 0 || (sticky_bit == 0 && (sum & shift_bit) == 0)\n    // - in add_float_significands_same_prec_lt_w\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-4.555806215962888\",\n        \"-0x4.8e4950f0795fc#53\",\n    );\n\n    // - x_exp > y_exp in add_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"0.0002\", \"0x0.001#1\", \"1.0\", \"0x1.0#1\");\n    test(\"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", \"0.0\", \"0x0.0\");\n    // - x_exp == y_exp in add_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\");\n    // - rm == Nearest && sum != 0 in add_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#3\", \"1.8\", \"0x1.c#3\", \"3.0\", \"0x3.0#3\");\n    // - exp_diff >= Limb::WIDTH in add_float_significands_same_prec_lt_w\n    test(\n        \"7.7e14\",\n        \"0x2.bcE+12#8\",\n        \"1.237e-9\",\n        \"0x5.50E-8#8\",\n        \"7.7e14\",\n        \"0x2.bcE+12#8\",\n    );\n    // - shift <= exp_diff < Limb::WIDTH in add_float_significands_same_prec_lt_w\n    // - shift <= exp_diff < Limb::WIDTH && !overflow in add_float_significands_same_prec_lt_w\n    test(\n        \"1.852193494e22\",\n        \"0x3.ec137baE+18#29\",\n        \"241425944.0\",\n        \"0xe63de18.0#29\",\n        \"1.852193494e22\",\n        \"0x3.ec137baE+18#29\",\n    );\n    // - shift <= exp_diff < Limb::WIDTH && !overflow in add_float_significands_same_prec_lt_w\n    test(\n        \"1.999999999999993\",\n        \"0x1.fffffffffffe#48\",\n        \"5.96046447753906e-8\",\n        \"0x1.000000000000E-6#48\",\n        \"2.00000005960464\",\n        \"0x2.000001000000#48\",\n    );\n\n    // - in add_float_significands_same_prec_w\n    // - x_exp == y_exp in add_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_w\n    // - !overflow in add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        \"3.0\",\n        \"0x3.0000000000000000#64\",\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"3.0\",\n        \"0x3.0000000000000000#64\",\n    );\n    // - (round_bit != 0) || (sticky_bit != 0) && rm == Nearest in\n    //   add_float_significands_same_prec_w\n    // - round_bit == 0 || (sticky_bit == 0 && (sum & 1) == 0) in add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n    );\n    // - round_bit != 0 && (sticky_bit != 0 || (sum & 1) != 0) in add_float_significands_same_prec_w\n    // - round_bit != 0 && (sticky_bit != 0 || (sum & 1) != 0) and !overflow in\n    //   add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000003\",\n        \"0x1.0000000000000006#64\",\n        \"2.0000000000000000004\",\n        \"0x2.0000000000000008#64\",\n    );\n    // - exp_diff >= Limb::WIDTH in add_float_significands_same_prec_w\n    test(\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n        \"2.9347251290514630352e-45\",\n        \"0x1.0c11b075f03d6daeE-37#64\",\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n    );\n    // - overflow in add_float_significands_same_prec_w\n    test(\n        \"0.00022185253582909293959\",\n        \"0x0.000e8a1162cbb1a4265#64\",\n        \"0.000029745661521717034001\",\n        \"0x0.0001f30ca4b8117ff0a0#64\",\n        \"0.0002515981973508099736\",\n        \"0x0.00107d1e0783c324170#64\",\n    );\n    // - round_bit != 0 && (sticky_bit != 0 || (sum & 1) != 0) and overflow in\n    //   add_float_significands_same_prec_w\n    test(\n        \"63.999999999999999997\",\n        \"0x3f.ffffffffffffffc#64\",\n        \"64.0\",\n        \"0x40.000000000000000#64\",\n        \"128.0\",\n        \"0x80.00000000000000#64\",\n    );\n\n    // - in add_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp in add_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff < Limb::WIDTH && !overflow in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        \"3.0\",\n        \"0x3.0000000000000000#65\",\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"3.0\",\n        \"0x3.0000000000000000#65\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in add_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in add_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (sum_0 != 0 || sum_1 != 0) in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n    );\n    // - rm == Nearest && sum_1 != 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#65\",\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && !overflow in\n    //   add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        \"18.63123034252626794758647\",\n        \"0x12.a1984fcd64a8ae228eef#85\",\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n    );\n    // - exp_diff >= Limb::WIDTH * 2 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n        \"1.14823551075108882469e-96\",\n        \"0x2.73dea72af3fe6314E-80#65\",\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n    );\n    // - exp_diff == Limb::WIDTH in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"19585.2851423168986928116147584507795\",\n        \"0x4c81.48ff163dc91a0d4bd90309b0f8#116\",\n        \"372369974082165972902790.766638151683\",\n        \"0x4eda377c7f0d747fa386.c44265dd58#116\",\n        \"372369974082165972922376.05178046858\",\n        \"0x4eda377c7f0d747ff008.0d417c1b20#116\",\n    );\n    // - exp_diff < Limb::WIDTH && overflow in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"18.492649216180435830000529\",\n        \"0x12.7e1e424fe51f1bb914c0#85\",\n        \"56.637589789906471403844847\",\n        \"0x38.a339159fe96c1722fdfe#85\",\n        \"75.130239006086907233845378\",\n        \"0x4b.215757efce8b32dc12c0#85\",\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && overflow in\n    //   add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"5.29395592276605355108231857701752e-23\",\n        \"0x4.00000007e000fffffff0000000E-19#107\",\n        \"255.999999999999999999999947060441\",\n        \"0xff.ffffffffffffffffffc000000#107\",\n        \"256.0\",\n        \"0x100.0000000000000000000000000#107\",\n    );\n    // - rm == Nearest && sum_1 == 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"0.0000610351562499999999996\",\n        \"0x0.0003ffffffffffffffff8#67\",\n        \"17179869183.9999389648\",\n        \"0x3ffffffff.fffc00000#67\",\n        \"17179869184.0\",\n        \"0x400000000.00000000#67\",\n    );\n\n    // - in add_float_significands_same_prec_2w\n    // - x_exp == y_exp in add_float_significands_same_prec_2w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_2w\n    // - exp_diff < TWICE_WIDTH in add_float_significands_same_prec_2w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_2w\n    // - exp_diff < TWICE_WIDTH && !overflow in add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#128\",\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_2w\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#128\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in add_float_significands_same_prec_2w\n    // - rm == Nearest in add_float_significands_same_prec_2w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (sum_0 & 1) == 0)) in\n    //   add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (sum_0 & 1) != 0) in\n    //   add_float_significands_same_prec_2w\n    // - rm == Nearest && !overflow in add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000018\",\n        \"0x1.00000000000000000000000000000006#128\",\n        \"2.00000000000000000000000000000000000002\",\n        \"0x2.00000000000000000000000000000008#128\",\n    );\n    // - exp_diff >= TWICE_WIDTH in add_float_significands_same_prec_2w\n    // - exp_diff > TWICE_WIDTH in add_float_significands_same_prec_2w\n    test(\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n        \"5.07801249136957145270807726205511855421e-45\",\n        \"0x1.cfd8608b7c32de2bbcfecf8bcf8a2d00E-37#128\",\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n    );\n    // - Limb::WIDTH <= exp_diff < TWICE_WIDTH in add_float_significands_same_prec_2w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH in add_float_significands_same_prec_2w\n    test(\n        \"4354249796990942.35435357526597783143164\",\n        \"0xf782ac869b7de.5ab6ea78fcf0cc5079f#128\",\n        \"8.03239453825726512240307053405256016022e-10\",\n        \"0x3.732bce7aa121827a284545a25f32dc68E-8#128\",\n        \"4354249796990942.35435357606921728525736\",\n        \"0xf782ac869b7de.5ab6ea7c701c9acb1b1#128\",\n    );\n    // - exp_diff == TWICE_WIDTH in add_float_significands_same_prec_2w\n    test(\n        \"15732412727332569995335732833027757624.44\",\n        \"0xbd5f3d586bc01069a1d94f5ab5a1638.7#128\",\n        \"0.0373708302820085888760745841639896128921\",\n        \"0x0.0991227de2b63edc67164401ce8ebdb04#128\",\n        \"15732412727332569995335732833027757624.5\",\n        \"0xbd5f3d586bc01069a1d94f5ab5a1638.8#128\",\n    );\n    // - Limb::WIDTH == exp_diff in add_float_significands_same_prec_2w\n    test(\n        \"1.057437459917463716438672572710788562701e-17\",\n        \"0xc.310127aae1df1a1cb12f60c4d339d76E-15#128\",\n        \"148.0549133677002965445211858794413066474\",\n        \"0x94.0e0ecd6e62d0a8c7c7c2a633277e3e#128\",\n        \"148.054913367700296555095560478615943812\",\n        \"0x94.0e0ecd6e62d0a98ad7d520e1456fe0#128\",\n    );\n    // - exp_diff < TWICE_WIDTH && overflow in add_float_significands_same_prec_2w\n    test(\n        \"990.890284854484258981204316304960898664\",\n        \"0x3de.e3e9b54e224e900a8701c94cea27bc#128\",\n        \"111.972242543885876168914754084523121772\",\n        \"0x6f.f8e4e329c509f04b7f9497ec8ce6438#128\",\n        \"1102.862527398370135150119070389484020437\",\n        \"0x44e.dcce9877e758805606966139770e00#128\",\n    );\n    // - rm == Nearest && overflow in add_float_significands_same_prec_2w\n    test(\n        \"1152920954851033088.0\",\n        \"0xfffff8000000000.00000000000000000#128\",\n        \"549755813887.999999999999999999999999998\",\n        \"0x7fffffffff.ffffffffffffffffffffff8#128\",\n        \"1152921504606846976.0\",\n        \"0x1000000000000000.00000000000000000#128\",\n    );\n\n    // - in add_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && !overflow in add_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit != 0 || sticky_bit != 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && (round_bit == 0 || (sticky_bit == 0\n    //   && (sum_0 & shift_bit) == 0)) in add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && (round_bit == 0 || (sticky_bit == 0\n    //   && (sum_0 & shift_bit) == 0)) && sum != 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp > y_exp in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#129\",\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#129\",\n    );\n    // - x_exp == y_exp in add_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n    );\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && round_bit != 0 && (sticky_bit != 0\n    //   || (sum_0 & shift_bit) != 0) in add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && round_bit != 0 && (sticky_bit != 0\n    //   || (sum_0 & shift_bit) != 0) && sum != 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        \"2.000000000000000000000000000000000000012\",\n        \"0x2.00000000000000000000000000000004#129\",\n    );\n    // - Limb::WIDTH * 2 <= exp_diff < Limb::WIDTH * 3 in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH * 2 < exp_diff < Limb::WIDTH * 3 in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH * 2 <= exp_diff < Limb::WIDTH * 3 && !overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n    );\n    // - exp_diff >= Limb::WIDTH * 3 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n        \"6.8892360159362421595728818935378487832685754059e-50\",\n        \"0x1.9c693c182df3035eef00d41638bbdd942f4d498E-41#155\",\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && !overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.2850537238606374652351877988811796373898773e-22\",\n        \"0x2.0607fd4819748c532aad3528693c1e3c1966E-18#146\",\n        \"978.49328809934495391839880801989439981236569\",\n        \"0x3d2.7e4820fe314caadcb9a156bef2f1c8e53c#146\",\n        \"978.49328809934495391839923652526678587611222\",\n        \"0x3d2.7e4820fe314caadcbba75ebc3b0b3d718f#146\",\n    );\n    // - exp_diff < Limb::WIDTH && overflow in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4499918.46219262840948309077470961400786337\",\n        \"0x44a9ce.7652418f789422bc22220831e2030#137\",\n        \"64560208.0262619516023687759351781439347886\",\n        \"0x3d91c50.06b91a6f42e5205070f82f89eefa#137\",\n        \"69060126.488454580011851866709887757942652\",\n        \"0x41dc61e.7d0b5bfebb79430c931a37bbd0fc#137\",\n    );\n    // - exp_diff == Limb::WIDTH * 2 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"563971925627753843356041629019151473018178607215.42\",\n        \"0x62c960337e963a378ba6626ea422d8a5e623986f.6c#165\",\n        \"1301375421.83361702516620516356439489325145225661938\",\n        \"0x4d9169bd.d567ece47a47ef60371d48c969ba8765d4#165\",\n        \"563971925627753843356041629019151473019479982637.25\",\n        \"0x62c960337e963a378ba6626ea422d8a633b5022d.40#165\",\n    );\n    // - exp_diff == Limb::WIDTH in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"226.9305090753243797994707628568605406194\",\n        \"0xe2.ee35d7bf263fda8c632644ad7c49d98#130\",\n        \"4262448175090788889452.984188256984861391\",\n        \"0xe71159efd3a67e736c.fbf3c2f8db72fb8#130\",\n        \"4262448175090788889679.91469733230924119\",\n        \"0xe71159efd3a67e744f.ea299ab801b2d60#130\",\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1180591620717411303423.999999999999999999999999997\",\n        \"0x3fffffffffffffffff.ffffffffffffffffffffff#158\",\n        \"5.68434188616351954822429632036496545806324230121e-14\",\n        \"0x1.000000000fffffffffffe0000000000000000038E-11#158\",\n        \"1180591620717411303424.00000000000005684341886163\",\n        \"0x400000000000000000.00000000001000000000fe#158\",\n    );\n    // - Limb::WIDTH * 2 <= exp_diff < Limb::WIDTH * 3 && overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && round_bit != 0 && (sticky_bit != 0\n    //   || (sum_0 & shift_bit) != 0) && sum == 0\n    test(\n        \"4503599627370495.9999999999999999999999999996\",\n        \"0xfffffffffffff.ffffffffffffffffffffffe#143\",\n        \"3.3087224509824797385046520537834728287650668e-24\",\n        \"0x4.00000003ffff0000000000000000fffffffE-20#143\",\n        \"4503599627370496.000000000000000000000003309\",\n        \"0x10000000000000.00000000000000000004000#143\",\n    );\n\n    // - in add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 in add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && round_bit == 0 in add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec in add_float_significands_same_prec_ge_3w\n    // - in add_significands_rsh_to_out\n    // - exp_diff < Limb::WIDTH in add_significands_rsh_to_out\n    // - 0 < exp_diff < prec && shift == 0 in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && limb == 0 in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && rm == Nearest in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit == 0 in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n    );\n    // - 0 < exp_diff < prec && shift != 0 in add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#193\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#193\",\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#193\",\n    );\n    // - exp_diff == 0 && rm == Nearest in add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && rm == Nearest && out[0] & shift_bit == 0 in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n    );\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && sticky_bit == 0 && out[0] &\n    //   shift_bit == 0\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n    );\n    // - exp_diff == 0 && rm == Nearest && out[0] & shift_bit != 0 in\n    //   add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && rm == Nearest && out[0] & shift_bit != 0 && !carry in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.000000000000000000000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000000000000000000006#192\",\n        \"2.0000000000000000000000000000000000000000000000000000000013\",\n        \"0x2.000000000000000000000000000000000000000000000008#192\",\n    );\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && (sticky_bit != 0 || out[0] &\n    //   shift_bit != 0) in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && (sticky_bit != 0 || out[0] &\n    //   shift_bit != 0) && !carry in add_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.000000000000000000000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000000000000000000006#192\",\n        \"3.0000000000000000000000000000000000000000000000000000000013\",\n        \"0x3.000000000000000000000000000000000000000000000008#192\",\n    );\n    // - exp_diff >= Limb::WIDTH in add_significands_rsh_to_out\n    // - exp_diff >= Limb::WIDTH && r != 0 in add_significands_rsh_to_out\n    test(\n        \"7.28057116938384227432903448367767196428679514765398378973101e-48\",\n        \"0xa.a3fc2da1f20fb2d9771f86d3c16a444cd62d5d139e3935f24E-40#198\",\n        \"3.5123473778825578958968695187657587760357139395948269588971e-27\",\n        \"0x1.1646de419a6dbd3466f3081403a87d719b7a765a1ec69e4658E-22#198\",\n        \"3.5123473778825578959041500899351426183100429740785046308614e-27\",\n        \"0x1.1646de419a6dbd3471970441a59a8d2474f195e0f288088aa8E-22#198\",\n    );\n    // - exp_diff >= prec in add_float_significands_same_prec_ge_3w\n    // - exp_diff > prec in add_float_significands_same_prec_ge_3w\n    // - exp_diff > prec in add_float_significands_same_prec_ge_3w && (rm == Nearest || rm == Floor\n    //   || rm == Down)\n    test(\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n        \"0.023991386767031193042066748710708351501952890752924613005724\",\n        \"0x0.06244cad8cd272134e34b325815ad281733f2c06231a0ee744#193\",\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n    );\n    // - 0 < exp_diff < prec && limb != 0 in add_float_significands_same_prec_ge_3w\n    test(\n        \"8.699772042374378140693728074838279708562673799416097107796\",\n        \"0x8.b32442b4a730454d66b1b2bdf7a2863d417e6ff22d7f6c58#193\",\n        \"7.5897463681962395437740598844462353563682906392115908083148\",\n        \"0x7.96f99e34566e7be1960d023e431dc5e0a7ad24ad691a1ac4#193\",\n        \"16.289518410570617684467787959284515064930964438627687916112\",\n        \"0x10.4a1de0e8fd9ec12efcbeb4fc3ac04c1de92b949f9699872#193\",\n    );\n    // - exp_diff >= Limb::WIDTH && r == 0 in add_significands_rsh_to_out\n    test(\n        \"6.442552350746554109885349691592991892989624685631192235549e-6\",\n        \"0x0.00006c168d38e231899f0fc85d1888549d5177bdceaee72e15060#192\",\n        \"1476808010161862576835936576709144.7975622615653024045505082\",\n        \"0x48cff00a780a50d34bb694ada218.cc2d0a55f25f9f9126258#192\",\n        \"1476808010161862576835936576709144.797568704117653151104618\",\n        \"0x48cff00a780a50d34bb694ada218.cc2d766c7f9881c2afc48#192\",\n    );\n    // - exp_diff == prec in add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest in add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest && power && !carry in\n    //   add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest && !power in add_float_significands_same_prec_ge_3w\n    test(\n        \"4.0635838402455207229400698207668893925379768151364313942222e-23\",\n        \"0x3.1202ecf10ff40b477337957dede18bd7b746884ec977474eE-19#194\",\n        \"1174582238252884689829665592721065057.76655867827770290150723\",\n        \"0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d4#194\",\n        \"1174582238252884689829665592721065057.76655867827770290150729\",\n        \"0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d8#194\",\n    );\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && (sticky_bit != 0 || out[0] &\n    //   shift_bit != 0) && carry in add_float_significands_same_prec_ge_3w\n    test(\n        \"4.336808689942017736029811203479766845699938816177735095446e-19\",\n        \"0x7.fffffffffffffffffffffffffffffffe0000000000000000E-16#192\",\n        \"5192296858534827628530496329220095.999999999999999999566319\",\n        \"0xffffffffffffffffffffffffffff.fffffffffffffff80000#192\",\n        \"5192296858534827628530496329220096.0\",\n        \"0x10000000000000000000000000000.00000000000000000000#192\",\n    );\n    // - exp_diff == prec && rm == Nearest && power && carry in\n    //   add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest && !power && carry in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"158456325028528675187087900671.99999999999999999999999999997\",\n        \"0x1ffffffffffffffffffffffff.fffffffffffffffffffffffe#192\",\n        \"2.5243548967072377773175314089049159349542605923488736152645e-29\",\n        \"0x1.fffffffffffffffffffffffffffffffffffffffffffffffeE-24#192\",\n        \"158456325028528675187087900672.0\",\n        \"0x2000000000000000000000000.000000000000000000000000#192\",\n    );\n    // - exp_diff == prec && rm == Nearest && power in add_float_significands_same_prec_ge_3w\n    test(\n        \"332306998926888516295359133097394175.99999997019767761230469\",\n        \"0x3ffffffff0007fffffffffffffffff.ffffff8000000000000#192\",\n        \"2.6469779601696885595885078146238811314105987548828125e-23\",\n        \"0x2.000000000000000000000000000000000000000000000000E-19#192\",\n        \"332306998926888516295359133097394175.99999997019767761230469\",\n        \"0x3ffffffff0007fffffffffffffffff.ffffff8000000000000#192\",\n    );\n\n    // - shift2 == 0 in add_float_significands_same_prec_general\n    // - y in add_float_significands_same_prec_general\n    // - shift != 0 in add_float_significands_same_prec_general\n    // - x == 0 first time in add_float_significands_same_prec_general\n    // - shift == 0 || following_bits != Uninitialized in add_float_significands_same_prec_general\n    // - round_bit != Uninitialized || shift == 0 in add_float_significands_same_prec_general\n    // - exp_diff_rem == 0 && yi == 0 second time in add_float_significands_same_prec_general\n    // - round_bit != Uninitialized sixth time in add_float_significands_same_prec_general\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\");\n    // - following_bits != False || round_bit != False in\n    //   add_float_significands_same_prec_general_round\n    // - rm == Nearest in add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits == False in add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit == 0 in\n    //   add_float_significands_same_prec_general_round\n    test(\"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", \"2.0\", \"0x2.0#2\");\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit != 0 in\n    //   add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit != 0 && carry in\n    //   add_float_significands_same_prec_general_round\n    test(\"2.0\", \"0x2.0#1\", \"1.5\", \"0x1.8#2\", \"4.0\", \"0x4.0#2\");\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit != 0 && !carry in\n    //   add_float_significands_same_prec_general_round\n    test(\"1.0\", \"0x1.0#1\", \"1.8\", \"0x1.c#3\", \"3.0\", \"0x3.0#3\");\n    // - x != 0 && x != mask second time in add_float_significands_same_prec_general\n    // - rm == Nearest && following_bits != False && round_bit != False in\n    //   add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits != False && round_bit != False && !carry in\n    //   add_float_significands_same_prec_general_round\n    test(\"1.5\", \"0x1.8#2\", \"4.0\", \"0x4.0#1\", \"6.0\", \"0x6.0#2\");\n    // - rm == Nearest && following_bits != False && round_bit == False in\n    //   add_float_significands_same_prec_general_round\n    test(\"4.0\", \"0x4.0#1\", \"1.2\", \"0x1.4#3\", \"5.0\", \"0x5.0#3\");\n    // - x != 0 && x != mask first time in add_float_significands_same_prec_general\n    // - shift != 0 && following_bits == Uninitialized in add_float_significands_same_prec_general\n    test(\"1.2\", \"0x1.4#3\", \"3.0\", \"0x3.0#2\", \"4.0\", \"0x4.0#3\");\n    // - rm == Nearest && following_bits != False && round_bit != False && carry in\n    //   add_float_significands_same_prec_general_round\n    test(\"1.8\", \"0x1.c#3\", \"6.0\", \"0x6.0#2\", \"8.0\", \"0x8.0#3\");\n    // - out_bits <= exp_diff in add_float_significands_same_prec_general\n    // - out_len <= xs_len first time in add_float_significands_same_prec_general\n    // - difw > 0 && difw > ys_len && exp_diff > out_bits in\n    //   add_float_significands_same_prec_general\n    // - round_bit != Uninitialized fifth time in add_float_significands_same_prec_general\n    test(\n        \"8.82188e11\",\n        \"0xc.d668E+9#18\",\n        \"9.75459983374e122\",\n        \"0x1.79c17f063aE+102#40\",\n        \"9.75459983374e122\",\n        \"0x1.79c17f063aE+102#40\",\n    );\n    // - out_len > xs_len first time in add_float_significands_same_prec_general\n    test(\n        \"2.8577648979177105962332201291018926848163080599637e-19\",\n        \"0x5.458a93bffa7b1c05bdd1c0552b60196746d9083cE-16#162\",\n        \"3.569720699507868e50\",\n        \"0xf.4400d3acf388E+41#51\",\n        \"3.5697206995078675404584127554321345196383736430592e50\",\n        \"0xf.4400d3acf3880000000000000000000000000000E+41#162\",\n    );\n    // - overlap > ys_len in add_float_significands_same_prec_general\n    // - out_len - k > overlap in add_float_significands_same_prec_general\n    // - difw <= 0 || difw <= ys_len in add_float_significands_same_prec_general\n    // - round_bit != Uninitialized fourth time in add_float_significands_same_prec_general\n    test(\n        \"29780282551.762684458936866363165\",\n        \"0x6ef0b0cb7.c33f49e84d21bb6040#104\",\n        \"0.00003945598947538\",\n        \"0x0.000295f62f36adb#46\",\n        \"29780282551.762723914926341743141\",\n        \"0x6ef0b0cb7.c341dfde7c58691040#104\",\n    );\n    // - out_len > xs_len second time in add_float_significands_same_prec_general\n    test(\n        \"1.07183972513958531257713938927815e-11\",\n        \"0xb.c8f5eafa12eb9821601f1dd6aeE-10#107\",\n        \"0.00374222828352849\",\n        \"0x0.00f5402c178824#46\",\n        \"0.00374222829424688982311482391965285\",\n        \"0x0.00f5402c235119eafa12eb9821602#107\",\n    );\n    // - exp_diff_rem == 0 second time in add_float_significands_same_prec_general\n    test(\n        \"5.19192095203e-15\",\n        \"0x1.761e097c5E-12#37\",\n        \"7.4e4\",\n        \"0x1.2E+4#5\",\n        \"73728.0\",\n        \"0x12000.00000#37\",\n    );\n    // - shift <= 1 in add_float_significands_same_prec_general\n    test(\n        \"15135.895602865542606017656527713819177465060416097749360065\",\n        \"0x3b1f.e5463ab9b599ce49b83c7988b324dc93ce50b2ed51a18#191\",\n        \"3.581529624499970047886732225242180736649e-8\",\n        \"0x9.9d355ad2b99a587727da095fa3226bf0E-7#130\",\n        \"15135.895602901357902262656228192686499717482223464235884113\",\n        \"0x3b1f.e5463b5388ef7b7551e200fb30c5728e007771ed51a18#191\",\n    );\n    // - round_bit == Uninitialized fourth time in add_float_significands_same_prec_general\n    // - round_bit == Uninitialized seventh time in add_float_significands_same_prec_general\n    test(\n        \"8.63643735016344467819174862798332593462e-6\",\n        \"0x0.000090e5374a001358c6606f968bf3813ad9#128\",\n        \"1.84904e-8\",\n        \"0x4.f6a6E-7#18\",\n        \"8.65492771851100147411665059026359937212e-6\",\n        \"0x0.00009134a1aa001358c6606f968bf3813ad9#128\",\n    );\n    // - round_bit == Uninitialized fifth time in add_float_significands_same_prec_general\n    test(\n        \"2.389545997e25\",\n        \"0x1.3c40f7bE+21#29\",\n        \"0.078263259824284000402\",\n        \"0x0.14090f9d6c745bc06#64\",\n        \"2.389545996756557709e25\",\n        \"0x1.3c40f7b000000000E+21#64\",\n    );\n    // - round_bit == Uninitialized seventh time in add_float_significands_same_prec_general\n    test(\n        \"5.7505515877842013577e-7\",\n        \"0x9.a5d7d56cabed47dE-6#64\",\n        \"1.1758894e-14\",\n        \"0x3.4f515E-12#22\",\n        \"5.7505517053731436845e-7\",\n        \"0x9.a5d7d8bbfd3d47dE-6#64\",\n    );\n    // - x != 0 && x == mask second time in add_float_significands_same_prec_general\n    // - xs_len <= out_len && following_bits == True in add_float_significands_same_prec_general\n    test(\n        \"1.081090215247020702e-18\",\n        \"0x1.3f14ddfe22c0634E-15#59\",\n        \"6.3799657596147e-8\",\n        \"0x1.12047722d26cE-6#47\",\n        \"6.37996575972280156e-8\",\n        \"0x1.12047722e65d4dcE-6#59\",\n    );\n    // - shift == 0 in add_float_significands_same_prec_general\n    test(\n        \"4.3055451539258443718732375731462554408177909736937057433067e-16\",\n        \"0x1.f06543668e6018c20c17efed72ff6d3d65a4c5dc9db475b0E-13#192\",\n        \"1.6388436e-15\",\n        \"0x7.61754E-13#21\",\n        \"2.0693980969049410047184094732421002104686218250305033868307e-15\",\n        \"0x9.51da83668e6018c20c17efed72ff6d3d65a4c5dc9db475bE-13#192\",\n    );\n    // - yi != 0 second time in add_float_significands_same_prec_general\n    test(\n        \"2.24181435676546e-16\",\n        \"0x1.0276ae5de1e8E-13#47\",\n        \"7.6430700039878539638425372386462404393e-36\",\n        \"0xa.28cd4cb186f5925ddb0d1ecb9681103E-30#128\",\n        \"2.24181435676546206911083333246297446029e-16\",\n        \"0x1.0276ae5de1e80000a28cd4cb186f5926E-13#128\",\n    );\n    // - x != 0 && x == mask first time in add_float_significands_same_prec_general\n    test(\n        \"2.1474796e9\",\n        \"0x7.ffff00E+7#24\",\n        \"8191.9998788833609\",\n        \"0x1fff.fff80fffff0#54\",\n        \"2147487743.9998789\",\n        \"0x80000fff.fff810#54\",\n    );\n\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.4E-268435456#3\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    test(\n        \"1.262113616894785778907e-31\",\n        \"0x2.8f53ace354a6b7284E-26#68\",\n        \"-1.26e-31\",\n        \"-0x2.90E-26#7\",\n        \"-1.296426623240940697535e-34\",\n        \"-0xa.c531cab5948d7c00E-29#68\",\n    );\n    test(\n        \"too_small\",\n        \"0x2.8f5E-268435454#14\",\n        \"-too_small\",\n        \"-0x2.900E-268435454#14\",\n        \"-too_small\",\n        \"-0x1.0000E-268435456#14\",\n    );\n    test(\n        \"-too_small\",\n        \"-0x2.8f5E-268435454#14\",\n        \"too_small\",\n        \"0x2.900E-268435454#14\",\n        \"too_small\",\n        \"0x1.0000E-268435456#14\",\n    );\n\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n    );\n}\n\n#[test]\nfn test_add_prec() {\n    let test = |s, s_hex, t, t_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (sum, o) = x.clone().add_prec(y.clone(), prec);\n        assert!(sum.is_valid());\n\n        assert_eq!(sum.to_string(), out);\n        assert_eq!(to_hex_string(&sum), out_hex);\n        assert_eq!(o, o_out);\n\n        let (sum_alt, o_alt) = x.clone().add_prec_val_ref(&y, prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = x.add_prec_ref_val(y.clone(), prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = x.add_prec_ref_ref(&y, prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_prec_assign(y.clone(), prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_prec_assign_ref(&y, prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = add_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n\n        let (rug_sum, rug_o) = rug_add_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sum)),\n            ComparableFloatRef(&sum)\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        2,\n        \"3.0\",\n        \"0x3.0#2\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    // - xs_len > out_len in add_float_significands_same_prec_general\n    // - following_bits != False || difw > 0 in add_float_significands_same_prec_general\n    // - difw <= ys_len in add_float_significands_same_prec_general\n    // - exp_diff_rem != 0 || yi != 0 first time in add_float_significands_same_prec_general\n    // - yi >= 0 && yi == ys_len in add_float_significands_same_prec_general\n    // - following_bits != Uninitialized first time in add_float_significands_same_prec_general\n    // - exp_diff_rem != 0 first time in add_float_significands_same_prec_general\n    // - yi >= 0 second time in add_float_significands_same_prec_general\n    // - yi >= 0 third time in add_float_significands_same_prec_general\n    // - x >= y in add_float_significands_same_prec_general\n    // - following_bits != False || x == 0 in add_float_significands_same_prec_general\n    // - following_bits != False && x != Limb::MAX second time in\n    //   add_float_significands_same_prec_general\n    test(\n        \"1.73414747294406e-17\",\n        \"0x1.3fe4cc8cf520E-14#48\",\n        \"5095194424.1679374580403939884785489\",\n        \"0x12fb27f38.2afdf3020e8eaac84a7ec#116\",\n        62,\n        \"5095194424.167937458\",\n        \"0x12fb27f38.2afdf300#62\",\n        Less,\n    );\n    // - yi < 0 || yi != ys_len in add_float_significands_same_prec_general\n    // - yi < 0 third time in add_float_significands_same_prec_general\n    test(\n        \"102490490.309858195\",\n        \"0x61be17a.4f52dde#54\",\n        \"140024642456267714260687682888.7395345704093208802906032076327334\",\n        \"0x1c471ab65a12bae8410f87d48.bd52233a2b6095a9fa45bd79bbfc#209\",\n        126,\n        \"140024642456267714260790173379.049392765\",\n        \"0x1c471ab65a12bae8417145ec3.0ca50118#126\",\n        Less,\n    );\n    // - following_bits != 0 && following_bits != Limb::MAX in\n    //   add_float_significands_same_prec_general\n    // - x != Limb::MAX first time in add_float_significands_same_prec_general\n    test(\n        \"3.6587e-6\",\n        \"0x0.00003d62#14\",\n        \"2.26998937985590408943624715555e46\",\n        \"0x3.f9e6004fa97f534f98cad274E+38#96\",\n        61,\n        \"2.269989379855904089e46\",\n        \"0x3.f9e6004fa97f534E+38#61\",\n        Less,\n    );\n    // - following_bits == Uninitialized first time in add_float_significands_same_prec_general\n    // - exp_diff_rem != 0 in add_float_significands_same_prec_general\n    // - yi < 0 first time in add_float_significands_same_prec_general\n    // - x >= y or not other conditions in add_float_significands_same_prec_general\n    // - round_bit == Limb::MAX second time in add_float_significands_same_prec_general\n    // - following_bits != False && x != Limb::MAX first time in\n    //   add_float_significands_same_prec_general\n    test(\n        \"6058.05208272591415306446968882359605946955168456454\",\n        \"0x17aa.0d554b247ce1b6ab28ba39c8d5992a74c7ac91a#169\",\n        \"0.000144566892208323\",\n        \"0x0.0009796e12f9784#47\",\n        64,\n        \"6058.0522272928063612\",\n        \"0x17aa.0d5ec4928fdb2#64\",\n        Less,\n    );\n    // - following_bits == True in add_float_significands_same_prec_general\n    // - round_bit == Uninitialized first time in add_float_significands_same_prec_general\n    // - x != Limb::MAX second time in add_float_significands_same_prec_general\n    test(\n        \"3.6596517369110659089355442395654891585e48\",\n        \"0x2.810875a0ca3206afd8c6cf841941830E+40#123\",\n        \"1545.699550397407201099813420288295\",\n        \"0x609.b315bc1ec48a143a74bd53048#109\",\n        64,\n        \"3.6596517369110659089e48\",\n        \"0x2.810875a0ca3206b0E+40#64\",\n        Greater,\n    );\n    // - yi >= 0 first time in add_float_significands_same_prec_general\n    test(\n        \"2.80915429604669102593383052436808885401854724410738829e-11\",\n        \"0x1.ee310ffa09a06a6361f52c2cd8a9569a780b775dc213E-9#177\",\n        \"519241072363118296470.333928838103121952666621563036\",\n        \"0x1c25eadc41d4907d96.557c5c3ed81cab65dab0cf920#166\",\n        64,\n        \"5.1924107236311829648e20\",\n        \"0x1.c25eadc41d4907daE+17#64\",\n        Greater,\n    );\n    // - round_bit != Uninitialized second time in add_float_significands_same_prec_general\n    test(\n        \"559935046210054011882951826578284118061013900.5853448\",\n        \"0x191bbd3588c78488c2f4d122814d5fb34edb8c.95d928#170\",\n        \"3.027932e11\",\n        \"0x4.67fe2E+9#22\",\n        63,\n        \"5.599350462100540119e44\",\n        \"0x1.91bbd3588c78488cE+37#63\",\n        Less,\n    );\n    // - following_bits == False && difw <= 0 in add_float_significands_same_prec_general\n    test(\n        \"7184368264698708563285024670194469326968686224.86386349506591\",\n        \"0x1422880c600dc4fd90a02f1814859aafd658690.dd2628738430#198\",\n        \"1.0296060328202e-24\",\n        \"0x1.3ea5cb49bdaE-20#44\",\n        61,\n        \"7.184368264698708565e45\",\n        \"0x1.422880c600dc4feE+38#61\",\n        Greater,\n    );\n    // - following_bits == False && x != 0 in add_float_significands_same_prec_general\n    test(\n        \"19710666.821984898059985706849\",\n        \"0x12cc2ca.d26d9a2ef9396c5108#94\",\n        \"7.0e4\",\n        \"0x1.0E+4#2\",\n        61,\n        \"19776202.82198489807\",\n        \"0x12dc2ca.d26d9a2f0#61\",\n        Greater,\n    );\n    // - round_bit != Uninitialized first time in add_float_significands_same_prec_general\n    test(\n        \"2.3370796820961060045359802932823709e39\",\n        \"0x6.de392c9978b4267553b428865de8E+32#112\",\n        \"1.187719715482312494e-58\",\n        \"0xb.edbf4827e1e28aaE-49#64\",\n        63,\n        \"2.3370796820961060044e39\",\n        \"0x6.de392c9978b4267E+32#63\",\n        Less,\n    );\n    // - difw > ys_len in add_float_significands_same_prec_general\n    // - difw > ys_len || goto_c_read in add_float_significands_same_prec_general\n    // - following_bits != Uninitialized second time in add_float_significands_same_prec_general\n    // - following_bits == False second time in add_float_significands_same_prec_general\n    // - xs[xi] != 0 in add_float_significands_same_prec_general\n    test(\n        \"1248577957.9617995883835430866672787859939813175787209064549678049868\",\n        \"0x4a6bc9a5.f6387f7169e05140ece8db047baba25ac8c576b8fed10fa4#221\",\n        \"1.65314121012e-6\",\n        \"0x0.00001bbc2ffb9e#36\",\n        126,\n        \"1248577957.96180124152475320394882420796\",\n        \"0x4a6bc9a5.f6389b2d99dbef40ece8db04#126\",\n        Less,\n    );\n    // - x < y in add_float_significands_same_prec_general\n    // - following_bits == False first time in add_float_significands_same_prec_general\n    // - round_bit != False or not other condition in add_float_significands_same_prec_general\n    test(\n        \"1.85445e-25\",\n        \"0x3.9648E-21#15\",\n        \"1.2975739042614492272769355049909712560463719657882671587557999636387971206e-6\",\n        \"0x0.000015c509987b7b0dbb1bf2aae59a4afde515d3ec2c3af539738e362659e1f1b0#243\",\n        62,\n        \"1.2975739042614492276e-6\",\n        \"0x0.000015c509987b7b0dbb8#62\",\n        Greater,\n    );\n    // - following_bits == Uninitialized second time in add_float_significands_same_prec_general\n    // - round_bit == Uninitialized third time in add_float_significands_same_prec_general\n    // - following_bits != False second time in add_float_significands_same_prec_general\n    test(\n        \"1.3111820218254081035114504135472568116036464005e-6\",\n        \"0x0.000015ff7be10e865ada82cd25acef5baa9c89c25f4#152\",\n        \"2.51465891601e-20\",\n        \"0x7.6c05c64a8E-17#38\",\n        128,\n        \"1.311182021825433250100610518712675662596e-6\",\n        \"0x0.000015ff7be10e86d19adf31cdacef5baa9c8#128\",\n        Less,\n    );\n    // - following_bits == False || x == Limb::MAX second time in\n    //   add_float_significands_same_prec_general\n    // - !goto_c_read in add_float_significands_same_prec_general\n    // - following_bits != False || yi < 0 in add_float_significands_same_prec_general\n    test(\n        \"7.9999999999995452526491135358810425\",\n        \"0x7.ffffffffff800000000000000000#114\",\n        \"0.0039062797764\",\n        \"0x0.0100007fe38#34\",\n        49,\n        \"8.00390627977595\",\n        \"0x8.0100007fe300#49\",\n        Equal,\n    );\n    // - following_bits != False first time in add_float_significands_same_prec_general\n    test(\n        \"2.89901505570589585435e-11\",\n        \"0x1.fe0007ffc00000000E-9#67\",\n        \"134217728.00000381469725\",\n        \"0x8000000.00003ffffffc#74\",\n        51,\n        \"134217728.0000038\",\n        \"0x8000000.000040#51\",\n        Less,\n    );\n    // - yi < 0 second time in add_float_significands_same_prec_general;\n    // - goto_c_read in add_float_significands_same_prec_general\n    test(\n        \"4.4474794e-47\",\n        \"0x4.0ffff0E-39#25\",\n        \"7.523135146670945963453530822847271532226579417449854573285752516755e-37\",\n        \"0xf.fffc000001fffffffffffffffffffffffffffc03fffffffc001ffeE-31#219\",\n        57,\n        \"7.52313514711569391e-37\",\n        \"0xf.fffc000411fff0E-31#57\",\n        Greater,\n    );\n    // - round_bit == False and other condition in add_float_significands_same_prec_general\n    test(\n        \"1048575.9999999999999999965\",\n        \"0xfffff.ffffffffffffffc0#81\",\n        \"1.1102230204892534781399170051165479471979625e-16\",\n        \"0x7.ffffff800000003ffe000001fffffffc0000E-14#145\",\n        48,\n        \"1048576.0\",\n        \"0x100000.0000000#48\",\n        Less,\n    );\n    // - x == Limb::MAX first time in add_float_significands_same_prec_general\n    // - xi != 0 in add_float_significands_same_prec_general\n    test(\n        \"3.810971975326539e-6\",\n        \"0x0.00003ff00000000004#52\",\n        \"4.90398573077084434674671048688098938757996518e55\",\n        \"0x1.ffffffffffffffffffffffffffffffffffffeE+46#148\",\n        21,\n        \"4.903986e55\",\n        \"0x2.00000E+46#21\",\n        Greater,\n    );\n    // - xs[xi] == 0 in add_float_significands_same_prec_general\n    test(\n        \"135.998\",\n        \"0x87.ff8#19\",\n        \"8796093087743.998046875\",\n        \"0x8000000ffff.ff80000000000000000000000000000#168\",\n        114,\n        \"8796093087879.99609375\",\n        \"0x80000010087.ff0000000000000000#114\",\n        Equal,\n    );\n    // - following_bits == False && yi >= 0 in add_float_significands_same_prec_general\n    // - exp_diff_rem != 0 && y_prec << (Limb::WIDTH - exp_diff_rem) != 0 in\n    //   add_float_significands_same_prec_general\n    test(\n        \"4610525002867933183.9999999999998\",\n        \"0x3ffbe00fffffffff.ffffffffffc#104\",\n        \"2.27373688992450493e-13\",\n        \"0x4.000003ffc00000E-11#58\",\n        47,\n        \"4.61052500286793e18\",\n        \"0x3.ffbe01000000E+15#47\",\n        Less,\n    );\n    // - exp_diff_rem == 0 first time in add_float_significands_same_prec_general\n    test(\n        \"199484.9246647061832808582\",\n        \"0x30b3c.ecb6d380d2988d78#79\",\n        \"9.2945767606483e-15\",\n        \"0x2.9dbeadc4568E-12#45\",\n        63,\n        \"199484.92466470618328\",\n        \"0x30b3c.ecb6d380d298#63\",\n        Less,\n    );\n    // - exp_diff_rem == 0 || y_prec << (Limb::WIDTH - exp_diff_rem) == 0 in\n    //   add_float_significands_same_prec_general\n    // - difw <= ys_len && !goto_c_read in add_float_significands_same_prec_general\n    test(\n        \"128.000244140566792339087\",\n        \"0x80.000fffffc00000000#75\",\n        \"7.5\",\n        \"0x7.800000000000000000000#87\",\n        60,\n        \"135.5002441405667923\",\n        \"0x87.800fffffc0000#60\",\n        Equal,\n    );\n    // - exp_diff_rem == 0 second time in add_float_significands_same_prec_general\n    // - yi != 0 first time in add_float_significands_same_prec_general\n    test(\n        \"127.9999999999999997744859485366053840029607161188794193511\",\n        \"0x7f.ffffffffffffefc000007fffffffffff0000000001e000#190\",\n        \"64.0000000000000000000000000000000000000000000000410536659471\",\n        \"0x40.000000000000000000000000000000000000003c000000008#200\",\n        90,\n        \"191.9999999999999997744859485\",\n        \"0xbf.ffffffffffffefc000008#90\",\n        Greater,\n    );\n    // - following_bits == False || x == Limb::MAX first time in\n    //   add_float_significands_same_prec_general\n    test(\n        \"1927941831.98168915743\",\n        \"0x72ea0ec7.fb4ffb0a0#65\",\n        \"10702647.0\",\n        \"0xa34f37.0#24\",\n        63,\n        \"1938644478.9816891574\",\n        \"0x738d5dfe.fb4ffb0a#63\",\n        Equal,\n    );\n    // - round_bit == Uninitialized sixth time in add_float_significands_same_prec_general\n    test(\n        \"8.69134330408049e-16\",\n        \"0x3.ea0b2d4be674E-13#48\",\n        \"15492.756587362761273446\",\n        \"0x3c84.c1afb59ba066160#71\",\n        128,\n        \"15492.75658736276127431557748582959734014\",\n        \"0x3c84.c1afb59ba06654a0b2d4be6740000#128\",\n        Equal,\n    );\n    // - ys[yi] != 0 in add_float_significands_same_prec_general\n    test(\n        \"2.384181243542116135358810424804687500000000000000000024885983948e-7\",\n        \"0x3.ffff8000000000000000000000000000000000000003ffc00000E-6#210\",\n        \"1.5\",\n        \"0x1.8000000000000000000#75\",\n        55,\n        \"1.50000023841812435\",\n        \"0x1.800003ffff8000#55\",\n        Less,\n    );\n    // - x == Limb::MAX second time in add_float_significands_same_prec_general\n    test(\n        \"98079714615416886934934209737619787751599303785390800896.0002441405\",\n        \"0x3fffffffffffffffffffffffffffffffffffff800000000.000fffff8#219\",\n        \"5.8207660907e-11\",\n        \"0x3.fffffffe0E-9#35\",\n        63,\n        \"9.807971461541688693e55\",\n        \"0x4.000000000000000E+46#63\",\n        Greater,\n    );\n    // - xi == 0 in add_float_significands_same_prec_general\n    test(\n        \"2.996272864212510369e-95\",\n        \"0x3.fffffff00000000E-79#60\",\n        \"1.49012180372665170580148696899414062499e-8\",\n        \"0x4.0000fffffffffffffffffffffffffff8E-7#128\",\n        27,\n        \"1.4901218e-8\",\n        \"0x4.000100E-7#27\",\n        Greater,\n    );\n    // - x < y and other conditions in add_float_significands_same_prec_general\n    test(\n        \"0.00024414062499999999999999979805160826342\",\n        \"0x0.000ffffffffffffffffffff00000000000#124\",\n        \"1.32348897761965396e-23\",\n        \"0xf.ffffff80000008E-20#57\",\n        63,\n        \"0.000244140625\",\n        \"0x0.0010000000000000000#63\",\n        Less,\n    );\n    // - ys[yi] == 0 in add_float_significands_same_prec_general\n    test(\n        \"0.99951171875\",\n        \"0x0.ffe00000000000000000000#92\",\n        \"0.017578124999996447286321199499070644378662109375\",\n        \"0x0.047fffffffff00000000000000000000000000000000000000000000#217\",\n        48,\n        \"1.01708984375\",\n        \"0x1.046000000000#48\",\n        Greater,\n    );\n    // - yi == 0 first time in add_float_significands_same_prec_general\n    test(\n        \"67108864.000000000000000000027105054312137610850186320021748542784370058\",\n        \"0x4000000.00000000000000007ffffffffffffffffffffffffffffff800000#236\",\n        \"3.63797880709171295166015625e-12\",\n        \"0x4.000000000000000000000E-10#86\",\n        103,\n        \"67108864.0000000000036379788342\",\n        \"0x4000000.0000000004000000800#103\",\n        Greater,\n    );\n    test(\n        \"3.91923414751995775967065104797896464447978457860112833061347e-17\",\n        \"0x2.d2f8998a5fa796b9de129923cf4d51e04f27e6b6a368fadb0E-14#197\",\n        \"2.75164948336014612968759798085025748008e-17\",\n        \"0x1.fb96f911d37dd9fe4933cbeee25d7ddeE-14#128\",\n        8,\n        \"6.68e-17\",\n        \"0x4.d0E-14#8\",\n        Greater,\n    );\n\n    test(\n        \"-too_small\",\n        \"-0x2.50888E-268435456#19\",\n        \"too_small\",\n        \"0x3.10E-268435456#10\",\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x3.10E-268435456#10\",\n        \"too_small\",\n        \"0x2.50888E-268435456#19\",\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\nfn add_prec_fail() {\n    assert_panic!(Float::NAN.add_prec(Float::NAN, 0));\n    assert_panic!(Float::NAN.add_prec_val_ref(&Float::NAN, 0));\n    assert_panic!(Float::NAN.add_prec_ref_val(Float::NAN, 0));\n    assert_panic!(Float::NAN.add_prec_ref_ref(&Float::NAN, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.add_prec_assign(Float::NAN, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.add_prec_assign_ref(&Float::NAN, 0)\n    });\n}\n\n#[test]\nfn test_add_round() {\n    let test = |s, s_hex, t, t_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (sum, o) = x.clone().add_round(y.clone(), rm);\n        assert!(sum.is_valid());\n\n        assert_eq!(sum.to_string(), out);\n        assert_eq!(to_hex_string(&sum), out_hex);\n        assert_eq!(o, o_out);\n\n        let (sum_alt, o_alt) = x.clone().add_round_val_ref(&y, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = x.add_round_ref_val(y.clone(), rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = x.add_round_ref_ref(&y, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_round_assign(y.clone(), rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_round_assign_ref(&y, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sum, rug_o) =\n                rug_add_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sum)),\n                ComparableFloatRef(&sum),\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (sum_alt, o_alt) = add_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    // Note different behavior for Floor\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    // - (round_bit != 0 || sticky_bit == 0) && (rm == Floor || rm == Down) in\n    //   add_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    // - (round_bit != 0 || sticky_bit == 0) && (rm == Ceiling || rm == Up) in\n    //   add_float_significands_same_prec_lt_w\n    // - (rm == Ceiling || rm == Up) && sum == 0 in add_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) && sum != 0 in add_float_significands_same_prec_lt_w\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"4.555806215962889\",\n        \"0x4.8e4950f079600#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"4.555806215962889\",\n        \"0x4.8e4950f079600#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Exact,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Exact,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"-4.555806215962889\",\n        \"-0x4.8e4950f079600#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-4.555806215962888\",\n        \"-0x4.8e4950f0795fc#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"-4.555806215962888\",\n        \"-0x4.8e4950f0795fc#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"-4.555806215962889\",\n        \"-0x4.8e4950f079600#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"-4.555806215962889\",\n        \"-0x4.8e4950f079600#53\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    // - x_exp > y_exp in add_float_significands_same_prec_lt_w\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    // - x_exp == y_exp in add_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Nearest, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    // - rm == Nearest && sum != 0 in add_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#3\", \"1.8\", \"0x1.c#3\", Nearest, \"3.0\", \"0x3.0#3\", Greater,\n    );\n    // - exp_diff >= Limb::WIDTH in add_float_significands_same_prec_lt_w\n    test(\n        \"7.7e14\",\n        \"0x2.bcE+12#8\",\n        \"1.237e-9\",\n        \"0x5.50E-8#8\",\n        Nearest,\n        \"7.7e14\",\n        \"0x2.bcE+12#8\",\n        Less,\n    );\n    // - shift <= exp_diff < Limb::WIDTH in add_float_significands_same_prec_lt_w\n    // - shift <= exp_diff < Limb::WIDTH && !overflow in add_float_significands_same_prec_lt_w\n    test(\n        \"1.852193494e22\",\n        \"0x3.ec137baE+18#29\",\n        \"241425944.0\",\n        \"0xe63de18.0#29\",\n        Nearest,\n        \"1.852193494e22\",\n        \"0x3.ec137baE+18#29\",\n        Less,\n    );\n    test(\n        \"1.999999999999993\",\n        \"0x1.fffffffffffe#48\",\n        \"5.96046447753906e-8\",\n        \"0x1.000000000000E-6#48\",\n        Nearest,\n        \"2.00000005960464\",\n        \"0x2.000001000000#48\",\n        Greater,\n    );\n\n    // - in add_float_significands_same_prec_w\n    // - x_exp == y_exp in add_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Equal,\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_w\n    // - !overflow in add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Nearest,\n        \"3.0\",\n        \"0x3.0000000000000000#64\",\n        Equal,\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"3.0\",\n        \"0x3.0000000000000000#64\",\n        Equal,\n    );\n    // - (round_bit != 0) || (sticky_bit != 0) && rm == Nearest in\n    //   add_float_significands_same_prec_w\n    // - round_bit == 0 || (sticky_bit == 0 && (sum & 1) == 0) in add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Less,\n    );\n    // - round_bit != 0 && (sticky_bit != 0 || (sum & 1) != 0) in add_float_significands_same_prec_w\n    // - round_bit != 0 && (sticky_bit != 0 || (sum & 1) != 0) and !overflow in\n    //   add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000003\",\n        \"0x1.0000000000000006#64\",\n        Nearest,\n        \"2.0000000000000000004\",\n        \"0x2.0000000000000008#64\",\n        Greater,\n    );\n    // - exp_diff >= Limb::WIDTH in add_float_significands_same_prec_w\n    test(\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n        \"2.9347251290514630352e-45\",\n        \"0x1.0c11b075f03d6daeE-37#64\",\n        Nearest,\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n        Less,\n    );\n    // - overflow in add_float_significands_same_prec_w\n    test(\n        \"0.00022185253582909293959\",\n        \"0x0.000e8a1162cbb1a4265#64\",\n        \"0.000029745661521717034001\",\n        \"0x0.0001f30ca4b8117ff0a0#64\",\n        Nearest,\n        \"0.0002515981973508099736\",\n        \"0x0.00107d1e0783c324170#64\",\n        Greater,\n    );\n    // - round_bit != 0 && (sticky_bit != 0 || (sum & 1) != 0) and overflow in\n    //   add_float_significands_same_prec_w\n    test(\n        \"63.999999999999999997\",\n        \"0x3f.ffffffffffffffc#64\",\n        \"64.0\",\n        \"0x40.000000000000000#64\",\n        Nearest,\n        \"128.0\",\n        \"0x80.00000000000000#64\",\n        Greater,\n    );\n\n    // - (round_bit != 0) || (sticky_bit != 0) && (rm == Floor || rm == Down) in\n    //   add_float_significands_same_prec_w\n    // - (round_bit != 0) || (sticky_bit != 0) && (rm == Floor || rm == Down) && sum != 0 in\n    //   add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Down,\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Less,\n    );\n    // - (round_bit != 0) || (sticky_bit != 0) && (rm == Ceiling || rm == Up) in\n    //   add_float_significands_same_prec_w\n    // - (round_bit != 0) || (sticky_bit != 0) && (rm == Ceiling || rm == Up) && sum != 0 in\n    //   add_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Up,\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#64\",\n        Greater,\n    );\n    // - (round_bit != 0) || (sticky_bit != 0) && (rm == Ceiling || rm == Up) && sum == 0 in\n    //   add_float_significands_same_prec_w\n    test(\n        \"536870911.99999999997\",\n        \"0x1fffffff.ffffffffe#64\",\n        \"1.00974195868289511071e-28\",\n        \"0x7.ffffffffffffffe0E-24#64\",\n        Up,\n        \"536870912.0\",\n        \"0x20000000.000000000#64\",\n        Greater,\n    );\n\n    // - in add_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp in add_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Equal,\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff < Limb::WIDTH && !overflow in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Nearest,\n        \"3.0\",\n        \"0x3.0000000000000000#65\",\n        Equal,\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"3.0\",\n        \"0x3.0000000000000000#65\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in add_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in add_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (sum_0 != 0 || sum_1 != 0) in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Less,\n    );\n    // - rm == Nearest && sum_1 != 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        Nearest,\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#65\",\n        Greater,\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && !overflow in\n    //   add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        \"18.63123034252626794758647\",\n        \"0x12.a1984fcd64a8ae228eef#85\",\n        Nearest,\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        Less,\n    );\n    // - exp_diff >= Limb::WIDTH * 2 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n        \"1.14823551075108882469e-96\",\n        \"0x2.73dea72af3fe6314E-80#65\",\n        Nearest,\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n        Less,\n    );\n    // - exp_diff == Limb::WIDTH in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"19585.2851423168986928116147584507795\",\n        \"0x4c81.48ff163dc91a0d4bd90309b0f8#116\",\n        \"372369974082165972902790.766638151683\",\n        \"0x4eda377c7f0d747fa386.c44265dd58#116\",\n        Nearest,\n        \"372369974082165972922376.05178046858\",\n        \"0x4eda377c7f0d747ff008.0d417c1b20#116\",\n        Less,\n    );\n    // - exp_diff < Limb::WIDTH && overflow in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"18.492649216180435830000529\",\n        \"0x12.7e1e424fe51f1bb914c0#85\",\n        \"56.637589789906471403844847\",\n        \"0x38.a339159fe96c1722fdfe#85\",\n        Nearest,\n        \"75.130239006086907233845378\",\n        \"0x4b.215757efce8b32dc12c0#85\",\n        Greater,\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && overflow in\n    //   add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"5.29395592276605355108231857701752e-23\",\n        \"0x4.00000007e000fffffff0000000E-19#107\",\n        \"255.999999999999999999999947060441\",\n        \"0xff.ffffffffffffffffffc000000#107\",\n        Nearest,\n        \"256.0\",\n        \"0x100.0000000000000000000000000#107\",\n        Less,\n    );\n    // - rm == Nearest && sum_1 == 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"0.0000610351562499999999996\",\n        \"0x0.0003ffffffffffffffff8#67\",\n        \"17179869183.9999389648\",\n        \"0x3ffffffff.fffc00000#67\",\n        Nearest,\n        \"17179869184.0\",\n        \"0x400000000.00000000#67\",\n        Greater,\n    );\n\n    // - rm == Floor || rm == Down in add_float_significands_same_prec_gt_w_lt_2w\n    // - (rm == Floor || rm == Down) && (sum_0 != 0 || sum_1 != 0) in\n    //   add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Floor,\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in add_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Ceiling || rm == Up && sum_1 != 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Ceiling,\n        \"2.0000000000000000001\",\n        \"0x2.0000000000000002#65\",\n        Greater,\n    );\n    // - rm == Ceiling || rm == Up && sum_1 == 0 in add_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.9999999999999999999999998\",\n        \"0x1.ffffffffffffffffffffc#83\",\n        \"2.4074118565121938372272894e-35\",\n        \"0x1.fffff8000000007fffff8E-29#83\",\n        Ceiling,\n        \"2.0\",\n        \"0x2.000000000000000000000#83\",\n        Greater,\n    );\n\n    // - in add_float_significands_same_prec_2w\n    // - x_exp == y_exp in add_float_significands_same_prec_2w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        Nearest,\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        Equal,\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_2w\n    // - exp_diff < TWICE_WIDTH in add_float_significands_same_prec_2w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_2w\n    // - exp_diff < TWICE_WIDTH && !overflow in add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#128\",\n        Equal,\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_2w\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#128\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in add_float_significands_same_prec_2w\n    // - rm == Nearest in add_float_significands_same_prec_2w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (sum_0 & 1) == 0)) in\n    //   add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        Nearest,\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (sum_0 & 1) != 0) in\n    //   add_float_significands_same_prec_2w\n    // - rm == Nearest && !overflow in add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000018\",\n        \"0x1.00000000000000000000000000000006#128\",\n        Nearest,\n        \"2.00000000000000000000000000000000000002\",\n        \"0x2.00000000000000000000000000000008#128\",\n        Greater,\n    );\n    // - exp_diff >= TWICE_WIDTH in add_float_significands_same_prec_2w\n    // - exp_diff > TWICE_WIDTH in add_float_significands_same_prec_2w\n    test(\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n        \"5.07801249136957145270807726205511855421e-45\",\n        \"0x1.cfd8608b7c32de2bbcfecf8bcf8a2d00E-37#128\",\n        Nearest,\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n        Less,\n    );\n    // - Limb::WIDTH <= exp_diff < TWICE_WIDTH in add_float_significands_same_prec_2w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH in add_float_significands_same_prec_2w\n    test(\n        \"4354249796990942.35435357526597783143164\",\n        \"0xf782ac869b7de.5ab6ea78fcf0cc5079f#128\",\n        \"8.03239453825726512240307053405256016022e-10\",\n        \"0x3.732bce7aa121827a284545a25f32dc68E-8#128\",\n        Nearest,\n        \"4354249796990942.35435357606921728525736\",\n        \"0xf782ac869b7de.5ab6ea7c701c9acb1b1#128\",\n        Less,\n    );\n    // - exp_diff == TWICE_WIDTH in add_float_significands_same_prec_2w\n    test(\n        \"15732412727332569995335732833027757624.44\",\n        \"0xbd5f3d586bc01069a1d94f5ab5a1638.7#128\",\n        \"0.0373708302820085888760745841639896128921\",\n        \"0x0.0991227de2b63edc67164401ce8ebdb04#128\",\n        Nearest,\n        \"15732412727332569995335732833027757624.5\",\n        \"0xbd5f3d586bc01069a1d94f5ab5a1638.8#128\",\n        Greater,\n    );\n    // - Limb::WIDTH == exp_diff in add_float_significands_same_prec_2w\n    test(\n        \"1.057437459917463716438672572710788562701e-17\",\n        \"0xc.310127aae1df1a1cb12f60c4d339d76E-15#128\",\n        \"148.0549133677002965445211858794413066474\",\n        \"0x94.0e0ecd6e62d0a8c7c7c2a633277e3e#128\",\n        Nearest,\n        \"148.054913367700296555095560478615943812\",\n        \"0x94.0e0ecd6e62d0a98ad7d520e1456fe0#128\",\n        Greater,\n    );\n    // - exp_diff < TWICE_WIDTH && overflow in add_float_significands_same_prec_2w\n    test(\n        \"990.890284854484258981204316304960898664\",\n        \"0x3de.e3e9b54e224e900a8701c94cea27bc#128\",\n        \"111.972242543885876168914754084523121772\",\n        \"0x6f.f8e4e329c509f04b7f9497ec8ce6438#128\",\n        Nearest,\n        \"1102.862527398370135150119070389484020437\",\n        \"0x44e.dcce9877e758805606966139770e00#128\",\n        Greater,\n    );\n    // - rm == Nearest && overflow in add_float_significands_same_prec_2w\n    test(\n        \"1152920954851033088.0\",\n        \"0xfffff8000000000.00000000000000000#128\",\n        \"549755813887.999999999999999999999999998\",\n        \"0x7fffffffff.ffffffffffffffffffffff8#128\",\n        Nearest,\n        \"1152921504606846976.0\",\n        \"0x1000000000000000.00000000000000000#128\",\n        Greater,\n    );\n    // - rm == Floor || m == Down in add_float_significands_same_prec_2w\n    // - (rm == Floor || m == Down) && (sum_0 != 0 || sum_1 != 0) in\n    //   add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        Floor,\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        Less,\n    );\n    // - rm == Ceiling || m == Up in add_float_significands_same_prec_2w\n    // - (rm == Ceiling || m == Up) && !overflow in add_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        Ceiling,\n        \"2.00000000000000000000000000000000000001\",\n        \"0x2.00000000000000000000000000000004#128\",\n        Greater,\n    );\n    // - (rm == Ceiling || m == Up) && overflow in add_float_significands_same_prec_2w\n    test(\n        \"69631.9999999850988390281969486491823076\",\n        \"0x10fff.ffffffc000000ffffffff80007fc#128\",\n        \"1.255420347077336152767157884641533283217e58\",\n        \"0x1.fffffffffffffffffffffffffffffffeE+48#128\",\n        Ceiling,\n        \"1.25542034707733615276715788464153328322e58\",\n        \"0x2.00000000000000000000000000000000E+48#128\",\n        Greater,\n    );\n\n    // - (round_bit != 0 || sticky_bit != 0) && (rm == Ceiling || rm == Up) in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && (rm == Ceiling || rm == Up) && sum_2 != 0 in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        Up,\n        \"2.000000000000000000000000000000000000012\",\n        \"0x2.00000000000000000000000000000004#129\",\n        Greater,\n    );\n    test(\n        \"9903517953099800764370386944.0000000000291038304566\",\n        \"0x1fffff800000000000000000.000000001fffffffff8#166\",\n        \"1.68499666669691498716668845382709804457445989930032e66\",\n        \"0x1.0000000000000000000001fff80000000000000000E+55#166\",\n        Up,\n        \"1.68499666669691498716668845382709804458436341725346e66\",\n        \"0x1.0000000000000000000001fff8000001fffff80008E+55#166\",\n        Greater,\n    );\n    // - in add_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH in add_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && !overflow in add_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit != 0 || sticky_bit != 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && (round_bit == 0 || (sticky_bit == 0\n    //   && (sum_0 & shift_bit) == 0)) in add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && (round_bit == 0 || (sticky_bit == 0\n    //   && (sum_0 & shift_bit) == 0)) && sum != 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp > y_exp in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#129\",\n        Less,\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#129\",\n        Less,\n    );\n    // - x_exp == y_exp in add_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Nearest,\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        Equal,\n    );\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && round_bit != 0 && (sticky_bit != 0\n    //   || (sum_0 & shift_bit) != 0) in add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && round_bit != 0 && (sticky_bit != 0\n    //   || (sum_0 & shift_bit) != 0) && sum != 0 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        Nearest,\n        \"2.000000000000000000000000000000000000012\",\n        \"0x2.00000000000000000000000000000004#129\",\n        Greater,\n    );\n    // - Limb::WIDTH * 2 <= exp_diff < Limb::WIDTH * 3 in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH * 2 < exp_diff < Limb::WIDTH * 3 in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH * 2 <= exp_diff < Limb::WIDTH * 3 && !overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        Nearest,\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        Less,\n    );\n    // - exp_diff >= Limb::WIDTH * 3 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n        \"6.8892360159362421595728818935378487832685754059e-50\",\n        \"0x1.9c693c182df3035eef00d41638bbdd942f4d498E-41#155\",\n        Nearest,\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n        Less,\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in add_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && !overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.2850537238606374652351877988811796373898773e-22\",\n        \"0x2.0607fd4819748c532aad3528693c1e3c1966E-18#146\",\n        \"978.49328809934495391839880801989439981236569\",\n        \"0x3d2.7e4820fe314caadcb9a156bef2f1c8e53c#146\",\n        Nearest,\n        \"978.49328809934495391839923652526678587611222\",\n        \"0x3d2.7e4820fe314caadcbba75ebc3b0b3d718f#146\",\n        Less,\n    );\n    // - exp_diff < Limb::WIDTH && overflow in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4499918.46219262840948309077470961400786337\",\n        \"0x44a9ce.7652418f789422bc22220831e2030#137\",\n        \"64560208.0262619516023687759351781439347886\",\n        \"0x3d91c50.06b91a6f42e5205070f82f89eefa#137\",\n        Nearest,\n        \"69060126.488454580011851866709887757942652\",\n        \"0x41dc61e.7d0b5bfebb79430c931a37bbd0fc#137\",\n        Less,\n    );\n    // - exp_diff == Limb::WIDTH * 2 in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"563971925627753843356041629019151473018178607215.42\",\n        \"0x62c960337e963a378ba6626ea422d8a5e623986f.6c#165\",\n        \"1301375421.83361702516620516356439489325145225661938\",\n        \"0x4d9169bd.d567ece47a47ef60371d48c969ba8765d4#165\",\n        Nearest,\n        \"563971925627753843356041629019151473019479982637.25\",\n        \"0x62c960337e963a378ba6626ea422d8a633b5022d.40#165\",\n        Less,\n    );\n    // - exp_diff == Limb::WIDTH in add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"226.9305090753243797994707628568605406194\",\n        \"0xe2.ee35d7bf263fda8c632644ad7c49d98#130\",\n        \"4262448175090788889452.984188256984861391\",\n        \"0xe71159efd3a67e736c.fbf3c2f8db72fb8#130\",\n        Nearest,\n        \"4262448175090788889679.91469733230924119\",\n        \"0xe71159efd3a67e744f.ea299ab801b2d60#130\",\n        Less,\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1180591620717411303423.999999999999999999999999997\",\n        \"0x3fffffffffffffffff.ffffffffffffffffffffff#158\",\n        \"5.68434188616351954822429632036496545806324230121e-14\",\n        \"0x1.000000000fffffffffffe0000000000000000038E-11#158\",\n        Nearest,\n        \"1180591620717411303424.00000000000005684341886163\",\n        \"0x400000000000000000.00000000001000000000fe#158\",\n        Less,\n    );\n    // - Limb::WIDTH * 2 <= exp_diff < Limb::WIDTH * 3 && overflow in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && rm == Nearest && round_bit != 0 && (sticky_bit != 0\n    //   || (sum_0 & shift_bit) != 0) && sum == 0\n    test(\n        \"4503599627370495.9999999999999999999999999996\",\n        \"0xfffffffffffff.ffffffffffffffffffffffe#143\",\n        \"3.3087224509824797385046520537834728287650668e-24\",\n        \"0x4.00000003ffff0000000000000000fffffffE-20#143\",\n        Nearest,\n        \"4503599627370496.000000000000000000000003309\",\n        \"0x10000000000000.00000000000000000004000#143\",\n        Greater,\n    );\n    // - (round_bit != 0 || sticky_bit != 0) && (rm == Floor || rm == Down) in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    // - (round_bit != 0 || sticky_bit != 0) && (rm == Floor || rm == Down) && sum != 0 in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Down,\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        Less,\n    );\n    // - (round_bit != 0 || sticky_bit != 0) && (rm == Ceiling || rm == Up) && sum_2 == 0 in\n    //   add_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"18014398509481983.9999999999999999999999999999999998\",\n        \"0x3fffffffffffff.ffffffffffffffffffffffffffff#166\",\n        \"9.6296497219361792652798897129246365926905082410768e-35\",\n        \"0x7.ffffffffffffffffffffffffffffffffffffffffeE-29#166\",\n        Up,\n        \"18014398509481984.0\",\n        \"0x40000000000000.0000000000000000000000000000#166\",\n        Greater,\n    );\n\n    // - 0 < exp_diff < prec && (rm == Ceiling || rm == Up) in\n    //   add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && (rm == Ceiling || rm == Up) && round_bit == 0 && sticky_bit == 0 in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        Up,\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n    // - in add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 in add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && round_bit == 0 in add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n    // - x_exp < y_exp in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec in add_float_significands_same_prec_ge_3w\n    // - in add_significands_rsh_to_out\n    // - exp_diff < Limb::WIDTH in add_significands_rsh_to_out\n    // - 0 < exp_diff < prec && shift == 0 in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && limb == 0 in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && rm == Nearest in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit == 0 in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n    // - x_exp > y_exp in add_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n    // - 0 < exp_diff < prec && shift != 0 in add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#193\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#193\",\n        Nearest,\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#193\",\n        Equal,\n    );\n    // - exp_diff == 0 && rm == Nearest in add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && rm == Nearest && out[0] & shift_bit == 0 in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Nearest,\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        Less,\n    );\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && sticky_bit == 0 && out[0] &\n    //   shift_bit == 0 in add_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Nearest,\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n        Less,\n    );\n    // - exp_diff == 0 && rm == Nearest && out[0] & shift_bit != 0 in\n    //   add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && rm == Nearest && out[0] & shift_bit != 0 && !carry in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.000000000000000000000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000000000000000000006#192\",\n        Nearest,\n        \"2.0000000000000000000000000000000000000000000000000000000013\",\n        \"0x2.000000000000000000000000000000000000000000000008#192\",\n        Greater,\n    );\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && (sticky_bit != 0 || out[0] &\n    //   shift_bit != 0) in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && (sticky_bit != 0 || out[0] &\n    //   shift_bit != 0) && !carry in add_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.000000000000000000000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000000000000000000006#192\",\n        Nearest,\n        \"3.0000000000000000000000000000000000000000000000000000000013\",\n        \"0x3.000000000000000000000000000000000000000000000008#192\",\n        Greater,\n    );\n    // - exp_diff >= Limb::WIDTH in add_significands_rsh_to_out\n    // - exp_diff >= Limb::WIDTH && r != 0 in add_significands_rsh_to_out\n    test(\n        \"7.28057116938384227432903448367767196428679514765398378973101e-48\",\n        \"0xa.a3fc2da1f20fb2d9771f86d3c16a444cd62d5d139e3935f24E-40#198\",\n        \"3.5123473778825578958968695187657587760357139395948269588971e-27\",\n        \"0x1.1646de419a6dbd3466f3081403a87d719b7a765a1ec69e4658E-22#198\",\n        Nearest,\n        \"3.5123473778825578959041500899351426183100429740785046308614e-27\",\n        \"0x1.1646de419a6dbd3471970441a59a8d2474f195e0f288088aa8E-22#198\",\n        Greater,\n    );\n    // - exp_diff >= prec in add_float_significands_same_prec_ge_3w\n    // - exp_diff > prec in add_float_significands_same_prec_ge_3w\n    // - exp_diff > prec in add_float_significands_same_prec_ge_3w && (rm == Nearest || rm == Floor\n    //   || rm == Down)\n    test(\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n        \"0.023991386767031193042066748710708351501952890752924613005724\",\n        \"0x0.06244cad8cd272134e34b325815ad281733f2c06231a0ee744#193\",\n        Nearest,\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n        Less,\n    );\n    // - 0 < exp_diff < prec && limb != 0 in add_float_significands_same_prec_ge_3w\n    test(\n        \"8.699772042374378140693728074838279708562673799416097107796\",\n        \"0x8.b32442b4a730454d66b1b2bdf7a2863d417e6ff22d7f6c58#193\",\n        \"7.5897463681962395437740598844462353563682906392115908083148\",\n        \"0x7.96f99e34566e7be1960d023e431dc5e0a7ad24ad691a1ac4#193\",\n        Nearest,\n        \"16.289518410570617684467787959284515064930964438627687916112\",\n        \"0x10.4a1de0e8fd9ec12efcbeb4fc3ac04c1de92b949f9699872#193\",\n        Greater,\n    );\n    // - exp_diff >= Limb::WIDTH && r == 0 in add_significands_rsh_to_out\n    test(\n        \"6.442552350746554109885349691592991892989624685631192235549e-6\",\n        \"0x0.00006c168d38e231899f0fc85d1888549d5177bdceaee72e15060#192\",\n        \"1476808010161862576835936576709144.7975622615653024045505082\",\n        \"0x48cff00a780a50d34bb694ada218.cc2d0a55f25f9f9126258#192\",\n        Nearest,\n        \"1476808010161862576835936576709144.797568704117653151104618\",\n        \"0x48cff00a780a50d34bb694ada218.cc2d766c7f9881c2afc48#192\",\n        Less,\n    );\n    // - exp_diff == prec in add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest in add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest && power && !carry in\n    //   add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest && !power in add_float_significands_same_prec_ge_3w\n    test(\n        \"4.0635838402455207229400698207668893925379768151364313942222e-23\",\n        \"0x3.1202ecf10ff40b477337957dede18bd7b746884ec977474eE-19#194\",\n        \"1174582238252884689829665592721065057.76655867827770290150723\",\n        \"0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d4#194\",\n        Nearest,\n        \"1174582238252884689829665592721065057.76655867827770290150729\",\n        \"0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d8#194\",\n        Greater,\n    );\n    // - 0 < exp_diff < prec && rm == Nearest && round_bit != 0 && (sticky_bit != 0 || out[0] &\n    //   shift_bit != 0) && carry in add_float_significands_same_prec_ge_3w\n    test(\n        \"4.336808689942017736029811203479766845699938816177735095446e-19\",\n        \"0x7.fffffffffffffffffffffffffffffffe0000000000000000E-16#192\",\n        \"5192296858534827628530496329220095.999999999999999999566319\",\n        \"0xffffffffffffffffffffffffffff.fffffffffffffff80000#192\",\n        Nearest,\n        \"5192296858534827628530496329220096.0\",\n        \"0x10000000000000000000000000000.00000000000000000000#192\",\n        Greater,\n    );\n    // - exp_diff == prec && rm == Nearest && power && carry in\n    //   add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && rm == Nearest && !power && carry in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"158456325028528675187087900671.99999999999999999999999999997\",\n        \"0x1ffffffffffffffffffffffff.fffffffffffffffffffffffe#192\",\n        \"2.5243548967072377773175314089049159349542605923488736152645e-29\",\n        \"0x1.fffffffffffffffffffffffffffffffffffffffffffffffeE-24#192\",\n        Nearest,\n        \"158456325028528675187087900672.0\",\n        \"0x2000000000000000000000000.000000000000000000000000#192\",\n        Greater,\n    );\n    // - exp_diff == prec && rm == Nearest && power in add_float_significands_same_prec_ge_3w\n    test(\n        \"332306998926888516295359133097394175.99999997019767761230469\",\n        \"0x3ffffffff0007fffffffffffffffff.ffffff8000000000000#192\",\n        \"2.6469779601696885595885078146238811314105987548828125e-23\",\n        \"0x2.000000000000000000000000000000000000000000000000E-19#192\",\n        Nearest,\n        \"332306998926888516295359133097394175.99999997019767761230469\",\n        \"0x3ffffffff0007fffffffffffffffff.ffffff8000000000000#192\",\n        Less,\n    );\n    // - 0 < exp_diff < prec && (rm == Floor || rm == Down || rm == Exact) in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        Down,\n        \"3.0\",\n        \"0x3.000000000000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n    // - exp_diff == 0 && (rm == Floor || rm == Down) in add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Down,\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        Less,\n    );\n    // - exp_diff == 0 && (rm == Ceiling || rm == Up) in add_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && (rm == Ceiling || rm == Up) && !carry in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Up,\n        \"2.0000000000000000000000000000000000000000000000000000000006\",\n        \"0x2.000000000000000000000000000000000000000000000004#192\",\n        Greater,\n    );\n    // - 0 < exp_diff < prec && (rm == Ceiling || rm == Up) && (round_bit != 0 || sticky_bit != 0)\n    //   in add_float_significands_same_prec_ge_3w\n    // - 0 < exp_diff < prec && (rm == Ceiling || rm == Up) && (round_bit != 0 || sticky_bit != 0)\n    //   && !carry in add_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Up,\n        \"3.0000000000000000000000000000000000000000000000000000000006\",\n        \"0x3.000000000000000000000000000000000000000000000004#192\",\n        Greater,\n    );\n    // - exp_diff > prec in add_float_significands_same_prec_ge_3w && (rm == Ceiling || rm == Up)\n    // - exp_diff > prec in add_float_significands_same_prec_ge_3w && (rm == Ceiling || rm == Up) &&\n    //   !carry\n    test(\n        \"6823.472967851766873629348006893003460678376513514025568927\",\n        \"0x1aa7.79146bcf65e9c10b73dc31b712bdbba94db27f42827ee#192\",\n        \"3.4171243258195824440860481554099490634319461554553884152664e-68\",\n        \"0xe.bd75c60b3fb1b2daadd125b174611af23cd95ed37b18fd3E-57#192\",\n        Up,\n        \"6823.472967851766873629348006893003460678376513514025568928\",\n        \"0x1aa7.79146bcf65e9c10b73dc31b712bdbba94db27f42827f0#192\",\n        Greater,\n    );\n    // - exp_diff == prec && (rm == Ceiling || rm == Up) in add_float_significands_same_prec_ge_3w\n    // - exp_diff == prec && (rm == Ceiling || rm == Up) && !carry in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"1.1549982013361157285883413763473468330143594437077681839568e-64\",\n        \"0xc.29de762f7d1efb4e2c76c8e4086645c726cd7efd160d9b2E-54#192\",\n        \"7.183764682683218761534928278745259569270911336851315880289e-7\",\n        \"0xc.0d6747ace11077b45ef60fe0663937937659be6facba820E-6#192\",\n        Up,\n        \"7.183764682683218761534928278745259569270911336851315880291e-7\",\n        \"0xc.0d6747ace11077b45ef60fe0663937937659be6facba821E-6#192\",\n        Greater,\n    );\n    // - exp_diff == prec && (rm == Floor || rm == Down) in add_float_significands_same_prec_ge_3w\n    test(\n        \"1.633185017652497317802829911277029120405335932425346213043e-62\",\n        \"0x6.b7f1cf4acb21f3fca0c966202fee44bb9bb293511aa1d780E-52#192\",\n        \"0.00010303969992625256008619861293450462215178250710705317873879\",\n        \"0x0.0006c0b8243103d1ef7ab2f1e9a66ec9ee623a5e72e237199db8#192\",\n        Floor,\n        \"0.00010303969992625256008619861293450462215178250710705317873879\",\n        \"0x0.0006c0b8243103d1ef7ab2f1e9a66ec9ee623a5e72e237199db8#192\",\n        Less,\n    );\n    // - exp_diff > prec in add_float_significands_same_prec_ge_3w && (rm == Ceiling || rm == Up) &&\n    //   carry\n    test(\n        \"2.3509707655716138708899159999241985031053943929132983433321e-38\",\n        \"0x7.fffc0007ffffffff0000000007ffffffffffffffffffffffE-32#195\",\n        \"2.15679573337205118357336120696157045389097155380324579848825e68\",\n        \"0x7.ffffffffffffffffffffffffffffffffffffffffffffffffE+56#195\",\n        Up,\n        \"2.1567957333720511835733612069615704538909715538032457984883e68\",\n        \"0x8.000000000000000000000000000000000000000000000000E+56#195\",\n        Greater,\n    );\n    // - 0 < exp_diff < prec && (rm == Ceiling || rm == Up) && (round_bit != 0 || sticky_bit != 0)\n    //   && carry in add_float_significands_same_prec_ge_3w\n    test(\n        \"8388607.9999999995343387126922607421875\",\n        \"0x7fffff.fffffffe00000000000000000000000000000000000#192\",\n        \"4.6566128730773925781249999999999999999999999999999999999993e-10\",\n        \"0x1.fffffffffffffffffffffffffffffffffffffffffffffffeE-8#192\",\n        Up,\n        \"8388608.0\",\n        \"0x800000.000000000000000000000000000000000000000000#192\",\n        Greater,\n    );\n    // - exp_diff == prec && (rm == Ceiling || rm == Up) && carry in\n    //   add_float_significands_same_prec_ge_3w\n    test(\n        \"511.9999999999999999999999999999999999999999999999999999999\",\n        \"0x1ff.fffffffffffffffffffffffffffffffffffffffffffffe#192\",\n        \"8.156630584998155601789981346010670828251902552640272418926e-56\",\n        \"0x1.ffffffffffffff00001ffffffffffffff80003f003000000E-46#192\",\n        Up,\n        \"512.0\",\n        \"0x200.0000000000000000000000000000000000000000000000#192\",\n        Greater,\n    );\n\n    // - rm == Floor || rm == Down in add_float_significands_same_prec_general_round\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Down, \"2.0\", \"0x2.0#2\", Less,\n    );\n    // - rm == Ceiling || rm == Up in add_float_significands_same_prec_general_round\n    // - (rm == Ceiling || rm == Up) && !carry in add_float_significands_same_prec_general_round\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Up, \"3.0\", \"0x3.0#2\", Greater,\n    );\n    // - (rm == Ceiling || rm == Up) && carry in add_float_significands_same_prec_general_round\n    test(\n        \"2.0\", \"0x2.0#1\", \"1.5\", \"0x1.8#2\", Up, \"4.0\", \"0x4.0#2\", Greater,\n    );\n\n    // - shift2 == 0 in add_float_significands_same_prec_general\n    // - y in add_float_significands_same_prec_general\n    // - shift != 0 in add_float_significands_same_prec_general\n    // - x == 0 first time in add_float_significands_same_prec_general\n    // - shift == 0 || following_bits != Uninitialized in add_float_significands_same_prec_general\n    // - round_bit != Uninitialized || shift == 0 in add_float_significands_same_prec_general\n    // - exp_diff_rem == 0 && yi == 0 second time in add_float_significands_same_prec_general\n    // - round_bit != Uninitialized sixth time in add_float_significands_same_prec_general\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Nearest, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    // - following_bits != False || round_bit != False in\n    //   add_float_significands_same_prec_general_round\n    // - rm == Nearest in add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits == False in add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit == 0 in\n    //   add_float_significands_same_prec_general_round\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Nearest, \"2.0\", \"0x2.0#2\", Less,\n    );\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit != 0 in\n    //   add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit != 0 && carry in\n    //   add_float_significands_same_prec_general_round\n    test(\n        \"2.0\", \"0x2.0#1\", \"1.5\", \"0x1.8#2\", Nearest, \"4.0\", \"0x4.0#2\", Greater,\n    );\n    // - rm == Nearest && following_bits == False && out[0] & shift_bit != 0 && !carry in\n    //   add_float_significands_same_prec_general_round\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.8\", \"0x1.c#3\", Nearest, \"3.0\", \"0x3.0#3\", Greater,\n    );\n    // - x != 0 && x != mask second time in add_float_significands_same_prec_general\n    // - rm == Nearest && following_bits != False && round_bit != False in\n    //   add_float_significands_same_prec_general_round\n    // - rm == Nearest && following_bits != False && round_bit != False && !carry in\n    //   add_float_significands_same_prec_general_round\n    test(\n        \"1.5\", \"0x1.8#2\", \"4.0\", \"0x4.0#1\", Nearest, \"6.0\", \"0x6.0#2\", Greater,\n    );\n    // - rm == Nearest && following_bits != False && round_bit == False in\n    //   add_float_significands_same_prec_general_round\n    test(\n        \"4.0\", \"0x4.0#1\", \"1.2\", \"0x1.4#3\", Nearest, \"5.0\", \"0x5.0#3\", Less,\n    );\n    // - x != 0 && x != mask first time in add_float_significands_same_prec_general\n    // - shift != 0 && following_bits == Uninitialized in add_float_significands_same_prec_general\n    test(\n        \"1.2\", \"0x1.4#3\", \"3.0\", \"0x3.0#2\", Nearest, \"4.0\", \"0x4.0#3\", Less,\n    );\n    // - rm == Nearest && following_bits != False && round_bit != False && carry in\n    //   add_float_significands_same_prec_general_round\n    test(\n        \"1.8\", \"0x1.c#3\", \"6.0\", \"0x6.0#2\", Nearest, \"8.0\", \"0x8.0#3\", Greater,\n    );\n    // - out_bits <= exp_diff in add_float_significands_same_prec_general\n    // - out_len <= xs_len first time in add_float_significands_same_prec_general\n    // - difw > 0 && difw > ys_len && exp_diff > out_bits in\n    //   add_float_significands_same_prec_general\n    // - round_bit != Uninitialized fifth time in add_float_significands_same_prec_general\n    test(\n        \"8.82188e11\",\n        \"0xc.d668E+9#18\",\n        \"9.75459983374e122\",\n        \"0x1.79c17f063aE+102#40\",\n        Nearest,\n        \"9.75459983374e122\",\n        \"0x1.79c17f063aE+102#40\",\n        Less,\n    );\n    // - out_len > xs_len first time in add_float_significands_same_prec_general\n    test(\n        \"2.8577648979177105962332201291018926848163080599637e-19\",\n        \"0x5.458a93bffa7b1c05bdd1c0552b60196746d9083cE-16#162\",\n        \"3.569720699507868e50\",\n        \"0xf.4400d3acf388E+41#51\",\n        Nearest,\n        \"3.5697206995078675404584127554321345196383736430592e50\",\n        \"0xf.4400d3acf3880000000000000000000000000000E+41#162\",\n        Less,\n    );\n    // - overlap > ys_len in add_float_significands_same_prec_general\n    // - out_len - k > overlap in add_float_significands_same_prec_general\n    // - difw <= 0 || difw <= ys_len in add_float_significands_same_prec_general\n    // - round_bit != Uninitialized fourth time in add_float_significands_same_prec_general\n    test(\n        \"29780282551.762684458936866363165\",\n        \"0x6ef0b0cb7.c33f49e84d21bb6040#104\",\n        \"0.00003945598947538\",\n        \"0x0.000295f62f36adb#46\",\n        Nearest,\n        \"29780282551.762723914926341743141\",\n        \"0x6ef0b0cb7.c341dfde7c58691040#104\",\n        Equal,\n    );\n    // - out_len > xs_len second time in add_float_significands_same_prec_general\n    test(\n        \"1.07183972513958531257713938927815e-11\",\n        \"0xb.c8f5eafa12eb9821601f1dd6aeE-10#107\",\n        \"0.00374222828352849\",\n        \"0x0.00f5402c178824#46\",\n        Nearest,\n        \"0.00374222829424688982311482391965285\",\n        \"0x0.00f5402c235119eafa12eb9821602#107\",\n        Greater,\n    );\n    // - exp_diff_rem == 0 second time in add_float_significands_same_prec_general\n    test(\n        \"5.19192095203e-15\",\n        \"0x1.761e097c5E-12#37\",\n        \"7.4e4\",\n        \"0x1.2E+4#5\",\n        Nearest,\n        \"73728.0\",\n        \"0x12000.00000#37\",\n        Less,\n    );\n    // - shift <= 1 in add_float_significands_same_prec_general\n    test(\n        \"15135.895602865542606017656527713819177465060416097749360065\",\n        \"0x3b1f.e5463ab9b599ce49b83c7988b324dc93ce50b2ed51a18#191\",\n        \"3.581529624499970047886732225242180736649e-8\",\n        \"0x9.9d355ad2b99a587727da095fa3226bf0E-7#130\",\n        Nearest,\n        \"15135.895602901357902262656228192686499717482223464235884113\",\n        \"0x3b1f.e5463b5388ef7b7551e200fb30c5728e007771ed51a18#191\",\n        Equal,\n    );\n    // - round_bit == Uninitialized fourth time in add_float_significands_same_prec_general\n    // - round_bit == Uninitialized seventh time in add_float_significands_same_prec_general\n    test(\n        \"8.63643735016344467819174862798332593462e-6\",\n        \"0x0.000090e5374a001358c6606f968bf3813ad9#128\",\n        \"1.84904e-8\",\n        \"0x4.f6a6E-7#18\",\n        Nearest,\n        \"8.65492771851100147411665059026359937212e-6\",\n        \"0x0.00009134a1aa001358c6606f968bf3813ad9#128\",\n        Equal,\n    );\n    // - round_bit == Uninitialized fifth time in add_float_significands_same_prec_general\n    test(\n        \"2.389545997e25\",\n        \"0x1.3c40f7bE+21#29\",\n        \"0.078263259824284000402\",\n        \"0x0.14090f9d6c745bc06#64\",\n        Nearest,\n        \"2.389545996756557709e25\",\n        \"0x1.3c40f7b000000000E+21#64\",\n        Less,\n    );\n    // - round_bit == Uninitialized seventh time in add_float_significands_same_prec_general\n    test(\n        \"5.7505515877842013577e-7\",\n        \"0x9.a5d7d56cabed47dE-6#64\",\n        \"1.1758894e-14\",\n        \"0x3.4f515E-12#22\",\n        Nearest,\n        \"5.7505517053731436845e-7\",\n        \"0x9.a5d7d8bbfd3d47dE-6#64\",\n        Equal,\n    );\n    // - x != 0 && x == mask second time in add_float_significands_same_prec_general\n    // - xs_len <= out_len && following_bits == True in add_float_significands_same_prec_general\n    test(\n        \"1.081090215247020702e-18\",\n        \"0x1.3f14ddfe22c0634E-15#59\",\n        \"6.3799657596147e-8\",\n        \"0x1.12047722d26cE-6#47\",\n        Nearest,\n        \"6.37996575972280156e-8\",\n        \"0x1.12047722e65d4dcE-6#59\",\n        Less,\n    );\n    // - shift == 0 in add_float_significands_same_prec_general\n    test(\n        \"4.3055451539258443718732375731462554408177909736937057433067e-16\",\n        \"0x1.f06543668e6018c20c17efed72ff6d3d65a4c5dc9db475b0E-13#192\",\n        \"1.6388436e-15\",\n        \"0x7.61754E-13#21\",\n        Nearest,\n        \"2.0693980969049410047184094732421002104686218250305033868307e-15\",\n        \"0x9.51da83668e6018c20c17efed72ff6d3d65a4c5dc9db475bE-13#192\",\n        Equal,\n    );\n    // - yi != 0 second time in add_float_significands_same_prec_general\n    test(\n        \"2.24181435676546e-16\",\n        \"0x1.0276ae5de1e8E-13#47\",\n        \"7.6430700039878539638425372386462404393e-36\",\n        \"0xa.28cd4cb186f5925ddb0d1ecb9681103E-30#128\",\n        Nearest,\n        \"2.24181435676546206911083333246297446029e-16\",\n        \"0x1.0276ae5de1e80000a28cd4cb186f5926E-13#128\",\n        Greater,\n    );\n    // - x != 0 && x == mask first time in add_float_significands_same_prec_general\n    test(\n        \"2.1474796e9\",\n        \"0x7.ffff00E+7#24\",\n        \"8191.9998788833609\",\n        \"0x1fff.fff80fffff0#54\",\n        Nearest,\n        \"2147487743.9998789\",\n        \"0x80000fff.fff810#54\",\n        Greater,\n    );\n\n    test(\n        \"-too_small\",\n        \"-0x2.50888E-268435456#19\",\n        \"too_small\",\n        \"0x3.10E-268435456#10\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n}\n\n#[test]\nfn add_round_fail() {\n    assert_panic!(Float::one_prec(1).add_round(Float::two_prec(1), Exact));\n    assert_panic!(Float::one_prec(1).add_round_val_ref(&Float::two_prec(1), Exact));\n    assert_panic!(Float::one_prec(1).add_round_ref_val(Float::two_prec(1), Exact));\n    assert_panic!(Float::one_prec(1).add_round_ref_ref(&Float::two_prec(1), Exact));\n\n    assert_panic!(parse_hex_string(\"0x1.0#1\").add_round(parse_hex_string(\"0x0.001#1\"), Exact));\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").add_round_val_ref(&parse_hex_string(\"0x0.001#1\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").add_round_ref_val(parse_hex_string(\"0x0.001#1\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").add_round_ref_ref(&parse_hex_string(\"0x0.001#1\"), Exact)\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .add_round(parse_hex_string(\"0x1.0000000000000002#64\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .add_round_val_ref(&parse_hex_string(\"0x1.0000000000000002#64\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .add_round_ref_val(parse_hex_string(\"0x1.0000000000000002#64\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .add_round_ref_ref(&parse_hex_string(\"0x1.0000000000000002#64\"), Exact)\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .add_round(parse_hex_string(\"0x1.0000000000000001#65\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .add_round_val_ref(&parse_hex_string(\"0x1.0000000000000001#65\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .add_round_ref_val(parse_hex_string(\"0x1.0000000000000001#65\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .add_round_ref_ref(&parse_hex_string(\"0x1.0000000000000001#65\"), Exact)\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").add_round(\n            parse_hex_string(\"0x1.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").add_round_val_ref(\n            &parse_hex_string(\"0x1.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").add_round_ref_val(\n            parse_hex_string(\"0x1.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").add_round_ref_ref(\n            &parse_hex_string(\"0x1.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").add_round(\n            parse_hex_string(\"0x1.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").add_round_val_ref(\n            &parse_hex_string(\"0x1.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").add_round_ref_val(\n            parse_hex_string(\"0x1.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").add_round_ref_ref(\n            &parse_hex_string(\"0x1.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\").add_round(\n            parse_hex_string(\"0x1.000000000000000000000000000000000000000000000002#192\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\")\n            .add_round_val_ref(\n                &parse_hex_string(\"0x1.000000000000000000000000000000000000000000000002#192\"),\n                Exact\n            )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\")\n            .add_round_ref_val(\n                parse_hex_string(\"0x1.000000000000000000000000000000000000000000000002#192\"),\n                Exact\n            )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\")\n            .add_round_ref_ref(\n                &parse_hex_string(\"0x1.000000000000000000000000000000000000000000000002#192\"),\n                Exact\n            )\n    );\n\n    assert_panic!(parse_hex_string(\"0x1.0#1\").add_round(parse_hex_string(\"0x1.8#2\"), Exact));\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").add_round_val_ref(&parse_hex_string(\"0x1.8#2\"), Exact)\n    );\n    assert_panic!({\n        parse_hex_string(\"0x1.0#1\").add_round_ref_val(parse_hex_string(\"0x1.8#2\"), Exact)\n    });\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").add_round_ref_ref(&parse_hex_string(\"0x1.8#2\"), Exact)\n    );\n\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_round_assign(Float::two_prec(1), Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_round_assign_ref(&Float::two_prec(1), Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0#1\");\n        x.add_round_assign(parse_hex_string(\"0x0.001#1\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0#1\");\n        x.add_round_assign_ref(&parse_hex_string(\"0x0.001#1\"), Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#64\");\n        x.add_round_assign(parse_hex_string(\"0x1.0000000000000002#64\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#64\");\n        x.add_round_assign_ref(&parse_hex_string(\"0x1.0000000000000002#64\"), Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#65\");\n        x.add_round_assign(parse_hex_string(\"0x1.0000000000000001#65\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#65\");\n        x.add_round_assign_ref(&parse_hex_string(\"0x1.0000000000000001#65\"), Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#128\");\n        x.add_round_assign(\n            parse_hex_string(\"0x1.00000000000000000000000000000002#128\"),\n            Exact,\n        )\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#128\");\n        x.add_round_assign_ref(\n            &parse_hex_string(\"0x1.00000000000000000000000000000002#128\"),\n            Exact,\n        )\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#129\");\n        x.add_round_assign(\n            parse_hex_string(\"0x1.00000000000000000000000000000003#129\"),\n            Exact,\n        )\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#129\");\n        x.add_round_assign_ref(\n            &parse_hex_string(\"0x1.00000000000000000000000000000003#129\"),\n            Exact,\n        )\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\");\n        x.add_round_assign(\n            parse_hex_string(\"0x1.000000000000000000000000000000000000000000000002#192\"),\n            Exact,\n        )\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\");\n        x.add_round_assign_ref(\n            &parse_hex_string(\"0x1.000000000000000000000000000000000000000000000002#192\"),\n            Exact,\n        )\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0#1\");\n        x.add_round_assign(parse_hex_string(\"0x1.8#2\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0#1\");\n        x.add_round_assign_ref(&parse_hex_string(\"0x1.8#2\"), Exact)\n    });\n}\n\n#[test]\nfn test_add_prec_round() {\n    let test = |s, s_hex, t, t_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (sum, o) = x.clone().add_prec_round(y.clone(), prec, rm);\n        assert!(sum.is_valid());\n\n        assert_eq!(sum.to_string(), out);\n        assert_eq!(to_hex_string(&sum), out_hex);\n        assert_eq!(o, o_out);\n\n        let (sum_alt, o_alt) = x.clone().add_prec_round_val_ref(&y, prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = x.add_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = x.add_prec_round_ref_ref(&y, prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_prec_round_assign(y.clone(), prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_prec_round_assign_ref(&y, prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (sum_alt, o_alt) = add_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sum, rug_o) = rug_add_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sum)),\n                ComparableFloatRef(&sum)\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Floor,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Ceiling,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Down,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Up,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Nearest,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"4.56\",\n        \"0x4.90#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"4.56\",\n        \"0x4.90#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-1.729\",\n        \"-0x1.ba8#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-1.729\",\n        \"-0x1.ba8#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"1.729\",\n        \"0x1.ba8#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"1.729\",\n        \"0x1.ba8#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-4.56\",\n        \"-0x4.90#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-4.56\",\n        \"-0x4.90#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        Floor,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        Ceiling,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        Down,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        Up,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        Nearest,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        Exact,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    // - exp_diff_rem == 0 && yi == 0 first time in add_float_significands_same_prec_general\n    test(\n        \"0.000487804412841796875000000000000000000000000000000000000000291703841149741293879771765\\\n        542\",\n        \"0x0.001ff8000000000000000000000000000000000000000000007800000000001fffffffffffe#288\",\n        \"0.000488281249999997\",\n        \"0x0.001fffffffffffc#47\",\n        53,\n        Ceiling,\n        \"0.0009760856628417935\",\n        \"0x0.003ff7ffffffffc2#53\",\n        Greater,\n    );\n    test(\n        \"0.000488281249999997\",\n        \"0x0.001fffffffffffc#47\",\n        \"0.000487804412841796875000000000000000000000000000000000000000291703841149741293879771765\\\n        542\",\n        \"0x0.001ff8000000000000000000000000000000000000000000007800000000001fffffffffffe#288\",\n        53,\n        Ceiling,\n        \"0.0009760856628417935\",\n        \"0x0.003ff7ffffffffc2#53\",\n        Greater,\n    );\n    // - round_bit != Uninitialized third time in add_float_significands_same_prec_general\n    test(\n        \"54004143877011445683.03364332940006328475124657021\",\n        \"0x2ed7542badc5a97b3.089cd9678077bdca8dabe52c#160\",\n        \"8.0\",\n        \"0x8.0#1\",\n        127,\n        Up,\n        \"54004143877011445691.033643329400063285\",\n        \"0x2ed7542badc5a97bb.089cd9678077bdd0#127\",\n        Greater,\n    );\n\n    test(\n        \"-1.948077668464e-10\",\n        \"-0xd.63182fa960E-9#41\",\n        \"too_big\",\n        \"0x7.c300ddfc112a6cf2a0bb36cf8E+268435455#100\",\n        3,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"1.948077668464e-10\",\n        \"0xd.63182fa960E-9#41\",\n        \"-too_big\",\n        \"-0x7.c300ddfc112a6cf2a0bb36cf8E+268435455#100\",\n        3,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test(\n        \"too_small\",\n        \"0x1.08E-268435456#6\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.08E-268435456#6\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\nfn add_prec_round_fail() {\n    assert_panic!(Float::one_prec(1).add_prec_round(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).add_prec_round_val_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).add_prec_round_ref_val(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).add_prec_round_ref_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_prec_round_assign(Float::two_prec(1), 0, Floor)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_prec_round_assign_ref(&Float::two_prec(1), 0, Floor)\n    });\n\n    assert_panic!(Float::one_prec(1).add_prec_round(Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).add_prec_round_val_ref(&Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).add_prec_round_ref_val(Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).add_prec_round_ref_ref(&Float::two_prec(1), 1, Exact));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_prec_round_assign(Float::two_prec(1), 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_prec_round_assign_ref(&Float::two_prec(1), 1, Exact)\n    });\n}\n\n#[test]\nfn test_add_rational() {\n    let test = |s, s_hex, t, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let sum = x.clone() + y.clone();\n        assert!(sum.is_valid());\n\n        assert_eq!(sum.to_string(), out);\n        assert_eq!(to_hex_string(&sum), out_hex);\n\n        let sum_alt = x.clone() + &y;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let sum_alt = &x + y.clone();\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let sum_alt = &x + &y;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n\n        let sum_alt = y.clone() + x.clone();\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let sum_alt = y.clone() + &x;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let sum_alt = &y + x.clone();\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let sum_alt = &y + &x;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n\n        let mut sum_alt = x.clone();\n        sum_alt += y.clone();\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        let mut sum_alt = x.clone();\n        sum_alt += &y;\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_add_rational(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::from(&y)\n            ))),\n            ComparableFloatRef(&sum)\n        );\n\n        let sum_alt =\n            add_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    };\n    test(\"NaN\", \"NaN\", \"123\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"123\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"123\", \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", \"0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"123\", \"1.0e2\", \"0x8.0E+1#1\");\n    test(\"-0.0\", \"-0x0.0\", \"123\", \"1.0e2\", \"0x8.0E+1#1\");\n    test(\"0.0\", \"0x0.0\", \"1/3\", \"0.2\", \"0x0.4#1\");\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", \"0.2\", \"0x0.4#1\");\n    test(\"123.0\", \"0x7b.0#7\", \"0\", \"123.0\", \"0x7b.0#7\");\n\n    // - same sign in float_rational_sum_exponent_range\n    test(\"1.0\", \"0x1.0#1\", \"2\", \"4.0\", \"0x4.0#1\");\n    test(\"1.0\", \"0x1.0#2\", \"2\", \"3.0\", \"0x3.0#2\");\n    test(\"1.0\", \"0x1.000#10\", \"2\", \"3.0\", \"0x3.00#10\");\n    test(\"1.0\", \"0x1.000#10\", \"1/3\", \"1.334\", \"0x1.558#10\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n    );\n    // - different signs and log_x_abs.abs_diff(log_y_abs) > 1 in float_rational_sum_exponent_range\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"1/50000\", \"1.0\", \"0x1.0#1\");\n    // - signs different and x.eq_abs(&y) in add_rational_prec_round\n    test(\"1.0\", \"0x1.0#1\", \"-1\", \"0.0\", \"0x0.0\");\n\n    test(\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        \"-1/8388607\",\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n    );\n    test(\"1.0\", \"0x1.0#1\", \"0\", \"1.0\", \"0x1.0#1\");\n    // - o == Equal in add_rational_prec_round_assign_helper\n    test(\"1.0\", \"0x1.0#1\", \"1\", \"2.0\", \"0x2.0#1\");\n    // - o != Equal in add_rational_prec_round_assign_helper\n    // - t != 0 in add_rational_prec_round_assign_helper\n    // - small Natural in float_can_round\n    // - err0 > prec && err > prec in float_can_round\n    // - s != Limb::WIDTH first time in float_can_round\n    // - n == 0 in float_can_round\n    // - float_can_round in add_rational_prec_round_assign_helper\n    test(\"1.0\", \"0x1.0#1\", \"1/3\", \"1.0\", \"0x1.0#1\");\n    // - large Natural in float_can_round\n    // - n != 0 && tmp != 0 && tmp != mask in float_can_round\n    test(\n        \"269104312292334.303\",\n        \"0xf4bfbaf113ee.4d8#57\",\n        \"517543599148951977/6042448266342026218192\",\n        \"269104312292334.303\",\n        \"0xf4bfbaf113ee.4d8#57\",\n    );\n    // - s == Limb::WIDTH first time in float_can_round\n    test(\n        \"1.1595752615776271305e-33\",\n        \"0x6.055703bef650178E-28#63\",\n        \"-2457795567751474853961645492284796573970712506001349310379799846240055987994196472114730\\\n        61298054082441720799/23\",\n        \"-1.0686067685875977626e106\",\n        \"-0x1.2a31c100f5e98110E+88#63\",\n    );\n    // - !float_can_round in add_rational_prec_round_assign_helper\n    // - n != 0 && tmp == 0 in float_can_round\n    // - n <= 0 first time in float_can_round\n    // - s != Limb::WIDTH second time in float_can_round\n    // - n > 0 first time in float_can_round\n    // - x == 0 in float_can_round\n    // - x != 0 in float_can_round\n    test(\n        \"5.82156e33\",\n        \"0x1.1f066E+28#20\",\n        \"8238723/1413731881599214931\",\n        \"5.82156e33\",\n        \"0x1.1f066E+28#20\",\n    );\n    // - n != 0 && tmp != 0 && tmp == mask in float_can_round\n    // - n <= 0 second time in float_can_round\n    // - s != Limb::WIDTH third time in float_can_round\n    test(\n        \"1.04226364758062811487679885e63\",\n        \"0x2.889a2dba3978ccd56c826E+52#85\",\n        \"-3183521742267703581572109801877979/35801077870645726\",\n        \"1.04226364758062811487679885e63\",\n        \"0x2.889a2dba3978ccd56c826E+52#85\",\n    );\n    // - s == Limb::WIDTH second time in float_can_round\n    // - n > 0 second time in float_can_round\n    // - x == Limb::MAX in float_can_round\n    test(\n        \"5.3586423373910357e63\",\n        \"0xd.06b0f9ea88b7aE+52#55\",\n        \"-808694/11557016618486698036897716112870533564271922504817764249868611771\",\n        \"5.3586423373910357e63\",\n        \"0xd.06b0f9ea88b7aE+52#55\",\n    );\n    // - x != Limb::MAX in float_can_round\n    test(\n        \"4.9046e10\",\n        \"0xb.6b5eE+8#19\",\n        \"-182971083215/47776579472461276067598384651239241670113870043\",\n        \"4.9046e10\",\n        \"0xb.6b5eE+8#19\",\n    );\n    // - s == Limb::WIDTH third time in float_can_round\n    test(\n        \"2.515940926449112e24\",\n        \"0x2.14c56e507323d0E+20#55\",\n        \"-3161/286335616056113777\",\n        \"2.515940926449112e24\",\n        \"0x2.14c56e507323d0E+20#55\",\n    );\n    // - err0 <= prec || err <= prec in float_can_round\n    // - different signs and log_x_abs.abs_diff(log_y_abs) <= 1 in float_rational_sum_exponent_range\n    // - different signs and log_x_abs.abs_diff(log_y_abs) == 1 in float_rational_sum_exponent_range\n    test(\n        \"5.96046446e-8\",\n        \"0xf.ffffffE-7#28\",\n        \"-255/4261412864\",\n        \"-2.34664179e-10\",\n        \"-0x1.0204182E-8#28\",\n    );\n    // - t == 0 in add_rational_prec_round_assign_helper\n    // - different signs and log_x_abs == log_y_abs in float_rational_sum_exponent_range\n    test(\n        \"64.0\",\n        \"0x40.00000#24\",\n        \"-215679573337202053366254388918461596342975394375083745820919489101824/336999333319768176\\\n        9435117813341997219028918889483691361889027096575\",\n        \"-3.7241676e-9\",\n        \"-0xf.fec40E-8#24\",\n    );\n}\n\n#[test]\nfn test_add_rational_prec() {\n    let test = |s, s_hex, t, prec, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (sum, o) = x.clone().add_rational_prec(y.clone(), prec);\n        assert!(sum.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(sum.to_string(), out);\n        assert_eq!(to_hex_string(&sum), out_hex);\n\n        let (sum_alt, o_alt) = x.clone().add_rational_prec_val_ref(&y, prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let (sum_alt, o_alt) = x.add_rational_prec_ref_val(y.clone(), prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let (sum_alt, o_alt) = x.add_rational_prec_ref_ref(&y, prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_rational_prec_assign(y.clone(), prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_rational_prec_assign_ref(&y, prec);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let (sum_alt, o_alt) = add_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n\n        let (rug_sum, rug_o) = rug_add_rational_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sum)),\n            ComparableFloatRef(&sum)\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"123\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, \"0.2\", \"0x0.4#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 2, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 2, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.000#10\", \"2\", 2, \"3.0\", \"0x3.0#2\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        100,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"1/50000\", 10, \"1.0\", \"0x1.000#10\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", 10, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"4.547473508864641189582899002890190173e-13\",\n        \"0x8.00000000000000003ffff000000000E-11#123\",\n        \"-4194304/9223372019742015487\",\n        3,\n        \"-8.0e-22\",\n        \"-0x4.0E-18#3\",\n        Less,\n    );\n}\n\n#[test]\nfn add_rational_prec_fail() {\n    assert_panic!(Float::NAN.add_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.add_rational_prec_val_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::NAN.add_rational_prec_ref_val(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.add_rational_prec_ref_ref(&Rational::ZERO, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.add_rational_prec_assign(Rational::ZERO, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.add_rational_prec_assign_ref(&Rational::ZERO, 0)\n    });\n}\n\n#[test]\nfn test_add_rational_round() {\n    let test_helper =\n        |s, s_hex, y: Rational, rm, out: &str, out_hex: &str, o_out, extreme: bool| {\n            let x = parse_hex_string(s_hex);\n            assert_eq!(x.to_string(), s);\n\n            let (sum, o) = x.clone().add_rational_round(y.clone(), rm);\n            assert!(sum.is_valid());\n            assert_eq!(o, o_out);\n\n            assert_eq!(sum.to_string(), out);\n            assert_eq!(to_hex_string(&sum), out_hex);\n\n            if !extreme {\n                let (sum_alt, o_alt) = x.clone().add_rational_round_val_ref(&y, rm);\n                assert!(sum_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n                assert_eq!(o_alt, o);\n\n                let (sum_alt, o_alt) = x.add_rational_round_ref_val(y.clone(), rm);\n                assert!(sum_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n                assert_eq!(o_alt, o);\n\n                let (sum_alt, o_alt) = x.add_rational_round_ref_ref(&y, rm);\n                assert!(sum_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n                assert_eq!(o_alt, o);\n\n                let mut sum_alt = x.clone();\n                let o_alt = sum_alt.add_rational_round_assign(y.clone(), rm);\n                assert!(sum_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n                assert_eq!(o_alt, o);\n\n                let mut sum_alt = x.clone();\n                let o_alt = sum_alt.add_rational_round_assign_ref(&y, rm);\n                assert!(sum_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n                assert_eq!(o_alt, o);\n            }\n\n            if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n                let (rug_sum, rug_o) = rug_add_rational_round(\n                    &rug::Float::exact_from(&x),\n                    &rug::Rational::exact_from(&y),\n                    rm,\n                );\n                assert_eq!(\n                    ComparableFloatRef(&Float::from(&rug_sum)),\n                    ComparableFloatRef(&sum)\n                );\n                assert_eq!(rug_o, o);\n            }\n\n            let (sum_alt, o_alt) =\n                add_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), rm);\n            assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n            assert_eq!(o_alt, o);\n        };\n    let test = |s, s_hex, t, rm, out: &str, out_hex: &str, o_out| {\n        test_helper(\n            s,\n            s_hex,\n            Rational::from_str(t).unwrap(),\n            rm,\n            out,\n            out_hex,\n            o_out,\n            false,\n        );\n    };\n    test(\"NaN\", \"NaN\", \"123\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"123\", Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123\",\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\"0.0\", \"0x0.0\", \"123\", Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"123\", Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123\",\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"123\", Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123\",\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"123\", Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123\",\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Floor, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Down, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Up, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Exact, \"123.0\", \"0x7b.0#7\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"1/3\", Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", Floor, \"2.0\", \"0x2.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Down, \"2.0\", \"0x2.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Up, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test(\"1.0\", \"0x1.0#2\", \"2\", Floor, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Ceiling, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Down, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Up, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Nearest, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Exact, \"3.0\", \"0x3.0#2\", Equal);\n\n    test(\"1.0\", \"0x1.000#10\", \"2\", Floor, \"3.0\", \"0x3.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Ceiling, \"3.0\", \"0x3.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Down, \"3.0\", \"0x3.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Up, \"3.0\", \"0x3.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Nearest, \"3.0\", \"0x3.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Exact, \"3.0\", \"0x3.00#10\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Floor,\n        \"1.332\",\n        \"0x1.550#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Ceiling,\n        \"1.334\",\n        \"0x1.558#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Down,\n        \"1.332\",\n        \"0x1.550#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Up,\n        \"1.334\",\n        \"0x1.558#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Nearest,\n        \"1.334\",\n        \"0x1.558#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Floor,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Ceiling,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Down,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Up,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Nearest,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Floor,\n        \"3.4749259869231262\",\n        \"0x3.7994bfdddaf84#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Ceiling,\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Down,\n        \"3.4749259869231262\",\n        \"0x3.7994bfdddaf84#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Up,\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Nearest,\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Floor,\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Ceiling,\n        \"2.8082593202564601\",\n        \"0x2.ceea1533304dc#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Down,\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Up,\n        \"2.8082593202564601\",\n        \"0x2.ceea1533304dc#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Nearest,\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Floor,\n        \"-2.8082593202564601\",\n        \"-0x2.ceea1533304dc#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Ceiling,\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Down,\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Up,\n        \"-2.8082593202564601\",\n        \"-0x2.ceea1533304dc#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Nearest,\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Floor,\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Ceiling,\n        \"-3.4749259869231262\",\n        \"-0x3.7994bfdddaf84#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Down,\n        \"-3.4749259869231262\",\n        \"-0x3.7994bfdddaf84#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Up,\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Nearest,\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n        Less,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"1/50000\", Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\n        \"1.0\", \"0x1.0#1\", \"1/50000\", Ceiling, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"1/50000\", Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"1/50000\", Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"1/50000\", Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        \"-1/8388607\",\n        Floor,\n        \"1.83e180\",\n        \"0x7.0eE+149#10\",\n        Less,\n    );\n    test(\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        \"-1/8388607\",\n        Ceiling,\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        Greater,\n    );\n    test(\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        \"-1/8388607\",\n        Down,\n        \"1.83e180\",\n        \"0x7.0eE+149#10\",\n        Less,\n    );\n    test(\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        \"-1/8388607\",\n        Up,\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        Greater,\n    );\n    test(\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        \"-1/8388607\",\n        Nearest,\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        Greater,\n    );\n    test(\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        \"-1/8388607\",\n        Nearest,\n        \"1.832e180\",\n        \"0x7.10E+149#10\",\n        Greater,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"0\", Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    // - o == Equal in add_rational_prec_round_assign_helper\n    test(\"1.0\", \"0x1.0#1\", \"1\", Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    // - o != Equal in add_rational_prec_round_assign_helper\n    // - t != 0 in add_rational_prec_round_assign_helper\n    // - small Natural in float_can_round\n    // - err0 > prec && err > prec in float_can_round\n    // - s != Limb::WIDTH first time in float_can_round\n    // - n == 0 in float_can_round\n    // - float_can_round in add_rational_prec_round_assign_helper\n    test(\"1.0\", \"0x1.0#1\", \"1/3\", Nearest, \"1.0\", \"0x1.0#1\", Less);\n    // - large Natural in float_can_round\n    // - n != 0 && tmp != 0 && tmp != mask in float_can_round\n    test(\n        \"269104312292334.303\",\n        \"0xf4bfbaf113ee.4d8#57\",\n        \"517543599148951977/6042448266342026218192\",\n        Nearest,\n        \"269104312292334.303\",\n        \"0xf4bfbaf113ee.4d8#57\",\n        Less,\n    );\n    // - s == Limb::WIDTH first time in float_can_round\n    test(\n        \"1.1595752615776271305e-33\",\n        \"0x6.055703bef650178E-28#63\",\n        \"-2457795567751474853961645492284796573970712506001349310379799846240055987994196472114730\\\n        61298054082441720799/23\",\n        Nearest,\n        \"-1.0686067685875977626e106\",\n        \"-0x1.2a31c100f5e98110E+88#63\",\n        Less,\n    );\n    // - !float_can_round in add_rational_prec_round_assign_helper\n    // - n != 0 && tmp == 0 in float_can_round\n    // - n <= 0 first time in float_can_round\n    // - s != Limb::WIDTH second time in float_can_round\n    // - n > 0 first time in float_can_round\n    // - x == 0 in float_can_round\n    // - x != 0 in float_can_round\n    test(\n        \"5.82156e33\",\n        \"0x1.1f066E+28#20\",\n        \"8238723/1413731881599214931\",\n        Nearest,\n        \"5.82156e33\",\n        \"0x1.1f066E+28#20\",\n        Less,\n    );\n    // - n != 0 && tmp != 0 && tmp == mask in float_can_round\n    // - n <= 0 second time in float_can_round\n    // - s != Limb::WIDTH third time in float_can_round\n    test(\n        \"1.04226364758062811487679885e63\",\n        \"0x2.889a2dba3978ccd56c826E+52#85\",\n        \"-3183521742267703581572109801877979/35801077870645726\",\n        Nearest,\n        \"1.04226364758062811487679885e63\",\n        \"0x2.889a2dba3978ccd56c826E+52#85\",\n        Greater,\n    );\n    // - s == Limb::WIDTH second time in float_can_round\n    // - n > 0 second time in float_can_round\n    // - x == Limb::MAX in float_can_round\n    test(\n        \"5.3586423373910357e63\",\n        \"0xd.06b0f9ea88b7aE+52#55\",\n        \"-808694/11557016618486698036897716112870533564271922504817764249868611771\",\n        Nearest,\n        \"5.3586423373910357e63\",\n        \"0xd.06b0f9ea88b7aE+52#55\",\n        Greater,\n    );\n    // - x != Limb::MAX in float_can_round\n    test(\n        \"4.9046e10\",\n        \"0xb.6b5eE+8#19\",\n        \"-182971083215/47776579472461276067598384651239241670113870043\",\n        Nearest,\n        \"4.9046e10\",\n        \"0xb.6b5eE+8#19\",\n        Greater,\n    );\n    // - s == Limb::WIDTH third time in float_can_round\n    test(\n        \"2.515940926449112e24\",\n        \"0x2.14c56e507323d0E+20#55\",\n        \"-3161/286335616056113777\",\n        Nearest,\n        \"2.515940926449112e24\",\n        \"0x2.14c56e507323d0E+20#55\",\n        Greater,\n    );\n    // - err0 <= prec || err <= prec in float_can_round\n    test(\n        \"5.96046446e-8\",\n        \"0xf.ffffffE-7#28\",\n        \"-255/4261412864\",\n        Nearest,\n        \"-2.34664179e-10\",\n        \"-0x1.0204182E-8#28\",\n        Less,\n    );\n    // - t == 0 in add_rational_prec_round_assign_helper\n    test(\n        \"64.0\",\n        \"0x40.00000#24\",\n        \"-215679573337202053366254388918461596342975394375083745820919489101824/336999333319768176\\\n        9435117813341997219028918889483691361889027096575\",\n        Nearest,\n        \"-3.7241676e-9\",\n        \"-0xf.fec40E-8#24\",\n        Greater,\n    );\n    // - max_exponent > i64::from(Float::MAX_EXPONENT) - 2 in add_rational_prec_round\n    test_helper(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n        true,\n    );\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n        true,\n    );\n    // - min_exponent >= Float::MAX_EXPONENT in add_rational_prec_round\n    // - both signs positive in float_rational_sum_sign\n    // - float_rational_sum_sign(x, &y) && (rm == Ceiling || rm == Up || rm == Nearest) in\n    //   add_rational_prec_round\n    test_helper(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n        true,\n    );\n    // - float_rational_sum_sign(x, &y) && (rm == Floor || rm == Down) in add_rational_prec_round\n    test_helper(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n        true,\n    );\n    // - !float_rational_sum_sign(x, &y) && (rm == Ceiling || rm == Down) in add_rational_prec_round\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n        true,\n    );\n    // - signs different and x.lt_abs(y) in float_rational_sum_sign\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) + 1),\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n        true,\n    );\n    // - both signs negative in float_rational_sum_sign\n    // - !float_rational_sum_sign(x, &y) && (rm == Floor || rm == Up || rm == Nearest) in\n    //   add_rational_prec_round\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n        true,\n    );\n    test_helper(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Rational::ONE + Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n        true,\n    );\n    test_helper(\n        \"1.0\",\n        \"0x1.0#1\",\n        Rational::NEGATIVE_ONE - Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n        true,\n    );\n}\n\n#[test]\nfn add_rational_round_fail() {\n    assert_panic!(Float::one_prec(1).add_rational_round(Rational::from_unsigneds(1u32, 3), Exact));\n    assert_panic!(\n        Float::one_prec(1).add_rational_round_val_ref(&Rational::from_unsigneds(1u32, 3), Exact)\n    );\n    assert_panic!(\n        Float::one_prec(1).add_rational_round_ref_val(Rational::from_unsigneds(1u32, 3), Exact)\n    );\n    assert_panic!(\n        Float::one_prec(1).add_rational_round_ref_ref(&Rational::from_unsigneds(1u32, 3), Exact)\n    );\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_rational_round_assign(Rational::from_unsigneds(1u32, 3), Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_rational_round_assign_ref(&Rational::from_unsigneds(1u32, 3), Exact)\n    });\n}\n\n#[test]\nfn test_add_rational_prec_round() {\n    let test = |s, s_hex, t, prec, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (sum, o) = x.clone().add_rational_prec_round(y.clone(), prec, rm);\n        assert!(sum.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(sum.to_string(), out);\n        assert_eq!(to_hex_string(&sum), out_hex);\n\n        let (sum_alt, o_alt) = x.clone().add_rational_prec_round_val_ref(&y, prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let (sum_alt, o_alt) = x.add_rational_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let (sum_alt, o_alt) = x.add_rational_prec_round_ref_ref(&y, prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_rational_prec_round_assign(y.clone(), prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.add_rational_prec_round_assign_ref(&y, prec, rm);\n        assert!(sum_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&sum_alt));\n        assert_eq!(o_alt, o);\n\n        let (sum_alt, o_alt) = add_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sum, rug_o) = rug_add_rational_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sum)),\n                ComparableFloatRef(&sum)\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"123\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"123\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"123\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\n        \"-0.0\", \"-0x0.0\", \"1/3\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Greater,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 2, Floor, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 2, Ceiling, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 2, Down, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 2, Up, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 2, Nearest, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 2, Exact, \"3.0\", \"0x3.0#2\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        100,\n        Floor,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        100,\n        Ceiling,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        100,\n        Down,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        100,\n        Up,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        100,\n        Nearest,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Floor,\n        \"3.473\",\n        \"0x3.79#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Down,\n        \"3.473\",\n        \"0x3.79#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Up,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Floor,\n        \"2.805\",\n        \"0x2.ce#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Ceiling,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Down,\n        \"2.805\",\n        \"0x2.ce#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Up,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Nearest,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Floor,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"-2.805\",\n        \"-0x2.ce#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Down,\n        \"-2.805\",\n        \"-0x2.ce#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Up,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Floor,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Ceiling,\n        \"-3.473\",\n        \"-0x3.79#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Down,\n        \"-3.473\",\n        \"-0x3.79#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Up,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Nearest,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1/50000\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1/50000\",\n        10,\n        Ceiling,\n        \"1.002\",\n        \"0x1.008#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1/50000\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1/50000\",\n        10,\n        Up,\n        \"1.002\",\n        \"0x1.008#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1/50000\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Less,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"-1\", 10, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n}\n\n#[test]\nfn add_rational_prec_round_fail() {\n    assert_panic!(Float::one_prec(1).add_rational_prec_round(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).add_rational_prec_round_val_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).add_rational_prec_round_ref_val(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).add_rational_prec_round_ref_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_rational_prec_round_assign(Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.add_rational_prec_round_assign_ref(&Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn add_prec_round_properties_helper(\n    x: Float,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (sum, o) = x.clone().add_prec_round(y.clone(), prec, rm);\n    assert!(sum.is_valid());\n    let (sum_alt, o_alt) = x.clone().add_prec_round_val_ref(&y, prec, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_prec_round_ref_ref(&y, prec, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (sum_alt, o_alt) = add_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_sum, rug_o) = rug_add_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sum)),\n            ComparableFloatRef(&sum)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && sum.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                sum.sub_prec_round_ref_ref(&x, y.significant_bits(), Exact)\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(y.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloat(\n                sum.sub_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n    }\n\n    if !extreme {\n        let r_sum = if sum.is_finite() {\n            if sum.is_normal() {\n                assert_eq!(sum.get_prec(), Some(prec));\n            }\n            let r_sum = Rational::exact_from(&x) + Rational::exact_from(&y);\n            assert_eq!(sum.partial_cmp(&r_sum), Some(o));\n            if o == Less {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if o == Greater {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n            Some(r_sum)\n        } else {\n            assert_eq!(o, Equal);\n            None\n        };\n\n        match (r_sum.is_some() && *r_sum.as_ref().unwrap() >= 0u32, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    }\n\n    let (sum_alt, o_alt) = y.add_prec_round_ref_ref(&x, prec, rm);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let (sum_alt, o_alt) = x.sub_prec_round_ref_val(-&y, prec, rm);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let (mut sum_alt, mut o_alt) = (-&x).sub_prec_round_val_ref(&y, prec, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut sum_alt, mut o_alt) = (-&x).add_prec_round(-&y, prec, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.add_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(sum.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.add_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn add_prec_round_properties() {\n    float_float_unsigned_rounding_mode_quadruple_gen_var_1().test_properties(|(x, y, prec, rm)| {\n        add_prec_round_properties_helper(x, y, prec, rm, false);\n    });\n\n    float_float_unsigned_rounding_mode_quadruple_gen_var_5().test_properties(|(x, y, prec, rm)| {\n        add_prec_round_properties_helper(x, y, prec, rm, true);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (sum, o) = x.add_prec_round_ref_val(Float::NAN, prec, rm);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        let (sum, o) = Float::NAN.add_prec_round_val_ref(&x, prec, rm);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(\n                    x.add_prec_round_ref_val(Float::INFINITY, prec, rm),\n                    (Float::INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::INFINITY.add_prec_round_val_ref(&x, prec, rm),\n                    (Float::INFINITY, Equal)\n                );\n            }\n            if x != Float::INFINITY {\n                assert_eq!(\n                    x.add_prec_round_ref_val(Float::NEGATIVE_INFINITY, prec, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.add_prec_round_val_ref(&x, prec, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (sum, o) = x.add_prec_round_ref_val(Float::ZERO, prec, rm);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n\n            let (sum, o) = Float::ZERO.add_prec_round_val_ref(&x, prec, rm);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n        }\n        if rm != Floor || !x.is_positive_zero() {\n            let (sum, o) = x.add_prec_round_ref_val(Float::NEGATIVE_ZERO, prec, rm);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n\n            let (sum, o) = Float::NEGATIVE_ZERO.add_prec_round_val_ref(&x, prec, rm);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n}\n\nfn add_prec_properties_helper(x: Float, y: Float, prec: u64, extreme: bool) {\n    let (sum, o) = x.clone().add_prec(y.clone(), prec);\n    assert!(sum.is_valid());\n    let (sum_alt, o_alt) = x.clone().add_prec_val_ref(&y, prec);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_prec_ref_val(y.clone(), prec);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_prec_ref_ref(&y, prec);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (sum_alt, o_alt) = add_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_sum, rug_o) = rug_add_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Float::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_sum)),\n        ComparableFloatRef(&sum)\n    );\n    assert_eq!(rug_o, o);\n\n    let (sum_alt, o_alt) = x.add_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if o == Equal && sum.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                sum.sub_prec_ref_ref(&x, y.significant_bits())\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(y.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloat(\n                sum.sub_prec_ref_ref(&y, x.significant_bits())\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n    }\n\n    if sum.is_finite() {\n        if sum.is_normal() {\n            assert_eq!(sum.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_sum = Rational::exact_from(&x) + Rational::exact_from(&y);\n            assert_eq!(sum.partial_cmp(&r_sum), Some(o));\n            if o == Less {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if o == Greater {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n        }\n    }\n\n    let (sum_alt, o_alt) = y.add_prec_ref_ref(&x, prec);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let (sum_alt, o_alt) = x.sub_prec_ref_val(-&y, prec);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if (x != 0u32 && y != 0u32) || (x.is_sign_positive() && y.is_sign_positive()) {\n        let (mut sum_alt, mut o_alt) = (-&x).sub_prec_val_ref(&y, prec);\n        sum_alt.neg_assign();\n        sum_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&sum_alt),\n            ComparableFloatRef(&sum.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (mut sum_alt, mut o_alt) = (-x).add_prec(-y, prec);\n        sum_alt.neg_assign();\n        sum_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&sum_alt),\n            ComparableFloatRef(&sum.abs_negative_zero())\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn add_prec_properties() {\n    float_float_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        add_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_float_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        add_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        let (sum, o) = x.add_prec_ref_val(Float::NAN, prec);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        let (sum, o) = Float::NAN.add_prec_val_ref(&x, prec);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(\n                    x.add_prec_ref_val(Float::INFINITY, prec),\n                    (Float::INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::INFINITY.add_prec_val_ref(&x, prec),\n                    (Float::INFINITY, Equal)\n                );\n            }\n            if x != Float::INFINITY {\n                assert_eq!(\n                    x.add_prec_ref_val(Float::NEGATIVE_INFINITY, prec),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.add_prec_val_ref(&x, prec),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (sum, o) = x.add_prec_ref_val(Float::ZERO, prec);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n\n            let (sum, o) = Float::ZERO.add_prec_val_ref(&x, prec);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n        }\n        let (sum, o) = x.add_prec_ref_val(Float::NEGATIVE_ZERO, prec);\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.set_prec(prec);\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n\n        let (sum, o) = Float::NEGATIVE_ZERO.add_prec_val_ref(&x, prec);\n        let mut sum_alt = x.clone();\n        let o_alt = sum_alt.set_prec(prec);\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn add_round_properties_helper(x: Float, y: Float, rm: RoundingMode, extreme: bool) {\n    let (sum, o) = x.clone().add_round(y.clone(), rm);\n    assert!(sum.is_valid());\n    let (sum_alt, o_alt) = x.clone().add_round_val_ref(&y, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_round_ref_val(y.clone(), rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let (sum_alt, o_alt) = x.add_round_ref_ref(&y, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (sum_alt, o_alt) = add_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    }\n    let (sum_alt, o_alt) =\n        x.add_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), rm);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if o == Equal && sum.is_finite() {\n        assert_eq!(sum.sub_round_ref_ref(&x, Exact).0, y);\n        assert_eq!(sum.sub_round_ref_ref(&y, Exact).0, x);\n    }\n\n    if !extreme {\n        let r_sum = if sum.is_finite() {\n            if x.is_normal() && y.is_normal() && sum.is_normal() {\n                assert_eq!(\n                    sum.get_prec(),\n                    Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n                );\n            }\n            let r_sum = Rational::exact_from(&x) + Rational::exact_from(&y);\n            assert_eq!(sum.partial_cmp(&r_sum), Some(o));\n            if o == Less {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if o == Greater {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n            Some(r_sum)\n        } else {\n            assert_eq!(o, Equal);\n            None\n        };\n\n        match (r_sum.is_some() && *r_sum.as_ref().unwrap() >= 0u32, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_sum, rug_o) =\n            rug_add_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sum)),\n            ComparableFloatRef(&sum)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (sum_alt, o_alt) = y.add_round_ref_ref(&x, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let (sum_alt, o_alt) = x.sub_round_ref_val(-&y, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let (mut sum_alt, mut o_alt) = (-&x).sub_round_val_ref(&y, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n\n    let (mut sum_alt, mut o_alt) = (-&x).add_round(-&y, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.add_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(sum.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.add_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn add_round_properties() {\n    float_float_rounding_mode_triple_gen_var_1().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_29().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, true);\n    });\n\n    float_float_rounding_mode_triple_gen_var_4().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_5().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_6().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_7().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_8().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_9().test_properties(|(x, y, rm)| {\n        add_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let (sum, o) = x.add_round_ref_val(Float::NAN, rm);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        let (sum, o) = Float::NAN.add_round_val_ref(&x, rm);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(\n                    x.add_round_ref_val(Float::INFINITY, rm),\n                    (Float::INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::INFINITY.add_round_val_ref(&x, rm),\n                    (Float::INFINITY, Equal)\n                );\n            }\n            if x != Float::INFINITY {\n                assert_eq!(\n                    x.add_round_ref_val(Float::NEGATIVE_INFINITY, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.add_round_val_ref(&x, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (sum, o) = x.add_round_ref_val(Float::ZERO, rm);\n            assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n            let (sum, o) = Float::ZERO.add_round_val_ref(&x, rm);\n            assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n        }\n        if rm != Floor || !x.is_positive_zero() {\n            let (sum, o) = x.add_round_ref_val(Float::NEGATIVE_ZERO, rm);\n            assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n            let (sum, o) = Float::NEGATIVE_ZERO.add_round_val_ref(&x, rm);\n            assert_eq!(ComparableFloatRef(&sum), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn add_properties_helper_1<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let sum_1 = x + y;\n        let sum_2 = emulate_float_float_to_float_fn(Float::add_prec, x, y);\n        assert_eq!(NiceFloat(sum_1), NiceFloat(sum_2));\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn add_properties_helper_2(x: Float, y: Float, extreme: bool) {\n    let sum = x.clone() + y.clone();\n    assert!(sum.is_valid());\n    let sum_alt = x.clone() + &y;\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = &x + y.clone();\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = &x + &y;\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let mut x_alt = x.clone();\n    x_alt += y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n\n    let mut x_alt = x.clone();\n    x_alt += &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n\n    if !extreme {\n        let sum_alt = add_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    }\n    let sum_alt = x\n        .add_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), Nearest)\n        .0;\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = x\n        .add_prec_ref_ref(&y, max(x.significant_bits(), y.significant_bits()))\n        .0;\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let (sum_alt, o) = x.add_round_ref_ref(&y, Nearest);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    if o == Equal && sum.is_finite() {\n        assert_eq!(&sum - &x, y);\n        assert_eq!(&sum - &y, x);\n    }\n\n    if sum.is_finite() && x.is_normal() && y.is_normal() && sum.is_normal() {\n        assert_eq!(\n            sum.get_prec(),\n            Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n        );\n        if !extreme {\n            let r_sum = Rational::exact_from(&x) + Rational::exact_from(&y);\n            if sum < r_sum {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if sum > r_sum {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n        }\n    }\n\n    let rug_sum = rug_add(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_sum)),\n        ComparableFloatRef(&sum),\n    );\n\n    let sum_alt = &y + &x;\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let sum_alt = &x - -&y;\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    if (x != 0u32 && y != 0u32) || (x.is_sign_positive() && y.is_sign_positive()) {\n        let sum_alt = (-(-&x - &y)).abs_negative_zero();\n        assert_eq!(\n            ComparableFloatRef(&sum_alt),\n            ComparableFloatRef(&sum.abs_negative_zero_ref())\n        );\n\n        let sum_alt = (-(-&x + -&y)).abs_negative_zero();\n        assert_eq!(\n            ComparableFloatRef(&sum_alt),\n            ComparableFloatRef(&sum.abs_negative_zero())\n        );\n    }\n\n    // example of associativity failure: 0x1.0#1 0x2.0#1 -0x1.0#1\n}\n\n#[test]\nfn add_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, true);\n    });\n\n    float_pair_gen_var_2().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_3().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_4().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_5().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_6().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_7().test_properties(|(x, y)| {\n        add_properties_helper_2(x, y, false);\n    });\n\n    apply_fn_to_primitive_floats!(add_properties_helper_1);\n\n    float_gen().test_properties(|x| {\n        assert!((&x + Float::NAN).is_nan());\n        assert!((Float::NAN + &x).is_nan());\n        if !x.is_nan() {\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(&x + Float::INFINITY, Float::INFINITY);\n                assert_eq!(Float::INFINITY + &x, Float::INFINITY);\n            }\n            if x != Float::INFINITY {\n                assert_eq!(&x + Float::NEGATIVE_INFINITY, Float::NEGATIVE_INFINITY);\n                assert_eq!(Float::NEGATIVE_INFINITY + &x, Float::NEGATIVE_INFINITY);\n            }\n        }\n        if !x.is_negative_zero() {\n            assert_eq!(\n                ComparableFloatRef(&(&x + Float::ZERO)),\n                ComparableFloatRef(&x)\n            );\n            assert_eq!(\n                ComparableFloatRef(&(Float::ZERO + &x)),\n                ComparableFloatRef(&x)\n            );\n        }\n        assert_eq!(\n            ComparableFloatRef(&(&x + Float::NEGATIVE_ZERO)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(\n            ComparableFloatRef(&(Float::NEGATIVE_ZERO + &x)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(ComparableFloat(&x + &x), ComparableFloat(x << 1u32));\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn add_rational_prec_round_properties_helper(\n    x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (sum, o) = x.clone().add_rational_prec_round(y.clone(), prec, rm);\n    assert!(sum.is_valid());\n    let (sum_alt, o_alt) = x.clone().add_rational_prec_round_val_ref(&y, prec, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_rational_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_rational_prec_round_ref_ref(&y, prec, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_rational_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_rational_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (sum_alt, o_alt) = add_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_sum, rug_o) = rug_add_rational_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sum)),\n            ComparableFloatRef(&sum)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && sum.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                sum.sub_rational_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        // TODO additional test\n    }\n\n    if sum.is_finite() {\n        if sum.is_normal() {\n            assert_eq!(sum.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_sum = Rational::exact_from(&x) + &y;\n            assert_eq!(sum.partial_cmp(&r_sum), Some(o));\n            if o == Less {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if o == Greater {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n            match (r_sum >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (sum_alt, o_alt) = x.sub_rational_prec_round_ref_val(-&y, prec, rm);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let (mut sum_alt, mut o_alt) = (-&x).sub_rational_prec_round_val_ref(&y, prec, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut sum_alt, mut o_alt) = (-&x).add_rational_prec_round(-&y, prec, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.add_rational_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(sum.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.add_rational_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn add_rational_prec_round_properties() {\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_1().test_properties(\n        |(x, y, prec, rm)| {\n            add_rational_prec_round_properties_helper(x, y, prec, rm, false);\n        },\n    );\n\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_7().test_properties_with_limit(\n        20,\n        |(x, y, prec, rm)| {\n            add_rational_prec_round_properties_helper(x, y, prec, rm, true);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        if !x.is_negative_zero() {\n            let (sum, o) = x.add_rational_prec_round_ref_val(Rational::ZERO, prec, rm);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n\n    rational_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (sum, o) = Float::NAN.add_rational_prec_round_val_ref(&x, prec, rm);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.add_rational_prec_round_val_ref(&x, prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.add_rational_prec_round_val_ref(&x, prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (sum, o) = Float::ZERO.add_rational_prec_round_val_ref(&x, prec, rm);\n        let (sum_alt, o_alt) = Float::from_rational_prec_round_ref(&x, prec, rm);\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n\n        let (sum, o) = Float::NEGATIVE_ZERO.add_rational_prec_round_val_ref(&x, prec, rm);\n        let (mut sum_alt, o_alt) = Float::from_rational_prec_round_ref(&x, prec, rm);\n        if x == 0u32 {\n            sum_alt.neg_assign();\n        }\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\nfn add_rational_prec_properties_helper(x: Float, y: Rational, prec: u64, extreme: bool) {\n    let (sum, o) = x.clone().add_rational_prec(y.clone(), prec);\n    assert!(sum.is_valid());\n    let (sum_alt, o_alt) = x.clone().add_rational_prec_val_ref(&y, prec);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_rational_prec_ref_val(y.clone(), prec);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n    let (sum_alt, o_alt) = x.add_rational_prec_ref_ref(&y, prec);\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_rational_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_rational_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (sum_alt, o_alt) = add_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_sum, rug_o) = rug_add_rational_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Rational::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_sum)),\n        ComparableFloatRef(&sum)\n    );\n    assert_eq!(rug_o, o);\n\n    if o == Equal && sum.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                sum.sub_rational_prec_ref_ref(&y, x.significant_bits())\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        // TODO additional test\n    }\n\n    let (sum_alt, o_alt) = x.add_rational_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if sum.is_finite() {\n        if sum.is_normal() {\n            assert_eq!(sum.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_sum = Rational::exact_from(&x) + &y;\n            assert_eq!(sum.partial_cmp(&r_sum), Some(o));\n            if o == Less {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if o == Greater {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n        }\n    }\n\n    let (sum_alt, o_alt) = x.sub_rational_prec_ref_val(-&y, prec);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if (x != 0u32 && y != 0u32) || x.is_sign_positive() {\n        let (mut sum_alt, mut o_alt) = (-&x).sub_rational_prec_val_ref(&y, prec);\n        sum_alt.neg_assign();\n        sum_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n\n        let (mut sum_alt, mut o_alt) = (-x).add_rational_prec(-y, prec);\n        sum_alt.neg_assign();\n        sum_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn add_rational_prec_properties() {\n    float_rational_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        add_rational_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_rational_unsigned_triple_gen_var_2().test_properties_with_limit(20, |(x, y, prec)| {\n        add_rational_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        if !x.is_negative_zero() {\n            let (sum, o) = x.add_rational_prec_ref_val(Rational::ZERO, prec);\n            let mut sum_alt = x.clone();\n            let o_alt = sum_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let (sum, o) = Float::NAN.add_rational_prec_val_ref(&x, prec);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.add_rational_prec_val_ref(&x, prec),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.add_rational_prec_val_ref(&x, prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        let (sum, o) = Float::ZERO.add_rational_prec_val_ref(&x, prec);\n        let (sum_alt, o_alt) = Float::from_rational_prec_ref(&x, prec);\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n\n        let (sum, o) = Float::NEGATIVE_ZERO.add_rational_prec_val_ref(&x, prec);\n        let (mut sum_alt, o_alt) = Float::from_rational_prec_ref(&x, prec);\n        if x == 0u32 {\n            sum_alt.neg_assign();\n        }\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn add_rational_round_properties_helper(x: Float, y: Rational, rm: RoundingMode, extreme: bool) {\n    let (sum, o) = x.clone().add_rational_round(y.clone(), rm);\n    assert!(sum.is_valid());\n    let (sum_alt, o_alt) = x.clone().add_rational_round_val_ref(&y, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let (sum_alt, o_alt) = x.add_rational_round_ref_val(y.clone(), rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let (sum_alt, o_alt) = x.add_rational_round_ref_ref(&y, rm);\n    assert!(sum_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_rational_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.add_rational_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (sum_alt, o_alt) =\n            add_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n        assert_eq!(o_alt, o);\n    }\n\n    let (sum_alt, o_alt) = x.add_rational_prec_round_ref_ref(&y, x.significant_bits(), rm);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    assert_eq!(o_alt, o);\n\n    if o == Equal && sum.is_finite() && sum != 0 {\n        assert_eq!(sum.sub_rational_round_ref_ref(&y, Exact).0, x);\n        // TODO additional test\n    }\n\n    if sum.is_finite() {\n        if x.is_normal() && sum.is_normal() {\n            assert_eq!(sum.get_prec(), Some(x.get_prec().unwrap()));\n        }\n        if !extreme {\n            let r_sum = Rational::exact_from(&x) + &y;\n            assert_eq!(sum.partial_cmp(&r_sum), Some(o));\n            if o == Less {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if o == Greater {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n\n            match (r_sum >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_sum, rug_o) = rug_add_rational_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sum)),\n            ComparableFloatRef(&sum)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (sum_alt, o_alt) = x.sub_rational_round_ref_val(-&y, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let (mut sum_alt, mut o_alt) = (-&x).sub_rational_round_val_ref(&y, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n\n    let (mut sum_alt, mut o_alt) = (-&x).add_rational_round(-&y, -rm);\n    sum_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(sum_alt.abs_negative_zero_ref()),\n        ComparableFloat(sum.abs_negative_zero_ref())\n    );\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.add_rational_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(sum.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.add_rational_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn add_rational_round_properties() {\n    float_rational_rounding_mode_triple_gen_var_1().test_properties(|(x, y, rm)| {\n        add_rational_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rational_rounding_mode_triple_gen_var_8().test_properties_with_limit(20, |(x, y, rm)| {\n        add_rational_round_properties_helper(x, y, rm, true);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        if !x.is_negative_zero() {\n            let (sum, o) = x.add_rational_round_ref_val(Rational::ZERO, rm);\n            assert_eq!(ComparableFloat(sum), ComparableFloat(x));\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_rounding_mode_pair_gen_var_6().test_properties(|(x, rm)| {\n        let (sum, o) = Float::NAN.add_rational_round_val_ref(&x, rm);\n        assert!(sum.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.add_rational_round_val_ref(&x, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.add_rational_round_val_ref(&x, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        let (sum, o) = Float::ZERO.add_rational_round_val_ref(&x, rm);\n        let (sum_alt, o_alt) = Float::from_rational_prec_round_ref(&x, 1, rm);\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n\n        let (sum, o) = Float::NEGATIVE_ZERO.add_rational_round_val_ref(&x, rm);\n        let (mut sum_alt, o_alt) = Float::from_rational_prec_round_ref(&x, 1, rm);\n        if x == 0u32 {\n            sum_alt.neg_assign();\n        }\n        assert_eq!(ComparableFloat(sum), ComparableFloat(sum_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn add_rational_properties_helper(x: Float, y: Rational, extreme: bool) {\n    let sum = x.clone() + y.clone();\n    assert!(sum.is_valid());\n    let sum_alt = x.clone() + &y;\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = &x + y.clone();\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = &x + &y;\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let sum_alt = y.clone() + x.clone();\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = y.clone() + &x;\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = &y + x.clone();\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = &y + &x;\n    assert!(sum_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    let mut x_alt = x.clone();\n    x_alt += y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n\n    let mut x_alt = x.clone();\n    x_alt += &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sum));\n\n    if !extreme {\n        let sum_alt =\n            add_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    }\n\n    let sum_alt = x\n        .add_rational_prec_round_ref_ref(&y, x.significant_bits(), Nearest)\n        .0;\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let sum_alt = x.add_rational_prec_ref_ref(&y, x.significant_bits()).0;\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    let (sum_alt, o) = x.add_rational_round_ref_ref(&y, Nearest);\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    if o == Equal && sum.is_finite() && sum != 0 {\n        assert_eq!(&sum - &y, x);\n        // TODO additional test\n    }\n\n    if sum.is_finite() && x.is_normal() && sum.is_normal() {\n        assert_eq!(sum.get_prec(), Some(x.get_prec().unwrap()));\n        if !extreme {\n            let r_sum = Rational::exact_from(&x) + &y;\n            if sum < r_sum {\n                let mut next = sum.clone();\n                next.increment();\n                assert!(next > r_sum);\n            } else if sum > r_sum {\n                let mut next = sum.clone();\n                next.decrement();\n                assert!(next < r_sum);\n            }\n        }\n    }\n\n    let rug_sum = rug_add_rational(&rug::Float::exact_from(&x), &rug::Rational::from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_sum)),\n        ComparableFloatRef(&sum),\n    );\n\n    let sum_alt = &x - -&y;\n    assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n    if (x != 0u32 && y != 0u32) || x.is_sign_positive() {\n        let sum_alt = (-(-&x - &y)).abs_negative_zero();\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n\n        let sum_alt = (-(-&x + -&y)).abs_negative_zero();\n        assert_eq!(ComparableFloatRef(&sum_alt), ComparableFloatRef(&sum));\n    }\n}\n\n#[test]\nfn add_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        add_rational_properties_helper(x, y, false);\n    });\n\n    float_rational_pair_gen_var_2().test_properties_with_limit(20, |(x, y)| {\n        add_rational_properties_helper(x, y, true);\n    });\n\n    float_gen().test_properties(|x| {\n        assert_eq!(\n            ComparableFloatRef(&(&x + Rational::ZERO)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(\n            ComparableFloatRef(&(Rational::ZERO + &x)),\n            ComparableFloatRef(&x)\n        );\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!((&x + Float::NAN).is_nan());\n        assert!((Float::NAN + &x).is_nan());\n        assert_eq!(&x + Float::INFINITY, Float::INFINITY);\n        assert_eq!(Float::INFINITY + &x, Float::INFINITY);\n        assert_eq!(&x + Float::NEGATIVE_INFINITY, Float::NEGATIVE_INFINITY);\n        assert_eq!(Float::NEGATIVE_INFINITY + &x, Float::NEGATIVE_INFINITY);\n        let sum_alt = Float::from_rational_prec_ref(&x, 1).0;\n        assert_eq!(\n            ComparableFloat(&x + Float::ZERO),\n            ComparableFloat(sum_alt.clone())\n        );\n        assert_eq!(\n            ComparableFloat(Float::ZERO + &x),\n            ComparableFloat(sum_alt.clone())\n        );\n        assert_eq!(\n            ComparableFloat((&x + Float::NEGATIVE_ZERO).abs_negative_zero()),\n            ComparableFloat(sum_alt.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloat((Float::NEGATIVE_ZERO + &x).abs_negative_zero()),\n            ComparableFloat(sum_alt.abs_negative_zero())\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/agm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Agm, AgmAssign, PowerOf2, Square};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeZero, One, OneHalf, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::arithmetic::agm::{primitive_float_agm, primitive_float_agm_rational};\nuse malachite_float::test_util::arithmetic::agm::{\n    agm_prec_round_extended, rug_agm, rug_agm_prec, rug_agm_prec_round, rug_agm_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_33, float_float_rounding_mode_triple_gen_var_34,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_9,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_10, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_2, float_gen, float_gen_var_4, float_gen_var_15,\n    float_pair_gen, float_pair_gen_var_10, float_rounding_mode_pair_gen,\n    float_rounding_mode_pair_gen_var_32, float_rounding_mode_pair_gen_var_33,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_6, float_unsigned_pair_gen_var_7,\n    float_unsigned_rounding_mode_triple_gen_var_1, float_unsigned_rounding_mode_triple_gen_var_17,\n    float_unsigned_rounding_mode_triple_gen_var_18,\n    rational_rational_unsigned_rounding_mode_quadruple_gen_var_1,\n    rational_unsigned_rounding_mode_triple_gen_var_5,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_pair_gen, rational_rational_unsigned_triple_gen_var_2,\n    rational_unsigned_pair_gen_var_8,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::cmp::max;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_agm() {\n    let test = |s, s_hex, t, t_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let agm = x.clone().agm(y.clone());\n        assert!(agm.is_valid());\n\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n\n        let agm_alt = x.clone().agm(&y);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        let agm_alt = (&x).agm(y.clone());\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        let agm_alt = (&x).agm(&y);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n\n        let mut agm_alt = x.clone();\n        agm_alt.agm_assign(y.clone());\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        let mut agm_alt = x.clone();\n        agm_alt.agm_assign(&y);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_agm(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y)\n            ))),\n            ComparableFloatRef(&agm),\n        );\n\n        let prec = max(x.significant_bits(), y.significant_bits());\n        let agm_alt = agm_prec_round_extended(x, y, prec, Nearest).0;\n        assert_eq!(ComparableFloat(agm_alt), ComparableFloat(agm));\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\"-Infinity\", \"-Infinity\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"-Infinity\", \"-Infinity\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\",\n    );\n    test(\"-Infinity\", \"-Infinity\", \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\");\n\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", \"1.5\", \"0x1.8#2\");\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", \"1.5\", \"0x1.8#2\");\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", \"1.5\", \"0x1.8#2\");\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        \"1.457\",\n        \"0x1.750#10\",\n    );\n    test(\n        \"24.0\",\n        \"0x18.000000000000000000000000#100\",\n        \"6.0\",\n        \"0x6.0000000000000000000000000#100\",\n        \"13.45817148172561542076681315698\",\n        \"0xd.754ab9e9f8ac5a0692360241#100\",\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"2.1920339783176708\",\n        \"0x2.31292388985d0#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"NaN\",\n        \"NaN\",\n    );\n\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        \"too_big\",\n        \"0x2.0E+268435448#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0e-9\",\n        \"0x8.0E-8#1\",\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_big\",\n        \"0x1.0E+268435448#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x7.184a0f216320E-268435451#48\",\n        \"1.0e-7\",\n        \"0x2.0E-6#2\",\n        \"2.51596539536877e-16\",\n        \"0x1.2212310c5964E-13#48\",\n    );\n}\n\n#[test]\nfn test_agm_prec() {\n    let test = |s, s_hex, t, t_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (agm, o) = x.clone().agm_prec(y.clone(), prec);\n        assert!(agm.is_valid());\n\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, o_out);\n\n        let (agm_alt, o_alt) = x.clone().agm_prec_val_ref(&y, prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (agm_alt, o_alt) = x.agm_prec_ref_val(y.clone(), prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (agm_alt, o_alt) = x.agm_prec_ref_ref(&y, prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut agm_alt = x.clone();\n        let o_alt = agm_alt.agm_prec_assign(y.clone(), prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut agm_alt = x.clone();\n        let o_alt = agm_alt.agm_prec_assign_ref(&y, prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (rug_agm, rug_o) = rug_agm_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_agm)),\n            ComparableFloatRef(&agm)\n        );\n        assert_eq!(rug_o, o);\n\n        let (agm_alt, o_alt) = agm_prec_round_extended(x, y, prec, Nearest);\n        assert_eq!(ComparableFloat(agm_alt), ComparableFloat(agm));\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 2, \"1.5\", \"0x1.8#2\", Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 2, \"1.5\", \"0x1.8#2\", Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 2, \"1.5\", \"0x1.8#2\", Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 2, \"1.5\", \"0x1.8#2\", Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        2,\n        \"1.5\",\n        \"0x1.8#2\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"2.191\",\n        \"0x2.31#10\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        1,\n        \"0.1\",\n        \"0x0.2#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"0.0002\",\n        \"0x0.001#1\",\n        20,\n        \"0.16187\",\n        \"0x0.297050#20\",\n        Less,\n    );\n    // - in agm_prec_round_ref_ref_normal\n    // - *a >= 0u32 && *b >= 0u32 in agm_prec_round_ref_ref_normal\n    // - a == b in agm_prec_round_ref_ref_normal\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 1, \"1.0\", \"0x1.0#1\", Equal,\n    );\n    // - *a < 0u32 || *b < 0u32 in agm_prec_round_ref_ref_normal\n    test(\"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    // - a < b in agm_prec_round_ref_ref_normal\n    // - !u_overflow && !u_underflow && !v_overflow && !v_underflow in agm_prec_round_ref_ref_normal\n    // - cmp != Equal in agm_prec_round_ref_ref_normal\n    // - eq <= p / 4 in agm_prec_round_ref_ref_normal\n    // - !uf.is_infinite() in agm_prec_round_ref_ref_normal\n    // - eq > p / 4 in agm_prec_round_ref_ref_normal\n    // - !underflow in agm_prec_round_ref_ref_normal\n    // - terminate Ziv in agm_prec_round_ref_ref_normal\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, \"1.0\", \"0x1.0#1\", Less,\n    );\n    // - a > b in agm_prec_round_ref_ref_normal\n    test(\n        \"2.0\", \"0x2.0#1\", \"1.0\", \"0x1.0#1\", 1, \"1.0\", \"0x1.0#1\", Less,\n    );\n    // - don't terminate Ziv in agm_prec_round_ref_ref_normal\n    test(\n        \"3.0379e20\",\n        \"0x1.0780E+17#14\",\n        \"6.0e1\",\n        \"0x4.0E+1#3\",\n        14,\n        \"1.075e19\",\n        \"0x9.530E+15#14\",\n        Less,\n    );\n    // - uf.is_infinite() in agm_prec_round_ref_ref_normal\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        \"too_big\",\n        \"0x2.0E+268435448#1\",\n        Less,\n    );\n    // - u_overflow || u_underflow || v_overflow || v_underflow in agm_prec_round_ref_ref_normal\n    // - u_overflow || v_overflow in agm_prec_round_ref_ref_normal\n    // - e1 + e2 > Float::MAX_EXPONENT in agm_prec_round_ref_ref_normal\n    test(\n        \"2.0\",\n        \"0x2.0#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        \"too_big\",\n        \"0x2.0E+268435448#1\",\n        Less,\n    );\n    // - !u_overflow && !v_overflow in agm_prec_round_ref_ref_normal\n    test(\n        \"0.5\",\n        \"0x0.8#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        \"9.0e-10\",\n        \"0x4.0E-8#1\",\n        Less,\n    );\n    // - underflow in agm_prec_round_ref_ref_normal\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        2,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Less,\n    );\n    // - e1 + e2 <= Float::MAX_EXPONENT in agm_prec_round_ref_ref_normal\n    test(\n        \"too_big\",\n        \"0x7.ffffffe3ffffffffeE+268435455#70\",\n        \"too_small\",\n        \"0x1.fffffffc1ffffffffffff1ffffe0000000000003ffffffffc00000000000000000000001fffffffffffff\\\n        ffffffffffff800000000E-268435442#424\",\n        7,\n        \"too_big\",\n        \"0x2.48E+268435448#7\",\n        Greater,\n    );\n}\n\n#[test]\nfn agm_prec_fail() {\n    assert_panic!(Float::NAN.agm_prec(Float::NAN, 0));\n    assert_panic!(Float::NAN.agm_prec_val_ref(&Float::NAN, 0));\n    assert_panic!(Float::NAN.agm_prec_ref_val(Float::NAN, 0));\n    assert_panic!(Float::NAN.agm_prec_ref_ref(&Float::NAN, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.agm_prec_assign(Float::NAN, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.agm_prec_assign_ref(&Float::NAN, 0)\n    });\n}\n\n#[test]\nfn test_agm_round() {\n    let test = |s, s_hex, t, t_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (agm, o) = x.clone().agm_round(y.clone(), rm);\n        assert!(agm.is_valid());\n\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, o_out);\n\n        let (agm_alt, o_alt) = x.clone().agm_round_val_ref(&y, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (agm_alt, o_alt) = x.agm_round_ref_val(y.clone(), rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (agm_alt, o_alt) = x.agm_round_ref_ref(&y, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut agm_alt = x.clone();\n        let o_alt = agm_alt.agm_round_assign(y.clone(), rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut agm_alt = x.clone();\n        let o_alt = agm_alt.agm_round_assign_ref(&y, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_agm, rug_o) =\n                rug_agm_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_agm)),\n                ComparableFloatRef(&agm),\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let prec = max(x.significant_bits(), y.significant_bits());\n        let (agm_alt, o_alt) = agm_prec_round_extended(x, y, prec, rm);\n        assert_eq!(ComparableFloat(agm_alt), ComparableFloat(agm));\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Floor, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Ceiling, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Down, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Up, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Less,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"1.0\", \"0x1.0#2\", Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Floor,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Ceiling,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Down,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Up,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Nearest,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"2.1920339783176708\",\n        \"0x2.31292388985d0#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"2.1920339783176712\",\n        \"0x2.31292388985d2#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"2.1920339783176708\",\n        \"0x2.31292388985d0#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"2.1920339783176712\",\n        \"0x2.31292388985d2#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"2.1920339783176708\",\n        \"0x2.31292388985d0#53\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"24.0\",\n        \"0x18.000000000000000000000000#100\",\n        \"6.0\",\n        \"0x6.0000000000000000000000000#100\",\n        Floor,\n        \"13.45817148172561542076681315696\",\n        \"0xd.754ab9e9f8ac5a0692360240#100\",\n        Less,\n    );\n    test(\n        \"24.0\",\n        \"0x18.000000000000000000000000#100\",\n        \"6.0\",\n        \"0x6.0000000000000000000000000#100\",\n        Ceiling,\n        \"13.45817148172561542076681315698\",\n        \"0xd.754ab9e9f8ac5a0692360241#100\",\n        Greater,\n    );\n    test(\n        \"24.0\",\n        \"0x18.000000000000000000000000#100\",\n        \"6.0\",\n        \"0x6.0000000000000000000000000#100\",\n        Down,\n        \"13.45817148172561542076681315696\",\n        \"0xd.754ab9e9f8ac5a0692360240#100\",\n        Less,\n    );\n    test(\n        \"24.0\",\n        \"0x18.000000000000000000000000#100\",\n        \"6.0\",\n        \"0x6.0000000000000000000000000#100\",\n        Up,\n        \"13.45817148172561542076681315698\",\n        \"0xd.754ab9e9f8ac5a0692360241#100\",\n        Greater,\n    );\n    test(\n        \"24.0\",\n        \"0x18.000000000000000000000000#100\",\n        \"6.0\",\n        \"0x6.0000000000000000000000000#100\",\n        Nearest,\n        \"13.45817148172561542076681315698\",\n        \"0xd.754ab9e9f8ac5a0692360241#100\",\n        Greater,\n    );\n}\n\n#[test]\nfn agm_round_fail() {\n    assert_panic!(Float::one_prec(1).agm_round(Float::two_prec(1), Exact));\n    assert_panic!(Float::one_prec(1).agm_round_val_ref(&Float::two_prec(1), Exact));\n    assert_panic!(Float::one_prec(1).agm_round_ref_val(Float::two_prec(1), Exact));\n    assert_panic!(Float::one_prec(1).agm_round_ref_ref(&Float::two_prec(1), Exact));\n}\n\n#[test]\nfn test_agm_prec_round() {\n    let test = |s, s_hex, t, t_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (agm, o) = x.clone().agm_prec_round(y.clone(), prec, rm);\n        assert!(agm.is_valid());\n\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, o_out);\n\n        let (agm_alt, o_alt) = x.clone().agm_prec_round_val_ref(&y, prec, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (agm_alt, o_alt) = x.agm_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (agm_alt, o_alt) = x.agm_prec_round_ref_ref(&y, prec, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut agm_alt = x.clone();\n        let o_alt = agm_alt.agm_prec_round_assign(y.clone(), prec, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut agm_alt = x.clone();\n        let o_alt = agm_alt.agm_prec_round_assign_ref(&y, prec, rm);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&agm_alt));\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_agm, rug_o) = rug_agm_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_agm)),\n                ComparableFloatRef(&agm)\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (agm_alt, o_alt) = agm_prec_round_extended(x, y, prec, rm);\n        assert_eq!(ComparableFloat(agm_alt), ComparableFloat(agm));\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Floor, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Down, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Up, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Floor,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Ceiling,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Down,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Up,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Nearest,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Floor, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Down, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Up, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Floor,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Ceiling,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Down,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Up,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Nearest,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Floor, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Down, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Up, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Floor,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Ceiling,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Down,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Up,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Nearest,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Floor, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Down, \"1.0\", \"0x1.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Up, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Floor,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Ceiling,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Down,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Up,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Nearest,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Floor,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Ceiling,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Down,\n        \"1.455\",\n        \"0x1.748#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Up,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Nearest,\n        \"1.457\",\n        \"0x1.750#10\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"2.191\",\n        \"0x2.31#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"2.195\",\n        \"0x2.32#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"2.191\",\n        \"0x2.31#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"2.195\",\n        \"0x2.32#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"2.191\",\n        \"0x2.31#10\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\", 10, Exact, \"NaN\", \"NaN\", Equal,\n    );\n}\n\n#[test]\nfn agm_prec_round_fail() {\n    assert_panic!(Float::one_prec(1).agm_prec_round(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).agm_prec_round_val_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).agm_prec_round_ref_val(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).agm_prec_round_ref_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.agm_prec_round_assign(Float::two_prec(1), 0, Floor)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.agm_prec_round_assign_ref(&Float::two_prec(1), 0, Floor)\n    });\n\n    assert_panic!(Float::one_prec(1).agm_prec_round(Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).agm_prec_round_val_ref(&Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).agm_prec_round_ref_val(Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).agm_prec_round_ref_ref(&Float::two_prec(1), 1, Exact));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.agm_prec_round_assign(Float::two_prec(1), 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.agm_prec_round_assign_ref(&Float::two_prec(1), 1, Exact)\n    });\n}\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_primitive_float_agm() {\n    fn test<T: PrimitiveFloat>(x: T, y: T, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n    {\n        assert_eq!(NiceFloat(primitive_float_agm(x, y)), NiceFloat(out));\n    }\n    test::<f32>(f32::NAN, f32::NAN, f32::NAN);\n    test::<f32>(f32::NAN, f32::INFINITY, f32::NAN);\n    test::<f32>(f32::NAN, f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(f32::NAN, 0.0, f32::NAN);\n    test::<f32>(f32::NAN, -0.0, f32::NAN);\n\n    test::<f32>(f32::INFINITY, f32::NAN, f32::NAN);\n    test::<f32>(f32::INFINITY, f32::INFINITY, f32::INFINITY);\n    test::<f32>(f32::INFINITY, f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(f32::INFINITY, 0.0, f32::NAN);\n    test::<f32>(f32::INFINITY, -0.0, f32::NAN);\n\n    test::<f32>(f32::NEGATIVE_INFINITY, f32::NAN, f32::NAN);\n    test::<f32>(f32::NEGATIVE_INFINITY, f32::INFINITY, f32::NAN);\n    test::<f32>(f32::NEGATIVE_INFINITY, f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(f32::NEGATIVE_INFINITY, 0.0, f32::NAN);\n    test::<f32>(f32::NEGATIVE_INFINITY, -0.0, f32::NAN);\n\n    test::<f32>(0.0, f32::NAN, f32::NAN);\n    test::<f32>(0.0, f32::INFINITY, f32::NAN);\n    test::<f32>(0.0, f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(0.0, 0.0, 0.0);\n    test::<f32>(0.0, -0.0, 0.0);\n\n    test::<f32>(-0.0, f32::NAN, f32::NAN);\n    test::<f32>(-0.0, f32::INFINITY, f32::NAN);\n    test::<f32>(-0.0, f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(-0.0, 0.0, 0.0);\n    test::<f32>(-0.0, -0.0, 0.0);\n\n    test::<f32>(123.0, f32::NAN, f32::NAN);\n    test::<f32>(123.0, f32::INFINITY, f32::INFINITY);\n    test::<f32>(123.0, f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(123.0, 0.0, 0.0);\n    test::<f32>(123.0, -0.0, 0.0);\n\n    test::<f32>(-123.0, f32::NAN, f32::NAN);\n    test::<f32>(-123.0, f32::INFINITY, f32::NAN);\n    test::<f32>(-123.0, f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(-123.0, 0.0, 0.0);\n    test::<f32>(-123.0, -0.0, 0.0);\n\n    test::<f32>(f32::NAN, 123.0, f32::NAN);\n    test::<f32>(f32::INFINITY, 123.0, f32::INFINITY);\n    test::<f32>(f32::NEGATIVE_INFINITY, 123.0, f32::NAN);\n    test::<f32>(0.0, 123.0, 0.0);\n    test::<f32>(-0.0, 123.0, 0.0);\n\n    test::<f32>(1.0, 2.0, 1.456791);\n    test::<f32>(24.0, 6.0, 13.458172);\n\n    test::<f64>(f64::NAN, f64::NAN, f64::NAN);\n    test::<f64>(f64::NAN, f64::INFINITY, f64::NAN);\n    test::<f64>(f64::NAN, f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(f64::NAN, 0.0, f64::NAN);\n    test::<f64>(f64::NAN, -0.0, f64::NAN);\n\n    test::<f64>(f64::INFINITY, f64::NAN, f64::NAN);\n    test::<f64>(f64::INFINITY, f64::INFINITY, f64::INFINITY);\n    test::<f64>(f64::INFINITY, f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(f64::INFINITY, 0.0, f64::NAN);\n    test::<f64>(f64::INFINITY, -0.0, f64::NAN);\n\n    test::<f64>(f64::NEGATIVE_INFINITY, f64::NAN, f64::NAN);\n    test::<f64>(f64::NEGATIVE_INFINITY, f64::INFINITY, f64::NAN);\n    test::<f64>(f64::NEGATIVE_INFINITY, f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(f64::NEGATIVE_INFINITY, 0.0, f64::NAN);\n    test::<f64>(f64::NEGATIVE_INFINITY, -0.0, f64::NAN);\n\n    test::<f64>(0.0, f64::NAN, f64::NAN);\n    test::<f64>(0.0, f64::INFINITY, f64::NAN);\n    test::<f64>(0.0, f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(0.0, 0.0, 0.0);\n    test::<f64>(0.0, -0.0, 0.0);\n\n    test::<f64>(-0.0, f64::NAN, f64::NAN);\n    test::<f64>(-0.0, f64::INFINITY, f64::NAN);\n    test::<f64>(-0.0, f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(-0.0, 0.0, 0.0);\n    test::<f64>(-0.0, -0.0, 0.0);\n\n    test::<f64>(123.0, f64::NAN, f64::NAN);\n    test::<f64>(123.0, f64::INFINITY, f64::INFINITY);\n    test::<f64>(123.0, f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(123.0, 0.0, 0.0);\n    test::<f64>(123.0, -0.0, 0.0);\n\n    test::<f64>(-123.0, f64::NAN, f64::NAN);\n    test::<f64>(-123.0, f64::INFINITY, f64::NAN);\n    test::<f64>(-123.0, f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(-123.0, 0.0, 0.0);\n    test::<f64>(-123.0, -0.0, 0.0);\n\n    test::<f64>(f64::NAN, 123.0, f64::NAN);\n    test::<f64>(f64::INFINITY, 123.0, f64::INFINITY);\n    test::<f64>(f64::NEGATIVE_INFINITY, 123.0, f64::NAN);\n    test::<f64>(0.0, 123.0, 0.0);\n    test::<f64>(-0.0, 123.0, 0.0);\n\n    test::<f64>(1.0, 2.0, 1.4567910310469068);\n    test::<f64>(24.0, 6.0, 13.458171481725616);\n}\n\n#[test]\nfn test_agm_rational_prec() {\n    let test = |s, t, prec, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let (agm, o) = Float::agm_rational_prec(u.clone(), v.clone(), prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_val_ref(u.clone(), &v, prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_ref_val(&u, v.clone(), prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_ref_ref(&u, &v, prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n    };\n    // - in agm_rational_prec_round\n    // - x == 0 || y == 0 in agm_rational_prec_round\n    test(\"0\", \"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 100, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", \"22/7\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 100, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-1\", \"22/7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 10, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 100, \"NaN\", \"NaN\", Equal);\n\n    test(\"22/7\", \"-1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 10, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 100, \"NaN\", \"NaN\", Equal);\n\n    test(\"22/7\", \"22/7\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"22/7\", \"22/7\", 10, \"3.145\", \"0x3.25#10\", Greater);\n    test(\n        \"22/7\",\n        \"22/7\",\n        100,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n\n    test(\"1\", \"2\", 1, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1\", \"2\", 10, \"1.457\", \"0x1.750#10\", Greater);\n    test(\n        \"1\",\n        \"2\",\n        100,\n        \"1.456791031046906869186432383265\",\n        \"0x1.74f041cb73dca72066c53853e#100\",\n        Less,\n    );\n\n    test(\"1\", \"4/3\", 1, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1\", \"4/3\", 10, \"1.16\", \"0x1.290#10\", Less);\n    test(\n        \"1\",\n        \"4/3\",\n        100,\n        \"1.160675892119856802207320983052\",\n        \"0x1.29220e25e91091bea1ecae6de#100\",\n        Less,\n    );\n\n    test(\"4/3\", \"2\", 1, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"4/3\", \"2\", 10, \"1.65\", \"0x1.a68#10\", Greater);\n    test(\n        \"4/3\",\n        \"2\",\n        100,\n        \"1.649786957490869641737773069062\",\n        \"0x1.a6587023ca668d7d15d42a6a8#100\",\n        Greater,\n    );\n\n    test(\"4/3\", \"22/7\", 1, \"2.0\", \"0x2.0#1\", Less);\n    test(\"4/3\", \"22/7\", 10, \"2.141\", \"0x2.24#10\", Less);\n    test(\n        \"4/3\",\n        \"22/7\",\n        100,\n        \"2.141515087948159535688532991751\",\n        \"0x2.243a5532a0bea4119018af58c#100\",\n        Greater,\n    );\n\n    // - x < 0 || y < 0 in agm_rational_prec_round\n    // - x >= 0 && y >= 0 in agm_rational_prec_round\n    // - x == y in agm_rational_prec_round\n    test(\"1\", \"1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    // - x != y in agm_rational_prec_round\n    // - no overflow or underflow in agm_rational_prec_round\n    // - in agm_rational_helper\n    // - x_o == Equal && y_o == Equal in agm_rational_helper\n    test(\"1\", \"1/2\", 1, \"0.5\", \"0x0.8#1\", Less);\n    // - x_o != Equal || y_o != Equal in agm_rational_helper\n    // - x_o == Equal in agm_rational_helper\n    // - y_o != Equal in agm_rational_helper\n    // - o_lo != Equal in agm_rational_helper\n    // - o_hi != Equal in agm_rational_helper\n    // - o_lo == o_hi && agm_lo == agm_hi in agm_rational_helper\n    test(\"1\", \"1/3\", 1, \"0.5\", \"0x0.8#1\", Less);\n    // - x_o != Equal in agm_rational_helper\n    // - y_o == Equal in agm_rational_helper\n    test(\"1/3\", \"1\", 1, \"0.5\", \"0x0.8#1\", Less);\n    // - o_lo != o_hi || agm_lo != agm_hi in agm_rational_helper\n    test(\n        \"558514310918953/444252178279\",\n        \"81626687/1727294\",\n        36,\n        \"422.994593993\",\n        \"0x1a6.fe9db64#36\",\n        Greater,\n    );\n    // - o_lo == Equal in agm_rational_helper\n    test(\"1/2\", \"5000001/10000000\", 1, \"0.5\", \"0x0.8#1\", Less);\n    // - o_hi == Equal in agm_rational_helper\n    test(\"1/2\", \"4999999/10000000\", 1, \"0.5\", \"0x0.8#1\", Greater);\n\n    let test_big = |u: Rational, v: Rational, prec, out, out_hex, out_o| {\n        let (agm, o) = Float::agm_rational_prec(u.clone(), v.clone(), prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_val_ref(u.clone(), &v, prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_ref_val(&u, v.clone(), prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_ref_ref(&u, &v, prec);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n    };\n    let max_exp = i64::from(Float::MAX_EXPONENT);\n    let min_exp = i64::from(Float::MIN_EXPONENT);\n    // - just overflow in agm_rational_prec_round\n    test_big(\n        Rational::power_of_2(max_exp),\n        Rational::power_of_2(max_exp + 1),\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - just underflow in agm_rational_prec_round\n    test_big(\n        Rational::power_of_2(min_exp - 4),\n        Rational::power_of_2(min_exp - 3),\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - just underflow (borderline) in agm_rational_prec_round\n    test_big(\n        Rational::power_of_2(min_exp - 3),\n        Rational::power_of_2(min_exp - 2),\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - partial overflow or underflow in agm_rational_prec_round\n    // - in agm_rational_helper_extended\n    // - x_o == Equal && y_o == Equal in agm_rational_helper_extended\n    test_big(\n        Rational::power_of_2(min_exp - 4),\n        Rational::power_of_2(max_exp + 1),\n        1,\n        \"too_big\",\n        \"0x4.0E+268435448#1\",\n        Less,\n    );\n    // - x_o != Equal || y_o != Equal in agm_rational_helper_extended\n    // - x_o == Equal in agm_rational_helper_extended\n    // - y_o != Equal in agm_rational_helper_extended\n    // - o_lo != Equal in agm_rational_helper_extended\n    // - o_hi != Equal in agm_rational_helper_extended\n    // - o_lo == o_hi && agm_lo == agm_hi in agm_rational_helper_extended\n    test_big(\n        Rational::ONE,\n        Rational::power_of_2(max_exp + 1) * Rational::from_unsigneds(4u8, 3),\n        1,\n        \"too_big\",\n        \"0x1.0E+268435449#1\",\n        Greater,\n    );\n    // - x_o != Equal in agm_rational_helper_extended\n    // - y_o == Equal in agm_rational_helper_extended\n    test_big(\n        Rational::power_of_2(max_exp + 1) * Rational::from_unsigneds(4u8, 3),\n        Rational::ONE,\n        1,\n        \"too_big\",\n        \"0x1.0E+268435449#1\",\n        Greater,\n    );\n    // - o_lo != o_hi || agm_lo != agm_hi in agm_rational_helper_extended\n    test_big(\n        Rational::from_unsigneds(558514310918953u64, 444252178279) << (max_exp - 6),\n        Rational::from_unsigneds(81626687u32, 1727294) << (max_exp - 6),\n        36,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - no overflow or underflow (borderline) in agm_rational_prec_round\n    // - o_lo == Equal in agm_rational_helper_extended\n    test_big(\n        Rational::ONE_HALF << max_exp,\n        Rational::from_unsigneds(5000001u32, 10000000) << max_exp,\n        1,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n}\n\n#[test]\nfn agm_ratonal_prec_fail() {\n    assert_panic!(Float::agm_rational_prec(Rational::ONE, Rational::ONE, 0));\n    assert_panic!(Float::agm_rational_prec_val_ref(\n        Rational::ONE,\n        &Rational::ONE,\n        0\n    ));\n    assert_panic!(Float::agm_rational_prec_ref_val(\n        &Rational::ONE,\n        Rational::ONE,\n        0\n    ));\n    assert_panic!(Float::agm_rational_prec_ref_ref(\n        &Rational::ONE,\n        &Rational::ONE,\n        0\n    ));\n}\n\n#[test]\nfn test_agm_rational_prec_round() {\n    let test = |s, t, prec, rm, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let (agm, o) = Float::agm_rational_prec_round(u.clone(), v.clone(), prec, rm);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_round_val_ref(u.clone(), &v, prec, rm);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_round_ref_val(&u, v.clone(), prec, rm);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n\n        let (agm, o) = Float::agm_rational_prec_round_ref_ref(&u, &v, prec, rm);\n        assert!(agm.is_valid());\n        assert_eq!(agm.to_string(), out);\n        assert_eq!(to_hex_string(&agm), out_hex);\n        assert_eq!(o, out_o);\n    };\n    test(\"0\", \"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", \"0\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", \"0\", 100, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 100, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 100, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 100, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 100, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"0\", 100, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", \"22/7\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", \"22/7\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", \"22/7\", 100, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 100, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 100, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 100, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 100, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"22/7\", 100, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-1\", \"22/7\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", \"22/7\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", \"22/7\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", \"22/7\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"22/7\", \"-1\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"22/7\", \"-1\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"22/7\", \"-1\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"22/7\", \"-1\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"22/7\", \"22/7\", 1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test(\"22/7\", \"22/7\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"22/7\", \"22/7\", 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test(\"22/7\", \"22/7\", 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"22/7\", \"22/7\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test(\"22/7\", \"22/7\", 10, Floor, \"3.141\", \"0x3.24#10\", Less);\n    test(\"22/7\", \"22/7\", 10, Ceiling, \"3.145\", \"0x3.25#10\", Greater);\n    test(\"22/7\", \"22/7\", 10, Down, \"3.141\", \"0x3.24#10\", Less);\n    test(\"22/7\", \"22/7\", 10, Up, \"3.145\", \"0x3.25#10\", Greater);\n    test(\"22/7\", \"22/7\", 10, Nearest, \"3.145\", \"0x3.25#10\", Greater);\n\n    test(\n        \"22/7\",\n        \"22/7\",\n        100,\n        Floor,\n        \"3.142857142857142857142857142855\",\n        \"0x3.2492492492492492492492490#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        \"22/7\",\n        100,\n        Ceiling,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        \"22/7\",\n        100,\n        Down,\n        \"3.142857142857142857142857142855\",\n        \"0x3.2492492492492492492492490#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        \"22/7\",\n        100,\n        Up,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        \"22/7\",\n        100,\n        Nearest,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n\n    test(\"1\", \"2\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1\", \"2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1\", \"2\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1\", \"2\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1\", \"2\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test(\"1\", \"2\", 10, Floor, \"1.455\", \"0x1.748#10\", Less);\n    test(\"1\", \"2\", 10, Ceiling, \"1.457\", \"0x1.750#10\", Greater);\n    test(\"1\", \"2\", 10, Down, \"1.455\", \"0x1.748#10\", Less);\n    test(\"1\", \"2\", 10, Up, \"1.457\", \"0x1.750#10\", Greater);\n    test(\"1\", \"2\", 10, Nearest, \"1.457\", \"0x1.750#10\", Greater);\n\n    test(\n        \"1\",\n        \"2\",\n        100,\n        Floor,\n        \"1.456791031046906869186432383265\",\n        \"0x1.74f041cb73dca72066c53853e#100\",\n        Less,\n    );\n    test(\n        \"1\",\n        \"2\",\n        100,\n        Ceiling,\n        \"1.456791031046906869186432383266\",\n        \"0x1.74f041cb73dca72066c538540#100\",\n        Greater,\n    );\n    test(\n        \"1\",\n        \"2\",\n        100,\n        Down,\n        \"1.456791031046906869186432383265\",\n        \"0x1.74f041cb73dca72066c53853e#100\",\n        Less,\n    );\n    test(\n        \"1\",\n        \"2\",\n        100,\n        Up,\n        \"1.456791031046906869186432383266\",\n        \"0x1.74f041cb73dca72066c538540#100\",\n        Greater,\n    );\n    test(\n        \"1\",\n        \"2\",\n        100,\n        Nearest,\n        \"1.456791031046906869186432383265\",\n        \"0x1.74f041cb73dca72066c53853e#100\",\n        Less,\n    );\n\n    test(\"1\", \"4/3\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1\", \"4/3\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1\", \"4/3\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1\", \"4/3\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1\", \"4/3\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test(\"1\", \"4/3\", 10, Floor, \"1.16\", \"0x1.290#10\", Less);\n    test(\"1\", \"4/3\", 10, Ceiling, \"1.162\", \"0x1.298#10\", Greater);\n    test(\"1\", \"4/3\", 10, Down, \"1.16\", \"0x1.290#10\", Less);\n    test(\"1\", \"4/3\", 10, Up, \"1.162\", \"0x1.298#10\", Greater);\n    test(\"1\", \"4/3\", 10, Nearest, \"1.16\", \"0x1.290#10\", Less);\n\n    test(\n        \"1\",\n        \"4/3\",\n        100,\n        Floor,\n        \"1.160675892119856802207320983052\",\n        \"0x1.29220e25e91091bea1ecae6de#100\",\n        Less,\n    );\n    test(\n        \"1\",\n        \"4/3\",\n        100,\n        Ceiling,\n        \"1.160675892119856802207320983053\",\n        \"0x1.29220e25e91091bea1ecae6e0#100\",\n        Greater,\n    );\n    test(\n        \"1\",\n        \"4/3\",\n        100,\n        Down,\n        \"1.160675892119856802207320983052\",\n        \"0x1.29220e25e91091bea1ecae6de#100\",\n        Less,\n    );\n    test(\n        \"1\",\n        \"4/3\",\n        100,\n        Up,\n        \"1.160675892119856802207320983053\",\n        \"0x1.29220e25e91091bea1ecae6e0#100\",\n        Greater,\n    );\n    test(\n        \"1\",\n        \"4/3\",\n        100,\n        Nearest,\n        \"1.160675892119856802207320983052\",\n        \"0x1.29220e25e91091bea1ecae6de#100\",\n        Less,\n    );\n\n    test(\"4/3\", \"2\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"4/3\", \"2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"4/3\", \"2\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"4/3\", \"2\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"4/3\", \"2\", 1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test(\"4/3\", \"2\", 10, Floor, \"1.648\", \"0x1.a60#10\", Less);\n    test(\"4/3\", \"2\", 10, Ceiling, \"1.65\", \"0x1.a68#10\", Greater);\n    test(\"4/3\", \"2\", 10, Down, \"1.648\", \"0x1.a60#10\", Less);\n    test(\"4/3\", \"2\", 10, Up, \"1.65\", \"0x1.a68#10\", Greater);\n    test(\"4/3\", \"2\", 10, Nearest, \"1.65\", \"0x1.a68#10\", Greater);\n\n    test(\n        \"4/3\",\n        \"2\",\n        100,\n        Floor,\n        \"1.64978695749086964173777306906\",\n        \"0x1.a6587023ca668d7d15d42a6a6#100\",\n        Less,\n    );\n    test(\n        \"4/3\",\n        \"2\",\n        100,\n        Ceiling,\n        \"1.649786957490869641737773069062\",\n        \"0x1.a6587023ca668d7d15d42a6a8#100\",\n        Greater,\n    );\n    test(\n        \"4/3\",\n        \"2\",\n        100,\n        Down,\n        \"1.64978695749086964173777306906\",\n        \"0x1.a6587023ca668d7d15d42a6a6#100\",\n        Less,\n    );\n    test(\n        \"4/3\",\n        \"2\",\n        100,\n        Up,\n        \"1.649786957490869641737773069062\",\n        \"0x1.a6587023ca668d7d15d42a6a8#100\",\n        Greater,\n    );\n    test(\n        \"4/3\",\n        \"2\",\n        100,\n        Nearest,\n        \"1.649786957490869641737773069062\",\n        \"0x1.a6587023ca668d7d15d42a6a8#100\",\n        Greater,\n    );\n\n    test(\"4/3\", \"22/7\", 1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test(\"4/3\", \"22/7\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"4/3\", \"22/7\", 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test(\"4/3\", \"22/7\", 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"4/3\", \"22/7\", 1, Nearest, \"2.0\", \"0x2.0#1\", Less);\n\n    test(\"4/3\", \"22/7\", 10, Floor, \"2.141\", \"0x2.24#10\", Less);\n    test(\"4/3\", \"22/7\", 10, Ceiling, \"2.145\", \"0x2.25#10\", Greater);\n    test(\"4/3\", \"22/7\", 10, Down, \"2.141\", \"0x2.24#10\", Less);\n    test(\"4/3\", \"22/7\", 10, Up, \"2.145\", \"0x2.25#10\", Greater);\n    test(\"4/3\", \"22/7\", 10, Nearest, \"2.141\", \"0x2.24#10\", Less);\n\n    test(\n        \"4/3\",\n        \"22/7\",\n        100,\n        Floor,\n        \"2.141515087948159535688532991747\",\n        \"0x2.243a5532a0bea4119018af588#100\",\n        Less,\n    );\n    test(\n        \"4/3\",\n        \"22/7\",\n        100,\n        Ceiling,\n        \"2.141515087948159535688532991751\",\n        \"0x2.243a5532a0bea4119018af58c#100\",\n        Greater,\n    );\n    test(\n        \"4/3\",\n        \"22/7\",\n        100,\n        Down,\n        \"2.141515087948159535688532991747\",\n        \"0x2.243a5532a0bea4119018af588#100\",\n        Less,\n    );\n    test(\n        \"4/3\",\n        \"22/7\",\n        100,\n        Up,\n        \"2.141515087948159535688532991751\",\n        \"0x2.243a5532a0bea4119018af58c#100\",\n        Greater,\n    );\n    test(\n        \"4/3\",\n        \"22/7\",\n        100,\n        Nearest,\n        \"2.141515087948159535688532991751\",\n        \"0x2.243a5532a0bea4119018af58c#100\",\n        Greater,\n    );\n}\n\n#[test]\nfn agm_ratonal_prec_round_fail() {\n    assert_panic!(Float::agm_rational_prec_round(\n        Rational::ONE,\n        Rational::ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::agm_rational_prec_round_val_ref(\n        Rational::ONE,\n        &Rational::ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::agm_rational_prec_round_ref_val(\n        &Rational::ONE,\n        Rational::ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::agm_rational_prec_round_ref_ref(\n        &Rational::ONE,\n        &Rational::ONE,\n        0,\n        Floor\n    ));\n}\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_primitive_float_agm_rational() {\n    fn test<T: PrimitiveFloat>(s: &str, t: &str, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n    {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        assert_eq!(\n            NiceFloat(primitive_float_agm_rational(&u, &v)),\n            NiceFloat(out)\n        );\n    }\n    test::<f32>(\"0\", \"0\", 0.0);\n    test::<f32>(\"123\", \"0\", 0.0);\n    test::<f32>(\"-123\", \"0\", 0.0);\n    test::<f32>(\"0\", \"123\", 0.0);\n    test::<f32>(\"0\", \"-123\", 0.0);\n\n    test::<f32>(\"-1\", \"-2\", f32::NAN);\n    test::<f32>(\"1\", \"2\", 1.456791);\n    test::<f32>(\"24\", \"6\", 13.458172);\n    test::<f32>(\"-1\", \"22/7\", f32::NAN);\n    test::<f32>(\"22/7\", \"-1\", f32::NAN);\n    test::<f32>(\"22/7\", \"22/7\", 3.142857);\n    test::<f32>(\"1\", \"2\", 1.456791);\n    test::<f32>(\"1\", \"4/3\", 1.1606759);\n    test::<f32>(\"4/3\", \"2\", 1.649787);\n    test::<f32>(\"4/3\", \"22/7\", 2.141515);\n\n    test::<f64>(\"0\", \"0\", 0.0);\n    test::<f64>(\"123\", \"0\", 0.0);\n    test::<f64>(\"-123\", \"0\", 0.0);\n    test::<f64>(\"0\", \"123\", 0.0);\n    test::<f64>(\"0\", \"-123\", 0.0);\n\n    test::<f64>(\"-1\", \"-2\", f64::NAN);\n    test::<f64>(\"1\", \"2\", 1.4567910310469068);\n    test::<f64>(\"24\", \"6\", 13.458171481725616);\n    test::<f64>(\"-1\", \"22/7\", f64::NAN);\n    test::<f64>(\"22/7\", \"-1\", f64::NAN);\n    test::<f64>(\"22/7\", \"22/7\", 3.142857142857143);\n    test::<f64>(\"1\", \"2\", 1.4567910310469068);\n    test::<f64>(\"1\", \"4/3\", 1.1606758921198568);\n    test::<f64>(\"4/3\", \"2\", 1.6497869574908697);\n    test::<f64>(\"4/3\", \"22/7\", 2.1415150879481595);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn agm_prec_round_properties_helper(\n    x: Float,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (agm, o) = x.clone().agm_prec_round(y.clone(), prec, rm);\n    assert!(agm.is_valid());\n    let (agm_alt, o_alt) = x.clone().agm_prec_round_val_ref(&y, prec, rm);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n    let (agm_alt, o_alt) = x.agm_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n    let (agm_alt, o_alt) = x.agm_prec_round_ref_ref(&y, prec, rm);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.agm_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.agm_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_agm, rug_o) = rug_agm_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_agm)),\n            ComparableFloatRef(&agm)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if !extreme {\n        let (agm_alt, o_alt) = agm_prec_round_extended(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n    }\n\n    if x < 0u32 && y != 0u32 || y < 0u32 && x != 0u32 {\n        assert!(agm.is_nan());\n    }\n\n    if agm.is_normal() && agm > 0u32 {\n        let (min, max) = if x <= y { (&x, &y) } else { (&y, &x) };\n        if o != Greater {\n            assert!(agm <= *max);\n        }\n        if o != Less {\n            assert!(agm >= *min);\n        }\n        if !extreme {\n            assert_eq!(agm.get_prec(), Some(prec));\n            let rx = Rational::exact_from(&x);\n            let ry = Rational::exact_from(&y);\n            if o != Greater {\n                let arith = (&rx + &ry) >> 1u32;\n                assert!(agm <= arith);\n            }\n            if o != Less {\n                let geom_squared = rx * ry;\n                assert!(Rational::exact_from(&agm).square() >= geom_squared);\n            }\n        }\n    } else {\n        assert_eq!(o, Equal);\n    }\n\n    let (agm_alt, o_alt) = y.agm_prec_round_ref_ref(&x, prec, rm);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.agm_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(agm.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.agm_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn agm_prec_round_properties() {\n    float_float_unsigned_rounding_mode_quadruple_gen_var_9().test_properties(|(x, y, prec, rm)| {\n        agm_prec_round_properties_helper(x, y, prec, rm, false);\n    });\n\n    float_float_unsigned_rounding_mode_quadruple_gen_var_10().test_properties(\n        |(x, y, prec, rm)| {\n            agm_prec_round_properties_helper(x, y, prec, rm, true);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        if !x.is_sign_negative() {\n            let (agm, o) = x.agm_prec_round_ref_ref(&x, prec, rm);\n            let (agm_alt, o_alt) = Float::from_float_prec_round_ref(&x, prec, rm);\n            assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n            assert_eq!(o_alt, o);\n        }\n\n        let (agm, o) = x.agm_prec_round_ref_val(Float::NAN, prec, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NAN.agm_prec_round_val_ref(&x, prec, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = x.agm_prec_round_ref_val(Float::NEGATIVE_INFINITY, prec, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NEGATIVE_INFINITY.agm_prec_round_val_ref(&x, prec, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_17().test_properties(|(x, prec, rm)| {\n        let (agm, o) = x.agm_prec_round_ref_val(Float::INFINITY, prec, rm);\n        assert_eq!(agm, Float::INFINITY);\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::INFINITY.agm_prec_round_val_ref(&x, prec, rm);\n        assert_eq!(agm, Float::INFINITY);\n        assert_eq!(o, Equal);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_18().test_properties(|(x, prec, rm)| {\n        let (agm, o) = x.agm_prec_round_ref_val(Float::ZERO, prec, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::ZERO.agm_prec_round_val_ref(&x, prec, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = x.agm_prec_round_ref_val(Float::NEGATIVE_ZERO, prec, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NEGATIVE_ZERO.agm_prec_round_val_ref(&x, prec, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn agm_prec_properties_helper(x: Float, y: Float, prec: u64, extreme: bool) {\n    let (agm, o) = x.clone().agm_prec(y.clone(), prec);\n    assert!(agm.is_valid());\n    let (agm_alt, o_alt) = x.clone().agm_prec_val_ref(&y, prec);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n    let (agm_alt, o_alt) = x.agm_prec_ref_val(y.clone(), prec);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n    let (agm_alt, o_alt) = x.agm_prec_ref_ref(&y, prec);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.agm_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.agm_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    let (rug_agm, rug_o) = rug_agm_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Float::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_agm)),\n        ComparableFloatRef(&agm)\n    );\n    assert_eq!(rug_o, o);\n\n    if !extreme {\n        let (agm_alt, o_alt) = agm_prec_round_extended(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n    }\n\n    if x < 0u32 && y != 0u32 || y < 0u32 && x != 0u32 {\n        assert!(agm.is_nan());\n    }\n\n    if agm.is_normal() && agm > 0u32 {\n        let (min, max) = if x <= y { (&x, &y) } else { (&y, &x) };\n        if o != Greater {\n            assert!(agm <= *max);\n        }\n        if o != Less {\n            assert!(agm >= *min);\n        }\n        assert_eq!(agm.get_prec(), Some(prec));\n        if !extreme {\n            let rx = Rational::exact_from(&x);\n            let ry = Rational::exact_from(&y);\n            if o != Greater {\n                let arith = (&rx + &ry) >> 1u32;\n                assert!(agm <= arith);\n            }\n            if o != Less {\n                let geom_squared = rx * ry;\n                assert!(Rational::exact_from(&agm).square() >= geom_squared);\n            }\n        }\n    } else {\n        assert_eq!(o, Equal);\n    }\n\n    let (agm_alt, o_alt) = x.agm_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    let (agm_alt, o_alt) = y.agm_prec_ref_ref(&x, prec);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\nfn agm_prec_properties() {\n    float_float_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        agm_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_float_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        agm_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        if !x.is_sign_negative() {\n            let (agm, o) = x.agm_prec_ref_ref(&x, prec);\n            let (agm_alt, o_alt) = Float::from_float_prec_ref(&x, prec);\n            assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n            assert_eq!(o_alt, o);\n        }\n\n        let (agm, o) = x.agm_prec_ref_val(Float::NAN, prec);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NAN.agm_prec_val_ref(&x, prec);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = x.agm_prec_ref_val(Float::NEGATIVE_INFINITY, prec);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NEGATIVE_INFINITY.agm_prec_val_ref(&x, prec);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n    });\n\n    float_unsigned_pair_gen_var_6().test_properties(|(x, prec)| {\n        let (agm, o) = x.agm_prec_ref_val(Float::INFINITY, prec);\n        assert_eq!(agm, Float::INFINITY);\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::INFINITY.agm_prec_val_ref(&x, prec);\n        assert_eq!(agm, Float::INFINITY);\n        assert_eq!(o, Equal);\n    });\n\n    float_unsigned_pair_gen_var_7().test_properties(|(x, prec)| {\n        let (agm, o) = x.agm_prec_ref_val(Float::ZERO, prec);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::ZERO.agm_prec_val_ref(&x, prec);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = x.agm_prec_ref_val(Float::NEGATIVE_ZERO, prec);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NEGATIVE_ZERO.agm_prec_val_ref(&x, prec);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn agm_round_properties_helper(x: Float, y: Float, rm: RoundingMode, extreme: bool) {\n    let (agm, o) = x.clone().agm_round(y.clone(), rm);\n    assert!(agm.is_valid());\n    let (agm_alt, o_alt) = x.clone().agm_round_val_ref(&y, rm);\n    assert!(agm_alt.is_valid());\n    assert_eq!(o_alt, o);\n    let (agm_alt, o_alt) = x.agm_round_ref_val(y.clone(), rm);\n    assert!(agm_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    let (agm_alt, o_alt) = x.agm_round_ref_ref(&y, rm);\n    assert!(agm_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.agm_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.agm_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    if agm.is_normal() && agm > 0u32 {\n        let (min_xy, max_xy) = if x <= y { (&x, &y) } else { (&y, &x) };\n        if o != Greater {\n            assert!(agm <= *max_xy);\n        }\n        if o != Less {\n            assert!(agm >= *min_xy);\n        }\n        if !extreme {\n            assert_eq!(\n                agm.get_prec(),\n                Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n            );\n            let rx = Rational::exact_from(&x);\n            let ry = Rational::exact_from(&y);\n            if o != Greater {\n                let arith = (&rx + &ry) >> 1u32;\n                assert!(agm <= arith);\n            }\n            if o != Less {\n                let geom_squared = rx * ry;\n                assert!(Rational::exact_from(&agm).square() >= geom_squared);\n            }\n        }\n    } else {\n        assert_eq!(o, Equal);\n    }\n    let (agm_alt, o_alt) =\n        x.agm_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), rm);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_agm, rug_o) =\n            rug_agm_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_agm)),\n            ComparableFloatRef(&agm)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if !extreme {\n        let prec = max(x.significant_bits(), y.significant_bits());\n        let (agm_alt, o_alt) = agm_prec_round_extended(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n    }\n\n    if x < 0u32 && y != 0u32 || y < 0u32 && x != 0u32 {\n        assert!(agm.is_nan());\n    }\n\n    let (agm_alt, o_alt) = y.agm_round_ref_ref(&x, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.agm_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(agm.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.agm_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn agm_round_properties() {\n    float_float_rounding_mode_triple_gen_var_33().test_properties(|(x, y, rm)| {\n        agm_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_34().test_properties(|(x, y, rm)| {\n        agm_round_properties_helper(x, y, rm, true);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        if !x.is_sign_negative() {\n            let (agm, o) = x.agm_round_ref_ref(&x, rm);\n            assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n        }\n\n        let (agm, o) = x.agm_round_ref_val(Float::NAN, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NAN.agm_round_val_ref(&x, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = x.agm_round_ref_val(Float::NEGATIVE_INFINITY, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NEGATIVE_INFINITY.agm_round_val_ref(&x, rm);\n        assert!(agm.is_nan());\n        assert_eq!(o, Equal);\n    });\n\n    float_rounding_mode_pair_gen_var_32().test_properties(|(x, rm)| {\n        let (agm, o) = x.agm_round_ref_val(Float::INFINITY, rm);\n        assert_eq!(agm, Float::INFINITY);\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::INFINITY.agm_round_val_ref(&x, rm);\n        assert_eq!(agm, Float::INFINITY);\n        assert_eq!(o, Equal);\n    });\n\n    float_rounding_mode_pair_gen_var_33().test_properties(|(x, rm)| {\n        let (agm, o) = x.agm_round_ref_val(Float::ZERO, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::ZERO.agm_round_val_ref(&x, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = x.agm_round_ref_val(Float::NEGATIVE_ZERO, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::NEGATIVE_ZERO.agm_round_val_ref(&x, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn agm_properties_helper(x: Float, y: Float, extreme: bool) {\n    let agm = x.clone().agm(y.clone());\n    assert!(agm.is_valid());\n    let agm_alt = x.clone().agm(&y);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    let agm_alt = (&x).agm(y.clone());\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    let agm_alt = (&x).agm(&y);\n    assert!(agm_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n\n    let mut x_alt = x.clone();\n    x_alt.agm_assign(y.clone());\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n\n    let mut x_alt = x.clone();\n    x_alt.agm_assign(&y);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&agm));\n\n    let agm_alt = x\n        .agm_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), Nearest)\n        .0;\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    let agm_alt = x\n        .agm_prec_ref_ref(&y, max(x.significant_bits(), y.significant_bits()))\n        .0;\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    let agm_alt = x.agm_round_ref_ref(&y, Nearest).0;\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n\n    let rug_agm = rug_agm(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_agm)),\n        ComparableFloatRef(&agm),\n    );\n\n    if !extreme {\n        let prec = max(x.significant_bits(), y.significant_bits());\n        let agm_alt = agm_prec_round_extended(x.clone(), y.clone(), prec, Nearest).0;\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n    }\n\n    if x < 0u32 && y != 0u32 || y < 0u32 && x != 0u32 {\n        assert!(agm.is_nan());\n    }\n\n    let agm_alt = y.agm(x);\n    assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n}\n\n#[test]\nfn agm_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        agm_properties_helper(x, y, false);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        agm_properties_helper(x, y, true);\n    });\n\n    float_gen().test_properties(|x| {\n        if !x.is_sign_negative() {\n            assert_eq!(ComparableFloatRef(&(&x).agm(&x)), ComparableFloatRef(&x));\n        }\n\n        let agm = (&x).agm(Float::NAN);\n        assert!(agm.is_nan());\n\n        let agm = Float::NAN.agm(&x);\n        assert!(agm.is_nan());\n\n        let agm = (&x).agm(Float::NEGATIVE_INFINITY);\n        assert!(agm.is_nan());\n\n        let agm = Float::NEGATIVE_INFINITY.agm(&x);\n        assert!(agm.is_nan());\n    });\n\n    float_gen_var_15().test_properties(|x| {\n        let agm = (&x).agm(Float::INFINITY);\n        assert_eq!(agm, Float::INFINITY);\n\n        let agm = Float::INFINITY.agm(&x);\n        assert_eq!(agm, Float::INFINITY);\n    });\n\n    float_gen_var_4().test_properties(|x| {\n        let agm = (&x).agm(Float::ZERO);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n\n        let agm = Float::ZERO.agm(&x);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n\n        let agm = (&x).agm(Float::NEGATIVE_ZERO);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n\n        let agm = Float::NEGATIVE_ZERO.agm(&x);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn primitive_float_agm_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        primitive_float_agm(x, y);\n    });\n}\n\n#[test]\nfn primitive_float_agm_properties() {\n    apply_fn_to_primitive_floats!(primitive_float_agm_properties_helper);\n}\n\n#[test]\nfn agm_rational_prec_round_properties() {\n    rational_rational_unsigned_rounding_mode_quadruple_gen_var_1().test_properties(\n        |(x, y, prec, rm)| {\n            let (agm, o) = Float::agm_rational_prec_round(x.clone(), y.clone(), prec, rm);\n            assert!(agm.is_valid());\n            let (agm_alt, o_alt) = Float::agm_rational_prec_round_val_ref(x.clone(), &y, prec, rm);\n            assert!(agm_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n            assert_eq!(o_alt, o);\n            let (agm_alt, o_alt) = Float::agm_rational_prec_round_ref_val(&x, y.clone(), prec, rm);\n            assert!(agm_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n            assert_eq!(o_alt, o);\n            let (agm_alt, o_alt) = Float::agm_rational_prec_round_ref_ref(&x, &y, prec, rm);\n            assert!(agm_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n            assert_eq!(o_alt, o);\n\n            if x < 0u32 && y != 0u32 || y < 0u32 && x != 0u32 {\n                assert!(agm.is_nan());\n            }\n\n            if agm.is_normal() && agm > 0u32 {\n                let (min, max) = if x <= y { (&x, &y) } else { (&y, &x) };\n                if o != Greater {\n                    assert!(agm <= *max);\n                }\n                if o != Less {\n                    assert!(agm >= *min);\n                }\n                assert_eq!(agm.get_prec(), Some(prec));\n                if o != Greater {\n                    let arith = (&x + &y) >> 1u32;\n                    assert!(agm <= arith);\n                }\n                if o != Less {\n                    let geom_squared = &x * &y;\n                    assert!(Rational::exact_from(&agm).square() >= geom_squared);\n                }\n            } else {\n                assert_eq!(o, Equal);\n            }\n\n            let (agm_alt, o_alt) = Float::agm_rational_prec_round_ref_ref(&y, &x, prec, rm);\n            assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n            assert_eq!(o_alt, o);\n\n            if o == Equal {\n                for rm in exhaustive_rounding_modes() {\n                    let (s, oo) = Float::agm_rational_prec_round_ref_ref(&x, &y, prec, rm);\n                    assert_eq!(\n                        ComparableFloat(s.abs_negative_zero_ref()),\n                        ComparableFloat(agm.abs_negative_zero_ref())\n                    );\n                    assert_eq!(oo, Equal);\n                }\n            } else {\n                assert_panic!(Float::agm_rational_prec_round_ref_ref(&x, &y, prec, Exact));\n            }\n        },\n    );\n\n    rational_unsigned_rounding_mode_triple_gen_var_5().test_properties(|(x, prec, rm)| {\n        let (agm, o) = Float::agm_rational_prec_round_ref_ref(&x, &x, prec, rm);\n        let (agm_alt, o_alt) = Float::from_rational_prec_round_ref(&x, prec, rm);\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n\n        let (agm, o) = Float::agm_rational_prec_round_ref_val(&x, Rational::ZERO, prec, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::agm_rational_prec_round_val_ref(Rational::ZERO, &x, prec, rm);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[test]\nfn agm_rational_prec_properties() {\n    rational_rational_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        let (agm, o) = Float::agm_rational_prec(x.clone(), y.clone(), prec);\n        assert!(agm.is_valid());\n        let (agm_alt, o_alt) = Float::agm_rational_prec_val_ref(x.clone(), &y, prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n        let (agm_alt, o_alt) = Float::agm_rational_prec_ref_val(&x, y.clone(), prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n        let (agm_alt, o_alt) = Float::agm_rational_prec_ref_ref(&x, &y, prec);\n        assert!(agm_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n\n        if x < 0u32 && y != 0u32 || y < 0u32 && x != 0u32 {\n            assert!(agm.is_nan());\n        }\n\n        if agm.is_normal() && agm > 0u32 {\n            let (min, max) = if x <= y { (&x, &y) } else { (&y, &x) };\n            if o != Greater {\n                assert!(agm <= *max);\n            }\n            if o != Less {\n                assert!(agm >= *min);\n            }\n            assert_eq!(agm.get_prec(), Some(prec));\n            if o != Greater {\n                let arith = (&x + &y) >> 1u32;\n                assert!(agm <= arith);\n            }\n            if o != Less {\n                let geom_squared = &x * &y;\n                assert!(Rational::exact_from(&agm).square() >= geom_squared);\n            }\n        } else {\n            assert_eq!(o, Equal);\n        }\n\n        let (agm_alt, o_alt) = Float::agm_rational_prec_ref_ref(&y, &x, prec);\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n    });\n\n    rational_unsigned_pair_gen_var_8().test_properties(|(x, prec)| {\n        let (agm, o) = Float::agm_rational_prec_ref_ref(&x, &x, prec);\n        let (agm_alt, o_alt) = Float::from_rational_prec_ref(&x, prec);\n        assert_eq!(ComparableFloatRef(&agm_alt), ComparableFloatRef(&agm));\n        assert_eq!(o_alt, o);\n\n        let (agm, o) = Float::agm_rational_prec_ref_val(&x, Rational::ZERO, prec);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (agm, o) = Float::agm_rational_prec_val_ref(Rational::ZERO, &x, prec);\n        assert_eq!(ComparableFloatRef(&agm), ComparableFloatRef(&Float::ZERO));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn primitive_float_agm_rational_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    rational_pair_gen().test_properties(|(x, y)| {\n        primitive_float_agm_rational::<T>(&x, &y);\n    });\n}\n\n#[test]\nfn primitive_float_agm_rational_properties() {\n    apply_fn_to_primitive_floats!(primitive_float_agm_rational_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::arithmetic::div::{\n    div_rational_prec_round_direct, div_rational_prec_round_direct_ref_ref,\n    div_rational_prec_round_direct_ref_val, div_rational_prec_round_direct_val_ref,\n    div_rational_prec_round_naive, div_rational_prec_round_naive_ref_ref,\n    div_rational_prec_round_naive_ref_val, div_rational_prec_round_naive_val_ref,\n    rational_div_float_prec_round_direct, rational_div_float_prec_round_direct_ref_ref,\n    rational_div_float_prec_round_direct_ref_val, rational_div_float_prec_round_direct_val_ref,\n    rational_div_float_prec_round_naive, rational_div_float_prec_round_naive_ref_ref,\n    rational_div_float_prec_round_naive_ref_val, rational_div_float_prec_round_naive_val_ref,\n};\nuse malachite_float::emulate_float_float_to_float_fn;\nuse malachite_float::test_util::arithmetic::div::{\n    div_prec_round_naive, rug_div, rug_div_prec, rug_div_prec_round, rug_div_rational,\n    rug_div_rational_prec, rug_div_rational_prec_round, rug_div_rational_round, rug_div_round,\n    rug_rational_div_float_prec, rug_rational_div_float_prec_round, rug_rational_div_float_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_23, float_float_rounding_mode_triple_gen_var_24,\n    float_float_rounding_mode_triple_gen_var_25, float_float_rounding_mode_triple_gen_var_26,\n    float_float_rounding_mode_triple_gen_var_27, float_float_rounding_mode_triple_gen_var_28,\n    float_float_rounding_mode_triple_gen_var_32,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_8, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_2, float_gen, float_pair_gen, float_pair_gen_var_2,\n    float_pair_gen_var_3, float_pair_gen_var_4, float_pair_gen_var_8, float_pair_gen_var_9,\n    float_pair_gen_var_10, float_rational_pair_gen, float_rational_pair_gen_var_2,\n    float_rational_rounding_mode_triple_gen_var_5, float_rational_rounding_mode_triple_gen_var_6,\n    float_rational_rounding_mode_triple_gen_var_10, float_rational_rounding_mode_triple_gen_var_11,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_5,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_9,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_10,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_2,\n    float_rounding_mode_pair_gen, float_unsigned_pair_gen_var_1,\n    float_unsigned_rounding_mode_triple_gen_var_1, rational_rounding_mode_pair_gen_var_6,\n    rational_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_div() {\n    let test = |s, s_hex, t, t_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let quotient = x.clone() / y.clone();\n        assert!(quotient.is_valid());\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let quotient_alt = x.clone() / &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let quotient_alt = &x / y.clone();\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let quotient_alt = &x / &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n\n        let mut quotient_alt = x.clone();\n        quotient_alt /= y.clone();\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let mut quotient_alt = x.clone();\n        quotient_alt /= &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_div(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y)\n            ))),\n            ComparableFloatRef(&quotient),\n        );\n\n        let quotient_alt = div_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", \"NaN\", \"NaN\");\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-Infinity\", \"-Infinity\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", \"-0.0\", \"-0x0.0\");\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-Infinity\", \"-Infinity\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", \"0.0\", \"0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\");\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\");\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\");\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n    );\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\");\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0082\",\n        \"0x0.0218#7\",\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0082\",\n        \"-0x0.0218#7\",\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", \"0.5\", \"0x0.8#1\");\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", \"0.5\", \"0x0.8#2\");\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", \"0.5\", \"0x0.8#2\");\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", \"0.5\", \"0x0.8#2\");\n    test(\"1.0\", \"0x1.000#10\", \"2.0\", \"0x2.00#10\", \"0.5\", \"0x0.800#10\");\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n    );\n\n    // - in div_float_significands_same_prec_lt_w\n    // - increment_exp in div_float_significands_same_prec_lt_w\n    // - (q0 + 2) & (mask >> 1) <= 2 in div_float_significands_same_prec_lt_w\n    // - h == 0 && l < y in div_float_significands_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    // - !increment_exp in div_float_significands_same_prec_lt_w\n    // - (q0 + 2) & (mask >> 1) > 2 in div_float_significands_same_prec_lt_w\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_same_prec_lt_w\n    // - rm == Nearest in div_float_significands_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (quotient & shift_bit) != 0) in\n    //   div_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\", \"0.8\", \"0x0.c#2\");\n    // - h != 0 || l >= y in div_float_significands_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", \"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\");\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (quotient & shift_bit) == 0)) in\n    //   div_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#3\", \"1.2\", \"0x1.4#3\", \"0.8\", \"0x0.c#3\");\n\n    // - in div_float_significands_same_prec_w\n    // - increment_exp in div_float_significands_same_prec_w\n    // - hi == 0 && lo < y in div_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n    );\n    // - !increment_exp in div_float_significands_same_prec_w\n    // - round_bit == 0 in div_float_significands_same_prec_w\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_same_prec_w\n    // - rm == Nearest in div_float_significands_same_prec_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (quotient & 1) == 0)) in\n    //   div_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe#64\",\n    );\n    // - hi != 0 || lo >= y in div_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n    );\n    // - rm == Nearest || round_bit != 0 && (sticky_bit != 0 || (quotient & 1) != 0) in\n    //   div_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n    );\n    // - round_bit != 0 in div_float_significands_same_prec_w\n    test(\n        \"3.1790543009742223972e-11\",\n        \"0x2.2f43e0add6ebd01cE-9#64\",\n        \"7770090901.6225594673\",\n        \"0x1cf222d95.9f600ea8#64\",\n        \"4.0913991113158902183e-21\",\n        \"0x1.35232b1b3b9aeabeE-17#64\",\n    );\n\n    // - in div_float_significands_same_prec_gt_w_lt_2w\n    // - increment_exp in div_float_significands_same_prec_gt_w_lt_2w\n    // - in div_float_2_approx\n    // - y_1 != Limb::MAX in div_float_2_approx\n    // - r_1 == 0 in div_float_2_approx\n    // - (q_0.wrapping_add(21)) & (mask >> 1) <= 21 in div_float_significands_same_prec_gt_w_lt_2w\n    // - s_2 == 0 && s_1 <= y_1 && (s_1 != y_1 || s_0 < y_0) in\n    //   div_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n    );\n    // - !increment_exp in div_float_significands_same_prec_gt_w_lt_2w\n    // - s_2 > 0 || s_1 > y_1 || (s_1 == y_1 && s_0 >= y_0) in\n    //   div_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in div_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (z_0 & shift_bit) == 0)) in\n    //   div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n    );\n    // - r_1 != 0 in div_float_2_approx\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe0#65\",\n    );\n    // - (q_0.wrapping_add(21)) & (mask >> 1) > 21 in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        \"0.99999999999999999984\",\n        \"0x0.fffffffffffffffd0#65\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && !overflow\n    //   in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n    );\n    // - y_1 == Limb::MAX in div_float_2_approx\n    test(\n        \"5.29395592276605355108231857701752e-23\",\n        \"0x4.00000007e000fffffff0000000E-19#107\",\n        \"255.999999999999999999999947060441\",\n        \"0xff.ffffffffffffffffffc000000#107\",\n        \"2.06795153233048966839153112178982e-25\",\n        \"0x4.00000007e000fffffff1000000E-21#107\",\n    );\n\n    // - in div_float_significands_long_by_short\n    // - diff >= 0 in div_float_significands_long_by_short\n    // - in limbs_div_limb_to_out_mod_with_fraction\n    // - d.get_highest_bit() in limbs_div_limb_to_out_mod_with_fraction\n    // - sticky_bit != 0 || diff >= 0 || i >= abs_diff in div_float_significands_long_by_short\n    // - tmp[ys_len] == 0 in div_float_significands_long_by_short\n    // - tmp[ys_len] == 0 && shift != 0 in div_float_significands_long_by_short\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_long_by_short\n    // - rm == Nearest in div_float_significands_long_by_short\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (ys[0] & shift_bit) != 0) in\n    //   div_float_significands_long_by_short\n    // - rm == Nearest && !overflow in div_float_significands_long_by_short\n    test(\"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", \"0.8\", \"0x0.c#2\");\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (ys[0] & shift_bit) == 0)) in\n    //   div_float_significands_long_by_short\n    test(\"1.0\", \"0x1.0#1\", \"1.2\", \"0x1.4#3\", \"0.8\", \"0x0.c#3\");\n    // - tmp[ys_len] != 0 in div_float_significands_long_by_short\n    // - tmp[ys_len] != 0 && shift != 0 in div_float_significands_long_by_short\n    test(\"1.5\", \"0x1.8#2\", \"1.2\", \"0x1.4#3\", \"1.2\", \"0x1.4#3\");\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_long_by_short\n    test(\"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#3\", \"1.0\", \"0x1.0#3\");\n    // - tmp[ys_len] == 0 && shift == 0 in div_float_significands_long_by_short\n    // - c >= u - c in div_float_significands_long_by_short\n    test(\n        \"1539239.2465826685826\",\n        \"0x177ca7.3f200ab152a#64\",\n        \"0.00009\",\n        \"0x0.0006#3\",\n        \"16812597210.673628039\",\n        \"0x3ea1bdfda.ac72e31c#64\",\n    );\n    // - c < u - c in div_float_significands_long_by_short\n    // - round_bit == 0 in div_float_significands_long_by_short\n    test(\n        \"1.7088961703394199635e-73\",\n        \"0x4.d4baa70e83509ad8E-61#64\",\n        \"1.7359472818744e-34\",\n        \"0xe.6bf39991dcE-29#42\",\n        \"9.844170892645193631e-40\",\n        \"0x5.5c13c13c6d059800E-33#64\",\n    );\n    // - tmp[ys_len] != 0 && shift == 0 in div_float_significands_long_by_short\n    test(\n        \"4.874956728709606165589080471392071684004548689044982493122e-71\",\n        \"0x5.6220e3ededa8be921ace72bbb95a16164a2f0abd57c49f18E-59#192\",\n        \"1.5092483e-10\",\n        \"0xa.5f190E-9#22\",\n        \"3.230056172437141772802006354545046772521759341614858124236e-61\",\n        \"0x8.4e07636cdfc96e412c1de0a522f40a5f092091c1a3aa159E-51#192\",\n    );\n\n    test(\n        \"6.88621557179233820703925296804982406452e-28\",\n        \"0x3.68ee78c4dbb67961d201a40495749728E-23#127\",\n        \"0.1418399214207466117788070203268\",\n        \"0x0.244f9effc4f1edfd85dfab3008#99\",\n        \"4.85492060543760755133907256608679730501e-27\",\n        \"0x1.80a57d020f8b7083401eec627a6787ccE-22#127\",\n    );\n\n    // - in div_float_significands_general\n    // - up[u_size - 1] == vp[vsize - 1] in div_float_significands_general\n    // - k == 0 || l == 0 in div_float_significands_general\n    // - up[k] == vp[l] && l != 0 in div_float_significands_general\n    // - q0size < MPFR_DIV_THRESHOLD || vsize < MPFR_DIV_THRESHOLD in div_float_significands_general\n    // - rm != Nearest || shift != 0 second time in div_float_significands_general\n    // - qqsize > u_size in div_float_significands_general\n    // - qqsize > u_size && !extra_bit in div_float_significands_general\n    // - vsize >= qsize in div_float_significands_general\n    // - in limbs_div_helper\n    // - ds_len == 2 in limbs_div_helper\n    // - qsize == q0size in div_float_significands_general\n    // - vsize <= qsize in div_float_significands_general\n    // - rm == Nearest second time in div_float_significands_general\n    // - !goto_truncate_check_qh && !goto_sub_1_ulp && !goto_sub_1_ulp && !goto_sub_2_ulp in\n    //   div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) in div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit == 0 in\n    //   div_float_significands_general\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n    );\n    // - up[u_size - 1] != vp[vsize - 1] in div_float_significands_general\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe0#65\",\n    );\n    // - qqsize > u_size && extra_bit in div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky != 0 in\n    //   div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky != 0 && !carry\n    //   first time in div_float_significands_general\n    test(\n        \"1.5\",\n        \"0x1.8#2\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.49999999999999999995\",\n        \"0x1.7fffffffffffffff#65\",\n    );\n    // - ds_len > 1 in limbs_div_helper\n    test(\n        \"12077.327578390390934514\",\n        \"0x2f2d.53dc2d699afa78b8#75\",\n        \"4.90332775049862782951473377323022738896770775e-11\",\n        \"0x3.5e9a4013acb1890afeca956568e5bffe30edE-9#146\",\n        \"246308796656764.923124719743308898445103382544\",\n        \"0xe0043c546c7c.ec51e6d16d3ab81c76ba65494#146\",\n    );\n    // - vsize < qsize in div_float_significands_general\n    test(\n        \"1917511442.613985761391508315964935868035476119276770671\",\n        \"0x724ae712.9d2e2bbd62dd31f140b2b9b664635f251b18c0#180\",\n        \"3.352896739388742667241376e25\",\n        \"0x1.bbc08f6e851e14a094c4E+21#79\",\n        \"5.718969570663133425280005234972069245666491961744252885e-17\",\n        \"0x4.1ef6b3c1725013efb2a8179983b542a97b0131f39a938E-14#180\",\n    );\n    // - rm == Nearest && shift == 0 second time in div_float_significands_general\n    // - qsize != q0size in div_float_significands_general\n    test(\n        \"1.490328e-27\",\n        \"0x7.61370E-23#20\",\n        \"2.89262335038499315783322011549431655756e-75\",\n        \"0x1.4ef161f7b7fc2c6cb4464f827b58b972E-62#128\",\n        \"5.15216656741446303242577558053691246166e47\",\n        \"0x5.a3f1d299f6f20544fbba161403f075f8E+39#128\",\n    );\n    // - rm == Floor || rm == Down || (round_bit == 0 && sticky == 0) in\n    //   div_float_significands_general\n    test(\n        \"2.38418579101562499999949513e-7\",\n        \"0x3.fffffffffffffffffc0000E-6#87\",\n        \"2113929216.0\",\n        \"0x7e000000.000000000#66\",\n        \"1.12784561231761934265233937e-16\",\n        \"0x8.208208208208208200000E-14#87\",\n    );\n    // - k != 0 && l != 0 in div_float_significands_general\n    // - up[k] != vp[l] first time in div_float_significands_general\n    // - up[k] != vp[l] second time in div_float_significands_general\n    test(\n        \"65535.99999999999999994\",\n        \"0xffff.fffffffffffffc#70\",\n        \"22835963083295358096932575511189670382427701248.00000000000000022202\",\n        \"0x3fffffffffffffffffffffffff8000007000000.0000000000000fff8#219\",\n        \"2.869859254937225361249367321235116718339077564583058127288930659162e-42\",\n        \"0x3.fffffffffffffffff000000007fffff8ffffffffffe000001c00008E-35#219\",\n    );\n    // - up[k] == vp[l] first time in div_float_significands_general\n    test(\n        \"1.91561942608236107295e53\",\n        \"0x2.0000000000000000E+44#66\",\n        \"43556142965880123323311949751266331066368.000061035156249999998\",\n        \"0x8000000000000000000000000000000000.0003fffffffffffff8#205\",\n        \"4398046511103.99999999999999999999999999999999383702417796084544\",\n        \"0x3ffffffffff.ffffffffffffffffffffffffffe00000000000004#205\",\n    );\n    // - up[k] == vp[l] && l == 0 second time in div_float_significands_general\n    test(\n        \"255.99999999813735485076904\",\n        \"0xff.fffffff800000000000#82\",\n        \"1.35525271559701978119405335351978053e-20\",\n        \"0x3.ffffffffe0000000000000000000E-17#114\",\n        \"18889465931478580854784.0\",\n        \"0x4000000000000000000.0000000000#114\",\n    );\n    // - q0size >= MPFR_DIV_THRESHOLD && vsize >= MPFR_DIV_THRESHOLD in\n    //   div_float_significands_general\n    // - u_size < n << 1 in div_float_significands_general\n    // - vsize < n in div_float_significands_general\n    // - in limbs_float_div_high\n    // - len >= MPFR_DIVHIGH_TAB.len() in limbs_float_div_high\n    // - k != 0 in limbs_float_div_high\n    // - q_high != 0 in limbs_float_div_high\n    // - carry == 0 in limbs_float_div_high\n    // - carry != 0 in limbs_float_div_high\n    // - len < MPFR_DIVHIGH_TAB.len() in limbs_float_div_high\n    // - k == 0 in limbs_float_div_high\n    // - len > 2 in limbs_float_div_high\n    // - qh == 1 in div_float_significands_general\n    // - in round_helper_2\n    // - err0 > 0 in round_helper_2\n    // - err0 > prec && prec < err in round_helper_2\n    // - s != Limb::WIDTH in round_helper_2\n    // - n != 0 && tmp != 0 && tmp != mask in round_helper_2\n    // - round_helper_2 in div_float_significands_general\n    // - rm == Nearest first time in div_float_significands_general\n    // - rm == Nearest && shift != 0 first time in div_float_significands_general\n    // - rm == Nearest && round_bit == 0 in div_float_significands_general\n    test(\n        \"914122363545.7300954288539961362078521335512160921125366724096502748846903936195389924148\\\n        154757063704910629280973433563521737016298541257057972452261335506117124831272191707877190\\\n        2119190824963185068512647039440777212199983388696\",\n        \"0xd4d5f05299.bae788b5e312f78f55ac79e4ca82e12494296afdb40ba21e0c21a4b3915ba2e217c389f8c9fd\\\n        22042f5ed70da20cfb9f1ee797b1433e077a2d34b1ae5781f975eebbcb21a32ee0c5afa5e59f8f382fe0c754a4\\\n        a3fb57fa4d668#754\",\n        \"99775868891207693182758620905617766484977359141657322302733467080906379945858675686059451\\\n        2527853476231275058799551652072546.7114971760702609364731573674336745185834760605451122614\\\n        680178551142556046183482705875960001033145321970465204907865385015751310573750415565593472\\\n        515573584122133946534420508845514863685042630834456885627933663697385547769664847990486584\\\n        336882273751721721644989648370590667737234950547668737865047573751482757356022197920174371\\\n        088074314780588737501583713833755004374512024407585163195094394292034507503368814534990168\\\n        9912721166210129145585\",\n        \"0x1826427338bc8ee8c907c3ce5e6a2a793f6ba67df6e738f22dc8aee7eb1838ddc4290e49186e61bdbedb847\\\n        d19c5d8c4bf88c62.b624adce6b0a3564827e04608c1aec0c8b10390491e15df75402c1788241935e791ebd5f4\\\n        25d73042c03e3bad5f0d11257d8bcdab6c8bae677785865be19fa4f42690ddb02174b09bb2c1c9ce6cf3dc2d80\\\n        9f0b0b79c42ae70f14ec682ac3850e91ee3b6ef02555e18758417024bf2e8801a759e710b3ac91f28b15277ff4\\\n        f6380b7ba380aa56c032ce8db2107bfd99a9c789098467f2b27a7b3e1bb6a9e7804ef8a26a3baea51e9a8da4d5\\\n        02af09995fd6ced97b00#1859\",\n        \"9.161757985214429764992710266551647359057325985892606639113002591596898046569993924851132\\\n        469009506849046579846739625666450546615840413944516736833310444241924771226669449467280905\\\n        847180462085951493210441487438964221396785151298524525494386941673630175499486324164244756\\\n        513337189186243674611400515366863669226025015162200893355049656715514081022497216123358900\\\n        204159965608607573130556648229035236124949246847315199932950877590362471534070708393335471\\\n        028355306786566135185894674384218244976402468322690432705335567965983855642753641740432604\\\n        3437409476409135277542e-112\",\n        \"0x8.d032a1c09c5a822250facc4d03dcbdde26d4f5fe102c1e08a4f87e413b615d798e202484a718a7e4ee277\\\n        3677de7769fc7d817e371393d771d3460b42f92e9ba23196df3ebdff7cdda4294aecfb6c43776a893a979bdc8c\\\n        cac166e11d435edd52a1481ecb355a6595fcd794f14478ca886b31b8422e8bc9fdcdbc2261e6c6dfdfea3875fd\\\n        d48e82b6f89b37437a8064efc36e3671100bf00cb530951d17bbaefe545249991b357ff0fbc5a593a69916e391\\\n        e844f20336e8635a395cbda774a8ed440b65ccac5a4a48827068b6780bdeecccb424ecbcea085547d055a670dd\\\n        a2ce7fd1bc8ccfff3fcE-93#1859\",\n    );\n    // - q_high == 0 in limbs_float_div_high\n    test(\n        \"3.667390117738159207950705349477719105571949429980976394812181671883945054829509256768693\\\n        428777428660656941387302685172371854480204626447190818847235223777196475037450938977825246\\\n        002439873468885558547110470430228085143851019175355894923610792842932340338852051239754427\\\n        095026930245556704615627992643819617817074019244527799280182728405175259498139200084973400\\\n        185025632529817381341736837108765891093445296142846875524815723636775475593320258020981988\\\n        641285509338653295726597545939874976233498010217572353942629414771256828458910867296816672\\\n        522543163090158525097032013393556880192772591230747507060825723928635133507431423165786715\\\n        278150157159772706487785219042905040143153742214007713387626849311191420055238664770362170\\\n        343983987545766271318010394410223132309343859005046365250499465556871672911799580499791909\\\n        295656508202340485571517780009270726548788594036564495463224892161734462687808109262481368\\\n        096969794376769660230615691331025217443348007977074560288273633401967130359649250852147512\\\n        141074330343117535301250887203664127461249846867757356639750473042390297739319749311431157\\\n        14372183907772936544329974943881256368038028229439176970805917055179180439477409e-9\",\n        \"0xf.c0568c485e0b826908a56a1e9eed605a795d47bbb3b22b86ff364a5aa967860d79fa907ffa4b598c74ca2\\\n        768fd610cc65e72d1328231f74c2896a372707f3fffd4713cd781c36ddc8c429a53c9de0a260ab39221aa6723f\\\n        639d4f0a18f42a39ce148ec18caa8292a2404e421cb5af96a525988ace64d3b66492e8b29b9f1982af075eac7f\\\n        a4c4f560684706f9c92a1babe3a7cedd233045842df3c534b90481e818908a787ba694e61d3bd3d93a45651240\\\n        a1926f3b818e8c51165d9c7c186dd99b0afededda17332acec6e4419ca2c498ecac62e9670b8cc359ac4ce5abb\\\n        e6a858a9ad732af4717655c73ab36f06357d16912bd759fba2c774b33607e2ee49fbf3328842b34b1649846034\\\n        e601a686e91c2040c578ab8676f4c413bc62718b75fe591900b6f10a6ee20a73c59ab3be30fb9a154c1a50b4b5\\\n        d60d7a76de24b93f804302eb4d625df61cf824be4c93189bd500d72fe88443b2e506a11e3b57403b447b8602ef\\\n        45e256c2e9cbfbc69697901d340ae418d96a38e3f87b38c8ee8b168c15df448ce29060725fff6438c91fd406bf\\\n        6cf95e07431942e379a50250441c4ed69a634f4e155cb67d47b7b4b285388f957b3809dcfb73606173ca9a64c8\\\n        9b5ee06f42fc1ee8c752cf947957f346aac01a1e21759f8267f58d36b22e7bd14E-8#3843\",\n        \"3187923845432148642442057154569059.126715487792372839803386914179538752693826970283207166\\\n        811288798839227319311871148502823407877176659352907588186871022894787193533982873662011253\\\n        290757573915501169313819926148549862448642272469031186766746849160076154409190019980289710\\\n        170792165652792217117270925812431819493193080694795589891807146039351866024622601910524654\\\n        975993653145125921373829181052606711648254654081125875153947355721451359688668050452670532\\\n        460418624462017975144128989503732730892234660879379487543472739334395798501406522301770530\\\n        084261662015482020833397653047706275744771695945820139179975325296925632712346348118093097\\\n        953095934511815810581175318735500116787412839224213098543182657584610954902591533740060963\\\n        289805212670558460977431314581393471573332429725647583364688986461335610003995668212280028\\\n        807977055980202986273442266172236653427698776974320204115552560417196660880213932819325142\\\n        548937684752935846670101028764484218237392844524558383599287530029421881169570993841163993\\\n        843829902198804691520255195056203676272889080365643704609455722537324606271987166289767672\\\n        190663805227886932691226996255254535007618551610966568052639325048438160780381909128343538\\\n        211967934803057176881479842550254050201767779261994751352264395465646274141983125281497566\\\n        020553366225193569060382295548356106219949376044134821789228041804290511458952966410365196\\\n        222090758059421770693182158103609003570428820956594490269060711518240230638460085565864341\\\n        256289190220580928350048868798606128912317218138793827337661513849296003850300428079774414\\\n        62431384255329048179650372924700507846477189871631671161154559755984562472291\",\n        \"0x9d2d417f3ca9f32fea99c6482363.20706d1bf7058f4c6275f668a177cd076adccb2fda12b6ed78a3b56bb5\\\n        9dfb518b8b3c05c40c48fd5544dac5cf4c4b5097a348e21623af642ca54df95b1dc69591e2bdc1e3f296461a0e\\\n        73545f0b1a728f095b34af1c14dc3ff040878852b81a047198ec51c9f7dcfffac0ad33017fdb2f0c43edcff12d\\\n        ef18336029b6f47a305e278cb4eda766445530f250be179818a2d241b5afebc21b194dbd62400042f887100725\\\n        62fb877debcff302fcc5b1162c1450e14478eb4e96906a31d6843172390e3cd69b3c0f474a72a62036579c22fe\\\n        1d1ad35fc2be49e475a1be85f30bec6d387e595070d17b17f5b5a6f400fde641d92abee13055777fe7f6b647fc\\\n        7850f8002fadb99332ceffb5439a87b2ac7f223b73750c6b42112fffe8b992da6c3fbc5274503b1bba48602753\\\n        174ba7260f73f3fa02c00fc495aad0f85c84c966f0a98fa7d85cca68b07d58e6292617f3b67fd0aafc0dc0c457\\\n        806b811f2698bea27de70e9ea3de0e898978b9670aa90750e88ac855daaf830c9dedb5d22968f2b01302edc889\\\n        ce03e2af4ec2e339258ace8efa81eeb76b273039929d7289eadfb0bae898fd0257e0f1db349eba610dfb56e3d3\\\n        1520f08012e02d96edfbf9a1a05ad01f682c49e1cf1e0f2b1131943ffe95afd8c6454deffe4bfdbf15fe656e18\\\n        13690a6dbdca197ec4c2b29ac61a6ca074a2866ff9f55184ed344bb45b2e44eca9945a21cd78ccdd427dff1dab\\\n        1d449dccc0aa07e37c89bb61c7fc94ce0edd5fb60b7e2d8034decb7a0e2bba4c1159236fd7f800450c1516e64c\\\n        bb2206f385ee11aba1c6993b2d50b2437bc23cc47f6b85d72fdd7348a5e321b5c960e8e23830fc93c4393938b8\\\n        98c2f16e8452c9e81ce5aa01460fb108dca1e371c53a1e72ad6ad0cb80bd5bf0ace476ab08fe8#5329\",\n        \"1.150400792350488243006374252439239370084430198894097883408930056885079539097149903334801\\\n        351771948494649335504249165228317854781872084884358035626531528587565616792440130659246789\\\n        547068913471358728267587391921067763401960740658485999234360708658257354709138940743401019\\\n        478517400580149085993404074744575447821383623813098520973947955049547026992303475579228215\\\n        436224676800479021561310494945776720018368502752527214637080415175177143606297950367602304\\\n        149567232708944245857383841379350871799797376084773487408407355299732079377175164962925047\\\n        553551234005632068337070468847266947004802579875459884664958168707856865409967591741263680\\\n        896819771668163339399940221050773763868745744855354003266260565352234279551485173590767169\\\n        460117377689246074482291141675360319952860733464727767370984256722737643645180588444886771\\\n        648355387388454942423178644791668457452750839522592156007162798991977390140623536578544490\\\n        057707937271642210929120388296125663413585185722459999909564986042307052548228205977082023\\\n        238981495642981332360042089388607651948288196055583153394379775735995327224157713864077477\\\n        321557707540034099204193983589868016082915953745995091314702115380175700364741814725184464\\\n        602065018950641261052531311066491931955988616475785792821351515116629573461861957542243077\\\n        532642867446492701937719979200426618485741197144774966492676324343483017759514367363624027\\\n        675809506514516688590348320872084123672477458766804242125009602995249222201904595636534318\\\n        096670348004414769559053243712710972449074750435098780379781902955436286126620063025099547\\\n        80435463720060716005725004637793753168276780047800093479230422676842555945701e-42\",\n        \"0x1.9a7a0a4405b5655db3032989d155cf7a58151a06aacabc4789fac720edfb0e835fe88bc9af3cc179149fe\\\n        616753cd76b4c7d9c17f2f47389f4e0007572679dad2a5316ede08c14af0283577f171d41d795d4ff13631def2\\\n        630089c6f215d7b5b8948c52ff97a4a1d9f1eb6d67b60e55478c40ffd2a7cd9684f43637e46ce3ce3e33085654\\\n        9165c4a377c6ab1dbb9c9b40ece8c47d94ddd1318dd2e5e57388b2e8ef80705d97c3db61d805c43cf7ff7a9a1e\\\n        41ded3ff033e68dc751b34ffd9cf2eae50cb7e7875b9d8f24116927cd9f609a65c71e840166cf535bbf110404d\\\n        bc493350b17705c0e23a9091d61f544117f70c6c6387dfb9a1dcc2f513cfbebc4cdd4b7d94c9fc57ceebebe3a2\\\n        e7d85b9b488b5571ef7b7c8621b770d99c67f9a19252ec5f9be4b129c7755b4a8585b97ea68e60e390c0b5c2b2\\\n        7b5fc3a47825c136e3b2517a6a7490ae84cf61659a9b819bfe59d45f7254dd48e028c7b694a9b9b427e60358fd\\\n        52afbeed855580a61e351d523d4ffaabfc7ca00e9a5b40128e9fd8b2998c189e95abc1857ff9ddf1dac904a2de\\\n        dfce45cbc4f1ffac50c26ec7e1135aa9ca96f6d3ac8cb3a6620a3aecb003d246eade4cf0e6394df920dfba899f\\\n        44ed41072e121f0402f19fc4c43c348467a07566df372a7b1af45354f2b4c7f94d52f355813e84c1a95202029c\\\n        0056a974e856e7c42fd6463561d1b5e02ed6a7e0ea0ca50887bd1047f4abd068ea61e2095abdad6a0cbaf91846\\\n        a340717aa624d6c6ba02f5d3e835ff06c742f1343479ec9a9b184eaca8e7c8be7eaf4fa322afc13f046a4a2e5f\\\n        4e84c723c68079991a080ac6939780e172640d568c2bc3452c14317358ee8d27a18af7c9bf2de8bea3e5b8b113\\\n        d8e61b810d6103e805c2a8f85b9b88f8c9129b924ba95521aa83a066991bea980c8be16f1df53E-35#5329\",\n    );\n    // - qh != 1 in div_float_significands_general\n    test(\n        \"5.001744775175450910666028825162941035057223155811961434576858983758571141018459147239961\\\n        203150588371507863692097065128597336587126035820647361489875366021800666979434518756504925\\\n        080057234368614339602900137940067888065298554658519361482160014564328827389146902718969285\\\n        655774560873251528749737416878097111467317878479458938947793439179987668446365650646689222\\\n        368834166803110702160567896615568919058064520266761717855703906871630752776256537972706691\\\n        492064397304429453321564568279795029252524047182880248127317544801138445700458013706547493\\\n        607273723210196209139384085476634511414334117395068648152693457778920460359930382343697178\\\n        078573995749595631668772420417704996567074590195305455833132484492282116574194971013126880\\\n        3791636230633361526548302742414616516594455084620537903358416e-16\",\n        \"0x2.40a97302ee75111e17146bc65c8925811ce517da511093e155a5f8d319eaddbeb4108f1636a175bfa8c49\\\n        995045d6820b2f007a269091d024c939d8b02f4910a81e4eb38a836a327a5c12207dbd4d7a81228e55fec96493\\\n        eb7d51704a03ee77c5caca6616fdc0b6cbe90c676923de6ef8bf3f132b9e5e0dcbae8db3a41502b6d35629f01c\\\n        0834af3506639efdaa9dba6adf35a24b53b04e032ba7f9821a7155eb04aa7d235436bb878e13e2f265b7a183bd\\\n        7830bf484c2c6b19e1df88120105ab6ceb5f940ee7e82d4a6da4e67b7532f20750db350a532138117c02fd3f63\\\n        1e917747a8217c0e647adfae38491beacae6be9197fecb6a639604eba9f3e2a0e1250124f9d994d6ae0f8077c0\\\n        ad1f961f00f0513cb1b3b92f03fd2e19ce799415d8c26352d23ab730bff342c3d10823b5d476e3a74e5e3a1265\\\n        3a2e81ad38c5d7f45687a8E-13#2587\",\n        \"1.142392802815468388118014752111991104436260746248041498551240097570984474280784266879307\\\n        592064853042631818930172030116326290909317377878988867978348974337550025356060840134215623\\\n        183687852648862683292152461337367387727519703906836027722282460995072637442171724001503892\\\n        471336699233392710738717656085295397789876649817787754823752786376233371866685422498954888\\\n        388883747226256845650864591251580129661172288008506642506027201072159168710566406994425528\\\n        61698637621752755004821872e-17\",\n        \"0xd.2bbf98dfde60cfd72ff373085dca4697e7a8a2b1b6d379d3c49be918a519d5508c59f210662104e5d0b4b\\\n        bb4e9f09afcccb3c1655f91f2a86657e3f1315aa4e7c857d68f4d7b989d2a2f5d56a205e85ef7d6d2e9325e0fe\\\n        eded2158374d99d513a6d203143a26cfd251731f49e63a0e342dec62e52287bd673124d763a94038f4529cffd3\\\n        3599c97c0e19c589ce5603d9c26a084d360b9e7decaa7dda44ce1c27bb7c21adcb23b90d069b0a9b53b9d66094\\\n        d817f0420227841d34052ed2bd52e148923f8E-15#1571\",\n        \"43.78305573046740119713641861874642911154821650761595780287653003720809501996262685108891\\\n        851641972710141298162279987632328545443442081070773994511258975201978303856309243168868354\\\n        195798884971190979692045031917290903217918542303368118161338247041052975773351929884789101\\\n        115569142934332750399827875003719838494787907290778719530315375971295186399328856671813524\\\n        401338950750393532748258170809380674066918530153006391759208813425198252649570832466781508\\\n        205219467712658427254330831981130973959961174357861904110964877950640959685965415405374479\\\n        749995867814629083616329619361738872731212580413192190669870683344353586783786957328312637\\\n        080558281918488071596583884466679323108552730394571978915258990045025562636051246193761815\\\n        9037942507064891051161378037771712070204599081778501997567779\",\n        \"0x2b.c87657214d897953f5e5edbb169c290285fbd11622c9cf401ba99ad9f03da7ffc778df1db0d888d67c18\\\n        379efc8b4b36ed8cbb67da04b5b4cfdabc5f751b0a6fc68b1e3a2a16a62c4160ce4d10e00ae47020ca5d3867a7\\\n        2213145fe6456480971ef0cb9716c6136384fe41721979e86d1ea1bdc104f2967865add528a1367b01cc449a48\\\n        5786a74209d8e4c5e216fa7ae2dc897fd4926b55eacde3321f7c41bf2875c24933c8eecc7a8a26f738fd6d666b\\\n        678ec93b48bab7b34c5392d3ca76949dab6958fa5caaf70927d3e8b40d050bb607bc1b4fe656506e1b3e468e87\\\n        8b257c21e926286697a97538d3230475cd54415b8154351e72363b4b7509061108fc6ac5db47219368f3ca4011\\\n        5309edd7318a116c2b62a34277bfdc8a1faf656b14b6a046087cfc5dd238cd94fe91967fb6dfc52f8afa5699df\\\n        e2970ca40fb03c71d7d668#2587\",\n    );\n    // - n != 0 && tmp == 0 in round_helper_2\n    // - s != Limb::WIDTH first time in round_helper_2\n    test(\n        \"0.029226865494398284939675773661541675546326681033634876986774906885711036844605915426240\\\n        340310096249605517533494947862661721742262334681480455706389428160732541825851560446846541\\\n        984468705310228771603694136853587701004882713625816107989162498255925332620064155091399923\\\n        221735997586925448254801064429910518067322424203818026901404115120552071966804127784634236\\\n        948421057038304255272147630765439482924461011451862112889343084859504616664030668233890526\\\n        750016895266382189553251377266295422223247821668554701473442441938933867323625955488726630\\\n        366895993417469747854898337776376811834753617592182604418498468334055402941851068346511528\\\n        636460609896950078921029074658151972716364203699936241491820871671807186599907001653993018\\\n        871354678119954470481273332266267481346670395677171242596948926022697465301700258863974068\\\n        74909984356479995046141060221761701111762543380195142151878885588292130260647185\",\n        \"0x0.077b696f76893b930df354ab0e34b0df1508ee4503f673e22fa3b41867c5e4ffbc43b589d4cb4a00c472e\\\n        4046ccc9dd4a2b88b59dde14b46da030dc5a0f825fc1d9ff0213e8b046b1cd79785dd554b78e98759eae454c23\\\n        4fddf6ee7ae174bfc7c1ed096e905b41ce6b18511a9bfc9cfbc43c536393410fe83a634f402b0f18a446a3af90\\\n        9a4079394959da6918bd9094c5b587839c67f902f1f107259257f4ae96549552e41dbe7dbaddda5b9d8fa2b2bd\\\n        d01ba920c27d6ff6e44bd8f0ef230d60508f693680e1d769f920949bd35768a7ff10fa62210e3caf84f93cdccb\\\n        a5238b5e4be804a1422da22abe509c758d0cf44f202896613342ffd0fa93939f0c9bcd4de899fb72b286773da8\\\n        fe9cbfbd51894ec97176996bf2b6a61ac27a5f524cd408e8bca09d7cefc329a98f17616d4b48652d0a3f14cc49\\\n        a9bbe75a69ae9167aaa9d1951d446e95bb89c1760a549ff81f7b1d8ee454047a7d3c3e244dc499d97b256eca33\\\n        3d43933df1e0a046136e10#2940\",\n        \"13755175900776476.03444104347769161034491994978466673515315430911280875941467408228432201\\\n        072744723926732268661761372710838010056791678637659254162102142124198282086034764229922487\\\n        783612307113854432839997318024745178344073274492535681224805316900558167281372795857375154\\\n        556654904332875058382920111153919687941523340022403648029377155100560618075774147398400587\\\n        446623619383420263487024723715538921428293815054071349051549046244877203394687286110159347\\\n        188168590858399073350484327515115795260226962105536078430163098017753828590552884767518140\\\n        1985404905771271934\",\n        \"0x30de427563881c.08d120d36075efcee88657ce81cdcaedf45cd89aeca352b6e32212d20771ea31a54387b4\\\n        8b1eb8738ae1d31c6213ddc44bdc809d5f5b278e3449ebd13c9ab8d89ec9f0a2d87e7233cbd5128caca14e0c42\\\n        61e5c9ed6444b50d0cce082673e3c80b1a7102c8fc7520036bc3c6900dbcff7cecdf27ac4022bd4095736dba93\\\n        f47ec8ed66154c32a8eb07e14079a264e1e3370aebbfeacf3a1bbfe7aa657d9911acc70d626a35a29d86c84029\\\n        f97428f7cd8a3965838abf5dba9a9943b07c0ad2541156ef8e2aca1afd50c7dc55f986c835b95647701f744563\\\n        d15716174f2ac444#1845\",\n        \"2.124790384741531086324618396766014790807036315098759090708607153306148130187657728807205\\\n        824808003798574987452867827342282934278081982848900135498971286785256137258700150407383617\\\n        040883394430575593960834148265479663570529896251340120502267014474793716347382140126837773\\\n        997589830815187190064041312015350810806968062929485379465521677249527992330225473850965169\\\n        559943150658138282772411679190301632849325467452565481282203194749783450341076382685241552\\\n        308193411477432500590221491760317417660435511777399629140824293491122934845121250984106958\\\n        267596015361360781611025519421253206751640221273565905944385402975185311734694681019948131\\\n        664198303801199498616289444621169851399879692298796098215712787193626312888177618196672010\\\n        550069281366814417353104090880010484400040465312380510548737422916103805415326232623198929\\\n        338433641210905412883566788706510371353536321443505713555119784985687877546815e-18\",\n        \"0x2.73209f5170c5b9aaeb5a7e9e79e1dba6ba9eb57b8701701f4d2be387a03993b7e53f907a48a9029ff962b\\\n        4eb20e6ade6771889642b19b1985ec76b2b24fb517b27eb86681dab6bc7d5a5a203545d850396986ce5c6f9542\\\n        50b478a0dd27222c6c45900f2d06dad9d7f78a79b9978e3ce203479c5dce6dde3affc40e370565c038007c8bc1\\\n        ef1fdf0f6398b88721063c52e5eb2c4b5ba1f10d93710d5abe8aab35f5bc5cdf7031f7765dd4f9d4065b1b5b86\\\n        4ccd6665b73715bdfe783fae157cdc8a78e9d053cae011d4dddf28499ac3809e290ca0a221e38d2a6dd8d01980\\\n        c64da2f6836e0815e2ae3feb8a0d765808afcbdf6df10cf661eaf6c064ec8023cad01912101fb7e8b732b555b4\\\n        a053a203ab5ec17c24af5694ed7db4f67c3c76a7f360512bc9a2018d2860111211238048d21af3d79aa0904474\\\n        22c0d9c9883b2f3769a5fe3faeaf8bab1409329c376b70c7b54fe1393115359c5a7ff43560bc0e2548a02ffb68\\\n        184585e5023a6fb507d0E-15#2940\",\n    );\n    // - rm == Nearest && round_bit != 0 in div_float_significands_general\n    // - rm == Nearest && round_bit != 0 && !carry in div_float_significands_general\n    test(\n        \"767950667289861979450190915916317600206727962344150969868.8721759327117422801652737665276\\\n        756590281054535919141164571740727630029753345081284383462360338144272865435150624843971065\\\n        632159910277471560574746205336214689461444841220676837587640834824669960199738043592424986\\\n        826697488691269778053087892841924823231361961899657984958299046295741089107389167540777341\\\n        1137893901502419455\",\n        \"0x1f51c7714fd0115fee394111538cd8cc2697edb4db72ae0c.df46ec035af05536a25a7e2694997099b2577e\\\n        a12f12bb82f781cda7cd6a148cc07ab56a0bac9e90b8590cb04b95fcb27209c3c8704cb6940c7fb857c1688d50\\\n        6042d2fb6c58e0600ed4d86a5af398f029ebf3521880629fcd23f2bfd5f9447e8dee8310647fde5e5f5e2a0a18\\\n        7cdc4e8c046be95417ea73f5d4a1962ebecd092b613af810#1250\",\n        \"51.02908107282950125513822733633990251324880237789609831750259919822628384179764854139813\\\n        664310170076349095466129599769105832710389521373306698912599298264052853550294941822816681\\\n        854313580668986120583821047373123379751687690065811623363578923931243167028825931454472450\\\n        957582633858214796963862561877157489833071159740156527107422181977546544800568916528954101\\\n        973657910504690951238460938847030239913388867386095316629182004723248011669496406544341717\\\n        280330814897033602543594303927085904297027340275835376721330553519116838042737905906942433\\\n        571685773257005175176741271374980135164819404821829229591371965448368260666618720681201228\\\n        891015077648242337901859343084853665103006650868094946302847691177013349096688713595881758\\\n        621480481903927608236275982505035171940737146501502983532266096788435188627685343250723400\\\n        305856753098249087347464717300786991295322157886984156263306019163631926110778355478267431\\\n        730519001037411438399866507817311259465545754442998333101310788661554118860610086857525556\\\n        649462275011688416941329847092728287810185063940836755796270353054485056127471728114260616\\\n        408519706805571508639638485588089026599284155688404740772260862102363921554760355678529807\\\n        545078380365647104062842403550988330511500383389703046031841433893387481098301402534069795\\\n        658730174573583314000979689827444189825731612831252242895060479770394162281620141901978731\\\n        360879005964038152579829187416621515149774573766217606037565254139422563209723838864340747\\\n        448492223949482531030183865551640816462517599780266133382572731428229045787209942986614817\\\n        192016158247860998226332096129248802519217902568127470669978186812858044800325333178140023\\\n        387809105983555698845635663825858578549915679237164757880235025950739307212793316009945989\\\n        415835829851915334677834156538103555704104713171341701847682567317855121655570126973890951\\\n        3929068030854124664713500553256\",\n        \"0x33.0771db70bc3cc1bbfd03fee9ecfaaa1f99d76266a08107a7c922f5787496298c9bd6b5bfa13889bc0bb1\\\n        0f2e280f2673b20cb2191b3f747978b1483ed5890a8f1e9b4ef8665dff89aeff7e04820fcb58e76837b70b36b4\\\n        946ecf9ebe8fba5e510503f922f8e39500946e3ba0fd0a28c3a881101047c77426f1160e2835ecd5cdfc3c85d7\\\n        78adf772e0b5f5d5913cda27866ff4a68981bb0b247705d4a7a13e0cf5df9064561c207ad89d6bd10ed4faf445\\\n        ceca3d7f86bbdcd652aaf5c547a0071a203dca41ee8ec829aff439308e3dd8d470556949fb583c7ed1bd6c7854\\\n        bb629c27db1c0caa83e77e13d983d022e1865331aa5f67de9bca45976769e471933efa23a7d5fe8e03b8eed13a\\\n        3920db5d0f4052f811bcd1955c217ad35a8b75478eb3f2e077ecc810af955e23d57d0b957bf2104261c9f16ba6\\\n        a16f119f6d83e2b35b1a28b6fc7a029bcec426c495328cba2082e252a65c7267a9a83365475cc6b4672f77d481\\\n        40ec81e987a366445896d2ae795891105da2f608b56dca4a3e4166c6a0338423e51de87dcbfe3717817893141c\\\n        8b61f1377d82379374f5ad121cb9e04cf51776a20bc8b0ccaa51862efa4f51d52333818ee4877c039261bcd8dc\\\n        152db0a6119f3724603b4aaf9994eaf197d5adbcb723d1dc6ebdd8d2cfd37952c4128f3b79556ea134b7193dcf\\\n        afdc170fa41bf528ba4deac3f3d79d4407db9fd076aaca428efe74dbbc1bc7fad8b57ab1a693330f49aab1ddcc\\\n        f26bdc853360568f201c8fea22c816ae67afff2668debe399f951e72144cfa93dea4f18d1ee734ed2bf350fed9\\\n        d126c9b660f6b27ba5e13f15a8be20837e071c52d7588c0a856a969903419e91d47e7011235886759942c1c0e1\\\n        896e1621b2d23df869694531248722482999c8600632a5ab2279907e29cb3c38994bfbe299cb368a72ef45ecaa\\\n        b9646b4f1e2f37f24aa954535b1ba220c8e91dfb8f81e56dc45ec4cb3181511fa5b1854096fb3f03f2aa052eb1\\\n        5111548f398b2a0ffeecd95498fef2bd7f25126507f63bd3803c3a9d1aff24563f7f0baf024307e9c75#6074\",\n        \"15049274867282653916783425765897232338286237097021544510.63055696334657926692700975852105\\\n        429908991325181901560777184807721684871576977542689434849596891044659963521044055457283641\\\n        367304991334226236960366994118987961185804836414630696056584495778598754606288486597978327\\\n        332370268104018122071463105903604569912790301532188931593783003198530412792016208481406460\\\n        177569545284296438034561831086095957417103960718034276692579871391678752019863068680376188\\\n        441084892942908419595289335759422879108451807263984856494740183999962091220506257869533189\\\n        151879060260534882539324732360323776701789524149049182180697710000483323367419829770508959\\\n        886298233038628402259126153349007515813222501560286947664943532169644098519601985837510236\\\n        220345218089637472842801890223279059211522040546360301667071765816467200381174390649332596\\\n        068474921226001156721359127966627401319343668619013146928630922944213877247277873392955093\\\n        504639915667110210542526572018725370251615388653789028473354868425502960351888594917293217\\\n        742712292964655900915998259809033409553076012583762301750508167459913039705278696038307105\\\n        198133823120123667996810391703122691279674638629684591634520584549627376733588876153831722\\\n        199369165407756045645488517825617351416613370266999295351664343537186993481753740631996768\\\n        537474147168714208012012313452364629821090786481898210882140832386720226088895885830143936\\\n        713915428453413001094302216345205004980013281182978168058085052927135299009881922560519790\\\n        174395754146412113876346433499785448301225654969985504964945207336686282652994022882395571\\\n        250336046288750244045997533647713495015654011612857222465008362940468446125031495141758501\\\n        398188163302138089732641998828146315905675208381266922364102647252983963785718802006725178\\\n        667871858412814374481149992996719213942377608145948042933317201168269095689729130915320304\\\n        63030844892155532105060912300876\",\n        \"0x9d1f2bb817353ba61ad13135f94f65b1b52180f58a183e.a16c2e5fd6b05e4155475ec873e35d0f193a9765\\\n        ef45957a4681138fd789135172e7be4efd1b67c60d22430a10832c82a4dc4a53156de6d8638ce6ffe089ebf880\\\n        f2e1c68c90b576b5dc0b99085865ed663bd642b7743ff5500d4c6d3e2cf4977af36122c98fc49e81ee87b80d89\\\n        3fe81fa07bdc5986b40bdb0bf7e6bfde432dcedd2063308cf685bfee2b964ff62d434434a9518683156e532f30\\\n        11f2ac8f98a75178cd412e00f2261a83f952b6a94bb97c280cb51f16f85891ddd7fe6ad8030e20422da11497e5\\\n        efe8d88db4f96479fd0b16f3703dca8946d944979a3454bb8155d8dbdd3a765584148771967d02f798d157b6a1\\\n        59e10461bc83d8ec9e55b557614c35d75b391c0c9d04aefe96cab5078bd3a13d5618ca219640c68919f1fefea9\\\n        a3d1e47a3fcbc8c19de2210708fd96fed608648d183fd4c1177d803a49f7d276f940aeef6feaffded75f8e03ce\\\n        33df996eeb67ac6c0bec62d821bfce22d9a30baa6f7f4963eb4eaa91707ba1b12fd6f3e04f75cfea4dc39c6488\\\n        d72e86c36ba981115f42300b97a7caa427023f16c4f66213cf0c18f04cb6aa66e4830cc7040b3103e27c2e800a\\\n        0bce21b653566628a5bb8b0becb80b441801f31aa100fb4539cf7e4d6d68815a666c11c6cf4ac97878c551c043\\\n        3750e9ab6fdeb65765ae3ece107302baf12b3086988bf4d0b37206bde4041cc7c4fa79d38170719e92c052187e\\\n        e810ed1b2b425c081512c7ee6ea722c413215229ebaecc207fb1126644e66dea7e0139682e90f91c71b579cd86\\\n        b91211305fe40770c3176e35b783732c2d74c8aa1a09da66c4f34dfa1f9fd35662c5c3d1f82eeb37498b121357\\\n        e73ed7eea79adeab91001b3c63b1f75aa82793cd1a2b39e1bb09ecf5c6522ccc46652d831abe3ad1f9bc301df5\\\n        2c646068fd97c0402a29caa4ea3f4de8e5fb8a4d537d45d685f87d05d95f7ba40fbb6a919e93b44fb78b9c80ea\\\n        6c0a75b4dff2f73844bf4f7172907d8165f606a47821da925eda50af0ce44be22fa2b36d56e1d1698a8#6074\",\n    );\n    // - s == Limb::WIDTH in round_helper_2\n    // - n == 0 first time in round_helper_2\n    test(\n        \"2.169542166817986625468879014599175406350620737442480370882139687492174119453066131804433\\\n        632496405940270655469169364935548092764516132338564210201385531365409396738163453793191332\\\n        174443470862749001312126324808896288354477512722829484994475343567852816045883088813362218\\\n        109536965926916816038009290804934132950340684582117875938116310656669280480683072639988319\\\n        858148103369026349100099758130382359401952836454392007054797540845974323496094771400665868\\\n        125503436816661354237720713751777833086011158065863046075212704099660843597053397398549954\\\n        8348685976904925033580113969653312280822082757679509546197165e-14\",\n        \"0x6.1b51e41e16de577dd7b5a3a6222357b305d4e7313b1d47721ebe3d4275ef95b0d98ad997627ec7acc76f5\\\n        d426b7c5a9333cbc0dec080499093952901e541880379e2fdf874d1d931d1243e2b2ab072c0772ce94734ae65d\\\n        ff7afda628d44635b3fba75efa9bd2c10d8bdcb3a61a8b6a7697f598758d80bd808f17f8351b1761850fd75cc1\\\n        9f86409ac25dd27dd0ce7c26478dae9d50aff0210dc4fa18674fd87aa017255dabd141e1289a7e734e21577610\\\n        bf92b6ce4fe21881cc5209081e0536f0aeb1dcf6e288feeed183095b510c09e50c432ef280e742528c0c4dd6d2\\\n        5e65c8b6d19c28914472a930aae1ad7fac96f6442134ee95f3bd8E-12#1993\",\n        \"301180.0045246172416425721655892719573457356766058630317841133942315022590404351104810586\\\n        213517139802439747677458029756555586634849124296886483237621871644459126081050822492233083\\\n        707945595254133438910359944302659214080172068073620764660184379004827633051943726032292014\\\n        225559234820452819113849827971319776547835482966443724022128469656550054145203573809984759\\\n        336239968661049955088445384576034864711412948863817402256055440443111246220943775270251981\\\n        245519547063921282094595332683031347213016637666849460902039610984880445147686118036204784\\\n        051476863264255027838976527798504452504598268980029728768388473210371246534136227460265249\\\n        86471927\",\n        \"0x4987c.0128867b146bf9c05b0bb90d2c480c2b610c9c19a0a03f58f0d0aefa84d41a94dbc0c1206d80eab12\\\n        18d0f5e72e0b72a6f063fe0f604b1eedcc3760c7f60b2aa6e35735292ea939fa59fc7da94b3e86d7bbba5f8ef6\\\n        8136a9a4c5d98df58e4ad215fee20274cd18a324d8b66b0119d3cf93efacf51659a9814222c8f9b53fe6356392\\\n        e2b27f1ee07621f888214936f129248d805ae614b37cae5b83f51b2be167dc62ef96c1322204921369dc6c7475\\\n        c195aa735676f467be6a45d895b6b08fba56a7919ac216a6dc76cf9f5c3184a2ffa7b1bc3d8760c250d651afca\\\n        18aa90ff70ee4532482978816617fb02f0de87b2abd54886d1c7c16d62550d5fd8a4abb55b0c4ebb8c#2111\",\n        \"7.203473451839519375659920800256968930150281137907207966420457324091308743561158996788387\\\n        290694159461823269997598092194316979651412090098764718003237064733792291895103263169730962\\\n        123418174759909091404064508319172962888992299461557410206033700688023479037478761668781891\\\n        761303156472454780198812373188616203221872171676002219543916314587725944225532571475160352\\\n        707938049990541748698746656039607206067984173221685967465441429896808706646646536972493098\\\n        282122681082474772608417991249668805473092287771115239878542545454824251859441724816281902\\\n        754574769925885897122660854445163455617440019293712118274988718965330199709067927675503187\\\n        81705947e-20\",\n        \"0x1.542ca6851865ac89e311ac1608cac34c9fe637305345b739b624981a50028d6f60e7fd803167413e1285b\\\n        796e7a5ed37e1cb19125606ca9d15a697c9c497b14455aae6477ad96ffa4f216a14878a9802e8350d104f0b9d8\\\n        cd86ff511d7efbd74d40104b107a9d7f33d0e8894d3b157e46b7fd4e6386f823e75ae0efa9be33aac3e252d7d2\\\n        411f8e2afd3773f3914778d26a6b76f5569fd822db5a66db515e3cdd6699301b71cbdb73f07c24fb20d0c66059\\\n        fe1f236a4656c3f508e25958bdef5ca863d7950c5740d7849b46bde7e1a38b797265dedd7d4dfdaee7bcb69dce\\\n        887bddd7a7bbd45a6561cfad8cd840e7d95599a81bb274cc02a161439f7280459a15c9865ad5b658ed8E-16\\\n        #2111\",\n    );\n    // - n != 0 && tmp != 0 && tmp == mask in round_helper_2\n    // - s != Limb::WIDTH second time in round_helper_2\n    test(\n        \"7.967842945782984973942186035477141750978306951371418866981413625233901049016799636923049\\\n        043510064598367854094347269064974737243308027061881036076018766384961823690368428913274793\\\n        537e-19\",\n        \"0xe.b2b51b3ba9b3fa4c3c91f60bbe2f30efe9403d1c1ed1fa2688711592167dc11f579d747f20609a0e8704a\\\n        660072ec620d514ab31d0845381f10e96f76ac41c97c2a7b53849757dc846fdeE-16#599\",\n        \"4.290314881292277334232122993869736164625712811477787127079554140127474408529492187148865\\\n        860241941174878594521708166855716060386064937593774872957730026516247807479269506509835640\\\n        014575725456051856772978910171974972671741113731811243859146099959299700690748160884209812\\\n        639693266282036645473254451466381125403186024743001502094065938286200460441378264282871237\\\n        445194601993083290951436490295842815606015494575193282638997440331311694865085507331318327\\\n        437042408938144577985735854973264189023250983346696190654635795462654945584732891184659237\\\n        746883228154089313101793763347136552004708447204474905674167880735273390965084667673056531\\\n        378593414825374458582134295243495148718875340371312206621884585775967428131940924035968587\\\n        526069447315202760539547246403295371510536211424729007907823710381420209210303664575050843\\\n        559776729235120592670693730372232402604761499044741741752247404544150954858075273585139895\\\n        643242778698674255451287458469387850297372316908957826221759549123594364155475346755476293\\\n        552962991845182999537688763267208310118481794778770137863789646906639637779481228371710954\\\n        980900001879766864929946144490423459237336070803276511200399191948305713293997532907864745\\\n        24489311444825214442690999e-14\",\n        \"0xc.137f67f6b60895b6164f36c36d5b134858a21d493d7d49584a1811d76bd92f10b6d0aa0bea20843896e0f\\\n        d0d2e93957b024a1b5e7101d0f679c3dcc134107c20f0664acbfdf6bafac9013ae41ce018c62b6cf36043f13a8\\\n        1c35291946c79569662de17adff4ec759b1ccbe440675ef95167b0d5a5481ea6e7a6b998233e094436c8eeaefb\\\n        e21fa0f9c24aad8d11f378034d73a5daec0111cef1b0b8426dd5df78555318d44c992e40ad5fa98171908c4019\\\n        636becfe749a93747c965c11e84b68df48e887e933449d42c1ec5c2d6a7658e91f6d68333ddfde5719ca117d72\\\n        dadec43975eb0b6b6a076c4ada32d70b0e93250cf5e8836b11ad6a8b13a4a957de6221168782640f2313ca3716\\\n        3e4da0decaee000e5824d53c71d0a36a55295f8ad1c7a86eb35eab709891d1a6ac96a10448e0e307c7d6742d8d\\\n        0617a3e21978394d0393bc9be8e32ff2d87e85ae44c3a76ac79752bcca4927ca5dc6dcfc4db10793dc0cfc2161\\\n        24fdf30070db19fd8a89982adf45a408e08499b77cf25011c54cf9270bf491a2186e1a5fad26087812cc3c2446\\\n        ca7e5457d75f66fe9e736ad07c6b1fe4b20eaf1f073d454f371f659f7402d24e6666c8e212ddccf50c22209ca5\\\n        7651a266ecba0559cacf587691f7f7df3389d9968023d71b412cc20516c9b1d00f1392474c6683bd0fd6c6dc7a\\\n        705d88E-12#3966\",\n        \"0.000018571697337476093645597974800042221391343383471511758884717235995391699590980821846\\\n        925772010524277797520625056343676345716562878283777572676679678398279369283853673423775272\\\n        117775978501001731220831012727542639628984101788862199591237806493805996059161201835253203\\\n        204357442043212398495525692960904672132359565047969002327766123188917268873022220728326927\\\n        266813579456518458545345939557868848624450974456390610446369728959726525392113471132021539\\\n        038960803550352390128253151270734177749632737865390247648212171456318006032507634424453843\\\n        795159031314496937836591202252458892414236797451738560115150573320872948069964155298984838\\\n        456270978739037104719669912968807593222214861520588395175617611807975267322946381339673265\\\n        479787948188151606275111200784895864164305724683464061829109671306661764726602634895903888\\\n        287506327660181397735839535481997625450956961420572462126703944263526095290954835871182404\\\n        868513321447417245068813964246287015709186652991049553947407472630595976266674750290084010\\\n        397575525528176465754260767775733418629588880876176812207672741703984898153224615968196909\\\n        775917982890995046346113085550279268258183711136206964350043642244181512435164664671221839\\\n        6370838653686792137638621224928\",\n        \"0x0.00013794d52b8b1e96ced9de16a585696e655c080cbd5da8030eef302763f4138b28d7261786b8ff50bc6\\\n        9d0a5f06f20dad7ee2a65fae9caeeaee187ea820eae6fd4c8a673a92def1c9a165c1aeec8807ddb464eac6f550\\\n        6dbe6d6e3a21a035c4472d414f4887b05775ede2ad98b9b380b663c0929394c811648792ef20f0756b6bad50de\\\n        099fda3dd792ae5616df8837945c3cb4cd833fb9bf0db07243887c0a8fedba7030c428024be8572bca9398f563\\\n        b2a661574fd7faf130ac3d404dbe94b7e0ca06f440962616e1879d4f15895a10229f04969c26dbb9a1b733f734\\\n        fd2be1c88c7b20af178cd1d3fa116fba33a435b040155b5f5f28f0668b798810c2acb1faf0581e46cc71e9b07f\\\n        c9e4ebcd8a96a7d7d318d649e4468baa2ce2cdf9b1adf74f6a6b8b95a3eed5991934327ddfeb243e80db0c230e\\\n        d593df31dce1201e64430a27d39e6760dcf2086c1cb86bfb4e9211f18940b72d1a492a5b9109c0fdf4f5fa9fce\\\n        9e0ec199756ee5f8e69ba7ded6b7507facbc46df62adaa4546b3113a80e7ea40bab782194bfd006099f6a79bb8\\\n        19aad950497cae351fdc370756b86b3188e5c2cf71ed56fdb3683c9cc38facff80b0f2076d0f3b3a8605ca24d2\\\n        c8b6301601e23b50ea0940f7ba05f92ddd4a644cca6e420d6bfcd06caab9c695ba67b857bc57e1000b5935d0a8\\\n        79821217280#3966\",\n    );\n    // - rm == Nearest && shift == 0 first time in div_float_significands_general\n    test(\n        \"3.494003589335061592114850452482839587826456952956376068177291318828682713177358264760784\\\n        874304744009907216335963217912223351596098015455390432300579562836209635380394751634810606\\\n        195414389573610568068623776330707730813932586805062287543490729241818555718410383777926489\\\n        343323917900958772688451527795643412381235039158654803215405274640835172391547486080681691\\\n        827169629800140882523056966137099117587677259077996268577162491409610597231997851472454718\\\n        312803304389117924206548413988545367622912505139619073824279361037770537659001099972259551\\\n        367613373821227769095845567435994753397767332318253172120529133505790353120177308303588487\\\n        770407205738279213609665027613843515660027068482463985188375646552261141849026408186728824\\\n        80307838589616979262426550353243006148083216398932181e-12\",\n        \"0x3.d7797e014d587584d7875beed50257a2555726437bf03fdebac1110cae2c4b64f09f9a338bf2ca8b1fcf5\\\n        e0128d7f387a40893706e25c04e65fdd316e3fc348d2478632d632bae209325b6c681dde52405cd7f8d9707d7f\\\n        5d6de0abb73e130c41c21c4537ce41381fc43788187dab4fa280fa46503f1890d663ca441f49a6a7e2b712e710\\\n        4c826535fdf1c8ae0282d162e3d128a982e44f67c6104624863e7f3c2c60833df521e5bab88feddd4843e4b50b\\\n        81ba442bc612787ad38f640412f6cff81df9793590dfa6a0debdd7f2f6de7a089fc50d597d700dbeeecfc9d795\\\n        ceb9a69d05db5c520717ddd7e73fabaea4e2cb06b1e1874b8b541dfca2083cb277e4d1bbefa48c0a427afea0a5\\\n        87cd5085c2ba28c1cad42a97be72844e851abf698ac844915e9f5ac4af406a2c354aa055f3c0994b7932d1bdb7\\\n        b4999768f776148E-10#2560\",\n        \"8.388557903692744678886673027706512178020882171440574341138664910770681048759242342335520\\\n        689291884051853125391850946672822384185374426629671262437149651332606541726962233658521936\\\n        440197380293004778812876511148916284206096731251130678261803308370362817534297504354768207\\\n        175302739282372189357904919163400327254111204148827422042723518774290057028465296755126014\\\n        371014512774422430414368313070504306047237723842986944935010614200247398223867859750512432\\\n        528263508555538801970472032683504663202558316239308702078808690323956381650112536926354687\\\n        819619269837340011822483859668579241157516055938780563664184620140501025776680716962470155\\\n        2e-35\",\n        \"0x6.f80c88bef08546fc8a21f0f2152ee0612eebad2635acbe0d49ce7179b387d0719cd657923976ec2796026\\\n        5e330a5e71c0cd8417c2cf919556130f9b353cdf2435349f846c895ede372648bccd9c217f1bb7c3e4197c1806\\\n        c4744c8a05ddf4f67946a4972f056d84028e7023d956a95b2ff067c093002267f7015fecb9ca5ed8f58dde48d7\\\n        4510e965bfa6478370f4e71e5a240dabdd9a4d6e000d4af93eea8510c6c4e095290bce062925fd9a7245caff37\\\n        8b7be01d3b94b56154cbeb98c26f78338a98e416fa9acc3bd12c4953b058efdcdbe56335f952208a15166babaa\\\n        698da808f96df97655d3f5cdb4768e6370755a01515d4ad54f625432fc742e9121b7cce4fdb08E-29#2088\",\n        \"41652017300815899948547.94831484736938823572318695739742204735159366375620848030675947597\\\n        937407214848121136435440017047965685656179645007771422864559798518659544278806178160023554\\\n        020245599674536568425190916908552958650848910192845046055088066614557330847090320384899468\\\n        575304634050066348271499359839369427201019441174516439045175255034723132436872248790761539\\\n        506937527488424041602486298663492699846695028977559705152038731125314966620233281505474337\\\n        677248672173837029868825260085661764008715204976773612281854954844288452423998027475082981\\\n        779489389492756600188312999400831430516184077432877044587246391185262444911853744883006186\\\n        684049728461939709785134255700251964580618924591175050653894151676243677123400686218961075\\\n        24208104943935667403367286485079704207117845193523456\",\n        \"0x8d1f5db9d3f145a7603.f2c4c307c343da5b63ef331aa97f5e951921921a937336258bc4ab65fdf9d715d36\\\n        ef6755e61dd29859283e35c618271ec076a196c3ddb06ce536bafe52ad10a521ebfdcda2a3839fce6eadd33d87\\\n        eba1d25c5eacfa66f0af4f1ce568be4792717319611eb807fe7fc0d855f2cf1b099f908a269208b3ee36d33e71\\\n        3912e0557515bf16566f8cc4c8c45fd6bb2ced1b3d3f27c9b272c6e5dfaacdd66335f658951d70cd7b3190aac8\\\n        b90d7e564b5c0ac68a04f4681a552c50de11c466e3ac1230d426fdc851e7d5705e73d7ad30a82c2febb82c46b4\\\n        93762b8d7c80e514c1fe29a64d4189fc176b72bb816f1223676b93d38dc33a2fd578eaf5fa512468b21e723d6c\\\n        d5595dac5bfd84c94e4826fc5b9aff74dec22c3cb43d7970a1359eb2642295a920a70da20a166db400602f0f4f\\\n        2aee9255f2251c#2560\",\n    );\n    // - !round_helper_2 in div_float_significands_general\n    test(\n        \"3.999999999999999999999999999999999999999999999999999999999999999999999999999447285212473\\\n        955543975273480780774427448575976676077991358482977909210124597604668289823519777773553500\\\n        1249731874464215297923136674027554116062077582682832144200801849365234375\",\n        \"0x3.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000000000000000#2090\",\n        \"3.944304526105059027058642826413931148366032175545115023851394653320312500000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000038180485e-31\",\n        \"0x8.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000001ffffffeE-26#2567\",\n        \"10141204801825835211973625643007.99999999999999999999999999999999999999999999859870153567\\\n        518292907627041671008386871973805812348422824293171611020891731413939851336181163787841796\\\n        874999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        99999999999999999999999999999999999999999999999018341217\",\n        \"0x7fffffffffffffffffffffffff.fffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffe0000002#2567\",\n    );\n}\n\n#[test]\nfn test_div_prec() {\n    let test = |s, s_hex, t, t_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (quotient, o) = x.clone().div_prec(y.clone(), prec);\n        assert!(quotient.is_valid());\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n        assert_eq!(o, o_out);\n\n        let (quotient_alt, o_alt) = x.clone().div_prec_val_ref(&y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = x.div_prec_ref_val(y.clone(), prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = x.div_prec_ref_ref(&y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_prec_assign(y.clone(), prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_prec_assign_ref(&y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = div_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(o_alt, o);\n\n        let (rug_quotient, rug_o) = rug_div_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_quotient)),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", 1, \"0.008\", \"0x0.02#1\", Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"-0.008\",\n        \"-0x0.02#1\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        \"-0.00813\",\n        \"-0x0.0215#10\",\n        Less,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        \"0.5\",\n        \"0x0.8#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n\n    // - rm == Nearest && overflow in div_float_significands_long_by_short\n    test(\n        \"5.8208294e-27\",\n        \"0x1.cd2c72E-22#24\",\n        \"5.322295e17\",\n        \"0x7.62dbe8E+14#24\",\n        3,\n        \"1.1e-44\",\n        \"0x4.0E-37#3\",\n        Greater,\n    );\n    // - diff < 0 in div_float_significands_long_by_short\n    // - sticky_bit == 0 && diff < 0 && i < abs_diff in div_float_significands_long_by_short\n    // - xs[i] != 0 first time in div_float_significands_long_by_short\n    test(\n        \"2.4914040842493675536005152793625253098043524808533216867315977e-8\",\n        \"0x6.b014710df6d8d0fb1901206ed24e1e002b4411ac77d2348fd2E-7#202\",\n        \"0.38945825655685\",\n        \"0x0.63b3894b11a0#45\",\n        74,\n        \"6.3971017234954763411416e-8\",\n        \"0x1.12c0e0961c12c850368E-6#74\",\n        Less,\n    );\n    // - xs[i] == 0 first time in div_float_significands_long_by_short\n    test(\n        \"5.94670436124321717863912904768573447358\",\n        \"0x5.f25b378e852b0522e85279dd6e9b5e20#129\",\n        \"5.93e6\",\n        \"0x5.a8E+5#9\",\n        5,\n        \"1.0e-6\",\n        \"0x0.000011#5\",\n        Greater,\n    );\n\n    // - qqsize <= u_size in div_float_significands_general\n    // - qqsize <= u_size && !extra_bit in div_float_significands_general\n    // - ds_len == 1 in limbs_div_helper\n    // - vsize > qsize in div_float_significands_general\n    // - inex != 0 in div_float_significands_general\n    // - rm == Nearest third time in div_float_significands_general\n    // - sticky_3 <= 1 in div_float_significands_general\n    // - qh == 0 in div_float_significands_general first time\n    // - !qh2 first time in div_float_significands_general\n    // - cmp_s_r != Equal in div_float_significands_general\n    // - cmp_s_r <= Equal first time in div_float_significands_general\n    test(\n        \"4.171457951045116318706366624151444947334895358793933e-7\",\n        \"0x6.ffa0a6f6450242ee750c35f12c7b17a438109694bfE-6#171\",\n        \"6.7041531299542248604361e-9\",\n        \"0x1.ccb4b589b3974d3c8a8E-7#75\",\n        63,\n        \"62.2219968754442595\",\n        \"0x3e.38d4c987d8e7580#63\",\n        Greater,\n    );\n    // - cmp_s_r > Equal first time in div_float_significands_general\n    // - !qh2 second time in div_float_significands_general\n    // - low_u == 0 second time in div_float_significands_general\n    // - cmp_s_r != Equal || low_u == 0 in div_float_significands_general\n    // - cmp_s_r <= Equal second time in div_float_significands_general\n    // - sticky_3 != 1 && round_bit == 0 in div_float_significands_general\n    // - cmp_s_r != Equal || shift != 0 in div_float_significands_general\n    // - rm == Nearest || ((rm == Ceiling || rm == Up) && inex != 0) in\n    //   div_float_significands_general\n    // - goto_truncate_check_qh || goto_sub_1_ulp || goto_sub_1_ulp || goto_sub_2_ulp in\n    //   div_float_significands_general\n    // - !goto_sub_2_ulp in div_float_significands_general\n    // - !goto_sub_2_ulp && !goto_sub_1_ulp in div_float_significands_general\n    // - qh == 0 in div_float_significands_general second time\n    test(\n        \"3.7563361266e88\",\n        \"0x4.b87f4dfa0E+73#36\",\n        \"6.769173652614128677797571270436826716e-13\",\n        \"0xb.e8909656207637d3379c02628519c4E-11#123\",\n        63,\n        \"5.549179736559369991e100\",\n        \"0x6.57b76abe8193e56E+83#63\",\n        Greater,\n    );\n    // - sticky_3 > 1 in div_float_significands_general\n    test(\n        \"6.4231308808e37\",\n        \"0x3.05280069E+31#34\",\n        \"737445296117739183341894639.41419934820825930816963962148939959402654898\",\n        \"0x262001d9b6493f3dffcfbef.6a08f7ee9438af0b7e2168670bbe153c76748#236\",\n        61,\n        \"87099760682.70268959\",\n        \"0x14478ce02a.b3e377#61\",\n        Greater,\n    );\n    // - cmp_s_r > Equal second time in div_float_significands_general\n    // - rm == Nearest fourth time in div_float_significands_general\n    // - rm == Nearest fourth time && shift == 1 in div_float_significands_general\n    // - rm == Nearest fourth time && shift == 1 && round_bit == 0 in div_float_significands_general\n    // - goto_sub_2_ulp in div_float_significands_general\n    // - goto_sub_2_ulp || goto_sub_1_ulp in div_float_significands_general\n    test(\n        \"6.4231308808e37\",\n        \"0x3.05280069E+31#34\",\n        \"737445296117739183341894639.41419934820825930816963962148939959402654898\",\n        \"0x262001d9b6493f3dffcfbef.6a08f7ee9438af0b7e2168670bbe153c76748#236\",\n        63,\n        \"87099760682.70268956\",\n        \"0x14478ce02a.b3e3768#63\",\n        Less,\n    );\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky != 0 && carry\n    //   first time in div_float_significands_general\n    test(\n        \"0.00002882366272258\",\n        \"0x0.0001e394b0518e#40\",\n        \"4.407913996892399269446698943482826e-28\",\n        \"0x2.2ec4fccc4a5e21c3fa6da2c36120E-23#113\",\n        1,\n        \"8.0e22\",\n        \"0x1.0E+19#1\",\n        Greater,\n    );\n    // - qqsize <= u_size && extra_bit in div_float_significands_general\n    test(\n        \"13863336.632654341786855779405528442674244\",\n        \"0xd389a8.a1f5a28ba59ea1aca395f84bcc2#131\",\n        \"88.32972592752556369746097031876493672699524930031683012093294198918\",\n        \"0x58.5468eb1b5d957d68d5c161060f2abd3d11568e57fb44ace5b9530c#222\",\n        49,\n        \"156949.8431822285\",\n        \"0x26515.d7daca60#49\",\n        Greater,\n    );\n    // - sticky_3 != 1 && round_bit != 0 in div_float_significands_general\n    test(\n        \"2.60106\",\n        \"0x2.99df#18\",\n        \"1.12640651293023472114636230356467597616119208733434416176044102440877312604351521285e-35\",\n        \"0xe.f8f67659254f23c6296e8bd68107bb0d6543b0d65b1f5b85639b43d42fafe22d0850E-30#273\",\n        62,\n        \"2.309165412400307267e35\",\n        \"0x2.c7910820f8e1a98E+29#62\",\n        Less,\n    );\n    // - sticky_3 == 1 in div_float_significands_general\n    test(\n        \"5.3925833329420346441e-59\",\n        \"0x5.6a7cd168af6b5224E-49#65\",\n        \"7.055235440683529923035882801220195059780252442336634700998228376328e-29\",\n        \"0x5.96f8c4a5671f264deaaafa2151d5a576774640994697357cb67388aE-24#222\",\n        126,\n        \"7.6433782802570609426763368452677453109e-31\",\n        \"0xf.80ab3d3f6f9720a3e3d6bc0dd473a20E-26#126\",\n        Greater,\n    );\n    // - low_u != 0 second time in div_float_significands_general\n    // - l >= k in div_float_significands_general\n    // - cy == 0 first time in div_float_significands_general\n    // - in sub_helper\n    // - len != 0 in sub_helper\n    // - !extra in sub_helper\n    test(\n        \"7.326919700506453074257659445909468362437490080995085670582700901565e-8\",\n        \"0x1.3ab0558546a1bb0ffb3951411ea17cd193a72ecfb10c90503c09df8E-6#220\",\n        \"6.204773818244710788233721e40\",\n        \"0xb.65787b1d85852bbdaff0E+33#81\",\n        62,\n        \"1.1808520205784374405e-48\",\n        \"0x1.b9cf274b9b9758d8E-40#62\",\n        Greater,\n    );\n    // - extra in sub_helper\n    test(\n        \"8175446.9642736466252057884969624115178724187752436027351898906495229305213\",\n        \"0x7cbf56.f6daa340a6612207973c17246d0fbeab7366f17c873b36e8a7c5e130#244\",\n        \"2.2364028106870166695e31\",\n        \"0x1.1a461277f5c6a045E+26#65\",\n        62,\n        \"3.655623631488002044e-25\",\n        \"0x7.122d595c6ad6278E-21#62\",\n        Greater,\n    );\n    // - rm == Nearest fourth time && shift != 1 in div_float_significands_general\n    test(\n        \"1.274876025e31\",\n        \"0xa.0e9775E+25#28\",\n        \"7.104011072486714881105976022274735719942619445087760266603169705559e-82\",\n        \"0x5.6412fa517e8e5c9e2826903dbe9c6b4f020acbf4d07a5f83b6e4008E-68#222\",\n        126,\n        \"1.79458620199896394199805694868744557485e112\",\n        \"0x1.dd946a676df629632baf4759d5af1090E+93#126\",\n        Greater,\n    );\n    // - l < k in div_float_significands_general\n    // - cy == 0 second time in div_float_significands_general\n    test(\n        \"1312304952.868834018993672867833994901273914152677\",\n        \"0x4e382f38.de6be8013ae5b9256e2e3d80a6484417#159\",\n        \"805222139786632223922.788562923013680863\",\n        \"0x2ba6b3b5e2de25dcb2.c9df427d2e92a42#130\",\n        61,\n        \"1.629742760446910473e-12\",\n        \"0x1.cabb579ba24a1c8E-10#61\",\n        Greater,\n    );\n    // - qh != 0 in div_float_significands_general first time\n    // - qh != 0 in div_float_significands_general second time\n    test(\n        \"4.77e-7\",\n        \"0x8.00E-6#9\",\n        \"7.27595761418342590332031250000000280259692864963414184745916657983226252757951518e-12\",\n        \"0x8.000000000000000000000000000fffffffffffffffffffffffffffffffc00000000E-10#272\",\n        12,\n        \"6.554e4\",\n        \"0x1.000E+4#12\",\n        Greater,\n    );\n    // - cmp_s_r == Equal in div_float_significands_general\n    // - u_size < qqsize in div_float_significands_general\n    // - !slice_test_zero in div_float_significands_general\n    test(\n        \"7.37e19\",\n        \"0x3.ffE+16#10\",\n        \"5192296858534827628530496329220096.00001525877451\",\n        \"0x10000000000000000000000000000.0000fffff000#160\",\n        19,\n        \"1.419698e-14\",\n        \"0x3.ff000E-12#19\",\n        Greater,\n    );\n    // - cy != 0 first time in div_float_significands_general\n    test(\n        \"68094456598293603327533905548505297620013066911.08376291606058693773517767794501897994582\\\n        258970805389024907002851553537297142201729190070813276436614829387252399053496817432401142\\\n        072590738640749961499805778301047693438889653237932045230908598957544293121509337746443019\\\n        818113697275492083034559948210251757918035033203320082922052180871824896122583688257790633\\\n        347767288424884057738898369318200284711885269916578380577251435556820233836251778387280672\\\n        557877138589743092466532437097578789439010809222705729003762084164876928991111619216295374\\\n        407477624059748769343096515734766384609704158183422827373811211581562563854555563208285030\\\n        789640954030131590715773225619459109078415421551825383051156907165239504581969296580217917\\\n        201401107075438836986951972027346920300296173028752019760961905082742144822764332949493643\\\n        236343403045805151576437841818592689216294090992083144539119316847195395330209116021520674\\\n        687172083129681053947608634984318972146599189025048336884553676307718881472973047561666876\\\n        170703037518590793048762200560314576630872589716790447601932356569152269838665699058277016\\\n        66840662018065630567707390037462589298017636098402605937122\",\n        \"0xbed7606a24f1082b01518fdb3fb83b7bd6aaa9f.15717c89190a577b04eeec86844b1c5da7ec1d515c98354\\\n        34d7eaf573076ade2dd2a181b60b144c489be5eadf10a8fa23688bb3d5dc411a80de60bf15d00f4e2bb3d1dd9a\\\n        05d37673fc56cf152b3e89f3955fd67353655a855872202dd9bb5939503124c7c8c1c2e93073284ac47ffc59ea\\\n        a0e2d8533a243325fc33e1795ea157a7a42aac695237acf96951da79f695a7ba51387281685f9dafc3987d0cd5\\\n        f393a28b74f7077fac3ca1d127e47df74353b51a5191ef44d9d17d76e82b13992c6d3cb5330e49f88047554a32\\\n        6085af468cf06e8d9d64da3bef6a9dcd50d9c3d50c03f20851ad827d200fd778bb6ffade66b04462f28dd87893\\\n        32e49807a56a3d251a3123c64131caa8c495f18271f1511c3ebb467c8e07f5a65ce58538f1b5a0a5cffb750f2d\\\n        2aadcba0995b2bc3d8ec2c295ded7fa6a05959ac7560ab0a8d43761ff672a2823d42f9a3274e5d9f621920a078\\\n        13bf0f700cfd42309086f1a2a594e81d2cc56780a2d2146487d5c84e4a45ea287d5082ebbc00d963dfc85328fe\\\n        fe6406f3583a1d25b20043620066c12999c2438ae661a9ce3a7577bc39adbb7d9c6b2b95f70ab93d453deab5ba\\\n        879c49217ce044fb8c99aafeab2a3c2d7b81d1420f50f3124#3778\",\n        \"5089003.986901636664002211687103226682676013278365930635943365557217778575140755071304051\\\n        262677914765136974076241170290188547560394627827342683941547868265780205495768503547504471\\\n        809839828485098007901365847412395780099805986364986150288103155890838726927248245864748917\\\n        545776909957932766621125809519317578017645670025405880924769796697930801127403727804288556\\\n        494641308619101409216398256844236435992132716137153671232504127486179270643290623882858426\\\n        225419756589684747143027545016939069261808018044193898155688966291933573563069322732013621\\\n        2807285459308838582521108293701\",\n        \"0x4da6eb.fca595edd73c4fe606a4af64c155ce5a5a06c66381dac0cd6a8b987a7c57162437fab8f807ce8aab\\\n        ccbcb3f448d402e4caa52f0641d93df28bfaf5e58a6f16f39adc87b5a1dd5398bb2bbcc7d994a0201b397c4a74\\\n        f97fca0b917ba0bd07b9ce9d25bb5feb2db2ede12841338d892fca759aafb7971202ee42d8f016c781218a37c3\\\n        bc2cd12d5917a00cf157abd9f8e9ca4f5b16b4359dfe287ef904d8db4c7df271a3b90126ef56586929a4a65813\\\n        f3467787c4829222d7fb9cf2e133be397a765f905e56ae783ac80f559db68cd58a90a22f1ab1af1d4dcd872ca6\\\n        981a9ecca8670be84795798bfc4#1890\",\n        63,\n        \"1.3380704116868237389e40\",\n        \"0x2.75285dfa208ffd00E+33#63\",\n        Greater,\n    );\n    // - cy != 0 second time in div_float_significands_general\n    test(\n        \"5491.549122096322909336636529538856618128292880125595066488677776051102905046366315843918\\\n        913993420423080685689765224843845532100106275652902608353545283642619588636389226823484210\\\n        861629061239611056329749023362152227886065897973662117489519345928983306276603012226918628\\\n        850786900692391091591113247385622873420889775685843449415444179626888676565806730164439066\\\n        916153918074448979830160313236976037323911844599167437480714277238521850834771260598243342\\\n        817521177189023\",\n        \"0x1573.8c93440537c5819a8b2239f718e330a799971b8d83971158cdd2e59617a3347f7b4fb69cbaf9e5ff87\\\n        522a9c5cda06c869912d81fca8e9ef0dbe259efb7b9b0a54a58449a185302363331ad127c4e9256f242984dbc8\\\n        bcbea4216ff87b05bc4790144521cef5ba2b27261d31a7b650ec83e23fe89b1b2f569c96581f78da0e0d4554f3\\\n        0f2ed4731ea3d9bfda8cb2254fa514c04681a9298a927fc2abb2b920ac830f6d5ceb4ccb7f627c3b8895ff1804\\\n        8c7517748878fce7a0839b14beb12#1536\",\n        \"1.509673347429890062512836190652173917347254081193788057095565296339169922295435269039375\\\n        472698941288863827397739888112708775552600102260052264376059462711206952889795049703596839\\\n        232956098476826545419162632064629313103364676417718336633177039699753340705596727615974068\\\n        628610723831801827765947524025118267152138672831243078933782856373566584766564765627600767\\\n        096322262179300330204832084508935397859168676086969433875110241760537834330483926543135245\\\n        217039771663537327658657093592229424143926522163858843150047672118222822507365351980019570\\\n        622407757023485804508837072933740850465658604e-7\",\n        \"0x2.88665707e5f5634041c4267ef6487dd6141defd41a214073fe6520a7bdcf0c026eeac8a1a76a6f7c7e2c0\\\n        73cf8d31cab2cfe226fc73bc3a686dc489877a18a6e4ecfc6970268300003802d27bf6e18d0623eb7b117d7342\\\n        0a73839c03f41c3d09bb282d8dedfe2fb5675ee89cf010503f7f0b26eede0bb1c37b08c5a55d42499a3d9a9175\\\n        c05b5b8d873a476906f4a54340f4892951e2c8ef3a29f769e86cfab6965b4f110f218061a287f47ff1b3c217cc\\\n        df00c65594ce0048e5bac7ab91da9e0ecbd44b6c0440d575c7f294899ff21e307008ade7d2fba1c820083431d2\\\n        3a0f94cf78f5937afde262a9f2aa86d36c391c0E-6#1935\",\n        189,\n        \"36375744007.4390200041449619204768129898564194090547870908\",\n        \"0x87829ce07.70639d7017a741d4c383ed19081084c4464eff0#189\",\n        Less,\n    );\n    // - qh2 first time in div_float_significands_general\n    // - qh2 second time in div_float_significands_general\n    test(\n        \"17592186044415.99999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999\",\n        \"0xfffffffffff.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe#619\",\n        \"511.9999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999858969189385560189369588899908301051658131815921691396545986807150339147015462\\\n        016914098983479659782731543057846003175884332840513803623318182318832820724717407320371823\\\n        6294395745915856\",\n        \"0x1ff.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000#1539\",\n        26,\n        \"3.4359738e10\",\n        \"0x8.000000E+8#26\",\n        Greater,\n    );\n    // - u_size >= qqsize in div_float_significands_general\n    // - in cmp_helper\n    // - xs_len >= ys_len in cmp_helper\n    // - cmp == Equal && ys_len != 0 in cmp_helper\n    // - extra first time in cmp_helper\n    // - xs[k + ys_len] == bb in cmp_helper\n    // - xs[k + ys_len] < bb in cmp_helper\n    // - cmp != Equal || k == 0 in cmp_helper first time\n    // - cmp != Equal || bb == 0 in cmp_helper\n    test(\n        \"5070602400912917605986812821504.000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000072282982868771681166004491412846722101397844122267684138688870467552820474559090102317\\\n        447234871538375909335604136421707865093288809202542467085297095776399695369977155046440218\\\n        72699461509694558652328992590065121835881232\",\n        \"0x40000000000000000000000000.000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffe#2230\",\n        \"0.031250000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000519145120156837503\\\n        646385401176147001734918579024397648372858359187739423120395387040659114766108267370765089\\\n        588804048262656404437892026790384389944710053355139410493357036837062723311890087295336535\\\n        224886414974037589635945157614552911737025968561447428534517548726620712055254368601400677\\\n        671297010734467257376219342434577391120913670811726006378408285341591896262197466018812208\\\n        707818364202903001714252499366447760377357676976645014748597726032434627346717442135450023\\\n        055574853304203092750885653943947474937587714924946440549453028916954237373614371956358356\\\n        475429001114655812373726770920126725739237754419551706215855979284224297710219012046069209\\\n        939692719820661068941772746188111229015697420074924121315943073728508778962547216389153434\\\n        262911373438798885794691058258008791084816770299900324276184865853804713586768050489411191\\\n        664317769877562965352444256815704956578248231483831995594631665817366125592817899193355951\\\n        118530268969738737015352029171836561799730662727849622621896971327136981718066405555588128\\\n        499837506069085441884105298697942808825809875065414280125486286978200226472477679074148608\\\n        959361116404570999151605839083899731368423273690135641440237909114194036012915602847402345\\\n        640200131464172673937558930023395763819989040966673763510370208058366269042896065620543694\\\n        889060883071378600260819500918049255496885447711748266825241404608194240474286320016971013\\\n        505365433166482975272851975538460641506474893740018353758689194264153921667729046743564069\\\n        253579744\",\n        \"0x0.0800000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffe000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        003fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01fffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffc000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000#6892\",\n        36,\n        \"1.62259276829e32\",\n        \"0x8.00000000E+26#36\",\n        Less,\n    );\n    // - xs_len < ys_len in cmp_helper\n    // - cmp == Equal && xs_len != 0 in cmp_helper\n    // - extra second time in cmp_helper\n    // - xs[xs_len] == bb in cmp_helper\n    // - xs[xs_len] < bb in cmp_helper\n    // - cmp != Equal || k == 0 in cmp_helper second time\n    // - cmp != Equal || !extra || ys[0] & 1 == 0 in cmp_helper\n    test(\n        \"0.000488281249999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999963663982709420587425167733195\\\n        304372898231735836009052811521034277852253692510619649191102380354831309742044158555819900\\\n        182303288606739679841769892362177959648480394191365684359543454337339931688383011417980993\\\n        719495486975941054744491093403718104080315380258293738327998799327152912644577698156976186\\\n        55095367486514165923991079335821758615173478\",\n        \"0x0.001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000000000000000000000000000000000000#2815\",\n        \"2.168404344971008868014905601739883422851562499999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        99999999999997e-19\",\n        \"0x3.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffcE-16#1232\",\n        36,\n        \"2.2517998137e15\",\n        \"0x8.00000000E+12#36\",\n        Less,\n    );\n    // - !extra first time in cmp_helper\n    // - xs[k + ys_len] > bb in cmp_helper\n    test(\n        \"187072209578355573530071658587684226515959365500928.0000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000001101803207893244326789943155\\\n        018460305099242595345476423646015479873854823483513049621916060417380926502108264599637960\\\n        009028188448912132272078404411433183433802785019851743390002334059444086579631362687278982\\\n        092055516132867633211303823870165864587972287857634502648284831738260191440051776077031899\\\n        598142362977237015956245760229588121897813474421614887403259665611637741356303541231148645\\\n        802831472359942877820272387728004709359817918832294062785037876007514227493405888433177689\\\n        680714430224698456312336396309714864041562196381794611694655680402546092635353483367808913\\\n        752362293005799560093641139943406727218702402175348117018858577588516940143086501070121082\\\n        790860175377027\",\n        \"0x800000000000000000000000000000000000000000.00000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000003ffffffff80000000000000000000000000000000000000000001fffffffffffffffffffffffffffff\\\n        0000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000#3331\",\n        \"4.814824860968089632639944856462318296345254120538470488099846988916397094726562500000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000043039187809582461740\\\n        237762479156173200033015160616639237674924575702164607097773158539128576763982320696088303\\\n        832038609517565761168327844792993520257347193172468143718482303439757405926333196250133060\\\n        288550223275967750822594171887174682861815132430042665799184768861200315909562005634908495\\\n        040482237984846081838841677107482858326355102804446586581213177924458440804958481615550624\\\n        777545362515887646344379566287174797564232997148384542907314841464505589746930096972150685\\\n        525970118605412491959870803444763295822500525548365368442918966063445202883350639365511116\\\n        639832781262353439062659724470167290957426899576854017375938862005470860735521697212635101\\\n        685662094078329428036605435693999242602513069760981920534839908438815346198461935722540210\\\n        326793005024577932413554325700374174982252819095920682430496242093539639719648496398673988\\\n        294181130946788869550483877630340388986962249045975498873325109426508397715202174256327738\\\n        115206226749346851411911082798138490772273613411588181424713572149102614119711767787285638\\\n        524703608044386935250150211880470005994669065127142264588906081548898113686963839840837625\\\n        878160925150811347647212869111896217042292003837889935947741223166647027572900535517651639\\\n        207495691251723099461646574220946216274869671971300965751857652439720077434006455131311793\\\n        590683604336422775710475248004038566299454724867611543407224462775327725726271022150051488\\\n        962306463251821198471593641698105320214416610382784775624895123451428368367748899615073448\\\n        540841180568439251922577807930504713787460146305777655304325240206357947725816143068424676\\\n        946204398859120790721921646336338115096532038905903264996890888572731012019093458139272007\\\n        836293712752099827742569952571629995231554586253215504385643489009213919397283063609836863\\\n        267686636840153036916740518806971074030344720455273318700117606897827915624482324081001558\\\n        580105852766963764590581776038099624170109326877344468594726954445140050830134037782433855\\\n        587285682701452954803937838579540908490074176523981670683042482665018271091095010951223690\\\n        5278182153271165591237853e-35\",\n        \"0x4.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000003fffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000007ffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffc000000000000000000000000000000000\\\n        0000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffc00000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00E-29#7548\",\n        94,\n        \"3.8853377844514581418389238136e84\",\n        \"0x2.00000000000000000000000E+70#94\",\n        Greater,\n    );\n    // - cmp != Equal || ys_len == 0 in cmp_helper\n    // - cmp == Equal && k != 0 in cmp_helper first time\n    // - xs[k] > bb in cmp_helper\n    test(\n        \"536870912.0\",\n        \"0x20000000.000000000000000000#100\",\n        \"618970019642690137449562112.000000000000000000000000413590306276513837413283570606\",\n        \"0x20000000000000000000000.000000000000000000007fffffffffffffff800000000#267\",\n        7,\n        \"8.7e-19\",\n        \"0x1.00E-15#7\",\n        Greater,\n    );\n    // - xs[k] == bb in cmp_helper\n    test(\n        \"5.82076609134674072265625e-11\",\n        \"0x4.0000000000000000000000000000000000000000000000000000000000E-9#234\",\n        \"8192.000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000073621518290228626754368\\\n        661771449651176491350325096363488672030344706104289026372412636851722245811280577862962401\\\n        765246827402220719444460351741455902885984901380506690583579618039994586998414375011572379\\\n        779182346403549244684325279848137048396135313055840892271543868080199241336353523751067084\\\n        487605126715192128136637640780333317069117147264850291384068338053712809423009097565764707\\\n        945202720557662560964127631897773337487421543251587594809897712933202207298421785498016072\\\n        254449856519027840276532392122510707729637176938094908140620695527942817590009777550509094\\\n        454152645378859315289504747645957548190040101946887130819745338279179159631457317778420898\\\n        470611527072781043747280163229876864141766629003055536247648501825111792890761407396390374\\\n        874897179718966769929553634685717455680003107614184209129041106624130501684449541327017766\\\n        6757753582718\",\n        \"0x2000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffe00000000000000000000000000000000000000000fffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc\\\n        #3924\",\n        15,\n        \"7.1054e-15\",\n        \"0x2.0000E-12#15\",\n        Greater,\n    );\n    // - !extra second time in cmp_helper\n    // - xs[xs_len] > bb in cmp_helper\n    test(\n        \"8388608.000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000684828866957428698438476408479242192022929376940887598\\\n        259032840130007525904001877047531991911904326913906546098688715629243382676607047027876451\\\n        719639473400356638537379034111884955325977768684942789942877048547849906527713086446752791\\\n        858723447410673711365769970369878574737183686864932741554880327679842509372652502021311890\\\n        709142794655721430723387345276067736929449744072002738257252158918229576617779883525921585\\\n        596123442220897772976221689427398725884900122239984724340651124172908938910231534143853336\\\n        754402\",\n        \"0x800000.00000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000000000000000000000000000007ffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc000000000000000\\\n        0000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000#4496\",\n        \"274877906944.0000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000060373564297453652118256309302784011108922184796264095\\\n        964856067554168050454843683714804467407509910692607381159281320687596446281451430072818608\\\n        057863867144256826337394425373143511933737397669081937627812007424941677129312470503091170\\\n        911733627368176008701133101413396404615425187244748480697366133742242352202719895177017100\\\n        690953740117147446309724130962650836546766701719441996132950568128342147049715911045228743\\\n        620410093793320012089795191308289370965558751489023393660780664527210525039278006479120686\\\n        667916583520393051061889574321018782852304715910223159623785353107527307680073164159574897\\\n        425049765870945886337964515155856670447604028696651128918360721209741264488097948768144159\\\n        7005421420614212549\",\n        \"0x4000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffc000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        #3940\",\n        17,\n        \"0.0000305176\",\n        \"0x0.00020000#17\",\n        Greater,\n    );\n    // - rm == Nearest fourth time && shift == 1 && round_bit != 0 in div_float_significands_general\n    test(\n        \"21778071482940061661655974875633165533184.00000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000038725919148493182\\\n        728180306332863518475702191920487908654877629413444163480976859648626822342770145969080575\\\n        425075544675393708363989923503155223180506533504920024360652705227860649920024820627696586\\\n        039669982633650149716545149281467950945053120039758890080803998602993819265261127978876161\\\n        185060505268781766584528622179744118464786493161582046377347178114187510333531866422621209\\\n        846804228328353733454965094209076361330420294172109758000406375110313580574114285388890693\\\n        305920075040658551907160730659163031529176823334039346417685325080367605674100555171634617\\\n        234928876787779313622179077907389499960227122096343446066535190397344011264079006874008414\\\n        382439268898793195608363864632580908988059168802931770976116933654316402639901396184475943\\\n        729788724295947748963417392515678664943418616270097079670860835720917411673092090040881885\\\n        21564006805419921875\",\n        \"0x4000000000000000000000000000000000.0000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000#3999\",\n        \"10384593794440907712397259839635455.99999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999993016492510700454214505644339937412396352916507799605382898196356288572513\\\n        255335843325740991172311658773153798524263030870893776870186113616631478977505034859608131\\\n        351745273180872140851736147478994985324507666557307045519001087646931454316452554197971038\\\n        325854489646439254746059314551440312981763083969256523175727926415817004690047870256478545\\\n        703194379897622730743058132509274625798800775561678711877861189187434830350273902228109246\\\n        439341677189967895547076747086150572427772646706738189826894090172821355170927596420947406\\\n        00086516265683600055\",\n        \"0x20000003fffffffffffffffffffff.fffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc#2748\",\n        63,\n        \"2097151.9843750001164\",\n        \"0x1fffff.fc000000800#63\",\n        Greater,\n    );\n    // - cmp == Equal && k != 0 in cmp_helper second time\n    // - extra third time in cmp_helper\n    // - bb == 0 in cmp_helper\n    // - bb != 0 in cmp_helper\n    test(\n        \"8191.999999999999999999999999999999605569547389494097294135717358606885163396782445488497\\\n        614860534667968750000000000000000000000000000000000000000000000000000000009104419837890877\\\n        372181354144852214156953700603760262322108787027839695294275046757\",\n        \"0x1fff.fffffffffffffffffffffffff800000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000007ffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffff#809\",\n        \"1.13686837721616029739379882812499995e-13\",\n        \"0x1.ffffffffffffffffffffffffffff8E-11#114\",\n        12,\n        \"7.206e16\",\n        \"0x1.000E+14#12\",\n        Less,\n    );\n    // - !extra third time in cmp_helper\n    test(\n        \"1220323748666959369108273.2342529296875\",\n        \"0x10269e20a74472df07b31.3bf8000000000000000000000000000#203\",\n        \"7627023429168496056926.707714\",\n        \"0x19d7636772071e31a5e.b52cc#93\",\n        3,\n        \"1.6e2\",\n        \"0xa.0E+1#3\",\n        Equal,\n    );\n    // - inex == 0 in div_float_significands_general\n    test(\n        \"37825066419214082102958195114240.0\",\n        \"0x1dd6b619c4a053851a451b28100.0#108\",\n        \"35597.514868846018999\",\n        \"0x8b0d.83ce71d761800#66\",\n        41,\n        \"1.0625760410123e27\",\n        \"0x3.6ef13a9ad6E+22#41\",\n        Equal,\n    );\n    // - slice_test_zero in div_float_significands_general\n    test(\n        \"1.7093142438003562047006422345280738002737985244107760125e-18\",\n        \"0x1.f88021f87c2effbffdfffffe1004000fbfdfffc00080000E-15#187\",\n        \"5.216412786622324189132254660659649298902e-23\",\n        \"0x3.f1003ffffffffffffc0000001fffffff8E-19#131\",\n        76,\n        \"32768.0019530653953552246\",\n        \"0x8000.007fff000000000#76\",\n        Equal,\n    );\n    // - vsize >= n in div_float_significands_general\n    test(\n        \"16383.875\",\n        \"0x3fff.e000000000000000000#88\",\n        \"73786413344884785152.0\",\n        \"0x3fffe000000000000.000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000#2354\",\n        1573,\n        \"2.220446049250313080847263336181640625e-16\",\n        \"0x1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000E-13#1573\",\n        Equal,\n    );\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky == 0 in\n    //   div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky == 0 && q0p[0]\n    //   & Limb::power_of_2(shift) == 0 in div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky == 0 && inex <\n    //   0 in div_float_significands_general\n    test(\n        \"3.552659469104e-15\",\n        \"0xf.fff00007f8E-13#41\",\n        \"4.84676140167789653245e-27\",\n        \"0x1.80000000000000000E-22#67\",\n        39,\n        \"732996567124.0\",\n        \"0xaaaa000054.0#39\",\n        Less,\n    );\n    // - xs[k] < bb in cmp_helper\n    test(\n        \"9444732965739290427392.000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000000000000000000000000007\",\n        \"0x2000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000004#832\",\n        \"2.646977960169688559588507814623881131410598754882812500000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000556268464626800345772558179333101016054803995115582957638331854221801108\\\n        703479548963570789753127755141009073606571985185530635329448182789571845492934678567064361\\\n        332708567592792632774560421640775880919059592137166530735473758036612778924544586718232305\\\n        427824501619198614662740023702411729616701208397136180761162254530729075026989491906995358\\\n        575857015870579521868248894534215532446934638248802017349968861414212348741850124926530061\\\n        137882705366115789406521732304520719972162648696165229524120554795461372143924212631388636\\\n        174362506256920084558049677121644286500487074477020716131861235836886832672281595198230113\\\n        567709366546419530594295018834136800596699897605463746431155006086897664830884143672193812\\\n        44610974066e-23\",\n        \"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00000000000000000\\\n        000000000000000000000000E-19#3316\",\n        166,\n        \"356811923176489970264571492362373784095686656.0\",\n        \"0x10000000000000000000000000000000000000.00000#166\",\n        Less,\n    );\n    // - u_size >= n << 1 in div_float_significands_general\n    test(\n        \"128577.8764868580029756801212656877698983158936282661425976800226962111142207941648763580\\\n        988345531602067112079580015968145327129866382559301038263207994838658330066205433266994831\\\n        467312285027812918907079178962008936026981323406687199299541735562087171599287887802035024\\\n        906243692028775515058236407279458918988174303955662670989299201833922393455224960273024665\\\n        835516171507144476172664636956597658975023887814926279578799575403427330090956378386637388\\\n        135713599495925645995132841117427501966959959182813336108896940311309853198603275957130349\\\n        180224933883131003754623341245570205903946496613695364321801198058339260724701640865654036\\\n        186860644657991116300768604961954024465425961935896721280763534922807739569795086883210509\\\n        579889273277174558334960325483739866345331038726073720427318649387253214131422147544043776\\\n        436460480773469181215055043763336182793567894315442629932401507848298532722652018799777250\\\n        015693272603467557015010371191540543654044197350381607085047315086344620959308640376127551\\\n        931466260812673044275557327198781497102634261681647151335962486321030934060949982367829468\\\n        020749656366004839444427964357828448988474386543697497400049219456871357814121030924016175\\\n        400479172517413298974822423000259842805397057515980600295281540360693708678122362364971796\\\n        779616611372222055466670808323170951832437930119313259384578003290031387708344288805368337\\\n        588807333974140623099430569336560667666750522945572113803323880761652974693642791189155133\\\n        946965374070768843306018991682723627881006841722563064115628027286093354777874808024620535\\\n        656673153645820545300742916103648617900434641706211663820400676448026510940215813847245690\\\n        787061247080030343563700831660998005203777247693478841377389920284883123241874488805072645\\\n        154615488002533716177437262647168075186850895612670638062910190731729666226316215350837312\\\n        425251155930035494177805868591779327099854491269372890119982152035832492671125032181675364\\\n        3983068068\",\n        \"0x1f641.e06171567f1fa1ce238d5b2d095d742087c3ea45ea9119d15b04ad4fd22debcddfe61686f85e93d4b\\\n        77b8c6117bfe0d897686b10fb2562ff6e4d3b597d38561e37784dd68d9eefbce8d53e8394cca9a3e2dc4566d1c\\\n        9dc04bea4f3078e8da6ef5461f25f3bde96a287773d9c8276b6c9374c221c96a70582c7441d2e07612a8c3dd03\\\n        e35a43d31a9e2671a63722177907b421a95e476796ca49409bffcc43124eb7f620ccf522ed0e21b1b97a662a4a\\\n        5b35525007c94fe7415d10ce2fc897c6fb779527f47ad96624541900afc16557a726046c3df3e463a8d759e7c7\\\n        feef0e9670534db9d04b9d9ffe0466a19dfc275afe386b4af62dae0d9ed645db8afc44566a1737f4ce512e8a0d\\\n        04938ce2572f4040cf0d01959d07f5d5df2d20e13e12234e2e5c841a48fd2fd2bb90b8def7c213d1e639884238\\\n        3071b76c2f1dc091971382e76e3ca531afb15c870664c6e2640615bd8879fac86f33c0ebf5aab3d0d4b010c955\\\n        1bef7718a83f66989073d65be312959c7c9937aaabe885475695d9dd1902651a5cd5f2d9ce22a6048f450b946f\\\n        042d4f9a2d15ed6a44d25272dce6b428476ab4a30c7d0300bbdf8a8cbae64493c2f3d0ea96dbe0adc923d55fff\\\n        656cc9d6b580f8d0add486b744493d4f9b350e37ff03e161abf2c2fd4893f126eff0a9b7b4f139f5368f126fc3\\\n        52362625255424e59ab7a735c2af91f74edfe3d37697ce869643481c7dc622fd11f6214d54709f5388c25fb8e8\\\n        690a34e8f4636c8a0ca5813927775ec20ea47fd7f0224e27ed9ebff6f101134d49ff8c6dd63ba49afa639a248b\\\n        3f88841d75b76333f69d13436dc569ecefd0683730d63b9249361dc821d6ec48b599171f73d07d2d356ab1b0dc\\\n        9dcc7bcd835d04ecb8ed41b2352145ab7136bd22c3c41e6a588a6760c1a914f23552091fad57262a23ad399e35\\\n        51b0b228b6dfc03c6869855611a71ea2a1b5016273f7eed2871f29979b0d9ba2abb1b7e380f0cf87a751babe1e\\\n        3d654913b9404d39fa3600a7242059cfcb69ccc95cab565fb53487bda573040c9a25205b93635c890bf9a60959\\\n        13cffc5cdc250bd50af4696d0d8d39574875a1cdc764ff65ab0#6302\",\n        \"0.007532733962226776718609740913688407060156761888422741155537371074310369441516668932842\\\n        179178987568947783738784004214845903753330652661093496965654876471036972958909346642328584\\\n        201643545013628367738833205156107907841411376234839693950678432472453643018318413087069746\\\n        828356026984992515666155286293579263416799907808093203442758385289281722930232963476563039\\\n        602580878024432965067810300259817455445278112730792320635207665972350444684469938601305178\\\n        752078424498914971701426156771409553942152089734535539717798744531200340412177539019002862\\\n        118652155125909377605665570522313722924827432454878041302391573666440354096007833415288205\\\n        656765947802568962289596330168089725205490246098452538786079372905549372857234270190725855\\\n        849112728556822692019699490095850190529727602819872838218231626101062980913313718469209544\\\n        852538752806279742668871810873531954763147922731900653003567552388163440686646259900626789\\\n        714304577755153280330851920000826258260164717299978188447909834297914804211039024170906197\\\n        475297083472857820673298493173502925728185522784910585353556804550521456290001513633298659\\\n        714500938359772146658459237683211430724499182734233300374504698265281053478589566729317858\\\n        790913972324776555314345736769665107752609864227197733165374999429056802940957299499067099\\\n        921050502361595526540479399993958945176147715155608250079631789775409187220084344594176902\\\n        12274124444296788210426683668353271294913726417315879718977231613999863580847401836166\",\n        \"0x0.01edaa4e04695976df280a5d8036e4043050607d25086f92fec3527973e673e50d6fe26cc2a98d36ffdcf\\\n        64e7201043923f5dc51bce0937d27378352c24808ded1b4b5b3a72dc7bc6709f34a90a426ef3ea922afac190c2\\\n        8474a8ca4b8fe2f5cbcaee63764658133bf4ee8c398d367693260118ca7e11a3cf7c60021ea9a5c44e5fd2b55c\\\n        5399c4d2af416fb8495ab953e2fe7f8c37c09d378b6b7ef179c89219865c2e112567c3d0e9ef3604c1cd29671a\\\n        220859d38f610b87914bda4727d5eb49b9b7067ccd5b9c9ef57e7e59956f66be8e839ab87e7420a7b6d992b60d\\\n        f12bfa9df09e2ca91b91841d01a991c5a473b0d0e55e6f4fda6266333923fec6358fbe2a3c3c1e0005c483a9eb\\\n        a2f70261785a9d095677b794e195f2ebc2ed814ff87150cc3b9449451981dac2554d3c18cf95ed5a563a7acd99\\\n        5db1f27732d6f2451a3dab2f423f4b7723b8da4c3f303120fc532ea95736220939e15f80b7fd846c650cb099d8\\\n        a0ace134a39fe85ec810d523e13c25e0b719d1cd0977db7ff0a86625a3cb74ff315e7dc83f55296c934dc15f2d\\\n        4b725cbaa31d95ba6f92d9bc74295829174293ceeb74daf101051b9c789701110c3a4116a550a47c228b82da67\\\n        245a50e2f1d015ed256175a549250731cf4a90e7f114a6469e323d37552553f60f164d64a8a921b998c466ae6c\\\n        631027958fb2f7fa98987fb56bdf12919d0fd1695c202c6d66beaf0d9868a53b16e283f1c970a6c9c90790af72\\\n        75b90192f86671e698defb34b13fbcaaee1cdfc4beec69c2c46072b7a53ab26c823b403098b7657e3ca970d43d\\\n        9954f49e9d5b94039a66b09f4#4752\",\n        1662,\n        \"17069217.78090363703967642537830172830995997926929566889372077304847867142361027601405442\\\n        286459362568854752643069912976321422774071641269497000825786673743566716666986122201673566\\\n        954005548156596610807551133418147862857497307376377531996417888282239877181408646433952455\\\n        449832546174770944921797138738845637802606582911913934926484494169960897434718640487978822\\\n        397032739913032542773985132071836123040945096104343234766846881246804903855742298793870626\\\n        77027180448793731547987433698769543012728726607028778\",\n        \"0x10474a1.c7e94cfe69b17ceb496b55c7673d812006e20b007a03948c3a4b4cfa0e6dbd76b73772e1f6a52b9\\\n        30ce94a60672db80391db2eb227cad27128df746aae7c1ddb5368fdf97185927d712711fe190297ac2c169017f\\\n        ac401dc6bb041c5fa94ba4452b5b1c6a3d3f8d6d83892439b9e9525639739ce0fdfe4663acc923263563286994\\\n        f78a08edfcad551d9695555741c5301f15857227aeb725ecb09ed40468e21e6e6fe4f0f94b9e338a39e9665362\\\n        acb0922dc06bca5074ed2c965471e97402ed8367fe149485e0bb52e243f78#1662\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && carry in div_float_significands_general\n    test(\n        \"2.454546732648863276547885977493137821487607756249724782555774558593552627360857928230048\\\n        942018665976138591785782565939256583959305212359451403757412054481726126552732229930964269\\\n        470905492198653519153594970703124999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        995761114627674791277020932519574469505017610728137410250159407014720169738824650046673749\\\n        059339474479527195633303962573451642912661719349979993453218111358455268175773121496346851\\\n        580476856645369527796626919786850732045813122714395701160155300736782415936562761674226693\\\n        028929972451809327089060718204876263534635026488050357020524924317959135992439056643999723\\\n        656960561739673936265216544476386688997222734833105296938067057205929214479610015975275932\\\n        718619380628277147130611593861916399934357066581330096178050556305086195135562253719174061\\\n        496425118601354010153670564319137109364713055282273218494183562236985834389291157056469689\\\n        9828846337814e-91\",\n        \"0x7.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000E-76#4517\",\n        \"0.015625000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000771048757510508716764719334683019132168263108153512725551350734409293871565\\\n        903519457201213361797567020084883497703807999422859208123581192925346248118136084792628172\\\n        988363113468168413497993606331107182531734570308778128025953654408272649725745457159283262\\\n        0134958821588759455527143\",\n        \"0x0.0400000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffff\\\n        fffffffffff8000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000#3655\",\n        2337,\n        \"1.570909908895272496990647025595608205752068963999823860835695717499873681510949074067231\\\n        322891946224728698742900842201124213733955335910048898404743714868304720993748627155817132\\\n        46137951500713825225830078125e-89\",\n        \"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000E-74#2337\",\n        Greater,\n    );\n    // - x_exp < Float::MIN_EXPONENT\n    // - x_exp < Float::MIN_EXPONENT special\n    // - x_exp < Float::MIN_EXPONENT special && sign\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"1.5\",\n        \"0x1.8#2\",\n        2,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    // - x_exp < Float::MIN_EXPONENT special && !sign\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"-1.5\",\n        \"-0x1.8#2\",\n        2,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    // - x_exp < Float::MIN_EXPONENT not special\n    // - x_exp < Float::MIN_EXPONENT not special && sign && rm == Floor | Down | Nearest\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"3.0\",\n        \"0x3.0#2\",\n        2,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - x_exp < Float::MIN_EXPONENT not special && !sign && rm == Ceiling | Down | Nearest\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"-3.0\",\n        \"-0x3.0#2\",\n        2,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    // - exp_diff + 2 < Float::MIN_EXPONENT\n    // - exp_diff + 2 < Float::MIN_EXPONENT && sign && rm == Floor | Down | Nearest\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        2,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - exp_diff + 2 < Float::MIN_EXPONENT && !sign && rm == Ceiling | Down | Nearest\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        2,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    // - x_exp > Float::MAX_EXPONENT\n    // - x_exp > Float::MAX_EXPONENT\n    // - x_exp > Float::MAX_EXPONENT && sign && rm == Ceiling | Up | Nearest\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"0.8\",\n        \"0x0.c#2\",\n        2,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - x_exp > Float::MAX_EXPONENT && !sign && rm == Floor | Up | Nearest\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"-0.8\",\n        \"-0x0.c#2\",\n        2,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    // - exp_diff > Float::MAX_EXPONENT\n    // - exp_diff > Float::MAX_EXPONENT && sign && Ceiling | Up | Nearest\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        2,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - exp_diff > Float::MAX_EXPONENT && !sign && Ceiling | Up | Nearest\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        2,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n}\n\n#[test]\nfn div_prec_fail() {\n    assert_panic!(Float::NAN.div_prec(Float::NAN, 0));\n    assert_panic!(Float::NAN.div_prec_val_ref(&Float::NAN, 0));\n    assert_panic!(Float::NAN.div_prec_ref_val(Float::NAN, 0));\n    assert_panic!(Float::NAN.div_prec_ref_ref(&Float::NAN, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.div_prec_assign(Float::NAN, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.div_prec_assign_ref(&Float::NAN, 0)\n    });\n}\n\n#[test]\nfn test_div_round() {\n    let test = |s, s_hex, t, t_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (quotient, o) = x.clone().div_round(y.clone(), rm);\n        assert!(quotient.is_valid());\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n        assert_eq!(o, o_out);\n\n        let (quotient_alt, o_alt) = x.clone().div_round_val_ref(&y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = x.div_round_ref_val(y.clone(), rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = x.div_round_ref_ref(&y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_round_assign(y.clone(), rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_round_assign_ref(&y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_quotient, rug_o) =\n                rug_div_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_quotient)),\n                ComparableFloatRef(&quotient),\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (quotient_alt, o_alt) = div_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"0.0081\",\n        \"0x0.0210#7\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Down,\n        \"0.0081\",\n        \"0x0.0210#7\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"-0.0082\",\n        \"-0x0.0218#7\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"-0.0081\",\n        \"-0x0.0210#7\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Down,\n        \"-0.0081\",\n        \"-0x0.0210#7\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"-0.0082\",\n        \"-0x0.0218#7\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"-0.0082\",\n        \"-0x0.0218#7\",\n        Less,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Floor, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Ceiling, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Down, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Up, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Nearest, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Exact, \"0.5\", \"0x0.8#1\", Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"0.45015815807855303\",\n        \"0x0.733d90a6f99884#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"0.45015815807855303\",\n        \"0x0.733d90a6f99884#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-0.45015815807855303\",\n        \"-0x0.733d90a6f99884#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"-0.45015815807855303\",\n        \"-0x0.733d90a6f99884#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-0.45015815807855303\",\n        \"-0x0.733d90a6f99884#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"-0.45015815807855303\",\n        \"-0x0.733d90a6f99884#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-0.45015815807855308\",\n        \"-0x0.733d90a6f99888#53\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"0.45015815807855303\",\n        \"0x0.733d90a6f99884#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"0.45015815807855303\",\n        \"0x0.733d90a6f99884#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"0.45015815807855308\",\n        \"0x0.733d90a6f99888#53\",\n        Greater,\n    );\n\n    // - rm == Floor || rm == Down in div_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\", Down, \"0.5\", \"0x0.8#2\", Less,\n    );\n    // - rm == Ceiling || rm == Up in div_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\", Up, \"0.8\", \"0x0.c#2\", Greater,\n    );\n\n    // - rm == Floor || rm == Down in div_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Down,\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe#64\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in div_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Up,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff#64\",\n        Greater,\n    );\n\n    // - rm == Floor || rm == Down in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Down,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n        Less,\n    );\n\n    // - rm == Ceiling || rm == Up in div_float_significands_same_prec_gt_w_lt_2w\n    // - (rm == Ceiling || rm == Up) && !overflow in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Up,\n        \"0.99999999999999999997\",\n        \"0x0.ffffffffffffffff8#65\",\n        Greater,\n    );\n    // - rm == Floor || rm == Down in div_float_significands_long_by_short\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Down, \"0.5\", \"0x0.8#2\", Less,\n    );\n    // - rm == Ceiling || rm == Up in div_float_significands_long_by_short\n    // - (rm == Ceiling || rm == Up) && !overflow in div_float_significands_long_by_short\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Up, \"0.8\", \"0x0.c#2\", Greater,\n    );\n\n    // - rm == Floor || rm == Down || inex == 0 second time in div_float_significands_general\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Down,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) && inex != 0 second time in div_float_significands_general\n    // - (rm == Up || rm == Ceiling) && (round_bit != 0 || sticky != 0) in\n    //   div_float_significands_general\n    // - (rm == Up || rm == Ceiling) && (round_bit != 0 || sticky != 0) && !carry in\n    //   div_float_significands_general\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Up,\n        \"0.99999999999999999997\",\n        \"0x0.ffffffffffffffff8#65\",\n        Greater,\n    );\n    // - rm == Down || rm == Floor first time in div_float_significands_general\n    test(\n        \"9601551840755394477782155306615.400809036690567306698564563582349725588158197630704697078\\\n        013417362910194409963799900311565761064675199511838067316509390850104862662213505749078521\\\n        770377437536581181743514602025941917984526635269955727174740188131870994016855234632753317\\\n        016792561638598147688756431699678956508985348347746587700412259161976828470219450879730366\\\n        977549362693268375201952814531271011740413280015272635082852480719566333921902104982178638\\\n        916033220231617933208782646056491566119203568817027316959068412927057431189073591651262563\\\n        044927867605702941287180061603188567390575475013505450984801866920347023147022407388362970\\\n        59088991236828388853335477454316615451511519\",\n        \"0x7930498878f5aafc3b8512a677.669b6bc886f9e61b8a5f2697dc5a3b5a2b2256b53dad0634eac355f6a0a5\\\n        1716868ade4d034f6702fb8253c1f989a028a5714d4d362b3553fc85427910a52d3d77e4f39bbc7914d902c799\\\n        e58ce8c619156cf04fd16baabf3b0abeb8808eb23612b9dac1cebfc00ede036daaa891cfe4e827cb450c1dc08a\\\n        8127d7ab7af3ad2ad37537634deffc4816e65732919e1337bdf6abce20a753777e12957b9282ddb2d803496313\\\n        dc5a1048926798d52bfa132da701a4550ee67ff9951f347ffc2fcd57993813839688be78495c10ef533661a217\\\n        c12a2f3327e0d96f3ee8d9b98f05db022bcbe3a69ce3b5009d3946e0ab02a8f9c18127f132344e97387cb60c19\\\n        2f6949d3c05183b19bc196#2230\",\n        \"0.055494458197186880675630915676192867532090892470422627386324587939238035948781984969197\\\n        293549419550977162311955781124943110956302191334821801709357381779895051695270613703928454\\\n        324596584327643817343816609304133584205767499993731432854297161698269943482406592768874444\\\n        537959922587924718339566077249075342435855861361805700477320039260219431275491192763683820\\\n        335274971653357747385666948482136785955293678142161982025522843889154198503897563042426395\\\n        128128925013857602497675148024154470366154782845358820106881972937537492453282371069714224\\\n        342987087633028783648188309716648625167308459669051113846104707695985727291553732092985376\\\n        828259777127224883258056131830095048084139109366273880047266946456087245977725112865710579\\\n        525111935320391211042996099454878241904334424644681645423208503968089041208566140555448097\\\n        852910157786980160921009881876094041863058139126904649967001982231878732430835123816538920\\\n        677999964668461960985136485079991108378659476109039768366016053541284627738754596865400997\\\n        112674267336505852768050602674774522669073467755292625683686148376948941511306559626232154\\\n        752250188007464931234370449669484827725942224651581822979291904312419637250173763557353262\\\n        213949126273235198961215664565140295983002285722717251104994492638175694612259962414559660\\\n        670986455111669460799863783422503680534332809871688740315758114042751185650495859242221856\\\n        676315059490112305738127164937772981750053994564437960009449100953381044642977719710987666\\\n        446442147625231494914221140350124646594870978197268779196749153799654193158076220975432784\\\n        285250458268961487489605062990550609833462756239703423977438296502233632161406744847227123\\\n        129345837972247611423244017961911382138681216321381679915794615975763676728759826413970576\\\n        860022980739678182223426387634227578298610034617798500806276338343012622846552838812662393\\\n        624312342667652111927682534015047744310614980669350777266223429538479188836406048087315918\\\n        309894499222120214872928367335411152843249721184424372084873571670196566303743654124450236\\\n        183156500319414376380635601282651645722305689309629762280330704861001884908133936528480642\\\n        756123234\",\n        \"0x0.0e34e28310efa672de91bbf3447b991e67d8318cdf0c4058e4c9c730c71dc5b4bf675e849e3ac19fa3e70\\\n        d9cbfb926620de7c9c66fc396364a70516bd66e253f5b318c8f82fabc4da09cab178fa55b2cd32603f085d4149\\\n        a70fb07eb0959a5a78a00603aae495e7a094d9ee04b63747d7a023fb4369e5bf83efc20d6dfe31bafee72256df\\\n        1e39a8949cb554b519bb7b532f0ffb97b7fe5238cb68f0cfca74556fd7588422c7b383f4183a4193de48c69bae\\\n        7faf54820ec3c71871cbb288daf37266ee4f1fd3e40e483ed25f601b87f9c4a92b8cec5ec0e8d7edbd4234fba3\\\n        1a0a463a29b8f32d02f0d1f55195b2ec33db71548c7ccaf7e3a658ee71d308649653be586268e028c9f15d7788\\\n        cbbd9d825fadf58d6f13183242c54015f254a271b4c89cfc1d82fc8c6182b0d0c620d53cf81728d495822994c6\\\n        63bb058d661f74be0ae8c8c10381afa72bc89a2a01da15a5f6d117b31e04e34a6e11e0aa8ad521b7a6117ce813\\\n        b8e9326335c30e14052e4aa58c9062245ce2b058e7ca1221aa19af3c21653dac76aa59bb843a7a0ad8c6e22992\\\n        639766e47bfcc7de81f7a5a43e5faba0bd029002632b5d26d5a4303d9bbf4cf2664d57e50df98491d49ceb0f2f\\\n        a1db2579ec23c459066023beebebd800fc879d76d59a3d6d2949650b07ef7b31e752ca051f4f107c7ff4af3f56\\\n        43eb287784ebcbcbefaa6a9496458e1b5afa0a74a27a47545d2f9091189f54f315a8bc904dedd3248f8cfbf32b\\\n        19df9037d47bd021b075b70aaa2087c30b755c65f93508e4564f2d998430e8f68565d451de80e317a96c18493e\\\n        662aa4f6ed98647d9051d9c993accc85820fe55a06d956025618ac1fbd020af906edd248ee088ee34f3ec8fc99\\\n        1e9392efafd1acd495d65fe834644d939ef5fa91d984969c79257afb98f8d94a3551a1a4b533c182b0d198d8a9\\\n        53e030b1532cd0e54117934099dd0b0027cd6058fb4190686ba78ded239aca8ac146e13f4c88052537903cb587\\\n        95eae03289ef10a0dee81bb143567c686a600364a57829437fc75160f8660a0ac48daacd98471fb2c0c490cd90\\\n        2cea0ea9aa3a814462dd78ab7d573f356b8c0ee7ac1f0c13819e3aeb5b2c8ea9f3a386bf90e5898fb38867db59\\\n        a9e8ae436df1ececb24a9e478c52dd17ad020f761aca8761acb63eb70ac73687a85f5fc45a10ab7873104f3489\\\n        9df7961eaa91080cf7a#6892\",\n        Down,\n        \"173018210334417056237548035723683.1345550599384516271435235732043979258142510481520742047\\\n        130035554740186809762152344382670192648388101752940643314971638619112864154957540114182619\\\n        545209429070531797326950151630683621502942030447090067022672243119213825092070120260014287\\\n        650642444490245716249659346973699250580875272571662195525373996192885786789722040970217252\\\n        777370731438163261287964967884564981241085126934825161618449785175399006215884116607844104\\\n        145207013638867416463540845880013358109313225877568519816660562362871960260263575794026214\\\n        064890992255005169417359526730610750695374229149780488537259076167061214467019669082171678\\\n        943457474819859479858903499033921570632357132665267027905891468527976638032942305102942045\\\n        515459276591245938425195867555877301085883501327362346064575111830484879274114432829480494\\\n        563831995727699779881566675298660138793679903428981563834668966551589617302484043712626362\\\n        382798953692078892165133138064987411558895534104001531006894289080282050149571295909335181\\\n        515141217224946465992765152346329894825749923118373449366824218493894112781616587290370204\\\n        333887308955509161095001732854868950761797166686537700534752075294673973732109977084605381\\\n        070618564835872903186336652176818456094869891043565959999476502149984797401333397104760957\\\n        841309659194208245402430373249330458021584229695150780497429392832862209911691278370023807\\\n        694413776673373810444117733945944078894301474904905817592608430260686560983085185519158848\\\n        721775216278449134110149155717067705547304860141801798990958269542345867084594152084822858\\\n        297268178452913654780535118518042943385992804181256593442747503443497424231886204147202265\\\n        781726406780662404185957882728275703416562894011247737570346607390736902934407385727937750\\\n        626919779463789669366072755563597481186609564844136728714713287282513301914775072382866982\\\n        311110548050622515213045989841457194255484993918942830103968812317468779964982010673379443\\\n        545157108484730053634532297455783144465121662023533540802524486197805471362616441499282252\\\n        085672354541543506489067224840744574429825390924134914919433088957785876098287919516428588\\\n        72328203\",\n        \"0x887cbfd350e72440510425951a3.2272334df26c980a06fd6f49c2120e08d01cbf40066a05dc52d2507fc8b\\\n        a1f7ad8adcfa81f54c2d43be83c3e9e1b2ae573ad5d2402f63f8286058a24ae0b84f54fb38a3e8763f3f65332c\\\n        7370e069a38ad39fac27c8792cedd37255b83172e20e4dad5cd71f1373de167311ac9c40b97f28dc1deb8f917a\\\n        4865473383f409e6cb0a10648e46d7a7b4e3635e29b5f290c2b02e89657217e160a8ead0781ee8d369a3f6e0e3\\\n        373a660b0b7d660faa1b7d91b4cf5cd42a8bdff468e78bef9c7ea60bb9ae18146e44c1a152917815a88c662a0e\\\n        8a69d92af1497fcb3af33505d54a549fda939b9762346d0a3acec60a952593d9b87d971a913e1a736e06692ed4\\\n        d0790ed0c9756fec1894ac0a4801a0f3ab65d90696cae94d0193ab36015ac78e049348dcf1a40ba53488aff432\\\n        71652cc4085e19eb0dee362c9c49aeb3ae6922f6bc840455cda7693538989a16dcbcd4771ea096b89b7b6ec780\\\n        e4860380764f3f7268711f226e1c48f3f0ae8068a5d25f97b077ce5d6fb11aa921f2c3ba7cf501ff5bc4456ff0\\\n        a7d490f2e7130fd865897809259d125e6c3a3766e4a746daaf401e8c0be059068b0514c0324881a6f2ed930ee7\\\n        2bad1215cb6436b3338bf75f190705e69ea7c9c4ebae6e62a0dce4ed74cbdd87135c82ac73fd0bb545e0f0950d\\\n        b386f309d2a674b58f9f446549a4ed3ae9a0de62e5e714f93368cb01396ec887f428e0d0df92bd1216c295f4e4\\\n        0268e7f8acb642c1e0df9c960e503d5774a53e0042cc13863d67afe7b2e6a631449876b9b307dfb8d3d8d23331\\\n        a7f27c4e21b77c1e3fa05115cd74fc8ddf363caf1d632bde07c5905d7b004ae049a1eb0b8862b102bab6364457\\\n        f072e4eda8795c7bb923327eb1948231771fd0cb4ee5dc7380738f0b1c42d79fbd02c6e1825eadf29ecc297410\\\n        bb9dcb7b2dbfdbf605008a87de17f15bcdae1b2fb9bc31db5d05410224a6ce36fad367262fff7a125c662ed7c8\\\n        cd2e30f4106d2b7a2ab98d4736946788f9fe057e0b0b1a6f1eb99ca9d05ba0091da8bcf3c05efa1e034913764a\\\n        6c0b52c6582c32ce658ca123e9d830d284a0b63dd2e432788616609ae6da4643f7d599c452e4c8b57689f717d1\\\n        07559c9efcba9e48001571c49a50a5b8bd100a652034b8f6bca1fe99f6e5537912ce6892e13dd1ccae7d8f4f91\\\n        cb7902ec4aa0749ea#6892\",\n        Less,\n    );\n    // - rm == Up || rm == Ceiling first time in div_float_significands_general\n    // - rm == Up || rm == Ceiling && !carry in div_float_significands_general\n    test(\n        \"9601551840755394477782155306615.400809036690567306698564563582349725588158197630704697078\\\n        013417362910194409963799900311565761064675199511838067316509390850104862662213505749078521\\\n        770377437536581181743514602025941917984526635269955727174740188131870994016855234632753317\\\n        016792561638598147688756431699678956508985348347746587700412259161976828470219450879730366\\\n        977549362693268375201952814531271011740413280015272635082852480719566333921902104982178638\\\n        916033220231617933208782646056491566119203568817027316959068412927057431189073591651262563\\\n        044927867605702941287180061603188567390575475013505450984801866920347023147022407388362970\\\n        59088991236828388853335477454316615451511519\",\n        \"0x7930498878f5aafc3b8512a677.669b6bc886f9e61b8a5f2697dc5a3b5a2b2256b53dad0634eac355f6a0a5\\\n        1716868ade4d034f6702fb8253c1f989a028a5714d4d362b3553fc85427910a52d3d77e4f39bbc7914d902c799\\\n        e58ce8c619156cf04fd16baabf3b0abeb8808eb23612b9dac1cebfc00ede036daaa891cfe4e827cb450c1dc08a\\\n        8127d7ab7af3ad2ad37537634deffc4816e65732919e1337bdf6abce20a753777e12957b9282ddb2d803496313\\\n        dc5a1048926798d52bfa132da701a4550ee67ff9951f347ffc2fcd57993813839688be78495c10ef533661a217\\\n        c12a2f3327e0d96f3ee8d9b98f05db022bcbe3a69ce3b5009d3946e0ab02a8f9c18127f132344e97387cb60c19\\\n        2f6949d3c05183b19bc196#2230\",\n        \"0.055494458197186880675630915676192867532090892470422627386324587939238035948781984969197\\\n        293549419550977162311955781124943110956302191334821801709357381779895051695270613703928454\\\n        324596584327643817343816609304133584205767499993731432854297161698269943482406592768874444\\\n        537959922587924718339566077249075342435855861361805700477320039260219431275491192763683820\\\n        335274971653357747385666948482136785955293678142161982025522843889154198503897563042426395\\\n        128128925013857602497675148024154470366154782845358820106881972937537492453282371069714224\\\n        342987087633028783648188309716648625167308459669051113846104707695985727291553732092985376\\\n        828259777127224883258056131830095048084139109366273880047266946456087245977725112865710579\\\n        525111935320391211042996099454878241904334424644681645423208503968089041208566140555448097\\\n        852910157786980160921009881876094041863058139126904649967001982231878732430835123816538920\\\n        677999964668461960985136485079991108378659476109039768366016053541284627738754596865400997\\\n        112674267336505852768050602674774522669073467755292625683686148376948941511306559626232154\\\n        752250188007464931234370449669484827725942224651581822979291904312419637250173763557353262\\\n        213949126273235198961215664565140295983002285722717251104994492638175694612259962414559660\\\n        670986455111669460799863783422503680534332809871688740315758114042751185650495859242221856\\\n        676315059490112305738127164937772981750053994564437960009449100953381044642977719710987666\\\n        446442147625231494914221140350124646594870978197268779196749153799654193158076220975432784\\\n        285250458268961487489605062990550609833462756239703423977438296502233632161406744847227123\\\n        129345837972247611423244017961911382138681216321381679915794615975763676728759826413970576\\\n        860022980739678182223426387634227578298610034617798500806276338343012622846552838812662393\\\n        624312342667652111927682534015047744310614980669350777266223429538479188836406048087315918\\\n        309894499222120214872928367335411152843249721184424372084873571670196566303743654124450236\\\n        183156500319414376380635601282651645722305689309629762280330704861001884908133936528480642\\\n        756123234\",\n        \"0x0.0e34e28310efa672de91bbf3447b991e67d8318cdf0c4058e4c9c730c71dc5b4bf675e849e3ac19fa3e70\\\n        d9cbfb926620de7c9c66fc396364a70516bd66e253f5b318c8f82fabc4da09cab178fa55b2cd32603f085d4149\\\n        a70fb07eb0959a5a78a00603aae495e7a094d9ee04b63747d7a023fb4369e5bf83efc20d6dfe31bafee72256df\\\n        1e39a8949cb554b519bb7b532f0ffb97b7fe5238cb68f0cfca74556fd7588422c7b383f4183a4193de48c69bae\\\n        7faf54820ec3c71871cbb288daf37266ee4f1fd3e40e483ed25f601b87f9c4a92b8cec5ec0e8d7edbd4234fba3\\\n        1a0a463a29b8f32d02f0d1f55195b2ec33db71548c7ccaf7e3a658ee71d308649653be586268e028c9f15d7788\\\n        cbbd9d825fadf58d6f13183242c54015f254a271b4c89cfc1d82fc8c6182b0d0c620d53cf81728d495822994c6\\\n        63bb058d661f74be0ae8c8c10381afa72bc89a2a01da15a5f6d117b31e04e34a6e11e0aa8ad521b7a6117ce813\\\n        b8e9326335c30e14052e4aa58c9062245ce2b058e7ca1221aa19af3c21653dac76aa59bb843a7a0ad8c6e22992\\\n        639766e47bfcc7de81f7a5a43e5faba0bd029002632b5d26d5a4303d9bbf4cf2664d57e50df98491d49ceb0f2f\\\n        a1db2579ec23c459066023beebebd800fc879d76d59a3d6d2949650b07ef7b31e752ca051f4f107c7ff4af3f56\\\n        43eb287784ebcbcbefaa6a9496458e1b5afa0a74a27a47545d2f9091189f54f315a8bc904dedd3248f8cfbf32b\\\n        19df9037d47bd021b075b70aaa2087c30b755c65f93508e4564f2d998430e8f68565d451de80e317a96c18493e\\\n        662aa4f6ed98647d9051d9c993accc85820fe55a06d956025618ac1fbd020af906edd248ee088ee34f3ec8fc99\\\n        1e9392efafd1acd495d65fe834644d939ef5fa91d984969c79257afb98f8d94a3551a1a4b533c182b0d198d8a9\\\n        53e030b1532cd0e54117934099dd0b0027cd6058fb4190686ba78ded239aca8ac146e13f4c88052537903cb587\\\n        95eae03289ef10a0dee81bb143567c686a600364a57829437fc75160f8660a0ac48daacd98471fb2c0c490cd90\\\n        2cea0ea9aa3a814462dd78ab7d573f356b8c0ee7ac1f0c13819e3aeb5b2c8ea9f3a386bf90e5898fb38867db59\\\n        a9e8ae436df1ececb24a9e478c52dd17ad020f761aca8761acb63eb70ac73687a85f5fc45a10ab7873104f3489\\\n        9df7961eaa91080cf7a#6892\",\n        Up,\n        \"173018210334417056237548035723683.1345550599384516271435235732043979258142510481520742047\\\n        130035554740186809762152344382670192648388101752940643314971638619112864154957540114182619\\\n        545209429070531797326950151630683621502942030447090067022672243119213825092070120260014287\\\n        650642444490245716249659346973699250580875272571662195525373996192885786789722040970217252\\\n        777370731438163261287964967884564981241085126934825161618449785175399006215884116607844104\\\n        145207013638867416463540845880013358109313225877568519816660562362871960260263575794026214\\\n        064890992255005169417359526730610750695374229149780488537259076167061214467019669082171678\\\n        943457474819859479858903499033921570632357132665267027905891468527976638032942305102942045\\\n        515459276591245938425195867555877301085883501327362346064575111830484879274114432829480494\\\n        563831995727699779881566675298660138793679903428981563834668966551589617302484043712626362\\\n        382798953692078892165133138064987411558895534104001531006894289080282050149571295909335181\\\n        515141217224946465992765152346329894825749923118373449366824218493894112781616587290370204\\\n        333887308955509161095001732854868950761797166686537700534752075294673973732109977084605381\\\n        070618564835872903186336652176818456094869891043565959999476502149984797401333397104760957\\\n        841309659194208245402430373249330458021584229695150780497429392832862209911691278370023807\\\n        694413776673373810444117733945944078894301474904905817592608430260686560983085185519158848\\\n        721775216278449134110149155717067705547304860141801798990958269542345867084594152084822858\\\n        297268178452913654780535118518042943385992804181256593442747503443497424231886204147202265\\\n        781726406780662404185957882728275703416562894011247737570346607390736902934407385727937750\\\n        626919779463789669366072755563597481186609564844136728714713287282513301914775072382866982\\\n        311110548050622515213045989841457194255484993918942830103968812317468779964982010673379443\\\n        545157108484730053634532297455783144465121662023533540802524486197805471362616441499282252\\\n        085672354541543506489067224840744574429825390924134914919433088957785876098287919516428588\\\n        7232821\",\n        \"0x887cbfd350e72440510425951a3.2272334df26c980a06fd6f49c2120e08d01cbf40066a05dc52d2507fc8b\\\n        a1f7ad8adcfa81f54c2d43be83c3e9e1b2ae573ad5d2402f63f8286058a24ae0b84f54fb38a3e8763f3f65332c\\\n        7370e069a38ad39fac27c8792cedd37255b83172e20e4dad5cd71f1373de167311ac9c40b97f28dc1deb8f917a\\\n        4865473383f409e6cb0a10648e46d7a7b4e3635e29b5f290c2b02e89657217e160a8ead0781ee8d369a3f6e0e3\\\n        373a660b0b7d660faa1b7d91b4cf5cd42a8bdff468e78bef9c7ea60bb9ae18146e44c1a152917815a88c662a0e\\\n        8a69d92af1497fcb3af33505d54a549fda939b9762346d0a3acec60a952593d9b87d971a913e1a736e06692ed4\\\n        d0790ed0c9756fec1894ac0a4801a0f3ab65d90696cae94d0193ab36015ac78e049348dcf1a40ba53488aff432\\\n        71652cc4085e19eb0dee362c9c49aeb3ae6922f6bc840455cda7693538989a16dcbcd4771ea096b89b7b6ec780\\\n        e4860380764f3f7268711f226e1c48f3f0ae8068a5d25f97b077ce5d6fb11aa921f2c3ba7cf501ff5bc4456ff0\\\n        a7d490f2e7130fd865897809259d125e6c3a3766e4a746daaf401e8c0be059068b0514c0324881a6f2ed930ee7\\\n        2bad1215cb6436b3338bf75f190705e69ea7c9c4ebae6e62a0dce4ed74cbdd87135c82ac73fd0bb545e0f0950d\\\n        b386f309d2a674b58f9f446549a4ed3ae9a0de62e5e714f93368cb01396ec887f428e0d0df92bd1216c295f4e4\\\n        0268e7f8acb642c1e0df9c960e503d5774a53e0042cc13863d67afe7b2e6a631449876b9b307dfb8d3d8d23331\\\n        a7f27c4e21b77c1e3fa05115cd74fc8ddf363caf1d632bde07c5905d7b004ae049a1eb0b8862b102bab6364457\\\n        f072e4eda8795c7bb923327eb1948231771fd0cb4ee5dc7380738f0b1c42d79fbd02c6e1825eadf29ecc297410\\\n        bb9dcb7b2dbfdbf605008a87de17f15bcdae1b2fb9bc31db5d05410224a6ce36fad367262fff7a125c662ed7c8\\\n        cd2e30f4106d2b7a2ab98d4736946788f9fe057e0b0b1a6f1eb99ca9d05ba0091da8bcf3c05efa1e034913764a\\\n        6c0b52c6582c32ce658ca123e9d830d284a0b63dd2e432788616609ae6da4643f7d599c452e4c8b57689f717d1\\\n        07559c9efcba9e48001571c49a50a5b8bd100a652034b8f6bca1fe99f6e5537912ce6892e13dd1ccae7d8f4f91\\\n        cb7902ec4aa0749eb#6892\",\n        Greater,\n    );\n\n    // - in div_float_significands_same_prec_lt_w\n    // - increment_exp in div_float_significands_same_prec_lt_w\n    // - (q0 + 2) & (mask >> 1) <= 2 in div_float_significands_same_prec_lt_w\n    // - h == 0 && l < y in div_float_significands_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal,\n    );\n    // - !increment_exp in div_float_significands_same_prec_lt_w\n    // - (q0 + 2) & (mask >> 1) > 2 in div_float_significands_same_prec_lt_w\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_same_prec_lt_w\n    // - rm == Nearest in div_float_significands_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (quotient & shift_bit) != 0) in\n    //   div_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\", Nearest, \"0.8\", \"0x0.c#2\", Greater,\n    );\n    // - h != 0 || l >= y in div_float_significands_same_prec_lt_w\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.0\", \"0x1.0#2\", Nearest, \"1.5\", \"0x1.8#2\", Equal,\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (quotient & shift_bit) == 0)) in\n    //   div_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#3\", \"1.2\", \"0x1.4#3\", Nearest, \"0.8\", \"0x0.c#3\", Less,\n    );\n\n    // - in div_float_significands_same_prec_w\n    // - increment_exp in div_float_significands_same_prec_w\n    // - hi == 0 && lo < y in div_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Equal,\n    );\n    // - !increment_exp in div_float_significands_same_prec_w\n    // - round_bit == 0 in div_float_significands_same_prec_w\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_same_prec_w\n    // - rm == Nearest in div_float_significands_same_prec_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (quotient & 1) == 0)) in\n    //   div_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe#64\",\n        Less,\n    );\n    // - hi != 0 || lo >= y in div_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Equal,\n    );\n    // - rm == Nearest || round_bit != 0 && (sticky_bit != 0 || (quotient & 1) != 0) in\n    //   div_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Greater,\n    );\n    // - round_bit != 0 in div_float_significands_same_prec_w\n    test(\n        \"3.1790543009742223972e-11\",\n        \"0x2.2f43e0add6ebd01cE-9#64\",\n        \"7770090901.6225594673\",\n        \"0x1cf222d95.9f600ea8#64\",\n        Nearest,\n        \"4.0913991113158902183e-21\",\n        \"0x1.35232b1b3b9aeabeE-17#64\",\n        Greater,\n    );\n\n    // - in div_float_significands_same_prec_gt_w_lt_2w\n    // - increment_exp in div_float_significands_same_prec_gt_w_lt_2w\n    // - in div_float_2_approx\n    // - y_1 != Limb::MAX in div_float_2_approx\n    // - r_1 == 0 in div_float_2_approx\n    // - (q_0.wrapping_add(21)) & (mask >> 1) <= 21 in div_float_significands_same_prec_gt_w_lt_2w\n    // - s_2 == 0 && s_1 <= y_1 && (s_1 != y_1 || s_0 < y_0) in\n    //   div_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Equal,\n    );\n    // - !increment_exp in div_float_significands_same_prec_gt_w_lt_2w\n    // - s_2 > 0 || s_1 > y_1 || (s_1 == y_1 && s_0 >= y_0) in\n    //   div_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in div_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (z_0 & shift_bit) == 0)) in\n    //   div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n        Less,\n    );\n    // - r_1 != 0 in div_float_2_approx\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Nearest,\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe0#65\",\n        Less,\n    );\n    // - (q_0.wrapping_add(21)) & (mask >> 1) > 21 in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        Nearest,\n        \"0.99999999999999999984\",\n        \"0x0.fffffffffffffffd0#65\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && !overflow\n    //   in div_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Greater,\n    );\n    // - y_1 == Limb::MAX in div_float_2_approx\n    test(\n        \"5.29395592276605355108231857701752e-23\",\n        \"0x4.00000007e000fffffff0000000E-19#107\",\n        \"255.999999999999999999999947060441\",\n        \"0xff.ffffffffffffffffffc000000#107\",\n        Nearest,\n        \"2.06795153233048966839153112178982e-25\",\n        \"0x4.00000007e000fffffff1000000E-21#107\",\n        Less,\n    );\n\n    // - in div_float_significands_long_by_short\n    // - diff >= 0 in div_float_significands_long_by_short\n    // - in limbs_div_limb_to_out_mod_with_fraction\n    // - d.get_highest_bit() in limbs_div_limb_to_out_mod_with_fraction\n    // - sticky_bit != 0 || diff >= 0 || i >= abs_diff in div_float_significands_long_by_short\n    // - tmp[ys_len] == 0 in div_float_significands_long_by_short\n    // - tmp[ys_len] == 0 && shift != 0 in div_float_significands_long_by_short\n    // - round_bit != 0 || sticky_bit != 0 in div_float_significands_long_by_short\n    // - rm == Nearest in div_float_significands_long_by_short\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (ys[0] & shift_bit) != 0) in\n    //   div_float_significands_long_by_short\n    // - rm == Nearest && !overflow in div_float_significands_long_by_short\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Nearest, \"0.8\", \"0x0.c#2\", Greater,\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (ys[0] & shift_bit) == 0)) in\n    //   div_float_significands_long_by_short\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.2\", \"0x1.4#3\", Nearest, \"0.8\", \"0x0.c#3\", Less,\n    );\n    // - tmp[ys_len] != 0 in div_float_significands_long_by_short\n    // - tmp[ys_len] != 0 && shift != 0 in div_float_significands_long_by_short\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.2\", \"0x1.4#3\", Nearest, \"1.2\", \"0x1.4#3\", Greater,\n    );\n    // - round_bit == 0 && sticky_bit == 0 in div_float_significands_long_by_short\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#3\", Nearest, \"1.0\", \"0x1.0#3\", Equal,\n    );\n    // - tmp[ys_len] == 0 && shift == 0 in div_float_significands_long_by_short\n    // - c >= u - c in div_float_significands_long_by_short\n    test(\n        \"1539239.2465826685826\",\n        \"0x177ca7.3f200ab152a#64\",\n        \"0.00009\",\n        \"0x0.0006#3\",\n        Nearest,\n        \"16812597210.673628039\",\n        \"0x3ea1bdfda.ac72e31c#64\",\n        Greater,\n    );\n    // - c < u - c in div_float_significands_long_by_short\n    // - round_bit == 0 in div_float_significands_long_by_short\n    test(\n        \"1.7088961703394199635e-73\",\n        \"0x4.d4baa70e83509ad8E-61#64\",\n        \"1.7359472818744e-34\",\n        \"0xe.6bf39991dcE-29#42\",\n        Nearest,\n        \"9.844170892645193631e-40\",\n        \"0x5.5c13c13c6d059800E-33#64\",\n        Less,\n    );\n    // - tmp[ys_len] != 0 && shift == 0 in div_float_significands_long_by_short\n    test(\n        \"4.874956728709606165589080471392071684004548689044982493122e-71\",\n        \"0x5.6220e3ededa8be921ace72bbb95a16164a2f0abd57c49f18E-59#192\",\n        \"1.5092483e-10\",\n        \"0xa.5f190E-9#22\",\n        Nearest,\n        \"3.230056172437141772802006354545046772521759341614858124236e-61\",\n        \"0x8.4e07636cdfc96e412c1de0a522f40a5f092091c1a3aa159E-51#192\",\n        Less,\n    );\n\n    test(\n        \"6.88621557179233820703925296804982406452e-28\",\n        \"0x3.68ee78c4dbb67961d201a40495749728E-23#127\",\n        \"0.1418399214207466117788070203268\",\n        \"0x0.244f9effc4f1edfd85dfab3008#99\",\n        Nearest,\n        \"4.85492060543760755133907256608679730501e-27\",\n        \"0x1.80a57d020f8b7083401eec627a6787ccE-22#127\",\n        Greater,\n    );\n\n    // - in div_float_significands_general\n    // - up[u_size - 1] == vp[vsize - 1] in div_float_significands_general\n    // - k == 0 || l == 0 in div_float_significands_general\n    // - up[k] == vp[l] && l != 0 in div_float_significands_general\n    // - q0size < MPFR_DIV_THRESHOLD || vsize < MPFR_DIV_THRESHOLD in div_float_significands_general\n    // - rm != Nearest || shift != 0 second time in div_float_significands_general\n    // - qqsize > u_size in div_float_significands_general\n    // - qqsize > u_size && !extra_bit in div_float_significands_general\n    // - vsize >= qsize in div_float_significands_general\n    // - in limbs_div_helper\n    // - ds_len == 2 in limbs_div_helper\n    // - qsize == q0size in div_float_significands_general\n    // - vsize <= qsize in div_float_significands_general\n    // - rm == Nearest second time in div_float_significands_general\n    // - !goto_truncate_check_qh && !goto_sub_1_ulp && !goto_sub_1_ulp && !goto_sub_2_ulp in\n    //   div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) in div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit == 0 in\n    //   div_float_significands_general\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n        Less,\n    );\n    // - up[u_size - 1] != vp[vsize - 1] in div_float_significands_general\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Nearest,\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe0#65\",\n        Less,\n    );\n    // - qqsize > u_size && extra_bit in div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky != 0 in\n    //   div_float_significands_general\n    // - rm == Nearest && (round_bit != 0 || sticky != 0) && round_bit != 0 && sticky != 0 && !carry\n    //   first time in div_float_significands_general\n    test(\n        \"1.5\",\n        \"0x1.8#2\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"1.49999999999999999995\",\n        \"0x1.7fffffffffffffff#65\",\n        Greater,\n    );\n    // - ds_len > 1 in limbs_div_helper\n    test(\n        \"12077.327578390390934514\",\n        \"0x2f2d.53dc2d699afa78b8#75\",\n        \"4.90332775049862782951473377323022738896770775e-11\",\n        \"0x3.5e9a4013acb1890afeca956568e5bffe30edE-9#146\",\n        Nearest,\n        \"246308796656764.923124719743308898445103382544\",\n        \"0xe0043c546c7c.ec51e6d16d3ab81c76ba65494#146\",\n        Less,\n    );\n    // - vsize < qsize in div_float_significands_general\n    test(\n        \"1917511442.613985761391508315964935868035476119276770671\",\n        \"0x724ae712.9d2e2bbd62dd31f140b2b9b664635f251b18c0#180\",\n        \"3.352896739388742667241376e25\",\n        \"0x1.bbc08f6e851e14a094c4E+21#79\",\n        Nearest,\n        \"5.718969570663133425280005234972069245666491961744252885e-17\",\n        \"0x4.1ef6b3c1725013efb2a8179983b542a97b0131f39a938E-14#180\",\n        Greater,\n    );\n    // - rm == Nearest && shift == 0 second time in div_float_significands_general\n    // - qsize != q0size in div_float_significands_general\n    test(\n        \"1.490328e-27\",\n        \"0x7.61370E-23#20\",\n        \"2.89262335038499315783322011549431655756e-75\",\n        \"0x1.4ef161f7b7fc2c6cb4464f827b58b972E-62#128\",\n        Nearest,\n        \"5.15216656741446303242577558053691246166e47\",\n        \"0x5.a3f1d299f6f20544fbba161403f075f8E+39#128\",\n        Less,\n    );\n    // - rm == Floor || rm == Down || (round_bit == 0 && sticky == 0) in\n    //   div_float_significands_general\n    test(\n        \"2.38418579101562499999949513e-7\",\n        \"0x3.fffffffffffffffffc0000E-6#87\",\n        \"2113929216.0\",\n        \"0x7e000000.000000000#66\",\n        Nearest,\n        \"1.12784561231761934265233937e-16\",\n        \"0x8.208208208208208200000E-14#87\",\n        Equal,\n    );\n    // - k != 0 && l != 0 in div_float_significands_general\n    // - up[k] != vp[l] first time in div_float_significands_general\n    // - up[k] != vp[l] second time in div_float_significands_general\n    test(\n        \"65535.99999999999999994\",\n        \"0xffff.fffffffffffffc#70\",\n        \"22835963083295358096932575511189670382427701248.00000000000000022202\",\n        \"0x3fffffffffffffffffffffffff8000007000000.0000000000000fff8#219\",\n        Nearest,\n        \"2.869859254937225361249367321235116718339077564583058127288930659162e-42\",\n        \"0x3.fffffffffffffffff000000007fffff8ffffffffffe000001c00008E-35#219\",\n        Greater,\n    );\n    // - up[k] == vp[l] first time in div_float_significands_general\n    test(\n        \"1.91561942608236107295e53\",\n        \"0x2.0000000000000000E+44#66\",\n        \"43556142965880123323311949751266331066368.000061035156249999998\",\n        \"0x8000000000000000000000000000000000.0003fffffffffffff8#205\",\n        Nearest,\n        \"4398046511103.99999999999999999999999999999999383702417796084544\",\n        \"0x3ffffffffff.ffffffffffffffffffffffffffe00000000000004#205\",\n        Less,\n    );\n    // - up[k] == vp[l] && l == 0 second time in div_float_significands_general\n    test(\n        \"255.99999999813735485076904\",\n        \"0xff.fffffff800000000000#82\",\n        \"1.35525271559701978119405335351978053e-20\",\n        \"0x3.ffffffffe0000000000000000000E-17#114\",\n        Nearest,\n        \"18889465931478580854784.0\",\n        \"0x4000000000000000000.0000000000#114\",\n        Equal,\n    );\n    // - q0size >= MPFR_DIV_THRESHOLD && vsize >= MPFR_DIV_THRESHOLD in\n    //   div_float_significands_general\n    // - u_size < n << 1 in div_float_significands_general\n    // - vsize < n in div_float_significands_general\n    // - in limbs_float_div_high\n    // - len >= MPFR_DIVHIGH_TAB.len() in limbs_float_div_high\n    // - k != 0 in limbs_float_div_high\n    // - q_high != 0 in limbs_float_div_high\n    // - carry == 0 in limbs_float_div_high\n    // - carry != 0 in limbs_float_div_high\n    // - len < MPFR_DIVHIGH_TAB.len() in limbs_float_div_high\n    // - k == 0 in limbs_float_div_high\n    // - len > 2 in limbs_float_div_high\n    // - qh == 1 in div_float_significands_general\n    // - in round_helper_2\n    // - err0 > 0 in round_helper_2\n    // - err0 > prec && prec < err in round_helper_2\n    // - s != Limb::WIDTH in round_helper_2\n    // - n != 0 && tmp != 0 && tmp != mask in round_helper_2\n    // - round_helper_2 in div_float_significands_general\n    // - rm == Nearest first time in div_float_significands_general\n    // - rm == Nearest && shift != 0 first time in div_float_significands_general\n    // - rm == Nearest && round_bit == 0 in div_float_significands_general\n    test(\n        \"914122363545.7300954288539961362078521335512160921125366724096502748846903936195389924148\\\n        154757063704910629280973433563521737016298541257057972452261335506117124831272191707877190\\\n        2119190824963185068512647039440777212199983388696\",\n        \"0xd4d5f05299.bae788b5e312f78f55ac79e4ca82e12494296afdb40ba21e0c21a4b3915ba2e217c389f8c9fd\\\n        22042f5ed70da20cfb9f1ee797b1433e077a2d34b1ae5781f975eebbcb21a32ee0c5afa5e59f8f382fe0c754a4\\\n        a3fb57fa4d668#754\",\n        \"99775868891207693182758620905617766484977359141657322302733467080906379945858675686059451\\\n        2527853476231275058799551652072546.7114971760702609364731573674336745185834760605451122614\\\n        680178551142556046183482705875960001033145321970465204907865385015751310573750415565593472\\\n        515573584122133946534420508845514863685042630834456885627933663697385547769664847990486584\\\n        336882273751721721644989648370590667737234950547668737865047573751482757356022197920174371\\\n        088074314780588737501583713833755004374512024407585163195094394292034507503368814534990168\\\n        9912721166210129145585\",\n        \"0x1826427338bc8ee8c907c3ce5e6a2a793f6ba67df6e738f22dc8aee7eb1838ddc4290e49186e61bdbedb847\\\n        d19c5d8c4bf88c62.b624adce6b0a3564827e04608c1aec0c8b10390491e15df75402c1788241935e791ebd5f4\\\n        25d73042c03e3bad5f0d11257d8bcdab6c8bae677785865be19fa4f42690ddb02174b09bb2c1c9ce6cf3dc2d80\\\n        9f0b0b79c42ae70f14ec682ac3850e91ee3b6ef02555e18758417024bf2e8801a759e710b3ac91f28b15277ff4\\\n        f6380b7ba380aa56c032ce8db2107bfd99a9c789098467f2b27a7b3e1bb6a9e7804ef8a26a3baea51e9a8da4d5\\\n        02af09995fd6ced97b00#1859\",\n        Nearest,\n        \"9.161757985214429764992710266551647359057325985892606639113002591596898046569993924851132\\\n        469009506849046579846739625666450546615840413944516736833310444241924771226669449467280905\\\n        847180462085951493210441487438964221396785151298524525494386941673630175499486324164244756\\\n        513337189186243674611400515366863669226025015162200893355049656715514081022497216123358900\\\n        204159965608607573130556648229035236124949246847315199932950877590362471534070708393335471\\\n        028355306786566135185894674384218244976402468322690432705335567965983855642753641740432604\\\n        3437409476409135277542e-112\",\n        \"0x8.d032a1c09c5a822250facc4d03dcbdde26d4f5fe102c1e08a4f87e413b615d798e202484a718a7e4ee277\\\n        3677de7769fc7d817e371393d771d3460b42f92e9ba23196df3ebdff7cdda4294aecfb6c43776a893a979bdc8c\\\n        cac166e11d435edd52a1481ecb355a6595fcd794f14478ca886b31b8422e8bc9fdcdbc2261e6c6dfdfea3875fd\\\n        d48e82b6f89b37437a8064efc36e3671100bf00cb530951d17bbaefe545249991b357ff0fbc5a593a69916e391\\\n        e844f20336e8635a395cbda774a8ed440b65ccac5a4a48827068b6780bdeecccb424ecbcea085547d055a670dd\\\n        a2ce7fd1bc8ccfff3fcE-93#1859\",\n        Less,\n    );\n    // - q_high == 0 in limbs_float_div_high\n    test(\n        \"3.667390117738159207950705349477719105571949429980976394812181671883945054829509256768693\\\n        428777428660656941387302685172371854480204626447190818847235223777196475037450938977825246\\\n        002439873468885558547110470430228085143851019175355894923610792842932340338852051239754427\\\n        095026930245556704615627992643819617817074019244527799280182728405175259498139200084973400\\\n        185025632529817381341736837108765891093445296142846875524815723636775475593320258020981988\\\n        641285509338653295726597545939874976233498010217572353942629414771256828458910867296816672\\\n        522543163090158525097032013393556880192772591230747507060825723928635133507431423165786715\\\n        278150157159772706487785219042905040143153742214007713387626849311191420055238664770362170\\\n        343983987545766271318010394410223132309343859005046365250499465556871672911799580499791909\\\n        295656508202340485571517780009270726548788594036564495463224892161734462687808109262481368\\\n        096969794376769660230615691331025217443348007977074560288273633401967130359649250852147512\\\n        141074330343117535301250887203664127461249846867757356639750473042390297739319749311431157\\\n        14372183907772936544329974943881256368038028229439176970805917055179180439477409e-9\",\n        \"0xf.c0568c485e0b826908a56a1e9eed605a795d47bbb3b22b86ff364a5aa967860d79fa907ffa4b598c74ca2\\\n        768fd610cc65e72d1328231f74c2896a372707f3fffd4713cd781c36ddc8c429a53c9de0a260ab39221aa6723f\\\n        639d4f0a18f42a39ce148ec18caa8292a2404e421cb5af96a525988ace64d3b66492e8b29b9f1982af075eac7f\\\n        a4c4f560684706f9c92a1babe3a7cedd233045842df3c534b90481e818908a787ba694e61d3bd3d93a45651240\\\n        a1926f3b818e8c51165d9c7c186dd99b0afededda17332acec6e4419ca2c498ecac62e9670b8cc359ac4ce5abb\\\n        e6a858a9ad732af4717655c73ab36f06357d16912bd759fba2c774b33607e2ee49fbf3328842b34b1649846034\\\n        e601a686e91c2040c578ab8676f4c413bc62718b75fe591900b6f10a6ee20a73c59ab3be30fb9a154c1a50b4b5\\\n        d60d7a76de24b93f804302eb4d625df61cf824be4c93189bd500d72fe88443b2e506a11e3b57403b447b8602ef\\\n        45e256c2e9cbfbc69697901d340ae418d96a38e3f87b38c8ee8b168c15df448ce29060725fff6438c91fd406bf\\\n        6cf95e07431942e379a50250441c4ed69a634f4e155cb67d47b7b4b285388f957b3809dcfb73606173ca9a64c8\\\n        9b5ee06f42fc1ee8c752cf947957f346aac01a1e21759f8267f58d36b22e7bd14E-8#3843\",\n        \"3187923845432148642442057154569059.126715487792372839803386914179538752693826970283207166\\\n        811288798839227319311871148502823407877176659352907588186871022894787193533982873662011253\\\n        290757573915501169313819926148549862448642272469031186766746849160076154409190019980289710\\\n        170792165652792217117270925812431819493193080694795589891807146039351866024622601910524654\\\n        975993653145125921373829181052606711648254654081125875153947355721451359688668050452670532\\\n        460418624462017975144128989503732730892234660879379487543472739334395798501406522301770530\\\n        084261662015482020833397653047706275744771695945820139179975325296925632712346348118093097\\\n        953095934511815810581175318735500116787412839224213098543182657584610954902591533740060963\\\n        289805212670558460977431314581393471573332429725647583364688986461335610003995668212280028\\\n        807977055980202986273442266172236653427698776974320204115552560417196660880213932819325142\\\n        548937684752935846670101028764484218237392844524558383599287530029421881169570993841163993\\\n        843829902198804691520255195056203676272889080365643704609455722537324606271987166289767672\\\n        190663805227886932691226996255254535007618551610966568052639325048438160780381909128343538\\\n        211967934803057176881479842550254050201767779261994751352264395465646274141983125281497566\\\n        020553366225193569060382295548356106219949376044134821789228041804290511458952966410365196\\\n        222090758059421770693182158103609003570428820956594490269060711518240230638460085565864341\\\n        256289190220580928350048868798606128912317218138793827337661513849296003850300428079774414\\\n        62431384255329048179650372924700507846477189871631671161154559755984562472291\",\n        \"0x9d2d417f3ca9f32fea99c6482363.20706d1bf7058f4c6275f668a177cd076adccb2fda12b6ed78a3b56bb5\\\n        9dfb518b8b3c05c40c48fd5544dac5cf4c4b5097a348e21623af642ca54df95b1dc69591e2bdc1e3f296461a0e\\\n        73545f0b1a728f095b34af1c14dc3ff040878852b81a047198ec51c9f7dcfffac0ad33017fdb2f0c43edcff12d\\\n        ef18336029b6f47a305e278cb4eda766445530f250be179818a2d241b5afebc21b194dbd62400042f887100725\\\n        62fb877debcff302fcc5b1162c1450e14478eb4e96906a31d6843172390e3cd69b3c0f474a72a62036579c22fe\\\n        1d1ad35fc2be49e475a1be85f30bec6d387e595070d17b17f5b5a6f400fde641d92abee13055777fe7f6b647fc\\\n        7850f8002fadb99332ceffb5439a87b2ac7f223b73750c6b42112fffe8b992da6c3fbc5274503b1bba48602753\\\n        174ba7260f73f3fa02c00fc495aad0f85c84c966f0a98fa7d85cca68b07d58e6292617f3b67fd0aafc0dc0c457\\\n        806b811f2698bea27de70e9ea3de0e898978b9670aa90750e88ac855daaf830c9dedb5d22968f2b01302edc889\\\n        ce03e2af4ec2e339258ace8efa81eeb76b273039929d7289eadfb0bae898fd0257e0f1db349eba610dfb56e3d3\\\n        1520f08012e02d96edfbf9a1a05ad01f682c49e1cf1e0f2b1131943ffe95afd8c6454deffe4bfdbf15fe656e18\\\n        13690a6dbdca197ec4c2b29ac61a6ca074a2866ff9f55184ed344bb45b2e44eca9945a21cd78ccdd427dff1dab\\\n        1d449dccc0aa07e37c89bb61c7fc94ce0edd5fb60b7e2d8034decb7a0e2bba4c1159236fd7f800450c1516e64c\\\n        bb2206f385ee11aba1c6993b2d50b2437bc23cc47f6b85d72fdd7348a5e321b5c960e8e23830fc93c4393938b8\\\n        98c2f16e8452c9e81ce5aa01460fb108dca1e371c53a1e72ad6ad0cb80bd5bf0ace476ab08fe8#5329\",\n        Nearest,\n        \"1.150400792350488243006374252439239370084430198894097883408930056885079539097149903334801\\\n        351771948494649335504249165228317854781872084884358035626531528587565616792440130659246789\\\n        547068913471358728267587391921067763401960740658485999234360708658257354709138940743401019\\\n        478517400580149085993404074744575447821383623813098520973947955049547026992303475579228215\\\n        436224676800479021561310494945776720018368502752527214637080415175177143606297950367602304\\\n        149567232708944245857383841379350871799797376084773487408407355299732079377175164962925047\\\n        553551234005632068337070468847266947004802579875459884664958168707856865409967591741263680\\\n        896819771668163339399940221050773763868745744855354003266260565352234279551485173590767169\\\n        460117377689246074482291141675360319952860733464727767370984256722737643645180588444886771\\\n        648355387388454942423178644791668457452750839522592156007162798991977390140623536578544490\\\n        057707937271642210929120388296125663413585185722459999909564986042307052548228205977082023\\\n        238981495642981332360042089388607651948288196055583153394379775735995327224157713864077477\\\n        321557707540034099204193983589868016082915953745995091314702115380175700364741814725184464\\\n        602065018950641261052531311066491931955988616475785792821351515116629573461861957542243077\\\n        532642867446492701937719979200426618485741197144774966492676324343483017759514367363624027\\\n        675809506514516688590348320872084123672477458766804242125009602995249222201904595636534318\\\n        096670348004414769559053243712710972449074750435098780379781902955436286126620063025099547\\\n        80435463720060716005725004637793753168276780047800093479230422676842555945701e-42\",\n        \"0x1.9a7a0a4405b5655db3032989d155cf7a58151a06aacabc4789fac720edfb0e835fe88bc9af3cc179149fe\\\n        616753cd76b4c7d9c17f2f47389f4e0007572679dad2a5316ede08c14af0283577f171d41d795d4ff13631def2\\\n        630089c6f215d7b5b8948c52ff97a4a1d9f1eb6d67b60e55478c40ffd2a7cd9684f43637e46ce3ce3e33085654\\\n        9165c4a377c6ab1dbb9c9b40ece8c47d94ddd1318dd2e5e57388b2e8ef80705d97c3db61d805c43cf7ff7a9a1e\\\n        41ded3ff033e68dc751b34ffd9cf2eae50cb7e7875b9d8f24116927cd9f609a65c71e840166cf535bbf110404d\\\n        bc493350b17705c0e23a9091d61f544117f70c6c6387dfb9a1dcc2f513cfbebc4cdd4b7d94c9fc57ceebebe3a2\\\n        e7d85b9b488b5571ef7b7c8621b770d99c67f9a19252ec5f9be4b129c7755b4a8585b97ea68e60e390c0b5c2b2\\\n        7b5fc3a47825c136e3b2517a6a7490ae84cf61659a9b819bfe59d45f7254dd48e028c7b694a9b9b427e60358fd\\\n        52afbeed855580a61e351d523d4ffaabfc7ca00e9a5b40128e9fd8b2998c189e95abc1857ff9ddf1dac904a2de\\\n        dfce45cbc4f1ffac50c26ec7e1135aa9ca96f6d3ac8cb3a6620a3aecb003d246eade4cf0e6394df920dfba899f\\\n        44ed41072e121f0402f19fc4c43c348467a07566df372a7b1af45354f2b4c7f94d52f355813e84c1a95202029c\\\n        0056a974e856e7c42fd6463561d1b5e02ed6a7e0ea0ca50887bd1047f4abd068ea61e2095abdad6a0cbaf91846\\\n        a340717aa624d6c6ba02f5d3e835ff06c742f1343479ec9a9b184eaca8e7c8be7eaf4fa322afc13f046a4a2e5f\\\n        4e84c723c68079991a080ac6939780e172640d568c2bc3452c14317358ee8d27a18af7c9bf2de8bea3e5b8b113\\\n        d8e61b810d6103e805c2a8f85b9b88f8c9129b924ba95521aa83a066991bea980c8be16f1df53E-35#5329\",\n        Less,\n    );\n    // - qh != 1 in div_float_significands_general\n    test(\n        \"5.001744775175450910666028825162941035057223155811961434576858983758571141018459147239961\\\n        203150588371507863692097065128597336587126035820647361489875366021800666979434518756504925\\\n        080057234368614339602900137940067888065298554658519361482160014564328827389146902718969285\\\n        655774560873251528749737416878097111467317878479458938947793439179987668446365650646689222\\\n        368834166803110702160567896615568919058064520266761717855703906871630752776256537972706691\\\n        492064397304429453321564568279795029252524047182880248127317544801138445700458013706547493\\\n        607273723210196209139384085476634511414334117395068648152693457778920460359930382343697178\\\n        078573995749595631668772420417704996567074590195305455833132484492282116574194971013126880\\\n        3791636230633361526548302742414616516594455084620537903358416e-16\",\n        \"0x2.40a97302ee75111e17146bc65c8925811ce517da511093e155a5f8d319eaddbeb4108f1636a175bfa8c49\\\n        995045d6820b2f007a269091d024c939d8b02f4910a81e4eb38a836a327a5c12207dbd4d7a81228e55fec96493\\\n        eb7d51704a03ee77c5caca6616fdc0b6cbe90c676923de6ef8bf3f132b9e5e0dcbae8db3a41502b6d35629f01c\\\n        0834af3506639efdaa9dba6adf35a24b53b04e032ba7f9821a7155eb04aa7d235436bb878e13e2f265b7a183bd\\\n        7830bf484c2c6b19e1df88120105ab6ceb5f940ee7e82d4a6da4e67b7532f20750db350a532138117c02fd3f63\\\n        1e917747a8217c0e647adfae38491beacae6be9197fecb6a639604eba9f3e2a0e1250124f9d994d6ae0f8077c0\\\n        ad1f961f00f0513cb1b3b92f03fd2e19ce799415d8c26352d23ab730bff342c3d10823b5d476e3a74e5e3a1265\\\n        3a2e81ad38c5d7f45687a8E-13#2587\",\n        \"1.142392802815468388118014752111991104436260746248041498551240097570984474280784266879307\\\n        592064853042631818930172030116326290909317377878988867978348974337550025356060840134215623\\\n        183687852648862683292152461337367387727519703906836027722282460995072637442171724001503892\\\n        471336699233392710738717656085295397789876649817787754823752786376233371866685422498954888\\\n        388883747226256845650864591251580129661172288008506642506027201072159168710566406994425528\\\n        61698637621752755004821872e-17\",\n        \"0xd.2bbf98dfde60cfd72ff373085dca4697e7a8a2b1b6d379d3c49be918a519d5508c59f210662104e5d0b4b\\\n        bb4e9f09afcccb3c1655f91f2a86657e3f1315aa4e7c857d68f4d7b989d2a2f5d56a205e85ef7d6d2e9325e0fe\\\n        eded2158374d99d513a6d203143a26cfd251731f49e63a0e342dec62e52287bd673124d763a94038f4529cffd3\\\n        3599c97c0e19c589ce5603d9c26a084d360b9e7decaa7dda44ce1c27bb7c21adcb23b90d069b0a9b53b9d66094\\\n        d817f0420227841d34052ed2bd52e148923f8E-15#1571\",\n        Nearest,\n        \"43.78305573046740119713641861874642911154821650761595780287653003720809501996262685108891\\\n        851641972710141298162279987632328545443442081070773994511258975201978303856309243168868354\\\n        195798884971190979692045031917290903217918542303368118161338247041052975773351929884789101\\\n        115569142934332750399827875003719838494787907290778719530315375971295186399328856671813524\\\n        401338950750393532748258170809380674066918530153006391759208813425198252649570832466781508\\\n        205219467712658427254330831981130973959961174357861904110964877950640959685965415405374479\\\n        749995867814629083616329619361738872731212580413192190669870683344353586783786957328312637\\\n        080558281918488071596583884466679323108552730394571978915258990045025562636051246193761815\\\n        9037942507064891051161378037771712070204599081778501997567779\",\n        \"0x2b.c87657214d897953f5e5edbb169c290285fbd11622c9cf401ba99ad9f03da7ffc778df1db0d888d67c18\\\n        379efc8b4b36ed8cbb67da04b5b4cfdabc5f751b0a6fc68b1e3a2a16a62c4160ce4d10e00ae47020ca5d3867a7\\\n        2213145fe6456480971ef0cb9716c6136384fe41721979e86d1ea1bdc104f2967865add528a1367b01cc449a48\\\n        5786a74209d8e4c5e216fa7ae2dc897fd4926b55eacde3321f7c41bf2875c24933c8eecc7a8a26f738fd6d666b\\\n        678ec93b48bab7b34c5392d3ca76949dab6958fa5caaf70927d3e8b40d050bb607bc1b4fe656506e1b3e468e87\\\n        8b257c21e926286697a97538d3230475cd54415b8154351e72363b4b7509061108fc6ac5db47219368f3ca4011\\\n        5309edd7318a116c2b62a34277bfdc8a1faf656b14b6a046087cfc5dd238cd94fe91967fb6dfc52f8afa5699df\\\n        e2970ca40fb03c71d7d668#2587\",\n        Greater,\n    );\n    // - n != 0 && tmp == 0 in round_helper_2\n    // - s != Limb::WIDTH first time in round_helper_2\n    test(\n        \"0.029226865494398284939675773661541675546326681033634876986774906885711036844605915426240\\\n        340310096249605517533494947862661721742262334681480455706389428160732541825851560446846541\\\n        984468705310228771603694136853587701004882713625816107989162498255925332620064155091399923\\\n        221735997586925448254801064429910518067322424203818026901404115120552071966804127784634236\\\n        948421057038304255272147630765439482924461011451862112889343084859504616664030668233890526\\\n        750016895266382189553251377266295422223247821668554701473442441938933867323625955488726630\\\n        366895993417469747854898337776376811834753617592182604418498468334055402941851068346511528\\\n        636460609896950078921029074658151972716364203699936241491820871671807186599907001653993018\\\n        871354678119954470481273332266267481346670395677171242596948926022697465301700258863974068\\\n        74909984356479995046141060221761701111762543380195142151878885588292130260647185\",\n        \"0x0.077b696f76893b930df354ab0e34b0df1508ee4503f673e22fa3b41867c5e4ffbc43b589d4cb4a00c472e\\\n        4046ccc9dd4a2b88b59dde14b46da030dc5a0f825fc1d9ff0213e8b046b1cd79785dd554b78e98759eae454c23\\\n        4fddf6ee7ae174bfc7c1ed096e905b41ce6b18511a9bfc9cfbc43c536393410fe83a634f402b0f18a446a3af90\\\n        9a4079394959da6918bd9094c5b587839c67f902f1f107259257f4ae96549552e41dbe7dbaddda5b9d8fa2b2bd\\\n        d01ba920c27d6ff6e44bd8f0ef230d60508f693680e1d769f920949bd35768a7ff10fa62210e3caf84f93cdccb\\\n        a5238b5e4be804a1422da22abe509c758d0cf44f202896613342ffd0fa93939f0c9bcd4de899fb72b286773da8\\\n        fe9cbfbd51894ec97176996bf2b6a61ac27a5f524cd408e8bca09d7cefc329a98f17616d4b48652d0a3f14cc49\\\n        a9bbe75a69ae9167aaa9d1951d446e95bb89c1760a549ff81f7b1d8ee454047a7d3c3e244dc499d97b256eca33\\\n        3d43933df1e0a046136e10#2940\",\n        \"13755175900776476.03444104347769161034491994978466673515315430911280875941467408228432201\\\n        072744723926732268661761372710838010056791678637659254162102142124198282086034764229922487\\\n        783612307113854432839997318024745178344073274492535681224805316900558167281372795857375154\\\n        556654904332875058382920111153919687941523340022403648029377155100560618075774147398400587\\\n        446623619383420263487024723715538921428293815054071349051549046244877203394687286110159347\\\n        188168590858399073350484327515115795260226962105536078430163098017753828590552884767518140\\\n        1985404905771271934\",\n        \"0x30de427563881c.08d120d36075efcee88657ce81cdcaedf45cd89aeca352b6e32212d20771ea31a54387b4\\\n        8b1eb8738ae1d31c6213ddc44bdc809d5f5b278e3449ebd13c9ab8d89ec9f0a2d87e7233cbd5128caca14e0c42\\\n        61e5c9ed6444b50d0cce082673e3c80b1a7102c8fc7520036bc3c6900dbcff7cecdf27ac4022bd4095736dba93\\\n        f47ec8ed66154c32a8eb07e14079a264e1e3370aebbfeacf3a1bbfe7aa657d9911acc70d626a35a29d86c84029\\\n        f97428f7cd8a3965838abf5dba9a9943b07c0ad2541156ef8e2aca1afd50c7dc55f986c835b95647701f744563\\\n        d15716174f2ac444#1845\",\n        Nearest,\n        \"2.124790384741531086324618396766014790807036315098759090708607153306148130187657728807205\\\n        824808003798574987452867827342282934278081982848900135498971286785256137258700150407383617\\\n        040883394430575593960834148265479663570529896251340120502267014474793716347382140126837773\\\n        997589830815187190064041312015350810806968062929485379465521677249527992330225473850965169\\\n        559943150658138282772411679190301632849325467452565481282203194749783450341076382685241552\\\n        308193411477432500590221491760317417660435511777399629140824293491122934845121250984106958\\\n        267596015361360781611025519421253206751640221273565905944385402975185311734694681019948131\\\n        664198303801199498616289444621169851399879692298796098215712787193626312888177618196672010\\\n        550069281366814417353104090880010484400040465312380510548737422916103805415326232623198929\\\n        338433641210905412883566788706510371353536321443505713555119784985687877546815e-18\",\n        \"0x2.73209f5170c5b9aaeb5a7e9e79e1dba6ba9eb57b8701701f4d2be387a03993b7e53f907a48a9029ff962b\\\n        4eb20e6ade6771889642b19b1985ec76b2b24fb517b27eb86681dab6bc7d5a5a203545d850396986ce5c6f9542\\\n        50b478a0dd27222c6c45900f2d06dad9d7f78a79b9978e3ce203479c5dce6dde3affc40e370565c038007c8bc1\\\n        ef1fdf0f6398b88721063c52e5eb2c4b5ba1f10d93710d5abe8aab35f5bc5cdf7031f7765dd4f9d4065b1b5b86\\\n        4ccd6665b73715bdfe783fae157cdc8a78e9d053cae011d4dddf28499ac3809e290ca0a221e38d2a6dd8d01980\\\n        c64da2f6836e0815e2ae3feb8a0d765808afcbdf6df10cf661eaf6c064ec8023cad01912101fb7e8b732b555b4\\\n        a053a203ab5ec17c24af5694ed7db4f67c3c76a7f360512bc9a2018d2860111211238048d21af3d79aa0904474\\\n        22c0d9c9883b2f3769a5fe3faeaf8bab1409329c376b70c7b54fe1393115359c5a7ff43560bc0e2548a02ffb68\\\n        184585e5023a6fb507d0E-15#2940\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 in div_float_significands_general\n    // - rm == Nearest && round_bit != 0 && !carry in div_float_significands_general\n    test(\n        \"767950667289861979450190915916317600206727962344150969868.8721759327117422801652737665276\\\n        756590281054535919141164571740727630029753345081284383462360338144272865435150624843971065\\\n        632159910277471560574746205336214689461444841220676837587640834824669960199738043592424986\\\n        826697488691269778053087892841924823231361961899657984958299046295741089107389167540777341\\\n        1137893901502419455\",\n        \"0x1f51c7714fd0115fee394111538cd8cc2697edb4db72ae0c.df46ec035af05536a25a7e2694997099b2577e\\\n        a12f12bb82f781cda7cd6a148cc07ab56a0bac9e90b8590cb04b95fcb27209c3c8704cb6940c7fb857c1688d50\\\n        6042d2fb6c58e0600ed4d86a5af398f029ebf3521880629fcd23f2bfd5f9447e8dee8310647fde5e5f5e2a0a18\\\n        7cdc4e8c046be95417ea73f5d4a1962ebecd092b613af810#1250\",\n        \"51.02908107282950125513822733633990251324880237789609831750259919822628384179764854139813\\\n        664310170076349095466129599769105832710389521373306698912599298264052853550294941822816681\\\n        854313580668986120583821047373123379751687690065811623363578923931243167028825931454472450\\\n        957582633858214796963862561877157489833071159740156527107422181977546544800568916528954101\\\n        973657910504690951238460938847030239913388867386095316629182004723248011669496406544341717\\\n        280330814897033602543594303927085904297027340275835376721330553519116838042737905906942433\\\n        571685773257005175176741271374980135164819404821829229591371965448368260666618720681201228\\\n        891015077648242337901859343084853665103006650868094946302847691177013349096688713595881758\\\n        621480481903927608236275982505035171940737146501502983532266096788435188627685343250723400\\\n        305856753098249087347464717300786991295322157886984156263306019163631926110778355478267431\\\n        730519001037411438399866507817311259465545754442998333101310788661554118860610086857525556\\\n        649462275011688416941329847092728287810185063940836755796270353054485056127471728114260616\\\n        408519706805571508639638485588089026599284155688404740772260862102363921554760355678529807\\\n        545078380365647104062842403550988330511500383389703046031841433893387481098301402534069795\\\n        658730174573583314000979689827444189825731612831252242895060479770394162281620141901978731\\\n        360879005964038152579829187416621515149774573766217606037565254139422563209723838864340747\\\n        448492223949482531030183865551640816462517599780266133382572731428229045787209942986614817\\\n        192016158247860998226332096129248802519217902568127470669978186812858044800325333178140023\\\n        387809105983555698845635663825858578549915679237164757880235025950739307212793316009945989\\\n        415835829851915334677834156538103555704104713171341701847682567317855121655570126973890951\\\n        3929068030854124664713500553256\",\n        \"0x33.0771db70bc3cc1bbfd03fee9ecfaaa1f99d76266a08107a7c922f5787496298c9bd6b5bfa13889bc0bb1\\\n        0f2e280f2673b20cb2191b3f747978b1483ed5890a8f1e9b4ef8665dff89aeff7e04820fcb58e76837b70b36b4\\\n        946ecf9ebe8fba5e510503f922f8e39500946e3ba0fd0a28c3a881101047c77426f1160e2835ecd5cdfc3c85d7\\\n        78adf772e0b5f5d5913cda27866ff4a68981bb0b247705d4a7a13e0cf5df9064561c207ad89d6bd10ed4faf445\\\n        ceca3d7f86bbdcd652aaf5c547a0071a203dca41ee8ec829aff439308e3dd8d470556949fb583c7ed1bd6c7854\\\n        bb629c27db1c0caa83e77e13d983d022e1865331aa5f67de9bca45976769e471933efa23a7d5fe8e03b8eed13a\\\n        3920db5d0f4052f811bcd1955c217ad35a8b75478eb3f2e077ecc810af955e23d57d0b957bf2104261c9f16ba6\\\n        a16f119f6d83e2b35b1a28b6fc7a029bcec426c495328cba2082e252a65c7267a9a83365475cc6b4672f77d481\\\n        40ec81e987a366445896d2ae795891105da2f608b56dca4a3e4166c6a0338423e51de87dcbfe3717817893141c\\\n        8b61f1377d82379374f5ad121cb9e04cf51776a20bc8b0ccaa51862efa4f51d52333818ee4877c039261bcd8dc\\\n        152db0a6119f3724603b4aaf9994eaf197d5adbcb723d1dc6ebdd8d2cfd37952c4128f3b79556ea134b7193dcf\\\n        afdc170fa41bf528ba4deac3f3d79d4407db9fd076aaca428efe74dbbc1bc7fad8b57ab1a693330f49aab1ddcc\\\n        f26bdc853360568f201c8fea22c816ae67afff2668debe399f951e72144cfa93dea4f18d1ee734ed2bf350fed9\\\n        d126c9b660f6b27ba5e13f15a8be20837e071c52d7588c0a856a969903419e91d47e7011235886759942c1c0e1\\\n        896e1621b2d23df869694531248722482999c8600632a5ab2279907e29cb3c38994bfbe299cb368a72ef45ecaa\\\n        b9646b4f1e2f37f24aa954535b1ba220c8e91dfb8f81e56dc45ec4cb3181511fa5b1854096fb3f03f2aa052eb1\\\n        5111548f398b2a0ffeecd95498fef2bd7f25126507f63bd3803c3a9d1aff24563f7f0baf024307e9c75#6074\",\n        Nearest,\n        \"15049274867282653916783425765897232338286237097021544510.63055696334657926692700975852105\\\n        429908991325181901560777184807721684871576977542689434849596891044659963521044055457283641\\\n        367304991334226236960366994118987961185804836414630696056584495778598754606288486597978327\\\n        332370268104018122071463105903604569912790301532188931593783003198530412792016208481406460\\\n        177569545284296438034561831086095957417103960718034276692579871391678752019863068680376188\\\n        441084892942908419595289335759422879108451807263984856494740183999962091220506257869533189\\\n        151879060260534882539324732360323776701789524149049182180697710000483323367419829770508959\\\n        886298233038628402259126153349007515813222501560286947664943532169644098519601985837510236\\\n        220345218089637472842801890223279059211522040546360301667071765816467200381174390649332596\\\n        068474921226001156721359127966627401319343668619013146928630922944213877247277873392955093\\\n        504639915667110210542526572018725370251615388653789028473354868425502960351888594917293217\\\n        742712292964655900915998259809033409553076012583762301750508167459913039705278696038307105\\\n        198133823120123667996810391703122691279674638629684591634520584549627376733588876153831722\\\n        199369165407756045645488517825617351416613370266999295351664343537186993481753740631996768\\\n        537474147168714208012012313452364629821090786481898210882140832386720226088895885830143936\\\n        713915428453413001094302216345205004980013281182978168058085052927135299009881922560519790\\\n        174395754146412113876346433499785448301225654969985504964945207336686282652994022882395571\\\n        250336046288750244045997533647713495015654011612857222465008362940468446125031495141758501\\\n        398188163302138089732641998828146315905675208381266922364102647252983963785718802006725178\\\n        667871858412814374481149992996719213942377608145948042933317201168269095689729130915320304\\\n        63030844892155532105060912300876\",\n        \"0x9d1f2bb817353ba61ad13135f94f65b1b52180f58a183e.a16c2e5fd6b05e4155475ec873e35d0f193a9765\\\n        ef45957a4681138fd789135172e7be4efd1b67c60d22430a10832c82a4dc4a53156de6d8638ce6ffe089ebf880\\\n        f2e1c68c90b576b5dc0b99085865ed663bd642b7743ff5500d4c6d3e2cf4977af36122c98fc49e81ee87b80d89\\\n        3fe81fa07bdc5986b40bdb0bf7e6bfde432dcedd2063308cf685bfee2b964ff62d434434a9518683156e532f30\\\n        11f2ac8f98a75178cd412e00f2261a83f952b6a94bb97c280cb51f16f85891ddd7fe6ad8030e20422da11497e5\\\n        efe8d88db4f96479fd0b16f3703dca8946d944979a3454bb8155d8dbdd3a765584148771967d02f798d157b6a1\\\n        59e10461bc83d8ec9e55b557614c35d75b391c0c9d04aefe96cab5078bd3a13d5618ca219640c68919f1fefea9\\\n        a3d1e47a3fcbc8c19de2210708fd96fed608648d183fd4c1177d803a49f7d276f940aeef6feaffded75f8e03ce\\\n        33df996eeb67ac6c0bec62d821bfce22d9a30baa6f7f4963eb4eaa91707ba1b12fd6f3e04f75cfea4dc39c6488\\\n        d72e86c36ba981115f42300b97a7caa427023f16c4f66213cf0c18f04cb6aa66e4830cc7040b3103e27c2e800a\\\n        0bce21b653566628a5bb8b0becb80b441801f31aa100fb4539cf7e4d6d68815a666c11c6cf4ac97878c551c043\\\n        3750e9ab6fdeb65765ae3ece107302baf12b3086988bf4d0b37206bde4041cc7c4fa79d38170719e92c052187e\\\n        e810ed1b2b425c081512c7ee6ea722c413215229ebaecc207fb1126644e66dea7e0139682e90f91c71b579cd86\\\n        b91211305fe40770c3176e35b783732c2d74c8aa1a09da66c4f34dfa1f9fd35662c5c3d1f82eeb37498b121357\\\n        e73ed7eea79adeab91001b3c63b1f75aa82793cd1a2b39e1bb09ecf5c6522ccc46652d831abe3ad1f9bc301df5\\\n        2c646068fd97c0402a29caa4ea3f4de8e5fb8a4d537d45d685f87d05d95f7ba40fbb6a919e93b44fb78b9c80ea\\\n        6c0a75b4dff2f73844bf4f7172907d8165f606a47821da925eda50af0ce44be22fa2b36d56e1d1698a8#6074\",\n        Greater,\n    );\n    // - s == Limb::WIDTH in round_helper_2\n    // - n == 0 first time in round_helper_2\n    test(\n        \"2.169542166817986625468879014599175406350620737442480370882139687492174119453066131804433\\\n        632496405940270655469169364935548092764516132338564210201385531365409396738163453793191332\\\n        174443470862749001312126324808896288354477512722829484994475343567852816045883088813362218\\\n        109536965926916816038009290804934132950340684582117875938116310656669280480683072639988319\\\n        858148103369026349100099758130382359401952836454392007054797540845974323496094771400665868\\\n        125503436816661354237720713751777833086011158065863046075212704099660843597053397398549954\\\n        8348685976904925033580113969653312280822082757679509546197165e-14\",\n        \"0x6.1b51e41e16de577dd7b5a3a6222357b305d4e7313b1d47721ebe3d4275ef95b0d98ad997627ec7acc76f5\\\n        d426b7c5a9333cbc0dec080499093952901e541880379e2fdf874d1d931d1243e2b2ab072c0772ce94734ae65d\\\n        ff7afda628d44635b3fba75efa9bd2c10d8bdcb3a61a8b6a7697f598758d80bd808f17f8351b1761850fd75cc1\\\n        9f86409ac25dd27dd0ce7c26478dae9d50aff0210dc4fa18674fd87aa017255dabd141e1289a7e734e21577610\\\n        bf92b6ce4fe21881cc5209081e0536f0aeb1dcf6e288feeed183095b510c09e50c432ef280e742528c0c4dd6d2\\\n        5e65c8b6d19c28914472a930aae1ad7fac96f6442134ee95f3bd8E-12#1993\",\n        \"301180.0045246172416425721655892719573457356766058630317841133942315022590404351104810586\\\n        213517139802439747677458029756555586634849124296886483237621871644459126081050822492233083\\\n        707945595254133438910359944302659214080172068073620764660184379004827633051943726032292014\\\n        225559234820452819113849827971319776547835482966443724022128469656550054145203573809984759\\\n        336239968661049955088445384576034864711412948863817402256055440443111246220943775270251981\\\n        245519547063921282094595332683031347213016637666849460902039610984880445147686118036204784\\\n        051476863264255027838976527798504452504598268980029728768388473210371246534136227460265249\\\n        86471927\",\n        \"0x4987c.0128867b146bf9c05b0bb90d2c480c2b610c9c19a0a03f58f0d0aefa84d41a94dbc0c1206d80eab12\\\n        18d0f5e72e0b72a6f063fe0f604b1eedcc3760c7f60b2aa6e35735292ea939fa59fc7da94b3e86d7bbba5f8ef6\\\n        8136a9a4c5d98df58e4ad215fee20274cd18a324d8b66b0119d3cf93efacf51659a9814222c8f9b53fe6356392\\\n        e2b27f1ee07621f888214936f129248d805ae614b37cae5b83f51b2be167dc62ef96c1322204921369dc6c7475\\\n        c195aa735676f467be6a45d895b6b08fba56a7919ac216a6dc76cf9f5c3184a2ffa7b1bc3d8760c250d651afca\\\n        18aa90ff70ee4532482978816617fb02f0de87b2abd54886d1c7c16d62550d5fd8a4abb55b0c4ebb8c#2111\",\n        Nearest,\n        \"7.203473451839519375659920800256968930150281137907207966420457324091308743561158996788387\\\n        290694159461823269997598092194316979651412090098764718003237064733792291895103263169730962\\\n        123418174759909091404064508319172962888992299461557410206033700688023479037478761668781891\\\n        761303156472454780198812373188616203221872171676002219543916314587725944225532571475160352\\\n        707938049990541748698746656039607206067984173221685967465441429896808706646646536972493098\\\n        282122681082474772608417991249668805473092287771115239878542545454824251859441724816281902\\\n        754574769925885897122660854445163455617440019293712118274988718965330199709067927675503187\\\n        81705947e-20\",\n        \"0x1.542ca6851865ac89e311ac1608cac34c9fe637305345b739b624981a50028d6f60e7fd803167413e1285b\\\n        796e7a5ed37e1cb19125606ca9d15a697c9c497b14455aae6477ad96ffa4f216a14878a9802e8350d104f0b9d8\\\n        cd86ff511d7efbd74d40104b107a9d7f33d0e8894d3b157e46b7fd4e6386f823e75ae0efa9be33aac3e252d7d2\\\n        411f8e2afd3773f3914778d26a6b76f5569fd822db5a66db515e3cdd6699301b71cbdb73f07c24fb20d0c66059\\\n        fe1f236a4656c3f508e25958bdef5ca863d7950c5740d7849b46bde7e1a38b797265dedd7d4dfdaee7bcb69dce\\\n        887bddd7a7bbd45a6561cfad8cd840e7d95599a81bb274cc02a161439f7280459a15c9865ad5b658ed8E-16\\\n        #2111\",\n        Less,\n    );\n    // - n != 0 && tmp != 0 && tmp == mask in round_helper_2\n    // - s != Limb::WIDTH second time in round_helper_2\n    test(\n        \"7.967842945782984973942186035477141750978306951371418866981413625233901049016799636923049\\\n        043510064598367854094347269064974737243308027061881036076018766384961823690368428913274793\\\n        537e-19\",\n        \"0xe.b2b51b3ba9b3fa4c3c91f60bbe2f30efe9403d1c1ed1fa2688711592167dc11f579d747f20609a0e8704a\\\n        660072ec620d514ab31d0845381f10e96f76ac41c97c2a7b53849757dc846fdeE-16#599\",\n        \"4.290314881292277334232122993869736164625712811477787127079554140127474408529492187148865\\\n        860241941174878594521708166855716060386064937593774872957730026516247807479269506509835640\\\n        014575725456051856772978910171974972671741113731811243859146099959299700690748160884209812\\\n        639693266282036645473254451466381125403186024743001502094065938286200460441378264282871237\\\n        445194601993083290951436490295842815606015494575193282638997440331311694865085507331318327\\\n        437042408938144577985735854973264189023250983346696190654635795462654945584732891184659237\\\n        746883228154089313101793763347136552004708447204474905674167880735273390965084667673056531\\\n        378593414825374458582134295243495148718875340371312206621884585775967428131940924035968587\\\n        526069447315202760539547246403295371510536211424729007907823710381420209210303664575050843\\\n        559776729235120592670693730372232402604761499044741741752247404544150954858075273585139895\\\n        643242778698674255451287458469387850297372316908957826221759549123594364155475346755476293\\\n        552962991845182999537688763267208310118481794778770137863789646906639637779481228371710954\\\n        980900001879766864929946144490423459237336070803276511200399191948305713293997532907864745\\\n        24489311444825214442690999e-14\",\n        \"0xc.137f67f6b60895b6164f36c36d5b134858a21d493d7d49584a1811d76bd92f10b6d0aa0bea20843896e0f\\\n        d0d2e93957b024a1b5e7101d0f679c3dcc134107c20f0664acbfdf6bafac9013ae41ce018c62b6cf36043f13a8\\\n        1c35291946c79569662de17adff4ec759b1ccbe440675ef95167b0d5a5481ea6e7a6b998233e094436c8eeaefb\\\n        e21fa0f9c24aad8d11f378034d73a5daec0111cef1b0b8426dd5df78555318d44c992e40ad5fa98171908c4019\\\n        636becfe749a93747c965c11e84b68df48e887e933449d42c1ec5c2d6a7658e91f6d68333ddfde5719ca117d72\\\n        dadec43975eb0b6b6a076c4ada32d70b0e93250cf5e8836b11ad6a8b13a4a957de6221168782640f2313ca3716\\\n        3e4da0decaee000e5824d53c71d0a36a55295f8ad1c7a86eb35eab709891d1a6ac96a10448e0e307c7d6742d8d\\\n        0617a3e21978394d0393bc9be8e32ff2d87e85ae44c3a76ac79752bcca4927ca5dc6dcfc4db10793dc0cfc2161\\\n        24fdf30070db19fd8a89982adf45a408e08499b77cf25011c54cf9270bf491a2186e1a5fad26087812cc3c2446\\\n        ca7e5457d75f66fe9e736ad07c6b1fe4b20eaf1f073d454f371f659f7402d24e6666c8e212ddccf50c22209ca5\\\n        7651a266ecba0559cacf587691f7f7df3389d9968023d71b412cc20516c9b1d00f1392474c6683bd0fd6c6dc7a\\\n        705d88E-12#3966\",\n        Nearest,\n        \"0.000018571697337476093645597974800042221391343383471511758884717235995391699590980821846\\\n        925772010524277797520625056343676345716562878283777572676679678398279369283853673423775272\\\n        117775978501001731220831012727542639628984101788862199591237806493805996059161201835253203\\\n        204357442043212398495525692960904672132359565047969002327766123188917268873022220728326927\\\n        266813579456518458545345939557868848624450974456390610446369728959726525392113471132021539\\\n        038960803550352390128253151270734177749632737865390247648212171456318006032507634424453843\\\n        795159031314496937836591202252458892414236797451738560115150573320872948069964155298984838\\\n        456270978739037104719669912968807593222214861520588395175617611807975267322946381339673265\\\n        479787948188151606275111200784895864164305724683464061829109671306661764726602634895903888\\\n        287506327660181397735839535481997625450956961420572462126703944263526095290954835871182404\\\n        868513321447417245068813964246287015709186652991049553947407472630595976266674750290084010\\\n        397575525528176465754260767775733418629588880876176812207672741703984898153224615968196909\\\n        775917982890995046346113085550279268258183711136206964350043642244181512435164664671221839\\\n        6370838653686792137638621224928\",\n        \"0x0.00013794d52b8b1e96ced9de16a585696e655c080cbd5da8030eef302763f4138b28d7261786b8ff50bc6\\\n        9d0a5f06f20dad7ee2a65fae9caeeaee187ea820eae6fd4c8a673a92def1c9a165c1aeec8807ddb464eac6f550\\\n        6dbe6d6e3a21a035c4472d414f4887b05775ede2ad98b9b380b663c0929394c811648792ef20f0756b6bad50de\\\n        099fda3dd792ae5616df8837945c3cb4cd833fb9bf0db07243887c0a8fedba7030c428024be8572bca9398f563\\\n        b2a661574fd7faf130ac3d404dbe94b7e0ca06f440962616e1879d4f15895a10229f04969c26dbb9a1b733f734\\\n        fd2be1c88c7b20af178cd1d3fa116fba33a435b040155b5f5f28f0668b798810c2acb1faf0581e46cc71e9b07f\\\n        c9e4ebcd8a96a7d7d318d649e4468baa2ce2cdf9b1adf74f6a6b8b95a3eed5991934327ddfeb243e80db0c230e\\\n        d593df31dce1201e64430a27d39e6760dcf2086c1cb86bfb4e9211f18940b72d1a492a5b9109c0fdf4f5fa9fce\\\n        9e0ec199756ee5f8e69ba7ded6b7507facbc46df62adaa4546b3113a80e7ea40bab782194bfd006099f6a79bb8\\\n        19aad950497cae351fdc370756b86b3188e5c2cf71ed56fdb3683c9cc38facff80b0f2076d0f3b3a8605ca24d2\\\n        c8b6301601e23b50ea0940f7ba05f92ddd4a644cca6e420d6bfcd06caab9c695ba67b857bc57e1000b5935d0a8\\\n        79821217280#3966\",\n        Less,\n    );\n    // - rm == Nearest && shift == 0 first time in div_float_significands_general\n    test(\n        \"3.494003589335061592114850452482839587826456952956376068177291318828682713177358264760784\\\n        874304744009907216335963217912223351596098015455390432300579562836209635380394751634810606\\\n        195414389573610568068623776330707730813932586805062287543490729241818555718410383777926489\\\n        343323917900958772688451527795643412381235039158654803215405274640835172391547486080681691\\\n        827169629800140882523056966137099117587677259077996268577162491409610597231997851472454718\\\n        312803304389117924206548413988545367622912505139619073824279361037770537659001099972259551\\\n        367613373821227769095845567435994753397767332318253172120529133505790353120177308303588487\\\n        770407205738279213609665027613843515660027068482463985188375646552261141849026408186728824\\\n        80307838589616979262426550353243006148083216398932181e-12\",\n        \"0x3.d7797e014d587584d7875beed50257a2555726437bf03fdebac1110cae2c4b64f09f9a338bf2ca8b1fcf5\\\n        e0128d7f387a40893706e25c04e65fdd316e3fc348d2478632d632bae209325b6c681dde52405cd7f8d9707d7f\\\n        5d6de0abb73e130c41c21c4537ce41381fc43788187dab4fa280fa46503f1890d663ca441f49a6a7e2b712e710\\\n        4c826535fdf1c8ae0282d162e3d128a982e44f67c6104624863e7f3c2c60833df521e5bab88feddd4843e4b50b\\\n        81ba442bc612787ad38f640412f6cff81df9793590dfa6a0debdd7f2f6de7a089fc50d597d700dbeeecfc9d795\\\n        ceb9a69d05db5c520717ddd7e73fabaea4e2cb06b1e1874b8b541dfca2083cb277e4d1bbefa48c0a427afea0a5\\\n        87cd5085c2ba28c1cad42a97be72844e851abf698ac844915e9f5ac4af406a2c354aa055f3c0994b7932d1bdb7\\\n        b4999768f776148E-10#2560\",\n        \"8.388557903692744678886673027706512178020882171440574341138664910770681048759242342335520\\\n        689291884051853125391850946672822384185374426629671262437149651332606541726962233658521936\\\n        440197380293004778812876511148916284206096731251130678261803308370362817534297504354768207\\\n        175302739282372189357904919163400327254111204148827422042723518774290057028465296755126014\\\n        371014512774422430414368313070504306047237723842986944935010614200247398223867859750512432\\\n        528263508555538801970472032683504663202558316239308702078808690323956381650112536926354687\\\n        819619269837340011822483859668579241157516055938780563664184620140501025776680716962470155\\\n        2e-35\",\n        \"0x6.f80c88bef08546fc8a21f0f2152ee0612eebad2635acbe0d49ce7179b387d0719cd657923976ec2796026\\\n        5e330a5e71c0cd8417c2cf919556130f9b353cdf2435349f846c895ede372648bccd9c217f1bb7c3e4197c1806\\\n        c4744c8a05ddf4f67946a4972f056d84028e7023d956a95b2ff067c093002267f7015fecb9ca5ed8f58dde48d7\\\n        4510e965bfa6478370f4e71e5a240dabdd9a4d6e000d4af93eea8510c6c4e095290bce062925fd9a7245caff37\\\n        8b7be01d3b94b56154cbeb98c26f78338a98e416fa9acc3bd12c4953b058efdcdbe56335f952208a15166babaa\\\n        698da808f96df97655d3f5cdb4768e6370755a01515d4ad54f625432fc742e9121b7cce4fdb08E-29#2088\",\n        Nearest,\n        \"41652017300815899948547.94831484736938823572318695739742204735159366375620848030675947597\\\n        937407214848121136435440017047965685656179645007771422864559798518659544278806178160023554\\\n        020245599674536568425190916908552958650848910192845046055088066614557330847090320384899468\\\n        575304634050066348271499359839369427201019441174516439045175255034723132436872248790761539\\\n        506937527488424041602486298663492699846695028977559705152038731125314966620233281505474337\\\n        677248672173837029868825260085661764008715204976773612281854954844288452423998027475082981\\\n        779489389492756600188312999400831430516184077432877044587246391185262444911853744883006186\\\n        684049728461939709785134255700251964580618924591175050653894151676243677123400686218961075\\\n        24208104943935667403367286485079704207117845193523456\",\n        \"0x8d1f5db9d3f145a7603.f2c4c307c343da5b63ef331aa97f5e951921921a937336258bc4ab65fdf9d715d36\\\n        ef6755e61dd29859283e35c618271ec076a196c3ddb06ce536bafe52ad10a521ebfdcda2a3839fce6eadd33d87\\\n        eba1d25c5eacfa66f0af4f1ce568be4792717319611eb807fe7fc0d855f2cf1b099f908a269208b3ee36d33e71\\\n        3912e0557515bf16566f8cc4c8c45fd6bb2ced1b3d3f27c9b272c6e5dfaacdd66335f658951d70cd7b3190aac8\\\n        b90d7e564b5c0ac68a04f4681a552c50de11c466e3ac1230d426fdc851e7d5705e73d7ad30a82c2febb82c46b4\\\n        93762b8d7c80e514c1fe29a64d4189fc176b72bb816f1223676b93d38dc33a2fd578eaf5fa512468b21e723d6c\\\n        d5595dac5bfd84c94e4826fc5b9aff74dec22c3cb43d7970a1359eb2642295a920a70da20a166db400602f0f4f\\\n        2aee9255f2251c#2560\",\n        Greater,\n    );\n    // - !round_helper_2 in div_float_significands_general\n    test(\n        \"3.999999999999999999999999999999999999999999999999999999999999999999999999999447285212473\\\n        955543975273480780774427448575976676077991358482977909210124597604668289823519777773553500\\\n        1249731874464215297923136674027554116062077582682832144200801849365234375\",\n        \"0x3.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000000000000000#2090\",\n        \"3.944304526105059027058642826413931148366032175545115023851394653320312500000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000038180485e-31\",\n        \"0x8.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000001ffffffeE-26#2567\",\n        Nearest,\n        \"10141204801825835211973625643007.99999999999999999999999999999999999999999999859870153567\\\n        518292907627041671008386871973805812348422824293171611020891731413939851336181163787841796\\\n        874999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        99999999999999999999999999999999999999999999999018341217\",\n        \"0x7fffffffffffffffffffffffff.fffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffe0000002#2567\",\n        Less,\n    );\n    // - x_exp < Float::MIN_EXPONENT not special && sign && rm == Ceiling | Up\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"3.0\",\n        \"0x3.0#2\",\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    // - x_exp < Float::MIN_EXPONENT not special && !sign && rm == Floor | Up\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"-3.0\",\n        \"-0x3.0#2\",\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    // - exp_diff + 2 < Float::MIN_EXPONENT && sign && rm == Ceiling | Up\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    // - exp_diff + 2 < Float::MIN_EXPONENT && !sign && rm == Floor | Up\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    // - x_exp > Float::MAX_EXPONENT && sign && rm == Floor | Down\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"0.8\",\n        \"0x0.c#2\",\n        Floor,\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Less,\n    );\n    // - x_exp > Float::MAX_EXPONENT && !sign && rm == Ceiling | Down\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"-0.8\",\n        \"-0x0.c#2\",\n        Ceiling,\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        Greater,\n    );\n    // - exp_diff > Float::MAX_EXPONENT && sign && Floor | Down\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        Floor,\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Less,\n    );\n    // - exp_diff > Float::MAX_EXPONENT && !sign && Floor | Down\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        Ceiling,\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        Greater,\n    );\n}\n\n#[test]\nfn div_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::ONE.div_round(THREE, Exact));\n    assert_panic!(Float::ONE.div_round_val_ref(&THREE, Exact));\n    assert_panic!(Float::ONE.div_round_ref_val(THREE, Exact));\n    assert_panic!(Float::ONE.div_round_ref_ref(&THREE, Exact));\n\n    assert_panic!({\n        let mut x = Float::ONE;\n        x.div_round_assign(THREE, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::ONE;\n        x.div_round_assign_ref(&THREE, Exact)\n    });\n}\n\n#[test]\nfn test_div_prec_round() {\n    let test = |s, s_hex, t, t_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (quotient, o) = x.clone().div_prec_round(y.clone(), prec, rm);\n        assert!(quotient.is_valid());\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n        assert_eq!(o, o_out);\n\n        let (quotient_alt, o_alt) = x.clone().div_prec_round_val_ref(&y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = x.div_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = x.div_prec_round_ref_ref(&y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_prec_round_assign(y.clone(), prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_prec_round_assign_ref(&y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (quotient_alt, o_alt) = div_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_quotient, rug_o) = rug_div_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_quotient)),\n                ComparableFloatRef(&quotient),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Floor,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Down,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Up,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Exact,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Floor,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Ceiling,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Down,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Up,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Nearest,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"0.008\", \"0x0.02#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.02\", \"0x0.04#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", 1, Down, \"0.008\", \"0x0.02#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", 1, Up, \"0.02\", \"0x0.04#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.008\", \"0x0.02#1\", Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"0.00812\",\n        \"0x0.0214#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Down,\n        \"0.00812\",\n        \"0x0.0214#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"-0.02\",\n        \"-0x0.04#1\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-0.008\",\n        \"-0x0.02#1\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"-0.008\",\n        \"-0x0.02#1\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"-0.02\",\n        \"-0x0.04#1\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"-0.008\",\n        \"-0x0.02#1\",\n        Greater,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"-0.00813\",\n        \"-0x0.0215#10\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"-0.00812\",\n        \"-0x0.0214#10\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Down,\n        \"-0.00812\",\n        \"-0x0.0214#10\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"-0.00813\",\n        \"-0x0.0215#10\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"-0.00813\",\n        \"-0x0.0215#10\",\n        Less,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Floor, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Down, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Up, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Nearest, \"0.5\", \"0x0.8#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Exact, \"0.5\", \"0x0.8#1\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Floor,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Ceiling,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Down,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Up,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Nearest,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Exact,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"0.4497\",\n        \"0x0.732#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"0.4497\",\n        \"0x0.732#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-0.4497\",\n        \"-0x0.732#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-0.4497\",\n        \"-0x0.732#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-0.4497\",\n        \"-0x0.732#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-0.4497\",\n        \"-0x0.732#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-0.4502\",\n        \"-0x0.734#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"0.4497\",\n        \"0x0.732#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"0.4497\",\n        \"0x0.732#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"0.4502\",\n        \"0x0.734#10\",\n        Greater,\n    );\n\n    // - (rm == Ceiling || rm == Up) && overflow in div_float_significands_long_by_short\n    test(\n        \"2.493205886061172926\",\n        \"0x2.7e42bdaed3d31b2#61\",\n        \"7.459893537e20\",\n        \"0x2.870ae94cE+17#33\",\n        5,\n        Ceiling,\n        \"3.4e-21\",\n        \"0x1.0E-17#5\",\n        Greater,\n    );\n\n    // - rm != Nearest third time in div_float_significands_genera\n    test(\n        \"3.7563361266e88\",\n        \"0x4.b87f4dfa0E+73#36\",\n        \"6.769173652614128677797571270436826716e-13\",\n        \"0xb.e8909656207637d3379c02628519c4E-11#123\",\n        63,\n        Ceiling,\n        \"5.549179736559369991e100\",\n        \"0x6.57b76abe8193e56E+83#63\",\n        Greater,\n    );\n    // - (rm == Up || rm == Ceiling) && (round_bit != 0 || sticky != 0) && carry in\n    //   div_float_significands_general\n    test(\n        \"4.70916604581e-30\",\n        \"0x5.f8363584bE-25#39\",\n        \"341290809831481093.63402342431195212374059\",\n        \"0x4bc822eed1c5f05.a24f5bf051591756f951#139\",\n        1,\n        Ceiling,\n        \"2.0e-47\",\n        \"0x2.0E-39#1\",\n        Greater,\n    );\n    // - rm != Nearest && ((rm != Ceiling && rm != Up) || inex == 0) && (inex == 0 || rm != Exact)\n    //   in div_float_significands_general\n    // - goto_sub_1_ulp in div_float_significands_general\n    test(\n        \"6265419941341407687.894108147333\",\n        \"0x56f33e3db44da9c7.e4e44583e2#102\",\n        \"28506201793260972591.2041505871822190859316631273737217979877602592305648246097\",\n        \"0x18b9a5f7fa6ec6a2f.3443367f6825dd51709bc60beed373653861dd1a1c6c0422#256\",\n        63,\n        Floor,\n        \"0.2197914680735399977\",\n        \"0x0.384440ef50d090080#63\",\n        Less,\n    );\n    // - rm == Floor || rm == Down fourth time in div_float_significands_general\n    // - (rm == Floor || rm == Down) fourth time && shift != 0 in div_float_significands_general\n    test(\n        \"1.274876025e31\",\n        \"0xa.0e9775E+25#28\",\n        \"7.104011072486714881105976022274735719942619445087760266603169705559e-82\",\n        \"0x5.6412fa517e8e5c9e2826903dbe9c6b4f020acbf4d07a5f83b6e4008E-68#222\",\n        126,\n        Floor,\n        \"1.79458620199896394199805694868744557483e112\",\n        \"0x1.dd946a676df629632baf4759d5af1088E+93#126\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up fourth time in div_float_significands_general\n    // - (rm == Ceiling || rm == Up) fourth time && shift != 0 in div_float_significands_general\n    test(\n        \"1.766000056026770292793619415e30\",\n        \"0x1.64a410213aff5d6e713e280E+25#90\",\n        \"3.8777897715163284337835091275987988e-9\",\n        \"0x1.0a7acc91ecf72f35cdef4a25d008eE-7#116\",\n        63,\n        Ceiling,\n        \"4.554140786585790019e38\",\n        \"0x1.569d8fa574bc1b5cE+32#63\",\n        Greater,\n    );\n    // - (rm == Floor || rm == Down) fourth time && shift == 0 in div_float_significands_general\n    test(\n        \"2.6837e8\",\n        \"0xf.ffE+6#12\",\n        \"33554432.0156249999999999\",\n        \"0x2000000.03fffffffffff8#79\",\n        64,\n        Floor,\n        \"7.9980468712756191975\",\n        \"0x7.ff7ffff001000018#64\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) fourth time && shift == 0 in div_float_significands_general\n    test(\n        \"0.00341799855229\",\n        \"0x0.00e0007ffff8#37\",\n        \"9444877080927366283263.8\",\n        \"0x20001ffffffffffffff.c#76\",\n        64,\n        Ceiling,\n        \"3.6188915144233536057e-25\",\n        \"0x6.fffd0002bffd4008E-21#64\",\n        Greater,\n    );\n    // - cmp_s_r == Equal && shift == 0 in div_float_significands_general\n    test(\n        \"6699743.0549682103909956055738813882394392365647386167825\",\n        \"0x663adf.0e126589f2efed5e335a996cf4ea2b00000000000#186\",\n        \"2.7716996157956048532084742e-18\",\n        \"0x3.320fb3ad0fa6bc833b14E-15#82\",\n        64,\n        Exact,\n        \"2.4171966604126677691e24\",\n        \"0x1.ffdc7e57cc8990bcE+20#64\",\n        Equal,\n    );\n    // - (32-bit) len == 0 in sub_helper\n    test(\n        \"30600.896887617100679\",\n        \"0x7788.e59a6d47a2818#64\",\n        \"2502994226528294594711254131620329726924950421806.930251136099954006921970343593452748426\\\n        707752157088293012113325450782206798004004382505336607707515733277073230960543511755657896\\\n        564954610313805343294199781328288665758818764110630501992193446364134574345717105834955361\\\n        7609386520869921223421139170307521302744186647065523683732731123797753054753663\",\n        \"0x1b66e24958fe115307da9ef9c4f815e31129d412e.ee24f03e9dbbd6cdaa800176f4f7a592b62d2ecb1428c\\\n        19779d86494af5a809600728d36c503347da5f0182f00935e63a628c673a55a1e67334c368efde2d7a0fccbc62\\\n        0edc630bdd9fafc83b3088a3186480eefe67a7c19b91b866c079c0716d7b844259f598eeb31d6c0baf035c6bc4\\\n        6b11b5efad4f3ae582c7740#1151\",\n        32,\n        Ceiling,\n        \"1.2225716132e-44\",\n        \"0x4.5cbe7760E-37#32\",\n        Greater,\n    );\n    // - rm == Up || rm == Ceiling && carry in div_float_significands_general\n    test(\n        \"2.454546732648863276547885977493137821487607756249724782555774558593552627360857928230048\\\n        942018665976138591785782565939256583959305212359451403757412054481726126552732229930964269\\\n        470905492198653519153594970703124999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        995761114627674791277020932519574469505017610728137410250159407014720169738824650046673749\\\n        059339474479527195633303962573451642912661719349979993453218111358455268175773121496346851\\\n        580476856645369527796626919786850732045813122714395701160155300736782415936562761674226693\\\n        028929972451809327089060718204876263534635026488050357020524924317959135992439056643999723\\\n        656960561739673936265216544476386688997222734833105296938067057205929214479610015975275932\\\n        718619380628277147130611593861916399934357066581330096178050556305086195135562253719174061\\\n        496425118601354010153670564319137109364713055282273218494183562236985834389291157056469689\\\n        9828846337814e-91\",\n        \"0x7.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000E-76#4517\",\n        \"0.015625000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000771048757510508716764719334683019132168263108153512725551350734409293871565\\\n        903519457201213361797567020084883497703807999422859208123581192925346248118136084792628172\\\n        988363113468168413497993606331107182531734570308778128025953654408272649725745457159283262\\\n        0134958821588759455527143\",\n        \"0x0.0400000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffff\\\n        fffffffffff8000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000#3655\",\n        2337,\n        Ceiling,\n        \"1.570909908895272496990647025595608205752068963999823860835695717499873681510949074067231\\\n        322891946224728698742900842201124213733955335910048898404743714868304720993748627155817132\\\n        46137951500713825225830078125e-89\",\n        \"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000E-74#2337\",\n        Greater,\n    );\n}\n\n#[test]\nfn div_prec_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::one_prec(1).div_prec_round(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).div_prec_round_val_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).div_prec_round_ref_val(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).div_prec_round_ref_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.div_prec_round_assign(Float::two_prec(1), 0, Floor)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.div_prec_round_assign_ref(&Float::two_prec(1), 0, Floor)\n    });\n\n    assert_panic!(Float::ONE.div_prec_round(THREE, 1, Exact));\n    assert_panic!(Float::ONE.div_prec_round_val_ref(&THREE, 1, Exact));\n    assert_panic!(Float::ONE.div_prec_round_ref_val(THREE, 1, Exact));\n    assert_panic!(Float::ONE.div_prec_round_ref_ref(&THREE, 1, Exact));\n    assert_panic!({\n        let mut x = Float::ONE;\n        x.div_prec_round_assign(THREE, 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::ONE;\n        x.div_prec_round_assign_ref(&THREE, 1, Exact)\n    });\n}\n\n#[test]\nfn test_div_rational() {\n    let test = |s, s_hex, t, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let quotient = x.clone() / y.clone();\n        assert!(quotient.is_valid());\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let quotient_alt = x.clone() / &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let quotient_alt = &x / y.clone();\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let quotient_alt = &x / &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n\n        let mut quotient_alt = x.clone();\n        quotient_alt /= y.clone();\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let mut quotient_alt = x.clone();\n        quotient_alt /= &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_div_rational(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::from(&y)\n            ))),\n            ComparableFloatRef(&quotient)\n        );\n\n        let quotient_alt =\n            div_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n\n        if x.is_normal() {\n            let quotient_alt =\n                div_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), Nearest)\n                    .0;\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n        }\n    };\n    test(\"NaN\", \"NaN\", \"123\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"123\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"123\", \"-Infinity\", \"-Infinity\");\n    test(\"NaN\", \"NaN\", \"0\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"0\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"0\", \"-Infinity\", \"-Infinity\");\n\n    test(\"0.0\", \"0x0.0\", \"0\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"0\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"123\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"123\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-123\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-123\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"1/3\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", \"-0.0\", \"-0x0.0\");\n    test(\"123.0\", \"0x7b.0#7\", \"1\", \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", \"0\", \"Infinity\", \"Infinity\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", \"-Infinity\", \"-Infinity\");\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", \"0.5\", \"0x0.8#1\");\n    test(\"1.0\", \"0x1.0#2\", \"2\", \"0.5\", \"0x0.8#2\");\n    test(\"1.0\", \"0x1.000#10\", \"2\", \"0.5\", \"0x0.800#10\");\n    test(\"1.0\", \"0x1.000#10\", \"3/2\", \"0.667\", \"0x0.aac#10\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"3/2\",\n        \"0.666666666666666666666666666667\",\n        \"0x0.aaaaaaaaaaaaaaaaaaaaaaaab#100\",\n    );\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", \"1.5\", \"0x1.8#2\");\n    test(\"3.0\", \"0x3.00#10\", \"2\", \"1.5\", \"0x1.800#10\");\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", \"2.0\", \"0x2.00#10\");\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n    );\n\n    // n and d both powers of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    // - only n a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"2/3\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    // - only d a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"3\",\n        \"too_big\",\n        \"0x1.0E+268435455#1\",\n    );\n    // - neither n nor d a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"5/3\",\n        \"too_big\",\n        \"0x2.0E+268435455#1\",\n    );\n}\n\n#[test]\nfn test_div_rational_prec() {\n    let test = |s, s_hex, t, prec, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (quotient, o) = x.clone().div_rational_prec(y.clone(), prec);\n        assert!(quotient.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let (quotient_alt, o_alt) = x.clone().div_rational_prec_val_ref(&y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = x.div_rational_prec_ref_val(y.clone(), prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = x.div_rational_prec_ref_ref(&y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_rational_prec_assign(y.clone(), prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_rational_prec_assign_ref(&y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            div_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        if x.is_normal() {\n            let (quotient_alt, o_alt) =\n                div_rational_prec_round_direct(x.clone(), y.clone(), prec, Nearest);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n        }\n\n        let (rug_quotient, rug_o) = rug_div_rational_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_quotient)),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"123\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"0\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"1\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", \"1\", 10, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"3/2\", 1, \"0.5\", \"0x0.8#1\", Less);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        10,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 10, \"1.5\", \"0x1.800#10\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", 1, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", 10, \"2.0\", \"0x2.00#10\", Equal);\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n}\n\n#[test]\nfn div_rational_prec_fail() {\n    assert_panic!(Float::NAN.div_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.div_rational_prec_val_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::NAN.div_rational_prec_ref_val(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.div_rational_prec_ref_ref(&Rational::ZERO, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.div_rational_prec_assign(Rational::ZERO, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.div_rational_prec_assign_ref(&Rational::ZERO, 0)\n    });\n}\n\n#[test]\nfn test_div_rational_round() {\n    let test = |s, s_hex, t, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (quotient, o) = x.clone().div_rational_round(y.clone(), rm);\n        assert!(quotient.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let (quotient_alt, o_alt) = x.clone().div_rational_round_val_ref(&y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = x.div_rational_round_ref_val(y.clone(), rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = x.div_rational_round_ref_ref(&y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_rational_round_assign(y.clone(), rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_rational_round_assign_ref(&y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_quotient, rug_o) = rug_div_rational_round(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::exact_from(&y),\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_quotient)),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (quotient_alt, o_alt) =\n            div_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        if x.is_normal() {\n            let (quotient_alt, o_alt) =\n                div_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"123\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"123\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"123\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"-123\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"1/3\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Floor, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Down, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Up, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Exact, \"123.0\", \"0x7b.0#7\", Equal);\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", Floor, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Ceiling, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Down, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Up, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Nearest, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Exact, \"0.5\", \"0x0.8#1\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        Floor,\n        \"0.666\",\n        \"0x0.aa8#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        Ceiling,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        Down,\n        \"0.666\",\n        \"0x0.aa8#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        Up,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        Nearest,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"3/2\",\n        Floor,\n        \"0.666666666666666666666666666666\",\n        \"0x0.aaaaaaaaaaaaaaaaaaaaaaaaa#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"3/2\",\n        Ceiling,\n        \"0.666666666666666666666666666667\",\n        \"0x0.aaaaaaaaaaaaaaaaaaaaaaaab#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"3/2\",\n        Down,\n        \"0.666666666666666666666666666666\",\n        \"0x0.aaaaaaaaaaaaaaaaaaaaaaaaa#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"3/2\",\n        Up,\n        \"0.666666666666666666666666666667\",\n        \"0x0.aaaaaaaaaaaaaaaaaaaaaaaab#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"3/2\",\n        Nearest,\n        \"0.666666666666666666666666666667\",\n        \"0x0.aaaaaaaaaaaaaaaaaaaaaaaab#100\",\n        Greater,\n    );\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", Floor, \"1.5\", \"0x1.8#2\", Equal);\n    test(\"3.0\", \"0x3.0#2\", \"2\", Ceiling, \"1.5\", \"0x1.8#2\", Equal);\n    test(\"3.0\", \"0x3.0#2\", \"2\", Down, \"1.5\", \"0x1.8#2\", Equal);\n    test(\"3.0\", \"0x3.0#2\", \"2\", Up, \"1.5\", \"0x1.8#2\", Equal);\n    test(\"3.0\", \"0x3.0#2\", \"2\", Nearest, \"1.5\", \"0x1.8#2\", Equal);\n    test(\"3.0\", \"0x3.0#2\", \"2\", Exact, \"1.5\", \"0x1.8#2\", Equal);\n\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", Floor, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"3/2\",\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", Down, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", Up, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"3/2\",\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", Exact, \"2.0\", \"0x2.00#10\", Equal);\n\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        Floor,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        Ceiling,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        Down,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        Up,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        Nearest,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        Exact,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Floor,\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Ceiling,\n        \"2.0943951023931957\",\n        \"0x2.182a4705ae6cc#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Down,\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Up,\n        \"2.0943951023931957\",\n        \"0x2.182a4705ae6cc#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Nearest,\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Floor,\n        \"-2.0943951023931957\",\n        \"-0x2.182a4705ae6cc#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Ceiling,\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Down,\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Up,\n        \"-2.0943951023931957\",\n        \"-0x2.182a4705ae6cc#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Nearest,\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Floor,\n        \"-2.0943951023931957\",\n        \"-0x2.182a4705ae6cc#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Ceiling,\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Down,\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Up,\n        \"-2.0943951023931957\",\n        \"-0x2.182a4705ae6cc#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        Nearest,\n        \"-2.0943951023931953\",\n        \"-0x2.182a4705ae6ca#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Floor,\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Ceiling,\n        \"2.0943951023931957\",\n        \"0x2.182a4705ae6cc#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Down,\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Up,\n        \"2.0943951023931957\",\n        \"0x2.182a4705ae6cc#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        Nearest,\n        \"2.0943951023931953\",\n        \"0x2.182a4705ae6ca#53\",\n        Less,\n    );\n}\n\n#[test]\nfn div_rational_round_fail() {\n    const THREE: Rational = Rational::const_from_unsigned(3);\n    assert_panic!(Float::ONE.div_rational_round(THREE, Exact));\n    assert_panic!(Float::ONE.div_rational_round_val_ref(&THREE, Exact));\n    assert_panic!(Float::ONE.div_rational_round_ref_val(THREE, Exact));\n    assert_panic!(Float::ONE.div_rational_round_ref_ref(&THREE, Exact));\n    assert_panic!({\n        let mut x = Float::ONE;\n        x.div_rational_round_assign(THREE, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::ONE;\n        x.div_rational_round_assign_ref(&THREE, Exact)\n    });\n}\n\n#[test]\nfn test_div_rational_prec_round() {\n    let test = |s, s_hex, t, prec, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (quotient, o) = x.clone().div_rational_prec_round(y.clone(), prec, rm);\n        assert!(quotient.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let (quotient_alt, o_alt) = x.clone().div_rational_prec_round_val_ref(&y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = x.div_rational_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = x.div_rational_prec_round_ref_ref(&y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_rational_prec_round_assign(y.clone(), prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut quotient_alt = x.clone();\n        let o_alt = quotient_alt.div_rational_prec_round_assign_ref(&y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        if x.is_normal() {\n            let (quotient_alt, o_alt) =\n                div_rational_prec_round_direct(x.clone(), y.clone(), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n\n            let (quotient_alt, o_alt) =\n                div_rational_prec_round_direct_val_ref(x.clone(), &y, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n\n            let (quotient_alt, o_alt) =\n                div_rational_prec_round_direct_ref_val(&x, y.clone(), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n\n            let (quotient_alt, o_alt) = div_rational_prec_round_direct_ref_ref(&x, &y, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_quotient, rug_o) = rug_div_rational_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_quotient)),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"123\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Floor, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Down, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Up, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Nearest, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Exact, \"0.5\", \"0x0.8#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Floor, \"0.5\", \"0x0.800#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2\",\n        10,\n        Ceiling,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Down, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Up, \"0.5\", \"0x0.800#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2\",\n        10,\n        Nearest,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Exact, \"0.5\", \"0x0.800#10\", Equal);\n\n    test(\"1.0\", \"0x1.000#10\", \"3/2\", 1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\"1.0\", \"0x1.000#10\", \"3/2\", 1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test(\"1.0\", \"0x1.000#10\", \"3/2\", 1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        10,\n        Floor,\n        \"0.666\",\n        \"0x0.aa8#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        10,\n        Ceiling,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        10,\n        Down,\n        \"0.666\",\n        \"0x0.aa8#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        10,\n        Up,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"3/2\",\n        10,\n        Nearest,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"3/2\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", 1, Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", 1, Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"3/2\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"3/2\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        10,\n        Up,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"3/2\",\n        10,\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Floor,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Ceiling,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Down,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Up,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Floor,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Ceiling,\n        \"2.098\",\n        \"0x2.19#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Down,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Up,\n        \"2.098\",\n        \"0x2.19#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Nearest,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Floor,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Ceiling,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Down,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Up,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Nearest,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Floor,\n        \"-2.098\",\n        \"-0x2.19#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Ceiling,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Down,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Up,\n        \"-2.098\",\n        \"-0x2.19#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Nearest,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Floor,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Ceiling,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Down,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Up,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        1,\n        Nearest,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Floor,\n        \"-2.098\",\n        \"-0x2.19#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Ceiling,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Down,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Up,\n        \"-2.098\",\n        \"-0x2.19#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3/2\",\n        10,\n        Nearest,\n        \"-2.094\",\n        \"-0x2.18#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Floor,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Ceiling,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Down,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Up,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Floor,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Ceiling,\n        \"2.098\",\n        \"0x2.19#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Down,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Up,\n        \"2.098\",\n        \"0x2.19#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3/2\",\n        10,\n        Nearest,\n        \"2.094\",\n        \"0x2.18#10\",\n        Less,\n    );\n}\n\n#[test]\nfn div_rational_prec_round_fail() {\n    assert_panic!(Float::one_prec(1).div_rational_prec_round(Rational::ONE, 0, Exact));\n    assert_panic!(Float::one_prec(1).div_rational_prec_round(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).div_rational_prec_round_val_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).div_rational_prec_round_ref_val(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).div_rational_prec_round_ref_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.div_rational_prec_round_assign(Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.div_rational_prec_round_assign_ref(&Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n}\n\n#[test]\nfn test_rational_div_float() {\n    let test = |s, t, t_hex, out: &str, out_hex: &str| {\n        let x = Rational::from_str(s).unwrap();\n\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let quotient = x.clone() / y.clone();\n        assert!(quotient.is_valid());\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let quotient_alt = x.clone() / &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let quotient_alt = &x / y.clone();\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        let quotient_alt = &x / &y;\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n\n        // TODO add rug comparison once https://gitlab.com/tspiteri/rug/-/issues/85 is resolved\n\n        let quotient_alt = rational_div_float_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            y.significant_bits(),\n            Nearest,\n        )\n        .0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n\n        if y.is_normal() {\n            let quotient_alt = rational_div_float_prec_round_direct(\n                x.clone(),\n                y.clone(),\n                y.significant_bits(),\n                Nearest,\n            )\n            .0;\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n        }\n    };\n    test(\"123\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"123\", \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\");\n    test(\"123\", \"-Infinity\", \"-Infinity\", \"-0.0\", \"-0x0.0\");\n    test(\"0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"0\", \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\");\n    test(\"0\", \"-Infinity\", \"-Infinity\", \"-0.0\", \"-0x0.0\");\n\n    test(\"0\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"0\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n    test(\"123\", \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\");\n    test(\"123\", \"-0.0\", \"-0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\"-123\", \"0.0\", \"0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\"-123\", \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\");\n    test(\"1/3\", \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\");\n    test(\"1/3\", \"-0.0\", \"-0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\"-1/3\", \"0.0\", \"0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\"-1/3\", \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\");\n    test(\"1\", \"123.0\", \"0x7b.0#7\", \"0.0082\", \"0x0.0218#7\");\n    test(\"0\", \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\");\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", \"-0.0\", \"-0x0.0\");\n\n    test(\"2\", \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\");\n    test(\"2\", \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\");\n    test(\"2\", \"1.0\", \"0x1.000#10\", \"2.0\", \"0x2.00#10\");\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", \"1.5\", \"0x1.800#10\");\n\n    test(\"2\", \"3.0\", \"0x3.0#2\", \"0.8\", \"0x0.c#2\");\n    test(\"2\", \"3.0\", \"0x3.00#10\", \"0.667\", \"0x0.aac#10\");\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", \"0.5\", \"0x0.800#10\");\n\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n    );\n\n    test(\n        \"1/2\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n    );\n\n    // - n and d both powers of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_small\",\n        \"0x4.0E-268435456#1\",\n    );\n    // - only n a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"1/3\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n    );\n    // - only d a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"3/2\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_small\",\n        \"0x8.0E-268435456#1\",\n    );\n    // - neither n nor d a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"3/5\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n    );\n}\n\n#[test]\nfn test_rational_div_float_prec() {\n    let test = |s, t, t_hex, prec, out: &str, out_hex: &str, o_out| {\n        let x = Rational::from_str(s).unwrap();\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (quotient, o) = Float::rational_div_float_prec(x.clone(), y.clone(), prec);\n        assert!(quotient.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_prec_val_ref(x.clone(), &y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_prec_ref_val(&x, y.clone(), prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_prec_ref_ref(&x, &y, prec);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (rug_quotient, rug_o) = rug_rational_div_float_prec(\n            &rug::Rational::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_quotient)),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"123\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"Infinity\", \"Infinity\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"123\", \"-Infinity\", \"-Infinity\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"Infinity\", \"Infinity\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"-Infinity\", \"-Infinity\", 1, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"123\", \"-0.0\", \"-0x0.0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-123\", \"0.0\", \"0x0.0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-123\", \"-0.0\", \"-0x0.0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"1/3\", \"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"1/3\", \"-0.0\", \"-0x0.0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-1/3\", \"0.0\", \"0x0.0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-1/3\", \"-0.0\", \"-0x0.0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"1\", \"123.0\", \"0x7b.0#7\", 1, \"0.008\", \"0x0.02#1\", Less);\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\"0\", \"123.0\", \"0x7b.0#7\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", 1, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"2\", \"1.0\", \"0x1.0#1\", 1, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", 10, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", 1, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", 10, \"1.5\", \"0x1.800#10\", Equal);\n\n    test(\"2\", \"3.0\", \"0x3.0#2\", 1, \"0.5\", \"0x0.8#1\", Less);\n    test(\"2\", \"3.0\", \"0x3.0#2\", 10, \"0.667\", \"0x0.aac#10\", Greater);\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", 1, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", 10, \"0.5\", \"0x0.800#10\", Equal);\n\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n}\n\n#[test]\nfn rational_div_float_prec_fail() {\n    assert_panic!(Float::rational_div_float_prec(\n        Rational::ZERO,\n        Float::NAN,\n        0\n    ));\n    assert_panic!(Float::rational_div_float_prec_val_ref(\n        Rational::ZERO,\n        &Float::NAN,\n        0\n    ));\n    assert_panic!(Float::rational_div_float_prec_ref_val(\n        &Rational::ZERO,\n        Float::NAN,\n        0\n    ));\n    assert_panic!(Float::rational_div_float_prec_ref_ref(\n        &Rational::ZERO,\n        &Float::NAN,\n        0\n    ));\n}\n\n#[test]\nfn test_rational_div_float_round() {\n    let test = |s, t, t_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = Rational::from_str(s).unwrap();\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (quotient, o) = Float::rational_div_float_round(x.clone(), y.clone(), rm);\n        assert!(quotient.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_round_val_ref(x.clone(), &y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_round_ref_val(&x, y.clone(), rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_round_ref_ref(&x, &y, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive(x.clone(), y.clone(), y.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        if y.is_normal() {\n            let (quotient_alt, o_alt) = rational_div_float_prec_round_direct(\n                x.clone(),\n                y.clone(),\n                y.significant_bits(),\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_quotient, rug_o) = rug_rational_div_float_round(\n                &rug::Rational::exact_from(&x),\n                &rug::Float::exact_from(&y),\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_quotient)),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"123\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"123\", \"Infinity\", \"Infinity\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"123\", \"Infinity\", \"Infinity\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"123\", \"Infinity\", \"Infinity\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"123\", \"Infinity\", \"Infinity\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"123\", \"Infinity\", \"Infinity\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"123\", \"Infinity\", \"Infinity\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\"123\", \"-Infinity\", \"-Infinity\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\"0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0\", \"Infinity\", \"Infinity\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"Infinity\", \"Infinity\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"Infinity\", \"Infinity\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"Infinity\", \"Infinity\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"Infinity\", \"Infinity\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"Infinity\", \"Infinity\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\"0\", \"-Infinity\", \"-Infinity\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"-Infinity\", \"-Infinity\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\"0\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"123\", \"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"123\", \"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"123\", \"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"123\", \"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"123\", \"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"123\", \"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"123\", \"-0.0\", \"-0x0.0\", Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-123\", \"0.0\", \"0x0.0\", Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"-123\", \"-0.0\", \"-0x0.0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\"1/3\", \"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"1/3\", \"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"1/3\", \"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"1/3\", \"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"1/3\", \"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"1/3\", \"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"1/3\", \"-0.0\", \"-0x0.0\", Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-1/3\", \"0.0\", \"0x0.0\", Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"-1/3\", \"-0.0\", \"-0x0.0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"0.0081\",\n        \"0x0.0210#7\",\n        Less,\n    );\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n    test(\"1\", \"123.0\", \"0x7b.0#7\", Down, \"0.0081\", \"0x0.0210#7\", Less);\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n\n    test(\"0\", \"123.0\", \"0x7b.0#7\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"2\", \"1.0\", \"0x1.0#1\", Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", Ceiling, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\"2\", \"1.0\", \"0x1.0#2\", Floor, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#2\", Ceiling, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#2\", Down, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#2\", Up, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#2\", Nearest, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#2\", Exact, \"2.0\", \"0x2.0#2\", Equal);\n\n    test(\"2\", \"1.0\", \"0x1.000#10\", Floor, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"2\", \"1.0\", \"0x1.000#10\", Ceiling, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"2\", \"1.0\", \"0x1.000#10\", Down, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"2\", \"1.0\", \"0x1.000#10\", Up, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"2\", \"1.0\", \"0x1.000#10\", Nearest, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"2\", \"1.0\", \"0x1.000#10\", Exact, \"2.0\", \"0x2.00#10\", Equal);\n\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        Floor,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        Ceiling,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", Down, \"1.5\", \"0x1.800#10\", Equal);\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", Up, \"1.5\", \"0x1.800#10\", Equal);\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        Nearest,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        Exact,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n\n    test(\"2\", \"3.0\", \"0x3.0#2\", Floor, \"0.5\", \"0x0.8#2\", Less);\n    test(\"2\", \"3.0\", \"0x3.0#2\", Ceiling, \"0.8\", \"0x0.c#2\", Greater);\n    test(\"2\", \"3.0\", \"0x3.0#2\", Down, \"0.5\", \"0x0.8#2\", Less);\n    test(\"2\", \"3.0\", \"0x3.0#2\", Up, \"0.8\", \"0x0.c#2\", Greater);\n    test(\"2\", \"3.0\", \"0x3.0#2\", Nearest, \"0.8\", \"0x0.c#2\", Greater);\n\n    test(\"2\", \"3.0\", \"0x3.00#10\", Floor, \"0.666\", \"0x0.aa8#10\", Less);\n    test(\n        \"2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        Ceiling,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n    test(\"2\", \"3.0\", \"0x3.00#10\", Down, \"0.666\", \"0x0.aa8#10\", Less);\n    test(\"2\", \"3.0\", \"0x3.00#10\", Up, \"0.667\", \"0x0.aac#10\", Greater);\n    test(\n        \"2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        Nearest,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", Floor, \"0.5\", \"0x0.800#10\", Equal);\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        Ceiling,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", Down, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", Up, \"0.5\", \"0x0.800#10\", Equal);\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        Nearest,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", Exact, \"0.5\", \"0x0.800#10\", Equal);\n\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"0.47746482927568606\",\n        \"0x0.7a3b2292bab314#53\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"0.47746482927568606\",\n        \"0x0.7a3b2292bab314#53\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n        Less,\n    );\n\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"-0.47746482927568606\",\n        \"-0x0.7a3b2292bab314#53\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"-0.47746482927568606\",\n        \"-0x0.7a3b2292bab314#53\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n        Greater,\n    );\n\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"-0.47746482927568606\",\n        \"-0x0.7a3b2292bab314#53\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"-0.47746482927568606\",\n        \"-0x0.7a3b2292bab314#53\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-0.47746482927568601\",\n        \"-0x0.7a3b2292bab310#53\",\n        Greater,\n    );\n\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"0.47746482927568606\",\n        \"0x0.7a3b2292bab314#53\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"0.47746482927568606\",\n        \"0x0.7a3b2292bab314#53\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"0.47746482927568601\",\n        \"0x0.7a3b2292bab310#53\",\n        Less,\n    );\n}\n\n#[test]\nfn rational_div_float_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::rational_div_float_round(Rational::ONE, THREE, Exact));\n    assert_panic!(Float::rational_div_float_round_val_ref(\n        Rational::ONE,\n        &THREE,\n        Exact\n    ));\n    assert_panic!(Float::rational_div_float_round_ref_val(\n        &Rational::ONE,\n        THREE,\n        Exact\n    ));\n    assert_panic!(Float::rational_div_float_round_ref_ref(\n        &Rational::ONE,\n        &THREE,\n        Exact\n    ));\n}\n\n#[test]\nfn test_rational_div_float_prec_round() {\n    let test = |s, t, t_hex, prec, rm, out: &str, out_hex: &str, o_out| {\n        let x = Rational::from_str(s).unwrap();\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (quotient, o) = Float::rational_div_float_prec_round(x.clone(), y.clone(), prec, rm);\n        assert!(quotient.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(quotient.to_string(), out);\n        assert_eq!(to_hex_string(&quotient), out_hex);\n\n        let (quotient_alt, o_alt) =\n            Float::rational_div_float_prec_round_val_ref(x.clone(), &y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            Float::rational_div_float_prec_round_ref_val(&x, y.clone(), prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_prec_round_ref_ref(&x, &y, prec, rm);\n        assert!(quotient_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&quotient),\n            ComparableFloatRef(&quotient_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = rational_div_float_prec_round_naive_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        if y.is_normal() {\n            let (quotient_alt, o_alt) =\n                rational_div_float_prec_round_direct(x.clone(), y.clone(), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n\n            let (quotient_alt, o_alt) =\n                rational_div_float_prec_round_direct_val_ref(x.clone(), &y, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n\n            let (quotient_alt, o_alt) =\n                rational_div_float_prec_round_direct_ref_val(&x, y.clone(), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n\n            let (quotient_alt, o_alt) =\n                rational_div_float_prec_round_direct_ref_ref(&x, &y, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&quotient_alt),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(o_alt, o);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_quotient, rug_o) = rug_rational_div_float_prec_round(\n                &rug::Rational::exact_from(&x),\n                &rug::Float::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_quotient)),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"123\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"123\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"123\", \"Infinity\", \"Infinity\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123\", \"Infinity\", \"Infinity\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123\", \"Infinity\", \"Infinity\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"123\", \"Infinity\", \"Infinity\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"123\", \"Infinity\", \"Infinity\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123\", \"Infinity\", \"Infinity\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\"0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0\", \"Infinity\", \"Infinity\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0\", \"Infinity\", \"Infinity\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"Infinity\", \"Infinity\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0\", \"Infinity\", \"Infinity\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0\", \"Infinity\", \"Infinity\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\"0\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"123\", \"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123\", \"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123\", \"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"123\", \"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"123\", \"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123\", \"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-123\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-123\", \"-0.0\", \"-0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"1/3\", \"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"1/3\", \"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"1/3\", \"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"1/3\", \"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"1/3\", \"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"1/3\", \"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"1/3\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-1/3\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-1/3\", \"-0.0\", \"-0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"1\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"0.008\", \"0x0.02#1\", Less,\n    );\n    test(\n        \"1\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.02\", \"0x0.04#1\", Greater,\n    );\n    test(\"1\", \"123.0\", \"0x7b.0#7\", 1, Down, \"0.008\", \"0x0.02#1\", Less);\n    test(\"1\", \"123.0\", \"0x7b.0#7\", 1, Up, \"0.02\", \"0x0.04#1\", Greater);\n    test(\n        \"1\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.008\", \"0x0.02#1\", Less,\n    );\n\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"0.00812\",\n        \"0x0.0214#10\",\n        Less,\n    );\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Down,\n        \"0.00812\",\n        \"0x0.0214#10\",\n        Less,\n    );\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\n        \"1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n\n    test(\"0\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0\", \"-123.0\", \"-0x7b.0#7\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\n        \"0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\"2\", \"1.0\", \"0x1.0#1\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", 1, Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", 1, Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\"2\", \"1.0\", \"0x1.0#1\", 10, Floor, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"2\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"2\", \"1.0\", \"0x1.0#1\", 10, Down, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"2\", \"1.0\", \"0x1.0#1\", 10, Up, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"2\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"2\", \"1.0\", \"0x1.0#1\", 10, Exact, \"2.0\", \"0x2.00#10\", Equal);\n\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"3/2\", \"1.0\", \"0x1.000#10\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        10,\n        Floor,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        10,\n        Ceiling,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        10,\n        Down,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        10,\n        Up,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        10,\n        Nearest,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"1.0\",\n        \"0x1.000#10\",\n        10,\n        Exact,\n        \"1.5\",\n        \"0x1.800#10\",\n        Equal,\n    );\n\n    test(\"2\", \"3.0\", \"0x3.0#2\", 1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test(\"2\", \"3.0\", \"0x3.0#2\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"2\", \"3.0\", \"0x3.0#2\", 1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test(\"2\", \"3.0\", \"0x3.0#2\", 1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"2\", \"3.0\", \"0x3.0#2\", 1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test(\n        \"2\",\n        \"3.0\",\n        \"0x3.0#2\",\n        10,\n        Floor,\n        \"0.666\",\n        \"0x0.aa8#10\",\n        Less,\n    );\n    test(\n        \"2\",\n        \"3.0\",\n        \"0x3.0#2\",\n        10,\n        Ceiling,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n    test(\"2\", \"3.0\", \"0x3.0#2\", 10, Down, \"0.666\", \"0x0.aa8#10\", Less);\n    test(\n        \"2\",\n        \"3.0\",\n        \"0x3.0#2\",\n        10,\n        Up,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n    test(\n        \"2\",\n        \"3.0\",\n        \"0x3.0#2\",\n        10,\n        Nearest,\n        \"0.667\",\n        \"0x0.aac#10\",\n        Greater,\n    );\n\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", 1, Floor, \"0.5\", \"0x0.8#1\", Equal);\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Equal,\n    );\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", 1, Down, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", 1, Up, \"0.5\", \"0x0.8#1\", Equal);\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Equal,\n    );\n    test(\"3/2\", \"3.0\", \"0x3.00#10\", 1, Exact, \"0.5\", \"0x0.8#1\", Equal);\n\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        10,\n        Floor,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        10,\n        Ceiling,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        10,\n        Down,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        10,\n        Up,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        10,\n        Nearest,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n    test(\n        \"3/2\",\n        \"3.0\",\n        \"0x3.00#10\",\n        10,\n        Exact,\n        \"0.5\",\n        \"0x0.800#10\",\n        Equal,\n    );\n\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"0.4771\",\n        \"0x0.7a2#10\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"0.4771\",\n        \"0x0.7a2#10\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-0.4771\",\n        \"-0x0.7a2#10\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-0.4771\",\n        \"-0x0.7a2#10\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-0.4771\",\n        \"-0x0.7a2#10\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-0.4771\",\n        \"-0x0.7a2#10\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-0.4775\",\n        \"-0x0.7a4#10\",\n        Less,\n    );\n\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"0.4771\",\n        \"0x0.7a2#10\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"0.4771\",\n        \"0x0.7a2#10\",\n        Less,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n    test(\n        \"-3/2\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"0.4775\",\n        \"0x0.7a4#10\",\n        Greater,\n    );\n}\n\n#[test]\nfn rational_div_float_prec_round_fail() {\n    assert_panic!(Float::rational_div_float_prec_round(\n        Rational::ONE,\n        Float::one_prec(1),\n        0,\n        Floor\n    ));\n    assert_panic!(Float::rational_div_float_prec_round(\n        Rational::ONE,\n        Float::from(3),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::rational_div_float_prec_round_val_ref(\n        Rational::ONE,\n        &Float::from(3),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::rational_div_float_prec_round_ref_val(\n        &Rational::ONE,\n        Float::from(3),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::rational_div_float_prec_round_ref_ref(\n        &Rational::ONE,\n        &Float::from(3),\n        1,\n        Exact\n    ));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn div_prec_round_properties_helper(\n    x: Float,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (quotient, o) = x.clone().div_prec_round(y.clone(), prec, rm);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = x.clone().div_prec_round_val_ref(&y, prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_prec_round_ref_ref(&y, prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) = div_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_quotient, rug_o) = rug_div_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_quotient)),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(\n            ComparableFloatRef(\n                &quotient\n                    .mul_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n            ),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(\n            ComparableFloatRef(\n                &x.div_prec_round_ref_ref(&quotient, y.significant_bits(), Exact)\n                    .0\n            ),\n            ComparableFloatRef(&y)\n        );\n    }\n\n    if quotient.is_finite() && y.is_finite() {\n        if quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / Rational::exact_from(&y);\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n            match (r_quotient >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (mut quotient_alt, mut o_alt) = x.div_prec_round_ref_val(-&y, prec, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut quotient_alt, mut o_alt) = (-&x).div_prec_round_val_ref(&y, prec, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (quotient_alt, o_alt) = (-&x).div_prec_round(-&y, prec, rm);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.div_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(quotient.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.div_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn div_prec_round_properties() {\n    float_float_unsigned_rounding_mode_quadruple_gen_var_4().test_properties(|(x, y, prec, rm)| {\n        div_prec_round_properties_helper(x, y, prec, rm, false);\n    });\n\n    float_float_unsigned_rounding_mode_quadruple_gen_var_8().test_properties(|(x, y, prec, rm)| {\n        div_prec_round_properties_helper(x, y, prec, rm, true);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_float_unsigned_rounding_mode_quadruple_gen_var_4().test_properties_with_config(\n        &config,\n        |(x, y, prec, rm)| {\n            div_prec_round_properties_helper(x, y, prec, rm, false);\n        },\n    );\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"mean_small_n\", 2048);\n    float_float_unsigned_rounding_mode_quadruple_gen_var_4().test_properties_with_config(\n        &config,\n        |(x, y, prec, rm)| {\n            div_prec_round_properties_helper(x, y, prec, rm, false);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (quotient, o) = x.div_prec_round_ref_val(Float::NAN, prec, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        let (quotient, o) = Float::NAN.div_prec_round_val_ref(&x, prec, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x.is_finite() {\n                assert_eq!(\n                    x.div_prec_round_ref_val(Float::INFINITY, prec, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::ZERO\n                        } else {\n                            Float::NEGATIVE_ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::INFINITY.div_prec_round_val_ref(&x, prec, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.div_prec_round_ref_val(Float::NEGATIVE_INFINITY, prec, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::NEGATIVE_ZERO\n                        } else {\n                            Float::ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.div_prec_round_val_ref(&x, prec, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n            }\n            if x != 0 {\n                assert_eq!(\n                    x.div_prec_round_ref_val(Float::ZERO, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::ZERO.div_prec_round_val_ref(&x, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::ZERO\n                        } else {\n                            Float::NEGATIVE_ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.div_prec_round_ref_val(Float::ZERO, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_ZERO.div_prec_round_val_ref(&x, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_ZERO\n                        } else {\n                            Float::ZERO\n                        },\n                        Equal\n                    )\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (quotient, o) = x.div_prec_round_ref_val(Float::ONE, prec, rm);\n            let mut quotient_alt = x.clone();\n            let o_alt = quotient_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(quotient), ComparableFloat(quotient_alt));\n            assert_eq!(o, o_alt);\n\n            if rm != Exact {\n                let (quotient, o) = Float::ONE.div_prec_round_val_ref(&x, prec, rm);\n                let (quotient_alt, o_alt) = x.clone().reciprocal_prec_round(prec, rm);\n                assert_eq!(ComparableFloat(quotient), ComparableFloat(quotient_alt));\n                assert_eq!(o, o_alt);\n            }\n        }\n    });\n}\n\nfn div_prec_properties_helper(x: Float, y: Float, prec: u64, extreme: bool) {\n    let (quotient, o) = x.clone().div_prec(y.clone(), prec);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = x.clone().div_prec_val_ref(&y, prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_prec_ref_val(y.clone(), prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_prec_ref_ref(&y, prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) = div_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(\n            ComparableFloatRef(&quotient.mul_prec_ref_ref(&y, x.significant_bits()).0),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(\n            ComparableFloatRef(&x.div_prec_ref_ref(&quotient, y.significant_bits()).0),\n            ComparableFloatRef(&y)\n        );\n    }\n\n    let (quotient_alt, o_alt) = x.div_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if quotient.is_finite() && y.is_finite() {\n        if quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / Rational::exact_from(&y);\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n        }\n    }\n\n    if (x != 0u32 && y != 0u32) || (x.is_sign_positive() && y.is_sign_positive()) {\n        let (mut quotient_alt, mut o_alt) = x.div_prec_ref_val(-&y, prec);\n        quotient_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(o_alt, o);\n\n        let (mut quotient_alt, mut o_alt) = (-&x).div_prec_val_ref(&y, prec);\n        quotient_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = (-x).div_prec(-y, prec);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn div_prec_properties() {\n    float_float_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        div_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_float_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        div_prec_properties_helper(x, y, prec, true);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_float_unsigned_triple_gen_var_1().test_properties_with_config(&config, |(x, y, prec)| {\n        div_prec_properties_helper(x, y, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"mean_small_n\", 2048);\n    float_float_unsigned_triple_gen_var_1().test_properties_with_config(&config, |(x, y, prec)| {\n        div_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        let (quotient, o) = x.div_prec_ref_val(Float::NAN, prec);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        let (quotient, o) = Float::NAN.div_prec_val_ref(&x, prec);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x.is_finite() {\n                assert_eq!(\n                    x.div_prec_ref_val(Float::INFINITY, prec),\n                    (\n                        if x.is_sign_positive() {\n                            Float::ZERO\n                        } else {\n                            Float::NEGATIVE_ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::INFINITY.div_prec_val_ref(&x, prec),\n                    (\n                        if x.is_sign_positive() {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.div_prec_ref_val(Float::NEGATIVE_INFINITY, prec),\n                    (\n                        if x.is_sign_positive() {\n                            Float::NEGATIVE_ZERO\n                        } else {\n                            Float::ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.div_prec_val_ref(&x, prec),\n                    (\n                        if x.is_sign_positive() {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n            }\n            if x != 0 {\n                assert_eq!(\n                    x.div_prec_ref_val(Float::ZERO, prec),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::ZERO.div_prec_val_ref(&x, prec),\n                    (\n                        if x > 0 {\n                            Float::ZERO\n                        } else {\n                            Float::NEGATIVE_ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.div_prec_ref_val(Float::NEGATIVE_ZERO, prec),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_ZERO.div_prec_val_ref(&x, prec),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_ZERO\n                        } else {\n                            Float::ZERO\n                        },\n                        Equal\n                    )\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (quotient, o) = x.div_prec_ref_val(Float::ONE, prec);\n            let mut quotient_alt = x.clone();\n            let o_alt = quotient_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(quotient), ComparableFloat(quotient_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn div_round_properties_helper(x: Float, y: Float, rm: RoundingMode, extreme: bool) {\n    let (quotient, o) = x.clone().div_round(y.clone(), rm);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = x.clone().div_round_val_ref(&y, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o_alt) = x.div_round_ref_val(y.clone(), rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o_alt) = x.div_round_ref_ref(&y, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) = div_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    let (quotient_alt, o_alt) =\n        x.div_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), rm);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(quotient.mul_round_ref_ref(&y, Exact).0, x);\n        assert_eq!(x.div_round_ref_ref(&quotient, Exact).0, y);\n    }\n\n    if quotient.is_finite() && y.is_finite() {\n        if x.is_normal() && y.is_normal() && quotient.is_normal() {\n            assert_eq!(\n                quotient.get_prec(),\n                Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n            );\n        }\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / Rational::exact_from(&y);\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n            match (r_quotient >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_quotient, rug_o) =\n            rug_div_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_quotient)),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (mut quotient_alt, mut o_alt) = x.div_round_ref_val(-&y, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n\n    let (mut quotient_alt, mut o_alt) = (-&x).div_round_val_ref(&y, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n\n    let (quotient_alt, o_alt) = (-&x).div_round(-&y, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.div_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(quotient.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.div_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn div_round_properties() {\n    float_float_rounding_mode_triple_gen_var_23().test_properties(|(x, y, rm)| {\n        div_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_32().test_properties(|(x, y, rm)| {\n        div_round_properties_helper(x, y, rm, true);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_float_rounding_mode_triple_gen_var_23().test_properties_with_config(\n        &config,\n        |(x, y, rm)| {\n            div_round_properties_helper(x, y, rm, false);\n        },\n    );\n\n    float_float_rounding_mode_triple_gen_var_24().test_properties(|(x, y, rm)| {\n        div_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_25().test_properties(|(x, y, rm)| {\n        div_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_26().test_properties(|(x, y, rm)| {\n        div_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_27().test_properties(|(x, y, rm)| {\n        div_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_28().test_properties(|(x, y, rm)| {\n        div_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let (quotient, o) = x.div_round_ref_val(Float::NAN, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        let (quotient, o) = Float::NAN.div_round_val_ref(&x, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x.is_finite() {\n                assert_eq!(\n                    x.div_round_ref_val(Float::INFINITY, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::ZERO\n                        } else {\n                            Float::NEGATIVE_ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::INFINITY.div_round_val_ref(&x, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.div_round_ref_val(Float::NEGATIVE_INFINITY, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::NEGATIVE_ZERO\n                        } else {\n                            Float::ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.div_round_val_ref(&x, rm),\n                    (\n                        if x.is_sign_positive() {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n            }\n            if x != 0 {\n                assert_eq!(\n                    x.div_round_ref_val(Float::ZERO, rm),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::ZERO.div_round_val_ref(&x, rm),\n                    (\n                        if x > 0 {\n                            Float::ZERO\n                        } else {\n                            Float::NEGATIVE_ZERO\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.div_round_ref_val(Float::NEGATIVE_ZERO, rm),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_ZERO.div_round_val_ref(&x, rm),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_ZERO\n                        } else {\n                            Float::ZERO\n                        },\n                        Equal\n                    )\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (quotient, o) = x.div_round_ref_val(Float::ONE, rm);\n            assert_eq!(ComparableFloatRef(&quotient), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn div_properties_helper_1(x: Float, y: Float, extreme: bool) {\n    let quotient = x.clone() / y.clone();\n    assert!(quotient.is_valid());\n    let quotient_alt = x.clone() / &y;\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = &x / y.clone();\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = &x / &y;\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    let mut x_alt = x.clone();\n    x_alt /= y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n\n    let mut x_alt = x.clone();\n    x_alt /= &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n\n    if !extreme {\n        let quotient_alt = div_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n    }\n    let quotient_alt = x\n        .div_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), Nearest)\n        .0;\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = x\n        .div_prec_ref_ref(&y, max(x.significant_bits(), y.significant_bits()))\n        .0;\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o) = x.div_round_ref_ref(&y, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(&quotient * &y, x);\n        assert_eq!(&x / &quotient, y);\n    }\n\n    if quotient.is_finite() && x.is_normal() && y.is_normal() && quotient.is_normal() {\n        assert_eq!(\n            quotient.get_prec(),\n            Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n        );\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / Rational::exact_from(&y);\n            if quotient < r_quotient {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if quotient > r_quotient {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n        }\n    }\n\n    let rug_quotient = rug_div(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_quotient)),\n        ComparableFloatRef(&quotient),\n    );\n\n    if (x != 0u32 && y != 0u32) || (x.is_sign_positive() && y.is_sign_positive()) {\n        assert_eq!(\n            ComparableFloatRef(&-(&x / -&y)),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(\n            ComparableFloatRef(&-(-&x / &y)),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(\n            ComparableFloatRef(&(-&x / -&y)),\n            ComparableFloatRef(&quotient)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn div_properties_helper_2<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let quotient_1 = x / y;\n        let quotient_2 = emulate_float_float_to_float_fn(Float::div_prec, x, y);\n        assert_eq!(NiceFloat(quotient_1), NiceFloat(quotient_2));\n    });\n}\n\n#[test]\nfn div_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        div_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        div_properties_helper_1(x, y, true);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_pair_gen().test_properties_with_config(&config, |(x, y)| {\n        div_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_2().test_properties(|(x, y)| {\n        div_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_3().test_properties(|(x, y)| {\n        div_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_4().test_properties(|(x, y)| {\n        div_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_8().test_properties(|(x, y)| {\n        div_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_9().test_properties(|(x, y)| {\n        div_properties_helper_1(x, y, false);\n    });\n\n    apply_fn_to_primitive_floats!(div_properties_helper_2);\n\n    float_gen().test_properties(|x| {\n        assert!((&x / Float::NAN).is_nan());\n        assert!((Float::NAN / &x).is_nan());\n        if !x.is_nan() {\n            if x.is_finite() {\n                assert_eq!(\n                    &x / Float::INFINITY,\n                    if x.is_sign_positive() {\n                        Float::ZERO\n                    } else {\n                        Float::NEGATIVE_ZERO\n                    }\n                );\n                assert_eq!(\n                    Float::INFINITY / &x,\n                    if x.is_sign_positive() {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    }\n                );\n                assert_eq!(\n                    &x / Float::NEGATIVE_INFINITY,\n                    if x.is_sign_positive() {\n                        Float::NEGATIVE_ZERO\n                    } else {\n                        Float::ZERO\n                    }\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY / &x,\n                    if x.is_sign_positive() {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    }\n                );\n            }\n            if x != 0 {\n                assert_eq!(\n                    &x / Float::ZERO,\n                    if x.is_sign_positive() {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    }\n                );\n                assert_eq!(\n                    Float::ZERO / &x,\n                    if x.is_sign_positive() {\n                        Float::ZERO\n                    } else {\n                        Float::NEGATIVE_ZERO\n                    }\n                );\n                assert_eq!(\n                    &x / Float::NEGATIVE_ZERO,\n                    if x.is_sign_positive() {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    }\n                );\n                assert_eq!(\n                    Float::NEGATIVE_ZERO / &x,\n                    if x.is_sign_positive() {\n                        Float::NEGATIVE_ZERO\n                    } else {\n                        Float::ZERO\n                    }\n                );\n            }\n            assert_eq!(&x / Float::ONE, x);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn div_rational_prec_round_properties_helper(\n    x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (quotient, o) = x.clone().div_rational_prec_round(y.clone(), prec, rm);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = x.clone().div_rational_prec_round_val_ref(&y, prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_rational_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_rational_prec_round_ref_ref(&y, prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_rational_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_rational_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_naive_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if x.is_normal() {\n        let (quotient_alt, o_alt) = div_rational_prec_round_direct(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_direct_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_direct_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = div_rational_prec_round_direct_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_quotient, rug_o) = rug_div_rational_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_quotient)),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(\n            ComparableFloatRef(\n                &quotient\n                    .mul_rational_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n            ),\n            ComparableFloatRef(&x)\n        );\n        // TODO additional test\n    }\n\n    if quotient.is_finite() {\n        if quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / &y;\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n            match (r_quotient >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (mut quotient_alt, mut o_alt) = x.div_rational_prec_round_ref_val(-&y, prec, -rm);\n    if y != 0 {\n        quotient_alt.neg_assign();\n    }\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref()),\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut quotient_alt, mut o_alt) = (-&x).div_rational_prec_round_val_ref(&y, prec, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if quotient != 0u32 && y != 0 {\n        let (quotient_alt, o_alt) = (-&x).div_rational_prec_round(-&y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.div_rational_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(quotient.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.div_rational_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn div_rational_prec_round_properties() {\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_4().test_properties(\n        |(x, y, prec, rm)| {\n            div_rational_prec_round_properties_helper(x, y, prec, rm, false);\n        },\n    );\n\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_9().test_properties(\n        |(x, y, prec, rm)| {\n            div_rational_prec_round_properties_helper(x, y, prec, rm, true);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        if !x.is_negative_zero() {\n            let (quotient, o) = x.div_rational_prec_round_ref_val(Rational::ONE, prec, rm);\n            let mut quotient_alt = x.clone();\n            let o_alt = quotient_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(quotient), ComparableFloat(quotient_alt));\n            assert_eq!(o, o_alt);\n        }\n        if !x.is_nan() && x != 0 {\n            assert_eq!(\n                x.div_rational_prec_round_ref_val(Rational::ZERO, prec, rm),\n                (\n                    if x > 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    },\n                    Equal\n                )\n            );\n        }\n    });\n\n    rational_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (quotient, o) = Float::NAN.div_rational_prec_round_val_ref(&x, prec, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(\n            Float::INFINITY.div_rational_prec_round_val_ref(&x, prec, rm),\n            (\n                if x >= 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                },\n                Equal\n            )\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.div_rational_prec_round_val_ref(&x, prec, rm),\n            (\n                if x >= 0 {\n                    Float::NEGATIVE_INFINITY\n                } else {\n                    Float::INFINITY\n                },\n                Equal\n            )\n        );\n        if x != 0 {\n            let (quotient, o) = Float::ZERO.div_rational_prec_round_val_ref(&x, prec, rm);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n\n            let (quotient, o) = Float::NEGATIVE_ZERO.div_rational_prec_round_val_ref(&x, prec, rm);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::NEGATIVE_ZERO\n                } else {\n                    Float::ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\nfn div_rational_prec_properties_helper(x: Float, y: Rational, prec: u64, extreme: bool) {\n    let (quotient, o) = x.clone().div_rational_prec(y.clone(), prec);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = x.clone().div_rational_prec_val_ref(&y, prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_rational_prec_ref_val(y.clone(), prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = x.div_rational_prec_ref_ref(&y, prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_rational_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_rational_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) =\n            div_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if x.is_normal() {\n        let (quotient_alt, o_alt) =\n            div_rational_prec_round_direct(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_quotient, rug_o) = rug_div_rational_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Rational::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_quotient)),\n        ComparableFloatRef(&quotient),\n    );\n    assert_eq!(rug_o, o);\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(\n            ComparableFloatRef(\n                &quotient\n                    .mul_rational_prec_ref_ref(&y, x.significant_bits())\n                    .0\n            ),\n            ComparableFloatRef(&x)\n        );\n        // TODO additional test\n    }\n\n    let (quotient_alt, o_alt) = x.div_rational_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if quotient.is_finite() {\n        if quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / &y;\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n        }\n    }\n\n    if x != 0u32 && y != 0u32 {\n        let (mut quotient_alt, mut o_alt) = x.div_rational_prec_ref_val(-&y, prec);\n        quotient_alt.neg_assign();\n        quotient_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloat(quotient_alt.abs_negative_zero()),\n            ComparableFloat(quotient.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (mut quotient_alt, mut o_alt) = (-&x).div_rational_prec_val_ref(&y, prec);\n        quotient_alt.neg_assign();\n        quotient_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloat(quotient_alt.abs_negative_zero()),\n            ComparableFloat(quotient.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = (-x).div_rational_prec(-y, prec);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn div_rational_prec_properties() {\n    float_rational_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        div_rational_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_rational_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        div_rational_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        if !x.is_negative_zero() {\n            let (quotient, o) = x.div_rational_prec_ref_val(Rational::ONE, prec);\n            let mut quotient_alt = x.clone();\n            let o_alt = quotient_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(quotient), ComparableFloat(quotient_alt));\n            assert_eq!(o, o_alt);\n        }\n\n        if x.is_finite() && x != 0 {\n            let (quotient, o) = x.div_rational_prec_ref_val(Rational::ZERO, prec);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let (quotient, o) = Float::NAN.div_rational_prec_val_ref(&x, prec);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        if x != 0 {\n            assert_eq!(\n                Float::INFINITY.div_rational_prec_val_ref(&x, prec),\n                (\n                    if x >= 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    },\n                    Equal\n                )\n            );\n            assert_eq!(\n                Float::NEGATIVE_INFINITY.div_rational_prec_val_ref(&x, prec),\n                (\n                    if x >= 0 {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    },\n                    Equal\n                )\n            );\n        }\n\n        if x != 0 {\n            let (quotient, o) = Float::ZERO.div_rational_prec_val_ref(&x, prec);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n            let (quotient, o) = Float::NEGATIVE_ZERO.div_rational_prec_val_ref(&x, prec);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::NEGATIVE_ZERO\n                } else {\n                    Float::ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn div_rational_round_properties_helper(x: Float, y: Rational, rm: RoundingMode, extreme: bool) {\n    let (quotient, o) = x.clone().div_rational_round(y.clone(), rm);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = x.clone().div_rational_round_val_ref(&y, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o_alt) = x.div_rational_round_ref_val(y.clone(), rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o_alt) = x.div_rational_round_ref_ref(&y, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_rational_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.div_rational_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) =\n            div_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if x.is_normal() {\n        let (quotient_alt, o_alt) =\n            div_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    let (quotient_alt, o_alt) = x.div_rational_prec_round_ref_ref(&y, x.significant_bits(), rm);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(quotient.mul_rational_round_ref_ref(&y, Exact).0, x);\n        // TODO additional test\n    }\n\n    if quotient.is_finite() {\n        if x.is_normal() && quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(x.get_prec().unwrap()));\n        }\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / &y;\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n            match (r_quotient >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_quotient, rug_o) = rug_div_rational_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_quotient)),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if y != 0 {\n        let (mut quotient_alt, mut o_alt) = x.div_rational_round_ref_val(-&y, -rm);\n        quotient_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(o_alt, o);\n        assert_eq!(\n            ComparableFloat(quotient_alt.abs_negative_zero_ref()),\n            ComparableFloat(quotient.abs_negative_zero_ref())\n        );\n    }\n\n    let (mut quotient_alt, mut o_alt) = (-&x).div_rational_round_val_ref(&y, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero_ref()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n\n    if x != 0 && y != 0 {\n        let (quotient_alt, o_alt) = (-&x).div_rational_round(-&y, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.div_rational_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(quotient.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.div_rational_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn div_rational_round_properties() {\n    float_rational_rounding_mode_triple_gen_var_5().test_properties(|(x, y, rm)| {\n        div_rational_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rational_rounding_mode_triple_gen_var_10().test_properties(|(x, y, rm)| {\n        div_rational_round_properties_helper(x, y, rm, true);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let (quotient, o) = x.div_rational_round_ref_val(Rational::ONE, rm);\n        assert_eq!(ComparableFloatRef(&quotient), ComparableFloatRef(&x));\n        assert_eq!(o, Equal);\n\n        if x.is_finite() && x != 0 {\n            let (quotient, o) = x.div_rational_round_ref_val(Rational::ZERO, rm);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_rounding_mode_pair_gen_var_6().test_properties(|(x, rm)| {\n        let (quotient, o) = Float::NAN.div_rational_round_val_ref(&x, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        if x != 0 {\n            assert_eq!(\n                Float::INFINITY.div_rational_round_val_ref(&x, rm),\n                (\n                    if x >= 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    },\n                    Equal\n                )\n            );\n            assert_eq!(\n                Float::NEGATIVE_INFINITY.div_rational_round_val_ref(&x, rm),\n                (\n                    if x >= 0 {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    },\n                    Equal\n                )\n            );\n        }\n    });\n}\n\nfn div_rational_properties_helper(x: Float, y: Rational, extreme: bool) {\n    let quotient = x.clone() / y.clone();\n    assert!(quotient.is_valid());\n    let quotient_alt = x.clone() / &y;\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = &x / y.clone();\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = &x / &y;\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    let mut x_alt = x.clone();\n    x_alt /= y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n\n    let mut x_alt = x.clone();\n    x_alt /= &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&quotient));\n\n    if !extreme {\n        let quotient_alt =\n            div_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n    }\n\n    if x.is_normal() {\n        let quotient_alt =\n            div_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n    }\n\n    let quotient_alt = x\n        .div_rational_prec_round_ref_ref(&y, x.significant_bits(), Nearest)\n        .0;\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    let quotient_alt = x.div_rational_prec_ref_ref(&y, x.significant_bits()).0;\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o) = x.div_rational_round_ref_ref(&y, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    if o == Equal && quotient.is_finite() && quotient != 0 {\n        assert_eq!(&quotient * &y, x);\n        // TODO additional test\n    }\n\n    if quotient.is_finite() && x.is_normal() && quotient.is_normal() {\n        assert_eq!(quotient.get_prec(), Some(x.get_prec().unwrap()));\n        if !extreme {\n            let r_quotient = Rational::exact_from(&x) / &y;\n            if quotient < r_quotient {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if quotient > r_quotient {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n        }\n    }\n\n    let rug_quotient = rug_div_rational(&rug::Float::exact_from(&x), &rug::Rational::from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_quotient)),\n        ComparableFloatRef(&quotient),\n    );\n\n    if quotient != 0u32 {\n        assert_eq!(\n            ComparableFloatRef(&-(-&x / &y)),\n            ComparableFloatRef(&quotient)\n        );\n        if y != 0 {\n            assert_eq!(\n                ComparableFloatRef(&-(&x / -&y)),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(\n                ComparableFloatRef(&(-x / -y)),\n                ComparableFloatRef(&quotient)\n            );\n        }\n    }\n}\n\n#[test]\nfn div_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        div_rational_properties_helper(x, y, false);\n    });\n\n    float_rational_pair_gen_var_2().test_properties(|(x, y)| {\n        div_rational_properties_helper(x, y, true);\n    });\n\n    float_gen().test_properties(|x| {\n        assert_eq!(\n            ComparableFloatRef(&(&x / Rational::ONE)),\n            ComparableFloatRef(&x)\n        );\n        if x.is_finite() && x != 0 {\n            assert_eq!(\n                ComparableFloat(&x / Rational::ZERO),\n                ComparableFloat(if x.is_sign_positive() {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                }),\n            );\n        }\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!((&x / Float::NAN).is_nan());\n        assert_eq!(\n            &x / Float::INFINITY,\n            if x >= 0 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            }\n        );\n        assert_eq!(\n            &x / Float::NEGATIVE_INFINITY,\n            if x >= 0 {\n                Float::NEGATIVE_ZERO\n            } else {\n                Float::ZERO\n            }\n        );\n        if x != 0 {\n            assert_eq!(\n                &x / Float::ZERO,\n                if x > 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                }\n            );\n            assert_eq!(\n                &x / Float::NEGATIVE_ZERO,\n                if x > 0 {\n                    Float::NEGATIVE_INFINITY\n                } else {\n                    Float::INFINITY\n                }\n            );\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn rational_div_float_prec_round_properties_helper(\n    x: Rational,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (quotient, o) = Float::rational_div_float_prec_round(x.clone(), y.clone(), prec, rm);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) =\n        Float::rational_div_float_prec_round_val_ref(x.clone(), &y, prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) =\n        Float::rational_div_float_prec_round_ref_val(&x, y.clone(), prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = Float::rational_div_float_prec_round_ref_ref(&x, &y, prec, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = rational_div_float_prec_round_naive_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if y.is_normal() {\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_direct(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_direct_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_direct_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = rational_div_float_prec_round_direct_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    // TODO add rug comparison once https://gitlab.com/tspiteri/rug/-/issues/85 is resolved\n\n    if quotient.is_finite() && y.is_finite() {\n        if quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_quotient = &x / Rational::exact_from(&y);\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n            match (r_quotient >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (mut quotient_alt, mut o_alt) =\n        Float::rational_div_float_prec_round_ref_val(&x, -&y, prec, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref()),\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut quotient_alt, mut o_alt) =\n        Float::rational_div_float_prec_round_val_ref(-&x, &y, prec, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if quotient != 0u32 && y != 0u32 {\n        let (quotient_alt, o_alt) = Float::rational_div_float_prec_round(-&x, -&y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = Float::rational_div_float_prec_round_ref_ref(&x, &y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(quotient.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(Float::rational_div_float_prec_round_ref_ref(\n            &x, &y, prec, Exact\n        ));\n    }\n}\n\n#[test]\nfn rational_div_float_prec_round_properties() {\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_5().test_properties(\n        |(y, x, prec, rm)| {\n            rational_div_float_prec_round_properties_helper(x, y, prec, rm, false);\n        },\n    );\n\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_10().test_properties(\n        |(y, x, prec, rm)| {\n            rational_div_float_prec_round_properties_helper(x, y, prec, rm, true);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        if !x.is_nan() && x != 0 {\n            assert_eq!(\n                Float::rational_div_float_prec_round_val_ref(Rational::ZERO, &x, prec, rm),\n                (\n                    if x > 0 {\n                        Float::ZERO\n                    } else {\n                        Float::NEGATIVE_ZERO\n                    },\n                    Equal\n                )\n            );\n        }\n    });\n\n    rational_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (quotient, o) = Float::rational_div_float_prec_round_ref_val(&x, Float::NAN, prec, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(\n            Float::rational_div_float_prec_round_ref_val(&x, Float::INFINITY, prec, rm),\n            (\n                if x >= 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                },\n                Equal\n            )\n        );\n        assert_eq!(\n            Float::rational_div_float_prec_round_ref_val(&x, Float::NEGATIVE_INFINITY, prec, rm),\n            (\n                if x >= 0 {\n                    Float::NEGATIVE_ZERO\n                } else {\n                    Float::ZERO\n                },\n                Equal\n            )\n        );\n        if x != 0 {\n            let (quotient, o) =\n                Float::rational_div_float_prec_round_ref_val(&x, Float::ZERO, prec, rm);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                })\n            );\n            assert_eq!(o, Equal);\n\n            let (quotient, o) =\n                Float::rational_div_float_prec_round_ref_val(&x, Float::NEGATIVE_ZERO, prec, rm);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::NEGATIVE_INFINITY\n                } else {\n                    Float::INFINITY\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\nfn rational_div_float_prec_properties_helper(x: Rational, y: Float, prec: u64, extreme: bool) {\n    let (quotient, o) = Float::rational_div_float_prec(x.clone(), y.clone(), prec);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = Float::rational_div_float_prec_val_ref(x.clone(), &y, prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = Float::rational_div_float_prec_ref_val(&x, y.clone(), prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n    let (quotient_alt, o_alt) = Float::rational_div_float_prec_ref_ref(&x, &y, prec);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if y.is_normal() {\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_direct(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    // TODO add rug comparison once https://gitlab.com/tspiteri/rug/-/issues/85 is resolved\n\n    let (quotient_alt, o_alt) = Float::rational_div_float_prec_round_ref_ref(&x, &y, prec, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if quotient.is_finite() && y.is_finite() {\n        if quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_quotient = &x / Rational::exact_from(&y);\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n        }\n    }\n\n    if x != 0u32 && y != 0u32 {\n        let (mut quotient_alt, mut o_alt) = Float::rational_div_float_prec_ref_val(&x, -&y, prec);\n        quotient_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (mut quotient_alt, mut o_alt) = Float::rational_div_float_prec_val_ref(-&x, &y, prec);\n        quotient_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n\n        let (quotient_alt, o_alt) = Float::rational_div_float_prec(-x, -y, prec);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn rational_div_float_prec_properties() {\n    float_rational_unsigned_triple_gen_var_1().test_properties(|(y, x, prec)| {\n        rational_div_float_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_rational_unsigned_triple_gen_var_2().test_properties(|(y, x, prec)| {\n        rational_div_float_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        if x.is_finite() && x != 0 {\n            let (quotient, o) = Float::rational_div_float_prec_val_ref(Rational::ZERO, &x, prec);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let (quotient, o) = Float::rational_div_float_prec_ref_val(&x, Float::NAN, prec);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        if x != 0 {\n            assert_eq!(\n                Float::rational_div_float_prec_ref_val(&x, Float::INFINITY, prec),\n                (\n                    if x >= 0 {\n                        Float::ZERO\n                    } else {\n                        Float::NEGATIVE_ZERO\n                    },\n                    Equal\n                )\n            );\n            assert_eq!(\n                Float::rational_div_float_prec_ref_val(&x, Float::NEGATIVE_INFINITY, prec),\n                (\n                    if x >= 0 {\n                        Float::NEGATIVE_ZERO\n                    } else {\n                        Float::ZERO\n                    },\n                    Equal\n                )\n            );\n        }\n\n        if x != 0 {\n            let (quotient, o) = Float::rational_div_float_prec_ref_val(&x, Float::ZERO, prec);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                })\n            );\n            assert_eq!(o, Equal);\n            let (quotient, o) =\n                Float::rational_div_float_prec_ref_val(&x, Float::NEGATIVE_ZERO, prec);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::NEGATIVE_INFINITY\n                } else {\n                    Float::INFINITY\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn rational_div_float_round_properties_helper(\n    x: Rational,\n    y: Float,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (quotient, o) = Float::rational_div_float_round(x.clone(), y.clone(), rm);\n    assert!(quotient.is_valid());\n    let (quotient_alt, o_alt) = Float::rational_div_float_round_val_ref(x.clone(), &y, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o_alt) = Float::rational_div_float_round_ref_val(&x, y.clone(), rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let (quotient_alt, o_alt) = Float::rational_div_float_round_ref_ref(&x, &y, rm);\n    assert!(quotient_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    if !extreme {\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_naive(x.clone(), y.clone(), y.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if y.is_normal() {\n        let (quotient_alt, o_alt) =\n            rational_div_float_prec_round_direct(x.clone(), y.clone(), y.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    // TODO add rug comparison once https://gitlab.com/tspiteri/rug/-/issues/85 is resolved\n\n    let (quotient_alt, o_alt) =\n        Float::rational_div_float_prec_round_ref_ref(&x, &y, y.significant_bits(), rm);\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    assert_eq!(o_alt, o);\n\n    if quotient.is_finite() && y.is_finite() {\n        if y.is_normal() && quotient.is_normal() {\n            assert_eq!(quotient.get_prec(), Some(y.get_prec().unwrap()));\n        }\n        if !extreme {\n            let r_quotient = &x / Rational::exact_from(&y);\n            assert_eq!(quotient.partial_cmp(&r_quotient), Some(o));\n            if o == Less {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if o == Greater {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n            match (r_quotient >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if y != 0 {\n        let (mut quotient_alt, mut o_alt) = Float::rational_div_float_round_ref_val(&x, -&y, -rm);\n        quotient_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(o_alt, o);\n        assert_eq!(\n            ComparableFloat(quotient_alt.abs_negative_zero_ref()),\n            ComparableFloat(quotient.abs_negative_zero_ref())\n        );\n    }\n\n    let (mut quotient_alt, mut o_alt) = Float::rational_div_float_round_val_ref(-&x, &y, -rm);\n    quotient_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(quotient_alt.abs_negative_zero_ref()),\n        ComparableFloat(quotient.abs_negative_zero_ref())\n    );\n\n    if x != 0 && y != 0 {\n        let (quotient_alt, o_alt) = Float::rational_div_float_round(-&x, -&y, rm);\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient),\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = Float::rational_div_float_round_ref_ref(&x, &y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(quotient.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(Float::rational_div_float_round_ref_ref(&x, &y, Exact));\n    }\n}\n\n#[test]\nfn rational_div_float_round_properties() {\n    float_rational_rounding_mode_triple_gen_var_6().test_properties(|(y, x, rm)| {\n        rational_div_float_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rational_rounding_mode_triple_gen_var_11().test_properties(|(y, x, rm)| {\n        rational_div_float_round_properties_helper(x, y, rm, true);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        if x.is_finite() && x != 0 {\n            let (quotient, o) = Float::rational_div_float_round_val_ref(Rational::ZERO, &x, rm);\n            assert_eq!(\n                ComparableFloat(quotient),\n                ComparableFloat(if x >= 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_rounding_mode_pair_gen_var_6().test_properties(|(x, rm)| {\n        let (quotient, o) = Float::rational_div_float_round_ref_val(&x, Float::NAN, rm);\n        assert!(quotient.is_nan());\n        assert_eq!(o, Equal);\n\n        if x != 0 {\n            assert_eq!(\n                Float::rational_div_float_round_ref_val(&x, Float::INFINITY, rm),\n                (\n                    if x >= 0 {\n                        Float::ZERO\n                    } else {\n                        Float::NEGATIVE_ZERO\n                    },\n                    Equal\n                )\n            );\n            assert_eq!(\n                Float::rational_div_float_round_ref_val(&x, Float::NEGATIVE_INFINITY, rm),\n                (\n                    if x >= 0 {\n                        Float::NEGATIVE_ZERO\n                    } else {\n                        Float::ZERO\n                    },\n                    Equal\n                )\n            );\n        }\n    });\n}\n\nfn rational_div_float_properties_helper(x: Rational, y: Float, extreme: bool) {\n    let quotient = x.clone() / y.clone();\n    assert!(quotient.is_valid());\n    let quotient_alt = x.clone() / &y;\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = &x / y.clone();\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = &x / &y;\n    assert!(quotient_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    if !extreme {\n        let quotient_alt = rational_div_float_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            y.significant_bits(),\n            Nearest,\n        )\n        .0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n    }\n\n    if y.is_normal() {\n        let quotient_alt = rational_div_float_prec_round_direct(\n            x.clone(),\n            y.clone(),\n            y.significant_bits(),\n            Nearest,\n        )\n        .0;\n        assert_eq!(\n            ComparableFloatRef(&quotient_alt),\n            ComparableFloatRef(&quotient)\n        );\n    }\n\n    let quotient_alt =\n        Float::rational_div_float_prec_round_ref_ref(&x, &y, y.significant_bits(), Nearest).0;\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = Float::rational_div_float_prec_ref_ref(&x, &y, y.significant_bits()).0;\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n    let quotient_alt = Float::rational_div_float_round_ref_ref(&x, &y, Nearest).0;\n    assert_eq!(\n        ComparableFloatRef(&quotient_alt),\n        ComparableFloatRef(&quotient)\n    );\n\n    if quotient.is_finite() && y.is_normal() && quotient.is_normal() {\n        assert_eq!(quotient.get_prec(), Some(y.get_prec().unwrap()));\n        if !extreme {\n            let r_quotient = &x / Rational::exact_from(&y);\n            if quotient < r_quotient {\n                let mut next = quotient.clone();\n                next.increment();\n                assert!(next > r_quotient);\n            } else if quotient > r_quotient {\n                let mut next = quotient.clone();\n                next.decrement();\n                assert!(next < r_quotient);\n            }\n        }\n    }\n\n    // TODO add rug comparison once https://gitlab.com/tspiteri/rug/-/issues/85 is resolved\n\n    if quotient != 0u32 {\n        assert_eq!(\n            ComparableFloatRef(&-(-&x / &y)),\n            ComparableFloatRef(&quotient)\n        );\n        if y != 0 {\n            assert_eq!(\n                ComparableFloatRef(&-(&x / -&y)),\n                ComparableFloatRef(&quotient)\n            );\n            assert_eq!(\n                ComparableFloatRef(&(-x / -y)),\n                ComparableFloatRef(&quotient)\n            );\n        }\n    }\n}\n\n#[test]\nfn rational_div_float_properties() {\n    float_rational_pair_gen().test_properties(|(y, x)| {\n        rational_div_float_properties_helper(x, y, false);\n    });\n\n    float_rational_pair_gen_var_2().test_properties(|(y, x)| {\n        rational_div_float_properties_helper(x, y, true);\n    });\n\n    float_gen().test_properties(|x| {\n        if x.is_finite() && x != 0 {\n            assert_eq!(\n                ComparableFloat(Rational::ZERO / &x),\n                ComparableFloat(if x.is_sign_positive() {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                }),\n            );\n            assert_eq!(\n                ComparableFloat(Rational::ZERO / &x),\n                ComparableFloat(if x.is_sign_positive() {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n        }\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!((Float::NAN / &x).is_nan());\n        assert_eq!(\n            Float::INFINITY / &x,\n            if x >= 0 {\n                Float::INFINITY\n            } else {\n                Float::NEGATIVE_INFINITY\n            }\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY / &x,\n            if x >= 0 {\n                Float::NEGATIVE_INFINITY\n            } else {\n                Float::INFINITY\n            }\n        );\n        if x != 0 {\n            assert_eq!(\n                Float::ZERO / &x,\n                if x > 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                }\n            );\n            assert_eq!(\n                Float::NEGATIVE_ZERO / &x,\n                if x > 0 {\n                    Float::NEGATIVE_ZERO\n                } else {\n                    Float::ZERO\n                }\n            );\n        }\n        let quotient_alt = Float::from_rational_prec_ref(&x, 1).0;\n        assert_eq!(\n            ComparableFloat(&x / Float::ONE),\n            ComparableFloat(quotient_alt.clone())\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_4, float_gen_var_12};\nuse malachite_q::Rational;\n\n#[test]\nfn test_is_power_of_2() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_power_of_2(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", false);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", true);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", true);\n    test(\"too_small\", \"0x1.0E-268435456#1\", true);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_power_of_2_properties_helper(x: Float) {\n    let is_power_of_2 = x.is_power_of_2();\n    if is_power_of_2 {\n        assert!(x > 0u32);\n    }\n}\n\n#[test]\nfn is_power_of_2_properties() {\n    float_gen().test_properties(|x| {\n        is_power_of_2_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_power_of_2_properties_helper(x);\n    });\n\n    float_gen_var_4().test_properties(|x| {\n        assert_eq!(x.is_power_of_2(), Rational::exact_from(x).is_power_of_2());\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(x.is_power_of_2(), Float::from(x).is_power_of_2());\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/ln.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\nuse core::{f32, f64};\nuse malachite_base::num::arithmetic::traits::{Ln, LnAssign, PowerOf2, Reciprocal};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, rounding_mode_gen, unsigned_gen_var_11,\n    unsigned_rounding_mode_pair_gen_var_3,\n};\nuse malachite_float::arithmetic::ln::{primitive_float_ln, primitive_float_ln_rational};\nuse malachite_float::test_util::arithmetic::ln::{\n    ln_prec_round_extended, rug_ln, rug_ln_prec, rug_ln_prec_round, rug_ln_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_12, float_rounding_mode_pair_gen_var_34,\n    float_rounding_mode_pair_gen_var_35, float_unsigned_pair_gen_var_1,\n    float_unsigned_pair_gen_var_4, float_unsigned_rounding_mode_triple_gen_var_19,\n    float_unsigned_rounding_mode_triple_gen_var_20,\n    rational_unsigned_rounding_mode_triple_gen_var_6,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_ln() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let ln = x.clone().ln();\n        assert!(ln.is_valid());\n\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n\n        let ln_alt = (&x).ln();\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n\n        let mut ln_alt = x.clone();\n        ln_alt.ln_assign();\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&ln),\n            ComparableFloatRef(\n                &ln_prec_round_extended(x.clone(), x.get_prec().unwrap_or(1), Nearest).0\n            )\n        );\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_ln(&rug::Float::exact_from(&x)))),\n            ComparableFloatRef(&ln)\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\"-0.0\", \"-0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\"1.0\", \"0x1.0#1\", \"0.0\", \"0x0.0\");\n    test(\"-1.0\", \"-0x1.0#1\", \"NaN\", \"NaN\");\n    test(\"1.0\", \"0x1.0000000000000000000000000#100\", \"0.0\", \"0x0.0\");\n    test(\"-1.0\", \"-0x1.0000000000000000000000000#100\", \"NaN\", \"NaN\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"4.81\", \"0x4.d#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1.1447298858494002\",\n        \"0x1.250d048e7a1bd#53\",\n    );\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"NaN\", \"NaN\");\n\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        \"1.577721810442023610823457130564e-30\",\n        \"0x1.ffffffffffffffffffffffffeE-25#100\",\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        \"-1.577721810442023610823457130566e-30\",\n        \"-0x2.0000000000000000000000000E-25#99\",\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        \"1.0\",\n        \"0x1.0000000000000#53\",\n    );\n}\n\n#[test]\nfn test_ln_prec() {\n    let test = |s, s_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (ln, o) = x.clone().ln_prec(prec);\n        assert!(ln.is_valid());\n\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, o_out);\n\n        let (ln_alt, o_alt) = x.ln_prec_ref(prec);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut ln_alt = x.clone();\n        let o_alt = ln_alt.ln_prec_assign(prec);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (ln_alt, o_alt) = ln_prec_round_extended(x.clone(), prec, Nearest);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (rug_ln, rug_o) = rug_ln_prec(&rug::Float::exact_from(&x), prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_ln)),\n            ComparableFloatRef(&ln),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    // - in ln_prec_round_normal\n    // - *x == 1u32 in ln_prec_round_normal\n    test(\"1.0\", \"0x1.0#1\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"NaN\", \"NaN\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"NaN\", \"NaN\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 1, \"4.0\", \"0x4.0#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 10, \"4.81\", \"0x4.d0#10\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"NaN\", \"NaN\", Equal);\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"1.145\",\n        \"0x1.250#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        1,\n        \"2.0e-30\",\n        \"0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        10,\n        \"1.578e-30\",\n        \"0x2.00E-25#10\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        1,\n        \"-2.0e-30\",\n        \"-0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        10,\n        \"-1.578e-30\",\n        \"-0x2.00E-25#10\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        10,\n        \"1.0\",\n        \"0x1.000#10\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        1000,\n        \"0.999999999999999946817622933941086294801645535631167330140966894773031833945843167502391\\\n        658696177866134372942956876650105751129080333063719848201745765425041221713102525849084801\\\n        372391581210765049471829553635989842946539858533293656242339571977421630183546441129939950\\\n        3482873700231381735818901075103963\",\n        \"0x0.fffffffffffffc2af5533763665751db2b3c952fde86afe1810bb66ea1494e989573a8be58f802b1c430a\\\n        02dc8ffc80b2e393a359078dce063403a2113f8777bb9d11195ac4058bd5552c15bae9bd34651b64dd0f9acde5\\\n        926173f1391023dd0bccba5e4cc09fab80c32b730f5bd7df655766e551cbd2672a9afa3df95#1000\",\n        Greater,\n    );\n    // - *x != 1u32 in ln_prec_round_normal\n    // - tmp1.is_normal() && tmp2.is_normal() in ln_prec_round_normal\n    // - !float_can_round in ln_prec_round_normal\n    // - float_can_round in ln_prec_round_normal\n    test(\"2.0\", \"0x2.0#1\", 1, \"0.5\", \"0x0.8#1\", Less);\n    // - !tmp1.is_normal() && !tmp2.is_normal() in ln_prec_round_normal\n    test(\n        \"0.999998\",\n        \"0x0.ffffe#19\",\n        5,\n        \"-1.9e-6\",\n        \"-0x0.000020#5\",\n        Greater,\n    );\n}\n\n#[test]\nfn ln_prec_fail() {\n    assert_panic!(Float::NAN.ln_prec(0));\n    assert_panic!(Float::NAN.ln_prec_ref(0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.ln_prec_assign(0)\n    });\n}\n\n#[test]\nfn test_ln_round() {\n    let test = |s, s_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (ln, o) = x.clone().ln_round(rm);\n        assert!(ln.is_valid());\n\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, o_out);\n\n        let (ln_alt, o_alt) = x.ln_round_ref(rm);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut ln_alt = x.clone();\n        let o_alt = ln_alt.ln_round_assign(rm);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (ln_alt, o_alt) = ln_prec_round_extended(x.clone(), x.get_prec().unwrap_or(1), rm);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_ln, rug_o) = rug_ln_round(&rug::Float::exact_from(&x), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_ln)),\n                ComparableFloatRef(&ln),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Ceiling, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Nearest, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Ceiling, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Nearest, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Up,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Exact,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", Floor, \"4.75\", \"0x4.c#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Ceiling, \"4.81\", \"0x4.d#7\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", Down, \"4.75\", \"0x4.c#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Up, \"4.81\", \"0x4.d#7\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", Nearest, \"4.81\", \"0x4.d#7\", Greater);\n\n    test(\"-123.0\", \"-0x7b.0#7\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"1.1447298858493999\",\n        \"0x1.250d048e7a1bc#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"1.1447298858494002\",\n        \"0x1.250d048e7a1bd#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"1.1447298858493999\",\n        \"0x1.250d048e7a1bc#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"1.1447298858494002\",\n        \"0x1.250d048e7a1bd#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"1.1447298858494002\",\n        \"0x1.250d048e7a1bd#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Nearest,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Nearest,\n        \"8.0e8\",\n        \"0x3.0E+7#2\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Nearest,\n        \"-5.0e8\",\n        \"-0x2.0E+7#1\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Nearest,\n        \"-8.0e8\",\n        \"-0x3.0E+7#2\",\n        Less,\n    );\n\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        Floor,\n        \"1.577721810442023610823457130564e-30\",\n        \"0x1.ffffffffffffffffffffffffeE-25#100\",\n        Less,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        Ceiling,\n        \"1.577721810442023610823457130566e-30\",\n        \"0x2.0000000000000000000000000E-25#100\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        Down,\n        \"1.577721810442023610823457130564e-30\",\n        \"0x1.ffffffffffffffffffffffffeE-25#100\",\n        Less,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        Up,\n        \"1.577721810442023610823457130566e-30\",\n        \"0x2.0000000000000000000000000E-25#100\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        Nearest,\n        \"1.577721810442023610823457130564e-30\",\n        \"0x1.ffffffffffffffffffffffffeE-25#100\",\n        Less,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        Floor,\n        \"-1.577721810442023610823457130571e-30\",\n        \"-0x2.0000000000000000000000008E-25#99\",\n        Less,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        Ceiling,\n        \"-1.577721810442023610823457130566e-30\",\n        \"-0x2.0000000000000000000000000E-25#99\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        Down,\n        \"-1.577721810442023610823457130566e-30\",\n        \"-0x2.0000000000000000000000000E-25#99\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        Up,\n        \"-1.577721810442023610823457130571e-30\",\n        \"-0x2.0000000000000000000000008E-25#99\",\n        Less,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        Nearest,\n        \"-1.577721810442023610823457130566e-30\",\n        \"-0x2.0000000000000000000000000E-25#99\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        Floor,\n        \"0.9999999999999999\",\n        \"0x0.fffffffffffff8#53\",\n        Less,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000#53\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        Down,\n        \"0.9999999999999999\",\n        \"0x0.fffffffffffff8#53\",\n        Less,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000#53\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000#53\",\n        Greater,\n    );\n}\n\n#[test]\nfn ln_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(THREE.ln_round(Exact));\n    assert_panic!(THREE.ln_round_ref(Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.ln_round_assign(Exact);\n    });\n}\n\n#[test]\nfn test_ln_prec_round() {\n    let test = |s, s_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (ln, o) = x.clone().ln_prec_round(prec, rm);\n        assert!(ln.is_valid());\n\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, o_out);\n\n        let (ln_alt, o_alt) = x.ln_prec_round_ref(prec, rm);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut ln_alt = x.clone();\n        let o_alt = ln_alt.ln_prec_round_assign(prec, rm);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (ln_alt, o_alt) = ln_prec_round_extended(x.clone(), prec, rm);\n        assert!(ln_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_ln, rug_o) = rug_ln_prec_round(&rug::Float::exact_from(&x), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_ln)),\n                ComparableFloatRef(&ln),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\"-Infinity\", \"-Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", 1, Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Ceiling, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Nearest, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", 1, Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", 1, Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", 1, Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", 1, Floor, \"4.0\", \"0x4.0#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Ceiling, \"8.0\", \"0x8.0#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 1, Down, \"4.0\", \"0x4.0#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Up, \"8.0\", \"0x8.0#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 1, Nearest, \"4.0\", \"0x4.0#1\", Less);\n\n    test(\"123.0\", \"0x7b.0#7\", 10, Floor, \"4.805\", \"0x4.ce#10\", Less);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"4.81\",\n        \"0x4.d0#10\",\n        Greater,\n    );\n    test(\"123.0\", \"0x7b.0#7\", 10, Down, \"4.805\", \"0x4.ce#10\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 10, Up, \"4.81\", \"0x4.d0#10\", Greater);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"4.81\",\n        \"0x4.d0#10\",\n        Greater,\n    );\n\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"1.145\",\n        \"0x1.250#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"1.146\",\n        \"0x1.258#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"1.145\",\n        \"0x1.250#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"1.146\",\n        \"0x1.258#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"1.145\",\n        \"0x1.250#10\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        1,\n        Floor,\n        \"8.0e-31\",\n        \"0x1.0E-25#1\",\n        Less,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        10,\n        Floor,\n        \"1.576e-30\",\n        \"0x1.ff8E-25#10\",\n        Less,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        1,\n        Ceiling,\n        \"2.0e-30\",\n        \"0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        10,\n        Ceiling,\n        \"1.578e-30\",\n        \"0x2.00E-25#10\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        1,\n        Down,\n        \"8.0e-31\",\n        \"0x1.0E-25#1\",\n        Less,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        10,\n        Down,\n        \"1.576e-30\",\n        \"0x1.ff8E-25#10\",\n        Less,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        1,\n        Up,\n        \"2.0e-30\",\n        \"0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        10,\n        Up,\n        \"1.578e-30\",\n        \"0x2.00E-25#10\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        1,\n        Nearest,\n        \"2.0e-30\",\n        \"0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n        10,\n        Nearest,\n        \"1.578e-30\",\n        \"0x2.00E-25#10\",\n        Greater,\n    );\n\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        1,\n        Floor,\n        \"-3.0e-30\",\n        \"-0x4.0E-25#1\",\n        Less,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        10,\n        Floor,\n        \"-1.581e-30\",\n        \"-0x2.01E-25#10\",\n        Less,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        1,\n        Ceiling,\n        \"-2.0e-30\",\n        \"-0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        10,\n        Ceiling,\n        \"-1.578e-30\",\n        \"-0x2.00E-25#10\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        1,\n        Down,\n        \"-2.0e-30\",\n        \"-0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        10,\n        Down,\n        \"-1.578e-30\",\n        \"-0x2.00E-25#10\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        1,\n        Up,\n        \"-3.0e-30\",\n        \"-0x4.0E-25#1\",\n        Less,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        10,\n        Up,\n        \"-1.581e-30\",\n        \"-0x2.01E-25#10\",\n        Less,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        1,\n        Nearest,\n        \"-2.0e-30\",\n        \"-0x2.0E-25#1\",\n        Greater,\n    );\n    test(\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n        10,\n        Nearest,\n        \"-1.578e-30\",\n        \"-0x2.00E-25#10\",\n        Greater,\n    );\n\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        1,\n        Floor,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        10,\n        Floor,\n        \"0.999\",\n        \"0x0.ffc#10\",\n        Less,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        10,\n        Ceiling,\n        \"1.0\",\n        \"0x1.000#10\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        1,\n        Down,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        10,\n        Down,\n        \"0.999\",\n        \"0x0.ffc#10\",\n        Less,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        10,\n        Up,\n        \"1.0\",\n        \"0x1.000#10\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Greater,\n    );\n}\n\n#[test]\nfn ln_prec_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::one_prec(1).ln_prec_round(0, Floor));\n    assert_panic!(Float::one_prec(1).ln_prec_round_ref(0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.ln_prec_round_assign(0, Floor)\n    });\n\n    assert_panic!(THREE.ln_prec_round(1, Exact));\n    assert_panic!(THREE.ln_prec_round_ref(1, Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.ln_prec_round_assign(1, Exact)\n    });\n}\n\n#[test]\nfn test_ln_rational_prec() {\n    let test = |s, prec, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (ln, o) = Float::ln_rational_prec(u.clone(), prec);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n\n        let (ln, o) = Float::ln_rational_prec_ref(&u, prec);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n    };\n    test(\"0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 10, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 100, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"1\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 100, \"0.0\", \"0x0.0\", Equal);\n    test(\"1/2\", 1, \"-0.5\", \"-0x0.8#1\", Greater);\n    test(\"1/2\", 10, \"-0.693\", \"-0x0.b18#10\", Less);\n    test(\n        \"1/2\",\n        100,\n        \"-0.693147180559945309417232121458\",\n        \"-0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Greater,\n    );\n    test(\"1/3\", 1, \"-1.0\", \"-0x1.0#1\", Greater);\n    test(\"1/3\", 10, \"-1.098\", \"-0x1.190#10\", Greater);\n    test(\n        \"1/3\",\n        100,\n        \"-1.098612288668109691395245236922\",\n        \"-0x1.193ea7aad030a976a4198d550#100\",\n        Greater,\n    );\n    test(\"22/7\", 1, \"1.0\", \"0x1.0#1\", Less);\n    test(\"22/7\", 10, \"1.145\", \"0x1.250#10\", Less);\n    test(\n        \"22/7\",\n        100,\n        \"1.14513230430300254837382295598\",\n        \"0x1.2527640493137b5c5ee7165de#100\",\n        Greater,\n    );\n\n    let test_big = |u: Rational, prec, out, out_hex, out_o| {\n        let (ln, o) = Float::ln_rational_prec(u.clone(), prec);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n\n        let (ln, o) = Float::ln_rational_prec_ref(&u, prec);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        \"693.0\",\n        \"0x2b5.0#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        \"-693.0\",\n        \"-0x2b5.0#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n}\n\n#[test]\nfn ln_rational_prec_fail() {\n    assert_panic!(Float::ln_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::ln_rational_prec(Rational::ONE, 0));\n    assert_panic!(Float::ln_rational_prec(Rational::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn ln_rational_prec_ref_fail() {\n    assert_panic!(Float::ln_rational_prec_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::ln_rational_prec_ref(&Rational::ONE, 0));\n    assert_panic!(Float::ln_rational_prec_ref(&Rational::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn test_ln_rational_prec_round_xxx() {\n    let test = |s, prec, rm, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (ln, o) = Float::ln_rational_prec_round(u.clone(), prec, rm);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n\n        let (ln, o) = Float::ln_rational_prec_round_ref(&u, prec, rm);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n    };\n    test(\"0\", 1, Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 1, Ceiling, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 1, Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 1, Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 1, Nearest, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 1, Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"0\", 10, Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 10, Ceiling, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 10, Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 10, Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 10, Nearest, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 10, Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"0\", 100, Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 100, Ceiling, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 100, Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 100, Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 100, Nearest, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"0\", 100, Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"1\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 100, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 100, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 100, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 100, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 100, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 100, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1/2\", 1, Floor, \"-1.0\", \"-0x1.0#1\", Less);\n    test(\"1/2\", 1, Ceiling, \"-0.5\", \"-0x0.8#1\", Greater);\n    test(\"1/2\", 1, Down, \"-0.5\", \"-0x0.8#1\", Greater);\n    test(\"1/2\", 1, Up, \"-1.0\", \"-0x1.0#1\", Less);\n    test(\"1/2\", 1, Nearest, \"-0.5\", \"-0x0.8#1\", Greater);\n\n    test(\"1/2\", 10, Floor, \"-0.693\", \"-0x0.b18#10\", Less);\n    test(\"1/2\", 10, Ceiling, \"-0.692\", \"-0x0.b14#10\", Greater);\n    test(\"1/2\", 10, Down, \"-0.692\", \"-0x0.b14#10\", Greater);\n    test(\"1/2\", 10, Up, \"-0.693\", \"-0x0.b18#10\", Less);\n    test(\"1/2\", 10, Nearest, \"-0.693\", \"-0x0.b18#10\", Less);\n\n    test(\n        \"1/2\",\n        100,\n        Floor,\n        \"-0.693147180559945309417232121459\",\n        \"-0x0.b17217f7d1cf79abc9e3b3981#100\",\n        Less,\n    );\n    test(\n        \"1/2\",\n        100,\n        Ceiling,\n        \"-0.693147180559945309417232121458\",\n        \"-0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Greater,\n    );\n    test(\n        \"1/2\",\n        100,\n        Down,\n        \"-0.693147180559945309417232121458\",\n        \"-0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Greater,\n    );\n    test(\n        \"1/2\",\n        100,\n        Up,\n        \"-0.693147180559945309417232121459\",\n        \"-0x0.b17217f7d1cf79abc9e3b3981#100\",\n        Less,\n    );\n    test(\n        \"1/2\",\n        100,\n        Nearest,\n        \"-0.693147180559945309417232121458\",\n        \"-0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Greater,\n    );\n\n    test(\"1/3\", 1, Floor, \"-2.0\", \"-0x2.0#1\", Less);\n    test(\"1/3\", 1, Ceiling, \"-1.0\", \"-0x1.0#1\", Greater);\n    test(\"1/3\", 1, Down, \"-1.0\", \"-0x1.0#1\", Greater);\n    test(\"1/3\", 1, Up, \"-2.0\", \"-0x2.0#1\", Less);\n    test(\"1/3\", 1, Nearest, \"-1.0\", \"-0x1.0#1\", Greater);\n\n    test(\"1/3\", 10, Floor, \"-1.1\", \"-0x1.198#10\", Less);\n    test(\"1/3\", 10, Ceiling, \"-1.098\", \"-0x1.190#10\", Greater);\n    test(\"1/3\", 10, Down, \"-1.098\", \"-0x1.190#10\", Greater);\n    test(\"1/3\", 10, Up, \"-1.1\", \"-0x1.198#10\", Less);\n    test(\"1/3\", 10, Nearest, \"-1.098\", \"-0x1.190#10\", Greater);\n\n    test(\n        \"1/3\",\n        100,\n        Floor,\n        \"-1.098612288668109691395245236924\",\n        \"-0x1.193ea7aad030a976a4198d552#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Ceiling,\n        \"-1.098612288668109691395245236922\",\n        \"-0x1.193ea7aad030a976a4198d550#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Down,\n        \"-1.098612288668109691395245236922\",\n        \"-0x1.193ea7aad030a976a4198d550#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Up,\n        \"-1.098612288668109691395245236924\",\n        \"-0x1.193ea7aad030a976a4198d552#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Nearest,\n        \"-1.098612288668109691395245236922\",\n        \"-0x1.193ea7aad030a976a4198d550#100\",\n        Greater,\n    );\n\n    test(\"22/7\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"22/7\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"22/7\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"22/7\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"22/7\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test(\"22/7\", 10, Floor, \"1.145\", \"0x1.250#10\", Less);\n    test(\"22/7\", 10, Ceiling, \"1.146\", \"0x1.258#10\", Greater);\n    test(\"22/7\", 10, Down, \"1.145\", \"0x1.250#10\", Less);\n    test(\"22/7\", 10, Up, \"1.146\", \"0x1.258#10\", Greater);\n    test(\"22/7\", 10, Nearest, \"1.145\", \"0x1.250#10\", Less);\n\n    test(\n        \"22/7\",\n        100,\n        Floor,\n        \"1.145132304303002548373822955979\",\n        \"0x1.2527640493137b5c5ee7165dc#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Ceiling,\n        \"1.14513230430300254837382295598\",\n        \"0x1.2527640493137b5c5ee7165de#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Down,\n        \"1.145132304303002548373822955979\",\n        \"0x1.2527640493137b5c5ee7165dc#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Up,\n        \"1.14513230430300254837382295598\",\n        \"0x1.2527640493137b5c5ee7165de#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Nearest,\n        \"1.14513230430300254837382295598\",\n        \"0x1.2527640493137b5c5ee7165de#100\",\n        Greater,\n    );\n\n    test(\"-1\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n\n    let test_big = |u: Rational, prec, rm, out, out_hex, out_o| {\n        let (ln, o) = Float::ln_rational_prec_round(u.clone(), prec, rm);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n\n        let (ln, o) = Float::ln_rational_prec_round_ref(&u, prec, rm);\n        assert!(ln.is_valid());\n        assert_eq!(ln.to_string(), out);\n        assert_eq!(to_hex_string(&ln), out_hex);\n        assert_eq!(o, out_o);\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Floor,\n        \"693.0\",\n        \"0x2b5.0#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Ceiling,\n        \"694.0\",\n        \"0x2b6.0#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Down,\n        \"693.0\",\n        \"0x2b5.0#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Up,\n        \"694.0\",\n        \"0x2b6.0#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Nearest,\n        \"693.0\",\n        \"0x2b5.0#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"7.43e8\",\n        \"0x2.c5E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"7.43e8\",\n        \"0x2.c5E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"7.43e8\",\n        \"0x2.c5E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"7.43e8\",\n        \"0x2.c5E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"7.44e8\",\n        \"0x2.c6E+7#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Floor,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Ceiling,\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Down,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Up,\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Nearest,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Floor,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Ceiling,\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Down,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Up,\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Nearest,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Floor,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Ceiling,\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Down,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Up,\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Nearest,\n        \"5.0e8\",\n        \"0x2.0E+7#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Floor,\n        \"-694.0\",\n        \"-0x2b6.0#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Ceiling,\n        \"-693.0\",\n        \"-0x2b5.0#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Down,\n        \"-693.0\",\n        \"-0x2b5.0#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Up,\n        \"-694.0\",\n        \"-0x2b6.0#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Nearest,\n        \"-693.0\",\n        \"-0x2b5.0#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"-7.43e8\",\n        \"-0x2.c5E+7#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"-7.44e8\",\n        \"-0x2.c6E+7#10\",\n        Less,\n    );\n}\n\n#[test]\nfn ln_rational_prec_round_fail() {\n    assert_panic!(Float::ln_rational_prec_round(Rational::ZERO, 0, Floor));\n    assert_panic!(Float::ln_rational_prec_round(Rational::ONE, 0, Floor));\n    assert_panic!(Float::ln_rational_prec_round(\n        Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::ln_rational_prec_round(\n        Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::ln_rational_prec_round(\n        Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n}\n\n#[test]\nfn ln_rational_prec_round_ref_fail() {\n    assert_panic!(Float::ln_rational_prec_round_ref(&Rational::ZERO, 0, Floor));\n    assert_panic!(Float::ln_rational_prec_round_ref(&Rational::ONE, 0, Floor));\n    assert_panic!(Float::ln_rational_prec_round_ref(\n        &Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::ln_rational_prec_round_ref(\n        &Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::ln_rational_prec_round_ref(\n        &Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn ln_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode) {\n    let (ln, o) = x.clone().ln_prec_round(prec, rm);\n    assert!(ln.is_valid());\n\n    let (ln_alt, o_alt) = x.ln_prec_round_ref(prec, rm);\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.ln_prec_round_assign(prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    let (ln_alt, o_alt) = ln_prec_round_extended(x.clone(), prec, rm);\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_ln, rug_o) = rug_ln_prec_round(&rug::Float::exact_from(&x), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_ln)),\n            ComparableFloatRef(&ln),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if x >= 0u32 && x.is_finite() {\n        assert!(ln < x);\n    }\n\n    if ln.is_normal() {\n        assert_eq!(ln.get_prec(), Some(prec));\n        if x > 1u32 && o > Less {\n            assert!(ln > 0u32);\n        } else if x < 1u32 && o < Greater {\n            assert!(ln < 0u32);\n        }\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.ln_prec_round_ref(prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(ln.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.ln_prec_round_ref(prec, Exact));\n    }\n}\n\n#[test]\nfn ln_prec_round_properties() {\n    float_unsigned_rounding_mode_triple_gen_var_19().test_properties(|(x, prec, rm)| {\n        ln_prec_round_properties_helper(x, prec, rm);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_20().test_properties(|(x, prec, rm)| {\n        ln_prec_round_properties_helper(x, prec, rm);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {\n        let (ln, o) = Float::NAN.ln_prec_round(prec, rm);\n        assert!(ln.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.ln_prec_round(prec, rm),\n            (Float::INFINITY, Equal)\n        );\n\n        let (s, o) = Float::NEGATIVE_INFINITY.ln_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::ZERO.ln_prec_round(prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        assert_eq!(\n            Float::NEGATIVE_ZERO.ln_prec_round(prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        assert_eq!(Float::ONE.ln_prec_round(prec, rm), (Float::ZERO, Equal));\n\n        let (s, o) = Float::NEGATIVE_ONE.ln_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn ln_prec_properties_helper(x: Float, prec: u64) {\n    let (ln, o) = x.clone().ln_prec(prec);\n    assert!(ln.is_valid());\n\n    let (ln_alt, o_alt) = x.ln_prec_ref(prec);\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.ln_prec_assign(prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    let (ln_alt, o_alt) = ln_prec_round_extended(x.clone(), prec, Nearest);\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n    assert_eq!(o_alt, o);\n\n    let (rug_ln, rug_o) = rug_ln_prec(&rug::Float::exact_from(&x), prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_ln)),\n        ComparableFloatRef(&ln),\n    );\n    assert_eq!(rug_o, o);\n\n    let (ln_alt, o_alt) = x.ln_prec_round_ref(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    if x >= 0u32 && x.is_finite() {\n        assert!(ln < x);\n    }\n\n    if ln.is_normal() {\n        assert_eq!(ln.get_prec(), Some(prec));\n        if x > 1u32 && o > Less {\n            assert!(ln > 0u32);\n        } else if x < 1u32 && o < Greater {\n            assert!(ln < 0u32);\n        }\n    }\n}\n\n#[test]\nfn ln_prec_properties() {\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        ln_prec_properties_helper(x, prec);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_unsigned_pair_gen_var_1().test_properties_with_config(&config, |(x, prec)| {\n        ln_prec_properties_helper(x, prec);\n    });\n\n    float_unsigned_pair_gen_var_4().test_properties(|(x, prec)| {\n        ln_prec_properties_helper(x, prec);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (ln, o) = Float::NAN.ln_prec(prec);\n        assert!(ln.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::ZERO.ln_prec(prec), (Float::NEGATIVE_INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_ZERO.ln_prec(prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        assert_eq!(Float::INFINITY.ln_prec(prec), (Float::INFINITY, Equal));\n        let (ln, o) = Float::NEGATIVE_INFINITY.ln_prec(prec);\n        assert_eq!(ComparableFloat(ln), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::ONE.ln_prec(prec), (Float::ZERO, Equal));\n\n        let (ln, o) = Float::NEGATIVE_ONE.ln_prec(prec);\n        assert_eq!(ComparableFloat(ln), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn ln_round_properties_helper(x: Float, rm: RoundingMode) {\n    let (ln, o) = x.clone().ln_round(rm);\n    assert!(ln.is_valid());\n\n    let (ln_alt, o_alt) = x.ln_round_ref(rm);\n    assert!(ln_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.ln_round_assign(rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    let (ln_alt, o_alt) = x.ln_prec_round_ref(x.significant_bits(), rm);\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    if x >= 0u32 && x.is_finite() {\n        assert!(ln < x);\n    }\n\n    if ln.is_normal() {\n        assert_eq!(ln.get_prec(), Some(x.get_prec().unwrap()));\n        if x > 1u32 && o > Less {\n            assert!(ln > 0u32);\n        } else if x < 1u32 && o < Greater {\n            assert!(ln < 0u32);\n        }\n    }\n\n    let (ln_alt, o_alt) = ln_prec_round_extended(x.clone(), x.get_prec().unwrap_or(1), rm);\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln), ComparableFloatRef(&ln_alt));\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_ln, rug_o) = rug_ln_round(&rug::Float::exact_from(&x), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_ln)),\n            ComparableFloatRef(&ln),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.ln_round_ref(rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(ln.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.ln_round_ref(Exact));\n    }\n}\n\n#[test]\nfn ln_round_properties() {\n    float_rounding_mode_pair_gen_var_34().test_properties(|(x, rm)| {\n        ln_round_properties_helper(x, rm);\n    });\n\n    float_rounding_mode_pair_gen_var_35().test_properties(|(x, rm)| {\n        ln_round_properties_helper(x, rm);\n    });\n\n    rounding_mode_gen().test_properties(|rm| {\n        let (ln, o) = Float::NAN.ln_round(rm);\n        assert!(ln.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::ZERO.ln_round(rm), (Float::NEGATIVE_INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_ZERO.ln_round(rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        assert_eq!(Float::INFINITY.ln_round(rm), (Float::INFINITY, Equal));\n        let (ln, o) = Float::NEGATIVE_INFINITY.ln_round(rm);\n        assert_eq!(ComparableFloat(ln), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::ONE.ln_round(rm), (Float::ZERO, Equal));\n\n        let (ln, o) = Float::NEGATIVE_ONE.ln_round(rm);\n        assert_eq!(ComparableFloat(ln), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn ln_properties_helper(x: Float) {\n    let ln = x.clone().ln();\n    assert!(ln.is_valid());\n\n    let ln_alt = (&x).ln();\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n\n    let mut x_alt = x.clone();\n    x_alt.ln_assign();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&ln));\n\n    let ln_alt = x.ln_prec_round_ref(x.significant_bits(), Nearest).0;\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    let ln_alt = x.ln_prec_ref(x.significant_bits()).0;\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n\n    let ln_alt = x.ln_round_ref(Nearest).0;\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n\n    if x >= 0u32 && x.is_finite() {\n        assert!(ln < x);\n    }\n\n    let ln_alt = ln_prec_round_extended(x.clone(), x.get_prec().unwrap_or(1), Nearest).0;\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n\n    let rug_ln = rug_ln(&rug::Float::exact_from(&x));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_ln)),\n        ComparableFloatRef(&ln),\n    );\n}\n\n#[test]\nfn ln_properties() {\n    float_gen().test_properties(|x| {\n        ln_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        ln_properties_helper(x);\n    });\n}\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_primitive_float_ln() {\n    fn test<T: PrimitiveFloat>(x: T, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n    {\n        assert_eq!(NiceFloat(primitive_float_ln(x)), NiceFloat(out));\n    }\n    test::<f32>(f32::NAN, f32::NAN);\n    test::<f32>(f32::INFINITY, f32::INFINITY);\n    test::<f32>(f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(0.0, f32::NEGATIVE_INFINITY);\n    test::<f32>(-0.0, f32::NEGATIVE_INFINITY);\n    test::<f32>(1.0, 0.0);\n    test::<f32>(-1.0, f32::NAN);\n    test::<f32>(0.5, -std::f32::consts::LN_2);\n    test::<f32>(-0.5, f32::NAN);\n    test::<f32>(2.0, std::f32::consts::LN_2);\n    test::<f32>(-2.0, f32::NAN);\n    test::<f32>(core::f32::consts::PI, 1.14473);\n    test::<f32>(-core::f32::consts::PI, f32::NAN);\n    test::<f32>(core::f32::consts::E, 0.99999994);\n    test::<f32>(-core::f32::consts::E, f32::NAN);\n\n    test::<f64>(f64::NAN, f64::NAN);\n    test::<f64>(f64::INFINITY, f64::INFINITY);\n    test::<f64>(f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(0.0, f64::NEGATIVE_INFINITY);\n    test::<f64>(-0.0, f64::NEGATIVE_INFINITY);\n    test::<f64>(1.0, 0.0);\n    test::<f64>(-1.0, f64::NAN);\n    test::<f64>(0.5, -std::f64::consts::LN_2);\n    test::<f64>(-0.5, f64::NAN);\n    test::<f64>(2.0, std::f64::consts::LN_2);\n    test::<f64>(-2.0, f64::NAN);\n    test::<f64>(core::f64::consts::PI, 1.1447298858494002);\n    test::<f64>(-core::f64::consts::PI, f64::NAN);\n    test::<f64>(core::f64::consts::E, 1.0);\n    test::<f64>(-core::f64::consts::E, f64::NAN);\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn primitive_float_ln_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_gen::<T>().test_properties(|x| {\n        primitive_float_ln(x);\n    });\n}\n\n#[test]\nfn primitive_float_ln_properties() {\n    apply_fn_to_primitive_floats!(primitive_float_ln_properties_helper);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn ln_rational_prec_round_properties_helper(x: Rational, prec: u64, rm: RoundingMode) {\n    let (ln, o) = Float::ln_rational_prec_round(x.clone(), prec, rm);\n    assert!(ln.is_valid());\n\n    let (ln_alt, o_alt) = Float::ln_rational_prec_round_ref(&x, prec, rm);\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    if x != 0u32 {\n        let (ln_alt, o_alt) = Float::ln_rational_prec_round((&x).reciprocal(), prec, -rm);\n        assert!(ln_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&(-ln_alt).abs_negative_zero()),\n            ComparableFloatRef(&ln.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt.reverse(), o);\n    }\n\n    if x >= 0u32 {\n        assert!(ln < x);\n    }\n\n    if ln.is_normal() {\n        assert_eq!(ln.get_prec(), Some(prec));\n        if x > 1u32 && o > Less {\n            assert!(ln > 0u32);\n        } else if x < 1u32 && o < Greater {\n            assert!(ln < 0u32);\n        }\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = Float::ln_rational_prec_round_ref(&x, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(ln.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(Float::ln_rational_prec_round_ref(&x, prec, Exact));\n    }\n}\n\n#[test]\nfn ln_rational_prec_round_properties() {\n    rational_unsigned_rounding_mode_triple_gen_var_6().test_properties(|(x, prec, rm)| {\n        ln_rational_prec_round_properties_helper(x, prec, rm);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {\n        assert_eq!(\n            Float::ln_rational_prec_round(Rational::ZERO, prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        assert_eq!(\n            Float::ln_rational_prec_round(Rational::ONE, prec, rm),\n            (Float::ZERO, Equal)\n        );\n\n        let (s, o) = Float::ln_rational_prec_round(Rational::NEGATIVE_ONE, prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn ln_rational_prec_properties_helper(x: Rational, prec: u64) {\n    let (ln, o) = Float::ln_rational_prec(x.clone(), prec);\n    assert!(ln.is_valid());\n\n    let (ln_alt, o_alt) = Float::ln_rational_prec_ref(&x, prec);\n    assert!(ln_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    let (ln_alt, o_alt) = Float::ln_rational_prec_round_ref(&x, prec, Nearest);\n    assert_eq!(ComparableFloatRef(&ln_alt), ComparableFloatRef(&ln));\n    assert_eq!(o_alt, o);\n\n    if x != 0u32 {\n        let (ln_alt, o_alt) = Float::ln_rational_prec((&x).reciprocal(), prec);\n        assert!(ln_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&(-ln_alt).abs_negative_zero()),\n            ComparableFloatRef(&ln.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt.reverse(), o);\n    }\n\n    if x >= 0u32 {\n        assert!(ln < x);\n    }\n\n    if ln.is_normal() {\n        assert_eq!(ln.get_prec(), Some(prec));\n        if x > 1u32 && o > Less {\n            assert!(ln > 0u32);\n        } else if x < 1u32 && o < Greater {\n            assert!(ln < 0u32);\n        }\n    }\n}\n\n#[test]\nfn ln_rational_prec_properties() {\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        ln_rational_prec_properties_helper(x, prec);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_eq!(\n            Float::ln_rational_prec(Rational::ZERO, prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::ln_rational_prec(Rational::ONE, prec),\n            (Float::ZERO, Equal)\n        );\n        let (ln, o) = Float::ln_rational_prec(Rational::NEGATIVE_ONE, prec);\n        assert_eq!(ComparableFloat(ln), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_primitive_float_ln_rational() {\n    fn test<T: PrimitiveFloat>(s: &str, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n    {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(NiceFloat(primitive_float_ln_rational(&u)), NiceFloat(out));\n    }\n    test::<f32>(\"0\", f32::NEGATIVE_INFINITY);\n    test::<f32>(\"1\", 0.0);\n    test::<f32>(\"1/2\", -std::f32::consts::LN_2);\n    test::<f32>(\"1/3\", -1.0986123);\n    test::<f32>(\"22/7\", 1.1451323);\n    test::<f32>(\"1000000\", 13.815511);\n    test::<f32>(\"1/1000000\", -13.815511);\n    test::<f32>(\"-1\", f32::NAN);\n    test::<f32>(\"-1/2\", f32::NAN);\n    test::<f32>(\"-1/3\", f32::NAN);\n    test::<f32>(\"-22/7\", f32::NAN);\n\n    test::<f64>(\"0\", f64::NEGATIVE_INFINITY);\n    test::<f64>(\"1\", 0.0);\n    test::<f64>(\"1/2\", -std::f64::consts::LN_2);\n    test::<f64>(\"1/3\", -1.0986122886681098);\n    test::<f64>(\"22/7\", 1.1451323043030026);\n    test::<f64>(\"1000000\", 13.815510557964274);\n    test::<f64>(\"1/1000000\", -13.815510557964274);\n    test::<f64>(\"-1\", f64::NAN);\n    test::<f64>(\"-1/2\", f64::NAN);\n    test::<f64>(\"-1/3\", f64::NAN);\n    test::<f64>(\"-22/7\", f64::NAN);\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn primitive_float_ln_rational_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    rational_gen().test_properties(|x| {\n        let y = primitive_float_ln_rational::<T>(&x);\n        if x != 0u32 {\n            assert_eq!(\n                NiceFloat(primitive_float_ln_rational(&x.reciprocal()).abs_negative_zero()),\n                NiceFloat((-y).abs_negative_zero())\n            );\n        }\n    });\n}\n\n#[test]\nfn primitive_float_ln_rational_properties() {\n    apply_fn_to_primitive_floats!(primitive_float_ln_rational_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::{\n    Ordering::{self, *},\n    max,\n};\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::arithmetic::mul::{\n    mul_rational_prec_round_direct, mul_rational_prec_round_direct_ref_ref,\n    mul_rational_prec_round_direct_ref_val, mul_rational_prec_round_direct_val_ref,\n    mul_rational_prec_round_naive, mul_rational_prec_round_naive_ref_ref,\n    mul_rational_prec_round_naive_ref_val, mul_rational_prec_round_naive_val_ref,\n};\nuse malachite_float::emulate_float_float_to_float_fn;\nuse malachite_float::test_util::arithmetic::mul::{\n    mul_prec_round_naive, rug_mul, rug_mul_prec, rug_mul_prec_round, rug_mul_rational,\n    rug_mul_rational_prec, rug_mul_rational_prec_round, rug_mul_rational_round, rug_mul_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_16, float_float_rounding_mode_triple_gen_var_17,\n    float_float_rounding_mode_triple_gen_var_18, float_float_rounding_mode_triple_gen_var_19,\n    float_float_rounding_mode_triple_gen_var_20, float_float_rounding_mode_triple_gen_var_21,\n    float_float_rounding_mode_triple_gen_var_22, float_float_rounding_mode_triple_gen_var_31,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_7, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_2, float_gen, float_pair_gen, float_pair_gen_var_2,\n    float_pair_gen_var_3, float_pair_gen_var_4, float_pair_gen_var_5, float_pair_gen_var_6,\n    float_pair_gen_var_7, float_pair_gen_var_10, float_rational_pair_gen,\n    float_rational_pair_gen_var_2, float_rational_rounding_mode_triple_gen_var_4,\n    float_rational_rounding_mode_triple_gen_var_9,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_8,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_2,\n    float_rounding_mode_pair_gen, float_unsigned_pair_gen_var_1,\n    float_unsigned_rounding_mode_triple_gen_var_1, rational_rounding_mode_pair_gen_var_6,\n    rational_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mul() {\n    let test = |s, s_hex, t, t_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let product = x.clone() * y.clone();\n        assert!(product.is_valid());\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n\n        let product_alt = x.clone() * &y;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let product_alt = &x * y.clone();\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let product_alt = &x * &y;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n\n        let mut product_alt = x.clone();\n        product_alt *= y.clone();\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let mut product_alt = x.clone();\n        product_alt *= &y;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_mul(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y)\n            ))),\n            ComparableFloatRef(&product)\n        );\n\n        let product_alt = mul_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", \"NaN\", \"NaN\");\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\"-Infinity\", \"-Infinity\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"-Infinity\", \"-Infinity\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", \"-0.0\", \"-0x0.0\");\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", \"0.0\", \"0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\");\n    test(\"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\");\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n    );\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\");\n    test(\"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", \"123.0\", \"0x7b.0#7\");\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", \"2.0\", \"0x2.0#1\");\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", \"2.0\", \"0x2.0#2\");\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", \"2.0\", \"0x2.0#2\");\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", \"2.0\", \"0x2.0#2\");\n    test(\"1.0\", \"0x1.000#10\", \"2.0\", \"0x2.00#10\", \"2.0\", \"0x2.00#10\");\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n    );\n\n    // - in mul_float_significands_same_prec_lt_w\n    // - decrement_exp in mul_float_significands_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    // - !decrement_exp in mul_float_significands_same_prec_lt_w\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_lt_w\n    // - rm == Nearest in mul_float_significands_same_prec_lt_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (product & shift_bit) == 0)) in\n    //   mul_float_significands_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#2\", \"2.0\", \"0x2.0#2\");\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (product & shift_bit) != 0) &&\n    //   product.overflowing_add_assign(shift_bit) in mul_float_significands_same_prec_lt_w\n    test(\"1.2\", \"0x1.4#3\", \"1.5\", \"0x1.8#3\", \"2.0\", \"0x2.0#3\");\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (product & shift_bit) != 0) &&\n    //   !product.overflowing_add_assign(shift_bit) in mul_float_significands_same_prec_lt_w\n    test(\"1.2\", \"0x1.4#4\", \"1.4\", \"0x1.6#4\", \"1.8\", \"0x1.c#4\");\n\n    // - in mul_float_significands_same_prec_w\n    // - decrement_exp in mul_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_w\n    // - rm == Nearest in mul_float_significands_same_prec_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && product.even())) in\n    //   mul_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || product.even()) &&\n    //   !product.overflowing_add_assign(1) in mul_float_significands_same_prec_w\n    test(\n        \"3.2729513077064011786e-37\",\n        \"0x6.f5f6d50e7b8f6eb0E-31#64\",\n        \"7.8519772600462495573e-34\",\n        \"0x4.13b4f0d218450fb0E-28#64\",\n        \"2.569913924134929736e-70\",\n        \"0x1.c610823e5a4c0774E-58#64\",\n    );\n    // - !decrement_exp in mul_float_significands_same_prec_w\n    test(\n        \"3116635254961129.0696\",\n        \"0xb1290314433e9.11d#64\",\n        \"7.092177112370390978e-10\",\n        \"0x3.0bcb09ebbb50e418E-8#64\",\n        \"2210372.9222841977617\",\n        \"0x21ba44.ec1ad133010#64\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || product.even()) &&\n    //   product.overflowing_add_assign(1) in mul_float_significands_same_prec_w\n    test(\n        \"1.9999999999999999998\",\n        \"0x1.fffffffffffffffc#64\",\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#64\",\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n    );\n    // - in mul_float_significands_same_prec_gt_w_lt_2w\n    // - l.wrapping_add(2) & (mask >> 2) <= 2 in mul_float_significands_same_prec_gt_w_lt_2w\n    // - decrement_exp in mul_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in mul_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (z_0 & shift_bit) == 0)) in\n    //   mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n    );\n    // - l.wrapping_add(2) & (mask >> 2) > 2 in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"1.00000000000000000022\",\n        \"0x1.0000000000000004#65\",\n    );\n    // - !decrement_exp in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"0.0001507756106295330606262754053\",\n        \"0x0.0009e19851127b95dcf03f0cdc#91\",\n        \"3458.565842843038054059107814\",\n        \"0xd82.90db1399862ba513faf8#91\",\n        \"0.5214673768571047372764465276\",\n        \"0x0.857ee2d1883c6e783c18b1e#91\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && !overflow\n    //   in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"119368.6474438890389479272222539538\",\n        \"0x1d248.a5bee1f96ad66a5061314f7#109\",\n        \"1.573235366444334767515689608501749e-6\",\n        \"0x0.00001a64fe94215b4ea1a015983c92bc#109\",\n        \"0.1877949778033513768632732912065661\",\n        \"0x0.301354e804b87d40aa80cfe1472a#109\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && overflow\n    //   in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"295147905179352825855.999999999999999997\",\n        \"0xfffffffffffffffff.ffffffffffffffc#127\",\n        \"0.000244140625000000000000000000000000000003\",\n        \"0x0.00100000000000000000000000000000004#127\",\n        \"72057594037927936.0\",\n        \"0x100000000000000.000000000000000000#127\",\n    );\n    // - in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - a0.wrapping_add(4) & (mask >> 2) <= 4 in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - decrement_exp in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && z_0 & shift_bit == 0)) in\n    //   mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n    );\n    // - a0.wrapping_add(4) & (mask >> 2) > 4 in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - !decrement_exp in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) in\n    //   mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && !overflow\n    //   in mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        \"0.00497732823382322348141815797577421539704054126\",\n        \"0x0.014631b5fc58aeb12d61fe8ebe2fa3511f34a8b#149\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && overflow in\n    //   mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.9999999999999999999999999999999999999993\",\n        \"0x1.ffffffffffffffffffffffffffffffffc#132\",\n        \"2.0000000000000000000000000000000000000007\",\n        \"0x2.000000000000000000000000000000004#132\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000#132\",\n    );\n    test(\"1.5\", \"0x1.8#2\", \"1.2\", \"0x1.4#3\", \"2.0\", \"0x2.0#3\");\n\n    // - in mul_float_significands_general\n    // - xs_len <= 2 in mul_float_significands_general\n    // - xs_len == 1 in mul_float_significands_general\n    // - b1 == 0 first time in mul_float_significands_general\n    // - !goto_full_multiply second time in mul_float_significands_general\n    // - in round_helper_raw\n    // - !increment_exp in mul_float_significands_general\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", \"1.0\", \"0x1.0#2\");\n    // - xs_hi[0] & ulp != 0 in round_helper_raw\n    // - increment in round_helper_raw\n    // - increment_exp in mul_float_significands_general\n    test(\"1.5\", \"0x1.8#2\", \"1.2\", \"0x1.4#3\", \"2.0\", \"0x2.0#3\");\n    // - b1 != 0 first time in mul_float_significands_general\n    // - xs_hi[0] & ulp == 0 in round_helper_raw\n    test(\"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#3\", \"2.0\", \"0x2.0#3\");\n    // - !increment in round_helper_raw\n    test(\"1.5\", \"0x1.8#2\", \"1.1\", \"0x1.2#4\", \"1.8\", \"0x1.c#4\");\n    // - xs_len != 1 && ys_len == 1 in mul_float_significands_general\n    test(\n        \"21729783659306408649613509.686\",\n        \"0x11f975eebbcb21a32ee0c5.af8#95\",\n        \"4.140691354e21\",\n        \"0xe.077a2d0E+17#30\",\n        \"8.9976327319036285762104654629e46\",\n        \"0xf.c2ad952d9bedaa8c340fb5cE+38#95\",\n    );\n    // - xs_len <= 2 || ys_len <= MPFR_MUL_THRESHOLD in mul_float_significands_general\n    // - goto_full_multiply second time in mul_float_significands_general\n    // - b1 != 0 third time in mul_float_significands_general\n    test(\n        \"3.29008365861415556134836580980448399733562188e-9\",\n        \"0xe.217c389f8c9fd22042f5ed70da20cfb9f1ecE-8#146\",\n        \"3719044561792922503530448846362960.3599330496921301151502834994\",\n        \"0xb75cf116bc625ef1eab58f3c9950.5c2492852d5fb6817443c180#205\",\n        \"12235967738412737409453496.5112769496822945381768578702376539566\",\n        \"0xa1f1123e59edd22860db8.82e30bd21587183f065c6eea9383ac0#205\",\n    );\n    // - b1 == 0 third time in mul_float_significands_general\n    test(\n        \"0.152\",\n        \"0x0.27#6\",\n        \"0.000677250271462116637219538246676594845637468375\",\n        \"0x0.002c625fc46315b1256e735851ab2413f0230460#149\",\n        \"0.0001031748460430568314514140297671374960150830727\",\n        \"0x0.0006c2fc96eb184dfcb3d3927471127f099555aa8#149\",\n    );\n    // - xs_len != 1 && ys_len != 1 in mul_float_significands_general\n    test(\n        \"3.600675849075089170455453502457566\",\n        \"0x3.99c5e47746483e1e72f35153c9e#109\",\n        \"7.042716356117671710991084962952371e-31\",\n        \"0xe.48c9931f0a6ce474caf85ca810deE-26#116\",\n        \"2.5358538695359015660810037702729442e-30\",\n        \"0x3.36ee7f4e42c0edeaa7100c9586414E-25#116\",\n    );\n    // - xs_len > 2 && ys_len > MPFR_MUL_THRESHOLD in mul_float_significands_general\n    // - (xs[0] != 0 || xs[1] != 0) && (ys[0] != 0 || ys[1] != 0) in mul_float_significands_general\n    // - out_prec > p - 5 in mul_float_significands_general\n    // - out_prec > p - 5 + Limb::WIDTH || xs_len <= threshold + 1 in mul_float_significands_general\n    // - in limbs_float_mul_high_same_length\n    // - n >= MPFR_MULHIGH_TAB.len() in limbs_float_mul_high_same_length\n    // - n <= MUL_FFT_THRESHOLD in limbs_float_mul_high_same_length\n    // - n < MPFR_MULHIGH_TAB.len() in limbs_float_mul_high_same_length\n    // - MPFR_MULHIGH_TAB[n] != -1 in limbs_float_mul_high_same_length\n    // - k == Some(0) in limbs_float_mul_high_same_length\n    // - in limbs_float_mul_high_same_length_basecase\n    // - b1 != 0 second time in mul_float_significands_general\n    // - !limbs_float_can_round in mul_float_significands_general\n    // - goto_full_multiply first time in mul_float_significands_general\n    test(\n        \"3.667390117738159207950705349477719105571949429980976394812181671883945054829509256768693\\\n        428777428660656941387302685172371854480204626447190818847235223777196475037450938977825246\\\n        002439873468885558547110470430228085143851019175355894923610792842932340338852051239754427\\\n        095026930245556704615627992643819617817074019244527799280182728405175259498139200084973400\\\n        185025632529817381341736837108765891093445296142846875524815723636775475593320258020981988\\\n        641285509338653295726597545939874976233498010217572353942629414771256828458910867296816672\\\n        522543163090158525097032013393556880192772591230747507060825723928635133507431423165786715\\\n        278150157159772706487785219042905040143153742214007713387626849311191420055238664770362170\\\n        343983987545766271318010394410223132309343859005046365250499465556871672911799580499791909\\\n        295656508202340485571517780009270726548788594036564495463224892161734462687808109262481368\\\n        096969794376769660230615691331025217443348007977074560288273633401967130359649250852147512\\\n        141074330343117535301250887203664127461249846867757356639750473042390297739319749311431157\\\n        14372183907772936544329974943881256368038028229439176970805917055179180439477409e-9\",\n        \"0xf.c0568c485e0b826908a56a1e9eed605a795d47bbb3b22b86ff364a5aa967860d79fa907ffa4b598c74ca2\\\n        768fd610cc65e72d1328231f74c2896a372707f3fffd4713cd781c36ddc8c429a53c9de0a260ab39221aa6723f\\\n        639d4f0a18f42a39ce148ec18caa8292a2404e421cb5af96a525988ace64d3b66492e8b29b9f1982af075eac7f\\\n        a4c4f560684706f9c92a1babe3a7cedd233045842df3c534b90481e818908a787ba694e61d3bd3d93a45651240\\\n        a1926f3b818e8c51165d9c7c186dd99b0afededda17332acec6e4419ca2c498ecac62e9670b8cc359ac4ce5abb\\\n        e6a858a9ad732af4717655c73ab36f06357d16912bd759fba2c774b33607e2ee49fbf3328842b34b1649846034\\\n        e601a686e91c2040c578ab8676f4c413bc62718b75fe591900b6f10a6ee20a73c59ab3be30fb9a154c1a50b4b5\\\n        d60d7a76de24b93f804302eb4d625df61cf824be4c93189bd500d72fe88443b2e506a11e3b57403b447b8602ef\\\n        45e256c2e9cbfbc69697901d340ae418d96a38e3f87b38c8ee8b168c15df448ce29060725fff6438c91fd406bf\\\n        6cf95e07431942e379a50250441c4ed69a634f4e155cb67d47b7b4b285388f957b3809dcfb73606173ca9a64c8\\\n        9b5ee06f42fc1ee8c752cf947957f346aac01a1e21759f8267f58d36b22e7bd14E-8#3843\",\n        \"3187923845432148642442057154569059.126715487792372839803386914179538752693826970283207166\\\n        811288798839227319311871148502823407877176659352907588186871022894787193533982873662011253\\\n        290757573915501169313819926148549862448642272469031186766746849160076154409190019980289710\\\n        170792165652792217117270925812431819493193080694795589891807146039351866024622601910524654\\\n        975993653145125921373829181052606711648254654081125875153947355721451359688668050452670532\\\n        460418624462017975144128989503732730892234660879379487543472739334395798501406522301770530\\\n        084261662015482020833397653047706275744771695945820139179975325296925632712346348118093097\\\n        953095934511815810581175318735500116787412839224213098543182657584610954902591533740060963\\\n        289805212670558460977431314581393471573332429725647583364688986461335610003995668212280028\\\n        807977055980202986273442266172236653427698776974320204115552560417196660880213932819325142\\\n        548937684752935846670101028764484218237392844524558383599287530029421881169570993841163993\\\n        843829902198804691520255195056203676272889080365643704609455722537324606271987166289767672\\\n        190663805227886932691226996255254535007618551610966568052639325048438160780381909128343538\\\n        211967934803057176881479842550254050201767779261994751352264395465646274141983125281497566\\\n        020553366225193569060382295548356106219949376044134821789228041804290511458952966410365196\\\n        222090758059421770693182158103609003570428820956594490269060711518240230638460085565864341\\\n        256289190220580928350048868798606128912317218138793827337661513849296003850300428079774414\\\n        62431384255329048179650372924700507846477189871631671161154559755984562472291\",\n        \"0x9d2d417f3ca9f32fea99c6482363.20706d1bf7058f4c6275f668a177cd076adccb2fda12b6ed78a3b56bb5\\\n        9dfb518b8b3c05c40c48fd5544dac5cf4c4b5097a348e21623af642ca54df95b1dc69591e2bdc1e3f296461a0e\\\n        73545f0b1a728f095b34af1c14dc3ff040878852b81a047198ec51c9f7dcfffac0ad33017fdb2f0c43edcff12d\\\n        ef18336029b6f47a305e278cb4eda766445530f250be179818a2d241b5afebc21b194dbd62400042f887100725\\\n        62fb877debcff302fcc5b1162c1450e14478eb4e96906a31d6843172390e3cd69b3c0f474a72a62036579c22fe\\\n        1d1ad35fc2be49e475a1be85f30bec6d387e595070d17b17f5b5a6f400fde641d92abee13055777fe7f6b647fc\\\n        7850f8002fadb99332ceffb5439a87b2ac7f223b73750c6b42112fffe8b992da6c3fbc5274503b1bba48602753\\\n        174ba7260f73f3fa02c00fc495aad0f85c84c966f0a98fa7d85cca68b07d58e6292617f3b67fd0aafc0dc0c457\\\n        806b811f2698bea27de70e9ea3de0e898978b9670aa90750e88ac855daaf830c9dedb5d22968f2b01302edc889\\\n        ce03e2af4ec2e339258ace8efa81eeb76b273039929d7289eadfb0bae898fd0257e0f1db349eba610dfb56e3d3\\\n        1520f08012e02d96edfbf9a1a05ad01f682c49e1cf1e0f2b1131943ffe95afd8c6454deffe4bfdbf15fe656e18\\\n        13690a6dbdca197ec4c2b29ac61a6ca074a2866ff9f55184ed344bb45b2e44eca9945a21cd78ccdd427dff1dab\\\n        1d449dccc0aa07e37c89bb61c7fc94ce0edd5fb60b7e2d8034decb7a0e2bba4c1159236fd7f800450c1516e64c\\\n        bb2206f385ee11aba1c6993b2d50b2437bc23cc47f6b85d72fdd7348a5e321b5c960e8e23830fc93c4393938b8\\\n        98c2f16e8452c9e81ce5aa01460fb108dca1e371c53a1e72ad6ad0cb80bd5bf0ace476ab08fe8#5329\",\n        \"11691360406839692866118328.82160678934697449148561930623262244451953109076390937578282165\\\n        187539508530274103471810974014544850101997980642382746362536485174905201106566021759334671\\\n        038084134174395853704847978726074297598470143399522515598459659231845311084194915852728366\\\n        056422715218301245062324603756166217017490819881851715545101168897106488715462344820352976\\\n        259754023729090781152750099501504576567751861133292449402560554539891918302651799386455549\\\n        657664547443484522197757542024159371062990161647359586646799536699319711548827677391665966\\\n        287279197599493918294842951008826029536226825832854955685587903267919852682540903329229694\\\n        700736024127943619726831445160555949561747552032983921128094877425217970278847326632273418\\\n        407484077549236662570769286015075277220777908237436835596208190640803687131540850535115913\\\n        655954830695789298058473415611731503722972733488269283706021704532728574584684669676341549\\\n        292252804245357342748316615826715707101522402518116062329441651970107805707342168691626509\\\n        305758570985170639749549248022366152944291484173783280217974452532323709041672239778485037\\\n        294723948248639908579195768663906666012983129167763644004221520737884980923091163080707988\\\n        588422464078838824212171802847408608047867571127753377657964788586031325255106000694013614\\\n        527340915821283801356153178149699147203162830520911097467745909302616153231682263893483275\\\n        019567006794361076438485306321832725119559578113910632379303074353609691782388847871383450\\\n        484766163524999863199330839928739926251980847649975020069602105177714848358628397385350021\\\n        24095735959378409981273751636624594837614456921497122960535259532723503477033\",\n        \"0x9abbdeae92a7cc75062b8.d254d2926ab47ec2646ac6102bc7f2c66e4adda59ec8c5ced87c449f85121ac94\\\n        7e79dc78b7313a18f2ce5e38db71d51c990df401764ed1949bc25e2614a9bdb3027efa1acf4ea0e322dfad232e\\\n        cbd31249cc1917bbdffcead4f455598e97f24397ef8bff64f45dfd672a81269c27e03d6cb02da64c33a0af7326\\\n        eb8e21ca7d9003144c8f62cd449d48953249142d7f5afd8112b58223fc36214a7e8c4b9a026eb8ba0dc0dca681\\\n        f9d3c37cf62540e73333f8e07151b6353a7d9d6ad54f935a33c049acbf7c6e4e80629250c603ad3a070a43d3f9\\\n        70a8c5d99edacc2b229a04d8bb9f8b71acb7611d4e6c4a3e4330466403e5422746189403976a41698df939ffc0\\\n        32b31da3e6493f1393fd89226bf6b4eadf296725de20aac599c96edd2a445c9d689fee07ae5e94997f00659560\\\n        27632aa2cbfceba0ad1dcfeb7fb56c3a038718044af027a05c55e79d87a581fe5887ab1630360a4ddf22f18f4d\\\n        250a5385c3b6ee351d8d368543ed65e80461de207d9d924e8595b146d24defa8dbd01358a44fdf639ae28a852e\\\n        7675001a1c34c22013db15e7527ad9b7064b49c21ba11b7ed42ac9a570c006de5a092e84450d553767a5e2bb57\\\n        f588dd1a63559f4b5bf0f0b1eda574f319b65c5c97023caf2862a4487c403143538931bdaba7e1fd57d1d07dc4\\\n        613f75769c70427af74a7af461be5b0126125aa40920e4e9b44a9e28616dc9ca7b77624028a0ed40aaed08486d\\\n        90086f51f501e47b6f5e0f7391a8320f07d62774d2c29f3abfc9f71514e3bc471ff2041ede5c0fb4ad39572ab8\\\n        6909d5a368ef66086eed3f37dad57f14ec6362b1b9567a687e771330ec416265c437c3e6d3c3136aedfe753577\\\n        319aed775fdefcbe6ff046d9f93acca0d253617b9b98b73f7e7fc043ad2e5f9ae06754e4df0f8#5329\",\n    );\n    // - out_prec <= p - 5 + Limb::WIDTH && xs_len > threshold + 1 in mul_float_significands_general\n    // - xs_len > len in mul_float_significands_general\n    // - k < len << 1 in mul_float_significands_general\n    // - b1 == 0 second time in mul_float_significands_general\n    // - !goto_full_multiply first time in mul_float_significands_general\n    test(\n        \"0.000505125560873134723723784766950092518997332731967301291698755707702902596942317437852\\\n        941942371960388246351631317879977557751125153730732708319124734660713981958784935850223006\\\n        317900579689594830566320680544405297096706330277372404179805722699177498153458710988448597\\\n        667865038489642478166853872591228283694673924060010690084057961646317421857676637869623134\\\n        589158734829608080525671151880734425152367375882305121472858495571639962287931732234443489\\\n        588015865732596365983920824372468289009819493599234552103162449485200505569599322042323513\\\n        171853918367347759762125056867136354464299283595190704290061720089955391730926571989543650\\\n        123824756\",\n        \"0x0.00211a99c3aab8ff53e9907564934b7d8b29ea0189ec9cd3d1a74407e1344b68fcd1809f4234bfef08c0c\\\n        3f89af1fe509093292b5b157eded4009179fedceae065ab0dd9d53b35a4ce7f1d190711e92618f7d0b216ce0bd\\\n        09e9c6f6625bcc6003ad38389decfb93a34f29b624c9c3c24dd825a59d15423602847fb2fe248d2b631514d4ed\\\n        f610fd7088faa3f59c46a406f42343787142069c527e5b0aa730ef1f4054d887515ccd31c4f04063d57d8645a7\\\n        b70fd198011231617f8b64344b5d43eb951d0a8ebfe39606336b443b19074cd641a63b4656b6e71133e47c099e\\\n        1fed7bc661252f72ee2c68b5cf9db6ee0645b455fb007e9d294c3a5e091df7f92b6268fff2e65b109ec#2100\",\n        \"1.594827021209513894575272853189101796908969657496052553026904808146944132849277331696165\\\n        366066982899056554189139962942976395082328192559670863685439930018276703216617917370998670\\\n        143663891402542565265723410284904517798491873969116076521737839809230852429183992755715781\\\n        991743918659448701680599805386273131215689278489918563344703836788128584757613316503273812\\\n        347176374414975252562793531554358724296424942636927017522952046066543039832692600611375088\\\n        044395866209370211970587133626417624012062511750942538348241762511210915523305672594074841\\\n        5529943020302456665999104875220004206872624343740835605816652e-79\",\n        \"0x4.ba3e1591f6a0ae18e8a750107efc0ca278b3954588d15a3695387227774da4319070b249d295916c24713\\\n        070f060a0df67ad5c2e8cc350d13189bcbf73f9af1e33fe42bf44fe99164bf802f7a5f41fe2d28377f1932b019\\\n        a00373f4400d62f20693ce9fbe239afbc3c804face7c59fb40fe03be617f14dd6880b31ff429280aafe8ea5d94\\\n        c3349efe67683ab81b8b5f4d00925073051d872bde743109c8e7c79da2c5fff9f489b12c271aa83405fe1d99c2\\\n        9f846c6b1c71dec233f13240569b3015559ed53bda719283585ed3f94bdeaea4d8438fe90e633bb97ee755eb88\\\n        113450187e9b05d8e6040fa53e6a10b6dcc2f01463a3937f5a90E-66#1988\",\n        \"8.055878935840864338761112052964131694842078144914087985110265043132694138227764882097467\\\n        485603629304908508159498533271385147841989466565220242546894501115782558008761861379571521\\\n        691942027516784202151149343065118307142127390742346695428089929852244559471690807529077258\\\n        667004534037323942848543095527661248910413746226405479291587579546107337446543923963731652\\\n        263604834014601264189816875633028978567676911887046995279630281027980542407933148412976200\\\n        257662826354908783390381610432026516882234795071151533161797811544609495678329417798803859\\\n        814384620434259660366163853727351148214688205975873187006097686502581917099916584703699137\\\n        7927e-83\",\n        \"0x9.c7fc20220e43b5ac1717bf3fc467495e7a66c020cb393887e4bf4a3ad3eb4f20763507aea5b673c5aff25\\\n        8525ec5ac9bbc9f5c976983bce6231282e951654f346e3e5f7779ecdeae718176d55b03e21297ae13b32728a38\\\n        30c19eb847a199cde2fd0f3aa2330282fc433000c5f99b14022cd881da6b7caa98d3563644c4710ec876c4b61c\\\n        b15fdd4cc7d712644bad3a66e844700eafebabf02dead4fd71d95a14ef9c6a12db9092cf7b4723f45cb086b401\\\n        8123e185be43126baa17ab68fd32a0834023652a003d24211dd87066d2d5b1f0f1993c0dd9756329316927dd98\\\n        425ba5d470abc9065c6ff724d0e16c68152314d36e37d235fe078572e42d94540fe4418a9440633E-69#2100\",\n    );\n    // - MPFR_MULHIGH_TAB[n] == -1 in limbs_float_mul_high_same_length\n    // - k.is_none() in limbs_float_mul_high_same_length\n    test(\n        \"5.001744775175450910666028825162941035057223155811961434576858983758571141018459147239961\\\n        203150588371507863692097065128597336587126035820647361489875366021800666979434518756504925\\\n        080057234368614339602900137940067888065298554658519361482160014564328827389146902718969285\\\n        655774560873251528749737416878097111467317878479458938947793439179987668446365650646689222\\\n        368834166803110702160567896615568919058064520266761717855703906871630752776256537972706691\\\n        492064397304429453321564568279795029252524047182880248127317544801138445700458013706547493\\\n        607273723210196209139384085476634511414334117395068648152693457778920460359930382343697178\\\n        078573995749595631668772420417704996567074590195305455833132484492282116574194971013126880\\\n        3791636230633361526548302742414616516594455084620537903358416e-16\",\n        \"0x2.40a97302ee75111e17146bc65c8925811ce517da511093e155a5f8d319eaddbeb4108f1636a175bfa8c49\\\n        995045d6820b2f007a269091d024c939d8b02f4910a81e4eb38a836a327a5c12207dbd4d7a81228e55fec96493\\\n        eb7d51704a03ee77c5caca6616fdc0b6cbe90c676923de6ef8bf3f132b9e5e0dcbae8db3a41502b6d35629f01c\\\n        0834af3506639efdaa9dba6adf35a24b53b04e032ba7f9821a7155eb04aa7d235436bb878e13e2f265b7a183bd\\\n        7830bf484c2c6b19e1df88120105ab6ceb5f940ee7e82d4a6da4e67b7532f20750db350a532138117c02fd3f63\\\n        1e917747a8217c0e647adfae38491beacae6be9197fecb6a639604eba9f3e2a0e1250124f9d994d6ae0f8077c0\\\n        ad1f961f00f0513cb1b3b92f03fd2e19ce799415d8c26352d23ab730bff342c3d10823b5d476e3a74e5e3a1265\\\n        3a2e81ad38c5d7f45687a8E-13#2587\",\n        \"1.142392802815468388118014752111991104436260746248041498551240097570984474280784266879307\\\n        592064853042631818930172030116326290909317377878988867978348974337550025356060840134215623\\\n        183687852648862683292152461337367387727519703906836027722282460995072637442171724001503892\\\n        471336699233392710738717656085295397789876649817787754823752786376233371866685422498954888\\\n        388883747226256845650864591251580129661172288008506642506027201072159168710566406994425528\\\n        61698637621752755004821872e-17\",\n        \"0xd.2bbf98dfde60cfd72ff373085dca4697e7a8a2b1b6d379d3c49be918a519d5508c59f210662104e5d0b4b\\\n        bb4e9f09afcccb3c1655f91f2a86657e3f1315aa4e7c857d68f4d7b989d2a2f5d56a205e85ef7d6d2e9325e0fe\\\n        eded2158374d99d513a6d203143a26cfd251731f49e63a0e342dec62e52287bd673124d763a94038f4529cffd3\\\n        3599c97c0e19c589ce5603d9c26a084d360b9e7decaa7dda44ce1c27bb7c21adcb23b90d069b0a9b53b9d66094\\\n        d817f0420227841d34052ed2bd52e148923f8E-15#1571\",\n        \"5.713957232680308157039243396854396365207579750474509016836068310655183904589399398864949\\\n        369194427543435776465300666190725186454505340683874976519507548279996486761744005041118935\\\n        948747589743699350970808906395296086217435990867715483224265504817855574934867156151545781\\\n        106814865537845359234760816964504042844539777879186641559132734209465852287196566458935778\\\n        830300266229578325422723437672411534085537936547389438107265754858071594639985760821104661\\\n        940648845072022419465943642338099526948876829384943161258695569354371632958134560717841147\\\n        840574265292252548747529841143166165808068071464187327019844718180901133673499079508336221\\\n        530763161764985656092293178070670798408664087435197003752408586649867017671653317949434498\\\n        7804832149608135310831412140057788625216612318872425368846162e-33\",\n        \"0x1.dab26e4414e016457a3b64d6dc588a9f2a4cbec7acd1a5b9033e00168a27a1ac3f669e39332cdbace29d9\\\n        b5d727df53a041f44f1389d6fda544d07799d35a62fbf327a55fca19ed803e80954753bfb12dcfda81be99eda5\\\n        2d7a382f6dd0ac26ab4b55fa3587bc812156b0ddb289357e7300ea3dafa43cee4f98c4068d3ffbeceea4a01ecc\\\n        74a09b85289f4c37000efab1e07926e01496cf6855b4a1f08915fff56a1737ff1d109fb6f3011fb249b88db85f\\\n        52980590101cbaa0e8af5872ded15ef0f39ec69d2d19d45c2972793e60bbb6eee9b673f24b3318973256a8e9bc\\\n        90d40f033e145dc56a6caa7e542a2701c0a41519fd0ef8d97ed0cef3e4296de50e877edeae80c0dd91f9082539\\\n        71e8998ef2a91d865baa5aa565e308789af81b128e8d0e832f5368e689962335ca7077ad875ea20eae1f2fc375\\\n        a972b8e7b8e285bbe3bdb0E-27#2587\",\n    );\n    // - xs_len <= len in mul_float_significands_general\n    // - limbs_float_can_round in mul_float_significands_general\n    test(\n        \"2791656999165.493196894581080462482671477586959884065253358835066410305633620155930725019\\\n        490863414181814174955842522364865024774379310519058136940369290858518517313460149216061827\\\n        231421960818181308820010416988884966114071973567666857448623899431042502611223036510238920\\\n        700493077403107131238955287441775846760482666068674778697270732066126184067657756561516984\\\n        251159820991198761865419427067747698722303345927460124328666182849055120607788400162794652\\\n        0878157328543259919881\",\n        \"0x289fbb948fd.7e4226d4b6e97c4ccb64c2a072193f46e582b56e431d1d873706fd936c5e3328fd5b164ebe6\\\n        f6c3319057366a2de168eaef87f67644a657027f176fb9d5deaa62912e24d9b1eebf67a642c7ebc91e95eba928\\\n        d2c47f45ab981a3053c2a055e2a36102f8c4b2c72f24edbf87122ddff42408c1c95b6eccee7c0a49a25e2fe2fd\\\n        67a0dfc9d33ccad11d273f88f3e5a176da6b5989e6fc247727a58af5ef0f3a863e35d59edceb1ed0401bb2ce98\\\n        77227cdff6442212230b17fb43a061516c#1558\",\n        \"2418611879271263.303076595070873673412348926925363768438166046534014463089969421888804109\\\n        398849144724043021994927400943502019398552005514731676646297869532250197280910814394530400\\\n        370821284006890204265425587260634300563572770382580394115150082129924900080499709146475799\\\n        383767996765000283568589472197582158015457869515972738606414178902063354061536898088295371\\\n        641586286472920893106777705320869713042818435525510767840203306234890813618032983465299395\\\n        730347727963352100742341245602143\",\n        \"0x897b6f5e9db5f.4d966d80032f1615c15b6d17e02b100d2d97b52de1b561199b3dbeda9276bc25c5519d480\\\n        c2c20f52155b94074ad9db0bd7a97dae0337b738b6709c5fdd1bbcf1492bef975c393313e477790485d0a4ed0f\\\n        8790d9d469d65c29122cd019f7ff423e0f74c0585cac3aa85ceee8cbd256a201e23dd78f6dc402aa36b5a053ea\\\n        c1a3b2c435ae84ee9942bec1d88e41507bee030c35cd3f18b2f7a5c9193976d7418a633e08ca4923be03a2dc93\\\n        6ed64c6ff04ace32f44aa72f58bf488b9bf31c4c03f#1596\",\n        \"6751934781032429031553446805.854936199324254228337806577049209187291041079391491758652444\\\n        360751832908394550062618692018471995917689775126406303977393164343146088816585483538887454\\\n        027840163444916716206473736192766508247978473183426254779355642987433462433675113794019449\\\n        629515518752711445976665575431349720824019816455254142652806744349728110370084378693365847\\\n        376950483953541149499814845310185214082773221620162084856311318860928357827312318714828967\\\n        076794760533141841485387490188815\",\n        \"0x15d111cde75ec690f0fb3395.dadd194843a336fd8b04fc1edf686f76aa52a00d00db09b133bcedaa832e64\\\n        e3cbe80e635c5bb60e81bb4cb3839dc581a1f683d480b6757136ace3d394264c5f969b75cb4d985b4b2b1096d2\\\n        a53a6d6570c7f7c917bed4f2a9c8f7bcdea046337457665b27e5e01bdbce6f20c6d5bc9e463f055cca9b0c53a2\\\n        f1f5b6d7211ac001a5fa99daf3378815db2c7bc77c6d6b76f815ae464fdc70ae82752dbe2b5683cc1ebc18275d\\\n        4685cbd35d58b70dbda84d2297ff9a12d20f2283678e#1596\",\n    );\n    // - out_prec <= p - 5 in mul_float_significands_general\n    test(\n        \"7.449979045041702122541548973189889723858373710052883535770432677692650998750696470703091\\\n        744255868088920360332810996981821635561095981209970543165990341865465399250649125818133550\\\n        345620227288485003961432095280508748897878683743133302349812547742789930883805941444651209\\\n        784236601329970891014476723035066837590220224883282604585022340111695027909185310636007609\\\n        680407882966239499164648695501638941698641158401193435378725738878261400237405551514713128\\\n        836982995938875007304023367379668047357772772649359285993284186179803252277e-21\",\n        \"0x2.32e78d682285335802e277865ca4c9a80daafb30e4f67daedb2f466845a2fba5d9b1c96b068c42999ae0b\\\n        463fb94e578b359027630c01a995d88a74b72186c316ec30a8b4238fb27273b57cc5e72fa518fa14032e99af11\\\n        e1d5ccfc1217be504bf8dae0d1ec7e885fc95b51f444d68ed47eb588644910e4196d65104707dcd1c488a22e9c\\\n        1ef05ce85b3823fd6aa2bb7ad7d14fa1da7a628e1ba344d98ad7e95bf7e01883afc84273614fb8387e4035b2d9\\\n        ad867bc2be83eaabaa44df896348f52d4972bc5e8cf58f1cfd421cc30920d9f5504a043149274f5E-17#1738\",\n        \"4.689598630661113758052361654518074651900718126313070505518580809308545656249466966444734\\\n        190644625007707301196274229099309347916384836732990153197811248723616418486524781737017155\\\n        222220872736570797023388780311017887508289881051954626904239986311860650999175535050592519\\\n        124458883175586921775053060798371665433755864916689805023189965297596140362143269558535567\\\n        196585839368205277548820051354051306095222442551993791324926248616628216018709202221063695\\\n        130497558241752004759655263919857509980778615592531001107310020150056419e-20\",\n        \"0xd.d75c4c85ded4dada979685c90590eb9f191595aa1862df62f276fa75d5d790d2c00d187fe126b806534fd\\\n        0379dfcf600aeee23bbe00ed5955cc2e11b7de967da0c347d3ca03714f55b714dbe2c9ad31dbd7b6fb9a639fa4\\\n        da6cec918f3fc77bbca5ded28446186fe8b4224339c0722fed5f69b2d07571b12f4cce6fece51fc63ab46ea7fe\\\n        5c1f350ed6aab2c76a1e817bf652a9c77a95e3e3c107ed65e9ace86dfec217fb9dcbba544e3d84b0f3cac6c221\\\n        176c57f1db9bc306f22db85308dab755243a502d385e1b0a31f2f8c2d53c98729cfe52f82289cE-17#1730\",\n        \"3.493741152808155821061780436862260285420312736969910829282351541785101293399126489805777\\\n        980187532032743650816868281893520821921299562434265222876601442289649987508199259232837158\\\n        559068445030886433472805552651673239073165198885867344396236299229232184802565958836951408\\\n        637905144866851014091996571320623346167534428281388860566996500707311335172658622534949254\\\n        838518529528764394710349462443386828046760610922770501616700810546292498376696602122491857\\\n        8540047731481736443609736067164917894729323015869507020379275317039780244947e-40\",\n        \"0x1.e6f4d9986216e186a3b15da557e0677276dd590e3d92a71ff89974ad2abac1a1e2e3dc761157b14cfef04\\\n        285b10c4bf2f72117bbdbdfd5ead95a5ed69f62f69682442a59a3f3c8a5a7b41238f0a029b2d53c54a08053451\\\n        35f5fc0a67464283bade3997992eea966997d442d69987820628966dfcaa6d25ca0be2df6ed92e5fa5201002da\\\n        70c6447c3a8a64ebd34fc04156c8dbd224d772ba1059982a5aa333d301a708dc568330bdead12245127d520b32\\\n        b4e7d9ae221552ab3d3f5f2f139c90118fe830b6adc84392948585b40267beb9fd60cce93fbed140E-33#1738\",\n    );\n    // - xs[0] == 0 && xs[1] == 0 || ys[0] == 0 && ys[1] == 0 in mul_float_significands_general\n    // - xs[xs_offset] == 0 in mul_float_significands_general\n    // - ys[ys_offset] == 0 in mul_float_significands_general\n    test(\n        \"4.44089209850062616169452667236328125e-16\",\n        \"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000E-13#2587\",\n        \"6.938893903907228377647697925567627621275394370123920756842177449687616281576087749649243\\\n        449560881562252974476503855378704420289043275360540974361356347799301147460937500000000000\\\n        428087763478203718701697872488500162623204828539850902982930587576291943616315378569169353\\\n        840957917417166522314320167278698048638040260019989045715363127222769643922793712163996851\\\n        225018060026136483495536368092685586468682354268058778363979622204058653592623442621394947\\\n        3239996744456973724770155e-18\",\n        \"0x8.0000000000000000000000000003fff000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fe00000000000000000000000000000000000E-15#1571\",\n        \"3.081487911019577364889564708135884006379343333980678546187704758135879626468817238227001\\\n        919863959483626636205013163029555487554952753086708205626001498966504653625325671484347367\\\n        558282010814620352468694740583510310926487120637351903244174605756585424927747220355720149\\\n        705262186320261062950329818867477826244378862350354462458385252797818784708103173459291235\\\n        769538479528034217611825504020777438216019896385615152551542382665798426796321259955655479\\\n        300773291504754679549289638268112862439028560817297535629039872109954348969232817790940901\\\n        772925125639499661447304917621775611916484032847611462965461660088172016929375670794716891\\\n        215288121297398166137896866022540415673603027116093396582728756514564426357106145459651571\\\n        0636500728956428014332817951864653686798458732591874037159276e-33\",\n        \"0x1.00000000000000000000000000007ffe00000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000E-27#2587\",\n    );\n    // - xs[xs_offset] != 0 in mul_float_significands_general\n    test(\n        \"3.999999999999999999999999999999999999999999999999999999999999999999999999999447285212473\\\n        955543975273480780774427448575976676077991358482977909210124597604668289823519777773553500\\\n        1249731874464215297923136674027554116062077582682832144200801849365234375\",\n        \"0x3.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000000000000000#2090\",\n        \"3.944304526105059027058642826413931148366032175545115023851394653320312500000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000038180485e-31\",\n        \"0x8.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000001ffffffeE-26#2567\",\n        \"1.577721810442023610823457130565572459346412870218046009540557861328124999999781992456191\\\n        582683140605249728137786969774247203293102032637435297463867968227730622206111553159326620\\\n        257748727154917100482837417166916131758491078680030585867783733868391940878208953914079279\\\n        677271330675596139325733702207799069583415985107421875000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000001527219401e-30\",\n        \"0x1.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000007ffffff8E-25#2567\",\n    );\n    // - ys[ys_offset] != 0 in mul_float_significands_general\n    test(\n        \"3.552713678800500929355621337890625000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000185653473271011701515143789632334288014147578747413968011889263434165\\\n        454031003144878632958696545103828379944287431463737771314691776232764018029744516848435369\\\n        906941507005331339097431189921414095915636548343770290467007831930064077297413615608072068\\\n        77626957251331627162116234578193867366731943186452308784033031e-15\",\n        \"0x1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000003fffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffE-12#1693\",\n        \"131071.9999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999931137299504668061215619580033350122879947175743013377219720120678876536\\\n        628643562946337394277177628286886258713868752206334184193331360816755408598724051586961746\\\n        685495576886231160425736851019484652776925452038003143395027472798288565900387988918967170\\\n        024140096215282631707814129061246845336549291242702672707242154281040996134116689237194330\\\n        449329247059466983779402165943011772702916829761392820351107526820413839207822952585392346\\\n        328868866364548445701244431290159307431187837005854773744122693182105660536394809595147776\\\n        165023610906858577556273686957594781817444085841499342583068122729709267291\",\n        \"0x1ffff.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffff80000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffc0000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000#2930\",\n        \"4.656612873077392578125000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000243339720485780457409929267946893197985903514415810436152543495368429\\\n        343907516442055321546973277589582124346598388556070043505489984826143425305512049232107258\\\n        133592644143603087675038065556842214758248268059151846952539521827810268928481776834311731\\\n        044052486308720793745225556140061733844701779522496735016181906708106564202059526039890815\\\n        919178696765989061598664073635409369732679923290228161362302668920197866351570235145652815\\\n        456445767888399222146130209012884306181795683184194476165898983356347814975458163826496169\\\n        408195862006279548822773547655683272930717806964759394377376260006554734212838956379338694\\\n        525902352837865322055484704841599472083306918235788680977972181745262154636e-10\",\n        \"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000007fffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffdffffffffffffffffffffff\\\n        fffffffffffffffffff80000000000000000000000000000000008000000000000000000000000000000000000\\\n        000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffdfffffffffffc0000000000000000004000000000000000000000000000000000000000000000000000000\\\n        00080000000000000E-8#2930\",\n    );\n    test(\n        \"12962368.00910437392826314193446550944389165836262015621514962112057577196019471161937054\\\n        243429475140935082492484312458697139062031326336320065697050792374770657213779646419924892\\\n        886900897092216274606911219143642483069838857046000551685989850622347518286427108428594195\\\n        826642547794926862213089792293539194572777838215978068770604450325322408918968488729618206\\\n        83239161602000658143319869428\",\n        \"0xc5ca40.0254aa0c45bef8b7e5bdc2c8d0bc3f4ef77512b0c665764acef9797020852473fed6cf5aef7ab76f\\\n        af4e7ccca7674b7b9a7d4e3adf7dbd2f9c51a93c8b500f9c6e799811cc9793ad3189530f5202900aed04c32d98\\\n        72075f4a8efb28f1e3d9e2065d70be0df4f07d46d4f2f48b95a6fcd718d2f233dbbaff41296fe46efd00783168\\\n        f9da607a651780d29e9357c1d8e9abdd149e2d7ed04e74488fff360#1283\",\n        \"24678125950611051118469790273997953293778953666881566874553684447233373952852192.03220118\\\n        824573657786267791510531425783997288827451260529832388036858875235909753308200751110173525\\\n        014519161498781309811156911488470099945303550175018037705473098495478288721507648423524330\\\n        255884870759432606723320831807670552582364423881930823507999308667398128596287742877235432\\\n        154091338959855861235089997932459245142831892\",\n        \"0xd51fdc4e02742b528c90f8a31146dcba3e1273bfdd1198ff1ec486c97e52f8c0e0.083e564a6864272a5d52\\\n        74cbdf67db38b72e576e7cfe8be5418f583cf4173a82939f37d7b6b399cada03434a24aef04a65323c333b33cf\\\n        622583787d8ec1f247c4f691c3a7862628783f4322923b6bb9434902754e348fb74eb6364e294832597785e445\\\n        1994ee48803ea5771d85e7f226166cdd1853477f296076996b97965596455eb50129#1336\",\n        \"319886950346849155967554337687681180827634107405044558954903133134156000777816460853971.0\\\n        571286460940042331570995057120143779176892645683546163312322051333969186064059757999062545\\\n        749424646225780605680908775358827191384406475576071818545005626321659954666901446716884049\\\n        318512517659256499382137861718683137930417158199590725586222075459373218000006096544204046\\\n        600400863088080659996213042623116710817104536\",\n        \"0xa4a9e4f5c54093e3388df17b55e5724251f90cd6c231443e4bc0d5770919a2c1878982d3.0e9ffba2a37526\\\n        7ffbc880a862170226c003dcfce47863efaa79493245f971642ca10409a10ad584de1597974f309b61313528bd\\\n        1512f14b2397a5630d41d067d57d9b327d751eacb350f8e13428d4508849e4464775e72f3b4fb63d6bef2d97b6\\\n        f0118aa022becb98c8c88fdcb280078abcbe4c3b8423dc1dfc91e6b09ea9115cd0cd#1336\",\n    );\n    test(\n        \"0.853553390593273762200422181052424519642417968844237018294169934497683119615526759712596\\\n        883581910393183753461557728074256231209013962684303161030374274983957853305666481876398188\\\n        949987625288195515142867527389992901492568633649215503682129354660222299652388082307621077\\\n        178580362709940650906998812851997421813349136582952207410155153814588098763686437571939990\\\n        432458893805084382964252838593650852124711790096724992674751203757636006947579113561955767\\\n        12323422965539514461577789916717825325390464224680930882212731621531237\",\n        \"0x0.da827999fcef32422cbec4d9baa55f4f8eb7b05d449dd426768bd642c199cc8aa57e41821d5c5161d458f\\\n        f37ee41ed9c87ba542f21ce3da53c02439b1efd13b469101743a1578fa72982ce3008de19bde558de488b4422c\\\n        523055e3917be2719e36ad451c5dbf4ee659531a198f9e426fa978907c1b72c1775525044c8206525409ca55b6\\\n        c7e877efa69d01675e49f0621326d5e6a945b28dc679a0db7c11b6380826e00ff191a9799952f4fbded0f5ffb5\\\n        0df1fe5110983ef503120fbd540e160fe5eef517bee198c41c51757faf9d96927a53b1fd65c#1719\",\n        \"0.853553390593273762200422181052424519642417968844237018294169934497683119615526759712596\\\n        883581910393183753461557728074256231209013962684303161030374274983957853305666481876398188\\\n        949987625288195515142867527389992901492568633649215503682129354660222299652388082307621077\\\n        178580362709940650906998812851997421813349136582952207410155153814588098763686437571939990\\\n        432458893805084382964252838593650852124711790096724992674751203757636006947579113561955767\\\n        12323422965539514461577789916717825325390464224680930882212731621531237\",\n        \"0x0.da827999fcef32422cbec4d9baa55f4f8eb7b05d449dd426768bd642c199cc8aa57e41821d5c5161d458f\\\n        f37ee41ed9c87ba542f21ce3da53c02439b1efd13b469101743a1578fa72982ce3008de19bde558de488b4422c\\\n        523055e3917be2719e36ad451c5dbf4ee659531a198f9e426fa978907c1b72c1775525044c8206525409ca55b6\\\n        c7e877efa69d01675e49f0621326d5e6a945b28dc679a0db7c11b6380826e00ff191a9799952f4fbded0f5ffb5\\\n        0df1fe5110983ef503120fbd540e160fe5eef517bee198c41c51757faf9d96927a53b1fd65c#1719\",\n        \"0.728553390593273762200422181052424519642417968844237018294169934497683119615526759712596\\\n        883581910393183753461557728074256231209013962684303161030374274983957853305666481876398188\\\n        949987625288195515142867527389992901492568633649215503682129354660222299652388082307621077\\\n        178580362709940650906998812851997421813349136582952207410155153814588098763686437571939990\\\n        432458893805084382964252838593650852124711790096724992674751203757636006947579113561955767\\\n        12323422965539514461577789916717825325390464224680930882212731621531237\",\n        \"0x0.ba827999fcef32422cbec4d9baa55f4f8eb7b05d449dd426768bd642c199cc8aa57e41821d5c5161d458f\\\n        f37ee41ed9c87ba542f21ce3da53c02439b1efd13b469101743a1578fa72982ce3008de19bde558de488b4422c\\\n        523055e3917be2719e36ad451c5dbf4ee659531a198f9e426fa978907c1b72c1775525044c8206525409ca55b6\\\n        c7e877efa69d01675e49f0621326d5e6a945b28dc679a0db7c11b6380826e00ff191a9799952f4fbded0f5ffb5\\\n        0df1fe5110983ef503120fbd540e160fe5eef517bee198c41c51757faf9d96927a53b1fd65c#1719\",\n    );\n}\n\n#[test]\nfn test_mul_prec() {\n    let test = |s, s_hex, t, t_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (product, o) = x.clone().mul_prec(y.clone(), prec);\n        assert!(product.is_valid());\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n        assert_eq!(o, o_out);\n\n        let (product_alt, o_alt) = x.clone().mul_prec_val_ref(&y, prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = x.mul_prec_ref_val(y.clone(), prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = x.mul_prec_ref_ref(&y, prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_prec_assign(y.clone(), prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_prec_assign_ref(&y, prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = mul_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product),\n        );\n        assert_eq!(o_alt, o);\n\n        let (rug_product, rug_o) = rug_mul_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_product)),\n            ComparableFloatRef(&product),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        10,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n\n    test(\n        \"1.4134592e-8\",\n        \"0x3.cb5260E-7#24\",\n        \"3.7164162e-37\",\n        \"0x7.e768d0E-31#24\",\n        2,\n        \"6.0e-45\",\n        \"0x2.0E-37#2\",\n        Greater,\n    );\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#2\", 3, \"2.0\", \"0x2.0#3\", Less,\n    );\n    test(\n        \"-6.5933e-41\",\n        \"-0x5.be5cE-34#17\",\n        \"too_small\",\n        \"0x1.abfd74a88E-268435431#34\",\n        68,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n}\n\n#[test]\nfn mul_prec_fail() {\n    assert_panic!(Float::NAN.mul_prec(Float::NAN, 0));\n    assert_panic!(Float::NAN.mul_prec_val_ref(&Float::NAN, 0));\n    assert_panic!(Float::NAN.mul_prec_ref_val(Float::NAN, 0));\n    assert_panic!(Float::NAN.mul_prec_ref_ref(&Float::NAN, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.mul_prec_assign(Float::NAN, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.mul_prec_assign_ref(&Float::NAN, 0)\n    });\n}\n\n#[test]\nfn test_mul_round() {\n    let test = |s, s_hex, t, t_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (product, o) = x.clone().mul_round(y.clone(), rm);\n        assert!(product.is_valid());\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n        assert_eq!(o, o_out);\n\n        let (product_alt, o_alt) = x.clone().mul_round_val_ref(&y, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = x.mul_round_ref_val(y.clone(), rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = x.mul_round_ref_ref(&y, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_round_assign(y.clone(), rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_round_assign_ref(&y, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_product, rug_o) =\n                rug_mul_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_product)),\n                ComparableFloatRef(&product),\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (product_alt, o_alt) = mul_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1.0\", \"0x1.0#1\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"123.0\", \"0x7b.0#7\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Floor, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Ceiling, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Down, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Up, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Nearest, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Exact, \"2.0\", \"0x2.0#1\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Floor, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Ceiling, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Down, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Up, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Nearest, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", Exact, \"2.0\", \"0x2.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Floor, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Ceiling, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Down, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Up, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Nearest, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Exact, \"2.0\", \"0x2.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Floor, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Ceiling, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Down, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Up, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Nearest, \"2.0\", \"0x2.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", Exact, \"2.0\", \"0x2.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Up,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"4.442882938158367\",\n        \"0x4.7160c6b758b94#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"4.442882938158367\",\n        \"0x4.7160c6b758b94#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"-4.442882938158367\",\n        \"-0x4.7160c6b758b94#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"-4.442882938158367\",\n        \"-0x4.7160c6b758b94#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"-4.442882938158367\",\n        \"-0x4.7160c6b758b94#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"-4.442882938158367\",\n        \"-0x4.7160c6b758b94#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-4.442882938158366\",\n        \"-0x4.7160c6b758b90#53\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"4.442882938158367\",\n        \"0x4.7160c6b758b94#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"4.442882938158367\",\n        \"0x4.7160c6b758b94#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"4.442882938158366\",\n        \"0x4.7160c6b758b90#53\",\n        Less,\n    );\n\n    // - rm == Floor || rm == Down in mul_float_significands_same_prec_lt_w\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#2\", Down, \"2.0\", \"0x2.0#2\", Less,\n    );\n    // - rm == Ceiling || rm == Up in mul_float_significands_same_prec_lt_w\n    // - (rm == Ceiling || rm == Up) && !product.overflowing_add_assign(shift_bit) in\n    //   mul_float_significands_same_prec_lt_w\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#2\", Up, \"3.0\", \"0x3.0#2\", Greater,\n    );\n    // - (rm == Ceiling || rm == Up) && product.overflowing_add_assign(shift_bit) in\n    //   mul_float_significands_same_prec_lt_w\n    test(\n        \"1.2\", \"0x1.4#3\", \"1.5\", \"0x1.8#3\", Up, \"2.0\", \"0x2.0#3\", Greater,\n    );\n    // - rm == Floor || rm == Down in mul_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Down,\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in mul_float_significands_same_prec_w\n    // - (rm == Ceiling || rm == Up) && !product.overflowing_add_assign(1) in\n    //   mul_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Up,\n        \"1.0000000000000000003\",\n        \"0x1.0000000000000006#64\",\n        Greater,\n    );\n    // - (rm == Ceiling || rm == Up) && product.overflowing_add_assign(1) in\n    //   mul_float_significands_same_prec_w\n    test(\n        \"1.9999999999999999998\",\n        \"0x1.fffffffffffffffc#64\",\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#64\",\n        Up,\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        Greater,\n    );\n    // - rm == Floor || rm == Down in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Down,\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in mul_float_significands_same_prec_gt_w_lt_2w\n    // - (rm == Ceiling || rm == Up) && !overflow in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Up,\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        Greater,\n    );\n    // - (rm == Ceiling || rm == Up) && overflow in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"295147905179352825855.999999999999999997\",\n        \"0xfffffffffffffffff.ffffffffffffffc#127\",\n        \"0.000244140625000000000000000000000000000003\",\n        \"0x0.00100000000000000000000000000000004#127\",\n        Up,\n        \"72057594037927936.0\",\n        \"0x100000000000000.000000000000000000#127\",\n        Greater,\n    );\n    // - rm == Floor || rm == Down in mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Down,\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - (rm == Ceiling || rm == Up) && z_2 != 0 in mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Up,\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        Greater,\n    );\n    // - (rm == Ceiling || rm == Up) && z_2 == 0 in mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.9999999999999999999999999999999999999993\",\n        \"0x1.ffffffffffffffffffffffffffffffffc#132\",\n        \"2.0000000000000000000000000000000000000007\",\n        \"0x2.000000000000000000000000000000004#132\",\n        Up,\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000#132\",\n        Greater,\n    );\n\n    // - in mul_float_significands_same_prec_lt_w\n    // - decrement_exp in mul_float_significands_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal,\n    );\n    // - !decrement_exp in mul_float_significands_same_prec_lt_w\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_lt_w\n    // - rm == Nearest in mul_float_significands_same_prec_lt_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (product & shift_bit) == 0)) in\n    //   mul_float_significands_same_prec_lt_w\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#2\", Nearest, \"2.0\", \"0x2.0#2\", Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (product & shift_bit) != 0) &&\n    //   product.overflowing_add_assign(shift_bit) in mul_float_significands_same_prec_lt_w\n    test(\n        \"1.2\", \"0x1.4#3\", \"1.5\", \"0x1.8#3\", Nearest, \"2.0\", \"0x2.0#3\", Greater,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (product & shift_bit) != 0) &&\n    //   !product.overflowing_add_assign(shift_bit) in mul_float_significands_same_prec_lt_w\n    test(\n        \"1.2\", \"0x1.4#4\", \"1.4\", \"0x1.6#4\", Nearest, \"1.8\", \"0x1.c#4\", Greater,\n    );\n\n    // - in mul_float_significands_same_prec_w\n    // - decrement_exp in mul_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_w\n    // - rm == Nearest in mul_float_significands_same_prec_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && product.even())) in\n    //   mul_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || product.even()) &&\n    //   !product.overflowing_add_assign(1) in mul_float_significands_same_prec_w\n    test(\n        \"3.2729513077064011786e-37\",\n        \"0x6.f5f6d50e7b8f6eb0E-31#64\",\n        \"7.8519772600462495573e-34\",\n        \"0x4.13b4f0d218450fb0E-28#64\",\n        Nearest,\n        \"2.569913924134929736e-70\",\n        \"0x1.c610823e5a4c0774E-58#64\",\n        Greater,\n    );\n    // - !decrement_exp in mul_float_significands_same_prec_w\n    test(\n        \"3116635254961129.0696\",\n        \"0xb1290314433e9.11d#64\",\n        \"7.092177112370390978e-10\",\n        \"0x3.0bcb09ebbb50e418E-8#64\",\n        Nearest,\n        \"2210372.9222841977617\",\n        \"0x21ba44.ec1ad133010#64\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || product.even()) &&\n    //   product.overflowing_add_assign(1) in mul_float_significands_same_prec_w\n    test(\n        \"1.9999999999999999998\",\n        \"0x1.fffffffffffffffc#64\",\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#64\",\n        Nearest,\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        Greater,\n    );\n    // - in mul_float_significands_same_prec_gt_w_lt_2w\n    // - l.wrapping_add(2) & (mask >> 2) <= 2 in mul_float_significands_same_prec_gt_w_lt_2w\n    // - decrement_exp in mul_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in mul_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (z_0 & shift_bit) == 0)) in\n    //   mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Less,\n    );\n    // - l.wrapping_add(2) & (mask >> 2) > 2 in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Nearest,\n        \"1.00000000000000000022\",\n        \"0x1.0000000000000004#65\",\n        Less,\n    );\n    // - !decrement_exp in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"0.0001507756106295330606262754053\",\n        \"0x0.0009e19851127b95dcf03f0cdc#91\",\n        \"3458.565842843038054059107814\",\n        \"0xd82.90db1399862ba513faf8#91\",\n        Nearest,\n        \"0.5214673768571047372764465276\",\n        \"0x0.857ee2d1883c6e783c18b1e#91\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && !overflow\n    //   in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"119368.6474438890389479272222539538\",\n        \"0x1d248.a5bee1f96ad66a5061314f7#109\",\n        \"1.573235366444334767515689608501749e-6\",\n        \"0x0.00001a64fe94215b4ea1a015983c92bc#109\",\n        Nearest,\n        \"0.1877949778033513768632732912065661\",\n        \"0x0.301354e804b87d40aa80cfe1472a#109\",\n        Greater,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && overflow\n    //   in mul_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"295147905179352825855.999999999999999997\",\n        \"0xfffffffffffffffff.ffffffffffffffc#127\",\n        \"0.000244140625000000000000000000000000000003\",\n        \"0x0.00100000000000000000000000000000004#127\",\n        Nearest,\n        \"72057594037927936.0\",\n        \"0x100000000000000.000000000000000000#127\",\n        Greater,\n    );\n    // - in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - a0.wrapping_add(4) & (mask >> 2) <= 4 in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - decrement_exp in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Nearest,\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && z_0 & shift_bit == 0)) in\n    //   mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Nearest,\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n        Less,\n    );\n    // - a0.wrapping_add(4) & (mask >> 2) > 4 in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - !decrement_exp in mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) in\n    //   mul_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && !overflow\n    //   in mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        Nearest,\n        \"0.00497732823382322348141815797577421539704054126\",\n        \"0x0.014631b5fc58aeb12d61fe8ebe2fa3511f34a8b#149\",\n        Greater,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && overflow in\n    //   mul_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.9999999999999999999999999999999999999993\",\n        \"0x1.ffffffffffffffffffffffffffffffffc#132\",\n        \"2.0000000000000000000000000000000000000007\",\n        \"0x2.000000000000000000000000000000004#132\",\n        Nearest,\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000#132\",\n        Greater,\n    );\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.2\", \"0x1.4#3\", Nearest, \"2.0\", \"0x2.0#3\", Greater,\n    );\n\n    // - in mul_float_significands_general\n    // - xs_len <= 2 in mul_float_significands_general\n    // - xs_len == 1 in mul_float_significands_general\n    // - b1 == 0 first time in mul_float_significands_general\n    // - !goto_full_multiply second time in mul_float_significands_general\n    // - in round_helper_raw\n    // - !increment_exp in mul_float_significands_general\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Nearest, \"1.0\", \"0x1.0#2\", Equal,\n    );\n    // - xs_hi[0] & ulp != 0 in round_helper_raw\n    // - increment in round_helper_raw\n    // - increment_exp in mul_float_significands_general\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.2\", \"0x1.4#3\", Nearest, \"2.0\", \"0x2.0#3\", Greater,\n    );\n    // - b1 != 0 first time in mul_float_significands_general\n    // - xs_hi[0] & ulp == 0 in round_helper_raw\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.5\", \"0x1.8#3\", Nearest, \"2.0\", \"0x2.0#3\", Less,\n    );\n    // - !increment in round_helper_raw\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.1\", \"0x1.2#4\", Nearest, \"1.8\", \"0x1.c#4\", Greater,\n    );\n    // - xs_len != 1 && ys_len == 1 in mul_float_significands_general\n    test(\n        \"21729783659306408649613509.686\",\n        \"0x11f975eebbcb21a32ee0c5.af8#95\",\n        \"4.140691354e21\",\n        \"0xe.077a2d0E+17#30\",\n        Nearest,\n        \"8.9976327319036285762104654629e46\",\n        \"0xf.c2ad952d9bedaa8c340fb5cE+38#95\",\n        Less,\n    );\n    // - xs_len <= 2 || ys_len <= MPFR_MUL_THRESHOLD in mul_float_significands_general\n    // - goto_full_multiply second time in mul_float_significands_general\n    // - b1 != 0 third time in mul_float_significands_general\n    test(\n        \"3.29008365861415556134836580980448399733562188e-9\",\n        \"0xe.217c389f8c9fd22042f5ed70da20cfb9f1ecE-8#146\",\n        \"3719044561792922503530448846362960.3599330496921301151502834994\",\n        \"0xb75cf116bc625ef1eab58f3c9950.5c2492852d5fb6817443c180#205\",\n        Nearest,\n        \"12235967738412737409453496.5112769496822945381768578702376539566\",\n        \"0xa1f1123e59edd22860db8.82e30bd21587183f065c6eea9383ac0#205\",\n        Less,\n    );\n    // - b1 == 0 third time in mul_float_significands_general\n    test(\n        \"0.152\",\n        \"0x0.27#6\",\n        \"0.000677250271462116637219538246676594845637468375\",\n        \"0x0.002c625fc46315b1256e735851ab2413f0230460#149\",\n        Nearest,\n        \"0.0001031748460430568314514140297671374960150830727\",\n        \"0x0.0006c2fc96eb184dfcb3d3927471127f099555aa8#149\",\n        Less,\n    );\n    // - xs_len != 1 && ys_len != 1 in mul_float_significands_general\n    test(\n        \"3.600675849075089170455453502457566\",\n        \"0x3.99c5e47746483e1e72f35153c9e#109\",\n        \"7.042716356117671710991084962952371e-31\",\n        \"0xe.48c9931f0a6ce474caf85ca810deE-26#116\",\n        Nearest,\n        \"2.5358538695359015660810037702729442e-30\",\n        \"0x3.36ee7f4e42c0edeaa7100c9586414E-25#116\",\n        Less,\n    );\n    // - xs_len > 2 && ys_len > MPFR_MUL_THRESHOLD in mul_float_significands_general\n    // - (xs[0] != 0 || xs[1] != 0) && (ys[0] != 0 || ys[1] != 0) in mul_float_significands_general\n    // - out_prec > p - 5 in mul_float_significands_general\n    // - out_prec > p - 5 + Limb::WIDTH || xs_len <= threshold + 1 in mul_float_significands_general\n    // - in limbs_float_mul_high_same_length\n    // - n >= MPFR_MULHIGH_TAB.len() in limbs_float_mul_high_same_length\n    // - n <= MUL_FFT_THRESHOLD in limbs_float_mul_high_same_length\n    // - n < MPFR_MULHIGH_TAB.len() in limbs_float_mul_high_same_length\n    // - MPFR_MULHIGH_TAB[n] != -1 in limbs_float_mul_high_same_length\n    // - k == Some(0) in limbs_float_mul_high_same_length\n    // - in limbs_float_mul_high_same_length_basecase\n    // - b1 != 0 second time in mul_float_significands_general\n    // - !limbs_float_can_round in mul_float_significands_general\n    // - goto_full_multiply first time in mul_float_significands_general\n    test(\n        \"3.667390117738159207950705349477719105571949429980976394812181671883945054829509256768693\\\n        428777428660656941387302685172371854480204626447190818847235223777196475037450938977825246\\\n        002439873468885558547110470430228085143851019175355894923610792842932340338852051239754427\\\n        095026930245556704615627992643819617817074019244527799280182728405175259498139200084973400\\\n        185025632529817381341736837108765891093445296142846875524815723636775475593320258020981988\\\n        641285509338653295726597545939874976233498010217572353942629414771256828458910867296816672\\\n        522543163090158525097032013393556880192772591230747507060825723928635133507431423165786715\\\n        278150157159772706487785219042905040143153742214007713387626849311191420055238664770362170\\\n        343983987545766271318010394410223132309343859005046365250499465556871672911799580499791909\\\n        295656508202340485571517780009270726548788594036564495463224892161734462687808109262481368\\\n        096969794376769660230615691331025217443348007977074560288273633401967130359649250852147512\\\n        141074330343117535301250887203664127461249846867757356639750473042390297739319749311431157\\\n        14372183907772936544329974943881256368038028229439176970805917055179180439477409e-9\",\n        \"0xf.c0568c485e0b826908a56a1e9eed605a795d47bbb3b22b86ff364a5aa967860d79fa907ffa4b598c74ca2\\\n        768fd610cc65e72d1328231f74c2896a372707f3fffd4713cd781c36ddc8c429a53c9de0a260ab39221aa6723f\\\n        639d4f0a18f42a39ce148ec18caa8292a2404e421cb5af96a525988ace64d3b66492e8b29b9f1982af075eac7f\\\n        a4c4f560684706f9c92a1babe3a7cedd233045842df3c534b90481e818908a787ba694e61d3bd3d93a45651240\\\n        a1926f3b818e8c51165d9c7c186dd99b0afededda17332acec6e4419ca2c498ecac62e9670b8cc359ac4ce5abb\\\n        e6a858a9ad732af4717655c73ab36f06357d16912bd759fba2c774b33607e2ee49fbf3328842b34b1649846034\\\n        e601a686e91c2040c578ab8676f4c413bc62718b75fe591900b6f10a6ee20a73c59ab3be30fb9a154c1a50b4b5\\\n        d60d7a76de24b93f804302eb4d625df61cf824be4c93189bd500d72fe88443b2e506a11e3b57403b447b8602ef\\\n        45e256c2e9cbfbc69697901d340ae418d96a38e3f87b38c8ee8b168c15df448ce29060725fff6438c91fd406bf\\\n        6cf95e07431942e379a50250441c4ed69a634f4e155cb67d47b7b4b285388f957b3809dcfb73606173ca9a64c8\\\n        9b5ee06f42fc1ee8c752cf947957f346aac01a1e21759f8267f58d36b22e7bd14E-8#3843\",\n        \"3187923845432148642442057154569059.126715487792372839803386914179538752693826970283207166\\\n        811288798839227319311871148502823407877176659352907588186871022894787193533982873662011253\\\n        290757573915501169313819926148549862448642272469031186766746849160076154409190019980289710\\\n        170792165652792217117270925812431819493193080694795589891807146039351866024622601910524654\\\n        975993653145125921373829181052606711648254654081125875153947355721451359688668050452670532\\\n        460418624462017975144128989503732730892234660879379487543472739334395798501406522301770530\\\n        084261662015482020833397653047706275744771695945820139179975325296925632712346348118093097\\\n        953095934511815810581175318735500116787412839224213098543182657584610954902591533740060963\\\n        289805212670558460977431314581393471573332429725647583364688986461335610003995668212280028\\\n        807977055980202986273442266172236653427698776974320204115552560417196660880213932819325142\\\n        548937684752935846670101028764484218237392844524558383599287530029421881169570993841163993\\\n        843829902198804691520255195056203676272889080365643704609455722537324606271987166289767672\\\n        190663805227886932691226996255254535007618551610966568052639325048438160780381909128343538\\\n        211967934803057176881479842550254050201767779261994751352264395465646274141983125281497566\\\n        020553366225193569060382295548356106219949376044134821789228041804290511458952966410365196\\\n        222090758059421770693182158103609003570428820956594490269060711518240230638460085565864341\\\n        256289190220580928350048868798606128912317218138793827337661513849296003850300428079774414\\\n        62431384255329048179650372924700507846477189871631671161154559755984562472291\",\n        \"0x9d2d417f3ca9f32fea99c6482363.20706d1bf7058f4c6275f668a177cd076adccb2fda12b6ed78a3b56bb5\\\n        9dfb518b8b3c05c40c48fd5544dac5cf4c4b5097a348e21623af642ca54df95b1dc69591e2bdc1e3f296461a0e\\\n        73545f0b1a728f095b34af1c14dc3ff040878852b81a047198ec51c9f7dcfffac0ad33017fdb2f0c43edcff12d\\\n        ef18336029b6f47a305e278cb4eda766445530f250be179818a2d241b5afebc21b194dbd62400042f887100725\\\n        62fb877debcff302fcc5b1162c1450e14478eb4e96906a31d6843172390e3cd69b3c0f474a72a62036579c22fe\\\n        1d1ad35fc2be49e475a1be85f30bec6d387e595070d17b17f5b5a6f400fde641d92abee13055777fe7f6b647fc\\\n        7850f8002fadb99332ceffb5439a87b2ac7f223b73750c6b42112fffe8b992da6c3fbc5274503b1bba48602753\\\n        174ba7260f73f3fa02c00fc495aad0f85c84c966f0a98fa7d85cca68b07d58e6292617f3b67fd0aafc0dc0c457\\\n        806b811f2698bea27de70e9ea3de0e898978b9670aa90750e88ac855daaf830c9dedb5d22968f2b01302edc889\\\n        ce03e2af4ec2e339258ace8efa81eeb76b273039929d7289eadfb0bae898fd0257e0f1db349eba610dfb56e3d3\\\n        1520f08012e02d96edfbf9a1a05ad01f682c49e1cf1e0f2b1131943ffe95afd8c6454deffe4bfdbf15fe656e18\\\n        13690a6dbdca197ec4c2b29ac61a6ca074a2866ff9f55184ed344bb45b2e44eca9945a21cd78ccdd427dff1dab\\\n        1d449dccc0aa07e37c89bb61c7fc94ce0edd5fb60b7e2d8034decb7a0e2bba4c1159236fd7f800450c1516e64c\\\n        bb2206f385ee11aba1c6993b2d50b2437bc23cc47f6b85d72fdd7348a5e321b5c960e8e23830fc93c4393938b8\\\n        98c2f16e8452c9e81ce5aa01460fb108dca1e371c53a1e72ad6ad0cb80bd5bf0ace476ab08fe8#5329\",\n        Nearest,\n        \"11691360406839692866118328.82160678934697449148561930623262244451953109076390937578282165\\\n        187539508530274103471810974014544850101997980642382746362536485174905201106566021759334671\\\n        038084134174395853704847978726074297598470143399522515598459659231845311084194915852728366\\\n        056422715218301245062324603756166217017490819881851715545101168897106488715462344820352976\\\n        259754023729090781152750099501504576567751861133292449402560554539891918302651799386455549\\\n        657664547443484522197757542024159371062990161647359586646799536699319711548827677391665966\\\n        287279197599493918294842951008826029536226825832854955685587903267919852682540903329229694\\\n        700736024127943619726831445160555949561747552032983921128094877425217970278847326632273418\\\n        407484077549236662570769286015075277220777908237436835596208190640803687131540850535115913\\\n        655954830695789298058473415611731503722972733488269283706021704532728574584684669676341549\\\n        292252804245357342748316615826715707101522402518116062329441651970107805707342168691626509\\\n        305758570985170639749549248022366152944291484173783280217974452532323709041672239778485037\\\n        294723948248639908579195768663906666012983129167763644004221520737884980923091163080707988\\\n        588422464078838824212171802847408608047867571127753377657964788586031325255106000694013614\\\n        527340915821283801356153178149699147203162830520911097467745909302616153231682263893483275\\\n        019567006794361076438485306321832725119559578113910632379303074353609691782388847871383450\\\n        484766163524999863199330839928739926251980847649975020069602105177714848358628397385350021\\\n        24095735959378409981273751636624594837614456921497122960535259532723503477033\",\n        \"0x9abbdeae92a7cc75062b8.d254d2926ab47ec2646ac6102bc7f2c66e4adda59ec8c5ced87c449f85121ac94\\\n        7e79dc78b7313a18f2ce5e38db71d51c990df401764ed1949bc25e2614a9bdb3027efa1acf4ea0e322dfad232e\\\n        cbd31249cc1917bbdffcead4f455598e97f24397ef8bff64f45dfd672a81269c27e03d6cb02da64c33a0af7326\\\n        eb8e21ca7d9003144c8f62cd449d48953249142d7f5afd8112b58223fc36214a7e8c4b9a026eb8ba0dc0dca681\\\n        f9d3c37cf62540e73333f8e07151b6353a7d9d6ad54f935a33c049acbf7c6e4e80629250c603ad3a070a43d3f9\\\n        70a8c5d99edacc2b229a04d8bb9f8b71acb7611d4e6c4a3e4330466403e5422746189403976a41698df939ffc0\\\n        32b31da3e6493f1393fd89226bf6b4eadf296725de20aac599c96edd2a445c9d689fee07ae5e94997f00659560\\\n        27632aa2cbfceba0ad1dcfeb7fb56c3a038718044af027a05c55e79d87a581fe5887ab1630360a4ddf22f18f4d\\\n        250a5385c3b6ee351d8d368543ed65e80461de207d9d924e8595b146d24defa8dbd01358a44fdf639ae28a852e\\\n        7675001a1c34c22013db15e7527ad9b7064b49c21ba11b7ed42ac9a570c006de5a092e84450d553767a5e2bb57\\\n        f588dd1a63559f4b5bf0f0b1eda574f319b65c5c97023caf2862a4487c403143538931bdaba7e1fd57d1d07dc4\\\n        613f75769c70427af74a7af461be5b0126125aa40920e4e9b44a9e28616dc9ca7b77624028a0ed40aaed08486d\\\n        90086f51f501e47b6f5e0f7391a8320f07d62774d2c29f3abfc9f71514e3bc471ff2041ede5c0fb4ad39572ab8\\\n        6909d5a368ef66086eed3f37dad57f14ec6362b1b9567a687e771330ec416265c437c3e6d3c3136aedfe753577\\\n        319aed775fdefcbe6ff046d9f93acca0d253617b9b98b73f7e7fc043ad2e5f9ae06754e4df0f8#5329\",\n        Greater,\n    );\n    // - out_prec <= p - 5 + Limb::WIDTH && xs_len > threshold + 1 in mul_float_significands_general\n    // - xs_len > len in mul_float_significands_general\n    // - k < len << 1 in mul_float_significands_general\n    // - b1 == 0 second time in mul_float_significands_general\n    // - !goto_full_multiply first time in mul_float_significands_general\n    test(\n        \"0.000505125560873134723723784766950092518997332731967301291698755707702902596942317437852\\\n        941942371960388246351631317879977557751125153730732708319124734660713981958784935850223006\\\n        317900579689594830566320680544405297096706330277372404179805722699177498153458710988448597\\\n        667865038489642478166853872591228283694673924060010690084057961646317421857676637869623134\\\n        589158734829608080525671151880734425152367375882305121472858495571639962287931732234443489\\\n        588015865732596365983920824372468289009819493599234552103162449485200505569599322042323513\\\n        171853918367347759762125056867136354464299283595190704290061720089955391730926571989543650\\\n        123824756\",\n        \"0x0.00211a99c3aab8ff53e9907564934b7d8b29ea0189ec9cd3d1a74407e1344b68fcd1809f4234bfef08c0c\\\n        3f89af1fe509093292b5b157eded4009179fedceae065ab0dd9d53b35a4ce7f1d190711e92618f7d0b216ce0bd\\\n        09e9c6f6625bcc6003ad38389decfb93a34f29b624c9c3c24dd825a59d15423602847fb2fe248d2b631514d4ed\\\n        f610fd7088faa3f59c46a406f42343787142069c527e5b0aa730ef1f4054d887515ccd31c4f04063d57d8645a7\\\n        b70fd198011231617f8b64344b5d43eb951d0a8ebfe39606336b443b19074cd641a63b4656b6e71133e47c099e\\\n        1fed7bc661252f72ee2c68b5cf9db6ee0645b455fb007e9d294c3a5e091df7f92b6268fff2e65b109ec#2100\",\n        \"1.594827021209513894575272853189101796908969657496052553026904808146944132849277331696165\\\n        366066982899056554189139962942976395082328192559670863685439930018276703216617917370998670\\\n        143663891402542565265723410284904517798491873969116076521737839809230852429183992755715781\\\n        991743918659448701680599805386273131215689278489918563344703836788128584757613316503273812\\\n        347176374414975252562793531554358724296424942636927017522952046066543039832692600611375088\\\n        044395866209370211970587133626417624012062511750942538348241762511210915523305672594074841\\\n        5529943020302456665999104875220004206872624343740835605816652e-79\",\n        \"0x4.ba3e1591f6a0ae18e8a750107efc0ca278b3954588d15a3695387227774da4319070b249d295916c24713\\\n        070f060a0df67ad5c2e8cc350d13189bcbf73f9af1e33fe42bf44fe99164bf802f7a5f41fe2d28377f1932b019\\\n        a00373f4400d62f20693ce9fbe239afbc3c804face7c59fb40fe03be617f14dd6880b31ff429280aafe8ea5d94\\\n        c3349efe67683ab81b8b5f4d00925073051d872bde743109c8e7c79da2c5fff9f489b12c271aa83405fe1d99c2\\\n        9f846c6b1c71dec233f13240569b3015559ed53bda719283585ed3f94bdeaea4d8438fe90e633bb97ee755eb88\\\n        113450187e9b05d8e6040fa53e6a10b6dcc2f01463a3937f5a90E-66#1988\",\n        Nearest,\n        \"8.055878935840864338761112052964131694842078144914087985110265043132694138227764882097467\\\n        485603629304908508159498533271385147841989466565220242546894501115782558008761861379571521\\\n        691942027516784202151149343065118307142127390742346695428089929852244559471690807529077258\\\n        667004534037323942848543095527661248910413746226405479291587579546107337446543923963731652\\\n        263604834014601264189816875633028978567676911887046995279630281027980542407933148412976200\\\n        257662826354908783390381610432026516882234795071151533161797811544609495678329417798803859\\\n        814384620434259660366163853727351148214688205975873187006097686502581917099916584703699137\\\n        7927e-83\",\n        \"0x9.c7fc20220e43b5ac1717bf3fc467495e7a66c020cb393887e4bf4a3ad3eb4f20763507aea5b673c5aff25\\\n        8525ec5ac9bbc9f5c976983bce6231282e951654f346e3e5f7779ecdeae718176d55b03e21297ae13b32728a38\\\n        30c19eb847a199cde2fd0f3aa2330282fc433000c5f99b14022cd881da6b7caa98d3563644c4710ec876c4b61c\\\n        b15fdd4cc7d712644bad3a66e844700eafebabf02dead4fd71d95a14ef9c6a12db9092cf7b4723f45cb086b401\\\n        8123e185be43126baa17ab68fd32a0834023652a003d24211dd87066d2d5b1f0f1993c0dd9756329316927dd98\\\n        425ba5d470abc9065c6ff724d0e16c68152314d36e37d235fe078572e42d94540fe4418a9440633E-69#2100\",\n        Greater,\n    );\n    // - MPFR_MULHIGH_TAB[n] == -1 in limbs_float_mul_high_same_length\n    // - k.is_none() in limbs_float_mul_high_same_length\n    test(\n        \"5.001744775175450910666028825162941035057223155811961434576858983758571141018459147239961\\\n        203150588371507863692097065128597336587126035820647361489875366021800666979434518756504925\\\n        080057234368614339602900137940067888065298554658519361482160014564328827389146902718969285\\\n        655774560873251528749737416878097111467317878479458938947793439179987668446365650646689222\\\n        368834166803110702160567896615568919058064520266761717855703906871630752776256537972706691\\\n        492064397304429453321564568279795029252524047182880248127317544801138445700458013706547493\\\n        607273723210196209139384085476634511414334117395068648152693457778920460359930382343697178\\\n        078573995749595631668772420417704996567074590195305455833132484492282116574194971013126880\\\n        3791636230633361526548302742414616516594455084620537903358416e-16\",\n        \"0x2.40a97302ee75111e17146bc65c8925811ce517da511093e155a5f8d319eaddbeb4108f1636a175bfa8c49\\\n        995045d6820b2f007a269091d024c939d8b02f4910a81e4eb38a836a327a5c12207dbd4d7a81228e55fec96493\\\n        eb7d51704a03ee77c5caca6616fdc0b6cbe90c676923de6ef8bf3f132b9e5e0dcbae8db3a41502b6d35629f01c\\\n        0834af3506639efdaa9dba6adf35a24b53b04e032ba7f9821a7155eb04aa7d235436bb878e13e2f265b7a183bd\\\n        7830bf484c2c6b19e1df88120105ab6ceb5f940ee7e82d4a6da4e67b7532f20750db350a532138117c02fd3f63\\\n        1e917747a8217c0e647adfae38491beacae6be9197fecb6a639604eba9f3e2a0e1250124f9d994d6ae0f8077c0\\\n        ad1f961f00f0513cb1b3b92f03fd2e19ce799415d8c26352d23ab730bff342c3d10823b5d476e3a74e5e3a1265\\\n        3a2e81ad38c5d7f45687a8E-13#2587\",\n        \"1.142392802815468388118014752111991104436260746248041498551240097570984474280784266879307\\\n        592064853042631818930172030116326290909317377878988867978348974337550025356060840134215623\\\n        183687852648862683292152461337367387727519703906836027722282460995072637442171724001503892\\\n        471336699233392710738717656085295397789876649817787754823752786376233371866685422498954888\\\n        388883747226256845650864591251580129661172288008506642506027201072159168710566406994425528\\\n        61698637621752755004821872e-17\",\n        \"0xd.2bbf98dfde60cfd72ff373085dca4697e7a8a2b1b6d379d3c49be918a519d5508c59f210662104e5d0b4b\\\n        bb4e9f09afcccb3c1655f91f2a86657e3f1315aa4e7c857d68f4d7b989d2a2f5d56a205e85ef7d6d2e9325e0fe\\\n        eded2158374d99d513a6d203143a26cfd251731f49e63a0e342dec62e52287bd673124d763a94038f4529cffd3\\\n        3599c97c0e19c589ce5603d9c26a084d360b9e7decaa7dda44ce1c27bb7c21adcb23b90d069b0a9b53b9d66094\\\n        d817f0420227841d34052ed2bd52e148923f8E-15#1571\",\n        Nearest,\n        \"5.713957232680308157039243396854396365207579750474509016836068310655183904589399398864949\\\n        369194427543435776465300666190725186454505340683874976519507548279996486761744005041118935\\\n        948747589743699350970808906395296086217435990867715483224265504817855574934867156151545781\\\n        106814865537845359234760816964504042844539777879186641559132734209465852287196566458935778\\\n        830300266229578325422723437672411534085537936547389438107265754858071594639985760821104661\\\n        940648845072022419465943642338099526948876829384943161258695569354371632958134560717841147\\\n        840574265292252548747529841143166165808068071464187327019844718180901133673499079508336221\\\n        530763161764985656092293178070670798408664087435197003752408586649867017671653317949434498\\\n        7804832149608135310831412140057788625216612318872425368846162e-33\",\n        \"0x1.dab26e4414e016457a3b64d6dc588a9f2a4cbec7acd1a5b9033e00168a27a1ac3f669e39332cdbace29d9\\\n        b5d727df53a041f44f1389d6fda544d07799d35a62fbf327a55fca19ed803e80954753bfb12dcfda81be99eda5\\\n        2d7a382f6dd0ac26ab4b55fa3587bc812156b0ddb289357e7300ea3dafa43cee4f98c4068d3ffbeceea4a01ecc\\\n        74a09b85289f4c37000efab1e07926e01496cf6855b4a1f08915fff56a1737ff1d109fb6f3011fb249b88db85f\\\n        52980590101cbaa0e8af5872ded15ef0f39ec69d2d19d45c2972793e60bbb6eee9b673f24b3318973256a8e9bc\\\n        90d40f033e145dc56a6caa7e542a2701c0a41519fd0ef8d97ed0cef3e4296de50e877edeae80c0dd91f9082539\\\n        71e8998ef2a91d865baa5aa565e308789af81b128e8d0e832f5368e689962335ca7077ad875ea20eae1f2fc375\\\n        a972b8e7b8e285bbe3bdb0E-27#2587\",\n        Less,\n    );\n    // - xs_len <= len in mul_float_significands_general\n    // - limbs_float_can_round in mul_float_significands_general\n    test(\n        \"2791656999165.493196894581080462482671477586959884065253358835066410305633620155930725019\\\n        490863414181814174955842522364865024774379310519058136940369290858518517313460149216061827\\\n        231421960818181308820010416988884966114071973567666857448623899431042502611223036510238920\\\n        700493077403107131238955287441775846760482666068674778697270732066126184067657756561516984\\\n        251159820991198761865419427067747698722303345927460124328666182849055120607788400162794652\\\n        0878157328543259919881\",\n        \"0x289fbb948fd.7e4226d4b6e97c4ccb64c2a072193f46e582b56e431d1d873706fd936c5e3328fd5b164ebe6\\\n        f6c3319057366a2de168eaef87f67644a657027f176fb9d5deaa62912e24d9b1eebf67a642c7ebc91e95eba928\\\n        d2c47f45ab981a3053c2a055e2a36102f8c4b2c72f24edbf87122ddff42408c1c95b6eccee7c0a49a25e2fe2fd\\\n        67a0dfc9d33ccad11d273f88f3e5a176da6b5989e6fc247727a58af5ef0f3a863e35d59edceb1ed0401bb2ce98\\\n        77227cdff6442212230b17fb43a061516c#1558\",\n        \"2418611879271263.303076595070873673412348926925363768438166046534014463089969421888804109\\\n        398849144724043021994927400943502019398552005514731676646297869532250197280910814394530400\\\n        370821284006890204265425587260634300563572770382580394115150082129924900080499709146475799\\\n        383767996765000283568589472197582158015457869515972738606414178902063354061536898088295371\\\n        641586286472920893106777705320869713042818435525510767840203306234890813618032983465299395\\\n        730347727963352100742341245602143\",\n        \"0x897b6f5e9db5f.4d966d80032f1615c15b6d17e02b100d2d97b52de1b561199b3dbeda9276bc25c5519d480\\\n        c2c20f52155b94074ad9db0bd7a97dae0337b738b6709c5fdd1bbcf1492bef975c393313e477790485d0a4ed0f\\\n        8790d9d469d65c29122cd019f7ff423e0f74c0585cac3aa85ceee8cbd256a201e23dd78f6dc402aa36b5a053ea\\\n        c1a3b2c435ae84ee9942bec1d88e41507bee030c35cd3f18b2f7a5c9193976d7418a633e08ca4923be03a2dc93\\\n        6ed64c6ff04ace32f44aa72f58bf488b9bf31c4c03f#1596\",\n        Nearest,\n        \"6751934781032429031553446805.854936199324254228337806577049209187291041079391491758652444\\\n        360751832908394550062618692018471995917689775126406303977393164343146088816585483538887454\\\n        027840163444916716206473736192766508247978473183426254779355642987433462433675113794019449\\\n        629515518752711445976665575431349720824019816455254142652806744349728110370084378693365847\\\n        376950483953541149499814845310185214082773221620162084856311318860928357827312318714828967\\\n        076794760533141841485387490188815\",\n        \"0x15d111cde75ec690f0fb3395.dadd194843a336fd8b04fc1edf686f76aa52a00d00db09b133bcedaa832e64\\\n        e3cbe80e635c5bb60e81bb4cb3839dc581a1f683d480b6757136ace3d394264c5f969b75cb4d985b4b2b1096d2\\\n        a53a6d6570c7f7c917bed4f2a9c8f7bcdea046337457665b27e5e01bdbce6f20c6d5bc9e463f055cca9b0c53a2\\\n        f1f5b6d7211ac001a5fa99daf3378815db2c7bc77c6d6b76f815ae464fdc70ae82752dbe2b5683cc1ebc18275d\\\n        4685cbd35d58b70dbda84d2297ff9a12d20f2283678e#1596\",\n        Greater,\n    );\n    // - out_prec <= p - 5 in mul_float_significands_general\n    test(\n        \"7.449979045041702122541548973189889723858373710052883535770432677692650998750696470703091\\\n        744255868088920360332810996981821635561095981209970543165990341865465399250649125818133550\\\n        345620227288485003961432095280508748897878683743133302349812547742789930883805941444651209\\\n        784236601329970891014476723035066837590220224883282604585022340111695027909185310636007609\\\n        680407882966239499164648695501638941698641158401193435378725738878261400237405551514713128\\\n        836982995938875007304023367379668047357772772649359285993284186179803252277e-21\",\n        \"0x2.32e78d682285335802e277865ca4c9a80daafb30e4f67daedb2f466845a2fba5d9b1c96b068c42999ae0b\\\n        463fb94e578b359027630c01a995d88a74b72186c316ec30a8b4238fb27273b57cc5e72fa518fa14032e99af11\\\n        e1d5ccfc1217be504bf8dae0d1ec7e885fc95b51f444d68ed47eb588644910e4196d65104707dcd1c488a22e9c\\\n        1ef05ce85b3823fd6aa2bb7ad7d14fa1da7a628e1ba344d98ad7e95bf7e01883afc84273614fb8387e4035b2d9\\\n        ad867bc2be83eaabaa44df896348f52d4972bc5e8cf58f1cfd421cc30920d9f5504a043149274f5E-17#1738\",\n        \"4.689598630661113758052361654518074651900718126313070505518580809308545656249466966444734\\\n        190644625007707301196274229099309347916384836732990153197811248723616418486524781737017155\\\n        222220872736570797023388780311017887508289881051954626904239986311860650999175535050592519\\\n        124458883175586921775053060798371665433755864916689805023189965297596140362143269558535567\\\n        196585839368205277548820051354051306095222442551993791324926248616628216018709202221063695\\\n        130497558241752004759655263919857509980778615592531001107310020150056419e-20\",\n        \"0xd.d75c4c85ded4dada979685c90590eb9f191595aa1862df62f276fa75d5d790d2c00d187fe126b806534fd\\\n        0379dfcf600aeee23bbe00ed5955cc2e11b7de967da0c347d3ca03714f55b714dbe2c9ad31dbd7b6fb9a639fa4\\\n        da6cec918f3fc77bbca5ded28446186fe8b4224339c0722fed5f69b2d07571b12f4cce6fece51fc63ab46ea7fe\\\n        5c1f350ed6aab2c76a1e817bf652a9c77a95e3e3c107ed65e9ace86dfec217fb9dcbba544e3d84b0f3cac6c221\\\n        176c57f1db9bc306f22db85308dab755243a502d385e1b0a31f2f8c2d53c98729cfe52f82289cE-17#1730\",\n        Nearest,\n        \"3.493741152808155821061780436862260285420312736969910829282351541785101293399126489805777\\\n        980187532032743650816868281893520821921299562434265222876601442289649987508199259232837158\\\n        559068445030886433472805552651673239073165198885867344396236299229232184802565958836951408\\\n        637905144866851014091996571320623346167534428281388860566996500707311335172658622534949254\\\n        838518529528764394710349462443386828046760610922770501616700810546292498376696602122491857\\\n        8540047731481736443609736067164917894729323015869507020379275317039780244947e-40\",\n        \"0x1.e6f4d9986216e186a3b15da557e0677276dd590e3d92a71ff89974ad2abac1a1e2e3dc761157b14cfef04\\\n        285b10c4bf2f72117bbdbdfd5ead95a5ed69f62f69682442a59a3f3c8a5a7b41238f0a029b2d53c54a08053451\\\n        35f5fc0a67464283bade3997992eea966997d442d69987820628966dfcaa6d25ca0be2df6ed92e5fa5201002da\\\n        70c6447c3a8a64ebd34fc04156c8dbd224d772ba1059982a5aa333d301a708dc568330bdead12245127d520b32\\\n        b4e7d9ae221552ab3d3f5f2f139c90118fe830b6adc84392948585b40267beb9fd60cce93fbed140E-33#1738\",\n        Greater,\n    );\n    // - xs[0] == 0 && xs[1] == 0 || ys[0] == 0 && ys[1] == 0 in mul_float_significands_general\n    // - xs[xs_offset] == 0 in mul_float_significands_general\n    // - ys[ys_offset] == 0 in mul_float_significands_general\n    test(\n        \"4.44089209850062616169452667236328125e-16\",\n        \"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000E-13#2587\",\n        \"6.938893903907228377647697925567627621275394370123920756842177449687616281576087749649243\\\n        449560881562252974476503855378704420289043275360540974361356347799301147460937500000000000\\\n        428087763478203718701697872488500162623204828539850902982930587576291943616315378569169353\\\n        840957917417166522314320167278698048638040260019989045715363127222769643922793712163996851\\\n        225018060026136483495536368092685586468682354268058778363979622204058653592623442621394947\\\n        3239996744456973724770155e-18\",\n        \"0x8.0000000000000000000000000003fff000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fe00000000000000000000000000000000000E-15#1571\",\n        Nearest,\n        \"3.081487911019577364889564708135884006379343333980678546187704758135879626468817238227001\\\n        919863959483626636205013163029555487554952753086708205626001498966504653625325671484347367\\\n        558282010814620352468694740583510310926487120637351903244174605756585424927747220355720149\\\n        705262186320261062950329818867477826244378862350354462458385252797818784708103173459291235\\\n        769538479528034217611825504020777438216019896385615152551542382665798426796321259955655479\\\n        300773291504754679549289638268112862439028560817297535629039872109954348969232817790940901\\\n        772925125639499661447304917621775611916484032847611462965461660088172016929375670794716891\\\n        215288121297398166137896866022540415673603027116093396582728756514564426357106145459651571\\\n        0636500728956428014332817951864653686798458732591874037159276e-33\",\n        \"0x1.00000000000000000000000000007ffe00000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000E-27#2587\",\n        Equal,\n    );\n    // - xs[xs_offset] != 0 in mul_float_significands_general\n    test(\n        \"3.999999999999999999999999999999999999999999999999999999999999999999999999999447285212473\\\n        955543975273480780774427448575976676077991358482977909210124597604668289823519777773553500\\\n        1249731874464215297923136674027554116062077582682832144200801849365234375\",\n        \"0x3.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000000000000000#2090\",\n        \"3.944304526105059027058642826413931148366032175545115023851394653320312500000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000038180485e-31\",\n        \"0x8.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000001ffffffeE-26#2567\",\n        Nearest,\n        \"1.577721810442023610823457130565572459346412870218046009540557861328124999999781992456191\\\n        582683140605249728137786969774247203293102032637435297463867968227730622206111553159326620\\\n        257748727154917100482837417166916131758491078680030585867783733868391940878208953914079279\\\n        677271330675596139325733702207799069583415985107421875000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000001527219401e-30\",\n        \"0x1.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000007ffffff8E-25#2567\",\n        Greater,\n    );\n    // - ys[ys_offset] != 0 in mul_float_significands_general\n    test(\n        \"3.552713678800500929355621337890625000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000185653473271011701515143789632334288014147578747413968011889263434165\\\n        454031003144878632958696545103828379944287431463737771314691776232764018029744516848435369\\\n        906941507005331339097431189921414095915636548343770290467007831930064077297413615608072068\\\n        77626957251331627162116234578193867366731943186452308784033031e-15\",\n        \"0x1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000003fffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffE-12#1693\",\n        \"131071.9999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999931137299504668061215619580033350122879947175743013377219720120678876536\\\n        628643562946337394277177628286886258713868752206334184193331360816755408598724051586961746\\\n        685495576886231160425736851019484652776925452038003143395027472798288565900387988918967170\\\n        024140096215282631707814129061246845336549291242702672707242154281040996134116689237194330\\\n        449329247059466983779402165943011772702916829761392820351107526820413839207822952585392346\\\n        328868866364548445701244431290159307431187837005854773744122693182105660536394809595147776\\\n        165023610906858577556273686957594781817444085841499342583068122729709267291\",\n        \"0x1ffff.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffff80000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffc0000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000#2930\",\n        Nearest,\n        \"4.656612873077392578125000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000243339720485780457409929267946893197985903514415810436152543495368429\\\n        343907516442055321546973277589582124346598388556070043505489984826143425305512049232107258\\\n        133592644143603087675038065556842214758248268059151846952539521827810268928481776834311731\\\n        044052486308720793745225556140061733844701779522496735016181906708106564202059526039890815\\\n        919178696765989061598664073635409369732679923290228161362302668920197866351570235145652815\\\n        456445767888399222146130209012884306181795683184194476165898983356347814975458163826496169\\\n        408195862006279548822773547655683272930717806964759394377376260006554734212838956379338694\\\n        525902352837865322055484704841599472083306918235788680977972181745262154636e-10\",\n        \"0x2.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000007fffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffdffffffffffffffffffffff\\\n        fffffffffffffffffff80000000000000000000000000000000008000000000000000000000000000000000000\\\n        000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffdfffffffffffc0000000000000000004000000000000000000000000000000000000000000000000000000\\\n        00080000000000000E-8#2930\",\n        Greater,\n    );\n    test(\n        \"12962368.00910437392826314193446550944389165836262015621514962112057577196019471161937054\\\n        243429475140935082492484312458697139062031326336320065697050792374770657213779646419924892\\\n        886900897092216274606911219143642483069838857046000551685989850622347518286427108428594195\\\n        826642547794926862213089792293539194572777838215978068770604450325322408918968488729618206\\\n        83239161602000658143319869428\",\n        \"0xc5ca40.0254aa0c45bef8b7e5bdc2c8d0bc3f4ef77512b0c665764acef9797020852473fed6cf5aef7ab76f\\\n        af4e7ccca7674b7b9a7d4e3adf7dbd2f9c51a93c8b500f9c6e799811cc9793ad3189530f5202900aed04c32d98\\\n        72075f4a8efb28f1e3d9e2065d70be0df4f07d46d4f2f48b95a6fcd718d2f233dbbaff41296fe46efd00783168\\\n        f9da607a651780d29e9357c1d8e9abdd149e2d7ed04e74488fff360#1283\",\n        \"24678125950611051118469790273997953293778953666881566874553684447233373952852192.03220118\\\n        824573657786267791510531425783997288827451260529832388036858875235909753308200751110173525\\\n        014519161498781309811156911488470099945303550175018037705473098495478288721507648423524330\\\n        255884870759432606723320831807670552582364423881930823507999308667398128596287742877235432\\\n        154091338959855861235089997932459245142831892\",\n        \"0xd51fdc4e02742b528c90f8a31146dcba3e1273bfdd1198ff1ec486c97e52f8c0e0.083e564a6864272a5d52\\\n        74cbdf67db38b72e576e7cfe8be5418f583cf4173a82939f37d7b6b399cada03434a24aef04a65323c333b33cf\\\n        622583787d8ec1f247c4f691c3a7862628783f4322923b6bb9434902754e348fb74eb6364e294832597785e445\\\n        1994ee48803ea5771d85e7f226166cdd1853477f296076996b97965596455eb50129#1336\",\n        Nearest,\n        \"319886950346849155967554337687681180827634107405044558954903133134156000777816460853971.0\\\n        571286460940042331570995057120143779176892645683546163312322051333969186064059757999062545\\\n        749424646225780605680908775358827191384406475576071818545005626321659954666901446716884049\\\n        318512517659256499382137861718683137930417158199590725586222075459373218000006096544204046\\\n        600400863088080659996213042623116710817104536\",\n        \"0xa4a9e4f5c54093e3388df17b55e5724251f90cd6c231443e4bc0d5770919a2c1878982d3.0e9ffba2a37526\\\n        7ffbc880a862170226c003dcfce47863efaa79493245f971642ca10409a10ad584de1597974f309b61313528bd\\\n        1512f14b2397a5630d41d067d57d9b327d751eacb350f8e13428d4508849e4464775e72f3b4fb63d6bef2d97b6\\\n        f0118aa022becb98c8c88fdcb280078abcbe4c3b8423dc1dfc91e6b09ea9115cd0cd#1336\",\n        Greater,\n    );\n    // - exp_sum - 1 > Float::MAX_EXPONENT\n    // - exp_sum - 1 > Float::MAX_EXPONENT && sign && rm == Floor | Down\n    test(\n        \"2.0\",\n        \"0x2.0#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    // - exp_sum - 1 > Float::MAX_EXPONENT && sign && rm == Ceiling | Up | Nearest\n    test(\n        \"2.0\",\n        \"0x2.0#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - exp_sum - 1 > Float::MAX_EXPONENT && !sign && rm == Ceiling | Down\n    test(\n        \"2.0\",\n        \"0x2.0#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    // - exp_sum - 1 > Float::MAX_EXPONENT && !sign && rm == Floor | Up | Nearest\n    test(\n        \"2.0\",\n        \"0x2.0#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    // - exp > Float::MAX_EXPONENT\n    // - exp > Float::MAX_EXPONENT && sign && rm == Floor | Down\n    test(\n        \"1.5\",\n        \"0x1.8#2\",\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Down,\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Less,\n    );\n    // - exp > Float::MAX_EXPONENT && sign && rm == Ceiling | Up | Nearest\n    test(\n        \"1.5\",\n        \"0x1.8#2\",\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - exp > Float::MAX_EXPONENT && !sign && rm == Ceiling | Down\n    test(\n        \"1.5\",\n        \"0x1.8#2\",\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        Down,\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        Greater,\n    );\n    // - exp > Float::MAX_EXPONENT && !sign && rm == Floor | Up | Nearest\n    test(\n        \"1.5\",\n        \"0x1.8#2\",\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    // - exp < Float::MIN_EXPONENT\n    // - exp < Float::MIN_EXPONENT not special\n    // - exp < Float::MIN_EXPONENT && sign && rm == Floor | Down | Nearest\n    test(\n        \"0.5\",\n        \"0x0.8#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - exp < Float::MIN_EXPONENT && sign && rm == Ceiling | Up\n    test(\n        \"0.5\",\n        \"0x0.8#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    // - exp < Float::MIN_EXPONENT && !sign && rm == Ceiling | Down | Nearest\n    test(\n        \"0.5\",\n        \"0x0.8#1\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    // - exp < Float::MIN_EXPONENT && !sign && rm == Floor | Up\n    test(\n        \"0.5\",\n        \"0x0.8#1\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    // - exp < Float::MIN_EXPONENT special\n    // - exp < Float::MIN_EXPONENT special and sign\n    test(\n        \"0.8\",\n        \"0x0.c#2\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    // - exp < Float::MIN_EXPONENT special and !sign\n    test(\n        \"0.8\",\n        \"0x0.c#2\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    // - exp_sum < Float::MIN_EXPONENT - 1\n    // - exp_sum < Float::MIN_EXPONENT - 1 && sign && rm == Floor | Down | Nearest\n    test(\n        \"0.1\",\n        \"0x0.2#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - exp_sum < Float::MIN_EXPONENT - 1 && sign && rm == Ceiling | Up\n    test(\n        \"0.1\",\n        \"0x0.2#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    // - exp_sum < Float::MIN_EXPONENT - 1 && !sign && rm == Ceiling | Down | Nearest\n    test(\n        \"0.1\",\n        \"0x0.2#1\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    // - exp_sum < Float::MIN_EXPONENT - 1 && !sign && rm == Floor | Up\n    test(\n        \"0.1\",\n        \"0x0.2#1\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\nfn mul_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(THREE.mul_round(THREE, Exact));\n    assert_panic!(THREE.mul_round_val_ref(&THREE, Exact));\n    assert_panic!(THREE.mul_round_ref_val(THREE, Exact));\n    assert_panic!(THREE.mul_round_ref_ref(&THREE, Exact));\n\n    assert_panic!({\n        let mut x = THREE;\n        x.mul_round_assign(THREE, Exact)\n    });\n    assert_panic!({\n        let mut x = THREE;\n        x.mul_round_assign_ref(&THREE, Exact)\n    });\n}\n\n#[test]\nfn test_mul_prec_round() {\n    let test = |s, s_hex, t, t_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (product, o) = x.clone().mul_prec_round(y.clone(), prec, rm);\n        assert!(product.is_valid());\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n        assert_eq!(o, o_out);\n\n        let (product_alt, o_alt) = x.clone().mul_prec_round_val_ref(&y, prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = x.mul_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = x.mul_prec_round_ref_ref(&y, prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_prec_round_assign(y.clone(), prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_prec_round_assign_ref(&y, prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (product_alt, o_alt) = mul_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_product, rug_o) = rug_mul_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_product)),\n                ComparableFloatRef(&product),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"1.0\", \"0x1.0#1\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-1.0\", \"-0x1.0#1\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"1.0\", \"0x1.0#1\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"1.0\", \"0x1.0#1\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"1.0\", \"0x1.0#1\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1.0\", \"-0x1.0#1\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Floor,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Ceiling,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Down,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Up,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        1,\n        Nearest,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Down,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Exact,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Floor,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Down,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Up,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Down, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Up, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Up,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Down, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Up, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Up,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Down, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Up, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Up,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#1\",\n        10,\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Down, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Up, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#2\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Up,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2.0\",\n        \"0x2.0#2\",\n        10,\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Floor,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Down,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        1,\n        Exact,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Up,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2.0\",\n        \"0x2.00#10\",\n        10,\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"8.0\",\n        \"0x8.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"8.0\",\n        \"0x8.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"4.44\",\n        \"0x4.70#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"4.44\",\n        \"0x4.70#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"-8.0\",\n        \"-0x8.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"-8.0\",\n        \"-0x8.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-4.44\",\n        \"-0x4.70#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-4.44\",\n        \"-0x4.70#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"-8.0\",\n        \"-0x8.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"-8.0\",\n        \"-0x8.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-4.44\",\n        \"-0x4.70#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-4.44\",\n        \"-0x4.70#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-4.445\",\n        \"-0x4.72#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"8.0\",\n        \"0x8.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"8.0\",\n        \"0x8.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"4.44\",\n        \"0x4.70#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"4.44\",\n        \"0x4.70#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"4.445\",\n        \"0x4.72#10\",\n        Greater,\n    );\n}\n\n#[test]\nfn mul_prec_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::one_prec(1).mul_prec_round(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).mul_prec_round_val_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).mul_prec_round_ref_val(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).mul_prec_round_ref_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.mul_prec_round_assign(Float::two_prec(1), 0, Floor)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.mul_prec_round_assign_ref(&Float::two_prec(1), 0, Floor)\n    });\n\n    assert_panic!(THREE.mul_prec_round(THREE, 1, Exact));\n    assert_panic!(THREE.mul_prec_round_val_ref(&THREE, 1, Exact));\n    assert_panic!(THREE.mul_prec_round_ref_val(THREE, 1, Exact));\n    assert_panic!(THREE.mul_prec_round_ref_ref(&THREE, 1, Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.mul_prec_round_assign(THREE, 1, Exact)\n    });\n    assert_panic!({\n        let mut x = THREE;\n        x.mul_prec_round_assign_ref(&THREE, 1, Exact)\n    });\n}\n\n#[test]\nfn test_mul_rational() {\n    let test = |s, s_hex, t, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let product = x.clone() * y.clone();\n        assert!(product.is_valid());\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n\n        let product_alt = x.clone() * &y;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let product_alt = &x * y.clone();\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let product_alt = &x * &y;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n\n        let product_alt = y.clone() * x.clone();\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let product_alt = y.clone() * &x;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let product_alt = &y * x.clone();\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let product_alt = &y * &x;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n\n        let mut product_alt = x.clone();\n        product_alt *= y.clone();\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        let mut product_alt = x.clone();\n        product_alt *= &y;\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_mul_rational(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::from(&y)\n            ))),\n            ComparableFloatRef(&product)\n        );\n\n        let product_alt =\n            mul_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n\n        if x.is_normal() {\n            let product_alt =\n                mul_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), Nearest)\n                    .0;\n            assert_eq!(\n                ComparableFloatRef(&product_alt),\n                ComparableFloatRef(&product)\n            );\n        }\n    };\n    test(\"NaN\", \"NaN\", \"123\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"123\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"123\", \"-Infinity\", \"-Infinity\");\n    test(\"NaN\", \"NaN\", \"0\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"0\", \"NaN\", \"NaN\");\n    test(\"-Infinity\", \"-Infinity\", \"0\", \"NaN\", \"NaN\");\n\n    test(\"0.0\", \"0x0.0\", \"0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"123\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"123\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-123\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-123\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"1/3\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", \"-0.0\", \"-0x0.0\");\n    test(\"123.0\", \"0x7b.0#7\", \"1\", \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", \"0\", \"0.0\", \"0x0.0\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", \"-0.0\", \"-0x0.0\");\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", \"2.0\", \"0x2.0#1\");\n    test(\"1.0\", \"0x1.0#2\", \"2\", \"2.0\", \"0x2.0#2\");\n    test(\"1.0\", \"0x1.000#10\", \"2\", \"2.0\", \"0x2.00#10\");\n    test(\"1.0\", \"0x1.000#10\", \"1/3\", \"0.3335\", \"0x0.556#10\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n    );\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", \"6.0\", \"0x6.0#2\");\n    test(\"3.0\", \"0x3.00#10\", \"2\", \"6.0\", \"0x6.00#10\");\n    test(\"3.0\", \"0x3.00#10\", \"1/3\", \"1.0\", \"0x1.000#10\");\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n    );\n\n    // n and d both powers of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    // - only n a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"1/3\",\n        \"too_big\",\n        \"0x1.0E+268435455#1\",\n    );\n    // - only d a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"3/2\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    // - neither n nor d a power of 2 in mul_rational_prec_round_assign_direct\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"3/5\",\n        \"too_big\",\n        \"0x2.0E+268435455#1\",\n    );\n}\n\n#[test]\nfn test_mul_rational_prec() {\n    let test = |s, s_hex, t, prec, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (product, o) = x.clone().mul_rational_prec(y.clone(), prec);\n        assert!(product.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n\n        let (product_alt, o_alt) = x.clone().mul_rational_prec_val_ref(&y, prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = x.mul_rational_prec_ref_val(y.clone(), prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = x.mul_rational_prec_ref_ref(&y, prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_rational_prec_assign(y.clone(), prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_rational_prec_assign_ref(&y, prec);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) =\n            mul_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        if x.is_normal() {\n            let (product_alt, o_alt) =\n                mul_rational_prec_round_direct(x.clone(), y.clone(), prec, Nearest);\n            assert_eq!(\n                ComparableFloatRef(&product_alt),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(o_alt, o);\n        }\n\n        let (rug_product, rug_o) = rug_mul_rational_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_product)),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"123\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", \"0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"1\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 10, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", 1, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", 10, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"1/3\", 1, \"0.2\", \"0x0.4#1\", Less);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        10,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, \"8.0\", \"0x8.0#1\", Greater);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 10, \"6.0\", \"0x6.00#10\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"2\", 1, \"8.0\", \"0x8.0#1\", Greater);\n    test(\"3.0\", \"0x3.00#10\", \"2\", 10, \"6.0\", \"0x6.00#10\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"1/3\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"1/3\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n}\n\n#[test]\nfn mul_rational_prec_fail() {\n    assert_panic!(Float::NAN.mul_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.mul_rational_prec_val_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::NAN.mul_rational_prec_ref_val(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.mul_rational_prec_ref_ref(&Rational::ZERO, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.mul_rational_prec_assign(Rational::ZERO, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.mul_rational_prec_assign_ref(&Rational::ZERO, 0)\n    });\n}\n\n#[test]\nfn test_mul_rational_round() {\n    let test = |s, s_hex, t, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (product, o) = x.clone().mul_rational_round(y.clone(), rm);\n        assert!(product.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n\n        let (product_alt, o_alt) = x.clone().mul_rational_round_val_ref(&y, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = x.mul_rational_round_ref_val(y.clone(), rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = x.mul_rational_round_ref_ref(&y, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_rational_round_assign(y.clone(), rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_rational_round_assign_ref(&y, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_product, rug_o) = rug_mul_rational_round(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::exact_from(&y),\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_product)),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (product_alt, o_alt) =\n            mul_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        if x.is_normal() {\n            let (product_alt, o_alt) =\n                mul_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), rm);\n            assert_eq!(\n                ComparableFloatRef(&product_alt),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(o_alt, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"123\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", \"0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", \"0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", \"0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", \"0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", \"0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", \"0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", \"0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"123\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"123\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"-123\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"1/3\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Floor, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Down, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Up, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"1\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"1\", Exact, \"123.0\", \"0x7b.0#7\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Ceiling, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#2\", \"2\", Floor, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Ceiling, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Down, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Up, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Nearest, \"2.0\", \"0x2.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", Exact, \"2.0\", \"0x2.0#2\", Equal);\n\n    test(\"1.0\", \"0x1.000#10\", \"2\", Floor, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Ceiling, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Down, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Up, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Nearest, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", Exact, \"2.0\", \"0x2.00#10\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Floor,\n        \"0.333\",\n        \"0x0.554#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Ceiling,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Down,\n        \"0.333\",\n        \"0x0.554#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Up,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        Nearest,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Floor,\n        \"0.3333333333333333333333333333331\",\n        \"0x0.55555555555555555555555550#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Ceiling,\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Down,\n        \"0.3333333333333333333333333333331\",\n        \"0x0.55555555555555555555555550#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Up,\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        Nearest,\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n        Greater,\n    );\n\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Floor,\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Ceiling,\n        \"1.0471975511965979\",\n        \"0x1.0c152382d7366#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Down,\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Up,\n        \"1.0471975511965979\",\n        \"0x1.0c152382d7366#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Nearest,\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Floor,\n        \"-1.0471975511965979\",\n        \"-0x1.0c152382d7366#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Ceiling,\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Down,\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Up,\n        \"-1.0471975511965979\",\n        \"-0x1.0c152382d7366#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Nearest,\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Floor,\n        \"-1.0471975511965979\",\n        \"-0x1.0c152382d7366#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Ceiling,\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Down,\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Up,\n        \"-1.0471975511965979\",\n        \"-0x1.0c152382d7366#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Nearest,\n        \"-1.0471975511965976\",\n        \"-0x1.0c152382d7365#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Floor,\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Ceiling,\n        \"1.0471975511965979\",\n        \"0x1.0c152382d7366#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Down,\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Up,\n        \"1.0471975511965979\",\n        \"0x1.0c152382d7366#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Nearest,\n        \"1.0471975511965976\",\n        \"0x1.0c152382d7365#53\",\n        Less,\n    );\n}\n\n#[test]\nfn mul_rational_round_fail() {\n    const THREE_F: Float = Float::const_from_unsigned(3);\n    const THREE_Q: Rational = Rational::const_from_unsigned(3);\n    assert_panic!(THREE_F.mul_rational_round(THREE_Q, Exact));\n    assert_panic!(THREE_F.mul_rational_round_val_ref(&THREE_Q, Exact));\n    assert_panic!(THREE_F.mul_rational_round_ref_val(THREE_Q, Exact));\n    assert_panic!(THREE_F.mul_rational_round_ref_ref(&THREE_Q, Exact));\n    assert_panic!({\n        let mut x = THREE_F;\n        x.mul_rational_round_assign(THREE_Q, Exact)\n    });\n    assert_panic!({\n        let mut x = THREE_F;\n        x.mul_rational_round_assign_ref(&THREE_Q, Exact)\n    });\n}\n\n#[test]\nfn test_mul_rational_prec_round() {\n    let test = |s, s_hex, t, prec, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (product, o) = x.clone().mul_rational_prec_round(y.clone(), prec, rm);\n        assert!(product.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(product.to_string(), out);\n        assert_eq!(to_hex_string(&product), out_hex);\n\n        let (product_alt, o_alt) = x.clone().mul_rational_prec_round_val_ref(&y, prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = x.mul_rational_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = x.mul_rational_prec_round_ref_ref(&y, prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_rational_prec_round_assign(y.clone(), prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let mut product_alt = x.clone();\n        let o_alt = product_alt.mul_rational_prec_round_assign_ref(&y, prec, rm);\n        assert!(product_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&product),\n            ComparableFloatRef(&product_alt)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_naive_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_naive_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_naive_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        if x.is_normal() {\n            let (product_alt, o_alt) =\n                mul_rational_prec_round_direct(x.clone(), y.clone(), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&product_alt),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(o_alt, o);\n\n            let (product_alt, o_alt) =\n                mul_rational_prec_round_direct_val_ref(x.clone(), &y, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&product_alt),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(o_alt, o);\n\n            let (product_alt, o_alt) =\n                mul_rational_prec_round_direct_ref_val(&x, y.clone(), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&product_alt),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(o_alt, o);\n\n            let (product_alt, o_alt) = mul_rational_prec_round_direct_ref_ref(&x, &y, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&product_alt),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(o_alt, o);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_product, rug_o) = rug_mul_rational_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_product)),\n                ComparableFloatRef(&product)\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"123\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"123\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"123\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"123\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", \"0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", \"0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", \"0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"-Infinity\", \"-Infinity\", \"0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", \"0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"-Infinity\", \"-Infinity\", \"0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"123\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"123\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"1/3\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"1\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", \"0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"0\",\n        1,\n        Exact,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Floor, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Down, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Up, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"2\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"2\", 10, Exact, \"2.0\", \"0x2.00#10\", Equal);\n\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#2\", \"2\", 10, Floor, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.0#2\", \"2\", 10, Down, \"2.0\", \"0x2.00#10\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"2\", 10, Up, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"2\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.0#2\", \"2\", 10, Exact, \"2.0\", \"0x2.00#10\", Equal);\n\n    test(\"1.0\", \"0x1.000#10\", \"2\", 1, Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.000#10\", \"2\", 1, Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"2\", 1, Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.000#10\", \"2\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2\",\n        10,\n        Ceiling,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.000#10\", \"2\", 10, Up, \"2.0\", \"0x2.00#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"2\",\n        10,\n        Exact,\n        \"2.0\",\n        \"0x2.00#10\",\n        Equal,\n    );\n\n    test(\"1.0\", \"0x1.000#10\", \"1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\"1.0\", \"0x1.000#10\", \"1/3\", 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"1.0\", \"0x1.000#10\", \"1/3\", 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        1,\n        Nearest,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        10,\n        Floor,\n        \"0.333\",\n        \"0x0.554#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        10,\n        Down,\n        \"0.333\",\n        \"0x0.554#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        10,\n        Up,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Floor,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Down,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Up,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Nearest,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Floor,\n        \"0.333\",\n        \"0x0.554#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Down,\n        \"0.333\",\n        \"0x0.554#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Up,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Floor, \"4.0\", \"0x4.0#1\", Less);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Ceiling, \"8.0\", \"0x8.0#1\", Greater);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Down, \"4.0\", \"0x4.0#1\", Less);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Up, \"8.0\", \"0x8.0#1\", Greater);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 1, Nearest, \"8.0\", \"0x8.0#1\", Greater);\n\n    test(\"3.0\", \"0x3.0#2\", \"2\", 10, Floor, \"6.0\", \"0x6.00#10\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.0#2\",\n        \"2\",\n        10,\n        Ceiling,\n        \"6.0\",\n        \"0x6.00#10\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.0#2\", \"2\", 10, Down, \"6.0\", \"0x6.00#10\", Equal);\n    test(\"3.0\", \"0x3.0#2\", \"2\", 10, Up, \"6.0\", \"0x6.00#10\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.0#2\",\n        \"2\",\n        10,\n        Nearest,\n        \"6.0\",\n        \"0x6.00#10\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.0#2\", \"2\", 10, Exact, \"6.0\", \"0x6.00#10\", Equal);\n\n    test(\"3.0\", \"0x3.00#10\", \"2\", 1, Floor, \"4.0\", \"0x4.0#1\", Less);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"2\",\n        1,\n        Ceiling,\n        \"8.0\",\n        \"0x8.0#1\",\n        Greater,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"2\", 1, Down, \"4.0\", \"0x4.0#1\", Less);\n    test(\"3.0\", \"0x3.00#10\", \"2\", 1, Up, \"8.0\", \"0x8.0#1\", Greater);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"2\",\n        1,\n        Nearest,\n        \"8.0\",\n        \"0x8.0#1\",\n        Greater,\n    );\n\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"2\",\n        10,\n        Floor,\n        \"6.0\",\n        \"0x6.00#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"2\",\n        10,\n        Ceiling,\n        \"6.0\",\n        \"0x6.00#10\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"2\", 10, Down, \"6.0\", \"0x6.00#10\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"2\", 10, Up, \"6.0\", \"0x6.00#10\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"2\",\n        10,\n        Nearest,\n        \"6.0\",\n        \"0x6.00#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"2\",\n        10,\n        Exact,\n        \"6.0\",\n        \"0x6.00#10\",\n        Equal,\n    );\n\n    test(\"3.0\", \"0x3.00#10\", \"1/3\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"1/3\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"3.0\", \"0x3.00#10\", \"1/3\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\"3.0\", \"0x3.00#10\", \"1/3\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        10,\n        Up,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.00#10\",\n        \"1/3\",\n        10,\n        Exact,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        1,\n        Exact,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Up,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"3.0\",\n        \"0x3.0000000000000000000000000#100\",\n        \"1/3\",\n        10,\n        Exact,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Floor,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"1.049\",\n        \"0x1.0c8#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Down,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Up,\n        \"1.049\",\n        \"0x1.0c8#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Floor,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Ceiling,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Down,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Up,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Nearest,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Floor,\n        \"-1.049\",\n        \"-0x1.0c8#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Ceiling,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Down,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Up,\n        \"-1.049\",\n        \"-0x1.0c8#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Nearest,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Floor,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Ceiling,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Down,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Up,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        1,\n        Nearest,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Floor,\n        \"-1.049\",\n        \"-0x1.0c8#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Down,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Up,\n        \"-1.049\",\n        \"-0x1.0c8#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"-1.047\",\n        \"-0x1.0c0#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Floor,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Ceiling,\n        \"1.049\",\n        \"0x1.0c8#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Down,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Up,\n        \"1.049\",\n        \"0x1.0c8#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Nearest,\n        \"1.047\",\n        \"0x1.0c0#10\",\n        Less,\n    );\n}\n\n#[test]\nfn mul_rational_prec_round_fail() {\n    assert_panic!(Float::one_prec(1).mul_rational_prec_round(Rational::ONE, 0, Exact));\n    assert_panic!(Float::one_prec(1).mul_rational_prec_round(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).mul_rational_prec_round_val_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).mul_rational_prec_round_ref_val(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).mul_rational_prec_round_ref_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.mul_rational_prec_round_assign(Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.mul_rational_prec_round_assign_ref(&Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn mul_prec_round_properties_helper(\n    x: Float,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (product, o) = x.clone().mul_prec_round(y.clone(), prec, rm);\n    assert!(product.is_valid());\n    let (product_alt, o_alt) = x.clone().mul_prec_round_val_ref(&y, prec, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_prec_round_ref_ref(&y, prec, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (product_alt, o_alt) = mul_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_product, rug_o) = rug_mul_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_product)),\n            ComparableFloatRef(&product),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(\n            ComparableFloatRef(\n                &product\n                    .div_prec_round_ref_ref(&x, y.significant_bits(), Exact)\n                    .0\n            ),\n            ComparableFloatRef(&y)\n        );\n        assert_eq!(\n            ComparableFloatRef(\n                &product\n                    .div_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n            ),\n            ComparableFloatRef(&x)\n        );\n    }\n\n    if product.is_finite() {\n        if product.is_normal() {\n            assert_eq!(product.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * Rational::exact_from(&y);\n            assert_eq!(product.partial_cmp(&r_product), Some(o));\n            if o == Less {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if o == Greater {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n            match (r_product >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (product_alt, o_alt) = y.mul_prec_round_ref_ref(&x, prec, rm);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut product_alt, mut o_alt) = x.mul_prec_round_ref_val(-&y, prec, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut product_alt, mut o_alt) = (-&x).mul_prec_round_val_ref(&y, prec, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (product_alt, o_alt) = (-&x).mul_prec_round(-&y, prec, rm);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.mul_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(product.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.mul_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn mul_prec_round_properties() {\n    float_float_unsigned_rounding_mode_quadruple_gen_var_3().test_properties(|(x, y, prec, rm)| {\n        mul_prec_round_properties_helper(x, y, prec, rm, false);\n    });\n\n    float_float_unsigned_rounding_mode_quadruple_gen_var_7().test_properties(|(x, y, prec, rm)| {\n        mul_prec_round_properties_helper(x, y, prec, rm, true);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (product, o) = x.mul_prec_round_ref_val(Float::NAN, prec, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        let (product, o) = Float::NAN.mul_prec_round_val_ref(&x, prec, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != 0 {\n                assert_eq!(\n                    x.mul_prec_round_ref_val(Float::INFINITY, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::INFINITY.mul_prec_round_val_ref(&x, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.mul_prec_round_ref_val(Float::NEGATIVE_INFINITY, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.mul_prec_round_val_ref(&x, prec, rm),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n            }\n            if x.is_finite() {\n                assert_eq!(\n                    x.mul_prec_round_ref_val(Float::ZERO, prec, rm),\n                    (Float::ZERO, Equal)\n                );\n                assert_eq!(\n                    Float::ZERO.mul_prec_round_val_ref(&x, prec, rm),\n                    (Float::ZERO, Equal)\n                );\n                assert_eq!(\n                    x.mul_prec_round_ref_val(Float::NEGATIVE_ZERO, prec, rm),\n                    (Float::ZERO, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_ZERO.mul_prec_round_val_ref(&x, prec, rm),\n                    (Float::ZERO, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (product, o) = x.mul_prec_round_ref_val(Float::ONE, prec, rm);\n            let mut product_alt = x.clone();\n            let o_alt = product_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n            assert_eq!(o, o_alt);\n\n            let (product, o) = Float::ONE.mul_prec_round_val_ref(&x, prec, rm);\n            let mut product_alt = x.clone();\n            let o_alt = product_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n}\n\nfn mul_prec_properties_helper(x: Float, y: Float, prec: u64, extreme: bool) {\n    let (product, o) = x.clone().mul_prec(y.clone(), prec);\n    assert!(product.is_valid());\n    let (product_alt, o_alt) = x.clone().mul_prec_val_ref(&y, prec);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_prec_ref_val(y.clone(), prec);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_prec_ref_ref(&y, prec);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (product_alt, o_alt) = mul_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_product, rug_o) = rug_mul_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Float::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_product)),\n        ComparableFloatRef(&product),\n    );\n    assert_eq!(rug_o, o);\n\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(\n            ComparableFloatRef(&product.div_prec_ref_ref(&x, y.significant_bits()).0),\n            ComparableFloatRef(&y)\n        );\n        assert_eq!(\n            ComparableFloatRef(&product.div_prec_ref_ref(&y, x.significant_bits()).0),\n            ComparableFloatRef(&x)\n        );\n    }\n\n    let (product_alt, o_alt) = x.mul_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    if product.is_finite() {\n        if product.is_normal() {\n            assert_eq!(product.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * Rational::exact_from(&y);\n            assert_eq!(product.partial_cmp(&r_product), Some(o));\n            if o == Less {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if o == Greater {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n        }\n    }\n\n    let (product_alt, o_alt) = y.mul_prec_ref_ref(&x, prec);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    if (x != 0u32 && y != 0u32) || (x.is_sign_positive() && y.is_sign_positive()) {\n        let (mut product_alt, mut o_alt) = x.mul_prec_ref_val(-&y, prec);\n        product_alt.neg_assign();\n        product_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloat(product_alt),\n            ComparableFloat(product.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (mut product_alt, mut o_alt) = (-&x).mul_prec_val_ref(&y, prec);\n        product_alt.neg_assign();\n        product_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloat(product_alt),\n            ComparableFloat(product.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = (-x).mul_prec(-y, prec);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn mul_prec_properties() {\n    float_float_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        mul_prec_properties_helper(x, y, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_float_unsigned_triple_gen_var_1().test_properties_with_config(&config, |(x, y, prec)| {\n        mul_prec_properties_helper(x, y, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"small_n\", 16 << Limb::LOG_WIDTH);\n    float_float_unsigned_triple_gen_var_1().test_properties_with_config(&config, |(x, y, prec)| {\n        mul_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_float_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        mul_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        let (product, o) = x.mul_prec_ref_val(Float::NAN, prec);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        let (product, o) = Float::NAN.mul_prec_val_ref(&x, prec);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != 0 {\n                assert_eq!(\n                    x.mul_prec_ref_val(Float::INFINITY, prec),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::INFINITY.mul_prec_val_ref(&x, prec),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.mul_prec_ref_val(Float::NEGATIVE_INFINITY, prec),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.mul_prec_val_ref(&x, prec),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n            }\n            if x.is_finite() {\n                assert_eq!(x.mul_prec_ref_val(Float::ZERO, prec), (Float::ZERO, Equal));\n                assert_eq!(Float::ZERO.mul_prec_val_ref(&x, prec), (Float::ZERO, Equal));\n                assert_eq!(\n                    x.mul_prec_ref_val(Float::NEGATIVE_ZERO, prec),\n                    (Float::ZERO, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_ZERO.mul_prec_val_ref(&x, prec),\n                    (Float::ZERO, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (product, o) = x.mul_prec_ref_val(Float::ONE, prec);\n            let mut product_alt = x.clone();\n            let o_alt = product_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n            assert_eq!(o, o_alt);\n\n            let (product, o) = Float::ONE.mul_prec_val_ref(&x, prec);\n            let mut product_alt = x.clone();\n            let o_alt = product_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn mul_round_properties_helper(x: Float, y: Float, rm: RoundingMode, extreme: bool) {\n    let (product, o) = x.clone().mul_round(y.clone(), rm);\n    assert!(product.is_valid());\n    let (product_alt, o_alt) = x.clone().mul_round_val_ref(&y, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let (product_alt, o_alt) = x.mul_round_ref_val(y.clone(), rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let (product_alt, o_alt) = x.mul_round_ref_ref(&y, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (product_alt, o_alt) = mul_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) =\n        x.mul_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), rm);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(product.div_round_ref_ref(&x, Exact).0, y);\n        assert_eq!(product.div_round_ref_ref(&y, Exact).0, x);\n    }\n\n    if product.is_finite() {\n        if x.is_normal() && y.is_normal() && product.is_normal() {\n            assert_eq!(\n                product.get_prec(),\n                Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n            );\n        }\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * Rational::exact_from(&y);\n            assert_eq!(product.partial_cmp(&r_product), Some(o));\n            if o == Less {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if o == Greater {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n            match (r_product >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_product, rug_o) =\n            rug_mul_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_product)),\n            ComparableFloatRef(&product),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (product_alt, o_alt) = y.mul_round_ref_ref(&x, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    let (mut product_alt, mut o_alt) = x.mul_round_ref_val(-&y, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n\n    let (mut product_alt, mut o_alt) = (-&x).mul_round_val_ref(&y, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n\n    let (product_alt, o_alt) = (-&x).mul_round(-&y, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.mul_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(product.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.mul_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn mul_round_properties() {\n    float_float_rounding_mode_triple_gen_var_16().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_17().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_18().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_19().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_20().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_21().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_22().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_31().test_properties(|(x, y, rm)| {\n        mul_round_properties_helper(x, y, rm, true);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let (product, o) = x.mul_round_ref_val(Float::NAN, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        let (product, o) = Float::NAN.mul_round_val_ref(&x, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != 0 {\n                assert_eq!(\n                    x.mul_round_ref_val(Float::INFINITY, rm),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::INFINITY.mul_round_val_ref(&x, rm),\n                    (\n                        if x > 0 {\n                            Float::INFINITY\n                        } else {\n                            Float::NEGATIVE_INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    x.mul_round_ref_val(Float::NEGATIVE_INFINITY, rm),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.mul_round_val_ref(&x, rm),\n                    (\n                        if x > 0 {\n                            Float::NEGATIVE_INFINITY\n                        } else {\n                            Float::INFINITY\n                        },\n                        Equal\n                    )\n                );\n            }\n            if x.is_finite() {\n                assert_eq!(x.mul_round_ref_val(Float::ZERO, rm), (Float::ZERO, Equal));\n                assert_eq!(Float::ZERO.mul_round_val_ref(&x, rm), (Float::ZERO, Equal));\n                assert_eq!(\n                    x.mul_round_ref_val(Float::NEGATIVE_ZERO, rm),\n                    (Float::ZERO, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_ZERO.mul_round_val_ref(&x, rm),\n                    (Float::ZERO, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (product, o) = x.mul_round_ref_val(Float::ONE, rm);\n            assert_eq!(ComparableFloatRef(&product), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n\n            let (product, o) = Float::ONE.mul_round_val_ref(&x, rm);\n            assert_eq!(ComparableFloatRef(&product), ComparableFloatRef(&x));\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn mul_properties_helper_1(x: Float, y: Float, extreme: bool) {\n    let product = x.clone() * y.clone();\n    assert!(product.is_valid());\n    let product_alt = x.clone() * &y;\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = &x * y.clone();\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = &x * &y;\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    let mut x_alt = x.clone();\n    x_alt *= y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n\n    let mut x_alt = x.clone();\n    x_alt *= &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n\n    if !extreme {\n        let product_alt = mul_prec_round_naive(\n            x.clone(),\n            y.clone(),\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n    }\n\n    let product_alt = x\n        .mul_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), Nearest)\n        .0;\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = x\n        .mul_prec_ref_ref(&y, max(x.significant_bits(), y.significant_bits()))\n        .0;\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let (product_alt, o) = x.mul_round_ref_ref(&y, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(&product / &x, y);\n        assert_eq!(&product / &y, x);\n    }\n\n    if product.is_finite() && x.is_normal() && y.is_normal() && product.is_normal() {\n        assert_eq!(\n            product.get_prec(),\n            Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n        );\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * Rational::exact_from(&y);\n            if product < r_product {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if product > r_product {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n        }\n    }\n\n    let rug_product = rug_mul(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_product)),\n        ComparableFloatRef(&product),\n    );\n\n    let product_alt = &y * &x;\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    if (x != 0u32 && y != 0u32) || (x.is_sign_positive() && y.is_sign_positive()) {\n        assert_eq!(ComparableFloatRef(&(&y * &x)), ComparableFloatRef(&product));\n        assert_eq!(\n            ComparableFloatRef(&-(&x * -&y)),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(\n            ComparableFloatRef(&-(-&x * &y)),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(\n            ComparableFloatRef(&(-&x * -&y)),\n            ComparableFloatRef(&product)\n        );\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn mul_properties_helper_2<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let product_1 = x * y;\n        let product_2 = emulate_float_float_to_float_fn(Float::mul_prec, x, y);\n        assert_eq!(NiceFloat(product_1), NiceFloat(product_2));\n    });\n}\n\n#[test]\nfn mul_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_pair_gen().test_properties_with_config(&config, |(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_2().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_3().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_4().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_5().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_6().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_7().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, false);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        mul_properties_helper_1(x, y, true);\n    });\n\n    apply_fn_to_primitive_floats!(mul_properties_helper_2);\n\n    float_gen().test_properties(|x| {\n        assert!((&x * Float::NAN).is_nan());\n        assert!((Float::NAN * &x).is_nan());\n        if !x.is_nan() {\n            if x != 0 {\n                assert_eq!(\n                    &x * Float::INFINITY,\n                    if x > 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    }\n                );\n                assert_eq!(\n                    Float::INFINITY * &x,\n                    if x > 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    }\n                );\n                assert_eq!(\n                    &x * Float::NEGATIVE_INFINITY,\n                    if x > 0 {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    }\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY * &x,\n                    if x > 0 {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    }\n                );\n            }\n            if x.is_finite() {\n                assert_eq!(&x * Float::ZERO, Float::ZERO);\n                assert_eq!(Float::ZERO * &x, Float::ZERO);\n                assert_eq!(&x * Float::NEGATIVE_ZERO, Float::ZERO);\n                assert_eq!(Float::NEGATIVE_ZERO * &x, Float::ZERO);\n            }\n            assert_eq!(&x * Float::ONE, x);\n            assert_eq!(Float::ONE * &x, x);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn mul_rational_prec_round_properties_helper(\n    x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (product, o) = x.clone().mul_rational_prec_round(y.clone(), prec, rm);\n    assert!(product.is_valid());\n    let (product_alt, o_alt) = x.clone().mul_rational_prec_round_val_ref(&y, prec, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_rational_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_rational_prec_round_ref_ref(&y, prec, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_rational_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_rational_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (product_alt, o_alt) = mul_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_naive_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_naive_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_naive_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if x.is_normal() {\n        let (product_alt, o_alt) = mul_rational_prec_round_direct(x.clone(), y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_direct_val_ref(x.clone(), &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_direct_ref_val(&x, y.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = mul_rational_prec_round_direct_ref_ref(&x, &y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_product, rug_o) = rug_mul_rational_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_product)),\n            ComparableFloatRef(&product),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(\n            ComparableFloatRef(\n                &product\n                    .div_rational_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n            ),\n            ComparableFloatRef(&x)\n        );\n        // TODO additional test\n    }\n\n    if product.is_finite() {\n        if product.is_normal() {\n            assert_eq!(product.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * &y;\n            assert_eq!(product.partial_cmp(&r_product), Some(o));\n            if o == Less {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if o == Greater {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n            match (r_product >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (mut product_alt, mut o_alt) = x.mul_rational_prec_round_ref_val(-&y, prec, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut product_alt, mut o_alt) = (-&x).mul_rational_prec_round_val_ref(&y, prec, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if product != 0u32 {\n        let (product_alt, o_alt) = (-&x).mul_rational_prec_round(-&y, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.mul_rational_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(product.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.mul_rational_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn mul_rational_prec_round_properties() {\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_3().test_properties(\n        |(x, y, prec, rm)| {\n            mul_rational_prec_round_properties_helper(x, y, prec, rm, false);\n        },\n    );\n\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_8().test_properties(\n        |(x, y, prec, rm)| {\n            mul_rational_prec_round_properties_helper(x, y, prec, rm, true);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        if !x.is_negative_zero() {\n            let (product, o) = x.mul_rational_prec_round_ref_val(Rational::ONE, prec, rm);\n            let mut product_alt = x.clone();\n            let o_alt = product_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n\n    rational_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (product, o) = Float::NAN.mul_rational_prec_round_val_ref(&x, prec, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        if x != 0 {\n            assert_eq!(\n                Float::INFINITY.mul_rational_prec_round_val_ref(&x, prec, rm),\n                (\n                    if x > 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    },\n                    Equal\n                )\n            );\n            assert_eq!(\n                Float::NEGATIVE_INFINITY.mul_rational_prec_round_val_ref(&x, prec, rm),\n                (\n                    if x > 0 {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    },\n                    Equal\n                )\n            );\n        }\n\n        let (product, o) = Float::ZERO.mul_rational_prec_round_val_ref(&x, prec, rm);\n        assert_eq!(\n            ComparableFloat(product),\n            ComparableFloat(if x >= 0 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            })\n        );\n        assert_eq!(o, Equal);\n\n        let (product, o) = Float::NEGATIVE_ZERO.mul_rational_prec_round_val_ref(&x, prec, rm);\n        assert_eq!(\n            ComparableFloat(product),\n            ComparableFloat(if x >= 0 {\n                Float::NEGATIVE_ZERO\n            } else {\n                Float::ZERO\n            })\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\nfn mul_rational_prec_properties_helper(x: Float, y: Rational, prec: u64, extreme: bool) {\n    let (product, o) = x.clone().mul_rational_prec(y.clone(), prec);\n    assert!(product.is_valid());\n    let (product_alt, o_alt) = x.clone().mul_rational_prec_val_ref(&y, prec);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_rational_prec_ref_val(y.clone(), prec);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    let (product_alt, o_alt) = x.mul_rational_prec_ref_ref(&y, prec);\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_rational_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_rational_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (product_alt, o_alt) =\n            mul_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if x.is_normal() {\n        let (product_alt, o_alt) =\n            mul_rational_prec_round_direct(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_product, rug_o) = rug_mul_rational_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Rational::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_product)),\n        ComparableFloatRef(&product),\n    );\n    assert_eq!(rug_o, o);\n\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(\n            ComparableFloatRef(\n                &product\n                    .div_rational_prec_ref_ref(&y, x.significant_bits())\n                    .0\n            ),\n            ComparableFloatRef(&x)\n        );\n        // TODO additional test\n    }\n\n    let (product_alt, o_alt) = x.mul_rational_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n\n    if product.is_finite() {\n        if product.is_normal() {\n            assert_eq!(product.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * &y;\n            assert_eq!(product.partial_cmp(&r_product), Some(o));\n            if o == Less {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if o == Greater {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n        }\n    }\n\n    if x != 0u32 && y != 0u32 {\n        let (mut product_alt, mut o_alt) = x.mul_rational_prec_ref_val(-&y, prec);\n        product_alt.neg_assign();\n        product_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (mut product_alt, mut o_alt) = (-&x).mul_rational_prec_val_ref(&y, prec);\n        product_alt.neg_assign();\n        product_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (product_alt, o_alt) = (-x).mul_rational_prec(-y, prec);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn mul_rational_prec_properties() {\n    float_rational_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        mul_rational_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_rational_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        mul_rational_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        if !x.is_negative_zero() {\n            let (product, o) = x.mul_rational_prec_ref_val(Rational::ONE, prec);\n            let mut product_alt = x.clone();\n            let o_alt = product_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n            assert_eq!(o, o_alt);\n        }\n\n        if x.is_finite() && !x.is_negative_zero() {\n            let (product, o) = x.mul_rational_prec_ref_val(Rational::ZERO, prec);\n            assert_eq!(\n                ComparableFloat(product),\n                ComparableFloat(if x >= 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let (product, o) = Float::NAN.mul_rational_prec_val_ref(&x, prec);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        if x != 0 {\n            assert_eq!(\n                Float::INFINITY.mul_rational_prec_val_ref(&x, prec),\n                (\n                    if x >= 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    },\n                    Equal\n                )\n            );\n            assert_eq!(\n                Float::NEGATIVE_INFINITY.mul_rational_prec_val_ref(&x, prec),\n                (\n                    if x >= 0 {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    },\n                    Equal\n                )\n            );\n        }\n\n        let (product, o) = Float::ONE.mul_rational_prec_val_ref(&x, prec);\n        let (product_alt, o_alt) = Float::from_rational_prec_ref(&x, prec);\n        assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n        assert_eq!(o, o_alt);\n\n        let (product, o) = Float::ZERO.mul_rational_prec_val_ref(&x, prec);\n        assert_eq!(\n            ComparableFloat(product),\n            ComparableFloat(if x >= 0 {\n                Float::ZERO\n            } else {\n                Float::NEGATIVE_ZERO\n            })\n        );\n        assert_eq!(o, Equal);\n\n        let (product, o) = Float::NEGATIVE_ZERO.mul_rational_prec_val_ref(&x, prec);\n        assert_eq!(\n            ComparableFloat(product),\n            ComparableFloat(if x >= 0 {\n                Float::NEGATIVE_ZERO\n            } else {\n                Float::ZERO\n            })\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn mul_rational_round_properties_helper(x: Float, y: Rational, rm: RoundingMode, extreme: bool) {\n    let (product, o) = x.clone().mul_rational_round(y.clone(), rm);\n    assert!(product.is_valid());\n    let (product_alt, o_alt) = x.clone().mul_rational_round_val_ref(&y, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let (product_alt, o_alt) = x.mul_rational_round_ref_val(y.clone(), rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let (product_alt, o_alt) = x.mul_rational_round_ref_ref(&y, rm);\n    assert!(product_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_rational_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.mul_rational_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (product_alt, o_alt) =\n            mul_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if x.is_normal() {\n        let (product_alt, o_alt) =\n            mul_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    let (product_alt, o_alt) = x.mul_rational_prec_round_ref_ref(&y, x.significant_bits(), rm);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    assert_eq!(o_alt, o);\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(product.div_rational_round_ref_ref(&y, Exact).0, x);\n        // TODO additional test\n    }\n\n    if product.is_finite() {\n        if x.is_normal() && product.is_normal() {\n            assert_eq!(product.get_prec(), Some(x.get_prec().unwrap()));\n        }\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * &y;\n            assert_eq!(product.partial_cmp(&r_product), Some(o));\n            if o == Less {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if o == Greater {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n            match (r_product >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_product, rug_o) = rug_mul_rational_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_product)),\n            ComparableFloatRef(&product),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (mut product_alt, mut o_alt) = x.mul_rational_round_ref_val(-&y, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero_ref()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n\n    let (mut product_alt, mut o_alt) = (-&x).mul_rational_round_val_ref(&y, -rm);\n    product_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(product_alt.abs_negative_zero_ref()),\n        ComparableFloat(product.abs_negative_zero_ref())\n    );\n\n    if x != 0 && y != 0 {\n        let (product_alt, o_alt) = (-&x).mul_rational_round(-&y, rm);\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product),\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.mul_rational_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(product.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.mul_rational_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn mul_rational_round_properties() {\n    float_rational_rounding_mode_triple_gen_var_4().test_properties(|(x, y, rm)| {\n        mul_rational_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rational_rounding_mode_triple_gen_var_9().test_properties(|(x, y, rm)| {\n        mul_rational_round_properties_helper(x, y, rm, true);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let (product, o) = x.mul_rational_round_ref_val(Rational::ONE, rm);\n        assert_eq!(ComparableFloatRef(&product), ComparableFloatRef(&x));\n        assert_eq!(o, Equal);\n\n        if x.is_finite() && !x.is_negative_zero() {\n            let (product, o) = x.mul_rational_round_ref_val(Rational::ZERO, rm);\n            assert_eq!(\n                ComparableFloat(product),\n                ComparableFloat(if x >= 0 {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_rounding_mode_pair_gen_var_6().test_properties(|(x, rm)| {\n        let (product, o) = Float::NAN.mul_rational_round_val_ref(&x, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        if x != 0 {\n            assert_eq!(\n                Float::INFINITY.mul_rational_round_val_ref(&x, rm),\n                (\n                    if x >= 0 {\n                        Float::INFINITY\n                    } else {\n                        Float::NEGATIVE_INFINITY\n                    },\n                    Equal\n                )\n            );\n            assert_eq!(\n                Float::NEGATIVE_INFINITY.mul_rational_round_val_ref(&x, rm),\n                (\n                    if x >= 0 {\n                        Float::NEGATIVE_INFINITY\n                    } else {\n                        Float::INFINITY\n                    },\n                    Equal\n                )\n            );\n        }\n        let (product, o) = Float::ONE.mul_rational_round_val_ref(&x, rm);\n        let (product_alt, o_alt) = Float::from_rational_prec_round_ref(&x, 1, rm);\n        assert_eq!(ComparableFloat(product), ComparableFloat(product_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\nfn mul_rational_properties_helper(x: Float, y: Rational, extreme: bool) {\n    let product = x.clone() * y.clone();\n    assert!(product.is_valid());\n    let product_alt = x.clone() * &y;\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = &x * y.clone();\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = &x * &y;\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    let product_alt = y.clone() * x.clone();\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = y.clone() * &x;\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = &y * x.clone();\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = &y * &x;\n    assert!(product_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    let mut x_alt = x.clone();\n    x_alt *= y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n\n    let mut x_alt = x.clone();\n    x_alt *= &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&product));\n\n    if !extreme {\n        let product_alt =\n            mul_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n    }\n\n    if x.is_normal() {\n        let product_alt =\n            mul_rational_prec_round_direct(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&product_alt),\n            ComparableFloatRef(&product)\n        );\n    }\n\n    let product_alt = x\n        .mul_rational_prec_round_ref_ref(&y, x.significant_bits(), Nearest)\n        .0;\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let product_alt = x.mul_rational_prec_ref_ref(&y, x.significant_bits()).0;\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n    let (product_alt, o) = x.mul_rational_round_ref_ref(&y, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&product_alt),\n        ComparableFloatRef(&product)\n    );\n\n    if o == Equal && product.is_finite() && product != 0 {\n        assert_eq!(&product / &y, x);\n        // TODO additional test\n    }\n\n    if product.is_finite() && x.is_normal() && product.is_normal() {\n        assert_eq!(product.get_prec(), Some(x.get_prec().unwrap()));\n        if !extreme {\n            let r_product = Rational::exact_from(&x) * &y;\n            if product < r_product {\n                let mut next = product.clone();\n                next.increment();\n                assert!(next > r_product);\n            } else if product > r_product {\n                let mut next = product.clone();\n                next.decrement();\n                assert!(next < r_product);\n            }\n        }\n    }\n\n    let rug_product = rug_mul_rational(&rug::Float::exact_from(&x), &rug::Rational::from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_product)),\n        ComparableFloatRef(&product),\n    );\n\n    if product != 0u32 {\n        assert_eq!(\n            ComparableFloatRef(&-(-&x * &y)),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(\n            ComparableFloatRef(&-(&x * -&y)),\n            ComparableFloatRef(&product)\n        );\n        assert_eq!(ComparableFloatRef(&(-x * -y)), ComparableFloatRef(&product));\n    }\n}\n\n#[test]\nfn mul_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        mul_rational_properties_helper(x, y, false);\n    });\n\n    float_rational_pair_gen_var_2().test_properties(|(x, y)| {\n        mul_rational_properties_helper(x, y, true);\n    });\n\n    float_gen().test_properties(|x| {\n        assert_eq!(\n            ComparableFloatRef(&(&x * Rational::ONE)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(\n            ComparableFloatRef(&(Rational::ONE * &x)),\n            ComparableFloatRef(&x)\n        );\n        if x.is_finite() {\n            assert_eq!(\n                ComparableFloat(&x * Rational::ZERO),\n                ComparableFloat(if x.is_sign_positive() {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                }),\n            );\n            assert_eq!(\n                ComparableFloat(Rational::ZERO * &x),\n                ComparableFloat(if x.is_sign_positive() {\n                    Float::ZERO\n                } else {\n                    Float::NEGATIVE_ZERO\n                })\n            );\n        }\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!((&x * Float::NAN).is_nan());\n        assert!((Float::NAN * &x).is_nan());\n        if x != 0 {\n            assert_eq!(\n                &x * Float::INFINITY,\n                if x > 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                }\n            );\n            assert_eq!(\n                Float::INFINITY * &x,\n                if x > 0 {\n                    Float::INFINITY\n                } else {\n                    Float::NEGATIVE_INFINITY\n                }\n            );\n            assert_eq!(\n                &x * Float::NEGATIVE_INFINITY,\n                if x > 0 {\n                    Float::NEGATIVE_INFINITY\n                } else {\n                    Float::INFINITY\n                }\n            );\n            assert_eq!(\n                Float::NEGATIVE_INFINITY * &x,\n                if x > 0 {\n                    Float::NEGATIVE_INFINITY\n                } else {\n                    Float::INFINITY\n                }\n            );\n        }\n        let product_alt = Float::from_rational_prec_ref(&x, 1).0;\n        assert_eq!(\n            ComparableFloat(&x * Float::ONE),\n            ComparableFloat(product_alt.clone())\n        );\n        assert_eq!(\n            ComparableFloat(Float::ONE * &x),\n            ComparableFloat(product_alt.clone())\n        );\n        assert_eq!(\n            ComparableFloat((&x * Float::ZERO).abs_negative_zero()),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(\n            ComparableFloat((Float::ZERO * &x).abs_negative_zero()),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(\n            ComparableFloat((&x * Float::NEGATIVE_ZERO).abs_negative_zero()),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(\n            ComparableFloat((Float::NEGATIVE_ZERO * &x).abs_negative_zero()),\n            ComparableFloat(Float::ZERO)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_4, float_gen_var_12};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\n\n#[test]\nfn test_neg() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let neg = -x.clone();\n        assert!(neg.is_valid());\n\n        assert_eq!(neg.to_string(), out);\n        assert_eq!(to_hex_string(&neg), out_hex);\n\n        let neg_alt = -&x;\n        assert!(neg_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&neg), ComparableFloatRef(&neg_alt));\n\n        let mut neg_alt = x.clone();\n        neg_alt.neg_assign();\n        assert!(neg_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&neg), ComparableFloatRef(&neg_alt));\n\n        assert_eq!(\n            ComparableFloat(Float::from(&-rug::Float::exact_from(&x))),\n            ComparableFloat(neg)\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"Infinity\", \"Infinity\");\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"1.0\", \"0x1.0#1\", \"-1.0\", \"-0x1.0#1\");\n    test(\"2.0\", \"0x2.0#1\", \"-2.0\", \"-0x2.0#1\");\n    test(\"0.5\", \"0x0.8#1\", \"-0.5\", \"-0x0.8#1\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"-2.0\", \"-0x2.0#1\", \"2.0\", \"0x2.0#1\");\n    test(\"-0.5\", \"-0x0.8#1\", \"0.5\", \"0x0.8#1\");\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n    );\n}\n\nfn neg_properties_helper(x: Float) {\n    let neg = -x.clone();\n    assert!(neg.is_valid());\n\n    let neg_alt = -&x;\n    assert!(neg_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&neg), ComparableFloatRef(&neg_alt));\n\n    let mut neg_alt = x.clone();\n    neg_alt.neg_assign();\n    assert!(neg_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&neg), ComparableFloatRef(&neg_alt));\n\n    assert_eq!(\n        ComparableFloatRef(&-Float::from(&rug::Float::exact_from(&x))),\n        ComparableFloatRef(&neg)\n    );\n    assert_eq!(\n        ComparableFloatRef(&neg) == ComparableFloatRef(&x),\n        x.is_nan()\n    );\n\n    assert_eq!(ComparableFloat(-neg), ComparableFloat(x));\n}\n\n#[test]\nfn neg_properties() {\n    float_gen().test_properties(|x| {\n        neg_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        neg_properties_helper(x);\n    });\n\n    float_gen_var_4().test_properties(|x| {\n        assert_eq!(Rational::exact_from(-&x), -Rational::exact_from(x));\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(\n            ComparableFloat(Float::from(-x)),\n            ComparableFloat(-Float::from(x))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, PowerOf2};\nuse malachite_base::num::basic::traits::Infinity;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, signed_unsigned_pair_gen_var_19, signed_unsigned_pair_gen_var_20,\n    unsigned_gen, unsigned_gen_var_5,\n};\nuse malachite_float::test_util::arithmetic::power_of_2::{\n    power_of_2_i64_naive, power_of_2_prec_naive, power_of_2_prec_round_naive, power_of_2_u64_naive,\n};\nuse malachite_float::test_util::arithmetic::shl_round::rug_shl_prec_round_signed;\nuse malachite_float::test_util::common::{rug_round_try_from_rounding_mode, to_hex_string};\nuse malachite_float::test_util::generators::{\n    signed_unsigned_rounding_mode_triple_gen_var_5, signed_unsigned_rounding_mode_triple_gen_var_6,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_power_of_2_prec_round() {\n    let test = |i: i64, prec: u64, rm: RoundingMode, out: &str, out_hex: &str, o_out| {\n        let (p, o) = Float::power_of_2_prec_round(i, prec, rm);\n        assert!(p.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(p.to_string(), out);\n        assert_eq!(to_hex_string(&p), out_hex);\n\n        let (p_alt, o_alt) = power_of_2_prec_round_naive(i, prec, rm);\n        assert_eq!(p_alt.to_string(), out);\n        assert_eq!(to_hex_string(&p_alt), out_hex);\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_p, o) = rug_shl_prec_round_signed(\n                &rug::Float::with_val(1, 1),\n                i32::exact_from(i),\n                prec,\n                rm,\n            );\n            let p = Float::exact_from(&rug_p);\n            assert_eq!(p.to_string(), out);\n            assert_eq!(to_hex_string(&p), out_hex);\n            assert_eq!(o, o_out);\n        }\n    };\n    test(0, 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(0, 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(0, 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(0, 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(0, 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(0, 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\n        0,\n        100,\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        0,\n        100,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        0,\n        100,\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        0,\n        100,\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        0,\n        100,\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        0,\n        100,\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(1, 1, Floor, \"2.0\", \"0x2.0#1\", Equal);\n    test(1, 1, Ceiling, \"2.0\", \"0x2.0#1\", Equal);\n    test(1, 1, Down, \"2.0\", \"0x2.0#1\", Equal);\n    test(1, 1, Up, \"2.0\", \"0x2.0#1\", Equal);\n    test(1, 1, Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    test(1, 1, Exact, \"2.0\", \"0x2.0#1\", Equal);\n\n    test(\n        1,\n        100,\n        Floor,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        1,\n        100,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        1,\n        100,\n        Down,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        1,\n        100,\n        Up,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        1,\n        100,\n        Nearest,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        1,\n        100,\n        Exact,\n        \"2.0\",\n        \"0x2.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(100, 1, Floor, \"1.0e30\", \"0x1.0E+25#1\", Equal);\n    test(100, 1, Ceiling, \"1.0e30\", \"0x1.0E+25#1\", Equal);\n    test(100, 1, Down, \"1.0e30\", \"0x1.0E+25#1\", Equal);\n    test(100, 1, Up, \"1.0e30\", \"0x1.0E+25#1\", Equal);\n    test(100, 1, Nearest, \"1.0e30\", \"0x1.0E+25#1\", Equal);\n    test(100, 1, Exact, \"1.0e30\", \"0x1.0E+25#1\", Equal);\n\n    test(\n        100,\n        100,\n        Floor,\n        \"1267650600228229401496703205376.0\",\n        \"0x10000000000000000000000000.0#100\",\n        Equal,\n    );\n    test(\n        100,\n        100,\n        Ceiling,\n        \"1267650600228229401496703205376.0\",\n        \"0x10000000000000000000000000.0#100\",\n        Equal,\n    );\n    test(\n        100,\n        100,\n        Down,\n        \"1267650600228229401496703205376.0\",\n        \"0x10000000000000000000000000.0#100\",\n        Equal,\n    );\n    test(\n        100,\n        100,\n        Up,\n        \"1267650600228229401496703205376.0\",\n        \"0x10000000000000000000000000.0#100\",\n        Equal,\n    );\n    test(\n        100,\n        100,\n        Nearest,\n        \"1267650600228229401496703205376.0\",\n        \"0x10000000000000000000000000.0#100\",\n        Equal,\n    );\n    test(\n        100,\n        100,\n        Exact,\n        \"1267650600228229401496703205376.0\",\n        \"0x10000000000000000000000000.0#100\",\n        Equal,\n    );\n\n    test(1073741822, 1, Floor, \"too_big\", \"0x4.0E+268435455#1\", Equal);\n    test(\n        1073741822,\n        1,\n        Ceiling,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test(1073741822, 1, Down, \"too_big\", \"0x4.0E+268435455#1\", Equal);\n    test(1073741822, 1, Up, \"too_big\", \"0x4.0E+268435455#1\", Equal);\n    test(\n        1073741822,\n        1,\n        Nearest,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test(1073741822, 1, Exact, \"too_big\", \"0x4.0E+268435455#1\", Equal);\n\n    test(\n        1073741822,\n        100,\n        Floor,\n        \"too_big\",\n        \"0x4.0000000000000000000000000E+268435455#100\",\n        Equal,\n    );\n    test(\n        1073741822,\n        100,\n        Ceiling,\n        \"too_big\",\n        \"0x4.0000000000000000000000000E+268435455#100\",\n        Equal,\n    );\n    test(\n        1073741822,\n        100,\n        Down,\n        \"too_big\",\n        \"0x4.0000000000000000000000000E+268435455#100\",\n        Equal,\n    );\n    test(\n        1073741822,\n        100,\n        Up,\n        \"too_big\",\n        \"0x4.0000000000000000000000000E+268435455#100\",\n        Equal,\n    );\n    test(\n        1073741822,\n        100,\n        Nearest,\n        \"too_big\",\n        \"0x4.0000000000000000000000000E+268435455#100\",\n        Equal,\n    );\n    test(\n        1073741822,\n        100,\n        Exact,\n        \"too_big\",\n        \"0x4.0000000000000000000000000E+268435455#100\",\n        Equal,\n    );\n\n    test(1073741823, 1, Floor, \"too_big\", \"0x4.0E+268435455#1\", Less);\n    test(1073741823, 1, Ceiling, \"Infinity\", \"Infinity\", Greater);\n    test(1073741823, 1, Down, \"too_big\", \"0x4.0E+268435455#1\", Less);\n    test(1073741823, 1, Up, \"Infinity\", \"Infinity\", Greater);\n    test(1073741823, 1, Nearest, \"Infinity\", \"Infinity\", Greater);\n\n    test(\n        1073741823,\n        100,\n        Floor,\n        \"too_big\",\n        \"0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        Less,\n    );\n    test(1073741823, 100, Ceiling, \"Infinity\", \"Infinity\", Greater);\n    test(\n        1073741823,\n        100,\n        Down,\n        \"too_big\",\n        \"0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        Less,\n    );\n    test(1073741823, 100, Up, \"Infinity\", \"Infinity\", Greater);\n    test(1073741823, 100, Nearest, \"Infinity\", \"Infinity\", Greater);\n\n    test(-1, 1, Floor, \"0.5\", \"0x0.8#1\", Equal);\n    test(-1, 1, Ceiling, \"0.5\", \"0x0.8#1\", Equal);\n    test(-1, 1, Down, \"0.5\", \"0x0.8#1\", Equal);\n    test(-1, 1, Up, \"0.5\", \"0x0.8#1\", Equal);\n    test(-1, 1, Nearest, \"0.5\", \"0x0.8#1\", Equal);\n    test(-1, 1, Exact, \"0.5\", \"0x0.8#1\", Equal);\n\n    test(\n        -1,\n        100,\n        Floor,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        -1,\n        100,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        -1,\n        100,\n        Down,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        -1,\n        100,\n        Up,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        -1,\n        100,\n        Nearest,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        -1,\n        100,\n        Exact,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(-100, 1, Floor, \"8.0e-31\", \"0x1.0E-25#1\", Equal);\n    test(-100, 1, Ceiling, \"8.0e-31\", \"0x1.0E-25#1\", Equal);\n    test(-100, 1, Down, \"8.0e-31\", \"0x1.0E-25#1\", Equal);\n    test(-100, 1, Up, \"8.0e-31\", \"0x1.0E-25#1\", Equal);\n    test(-100, 1, Nearest, \"8.0e-31\", \"0x1.0E-25#1\", Equal);\n    test(-100, 1, Exact, \"8.0e-31\", \"0x1.0E-25#1\", Equal);\n\n    test(\n        -1073741824,\n        1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test(-1073741824, 1, Up, \"too_small\", \"0x1.0E-268435456#1\", Equal);\n    test(\n        -1073741824,\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        1,\n        Exact,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test(\n        -1073741824,\n        100,\n        Floor,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        100,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        100,\n        Down,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        100,\n        Up,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        100,\n        Nearest,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Equal,\n    );\n    test(\n        -1073741824,\n        100,\n        Exact,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Equal,\n    );\n\n    test(-1073741825, 1, Floor, \"0.0\", \"0x0.0\", Less);\n    test(\n        -1073741825,\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(-1073741825, 1, Down, \"0.0\", \"0x0.0\", Less);\n    test(\n        -1073741825,\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(-1073741825, 1, Nearest, \"0.0\", \"0x0.0\", Less);\n\n    test(-1073741825, 100, Floor, \"0.0\", \"0x0.0\", Less);\n    test(\n        -1073741825,\n        100,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Greater,\n    );\n    test(-1073741825, 100, Down, \"0.0\", \"0x0.0\", Less);\n    test(\n        -1073741825,\n        100,\n        Up,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Greater,\n    );\n    test(-1073741825, 100, Nearest, \"0.0\", \"0x0.0\", Less);\n}\n\n#[test]\nfn power_of_2_prec_round_fail() {\n    assert_panic!(Float::power_of_2_prec_round(0, 0, Floor));\n    assert_panic!(Float::power_of_2_prec_round(1073741823, 1, Exact));\n    assert_panic!(Float::power_of_2_prec_round(1073741823, 100, Exact));\n    assert_panic!(Float::power_of_2_prec_round(-1073741825, 1, Exact));\n    assert_panic!(Float::power_of_2_prec_round(-1073741825, 100, Exact));\n}\n\nfn power_of_2_prec_round_properties_helper(i: i64, prec: u64, rm: RoundingMode) {\n    let (p, o) = Float::power_of_2_prec_round(i, prec, rm);\n    assert!(p.is_valid());\n    assert!(p.is_finite() || p == Float::INFINITY || p.is_positive_zero());\n    assert!(p >= 0u32);\n    if p.is_normal() {\n        assert_eq!(p.get_prec(), Some(prec));\n    } else {\n        assert_eq!(o, if p > 0 { Greater } else { Less });\n    }\n\n    if i.lt_abs(&1_000_000_000) {\n        let (p_alt, o_alt) = power_of_2_prec_round_naive(i, prec, rm);\n        assert_eq!(ComparableFloatRef(&p_alt), ComparableFloatRef(&p));\n        assert_eq!(o_alt, o);\n    }\n\n    if rm == Exact {\n        assert_eq!(o, Equal);\n    } else {\n        let rm = rug_round_try_from_rounding_mode(rm).unwrap();\n        if i32::convertible_from(i) {\n            let (rug_p, rug_o) = rug_shl_prec_round_signed(\n                &rug::Float::with_val(1, 1),\n                i32::exact_from(i),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloat(Float::exact_from(&rug_p)),\n                ComparableFloat(p)\n            );\n            assert_eq!(rug_o, o);\n        }\n    }\n}\n\n#[test]\nfn power_of_2_prec_round_properties() {\n    signed_unsigned_rounding_mode_triple_gen_var_5().test_properties(|(i, prec, rm)| {\n        power_of_2_prec_round_properties_helper(i, prec, rm);\n    });\n\n    signed_unsigned_rounding_mode_triple_gen_var_6().test_properties(|(i, prec, rm)| {\n        power_of_2_prec_round_properties_helper(i, prec, rm);\n    });\n}\n\n#[test]\nfn test_power_of_2_prec() {\n    let test = |i: i64, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let (p, o) = Float::power_of_2_prec(i, prec);\n        assert!(p.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(p.to_string(), out);\n        assert_eq!(to_hex_string(&p), out_hex);\n\n        let (p_alt, o_alt) = power_of_2_prec_naive(i, prec);\n        assert_eq!(p_alt.to_string(), out);\n        assert_eq!(to_hex_string(&p_alt), out_hex);\n        assert_eq!(o_alt, o_out);\n\n        let rug_p = rug::Float::with_val(u32::exact_from(prec), 1) << i32::exact_from(i);\n        let p = Float::exact_from(&rug_p);\n        assert_eq!(p.to_string(), out);\n        assert_eq!(to_hex_string(&p), out_hex);\n    };\n    test(0, 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(0, 100, \"1.0\", \"0x1.0000000000000000000000000#100\", Equal);\n    test(1, 1, \"2.0\", \"0x2.0#1\", Equal);\n    test(1, 100, \"2.0\", \"0x2.0000000000000000000000000#100\", Equal);\n    test(100, 1, \"1.0e30\", \"0x1.0E+25#1\", Equal);\n    test(\n        100,\n        100,\n        \"1267650600228229401496703205376.0\",\n        \"0x10000000000000000000000000.0#100\",\n        Equal,\n    );\n    test(1073741822, 1, \"too_big\", \"0x4.0E+268435455#1\", Equal);\n    test(1073741823, 1, \"Infinity\", \"Infinity\", Greater);\n\n    test(-1, 1, \"0.5\", \"0x0.8#1\", Equal);\n    test(-1, 100, \"0.5\", \"0x0.8000000000000000000000000#100\", Equal);\n    test(-100, 1, \"8.0e-31\", \"0x1.0E-25#1\", Equal);\n    test(\n        -100,\n        100,\n        \"7.88860905221011805411728565283e-31\",\n        \"0x1.0000000000000000000000000E-25#100\",\n        Equal,\n    );\n    test(-1073741824, 1, \"too_small\", \"0x1.0E-268435456#1\", Equal);\n    test(-1073741825, 1, \"0.0\", \"0x0.0\", Less);\n}\n\n#[test]\n#[should_panic]\nfn power_of_2_prec_fail() {\n    Float::power_of_2_prec(0, 0);\n}\n\nfn power_of_2_prec_properties_helper(i: i64, prec: u64) {\n    let (p, o) = Float::power_of_2_prec(i, prec);\n    assert!(p.is_valid());\n    assert!(p.is_finite() || p == Float::INFINITY || p.is_positive_zero());\n    assert!(p >= 0u32);\n    assert_eq!(Float::power_of_2(i), p);\n    let (p_alt, o_alt) = Float::power_of_2_prec_round(i, prec, Nearest);\n    assert_eq!(ComparableFloatRef(&p_alt), ComparableFloatRef(&p));\n    assert_eq!(o, o_alt);\n    if p.is_normal() {\n        assert_eq!(o, Equal);\n        assert_eq!(p.get_prec(), Some(prec));\n        assert!(p.is_power_of_2());\n    } else {\n        assert_eq!(o, if p > 0 { Greater } else { Less });\n    }\n\n    if i.lt_abs(&1_000_000_000) {\n        let (p_alt, o_alt) = power_of_2_prec_naive(i, prec);\n        assert_eq!(ComparableFloatRef(&p_alt), ComparableFloatRef(&p));\n        assert_eq!(o_alt, o);\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (p_alt, o_alt) = Float::power_of_2_prec_round(i, prec, rm);\n            assert_eq!(ComparableFloatRef(&p_alt), ComparableFloatRef(&p));\n            assert_eq!(o_alt, Equal);\n        }\n    }\n    if let Ok(i) = i32::try_from(i) {\n        let rug_p = rug::Float::with_val(u32::exact_from(prec), 1) << i;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_p)),\n            ComparableFloatRef(&p)\n        );\n    }\n}\n\n#[test]\nfn power_of_2_prec_properties() {\n    signed_unsigned_pair_gen_var_19::<i64, u64>().test_properties(|(i, prec)| {\n        power_of_2_prec_properties_helper(i, prec);\n    });\n\n    signed_unsigned_pair_gen_var_20::<i64, u64>().test_properties(|(i, prec)| {\n        power_of_2_prec_properties_helper(i, prec);\n    });\n}\n\n#[test]\nfn test_power_of_2() {\n    let test = |i: i64, out: &str, out_hex: &str| {\n        let p = Float::power_of_2(i);\n        assert!(p.is_valid());\n\n        assert_eq!(p.to_string(), out);\n        assert_eq!(to_hex_string(&p), out_hex);\n\n        let p_alt = power_of_2_i64_naive(i);\n        assert_eq!(ComparableFloatRef(&p_alt), ComparableFloatRef(&p));\n\n        let rug_p = rug::Float::with_val(1, 1) << i32::exact_from(i);\n        let p = Float::exact_from(&rug_p);\n        assert_eq!(p.to_string(), out);\n        assert_eq!(to_hex_string(&p), out_hex);\n    };\n    test(0, \"1.0\", \"0x1.0#1\");\n    test(1, \"2.0\", \"0x2.0#1\");\n    test(2, \"4.0\", \"0x4.0#1\");\n    test(3, \"8.0\", \"0x8.0#1\");\n    test(1073741822, \"too_big\", \"0x4.0E+268435455#1\");\n    test(1073741823, \"Infinity\", \"Infinity\");\n\n    test(-1, \"0.5\", \"0x0.8#1\");\n    test(-2, \"0.2\", \"0x0.4#1\");\n    test(-3, \"0.1\", \"0x0.2#1\");\n    test(-100, \"8.0e-31\", \"0x1.0E-25#1\");\n    test(-1073741824, \"too_small\", \"0x1.0E-268435456#1\");\n    test(-1073741825, \"0.0\", \"0x0.0\");\n\n    let test = |u: u64, out: &str, out_hex: &str| {\n        let p = Float::power_of_2(u);\n        assert!(p.is_valid());\n\n        assert_eq!(p.to_string(), out);\n        assert_eq!(to_hex_string(&p), out_hex);\n\n        let p_alt = power_of_2_u64_naive(u);\n        assert_eq!(p_alt.to_string(), out);\n        assert_eq!(to_hex_string(&p_alt), out_hex);\n\n        let rug_p = rug::Float::with_val(1, 1) << u32::exact_from(u);\n        let p = Float::exact_from(&rug_p);\n        assert_eq!(p.to_string(), out);\n        assert_eq!(to_hex_string(&p), out_hex);\n    };\n    test(0, \"1.0\", \"0x1.0#1\");\n    test(1, \"2.0\", \"0x2.0#1\");\n    test(2, \"4.0\", \"0x4.0#1\");\n    test(3, \"8.0\", \"0x8.0#1\");\n    test(100, \"1.0e30\", \"0x1.0E+25#1\");\n    test(1073741822, \"too_big\", \"0x4.0E+268435455#1\");\n    test(1073741823, \"Infinity\", \"Infinity\");\n}\n\nfn power_of_2_properties_signed_helper(i: i64) {\n    let p = Float::power_of_2(i);\n    assert!(p.is_valid());\n    assert!(p.is_finite() || p == Float::INFINITY || p.is_positive_zero());\n    assert!(p >= 0u32);\n    if p.is_normal() {\n        assert!(p.is_power_of_2());\n        assert_eq!(p.get_prec(), Some(1));\n    }\n    assert_eq!(\n        ComparableFloatRef(&Float::power_of_2_prec(i, 1).0),\n        ComparableFloatRef(&p)\n    );\n    if i >= 0 {\n        assert_eq!(\n            ComparableFloatRef(&Float::power_of_2(i.unsigned_abs())),\n            ComparableFloatRef(&p)\n        );\n    }\n\n    if i.lt_abs(&1_000_000_000) {\n        let p_alt = power_of_2_i64_naive(i);\n        assert_eq!(ComparableFloatRef(&p_alt), ComparableFloatRef(&p));\n    }\n\n    if let Ok(i) = u32::try_from(i) {\n        let rug_p = rug::Float::with_val(1, 1) << i;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_p)),\n            ComparableFloatRef(&p)\n        );\n    }\n}\n\nfn power_of_2_properties_unsigned_helper(u: u64) {\n    let p = Float::power_of_2(u);\n    assert!(p.is_valid());\n    assert!(p.is_finite() || p == Float::INFINITY || p.is_positive_zero());\n    assert!(p >= 0u32);\n    if p.is_normal() {\n        assert!(p.is_power_of_2());\n        assert_eq!(p.get_prec(), Some(1));\n    }\n\n    if u < 1_000_000_000 {\n        let p_alt = power_of_2_u64_naive(u);\n        assert_eq!(ComparableFloatRef(&p_alt), ComparableFloatRef(&p));\n    }\n\n    if let Ok(u) = u32::try_from(u) {\n        let rug_p = rug::Float::with_val(1, 1) << u;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_p)),\n            ComparableFloatRef(&p)\n        );\n    }\n}\n\n#[test]\nfn power_of_2_properties() {\n    signed_gen_var_5().test_properties(|i| {\n        power_of_2_properties_signed_helper(i);\n    });\n\n    signed_gen().test_properties(|i| {\n        power_of_2_properties_signed_helper(i);\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        power_of_2_properties_unsigned_helper(u);\n    });\n\n    unsigned_gen().test_properties(|u| {\n        power_of_2_properties_unsigned_helper(u);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{NegAssign, Reciprocal, ReciprocalAssign};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, rounding_mode_gen, unsigned_gen_var_11,\n    unsigned_rounding_mode_pair_gen_var_3,\n};\nuse malachite_float::emulate_float_to_float_fn;\nuse malachite_float::test_util::arithmetic::reciprocal::{\n    reciprocal_prec_round_naive_1, reciprocal_prec_round_naive_2, rug_reciprocal,\n    rug_reciprocal_prec, rug_reciprocal_prec_round, rug_reciprocal_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_6, float_gen_var_7, float_gen_var_8, float_gen_var_11,\n    float_gen_var_12, float_rounding_mode_pair_gen_var_13, float_rounding_mode_pair_gen_var_14,\n    float_rounding_mode_pair_gen_var_15, float_rounding_mode_pair_gen_var_16,\n    float_rounding_mode_pair_gen_var_17, float_rounding_mode_pair_gen_var_23,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_3, float_unsigned_rounding_mode_triple_gen_var_12,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_reciprocal() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let reciprocal = x.clone().reciprocal();\n        assert!(reciprocal.is_valid());\n\n        assert_eq!(reciprocal.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal), out_hex);\n\n        let reciprocal_alt = (&x).reciprocal();\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n\n        let mut reciprocal_alt = x.clone();\n        reciprocal_alt.reciprocal_assign();\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n\n        let reciprocal_alt =\n            reciprocal_prec_round_naive_1(x.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        let reciprocal_alt =\n            reciprocal_prec_round_naive_2(x.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n\n        let rug_reciprocal = rug_reciprocal(&rug::Float::exact_from(&x));\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal)),\n            ComparableFloatRef(&reciprocal),\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\");\n    test(\"-Infinity\", \"-Infinity\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\");\n    test(\"-0.0\", \"-0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"-1.0\", \"-0x1.0#1\", \"-1.0\", \"-0x1.0#1\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"0.0082\", \"0x0.0218#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"-0.0082\", \"-0x0.0218#7\");\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"0.7071067811865475\",\n        \"0x0.b504f333f9de60#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-0.7071067811865475\",\n        \"-0x0.b504f333f9de60#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0.31830988618379069\",\n        \"0x0.517cc1b727220c#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-0.31830988618379069\",\n        \"-0x0.517cc1b727220c#53\",\n    );\n\n    // - x.is_power_of_2() in reciprocal_prec_round\n    // - !x.is_power_of_2() in reciprocal_prec_round\n    // - in reciprocal_float_significand_same_prec_lt_w\n    // - x != LIMB_HIGH_BIT in reciprocal_float_significand_same_prec_lt_w\n    // - (q + 2) & (mask >> 1) > 2 in reciprocal_float_significand_same_prec_lt_w;\n    // - round_bit != 0 || sticky_bit != 0 in reciprocal_float_significand_same_prec_lt_w\n    // - rm == Nearest in reciprocal_float_significand_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 && reciprocal & shift_bit != 0) in\n    //   reciprocal_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", \"0.8\", \"0x0.c#2\");\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && reciprocal & shift_bit == 0) in\n    //   reciprocal_float_significand_same_prec_lt_w\n    test(\"1.2\", \"0x1.4#3\", \"0.8\", \"0x0.c#3\");\n    // - (q + 2) & (mask >> 1) <= 2 in reciprocal_float_significand_same_prec_lt_w\n    // - hi == 0 && lo < x first time in reciprocal_float_significand_same_prec_lt_w\n    // - hi == 0 && lo < x second time in reciprocal_float_significand_same_prec_lt_w\n    test(\n        \"3615091.606162289805\",\n        \"0x372973.9b2d73aac8#61\",\n        \"2.7661816322867136e-7\",\n        \"0x4.a410e30d72ea318E-6#61\",\n    );\n    // - in reciprocal_float_significand_same_prec_w\n    // - x != LIMB_HIGH_BIT in reciprocal_float_significand_same_prec_w\n    // - hi == 0 && lo < x first time in reciprocal_float_significand_same_prec_w\n    // - hi == 0 && lo < x second time in reciprocal_float_significand_same_prec_w\n    // - !round_bit in reciprocal_float_significand_same_prec_w\n    // - round_bit || sticky_bit != 0 in reciprocal_float_significand_same_prec_w\n    // - rm == Exact in reciprocal_float_significand_same_prec_w\n    // - rm == Exact && (!round_bit || sticky_bit == 0 && reciprocal.even()) in\n    //   reciprocal_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe#64\",\n    );\n    // - round_bit in reciprocal_float_significand_same_prec_w\n    // - rm == Exact && round_bit && (sticky_bit != 0 || reciprocal.even() in\n    //   reciprocal_float_significand_same_prec_w\n    test(\n        \"0.113243462684988497952\",\n        \"0x0.1cfd8608b7c32de2a#64\",\n        \"8.830531814288645436\",\n        \"0x8.d49dbba4a843592#64\",\n    );\n    // - in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - x_0 != 0 || x_1 != LIMB_HIGH_BIT in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - in reciprocal_float_2_approx\n    // - x_1 != Limb::MAX in reciprocal_float_2_approx\n    // - yy == 0 in reciprocal_float_2_approx\n    // - r_0 != 0 || yy == 0 in reciprocal_float_2_approx\n    // - carry in reciprocal_float_2_approx\n    // - r_1 == 0 in reciprocal_float_2_approx\n    // - (q_0.wrapping_add(21)) & (mask >> 1) <= 21 in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - s_1 != 0 || s_0 != 0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - s_2 > 0 || s_1 > x_1 || s_1 == x_1 && s_0 >= x_0 in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - s_1 < x_1 || s_1 == x_1 && s_0 < x_0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - round_bit != 0 || sticky_bit != 0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && z_0 & shift_bit == 0) in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n    );\n    // - r_1 != 0 in reciprocal_float_2_approx\n    // - s_1 >= x_1 && (s_1 != x_1 || s_0 >= x_0) in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe0#65\",\n    );\n    // - yy != 0 in reciprocal_float_2_approx\n    test(\n        \"1.00000000000000000003\",\n        \"0x1.00000000000000008#66\",\n        \"0.99999999999999999997\",\n        \"0x0.ffffffffffffffff8#66\",\n    );\n    // - (q_0.wrapping_add(21)) & (mask >> 1) > 21 in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        \"0.99999999999999999984\",\n        \"0x0.fffffffffffffffd0#65\",\n    );\n    // - rm != Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && !carry in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        \"6.9434396726939059937558762e-29\",\n        \"0x5.804bfffff864a7e6a3c7cE-24#85\",\n    );\n    // - s_2 <= 0 && s_1 <= x_1 && (s_1 != x_1 || s_0 < x_0) in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.1066650957130428898050817125418740852e-35\",\n        \"0xe.b5c943322fb9cafab82fc881e3c1f4E-30#123\",\n        \"90361574054676697026138186100092211.86\",\n        \"0x11672b68e1cda153b96db5b555ad33.dc#123\",\n    );\n    // - x_1 == Limb::MAX in reciprocal_float_2_approx\n    test(\n        \"4.9517601571415210995e27\",\n        \"0xf.fffffffffffffff8E+22#65\",\n        \"2.019483917365790222e-28\",\n        \"0x1.0000000000000001E-23#65\",\n    );\n    // - !carry in reciprocal_float_2_approx\n    test(\n        \"1.809457589959748038781206513903043742e-25\",\n        \"0x3.800000000000000000000000000000E-21#121\",\n        \"5526518032524019084371090.285714285714\",\n        \"0x492492492492492492492.4924924924#121\",\n    );\n    // - s_1 == 0 && s_0 == 0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"4095.75\",\n        \"0xfff.c00000000000000000000000000#120\",\n        \"0.0002441555270707440639687480925349447598\",\n        \"0x0.001000400100040010004001000400100#120\",\n    );\n    // - in reciprocal_float_significand_general\n    // - extra_bit in reciprocal_float_significand_general\n    // - qs_len < MPFR_DIV_THRESHOLD || ds_len < MPFR_DIV_THRESHOLD in\n    //   reciprocal_float_significand_general\n    // - rm != Nearest || shift != 0 in reciprocal_float_significand_general\n    // - ds_len >= qs_2_len in reciprocal_float_significand_general\n    // - qs_2_len == qs_len in reciprocal_float_significand_general\n    // - sticky_bit != 0 || sticky_3 != 0 in reciprocal_float_significand_general\n    // - ds_len <= qs_2_len in reciprocal_float_significand_general\n    // - ds_len <= qs_2_len && rm == Nearest in reciprocal_float_significand_general\n    // - cleanup == None in reciprocal_float_significand_general\n    // - cleanup == None && rm == Nearest && (round_bit != 0 || sticky_bit != 0) in\n    //   reciprocal_float_significand_general\n    // - cleanup == None && rm == Nearest && (round_bit != 0 || sticky_bit != 0) && round_bit == 0\n    //   in reciprocal_float_significand_general\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"0.999999999999999999999999999999999999997\",\n        \"0x0.ffffffffffffffffffffffffffffffff0#129\",\n    );\n    // - !extra_bit in reciprocal_float_significand_general\n    test(\n        \"3.8524937267946719191140399538619613749184e-10\",\n        \"0x1.a7960ee660129a7bc6beccda5d8bb012f0E-8#135\",\n        \"2595721293.573692163399156109109436743137\",\n        \"0x9ab7904d.92dd7d57c55752828aeb2a056a#135\",\n    );\n    // - cleanup == None && rm == Nearest && (round_bit != 0 || sticky_bit != 0) && round_bit != 0\n    //   && sticky_bit == 0 in reciprocal_float_significand_general\n    test(\n        \"59494692712728004820788608585666.4829798\",\n        \"0x2eeedb85c9cdc503a8e25ed4fc2.7ba490#129\",\n        \"1.680822195062896543011322450000404260061e-32\",\n        \"0x5.745f58c91536fd9586859912d6b99220E-27#129\",\n    );\n    // - rm == Nearest && shift == 0 in reciprocal_float_significand_general\n    // - ds_len < qs_2_len in reciprocal_float_significand_general\n    // - qs_2_len != qs_len in reciprocal_float_significand_general\n    test(\n        \"2.652265028059746721807174554033221706564e-11\",\n        \"0x1.d29765de1f777af51db92558a3d9f542E-9#128\",\n        \"37703622730.7776167463689706185944181549\",\n        \"0x8c74fa04a.c711e41e7a061938aeb7ca7#128\",\n    );\n    // - qs_len >= MPFR_DIV_THRESHOLD && ds_len >= MPFR_DIV_THRESHOLD in\n    //   reciprocal_float_significand_general\n    // - ds_len < n in reciprocal_float_significand_general\n    // - !q_high first time in reciprocal_float_significand_general\n    test(\n        \"99775868891207693182758620905617766484977359141657322302733467080906379945858675686059451\\\n        2527853476231275058799551652072546.7114971760702609364731573674336745185834760605451122614\\\n        680178551142556046183482705875960001033145321970465204907865385015751310573750415565593472\\\n        515573584122133946534420508845514863685042630834456885627933663697385547769664847990486584\\\n        336882273751721721644989648370590667737234950547668737865047573751482757356022197920174371\\\n        088074314780588737501583713833755004374512024407585163195094394292034507503368814534990168\\\n        9912721166210129145585\",\n        \"0x1826427338bc8ee8c907c3ce5e6a2a793f6ba67df6e738f22dc8aee7eb1838ddc4290e49186e61bdbedb847\\\n        d19c5d8c4bf88c62.b624adce6b0a3564827e04608c1aec0c8b10390491e15df75402c1788241935e791ebd5f4\\\n        25d73042c03e3bad5f0d11257d8bcdab6c8bae677785865be19fa4f42690ddb02174b09bb2c1c9ce6cf3dc2d80\\\n        9f0b0b79c42ae70f14ec682ac3850e91ee3b6ef02555e18758417024bf2e8801a759e710b3ac91f28b15277ff4\\\n        f6380b7ba380aa56c032ce8db2107bfd99a9c789098467f2b27a7b3e1bb6a9e7804ef8a26a3baea51e9a8da4d5\\\n        02af09995fd6ced97b00#1859\",\n        \"1.002246345847779005201453959044909523251487705121768272318254782834562788571992915761065\\\n        827618366102604676901058851697875789517863827988808181377939460972322574747531876040609995\\\n        972589309563651666694269954573404860608746408716939006674422401722850836821062009150256011\\\n        720454011696660779666788543360159960577274185817743487975811370456064842946971427355525804\\\n        257690941749159301402957505054859414089331855848531064209977516186532202351442372831975270\\\n        870077932986581025601789533966442159881772178301189187013534424007199259091978932352502557\\\n        2202453587766889671779e-123\",\n        \"0xa.99c4846d5eeedd01292b3ecbfdcde3e23e86f2c0de91a7853e3f16d01225356463802a0309555fe6a982a\\\n        b689ccb12d932eab55b6ffd61c4fdd7cd737afd36bd5acda69948c10851f5fd1a254537be41d4c013aa43aaa09\\\n        93fccd821acb36881a3a14540999fa35a76a34b052ec4c6e62c85b8890330ad74145c3af385378890639293f97\\\n        87eeb51c942fb1b0480f7e5dcadd2da6f8bbf05ac6e562e773bff36faf231658530929fef9e7c5b84843c5674a\\\n        883eede0deef889addd0d20f57f1eaeb61dfb8dd23ed0ba6dfc00929192924d8b397f3d5d4913b580d5176e47b\\\n        5900b7857bdc095ca14E-103#1859\",\n    );\n    // - r_0 == 0 && yy != 0 in reciprocal_float_2_approx\n    test(\n        \"206158430208.00000000558794\",\n        \"0x3000000000.000000180000#83\",\n        \"4.850638409455617268748732e-12\",\n        \"0x5.5555555555555552aaabE-10#83\",\n    );\n}\n\n#[test]\nfn test_reciprocal_prec() {\n    let test = |s, s_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (reciprocal, o) = x.clone().reciprocal_prec(prec);\n        assert!(reciprocal.is_valid());\n\n        assert_eq!(reciprocal.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal), out_hex);\n        assert_eq!(o, o_out);\n\n        let (reciprocal_alt, o_alt) = x.reciprocal_prec_ref(prec);\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut reciprocal_alt = x.clone();\n        let o_alt = reciprocal_alt.reciprocal_prec_assign(prec);\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_1(x.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n        let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_2(x.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n\n        let (rug_reciprocal, rug_o) = rug_reciprocal_prec(&rug::Float::exact_from(&x), prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal)),\n            ComparableFloatRef(&reciprocal),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", 1, \"0.008\", \"0x0.02#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 10, \"0.00813\", \"0x0.0215#10\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-0.008\", \"-0x0.02#1\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-0.00813\", \"-0x0.0215#10\", Less);\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        \"0.707\",\n        \"0x0.b50#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        \"-0.707\",\n        \"-0x0.b50#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.3184\",\n        \"0x0.518#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-0.3184\",\n        \"-0x0.518#10\",\n        Less,\n    );\n\n    // - in reciprocal_float_significand_short\n    // - in limbs_reciprocal_limb_to_out_mod_with_fraction\n    // - fraction_len != 0 in limbs_reciprocal_limb_to_out_mod_with_fraction\n    // - out_last == 0 in reciprocal_float_significand_short\n    // - out_last == 0 && shift != 0 in reciprocal_float_significand_short\n    // - round_bit == 0 && sticky_bit != 0 in reciprocal_float_significand_short\n    // - rm == Nearest in reciprocal_float_significand_short\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && out[0] & shift_bit == 0) in\n    //   reciprocal_float_significand_short\n    test(\"1.5\", \"0x1.8#2\", 1, \"0.5\", \"0x0.8#1\", Less);\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || out[0] & shift_bit != 0) in\n    //   reciprocal_float_significand_short\n    test(\"1.5\", \"0x1.8#2\", 4, \"0.7\", \"0x0.b#4\", Greater);\n    // - ds_len > qs_2_len in reciprocal_float_significand_general\n    // - inex != Equal in reciprocal_float_significand_general\n    // - ds_len > qs_2_len && rm == Nearest in reciprocal_float_significand_general\n    // - sticky_3 > 1 in reciprocal_float_significand_general\n    test(\n        \"0.000199046277632504184666664672269768242929310652018203552191617720205649\",\n        \"0x0.000d0b7140b8f3aea60aad60c1dc3b2ee0d83e2eba33dcfb6f874df52d78#225\",\n        26,\n        \"5023.9573\",\n        \"0x139f.f510#26\",\n        Less,\n    );\n    // - out_last == 0 && shift == 0 in reciprocal_float_significand_short\n    // - out_last == 0 && shift == 0 && c >= y - c\n    test(\n        \"1.4904942e-19\",\n        \"0x2.bfddbE-16#22\",\n        64,\n        \"6709184284559176977.0\",\n        \"0x5d1bcf8f5dc87511.0#64\",\n        Greater,\n    );\n    // - sticky_3 <= 1 in reciprocal_float_significand_general\n    // - !q_high second time in reciprocal_float_significand_general\n    // - !q_high_2 in reciprocal_float_significand_general\n    // - cmp_s_r != Equal in reciprocal_float_significand_general\n    // - cmp_s_r <= Equal first time in reciprocal_float_significand_general\n    test(\n        \"13104.5238818416080254535\",\n        \"0x3330.861d1ed0acba8a3a#77\",\n        61,\n        \"0.00007630952555137529844\",\n        \"0x0.00050042eaa75fe3e40#61\",\n        Less,\n    );\n    // - cmp_s_r > Equal first time in reciprocal_float_significand_general\n    // - cmp_s_r > Equal && !q_high_2 in reciprocal_float_significand_general\n    // - cmp_s_r <= Equal second time in reciprocal_float_significand_general\n    // - sticky_3 != 1 && round_bit != 0 in reciprocal_float_significand_general\n    test(\n        \"4047252243163522937320069504914937843.384444039\",\n        \"0x30b78f117589e437888c5573227d7f3.626aecb#150\",\n        126,\n        \"2.47081214591743090926825573642415225879e-37\",\n        \"0x5.413cf35bf8a6be7eed9713c3529cac4E-31#126\",\n        Less,\n    );\n    // - out_last == 0 && shift == 0 && c < y - c in reciprocal_float_significand_short\n    test(\n        \"0.252\",\n        \"0x0.408#8\",\n        64,\n        \"3.9689922480620155039\",\n        \"0x3.f80fe03f80fe03f8#64\",\n        Less,\n    );\n    // - sticky_3 != 1 && round_bit == 0 in reciprocal_float_significand_general\n    // - cmp_s_r != Equal || shift != 0 in reciprocal_float_significand_general\n    // - rm == Nearest || ((rm == Ceiling || rm == Up) && inex != Equal) in\n    //   reciprocal_float_significand_general\n    // - cleanup == TruncateCheckQHigh in reciprocal_float_significand_general\n    // - !q_high third time in reciprocal_float_significand_general\n    test(\n        \"13486082141.77132281557478202754\",\n        \"0x323d5485d.c575697b8d65625d0#99\",\n        60,\n        \"7.41505197349076425e-11\",\n        \"0x5.187840c7b7df518E-9#60\",\n        Greater,\n    );\n    // - sticky_3 == 1 in reciprocal_float_significand_general\n    test(\n        \"1.22280082196367917099634553e-19\",\n        \"0x2.41738c7082eda42f40f3f0E-16#87\",\n        62,\n        \"8177946743559704448.0\",\n        \"0x717de73c11f04f80.0#62\",\n        Less,\n    );\n    // - cmp_s_r > Equal second time in reciprocal_float_significand_general\n    // - cmp_s_r > Equal && rm == Nearest in reciprocal_float_significand_general\n    // - cmp_s_r > Equal && rm == Nearest && shift == 1 in reciprocal_float_significand_general\n    // - cmp_s_r > Equal && rm == Nearest && shift == 1 && round_bit == 0 in\n    //   reciprocal_float_significand_general\n    // - cleanup == Sub2Ulp in reciprocal_float_significand_general\n    test(\n        \"18686733767405.50192797818236099916512095073138146049740456616\",\n        \"0x10fed820d2ed.807e5a1b3d9ab71287cc373ef7f3521609fa72f#201\",\n        63,\n        \"5.351389988464750895e-14\",\n        \"0xf.1015372ed29c6daE-12#63\",\n        Less,\n    );\n    // - cmp_s_r > Equal && rm == Nearest && shift == 1 && round_bit != 0 in\n    //   reciprocal_float_significand_general\n    test(\n        \"5.1485428388978050057923204436e-7\",\n        \"0x8.a348459137c894fe7ce2ce4E-6#94\",\n        63,\n        \"1942297.1339480570737\",\n        \"0x1da319.224a6b7c7e8#63\",\n        Greater,\n    );\n    // - q_high second time in reciprocal_float_significand_general\n    // - q_high third time in reciprocal_float_significand_general\n    test(\n        \"77371252455336267181195267.98438\",\n        \"0x4000000000000000000003.fc00#101\",\n        21,\n        \"1.29247e-26\",\n        \"0x4.00000E-22#21\",\n        Greater,\n    );\n    // - cmp_s_r > Equal && rm == Nearest && shift != 1 in reciprocal_float_significand_general\n    test(\n        \"2658455991647202407967140029027844095.999984793\",\n        \"0x2000000003fffdfffffffffff7fffff.ffff00e#150\",\n        126,\n        \"3.76158192252184441821673862447332945247e-37\",\n        \"0x7.ffffffff000080001fffe0020400060E-31#126\",\n        Greater,\n    );\n    // - cmp_s_r == Equal in reciprocal_float_significand_general\n    // - !slice_test_zero(sp_lo) in reciprocal_float_significand_general\n    test(\n        \"1.00000000000000000000000000000000000000000000035028\",\n        \"0x1.00000000000000000000000000000000000001fff#165\",\n        9,\n        \"1.0\",\n        \"0x1.00#9\",\n        Greater,\n    );\n    // - ds_len >= n in reciprocal_float_significand_general\n    test(\n        \"0.055494458197186880675630915676192867532090892470422627386324587939238035948781984969197\\\n        293549419550977162311955781124943110956302191334821801709357381779895051695270613703928454\\\n        324596584327643817343816609304133584205767499993731432854297161698269943482406592768874444\\\n        537959922587924718339566077249075342435855861361805700477320039260219431275491192763683820\\\n        335274971653357747385666948482136785955293678142161982025522843889154198503897563042426395\\\n        128128925013857602497675148024154470366154782845358820106881972937537492453282371069714224\\\n        342987087633028783648188309716648625167308459669051113846104707695985727291553732092985376\\\n        828259777127224883258056131830095048084139109366273880047266946456087245977725112865710579\\\n        525111935320391211042996099454878241904334424644681645423208503968089041208566140555448097\\\n        852910157786980160921009881876094041863058139126904649967001982231878732430835123816538920\\\n        677999964668461960985136485079991108378659476109039768366016053541284627738754596865400997\\\n        112674267336505852768050602674774522669073467755292625683686148376948941511306559626232154\\\n        752250188007464931234370449669484827725942224651581822979291904312419637250173763557353262\\\n        213949126273235198961215664565140295983002285722717251104994492638175694612259962414559660\\\n        670986455111669460799863783422503680534332809871688740315758114042751185650495859242221856\\\n        676315059490112305738127164937772981750053994564437960009449100953381044642977719710987666\\\n        446442147625231494914221140350124646594870978197268779196749153799654193158076220975432784\\\n        285250458268961487489605062990550609833462756239703423977438296502233632161406744847227123\\\n        129345837972247611423244017961911382138681216321381679915794615975763676728759826413970576\\\n        860022980739678182223426387634227578298610034617798500806276338343012622846552838812662393\\\n        624312342667652111927682534015047744310614980669350777266223429538479188836406048087315918\\\n        309894499222120214872928367335411152843249721184424372084873571670196566303743654124450236\\\n        183156500319414376380635601282651645722305689309629762280330704861001884908133936528480642\\\n        756123234\",\n        \"0x0.0e34e28310efa672de91bbf3447b991e67d8318cdf0c4058e4c9c730c71dc5b4bf675e849e3ac19fa3e70\\\n        d9cbfb926620de7c9c66fc396364a70516bd66e253f5b318c8f82fabc4da09cab178fa55b2cd32603f085d4149\\\n        a70fb07eb0959a5a78a00603aae495e7a094d9ee04b63747d7a023fb4369e5bf83efc20d6dfe31bafee72256df\\\n        1e39a8949cb554b519bb7b532f0ffb97b7fe5238cb68f0cfca74556fd7588422c7b383f4183a4193de48c69bae\\\n        7faf54820ec3c71871cbb288daf37266ee4f1fd3e40e483ed25f601b87f9c4a92b8cec5ec0e8d7edbd4234fba3\\\n        1a0a463a29b8f32d02f0d1f55195b2ec33db71548c7ccaf7e3a658ee71d308649653be586268e028c9f15d7788\\\n        cbbd9d825fadf58d6f13183242c54015f254a271b4c89cfc1d82fc8c6182b0d0c620d53cf81728d495822994c6\\\n        63bb058d661f74be0ae8c8c10381afa72bc89a2a01da15a5f6d117b31e04e34a6e11e0aa8ad521b7a6117ce813\\\n        b8e9326335c30e14052e4aa58c9062245ce2b058e7ca1221aa19af3c21653dac76aa59bb843a7a0ad8c6e22992\\\n        639766e47bfcc7de81f7a5a43e5faba0bd029002632b5d26d5a4303d9bbf4cf2664d57e50df98491d49ceb0f2f\\\n        a1db2579ec23c459066023beebebd800fc879d76d59a3d6d2949650b07ef7b31e752ca051f4f107c7ff4af3f56\\\n        43eb287784ebcbcbefaa6a9496458e1b5afa0a74a27a47545d2f9091189f54f315a8bc904dedd3248f8cfbf32b\\\n        19df9037d47bd021b075b70aaa2087c30b755c65f93508e4564f2d998430e8f68565d451de80e317a96c18493e\\\n        662aa4f6ed98647d9051d9c993accc85820fe55a06d956025618ac1fbd020af906edd248ee088ee34f3ec8fc99\\\n        1e9392efafd1acd495d65fe834644d939ef5fa91d984969c79257afb98f8d94a3551a1a4b533c182b0d198d8a9\\\n        53e030b1532cd0e54117934099dd0b0027cd6058fb4190686ba78ded239aca8ac146e13f4c88052537903cb587\\\n        95eae03289ef10a0dee81bb143567c686a600364a57829437fc75160f8660a0ac48daacd98471fb2c0c490cd90\\\n        2cea0ea9aa3a814462dd78ab7d573f356b8c0ee7ac1f0c13819e3aeb5b2c8ea9f3a386bf90e5898fb38867db59\\\n        a9e8ae436df1ececb24a9e478c52dd17ad020f761aca8761acb63eb70ac73687a85f5fc45a10ab7873104f3489\\\n        9df7961eaa91080cf7a#6892\",\n        2006,\n        \"18.01981733827778674260325184800154550178488687484021553354418910902303106544992907597073\\\n        029189149288233180017138039419588169269797921955767649134253967949783482048904124978427680\\\n        356665076989426379081885511868423028921432842040598017121872298172949413285212017353511719\\\n        635837927429422415155120291649700552853758008370658383590920718577880818445566446372050296\\\n        508733341553853089827665379953621398768316388977766832203115700511569639084749508682625973\\\n        200934933860726967306493882349632958444320046459537281159643562613023877018494385007867594\\\n        9194217635032456311998703209522721567033904823795308705191538464412\",\n        \"0x12.0512bfc3cbff370e13079bf70f24c8fc14fb1154aa0638c41252b425cfb276f04379cf0908b1732ae3ca\\\n        5d5ce2ef398eca257c87dfb650e9648bf8397dd443e42a5fd3663c3d58b9b6cd2a1ebf3c9246c45a1f6086158e\\\n        a1e93d0f78945b71e8bdf265700c826de9776e648ce900159a0f4f2716ec326e2b8289920112637767e8fee268\\\n        3363b8e4c4bf07c685c226e6b97d260fdc2910d7e8a10fada9bda175aeb73def046bae399c664bfe3cfb3f7e73\\\n        136427cf5ca96cad226976adc2a9a0117dd38cbd0aaf5edbdb6a9e925126c38670a8946bc5ee1840200876c486\\\n        de477d9c4b50e410143b115c27f9ba57c1176894c9d33effdbbd50928#2006\",\n        Less,\n    );\n    // - q_high first time in reciprocal_float_significand_general\n    // - !round_helper_2 in reciprocal_float_significand_general\n    test(\n        \"3.725290298461914062500000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000011016237598729697344643067035553076048795855845749823769296583726265856513\\\n        808851994012395922156678620494270052333942368952051919368238891272218333e-9\",\n        \"0x1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeE-7#3520\",\n        1969,\n        \"268435456.0\",\n        \"0x10000000.000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000000000000000000000000000000000#1969\",\n        Greater,\n    );\n}\n\n#[test]\nfn reciprocal_prec_fail() {\n    assert_panic!(Float::NAN.reciprocal_prec(0));\n    assert_panic!(Float::NAN.reciprocal_prec_ref(0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.reciprocal_prec_assign(0)\n    });\n}\n\n#[test]\nfn test_reciprocal_round() {\n    let test = |s, s_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (reciprocal, o) = x.clone().reciprocal_round(rm);\n        assert!(reciprocal.is_valid());\n\n        assert_eq!(reciprocal.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal), out_hex);\n        assert_eq!(o, o_out);\n\n        let (reciprocal_alt, o_alt) = x.reciprocal_round_ref(rm);\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut reciprocal_alt = x.clone();\n        let o_alt = reciprocal_alt.reciprocal_round_assign(rm);\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (reciprocal_alt, o_alt) =\n            reciprocal_prec_round_naive_1(x.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n        let (reciprocal_alt, o_alt) =\n            reciprocal_prec_round_naive_2(x.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_reciprocal, rug_o) = rug_reciprocal_round(&rug::Float::exact_from(&x), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_reciprocal)),\n                ComparableFloatRef(&reciprocal),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Ceiling, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Nearest, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", Floor, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Ceiling, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Down, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Up, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Nearest, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Exact, \"-1.0\", \"-0x1.0#1\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Floor,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Down,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Up,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Exact,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", Floor, \"0.0081\", \"0x0.0210#7\", Less);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n    test(\"123.0\", \"0x7b.0#7\", Down, \"0.0081\", \"0x0.0210#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Up, \"0.0082\", \"0x0.0218#7\", Greater);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        Nearest,\n        \"0.0082\",\n        \"0x0.0218#7\",\n        Greater,\n    );\n\n    test(\"-123.0\", \"-0x7b.0#7\", Floor, \"-0.0082\", \"-0x0.0218#7\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Ceiling,\n        \"-0.0081\",\n        \"-0x0.0210#7\",\n        Greater,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Down,\n        \"-0.0081\",\n        \"-0x0.0210#7\",\n        Greater,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", Up, \"-0.0082\", \"-0x0.0218#7\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Nearest,\n        \"-0.0082\",\n        \"-0x0.0218#7\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Floor,\n        \"0.7071067811865475\",\n        \"0x0.b504f333f9de60#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Ceiling,\n        \"0.7071067811865476\",\n        \"0x0.b504f333f9de68#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Down,\n        \"0.7071067811865475\",\n        \"0x0.b504f333f9de60#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Up,\n        \"0.7071067811865476\",\n        \"0x0.b504f333f9de68#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Nearest,\n        \"0.7071067811865475\",\n        \"0x0.b504f333f9de60#53\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Floor,\n        \"-0.7071067811865476\",\n        \"-0x0.b504f333f9de68#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Ceiling,\n        \"-0.7071067811865475\",\n        \"-0x0.b504f333f9de60#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Down,\n        \"-0.7071067811865475\",\n        \"-0x0.b504f333f9de60#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Up,\n        \"-0.7071067811865476\",\n        \"-0x0.b504f333f9de68#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Nearest,\n        \"-0.7071067811865475\",\n        \"-0x0.b504f333f9de60#53\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"0.31830988618379064\",\n        \"0x0.517cc1b7272208#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"0.31830988618379069\",\n        \"0x0.517cc1b727220c#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"0.31830988618379064\",\n        \"0x0.517cc1b7272208#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"0.31830988618379069\",\n        \"0x0.517cc1b727220c#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"0.31830988618379069\",\n        \"0x0.517cc1b727220c#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"-0.31830988618379069\",\n        \"-0x0.517cc1b727220c#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-0.31830988618379064\",\n        \"-0x0.517cc1b7272208#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"-0.31830988618379064\",\n        \"-0x0.517cc1b7272208#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"-0.31830988618379069\",\n        \"-0x0.517cc1b727220c#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-0.31830988618379069\",\n        \"-0x0.517cc1b727220c#53\",\n        Less,\n    );\n\n    // - rm == Floor || rm == Down in reciprocal_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", Down, \"0.5\", \"0x0.8#2\", Less);\n    // - rm == Ceiling || rm == Up in reciprocal_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", Up, \"0.8\", \"0x0.c#2\", Greater);\n    // - rm == Floor || rm == Down in reciprocal_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Down,\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe#64\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in reciprocal_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Up,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff#64\",\n        Greater,\n    );\n    // - rm == Floor || rm == Down in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Down,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Up,\n        \"0.99999999999999999997\",\n        \"0x0.ffffffffffffffff8#65\",\n        Greater,\n    );\n    // - ds_len <= qs_2_len && rm == Ceiling || rm == Up && inex != Equal in\n    //   reciprocal_float_significand_general\n    // - cleanup == None && (rm == Ceiling || rm == Up) && (round_bit != 0 || sticky_bit != 0) in\n    //   reciprocal_float_significand_general\n    test(\n        \"2.4914040842493675536005152793625253098043524808533216867315977e-8\",\n        \"0x6.b014710df6d8d0fb1901206ed24e1e002b4411ac77d2348fd2E-7#202\",\n        Up,\n        \"40138009.17811728321982547739205337771132288200540084196230409\",\n        \"0x2647519.2d9918224811b1eb5289a86e1aa22ec284493440dbd2#202\",\n        Greater,\n    );\n    // - ds_len <= qs_2_len && rm == Floor || rm == Down || (rm != Nearest && inex == Equal) in\n    //   reciprocal_float_significand_general\n    // - cleanup == None && (rm == Floor || rm == Down || round_bit == 0 && sticky_bit == 0) in\n    //   reciprocal_float_significand_general\n    test(\n        \"2.4914040842493675536005152793625253098043524808533216867315977e-8\",\n        \"0x6.b014710df6d8d0fb1901206ed24e1e002b4411ac77d2348fd2E-7#202\",\n        Down,\n        \"40138009.17811728321982547739205337771132288200540084196230408\",\n        \"0x2647519.2d9918224811b1eb5289a86e1aa22ec284493440dbd1#202\",\n        Less,\n    );\n\n    // - x.is_power_of_2() in reciprocal_prec_round\n    // - !x.is_power_of_2() in reciprocal_prec_round\n    // - in reciprocal_float_significand_same_prec_lt_w\n    // - x != LIMB_HIGH_BIT in reciprocal_float_significand_same_prec_lt_w\n    // - (q + 2) & (mask >> 1) > 2 in reciprocal_float_significand_same_prec_lt_w;\n    // - round_bit != 0 || sticky_bit != 0 in reciprocal_float_significand_same_prec_lt_w\n    // - rm == Nearest in reciprocal_float_significand_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 && reciprocal & shift_bit != 0) in\n    //   reciprocal_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", Nearest, \"0.8\", \"0x0.c#2\", Greater);\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && reciprocal & shift_bit == 0) in\n    //   reciprocal_float_significand_same_prec_lt_w\n    test(\"1.2\", \"0x1.4#3\", Nearest, \"0.8\", \"0x0.c#3\", Less);\n    // - (q + 2) & (mask >> 1) <= 2 in reciprocal_float_significand_same_prec_lt_w\n    // - hi == 0 && lo < x first time in reciprocal_float_significand_same_prec_lt_w\n    // - hi == 0 && lo < x second time in reciprocal_float_significand_same_prec_lt_w\n    test(\n        \"3615091.606162289805\",\n        \"0x372973.9b2d73aac8#61\",\n        Nearest,\n        \"2.7661816322867136e-7\",\n        \"0x4.a410e30d72ea318E-6#61\",\n        Less,\n    );\n    // - in reciprocal_float_significand_same_prec_w\n    // - x != LIMB_HIGH_BIT in reciprocal_float_significand_same_prec_w\n    // - hi == 0 && lo < x first time in reciprocal_float_significand_same_prec_w\n    // - hi == 0 && lo < x second time in reciprocal_float_significand_same_prec_w\n    // - !round_bit in reciprocal_float_significand_same_prec_w\n    // - round_bit || sticky_bit != 0 in reciprocal_float_significand_same_prec_w\n    // - rm == Exact in reciprocal_float_significand_same_prec_w\n    // - rm == Exact && (!round_bit || sticky_bit == 0 && reciprocal.even()) in\n    //   reciprocal_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe#64\",\n        Less,\n    );\n    // - round_bit in reciprocal_float_significand_same_prec_w\n    // - rm == Exact && round_bit && (sticky_bit != 0 || reciprocal.even() in\n    //   reciprocal_float_significand_same_prec_w\n    test(\n        \"0.113243462684988497952\",\n        \"0x0.1cfd8608b7c32de2a#64\",\n        Nearest,\n        \"8.830531814288645436\",\n        \"0x8.d49dbba4a843592#64\",\n        Greater,\n    );\n    // - in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - x_0 != 0 || x_1 != LIMB_HIGH_BIT in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - in reciprocal_float_2_approx\n    // - x_1 != Limb::MAX in reciprocal_float_2_approx\n    // - yy == 0 in reciprocal_float_2_approx\n    // - r_0 != 0 || yy == 0 in reciprocal_float_2_approx\n    // - carry in reciprocal_float_2_approx\n    // - r_1 == 0 in reciprocal_float_2_approx\n    // - (q_0.wrapping_add(21)) & (mask >> 1) <= 21 in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - s_1 != 0 || s_0 != 0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - s_2 > 0 || s_1 > x_1 || s_1 == x_1 && s_0 >= x_0 in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - s_1 < x_1 || s_1 == x_1 && s_0 < x_0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - round_bit != 0 || sticky_bit != 0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && z_0 & shift_bit == 0) in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"0.99999999999999999995\",\n        \"0x0.ffffffffffffffff0#65\",\n        Less,\n    );\n    // - r_1 != 0 in reciprocal_float_2_approx\n    // - s_1 >= x_1 && (s_1 != x_1 || s_0 >= x_0) in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Nearest,\n        \"0.99999999999999999989\",\n        \"0x0.fffffffffffffffe0#65\",\n        Less,\n    );\n    // - yy != 0 in reciprocal_float_2_approx\n    test(\n        \"1.00000000000000000003\",\n        \"0x1.00000000000000008#66\",\n        Nearest,\n        \"0.99999999999999999997\",\n        \"0x0.ffffffffffffffff8#66\",\n        Less,\n    );\n    // - (q_0.wrapping_add(21)) & (mask >> 1) > 21 in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        Nearest,\n        \"0.99999999999999999984\",\n        \"0x0.fffffffffffffffd0#65\",\n        Less,\n    );\n    // - rm != Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && !carry in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        Nearest,\n        \"6.9434396726939059937558762e-29\",\n        \"0x5.804bfffff864a7e6a3c7cE-24#85\",\n        Greater,\n    );\n    // - s_2 <= 0 && s_1 <= x_1 && (s_1 != x_1 || s_0 < x_0) in\n    //   reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.1066650957130428898050817125418740852e-35\",\n        \"0xe.b5c943322fb9cafab82fc881e3c1f4E-30#123\",\n        Nearest,\n        \"90361574054676697026138186100092211.86\",\n        \"0x11672b68e1cda153b96db5b555ad33.dc#123\",\n        Greater,\n    );\n    // - x_1 == Limb::MAX in reciprocal_float_2_approx\n    test(\n        \"4.9517601571415210995e27\",\n        \"0xf.fffffffffffffff8E+22#65\",\n        Nearest,\n        \"2.019483917365790222e-28\",\n        \"0x1.0000000000000001E-23#65\",\n        Greater,\n    );\n    // - !carry in reciprocal_float_2_approx\n    test(\n        \"1.809457589959748038781206513903043742e-25\",\n        \"0x3.800000000000000000000000000000E-21#121\",\n        Nearest,\n        \"5526518032524019084371090.285714285714\",\n        \"0x492492492492492492492.4924924924#121\",\n        Less,\n    );\n    // - s_1 == 0 && s_0 == 0 in reciprocal_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"4095.75\",\n        \"0xfff.c00000000000000000000000000#120\",\n        Nearest,\n        \"0.0002441555270707440639687480925349447598\",\n        \"0x0.001000400100040010004001000400100#120\",\n        Less,\n    );\n    // - in reciprocal_float_significand_general\n    // - extra_bit in reciprocal_float_significand_general\n    // - qs_len < MPFR_DIV_THRESHOLD || ds_len < MPFR_DIV_THRESHOLD in\n    //   reciprocal_float_significand_general\n    // - rm != Nearest || shift != 0 in reciprocal_float_significand_general\n    // - ds_len >= qs_2_len in reciprocal_float_significand_general\n    // - qs_2_len == qs_len in reciprocal_float_significand_general\n    // - sticky_bit != 0 || sticky_3 != 0 in reciprocal_float_significand_general\n    // - ds_len <= qs_2_len in reciprocal_float_significand_general\n    // - ds_len <= qs_2_len && rm == Nearest in reciprocal_float_significand_general\n    // - cleanup == None in reciprocal_float_significand_general\n    // - cleanup == None && rm == Nearest && (round_bit != 0 || sticky_bit != 0) in\n    //   reciprocal_float_significand_general\n    // - cleanup == None && rm == Nearest && (round_bit != 0 || sticky_bit != 0) && round_bit == 0\n    //   in reciprocal_float_significand_general\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Nearest,\n        \"0.999999999999999999999999999999999999997\",\n        \"0x0.ffffffffffffffffffffffffffffffff0#129\",\n        Less,\n    );\n    // - !extra_bit in reciprocal_float_significand_general\n    test(\n        \"3.8524937267946719191140399538619613749184e-10\",\n        \"0x1.a7960ee660129a7bc6beccda5d8bb012f0E-8#135\",\n        Nearest,\n        \"2595721293.573692163399156109109436743137\",\n        \"0x9ab7904d.92dd7d57c55752828aeb2a056a#135\",\n        Less,\n    );\n    // - cleanup == None && rm == Nearest && (round_bit != 0 || sticky_bit != 0) && round_bit != 0\n    //   && sticky_bit == 0 in reciprocal_float_significand_general\n    test(\n        \"59494692712728004820788608585666.4829798\",\n        \"0x2eeedb85c9cdc503a8e25ed4fc2.7ba490#129\",\n        Nearest,\n        \"1.680822195062896543011322450000404260061e-32\",\n        \"0x5.745f58c91536fd9586859912d6b99220E-27#129\",\n        Greater,\n    );\n    // - rm == Nearest && shift == 0 in reciprocal_float_significand_general\n    // - ds_len < qs_2_len in reciprocal_float_significand_general\n    // - qs_2_len != qs_len in reciprocal_float_significand_general\n    test(\n        \"2.652265028059746721807174554033221706564e-11\",\n        \"0x1.d29765de1f777af51db92558a3d9f542E-9#128\",\n        Nearest,\n        \"37703622730.7776167463689706185944181549\",\n        \"0x8c74fa04a.c711e41e7a061938aeb7ca7#128\",\n        Greater,\n    );\n    // - qs_len >= MPFR_DIV_THRESHOLD && ds_len >= MPFR_DIV_THRESHOLD in\n    //   reciprocal_float_significand_general\n    // - ds_len < n in reciprocal_float_significand_general\n    // - !q_high first time in reciprocal_float_significand_general\n    test(\n        \"99775868891207693182758620905617766484977359141657322302733467080906379945858675686059451\\\n        2527853476231275058799551652072546.7114971760702609364731573674336745185834760605451122614\\\n        680178551142556046183482705875960001033145321970465204907865385015751310573750415565593472\\\n        515573584122133946534420508845514863685042630834456885627933663697385547769664847990486584\\\n        336882273751721721644989648370590667737234950547668737865047573751482757356022197920174371\\\n        088074314780588737501583713833755004374512024407585163195094394292034507503368814534990168\\\n        9912721166210129145585\",\n        \"0x1826427338bc8ee8c907c3ce5e6a2a793f6ba67df6e738f22dc8aee7eb1838ddc4290e49186e61bdbedb847\\\n        d19c5d8c4bf88c62.b624adce6b0a3564827e04608c1aec0c8b10390491e15df75402c1788241935e791ebd5f4\\\n        25d73042c03e3bad5f0d11257d8bcdab6c8bae677785865be19fa4f42690ddb02174b09bb2c1c9ce6cf3dc2d80\\\n        9f0b0b79c42ae70f14ec682ac3850e91ee3b6ef02555e18758417024bf2e8801a759e710b3ac91f28b15277ff4\\\n        f6380b7ba380aa56c032ce8db2107bfd99a9c789098467f2b27a7b3e1bb6a9e7804ef8a26a3baea51e9a8da4d5\\\n        02af09995fd6ced97b00#1859\",\n        Nearest,\n        \"1.002246345847779005201453959044909523251487705121768272318254782834562788571992915761065\\\n        827618366102604676901058851697875789517863827988808181377939460972322574747531876040609995\\\n        972589309563651666694269954573404860608746408716939006674422401722850836821062009150256011\\\n        720454011696660779666788543360159960577274185817743487975811370456064842946971427355525804\\\n        257690941749159301402957505054859414089331855848531064209977516186532202351442372831975270\\\n        870077932986581025601789533966442159881772178301189187013534424007199259091978932352502557\\\n        2202453587766889671779e-123\",\n        \"0xa.99c4846d5eeedd01292b3ecbfdcde3e23e86f2c0de91a7853e3f16d01225356463802a0309555fe6a982a\\\n        b689ccb12d932eab55b6ffd61c4fdd7cd737afd36bd5acda69948c10851f5fd1a254537be41d4c013aa43aaa09\\\n        93fccd821acb36881a3a14540999fa35a76a34b052ec4c6e62c85b8890330ad74145c3af385378890639293f97\\\n        87eeb51c942fb1b0480f7e5dcadd2da6f8bbf05ac6e562e773bff36faf231658530929fef9e7c5b84843c5674a\\\n        883eede0deef889addd0d20f57f1eaeb61dfb8dd23ed0ba6dfc00929192924d8b397f3d5d4913b580d5176e47b\\\n        5900b7857bdc095ca14E-103#1859\",\n        Greater,\n    );\n    // - r_0 == 0 && yy != 0 in reciprocal_float_2_approx\n    test(\n        \"206158430208.00000000558794\",\n        \"0x3000000000.000000180000#83\",\n        Nearest,\n        \"4.850638409455617268748732e-12\",\n        \"0x5.5555555555555552aaabE-10#83\",\n        Greater,\n    );\n}\n\n#[test]\nfn reciprocal_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(THREE.reciprocal_round(Exact));\n    assert_panic!(THREE.reciprocal_round_ref(Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.reciprocal_round_assign(Exact);\n    });\n}\n\n#[test]\nfn test_reciprocal_prec_round() {\n    let test = |s, s_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (reciprocal, o) = x.clone().reciprocal_prec_round(prec, rm);\n        assert!(reciprocal.is_valid());\n\n        assert_eq!(reciprocal.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal), out_hex);\n        assert_eq!(o, o_out);\n\n        let (reciprocal_alt, o_alt) = x.reciprocal_prec_round_ref(prec, rm);\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut reciprocal_alt = x.clone();\n        let o_alt = reciprocal_alt.reciprocal_prec_round_assign(prec, rm);\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal),\n            ComparableFloatRef(&reciprocal_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_1(x.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n        let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_2(x.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_reciprocal, rug_o) =\n                rug_reciprocal_prec_round(&rug::Float::exact_from(&x), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_reciprocal)),\n                ComparableFloatRef(&reciprocal),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\"-Infinity\", \"-Infinity\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\"-Infinity\", \"-Infinity\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", 1, Floor, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", 1, Down, \"-Infinity\", \"-Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Up, \"-Infinity\", \"-Infinity\", Equal);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", 1, Exact, \"-Infinity\", \"-Infinity\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 1, Floor, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Down, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Up, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Nearest, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Exact, \"-1.0\", \"-0x1.0#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 10, Floor, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Ceiling,\n        \"-1.0\",\n        \"-0x1.000#10\",\n        Equal,\n    );\n    test(\"-1.0\", \"-0x1.0#1\", 10, Down, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Up, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        10,\n        Nearest,\n        \"-1.0\",\n        \"-0x1.000#10\",\n        Equal,\n    );\n    test(\"-1.0\", \"-0x1.0#1\", 10, Exact, \"-1.0\", \"-0x1.000#10\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 1, Floor, \"0.008\", \"0x0.02#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.02\", \"0x0.04#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 1, Down, \"0.008\", \"0x0.02#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Up, \"0.02\", \"0x0.04#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.008\", \"0x0.02#1\", Less);\n\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Floor, \"-0.02\", \"-0x0.04#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-0.008\",\n        \"-0x0.02#1\",\n        Greater,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Down,\n        \"-0.008\",\n        \"-0x0.02#1\",\n        Greater,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Up, \"-0.02\", \"-0x0.04#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"-0.008\",\n        \"-0x0.02#1\",\n        Greater,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"0.00812\",\n        \"0x0.0214#10\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Down,\n        \"0.00812\",\n        \"0x0.0214#10\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"0.00813\",\n        \"0x0.0215#10\",\n        Greater,\n    );\n\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Floor,\n        \"-0.00813\",\n        \"-0x0.0215#10\",\n        Less,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Ceiling,\n        \"-0.00812\",\n        \"-0x0.0214#10\",\n        Greater,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Down,\n        \"-0.00812\",\n        \"-0x0.0214#10\",\n        Greater,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Up,\n        \"-0.00813\",\n        \"-0x0.0215#10\",\n        Less,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Nearest,\n        \"-0.00813\",\n        \"-0x0.0215#10\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Floor,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Down,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Floor,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Ceiling,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Down,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Up,\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Nearest,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Floor,\n        \"0.707\",\n        \"0x0.b50#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Ceiling,\n        \"0.708\",\n        \"0x0.b54#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Down,\n        \"0.707\",\n        \"0x0.b50#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Up,\n        \"0.708\",\n        \"0x0.b54#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Nearest,\n        \"0.707\",\n        \"0x0.b50#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Floor,\n        \"-0.708\",\n        \"-0x0.b54#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Ceiling,\n        \"-0.707\",\n        \"-0x0.b50#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Down,\n        \"-0.707\",\n        \"-0x0.b50#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Up,\n        \"-0.708\",\n        \"-0x0.b54#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Nearest,\n        \"-0.707\",\n        \"-0x0.b50#10\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"0.5\",\n        \"0x0.8#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"0.2\",\n        \"0x0.4#1\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"-0.5\",\n        \"-0x0.8#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"-0.2\",\n        \"-0x0.4#1\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"0.3179\",\n        \"0x0.516#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"0.3184\",\n        \"0x0.518#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"0.3179\",\n        \"0x0.516#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"0.3184\",\n        \"0x0.518#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"0.3184\",\n        \"0x0.518#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-0.3184\",\n        \"-0x0.518#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-0.3179\",\n        \"-0x0.516#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-0.3179\",\n        \"-0x0.516#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-0.3184\",\n        \"-0x0.518#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-0.3184\",\n        \"-0x0.518#10\",\n        Less,\n    );\n\n    // - rm == Floor || rm == Down in reciprocal_float_significand_short\n    test(\"1.5\", \"0x1.8#2\", 1, Down, \"0.5\", \"0x0.8#1\", Less);\n    // - rm == Ceiling || rm == Up in reciprocal_float_significand_short\n    test(\"1.5\", \"0x1.8#2\", 1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    // - ds_len > qs_2_len && rm != Nearest in reciprocal_float_significand_general\n    test(\n        \"2.4914040842493675536005152793625253098043524808533216867315977e-8\",\n        \"0x6.b014710df6d8d0fb1901206ed24e1e002b4411ac77d2348fd2E-7#202\",\n        15,\n        Up,\n        \"4.0139e7\",\n        \"0x2.6478E+6#15\",\n        Greater,\n    );\n    // - rm != Nearest && (rm != Ceiling && rm != Up || inex == Equal) && (rm != Exact || inex !=\n    //   Equal) in reciprocal_float_significand_general\n    // - cleanup == Sub1Ulp in reciprocal_float_significand_general\n    test(\n        \"1164607425.036820041559\",\n        \"0x456a7fc1.096d09ca55#71\",\n        64,\n        Down,\n        \"8.586584444697183348e-10\",\n        \"0x3.b01add9bdcc8ca28E-8#64\",\n        Less,\n    );\n    // - cmp_s_r > Equal && (rm == Ceiling || rm == Up) in reciprocal_float_significand_general\n    // - cmp_s_r > Equal && (rm == Ceiling || rm == Up) && shift != 0 in\n    //   reciprocal_float_significand_general\n    test(\n        \"18686733767405.50192797818236099916512095073138146049740456616\",\n        \"0x10fed820d2ed.807e5a1b3d9ab71287cc373ef7f3521609fa72f#201\",\n        63,\n        Up,\n        \"5.3513899884647508956e-14\",\n        \"0xf.1015372ed29c6dcE-12#63\",\n        Greater,\n    );\n    // - cmp_s_r > Equal && (rm == Floor || rm == Down) in reciprocal_float_significand_general\n    // - cmp_s_r > Equal && (rm == Floor || rm == Down) && shift != 0 in\n    //   reciprocal_float_significand_general\n    test(\n        \"18686733767405.50192797818236099916512095073138146049740456616\",\n        \"0x10fed820d2ed.807e5a1b3d9ab71287cc373ef7f3521609fa72f#201\",\n        63,\n        Down,\n        \"5.351389988464750895e-14\",\n        \"0xf.1015372ed29c6daE-12#63\",\n        Less,\n    );\n    // - cmp_s_r > Equal && (rm == Ceiling || rm == Up) && shift == 0 in\n    //   reciprocal_float_significand_general\n    test(\n        \"1.063382396643406948814112e37\",\n        \"0x8.000000007ffffffffff8E+30#81\",\n        64,\n        Up,\n        \"9.4039548064414545111e-38\",\n        \"0x1.ffffffffe0000002E-31#64\",\n        Greater,\n    );\n    // - cmp_s_r > Equal && (rm == Floor || rm == Down) && shift == 0 in\n    //   reciprocal_float_significand_general\n    test(\n        \"1.063382396643406948814112e37\",\n        \"0x8.000000007ffffffffff8E+30#81\",\n        64,\n        Down,\n        \"9.4039548064414545106e-38\",\n        \"0x1.ffffffffe0000000E-31#64\",\n        Less,\n    );\n    // - exp > Self::MAX_EXPONENT in reciprocal\n    // - exp > Self::MAX_EXPONENT && sign && Ceiling | Up | Nearest in reciprocal\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        2,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // exp > Self::MAX_EXPONENT && sign && Floor | Down in reciprocal\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        2,\n        Floor,\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Less,\n    );\n    // - exp > Self::MAX_EXPONENT && !sign && Floor | Up | Nearest\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        2,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    // - exp > Self::MAX_EXPONENT && !sign && Ceiling | Down in reciprocal\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        2,\n        Ceiling,\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        Greater,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        Floor,\n        \"too_small\",\n        \"0x4.0E-268435456#1\",\n        Equal,\n    );\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        2,\n        Floor,\n        \"too_small\",\n        \"0x2.0E-268435456#2\",\n        Less,\n    );\n    test(\n        \"too_big\",\n        \"0x7.0E+268435455#3\",\n        3,\n        Floor,\n        \"too_small\",\n        \"0x2.0E-268435456#3\",\n        Less,\n    );\n    test(\n        \"too_big\",\n        \"0x7.ffffE+268435455#19\",\n        19,\n        Floor,\n        \"too_small\",\n        \"0x2.00000E-268435456#19\",\n        Less,\n    );\n}\n\n#[test]\nfn reciprocal_prec_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::one_prec(1).reciprocal_prec_round(0, Floor));\n    assert_panic!(Float::one_prec(1).reciprocal_prec_round_ref(0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.reciprocal_prec_round_assign(0, Floor)\n    });\n\n    assert_panic!(THREE.reciprocal_prec_round(1, Exact));\n    assert_panic!(THREE.reciprocal_prec_round_ref(1, Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.reciprocal_prec_round_assign(1, Exact)\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode, extreme: bool) {\n    let (reciprocal, o) = x.clone().reciprocal_prec_round(prec, rm);\n    assert!(reciprocal.is_valid());\n    let (reciprocal_alt, o_alt) = x.reciprocal_prec_round_ref(prec, rm);\n    assert!(reciprocal_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.reciprocal_prec_round_assign(prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&reciprocal));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_1(x.clone(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n    }\n    let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_2(x.clone(), prec, rm);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_reciprocal, rug_o) =\n            rug_reciprocal_prec_round(&rug::Float::exact_from(&x), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal)),\n            ComparableFloatRef(&reciprocal),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && reciprocal.is_finite() && reciprocal != 0 {\n        assert_eq!(\n            ComparableFloatRef(\n                &reciprocal\n                    .reciprocal_prec_round_ref(x.significant_bits(), Exact)\n                    .0\n            ),\n            ComparableFloatRef(&x)\n        );\n    }\n\n    let (reciprocal_alt, o_alt) = Float::ONE.div_prec_round(x.clone(), prec, rm);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    if reciprocal.is_finite() && x.is_finite() {\n        if reciprocal.is_normal() {\n            assert_eq!(reciprocal.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_reciprocal = Rational::exact_from(&x).reciprocal();\n            assert_eq!(reciprocal.partial_cmp(&r_reciprocal), Some(o));\n            if o == Less {\n                let mut next = reciprocal.clone();\n                next.increment();\n                assert!(next > r_reciprocal);\n            } else if o == Greater {\n                let mut next = reciprocal.clone();\n                next.decrement();\n                assert!(next < r_reciprocal);\n            }\n            match (r_reciprocal >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (mut reciprocal_alt, mut o_alt) = (-&x).reciprocal_prec_round(prec, -rm);\n    reciprocal_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(reciprocal_alt.abs_negative_zero()),\n        ComparableFloat(reciprocal.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.reciprocal_prec_round_ref(prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(reciprocal.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.reciprocal_prec_round_ref(prec, Exact));\n    }\n}\n\n#[test]\nfn reciprocal_prec_round_properties() {\n    float_unsigned_rounding_mode_triple_gen_var_3().test_properties(|(x, prec, rm)| {\n        reciprocal_prec_round_properties_helper(x, prec, rm, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_unsigned_rounding_mode_triple_gen_var_3().test_properties_with_config(\n        &config,\n        |(x, prec, rm)| {\n            reciprocal_prec_round_properties_helper(x, prec, rm, false);\n        },\n    );\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"mean_small_n\", 2048);\n    float_unsigned_rounding_mode_triple_gen_var_3().test_properties_with_config(\n        &config,\n        |(x, prec, rm)| {\n            reciprocal_prec_round_properties_helper(x, prec, rm, false);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_12().test_properties(|(x, prec, rm)| {\n        reciprocal_prec_round_properties_helper(x, prec, rm, true);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {\n        let (reciprocal, o) = Float::NAN.reciprocal_prec_round(prec, rm);\n        assert!(reciprocal.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(\n            Float::INFINITY.reciprocal_prec_round(prec, rm),\n            (Float::ZERO, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.reciprocal_prec_round(prec, rm),\n            (Float::NEGATIVE_ZERO, Equal)\n        );\n        assert_eq!(\n            Float::ZERO.reciprocal_prec_round(prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_ZERO.reciprocal_prec_round(prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::ONE.reciprocal_prec_round(prec, rm),\n            (Float::one_prec(prec), Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_ONE.reciprocal_prec_round(prec, rm),\n            (Float::negative_one_prec(prec), Equal)\n        );\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_prec_properties_helper(x: Float, prec: u64, extreme: bool) {\n    let (reciprocal, o) = x.clone().reciprocal_prec(prec);\n    assert!(reciprocal.is_valid());\n    let (reciprocal_alt, o_alt) = x.reciprocal_prec_ref(prec);\n    assert!(reciprocal_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.reciprocal_prec_assign(prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&reciprocal));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_1(x.clone(), prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n    }\n    let (reciprocal_alt, o_alt) = reciprocal_prec_round_naive_2(x.clone(), prec, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    let (rug_reciprocal, rug_o) = rug_reciprocal_prec(&rug::Float::exact_from(&x), prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_reciprocal)),\n        ComparableFloatRef(&reciprocal),\n    );\n    assert_eq!(rug_o, o);\n\n    let (reciprocal_alt, o_alt) = Float::ONE.div_prec(x.clone(), prec);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    if reciprocal.is_finite() && x.is_finite() {\n        if reciprocal.is_normal() {\n            assert_eq!(reciprocal.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_reciprocal = Rational::exact_from(&x).reciprocal();\n            assert_eq!(reciprocal.partial_cmp(&r_reciprocal), Some(o));\n            if o == Less {\n                let mut next = reciprocal.clone();\n                next.increment();\n                assert!(next > r_reciprocal);\n            } else if o == Greater {\n                let mut next = reciprocal.clone();\n                next.decrement();\n                assert!(next < r_reciprocal);\n            }\n        }\n    }\n\n    let (mut reciprocal_alt, mut o_alt) = (-&x).reciprocal_prec(prec);\n    reciprocal_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(reciprocal_alt.abs_negative_zero()),\n        ComparableFloat(reciprocal.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n}\n\n#[test]\nfn reciprocal_prec_properties() {\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        reciprocal_prec_properties_helper(x, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_unsigned_pair_gen_var_1().test_properties_with_config(&config, |(x, prec)| {\n        reciprocal_prec_properties_helper(x, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"mean_small_n\", 2048);\n    float_unsigned_pair_gen_var_1().test_properties_with_config(&config, |(x, prec)| {\n        reciprocal_prec_properties_helper(x, prec, false);\n    });\n\n    float_unsigned_pair_gen_var_4().test_properties(|(x, prec)| {\n        reciprocal_prec_properties_helper(x, prec, true);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (reciprocal, o) = Float::NAN.reciprocal_prec(prec);\n        assert!(reciprocal.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.reciprocal_prec(prec), (Float::ZERO, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.reciprocal_prec(prec),\n            (Float::NEGATIVE_ZERO, Equal)\n        );\n        assert_eq!(Float::ZERO.reciprocal_prec(prec), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_ZERO.reciprocal_prec(prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::ONE.reciprocal_prec(prec),\n            (Float::one_prec(prec), Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_ONE.reciprocal_prec(prec),\n            (Float::negative_one_prec(prec), Equal)\n        );\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_round_properties_helper(x: Float, rm: RoundingMode, extreme: bool) {\n    let (reciprocal, o) = x.clone().reciprocal_round(rm);\n    assert!(reciprocal.is_valid());\n    let (reciprocal_alt, o_alt) = x.reciprocal_round_ref(rm);\n    assert!(reciprocal_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.reciprocal_round_assign(rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&reciprocal));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (reciprocal_alt, o_alt) =\n            reciprocal_prec_round_naive_1(x.clone(), x.significant_bits(), rm);\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_alt),\n            ComparableFloatRef(&reciprocal)\n        );\n        assert_eq!(o_alt, o);\n    }\n    let (reciprocal_alt, o_alt) =\n        reciprocal_prec_round_naive_2(x.clone(), x.significant_bits(), rm);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_reciprocal, rug_o) = rug_reciprocal_round(&rug::Float::exact_from(&x), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal)),\n            ComparableFloatRef(&reciprocal),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (reciprocal_alt, o_alt) = Float::ONE.div_round(x.clone(), rm);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n    assert_eq!(o_alt, o);\n\n    if reciprocal.is_finite() && x.is_finite() {\n        if reciprocal.is_normal() {\n            assert_eq!(reciprocal.get_prec(), Some(x.significant_bits()));\n        }\n        if !extreme {\n            let r_reciprocal = Rational::exact_from(&x).reciprocal();\n            assert_eq!(reciprocal.partial_cmp(&r_reciprocal), Some(o));\n            if o == Less {\n                let mut next = reciprocal.clone();\n                next.increment();\n                assert!(next > r_reciprocal);\n            } else if o == Greater {\n                let mut next = reciprocal.clone();\n                next.decrement();\n                assert!(next < r_reciprocal);\n            }\n            match (r_reciprocal >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (mut reciprocal_alt, mut o_alt) = (-&x).reciprocal_round(-rm);\n    reciprocal_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(reciprocal_alt.abs_negative_zero()),\n        ComparableFloat(reciprocal.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.reciprocal_round_ref(rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(reciprocal.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.reciprocal_round_ref(Exact));\n    }\n}\n\n#[test]\nfn reciprocal_round_properties() {\n    float_rounding_mode_pair_gen_var_13().test_properties(|(x, rm)| {\n        reciprocal_round_properties_helper(x, rm, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_rounding_mode_pair_gen_var_13().test_properties_with_config(&config, |(x, rm)| {\n        reciprocal_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_14().test_properties(|(x, rm)| {\n        reciprocal_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_15().test_properties(|(x, rm)| {\n        reciprocal_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_16().test_properties(|(x, rm)| {\n        reciprocal_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_17().test_properties(|(x, rm)| {\n        reciprocal_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_23().test_properties(|(x, rm)| {\n        reciprocal_round_properties_helper(x, rm, true);\n    });\n\n    rounding_mode_gen().test_properties(|rm| {\n        let (reciprocal, o) = Float::NAN.reciprocal_round(rm);\n        assert!(reciprocal.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.reciprocal_round(rm), (Float::ZERO, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.reciprocal_round(rm),\n            (Float::NEGATIVE_ZERO, Equal)\n        );\n        assert_eq!(Float::ZERO.reciprocal_round(rm), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_ZERO.reciprocal_round(rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        assert_eq!(Float::ONE.reciprocal_round(rm), (Float::ONE, Equal));\n        assert_eq!(\n            Float::NEGATIVE_ONE.reciprocal_round(rm),\n            (Float::NEGATIVE_ONE, Equal)\n        );\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn reciprocal_properties_helper_2<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_gen::<T>().test_properties(|x| {\n        let reciprocal_1 = x.reciprocal();\n        let reciprocal_2 = emulate_float_to_float_fn(Float::reciprocal_prec, x);\n        assert_eq!(NiceFloat(reciprocal_1), NiceFloat(reciprocal_2));\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_properties_helper_1(x: Float, extreme: bool) {\n    let reciprocal = x.clone().reciprocal();\n    assert!(reciprocal.is_valid());\n\n    let reciprocal_alt = (&x).reciprocal();\n    assert!(reciprocal_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_alt),\n        ComparableFloatRef(&reciprocal)\n    );\n\n    let mut x_alt = x.clone();\n    x_alt.reciprocal_assign();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&reciprocal));\n\n    if !extreme {\n        assert_eq!(\n            ComparableFloatRef(\n                &reciprocal_prec_round_naive_1(x.clone(), x.significant_bits(), Nearest).0\n            ),\n            ComparableFloatRef(&reciprocal)\n        );\n    }\n    assert_eq!(\n        ComparableFloatRef(\n            &reciprocal_prec_round_naive_2(x.clone(), x.significant_bits(), Nearest).0\n        ),\n        ComparableFloatRef(&reciprocal)\n    );\n\n    let rug_reciprocal = rug_reciprocal(&rug::Float::exact_from(&x));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_reciprocal)),\n        ComparableFloatRef(&reciprocal),\n    );\n\n    assert_eq!(\n        ComparableFloatRef(&(Float::ONE / x.clone())),\n        ComparableFloatRef(&reciprocal)\n    );\n\n    if reciprocal.is_finite() && x.is_finite() {\n        if reciprocal.is_normal() {\n            assert_eq!(reciprocal.get_prec(), Some(x.significant_bits()));\n        }\n        if !extreme {\n            let r_reciprocal = Rational::exact_from(&x).reciprocal();\n            if reciprocal < r_reciprocal {\n                let mut next = reciprocal.clone();\n                next.increment();\n                assert!(next > r_reciprocal);\n            } else if reciprocal > r_reciprocal {\n                let mut next = reciprocal.clone();\n                next.decrement();\n                assert!(next < r_reciprocal);\n            }\n        }\n    }\n\n    let mut reciprocal_alt = (-&x).reciprocal();\n    reciprocal_alt.neg_assign();\n    assert_eq!(\n        ComparableFloat(reciprocal_alt.abs_negative_zero()),\n        ComparableFloat(reciprocal.abs_negative_zero_ref())\n    );\n}\n\n#[test]\nfn reciprocal_properties() {\n    float_gen().test_properties(|x| {\n        reciprocal_properties_helper_1(x, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_gen().test_properties_with_config(&config, |x| {\n        reciprocal_properties_helper_1(x, false);\n    });\n\n    float_gen_var_6().test_properties(|x| {\n        reciprocal_properties_helper_1(x, false);\n    });\n\n    float_gen_var_7().test_properties(|x| {\n        reciprocal_properties_helper_1(x, false);\n    });\n\n    float_gen_var_8().test_properties(|x| {\n        reciprocal_properties_helper_1(x, false);\n    });\n\n    float_gen_var_11().test_properties(|x| {\n        reciprocal_properties_helper_1(x, false);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        reciprocal_properties_helper_1(x, true);\n    });\n\n    apply_fn_to_primitive_floats!(reciprocal_properties_helper_2);\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/reciprocal_sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\nuse core::{f32, f64};\nuse malachite_base::num::arithmetic::traits::{\n    PowerOf2, Reciprocal, ReciprocalSqrt, ReciprocalSqrtAssign, Square,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, rounding_mode_gen, unsigned_gen_var_11,\n    unsigned_rounding_mode_pair_gen_var_3,\n};\nuse malachite_float::arithmetic::reciprocal_sqrt::{\n    primitive_float_reciprocal_sqrt, primitive_float_reciprocal_sqrt_rational,\n};\nuse malachite_float::test_util::arithmetic::reciprocal_sqrt::{\n    reciprocal_sqrt_rational_prec_round_generic, reciprocal_sqrt_rational_prec_round_simple,\n    rug_reciprocal_sqrt, rug_reciprocal_sqrt_prec, rug_reciprocal_sqrt_prec_round,\n    rug_reciprocal_sqrt_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_12, float_rounding_mode_pair_gen_var_30,\n    float_rounding_mode_pair_gen_var_31, float_unsigned_pair_gen_var_1,\n    float_unsigned_pair_gen_var_4, float_unsigned_rounding_mode_triple_gen_var_15,\n    float_unsigned_rounding_mode_triple_gen_var_16,\n    rational_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen_var_1, rational_pair_gen_var_8, rational_unsigned_pair_gen_var_7,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_reciprocal_sqrt() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let reciprocal_sqrt = x.clone().reciprocal_sqrt();\n        assert!(reciprocal_sqrt.is_valid());\n\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n\n        let reciprocal_sqrt_alt = (&x).reciprocal_sqrt();\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n\n        let mut reciprocal_sqrt_alt = x.clone();\n        reciprocal_sqrt_alt.reciprocal_sqrt_assign();\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt(&rug::Float::exact_from(\n                &x\n            )))),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\");\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\");\n    test(\"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\");\n    // - working_prec < limb_to_bit_count(rn) in limbs_reciprocal_sqrt\n    // - in limbs_reciprocal_sqrt\n    // - an <= n in limbs_reciprocal_sqrt\n    // - p > 11 in limbs_reciprocal_sqrt\n    // - ahn <= an in limbs_reciprocal_sqrt\n    // - p == 11 in limbs_reciprocal_sqrt\n    // - h << 1 <= Limb::WIDTH in limbs_reciprocal_sqrt\n    // - rn == 1 in limbs_reciprocal_sqrt\n    // - neg == 0 first time in limbs_reciprocal_sqrt\n    // - tn == 1 in limbs_reciprocal_sqrt\n    // - !a_s in limbs_reciprocal_sqrt\n    // - pl != 0 in limbs_reciprocal_sqrt\n    // - neg == 0 second time in limbs_reciprocal_sqrt\n    // - neg == 0 && ln == 0 in limbs_reciprocal_sqrt\n    // - cy != 0 in limbs_reciprocal_sqrt\n    // - h << 1 > Limb::WIDTH && xn == 1 in limbs_reciprocal_sqrt\n    // - rn != 1 in limbs_reciprocal_sqrt\n    // - tn != 1 in limbs_reciprocal_sqrt\n    // - pl == 0 in limbs_reciprocal_sqrt\n    // - can't round in limbs_reciprocal_sqrt\n    // - s == 0 && x.is_power_of_2() in limbs_reciprocal_sqrt\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"-1.0\", \"-0x1.0#1\", \"NaN\", \"NaN\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n    );\n    test(\"-1.0\", \"-0x1.0000000000000000000000000#100\", \"NaN\", \"NaN\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"0.09\", \"0x0.170#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0.5641895835477563\",\n        \"0x0.906eba8214db68#53\",\n    );\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"NaN\", \"NaN\");\n}\n\n#[test]\nfn test_reciprocal_sqrt_prec() {\n    let test = |s, s_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (reciprocal_sqrt, o) = x.clone().reciprocal_sqrt_prec(prec);\n        assert!(reciprocal_sqrt.is_valid());\n\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, o_out);\n\n        let (reciprocal_sqrt_alt, o_alt) = x.reciprocal_sqrt_prec_ref(prec);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut reciprocal_sqrt_alt = x.clone();\n        let o_alt = reciprocal_sqrt_alt.reciprocal_sqrt_prec_assign(prec);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let (rug_reciprocal_sqrt, rug_o) =\n            rug_reciprocal_sqrt_prec(&rug::Float::exact_from(&x), prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt)),\n            ComparableFloatRef(&reciprocal_sqrt),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"NaN\", \"NaN\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"NaN\", \"NaN\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 1, \"0.06\", \"0x0.1#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 10, \"0.0902\", \"0x0.1718#10\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"NaN\", \"NaN\", Equal);\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.564\",\n        \"0x0.908#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    // - a_s in limbs_reciprocal_sqrt\n    // - cy == 0 in limbs_reciprocal_sqrt\n    // - neg != 0 first time in limbs_reciprocal_sqrt\n    // - neg != 0 second time in limbs_reciprocal_sqrt\n    // - neg != 0 && ln == 0 in limbs_reciprocal_sqrt\n    // - can round in limbs_reciprocal_sqrt\n    test(\"2.0\", \"0x2.0#1\", 1, \"0.5\", \"0x0.8#1\", Less);\n    // - neg == 0 && ln != 0 in limbs_reciprocal_sqrt\n    // - h << 1 > Limb::WIDTH && xn != 1 in limbs_reciprocal_sqrt\n    // - rn < xn << 1 in limbs_reciprocal_sqrt\n    test(\n        \"21729783659306408649613509.686\",\n        \"0x11f975eebbcb21a32ee0c5.af8#95\",\n        95,\n        \"2.14522227948652325458263602314e-13\",\n        \"0x3.c61f4a318617d94043119898E-11#95\",\n        Less,\n    );\n    // - working_prec >= limb_to_bit_count(rn) in limbs_reciprocal_sqrt\n    // - neg != 0 && ln != 0 in limbs_reciprocal_sqrt\n    test(\n        \"513.233925441497129966680656795646506\",\n        \"0x201.3be289a8eeba947a6a3693540ab#118\",\n        118,\n        \"0.0441410156743607347324939524894430093\",\n        \"0x0.0b4cd35abbcd63a67e82b6f5189c42c#118\",\n        Less,\n    );\n    // - rn >= xn << 1 in limbs_reciprocal_sqrt\n    test(\n        \"531607.999405753398566100250398911805595276409254333486007034444758646220477451\",\n        \"0x81c97.ffd90e3247f501afdb3e5781d0c650b8de694094110713b5a698d3d38550#257\",\n        257,\n        \"0.00137152663593666837873986552665405007986703190176786715506823381645265890475571\",\n        \"0x0.0059e2660c04516f28e8c959120460810dbcbbd967b4a8d1f95cf325678e624d8b8#257\",\n        Less,\n    );\n    // - s != 0 || !x.is_power_of_2() in limbs_reciprocal_sqrt\n    // - ahn > an in limbs_reciprocal_sqrt\n    test(\n        \"2.97703041169639178e-21\",\n        \"0xe.0f0249448dd1dE-18#56\",\n        56,\n        \"18327716753.4591751\",\n        \"0x4446ac391.758c80#56\",\n        Less,\n    );\n    // - an > n in limbs_reciprocal_sqrt\n    test(\n        \"0.000199046277632504184666664672269768242929310652018203552191617720205649\",\n        \"0x0.000d0b7140b8f3aea60aad60c1dc3b2ee0d83e2eba33dcfb6f874df52d78#225\",\n        26,\n        \"70.879879\",\n        \"0x46.e13fc#26\",\n        Less,\n    );\n}\n\n#[test]\nfn reciprocal_sqrt_prec_fail() {\n    assert_panic!(Float::NAN.reciprocal_sqrt_prec(0));\n    assert_panic!(Float::NAN.reciprocal_sqrt_prec_ref(0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.reciprocal_sqrt_prec_assign(0)\n    });\n}\n\n#[test]\nfn test_reciprocal_sqrt_round() {\n    let test = |s, s_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (reciprocal_sqrt, o) = x.clone().reciprocal_sqrt_round(rm);\n        assert!(reciprocal_sqrt.is_valid());\n\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, o_out);\n\n        let (reciprocal_sqrt_alt, o_alt) = x.reciprocal_sqrt_round_ref(rm);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut reciprocal_sqrt_alt = x.clone();\n        let o_alt = reciprocal_sqrt_alt.reciprocal_sqrt_round_assign(rm);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_reciprocal_sqrt, rug_o) =\n                rug_reciprocal_sqrt_round(&rug::Float::exact_from(&x), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt)),\n                ComparableFloatRef(&reciprocal_sqrt),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", Floor, \"0.09\", \"0x0.170#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Ceiling, \"0.091\", \"0x0.174#7\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", Down, \"0.09\", \"0x0.170#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Up, \"0.091\", \"0x0.174#7\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", Nearest, \"0.09\", \"0x0.170#7\", Less);\n\n    test(\"-123.0\", \"-0x7b.0#7\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"0.5641895835477563\",\n        \"0x0.906eba8214db68#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"0.5641895835477564\",\n        \"0x0.906eba8214db70#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"0.5641895835477563\",\n        \"0x0.906eba8214db68#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"0.5641895835477564\",\n        \"0x0.906eba8214db70#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"0.5641895835477563\",\n        \"0x0.906eba8214db68#53\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n}\n\n#[test]\nfn reciprocal_sqrt_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(THREE.reciprocal_sqrt_round(Exact));\n    assert_panic!(THREE.reciprocal_sqrt_round_ref(Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.reciprocal_sqrt_round_assign(Exact);\n    });\n}\n\n#[test]\nfn test_reciprocal_sqrt_prec_round() {\n    let test = |s, s_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (reciprocal_sqrt, o) = x.clone().reciprocal_sqrt_prec_round(prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, o_out);\n\n        let (reciprocal_sqrt_alt, o_alt) = x.reciprocal_sqrt_prec_round_ref(prec, rm);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        let mut reciprocal_sqrt_alt = x.clone();\n        let o_alt = reciprocal_sqrt_alt.reciprocal_sqrt_prec_round_assign(prec, rm);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt),\n            ComparableFloatRef(&reciprocal_sqrt_alt)\n        );\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_reciprocal_sqrt, rug_o) =\n                rug_reciprocal_sqrt_prec_round(&rug::Float::exact_from(&x), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt)),\n                ComparableFloatRef(&reciprocal_sqrt),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", 1, Floor, \"0.06\", \"0x0.1#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Ceiling, \"0.1\", \"0x0.2#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 1, Down, \"0.06\", \"0x0.1#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Up, \"0.1\", \"0x0.2#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 1, Nearest, \"0.06\", \"0x0.1#1\", Less);\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"0.0901\",\n        \"0x0.1710#10\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"0.0902\",\n        \"0x0.1718#10\",\n        Greater,\n    );\n    test(\"123.0\", \"0x7b.0#7\", 10, Down, \"0.0901\", \"0x0.1710#10\", Less);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"0.0902\",\n        \"0x0.1718#10\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"0.0902\",\n        \"0x0.1718#10\",\n        Greater,\n    );\n\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"0.5\",\n        \"0x0.8#1\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"0.563\",\n        \"0x0.904#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"0.564\",\n        \"0x0.908#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"0.563\",\n        \"0x0.904#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"0.564\",\n        \"0x0.908#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"0.564\",\n        \"0x0.908#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n}\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_primitive_float_reciprocal_sqrt() {\n    fn test<T: PrimitiveFloat>(x: T, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n    {\n        assert_eq!(\n            NiceFloat(primitive_float_reciprocal_sqrt(x)),\n            NiceFloat(out)\n        );\n    }\n    test::<f32>(f32::NAN, f32::NAN);\n    test::<f32>(f32::INFINITY, 0.0);\n    test::<f32>(f32::NEGATIVE_INFINITY, f32::NAN);\n    test::<f32>(0.0, f32::INFINITY);\n    test::<f32>(-0.0, f32::INFINITY);\n    test::<f32>(1.0, 1.0);\n    test::<f32>(-1.0, f32::NAN);\n    test::<f32>(0.5, core::f32::consts::SQRT_2);\n    test::<f32>(-0.5, f32::NAN);\n    test::<f32>(2.0, core::f32::consts::FRAC_1_SQRT_2);\n    test::<f32>(-2.0, f32::NAN);\n    test::<f32>(core::f32::consts::PI, 0.56418955);\n    test::<f32>(-core::f32::consts::PI, f32::NAN);\n\n    test::<f64>(f64::NAN, f64::NAN);\n    test::<f64>(f64::INFINITY, 0.0);\n    test::<f64>(f64::NEGATIVE_INFINITY, f64::NAN);\n    test::<f64>(0.0, f64::INFINITY);\n    test::<f64>(-0.0, f64::INFINITY);\n    test::<f64>(1.0, 1.0);\n    test::<f64>(-1.0, f64::NAN);\n    test::<f64>(0.5, core::f64::consts::SQRT_2);\n    test::<f64>(-0.5, f64::NAN);\n    test::<f64>(2.0, core::f64::consts::FRAC_1_SQRT_2);\n    test::<f64>(-2.0, f64::NAN);\n    test::<f64>(core::f64::consts::PI, 0.5641895835477563);\n    test::<f64>(-core::f64::consts::PI, f64::NAN);\n}\n\n#[test]\nfn test_reciprocal_sqrt_rational_prec() {\n    let test = |s, prec, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec(u.clone(), prec);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec_ref(&u, prec);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_generic(&u, prec, Nearest);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_simple(&u, prec, Nearest);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square > u);\n                    let mut next = reciprocal_sqrt.clone();\n                    next.increment();\n                    if next != 0u32 {\n                        assert!(Rational::exact_from(&next).square().reciprocal() < u);\n                    }\n                }\n                Greater => {\n                    assert!(square < u);\n                    let mut previous = reciprocal_sqrt.clone();\n                    previous.decrement();\n                    if previous != 0u32 {\n                        assert!(Rational::exact_from(&previous).square().reciprocal() > u);\n                    }\n                }\n            }\n        }\n    };\n    test(\"0\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 10, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 100, \"Infinity\", \"Infinity\", Equal);\n    test(\"1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 100, \"1.0\", \"0x1.0000000000000000000000000#100\", Equal);\n    test(\"1/2\", 1, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1/2\", 10, \"1.414\", \"0x1.6a0#10\", Less);\n    test(\n        \"1/2\",\n        100,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n    test(\"1/3\", 1, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1/3\", 10, \"1.732\", \"0x1.bb8#10\", Greater);\n    test(\n        \"1/3\",\n        100,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n    test(\"22/7\", 1, \"0.5\", \"0x0.8#1\", Less);\n    test(\"22/7\", 10, \"0.564\", \"0x0.908#10\", Greater);\n    test(\n        \"22/7\",\n        100,\n        \"0.5640760748177662089151473616116\",\n        \"0x0.90674a25cc60febbd6cc7515c#100\",\n        Greater,\n    );\n\n    let test_big = |u: Rational, prec, out, out_hex, out_o| {\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec(u.clone(), prec);\n        assert!(reciprocal_sqrt.is_valid());\n\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec_ref(&u, prec);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_generic(&u, prec, Nearest);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_simple(&u, prec, Nearest);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square > u);\n                    let mut next = reciprocal_sqrt.clone();\n                    next.increment();\n                    if next != 0u32 {\n                        assert!(Rational::exact_from(&next).square().reciprocal() < u);\n                    }\n                }\n                Greater => {\n                    assert!(square < u);\n                    let mut previous = reciprocal_sqrt.clone();\n                    previous.decrement();\n                    if previous != 0 {\n                        assert!(Rational::exact_from(&previous).square().reciprocal() > u);\n                    }\n                }\n            }\n        }\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"too_small\",\n        \"0x2.00E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        \"too_big\",\n        \"0x1.000E+134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n}\n\n#[test]\nfn reciprocal_sqrt_rational_prec_fail() {\n    assert_panic!(Float::reciprocal_sqrt_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec(Rational::ONE, 0));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec(\n        Rational::NEGATIVE_ONE,\n        0\n    ));\n}\n\n#[test]\nfn reciprocal_sqrt_rational_prec_ref_fail() {\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_ref(&Rational::ONE, 0));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_ref(\n        &Rational::NEGATIVE_ONE,\n        0\n    ));\n}\n\n#[test]\nfn test_reciprocal_sqrt_rational_prec_round() {\n    let test = |s, prec, rm, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec_round(u.clone(), prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(&u, prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_generic(&u, prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_simple(&u, prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square > u);\n                    let mut next = reciprocal_sqrt.clone();\n                    next.increment();\n                    if next != 0u32 {\n                        assert!(Rational::exact_from(&next).square().reciprocal() < u);\n                    }\n                }\n                Greater => {\n                    assert!(square < u);\n                    let mut previous = reciprocal_sqrt.clone();\n                    previous.decrement();\n                    if previous != 0u32 {\n                        assert!(Rational::exact_from(&previous).square().reciprocal() > u);\n                    }\n                }\n            }\n        }\n    };\n    test(\"0\", 1, Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 1, Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 1, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"0\", 10, Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 10, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 10, Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 10, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 10, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 10, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"0\", 100, Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 100, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 100, Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 100, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 100, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test(\"0\", 100, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\n        \"1\",\n        100,\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"1/2\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1/2\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1/2\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1/2\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1/2\", 1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test(\"1/2\", 10, Floor, \"1.414\", \"0x1.6a0#10\", Less);\n    test(\"1/2\", 10, Ceiling, \"1.416\", \"0x1.6a8#10\", Greater);\n    test(\"1/2\", 10, Down, \"1.414\", \"0x1.6a0#10\", Less);\n    test(\"1/2\", 10, Up, \"1.416\", \"0x1.6a8#10\", Greater);\n    test(\"1/2\", 10, Nearest, \"1.414\", \"0x1.6a0#10\", Less);\n\n    test(\n        \"1/2\",\n        100,\n        Floor,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n    test(\n        \"1/2\",\n        100,\n        Ceiling,\n        \"1.414213562373095048801688724211\",\n        \"0x1.6a09e667f3bcc908b2fb13670#100\",\n        Greater,\n    );\n    test(\n        \"1/2\",\n        100,\n        Down,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n    test(\n        \"1/2\",\n        100,\n        Up,\n        \"1.414213562373095048801688724211\",\n        \"0x1.6a09e667f3bcc908b2fb13670#100\",\n        Greater,\n    );\n    test(\n        \"1/2\",\n        100,\n        Nearest,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n\n    test(\"1/3\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1/3\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1/3\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1/3\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"1/3\", 1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test(\"1/3\", 10, Floor, \"1.73\", \"0x1.bb0#10\", Less);\n    test(\"1/3\", 10, Ceiling, \"1.732\", \"0x1.bb8#10\", Greater);\n    test(\"1/3\", 10, Down, \"1.73\", \"0x1.bb0#10\", Less);\n    test(\"1/3\", 10, Up, \"1.732\", \"0x1.bb8#10\", Greater);\n    test(\"1/3\", 10, Nearest, \"1.732\", \"0x1.bb8#10\", Greater);\n\n    test(\n        \"1/3\",\n        100,\n        Floor,\n        \"1.732050807568877293527446341505\",\n        \"0x1.bb67ae8584caa73b25742d706#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Ceiling,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Down,\n        \"1.732050807568877293527446341505\",\n        \"0x1.bb67ae8584caa73b25742d706#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Up,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Nearest,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n\n    test(\"22/7\", 1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test(\"22/7\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"22/7\", 1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test(\"22/7\", 1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"22/7\", 1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test(\"22/7\", 10, Floor, \"0.563\", \"0x0.904#10\", Less);\n    test(\"22/7\", 10, Ceiling, \"0.564\", \"0x0.908#10\", Greater);\n    test(\"22/7\", 10, Down, \"0.563\", \"0x0.904#10\", Less);\n    test(\"22/7\", 10, Up, \"0.564\", \"0x0.908#10\", Greater);\n    test(\"22/7\", 10, Nearest, \"0.564\", \"0x0.908#10\", Greater);\n\n    test(\n        \"22/7\",\n        100,\n        Floor,\n        \"0.564076074817766208915147361611\",\n        \"0x0.90674a25cc60febbd6cc7515b#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Ceiling,\n        \"0.5640760748177662089151473616116\",\n        \"0x0.90674a25cc60febbd6cc7515c#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Down,\n        \"0.564076074817766208915147361611\",\n        \"0x0.90674a25cc60febbd6cc7515b#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Up,\n        \"0.5640760748177662089151473616116\",\n        \"0x0.90674a25cc60febbd6cc7515c#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Nearest,\n        \"0.5640760748177662089151473616116\",\n        \"0x0.90674a25cc60febbd6cc7515c#100\",\n        Greater,\n    );\n\n    test(\"-1\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n\n    let test_big = |u: Rational, prec, rm, out, out_hex, out_o| {\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec_round(u.clone(), prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec_round_ref(&u, prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_generic(&u, prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (reciprocal_sqrt, o) = reciprocal_sqrt_rational_prec_round_simple(&u, prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n        assert_eq!(reciprocal_sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&reciprocal_sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square > u);\n                    let mut next = reciprocal_sqrt.clone();\n                    next.increment();\n                    if next != 0u32 {\n                        assert!(Rational::exact_from(&next).square().reciprocal() < u);\n                    }\n                }\n                Greater => {\n                    assert!(square < u);\n                    let mut previous = reciprocal_sqrt.clone();\n                    previous.decrement();\n                    if previous != 0u32 {\n                        assert!(Rational::exact_from(&previous).square().reciprocal() > u);\n                    }\n                }\n            }\n        }\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Floor,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Ceiling,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Down,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Up,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Nearest,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Exact,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.6a8E-134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.6a8E-134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_small\",\n        \"0x2.00E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x2.00E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_small\",\n        \"0x2.00E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_small\",\n        \"0x2.00E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x2.00E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_small\",\n        \"0x2.00E-134217728#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-134217728#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-134217728#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Up,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-134217728#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-134217728#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Up,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-134217728#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-134217728#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Up,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x2.0E-134217728#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Floor,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Ceiling,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Down,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Up,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Nearest,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Exact,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Floor,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0xb.54E+134217727#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Down,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Up,\n        \"too_big\",\n        \"0xb.54E+134217727#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x1.000E+134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x1.000E+134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_big\",\n        \"0x1.000E+134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_big\",\n        \"0x1.000E+134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x1.000E+134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_big\",\n        \"0x1.000E+134217728#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x1.6a8E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Down,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Up,\n        \"too_big\",\n        \"0x1.6a8E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Down,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Up,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"too_big\",\n        \"0x1.698E+134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x1.6a0E+134217728#10\",\n        Greater,\n    );\n}\n\n#[test]\nfn reciprocal_sqrt_rational_prec_round_fail() {\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round(\n        Rational::ZERO,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round(\n        Rational::ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round(\n        Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round(\n        Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round(\n        Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n}\n\n#[test]\nfn reciprocal_sqrt_rational_prec_round_ref_fail() {\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round_ref(\n        &Rational::ZERO,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round_ref(\n        &Rational::ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round_ref(\n        &Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round_ref(\n        &Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::reciprocal_sqrt_rational_prec_round_ref(\n        &Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n}\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_primitive_float_reciprocal_sqrt_rational() {\n    fn test<T: PrimitiveFloat>(s: &str, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n        Rational: ExactFrom<T>,\n    {\n        let u = Rational::from_str(s).unwrap();\n        let reciprocal_sqrt = primitive_float_reciprocal_sqrt_rational::<T>(&u);\n        assert_eq!(NiceFloat(reciprocal_sqrt), NiceFloat(out));\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(reciprocal_sqrt).square().reciprocal();\n            match square.cmp(&u) {\n                Less => {\n                    let mut next = reciprocal_sqrt;\n                    next = next.next_lower();\n                    assert!(Rational::exact_from(next).square().reciprocal() > u);\n                }\n                Greater => {\n                    let mut previous = reciprocal_sqrt;\n                    previous = previous.next_higher();\n                    assert!(Rational::exact_from(previous).square().reciprocal() < u);\n                }\n                _ => {}\n            }\n        }\n    }\n    test::<f32>(\"0\", f32::INFINITY);\n    test::<f32>(\"1\", 1.0);\n    test::<f32>(\"1/2\", f32::consts::SQRT_2);\n    test::<f32>(\"1/3\", 1.7320508);\n    test::<f32>(\"22/7\", 0.56407607);\n    test::<f32>(\"1/225\", 15.0);\n    test::<f32>(\"-1\", f32::NAN);\n    test::<f32>(\"-1/2\", f32::NAN);\n    test::<f32>(\"-1/3\", f32::NAN);\n    test::<f32>(\"-22/7\", f32::NAN);\n\n    test::<f64>(\"0\", f64::INFINITY);\n    test::<f64>(\"1\", 1.0);\n    test::<f64>(\"1/2\", f64::consts::SQRT_2);\n    test::<f64>(\"1/3\", 1.7320508075688772);\n    test::<f64>(\"22/7\", 0.5640760748177662);\n    test::<f64>(\"1/225\", 15.0);\n    test::<f64>(\"-1\", f64::NAN);\n    test::<f64>(\"-1/2\", f64::NAN);\n    test::<f64>(\"-1/3\", f64::NAN);\n    test::<f64>(\"-22/7\", f64::NAN);\n\n    #[allow(clippy::needless_pass_by_value)]\n    fn test_big<T: PrimitiveFloat>(u: Rational, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n        Rational: ExactFrom<T>,\n    {\n        let reciprocal_sqrt = primitive_float_reciprocal_sqrt_rational::<T>(&u);\n        assert_eq!(NiceFloat(reciprocal_sqrt), NiceFloat(out));\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(reciprocal_sqrt).square().reciprocal();\n            match square.cmp(&u) {\n                Less => {\n                    let mut next = reciprocal_sqrt;\n                    next = next.next_lower();\n                    assert!(Rational::exact_from(next).square().reciprocal() > u);\n                }\n                Greater => {\n                    let mut previous = reciprocal_sqrt;\n                    previous = previous.next_higher();\n                    assert!(Rational::exact_from(previous).square().reciprocal() < u);\n                }\n                _ => {}\n            }\n        }\n    }\n    test_big::<f32>(Rational::power_of_2(1000i64), 0.0);\n    test_big::<f32>(Rational::power_of_2(-1000i64), f32::INFINITY);\n    test_big::<f32>(Rational::power_of_2(-290i64), f32::INFINITY);\n    test_big::<f32>(Rational::power_of_2(-200i64), 1.2676506e30);\n\n    test_big::<f64>(Rational::power_of_2(10000i64), 0.0);\n    test_big::<f64>(Rational::power_of_2(1000i64), 3.054936363499605e-151);\n    test_big::<f64>(Rational::power_of_2(-10000i64), f64::INFINITY);\n    test_big::<f64>(Rational::power_of_2(-2100i64), f64::INFINITY);\n    test_big::<f64>(Rational::power_of_2(-1000i64), 3.273390607896142e150);\n}\n\n#[test]\nfn reciprocal_sqrt_prec_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::one_prec(1).reciprocal_sqrt_prec_round(0, Floor));\n    assert_panic!(Float::one_prec(1).reciprocal_sqrt_prec_round_ref(0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.reciprocal_sqrt_prec_round_assign(0, Floor)\n    });\n\n    assert_panic!(THREE.reciprocal_sqrt_prec_round(1, Exact));\n    assert_panic!(THREE.reciprocal_sqrt_prec_round_ref(1, Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.reciprocal_sqrt_prec_round_assign(1, Exact)\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_sqrt_prec_round_properties_helper(\n    x: Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (reciprocal_sqrt, o) = x.clone().reciprocal_sqrt_prec_round(prec, rm);\n    assert!(reciprocal_sqrt.is_valid());\n\n    let (reciprocal_sqrt_alt, o_alt) = x.clone().reciprocal_sqrt_prec_round_ref(prec, rm);\n    assert!(reciprocal_sqrt_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.reciprocal_sqrt_prec_round_assign(prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&x_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_reciprocal_sqrt, rug_o) =\n            rug_reciprocal_sqrt_prec_round(&rug::Float::exact_from(&x), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt)),\n            ComparableFloatRef(&reciprocal_sqrt),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(reciprocal_sqrt.is_sign_positive());\n    }\n\n    if reciprocal_sqrt.is_normal() {\n        assert_eq!(reciprocal_sqrt.get_prec(), Some(prec));\n        if x > 1u32 && o < Greater {\n            assert!(reciprocal_sqrt < x);\n        } else if x < 1u32 && o > Less {\n            assert!(reciprocal_sqrt > x);\n        }\n    }\n\n    if !extreme && x.is_normal() && reciprocal_sqrt.is_normal() {\n        let reciprocal_square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n        match o {\n            Equal => assert_eq!(reciprocal_square, x),\n            Less => {\n                assert!(reciprocal_square > x);\n                let mut next = reciprocal_sqrt.clone();\n                next.increment();\n                if next != 0u32 {\n                    assert!(Rational::exact_from(&next).square().reciprocal() < x);\n                }\n            }\n            Greater => {\n                assert!(reciprocal_square < x);\n                let mut previous = reciprocal_sqrt.clone();\n                previous.decrement();\n                if previous != 0u32 {\n                    assert!(Rational::exact_from(&previous).square().reciprocal() > x);\n                }\n            }\n        }\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.reciprocal_sqrt_prec_round_ref(prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(reciprocal_sqrt.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.reciprocal_sqrt_prec_round_ref(prec, Exact));\n    }\n}\n\n#[test]\nfn reciprocal_sqrt_prec_round_properties() {\n    float_unsigned_rounding_mode_triple_gen_var_15().test_properties(|(x, prec, rm)| {\n        reciprocal_sqrt_prec_round_properties_helper(x, prec, rm, false);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_16().test_properties(|(x, prec, rm)| {\n        reciprocal_sqrt_prec_round_properties_helper(x, prec, rm, true);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {\n        let (product, o) = Float::NAN.reciprocal_sqrt_prec_round(prec, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        let (s, o) = Float::INFINITY.reciprocal_sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (s, o) = Float::NEGATIVE_INFINITY.reciprocal_sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n\n        let (s, o) = Float::ZERO.reciprocal_sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::INFINITY));\n        assert_eq!(o, Equal);\n\n        let (s, o) = Float::NEGATIVE_ZERO.reciprocal_sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::INFINITY));\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::ONE.reciprocal_sqrt_prec_round(prec, rm),\n            (Float::one_prec(prec), Equal)\n        );\n\n        let (s, o) = Float::NEGATIVE_ONE.reciprocal_sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_sqrt_prec_properties_helper(x: Float, prec: u64, extreme: bool) {\n    let (reciprocal_sqrt, o) = x.clone().reciprocal_sqrt_prec(prec);\n    assert!(reciprocal_sqrt.is_valid());\n\n    let (reciprocal_sqrt_alt, o_alt) = x.reciprocal_sqrt_prec_ref(prec);\n    assert!(reciprocal_sqrt_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.reciprocal_sqrt_prec_assign(prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&x_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    assert_eq!(o_alt, o);\n\n    let (rug_reciprocal_sqrt, rug_o) = rug_reciprocal_sqrt_prec(&rug::Float::exact_from(&x), prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt)),\n        ComparableFloatRef(&reciprocal_sqrt),\n    );\n    assert_eq!(rug_o, o);\n\n    let (reciprocal_sqrt_alt, o_alt) = x.reciprocal_sqrt_prec_round_ref(prec, Nearest);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    assert_eq!(o_alt, o);\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(reciprocal_sqrt.is_sign_positive());\n    }\n\n    if reciprocal_sqrt.is_normal() {\n        assert_eq!(reciprocal_sqrt.get_prec(), Some(prec));\n        if x > 1u32 && o < Greater {\n            assert!(reciprocal_sqrt < x);\n        } else if x < 1u32 && o > Less {\n            assert!(reciprocal_sqrt > x);\n        }\n    }\n\n    if !extreme && x.is_normal() && reciprocal_sqrt.is_normal() {\n        let reciprocal_square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n        match o {\n            Equal => assert_eq!(reciprocal_square, x),\n            Less => {\n                assert!(reciprocal_square > x);\n                let mut next = reciprocal_sqrt.clone();\n                next.increment();\n                if next != 0u32 {\n                    assert!(Rational::exact_from(&next).square().reciprocal() < x);\n                }\n            }\n            Greater => {\n                assert!(reciprocal_square < x);\n                let mut previous = reciprocal_sqrt.clone();\n                previous.decrement();\n                if previous != 0 {\n                    assert!(Rational::exact_from(&previous).square().reciprocal() > x);\n                }\n            }\n        }\n    }\n}\n\n#[test]\nfn reciprocal_sqrt_prec_properties() {\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        reciprocal_sqrt_prec_properties_helper(x, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_unsigned_pair_gen_var_1().test_properties_with_config(&config, |(x, prec)| {\n        reciprocal_sqrt_prec_properties_helper(x, prec, false);\n    });\n\n    float_unsigned_pair_gen_var_4().test_properties(|(x, prec)| {\n        reciprocal_sqrt_prec_properties_helper(x, prec, true);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (reciprocal_sqrt, o) = Float::NAN.reciprocal_sqrt_prec(prec);\n        assert!(reciprocal_sqrt.is_nan());\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::ZERO.reciprocal_sqrt_prec(prec);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::INFINITY)\n        );\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::NEGATIVE_ZERO.reciprocal_sqrt_prec(prec);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::INFINITY)\n        );\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::INFINITY.reciprocal_sqrt_prec(prec);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::NEGATIVE_INFINITY.reciprocal_sqrt_prec(prec);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::NAN)\n        );\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::ONE.reciprocal_sqrt_prec(prec),\n            (Float::one_prec(prec), Equal)\n        );\n\n        let (reciprocal_sqrt, o) = Float::NEGATIVE_ONE.reciprocal_sqrt_prec(prec);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::NAN)\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_sqrt_round_properties_helper(x: Float, rm: RoundingMode, extreme: bool) {\n    let (reciprocal_sqrt, o) = x.clone().reciprocal_sqrt_round(rm);\n    assert!(reciprocal_sqrt.is_valid());\n\n    let (reciprocal_sqrt_alt, o_alt) = x.reciprocal_sqrt_round_ref(rm);\n    assert!(reciprocal_sqrt_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.reciprocal_sqrt_round_assign(rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&x_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    assert_eq!(o_alt, o);\n\n    let (reciprocal_sqrt_alt, o_alt) = x.reciprocal_sqrt_prec_round_ref(x.significant_bits(), rm);\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    assert_eq!(o_alt, o);\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(reciprocal_sqrt.is_sign_positive());\n    }\n\n    if reciprocal_sqrt.is_normal() {\n        assert_eq!(reciprocal_sqrt.get_prec(), Some(x.get_prec().unwrap()));\n        if x > 1u32 && o < Greater {\n            assert!(reciprocal_sqrt < x);\n        } else if x < 1u32 && o > Less {\n            assert!(reciprocal_sqrt > x);\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_reciprocal_sqrt, rug_o) =\n            rug_reciprocal_sqrt_round(&rug::Float::exact_from(&x), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt)),\n            ComparableFloatRef(&reciprocal_sqrt),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if !extreme && x.is_normal() && reciprocal_sqrt.is_normal() {\n        let reciprocal_square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n        match o {\n            Equal => assert_eq!(reciprocal_square, x),\n            Less => {\n                assert!(reciprocal_square > x);\n                let mut next = reciprocal_sqrt.clone();\n                next.increment();\n                if next != 0u32 {\n                    assert!(Rational::exact_from(&next).square().reciprocal() < x);\n                }\n            }\n            Greater => {\n                assert!(reciprocal_square < x);\n                let mut previous = reciprocal_sqrt.clone();\n                previous.decrement();\n                if previous != 0u32 {\n                    assert!(Rational::exact_from(&previous).square().reciprocal() > x);\n                }\n            }\n        }\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.reciprocal_sqrt_round_ref(rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(reciprocal_sqrt.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.reciprocal_sqrt_round_ref(Exact));\n    }\n}\n\n#[test]\nfn reciprocal_sqrt_round_properties() {\n    float_rounding_mode_pair_gen_var_30().test_properties(|(x, rm)| {\n        reciprocal_sqrt_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_31().test_properties(|(x, rm)| {\n        reciprocal_sqrt_round_properties_helper(x, rm, true);\n    });\n\n    rounding_mode_gen().test_properties(|rm| {\n        let (reciprocal_sqrt, o) = Float::NAN.reciprocal_sqrt_round(rm);\n        assert!(reciprocal_sqrt.is_nan());\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::ZERO.reciprocal_sqrt_round(rm);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::INFINITY)\n        );\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::NEGATIVE_ZERO.reciprocal_sqrt_round(rm);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::INFINITY)\n        );\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::INFINITY.reciprocal_sqrt_round(rm);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(o, Equal);\n\n        let (reciprocal_sqrt, o) = Float::NEGATIVE_INFINITY.reciprocal_sqrt_round(rm);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::NAN)\n        );\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::ONE.reciprocal_sqrt_round(rm), (Float::ONE, Equal));\n\n        let (reciprocal_sqrt, o) = Float::NEGATIVE_ONE.reciprocal_sqrt_round(rm);\n        assert_eq!(\n            ComparableFloat(reciprocal_sqrt),\n            ComparableFloat(Float::NAN)\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn reciprocal_sqrt_properties_helper(x: Float, extreme: bool) {\n    let reciprocal_sqrt = x.clone().reciprocal_sqrt();\n    assert!(reciprocal_sqrt.is_valid());\n\n    let reciprocal_sqrt_alt = (&x).reciprocal_sqrt();\n    assert!(reciprocal_sqrt_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n\n    let mut x_alt = x.clone();\n    x_alt.reciprocal_sqrt_assign();\n    assert!(x_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&x_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n\n    let reciprocal_sqrt_alt = x\n        .reciprocal_sqrt_prec_round_ref(x.significant_bits(), Nearest)\n        .0;\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n    let reciprocal_sqrt_alt = x.reciprocal_sqrt_prec_ref(x.significant_bits()).0;\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n\n    let reciprocal_sqrt_alt = x.reciprocal_sqrt_round_ref(Nearest).0;\n    assert_eq!(\n        ComparableFloatRef(&reciprocal_sqrt_alt),\n        ComparableFloatRef(&reciprocal_sqrt)\n    );\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(reciprocal_sqrt.is_sign_positive());\n    }\n\n    if x.is_normal() && reciprocal_sqrt.is_normal() {\n        assert_eq!(reciprocal_sqrt.get_prec(), Some(x.get_prec().unwrap()));\n    }\n\n    if !extreme && x.is_normal() && reciprocal_sqrt.is_normal() {\n        assert_eq!(reciprocal_sqrt.get_prec(), Some(x.get_prec().unwrap()));\n        let reciprocal_square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n        if reciprocal_square < x {\n            let mut next = reciprocal_sqrt.clone();\n            next.decrement();\n            assert!(Rational::exact_from(&next).square().reciprocal() > x);\n        } else if reciprocal_square > x {\n            let mut previous = reciprocal_sqrt.clone();\n            previous.increment();\n            assert!(Rational::exact_from(&previous).square().reciprocal() < x);\n        }\n    }\n\n    let rug_reciprocal_sqrt = rug_reciprocal_sqrt(&rug::Float::exact_from(&x));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_reciprocal_sqrt)),\n        ComparableFloatRef(&reciprocal_sqrt),\n    );\n}\n\n#[test]\nfn reciprocal_sqrt_properties() {\n    float_gen().test_properties(|x| {\n        reciprocal_sqrt_properties_helper(x, false);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        reciprocal_sqrt_properties_helper(x, true);\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn primitive_float_reciprocal_sqrt_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    Rational: ExactFrom<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_gen::<T>().test_properties(|x| {\n        let reciprocal_sqrt = primitive_float_reciprocal_sqrt(x);\n        if x.is_normal() && reciprocal_sqrt.is_normal() {\n            let reciprocal_square = Rational::exact_from(reciprocal_sqrt).square().reciprocal();\n            if reciprocal_square < x {\n                let next = reciprocal_sqrt.next_lower();\n                assert!(Rational::exact_from(next).square().reciprocal() > x);\n            } else if reciprocal_square > x {\n                let previous = reciprocal_sqrt.next_higher();\n                assert!(Rational::exact_from(previous).square().reciprocal() < x);\n            }\n        }\n    });\n}\n\n#[test]\nfn primitive_float_reciprocal_sqrt_properties() {\n    apply_fn_to_primitive_floats!(primitive_float_reciprocal_sqrt_properties_helper);\n}\n\n#[test]\nfn reciprocal_sqrt_rational_prec_properties() {\n    rational_unsigned_pair_gen_var_7().test_properties(|(x, prec)| {\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec(x.clone(), prec);\n        assert!(reciprocal_sqrt.is_valid());\n\n        let (reciprocal_sqrt_alt, o_alt) = Float::reciprocal_sqrt_rational_prec_ref(&x, prec);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt_alt),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n        assert_eq!(o, o_alt);\n\n        let (reciprocal_sqrt_alt, o_alt) =\n            Float::reciprocal_sqrt_rational_prec_round_ref(&x, prec, Nearest);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt_alt),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n        assert_eq!(o, o_alt);\n\n        let (reciprocal_sqrt_alt, o_alt) =\n            reciprocal_sqrt_rational_prec_round_generic(&x, prec, Nearest);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt_alt),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n        assert_eq!(o, o_alt);\n\n        let (reciprocal_sqrt_alt, o_alt) =\n            reciprocal_sqrt_rational_prec_round_simple(&x, prec, Nearest);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt_alt),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n        assert_eq!(o, o_alt);\n\n        if !reciprocal_sqrt.is_nan() {\n            assert_eq!(\n                reciprocal_sqrt.get_prec(),\n                if x == 0u32 { None } else { Some(prec) }\n            );\n        }\n\n        if x >= 0u32 {\n            assert!(reciprocal_sqrt.is_sign_positive());\n        }\n\n        if reciprocal_sqrt.is_normal() {\n            if x > 1u32 && o < Greater {\n                assert!(reciprocal_sqrt < x);\n            } else if x < 1u32 && o > Less {\n                assert!(reciprocal_sqrt > x);\n            }\n\n            let square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n            match o {\n                Equal => assert_eq!(square, x),\n                Less => {\n                    assert!(square > x);\n                    let mut next = reciprocal_sqrt.clone();\n                    next.increment();\n                    if next != 0u32 {\n                        assert!(Rational::exact_from(&next).square().reciprocal() < x);\n                    }\n                }\n                Greater => {\n                    assert!(square < x);\n                    let mut previous = reciprocal_sqrt.clone();\n                    previous.decrement();\n                    if previous != 0 {\n                        assert!(Rational::exact_from(&previous).square().reciprocal() > x);\n                    }\n                }\n            }\n        }\n    });\n}\n\n#[test]\nfn reciprocal_sqrt_rational_prec_round_properties() {\n    rational_unsigned_rounding_mode_triple_gen_var_4().test_properties(|(x, prec, rm)| {\n        let (reciprocal_sqrt, o) = Float::reciprocal_sqrt_rational_prec_round(x.clone(), prec, rm);\n        assert!(reciprocal_sqrt.is_valid());\n\n        let (reciprocal_sqrt_alt, o_alt) =\n            Float::reciprocal_sqrt_rational_prec_round_ref(&x, prec, rm);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt_alt),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n        assert_eq!(o, o_alt);\n\n        if !reciprocal_sqrt.is_nan() {\n            match (x >= 0, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n\n        let (reciprocal_sqrt_alt, o_alt) =\n            reciprocal_sqrt_rational_prec_round_generic(&x, prec, rm);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt_alt),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n        assert_eq!(o, o_alt);\n\n        let (reciprocal_sqrt_alt, o_alt) = reciprocal_sqrt_rational_prec_round_simple(&x, prec, rm);\n        assert!(reciprocal_sqrt_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&reciprocal_sqrt_alt),\n            ComparableFloatRef(&reciprocal_sqrt)\n        );\n        assert_eq!(o, o_alt);\n\n        if !reciprocal_sqrt.is_nan() {\n            assert_eq!(\n                reciprocal_sqrt.get_prec(),\n                if x == 0u32 { None } else { Some(prec) }\n            );\n        }\n\n        if x >= 0u32 {\n            assert!(reciprocal_sqrt.is_sign_positive());\n        }\n\n        if reciprocal_sqrt.is_normal() {\n            if x > 1u32 && o < Greater {\n                assert!(reciprocal_sqrt < x);\n            } else if x < 1u32 && o > Less {\n                assert!(reciprocal_sqrt > x);\n            }\n        }\n\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(&reciprocal_sqrt).square().reciprocal();\n            match o {\n                Equal => assert_eq!(square, x),\n                Less => {\n                    assert!(square > x);\n                    let mut next = reciprocal_sqrt.clone();\n                    next.increment();\n                    if next != 0 {\n                        assert!(Rational::exact_from(&next).square().reciprocal() < x);\n                    }\n                }\n                Greater => {\n                    assert!(square < x);\n                    let mut previous = reciprocal_sqrt.clone();\n                    previous.decrement();\n                    if previous != 0u32 {\n                        assert!(Rational::exact_from(&previous).square().reciprocal() > x);\n                    }\n                }\n            }\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                let (s, oo) = Float::reciprocal_sqrt_rational_prec_round_ref(&x, prec, rm);\n                assert_eq!(\n                    ComparableFloat(s.abs_negative_zero_ref()),\n                    ComparableFloat(reciprocal_sqrt.abs_negative_zero_ref())\n                );\n                assert_eq!(oo, Equal);\n            }\n        } else {\n            assert_panic!(Float::reciprocal_sqrt_rational_prec_round_ref(\n                &x, prec, Exact\n            ));\n        }\n    });\n\n    // reciprocal_sqrt(3/5) is one of the simplest cases that doesn't reduce to sqrt or\n    // reciprocal_sqrt of a Float\n    const X: Rational = Rational::const_from_unsigneds(3, 5);\n    test_constant(\n        |prec, rm| Float::reciprocal_sqrt_rational_prec_round(X, prec, rm),\n        10000,\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn primitive_float_reciprocal_sqrt_rational_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n    Rational: ExactFrom<T>,\n{\n    rational_gen_var_1().test_properties(|x| {\n        let reciprocal_sqrt = primitive_float_reciprocal_sqrt_rational::<T>(&x);\n        if reciprocal_sqrt.is_normal() {\n            let square = Rational::exact_from(reciprocal_sqrt).square().reciprocal();\n            match square.cmp(&x) {\n                Less => {\n                    assert!(\n                        Rational::exact_from(reciprocal_sqrt.next_higher())\n                            .square()\n                            .reciprocal()\n                            < x\n                    );\n                }\n                Greater => {\n                    assert!(\n                        Rational::exact_from(reciprocal_sqrt.next_lower())\n                            .square()\n                            .reciprocal()\n                            > x\n                    );\n                }\n                _ => {}\n            }\n        }\n    });\n\n    rational_pair_gen_var_8().test_properties(|(x, y)| {\n        let reciprocal_sqrt_x = NiceFloat(primitive_float_reciprocal_sqrt_rational::<T>(&x));\n        let reciprocal_sqrt_y = NiceFloat(primitive_float_reciprocal_sqrt_rational::<T>(&y));\n        if !reciprocal_sqrt_x.0.is_nan() && !reciprocal_sqrt_y.0.is_nan() {\n            match x.partial_cmp(&y).unwrap() {\n                Equal => assert_eq!(reciprocal_sqrt_x, reciprocal_sqrt_y),\n                Less => assert!(reciprocal_sqrt_x >= reciprocal_sqrt_y),\n                Greater => assert!(reciprocal_sqrt_x <= reciprocal_sqrt_y),\n            }\n        }\n    });\n}\n\n#[test]\nfn primitive_float_reciprocal_sqrt_rational_properties() {\n    apply_fn_to_primitive_floats!(primitive_float_reciprocal_sqrt_rational_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, PowerOf2, ShlRound, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeZero, One, Zero,\n};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, unsigned_gen, unsigned_gen_var_5,\n};\nuse malachite_float::test_util::arithmetic::shl::shl_naive;\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::generators::{\n    float_gen, float_signed_pair_gen_var_2, float_signed_pair_gen_var_3,\n    float_unsigned_pair_gen_var_2, float_unsigned_pair_gen_var_3,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\nuse malachite_q::Rational;\nuse std::ops::{Shl, ShlAssign, Shr};\n\nfn test_shl_unsigned_helper<T: PrimitiveUnsigned, F: Fn(Float, T, Float)>(f: F)\nwhere\n    Float: ShlAssign<T> + Shl<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    let test = |s, s_hex, v: u64, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = x.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = &x << v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = shl_naive(x.clone(), v);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n\n        f(x, v, n);\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"246.0\", \"0xf6.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"1.26e5\", \"0x1.ecE+4#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"1.56e32\", \"0x7.bE+26#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-246.0\", \"-0xf6.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-1.26e5\", \"-0x1.ecE+4#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-1.56e32\", \"-0x7.bE+26#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"6.283185307179586\",\n        \"0x6.487ed5110b460#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"3216.9908772759482\",\n        \"0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"3.9824418129956972e30\",\n        \"0x3.243f6a8885a30E+25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-6.283185307179586\",\n        \"-0x6.487ed5110b460#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-3216.9908772759482\",\n        \"-0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-3.9824418129956972e30\",\n        \"-0x3.243f6a8885a30E+25#53\",\n    );\n\n    let test_extreme = |s, s_hex, v: i32, out: &str, out_hex: &str| {\n        let v = u64::exact_from(v);\n        if T::convertible_from(v) {\n            test(s, s_hex, v, out, out_hex);\n        }\n    };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n}\n\n#[test]\nfn test_shl_unsigned() {\n    test_shl_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u32, _>(|x, v, shifted| {\n        let mut n = rug::Float::exact_from(&x);\n        n <<= v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n\n        let n = rug::Float::exact_from(&x) << v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n    });\n    test_shl_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shl_signed_helper<T: PrimitiveSigned, F: Fn(Float, T, Float)>(f: F)\nwhere\n    Float: ShlAssign<T> + Shl<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n{\n    let test = |s, s_hex, v: i64, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = x.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = &x << v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = shl_naive(x.clone(), v);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n\n        f(x, v, n);\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"246.0\", \"0xf6.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"1.26e5\", \"0x1.ecE+4#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"1.56e32\", \"0x7.bE+26#7\");\n    test(\"123.0\", \"0x7b.0#7\", -1, \"61.5\", \"0x3d.8#7\");\n    test(\"123.0\", \"0x7b.0#7\", -10, \"0.12\", \"0x0.1ec#7\");\n    test(\"123.0\", \"0x7b.0#7\", -100, \"9.7e-29\", \"0x7.bE-24#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-246.0\", \"-0xf6.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-1.26e5\", \"-0x1.ecE+4#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-1.56e32\", \"-0x7.bE+26#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -1, \"-61.5\", \"-0x3d.8#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -10, \"-0.12\", \"-0x0.1ec#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -100, \"-9.7e-29\", \"-0x7.bE-24#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"6.283185307179586\",\n        \"0x6.487ed5110b460#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"3216.9908772759482\",\n        \"0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"3.9824418129956972e30\",\n        \"0x3.243f6a8885a30E+25#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        \"1.5707963267948966\",\n        \"0x1.921fb54442d18#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -10,\n        \"0.0030679615757712823\",\n        \"0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        \"2.4782796245465248e-30\",\n        \"0x3.243f6a8885a30E-25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-6.283185307179586\",\n        \"-0x6.487ed5110b460#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-3216.9908772759482\",\n        \"-0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-3.9824418129956972e30\",\n        \"-0x3.243f6a8885a30E+25#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        \"-1.5707963267948966\",\n        \"-0x1.921fb54442d18#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -10,\n        \"-0.0030679615757712823\",\n        \"-0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        \"-2.4782796245465248e-30\",\n        \"-0x3.243f6a8885a30E-25#53\",\n    );\n\n    let test_extreme = |s, s_hex, v: i32, out: &str, out_hex: &str| {\n        let v = i64::from(v);\n        if T::convertible_from(v) {\n            test(s, s_hex, v, out, out_hex);\n        }\n    };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n    );\n    test_extreme(\"1.0\", \"0x1.0#1\", Float::MIN_EXPONENT - 2, \"0.0\", \"0x0.0\");\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        \"-0.0\",\n        \"-0x0.0\",\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n    );\n}\n\n#[test]\nfn test_shl_signed() {\n    test_shl_signed_helper::<i8, _>(|_, _, _| {});\n    test_shl_signed_helper::<i16, _>(|_, _, _| {});\n    test_shl_signed_helper::<i32, _>(|x, v, shifted| {\n        let mut n = rug::Float::exact_from(&x);\n        n <<= v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n\n        let n = rug::Float::exact_from(&x) << v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n    });\n    test_shl_signed_helper::<i64, _>(|_, _, _| {});\n    test_shl_signed_helper::<i128, _>(|_, _, _| {});\n    test_shl_signed_helper::<isize, _>(|_, _, _| {});\n}\n\nfn shl_properties_helper_unsigned_helper<T: PrimitiveUnsigned>(n: Float, u: T)\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShlRound<T, Output = Float>\n        + ShlAssign<T>\n        + Shr<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    mut_n <<= u;\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    let shifted_alt = &n << u;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone() << u;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shl_round(u, Nearest).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shl_prec(u, n.get_prec().unwrap_or(1)).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let shifted_alt = shl_naive(n.clone(), u);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if !n.is_nan() {\n        assert!((&n << u).ge_abs(&n));\n    }\n    assert_eq!(ComparableFloat(-&n << u), ComparableFloat(-(&n << u)));\n\n    if shifted.is_normal() {\n        assert_eq!(ComparableFloatRef(&(&n << u >> u)), ComparableFloatRef(&n));\n        assert_eq!(\n            ComparableFloat(&n << u),\n            ComparableFloat(n * Float::power_of_2(u64::exact_from(u)))\n        );\n    }\n}\n\nfn shl_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShlRound<T, Output = Float>\n        + ShlAssign<T>\n        + Shr<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_unsigned_pair_gen_var_2::<T>().test_properties(|(n, u)| {\n        shl_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_unsigned_pair_gen_var_3::<T>().test_properties(|(n, u)| {\n        shl_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_gen().test_properties(|n| {\n        assert_eq!(ComparableFloat(&n << T::ZERO), ComparableFloat(n));\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert!((Float::NAN << u).is_nan());\n        assert_eq!(Float::INFINITY << u, Float::INFINITY);\n        assert_eq!(Float::NEGATIVE_INFINITY << u, Float::NEGATIVE_INFINITY);\n        assert_eq!(\n            ComparableFloat(Float::ZERO << u),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(\n            ComparableFloat(Float::NEGATIVE_ZERO << u),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n    });\n\n    unsigned_gen_var_5::<T>().test_properties(|u| {\n        assert!((Float::ONE << u).is_power_of_2());\n    });\n\n    integer_unsigned_pair_gen_var_2::<T>().test_properties(|(n, u)| {\n        assert_eq!(&n << u, Float::exact_from(n) << u);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_properties_helper_signed_helper<T: PrimitiveSigned>(n: Float, i: T)\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShlRound<T, Output = Float>\n        + ShlAssign<T>\n        + Shr<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>\n        + Shl<<T as UnsignedAbs>::Output, Output = Float>\n        + Shr<T, Output = Float>\n        + Shr<<T as UnsignedAbs>::Output, Output = Float>,\n    i64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    mut_n <<= i;\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    let shifted_alt = &n << i;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone() << i;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shl_round(i, Nearest).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shl_prec(i, n.get_prec().unwrap_or(1)).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(i))\n        .lt_abs(&1_000_000)\n    {\n        let shifted_alt = shl_naive(n.clone(), i);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if i >= T::ZERO {\n        assert_eq!(\n            ComparableFloatRef(&(&n << i.unsigned_abs())),\n            ComparableFloatRef(&shifted)\n        );\n    } else if i != T::MIN {\n        assert_eq!(\n            ComparableFloatRef(&(&n >> i.unsigned_abs())),\n            ComparableFloatRef(&shifted)\n        );\n    }\n    assert_eq!(ComparableFloat(-&n << i), ComparableFloat(-(&n << i)));\n    if let Some(neg_i) = i.checked_neg() {\n        assert_eq!(ComparableFloat(&n << neg_i), ComparableFloat(&n >> i));\n    }\n\n    if shifted.is_normal() {\n        if shifted.get_exponent() != Some(Float::MIN_EXPONENT) {\n            assert_eq!(ComparableFloatRef(&(&n << i >> i)), ComparableFloatRef(&n));\n        }\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(n * Float::power_of_2(i64::exact_from(i)))\n        );\n    }\n}\n\nfn shl_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShlRound<T, Output = Float>\n        + ShlAssign<T>\n        + Shr<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>\n        + Shl<<T as UnsignedAbs>::Output, Output = Float>\n        + Shr<T, Output = Float>\n        + Shr<<T as UnsignedAbs>::Output, Output = Float>,\n    i64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_signed_pair_gen_var_2::<T>().test_properties(|(n, i)| {\n        shl_properties_helper_signed_helper(n, i);\n    });\n\n    float_signed_pair_gen_var_3::<T>().test_properties(|(n, i)| {\n        shl_properties_helper_signed_helper(n, i);\n    });\n\n    float_gen().test_properties(|n| {\n        assert_eq!(ComparableFloat(&n << T::ZERO), ComparableFloat(n));\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert!((Float::NAN << i).is_nan());\n        assert_eq!(Float::INFINITY << i, Float::INFINITY);\n        assert_eq!(Float::NEGATIVE_INFINITY << i, Float::NEGATIVE_INFINITY);\n        assert_eq!(\n            ComparableFloat(Float::ZERO << i),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(\n            ComparableFloat(Float::NEGATIVE_ZERO << i),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n    });\n\n    signed_gen_var_5::<T>().test_properties(|i| {\n        assert!((Float::ONE << i).is_power_of_2());\n    });\n}\n\n#[test]\nfn shl_properties() {\n    apply_fn_to_unsigneds!(shl_properties_helper_unsigned);\n    apply_fn_to_signeds!(shl_properties_helper_signed);\n\n    float_unsigned_pair_gen_var_2::<u32>().test_properties(|(n, u)| {\n        let shifted = &n << u;\n        let mut rug_n = rug::Float::exact_from(&n);\n        rug_n <<= u;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(\n            ComparableFloat(Float::from(&(rug::Float::exact_from(&n) << u))),\n            ComparableFloat(shifted)\n        );\n    });\n\n    float_signed_pair_gen_var_2::<i32>().test_properties(|(n, i)| {\n        let shifted = &n << i;\n        let mut rug_n = rug::Float::exact_from(&n);\n        rug_n <<= i;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(\n            ComparableFloat(Float::from(&(rug::Float::exact_from(&n) << i))),\n            ComparableFloat(shifted)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    IsPowerOf2, PowerOf2, ShlRound, ShlRoundAssign, ShrRound, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, signed_rounding_mode_pair_gen_var_5,\n    signed_unsigned_pair_gen_var_19, signed_unsigned_pair_gen_var_20,\n    signed_unsigned_rounding_mode_triple_gen_var_7, signed_unsigned_rounding_mode_triple_gen_var_8,\n    unsigned_pair_gen_var_18, unsigned_rounding_mode_pair_gen,\n    unsigned_rounding_mode_pair_gen_var_5, unsigned_unsigned_rounding_mode_triple_gen_var_7,\n};\nuse malachite_float::test_util::arithmetic::shl_round::{\n    rug_shl_prec_round_signed, rug_shl_prec_round_unsigned, rug_shl_prec_signed,\n    rug_shl_prec_unsigned, rug_shl_round_signed, rug_shl_round_unsigned, shl_prec_naive,\n    shl_prec_round_naive, shl_round_naive,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_rounding_mode_pair_gen, float_signed_rounding_mode_triple_gen_var_1,\n    float_signed_rounding_mode_triple_gen_var_2,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_signed_unsigned_triple_gen_var_1, float_signed_unsigned_triple_gen_var_2,\n    float_unsigned_pair_gen_var_1, float_unsigned_rounding_mode_triple_gen_var_1,\n    float_unsigned_rounding_mode_triple_gen_var_5, float_unsigned_rounding_mode_triple_gen_var_6,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_unsigned_unsigned_triple_gen_var_1, float_unsigned_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_unsigned_rounding_mode_triple_gen_var_5;\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\nuse std::ops::Shl;\nuse std::panic::catch_unwind;\n\nfn test_shl_prec_round_unsigned_helper<\n    T: PrimitiveUnsigned,\n    F: Fn(Float, T, u64, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShlRoundAssign<T> + ShlRound<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    let test_r = |s,\n                  s_hex,\n                  v: u64,\n                  prec: u64,\n                  rm: RoundingMode,\n                  out: &str,\n                  out_hex: &str,\n                  out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shl_prec_round_assign(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shl_prec_round(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shl_prec_round_ref(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shl_prec_round_naive(x.clone(), v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, rm, n, out_o);\n    };\n\n    let test = |s, s_hex, v: u64, prec: u64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            test_r(s, s_hex, v, prec, rm, out, out_hex, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\");\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Floor,\n        \"7.0e4\",\n        \"0x1.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Ceiling,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Down,\n        \"7.0e4\",\n        \"0x1.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Up,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Nearest,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Down,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Floor,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Ceiling,\n        \"-7.0e4\",\n        \"-0x1.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Down,\n        \"-7.0e4\",\n        \"-0x1.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Up,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Nearest,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n\n    // - overflow in shl_prec_round\n    // - overflow && sign && rm == Floor | Down in shl_prec_round\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    // - overflow && sign && rm == Up | Ceiling | Nearest in shl_prec_round\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    // - overflow && !sign && rm == Up | Floor | Nearest in shl_prec_round\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    // - overflow && !sign && rm == Ceiling | Down in shl_prec_round\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shl_prec_round_unsigned() {\n    test_shl_prec_round_unsigned_helper::<u8, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_unsigned_helper::<u16, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_unsigned_helper::<u32, _>(|x, v, prec, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shl_prec_round_unsigned(&rug::Float::exact_from(&x), v, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shl_prec_round_unsigned_helper::<u64, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_unsigned_helper::<u128, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_unsigned_helper::<usize, _>(|_, _, _, _, _, _| {});\n}\n\nfn test_shl_prec_round_signed_helper<\n    T: PrimitiveSigned,\n    F: Fn(Float, T, u64, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShlRoundAssign<T> + ShlRound<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    let test_r = |s,\n                  s_hex,\n                  v: i64,\n                  prec: u64,\n                  rm: RoundingMode,\n                  out: &str,\n                  out_hex: &str,\n                  out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shl_prec_round_assign(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shl_prec_round(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shl_prec_round_ref(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shl_prec_round_naive(x.clone(), v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, rm, n, out_o);\n    };\n\n    let test = |s, s_hex, v: i64, prec: u64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            test_r(s, s_hex, v, prec, rm, out, out_hex, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, 1, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, 1, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, 10, \"-0.0\", \"-0x0.0\");\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Floor,\n        \"7.0e4\",\n        \"0x1.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Ceiling,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Down,\n        \"7.0e4\",\n        \"0x1.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Up,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        1,\n        Nearest,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n\n    test_r(\"123.0\", \"0x7b.0#7\", -10, 1, Floor, \"0.06\", \"0x0.1#1\", Less);\n    test_r(\n        \"123.0\", \"0x7b.0#7\", -10, 1, Ceiling, \"0.1\", \"0x0.2#1\", Greater,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", -10, 1, Down, \"0.06\", \"0x0.1#1\", Less);\n    test_r(\"123.0\", \"0x7b.0#7\", -10, 1, Up, \"0.1\", \"0x0.2#1\", Greater);\n    test_r(\n        \"123.0\", \"0x7b.0#7\", -10, 1, Nearest, \"0.1\", \"0x0.2#1\", Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Floor,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Ceiling,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Down,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Up,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Nearest,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Exact,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Down,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Floor,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Ceiling,\n        \"-7.0e4\",\n        \"-0x1.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Down,\n        \"-7.0e4\",\n        \"-0x1.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Up,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Nearest,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Floor,\n        \"-0.1\",\n        \"-0x0.2#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Ceiling,\n        \"-0.06\",\n        \"-0x0.1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Down,\n        \"-0.06\",\n        \"-0x0.1#1\",\n        Greater,\n    );\n    test_r(\"-123.0\", \"-0x7b.0#7\", -10, 1, Up, \"-0.1\", \"-0x0.2#1\", Less);\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Nearest,\n        \"-0.1\",\n        \"-0x0.2#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Floor,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Ceiling,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Down,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Up,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Nearest,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Exact,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n\n    // - overflow in shl_prec_round\n    // - overflow && sign && rm == Floor | Down in shl_prec_round\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    // - overflow && sign && rm == Up | Ceiling | Nearest in shl_prec_round\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    // - overflow && !sign && rm == Up | Floor | Nearest in shl_prec_round\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    // - overflow && !sign && rm == Ceiling | Down in shl_prec_round\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    // - underflow in shl_prec_round\n    // - underflow && sign && rm == Floor | Down | Nearest in shl_prec_round\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        -1,\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - underflow && sign && rm == Up | Ceiling in shl_prec_round\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        -1,\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        -1,\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        -1,\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        -1,\n        1,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    // - underflow && !sign && rm == Up | Floor in shl_prec_round\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        -1,\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    // - underflow && !sign && rm == Ceiling | Down | Nearest in shl_prec_round\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        -1,\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        -1,\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        -1,\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        -1,\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    // - underflow half-up in shl_prec_round\n    // - underflow half-up && sign in shl_prec_round\n    test_r(\n        \"too_small\",\n        \"0x4.df81e47e11c9aa6dE-268435455#67\",\n        -7,\n        66,\n        Nearest,\n        \"too_small\",\n        \"0x1.00000000000000000E-268435456#66\",\n        Greater,\n    );\n    // - underflow half-up && !sign in shl_prec_round\n    test_r(\n        \"-too_small\",\n        \"-0x4.df81e47e11c9aa6dE-268435455#67\",\n        -7,\n        66,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.00000000000000000E-268435456#66\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shl_prec_round_signed() {\n    test_shl_prec_round_signed_helper::<i8, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_signed_helper::<i16, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_signed_helper::<i32, _>(|x, v, prec, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shl_prec_round_signed(&rug::Float::exact_from(&x), v, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shl_prec_round_signed_helper::<i64, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_signed_helper::<i128, _>(|_, _, _, _, _, _| {});\n    test_shl_prec_round_signed_helper::<isize, _>(|_, _, _, _, _, _| {});\n}\n\n#[test]\nfn shl_prec_round_fail() {\n    assert_panic!(Float::ONE.shl_prec_round(Float::MAX_EXPONENT, 1, Exact));\n    assert_panic!(Float::ONE.shl_prec_round(Float::MIN_EXPONENT - 2, 1, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shl_prec_round(Float::MAX_EXPONENT, 1, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shl_prec_round(Float::MIN_EXPONENT - 2, 1, Exact));\n}\n\nfn test_shl_prec_unsigned_helper<T: PrimitiveUnsigned, F: Fn(Float, T, u64, Float, Ordering)>(f: F)\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    let test = |s, s_hex, v: u64, prec: u64, out: &str, out_hex: &str, out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shl_prec_assign(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shl_prec(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shl_prec_ref(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shl_prec_naive(x.clone(), v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, n, out_o);\n    };\n\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 0, 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 0, 10, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", 10, 1, \"1.0e5\", \"0x2.0E+4#1\", Greater);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 1, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 10, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, 1, \"-1.0e5\", \"-0x2.0E+4#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shl_prec_unsigned() {\n    test_shl_prec_unsigned_helper::<u8, _>(|_, _, _, _, _| {});\n    test_shl_prec_unsigned_helper::<u16, _>(|_, _, _, _, _| {});\n    test_shl_prec_unsigned_helper::<u32, _>(|x, v, prec, shifted, o_out| {\n        let (n, o) = rug_shl_prec_unsigned(&rug::Float::exact_from(&x), v, prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, o_out);\n    });\n    test_shl_prec_unsigned_helper::<u64, _>(|_, _, _, _, _| {});\n    test_shl_prec_unsigned_helper::<u128, _>(|_, _, _, _, _| {});\n    test_shl_prec_unsigned_helper::<usize, _>(|_, _, _, _, _| {});\n}\n\nfn test_shl_prec_signed_helper<T: PrimitiveSigned, F: Fn(Float, T, u64, Float, Ordering)>(f: F)\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    let test = |s, s_hex, v: i64, prec: u64, out: &str, out_hex: &str, out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shl_prec_assign(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shl_prec(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shl_prec_ref(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shl_prec_naive(x.clone(), v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, n, out_o);\n    };\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", -10, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", -10, 10, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", -10, 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", -10, 10, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        -10,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        -10,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", -10, 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", -10, 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", -10, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", -10, 10, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 0, 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 0, 10, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", 10, 1, \"1.0e5\", \"0x2.0E+4#1\", Greater);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", -10, 1, \"0.1\", \"0x0.2#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", -10, 10, \"0.1201\", \"0x0.1ec0#10\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 1, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 10, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, 1, \"-1.0e5\", \"-0x2.0E+4#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", -10, 1, \"-0.1\", \"-0x0.2#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        1,\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        1,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        -1,\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        -1,\n        1,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    // - underflow half-up in shl_prec_round\n    // - underflow half-up && sign in shl_prec_round\n    test(\n        \"too_small\",\n        \"0x4.df81e47e11c9aa6dE-268435455#67\",\n        -7,\n        66,\n        \"too_small\",\n        \"0x1.00000000000000000E-268435456#66\",\n        Greater,\n    );\n    // - underflow half-up && !sign in shl_prec_round\n    test(\n        \"-too_small\",\n        \"-0x4.df81e47e11c9aa6dE-268435455#67\",\n        -7,\n        66,\n        \"-too_small\",\n        \"-0x1.00000000000000000E-268435456#66\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shl_prec_signed() {\n    test_shl_prec_signed_helper::<i8, _>(|_, _, _, _, _| {});\n    test_shl_prec_signed_helper::<i16, _>(|_, _, _, _, _| {});\n    test_shl_prec_signed_helper::<i32, _>(|x, v, prec, shifted, o_out| {\n        let (n, o) = rug_shl_prec_signed(&rug::Float::exact_from(&x), v, prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, o_out);\n    });\n    test_shl_prec_signed_helper::<i64, _>(|_, _, _, _, _| {});\n    test_shl_prec_signed_helper::<i128, _>(|_, _, _, _, _| {});\n    test_shl_prec_signed_helper::<isize, _>(|_, _, _, _, _| {});\n}\n\nfn test_shl_round_unsigned_helper<\n    T: PrimitiveUnsigned,\n    F: Fn(Float, T, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShlRoundAssign<T> + ShlRound<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    let test = |s, s_hex, v: u64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            let x = parse_hex_string(s_hex);\n            assert_eq!(x.to_string(), s);\n            let v = T::exact_from(v);\n\n            let mut n = x.clone();\n            let o = n.shl_round_assign(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = x.clone().shl_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = (&x).shl_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = shl_round_naive(x.clone(), v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert_eq!(o, Equal);\n\n            f(x, v, rm, n, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"246.0\", \"0xf6.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"1.26e5\", \"0x1.ecE+4#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"1.56e32\", \"0x7.bE+26#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-246.0\", \"-0xf6.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-1.26e5\", \"-0x1.ecE+4#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-1.56e32\", \"-0x7.bE+26#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"6.283185307179586\",\n        \"0x6.487ed5110b460#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"3216.9908772759482\",\n        \"0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"3.9824418129956972e30\",\n        \"0x3.243f6a8885a30E+25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-6.283185307179586\",\n        \"-0x6.487ed5110b460#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-3216.9908772759482\",\n        \"-0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-3.9824418129956972e30\",\n        \"-0x3.243f6a8885a30E+25#53\",\n    );\n\n    let test_extreme =\n        |s, s_hex, v: i32, rm: RoundingMode, out: &str, out_hex: &str, out_o: Ordering| {\n            let v = u64::exact_from(v);\n            if T::convertible_from(v) {\n                let x = parse_hex_string(s_hex);\n                assert_eq!(x.to_string(), s);\n                let v = T::exact_from(v);\n\n                let mut n = x.clone();\n                let o = n.shl_round_assign(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = x.clone().shl_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = (&x).shl_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = shl_round_naive(x.clone(), v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert_eq!(o, out_o);\n\n                f(x, v, rm, n, out_o);\n            }\n        };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Ceiling,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Up,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Nearest,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Exact,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Floor,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Up,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Nearest,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Exact,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shl_round_unsigned() {\n    test_shl_round_unsigned_helper::<u8, _>(|_, _, _, _, _| {});\n    test_shl_round_unsigned_helper::<u16, _>(|_, _, _, _, _| {});\n    test_shl_round_unsigned_helper::<u32, _>(|x, v, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shl_round_unsigned(&rug::Float::exact_from(&x), v, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shl_round_unsigned_helper::<u64, _>(|_, _, _, _, _| {});\n    test_shl_round_unsigned_helper::<u128, _>(|_, _, _, _, _| {});\n    test_shl_round_unsigned_helper::<usize, _>(|_, _, _, _, _| {});\n}\n\nfn test_shl_round_signed_helper<\n    T: PrimitiveSigned,\n    F: Fn(Float, T, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShlRoundAssign<T> + ShlRound<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n{\n    let test = |s, s_hex, v: i64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            let x = parse_hex_string(s_hex);\n            assert_eq!(x.to_string(), s);\n            let v = T::exact_from(v);\n\n            let mut n = x.clone();\n            let o = n.shl_round_assign(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = x.clone().shl_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = (&x).shl_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = shl_round_naive(x.clone(), v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert_eq!(o, Equal);\n\n            f(x, v, rm, n, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"246.0\", \"0xf6.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"1.26e5\", \"0x1.ecE+4#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"1.56e32\", \"0x7.bE+26#7\");\n    test(\"123.0\", \"0x7b.0#7\", -1, \"61.5\", \"0x3d.8#7\");\n    test(\"123.0\", \"0x7b.0#7\", -10, \"0.12\", \"0x0.1ec#7\");\n    test(\"123.0\", \"0x7b.0#7\", -100, \"9.7e-29\", \"0x7.bE-24#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-246.0\", \"-0xf6.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-1.26e5\", \"-0x1.ecE+4#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-1.56e32\", \"-0x7.bE+26#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -1, \"-61.5\", \"-0x3d.8#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -10, \"-0.12\", \"-0x0.1ec#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -100, \"-9.7e-29\", \"-0x7.bE-24#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"6.283185307179586\",\n        \"0x6.487ed5110b460#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"3216.9908772759482\",\n        \"0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"3.9824418129956972e30\",\n        \"0x3.243f6a8885a30E+25#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        \"1.5707963267948966\",\n        \"0x1.921fb54442d18#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -10,\n        \"0.0030679615757712823\",\n        \"0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        \"2.4782796245465248e-30\",\n        \"0x3.243f6a8885a30E-25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-6.283185307179586\",\n        \"-0x6.487ed5110b460#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-3216.9908772759482\",\n        \"-0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-3.9824418129956972e30\",\n        \"-0x3.243f6a8885a30E+25#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        \"-1.5707963267948966\",\n        \"-0x1.921fb54442d18#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -10,\n        \"-0.0030679615757712823\",\n        \"-0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        \"-2.4782796245465248e-30\",\n        \"-0x3.243f6a8885a30E-25#53\",\n    );\n\n    let test_extreme =\n        |s, s_hex, v: i32, rm: RoundingMode, out: &str, out_hex: &str, out_o: Ordering| {\n            let v = i64::from(v);\n            if T::convertible_from(v) {\n                let x = parse_hex_string(s_hex);\n                assert_eq!(x.to_string(), s);\n                let v = T::exact_from(v);\n\n                let mut n = x.clone();\n                let o = n.shl_round_assign(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = x.clone().shl_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = (&x).shl_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = shl_round_naive(x.clone(), v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert_eq!(o, out_o);\n\n                f(x, v, rm, n, out_o);\n            }\n        };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Ceiling,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Up,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Nearest,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Exact,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Floor,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Up,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Nearest,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        Exact,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Exact,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Ceiling,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Down,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 1,\n        Exact,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT - 2,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MIN_EXPONENT - 2,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n}\n\n#[test]\nfn shl_round_fail() {\n    assert_panic!(Float::ONE.shl_round(Float::MAX_EXPONENT, Exact));\n    assert_panic!(Float::ONE.shl_round(Float::MIN_EXPONENT - 2, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shl_round(Float::MAX_EXPONENT, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shl_round(Float::MIN_EXPONENT - 2, Exact));\n}\n\n#[test]\nfn test_shl_round_signed() {\n    test_shl_round_signed_helper::<i8, _>(|_, _, _, _, _| {});\n    test_shl_round_signed_helper::<i16, _>(|_, _, _, _, _| {});\n    test_shl_round_signed_helper::<i32, _>(|x, v, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shl_round_signed(&rug::Float::exact_from(&x), v, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shl_round_signed_helper::<i64, _>(|_, _, _, _, _| {});\n    test_shl_round_signed_helper::<i128, _>(|_, _, _, _, _| {});\n    test_shl_round_signed_helper::<isize, _>(|_, _, _, _, _| {});\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_properties_helper_unsigned_helper<T: PrimitiveUnsigned>(n: Float, u: T, prec: u64)\nwhere\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shl_prec_assign(u, prec);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shl_prec_round_ref(u, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shl_prec_ref(u, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shl_prec(u, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shl_prec_naive(n.clone(), u, prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted),\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    let (shifted_2, o_2) = (-&n).shl_prec(u, prec);\n    let (shifted_2_alt, o_2_alt) = n.shl_prec_ref(u, prec);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) = n.mul_prec(Float::power_of_2(u64::exact_from(u)), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shl_prec_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n{\n    float_unsigned_unsigned_triple_gen_var_1::<T, _>().test_properties(|(n, u, prec)| {\n        shl_prec_properties_helper_unsigned_helper(n, u, prec);\n    });\n\n    float_unsigned_unsigned_triple_gen_var_2::<T, _>().test_properties(|(n, u, prec)| {\n        shl_prec_properties_helper_unsigned_helper(n, u, prec);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(n, prec)| {\n        let (shifted, o) = n.shl_prec_ref(T::ZERO, prec);\n        let (shifted_alt, o_alt) = Float::from_float_prec(n, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    unsigned_pair_gen_var_18::<T, _>().test_properties(|(u, prec)| {\n        let (shifted, o) = Float::NAN.shl_prec(u, prec);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shl_prec(u, prec), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shl_prec(u, prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shl_prec(u, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shl_prec(u, prec);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_properties_helper_signed_helper<T: PrimitiveSigned>(n: Float, i: T, prec: u64)\nwhere\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shl_prec_assign(i, prec);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shl_prec_round_ref(i, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shl_prec_ref(i, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shl_prec(i, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(i))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shl_prec_naive(n.clone(), i, prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    if i >= T::ZERO {\n        let (shifted_alt, o_alt) = n.shl_prec_ref(i.unsigned_abs(), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    } else if i != T::MIN {\n        let (shifted_alt, o_alt) = n.shr_prec_ref(i.unsigned_abs(), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    };\n\n    let (shifted_2, o_2) = (-&n).shl_prec(i, prec);\n    let (shifted_2_alt, o_2_alt) = n.shl_prec_ref(i, prec);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) = n.mul_prec(Float::power_of_2(i64::exact_from(i)), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shl_prec_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    float_signed_unsigned_triple_gen_var_1::<T, _>().test_properties(|(n, i, prec)| {\n        shl_prec_properties_helper_signed_helper(n, i, prec);\n    });\n\n    float_signed_unsigned_triple_gen_var_2::<T, _>().test_properties(|(n, i, prec)| {\n        shl_prec_properties_helper_signed_helper(n, i, prec);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(n, prec)| {\n        let (shifted, o) = n.shl_prec_ref(T::ZERO, prec);\n        let (shifted_alt, o_alt) = Float::from_float_prec(n, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    signed_unsigned_pair_gen_var_19::<T, _>().test_properties(|(i, prec)| {\n        let (shifted, o) = Float::NAN.shl_prec(i, prec);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shl_prec(i, prec), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shl_prec(i, prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shl_prec(i, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shl_prec(i, prec);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    signed_unsigned_pair_gen_var_20::<T, _>().test_properties(|(i, prec)| {\n        let (shifted, o) = Float::ONE.shl_prec(i, prec);\n        if shifted.is_normal() {\n            assert!(shifted.is_power_of_2());\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_rug_unsigned_helper(n: Float, u: u32, prec: u64) {\n    let (shifted, o) = n.shl_prec_ref(u, prec);\n    let (rug_shifted, rug_o) = rug_shl_prec_unsigned(&rug::Float::exact_from(&n), u, prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_shifted)),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o, rug_o);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_rug_signed_helper(n: Float, i: i32, prec: u64) {\n    let (shifted, o) = n.shl_prec_ref(i, prec);\n    let (rug_shifted, rug_o) = rug_shl_prec_signed(&rug::Float::exact_from(&n), i, prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_shifted)),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o, rug_o);\n}\n\n#[test]\nfn shl_prec_properties() {\n    apply_fn_to_unsigneds!(shl_prec_properties_helper_unsigned);\n    apply_fn_to_signeds!(shl_prec_properties_helper_signed);\n\n    float_unsigned_unsigned_triple_gen_var_1::<u32, _>()\n        .test_properties(|(n, u, prec)| shl_prec_rug_unsigned_helper(n, u, prec));\n\n    float_unsigned_unsigned_triple_gen_var_2::<u32, _>()\n        .test_properties(|(n, u, prec)| shl_prec_rug_unsigned_helper(n, u, prec));\n\n    float_signed_unsigned_triple_gen_var_1::<i32, _>()\n        .test_properties(|(n, i, prec)| shl_prec_rug_signed_helper(n, i, prec));\n\n    float_signed_unsigned_triple_gen_var_2::<i32, _>()\n        .test_properties(|(n, i, prec)| shl_prec_rug_signed_helper(n, i, prec));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_round_properties_helper_unsigned_helper<T: PrimitiveUnsigned>(\n    n: Float,\n    u: T,\n    prec: u64,\n    rm: RoundingMode,\n) where\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shl_prec_round_assign(u, prec, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shl_prec_round_ref(u, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shl_prec_round_ref(u, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shl_prec_round(u, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shl_prec_round_naive(n.clone(), u, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted),\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    let (shifted_2, o_2) = (-&n).shl_prec_round(u, prec, rm);\n    let (shifted_2_alt, o_2_alt) = n.shl_prec_round_ref(u, prec, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) =\n            n.mul_prec_round(Float::power_of_2(u64::exact_from(u)), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shl_prec_round_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n{\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<T>().test_properties(\n        |(n, u, prec, rm)| {\n            shl_prec_round_properties_helper_unsigned_helper(n, u, prec, rm);\n        },\n    );\n\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2::<T>().test_properties(\n        |(n, u, prec, rm)| {\n            shl_prec_round_properties_helper_unsigned_helper(n, u, prec, rm);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, prec, rm)| {\n        let (shifted, o) = n.shl_prec_round_ref(T::ZERO, prec, rm);\n        let (shifted_alt, o_alt) = Float::from_float_prec_round(n, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    unsigned_unsigned_rounding_mode_triple_gen_var_7::<T, _>().test_properties(|(u, prec, rm)| {\n        let (shifted, o) = Float::NAN.shl_prec_round(u, prec, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(\n            Float::INFINITY.shl_prec_round(u, prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shl_prec_round(u, prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shl_prec_round(u, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shl_prec_round(u, prec, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_round_properties_helper_signed_helper<T: PrimitiveSigned>(\n    n: Float,\n    i: T,\n    prec: u64,\n    rm: RoundingMode,\n) where\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shl_prec_round_assign(i, prec, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shl_prec_round_ref(i, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shl_prec_round_ref(i, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shl_prec_round(i, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(i))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shl_prec_round_naive(n.clone(), i, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    if i >= T::ZERO {\n        let (shifted_alt, o_alt) = n.shl_prec_round_ref(i.unsigned_abs(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    } else if i != T::MIN {\n        let (shifted_alt, o_alt) = n.shr_prec_round_ref(i.unsigned_abs(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    };\n\n    let (shifted_2, o_2) = (-&n).shl_prec_round(i, prec, rm);\n    let (shifted_2_alt, o_2_alt) = n.shl_prec_round_ref(i, prec, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) =\n            n.mul_prec_round(Float::power_of_2(i64::exact_from(i)), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shl_prec_round_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shl<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<T>().test_properties(\n        |(n, i, prec, rm)| {\n            shl_prec_round_properties_helper_signed_helper(n, i, prec, rm);\n        },\n    );\n\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_2::<T>().test_properties(\n        |(n, i, prec, rm)| {\n            shl_prec_round_properties_helper_signed_helper(n, i, prec, rm);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, prec, rm)| {\n        let (shifted, o) = n.shl_prec_round_ref(T::ZERO, prec, rm);\n        let (shifted_alt, o_alt) = Float::from_float_prec_round(n, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    signed_unsigned_rounding_mode_triple_gen_var_7::<T, _>().test_properties(|(i, prec, rm)| {\n        let (shifted, o) = Float::NAN.shl_prec_round(i, prec, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(\n            Float::INFINITY.shl_prec_round(i, prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shl_prec_round(i, prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shl_prec_round(i, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shl_prec_round(i, prec, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    signed_unsigned_rounding_mode_triple_gen_var_8::<T, _>().test_properties(|(i, prec, rm)| {\n        let (shifted, o) = Float::ONE.shl_prec_round(i, prec, rm);\n        assert!(shifted.is_power_of_2());\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_round_rug_unsigned_helper(n: Float, u: u32, prec: u64, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = n.shl_prec_round_ref(u, prec, rm);\n        let (rug_shifted, rug_o) =\n            rug_shl_prec_round_unsigned(&rug::Float::exact_from(&n), u, prec, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_prec_round_rug_signed_helper(n: Float, i: i32, prec: u64, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = n.shl_prec_round_ref(i, prec, rm);\n        let (rug_shifted, rug_o) =\n            rug_shl_prec_round_signed(&rug::Float::exact_from(&n), i, prec, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[test]\nfn shl_prec_round_properties() {\n    apply_fn_to_unsigneds!(shl_prec_round_properties_helper_unsigned);\n    apply_fn_to_signeds!(shl_prec_round_properties_helper_signed);\n\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_1::<u32>()\n        .test_properties(|(n, u, prec, rm)| shl_prec_round_rug_unsigned_helper(n, u, prec, rm));\n\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_2::<u32>()\n        .test_properties(|(n, u, prec, rm)| shl_prec_round_rug_unsigned_helper(n, u, prec, rm));\n\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_1::<i32>()\n        .test_properties(|(n, i, prec, rm)| shl_prec_round_rug_signed_helper(n, i, prec, rm));\n\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_2::<i32>()\n        .test_properties(|(n, i, prec, rm)| shl_prec_round_rug_signed_helper(n, i, prec, rm));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_round_properties_helper_unsigned_helper<T: PrimitiveUnsigned>(\n    n: Float,\n    u: T,\n    rm: RoundingMode,\n) where\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: ShlRound<T, Output = Float> + ShlRoundAssign<T> + ShrRound<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shl_round_assign(u, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = (&n).shl_round(u, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = (&n).shl_round(u, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shl_round(u, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.shl_prec_round_ref(u, n.get_prec().unwrap_or(1), rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shl_round_naive(n.clone(), u, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if !n.is_nan() {\n        assert!((&n).shl_round(u, rm).0.ge_abs(&n));\n    }\n\n    let (shifted_2, o_2) = (-&n).shl_round(u, rm);\n    let (shifted_2_alt, o_2_alt) = (&n).shl_round(u, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) = n.mul_round(Float::power_of_2(u64::exact_from(u)), rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shl_round_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: ShlRound<T, Output = Float> + ShrRound<T, Output = Float> + ShlRoundAssign<T>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_unsigned_rounding_mode_triple_gen_var_5::<T>().test_properties(|(n, u, rm)| {\n        shl_round_properties_helper_unsigned_helper(n, u, rm);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_6::<T>().test_properties(|(n, u, rm)| {\n        shl_round_properties_helper_unsigned_helper(n, u, rm);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        let (shifted, o) = (&n).shl_round(T::ZERO, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(n));\n        assert_eq!(o, Equal);\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(u, rm)| {\n        let (shifted, o) = Float::NAN.shl_round(u, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shl_round(u, rm), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shl_round(u, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shl_round(u, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shl_round(u, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_5::<T>().test_properties(|(u, rm)| {\n        let (shifted, o) = Float::ONE.shl_round(u, rm);\n        assert!(shifted.is_power_of_2());\n        assert_eq!(o, Equal);\n    });\n\n    integer_unsigned_rounding_mode_triple_gen_var_5::<T>().test_properties(|(n, u, rm)| {\n        let (shifted, o) = Float::exact_from(&n).shl_round(u, rm);\n        assert_eq!(&n << u, shifted);\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_round_properties_helper_signed_helper<T: PrimitiveSigned>(n: Float, i: T, rm: RoundingMode)\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: ShlRound<T, Output = Float> + ShlRoundAssign<T> + ShrRound<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>\n        + ShlRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShrRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShrRound<T, Output = Float>,\n    i64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shl_round_assign(i, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = (&n).shl_round(i, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = (&n).shl_round(i, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shl_round(i, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.shl_prec_round_ref(i, n.get_prec().unwrap_or(1), rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(i))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shl_round_naive(n.clone(), i, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if !n.is_nan() {\n        if i >= T::ZERO {\n            assert!((&n).shl_round(i, rm).0.ge_abs(&n));\n        } else {\n            assert!((&n).shl_round(i, rm).0.le_abs(&n));\n        }\n    }\n\n    if i >= T::ZERO {\n        let (shifted_alt, o_alt) = (&n).shl_round(i.unsigned_abs(), rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    } else if i != T::MIN {\n        let (shifted_alt, o_alt) = (&n).shr_round(i.unsigned_abs(), rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    };\n\n    let (shifted_2, o_2) = (-&n).shl_round(i, rm);\n    let (shifted_2_alt, o_2_alt) = (&n).shl_round(i, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) = n.mul_round(Float::power_of_2(i64::exact_from(i)), rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shl_round_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Float: ShlRound<T, Output = Float> + ShlRoundAssign<T> + ShrRound<T, Output = Float>,\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Float: ShlRound<T, Output = Float>\n        + ShlRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShrRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShrRound<T, Output = Float>,\n    i64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_signed_rounding_mode_triple_gen_var_1::<T>().test_properties(|(n, i, rm)| {\n        shl_round_properties_helper_signed_helper(n, i, rm);\n    });\n\n    float_signed_rounding_mode_triple_gen_var_2::<T>().test_properties(|(n, i, rm)| {\n        shl_round_properties_helper_signed_helper(n, i, rm);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        let (shifted, o) = (&n).shl_round(T::ZERO, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(n));\n        assert_eq!(o, Equal);\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(i, rm)| {\n        let (shifted, o) = Float::NAN.shl_round(i, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shl_round(i, rm), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shl_round(i, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shl_round(i, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shl_round(i, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    signed_rounding_mode_pair_gen_var_5::<T>().test_properties(|(i, rm)| {\n        let (shifted, o) = Float::ONE.shl_round(i, rm);\n        assert!(shifted.is_power_of_2());\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_round_rug_unsigned_helper(n: Float, u: u32, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = (&n).shl_round(u, rm);\n        let (rug_shifted, rug_o) = rug_shl_round_unsigned(&rug::Float::exact_from(&n), u, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shl_round_rug_signed_helper(n: Float, i: i32, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = (&n).shl_round(i, rm);\n        let (rug_shifted, rug_o) = rug_shl_round_signed(&rug::Float::exact_from(&n), i, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[test]\nfn shl_round_properties() {\n    apply_fn_to_unsigneds!(shl_round_properties_helper_unsigned);\n    apply_fn_to_signeds!(shl_round_properties_helper_signed);\n\n    float_unsigned_rounding_mode_triple_gen_var_5::<u32>()\n        .test_properties(|(n, u, rm)| shl_round_rug_unsigned_helper(n, u, rm));\n\n    float_unsigned_rounding_mode_triple_gen_var_6::<u32>()\n        .test_properties(|(n, u, rm)| shl_round_rug_unsigned_helper(n, u, rm));\n\n    float_signed_rounding_mode_triple_gen_var_1::<i32>()\n        .test_properties(|(n, i, rm)| shl_round_rug_signed_helper(n, i, rm));\n\n    float_signed_rounding_mode_triple_gen_var_2::<i32>()\n        .test_properties(|(n, i, rm)| shl_round_rug_signed_helper(n, i, rm));\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, PowerOf2, ShrRound, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeZero, One, Zero,\n};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, unsigned_gen, unsigned_gen_var_5,\n};\nuse malachite_float::test_util::arithmetic::shr::shr_naive;\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::generators::{\n    float_gen, float_signed_pair_gen_var_2, float_signed_pair_gen_var_3,\n    float_unsigned_pair_gen_var_2, float_unsigned_pair_gen_var_3,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\nuse std::ops::{Shl, Shr, ShrAssign};\n\nfn test_shr_unsigned_helper<T: PrimitiveUnsigned, F: Fn(Float, T, Float)>(f: F)\nwhere\n    Float: ShrAssign<T> + Shr<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    let test = |s, s_hex, v: u64, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = x.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = &x >> v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = shr_naive(x.clone(), v);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n\n        f(x, v, n);\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"61.5\", \"0x3d.8#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"0.12\", \"0x0.1ec#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"9.7e-29\", \"0x7.bE-24#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-61.5\", \"-0x3d.8#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-0.12\", \"-0x0.1ec#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-9.7e-29\", \"-0x7.bE-24#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"1.5707963267948966\",\n        \"0x1.921fb54442d18#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.0030679615757712823\",\n        \"0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"2.4782796245465248e-30\",\n        \"0x3.243f6a8885a30E-25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-1.5707963267948966\",\n        \"-0x1.921fb54442d18#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-0.0030679615757712823\",\n        \"-0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-2.4782796245465248e-30\",\n        \"-0x3.243f6a8885a30E-25#53\",\n    );\n\n    let test_extreme = |s, s_hex, v: i32, out: &str, out_hex: &str| {\n        let v = u64::exact_from(v);\n        if T::convertible_from(v) {\n            test(s, s_hex, v, out, out_hex);\n        }\n    };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"too_small\",\n        \"0x4.0E-268435456#1\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n    );\n    test_extreme(\"1.0\", \"0x1.0#1\", Float::MAX_EXPONENT + 2, \"0.0\", \"0x0.0\");\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"-too_small\",\n        \"-0x4.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        \"-0.0\",\n        \"-0x0.0\",\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n    );\n}\n\n#[test]\nfn test_shr_unsigned() {\n    test_shr_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u32, _>(|x, v, shifted| {\n        let mut n = rug::Float::exact_from(&x);\n        n >>= v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n\n        let n = rug::Float::exact_from(&x) >> v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n    });\n    test_shr_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shr_signed_helper<T: PrimitiveSigned, F: Fn(Float, T, Float)>(f: F)\nwhere\n    Float: ShrAssign<T> + Shr<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n{\n    let test = |s, s_hex, v: i64, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = x.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = &x >> v;\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n\n        let n = shr_naive(x.clone(), v);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n\n        f(x, v, n);\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"61.5\", \"0x3d.8#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"0.12\", \"0x0.1ec#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"9.7e-29\", \"0x7.bE-24#7\");\n    test(\"123.0\", \"0x7b.0#7\", -1, \"246.0\", \"0xf6.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", -10, \"1.26e5\", \"0x1.ecE+4#7\");\n    test(\"123.0\", \"0x7b.0#7\", -100, \"1.56e32\", \"0x7.bE+26#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-61.5\", \"-0x3d.8#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-0.12\", \"-0x0.1ec#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-9.7e-29\", \"-0x7.bE-24#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -1, \"-246.0\", \"-0xf6.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -10, \"-1.26e5\", \"-0x1.ecE+4#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -100, \"-1.56e32\", \"-0x7.bE+26#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"1.5707963267948966\",\n        \"0x1.921fb54442d18#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.0030679615757712823\",\n        \"0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"2.4782796245465248e-30\",\n        \"0x3.243f6a8885a30E-25#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        \"6.283185307179586\",\n        \"0x6.487ed5110b460#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -10,\n        \"3216.9908772759482\",\n        \"0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        \"3.9824418129956972e30\",\n        \"0x3.243f6a8885a30E+25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-1.5707963267948966\",\n        \"-0x1.921fb54442d18#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-0.0030679615757712823\",\n        \"-0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-2.4782796245465248e-30\",\n        \"-0x3.243f6a8885a30E-25#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        \"-6.283185307179586\",\n        \"-0x6.487ed5110b460#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -10,\n        \"-3216.9908772759482\",\n        \"-0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        \"-3.9824418129956972e30\",\n        \"-0x3.243f6a8885a30E+25#53\",\n    );\n\n    let test_extreme = |s, s_hex, v: i32, out: &str, out_hex: &str| {\n        let v = i64::exact_from(v);\n        if T::convertible_from(v) {\n            test(s, s_hex, v, out, out_hex);\n        }\n    };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"too_small\",\n        \"0x4.0E-268435456#1\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n    );\n    test_extreme(\"1.0\", \"0x1.0#1\", Float::MAX_EXPONENT + 2, \"0.0\", \"0x0.0\");\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT - 1,\n        \"-too_small\",\n        \"-0x4.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        \"-0.0\",\n        \"-0x0.0\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT,\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT,\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n    );\n}\n\n#[test]\nfn test_shr_signed() {\n    test_shr_signed_helper::<i8, _>(|_, _, _| {});\n    test_shr_signed_helper::<i16, _>(|_, _, _| {});\n    test_shr_signed_helper::<i32, _>(|x, v, shifted| {\n        let mut n = rug::Float::exact_from(&x);\n        n >>= v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n\n        let n = rug::Float::exact_from(&x) >> v;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n    });\n    test_shr_signed_helper::<i64, _>(|_, _, _| {});\n    test_shr_signed_helper::<i128, _>(|_, _, _| {});\n    test_shr_signed_helper::<isize, _>(|_, _, _| {});\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_properties_helper_unsigned_helper<T: PrimitiveInt>(n: Float, u: T)\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShrRound<T, Output = Float>\n        + Shr<T, Output = Float>\n        + ShrAssign<T>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n    i64: TryFrom<T>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    mut_n >>= u;\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    let shifted_alt = &n >> u;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone() >> u;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shr_round(u, Nearest).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shr_prec(u, n.get_prec().unwrap_or(1)).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_sub(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let shifted_alt = shr_naive(n.clone(), u);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if !n.is_nan() {\n        assert!((&n >> u).le_abs(&n));\n    }\n    assert_eq!(ComparableFloat(-&n >> u), ComparableFloat(-(&n >> u)));\n\n    if shifted.is_normal() {\n        if shifted.get_exponent() != Some(Float::MIN_EXPONENT) {\n            assert_eq!(ComparableFloatRef(&(&n >> u << u)), ComparableFloatRef(&n));\n        }\n        assert_eq!(\n            ComparableFloatRef(&shifted),\n            ComparableFloatRef(\n                &(&n * Float::power_of_2(i64::exact_from(u).checked_neg().unwrap()))\n            )\n        );\n\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(n / Float::power_of_2(u64::exact_from(u)))\n        );\n    }\n}\n\nfn shr_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShrRound<T, Output = Float>\n        + Shr<T, Output = Float>\n        + ShrAssign<T>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shr<T, Output = Float>,\n    i64: TryFrom<T>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_unsigned_pair_gen_var_2::<T>().test_properties(|(n, u)| {\n        shr_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_unsigned_pair_gen_var_3::<T>().test_properties(|(n, u)| {\n        shr_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_gen().test_properties(|n| {\n        assert_eq!(ComparableFloat(&n >> T::ZERO), ComparableFloat(n));\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert!((Float::NAN >> u).is_nan());\n        assert_eq!(Float::INFINITY >> u, Float::INFINITY);\n        assert_eq!(Float::NEGATIVE_INFINITY >> u, Float::NEGATIVE_INFINITY);\n        assert_eq!(\n            ComparableFloat(Float::ZERO >> u),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(\n            ComparableFloat(Float::NEGATIVE_ZERO >> u),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n    });\n\n    unsigned_gen_var_5::<T>().test_properties(|u| {\n        assert!((Float::ONE >> u).is_power_of_2());\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_properties_helper_signed_helper<T: PrimitiveSigned>(n: Float, i: T)\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShrRound<T, Output = Float>\n        + ShrAssign<T>\n        + Shr<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>\n        + Shr<T, Output = Float>\n        + Shr<<T as UnsignedAbs>::Output, Output = Float>\n        + Shl<<T as UnsignedAbs>::Output, Output = Float>,\n    i64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    mut_n >>= i;\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    let shifted_alt = &n >> i;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone() >> i;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shr_round(i, Nearest).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    let shifted_alt = n.clone().shr_prec(i, n.get_prec().unwrap_or(1)).0;\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_sub(i128::exact_from(i))\n        .lt_abs(&1_000_000)\n    {\n        let shifted_alt = shr_naive(n.clone(), i);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if i >= T::ZERO {\n        assert_eq!(\n            ComparableFloatRef(&(&n >> i.unsigned_abs())),\n            ComparableFloatRef(&shifted)\n        );\n    } else if i != T::MIN {\n        assert_eq!(\n            ComparableFloatRef(&(&n << i.unsigned_abs())),\n            ComparableFloatRef(&shifted)\n        );\n    }\n    assert_eq!(ComparableFloat(-&n >> i), ComparableFloat(-(&n >> i)));\n    if let Some(neg_i) = i.checked_neg() {\n        assert_eq!(ComparableFloat(&n >> neg_i), ComparableFloat(&n << i));\n    }\n\n    if shifted.is_normal() {\n        if shifted.get_exponent() != Some(Float::MIN_EXPONENT) {\n            assert_eq!(ComparableFloatRef(&(&n >> i << i)), ComparableFloatRef(&n));\n        }\n        assert_eq!(\n            ComparableFloat(&n >> i),\n            ComparableFloat(&n * Float::power_of_2(i64::exact_from(i).checked_neg().unwrap()))\n        );\n\n        assert_eq!(\n            ComparableFloat(&n >> i),\n            ComparableFloat(n / Float::power_of_2(i64::exact_from(i)))\n        );\n    }\n}\n\nfn shr_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: Shl<T, Output = Float>\n        + ShrRound<T, Output = Float>\n        + ShrAssign<T>\n        + Shr<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: Shl<T, Output = Float>\n        + Shr<T, Output = Float>\n        + Shr<<T as UnsignedAbs>::Output, Output = Float>\n        + Shl<<T as UnsignedAbs>::Output, Output = Float>,\n    i64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_signed_pair_gen_var_2::<T>().test_properties(|(n, i)| {\n        shr_properties_helper_signed_helper(n, i);\n    });\n\n    float_signed_pair_gen_var_3::<T>().test_properties(|(n, i)| {\n        shr_properties_helper_signed_helper(n, i);\n    });\n\n    float_gen().test_properties(|n| {\n        assert_eq!(ComparableFloat(&n >> T::ZERO), ComparableFloat(n));\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert!((Float::NAN >> i).is_nan());\n        assert_eq!(Float::INFINITY >> i, Float::INFINITY);\n        assert_eq!(Float::NEGATIVE_INFINITY >> i, Float::NEGATIVE_INFINITY);\n        assert_eq!(\n            ComparableFloat(Float::ZERO >> i),\n            ComparableFloat(Float::ZERO)\n        );\n        assert_eq!(\n            ComparableFloat(Float::NEGATIVE_ZERO >> i),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n    });\n\n    signed_gen_var_5::<T>().test_properties(|i| {\n        assert!((Float::ONE >> i).is_power_of_2());\n    });\n}\n\n#[test]\nfn shr_properties() {\n    apply_fn_to_unsigneds!(shr_properties_helper_unsigned);\n    apply_fn_to_signeds!(shr_properties_helper_signed);\n\n    float_unsigned_pair_gen_var_2::<u32>().test_properties(|(n, u)| {\n        let shifted = &n >> u;\n        let mut rug_n = rug::Float::exact_from(&n);\n        rug_n >>= u;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(\n            ComparableFloat(Float::from(&(rug::Float::exact_from(&n) >> u))),\n            ComparableFloat(shifted)\n        );\n    });\n\n    float_signed_pair_gen_var_2::<i32>().test_properties(|(n, i)| {\n        let shifted = &n >> i;\n        let mut rug_n = rug::Float::exact_from(&n);\n        rug_n >>= i;\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(\n            ComparableFloat(Float::from(&(rug::Float::exact_from(&n) >> i))),\n            ComparableFloat(shifted)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    IsPowerOf2, PowerOf2, ShlRound, ShrRound, ShrRoundAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, signed_rounding_mode_pair_gen_var_5,\n    signed_unsigned_pair_gen_var_19, signed_unsigned_pair_gen_var_20,\n    signed_unsigned_rounding_mode_triple_gen_var_7, signed_unsigned_rounding_mode_triple_gen_var_8,\n    unsigned_pair_gen_var_18, unsigned_rounding_mode_pair_gen,\n    unsigned_rounding_mode_pair_gen_var_5, unsigned_unsigned_rounding_mode_triple_gen_var_7,\n};\nuse malachite_float::test_util::arithmetic::shr_round::{\n    rug_shr_prec_round_signed, rug_shr_prec_round_unsigned, rug_shr_prec_signed,\n    rug_shr_prec_unsigned, rug_shr_round_signed, rug_shr_round_unsigned, shr_prec_naive,\n    shr_prec_round_naive, shr_round_naive,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_rounding_mode_pair_gen, float_signed_rounding_mode_triple_gen_var_4,\n    float_signed_rounding_mode_triple_gen_var_5,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_signed_unsigned_triple_gen_var_1, float_signed_unsigned_triple_gen_var_2,\n    float_unsigned_pair_gen_var_1, float_unsigned_rounding_mode_triple_gen_var_1,\n    float_unsigned_rounding_mode_triple_gen_var_8, float_unsigned_rounding_mode_triple_gen_var_9,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3,\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4,\n    float_unsigned_unsigned_triple_gen_var_1, float_unsigned_unsigned_triple_gen_var_2,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\nuse std::ops::Shr;\nuse std::panic::catch_unwind;\n\nfn test_shr_prec_round_unsigned_helper<\n    T: PrimitiveUnsigned,\n    F: Fn(Float, T, u64, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShrRoundAssign<T> + ShrRound<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    let test_r = |s,\n                  s_hex,\n                  v: u64,\n                  prec: u64,\n                  rm: RoundingMode,\n                  out: &str,\n                  out_hex: &str,\n                  out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shr_prec_round_assign(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shr_prec_round(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shr_prec_round_ref(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shr_prec_round_naive(x.clone(), v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, rm, n, out_o);\n    };\n\n    let test = |s, s_hex, v: u64, prec: u64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            test_r(s, s_hex, v, prec, rm, out, out_hex, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\");\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\"123.0\", \"0x7b.0#7\", 10, 1, Floor, \"0.06\", \"0x0.1#1\", Less);\n    test_r(\n        \"123.0\", \"0x7b.0#7\", 10, 1, Ceiling, \"0.1\", \"0x0.2#1\", Greater,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 10, 1, Down, \"0.06\", \"0x0.1#1\", Less);\n    test_r(\"123.0\", \"0x7b.0#7\", 10, 1, Up, \"0.1\", \"0x0.2#1\", Greater);\n    test_r(\n        \"123.0\", \"0x7b.0#7\", 10, 1, Nearest, \"0.1\", \"0x0.2#1\", Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Down,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Floor,\n        \"-0.1\",\n        \"-0x0.2#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Ceiling,\n        \"-0.06\",\n        \"-0x0.1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Down,\n        \"-0.06\",\n        \"-0x0.1#1\",\n        Greater,\n    );\n    test_r(\"-123.0\", \"-0x7b.0#7\", 10, 1, Up, \"-0.1\", \"-0x0.2#1\", Less);\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Nearest,\n        \"-0.1\",\n        \"-0x0.2#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    test_r(\n        \"too_small\",\n        \"0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        Nearest,\n        \"too_small\",\n        \"0x1.00000000000000000E-268435456#66\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.00000000000000000E-268435456#66\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shr_prec_round_unsigned() {\n    test_shr_prec_round_unsigned_helper::<u8, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_unsigned_helper::<u16, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_unsigned_helper::<u32, _>(|x, v, prec, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shr_prec_round_unsigned(&rug::Float::exact_from(&x), v, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shr_prec_round_unsigned_helper::<u64, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_unsigned_helper::<u128, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_unsigned_helper::<usize, _>(|_, _, _, _, _, _| {});\n}\n\nfn test_shr_prec_round_signed_helper<\n    T: PrimitiveSigned,\n    F: Fn(Float, T, u64, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShrRoundAssign<T> + ShrRound<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    let test_r = |s,\n                  s_hex,\n                  v: i64,\n                  prec: u64,\n                  rm: RoundingMode,\n                  out: &str,\n                  out_hex: &str,\n                  out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shr_prec_round_assign(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shr_prec_round(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shr_prec_round_ref(v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shr_prec_round_naive(x.clone(), v, prec, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, rm, n, out_o);\n    };\n\n    let test = |s, s_hex, v: i64, prec: u64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            test_r(s, s_hex, v, prec, rm, out, out_hex, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, 1, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, 1, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, 1, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, 1, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, 1, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, 10, \"-0.0\", \"-0x0.0\");\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 0, 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"123.0\",\n        \"0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\"123.0\", \"0x7b.0#7\", 10, 1, Floor, \"0.06\", \"0x0.1#1\", Less);\n    test_r(\n        \"123.0\", \"0x7b.0#7\", 10, 1, Ceiling, \"0.1\", \"0x0.2#1\", Greater,\n    );\n    test_r(\"123.0\", \"0x7b.0#7\", 10, 1, Down, \"0.06\", \"0x0.1#1\", Less);\n    test_r(\"123.0\", \"0x7b.0#7\", 10, 1, Up, \"0.1\", \"0x0.2#1\", Greater);\n    test_r(\n        \"123.0\", \"0x7b.0#7\", 10, 1, Nearest, \"0.1\", \"0x0.2#1\", Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"0.1201\",\n        \"0x0.1ec0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        1,\n        Floor,\n        \"7.0e4\",\n        \"0x1.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        1,\n        Ceiling,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        1,\n        Down,\n        \"7.0e4\",\n        \"0x1.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        1,\n        Up,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        1,\n        Nearest,\n        \"1.0e5\",\n        \"0x2.0E+4#1\",\n        Greater,\n    );\n\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Floor,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Ceiling,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Down,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Up,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Nearest,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        Exact,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Floor,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Ceiling,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Down,\n        \"-6.0e1\",\n        \"-0x4.0E+1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Up,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        1,\n        Nearest,\n        \"-1.0e2\",\n        \"-0x8.0E+1#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Floor,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Ceiling,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Down,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Up,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Nearest,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        0,\n        10,\n        Exact,\n        \"-123.0\",\n        \"-0x7b.0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Floor,\n        \"-0.1\",\n        \"-0x0.2#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Ceiling,\n        \"-0.06\",\n        \"-0x0.1#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Down,\n        \"-0.06\",\n        \"-0x0.1#1\",\n        Greater,\n    );\n    test_r(\"-123.0\", \"-0x7b.0#7\", 10, 1, Up, \"-0.1\", \"-0x0.2#1\", Less);\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        1,\n        Nearest,\n        \"-0.1\",\n        \"-0x0.2#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Floor,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Ceiling,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Down,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Up,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Nearest,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        Exact,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Floor,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Ceiling,\n        \"-7.0e4\",\n        \"-0x1.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Down,\n        \"-7.0e4\",\n        \"-0x1.0E+4#1\",\n        Greater,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Up,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        1,\n        Nearest,\n        \"-1.0e5\",\n        \"-0x2.0E+4#1\",\n        Less,\n    );\n\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Floor,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Ceiling,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Down,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Up,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Nearest,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test_r(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        Exact,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -1,\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -1,\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -1,\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -1,\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_r(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -1,\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -1,\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -1,\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -1,\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -1,\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_r(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -1,\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_r(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    test_r(\n        \"too_small\",\n        \"0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        Nearest,\n        \"too_small\",\n        \"0x1.00000000000000000E-268435456#66\",\n        Greater,\n    );\n    test_r(\n        \"-too_small\",\n        \"-0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.00000000000000000E-268435456#66\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shr_prec_round_signed() {\n    test_shr_prec_round_signed_helper::<i8, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_signed_helper::<i16, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_signed_helper::<i32, _>(|x, v, prec, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shr_prec_round_signed(&rug::Float::exact_from(&x), v, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shr_prec_round_signed_helper::<i64, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_signed_helper::<i128, _>(|_, _, _, _, _, _| {});\n    test_shr_prec_round_signed_helper::<isize, _>(|_, _, _, _, _, _| {});\n}\n\n#[test]\nfn shr_prec_round_fail() {\n    assert_panic!(Float::ONE.shr_prec_round(Float::MIN_EXPONENT, 1, Exact));\n    assert_panic!(Float::ONE.shr_prec_round(Float::MAX_EXPONENT + 2, 1, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shr_prec_round(Float::MIN_EXPONENT, 1, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shr_prec_round(Float::MAX_EXPONENT + 2, 1, Exact));\n}\n\nfn test_shr_prec_unsigned_helper<T: PrimitiveUnsigned, F: Fn(Float, T, u64, Float, Ordering)>(f: F)\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    let test = |s, s_hex, v: u64, prec: u64, out: &str, out_hex: &str, out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shr_prec_assign(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shr_prec(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shr_prec_ref(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shr_prec_naive(x.clone(), v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, n, out_o);\n    };\n\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 0, 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 0, 10, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", 10, 1, \"0.1\", \"0x0.2#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 10, 10, \"0.1201\", \"0x0.1ec0#10\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 1, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 10, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, 1, \"-0.1\", \"-0x0.2#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        \"too_small\",\n        \"0x1.00000000000000000E-268435456#66\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        \"-too_small\",\n        \"-0x1.00000000000000000E-268435456#66\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shr_prec_unsigned() {\n    test_shr_prec_unsigned_helper::<u8, _>(|_, _, _, _, _| {});\n    test_shr_prec_unsigned_helper::<u16, _>(|_, _, _, _, _| {});\n    test_shr_prec_unsigned_helper::<u32, _>(|x, v, prec, shifted, o_out| {\n        let (n, o) = rug_shr_prec_unsigned(&rug::Float::exact_from(&x), v, prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, o_out);\n    });\n    test_shr_prec_unsigned_helper::<u64, _>(|_, _, _, _, _| {});\n    test_shr_prec_unsigned_helper::<u128, _>(|_, _, _, _, _| {});\n    test_shr_prec_unsigned_helper::<usize, _>(|_, _, _, _, _| {});\n}\n\nfn test_shr_prec_signed_helper<T: PrimitiveSigned, F: Fn(Float, T, u64, Float, Ordering)>(f: F)\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    let test = |s, s_hex, v: i64, prec: u64, out: &str, out_hex: &str, out_o: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let v = T::exact_from(v);\n\n        let mut n = x.clone();\n        let o = n.shr_prec_assign(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.clone().shr_prec(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = x.shr_prec_ref(v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert!(n.is_valid());\n        assert_eq!(o, out_o);\n\n        let (n, o) = shr_prec_naive(x.clone(), v, prec);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(to_hex_string(&n), out_hex);\n        assert_eq!(o, out_o);\n\n        f(x, v, prec, n, out_o);\n    };\n    test(\"NaN\", \"NaN\", 0, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 0, 10, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 10, 10, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", -10, 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", -10, 10, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 0, 10, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", 10, 1, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 10, 10, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", -10, 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", -10, 10, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        0,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        10,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        -10,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        -10,\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", 10, 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 10, 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", -10, 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", -10, 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 10, 10, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", -10, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", -10, 10, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 0, 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 0, 10, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", 10, 1, \"0.1\", \"0x0.2#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 10, 10, \"0.1201\", \"0x0.1ec0#10\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", -10, 1, \"1.0e5\", \"0x2.0E+4#1\", Greater);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        -10,\n        10,\n        \"1.26e5\",\n        \"0x1.ec0E+4#10\",\n        Equal,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 1, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n    test(\"-123.0\", \"-0x7b.0#7\", 0, 10, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, 1, \"-0.1\", \"-0x0.2#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        10,\n        \"-0.1201\",\n        \"-0x0.1ec0#10\",\n        Equal,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", -10, 1, \"-1.0e5\", \"-0x2.0E+4#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        -10,\n        10,\n        \"-1.26e5\",\n        \"-0x1.ec0E+4#10\",\n        Equal,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -1,\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -1,\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        1,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        \"too_small\",\n        \"0x1.00000000000000000E-268435456#66\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x4.df81e47e11c9aa6dE-268435455#67\",\n        7,\n        66,\n        \"-too_small\",\n        \"-0x1.00000000000000000E-268435456#66\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shr_prec_signed() {\n    test_shr_prec_signed_helper::<i8, _>(|_, _, _, _, _| {});\n    test_shr_prec_signed_helper::<i16, _>(|_, _, _, _, _| {});\n    test_shr_prec_signed_helper::<i32, _>(|x, v, prec, shifted, o_out| {\n        let (n, o) = rug_shr_prec_signed(&rug::Float::exact_from(&x), v, prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&n)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, o_out);\n    });\n    test_shr_prec_signed_helper::<i64, _>(|_, _, _, _, _| {});\n    test_shr_prec_signed_helper::<i128, _>(|_, _, _, _, _| {});\n    test_shr_prec_signed_helper::<isize, _>(|_, _, _, _, _| {});\n}\n\nfn test_shr_round_unsigned_helper<\n    T: PrimitiveUnsigned,\n    F: Fn(Float, T, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShrRoundAssign<T> + ShrRound<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    let test = |s, s_hex, v: u64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            let x = parse_hex_string(s_hex);\n            assert_eq!(x.to_string(), s);\n            let v = T::exact_from(v);\n\n            let mut n = x.clone();\n            let o = n.shr_round_assign(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = x.clone().shr_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = (&x).shr_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = shr_round_naive(x.clone(), v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert_eq!(o, Equal);\n\n            f(x, v, rm, n, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"61.5\", \"0x3d.8#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"0.12\", \"0x0.1ec#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"9.7e-29\", \"0x7.bE-24#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-61.5\", \"-0x3d.8#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-0.12\", \"-0x0.1ec#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-9.7e-29\", \"-0x7.bE-24#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"1.5707963267948966\",\n        \"0x1.921fb54442d18#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.0030679615757712823\",\n        \"0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"2.4782796245465248e-30\",\n        \"0x3.243f6a8885a30E-25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-1.5707963267948966\",\n        \"-0x1.921fb54442d18#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-0.0030679615757712823\",\n        \"-0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-2.4782796245465248e-30\",\n        \"-0x3.243f6a8885a30E-25#53\",\n    );\n\n    let test_extreme =\n        |s, s_hex, v: i32, rm: RoundingMode, out: &str, out_hex: &str, out_o: Ordering| {\n            let v = u64::exact_from(v);\n            if T::convertible_from(v) {\n                let x = parse_hex_string(s_hex);\n                assert_eq!(x.to_string(), s);\n                let v = T::exact_from(v);\n\n                let mut n = x.clone();\n                let o = n.shr_round_assign(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = x.clone().shr_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = (&x).shr_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = shr_round_naive(x.clone(), v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert_eq!(o, out_o);\n\n                f(x, v, rm, n, out_o);\n            }\n        };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Exact,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Ceiling,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Down,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Exact,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n}\n\n#[test]\nfn test_shr_round_unsigned() {\n    test_shr_round_unsigned_helper::<u8, _>(|_, _, _, _, _| {});\n    test_shr_round_unsigned_helper::<u16, _>(|_, _, _, _, _| {});\n    test_shr_round_unsigned_helper::<u32, _>(|x, v, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shr_round_unsigned(&rug::Float::exact_from(&x), v, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shr_round_unsigned_helper::<u64, _>(|_, _, _, _, _| {});\n    test_shr_round_unsigned_helper::<u128, _>(|_, _, _, _, _| {});\n    test_shr_round_unsigned_helper::<usize, _>(|_, _, _, _, _| {});\n}\n\nfn test_shr_round_signed_helper<\n    T: PrimitiveSigned,\n    F: Fn(Float, T, RoundingMode, Float, Ordering),\n>(\n    f: F,\n) where\n    Float: ShrRoundAssign<T> + ShrRound<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T, Output = Float>,\n{\n    let test = |s, s_hex, v: i64, out: &str, out_hex: &str| {\n        for rm in exhaustive_rounding_modes() {\n            let x = parse_hex_string(s_hex);\n            assert_eq!(x.to_string(), s);\n            let v = T::exact_from(v);\n\n            let mut n = x.clone();\n            let o = n.shr_round_assign(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = x.clone().shr_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = (&x).shr_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o, Equal);\n\n            let (n, o) = shr_round_naive(x.clone(), v, rm);\n            assert_eq!(n.to_string(), out);\n            assert_eq!(to_hex_string(&n), out_hex);\n            assert_eq!(o, Equal);\n\n            f(x, v, rm, n, Equal);\n        }\n    };\n    test(\"NaN\", \"NaN\", 0, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", 10, \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", -10, \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", 0, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", 10, \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", -10, \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 0, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", 10, \"-Infinity\", \"-Infinity\");\n    test(\"-Infinity\", \"-Infinity\", -10, \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", 10, \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", -10, \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", 10, \"-0.0\", \"-0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", -10, \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", 0, \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", 1, \"61.5\", \"0x3d.8#7\");\n    test(\"123.0\", \"0x7b.0#7\", 10, \"0.12\", \"0x0.1ec#7\");\n    test(\"123.0\", \"0x7b.0#7\", 100, \"9.7e-29\", \"0x7.bE-24#7\");\n    test(\"123.0\", \"0x7b.0#7\", -1, \"246.0\", \"0xf6.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", -10, \"1.26e5\", \"0x1.ecE+4#7\");\n    test(\"123.0\", \"0x7b.0#7\", -100, \"1.56e32\", \"0x7.bE+26#7\");\n\n    test(\"-123.0\", \"-0x7b.0#7\", 0, \"-123.0\", \"-0x7b.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"-61.5\", \"-0x3d.8#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"-0.12\", \"-0x0.1ec#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", 100, \"-9.7e-29\", \"-0x7.bE-24#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -1, \"-246.0\", \"-0xf6.0#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -10, \"-1.26e5\", \"-0x1.ecE+4#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", -100, \"-1.56e32\", \"-0x7.bE+26#7\");\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"1.5707963267948966\",\n        \"0x1.921fb54442d18#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"0.0030679615757712823\",\n        \"0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"2.4782796245465248e-30\",\n        \"0x3.243f6a8885a30E-25#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        \"6.283185307179586\",\n        \"0x6.487ed5110b460#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -10,\n        \"3216.9908772759482\",\n        \"0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        \"3.9824418129956972e30\",\n        \"0x3.243f6a8885a30E+25#53\",\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"-1.5707963267948966\",\n        \"-0x1.921fb54442d18#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-0.0030679615757712823\",\n        \"-0x0.00c90fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-2.4782796245465248e-30\",\n        \"-0x3.243f6a8885a30E-25#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        \"-6.283185307179586\",\n        \"-0x6.487ed5110b460#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -10,\n        \"-3216.9908772759482\",\n        \"-0xc90.fdaa22168c0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        \"-3.9824418129956972e30\",\n        \"-0x3.243f6a8885a30E+25#53\",\n    );\n\n    let test_extreme =\n        |s, s_hex, v: i32, rm: RoundingMode, out: &str, out_hex: &str, out_o: Ordering| {\n            let v = i64::from(v);\n            if T::convertible_from(v) {\n                let x = parse_hex_string(s_hex);\n                assert_eq!(x.to_string(), s);\n                let v = T::exact_from(v);\n\n                let mut n = x.clone();\n                let o = n.shr_round_assign(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = x.clone().shr_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = (&x).shr_round(v, rm);\n                assert_eq!(n.to_string(), out);\n                assert!(n.is_valid());\n                assert_eq!(o, out_o);\n\n                let (n, o) = shr_round_naive(x.clone(), v, rm);\n                assert_eq!(n.to_string(), out);\n                assert_eq!(to_hex_string(&n), out_hex);\n                assert_eq!(o, out_o);\n\n                f(x, v, rm, n, out_o);\n            }\n        };\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Ceiling,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Up,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Nearest,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Exact,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n    test_extreme(\n        \"1.5\",\n        \"0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Floor,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Up,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Nearest,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT + 1,\n        Exact,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MIN_EXPONENT,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Exact,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_extreme(\n        \"1.0\",\n        \"0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Ceiling,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Down,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 1,\n        Exact,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_extreme(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n    test_extreme(\n        \"-1.5\",\n        \"-0x1.8#2\",\n        Float::MAX_EXPONENT + 2,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        Less,\n    );\n}\n\n#[test]\nfn shr_round_fail() {\n    assert_panic!(Float::ONE.shr_round(Float::MIN_EXPONENT, Exact));\n    assert_panic!(Float::ONE.shr_round(Float::MAX_EXPONENT + 2, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shr_round(Float::MIN_EXPONENT, Exact));\n    assert_panic!(Float::NEGATIVE_ONE.shr_round(Float::MAX_EXPONENT + 2, Exact));\n}\n\n#[test]\nfn test_shr_round_signed() {\n    test_shr_round_signed_helper::<i8, _>(|_, _, _, _, _| {});\n    test_shr_round_signed_helper::<i16, _>(|_, _, _, _, _| {});\n    test_shr_round_signed_helper::<i32, _>(|x, v, rm, shifted, o_out| {\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (n, o) = rug_shr_round_signed(&rug::Float::exact_from(&x), v, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&n)),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o, o_out);\n        }\n    });\n    test_shr_round_signed_helper::<i64, _>(|_, _, _, _, _| {});\n    test_shr_round_signed_helper::<i128, _>(|_, _, _, _, _| {});\n    test_shr_round_signed_helper::<isize, _>(|_, _, _, _, _| {});\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_properties_helper_unsigned_helper<T: PrimitiveUnsigned>(n: Float, u: T, prec: u64)\nwhere\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shr_prec_assign(u, prec);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shr_prec_round_ref(u, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shr_prec_ref(u, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shr_prec(u, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shr_prec_naive(n.clone(), u, prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted),\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    let (shifted_2, o_2) = (-&n).shr_prec(u, prec);\n    let (shifted_2_alt, o_2_alt) = n.shr_prec_ref(u, prec);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) = n.div_prec(Float::power_of_2(u64::exact_from(u)), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shr_prec_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n{\n    float_unsigned_unsigned_triple_gen_var_1::<T, _>().test_properties(|(n, u, prec)| {\n        shr_prec_properties_helper_unsigned_helper(n, u, prec);\n    });\n\n    float_unsigned_unsigned_triple_gen_var_2::<T, _>().test_properties(|(n, u, prec)| {\n        shr_prec_properties_helper_unsigned_helper(n, u, prec);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(n, prec)| {\n        let (shifted, o) = n.shr_prec_ref(T::ZERO, prec);\n        let (shifted_alt, o_alt) = Float::from_float_prec(n, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    unsigned_pair_gen_var_18::<T, _>().test_properties(|(u, prec)| {\n        let (shifted, o) = Float::NAN.shr_prec(u, prec);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shr_prec(u, prec), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shr_prec(u, prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shr_prec(u, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shr_prec(u, prec);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_properties_helper_signed_helper<T: PrimitiveSigned>(n: Float, i: T, prec: u64)\nwhere\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shr_prec_assign(i, prec);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shr_prec_round_ref(i, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shr_prec_ref(i, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shr_prec(i, prec);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(i))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shr_prec_naive(n.clone(), i, prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    if i >= T::ZERO {\n        let (shifted_alt, o_alt) = n.shr_prec_ref(i.unsigned_abs(), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    } else if i != T::MIN {\n        let (shifted_alt, o_alt) = n.shl_prec_ref(i.unsigned_abs(), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    };\n\n    let (shifted_2, o_2) = (-&n).shr_prec(i, prec);\n    let (shifted_2_alt, o_2_alt) = n.shr_prec_ref(i, prec);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) = n.div_prec(Float::power_of_2(i64::exact_from(i)), prec);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shr_prec_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    float_signed_unsigned_triple_gen_var_1::<T, _>().test_properties(|(n, i, prec)| {\n        shr_prec_properties_helper_signed_helper(n, i, prec);\n    });\n\n    float_signed_unsigned_triple_gen_var_2::<T, _>().test_properties(|(n, i, prec)| {\n        shr_prec_properties_helper_signed_helper(n, i, prec);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(n, prec)| {\n        let (shifted, o) = n.shr_prec_ref(T::ZERO, prec);\n        let (shifted_alt, o_alt) = Float::from_float_prec(n, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    signed_unsigned_pair_gen_var_19::<T, _>().test_properties(|(i, prec)| {\n        let (shifted, o) = Float::NAN.shr_prec(i, prec);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shr_prec(i, prec), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shr_prec(i, prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shr_prec(i, prec);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shr_prec(i, prec);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    signed_unsigned_pair_gen_var_20::<T, _>().test_properties(|(i, prec)| {\n        let (shifted, o) = Float::ONE.shr_prec(i, prec);\n        if shifted.is_normal() {\n            assert!(shifted.is_power_of_2());\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_rug_unsigned_helper(n: Float, u: u32, prec: u64) {\n    let (shifted, o) = n.shr_prec_ref(u, prec);\n    let (rug_shifted, rug_o) = rug_shr_prec_unsigned(&rug::Float::exact_from(&n), u, prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_shifted)),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o, rug_o);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_rug_signed_helper(n: Float, i: i32, prec: u64) {\n    let (shifted, o) = n.shr_prec_ref(i, prec);\n    let (rug_shifted, rug_o) = rug_shr_prec_signed(&rug::Float::exact_from(&n), i, prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_shifted)),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o, rug_o);\n}\n\n#[test]\nfn shr_prec_properties() {\n    apply_fn_to_unsigneds!(shr_prec_properties_helper_unsigned);\n    apply_fn_to_signeds!(shr_prec_properties_helper_signed);\n\n    float_unsigned_unsigned_triple_gen_var_1::<u32, _>()\n        .test_properties(|(n, u, prec)| shr_prec_rug_unsigned_helper(n, u, prec));\n\n    float_unsigned_unsigned_triple_gen_var_2::<u32, _>()\n        .test_properties(|(n, u, prec)| shr_prec_rug_unsigned_helper(n, u, prec));\n\n    float_signed_unsigned_triple_gen_var_1::<i32, _>()\n        .test_properties(|(n, i, prec)| shr_prec_rug_signed_helper(n, i, prec));\n\n    float_signed_unsigned_triple_gen_var_2::<i32, _>()\n        .test_properties(|(n, i, prec)| shr_prec_rug_signed_helper(n, i, prec));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_round_properties_helper_unsigned_helper<T: PrimitiveUnsigned>(\n    n: Float,\n    u: T,\n    prec: u64,\n    rm: RoundingMode,\n) where\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shr_prec_round_assign(u, prec, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shr_prec_round_ref(u, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shr_prec_round_ref(u, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shr_prec_round(u, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shr_prec_round_naive(n.clone(), u, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted),\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    let (shifted_2, o_2) = (-&n).shr_prec_round(u, prec, rm);\n    let (shifted_2_alt, o_2_alt) = n.shr_prec_round_ref(u, prec, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) =\n            n.div_prec_round(Float::power_of_2(u64::exact_from(u)), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shr_prec_round_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    i128: TryFrom<T>,\n    u64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n{\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<T>().test_properties(\n        |(n, u, prec, rm)| {\n            shr_prec_round_properties_helper_unsigned_helper(n, u, prec, rm);\n        },\n    );\n\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4::<T>().test_properties(\n        |(n, u, prec, rm)| {\n            shr_prec_round_properties_helper_unsigned_helper(n, u, prec, rm);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, prec, rm)| {\n        let (shifted, o) = n.shr_prec_round_ref(T::ZERO, prec, rm);\n        let (shifted_alt, o_alt) = Float::from_float_prec_round(n, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    unsigned_unsigned_rounding_mode_triple_gen_var_7::<T, _>().test_properties(|(u, prec, rm)| {\n        let (shifted, o) = Float::NAN.shr_prec_round(u, prec, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(\n            Float::INFINITY.shr_prec_round(u, prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shr_prec_round(u, prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shr_prec_round(u, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shr_prec_round(u, prec, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_round_properties_helper_signed_helper<T: PrimitiveSigned>(\n    n: Float,\n    i: T,\n    prec: u64,\n    rm: RoundingMode,\n) where\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shr_prec_round_assign(i, prec, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = n.shr_prec_round_ref(i, prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = n.shr_prec_round_ref(i, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shr_prec_round(i, prec, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_add(i128::exact_from(i))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shr_prec_round_naive(n.clone(), i, prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(shifted.get_prec(), Some(prec));\n    }\n\n    if i >= T::ZERO {\n        let (shifted_alt, o_alt) = n.shr_prec_round_ref(i.unsigned_abs(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    } else if i != T::MIN {\n        let (shifted_alt, o_alt) = n.shl_prec_round_ref(i.unsigned_abs(), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    };\n\n    let (shifted_2, o_2) = (-&n).shr_prec_round(i, prec, rm);\n    let (shifted_2_alt, o_2_alt) = n.shr_prec_round_ref(i, prec, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        let (shifted_alt, o_alt) =\n            n.div_prec_round(Float::power_of_2(i64::exact_from(i)), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\nfn shr_prec_round_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    i128: TryFrom<T>,\n    i64: TryFrom<T>,\n    Rational: Shr<T, Output = Rational>,\n    <T as UnsignedAbs>::Output: PrimitiveUnsigned,\n{\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<T>().test_properties(\n        |(n, i, prec, rm)| {\n            shr_prec_round_properties_helper_signed_helper(n, i, prec, rm);\n        },\n    );\n\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_4::<T>().test_properties(\n        |(n, i, prec, rm)| {\n            shr_prec_round_properties_helper_signed_helper(n, i, prec, rm);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, prec, rm)| {\n        let (shifted, o) = n.shr_prec_round_ref(T::ZERO, prec, rm);\n        let (shifted_alt, o_alt) = Float::from_float_prec_round(n, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(shifted_alt));\n        assert_eq!(o, o_alt);\n    });\n\n    signed_unsigned_rounding_mode_triple_gen_var_7::<T, _>().test_properties(|(i, prec, rm)| {\n        let (shifted, o) = Float::NAN.shr_prec_round(i, prec, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(\n            Float::INFINITY.shr_prec_round(i, prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shr_prec_round(i, prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shr_prec_round(i, prec, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shr_prec_round(i, prec, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    signed_unsigned_rounding_mode_triple_gen_var_8::<T, _>().test_properties(|(i, prec, rm)| {\n        let (shifted, o) = Float::ONE.shr_prec_round(i, prec, rm);\n        assert!(shifted.is_power_of_2());\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_round_rug_unsigned_helper(n: Float, u: u32, prec: u64, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = n.shr_prec_round_ref(u, prec, rm);\n        let (rug_shifted, rug_o) =\n            rug_shr_prec_round_unsigned(&rug::Float::exact_from(&n), u, prec, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_prec_round_rug_signed_helper(n: Float, i: i32, prec: u64, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = n.shr_prec_round_ref(i, prec, rm);\n        let (rug_shifted, rug_o) =\n            rug_shr_prec_round_signed(&rug::Float::exact_from(&n), i, prec, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[test]\nfn shr_prec_round_properties() {\n    apply_fn_to_unsigneds!(shr_prec_round_properties_helper_unsigned);\n    apply_fn_to_signeds!(shr_prec_round_properties_helper_signed);\n\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_3::<u32>()\n        .test_properties(|(n, u, prec, rm)| shr_prec_round_rug_unsigned_helper(n, u, prec, rm));\n\n    float_unsigned_unsigned_rounding_mode_quadruple_gen_var_4::<u32>()\n        .test_properties(|(n, u, prec, rm)| shr_prec_round_rug_unsigned_helper(n, u, prec, rm));\n\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_3::<i32>()\n        .test_properties(|(n, i, prec, rm)| shr_prec_round_rug_signed_helper(n, i, prec, rm));\n\n    float_signed_unsigned_rounding_mode_quadruple_gen_var_4::<i32>()\n        .test_properties(|(n, i, prec, rm)| shr_prec_round_rug_signed_helper(n, i, prec, rm));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_round_properties_helper_unsigned_helper<T: PrimitiveUnsigned>(\n    n: Float,\n    u: T,\n    rm: RoundingMode,\n) where\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: ShrRound<T, Output = Float> + ShrRoundAssign<T> + ShlRound<T, Output = Float>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T, Output = Float> + Shr<T, Output = Float>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shr_round_assign(u, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = (&n).shr_round(u, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = (&n).shr_round(u, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shr_round(u, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.shr_prec_round_ref(u, n.get_prec().unwrap_or(1), rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_sub(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shr_round_naive(n.clone(), u, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if i128::from(n.get_exponent().unwrap_or(1))\n        .wrapping_sub(i128::exact_from(u))\n        .lt_abs(&1_000_000)\n    {\n        let (shifted_alt, o_alt) = shr_round_naive(n.clone(), u, rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    }\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if !n.is_nan() {\n        assert!((&n).shr_round(u, rm).0.le_abs(&n));\n    }\n\n    let (shifted_2, o_2) = (-&n).shr_round(u, rm);\n    let (shifted_2_alt, o_2_alt) = (&n).shr_round(u, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        assert_eq!(\n            ComparableFloat(&n >> u),\n            ComparableFloat(n / Float::power_of_2(u64::exact_from(u)))\n        );\n    }\n}\n\nfn shr_round_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: ShrRound<T, Output = Float> + ShlRound<T, Output = Float> + ShrRoundAssign<T>,\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Float: ShrRound<T, Output = Float> + Shr<T, Output = Float>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_unsigned_rounding_mode_triple_gen_var_8::<T>().test_properties(|(n, u, rm)| {\n        shr_round_properties_helper_unsigned_helper(n, u, rm);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_9::<T>().test_properties(|(n, u, rm)| {\n        shr_round_properties_helper_unsigned_helper(n, u, rm);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        let (shifted, o) = (&n).shr_round(T::ZERO, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(n));\n        assert_eq!(o, Equal);\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(u, rm)| {\n        let (shifted, o) = Float::NAN.shr_round(u, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shr_round(u, rm), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shr_round(u, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shr_round(u, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shr_round(u, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_5::<T>().test_properties(|(u, rm)| {\n        let (shifted, o) = Float::ONE.shr_round(u, rm);\n        assert!(shifted.is_power_of_2());\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_round_properties_helper_signed_helper<T: PrimitiveSigned>(n: Float, i: T, rm: RoundingMode)\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: ShrRound<T, Output = Float> + ShrRoundAssign<T> + ShlRound<T, Output = Float>,\n    for<'a> &'a Float: ShrRound<T, Output = Float>\n        + Shr<T, Output = Float>\n        + ShrRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShlRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShlRound<T, Output = Float>,\n    u64: TryFrom<T>,\n    i64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    let mut mut_n = n.clone();\n    let o = mut_n.shr_round_assign(i, rm);\n    assert!(mut_n.is_valid());\n    let shifted = mut_n;\n\n    match (n >= 0, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (shifted_alt, o_alt) = (&n).shr_round(i, rm);\n            assert_eq!(\n                ComparableFloatRef(&shifted_alt),\n                ComparableFloatRef(&shifted)\n            );\n            assert_eq!(o_alt, Equal);\n        }\n    }\n\n    let (shifted_alt, o_alt) = (&n).shr_round(i, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.clone().shr_round(i, rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    let (shifted_alt, o_alt) = n.shr_prec_round_ref(i, n.get_prec().unwrap_or(1), rm);\n    assert!(shifted_alt.is_valid());\n    assert_eq!(\n        ComparableFloatRef(&shifted_alt),\n        ComparableFloatRef(&shifted)\n    );\n    assert_eq!(o_alt, o);\n\n    if shifted.is_normal() {\n        assert_eq!(n.get_prec(), shifted.get_prec());\n    }\n\n    if !n.is_nan() {\n        if i >= T::ZERO {\n            assert!((&n).shr_round(i, rm).0.le_abs(&n));\n        } else {\n            assert!((&n).shr_round(i, rm).0.ge_abs(&n));\n        }\n    }\n\n    if i >= T::ZERO {\n        let (shifted_alt, o_alt) = (&n).shr_round(i.unsigned_abs(), rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    } else if i != T::MIN {\n        let (shifted_alt, o_alt) = (&n).shl_round(i.unsigned_abs(), rm);\n        assert_eq!(\n            ComparableFloatRef(&shifted_alt),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o_alt, o);\n    };\n\n    let (shifted_2, o_2) = (-&n).shr_round(i, rm);\n    let (shifted_2_alt, o_2_alt) = (&n).shr_round(i, -rm);\n    assert_eq!(ComparableFloat(-shifted_2_alt), ComparableFloat(shifted_2));\n    assert_eq!(o_2_alt.reverse(), o_2);\n\n    if shifted.is_normal() {\n        assert_eq!(\n            ComparableFloat(&n >> i),\n            ComparableFloat(n / Float::power_of_2(i64::exact_from(i)))\n        );\n    }\n}\n\nfn shr_round_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Float: ShrRound<T, Output = Float> + ShrRoundAssign<T> + ShlRound<T, Output = Float>,\n    for<'a> &'a Float: ShrRound<T, Output = Float>\n        + Shr<T, Output = Float>\n        + ShrRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShlRound<<T as UnsignedAbs>::Output, Output = Float>\n        + ShlRound<T, Output = Float>,\n    i64: TryFrom<T>,\n    u64: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    float_signed_rounding_mode_triple_gen_var_4::<T>().test_properties(|(n, i, rm)| {\n        shr_round_properties_helper_signed_helper(n, i, rm);\n    });\n\n    float_signed_rounding_mode_triple_gen_var_5::<T>().test_properties(|(n, i, rm)| {\n        shr_round_properties_helper_signed_helper(n, i, rm);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        let (shifted, o) = (&n).shr_round(T::ZERO, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(n));\n        assert_eq!(o, Equal);\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(i, rm)| {\n        let (shifted, o) = Float::NAN.shr_round(i, rm);\n        assert!(shifted.is_nan());\n        assert_eq!(o, Equal);\n        assert_eq!(Float::INFINITY.shr_round(i, rm), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.shr_round(i, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (shifted, o) = Float::ZERO.shr_round(i, rm);\n        assert_eq!(ComparableFloat(shifted), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (shifted, o) = Float::NEGATIVE_ZERO.shr_round(i, rm);\n        assert_eq!(\n            ComparableFloat(shifted),\n            ComparableFloat(Float::NEGATIVE_ZERO)\n        );\n        assert_eq!(o, Equal);\n    });\n\n    signed_rounding_mode_pair_gen_var_5::<T>().test_properties(|(i, rm)| {\n        let (shifted, o) = Float::ONE.shr_round(i, rm);\n        assert!(shifted.is_power_of_2());\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_round_rug_unsigned_helper(n: Float, u: u32, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = (&n).shr_round(u, rm);\n        let (rug_shifted, rug_o) = rug_shr_round_unsigned(&rug::Float::exact_from(&n), u, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn shr_round_rug_signed_helper(n: Float, i: i32, rm: RoundingMode) {\n    if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n        let (shifted, o) = (&n).shr_round(i, rm);\n        let (rug_shifted, rug_o) = rug_shr_round_signed(&rug::Float::exact_from(&n), i, rug_rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_shifted)),\n            ComparableFloatRef(&shifted)\n        );\n        assert_eq!(o, rug_o);\n    }\n}\n\n#[test]\nfn shr_round_properties() {\n    apply_fn_to_unsigneds!(shr_round_properties_helper_unsigned);\n    apply_fn_to_signeds!(shr_round_properties_helper_signed);\n\n    float_unsigned_rounding_mode_triple_gen_var_8::<u32>()\n        .test_properties(|(n, u, rm)| shr_round_rug_unsigned_helper(n, u, rm));\n\n    float_unsigned_rounding_mode_triple_gen_var_9::<u32>()\n        .test_properties(|(n, u, rm)| shr_round_rug_unsigned_helper(n, u, rm));\n\n    float_signed_rounding_mode_triple_gen_var_4::<i32>()\n        .test_properties(|(n, i, rm)| shr_round_rug_signed_helper(n, i, rm));\n\n    float_signed_rounding_mode_triple_gen_var_5::<i32>()\n        .test_properties(|(n, i, rm)| shr_round_rug_signed_helper(n, i, rm));\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::traits::NaN;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::primitive_float_gen_var_11;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{float_gen_var_2, float_gen_var_3, float_gen_var_14};\nuse malachite_q::Rational;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_sign() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.sign(), out);\n    };\n    test(\"Infinity\", \"Infinity\", Greater);\n    test(\"-Infinity\", \"-Infinity\", Less);\n    test(\"0.0\", \"0x0.0\", Greater);\n    test(\"-0.0\", \"-0x0.0\", Less);\n\n    test(\"1.0\", \"0x1.0#1\", Greater);\n    test(\"2.0\", \"0x2.0#1\", Greater);\n    test(\"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", Greater);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", Greater);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", Greater);\n    test(\"too_big\", \"0x4.0E+268435455#1\", Greater);\n    test(\"too_small\", \"0x1.0E-268435456#1\", Greater);\n\n    test(\"-1.0\", \"-0x1.0#1\", Less);\n    test(\"-2.0\", \"-0x2.0#1\", Less);\n    test(\"-0.5\", \"-0x0.8#1\", Less);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", Less);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", Less);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", Less);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", Less);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", Less);\n}\n\n#[test]\n#[should_panic]\nfn sign_fail() {\n    Float::NAN.sign();\n}\n\nfn sign_properties_helper(x: Float) {\n    let sign = x.sign();\n    assert_ne!(sign, Equal);\n    assert_eq!(if x.is_sign_positive() { Greater } else { Less }, sign);\n    assert_eq!((-x).sign(), sign.reverse());\n}\n\n#[test]\nfn sign_properties() {\n    float_gen_var_2().test_properties(|x| {\n        sign_properties_helper(x);\n    });\n\n    float_gen_var_14().test_properties(|x| {\n        sign_properties_helper(x);\n    });\n\n    float_gen_var_3().test_properties(|x| {\n        assert_eq!(x.sign(), Rational::exact_from(x).sign());\n    });\n\n    primitive_float_gen_var_11::<f64>().test_properties(|x| {\n        assert_eq!(x.sign(), Float::from(x).sign());\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\nuse core::{f32, f64};\nuse malachite_base::num::arithmetic::traits::{PowerOf2, Sqrt, SqrtAssign, Square};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, rounding_mode_gen, unsigned_gen_var_11,\n    unsigned_rounding_mode_pair_gen_var_3,\n};\nuse malachite_float::arithmetic::sqrt::primitive_float_sqrt_rational;\nuse malachite_float::emulate_float_to_float_fn;\nuse malachite_float::test_util::arithmetic::sqrt::{\n    rug_sqrt, rug_sqrt_prec, rug_sqrt_prec_round, rug_sqrt_round, sqrt_rational_prec_round_generic,\n    sqrt_rational_prec_round_simple,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_6, float_gen_var_7, float_gen_var_8, float_gen_var_11,\n    float_gen_var_12, float_rounding_mode_pair_gen_var_24, float_rounding_mode_pair_gen_var_25,\n    float_rounding_mode_pair_gen_var_26, float_rounding_mode_pair_gen_var_27,\n    float_rounding_mode_pair_gen_var_28, float_rounding_mode_pair_gen_var_29,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_13, float_unsigned_rounding_mode_triple_gen_var_14,\n    rational_unsigned_rounding_mode_triple_gen_var_3,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_pair_gen, rational_unsigned_pair_gen_var_3,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_sqrt() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let sqrt = x.clone().sqrt();\n        assert!(sqrt.is_valid());\n\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n\n        let sqrt_alt = (&x).sqrt();\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n\n        let mut sqrt_alt = x.clone();\n        sqrt_alt.sqrt_assign();\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt(&rug::Float::exact_from(&x)))),\n            ComparableFloatRef(&sqrt)\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\");\n    // - in sqrt_float_significand_ref\n    // - in sqrt_float_significand_ref_helper\n    // - in sqrt_float_significand_same_prec_ref\n    // - 1 limb in sqrt_float_significand_same_prec_ref\n    // - in sqrt_float_significand_same_prec_lt_w\n    // - exp_u.odd() in sqrt_float_significand_same_prec_lt_w\n    // - in limb_sqrt_approx\n    // - in half_limb_sqrt_approx\n    // - z <= 2 * (LIMIT - 1) in limb_sqrt_approx\n    // - z > y + y in limb_sqrt_approx\n    // - r0.wrapping_add(7) & (mask >> 1) <= 7 in sqrt_float_significand_same_prec_lt_w\n    // - rb == 0 || (rb == 1 && sb <= r0.wrapping_mul(2)) in sqrt_float_significand_same_prec_lt_w\n    // - sb == 0 in sqrt_float_significand_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"-1.0\", \"-0x1.0#1\", \"NaN\", \"NaN\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n    );\n    test(\"-1.0\", \"-0x1.0000000000000000000000000#100\", \"NaN\", \"NaN\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"11.1\", \"0xb.2#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1.7724538509055159\",\n        \"0x1.c5bf891b4ef6a#53\",\n    );\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"NaN\", \"NaN\");\n\n    test(\n        \"245015989.087862987938504839548125246171\",\n        \"0xe9aa5b5.167e3053b9874c7a7e9ad42ec#126\",\n        \"15652.9865868422371154837031363385510498\",\n        \"0x3d24.fc90f48e1283b9ddd9ddcd80c651#126\",\n    );\n    test(\n        \"8207.999969482421875000000208449716311754706238513360135037\",\n        \"0x200f.fffe00000000000000fc000ffffffffe7fffffffe0000#191\",\n        \"90.59801305482599751936121493336015116751576530601123201492\",\n        \"0x5a.991762310f07e6c407b327fcf04aa587cf47462012c4a5#191\",\n    );\n    test(\n        \"255.99998475609754677861929270691580954\",\n        \"0xff.ffff003ff00000000003ffffffffc#122\",\n        \"15.999999523628041245261756402527546248\",\n        \"0xf.fffff801ff7e00ff9f10dd9f7ca998#122\",\n    );\n    test(\n        \"0.9175812291850011518031983506835431746\",\n        \"0x0.eae69a7ac5e74e0580d8afa7065e9b0#121\",\n        \"0.9579046033843877252229074148114839997\",\n        \"0x0.f5393c70394ab5224b7b609430e0038#121\",\n    );\n}\n\n#[test]\nfn test_sqrt_prec() {\n    let test = |s, s_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (sqrt, o) = x.clone().sqrt_prec(prec);\n        assert!(sqrt.is_valid());\n\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, o_out);\n\n        let (sqrt_alt, o_alt) = x.sqrt_prec_ref(prec);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sqrt_alt = x.clone();\n        let o_alt = sqrt_alt.sqrt_prec_assign(prec);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (rug_sqrt, rug_o) = rug_sqrt_prec(&rug::Float::exact_from(&x), prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt)),\n            ComparableFloatRef(&sqrt),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"NaN\", \"NaN\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"NaN\", \"NaN\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", 1, \"8.0\", \"0x8.0#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 10, \"11.09\", \"0xb.18#10\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, \"NaN\", \"NaN\", Equal);\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"1.771\",\n        \"0x1.c58#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"0.004\",\n        \"0x0.01#1\",\n        159,\n        \"0.0625\",\n        \"0x0.10000000000000000000000000000000000000000#159\",\n        Equal,\n    );\n    test(\n        \"3.977856078879580383473276114029204544685854243426e189\",\n        \"0x3.9238e0e804fbb07c90c48c1a3f2717fe767aa541E+157#162\",\n        162,\n        \"6.307024717630001791804921737602144987170364743623e94\",\n        \"0x7.8f1c619832e271db7d7c00000000000000000000E+78#162\",\n        Equal,\n    );\n    // - rm == Nearest && sticky1 == (1 << (sh - 1)) && !sqrt_inexact && sticky0 == 0 in\n    //   sqrt_float_significands_general\n    // - in even_rule\n    // - sh < Limb::WIDTH in even_rule\n    // - rp[0] & (1 << sh) != 0 in even_rule\n    // - inexact != Less in even_rule\n    test(\"2.2\", \"0x2.4#4\", 1, \"2.0\", \"0x2.0#1\", Greater);\n    // - rp[0] & (1 << sh) == 0 in even_rule\n    // - inexact == Less in even_rule\n    test(\"1.56\", \"0x1.9#5\", 2, \"1.0\", \"0x1.0#2\", Less);\n    // - u_size > rrsize in sqrt_float_significands_general\n    // - u_size > rrsize && !odd_exp in sqrt_float_significands_general\n    // - sticky0 == 0 && l != 0 in sqrt_float_significands_general\n    test(\n        \"0.000199046277632504184666664672269768242929310652018203552191617720205649\",\n        \"0x0.000d0b7140b8f3aea60aad60c1dc3b2ee0d83e2eba33dcfb6f874df52d78#225\",\n        26,\n        \"0.0141083761\",\n        \"0x0.039c9b46#26\",\n        Less,\n    );\n    // - u_size <= rrsize && odd_exp && k == 0 in sqrt_float_significands_general\n    test(\n        \"330.3297903358337046735382484655688\",\n        \"0x14a.546d23b2f14f71a1f4c12ddaa88#115\",\n        45,\n        \"18.17497703811\",\n        \"0x12.2ccb4b903c#45\",\n        Greater,\n    );\n    // - u_size > rrsize && odd_exp in sqrt_float_significands_general\n    test(\n        \"4.377225292368646512419693467837359069662104001145e-12\",\n        \"0x4.d01452b8a6a69b159aa9fe42a13c8852969ebbf2E-10#163\",\n        31,\n        \"2.092181946e-6\",\n        \"0x0.00002319da608#31\",\n        Greater,\n    );\n    // - sticky0 != 0 || l == 0 in sqrt_float_significands_general\n    test(\n        \"1.05073202367937779245019344912798895329031793654792205944648e-92\",\n        \"0x5.7ab7ff36bcc0024c64f4507f522e91df687d9649e2e60984E-77#195\",\n        53,\n        \"1.0250522053434049e-46\",\n        \"0x9.5cfc196264d98E-39#53\",\n        Greater,\n    );\n}\n\n#[test]\nfn sqrt_prec_fail() {\n    assert_panic!(Float::NAN.sqrt_prec(0));\n    assert_panic!(Float::NAN.sqrt_prec_ref(0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.sqrt_prec_assign(0)\n    });\n}\n\n#[test]\nfn test_sqrt_round() {\n    let test = |s, s_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (sqrt, o) = x.clone().sqrt_round(rm);\n        assert!(sqrt.is_valid());\n\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, o_out);\n\n        let (sqrt_alt, o_alt) = x.sqrt_round_ref(rm);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sqrt_alt = x.clone();\n        let o_alt = sqrt_alt.sqrt_round_assign(rm);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sqrt, rug_o) = rug_sqrt_round(&rug::Float::exact_from(&x), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sqrt)),\n                ComparableFloatRef(&sqrt),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\"-Infinity\", \"-Infinity\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", Floor, \"11.0\", \"0xb.0#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Ceiling, \"11.1\", \"0xb.2#7\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", Down, \"11.0\", \"0xb.0#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Up, \"11.1\", \"0xb.2#7\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", Nearest, \"11.1\", \"0xb.2#7\", Greater);\n\n    test(\"-123.0\", \"-0x7b.0#7\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"1.7724538509055159\",\n        \"0x1.c5bf891b4ef6a#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"1.7724538509055161\",\n        \"0x1.c5bf891b4ef6b#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"1.7724538509055159\",\n        \"0x1.c5bf891b4ef6a#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"1.7724538509055161\",\n        \"0x1.c5bf891b4ef6b#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"1.7724538509055159\",\n        \"0x1.c5bf891b4ef6a#53\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    // - exp_u.even() in sqrt_float_significand_same_prec_lt_w\n    // - z <= y + y in limb_sqrt_approx\n    // - r0.wrapping_add(7) & (mask >> 1) > 7 in sqrt_float_significand_same_prec_lt_w\n    // - sb != 0 in sqrt_float_significand_same_prec_lt_w\n    // - rm == Nearest in sqrt_float_significand_same_prec_lt_w\n    // - rm == Nearest && rb == 0 in sqrt_float_significand_same_prec_lt_w\n    test(\"2.0\", \"0x2.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Less);\n    // - rm == Nearest && rb != 0 in sqrt_float_significand_same_prec_lt_w\n    // - rm == Nearest && rb != 0 && r0 != 0 in sqrt_float_significand_same_prec_lt_w\n    test(\"2.0\", \"0x2.0#2\", Nearest, \"1.5\", \"0x1.8#2\", Greater);\n    // - z > 2 * (LIMIT - 1) in limb_sqrt_approx\n    test(\"3.5\", \"0x3.8#3\", Nearest, \"1.8\", \"0x1.c#3\", Less);\n    // - !(rb == 0 || (rb == 1 && sb <= r0.wrapping_mul(2))) in\n    //   sqrt_float_significand_same_prec_lt_w\n    test(\n        \"8.56684288039927757e26\",\n        \"0x2.c4a1f44fb4eb72cE+22#60\",\n        Nearest,\n        \"29269169582342.57382\",\n        \"0x1a9ec274b106.92e6#60\",\n        Greater,\n    );\n    // - in sqrt_float_significand_same_prec_w\n    // - exp_u.odd() in sqrt_float_significand_same_prec_w\n    // - rb == 0 || (rb == 1 && sb <= r0.wrapping_mul(2)) in sqrt_float_significand_same_prec_w\n    // - sb == 0 in sqrt_float_significand_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Equal,\n    );\n    // - exp_u.even() in sqrt_float_significand_same_prec_w\n    // - !(rb == 0 || (rb == 1 && sb <= r0.wrapping_mul(2))) in sqrt_float_significand_same_prec_w\n    // - sb != 0 in sqrt_float_significand_same_prec_w\n    // - rm == Nearest in sqrt_float_significand_same_prec_w\n    // - rm == Nearest && rb == 0 in sqrt_float_significand_same_prec_w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Nearest,\n        \"1.4142135623730950488\",\n        \"0x1.6a09e667f3bcc908#64\",\n        Less,\n    );\n    // - rm == Nearest && rb != 0 in sqrt_float_significand_same_prec_w\n    // - rm == Nearest && rb != 0 && r0 != 0 in sqrt_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n        Nearest,\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Greater,\n    );\n    // - 2 limbs, prec != 2*w in sqrt_float_significand_same_prec_ref\n    // - in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - exp_u.odd() in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - in limbs_2_sqrt_approx\n    // - in limb_sqrt\n    // - in limb_inverse_sqrt_approx\n    // - !r.get_highest_bit() in limb_sqrt\n    // - h < 16 in limb_sqrt\n    // - h < 8 in limb_sqrt\n    // - h < 4 in limb_sqrt\n    // - h <= 1 && ((h != 1) || (l <= r.wrapping_mul(2))) in limb_sqrt\n    // - h == 0 in limbs_2_sqrt_approx\n    // - r0.wrapping_add(26) & (mask >> 1) <= 30 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - SignedLimb::wrapping_from(t2) >= 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - t2 <= 1 && (t2 != 1 || t1 <= h) && (t2 != 1 || t1 != h || t0 <= l) in\n    //   sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - sb == 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Equal,\n    );\n    // - exp_u.even() in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - r.get_highest_bit() in limb_sqrt\n    // - h >= 4 in limb_sqrt\n    // - h > 1 || ((h == 1) && (l > r.wrapping_mul(2))) in limb_sqrt\n    // - r0.wrapping_add(26) & (mask >> 1) > 30 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - sb != 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest && rb != 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest && rb != 0 && r1 != 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Nearest,\n        \"1.41421356237309504882\",\n        \"0x1.6a09e667f3bcc909#65\",\n        Greater,\n    );\n    // - t2 > 1 || (t2 == 1 && t1 > h) || (t2 == 1 && t1 == h && t0 > l) in\n    //   sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest && rb == 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Less,\n    );\n    // - h != 0 in limbs_2_sqrt_approx\n    test(\n        \"2.00000000000000000125\",\n        \"0x2.0000000000000017#66\",\n        Nearest,\n        \"1.41421356237309504925\",\n        \"0x1.6a09e667f3bcc9110#66\",\n        Greater,\n    );\n    // - h >= 8 in limb_sqrt\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        Nearest,\n        \"120008682170084.730095556159\",\n        \"0x6d25b2dee6e4.bae78ad8a8#85\",\n        Greater,\n    );\n    // - h >= 16 in limb_sqrt\n    test(\n        \"14.8543972813270696412821\",\n        \"0xe.dab9c7bd1750bad37350#83\",\n        Nearest,\n        \"3.8541402778475862892890363\",\n        \"0x3.daa8efef8d3e9881bc6d0#83\",\n        Less,\n    );\n    // - default case in sqrt_float_significand_same_prec_ref\n    // - in sqrt_float_significands_general\n    // - sh != 0 || rm != Nearest in sqrt_float_significands_general\n    // - u_size <= rrsize in sqrt_float_significands_general\n    // - u_size <= rrsize || !odd_exp in sqrt_float_significands_general\n    // - sticky0 in sqrt_float_significands_general\n    // - rm == Nearest in sqrt_float_significands_general\n    // - rm == Nearest && sh < Limb::WIDTH in sqrt_float_significands_general\n    // - rm == Nearest && sticky1 & (1 << (sh - 1)) == 0 in sqrt_float_significands_general\n    // - in truncate\n    // - sh != Limb::WIDTH in truncate\n    test(\n        \"531607.999405753398566100250398911805595276409254333486007034444758646220477451\",\n        \"0x81c97.ffd90e3247f501afdb3e5781d0c650b8de694094110713b5a698d3d38550#257\",\n        Nearest,\n        \"729.11453106199536130370773365901724384208766502803825392984301547488034915749\",\n        \"0x2d9.1d51e85da56f057ec9027291169bc84fb3262e9f7b56ad4fbded5d5fb28234#257\",\n        Less,\n    );\n    // - u_size <= rrsize && odd_exp in sqrt_float_significands_general\n    // - u_size <= rrsize && odd_exp && k != 0 in sqrt_float_significands_general\n    test(\n        \"8669478862124781.0453122498906357696603256\",\n        \"0x1eccd857f6f6ed.0b999567637220ce5162#133\",\n        Nearest,\n        \"93110036.31255215575055410689733347856975\",\n        \"0x58cbf14.50036b073e308b45123fad288c8#133\",\n        Less,\n    );\n    // - rm == Nearest && sticky1 & (1 << (sh - 1)) != 0 in sqrt_float_significands_general\n    // - rm == Nearest && sticky1 == (1 << (sh - 1)) && !sqrt_inexact && sticky0 != 0 in\n    //   sqrt_float_significands_general\n    // - in add_one\n    // - sh != Limb::WIDTH in add_one\n    // - !carry in add_one\n    test(\n        \"4.342868714761498751021923028996829056762200989107722850118926783525941596406956471866296\\\n        2992498076143086829355664e-20\",\n        \"0xc.d160fab1cc524c2fe76cffa155f81b8188af00d7023e4d317d44fbce1d3d47bc1d1312f172ce15520ea1d\\\n        11590abE-17#372\",\n        Nearest,\n        \"2.083955065437232202468518924164364631048457537561905126352513612727408728510770037672930\\\n        6989930075738883830052488e-10\",\n        \"0xe.5221ecf52b8695b0ee215b5d4b92348fce150af3190e08806ac4bb447fc0e236659b5b02162fde717b9e2\\\n        56afe2eE-9#372\",\n        Greater,\n    );\n    // - sh == 0 && rm == Nearest in sqrt_float_significands_general\n    // - rm == Nearest && sh >= Limb::WIDTH in sqrt_float_significands_general\n    // - rm == Nearest && sticky1.get_highest_bit() in sqrt_float_significands_general\n    // - rm == Nearest && sticky1 == LIMB_HIGH_BIT && !sqrt_inexact && sticky0 != 0 in\n    //   sqrt_float_significands_general\n    // - sh == Limb::WIDTH in add_one\n    test(\n        \"2.652265028059746721807174554033221706564e-11\",\n        \"0x1.d29765de1f777af51db92558a3d9f542E-9#128\",\n        Nearest,\n        \"5.15001459032860092518337573994143253147e-6\",\n        \"0x0.0000566724ecdf4dd7e9fadaf1a94e15741b0#128\",\n        Greater,\n    );\n    // - rm == Nearest && !sticky1.get_highest_bit() in sqrt_float_significands_general\n    // - sh == Limb::WIDTH in truncate\n    test(\n        \"4.131497698938604195099390193257480907988376605341754029892e72\",\n        \"0x2.569dc44aae4efd9bf163a72fcf66facef9729212ebaf3d4cE+60#192\",\n        Nearest,\n        \"2032608594623815959008545804304448692.2928683624055859234906\",\n        \"0x18777574b6d7a0f8c80efa20bdefcb4.4af96bc690a8425010#192\",\n        Less,\n    );\n    // - !sticky0 in sqrt_float_significands_general\n    test(\n        \"3.9231885846166754773973683895047915100639721527900216e56\",\n        \"0x1.00000000000000000000000000000000000000000000E+47#176\",\n        Nearest,\n        \"19807040628566084398385987584.0\",\n        \"0x400000000000000000000000.000000000000000000000#176\",\n        Equal,\n    );\n\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Nearest,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Equal,\n    );\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Nearest,\n        \"too_big\",\n        \"0x8.0E+134217727#2\",\n        Less,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-134217728#1\",\n        Equal,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-134217728#2\",\n        Equal,\n    );\n\n    // - rm == Floor | Down in sqrt_float_significand_same_prec_lt_w\n    test(\"2.0\", \"0x2.0#1\", Down, \"1.0\", \"0x1.0#1\", Less);\n    // - rm == Ceiling | Up in sqrt_float_significand_same_prec_lt_w\n    // - rm == Ceiling | Up && r0 == 0 in sqrt_float_significand_same_prec_lt_w\n    test(\"2.0\", \"0x2.0#1\", Up, \"2.0\", \"0x2.0#1\", Greater);\n    // - rm == Ceiling | Up && r0 != 0 in sqrt_float_significand_same_prec_lt_w\n    test(\"2.0\", \"0x2.0#2\", Up, \"1.5\", \"0x1.8#2\", Greater);\n    // - rm == Floor | Down in sqrt_float_significand_same_prec_w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Down,\n        \"1.4142135623730950488\",\n        \"0x1.6a09e667f3bcc908#64\",\n        Less,\n    );\n    // - rm == Ceiling | Up in sqrt_float_significand_same_prec_w\n    // - r0 != 0 in sqrt_float_significand_same_prec_w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Up,\n        \"1.4142135623730950489\",\n        \"0x1.6a09e667f3bcc90a#64\",\n        Greater,\n    );\n    // - r0 == 0 in sqrt_float_significand_same_prec_w\n    test(\n        \"67108863.999999999996\",\n        \"0x3ffffff.fffffffffc#64\",\n        Up,\n        \"8192.0\",\n        \"0x2000.0000000000000#64\",\n        Greater,\n    );\n    // - rm == Floor | Down in sqrt_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Down,\n        \"1.41421356237309504876\",\n        \"0x1.6a09e667f3bcc908#65\",\n        Less,\n    );\n    // - rm == Ceiling | Up in sqrt_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Ceiling | Up && r1 != 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Up,\n        \"1.41421356237309504882\",\n        \"0x1.6a09e667f3bcc909#65\",\n        Greater,\n    );\n    // - rm == Ceiling | Up && r1 == 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"7.00649232162408535461864791e-46\",\n        \"0x3.fffffffffffffffffffffeE-38#89\",\n        Up,\n        \"2.646977960169688559588507815e-23\",\n        \"0x2.0000000000000000000000E-19#89\",\n        Greater,\n    );\n    // - rm == Floor | Down in sqrt_float_significands_general\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        Down,\n        \"1.414213562373095048801688724209698078569\",\n        \"0x1.6a09e667f3bcc908b2fb1366ea957d3e#129\",\n        Less,\n    );\n    // - rm == Ceiling | Up in sqrt_float_significands_general\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        Up,\n        \"1.414213562373095048801688724209698078572\",\n        \"0x1.6a09e667f3bcc908b2fb1366ea957d3f#129\",\n        Greater,\n    );\n    // - carry in add_one\n    test(\n        \"0.999999999999999999999999999999999999999\",\n        \"0x0.ffffffffffffffffffffffffffffffff8#129\",\n        Up,\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Greater,\n    );\n    // - SignedLimb::wrapping_from(t2) < 0 in sqrt_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"3.1370587247788594938889277427222882863e58\",\n        \"0x4.ff643687dfbb20bf81d2ef780dca280E+48#124\",\n        Nearest,\n        \"177117439140781941633284688407.1796741\",\n        \"0x23c4c1c9f13433f0d1315ca17.2dff1f4#124\",\n        Less,\n    );\n}\n\n#[test]\nfn sqrt_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(THREE.sqrt_round(Exact));\n    assert_panic!(THREE.sqrt_round_ref(Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.sqrt_round_assign(Exact);\n    });\n}\n\n#[test]\nfn test_sqrt_prec_round() {\n    let test = |s, s_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (sqrt, o) = x.clone().sqrt_prec_round(prec, rm);\n        assert!(sqrt.is_valid());\n\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, o_out);\n\n        let (sqrt_alt, o_alt) = x.sqrt_prec_round_ref(prec, rm);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut sqrt_alt = x.clone();\n        let o_alt = sqrt_alt.sqrt_prec_round_assign(prec, rm);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt), ComparableFloatRef(&sqrt_alt));\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sqrt, rug_o) = rug_sqrt_prec_round(&rug::Float::exact_from(&x), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sqrt)),\n                ComparableFloatRef(&sqrt),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\"-Infinity\", \"-Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", 1, Floor, \"8.0\", \"0x8.0#1\", Less);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"2.0e1\",\n        \"0x1.0E+1#1\",\n        Greater,\n    );\n    test(\"123.0\", \"0x7b.0#7\", 1, Down, \"8.0\", \"0x8.0#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Up, \"2.0e1\", \"0x1.0E+1#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 1, Nearest, \"8.0\", \"0x8.0#1\", Less);\n\n    test(\"123.0\", \"0x7b.0#7\", 10, Floor, \"11.08\", \"0xb.14#10\", Less);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"11.09\",\n        \"0xb.18#10\",\n        Greater,\n    );\n    test(\"123.0\", \"0x7b.0#7\", 10, Down, \"11.08\", \"0xb.14#10\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 10, Up, \"11.09\", \"0xb.18#10\", Greater);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"11.09\",\n        \"0xb.18#10\",\n        Greater,\n    );\n\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"1.771\",\n        \"0x1.c58#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"1.773\",\n        \"0x1.c60#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"1.771\",\n        \"0x1.c58#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"1.773\",\n        \"0x1.c60#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"1.771\",\n        \"0x1.c58#10\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n}\n\n#[test]\nfn sqrt_prec_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::one_prec(1).sqrt_prec_round(0, Floor));\n    assert_panic!(Float::one_prec(1).sqrt_prec_round_ref(0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sqrt_prec_round_assign(0, Floor)\n    });\n\n    assert_panic!(THREE.sqrt_prec_round(1, Exact));\n    assert_panic!(THREE.sqrt_prec_round_ref(1, Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.sqrt_prec_round_assign(1, Exact)\n    });\n}\n\n#[test]\nfn test_sqrt_rational_prec() {\n    let test = |s, prec, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (sqrt, o) = Float::sqrt_rational_prec(u.clone(), prec);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = Float::sqrt_rational_prec_ref(&u, prec);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_generic(&u, prec, Nearest);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_simple(&u, prec, Nearest);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(&sqrt).square();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square < u);\n                    let mut next = sqrt.clone();\n                    next.increment();\n                    assert!(Rational::exact_from(&next).square() > u);\n                }\n                Greater => {\n                    assert!(square > u);\n                    let mut previous = sqrt.clone();\n                    previous.decrement();\n                    assert!(Rational::exact_from(&previous).square() < u);\n                }\n            }\n        }\n    };\n    test(\"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 100, \"1.0\", \"0x1.0000000000000000000000000#100\", Equal);\n    test(\"1/2\", 1, \"0.5\", \"0x0.8#1\", Less);\n    test(\"1/2\", 10, \"0.707\", \"0x0.b50#10\", Less);\n    test(\n        \"1/2\",\n        100,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n    test(\"1/3\", 1, \"0.5\", \"0x0.8#1\", Less);\n    test(\"1/3\", 10, \"0.577\", \"0x0.93c#10\", Less);\n    test(\n        \"1/3\",\n        100,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n    test(\"22/7\", 1, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"22/7\", 10, \"1.773\", \"0x1.c60#10\", Greater);\n    test(\n        \"22/7\",\n        100,\n        \"1.772810520855836656590463136493\",\n        \"0x1.c5d6e909149e8e4e59f04b68e#100\",\n        Greater,\n    );\n\n    let test_big = |u: Rational, prec, out, out_hex, out_o| {\n        let (sqrt, o) = Float::sqrt_rational_prec(u.clone(), prec);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = Float::sqrt_rational_prec_ref(&u, prec);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_generic(&u, prec, Nearest);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_simple(&u, prec, Nearest);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(&sqrt).square();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square < u);\n                    let mut next = sqrt.clone();\n                    next.increment();\n                    assert!(Rational::exact_from(&next).square() > u);\n                }\n                Greater => {\n                    assert!(square > u);\n                    let mut previous = sqrt.clone();\n                    previous.decrement();\n                    assert!(Rational::exact_from(&previous).square() < u);\n                }\n            }\n        }\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"too_big\",\n        \"0x8.00E+134217727#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        \"too_small\",\n        \"0x1.000E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n}\n\n#[test]\nfn sqrt_rational_prec_fail() {\n    assert_panic!(Float::sqrt_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::sqrt_rational_prec(Rational::ONE, 0));\n    assert_panic!(Float::sqrt_rational_prec(Rational::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn sqrt_rational_prec_ref_fail() {\n    assert_panic!(Float::sqrt_rational_prec_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::sqrt_rational_prec_ref(&Rational::ONE, 0));\n    assert_panic!(Float::sqrt_rational_prec_ref(&Rational::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn test_sqrt_rational_prec_round() {\n    let test = |s, prec, rm, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (sqrt, o) = Float::sqrt_rational_prec_round(u.clone(), prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = Float::sqrt_rational_prec_round_ref(&u, prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_generic(&u, prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_simple(&u, prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(&sqrt).square();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square < u);\n                    let mut next = sqrt.clone();\n                    next.increment();\n                    assert!(Rational::exact_from(&next).square() > u);\n                }\n                Greater => {\n                    assert!(square > u);\n                    let mut previous = sqrt.clone();\n                    previous.decrement();\n                    assert!(Rational::exact_from(&previous).square() < u);\n                }\n            }\n        }\n    };\n    test(\"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 100, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\n        \"1\",\n        100,\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"1/2\", 1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test(\"1/2\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"1/2\", 1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test(\"1/2\", 1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"1/2\", 1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test(\"1/2\", 10, Floor, \"0.707\", \"0x0.b50#10\", Less);\n    test(\"1/2\", 10, Ceiling, \"0.708\", \"0x0.b54#10\", Greater);\n    test(\"1/2\", 10, Down, \"0.707\", \"0x0.b50#10\", Less);\n    test(\"1/2\", 10, Up, \"0.708\", \"0x0.b54#10\", Greater);\n    test(\"1/2\", 10, Nearest, \"0.707\", \"0x0.b50#10\", Less);\n\n    test(\n        \"1/2\",\n        100,\n        Floor,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n    test(\n        \"1/2\",\n        100,\n        Ceiling,\n        \"0.7071067811865475244008443621054\",\n        \"0x0.b504f333f9de6484597d89b38#100\",\n        Greater,\n    );\n    test(\n        \"1/2\",\n        100,\n        Down,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n    test(\n        \"1/2\",\n        100,\n        Up,\n        \"0.7071067811865475244008443621054\",\n        \"0x0.b504f333f9de6484597d89b38#100\",\n        Greater,\n    );\n    test(\n        \"1/2\",\n        100,\n        Nearest,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n\n    test(\"1/3\", 1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test(\"1/3\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"1/3\", 1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test(\"1/3\", 1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test(\"1/3\", 1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test(\"1/3\", 10, Floor, \"0.577\", \"0x0.93c#10\", Less);\n    test(\"1/3\", 10, Ceiling, \"0.578\", \"0x0.940#10\", Greater);\n    test(\"1/3\", 10, Down, \"0.577\", \"0x0.93c#10\", Less);\n    test(\"1/3\", 10, Up, \"0.578\", \"0x0.940#10\", Greater);\n    test(\"1/3\", 10, Nearest, \"0.577\", \"0x0.93c#10\", Less);\n\n    test(\n        \"1/3\",\n        100,\n        Floor,\n        \"0.577350269189625764509148780501\",\n        \"0x0.93cd3a2c8198e2690c7c0f257#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Ceiling,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Down,\n        \"0.577350269189625764509148780501\",\n        \"0x0.93cd3a2c8198e2690c7c0f257#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Up,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Nearest,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n\n    test(\"22/7\", 1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\"22/7\", 1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"22/7\", 1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"22/7\", 1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\"22/7\", 1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test(\"22/7\", 10, Floor, \"1.771\", \"0x1.c58#10\", Less);\n    test(\"22/7\", 10, Ceiling, \"1.773\", \"0x1.c60#10\", Greater);\n    test(\"22/7\", 10, Down, \"1.771\", \"0x1.c58#10\", Less);\n    test(\"22/7\", 10, Up, \"1.773\", \"0x1.c60#10\", Greater);\n    test(\"22/7\", 10, Nearest, \"1.773\", \"0x1.c60#10\", Greater);\n\n    test(\n        \"22/7\",\n        100,\n        Floor,\n        \"1.772810520855836656590463136491\",\n        \"0x1.c5d6e909149e8e4e59f04b68c#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Ceiling,\n        \"1.772810520855836656590463136493\",\n        \"0x1.c5d6e909149e8e4e59f04b68e#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Down,\n        \"1.772810520855836656590463136491\",\n        \"0x1.c5d6e909149e8e4e59f04b68c#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Up,\n        \"1.772810520855836656590463136493\",\n        \"0x1.c5d6e909149e8e4e59f04b68e#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Nearest,\n        \"1.772810520855836656590463136493\",\n        \"0x1.c5d6e909149e8e4e59f04b68e#100\",\n        Greater,\n    );\n\n    test(\"-1\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/2\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-1/2\", 100, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-1/3\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-1/3\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 10, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 10, Nearest, \"NaN\", \"NaN\", Equal);\n\n    test(\"-22/7\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Up, \"NaN\", \"NaN\", Equal);\n    test(\"-22/7\", 100, Nearest, \"NaN\", \"NaN\", Equal);\n\n    let test_big = |u: Rational, prec, rm, out, out_hex, out_o| {\n        let (sqrt, o) = Float::sqrt_rational_prec_round(u.clone(), prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = Float::sqrt_rational_prec_round_ref(&u, prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_generic(&u, prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        let (sqrt, o) = sqrt_rational_prec_round_simple(&u, prec, rm);\n        assert!(sqrt.is_valid());\n        assert_eq!(sqrt.to_string(), out);\n        assert_eq!(to_hex_string(&sqrt), out_hex);\n        assert_eq!(o, out_o);\n\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(&sqrt).square();\n            match o {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square < u);\n                    let mut next = sqrt.clone();\n                    next.increment();\n                    assert!(Rational::exact_from(&next).square() > u);\n                }\n                Greater => {\n                    assert!(square > u);\n                    let mut previous = sqrt.clone();\n                    previous.decrement();\n                    assert!(Rational::exact_from(&previous).square() < u);\n                }\n            }\n        }\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Floor,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Ceiling,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Down,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Up,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Nearest,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Exact,\n        \"3.273e150\",\n        \"0x1.000E+125#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0xb.54E+134217727#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"too_big\",\n        \"0xb.54E+134217727#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0xb.50E+134217727#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x8.00E+134217727#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x8.00E+134217727#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_big\",\n        \"0x8.00E+134217727#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_big\",\n        \"0x8.00E+134217727#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x8.00E+134217727#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_big\",\n        \"0x8.00E+134217727#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Ceiling,\n        \"too_big\",\n        \"0x1.0E+134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Down,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Up,\n        \"too_big\",\n        \"0x1.0E+134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Nearest,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Ceiling,\n        \"too_big\",\n        \"0x1.0E+134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Down,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Up,\n        \"too_big\",\n        \"0x1.0E+134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Nearest,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Ceiling,\n        \"too_big\",\n        \"0x1.0E+134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Down,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Up,\n        \"too_big\",\n        \"0x1.0E+134217728#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Nearest,\n        \"too_big\",\n        \"0x8.0E+134217727#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Floor,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Ceiling,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Down,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Up,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Nearest,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Exact,\n        \"3.055e-151\",\n        \"0x1.000E-125#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Floor,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.6a8E-134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Down,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.6a8E-134217728#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.6a0E-134217728#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_small\",\n        \"0x1.000E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_small\",\n        \"0x1.000E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.000E-134217728#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_small\",\n        \"0x1.000E-134217728#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Floor,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Down,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Up,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Floor,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Down,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Up,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"too_small\",\n        \"0xb.54E-134217729#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0xb.50E-134217729#10\",\n        Less,\n    );\n}\n\n#[test]\nfn sqrt_rational_prec_round_fail() {\n    assert_panic!(Float::sqrt_rational_prec_round(Rational::ZERO, 0, Floor));\n    assert_panic!(Float::sqrt_rational_prec_round(Rational::ONE, 0, Floor));\n    assert_panic!(Float::sqrt_rational_prec_round(\n        Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::sqrt_rational_prec_round(\n        Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::sqrt_rational_prec_round(\n        Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n}\n\n#[test]\nfn sqrt_rational_prec_round_ref_fail() {\n    assert_panic!(Float::sqrt_rational_prec_round_ref(\n        &Rational::ZERO,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::sqrt_rational_prec_round_ref(\n        &Rational::ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::sqrt_rational_prec_round_ref(\n        &Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::sqrt_rational_prec_round_ref(\n        &Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::sqrt_rational_prec_round_ref(\n        &Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n}\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_primitive_float_sqrt_rational() {\n    fn test<T: PrimitiveFloat>(s: &str, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n        Rational: ExactFrom<T>,\n    {\n        let u = Rational::from_str(s).unwrap();\n\n        let sqrt = primitive_float_sqrt_rational::<T>(&u);\n        assert_eq!(NiceFloat(sqrt), NiceFloat(out));\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(sqrt).square();\n            match square.cmp(&u) {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square < u);\n                    let mut next = sqrt;\n                    next = next.next_higher();\n                    assert!(Rational::exact_from(next).square() > u);\n                }\n                Greater => {\n                    assert!(square > u);\n                    let mut previous = sqrt;\n                    previous = previous.next_lower();\n                    assert!(Rational::exact_from(previous).square() < u);\n                }\n            }\n        }\n    }\n    test::<f32>(\"0\", 0.0);\n    test::<f32>(\"1\", 1.0);\n    test::<f32>(\"1/2\", 0.70710677);\n    test::<f32>(\"1/3\", 0.57735026);\n    test::<f32>(\"22/7\", 1.7728106);\n    test::<f32>(\"225\", 15.0);\n    test::<f32>(\"-1\", f32::NAN);\n    test::<f32>(\"-1/2\", f32::NAN);\n    test::<f32>(\"-1/3\", f32::NAN);\n    test::<f32>(\"-22/7\", f32::NAN);\n\n    test::<f64>(\"0\", 0.0);\n    test::<f64>(\"1\", 1.0);\n    test::<f64>(\"1/2\", f64::consts::FRAC_1_SQRT_2);\n    test::<f64>(\"1/3\", 0.5773502691896257);\n    test::<f64>(\"22/7\", 1.7728105208558367);\n    test::<f64>(\"225\", 15.0);\n    test::<f64>(\"-1\", f64::NAN);\n    test::<f64>(\"-1/2\", f64::NAN);\n    test::<f64>(\"-1/3\", f64::NAN);\n    test::<f64>(\"-22/7\", f64::NAN);\n\n    #[allow(clippy::needless_pass_by_value)]\n    fn test_big<T: PrimitiveFloat>(u: Rational, out: T)\n    where\n        Float: From<T> + PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n        Rational: ExactFrom<T>,\n    {\n        let sqrt = primitive_float_sqrt_rational::<T>(&u);\n        assert_eq!(NiceFloat(sqrt), NiceFloat(out));\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(sqrt).square();\n            match square.cmp(&u) {\n                Equal => assert_eq!(square, u),\n                Less => {\n                    assert!(square < u);\n                    let mut next = sqrt;\n                    next = next.next_higher();\n                    assert!(Rational::exact_from(next).square() > u);\n                }\n                Greater => {\n                    assert!(square > u);\n                    let mut previous = sqrt;\n                    previous = previous.next_lower();\n                    assert!(Rational::exact_from(previous).square() < u);\n                }\n            }\n        }\n    }\n    test_big::<f32>(Rational::power_of_2(1000i64), f32::INFINITY);\n    test_big::<f32>(Rational::power_of_2(-1000i64), 0.0);\n    test_big::<f32>(Rational::power_of_2(-290i64), 2.2e-44);\n    test_big::<f32>(Rational::power_of_2(-200i64), 7.888609e-31);\n\n    test_big::<f64>(Rational::power_of_2(10000i64), f64::INFINITY);\n    test_big::<f64>(Rational::power_of_2(1000i64), 3.273390607896142e150);\n    test_big::<f64>(Rational::power_of_2(-10000i64), 0.0);\n    test_big::<f64>(Rational::power_of_2(-2100i64), 8.289046e-317);\n    test_big::<f64>(Rational::power_of_2(-1000i64), 3.054936363499605e-151);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sqrt_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode, extreme: bool) {\n    let (sqrt, o) = x.clone().sqrt_prec_round(prec, rm);\n    assert!(sqrt.is_valid());\n\n    let (sqrt_alt, o_alt) = x.clone().sqrt_prec_round_ref(prec, rm);\n    assert!(sqrt_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sqrt_prec_round_assign(prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sqrt));\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_sqrt, rug_o) = rug_sqrt_prec_round(&rug::Float::exact_from(&x), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt)),\n            ComparableFloatRef(&sqrt),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(sqrt.is_sign_positive());\n    }\n\n    if sqrt.is_normal() {\n        assert_eq!(sqrt.get_prec(), Some(prec));\n        if x > 1u32 && o < Greater {\n            assert!(sqrt < x);\n        } else if x < 1u32 && o > Less {\n            assert!(sqrt > x);\n        }\n    }\n\n    if !extreme && x.is_normal() && sqrt.is_normal() {\n        let square = Rational::exact_from(&sqrt).square();\n        match o {\n            Equal => assert_eq!(square, x),\n            Less => {\n                assert!(square < x);\n                let mut next = sqrt.clone();\n                next.increment();\n                assert!(Rational::exact_from(&next).square() > x);\n            }\n            Greater => {\n                assert!(square > x);\n                let mut previous = sqrt.clone();\n                previous.decrement();\n                assert!(Rational::exact_from(&previous).square() < x);\n            }\n        }\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.sqrt_prec_round_ref(prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(sqrt.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.sqrt_prec_round_ref(prec, Exact));\n    }\n}\n\n#[test]\nfn sqrt_prec_round_properties() {\n    float_unsigned_rounding_mode_triple_gen_var_13().test_properties(|(x, prec, rm)| {\n        sqrt_prec_round_properties_helper(x, prec, rm, false);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_14().test_properties(|(x, prec, rm)| {\n        sqrt_prec_round_properties_helper(x, prec, rm, true);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {\n        let (sqrt, o) = Float::NAN.sqrt_prec_round(prec, rm);\n        assert!(sqrt.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.sqrt_prec_round(prec, rm),\n            (Float::INFINITY, Equal)\n        );\n\n        let (s, o) = Float::NEGATIVE_INFINITY.sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n\n        let (s, o) = Float::ZERO.sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (s, o) = Float::NEGATIVE_ZERO.sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NEGATIVE_ZERO));\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::ONE.sqrt_prec_round(prec, rm),\n            (Float::one_prec(prec), Equal)\n        );\n\n        let (s, o) = Float::NEGATIVE_ONE.sqrt_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sqrt_prec_properties_helper(x: Float, prec: u64, extreme: bool) {\n    let (sqrt, o) = x.clone().sqrt_prec(prec);\n    assert!(sqrt.is_valid());\n\n    let (sqrt_alt, o_alt) = x.sqrt_prec_ref(prec);\n    assert!(sqrt_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sqrt_prec_assign(prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sqrt));\n    assert_eq!(o_alt, o);\n\n    let (rug_sqrt, rug_o) = rug_sqrt_prec(&rug::Float::exact_from(&x), prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_sqrt)),\n        ComparableFloatRef(&sqrt),\n    );\n    assert_eq!(rug_o, o);\n\n    let (sqrt_alt, o_alt) = x.sqrt_prec_round_ref(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n    assert_eq!(o_alt, o);\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(sqrt.is_sign_positive());\n    }\n\n    if sqrt.is_normal() {\n        assert_eq!(sqrt.get_prec(), Some(prec));\n        if x > 1u32 && o < Greater {\n            assert!(sqrt < x);\n        } else if x < 1u32 && o > Less {\n            assert!(sqrt > x);\n        }\n    }\n\n    if !extreme && x.is_normal() && sqrt.is_normal() {\n        let square = Rational::exact_from(&sqrt).square();\n        match o {\n            Equal => assert_eq!(square, x),\n            Less => {\n                assert!(square < x);\n                let mut next = sqrt.clone();\n                next.increment();\n                assert!(Rational::exact_from(&next).square() > x);\n            }\n            Greater => {\n                assert!(square > x);\n                let mut previous = sqrt.clone();\n                previous.decrement();\n                assert!(Rational::exact_from(&previous).square() < x);\n            }\n        }\n    }\n}\n\n#[test]\nfn sqrt_prec_properties() {\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        sqrt_prec_properties_helper(x, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_unsigned_pair_gen_var_1().test_properties_with_config(&config, |(x, prec)| {\n        sqrt_prec_properties_helper(x, prec, false);\n    });\n\n    float_unsigned_pair_gen_var_4().test_properties(|(x, prec)| {\n        sqrt_prec_properties_helper(x, prec, true);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (sqrt, o) = Float::NAN.sqrt_prec(prec);\n        assert!(sqrt.is_nan());\n        assert_eq!(o, Equal);\n\n        let (sqrt, o) = Float::ZERO.sqrt_prec(prec);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (sqrt, o) = Float::NEGATIVE_ZERO.sqrt_prec(prec);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::NEGATIVE_ZERO));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::INFINITY.sqrt_prec(prec), (Float::INFINITY, Equal));\n\n        let (sqrt, o) = Float::NEGATIVE_INFINITY.sqrt_prec(prec);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::ONE.sqrt_prec(prec), (Float::one_prec(prec), Equal));\n\n        let (sqrt, o) = Float::NEGATIVE_ONE.sqrt_prec(prec);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sqrt_round_properties_helper(x: Float, rm: RoundingMode, extreme: bool) {\n    let (sqrt, o) = x.clone().sqrt_round(rm);\n    assert!(sqrt.is_valid());\n\n    let (sqrt_alt, o_alt) = x.sqrt_round_ref(rm);\n    assert!(sqrt_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sqrt_round_assign(rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sqrt));\n    assert_eq!(o_alt, o);\n\n    let (sqrt_alt, o_alt) = x.sqrt_prec_round_ref(x.significant_bits(), rm);\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n    assert_eq!(o_alt, o);\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(sqrt.is_sign_positive());\n    }\n\n    if sqrt.is_normal() {\n        assert_eq!(sqrt.get_prec(), Some(x.get_prec().unwrap()));\n        if x > 1u32 && o < Greater {\n            assert!(sqrt < x);\n        } else if x < 1u32 && o > Less {\n            assert!(sqrt > x);\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_sqrt, rug_o) = rug_sqrt_round(&rug::Float::exact_from(&x), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt)),\n            ComparableFloatRef(&sqrt),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if !extreme && x.is_normal() && sqrt.is_normal() {\n        let square = Rational::exact_from(&sqrt).square();\n        match o {\n            Equal => assert_eq!(square, x),\n            Less => {\n                assert!(square < x);\n                let mut next = sqrt.clone();\n                next.increment();\n                assert!(Rational::exact_from(&next).square() > x);\n            }\n            Greater => {\n                assert!(square > x);\n                let mut previous = sqrt.clone();\n                previous.decrement();\n                assert!(Rational::exact_from(&previous).square() < x);\n            }\n        }\n    }\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.sqrt_round_ref(rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(sqrt.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.sqrt_round_ref(Exact));\n    }\n}\n\n#[test]\nfn sqrt_round_properties() {\n    float_rounding_mode_pair_gen_var_24().test_properties(|(x, rm)| {\n        sqrt_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_25().test_properties(|(x, rm)| {\n        sqrt_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_26().test_properties(|(x, rm)| {\n        sqrt_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_27().test_properties(|(x, rm)| {\n        sqrt_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_28().test_properties(|(x, rm)| {\n        sqrt_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_29().test_properties(|(x, rm)| {\n        sqrt_round_properties_helper(x, rm, true);\n    });\n\n    rounding_mode_gen().test_properties(|rm| {\n        let (sqrt, o) = Float::NAN.sqrt_round(rm);\n        assert!(sqrt.is_nan());\n        assert_eq!(o, Equal);\n\n        let (sqrt, o) = Float::ZERO.sqrt_round(rm);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (sqrt, o) = Float::NEGATIVE_ZERO.sqrt_round(rm);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::NEGATIVE_ZERO));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::INFINITY.sqrt_round(rm), (Float::INFINITY, Equal));\n\n        let (sqrt, o) = Float::NEGATIVE_INFINITY.sqrt_round(rm);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::ONE.sqrt_round(rm), (Float::ONE, Equal));\n\n        let (sqrt, o) = Float::NEGATIVE_ONE.sqrt_round(rm);\n        assert_eq!(ComparableFloat(sqrt), ComparableFloat(Float::NAN));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sqrt_properties_helper_1(x: Float, extreme: bool) {\n    let sqrt = x.clone().sqrt();\n    assert!(sqrt.is_valid());\n\n    let sqrt_alt = (&x).sqrt();\n    assert!(sqrt_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n\n    let mut x_alt = x.clone();\n    x_alt.sqrt_assign();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&sqrt));\n\n    let sqrt_alt = x.sqrt_prec_round_ref(x.significant_bits(), Nearest).0;\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n    let sqrt_alt = x.sqrt_prec_ref(x.significant_bits()).0;\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n\n    let sqrt_alt = x.sqrt_round_ref(Nearest).0;\n    assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n\n    if x >= 0u32 && !x.is_negative_zero() {\n        assert!(sqrt.is_sign_positive());\n    }\n\n    if !extreme && x.is_normal() && sqrt.is_normal() {\n        assert_eq!(sqrt.get_prec(), Some(x.get_prec().unwrap()));\n        let square = Rational::exact_from(&sqrt).square();\n        if square < x {\n            let mut next = sqrt.clone();\n            next.increment();\n            assert!(Rational::exact_from(&next).square() > x);\n        } else if square > x {\n            let mut previous = sqrt.clone();\n            previous.decrement();\n            assert!(Rational::exact_from(&previous).square() < x);\n        }\n    }\n\n    let rug_sqrt = rug_sqrt(&rug::Float::exact_from(&x));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_sqrt)),\n        ComparableFloatRef(&sqrt),\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn sqrt_properties_helper_2<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_gen::<T>().test_properties(|x| {\n        let sqrt_1 = x.sqrt();\n        let sqrt_2 = emulate_float_to_float_fn(Float::sqrt_prec, x);\n        assert_eq!(NiceFloat(sqrt_1), NiceFloat(sqrt_2));\n    });\n}\n\n#[test]\nfn sqrt_properties() {\n    float_gen().test_properties(|x| {\n        sqrt_properties_helper_1(x, false);\n    });\n\n    float_gen_var_6().test_properties(|x| {\n        sqrt_properties_helper_1(x, false);\n    });\n\n    float_gen_var_7().test_properties(|x| {\n        sqrt_properties_helper_1(x, false);\n    });\n\n    float_gen_var_8().test_properties(|x| {\n        sqrt_properties_helper_1(x, false);\n    });\n\n    float_gen_var_11().test_properties(|x| {\n        sqrt_properties_helper_1(x, false);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        sqrt_properties_helper_1(x, true);\n    });\n\n    apply_fn_to_primitive_floats!(sqrt_properties_helper_2);\n}\n\n#[test]\nfn sqrt_rational_prec_properties() {\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let (sqrt, o) = Float::sqrt_rational_prec(x.clone(), prec);\n        assert!(sqrt.is_valid());\n\n        let (sqrt_alt, o_alt) = Float::sqrt_rational_prec_ref(&x, prec);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n        assert_eq!(o, o_alt);\n\n        let (sqrt_alt, o_alt) = Float::sqrt_rational_prec_round_ref(&x, prec, Nearest);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n        assert_eq!(o, o_alt);\n\n        let (sqrt_alt, o_alt) = sqrt_rational_prec_round_generic(&x, prec, Nearest);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n        assert_eq!(o, o_alt);\n\n        let (sqrt_alt, o_alt) = sqrt_rational_prec_round_simple(&x, prec, Nearest);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n        assert_eq!(o, o_alt);\n\n        if !sqrt.is_nan() {\n            assert_eq!(sqrt.get_prec(), if x == 0u32 { None } else { Some(prec) });\n        }\n\n        if x >= 0u32 {\n            assert!(sqrt.is_sign_positive());\n        }\n\n        if sqrt.is_normal() {\n            if x > 1u32 && o < Greater {\n                assert!(sqrt < x);\n            } else if x < 1u32 && o > Less {\n                assert!(sqrt > x);\n            }\n\n            let square = Rational::exact_from(&sqrt).square();\n            match o {\n                Equal => assert_eq!(square, x),\n                Less => {\n                    assert!(square < x);\n                    let mut next = sqrt.clone();\n                    next.increment();\n                    assert!(Rational::exact_from(&next).square() > x);\n                }\n                Greater => {\n                    assert!(square > x);\n                    let mut previous = sqrt.clone();\n                    previous.decrement();\n                    assert!(Rational::exact_from(&previous).square() < x);\n                }\n            }\n        }\n    });\n}\n\n#[test]\nfn sqrt_rational_prec_round_properties() {\n    rational_unsigned_rounding_mode_triple_gen_var_3().test_properties(|(x, prec, rm)| {\n        let (sqrt, o) = Float::sqrt_rational_prec_round(x.clone(), prec, rm);\n        assert!(sqrt.is_valid());\n\n        let (sqrt_alt, o_alt) = Float::sqrt_rational_prec_round_ref(&x, prec, rm);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n        assert_eq!(o, o_alt);\n\n        if !sqrt.is_nan() {\n            match (x >= 0, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n\n        let (sqrt_alt, o_alt) = sqrt_rational_prec_round_generic(&x, prec, rm);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n        assert_eq!(o, o_alt);\n\n        let (sqrt_alt, o_alt) = sqrt_rational_prec_round_simple(&x, prec, rm);\n        assert!(sqrt_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&sqrt_alt), ComparableFloatRef(&sqrt));\n        assert_eq!(o, o_alt);\n\n        if !sqrt.is_nan() {\n            assert_eq!(sqrt.get_prec(), if x == 0u32 { None } else { Some(prec) });\n        }\n\n        if x >= 0u32 {\n            assert!(sqrt.is_sign_positive());\n        }\n\n        if sqrt.is_normal() {\n            if x > 1u32 && o < Greater {\n                assert!(sqrt < x);\n            } else if x < 1u32 && o > Less {\n                assert!(sqrt > x);\n            }\n        }\n\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(&sqrt).square();\n            match o {\n                Equal => assert_eq!(square, x),\n                Less => {\n                    assert!(square < x);\n                    let mut next = sqrt.clone();\n                    next.increment();\n                    assert!(Rational::exact_from(&next).square() > x);\n                }\n                Greater => {\n                    assert!(square > x);\n                    let mut previous = sqrt.clone();\n                    previous.decrement();\n                    assert!(Rational::exact_from(&previous).square() < x);\n                }\n            }\n        }\n\n        if o == Equal {\n            for rm in exhaustive_rounding_modes() {\n                let (s, oo) = Float::sqrt_rational_prec_round_ref(&x, prec, rm);\n                assert_eq!(\n                    ComparableFloat(s.abs_negative_zero_ref()),\n                    ComparableFloat(sqrt.abs_negative_zero_ref())\n                );\n                assert_eq!(oo, Equal);\n            }\n        } else {\n            assert_panic!(Float::sqrt_rational_prec_round_ref(&x, prec, Exact));\n        }\n    });\n\n    // sqrt(3/5) is one of the simplest cases that doesn't reduce to sqrt or reciprocal_sqrt of a\n    // Float\n    const X: Rational = Rational::const_from_unsigneds(3, 5);\n    test_constant(\n        |prec, rm| Float::sqrt_rational_prec_round(X, prec, rm),\n        10000,\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn primitive_float_sqrt_rational_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n    Rational: ExactFrom<T>,\n{\n    rational_gen().test_properties(|x| {\n        let sqrt = primitive_float_sqrt_rational::<T>(&x);\n        if sqrt.is_normal() {\n            let square = Rational::exact_from(sqrt).square();\n            match square.cmp(&x) {\n                Less => {\n                    assert!(Rational::exact_from(sqrt.next_higher()).square() > x);\n                }\n                Greater => {\n                    assert!(Rational::exact_from(sqrt.next_lower()).square() < x);\n                }\n                _ => {}\n            }\n        }\n    });\n\n    rational_pair_gen().test_properties(|(x, y)| {\n        let sqrt_x = NiceFloat(primitive_float_sqrt_rational::<T>(&x));\n        let sqrt_y = NiceFloat(primitive_float_sqrt_rational::<T>(&y));\n        if !sqrt_x.0.is_nan() && !sqrt_y.0.is_nan() {\n            match x.partial_cmp(&y).unwrap() {\n                Equal => assert_eq!(sqrt_x, sqrt_y),\n                Less => assert!(sqrt_x <= sqrt_y),\n                Greater => assert!(sqrt_x >= sqrt_y),\n            }\n        }\n    });\n}\n\n#[test]\nfn primitive_float_sqrt_rational_properties() {\n    apply_fn_to_primitive_floats!(primitive_float_sqrt_rational_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{Square, SquareAssign};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, rounding_mode_gen, unsigned_gen_var_11,\n    unsigned_rounding_mode_pair_gen_var_3,\n};\nuse malachite_float::emulate_float_to_float_fn;\nuse malachite_float::test_util::arithmetic::square::{\n    rug_square, rug_square_prec, rug_square_prec_round, rug_square_round, square_prec_round_naive,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_6, float_gen_var_7, float_gen_var_8, float_gen_var_9,\n    float_gen_var_10, float_gen_var_12, float_rounding_mode_pair_gen_var_7,\n    float_rounding_mode_pair_gen_var_8, float_rounding_mode_pair_gen_var_9,\n    float_rounding_mode_pair_gen_var_10, float_rounding_mode_pair_gen_var_11,\n    float_rounding_mode_pair_gen_var_12, float_rounding_mode_pair_gen_var_22,\n    float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_2, float_unsigned_rounding_mode_triple_gen_var_11,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::platform::Limb;\nuse malachite_q::Rational;\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_square() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let square = x.clone().square();\n        assert!(square.is_valid());\n\n        assert_eq!(square.to_string(), out);\n        assert_eq!(to_hex_string(&square), out_hex);\n\n        let square_alt = (&x).square();\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n\n        let mut square_alt = x.clone();\n        square_alt.square_assign();\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_square(&rug::Float::exact_from(&x)))),\n            ComparableFloatRef(&square)\n        );\n\n        let square_alt = square_prec_round_naive(x.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"Infinity\", \"Infinity\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\"-1.0\", \"-0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"1.51e4\", \"0x3.b0E+3#7\");\n    test(\"-123.0\", \"-0x7b.0#7\", \"1.51e4\", \"0x3.b0E+3#7\");\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n    );\n\n    // - in square_float_significand_same_prec_lt_w\n    // - decrement_exp in square_float_significand_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\");\n    // - !decrement_exp in square_float_significand_same_prec_lt_w\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_lt_w\n    // - rm == Nearest in square_float_significand_same_prec_lt_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && square & shift_bit == 0)) in\n    //   square_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", \"2.0\", \"0x2.0#2\");\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || square & shift_bit != 0) &&\n    //   !overflow in square_float_significand_same_prec_lt_w\n    test(\"1.6\", \"0x1.a#4\", \"2.8\", \"0x2.c#4\");\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || square & shift_bit != 0) && overflow\n    //   in square_float_significand_same_prec_lt_w\n    test(\"1.414\", \"0x1.6a#8\", \"2.0\", \"0x2.00#8\");\n    // - in square_float_significand_same_prec_w\n    // - decrement_exp in square_float_significand_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_w\n    // - rm == Nearest in square_float_significand_same_prec_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && product.even())) in\n    //   square_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n    );\n    // - !decrement_exp in square_float_significand_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || product.odd()) && !overflow in\n    //   square_float_significand_same_prec_w\n    test(\n        \"3.2729513077064011786e-37\",\n        \"0x6.f5f6d50e7b8f6eb0E-31#64\",\n        \"1.0712210262617041571e-73\",\n        \"0x3.073e45e79ac604c4E-61#64\",\n    );\n    test(\n        \"1.9999999999999999999\",\n        \"0x1.fffffffffffffffe#64\",\n        \"3.9999999999999999996\",\n        \"0x3.fffffffffffffff8#64\",\n    );\n    test(\n        \"1.9999999999999999998\",\n        \"0x1.fffffffffffffffc#64\",\n        \"3.9999999999999999991\",\n        \"0x3.fffffffffffffff0#64\",\n    );\n    test(\n        \"1.4142135623730950488\",\n        \"0x1.6a09e667f3bcc908#64\",\n        \"1.9999999999999999999\",\n        \"0x1.fffffffffffffffe#64\",\n    );\n    test(\n        \"1.4142135623730950489\",\n        \"0x1.6a09e667f3bcc90a#64\",\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#64\",\n    );\n\n    // - in square_float_significand_same_prec_gt_w_lt_2w\n    // - lo.wrapping_add(2) & (mask >> 2) <= 2 in square_float_significand_same_prec_gt_w_lt_2w\n    // - decrement_exp in square_float_significand_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest in square_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && (z_0 & shift_bit) == 0) in\n    //   square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n    );\n    // - lo.wrapping_add(2) & (mask >> 2) > 2 in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"1.00000000000000000022\",\n        \"0x1.0000000000000004#65\",\n    );\n    // - !decrement_exp in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        \"2.0742001767277848782373298e56\",\n        \"0x8.7590e74562e8c0aeed1d0E+46#85\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && !overflow\n    //   in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"119368.6474438890389479272222539538\",\n        \"0x1d248.a5bee1f96ad66a5061314f7#109\",\n        \"14248873992.58347719172623084795998\",\n        \"0x3514c9008.955ec2e06d13cb2d862#109\",\n    );\n    // - in square_float_significand_same_prec_gt_2w_lt_3w\n    // - a0.wrapping_add(4) & (mask >> 2) <= 4 in square_float_significand_same_prec_gt_2w_lt_3w\n    // - decrement_exp in square_float_significand_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_gt_2w_lt_3w\n    // - rm == Nearest in square_float_significand_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && z_0 & shift_bit == 0) in\n    //   square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n    );\n    // - a0.wrapping_add(4) & (mask >> 2) > 4 in square_float_significand_same_prec_gt_2w_lt_3w\n    // - !decrement_exp in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        \"4.09688648907491713333499964381160220254051958e-58\",\n        \"0x2.9258227caed7c4000630a1192a20211680c74E-48#149\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) in\n    //   square_float_significand_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && !overflow\n    //   in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"4.9709672065181108960570410290811793724062284431352e-48\",\n        \"0x7.43dc113e95ca123693650af31435eac45c0e7a680E-40#165\",\n        \"2.47105149682784709830100902225310999174453232836862e-95\",\n        \"0x3.4c805dfa0982f9705aa6bbd6840b755493beef234E-79#165\",\n    );\n    test(\n        \"0.853553390593273762200422181052424519642417968844237018294169934497683119615526759712596\\\n        883581910393183753461557728074256231209013962684303161030374274983957853305666481876398188\\\n        949987625288195515142867527389992901492568633649215503682129354660222299652388082307621077\\\n        178580362709940650906998812851997421813349136582952207410155153814588098763686437571939990\\\n        432458893805084382964252838593650852124711790096724992674751203757636006947579113561955767\\\n        12323422965539514461577789916717825325390464224680930882212731621531237\",\n        \"0x0.da827999fcef32422cbec4d9baa55f4f8eb7b05d449dd426768bd642c199cc8aa57e41821d5c5161d458f\\\n        f37ee41ed9c87ba542f21ce3da53c02439b1efd13b469101743a1578fa72982ce3008de19bde558de488b4422c\\\n        523055e3917be2719e36ad451c5dbf4ee659531a198f9e426fa978907c1b72c1775525044c8206525409ca55b6\\\n        c7e877efa69d01675e49f0621326d5e6a945b28dc679a0db7c11b6380826e00ff191a9799952f4fbded0f5ffb5\\\n        0df1fe5110983ef503120fbd540e160fe5eef517bee198c41c51757faf9d96927a53b1fd65c#1719\",\n        \"0.728553390593273762200422181052424519642417968844237018294169934497683119615526759712596\\\n        883581910393183753461557728074256231209013962684303161030374274983957853305666481876398188\\\n        949987625288195515142867527389992901492568633649215503682129354660222299652388082307621077\\\n        178580362709940650906998812851997421813349136582952207410155153814588098763686437571939990\\\n        432458893805084382964252838593650852124711790096724992674751203757636006947579113561955767\\\n        12323422965539514461577789916717825325390464224680930882212731621531237\",\n        \"0x0.ba827999fcef32422cbec4d9baa55f4f8eb7b05d449dd426768bd642c199cc8aa57e41821d5c5161d458f\\\n        f37ee41ed9c87ba542f21ce3da53c02439b1efd13b469101743a1578fa72982ce3008de19bde558de488b4422c\\\n        523055e3917be2719e36ad451c5dbf4ee659531a198f9e426fa978907c1b72c1775525044c8206525409ca55b6\\\n        c7e877efa69d01675e49f0621326d5e6a945b28dc679a0db7c11b6380826e00ff191a9799952f4fbded0f5ffb5\\\n        0df1fe5110983ef503120fbd540e160fe5eef517bee198c41c51757faf9d96927a53b1fd65c#1719\",\n    );\n}\n\n#[test]\nfn test_square_prec() {\n    let test = |s, s_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (square, o) = x.clone().square_prec(prec);\n        assert!(square.is_valid());\n\n        assert_eq!(square.to_string(), out);\n        assert_eq!(to_hex_string(&square), out_hex);\n        assert_eq!(o, o_out);\n\n        let (square_alt, o_alt) = x.square_prec_ref(prec);\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut square_alt = x.clone();\n        let o_alt = square_alt.square_prec_assign(prec);\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (square_alt, o_alt) = square_prec_round_naive(x.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n        assert_eq!(o_alt, o);\n\n        let (rug_square, rug_o) = rug_square_prec(&rug::Float::exact_from(&x), prec);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_square)),\n            ComparableFloatRef(&square),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"-Infinity\", \"-Infinity\", 1, \"Infinity\", \"Infinity\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", 1, \"2.0e4\", \"0x4.0E+3#1\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", 10, \"1.514e4\", \"0x3.b2E+3#10\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, \"2.0e4\", \"0x4.0E+3#1\", Greater);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        \"1.514e4\",\n        \"0x3.b2E+3#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n\n    // - in square_float_significands_general\n    // - xs_len <= 2 in square_float_significands_general\n    // - xs_len == 1 in square_float_significands_general\n    // - !b1 first time in square_float_significands_general\n    // - !goto_full_square second time in square_float_significands_general\n    // - !increment_exp in square_float_significands_general\n    test(\"1.0\", \"0x1.0#1\", 2, \"1.0\", \"0x1.0#2\", Equal);\n    // - b1 first time in square_float_significands_general\n    test(\"1.5\", \"0x1.8#2\", 1, \"2.0\", \"0x2.0#1\", Less);\n    // - increment_exp in square_float_significands_general\n    test(\"1.2\", \"0x1.4#3\", 1, \"2.0\", \"0x2.0#1\", Greater);\n    // - xs_len < 2 <= MPFR_SQR_THRESHOLD in square_float_significands_general\n    // - goto_full_square second time in square_float_significands_general\n    // - b1 third time in square_float_significands_general\n    test(\n        \"0.000199046277632504184666664672269768242929310652018203552191617720205649\",\n        \"0x0.000d0b7140b8f3aea60aad60c1dc3b2ee0d83e2eba33dcfb6f874df52d78#225\",\n        26,\n        \"3.9619421e-8\",\n        \"0xa.a2a038E-7#26\",\n        Less,\n    );\n    // - xs_len == 2 in square_float_significands_general\n    test(\n        \"330.3297903358337046735382484655688\",\n        \"0x14a.546d23b2f14f71a1f4c12ddaa88#115\",\n        45,\n        \"109117.770383317\",\n        \"0x1aa3d.c537d75#45\",\n        Greater,\n    );\n    // - !b1 third time in square_float_significands_general\n    test(\n        \"88.32972592752556369746097031876493672699524930031683012093294198918\",\n        \"0x58.5468eb1b5d957d68d5c161060f2abd3d11568e57fb44ace5b9530c#222\",\n        41,\n        \"7802.140482433\",\n        \"0x1e7a.23f6a82#41\",\n        Greater,\n    );\n    // - xs_len > MPFR_SQR_THRESHOLD in square_float_significands_general\n    // - xs[0] != 0 || xs[1] != 0 in square_float_significands_general\n    // - out_prec <= p - 5 in square_float_significands_general\n    // - !goto_full_square first time in square_float_significands_general\n    // - in limbs_float_square_high\n    // - k.is_none() in limbs_float_square_high\n    // - b1 second time in square_float_significands_general\n    // - can_round in square_float_significands_general\n    test(\n        \"396.3412272551190567593891335756570564001425784787446073953740531440207891605323131867948\\\n        869355406520857599475406495997289490143735096829625551391579153111055037678989978858579586\\\n        021105696471344997604889396207883425571313379937012790014662248134632025438319010426957144\\\n        355546486040271820495868974546882981476343977667254209899704548500299738343700283443799494\\\n        532151589935402512791651191411866655264587358069356924819557816073395721436815590916015139\\\n        840293409397442\",\n        \"0x18c.575aab5d3d7d931fe7b1df9a17c5180eb11799ddcdb0b514b818c68be091c380b4f49e26c6357fc5521\\\n        89c83f7fb1af51d3ad56a7621351488217dec257419292d332960be3dcbdbf0989c56e4cc82fcee123ce6c00b8\\\n        63f9e45062bf3fbae296936b2ab5e3779905657246488ffaf88040c9e3456d8e0dcb25c0b55feba5452509320e\\\n        91f9be5ce584d555f8c77c79aeec4f5bb5aff76c235d04d87f5adafe9a729dccc5692f11d14f4aeeec72b2dc3e\\\n        c35bf6b0a8d1d636bb2afad1ab82c0#1539\",\n        41,\n        \"157086.3684222\",\n        \"0x2659e.5e50ea#41\",\n        Greater,\n    );\n    // - !b1 second time in square_float_significands_general\n    test(\n        \"0.289565969492664694638578202456729810638628879666435586140728331245058747654800231361781\\\n        733367215018660480916949243715433401890725345322341436886642908102373347900363371546861032\\\n        804628537167569586473086484745604528149555432827776527274466086199528238950727774219761110\\\n        278394595668030807862161516149163941956835588098749888947102946654461061159884953097421811\\\n        149735301912628233431116932895412543378996752139902311082164451547359831823770756258588441\\\n        392364079976282812844068282256919410425900496233045740740436555471195699615728406687884353\\\n        411870520651275282496307876556394549674324563102261561135259821040813150131202195032317605\\\n        601108576080171231347456850423368707704016287732147225807113778613580546356726188558446009\\\n        37667532705200099920676965417288103441\",\n        \"0x0.4a20fed1016a521a64864d01138a193df1e23f2f35edd21912c8d7ea345216c5ec7c59aca3d2ce1378dd1\\\n        89d7419984353ecef1dc303caddc54cc6cf871a7d44df07922bfe75b3e27fa2ac58a45a2700c2b9d233b14afbe\\\n        c4aeeed4683073d061d99c2f92084cbae1d1bf26f8fb2323910d590864daa5f4b534e0509ff60a7238357ab7ff\\\n        36bcc0024c64f4507f522e91df687d9649e2e609840feea945bd53cec1fec45c7ccee6ad51aacd8c59427836f6\\\n        871c316bc3ba008d00a81638ec6c5630fafa1ebe3c492a94c04c96f772e57d74f808872161bf166402ea4e9dd0\\\n        42397a51a2e1ffd33b8865cca279beaaf61c288bdc67dceb9e84f124abd1c1016bfc1d67e916ef24dc5a541f8c\\\n        e0888c25325a3955899b701e5035429c76e90b7de02973eaa08674d6315156df3c4afdd962afc0b2fb855c12c7\\\n        cb#2507\",\n        41,\n        \"0.08384845068821\",\n        \"0x0.1577179186b#41\",\n        Less,\n    );\n    // - k == Some(0) in limbs_float_square_high\n    // - in limbs_float_square_high_basecase\n    test(\n        \"2.534905093269173913399961419051078001207362536676304036217117050023406987769089211085345\\\n        845282321276763762108762278121117963061716139888836603176571082592497694546991532956806762\\\n        060078393566599448512584861538013806584451166069797239642908909634341260487656925769615819\\\n        575456879212968568058838065343005029399246396366977778814769813140337173953816940118229696\\\n        975910769633258534685767958638383299293048391708530965415961893726949253541358150164947850\\\n        354131943712963257075685505691799739914956071583726713409225265256065457404089250831362505\\\n        964054898560581202320837085103659819920563909237065863856674551755094031141043600118470396\\\n        110548066038755307598657006758419658655479386061317383935495778887020750969220495044500181\\\n        502836698351684979845272389537925642124685759621079734656489541651071700522564930994999675\\\n        548215393164945318735677787876975365012973524228071379171196099071790619084107585184183873\\\n        649229987470512431316532998401599147457982188040992886626796443210441148620644905909977484\\\n        092106548023293796713001951271606863906640116960398160889963208431853184379130926702446309\\\n        16665296291511e-18\",\n        \"0x2.ec2c037afc439f03a036777b3b49c929652bc0198062ee846d167a89e9a1b649beaab8e3935d29165383b\\\n        8032ab14cd30954f6e10277bf2adbaa3dc7f4af85aa6a3dfe37f0afee4bafa862c5d97d6b0ad6fe3a473f086a0\\\n        d78eaa4db0710879d93d26ada2de74e4133838c88fda61bf559b836a376e2ece72417c51fff1870b23e21aa228\\\n        c6b132e5b2dea393b782ddc27593a878aec5ddd0254c2fe5515f3036b02fc8ab225f7433c0e931717894c1f581\\\n        86927d1a1d3ae8a8d5a52d6ffd5bb9a6f1d8c55f9c54d16411a5a7a6bf1616d3eaf4692379eb81ba2b11179269\\\n        987c75a403cd7845851b66bf9758892745e79ac67a6a8feb7dcdcb16690d8fae58f96bc20e8495bdee03ef7ad7\\\n        d1821419ec1bfe2bb5b49cbfcab0f7a3523939693c97830d3c6e027badb91529d6076972fcea0ace6d83b34f64\\\n        0da99faaa4862efc02a02d3a5066111bfc08e28a6b55ff9e7c245b0232f0a85e97a68fa69e8d218bce6abe990a\\\n        2e0b503cf831ad5df31caba8915c38bad1cc785b9e99b3bb855801ec29ad43668762f37f228f77bf7a8590649f\\\n        937d5dc5039a46479d0dac0be7aa72929e8868980b3f76831bf434c15ba83ba74394414959b1c8bc010f735a6c\\\n        14c8b93afc80E-15#3627\",\n        423,\n        \"6.425743831881999297033060889967219634391598848272085805147756300415778053639020164208035\\\n        3509860715112301888671841760135704785647e-36\",\n        \"0x8.8a913be7e47dfd7ad8403512f1a0ee8d3fad7395038c39eb4039b4703fdcd0314b45e761b67375d18eb58\\\n        ced237cd5fd6c79c02dcE-30#423\",\n        Less,\n    );\n    // - xs[0] == 0 && xs[1] == 0 in square_float_significands_general\n    test(\n        \"511.9999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\\n        999999999999858969189385560189369588899908301051658131815921691396545986807150339147015462\\\n        016914098983479659782731543057846003175884332840513803623318182318832820724717407320371823\\\n        6294395745915856\",\n        \"0x1ff.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000#1539\",\n        45,\n        \"262144.0\",\n        \"0x40000.0000000#45\",\n        Greater,\n    );\n    // - !can_round in square_float_significands_general\n    test(\n        \"5070602400912917605986812821504.000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000072282982868771681166004491412846722101397844122267684138688870467552820474559090102317\\\n        447234871538375909335604136421707865093288809202542467085297095776399695369977155046440218\\\n        72699461509694558652328992590065121835881232\",\n        \"0x40000000000000000000000000.000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\\\n        fffffffffffffffffffffe#2230\",\n        75,\n        \"2.5711008708143844408671e61\",\n        \"0x1.0000000000000000000E+51#75\",\n        Less,\n    );\n    // - k != None && k != Some(0) && len <= SQR_FFT_THRESHOLD in limbs_float_square_high\n    test(\n        \"396.3412272551190567593891335756570564001425784787446073953740531440207891605323131867948\\\n        869355406520857599475406495997289490143735096829625551391579153111055037678989978858579586\\\n        021105696471344997604889396207883425571313379937012790014662248134632025438319010426957144\\\n        355546486040271820495868974546882981476343977667254209899704548500299738343700283443799494\\\n        532151589935402512791651191411866655264587358069356924819557816073395721436815590916015139\\\n        840293409397442\",\n        \"0x18c.575aab5d3d7d931fe7b1df9a17c5180eb11799ddcdb0b514b818c68be091c380b4f49e26c6357fc5521\\\n        89c83f7fb1af51d3ad56a7621351488217dec257419292d332960be3dcbdbf0989c56e4cc82fcee123ce6c00b8\\\n        63f9e45062bf3fbae296936b2ab5e3779905657246488ffaf88040c9e3456d8e0dcb25c0b55feba5452509320e\\\n        91f9be5ce584d555f8c77c79aeec4f5bb5aff76c235d04d87f5adafe9a729dccc5692f11d14f4aeeec72b2dc3e\\\n        c35bf6b0a8d1d636bb2afad1ab82c0#1539\",\n        1000,\n        \"157086.3684220939290392835990654860444953123468682922432646919273797192952403374080185049\\\n        441414358725029167080302705853255170809678818388441806686518494713508728113056316939955366\\\n        580321349638671885788642336442940811575310873763709312578497006621517503935000405848895060\\\n        9190911436529068384755172193385643\",\n        \"0x2659e.5e50e90c8c8f731b6ec42e31ac581c6d5c6e7051268a54ce30dbe17faafc9ad4523be4827db001d48\\\n        8a322a36c3d610868daa74b44da3bd6945b467643769f500a263ca6634a2786c8e089cd305b177ffba7d9cf923\\\n        74c0483fa9a736b452c7e65bfe13f1fbababe9090e56a0abfa7e4982915fe0dff247e8378e8#1000\",\n        Greater,\n    );\n    // - out_prec > p - 5 in square_float_significands_general\n    // - out_prec > p - 5 + Limb::WIDTH || xs_len <= MPFR_SQR_THRESHOLD + 1 in\n    //   square_float_significands_general\n    // - goto_full_square first time in square_float_significands_general\n    test(\n        \"396.3412272551190567593891335756570564001425784787446073953740531440207891605323131867948\\\n        869355406520857599475406495997289490143735096829625551391579153111055037678989978858579586\\\n        021105696471344997604889396207883425571313379937012790014662248134632025438319010426957144\\\n        355546486040271820495868974546882981476343977667254209899704548500299738343700283443799494\\\n        532151589935402512791651191411866655264587358069356924819557816073395721436815590916015139\\\n        840293409397442\",\n        \"0x18c.575aab5d3d7d931fe7b1df9a17c5180eb11799ddcdb0b514b818c68be091c380b4f49e26c6357fc5521\\\n        89c83f7fb1af51d3ad56a7621351488217dec257419292d332960be3dcbdbf0989c56e4cc82fcee123ce6c00b8\\\n        63f9e45062bf3fbae296936b2ab5e3779905657246488ffaf88040c9e3456d8e0dcb25c0b55feba5452509320e\\\n        91f9be5ce584d555f8c77c79aeec4f5bb5aff76c235d04d87f5adafe9a729dccc5692f11d14f4aeeec72b2dc3e\\\n        c35bf6b0a8d1d636bb2afad1ab82c0#1539\",\n        5000,\n        \"157086.3684220939290392835990654860444953123468682922432646919273797192952403374080185049\\\n        441414358725029167080302705853255170809678818388441806686518494713508728113056316939955366\\\n        580321349638671885788642336442940811575310873763709312578497006621517503935000405848895060\\\n        919091143652906838475517219338564216871512733323414114900025582889108770319888495423472591\\\n        622217081406162593383439817010743870950284355953948594596501930134914144626602460886577742\\\n        699397445023366416628676609358289067494944516044161793867980863078877928160882497479870173\\\n        995550846564918220947311792283316244784987871826325087158139795457567671300755416634197565\\\n        825272103067497350477832613308006740370014538444363794113999101665422314265225122590389544\\\n        388555686073293478850435707082986891289816937189501867266947100104879700862539689861260203\\\n        303222356049565246944094013202651746222554947384760413370539804854333289940364855469937239\\\n        014120251649267431651939212811005766277308077834857972931251756411522886575455852040387255\\\n        586633599190053514685721006798676467868675709844997689304699851005119605477859913661835009\\\n        980047325267722717984269099465289430789912767924820742466247451598658072993390431860927262\\\n        510441796888642732252820490424273307195428579227975601954580861122408746440602416210603394\\\n        010320119854126656872002234654813295901729990426282838623889803078731960696692381273900064\\\n        363258066357675869791572233715232583553618635258761844046010323346239050118033120274686587\\\n        47626978436794438933236478602171106153180118157402691906229607357337\",\n        \"0x2659e.5e50e90c8c8f731b6ec42e31ac581c6d5c6e7051268a54ce30dbe17faafc9ad4523be4827db001d48\\\n        8a322a36c3d610868daa74b44da3bd6945b467643769f500a263ca6634a2786c8e089cd305b177ffba7d9cf923\\\n        74c0483fa9a736b452c7e65bfe13f1fbababe9090e56a0abfa7e4982915fe0dff247e8378e637c71563f40ac88\\\n        bff59ccb63d55f07b40f44324086d33c752ca2a398f8021f9ab7e61160ce80b0eb4d350cfcb2745c0ffb94a7ea\\\n        c2a42031e1d67c39dabea5ed0ed1839b3cb19c95afad38ff4d85fe726701b1400759bff428fc5d441579646a9a\\\n        edbda6e96c39642ea5102dcc1744e2f22bc2669606b02248465eda50f7ab00888fe70cd5b94c6886478a9d89d4\\\n        721fd315aae640835a05a2ac14cf927011012c9a0b12526c935c3b86e035f9369aa246b7f864ac313401679f2d\\\n        585686dd60ca3610690fc6e131d703a07afa9f50e1c62593876e5dfcd53a06dfc5c84a2d7c8129428f50ff8669\\\n        462d4cbbacfe9e72bf3cd17875fb28dd45607447a1bdd656f47900000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        #5000\",\n        Equal,\n    );\n    // - out_prec <= p - 5 + Limb::WIDTH && xs_len > MPFR_SQR_THRESHOLD + 1 in\n    //   square_float_significands_general\n    // - xs_len <= len in square_float_significands_general\n    // - k < twice_len in square_float_significands_general\n    test(\n        \"70459532516206275717738.24583571192785940804485220379113093012216854237552273164629839052\\\n        295542459627091867686732592292054910255896821543632944963319945361030770270423888774548519\\\n        352455933682416235026529894320254192088358055829902767990508592251676851896653974385735963\\\n        818455173075208105139936148350808080166279329650970874228499292765775926866402018763767601\\\n        932631118142152227916465948527446827475834919059052275938611139784416871828297279794775881\\\n        754156488112402263366312959738244152841157181731104967167515387928211427131697792191239671\\\n        200062974233522321766736844717284659803787329075216256925936831334895804054605134987158729\\\n        635284806758566129642530508638215601547746106827192539740893000302521313674983124372016914\\\n        389464631779788838617640381788549537988633853246170604449289457144019599904363663940307935\\\n        010893280729695200089400652615175194820160750890242280186267733830422108880046398617008039\\\n        346196610860314292217862221940568925947020858793049858538542201667012791629444317697230994\\\n        497432161328637397726885087365856366871387393212442806903408576734184446519785519751530501\\\n        203958503763892329891980999384336300765212927244594343049091702158556853491733512332595607\\\n        980340866258213963813028256778277899307861580399445091884912999955742998432553541817046928\\\n        089178846440489676733765036119262237349966327782496860922729317780078565098542288671006633\\\n        263750319390117261972206095532634412489779996284041680459224965604552001326514848875913522\\\n        75401658328725688546699002488305760364795486416541\",\n        \"0xeeb9e70f8e3103fea6a.3eef16d6eb45c3a998fb982ebe639fc8759b70c44fe5810571a8155bfb031e4bc24\\\n        7dda5a8581f5ab0434d47c9eb35f6a9fb469e23b989044db9aefcec6a8d1de5bf14332cc4bb1bc75c32a4e36cc\\\n        f907a5658e025a6f217cb147f7a8ce671eee07c655ecbe2598eb280ca4d26207f6c1e55ed67b66c69d289c56d3\\\n        4f2d2b25f411c0b9e4696d67a2ebe0b5716309bb26e24a3cc52943382e8956c46f600932e74aed277d50d0b801\\\n        d8cdf51e8d20373cc3c14623e93446643f969b662cd3d7da7f3f840246325c873da49be886e93a9f2b9debb19d\\\n        6b28dc9e7e168f16ac806d56ffbeb1836aff27be850217d6311ab97d9742412187d3ecde0f7d4a0c89c6b46c37\\\n        610de9e5d478f868be38875f5c45f683618305161b4a1e6811cc1c53c2798dddbe1daba42c542637900cae7fe8\\\n        7cb8178a8825ae05ae6c791d728ab540947bc63fcb32f5af0d89b211e00aa940c8ccb7aa1ff76a1590b970f2c4\\\n        010fddbeb773600a0bd98bc005244e5ce6bf94d6ff4be6c4ddaffe2d3f89ae99eb2b79591c994977331c5caa40\\\n        d57d28f6fa0bd1458390ffd906d84e849964bf2c3afb5fa3e251d60fb42251182bc006f0da82dd32c5877d3183\\\n        b771fa955b64fe611c8a57edf9070898139a48e93a9f7cf1bc280142a0c900175e97125e4dba6cd579985765eb\\\n        ea2bf0ecfb3754e8373897fd5f3fbdd8a04c429f1eb274d27b90c5ba4cdc5221ee37d3885cc6b8a0745a21d803\\\n        9a0571a0a77248c1a21338919b63ada2c014b8d1864ad65dc80551ded9cd5e048f7a262866d51e252ee527629b\\\n        0628f7561340ddc20398c57d6f3159cec6f4979a02c5610d3743e31aa8993d652c6ea0#4942\",\n        5000,\n        \"4964545722402329471538520890548020778505727316.714928212970963455240096184214428743957383\\\n        329922752233199764049780878042702316184608300084915002665385500366536453418018453492928341\\\n        017054541630873437214644149654854522755654366831843415669733075028381314388954345055868246\\\n        000218989221937469258574896624097067887464348708304868331849053151758619452575265628276389\\\n        682599022898309226512794404632814475266579950972366209872195059885305874209009896969746959\\\n        550374594439111632193759127250892146888326838744623554050318490109344201586718804154701606\\\n        966010758459087950191998865560033257935278780535428646473292047088396527777426223171234483\\\n        188009004262125992356660280897524089496628310376755558332111429032108512629018171093951768\\\n        666071288536225840334502196980458876275123956423686107784807652541652782835788006847858977\\\n        993995691507283189780038044528425354524130033815262491772309833202212299992561581175232232\\\n        053665702559586771762340461465421956694347639348699503880840804336286789065206696824702252\\\n        001401065405887247144705146834255039213991488108844897575368853688286293567906566377054487\\\n        855713514655373784168449710429759002204390811345191073301339247358231849563161226052987665\\\n        594985477181835691490984499872892234197121121888658800164578709448237427211277623000068159\\\n        736988165669283234595563391379976241167126662466254710156731663896405093320111508971147717\\\n        596133787650005180714732054756611220213766696881623761124569357842183971615077248468826825\\\n        78028047188611500722085706480035062367867718429318751607371955873121\",\n        \"0xde9e30a0b16bb9d3b1d41b9ca941523105ed54.b705890db2b0d9f3e32b9f103e1b83c7f9edba5c1f4e2af3\\\n        adeb66de82892d7410e07fd6532bc0baf1535d9dfdf455d02d7b3cdcd6b683dd9909ef54c1c3138d14f10d53ef\\\n        a61999322d530e26efcb69e290c671098fb49bb695602d0e25cb7d993dc249014fc873b17a61bb8c9a878cb42e\\\n        f205fa6138dbfc05bd5c65440690ca6b0054108cab3099860992a8d16ad6797a10fba9af26f477b820e5a0499c\\\n        bf71480aff1edfd22ad78810350210eae0cec2b5d0248df96b630be8372423d110cdd49422b85db636542c44ca\\\n        d9c82a307aaeb2d1795d93184dd19dc0e3bd6c9cdc631fe51a88f0a178def01f6ae41386a6563a14613e79ab7d\\\n        b81b5373a481694455cc8778c037bd3a3c6e2b7a0f448025095104d91359860535455349496f70c9ca535c3e69\\\n        8563c5e868485868fb51e33f09ed11186e72d4c6b2ce9f4b7629a78b907f198ac6cdde2f6642df2b1c9737ce1a\\\n        48ac426a8d401ef2aa8acbd3185bfd87dc282064adc7145f4dc07a12d6b35f38fb04eb2c4da98e45b7287d9982\\\n        2aea6ee0f4d2b8771272e2f4e9d0afb433896b20f842155ae13c2df308b254065539842f8cb05363f97ef29bbb\\\n        6b1fd5ac471efcf6cd026fe29de50b9a08d5e4610e95cba281a1006f876c351b4b8c381caf1f9f849a3ad17f6b\\\n        fed7e727b78c97f11622da2ae8fd3c5759f030ea2800bd1d267f019d2292f18d7360d036e88707bbd93901fda7\\\n        c8fa8cfeeb7aca62069cec0809ae3add2dfdbffa773246c8ae9749ac6c8b0cced5911da8050ea0171f866099b7\\\n        44d3739341181361c2df7c3d9320134683888ed78e4d80fc191958b201777943c0cac9c3c082a01b24d3#5000\",\n        Less,\n    );\n}\n\n#[test]\nfn square_prec_fail() {\n    assert_panic!(Float::NAN.square_prec(0));\n    assert_panic!(Float::NAN.square_prec_ref(0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.square_prec_assign(0)\n    });\n}\n\n#[test]\nfn test_square_round() {\n    let test = |s, s_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (square, o) = x.clone().square_round(rm);\n        assert!(square.is_valid());\n\n        assert_eq!(square.to_string(), out);\n        assert_eq!(to_hex_string(&square), out_hex);\n        assert_eq!(o, o_out);\n\n        let (square_alt, o_alt) = x.square_round_ref(rm);\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut square_alt = x.clone();\n        let o_alt = square_alt.square_round_assign(rm);\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_square, rug_o) = rug_square_round(&rug::Float::exact_from(&x), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_square)),\n                ComparableFloatRef(&square),\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (square_alt, o_alt) = square_prec_round_naive(x.clone(), x.significant_bits(), rm);\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", Floor, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", Down, \"Infinity\", \"Infinity\", Equal);\n    test(\"Infinity\", \"Infinity\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\"-Infinity\", \"-Infinity\", Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", Floor, \"1.51e4\", \"0x3.b0E+3#7\", Less);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        Ceiling,\n        \"1.52e4\",\n        \"0x3.b8E+3#7\",\n        Greater,\n    );\n    test(\"123.0\", \"0x7b.0#7\", Down, \"1.51e4\", \"0x3.b0E+3#7\", Less);\n    test(\"123.0\", \"0x7b.0#7\", Up, \"1.52e4\", \"0x3.b8E+3#7\", Greater);\n    test(\"123.0\", \"0x7b.0#7\", Nearest, \"1.51e4\", \"0x3.b0E+3#7\", Less);\n\n    test(\"-123.0\", \"-0x7b.0#7\", Floor, \"1.51e4\", \"0x3.b0E+3#7\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Ceiling,\n        \"1.52e4\",\n        \"0x3.b8E+3#7\",\n        Greater,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", Down, \"1.51e4\", \"0x3.b0E+3#7\", Less);\n    test(\"-123.0\", \"-0x7b.0#7\", Up, \"1.52e4\", \"0x3.b8E+3#7\", Greater);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Nearest,\n        \"1.51e4\",\n        \"0x3.b0E+3#7\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Floor,\n        \"2.0\",\n        \"0x2.0000000000000#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Ceiling,\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Down,\n        \"2.0\",\n        \"0x2.0000000000000#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Up,\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Nearest,\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Floor,\n        \"2.0\",\n        \"0x2.0000000000000#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Ceiling,\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Down,\n        \"2.0\",\n        \"0x2.0000000000000#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Up,\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Nearest,\n        \"2.0000000000000004\",\n        \"0x2.0000000000002#53\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"9.869604401089356\",\n        \"0x9.de9e64df22ee8#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"9.869604401089356\",\n        \"0x9.de9e64df22ee8#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"9.869604401089356\",\n        \"0x9.de9e64df22ee8#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"9.869604401089356\",\n        \"0x9.de9e64df22ee8#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"9.869604401089358\",\n        \"0x9.de9e64df22ef0#53\",\n        Greater,\n    );\n\n    // - rm == Floor || rm == Down in square_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", Down, \"2.0\", \"0x2.0#2\", Less);\n    // - rm == Ceiling || rm == Up in square_float_significand_same_prec_lt_w\n    // - (rm == Ceiling || rm == Up) && !overflow in square_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", Up, \"3.0\", \"0x3.0#2\", Greater);\n    // - (rm == Ceiling || rm == Up) && overflow in square_float_significand_same_prec_lt_w\n    test(\"1.4\", \"0x1.6#4\", Up, \"2.0\", \"0x2.0#4\", Greater);\n    // - rm == Floor || rm == Down in square_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Down,\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in square_float_significand_same_prec_w\n    // - (rm == Ceiling || rm == Up) && !overflow in square_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Up,\n        \"1.0000000000000000003\",\n        \"0x1.0000000000000006#64\",\n        Greater,\n    );\n    // - rm == Floor || rm == Down in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Down,\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in square_float_significand_same_prec_gt_w_lt_2w\n    // - (rm == Ceiling || rm == Up) && !overflow in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Up,\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        Greater,\n    );\n    // - rm == Floor || rm == Down in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Down,\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n        Less,\n    );\n    // - rm == Ceiling || rm == Up in square_float_significand_same_prec_gt_2w_lt_3w\n    // - (rm == Floor || rm == Down) && !overflow in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Up,\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        Greater,\n    );\n\n    // - in square_float_significand_same_prec_lt_w\n    // - decrement_exp in square_float_significand_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    // - !decrement_exp in square_float_significand_same_prec_lt_w\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_lt_w\n    // - rm == Nearest in square_float_significand_same_prec_lt_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && square & shift_bit == 0)) in\n    //   square_float_significand_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", Nearest, \"2.0\", \"0x2.0#2\", Less);\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || square & shift_bit != 0) &&\n    //   !overflow in square_float_significand_same_prec_lt_w\n    test(\"1.6\", \"0x1.a#4\", Nearest, \"2.8\", \"0x2.c#4\", Greater);\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || square & shift_bit != 0) && overflow\n    //   in square_float_significand_same_prec_lt_w\n    test(\"1.414\", \"0x1.6a#8\", Nearest, \"2.0\", \"0x2.00#8\", Greater);\n    // - in square_float_significand_same_prec_w\n    // - decrement_exp in square_float_significand_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_w\n    // - rm == Nearest in square_float_significand_same_prec_w\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && product.even())) in\n    //   square_float_significand_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"1.0000000000000000002\",\n        \"0x1.0000000000000004#64\",\n        Less,\n    );\n    // - !decrement_exp in square_float_significand_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || product.odd()) && !overflow in\n    //   square_float_significand_same_prec_w\n    test(\n        \"3.2729513077064011786e-37\",\n        \"0x6.f5f6d50e7b8f6eb0E-31#64\",\n        Nearest,\n        \"1.0712210262617041571e-73\",\n        \"0x3.073e45e79ac604c4E-61#64\",\n        Greater,\n    );\n    test(\n        \"1.9999999999999999999\",\n        \"0x1.fffffffffffffffe#64\",\n        Nearest,\n        \"3.9999999999999999996\",\n        \"0x3.fffffffffffffff8#64\",\n        Less,\n    );\n    test(\n        \"1.9999999999999999998\",\n        \"0x1.fffffffffffffffc#64\",\n        Nearest,\n        \"3.9999999999999999991\",\n        \"0x3.fffffffffffffff0#64\",\n        Less,\n    );\n    test(\n        \"1.4142135623730950488\",\n        \"0x1.6a09e667f3bcc908#64\",\n        Nearest,\n        \"1.9999999999999999999\",\n        \"0x1.fffffffffffffffe#64\",\n        Less,\n    );\n    test(\n        \"1.4142135623730950489\",\n        \"0x1.6a09e667f3bcc90a#64\",\n        Nearest,\n        \"2.0000000000000000002\",\n        \"0x2.0000000000000004#64\",\n        Greater,\n    );\n\n    // - in square_float_significand_same_prec_gt_w_lt_2w\n    // - lo.wrapping_add(2) & (mask >> 2) <= 2 in square_float_significand_same_prec_gt_w_lt_2w\n    // - decrement_exp in square_float_significand_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest in square_float_significand_same_prec_gt_w_lt_2w\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && (z_0 & shift_bit) == 0) in\n    //   square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Less,\n    );\n    // - lo.wrapping_add(2) & (mask >> 2) > 2 in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Nearest,\n        \"1.00000000000000000022\",\n        \"0x1.0000000000000004#65\",\n        Less,\n    );\n    // - !decrement_exp in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        Nearest,\n        \"2.0742001767277848782373298e56\",\n        \"0x8.7590e74562e8c0aeed1d0E+46#85\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (z_0 & shift_bit) != 0) && !overflow\n    //   in square_float_significand_same_prec_gt_w_lt_2w\n    test(\n        \"119368.6474438890389479272222539538\",\n        \"0x1d248.a5bee1f96ad66a5061314f7#109\",\n        Nearest,\n        \"14248873992.58347719172623084795998\",\n        \"0x3514c9008.955ec2e06d13cb2d862#109\",\n        Greater,\n    );\n    // - in square_float_significand_same_prec_gt_2w_lt_3w\n    // - a0.wrapping_add(4) & (mask >> 2) <= 4 in square_float_significand_same_prec_gt_2w_lt_3w\n    // - decrement_exp in square_float_significand_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Nearest,\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in square_float_significand_same_prec_gt_2w_lt_3w\n    // - rm == Nearest in square_float_significand_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && (round_bit == 0 || sticky_bit == 0 && z_0 & shift_bit == 0) in\n    //   square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Nearest,\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n        Less,\n    );\n    // - a0.wrapping_add(4) & (mask >> 2) > 4 in square_float_significand_same_prec_gt_2w_lt_3w\n    // - !decrement_exp in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        Nearest,\n        \"4.09688648907491713333499964381160220254051958e-58\",\n        \"0x2.9258227caed7c4000630a1192a20211680c74E-48#149\",\n        Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) in\n    //   square_float_significand_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || z_0 & shift_bit != 0) && !overflow\n    //   in square_float_significand_same_prec_gt_2w_lt_3w\n    test(\n        \"4.9709672065181108960570410290811793724062284431352e-48\",\n        \"0x7.43dc113e95ca123693650af31435eac45c0e7a680E-40#165\",\n        Nearest,\n        \"2.47105149682784709830100902225310999174453232836862e-95\",\n        \"0x3.4c805dfa0982f9705aa6bbd6840b755493beef234E-79#165\",\n        Greater,\n    );\n    // - twice_exp - 1 > Float::MAX_EXPONENT\n    // - twice_exp - 1 > Float::MAX_EXPONENT && rm == Floor | Down\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    // - twice_exp - 1 > Float::MAX_EXPONENT && rm == Ceiling | Up | Nearest\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - exp > Float::MAX_EXPONENT\n    // - exp > Float::MAX_EXPONENT && rm == Floor | Down\n    test(\n        \"too_big\",\n        \"0xc.0E+134217727#2\",\n        Down,\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        Less,\n    );\n    // - exp > Float::MAX_EXPONENT && rm == Ceiling | Up | Nearest\n    test(\n        \"too_big\",\n        \"0xc.0E+134217727#2\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // - twice_exp < Float::MIN_EXPONENT - 1\n    // - twice_exp < Float::MIN_EXPONENT - 1 && rm == Floor | Down | Nearest\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - twice_exp < Float::MIN_EXPONENT - 1 && rm == Ceiling | Up\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    // - exp < Float::MIN_EXPONENT\n    // - exp < Float::MIN_EXPONENT no special\n    // - exp < Float::MIN_EXPONENT no special && rm == Floor | Down | Nearest\n    test(\n        \"too_small\",\n        \"0x8.0E-134217729#1\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    // - exp < Float::MIN_EXPONENT no special && rm == Ceiling | Up\n    test(\n        \"too_small\",\n        \"0x8.0E-134217729#1\",\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    // - exp < Float::MIN_EXPONENT special\n    test(\n        \"too_small\",\n        \"0xc.0E-134217729#2\",\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        Greater,\n    );\n}\n\n#[test]\nfn square_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(THREE.square_round(Exact));\n    assert_panic!(THREE.square_round_ref(Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.square_round_assign(Exact);\n    });\n}\n\n#[test]\nfn test_square_prec_round() {\n    let test = |s, s_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (square, o) = x.clone().square_prec_round(prec, rm);\n        assert!(square.is_valid());\n\n        assert_eq!(square.to_string(), out);\n        assert_eq!(to_hex_string(&square), out_hex);\n        assert_eq!(o, o_out);\n\n        let (square_alt, o_alt) = x.square_prec_round_ref(prec, rm);\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut square_alt = x.clone();\n        let o_alt = square_alt.square_prec_round_assign(prec, rm);\n        assert!(square_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&square), ComparableFloatRef(&square_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (square_alt, o_alt) = square_prec_round_naive(x.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_square, rug_o) = rug_square_prec_round(&rug::Float::exact_from(&x), prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_square)),\n                ComparableFloatRef(&square),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\"Infinity\", \"Infinity\", 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1.0\", \"0x1.0#1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Up,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        1,\n        Exact,\n        \"1.0\",\n        \"0x1.0#1\",\n        Equal,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Ceiling,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Up,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        10,\n        Exact,\n        \"1.0\",\n        \"0x1.000#10\",\n        Equal,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", 1, Floor, \"8.0e3\", \"0x2.0E+3#1\", Less);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Ceiling,\n        \"2.0e4\",\n        \"0x4.0E+3#1\",\n        Greater,\n    );\n    test(\"123.0\", \"0x7b.0#7\", 1, Down, \"8.0e3\", \"0x2.0E+3#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", 1, Up, \"2.0e4\", \"0x4.0E+3#1\", Greater);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        1,\n        Nearest,\n        \"2.0e4\",\n        \"0x4.0E+3#1\",\n        Greater,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Floor,\n        \"1.512e4\",\n        \"0x3.b1E+3#10\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Ceiling,\n        \"1.514e4\",\n        \"0x3.b2E+3#10\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Down,\n        \"1.512e4\",\n        \"0x3.b1E+3#10\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Up,\n        \"1.514e4\",\n        \"0x3.b2E+3#10\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        10,\n        Nearest,\n        \"1.514e4\",\n        \"0x3.b2E+3#10\",\n        Greater,\n    );\n\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Floor, \"8.0e3\", \"0x2.0E+3#1\", Less);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"2.0e4\",\n        \"0x4.0E+3#1\",\n        Greater,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Down, \"8.0e3\", \"0x2.0E+3#1\", Less);\n    test(\"-123.0\", \"-0x7b.0#7\", 1, Up, \"2.0e4\", \"0x4.0E+3#1\", Greater);\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"2.0e4\",\n        \"0x4.0E+3#1\",\n        Greater,\n    );\n\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Floor,\n        \"1.512e4\",\n        \"0x3.b1E+3#10\",\n        Less,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Ceiling,\n        \"1.514e4\",\n        \"0x3.b2E+3#10\",\n        Greater,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Down,\n        \"1.512e4\",\n        \"0x3.b1E+3#10\",\n        Less,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Up,\n        \"1.514e4\",\n        \"0x3.b2E+3#10\",\n        Greater,\n    );\n    test(\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        10,\n        Nearest,\n        \"1.514e4\",\n        \"0x3.b2E+3#10\",\n        Greater,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Floor,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Ceiling,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Down,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Up,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Ceiling,\n        \"2.004\",\n        \"0x2.01#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Up,\n        \"2.004\",\n        \"0x2.01#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Floor,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Ceiling,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Down,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Up,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Nearest,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Floor,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Ceiling,\n        \"2.004\",\n        \"0x2.01#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Down,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Up,\n        \"2.004\",\n        \"0x2.01#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        Nearest,\n        \"2.0\",\n        \"0x2.00#10\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"2.0e1\",\n        \"0x1.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"2.0e1\",\n        \"0x1.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"9.86\",\n        \"0x9.dc#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"9.86\",\n        \"0x9.dc#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Floor,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Ceiling,\n        \"2.0e1\",\n        \"0x1.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Down,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Up,\n        \"2.0e1\",\n        \"0x1.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Nearest,\n        \"8.0\",\n        \"0x8.0#1\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"9.86\",\n        \"0x9.dc#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"9.86\",\n        \"0x9.dc#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"9.88\",\n        \"0x9.e0#10\",\n        Greater,\n    );\n}\n\n#[test]\nfn square_prec_round_fail() {\n    const THREE: Float = Float::const_from_unsigned(3);\n    assert_panic!(Float::one_prec(1).square_prec_round(0, Floor));\n    assert_panic!(Float::one_prec(1).square_prec_round_ref(0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.square_prec_round_assign(0, Floor)\n    });\n\n    assert_panic!(THREE.square_prec_round(1, Exact));\n    assert_panic!(THREE.square_prec_round_ref(1, Exact));\n    assert_panic!({\n        let mut x = THREE;\n        x.square_prec_round_assign(1, Exact)\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn square_prec_round_properties_helper(x: Float, prec: u64, rm: RoundingMode, extreme: bool) {\n    let (square, o) = x.clone().square_prec_round(prec, rm);\n    assert!(square.is_valid());\n\n    let (square_alt, o_alt) = x.clone().square_prec_round_ref(prec, rm);\n    assert!(square_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.square_prec_round_assign(prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (square_alt, o_alt) = square_prec_round_naive(x.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_square, rug_o) = rug_square_prec_round(&rug::Float::exact_from(&x), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_square)),\n            ComparableFloatRef(&square),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if !x.is_nan() {\n        assert!(square.is_sign_positive());\n    }\n\n    if square.is_finite() {\n        if square.is_normal() {\n            assert_eq!(square.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_square = Rational::exact_from(&x).square();\n            assert_eq!(square.partial_cmp(&r_square), Some(o));\n            if o == Less {\n                let mut next = square.clone();\n                next.increment();\n                assert!(next > r_square);\n            } else if o == Greater {\n                let mut next = square.clone();\n                next.decrement();\n                assert!(next < r_square);\n            }\n            match (r_square >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (square_alt, o_alt) = (-&x).square_prec_round(prec, rm);\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        if square.is_finite() {\n            assert!(square.sqrt_prec_round_ref(prec, Exact).0.eq_abs(&x));\n        }\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.square_prec_round_ref(prec, rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(square.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.square_prec_round_ref(prec, Exact));\n    }\n}\n\n#[test]\nfn square_prec_round_properties() {\n    float_unsigned_rounding_mode_triple_gen_var_2().test_properties(|(x, prec, rm)| {\n        square_prec_round_properties_helper(x, prec, rm, false);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_11().test_properties(|(x, prec, rm)| {\n        square_prec_round_properties_helper(x, prec, rm, true);\n    });\n\n    unsigned_rounding_mode_pair_gen_var_3().test_properties(|(prec, rm)| {\n        let (product, o) = Float::NAN.square_prec_round(prec, rm);\n        assert!(product.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.square_prec_round(prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.square_prec_round(prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        let (s, o) = Float::ZERO.square_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (s, o) = Float::NEGATIVE_ZERO.square_prec_round(prec, rm);\n        assert_eq!(ComparableFloat(s), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::ONE.square_prec_round(prec, rm),\n            (Float::one_prec(prec), Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_ONE.square_prec_round(prec, rm),\n            (Float::one_prec(prec), Equal)\n        );\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn square_prec_properties_helper(x: Float, prec: u64, extreme: bool) {\n    let (square, o) = x.clone().square_prec(prec);\n    assert!(square.is_valid());\n\n    let (square_alt, o_alt) = x.square_prec_ref(prec);\n    assert!(square_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.square_prec_assign(prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (square_alt, o_alt) = square_prec_round_naive(x.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_square, rug_o) = rug_square_prec(&rug::Float::exact_from(&x), prec);\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_square)),\n        ComparableFloatRef(&square),\n    );\n    assert_eq!(rug_o, o);\n\n    let (square_alt, o_alt) = x.square_prec_round_ref(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    if !x.is_nan() {\n        assert!(square.is_sign_positive());\n    }\n\n    if square.is_finite() {\n        if square.is_normal() {\n            assert_eq!(square.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_square = Rational::exact_from(&x).square();\n            assert_eq!(square.partial_cmp(&r_square), Some(o));\n            if o == Less {\n                let mut next = square.clone();\n                next.increment();\n                assert!(next > r_square);\n            } else if o == Greater {\n                let mut next = square.clone();\n                next.decrement();\n                assert!(next < r_square);\n            }\n        }\n    }\n\n    let (square_alt, o_alt) = (-&x).square_prec(prec);\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    if o == Equal && square.is_finite() {\n        assert!(\n            square\n                .sqrt_prec_round(x.get_prec().unwrap_or(1), Exact)\n                .0\n                .eq_abs(&x)\n        );\n    }\n}\n\n#[test]\nfn square_prec_properties() {\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        square_prec_properties_helper(x, prec, false);\n    });\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_precision_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    float_unsigned_pair_gen_var_1().test_properties_with_config(&config, |(x, prec)| {\n        square_prec_properties_helper(x, prec, false);\n    });\n\n    float_unsigned_pair_gen_var_4().test_properties(|(x, prec)| {\n        square_prec_properties_helper(x, prec, true);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (square, o) = Float::NAN.square_prec(prec);\n        assert!(square.is_nan());\n        assert_eq!(o, Equal);\n\n        let (square, o) = Float::ZERO.square_prec(prec);\n        assert_eq!(ComparableFloat(square), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (square, o) = Float::NEGATIVE_ZERO.square_prec(prec);\n        assert_eq!(ComparableFloat(square), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::INFINITY.square_prec(prec), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.square_prec(prec),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(Float::ONE.square_prec(prec), (Float::one_prec(prec), Equal));\n        assert_eq!(\n            Float::NEGATIVE_ONE.square_prec(prec),\n            (Float::one_prec(prec), Equal)\n        );\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn square_round_properties_helper(x: Float, rm: RoundingMode, extreme: bool) {\n    let (square, o) = x.clone().square_round(rm);\n    assert!(square.is_valid());\n\n    let (square_alt, o_alt) = x.square_round_ref(rm);\n    assert!(square_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.square_round_assign(rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (square_alt, o_alt) = square_prec_round_naive(x.clone(), x.significant_bits(), rm);\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n        assert_eq!(o_alt, o);\n    }\n\n    let (square_alt, o_alt) = x.square_prec_round_ref(x.significant_bits(), rm);\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    assert_eq!(o_alt, o);\n\n    if !x.is_nan() {\n        assert!(square.is_sign_positive());\n    }\n\n    if square.is_finite() {\n        if x.is_normal() && square.is_normal() {\n            assert_eq!(square.get_prec(), Some(x.get_prec().unwrap()));\n        }\n        if !extreme {\n            let r_square = Rational::exact_from(&x).square();\n            assert_eq!(square.partial_cmp(&r_square), Some(o));\n            if o == Less {\n                let mut next = square.clone();\n                next.increment();\n                assert!(next > r_square);\n            } else if o == Greater {\n                let mut next = square.clone();\n                next.decrement();\n                assert!(next < r_square);\n            }\n            match (r_square >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_square, rug_o) = rug_square_round(&rug::Float::exact_from(&x), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_square)),\n            ComparableFloatRef(&square),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (square_alt, o_alt) = (-&x).square_round(rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n\n    if o == Equal {\n        if square.is_finite() {\n            assert!(square.sqrt_round_ref(Exact).0.eq_abs(&x));\n        }\n        for rm in exhaustive_rounding_modes() {\n            let (s, oo) = x.square_round_ref(rm);\n            assert_eq!(\n                ComparableFloat(s.abs_negative_zero_ref()),\n                ComparableFloat(square.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.square_round_ref(Exact));\n    }\n}\n\n#[test]\nfn square_round_properties() {\n    float_rounding_mode_pair_gen_var_7().test_properties(|(x, rm)| {\n        square_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_8().test_properties(|(x, rm)| {\n        square_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_9().test_properties(|(x, rm)| {\n        square_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_10().test_properties(|(x, rm)| {\n        square_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_11().test_properties(|(x, rm)| {\n        square_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_12().test_properties(|(x, rm)| {\n        square_round_properties_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_22().test_properties(|(x, rm)| {\n        square_round_properties_helper(x, rm, true);\n    });\n\n    rounding_mode_gen().test_properties(|rm| {\n        let (square, o) = Float::NAN.square_round(rm);\n        assert!(square.is_nan());\n        assert_eq!(o, Equal);\n\n        let (square, o) = Float::ZERO.square_round(rm);\n        assert_eq!(ComparableFloat(square), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        let (square, o) = Float::NEGATIVE_ZERO.square_round(rm);\n        assert_eq!(ComparableFloat(square), ComparableFloat(Float::ZERO));\n        assert_eq!(o, Equal);\n\n        assert_eq!(Float::INFINITY.square_round(rm), (Float::INFINITY, Equal));\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.square_round(rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(Float::ONE.square_round(rm), (Float::ONE, Equal));\n        assert_eq!(Float::NEGATIVE_ONE.square_round(rm), (Float::ONE, Equal));\n    });\n}\n\nfn square_properties_helper_1(x: Float, extreme: bool) {\n    let square = x.clone().square();\n    assert!(square.is_valid());\n\n    let square_alt = (&x).square();\n    assert!(square_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n\n    let mut x_alt = x.clone();\n    x_alt.square_assign();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&square));\n\n    if !extreme {\n        let square_alt = square_prec_round_naive(x.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    }\n\n    let square_alt = x.square_prec_round_ref(x.significant_bits(), Nearest).0;\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n    let square_alt = x.square_prec_ref(x.significant_bits()).0;\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n\n    let square_alt = x.square_round_ref(Nearest).0;\n    assert_eq!(ComparableFloatRef(&square_alt), ComparableFloatRef(&square));\n\n    if !x.is_nan() {\n        assert!(square.is_sign_positive());\n    }\n\n    if square.is_finite() && x.is_normal() && square.is_normal() {\n        assert_eq!(square.get_prec(), Some(x.get_prec().unwrap()));\n        if !extreme {\n            let r_square = Rational::exact_from(&x).square();\n            if square < r_square {\n                let mut next = square.clone();\n                next.increment();\n                assert!(next > r_square);\n            } else if square > r_square {\n                let mut next = square.clone();\n                next.decrement();\n                assert!(next < r_square);\n            }\n        }\n    }\n\n    let rug_square = rug_square(&rug::Float::exact_from(&x));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_square)),\n        ComparableFloatRef(&square),\n    );\n\n    assert_eq!(ComparableFloat((-x).square()), ComparableFloat(square));\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn square_properties_helper_2<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_gen::<T>().test_properties(|x| {\n        let square_1 = x.square();\n        let square_2 = emulate_float_to_float_fn(Float::square_prec, x);\n        assert_eq!(NiceFloat(square_1), NiceFloat(square_2));\n    });\n}\n\n#[test]\nfn square_properties() {\n    float_gen().test_properties(|x| {\n        square_properties_helper_1(x, false);\n    });\n\n    float_gen_var_6().test_properties(|x| {\n        square_properties_helper_1(x, false);\n    });\n\n    float_gen_var_7().test_properties(|x| {\n        square_properties_helper_1(x, false);\n    });\n\n    float_gen_var_8().test_properties(|x| {\n        square_properties_helper_1(x, false);\n    });\n\n    float_gen_var_9().test_properties(|x| {\n        square_properties_helper_1(x, false);\n    });\n\n    float_gen_var_10().test_properties(|x| {\n        square_properties_helper_1(x, false);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        square_properties_helper_1(x, true);\n    });\n\n    apply_fn_to_primitive_floats!(square_properties_helper_2);\n}\n"
  },
  {
    "path": "malachite-float/tests/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{NegAssign, PowerOf2};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, Zero,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::emulate_float_float_to_float_fn;\nuse malachite_float::test_util::arithmetic::add::add_prec_round_naive;\nuse malachite_float::test_util::arithmetic::sub::sub_rational_prec_round_naive;\nuse malachite_float::test_util::arithmetic::sub::{\n    rug_sub, rug_sub_prec, rug_sub_prec_round, rug_sub_rational, rug_sub_rational_prec,\n    rug_sub_rational_prec_round, rug_sub_rational_round, rug_sub_round,\n};\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_try_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_float_rounding_mode_triple_gen_var_2, float_float_rounding_mode_triple_gen_var_10,\n    float_float_rounding_mode_triple_gen_var_11, float_float_rounding_mode_triple_gen_var_12,\n    float_float_rounding_mode_triple_gen_var_13, float_float_rounding_mode_triple_gen_var_14,\n    float_float_rounding_mode_triple_gen_var_15, float_float_rounding_mode_triple_gen_var_30,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_float_unsigned_rounding_mode_quadruple_gen_var_6, float_float_unsigned_triple_gen_var_1,\n    float_float_unsigned_triple_gen_var_2, float_gen, float_pair_gen, float_pair_gen_var_2,\n    float_pair_gen_var_3, float_pair_gen_var_4, float_pair_gen_var_5, float_pair_gen_var_6,\n    float_pair_gen_var_7, float_pair_gen_var_10, float_rational_pair_gen,\n    float_rational_pair_gen_var_2, float_rational_rounding_mode_triple_gen_var_2,\n    float_rational_rounding_mode_triple_gen_var_8,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_2,\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_7,\n    float_rational_unsigned_triple_gen_var_1, float_rational_unsigned_triple_gen_var_2,\n    float_rounding_mode_pair_gen, float_unsigned_pair_gen_var_1,\n    float_unsigned_rounding_mode_triple_gen_var_1, rational_rounding_mode_pair_gen_var_6,\n    rational_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\nuse std::cmp::{\n    Ordering::{self, *},\n    max,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_sub() {\n    let test = |s, s_hex, t, t_hex, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let diff = x.clone() - y.clone();\n        assert!(diff.is_valid());\n\n        assert_eq!(diff.to_string(), out);\n        assert_eq!(to_hex_string(&diff), out_hex);\n\n        let diff_alt = x.clone() - &y;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n\n        let diff_alt = &x - y.clone();\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n\n        let diff_alt = &x - &y;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n\n        let mut diff_alt = x.clone();\n        diff_alt -= y.clone();\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        let mut diff_alt = x.clone();\n        diff_alt -= &y;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sub(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y)\n            ))),\n            ComparableFloatRef(&diff)\n        );\n\n        let diff_alt = add_prec_round_naive(\n            x.clone(),\n            -&y,\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\");\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", \"Infinity\", \"Infinity\",\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\",\n    );\n\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\");\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", \"123.0\", \"0x7b.0#7\");\n    test(\"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", \"123.0\", \"0x7b.0#7\");\n\n    test(\"NaN\", \"NaN\", \"-123.0\", \"-0x7b.0#7\", \"NaN\", \"NaN\");\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\"0.0\", \"0x0.0\", \"-123.0\", \"-0x7b.0#7\", \"123.0\", \"0x7b.0#7\");\n    test(\"-0.0\", \"-0x0.0\", \"-123.0\", \"-0x7b.0#7\", \"123.0\", \"0x7b.0#7\");\n\n    test(\"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", \"4.0\", \"0x4.0#1\");\n    test(\"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", \"3.0\", \"0x3.0#2\");\n    test(\"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", \"3.0\", \"0x3.0#2\");\n    test(\"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", \"3.0\", \"0x3.0#2\");\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        \"3.0\",\n        \"0x3.00#10\",\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-4.555806215962888\",\n        \"-0x4.8e4950f0795fc#53\",\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"-0.0002\", \"-0x0.001#1\", \"1.0\", \"0x1.0#1\");\n    // - in sub_float_significands_same_prec_lt_w\n    // - x_exp == y_exp in sub_float_significands_same_prec_lt_w\n    // - x == y in sub_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", \"0.0\", \"0x0.0\");\n    // - x_exp < y_exp in sub_float_significands_same_prec_lt_w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_lt_w\n    // - leading_zeros != 0 in sub_float_significands_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", \"-1.0\", \"-0x1.0#1\");\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_lt_w\n    // - neg in sub_float_significands_same_prec_lt_w\n    // - rm == Nearest in sub_float_significands_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & shift_bit) != 0) in\n    //   sub_float_significands_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && sticky_bit != 0 && diff == 0 in\n    //   sub_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"4.0\", \"0x4.0#1\", \"-4.0\", \"-0x4.0#1\");\n    // - !neg in sub_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#1\", \"0.2\", \"0x0.4#1\", \"1.0\", \"0x1.0#1\");\n    // - x < y in sub_float_significands_same_prec_lt_w\n    test(\"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\", \"-0.5\", \"-0x0.8#2\");\n    // - x > y in sub_float_significands_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", \"1.0\", \"0x1.0#2\", \"0.5\", \"0x0.8#2\");\n    // - leading_zeros == 0 in sub_float_significands_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", \"0.5\", \"0x0.8#2\", \"1.0\", \"0x1.0#2\");\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff & shift_bit) == 0)) in\n    //   sub_float_significands_same_prec_lt_w\n    test(\"2.0\", \"0x2.0#2\", \"0.8\", \"0x0.c#2\", \"1.0\", \"0x1.0#2\");\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & shift_bit) != 0) && diff !=\n    //   0 in sub_float_significands_same_prec_lt_w\n    test(\"1.5\", \"0x1.8#2\", \"0.1\", \"0x0.2#2\", \"1.5\", \"0x1.8#2\");\n    // - exp_diff >= Limb::WIDTH in sub_float_significands_same_prec_lt_w\n    // - x <= LIMB_HIGH_BIT in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        \"6.0e-11\",\n        \"0x4.0E-9#1\",\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n    );\n    // - x > LIMB_HIGH_BIT in sub_float_significands_same_prec_lt_w\n    test(\n        \"9.2047171e-27\",\n        \"0x2.d945d78E-22#27\",\n        \"1.43189635e33\",\n        \"0x4.69912aE+27#27\",\n        \"-1.43189635e33\",\n        \"-0x4.69912aE+27#27\",\n    );\n\n    // - in sub_float_significands_same_prec_w\n    // - x_exp == y_exp in sub_float_significands_same_prec_w\n    // - x_exp == y_exp && a0 == 0 in sub_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_w\n    // - x_exp < y_exp in sub_float_significands_same_prec_w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_w\n    // - a0 != 0 in sub_float_significands_same_prec_w\n    // - leading_zeros != 0 in sub_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        \"-1.0\",\n        \"-0x1.0000000000000000#64\",\n    );\n    // - a0 > x in sub_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"-1.084202172485504434e-19\",\n        \"-0x2.0000000000000000E-16#64\",\n    );\n    // - a0 <= x in sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.084202172485504434e-19\",\n        \"0x2.0000000000000000E-16#64\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_w\n    // - neg in sub_float_significands_same_prec_w\n    // - rm == Nearest in sub_float_significands_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & 1) != 0) in\n    //   sub_float_significands_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & 1) != 0) &&\n    //   !diff.overflowing_add_assign(1) in sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        \"-3.0\",\n        \"-0x3.0000000000000000#64\",\n    );\n    // - !neg in sub_float_significands_same_prec_w\n    test(\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"3.0\",\n        \"0x3.0000000000000000#64\",\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff & 1) == 0)) in\n    //   sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000003\",\n        \"0x1.0000000000000006#64\",\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        \"-2.9999999999999999996\",\n        \"-0x2.fffffffffffffff8#64\",\n    );\n    // - leading_zeros == 0 in sub_float_significands_same_prec_w\n    test(\n        \"3.2729513077064011786e-37\",\n        \"0x6.f5f6d50e7b8f6eb0E-31#64\",\n        \"7.8519772600462495573e-34\",\n        \"0x4.13b4f0d218450fb0E-28#64\",\n        \"-7.848704308738543156e-34\",\n        \"-0x4.13459164c75d56b8E-28#64\",\n    );\n    // - exp_diff >= Limb::WIDTH in sub_float_significands_same_prec_w\n    // - x > LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    test(\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n        \"2.9347251290514630352e-45\",\n        \"0x1.0c11b075f03d6daeE-37#64\",\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n    );\n    // - x <= LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    // - exp_diff != Limb::WIDTH || y <= LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & 1) != 0) &&\n    //   diff.overflowing_add_assign(1) in sub_float_significands_same_prec_w\n    test(\n        \"8355840.0624923708378\",\n        \"0x7f8000.0fff8000ff8#64\",\n        \"2.3384026197294446691e49\",\n        \"0x1.0000000000000000E+41#64\",\n        \"-2.3384026197294446691e49\",\n        \"-0x1.0000000000000000E+41#64\",\n    );\n    // - x_exp != y_exp && a0 == 0 in sub_float_significands_same_prec_w\n    test(\n        \"63.999999999999999997\",\n        \"0x3f.ffffffffffffffc#64\",\n        \"64.0\",\n        \"0x40.000000000000000#64\",\n        \"-3.4694469519536141888e-18\",\n        \"-0x4.0000000000000000E-15#64\",\n    );\n    // - exp_diff == Limb::WIDTH && y > LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    test(\n        \"4.656578456163629198e-10\",\n        \"0x1.ffff07fffffffffeE-8#64\",\n        \"4294967296.0\",\n        \"0x100000000.00000000#64\",\n        \"-4294967295.9999999995\",\n        \"-0xffffffff.fffffffe#64\",\n    );\n\n    // - in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp in sub_float_significands_same_prec_gt_w_lt_2w\n    // - a1 == 0 && a0 == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp < y_exp in sub_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp != y_exp && a1 != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp != y_exp && leading_zeros != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        \"-1.0\",\n        \"-0x1.0000000000000000#65\",\n    );\n    // - (a1 != 0 || a0 != 0) && a1 >= x_1 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp && a1 == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp && leading_zeros == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"-5.42101086242752217e-20\",\n        \"-0x1.0000000000000000E-16#65\",\n    );\n    // - (a1 != 0 || a0 != 0) && a1 < x_1 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"5.42101086242752217e-20\",\n        \"0x1.0000000000000000E-16#65\",\n    );\n    // - x_exp == y_exp && leading_zeros != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000#66\",\n        \"1.00000000000000000003\",\n        \"0x1.00000000000000008#66\",\n        \"-2.710505431213761085e-20\",\n        \"-0x8.0000000000000000E-17#66\",\n    );\n    // - x_exp == y_exp && a1 != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        \"-1.084202172485504434e-19\",\n        \"-0x2.0000000000000000E-16#65\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - neg in sub_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in sub_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   !overflow in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        \"-3.0\",\n        \"-0x3.0000000000000000#65\",\n    );\n    // - !neg in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"3.0\",\n        \"0x3.0000000000000000#65\",\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff_0 & shift_bit) == 0)) in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        \"-2.9999999999999999998\",\n        \"-0x2.fffffffffffffffc#65\",\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && a1 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        \"18.63123034252626794758647\",\n        \"0x12.a1984fcd64a8ae228eef#85\",\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n    );\n    // - x_exp != y_exp && leading_zeros == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"0.0001507756106295330606262754053\",\n        \"0x0.0009e19851127b95dcf03f0cdc#91\",\n        \"3458.565842843038054059107814\",\n        \"0xd82.90db1399862ba513faf8#91\",\n        \"-3458.565692067427424526047188\",\n        \"-0xd82.90d132013519297e1e08#91\",\n    );\n    // - exp_diff >= Limb::WIDTH * 2 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff >= Limb::WIDTH * 2 && a1 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n        \"1.14823551075108882469e-96\",\n        \"0x2.73dea72af3fe6314E-80#65\",\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n    );\n    // - exp_diff == Limb::WIDTH in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"19585.2851423168986928116147584507795\",\n        \"0x4c81.48ff163dc91a0d4bd90309b0f8#116\",\n        \"372369974082165972902790.766638151683\",\n        \"0x4eda377c7f0d747fa386.c44265dd58#116\",\n        \"-372369974082165972883205.481495834785\",\n        \"-0x4eda377c7f0d747f5705.7b434f9f90#116\",\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && a1 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   overflow in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"9.9035203142830421991929938e27\",\n        \"0x2.000000000000000000000E+23#85\",\n        \"16.0\",\n        \"0x10.00000000000000000000#85\",\n        \"9.9035203142830421991929938e27\",\n        \"0x2.000000000000000000000E+23#85\",\n    );\n    // - exp_diff >= Limb::WIDTH * 2 && a1 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"5.3455294200288159103345444e-51\",\n        \"0x1.ffffffffc000000000000E-42#83\",\n        \"8.0\",\n        \"0x8.00000000000000000000#83\",\n        \"-8.0\",\n        \"-0x8.00000000000000000000#83\",\n    );\n    // - x_exp != y_exp && a1 == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.00000000000000000000084702\",\n        \"0x4.000000000000000003fffc#89\",\n        \"3.999999999999999999999999994\",\n        \"0x3.fffffffffffffffffffffe#89\",\n        \"8.47026484905764768539612568e-22\",\n        \"0x3.fffe000000000000000000E-18#89\",\n    );\n\n    // - in sub_float_significands_same_prec_2w\n    // - x_exp == y_exp in sub_float_significands_same_prec_2w\n    // - a1 == 0 && a0 == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_2w\n    // - x_exp < y_exp in sub_float_significands_same_prec_2w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_2w\n    // - a1 != 0 second time in sub_float_significands_same_prec_2w\n    // - a1 != 0 third time in sub_float_significands_same_prec_2w\n    // - x_exp != y_exp && leading_zeros != 0 in sub_float_significands_same_prec_2w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        \"-1.0\",\n        \"-0x1.00000000000000000000000000000000#128\",\n    );\n    // - (a1 != 0 || a0 != 0) && a1 >= x_1 in sub_float_significands_same_prec_2w\n    // - a1 == 0 first time in sub_float_significands_same_prec_2w\n    // - x_exp == y_exp && leading_zeros != 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"-5.87747175411143753984368268611122838909e-39\",\n        \"-0x2.00000000000000000000000000000000E-32#128\",\n    );\n    // - (a1 != 0 || a0 != 0) && a1 < x_1 in sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"5.87747175411143753984368268611122838909e-39\",\n        \"0x2.00000000000000000000000000000000E-32#128\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_2w\n    // - neg in sub_float_significands_same_prec_2w\n    // - rm == Nearest in sub_float_significands_same_prec_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & 1) != 0) && !overflow in\n    //   sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        \"-3.0\",\n        \"-0x3.00000000000000000000000000000000#128\",\n    );\n    // - !neg in sub_float_significands_same_prec_2w\n    test(\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#128\",\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff_0 & 1) == 0)) in\n    //   sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000018\",\n        \"0x1.00000000000000000000000000000006#128\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        \"-2.99999999999999999999999999999999999998\",\n        \"-0x2.fffffffffffffffffffffffffffffff8#128\",\n    );\n    // - x_exp != y_exp && leading_zeros == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.91698663575347889601435178329077738407e-37\",\n        \"0x4.13b4f0d218450fb6f5f6d50e7b8f6eb0E-31#128\",\n        \"8.0669110092962644724944820639408319804e-34\",\n        \"0x4.3046c1d7c0f5b6be39df2b03f3e49a70E-28#128\",\n        \"-8.06499402266051099359846771215754120301e-34\",\n        \"-0x4.30058688b3d4326d3e6fcb96a2fce178E-28#128\",\n    );\n    // - exp_diff >= Limb::WIDTH * 2 in sub_float_significands_same_prec_2w\n    // - x_1 > LIMB_HIGH_BIT || x_0 > 0 in sub_float_significands_same_prec_2w\n    test(\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n        \"5.07801249136957145270807726205511855421e-45\",\n        \"0x1.cfd8608b7c32de2bbcfecf8bcf8a2d00E-37#128\",\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_2w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_2w\n    // - a1 >= LIMB_HIGH_BIT in sub_float_significands_same_prec_2w\n    test(\n        \"4354249796990942.35435357526597783143164\",\n        \"0xf782ac869b7de.5ab6ea78fcf0cc5079f#128\",\n        \"8.03239453825726512240307053405256016022e-10\",\n        \"0x3.732bce7aa121827a284545a25f32dc68E-8#128\",\n        \"4354249796990942.35435357446273837760591\",\n        \"0xf782ac869b7de.5ab6ea7589c4fdd5d8d#128\",\n    );\n    // - a1 != 0 first time in sub_float_significands_same_prec_2w\n    test(\n        \"852777855057.113455599443829872557360137\",\n        \"0xc68d856851.1d0b6d1928c98779f28bdd#128\",\n        \"869223500084.503694559376384046083491558\",\n        \"0xca61c20934.80f2206bb1d7d5cad69caa#128\",\n        \"-16445645027.39023895993255417352613142066\",\n        \"-0x3d43ca0e3.63e6b352890e4e50e410cd00#128\",\n    );\n    // - exp_diff == Limb::WIDTH in sub_float_significands_same_prec_2w\n    test(\n        \"1.057437459917463716438672572710788562701e-17\",\n        \"0xc.310127aae1df1a1cb12f60c4d339d76E-15#128\",\n        \"148.0549133677002965445211858794413066474\",\n        \"0x94.0e0ecd6e62d0a8c7c7c2a633277e3e#128\",\n        \"-148.054913367700296533946811280266669483\",\n        \"-0x94.0e0ecd6e62d0a804b7b02b85098c9c#128\",\n    );\n    // - x_1 <= LIMB_HIGH_BIT && x_0 <= 0 in sub_float_significands_same_prec_2w\n    // - exp_diff != TWICE_WIDTH || tst in sub_float_significands_same_prec_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & 1) != 0) && overflow in\n    //   sub_float_significands_same_prec_2w\n    test(\n        \"3.83123885216472214589586756787577295905e53\",\n        \"0x4.00000000000000000000000000000000E+44#128\",\n        \"9.09494703466994132423639742106012939545e-13\",\n        \"0x1.00000008000000000000007fffffff80E-10#128\",\n        \"3.83123885216472214589586756787577295905e53\",\n        \"0x4.00000000000000000000000000000000E+44#128\",\n    );\n    // - a1 < LIMB_HIGH_BIT in sub_float_significands_same_prec_2w\n    test(\n        \"0.000473141670219947088192358501321236008969\",\n        \"0x0.001f01fffffe001ffe000000000003ffff0#128\",\n        \"144115188075855872.000000000007275846592\",\n        \"0x200000000000000.0000000007fff80000#128\",\n        \"-144115188075855871.9995268583370558995037\",\n        \"-0x1ffffffffffffff.ffe0fe000801f7e002#128\",\n    );\n    // - a1 == 0 second  time in sub_float_significands_same_prec_2w\n    test(\n        \"1.192092895507812500000000000000000918348e-7\",\n        \"0x2.0000000000000000000000000007fffcE-6#128\",\n        \"1.19209289550781249999999999999999632658e-7\",\n        \"0x1.ffffffffffffffffffffffffffe00000E-6#128\",\n        \"4.5917678014072389539175224798764807294e-40\",\n        \"0x2.7fffc000000000000000000000000000E-33#128\",\n    );\n    // - exp_diff == TWICE_WIDTH && !tst in sub_float_significands_same_prec_2w\n    test(\n        \"1024.0\",\n        \"0x400.000000000000000000000000000000#128\",\n        \"5.97151130219911582898625687582100437209e-36\",\n        \"0x7.f00000001fffffffffffffffe0000000E-30#128\",\n        \"1023.999999999999999999999999999999999994\",\n        \"0x3ff.fffffffffffffffffffffffffffff8#128\",\n    );\n    // - x_exp == y_exp && leading_zeros == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"0.249999999999999999999999999974756451033\",\n        \"0x0.3ffffffffffffffffffffffe000000000#128\",\n        \"0.2499999999999999999864474728691747435412\",\n        \"0x0.3fffffffffffffffc0000001ffffffffc#128\",\n        \"1.35525271055817074916830884337875729072e-20\",\n        \"0x3.ffffffc0000000040000000000000000E-17#128\",\n    );\n    // - a1 == 0 third time in sub_float_significands_same_prec_2w\n    test(\n        \"8.0\",\n        \"0x8.0000000000000000000000000000000#128\",\n        \"7.99999999999999999999999999999999999998\",\n        \"0x7.fffffffffffffffffffffffffffffff8#128\",\n        \"2.35098870164457501593747307444449135564e-38\",\n        \"0x8.0000000000000000000000000000000E-32#128\",\n    );\n\n    // - in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - a2 == 0 && a1 == 0 && a0 == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && sticky_bit == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && a2 != 0 first time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && leading_zeros != 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        \"-1.0\",\n        \"-0x1.00000000000000000000000000000000#129\",\n    );\n    // - x_exp >= y_exp in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n    );\n    // - (a2 != 0 || a1 != 0 || a0 != 0) && a2 >= x_2 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp && a2 == 0 first time in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp && a2 == 0 second time in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp && leading_zeros == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"-2.93873587705571876992184134305561419455e-39\",\n        \"-0x1.00000000000000000000000000000000E-32#129\",\n    );\n    // - (a2 != 0 || a1 != 0 || a0 != 0) && a2 < x_2 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"2.93873587705571876992184134305561419455e-39\",\n        \"0x1.00000000000000000000000000000000E-32#129\",\n    );\n    // - x_exp == y_exp && leading_zeros != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000#130\",\n        \"1.000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000008#130\",\n        \"-1.469367938527859384960920671527807097273e-39\",\n        \"-0x8.00000000000000000000000000000000E-33#130\",\n    );\n    // - x_exp == y_exp && a2 != 0 second time in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n        \"-5.87747175411143753984368268611122838909e-39\",\n        \"-0x2.00000000000000000000000000000000E-32#129\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - neg in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   overflow in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) && diff_1\n    //   == 0 && diff_0 == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && diff_2 != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        \"-3.0\",\n        \"-0x3.00000000000000000000000000000000#129\",\n    );\n    // - !neg in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#129\",\n    );\n    // - rm == Nearest && round_bit == 0 || (sticky_bit == 0 && (diff_0 & shift_bit) == 0) in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        \"-2.999999999999999999999999999999999999988\",\n        \"-0x2.fffffffffffffffffffffffffffffffc#129\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   (diff_1 != 0 || diff_0 != 0) in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.000000000000000000000000000000000000006\",\n        \"0x2.00000000000000000000000000000002#129\",\n        \"0.500000000000000000000000000000000000001\",\n        \"0x0.800000000000000000000000000000008#129\",\n        \"1.500000000000000000000000000000000000006\",\n        \"0x1.80000000000000000000000000000002#129\",\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   !overflow in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.000000000000000000000000000000000000003\",\n        \"0x2.00000000000000000000000000000001#130\",\n        \"0.5000000000000000000000000000000000000007\",\n        \"0x0.800000000000000000000000000000004#130\",\n        \"1.500000000000000000000000000000000000003\",\n        \"0x1.800000000000000000000000000000010#130\",\n    );\n    // - TWICE_WIDTH <= exp_diff < THRICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - TWICE_WIDTH < exp_diff < THRICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - TWICE_WIDTH <= exp_diff < THRICE_WIDTH && a2 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        \"-245906107849378561117126906.9059035528266331265\",\n        \"-0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n    );\n    // - exp_diff >= THRICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff >= THRICE_WIDTH && a2 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n        \"6.8892360159362421595728818935378487832685754059e-50\",\n        \"0x1.9c693c182df3035eef00d41638bbdd942f4d498E-41#155\",\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n    );\n    // - exp_diff < Limb::WIDTH && leading_zeros == 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.9709672065181108960570410290811793724062284431352e-48\",\n        \"0x7.43dc113e95ca123693650af31435eac45c0e7a680E-40#165\",\n        \"5.2183974782595301717751266872943662193587933931613e-47\",\n        \"0x4.c4457ca8b3429511981a96eb0c2de4fdb8c43bea4E-39#165\",\n        \"-4.7213007576077190821694225843862482821181705488478e-47\",\n        \"-0x4.5007bb94c9e5f3ee2ee4463bdaea865173035443cE-39#165\",\n    );\n    // - exp_diff < Limb::WIDTH && sticky_bit != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"8.264811372870109665580646414654919646529224699888394e-20\",\n        \"0x1.864b7049feb3dcfe49ea910db778157cbe9c2021b44E-16#171\",\n        \"0.0007337187065343299500100945131574173571435306249470578\",\n        \"0x0.003015c1d959ec54ab97dc58b77c22566586c06119b810#171\",\n        \"-0.0007337187065343298673619807844563207013370664783978612\",\n        \"-0x0.003015c1d959ec53254c6c0eb8c845581b9c2f53623ff8#171\",\n    );\n    // - Limb::WIDTH <= exp_diff < TWICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && sticky_bit != 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && a2 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.2850537238606374652351877988811796373898773e-22\",\n        \"0x2.0607fd4819748c532aad3528693c1e3c1966E-18#146\",\n        \"978.49328809934495391839880801989439981236569\",\n        \"0x3d2.7e4820fe314caadcb9a156bef2f1c8e53c#146\",\n        \"-978.49328809934495391839837951452201374861917\",\n        \"-0x3d2.7e4820fe314caadcb79b4ec1aad85458e9#146\",\n    );\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && sticky_bit == 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"0.4575080253178526499352273198671695352442\",\n        \"0x0.751f3ef665d0ca4dfa2d089979c4e9600#130\",\n        \"184366716174337778394.1535133791267987587\",\n        \"0x9fe9a278b38ab22da.274ca71ed919c918#130\",\n        \"-184366716174337778393.6960053538089461089\",\n        \"-0x9fe9a278b38ab22d9.b22d68287348fecc#130\",\n    );\n    // - x_exp == y_exp && a2 != 0 first time in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"229.1456159244630209666077998586332154002628588961962846344\",\n        \"0xe5.254715d158717849f7198986a38cb415eeea3464b1df38#189\",\n        \"175.1335582002789888688278442018847623084238889142385801004\",\n        \"0xaf.2230dec64f958583522e37252cf610378914f3127d0bb0#189\",\n        \"54.01205772418403209777995565674845309183896998195770453405\",\n        \"0x36.0316370b08dbf2c6a4eb52617696a3de65d5415234d388#189\",\n    );\n    // - exp_diff == TWICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"563971925627753843356041629019151473018178607215.42\",\n        \"0x62c960337e963a378ba6626ea422d8a5e623986f.6c#165\",\n        \"1301375421.83361702516620516356439489325145225661938\",\n        \"0x4d9169bd.d567ece47a47ef60371d48c969ba8765d4#165\",\n        \"563971925627753843356041629019151473016877231793.59\",\n        \"0x62c960337e963a378ba6626ea422d8a598922eb1.98#165\",\n    );\n    // - exp_diff == Limb::WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"226.9305090753243797994707628568605406194\",\n        \"0xe2.ee35d7bf263fda8c632644ad7c49d98#130\",\n        \"4262448175090788889452.984188256984861391\",\n        \"0xe71159efd3a67e736c.fbf3c2f8db72fb8#130\",\n        \"-4262448175090788889226.053679181660481592\",\n        \"-0xe71159efd3a67e728a.0dbdeb39b533210#130\",\n    );\n    // - TWICE_WIDTH <= exp_diff < THRICE_WIDTH && a2 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && diff_2 == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"0.0001220703125\",\n        \"0x0.0008000000000000000000000000000000000000#145\",\n        \"8.2855746158774225568154012162196749515653053e-50\",\n        \"0x1.f0000fc000000000000003fffffffffffffcE-41#145\",\n        \"0.0001220703125\",\n        \"0x0.0008000000000000000000000000000000000000#145\",\n    );\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && a2 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"0.0156250000000000000000000000252435487789932816416198\",\n        \"0x0.040000000000000000000001ffffffc00000000003f#167\",\n        \"2.11758236813575084767080625169910490512847748461541e-22\",\n        \"0xf.ffffffffffffffffffffffffffffffffff0000000E-19#167\",\n        \"0.0156249999999999999997882417884299736942262010164499\",\n        \"0x0.03ffffffffffffffff000001ffffffc00000000003f0#167\",\n    );\n    // - exp_diff >= THRICE_WIDTH && a2 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.028440348325753776346855739098344065614209916020987e62\",\n        \"0x4.000000000000000000000000000000000000000000E+51#168\",\n        \"0.00781238079073842683897073489057921223679527623088422\",\n        \"0x0.01fffe000007e000000038000007fffffffffe000000#168\",\n        \"1.028440348325753776346855739098344065614209916020987e62\",\n        \"0x4.000000000000000000000000000000000000000000E+51#168\",\n    );\n    // - exp_diff < Limb::WIDTH && a2 == 0 first time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && a2 != 0 second time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"32767.9999999999999999999999999999999999999999996\",\n        \"0x7fff.fffffffffffffffffffffffffffffffffff8#156\",\n        \"32768.0000000000000000069388939039072268369037424\",\n        \"0x8000.000000000000007ffffffffffff80000000#156\",\n        \"-6.93889390390722683690374277451135137549581608853e-18\",\n        \"-0x7.ffffffffffff800000008000000000000000000E-15#156\",\n    );\n    // - exp_diff < Limb::WIDTH && a2 == 0 second time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"137438953471.99999999999999999999999999999\",\n        \"0x1fffffffff.ffffffffffffffffffffffff#133\",\n        \"137438953472.0\",\n        \"0x2000000000.000000000000000000000000#133\",\n        \"-1.2621774483536188886587657044524579674771e-29\",\n        \"-0x1.000000000000000000000000000000000E-24#133\",\n    );\n\n    // - in sub_float_significands_same_prec_ge_3w\n    // - x_exp == y_exp in sub_float_significands_same_prec_ge_3w\n    // - k < 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    // - x_exp > y_exp in sub_float_significands_same_prec_ge_3w\n    // - exp_diff == 1 in sub_float_significands_same_prec_ge_3w\n    // - !goto_sub_d1_no_lose && !goto_sub_d1_lose in sub_float_significands_same_prec_ge_3w\n    // - limb < LIMB_HIGH_BIT in sub_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 in sub_float_significands_same_prec_ge_3w\n    // - goto_exact_normalize in sub_float_significands_same_prec_ge_3w\n    // - limb != 0 in sub_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && limb != 0 && leading_zeros == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n    );\n    // - k >= 0 && xs[k] < ys[k] in sub_float_significands_same_prec_ge_3w\n    // - !goto_exact_normalize in sub_float_significands_same_prec_ge_3w\n    // - limb == 0 in sub_float_significands_same_prec_ge_3w\n    // - out[usize::exact_from(k)] != 0 in sub_float_significands_same_prec_ge_3w\n    // - limb == 0 && leading_zeros != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"-3.186183822264904554057760795535423611182209110385237572148e-58\",\n        \"-0x2.000000000000000000000000000000000000000000000000E-48#192\",\n    );\n    // - k >= 0 && xs[k] >= ys[k] in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"3.186183822264904554057760795535423611182209110385237572148e-58\",\n        \"0x2.000000000000000000000000000000000000000000000000E-48#192\",\n    );\n    // - exp_diff == 0 && limb != 0 && leading_zeros != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"0.9999999999999999999999999999999999999999999999999999999997\",\n        \"0x0.fffffffffffffffffffffffffffffffffffffffffffffffe#192\",\n    );\n    // - 2 <= exp_diff < prec in sub_float_significands_same_prec_ge_3w\n    // - dm != 0 && m == 0 in sub_float_significands_same_prec_ge_3w\n    // - sx != 0 in sub_float_significands_same_prec_ge_3w\n    // - !out[n - 1].get_highest_bit() in sub_float_significands_same_prec_ge_3w\n    // - round_bit == 0 in sub_float_significands_same_prec_ge_3w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"0.5\",\n        \"0x0.800000000000000000000000000000000000000000000000#192\",\n        \"1.5\",\n        \"0x1.800000000000000000000000000000000000000000000000#192\",\n    );\n    // - limb == 0 && leading_zeros == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#193\",\n        \"1.0000000000000000000000000000000000000000000000000000000002\",\n        \"0x1.000000000000000000000000000000000000000000000001#193\",\n        \"-1.5930919111324522770288803977677118055911045551926187860739e-58\",\n        \"-0x1.000000000000000000000000000000000000000000000000E-48#193\",\n    );\n    // - sx == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#193\",\n        \"0.5\",\n        \"0x0.8000000000000000000000000000000000000000000000000#193\",\n        \"1.5\",\n        \"0x1.800000000000000000000000000000000000000000000000#193\",\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_ge_3w\n    // - out_power_of_2 || round_bit == 0 in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest && !out_power_of_2 first time in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest && (round_bit == 0 || (round_bit != 0 && sticky_bit == 0 && (out[0] &\n    //   shift_bit == 0 || prec == 1))) in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        \"-3.0\",\n        \"-0x3.000000000000000000000000000000000000000000000000#192\",\n    );\n    // - out[usize::exact_from(k)] == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000002\",\n        \"0x1.000000000000000000000000000000000000000000000001#193\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#193\",\n        \"-1.5930919111324522770288803977677118055911045551926187860739e-58\",\n        \"-0x1.000000000000000000000000000000000000000000000000E-48#193\",\n    );\n    // - round_bit != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000006\",\n        \"0x1.000000000000000000000000000000000000000000000004#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        \"-2.9999999999999999999999999999999999999999999999999999999994\",\n        \"-0x2.fffffffffffffffffffffffffffffffffffffffffffffffc#192\",\n    );\n    // - rm == Nearest && round_bit != 0 && (round_bit == 0 || sticky_bit != 0 || (out[0] &\n    //   shift_bit != 0 && prec == 1)) in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest && !out_power_of_2 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.000000000000000000000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000000000000000000006#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        \"-2.9999999999999999999999999999999999999999999999999999999987\",\n        \"-0x2.fffffffffffffffffffffffffffffffffffffffffffffff8#192\",\n    );\n    // - sticky_bit_2 == 0 && k > 0 third time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"0.5\",\n        \"0x0.8000000000000000000000000000000000000000000000000#193\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#193\",\n        \"-3.5\",\n        \"-0x3.800000000000000000000000000000000000000000000000#193\",\n    );\n    // - sticky_bit_2 != 0 || k <= 0 third time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        \"0.5000000000000000000000000000000000000000000000000000000002\",\n        \"0x0.800000000000000000000000000000000000000000000001#192\",\n        \"3.5\",\n        \"0x3.800000000000000000000000000000000000000000000000#192\",\n    );\n    // - dm != 0 && m != 0 in sub_float_significands_same_prec_ge_3w\n    // - out[n - 1].get_highest_bit() in sub_float_significands_same_prec_ge_3w\n    test(\n        \"7.28057116938384227432903448367767196428679514765398378973101e-48\",\n        \"0xa.a3fc2da1f20fb2d9771f86d3c16a444cd62d5d139e3935f24E-40#198\",\n        \"3.5123473778825578958968695187657587760357139395948269588971e-27\",\n        \"0x1.1646de419a6dbd3466f3081403a87d719b7a765a1ec69e4658E-22#198\",\n        \"-3.51234737788255789588958894759637493376138490511114928693281e-27\",\n        \"-0x1.1646de419a6dbd345c4f0be661b66dbec20356d34b05340208E-22#198\",\n    );\n    // - exp_diff >= prec in sub_float_significands_same_prec_ge_3w\n    // - exp_diff > prec in sub_float_significands_same_prec_ge_3w\n    // - exp_diff != prec + 1 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n        \"0.023991386767031193042066748710708351501952890752924613005724\",\n        \"0x0.06244cad8cd272134e34b325815ad281733f2c06231a0ee744#193\",\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n    );\n    // - dm == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"6.442552350746554109885349691592991892989624685631192235549e-6\",\n        \"0x0.00006c168d38e231899f0fc85d1888549d5177bdceaee72e15060#192\",\n        \"1476808010161862576835936576709144.7975622615653024045505082\",\n        \"0x48cff00a780a50d34bb694ada218.cc2d0a55f25f9f9126258#192\",\n        \"-1476808010161862576835936576709144.7975558190129516579963983\",\n        \"-0x48cff00a780a50d34bb694ada218.cc2c9e3f6526bd5f9c868#192\",\n    );\n    // - exp_diff == prec + 1 in sub_float_significands_same_prec_ge_3w\n    // - sticky_bit_2 != 0 || k <= 0 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"29249291732025621624535078208.59212499364958152526111994335\",\n        \"0x5e827271f9e9d261e7cb5540.979580eade814aae28ae9d3c8#192\",\n        \"1.7056859397843570965021420438616279890690624515282312011749e-30\",\n        \"0x2.2986d80d04731f28b49380410e3f4711dc2cc5f113c594a0E-25#192\",\n        \"29249291732025621624535078208.59212499364958152526111994335\",\n        \"0x5e827271f9e9d261e7cb5540.979580eade814aae28ae9d3c8#192\",\n    );\n    // - limb > LIMB_HIGH_BIT in sub_float_significands_same_prec_ge_3w\n    // - y0 != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1958139908729.1847354007541959640287427302874567071533816044\",\n        \"0x1c7ea3bd279.2f4ad1b8a7190307771c7e5767590237208b90#192\",\n        \"688604646855.2266320591592881661509057171162297144871538944\",\n        \"0xa054090dc7.3a048f025074a63da83a500a235d2b8fd9766d#192\",\n        \"1269535261873.9581033415949077978778370131712269926662277102\",\n        \"0x1279632c4b1.f54642b656a45cc9cee22e4d43fbd6a7471524#192\",\n    );\n    // - y0 == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2473299914875391681216.10395653853096422269749051583697615\",\n        \"0x8613ee70797f97a2c0.1a9ce54d32239153edab6ff15dad1c0#193\",\n        \"7716446651886500012256.87778108230244207876352217543002925\",\n        \"0x1a24f3592677b2760e0.e0b642d189564d3b4c797ad9c9cde8#193\",\n        \"-5243146737011108331040.7738245437714778560660316595930531\",\n        \"-0x11c3b4721edfb8fbe20.c6195d845732bbe75ece0ae86c20cc#193\",\n    );\n    // - exp_diff == prec in sub_float_significands_same_prec_ge_3w\n    // - sticky_bit_2 != 0 || k <= 0 first time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"4.0635838402455207229400698207668893925379768151364313942222e-23\",\n        \"0x3.1202ecf10ff40b477337957dede18bd7b746884ec977474eE-19#194\",\n        \"1174582238252884689829665592721065057.76655867827770290150723\",\n        \"0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d4#194\",\n        \"-1174582238252884689829665592721065057.76655867827770290150718\",\n        \"-0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d0#194\",\n    );\n    // - rm == Nearest && out_power_of_2 first time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"22300745198530623141535718272648361505980416.0\",\n        \"0x1000000000000000000000000000000000000.000000000000#192\",\n        \"8.470329472543003387009805160583577341645369940072346001613e-22\",\n        \"0x3.ffffffffffffffe000000003ff0000003ffffffc00000000E-18#192\",\n        \"22300745198530623141535718272648361505980416.0\",\n        \"0x1000000000000000000000000000000000000.000000000000#192\",\n    );\n    // - sticky_bit_2 == 0 && k > 0 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.6849966666969146159452711670928107852024276704905067469395e66\",\n        \"0xf.ffffffffffff01fffff00000000000000000000000000000E+54#193\",\n        \"33554432.00000000000000044408920985006261616945266723632812\",\n        \"0x2000000.0000000000001ffffffffffffffffffffffffffffe#193\",\n        \"1.6849966666969146159452711670928107852024276704905067469395e66\",\n        \"0xf.ffffffffffff01fffff00000000000000000000000000000E+54#193\",\n    );\n    // - limb == LIMB_HIGH_BIT in sub_float_significands_same_prec_ge_3w\n    // - l >= 0 first time in sub_float_significands_same_prec_ge_3w\n    // - xs[l] != yl_shifted in sub_float_significands_same_prec_ge_3w\n    // - l >= 0 && xs[l] <= yl_shifted in sub_float_significands_same_prec_ge_3w\n    // - goto_sub_d1_no_lose || goto_sub_d1_lose in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2047.9999999999999999999999999999747564510329303127198868805\",\n        \"0x7ff.fffffffffffffffffffffffe00000000003c000003fffc#193\",\n        \"4095.99999999999999988897769753748434595763683319091796875\",\n        \"0xfff.fffffffffffff800000000000000000000000000000000#193\",\n        \"-2047.9999999999999998889776975375095895066039028781980818695\",\n        \"-0x7ff.fffffffffffff80000000001ffffffffffc3fffffc0004#193\",\n    );\n    // - sticky_bit_2 == 0 && k > 0 first time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"0.0002442598197376355528831482438462803411504065058668775410457\",\n        \"0x0.001001fff000000000000003ffff00000001fffffff07fffffe#192\",\n        \"5.834076822994820350447560050418866475553361427251759468222e-62\",\n        \"0x1.8000000000000000000000000000000000001c00007ffffeE-51#192\",\n        \"0.00024425981973763555288314824384628034115040650586687754104564\",\n        \"0x0.001001fff000000000000003ffff00000001fffffff07fffffc#192\",\n    );\n    // - l >= 0 && xs[l] > yl_shifted in sub_float_significands_same_prec_ge_3w\n    test(\n        \"127.99999999999999999999998841947063540272586186468301133273\",\n        \"0x7f.fffffffffffffffffff1fffff00007ffffffffffffffff8#192\",\n        \"255.99999999999999999999999979320484686174308128214782699291\",\n        \"0xff.ffffffffffffffffffffc00000000000000000000000ff#192\",\n        \"-128.0000000000000000000000113737342114590172194174648156602\",\n        \"-0x80.0000000000000000000dc0000ffff80000000000000100#192\",\n    );\n    // - out_power_of_2 && round_bit != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"81129638414606681695789005144064.0\",\n        \"0x400000000000000000000000000.0000000000000000000000#193\",\n        \"6.46392625738094777466974989455420015132331189664152496326e-27\",\n        \"0x2.001ffffffffe0000001fffff000000ffffff80000000000eE-22#193\",\n        \"81129638414606681695789005144063.999999999999999999999999994\",\n        \"0x3ffffffffffffffffffffffffff.fffffffffffffffffffffe#193\",\n    );\n    // - rm == Nearest && out_power_of_2 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"9.5367431640625e-7\",\n        \"0x0.00001000000000000000000000000000000000000000000000000#192\",\n        \"7.596455102175746880546879414772134233793171691679642324806e-65\",\n        \"0x8.00000ffffffffffe000000000000000000000000001ffffE-54#192\",\n        \"9.536743164062499999999999999999999999999999999999999999998e-7\",\n        \"0xf.fffffffffffffffffffffffffffffffffffffffffffffffE-6#192\",\n    );\n    // - xs[l] == yl_shifted in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1180591620717411303423.9999999999999999999999999999999999998\",\n        \"0x3fffffffffffffffff.ffffffffffffffffffffffffffffffc#192\",\n        \"2361183241434822606847.9999999999999999930619531290400259223\",\n        \"0x7fffffffffffffffff.ffffffffffffff8003ffffffffffff8#192\",\n        \"-1180591620717411303423.9999999999999999930619531290400259225\",\n        \"-0x3fffffffffffffffff.ffffffffffffff8003ffffffffffffc#192\",\n    );\n    // - l < 0 first time in sub_float_significands_same_prec_ge_3w\n    // - l < 0 second time in sub_float_significands_same_prec_ge_3w\n    // - yl_shifted != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"32767.999999999999999999999999999999999999999999999999999995\",\n        \"0x7fff.ffffffffffffffffffffffffffffffffffffffffffff8#192\",\n        \"65535.99999999999999999999999999999999999999999999999999999\",\n        \"0xffff.ffffffffffffffffffffffffffffffffffffffffffff#192\",\n        \"-32767.999999999999999999999999999999999999999999999999999995\",\n        \"-0x7fff.ffffffffffffffffffffffffffffffffffffffffffff8#192\",\n    );\n    // - yl_shifted == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"34359738367.999999999999999999999999999999999999999999999989\",\n        \"0x7ffffffff.fffffffffffffffffffffffffffffffffffffff0#192\",\n        \"68719476735.99999999999999999999999999999999999999999999999\",\n        \"0xfffffffff.fffffffffffffffffffffffffffffffffffffff#192\",\n        \"-34359738368.0\",\n        \"-0x800000000.000000000000000000000000000000000000000#192\",\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", \"-0.5\", \"-0x0.8#2\");\n    test(\"0.5\", \"0x0.8#1\", \"3.0\", \"0x3.0#2\", \"-2.0\", \"-0x2.0#2\");\n    test(\"0.2\", \"0x0.4#1\", \"4.0\", \"0x4.0#2\", \"-4.0\", \"-0x4.0#2\");\n    test(\n        \"0.00374222828352849\",\n        \"0x0.00f5402c178824#46\",\n        \"1.07183972513958531257713938927815e-11\",\n        \"0xb.c8f5eafa12eb9821601f1dd6aeE-10#107\",\n        \"0.00374222827281009532032311766811006\",\n        \"0x0.00f5402c0bbf2e1505ed1467de9fe#107\",\n    );\n    test(\n        \"2589062031404.0\",\n        \"0x25ad01f682c.0#43\",\n        \"4351572166934988.581719655389852344796925751245753159273257621838622031922945531041952618\\\n        810238932316\",\n        \"0xf75bb593981cc.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n        \"-4348983104903584.58171965538985234479692575124575315927325762183862203192294553104195261\\\n        8810238932316\",\n        \"-0xf7360891a19a0.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n    );\n\n    // - in sub_float_significands_general\n    // - in exponent_shift_compare\n    // - sdiff_exp >= 0 in exponent_shift_compare\n    // - diff_exp == 0 first time in exponent_shift_compare\n    // - xi >= 0 && yi >= 0 && xs[xi] == ys[yi] in exponent_shift_compare\n    // - xi < 0 in exponent_shift_compare\n    // - xi < 0 && yi < 0 in exponent_shift_compare\n    // - sign == Equal in sub_float_significands_general\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", \"0.0\", \"0x0.0\");\n    // - diff_exp != 0 first time in exponent_shift_compare\n    // - diff_exp < Limb::WIDTH in exponent_shift_compare\n    // - diff_exp != 0 second time in exponent_shift_compare\n    // - (yi < 0 && lasty == 0) || high_dif != 0 || dif != 1 in exponent_shift_compare\n    // - high_dif == 0 in exponent_shift_compare\n    // - dif.is_power_of_2() in exponent_shift_compare\n    // - yi < 0 && lasty == 0 in exponent_shift_compare\n    // - sign != Equal in sub_float_significands_general\n    // - sign != Less in sub_float_significands_general\n    // - !neg in sub_float_significands_general\n    // - max(out_prec, x_prec) + 2 > exp_diff in sub_float_significands_general\n    // - shift_x != 0 in sub_float_significands_general\n    // - shift_y == 0 in sub_float_significands_general\n    // - cancel >= exp_diff in sub_float_significands_general\n    // - out_len + cancel1 <= xs_len in sub_float_significands_general\n    // - out_len + cancel2 > 0 in sub_float_significands_general\n    // - cancel2 >= 0 in sub_float_significands_general\n    // - out_len + cancel2 <= ys_len in sub_float_significands_general\n    // - rm == Nearest in sub_float_significands_general\n    // - rm == Nearest && carry <= Limb::power_of_2(sh - 1) && (0 >= carry || carry >=\n    //   Limb::power_of_2(sh - 1)) in sub_float_significands_general\n    // - !goto_truncate in sub_float_significands_general\n    // - ixs_len <= 0 && iys_len <= 0 in sub_float_significands_general\n    // - !goto_truncate && !goto_end_of_sub second time in sub_float_significands_general\n    // - rm != Nearest || cmp_low == 0 in sub_float_significands_general\n    // - !goto_end_of_sub in sub_float_significands_general\n    // - out[out_len - 1] >> (Limb::WIDTH - 1) != 0 in sub_float_significands_general\n    // - cancel != 0 in sub_float_significands_general\n    test(\"2.0\", \"0x2.0#1\", \"1.0\", \"0x1.0#2\", \"1.0\", \"0x1.0#2\");\n    // - sdiff_exp < 0 in exponent_shift_compare\n    // - sign == Less in sub_float_significands_general\n    // - neg in sub_float_significands_general\n    test(\"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", \"-1.0\", \"-0x1.0#2\");\n    // - xi < 0 || yi < 0 || xs[xi] != ys[yi] in exponent_shift_compare\n    // - xi >= 0 in exponent_shift_compare\n    // - yi >= 0 second time in exponent_shift_compare\n    // - xs[xi] < ys[yi] in exponent_shift_compare\n    // - diff_exp == 0 second time in exponent_shift_compare\n    // - shift_y != 0 in sub_float_significands_general\n    test(\"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", \"-0.5\", \"-0x0.8#2\");\n    // - xs[xi] >= ys[yi] in exponent_shift_compare\n    test(\"1.5\", \"0x1.8#2\", \"1.0\", \"0x1.0#1\", \"0.5\", \"0x0.8#2\");\n    // - shift_x == 0 in sub_float_significands_general\n    // - cancel < exp_diff in sub_float_significands_general\n    // - ixs_len > 0 || iys_len > 0 in sub_float_significands_general\n    // - ixs_len <= 0 in sub_float_significands_general\n    // - iys_len condition in sub_float_significands_general\n    // - cmp_low == 0 first time in sub_float_significands_general\n    // - rm == Nearest && (sh != 0 || k != 0) in sub_float_significands_general\n    // - cmp_low == 0 second time in sub_float_significands_general\n    // - !goto_truncate && !goto_end_of_sub first time in sub_float_significands_general\n    // - cancel == 0 in sub_float_significands_general\n    test(\"0.5\", \"0x0.8#1\", \"1.5\", \"0x1.8#2\", \"-1.0\", \"-0x1.0#2\");\n    // - !dif.is_power_of_2() in exponent_shift_compare\n    test(\"0.5\", \"0x0.8#1\", \"2.0\", \"0x2.0#2\", \"-1.5\", \"-0x1.8#2\");\n    // - cmp_low != 0 first time in sub_float_significands_general\n    // - cmp_low > 0 in sub_float_significands_general\n    // - cmp_low > 0 && rm == Nearest in sub_float_significands_general\n    // - cmp_low > 0 && rm == Nearest && xx == yy in sub_float_significands_general\n    // - rm == Nearest && cmp_low != 0 in sub_float_significands_general\n    // - (out[0] >> sh) & 1 == 0 in sub_float_significands_general\n    test(\"0.5\", \"0x0.8#1\", \"3.0\", \"0x3.0#2\", \"-2.0\", \"-0x2.0#2\");\n    // - (out[0] >> sh) & 1 != 0 in sub_float_significands_general\n    // - cmp_low >= 0 in sub_float_significands_general\n    // - cmp_low >= 0 && !carry in sub_float_significands_general\n    test(\"4.0\", \"0x4.0#1\", \"1.2\", \"0x1.4#3\", \"3.0\", \"0x3.0#3\");\n    // - cmp_low >= 0 && carry in sub_float_significands_general\n    test(\"4.0\", \"0x4.0#1\", \"0.5\", \"0x0.8#2\", \"4.0\", \"0x4.0#2\");\n    // - rm == Nearest && carry > Limb::power_of_2(sh - 1) in sub_float_significands_general\n    // - goto_truncate in sub_float_significands_general\n    test(\"3.0\", \"0x3.0#2\", \"0.2\", \"0x0.4#1\", \"3.0\", \"0x3.0#2\");\n    // - rm == Nearest && carry <= Limb::power_of_2(sh - 1) && 0 < carry && carry <\n    //   Limb::power_of_2(sh - 1) in sub_float_significands_general\n    test(\"4.0\", \"0x4.0#1\", \"0.8\", \"0x0.c#2\", \"3.0\", \"0x3.0#2\");\n    // - max(out_prec, x_prec) + 2 <= exp_diff in sub_float_significands_general\n    // - in round_helper\n    // - dest_prec >= x_prec in round_helper\n    // - !increment_exp in sub_float_significands_general\n    // - inexact == 0 && rm != Down && rm != Floor in sub_float_significands_general\n    test(\"0.2\", \"0x0.4#1\", \"4.0\", \"0x4.0#2\", \"-4.0\", \"-0x4.0#2\");\n    // - diff_exp >= Limb::WIDTH in exponent_shift_compare first time\n    test(\n        \"8.82188e11\",\n        \"0xc.d668E+9#18\",\n        \"9.75459983374e122\",\n        \"0x1.79c17f063aE+102#40\",\n        \"-9.75459983374e122\",\n        \"-0x1.79c17f063aE+102#40\",\n    );\n    // - cancel2 < 0 in sub_float_significands_general\n    // - out_len - neg_cancel2 <= ys_len in sub_float_significands_general\n    test(\n        \"3.29008365861415556134836580980448399733562188e-9\",\n        \"0xe.217c389f8c9fd22042f5ed70da20cfb9f1ecE-8#146\",\n        \"3719044561792922503530448846362960.3599330496921301151502834994\",\n        \"0xb75cf116bc625ef1eab58f3c9950.5c2492852d5fb6817443c180#205\",\n        \"-3719044561792922503530448846362960.359933046402046456536127938\",\n        \"-0xb75cf116bc625ef1eab58f3c9950.5c2492770be37de1e7a3ef60#205\",\n    );\n    // - out_len + cancel1 > xs_len in sub_float_significands_general\n    // - cancel1 < xs_len in sub_float_significands_general\n    test(\n        \"1.07183972513958531257713938927815e-11\",\n        \"0xb.c8f5eafa12eb9821601f1dd6aeE-10#107\",\n        \"0.00374222828352849\",\n        \"0x0.00f5402c178824#46\",\n        \"-0.00374222827281009532032311766811006\",\n        \"-0x0.00f5402c0bbf2e1505ed1467de9fe#107\",\n    );\n    // - out_len + cancel2 > ys_len in sub_float_significands_general\n    test(\n        \"2589062031404.0\",\n        \"0x25ad01f682c.0#43\",\n        \"4351572166934988.581719655389852344796925751245753159273257621838622031922945531041952618\\\n        810238932316\",\n        \"0xf75bb593981cc.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n        \"-4348983104903584.58171965538985234479692575124575315927325762183862203192294553104195261\\\n        8810238932316\",\n        \"-0xf7360891a19a0.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n    );\n    // - yi >= 0 && lasty != 0 in exponent_shift_compare\n    // - xi < 0 fourth time in exponent_shift_compare\n    // - lasty == 0 in exponent_shift_compare\n    // - yi < 0 || ys[yi] != 0 in exponent_shift_compare\n    // - yi >= 0 fourth time in exponent_shift_compare\n    test(\n        \"0.002\",\n        \"0x0.008#2\",\n        \"1.107886492190627864290739752375593855464628579e-38\",\n        \"0x3.c51af197224960473945f6944424f855697e2E-32#149\",\n        \"0.001953124999999999999999999999999999988921135078\",\n        \"0x0.007ffffffffffffffffffffffffffffc3ae50e68#149\",\n    );\n    // - cmp_low > 0 && rm == Nearest && xx < yy in sub_float_significands_general\n    // - goto_truncate || goto_end_of_sub first time in sub_float_significands_general\n    // - goto_truncate || goto_end_of_sub second time in sub_float_significands_general\n    test(\n        \"1.521287e-9\",\n        \"0x6.88ac4E-8#21\",\n        \"6.842391932190563625e-20\",\n        \"0x1.431f7157e61b20d0E-16#62\",\n        \"1.5212870962270854807e-9\",\n        \"0x6.88ac3ffebce08eaE-8#62\",\n    );\n    // - out_len - neg_cancel2 > ys_len in sub_float_significands_general\n    test(\n        \"0.00678514868524062\",\n        \"0x0.01bcabe7b39c71#49\",\n        \"492541199943575879969.43922949854802247248767794847124160758\",\n        \"0x1ab361dbc0e97d4121.7071582bb3c5bd22b8f59cfc93c72a98#194\",\n        \"-492541199943575879969.43244434986278185350564935536210679008\",\n        \"-0x1ab361dbc0e97d4121.6eb4ac4400294c22b8f59cfc93c72a98#194\",\n    );\n    // - rm == Nearest && sh == 0 && k == 0 in sub_float_significands_general\n    // - rm == Nearest && cmp_low >= 0 in sub_float_significands_general\n    // - rm == Nearest && cmp_low >= 0 && yy < half in sub_float_significands_general\n    // - rm == Nearest && cmp_low >= 0 && cmp_low <= 0 in sub_float_significands_general\n    test(\n        \"5.7505515877842013577e-7\",\n        \"0x9.a5d7d56cabed47dE-6#64\",\n        \"1.1758894e-14\",\n        \"0x3.4f515E-12#22\",\n        \"5.7505514701952590309e-7\",\n        \"0x9.a5d7d21d5a9d47dE-6#64\",\n    );\n    // - rm == Nearest && cmp_low < 0 in sub_float_significands_general\n    // - rm == Nearest && cmp_low < 0 && yy < half in sub_float_significands_general\n    // - cmp_low < 0 in sub_float_significands_general first time\n    // - cmp_low < 0 && rm == Nearest in sub_float_significands_general\n    // - rm == Nearest && (xx > yy || sh > 0 || cmp_low == -1) in sub_float_significands_general\n    test(\n        \"8319983682.218895978935307677994592087137128849954503237724\",\n        \"0x1efe8e042.3809911ec0c7f99b114d2930720001b00aa46846#192\",\n        \"1.88392800575e35\",\n        \"0x2.4487b7174E+29#37\",\n        \"-188392800574747474298435817696599997.78110402106469232200542\",\n        \"-0x24487b7173fffffffffffe10171fbd.c7f66ee13f380664eec#192\",\n    );\n    // - rm == Nearest && cmp_low < 0 && yy >= half in sub_float_significands_general\n    // - rm == Nearest && xx < yy && sh <= 0 && cmp_low != -1 in sub_float_significands_general\n    // - goto_end_of_sub in sub_float_significands_general\n    test(\n        \"2.36288970224581301467472547462526069521e-27\",\n        \"0xb.b3518c72d51185c09977eb6e009c2c0E-23#128\",\n        \"3.413020751e-12\",\n        \"0x3.c0ae105E-10#30\",\n        \"-3.413020751029435178256669624768773569e-12\",\n        \"-0x3.c0ae104fffff44cae738d2aee7a3f668E-10#128\",\n    );\n    // - xi >= 0 fourth time in exponent_shift_compare\n    // - diff_exp >= Limb::WIDTH in exponent_shift_compare second time\n    // - xs[xi] == yy in exponent_shift_compare\n    test(\n        \"1125899906842624.0\",\n        \"0x4000000000000.000000000000#98\",\n        \"1.166815364554e-61\",\n        \"0x2.ffffffff80E-51#39\",\n        \"1125899906842624.0\",\n        \"0x4000000000000.000000000000#98\",\n    );\n    // - 0 < diff_exp < Limb::WIDTH && yi >= 0 in exponent_shift_compare\n    // - xs[xi] != yy in exponent_shift_compare\n    test(\n        \"9671406556917033397649408.0\",\n        \"0x800000000000000000000.0000#99\",\n        \"65536.015624999999999999946\",\n        \"0x10000.03ffffffffffffff00#87\",\n        \"9671406556917033397583871.98438\",\n        \"0x7fffffffffffffffeffff.fc00#99\",\n    );\n    // - diff_exp == 0 && yi >= 0 in exponent_shift_compare\n    test(\n        \"1.3877787807814456370485565165946e-17\",\n        \"0xf.ffffffffffffe007ffffffff8E-15#101\",\n        \"128.0000000000000000000000000008077935669463159990585083341\",\n        \"0x80.00000000000000000000003ffffffffffffe0000000000#190\",\n        \"-127.9999999999999999861222121929933371964607508331127668586\",\n        \"-0x7f.ffffffffffffff00000000400001ff7ffffe0008000000#190\",\n    );\n    // - rm == Nearest && xx == yy && sh <= 0 && cmp_low != -1 in sub_float_significands_general\n    // - cmp_low < 0 in sub_float_significands_general second time\n    test(\n        \"2.220581574517834801066783605693002897371795957735742517101e-16\",\n        \"0x1.0003fffffe00000000007ffffffffffffffffffffff000feE-13#192\",\n        \"8.881784e-16\",\n        \"0x4.00000E-13#21\",\n        \"-6.661202622483417522322269739033559602628204042264257482898e-16\",\n        \"-0x2.fffc000001ffffffffff80000000000000000000000fff00E-13#192\",\n    );\n    // - diff_exp < Limb::WIDTH && yi < 0 in exponent_shift_compare\n    test(\n        \"-1.8e-12\",\n        \"-0x1.fcE-10#7\",\n        \"-524288.0000000000017621525\",\n        \"-0x80000.0000000001f00078#81\",\n        \"524287.9999999999999573739\",\n        \"0x7ffff.fffffffffff40078#81\",\n    );\n    // - (yi >= 0 || lasty != 0) && high_dif == 0 && dif == 1 in exponent_shift_compare\n    // - xi >= 0 third time in exponent_shift_compare\n    // - yi >= 0 && diff_exp != 0 in exponent_shift_compare\n    // - high_dif != 0 in exponent_shift_compare\n    // - dif == 0 in exponent_shift_compare\n    test(\n        \"3.99999999999999999957\",\n        \"0x3.fffffffffffffff80#67\",\n        \"4.0\",\n        \"0x4.00000000000000000#68\",\n        \"-4.33680868994201773603e-19\",\n        \"-0x8.0000000000000000E-16#68\",\n    );\n    // - xi < 0 third time in exponent_shift_compare\n    // - cancel1 >= xs_len in sub_float_significands_general\n    test(\n        \"6.77626357803440271254657930615627554e-21\",\n        \"0x1.ffffffffffffffffffffc01fff800E-17#117\",\n        \"7.0e-21\",\n        \"0x2.0E-17#4\",\n        \"-6.99280860154738521672154778865541105e-46\",\n        \"-0x3.fe000800000000000000000000000E-38#117\",\n    );\n    // - yi >= 0 && diff_exp == 0 in exponent_shift_compare\n    // - dif != 0 in exponent_shift_compare\n    test(\n        \"1.45519152351431153846750277125465800054371356958e-11\",\n        \"0x1.00000001ffffffffffffffffffffffffffffffcE-9#155\",\n        \"1.455191523514311538467502771254658000526607875496523229114700566610230516799191954282190\\\n        364e-11\",\n        \"0x1.00000001fffffffffffffffffffffffc0000000000000000000000000000fffffffffff87f8E-9#301\",\n        \"1.710569408086637569000134230861426729009957349416545362986887684243433631257558931055548\\\n        3967e-49\",\n        \"0x3.ffffffbfffffffffffffffffffff00000000000780800000000000000000000000000000000E-41#301\",\n    );\n    // - xs[xi] == 0 in exponent_shift_compare\n    // - xi < 0 second time in exponent_shift_compare\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    // - xi >= 0 second time in exponent_shift_compare\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"-1.0\",\n        \"-0x1.0#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.4E-268435456#3\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    test(\n        \"1.262113616894785778907e-31\",\n        \"0x2.8f53ace354a6b7284E-26#68\",\n        \"1.26e-31\",\n        \"0x2.90E-26#7\",\n        \"-1.296426623240940697535e-34\",\n        \"-0xa.c531cab5948d7c00E-29#68\",\n    );\n    test(\n        \"too_small\",\n        \"0x2.8f5E-268435454#14\",\n        \"too_small\",\n        \"0x2.900E-268435454#14\",\n        \"-too_small\",\n        \"-0x1.0000E-268435456#14\",\n    );\n    test(\n        \"-too_small\",\n        \"-0x2.8f5E-268435454#14\",\n        \"-too_small\",\n        \"-0x2.900E-268435454#14\",\n        \"too_small\",\n        \"0x1.0000E-268435456#14\",\n    );\n\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n    );\n}\n\n#[test]\nfn test_sub_prec() {\n    let test = |s, s_hex, t, t_hex, prec: u64, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (diff, o) = x.clone().sub_prec(y.clone(), prec);\n        assert!(diff.is_valid());\n\n        assert_eq!(diff.to_string(), out);\n        assert_eq!(to_hex_string(&diff), out_hex);\n        assert_eq!(o, o_out);\n\n        let (diff_alt, o_alt) = x.clone().sub_prec_val_ref(&y, prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = x.sub_prec_ref_val(y.clone(), prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = x.sub_prec_ref_ref(&y, prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_prec_assign(y.clone(), prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_prec_assign_ref(&y, prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = add_prec_round_naive(x.clone(), -&y, prec, Nearest);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n\n        let (rug_diff, rug_o) = rug_sub_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_diff)),\n            ComparableFloatRef(&diff),\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, \"NaN\", \"NaN\", Equal);\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"NaN\", \"NaN\", \"-123.0\", \"-0x7b.0#7\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", 1, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", 2, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        1,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        2,\n        \"3.0\",\n        \"0x3.0#2\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        10,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"4.0\",\n        \"0x4.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        \"-4.0\",\n        \"-0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        1,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        20,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 10, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"0.5\", \"0x0.8#1\", \"4.0\", \"0x4.0#1\", 2, \"-4.0\", \"-0x4.0#2\", Less,\n    );\n    test(\n        \"8.829e30\",\n        \"0x6.f70E+25#13\",\n        \"0.05475\",\n        \"0x0.0e04#10\",\n        36,\n        \"8.8289883602e30\",\n        \"0x6.f70000000E+25#36\",\n        Greater,\n    );\n    test(\n        \"1.6390041924e12\",\n        \"0x1.7d9c433e8E+10#34\",\n        \"1.8272611248130303984e40\",\n        \"0x3.5b2c8ea9f3a386bE+33#62\",\n        40,\n        \"-1.827261124813e40\",\n        \"-0x3.5b2c8ea9f4E+33#40\",\n        Less,\n    );\n    test(\n        \"5.96031697199505378e-9\",\n        \"0x1.9997014b4948928E-7#60\",\n        \"0.000014\",\n        \"0x0.0000f#4\",\n        3,\n        \"-0.000013\",\n        \"-0x0.0000e#3\",\n        Greater,\n    );\n    test(\n        \"8.7741695e-21\",\n        \"0x2.96f51f0E-17#27\",\n        \"1.86647e10\",\n        \"0x4.5880E+8#16\",\n        11,\n        \"-1.866e10\",\n        \"-0x4.58E+8#11\",\n        Greater,\n    );\n    // - dest_prec < x_prec in round_helper\n    // - sh != 0 in round_helper\n    // - sh != 0 && (rm == Nearest || rb == 0) in round_helper\n    // - sh != 0 && (rm == Nearest || rb == 0) && (n == 0 || sb != 0) in round_helper\n    // - rm == Nearest in round_helper\n    // - rm == Nearest && rb != 0 && sb != 0 in round_helper\n    // - !increment second time in round_helper\n    // - inexact != 0 && inexact != MPFR_EVEN_INEX in sub_float_significands_general\n    test(\n        \"1.6390041924e12\",\n        \"0x1.7d9c433e8E+10#34\",\n        \"1.8272611248130303984e40\",\n        \"0x3.5b2c8ea9f3a386bE+33#62\",\n        40,\n        \"-1.827261124813e40\",\n        \"-0x3.5b2c8ea9f4E+33#40\",\n        Less,\n    );\n    // - rm == Nearest && rb == 0 in round_helper\n    test(\n        \"13104.5238818416080254535\",\n        \"0x3330.861d1ed0acba8a3a#77\",\n        \"2.854e-35\",\n        \"0x2.5fE-29#10\",\n        17,\n        \"13104.5\",\n        \"0x3330.8#17\",\n        Less,\n    );\n    // - out_len + cancel2 <= 0 in sub_float_significands_general\n    test(\n        \"1.73414747294406e-17\",\n        \"0x1.3fe4cc8cf520E-14#48\",\n        \"5095194424.1679374580403939884785489\",\n        \"0x12fb27f38.2afdf3020e8eaac84a7ec#116\",\n        62,\n        \"-5095194424.167937458\",\n        \"-0x12fb27f38.2afdf300#62\",\n        Greater,\n    );\n    // - rm == Nearest && rb != 0 && sb == 0 in round_helper\n    // - xs[o] & ulp != 0 in round_helper\n    // - increment first time in round_helper\n    // - increment_exp in sub_float_significands_general\n    // - inexact != 0 || rm == Down || rm == Floor && (inexact == 0 || inexact == MPFR_EVEN_INEX) in\n    //   sub_float_significands_general\n    // - !out[out_len - 1].get_highest_bit() in sub_float_significands_general\n    test(\n        \"5.96031697199505378e-9\",\n        \"0x1.9997014b4948928E-7#60\",\n        \"0.000014\",\n        \"0x0.0000f#4\",\n        3,\n        \"-0.000013\",\n        \"-0x0.0000e#3\",\n        Greater,\n    );\n    // - xs[o] & ulp == 0 in round_helper\n    test(\n        \"8.7741695e-21\",\n        \"0x2.96f51f0E-17#27\",\n        \"1.86647e10\",\n        \"0x4.5880E+8#16\",\n        11,\n        \"-1.866e10\",\n        \"-0x4.58E+8#11\",\n        Greater,\n    );\n    // - !increment first time in round_helper\n    // - out[out_len - 1].get_highest_bit() in sub_float_significands_general\n    test(\n        \"1.3482e25\",\n        \"0xb.27E+20#12\",\n        \"1.12202588817e-11\",\n        \"0xc.5638dc08E-10#36\",\n        11,\n        \"1.348e25\",\n        \"0xb.26E+20#11\",\n        Less,\n    );\n    // - increment second time in round_helper\n    test(\n        \"4.53892e18\",\n        \"0x3.efd8E+15#16\",\n        \"3412.3125291\",\n        \"0xd54.5001e8#33\",\n        1,\n        \"5.0e18\",\n        \"0x4.0E+15#1\",\n        Greater,\n    );\n    // - ixs_len > 0 in sub_float_significands_general\n    test(\n        \"6058.05208272591415306446968882359605946955168456454\",\n        \"0x17aa.0d554b247ce1b6ab28ba39c8d5992a74c7ac91a#169\",\n        \"0.000144566892208323\",\n        \"0x0.0009796e12f9784#47\",\n        64,\n        \"6058.0519381590219448\",\n        \"0x17aa.0d4bd1b669e84#64\",\n        Greater,\n    );\n    // - sh == 0 in round_helper\n    // - sh == 0 && (rm == Nearest || rb == 0) in round_helper\n    // - sh == 0 && (rm == Nearest || rb == 0) && (n == 0 || sb != 0) in round_helper\n    test(\n        \"3.6596517369110659089355442395654891585e48\",\n        \"0x2.810875a0ca3206afd8c6cf841941830E+40#123\",\n        \"1545.699550397407201099813420288295\",\n        \"0x609.b315bc1ec48a143a74bd53048#109\",\n        64,\n        \"3.6596517369110659089e48\",\n        \"0x2.810875a0ca3206b0E+40#64\",\n        Greater,\n    );\n    // - rm == Nearest && cmp_low >= 0 && cmp_low > 0 in sub_float_significands_general\n    // - cmp_low > 0 && rm == Nearest && xx > yy in sub_float_significands_general\n    // - cmp_low == 2 && rm == Nearest && xx > yy in sub_float_significands_general\n    // - cmp_low == 2 && rm == Nearest && xx > yy && !carry in sub_float_significands_general\n    test(\n        \"2.80915429604669102593383052436808885401854724410738829e-11\",\n        \"0x1.ee310ffa09a06a6361f52c2cd8a9569a780b775dc213E-9#177\",\n        \"519241072363118296470.333928838103121952666621563036\",\n        \"0x1c25eadc41d4907d96.557c5c3ed81cab65dab0cf920#166\",\n        64,\n        \"-5.1924107236311829648e20\",\n        \"-0x1.c25eadc41d4907daE+17#64\",\n        Less,\n    );\n    // - cmp_low > 0 && cmp_low != 2 && rm == Nearest && xx > yy in sub_float_significands_general\n    test(\n        \"559935046210054011882951826578284118061013900.5853448\",\n        \"0x191bbd3588c78488c2f4d122814d5fb34edb8c.95d928#170\",\n        \"3.027932e11\",\n        \"0x4.67fe2E+9#22\",\n        63,\n        \"5.599350462100540119e44\",\n        \"0x1.91bbd3588c78488cE+37#63\",\n        Less,\n    );\n    // - sh != 0 && (rm == Nearest || rb == 0) && n != 0 && sb == 0 in round_helper\n    test(\n        \"7184368264698708563285024670194469326968686224.86386349506591\",\n        \"0x1422880c600dc4fd90a02f1814859aafd658690.dd2628738430#198\",\n        \"1.0296060328202e-24\",\n        \"0x1.3ea5cb49bdaE-20#44\",\n        61,\n        \"7.184368264698708565e45\",\n        \"0x1.422880c600dc4feE+38#61\",\n        Greater,\n    );\n    // - not iys_len condition in sub_float_significands_general\n    test(\n        \"0.005406335446698931371156460215539762984788400068\",\n        \"0x0.01624f41ef4d9361bd396d1b5ff5c84cbeacdc10#153\",\n        \"268934084586659427574577798723115132232.14094768348\",\n        \"0xca52d21696ccb42e28dd0ff5c50ba548.241525bafe#167\",\n        62,\n        \"-2.689340845866594276e38\",\n        \"-0xc.a52d21696ccb430E+31#62\",\n        Less,\n    );\n    // - out[out_len - 1] >> (Limb::WIDTH - 1) == 0 in sub_float_significands_general\n    test(\n        \"64.0\",\n        \"0x40.000000000000000000000000#101\",\n        \"3.388131587461699328349286349380665493965593642335603946234186645761911188725141218987660\\\n        374e-21\",\n        \"0xf.fffff007f8000000007ffc00ffff00007fffffffffffffff80003ffff800001fffffffff80E-18#298\",\n        32,\n        \"64.0\",\n        \"0x40.0000000#32\",\n        Greater,\n    );\n    // - xi < 0 && yi >= 0 in exponent_shift_compare\n    // - yi < 0 second time in exponent_shift_compare\n    // - xs[xi] != 0 in exponent_shift_compare\n    test(\n        \"8.0\",\n        \"0x8.00#10\",\n        \"8.000000000000000000001799531422609112\",\n        \"0x8.0000000000000000087f8000000000#121\",\n        146,\n        \"-1.79953142260911170668274960959820418793242425e-21\",\n        \"-0x8.7f8000000000000000000000000000000000E-18#146\",\n        Equal,\n    );\n    // - yi >= 0 && ys[yi] == 0 in exponent_shift_compare\n    // - yi < 0 fourth time in exponent_shift_compare\n    test(\n        \"65536.0\",\n        \"0x10000.0000000000000000000#90\",\n        \"1.0e5\",\n        \"0x2.0E+4#2\",\n        146,\n        \"-65536.0\",\n        \"-0x10000.000000000000000000000000000000000#146\",\n        Equal,\n    );\n    // - rm == Nearest && cmp_low >= 0 && yy >= half in sub_float_significands_general\n    test(\n        \"3004622760.998488672936478517\",\n        \"0xb316e7a8.ff9cf423b0491b4#90\",\n        \"1355498858579258.8596\",\n        \"0x4d0d1abf5853a.dc0ec#70\",\n        64,\n        \"-1355495853956497.8611\",\n        \"-0x4d0d0f8de9d91.dc70#64\",\n        Greater,\n    );\n    // - cmp_low == 2 && rm == Nearest && xx > yy && carry in sub_float_significands_general\n    test(\n        \"2596143477507256672744148570210303.750244140624999888977803416602752745179193772357882662\\\n        973853959140044204\",\n        \"0x7ffff000000000000000001fffff.c00ffffffffff800007ffffffffffffffe000001ffffffff80000001ff\\\n        fc#349\",\n        \"4.2351647e-22\",\n        \"0x1.ffffffcE-18#27\",\n        18,\n        \"2.59615e33\",\n        \"0x8.0000E+27#18\",\n        Greater,\n    );\n    // - lasty != 0 in exponent_shift_compare\n    test(\n        \"6.2230152778611417071440640537801242403342227837862e-61\",\n        \"0xf.ffffffffffffffffffffffffffffff1ffff3fffeE-51#163\",\n        \"6.0e-61\",\n        \"0x1.0E-50#4\",\n        11,\n        \"-2.56e-98\",\n        \"-0xe.00E-82#11\",\n        Greater,\n    );\n    // - sh == 0 && (rm == Nearest || rb == 0) && n != 0 && sb == 0 in round_helper\n    test(\n        \"1.56676e-64\",\n        \"0x1.07ff8E-53#18\",\n        \"127.906249999999999993061106096092771622352302164\",\n        \"0x7f.e7ffffffffffff8000000000000000000001ff8#160\",\n        64,\n        \"-127.906249999999999993\",\n        \"-0x7f.e7ffffffffffff8#64\",\n        Greater,\n    );\n    // - yi < 0 third time in exponent_shift_compare\n    test(\n        \"6.9e-18\",\n        \"0x8.0E-15#6\",\n        \"6.9388939039072283773e-18\",\n        \"0x7.fffffffffffffff8E-15#64\",\n        86,\n        \"3.7615819226313200254999569e-37\",\n        \"0x8.000000000000000000000E-31#86\",\n        Equal,\n    );\n\n    test(\n        \"-too_small\",\n        \"-0x2.50888E-268435456#19\",\n        \"-too_small\",\n        \"-0x3.10E-268435456#10\",\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x3.10E-268435456#10\",\n        \"-too_small\",\n        \"-0x2.50888E-268435456#19\",\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\nfn sub_prec_fail() {\n    assert_panic!(Float::NAN.sub_prec(Float::NAN, 0));\n    assert_panic!(Float::NAN.sub_prec_val_ref(&Float::NAN, 0));\n    assert_panic!(Float::NAN.sub_prec_ref_val(Float::NAN, 0));\n    assert_panic!(Float::NAN.sub_prec_ref_ref(&Float::NAN, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.sub_prec_assign(Float::NAN, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.sub_prec_assign_ref(&Float::NAN, 0)\n    });\n}\n\n#[test]\nfn test_sub_round() {\n    let test = |s, s_hex, t, t_hex, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (diff, o) = x.clone().sub_round(y.clone(), rm);\n        assert!(diff.is_valid());\n\n        assert_eq!(diff.to_string(), out);\n        assert_eq!(to_hex_string(&diff), out_hex);\n        assert_eq!(o, o_out);\n\n        let (diff_alt, o_alt) = x.clone().sub_round_val_ref(&y, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = x.sub_round_ref_val(y.clone(), rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = x.sub_round_ref_ref(&y, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_round_assign(y.clone(), rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_round_assign_ref(&y, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_diff, rug_o) =\n                rug_sub_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_diff)),\n                ComparableFloatRef(&diff),\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (diff_alt, o_alt) = add_prec_round_naive(\n            x.clone(),\n            -&y,\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"-0.0\", \"-0x0.0\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Floor, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Down, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Up, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0.0\", \"0x0.0\", Exact, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-123.0\", \"-0x7b.0#7\", Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Floor,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Down,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Up,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Exact,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Floor,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Ceiling,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Down,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Up,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Nearest,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        Exact,\n        \"123.0\",\n        \"0x7b.0#7\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", Floor, \"3.0\", \"0x3.0#2\", Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"4.555806215962889\",\n        \"0x4.8e4950f079600#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"4.555806215962889\",\n        \"0x4.8e4950f079600#53\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"4.555806215962888\",\n        \"0x4.8e4950f0795fc#53\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Nearest,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Exact,\n        \"-1.727379091216698\",\n        \"-0x1.ba35842091e63#53\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Floor,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Down,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Up,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Nearest,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Exact,\n        \"1.727379091216698\",\n        \"0x1.ba35842091e63#53\",\n        Equal,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"-4.555806215962889\",\n        \"-0x4.8e4950f079600#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Ceiling,\n        \"-4.555806215962888\",\n        \"-0x4.8e4950f0795fc#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Down,\n        \"-4.555806215962888\",\n        \"-0x4.8e4950f0795fc#53\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Up,\n        \"-4.555806215962889\",\n        \"-0x4.8e4950f079600#53\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Floor,\n        \"-4.555806215962889\",\n        \"-0x4.8e4950f079600#53\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.5\", \"0x0.8#1\", \"2.0\", \"0x2.0#1\", Down, \"-1.0\", \"-0x1.0#1\", Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    // - in sub_float_significands_same_prec_lt_w\n    // - x_exp == y_exp in sub_float_significands_same_prec_lt_w\n    // - x == y in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    // - x_exp < y_exp in sub_float_significands_same_prec_lt_w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_lt_w\n    // - leading_zeros != 0 in sub_float_significands_same_prec_lt_w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#1\", Nearest, \"-1.0\", \"-0x1.0#1\", Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_lt_w\n    // - neg in sub_float_significands_same_prec_lt_w\n    // - rm == Nearest in sub_float_significands_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & shift_bit) != 0) in\n    //   sub_float_significands_same_prec_lt_w\n    // - rm == Nearest && round_bit != 0 && sticky_bit != 0 && diff == 0 in\n    //   sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"4.0\", \"0x4.0#1\", Nearest, \"-4.0\", \"-0x4.0#1\", Less,\n    );\n    // - !neg in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"0.2\", \"0x0.4#1\", Nearest, \"1.0\", \"0x1.0#1\", Greater,\n    );\n    // - x < y in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\", Nearest, \"-0.5\", \"-0x0.8#2\", Equal,\n    );\n    // - x > y in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.0\", \"0x1.0#2\", Nearest, \"0.5\", \"0x0.8#2\", Equal,\n    );\n    // - leading_zeros == 0 in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.5\", \"0x1.8#2\", \"0.5\", \"0x0.8#2\", Nearest, \"1.0\", \"0x1.0#2\", Equal,\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff & shift_bit) == 0)) in\n    //   sub_float_significands_same_prec_lt_w\n    test(\n        \"2.0\", \"0x2.0#2\", \"0.8\", \"0x0.c#2\", Nearest, \"1.0\", \"0x1.0#2\", Less,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & shift_bit) != 0) && diff !=\n    //   0 in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.5\", \"0x1.8#2\", \"0.1\", \"0x0.2#2\", Nearest, \"1.5\", \"0x1.8#2\", Greater,\n    );\n    // - exp_diff >= Limb::WIDTH in sub_float_significands_same_prec_lt_w\n    // - x <= LIMB_HIGH_BIT in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        \"6.0e-11\",\n        \"0x4.0E-9#1\",\n        Nearest,\n        \"1.0e9\",\n        \"0x4.0E+7#1\",\n        Greater,\n    );\n    // - x > LIMB_HIGH_BIT in sub_float_significands_same_prec_lt_w\n    test(\n        \"9.2047171e-27\",\n        \"0x2.d945d78E-22#27\",\n        \"1.43189635e33\",\n        \"0x4.69912aE+27#27\",\n        Nearest,\n        \"-1.43189635e33\",\n        \"-0x4.69912aE+27#27\",\n        Less,\n    );\n\n    // - rm == Floor || rm == Down in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"0.2\", \"0x0.4#1\", Down, \"0.5\", \"0x0.8#1\", Less,\n    );\n    // - rm == Ceiling || rm == Up in sub_float_significands_same_prec_lt_w\n    // - (rm == Ceiling || rm == Up) && diff == 0 in sub_float_significands_same_prec_lt_w\n    test(\n        \"1.0\", \"0x1.0#1\", \"0.2\", \"0x0.4#1\", Up, \"1.0\", \"0x1.0#1\", Greater,\n    );\n    // - (rm == Ceiling || rm == Up) && diff != 0 in sub_float_significands_same_prec_lt_w\n    test(\n        \"2.0\", \"0x2.0#2\", \"0.8\", \"0x0.c#2\", Up, \"1.5\", \"0x1.8#2\", Greater,\n    );\n\n    // - in sub_float_significands_same_prec_w\n    // - x_exp == y_exp in sub_float_significands_same_prec_w\n    // - x_exp == y_exp && a0 == 0 in sub_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_w\n    // - x_exp < y_exp in sub_float_significands_same_prec_w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_w\n    // - a0 != 0 in sub_float_significands_same_prec_w\n    // - leading_zeros != 0 in sub_float_significands_same_prec_w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"2.0\",\n        \"0x2.0000000000000000#64\",\n        Nearest,\n        \"-1.0\",\n        \"-0x1.0000000000000000#64\",\n        Equal,\n    );\n    // - a0 > x in sub_float_significands_same_prec_w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"-1.084202172485504434e-19\",\n        \"-0x2.0000000000000000E-16#64\",\n        Equal,\n    );\n    // - a0 <= x in sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"1.0\",\n        \"0x1.0000000000000000#64\",\n        Nearest,\n        \"1.084202172485504434e-19\",\n        \"0x2.0000000000000000E-16#64\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_w\n    // - neg in sub_float_significands_same_prec_w\n    // - rm == Nearest in sub_float_significands_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & 1) != 0) in\n    //   sub_float_significands_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & 1) != 0) &&\n    //   !diff.overflowing_add_assign(1) in sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        Nearest,\n        \"-3.0\",\n        \"-0x3.0000000000000000#64\",\n        Less,\n    );\n    // - !neg in sub_float_significands_same_prec_w\n    test(\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        Nearest,\n        \"3.0\",\n        \"0x3.0000000000000000#64\",\n        Greater,\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff & 1) == 0)) in\n    //   sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000003\",\n        \"0x1.0000000000000006#64\",\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        Nearest,\n        \"-2.9999999999999999996\",\n        \"-0x2.fffffffffffffff8#64\",\n        Greater,\n    );\n    // - leading_zeros == 0 in sub_float_significands_same_prec_w\n    test(\n        \"3.2729513077064011786e-37\",\n        \"0x6.f5f6d50e7b8f6eb0E-31#64\",\n        \"7.8519772600462495573e-34\",\n        \"0x4.13b4f0d218450fb0E-28#64\",\n        Nearest,\n        \"-7.848704308738543156e-34\",\n        \"-0x4.13459164c75d56b8E-28#64\",\n        Greater,\n    );\n    // - exp_diff >= Limb::WIDTH in sub_float_significands_same_prec_w\n    // - x > LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    test(\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n        \"2.9347251290514630352e-45\",\n        \"0x1.0c11b075f03d6daeE-37#64\",\n        Nearest,\n        \"5.9376349676904431794e-6\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n        Greater,\n    );\n    // - x <= LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    // - exp_diff != Limb::WIDTH || y <= LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff & 1) != 0) &&\n    //   diff.overflowing_add_assign(1) in sub_float_significands_same_prec_w\n    test(\n        \"8355840.0624923708378\",\n        \"0x7f8000.0fff8000ff8#64\",\n        \"2.3384026197294446691e49\",\n        \"0x1.0000000000000000E+41#64\",\n        Nearest,\n        \"-2.3384026197294446691e49\",\n        \"-0x1.0000000000000000E+41#64\",\n        Less,\n    );\n    // - x_exp != y_exp && a0 == 0 in sub_float_significands_same_prec_w\n    test(\n        \"63.999999999999999997\",\n        \"0x3f.ffffffffffffffc#64\",\n        \"64.0\",\n        \"0x40.000000000000000#64\",\n        Nearest,\n        \"-3.4694469519536141888e-18\",\n        \"-0x4.0000000000000000E-15#64\",\n        Equal,\n    );\n    // - exp_diff == Limb::WIDTH && y > LIMB_HIGH_BIT in sub_float_significands_same_prec_w\n    test(\n        \"4.656578456163629198e-10\",\n        \"0x1.ffff07fffffffffeE-8#64\",\n        \"4294967296.0\",\n        \"0x100000000.00000000#64\",\n        Nearest,\n        \"-4294967295.9999999995\",\n        \"-0xffffffff.fffffffe#64\",\n        Greater,\n    );\n\n    // - rm == Floor || rm == Down in sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        Down,\n        \"-2.9999999999999999998\",\n        \"-0x2.fffffffffffffffc#64\",\n        Greater,\n    );\n    // - rm == Ceiling || rm == Up in sub_float_significands_same_prec_w\n    // - (rm == Ceiling || rm == Up) && !diff.overflowing_add_assign(1) in\n    //   sub_float_significands_same_prec_w\n    test(\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n        \"4.0\",\n        \"0x4.0000000000000000#64\",\n        Up,\n        \"-3.0\",\n        \"-0x3.0000000000000000#64\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) && diff.overflowing_add_assign(1) in\n    //   sub_float_significands_same_prec_w\n    test(\n        \"7.737125245533626718e25\",\n        \"0x4.0000000000000000E+21#64\",\n        \"3.4410713482205469792e-21\",\n        \"0x1.03fffffffffc0000E-17#64\",\n        Up,\n        \"7.737125245533626718e25\",\n        \"0x4.0000000000000000E+21#64\",\n        Greater,\n    );\n\n    // - in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp in sub_float_significands_same_prec_gt_w_lt_2w\n    // - a1 == 0 && a0 == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp < y_exp in sub_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp != y_exp && a1 != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp != y_exp && leading_zeros != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"2.0\",\n        \"0x2.0000000000000000#65\",\n        Nearest,\n        \"-1.0\",\n        \"-0x1.0000000000000000#65\",\n        Equal,\n    );\n    // - (a1 != 0 || a0 != 0) && a1 >= x_1 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp && a1 == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - x_exp == y_exp && leading_zeros == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"-5.42101086242752217e-20\",\n        \"-0x1.0000000000000000E-16#65\",\n        Equal,\n    );\n    // - (a1 != 0 || a0 != 0) && a1 < x_1 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        Nearest,\n        \"5.42101086242752217e-20\",\n        \"0x1.0000000000000000E-16#65\",\n        Equal,\n    );\n    // - x_exp == y_exp && leading_zeros != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000#66\",\n        \"1.00000000000000000003\",\n        \"0x1.00000000000000008#66\",\n        Nearest,\n        \"-2.710505431213761085e-20\",\n        \"-0x8.0000000000000000E-17#66\",\n        Equal,\n    );\n    // - x_exp == y_exp && a1 != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n        \"1.00000000000000000011\",\n        \"0x1.0000000000000002#65\",\n        Nearest,\n        \"-1.084202172485504434e-19\",\n        \"-0x2.0000000000000000E-16#65\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - neg in sub_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest in sub_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   !overflow in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        Nearest,\n        \"-3.0\",\n        \"-0x3.0000000000000000#65\",\n        Less,\n    );\n    // - !neg in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        Nearest,\n        \"3.0\",\n        \"0x3.0000000000000000#65\",\n        Greater,\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff_0 & shift_bit) == 0)) in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000016\",\n        \"0x1.0000000000000003#65\",\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        Nearest,\n        \"-2.9999999999999999998\",\n        \"-0x2.fffffffffffffffc#65\",\n        Greater,\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && a1 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        \"18.63123034252626794758647\",\n        \"0x12.a1984fcd64a8ae228eef#85\",\n        Nearest,\n        \"1.44020837962004126031156726e28\",\n        \"0x2.e891fdf020840728c0894E+23#85\",\n        Greater,\n    );\n    // - x_exp != y_exp && leading_zeros == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"0.0001507756106295330606262754053\",\n        \"0x0.0009e19851127b95dcf03f0cdc#91\",\n        \"3458.565842843038054059107814\",\n        \"0xd82.90db1399862ba513faf8#91\",\n        Nearest,\n        \"-3458.565692067427424526047188\",\n        \"-0xd82.90d132013519297e1e08#91\",\n        Less,\n    );\n    // - exp_diff >= Limb::WIDTH * 2 in sub_float_significands_same_prec_gt_w_lt_2w\n    // - exp_diff >= Limb::WIDTH * 2 && a1 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n        \"1.14823551075108882469e-96\",\n        \"0x2.73dea72af3fe6314E-80#65\",\n        Nearest,\n        \"4.8545822922649671226e27\",\n        \"0xf.af9dc963a0709f78E+22#65\",\n        Greater,\n    );\n    // - exp_diff == Limb::WIDTH in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"19585.2851423168986928116147584507795\",\n        \"0x4c81.48ff163dc91a0d4bd90309b0f8#116\",\n        \"372369974082165972902790.766638151683\",\n        \"0x4eda377c7f0d747fa386.c44265dd58#116\",\n        Nearest,\n        \"-372369974082165972883205.481495834785\",\n        \"-0x4eda377c7f0d747f5705.7b434f9f90#116\",\n        Less,\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 && a1 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   overflow in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"9.9035203142830421991929938e27\",\n        \"0x2.000000000000000000000E+23#85\",\n        \"16.0\",\n        \"0x10.00000000000000000000#85\",\n        Nearest,\n        \"9.9035203142830421991929938e27\",\n        \"0x2.000000000000000000000E+23#85\",\n        Greater,\n    );\n    // - exp_diff >= Limb::WIDTH * 2 && a1 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"5.3455294200288159103345444e-51\",\n        \"0x1.ffffffffc000000000000E-42#83\",\n        \"8.0\",\n        \"0x8.00000000000000000000#83\",\n        Nearest,\n        \"-8.0\",\n        \"-0x8.00000000000000000000#83\",\n        Less,\n    );\n    // - x_exp != y_exp && a1 == 0 in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"4.00000000000000000000084702\",\n        \"0x4.000000000000000003fffc#89\",\n        \"3.999999999999999999999999994\",\n        \"0x3.fffffffffffffffffffffe#89\",\n        Nearest,\n        \"8.47026484905764768539612568e-22\",\n        \"0x3.fffe000000000000000000E-18#89\",\n        Equal,\n    );\n\n    // - rm == Floor || rm == Down in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        Down,\n        \"-2.9999999999999999999\",\n        \"-0x2.fffffffffffffffe#65\",\n        Greater,\n    );\n    // - rm == Ceiling || rm == Up in sub_float_significands_same_prec_gt_w_lt_2w\n    // - (rm == Ceiling || rm == Up) && !overflow in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.00000000000000000005\",\n        \"0x1.0000000000000001#65\",\n        \"4.0\",\n        \"0x4.0000000000000000#65\",\n        Up,\n        \"-3.0\",\n        \"-0x3.0000000000000000#65\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) && overflow in sub_float_significands_same_prec_gt_w_lt_2w\n    test(\n        \"1.5986723171183083380727715984266450731e-36\",\n        \"0x2.1fffffffffff00000000000000ffff8E-30#123\",\n        \"2475880078570760549798248448.0\",\n        \"0x80000000000000000000000.00000000#123\",\n        Up,\n        \"-2475880078570760549798248448.0\",\n        \"-0x80000000000000000000000.00000000#123\",\n        Less,\n    );\n\n    // - in sub_float_significands_same_prec_2w\n    // - x_exp == y_exp in sub_float_significands_same_prec_2w\n    // - a1 == 0 && a0 == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_2w\n    // - x_exp < y_exp in sub_float_significands_same_prec_2w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_2w\n    // - a1 != 0 second time in sub_float_significands_same_prec_2w\n    // - a1 != 0 third time in sub_float_significands_same_prec_2w\n    // - x_exp != y_exp && leading_zeros != 0 in sub_float_significands_same_prec_2w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#128\",\n        Nearest,\n        \"-1.0\",\n        \"-0x1.00000000000000000000000000000000#128\",\n        Equal,\n    );\n    // - (a1 != 0 || a0 != 0) && a1 >= x_1 in sub_float_significands_same_prec_2w\n    // - a1 == 0 first time in sub_float_significands_same_prec_2w\n    // - x_exp == y_exp && leading_zeros != 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        Nearest,\n        \"-5.87747175411143753984368268611122838909e-39\",\n        \"-0x2.00000000000000000000000000000000E-32#128\",\n        Equal,\n    );\n    // - (a1 != 0 || a0 != 0) && a1 < x_1 in sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#128\",\n        Nearest,\n        \"5.87747175411143753984368268611122838909e-39\",\n        \"0x2.00000000000000000000000000000000E-32#128\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_2w\n    // - neg in sub_float_significands_same_prec_2w\n    // - rm == Nearest in sub_float_significands_same_prec_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & 1) != 0) && !overflow in\n    //   sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        Nearest,\n        \"-3.0\",\n        \"-0x3.00000000000000000000000000000000#128\",\n        Less,\n    );\n    // - !neg in sub_float_significands_same_prec_2w\n    test(\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#128\",\n        Greater,\n    );\n    // - rm == Nearest && (round_bit == 0 || (sticky_bit == 0 && (diff_0 & 1) == 0)) in\n    //   sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000018\",\n        \"0x1.00000000000000000000000000000006#128\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        Nearest,\n        \"-2.99999999999999999999999999999999999998\",\n        \"-0x2.fffffffffffffffffffffffffffffff8#128\",\n        Greater,\n    );\n    // - x_exp != y_exp && leading_zeros == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"1.91698663575347889601435178329077738407e-37\",\n        \"0x4.13b4f0d218450fb6f5f6d50e7b8f6eb0E-31#128\",\n        \"8.0669110092962644724944820639408319804e-34\",\n        \"0x4.3046c1d7c0f5b6be39df2b03f3e49a70E-28#128\",\n        Nearest,\n        \"-8.06499402266051099359846771215754120301e-34\",\n        \"-0x4.30058688b3d4326d3e6fcb96a2fce178E-28#128\",\n        Greater,\n    );\n    // - exp_diff >= Limb::WIDTH * 2 in sub_float_significands_same_prec_2w\n    // - x_1 > LIMB_HIGH_BIT || x_0 > 0 in sub_float_significands_same_prec_2w\n    test(\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n        \"5.07801249136957145270807726205511855421e-45\",\n        \"0x1.cfd8608b7c32de2bbcfecf8bcf8a2d00E-37#128\",\n        Nearest,\n        \"5.80991149045382428948889299639419733262e-6\",\n        \"0x0.00006179613d776a1c835894818a219f488e8#128\",\n        Greater,\n    );\n    // - Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_2w\n    // - Limb::WIDTH < exp_diff < Limb::WIDTH * 2 in sub_float_significands_same_prec_2w\n    // - a1 >= LIMB_HIGH_BIT in sub_float_significands_same_prec_2w\n    test(\n        \"4354249796990942.35435357526597783143164\",\n        \"0xf782ac869b7de.5ab6ea78fcf0cc5079f#128\",\n        \"8.03239453825726512240307053405256016022e-10\",\n        \"0x3.732bce7aa121827a284545a25f32dc68E-8#128\",\n        Nearest,\n        \"4354249796990942.35435357446273837760591\",\n        \"0xf782ac869b7de.5ab6ea7589c4fdd5d8d#128\",\n        Greater,\n    );\n    // - a1 != 0 first time in sub_float_significands_same_prec_2w\n    test(\n        \"852777855057.113455599443829872557360137\",\n        \"0xc68d856851.1d0b6d1928c98779f28bdd#128\",\n        \"869223500084.503694559376384046083491558\",\n        \"0xca61c20934.80f2206bb1d7d5cad69caa#128\",\n        Nearest,\n        \"-16445645027.39023895993255417352613142066\",\n        \"-0x3d43ca0e3.63e6b352890e4e50e410cd00#128\",\n        Equal,\n    );\n    // - exp_diff == Limb::WIDTH in sub_float_significands_same_prec_2w\n    test(\n        \"1.057437459917463716438672572710788562701e-17\",\n        \"0xc.310127aae1df1a1cb12f60c4d339d76E-15#128\",\n        \"148.0549133677002965445211858794413066474\",\n        \"0x94.0e0ecd6e62d0a8c7c7c2a633277e3e#128\",\n        Nearest,\n        \"-148.054913367700296533946811280266669483\",\n        \"-0x94.0e0ecd6e62d0a804b7b02b85098c9c#128\",\n        Greater,\n    );\n    // - x_1 <= LIMB_HIGH_BIT && x_0 <= 0 in sub_float_significands_same_prec_2w\n    // - exp_diff != TWICE_WIDTH || tst in sub_float_significands_same_prec_2w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & 1) != 0) && overflow in\n    //   sub_float_significands_same_prec_2w\n    test(\n        \"3.83123885216472214589586756787577295905e53\",\n        \"0x4.00000000000000000000000000000000E+44#128\",\n        \"9.09494703466994132423639742106012939545e-13\",\n        \"0x1.00000008000000000000007fffffff80E-10#128\",\n        Nearest,\n        \"3.83123885216472214589586756787577295905e53\",\n        \"0x4.00000000000000000000000000000000E+44#128\",\n        Greater,\n    );\n    // - a1 < LIMB_HIGH_BIT in sub_float_significands_same_prec_2w\n    test(\n        \"0.000473141670219947088192358501321236008969\",\n        \"0x0.001f01fffffe001ffe000000000003ffff0#128\",\n        \"144115188075855872.000000000007275846592\",\n        \"0x200000000000000.0000000007fff80000#128\",\n        Nearest,\n        \"-144115188075855871.9995268583370558995037\",\n        \"-0x1ffffffffffffff.ffe0fe000801f7e002#128\",\n        Less,\n    );\n    // - a1 == 0 second  time in sub_float_significands_same_prec_2w\n    test(\n        \"1.192092895507812500000000000000000918348e-7\",\n        \"0x2.0000000000000000000000000007fffcE-6#128\",\n        \"1.19209289550781249999999999999999632658e-7\",\n        \"0x1.ffffffffffffffffffffffffffe00000E-6#128\",\n        Nearest,\n        \"4.5917678014072389539175224798764807294e-40\",\n        \"0x2.7fffc000000000000000000000000000E-33#128\",\n        Equal,\n    );\n    // - exp_diff == TWICE_WIDTH && !tst in sub_float_significands_same_prec_2w\n    test(\n        \"1024.0\",\n        \"0x400.000000000000000000000000000000#128\",\n        \"5.97151130219911582898625687582100437209e-36\",\n        \"0x7.f00000001fffffffffffffffe0000000E-30#128\",\n        Nearest,\n        \"1023.999999999999999999999999999999999994\",\n        \"0x3ff.fffffffffffffffffffffffffffff8#128\",\n        Less,\n    );\n    // - x_exp == y_exp && leading_zeros == 0 in sub_float_significands_same_prec_2w\n    test(\n        \"0.249999999999999999999999999974756451033\",\n        \"0x0.3ffffffffffffffffffffffe000000000#128\",\n        \"0.2499999999999999999864474728691747435412\",\n        \"0x0.3fffffffffffffffc0000001ffffffffc#128\",\n        Nearest,\n        \"1.35525271055817074916830884337875729072e-20\",\n        \"0x3.ffffffc0000000040000000000000000E-17#128\",\n        Equal,\n    );\n    // - a1 == 0 third time in sub_float_significands_same_prec_2w\n    test(\n        \"8.0\",\n        \"0x8.0000000000000000000000000000000#128\",\n        \"7.99999999999999999999999999999999999998\",\n        \"0x7.fffffffffffffffffffffffffffffff8#128\",\n        Nearest,\n        \"2.35098870164457501593747307444449135564e-38\",\n        \"0x8.0000000000000000000000000000000E-32#128\",\n        Equal,\n    );\n\n    // - rm == Floor || rm == Down in sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        Down,\n        \"-2.99999999999999999999999999999999999999\",\n        \"-0x2.fffffffffffffffffffffffffffffffc#128\",\n        Greater,\n    );\n    // - rm == Ceiling || rm == Up in sub_float_significands_same_prec_2w\n    // - (rm == Ceiling || rm == Up) && !overflow in sub_float_significands_same_prec_2w\n    test(\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#128\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#128\",\n        Up,\n        \"-3.0\",\n        \"-0x3.00000000000000000000000000000000#128\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) && overflow in sub_float_significands_same_prec_2w\n    test(\n        \"77371252455336267181195264.0\",\n        \"0x4000000000000000000000.00000000000#128\",\n        \"4.93038066207960562897601098365736701192e-32\",\n        \"0x1.00000003e00000000001ff000000001eE-26#128\",\n        Up,\n        \"77371252455336267181195264.0\",\n        \"0x4000000000000000000000.00000000000#128\",\n        Greater,\n    );\n\n    // - rm == Floor || rm == Down in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        Down,\n        \"-2.999999999999999999999999999999999999994\",\n        \"-0x2.fffffffffffffffffffffffffffffffe#129\",\n        Greater,\n    );\n    // - rm == Ceiling || rm == Up in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - (rm == Ceiling || rm == Up) && overflow in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - (rm == Ceiling || rm == Up) && diff_1 == 0 && diff_0 == 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - (rm == Ceiling || rm == Up) && diff_2 != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        Up,\n        \"-3.0\",\n        \"-0x3.00000000000000000000000000000000#129\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) && !overflow in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - (rm == Ceiling || rm == Up) && (diff_1 != 0 || diff_0 != 0) in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        Up,\n        \"-2.999999999999999999999999999999999999994\",\n        \"-0x2.fffffffffffffffffffffffffffffffe#129\",\n        Less,\n    );\n    // - (rm == Ceiling || rm == Up) && diff_2 == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"3.982729777831130692572200994412995874342180298e-59\",\n        \"0x3.ffffffffffffffffffffffff800000000000000E-49#155\",\n        \"9.31322574615478515625e-10\",\n        \"0x4.00000000000000000000000000000000000000E-8#155\",\n        Floor,\n        \"-9.31322574615478515625e-10\",\n        \"-0x4.00000000000000000000000000000000000000E-8#155\",\n        Less,\n    );\n\n    // - in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - a2 == 0 && a1 == 0 && a0 == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    // - x_exp != y_exp in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && sticky_bit == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && a2 != 0 first time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && leading_zeros != 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        Nearest,\n        \"-1.0\",\n        \"-0x1.00000000000000000000000000000000#129\",\n        Equal,\n    );\n    // - x_exp >= y_exp in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.0\",\n        \"0x2.00000000000000000000000000000000#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Nearest,\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Equal,\n    );\n    // - (a2 != 0 || a1 != 0 || a0 != 0) && a2 >= x_2 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp && a2 == 0 first time in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp && a2 == 0 second time in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - x_exp == y_exp && leading_zeros == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Nearest,\n        \"-2.93873587705571876992184134305561419455e-39\",\n        \"-0x1.00000000000000000000000000000000E-32#129\",\n        Equal,\n    );\n    // - (a2 != 0 || a1 != 0 || a0 != 0) && a2 < x_2 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        Nearest,\n        \"2.93873587705571876992184134305561419455e-39\",\n        \"0x1.00000000000000000000000000000000E-32#129\",\n        Equal,\n    );\n    // - x_exp == y_exp && leading_zeros != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000#130\",\n        \"1.000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000008#130\",\n        Nearest,\n        \"-1.469367938527859384960920671527807097273e-39\",\n        \"-0x8.00000000000000000000000000000000E-33#130\",\n        Equal,\n    );\n    // - x_exp == y_exp && a2 != 0 second time in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.0\",\n        \"0x1.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000006\",\n        \"0x1.00000000000000000000000000000002#129\",\n        Nearest,\n        \"-5.87747175411143753984368268611122838909e-39\",\n        \"-0x2.00000000000000000000000000000000E-32#129\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - neg in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   overflow in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) && diff_1\n    //   == 0 && diff_0 == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && diff_2 != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        Nearest,\n        \"-3.0\",\n        \"-0x3.00000000000000000000000000000000#129\",\n        Less,\n    );\n    // - !neg in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        \"1.000000000000000000000000000000000000003\",\n        \"0x1.00000000000000000000000000000001#129\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00000000000000000000000000000000#129\",\n        Greater,\n    );\n    // - rm == Nearest && round_bit == 0 || (sticky_bit == 0 && (diff_0 & shift_bit) == 0) in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.000000000000000000000000000000000000009\",\n        \"0x1.00000000000000000000000000000003#129\",\n        \"4.0\",\n        \"0x4.00000000000000000000000000000000#129\",\n        Nearest,\n        \"-2.999999999999999999999999999999999999988\",\n        \"-0x2.fffffffffffffffffffffffffffffffc#129\",\n        Greater,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   (diff_1 != 0 || diff_0 != 0) in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.000000000000000000000000000000000000006\",\n        \"0x2.00000000000000000000000000000002#129\",\n        \"0.500000000000000000000000000000000000001\",\n        \"0x0.800000000000000000000000000000008#129\",\n        Nearest,\n        \"1.500000000000000000000000000000000000006\",\n        \"0x1.80000000000000000000000000000002#129\",\n        Greater,\n    );\n    // - rm == Nearest && round_bit != 0 && (sticky_bit != 0 || (diff_0 & shift_bit) != 0) &&\n    //   !overflow in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.000000000000000000000000000000000000003\",\n        \"0x2.00000000000000000000000000000001#130\",\n        \"0.5000000000000000000000000000000000000007\",\n        \"0x0.800000000000000000000000000000004#130\",\n        Nearest,\n        \"1.500000000000000000000000000000000000003\",\n        \"0x1.800000000000000000000000000000010#130\",\n        Greater,\n    );\n    // - TWICE_WIDTH <= exp_diff < THRICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - TWICE_WIDTH < exp_diff < THRICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - TWICE_WIDTH <= exp_diff < THRICE_WIDTH && a2 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"2.024076700393272432111968987625898501371897741e-29\",\n        \"0x1.9a88122864b9c4b577e4b655958954f82345dE-24#149\",\n        \"245906107849378561117126906.9059035528266331265\",\n        \"0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        Nearest,\n        \"-245906107849378561117126906.9059035528266331265\",\n        \"-0xcb68a4d1611415054400fa.e7e94b94b8791630#149\",\n        Less,\n    );\n    // - exp_diff >= THRICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff >= THRICE_WIDTH && a2 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n        \"6.8892360159362421595728818935378487832685754059e-50\",\n        \"0x1.9c693c182df3035eef00d41638bbdd942f4d498E-41#155\",\n        Nearest,\n        \"4.397610888919711045634814958598336677777534377e47\",\n        \"0x4.d0791b9428a6b4fc52e44e537ab5a0f269ad60E+39#155\",\n        Greater,\n    );\n    // - exp_diff < Limb::WIDTH && leading_zeros == 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.9709672065181108960570410290811793724062284431352e-48\",\n        \"0x7.43dc113e95ca123693650af31435eac45c0e7a680E-40#165\",\n        \"5.2183974782595301717751266872943662193587933931613e-47\",\n        \"0x4.c4457ca8b3429511981a96eb0c2de4fdb8c43bea4E-39#165\",\n        Nearest,\n        \"-4.7213007576077190821694225843862482821181705488478e-47\",\n        \"-0x4.5007bb94c9e5f3ee2ee4463bdaea865173035443cE-39#165\",\n        Equal,\n    );\n    // - exp_diff < Limb::WIDTH && sticky_bit != 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"8.264811372870109665580646414654919646529224699888394e-20\",\n        \"0x1.864b7049feb3dcfe49ea910db778157cbe9c2021b44E-16#171\",\n        \"0.0007337187065343299500100945131574173571435306249470578\",\n        \"0x0.003015c1d959ec54ab97dc58b77c22566586c06119b810#171\",\n        Nearest,\n        \"-0.0007337187065343298673619807844563207013370664783978612\",\n        \"-0x0.003015c1d959ec53254c6c0eb8c845581b9c2f53623ff8#171\",\n        Greater,\n    );\n    // - Limb::WIDTH <= exp_diff < TWICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && sticky_bit != 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && a2 >= LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"4.2850537238606374652351877988811796373898773e-22\",\n        \"0x2.0607fd4819748c532aad3528693c1e3c1966E-18#146\",\n        \"978.49328809934495391839880801989439981236569\",\n        \"0x3d2.7e4820fe314caadcb9a156bef2f1c8e53c#146\",\n        Nearest,\n        \"-978.49328809934495391839837951452201374861917\",\n        \"-0x3d2.7e4820fe314caadcb79b4ec1aad85458e9#146\",\n        Less,\n    );\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && sticky_bit == 0 in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"0.4575080253178526499352273198671695352442\",\n        \"0x0.751f3ef665d0ca4dfa2d089979c4e9600#130\",\n        \"184366716174337778394.1535133791267987587\",\n        \"0x9fe9a278b38ab22da.274ca71ed919c918#130\",\n        Nearest,\n        \"-184366716174337778393.6960053538089461089\",\n        \"-0x9fe9a278b38ab22d9.b22d68287348fecc#130\",\n        Less,\n    );\n    // - x_exp == y_exp && a2 != 0 first time in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"229.1456159244630209666077998586332154002628588961962846344\",\n        \"0xe5.254715d158717849f7198986a38cb415eeea3464b1df38#189\",\n        \"175.1335582002789888688278442018847623084238889142385801004\",\n        \"0xaf.2230dec64f958583522e37252cf610378914f3127d0bb0#189\",\n        Nearest,\n        \"54.01205772418403209777995565674845309183896998195770453405\",\n        \"0x36.0316370b08dbf2c6a4eb52617696a3de65d5415234d388#189\",\n        Equal,\n    );\n    // - exp_diff == TWICE_WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"563971925627753843356041629019151473018178607215.42\",\n        \"0x62c960337e963a378ba6626ea422d8a5e623986f.6c#165\",\n        \"1301375421.83361702516620516356439489325145225661938\",\n        \"0x4d9169bd.d567ece47a47ef60371d48c969ba8765d4#165\",\n        Nearest,\n        \"563971925627753843356041629019151473016877231793.59\",\n        \"0x62c960337e963a378ba6626ea422d8a598922eb1.98#165\",\n        Greater,\n    );\n    // - exp_diff == Limb::WIDTH in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"226.9305090753243797994707628568605406194\",\n        \"0xe2.ee35d7bf263fda8c632644ad7c49d98#130\",\n        \"4262448175090788889452.984188256984861391\",\n        \"0xe71159efd3a67e736c.fbf3c2f8db72fb8#130\",\n        Nearest,\n        \"-4262448175090788889226.053679181660481592\",\n        \"-0xe71159efd3a67e728a.0dbdeb39b533210#130\",\n        Less,\n    );\n    // - TWICE_WIDTH <= exp_diff < THRICE_WIDTH && a2 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - rm == Nearest && diff_2 == 0 in sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"0.0001220703125\",\n        \"0x0.0008000000000000000000000000000000000000#145\",\n        \"8.2855746158774225568154012162196749515653053e-50\",\n        \"0x1.f0000fc000000000000003fffffffffffffcE-41#145\",\n        Nearest,\n        \"0.0001220703125\",\n        \"0x0.0008000000000000000000000000000000000000#145\",\n        Greater,\n    );\n    // - Limb::WIDTH < exp_diff < TWICE_WIDTH && a2 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"0.0156250000000000000000000000252435487789932816416198\",\n        \"0x0.040000000000000000000001ffffffc00000000003f#167\",\n        \"2.11758236813575084767080625169910490512847748461541e-22\",\n        \"0xf.ffffffffffffffffffffffffffffffffff0000000E-19#167\",\n        Nearest,\n        \"0.0156249999999999999997882417884299736942262010164499\",\n        \"0x0.03ffffffffffffffff000001ffffffc00000000003f0#167\",\n        Less,\n    );\n    // - exp_diff >= THRICE_WIDTH && a2 < LIMB_HIGH_BIT in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"1.028440348325753776346855739098344065614209916020987e62\",\n        \"0x4.000000000000000000000000000000000000000000E+51#168\",\n        \"0.00781238079073842683897073489057921223679527623088422\",\n        \"0x0.01fffe000007e000000038000007fffffffffe000000#168\",\n        Nearest,\n        \"1.028440348325753776346855739098344065614209916020987e62\",\n        \"0x4.000000000000000000000000000000000000000000E+51#168\",\n        Greater,\n    );\n    // - exp_diff < Limb::WIDTH && a2 == 0 first time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    // - exp_diff < Limb::WIDTH && a2 != 0 second time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"32767.9999999999999999999999999999999999999999996\",\n        \"0x7fff.fffffffffffffffffffffffffffffffffff8#156\",\n        \"32768.0000000000000000069388939039072268369037424\",\n        \"0x8000.000000000000007ffffffffffff80000000#156\",\n        Nearest,\n        \"-6.93889390390722683690374277451135137549581608853e-18\",\n        \"-0x7.ffffffffffff800000008000000000000000000E-15#156\",\n        Equal,\n    );\n    // - exp_diff < Limb::WIDTH && a2 == 0 second time in\n    //   sub_float_significands_same_prec_gt_2w_lt_3w\n    test(\n        \"137438953471.99999999999999999999999999999\",\n        \"0x1fffffffff.ffffffffffffffffffffffff#133\",\n        \"137438953472.0\",\n        \"0x2000000000.000000000000000000000000#133\",\n        Nearest,\n        \"-1.2621774483536188886587657044524579674771e-29\",\n        \"-0x1.000000000000000000000000000000000E-24#133\",\n        Equal,\n    );\n\n    // - in sub_float_significands_same_prec_ge_3w\n    // - x_exp == y_exp in sub_float_significands_same_prec_ge_3w\n    // - k < 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    // - x_exp > y_exp in sub_float_significands_same_prec_ge_3w\n    // - exp_diff == 1 in sub_float_significands_same_prec_ge_3w\n    // - !goto_sub_d1_no_lose && !goto_sub_d1_lose in sub_float_significands_same_prec_ge_3w\n    // - limb < LIMB_HIGH_BIT in sub_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 in sub_float_significands_same_prec_ge_3w\n    // - goto_exact_normalize in sub_float_significands_same_prec_ge_3w\n    // - limb != 0 in sub_float_significands_same_prec_ge_3w\n    // - exp_diff == 0 && limb != 0 && leading_zeros == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n    // - k >= 0 && xs[k] < ys[k] in sub_float_significands_same_prec_ge_3w\n    // - !goto_exact_normalize in sub_float_significands_same_prec_ge_3w\n    // - limb == 0 in sub_float_significands_same_prec_ge_3w\n    // - out[usize::exact_from(k)] != 0 in sub_float_significands_same_prec_ge_3w\n    // - limb == 0 && leading_zeros != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Nearest,\n        \"-3.186183822264904554057760795535423611182209110385237572148e-58\",\n        \"-0x2.000000000000000000000000000000000000000000000000E-48#192\",\n        Equal,\n    );\n    // - k >= 0 && xs[k] >= ys[k] in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"3.186183822264904554057760795535423611182209110385237572148e-58\",\n        \"0x2.000000000000000000000000000000000000000000000000E-48#192\",\n        Equal,\n    );\n    // - exp_diff == 0 && limb != 0 && leading_zeros != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Nearest,\n        \"0.9999999999999999999999999999999999999999999999999999999997\",\n        \"0x0.fffffffffffffffffffffffffffffffffffffffffffffffe#192\",\n        Equal,\n    );\n    // - 2 <= exp_diff < prec in sub_float_significands_same_prec_ge_3w\n    // - dm != 0 && m == 0 in sub_float_significands_same_prec_ge_3w\n    // - sx != 0 in sub_float_significands_same_prec_ge_3w\n    // - !out[n - 1].get_highest_bit() in sub_float_significands_same_prec_ge_3w\n    // - round_bit == 0 in sub_float_significands_same_prec_ge_3w\n    // - round_bit == 0 && sticky_bit == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#192\",\n        \"0.5\",\n        \"0x0.800000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"1.5\",\n        \"0x1.800000000000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n    // - limb == 0 && leading_zeros == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0\",\n        \"0x1.000000000000000000000000000000000000000000000000#193\",\n        \"1.0000000000000000000000000000000000000000000000000000000002\",\n        \"0x1.000000000000000000000000000000000000000000000001#193\",\n        Nearest,\n        \"-1.5930919111324522770288803977677118055911045551926187860739e-58\",\n        \"-0x1.000000000000000000000000000000000000000000000000E-48#193\",\n        Equal,\n    );\n    // - sx == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2.0\",\n        \"0x2.000000000000000000000000000000000000000000000000#193\",\n        \"0.5\",\n        \"0x0.8000000000000000000000000000000000000000000000000#193\",\n        Nearest,\n        \"1.5\",\n        \"0x1.800000000000000000000000000000000000000000000000#193\",\n        Equal,\n    );\n    // - round_bit != 0 || sticky_bit != 0 in sub_float_significands_same_prec_ge_3w\n    // - out_power_of_2 || round_bit == 0 in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest && !out_power_of_2 first time in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest && (round_bit == 0 || (round_bit != 0 && sticky_bit == 0 && (out[0] &\n    //   shift_bit == 0 || prec == 1))) in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"-3.0\",\n        \"-0x3.000000000000000000000000000000000000000000000000#192\",\n        Less,\n    );\n    // - out[usize::exact_from(k)] == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000002\",\n        \"0x1.000000000000000000000000000000000000000000000001#193\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#193\",\n        Nearest,\n        \"-1.5930919111324522770288803977677118055911045551926187860739e-58\",\n        \"-0x1.000000000000000000000000000000000000000000000000E-48#193\",\n        Equal,\n    );\n    // - round_bit != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000006\",\n        \"0x1.000000000000000000000000000000000000000000000004#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"-2.9999999999999999999999999999999999999999999999999999999994\",\n        \"-0x2.fffffffffffffffffffffffffffffffffffffffffffffffc#192\",\n        Equal,\n    );\n    // - rm == Nearest && round_bit != 0 && (round_bit == 0 || sticky_bit != 0 || (out[0] &\n    //   shift_bit != 0 && prec == 1)) in sub_float_significands_same_prec_ge_3w\n    // - rm == Nearest && !out_power_of_2 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.000000000000000000000000000000000000000000000000000000001\",\n        \"0x1.000000000000000000000000000000000000000000000006#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        Nearest,\n        \"-2.9999999999999999999999999999999999999999999999999999999987\",\n        \"-0x2.fffffffffffffffffffffffffffffffffffffffffffffff8#192\",\n        Greater,\n    );\n    // - sticky_bit_2 == 0 && k > 0 third time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"0.5\",\n        \"0x0.8000000000000000000000000000000000000000000000000#193\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#193\",\n        Nearest,\n        \"-3.5\",\n        \"-0x3.800000000000000000000000000000000000000000000000#193\",\n        Equal,\n    );\n    // - sticky_bit_2 != 0 || k <= 0 third time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        \"0.5000000000000000000000000000000000000000000000000000000002\",\n        \"0x0.800000000000000000000000000000000000000000000001#192\",\n        Nearest,\n        \"3.5\",\n        \"0x3.800000000000000000000000000000000000000000000000#192\",\n        Greater,\n    );\n    // - dm != 0 && m != 0 in sub_float_significands_same_prec_ge_3w\n    // - out[n - 1].get_highest_bit() in sub_float_significands_same_prec_ge_3w\n    test(\n        \"7.28057116938384227432903448367767196428679514765398378973101e-48\",\n        \"0xa.a3fc2da1f20fb2d9771f86d3c16a444cd62d5d139e3935f24E-40#198\",\n        \"3.5123473778825578958968695187657587760357139395948269588971e-27\",\n        \"0x1.1646de419a6dbd3466f3081403a87d719b7a765a1ec69e4658E-22#198\",\n        Nearest,\n        \"-3.51234737788255789588958894759637493376138490511114928693281e-27\",\n        \"-0x1.1646de419a6dbd345c4f0be661b66dbec20356d34b05340208E-22#198\",\n        Greater,\n    );\n    // - exp_diff >= prec in sub_float_significands_same_prec_ge_3w\n    // - exp_diff > prec in sub_float_significands_same_prec_ge_3w\n    // - exp_diff != prec + 1 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n        \"0.023991386767031193042066748710708351501952890752924613005724\",\n        \"0x0.06244cad8cd272134e34b325815ad281733f2c06231a0ee744#193\",\n        Nearest,\n        \"4.1322282880219162156901559575161649173615955518072607291207e86\",\n        \"0xd.4b575f05941ee41ef3ef9a37068d9d453f22eb3bf80bd1b0E+71#193\",\n        Greater,\n    );\n    // - dm == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"6.442552350746554109885349691592991892989624685631192235549e-6\",\n        \"0x0.00006c168d38e231899f0fc85d1888549d5177bdceaee72e15060#192\",\n        \"1476808010161862576835936576709144.7975622615653024045505082\",\n        \"0x48cff00a780a50d34bb694ada218.cc2d0a55f25f9f9126258#192\",\n        Nearest,\n        \"-1476808010161862576835936576709144.7975558190129516579963983\",\n        \"-0x48cff00a780a50d34bb694ada218.cc2c9e3f6526bd5f9c868#192\",\n        Less,\n    );\n    // - exp_diff == prec + 1 in sub_float_significands_same_prec_ge_3w\n    // - sticky_bit_2 != 0 || k <= 0 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"29249291732025621624535078208.59212499364958152526111994335\",\n        \"0x5e827271f9e9d261e7cb5540.979580eade814aae28ae9d3c8#192\",\n        \"1.7056859397843570965021420438616279890690624515282312011749e-30\",\n        \"0x2.2986d80d04731f28b49380410e3f4711dc2cc5f113c594a0E-25#192\",\n        Nearest,\n        \"29249291732025621624535078208.59212499364958152526111994335\",\n        \"0x5e827271f9e9d261e7cb5540.979580eade814aae28ae9d3c8#192\",\n        Greater,\n    );\n    // - limb > LIMB_HIGH_BIT in sub_float_significands_same_prec_ge_3w\n    // - y0 != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1958139908729.1847354007541959640287427302874567071533816044\",\n        \"0x1c7ea3bd279.2f4ad1b8a7190307771c7e5767590237208b90#192\",\n        \"688604646855.2266320591592881661509057171162297144871538944\",\n        \"0xa054090dc7.3a048f025074a63da83a500a235d2b8fd9766d#192\",\n        Nearest,\n        \"1269535261873.9581033415949077978778370131712269926662277102\",\n        \"0x1279632c4b1.f54642b656a45cc9cee22e4d43fbd6a7471524#192\",\n        Greater,\n    );\n    // - y0 == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2473299914875391681216.10395653853096422269749051583697615\",\n        \"0x8613ee70797f97a2c0.1a9ce54d32239153edab6ff15dad1c0#193\",\n        \"7716446651886500012256.87778108230244207876352217543002925\",\n        \"0x1a24f3592677b2760e0.e0b642d189564d3b4c797ad9c9cde8#193\",\n        Nearest,\n        \"-5243146737011108331040.7738245437714778560660316595930531\",\n        \"-0x11c3b4721edfb8fbe20.c6195d845732bbe75ece0ae86c20cc#193\",\n        Equal,\n    );\n    // - exp_diff == prec in sub_float_significands_same_prec_ge_3w\n    // - sticky_bit_2 != 0 || k <= 0 first time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"4.0635838402455207229400698207668893925379768151364313942222e-23\",\n        \"0x3.1202ecf10ff40b477337957dede18bd7b746884ec977474eE-19#194\",\n        \"1174582238252884689829665592721065057.76655867827770290150723\",\n        \"0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d4#194\",\n        Nearest,\n        \"-1174582238252884689829665592721065057.76655867827770290150718\",\n        \"-0xe237601fa3ed6d89b0ae33e924c461.c43d3085aaefab6b5d0#194\",\n        Greater,\n    );\n    // - rm == Nearest && out_power_of_2 first time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"22300745198530623141535718272648361505980416.0\",\n        \"0x1000000000000000000000000000000000000.000000000000#192\",\n        \"8.470329472543003387009805160583577341645369940072346001613e-22\",\n        \"0x3.ffffffffffffffe000000003ff0000003ffffffc00000000E-18#192\",\n        Nearest,\n        \"22300745198530623141535718272648361505980416.0\",\n        \"0x1000000000000000000000000000000000000.000000000000#192\",\n        Greater,\n    );\n    // - sticky_bit_2 == 0 && k > 0 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.6849966666969146159452711670928107852024276704905067469395e66\",\n        \"0xf.ffffffffffff01fffff00000000000000000000000000000E+54#193\",\n        \"33554432.00000000000000044408920985006261616945266723632812\",\n        \"0x2000000.0000000000001ffffffffffffffffffffffffffffe#193\",\n        Nearest,\n        \"1.6849966666969146159452711670928107852024276704905067469395e66\",\n        \"0xf.ffffffffffff01fffff00000000000000000000000000000E+54#193\",\n        Greater,\n    );\n    // - limb == LIMB_HIGH_BIT in sub_float_significands_same_prec_ge_3w\n    // - l >= 0 first time in sub_float_significands_same_prec_ge_3w\n    // - xs[l] != yl_shifted in sub_float_significands_same_prec_ge_3w\n    // - l >= 0 && xs[l] <= yl_shifted in sub_float_significands_same_prec_ge_3w\n    // - goto_sub_d1_no_lose || goto_sub_d1_lose in sub_float_significands_same_prec_ge_3w\n    test(\n        \"2047.9999999999999999999999999999747564510329303127198868805\",\n        \"0x7ff.fffffffffffffffffffffffe00000000003c000003fffc#193\",\n        \"4095.99999999999999988897769753748434595763683319091796875\",\n        \"0xfff.fffffffffffff800000000000000000000000000000000#193\",\n        Nearest,\n        \"-2047.9999999999999998889776975375095895066039028781980818695\",\n        \"-0x7ff.fffffffffffff80000000001ffffffffffc3fffffc0004#193\",\n        Equal,\n    );\n    // - sticky_bit_2 == 0 && k > 0 first time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"0.0002442598197376355528831482438462803411504065058668775410457\",\n        \"0x0.001001fff000000000000003ffff00000001fffffff07fffffe#192\",\n        \"5.834076822994820350447560050418866475553361427251759468222e-62\",\n        \"0x1.8000000000000000000000000000000000001c00007ffffeE-51#192\",\n        Nearest,\n        \"0.00024425981973763555288314824384628034115040650586687754104564\",\n        \"0x0.001001fff000000000000003ffff00000001fffffff07fffffc#192\",\n        Less,\n    );\n    // - l >= 0 && xs[l] > yl_shifted in sub_float_significands_same_prec_ge_3w\n    test(\n        \"127.99999999999999999999998841947063540272586186468301133273\",\n        \"0x7f.fffffffffffffffffff1fffff00007ffffffffffffffff8#192\",\n        \"255.99999999999999999999999979320484686174308128214782699291\",\n        \"0xff.ffffffffffffffffffffc00000000000000000000000ff#192\",\n        Nearest,\n        \"-128.0000000000000000000000113737342114590172194174648156602\",\n        \"-0x80.0000000000000000000dc0000ffff80000000000000100#192\",\n        Less,\n    );\n    // - out_power_of_2 && round_bit != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"81129638414606681695789005144064.0\",\n        \"0x400000000000000000000000000.0000000000000000000000#193\",\n        \"6.46392625738094777466974989455420015132331189664152496326e-27\",\n        \"0x2.001ffffffffe0000001fffff000000ffffff80000000000eE-22#193\",\n        Nearest,\n        \"81129638414606681695789005144063.999999999999999999999999994\",\n        \"0x3ffffffffffffffffffffffffff.fffffffffffffffffffffe#193\",\n        Greater,\n    );\n    // - rm == Nearest && out_power_of_2 second time in sub_float_significands_same_prec_ge_3w\n    test(\n        \"9.5367431640625e-7\",\n        \"0x0.00001000000000000000000000000000000000000000000000000#192\",\n        \"7.596455102175746880546879414772134233793171691679642324806e-65\",\n        \"0x8.00000ffffffffffe000000000000000000000000001ffffE-54#192\",\n        Nearest,\n        \"9.536743164062499999999999999999999999999999999999999999998e-7\",\n        \"0xf.fffffffffffffffffffffffffffffffffffffffffffffffE-6#192\",\n        Less,\n    );\n    // - xs[l] == yl_shifted in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1180591620717411303423.9999999999999999999999999999999999998\",\n        \"0x3fffffffffffffffff.ffffffffffffffffffffffffffffffc#192\",\n        \"2361183241434822606847.9999999999999999930619531290400259223\",\n        \"0x7fffffffffffffffff.ffffffffffffff8003ffffffffffff8#192\",\n        Nearest,\n        \"-1180591620717411303423.9999999999999999930619531290400259225\",\n        \"-0x3fffffffffffffffff.ffffffffffffff8003ffffffffffffc#192\",\n        Equal,\n    );\n    // - l < 0 first time in sub_float_significands_same_prec_ge_3w\n    // - l < 0 second time in sub_float_significands_same_prec_ge_3w\n    // - yl_shifted != 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"32767.999999999999999999999999999999999999999999999999999995\",\n        \"0x7fff.ffffffffffffffffffffffffffffffffffffffffffff8#192\",\n        \"65535.99999999999999999999999999999999999999999999999999999\",\n        \"0xffff.ffffffffffffffffffffffffffffffffffffffffffff#192\",\n        Nearest,\n        \"-32767.999999999999999999999999999999999999999999999999999995\",\n        \"-0x7fff.ffffffffffffffffffffffffffffffffffffffffffff8#192\",\n        Equal,\n    );\n    // - yl_shifted == 0 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"34359738367.999999999999999999999999999999999999999999999989\",\n        \"0x7ffffffff.fffffffffffffffffffffffffffffffffffffff0#192\",\n        \"68719476735.99999999999999999999999999999999999999999999999\",\n        \"0xfffffffff.fffffffffffffffffffffffffffffffffffffff#192\",\n        Nearest,\n        \"-34359738368.0\",\n        \"-0x800000000.000000000000000000000000000000000000000#192\",\n        Equal,\n    );\n\n    // - neg in sub_float_significands_same_prec_ge_3w\n    // - rm == Down || rm == Floor in sub_float_significands_same_prec_ge_3w\n    // - (rm == Down || rm == Floor) && !out_power_of_2 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        Down,\n        \"-2.9999999999999999999999999999999999999999999999999999999994\",\n        \"-0x2.fffffffffffffffffffffffffffffffffffffffffffffffc#192\",\n        Greater,\n    );\n    // - !neg in sub_float_significands_same_prec_ge_3w\n    test(\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        Down,\n        \"2.9999999999999999999999999999999999999999999999999999999994\",\n        \"0x2.fffffffffffffffffffffffffffffffffffffffffffffffc#192\",\n        Less,\n    );\n    // - rm == Up || rm == Ceiling in sub_float_significands_same_prec_ge_3w\n    test(\n        \"1.0000000000000000000000000000000000000000000000000000000003\",\n        \"0x1.000000000000000000000000000000000000000000000002#192\",\n        \"4.0\",\n        \"0x4.000000000000000000000000000000000000000000000000#192\",\n        Up,\n        \"-3.0\",\n        \"-0x3.000000000000000000000000000000000000000000000000#192\",\n        Less,\n    );\n    // - (rm == Down || rm == Floor) && out_power_of_2 in sub_float_significands_same_prec_ge_3w\n    test(\n        \"5.392603845001725202291044579550746038551121674218581060912e-33\",\n        \"0x1.c0000000fffffffffffffffffffffffffffffffffffffffeE-27#192\",\n        \"1329227995784915872903807060280344576.0\",\n        \"0x1000000000000000000000000000000.000000000000000000#192\",\n        Ceiling,\n        \"-1329227995784915872903807060280344575.9999999999999999999998\",\n        \"-0xffffffffffffffffffffffffffffff.ffffffffffffffffff#192\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Nearest, \"-0.5\", \"-0x0.8#2\", Equal,\n    );\n    test(\n        \"0.5\", \"0x0.8#1\", \"3.0\", \"0x3.0#2\", Nearest, \"-2.0\", \"-0x2.0#2\", Greater,\n    );\n    test(\n        \"0.2\", \"0x0.4#1\", \"4.0\", \"0x4.0#2\", Nearest, \"-4.0\", \"-0x4.0#2\", Less,\n    );\n    test(\n        \"0.00374222828352849\",\n        \"0x0.00f5402c178824#46\",\n        \"1.07183972513958531257713938927815e-11\",\n        \"0xb.c8f5eafa12eb9821601f1dd6aeE-10#107\",\n        Nearest,\n        \"0.00374222827281009532032311766811006\",\n        \"0x0.00f5402c0bbf2e1505ed1467de9fe#107\",\n        Less,\n    );\n    test(\n        \"2589062031404.0\",\n        \"0x25ad01f682c.0#43\",\n        \"4351572166934988.581719655389852344796925751245753159273257621838622031922945531041952618\\\n        810238932316\",\n        \"0xf75bb593981cc.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n        Nearest,\n        \"-4348983104903584.58171965538985234479692575124575315927325762183862203192294553104195261\\\n        8810238932316\",\n        \"-0xf7360891a19a0.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n        Equal,\n    );\n\n    // - in sub_float_significands_general\n    // - in exponent_shift_compare\n    // - sdiff_exp >= 0 in exponent_shift_compare\n    // - diff_exp == 0 first time in exponent_shift_compare\n    // - xi >= 0 && yi >= 0 && xs[xi] == ys[yi] in exponent_shift_compare\n    // - xi < 0 in exponent_shift_compare\n    // - xi < 0 && yi < 0 in exponent_shift_compare\n    // - sign == Equal in sub_float_significands_general\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    // - diff_exp != 0 first time in exponent_shift_compare\n    // - diff_exp < Limb::WIDTH in exponent_shift_compare\n    // - diff_exp != 0 second time in exponent_shift_compare\n    // - (yi < 0 && lasty == 0) || high_dif != 0 || dif != 1 in exponent_shift_compare\n    // - high_dif == 0 in exponent_shift_compare\n    // - dif.is_power_of_2() in exponent_shift_compare\n    // - yi < 0 && lasty == 0 in exponent_shift_compare\n    // - sign != Equal in sub_float_significands_general\n    // - sign != Less in sub_float_significands_general\n    // - !neg in sub_float_significands_general\n    // - max(out_prec, x_prec) + 2 > exp_diff in sub_float_significands_general\n    // - shift_x != 0 in sub_float_significands_general\n    // - shift_y == 0 in sub_float_significands_general\n    // - cancel >= exp_diff in sub_float_significands_general\n    // - out_len + cancel1 <= xs_len in sub_float_significands_general\n    // - out_len + cancel2 > 0 in sub_float_significands_general\n    // - cancel2 >= 0 in sub_float_significands_general\n    // - out_len + cancel2 <= ys_len in sub_float_significands_general\n    // - rm == Nearest in sub_float_significands_general\n    // - rm == Nearest && carry <= Limb::power_of_2(sh - 1) && (0 >= carry || carry >=\n    //   Limb::power_of_2(sh - 1)) in sub_float_significands_general\n    // - !goto_truncate in sub_float_significands_general\n    // - ixs_len <= 0 && iys_len <= 0 in sub_float_significands_general\n    // - !goto_truncate && !goto_end_of_sub second time in sub_float_significands_general\n    // - rm != Nearest || cmp_low == 0 in sub_float_significands_general\n    // - !goto_end_of_sub in sub_float_significands_general\n    // - out[out_len - 1] >> (Limb::WIDTH - 1) != 0 in sub_float_significands_general\n    // - cancel != 0 in sub_float_significands_general\n    test(\n        \"2.0\", \"0x2.0#1\", \"1.0\", \"0x1.0#2\", Nearest, \"1.0\", \"0x1.0#2\", Equal,\n    );\n    // - sdiff_exp < 0 in exponent_shift_compare\n    // - sign == Less in sub_float_significands_general\n    // - neg in sub_float_significands_general\n    test(\n        \"1.0\", \"0x1.0#2\", \"2.0\", \"0x2.0#1\", Nearest, \"-1.0\", \"-0x1.0#2\", Equal,\n    );\n    // - xi < 0 || yi < 0 || xs[xi] != ys[yi] in exponent_shift_compare\n    // - xi >= 0 in exponent_shift_compare\n    // - yi >= 0 second time in exponent_shift_compare\n    // - xs[xi] < ys[yi] in exponent_shift_compare\n    // - diff_exp == 0 second time in exponent_shift_compare\n    // - shift_y != 0 in sub_float_significands_general\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.5\", \"0x1.8#2\", Nearest, \"-0.5\", \"-0x0.8#2\", Equal,\n    );\n    // - xs[xi] >= ys[yi] in exponent_shift_compare\n    test(\n        \"1.5\", \"0x1.8#2\", \"1.0\", \"0x1.0#1\", Nearest, \"0.5\", \"0x0.8#2\", Equal,\n    );\n    // - shift_x == 0 in sub_float_significands_general\n    // - cancel < exp_diff in sub_float_significands_general\n    // - ixs_len > 0 || iys_len > 0 in sub_float_significands_general\n    // - ixs_len <= 0 in sub_float_significands_general\n    // - iys_len condition in sub_float_significands_general\n    // - cmp_low == 0 first time in sub_float_significands_general\n    // - rm == Nearest && (sh != 0 || k != 0) in sub_float_significands_general\n    // - cmp_low == 0 second time in sub_float_significands_general\n    // - !goto_truncate && !goto_end_of_sub first time in sub_float_significands_general\n    // - cancel == 0 in sub_float_significands_general\n    test(\n        \"0.5\", \"0x0.8#1\", \"1.5\", \"0x1.8#2\", Nearest, \"-1.0\", \"-0x1.0#2\", Equal,\n    );\n    // - !dif.is_power_of_2() in exponent_shift_compare\n    test(\n        \"0.5\", \"0x0.8#1\", \"2.0\", \"0x2.0#2\", Nearest, \"-1.5\", \"-0x1.8#2\", Equal,\n    );\n    // - cmp_low != 0 first time in sub_float_significands_general\n    // - cmp_low > 0 in sub_float_significands_general\n    // - cmp_low > 0 && rm == Nearest in sub_float_significands_general\n    // - cmp_low > 0 && rm == Nearest && xx == yy in sub_float_significands_general\n    // - rm == Nearest && cmp_low != 0 in sub_float_significands_general\n    // - (out[0] >> sh) & 1 == 0 in sub_float_significands_general\n    test(\n        \"0.5\", \"0x0.8#1\", \"3.0\", \"0x3.0#2\", Nearest, \"-2.0\", \"-0x2.0#2\", Greater,\n    );\n    // - (out[0] >> sh) & 1 != 0 in sub_float_significands_general\n    // - cmp_low >= 0 in sub_float_significands_general\n    // - cmp_low >= 0 && !carry in sub_float_significands_general\n    test(\n        \"4.0\", \"0x4.0#1\", \"1.2\", \"0x1.4#3\", Nearest, \"3.0\", \"0x3.0#3\", Greater,\n    );\n    // - cmp_low >= 0 && carry in sub_float_significands_general\n    test(\n        \"4.0\", \"0x4.0#1\", \"0.5\", \"0x0.8#2\", Nearest, \"4.0\", \"0x4.0#2\", Greater,\n    );\n    // - rm == Nearest && carry > Limb::power_of_2(sh - 1) in sub_float_significands_general\n    // - goto_truncate in sub_float_significands_general\n    test(\n        \"3.0\", \"0x3.0#2\", \"0.2\", \"0x0.4#1\", Nearest, \"3.0\", \"0x3.0#2\", Greater,\n    );\n    // - rm == Nearest && carry <= Limb::power_of_2(sh - 1) && 0 < carry && carry <\n    //   Limb::power_of_2(sh - 1) in sub_float_significands_general\n    test(\n        \"4.0\", \"0x4.0#1\", \"0.8\", \"0x0.c#2\", Nearest, \"3.0\", \"0x3.0#2\", Less,\n    );\n    // - max(out_prec, x_prec) + 2 <= exp_diff in sub_float_significands_general\n    // - in round_helper\n    // - dest_prec >= x_prec in round_helper\n    // - !increment_exp in sub_float_significands_general\n    // - inexact == 0 && rm != Down && rm != Floor in sub_float_significands_general\n    test(\n        \"0.2\", \"0x0.4#1\", \"4.0\", \"0x4.0#2\", Nearest, \"-4.0\", \"-0x4.0#2\", Less,\n    );\n    // - diff_exp >= Limb::WIDTH in exponent_shift_compare first time\n    test(\n        \"8.82188e11\",\n        \"0xc.d668E+9#18\",\n        \"9.75459983374e122\",\n        \"0x1.79c17f063aE+102#40\",\n        Nearest,\n        \"-9.75459983374e122\",\n        \"-0x1.79c17f063aE+102#40\",\n        Less,\n    );\n    // - cancel2 < 0 in sub_float_significands_general\n    // - out_len - neg_cancel2 <= ys_len in sub_float_significands_general\n    test(\n        \"3.29008365861415556134836580980448399733562188e-9\",\n        \"0xe.217c389f8c9fd22042f5ed70da20cfb9f1ecE-8#146\",\n        \"3719044561792922503530448846362960.3599330496921301151502834994\",\n        \"0xb75cf116bc625ef1eab58f3c9950.5c2492852d5fb6817443c180#205\",\n        Nearest,\n        \"-3719044561792922503530448846362960.359933046402046456536127938\",\n        \"-0xb75cf116bc625ef1eab58f3c9950.5c2492770be37de1e7a3ef60#205\",\n        Less,\n    );\n    // - out_len + cancel1 > xs_len in sub_float_significands_general\n    // - cancel1 < xs_len in sub_float_significands_general\n    test(\n        \"1.07183972513958531257713938927815e-11\",\n        \"0xb.c8f5eafa12eb9821601f1dd6aeE-10#107\",\n        \"0.00374222828352849\",\n        \"0x0.00f5402c178824#46\",\n        Nearest,\n        \"-0.00374222827281009532032311766811006\",\n        \"-0x0.00f5402c0bbf2e1505ed1467de9fe#107\",\n        Greater,\n    );\n    // - out_len + cancel2 > ys_len in sub_float_significands_general\n    test(\n        \"2589062031404.0\",\n        \"0x25ad01f682c.0#43\",\n        \"4351572166934988.581719655389852344796925751245753159273257621838622031922945531041952618\\\n        810238932316\",\n        \"0xf75bb593981cc.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n        Nearest,\n        \"-4348983104903584.58171965538985234479692575124575315927325762183862203192294553104195261\\\n        8810238932316\",\n        \"-0xf7360891a19a0.94eb944f56fd85d744c7e812bf078ed9a4f5d3086fdab71e98a907840097016cb76fdc\\\n        #330\",\n        Equal,\n    );\n    // - yi >= 0 && lasty != 0 in exponent_shift_compare\n    // - xi < 0 fourth time in exponent_shift_compare\n    // - lasty == 0 in exponent_shift_compare\n    // - yi < 0 || ys[yi] != 0 in exponent_shift_compare\n    // - yi >= 0 fourth time in exponent_shift_compare\n    test(\n        \"0.002\",\n        \"0x0.008#2\",\n        \"1.107886492190627864290739752375593855464628579e-38\",\n        \"0x3.c51af197224960473945f6944424f855697e2E-32#149\",\n        Nearest,\n        \"0.001953124999999999999999999999999999988921135078\",\n        \"0x0.007ffffffffffffffffffffffffffffc3ae50e68#149\",\n        Less,\n    );\n    // - cmp_low > 0 && rm == Nearest && xx < yy in sub_float_significands_general\n    // - goto_truncate || goto_end_of_sub first time in sub_float_significands_general\n    // - goto_truncate || goto_end_of_sub second time in sub_float_significands_general\n    test(\n        \"1.521287e-9\",\n        \"0x6.88ac4E-8#21\",\n        \"6.842391932190563625e-20\",\n        \"0x1.431f7157e61b20d0E-16#62\",\n        Nearest,\n        \"1.5212870962270854807e-9\",\n        \"0x6.88ac3ffebce08eaE-8#62\",\n        Less,\n    );\n    // - out_len - neg_cancel2 > ys_len in sub_float_significands_general\n    test(\n        \"0.00678514868524062\",\n        \"0x0.01bcabe7b39c71#49\",\n        \"492541199943575879969.43922949854802247248767794847124160758\",\n        \"0x1ab361dbc0e97d4121.7071582bb3c5bd22b8f59cfc93c72a98#194\",\n        Nearest,\n        \"-492541199943575879969.43244434986278185350564935536210679008\",\n        \"-0x1ab361dbc0e97d4121.6eb4ac4400294c22b8f59cfc93c72a98#194\",\n        Equal,\n    );\n    // - rm == Nearest && sh == 0 && k == 0 in sub_float_significands_general\n    // - rm == Nearest && cmp_low >= 0 in sub_float_significands_general\n    // - rm == Nearest && cmp_low >= 0 && yy < half in sub_float_significands_general\n    // - rm == Nearest && cmp_low >= 0 && cmp_low <= 0 in sub_float_significands_general\n    test(\n        \"5.7505515877842013577e-7\",\n        \"0x9.a5d7d56cabed47dE-6#64\",\n        \"1.1758894e-14\",\n        \"0x3.4f515E-12#22\",\n        Nearest,\n        \"5.7505514701952590309e-7\",\n        \"0x9.a5d7d21d5a9d47dE-6#64\",\n        Equal,\n    );\n    // - rm == Nearest && cmp_low < 0 in sub_float_significands_general\n    // - rm == Nearest && cmp_low < 0 && yy < half in sub_float_significands_general\n    // - cmp_low < 0 in sub_float_significands_general first time\n    // - cmp_low < 0 && rm == Nearest in sub_float_significands_general\n    // - rm == Nearest && (xx > yy || sh > 0 || cmp_low == -1) in sub_float_significands_general\n    test(\n        \"8319983682.218895978935307677994592087137128849954503237724\",\n        \"0x1efe8e042.3809911ec0c7f99b114d2930720001b00aa46846#192\",\n        \"1.88392800575e35\",\n        \"0x2.4487b7174E+29#37\",\n        Nearest,\n        \"-188392800574747474298435817696599997.78110402106469232200542\",\n        \"-0x24487b7173fffffffffffe10171fbd.c7f66ee13f380664eec#192\",\n        Less,\n    );\n    // - rm == Nearest && cmp_low < 0 && yy >= half in sub_float_significands_general\n    // - rm == Nearest && xx < yy && sh <= 0 && cmp_low != -1 in sub_float_significands_general\n    // - goto_end_of_sub in sub_float_significands_general\n    test(\n        \"2.36288970224581301467472547462526069521e-27\",\n        \"0xb.b3518c72d51185c09977eb6e009c2c0E-23#128\",\n        \"3.413020751e-12\",\n        \"0x3.c0ae105E-10#30\",\n        Nearest,\n        \"-3.413020751029435178256669624768773569e-12\",\n        \"-0x3.c0ae104fffff44cae738d2aee7a3f668E-10#128\",\n        Greater,\n    );\n    // - xi >= 0 fourth time in exponent_shift_compare\n    // - diff_exp >= Limb::WIDTH in exponent_shift_compare second time\n    // - xs[xi] == yy in exponent_shift_compare\n    test(\n        \"1125899906842624.0\",\n        \"0x4000000000000.000000000000#98\",\n        \"1.166815364554e-61\",\n        \"0x2.ffffffff80E-51#39\",\n        Nearest,\n        \"1125899906842624.0\",\n        \"0x4000000000000.000000000000#98\",\n        Greater,\n    );\n    // - 0 < diff_exp < Limb::WIDTH && yi >= 0 in exponent_shift_compare\n    // - xs[xi] != yy in exponent_shift_compare\n    test(\n        \"9671406556917033397649408.0\",\n        \"0x800000000000000000000.0000#99\",\n        \"65536.015624999999999999946\",\n        \"0x10000.03ffffffffffffff00#87\",\n        Nearest,\n        \"9671406556917033397583871.98438\",\n        \"0x7fffffffffffffffeffff.fc00#99\",\n        Less,\n    );\n    // - diff_exp == 0 && yi >= 0 in exponent_shift_compare\n    test(\n        \"1.3877787807814456370485565165946e-17\",\n        \"0xf.ffffffffffffe007ffffffff8E-15#101\",\n        \"128.0000000000000000000000000008077935669463159990585083341\",\n        \"0x80.00000000000000000000003ffffffffffffe0000000000#190\",\n        Nearest,\n        \"-127.9999999999999999861222121929933371964607508331127668586\",\n        \"-0x7f.ffffffffffffff00000000400001ff7ffffe0008000000#190\",\n        Equal,\n    );\n    // - rm == Nearest && xx == yy && sh <= 0 && cmp_low != -1 in sub_float_significands_general\n    // - cmp_low < 0 in sub_float_significands_general second time\n    test(\n        \"2.220581574517834801066783605693002897371795957735742517101e-16\",\n        \"0x1.0003fffffe00000000007ffffffffffffffffffffff000feE-13#192\",\n        \"8.881784e-16\",\n        \"0x4.00000E-13#21\",\n        Nearest,\n        \"-6.661202622483417522322269739033559602628204042264257482898e-16\",\n        \"-0x2.fffc000001ffffffffff80000000000000000000000fff00E-13#192\",\n        Greater,\n    );\n    // - diff_exp < Limb::WIDTH && yi < 0 in exponent_shift_compare\n    test(\n        \"-1.8e-12\",\n        \"-0x1.fcE-10#7\",\n        \"-524288.0000000000017621525\",\n        \"-0x80000.0000000001f00078#81\",\n        Nearest,\n        \"524287.9999999999999573739\",\n        \"0x7ffff.fffffffffff40078#81\",\n        Equal,\n    );\n    // - (yi >= 0 || lasty != 0) && high_dif == 0 && dif == 1 in exponent_shift_compare\n    // - xi >= 0 third time in exponent_shift_compare\n    // - yi >= 0 && diff_exp != 0 in exponent_shift_compare\n    // - high_dif != 0 in exponent_shift_compare\n    // - dif == 0 in exponent_shift_compare\n    test(\n        \"3.99999999999999999957\",\n        \"0x3.fffffffffffffff80#67\",\n        \"4.0\",\n        \"0x4.00000000000000000#68\",\n        Nearest,\n        \"-4.33680868994201773603e-19\",\n        \"-0x8.0000000000000000E-16#68\",\n        Equal,\n    );\n    // - xi < 0 third time in exponent_shift_compare\n    // - cancel1 >= xs_len in sub_float_significands_general\n    test(\n        \"6.77626357803440271254657930615627554e-21\",\n        \"0x1.ffffffffffffffffffffc01fff800E-17#117\",\n        \"7.0e-21\",\n        \"0x2.0E-17#4\",\n        Nearest,\n        \"-6.99280860154738521672154778865541105e-46\",\n        \"-0x3.fe000800000000000000000000000E-38#117\",\n        Equal,\n    );\n    // - yi >= 0 && diff_exp == 0 in exponent_shift_compare\n    // - dif != 0 in exponent_shift_compare\n    test(\n        \"1.45519152351431153846750277125465800054371356958e-11\",\n        \"0x1.00000001ffffffffffffffffffffffffffffffcE-9#155\",\n        \"1.455191523514311538467502771254658000526607875496523229114700566610230516799191954282190\\\n        364e-11\",\n        \"0x1.00000001fffffffffffffffffffffffc0000000000000000000000000000fffffffffff87f8E-9#301\",\n        Nearest,\n        \"1.710569408086637569000134230861426729009957349416545362986887684243433631257558931055548\\\n        3967e-49\",\n        \"0x3.ffffffbfffffffffffffffffffff00000000000780800000000000000000000000000000000E-41#301\",\n        Equal,\n    );\n    // - xs[xi] == 0 in exponent_shift_compare\n    // - xi < 0 second time in exponent_shift_compare\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    // - xi >= 0 second time in exponent_shift_compare\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    // - rm != Nearest in sub_float_significands_general\n    // - rm != Nearest && carry == 0 in sub_float_significands_general\n    test(\n        \"2.0\", \"0x2.0#1\", \"1.0\", \"0x1.0#2\", Down, \"1.0\", \"0x1.0#2\", Equal,\n    );\n    // - rm != Nearest && carry != 0 in sub_float_significands_general\n    // - rm == Floor || rm == Down in sub_float_significands_general\n    test(\n        \"0.5\", \"0x0.8#1\", \"3.0\", \"0x3.0#2\", Down, \"-2.0\", \"-0x2.0#2\", Greater,\n    );\n    // - rm == Ceiling || rm == Up in sub_float_significands_general\n    // - (rm == Ceiling || rm == Up) && !carry in sub_float_significands_general\n    test(\n        \"0.5\", \"0x0.8#1\", \"3.0\", \"0x3.0#2\", Up, \"-3.0\", \"-0x3.0#2\", Less,\n    );\n    // - (rm == Ceiling || rm == Up) && carry in sub_float_significands_general\n    test(\n        \"4.0\", \"0x4.0#1\", \"0.5\", \"0x0.8#2\", Up, \"4.0\", \"0x4.0#2\", Greater,\n    );\n    // - cmp_low < 0 && (rm == Floor || rm == Down) in sub_float_significands_general\n    test(\n        \"0.1952943266615587806218370459\",\n        \"0x0.31fecf1a1b1180be748fe5b8#91\",\n        \"5.04217616231508488430478600129900999076e-13\",\n        \"0x8.decb552f6cf9a70a64d0c0d7a367802E-11#127\",\n        Down,\n        \"0.195294326661054563005605537435615043117\",\n        \"0x0.31fecf1a1a8394092199161d8f59b2f38#127\",\n        Less,\n    );\n    // - cmp_low < 0 && (rm == Ceiling || rm == Up) in sub_float_significands_general\n    test(\n        \"1.1718977744e31\",\n        \"0x9.3ea0f304E+25#34\",\n        \"1910333504687680.9305\",\n        \"0x6c9702df30e40.ee38#64\",\n        Ceiling,\n        \"1.171897774363652748e31\",\n        \"0x9.3ea0f303ffff937E+25#64\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#2\", Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        Ceiling,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        Up,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000E-7#69\",\n        Exact,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        Floor,\n        \"-0.0\",\n        \"-0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        Ceiling,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        Up,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n    test(\n        \"7.0e-9\",\n        \"0x2.0E-7#2\",\n        \"7.450580596923828125e-9\",\n        \"0x2.00000000000000000000000000000000000000000000000000E-7#200\",\n        Exact,\n        \"0.0\",\n        \"0x0.0\",\n        Equal,\n    );\n\n    test(\n        \"-too_small\",\n        \"-0x2.50888E-268435456#19\",\n        \"-too_small\",\n        \"-0x3.10E-268435456#10\",\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n}\n\n#[test]\nfn sub_round_fail() {\n    assert_panic!(Float::one_prec(1).sub_round(Float::from_unsigned_prec(4u8, 1).0, Exact));\n    assert_panic!({\n        Float::one_prec(1).sub_round_val_ref(&Float::from_unsigned_prec(4u8, 1).0, Exact)\n    });\n    assert_panic!(Float::one_prec(1).sub_round_ref_val(Float::from_unsigned_prec(4u8, 1).0, Exact));\n    assert_panic!({\n        Float::one_prec(1).sub_round_ref_ref(&Float::from_unsigned_prec(4u8, 1).0, Exact)\n    });\n\n    assert_panic!(parse_hex_string(\"0x1.0#1\").sub_round(parse_hex_string(\"0x0.001#1\"), Exact));\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").sub_round_val_ref(&parse_hex_string(\"0x0.001#1\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").sub_round_ref_val(parse_hex_string(\"0x0.001#1\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0#1\").sub_round_ref_ref(&parse_hex_string(\"0x0.001#1\"), Exact)\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .sub_round(parse_hex_string(\"0x2.0000000000000002#64\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .sub_round_val_ref(&parse_hex_string(\"0x2.0000000000000002#64\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .sub_round_ref_val(parse_hex_string(\"0x2.0000000000000002#64\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#64\")\n            .sub_round_ref_ref(&parse_hex_string(\"0x2.0000000000000002#64\"), Exact)\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .sub_round(parse_hex_string(\"0x2.0000000000000001#65\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .sub_round_val_ref(&parse_hex_string(\"0x2.0000000000000001#65\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .sub_round_ref_val(parse_hex_string(\"0x2.0000000000000001#65\"), Exact)\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.0000000000000000#65\")\n            .sub_round_ref_ref(&parse_hex_string(\"0x2.0000000000000001#65\"), Exact)\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").sub_round(\n            parse_hex_string(\"0x2.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").sub_round_val_ref(\n            &parse_hex_string(\"0x2.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").sub_round_ref_val(\n            parse_hex_string(\"0x2.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#128\").sub_round_ref_ref(\n            &parse_hex_string(\"0x2.00000000000000000000000000000002#128\"),\n            Exact\n        )\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").sub_round(\n            parse_hex_string(\"0x2.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").sub_round_val_ref(\n            &parse_hex_string(\"0x2.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").sub_round_ref_val(\n            parse_hex_string(\"0x2.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.00000000000000000000000000000000#129\").sub_round_ref_ref(\n            &parse_hex_string(\"0x2.00000000000000000000000000000003#129\"),\n            Exact\n        )\n    );\n\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\").sub_round(\n            parse_hex_string(\"0x2.000000000000000000000000000000000000000000000002#192\"),\n            Exact\n        )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\")\n            .sub_round_val_ref(\n                &parse_hex_string(\"0x2.000000000000000000000000000000000000000000000002#192\"),\n                Exact\n            )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\")\n            .sub_round_ref_val(\n                parse_hex_string(\"0x2.000000000000000000000000000000000000000000000002#192\"),\n                Exact\n            )\n    );\n    assert_panic!(\n        parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\")\n            .sub_round_ref_ref(\n                &parse_hex_string(\"0x2.000000000000000000000000000000000000000000000002#192\"),\n                Exact\n            )\n    );\n\n    assert_panic!(parse_hex_string(\"0x0.8#1\").sub_round(parse_hex_string(\"0x3.0#2\"), Exact));\n    assert_panic!(\n        parse_hex_string(\"0x0.8#1\").sub_round_val_ref(&parse_hex_string(\"0x3.0#2\"), Exact)\n    );\n    assert_panic!({\n        parse_hex_string(\"0x0.8#1\").sub_round_ref_val(parse_hex_string(\"0x3.0#2\"), Exact)\n    });\n    assert_panic!(\n        parse_hex_string(\"0x0.8#1\").sub_round_ref_ref(&parse_hex_string(\"0x3.0#2\"), Exact)\n    );\n\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_round_assign(Float::from_unsigned_prec(4u8, 1).0, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_round_assign_ref(&Float::from_unsigned_prec(4u8, 1).0, Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0#1\");\n        x.sub_round_assign(parse_hex_string(\"0x0.001#1\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0#1\");\n        x.sub_round_assign_ref(&parse_hex_string(\"0x0.001#1\"), Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#64\");\n        x.sub_round_assign(parse_hex_string(\"0x2.0000000000000002#64\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#64\");\n        x.sub_round_assign_ref(&parse_hex_string(\"0x2.0000000000000002#64\"), Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#65\");\n        x.sub_round_assign(parse_hex_string(\"0x2.0000000000000001#65\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.0000000000000000#65\");\n        x.sub_round_assign_ref(&parse_hex_string(\"0x2.0000000000000001#65\"), Exact)\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#128\");\n        x.sub_round_assign(\n            parse_hex_string(\"0x2.00000000000000000000000000000002#128\"),\n            Exact,\n        )\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#128\");\n        x.sub_round_assign_ref(\n            &parse_hex_string(\"0x2.00000000000000000000000000000002#128\"),\n            Exact,\n        )\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#129\");\n        x.sub_round_assign(\n            parse_hex_string(\"0x2.00000000000000000000000000000003#129\"),\n            Exact,\n        )\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.00000000000000000000000000000000#129\");\n        x.sub_round_assign_ref(\n            &parse_hex_string(\"0x2.00000000000000000000000000000003#129\"),\n            Exact,\n        )\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\");\n        x.sub_round_assign(\n            parse_hex_string(\"0x2.000000000000000000000000000000000000000000000002#192\"),\n            Exact,\n        )\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x1.000000000000000000000000000000000000000000000000#192\");\n        x.sub_round_assign_ref(\n            &parse_hex_string(\"0x2.000000000000000000000000000000000000000000000002#192\"),\n            Exact,\n        )\n    });\n\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x0.8#1\");\n        x.sub_round_assign(parse_hex_string(\"0x3.0#2\"), Exact)\n    });\n    assert_panic!({\n        let mut x = parse_hex_string(\"0x0.8#1\");\n        x.sub_round_assign_ref(&parse_hex_string(\"0x3.0#2\"), Exact)\n    });\n}\n\n#[test]\nfn test_sub_prec_round() {\n    let test = |s, s_hex, t, t_hex, prec: u64, rm, out: &str, out_hex: &str, o_out: Ordering| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let (diff, o) = x.clone().sub_prec_round(y.clone(), prec, rm);\n        assert!(diff.is_valid());\n\n        assert_eq!(diff.to_string(), out);\n        assert_eq!(to_hex_string(&diff), out_hex);\n        assert_eq!(o, o_out);\n\n        let (diff_alt, o_alt) = x.clone().sub_prec_round_val_ref(&y, prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = x.sub_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = x.sub_prec_round_ref_ref(&y, prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_prec_round_assign(y.clone(), prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_prec_round_assign_ref(&y, prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o_out);\n\n        let (diff_alt, o_alt) = add_prec_round_naive(x.clone(), -&y, prec, rm);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_diff, rug_o) = rug_sub_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Float::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_diff)),\n                ComparableFloatRef(&diff),\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"NaN\", \"NaN\", \"-0.0\", \"-0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-0.0\", \"-0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"NaN\",\n        \"NaN\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    // Note different behavior for Floor\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"-0.0\", \"-0x0.0\", 1, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"-0.0\", \"-0x0.0\", \"0.0\", \"0x0.0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal,\n    );\n\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Floor, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Ceiling, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Down, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Up, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Nearest, \"NaN\", \"NaN\", Equal,\n    );\n    test(\n        \"123.0\", \"0x7b.0#7\", \"NaN\", \"NaN\", 1, Exact, \"NaN\", \"NaN\", Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-Infinity\",\n        \"-Infinity\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"Infinity\",\n        \"Infinity\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"-0.0\",\n        \"-0x0.0\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0.0\",\n        \"0x0.0\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Floor,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Down,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Up,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n    test(\n        \"NaN\",\n        \"NaN\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Exact,\n        \"NaN\",\n        \"NaN\",\n        Equal,\n    );\n\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Floor,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Down,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Exact,\n        \"Infinity\",\n        \"Infinity\",\n        Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123.0\",\n        \"-0x7b.0#7\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#1\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2.0\", \"-0x2.0#2\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#1\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#1\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", 1, Floor, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", 1, Down, \"2.0\", \"0x2.0#1\", Less,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", 1, Up, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\n        \"1.0\", \"0x1.0#2\", \"-2.0\", \"-0x2.0#2\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#2\",\n        \"-2.0\",\n        \"-0x2.0#2\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        1,\n        Floor,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        1,\n        Ceiling,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        1,\n        Down,\n        \"2.0\",\n        \"0x2.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        1,\n        Up,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        1,\n        Nearest,\n        \"4.0\",\n        \"0x4.0#1\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        10,\n        Floor,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        10,\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        10,\n        Down,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        10,\n        Up,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        10,\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2.0\",\n        \"-0x2.00#10\",\n        10,\n        Exact,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"4.56\",\n        \"0x4.90#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"4.56\",\n        \"0x4.90#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"4.555\",\n        \"0x4.8e#10\",\n        Less,\n    );\n\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-1.729\",\n        \"-0x1.ba8#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-1.729\",\n        \"-0x1.ba8#10\",\n        Less,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-1.727\",\n        \"-0x1.ba0#10\",\n        Greater,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"1.729\",\n        \"0x1.ba8#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"1.729\",\n        \"0x1.ba8#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"1.727\",\n        \"0x1.ba0#10\",\n        Less,\n    );\n\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-4.56\",\n        \"-0x4.90#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-4.56\",\n        \"-0x4.90#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-4.555\",\n        \"-0x4.8e#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        1,\n        Floor,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        1,\n        Ceiling,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        1,\n        Down,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        1,\n        Up,\n        \"2.0\",\n        \"0x2.0#1\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        1,\n        Nearest,\n        \"1.0\",\n        \"0x1.0#1\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        20,\n        Floor,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        20,\n        Ceiling,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        20,\n        Down,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        20,\n        Up,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        20,\n        Nearest,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-0.0002\",\n        \"-0x0.001#1\",\n        20,\n        Exact,\n        \"1.000244\",\n        \"0x1.00100#20\",\n        Equal,\n    );\n\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 10, Floor, \"-0.0\", \"-0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 10, Down, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 10, Up, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 10, Nearest, \"0.0\", \"0x0.0\", Equal,\n    );\n    test(\n        \"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 10, Exact, \"0.0\", \"0x0.0\", Equal,\n    );\n    // - rm != Nearest in round_helper\n    // - (rm == Up || rm == Ceiling) && sb | rb != 0 in round_helper\n    // - !increment third time in round_helper\n    test(\n        \"13104.5238818416080254535\",\n        \"0x3330.861d1ed0acba8a3a#77\",\n        \"2.854e-35\",\n        \"0x2.5fE-29#10\",\n        17,\n        Ceiling,\n        \"13104.6\",\n        \"0x3330.a#17\",\n        Greater,\n    );\n    // - sh != 0 && (rm != Nearest && rb != 0) in round_helper\n    // - rm == Down || rm == Floor in round_helper\n    test(\n        \"2.8979948183270175762296398212780973e-12\",\n        \"0x3.2fb688bd98f0271a53708f0554568E-10#115\",\n        \"8.270488650862e23\",\n        \"0xa.f2268a8074E+19#42\",\n        2,\n        Down,\n        \"-6.0e23\",\n        \"-0x8.0E+19#2\",\n        Greater,\n    );\n    // - (rm == Up || rm == Ceiling) && sb | rb == 0 in round_helper\n    test(\n        \"1.503764257662314e22\",\n        \"0x3.2f31367a9800E+18#48\",\n        \"7.3839e-20\",\n        \"0x1.5cb2E-16#17\",\n        39,\n        Ceiling,\n        \"1.503764257662e22\",\n        \"0x3.2f31367a98E+18#39\",\n        Greater,\n    );\n    // - increment third time in round_helper\n    test(\n        \"4.70916604581e-30\",\n        \"0x5.f8363584bE-25#39\",\n        \"341290809831481093.63402342431195212374059\",\n        \"0x4bc822eed1c5f05.a24f5bf051591756f951#139\",\n        1,\n        Floor,\n        \"-6.0e17\",\n        \"-0x8.0E+14#1\",\n        Less,\n    );\n    // - cmp_low > 0 && (rm == Floor || rm == Down) in sub_float_significands_general\n    test(\n        \"559935046210054011882951826578284118061013900.5853448\",\n        \"0x191bbd3588c78488c2f4d122814d5fb34edb8c.95d928#170\",\n        \"3.027932e11\",\n        \"0x4.67fe2E+9#22\",\n        63,\n        Down,\n        \"5.599350462100540119e44\",\n        \"0x1.91bbd3588c78488cE+37#63\",\n        Less,\n    );\n    // - cmp_low > 0 && (rm == Ceiling || rm == Up) in sub_float_significands_general\n    // - cmp_low > 0 && (rm == Ceiling || rm == Up) && !carry in sub_float_significands_general\n    test(\n        \"1.3111820218254081035114504135472568116036464005e-6\",\n        \"0x0.000015ff7be10e865ada82cd25acef5baa9c89c25f4#152\",\n        \"2.51465891601e-20\",\n        \"0x7.6c05c64a8E-17#38\",\n        128,\n        Ceiling,\n        \"1.311182021825382956922290308381837960614e-6\",\n        \"0x0.000015ff7be10e85e41a26687dacef5baa9ca#128\",\n        Greater,\n    );\n    // - cmp_low > 0 && (rm == Ceiling || rm == Up) && carry in sub_float_significands_general\n    test(\n        \"1.19e-7\",\n        \"0x2.0E-6#6\",\n        \"2722258925226302905881161717745111269376.0000001187\",\n        \"0x7ffffff800000000000003fe7c0000000.000001fe0#164\",\n        28,\n        Up,\n        \"-2.72225894e39\",\n        \"-0x8.000000E+32#28\",\n        Less,\n    );\n\n    test(\n        \"-1.948077668464e-10\",\n        \"-0xd.63182fa960E-9#41\",\n        \"-too_big\",\n        \"-0x7.c300ddfc112a6cf2a0bb36cf8E+268435455#100\",\n        3,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"1.948077668464e-10\",\n        \"0xd.63182fa960E-9#41\",\n        \"too_big\",\n        \"0x7.c300ddfc112a6cf2a0bb36cf8E+268435455#100\",\n        3,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test(\n        \"too_small\",\n        \"0x1.08E-268435456#6\",\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.08E-268435456#6\",\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\nfn sub_prec_round_fail() {\n    assert_panic!(Float::one_prec(1).sub_prec_round(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).sub_prec_round_val_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).sub_prec_round_ref_val(Float::two_prec(1), 0, Floor));\n    assert_panic!(Float::one_prec(1).sub_prec_round_ref_ref(&Float::two_prec(1), 0, Floor));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_prec_round_assign(Float::two_prec(1), 0, Floor)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_prec_round_assign_ref(&Float::two_prec(1), 0, Floor)\n    });\n\n    assert_panic!(Float::one_prec(1).sub_prec_round(-Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).sub_prec_round_val_ref(&-Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).sub_prec_round_ref_val(-Float::two_prec(1), 1, Exact));\n    assert_panic!(Float::one_prec(1).sub_prec_round_ref_ref(&-Float::two_prec(1), 1, Exact));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_prec_round_assign(-Float::two_prec(1), 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_prec_round_assign_ref(&-Float::two_prec(1), 1, Exact)\n    });\n}\n\n#[test]\nfn test_sub_rational() {\n    let test = |s, s_hex, t, out: &str, out_hex: &str| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let diff = x.clone() - y.clone();\n        assert!(diff.is_valid());\n\n        assert_eq!(diff.to_string(), out);\n        assert_eq!(to_hex_string(&diff), out_hex);\n\n        let diff_alt = x.clone() - &y;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        let diff_alt = &x - y.clone();\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        let diff_alt = &x - &y;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n\n        let diff_alt = y.clone() - x.clone();\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloat(-&diff), ComparableFloat(diff_alt));\n        let diff_alt = y.clone() - &x;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloat(-&diff), ComparableFloat(diff_alt));\n        let diff_alt = &y - x.clone();\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloat(-&diff), ComparableFloat(diff_alt));\n        let diff_alt = &y - &x;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloat(-&diff), ComparableFloat(diff_alt));\n\n        let mut diff_alt = x.clone();\n        diff_alt -= y.clone();\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        let mut diff_alt = x.clone();\n        diff_alt -= &y;\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sub_rational(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::from(&y)\n            ))),\n            ComparableFloatRef(&diff)\n        );\n\n        let diff_alt = sub_rational_prec_round_naive(x.clone(), y, x.significant_bits(), Nearest).0;\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    };\n    test(\"NaN\", \"NaN\", \"-123\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"-123\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"-123\", \"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\", \"0\", \"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\", \"0\", \"-0.0\", \"-0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"-123\", \"1.0e2\", \"0x8.0E+1#1\");\n    test(\"-0.0\", \"-0x0.0\", \"-123\", \"1.0e2\", \"0x8.0E+1#1\");\n    test(\"0.0\", \"0x0.0\", \"-1/3\", \"0.2\", \"0x0.4#1\");\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", \"0.2\", \"0x0.4#1\");\n    test(\"123.0\", \"0x7b.0#7\", \"0\", \"123.0\", \"0x7b.0#7\");\n\n    // - different signs in float_rational_diff_exponent_range\n    test(\"1.0\", \"0x1.0#1\", \"-2\", \"4.0\", \"0x4.0#1\");\n    test(\"1.0\", \"0x1.0#2\", \"-2\", \"3.0\", \"0x3.0#2\");\n    test(\"1.0\", \"0x1.000#10\", \"-2\", \"3.0\", \"0x3.00#10\");\n    test(\"1.0\", \"0x1.000#10\", \"-1/3\", \"1.334\", \"0x1.558#10\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"-1/3\",\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n    );\n    // - same sign and log_x_abs.abs_diff(log_y_abs) > 1 in float_rational_diff_exponent_range\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"-1/50000\", \"1.0\", \"0x1.0#1\");\n    test(\"1.0\", \"0x1.0#1\", \"1\", \"0.0\", \"0x0.0\");\n    // - same sign and log_x_abs.abs_diff(log_y_abs) <= 1 in float_rational_diff_exponent_range\n    // - same sign and log_x_abs.abs_diff(log_y_abs) == 1 in float_rational_diff_exponent_range\n    test(\"2.0\", \"0x2.0#1\", \"1\", \"1.0\", \"0x1.0#1\");\n    // - same sign and log_x_abs == log_y_abs in float_rational_diff_exponent_range\n    test(\"1.0\", \"0x1.0#1\", \"3/2\", \"-0.5\", \"-0x0.8#1\");\n    test(\"2.0\", \"0x2.0#1\", \"1\", \"1.0\", \"0x1.0#1\");\n    test(\"1.0\", \"0x1.0#1\", \"3/2\", \"-0.5\", \"-0x0.8#1\");\n}\n\n#[test]\nfn test_sub_rational_prec() {\n    let test = |s, s_hex, t, prec, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (diff, o) = x.clone().sub_rational_prec(y.clone(), prec);\n        assert!(diff.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(diff.to_string(), out);\n        assert_eq!(to_hex_string(&diff), out_hex);\n\n        let (diff_alt, o_alt) = x.clone().sub_rational_prec_val_ref(&y, prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let (diff_alt, o_alt) = x.sub_rational_prec_ref_val(y.clone(), prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let (diff_alt, o_alt) = x.sub_rational_prec_ref_ref(&y, prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_rational_prec_assign(y.clone(), prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_rational_prec_assign_ref(&y, prec);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let (diff_alt, o_alt) = sub_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n\n        let (rug_diff, rug_o) = rug_sub_rational_prec(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_diff)),\n            ComparableFloatRef(&diff)\n        );\n        assert_eq!(rug_o, o);\n    };\n    test(\"NaN\", \"NaN\", \"-123\", 1, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", 1, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", \"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", 1, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", 1, \"0.2\", \"0x0.4#1\", Less);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 2, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"-2\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#2\", \"-2\", 2, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"-2\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.000#10\", \"-2\", 2, \"3.0\", \"0x3.0#2\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        100,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"-1/50000\", 10, \"1.0\", \"0x1.000#10\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"1\", 10, \"0.0\", \"0x0.0\", Equal);\n}\n\n#[test]\nfn sub_rational_prec_fail() {\n    assert_panic!(Float::NAN.sub_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.sub_rational_prec_val_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::NAN.sub_rational_prec_ref_val(Rational::ZERO, 0));\n    assert_panic!(Float::NAN.sub_rational_prec_ref_ref(&Rational::ZERO, 0));\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.sub_rational_prec_assign(Rational::ZERO, 0)\n    });\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.sub_rational_prec_assign_ref(&Rational::ZERO, 0)\n    });\n}\n\n#[test]\nfn test_sub_rational_round() {\n    let test_helper =\n        |s, s_hex, y: Rational, rm, out: &str, out_hex: &str, o_out, extreme: bool| {\n            let x = parse_hex_string(s_hex);\n            assert_eq!(x.to_string(), s);\n\n            let (diff, o) = x.clone().sub_rational_round(y.clone(), rm);\n            assert!(diff.is_valid());\n            assert_eq!(o, o_out);\n\n            assert_eq!(diff.to_string(), out);\n            assert_eq!(to_hex_string(&diff), out_hex);\n\n            if !extreme {\n                let (diff_alt, o_alt) = x.clone().sub_rational_round_val_ref(&y, rm);\n                assert!(diff_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n                assert_eq!(o_alt, o);\n\n                let (diff_alt, o_alt) = x.sub_rational_round_ref_val(y.clone(), rm);\n                assert!(diff_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n                assert_eq!(o_alt, o);\n\n                let (diff_alt, o_alt) = x.sub_rational_round_ref_ref(&y, rm);\n                assert!(diff_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n                assert_eq!(o_alt, o);\n\n                let mut diff_alt = x.clone();\n                let o_alt = diff_alt.sub_rational_round_assign(y.clone(), rm);\n                assert!(diff_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n                assert_eq!(o_alt, o);\n\n                let mut diff_alt = x.clone();\n                let o_alt = diff_alt.sub_rational_round_assign_ref(&y, rm);\n                assert!(diff_alt.is_valid());\n                assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n                assert_eq!(o_alt, o);\n            }\n\n            if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n                let (rug_diff, rug_o) = rug_sub_rational_round(\n                    &rug::Float::exact_from(&x),\n                    &rug::Rational::exact_from(&y),\n                    rm,\n                );\n                assert_eq!(\n                    ComparableFloatRef(&Float::from(&rug_diff)),\n                    ComparableFloatRef(&diff)\n                );\n                assert_eq!(rug_o, o);\n            }\n\n            let (diff_alt, o_alt) =\n                sub_rational_prec_round_naive(x.clone(), y, x.significant_bits(), rm);\n            assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n            assert_eq!(o_alt, o);\n        };\n    let test = |s, s_hex, t, rm, out: &str, out_hex: &str, o_out| {\n        test_helper(\n            s,\n            s_hex,\n            Rational::from_str(t).unwrap(),\n            rm,\n            out,\n            out_hex,\n            o_out,\n            false,\n        );\n    };\n    test(\"NaN\", \"NaN\", \"-123\", Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0\", Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"-123\", Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123\",\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\"0.0\", \"0x0.0\", \"-123\", Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"-123\", Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123\",\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123\",\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"-123\", Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123\",\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Floor, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Ceiling, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Down, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Up, \"123.0\", \"0x7b.0#7\", Equal);\n    test(\n        \"123.0\", \"0x7b.0#7\", \"0\", Nearest, \"123.0\", \"0x7b.0#7\", Equal,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"0\", Exact, \"123.0\", \"0x7b.0#7\", Equal);\n\n    test(\"0.0\", \"0x0.0\", \"-1/3\", Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\"1.0\", \"0x1.0#1\", \"-2\", Floor, \"2.0\", \"0x2.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", Down, \"2.0\", \"0x2.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", Up, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test(\"1.0\", \"0x1.0#2\", \"-2\", Floor, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"-2\", Ceiling, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"-2\", Down, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"-2\", Up, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"-2\", Nearest, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#2\", \"-2\", Exact, \"3.0\", \"0x3.0#2\", Equal);\n\n    test(\"1.0\", \"0x1.000#10\", \"-2\", Floor, \"3.0\", \"0x3.00#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2\",\n        Ceiling,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.000#10\", \"-2\", Down, \"3.0\", \"0x3.00#10\", Equal);\n    test(\"1.0\", \"0x1.000#10\", \"-2\", Up, \"3.0\", \"0x3.00#10\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-2\",\n        Nearest,\n        \"3.0\",\n        \"0x3.00#10\",\n        Equal,\n    );\n    test(\"1.0\", \"0x1.000#10\", \"-2\", Exact, \"3.0\", \"0x3.00#10\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        Floor,\n        \"1.332\",\n        \"0x1.550#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        Ceiling,\n        \"1.334\",\n        \"0x1.558#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        Down,\n        \"1.332\",\n        \"0x1.550#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        Up,\n        \"1.334\",\n        \"0x1.558#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        Nearest,\n        \"1.334\",\n        \"0x1.558#10\",\n        Greater,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"-1/3\",\n        Floor,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"-1/3\",\n        Ceiling,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"-1/3\",\n        Down,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"-1/3\",\n        Up,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"-1/3\",\n        Nearest,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Floor,\n        \"3.4749259869231262\",\n        \"0x3.7994bfdddaf84#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Ceiling,\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Down,\n        \"3.4749259869231262\",\n        \"0x3.7994bfdddaf84#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Up,\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Nearest,\n        \"3.4749259869231266\",\n        \"0x3.7994bfdddaf86#53\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Floor,\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Ceiling,\n        \"2.8082593202564601\",\n        \"0x2.ceea1533304dc#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Down,\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Up,\n        \"2.8082593202564601\",\n        \"0x2.ceea1533304dc#53\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Nearest,\n        \"2.8082593202564596\",\n        \"0x2.ceea1533304da#53\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Floor,\n        \"-2.8082593202564601\",\n        \"-0x2.ceea1533304dc#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Ceiling,\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Down,\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Up,\n        \"-2.8082593202564601\",\n        \"-0x2.ceea1533304dc#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Nearest,\n        \"-2.8082593202564596\",\n        \"-0x2.ceea1533304da#53\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Floor,\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Ceiling,\n        \"-3.4749259869231262\",\n        \"-0x3.7994bfdddaf84#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Down,\n        \"-3.4749259869231262\",\n        \"-0x3.7994bfdddaf84#53\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Up,\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Nearest,\n        \"-3.4749259869231266\",\n        \"-0x3.7994bfdddaf86#53\",\n        Less,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"-1/50000\", Floor, \"1.0\", \"0x1.0#1\", Less);\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1/50000\", Ceiling, \"2.0\", \"0x2.0#1\", Greater,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"-1/50000\", Down, \"1.0\", \"0x1.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"-1/50000\", Up, \"2.0\", \"0x2.0#1\", Greater);\n    test(\n        \"1.0\", \"0x1.0#1\", \"-1/50000\", Nearest, \"1.0\", \"0x1.0#1\", Less,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"1\", Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", Exact, \"0.0\", \"0x0.0\", Equal);\n\n    // - max_exponent > i64::from(Float::MAX_EXPONENT) - 2 in add_rational_prec_round\n    test_helper(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n        true,\n    );\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n        true,\n    );\n    // - min_exponent >= Float::MAX_EXPONENT in add_rational_prec_round\n    // - both signs positive in float_rational_sum_sign\n    // - float_rational_sum_sign(x, &y) && (rm == Ceiling || rm == Up || rm == Nearest) in\n    //   add_rational_prec_round\n    test_helper(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n        true,\n    );\n    // - float_rational_sum_sign(x, &y) && (rm == Floor || rm == Down) in add_rational_prec_round\n    test_helper(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n        true,\n    );\n    // - !float_rational_sum_sign(x, &y) && (rm == Ceiling || rm == Down) in add_rational_prec_round\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n        true,\n    );\n    // - signs different and x.lt_abs(y) in float_rational_sum_sign\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) + 1),\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n        true,\n    );\n    // - both signs negative in float_rational_sum_sign\n    // - !float_rational_sum_sign(x, &y) && (rm == Floor || rm == Up || rm == Nearest) in\n    //   add_rational_prec_round\n    test_helper(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n        true,\n    );\n    test_helper(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        Rational::NEGATIVE_ONE - Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n        true,\n    );\n    test_helper(\n        \"1.0\",\n        \"0x1.0#1\",\n        Rational::ONE + Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n        true,\n    );\n}\n\n#[test]\nfn sub_rational_round_fail() {\n    assert_panic!(Float::one_prec(1).sub_rational_round(-Rational::from_unsigneds(1u32, 3), Exact));\n    assert_panic!(\n        Float::one_prec(1).sub_rational_round_val_ref(&-Rational::from_unsigneds(1u32, 3), Exact)\n    );\n    assert_panic!(\n        Float::one_prec(1).sub_rational_round_ref_val(-Rational::from_unsigneds(1u32, 3), Exact)\n    );\n    assert_panic!(\n        Float::one_prec(1).sub_rational_round_ref_ref(&-Rational::from_unsigneds(1u32, 3), Exact)\n    );\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_rational_round_assign(-Rational::from_unsigneds(1u32, 3), Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_rational_round_assign_ref(&-Rational::from_unsigneds(1u32, 3), Exact)\n    });\n}\n\n#[test]\nfn test_sub_rational_prec_round() {\n    let test = |s, s_hex, t, prec, rm, out: &str, out_hex: &str, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = Rational::from_str(t).unwrap();\n\n        let (diff, o) = x.clone().sub_rational_prec_round(y.clone(), prec, rm);\n        assert!(diff.is_valid());\n        assert_eq!(o, o_out);\n\n        assert_eq!(diff.to_string(), out);\n        assert_eq!(to_hex_string(&diff), out_hex);\n\n        let (diff_alt, o_alt) = x.clone().sub_rational_prec_round_val_ref(&y, prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let (diff_alt, o_alt) = x.sub_rational_prec_round_ref_val(y.clone(), prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let (diff_alt, o_alt) = x.sub_rational_prec_round_ref_ref(&y, prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_rational_prec_round_assign(y.clone(), prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.sub_rational_prec_round_assign_ref(&y, prec, rm);\n        assert!(diff_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o_alt, o);\n\n        let (diff_alt, o_alt) = sub_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_diff, rug_o) = rug_sub_rational_prec_round(\n                &rug::Float::exact_from(&x),\n                &rug::Rational::exact_from(&y),\n                prec,\n                rm,\n            );\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_diff)),\n                ComparableFloatRef(&diff)\n            );\n            assert_eq!(rug_o, o);\n        }\n    };\n    test(\"NaN\", \"NaN\", \"-123\", 1, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", 1, Down, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", 1, Up, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", \"-123\", 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", 1, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", 1, Ceiling, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", 1, Down, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", 1, Up, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", 1, Nearest, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", \"-123\", 1, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"-123\",\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", \"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", \"0\", 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\"0.0\", \"0x0.0\", \"-123\", 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"-123\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"-0.0\",\n        \"-0x0.0\",\n        \"-123\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"0.0\", \"0x0.0\", \"-1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\n        \"0.0\", \"0x0.0\", \"-1/3\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Greater,\n    );\n    test(\"0.0\", \"0x0.0\", \"-1/3\", 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\n        \"-0.0\", \"-0x0.0\", \"-1/3\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Greater,\n    );\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Floor,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Ceiling,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Down,\n        \"6.0e1\",\n        \"0x4.0E+1#1\",\n        Less,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Up,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n    test(\n        \"123.0\",\n        \"0x7b.0#7\",\n        \"0\",\n        1,\n        Nearest,\n        \"1.0e2\",\n        \"0x8.0E+1#1\",\n        Greater,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater,\n    );\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test(\n        \"1.0\", \"0x1.0#1\", \"-2\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 2, Floor, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 2, Ceiling, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 2, Down, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 2, Up, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 2, Nearest, \"3.0\", \"0x3.0#2\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"-2\", 2, Exact, \"3.0\", \"0x3.0#2\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        100,\n        Floor,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        100,\n        Ceiling,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        100,\n        Down,\n        \"1.333333333333333333333333333332\",\n        \"0x1.5555555555555555555555554#100\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        100,\n        Up,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.000#10\",\n        \"-1/3\",\n        100,\n        Nearest,\n        \"1.333333333333333333333333333334\",\n        \"0x1.5555555555555555555555556#100\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Floor,\n        \"3.473\",\n        \"0x3.79#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Ceiling,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Down,\n        \"3.473\",\n        \"0x3.79#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Up,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Nearest,\n        \"3.477\",\n        \"0x3.7a#10\",\n        Greater,\n    );\n\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Floor,\n        \"2.805\",\n        \"0x2.ce#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Down,\n        \"2.805\",\n        \"0x2.ce#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Up,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"2.809\",\n        \"0x2.cf#10\",\n        Greater,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Floor,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Ceiling,\n        \"-2.805\",\n        \"-0x2.ce#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Down,\n        \"-2.805\",\n        \"-0x2.ce#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Up,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        10,\n        Nearest,\n        \"-2.809\",\n        \"-0x2.cf#10\",\n        Less,\n    );\n\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Floor,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Ceiling,\n        \"-3.473\",\n        \"-0x3.79#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Down,\n        \"-3.473\",\n        \"-0x3.79#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Up,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        10,\n        Nearest,\n        \"-3.477\",\n        \"-0x3.7a#10\",\n        Less,\n    );\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-1/50000\",\n        10,\n        Floor,\n        \"1.0\",\n        \"0x1.000#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-1/50000\",\n        10,\n        Ceiling,\n        \"1.002\",\n        \"0x1.008#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-1/50000\",\n        10,\n        Down,\n        \"1.0\",\n        \"0x1.000#10\",\n        Less,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-1/50000\",\n        10,\n        Up,\n        \"1.002\",\n        \"0x1.008#10\",\n        Greater,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        \"-1/50000\",\n        10,\n        Nearest,\n        \"1.0\",\n        \"0x1.000#10\",\n        Less,\n    );\n\n    test(\"1.0\", \"0x1.0#1\", \"1\", 10, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"1.0\", \"0x1.0#1\", \"1\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n}\n\n#[test]\nfn sub_rational_prec_round_fail() {\n    assert_panic!(Float::one_prec(1).sub_rational_prec_round(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).sub_rational_prec_round_val_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).sub_rational_prec_round_ref_val(\n        Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::one_prec(1).sub_rational_prec_round_ref_ref(\n        &Rational::from_unsigneds(5u32, 8),\n        1,\n        Exact\n    ));\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_rational_prec_round_assign(Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n    assert_panic!({\n        let mut x = Float::one_prec(1);\n        x.sub_rational_prec_round_assign_ref(&Rational::from_unsigneds(5u32, 8), 1, Exact)\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sub_prec_round_properties_helper(\n    x: Float,\n    y: Float,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (diff, o) = x.clone().sub_prec_round(y.clone(), prec, rm);\n    assert!(diff.is_valid());\n    let (diff_alt, o_alt) = x.clone().sub_prec_round_val_ref(&y, prec, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_prec_round_ref_ref(&y, prec, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (diff_alt, o_alt) = add_prec_round_naive(x.clone(), -&y, prec, rm);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_diff, rug_o) = rug_sub_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Float::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_diff)),\n            ComparableFloatRef(&diff),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && diff.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                diff.add_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloat(\n                x.sub_prec_round_ref_ref(&diff, y.significant_bits(), Exact)\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(y.abs_negative_zero_ref())\n        );\n    }\n\n    if !extreme {\n        let r_diff = if diff.is_finite() {\n            if diff.is_normal() {\n                assert_eq!(diff.get_prec(), Some(prec));\n            }\n            let r_diff = Rational::exact_from(&x) - Rational::exact_from(&y);\n            assert_eq!(diff.partial_cmp(&r_diff), Some(o));\n            if o == Less {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if o == Greater {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n            Some(r_diff)\n        } else {\n            assert_eq!(o, Equal);\n            None\n        };\n\n        match (r_diff.is_some() && *r_diff.as_ref().unwrap() >= 0u32, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    }\n\n    let (mut diff_alt, mut o_alt) = y.sub_prec_round_ref_ref(&x, prec, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero_ref()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (diff_alt, o_alt) = x.add_prec_round_ref_val(-&y, prec, rm);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let (mut diff_alt, mut o_alt) = (-&x).add_prec_round_val_ref(&y, prec, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut diff_alt, mut o_alt) = (-&x).sub_prec_round(-&y, prec, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (d, oo) = x.sub_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(d.abs_negative_zero_ref()),\n                ComparableFloat(diff.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.sub_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn sub_prec_round_properties() {\n    float_float_unsigned_rounding_mode_quadruple_gen_var_2().test_properties(|(x, y, prec, rm)| {\n        sub_prec_round_properties_helper(x, y, prec, rm, false);\n    });\n\n    float_float_unsigned_rounding_mode_quadruple_gen_var_6().test_properties(|(x, y, prec, rm)| {\n        sub_prec_round_properties_helper(x, y, prec, rm, true);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (diff, o) = x.sub_prec_round_ref_val(Float::NAN, prec, rm);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        let (diff, o) = Float::NAN.sub_prec_round_val_ref(&x, prec, rm);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != Float::INFINITY {\n                assert_eq!(\n                    x.sub_prec_round_ref_val(Float::INFINITY, prec, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::INFINITY.sub_prec_round_val_ref(&x, prec, rm),\n                    (Float::INFINITY, Equal)\n                );\n            }\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(\n                    x.sub_prec_round_ref_val(Float::NEGATIVE_INFINITY, prec, rm),\n                    (Float::INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.sub_prec_round_val_ref(&x, prec, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (diff, o) = x.sub_prec_round_ref_val(Float::ZERO, prec, rm);\n            let mut diff_alt = x.clone();\n            let o_alt = diff_alt.set_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero()),\n                ComparableFloat(diff_alt.abs_negative_zero())\n            );\n            assert_eq!(o, o_alt);\n\n            let (diff, o) = Float::ZERO.sub_prec_round_val_ref(&x, prec, rm);\n            let mut diff_alt = -&x;\n            let o_alt = diff_alt.set_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero()),\n                ComparableFloat(diff_alt.abs_negative_zero())\n            );\n            assert_eq!(o, o_alt);\n        }\n        if rm != Floor || !x.is_positive_zero() {\n            let (diff, o) = x.sub_prec_round_ref_val(Float::NEGATIVE_ZERO, prec, rm);\n            let mut diff_alt = x.clone();\n            let o_alt = diff_alt.set_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero()),\n                ComparableFloat(diff_alt.abs_negative_zero())\n            );\n            assert_eq!(o, o_alt);\n\n            let (diff, o) = Float::NEGATIVE_ZERO.sub_prec_round_val_ref(&x, prec, rm);\n            let mut diff_alt = -&x;\n            let o_alt = diff_alt.set_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero()),\n                ComparableFloat(diff_alt.abs_negative_zero())\n            );\n            assert_eq!(o, o_alt);\n        }\n    });\n}\n\nfn sub_prec_properties_helper(x: Float, y: Float, prec: u64, extreme: bool) {\n    let (diff, o) = x.clone().sub_prec(y.clone(), prec);\n    assert!(diff.is_valid());\n    let (diff_alt, o_alt) = x.clone().sub_prec_val_ref(&y, prec);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_prec_ref_val(y.clone(), prec);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_prec_ref_ref(&y, prec);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (diff_alt, o_alt) = add_prec_round_naive(x.clone(), -&y, prec, Nearest);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_diff, rug_o) = rug_sub_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Float::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_diff)),\n        ComparableFloatRef(&diff),\n    );\n    assert_eq!(rug_o, o);\n\n    if o == Equal && diff.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                diff.add_prec_ref_ref(&y, x.significant_bits())\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloat(\n                x.sub_prec_ref_ref(&diff, y.significant_bits())\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(y.abs_negative_zero_ref())\n        );\n    }\n\n    let (diff_alt, o_alt) = x.sub_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if diff.is_finite() {\n        if diff.is_normal() {\n            assert_eq!(diff.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_diff = Rational::exact_from(&x) - Rational::exact_from(&y);\n            assert_eq!(diff.partial_cmp(&r_diff), Some(o));\n            if o == Less {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if o == Greater {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n        }\n    }\n\n    let (mut diff_alt, mut o_alt) = y.sub_prec_ref_ref(&x, prec);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero_ref()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (diff_alt, o_alt) = x.add_prec_ref_val(-&y, prec);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if (x != 0u32 && y != 0u32) || (x.is_sign_positive() && y.is_sign_positive()) {\n        let (mut diff_alt, mut o_alt) = (-&x).add_prec_val_ref(&y, prec);\n        diff_alt.neg_assign();\n        diff_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&diff_alt),\n            ComparableFloatRef(&diff.abs_negative_zero_ref())\n        );\n        assert_eq!(o_alt, o);\n\n        let (mut diff_alt, mut o_alt) = (-x).sub_prec(-y, prec);\n        diff_alt.neg_assign();\n        diff_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloatRef(&diff_alt),\n            ComparableFloatRef(&diff.abs_negative_zero())\n        );\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn sub_prec_properties() {\n    float_float_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        sub_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_float_unsigned_triple_gen_var_2().test_properties(|(x, y, prec)| {\n        sub_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        let (diff, o) = x.sub_prec_ref_val(Float::NAN, prec);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        let (diff, o) = Float::NAN.sub_prec_val_ref(&x, prec);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != Float::INFINITY {\n                assert_eq!(\n                    x.sub_prec_ref_val(Float::INFINITY, prec),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::INFINITY.sub_prec_val_ref(&x, prec),\n                    (Float::INFINITY, Equal)\n                );\n            }\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(\n                    x.sub_prec_ref_val(Float::NEGATIVE_INFINITY, prec),\n                    (Float::INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.sub_prec_val_ref(&x, prec),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (diff, o) = x.sub_prec_ref_val(Float::ZERO, prec);\n            let mut diff_alt = x.clone();\n            let o_alt = diff_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(diff), ComparableFloat(diff_alt));\n            assert_eq!(o, o_alt);\n\n            let (diff, o) = Float::ZERO.sub_prec_val_ref(&x, prec);\n            let mut diff_alt = -&x;\n            let o_alt = diff_alt.set_prec(prec);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero()),\n                ComparableFloat(diff_alt.abs_negative_zero())\n            );\n            assert_eq!(o, o_alt);\n        }\n        let (diff, o) = x.sub_prec_ref_val(Float::NEGATIVE_ZERO, prec);\n        let mut diff_alt = x.clone();\n        let o_alt = diff_alt.set_prec(prec);\n        assert_eq!(\n            ComparableFloat(diff.abs_negative_zero()),\n            ComparableFloat(diff_alt.abs_negative_zero())\n        );\n        assert_eq!(o, o_alt);\n\n        let (diff, o) = Float::NEGATIVE_ZERO.sub_prec_val_ref(&x, prec);\n        let mut diff_alt = -x;\n        let o_alt = diff_alt.set_prec(prec);\n        assert_eq!(ComparableFloat(diff), ComparableFloat(diff_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sub_round_properties_helper(x: Float, y: Float, rm: RoundingMode, extreme: bool) {\n    let (diff, o) = x.clone().sub_round(y.clone(), rm);\n    assert!(diff.is_valid());\n    let (diff_alt, o_alt) = x.clone().sub_round_val_ref(&y, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let (diff_alt, o_alt) = x.sub_round_ref_val(y.clone(), rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let (diff_alt, o_alt) = x.sub_round_ref_ref(&y, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (diff_alt, o_alt) = add_prec_round_naive(\n            x.clone(),\n            -&y,\n            max(x.significant_bits(), y.significant_bits()),\n            rm,\n        );\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    }\n\n    let (diff_alt, o_alt) =\n        x.sub_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), rm);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if o == Equal && diff.is_finite() {\n        assert_eq!(diff.add_round_ref_ref(&y, Exact).0, x);\n        assert_eq!(x.sub_round_ref_ref(&diff, Exact).0, y);\n    }\n\n    if !extreme {\n        let r_diff = if diff.is_finite() {\n            if x.is_normal() && y.is_normal() && diff.is_normal() {\n                assert_eq!(\n                    diff.get_prec(),\n                    Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n                );\n            }\n            let r_diff = Rational::exact_from(&x) - Rational::exact_from(&y);\n            assert_eq!(diff.partial_cmp(&r_diff), Some(o));\n            if o == Less {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if o == Greater {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n            Some(r_diff)\n        } else {\n            assert_eq!(o, Equal);\n            None\n        };\n        match (r_diff.is_some() && *r_diff.as_ref().unwrap() >= 0u32, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_diff, rug_o) =\n            rug_sub_round(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y), rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_diff)),\n            ComparableFloatRef(&diff),\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (mut diff_alt, mut o_alt) = y.sub_round_ref_ref(&x, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloatRef(&diff_alt.abs_negative_zero()),\n        ComparableFloatRef(&diff.abs_negative_zero_ref())\n    );\n\n    let (diff_alt, o_alt) = x.add_round_ref_val(-&y, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let (mut diff_alt, mut o_alt) = (-&x).add_round_val_ref(&y, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n\n    let (mut diff_alt, mut o_alt) = (-&x).sub_round(-&y, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (d, oo) = x.sub_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(d.abs_negative_zero_ref()),\n                ComparableFloat(diff.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.sub_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn sub_round_properties() {\n    float_float_rounding_mode_triple_gen_var_2().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_30().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, true);\n    });\n\n    float_float_rounding_mode_triple_gen_var_10().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_11().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_12().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_13().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_14().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, false);\n    });\n\n    float_float_rounding_mode_triple_gen_var_15().test_properties(|(x, y, rm)| {\n        sub_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let (diff, o) = x.sub_round_ref_val(Float::NAN, rm);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        let (diff, o) = Float::NAN.sub_round_val_ref(&x, rm);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        if !x.is_nan() {\n            if x != Float::INFINITY {\n                assert_eq!(\n                    x.sub_round_ref_val(Float::INFINITY, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::INFINITY.sub_round_val_ref(&x, rm),\n                    (Float::INFINITY, Equal)\n                );\n            }\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(\n                    x.sub_round_ref_val(Float::NEGATIVE_INFINITY, rm),\n                    (Float::INFINITY, Equal)\n                );\n                assert_eq!(\n                    Float::NEGATIVE_INFINITY.sub_round_val_ref(&x, rm),\n                    (Float::NEGATIVE_INFINITY, Equal)\n                );\n            }\n        }\n        if !x.is_negative_zero() {\n            let (diff, o) = x.sub_round_ref_val(Float::ZERO, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero_ref()),\n                ComparableFloat(x.abs_negative_zero_ref())\n            );\n            assert_eq!(o, Equal);\n            let (diff, o) = Float::ZERO.sub_round_val_ref(&x, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero()),\n                ComparableFloat((-&x).abs_negative_zero())\n            );\n            assert_eq!(o, Equal);\n        }\n        if rm != Floor || !x.is_positive_zero() {\n            let (diff, o) = x.sub_round_ref_val(Float::NEGATIVE_ZERO, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero_ref()),\n                ComparableFloat(x.abs_negative_zero_ref())\n            );\n            assert_eq!(o, Equal);\n            let (diff, o) = Float::NEGATIVE_ZERO.sub_round_val_ref(&x, rm);\n            assert_eq!(\n                ComparableFloat(diff.abs_negative_zero()),\n                ComparableFloat((-&x).abs_negative_zero())\n            );\n            assert_eq!(o, Equal);\n        }\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn sub_properties_helper_1<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float>,\n{\n    primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let diff_1 = x - y;\n        let diff_2 = emulate_float_float_to_float_fn(Float::sub_prec, x, y);\n        assert_eq!(NiceFloat(diff_1), NiceFloat(diff_2));\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sub_properties_helper_2(x: Float, y: Float, extreme: bool) {\n    let diff = x.clone() - y.clone();\n    assert!(diff.is_valid());\n    let diff_alt = x.clone() - &y;\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = &x - y.clone();\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = &x - &y;\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let mut x_alt = x.clone();\n    x_alt -= y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n\n    let mut x_alt = x.clone();\n    x_alt -= &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n\n    if !extreme {\n        let diff_alt = add_prec_round_naive(\n            x.clone(),\n            -&y,\n            max(x.significant_bits(), y.significant_bits()),\n            Nearest,\n        )\n        .0;\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    }\n\n    let diff_alt = x\n        .sub_prec_round_ref_ref(&y, max(x.significant_bits(), y.significant_bits()), Nearest)\n        .0;\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = x\n        .sub_prec_ref_ref(&y, max(x.significant_bits(), y.significant_bits()))\n        .0;\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let (diff_alt, o) = x.sub_round_ref_ref(&y, Nearest);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    if o == Equal && diff.is_finite() {\n        assert_eq!(&diff + &y, x);\n        assert_eq!(&x - &diff, y);\n    }\n\n    if diff.is_finite() && x.is_normal() && y.is_normal() && diff.is_normal() {\n        assert_eq!(\n            diff.get_prec(),\n            Some(max(x.get_prec().unwrap(), y.get_prec().unwrap()))\n        );\n        if !extreme {\n            let r_diff = Rational::exact_from(&x) - Rational::exact_from(&y);\n            if diff < r_diff {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if diff > r_diff {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n        }\n    }\n\n    let rug_diff = rug_sub(&rug::Float::exact_from(&x), &rug::Float::exact_from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_diff)),\n        ComparableFloatRef(&diff),\n    );\n\n    let diff_alt = -(&y - &x);\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n\n    let diff_alt = &x + -&y;\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let diff_alt = -(-&x + &y);\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n\n    let diff_alt = -(-&x - -&y);\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero())\n    );\n}\n\n#[test]\nfn sub_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, true);\n    });\n\n    float_pair_gen_var_2().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_3().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_4().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_5().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_6().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, false);\n    });\n\n    float_pair_gen_var_7().test_properties(|(x, y)| {\n        sub_properties_helper_2(x, y, false);\n    });\n\n    apply_fn_to_primitive_floats!(sub_properties_helper_1);\n\n    float_gen().test_properties(|x| {\n        assert!((&x - Float::NAN).is_nan());\n        assert!((Float::NAN - &x).is_nan());\n        if !x.is_nan() {\n            if x != Float::INFINITY {\n                assert_eq!(&x - Float::INFINITY, Float::NEGATIVE_INFINITY);\n                assert_eq!(Float::INFINITY - &x, Float::INFINITY);\n            }\n            if x != Float::NEGATIVE_INFINITY {\n                assert_eq!(&x - Float::NEGATIVE_INFINITY, Float::INFINITY);\n                assert_eq!(Float::NEGATIVE_INFINITY - &x, Float::NEGATIVE_INFINITY);\n            }\n        }\n        assert_eq!(\n            ComparableFloatRef(&(&x - Float::ZERO)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(\n            ComparableFloat((-(Float::ZERO - &x)).abs_negative_zero()),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloat((&x - Float::NEGATIVE_ZERO).abs_negative_zero()),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloatRef(&-(Float::NEGATIVE_ZERO - &x)),\n            ComparableFloatRef(&x)\n        );\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sub_rational_prec_round_properties_helper(\n    x: Float,\n    y: Rational,\n    prec: u64,\n    rm: RoundingMode,\n    extreme: bool,\n) {\n    let (diff, o) = x.clone().sub_rational_prec_round(y.clone(), prec, rm);\n    assert!(diff.is_valid());\n    let (diff_alt, o_alt) = x.clone().sub_rational_prec_round_val_ref(&y, prec, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_rational_prec_round_ref_val(y.clone(), prec, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_rational_prec_round_ref_ref(&y, prec, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_rational_prec_round_assign(y.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_rational_prec_round_assign_ref(&y, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (diff_alt, o_alt) = sub_rational_prec_round_naive(x.clone(), y.clone(), prec, rm);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_diff, rug_o) = rug_sub_rational_prec_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            prec,\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_diff)),\n            ComparableFloatRef(&diff)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    if o == Equal && diff.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                diff.add_rational_prec_round_ref_ref(&y, x.significant_bits(), Exact)\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        // TODO additional test\n    }\n\n    if diff.is_finite() {\n        if diff.is_normal() {\n            assert_eq!(diff.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_diff = Rational::exact_from(&x) - &y;\n            assert_eq!(diff.partial_cmp(&r_diff), Some(o));\n            if o == Less {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if o == Greater {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n            match (r_diff >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    let (diff_alt, o_alt) = x.add_rational_prec_round_ref_val(-&y, prec, rm);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let (mut diff_alt, mut o_alt) = (-&x).add_rational_prec_round_val_ref(&y, prec, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    let (mut diff_alt, mut o_alt) = (-&x).sub_rational_prec_round(-&y, prec, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n    assert_eq!(o_alt, o);\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (d, oo) = x.sub_rational_prec_round_ref_ref(&y, prec, rm);\n            assert_eq!(\n                ComparableFloat(d.abs_negative_zero_ref()),\n                ComparableFloat(diff.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.sub_rational_prec_round_ref_ref(&y, prec, Exact));\n    }\n}\n\n#[test]\nfn sub_rational_prec_round_properties() {\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_2().test_properties(\n        |(x, y, prec, rm)| {\n            sub_rational_prec_round_properties_helper(x, y, prec, rm, false);\n        },\n    );\n\n    float_rational_unsigned_rounding_mode_quadruple_gen_var_7().test_properties_with_limit(\n        20,\n        |(x, y, prec, rm)| {\n            sub_rational_prec_round_properties_helper(x, y, prec, rm, true);\n        },\n    );\n\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        if !x.is_negative_zero() {\n            let (diff, o) = x.sub_rational_prec_round_ref_val(Rational::ZERO, prec, rm);\n            let mut diff_alt = x.clone();\n            let o_alt = diff_alt.set_prec_round(prec, rm);\n            assert_eq!(ComparableFloat(diff), ComparableFloat(diff_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n\n    rational_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (diff, o) = Float::NAN.sub_rational_prec_round_val_ref(&x, prec, rm);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.sub_rational_prec_round_val_ref(&x, prec, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.sub_rational_prec_round_val_ref(&x, prec, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n\n        let (diff, o) = Float::ZERO.sub_rational_prec_round_val_ref(&x, prec, rm);\n        let (mut diff_alt, mut o_alt) = Float::from_rational_prec_round_ref(&x, prec, -rm);\n        diff_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloat(diff.abs_negative_zero()),\n            ComparableFloat(diff_alt.abs_negative_zero())\n        );\n        assert_eq!(o, o_alt);\n\n        let (diff, o) = Float::NEGATIVE_ZERO.sub_rational_prec_round_val_ref(&x, prec, rm);\n        let (mut diff_alt, mut o_alt) = Float::from_rational_prec_round_ref(&x, prec, -rm);\n        diff_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(ComparableFloat(diff), ComparableFloat(diff_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\nfn sub_rational_prec_properties_helper(x: Float, y: Rational, prec: u64, extreme: bool) {\n    let (diff, o) = x.clone().sub_rational_prec(y.clone(), prec);\n    assert!(diff.is_valid());\n    let (diff_alt, o_alt) = x.clone().sub_rational_prec_val_ref(&y, prec);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_rational_prec_ref_val(y.clone(), prec);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n    let (diff_alt, o_alt) = x.sub_rational_prec_ref_ref(&y, prec);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_rational_prec_assign(y.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_rational_prec_assign_ref(&y, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (diff_alt, o_alt) = sub_rational_prec_round_naive(x.clone(), y.clone(), prec, Nearest);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    }\n\n    let (rug_diff, rug_o) = rug_sub_rational_prec(\n        &rug::Float::exact_from(&x),\n        &rug::Rational::exact_from(&y),\n        prec,\n    );\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_diff)),\n        ComparableFloatRef(&diff)\n    );\n    assert_eq!(rug_o, o);\n\n    if o == Equal && diff.is_finite() {\n        assert_eq!(\n            ComparableFloat(\n                diff.add_rational_prec_ref_ref(&y, x.significant_bits())\n                    .0\n                    .abs_negative_zero()\n            ),\n            ComparableFloat(x.abs_negative_zero_ref())\n        );\n        // TODO additional test\n    }\n\n    let (diff_alt, o_alt) = x.sub_rational_prec_round_ref_ref(&y, prec, Nearest);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if diff.is_finite() {\n        if diff.is_normal() {\n            assert_eq!(diff.get_prec(), Some(prec));\n        }\n        if !extreme {\n            let r_diff = Rational::exact_from(&x) - &y;\n            assert_eq!(diff.partial_cmp(&r_diff), Some(o));\n            if o == Less {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if o == Greater {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n        }\n    }\n\n    let (diff_alt, o_alt) = x.add_rational_prec_ref_val(-&y, prec);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if (x != 0u32 && y != 0u32) || x.is_sign_positive() {\n        let (mut diff_alt, mut o_alt) = (-&x).add_rational_prec_val_ref(&y, prec);\n        diff_alt.neg_assign();\n        diff_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n\n        let (mut diff_alt, mut o_alt) = (-x).sub_rational_prec(-y, prec);\n        diff_alt.neg_assign();\n        diff_alt.abs_negative_zero_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    }\n}\n\n#[test]\nfn sub_rational_prec_properties() {\n    float_rational_unsigned_triple_gen_var_1().test_properties(|(x, y, prec)| {\n        sub_rational_prec_properties_helper(x, y, prec, false);\n    });\n\n    float_rational_unsigned_triple_gen_var_2().test_properties_with_limit(20, |(x, y, prec)| {\n        sub_rational_prec_properties_helper(x, y, prec, true);\n    });\n\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        if !x.is_negative_zero() {\n            let (diff, o) = x.sub_rational_prec_ref_val(Rational::ZERO, prec);\n            let mut diff_alt = x.clone();\n            let o_alt = diff_alt.set_prec(prec);\n            assert_eq!(ComparableFloat(diff), ComparableFloat(diff_alt));\n            assert_eq!(o, o_alt);\n        }\n    });\n\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let (diff, o) = Float::NAN.sub_rational_prec_val_ref(&x, prec);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.sub_rational_prec_val_ref(&x, prec),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.sub_rational_prec_val_ref(&x, prec),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        let (diff, o) = Float::ZERO.sub_rational_prec_val_ref(&x, prec);\n        let (mut diff_alt, mut o_alt) = Float::from_rational_prec_ref(&x, prec);\n        diff_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloat(diff.abs_negative_zero()),\n            ComparableFloat(diff_alt.abs_negative_zero())\n        );\n        assert_eq!(o, o_alt);\n\n        let (diff, o) = Float::NEGATIVE_ZERO.sub_rational_prec_val_ref(&x, prec);\n        let (mut diff_alt, mut o_alt) = Float::from_rational_prec_ref(&x, prec);\n        diff_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(ComparableFloat(diff), ComparableFloat(diff_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sub_rational_round_properties_helper(x: Float, y: Rational, rm: RoundingMode, extreme: bool) {\n    let (diff, o) = x.clone().sub_rational_round(y.clone(), rm);\n    assert!(diff.is_valid());\n    let (diff_alt, o_alt) = x.clone().sub_rational_round_val_ref(&y, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let (diff_alt, o_alt) = x.sub_rational_round_ref_val(y.clone(), rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let (diff_alt, o_alt) = x.sub_rational_round_ref_ref(&y, rm);\n    assert!(diff_alt.is_valid());\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_rational_round_assign(y.clone(), rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    let mut x_alt = x.clone();\n    let o_alt = x_alt.sub_rational_round_assign_ref(&y, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if !extreme {\n        let (diff_alt, o_alt) =\n            sub_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), rm);\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n        assert_eq!(o_alt, o);\n    }\n\n    let (diff_alt, o_alt) = x.sub_rational_prec_round_ref_ref(&y, x.significant_bits(), rm);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    assert_eq!(o_alt, o);\n\n    if o == Equal && diff.is_finite() && diff != 0 {\n        assert_eq!(diff.add_rational_round_ref_ref(&y, Exact).0, x);\n        // TODO additional test\n    }\n\n    if diff.is_finite() {\n        if x.is_normal() && diff.is_normal() {\n            assert_eq!(diff.get_prec(), Some(x.get_prec().unwrap()));\n        }\n        if !extreme {\n            let r_diff = Rational::exact_from(&x) - &y;\n            assert_eq!(diff.partial_cmp(&r_diff), Some(o));\n            if o == Less {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if o == Greater {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n\n            match (r_diff >= 0u32, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    }\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_diff, rug_o) = rug_sub_rational_round(\n            &rug::Float::exact_from(&x),\n            &rug::Rational::exact_from(&y),\n            rm,\n        );\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_diff)),\n            ComparableFloatRef(&diff)\n        );\n        assert_eq!(rug_o, o);\n    }\n\n    let (diff_alt, o_alt) = x.add_rational_round_ref_val(-&y, rm);\n    assert_eq!(o_alt, o);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let (mut diff_alt, mut o_alt) = (-&x).add_rational_round_val_ref(&y, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n\n    let (mut diff_alt, mut o_alt) = (-&x).sub_rational_round(-&y, -rm);\n    diff_alt.neg_assign();\n    o_alt = o_alt.reverse();\n    assert_eq!(o_alt, o);\n    assert_eq!(\n        ComparableFloat(diff_alt.abs_negative_zero()),\n        ComparableFloat(diff.abs_negative_zero_ref())\n    );\n\n    if o == Equal {\n        for rm in exhaustive_rounding_modes() {\n            let (d, oo) = x.sub_rational_round_ref_ref(&y, rm);\n            assert_eq!(\n                ComparableFloat(d.abs_negative_zero_ref()),\n                ComparableFloat(diff.abs_negative_zero_ref())\n            );\n            assert_eq!(oo, Equal);\n        }\n    } else {\n        assert_panic!(x.sub_rational_round_ref_ref(&y, Exact));\n    }\n}\n\n#[test]\nfn sub_rational_round_properties() {\n    float_rational_rounding_mode_triple_gen_var_2().test_properties(|(x, y, rm)| {\n        sub_rational_round_properties_helper(x, y, rm, false);\n    });\n\n    float_rational_rounding_mode_triple_gen_var_8().test_properties_with_limit(20, |(x, y, rm)| {\n        sub_rational_round_properties_helper(x, y, rm, true);\n    });\n\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        if !x.is_negative_zero() {\n            let (diff, o) = x.sub_rational_round_ref_val(Rational::ZERO, rm);\n            assert_eq!(ComparableFloat(diff), ComparableFloat(x));\n            assert_eq!(o, Equal);\n        }\n    });\n\n    rational_rounding_mode_pair_gen_var_6().test_properties(|(x, rm)| {\n        let (diff, o) = Float::NAN.sub_rational_round_val_ref(&x, rm);\n        assert!(diff.is_nan());\n        assert_eq!(o, Equal);\n\n        assert_eq!(\n            Float::INFINITY.sub_rational_round_val_ref(&x, rm),\n            (Float::INFINITY, Equal)\n        );\n        assert_eq!(\n            Float::NEGATIVE_INFINITY.sub_rational_round_val_ref(&x, rm),\n            (Float::NEGATIVE_INFINITY, Equal)\n        );\n        let (diff, o) = Float::ZERO.sub_rational_round_val_ref(&x, rm);\n        let (mut diff_alt, mut o_alt) = Float::from_rational_prec_round_ref(&x, 1, -rm);\n        diff_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(\n            ComparableFloat(diff.abs_negative_zero()),\n            ComparableFloat(diff_alt.abs_negative_zero())\n        );\n        assert_eq!(o, o_alt);\n\n        let (diff, o) = Float::NEGATIVE_ZERO.sub_rational_round_val_ref(&x, rm);\n        let (mut diff_alt, mut o_alt) = Float::from_rational_prec_round_ref(&x, 1, -rm);\n        diff_alt.neg_assign();\n        o_alt = o_alt.reverse();\n        assert_eq!(ComparableFloatRef(&diff), ComparableFloatRef(&diff_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn sub_rational_properties_helper(x: Float, y: Rational, extreme: bool) {\n    let diff = x.clone() - y.clone();\n    assert!(diff.is_valid());\n    let diff_alt = x.clone() - &y;\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = &x - y.clone();\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = &x - &y;\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let diff_alt = -(y.clone() - x.clone());\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = -(y.clone() - &x);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = -(&y - x.clone());\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = -(&y - &x);\n    assert!(diff_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    let mut x_alt = x.clone();\n    x_alt -= y.clone();\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n\n    let mut x_alt = x.clone();\n    x_alt -= &y;\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&diff));\n\n    if !extreme {\n        let diff_alt =\n            sub_rational_prec_round_naive(x.clone(), y.clone(), x.significant_bits(), Nearest).0;\n        assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    }\n\n    let diff_alt = x\n        .sub_rational_prec_round_ref_ref(&y, x.significant_bits(), Nearest)\n        .0;\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let diff_alt = x.sub_rational_prec_ref_ref(&y, x.significant_bits()).0;\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n    let (diff_alt, o) = x.sub_rational_round_ref_ref(&y, Nearest);\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    if o == Equal && diff.is_finite() && diff != 0 {\n        assert_eq!(&diff + &y, x);\n        // TODO additional test\n    }\n\n    if diff.is_finite() && x.is_normal() && diff.is_normal() {\n        assert_eq!(diff.get_prec(), Some(x.get_prec().unwrap()));\n        if !extreme {\n            let r_diff = Rational::exact_from(&x) - &y;\n            if diff < r_diff {\n                let mut next = diff.clone();\n                next.increment();\n                assert!(next > r_diff);\n            } else if diff > r_diff {\n                let mut next = diff.clone();\n                next.decrement();\n                assert!(next < r_diff);\n            }\n        }\n    }\n\n    let rug_diff = rug_sub_rational(&rug::Float::exact_from(&x), &rug::Rational::from(&y));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_diff)),\n        ComparableFloatRef(&diff),\n    );\n\n    let diff_alt = &x + -&y;\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n\n    if (x != 0u32 && y != 0u32) || x.is_sign_positive() {\n        let diff_alt = -(-&x + &y);\n        assert_eq!(\n            ComparableFloat(diff_alt.abs_negative_zero()),\n            ComparableFloat(diff.abs_negative_zero_ref())\n        );\n\n        let diff_alt = -(-&x - -&y);\n        assert_eq!(\n            ComparableFloat(diff_alt.abs_negative_zero()),\n            ComparableFloat(diff.abs_negative_zero_ref())\n        );\n    }\n\n    let diff_alt = sub_rational_prec_round_naive(x.clone(), y, x.significant_bits(), Nearest).0;\n    assert_eq!(ComparableFloatRef(&diff_alt), ComparableFloatRef(&diff));\n}\n\n#[test]\nfn sub_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        sub_rational_properties_helper(x, y, false);\n    });\n\n    float_rational_pair_gen_var_2().test_properties_with_limit(20, |(x, y)| {\n        sub_rational_properties_helper(x, y, true);\n    });\n\n    float_gen().test_properties(|x| {\n        assert_eq!(\n            ComparableFloatRef(&(&x - Rational::ZERO)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(\n            ComparableFloatRef(&-(Rational::ZERO - &x)),\n            ComparableFloatRef(&x)\n        );\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!((&x - Float::NAN).is_nan());\n        assert!((Float::NAN - &x).is_nan());\n        assert_eq!(&x - Float::INFINITY, Float::NEGATIVE_INFINITY);\n        assert_eq!(Float::INFINITY - &x, Float::INFINITY);\n        assert_eq!(&x - Float::NEGATIVE_INFINITY, Float::INFINITY);\n        assert_eq!(Float::NEGATIVE_INFINITY - &x, Float::NEGATIVE_INFINITY);\n        let diff_alt = Float::from_rational_prec_ref(&x, 1).0;\n        assert_eq!(\n            ComparableFloat((&x - Float::ZERO).abs_negative_zero()),\n            ComparableFloat(diff_alt.abs_negative_zero_ref())\n        );\n        assert_eq!(\n            ComparableFloat((Float::ZERO - &x).abs_negative_zero()),\n            ComparableFloat((-&diff_alt).abs_negative_zero())\n        );\n        assert_eq!(\n            ComparableFloat(&x - Float::NEGATIVE_ZERO),\n            ComparableFloat(diff_alt.clone())\n        );\n        assert_eq!(\n            ComparableFloat(Float::NEGATIVE_ZERO - &x),\n            ComparableFloat(-diff_alt)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/classification.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\nuse malachite_float::{ComparableFloatRef, Float};\nuse std::num::FpCategory;\n\n#[test]\nfn test_is_nan() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_nan(), out);\n        assert_eq!(rug::Float::exact_from(&x).is_nan(), out);\n    };\n    test(\"NaN\", \"NaN\", true);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", false);\n\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"2.0\", \"0x2.0#1\", false);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_nan_properties_helper(x: Float) {\n    let is_nan = x.is_nan();\n    assert_eq!(\n        is_nan,\n        ComparableFloatRef(&x) == ComparableFloatRef(&Float::NAN)\n    );\n    assert_eq!(is_nan, x.classify() == FpCategory::Nan);\n    assert_eq!(is_nan, !x.is_finite() && !x.is_infinite());\n    assert_eq!(is_nan, rug::Float::exact_from(&x).is_nan());\n}\n\n#[test]\nfn is_nan_properties() {\n    float_gen().test_properties(|x| {\n        is_nan_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_nan_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(Float::from(x).is_nan(), x.is_nan());\n    });\n}\n\n#[test]\nfn test_is_finite() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_finite(), out);\n        assert_eq!(rug::Float::exact_from(&x).is_finite(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", true);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", true);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", true);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", true);\n    test(\"too_big\", \"0x4.0E+268435455#1\", true);\n    test(\"too_small\", \"0x1.0E-268435456#1\", true);\n\n    test(\"-1.0\", \"-0x1.0#1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", true);\n    test(\"-0.5\", \"-0x0.8#1\", true);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", true);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", true);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", true);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", true);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", true);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_finite_properties_helper(x: Float) {\n    let is_finite = x.is_finite();\n    assert_eq!(is_finite, !x.is_nan() && !x.is_infinite());\n    assert_eq!(\n        is_finite,\n        x > Float::NEGATIVE_INFINITY && x < Float::INFINITY\n    );\n    assert_eq!(is_finite, rug::Float::exact_from(&x).is_finite());\n}\n\n#[test]\nfn is_finite_properties() {\n    float_gen().test_properties(|x| {\n        is_finite_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_finite_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(Float::from(x).is_finite(), x.is_finite());\n    });\n}\n\n#[test]\nfn test_is_infinite() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_infinite(), out);\n        assert_eq!(rug::Float::exact_from(&x).is_infinite(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", true);\n    test(\"-Infinity\", \"-Infinity\", true);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", false);\n\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"2.0\", \"0x2.0#1\", false);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_infinite_properties_helper(x: Float) {\n    let is_infinite = x.is_infinite();\n    assert_eq!(x.classify() == FpCategory::Infinite, is_infinite);\n    assert_eq!(is_infinite, !x.is_nan() && !x.is_finite());\n    assert_eq!(\n        is_infinite,\n        x == Float::NEGATIVE_INFINITY || x == Float::INFINITY\n    );\n    assert_eq!(is_infinite, rug::Float::exact_from(&x).is_infinite());\n}\n\n#[test]\nfn is_infinite_properties() {\n    float_gen().test_properties(|x| {\n        is_infinite_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_infinite_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(Float::from(x).is_infinite(), x.is_infinite());\n    });\n}\n\n#[test]\nfn test_is_positive_zero() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_positive_zero(), out);\n        let fx = rug::Float::exact_from(&x);\n        assert_eq!(fx.is_zero() && fx.is_sign_positive(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", false);\n\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"2.0\", \"0x2.0#1\", false);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_positive_zero_properties_helper(x: Float) {\n    let is_positive_zero = x.is_positive_zero();\n    assert_eq!(\n        is_positive_zero,\n        ComparableFloatRef(&x) == ComparableFloatRef(&Float::ZERO)\n    );\n    assert_eq!(is_positive_zero, x == Float::ZERO && x.is_sign_positive());\n    let fx = rug::Float::exact_from(&x);\n    assert_eq!(is_positive_zero, fx.is_zero() && fx.is_sign_positive());\n}\n\n#[test]\nfn is_positive_zero_properties() {\n    float_gen().test_properties(|x| {\n        is_positive_zero_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_positive_zero_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(\n            Float::from(x).is_positive_zero(),\n            x == 0.0 && x.is_sign_positive()\n        );\n    });\n}\n\n#[test]\nfn test_is_negative_zero() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_negative_zero(), out);\n        let fx = rug::Float::exact_from(&x);\n        assert_eq!(fx.is_zero() && fx.is_sign_negative(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"2.0\", \"0x2.0#1\", false);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_negative_zero_properties_helper(x: Float) {\n    let is_negative_zero = x.is_negative_zero();\n    assert_eq!(\n        is_negative_zero,\n        ComparableFloatRef(&x) == ComparableFloatRef(&Float::NEGATIVE_ZERO)\n    );\n    assert_eq!(is_negative_zero, x == Float::ZERO && x.is_sign_negative());\n    let fx = rug::Float::exact_from(&x);\n    assert_eq!(is_negative_zero, fx.is_zero() && fx.is_sign_negative());\n}\n\n#[test]\nfn is_negative_zero_properties() {\n    float_gen().test_properties(|x| {\n        is_negative_zero_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_negative_zero_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(\n            Float::from(x).is_negative_zero(),\n            x == 0.0 && x.is_sign_negative()\n        );\n    });\n}\n\n#[test]\nfn test_is_zero() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_zero(), out);\n        assert_eq!(rug::Float::exact_from(&x).is_zero(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"2.0\", \"0x2.0#1\", false);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_zero_properties_helper(x: Float) {\n    let is_zero = x.is_zero();\n    assert_eq!(is_zero, x == Float::ZERO);\n    assert_eq!(is_zero, x.classify() == FpCategory::Zero);\n    assert_eq!(is_zero, rug::Float::exact_from(&x).is_zero());\n}\n\n#[test]\nfn is_zero_properties() {\n    float_gen().test_properties(|x| {\n        is_zero_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_zero_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(Float::from(x).is_zero(), x == 0.0);\n    });\n}\n\n#[test]\nfn test_is_normal() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_normal(), out);\n        assert_eq!(rug::Float::exact_from(&x).is_normal(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", false);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", true);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", true);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", true);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", true);\n    test(\"too_big\", \"0x4.0E+268435455#1\", true);\n    test(\"too_small\", \"0x1.0E-268435456#1\", true);\n\n    test(\"-1.0\", \"-0x1.0#1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", true);\n    test(\"-0.5\", \"-0x0.8#1\", true);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", true);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", true);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", true);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", true);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", true);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_normal_properties_helper(x: Float) {\n    let is_normal = x.is_normal();\n    assert_eq!(is_normal, x.is_finite() && !x.is_zero());\n    assert_eq!(is_normal, x.classify() == FpCategory::Normal);\n    assert_eq!(is_normal, rug::Float::exact_from(&x).is_normal());\n}\n\n#[test]\nfn is_normal_properties() {\n    float_gen().test_properties(|x| {\n        is_normal_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_normal_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_is_sign_positive() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_sign_positive(), out);\n        let fx = rug::Float::exact_from(&x);\n        assert_eq!(!fx.is_nan() && fx.is_sign_positive(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", true);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", false);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", true);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", true);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", true);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", true);\n    test(\"too_big\", \"0x4.0E+268435455#1\", true);\n    test(\"too_small\", \"0x1.0E-268435456#1\", true);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_sign_positive_properties_helper(x: Float) {\n    let is_sign_positive = x.is_sign_positive();\n    assert_eq!(is_sign_positive, x.is_positive_zero() || x > Float::ZERO);\n    assert_eq!(is_sign_positive, !x.is_nan() && !x.is_sign_negative());\n    let fx = rug::Float::exact_from(&x);\n    assert_eq!(is_sign_positive, !fx.is_nan() && fx.is_sign_positive());\n}\n\n#[test]\nfn is_sign_positive_properties() {\n    float_gen().test_properties(|x| {\n        is_sign_positive_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_sign_positive_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(\n            Float::from(x).is_sign_positive(),\n            !x.is_nan() && x.is_sign_positive()\n        );\n    });\n}\n\n#[test]\nfn test_is_sign_negative() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_sign_negative(), out);\n        let fx = rug::Float::exact_from(&x);\n        assert_eq!(!fx.is_nan() && fx.is_sign_negative(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", true);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"2.0\", \"0x2.0#1\", false);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n    test(\"-1.0\", \"-0x1.0#1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", true);\n    test(\"-0.5\", \"-0x0.8#1\", true);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", true);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", true);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", true);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", true);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", true);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_sign_negative_properties_helper(x: Float) {\n    let is_sign_negative = x.is_sign_negative();\n    assert_eq!(is_sign_negative, x.is_negative_zero() || x < Float::ZERO);\n    assert_eq!(is_sign_negative, !x.is_nan() && !x.is_sign_positive());\n    let fx = rug::Float::exact_from(&x);\n    assert_eq!(is_sign_negative, !fx.is_nan() && fx.is_sign_negative());\n}\n\n#[test]\nfn is_sign_negative_properties() {\n    float_gen().test_properties(|x| {\n        is_sign_negative_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        is_sign_negative_properties_helper(x);\n    });\n\n    primitive_float_gen::<f64>().test_properties(|x| {\n        assert_eq!(\n            Float::from(x).is_sign_negative(),\n            !x.is_nan() && x.is_sign_negative()\n        );\n    });\n}\n\n#[test]\nfn test_classify() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.classify(), out);\n        assert_eq!(rug::Float::exact_from(&x).classify(), out);\n    };\n    test(\"NaN\", \"NaN\", FpCategory::Nan);\n    test(\"Infinity\", \"Infinity\", FpCategory::Infinite);\n    test(\"-Infinity\", \"-Infinity\", FpCategory::Infinite);\n    test(\"0.0\", \"0x0.0\", FpCategory::Zero);\n    test(\"-0.0\", \"-0x0.0\", FpCategory::Zero);\n\n    test(\"1.0\", \"0x1.0#1\", FpCategory::Normal);\n    test(\"2.0\", \"0x2.0#1\", FpCategory::Normal);\n    test(\"0.5\", \"0x0.8#1\", FpCategory::Normal);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        FpCategory::Normal,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        FpCategory::Normal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        FpCategory::Normal,\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", FpCategory::Normal);\n    test(\"too_small\", \"0x1.0E-268435456#1\", FpCategory::Normal);\n\n    test(\"-1.0\", \"-0x1.0#1\", FpCategory::Normal);\n    test(\"-2.0\", \"-0x2.0#1\", FpCategory::Normal);\n    test(\"-0.5\", \"-0x0.8#1\", FpCategory::Normal);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        FpCategory::Normal,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        FpCategory::Normal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        FpCategory::Normal,\n    );\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", FpCategory::Normal);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", FpCategory::Normal);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn classify_properties_helper(x: Float) {\n    assert_eq!(x.classify(), rug::Float::exact_from(&x).classify());\n}\n\n#[test]\nfn classify_properties() {\n    float_gen().test_properties(|x| {\n        classify_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        classify_properties_helper(x);\n    });\n}\n\n#[allow(clippy::redundant_closure_for_method_calls)]\n#[test]\nfn test_to_non_nan() {\n    let test = |s, s_hex, out: Option<&str>, out_hex: Option<&str>| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let actual_out = x.to_non_nan();\n        assert!(actual_out.as_ref().is_none_or(Float::is_valid));\n        let actual_out_alt = x.into_non_nan();\n        assert!(actual_out_alt.as_ref().is_none_or(Float::is_valid));\n        assert_eq!(actual_out_alt, actual_out);\n\n        let s = actual_out.as_ref().map(|x| x.to_string());\n        assert_eq!(s.as_deref(), out);\n        let s = actual_out.map(|x| to_hex_string(&x));\n        assert_eq!(s.as_deref(), out_hex);\n    };\n    test(\"NaN\", \"NaN\", None, None);\n    test(\"Infinity\", \"Infinity\", Some(\"Infinity\"), Some(\"Infinity\"));\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        Some(\"-Infinity\"),\n        Some(\"-Infinity\"),\n    );\n    test(\"0.0\", \"0x0.0\", Some(\"0.0\"), Some(\"0x0.0\"));\n    test(\"-0.0\", \"-0x0.0\", Some(\"-0.0\"), Some(\"-0x0.0\"));\n\n    test(\"1.0\", \"0x1.0#1\", Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test(\"2.0\", \"0x2.0#1\", Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test(\"0.5\", \"0x0.8#1\", Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Some(\"0.33333333333333331\"),\n        Some(\"0x0.55555555555554#53\"),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Some(\"1.4142135623730951\"),\n        Some(\"0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Some(\"3.1415926535897931\"),\n        Some(\"0x3.243f6a8885a30#53\"),\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Some(\"too_big\"),\n        Some(\"0x4.0E+268435455#1\"),\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Some(\"too_small\"),\n        Some(\"0x1.0E-268435456#1\"),\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", Some(\"-1.0\"), Some(\"-0x1.0#1\"));\n    test(\"-2.0\", \"-0x2.0#1\", Some(\"-2.0\"), Some(\"-0x2.0#1\"));\n    test(\"-0.5\", \"-0x0.8#1\", Some(\"-0.5\"), Some(\"-0x0.8#1\"));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Some(\"-0.33333333333333331\"),\n        Some(\"-0x0.55555555555554#53\"),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Some(\"-1.4142135623730951\"),\n        Some(\"-0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Some(\"-3.1415926535897931\"),\n        Some(\"-0x3.243f6a8885a30#53\"),\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Some(\"-too_big\"),\n        Some(\"-0x4.0E+268435455#1\"),\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Some(\"-too_small\"),\n        Some(\"-0x1.0E-268435456#1\"),\n    );\n}\n\nfn to_non_nan_properties_helper(x: Float) {\n    let nn = x.to_non_nan();\n    if let Some(nn) = nn {\n        assert!(nn.is_valid());\n        let nn_alt = x.clone().into_non_nan().unwrap();\n        assert!(nn_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&nn), ComparableFloatRef(&nn_alt));\n        assert_eq!(ComparableFloatRef(&nn), ComparableFloatRef(&x));\n        assert!(!nn.is_nan());\n    } else {\n        assert!(x.is_nan());\n        assert!(x.into_non_nan().is_none());\n    }\n}\n\n#[test]\nfn to_non_nan_properties() {\n    float_gen().test_properties(|x| {\n        to_non_nan_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        to_non_nan_properties_helper(x);\n    });\n}\n\n#[allow(clippy::redundant_closure_for_method_calls)]\n#[test]\nfn test_to_finite() {\n    let test = |s, s_hex, out: Option<&str>, out_hex: Option<&str>| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let actual_out = x.to_finite();\n        assert!(actual_out.as_ref().is_none_or(Float::is_valid));\n        let actual_out_alt = x.into_finite();\n        assert!(actual_out_alt.as_ref().is_none_or(Float::is_valid));\n        assert_eq!(actual_out_alt, actual_out);\n\n        let s = actual_out.as_ref().map(|x| x.to_string());\n        assert_eq!(s.as_deref(), out);\n        let s = actual_out.map(|x| to_hex_string(&x));\n        assert_eq!(s.as_deref(), out_hex);\n    };\n    test(\"NaN\", \"NaN\", None, None);\n    test(\"Infinity\", \"Infinity\", None, None);\n    test(\"-Infinity\", \"-Infinity\", None, None);\n    test(\"0.0\", \"0x0.0\", Some(\"0.0\"), Some(\"0x0.0\"));\n    test(\"-0.0\", \"-0x0.0\", Some(\"-0.0\"), Some(\"-0x0.0\"));\n\n    test(\"1.0\", \"0x1.0#1\", Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test(\"2.0\", \"0x2.0#1\", Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test(\"0.5\", \"0x0.8#1\", Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Some(\"0.33333333333333331\"),\n        Some(\"0x0.55555555555554#53\"),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Some(\"1.4142135623730951\"),\n        Some(\"0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Some(\"3.1415926535897931\"),\n        Some(\"0x3.243f6a8885a30#53\"),\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Some(\"too_big\"),\n        Some(\"0x4.0E+268435455#1\"),\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Some(\"too_small\"),\n        Some(\"0x1.0E-268435456#1\"),\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", Some(\"-1.0\"), Some(\"-0x1.0#1\"));\n    test(\"-2.0\", \"-0x2.0#1\", Some(\"-2.0\"), Some(\"-0x2.0#1\"));\n    test(\"-0.5\", \"-0x0.8#1\", Some(\"-0.5\"), Some(\"-0x0.8#1\"));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Some(\"-0.33333333333333331\"),\n        Some(\"-0x0.55555555555554#53\"),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Some(\"-1.4142135623730951\"),\n        Some(\"-0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Some(\"-3.1415926535897931\"),\n        Some(\"-0x3.243f6a8885a30#53\"),\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Some(\"-too_big\"),\n        Some(\"-0x4.0E+268435455#1\"),\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Some(\"-too_small\"),\n        Some(\"-0x1.0E-268435456#1\"),\n    );\n}\n\nfn to_finite_properties_helper(x: Float) {\n    let f = x.to_finite();\n    if let Some(f) = f {\n        assert!(f.is_valid());\n        let f_alt = x.clone().into_non_nan().unwrap();\n        assert!(f_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&f), ComparableFloatRef(&f_alt));\n        assert_eq!(ComparableFloatRef(&f), ComparableFloatRef(&x));\n        assert!(f.is_finite());\n    } else {\n        assert!(!x.is_finite());\n        assert!(x.into_finite().is_none());\n    }\n}\n\n#[test]\nfn to_finite_properties() {\n    float_gen().test_properties(|x| {\n        to_finite_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        to_finite_properties_helper(x);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/complexity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\n\n#[test]\nfn test_complexity() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.complexity(), out);\n    };\n    test(\"NaN\", \"NaN\", 1);\n    test(\"Infinity\", \"Infinity\", 1);\n    test(\"-Infinity\", \"-Infinity\", 1);\n    test(\"0.0\", \"0x0.0\", 1);\n    test(\"-0.0\", \"-0x0.0\", 1);\n\n    test(\"1.0\", \"0x1.0#1\", 1);\n    test(\"2.0\", \"0x2.0#1\", 1);\n    test(\"0.5\", \"0x0.8#1\", 1);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 53);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 53);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 53);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 400);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 400);\n    test(\"too_big\", \"0x4.0E+268435455#1\", 1073741822);\n    test(\"too_small\", \"0x1.0E-268435456#1\", 1073741824);\n\n    test(\"-1.0\", \"-0x1.0#1\", 1);\n    test(\"-2.0\", \"-0x2.0#1\", 1);\n    test(\"-0.5\", \"-0x0.8#1\", 1);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 53);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 53);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 53);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 400);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 400);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", 1073741822);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", 1073741824);\n}\n\n#[test]\nfn test_significant_bits() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.significant_bits(), out);\n    };\n    test(\"NaN\", \"NaN\", 1);\n    test(\"Infinity\", \"Infinity\", 1);\n    test(\"-Infinity\", \"-Infinity\", 1);\n    test(\"0.0\", \"0x0.0\", 1);\n    test(\"-0.0\", \"-0x0.0\", 1);\n\n    test(\"1.0\", \"0x1.0#1\", 1);\n    test(\"2.0\", \"0x2.0#1\", 1);\n    test(\"0.5\", \"0x0.8#1\", 1);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 53);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 53);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 53);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1);\n    test(\"too_big\", \"0x4.0E+268435455#1\", 1);\n    test(\"too_small\", \"0x1.0E-268435456#1\", 1);\n\n    test(\"-1.0\", \"-0x1.0#1\", 1);\n    test(\"-2.0\", \"-0x2.0#1\", 1);\n    test(\"-0.5\", \"-0x0.8#1\", 1);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 53);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 53);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 53);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", 1);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", 1);\n}\n\nfn complexity_properties_helper(x: Float) {\n    let complexity = x.complexity();\n    assert_ne!(complexity, 0);\n    assert_eq!((-x).complexity(), complexity);\n}\n\n#[test]\nfn complexity_properties() {\n    float_gen().test_properties(|x| {\n        complexity_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        complexity_properties_helper(x);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn significant_bits_properties_helper(x: Float) {\n    let bits = x.significant_bits();\n    assert_ne!(bits, 0);\n    assert_eq!((-&x).significant_bits(), bits);\n    assert!(bits <= x.complexity());\n}\n\n#[test]\nfn significant_bits_properties() {\n    float_gen().test_properties(|x| {\n        significant_bits_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        significant_bits_properties_helper(x);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::comparison::traits::{Max, Min};\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Two, Zero,\n};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::unsigned_gen_var_11;\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse rug::float::Special;\n\n#[test]\nfn test_min() {\n    let min = Float::MIN;\n    assert!(min.is_valid());\n    assert_eq!(min, f64::NEGATIVE_INFINITY);\n    assert_eq!(min.to_string(), \"-Infinity\");\n    assert_eq!(\n        Float::from(&rug::Float::with_val(1, Special::NegInfinity)),\n        min\n    );\n}\n\n#[test]\nfn test_max() {\n    let max = Float::MAX;\n    assert!(max.is_valid());\n    assert_eq!(max, f64::INFINITY);\n    assert_eq!(max.to_string(), \"Infinity\");\n    assert_eq!(\n        Float::from(&rug::Float::with_val(1, Special::Infinity)),\n        max\n    );\n}\n\n#[test]\nfn test_zero() {\n    let zero = Float::ZERO;\n    assert!(zero.is_valid());\n    assert_eq!(zero, 0);\n    assert_eq!(zero, 0.0);\n    assert!(zero.is_positive_zero());\n    assert!(zero.is_zero());\n    assert_eq!(zero.to_string(), \"0.0\");\n    assert_eq!(\n        ComparableFloat(Float::from(&rug::Float::with_val(1, Special::Zero))),\n        ComparableFloat(zero)\n    );\n}\n\n#[test]\nfn test_min_positive_value_prec() {\n    let min_positive = Float::MIN_POSITIVE;\n    assert!(min_positive.is_valid());\n    assert_eq!(min_positive.to_string(), \"too_small\");\n    assert_eq!(\n        format!(\"{:#x}\", ComparableFloatRef(&min_positive)),\n        \"0x1.0E-268435456#1\"\n    );\n    assert_eq!(min_positive.get_prec(), Some(1));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(\n            &(rug::Float::with_val(1, 1.0) << (Float::MIN_EXPONENT - 1))\n        )),\n        ComparableFloatRef(&min_positive)\n    );\n    assert_eq!(\n        ComparableFloat(Float::min_positive_value_prec(1)),\n        ComparableFloat(min_positive)\n    );\n\n    let test = |p, out, out_hex| {\n        let min_positive = Float::min_positive_value_prec(p);\n        assert!(min_positive.is_valid());\n        assert_eq!(min_positive.to_string(), out);\n        assert_eq!(to_hex_string(&min_positive), out_hex);\n        assert_eq!(\n            ComparableFloat(Float::from(\n                &(rug::Float::with_val(u32::exact_from(p), 1.0) << (Float::MIN_EXPONENT - 1))\n            )),\n            ComparableFloat(min_positive)\n        );\n    };\n    test(1, \"too_small\", \"0x1.0E-268435456#1\");\n    test(2, \"too_small\", \"0x1.0E-268435456#2\");\n    test(3, \"too_small\", \"0x1.0E-268435456#3\");\n    test(10, \"too_small\", \"0x1.000E-268435456#10\");\n    test(\n        100,\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn min_positive_value_prec_fail() {\n    Float::min_positive_value_prec(0);\n}\n\n#[test]\nfn min_positive_value_prec_properties() {\n    unsigned_gen_var_11().test_properties(|p| {\n        let min = Float::min_positive_value_prec(p);\n        assert!(min.is_valid());\n        assert_eq!(min.get_prec(), Some(p));\n        assert!(min.is_power_of_2());\n    });\n}\n\n#[test]\nfn test_abs_is_min_positive_value_properties() {\n    let test = |s, s_hex, out: bool| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.abs_is_min_positive_value(), out);\n    };\n    test(\"too_small\", \"0x1.0E-268435456#1\", true);\n    test(\"too_small\", \"0x1.0E-268435456#2\", true);\n    test(\"too_small\", \"0x1.0E-268435456#3\", true);\n    test(\"too_small\", \"0x1.000E-268435456#10\", true);\n    test(\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        true,\n    );\n\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", true);\n    test(\"-too_small\", \"-0x1.0E-268435456#2\", true);\n    test(\"-too_small\", \"-0x1.0E-268435456#3\", true);\n    test(\"-too_small\", \"-0x1.000E-268435456#10\", true);\n    test(\n        \"-too_small\",\n        \"-0x1.0000000000000000000000000E-268435456#100\",\n        true,\n    );\n\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", false);\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", false);\n\n    test(\"too_small\", \"0x1.8E-268435456#2\", false);\n    test(\"too_small\", \"0x2.0E-268435456#1\", false);\n    test(\"too_small\", \"0x1.0E-268435455#1\", false);\n    test(\"-too_small\", \"-0x1.8E-268435456#2\", false);\n    test(\"-too_small\", \"-0x2.0E-268435456#1\", false);\n    test(\"-too_small\", \"-0x1.0E-268435455#1\", false);\n}\n\nfn abs_is_min_positive_value_properties_helper(x: Float) {\n    let is_min = x.abs_is_min_positive_value();\n    assert_eq!(\n        is_min,\n        x.is_normal() && x.eq_abs(&Float::min_positive_value_prec(x.get_prec().unwrap()))\n    );\n    assert_eq!((-x).abs_is_min_positive_value(), is_min);\n}\n\n#[test]\nfn abs_is_min_positive_value_properties() {\n    float_gen().test_properties(|x| {\n        abs_is_min_positive_value_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        abs_is_min_positive_value_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_max_finite_value_with_prec() {\n    let test = |p, out, out_hex| {\n        let max_finite = Float::max_finite_value_with_prec(p);\n        assert!(max_finite.is_valid());\n        assert_eq!(max_finite.to_string(), out);\n        assert_eq!(to_hex_string(&max_finite), out_hex);\n    };\n    test(1, \"too_big\", \"0x4.0E+268435455#1\");\n    test(2, \"too_big\", \"0x6.0E+268435455#2\");\n    test(3, \"too_big\", \"0x7.0E+268435455#3\");\n    test(10, \"too_big\", \"0x7.feE+268435455#10\");\n    test(\n        100,\n        \"too_big\",\n        \"0x7.ffffffffffffffffffffffff8E+268435455#100\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn max_finite_value_with_prec_fail() {\n    Float::max_finite_value_with_prec(0);\n}\n\n#[test]\nfn max_finite_value_with_prec_properties() {\n    unsigned_gen_var_11().test_properties(|p| {\n        let max = Float::max_finite_value_with_prec(p);\n        assert!(max.is_valid());\n        assert_eq!(max.get_prec(), Some(p));\n        assert!(max > 0u32);\n    });\n}\n\n#[test]\nfn test_abs_is_max_finite_value_with_prec() {\n    let test = |s, s_hex, out: bool| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.abs_is_max_finite_value_with_prec(), out);\n    };\n    test(\"too_big\", \"0x4.0E+268435455#1\", true);\n    test(\"too_big\", \"0x6.0E+268435455#2\", true);\n    test(\"too_big\", \"0x7.0E+268435455#3\", true);\n    test(\"too_big\", \"0x7.feE+268435455#10\", true);\n    test(\n        \"too_big\",\n        \"0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        true,\n    );\n\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", true);\n    test(\"-too_big\", \"-0x6.0E+268435455#2\", true);\n    test(\"-too_big\", \"-0x7.0E+268435455#3\", true);\n    test(\"-too_big\", \"-0x7.feE+268435455#10\", true);\n    test(\n        \"-too_big\",\n        \"-0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        true,\n    );\n\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", false);\n    test(\"-0.0\", \"-0x0.0\", false);\n    test(\"1.0\", \"0x1.0#1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", false);\n\n    test(\"too_big\", \"0x2.0E+268435455#1\", false);\n    test(\"too_big\", \"0x4.0E+268435455#2\", false);\n    test(\"too_big\", \"0x4.0E+268435454#2\", false);\n    test(\"-too_big\", \"-0x2.0E+268435455#1\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#2\", false);\n    test(\"-too_big\", \"-0x4.0E+268435454#2\", false);\n}\n\nfn abs_is_max_finite_value_with_prec_properties_helper(x: Float) {\n    let is_max = x.abs_is_max_finite_value_with_prec();\n    assert_eq!(\n        is_max,\n        x.is_normal() && x.eq_abs(&Float::max_finite_value_with_prec(x.get_prec().unwrap()))\n    );\n    assert_eq!((-x).abs_is_max_finite_value_with_prec(), is_max);\n}\n\n#[test]\nfn abs_is_max_finite_value_with_prec_properties() {\n    float_gen().test_properties(|x| {\n        abs_is_max_finite_value_with_prec_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        abs_is_max_finite_value_with_prec_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_one_prec() {\n    let one = Float::ONE;\n    assert!(one.is_valid());\n    assert_eq!(one, 1);\n    assert_eq!(one, 1.0);\n    assert_eq!(one.to_string(), \"1.0\");\n    assert_eq!(one.get_prec(), Some(1));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug::Float::with_val(1, 1.0))),\n        ComparableFloatRef(&one)\n    );\n    assert_eq!(ComparableFloat(Float::one_prec(1)), ComparableFloat(one));\n\n    let test = |p, out, out_hex| {\n        let one = Float::one_prec(p);\n        assert!(one.is_valid());\n        assert_eq!(one.to_string(), out);\n        assert_eq!(to_hex_string(&one), out_hex);\n        assert_eq!(\n            ComparableFloat(Float::from(&rug::Float::with_val(u32::exact_from(p), 1.0))),\n            ComparableFloat(one)\n        );\n    };\n    test(1, \"1.0\", \"0x1.0#1\");\n    test(2, \"1.0\", \"0x1.0#2\");\n    test(3, \"1.0\", \"0x1.0#3\");\n    test(10, \"1.0\", \"0x1.000#10\");\n    test(100, \"1.0\", \"0x1.0000000000000000000000000#100\");\n}\n\n#[test]\n#[should_panic]\nfn one_prec_fail() {\n    Float::one_prec(0);\n}\n\n#[test]\nfn one_prec_properties() {\n    unsigned_gen_var_11().test_properties(|p| {\n        let one = Float::one_prec(p);\n        assert!(one.is_valid());\n        assert_eq!(one, 1);\n        assert_eq!(one, 1.0);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug::Float::with_val(u32::exact_from(p), 1.0))),\n            ComparableFloatRef(&one)\n        );\n\n        assert_eq!(one.get_prec(), Some(p));\n    });\n}\n\n#[test]\nfn test_two_prec() {\n    let two = Float::TWO;\n    assert!(two.is_valid());\n    assert_eq!(two, 2);\n    assert_eq!(two, 2.0);\n    assert_eq!(two.to_string(), \"2.0\");\n    assert_eq!(two.get_prec(), Some(1));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug::Float::with_val(1, 2.0))),\n        ComparableFloatRef(&two)\n    );\n    assert_eq!(ComparableFloat(Float::two_prec(1)), ComparableFloat(two));\n\n    let test = |p, out, out_hex| {\n        let two = Float::two_prec(p);\n        assert!(two.is_valid());\n        assert_eq!(two.to_string(), out);\n        assert_eq!(to_hex_string(&two), out_hex);\n        assert_eq!(\n            ComparableFloat(Float::from(&rug::Float::with_val(u32::exact_from(p), 2.0))),\n            ComparableFloat(two)\n        );\n    };\n    test(1, \"2.0\", \"0x2.0#1\");\n    test(2, \"2.0\", \"0x2.0#2\");\n    test(3, \"2.0\", \"0x2.0#3\");\n    test(10, \"2.0\", \"0x2.00#10\");\n    test(100, \"2.0\", \"0x2.0000000000000000000000000#100\");\n}\n\n#[test]\n#[should_panic]\nfn two_prec_fail() {\n    Float::two_prec(0);\n}\n\n#[test]\nfn two_prec_properties() {\n    unsigned_gen_var_11().test_properties(|p| {\n        let two = Float::two_prec(p);\n        assert!(two.is_valid());\n        assert_eq!(two, 2);\n        assert_eq!(two, 2.0);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug::Float::with_val(u32::exact_from(p), 2.0))),\n            ComparableFloatRef(&two)\n        );\n\n        assert_eq!(two.get_prec(), Some(p));\n    });\n}\n\n#[test]\nfn test_negative_one_prec() {\n    let negative_one = Float::NEGATIVE_ONE;\n    assert!(negative_one.is_valid());\n    assert_eq!(negative_one, -1);\n    assert_eq!(negative_one, -1.0);\n    assert_eq!(negative_one.to_string(), \"-1.0\");\n    assert_eq!(negative_one.get_prec(), Some(1));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug::Float::with_val(1, -1.0))),\n        ComparableFloatRef(&negative_one)\n    );\n    assert_eq!(\n        ComparableFloat(Float::negative_one_prec(1)),\n        ComparableFloat(negative_one)\n    );\n\n    let test = |p, out, out_hex| {\n        let negative_one = Float::negative_one_prec(p);\n        assert!(negative_one.is_valid());\n        assert_eq!(negative_one.to_string(), out);\n        assert_eq!(to_hex_string(&negative_one), out_hex);\n        assert_eq!(\n            ComparableFloat(Float::from(&rug::Float::with_val(u32::exact_from(p), -1.0))),\n            ComparableFloat(negative_one)\n        );\n    };\n    test(1, \"-1.0\", \"-0x1.0#1\");\n    test(2, \"-1.0\", \"-0x1.0#2\");\n    test(3, \"-1.0\", \"-0x1.0#3\");\n    test(10, \"-1.0\", \"-0x1.000#10\");\n    test(100, \"-1.0\", \"-0x1.0000000000000000000000000#100\");\n}\n\n#[test]\n#[should_panic]\nfn negative_one_prec_fail() {\n    Float::negative_one_prec(0);\n}\n\n#[test]\nfn negative_one_prec_properties() {\n    unsigned_gen_var_11().test_properties(|p| {\n        let negative_one = Float::negative_one_prec(p);\n        assert!(negative_one.is_valid());\n        assert_eq!(negative_one, -1);\n        assert_eq!(negative_one, -1.0);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug::Float::with_val(\n                u32::exact_from(p),\n                -1.0\n            ))),\n            ComparableFloatRef(&negative_one)\n        );\n\n        assert_eq!(negative_one.get_prec(), Some(p));\n    });\n}\n\n#[test]\nfn test_one_half_prec() {\n    let one_half = Float::ONE_HALF;\n    assert!(one_half.is_valid());\n    assert_eq!(one_half, 0.5);\n    assert_eq!(one_half.to_string(), \"0.5\");\n    assert_eq!(one_half.get_prec(), Some(1));\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug::Float::with_val(1, 0.5))),\n        ComparableFloatRef(&one_half)\n    );\n    assert_eq!(\n        ComparableFloat(Float::one_half_prec(1)),\n        ComparableFloat(one_half)\n    );\n\n    let test = |p, out, out_hex| {\n        let one_half = Float::one_half_prec(p);\n        assert!(one_half.is_valid());\n        assert_eq!(one_half.to_string(), out);\n        assert_eq!(to_hex_string(&one_half), out_hex);\n        assert_eq!(\n            ComparableFloat(Float::from(&rug::Float::with_val(u32::exact_from(p), 0.5))),\n            ComparableFloat(one_half)\n        );\n    };\n    test(1, \"0.5\", \"0x0.8#1\");\n    test(2, \"0.5\", \"0x0.8#2\");\n    test(3, \"0.5\", \"0x0.8#3\");\n    test(10, \"0.5\", \"0x0.800#10\");\n    test(100, \"0.5\", \"0x0.8000000000000000000000000#100\");\n}\n\n#[test]\n#[should_panic]\nfn one_half_prec_fail() {\n    Float::one_half_prec(0);\n}\n\n#[test]\nfn one_half_prec_properties() {\n    unsigned_gen_var_11().test_properties(|p| {\n        let one_half = Float::one_half_prec(p);\n        assert!(one_half.is_valid());\n        assert_eq!(one_half, 0.5);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug::Float::with_val(u32::exact_from(p), 0.5))),\n            ComparableFloatRef(&one_half)\n        );\n\n        assert_eq!(one_half.get_prec(), Some(p));\n    });\n}\n\n#[test]\nfn test_negative_zero() {\n    let negative_zero = Float::NEGATIVE_ZERO;\n    assert!(negative_zero.is_valid());\n    assert_eq!(negative_zero, 0);\n    assert!(negative_zero.is_negative_zero());\n    assert!(negative_zero.is_zero());\n    assert_eq!(negative_zero.to_string(), \"-0.0\");\n    assert_eq!(\n        ComparableFloat(Float::from(&rug::Float::with_val(1, Special::NegZero))),\n        ComparableFloat(negative_zero)\n    );\n}\n\n#[test]\nfn test_nan() {\n    let nan = Float::NAN;\n    assert!(nan.is_valid());\n    assert!(nan.is_nan());\n    assert_eq!(nan.to_string(), \"NaN\");\n    assert_eq!(\n        ComparableFloat(Float::from(&rug::Float::with_val(1, Special::Nan))),\n        ComparableFloat(nan)\n    );\n}\n\n#[test]\nfn test_infinity() {\n    let infinity = Float::INFINITY;\n    assert!(infinity.is_valid());\n    assert_eq!(infinity, f64::INFINITY);\n    assert_eq!(infinity.to_string(), \"Infinity\");\n    assert_eq!(\n        Float::from(&rug::Float::with_val(1, Special::Infinity)),\n        infinity\n    );\n}\n\n#[test]\nfn test_negative_infinity() {\n    let negative_infinity = Float::NEGATIVE_INFINITY;\n    assert!(negative_infinity.is_valid());\n    assert_eq!(negative_infinity, f64::NEGATIVE_INFINITY);\n    assert_eq!(negative_infinity.to_string(), \"-Infinity\");\n    assert_eq!(\n        Float::from(&rug::Float::with_val(1, Special::NegInfinity)),\n        negative_infinity\n    );\n}\n\n#[test]\nfn test_default() {\n    let d = Float::default();\n    assert!(d.is_valid());\n    assert!(d.is_nan());\n    assert_eq!(d.to_string(), \"NaN\");\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/get_and_set.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::strings::ToDebugString;\nuse malachite_float::test_util::common::{\n    parse_hex_string, rug_round_exact_from_rounding_mode, to_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_12, float_unsigned_pair_gen_var_1, float_unsigned_pair_gen_var_4,\n    float_unsigned_rounding_mode_triple_gen_var_1, float_unsigned_rounding_mode_triple_gen_var_4,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_to_significand() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let significand = x.to_significand();\n        assert_eq!(x.significand_ref(), significand.as_ref());\n        assert_eq!(x.clone().into_significand(), significand);\n        if Limb::WIDTH == u64::WIDTH {\n            assert_eq!(significand.to_debug_string(), out);\n            assert_eq!(\n                rug::Float::exact_from(&x)\n                    .get_significand()\n                    .map(|s| Natural::exact_from(&*s)),\n                significand\n            );\n        }\n    };\n    test(\"NaN\", \"NaN\", \"None\");\n    test(\"Infinity\", \"Infinity\", \"None\");\n    test(\"-Infinity\", \"-Infinity\", \"None\");\n    test(\"0.0\", \"0x0.0\", \"None\");\n    test(\"-0.0\", \"-0x0.0\", \"None\");\n\n    test(\"1.0\", \"0x1.0#1\", \"Some(9223372036854775808)\");\n    test(\"2.0\", \"0x2.0#1\", \"Some(9223372036854775808)\");\n    test(\"0.5\", \"0x0.8#1\", \"Some(9223372036854775808)\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"Some(12297829382473033728)\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"Some(13043817825332783104)\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"Some(14488038916154245120)\",\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"Some(9223372036854775808)\");\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"Some(9223372036854775808)\");\n    test(\n        \"2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        \"Some(57896044618658097711785492504343953926634992332820282019728792003956564819968)\",\n    );\n    test(\n        \"3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        \"Some(57896044618658097711785492504343953926634992332820282019728792003956564819968)\",\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", \"Some(9223372036854775808)\");\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"Some(9223372036854775808)\",\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"Some(9223372036854775808)\");\n    test(\"-2.0\", \"-0x2.0#1\", \"Some(9223372036854775808)\");\n    test(\"-0.5\", \"-0x0.8#1\", \"Some(9223372036854775808)\");\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"Some(12297829382473033728)\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"Some(13043817825332783104)\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"Some(14488038916154245120)\",\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"Some(9223372036854775808)\");\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"Some(9223372036854775808)\");\n    test(\n        \"-2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        \"Some(57896044618658097711785492504343953926634992332820282019728792003956564819968)\",\n    );\n    test(\n        \"-3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        \"Some(57896044618658097711785492504343953926634992332820282019728792003956564819968)\",\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"Some(9223372036854775808)\",\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"Some(9223372036854775808)\",\n    );\n}\n\nfn to_significand_properties_helper(x: Float) {\n    let significand = x.to_significand();\n    assert_eq!(x.significand_ref(), significand.as_ref());\n    assert_eq!(x.clone().into_significand(), significand);\n    if Limb::WIDTH == u64::WIDTH {\n        assert_eq!(\n            rug::Float::exact_from(&x)\n                .get_significand()\n                .map(|s| Natural::exact_from(&*s)),\n            significand\n        );\n    }\n\n    significand.as_ref().map_or_else(\n        || {\n            assert!(!x.is_normal());\n        },\n        |significand| {\n            assert_ne!(*significand, 0u32);\n            assert!(\n                significand\n                    .significant_bits()\n                    .divisible_by_power_of_2(Limb::LOG_WIDTH)\n            );\n        },\n    );\n    assert_eq!((-x).into_significand(), significand);\n}\n\n#[test]\nfn to_significand_properties() {\n    float_gen().test_properties(|x| {\n        to_significand_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        to_significand_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_get_exponent() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let exponent = x.get_exponent();\n        assert_eq!(exponent, out);\n        assert_eq!(rug::Float::exact_from(&x).get_exp(), out);\n    };\n    test(\"NaN\", \"NaN\", None);\n    test(\"Infinity\", \"Infinity\", None);\n    test(\"-Infinity\", \"-Infinity\", None);\n    test(\"0.0\", \"0x0.0\", None);\n    test(\"-0.0\", \"-0x0.0\", None);\n\n    test(\"1.0\", \"0x1.0#1\", Some(1));\n    test(\"2.0\", \"0x2.0#1\", Some(2));\n    test(\"0.5\", \"0x0.8#1\", Some(0));\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", Some(-1));\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", Some(1));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", Some(2));\n    test(\"3.0e120\", \"0x1.0E+100#1\", Some(401));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", Some(-399));\n    test(\n        \"2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        Some(401),\n    );\n    test(\n        \"3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        Some(-399),\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", Some(1073741823));\n    test(\"too_small\", \"0x1.0E-268435456#1\", Some(-1073741823));\n\n    test(\"-1.0\", \"-0x1.0#1\", Some(1));\n    test(\"-2.0\", \"-0x2.0#1\", Some(2));\n    test(\"-0.5\", \"-0x0.8#1\", Some(0));\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", Some(-1));\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", Some(1));\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", Some(2));\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", Some(401));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", Some(-399));\n    test(\n        \"-2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        Some(401),\n    );\n    test(\n        \"-3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        Some(-399),\n    );\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", Some(1073741823));\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", Some(-1073741823));\n}\n\nfn get_exponent_properties_helper(x: Float) {\n    let exponent = x.get_exponent();\n    assert_eq!(rug::Float::exact_from(&x).get_exp(), exponent);\n    if let Some(exponent) = exponent {\n        assert_eq!(x.sci_exponent() + 1, exponent);\n        assert!(exponent <= Float::MAX_EXPONENT);\n        assert!(exponent >= Float::MIN_EXPONENT);\n    } else {\n        assert!(!x.is_normal());\n    }\n}\n\n#[test]\nfn get_exponent_properties() {\n    float_gen().test_properties(|x| {\n        get_exponent_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        get_exponent_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_get_prec() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let exponent = x.get_prec();\n        assert_eq!(exponent, out);\n        if x.is_normal() {\n            assert_eq!(Some(u64::from(rug::Float::exact_from(&x).prec())), out);\n        }\n    };\n    test(\"NaN\", \"NaN\", None);\n    test(\"Infinity\", \"Infinity\", None);\n    test(\"-Infinity\", \"-Infinity\", None);\n    test(\"0.0\", \"0x0.0\", None);\n    test(\"-0.0\", \"-0x0.0\", None);\n\n    test(\"1.0\", \"0x1.0#1\", Some(1));\n    test(\"2.0\", \"0x2.0#1\", Some(1));\n    test(\"0.5\", \"0x0.8#1\", Some(1));\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", Some(53));\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", Some(53));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", Some(53));\n    test(\"3.0e120\", \"0x1.0E+100#1\", Some(1));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", Some(1));\n    test(\n        \"2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        Some(200),\n    );\n    test(\n        \"3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        Some(200),\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", Some(1));\n    test(\"too_small\", \"0x1.0E-268435456#1\", Some(1));\n\n    test(\"-1.0\", \"-0x1.0#1\", Some(1));\n    test(\"-2.0\", \"-0x2.0#1\", Some(1));\n    test(\"-0.5\", \"-0x0.8#1\", Some(1));\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", Some(53));\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", Some(53));\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", Some(53));\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", Some(1));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", Some(1));\n    test(\n        \"-2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        Some(200),\n    );\n    test(\n        \"-3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        Some(200),\n    );\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", Some(1));\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", Some(1));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn get_prec_properties_helper(x: Float) {\n    x.get_prec().map_or_else(\n        || {\n            assert!(!x.is_normal());\n        },\n        |precision| {\n            assert_eq!(u64::from(rug::Float::exact_from(&x).prec()), precision);\n        },\n    );\n}\n\n#[test]\nfn get_prec_properties() {\n    float_gen().test_properties(|x| {\n        get_prec_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        get_prec_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_get_min_prec() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let exponent = x.get_min_prec();\n        assert_eq!(exponent, out);\n    };\n    test(\"NaN\", \"NaN\", None);\n    test(\"Infinity\", \"Infinity\", None);\n    test(\"-Infinity\", \"-Infinity\", None);\n    test(\"0.0\", \"0x0.0\", None);\n    test(\"-0.0\", \"-0x0.0\", None);\n\n    test(\"1.0\", \"0x1.0#1\", Some(1));\n    test(\"2.0\", \"0x2.0#1\", Some(1));\n    test(\"0.5\", \"0x0.8#1\", Some(1));\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", Some(53));\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", Some(53));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", Some(50));\n    test(\"3.0e120\", \"0x1.0E+100#1\", Some(1));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", Some(1));\n    test(\n        \"2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        Some(1),\n    );\n    test(\n        \"3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        Some(1),\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", Some(1));\n    test(\"too_small\", \"0x1.0E-268435456#1\", Some(1));\n\n    test(\"-1.0\", \"-0x1.0#1\", Some(1));\n    test(\"-2.0\", \"-0x2.0#1\", Some(1));\n    test(\"-0.5\", \"-0x0.8#1\", Some(1));\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", Some(53));\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", Some(53));\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", Some(50));\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", Some(1));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", Some(1));\n    test(\n        \"-2.582249878086908589655919172003011874329705792829223512830659e120\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E+100#200\",\n        Some(1),\n    );\n    test(\n        \"-3.872591914849318272818030633286351847570219192048790865487763e-121\",\n        \"-0x1.00000000000000000000000000000000000000000000000000E-100#200\",\n        Some(1),\n    );\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", Some(1));\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", Some(1));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn get_min_prec_properties_helper(x: Float) {\n    x.get_min_prec().map_or_else(\n        || {\n            assert!(!x.is_normal());\n        },\n        |min_prec| {\n            assert!(min_prec <= x.get_prec().unwrap());\n        },\n    );\n}\n\n#[test]\nfn get_min_prec_properties() {\n    float_gen().test_properties(|x| {\n        get_min_prec_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        get_min_prec_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_set_prec_round() {\n    let test = |s, s_hex, prec, rm, out, out_hex, o| {\n        let mut x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let old_x = x.clone();\n        assert_eq!(x.set_prec_round(prec, rm), o);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        let (x_alt, o_alt) = Float::from_float_prec_round(old_x.clone(), prec, rm);\n        assert!(x_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n        assert_eq!(o_alt, o);\n\n        let (x_alt, o_alt) = Float::from_float_prec_round_ref(&old_x, prec, rm);\n        assert!(x_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n        assert_eq!(o_alt, o);\n\n        if rm != Exact {\n            let mut rug_x = rug::Float::exact_from(&old_x);\n            assert_eq!(\n                rug_x.set_prec_round(\n                    u32::exact_from(prec),\n                    rug_round_exact_from_rounding_mode(rm)\n                ),\n                o\n            );\n            assert_eq!(ComparableFloat(x), ComparableFloat(Float::from(&rug_x)));\n        }\n    };\n    test(\"NaN\", \"NaN\", 100, Floor, \"NaN\", \"NaN\", Equal);\n    test(\"NaN\", \"NaN\", 100, Exact, \"NaN\", \"NaN\", Equal);\n    test(\n        \"Infinity\", \"Infinity\", 100, Floor, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"Infinity\", \"Infinity\", 100, Exact, \"Infinity\", \"Infinity\", Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        100,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        100,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", 100, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0.0\", \"0x0.0\", 100, Exact, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 100, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 100, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        100,\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        100,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        100,\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        100,\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        100,\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        100,\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Floor,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Ceiling,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Down,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Up,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Nearest,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Exact,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"3.141\",\n        \"0x3.24#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"3.145\",\n        \"0x3.25#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"3.141\",\n        \"0x3.24#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"3.145\",\n        \"0x3.25#10\",\n        Greater,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"3.141\",\n        \"0x3.24#10\",\n        Less,\n    );\n\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    // It doesn't really make sense that rounding with `Nearest` could overflow, but this matches\n    // the behavior of MPFR.\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Less,\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Less,\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        1,\n        Up,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Greater,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        100,\n        Floor,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        100,\n        Ceiling,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        100,\n        Down,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        100,\n        Up,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        100,\n        Nearest,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        100,\n        Exact,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Floor,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Floor,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Down,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Up,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Nearest,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Exact,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Floor,\n        \"-3.145\",\n        \"-0x3.25#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Ceiling,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Down,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Up,\n        \"-3.145\",\n        \"-0x3.25#10\",\n        Less,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        Nearest,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    test(\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test(\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test(\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test(\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    // It doesn't really make sense that rounding with `Nearest` could overflow, but this matches\n    // the behavior of MPFR.\n    test(\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        1,\n        Ceiling,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        1,\n        Down,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Greater,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Less,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Less,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn set_prec_round_fail() {\n    let mut x = Float::from(std::f64::consts::PI);\n    x.set_prec_round(10, Exact);\n}\n\nfn set_prec_round_properties_helper(mut x: Float, prec: u64, rm: RoundingMode) {\n    let old_x = x.clone();\n    let o = x.set_prec_round(prec, rm);\n    assert!(x.is_valid());\n    let final_x = x.clone();\n    if x.is_normal() {\n        assert_eq!(x.get_prec(), Some(prec));\n        assert_eq!(x.partial_cmp(&old_x), Some(o));\n    } else {\n        assert!(o != if x > 0 { Less } else { Greater });\n    }\n\n    let (x_alt, o_alt) = Float::from_float_prec_round(old_x.clone(), prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n\n    let (x_alt, o_alt) = Float::from_float_prec_round_ref(&old_x, prec, rm);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n\n    if rm == Exact {\n        assert_eq!(o, Equal);\n    } else {\n        let mut rug_x = rug::Float::exact_from(&old_x);\n        assert_eq!(\n            rug_x.set_prec_round(\n                u32::exact_from(prec),\n                rug_round_exact_from_rounding_mode(rm)\n            ),\n            o\n        );\n        assert_eq!(\n            ComparableFloatRef(&x),\n            ComparableFloatRef(&Float::from(&rug_x))\n        );\n    }\n\n    if o == Equal\n        && let Some(old_precision) = old_x.get_prec()\n    {\n        assert_eq!(x.set_prec_round(old_precision, Exact), Equal);\n        assert_eq!(ComparableFloatRef(&x), ComparableFloatRef(&old_x));\n    }\n\n    let mut x = -old_x;\n    x.set_prec_round(prec, -rm);\n    assert_eq!(ComparableFloat(x), ComparableFloat(-final_x));\n}\n\n#[test]\nfn set_prec_round_properties() {\n    float_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        set_prec_round_properties_helper(x, prec, rm);\n    });\n\n    float_unsigned_rounding_mode_triple_gen_var_4().test_properties(|(x, prec, rm)| {\n        set_prec_round_properties_helper(x, prec, rm);\n    });\n}\n\n#[test]\nfn test_set_prec() {\n    let test = |s, s_hex, prec, out, out_hex, o| {\n        let mut x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let old_x = x.clone();\n        assert_eq!(x.set_prec(prec), o);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        let (x_alt, o_alt) = Float::from_float_prec(old_x.clone(), prec);\n        assert!(x_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n        assert_eq!(o_alt, o);\n\n        let (x_alt, o_alt) = Float::from_float_prec_ref(&old_x, prec);\n        assert!(x_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n        assert_eq!(o_alt, o);\n\n        let mut rug_x = rug::Float::exact_from(&old_x);\n        rug_x.set_prec(u32::exact_from(prec));\n        assert_eq!(ComparableFloat(x), ComparableFloat(Float::from(&rug_x)));\n    };\n    test(\"NaN\", \"NaN\", 100, \"NaN\", \"NaN\", Equal);\n    test(\"Infinity\", \"Infinity\", 100, \"Infinity\", \"Infinity\", Equal);\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        100,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test(\"0.0\", \"0x0.0\", 100, \"0.0\", \"0x0.0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", 100, \"-0.0\", \"-0x0.0\", Equal);\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        100,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        10,\n        \"0.3335\",\n        \"0x0.556#10\",\n        Greater,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        10,\n        \"1.414\",\n        \"0x1.6a0#10\",\n        Less,\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        10,\n        \"3.141\",\n        \"0x3.24#10\",\n        Less,\n    );\n    // It doesn't really make sense that rounding with `Nearest` could overflow, but this matches\n    // the behavior of MPFR.\n    test(\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test(\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n        1,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Greater,\n    );\n\n    test(\n        \"-1.0\",\n        \"-0x1.0#1\",\n        100,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        10,\n        \"-0.3335\",\n        \"-0x0.556#10\",\n        Less,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        10,\n        \"-1.414\",\n        \"-0x1.6a0#10\",\n        Greater,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        10,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    // It doesn't really make sense that rounding with `Nearest` could overflow, but this matches\n    // the behavior of MPFR.\n    test(\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n        1,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Less,\n    );\n}\n\nfn set_prec_properties_helper(mut x: Float, prec: u64) {\n    let old_x = x.clone();\n    let o = x.set_prec(prec);\n    let final_x = x.clone();\n    assert!(x.is_valid());\n    if x.is_normal() {\n        assert_eq!(x.get_prec(), Some(prec));\n        assert_eq!(x.partial_cmp(&old_x), Some(o));\n    } else {\n        assert!(o != if x > 0 { Less } else { Greater });\n    }\n\n    let (x_alt, o_alt) = Float::from_float_prec(old_x.clone(), prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n\n    let (x_alt, o_alt) = Float::from_float_prec_ref(&old_x, prec);\n    assert!(x_alt.is_valid());\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n\n    let mut rug_x = rug::Float::exact_from(&old_x);\n    rug_x.set_prec(u32::exact_from(prec));\n    assert_eq!(\n        ComparableFloatRef(&x),\n        ComparableFloatRef(&Float::from(&rug_x))\n    );\n\n    if o == Equal\n        && let Some(old_precision) = old_x.get_prec()\n    {\n        assert_eq!(x.set_prec_round(old_precision, Exact), Equal);\n        assert_eq!(ComparableFloatRef(&x), ComparableFloatRef(&old_x));\n    }\n\n    let mut x = -old_x;\n    x.set_prec(prec);\n    assert_eq!(ComparableFloat(x), ComparableFloat(-final_x));\n}\n\n#[test]\nfn set_prec_properties() {\n    float_unsigned_pair_gen_var_1().test_properties(|(x, prec)| {\n        set_prec_properties_helper(x, prec);\n    });\n\n    float_unsigned_pair_gen_var_4().test_properties(|(x, prec)| {\n        set_prec_properties_helper(x, prec);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/named.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_float::Float;\n\n#[test]\nfn test_named() {\n    assert_eq!(Float::NAME, \"Float\");\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/overflow_and_underflow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::{self, *};\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_ordering_pair_gen, float_ordering_pair_gen_var_1,\n};\nuse malachite_float::{Float, test_overflow, test_underflow};\n\n#[test]\nfn test_test_overflow() {\n    let test = |s, s_hex, o, out: bool| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(test_overflow(&x, o), out);\n    };\n    test(\"Infinity\", \"Infinity\", Greater, true);\n    // This input doesn't actually make sense, since Infinity can't be less than the actual value\n    test(\"Infinity\", \"Infinity\", Less, false);\n    test(\"-Infinity\", \"-Infinity\", Less, true);\n    // Likewise\n    test(\"-Infinity\", \"-Infinity\", Greater, false);\n\n    test(\"too_big\", \"0x4.0E+268435455#1\", Equal, false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", Less, true);\n    test(\"too_big\", \"0x6.0E+268435455#2\", Less, true);\n    test(\"too_big\", \"0x7.0E+268435455#3\", Less, true);\n    test(\"too_big\", \"0x7.feE+268435455#10\", Less, true);\n    test(\n        \"too_big\",\n        \"0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        Less,\n        true,\n    );\n    test(\"too_big\", \"0x4.0E+268435454#1\", Less, false);\n    test(\"too_big\", \"0x6.0E+268435454#2\", Less, false);\n    test(\"too_big\", \"0x7.0E+268435454#3\", Less, false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", Greater, false);\n    test(\"too_big\", \"0x6.0E+268435455#2\", Greater, false);\n    test(\"too_big\", \"0x7.0E+268435455#3\", Greater, false);\n    test(\"too_big\", \"0x7.feE+268435455#10\", Greater, false);\n    test(\n        \"too_big\",\n        \"0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        Greater,\n        false,\n    );\n\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", Equal, false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", Greater, true);\n    test(\"-too_big\", \"-0x6.0E+268435455#2\", Greater, true);\n    test(\"-too_big\", \"-0x7.0E+268435455#3\", Greater, true);\n    test(\"-too_big\", \"-0x7.feE+268435455#10\", Greater, true);\n    test(\n        \"-too_big\",\n        \"-0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        Greater,\n        true,\n    );\n    test(\"-too_big\", \"-0x4.0E+268435454#1\", Greater, false);\n    test(\"-too_big\", \"-0x6.0E+268435454#2\", Greater, false);\n    test(\"-too_big\", \"-0x7.0E+268435454#3\", Greater, false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", Less, false);\n    test(\"-too_big\", \"-0x6.0E+268435455#2\", Less, false);\n    test(\"-too_big\", \"-0x7.0E+268435455#3\", Less, false);\n    test(\"-too_big\", \"-0x7.feE+268435455#10\", Less, false);\n    test(\n        \"-too_big\",\n        \"-0x7.ffffffffffffffffffffffff8E+268435455#100\",\n        Less,\n        false,\n    );\n\n    test(\"0.0\", \"0x0.0\", Equal, false);\n    test(\"-0.0\", \"-0x0.0\", Equal, false);\n    test(\"1.0\", \"0x1.0#1\", Equal, false);\n    test(\"-1.0\", \"-0x1.0#1\", Equal, false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn test_overflow_properties_helper(x: Float, o: Ordering) {\n    let overflow = test_overflow(&x, o);\n    assert_eq!(test_overflow(&-x, o.reverse()), overflow);\n}\n\n#[test]\nfn test_overflow_properties() {\n    float_ordering_pair_gen().test_properties(|(x, o)| {\n        test_overflow_properties_helper(x, o);\n    });\n\n    float_ordering_pair_gen_var_1().test_properties(|(x, o)| {\n        test_overflow_properties_helper(x, o);\n    });\n}\n\n#[test]\nfn test_test_underflow() {\n    let test = |s, s_hex, o, out: bool| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(test_underflow(&x, o), out);\n    };\n    test(\"0.0\", \"0x0.0\", Less, true);\n    test(\"0.0\", \"0x0.0\", Greater, true);\n    test(\"-0.0\", \"-0x0.0\", Less, true);\n    test(\"-0.0\", \"-0x0.0\", Greater, true);\n\n    test(\"too_small\", \"0x1.0E-268435456#1\", Equal, false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", Greater, true);\n    test(\"too_small\", \"0x1.0E-268435456#2\", Greater, true);\n    test(\"too_small\", \"0x1.0E-268435456#3\", Greater, true);\n    test(\"too_small\", \"0x1.000E-268435456#10\", Greater, true);\n    test(\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Greater,\n        true,\n    );\n    test(\"too_small\", \"0x1.8E-268435456#2\", Greater, false);\n    test(\"too_small\", \"0x2.0E-268435456#1\", Greater, false);\n    test(\"too_small\", \"0x1.0E-268435455#1\", Greater, false);\n    test(\"too_small\", \"0x1.0E-268435456#1\", Less, false);\n    test(\"too_small\", \"0x1.0E-268435456#2\", Less, false);\n    test(\"too_small\", \"0x1.0E-268435456#3\", Less, false);\n    test(\"too_small\", \"0x1.000E-268435456#10\", Less, false);\n    test(\n        \"too_small\",\n        \"0x1.0000000000000000000000000E-268435456#100\",\n        Less,\n        false,\n    );\n\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", Equal, false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", Less, true);\n    test(\"-too_small\", \"-0x1.0E-268435456#2\", Less, true);\n    test(\"-too_small\", \"-0x1.0E-268435456#3\", Less, true);\n    test(\"-too_small\", \"-0x1.000E-268435456#10\", Less, true);\n    test(\n        \"-too_small\",\n        \"-0x1.0000000000000000000000000E-268435456#100\",\n        Less,\n        true,\n    );\n    test(\"-too_small\", \"-0x1.8E-268435456#2\", Less, false);\n    test(\"-too_small\", \"-0x2.0E-268435456#1\", Less, false);\n    test(\"-too_small\", \"-0x1.0E-268435455#1\", Less, false);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", Greater, false);\n    test(\"-too_small\", \"-0x1.0E-268435456#2\", Greater, false);\n    test(\"-too_small\", \"-0x1.0E-268435456#3\", Greater, false);\n    test(\"-too_small\", \"-0x1.000E-268435456#10\", Greater, false);\n    test(\n        \"-too_small\",\n        \"-0x1.0000000000000000000000000E-268435456#100\",\n        Greater,\n        false,\n    );\n\n    test(\"0.0\", \"0x0.0\", Equal, false);\n    test(\"-0.0\", \"-0x0.0\", Equal, false);\n    test(\"1.0\", \"0x1.0#1\", Equal, false);\n    test(\"-1.0\", \"-0x1.0#1\", Equal, false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn test_underflow_properties_helper(x: Float, o: Ordering) {\n    let underflow = test_underflow(&x, o);\n    assert_eq!(test_underflow(&-x, o.reverse()), underflow);\n}\n\n#[test]\nfn test_underflow_properties() {\n    float_ordering_pair_gen().test_properties(|(x, o)| {\n        test_underflow_properties_helper(x, o);\n    });\n\n    float_ordering_pair_gen_var_1().test_properties(|(x, o)| {\n        test_underflow_properties_helper(x, o);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/size.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::Float;\nuse std::mem::size_of;\n\n#[test]\nfn test_size() {\n    if size_of::<usize>() == size_of::<u64>() {\n        assert_eq!(size_of::<Float>(), 40);\n    }\n}\n"
  },
  {
    "path": "malachite-float/tests/basic/ulp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::assert_panic;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\nuse malachite_base::test_util::generators::primitive_float_gen_var_12;\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::conversion::from_primitive_float::alt_precision;\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_3, float_gen_var_12, float_gen_var_13,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse std::panic::catch_unwind;\n\n#[allow(clippy::redundant_closure_for_method_calls)]\n#[test]\nfn test_ulp() {\n    let test = |s, s_hex, out: Option<&str>, out_hex: Option<&str>| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let actual_out = x.ulp();\n        assert!(actual_out.as_ref().is_none_or(Float::is_valid));\n\n        let s = actual_out.as_ref().map(|x| x.to_string());\n        assert_eq!(s.as_deref(), out);\n        let s = actual_out.map(|x| to_hex_string(&x));\n        assert_eq!(s.as_deref(), out_hex);\n    };\n    test(\"NaN\", \"NaN\", None, None);\n    test(\"Infinity\", \"Infinity\", None, None);\n    test(\"-Infinity\", \"-Infinity\", None, None);\n    test(\"0.0\", \"0x0.0\", None, None);\n    test(\"-0.0\", \"-0x0.0\", None, None);\n\n    test(\"1.0\", \"0x1.0#1\", Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test(\"2.0\", \"0x2.0#1\", Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test(\"0.5\", \"0x0.8#1\", Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Some(\"6.0e-17\"),\n        Some(\"0x4.0E-14#1\"),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        Some(\"2.0e-16\"),\n        Some(\"0x1.0E-13#1\"),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        Some(\"4.0e-16\"),\n        Some(\"0x2.0E-13#1\"),\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Some(\"too_big\"),\n        Some(\"0x4.0E+268435455#1\"),\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Some(\"too_small\"),\n        Some(\"0x1.0E-268435456#1\"),\n    );\n    test(\"too_small\", \"0x1.0E-268435456#2\", None, None);\n\n    test(\"-1.0\", \"-0x1.0#1\", Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test(\"-2.0\", \"-0x2.0#1\", Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test(\"-0.5\", \"-0x0.8#1\", Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Some(\"6.0e-17\"),\n        Some(\"0x4.0E-14#1\"),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        Some(\"2.0e-16\"),\n        Some(\"0x1.0E-13#1\"),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        Some(\"4.0e-16\"),\n        Some(\"0x2.0E-13#1\"),\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Some(\"too_big\"),\n        Some(\"0x4.0E+268435455#1\"),\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Some(\"too_small\"),\n        Some(\"0x1.0E-268435456#1\"),\n    );\n    test(\"-too_small\", \"-0x1.0E-268435456#2\", None, None);\n}\n\nfn ulp_properties_helper(x: Float) {\n    let ulp = x.ulp();\n    ulp.as_ref().map_or_else(\n        || {},\n        |ulp| {\n            assert!(ulp.is_valid());\n            assert!(*ulp > 0);\n            assert!(ulp.is_power_of_2());\n        },\n    );\n    assert_eq!((-x).ulp().map(ComparableFloat), ulp.map(ComparableFloat));\n}\n\n#[test]\nfn ulp_properties() {\n    float_gen().test_properties(|x| {\n        ulp_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        ulp_properties_helper(x);\n    });\n}\n\n#[test]\nfn test_increment() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let mut x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        x.increment();\n        assert!(x.is_valid());\n\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    };\n    test(\"1.0\", \"0x1.0#1\", \"2.0\", \"0x2.0#2\");\n    test(\"2.0\", \"0x2.0#1\", \"4.0\", \"0x4.0#2\");\n    test(\"0.5\", \"0x0.8#1\", \"1.0\", \"0x1.0#2\");\n    test(\"1.0\", \"0x1.0#2\", \"1.5\", \"0x1.8#2\");\n    test(\"2.0\", \"0x2.0#2\", \"3.0\", \"0x3.0#2\");\n    test(\"0.5\", \"0x0.8#2\", \"0.8\", \"0x0.c#2\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"1.000000000000000000000000000002\",\n        \"0x1.0000000000000000000000002#100\",\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0.33333333333333337\",\n        \"0x0.55555555555558#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730954\",\n        \"0x1.6a09e667f3bce#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3.1415926535897936\",\n        \"0x3.243f6a8885a32#53\",\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#2\",\n        \"too_big\",\n        \"0x6.0E+268435455#2\",\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", \"Infinity\", \"Infinity\");\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"too_small\",\n        \"0x2.0E-268435456#2\",\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#2\",\n        \"too_small\",\n        \"0x1.8E-268435456#2\",\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"-0.0\", \"-0x0.0\");\n    test(\"-2.0\", \"-0x2.0#1\", \"-0.0\", \"-0x0.0\");\n    test(\"-0.5\", \"-0x0.8#1\", \"-0.0\", \"-0x0.0\");\n    test(\"-1.0\", \"-0x1.0#2\", \"-0.5\", \"-0x0.8#1\");\n    test(\"-2.0\", \"-0x2.0#2\", \"-1.0\", \"-0x1.0#1\");\n    test(\"-0.5\", \"-0x0.8#2\", \"-0.2\", \"-0x0.4#1\");\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        \"-0.999999999999999999999999999998\",\n        \"-0x0.ffffffffffffffffffffffffe#99\",\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-0.33333333333333326\",\n        \"-0x0.55555555555550#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1.4142135623730949\",\n        \"-0x1.6a09e667f3bcc#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3.1415926535897927\",\n        \"-0x3.243f6a8885a2e#53\",\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#2\",\n        \"-too_big\",\n        \"-0x2.0E+268435455#1\",\n    );\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", \"-0.0\", \"-0x0.0\");\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", \"-0.0\", \"-0x0.0\");\n    test(\"-too_small\", \"-0x1.0E-268435456#2\", \"-0.0\", \"-0x0.0\");\n}\n\n#[test]\nfn increment_fail() {\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.increment();\n    });\n    assert_panic!({\n        let mut x = Float::INFINITY;\n        x.increment();\n    });\n    assert_panic!({\n        let mut x = Float::NEGATIVE_INFINITY;\n        x.increment();\n    });\n    assert_panic!({\n        let mut x = Float::ZERO;\n        x.increment();\n    });\n    assert_panic!({\n        let mut x = Float::NEGATIVE_ZERO;\n        x.increment();\n    });\n}\n\nfn increment_properties_helper(mut x: Float, extreme: bool) {\n    let old_x = x.clone();\n    x.increment();\n    let final_x = x.clone();\n    assert!(x.is_valid());\n    if !extreme {\n        assert_eq!(\n            Rational::exact_from(&old_x) + Rational::exact_from(old_x.ulp().unwrap()),\n            Rational::exact_from(&x)\n        );\n    }\n    if x.is_normal() {\n        assert_eq!(x.ulp(), old_x.ulp());\n        assert!(x.get_prec().unwrap().abs_diff(old_x.get_prec().unwrap()) <= 1);\n        x.decrement();\n        assert_eq!(ComparableFloatRef(&x), ComparableFloatRef(&old_x));\n    }\n    let mut x = -old_x;\n    x.decrement();\n    assert_eq!(ComparableFloat(x), ComparableFloat(-final_x));\n}\n\n#[test]\nfn increment_properties() {\n    float_gen_var_3().test_properties(|x| {\n        increment_properties_helper(x, false);\n    });\n\n    float_gen_var_13().test_properties(|x| {\n        increment_properties_helper(x, true);\n    });\n\n    primitive_float_gen_var_12::<f64>().test_properties(|x| {\n        let next_x = x.next_higher();\n        if next_x.is_finite() && next_x != 0.0 && x.sci_exponent() == next_x.sci_exponent() {\n            let mut big_x = Float::from_primitive_float_prec(x, alt_precision(x)).0;\n            big_x.increment();\n            assert_eq!(\n                ComparableFloat(big_x),\n                ComparableFloat(Float::from_primitive_float_prec(next_x, alt_precision(next_x)).0)\n            );\n        }\n    });\n}\n\n#[test]\nfn test_decrement() {\n    let test = |s, s_hex, out: &str, out_hex: &str| {\n        let mut x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        x.decrement();\n        assert!(x.is_valid());\n\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    };\n    test(\"1.0\", \"0x1.0#1\", \"0.0\", \"0x0.0\");\n    test(\"2.0\", \"0x2.0#1\", \"0.0\", \"0x0.0\");\n    test(\"0.5\", \"0x0.8#1\", \"0.0\", \"0x0.0\");\n    test(\"1.0\", \"0x1.0#2\", \"0.5\", \"0x0.8#1\");\n    test(\"2.0\", \"0x2.0#2\", \"1.0\", \"0x1.0#1\");\n    test(\"0.5\", \"0x0.8#2\", \"0.2\", \"0x0.4#1\");\n    test(\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        \"0.999999999999999999999999999998\",\n        \"0x0.ffffffffffffffffffffffffe#99\",\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0.33333333333333326\",\n        \"0x0.55555555555550#53\",\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730949\",\n        \"0x1.6a09e667f3bcc#53\",\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"3.1415926535897927\",\n        \"0x3.243f6a8885a2e#53\",\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#2\",\n        \"too_big\",\n        \"0x2.0E+268435455#1\",\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", \"0.0\", \"0x0.0\");\n    test(\"too_small\", \"0x1.0E-268435456#1\", \"0.0\", \"0x0.0\");\n    test(\"too_small\", \"0x1.0E-268435456#2\", \"0.0\", \"0x0.0\");\n\n    test(\"-1.0\", \"-0x1.0#1\", \"-2.0\", \"-0x2.0#2\");\n    test(\"-2.0\", \"-0x2.0#1\", \"-4.0\", \"-0x4.0#2\");\n    test(\"-0.5\", \"-0x0.8#1\", \"-1.0\", \"-0x1.0#2\");\n    test(\"-1.0\", \"-0x1.0#2\", \"-1.5\", \"-0x1.8#2\");\n    test(\"-2.0\", \"-0x2.0#2\", \"-3.0\", \"-0x3.0#2\");\n    test(\"-0.5\", \"-0x0.8#2\", \"-0.8\", \"-0x0.c#2\");\n    test(\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        \"-1.000000000000000000000000000002\",\n        \"-0x1.0000000000000000000000002#100\",\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-0.33333333333333337\",\n        \"-0x0.55555555555558#53\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1.4142135623730954\",\n        \"-0x1.6a09e667f3bce#53\",\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-3.1415926535897936\",\n        \"-0x3.243f6a8885a32#53\",\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#2\",\n        \"-too_big\",\n        \"-0x6.0E+268435455#2\",\n    );\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", \"-Infinity\", \"-Infinity\");\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"-too_small\",\n        \"-0x2.0E-268435456#2\",\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#2\",\n        \"-too_small\",\n        \"-0x1.8E-268435456#2\",\n    );\n}\n\n#[test]\nfn decrement_fail() {\n    assert_panic!({\n        let mut x = Float::NAN;\n        x.decrement();\n    });\n    assert_panic!({\n        let mut x = Float::INFINITY;\n        x.decrement();\n    });\n    assert_panic!({\n        let mut x = Float::NEGATIVE_INFINITY;\n        x.decrement();\n    });\n    assert_panic!({\n        let mut x = Float::ZERO;\n        x.decrement();\n    });\n    assert_panic!({\n        let mut x = Float::NEGATIVE_ZERO;\n        x.decrement();\n    });\n}\n\nfn decrement_properties_helper(mut x: Float, extreme: bool) {\n    let old_x = x.clone();\n    x.decrement();\n    let final_x = x.clone();\n    assert!(x.is_valid());\n    if !extreme {\n        assert_eq!(\n            Rational::exact_from(&old_x) - Rational::exact_from(old_x.ulp().unwrap()),\n            Rational::exact_from(&x)\n        );\n    }\n    if x.is_normal() {\n        assert_eq!(x.ulp(), old_x.ulp());\n        assert!(x.get_prec().unwrap().abs_diff(old_x.get_prec().unwrap()) <= 1);\n        x.increment();\n        assert_eq!(ComparableFloatRef(&x), ComparableFloatRef(&old_x));\n    }\n    let mut x = -old_x;\n    x.increment();\n    assert_eq!(ComparableFloat(x), ComparableFloat(-final_x));\n}\n\n#[test]\nfn decrement_properties() {\n    float_gen_var_3().test_properties(|x| {\n        decrement_properties_helper(x, false);\n    });\n\n    float_gen_var_13().test_properties(|x| {\n        decrement_properties_helper(x, true);\n    });\n\n    primitive_float_gen_var_12::<f64>().test_properties(|x| {\n        let next_x = x.next_lower();\n        if next_x.is_finite() && next_x != 0.0 && x.sci_exponent() == next_x.sci_exponent() {\n            let mut big_x = Float::from_primitive_float_prec(x, alt_precision(x)).0;\n            big_x.decrement();\n            assert_eq!(\n                ComparableFloat(big_x),\n                ComparableFloat(Float::from_primitive_float_prec(next_x, alt_precision(next_x)).0)\n            );\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::test_util::common::{ORDERED_FLOAT_HEX_STRINGS, parse_hex_string};\nuse malachite_float::test_util::generators::{\n    float_gen, float_pair_gen, float_pair_gen_var_1, float_pair_gen_var_10, float_triple_gen,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\n\nconst fn encode(oo: Option<Ordering>) -> u8 {\n    match oo {\n        None => 9,\n        Some(Less) => 0,\n        Some(Equal) => 1,\n        Some(Greater) => 2,\n    }\n}\n\n#[rustfmt::skip]\nconst MATRIX: [[u8; 21]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 1, 1, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#100\n    [2, 2, 2, 2, 1, 1, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#2\n    [2, 2, 2, 2, 1, 1, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], // NaN\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#1\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#2\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#100\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1],\n];\n\n#[test]\nfn test_partial_cmp() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX.iter()) {\n        let x = parse_hex_string(sx);\n        for (sy, &e) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(row.iter()) {\n            let y = parse_hex_string(sy);\n            assert_eq!(encode(x.partial_cmp(&y)), e);\n            assert_eq!(\n                encode(rug::Float::exact_from(&x).partial_cmp(&rug::Float::exact_from(&y))),\n                e\n            );\n        }\n    }\n}\n\nfn partial_cmp_properties_helper(x: Float, y: Float) {\n    let ord = x.partial_cmp(&y);\n    assert_eq!(y.partial_cmp(&x).map(Ordering::reverse), ord);\n    assert_eq!(x == y, x.partial_cmp(&y) == Some(Equal));\n    assert_eq!((-&y).partial_cmp(&-&x), ord);\n    assert_eq!(\n        rug::Float::exact_from(&x).partial_cmp(&rug::Float::exact_from(&y)),\n        ord\n    );\n    if (!x.is_zero() || !y.is_zero())\n        && let Some(ord) = ord\n        && ord != Equal\n    {\n        assert_eq!(ComparableFloat(x).cmp(&ComparableFloat(y)), ord);\n    }\n}\n\n#[test]\nfn partial_cmp_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_properties_helper(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        partial_cmp_properties_helper(x, y);\n    });\n\n    float_gen().test_properties(|x| {\n        if !x.is_nan() {\n            assert_eq!(x.partial_cmp(&x), Some(Equal));\n            assert!(x <= Float::INFINITY);\n            assert!(x >= Float::NEGATIVE_INFINITY);\n        }\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(\n            Float::from(x).partial_cmp(&Float::from(y)),\n            x.partial_cmp(&y)\n        );\n    });\n\n    float_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(\n            Some(Rational::exact_from(&x).cmp(&Rational::exact_from(&y))),\n            x.partial_cmp(&y)\n        );\n    });\n}\n\nfn read_hex_strings(strings: &[&str]) -> Vec<Float> {\n    strings.iter().map(|s| parse_hex_string(s)).collect()\n}\n\n#[test]\nfn test_comparable_float_cmp() {\n    let xs = read_hex_strings(&ORDERED_FLOAT_HEX_STRINGS);\n    let ys = read_hex_strings(&ORDERED_FLOAT_HEX_STRINGS);\n    for (i, x) in xs.iter().enumerate() {\n        for (j, y) in ys.iter().enumerate() {\n            assert_eq!(\n                i.cmp(&j),\n                ComparableFloat(x.clone()).cmp(&ComparableFloat(y.clone()))\n            );\n            assert_eq!(i.cmp(&j), ComparableFloatRef(x).cmp(&ComparableFloatRef(y)));\n        }\n    }\n}\n\n#[test]\nfn comparable_float_cmp_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        let ord = cx.cmp(&cy);\n        assert_eq!(cy.cmp(&cx).reverse(), ord);\n        assert_eq!(cx == cy, cx.cmp(&cy) == Equal);\n        assert_eq!(\n            ComparableFloat(x.clone()).cmp(&ComparableFloat(y.clone())),\n            ord\n        );\n        assert_eq!((ComparableFloat(-y)).cmp(&ComparableFloat(-x)), ord);\n    });\n\n    float_gen().test_properties(|x| {\n        let cx = ComparableFloatRef(&x);\n        assert_eq!(cx.cmp(&cx), Equal);\n        assert!(cx <= ComparableFloatRef(&Float::INFINITY));\n        assert!(cx >= ComparableFloatRef(&Float::NEGATIVE_INFINITY));\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        let cz = ComparableFloatRef(&z);\n        if cx < cy && cy < cz {\n            assert!(cx < cz);\n        } else if cx > cy && cy > cz {\n            assert!(cx > cz);\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(\n            ComparableFloat(Float::from(x)).cmp(&ComparableFloat(Float::from(y))),\n            NiceFloat(x).cmp(&NiceFloat(y))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::{Infinity, NegativeInfinity};\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::test_util::common::{ORDERED_FLOAT_HEX_STRINGS, parse_hex_string};\nuse malachite_float::test_util::generators::{\n    float_gen, float_pair_gen, float_pair_gen_var_1, float_pair_gen_var_10, float_triple_gen,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\n\nconst fn encode(oo: Option<Ordering>) -> u8 {\n    match oo {\n        None => 9,\n        Some(Less) => 0,\n        Some(Equal) => 1,\n        Some(Greater) => 2,\n    }\n}\n\n#[rustfmt::skip]\nconst MATRIX: [[u8; 21]; 21] = [\n    [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1],\n    [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0],\n    [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 9, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 9, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 9, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0],\n    [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1],\n];\n\n#[test]\nfn test_partial_cmp_abs() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX.iter()) {\n        let x = parse_hex_string(sx);\n        for (sy, &e) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(row.iter()) {\n            let y = parse_hex_string(sy);\n            assert_eq!(encode(x.partial_cmp_abs(&y)), e);\n            assert_eq!(\n                encode(rug::Float::exact_from(&x).cmp_abs(&rug::Float::exact_from(&y))),\n                e\n            );\n        }\n    }\n}\n\nfn partial_cmp_abs_properties_helper(x: Float, y: Float) {\n    let ord = x.partial_cmp_abs(&y);\n    assert_eq!(y.partial_cmp_abs(&x).map(Ordering::reverse), ord);\n    assert_eq!(\n        (&x).abs() == (&y).abs(),\n        x.partial_cmp_abs(&y) == Some(Equal)\n    );\n    assert_eq!((-&x).partial_cmp_abs(&y), ord);\n    assert_eq!(x.partial_cmp_abs(&-&y), ord);\n    assert_eq!((-&x).partial_cmp_abs(&-&y), ord);\n    assert_eq!(\n        rug::Float::exact_from(&x).cmp_abs(&rug::Float::exact_from(&y)),\n        ord\n    );\n    if (!x.is_zero() || !y.is_zero())\n        && let Some(ord) = ord\n        && ord != Equal\n    {\n        assert_eq!(ComparableFloat(x).cmp_abs(&ComparableFloat(y)), ord);\n    }\n}\n\n#[test]\nfn partial_cmp_abs_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_abs_properties_helper(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        partial_cmp_abs_properties_helper(x, y);\n    });\n\n    float_gen().test_properties(|x| {\n        if !x.is_nan() {\n            assert_eq!(x.partial_cmp_abs(&x), Some(Equal));\n            assert_eq!(x.partial_cmp_abs(&-&x), Some(Equal));\n            assert_eq!((-&x).partial_cmp_abs(&x), Some(Equal));\n            assert_eq!((-&x).partial_cmp_abs(&-&x), Some(Equal));\n            assert!(x.le_abs(&Float::INFINITY));\n            assert!(x.le_abs(&Float::NEGATIVE_INFINITY));\n        }\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(\n            Float::from(x).partial_cmp_abs(&Float::from(y)),\n            x.abs().partial_cmp(&y.abs())\n        );\n    });\n\n    float_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(\n            Some(Rational::exact_from(&x).cmp_abs(&Rational::exact_from(&y))),\n            x.partial_cmp_abs(&y)\n        );\n    });\n}\n\n#[rustfmt::skip]\nconst MATRIX_2: [[u8; 21]; 21] = [\n    [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1],\n    [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0],\n    [0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0],\n    [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1],\n];\n\n#[test]\nfn test_comparable_float_cmp_abs() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_2.iter()) {\n        let x = parse_hex_string(sx);\n        for (sy, &e) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(row.iter()) {\n            assert_ne!(e, 9);\n            let y = parse_hex_string(sy);\n            assert_eq!(\n                encode(Some(\n                    ComparableFloat(x.clone()).cmp_abs(&ComparableFloat(y.clone()))\n                )),\n                e\n            );\n            assert_eq!(\n                encode(Some(\n                    ComparableFloatRef(&x).cmp_abs(&ComparableFloatRef(&y))\n                )),\n                e\n            );\n        }\n    }\n}\n\nfn comparable_float_cmp_abs_properties_helper(x: Float, y: Float) {\n    let cx = ComparableFloatRef(&x);\n    let cy = ComparableFloatRef(&y);\n    let ord = cx.cmp_abs(&cy);\n    assert_eq!(cy.cmp_abs(&cx).reverse(), ord);\n    assert_eq!(\n        ComparableFloat((&x).abs()) == ComparableFloat((&y).abs()),\n        cx.cmp_abs(&cy) == Equal\n    );\n    assert_eq!(\n        ComparableFloat(x.clone()).cmp_abs(&ComparableFloat(y.clone())),\n        ord\n    );\n    assert_eq!(\n        (ComparableFloatRef(&x)).cmp_abs(&ComparableFloatRef(&-&y)),\n        ord\n    );\n    assert_eq!(\n        (ComparableFloatRef(&-&x)).cmp_abs(&ComparableFloatRef(&y)),\n        ord\n    );\n    assert_eq!((ComparableFloat(-x)).cmp_abs(&ComparableFloat(-y)), ord);\n}\n\n#[test]\nfn comparable_float_cmp_abs_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        comparable_float_cmp_abs_properties_helper(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        comparable_float_cmp_abs_properties_helper(x, y);\n    });\n\n    float_gen().test_properties(|x| {\n        let cx = ComparableFloatRef(&x);\n        assert_eq!(cx.cmp_abs(&cx), Equal);\n        assert_eq!(cx.cmp_abs(&ComparableFloatRef(&-&x)), Equal);\n        assert_eq!(ComparableFloatRef(&-&x).cmp_abs(&cx), Equal);\n        assert_eq!(\n            ComparableFloatRef(&-&x).cmp_abs(&ComparableFloatRef(&-&x)),\n            Equal\n        );\n        assert!(cx.le_abs(&ComparableFloatRef(&Float::INFINITY)));\n        assert!(cx.le_abs(&ComparableFloatRef(&Float::NEGATIVE_INFINITY)));\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        let cx = ComparableFloatRef(&x);\n        let cy = ComparableFloatRef(&y);\n        let cz = ComparableFloatRef(&z);\n        if cx.lt_abs(&cy) && cy.lt_abs(&cz) {\n            assert!(cx.lt_abs(&cz));\n        } else if cx.gt_abs(&cy) && cy.gt_abs(&cz) {\n            assert!(cx.gt_abs(&cz));\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(\n            ComparableFloat(Float::from(x)).cmp_abs(&ComparableFloat(Float::from(y))),\n            NiceFloat(x.abs()).cmp(&NiceFloat(y.abs()))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::NaN;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::test_util::common::{\n    ORDERED_FLOAT_HEX_STRINGS, ORDERED_FLOAT_STRINGS, parse_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_gen, float_pair_gen, float_pair_gen_var_1, float_pair_gen_var_10, float_triple_gen,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\n\n#[rustfmt::skip]\nconst MATRIX: [[u8; 21]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n];\n\n#[test]\nfn test_eq() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX.iter()) {\n        let x = parse_hex_string(sx);\n        for (sy, &e) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(row.iter()) {\n            let y = parse_hex_string(sy);\n            assert_eq!(u8::from(x == y), e);\n            assert_eq!(\n                u8::from(rug::Float::exact_from(&x) == rug::Float::exact_from(&y)),\n                e\n            );\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn eq_properties_helper(x: Float, y: Float) {\n    let e = x == y;\n    assert_eq!(y == x, e);\n    assert_eq!(rug::Float::exact_from(&x) == rug::Float::exact_from(&y), e);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn eq_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        eq_properties_helper(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        eq_properties_helper(x, y);\n    });\n\n    float_gen().test_properties(|x| {\n        if !x.is_nan() {\n            assert_eq!(x, x);\n        }\n        assert_ne!(x, Float::NAN);\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        if x == y && y == z {\n            assert_eq!(x, z);\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x) == Float::from(y), x == y);\n    });\n\n    float_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x) == Rational::exact_from(&y), x == y);\n    });\n}\n\nfn read_hex_strings(strings: &[&str]) -> Vec<Float> {\n    strings.iter().map(|s| parse_hex_string(s)).collect()\n}\n\n#[test]\nfn test_comparable_float_eq() {\n    let xs = read_hex_strings(&ORDERED_FLOAT_HEX_STRINGS);\n    let ys = read_hex_strings(&ORDERED_FLOAT_HEX_STRINGS);\n    let xs_2: Vec<String> = xs.iter().map(Float::to_string).collect();\n    assert_eq!(xs_2, ORDERED_FLOAT_STRINGS);\n    for (i, x) in xs.iter().enumerate() {\n        for (j, y) in ys.iter().enumerate() {\n            assert_eq!(\n                i == j,\n                ComparableFloat(x.clone()) == ComparableFloat(y.clone())\n            );\n            assert_eq!(i == j, ComparableFloatRef(x) == ComparableFloatRef(y));\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn comparable_float_eq_properties_helper(x: Float, y: Float) {\n    let rx = ComparableFloatRef(&x);\n    let ry = ComparableFloatRef(&y);\n    let e = rx == ry;\n    assert_eq!(ry == rx, e);\n\n    let x = ComparableFloat(x.clone());\n    let y = ComparableFloat(y.clone());\n    assert_eq!(x == y, e);\n    assert_eq!(y == x, e);\n\n    if e && !x.is_nan() {\n        assert_eq!(x, y);\n    }\n}\n\n#[test]\nfn comparable_float_eq_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        comparable_float_eq_properties_helper(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        comparable_float_eq_properties_helper(x, y);\n    });\n\n    float_gen().test_properties(|x| {\n        let x = ComparableFloat(x);\n        assert_eq!(x, x);\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        let x = ComparableFloat(x);\n        let y = ComparableFloat(y);\n        let z = ComparableFloat(z);\n        if x == y && y == z {\n            assert_eq!(x, z);\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(\n            ComparableFloat(Float::from(x)) == ComparableFloat(Float::from(y)),\n            NiceFloat(x) == NiceFloat(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::NaN;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::primitive_float_pair_gen;\nuse malachite_float::test_util::common::{ORDERED_FLOAT_HEX_STRINGS, parse_hex_string};\nuse malachite_float::test_util::generators::{\n    float_gen, float_pair_gen, float_pair_gen_var_1, float_pair_gen_var_10, float_triple_gen,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\n\n#[rustfmt::skip]\nconst MATRIX: [[u8; 21]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n];\n\n#[test]\nfn test_eq_abs() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX.iter()) {\n        let x = parse_hex_string(sx);\n        for (sy, &e) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(row.iter()) {\n            let y = parse_hex_string(sy);\n            assert_eq!(u8::from(x.eq_abs(&y)), e);\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn eq_abs_properties_helper(x: Float, y: Float) {\n    let e = x.eq_abs(&y);\n    assert_eq!((&x).abs() == (&y).abs(), e);\n    assert_eq!(x.ne_abs(&y), !e);\n    assert_eq!(y.eq_abs(&x), e);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn eq_abs_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        eq_abs_properties_helper(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        eq_abs_properties_helper(x, y);\n    });\n\n    float_gen().test_properties(|x| {\n        if !x.is_nan() {\n            assert!(x.eq_abs(&x));\n        }\n        assert!(x.ne_abs(&Float::NAN));\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x).eq_abs(&Float::from(y)), x.eq_abs(&y));\n    });\n\n    float_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::exact_from(&x).eq_abs(&Rational::exact_from(&y)),\n            x.eq_abs(&y)\n        );\n    });\n}\n\n#[rustfmt::skip]\nconst ORDERED_FLOAT_MATRIX: [[u8; 21]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n];\n\n#[test]\nfn test_comparable_float_eq_abs() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS\n        .iter()\n        .zip(ORDERED_FLOAT_MATRIX.iter())\n    {\n        let x = parse_hex_string(sx);\n        for (sy, &e) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(row.iter()) {\n            let y = parse_hex_string(sy);\n            assert_eq!(\n                u8::from(ComparableFloat(x.clone()).eq_abs(&ComparableFloat(y.clone()))),\n                e\n            );\n            assert_eq!(\n                u8::from(ComparableFloatRef(&x).eq_abs(&ComparableFloatRef(&y))),\n                e\n            );\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn comparable_float_eq_abs_properties_helper(x: Float, y: Float) {\n    let rx = ComparableFloatRef(&x);\n    let ry = ComparableFloatRef(&y);\n    let e = rx.eq_abs(&ry);\n    assert_eq!(\n        ComparableFloatRef(&(&x).abs()) == ComparableFloatRef(&(&y).abs()),\n        e\n    );\n    assert_eq!(rx.ne_abs(&ry), !e);\n    assert_eq!(ry.eq_abs(&rx), e);\n\n    let x = ComparableFloat(x.clone());\n    let y = ComparableFloat(y.clone());\n    assert_eq!(\n        ComparableFloat((&x.0).abs()) == ComparableFloat((&y.0).abs()),\n        e\n    );\n    assert_eq!(x.eq_abs(&y), e);\n    assert_eq!(x.ne_abs(&y), !e);\n    assert_eq!(y.eq_abs(&x), e);\n\n    if e && !x.is_nan() {\n        assert!(x.eq_abs(&y));\n    }\n}\n\n#[test]\nfn comparable_float_eq_abs_properties() {\n    float_pair_gen().test_properties(|(x, y)| {\n        comparable_float_eq_abs_properties_helper(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        comparable_float_eq_abs_properties_helper(x, y);\n    });\n\n    float_gen().test_properties(|x| {\n        let x = ComparableFloat(x);\n        assert!(x.eq_abs(&x));\n    });\n\n    float_triple_gen().test_properties(|(x, y, z)| {\n        let x = ComparableFloat(x);\n        let y = ComparableFloat(y);\n        let z = ComparableFloat(z);\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    primitive_float_pair_gen::<f64>().test_properties(|(x, y)| {\n        assert_eq!(\n            ComparableFloat(Float::from(x)).eq_abs(&ComparableFloat(Float::from(y))),\n            NiceFloat(x).eq_abs(&NiceFloat(y))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/eq_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_integer_pair_gen, float_integer_pair_gen_var_1, float_integer_pair_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen};\nuse malachite_q::Rational;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_integer() {\n    let test = |s, s_hex, t, eq: bool| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!((&u).abs() == (&v).abs(), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"NaN\", \"NaN\", \"0\", false);\n    test(\"Infinity\", \"Infinity\", \"0\", false);\n    test(\"-Infinity\", \"-Infinity\", \"0\", false);\n    test(\"0.0\", \"0x0.0\", \"0\", true);\n    test(\"-0.0\", \"-0x0.0\", \"0\", true);\n    test(\"1.0\", \"0x1.0#1\", \"0\", false);\n    test(\"2.0\", \"0x2.0#1\", \"0\", false);\n    test(\"0.5\", \"0x0.8#1\", \"0\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"0\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"0\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", false);\n\n    test(\"NaN\", \"NaN\", \"1\", false);\n    test(\"Infinity\", \"Infinity\", \"1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1\", false);\n    test(\"0.0\", \"0x0.0\", \"1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"1\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", false);\n\n    test(\"NaN\", \"NaN\", \"100\", false);\n    test(\"Infinity\", \"Infinity\", \"100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"100\", false);\n    test(\"0.0\", \"0x0.0\", \"100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"100\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"100\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", false);\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, true);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    test(\"NaN\", \"NaN\", \"-1\", false);\n    test(\"Infinity\", \"Infinity\", \"-1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1\", false);\n    test(\"0.0\", \"0x0.0\", \"-1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"-1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"-1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", false);\n\n    test(\"NaN\", \"NaN\", \"-100\", false);\n    test(\"Infinity\", \"Infinity\", \"-100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-100\", false);\n    test(\"0.0\", \"0x0.0\", \"-100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-100\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", false);\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, true);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::cmp_owned)]\nfn eq_abs_integer_properties_helper(x: Float, y: Integer) {\n    let eq_abs = x.eq_abs(&y);\n    assert_eq!((&x).abs() == (&y).abs(), eq_abs);\n    assert_eq!(x.ne_abs(&y), !eq_abs);\n    assert_eq!(y.eq_abs(&x), eq_abs);\n    assert_eq!(x.eq_abs(&Float::exact_from(&y)), eq_abs);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn eq_abs_integer_properties() {\n    float_integer_pair_gen().test_properties(|(x, y)| {\n        eq_abs_integer_properties_helper(x, y);\n    });\n\n    float_integer_pair_gen_var_2().test_properties(|(x, y)| {\n        eq_abs_integer_properties_helper(x, y);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.ne_abs(&Float::NAN));\n        assert!(x.ne_abs(&Float::INFINITY));\n        assert!(x.ne_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Float::exact_from(&x).eq_abs(&y), x.eq_abs(&y));\n        assert_eq!(x.eq_abs(&Float::exact_from(&y)), x.eq_abs(&y));\n    });\n\n    float_integer_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x).eq_abs(&y), x.eq_abs(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_natural_pair_gen, float_natural_pair_gen_var_1, float_natural_pair_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen};\nuse malachite_q::Rational;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_natural() {\n    let test = |s, s_hex, t, eq: bool| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"NaN\", \"NaN\", \"0\", false);\n    test(\"Infinity\", \"Infinity\", \"0\", false);\n    test(\"-Infinity\", \"-Infinity\", \"0\", false);\n    test(\"0.0\", \"0x0.0\", \"0\", true);\n    test(\"-0.0\", \"-0x0.0\", \"0\", true);\n    test(\"1.0\", \"0x1.0#1\", \"0\", false);\n    test(\"2.0\", \"0x2.0#1\", \"0\", false);\n    test(\"0.5\", \"0x0.8#1\", \"0\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"0\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"0\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", false);\n\n    test(\"NaN\", \"NaN\", \"1\", false);\n    test(\"Infinity\", \"Infinity\", \"1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1\", false);\n    test(\"0.0\", \"0x0.0\", \"1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"1\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", false);\n\n    test(\"NaN\", \"NaN\", \"100\", false);\n    test(\"Infinity\", \"Infinity\", \"100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"100\", false);\n    test(\"0.0\", \"0x0.0\", \"100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"100\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"100\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", false);\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, true);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::cmp_owned)]\nfn eq_abs_natural_properties_helper(x: Float, y: Natural) {\n    let eq = x.eq_abs(&y);\n    assert_eq!((&x).abs() == y, eq);\n    assert_eq!(x.ne_abs(&y), !eq);\n    assert_eq!(y.eq_abs(&x), eq);\n    assert_eq!(x.eq_abs(&Float::exact_from(&y)), eq);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn eq_abs_natural_properties() {\n    float_natural_pair_gen().test_properties(|(x, y)| {\n        eq_abs_natural_properties_helper(x, y);\n    });\n\n    float_natural_pair_gen_var_2().test_properties(|(x, y)| {\n        eq_abs_natural_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert!(x.ne_abs(&Float::NAN));\n        assert!(x.ne_abs(&Float::INFINITY));\n        assert!(x.ne_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Float::exact_from(&x).eq_abs(&y), x == y);\n        assert_eq!(x.eq_abs(&Float::exact_from(&y)), x == y);\n    });\n\n    float_natural_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x).eq_abs(&y), x.eq_abs(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::{\n    ORDERED_F32S, ORDERED_F64S, ORDERED_FLOAT_HEX_STRINGS, parse_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_var_1,\n};\nuse std::cmp::Ordering::*;\n\n#[rustfmt::skip]\nconst MATRIX_F32: [[u8; 17]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n];\n\n#[rustfmt::skip]\nconst MATRIX_F64: [[u8; 17]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n];\n\n#[test]\nfn test_eq_abs_primitive_float() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F64.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F64S.iter().zip(row.iter()) {\n            assert_eq!(u8::from(x.eq_abs(&y)), e);\n            assert_eq!(u8::from(y.eq_abs(&x)), e);\n        }\n    }\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F32.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F32S.iter().zip(row.iter()) {\n            assert_eq!(u8::from(x.eq_abs(&y)), e);\n            assert_eq!(u8::from(y.eq_abs(&x)), e);\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn eq_abs_primitive_float_properties_helper_helper<T: EqAbs<Float> + PrimitiveFloat>(n: Float, f: T)\nwhere\n    Float: TryFrom<T> + EqAbs<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    let eq = n.eq_abs(&f);\n    assert_eq!((&n).abs() == f.abs(), eq);\n    assert_eq!(n.ne_abs(&f), !eq);\n    assert_eq!(f.eq_abs(&n), eq);\n    assert_eq!(n.partial_cmp_abs(&f) == Some(Equal), eq);\n    if f.is_finite() {\n        assert_eq!(EqAbs::<Float>::eq_abs(&n, &Float::exact_from(f)), eq);\n    }\n}\n\nfn eq_abs_primitive_float_properties_helper<T: EqAbs<Float> + PrimitiveFloat>()\nwhere\n    Float: TryFrom<T> + EqAbs<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    float_primitive_float_pair_gen::<T>().test_properties(|(n, f)| {\n        eq_abs_primitive_float_properties_helper_helper(n, f);\n    });\n\n    float_primitive_float_pair_gen_var_1::<T>().test_properties(|(n, f)| {\n        eq_abs_primitive_float_properties_helper_helper(n, f);\n    });\n}\n\n#[test]\nfn eq_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(eq_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen, unsigned_gen, unsigned_pair_gen_var_27,\n};\nuse malachite_base::{apply_fn_to_signeds, apply_fn_to_unsigneds};\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen, float_signed_pair_gen_var_4, float_unsigned_pair_gen,\n    float_unsigned_pair_gen_var_5,\n};\n\n#[test]\nfn test_eq_abs_u32() {\n    let test = |s, s_hex, v: u32, eq: bool| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, true);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n}\n\n#[test]\nfn test_eq_abs_u64() {\n    let test = |s, s_hex, v: u64, eq: bool| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, true);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n}\n\n#[test]\nfn test_eq_abs_i32() {\n    let test = |s, s_hex, v: i32, eq: bool| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!((&u).abs() == v.unsigned_abs(), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, true);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n\n    test(\"NaN\", \"NaN\", -1, false);\n    test(\"Infinity\", \"Infinity\", -1, false);\n    test(\"-Infinity\", \"-Infinity\", -1, false);\n    test(\"0.0\", \"0x0.0\", -1, false);\n    test(\"-0.0\", \"-0x0.0\", -1, false);\n    test(\"1.0\", \"0x1.0#1\", -1, true);\n    test(\"2.0\", \"0x2.0#1\", -1, false);\n    test(\"0.5\", \"0x0.8#1\", -1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, false);\n    test(\"-1.0\", \"-0x1.0#1\", -1, true);\n    test(\"-2.0\", \"-0x2.0#1\", -1, false);\n    test(\"-0.5\", \"-0x0.8#1\", -1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", -1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, false);\n\n    test(\"NaN\", \"NaN\", -100, false);\n    test(\"Infinity\", \"Infinity\", -100, false);\n    test(\"-Infinity\", \"-Infinity\", -100, false);\n    test(\"0.0\", \"0x0.0\", -100, false);\n    test(\"-0.0\", \"-0x0.0\", -100, false);\n    test(\"1.0\", \"0x1.0#1\", -100, false);\n    test(\"2.0\", \"0x2.0#1\", -100, false);\n    test(\"0.5\", \"0x0.8#1\", -100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, false);\n    test(\"-1.0\", \"-0x1.0#1\", -100, false);\n    test(\"-2.0\", \"-0x2.0#1\", -100, false);\n    test(\"-0.5\", \"-0x0.8#1\", -100, false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, false);\n}\n\n#[test]\nfn test_eq_abs_i64() {\n    let test = |s, s_hex, v: i64, eq: bool| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!((&u).abs() == v.unsigned_abs(), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, true);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n\n    test(\"NaN\", \"NaN\", -1, false);\n    test(\"Infinity\", \"Infinity\", -1, false);\n    test(\"-Infinity\", \"-Infinity\", -1, false);\n    test(\"0.0\", \"0x0.0\", -1, false);\n    test(\"-0.0\", \"-0x0.0\", -1, false);\n    test(\"1.0\", \"0x1.0#1\", -1, true);\n    test(\"2.0\", \"0x2.0#1\", -1, false);\n    test(\"0.5\", \"0x0.8#1\", -1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, false);\n    test(\"-1.0\", \"-0x1.0#1\", -1, true);\n    test(\"-2.0\", \"-0x2.0#1\", -1, false);\n    test(\"-0.5\", \"-0x0.8#1\", -1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", -1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, false);\n\n    test(\"NaN\", \"NaN\", -100, false);\n    test(\"Infinity\", \"Infinity\", -100, false);\n    test(\"-Infinity\", \"-Infinity\", -100, false);\n    test(\"0.0\", \"0x0.0\", -100, false);\n    test(\"-0.0\", \"-0x0.0\", -100, false);\n    test(\"1.0\", \"0x1.0#1\", -100, false);\n    test(\"2.0\", \"0x2.0#1\", -100, false);\n    test(\"0.5\", \"0x0.8#1\", -100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, false);\n    test(\"-1.0\", \"-0x1.0#1\", -100, false);\n    test(\"-2.0\", \"-0x2.0#1\", -100, false);\n    test(\"-0.5\", \"-0x0.8#1\", -100, false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, false);\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::cmp_owned, clippy::op_ref)]\nfn eq_abs_primitive_int_properties_helper_unsigned_helper<T: EqAbs<Float> + PrimitiveUnsigned>(\n    n: Float,\n    u: T,\n) where\n    Float: From<T> + PartialEq<T> + EqAbs<T>,\n{\n    let eq = n.eq_abs(&u);\n    assert_eq!(EqAbs::<Float>::eq_abs(&n, &Float::from(u)), eq);\n    assert_eq!((&n).abs() == u, eq);\n    assert_eq!(n.ne_abs(&u), !eq);\n\n    assert_eq!(u.eq_abs(&n), eq);\n    assert_eq!(EqAbs::<Float>::eq_abs(&Float::from(u), &n), eq);\n}\n\n#[allow(clippy::cmp_owned, clippy::op_ref)]\nfn eq_abs_primitive_int_properties_helper_unsigned<T: EqAbs<Float> + PrimitiveUnsigned>()\nwhere\n    Float: From<T> + PartialEq<T> + EqAbs<T>,\n{\n    float_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        eq_abs_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_unsigned_pair_gen_var_5::<T>().test_properties(|(n, u)| {\n        eq_abs_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert!(x.ne_abs(&Float::NAN));\n        assert!(x.ne_abs(&Float::INFINITY));\n        assert!(x.ne_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x).eq_abs(&y), x == y);\n        assert_eq!(x.eq_abs(&Float::from(y)), x == y);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn eq_abs_primitive_int_properties_helper_signed_helper<T: EqAbs<Float> + PrimitiveSigned>(\n    n: Float,\n    i: T,\n) where\n    Float: From<T> + PartialEq<<T as UnsignedAbs>::Output> + EqAbs<T>,\n{\n    let eq = n.eq_abs(&i);\n    assert_eq!(EqAbs::<Float>::eq_abs(&n, &Float::from(i)), eq);\n    assert_eq!((&n).abs() == i.unsigned_abs(), eq);\n    assert_eq!(n.ne_abs(&i), !eq);\n\n    assert_eq!(i.eq_abs(&n), eq);\n    assert_eq!(EqAbs::<Float>::eq_abs(&Float::from(i), &n), eq);\n}\n\nfn eq_abs_primitive_int_properties_helper_signed<T: EqAbs<Float> + PrimitiveSigned>()\nwhere\n    Float: From<T> + PartialEq<<T as UnsignedAbs>::Output> + EqAbs<T>,\n{\n    float_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        eq_abs_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    float_signed_pair_gen_var_4::<T>().test_properties(|(n, i)| {\n        eq_abs_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert!(x.ne_abs(&Float::NAN));\n        assert!(x.ne_abs(&Float::INFINITY));\n        assert!(x.ne_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x).eq_abs(&y), x.eq_abs(&y));\n        assert_eq!(x.eq_abs(&Float::from(y)), x.eq_abs(&y));\n    });\n}\n\n#[test]\nfn eq_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(eq_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(eq_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/eq_abs_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_rational_pair_gen, float_rational_pair_gen_var_1, float_rational_pair_gen_var_2,\n};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_rational() {\n    let test = |s, s_hex, t, eq: bool| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Rational::from_str(t).unwrap();\n\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!((&u).abs() == (&v).abs(), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"NaN\", \"NaN\", \"0\", false);\n    test(\"Infinity\", \"Infinity\", \"0\", false);\n    test(\"-Infinity\", \"-Infinity\", \"0\", false);\n    test(\"0.0\", \"0x0.0\", \"0\", true);\n    test(\"-0.0\", \"-0x0.0\", \"0\", true);\n    test(\"1.0\", \"0x1.0#1\", \"0\", false);\n    test(\"2.0\", \"0x2.0#1\", \"0\", false);\n    test(\"0.5\", \"0x0.8#1\", \"0\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"0\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"0\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", false);\n\n    test(\"NaN\", \"NaN\", \"1\", false);\n    test(\"Infinity\", \"Infinity\", \"1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1\", false);\n    test(\"0.0\", \"0x0.0\", \"1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"1\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", false);\n\n    test(\"NaN\", \"NaN\", \"100\", false);\n    test(\"Infinity\", \"Infinity\", \"100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"100\", false);\n    test(\"0.0\", \"0x0.0\", \"100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"100\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"100\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", false);\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, true);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    test(\"NaN\", \"NaN\", \"1/2\", false);\n    test(\"Infinity\", \"Infinity\", \"1/2\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1/2\", false);\n    test(\"0.0\", \"0x0.0\", \"1/2\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1/2\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1/2\", false);\n    test(\"2.0\", \"0x2.0#1\", \"1/2\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1/2\", true);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1/2\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1/2\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1/2\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/2\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/2\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1/2\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"1/2\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1/2\", true);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/2\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1/2\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1/2\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/2\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/2\", false);\n\n    test(\"NaN\", \"NaN\", \"1/3\", false);\n    test(\"Infinity\", \"Infinity\", \"1/3\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1/3\", false);\n    test(\"0.0\", \"0x0.0\", \"1/3\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1/3\", false);\n    test(\"2.0\", \"0x2.0#1\", \"1/3\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1/3\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1/3\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1/3\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1/3\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/3\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/3\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1/3\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"1/3\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1/3\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/3\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1/3\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1/3\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/3\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/3\", false);\n\n    test(\"NaN\", \"NaN\", \"22/7\", false);\n    test(\"Infinity\", \"Infinity\", \"22/7\", false);\n    test(\"-Infinity\", \"-Infinity\", \"22/7\", false);\n    test(\"0.0\", \"0x0.0\", \"22/7\", false);\n    test(\"-0.0\", \"-0x0.0\", \"22/7\", false);\n    test(\"1.0\", \"0x1.0#1\", \"22/7\", false);\n    test(\"2.0\", \"0x2.0#1\", \"22/7\", false);\n    test(\"0.5\", \"0x0.8#1\", \"22/7\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"22/7\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"22/7\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"22/7\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"22/7\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"22/7\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"22/7\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"22/7\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"22/7\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"22/7\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"22/7\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"22/7\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"22/7\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"22/7\", false);\n\n    test(\"NaN\", \"NaN\", \"-1\", false);\n    test(\"Infinity\", \"Infinity\", \"-1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1\", false);\n    test(\"0.0\", \"0x0.0\", \"-1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"-1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"-1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", false);\n\n    test(\"NaN\", \"NaN\", \"-100\", false);\n    test(\"Infinity\", \"Infinity\", \"-100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-100\", false);\n    test(\"0.0\", \"0x0.0\", \"-100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-100\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", false);\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, true);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    test(\"NaN\", \"NaN\", \"-1/2\", false);\n    test(\"Infinity\", \"Infinity\", \"-1/2\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1/2\", false);\n    test(\"0.0\", \"0x0.0\", \"-1/2\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1/2\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1/2\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-1/2\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1/2\", true);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1/2\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1/2\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/2\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/2\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/2\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/2\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/2\", true);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/2\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/2\", false);\n\n    test(\"NaN\", \"NaN\", \"-1/3\", false);\n    test(\"Infinity\", \"Infinity\", \"-1/3\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1/3\", false);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1/3\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-1/3\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1/3\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1/3\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1/3\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/3\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/3\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/3\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/3\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/3\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/3\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/3\", false);\n\n    test(\"NaN\", \"NaN\", \"-22/7\", false);\n    test(\"Infinity\", \"Infinity\", \"-22/7\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-22/7\", false);\n    test(\"0.0\", \"0x0.0\", \"-22/7\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-22/7\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-22/7\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-22/7\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-22/7\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-22/7\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-22/7\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-22/7\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-22/7\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-22/7\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-22/7\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-22/7\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-22/7\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-22/7\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn eq_abs_rational_properties_helper(x: Float, y: Rational) {\n    let eq_abs = x.eq_abs(&y);\n    assert_eq!((&x).abs() == (&y).abs(), eq_abs);\n    assert_eq!(x.ne_abs(&y), !eq_abs);\n    assert_eq!(y.eq_abs(&x), eq_abs);\n}\n\n#[test]\nfn eq_abs_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        eq_abs_rational_properties_helper(x, y);\n    });\n\n    float_rational_pair_gen_var_2().test_properties(|(x, y)| {\n        eq_abs_rational_properties_helper(x, y);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!(x.ne_abs(&Float::NAN));\n        assert!(x.ne_abs(&Float::INFINITY));\n        assert!(x.ne_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    float_rational_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x).eq_abs(&y), x.eq_abs(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::hash::hash;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\nuse malachite_float::{ComparableFloatRef, Float};\n\n#[allow(clippy::needless_pass_by_value)]\nfn hash_properties_helper(x: Float) {\n    assert_eq!(\n        hash(&ComparableFloatRef(&x)),\n        hash(&ComparableFloatRef(&x.clone()))\n    );\n}\n\n#[test]\nfn hash_properties() {\n    float_gen().test_properties(|x| {\n        hash_properties_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        hash_properties_helper(x);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_float_integer_triple_gen, float_integer_integer_triple_gen, float_integer_pair_gen,\n    float_integer_pair_gen_var_1, float_integer_pair_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen};\nuse malachite_q::Rational;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_integer() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp(&(&v).abs()), out);\n        assert_eq!(v.partial_cmp_abs(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u)\n                .abs()\n                .partial_cmp(&rug::Integer::from(&v).abs()),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", \"0\", None);\n    test(\"Infinity\", \"Infinity\", \"0\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"0\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"0\", Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", \"0\", Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", \"0\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"0\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"1\", None);\n    test(\"Infinity\", \"Infinity\", \"1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"100\", None);\n    test(\"Infinity\", \"Infinity\", \"100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"100\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", Some(Less));\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Equal));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-1\", None);\n    test(\"Infinity\", \"Infinity\", \"-1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"-1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"-1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"-1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-100\", None);\n    test(\"Infinity\", \"Infinity\", \"-100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-100\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"-100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"-100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"-100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"-100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"-100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", Some(Less));\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Equal));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_abs_integer_properties_helper(x: Float, y: Integer) {\n    let cmp = x.partial_cmp_abs(&y);\n    assert_eq!(x.partial_cmp_abs(&Float::exact_from(&y)), cmp);\n    assert_eq!((&x).abs().partial_cmp(&(&y).abs()), cmp);\n    assert_eq!(\n        rug::Float::exact_from(&x)\n            .abs()\n            .partial_cmp(&rug::Integer::from(&y).abs()),\n        cmp\n    );\n    assert_eq!(y.partial_cmp_abs(&x), cmp.map(Ordering::reverse));\n}\n\n#[test]\nfn partial_cmp_abs_integer_properties() {\n    float_integer_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_abs_integer_properties_helper(x, y);\n    });\n\n    float_integer_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_cmp_abs_integer_properties_helper(x, y);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.partial_cmp_abs(&Float::NAN).is_none());\n        assert!(x.ge_abs(&Float::ZERO));\n        assert!(x.ge_abs(&Float::NEGATIVE_ZERO));\n        assert!(x.lt_abs(&Float::INFINITY));\n        assert!(x.lt_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    float_float_integer_triple_gen().test_properties(|(x, z, y)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    float_integer_integer_triple_gen().test_properties(|(y, x, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(\n            Float::exact_from(&x).partial_cmp_abs(&y),\n            x.partial_cmp_abs(&y)\n        );\n        assert_eq!(\n            x.partial_cmp_abs(&Float::exact_from(&y)),\n            x.partial_cmp_abs(&y)\n        );\n    });\n\n    float_integer_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::exact_from(&x).partial_cmp_abs(&y),\n            x.partial_cmp_abs(&y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_float_natural_triple_gen, float_natural_natural_triple_gen, float_natural_pair_gen,\n    float_natural_pair_gen_var_1, float_natural_pair_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen};\nuse malachite_q::Rational;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_natural() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp_abs(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u)\n                .abs()\n                .partial_cmp(&rug::Integer::from(&v)),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", \"0\", None);\n    test(\"Infinity\", \"Infinity\", \"0\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"0\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"0\", Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", \"0\", Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", \"0\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"0\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"1\", None);\n    test(\"Infinity\", \"Infinity\", \"1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"100\", None);\n    test(\"Infinity\", \"Infinity\", \"100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"100\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", Some(Less));\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Equal));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_abs_natural_properties_helper(x: Float, y: Natural) {\n    let cmp = x.partial_cmp_abs(&y);\n    assert_eq!(x.partial_cmp_abs(&Float::exact_from(&y)), cmp);\n    assert_eq!((&x).abs().partial_cmp(&y), cmp);\n    assert_eq!(\n        rug::Float::exact_from(&x)\n            .abs()\n            .partial_cmp(&rug::Integer::from(&y)),\n        cmp\n    );\n    assert_eq!(y.partial_cmp_abs(&x), cmp.map(Ordering::reverse));\n}\n\n#[test]\nfn partial_cmp_abs_natural_properties() {\n    float_natural_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_abs_natural_properties_helper(x, y);\n    });\n\n    float_natural_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_cmp_abs_natural_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert!(x.partial_cmp_abs(&Float::NAN).is_none());\n        assert!(x.ge_abs(&Float::ZERO));\n        assert!(x.ge_abs(&Float::NEGATIVE_ZERO));\n        assert!(x.lt_abs(&Float::INFINITY));\n        assert!(x.lt_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    float_float_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    float_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x < z);\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x > z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Float::exact_from(&x).partial_cmp_abs(&y), x.partial_cmp(&y));\n        assert_eq!(x.partial_cmp_abs(&Float::exact_from(&y)), x.partial_cmp(&y));\n    });\n\n    float_natural_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::exact_from(&x).partial_cmp_abs(&y),\n            x.partial_cmp_abs(&y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{primitive_float_gen, primitive_float_gen_var_11};\nuse malachite_float::Float;\nuse malachite_float::test_util::common::{\n    ORDERED_F32S, ORDERED_F64S, ORDERED_FLOAT_HEX_STRINGS, parse_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_float_primitive_float_triple_gen, float_gen, float_gen_var_2,\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_var_1,\n    float_primitive_float_primitive_float_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\n\nconst fn encode(oo: Option<Ordering>) -> u8 {\n    match oo {\n        None => 9,\n        Some(Less) => 0,\n        Some(Equal) => 1,\n        Some(Greater) => 2,\n    }\n}\n\n#[rustfmt::skip]\nconst MATRIX_F32: [[u8; 17]; 21] = [\n    [1, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1],\n    [0, 0, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 0, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 0, 0, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 0, 0, 0],\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 1, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 2, 9, 2, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 2, 9, 2, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 1, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 0, 0, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 0, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 0, 0],\n    [1, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1],\n];\n\n#[rustfmt::skip]\nconst MATRIX_F64: [[u8; 17]; 21] = [\n    [1, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1],\n    [0, 1, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 1, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 0, 0, 1, 2, 2, 2, 2, 9, 2, 2, 2, 2, 1, 0, 0, 0],\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 1, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 1, 2, 9, 2, 1, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 1, 2, 9, 2, 1, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 1, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 1, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 1, 2, 2, 2, 2, 9, 2, 2, 2, 2, 1, 0, 0, 0],\n    [0, 0, 1, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 1, 0, 0],\n    [0, 1, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 1, 0],\n    [1, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1],\n];\n\n#[test]\nfn test_partial_cmp_abs_primitive_float() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F64.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F64S.iter().zip(row.iter()) {\n            assert_eq!(encode(x.partial_cmp_abs(&y)), e);\n            assert_eq!(encode(y.partial_cmp_abs(&x).map(Ordering::reverse)), e);\n        }\n    }\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F32.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F32S.iter().zip(row.iter()) {\n            assert_eq!(encode(x.partial_cmp_abs(&y)), e);\n            assert_eq!(encode(y.partial_cmp_abs(&x).map(Ordering::reverse)), e);\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_abs_primitive_float_properties_helper_helper<\n    T: PartialOrd<T> + PartialOrdAbs<Float> + PrimitiveFloat,\n>(\n    n: Float,\n    u: T,\n) where\n    Float: TryFrom<T> + PartialOrd<T> + PartialOrdAbs<T>,\n{\n    let cmp = n.partial_cmp_abs(&u);\n    assert_eq!((&n).abs().partial_cmp(&u.abs()), cmp);\n\n    let cmp_rev = cmp.map(Ordering::reverse);\n    assert_eq!(u.partial_cmp_abs(&n), cmp_rev);\n\n    assert_eq!(\n        PartialOrdAbs::<Float>::partial_cmp_abs(&n, &Float::exact_from(u)),\n        cmp\n    );\n}\n\nfn partial_cmp_abs_primitive_float_properties_helper<\n    T: PartialOrd<T> + PartialOrdAbs<Float> + PrimitiveFloat,\n>()\nwhere\n    Float: TryFrom<T> + PartialOrd<T> + PartialOrdAbs<T>,\n{\n    float_primitive_float_pair_gen::<T>().test_properties(|(n, u)| {\n        partial_cmp_abs_primitive_float_properties_helper_helper(n, u);\n    });\n\n    float_primitive_float_pair_gen_var_1::<T>().test_properties(|(n, u)| {\n        partial_cmp_abs_primitive_float_properties_helper_helper(n, u);\n    });\n\n    float_float_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(PartialOrdAbs::<Float>::partial_cmp_abs(&n, &m), Some(Less));\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(\n                PartialOrdAbs::<Float>::partial_cmp_abs(&n, &m),\n                Some(Greater)\n            );\n        }\n    });\n\n    float_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(PartialOrdAbs::<T>::lt_abs(&u, &v));\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(PartialOrdAbs::<T>::gt_abs(&u, &v));\n        }\n    });\n\n    float_gen().test_properties(|x| {\n        assert!(!(x.lt_abs(&T::NAN)));\n        assert!(!(x.gt_abs(&T::NAN)));\n    });\n\n    float_gen_var_2().test_properties(|x| {\n        assert!(x.le_abs(&T::NEGATIVE_INFINITY));\n        assert!(x.le_abs(&T::INFINITY));\n    });\n\n    primitive_float_gen::<T>().test_properties(|x| {\n        assert!(!(x.lt_abs(&Float::NAN)));\n        assert!(!(x.gt_abs(&Float::NAN)));\n    });\n\n    primitive_float_gen_var_11::<T>().test_properties(|x| {\n        assert!(x.le_abs(&Float::NEGATIVE_INFINITY));\n        assert!(x.le_abs(&Float::INFINITY));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen, unsigned_gen, unsigned_pair_gen_var_27,\n};\nuse malachite_base::{apply_fn_to_signeds, apply_fn_to_unsigneds};\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_float_signed_triple_gen, float_float_unsigned_triple_gen, float_signed_pair_gen,\n    float_signed_pair_gen_var_4, float_signed_signed_triple_gen, float_unsigned_pair_gen,\n    float_unsigned_pair_gen_var_5, float_unsigned_unsigned_triple_gen,\n};\nuse rug;\nuse std::cmp::Ordering::{self, *};\n\n#[test]\nfn test_partial_cmp_abs_u32() {\n    let test = |s, s_hex, v: u32, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp_abs(&u), out.map(Ordering::reverse));\n        assert_eq!(rug::Float::exact_from(&u).abs().partial_cmp(&v), out);\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Greater));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_abs_u64() {\n    let test = |s, s_hex, v: u64, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp_abs(&u), out.map(Ordering::reverse));\n        assert_eq!(rug::Float::exact_from(&u).abs().partial_cmp(&v), out);\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Greater));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_abs_i32() {\n    let test = |s, s_hex, v: i32, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp(&v.unsigned_abs()), out);\n        assert_eq!(v.partial_cmp_abs(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u)\n                .abs()\n                .partial_cmp(&v.unsigned_abs()),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Greater));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n\n    test(\"NaN\", \"NaN\", -1, None);\n    test(\"Infinity\", \"Infinity\", -1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -1, Some(Greater));\n    test(\"0.0\", \"0x0.0\", -1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", -1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", -1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", -1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", -1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", -1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", -1, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", -1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, Some(Less));\n\n    test(\"NaN\", \"NaN\", -100, None);\n    test(\"Infinity\", \"Infinity\", -100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -100, Some(Greater));\n    test(\"0.0\", \"0x0.0\", -100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", -100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", -100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", -100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", -100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", -100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", -100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", -100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_abs_i64() {\n    let test = |s, s_hex, v: i64, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp(&v.unsigned_abs()), out);\n        assert_eq!(v.partial_cmp_abs(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u)\n                .abs()\n                .partial_cmp(&v.unsigned_abs()),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Greater));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Greater));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n\n    test(\"NaN\", \"NaN\", -1, None);\n    test(\"Infinity\", \"Infinity\", -1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -1, Some(Greater));\n    test(\"0.0\", \"0x0.0\", -1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", -1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", -1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", -1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", -1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", -1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", -1, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", -1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, Some(Less));\n\n    test(\"NaN\", \"NaN\", -100, None);\n    test(\"Infinity\", \"Infinity\", -100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -100, Some(Greater));\n    test(\"0.0\", \"0x0.0\", -100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", -100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", -100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", -100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", -100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", -100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", -100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", -100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, Some(Less));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_abs_primitive_int_properties_helper_unsigned_helper<\n    T: PartialOrdAbs<Float> + PrimitiveUnsigned,\n>(\n    n: Float,\n    u: T,\n) where\n    Float: From<T> + PartialOrdAbs<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    let cmp = n.partial_cmp_abs(&u);\n    assert_eq!(\n        PartialOrdAbs::<Float>::partial_cmp_abs(&n, &Float::from(u)),\n        cmp\n    );\n    assert_eq!((&n).abs().partial_cmp(&u), cmp);\n    assert_eq!(rug::Float::exact_from(&n).abs().partial_cmp(&u), cmp);\n\n    let cmp_rev = cmp.map(Ordering::reverse);\n    assert_eq!(u.partial_cmp_abs(&n), cmp_rev);\n    assert_eq!(\n        PartialOrdAbs::<Float>::partial_cmp_abs(&Float::from(u), &n),\n        cmp_rev\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_abs_primitive_int_properties_helper_unsigned<\n    T: PartialOrdAbs<Float> + PrimitiveUnsigned,\n>()\nwhere\n    Float: From<T> + PartialOrdAbs<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    float_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        partial_cmp_abs_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_unsigned_pair_gen_var_5::<T>().test_properties(|(n, u)| {\n        partial_cmp_abs_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert!(x.partial_cmp_abs(&Float::NAN).is_none());\n        assert!(x.ge_abs(&Float::ZERO));\n        assert!(x.ge_abs(&Float::NEGATIVE_ZERO));\n        assert!(x.lt_abs(&Float::INFINITY));\n        assert!(x.lt_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    float_float_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(PartialOrdAbs::<Float>::partial_cmp_abs(&n, &m), Some(Less));\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(\n                PartialOrdAbs::<Float>::partial_cmp_abs(&n, &m),\n                Some(Greater)\n            );\n        }\n    });\n\n    float_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(u < v);\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(u > v);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x).partial_cmp_abs(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp_abs(&Float::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_abs_primitive_int_properties_helper_signed_helper<\n    T: PartialOrdAbs<Float> + PrimitiveSigned,\n>(\n    n: Float,\n    i: T,\n) where\n    Float: From<T> + PartialOrdAbs<T> + PartialOrd<<T as UnsignedAbs>::Output>,\n    rug::Float: PartialOrd<<T as UnsignedAbs>::Output>,\n{\n    let cmp = n.partial_cmp_abs(&i);\n    assert_eq!(\n        PartialOrdAbs::<Float>::partial_cmp_abs(&n, &Float::from(i)),\n        cmp\n    );\n    assert_eq!((&n).abs().partial_cmp(&i.unsigned_abs()), cmp);\n    assert_eq!(\n        rug::Float::exact_from(&n)\n            .abs()\n            .partial_cmp(&i.unsigned_abs()),\n        cmp\n    );\n\n    let cmp_rev = cmp.map(Ordering::reverse);\n    assert_eq!(i.partial_cmp_abs(&n), cmp_rev);\n    assert_eq!(\n        PartialOrdAbs::<Float>::partial_cmp_abs(&Float::from(i), &n),\n        cmp_rev\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_abs_primitive_int_properties_helper_signed<\n    T: PartialOrdAbs<Float> + PrimitiveSigned,\n>()\nwhere\n    Float: From<T> + PartialOrdAbs<T> + PartialOrd<<T as UnsignedAbs>::Output>,\n    rug::Float: PartialOrd<<T as UnsignedAbs>::Output>,\n{\n    float_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        partial_cmp_abs_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    float_signed_pair_gen_var_4::<T>().test_properties(|(n, i)| {\n        partial_cmp_abs_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert!(x.partial_cmp_abs(&Float::NAN).is_none());\n        assert!(x.ge_abs(&Float::ZERO));\n        assert!(x.ge_abs(&Float::NEGATIVE_ZERO));\n        assert!(x.lt_abs(&Float::INFINITY));\n        assert!(x.lt_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    float_float_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n.lt_abs(&i) && i.lt_abs(&m) {\n            assert_eq!(PartialOrdAbs::<Float>::partial_cmp_abs(&n, &m), Some(Less));\n        } else if n.gt_abs(&i) && i.gt_abs(&m) {\n            assert_eq!(\n                PartialOrdAbs::<Float>::partial_cmp_abs(&n, &m),\n                Some(Greater)\n            );\n        }\n    });\n\n    float_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i.lt_abs(&n) && n.lt_abs(&j) {\n            assert!(i.lt_abs(&j));\n        } else if i.gt_abs(&n) && n.gt_abs(&j) {\n            assert!(i.gt_abs(&j));\n        }\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x).partial_cmp_abs(&y), x.partial_cmp_abs(&y));\n        assert_eq!(x.partial_cmp_abs(&Float::from(y)), x.partial_cmp_abs(&y));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_abs_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeZero, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_float_rational_triple_gen, float_rational_pair_gen, float_rational_pair_gen_var_1,\n    float_rational_pair_gen_var_2, float_rational_rational_triple_gen,\n};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_rational() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Rational::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp(&(&v).abs()), out);\n        assert_eq!(v.partial_cmp_abs(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u)\n                .abs()\n                .partial_cmp(&rug::Rational::from(&v).abs()),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", \"0\", None);\n    test(\"Infinity\", \"Infinity\", \"0\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"0\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"0\", Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", \"0\", Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", \"0\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"0\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"1\", None);\n    test(\"Infinity\", \"Infinity\", \"1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"100\", None);\n    test(\"Infinity\", \"Infinity\", \"100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"100\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", Some(Less));\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Equal));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    test(\"NaN\", \"NaN\", \"1/2\", None);\n    test(\"Infinity\", \"Infinity\", \"1/2\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1/2\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"1/2\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1/2\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1/2\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"1/2\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1/2\", Some(Equal));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1/2\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1/2\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/2\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/2\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/2\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1/2\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"1/2\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"1/2\", Some(Equal));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/2\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1/2\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/2\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/2\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/2\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"1/3\", None);\n    test(\"Infinity\", \"Infinity\", \"1/3\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1/3\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"1/3\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1/3\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"1/3\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1/3\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1/3\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1/3\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/3\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/3\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1/3\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"1/3\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"1/3\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/3\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1/3\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/3\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/3\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"22/7\", None);\n    test(\"Infinity\", \"Infinity\", \"22/7\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"22/7\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"22/7\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"22/7\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"22/7\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"22/7\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"22/7\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"22/7\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"22/7\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"22/7\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"22/7\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"22/7\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"22/7\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"22/7\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-1\", None);\n    test(\"Infinity\", \"Infinity\", \"-1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"-1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"-1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"-1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-100\", None);\n    test(\"Infinity\", \"Infinity\", \"-100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-100\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"-100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"-100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"-100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"-100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"-100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", Some(Less));\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Equal));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Greater));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-1/2\", None);\n    test(\"Infinity\", \"Infinity\", \"-1/2\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1/2\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"-1/2\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"-1/2\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"-1/2\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-1/2\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1/2\", Some(Equal));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/2\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/2\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/2\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/2\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/2\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/2\", Some(Equal));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/2\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/2\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/2\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-1/3\", None);\n    test(\"Infinity\", \"Infinity\", \"-1/3\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1/3\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"-1/3\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"-1/3\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-1/3\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1/3\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/3\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/3\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/3\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/3\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/3\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/3\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/3\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/3\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/3\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-22/7\", None);\n    test(\"Infinity\", \"Infinity\", \"-22/7\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-22/7\", Some(Greater));\n    test(\"0.0\", \"0x0.0\", \"-22/7\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"-22/7\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"-22/7\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"-22/7\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"-22/7\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-22/7\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-22/7\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-22/7\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-22/7\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-22/7\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"-22/7\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"-22/7\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"-22/7\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-22/7\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-22/7\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-22/7\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-22/7\", Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-22/7\", Some(Less));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_abs_rational_properties_helper(x: Float, y: Rational) {\n    let cmp = x.partial_cmp_abs(&y);\n    assert_eq!((&x).abs().partial_cmp(&(&y).abs()), cmp);\n    assert_eq!(\n        rug::Float::exact_from(&x)\n            .abs()\n            .partial_cmp(&rug::Rational::from(&y).abs()),\n        cmp\n    );\n    assert_eq!(y.partial_cmp_abs(&x), cmp.map(Ordering::reverse));\n}\n\n#[test]\nfn partial_cmp_abs_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_abs_rational_properties_helper(x, y);\n    });\n\n    float_rational_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_cmp_abs_rational_properties_helper(x, y);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!(x.partial_cmp_abs(&Float::NAN).is_none());\n        assert!(x.ge_abs(&Float::ZERO));\n        assert!(x.ge_abs(&Float::NEGATIVE_ZERO));\n        assert!(x.lt_abs(&Float::INFINITY));\n        assert!(x.lt_abs(&Float::NEGATIVE_INFINITY));\n    });\n\n    float_float_rational_triple_gen().test_properties(|(x, z, y)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    float_rational_rational_triple_gen().test_properties(|(y, x, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    float_rational_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::exact_from(&x).partial_cmp_abs(&y),\n            x.partial_cmp_abs(&y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_float_integer_triple_gen, float_integer_integer_triple_gen, float_integer_pair_gen,\n    float_integer_pair_gen_var_1, float_integer_pair_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_integer() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u).partial_cmp(&rug::Integer::from(&v)),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", \"0\", None);\n    test(\"Infinity\", \"Infinity\", \"0\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"0\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"0\", Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", \"0\", Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", \"0\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"0\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"1\", None);\n    test(\"Infinity\", \"Infinity\", \"1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"100\", None);\n    test(\"Infinity\", \"Infinity\", \"100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"100\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", Some(Less));\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-1\", None);\n    test(\"Infinity\", \"Infinity\", \"-1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"-1\", Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", \"-1\", Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"-100\", None);\n    test(\"Infinity\", \"Infinity\", \"-100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-100\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"-100\", Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", \"-100\", Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", \"-100\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-100\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-100\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", Some(Greater));\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Equal));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Greater));\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Greater));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_integer_properties_helper(x: Float, y: Integer) {\n    let cmp = x.partial_cmp(&y);\n    assert_eq!(x.partial_cmp(&Float::exact_from(&y)), cmp);\n    assert_eq!(\n        rug::Float::exact_from(&x).partial_cmp(&rug::Integer::from(&y)),\n        cmp\n    );\n    assert_eq!(y.partial_cmp(&x), cmp.map(Ordering::reverse));\n}\n\n#[test]\nfn partial_cmp_integer_properties() {\n    float_integer_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_integer_properties_helper(x, y);\n    });\n\n    float_integer_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_cmp_integer_properties_helper(x, y);\n    });\n\n    float_float_integer_triple_gen().test_properties(|(x, z, y)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    float_integer_integer_triple_gen().test_properties(|(y, x, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Float::exact_from(&x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Float::exact_from(&y)), Some(x.cmp(&y)));\n    });\n\n    float_integer_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x).partial_cmp(&y), x.partial_cmp(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_float_natural_triple_gen, float_natural_natural_triple_gen, float_natural_pair_gen,\n    float_natural_pair_gen_var_1, float_natural_pair_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_pair_gen;\nuse malachite_q::Rational;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_natural() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u).partial_cmp(&rug::Integer::from(&v)),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", \"0\", None);\n    test(\"Infinity\", \"Infinity\", \"0\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"0\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"0\", Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", \"0\", Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", \"0\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"0\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"1\", None);\n    test(\"Infinity\", \"Infinity\", \"1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"100\", None);\n    test(\"Infinity\", \"Infinity\", \"100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"100\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", Some(Less));\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_natural_properties_helper(x: Float, y: Natural) {\n    let cmp = x.partial_cmp(&y);\n    assert_eq!(x.partial_cmp(&Float::exact_from(&y)), cmp);\n    assert_eq!(\n        rug::Float::exact_from(&x).partial_cmp(&rug::Integer::from(&y)),\n        cmp\n    );\n    assert_eq!(y.partial_cmp(&x), cmp.map(Ordering::reverse));\n}\n\n#[test]\nfn partial_cmp_natural_properties() {\n    float_natural_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_natural_properties_helper(x, y);\n    });\n\n    float_natural_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_cmp_natural_properties_helper(x, y);\n    });\n\n    float_float_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    float_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Float::exact_from(&x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Float::exact_from(&y)), Some(x.cmp(&y)));\n    });\n\n    float_natural_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x).partial_cmp(&y), x.partial_cmp(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{primitive_float_gen, primitive_float_gen_var_11};\nuse malachite_float::Float;\nuse malachite_float::test_util::common::{\n    ORDERED_F32S, ORDERED_F64S, ORDERED_FLOAT_HEX_STRINGS, parse_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_float_primitive_float_triple_gen, float_gen, float_gen_var_2,\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_var_1,\n    float_primitive_float_primitive_float_triple_gen,\n};\nuse rug;\nuse std::cmp::Ordering::{self, *};\n\nconst fn encode(oo: Option<Ordering>) -> u8 {\n    match oo {\n        None => 9,\n        Some(Less) => 0,\n        Some(Equal) => 1,\n        Some(Greater) => 2,\n    }\n}\n\n#[rustfmt::skip]\nconst MATRIX_F32: [[u8; 17]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 1, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#100\n    [2, 2, 2, 2, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#2\n    [2, 2, 2, 2, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [2, 2, 2, 2, 2, 1, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], // NaN\n    [2, 2, 2, 2, 2, 2, 2, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#1\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#2\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#100\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 1, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1],\n];\n\n#[rustfmt::skip]\nconst MATRIX_F64: [[u8; 17]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 1, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 1, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 1, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#100\n    [2, 2, 2, 2, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#2\n    [2, 2, 2, 2, 1, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [2, 2, 2, 2, 2, 1, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 1, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], // NaN\n    [2, 2, 2, 2, 2, 2, 2, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 1, 0, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 1, 0, 0, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#1\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#2\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 1, 0, 0, 0, 0], // 0x1.0#100\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 1, 0, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 1, 0, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 1, 0],\n    [2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 1],\n];\n\n#[test]\nfn test_partial_cmp_primitive_float() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F64.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F64S.iter().zip(row.iter()) {\n            assert_eq!(encode(x.partial_cmp(&y)), e);\n            assert_eq!(encode(rug::Float::exact_from(&x).partial_cmp(&y)), e);\n            assert_eq!(encode(y.partial_cmp(&x).map(Ordering::reverse)), e);\n            assert_eq!(\n                encode(\n                    y.partial_cmp(&rug::Float::exact_from(&x))\n                        .map(Ordering::reverse)\n                ),\n                e\n            );\n        }\n    }\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F32.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F32S.iter().zip(row.iter()) {\n            assert_eq!(encode(x.partial_cmp(&y)), e);\n            assert_eq!(encode(rug::Float::exact_from(&x).partial_cmp(&y)), e);\n            assert_eq!(encode(y.partial_cmp(&x).map(Ordering::reverse)), e);\n            assert_eq!(\n                encode(\n                    y.partial_cmp(&rug::Float::exact_from(&x))\n                        .map(Ordering::reverse)\n                ),\n                e\n            );\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_primitive_float_properties_helper_helper<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveFloat,\n>(\n    n: Float,\n    u: T,\n) where\n    Float: TryFrom<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    let cmp = n.partial_cmp(&u);\n    assert_eq!(rug::Float::exact_from(&n).partial_cmp(&u), cmp);\n\n    let cmp_rev = cmp.map(Ordering::reverse);\n    assert_eq!(u.partial_cmp(&n), cmp_rev);\n    assert_eq!(u.partial_cmp(&rug::Float::exact_from(&n)), cmp_rev);\n\n    assert_eq!(\n        PartialOrd::<Float>::partial_cmp(&n, &Float::exact_from(u)),\n        cmp\n    );\n}\n\n#[allow(clippy::neg_cmp_op_on_partial_ord)]\nfn partial_cmp_primitive_float_properties_helper<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveFloat,\n>()\nwhere\n    Float: TryFrom<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    float_primitive_float_pair_gen::<T>().test_properties(|(n, u)| {\n        partial_cmp_primitive_float_properties_helper_helper(n, u);\n    });\n\n    float_primitive_float_pair_gen_var_1::<T>().test_properties(|(n, u)| {\n        partial_cmp_primitive_float_properties_helper_helper(n, u);\n    });\n\n    float_float_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &m), Some(Less));\n        } else if n > u && u > m {\n            assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &m), Some(Greater));\n        }\n    });\n\n    float_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    float_gen().test_properties(|x| {\n        assert!(!(x < T::NAN));\n        assert!(!(x > T::NAN));\n    });\n\n    float_gen_var_2().test_properties(|x| {\n        assert!(x >= T::NEGATIVE_INFINITY);\n        assert!(x <= T::INFINITY);\n    });\n\n    primitive_float_gen::<T>().test_properties(|x| {\n        assert!(!(x < Float::NAN));\n        assert!(!(x > Float::NAN));\n    });\n\n    primitive_float_gen_var_11::<T>().test_properties(|x| {\n        assert!(x >= Float::NEGATIVE_INFINITY);\n        assert!(x <= Float::INFINITY);\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_base::{apply_fn_to_signeds, apply_fn_to_unsigneds};\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_float_signed_triple_gen, float_float_unsigned_triple_gen, float_signed_pair_gen,\n    float_signed_pair_gen_var_4, float_signed_signed_triple_gen, float_unsigned_pair_gen,\n    float_unsigned_pair_gen_var_5, float_unsigned_unsigned_triple_gen,\n};\nuse rug;\nuse std::cmp::Ordering::{self, *};\n\n#[test]\nfn test_partial_cmp_u32() {\n    let test = |s, s_hex, v: u32, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(rug::Float::exact_from(&u).partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Less));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Less));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Less));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Less));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_u64() {\n    let test = |s, s_hex, v: u64, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(rug::Float::exact_from(&u).partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Less));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Less));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Less));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Less));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_i32() {\n    let test = |s, s_hex, v: i32, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(rug::Float::exact_from(&u).partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Less));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Less));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Less));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Less));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n\n    test(\"NaN\", \"NaN\", -1, None);\n    test(\"Infinity\", \"Infinity\", -1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -1, Some(Less));\n    test(\"0.0\", \"0x0.0\", -1, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", -1, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", -1, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", -1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", -1, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", -1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", -1, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", -1, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, Some(Greater));\n\n    test(\"NaN\", \"NaN\", -100, None);\n    test(\"Infinity\", \"Infinity\", -100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -100, Some(Less));\n    test(\"0.0\", \"0x0.0\", -100, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", -100, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", -100, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", -100, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", -100, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", -100, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", -100, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", -100, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, Some(Greater));\n}\n\n#[test]\nfn test_partial_cmp_i64() {\n    let test = |s, s_hex, v: i64, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(rug::Float::exact_from(&u).partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"NaN\", \"NaN\", 0, None);\n    test(\"Infinity\", \"Infinity\", 0, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 0, Some(Less));\n    test(\"0.0\", \"0x0.0\", 0, Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", 0, Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", 0, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", 0, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 0, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        0,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", 0, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 0, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 0, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        0,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        0,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, Some(Less));\n\n    test(\"NaN\", \"NaN\", 1, None);\n    test(\"Infinity\", \"Infinity\", 1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 1, Some(Less));\n    test(\"0.0\", \"0x0.0\", 1, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 1, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", 1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", 1, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 1, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 1, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 1, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        1,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        1,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, Some(Less));\n\n    test(\"NaN\", \"NaN\", 100, None);\n    test(\"Infinity\", \"Infinity\", 100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", 100, Some(Less));\n    test(\"0.0\", \"0x0.0\", 100, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", 100, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", 100, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", 100, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", 100, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", 100, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", 100, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", 100, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        100,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        100,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, Some(Less));\n\n    test(\"NaN\", \"NaN\", -1, None);\n    test(\"Infinity\", \"Infinity\", -1, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -1, Some(Less));\n    test(\"0.0\", \"0x0.0\", -1, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", -1, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", -1, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", -1, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", -1, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", -1, Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", -1, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", -1, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -1,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -1,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -1,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, Some(Greater));\n\n    test(\"NaN\", \"NaN\", -100, None);\n    test(\"Infinity\", \"Infinity\", -100, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", -100, Some(Less));\n    test(\"0.0\", \"0x0.0\", -100, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", -100, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", -100, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", -100, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", -100, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", -100, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", -100, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", -100, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        -100,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, Some(Greater));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_primitive_int_properties_helper_unsigned_helper<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveUnsigned,\n>(\n    n: Float,\n    u: T,\n) where\n    Float: From<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    let cmp = n.partial_cmp(&u);\n    assert_eq!(rug::Float::exact_from(&n).partial_cmp(&u), cmp);\n    assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &Float::from(u)), cmp);\n\n    let cmp_rev = cmp.map(Ordering::reverse);\n    assert_eq!(u.partial_cmp(&n), cmp_rev);\n    assert_eq!(u.partial_cmp(&rug::Float::exact_from(&n)), cmp_rev);\n    assert_eq!(\n        PartialOrd::<Float>::partial_cmp(&Float::from(u), &n),\n        cmp_rev\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_unsigned<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveUnsigned,\n>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    float_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        partial_cmp_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_unsigned_pair_gen_var_5::<T>().test_properties(|(n, u)| {\n        partial_cmp_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_float_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &m), Some(Less));\n        } else if n > u && u > m {\n            assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &m), Some(Greater));\n        }\n    });\n\n    float_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Float::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_primitive_int_properties_helper_signed_helper<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveSigned,\n>(\n    n: Float,\n    i: T,\n) where\n    Float: From<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    let cmp = n.partial_cmp(&i);\n    assert_eq!(rug::Float::exact_from(&n).partial_cmp(&i), cmp);\n    assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &Float::from(i)), cmp);\n\n    let cmp_rev = cmp.map(Ordering::reverse);\n    assert_eq!(i.partial_cmp(&n), cmp_rev);\n    assert_eq!(i.partial_cmp(&rug::Float::exact_from(&n)), cmp_rev);\n    assert_eq!(\n        PartialOrd::<Float>::partial_cmp(&Float::from(i), &n),\n        cmp_rev\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_signed<\n    T: PartialOrd<Float> + PartialOrd<rug::Float> + PrimitiveSigned,\n>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    rug::Float: PartialOrd<T>,\n{\n    float_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        partial_cmp_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    float_signed_pair_gen_var_4::<T>().test_properties(|(n, i)| {\n        partial_cmp_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    float_float_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n < i && i < m {\n            assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &m), Some(Less));\n        } else if n > i && i > m {\n            assert_eq!(PartialOrd::<Float>::partial_cmp(&n, &m), Some(Greater));\n        }\n    });\n\n    float_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i < n && n < j {\n            assert!(i < j);\n        } else if i > n && n > j {\n            assert!(i > j);\n        }\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Float::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_cmp_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::comparison::partial_cmp_rational::float_partial_cmp_rational_alt;\nuse malachite_float::test_util::generators::{\n    float_float_rational_triple_gen, float_rational_pair_gen, float_rational_pair_gen_var_1,\n    float_rational_pair_gen_var_2, float_rational_rational_triple_gen,\n};\nuse malachite_q::Rational;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_rational() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Rational::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n        assert_eq!(\n            rug::Float::exact_from(&u).partial_cmp(&rug::Rational::from(&v)),\n            out\n        );\n    };\n    test(\"NaN\", \"NaN\", \"0\", None);\n    test(\"Infinity\", \"Infinity\", \"0\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"0\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"0\", Some(Equal));\n    test(\"-0.0\", \"-0x0.0\", \"0\", Some(Equal));\n    test(\"1.0\", \"0x1.0#1\", \"0\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"0\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"0\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"0\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"1\", None);\n    test(\"Infinity\", \"Infinity\", \"1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"1\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1\", Some(Equal));\n    test(\"2.0\", \"0x2.0#1\", \"1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"100\", None);\n    test(\"Infinity\", \"Infinity\", \"100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"100\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"100\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"100\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"100\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"100\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"100\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", Some(Less));\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Equal));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Less));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Less));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Less));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Less));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, Some(Less));\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, Some(Less));\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Less));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Less));\n\n    test(\"NaN\", \"NaN\", \"1/2\", None);\n    test(\"Infinity\", \"Infinity\", \"1/2\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1/2\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"1/2\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1/2\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1/2\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"1/2\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1/2\", Some(Equal));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1/2\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1/2\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/2\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/2\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/2\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1/2\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"1/2\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"1/2\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/2\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1/2\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/2\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/2\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/2\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"1/3\", None);\n    test(\"Infinity\", \"Infinity\", \"1/3\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"1/3\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"1/3\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"1/3\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"1/3\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"1/3\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1/3\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1/3\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/3\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/3\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"1/3\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"1/3\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"1/3\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/3\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1/3\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"1/3\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/3\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/3\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"22/7\", None);\n    test(\"Infinity\", \"Infinity\", \"22/7\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"22/7\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"22/7\", Some(Less));\n    test(\"-0.0\", \"-0x0.0\", \"22/7\", Some(Less));\n    test(\"1.0\", \"0x1.0#1\", \"22/7\", Some(Less));\n    test(\"2.0\", \"0x2.0#1\", \"22/7\", Some(Less));\n    test(\"0.5\", \"0x0.8#1\", \"22/7\", Some(Less));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"22/7\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"22/7\", Some(Less));\n    test(\"-1.0\", \"-0x1.0#1\", \"22/7\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"22/7\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"22/7\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"22/7\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"22/7\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"22/7\", Some(Less));\n\n    test(\"NaN\", \"NaN\", \"-1\", None);\n    test(\"Infinity\", \"Infinity\", \"-1\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"-1\", Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", \"-1\", Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", \"-1\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-1\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", Some(Equal));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"-100\", None);\n    test(\"Infinity\", \"Infinity\", \"-100\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-100\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"-100\", Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", \"-100\", Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", \"-100\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-100\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-100\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", Some(Greater));\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Equal));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Greater));\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, None);\n    test(\"Infinity\", \"Infinity\", s, Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", s, Some(Less));\n    test(\"0.0\", \"0x0.0\", s, Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", s, Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", s, Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", s, Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", s, Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", s, Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", s, Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", s, Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        s,\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        s,\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, Some(Greater));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"-1/2\", None);\n    test(\"Infinity\", \"Infinity\", \"-1/2\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1/2\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"-1/2\", Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", \"-1/2\", Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", \"-1/2\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-1/2\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1/2\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/2\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/2\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/2\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/2\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/2\", Some(Equal));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/2\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/2\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/2\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/2\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/2\", Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"-1/3\", None);\n    test(\"Infinity\", \"Infinity\", \"-1/3\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-1/3\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"-1/3\", Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", \"-1/3\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-1/3\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-1/3\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/3\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/3\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/3\", Some(Less));\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/3\", Some(Less));\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/3\", Some(Less));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/3\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/3\",\n        Some(Less),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        Some(Less),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/3\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/3\", Some(Greater));\n\n    test(\"NaN\", \"NaN\", \"-22/7\", None);\n    test(\"Infinity\", \"Infinity\", \"-22/7\", Some(Greater));\n    test(\"-Infinity\", \"-Infinity\", \"-22/7\", Some(Less));\n    test(\"0.0\", \"0x0.0\", \"-22/7\", Some(Greater));\n    test(\"-0.0\", \"-0x0.0\", \"-22/7\", Some(Greater));\n    test(\"1.0\", \"0x1.0#1\", \"-22/7\", Some(Greater));\n    test(\"2.0\", \"0x2.0#1\", \"-22/7\", Some(Greater));\n    test(\"0.5\", \"0x0.8#1\", \"-22/7\", Some(Greater));\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-22/7\",\n        Some(Greater),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"-22/7\",\n        Some(Greater),\n    );\n    test(\n        \"3.1415926535897931\",\n        \"0x3.243f6a8885a30#53\",\n        \"-22/7\",\n        Some(Greater),\n    );\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-22/7\", Some(Greater));\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-22/7\", Some(Greater));\n    test(\"-1.0\", \"-0x1.0#1\", \"-22/7\", Some(Greater));\n    test(\"-2.0\", \"-0x2.0#1\", \"-22/7\", Some(Greater));\n    test(\"-0.5\", \"-0x0.8#1\", \"-22/7\", Some(Greater));\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-22/7\",\n        Some(Greater),\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-22/7\",\n        Some(Greater),\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-22/7\",\n        Some(Greater),\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-22/7\", Some(Less));\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-22/7\", Some(Greater));\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_cmp_rational_properties_helper(x: Float, y: Rational) {\n    let cmp = x.partial_cmp(&y);\n    assert_eq!(\n        rug::Float::exact_from(&x).partial_cmp(&rug::Rational::from(&y)),\n        cmp\n    );\n    assert_eq!(float_partial_cmp_rational_alt(&x, &y), cmp);\n    assert_eq!(y.partial_cmp(&x), cmp.map(Ordering::reverse));\n}\n\n#[test]\nfn partial_cmp_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        partial_cmp_rational_properties_helper(x, y);\n    });\n\n    float_rational_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_cmp_rational_properties_helper(x, y);\n    });\n\n    float_float_rational_triple_gen().test_properties(|(x, z, y)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    float_rational_rational_triple_gen().test_properties(|(y, x, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    float_rational_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Some(Rational::exact_from(&x).cmp(&y)), x.partial_cmp(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_eq_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_integer_pair_gen, float_integer_pair_gen_var_1, float_integer_pair_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen};\nuse malachite_q::Rational;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_integer() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(v == u, out);\n        assert_eq!(rug::Float::exact_from(&u) == rug::Integer::from(&v), out);\n    };\n    test(\"NaN\", \"NaN\", \"0\", false);\n    test(\"Infinity\", \"Infinity\", \"0\", false);\n    test(\"-Infinity\", \"-Infinity\", \"0\", false);\n    test(\"0.0\", \"0x0.0\", \"0\", true);\n    test(\"-0.0\", \"-0x0.0\", \"0\", true);\n    test(\"1.0\", \"0x1.0#1\", \"0\", false);\n    test(\"2.0\", \"0x2.0#1\", \"0\", false);\n    test(\"0.5\", \"0x0.8#1\", \"0\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"0\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"0\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", false);\n\n    test(\"NaN\", \"NaN\", \"1\", false);\n    test(\"Infinity\", \"Infinity\", \"1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1\", false);\n    test(\"0.0\", \"0x0.0\", \"1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"1\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", false);\n\n    test(\"NaN\", \"NaN\", \"100\", false);\n    test(\"Infinity\", \"Infinity\", \"100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"100\", false);\n    test(\"0.0\", \"0x0.0\", \"100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"100\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"100\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", false);\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    test(\"NaN\", \"NaN\", \"-1\", false);\n    test(\"Infinity\", \"Infinity\", \"-1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1\", false);\n    test(\"0.0\", \"0x0.0\", \"-1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"-1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", false);\n\n    test(\"NaN\", \"NaN\", \"-100\", false);\n    test(\"Infinity\", \"Infinity\", \"-100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-100\", false);\n    test(\"0.0\", \"0x0.0\", \"-100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-100\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", false);\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, true);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::cmp_owned)]\nfn partial_eq_integer_properties_helper(x: Float, y: Integer) {\n    let eq = x == y;\n    assert_eq!(y == x, eq);\n    assert_eq!(x == Float::exact_from(&y), eq);\n    assert_eq!(rug::Float::exact_from(&x) == rug::Integer::from(&y), eq);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn partial_eq_integer_properties() {\n    float_integer_pair_gen().test_properties(|(x, y)| {\n        partial_eq_integer_properties_helper(x, y);\n    });\n\n    float_integer_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_eq_integer_properties_helper(x, y);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_ne!(x, Float::NAN);\n        assert_ne!(x, Float::INFINITY);\n        assert_ne!(x, Float::NEGATIVE_INFINITY);\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Float::exact_from(&x) == y, x == y);\n        assert_eq!(x == Float::exact_from(&y), x == y);\n    });\n\n    float_integer_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x) == y, x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_natural_pair_gen, float_natural_pair_gen_var_1, float_natural_pair_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen};\nuse malachite_q::Rational;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_natural() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(v == u, out);\n        assert_eq!(rug::Float::exact_from(&u) == rug::Integer::from(&v), out);\n    };\n    test(\"NaN\", \"NaN\", \"0\", false);\n    test(\"Infinity\", \"Infinity\", \"0\", false);\n    test(\"-Infinity\", \"-Infinity\", \"0\", false);\n    test(\"0.0\", \"0x0.0\", \"0\", true);\n    test(\"-0.0\", \"-0x0.0\", \"0\", true);\n    test(\"1.0\", \"0x1.0#1\", \"0\", false);\n    test(\"2.0\", \"0x2.0#1\", \"0\", false);\n    test(\"0.5\", \"0x0.8#1\", \"0\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"0\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"0\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", false);\n\n    test(\"NaN\", \"NaN\", \"1\", false);\n    test(\"Infinity\", \"Infinity\", \"1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1\", false);\n    test(\"0.0\", \"0x0.0\", \"1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"1\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", false);\n\n    test(\"NaN\", \"NaN\", \"100\", false);\n    test(\"Infinity\", \"Infinity\", \"100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"100\", false);\n    test(\"0.0\", \"0x0.0\", \"100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"100\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"100\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", false);\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::cmp_owned)]\nfn partial_eq_natural_properties_helper(x: Float, y: Natural) {\n    let eq = x == y;\n    assert_eq!(y == x, eq);\n    assert_eq!(x == Float::exact_from(&y), eq);\n    assert_eq!(rug::Float::exact_from(&x) == rug::Integer::from(&y), eq);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn partial_eq_natural_properties() {\n    float_natural_pair_gen().test_properties(|(x, y)| {\n        partial_eq_natural_properties_helper(x, y);\n    });\n\n    float_natural_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_eq_natural_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_ne!(x, Float::NAN);\n        assert_ne!(x, Float::INFINITY);\n        assert_ne!(x, Float::NEGATIVE_INFINITY);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Float::exact_from(&x) == y, x == y);\n        assert_eq!(x == Float::exact_from(&y), x == y);\n    });\n\n    float_natural_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x) == y, x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::{\n    ORDERED_F32S, ORDERED_F64S, ORDERED_FLOAT_HEX_STRINGS, parse_hex_string,\n};\nuse malachite_float::test_util::generators::{\n    float_primitive_float_pair_gen, float_primitive_float_pair_gen_var_1,\n};\nuse rug;\nuse std::cmp::Ordering::*;\n\n#[rustfmt::skip]\nconst MATRIX_F32: [[u8; 17]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n];\n\n#[rustfmt::skip]\nconst MATRIX_F64: [[u8; 17]; 21] = [\n    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#100\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#2\n    [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // -0x1.0#1\n    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // -0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // NaN\n    [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], // 0.0\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#1\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#2\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], // 0x1.0#100\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n];\n\n#[test]\nfn test_partial_eq_primitive_float() {\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F64.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F64S.iter().zip(row.iter()) {\n            assert_eq!(u8::from(x == y), e);\n            assert_eq!(u8::from(rug::Float::exact_from(&x) == y), e);\n            assert_eq!(u8::from(y == x), e);\n            assert_eq!(u8::from(y == rug::Float::exact_from(&x)), e);\n        }\n    }\n    for (sx, row) in ORDERED_FLOAT_HEX_STRINGS.iter().zip(MATRIX_F32.iter()) {\n        let x = parse_hex_string(sx);\n        for (&y, &e) in ORDERED_F32S.iter().zip(row.iter()) {\n            assert_eq!(u8::from(x == y), e);\n            assert_eq!(u8::from(rug::Float::exact_from(&x) == y), e);\n            assert_eq!(u8::from(y == x), e);\n            assert_eq!(u8::from(y == rug::Float::exact_from(&x)), e);\n        }\n    }\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_eq_primitive_float_properties_helper_helper<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveFloat,\n>(\n    n: Float,\n    f: T,\n) where\n    Float: TryFrom<T> + PartialEq<T> + PartialOrd<T>,\n    rug::Float: PartialEq<T>,\n{\n    let eq = n == f;\n    assert_eq!(f == n, eq);\n    let rn = rug::Float::exact_from(&n);\n    assert_eq!(rn == f, eq);\n    assert_eq!(f == rn, eq);\n    assert_eq!(n.partial_cmp(&f) == Some(Equal), eq);\n    if f.is_finite() {\n        assert_eq!(PartialEq::<Float>::eq(&n, &Float::exact_from(f)), eq);\n    }\n}\n\nfn partial_eq_primitive_float_properties_helper<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveFloat,\n>()\nwhere\n    Float: TryFrom<T> + PartialEq<T> + PartialOrd<T>,\n    rug::Float: PartialEq<T>,\n{\n    float_primitive_float_pair_gen::<T>().test_properties(|(n, f)| {\n        partial_eq_primitive_float_properties_helper_helper(n, f);\n    });\n\n    float_primitive_float_pair_gen_var_1::<T>().test_properties(|(n, f)| {\n        partial_eq_primitive_float_properties_helper_helper(n, f);\n    });\n}\n\n#[test]\nfn partial_eq_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_eq_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen, unsigned_gen, unsigned_pair_gen_var_27,\n};\nuse malachite_base::{apply_fn_to_signeds, apply_fn_to_unsigneds};\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_signed_pair_gen, float_signed_pair_gen_var_4, float_unsigned_pair_gen,\n    float_unsigned_pair_gen_var_5,\n};\nuse rug;\n\n#[test]\nfn test_partial_eq_u32() {\n    let test = |s, s_hex, v: u32, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        let ru = rug::Float::exact_from(&u);\n        assert_eq!(u == v, out);\n        assert_eq!(ru == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == ru, out);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, false);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n}\n\n#[test]\nfn test_partial_eq_u64() {\n    let test = |s, s_hex, v: u64, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        let ru = rug::Float::exact_from(&u);\n        assert_eq!(u == v, out);\n        assert_eq!(ru == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == ru, out);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, false);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n}\n\n#[test]\nfn test_partial_eq_i32() {\n    let test = |s, s_hex, v: i32, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        let ru = rug::Float::exact_from(&u);\n        assert_eq!(u == v, out);\n        assert_eq!(ru == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == ru, out);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, false);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n\n    test(\"NaN\", \"NaN\", -1, false);\n    test(\"Infinity\", \"Infinity\", -1, false);\n    test(\"-Infinity\", \"-Infinity\", -1, false);\n    test(\"0.0\", \"0x0.0\", -1, false);\n    test(\"-0.0\", \"-0x0.0\", -1, false);\n    test(\"1.0\", \"0x1.0#1\", -1, false);\n    test(\"2.0\", \"0x2.0#1\", -1, false);\n    test(\"0.5\", \"0x0.8#1\", -1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, false);\n    test(\"-1.0\", \"-0x1.0#1\", -1, true);\n    test(\"-2.0\", \"-0x2.0#1\", -1, false);\n    test(\"-0.5\", \"-0x0.8#1\", -1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", -1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, false);\n\n    test(\"NaN\", \"NaN\", -100, false);\n    test(\"Infinity\", \"Infinity\", -100, false);\n    test(\"-Infinity\", \"-Infinity\", -100, false);\n    test(\"0.0\", \"0x0.0\", -100, false);\n    test(\"-0.0\", \"-0x0.0\", -100, false);\n    test(\"1.0\", \"0x1.0#1\", -100, false);\n    test(\"2.0\", \"0x2.0#1\", -100, false);\n    test(\"0.5\", \"0x0.8#1\", -100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, false);\n    test(\"-1.0\", \"-0x1.0#1\", -100, false);\n    test(\"-2.0\", \"-0x2.0#1\", -100, false);\n    test(\"-0.5\", \"-0x0.8#1\", -100, false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, false);\n}\n\n#[test]\nfn test_partial_eq_i64() {\n    let test = |s, s_hex, v: i64, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n\n        let ru = rug::Float::exact_from(&u);\n        assert_eq!(u == v, out);\n        assert_eq!(ru == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == ru, out);\n    };\n    test(\"NaN\", \"NaN\", 0, false);\n    test(\"Infinity\", \"Infinity\", 0, false);\n    test(\"-Infinity\", \"-Infinity\", 0, false);\n    test(\"0.0\", \"0x0.0\", 0, true);\n    test(\"-0.0\", \"-0x0.0\", 0, true);\n    test(\"1.0\", \"0x1.0#1\", 0, false);\n    test(\"2.0\", \"0x2.0#1\", 0, false);\n    test(\"0.5\", \"0x0.8#1\", 0, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 0, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 0, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 0, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 0, false);\n    test(\"-1.0\", \"-0x1.0#1\", 0, false);\n    test(\"-2.0\", \"-0x2.0#1\", 0, false);\n    test(\"-0.5\", \"-0x0.8#1\", 0, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 0, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 0, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 0, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 0, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 0, false);\n\n    test(\"NaN\", \"NaN\", 1, false);\n    test(\"Infinity\", \"Infinity\", 1, false);\n    test(\"-Infinity\", \"-Infinity\", 1, false);\n    test(\"0.0\", \"0x0.0\", 1, false);\n    test(\"-0.0\", \"-0x0.0\", 1, false);\n    test(\"1.0\", \"0x1.0#1\", 1, true);\n    test(\"2.0\", \"0x2.0#1\", 1, false);\n    test(\"0.5\", \"0x0.8#1\", 1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 1, false);\n    test(\"-1.0\", \"-0x1.0#1\", 1, false);\n    test(\"-2.0\", \"-0x2.0#1\", 1, false);\n    test(\"-0.5\", \"-0x0.8#1\", 1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 1, false);\n\n    test(\"NaN\", \"NaN\", 100, false);\n    test(\"Infinity\", \"Infinity\", 100, false);\n    test(\"-Infinity\", \"-Infinity\", 100, false);\n    test(\"0.0\", \"0x0.0\", 100, false);\n    test(\"-0.0\", \"-0x0.0\", 100, false);\n    test(\"1.0\", \"0x1.0#1\", 100, false);\n    test(\"2.0\", \"0x2.0#1\", 100, false);\n    test(\"0.5\", \"0x0.8#1\", 100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", 100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", 100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", 100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", 100, false);\n    test(\"-1.0\", \"-0x1.0#1\", 100, false);\n    test(\"-2.0\", \"-0x2.0#1\", 100, false);\n    test(\"-0.5\", \"-0x0.8#1\", 100, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", 100, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", 100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", 100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", 100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", 100, false);\n\n    test(\"NaN\", \"NaN\", -1, false);\n    test(\"Infinity\", \"Infinity\", -1, false);\n    test(\"-Infinity\", \"-Infinity\", -1, false);\n    test(\"0.0\", \"0x0.0\", -1, false);\n    test(\"-0.0\", \"-0x0.0\", -1, false);\n    test(\"1.0\", \"0x1.0#1\", -1, false);\n    test(\"2.0\", \"0x2.0#1\", -1, false);\n    test(\"0.5\", \"0x0.8#1\", -1, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -1, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -1, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -1, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -1, false);\n    test(\"-1.0\", \"-0x1.0#1\", -1, true);\n    test(\"-2.0\", \"-0x2.0#1\", -1, false);\n    test(\"-0.5\", \"-0x0.8#1\", -1, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", -1, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -1, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -1, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -1, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -1, false);\n\n    test(\"NaN\", \"NaN\", -100, false);\n    test(\"Infinity\", \"Infinity\", -100, false);\n    test(\"-Infinity\", \"-Infinity\", -100, false);\n    test(\"0.0\", \"0x0.0\", -100, false);\n    test(\"-0.0\", \"-0x0.0\", -100, false);\n    test(\"1.0\", \"0x1.0#1\", -100, false);\n    test(\"2.0\", \"0x2.0#1\", -100, false);\n    test(\"0.5\", \"0x0.8#1\", -100, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", -100, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", -100, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", -100, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", -100, false);\n    test(\"-1.0\", \"-0x1.0#1\", -100, false);\n    test(\"-2.0\", \"-0x2.0#1\", -100, false);\n    test(\"-0.5\", \"-0x0.8#1\", -100, false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        -100,\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", -100, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", -100, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", -100, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", -100, false);\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::cmp_owned, clippy::op_ref)]\nfn partial_eq_primitive_int_properties_helper_unsigned_helper<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveUnsigned,\n>(\n    n: Float,\n    u: T,\n) where\n    Float: From<T> + PartialEq<T>,\n    rug::Float: PartialEq<T>,\n{\n    let eq = n == u;\n    assert_eq!(rug::Float::exact_from(&n) == u, eq);\n    assert_eq!(&n == &Float::from(u), eq);\n\n    assert_eq!(u == n, eq);\n    assert_eq!(u == rug::Float::exact_from(&n), eq);\n    assert_eq!(&Float::from(u) == &n, eq);\n}\n\n#[allow(clippy::cmp_owned, clippy::op_ref)]\nfn partial_eq_primitive_int_properties_helper_unsigned<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveUnsigned,\n>()\nwhere\n    Float: From<T> + PartialEq<T>,\n    rug::Float: PartialEq<T>,\n{\n    float_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        partial_eq_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    float_unsigned_pair_gen_var_5::<T>().test_properties(|(n, u)| {\n        partial_eq_primitive_int_properties_helper_unsigned_helper(n, u);\n    });\n\n    unsigned_gen::<T>().test_properties(|x| {\n        assert_ne!(x, Float::NAN);\n        assert_ne!(x, Float::INFINITY);\n        assert_ne!(x, Float::NEGATIVE_INFINITY);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x) == y, x == y);\n        assert_eq!(x == Float::from(y), x == y);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::op_ref)]\nfn partial_eq_primitive_int_properties_helper_signed_helper<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveSigned,\n>(\n    n: Float,\n    i: T,\n) where\n    Float: From<T> + PartialEq<T>,\n    rug::Float: PartialEq<T>,\n{\n    let eq = n == i;\n    assert_eq!(rug::Float::exact_from(&n) == i, eq);\n    assert_eq!(&n == &Float::from(i), eq);\n\n    assert_eq!(i == n, eq);\n    assert_eq!(i == rug::Float::exact_from(&n), eq);\n    assert_eq!(&Float::from(i) == &n, eq);\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref)]\nfn partial_eq_primitive_int_properties_helper_signed<\n    T: PartialEq<Float> + PartialEq<rug::Float> + PrimitiveSigned,\n>()\nwhere\n    Float: From<T> + PartialEq<T>,\n    rug::Float: PartialEq<T>,\n{\n    float_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        partial_eq_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    float_signed_pair_gen_var_4::<T>().test_properties(|(n, i)| {\n        partial_eq_primitive_int_properties_helper_signed_helper(n, i);\n    });\n\n    signed_gen::<T>().test_properties(|x| {\n        assert_ne!(x, Float::NAN);\n        assert_ne!(x, Float::INFINITY);\n        assert_ne!(x, Float::NEGATIVE_INFINITY);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Float::from(x) == y, x == y);\n        assert_eq!(x == Float::from(y), x == y);\n    });\n}\n\n#[test]\nfn partial_eq_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_eq_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_eq_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-float/tests/comparison/partial_eq_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_rational_pair_gen, float_rational_pair_gen_var_1, float_rational_pair_gen_var_2,\n};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_rational() {\n    let test = |s, s_hex, t, out| {\n        let u = parse_hex_string(s_hex);\n        assert_eq!(u.to_string(), s);\n        let v = Rational::from_str(t).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(v == u, out);\n        assert_eq!(rug::Float::exact_from(&u) == rug::Rational::from(&v), out);\n    };\n    test(\"NaN\", \"NaN\", \"0\", false);\n    test(\"Infinity\", \"Infinity\", \"0\", false);\n    test(\"-Infinity\", \"-Infinity\", \"0\", false);\n    test(\"0.0\", \"0x0.0\", \"0\", true);\n    test(\"-0.0\", \"-0x0.0\", \"0\", true);\n    test(\"1.0\", \"0x1.0#1\", \"0\", false);\n    test(\"2.0\", \"0x2.0#1\", \"0\", false);\n    test(\"0.5\", \"0x0.8#1\", \"0\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"0\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"0\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"0\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"0\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"0\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"0\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"0\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"0\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"0\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"0\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"0\", false);\n\n    test(\"NaN\", \"NaN\", \"1\", false);\n    test(\"Infinity\", \"Infinity\", \"1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1\", false);\n    test(\"0.0\", \"0x0.0\", \"1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1\", true);\n    test(\"2.0\", \"0x2.0#1\", \"1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", \"1\", false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1\", false);\n\n    test(\"NaN\", \"NaN\", \"100\", false);\n    test(\"Infinity\", \"Infinity\", \"100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"100\", false);\n    test(\"0.0\", \"0x0.0\", \"100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"100\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"100\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"100\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"100\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"100\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"100\", false);\n\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, true);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"2582249878086908589655919172003011874329705792829223512830659356540647622016841194629\\\n    645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    test(\"NaN\", \"NaN\", \"1/2\", false);\n    test(\"Infinity\", \"Infinity\", \"1/2\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1/2\", false);\n    test(\"0.0\", \"0x0.0\", \"1/2\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1/2\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1/2\", false);\n    test(\"2.0\", \"0x2.0#1\", \"1/2\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1/2\", true);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1/2\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1/2\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1/2\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/2\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/2\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1/2\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"1/2\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1/2\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/2\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1/2\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1/2\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/2\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/2\", false);\n\n    test(\"NaN\", \"NaN\", \"1/3\", false);\n    test(\"Infinity\", \"Infinity\", \"1/3\", false);\n    test(\"-Infinity\", \"-Infinity\", \"1/3\", false);\n    test(\"0.0\", \"0x0.0\", \"1/3\", false);\n    test(\"-0.0\", \"-0x0.0\", \"1/3\", false);\n    test(\"1.0\", \"0x1.0#1\", \"1/3\", false);\n    test(\"2.0\", \"0x2.0#1\", \"1/3\", false);\n    test(\"0.5\", \"0x0.8#1\", \"1/3\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"1/3\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1/3\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"1/3\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"1/3\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"1/3\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"1/3\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"1/3\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"1/3\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1/3\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"1/3\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"1/3\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"1/3\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"1/3\", false);\n\n    test(\"NaN\", \"NaN\", \"22/7\", false);\n    test(\"Infinity\", \"Infinity\", \"22/7\", false);\n    test(\"-Infinity\", \"-Infinity\", \"22/7\", false);\n    test(\"0.0\", \"0x0.0\", \"22/7\", false);\n    test(\"-0.0\", \"-0x0.0\", \"22/7\", false);\n    test(\"1.0\", \"0x1.0#1\", \"22/7\", false);\n    test(\"2.0\", \"0x2.0#1\", \"22/7\", false);\n    test(\"0.5\", \"0x0.8#1\", \"22/7\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"22/7\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"22/7\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"22/7\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"22/7\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"22/7\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"22/7\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"22/7\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"22/7\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"22/7\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"22/7\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"22/7\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"22/7\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"22/7\", false);\n\n    test(\"NaN\", \"NaN\", \"-1\", false);\n    test(\"Infinity\", \"Infinity\", \"-1\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1\", false);\n    test(\"0.0\", \"0x0.0\", \"-1\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-1\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"-1\", false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1\",\n        false,\n    );\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", \"-1\", false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", \"-1\", false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1\", false);\n\n    test(\"NaN\", \"NaN\", \"-100\", false);\n    test(\"Infinity\", \"Infinity\", \"-100\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-100\", false);\n    test(\"0.0\", \"0x0.0\", \"-100\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-100\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-100\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-100\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-100\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-100\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-100\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-100\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-100\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-100\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-100\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-100\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-100\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-100\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-100\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-100\", false);\n\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493376\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, true);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    // off by 1\n    let s = \"-258224987808690858965591917200301187432970579282922351283065935654064762201684119462\\\n    9645353280137831435903171972747493377\";\n    test(\"NaN\", \"NaN\", s, false);\n    test(\"Infinity\", \"Infinity\", s, false);\n    test(\"-Infinity\", \"-Infinity\", s, false);\n    test(\"0.0\", \"0x0.0\", s, false);\n    test(\"-0.0\", \"-0x0.0\", s, false);\n    test(\"1.0\", \"0x1.0#1\", s, false);\n    test(\"2.0\", \"0x2.0#1\", s, false);\n    test(\"0.5\", \"0x0.8#1\", s, false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", s, false);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", s, false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", s, false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", s, false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", s, false);\n    test(\"-1.0\", \"-0x1.0#1\", s, false);\n    test(\"-2.0\", \"-0x2.0#1\", s, false);\n    test(\"-0.5\", \"-0x0.8#1\", s, false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", s, false);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", s, false);\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\", s, false);\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", s, false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", s, false);\n\n    test(\"NaN\", \"NaN\", \"-1/2\", false);\n    test(\"Infinity\", \"Infinity\", \"-1/2\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1/2\", false);\n    test(\"0.0\", \"0x0.0\", \"-1/2\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1/2\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1/2\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-1/2\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1/2\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1/2\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1/2\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/2\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/2\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/2\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/2\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/2\", true);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/2\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/2\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/2\", false);\n\n    test(\"NaN\", \"NaN\", \"-1/3\", false);\n    test(\"Infinity\", \"Infinity\", \"-1/3\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-1/3\", false);\n    test(\"0.0\", \"0x0.0\", \"-1/3\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-1/3\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-1/3\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-1/3\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-1/3\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-1/3\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-1/3\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-1/3\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-1/3\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-1/3\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-1/3\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-1/3\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-1/3\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-1/3\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-1/3\", false);\n\n    test(\"NaN\", \"NaN\", \"-22/7\", false);\n    test(\"Infinity\", \"Infinity\", \"-22/7\", false);\n    test(\"-Infinity\", \"-Infinity\", \"-22/7\", false);\n    test(\"0.0\", \"0x0.0\", \"-22/7\", false);\n    test(\"-0.0\", \"-0x0.0\", \"-22/7\", false);\n    test(\"1.0\", \"0x1.0#1\", \"-22/7\", false);\n    test(\"2.0\", \"0x2.0#1\", \"-22/7\", false);\n    test(\"0.5\", \"0x0.8#1\", \"-22/7\", false);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"-22/7\", false);\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\", \"-22/7\", false);\n    test(\"3.0e120\", \"0x1.0E+100#1\", \"-22/7\", false);\n    test(\"4.0e-121\", \"0x1.0E-100#1\", \"-22/7\", false);\n    test(\"-1.0\", \"-0x1.0#1\", \"-22/7\", false);\n    test(\"-2.0\", \"-0x2.0#1\", \"-22/7\", false);\n    test(\"-0.5\", \"-0x0.8#1\", \"-22/7\", false);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\n        \"-3.1415926535897931\",\n        \"-0x3.243f6a8885a30#53\",\n        \"-22/7\",\n        false,\n    );\n    test(\"-3.0e120\", \"-0x1.0E+100#1\", \"-22/7\", false);\n    test(\"-4.0e-121\", \"-0x1.0E-100#1\", \"-22/7\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn partial_eq_rational_properties_helper(x: Float, y: Rational) {\n    let eq = x == y;\n    assert_eq!(y == x, eq);\n    assert_eq!(rug::Float::exact_from(&x) == rug::Rational::from(&y), eq);\n}\n\n#[test]\nfn partial_eq_rational_properties() {\n    float_rational_pair_gen().test_properties(|(x, y)| {\n        partial_eq_rational_properties_helper(x, y);\n    });\n\n    float_rational_pair_gen_var_2().test_properties(|(x, y)| {\n        partial_eq_rational_properties_helper(x, y);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_ne!(x, Float::NAN);\n        assert_ne!(x, Float::INFINITY);\n        assert_ne!(x, Float::NEGATIVE_INFINITY);\n    });\n\n    float_rational_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(&x) == y, x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/gauss_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::GaussConstant;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_gauss_constant_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::gauss_constant_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_gauss_constant_prec() {\n    test_gauss_constant_prec_helper(1, \"1.0\", \"0x1.0#1\", Greater);\n    test_gauss_constant_prec_helper(2, \"0.8\", \"0x0.c#2\", Less);\n    test_gauss_constant_prec_helper(3, \"0.9\", \"0x0.e#3\", Greater);\n    test_gauss_constant_prec_helper(4, \"0.81\", \"0x0.d#4\", Less);\n    test_gauss_constant_prec_helper(5, \"0.84\", \"0x0.d8#5\", Greater);\n    test_gauss_constant_prec_helper(6, \"0.83\", \"0x0.d4#6\", Less);\n    test_gauss_constant_prec_helper(7, \"0.836\", \"0x0.d6#7\", Greater);\n    test_gauss_constant_prec_helper(8, \"0.836\", \"0x0.d6#8\", Greater);\n    test_gauss_constant_prec_helper(9, \"0.834\", \"0x0.d58#9\", Less);\n    test_gauss_constant_prec_helper(10, \"0.835\", \"0x0.d5c#10\", Greater);\n    test_gauss_constant_prec_helper(\n        100,\n        \"0.834626841674073186281429732799\",\n        \"0x0.d5aa1acd5a9a1f6b126ed4160#100\",\n        Less,\n    );\n    test_gauss_constant_prec_helper(\n        1000,\n        \"0.834626841674073186281429732799046808993993013490347002449827370103681992709526411869691\\\n        160351275324129067850352412010086724789007634750392659060526742712560320685998973751521461\\\n        574107190667714762311244616644051871383967845140283869200451381335890758553020498480052804\\\n        4693164358093689789568906891741207\",\n        \"0x0.d5aa1acd5a9a1f6b126ed416015390b8dc5fceee4c86afc8c271f049361406e4cdd9089ef0715384d6c72\\\n        c4bdd754b2bc1ecc5c199c686439032cbb16813342ded4cffc19dcab8db34c27b6168ceb88298ed572b191c8f3\\\n        05743e1f293dfd41f82b0210f65e6163e5434a891261dc7440e2093b1a156a8e05ae8319d30#1000\",\n        Greater,\n    );\n    test_gauss_constant_prec_helper(\n        10000,\n        \"0.834626841674073186281429732799046808993993013490347002449827370103681992709526411869691\\\n        160351275324129067850352412010086724789007634750392659060526742712560320685998973751521461\\\n        574107190667714762311244616644051871383967845140283869200451381335890758553020498480052804\\\n        469316435809368978956890689174120737291094066558175187025477401074678379716526356753331906\\\n        545452517692961030560054068494662548964218614294720752148653658161076202146037520348775359\\\n        620856771168292200325359109589899893069833199696977335883739104959085967402918246956874691\\\n        648574519106727574078611438142761058018432034542615493754610095708911752106842013580331247\\\n        539219381390232390909523434088742226918438886299422225926335216394780110220990752149069396\\\n        430836038257717941194870596739642726558350848321693971336950595116238828151547470228642077\\\n        757753710601888047232489046185253018895970256898180138788048957359293465403946331321583387\\\n        855328545224934416417651732023496827033747209414764964964606237379439957051908666982548125\\\n        962465776495889388368485992365411189017490504837785319323332016970056895534269527949656522\\\n        591691440712533718989871283605282652705310788877986415746880714285132363349955706585164159\\\n        241908262606339549845864348827078931363082390967437220434580842087307738346482679475197152\\\n        331746478597653712438272228263231954311739836817821079539242107816783313273533095656482023\\\n        584565825460564836279530167452398262582723504220166256671818402486313168189187792969542212\\\n        049101757196085075106858844201730767102408667492711144920904088412131757268261002709591485\\\n        892572769623193922808548994645936128594734522557112869973628301289234178756660025395220971\\\n        552551454810467511328914938148018407394784903305080042952463744828221428366721013966075942\\\n        176793399501825273207819753276434605496999824553994689519587067068339386727318342025784480\\\n        812767824268457965573220366984271657187184409113540094514027074844640093106297080444683824\\\n        377405875474810493604461011348533762134305687849293031921110040424810842901352348537310269\\\n        206343713905334007912336241882284201504403580321299174976797884816704896804726358250985559\\\n        799985988186958064670880371662368698113531302487616884846859115258187407737403728723368707\\\n        323846651707183803490851996303220801277270427901677230978957397647160240115820018502810895\\\n        154331934225555668095902625013638806356733750900152886422306611378111421987550050293430845\\\n        245916855621247493144225520107062263328132881734912860608708345845489197324468978356848814\\\n        153016313843435670624732166396406812362503527093774812335463520844348918966133198354326738\\\n        496326752080510329079510994322418056607631925724340293558660223517800973234536235348928246\\\n        383901175664232107529211451027625980008171999768528451504191728443523334216985440123487511\\\n        813092014431776472273139813296105395494814393977203673426345745101500312996611664855878256\\\n        912980607401095185355559714095036916705107898036880918260750972195965805299757075605874207\\\n        106344998902706621017515778393586780555045138364087216847932503796899969299231484446771505\\\n        66063511739512880228167240763662857429382489\",\n        \"0x0.d5aa1acd5a9a1f6b126ed416015390b8dc5fceee4c86afc8c271f049361406e4cdd9089ef0715384d6c72\\\n        c4bdd754b2bc1ecc5c199c686439032cbb16813342ded4cffc19dcab8db34c27b6168ceb88298ed572b191c8f3\\\n        05743e1f293dfd41f82b0210f65e6163e5434a891261dc7440e2093b1a156a8e05ae8319d2ff97641b5a7fd78f\\\n        7cf6dc96868e4130d819e5f2ca3a94c6112e9b5a5801bfe4a11e5a42582d5081ac41fa9b728b4ac35e244d5a85\\\n        69a511aa70984b50c4070684a6ac159bdc9325d1fde1271f02527cc064b69ec913f415531392712d3fb1c34ed3\\\n        c075bef86d6a059f7a22834767ad03e455760919f51006e91df313136656ef23512f1e105bfa2eb5f06fef2837\\\n        36474330c7c0bac59657d9963f201efba238eaa0c933f0989864323803599e6dc26aef9c7fa5f268f531f503b3\\\n        af964f171b4980fb0cb845df9f68e7393d3471de7195e248e795b9225a0b176c4deecd2390e150a7ca76c1f3dd\\\n        f86cce329f30053a570d269f38de7c3d7475abb273c84dbbbc9e2469b486e86b3f792f8c039bb07b126676c07b\\\n        33332595fc7d9f877476f088f075265ed7f675bbcc8e6d8ada2f52abb307a3ebc73a2639ecf3287b4c2a68c18e\\\n        03b158d2ddfabb3f14826dc5a16e5b0d15b6dc83d22f25505ed5a58a81e4fb874d6fa23df6989cd319003989f0\\\n        8e14d201f949eff049dcb40d2e4ee6a09a9cb8a8ed98c3cf66f7aadd8ab1107e0777170849e24b32d5342ba17d\\\n        e3db8816045423a00fd6feebadc650d05a47f26ef7b184793feab8a0f72fda537794ec1db7ba60bae81a34044d\\\n        f64da299718b09ab02787b15c0cc87c047594f33d4955d2fa6b272582fedc6252a9c2143e9b5c510a52bd37d1b\\\n        8b03a88f3f3981ee8fb77b336a301bcf19ad8bffac5815954340690f235ebc2f763fd7beff9bee4393243bd467\\\n        8ba486780982c6ddb3e52a1a7c220d85f80cd263b3c39039c67d2105008bfc82b656b0a569fef2af16435a097a\\\n        066864fa7f39d24e36a9e4ee1e48fb7520d941e1c3d998a423d7323624de96e0862f19531652e4a4c7fd843112\\\n        48118ebe1f71610abf8bd41e859c8fd1087afdb24745cb6cd03af58f79904a9b1aa2e2dc5571c564cc3276b76f\\\n        a2003f5fc9e83956ab4c37848e2537ea2bbb81600b49441a0246fa5972e98b073069cc693abad679c6e5af259b\\\n        9a3418f9a2c0eb07f4bee61de65e0c4cac92dc7e814e9e710fef4117be6ceae26e295b32403823e99471d39256\\\n        22751aa788ff76be3ade62a196e546ab1f24bb973e914cc5b9fdf6baa5b5ae0ec5513fb76772007bacb0b1d514\\\n        f9045622b309cf750c162aaf417ff93536fc9a21c95909021f3f92c404825a0615e27cc5b5c309636ee7d0ade9\\\n        e7974b4a7c5dbb74ac75f2adc6929afe15b9891b7d9217c366f601132c9e5e7f7a2d05a80035e9cebc097affd5\\\n        0a7e73a3fc24a15efc02146f08b666cb29b7855e06e9bff03beaf3d27b2d8c1986ee6b77d51078df5b8194951c\\\n        2f9cc61e37de23b068699ee0af89a23c09235b52b15c7003c8a4ebb021a6e1e30411487ce16815548f919f2288\\\n        209aca02dad50dae05cf6669f49c173ec9e988c850db3ab92226478c1a6349300af076f75432e01bcebf00fc94\\\n        e171e049a257068125002014c8ec94daab6f5fc58d480f3ea11937610c5c72e1ba18d8440d6c4f583cb3453b9d\\\n        9f5effe308d79101081796211c92bf38dcd19353835166bb09cc2bd541798f16eaa8df0183d#10000\",\n        Greater,\n    );\n\n    let gauss_constant_f32 = Float::gauss_constant_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(gauss_constant_f32.to_string(), \"0.83462685\");\n    assert_eq!(to_hex_string(&gauss_constant_f32), \"0x0.d5aa1b#24\");\n    assert_eq!(gauss_constant_f32, f32::GAUSS_CONSTANT);\n\n    let gauss_constant_f64 = Float::gauss_constant_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(gauss_constant_f64.to_string(), \"0.8346268416740732\");\n    assert_eq!(to_hex_string(&gauss_constant_f64), \"0x0.d5aa1acd5a9a20#53\");\n    assert_eq!(gauss_constant_f64, f64::GAUSS_CONSTANT);\n}\n\n#[test]\n#[should_panic]\nfn gauss_constant_prec_fail_1() {\n    Float::gauss_constant_prec(0);\n}\n\nfn test_gauss_constant_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::gauss_constant_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_gauss_constant_prec_round() {\n    test_gauss_constant_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_gauss_constant_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_gauss_constant_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_gauss_constant_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_gauss_constant_prec_round_helper(1, Nearest, \"1.0\", \"0x1.0#1\", Greater);\n\n    test_gauss_constant_prec_round_helper(2, Floor, \"0.8\", \"0x0.c#2\", Less);\n    test_gauss_constant_prec_round_helper(2, Ceiling, \"1.0\", \"0x1.0#2\", Greater);\n    test_gauss_constant_prec_round_helper(2, Down, \"0.8\", \"0x0.c#2\", Less);\n    test_gauss_constant_prec_round_helper(2, Up, \"1.0\", \"0x1.0#2\", Greater);\n    test_gauss_constant_prec_round_helper(2, Nearest, \"0.8\", \"0x0.c#2\", Less);\n\n    test_gauss_constant_prec_round_helper(3, Floor, \"0.8\", \"0x0.c#3\", Less);\n    test_gauss_constant_prec_round_helper(3, Ceiling, \"0.9\", \"0x0.e#3\", Greater);\n    test_gauss_constant_prec_round_helper(3, Down, \"0.8\", \"0x0.c#3\", Less);\n    test_gauss_constant_prec_round_helper(3, Up, \"0.9\", \"0x0.e#3\", Greater);\n    test_gauss_constant_prec_round_helper(3, Nearest, \"0.9\", \"0x0.e#3\", Greater);\n\n    test_gauss_constant_prec_round_helper(4, Floor, \"0.81\", \"0x0.d#4\", Less);\n    test_gauss_constant_prec_round_helper(4, Ceiling, \"0.88\", \"0x0.e#4\", Greater);\n    test_gauss_constant_prec_round_helper(4, Down, \"0.81\", \"0x0.d#4\", Less);\n    test_gauss_constant_prec_round_helper(4, Up, \"0.88\", \"0x0.e#4\", Greater);\n    test_gauss_constant_prec_round_helper(4, Nearest, \"0.81\", \"0x0.d#4\", Less);\n\n    test_gauss_constant_prec_round_helper(5, Floor, \"0.81\", \"0x0.d0#5\", Less);\n    test_gauss_constant_prec_round_helper(5, Ceiling, \"0.84\", \"0x0.d8#5\", Greater);\n    test_gauss_constant_prec_round_helper(5, Down, \"0.81\", \"0x0.d0#5\", Less);\n    test_gauss_constant_prec_round_helper(5, Up, \"0.84\", \"0x0.d8#5\", Greater);\n    test_gauss_constant_prec_round_helper(5, Nearest, \"0.84\", \"0x0.d8#5\", Greater);\n\n    test_gauss_constant_prec_round_helper(6, Floor, \"0.83\", \"0x0.d4#6\", Less);\n    test_gauss_constant_prec_round_helper(6, Ceiling, \"0.84\", \"0x0.d8#6\", Greater);\n    test_gauss_constant_prec_round_helper(6, Down, \"0.83\", \"0x0.d4#6\", Less);\n    test_gauss_constant_prec_round_helper(6, Up, \"0.84\", \"0x0.d8#6\", Greater);\n    test_gauss_constant_prec_round_helper(6, Nearest, \"0.83\", \"0x0.d4#6\", Less);\n\n    test_gauss_constant_prec_round_helper(7, Floor, \"0.83\", \"0x0.d4#7\", Less);\n    test_gauss_constant_prec_round_helper(7, Ceiling, \"0.836\", \"0x0.d6#7\", Greater);\n    test_gauss_constant_prec_round_helper(7, Down, \"0.83\", \"0x0.d4#7\", Less);\n    test_gauss_constant_prec_round_helper(7, Up, \"0.836\", \"0x0.d6#7\", Greater);\n    test_gauss_constant_prec_round_helper(7, Nearest, \"0.836\", \"0x0.d6#7\", Greater);\n\n    test_gauss_constant_prec_round_helper(8, Floor, \"0.832\", \"0x0.d5#8\", Less);\n    test_gauss_constant_prec_round_helper(8, Ceiling, \"0.836\", \"0x0.d6#8\", Greater);\n    test_gauss_constant_prec_round_helper(8, Down, \"0.832\", \"0x0.d5#8\", Less);\n    test_gauss_constant_prec_round_helper(8, Up, \"0.836\", \"0x0.d6#8\", Greater);\n    test_gauss_constant_prec_round_helper(8, Nearest, \"0.836\", \"0x0.d6#8\", Greater);\n\n    test_gauss_constant_prec_round_helper(9, Floor, \"0.834\", \"0x0.d58#9\", Less);\n    test_gauss_constant_prec_round_helper(9, Ceiling, \"0.836\", \"0x0.d60#9\", Greater);\n    test_gauss_constant_prec_round_helper(9, Down, \"0.834\", \"0x0.d58#9\", Less);\n    test_gauss_constant_prec_round_helper(9, Up, \"0.836\", \"0x0.d60#9\", Greater);\n    test_gauss_constant_prec_round_helper(9, Nearest, \"0.834\", \"0x0.d58#9\", Less);\n\n    test_gauss_constant_prec_round_helper(10, Floor, \"0.834\", \"0x0.d58#10\", Less);\n    test_gauss_constant_prec_round_helper(10, Ceiling, \"0.835\", \"0x0.d5c#10\", Greater);\n    test_gauss_constant_prec_round_helper(10, Down, \"0.834\", \"0x0.d58#10\", Less);\n    test_gauss_constant_prec_round_helper(10, Up, \"0.835\", \"0x0.d5c#10\", Greater);\n    test_gauss_constant_prec_round_helper(10, Nearest, \"0.835\", \"0x0.d5c#10\", Greater);\n\n    test_gauss_constant_prec_round_helper(\n        100,\n        Floor,\n        \"0.834626841674073186281429732799\",\n        \"0x0.d5aa1acd5a9a1f6b126ed4160#100\",\n        Less,\n    );\n    test_gauss_constant_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.8346268416740731862814297328\",\n        \"0x0.d5aa1acd5a9a1f6b126ed4161#100\",\n        Greater,\n    );\n    test_gauss_constant_prec_round_helper(\n        100,\n        Down,\n        \"0.834626841674073186281429732799\",\n        \"0x0.d5aa1acd5a9a1f6b126ed4160#100\",\n        Less,\n    );\n    test_gauss_constant_prec_round_helper(\n        100,\n        Up,\n        \"0.8346268416740731862814297328\",\n        \"0x0.d5aa1acd5a9a1f6b126ed4161#100\",\n        Greater,\n    );\n    test_gauss_constant_prec_round_helper(\n        100,\n        Nearest,\n        \"0.834626841674073186281429732799\",\n        \"0x0.d5aa1acd5a9a1f6b126ed4160#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn gauss_constant_prec_round_fail_1() {\n    Float::gauss_constant_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn gauss_constant_prec_round_fail_2() {\n    Float::gauss_constant_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn gauss_constant_prec_round_fail_3() {\n    Float::gauss_constant_prec_round(1000, Exact);\n}\n\n#[test]\nfn gauss_constant_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (gauss_constant, o) = Float::gauss_constant_prec(prec);\n        assert!(gauss_constant.is_valid());\n        assert_eq!(gauss_constant.get_prec(), Some(prec));\n        assert_eq!(\n            gauss_constant.get_exponent(),\n            Some(if prec == 1 { 1 } else { 0 })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (gauss_constant_alt, o_alt) = Float::gauss_constant_prec_round(prec, Ceiling);\n            let mut next_upper = gauss_constant.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(gauss_constant_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !gauss_constant.is_power_of_2() {\n            let (gauss_constant_alt, o_alt) = Float::gauss_constant_prec_round(prec, Floor);\n            let mut next_lower = gauss_constant.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(gauss_constant_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (gauss_constant_alt, o_alt) = Float::gauss_constant_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&gauss_constant_alt),\n            ComparableFloatRef(&gauss_constant)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn gauss_constant_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (gauss_constant, o) = Float::gauss_constant_prec_round(prec, rm);\n        assert!(gauss_constant.is_valid());\n        assert_eq!(gauss_constant.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 1,\n            _ => 0,\n        };\n        assert_eq!(gauss_constant.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (gauss_constant_alt, o_alt) = Float::gauss_constant_prec_round(prec, Ceiling);\n            let mut next_upper = gauss_constant.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(gauss_constant_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !gauss_constant.is_power_of_2() {\n            let (gauss_constant_alt, o_alt) = Float::gauss_constant_prec_round(prec, Floor);\n            let mut next_lower = gauss_constant.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(gauss_constant_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::gauss_constant_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::gauss_constant_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/lemniscate_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::LemniscateConstant;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::lemniscate_constant::*;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_lemniscate_constant_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::lemniscate_constant_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = lemniscate_constant_prec_round_simple(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_lemniscate_constant_prec() {\n    test_lemniscate_constant_prec_helper(1, \"2.0\", \"0x2.0#1\", Less);\n    test_lemniscate_constant_prec_helper(2, \"3.0\", \"0x3.0#2\", Greater);\n    test_lemniscate_constant_prec_helper(3, \"2.5\", \"0x2.8#3\", Less);\n    test_lemniscate_constant_prec_helper(4, \"2.5\", \"0x2.8#4\", Less);\n    test_lemniscate_constant_prec_helper(5, \"2.6\", \"0x2.a#5\", Greater);\n    test_lemniscate_constant_prec_helper(6, \"2.62\", \"0x2.a#6\", Greater);\n    test_lemniscate_constant_prec_helper(7, \"2.62\", \"0x2.a0#7\", Greater);\n    test_lemniscate_constant_prec_helper(8, \"2.62\", \"0x2.a0#8\", Greater);\n    test_lemniscate_constant_prec_helper(9, \"2.625\", \"0x2.a0#9\", Greater);\n    test_lemniscate_constant_prec_helper(10, \"2.621\", \"0x2.9f#10\", Less);\n    test_lemniscate_constant_prec_helper(\n        100,\n        \"2.62205755429211981046483958989\",\n        \"0x2.9f3f29f3ea160dcf30eed7580#100\",\n        Less,\n    );\n    test_lemniscate_constant_prec_helper(\n        1000,\n        \"2.622057554292119810464839589891119413682754951431623162816821703800790587070414250230295\\\n        532961429093446135752671783218055608956901393935694701119434775235840422641497164906951936\\\n        899979932146072383121390810206221897429600856554539772305369549710288888325526487021329012\\\n        0975408331285685117297522292142966\",\n        \"0x2.9f3f29f3ea160dcf30eed75811b3c2f6d7172e48e43735af6b46c7af912d10e70017b44f6b10c20e6755e\\\n        81d92714d02ce28c9bbc0133ee370554ff5165f91aae132697ee64025bd01da354b8da35c1ca7832784a9965a0\\\n        c14398dc6fb92c5154e84157fa74aec0c44dfda20393fe782139b91b083fc85b1441ac82ad0#1000\",\n        Less,\n    );\n    test_lemniscate_constant_prec_helper(\n        10000,\n        \"2.622057554292119810464839589891119413682754951431623162816821703800790587070414250230295\\\n        532961429093446135752671783218055608956901393935694701119434775235840422641497164906951936\\\n        899979932146072383121390810206221897429600856554539772305369549710288888325526487021329012\\\n        097540833128568511729752229214296692430513968456455539432881415381331735108409226312132476\\\n        667633414509988603429421479224714487963907872564189521811027252516629964333384660679333635\\\n        093139808526237739409142626489848034804572541477046175421256342129955863129980224054609012\\\n        091499139897885645312480971101149665075060542093841723886900040274785389625483030580303946\\\n        324783219558325522973037191341918983592199914229536672569106861130938134980725552913015093\\\n        730332611087045814240765781886530766932476940761626721636249549480066760961388122322476925\\\n        591018705775743614648912879832686662030731373313562107612636379245785801781364105361306093\\\n        563472025022592312041202668270457723044608378953311357002940577442011806826257962983642671\\\n        092116198597298460755620828986569905715850585969733482498916979139661512076092673544847646\\\n        574626457769227556279085403488486299631791644074183032890572244174725314174445875123605657\\\n        139575363059725889282920861276365948025081705994780553810740323485381958708594579092174018\\\n        668477776969917734589963845805236673259560797055893212070139745771343010329460928029259114\\\n        281387388493544876912962400450451515749437725842216728515086072450581997727624380905274299\\\n        795351792018910957399605991273238903791116648437850911342937302632750071201301892980462180\\\n        428765649352238455214584305436298513850108631443435366399087818335289725057991586901139218\\\n        731261235482234682842959686621093089202655982151707327457126997244722591053622446697155585\\\n        523244205556551378985416014007281696154803764953004010586969769798728528544268595900874210\\\n        615976672889856196920646383327838417979669834893047455706005883206470466312323973364023277\\\n        796282492416941692491715034784541889387264509022763917623129944975660994166520078299733003\\\n        514497680346375538989464128500976201473352363956758954456057294389704660492210734900562422\\\n        060698049424698227273322272545152596399605261093570054581266506375784426587891009902248739\\\n        074851475335571668858945648604938903484149255083213830273958314785697922542663980952768924\\\n        339176421212403458061264319698865734211695958669092740058571756733772940260843870335168806\\\n        554093029896061847165969615210879733103894090573687904026615017392722182113253614379462748\\\n        410822722172415291174195706198674247582236389438854755351468899984473586928701255109272056\\\n        897315524697141375285481897383672357481534008060452330772039824202794480385098376136184356\\\n        879523471104690616561399028704017447178011844138034863898042145300962033247526574931328554\\\n        943387329065193422836581434847505032876745487649716644131511122812960672857587623568606457\\\n        132192794260190549677753958426178724331815736858905292945584979487114184373394133441249801\\\n        511678382932856516301228572505799118357873322849053225342038152978949939297661715113526220\\\n        8853282485258038240456468938147672657060189\",\n        \"0x2.9f3f29f3ea160dcf30eed75811b3c2f6d7172e48e43735af6b46c7af912d10e70017b44f6b10c20e6755e\\\n        81d92714d02ce28c9bbc0133ee370554ff5165f91aae132697ee64025bd01da354b8da35c1ca7832784a9965a0\\\n        c14398dc6fb92c5154e84157fa74aec0c44dfda20393fe782139b91b083fc85b1441ac82ad11541d32c7d05a72\\\n        3a95453cb09b15964d9b9e2bc05b3b7d29877c9a4b44216c4a2dda21dc33dd433090e44a06c3c1f481e075fd94\\\n        21ecc82d065fe31873cf84d0a6f66b94a68ca0edf58ab7118c279921d8f0b918ce81b4b6f957b508ec630ae014\\\n        066fb52b9825f76ccb6bc78c38c4492c0220c805403b6d28ebc28cff3c6b354eed64d86b282b6c5045ee4a48d2\\\n        39d222d69aa29ebba7e23d6ca59093bf052e76d6da8e7567ecbf817d2c1225ec79a3ca30176f7278fe02993af2\\\n        4f6729cf38a835f6546826d4845bb03bd57075dcb0902f9a09225354aa620358678e3510c30ed57970038d983e\\\n        b399d694188f2bd2a3cdd0195478f25df26f7f6d941552566f3efbb6f49cd4a9ffe631175ae021fa25809ab898\\\n        26df98a555338ac2029fc9ee45c5099d7284ef412f878425791628a818f7c826883b3ad7198d30c5f83a7738d7\\\n        1de0a3310c7cc5e889941fc475a5d9145798b2ecc4c57c6ab448267648a64942b2ae1b4a2b8f2735acdc0e72e6\\\n        826ee5b166c4c05d874f61c2a55ce9d1ebafc1c0375a43b0df0189b326566e625334856a6d43bc6256ac22f546\\\n        6d302d1d2242310bf0118124c9cb1bcc69be3a951b4f9f86c419494311bfc1fb0f2d6dd5768703d859fcfe1b4d\\\n        6b959e9ee6767cf7a152f34269e166cf850fc2d0278f0ba25bf64ed7cfe799d7a324cf238084d10ec8dc667d8f\\\n        92403b94640db67e3c63473f683fe6a3881b3997069fe1ad958a5433e7720102a273512d2b28d4a46699a3cb1f\\\n        42532f37658965357b95e149d90c83c02453c15517ecbb80c88df5b1a8e0ee86c0d4d082758058cb2664c62dae\\\n        f9ed89bd69c0d6f66381e3f93d7474e266a2bf1dc97c19464cbbd0793bd74674dc03e28a2ab5e1d50da6fc8b09\\\n        76730ce30603718f3072e1081edfb2dbe178162099ea48bf81c3341f1421f77008833a0b30ad6cdad21d2beb60\\\n        e79f8c891d70c88d7fcf6dfca38032e48280e8d3f40c5a0ab27dc76c32113d090c4686e0c5af335ee8e02bf167\\\n        565f64587b00b6eeb163f782ee0f30a13c6386b94732d3d795261b00f328f20061e7dd29e5ba1649815e8b86f8\\\n        749cf82d7ae468a30fc75a44213e70e017de72b2f73bd8698855f4d0d0806980ddd6d3a2d5257165fd1f73ea29\\\n        d2c6b232528aa4f54a711deccfbe0a41aad688b4c077d9d7bce4d8d4bf0a22d61a55d4f97f147c6f45f5d03023\\\n        4fd8ba98f9dec471598ea5fa3f0f35ef0e006bcbfa54050e6e4ca5d8734c24cda360ea64146d27c81d0e05d61d\\\n        577cf76b8b4ed519262488699e7a5a0838dbc88c3be2fc7c488d855b0f9ccfe111091777beb081c1ea5ee0853b\\\n        3ae2d4ea046a292e33e9ab99d3734355a7bb39462571a408ad450e83de0ee52fdb5aa8d38706117b2c87b03ab5\\\n        868eff0e9c6c3ab4afce9ddca3db9b0c66305ca71fd6a7842fdb2dc86990eb4bc0b7fde91f503e8788a772ab33\\\n        41473c80c1503eeca8c1534d984be33f86f904239944078141f06fe1dee3e1eaae3cb2f1984df30e54f0dc6c3c\\\n        ac27892c1ee783c1d26589418270060cdb2077a890b369215342641df45d1210b1cc551b780#10000\",\n        Greater,\n    );\n\n    let lemniscate_constant_f32 =\n        Float::lemniscate_constant_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(lemniscate_constant_f32.to_string(), \"2.6220574\");\n    assert_eq!(to_hex_string(&lemniscate_constant_f32), \"0x2.9f3f28#24\");\n    assert_eq!(lemniscate_constant_f32, f32::LEMNISCATE_CONSTANT);\n\n    let lemniscate_constant_f64 =\n        Float::lemniscate_constant_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(lemniscate_constant_f64.to_string(), \"2.6220575542921196\");\n    assert_eq!(\n        to_hex_string(&lemniscate_constant_f64),\n        \"0x2.9f3f29f3ea160#53\"\n    );\n    assert_eq!(lemniscate_constant_f64, f64::LEMNISCATE_CONSTANT);\n}\n\n#[test]\n#[should_panic]\nfn lemniscate_constant_prec_fail_1() {\n    Float::lemniscate_constant_prec(0);\n}\n\nfn test_lemniscate_constant_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::lemniscate_constant_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = lemniscate_constant_prec_round_simple(prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_lemniscate_constant_prec_round() {\n    test_lemniscate_constant_prec_round_helper(1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test_lemniscate_constant_prec_round_helper(1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test_lemniscate_constant_prec_round_helper(1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test_lemniscate_constant_prec_round_helper(1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test_lemniscate_constant_prec_round_helper(1, Nearest, \"2.0\", \"0x2.0#1\", Less);\n\n    test_lemniscate_constant_prec_round_helper(2, Floor, \"2.0\", \"0x2.0#2\", Less);\n    test_lemniscate_constant_prec_round_helper(2, Ceiling, \"3.0\", \"0x3.0#2\", Greater);\n    test_lemniscate_constant_prec_round_helper(2, Down, \"2.0\", \"0x2.0#2\", Less);\n    test_lemniscate_constant_prec_round_helper(2, Up, \"3.0\", \"0x3.0#2\", Greater);\n    test_lemniscate_constant_prec_round_helper(2, Nearest, \"3.0\", \"0x3.0#2\", Greater);\n\n    test_lemniscate_constant_prec_round_helper(3, Floor, \"2.5\", \"0x2.8#3\", Less);\n    test_lemniscate_constant_prec_round_helper(3, Ceiling, \"3.0\", \"0x3.0#3\", Greater);\n    test_lemniscate_constant_prec_round_helper(3, Down, \"2.5\", \"0x2.8#3\", Less);\n    test_lemniscate_constant_prec_round_helper(3, Up, \"3.0\", \"0x3.0#3\", Greater);\n    test_lemniscate_constant_prec_round_helper(3, Nearest, \"2.5\", \"0x2.8#3\", Less);\n\n    test_lemniscate_constant_prec_round_helper(4, Floor, \"2.5\", \"0x2.8#4\", Less);\n    test_lemniscate_constant_prec_round_helper(4, Ceiling, \"2.8\", \"0x2.c#4\", Greater);\n    test_lemniscate_constant_prec_round_helper(4, Down, \"2.5\", \"0x2.8#4\", Less);\n    test_lemniscate_constant_prec_round_helper(4, Up, \"2.8\", \"0x2.c#4\", Greater);\n    test_lemniscate_constant_prec_round_helper(4, Nearest, \"2.5\", \"0x2.8#4\", Less);\n\n    test_lemniscate_constant_prec_round_helper(5, Floor, \"2.5\", \"0x2.8#5\", Less);\n    test_lemniscate_constant_prec_round_helper(5, Ceiling, \"2.6\", \"0x2.a#5\", Greater);\n    test_lemniscate_constant_prec_round_helper(5, Down, \"2.5\", \"0x2.8#5\", Less);\n    test_lemniscate_constant_prec_round_helper(5, Up, \"2.6\", \"0x2.a#5\", Greater);\n    test_lemniscate_constant_prec_round_helper(5, Nearest, \"2.6\", \"0x2.a#5\", Greater);\n\n    test_lemniscate_constant_prec_round_helper(6, Floor, \"2.56\", \"0x2.9#6\", Less);\n    test_lemniscate_constant_prec_round_helper(6, Ceiling, \"2.62\", \"0x2.a#6\", Greater);\n    test_lemniscate_constant_prec_round_helper(6, Down, \"2.56\", \"0x2.9#6\", Less);\n    test_lemniscate_constant_prec_round_helper(6, Up, \"2.62\", \"0x2.a#6\", Greater);\n    test_lemniscate_constant_prec_round_helper(6, Nearest, \"2.62\", \"0x2.a#6\", Greater);\n\n    test_lemniscate_constant_prec_round_helper(7, Floor, \"2.59\", \"0x2.98#7\", Less);\n    test_lemniscate_constant_prec_round_helper(7, Ceiling, \"2.62\", \"0x2.a0#7\", Greater);\n    test_lemniscate_constant_prec_round_helper(7, Down, \"2.59\", \"0x2.98#7\", Less);\n    test_lemniscate_constant_prec_round_helper(7, Up, \"2.62\", \"0x2.a0#7\", Greater);\n    test_lemniscate_constant_prec_round_helper(7, Nearest, \"2.62\", \"0x2.a0#7\", Greater);\n\n    test_lemniscate_constant_prec_round_helper(8, Floor, \"2.61\", \"0x2.9c#8\", Less);\n    test_lemniscate_constant_prec_round_helper(8, Ceiling, \"2.62\", \"0x2.a0#8\", Greater);\n    test_lemniscate_constant_prec_round_helper(8, Down, \"2.61\", \"0x2.9c#8\", Less);\n    test_lemniscate_constant_prec_round_helper(8, Up, \"2.62\", \"0x2.a0#8\", Greater);\n    test_lemniscate_constant_prec_round_helper(8, Nearest, \"2.62\", \"0x2.a0#8\", Greater);\n\n    test_lemniscate_constant_prec_round_helper(9, Floor, \"2.617\", \"0x2.9e#9\", Less);\n    test_lemniscate_constant_prec_round_helper(9, Ceiling, \"2.625\", \"0x2.a0#9\", Greater);\n    test_lemniscate_constant_prec_round_helper(9, Down, \"2.617\", \"0x2.9e#9\", Less);\n    test_lemniscate_constant_prec_round_helper(9, Up, \"2.625\", \"0x2.a0#9\", Greater);\n    test_lemniscate_constant_prec_round_helper(9, Nearest, \"2.625\", \"0x2.a0#9\", Greater);\n\n    test_lemniscate_constant_prec_round_helper(10, Floor, \"2.621\", \"0x2.9f#10\", Less);\n    test_lemniscate_constant_prec_round_helper(10, Ceiling, \"2.625\", \"0x2.a0#10\", Greater);\n    test_lemniscate_constant_prec_round_helper(10, Down, \"2.621\", \"0x2.9f#10\", Less);\n    test_lemniscate_constant_prec_round_helper(10, Up, \"2.625\", \"0x2.a0#10\", Greater);\n    test_lemniscate_constant_prec_round_helper(10, Nearest, \"2.621\", \"0x2.9f#10\", Less);\n\n    test_lemniscate_constant_prec_round_helper(\n        100,\n        Floor,\n        \"2.62205755429211981046483958989\",\n        \"0x2.9f3f29f3ea160dcf30eed7580#100\",\n        Less,\n    );\n    test_lemniscate_constant_prec_round_helper(\n        100,\n        Ceiling,\n        \"2.622057554292119810464839589893\",\n        \"0x2.9f3f29f3ea160dcf30eed7584#100\",\n        Greater,\n    );\n    test_lemniscate_constant_prec_round_helper(\n        100,\n        Down,\n        \"2.62205755429211981046483958989\",\n        \"0x2.9f3f29f3ea160dcf30eed7580#100\",\n        Less,\n    );\n    test_lemniscate_constant_prec_round_helper(\n        100,\n        Up,\n        \"2.622057554292119810464839589893\",\n        \"0x2.9f3f29f3ea160dcf30eed7584#100\",\n        Greater,\n    );\n    test_lemniscate_constant_prec_round_helper(\n        100,\n        Nearest,\n        \"2.62205755429211981046483958989\",\n        \"0x2.9f3f29f3ea160dcf30eed7580#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn lemniscate_constant_prec_round_fail_1() {\n    Float::lemniscate_constant_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn lemniscate_constant_prec_round_fail_2() {\n    Float::lemniscate_constant_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn lemniscate_constant_prec_round_fail_3() {\n    Float::lemniscate_constant_prec_round(1000, Exact);\n}\n\n#[test]\nfn lemniscate_constant_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (lemniscate_constant, o) = Float::lemniscate_constant_prec(prec);\n        assert!(lemniscate_constant.is_valid());\n        assert_eq!(lemniscate_constant.get_prec(), Some(prec));\n        assert_eq!(lemniscate_constant.get_exponent(), Some(2));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (lemniscate_constant_alt, o_alt) =\n                Float::lemniscate_constant_prec_round(prec, Ceiling);\n            let mut next_upper = lemniscate_constant.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(lemniscate_constant_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !lemniscate_constant.is_power_of_2() {\n            let (lemniscate_constant_alt, o_alt) =\n                Float::lemniscate_constant_prec_round(prec, Floor);\n            let mut next_lower = lemniscate_constant.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(lemniscate_constant_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (lemniscate_constant_alt, o_alt) = Float::lemniscate_constant_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&lemniscate_constant_alt),\n            ComparableFloatRef(&lemniscate_constant)\n        );\n        assert_eq!(o_alt, o);\n\n        let (lemniscate_constant_alt, o_alt) = lemniscate_constant_prec_round_simple(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&lemniscate_constant_alt),\n            ComparableFloatRef(&lemniscate_constant)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn lemniscate_constant_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (lemniscate_constant, o) = Float::lemniscate_constant_prec_round(prec, rm);\n        assert!(lemniscate_constant.is_valid());\n        assert_eq!(lemniscate_constant.get_prec(), Some(prec));\n        assert_eq!(\n            lemniscate_constant.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                3\n            } else {\n                2\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (lemniscate_constant_alt, o_alt) =\n                Float::lemniscate_constant_prec_round(prec, Ceiling);\n            let mut next_upper = lemniscate_constant.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(lemniscate_constant_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !lemniscate_constant.is_power_of_2() {\n            let (lemniscate_constant_alt, o_alt) =\n                Float::lemniscate_constant_prec_round(prec, Floor);\n            let mut next_lower = lemniscate_constant.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(lemniscate_constant_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n\n        let (lemniscate_constant_alt, o_alt) = lemniscate_constant_prec_round_simple(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&lemniscate_constant_alt),\n            ComparableFloatRef(&lemniscate_constant)\n        );\n        assert_eq!(o_alt, o);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::lemniscate_constant_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::lemniscate_constant_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/ln_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::{Ln2, Two};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{\n    rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::constants::ln_2::rug_ln_2_prec_round;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_ln_2_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::ln_2_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = Float::ln_prec(Float::TWO, prec);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n\n    let (rug_x, rug_o) =\n        rug_ln_2_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_x)),\n        ComparableFloatRef(&x)\n    );\n    assert_eq!(rug_o, o);\n}\n\n#[test]\npub fn test_ln_2_prec() {\n    // - in ln_2_prec_round\n    // - in sum\n    // - n2 != n1 + 1 in sum\n    // - n2 == n1 + 1 in sum\n    // - n1 == 0 in sum\n    // - n1 != 0 in sum\n    // - !need_p first time in sum\n    // - v == 0 first time in sum\n    // - can't round in ln_2_prec_round\n    // - need_p first time in sum\n    // - v != 0 first time in sum\n    // - w < v first time in sum\n    // - need_p second time in sum\n    // - w < v second time in sum\n    // - v != 0 second time in sum\n    // - need_p third time in sum\n    // - w >= v first time in sum\n    // - v == 0 second time in sum\n    // - w >= v second time in sum\n    // - !need_p second time in sum\n    // - !need_p third time in sum\n    // - can round in ln_2_prec_round\n    test_ln_2_prec_helper(1, \"0.5\", \"0x0.8#1\", Less);\n    test_ln_2_prec_helper(2, \"0.8\", \"0x0.c#2\", Greater);\n    test_ln_2_prec_helper(3, \"0.8\", \"0x0.c#3\", Greater);\n    test_ln_2_prec_helper(4, \"0.7\", \"0x0.b#4\", Less);\n    test_ln_2_prec_helper(5, \"0.69\", \"0x0.b0#5\", Less);\n    test_ln_2_prec_helper(6, \"0.69\", \"0x0.b0#6\", Less);\n    test_ln_2_prec_helper(7, \"0.695\", \"0x0.b2#7\", Greater);\n    test_ln_2_prec_helper(8, \"0.691\", \"0x0.b1#8\", Less);\n    test_ln_2_prec_helper(9, \"0.693\", \"0x0.b18#9\", Greater);\n    test_ln_2_prec_helper(10, \"0.693\", \"0x0.b18#10\", Greater);\n    test_ln_2_prec_helper(\n        100,\n        \"0.693147180559945309417232121458\",\n        \"0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Less,\n    );\n    test_ln_2_prec_helper(\n        1000,\n        \"0.693147180559945309417232121458176568075500134360255254120680009493393621969694715605863\\\n        326996418687542001481020570685733685520235758130557032670751635075961930727570828371435190\\\n        307038623891673471123350115364497955239120475172681574932065155524734139525882950453007095\\\n        3263666426541042391578149520437404\",\n        \"0x0.b17217f7d1cf79abc9e3b39803f2f6af40f343267298b62d8a0d175b8baafa2be7b876206debac9855955\\\n        2fb4afa1b10ed2eae35c138214427573b291169b8253e96ca16224ae8c51acbda11317c387eb9ea9bc3b136603\\\n        b256fa0ec7657f74b72ce87b19d6548caf5dfa6bd38303248655fa1872f20e3a2da2d97c50f#1000\",\n        Less,\n    );\n    test_ln_2_prec_helper(\n        10000,\n        \"0.693147180559945309417232121458176568075500134360255254120680009493393621969694715605863\\\n        326996418687542001481020570685733685520235758130557032670751635075961930727570828371435190\\\n        307038623891673471123350115364497955239120475172681574932065155524734139525882950453007095\\\n        326366642654104239157814952043740430385500801944170641671518644712839968171784546957026271\\\n        631064546150257207402481637773389638550695260668341137273873722928956493547025762652098859\\\n        693201965058554764703306793654432547632744951250406069438147104689946506220167720424524529\\\n        612687946546193165174681392672504103802546259656869144192871608293803172714367782654877566\\\n        485085674077648451464439940461422603193096735402574446070308096085047486638523138181676751\\\n        438667476647890881437141985494231519973548803751658612753529166100071053558249879414729509\\\n        293113897155998205654392871700072180857610252368892132449713893203784393530887748259701715\\\n        591070882368362758984258918535302436342143670611892367891923723146723217205340164925687274\\\n        778234453534764811494186423867767744060695626573796008670762571991847340226514628379048830\\\n        620330611446300737194890027436439650025809365194430411911506080948793067865158870900605203\\\n        468429736193841289652556539686022194122924207574321757489097706752687115817051137009158942\\\n        665478595964890653058460258668382940022833005382074005677053046787001841624044188332327983\\\n        863490015631218895606505531512721993983320307514084260914790012651682434438935724727882054\\\n        862715527418772430024897945401961872339808608316648114909306675193393128904316413706813977\\\n        764981769748689038877899912965036192707108892641052309247839173735012298424204995689359922\\\n        066022046549415106139187885744245577510206837030866619480896412186807790208181588580001688\\\n        115973056186676199187395200766719214592236720602539595436541655311295175989940056000366513\\\n        567569051245926825743946483168332624901803824240824231452306140963805700702551387702681785\\\n        163069025513703234053802145019015374029509942262995779647427138157363801729873940704242179\\\n        972266962979939312706935747240493386530879758721699645129446491883771156701678598804981838\\\n        896784134938314014073166472765327635919233511233389338709513209059272185471328975470797891\\\n        384445466676192702885533423429899321803769154973340267546758873236778342916191810430116091\\\n        695265547859732891763545556742863877463987101912431754255888301206779210280341206879759143\\\n        081283307230300883494705792496591005860012341561757413272465943068435465211135021544341539\\\n        955381856522750221424566440006276183303206472725721975152908278568421320795988638967277119\\\n        552218819046603957009774706512619505278932296088931405625433442552392062030343941777357945\\\n        592125901992559114844024239012554259003129537051922061506434583787873002035414421785758013\\\n        236451660709914383145004985896688577222148652882169418127048860758972203216663128378329156\\\n        763074987298574638928269373509840778049395004933998762647550703162216139034845299424917248\\\n        373406136622638349368111684167056925214751383930638455371862687797328895558871634429756244\\\n        75539236636948887782389017498102735655240503\",\n        \"0x0.b17217f7d1cf79abc9e3b39803f2f6af40f343267298b62d8a0d175b8baafa2be7b876206debac9855955\\\n        2fb4afa1b10ed2eae35c138214427573b291169b8253e96ca16224ae8c51acbda11317c387eb9ea9bc3b136603\\\n        b256fa0ec7657f74b72ce87b19d6548caf5dfa6bd38303248655fa1872f20e3a2da2d97c50f3fd5c607f4ca11f\\\n        b5bfb90610d30f88fe551a2ee569d6dfc1efa157d2e23de1400b39617460775db8990e5c943e732b479cd33ccc\\\n        c4e659393514c4c1a1e0bd1d6095d25669b333564a3376a9c7f8a5e148e82074db6015cfe7aa30c480a5417350\\\n        d2c955d5179b1e17b9dae313cdb6c606cb1078f735d1b2db31b5f50b5185064c18b4d162db3b365853d7598a19\\\n        51ae273ee5570b6c68f96983496d4e6d330af889b44a02554731cdc8ea17293d1228a4ef98d6f5177fbcf07552\\\n        68a5c1f9538b98261affd446b1ca3cf5e9222b88c66d3c5422183edc99421090bbb16faf3d949f236e02b20cee\\\n        886b905c128d53d0bd2f9621363196af503020060e49908391a0c57339ba2beba7d052ac5b61cc4e9207cef2f0\\\n        ce2d7373958d7622658901e646a95184460dc4e7487156e0c292413d5e361c1696dd24aaebd473826fda0c238b\\\n        90ab111bbbd67c724972cd18bfbbd9d426c472096e76115c05f6f7cebac9f45aececb72f19c38339d8f6826250\\\n        dea891ef07afff3a892374e175eb4afc8daadd885db6ab03a49bd0dc0b1b31d8a0e23fac5e5767df95884e0642\\\n        5a41526fac51c3ea8449fe8f70edd062b1a63a6c4c60c52ab33161e238438897a39ce78b63c9f364f5b8aef22e\\\n        c2fee6e0850eca42d06fb0c75df5497e00c554b03d7d2874a000ca8f58d94f0341cbe2ec92156c9f949db4a931\\\n        6f281501e53daec3f64f1b783154c60320e2ff79333ce3573facc5fdcf11785903155bbd90f023b220224fcd84\\\n        71bf4f445f0a88a14f0cd976ea354bb20cdb5ccb3db239288d586554e2a0e8a6fe51a8cfaa72ef2ad8a43dc421\\\n        2b210b779dfe49d7307cc846532e4b9694edad162af053b1751f3a3d091f65665815412b5e8c202461069ac14b\\\n        958784934b8d6cce1daa50537011aa4fb42b9a3def41bda1f85ef6fdbf2f2d89d2a4b1835278fd9405789f4568\\\n        12b552879a6168695c12963b0ff01eaab73e5b5c1585318e7624f14a51a4a026b6808292057fd99b66dc085a98\\\n        ac8d8caf9eeeea98a2400cac95f260fd10036f9f91096ac3195220a1a356b2a73b7eaadaf6d605871ef7afb80b\\\n        c423433562e94b12dfab414451579df59eae0517070624012a82962c59cab347f8304d889659e5a9139db14efc\\\n        c30852be3e8fc99f14d1d822dd6e2f76797e30219c8aa9ce8848a886eb3c87b7295988012e8314186edbaf8685\\\n        6ccd3c3b6ee94e62f110a6783d2aae89ccc3b76fc435a0ce134c2838fd571ec6c1366a992cbb9ac407ddb6c13a\\\n        4b8d1ecf7567eb0971cc90b5518569f144e67ebe9b42698fea79d89d5c5ed40ac5e3701d7d7725377cf0656907\\\n        fb9b1b16ea8911afbf1ae5a66203d62fd1e7093435b9c277736a70fa8601cf6868a055b2238677a2bfbbd843bf\\\n        a1873f0c446b01b2ae0e98e0e1527a900b1af5e75f87c7cd17af804d933d6f7e1b9e1903d71c7bba0281137609\\\n        0dd617335dfdd424f2b661cd85063034e341b06e211977b075a8b7808df43bd8eef1fd9678cc0b5e9f60a3eb81\\\n        747f87e5709468d78ebd2da0116e6b65aeb3be77ee236fdc33bc8e7df1ffc2e2288f8ca9aee#10000\",\n        Less,\n    );\n\n    let ln_2_f32 = Float::ln_2_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(ln_2_f32.to_string(), \"0.69314718\");\n    assert_eq!(to_hex_string(&ln_2_f32), \"0x0.b17218#24\");\n    assert_eq!(ln_2_f32, f32::LN_2);\n\n    let ln_2_f64 = Float::ln_2_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(ln_2_f64.to_string(), \"0.6931471805599453\");\n    assert_eq!(to_hex_string(&ln_2_f64), \"0x0.b17217f7d1cf78#53\");\n    assert_eq!(ln_2_f64, f64::LN_2);\n}\n\n#[test]\n#[should_panic]\nfn ln_2_prec_fail_1() {\n    Float::ln_2_prec(0);\n}\n\nfn test_ln_2_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::ln_2_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = Float::ln_prec_round(Float::TWO, prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_x, rug_o) = rug_ln_2_prec_round(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_x)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(rug_o, o);\n    }\n}\n\n#[test]\npub fn test_ln_2_prec_round() {\n    test_ln_2_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_ln_2_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_ln_2_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_ln_2_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_ln_2_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test_ln_2_prec_round_helper(2, Floor, \"0.5\", \"0x0.8#2\", Less);\n    test_ln_2_prec_round_helper(2, Ceiling, \"0.8\", \"0x0.c#2\", Greater);\n    test_ln_2_prec_round_helper(2, Down, \"0.5\", \"0x0.8#2\", Less);\n    test_ln_2_prec_round_helper(2, Up, \"0.8\", \"0x0.c#2\", Greater);\n    test_ln_2_prec_round_helper(2, Nearest, \"0.8\", \"0x0.c#2\", Greater);\n\n    test_ln_2_prec_round_helper(3, Floor, \"0.6\", \"0x0.a#3\", Less);\n    test_ln_2_prec_round_helper(3, Ceiling, \"0.8\", \"0x0.c#3\", Greater);\n    test_ln_2_prec_round_helper(3, Down, \"0.6\", \"0x0.a#3\", Less);\n    test_ln_2_prec_round_helper(3, Up, \"0.8\", \"0x0.c#3\", Greater);\n    test_ln_2_prec_round_helper(3, Nearest, \"0.8\", \"0x0.c#3\", Greater);\n\n    test_ln_2_prec_round_helper(4, Floor, \"0.7\", \"0x0.b#4\", Less);\n    test_ln_2_prec_round_helper(4, Ceiling, \"0.75\", \"0x0.c#4\", Greater);\n    test_ln_2_prec_round_helper(4, Down, \"0.7\", \"0x0.b#4\", Less);\n    test_ln_2_prec_round_helper(4, Up, \"0.75\", \"0x0.c#4\", Greater);\n    test_ln_2_prec_round_helper(4, Nearest, \"0.7\", \"0x0.b#4\", Less);\n\n    test_ln_2_prec_round_helper(5, Floor, \"0.69\", \"0x0.b0#5\", Less);\n    test_ln_2_prec_round_helper(5, Ceiling, \"0.72\", \"0x0.b8#5\", Greater);\n    test_ln_2_prec_round_helper(5, Down, \"0.69\", \"0x0.b0#5\", Less);\n    test_ln_2_prec_round_helper(5, Up, \"0.72\", \"0x0.b8#5\", Greater);\n    test_ln_2_prec_round_helper(5, Nearest, \"0.69\", \"0x0.b0#5\", Less);\n\n    test_ln_2_prec_round_helper(6, Floor, \"0.69\", \"0x0.b0#6\", Less);\n    test_ln_2_prec_round_helper(6, Ceiling, \"0.7\", \"0x0.b4#6\", Greater);\n    test_ln_2_prec_round_helper(6, Down, \"0.69\", \"0x0.b0#6\", Less);\n    test_ln_2_prec_round_helper(6, Up, \"0.7\", \"0x0.b4#6\", Greater);\n    test_ln_2_prec_round_helper(6, Nearest, \"0.69\", \"0x0.b0#6\", Less);\n\n    test_ln_2_prec_round_helper(7, Floor, \"0.69\", \"0x0.b0#7\", Less);\n    test_ln_2_prec_round_helper(7, Ceiling, \"0.695\", \"0x0.b2#7\", Greater);\n    test_ln_2_prec_round_helper(7, Down, \"0.69\", \"0x0.b0#7\", Less);\n    test_ln_2_prec_round_helper(7, Up, \"0.695\", \"0x0.b2#7\", Greater);\n    test_ln_2_prec_round_helper(7, Nearest, \"0.695\", \"0x0.b2#7\", Greater);\n\n    test_ln_2_prec_round_helper(8, Floor, \"0.691\", \"0x0.b1#8\", Less);\n    test_ln_2_prec_round_helper(8, Ceiling, \"0.695\", \"0x0.b2#8\", Greater);\n    test_ln_2_prec_round_helper(8, Down, \"0.691\", \"0x0.b1#8\", Less);\n    test_ln_2_prec_round_helper(8, Up, \"0.695\", \"0x0.b2#8\", Greater);\n    test_ln_2_prec_round_helper(8, Nearest, \"0.691\", \"0x0.b1#8\", Less);\n\n    test_ln_2_prec_round_helper(9, Floor, \"0.691\", \"0x0.b10#9\", Less);\n    test_ln_2_prec_round_helper(9, Ceiling, \"0.693\", \"0x0.b18#9\", Greater);\n    test_ln_2_prec_round_helper(9, Down, \"0.691\", \"0x0.b10#9\", Less);\n    test_ln_2_prec_round_helper(9, Up, \"0.693\", \"0x0.b18#9\", Greater);\n    test_ln_2_prec_round_helper(9, Nearest, \"0.693\", \"0x0.b18#9\", Greater);\n\n    test_ln_2_prec_round_helper(10, Floor, \"0.692\", \"0x0.b14#10\", Less);\n    test_ln_2_prec_round_helper(10, Ceiling, \"0.693\", \"0x0.b18#10\", Greater);\n    test_ln_2_prec_round_helper(10, Down, \"0.692\", \"0x0.b14#10\", Less);\n    test_ln_2_prec_round_helper(10, Up, \"0.693\", \"0x0.b18#10\", Greater);\n    test_ln_2_prec_round_helper(10, Nearest, \"0.693\", \"0x0.b18#10\", Greater);\n\n    test_ln_2_prec_round_helper(\n        100,\n        Floor,\n        \"0.693147180559945309417232121458\",\n        \"0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Less,\n    );\n    test_ln_2_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.693147180559945309417232121459\",\n        \"0x0.b17217f7d1cf79abc9e3b3981#100\",\n        Greater,\n    );\n    test_ln_2_prec_round_helper(\n        100,\n        Down,\n        \"0.693147180559945309417232121458\",\n        \"0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Less,\n    );\n    test_ln_2_prec_round_helper(\n        100,\n        Up,\n        \"0.693147180559945309417232121459\",\n        \"0x0.b17217f7d1cf79abc9e3b3981#100\",\n        Greater,\n    );\n    test_ln_2_prec_round_helper(\n        100,\n        Nearest,\n        \"0.693147180559945309417232121458\",\n        \"0x0.b17217f7d1cf79abc9e3b3980#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn ln_2_prec_round_fail_1() {\n    Float::ln_2_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn ln_2_prec_round_fail_2() {\n    Float::ln_2_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn ln_2_prec_round_fail_3() {\n    Float::ln_2_prec_round(1000, Exact);\n}\n\n#[test]\nfn ln_2_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (ln_2, o) = Float::ln_2_prec(prec);\n        assert!(ln_2.is_valid());\n        assert_eq!(ln_2.get_prec(), Some(prec));\n        assert_eq!(ln_2.get_exponent(), Some(0));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (ln_2_alt, o_alt) = Float::ln_2_prec_round(prec, Ceiling);\n            let mut next_upper = ln_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(ln_2_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !ln_2.is_power_of_2() {\n            let (ln_2_alt, o_alt) = Float::ln_2_prec_round(prec, Floor);\n            let mut next_lower = ln_2.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(ln_2_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (ln_2_alt, o_alt) = Float::ln_2_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&ln_2_alt), ComparableFloatRef(&ln_2));\n        assert_eq!(o_alt, o);\n\n        let (ln_2_alt, o_alt) = Float::ln_prec(Float::TWO, prec);\n        assert_eq!(ComparableFloatRef(&ln_2_alt), ComparableFloatRef(&ln_2));\n        assert_eq!(o_alt, o);\n\n        let (rug_ln_2, rug_o) =\n            rug_ln_2_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_ln_2)),\n            ComparableFloatRef(&ln_2)\n        );\n        assert_eq!(rug_o, o);\n    });\n}\n\n#[test]\nfn ln_2_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (ln_2, o) = Float::ln_2_prec_round(prec, rm);\n        assert!(ln_2.is_valid());\n        assert_eq!(ln_2.get_prec(), Some(prec));\n        assert_eq!(\n            ln_2.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                1\n            } else {\n                0\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (ln_2_alt, o_alt) = Float::ln_2_prec_round(prec, Ceiling);\n            let mut next_upper = ln_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(ln_2_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !ln_2.is_power_of_2() {\n            let (ln_2_alt, o_alt) = Float::ln_2_prec_round(prec, Floor);\n            let mut next_lower = ln_2.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(ln_2_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        let (ln_2_alt, o_alt) = Float::ln_prec_round(Float::TWO, prec, rm);\n        assert_eq!(ComparableFloatRef(&ln_2_alt), ComparableFloatRef(&ln_2));\n        assert_eq!(o_alt, o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_ln_2, rug_o) = rug_ln_2_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_ln_2)),\n                ComparableFloatRef(&ln_2)\n            );\n            assert_eq!(rug_o, o);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::ln_2_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::ln_2_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/log_2_e.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Log2E;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::log_2_e::log_2_e_prec_round_simple;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_log_2_e_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::log_2_e_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = log_2_e_prec_round_simple(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_log_2_e_prec() {\n    test_log_2_e_prec_helper(1, \"1.0\", \"0x1.0#1\", Less);\n    test_log_2_e_prec_helper(2, \"1.5\", \"0x1.8#2\", Greater);\n    test_log_2_e_prec_helper(3, \"1.5\", \"0x1.8#3\", Greater);\n    test_log_2_e_prec_helper(4, \"1.5\", \"0x1.8#4\", Greater);\n    test_log_2_e_prec_helper(5, \"1.44\", \"0x1.7#5\", Less);\n    test_log_2_e_prec_helper(6, \"1.44\", \"0x1.70#6\", Less);\n    test_log_2_e_prec_helper(7, \"1.44\", \"0x1.70#7\", Less);\n    test_log_2_e_prec_helper(8, \"1.445\", \"0x1.72#8\", Greater);\n    test_log_2_e_prec_helper(9, \"1.441\", \"0x1.71#9\", Less);\n    test_log_2_e_prec_helper(10, \"1.443\", \"0x1.718#10\", Greater);\n    test_log_2_e_prec_helper(\n        100,\n        \"1.442695040888963407359924681003\",\n        \"0x1.71547652b82fe1777d0ffda0e#100\",\n        Greater,\n    );\n    test_log_2_e_prec_helper(\n        1000,\n        \"1.442695040888963407359924681001892137426645954152985934135449406931109219181185079885526\\\n        622893506344496997518309652544255593101687168359642720662158223479336274537369884718493630\\\n        701387663532015533894318916664837643128615424047478422289497904795091530351338588054968865\\\n        8930969963680361105110756308441454\",\n        \"0x1.71547652b82fe1777d0ffda0d23a7d11d6aef551bad2b4b1164a2cd9a342648fbc3887eeaa2ed9ac49b25\\\n        eeb82d7c167d52173cc1895213f897f5e06a7be73665fc529264c2fb3ab643687aaf3ab440c16bd777e75050a8\\\n        d1a39e8af56c64a7833352906deb692ce4f199e108cf392819cfc406b19abb71ec25e11f75c#1000\",\n        Less,\n    );\n    test_log_2_e_prec_helper(\n        10000,\n        \"1.442695040888963407359924681001892137426645954152985934135449406931109219181185079885526\\\n        622893506344496997518309652544255593101687168359642720662158223479336274537369884718493630\\\n        701387663532015533894318916664837643128615424047478422289497904795091530351338588054968865\\\n        893096996368036110511075630844145427215828344941891933908577715790044171280246848341374522\\\n        695182369011239094034459968539906113421722886278029158010630061976762445652605995073753240\\\n        625655815475938178305239725510724813077156267545807578171330193573006168761937372982675897\\\n        415623817983567103443489750680705518088486561386832917732182934913968431059345402202518636\\\n        934526269215095597191002219679224321433424494179071455118499385921221675365311300774632767\\\n        206461233741108211913794433398480579310912877609670200375758998158851806126788099760956252\\\n        507841024847056900768768058461327865474782027808659462060910749015324819969730579015272324\\\n        787298740981254100033448687573822364716494544753706716759589942809981826783490131666633534\\\n        803678986944688709116660497353729258607212948697354540708098306748938341237186314008359796\\\n        188659758687452533054689212976641570420621259246313692421680590877408335813928666541584971\\\n        162587069556578588747699631296952500459372627389026805669355128729433837219131116650881001\\\n        587862655915637954055905677822368140030968843934808622848184791345633141193023840264097274\\\n        843644962195449224465222047176358607479658556660534098286098574027883743312688563354434306\\\n        978701896435826139118100252599020766184432984883184723915912701390457047735764831010211928\\\n        297085328960931680353919649869573264393791490308485470616433789856348238900004564261855622\\\n        496930913960312520223767376074153862116245551165086436799129389371225572752855358505388627\\\n        546928167550407303918984389641052039899021078907741074670715487187445927826480325745329406\\\n        836552544103465737320315138225129361437624142202250714370369730734609414850108603189323604\\\n        113311115744937702491468814553609722861672425272088889061517451052531559178316247029430178\\\n        095934252371975125612329569505926858901075573121447832714438655839592620356007499708416567\\\n        681679268721978983048302281782977385152293797381195278398266923467818982723138352442777865\\\n        647623134859901194028780732484171511058619349202546881837818357300094700147502951964817837\\\n        874039354216278848238941974695520862627419471357392597226651239427201166462692938707284017\\\n        956993398889202501277913459329094676020415764879790841607401359157889710773691716288172692\\\n        755182517960232474350173532606863738793763572044458313264353526509290061748888247033974920\\\n        459020557724020364994277699238470527177685203357040125910731736639056137520453197778773562\\\n        797180625921321743667984249874334562328228971247257945609197595215055835184523639531383497\\\n        657376260166981167685146145560638695562162638896323160272971094995069592801744350030798593\\\n        924157506631512149867563008065061831442109254227561277967430907171276820183902280303065724\\\n        252294800267075913436729080697447776799229453917140856561043148672020633912643384787632773\\\n        495535569020831968308365499869958364273149\",\n        \"0x1.71547652b82fe1777d0ffda0d23a7d11d6aef551bad2b4b1164a2cd9a342648fbc3887eeaa2ed9ac49b25\\\n        eeb82d7c167d52173cc1895213f897f5e06a7be73665fc529264c2fb3ab643687aaf3ab440c16bd777e75050a8\\\n        d1a39e8af56c64a7833352906deb692ce4f199e108cf392819cfc406b19abb71ec25e11f75c6142e64ca16da20\\\n        b1d74a12c719098b4040cbe82351bd8bd422427231f9ee25bd0c470fe2464b892824c120f2d07db43448b6bdd3\\\n        58165f1a2b3d8675f9ee1d8d19ce22ece1d8e1cf2ed95025c73a0b608ecb0ac9cb843a1c53b021698c0eba2176\\\n        77f7d0b9c4b6e004ca5169aedd5b0fbf79220755e0827ae421af38c350dbfd200f5437ad88854a185bbc4bbb5f\\\n        9231797de27c1982e15c6f87a30b468c39b2a586e51fb9211a51bfd1e1075e545eff26d6bfc0b51b3db80dbcb2\\\n        4254977733864dadcb616d749e415eb60cbda42f3df5d4a527d762fb97efdb287e16c60c8e5cbd7fc5b97445f4\\\n        a50a628f826ca66964b903cfa5da099460790c09071c1e23caa41ed00d87cd3ea10639d896b14ff19af35259c5\\\n        375f02f650e4e4154a0f0ad4150c9f23c2ac41a153c154c13420555a1dd2359b43d861faa27020f89240cce172\\\n        8bc41b06c19c811d57a442f32964754bf5393c68fce7c1143becd02ebdb9d9d6cd6ce0772765a409b32d4e2ff5\\\n        e479ea9cf606f388b14bf1040fd7ac3c572fa96799afa88d9b908ee33cc144dd7b3a9034befd1786dffd1b374c\\\n        3ab057c78308382a2ecb4a8ae9ebfe2400db7e42eb1afaf630de1ee8d85808160092d7bfb276e839390f2cc6dd\\\n        801dd8d0791db4a9e602c37179d4d793f85e6b7de417c9d92c6cded0dec3a15568bd8c41b35d16b262f9c9b86f\\\n        8efb146d75817a5a20dd9f20c8b36649fc6713eb9a596b7b63c90b82f4efacb3afa37dbda4bd2259ec05bf0464\\\n        c73c98129349a177c1beac7023630d669ff199f5bb7b898c5f42057260d95232260b815e608b14add28858c21b\\\n        afcb7061a345db80ebbd88c1a8cd7d558c3e49fde7e67e61b47752cc51aa59a7a8909a7888a2a53158b35e487f\\\n        9ccf8914ce12c742a93e9cb6d7360a5e4fb2e4acdd70f3a7c5afb7233d9547378dbd9a0f8eee80c01446b265c0\\\n        30bbd0bba9aa245c1a351aa40c8e9a6c1a2f9259df8d78033b8e5b1fbb46c6ff0514ca6f17c72498ff937dc7ef\\\n        1270ea59b36d4b6f41f6d327e363e04463279e5a893d88566e171b92c0af10b9eb3015a189e17eb81288143e5c\\\n        ea089a45ca8b5c69aeb433e4dc420589191a767f85e5aa15108ac58de430f24ddc986f1a18377639dcc819b7fe\\\n        b92041aeb238c812adf284474f81d729d962149f69e3aa2000a51acde13f7d8c097cdde28b92b7323ee95f66b3\\\n        c11bb8a14c27dad07685f8ebe4195220ef186f13536485dd4d3f6d1a01a7f5dc63145fb5688742fa36da1ef616\\\n        c00760f0ca4ea16514fed4ceb9a0b1afafe73aaa7a69727855effa8662bb16794ee125dc16c57b422bf1ab01bf\\\n        576392dd8813dc17771e2e4956c8bf568126613e4814945f3583b02acc36249d1db915aecab476582cf6dc8646\\\n        02ba37849ddb40cc61052fdd5001e3ecd7ac0e1d9d011d01f5392aaaf33b9d2a91f01e5ded9a6ec3f5b1e01e45\\\n        e96fb5653006d8a86b8986eb4bfc9b73352350d82bbde9d247cbd4b56ca2d8fd78c0244b2003418eef32ffec82\\\n        a35b9c7c64ed6f67a012528ad9fcd8c71017143f043b22cace3bfa4730f9c22bc761a40f5ea#10000\",\n        Less,\n    );\n\n    let log_2_e_f32 = Float::log_2_e_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(log_2_e_f32.to_string(), \"1.442695\");\n    assert_eq!(to_hex_string(&log_2_e_f32), \"0x1.715476#24\");\n    assert_eq!(log_2_e_f32, f32::LOG_2_E);\n\n    let log_2_e_f64 = Float::log_2_e_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(log_2_e_f64.to_string(), \"1.4426950408889634\");\n    assert_eq!(to_hex_string(&log_2_e_f64), \"0x1.71547652b82fe#53\");\n    assert_eq!(log_2_e_f64, f64::LOG_2_E);\n}\n\n#[test]\n#[should_panic]\nfn log_2_e_prec_fail_1() {\n    Float::log_2_e_prec(0);\n}\n\nfn test_log_2_e_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::log_2_e_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = log_2_e_prec_round_simple(prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_log_2_e_prec_round() {\n    test_log_2_e_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_log_2_e_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_log_2_e_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_log_2_e_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_log_2_e_prec_round_helper(1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test_log_2_e_prec_round_helper(2, Floor, \"1.0\", \"0x1.0#2\", Less);\n    test_log_2_e_prec_round_helper(2, Ceiling, \"1.5\", \"0x1.8#2\", Greater);\n    test_log_2_e_prec_round_helper(2, Down, \"1.0\", \"0x1.0#2\", Less);\n    test_log_2_e_prec_round_helper(2, Up, \"1.5\", \"0x1.8#2\", Greater);\n    test_log_2_e_prec_round_helper(2, Nearest, \"1.5\", \"0x1.8#2\", Greater);\n\n    test_log_2_e_prec_round_helper(3, Floor, \"1.2\", \"0x1.4#3\", Less);\n    test_log_2_e_prec_round_helper(3, Ceiling, \"1.5\", \"0x1.8#3\", Greater);\n    test_log_2_e_prec_round_helper(3, Down, \"1.2\", \"0x1.4#3\", Less);\n    test_log_2_e_prec_round_helper(3, Up, \"1.5\", \"0x1.8#3\", Greater);\n    test_log_2_e_prec_round_helper(3, Nearest, \"1.5\", \"0x1.8#3\", Greater);\n\n    test_log_2_e_prec_round_helper(4, Floor, \"1.4\", \"0x1.6#4\", Less);\n    test_log_2_e_prec_round_helper(4, Ceiling, \"1.5\", \"0x1.8#4\", Greater);\n    test_log_2_e_prec_round_helper(4, Down, \"1.4\", \"0x1.6#4\", Less);\n    test_log_2_e_prec_round_helper(4, Up, \"1.5\", \"0x1.8#4\", Greater);\n    test_log_2_e_prec_round_helper(4, Nearest, \"1.5\", \"0x1.8#4\", Greater);\n\n    test_log_2_e_prec_round_helper(5, Floor, \"1.44\", \"0x1.7#5\", Less);\n    test_log_2_e_prec_round_helper(5, Ceiling, \"1.5\", \"0x1.8#5\", Greater);\n    test_log_2_e_prec_round_helper(5, Down, \"1.44\", \"0x1.7#5\", Less);\n    test_log_2_e_prec_round_helper(5, Up, \"1.5\", \"0x1.8#5\", Greater);\n    test_log_2_e_prec_round_helper(5, Nearest, \"1.44\", \"0x1.7#5\", Less);\n\n    test_log_2_e_prec_round_helper(6, Floor, \"1.44\", \"0x1.70#6\", Less);\n    test_log_2_e_prec_round_helper(6, Ceiling, \"1.47\", \"0x1.78#6\", Greater);\n    test_log_2_e_prec_round_helper(6, Down, \"1.44\", \"0x1.70#6\", Less);\n    test_log_2_e_prec_round_helper(6, Up, \"1.47\", \"0x1.78#6\", Greater);\n    test_log_2_e_prec_round_helper(6, Nearest, \"1.44\", \"0x1.70#6\", Less);\n\n    test_log_2_e_prec_round_helper(7, Floor, \"1.44\", \"0x1.70#7\", Less);\n    test_log_2_e_prec_round_helper(7, Ceiling, \"1.45\", \"0x1.74#7\", Greater);\n    test_log_2_e_prec_round_helper(7, Down, \"1.44\", \"0x1.70#7\", Less);\n    test_log_2_e_prec_round_helper(7, Up, \"1.45\", \"0x1.74#7\", Greater);\n    test_log_2_e_prec_round_helper(7, Nearest, \"1.44\", \"0x1.70#7\", Less);\n\n    test_log_2_e_prec_round_helper(8, Floor, \"1.44\", \"0x1.70#8\", Less);\n    test_log_2_e_prec_round_helper(8, Ceiling, \"1.445\", \"0x1.72#8\", Greater);\n    test_log_2_e_prec_round_helper(8, Down, \"1.44\", \"0x1.70#8\", Less);\n    test_log_2_e_prec_round_helper(8, Up, \"1.445\", \"0x1.72#8\", Greater);\n    test_log_2_e_prec_round_helper(8, Nearest, \"1.445\", \"0x1.72#8\", Greater);\n\n    test_log_2_e_prec_round_helper(9, Floor, \"1.441\", \"0x1.71#9\", Less);\n    test_log_2_e_prec_round_helper(9, Ceiling, \"1.445\", \"0x1.72#9\", Greater);\n    test_log_2_e_prec_round_helper(9, Down, \"1.441\", \"0x1.71#9\", Less);\n    test_log_2_e_prec_round_helper(9, Up, \"1.445\", \"0x1.72#9\", Greater);\n    test_log_2_e_prec_round_helper(9, Nearest, \"1.441\", \"0x1.71#9\", Less);\n\n    test_log_2_e_prec_round_helper(10, Floor, \"1.441\", \"0x1.710#10\", Less);\n    test_log_2_e_prec_round_helper(10, Ceiling, \"1.443\", \"0x1.718#10\", Greater);\n    test_log_2_e_prec_round_helper(10, Down, \"1.441\", \"0x1.710#10\", Less);\n    test_log_2_e_prec_round_helper(10, Up, \"1.443\", \"0x1.718#10\", Greater);\n    test_log_2_e_prec_round_helper(10, Nearest, \"1.443\", \"0x1.718#10\", Greater);\n\n    test_log_2_e_prec_round_helper(\n        100,\n        Floor,\n        \"1.442695040888963407359924681001\",\n        \"0x1.71547652b82fe1777d0ffda0c#100\",\n        Less,\n    );\n    test_log_2_e_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.442695040888963407359924681003\",\n        \"0x1.71547652b82fe1777d0ffda0e#100\",\n        Greater,\n    );\n    test_log_2_e_prec_round_helper(\n        100,\n        Down,\n        \"1.442695040888963407359924681001\",\n        \"0x1.71547652b82fe1777d0ffda0c#100\",\n        Less,\n    );\n    test_log_2_e_prec_round_helper(\n        100,\n        Up,\n        \"1.442695040888963407359924681003\",\n        \"0x1.71547652b82fe1777d0ffda0e#100\",\n        Greater,\n    );\n    test_log_2_e_prec_round_helper(\n        100,\n        Nearest,\n        \"1.442695040888963407359924681003\",\n        \"0x1.71547652b82fe1777d0ffda0e#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn log_2_e_prec_round_fail_1() {\n    Float::log_2_e_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn log_2_e_prec_round_fail_2() {\n    Float::log_2_e_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn log_2_e_prec_round_fail_3() {\n    Float::log_2_e_prec_round(1000, Exact);\n}\n\n#[test]\nfn log_2_e_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (log_2_e, o) = Float::log_2_e_prec(prec);\n        assert!(log_2_e.is_valid());\n        assert_eq!(log_2_e.get_prec(), Some(prec));\n        assert_eq!(log_2_e.get_exponent(), Some(1));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (log_2_e_alt, o_alt) = Float::log_2_e_prec_round(prec, Ceiling);\n            let mut next_upper = log_2_e.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(log_2_e_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !log_2_e.is_power_of_2() {\n            let (log_2_e_alt, o_alt) = Float::log_2_e_prec_round(prec, Floor);\n            let mut next_lower = log_2_e.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(log_2_e_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (log_2_e_alt, o_alt) = Float::log_2_e_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&log_2_e_alt),\n            ComparableFloatRef(&log_2_e)\n        );\n        assert_eq!(o_alt, o);\n\n        let (log_2_e_alt, o_alt) = log_2_e_prec_round_simple(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&log_2_e_alt),\n            ComparableFloatRef(&log_2_e)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn log_2_e_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (log_2_e, o) = Float::log_2_e_prec_round(prec, rm);\n        assert!(log_2_e.is_valid());\n        assert_eq!(log_2_e.get_prec(), Some(prec));\n        assert_eq!(\n            log_2_e.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                2\n            } else {\n                1\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (log_2_e_alt, o_alt) = Float::log_2_e_prec_round(prec, Ceiling);\n            let mut next_upper = log_2_e.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(log_2_e_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !log_2_e.is_power_of_2() {\n            let (log_2_e_alt, o_alt) = Float::log_2_e_prec_round(prec, Floor);\n            let mut next_lower = log_2_e.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(log_2_e_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        let (log_2_e_alt, o_alt) = log_2_e_prec_round_simple(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&log_2_e_alt),\n            ComparableFloatRef(&log_2_e)\n        );\n        assert_eq!(o_alt, o);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::log_2_e_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::log_2_e_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/one_over_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::OneOverPi;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::one_over_pi::one_over_pi_prec_round_simple;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_one_over_pi_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::one_over_pi_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = one_over_pi_prec_round_simple(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_one_over_pi_prec() {\n    test_one_over_pi_prec_helper(1, \"0.2\", \"0x0.4#1\", Less);\n    test_one_over_pi_prec_helper(2, \"0.4\", \"0x0.6#2\", Greater);\n    test_one_over_pi_prec_helper(3, \"0.3\", \"0x0.5#3\", Less);\n    test_one_over_pi_prec_helper(4, \"0.31\", \"0x0.50#4\", Less);\n    test_one_over_pi_prec_helper(5, \"0.31\", \"0x0.50#5\", Less);\n    test_one_over_pi_prec_helper(6, \"0.32\", \"0x0.52#6\", Greater);\n    test_one_over_pi_prec_helper(7, \"0.316\", \"0x0.51#7\", Less);\n    test_one_over_pi_prec_helper(8, \"0.318\", \"0x0.518#8\", Greater);\n    test_one_over_pi_prec_helper(9, \"0.318\", \"0x0.518#9\", Greater);\n    test_one_over_pi_prec_helper(10, \"0.3184\", \"0x0.518#10\", Greater);\n    test_one_over_pi_prec_helper(\n        100,\n        \"0.3183098861837906715377675267449\",\n        \"0x0.517cc1b727220a94fe13abe8f8#100\",\n        Less,\n    );\n    test_one_over_pi_prec_helper(\n        1000,\n        \"0.318309886183790671537767526745028724068919291480912897495334688117793595268453070180227\\\n        605532506171912145685453515916073785823692229157305755934821463399678458479933874818155146\\\n        155492793850615377434785792434795323386724780483447258023664760228445399511431880923780173\\\n        80534791224097882187387568817105745\",\n        \"0x0.517cc1b727220a94fe13abe8fa9a6ee06db14acc9e21c820ff28b1d5ef5de2b0db92371d2126e97003249\\\n        77504e8c90e7f0ef58e5894d39f74411afa975da24274ce38135a2fbf209cc8eb1cc1a99cfa4e422fc5defc941\\\n        d8ffc4bffef02cc07f79788c5ad05368fb69b3f6793e584dba7a31fb34f2ff516ba93dd63f60#1000\",\n        Greater,\n    );\n    test_one_over_pi_prec_helper(\n        10000,\n        \"0.318309886183790671537767526745028724068919291480912897495334688117793595268453070180227\\\n        605532506171912145685453515916073785823692229157305755934821463399678458479933874818155146\\\n        155492793850615377434785792434795323386724780483447258023664760228445399511431880923780173\\\n        805347912240978821873875688171057446199892886800497344695478919221796646193566149812333972\\\n        925609398897304375763149573133928482077991748278697219967736198399924885751170342357716862\\\n        235037534321093095073976019478920729518667536118604988993270610654313551006440649555632794\\\n        332045893496239196331681212033606071996267823974997665573308870559510140032481355128777699\\\n        142621760244398752295362755529475781266136092915956963522624854628139921550049000595519714\\\n        178113805593570263050420032635492041849623212481122912406292968178496918382870423150815112\\\n        401743053213604434318281514949165445195492570799750310658781627963544818716509594146657438\\\n        081399951815315415698694078717965617434685128073379023325091411886655262537300052245435942\\\n        306422519900877335890075251121672634233905195162564498832466686290212247073757126227273384\\\n        334284139493920258501156672106239217189019679113437419909493020863247631035161678885959941\\\n        999010508775132258891766613692101570583030282080978597701277632155239398614682077999157383\\\n        781196187475544123750864454378602732510522477560775077762213628135308681656557053866853599\\\n        112141580772120705477992490251991498552594047188191168602329659282371155424811508898914043\\\n        579539584818980654589540433299207130636307088007681379749435383177526381933013928809553941\\\n        375367313556209559590900706791516603763677375875532249629906119931160438167197502070254258\\\n        086463160997439373755518931326924420684088817109957007585477388587073238755658574718756869\\\n        406460474291675847114237272683858920366364583928330017566158662706995581994917298580534901\\\n        219787378189176610067406107610946246431618863953520645662628379619499644876670348713979695\\\n        002079001367760079573447199216048005478021749909709575847136522279897806537994854166992229\\\n        841657807553569486071009136912167342958616913446654070970785112404173678648199124423506636\\\n        788041941587141549930997617372132721937323934074949084205662438503692449669982322299133112\\\n        075939352279862565992155216555980201566072004676545975817080477523114890861852023820108675\\\n        996778093098424965903214145706010454420472035046626346359518622100656310218747827279290611\\\n        585214360167235909753449291960947954584896218401874251573836665791772567980871737333279513\\\n        468902819007274654383486227761327661451846055194690121096425556074130675566064341975469933\\\n        136981600653977013483582929367016563233706628672321461990299706239639467516888419683311908\\\n        304501286788625728880767767123017595432900341294135037549121183217433715715878452469512663\\\n        422265997311883193781439701377488460115038395411380076436785124406774847072513616708313034\\\n        594217623443591873665129770374999497417106233196612202784289089203229769055405022822140497\\\n        043479490207733472807745720199349786347123624142348095779873777311384615697004611411428812\\\n        72772640473704021482011497184562231443936007\",\n        \"0x0.517cc1b727220a94fe13abe8fa9a6ee06db14acc9e21c820ff28b1d5ef5de2b0db92371d2126e97003249\\\n        77504e8c90e7f0ef58e5894d39f74411afa975da24274ce38135a2fbf209cc8eb1cc1a99cfa4e422fc5defc941\\\n        d8ffc4bffef02cc07f79788c5ad05368fb69b3f6793e584dba7a31fb34f2ff516ba93dd63f5f2f8bd9e839cfbc\\\n        529497535fdafd88fc6ae842b0198237e3db5d5f867de104d7a1b0ed4f1c8b0af730d8432ccc2af8a50342046f\\\n        fec4026b9939883030aab6539d464b0713de04635a3e20ce1b3e6ee74049541ace23b45cb0e536ed7a268ab8c8\\\n        29f52ff83829fbf19f419616f27cc193edde19e9377b58f2f7c4f9d0f9ae5793f8ec3f890c83e3e12357d376ab\\\n        b9698219d8ae30a5ace8ce1e16256a0a6962e8006233ec316b8f1cd634d803119be695a4bd3da6aaa9bfb1f6b8\\\n        c0851fe3b26954eb255ebb87c3e31abd83d738a8bab24e06ceb1d9c4253e591923bc56b11aa2d5c8f800d8578e\\\n        fe70cff98cfb50f3330abcca3fdd66c3fbf5bb29144f419305ff366e277849b366a1faeebef0b6f1dac494def1\\\n        4116974431426ac711965630b718465bef028600bd38ef9adf00c1a099731094180a441adc77abfd856f9748f2\\\n        1a52469b3886c6ed5212fd76730b55214055a4ce9f953033fbbae41e151c41e30bc39c52d4657deebb7b1d316e\\\n        5dffa77c0c6b3e09322e52a9b6ce569541446b0e13be4890a13024da309622ce22262e448d926f98b8056a1ea7\\\n        2a494886afefe5f00664a0f7767387a9f09c078f661f3d9947c63ca02c99f38e0d9849779a285ce09443d9055c\\\n        fda9761492397993db6aa864853b90ff3b5cb6598a50b3cf13ca0c4effa4bca744273714b98ccb5f6c41b2faf8\\\n        77eddda4d24365233a13938992ec6dc0acf84f2de1298c69cba7b8e0298008606b40425ac77164855238173ba1\\\n        26b5ed33efbb92437778b4fd34a477b48da28a9e8f9056799cc103f25fab431d92f9f6e81aea03fc4c294a92ae\\\n        0321b886c369924193aa62dea38a7372a22e08485b4fa956ab30a4e8393a8022eed9dda62bb750bfcc3beb5a4d\\\n        d138e94b4cb5666632a0a56b5714844ecc42839165f52024a03bbb8187993fe005438f524e1331ef03241eecbc\\\n        b9fd1feca21c64306ef2098ce9cc946386ef3db8b9def84159b8ad0402e49c02d4908886c7407d7c03625ffed8\\\n        7c81c3b0c2c8ad2b15de5b0dcc4e3dea00802796913baa4fb5b75dd916dd50a05179344bb41b2199d848d4a075\\\n        51d28e1518ed776d789132e26e136ce3d16cbab60419f81fb7804c62015cc98b683da1c8a90062de1ec62497aa\\\n        5d6e352e527669bd39b54f34a4955b4216eef318cf7c63b2945b41bedfe55d0d7188aefd0d7006d7d863326b25\\\n        b82f6983294dfab2b9d7fa3dcfcb579df3aefc994184055fb46330ae58203117d0ef26cd2599ec78dab84e69b7\\\n        4a127525f09da91998d55785432a7d2e0e9079f85e6bc2dbb7c918245bdb90bc4a9d3637137378075f7ac254dd\\\n        bed625d335567e7bb0e816896f8d8e0ccc63bd6e1ed2443502efbfa406317f8564d766ede2e1fb6ef680fe3c85\\\n        b6d951d12d1cd578049a9d6822bdb5a1694bf4025d383ed07553b50acbd95090b16dbee7ef2fd7f6dc4fedf44b\\\n        63b727e548338401f0ab742ffc3fe839f1419b3b0c30c15755ea6d7f3d9b736c79cb3caaddf98a46bc20b6f982\\\n        196e39ab092e73864dc65987eb65fd10052723602d06ead23b790e90931422e5ca4b0b8702b0#10000\",\n        Less,\n    );\n\n    let one_over_pi_f32 = Float::one_over_pi_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(one_over_pi_f32.to_string(), \"0.31830987\");\n    assert_eq!(to_hex_string(&one_over_pi_f32), \"0x0.517cc18#24\");\n    assert_eq!(one_over_pi_f32, f32::ONE_OVER_PI);\n\n    let one_over_pi_f64 = Float::one_over_pi_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(one_over_pi_f64.to_string(), \"0.31830988618379069\");\n    assert_eq!(to_hex_string(&one_over_pi_f64), \"0x0.517cc1b727220c#53\");\n    assert_eq!(one_over_pi_f64, f64::ONE_OVER_PI);\n}\n\n#[test]\n#[should_panic]\nfn one_over_pi_prec_fail_1() {\n    Float::one_over_pi_prec(0);\n}\n\nfn test_one_over_pi_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::one_over_pi_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = one_over_pi_prec_round_simple(prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_one_over_pi_prec_round() {\n    test_one_over_pi_prec_round_helper(1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test_one_over_pi_prec_round_helper(1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test_one_over_pi_prec_round_helper(1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test_one_over_pi_prec_round_helper(1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test_one_over_pi_prec_round_helper(1, Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test_one_over_pi_prec_round_helper(2, Floor, \"0.2\", \"0x0.4#2\", Less);\n    test_one_over_pi_prec_round_helper(2, Ceiling, \"0.4\", \"0x0.6#2\", Greater);\n    test_one_over_pi_prec_round_helper(2, Down, \"0.2\", \"0x0.4#2\", Less);\n    test_one_over_pi_prec_round_helper(2, Up, \"0.4\", \"0x0.6#2\", Greater);\n    test_one_over_pi_prec_round_helper(2, Nearest, \"0.4\", \"0x0.6#2\", Greater);\n\n    test_one_over_pi_prec_round_helper(3, Floor, \"0.3\", \"0x0.5#3\", Less);\n    test_one_over_pi_prec_round_helper(3, Ceiling, \"0.38\", \"0x0.6#3\", Greater);\n    test_one_over_pi_prec_round_helper(3, Down, \"0.3\", \"0x0.5#3\", Less);\n    test_one_over_pi_prec_round_helper(3, Up, \"0.38\", \"0x0.6#3\", Greater);\n    test_one_over_pi_prec_round_helper(3, Nearest, \"0.3\", \"0x0.5#3\", Less);\n\n    test_one_over_pi_prec_round_helper(4, Floor, \"0.31\", \"0x0.50#4\", Less);\n    test_one_over_pi_prec_round_helper(4, Ceiling, \"0.34\", \"0x0.58#4\", Greater);\n    test_one_over_pi_prec_round_helper(4, Down, \"0.31\", \"0x0.50#4\", Less);\n    test_one_over_pi_prec_round_helper(4, Up, \"0.34\", \"0x0.58#4\", Greater);\n    test_one_over_pi_prec_round_helper(4, Nearest, \"0.31\", \"0x0.50#4\", Less);\n\n    test_one_over_pi_prec_round_helper(5, Floor, \"0.31\", \"0x0.50#5\", Less);\n    test_one_over_pi_prec_round_helper(5, Ceiling, \"0.33\", \"0x0.54#5\", Greater);\n    test_one_over_pi_prec_round_helper(5, Down, \"0.31\", \"0x0.50#5\", Less);\n    test_one_over_pi_prec_round_helper(5, Up, \"0.33\", \"0x0.54#5\", Greater);\n    test_one_over_pi_prec_round_helper(5, Nearest, \"0.31\", \"0x0.50#5\", Less);\n\n    test_one_over_pi_prec_round_helper(6, Floor, \"0.31\", \"0x0.50#6\", Less);\n    test_one_over_pi_prec_round_helper(6, Ceiling, \"0.32\", \"0x0.52#6\", Greater);\n    test_one_over_pi_prec_round_helper(6, Down, \"0.31\", \"0x0.50#6\", Less);\n    test_one_over_pi_prec_round_helper(6, Up, \"0.32\", \"0x0.52#6\", Greater);\n    test_one_over_pi_prec_round_helper(6, Nearest, \"0.32\", \"0x0.52#6\", Greater);\n\n    test_one_over_pi_prec_round_helper(7, Floor, \"0.316\", \"0x0.51#7\", Less);\n    test_one_over_pi_prec_round_helper(7, Ceiling, \"0.32\", \"0x0.52#7\", Greater);\n    test_one_over_pi_prec_round_helper(7, Down, \"0.316\", \"0x0.51#7\", Less);\n    test_one_over_pi_prec_round_helper(7, Up, \"0.32\", \"0x0.52#7\", Greater);\n    test_one_over_pi_prec_round_helper(7, Nearest, \"0.316\", \"0x0.51#7\", Less);\n\n    test_one_over_pi_prec_round_helper(8, Floor, \"0.316\", \"0x0.510#8\", Less);\n    test_one_over_pi_prec_round_helper(8, Ceiling, \"0.318\", \"0x0.518#8\", Greater);\n    test_one_over_pi_prec_round_helper(8, Down, \"0.316\", \"0x0.510#8\", Less);\n    test_one_over_pi_prec_round_helper(8, Up, \"0.318\", \"0x0.518#8\", Greater);\n    test_one_over_pi_prec_round_helper(8, Nearest, \"0.318\", \"0x0.518#8\", Greater);\n\n    test_one_over_pi_prec_round_helper(9, Floor, \"0.317\", \"0x0.514#9\", Less);\n    test_one_over_pi_prec_round_helper(9, Ceiling, \"0.318\", \"0x0.518#9\", Greater);\n    test_one_over_pi_prec_round_helper(9, Down, \"0.317\", \"0x0.514#9\", Less);\n    test_one_over_pi_prec_round_helper(9, Up, \"0.318\", \"0x0.518#9\", Greater);\n    test_one_over_pi_prec_round_helper(9, Nearest, \"0.318\", \"0x0.518#9\", Greater);\n\n    test_one_over_pi_prec_round_helper(10, Floor, \"0.3179\", \"0x0.516#10\", Less);\n    test_one_over_pi_prec_round_helper(10, Ceiling, \"0.3184\", \"0x0.518#10\", Greater);\n    test_one_over_pi_prec_round_helper(10, Down, \"0.3179\", \"0x0.516#10\", Less);\n    test_one_over_pi_prec_round_helper(10, Up, \"0.3184\", \"0x0.518#10\", Greater);\n    test_one_over_pi_prec_round_helper(10, Nearest, \"0.3184\", \"0x0.518#10\", Greater);\n\n    test_one_over_pi_prec_round_helper(\n        100,\n        Floor,\n        \"0.3183098861837906715377675267449\",\n        \"0x0.517cc1b727220a94fe13abe8f8#100\",\n        Less,\n    );\n    test_one_over_pi_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.3183098861837906715377675267453\",\n        \"0x0.517cc1b727220a94fe13abe900#100\",\n        Greater,\n    );\n    test_one_over_pi_prec_round_helper(\n        100,\n        Down,\n        \"0.3183098861837906715377675267449\",\n        \"0x0.517cc1b727220a94fe13abe8f8#100\",\n        Less,\n    );\n    test_one_over_pi_prec_round_helper(\n        100,\n        Up,\n        \"0.3183098861837906715377675267453\",\n        \"0x0.517cc1b727220a94fe13abe900#100\",\n        Greater,\n    );\n    test_one_over_pi_prec_round_helper(\n        100,\n        Nearest,\n        \"0.3183098861837906715377675267449\",\n        \"0x0.517cc1b727220a94fe13abe8f8#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn one_over_pi_prec_round_fail_1() {\n    Float::one_over_pi_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn one_over_pi_prec_round_fail_2() {\n    Float::one_over_pi_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn one_over_pi_prec_round_fail_3() {\n    Float::one_over_pi_prec_round(1000, Exact);\n}\n\n#[test]\nfn one_over_pi_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (one_over_pi, o) = Float::one_over_pi_prec(prec);\n        assert!(one_over_pi.is_valid());\n        assert_eq!(one_over_pi.get_prec(), Some(prec));\n        assert_eq!(one_over_pi.get_exponent(), Some(-1));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (one_over_pi_alt, o_alt) = Float::one_over_pi_prec_round(prec, Ceiling);\n            let mut next_upper = one_over_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(one_over_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !one_over_pi.is_power_of_2() {\n            let (one_over_pi_alt, o_alt) = Float::one_over_pi_prec_round(prec, Floor);\n            let mut next_lower = one_over_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(one_over_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (one_over_pi_alt, o_alt) = Float::one_over_pi_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&one_over_pi_alt),\n            ComparableFloatRef(&one_over_pi)\n        );\n        assert_eq!(o_alt, o);\n\n        let (one_over_pi_alt, o_alt) = one_over_pi_prec_round_simple(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&one_over_pi_alt),\n            ComparableFloatRef(&one_over_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn one_over_pi_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (one_over_pi, o) = Float::one_over_pi_prec_round(prec, rm);\n        assert!(one_over_pi.is_valid());\n        assert_eq!(one_over_pi.get_prec(), Some(prec));\n        assert_eq!(\n            one_over_pi.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                0\n            } else {\n                -1\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (one_over_pi_alt, o_alt) = Float::one_over_pi_prec_round(prec, Ceiling);\n            let mut next_upper = one_over_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(one_over_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !one_over_pi.is_power_of_2() {\n            let (one_over_pi_alt, o_alt) = Float::one_over_pi_prec_round(prec, Floor);\n            let mut next_lower = one_over_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(one_over_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n\n        let (one_over_pi_alt, o_alt) = one_over_pi_prec_round_simple(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&one_over_pi_alt),\n            ComparableFloatRef(&one_over_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::one_over_pi_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::one_over_pi_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/one_over_sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::OneOverSqrtPi;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::one_over_sqrt_pi::one_over_sqrt_pi_prec_round_simple;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_one_over_sqrt_pi_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::one_over_sqrt_pi_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = one_over_sqrt_pi_prec_round_simple(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_one_over_sqrt_pi_prec() {\n    test_one_over_sqrt_pi_prec_helper(1, \"0.5\", \"0x0.8#1\", Less);\n    test_one_over_sqrt_pi_prec_helper(2, \"0.5\", \"0x0.8#2\", Less);\n    test_one_over_sqrt_pi_prec_helper(3, \"0.6\", \"0x0.a#3\", Greater);\n    test_one_over_sqrt_pi_prec_helper(4, \"0.56\", \"0x0.9#4\", Less);\n    test_one_over_sqrt_pi_prec_helper(5, \"0.56\", \"0x0.90#5\", Less);\n    test_one_over_sqrt_pi_prec_helper(6, \"0.56\", \"0x0.90#6\", Less);\n    test_one_over_sqrt_pi_prec_helper(7, \"0.56\", \"0x0.90#7\", Less);\n    test_one_over_sqrt_pi_prec_helper(8, \"0.562\", \"0x0.90#8\", Less);\n    test_one_over_sqrt_pi_prec_helper(9, \"0.564\", \"0x0.908#9\", Greater);\n    test_one_over_sqrt_pi_prec_helper(10, \"0.564\", \"0x0.908#10\", Greater);\n    test_one_over_sqrt_pi_prec_helper(\n        100,\n        \"0.564189583547756286948079451561\",\n        \"0x0.906eba8214db688d71d48a7f7#100\",\n        Greater,\n    );\n    test_one_over_sqrt_pi_prec_helper(\n        1000,\n        \"0.564189583547756286948079451560772585844050629328998856844085721710642468441493414486743\\\n        660202107363443028347906361707351689931494826162866365489520017768993292837637059598439760\\\n        352464350217972571211580245772820220554508527173216622208463308111399512763454486023068237\\\n        6909187451587466158513010663983578\",\n        \"0x0.906eba8214db688d71d48a7f6bfec3441409a0ebac3e751739a15830cce620b0c0759cf859270f1140c03\\\n        6096cc79aebbd1f4eee48e1ca7874f76f877ffec25152561dcc244dc65e9c22f47f7b7fb57c9522f2f93e16b2a\\\n        3d27a3282dada7316eb9feb2436f2f272ac2c88bbba81b1c750754b409e94d32d18d3e91add#1000\",\n        Greater,\n    );\n    test_one_over_sqrt_pi_prec_helper(\n        10000,\n        \"0.564189583547756286948079451560772585844050629328998856844085721710642468441493414486743\\\n        660202107363443028347906361707351689931494826162866365489520017768993292837637059598439760\\\n        352464350217972571211580245772820220554508527173216622208463308111399512763454486023068237\\\n        690918745158746615851301066398357771999377334160357798876166744076233039380216350601643621\\\n        696235050458312531946879456656288325815521624434548865703189877430881778182948389475108500\\\n        918458534221631782589335251833012024622562223724947270033897431264299659426350428304490363\\\n        315803937695985608159337829220557382923788231579233105761964777468253090171561808059522229\\\n        617632465359040085344294862502894739216418119274309774225569878795779049874819136937239692\\\n        072860633424767969948609588763043633726455878751543080934419738483288491379175361895663509\\\n        241348925308830394965405841057254148274823475174742009396988341677714885589167833739498591\\\n        581650137685988686204396412907286928963807377326731118428678802115524866218971908896807531\\\n        495120147455271759129815272122063234346757415260256184982277894986952530166949696856638623\\\n        092204424861433131061101739704316554435364616300266810889304772054130274832143365864710291\\\n        854949083838769247696374058754103158473317076216953144890497317398112138525262894966581881\\\n        072472305017305600073055507380269070239209325129365185654408027303045608558893318652586305\\\n        258834720981091615225551340163448096077340629067652092477744457915659936286913810650697399\\\n        221160635018381201634827945255588045897195279903092298856115545628197444322318409489548225\\\n        698923189346820367003206229210032439562925718525419045578836831335596305728880148673271426\\\n        404156118265947052921488282109621556115877884575869370769316568975733036330605808042677655\\\n        428887246839586538128191754446004116925982320701014879775987396655241201231020855972580774\\\n        163232436519687057937186995686641316370707460164674562326647852763293612556036730458147509\\\n        675836925881775102516171791588543511319449779511302064465744235464169847898040837501074701\\\n        352751880478226229284695968227276043713529635662439179198513462262203022255831394816897442\\\n        156283042895891974583056032928037616331070074684468077543352388043093250182093443276971756\\\n        604585358146189293483000847521883563156134850300525631317511502402815253573480281037755873\\\n        096872058049839116785448367821638308739616614732338613368580643691303623270229201209584205\\\n        184540016221297602224920502091385620779268452045138092065191048228713446511588759776466334\\\n        955164279752771529006304592626662132102474121626192672652575831748945391640021506027583121\\\n        434323762213688659265886677223270051307283677840267588527026126262046233048278337730934597\\\n        251048975207110619022526431266585290657052824558964508055413035731525022451056993474245131\\\n        940271984820050179010512183653933500150867883341285338203943259891864588601821281032378193\\\n        761352726418609752619573339217755306901824708807431947047706039526585252022757276732244053\\\n        528355676567827486661805285681843895340144818064306646936344654007472918717723921069499452\\\n        62293257821840527730356884864031512332566992\",\n        \"0x0.906eba8214db688d71d48a7f6bfec3441409a0ebac3e751739a15830cce620b0c0759cf859270f1140c03\\\n        6096cc79aebbd1f4eee48e1ca7874f76f877ffec25152561dcc244dc65e9c22f47f7b7fb57c9522f2f93e16b2a\\\n        3d27a3282dada7316eb9feb2436f2f272ac2c88bbba81b1c750754b409e94d32d18d3e91adcff6c039ad39cf86\\\n        6dd09628cd2681847e759247bb68d0db3217d6928d2c52986a1ef82fd6bde19d4863cd81de6bb94f13db14d3ac\\\n        25186f4f23712538d461ea97b001e73157a8e5fd0894dfd79bea110cd0c886c16e0cc2d71f2331782fe3af6af3\\\n        8d95ebaf4bdcaf407f127fcee21139e560f41988fba498490a2f046bd5d928060833f81efeffc9b1f476e77a5c\\\n        560d16d31aff355b18658c49dfffbf2b24ebd85570ea4e3551e6045d0a36dcb1e46fe9121958e5e0085a461d2e\\\n        69efd1284fb5f445a03e882c983dc91ec8ffd8edb30c57e8ad4952dd036641d7d5223048f5567aa5a9178ca2e8\\\n        c8f26d66d0899c3cba579d1a1fbe71b4cabf7ee1c212c2987e7c81ba09dd83fd1b82dc9a5d640a2bb4106903a0\\\n        5532629934b6622adbce3256ae672fffa96cd508a764ff883a76e3184d13014db85491972cf555280d50565251\\\n        3b94139e1397635d9a38584adbe3a3d177cf1e310732f87b24661689d25a18170cbd38f4766de0088c2c050e08\\\n        d1a0e3c9a6988eb9f9a25c2e839623d90f4226b5c965b39c56a5777a8a4e07a5f76e5dac5d468d209c0346efe2\\\n        57ef980d1deaf815ccd5e0661a456ebeaf04e66aad8ed6462a7117e127986462672d4372a902f7db4341aeac82\\\n        533af16409add2cb38cfdd50cdd3c49336dbd8d5a6d9b58e5a095a6af709feef8bb46de1a3e9536a629b5d6487\\\n        ffff1ab63baf70322c7216ba26b50b76a8d62074f1019a114b1ebbd2a2fc5ad771751d9be11eda7a826a3dcc36\\\n        516aa1d5bf8ac7936a37a25d41c716753bba34924d7fb957eb8baad78e7560fd3d6864629b76a7959212a2c2c1\\\n        9e83efb12a9f58ffffe0e879efbb8a0c0567130c689128e7f54f353052ff8436c6696bd07a1748582a5756e413\\\n        401db988220bc7b3b589f914a6cbdccf698c70552afd06a795b55b0ce2bb849e6704291c36f27aa171cee7eae5\\\n        a646b9b49e5a8fe668b1fbe87c2a9c3a09bebd4e81c43620dbd1a3d4418f0d6ea7c30ea4749dbded9a534c38ea\\\n        7457b0a410276136368d0aa59998f7ef31f091494d36e75bbc31316a0b4a715d23ed230545370985cc1222f507\\\n        22da00753753538227128b1aa8de13ca2840e9a229209879f8f4687e0510d2dad16e5431258280d050039bf530\\\n        2194770c6354c1c43f61d1192f579f9440ca53f792c8bbffc33132f201844b7e8dafbab89aeda56c8b23b471de\\\n        02baaebbae4a33608e0d4e6ce9c02fe99164d5ffaa134ff9246ae00f4cc6d6560cad52a48ba21174a58bbaf3ac\\\n        19e64f7c8282a70460a445d41d2fc237829e680bb1795b47a64cbc7620d29fc77362dc8769613f41fd347815e5\\\n        28b411c31003911777199ab2f233e757e919885780c6ec05d414c0c5c164f4b12e388f4383cfe534a6ede9fddf\\\n        b68089f73397e212e0df99ff496d43a9f35abb5e03f8b7a9c0d6b0afe2ec113c6918476e1f63429f60e3910430\\\n        7aeaf0e9c06c51f49e31cafa107a56947bed2ac19415640ce6db45372d33b0f0d5c87c6bc4c0e0fd0a81da36fd\\\n        bc11afa300997175943be0fe51f3d0b221b9d99cb1aa10f1c4761e8be0cf7920bfa3b689d53#10000\",\n        Less,\n    );\n\n    let one_over_sqrt_pi_f32 = Float::one_over_sqrt_pi_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(one_over_sqrt_pi_f32.to_string(), \"0.56418961\");\n    assert_eq!(to_hex_string(&one_over_sqrt_pi_f32), \"0x0.906ebb#24\");\n    assert_eq!(one_over_sqrt_pi_f32, f32::ONE_OVER_SQRT_PI);\n\n    let one_over_sqrt_pi_f64 = Float::one_over_sqrt_pi_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(one_over_sqrt_pi_f64.to_string(), \"0.5641895835477563\");\n    assert_eq!(\n        to_hex_string(&one_over_sqrt_pi_f64),\n        \"0x0.906eba8214db68#53\"\n    );\n    assert_eq!(one_over_sqrt_pi_f64, f64::ONE_OVER_SQRT_PI);\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_pi_prec_fail_1() {\n    Float::one_over_sqrt_pi_prec(0);\n}\n\nfn test_one_over_sqrt_pi_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::one_over_sqrt_pi_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = one_over_sqrt_pi_prec_round_simple(prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_one_over_sqrt_pi_prec_round() {\n    test_one_over_sqrt_pi_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test_one_over_sqrt_pi_prec_round_helper(2, Floor, \"0.5\", \"0x0.8#2\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(2, Ceiling, \"0.8\", \"0x0.c#2\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(2, Down, \"0.5\", \"0x0.8#2\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(2, Up, \"0.8\", \"0x0.c#2\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(2, Nearest, \"0.5\", \"0x0.8#2\", Less);\n\n    test_one_over_sqrt_pi_prec_round_helper(3, Floor, \"0.5\", \"0x0.8#3\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(3, Ceiling, \"0.6\", \"0x0.a#3\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(3, Down, \"0.5\", \"0x0.8#3\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(3, Up, \"0.6\", \"0x0.a#3\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(3, Nearest, \"0.6\", \"0x0.a#3\", Greater);\n\n    test_one_over_sqrt_pi_prec_round_helper(4, Floor, \"0.56\", \"0x0.9#4\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(4, Ceiling, \"0.62\", \"0x0.a#4\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(4, Down, \"0.56\", \"0x0.9#4\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(4, Up, \"0.62\", \"0x0.a#4\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(4, Nearest, \"0.56\", \"0x0.9#4\", Less);\n\n    test_one_over_sqrt_pi_prec_round_helper(5, Floor, \"0.56\", \"0x0.90#5\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(5, Ceiling, \"0.59\", \"0x0.98#5\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(5, Down, \"0.56\", \"0x0.90#5\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(5, Up, \"0.59\", \"0x0.98#5\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(5, Nearest, \"0.56\", \"0x0.90#5\", Less);\n\n    test_one_over_sqrt_pi_prec_round_helper(6, Floor, \"0.56\", \"0x0.90#6\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(6, Ceiling, \"0.58\", \"0x0.94#6\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(6, Down, \"0.56\", \"0x0.90#6\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(6, Up, \"0.58\", \"0x0.94#6\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(6, Nearest, \"0.56\", \"0x0.90#6\", Less);\n\n    test_one_over_sqrt_pi_prec_round_helper(7, Floor, \"0.56\", \"0x0.90#7\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(7, Ceiling, \"0.57\", \"0x0.92#7\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(7, Down, \"0.56\", \"0x0.90#7\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(7, Up, \"0.57\", \"0x0.92#7\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(7, Nearest, \"0.56\", \"0x0.90#7\", Less);\n\n    test_one_over_sqrt_pi_prec_round_helper(8, Floor, \"0.562\", \"0x0.90#8\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(8, Ceiling, \"0.566\", \"0x0.91#8\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(8, Down, \"0.562\", \"0x0.90#8\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(8, Up, \"0.566\", \"0x0.91#8\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(8, Nearest, \"0.562\", \"0x0.90#8\", Less);\n\n    test_one_over_sqrt_pi_prec_round_helper(9, Floor, \"0.562\", \"0x0.900#9\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(9, Ceiling, \"0.564\", \"0x0.908#9\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(9, Down, \"0.562\", \"0x0.900#9\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(9, Up, \"0.564\", \"0x0.908#9\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(9, Nearest, \"0.564\", \"0x0.908#9\", Greater);\n\n    test_one_over_sqrt_pi_prec_round_helper(10, Floor, \"0.563\", \"0x0.904#10\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(10, Ceiling, \"0.564\", \"0x0.908#10\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(10, Down, \"0.563\", \"0x0.904#10\", Less);\n    test_one_over_sqrt_pi_prec_round_helper(10, Up, \"0.564\", \"0x0.908#10\", Greater);\n    test_one_over_sqrt_pi_prec_round_helper(10, Nearest, \"0.564\", \"0x0.908#10\", Greater);\n\n    test_one_over_sqrt_pi_prec_round_helper(\n        100,\n        Floor,\n        \"0.56418958354775628694807945156\",\n        \"0x0.906eba8214db688d71d48a7f6#100\",\n        Less,\n    );\n    test_one_over_sqrt_pi_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.564189583547756286948079451561\",\n        \"0x0.906eba8214db688d71d48a7f7#100\",\n        Greater,\n    );\n    test_one_over_sqrt_pi_prec_round_helper(\n        100,\n        Down,\n        \"0.56418958354775628694807945156\",\n        \"0x0.906eba8214db688d71d48a7f6#100\",\n        Less,\n    );\n    test_one_over_sqrt_pi_prec_round_helper(\n        100,\n        Up,\n        \"0.564189583547756286948079451561\",\n        \"0x0.906eba8214db688d71d48a7f7#100\",\n        Greater,\n    );\n    test_one_over_sqrt_pi_prec_round_helper(\n        100,\n        Nearest,\n        \"0.564189583547756286948079451561\",\n        \"0x0.906eba8214db688d71d48a7f7#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_pi_prec_round_fail_1() {\n    Float::one_over_sqrt_pi_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_pi_prec_round_fail_2() {\n    Float::one_over_sqrt_pi_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_pi_prec_round_fail_3() {\n    Float::one_over_sqrt_pi_prec_round(1000, Exact);\n}\n\n#[test]\nfn one_over_sqrt_pi_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (one_over_sqrt_pi, o) = Float::one_over_sqrt_pi_prec(prec);\n        assert!(one_over_sqrt_pi.is_valid());\n        assert_eq!(one_over_sqrt_pi.get_prec(), Some(prec));\n        assert_eq!(one_over_sqrt_pi.get_exponent(), Some(0));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (one_over_sqrt_pi_alt, o_alt) = Float::one_over_sqrt_pi_prec_round(prec, Ceiling);\n            let mut next_upper = one_over_sqrt_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(one_over_sqrt_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !one_over_sqrt_pi.is_power_of_2() {\n            let (one_over_sqrt_pi_alt, o_alt) = Float::one_over_sqrt_pi_prec_round(prec, Floor);\n            let mut next_lower = one_over_sqrt_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(one_over_sqrt_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (one_over_sqrt_pi_alt, o_alt) = Float::one_over_sqrt_pi_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&one_over_sqrt_pi_alt),\n            ComparableFloatRef(&one_over_sqrt_pi)\n        );\n        assert_eq!(o_alt, o);\n\n        let (one_over_sqrt_pi_alt, o_alt) = one_over_sqrt_pi_prec_round_simple(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&one_over_sqrt_pi_alt),\n            ComparableFloatRef(&one_over_sqrt_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn one_over_sqrt_pi_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (one_over_sqrt_pi, o) = Float::one_over_sqrt_pi_prec_round(prec, rm);\n        assert!(one_over_sqrt_pi.is_valid());\n        assert_eq!(one_over_sqrt_pi.get_prec(), Some(prec));\n        assert_eq!(\n            one_over_sqrt_pi.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                1\n            } else {\n                0\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (one_over_sqrt_pi_alt, o_alt) = Float::one_over_sqrt_pi_prec_round(prec, Ceiling);\n            let mut next_upper = one_over_sqrt_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(one_over_sqrt_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !one_over_sqrt_pi.is_power_of_2() {\n            let (one_over_sqrt_pi_alt, o_alt) = Float::one_over_sqrt_pi_prec_round(prec, Floor);\n            let mut next_lower = one_over_sqrt_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(one_over_sqrt_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n\n        let (one_over_sqrt_pi_alt, o_alt) = one_over_sqrt_pi_prec_round_simple(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&one_over_sqrt_pi_alt),\n            ComparableFloatRef(&one_over_sqrt_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::one_over_sqrt_pi_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::one_over_sqrt_pi_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/one_over_sqrt_tau.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::OneOverSqrtTau;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::one_over_sqrt_tau::one_over_sqrt_tau_prec_round_simple;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_one_over_sqrt_tau_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::one_over_sqrt_tau_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = one_over_sqrt_tau_prec_round_simple(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_one_over_sqrt_tau_prec() {\n    test_one_over_sqrt_tau_prec_helper(1, \"0.5\", \"0x0.8#1\", Greater);\n    test_one_over_sqrt_tau_prec_helper(2, \"0.4\", \"0x0.6#2\", Less);\n    test_one_over_sqrt_tau_prec_helper(3, \"0.38\", \"0x0.6#3\", Less);\n    test_one_over_sqrt_tau_prec_helper(4, \"0.41\", \"0x0.68#4\", Greater);\n    test_one_over_sqrt_tau_prec_helper(5, \"0.41\", \"0x0.68#5\", Greater);\n    test_one_over_sqrt_tau_prec_helper(6, \"0.4\", \"0x0.66#6\", Less);\n    test_one_over_sqrt_tau_prec_helper(7, \"0.398\", \"0x0.66#7\", Less);\n    test_one_over_sqrt_tau_prec_helper(8, \"0.398\", \"0x0.660#8\", Less);\n    test_one_over_sqrt_tau_prec_helper(9, \"0.399\", \"0x0.664#9\", Greater);\n    test_one_over_sqrt_tau_prec_helper(10, \"0.3989\", \"0x0.662#10\", Less);\n    test_one_over_sqrt_tau_prec_helper(\n        100,\n        \"0.3989422804014326779399460599344\",\n        \"0x0.662114cf50d942343f2cf14030#100\",\n        Greater,\n    );\n    test_one_over_sqrt_tau_prec_helper(\n        1000,\n        \"0.398942280401432677939946059934381868475858631164934657665925829670657925899301838501252\\\n        333907306936430302558862635182685510991954555837242996212730625507706345270582720499317564\\\n        516345807530597253642732083669593478271702999186419063456032808933388606704653652796716869\\\n        34195477117721206532537536913347877\",\n        \"0x0.662114cf50d942343f2cf1402eae38bfd3829f30512706d8c0471b4802639d2e9df8ac55447d3db723f5d\\\n        3abb374e88deb14277970be1513278e993445f08cff98282e1fd947ce4b4ecdbd6e65c23395cacb544de69eea3\\\n        2c276937b1bc567691c1cec4882c77aacefe1f6708329ab3fc8d2ab2435ee45c9150c426bbb8#1000\",\n        Greater,\n    );\n    test_one_over_sqrt_tau_prec_helper(\n        10000,\n        \"0.398942280401432677939946059934381868475858631164934657665925829670657925899301838501252\\\n        333907306936430302558862635182685510991954555837242996212730625507706345270582720499317564\\\n        516345807530597253642732083669593478271702999186419063456032808933388606704653652796716869\\\n        341954771177212065325375369133478750560424055704884258180482317903772804997176338575363992\\\n        839140318693283694771754858239775054447927761155070412703969672485047337603814813923901300\\\n        564676023356305570085700726641100015721563953577823123410952609069269089244567245554672105\\\n        743928915256735109303850680783183519806551964687438189980165959781887721458861617459900501\\\n        712960940366313293846201865045309966814316491432421060417455294539282219688799792718106125\\\n        413701644536367652874648406122597740302757632013709422194511725465470758442141422502838061\\\n        868594135257554774549801530578349147613022007422892027821093302633276582742943413612643384\\\n        980057963587894437275171155013545859889393745518894340738320491519829619307071761750803329\\\n        086547364282269194590675379988171293765563498747919820220506439472756588960162518241653865\\\n        682958549834199174484028901472961826557349795720893467152719051181680313262827229623899368\\\n        921510110599838914400198674472347351963204746387291915197608912260762509601476407511767145\\\n        433601016214971648007948262922613392149108721308143700798328558749768734347897980278300510\\\n        262826071460132831874309251391448950500864351371232094749134907629411222727979591421075299\\\n        673747197316387505002135776055200631744235271327518724616860849157649748825471682030207497\\\n        062098265106007658380606023541897775864990099263845899892122682397288552012228221816314178\\\n        308158121229466255828963270625452661691131034742094301703313846663457879729080007652468485\\\n        334179957678287388085633885615200206213603246796710415477475796066423508536474271747792912\\\n        434828025073907614687889180477807434263307378988209019313548164988087811605658554801862326\\\n        665697388456830642702724077905143312033897044455936044032662126236766581278672374404901166\\\n        564541339777091280689982201428151967506588958639140595771858450705515561437105861118338079\\\n        716914044380378761129991061804988776438561675358245271277544532102159485888359954032827725\\\n        246069745445363049745582651877816164759265756297881307521577254233707200857137834531266312\\\n        782357208128645404040264033722898206313179116571251682514874032991214269126845955003622262\\\n        315257794830645021004783385421309666323873108778765242160746712375568508761910339254792109\\\n        211573641128195708927088639062119252851547796326120921969626873693129996429236958310270565\\\n        733834386378238052071363813152698866481153604716886972531676903101376207010580993776843055\\\n        041892765565102116589831129651509557052479656507203268313538993083521906924099338259623407\\\n        406961415103750340216958051666093814503142437034516561361464323353515610162799624281647911\\\n        127783108359666320819610363671588870086956238204933545154454220560124064024272600360105966\\\n        644223437056162524970715123219160940261473588761105521231222473362842356480453287247436537\\\n        04133401719034564232591496298172511220088055\",\n        \"0x0.662114cf50d942343f2cf1402eae38bfd3829f30512706d8c0471b4802639d2e9df8ac55447d3db723f5d\\\n        3abb374e88deb14277970be1513278e993445f08cff98282e1fd947ce4b4ecdbd6e65c23395cacb544de69eea3\\\n        2c276937b1bc567691c1cec4882c77aacefe1f6708329ab3fc8d2ab2435ee45c9150c426bbb49487e480d8928e\\\n        623122d2369599582a3983769e7329865c92193ed298857cb81ab87659565e91e51487afe60871d04a18e432e6\\\n        bff594c697ed53f9d0aaf01aa890d8b742ca9e5ec8b5ea95546cad1961020feb8ed1ea218282c79079f714f4a0\\\n        bfda67f0e5ab81ec651ef4167fcf0e311b0d6b17578cbb5c65b311eb9071956748defa26992503a86e8300c9f5\\\n        082467be471e1dec4e7e1e9180296a90caadaed32e1972f7d51f05d9bcb5a7fe9f37a2d620cd24a3f28575328d\\\n        854f7a09661928fa57a78ad7d45d31fdb6377ddd63a6b7ce9fcd58c0ea0d7d36a37179fa5dd9215dde6682b2d8\\\n        6a8158f30670945f1eede2fd6ca404d7795a848aa442b3106116c7e9a212cdf14506bbc1ac9ab8d9b98bfd767b\\\n        d58e4a529fcb015285a0779f53c3be9533137bac5c5f90226a7534c7a819995ffae2499426d04682ef71cbbb0b\\\n        0e3261ce51b1494f21861a1750090850f2ae343d0a6e302b563eac32d234a07be481f2e2f16df62fb78e9e342d\\\n        6d3029d2c37a03cbaae2fdc23728ea3136432daed576883b9fe332b136f979cb9de719361019e6e62aa7893d43\\\n        6a8e51246e9378a70b92afcc9323b414f4de095326a8ef23d71049f3e05b326ad299d22fc0bc8b809450180fef\\\n        478554821b4ee6e0357f88b14350f4e77386b505ad7c8fa32a5b42163de45cf7b41ad63c4aed86175ef1028a0d\\\n        932b739351783a42c771c6967ea9212f2c8e86616639d9705a45299031b722cafe8f6042a968f1e5aee9c73c6b\\\n        a50c6af3a2598b0e128dbf85be2f3a60df9fb6f48a8ee7162d7013b3c1ca232deae1b39f0d797180f7a6a752a6\\\n        83690e26925c1b164a07f4ac2cb0c0ad0145ef80be80744063f6bc1ef94fc58e85283f61fa89f784b8d0679fc2\\\n        3f82e80dc04e91054d8cb75f64dbcee3db4759684165e5c21e0a98b9e88456e5c5444a353a73991f4fef88ee23\\\n        9e8cb2fc7152d3bdb119b8edb56206b31171a7eb12fac6cfba71c9341ef50a6863b38ab43747cfd41e062104bc\\\n        48549100e7b85f76b1989f0f72ef87e9cb989045f8500dfc329819b44464fa01750b5c8911a7b4776be2e27016\\\n        1f2ac11cea7136bce9f185370fc22fb213c3cbc9eca4d85875674085728a8d475b0cb557c00062f22e0de84560\\\n        33321dd367fc84751878bb1ebf079740abebbc8adce82e6ed570f9bb90f741f47f1ce9619b5f354c15a51894ea\\\n        e8f37251e6f6c2f24f191e380b3cf8f9550968d0b3628248974046f1ed6013aee5bb2817edf5276d43f1c894dd\\\n        4f87a770f11619efb6f33d62f037de3612014ab96d3ba744922006bd15b4c0e248bfc854e1f4666a12ee7d5bf3\\\n        765d35191b53037aa8e989ca2868ff144c1bc7b6867eea49a234b963f36812f0119d5b379e2db3e5f1cbf7cbe9\\\n        8f92866e1120d3ba1ae76dfaa31dd7cfc7b651b490b8a434b8def7a99cb6c880eac6e66bf16ad72ef5492adcb4\\\n        3ca05e0bab3fae213ca98d72f11460f81ef2366721c30053b2f769cb43c96a42504e21e504c86f85c4916dba52\\\n        de2edd93889cfd32b8ac6a59cb54912ec0c01f3dd79eaaea0699c78d5e8b7f1b5234617b1d10#10000\",\n        Less,\n    );\n\n    let one_over_sqrt_tau_f32 = Float::one_over_sqrt_tau_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(one_over_sqrt_tau_f32.to_string(), \"0.39894229\");\n    assert_eq!(to_hex_string(&one_over_sqrt_tau_f32), \"0x0.6621150#24\");\n    assert_eq!(one_over_sqrt_tau_f32, f32::ONE_OVER_SQRT_TAU);\n\n    let one_over_sqrt_tau_f64 = Float::one_over_sqrt_tau_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(one_over_sqrt_tau_f64.to_string(), \"0.3989422804014327\");\n    assert_eq!(\n        to_hex_string(&one_over_sqrt_tau_f64),\n        \"0x0.662114cf50d944#53\"\n    );\n    assert_eq!(one_over_sqrt_tau_f64, f64::ONE_OVER_SQRT_TAU);\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_tau_prec_fail_1() {\n    Float::one_over_sqrt_tau_prec(0);\n}\n\nfn test_one_over_sqrt_tau_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::one_over_sqrt_tau_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = one_over_sqrt_tau_prec_round_simple(prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_one_over_sqrt_tau_prec_round() {\n    test_one_over_sqrt_tau_prec_round_helper(1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Greater);\n\n    test_one_over_sqrt_tau_prec_round_helper(2, Floor, \"0.4\", \"0x0.6#2\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(2, Ceiling, \"0.5\", \"0x0.8#2\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(2, Down, \"0.4\", \"0x0.6#2\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(2, Up, \"0.5\", \"0x0.8#2\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(2, Nearest, \"0.4\", \"0x0.6#2\", Less);\n\n    test_one_over_sqrt_tau_prec_round_helper(3, Floor, \"0.38\", \"0x0.6#3\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(3, Ceiling, \"0.44\", \"0x0.7#3\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(3, Down, \"0.38\", \"0x0.6#3\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(3, Up, \"0.44\", \"0x0.7#3\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(3, Nearest, \"0.38\", \"0x0.6#3\", Less);\n\n    test_one_over_sqrt_tau_prec_round_helper(4, Floor, \"0.38\", \"0x0.60#4\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(4, Ceiling, \"0.41\", \"0x0.68#4\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(4, Down, \"0.38\", \"0x0.60#4\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(4, Up, \"0.41\", \"0x0.68#4\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(4, Nearest, \"0.41\", \"0x0.68#4\", Greater);\n\n    test_one_over_sqrt_tau_prec_round_helper(5, Floor, \"0.39\", \"0x0.64#5\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(5, Ceiling, \"0.41\", \"0x0.68#5\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(5, Down, \"0.39\", \"0x0.64#5\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(5, Up, \"0.41\", \"0x0.68#5\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(5, Nearest, \"0.41\", \"0x0.68#5\", Greater);\n\n    test_one_over_sqrt_tau_prec_round_helper(6, Floor, \"0.4\", \"0x0.66#6\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(6, Ceiling, \"0.406\", \"0x0.68#6\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(6, Down, \"0.4\", \"0x0.66#6\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(6, Up, \"0.406\", \"0x0.68#6\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(6, Nearest, \"0.4\", \"0x0.66#6\", Less);\n\n    test_one_over_sqrt_tau_prec_round_helper(7, Floor, \"0.398\", \"0x0.66#7\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(7, Ceiling, \"0.402\", \"0x0.67#7\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(7, Down, \"0.398\", \"0x0.66#7\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(7, Up, \"0.402\", \"0x0.67#7\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(7, Nearest, \"0.398\", \"0x0.66#7\", Less);\n\n    test_one_over_sqrt_tau_prec_round_helper(8, Floor, \"0.398\", \"0x0.660#8\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(8, Ceiling, \"0.4\", \"0x0.668#8\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(8, Down, \"0.398\", \"0x0.660#8\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(8, Up, \"0.4\", \"0x0.668#8\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(8, Nearest, \"0.398\", \"0x0.660#8\", Less);\n\n    test_one_over_sqrt_tau_prec_round_helper(9, Floor, \"0.398\", \"0x0.660#9\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(9, Ceiling, \"0.399\", \"0x0.664#9\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(9, Down, \"0.398\", \"0x0.660#9\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(9, Up, \"0.399\", \"0x0.664#9\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(9, Nearest, \"0.399\", \"0x0.664#9\", Greater);\n\n    test_one_over_sqrt_tau_prec_round_helper(10, Floor, \"0.3989\", \"0x0.662#10\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(10, Ceiling, \"0.3994\", \"0x0.664#10\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(10, Down, \"0.3989\", \"0x0.662#10\", Less);\n    test_one_over_sqrt_tau_prec_round_helper(10, Up, \"0.3994\", \"0x0.664#10\", Greater);\n    test_one_over_sqrt_tau_prec_round_helper(10, Nearest, \"0.3989\", \"0x0.662#10\", Less);\n\n    test_one_over_sqrt_tau_prec_round_helper(\n        100,\n        Floor,\n        \"0.3989422804014326779399460599341\",\n        \"0x0.662114cf50d942343f2cf14028#100\",\n        Less,\n    );\n    test_one_over_sqrt_tau_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.3989422804014326779399460599344\",\n        \"0x0.662114cf50d942343f2cf14030#100\",\n        Greater,\n    );\n    test_one_over_sqrt_tau_prec_round_helper(\n        100,\n        Down,\n        \"0.3989422804014326779399460599341\",\n        \"0x0.662114cf50d942343f2cf14028#100\",\n        Less,\n    );\n    test_one_over_sqrt_tau_prec_round_helper(\n        100,\n        Up,\n        \"0.3989422804014326779399460599344\",\n        \"0x0.662114cf50d942343f2cf14030#100\",\n        Greater,\n    );\n    test_one_over_sqrt_tau_prec_round_helper(\n        100,\n        Nearest,\n        \"0.3989422804014326779399460599344\",\n        \"0x0.662114cf50d942343f2cf14030#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_tau_prec_round_fail_1() {\n    Float::one_over_sqrt_tau_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_tau_prec_round_fail_2() {\n    Float::one_over_sqrt_tau_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn one_over_sqrt_tau_prec_round_fail_3() {\n    Float::one_over_sqrt_tau_prec_round(1000, Exact);\n}\n\n#[test]\nfn one_over_sqrt_tau_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (one_over_sqrt_tau, o) = Float::one_over_sqrt_tau_prec(prec);\n        assert!(one_over_sqrt_tau.is_valid());\n        assert_eq!(one_over_sqrt_tau.get_prec(), Some(prec));\n        assert_eq!(\n            one_over_sqrt_tau.get_exponent(),\n            Some(if prec == 1 { 0 } else { -1 })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (one_over_sqrt_tau_alt, o_alt) = Float::one_over_sqrt_tau_prec_round(prec, Ceiling);\n            let mut next_upper = one_over_sqrt_tau.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(one_over_sqrt_tau_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !one_over_sqrt_tau.is_power_of_2() {\n            let (one_over_sqrt_tau_alt, o_alt) = Float::one_over_sqrt_tau_prec_round(prec, Floor);\n            let mut next_lower = one_over_sqrt_tau.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(one_over_sqrt_tau_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (one_over_sqrt_tau_alt, o_alt) = Float::one_over_sqrt_tau_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&one_over_sqrt_tau_alt),\n            ComparableFloatRef(&one_over_sqrt_tau)\n        );\n        assert_eq!(o_alt, o);\n\n        let (one_over_sqrt_tau_alt, o_alt) = one_over_sqrt_tau_prec_round_simple(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&one_over_sqrt_tau_alt),\n            ComparableFloatRef(&one_over_sqrt_tau)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn one_over_sqrt_tau_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (one_over_sqrt_tau, o) = Float::one_over_sqrt_tau_prec_round(prec, rm);\n        assert!(one_over_sqrt_tau.is_valid());\n        assert_eq!(one_over_sqrt_tau.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 0,\n            _ => -1,\n        };\n        assert_eq!(one_over_sqrt_tau.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (one_over_sqrt_tau_alt, o_alt) = Float::one_over_sqrt_tau_prec_round(prec, Ceiling);\n            let mut next_upper = one_over_sqrt_tau.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(one_over_sqrt_tau_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !one_over_sqrt_tau.is_power_of_2() {\n            let (one_over_sqrt_tau_alt, o_alt) = Float::one_over_sqrt_tau_prec_round(prec, Floor);\n            let mut next_lower = one_over_sqrt_tau.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(one_over_sqrt_tau_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n\n        let (one_over_sqrt_tau_alt, o_alt) = one_over_sqrt_tau_prec_round_simple(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&one_over_sqrt_tau_alt),\n            ComparableFloatRef(&one_over_sqrt_tau)\n        );\n        assert_eq!(o_alt, o);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::one_over_sqrt_tau_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::one_over_sqrt_tau_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/phi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Phi;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_phi_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::phi_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_phi_prec() {\n    test_phi_prec_helper(1, \"2.0\", \"0x2.0#1\", Greater);\n    test_phi_prec_helper(2, \"1.5\", \"0x1.8#2\", Less);\n    test_phi_prec_helper(3, \"1.5\", \"0x1.8#3\", Less);\n    test_phi_prec_helper(4, \"1.6\", \"0x1.a#4\", Greater);\n    test_phi_prec_helper(5, \"1.62\", \"0x1.a#5\", Greater);\n    test_phi_prec_helper(6, \"1.62\", \"0x1.a0#6\", Greater);\n    test_phi_prec_helper(7, \"1.62\", \"0x1.a0#7\", Greater);\n    test_phi_prec_helper(8, \"1.617\", \"0x1.9e#8\", Less);\n    test_phi_prec_helper(9, \"1.617\", \"0x1.9e#9\", Less);\n    test_phi_prec_helper(10, \"1.617\", \"0x1.9e0#10\", Less);\n    test_phi_prec_helper(\n        100,\n        \"1.618033988749894848204586834366\",\n        \"0x1.9e3779b97f4a7c15f39cc0606#100\",\n        Greater,\n    );\n    test_phi_prec_helper(\n        1000,\n        \"1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207\\\n        204189391137484754088075386891752126633862223536931793180060766726354433389086595939582905\\\n        638322661319928290267880675208766892501711696207032221043216269548626296313614438149758701\\\n        2203408058879544547492461856953648\",\n        \"0x1.9e3779b97f4a7c15f39cc0605cedc8341082276bf3a27251f86c6a11d0c18e952767f0b153d27b7f03470\\\n        45b5bf1827f01886f0928403002c1d64ba40f335e36f06ad7ae9717877e85839d6effbd7dc664d325d1c537168\\\n        2cadd0cccfdffbbe1626e33b8d04b4331bbf73c790d94f79d471c4ab3ed3d82a5fec507705e#1000\",\n        Less,\n    );\n    test_phi_prec_helper(\n        10000,\n        \"1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207\\\n        204189391137484754088075386891752126633862223536931793180060766726354433389086595939582905\\\n        638322661319928290267880675208766892501711696207032221043216269548626296313614438149758701\\\n        220340805887954454749246185695364864449241044320771344947049565846788509874339442212544877\\\n        066478091588460749988712400765217057517978834166256249407589069704000281210427621771117778\\\n        053153171410117046665991466979873176135600670874807101317952368942752194843530567830022878\\\n        569978297783478458782289110976250030269615617002504643382437764861028383126833037242926752\\\n        631165339247316711121158818638513316203840052221657912866752946549068113171599343235973494\\\n        985090409476213222981017261070596116456299098162905552085247903524060201727997471753427775\\\n        927786256194320827505131218156285512224809394712341451702237358057727861600868838295230459\\\n        264787801788992199027077690389532196819861514378031499741106926088674296226757560523172777\\\n        520353613936210767389376455606060592165894667595519004005559089502295309423124823552122124\\\n        154440064703405657347976639723949499465845788730396230903750339938562102423690251386804145\\\n        779956981224457471780341731264532204163972321340444494873023154176768937521030687378803441\\\n        700939544096279558986787232095124268935573097045095956844017555198819218020640529055189349\\\n        475926007348522821010881946445442223188913192946896220023014437702699230078030852611807545\\\n        192887705021096842493627135925187607778846658361502389134933331223105339232136243192637289\\\n        106705033992822652635562090297986424727597725655086154875435748264718141451270006023890162\\\n        077732244994353088999095016803281121943204819643876758633147985719113978153978074761507722\\\n        117508269458639320456520989698555678141069683728840587461033781054443909436835835813811311\\\n        689938555769754841491445341509129540700501947754861630754226417293946803673198058618339183\\\n        285991303960720144559504497792120761247856459161608370594987860069701894098864007644361709\\\n        334172709191433650137157660114803814306262380514321173481510055901345610118007905063814215\\\n        270930858809287570345050780814545881990633612982798141174533927312080928972792221329806429\\\n        468782427487401745055406778757083237310975915117762978443284747908176518097787268416117632\\\n        503861211291436834376702350371116330725869883258710336322238109809012110198991768414917512\\\n        331340152733843837234500934786049792945991582201258104598230925528721241370436149102054718\\\n        554961180876426576511060545881475604431784798584539731286301625448761148520217064404111660\\\n        766950597757832570395110878230827106478939021115691039276838453863333215658296597731034360\\\n        323225457436372041244064088826737584339536795931232213437320995749889469956564736007295999\\\n        839128810319742631251797141432012311279551894778172691415891177991956481255800184550656329\\\n        528598591000908621802977563789259991649946428193022293552346674759326951654214021091363018\\\n        194722707890122087287361707348649998156255472811373479871656952748900814438405327483781378\\\n        2466917444229634914708157007352545707089773\",\n        \"0x1.9e3779b97f4a7c15f39cc0605cedc8341082276bf3a27251f86c6a11d0c18e952767f0b153d27b7f03470\\\n        45b5bf1827f01886f0928403002c1d64ba40f335e36f06ad7ae9717877e85839d6effbd7dc664d325d1c537168\\\n        2cadd0cccfdffbbe1626e33b8d04b4331bbf73c790d94f79d471c4ab3ed3d82a5fec507705e4ae6e5e73a9b91f\\\n        3aa4db287ae44f332e923a73cb91648e428e975a3781eb01b49d8674fa1508419e0eaa4038b352d9bad30f4485\\\n        b71a8ef64452a0dd40dc8cb8f9a2d4c514f1b229dcaa222ac268e9666e4a866769145f5f5880a9d0acd3b9e8c6\\\n        82f4f810320abeb94034e70f21608c061ab1c1caef1ebdcefbc72134ecf06ed82bfb7d8eb1a41901d65f5c8cab\\\n        2accbc32eab1fbe8284f2b44ba2e834c5893a39ea7865443f489c37f8742acd895afd87b467d22a40d098f30dd\\\n        2cafdeb3abb3a13507b46b3d757fc04001906e1767d40c3a3792a26eeef2ab5bd6685b915b5629400faa684ecb\\\n        a752dddcb5d18576d77b652ac0d999973686604128f0cd42743596deb2d42c789d64b92658610b5b95c719adeb\\\n        8ce287326344e31d59a59963220b1a4c42771d454ec78f12393bfb4ac54188e59113d7c35441f15aa34a114070\\\n        35f006fc3ad70fc0d6331c6d479f484bf39cbfbd95e664e39bebdc5b09d9d5b8f8905d9805c8199457d444a909\\\n        316cc58d38b3a25c714be8d422964e9724c033b6748acbc2e05caaf737c95622e6483fa0707999afc482995170\\\n        1c6ed5f27ce231770965541f5f28797f2fecbd984d3435ce547c88c38466e2865235683d4447e4b32757903058\\\n        ca11a903f3baa3864932b80a7d02d61b50c1ff281d5dd2947da4624bbc7c7b94962717aed284395c42f253c17f\\\n        492f401bb6c17a95c3296b424db05afa8e7ad2561aca1f4fd6e0eb57f831e40227fbacd467ff8b7f84370aef71\\\n        1857634d0cf4189002dde8787576c631f0b9a173c16b80e7d941c128a540c91d33a1daf0f0222986e3c7661b2a\\\n        7b374dc06d8396659e0fde9b7b41dc1bbb0f42988d4d2525906bdf64a6ea5b159f2adf7c883ce8c4808a9b46eb\\\n        960f74192010862bd1c306500c6795a0a29df4a34d42b1a418a9fbcabd51e1887aa0f8ebdf4452d6efb8d2948d\\\n        8878256e2c6c33dc8ca89d68e06aeabd56bca17dea2358e443b567201dbe25e06a7451a736b14cfe3af4385221\\\n        86524dad69f054b61cdbf1ba9a54f46ff7a2a1e5090e0a26dbe7766ebf40475a2f166ab6b1791b0ee0b48d863c\\\n        08f809967ac68a158a6b4eefe4fae8eb1d32cfa6a4573468c137401262ab7893a30cb015245b76fa16cf89db93\\\n        647bb74e2581ae8823d14c0343efb790b35764216428d6e9856dd074ee6f411ee1b5dd2a670cce122bf868be81\\\n        8525e08f5b8b3d940252b853b7248a83aa561610f17a35fc83e542a94fcb71694c229ef98f50746a08c3fcd875\\\n        ca4b94d390bba41e657f21892b6ee0ef705034accc46fc4e1af7e9a90ff984fc20bd9596a3da5beca81a0ac599\\\n        947c1f5eebf18b16c96a12face93501968c59c16f7cd92e8a58d472335d816bbb85e1caa23ed2a61cc0cdbbb37\\\n        00b8bb3f9669fc3590347bc63f4c5dcb9b2a8c174acbadbdef7dd61aa4dff59fb3adca34b37fd54fcdbdeb6824\\\n        16a89edc65754aadaa3d5d5f329b92a98a8f08c8d6b6197dec9b63286673d2123a78adb6e162b938081682e154\\\n        56856ea498bee3ac11a03804078c8426b1eeba9afe94a602b0aca31dcc753b038d74573c896#10000\",\n        Greater,\n    );\n\n    let phi_f32 = Float::phi_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(phi_f32.to_string(), \"1.618034\");\n    assert_eq!(to_hex_string(&phi_f32), \"0x1.9e377a#24\");\n    assert_eq!(phi_f32, f32::PHI);\n\n    let phi_f64 = Float::phi_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(phi_f64.to_string(), \"1.6180339887498949\");\n    assert_eq!(to_hex_string(&phi_f64), \"0x1.9e3779b97f4a8#53\");\n    assert_eq!(phi_f64, f64::PHI);\n}\n\n#[test]\n#[should_panic]\nfn phi_prec_fail_1() {\n    Float::phi_prec(0);\n}\n\nfn test_phi_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::phi_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_phi_prec_round() {\n    test_phi_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_phi_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_phi_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_phi_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_phi_prec_round_helper(1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test_phi_prec_round_helper(2, Floor, \"1.5\", \"0x1.8#2\", Less);\n    test_phi_prec_round_helper(2, Ceiling, \"2.0\", \"0x2.0#2\", Greater);\n    test_phi_prec_round_helper(2, Down, \"1.5\", \"0x1.8#2\", Less);\n    test_phi_prec_round_helper(2, Up, \"2.0\", \"0x2.0#2\", Greater);\n    test_phi_prec_round_helper(2, Nearest, \"1.5\", \"0x1.8#2\", Less);\n\n    test_phi_prec_round_helper(3, Floor, \"1.5\", \"0x1.8#3\", Less);\n    test_phi_prec_round_helper(3, Ceiling, \"1.8\", \"0x1.c#3\", Greater);\n    test_phi_prec_round_helper(3, Down, \"1.5\", \"0x1.8#3\", Less);\n    test_phi_prec_round_helper(3, Up, \"1.8\", \"0x1.c#3\", Greater);\n    test_phi_prec_round_helper(3, Nearest, \"1.5\", \"0x1.8#3\", Less);\n\n    test_phi_prec_round_helper(4, Floor, \"1.5\", \"0x1.8#4\", Less);\n    test_phi_prec_round_helper(4, Ceiling, \"1.6\", \"0x1.a#4\", Greater);\n    test_phi_prec_round_helper(4, Down, \"1.5\", \"0x1.8#4\", Less);\n    test_phi_prec_round_helper(4, Up, \"1.6\", \"0x1.a#4\", Greater);\n    test_phi_prec_round_helper(4, Nearest, \"1.6\", \"0x1.a#4\", Greater);\n\n    test_phi_prec_round_helper(5, Floor, \"1.56\", \"0x1.9#5\", Less);\n    test_phi_prec_round_helper(5, Ceiling, \"1.62\", \"0x1.a#5\", Greater);\n    test_phi_prec_round_helper(5, Down, \"1.56\", \"0x1.9#5\", Less);\n    test_phi_prec_round_helper(5, Up, \"1.62\", \"0x1.a#5\", Greater);\n    test_phi_prec_round_helper(5, Nearest, \"1.62\", \"0x1.a#5\", Greater);\n\n    test_phi_prec_round_helper(6, Floor, \"1.59\", \"0x1.98#6\", Less);\n    test_phi_prec_round_helper(6, Ceiling, \"1.62\", \"0x1.a0#6\", Greater);\n    test_phi_prec_round_helper(6, Down, \"1.59\", \"0x1.98#6\", Less);\n    test_phi_prec_round_helper(6, Up, \"1.62\", \"0x1.a0#6\", Greater);\n    test_phi_prec_round_helper(6, Nearest, \"1.62\", \"0x1.a0#6\", Greater);\n\n    test_phi_prec_round_helper(7, Floor, \"1.61\", \"0x1.9c#7\", Less);\n    test_phi_prec_round_helper(7, Ceiling, \"1.62\", \"0x1.a0#7\", Greater);\n    test_phi_prec_round_helper(7, Down, \"1.61\", \"0x1.9c#7\", Less);\n    test_phi_prec_round_helper(7, Up, \"1.62\", \"0x1.a0#7\", Greater);\n    test_phi_prec_round_helper(7, Nearest, \"1.62\", \"0x1.a0#7\", Greater);\n\n    test_phi_prec_round_helper(8, Floor, \"1.617\", \"0x1.9e#8\", Less);\n    test_phi_prec_round_helper(8, Ceiling, \"1.625\", \"0x1.a0#8\", Greater);\n    test_phi_prec_round_helper(8, Down, \"1.617\", \"0x1.9e#8\", Less);\n    test_phi_prec_round_helper(8, Up, \"1.625\", \"0x1.a0#8\", Greater);\n    test_phi_prec_round_helper(8, Nearest, \"1.617\", \"0x1.9e#8\", Less);\n\n    test_phi_prec_round_helper(9, Floor, \"1.617\", \"0x1.9e#9\", Less);\n    test_phi_prec_round_helper(9, Ceiling, \"1.621\", \"0x1.9f#9\", Greater);\n    test_phi_prec_round_helper(9, Down, \"1.617\", \"0x1.9e#9\", Less);\n    test_phi_prec_round_helper(9, Up, \"1.621\", \"0x1.9f#9\", Greater);\n    test_phi_prec_round_helper(9, Nearest, \"1.617\", \"0x1.9e#9\", Less);\n\n    test_phi_prec_round_helper(10, Floor, \"1.617\", \"0x1.9e0#10\", Less);\n    test_phi_prec_round_helper(10, Ceiling, \"1.619\", \"0x1.9e8#10\", Greater);\n    test_phi_prec_round_helper(10, Down, \"1.617\", \"0x1.9e0#10\", Less);\n    test_phi_prec_round_helper(10, Up, \"1.619\", \"0x1.9e8#10\", Greater);\n    test_phi_prec_round_helper(10, Nearest, \"1.617\", \"0x1.9e0#10\", Less);\n\n    test_phi_prec_round_helper(\n        100,\n        Floor,\n        \"1.618033988749894848204586834364\",\n        \"0x1.9e3779b97f4a7c15f39cc0604#100\",\n        Less,\n    );\n    test_phi_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.618033988749894848204586834366\",\n        \"0x1.9e3779b97f4a7c15f39cc0606#100\",\n        Greater,\n    );\n    test_phi_prec_round_helper(\n        100,\n        Down,\n        \"1.618033988749894848204586834364\",\n        \"0x1.9e3779b97f4a7c15f39cc0604#100\",\n        Less,\n    );\n    test_phi_prec_round_helper(\n        100,\n        Up,\n        \"1.618033988749894848204586834366\",\n        \"0x1.9e3779b97f4a7c15f39cc0606#100\",\n        Greater,\n    );\n    test_phi_prec_round_helper(\n        100,\n        Nearest,\n        \"1.618033988749894848204586834366\",\n        \"0x1.9e3779b97f4a7c15f39cc0606#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn phi_prec_round_fail_1() {\n    Float::phi_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn phi_prec_round_fail_2() {\n    Float::phi_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn phi_prec_round_fail_3() {\n    Float::phi_prec_round(1000, Exact);\n}\n\n#[test]\nfn phi_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (phi, o) = Float::phi_prec(prec);\n        assert!(phi.is_valid());\n        assert_eq!(phi.get_prec(), Some(prec));\n        assert_eq!(phi.get_exponent(), Some(if prec == 1 { 2 } else { 1 }));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (phi_alt, o_alt) = Float::phi_prec_round(prec, Ceiling);\n            let mut next_upper = phi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(phi_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !phi.is_power_of_2() {\n            let (phi_alt, o_alt) = Float::phi_prec_round(prec, Floor);\n            let mut next_lower = phi.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(phi_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (phi_alt, o_alt) = Float::phi_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&phi_alt), ComparableFloatRef(&phi));\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn phi_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (phi, o) = Float::phi_prec_round(prec, rm);\n        assert!(phi.is_valid());\n        assert_eq!(phi.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 2,\n            _ => 1,\n        };\n        assert_eq!(phi.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (phi_alt, o_alt) = Float::phi_prec_round(prec, Ceiling);\n            let mut next_upper = phi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(phi_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !phi.is_power_of_2() {\n            let (phi_alt, o_alt) = Float::phi_prec_round(prec, Floor);\n            let mut next_lower = phi.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(phi_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::phi_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::phi_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Pi;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{\n    rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::constants::pi::rug_pi_prec_round;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_pi_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::pi_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (rug_x, rug_o) =\n        rug_pi_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_x)),\n        ComparableFloatRef(&x)\n    );\n    assert_eq!(rug_o, o);\n}\n\nfn test_pi_prec_helper_big(prec: u64) {\n    let (x, o) = Float::pi_prec(prec);\n    assert!(x.is_valid());\n\n    let (rug_x, rug_o) =\n        rug_pi_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_x)),\n        ComparableFloatRef(&x)\n    );\n    assert_eq!(rug_o, o);\n}\n\n#[test]\npub fn test_pi_prec() {\n    test_pi_prec_helper(1, \"4.0\", \"0x4.0#1\", Greater);\n    test_pi_prec_helper(2, \"3.0\", \"0x3.0#2\", Less);\n    test_pi_prec_helper(3, \"3.0\", \"0x3.0#3\", Less);\n    test_pi_prec_helper(4, \"3.2\", \"0x3.4#4\", Greater);\n    test_pi_prec_helper(5, \"3.1\", \"0x3.2#5\", Less);\n    test_pi_prec_helper(6, \"3.12\", \"0x3.2#6\", Less);\n    test_pi_prec_helper(7, \"3.16\", \"0x3.28#7\", Greater);\n    test_pi_prec_helper(8, \"3.14\", \"0x3.24#8\", Less);\n    test_pi_prec_helper(9, \"3.14\", \"0x3.24#9\", Less);\n    test_pi_prec_helper(10, \"3.141\", \"0x3.24#10\", Less);\n    test_pi_prec_helper(\n        100,\n        \"3.141592653589793238462643383279\",\n        \"0x3.243f6a8885a308d313198a2e0#100\",\n        Less,\n    );\n    test_pi_prec_helper(\n        1000,\n        \"3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034\\\n        825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105\\\n        559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348\\\n        6104543266482133936072602491412736\",\n        \"0x3.243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89452821e638d01377be546\\\n        6cf34e90c6cc0ac29b7c97c50dd3f84d5b5b54709179216d5d98979fb1bd1310ba698dfb5ac2ffd72dbd01adfb\\\n        7b8e1afed6a267e96ba7c9045f12c7f9924a19947b3916cf70801f2e2858efc16636920d870#1000\",\n        Less,\n    );\n    test_pi_prec_helper(\n        10000,\n        \"3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034\\\n        825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105\\\n        559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348\\\n        610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590\\\n        360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118\\\n        548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224\\\n        737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771\\\n        342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021\\\n        960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459\\\n        455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147\\\n        303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195\\\n        909216420198938095257201065485863278865936153381827968230301952035301852968995773622599413\\\n        891249721775283479131515574857242454150695950829533116861727855889075098381754637464939319\\\n        255060400927701671139009848824012858361603563707660104710181942955596198946767837449448255\\\n        379774726847104047534646208046684259069491293313677028989152104752162056966024058038150193\\\n        511253382430035587640247496473263914199272604269922796782354781636009341721641219924586315\\\n        030286182974555706749838505494588586926995690927210797509302955321165344987202755960236480\\\n        665499119881834797753566369807426542527862551818417574672890977772793800081647060016145249\\\n        192173217214772350141441973568548161361157352552133475741849468438523323907394143334547762\\\n        416862518983569485562099219222184272550254256887671790494601653466804988627232791786085784\\\n        383827967976681454100953883786360950680064225125205117392984896084128488626945604241965285\\\n        022210661186306744278622039194945047123713786960956364371917287467764657573962413890865832\\\n        645995813390478027590099465764078951269468398352595709825822620522489407726719478268482601\\\n        476990902640136394437455305068203496252451749399651431429809190659250937221696461515709858\\\n        387410597885959772975498930161753928468138268683868942774155991855925245953959431049972524\\\n        680845987273644695848653836736222626099124608051243884390451244136549762780797715691435997\\\n        700129616089441694868555848406353422072225828488648158456028506016842739452267467678895252\\\n        138522549954666727823986456596116354886230577456498035593634568174324112515076069479451096\\\n        596094025228879710893145669136867228748940560101503308617928680920874760917824938589009714\\\n        909675985261365549781893129784821682998948722658804857564014270477555132379641451523746234\\\n        364542858444795265867821051141354735739523113427166102135969536231442952484937187110145765\\\n        403590279934403742007310578539062198387447808478489683321445713868751943506430218453191048\\\n        481005370614680674919278191197939952061419663428754440643745123718192179998391015919561814\\\n        675142691239748940907186494231961567945208\",\n        \"0x3.243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89452821e638d01377be546\\\n        6cf34e90c6cc0ac29b7c97c50dd3f84d5b5b54709179216d5d98979fb1bd1310ba698dfb5ac2ffd72dbd01adfb\\\n        7b8e1afed6a267e96ba7c9045f12c7f9924a19947b3916cf70801f2e2858efc16636920d871574e69a458fea3f\\\n        4933d7e0d95748f728eb658718bcd5882154aee7b54a41dc25a59b59c30d5392af26013c5d1b023286085f0ca4\\\n        17918b8db38ef8e79dcb0603a180e6c9e0e8bb01e8a3ed71577c1bd314b2778af2fda55605c60e65525f3aa55a\\\n        b945748986263e8144055ca396a2aab10b6b4cc5c341141e8cea15486af7c72e993b3ee1411636fbc2a2ba9c55\\\n        d741831f6ce5c3e169b87931eafd6ba336c24cf5c7a325381289586773b8f48986b4bb9afc4bfe81b662821936\\\n        1d809ccfb21a991487cac605dec8032ef845d5de98575b1dc262302eb651b8823893e81d396acc50f6d6ff383f\\\n        442392e0b4482a484200469c8f04a9e1f9b5e21c66842f6e96c9a670c9c61abd388f06a51a0d2d8542f68960fa\\\n        728ab5133a36eef0b6c137a3be4ba3bf0507efb2a98a1f1651d39af017666ca593e82430e888cee8619456f9fb\\\n        47d84a5c33b8b5ebee06f75d885c12073401a449f56c16aa64ed3aa62363f77061bfedf72429b023d37d0d724d\\\n        00a1248db0fead349f1c09b075372c980991b7b25d479d8f6e8def7e3fe501ab6794c3b976ce0bd04c006bac1a\\\n        94fb6409f60c45e5c9ec2196a246368fb6faf3e6c53b51339b2eb3b52ec6f6dfc511f9b30952ccc814544af5eb\\\n        d09bee3d004de334afd660f2807192e4bb3c0cba85745c8740fd20b5f39b9d3fbdb5579c0bd1a60320ad6a100c\\\n        6402c7279679f25fefb1fa3cc8ea5e9f8db3222f83c7516dffd616b152f501ec8ad0552ab323db5fafd2387605\\\n        3317b483e00df829e5c57bbca6f8ca01a87562edf1769dbd542a8f6287effc3ac6732c68c4f5573695b27b0bbc\\\n        a58c8e1ffa35db8f011a010fa3d98fd2183b84afcb56c2dd1d35b9a53e479b6f84565d28e49bc4bfb9790e1ddf\\\n        2daa4cb7e3362fb1341cee4c6e8ef20cada36774c01d07e9efe2bf11fb495dbda4dae909198eaad8e716b93d5a\\\n        0d08ed1d0afc725e08e3c5b2f8e7594b78ff6e2fbf2122b648888b812900df01c4fad5ea0688fc31cd1cff191b\\\n        3a8c1ad2f2f2218be0e1777ea752dfe8b021fa1e5a0cc0fb56f74e818acf3d6ce89e299b4a84fe0fd13e0b77cc\\\n        43b81d2ada8d9165fa2668095770593cc7314211a1477e6ad206577b5fa86c75442f5fb9d35cfebcdaf0c7b3e8\\\n        9a0d6411bd3ae1e7e4900250e2d2071b35e226800bb57b8e0af2464369bf009b91e5563911d59dfa6aa78c1438\\\n        9d95a537f207d5ba202e5b9c5832603766295cfa911c819684e734a41b3472dca7b14a94a1b5100529a532915d\\\n        60f573fbc9bc6e42b60a47681e6740008ba6fb5571be91ff296ec6b2a0dd915b6636521e7b9f9b6ff34052ec58\\\n        5566453b02d5da99f8fa108ba47996e85076a4b7a70e9b5b32944db75092ec4192623ad6ea6b049a7df7d9cee6\\\n        0b88fedb266ecaa8c71699a17ff5664526cc2b19ee1193602a575094c29a0591340e4183a3e3f54989a5b429d6\\\n        56b8fe4d699f73fd6a1d29c07efe830f54d2d38e6f0255dc14cdd20868470eb266382e9c6021ecc5e09686b3f3\\\n        ebaefc93c9718146b6a70a1687f358452a0e286b79c5305aa5007373e07841c7fdeae5c8e7c#10000\",\n        Less,\n    );\n    test_pi_prec_helper_big(1000000);\n\n    let pi_f32 = Float::pi_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_f32.to_string(), \"3.1415927\");\n    assert_eq!(to_hex_string(&pi_f32), \"0x3.243f6c#24\");\n    assert_eq!(pi_f32, f32::PI);\n\n    let pi_f64 = Float::pi_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_f64.to_string(), \"3.1415926535897931\");\n    assert_eq!(to_hex_string(&pi_f64), \"0x3.243f6a8885a30#53\");\n    assert_eq!(pi_f64, f64::PI);\n}\n\n#[test]\n#[should_panic]\nfn pi_prec_fail_1() {\n    Float::pi_prec(0);\n}\n\nfn test_pi_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::pi_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_x, rug_o) = rug_pi_prec_round(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_x)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(rug_o, o);\n    }\n}\n\n#[test]\npub fn test_pi_prec_round() {\n    test_pi_prec_round_helper(1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test_pi_prec_round_helper(1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test_pi_prec_round_helper(1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test_pi_prec_round_helper(1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test_pi_prec_round_helper(1, Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test_pi_prec_round_helper(2, Floor, \"3.0\", \"0x3.0#2\", Less);\n    test_pi_prec_round_helper(2, Ceiling, \"4.0\", \"0x4.0#2\", Greater);\n    test_pi_prec_round_helper(2, Down, \"3.0\", \"0x3.0#2\", Less);\n    test_pi_prec_round_helper(2, Up, \"4.0\", \"0x4.0#2\", Greater);\n    test_pi_prec_round_helper(2, Nearest, \"3.0\", \"0x3.0#2\", Less);\n\n    test_pi_prec_round_helper(3, Floor, \"3.0\", \"0x3.0#3\", Less);\n    test_pi_prec_round_helper(3, Ceiling, \"3.5\", \"0x3.8#3\", Greater);\n    test_pi_prec_round_helper(3, Down, \"3.0\", \"0x3.0#3\", Less);\n    test_pi_prec_round_helper(3, Up, \"3.5\", \"0x3.8#3\", Greater);\n    test_pi_prec_round_helper(3, Nearest, \"3.0\", \"0x3.0#3\", Less);\n\n    test_pi_prec_round_helper(4, Floor, \"3.0\", \"0x3.0#4\", Less);\n    test_pi_prec_round_helper(4, Ceiling, \"3.2\", \"0x3.4#4\", Greater);\n    test_pi_prec_round_helper(4, Down, \"3.0\", \"0x3.0#4\", Less);\n    test_pi_prec_round_helper(4, Up, \"3.2\", \"0x3.4#4\", Greater);\n    test_pi_prec_round_helper(4, Nearest, \"3.2\", \"0x3.4#4\", Greater);\n\n    test_pi_prec_round_helper(5, Floor, \"3.1\", \"0x3.2#5\", Less);\n    test_pi_prec_round_helper(5, Ceiling, \"3.2\", \"0x3.4#5\", Greater);\n    test_pi_prec_round_helper(5, Down, \"3.1\", \"0x3.2#5\", Less);\n    test_pi_prec_round_helper(5, Up, \"3.2\", \"0x3.4#5\", Greater);\n    test_pi_prec_round_helper(5, Nearest, \"3.1\", \"0x3.2#5\", Less);\n\n    test_pi_prec_round_helper(6, Floor, \"3.12\", \"0x3.2#6\", Less);\n    test_pi_prec_round_helper(6, Ceiling, \"3.19\", \"0x3.3#6\", Greater);\n    test_pi_prec_round_helper(6, Down, \"3.12\", \"0x3.2#6\", Less);\n    test_pi_prec_round_helper(6, Up, \"3.19\", \"0x3.3#6\", Greater);\n    test_pi_prec_round_helper(6, Nearest, \"3.12\", \"0x3.2#6\", Less);\n\n    test_pi_prec_round_helper(7, Floor, \"3.12\", \"0x3.20#7\", Less);\n    test_pi_prec_round_helper(7, Ceiling, \"3.16\", \"0x3.28#7\", Greater);\n    test_pi_prec_round_helper(7, Down, \"3.12\", \"0x3.20#7\", Less);\n    test_pi_prec_round_helper(7, Up, \"3.16\", \"0x3.28#7\", Greater);\n    test_pi_prec_round_helper(7, Nearest, \"3.16\", \"0x3.28#7\", Greater);\n\n    test_pi_prec_round_helper(8, Floor, \"3.14\", \"0x3.24#8\", Less);\n    test_pi_prec_round_helper(8, Ceiling, \"3.16\", \"0x3.28#8\", Greater);\n    test_pi_prec_round_helper(8, Down, \"3.14\", \"0x3.24#8\", Less);\n    test_pi_prec_round_helper(8, Up, \"3.16\", \"0x3.28#8\", Greater);\n    test_pi_prec_round_helper(8, Nearest, \"3.14\", \"0x3.24#8\", Less);\n\n    test_pi_prec_round_helper(9, Floor, \"3.14\", \"0x3.24#9\", Less);\n    test_pi_prec_round_helper(9, Ceiling, \"3.15\", \"0x3.26#9\", Greater);\n    test_pi_prec_round_helper(9, Down, \"3.14\", \"0x3.24#9\", Less);\n    test_pi_prec_round_helper(9, Up, \"3.15\", \"0x3.26#9\", Greater);\n    test_pi_prec_round_helper(9, Nearest, \"3.14\", \"0x3.24#9\", Less);\n\n    test_pi_prec_round_helper(10, Floor, \"3.141\", \"0x3.24#10\", Less);\n    test_pi_prec_round_helper(10, Ceiling, \"3.145\", \"0x3.25#10\", Greater);\n    test_pi_prec_round_helper(10, Down, \"3.141\", \"0x3.24#10\", Less);\n    test_pi_prec_round_helper(10, Up, \"3.145\", \"0x3.25#10\", Greater);\n    test_pi_prec_round_helper(10, Nearest, \"3.141\", \"0x3.24#10\", Less);\n\n    test_pi_prec_round_helper(\n        100,\n        Floor,\n        \"3.141592653589793238462643383279\",\n        \"0x3.243f6a8885a308d313198a2e0#100\",\n        Less,\n    );\n    test_pi_prec_round_helper(\n        100,\n        Ceiling,\n        \"3.141592653589793238462643383282\",\n        \"0x3.243f6a8885a308d313198a2e4#100\",\n        Greater,\n    );\n    test_pi_prec_round_helper(\n        100,\n        Down,\n        \"3.141592653589793238462643383279\",\n        \"0x3.243f6a8885a308d313198a2e0#100\",\n        Less,\n    );\n    test_pi_prec_round_helper(\n        100,\n        Up,\n        \"3.141592653589793238462643383282\",\n        \"0x3.243f6a8885a308d313198a2e4#100\",\n        Greater,\n    );\n    test_pi_prec_round_helper(\n        100,\n        Nearest,\n        \"3.141592653589793238462643383279\",\n        \"0x3.243f6a8885a308d313198a2e0#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn pi_prec_round_fail_1() {\n    Float::pi_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn pi_prec_round_fail_2() {\n    Float::pi_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn pi_prec_round_fail_3() {\n    Float::pi_prec_round(1000, Exact);\n}\n\n#[test]\nfn pi_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (pi, o) = Float::pi_prec(prec);\n        assert!(pi.is_valid());\n        assert_eq!(pi.get_prec(), Some(prec));\n        assert_eq!(pi.get_exponent(), Some(if prec == 1 { 3 } else { 2 }));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_alt, o_alt) = Float::pi_prec_round(prec, Ceiling);\n            let mut next_upper = pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi.is_power_of_2() {\n            let (pi_alt, o_alt) = Float::pi_prec_round(prec, Floor);\n            let mut next_lower = pi.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (pi_alt, o_alt) = Float::pi_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&pi_alt), ComparableFloatRef(&pi));\n        assert_eq!(o_alt, o);\n\n        let (rug_pi, rug_o) =\n            rug_pi_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_pi)),\n            ComparableFloatRef(&pi)\n        );\n        assert_eq!(rug_o, o);\n    });\n}\n\n#[test]\nfn pi_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (pi, o) = Float::pi_prec_round(prec, rm);\n        assert!(pi.is_valid());\n        assert_eq!(pi.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 3,\n            _ => 2,\n        };\n        assert_eq!(pi.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_alt, o_alt) = Float::pi_prec_round(prec, Ceiling);\n            let mut next_upper = pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi.is_power_of_2() {\n            let (pi_alt, o_alt) = Float::pi_prec_round(prec, Floor);\n            let mut next_lower = pi.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_pi, rug_o) = rug_pi_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_pi)),\n                ComparableFloatRef(&pi)\n            );\n            assert_eq!(rug_o, o);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::pi_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::pi_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/pi_over_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::PiOver2;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_pi_over_2_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::pi_over_2_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_2_prec() {\n    test_pi_over_2_prec_helper(1, \"2.0\", \"0x2.0#1\", Greater);\n    test_pi_over_2_prec_helper(2, \"1.5\", \"0x1.8#2\", Less);\n    test_pi_over_2_prec_helper(3, \"1.5\", \"0x1.8#3\", Less);\n    test_pi_over_2_prec_helper(4, \"1.6\", \"0x1.a#4\", Greater);\n    test_pi_over_2_prec_helper(5, \"1.56\", \"0x1.9#5\", Less);\n    test_pi_over_2_prec_helper(6, \"1.56\", \"0x1.90#6\", Less);\n    test_pi_over_2_prec_helper(7, \"1.58\", \"0x1.94#7\", Greater);\n    test_pi_over_2_prec_helper(8, \"1.57\", \"0x1.92#8\", Less);\n    test_pi_over_2_prec_helper(9, \"1.57\", \"0x1.92#9\", Less);\n    test_pi_over_2_prec_helper(10, \"1.57\", \"0x1.920#10\", Less);\n    test_pi_over_2_prec_helper(\n        100,\n        \"1.57079632679489661923132169164\",\n        \"0x1.921fb54442d18469898cc5170#100\",\n        Less,\n    );\n    test_pi_over_2_prec_helper(\n        1000,\n        \"1.570796326794896619231321691639751442098584699687552910487472296153908203143104499314017\\\n        412671058533991074043256641153323546922304775291115862679704064240558725142051350969260552\\\n        779822311474477465190982214405487832966723064237824116893391582635600954572824283461730174\\\n        3052271633241066968036301245706368\",\n        \"0x1.921fb54442d18469898cc51701b839a252049c1114cf98e804177d4c76273644a29410f31c6809bbdf2a3\\\n        3679a748636605614dbe4be286e9fc26adadaa3848bc90b6aecc4bcfd8de89885d34c6fdad617feb96de80d6fd\\\n        bdc70d7f6b5133f4b5d3e4822f8963fcc9250cca3d9c8b67b8400f97142c77e0b31b4906c38#1000\",\n        Less,\n    );\n    test_pi_over_2_prec_helper(\n        10000,\n        \"1.570796326794896619231321691639751442098584699687552910487472296153908203143104499314017\\\n        412671058533991074043256641153323546922304775291115862679704064240558725142051350969260552\\\n        779822311474477465190982214405487832966723064237824116893391582635600954572824283461730174\\\n        305227163324106696803630124570636862293503303157794087440760460481414627045857682183946295\\\n        180005665265274410233260692073475970755804716528635182879795976546093058690966305896552559\\\n        274037231189981374783675942876362445613969091505974564916836681220328321543010697473197612\\\n        368595351089930471851385269608588146588376192337409233834702566000284063572631780413892885\\\n        671378894804586818589360734220450612476715073274792685525396139844629461771009978056064510\\\n        980432017209079906814887385654980259353605674999999186489024975529865866408048159297512229\\\n        727673454151321261154126672342517630965594085505001568919376443293766604190710308588834573\\\n        651799126745214377734365579781431941176893796875978890928890266085613403306500963938305597\\\n        954608210099469047628600532742931639432968076690913984115150976017650926484497886811299706\\\n        945624860887641739565757787428621227075347975414766558430863927944537549190877318732469659\\\n        627530200463850835569504924412006429180801781853830052355090971477798099473383918724724127\\\n        689887363423552023767323104023342129534745646656838514494576052376081028483012029019075096\\\n        755626691215017793820123748236631957099636302134961398391177390818004670860820609962293157\\\n        515143091487277853374919252747294293463497845463605398754651477660582672493601377980118240\\\n        332749559940917398876783184903713271263931275909208787336445488886396900040823530008072624\\\n        596086608607386175070720986784274080680578676276066737870924734219261661953697071667273881\\\n        208431259491784742781049609611092136275127128443835895247300826733402494313616395893042892\\\n        191913983988340727050476941893180475340032112562602558696492448042064244313472802120982642\\\n        511105330593153372139311019597472523561856893480478182185958643733882328786981206945432916\\\n        322997906695239013795049732882039475634734199176297854912911310261244703863359739134241300\\\n        738495451320068197218727652534101748126225874699825715714904595329625468610848230757854929\\\n        193705298942979886487749465080876964234069134341934471387077995927962622976979715524986262\\\n        340422993636822347924326918368111313049562304025621942195225622068274881390398857845717998\\\n        850064808044720847434277924203176711036112914244324079228014253008421369726133733839447626\\\n        069261274977333363911993228298058177443115288728249017796817284087162056257538034739725548\\\n        298047012614439855446572834568433614374470280050751654308964340460437380458912469294504857\\\n        454837992630682774890946564892410841499474361329402428782007135238777566189820725761873117\\\n        182271429222397632933910525570677367869761556713583051067984768115721476242468593555072882\\\n        701795139967201871003655289269531099193723904239244841660722856934375971753215109226595524\\\n        240502685307340337459639095598969976030709831714377220321872561859096089999195507959780907\\\n        337571345619874470453593247115980783972604\",\n        \"0x1.921fb54442d18469898cc51701b839a252049c1114cf98e804177d4c76273644a29410f31c6809bbdf2a3\\\n        3679a748636605614dbe4be286e9fc26adadaa3848bc90b6aecc4bcfd8de89885d34c6fdad617feb96de80d6fd\\\n        bdc70d7f6b5133f4b5d3e4822f8963fcc9250cca3d9c8b67b8400f97142c77e0b31b4906c38aba734d22c7f51f\\\n        a499ebf06caba47b9475b2c38c5e6ac410aa5773daa520ee12d2cdace186a9c95793009e2e8d811943042f8652\\\n        0bc8c5c6d9c77c73cee58301d0c07364f0745d80f451f6b8abbe0de98a593bc5797ed2ab02e30732a92f9d52ad\\\n        5ca2ba44c3131f40a202ae51cb51555885b5a662e1a08a0f46750aa4357be3974c9d9f70a08b1b7de1515d4e2a\\\n        eba0c18fb672e1f0b4dc3c98f57eb5d19b61267ae3d1929c0944ac33b9dc7a44c35a5dcd7e25ff40db31410c9b\\\n        0ec04e67d90d4c8a43e56302ef6401977c22eaef4c2bad8ee13118175b28dc411c49f40e9cb566287b6b7f9c1f\\\n        a211c9705a2415242100234e478254f0fcdaf10e334217b74b64d33864e30d5e9c4783528d0696c2a17b44b07d\\\n        39455a899d1b77785b609bd1df25d1df8283f7d954c50f8b28e9cd780bb33652c9f412187444677430ca2b7cfd\\\n        a3ec252e19dc5af5f7037baec42e09039a00d224fab60b5532769d5311b1fbb830dff6fb9214d811e9be86b926\\\n        80509246d87f569a4f8e04d83a9b964c04c8dbd92ea3cec7b746f7bf1ff280d5b3ca61dcbb6705e8260035d60d\\\n        4a7db204fb0622f2e4f610cb51231b47db7d79f3629da899cd9759da97637b6fe288fcd984a966640a2a257af5\\\n        e84df71e8026f19a57eb30794038c9725d9e065d42ba2e43a07e905af9cdce9fdedaabce05e8d3019056b50806\\\n        32016393cb3cf92ff7d8fd1e64752f4fc6d99117c1e3a8b6ffeb0b58a97a80f645682a955991edafd7e91c3b02\\\n        998bda41f006fc14f2e2bdde537c6500d43ab176f8bb4edeaa1547b143f7fe1d63399634627aab9b4ad93d85de\\\n        52c6470ffd1aedc7808d0087d1ecc7e90c1dc257e5ab616e8e9adcd29f23cdb7c22b2e94724de25fdcbc870eef\\\n        96d5265bf19b17d89a0e77263747790656d1b3ba600e83f4f7f15f88fda4aeded26d74848cc7556c738b5c9ead\\\n        0684768e857e392f0471e2d97c73aca5bc7fb717df90915b244445c094806f80e27d6af503447e18e68e7f8c8d\\\n        9d460d69797910c5f070bbbf53a96ff45810fd0f2d06607dab7ba740c5679eb6744f14cda5427f07e89f05bbe6\\\n        21dc0e956d46c8b2fd133404abb82c9e6398a108d0a3bf3569032bbdafd4363aa217afdce9ae7f5e6d7863d9f4\\\n        4d06b208de9d70f3f24801287169038d9af1134005dabdc705792321b4df804dc8f2ab1c88eacefd3553c60a1c\\\n        4ecad29bf903eadd10172dce2c19301bb314ae7d488e40cb42739a520d9a396e53d8a54a50da880294d29948ae\\\n        b07ab9fde4de37215b0523b40f33a00045d37daab8df48ff94b76359506ec8adb31b290f3dcfcdb7f9a029762c\\\n        2ab3229d816aed4cfc7d0845d23ccb74283b525bd3874dad994a26dba8497620c9311d6b7535824d3efbece773\\\n        05c47f6d93376554638b4cd0bffab3229366158cf708c9b0152ba84a614d02c89a0720c1d1f1faa4c4d2da14eb\\\n        2b5c7f26b4cfb9feb50e94e03f7f4187aa6969c737812aee0a66e90434238759331c174e3010f662f04b4359f9\\\n        f5d77e49e4b8c0a35b53850b43f9ac2295071435bce2982d528039b9f03c20e3fef572e473e#10000\",\n        Less,\n    );\n\n    let pi_over_2_f32 = Float::pi_over_2_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_2_f32.to_string(), \"1.5707964\");\n    assert_eq!(to_hex_string(&pi_over_2_f32), \"0x1.921fb6#24\");\n    assert_eq!(pi_over_2_f32, f32::PI_OVER_2);\n\n    let pi_over_2_f64 = Float::pi_over_2_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_2_f64.to_string(), \"1.5707963267948966\");\n    assert_eq!(to_hex_string(&pi_over_2_f64), \"0x1.921fb54442d18#53\");\n    assert_eq!(pi_over_2_f64, f64::PI_OVER_2);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_2_prec_fail_1() {\n    Float::pi_over_2_prec(0);\n}\n\nfn test_pi_over_2_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::pi_over_2_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_2_prec_round() {\n    test_pi_over_2_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_pi_over_2_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_pi_over_2_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_pi_over_2_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_pi_over_2_prec_round_helper(1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test_pi_over_2_prec_round_helper(2, Floor, \"1.5\", \"0x1.8#2\", Less);\n    test_pi_over_2_prec_round_helper(2, Ceiling, \"2.0\", \"0x2.0#2\", Greater);\n    test_pi_over_2_prec_round_helper(2, Down, \"1.5\", \"0x1.8#2\", Less);\n    test_pi_over_2_prec_round_helper(2, Up, \"2.0\", \"0x2.0#2\", Greater);\n    test_pi_over_2_prec_round_helper(2, Nearest, \"1.5\", \"0x1.8#2\", Less);\n\n    test_pi_over_2_prec_round_helper(3, Floor, \"1.5\", \"0x1.8#3\", Less);\n    test_pi_over_2_prec_round_helper(3, Ceiling, \"1.8\", \"0x1.c#3\", Greater);\n    test_pi_over_2_prec_round_helper(3, Down, \"1.5\", \"0x1.8#3\", Less);\n    test_pi_over_2_prec_round_helper(3, Up, \"1.8\", \"0x1.c#3\", Greater);\n    test_pi_over_2_prec_round_helper(3, Nearest, \"1.5\", \"0x1.8#3\", Less);\n\n    test_pi_over_2_prec_round_helper(4, Floor, \"1.5\", \"0x1.8#4\", Less);\n    test_pi_over_2_prec_round_helper(4, Ceiling, \"1.6\", \"0x1.a#4\", Greater);\n    test_pi_over_2_prec_round_helper(4, Down, \"1.5\", \"0x1.8#4\", Less);\n    test_pi_over_2_prec_round_helper(4, Up, \"1.6\", \"0x1.a#4\", Greater);\n    test_pi_over_2_prec_round_helper(4, Nearest, \"1.6\", \"0x1.a#4\", Greater);\n\n    test_pi_over_2_prec_round_helper(5, Floor, \"1.56\", \"0x1.9#5\", Less);\n    test_pi_over_2_prec_round_helper(5, Ceiling, \"1.62\", \"0x1.a#5\", Greater);\n    test_pi_over_2_prec_round_helper(5, Down, \"1.56\", \"0x1.9#5\", Less);\n    test_pi_over_2_prec_round_helper(5, Up, \"1.62\", \"0x1.a#5\", Greater);\n    test_pi_over_2_prec_round_helper(5, Nearest, \"1.56\", \"0x1.9#5\", Less);\n\n    test_pi_over_2_prec_round_helper(6, Floor, \"1.56\", \"0x1.90#6\", Less);\n    test_pi_over_2_prec_round_helper(6, Ceiling, \"1.59\", \"0x1.98#6\", Greater);\n    test_pi_over_2_prec_round_helper(6, Down, \"1.56\", \"0x1.90#6\", Less);\n    test_pi_over_2_prec_round_helper(6, Up, \"1.59\", \"0x1.98#6\", Greater);\n    test_pi_over_2_prec_round_helper(6, Nearest, \"1.56\", \"0x1.90#6\", Less);\n\n    test_pi_over_2_prec_round_helper(7, Floor, \"1.56\", \"0x1.90#7\", Less);\n    test_pi_over_2_prec_round_helper(7, Ceiling, \"1.58\", \"0x1.94#7\", Greater);\n    test_pi_over_2_prec_round_helper(7, Down, \"1.56\", \"0x1.90#7\", Less);\n    test_pi_over_2_prec_round_helper(7, Up, \"1.58\", \"0x1.94#7\", Greater);\n    test_pi_over_2_prec_round_helper(7, Nearest, \"1.58\", \"0x1.94#7\", Greater);\n\n    test_pi_over_2_prec_round_helper(8, Floor, \"1.57\", \"0x1.92#8\", Less);\n    test_pi_over_2_prec_round_helper(8, Ceiling, \"1.58\", \"0x1.94#8\", Greater);\n    test_pi_over_2_prec_round_helper(8, Down, \"1.57\", \"0x1.92#8\", Less);\n    test_pi_over_2_prec_round_helper(8, Up, \"1.58\", \"0x1.94#8\", Greater);\n    test_pi_over_2_prec_round_helper(8, Nearest, \"1.57\", \"0x1.92#8\", Less);\n\n    test_pi_over_2_prec_round_helper(9, Floor, \"1.57\", \"0x1.92#9\", Less);\n    test_pi_over_2_prec_round_helper(9, Ceiling, \"1.574\", \"0x1.93#9\", Greater);\n    test_pi_over_2_prec_round_helper(9, Down, \"1.57\", \"0x1.92#9\", Less);\n    test_pi_over_2_prec_round_helper(9, Up, \"1.574\", \"0x1.93#9\", Greater);\n    test_pi_over_2_prec_round_helper(9, Nearest, \"1.57\", \"0x1.92#9\", Less);\n\n    test_pi_over_2_prec_round_helper(10, Floor, \"1.57\", \"0x1.920#10\", Less);\n    test_pi_over_2_prec_round_helper(10, Ceiling, \"1.572\", \"0x1.928#10\", Greater);\n    test_pi_over_2_prec_round_helper(10, Down, \"1.57\", \"0x1.920#10\", Less);\n    test_pi_over_2_prec_round_helper(10, Up, \"1.572\", \"0x1.928#10\", Greater);\n    test_pi_over_2_prec_round_helper(10, Nearest, \"1.57\", \"0x1.920#10\", Less);\n\n    test_pi_over_2_prec_round_helper(\n        100,\n        Floor,\n        \"1.57079632679489661923132169164\",\n        \"0x1.921fb54442d18469898cc5170#100\",\n        Less,\n    );\n    test_pi_over_2_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.570796326794896619231321691641\",\n        \"0x1.921fb54442d18469898cc5172#100\",\n        Greater,\n    );\n    test_pi_over_2_prec_round_helper(\n        100,\n        Down,\n        \"1.57079632679489661923132169164\",\n        \"0x1.921fb54442d18469898cc5170#100\",\n        Less,\n    );\n    test_pi_over_2_prec_round_helper(\n        100,\n        Up,\n        \"1.570796326794896619231321691641\",\n        \"0x1.921fb54442d18469898cc5172#100\",\n        Greater,\n    );\n    test_pi_over_2_prec_round_helper(\n        100,\n        Nearest,\n        \"1.57079632679489661923132169164\",\n        \"0x1.921fb54442d18469898cc5170#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn pi_over_2_prec_round_fail_1() {\n    Float::pi_over_2_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_2_prec_round_fail_2() {\n    Float::pi_over_2_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_2_prec_round_fail_3() {\n    Float::pi_over_2_prec_round(1000, Exact);\n}\n\n#[test]\nfn pi_over_2_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (pi_over_2, o) = Float::pi_over_2_prec(prec);\n        assert!(pi_over_2.is_valid());\n        assert_eq!(pi_over_2.get_prec(), Some(prec));\n        assert_eq!(\n            pi_over_2.get_exponent(),\n            Some(if prec == 1 { 2 } else { 1 })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_2_alt, o_alt) = Float::pi_over_2_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_2_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_2.is_power_of_2() {\n            let (pi_over_2_alt, o_alt) = Float::pi_over_2_prec_round(prec, Floor);\n            let mut next_lower = pi_over_2.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_2_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (pi_over_2_alt, o_alt) = Float::pi_over_2_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&pi_over_2_alt),\n            ComparableFloatRef(&pi_over_2)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn pi_over_2_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (pi_over_2, o) = Float::pi_over_2_prec_round(prec, rm);\n        assert!(pi_over_2.is_valid());\n        assert_eq!(pi_over_2.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 2,\n            _ => 1,\n        };\n        assert_eq!(pi_over_2.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_2_alt, o_alt) = Float::pi_over_2_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_2_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_2.is_power_of_2() {\n            let (pi_over_2_alt, o_alt) = Float::pi_over_2_prec_round(prec, Floor);\n            let mut next_lower = pi_over_2.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_2_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::pi_over_2_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::pi_over_2_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/pi_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::PiOver3;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::pi_over_3::pi_over_3_prec_round_simple;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_pi_over_3_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::pi_over_3_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = pi_over_3_prec_round_simple(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_pi_over_3_prec() {\n    test_pi_over_3_prec_helper(1, \"1.0\", \"0x1.0#1\", Less);\n    test_pi_over_3_prec_helper(2, \"1.0\", \"0x1.0#2\", Less);\n    test_pi_over_3_prec_helper(3, \"1.0\", \"0x1.0#3\", Less);\n    test_pi_over_3_prec_helper(4, \"1.0\", \"0x1.0#4\", Less);\n    test_pi_over_3_prec_helper(5, \"1.06\", \"0x1.1#5\", Greater);\n    test_pi_over_3_prec_helper(6, \"1.06\", \"0x1.10#6\", Greater);\n    test_pi_over_3_prec_helper(7, \"1.05\", \"0x1.0c#7\", Less);\n    test_pi_over_3_prec_helper(8, \"1.047\", \"0x1.0c#8\", Less);\n    test_pi_over_3_prec_helper(9, \"1.047\", \"0x1.0c#9\", Less);\n    test_pi_over_3_prec_helper(10, \"1.047\", \"0x1.0c0#10\", Less);\n    test_pi_over_3_prec_helper(\n        100,\n        \"1.047197551196597746154214461094\",\n        \"0x1.0c152382d73658465bb32e0f6#100\",\n        Greater,\n    );\n    test_pi_over_3_prec_helper(\n        1000,\n        \"1.047197551196597746154214461093167628065723133125035273658314864102605468762069666209344\\\n        941780705689327382695504427435549031281536516860743908453136042827039150094700900646173701\\\n        853214874316318310127321476270325221977815376158549411262261055090400636381882855641153449\\\n        5368181088827377978690867497137579\",\n        \"0x1.0c152382d73658465bb32e0f567ad116e158680b6335109aad64fe32f96f7983170d60a212f0067d3f717\\\n        79a66f85979958eb892987ec59f152c473c91c2585d30b247488328a90945bb03e232f53c8ebaa9d0f3f008f53\\\n        d3da08ff9ce0cd4dce8d4301750642a88618b3317e685cefd02ab50f62c84feb221230af2d0#1000\",\n        Less,\n    );\n    test_pi_over_3_prec_helper(\n        10000,\n        \"1.047197551196597746154214461093167628065723133125035273658314864102605468762069666209344\\\n        941780705689327382695504427435549031281536516860743908453136042827039150094700900646173701\\\n        853214874316318310127321476270325221977815376158549411262261055090400636381882855641153449\\\n        536818108882737797869086749713757908195668868771862724960506973654276418030571788122630863\\\n        453337110176849606822173794715650647170536477685756788586530651030728705793977537264368372\\\n        849358154126654249855783961917574963742646061003983043277891120813552214362007131648798408\\\n        245730234059953647900923513072392097725584128224939489223135044000189375715087853609261923\\\n        780919263203057879059573822813633741651143382183195123683597426563086307847339985370709673\\\n        986954678139386604543258257103320172902403783333332790992683317019910577605365439531674819\\\n        818448969434214174102751114895011753977062723670001045946250962195844402793806872392556382\\\n        434532751163476251822910386520954627451262531250652593952593510723742268871000642625537065\\\n        303072140066312698419067021828621092955312051127275989410100650678433950989665257874199804\\\n        630416573925094493043838524952414151383565316943177705620575951963025032793918212488313106\\\n        418353466975900557046336616274670952787201187902553368236727314318532066315589279149816085\\\n        126591575615701349178215402682228086356497097771225676329717368250720685655341352679383397\\\n        837084460810011862546749165491087971399757534756640932260784927212003113907213739974862105\\\n        010095394324851902249946168498196195642331896975736932503100985107055114995734251986745493\\\n        555166373293944932584522123269142180842620850606139191557630325924264600027215686672048416\\\n        397391072404924116713813991189516053787052450850711158580616489479507774635798047778182587\\\n        472287506327856495187366406407394757516751418962557263498200551155601662875744263928695261\\\n        461275989325560484700317961262120316893354741708401705797661632028042829542315201413988428\\\n        340736887062102248092874013064981682374571262320318788123972429155921552524654137963621944\\\n        215331937796826009196699821921359650423156132784198569941940873507496469242239826089494200\\\n        492330300880045464812485101689401165417483916466550477143269730219750312407232153838569952\\\n        795803532628653257658499643387251309489379422894622980924718663951975081984653143683324174\\\n        893615329091214898616217945578740875366374869350414628130150414712183254260265905230478665\\\n        900043205363147231622851949468784474024075276162882719485342835338947579817422489226298417\\\n        379507516651555575941328818865372118295410192485499345197878189391441370838358689826483698\\\n        865364675076293236964381889712289076249646853367167769539309560306958253639274979529669904\\\n        969891995087121849927297709928273894332982907552934952521338090159185044126547150507915411\\\n        454847619481598421955940350380451578579841037809055367378656512077147650828312395703381921\\\n        801196759978134580669103526179687399462482602826163227773815237956250647835476739484397016\\\n        160335123538226891639759397065979984020473221142918146881248374572730726666130338639853938\\\n        2250475637465829803023954980773205226484027\",\n        \"0x1.0c152382d73658465bb32e0f567ad116e158680b6335109aad64fe32f96f7983170d60a212f0067d3f717\\\n        79a66f85979958eb892987ec59f152c473c91c2585d30b247488328a90945bb03e232f53c8ebaa9d0f3f008f53\\\n        d3da08ff9ce0cd4dce8d4301750642a88618b3317e685cefd02ab50f62c84feb221230af2d0726f788c1daa36a\\\n        6dbbf2a048726da7b84e772d083ef1d80b1c3a4d3c6e15f40c8c891debaf1bdb8fb755bec9b3ab662cad750436\\\n        b285d92f3bda52f7df43acabe0804cedf5a2e900a2e14f25c7d409465c3b7d2e50ff371cac975a21c61fbe371e\\\n        3dc1d1832cb76a2b16ac7436878b8e3b03ce6eec966b06b4d9a35c6d78fd4264ddbe6a4b15b21253eb8b938971\\\n        f26b2bb5244c96a07892d310a3a9ce8bbceb6efc97e10c68062dc8227be851832ce6e933a96eaa2b3ccb80b312\\\n        09d5899a90b3885c2d4397574a42abba52c1f1f4dd7273b49620baba3cc5e82b68314d5f132399705247aa6815\\\n        16b6864ae6c2b8c2c0aac2342fac38a0a891f60977816524dcede22598975e3f12da578c5e046481c0fcd875a8\\\n        d0d8e70668bcfa503ceb128bea19369501ad4fe638835fb21b4688fab277798c86a2b6baf82d9a4d75dc1cfdfe\\\n        6d4818c96692e74ea4acfd1f2d74060266ab36c351ceb238cc4f138cb676a7d020954f5261633ab69bd459d0c4\\\n        558b0c2f3aff8f118a5eade57c67b98803309290c9c289da7a2f4fd4bff7008e77dc413dd244ae9ac40023e408\\\n        dc53cc035204174c98a40b32361767853cfe514cec691b1133ba3be70f97a79fec5b533badc64442b1716e51f9\\\n        45894f69aac4a1118ff22050d57b30f6e914043e2c7c1ed7c054603ca689346a9491c7deae9b37566039ce0559\\\n        76ab97b7dcd350caa53b5369984e1f8a84910b652bed1b24aa9cb23b1ba700a42e4571b8e661491fe54612d201\\\n        bbb291814aaf52b8a1ec7e9437a84355e2d1cba4a5d2349471638520d7faa968ecd10ecd96fc7267873b7e593e\\\n        e1d984b55367492fab08ab05369dda9b5d692c3a991ceb9f09bc933714c289252c1cc9b84c33ec3fe87daf5f4a\\\n        648e1992a1120fe5bc09a4c424da50aee48bcd26eab457f8a54b9505fe6dc9e9e19e4dadb32f8e484d07931473\\\n        59ada45f03a97b74ada141e652f7c86e7daa7a0fea6060e76d82d92b0daaf50096fe474e022da965ef09aa5db3\\\n        be2eb39ba650b5d94af5d27f8d1b9ff83ab5fe0a1e044053c7a7c4d5d8efbf244d8a0dde6e2c54aff06a03d299\\\n        6be809b8f38485cca8b778031d2573144265c0b08b17d4ce46021d291fe2ced1c1651fe89bc9aa3ef3a597e6a2\\\n        de0476b09468f5f7f6daab704b9b57b3bca0b78003e7292f58fb6cc1233faade85f71cbdb09c89fe238d2eb168\\\n        34873712a6029c93600f73dec810cabd220dc9a8db09808781a266e15e66d0f437e5c386e091b001b88c663074\\\n        75a726a9433ecf6b92036d22b4cd155583e253c725ea30aa6324ece6359f3073ccbcc60a293533cffbc01ba41d\\\n        71ccc1be564748ddfda8b02e8c2887a2c57ce1928d04de73bb86c4927030f96b30cb68f24e23ac337f529defa2\\\n        03d854f3b77a438d97b23335d551ccc1b79963b34f5b31200e1d1adc40de01db115a15d68bf6a71883373c0df2\\\n        1ce854c4788a7bff235f0dead4ff81051c464684cfab71f406ef4602cd6d04e62212ba34200b4eeca0322ce6a6\\\n        a3e4fedbedd0806ce78d035cd7fbc8170e04b823d341bac8e1aad126a02815ed54a3a1eda2a#10000\",\n        Greater,\n    );\n\n    let pi_over_3_f32 = Float::pi_over_3_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_3_f32.to_string(), \"1.0471976\");\n    assert_eq!(to_hex_string(&pi_over_3_f32), \"0x1.0c1524#24\");\n    assert_eq!(pi_over_3_f32, f32::PI_OVER_3);\n\n    let pi_over_3_f64 = Float::pi_over_3_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_3_f64.to_string(), \"1.0471975511965979\");\n    assert_eq!(to_hex_string(&pi_over_3_f64), \"0x1.0c152382d7366#53\");\n    assert_eq!(pi_over_3_f64, f64::PI_OVER_3);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_3_prec_fail_1() {\n    Float::pi_over_3_prec(0);\n}\n\nfn test_pi_over_3_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::pi_over_3_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = pi_over_3_prec_round_simple(prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_pi_over_3_prec_round() {\n    test_pi_over_3_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_pi_over_3_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_pi_over_3_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_pi_over_3_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_pi_over_3_prec_round_helper(1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test_pi_over_3_prec_round_helper(2, Floor, \"1.0\", \"0x1.0#2\", Less);\n    test_pi_over_3_prec_round_helper(2, Ceiling, \"1.5\", \"0x1.8#2\", Greater);\n    test_pi_over_3_prec_round_helper(2, Down, \"1.0\", \"0x1.0#2\", Less);\n    test_pi_over_3_prec_round_helper(2, Up, \"1.5\", \"0x1.8#2\", Greater);\n    test_pi_over_3_prec_round_helper(2, Nearest, \"1.0\", \"0x1.0#2\", Less);\n\n    test_pi_over_3_prec_round_helper(3, Floor, \"1.0\", \"0x1.0#3\", Less);\n    test_pi_over_3_prec_round_helper(3, Ceiling, \"1.2\", \"0x1.4#3\", Greater);\n    test_pi_over_3_prec_round_helper(3, Down, \"1.0\", \"0x1.0#3\", Less);\n    test_pi_over_3_prec_round_helper(3, Up, \"1.2\", \"0x1.4#3\", Greater);\n    test_pi_over_3_prec_round_helper(3, Nearest, \"1.0\", \"0x1.0#3\", Less);\n\n    test_pi_over_3_prec_round_helper(4, Floor, \"1.0\", \"0x1.0#4\", Less);\n    test_pi_over_3_prec_round_helper(4, Ceiling, \"1.1\", \"0x1.2#4\", Greater);\n    test_pi_over_3_prec_round_helper(4, Down, \"1.0\", \"0x1.0#4\", Less);\n    test_pi_over_3_prec_round_helper(4, Up, \"1.1\", \"0x1.2#4\", Greater);\n    test_pi_over_3_prec_round_helper(4, Nearest, \"1.0\", \"0x1.0#4\", Less);\n\n    test_pi_over_3_prec_round_helper(5, Floor, \"1.0\", \"0x1.0#5\", Less);\n    test_pi_over_3_prec_round_helper(5, Ceiling, \"1.06\", \"0x1.1#5\", Greater);\n    test_pi_over_3_prec_round_helper(5, Down, \"1.0\", \"0x1.0#5\", Less);\n    test_pi_over_3_prec_round_helper(5, Up, \"1.06\", \"0x1.1#5\", Greater);\n    test_pi_over_3_prec_round_helper(5, Nearest, \"1.06\", \"0x1.1#5\", Greater);\n\n    test_pi_over_3_prec_round_helper(6, Floor, \"1.03\", \"0x1.08#6\", Less);\n    test_pi_over_3_prec_round_helper(6, Ceiling, \"1.06\", \"0x1.10#6\", Greater);\n    test_pi_over_3_prec_round_helper(6, Down, \"1.03\", \"0x1.08#6\", Less);\n    test_pi_over_3_prec_round_helper(6, Up, \"1.06\", \"0x1.10#6\", Greater);\n    test_pi_over_3_prec_round_helper(6, Nearest, \"1.06\", \"0x1.10#6\", Greater);\n\n    test_pi_over_3_prec_round_helper(7, Floor, \"1.05\", \"0x1.0c#7\", Less);\n    test_pi_over_3_prec_round_helper(7, Ceiling, \"1.06\", \"0x1.10#7\", Greater);\n    test_pi_over_3_prec_round_helper(7, Down, \"1.05\", \"0x1.0c#7\", Less);\n    test_pi_over_3_prec_round_helper(7, Up, \"1.06\", \"0x1.10#7\", Greater);\n    test_pi_over_3_prec_round_helper(7, Nearest, \"1.05\", \"0x1.0c#7\", Less);\n\n    test_pi_over_3_prec_round_helper(8, Floor, \"1.047\", \"0x1.0c#8\", Less);\n    test_pi_over_3_prec_round_helper(8, Ceiling, \"1.055\", \"0x1.0e#8\", Greater);\n    test_pi_over_3_prec_round_helper(8, Down, \"1.047\", \"0x1.0c#8\", Less);\n    test_pi_over_3_prec_round_helper(8, Up, \"1.055\", \"0x1.0e#8\", Greater);\n    test_pi_over_3_prec_round_helper(8, Nearest, \"1.047\", \"0x1.0c#8\", Less);\n\n    test_pi_over_3_prec_round_helper(9, Floor, \"1.047\", \"0x1.0c#9\", Less);\n    test_pi_over_3_prec_round_helper(9, Ceiling, \"1.051\", \"0x1.0d#9\", Greater);\n    test_pi_over_3_prec_round_helper(9, Down, \"1.047\", \"0x1.0c#9\", Less);\n    test_pi_over_3_prec_round_helper(9, Up, \"1.051\", \"0x1.0d#9\", Greater);\n    test_pi_over_3_prec_round_helper(9, Nearest, \"1.047\", \"0x1.0c#9\", Less);\n\n    test_pi_over_3_prec_round_helper(10, Floor, \"1.047\", \"0x1.0c0#10\", Less);\n    test_pi_over_3_prec_round_helper(10, Ceiling, \"1.049\", \"0x1.0c8#10\", Greater);\n    test_pi_over_3_prec_round_helper(10, Down, \"1.047\", \"0x1.0c0#10\", Less);\n    test_pi_over_3_prec_round_helper(10, Up, \"1.049\", \"0x1.0c8#10\", Greater);\n    test_pi_over_3_prec_round_helper(10, Nearest, \"1.047\", \"0x1.0c0#10\", Less);\n\n    test_pi_over_3_prec_round_helper(\n        100,\n        Floor,\n        \"1.047197551196597746154214461092\",\n        \"0x1.0c152382d73658465bb32e0f4#100\",\n        Less,\n    );\n    test_pi_over_3_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.047197551196597746154214461094\",\n        \"0x1.0c152382d73658465bb32e0f6#100\",\n        Greater,\n    );\n    test_pi_over_3_prec_round_helper(\n        100,\n        Down,\n        \"1.047197551196597746154214461092\",\n        \"0x1.0c152382d73658465bb32e0f4#100\",\n        Less,\n    );\n    test_pi_over_3_prec_round_helper(\n        100,\n        Up,\n        \"1.047197551196597746154214461094\",\n        \"0x1.0c152382d73658465bb32e0f6#100\",\n        Greater,\n    );\n    test_pi_over_3_prec_round_helper(\n        100,\n        Nearest,\n        \"1.047197551196597746154214461094\",\n        \"0x1.0c152382d73658465bb32e0f6#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn pi_over_3_prec_round_fail_1() {\n    Float::pi_over_3_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_3_prec_round_fail_2() {\n    Float::pi_over_3_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_3_prec_round_fail_3() {\n    Float::pi_over_3_prec_round(1000, Exact);\n}\n\n#[test]\nfn pi_over_3_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (pi_over_3, o) = Float::pi_over_3_prec(prec);\n        assert!(pi_over_3.is_valid());\n        assert_eq!(pi_over_3.get_prec(), Some(prec));\n        assert_eq!(pi_over_3.get_exponent(), Some(1));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_3_alt, o_alt) = Float::pi_over_3_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_3.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_3_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_3.is_power_of_2() {\n            let (pi_over_3_alt, o_alt) = Float::pi_over_3_prec_round(prec, Floor);\n            let mut next_lower = pi_over_3.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_3_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (pi_over_3_alt, o_alt) = Float::pi_over_3_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&pi_over_3_alt),\n            ComparableFloatRef(&pi_over_3)\n        );\n        assert_eq!(o_alt, o);\n\n        let (pi_over_3_alt, o_alt) = pi_over_3_prec_round_simple(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&pi_over_3_alt),\n            ComparableFloatRef(&pi_over_3)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn pi_over_3_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (pi_over_3, o) = Float::pi_over_3_prec_round(prec, rm);\n        assert!(pi_over_3.is_valid());\n        assert_eq!(pi_over_3.get_prec(), Some(prec));\n        assert_eq!(\n            pi_over_3.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                2\n            } else {\n                1\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_3_alt, o_alt) = Float::pi_over_3_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_3.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_3_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_3.is_power_of_2() {\n            let (pi_over_3_alt, o_alt) = Float::pi_over_3_prec_round(prec, Floor);\n            let mut next_lower = pi_over_3.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_3_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        let (pi_over_3_alt, o_alt) = pi_over_3_prec_round_simple(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&pi_over_3_alt),\n            ComparableFloatRef(&pi_over_3)\n        );\n        assert_eq!(o_alt, o);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::pi_over_3_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::pi_over_3_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/pi_over_4.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::PiOver4;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_pi_over_4_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::pi_over_4_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_4_prec() {\n    test_pi_over_4_prec_helper(1, \"1.0\", \"0x1.0#1\", Greater);\n    test_pi_over_4_prec_helper(2, \"0.8\", \"0x0.c#2\", Less);\n    test_pi_over_4_prec_helper(3, \"0.8\", \"0x0.c#3\", Less);\n    test_pi_over_4_prec_helper(4, \"0.81\", \"0x0.d#4\", Greater);\n    test_pi_over_4_prec_helper(5, \"0.78\", \"0x0.c8#5\", Less);\n    test_pi_over_4_prec_helper(6, \"0.78\", \"0x0.c8#6\", Less);\n    test_pi_over_4_prec_helper(7, \"0.79\", \"0x0.ca#7\", Greater);\n    test_pi_over_4_prec_helper(8, \"0.785\", \"0x0.c9#8\", Less);\n    test_pi_over_4_prec_helper(9, \"0.785\", \"0x0.c90#9\", Less);\n    test_pi_over_4_prec_helper(10, \"0.785\", \"0x0.c90#10\", Less);\n    test_pi_over_4_prec_helper(\n        100,\n        \"0.78539816339744830961566084582\",\n        \"0x0.c90fdaa22168c234c4c6628b8#100\",\n        Less,\n    );\n    test_pi_over_4_prec_helper(\n        1000,\n        \"0.785398163397448309615660845819875721049292349843776455243736148076954101571552249657008\\\n        706335529266995537021628320576661773461152387645557931339852032120279362571025675484630276\\\n        389911155737238732595491107202743916483361532118912058446695791317800477286412141730865087\\\n        1526135816620533484018150622853184\",\n        \"0x0.c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef951\\\n        9b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7e\\\n        dee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c#1000\",\n        Less,\n    );\n    test_pi_over_4_prec_helper(\n        10000,\n        \"0.785398163397448309615660845819875721049292349843776455243736148076954101571552249657008\\\n        706335529266995537021628320576661773461152387645557931339852032120279362571025675484630276\\\n        389911155737238732595491107202743916483361532118912058446695791317800477286412141730865087\\\n        152613581662053348401815062285318431146751651578897043720380230240707313522928841091973147\\\n        590002832632637205116630346036737985377902358264317591439897988273046529345483152948276279\\\n        637018615594990687391837971438181222806984545752987282458418340610164160771505348736598806\\\n        184297675544965235925692634804294073294188096168704616917351283000142031786315890206946442\\\n        835689447402293409294680367110225306238357536637396342762698069922314730885504989028032255\\\n        490216008604539953407443692827490129676802837499999593244512487764932933204024079648756114\\\n        863836727075660630577063336171258815482797042752500784459688221646883302095355154294417286\\\n        825899563372607188867182789890715970588446898437989445464445133042806701653250481969152798\\\n        977304105049734523814300266371465819716484038345456992057575488008825463242248943405649853\\\n        472812430443820869782878893714310613537673987707383279215431963972268774595438659366234829\\\n        813765100231925417784752462206003214590400890926915026177545485738899049736691959362362063\\\n        844943681711776011883661552011671064767372823328419257247288026188040514241506014509537548\\\n        377813345607508896910061874118315978549818151067480699195588695409002335430410304981146578\\\n        757571545743638926687459626373647146731748922731802699377325738830291336246800688990059120\\\n        166374779970458699438391592451856635631965637954604393668222744443198450020411765004036312\\\n        298043304303693087535360493392137040340289338138033368935462367109630830976848535833636940\\\n        604215629745892371390524804805546068137563564221917947623650413366701247156808197946521446\\\n        095956991994170363525238470946590237670016056281301279348246224021032122156736401060491321\\\n        255552665296576686069655509798736261780928446740239091092979321866941164393490603472716458\\\n        161498953347619506897524866441019737817367099588148927456455655130622351931679869567120650\\\n        369247725660034098609363826267050874063112937349912857857452297664812734305424115378927464\\\n        596852649471489943243874732540438482117034567170967235693538997963981311488489857762493131\\\n        170211496818411173962163459184055656524781152012810971097612811034137440695199428922858999\\\n        425032404022360423717138962101588355518056457122162039614007126504210684863066866919723813\\\n        034630637488666681955996614149029088721557644364124508898408642043581028128769017369862774\\\n        149023506307219927723286417284216807187235140025375827154482170230218690229456234647252428\\\n        727418996315341387445473282446205420749737180664701214391003567619388783094910362880936558\\\n        591135714611198816466955262785338683934880778356791525533992384057860738121234296777536441\\\n        350897569983600935501827644634765549596861952119622420830361428467187985876607554613297762\\\n        120251342653670168729819547799484988015354915857188610160936280929548044999597753979890453\\\n        66878567280993723522679662355799039198630201\",\n        \"0x0.c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef951\\\n        9b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7e\\\n        dee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8f\\\n        d24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c329\\\n        05e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956\\\n        ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea715\\\n        75d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d\\\n        87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0f\\\n        d108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e\\\n        9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7e\\\n        d1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93\\\n        402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06\\\n        a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7a\\\n        f426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a8403\\\n        1900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d81\\\n        4cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef\\\n        29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777\\\n        cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f56\\\n        83423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646\\\n        cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf3\\\n        10ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa\\\n        268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e\\\n        2765694dfc81f56e880b96e7160c980dd98a573ea4472065a139cd2906cd1cb729ec52a5286d44014a694ca457\\\n        583d5cfef26f1b90ad8291da0799d00022e9bed55c6fa47fca5bb1aca8376456d98d94879ee7e6dbfcd014bb16\\\n        1559914ec0b576a67e3e8422e91e65ba141da92de9c3a6d6cca5136dd424bb1064988eb5ba9ac1269f7df673b9\\\n        82e23fb6c99bb2aa31c5a6685ffd599149b30ac67b8464d80a95d42530a681644d039060e8f8fd5262696d0a75\\\n        95ae3f935a67dcff5a874a701fbfa0c3d534b4e39bc09577053374821a11c3ac998e0ba718087b317825a1acfc\\\n        faebbf24f25c6051ada9c285a1fcd6114a838a1ade714c16a9401cdcf81e1071ff7ab97239f#10000\",\n        Less,\n    );\n\n    let pi_over_4_f32 = Float::pi_over_4_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_4_f32.to_string(), \"0.78539819\");\n    assert_eq!(to_hex_string(&pi_over_4_f32), \"0x0.c90fdb#24\");\n    assert_eq!(pi_over_4_f32, f32::PI_OVER_4);\n\n    let pi_over_4_f64 = Float::pi_over_4_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_4_f64.to_string(), \"0.7853981633974483\");\n    assert_eq!(to_hex_string(&pi_over_4_f64), \"0x0.c90fdaa22168c0#53\");\n    assert_eq!(pi_over_4_f64, f64::PI_OVER_4);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_4_prec_fail_1() {\n    Float::pi_over_4_prec(0);\n}\n\nfn test_pi_over_4_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::pi_over_4_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_4_prec_round() {\n    test_pi_over_4_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_pi_over_4_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_pi_over_4_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_pi_over_4_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_pi_over_4_prec_round_helper(1, Nearest, \"1.0\", \"0x1.0#1\", Greater);\n\n    test_pi_over_4_prec_round_helper(2, Floor, \"0.8\", \"0x0.c#2\", Less);\n    test_pi_over_4_prec_round_helper(2, Ceiling, \"1.0\", \"0x1.0#2\", Greater);\n    test_pi_over_4_prec_round_helper(2, Down, \"0.8\", \"0x0.c#2\", Less);\n    test_pi_over_4_prec_round_helper(2, Up, \"1.0\", \"0x1.0#2\", Greater);\n    test_pi_over_4_prec_round_helper(2, Nearest, \"0.8\", \"0x0.c#2\", Less);\n\n    test_pi_over_4_prec_round_helper(3, Floor, \"0.8\", \"0x0.c#3\", Less);\n    test_pi_over_4_prec_round_helper(3, Ceiling, \"0.9\", \"0x0.e#3\", Greater);\n    test_pi_over_4_prec_round_helper(3, Down, \"0.8\", \"0x0.c#3\", Less);\n    test_pi_over_4_prec_round_helper(3, Up, \"0.9\", \"0x0.e#3\", Greater);\n    test_pi_over_4_prec_round_helper(3, Nearest, \"0.8\", \"0x0.c#3\", Less);\n\n    test_pi_over_4_prec_round_helper(4, Floor, \"0.75\", \"0x0.c#4\", Less);\n    test_pi_over_4_prec_round_helper(4, Ceiling, \"0.81\", \"0x0.d#4\", Greater);\n    test_pi_over_4_prec_round_helper(4, Down, \"0.75\", \"0x0.c#4\", Less);\n    test_pi_over_4_prec_round_helper(4, Up, \"0.81\", \"0x0.d#4\", Greater);\n    test_pi_over_4_prec_round_helper(4, Nearest, \"0.81\", \"0x0.d#4\", Greater);\n\n    test_pi_over_4_prec_round_helper(5, Floor, \"0.78\", \"0x0.c8#5\", Less);\n    test_pi_over_4_prec_round_helper(5, Ceiling, \"0.81\", \"0x0.d0#5\", Greater);\n    test_pi_over_4_prec_round_helper(5, Down, \"0.78\", \"0x0.c8#5\", Less);\n    test_pi_over_4_prec_round_helper(5, Up, \"0.81\", \"0x0.d0#5\", Greater);\n    test_pi_over_4_prec_round_helper(5, Nearest, \"0.78\", \"0x0.c8#5\", Less);\n\n    test_pi_over_4_prec_round_helper(6, Floor, \"0.78\", \"0x0.c8#6\", Less);\n    test_pi_over_4_prec_round_helper(6, Ceiling, \"0.8\", \"0x0.cc#6\", Greater);\n    test_pi_over_4_prec_round_helper(6, Down, \"0.78\", \"0x0.c8#6\", Less);\n    test_pi_over_4_prec_round_helper(6, Up, \"0.8\", \"0x0.cc#6\", Greater);\n    test_pi_over_4_prec_round_helper(6, Nearest, \"0.78\", \"0x0.c8#6\", Less);\n\n    test_pi_over_4_prec_round_helper(7, Floor, \"0.78\", \"0x0.c8#7\", Less);\n    test_pi_over_4_prec_round_helper(7, Ceiling, \"0.79\", \"0x0.ca#7\", Greater);\n    test_pi_over_4_prec_round_helper(7, Down, \"0.78\", \"0x0.c8#7\", Less);\n    test_pi_over_4_prec_round_helper(7, Up, \"0.79\", \"0x0.ca#7\", Greater);\n    test_pi_over_4_prec_round_helper(7, Nearest, \"0.79\", \"0x0.ca#7\", Greater);\n\n    test_pi_over_4_prec_round_helper(8, Floor, \"0.785\", \"0x0.c9#8\", Less);\n    test_pi_over_4_prec_round_helper(8, Ceiling, \"0.789\", \"0x0.ca#8\", Greater);\n    test_pi_over_4_prec_round_helper(8, Down, \"0.785\", \"0x0.c9#8\", Less);\n    test_pi_over_4_prec_round_helper(8, Up, \"0.789\", \"0x0.ca#8\", Greater);\n    test_pi_over_4_prec_round_helper(8, Nearest, \"0.785\", \"0x0.c9#8\", Less);\n\n    test_pi_over_4_prec_round_helper(9, Floor, \"0.785\", \"0x0.c90#9\", Less);\n    test_pi_over_4_prec_round_helper(9, Ceiling, \"0.787\", \"0x0.c98#9\", Greater);\n    test_pi_over_4_prec_round_helper(9, Down, \"0.785\", \"0x0.c90#9\", Less);\n    test_pi_over_4_prec_round_helper(9, Up, \"0.787\", \"0x0.c98#9\", Greater);\n    test_pi_over_4_prec_round_helper(9, Nearest, \"0.785\", \"0x0.c90#9\", Less);\n\n    test_pi_over_4_prec_round_helper(10, Floor, \"0.785\", \"0x0.c90#10\", Less);\n    test_pi_over_4_prec_round_helper(10, Ceiling, \"0.786\", \"0x0.c94#10\", Greater);\n    test_pi_over_4_prec_round_helper(10, Down, \"0.785\", \"0x0.c90#10\", Less);\n    test_pi_over_4_prec_round_helper(10, Up, \"0.786\", \"0x0.c94#10\", Greater);\n    test_pi_over_4_prec_round_helper(10, Nearest, \"0.785\", \"0x0.c90#10\", Less);\n\n    test_pi_over_4_prec_round_helper(\n        100,\n        Floor,\n        \"0.78539816339744830961566084582\",\n        \"0x0.c90fdaa22168c234c4c6628b8#100\",\n        Less,\n    );\n    test_pi_over_4_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.7853981633974483096156608458206\",\n        \"0x0.c90fdaa22168c234c4c6628b9#100\",\n        Greater,\n    );\n    test_pi_over_4_prec_round_helper(\n        100,\n        Down,\n        \"0.78539816339744830961566084582\",\n        \"0x0.c90fdaa22168c234c4c6628b8#100\",\n        Less,\n    );\n    test_pi_over_4_prec_round_helper(\n        100,\n        Up,\n        \"0.7853981633974483096156608458206\",\n        \"0x0.c90fdaa22168c234c4c6628b9#100\",\n        Greater,\n    );\n    test_pi_over_4_prec_round_helper(\n        100,\n        Nearest,\n        \"0.78539816339744830961566084582\",\n        \"0x0.c90fdaa22168c234c4c6628b8#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn pi_over_4_prec_round_fail_1() {\n    Float::pi_over_4_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_4_prec_round_fail_2() {\n    Float::pi_over_4_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_4_prec_round_fail_3() {\n    Float::pi_over_4_prec_round(1000, Exact);\n}\n\n#[test]\nfn pi_over_4_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (pi_over_4, o) = Float::pi_over_4_prec(prec);\n        assert!(pi_over_4.is_valid());\n        assert_eq!(pi_over_4.get_prec(), Some(prec));\n        assert_eq!(\n            pi_over_4.get_exponent(),\n            Some(if prec == 1 { 1 } else { 0 })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_4_alt, o_alt) = Float::pi_over_4_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_4.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_4_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_4.is_power_of_2() {\n            let (pi_over_4_alt, o_alt) = Float::pi_over_4_prec_round(prec, Floor);\n            let mut next_lower = pi_over_4.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_4_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (pi_over_4_alt, o_alt) = Float::pi_over_4_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&pi_over_4_alt),\n            ComparableFloatRef(&pi_over_4)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn pi_over_4_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (pi_over_4, o) = Float::pi_over_4_prec_round(prec, rm);\n        assert!(pi_over_4.is_valid());\n        assert_eq!(pi_over_4.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 1,\n            _ => 0,\n        };\n        assert_eq!(pi_over_4.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_4_alt, o_alt) = Float::pi_over_4_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_4.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_4_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_4.is_power_of_2() {\n            let (pi_over_4_alt, o_alt) = Float::pi_over_4_prec_round(prec, Floor);\n            let mut next_lower = pi_over_4.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_4_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::pi_over_4_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::pi_over_4_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/pi_over_6.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::PiOver6;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_pi_over_6_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::pi_over_6_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_6_prec() {\n    test_pi_over_6_prec_helper(1, \"0.5\", \"0x0.8#1\", Less);\n    test_pi_over_6_prec_helper(2, \"0.5\", \"0x0.8#2\", Less);\n    test_pi_over_6_prec_helper(3, \"0.5\", \"0x0.8#3\", Less);\n    test_pi_over_6_prec_helper(4, \"0.5\", \"0x0.8#4\", Less);\n    test_pi_over_6_prec_helper(5, \"0.53\", \"0x0.88#5\", Greater);\n    test_pi_over_6_prec_helper(6, \"0.53\", \"0x0.88#6\", Greater);\n    test_pi_over_6_prec_helper(7, \"0.523\", \"0x0.86#7\", Less);\n    test_pi_over_6_prec_helper(8, \"0.523\", \"0x0.86#8\", Less);\n    test_pi_over_6_prec_helper(9, \"0.523\", \"0x0.860#9\", Less);\n    test_pi_over_6_prec_helper(10, \"0.523\", \"0x0.860#10\", Less);\n    test_pi_over_6_prec_helper(\n        100,\n        \"0.523598775598298873077107230547\",\n        \"0x0.860a91c16b9b2c232dd99707b#100\",\n        Greater,\n    );\n    test_pi_over_6_prec_helper(\n        1000,\n        \"0.523598775598298873077107230546583814032861566562517636829157432051302734381034833104672\\\n        470890352844663691347752213717774515640768258430371954226568021413519575047350450323086850\\\n        926607437158159155063660738135162610988907688079274705631130527545200318190941427820576724\\\n        7684090544413688989345433748568789\",\n        \"0x0.860a91c16b9b2c232dd99707ab3d688b70ac3405b19a884d56b27f197cb7bcc18b86b0510978033e9fb8b\\\n        bcd337c2cbccac75c494c3f62cf8a96239e48e12c2e985923a441945484a2dd81f1197a9e475d54e879f8047a9\\\n        e9ed047fce7066a6e746a180ba832154430c5998bf342e77e8155a87b16427f591091857968#1000\",\n        Less,\n    );\n    test_pi_over_6_prec_helper(\n        10000,\n        \"0.523598775598298873077107230546583814032861566562517636829157432051302734381034833104672\\\n        470890352844663691347752213717774515640768258430371954226568021413519575047350450323086850\\\n        926607437158159155063660738135162610988907688079274705631130527545200318190941427820576724\\\n        768409054441368898934543374856878954097834434385931362480253486827138209015285894061315431\\\n        726668555088424803411086897357825323585268238842878394293265325515364352896988768632184186\\\n        424679077063327124927891980958787481871323030501991521638945560406776107181003565824399204\\\n        122865117029976823950461756536196048862792064112469744611567522000094687857543926804630961\\\n        890459631601528939529786911406816870825571691091597561841798713281543153923669992685354836\\\n        993477339069693302271629128551660086451201891666666395496341658509955288802682719765837409\\\n        909224484717107087051375557447505876988531361835000522973125481097922201396903436196278191\\\n        217266375581738125911455193260477313725631265625326296976296755361871134435500321312768532\\\n        651536070033156349209533510914310546477656025563637994705050325339216975494832628937099902\\\n        315208286962547246521919262476207075691782658471588852810287975981512516396959106244156553\\\n        209176733487950278523168308137335476393600593951276684118363657159266033157794639574908042\\\n        563295787807850674589107701341114043178248548885612838164858684125360342827670676339691698\\\n        918542230405005931273374582745543985699878767378320466130392463606001556953606869987431052\\\n        505047697162425951124973084249098097821165948487868466251550492553527557497867125993372746\\\n        777583186646972466292261061634571090421310425303069595778815162962132300013607843336024208\\\n        198695536202462058356906995594758026893526225425355579290308244739753887317899023889091293\\\n        736143753163928247593683203203697378758375709481278631749100275577800831437872131964347630\\\n        730637994662780242350158980631060158446677370854200852898830816014021414771157600706994214\\\n        170368443531051124046437006532490841187285631160159394061986214577960776262327068981810972\\\n        107665968898413004598349910960679825211578066392099284970970436753748234621119913044747100\\\n        246165150440022732406242550844700582708741958233275238571634865109875156203616076919284976\\\n        397901766314326628829249821693625654744689711447311490462359331975987540992326571841662087\\\n        446807664545607449308108972789370437683187434675207314065075207356091627130132952615239332\\\n        950021602681573615811425974734392237012037638081441359742671417669473789908711244613149208\\\n        689753758325777787970664409432686059147705096242749672598939094695720685419179344913241849\\\n        432682337538146618482190944856144538124823426683583884769654780153479126819637489764834952\\\n        484945997543560924963648854964136947166491453776467476260669045079592522063273575253957705\\\n        727423809740799210977970175190225789289920518904527683689328256038573825414156197851690960\\\n        900598379989067290334551763089843699731241301413081613886907618978125323917738369742198508\\\n        080167561769113445819879698532989992010236610571459073440624187286365363333065169319926969\\\n        11252378187329149015119774903866026132420136\",\n        \"0x0.860a91c16b9b2c232dd99707ab3d688b70ac3405b19a884d56b27f197cb7bcc18b86b0510978033e9fb8b\\\n        bcd337c2cbccac75c494c3f62cf8a96239e48e12c2e985923a441945484a2dd81f1197a9e475d54e879f8047a9\\\n        e9ed047fce7066a6e746a180ba832154430c5998bf342e77e8155a87b16427f5910918579683937bc460ed51b5\\\n        36ddf950243936d3dc273b96841f78ec058e1d269e370afa0646448ef5d78dedc7dbaadf64d9d5b31656ba821b\\\n        5942ec979ded297befa1d655f0402676fad174805170a792e3ea04a32e1dbe97287f9b8e564bad10e30fdf1b8f\\\n        1ee0e8c1965bb5158b563a1b43c5c71d81e737764b35835a6cd1ae36bc7ea1326edf35258ad90929f5c5c9c4b8\\\n        f93595da92264b503c49698851d4e745de75b77e4bf086340316e4113df428c196737499d4b755159e65c05989\\\n        04eac4cd4859c42e16a1cbaba52155dd2960f8fa6eb939da4b105d5d1e62f415b418a6af8991ccb82923d5340a\\\n        8b5b432573615c616055611a17d61c505448fb04bbc0b2926e76f112cc4baf1f896d2bc62f023240e07e6c3ad4\\\n        686c7383345e7d281e758945f50c9b4a80d6a7f31c41afd90da3447d593bbcc643515b5d7c16cd26baee0e7eff\\\n        36a40c64b34973a752567e8f96ba030133559b61a8e7591c662789c65b3b53e8104aa7a930b19d5b4dea2ce862\\\n        2ac586179d7fc788c52f56f2be33dcc40198494864e144ed3d17a7ea5ffb80473bee209ee922574d620011f204\\\n        6e29e601a9020ba64c5205991b0bb3c29e7f28a676348d8899dd1df387cbd3cff62da99dd6e3222158b8b728fc\\\n        a2c4a7b4d5625088c7f910286abd987b748a021f163e0f6be02a301e53449a354a48e3ef574d9bab301ce702ac\\\n        bb55cbdbee69a865529da9b4cc270fc5424885b295f68d92554e591d8dd380521722b8dc7330a48ff2a3096900\\\n        ddd948c0a557a95c50f63f4a1bd421aaf168e5d252e91a4a38b1c2906bfd54b476688766cb7e3933c39dbf2c9f\\\n        70ecc25aa9b3a497d58455829b4eed4daeb4961d4c8e75cf84de499b8a614492960e64dc2619f61ff43ed7afa5\\\n        32470cc9508907f2de04d262126d28577245e693755a2bfc52a5ca82ff36e4f4f0cf26d6d997c7242683c98a39\\\n        acd6d22f81d4bdba56d0a0f3297be4373ed53d07f5303073b6c16c9586d57a804b7f23a70116d4b2f784d52ed9\\\n        df1759cdd3285aeca57ae93fc68dcffc1d5aff050f022029e3d3e26aec77df9226c506ef37162a57f83501e94c\\\n        b5f404dc79c242e6545bbc018e92b98a2132e058458bea6723010e948ff16768e0b28ff44de4d51f79d2cbf351\\\n        6f023b584a347afbfb6d55b825cdabd9de505bc001f39497ac7db660919fd56f42fb8e5ed84e44ff11c69758b4\\\n        1a439b8953014e49b007b9ef6408655e9106e4d46d84c043c0d13370af33687a1bf2e1c37048d800dc4633183a\\\n        3ad39354a19f67b5c901b6915a668aaac1f129e392f51855319276731acf9839e65e6305149a99e7fde00dd20e\\\n        b8e660df2b23a46efed45817461443d162be70c946826f39ddc3624938187cb59865b4792711d619bfa94ef7d1\\\n        01ec2a79dbbd21c6cbd9199aeaa8e660dbccb1d9a7ad9890070e8d6e206f00ed88ad0aeb45fb538c419b9e06f9\\\n        0e742a623c453dff91af86f56a7fc0828e23234267d5b8fa0377a30166b6827311095d1a1005a7765019167353\\\n        51f27f6df6e8403673c681ae6bfde40b87025c11e9a0dd6470d5689350140af6aa51d0f6d15#10000\",\n        Greater,\n    );\n\n    let pi_over_6_f32 = Float::pi_over_6_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_6_f32.to_string(), \"0.52359879\");\n    assert_eq!(to_hex_string(&pi_over_6_f32), \"0x0.860a92#24\");\n    assert_eq!(pi_over_6_f32, f32::PI_OVER_6);\n\n    let pi_over_6_f64 = Float::pi_over_6_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_6_f64.to_string(), \"0.5235987755982989\");\n    assert_eq!(to_hex_string(&pi_over_6_f64), \"0x0.860a91c16b9b30#53\");\n    assert_eq!(pi_over_6_f64, f64::PI_OVER_6);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_6_prec_fail_1() {\n    Float::pi_over_6_prec(0);\n}\n\nfn test_pi_over_6_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::pi_over_6_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_6_prec_round() {\n    test_pi_over_6_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_pi_over_6_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_pi_over_6_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_pi_over_6_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_pi_over_6_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test_pi_over_6_prec_round_helper(2, Floor, \"0.5\", \"0x0.8#2\", Less);\n    test_pi_over_6_prec_round_helper(2, Ceiling, \"0.8\", \"0x0.c#2\", Greater);\n    test_pi_over_6_prec_round_helper(2, Down, \"0.5\", \"0x0.8#2\", Less);\n    test_pi_over_6_prec_round_helper(2, Up, \"0.8\", \"0x0.c#2\", Greater);\n    test_pi_over_6_prec_round_helper(2, Nearest, \"0.5\", \"0x0.8#2\", Less);\n\n    test_pi_over_6_prec_round_helper(3, Floor, \"0.5\", \"0x0.8#3\", Less);\n    test_pi_over_6_prec_round_helper(3, Ceiling, \"0.6\", \"0x0.a#3\", Greater);\n    test_pi_over_6_prec_round_helper(3, Down, \"0.5\", \"0x0.8#3\", Less);\n    test_pi_over_6_prec_round_helper(3, Up, \"0.6\", \"0x0.a#3\", Greater);\n    test_pi_over_6_prec_round_helper(3, Nearest, \"0.5\", \"0x0.8#3\", Less);\n\n    test_pi_over_6_prec_round_helper(4, Floor, \"0.5\", \"0x0.8#4\", Less);\n    test_pi_over_6_prec_round_helper(4, Ceiling, \"0.56\", \"0x0.9#4\", Greater);\n    test_pi_over_6_prec_round_helper(4, Down, \"0.5\", \"0x0.8#4\", Less);\n    test_pi_over_6_prec_round_helper(4, Up, \"0.56\", \"0x0.9#4\", Greater);\n    test_pi_over_6_prec_round_helper(4, Nearest, \"0.5\", \"0x0.8#4\", Less);\n\n    test_pi_over_6_prec_round_helper(5, Floor, \"0.5\", \"0x0.80#5\", Less);\n    test_pi_over_6_prec_round_helper(5, Ceiling, \"0.53\", \"0x0.88#5\", Greater);\n    test_pi_over_6_prec_round_helper(5, Down, \"0.5\", \"0x0.80#5\", Less);\n    test_pi_over_6_prec_round_helper(5, Up, \"0.53\", \"0x0.88#5\", Greater);\n    test_pi_over_6_prec_round_helper(5, Nearest, \"0.53\", \"0x0.88#5\", Greater);\n\n    test_pi_over_6_prec_round_helper(6, Floor, \"0.52\", \"0x0.84#6\", Less);\n    test_pi_over_6_prec_round_helper(6, Ceiling, \"0.53\", \"0x0.88#6\", Greater);\n    test_pi_over_6_prec_round_helper(6, Down, \"0.52\", \"0x0.84#6\", Less);\n    test_pi_over_6_prec_round_helper(6, Up, \"0.53\", \"0x0.88#6\", Greater);\n    test_pi_over_6_prec_round_helper(6, Nearest, \"0.53\", \"0x0.88#6\", Greater);\n\n    test_pi_over_6_prec_round_helper(7, Floor, \"0.523\", \"0x0.86#7\", Less);\n    test_pi_over_6_prec_round_helper(7, Ceiling, \"0.53\", \"0x0.88#7\", Greater);\n    test_pi_over_6_prec_round_helper(7, Down, \"0.523\", \"0x0.86#7\", Less);\n    test_pi_over_6_prec_round_helper(7, Up, \"0.53\", \"0x0.88#7\", Greater);\n    test_pi_over_6_prec_round_helper(7, Nearest, \"0.523\", \"0x0.86#7\", Less);\n\n    test_pi_over_6_prec_round_helper(8, Floor, \"0.523\", \"0x0.86#8\", Less);\n    test_pi_over_6_prec_round_helper(8, Ceiling, \"0.527\", \"0x0.87#8\", Greater);\n    test_pi_over_6_prec_round_helper(8, Down, \"0.523\", \"0x0.86#8\", Less);\n    test_pi_over_6_prec_round_helper(8, Up, \"0.527\", \"0x0.87#8\", Greater);\n    test_pi_over_6_prec_round_helper(8, Nearest, \"0.523\", \"0x0.86#8\", Less);\n\n    test_pi_over_6_prec_round_helper(9, Floor, \"0.523\", \"0x0.860#9\", Less);\n    test_pi_over_6_prec_round_helper(9, Ceiling, \"0.525\", \"0x0.868#9\", Greater);\n    test_pi_over_6_prec_round_helper(9, Down, \"0.523\", \"0x0.860#9\", Less);\n    test_pi_over_6_prec_round_helper(9, Up, \"0.525\", \"0x0.868#9\", Greater);\n    test_pi_over_6_prec_round_helper(9, Nearest, \"0.523\", \"0x0.860#9\", Less);\n\n    test_pi_over_6_prec_round_helper(10, Floor, \"0.523\", \"0x0.860#10\", Less);\n    test_pi_over_6_prec_round_helper(10, Ceiling, \"0.524\", \"0x0.864#10\", Greater);\n    test_pi_over_6_prec_round_helper(10, Down, \"0.523\", \"0x0.860#10\", Less);\n    test_pi_over_6_prec_round_helper(10, Up, \"0.524\", \"0x0.864#10\", Greater);\n    test_pi_over_6_prec_round_helper(10, Nearest, \"0.523\", \"0x0.860#10\", Less);\n\n    test_pi_over_6_prec_round_helper(\n        100,\n        Floor,\n        \"0.523598775598298873077107230546\",\n        \"0x0.860a91c16b9b2c232dd99707a#100\",\n        Less,\n    );\n    test_pi_over_6_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.523598775598298873077107230547\",\n        \"0x0.860a91c16b9b2c232dd99707b#100\",\n        Greater,\n    );\n    test_pi_over_6_prec_round_helper(\n        100,\n        Down,\n        \"0.523598775598298873077107230546\",\n        \"0x0.860a91c16b9b2c232dd99707a#100\",\n        Less,\n    );\n    test_pi_over_6_prec_round_helper(\n        100,\n        Up,\n        \"0.523598775598298873077107230547\",\n        \"0x0.860a91c16b9b2c232dd99707b#100\",\n        Greater,\n    );\n    test_pi_over_6_prec_round_helper(\n        100,\n        Nearest,\n        \"0.523598775598298873077107230547\",\n        \"0x0.860a91c16b9b2c232dd99707b#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn pi_over_6_prec_round_fail_1() {\n    Float::pi_over_6_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_6_prec_round_fail_2() {\n    Float::pi_over_6_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_6_prec_round_fail_3() {\n    Float::pi_over_6_prec_round(1000, Exact);\n}\n\n#[test]\nfn pi_over_6_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (pi_over_6, o) = Float::pi_over_6_prec(prec);\n        assert!(pi_over_6.is_valid());\n        assert_eq!(pi_over_6.get_prec(), Some(prec));\n        assert_eq!(pi_over_6.get_exponent(), Some(0));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_6_alt, o_alt) = Float::pi_over_6_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_6.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_6_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_6.is_power_of_2() {\n            let (pi_over_6_alt, o_alt) = Float::pi_over_6_prec_round(prec, Floor);\n            let mut next_lower = pi_over_6.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_6_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (pi_over_6_alt, o_alt) = Float::pi_over_6_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&pi_over_6_alt),\n            ComparableFloatRef(&pi_over_6)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn pi_over_6_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (pi_over_6, o) = Float::pi_over_6_prec_round(prec, rm);\n        assert!(pi_over_6.is_valid());\n        assert_eq!(pi_over_6.get_prec(), Some(prec));\n        assert_eq!(\n            pi_over_6.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                1\n            } else {\n                0\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_6_alt, o_alt) = Float::pi_over_6_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_6.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_6_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_6.is_power_of_2() {\n            let (pi_over_6_alt, o_alt) = Float::pi_over_6_prec_round(prec, Floor);\n            let mut next_lower = pi_over_6.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_6_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::pi_over_6_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::pi_over_6_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/pi_over_8.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::PiOver8;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_pi_over_8_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::pi_over_8_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_8_prec() {\n    test_pi_over_8_prec_helper(1, \"0.5\", \"0x0.8#1\", Greater);\n    test_pi_over_8_prec_helper(2, \"0.4\", \"0x0.6#2\", Less);\n    test_pi_over_8_prec_helper(3, \"0.38\", \"0x0.6#3\", Less);\n    test_pi_over_8_prec_helper(4, \"0.41\", \"0x0.68#4\", Greater);\n    test_pi_over_8_prec_helper(5, \"0.39\", \"0x0.64#5\", Less);\n    test_pi_over_8_prec_helper(6, \"0.39\", \"0x0.64#6\", Less);\n    test_pi_over_8_prec_helper(7, \"0.395\", \"0x0.65#7\", Greater);\n    test_pi_over_8_prec_helper(8, \"0.393\", \"0x0.648#8\", Less);\n    test_pi_over_8_prec_helper(9, \"0.393\", \"0x0.648#9\", Less);\n    test_pi_over_8_prec_helper(10, \"0.3926\", \"0x0.648#10\", Less);\n    test_pi_over_8_prec_helper(\n        100,\n        \"0.3926990816987241548078304229099\",\n        \"0x0.6487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n    test_pi_over_8_prec_helper(\n        1000,\n        \"0.392699081698724154807830422909937860524646174921888227621868074038477050785776124828504\\\n        353167764633497768510814160288330886730576193822778965669926016060139681285512837742315138\\\n        194955577868619366297745553601371958241680766059456029223347895658900238643206070865432543\\\n        5763067908310266742009075311426592\",\n        \"0x0.6487ed5110b4611a62633145c06e0e68948127044533e63a0105df531d89cd9128a5043cc71a026ef7ca8\\\n        cd9e69d218d98158536f92f8a1ba7f09ab6b6a8e122f242dabb312f3f637a262174d31bf6b585ffae5b7a035bf\\\n        6f71c35fdad44cfd2d74f9208be258ff324943328f6722d9ee1003e5c50b1df82cc6d241b0e0#1000\",\n        Less,\n    );\n    test_pi_over_8_prec_helper(\n        10000,\n        \"0.392699081698724154807830422909937860524646174921888227621868074038477050785776124828504\\\n        353167764633497768510814160288330886730576193822778965669926016060139681285512837742315138\\\n        194955577868619366297745553601371958241680766059456029223347895658900238643206070865432543\\\n        576306790831026674200907531142659215573375825789448521860190115120353656761464420545986573\\\n        795001416316318602558315173018368992688951179132158795719948994136523264672741576474138139\\\n        818509307797495343695918985719090611403492272876493641229209170305082080385752674368299403\\\n        092148837772482617962846317402147036647094048084352308458675641500071015893157945103473221\\\n        417844723701146704647340183555112653119178768318698171381349034961157365442752494514016127\\\n        745108004302269976703721846413745064838401418749999796622256243882466466602012039824378057\\\n        431918363537830315288531668085629407741398521376250392229844110823441651047677577147208643\\\n        412949781686303594433591394945357985294223449218994722732222566521403350826625240984576399\\\n        488652052524867261907150133185732909858242019172728496028787744004412731621124471702824926\\\n        736406215221910434891439446857155306768836993853691639607715981986134387297719329683117414\\\n        906882550115962708892376231103001607295200445463457513088772742869449524868345979681181031\\\n        922471840855888005941830776005835532383686411664209628623644013094020257120753007254768774\\\n        188906672803754448455030937059157989274909075533740349597794347704501167715205152490573289\\\n        378785772871819463343729813186823573365874461365901349688662869415145668123400344495029560\\\n        083187389985229349719195796225928317815982818977302196834111372221599225010205882502018156\\\n        149021652151846543767680246696068520170144669069016684467731183554815415488424267916818470\\\n        302107814872946185695262402402773034068781782110958973811825206683350623578404098973260723\\\n        047978495997085181762619235473295118835008028140650639674123112010516061078368200530245660\\\n        627776332648288343034827754899368130890464223370119545546489660933470582196745301736358229\\\n        080749476673809753448762433220509868908683549794074463728227827565311175965839934783560325\\\n        184623862830017049304681913133525437031556468674956428928726148832406367152712057689463732\\\n        298426324735744971621937366270219241058517283585483617846769498981990655744244928881246565\\\n        585105748409205586981081729592027828262390576006405485548806405517068720347599714461429499\\\n        712516202011180211858569481050794177759028228561081019807003563252105342431533433459861906\\\n        517315318744333340977998307074514544360778822182062254449204321021790514064384508684931387\\\n        074511753153609963861643208642108403593617570012687913577241085115109345114728117323626214\\\n        363709498157670693722736641223102710374868590332350607195501783809694391547455181440468279\\\n        295567857305599408233477631392669341967440389178395762766996192028930369060617148388768220\\\n        675448784991800467750913822317382774798430976059811210415180714233593992938303777306648881\\\n        060125671326835084364909773899742494007677457928594305080468140464774022499798876989945226\\\n        834392836404968617613398311778995195993151\",\n        \"0x0.6487ed5110b4611a62633145c06e0e68948127044533e63a0105df531d89cd9128a5043cc71a026ef7ca8\\\n        cd9e69d218d98158536f92f8a1ba7f09ab6b6a8e122f242dabb312f3f637a262174d31bf6b585ffae5b7a035bf\\\n        6f71c35fdad44cfd2d74f9208be258ff324943328f6722d9ee1003e5c50b1df82cc6d241b0e2ae9cd348b1fd47\\\n        e9267afc1b2ae91ee51d6cb0e3179ab1042a95dcf6a9483b84b4b36b3861aa7255e4c0278ba3604650c10be194\\\n        82f23171b671df1cf3b960c074301cd93c1d17603d147dae2aef837a62964ef15e5fb4aac0b8c1ccaa4be754ab\\\n        5728ae9130c4c7d02880ab9472d45556216d6998b8682283d19d42a90d5ef8e5d32767dc2822c6df785457538a\\\n        bae83063ed9cb87c2d370f263d5fad7466d8499eb8f464a702512b0cee771e9130d697735f897fd036cc504326\\\n        c3b01399f643532290f958c0bbd90065df08babbd30aeb63b84c4605d6ca371047127d03a72d598a1edadfe707\\\n        e884725c16890549084008d391e0953c3f36bc438cd085edd2d934ce1938c357a711e0d4a341a5b0a85ed12c1f\\\n        4e5156a26746ddde16d826f477c97477e0a0fdf6553143e2ca3a735e02eccd94b27d04861d1119dd0c328adf3f\\\n        68fb094b867716bd7dc0deebb10b8240e68034893ead82d54c9da754c46c7eee0c37fdbee48536047a6fa1ae49\\\n        a0142491b61fd5a693e381360ea6e593013236f64ba8f3b1edd1bdefc7fca0356cf298772ed9c17a09800d7583\\\n        529f6c813ec188bcb93d8432d448c6d1f6df5e7cd8a76a267365d676a5d8dedbf8a23f36612a5999028a895ebd\\\n        7a137dc7a009bc6695facc1e500e325c9767819750ae8b90e81fa416be7373a7f7b6aaf3817a34c06415ad4201\\\n        8c8058e4f2cf3e4bfdf63f47991d4bd3f1b66445f078ea2dbffac2d62a5ea03d915a0aa556647b6bf5fa470ec0\\\n        a662f6907c01bf053cb8af7794df1940350eac5dbe2ed3b7aa8551ec50fdff8758ce658d189eaae6d2b64f6177\\\n        94b191c3ff46bb71e0234021f47b31fa43077095f96ad85ba3a6b734a7c8f36df08acba51c937897f72f21c3bb\\\n        e5b54996fc66c5f626839dc98dd1de4195b46cee9803a0fd3dfc57e23f692bb7b49b5d212331d55b1ce2d727ab\\\n        41a11da3a15f8e4bc11c78b65f1ceb296f1fedc5f7e42456c911117025201be0389f5abd40d11f8639a39fe323\\\n        6751835a5e5e44317c1c2eefd4ea5bfd16043f43cb41981f6adee9d03159e7ad9d13c53369509fc1fa27c16ef9\\\n        887703a55b51b22cbf44cd012aee0b2798e628423428efcd5a40caef6bf50d8ea885ebf73a6b9fd79b5e18f67d\\\n        1341ac8237a75c3cfc92004a1c5a40e366bc44d00176af71c15e48c86d37e013723caac7223ab3bf4d54f18287\\\n        13b2b4a6fe40fab74405cb738b064c06ecc52b9f52239032d09ce69483668e5b94f629529436a200a534a6522b\\\n        ac1eae7f79378dc856c148ed03cce8001174df6aae37d23fe52dd8d6541bb22b6cc6ca43cf73f36dfe680a5d8b\\\n        0aacc8a7605abb533f1f4211748f32dd0a0ed496f4e1d36b665289b6ea125d88324c475add4d60934fbefb39dc\\\n        c1711fdb64cdd95518e2d3342ffeacc8a4d985633dc2326c054aea12985340b22681c830747c7ea93134b6853a\\\n        cad71fc9ad33ee7fad43a5380fdfd061ea9a5a71cde04abb8299ba410d08e1d64cc705d38c043d98bc12d0d67e\\\n        7d75df92792e3028d6d4e142d0fe6b08a541c50d6f38a60b54a00e6e7c0f0838ffbd5cb91cf8#10000\",\n        Less,\n    );\n\n    let pi_over_8_f32 = Float::pi_over_8_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_8_f32.to_string(), \"0.39269909\");\n    assert_eq!(to_hex_string(&pi_over_8_f32), \"0x0.6487ed8#24\");\n    assert_eq!(pi_over_8_f32, f32::PI_OVER_8);\n\n    let pi_over_8_f64 = Float::pi_over_8_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(pi_over_8_f64.to_string(), \"0.39269908169872414\");\n    assert_eq!(to_hex_string(&pi_over_8_f64), \"0x0.6487ed5110b460#53\");\n    assert_eq!(pi_over_8_f64, f64::PI_OVER_8);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_8_prec_fail_1() {\n    Float::pi_over_8_prec(0);\n}\n\nfn test_pi_over_8_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::pi_over_8_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_pi_over_8_prec_round() {\n    test_pi_over_8_prec_round_helper(1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test_pi_over_8_prec_round_helper(1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test_pi_over_8_prec_round_helper(1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test_pi_over_8_prec_round_helper(1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test_pi_over_8_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Greater);\n\n    test_pi_over_8_prec_round_helper(2, Floor, \"0.4\", \"0x0.6#2\", Less);\n    test_pi_over_8_prec_round_helper(2, Ceiling, \"0.5\", \"0x0.8#2\", Greater);\n    test_pi_over_8_prec_round_helper(2, Down, \"0.4\", \"0x0.6#2\", Less);\n    test_pi_over_8_prec_round_helper(2, Up, \"0.5\", \"0x0.8#2\", Greater);\n    test_pi_over_8_prec_round_helper(2, Nearest, \"0.4\", \"0x0.6#2\", Less);\n\n    test_pi_over_8_prec_round_helper(3, Floor, \"0.38\", \"0x0.6#3\", Less);\n    test_pi_over_8_prec_round_helper(3, Ceiling, \"0.44\", \"0x0.7#3\", Greater);\n    test_pi_over_8_prec_round_helper(3, Down, \"0.38\", \"0x0.6#3\", Less);\n    test_pi_over_8_prec_round_helper(3, Up, \"0.44\", \"0x0.7#3\", Greater);\n    test_pi_over_8_prec_round_helper(3, Nearest, \"0.38\", \"0x0.6#3\", Less);\n\n    test_pi_over_8_prec_round_helper(4, Floor, \"0.38\", \"0x0.60#4\", Less);\n    test_pi_over_8_prec_round_helper(4, Ceiling, \"0.41\", \"0x0.68#4\", Greater);\n    test_pi_over_8_prec_round_helper(4, Down, \"0.38\", \"0x0.60#4\", Less);\n    test_pi_over_8_prec_round_helper(4, Up, \"0.41\", \"0x0.68#4\", Greater);\n    test_pi_over_8_prec_round_helper(4, Nearest, \"0.41\", \"0x0.68#4\", Greater);\n\n    test_pi_over_8_prec_round_helper(5, Floor, \"0.39\", \"0x0.64#5\", Less);\n    test_pi_over_8_prec_round_helper(5, Ceiling, \"0.41\", \"0x0.68#5\", Greater);\n    test_pi_over_8_prec_round_helper(5, Down, \"0.39\", \"0x0.64#5\", Less);\n    test_pi_over_8_prec_round_helper(5, Up, \"0.41\", \"0x0.68#5\", Greater);\n    test_pi_over_8_prec_round_helper(5, Nearest, \"0.39\", \"0x0.64#5\", Less);\n\n    test_pi_over_8_prec_round_helper(6, Floor, \"0.39\", \"0x0.64#6\", Less);\n    test_pi_over_8_prec_round_helper(6, Ceiling, \"0.4\", \"0x0.66#6\", Greater);\n    test_pi_over_8_prec_round_helper(6, Down, \"0.39\", \"0x0.64#6\", Less);\n    test_pi_over_8_prec_round_helper(6, Up, \"0.4\", \"0x0.66#6\", Greater);\n    test_pi_over_8_prec_round_helper(6, Nearest, \"0.39\", \"0x0.64#6\", Less);\n\n    test_pi_over_8_prec_round_helper(7, Floor, \"0.391\", \"0x0.64#7\", Less);\n    test_pi_over_8_prec_round_helper(7, Ceiling, \"0.395\", \"0x0.65#7\", Greater);\n    test_pi_over_8_prec_round_helper(7, Down, \"0.391\", \"0x0.64#7\", Less);\n    test_pi_over_8_prec_round_helper(7, Up, \"0.395\", \"0x0.65#7\", Greater);\n    test_pi_over_8_prec_round_helper(7, Nearest, \"0.395\", \"0x0.65#7\", Greater);\n\n    test_pi_over_8_prec_round_helper(8, Floor, \"0.393\", \"0x0.648#8\", Less);\n    test_pi_over_8_prec_round_helper(8, Ceiling, \"0.395\", \"0x0.650#8\", Greater);\n    test_pi_over_8_prec_round_helper(8, Down, \"0.393\", \"0x0.648#8\", Less);\n    test_pi_over_8_prec_round_helper(8, Up, \"0.395\", \"0x0.650#8\", Greater);\n    test_pi_over_8_prec_round_helper(8, Nearest, \"0.393\", \"0x0.648#8\", Less);\n\n    test_pi_over_8_prec_round_helper(9, Floor, \"0.393\", \"0x0.648#9\", Less);\n    test_pi_over_8_prec_round_helper(9, Ceiling, \"0.394\", \"0x0.64c#9\", Greater);\n    test_pi_over_8_prec_round_helper(9, Down, \"0.393\", \"0x0.648#9\", Less);\n    test_pi_over_8_prec_round_helper(9, Up, \"0.394\", \"0x0.64c#9\", Greater);\n    test_pi_over_8_prec_round_helper(9, Nearest, \"0.393\", \"0x0.648#9\", Less);\n\n    test_pi_over_8_prec_round_helper(10, Floor, \"0.3926\", \"0x0.648#10\", Less);\n    test_pi_over_8_prec_round_helper(10, Ceiling, \"0.3931\", \"0x0.64a#10\", Greater);\n    test_pi_over_8_prec_round_helper(10, Down, \"0.3926\", \"0x0.648#10\", Less);\n    test_pi_over_8_prec_round_helper(10, Up, \"0.3931\", \"0x0.64a#10\", Greater);\n    test_pi_over_8_prec_round_helper(10, Nearest, \"0.3926\", \"0x0.648#10\", Less);\n\n    test_pi_over_8_prec_round_helper(\n        100,\n        Floor,\n        \"0.3926990816987241548078304229099\",\n        \"0x0.6487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n    test_pi_over_8_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.3926990816987241548078304229103\",\n        \"0x0.6487ed5110b4611a62633145c8#100\",\n        Greater,\n    );\n    test_pi_over_8_prec_round_helper(\n        100,\n        Down,\n        \"0.3926990816987241548078304229099\",\n        \"0x0.6487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n    test_pi_over_8_prec_round_helper(\n        100,\n        Up,\n        \"0.3926990816987241548078304229103\",\n        \"0x0.6487ed5110b4611a62633145c8#100\",\n        Greater,\n    );\n    test_pi_over_8_prec_round_helper(\n        100,\n        Nearest,\n        \"0.3926990816987241548078304229099\",\n        \"0x0.6487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn pi_over_8_prec_round_fail_1() {\n    Float::pi_over_8_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_8_prec_round_fail_2() {\n    Float::pi_over_8_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn pi_over_8_prec_round_fail_3() {\n    Float::pi_over_8_prec_round(1000, Exact);\n}\n\n#[test]\nfn pi_over_8_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (pi_over_8, o) = Float::pi_over_8_prec(prec);\n        assert!(pi_over_8.is_valid());\n        assert_eq!(pi_over_8.get_prec(), Some(prec));\n        assert_eq!(\n            pi_over_8.get_exponent(),\n            Some(if prec == 1 { 0 } else { -1 })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_8_alt, o_alt) = Float::pi_over_8_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_8.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_8_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_8.is_power_of_2() {\n            let (pi_over_8_alt, o_alt) = Float::pi_over_8_prec_round(prec, Floor);\n            let mut next_lower = pi_over_8.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_8_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (pi_over_8_alt, o_alt) = Float::pi_over_8_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&pi_over_8_alt),\n            ComparableFloatRef(&pi_over_8)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn pi_over_8_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (pi_over_8, o) = Float::pi_over_8_prec_round(prec, rm);\n        assert!(pi_over_8.is_valid());\n        assert_eq!(pi_over_8.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 0,\n            _ => -1,\n        };\n        assert_eq!(pi_over_8.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (pi_over_8_alt, o_alt) = Float::pi_over_8_prec_round(prec, Ceiling);\n            let mut next_upper = pi_over_8.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pi_over_8_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pi_over_8.is_power_of_2() {\n            let (pi_over_8_alt, o_alt) = Float::pi_over_8_prec_round(prec, Floor);\n            let mut next_lower = pi_over_8.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pi_over_8_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::pi_over_8_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::pi_over_8_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/prime_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::PrimeConstant;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::prime_constant::prime_constant_prec_round_naive;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_prime_constant_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::prime_constant_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = prime_constant_prec_round_naive(prec, Nearest);\n    assert_eq!(x, x_alt);\n    assert_eq!(o, o_alt);\n}\n\n#[test]\npub fn test_prime_constant_prec() {\n    test_prime_constant_prec_helper(1, \"0.5\", \"0x0.8#1\", Greater);\n    test_prime_constant_prec_helper(2, \"0.4\", \"0x0.6#2\", Less);\n    test_prime_constant_prec_helper(3, \"0.44\", \"0x0.7#3\", Greater);\n    test_prime_constant_prec_helper(4, \"0.41\", \"0x0.68#4\", Less);\n    test_prime_constant_prec_helper(5, \"0.42\", \"0x0.6c#5\", Greater);\n    test_prime_constant_prec_helper(6, \"0.414\", \"0x0.6a#6\", Less);\n    test_prime_constant_prec_helper(7, \"0.414\", \"0x0.6a#7\", Less);\n    test_prime_constant_prec_helper(8, \"0.414\", \"0x0.6a0#8\", Less);\n    test_prime_constant_prec_helper(9, \"0.415\", \"0x0.6a4#9\", Greater);\n    test_prime_constant_prec_helper(10, \"0.4146\", \"0x0.6a2#10\", Less);\n    test_prime_constant_prec_helper(\n        100,\n        \"0.4146825098511116602481096221542\",\n        \"0x0.6a28a20a08a208282282208088#100\",\n        Less,\n    );\n    test_prime_constant_prec_helper(\n        1000,\n        \"0.414682509851111660248109622154307708365774238137916977868245414488640960619357334196290\\\n        048428475777939616159352082985957835749978453022009904120814650033958993701974119186285615\\\n        579237191637251488161071073428432480218016979856815134246794749243902778820311537783180662\\\n        98787003544718107300315282293658657\",\n        \"0x0.6a28a20a08a20828228220808a28800220a00a08220828028a00200228828020820a08a00800228800208\\\n        028820208220808808028028220808a20020220220800a00008200820a08020828208a00200a20828008820200\\\n        808020208220208808800200800a00a28020008a20008a200002202008088208002208202080#1000\",\n        Less,\n    );\n    test_prime_constant_prec_helper(\n        10000,\n        \"0.414682509851111660248109622154307708365774238137916977868245414488640960619357334196290\\\n        048428475777939616159352082985957835749978453022009904120814650033958993701974119186285615\\\n        579237191637251488161071073428432480218016979856815134246794749243902778820311537783180662\\\n        987870035447181073003152822936586571701195884345760580684835877525498698320011540191930758\\\n        099002319261468413919152574118369129168574279239129804341592424543430422903399908325112045\\\n        668292742611194732667211553722399175647987527658878910703815406904018048152558727250330913\\\n        032734465178315959501124916374515488312368223411699732976990859213965904304781712473399850\\\n        022855936162301792842610279636663239004692389139831027778036326093312778898964673169309518\\\n        310306063152926347489776338241054180226337674492907279938068989754912015273280509376794011\\\n        427472704319064395781618400649434291302477306540023894812147846692492936635719588061120657\\\n        051390501956020214967100891969377486235872143778145145772057385386205343716378192432613513\\\n        172804602223001006685864520195545148953810709046574934296166432665763774833905637940402631\\\n        576801946504697746229836623924610157737793410864303438788766145163542908821015516523230106\\\n        797290246886870760828326453371632716614992987127399459741555239537031562083871442168565303\\\n        189912375257157779026541835903342269582971374263275545243196592115378128694441070207946879\\\n        764496037081508369373832295654819400087481268863376301792472431388415929294658211923608901\\\n        402710138982797422281950231204740825160556996531760010125162932087538066645067994257503747\\\n        988951392973626720366328982170505846234832544143958403519197518756622565009818379834626553\\\n        617954708446358169530464486348037793106750286422766029143787907491013162528697477255180525\\\n        301688970187379440498919433856401585513390951795192326204312092377569597171283867789460769\\\n        396842845072133229690180683640002570495073917768933999215761139873608859874089589096776461\\\n        995923745390535138086006656259166023212941879359754829079532092146864715376576674216923592\\\n        356284657954731472882379615899071977783469111502062539802490350514979367013733212811256787\\\n        651076562739406500368100788692192060657019146542871834536027154909579465624259941136769107\\\n        561003973746479133595976239940200240349439391177366640902400434482715348474352654705232334\\\n        865757263289528822462280034190931946143020430007789481367871305250457767936834157491630698\\\n        107741376398506062111121345698764997552559136414698454192672485636202709453131509266585281\\\n        706706580881014762163488645479634465001692797445197175229384471918672226624328100132469141\\\n        109007889697011845498155181004138530396370327432831414575546500251524843825045622130807383\\\n        973351694821712447724540951485939349474765305310454105446321469155906341381357010374677903\\\n        488746578301462245594571327626904723478958729803396726212447661231362593184418074810567100\\\n        150303566417543158729492869454556673124380354806665894633517169712578312518114309438722159\\\n        398158466744490582994391095649028975452941714271570359608073520730264326067239780059666358\\\n        3765668592857275961081596601034186349684386\",\n        \"0x0.6a28a20a08a20828228220808a28800220a00a08220828028a00200228828020820a08a00800228800208\\\n        028820208220808808028028220808a20020220220800a00008200820a08020828208a00200a20828008820200\\\n        808020208220208808800200800a00a28020008a20008a20000220200808820800220820208008828028200a00\\\n        a08000228820808208000028020200820808008820a08008020000a20a08a20028200000000820808000200800\\\n        228820228200200a28820020020200208820220220008828828200800008228000008a00800a00808208200008\\\n        228008020020200020008228a00800820800028000a00000820208a20208028020008020800a28020028000a08\\\n        a00808000200000220808000a20200028808208800a00000828220800208a08820020820008820020208800000\\\n        200008020220a08000020028000808800800200a20208228820228200a00808800200800a08a00020008820208\\\n        800020200820808020020008820a00000028020220008808008200220800008028000800000228008220020808\\\n        808000028a00200000028208220a00220028028000a00020800008000808a28000020200208028828200a00200\\\n        a00800208820208200020028800208808020208200000828020008820000a00800228020008808000220a20a00\\\n        220000200000800a20828200000a08000820028200200028820008a00008000008020a00a00a00828028020808\\\n        000000200a00808200800020800800a00008220820000a00800208a20000028008200020208200008000a20a08\\\n        200820020020000a08800020200000228828008800200000008020800800208020028820208028800208220a00\\\n        a00020020200008820028208200000020800220200808008000228800000800828000820800200800220000000\\\n        820820208a00208a08000020a20000a20028220000008208808020000000200028228a00800208808020800008\\\n        a08000000220200820808200220a08828028000820000220020008000000820000220000808220800208200a00\\\n        800808028020200200800000a20208808000200820a08020028020820808200828208200808000008200000a00\\\n        008808020000000808000228020a08800020200200008000828008200a00a08020008800000a00028028020000\\\n        228808000820a00200020220800000028028220820208800820200220008008020000020800828000020200008\\\n        020800228200808220800000020008028008028000a00008000008000208000800020a00008828020200820808\\\n        828028008820a00220008000220800008808220220008220008008a00000008800000820800800800208a20000\\\n        820020208800a00200000008000a08000020008200800828808020820000020008220200200008028028820000\\\n        208800228800208008000008020808028000000220a00220008200000000800808200a20000200808000a00800\\\n        228008200020808808820208200208820808000220000220028020a00800a20000208000000208808020020a00\\\n        000028228000800a08020200000200208000208800208800808200220800820028000800008a00800020220008\\\n        a08000020800208200828028a00000a20820020800200800820220000000020008008220a00208008000a00808\\\n        000028008220800028008220020208008820020a00200220008200020a008080002080000000#10000\",\n        Less,\n    );\n\n    let pc_f32 = Float::prime_constant_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(pc_f32.to_string(), \"0.41468251\");\n    assert_eq!(to_hex_string(&pc_f32), \"0x0.6a28a20#24\");\n    assert_eq!(pc_f32, f32::PRIME_CONSTANT);\n\n    let pc_f64 = Float::prime_constant_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(pc_f64.to_string(), \"0.41468250985111166\");\n    assert_eq!(to_hex_string(&pc_f64), \"0x0.6a28a20a08a208#53\");\n    assert_eq!(pc_f64, f64::PRIME_CONSTANT);\n}\n\n#[test]\n#[should_panic]\nfn prime_constant_prec_fail_1() {\n    Float::prime_constant_prec(0);\n}\n\nfn test_prime_constant_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::prime_constant_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = prime_constant_prec_round_naive(prec, rm);\n    assert_eq!(x, x_alt);\n    assert_eq!(o, o_alt);\n}\n\n#[test]\npub fn test_prime_constant_prec_round() {\n    test_prime_constant_prec_round_helper(1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test_prime_constant_prec_round_helper(1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test_prime_constant_prec_round_helper(1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test_prime_constant_prec_round_helper(1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test_prime_constant_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Greater);\n\n    test_prime_constant_prec_round_helper(2, Floor, \"0.4\", \"0x0.6#2\", Less);\n    test_prime_constant_prec_round_helper(2, Ceiling, \"0.5\", \"0x0.8#2\", Greater);\n    test_prime_constant_prec_round_helper(2, Down, \"0.4\", \"0x0.6#2\", Less);\n    test_prime_constant_prec_round_helper(2, Up, \"0.5\", \"0x0.8#2\", Greater);\n    test_prime_constant_prec_round_helper(2, Nearest, \"0.4\", \"0x0.6#2\", Less);\n\n    test_prime_constant_prec_round_helper(3, Floor, \"0.38\", \"0x0.6#3\", Less);\n    test_prime_constant_prec_round_helper(3, Ceiling, \"0.44\", \"0x0.7#3\", Greater);\n    test_prime_constant_prec_round_helper(3, Down, \"0.38\", \"0x0.6#3\", Less);\n    test_prime_constant_prec_round_helper(3, Up, \"0.44\", \"0x0.7#3\", Greater);\n    test_prime_constant_prec_round_helper(3, Nearest, \"0.44\", \"0x0.7#3\", Greater);\n\n    test_prime_constant_prec_round_helper(4, Floor, \"0.41\", \"0x0.68#4\", Less);\n    test_prime_constant_prec_round_helper(4, Ceiling, \"0.44\", \"0x0.70#4\", Greater);\n    test_prime_constant_prec_round_helper(4, Down, \"0.41\", \"0x0.68#4\", Less);\n    test_prime_constant_prec_round_helper(4, Up, \"0.44\", \"0x0.70#4\", Greater);\n    test_prime_constant_prec_round_helper(4, Nearest, \"0.41\", \"0x0.68#4\", Less);\n\n    test_prime_constant_prec_round_helper(5, Floor, \"0.41\", \"0x0.68#5\", Less);\n    test_prime_constant_prec_round_helper(5, Ceiling, \"0.42\", \"0x0.6c#5\", Greater);\n    test_prime_constant_prec_round_helper(5, Down, \"0.41\", \"0x0.68#5\", Less);\n    test_prime_constant_prec_round_helper(5, Up, \"0.42\", \"0x0.6c#5\", Greater);\n    test_prime_constant_prec_round_helper(5, Nearest, \"0.42\", \"0x0.6c#5\", Greater);\n\n    test_prime_constant_prec_round_helper(6, Floor, \"0.414\", \"0x0.6a#6\", Less);\n    test_prime_constant_prec_round_helper(6, Ceiling, \"0.42\", \"0x0.6c#6\", Greater);\n    test_prime_constant_prec_round_helper(6, Down, \"0.414\", \"0x0.6a#6\", Less);\n    test_prime_constant_prec_round_helper(6, Up, \"0.42\", \"0x0.6c#6\", Greater);\n    test_prime_constant_prec_round_helper(6, Nearest, \"0.414\", \"0x0.6a#6\", Less);\n\n    test_prime_constant_prec_round_helper(7, Floor, \"0.414\", \"0x0.6a#7\", Less);\n    test_prime_constant_prec_round_helper(7, Ceiling, \"0.418\", \"0x0.6b#7\", Greater);\n    test_prime_constant_prec_round_helper(7, Down, \"0.414\", \"0x0.6a#7\", Less);\n    test_prime_constant_prec_round_helper(7, Up, \"0.418\", \"0x0.6b#7\", Greater);\n    test_prime_constant_prec_round_helper(7, Nearest, \"0.414\", \"0x0.6a#7\", Less);\n\n    test_prime_constant_prec_round_helper(8, Floor, \"0.414\", \"0x0.6a0#8\", Less);\n    test_prime_constant_prec_round_helper(8, Ceiling, \"0.416\", \"0x0.6a8#8\", Greater);\n    test_prime_constant_prec_round_helper(8, Down, \"0.414\", \"0x0.6a0#8\", Less);\n    test_prime_constant_prec_round_helper(8, Up, \"0.416\", \"0x0.6a8#8\", Greater);\n    test_prime_constant_prec_round_helper(8, Nearest, \"0.414\", \"0x0.6a0#8\", Less);\n\n    test_prime_constant_prec_round_helper(9, Floor, \"0.414\", \"0x0.6a0#9\", Less);\n    test_prime_constant_prec_round_helper(9, Ceiling, \"0.415\", \"0x0.6a4#9\", Greater);\n    test_prime_constant_prec_round_helper(9, Down, \"0.414\", \"0x0.6a0#9\", Less);\n    test_prime_constant_prec_round_helper(9, Up, \"0.415\", \"0x0.6a4#9\", Greater);\n    test_prime_constant_prec_round_helper(9, Nearest, \"0.415\", \"0x0.6a4#9\", Greater);\n\n    test_prime_constant_prec_round_helper(10, Floor, \"0.4146\", \"0x0.6a2#10\", Less);\n    test_prime_constant_prec_round_helper(10, Ceiling, \"0.415\", \"0x0.6a4#10\", Greater);\n    test_prime_constant_prec_round_helper(10, Down, \"0.4146\", \"0x0.6a2#10\", Less);\n    test_prime_constant_prec_round_helper(10, Up, \"0.415\", \"0x0.6a4#10\", Greater);\n    test_prime_constant_prec_round_helper(10, Nearest, \"0.4146\", \"0x0.6a2#10\", Less);\n\n    test_prime_constant_prec_round_helper(\n        100,\n        Floor,\n        \"0.4146825098511116602481096221542\",\n        \"0x0.6a28a20a08a208282282208088#100\",\n        Less,\n    );\n    test_prime_constant_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.4146825098511116602481096221546\",\n        \"0x0.6a28a20a08a208282282208090#100\",\n        Greater,\n    );\n    test_prime_constant_prec_round_helper(\n        100,\n        Down,\n        \"0.4146825098511116602481096221542\",\n        \"0x0.6a28a20a08a208282282208088#100\",\n        Less,\n    );\n    test_prime_constant_prec_round_helper(\n        100,\n        Up,\n        \"0.4146825098511116602481096221546\",\n        \"0x0.6a28a20a08a208282282208090#100\",\n        Greater,\n    );\n    test_prime_constant_prec_round_helper(\n        100,\n        Nearest,\n        \"0.4146825098511116602481096221542\",\n        \"0x0.6a28a20a08a208282282208088#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn prime_constant_prec_round_fail_1() {\n    Float::prime_constant_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn prime_constant_prec_round_fail_2() {\n    Float::prime_constant_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn prime_constant_prec_round_fail_3() {\n    Float::prime_constant_prec_round(1000, Exact);\n}\n\n#[test]\nfn prime_constant_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (pc, o) = Float::prime_constant_prec(prec);\n        assert!(pc.is_valid());\n        assert_eq!(pc.get_prec(), Some(prec));\n        assert_ne!(o, Equal);\n        assert_eq!(pc.get_exponent(), Some(if prec == 1 { 0 } else { -1 }));\n        if o == Less {\n            let (pc_alt, o_alt) = Float::prime_constant_prec_round(prec, Ceiling);\n            let mut next_upper = pc.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pc_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pc.is_power_of_2() {\n            let (pc_alt, o_alt) = Float::prime_constant_prec_round(prec, Floor);\n            let mut next_lower = pc.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pc_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (pc_alt, o_alt) = Float::prime_constant_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&pc_alt), ComparableFloatRef(&pc));\n        assert_eq!(o_alt, o);\n\n        let (pc_alt, o_alt) = prime_constant_prec_round_naive(prec, Nearest);\n        assert_eq!(pc, pc_alt);\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[test]\nfn prime_constant_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (pc, o) = Float::prime_constant_prec_round(prec, rm);\n        assert!(pc.is_valid());\n        assert_eq!(pc.get_prec(), Some(prec));\n        assert_ne!(o, Equal);\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 0,\n            _ => -1,\n        };\n        assert_eq!(pc.get_exponent(), Some(expected_exponent));\n        if o == Less {\n            let (pc_alt, o_alt) = Float::prime_constant_prec_round(prec, Ceiling);\n            let mut next_upper = pc.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(pc_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !pc.is_power_of_2() {\n            let (pc_alt, o_alt) = Float::prime_constant_prec_round(prec, Floor);\n            let mut next_lower = pc.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(pc_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        let (pc_alt, o_alt) = prime_constant_prec_round_naive(prec, rm);\n        assert_eq!(pc, pc_alt);\n        assert_eq!(o, o_alt);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::prime_constant_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::prime_constant_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/prouhet_thue_morse_constant.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::ProuhetThueMorseConstant;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::prouhet_thue_morse_constant::*;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_prouhet_thue_morse_constant_prec_helper(\n    prec: u64,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::prouhet_thue_morse_constant_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = prouhet_thue_morse_constant_prec_round_naive(prec, Nearest);\n    assert_eq!(x, x_alt);\n    assert_eq!(o, o_alt);\n}\n\n#[test]\npub fn test_prouhet_thue_morse_constant_prec() {\n    test_prouhet_thue_morse_constant_prec_helper(1, \"0.5\", \"0x0.8#1\", Greater);\n    test_prouhet_thue_morse_constant_prec_helper(2, \"0.4\", \"0x0.6#2\", Less);\n    test_prouhet_thue_morse_constant_prec_helper(3, \"0.44\", \"0x0.7#3\", Greater);\n    test_prouhet_thue_morse_constant_prec_helper(4, \"0.41\", \"0x0.68#4\", Less);\n    test_prouhet_thue_morse_constant_prec_helper(5, \"0.41\", \"0x0.68#5\", Less);\n    test_prouhet_thue_morse_constant_prec_helper(6, \"0.414\", \"0x0.6a#6\", Greater);\n    test_prouhet_thue_morse_constant_prec_helper(7, \"0.414\", \"0x0.6a#7\", Greater);\n    test_prouhet_thue_morse_constant_prec_helper(8, \"0.412\", \"0x0.698#8\", Less);\n    test_prouhet_thue_morse_constant_prec_helper(9, \"0.412\", \"0x0.698#9\", Less);\n    test_prouhet_thue_morse_constant_prec_helper(10, \"0.4126\", \"0x0.69a#10\", Greater);\n    test_prouhet_thue_morse_constant_prec_helper(\n        100,\n        \"0.4124540336401075977833613682584\",\n        \"0x0.69969669966969969669699668#100\",\n        Less,\n    );\n    test_prouhet_thue_morse_constant_prec_helper(\n        1000,\n        \"0.412454033640107597783361368258455283089478374455769557573379415348793592365782588963804\\\n        540486212133396256366446538137487421617125193606520130996812525914093898811685058241405148\\\n        794923736837717681632072372543961648455116929274915967121308797839015745939416763942926546\\\n        99576354558364476401478446511510844\",\n        \"0x0.6996966996696996966969966996966996696996699696696996966996696996966969966996966969969\\\n        669966969966996966996696996966969966996966996696996699696696996966996696996699696699669699\\\n        6966969966996966969969669966969969669699669969669966969966996966969969669968#1000\",\n        Greater,\n    );\n    test_prouhet_thue_morse_constant_prec_helper(\n        10000,\n        \"0.412454033640107597783361368258455283089478374455769557573379415348793592365782588963804\\\n        540486212133396256366446538137487421617125193606520130996812525914093898811685058241405148\\\n        794923736837717681632072372543961648455116929274915967121308797839015745939416763942926546\\\n        995763545583644764014784465115108432988880527862797583778966429806153625600892794767509570\\\n        613156170981916634767556262265886591706560103745429025080980592282684200382286637025552138\\\n        072551019786013560720441271576469980054213089589582092326366528534417259882166080658990995\\\n        454185078647844640598822656110795985657599962216385510031350572070562361426971255128326932\\\n        200511472227565707730468866881043116266791929041303471097804134296620336523301148618999636\\\n        607737503684384287533124783775524067880628087063676089104069872257951121771322589484343969\\\n        687095887155500338806472758969301236596955913500219809107121878986270983191365987288252181\\\n        126158494661750104956413082261728325258668242137155812289887905859814150448158087621806081\\\n        262788059473203194858059514889641770915367577963421317521615653898873066742051436896862845\\\n        559388487896091534788479920439498978693239273118810516671742331317074845718885491752000298\\\n        494549886494536473002915644233647450149747441404205378363056251376268024177778124482615212\\\n        986239829412055649329758982540912039441942593759895057769683431420175890362746422845117500\\\n        028864842247279148167611365866356168475145086817445555637346709003759617604542400457827717\\\n        878660619366846815483941374378957060770110880180541318234323659237369552401312033505621806\\\n        489384014183232923162046501177883641270956312786606124433156307628120044554491098561964906\\\n        941642998546962635980094725095337754362574897392106593547505034744530716373746139055913844\\\n        730509118321844885047459136295028893709649115890738042446256488167921608092525231651808551\\\n        275515631923236859178416003062357823567287388396791613593690713019818632422297617615418611\\\n        504665052818584325511618352200787725967763734519804573074925771880268729695759436794061431\\\n        099083941098658903463402394219222397121260948820568428682987584463231060168451271023138827\\\n        618185738550975032215601211268731359671002623792857579075515885840571314634970190214029027\\\n        767535211043320712596064063934151016649744328535127842648397490736292971851028934173894800\\\n        896326950620264219873205858953858503888863733655930190565936770347310031381812711297640523\\\n        854923089574146136921130192885320184597064184712813990427490161972158454924359809839110934\\\n        222905109312597374946863138945391555541320741472882457682612774489682755147712902066198766\\\n        365305692386197821993411562093365185277357462610197541359244519518547852573339123003451159\\\n        324066183679763125504488718106276971066142222729525177728792136200206791458838091045048890\\\n        889263477842031146946636054226135511708407225571080034132437244605493617364337010772961383\\\n        884632019459005730120007550129264229222419321684701101892904472852138411474750231020219380\\\n        490568164815194679503954588116034274794607988054271917142826665676154809041554888257037645\\\n        08626387325662901457682774568054766955037516\",\n        \"0x0.6996966996696996966969966996966996696996699696696996966996696996966969966996966969969\\\n        669966969966996966996696996966969966996966996696996699696696996966996696996699696699669699\\\n        696696996699696696996966996696996966969966996966996696996699696696996966996696996966969966\\\n        996966969969669966969966996966996696996966969966996966969969669966969969669699669969669966\\\n        969966996966969969669966969966996966996696996966969966996966996696996699696696996966996696\\\n        996966969966996966969969669966969966996966996696996966969966996966996696996699696696996966\\\n        996696996699696699669699696696996699696696996966996696996966969966996966996696996699696696\\\n        996966996696996699696699669699696696996699696699669699669969669699696699669699696696996699\\\n        696696996966996696996699696699669699696696996699696696996966996696996966969966996966996696\\\n        996699696696996966996696996966969966996966969969669966969966996966996696996966969966996966\\\n        996696996699696696996966996696996699696699669699696696996699696696996966996696996966969966\\\n        996966996696996699696696996966996696996966969966996966969969669966969966996966996696996966\\\n        969966996966969969669966969969669699669969669966969966996966969969669966969966996966996696\\\n        996966969966996966996696996699696696996966996696996966969966996966969969669966969966996966\\\n        996696996966969966996966969969669966969969669699669969669966969966996966969969669966969969\\\n        669699669969669699696699669699669969669966969969669699669969669966969966996966969969669966\\\n        969966996966996696996966969966996966969969669966969969669699669969669966969966996966969969\\\n        669966969966996966996696996966969966996966996696996699696696996966996696996966969966996966\\\n        969969669966969966996966996696996966969966996966996696996699696696996966996696996699696699\\\n        669699696696996699696696996966996696996966969966996966996696996699696696996966996696996966\\\n        969966996966969969669966969966996966996696996966969966996966969969669966969969669699669969\\\n        669966969966996966969969669966969966996966996696996966969966996966996696996699696696996966\\\n        996696996966969966996966969969669966969966996966996696996966969966996966996696996699696696\\\n        996966996696996699696699669699696696996699696696996966996696996966969966996966996696996699\\\n        696696996966996696996699696699669699696696996699696699669699669969669699696699669699696696\\\n        996699696696996966996696996699696699669699696696996699696696996966996696996966969966996966\\\n        996696996699696696996966996696996966969966996966969969669966969966996966996696996966969966\\\n        9969669966969966996966969969669966969966996966996696996966969966996966969968#10000\",\n        Less,\n    );\n\n    let ptmc_f32 = Float::prouhet_thue_morse_constant_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(ptmc_f32.to_string(), \"0.41245404\");\n    assert_eq!(to_hex_string(&ptmc_f32), \"0x0.6996968#24\");\n    assert_eq!(ptmc_f32, f32::PROUHET_THUE_MORSE_CONSTANT);\n\n    let ptmc_f64 = Float::prouhet_thue_morse_constant_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(ptmc_f64.to_string(), \"0.41245403364010758\");\n    assert_eq!(to_hex_string(&ptmc_f64), \"0x0.69969669966968#53\");\n    assert_eq!(ptmc_f64, f64::PROUHET_THUE_MORSE_CONSTANT);\n}\n\n#[test]\n#[should_panic]\nfn prouhet_thue_morse_constant_prec_fail_1() {\n    Float::prouhet_thue_morse_constant_prec(0);\n}\n\nfn test_prouhet_thue_morse_constant_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::prouhet_thue_morse_constant_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = prouhet_thue_morse_constant_prec_round_naive(prec, rm);\n    assert_eq!(x, x_alt);\n    assert_eq!(o, o_alt);\n}\n\n#[test]\npub fn test_prouhet_thue_morse_constant_prec_round() {\n    test_prouhet_thue_morse_constant_prec_round_helper(1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Greater);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(2, Floor, \"0.4\", \"0x0.6#2\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(2, Ceiling, \"0.5\", \"0x0.8#2\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(2, Down, \"0.4\", \"0x0.6#2\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(2, Up, \"0.5\", \"0x0.8#2\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(2, Nearest, \"0.4\", \"0x0.6#2\", Less);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(3, Floor, \"0.38\", \"0x0.6#3\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(3, Ceiling, \"0.44\", \"0x0.7#3\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(3, Down, \"0.38\", \"0x0.6#3\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(3, Up, \"0.44\", \"0x0.7#3\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(3, Nearest, \"0.44\", \"0x0.7#3\", Greater);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(4, Floor, \"0.41\", \"0x0.68#4\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(4, Ceiling, \"0.44\", \"0x0.70#4\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(4, Down, \"0.41\", \"0x0.68#4\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(4, Up, \"0.44\", \"0x0.70#4\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(4, Nearest, \"0.41\", \"0x0.68#4\", Less);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(5, Floor, \"0.41\", \"0x0.68#5\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(5, Ceiling, \"0.42\", \"0x0.6c#5\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(5, Down, \"0.41\", \"0x0.68#5\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(5, Up, \"0.42\", \"0x0.6c#5\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(5, Nearest, \"0.41\", \"0x0.68#5\", Less);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(6, Floor, \"0.406\", \"0x0.68#6\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(6, Ceiling, \"0.414\", \"0x0.6a#6\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(6, Down, \"0.406\", \"0x0.68#6\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(6, Up, \"0.414\", \"0x0.6a#6\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(6, Nearest, \"0.414\", \"0x0.6a#6\", Greater);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(7, Floor, \"0.41\", \"0x0.69#7\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(7, Ceiling, \"0.414\", \"0x0.6a#7\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(7, Down, \"0.41\", \"0x0.69#7\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(7, Up, \"0.414\", \"0x0.6a#7\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(7, Nearest, \"0.414\", \"0x0.6a#7\", Greater);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(8, Floor, \"0.412\", \"0x0.698#8\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(8, Ceiling, \"0.414\", \"0x0.6a0#8\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(8, Down, \"0.412\", \"0x0.698#8\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(8, Up, \"0.414\", \"0x0.6a0#8\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(8, Nearest, \"0.412\", \"0x0.698#8\", Less);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(9, Floor, \"0.412\", \"0x0.698#9\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(9, Ceiling, \"0.413\", \"0x0.69c#9\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(9, Down, \"0.412\", \"0x0.698#9\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(9, Up, \"0.413\", \"0x0.69c#9\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(9, Nearest, \"0.412\", \"0x0.698#9\", Less);\n\n    test_prouhet_thue_morse_constant_prec_round_helper(10, Floor, \"0.4121\", \"0x0.698#10\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(\n        10,\n        Ceiling,\n        \"0.4126\",\n        \"0x0.69a#10\",\n        Greater,\n    );\n    test_prouhet_thue_morse_constant_prec_round_helper(10, Down, \"0.4121\", \"0x0.698#10\", Less);\n    test_prouhet_thue_morse_constant_prec_round_helper(10, Up, \"0.4126\", \"0x0.69a#10\", Greater);\n    test_prouhet_thue_morse_constant_prec_round_helper(\n        10,\n        Nearest,\n        \"0.4126\",\n        \"0x0.69a#10\",\n        Greater,\n    );\n\n    test_prouhet_thue_morse_constant_prec_round_helper(\n        100,\n        Floor,\n        \"0.4124540336401075977833613682584\",\n        \"0x0.69969669966969969669699668#100\",\n        Less,\n    );\n    test_prouhet_thue_morse_constant_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.4124540336401075977833613682588\",\n        \"0x0.69969669966969969669699670#100\",\n        Greater,\n    );\n    test_prouhet_thue_morse_constant_prec_round_helper(\n        100,\n        Down,\n        \"0.4124540336401075977833613682584\",\n        \"0x0.69969669966969969669699668#100\",\n        Less,\n    );\n    test_prouhet_thue_morse_constant_prec_round_helper(\n        100,\n        Up,\n        \"0.4124540336401075977833613682588\",\n        \"0x0.69969669966969969669699670#100\",\n        Greater,\n    );\n    test_prouhet_thue_morse_constant_prec_round_helper(\n        100,\n        Nearest,\n        \"0.4124540336401075977833613682584\",\n        \"0x0.69969669966969969669699668#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn prouhet_thue_morse_constant_prec_round_fail_1() {\n    Float::prouhet_thue_morse_constant_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn prouhet_thue_morse_constant_prec_round_fail_2() {\n    Float::prouhet_thue_morse_constant_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn prouhet_thue_morse_constant_prec_round_fail_3() {\n    Float::prouhet_thue_morse_constant_prec_round(1000, Exact);\n}\n\n#[test]\nfn prouhet_thue_morse_constant_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (ptmc, o) = Float::prouhet_thue_morse_constant_prec(prec);\n        assert!(ptmc.is_valid());\n        assert_eq!(ptmc.get_prec(), Some(prec));\n        assert_eq!(ptmc.get_exponent(), Some(if prec == 1 { 0 } else { -1 }));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (ptmc_alt, o_alt) = Float::prouhet_thue_morse_constant_prec_round(prec, Ceiling);\n            let mut next_upper = ptmc.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(ptmc_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !ptmc.is_power_of_2() {\n            let (ptmc_alt, o_alt) = Float::prouhet_thue_morse_constant_prec_round(prec, Floor);\n            let mut next_lower = ptmc.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(ptmc_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (ptmc_alt, o_alt) = Float::prouhet_thue_morse_constant_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&ptmc_alt), ComparableFloatRef(&ptmc));\n        assert_eq!(o_alt, o);\n\n        let (ptmc_alt, o_alt) = prouhet_thue_morse_constant_prec_round_naive(prec, Nearest);\n        assert_eq!(ptmc, ptmc_alt);\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[test]\nfn prouhet_thue_morse_constant_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (ptmc, o) = Float::prouhet_thue_morse_constant_prec_round(prec, rm);\n        assert!(ptmc.is_valid());\n        assert_eq!(ptmc.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 0,\n            _ => -1,\n        };\n        assert_eq!(ptmc.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (ptmc_alt, o_alt) = Float::prouhet_thue_morse_constant_prec_round(prec, Ceiling);\n            let mut next_upper = ptmc.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(ptmc_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !ptmc.is_power_of_2() {\n            let (ptmc_alt, o_alt) = Float::prouhet_thue_morse_constant_prec_round(prec, Floor);\n            let mut next_lower = ptmc.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(ptmc_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        let (ptmc_alt, o_alt) = prouhet_thue_morse_constant_prec_round_naive(prec, rm);\n        assert_eq!(ptmc, ptmc_alt);\n        assert_eq!(o, o_alt);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::prouhet_thue_morse_constant_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::prouhet_thue_morse_constant_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/sqrt_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Sqrt2;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{\n    rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::constants::sqrt_2::rug_sqrt_2_prec_round;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_sqrt_2_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::sqrt_2_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (rug_x, rug_o) =\n        rug_sqrt_2_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_x)),\n        ComparableFloatRef(&x)\n    );\n    assert_eq!(rug_o, o);\n}\n\n#[test]\npub fn test_sqrt_2_prec() {\n    test_sqrt_2_prec_helper(1, \"1.0\", \"0x1.0#1\", Less);\n    test_sqrt_2_prec_helper(2, \"1.5\", \"0x1.8#2\", Greater);\n    test_sqrt_2_prec_helper(3, \"1.5\", \"0x1.8#3\", Greater);\n    test_sqrt_2_prec_helper(4, \"1.4\", \"0x1.6#4\", Less);\n    test_sqrt_2_prec_helper(5, \"1.44\", \"0x1.7#5\", Greater);\n    test_sqrt_2_prec_helper(6, \"1.41\", \"0x1.68#6\", Less);\n    test_sqrt_2_prec_helper(7, \"1.42\", \"0x1.6c#7\", Greater);\n    test_sqrt_2_prec_helper(8, \"1.414\", \"0x1.6a#8\", Less);\n    test_sqrt_2_prec_helper(9, \"1.414\", \"0x1.6a#9\", Less);\n    test_sqrt_2_prec_helper(10, \"1.414\", \"0x1.6a0#10\", Less);\n    test_sqrt_2_prec_helper(\n        100,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n    test_sqrt_2_prec_helper(\n        1000,\n        \"1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387\\\n        534327641572735013846230912297024924836055850737212644121497099935831413222665927505592755\\\n        799950501152782060571470109559971605970274534596862014728517418640889198609552329230484308\\\n        7143214508397626036279952514079896\",\n        \"0x1.6a09e667f3bcc908b2fb1366ea957d3e3adec17512775099da2f590b0667322a95f90608757145875163f\\\n        cdfb907b6721ee950bc8738f694f0090e6c7bf44ed1a4405d0e855e3e9ca60b38c0237866f7956379222d108b1\\\n        48c1578e45ef89c678dab5147176fd3b99654c68663e7909bea5e241f06dcb05dd549411320#1000\",\n        Less,\n    );\n    test_sqrt_2_prec_helper(\n        10000,\n        \"1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387\\\n        534327641572735013846230912297024924836055850737212644121497099935831413222665927505592755\\\n        799950501152782060571470109559971605970274534596862014728517418640889198609552329230484308\\\n        714321450839762603627995251407989687253396546331808829640620615258352395054745750287759961\\\n        729835575220337531857011354374603408498847160386899970699004815030544027790316454247823068\\\n        492936918621580578463111596668713013015618568987237235288509264861249497715421833420428568\\\n        606014682472077143585487415565706967765372022648544701585880162075847492265722600208558446\\\n        652145839889394437092659180031138824646815708263010059485870400318648034219489727829064104\\\n        507263688131373985525611732204024509122770022694112757362728049573810896750401836986836845\\\n        072579936472906076299694138047565482372899718032680247442062926912485905218100445984215059\\\n        112024944134172853147810580360337107730918286931471017111168391658172688941975871658215212\\\n        822951848847208969463386289156288276595263514054226765323969461751129160240871551013515045\\\n        538128756005263146801712740265396947024030051749531886292563138518816347800156936917688185\\\n        237868405228783762938921430065586956868596459515550164472450983689603688732311438941557665\\\n        104088391429233811320605243362948531704991577175622854974143899918802176243096520656421182\\\n        731672625753959471725593463723863226148274262220867115583959992652117625269891754098815934\\\n        864008345708518147223181420407042650905653233339843645786579679651926729239987536661721598\\\n        257886026336361782749599421940377775368142621773879919455139723127406689832998989538672882\\\n        285637869774966251996658352577619893932284534473569479496295216889148549253890475582883452\\\n        609652409654288939453864662574492755638196441031697983306185201937938494005715633372054806\\\n        854057586799967012137223947582142630658513221740883238294728761739364746783743196000159218\\\n        880734785761725221186749042497736692920731109636972160893370866115673458533483329525467585\\\n        164471075784860246360083444911481858765555428645512331421992631133251797060843655970435285\\\n        641008791850076036100915946567067688360557174007675690509613671940132493560524018599910506\\\n        210816359772643138060546701029356997104242510578174953105725593498445112692278034491350663\\\n        756874776028316282960553242242695753452902883876844642917328277088831808702533985233812274\\\n        999081237189254072647536785030482159180188616710897286922920119759988070381854333253646021\\\n        108229927929307287178079988809917674177410898306080032631181642798823117154363869661702999\\\n        934161614878686018045505553986913115186010386375325004558186044804075024119518430567453368\\\n        361367459737442398855328517930896037389891517319587413442881784212502191695187559344438739\\\n        618931454999990610758704909026088351763622474975785885836803745793115733980209998662218694\\\n        992259591327642361941059210032802614987456659968887406795616739185957288864247346358588686\\\n        449682238600698335264279905628316561391394255764906206518602164726303336297507569787060660\\\n        6856498160092718709292153132368281356988938\",\n        \"0x1.6a09e667f3bcc908b2fb1366ea957d3e3adec17512775099da2f590b0667322a95f90608757145875163f\\\n        cdfb907b6721ee950bc8738f694f0090e6c7bf44ed1a4405d0e855e3e9ca60b38c0237866f7956379222d108b1\\\n        48c1578e45ef89c678dab5147176fd3b99654c68663e7909bea5e241f06dcb05dd5494113208194950272956db\\\n        1fa1dfbe9a74059d7927c1884c9b579aa516ca3719e6836df046d8e0209b803fc646a5e6654bd3ef7b43d7fed4\\\n        37c7f9444260fbd40c483ef55038583f97bbd45efb8663107145d5febe765a49e94ec7f597105fbfc2e1fa763e\\\n        f01f3599c82f2fe500b848cf0bd252ae046bf9f1ef7947d46769af8c14bcc67c7c290be76929b0578c10b584fb\\\n        487c924f5b71f82dcd2903609dee8912983d4eaad0eea321f7489f46a7e9030be20fb7694efb58c9984cdd70a1\\\n        da9045c3d133a068423d6e38303d901ba9da3476684796c5cd5972dc0ff3540c3412942d6406101ef6fc6de911\\\n        4a2b4f248c689c600bb40a8b56b041fd5de6e0dd0c66d4831fe7fff5757e4710980cdbd5c268485da5e91b3e2f\\\n        205b72725b971d60a1f888f08a0a6e100ccedc2ce5bd98aee71e42e268d37a6072f220234613ffc22453439ea9\\\n        7a999b6c9e3ce71f94d6092ace120ab8e550e0d5511688631778cf60350d02fe85f29ec8be5c72b807af5771b8\\\n        25b30a0e78376a91c08c6a7f0f8f323b36281d225689c0b5a82047db989f63a8a64e8519bc0d0c1e22280484d9\\\n        4f4f9bb3d4b31d489d75231b5c633c480c96be549bf5d96678b4d2c4dda867bd8e48029fea8c8173567c2ba3d3\\\n        ce9dfe0bd1b4dd771178057b695b7eaf1b05c22c8d5feebd077fec96db8f778fc1c2bbbce1b49ebf5af4460882\\\n        958add01ca7f1b6bc0b7ec1bc6e0a6edbc67f85b274e0861b3a137571b16549873d211c6aae69d801e579445bc\\\n        60a3e0a4fd8968eb794bdc702d6945da94b04a440cabc94387c3d26fd0f3be8af6305a53a177288aca13fb406c\\\n        982915d83ba0d3558d81dd1159e9643eaa27eb7757a2052975b6f4a889e3d092bb1c685480dc2e99947b372ded\\\n        a05e2192f95b1b926512b404c33181d64a359a89b6f8864f3d575319359aa386257a93a57a5977547fa0f606cc\\\n        32eea84ef7103d2d2d57b6c153a5f37c2c77fe2928d321b29470eae4158b3cedc64ade1e431a138bb7be7305b4\\\n        6f7fe0bc754ff3ec042bdc85b325996522a87b8643e3d17870f8c25b5978060d55b82fd4ed3f3e15892b5b5236\\\n        182cb2831f44ca27ad1a66fd56fdc29a7c7a93e4279aa12d460a0d49495b6be4dc73ddf96ee80a9dfc22d8d385\\\n        ea2ecc801d740c1990c7bf28458480527bb8ba8109d2770c3ffde121a7be434f83d0aabfbde531f74bafdbc2da\\\n        fbece02e65bb77b8fbb8cdb4ad8e4b9ef01e2c90f8069d23ecfb0c8e2e27d647daa43762a64b9c7d745344fdb5\\\n        16fc56fa1eae6a95874fb501f69b17b66b81dfba11ed52415d7ee3e53f9585946bb2081617805996805bb4f9da\\\n        796f633c9d13f6c172c3afe3401a32e99dd6a247e279600a3f5c09991a6554a35000ffe090abfbc2d8a4a88145\\\n        9ed127a54ccecb63cf6373a711c9cf91566c397b28278a7f0bb8bbc4516ddcab0f6e9557448f93eeb80f69f34b\\\n        525c760f3380ef9edb8aceefa8db3c7ce26e42aa5984d4db95612ec528a245fcf43db3757f0a0a1fc24fe218f4\\\n        b630720904044b232f38c4032f1c3ab8971dd4f7966dd97614bae8d797a0848b1d5cfdb137e#10000\",\n        Greater,\n    );\n\n    let sqrt_2_f32 = Float::sqrt_2_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_2_f32.to_string(), \"1.4142135\");\n    assert_eq!(to_hex_string(&sqrt_2_f32), \"0x1.6a09e6#24\");\n    assert_eq!(sqrt_2_f32, f32::SQRT_2);\n\n    let sqrt_2_f64 = Float::sqrt_2_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_2_f64.to_string(), \"1.4142135623730951\");\n    assert_eq!(to_hex_string(&sqrt_2_f64), \"0x1.6a09e667f3bcd#53\");\n    assert_eq!(sqrt_2_f64, f64::SQRT_2);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_prec_fail_1() {\n    Float::sqrt_2_prec(0);\n}\n\nfn test_sqrt_2_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::sqrt_2_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_x, rug_o) = rug_sqrt_2_prec_round(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_x)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(rug_o, o);\n    }\n}\n\n#[test]\npub fn test_sqrt_2_prec_round() {\n    test_sqrt_2_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_sqrt_2_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_2_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_sqrt_2_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_2_prec_round_helper(1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test_sqrt_2_prec_round_helper(2, Floor, \"1.0\", \"0x1.0#2\", Less);\n    test_sqrt_2_prec_round_helper(2, Ceiling, \"1.5\", \"0x1.8#2\", Greater);\n    test_sqrt_2_prec_round_helper(2, Down, \"1.0\", \"0x1.0#2\", Less);\n    test_sqrt_2_prec_round_helper(2, Up, \"1.5\", \"0x1.8#2\", Greater);\n    test_sqrt_2_prec_round_helper(2, Nearest, \"1.5\", \"0x1.8#2\", Greater);\n\n    test_sqrt_2_prec_round_helper(3, Floor, \"1.2\", \"0x1.4#3\", Less);\n    test_sqrt_2_prec_round_helper(3, Ceiling, \"1.5\", \"0x1.8#3\", Greater);\n    test_sqrt_2_prec_round_helper(3, Down, \"1.2\", \"0x1.4#3\", Less);\n    test_sqrt_2_prec_round_helper(3, Up, \"1.5\", \"0x1.8#3\", Greater);\n    test_sqrt_2_prec_round_helper(3, Nearest, \"1.5\", \"0x1.8#3\", Greater);\n\n    test_sqrt_2_prec_round_helper(4, Floor, \"1.4\", \"0x1.6#4\", Less);\n    test_sqrt_2_prec_round_helper(4, Ceiling, \"1.5\", \"0x1.8#4\", Greater);\n    test_sqrt_2_prec_round_helper(4, Down, \"1.4\", \"0x1.6#4\", Less);\n    test_sqrt_2_prec_round_helper(4, Up, \"1.5\", \"0x1.8#4\", Greater);\n    test_sqrt_2_prec_round_helper(4, Nearest, \"1.4\", \"0x1.6#4\", Less);\n\n    test_sqrt_2_prec_round_helper(5, Floor, \"1.38\", \"0x1.6#5\", Less);\n    test_sqrt_2_prec_round_helper(5, Ceiling, \"1.44\", \"0x1.7#5\", Greater);\n    test_sqrt_2_prec_round_helper(5, Down, \"1.38\", \"0x1.6#5\", Less);\n    test_sqrt_2_prec_round_helper(5, Up, \"1.44\", \"0x1.7#5\", Greater);\n    test_sqrt_2_prec_round_helper(5, Nearest, \"1.44\", \"0x1.7#5\", Greater);\n\n    test_sqrt_2_prec_round_helper(6, Floor, \"1.41\", \"0x1.68#6\", Less);\n    test_sqrt_2_prec_round_helper(6, Ceiling, \"1.44\", \"0x1.70#6\", Greater);\n    test_sqrt_2_prec_round_helper(6, Down, \"1.41\", \"0x1.68#6\", Less);\n    test_sqrt_2_prec_round_helper(6, Up, \"1.44\", \"0x1.70#6\", Greater);\n    test_sqrt_2_prec_round_helper(6, Nearest, \"1.41\", \"0x1.68#6\", Less);\n\n    test_sqrt_2_prec_round_helper(7, Floor, \"1.41\", \"0x1.68#7\", Less);\n    test_sqrt_2_prec_round_helper(7, Ceiling, \"1.42\", \"0x1.6c#7\", Greater);\n    test_sqrt_2_prec_round_helper(7, Down, \"1.41\", \"0x1.68#7\", Less);\n    test_sqrt_2_prec_round_helper(7, Up, \"1.42\", \"0x1.6c#7\", Greater);\n    test_sqrt_2_prec_round_helper(7, Nearest, \"1.42\", \"0x1.6c#7\", Greater);\n\n    test_sqrt_2_prec_round_helper(8, Floor, \"1.414\", \"0x1.6a#8\", Less);\n    test_sqrt_2_prec_round_helper(8, Ceiling, \"1.42\", \"0x1.6c#8\", Greater);\n    test_sqrt_2_prec_round_helper(8, Down, \"1.414\", \"0x1.6a#8\", Less);\n    test_sqrt_2_prec_round_helper(8, Up, \"1.42\", \"0x1.6c#8\", Greater);\n    test_sqrt_2_prec_round_helper(8, Nearest, \"1.414\", \"0x1.6a#8\", Less);\n\n    test_sqrt_2_prec_round_helper(9, Floor, \"1.414\", \"0x1.6a#9\", Less);\n    test_sqrt_2_prec_round_helper(9, Ceiling, \"1.418\", \"0x1.6b#9\", Greater);\n    test_sqrt_2_prec_round_helper(9, Down, \"1.414\", \"0x1.6a#9\", Less);\n    test_sqrt_2_prec_round_helper(9, Up, \"1.418\", \"0x1.6b#9\", Greater);\n    test_sqrt_2_prec_round_helper(9, Nearest, \"1.414\", \"0x1.6a#9\", Less);\n\n    test_sqrt_2_prec_round_helper(10, Floor, \"1.414\", \"0x1.6a0#10\", Less);\n    test_sqrt_2_prec_round_helper(10, Ceiling, \"1.416\", \"0x1.6a8#10\", Greater);\n    test_sqrt_2_prec_round_helper(10, Down, \"1.414\", \"0x1.6a0#10\", Less);\n    test_sqrt_2_prec_round_helper(10, Up, \"1.416\", \"0x1.6a8#10\", Greater);\n    test_sqrt_2_prec_round_helper(10, Nearest, \"1.414\", \"0x1.6a0#10\", Less);\n\n    test_sqrt_2_prec_round_helper(\n        100,\n        Floor,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n    test_sqrt_2_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.414213562373095048801688724211\",\n        \"0x1.6a09e667f3bcc908b2fb13670#100\",\n        Greater,\n    );\n    test_sqrt_2_prec_round_helper(\n        100,\n        Down,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n    test_sqrt_2_prec_round_helper(\n        100,\n        Up,\n        \"1.414213562373095048801688724211\",\n        \"0x1.6a09e667f3bcc908b2fb13670#100\",\n        Greater,\n    );\n    test_sqrt_2_prec_round_helper(\n        100,\n        Nearest,\n        \"1.414213562373095048801688724209\",\n        \"0x1.6a09e667f3bcc908b2fb1366e#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_prec_round_fail_1() {\n    Float::sqrt_2_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_prec_round_fail_2() {\n    Float::sqrt_2_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_prec_round_fail_3() {\n    Float::sqrt_2_prec_round(1000, Exact);\n}\n\n#[test]\nfn sqrt_2_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (sqrt_2, o) = Float::sqrt_2_prec(prec);\n        assert!(sqrt_2.is_valid());\n        assert_eq!(sqrt_2.get_prec(), Some(prec));\n        assert_eq!(sqrt_2.get_exponent(), Some(1));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_2_alt, o_alt) = Float::sqrt_2_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(sqrt_2_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_2.is_power_of_2() {\n            let (sqrt_2_alt, o_alt) = Float::sqrt_2_prec_round(prec, Floor);\n            let mut next_lower = sqrt_2.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(sqrt_2_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (sqrt_2_alt, o_alt) = Float::sqrt_2_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&sqrt_2_alt), ComparableFloatRef(&sqrt_2));\n        assert_eq!(o_alt, o);\n\n        let (rug_sqrt_2, rug_o) =\n            rug_sqrt_2_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt_2)),\n            ComparableFloatRef(&sqrt_2)\n        );\n        assert_eq!(rug_o, o);\n    });\n}\n\n#[test]\nfn sqrt_2_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (sqrt_2, o) = Float::sqrt_2_prec_round(prec, rm);\n        assert!(sqrt_2.is_valid());\n        assert_eq!(sqrt_2.get_prec(), Some(prec));\n        assert_eq!(\n            sqrt_2.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                2\n            } else {\n                1\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_2_alt, o_alt) = Float::sqrt_2_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(sqrt_2_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_2.is_power_of_2() {\n            let (sqrt_2_alt, o_alt) = Float::sqrt_2_prec_round(prec, Floor);\n            let mut next_lower = sqrt_2.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(sqrt_2_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sqrt_2, rug_o) = rug_sqrt_2_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sqrt_2)),\n                ComparableFloatRef(&sqrt_2)\n            );\n            assert_eq!(rug_o, o);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::sqrt_2_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::sqrt_2_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/sqrt_2_over_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Sqrt2Over2;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{\n    rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::constants::sqrt_2_over_2::rug_sqrt_2_over_2_prec_round;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_sqrt_2_over_2_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::sqrt_2_over_2_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (rug_x, rug_o) =\n        rug_sqrt_2_over_2_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_x)),\n        ComparableFloatRef(&x)\n    );\n    assert_eq!(rug_o, o);\n}\n\n#[test]\npub fn test_sqrt_2_over_2_prec() {\n    test_sqrt_2_over_2_prec_helper(1, \"0.5\", \"0x0.8#1\", Less);\n    test_sqrt_2_over_2_prec_helper(2, \"0.8\", \"0x0.c#2\", Greater);\n    test_sqrt_2_over_2_prec_helper(3, \"0.8\", \"0x0.c#3\", Greater);\n    test_sqrt_2_over_2_prec_helper(4, \"0.7\", \"0x0.b#4\", Less);\n    test_sqrt_2_over_2_prec_helper(5, \"0.72\", \"0x0.b8#5\", Greater);\n    test_sqrt_2_over_2_prec_helper(6, \"0.7\", \"0x0.b4#6\", Less);\n    test_sqrt_2_over_2_prec_helper(7, \"0.71\", \"0x0.b6#7\", Greater);\n    test_sqrt_2_over_2_prec_helper(8, \"0.707\", \"0x0.b5#8\", Less);\n    test_sqrt_2_over_2_prec_helper(9, \"0.707\", \"0x0.b50#9\", Less);\n    test_sqrt_2_over_2_prec_helper(10, \"0.707\", \"0x0.b50#10\", Less);\n    test_sqrt_2_over_2_prec_helper(\n        100,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n    test_sqrt_2_over_2_prec_helper(\n        1000,\n        \"0.707106781186547524400844362104849039284835937688474036588339868995366239231053519425193\\\n        767163820786367506923115456148512462418027925368606322060748549967915706611332963752796377\\\n        899975250576391030285735054779985802985137267298431007364258709320444599304776164615242154\\\n        3571607254198813018139976257039948\",\n        \"0x0.b504f333f9de6484597d89b3754abe9f1d6f60ba893ba84ced17ac85833399154afc83043ab8a2c3a8b1f\\\n        e6fdc83db390f74a85e439c7b4a780487363dfa2768d2202e8742af1f4e53059c6011bc337bcab1bc911688458\\\n        a460abc722f7c4e33c6d5a8a38bb7e9dccb2a634331f3c84df52f120f836e582eeaa4a08990#1000\",\n        Less,\n    );\n    test_sqrt_2_over_2_prec_helper(\n        10000,\n        \"0.707106781186547524400844362104849039284835937688474036588339868995366239231053519425193\\\n        767163820786367506923115456148512462418027925368606322060748549967915706611332963752796377\\\n        899975250576391030285735054779985802985137267298431007364258709320444599304776164615242154\\\n        357160725419881301813997625703994843626698273165904414820310307629176197527372875143879980\\\n        864917787610168765928505677187301704249423580193449985349502407515272013895158227123911534\\\n        246468459310790289231555798334356506507809284493618617644254632430624748857710916710214284\\\n        303007341236038571792743707782853483882686011324272350792940081037923746132861300104279223\\\n        326072919944697218546329590015569412323407854131505029742935200159324017109744863914532052\\\n        253631844065686992762805866102012254561385011347056378681364024786905448375200918493418422\\\n        536289968236453038149847069023782741186449859016340123721031463456242952609050222992107529\\\n        556012472067086426573905290180168553865459143465735508555584195829086344470987935829107606\\\n        411475924423604484731693144578144138297631757027113382661984730875564580120435775506757522\\\n        769064378002631573400856370132698473512015025874765943146281569259408173900078468458844092\\\n        618934202614391881469460715032793478434298229757775082236225491844801844366155719470778832\\\n        552044195714616905660302621681474265852495788587811427487071949959401088121548260328210591\\\n        365836312876979735862796731861931613074137131110433557791979996326058812634945877049407967\\\n        432004172854259073611590710203521325452826616669921822893289839825963364619993768330860799\\\n        128943013168180891374799710970188887684071310886939959727569861563703344916499494769336441\\\n        142818934887483125998329176288809946966142267236784739748147608444574274626945237791441726\\\n        304826204827144469726932331287246377819098220515848991653092600968969247002857816686027403\\\n        427028793399983506068611973791071315329256610870441619147364380869682373391871598000079609\\\n        440367392880862610593374521248868346460365554818486080446685433057836729266741664762733792\\\n        582235537892430123180041722455740929382777714322756165710996315566625898530421827985217642\\\n        820504395925038018050457973283533844180278587003837845254806835970066246780262009299955253\\\n        105408179886321569030273350514678498552121255289087476552862796749222556346139017245675331\\\n        878437388014158141480276621121347876726451441938422321458664138544415904351266992616906137\\\n        499540618594627036323768392515241079590094308355448643461460059879994035190927166626823010\\\n        554114963964653643589039994404958837088705449153040016315590821399411558577181934830851499\\\n        967080807439343009022752776993456557593005193187662502279093022402037512059759215283726684\\\n        180683729868721199427664258965448018694945758659793706721440892106251095847593779672219369\\\n        809465727499995305379352454513044175881811237487892942918401872896557866990104999331109347\\\n        496129795663821180970529605016401307493728329984443703397808369592978644432123673179294343\\\n        224841119300349167632139952814158280695697127882453103259301082363151668148753784893530330\\\n        34282490800463593546460765661841406784944688\",\n        \"0x0.b504f333f9de6484597d89b3754abe9f1d6f60ba893ba84ced17ac85833399154afc83043ab8a2c3a8b1f\\\n        e6fdc83db390f74a85e439c7b4a780487363dfa2768d2202e8742af1f4e53059c6011bc337bcab1bc911688458\\\n        a460abc722f7c4e33c6d5a8a38bb7e9dccb2a634331f3c84df52f120f836e582eeaa4a0899040ca4a81394ab6d\\\n        8fd0efdf4d3a02cebc93e0c4264dabcd528b651b8cf341b6f8236c70104dc01fe32352f332a5e9f7bda1ebff6a\\\n        1be3fca221307dea06241f7aa81c2c1fcbddea2f7dc3318838a2eaff5f3b2d24f4a763facb882fdfe170fd3b1f\\\n        780f9acce41797f2805c246785e929570235fcf8f7bca3ea33b4d7c60a5e633e3e1485f3b494d82bc6085ac27d\\\n        a43e4927adb8fc16e69481b04ef744894c1ea75568775190fba44fa353f48185f107dbb4a77dac64cc266eb850\\\n        ed4822e1e899d034211eb71c181ec80dd4ed1a3b3423cb62e6acb96e07f9aa061a094a16b203080f7b7e36f488\\\n        a515a79246344e3005da0545ab5820feaef3706e86336a418ff3fffababf23884c066deae134242ed2f48d9f17\\\n        902db9392dcb8eb050fc44784505370806676e1672decc57738f21713469bd3039791011a309ffe11229a1cf54\\\n        bd4ccdb64f1e738fca6b04956709055c72a8706aa88b44318bbc67b01a86817f42f94f645f2e395c03d7abb8dc\\\n        12d985073c1bb548e046353f87c7991d9b140e912b44e05ad41023edcc4fb1d45327428cde06860f111402426c\\\n        a7a7cdd9ea598ea44eba918dae319e24064b5f2a4dfaecb33c5a69626ed433dec724014ff54640b9ab3e15d1e9\\\n        e74eff05e8da6ebb88bc02bdb4adbf578d82e11646aff75e83bff64b6dc7bbc7e0e15dde70da4f5fad7a230441\\\n        4ac56e80e53f8db5e05bf60de3705376de33fc2d93a70430d9d09bab8d8b2a4c39e908e355734ec00f2bca22de\\\n        3051f0527ec4b475bca5ee3816b4a2ed4a5825220655e4a1c3e1e937e879df457b182d29d0bb94456509fda036\\\n        4c148aec1dd069aac6c0ee88acf4b21f5513f5bbabd10294badb7a5444f1e8495d8e342a406e174cca3d9b96f6\\\n        d02f10c97cad8dc932895a026198c0eb251acd44db7c43279eaba98c9acd51c312bd49d2bd2cbbaa3fd07b0366\\\n        197754277b881e9696abdb60a9d2f9be163bff14946990d94a3875720ac59e76e3256f0f218d09c5dbdf3982da\\\n        37bff05e3aa7f9f60215ee42d992ccb291543dc321f1e8bc387c612dacbc0306aadc17ea769f9f0ac495ada91b\\\n        0c1659418fa26513d68d337eab7ee14d3e3d49f213cd5096a30506a4a4adb5f26e39eefcb774054efe116c69c2\\\n        f51766400eba060cc863df9422c240293ddc5d4084e93b861ffef090d3df21a7c1e8555fdef298fba5d7ede16d\\\n        7df6701732ddbbdc7ddc66da56c725cf780f16487c034e91f67d86471713eb23ed521bb15325ce3eba29a27eda\\\n        8b7e2b7d0f57354ac3a7da80fb4d8bdb35c0efdd08f6a920aebf71f29fcac2ca35d9040b0bc02ccb402dda7ced\\\n        3cb7b19e4e89fb60b961d7f1a00d1974ceeb5123f13cb0051fae04cc8d32aa51a8007ff04855fde16c525440a2\\\n        cf6893d2a66765b1e7b1b9d388e4e7c8ab361cbd9413c53f85dc5de228b6ee5587b74aaba247c9f75c07b4f9a5\\\n        a92e3b0799c077cf6dc56777d46d9e3e713721552cc26a6dcab09762945122fe7a1ed9babf85050fe127f10c7a\\\n        5b18390482022591979c6201978e1d5c4b8eea7bcb36ecbb0a5d746bcbd042458eae7ed89bf#10000\",\n        Greater,\n    );\n\n    let sqrt_2_over_2_f32 = Float::sqrt_2_over_2_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_2_over_2_f32.to_string(), \"0.70710677\");\n    assert_eq!(to_hex_string(&sqrt_2_over_2_f32), \"0x0.b504f3#24\");\n    assert_eq!(sqrt_2_over_2_f32, f32::SQRT_2_OVER_2);\n\n    let sqrt_2_over_2_f64 = Float::sqrt_2_over_2_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_2_over_2_f64.to_string(), \"0.7071067811865476\");\n    assert_eq!(to_hex_string(&sqrt_2_over_2_f64), \"0x0.b504f333f9de68#53\");\n    assert_eq!(sqrt_2_over_2_f64, f64::SQRT_2_OVER_2);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_over_2_prec_fail_1() {\n    Float::sqrt_2_over_2_prec(0);\n}\n\nfn test_sqrt_2_over_2_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::sqrt_2_over_2_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_x, rug_o) = rug_sqrt_2_over_2_prec_round(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_x)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(rug_o, o);\n    }\n}\n\n#[test]\npub fn test_sqrt_2_over_2_prec_round() {\n    test_sqrt_2_over_2_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_sqrt_2_over_2_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_sqrt_2_over_2_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test_sqrt_2_over_2_prec_round_helper(2, Floor, \"0.5\", \"0x0.8#2\", Less);\n    test_sqrt_2_over_2_prec_round_helper(2, Ceiling, \"0.8\", \"0x0.c#2\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(2, Down, \"0.5\", \"0x0.8#2\", Less);\n    test_sqrt_2_over_2_prec_round_helper(2, Up, \"0.8\", \"0x0.c#2\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(2, Nearest, \"0.8\", \"0x0.c#2\", Greater);\n\n    test_sqrt_2_over_2_prec_round_helper(3, Floor, \"0.6\", \"0x0.a#3\", Less);\n    test_sqrt_2_over_2_prec_round_helper(3, Ceiling, \"0.8\", \"0x0.c#3\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(3, Down, \"0.6\", \"0x0.a#3\", Less);\n    test_sqrt_2_over_2_prec_round_helper(3, Up, \"0.8\", \"0x0.c#3\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(3, Nearest, \"0.8\", \"0x0.c#3\", Greater);\n\n    test_sqrt_2_over_2_prec_round_helper(4, Floor, \"0.7\", \"0x0.b#4\", Less);\n    test_sqrt_2_over_2_prec_round_helper(4, Ceiling, \"0.75\", \"0x0.c#4\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(4, Down, \"0.7\", \"0x0.b#4\", Less);\n    test_sqrt_2_over_2_prec_round_helper(4, Up, \"0.75\", \"0x0.c#4\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(4, Nearest, \"0.7\", \"0x0.b#4\", Less);\n\n    test_sqrt_2_over_2_prec_round_helper(5, Floor, \"0.69\", \"0x0.b0#5\", Less);\n    test_sqrt_2_over_2_prec_round_helper(5, Ceiling, \"0.72\", \"0x0.b8#5\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(5, Down, \"0.69\", \"0x0.b0#5\", Less);\n    test_sqrt_2_over_2_prec_round_helper(5, Up, \"0.72\", \"0x0.b8#5\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(5, Nearest, \"0.72\", \"0x0.b8#5\", Greater);\n\n    test_sqrt_2_over_2_prec_round_helper(6, Floor, \"0.7\", \"0x0.b4#6\", Less);\n    test_sqrt_2_over_2_prec_round_helper(6, Ceiling, \"0.72\", \"0x0.b8#6\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(6, Down, \"0.7\", \"0x0.b4#6\", Less);\n    test_sqrt_2_over_2_prec_round_helper(6, Up, \"0.72\", \"0x0.b8#6\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(6, Nearest, \"0.7\", \"0x0.b4#6\", Less);\n\n    test_sqrt_2_over_2_prec_round_helper(7, Floor, \"0.703\", \"0x0.b4#7\", Less);\n    test_sqrt_2_over_2_prec_round_helper(7, Ceiling, \"0.71\", \"0x0.b6#7\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(7, Down, \"0.703\", \"0x0.b4#7\", Less);\n    test_sqrt_2_over_2_prec_round_helper(7, Up, \"0.71\", \"0x0.b6#7\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(7, Nearest, \"0.71\", \"0x0.b6#7\", Greater);\n\n    test_sqrt_2_over_2_prec_round_helper(8, Floor, \"0.707\", \"0x0.b5#8\", Less);\n    test_sqrt_2_over_2_prec_round_helper(8, Ceiling, \"0.711\", \"0x0.b6#8\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(8, Down, \"0.707\", \"0x0.b5#8\", Less);\n    test_sqrt_2_over_2_prec_round_helper(8, Up, \"0.711\", \"0x0.b6#8\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(8, Nearest, \"0.707\", \"0x0.b5#8\", Less);\n\n    test_sqrt_2_over_2_prec_round_helper(9, Floor, \"0.707\", \"0x0.b50#9\", Less);\n    test_sqrt_2_over_2_prec_round_helper(9, Ceiling, \"0.709\", \"0x0.b58#9\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(9, Down, \"0.707\", \"0x0.b50#9\", Less);\n    test_sqrt_2_over_2_prec_round_helper(9, Up, \"0.709\", \"0x0.b58#9\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(9, Nearest, \"0.707\", \"0x0.b50#9\", Less);\n\n    test_sqrt_2_over_2_prec_round_helper(10, Floor, \"0.707\", \"0x0.b50#10\", Less);\n    test_sqrt_2_over_2_prec_round_helper(10, Ceiling, \"0.708\", \"0x0.b54#10\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(10, Down, \"0.707\", \"0x0.b50#10\", Less);\n    test_sqrt_2_over_2_prec_round_helper(10, Up, \"0.708\", \"0x0.b54#10\", Greater);\n    test_sqrt_2_over_2_prec_round_helper(10, Nearest, \"0.707\", \"0x0.b50#10\", Less);\n\n    test_sqrt_2_over_2_prec_round_helper(\n        100,\n        Floor,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n    test_sqrt_2_over_2_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.7071067811865475244008443621054\",\n        \"0x0.b504f333f9de6484597d89b38#100\",\n        Greater,\n    );\n    test_sqrt_2_over_2_prec_round_helper(\n        100,\n        Down,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n    test_sqrt_2_over_2_prec_round_helper(\n        100,\n        Up,\n        \"0.7071067811865475244008443621054\",\n        \"0x0.b504f333f9de6484597d89b38#100\",\n        Greater,\n    );\n    test_sqrt_2_over_2_prec_round_helper(\n        100,\n        Nearest,\n        \"0.7071067811865475244008443621046\",\n        \"0x0.b504f333f9de6484597d89b37#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_over_2_prec_round_fail_1() {\n    Float::sqrt_2_over_2_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_over_2_prec_round_fail_2() {\n    Float::sqrt_2_over_2_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_2_over_2_prec_round_fail_3() {\n    Float::sqrt_2_over_2_prec_round(1000, Exact);\n}\n\n#[test]\nfn sqrt_2_over_2_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (sqrt_2_over_2, o) = Float::sqrt_2_over_2_prec(prec);\n        assert!(sqrt_2_over_2.is_valid());\n        assert_eq!(sqrt_2_over_2.get_prec(), Some(prec));\n        assert_eq!(sqrt_2_over_2.get_exponent(), Some(0));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_2_over_2_alt, o_alt) = Float::sqrt_2_over_2_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_2_over_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(sqrt_2_over_2_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_2_over_2.is_power_of_2() {\n            let (sqrt_2_over_2_alt, o_alt) = Float::sqrt_2_over_2_prec_round(prec, Floor);\n            let mut next_lower = sqrt_2_over_2.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(sqrt_2_over_2_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (sqrt_2_over_2_alt, o_alt) = Float::sqrt_2_over_2_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&sqrt_2_over_2_alt),\n            ComparableFloatRef(&sqrt_2_over_2)\n        );\n        assert_eq!(o_alt, o);\n\n        let (rug_sqrt_2_over_2, rug_o) =\n            rug_sqrt_2_over_2_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt_2_over_2)),\n            ComparableFloatRef(&sqrt_2_over_2)\n        );\n        assert_eq!(rug_o, o);\n    });\n}\n\n#[test]\nfn sqrt_2_over_2_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (sqrt_2_over_2, o) = Float::sqrt_2_over_2_prec_round(prec, rm);\n        assert!(sqrt_2_over_2.is_valid());\n        assert_eq!(sqrt_2_over_2.get_prec(), Some(prec));\n        assert_eq!(\n            sqrt_2_over_2.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                1\n            } else {\n                0\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_2_over_2_alt, o_alt) = Float::sqrt_2_over_2_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_2_over_2.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(sqrt_2_over_2_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_2_over_2.is_power_of_2() {\n            let (sqrt_2_over_2_alt, o_alt) = Float::sqrt_2_over_2_prec_round(prec, Floor);\n            let mut next_lower = sqrt_2_over_2.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(sqrt_2_over_2_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sqrt_2_over_2, rug_o) = rug_sqrt_2_over_2_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sqrt_2_over_2)),\n                ComparableFloatRef(&sqrt_2_over_2)\n            );\n            assert_eq!(rug_o, o);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::sqrt_2_over_2_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::sqrt_2_over_2_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/sqrt_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Sqrt3;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{\n    rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::constants::sqrt_3::rug_sqrt_3_prec_round;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_sqrt_3_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::sqrt_3_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (rug_x, rug_o) =\n        rug_sqrt_3_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_x)),\n        ComparableFloatRef(&x)\n    );\n    assert_eq!(rug_o, o);\n}\n\n#[test]\npub fn test_sqrt_3_prec() {\n    test_sqrt_3_prec_helper(1, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_3_prec_helper(2, \"1.5\", \"0x1.8#2\", Less);\n    test_sqrt_3_prec_helper(3, \"1.8\", \"0x1.c#3\", Greater);\n    test_sqrt_3_prec_helper(4, \"1.8\", \"0x1.c#4\", Greater);\n    test_sqrt_3_prec_helper(5, \"1.75\", \"0x1.c#5\", Greater);\n    test_sqrt_3_prec_helper(6, \"1.72\", \"0x1.b8#6\", Less);\n    test_sqrt_3_prec_helper(7, \"1.73\", \"0x1.bc#7\", Greater);\n    test_sqrt_3_prec_helper(8, \"1.734\", \"0x1.bc#8\", Greater);\n    test_sqrt_3_prec_helper(9, \"1.73\", \"0x1.bb#9\", Less);\n    test_sqrt_3_prec_helper(10, \"1.732\", \"0x1.bb8#10\", Greater);\n    test_sqrt_3_prec_helper(\n        100,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n    test_sqrt_3_prec_helper(\n        1000,\n        \"1.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146\\\n        186757248575675626141415406703029969945094998952478811655512094373648528093231902305582067\\\n        974820101084674923265015312343266903322886650672254668921837971227047131660367861588019049\\\n        9865373798593894676503475065760508\",\n        \"0x1.bb67ae8584caa73b25742d7078b83b8925d834cc53da4798c720a6486e45a6e2490bcfd95ef15dbda9930\\\n        aae12228f87cc4cf24da3a1ec68d0cd33a01ad9a383b9e122e6138c3ae6de5ede3bd42db7301b6bf553af7b09f\\\n        d6ebef33a9a9fe57729426f30e5892ab572816ccefc5899355f7f11c3e24f3768a5c7cb90d6#1000\",\n        Greater,\n    );\n    test_sqrt_3_prec_helper(\n        10000,\n        \"1.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146\\\n        186757248575675626141415406703029969945094998952478811655512094373648528093231902305582067\\\n        974820101084674923265015312343266903322886650672254668921837971227047131660367861588019049\\\n        986537379859389467650347506576050756618348129606100947602187190325083145829523959832997789\\\n        824508288714463832917347224163984587855397667958063818353666110843173780894378316102088305\\\n        524901670023520711144288695990956365797087168498072899493296484283020786408603988738697537\\\n        582317317831395992983007838702877053913369563312103707264019249106768231199288375641141422\\\n        016742752102372994270831059898459475987664288897796147837958390228854852903576033852808064\\\n        381972344661059689722872865264153822664698420021195484155278441181286534507035191650016689\\\n        294415480846071277143999762926834629577438361895110127148638746976545982451788550975379013\\\n        880664961911962222957110555242923723192197738262561631468842032853716682938649611917049738\\\n        836395495938145757671853373633125910899655424624834787197605235997769192323570220305302840\\\n        385915414971072429559206706202509520175963185872766359975283663431080150665853710647328538\\\n        625922260582220510403680270297504798728079461658100417052681940019095733462175943893670249\\\n        320422691034369812463720111185261084268910299720311202100063507176374582405203847555197279\\\n        933797614906107894985544223326004018851303631561144886847281589288163245187265066645384877\\\n        599162576642872111240842068016763517100102943180715515190961642460907039408129216903517492\\\n        961364004139670431041253632327030922577327960292376597745537095469115742140424230781992327\\\n        617401906424512454877516862696105333694216213605394604245654140128533007813633449856736406\\\n        703977342229811961042925534501601405940479547154534548407271737656262366549166640233006013\\\n        265744070107836858468452313160467754480500402240639911970362218602920238867150711017169400\\\n        296868759663500040895316214233425227956834067013470185902028360716762147743493449563595808\\\n        082130442586469468522610908263353008756612603460672195404055984128912975994810000772057440\\\n        230047673258800091514371489475444879157191294659083570873961515537797640262068370848046072\\\n        969382719585689759759626104159152657577790782334980567840022901532052138935373775536566427\\\n        046826874289963441395743666073744445583086477893212985302148197395341478170516614952551763\\\n        291993699565744522639112519093541386989366817430938226424736926202072990967831154131946484\\\n        377915459915923928287714695149274026409213645654041644581490201945749419305269002613972646\\\n        081065071439603206077510594187798284793986195249964165213139715293599421897416647075187235\\\n        788629466108560170428869605798394052906407430811833388677881562635867156008396760245349229\\\n        943938867059754315442943430957258470988215463111260766774067864571578060647447499750354544\\\n        559313286549189849336572747626297414738235686914837831363361283627903824840163806671607179\\\n        848728555842931349226093240565957553651136754644387834283313466644554180390821898983294626\\\n        3450161711220169296194601693206210330397449\",\n        \"0x1.bb67ae8584caa73b25742d7078b83b8925d834cc53da4798c720a6486e45a6e2490bcfd95ef15dbda9930\\\n        aae12228f87cc4cf24da3a1ec68d0cd33a01ad9a383b9e122e6138c3ae6de5ede3bd42db7301b6bf553af7b09f\\\n        d6ebef33a9a9fe57729426f30e5892ab572816ccefc5899355f7f11c3e24f3768a5c7cb90d55302505df014c70\\\n        adb1ec1baf58f084433c0d56696a039d962d8434194aab164d642f76e2c8f7dbed64b39dad2f9f7726c6930c49\\\n        d48ffcdc21114a6c36b2ab7018af65c10f806a8fcf4188ef377d2d5b5fd1942e6fd41f9d23b667813df420b68d\\\n        313b387ae00d7a1ddd40aa69bb5352d3522529a7269af1ace62c8325ced0d18c24635d661cfb468be1b096fe67\\\n        7a78756ff46b5506d202bbab5e3351351776080e751e7a6ed2ecbd5cab0343f677bc2f4d3020b12c5a3dd54170\\\n        514f1d910c64a786d9f4fdde306dfce0de8466b0c0b1097801348a9497aca75bdd1b2cb8a042330fb4a53f02fb\\\n        e02b0bd65b382e53877c9b3b518f837f09b9ea3eada4de774744c667ee778a7de2100ef3847573d88bf593779a\\\n        f61a446d5cf76c39e9b5e3a8e82eadb3bab8bbed573c82332c9b692ad88926393687c4cfd268bf8c11f4f39490\\\n        3816010414c231d5ab4e954cca351a0b97b9c1dfc9c263bc18fe1b0899efae7dc41d63fa0d29a5e5d541f52617\\\n        ab4671cded759436e30da234491b192dc6d190fe6b15e72e0a142ca532c3971e0e57a50d517325b52415ccf1e4\\\n        feb9efba3bf091f9c3ffb3a9b243bb001a5fa8c9c9272115c5b9f6cf09325ecc659bb47a3b2dbf660c7bfd4046\\\n        81a5c00c10bc4c7978e5255fc1aa1230c7768f631ccba5fe87314527436fc1e1851ffcf0709060141b5e7c80d2\\\n        f80c57e3f4f1242645dc47a2e85bcbe4b8d7a8185e7000f7655499a681467d71000bd05244d47947991e01d822\\\n        3c817c45780617c2a1fed7f14f334615af5cd378b298c36afe497ed4e6d74b8f87312cc7d9c03b1b260ae50eae\\\n        83b121f59686686a44115094562752ce8e7eef2baf5383aaf67c4b9cc3e12d6edf2424fab1e11fdea7d433bca4\\\n        4d5022ed471d20ae60d74b953c30bbc0a8ca668f86c230ff4b42e14ee60fa2752e462642cebb5c383da047309e\\\n        fec6fff1c9ab3b796ef8d1b446f6b7b87453acf3c77dcdab7d5eb310fb8b07a014e9c03e0f1e0fcdd841bc45e2\\\n        186afe58e091e66d9d713952fbf2cef88598adf4ce26f02044d52ef69dca5124d91adc008a9375da7ec5b47953\\\n        0ff2146c81ab095fe0a995a418ed5eef9ab0b044f06369d3e37b1b97baf10ee167701aa2bdcde28e3b3ab1924e\\\n        9f93affd5e402c83fbc35c9c1ebe0b497b1eb1fb1333d19373e5b7327b1da58ef99c201deee108a885f9d569d3\\\n        7843e775a3b7a6ebe41c3b08f740482934519c3d82cabd6bc17498ad9d484526b2af59e948b13fc009a7ae97d7\\\n        ed1dd29de6c5cbeff0deb3f702f4b105873857f2fa74515cca70f8453dafb5bd7104a15ad9259826c47c17ac69\\\n        a50cb6280457aa7ae6a4dcf359618816b665a5949609815ffb3b9a5ca3db6941ab0faba197ed8870640a0714bc\\\n        c395db140d3ab37df75a5c13af7fe4d8b784d8594a59a664cb01ecb6910be6712b1f42d802886f52cd61fc24a8\\\n        13d04b79a53bf7bd7c5a328606a507d61c98e40551ed0923be10c7927cfc334b9a72486dfcdf217395cf771132\\\n        201a0c1814249a0edd7771933fa5a194818792f12eb0aed7c164b6a95c3786ff646361d752e#10000\",\n        Greater,\n    );\n\n    let sqrt_3_f32 = Float::sqrt_3_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_3_f32.to_string(), \"1.7320508\");\n    assert_eq!(to_hex_string(&sqrt_3_f32), \"0x1.bb67ae#24\");\n    assert_eq!(sqrt_3_f32, f32::SQRT_3);\n\n    let sqrt_3_f64 = Float::sqrt_3_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_3_f64.to_string(), \"1.7320508075688772\");\n    assert_eq!(to_hex_string(&sqrt_3_f64), \"0x1.bb67ae8584caa#53\");\n    assert_eq!(sqrt_3_f64, f64::SQRT_3);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_prec_fail_1() {\n    Float::sqrt_3_prec(0);\n}\n\nfn test_sqrt_3_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::sqrt_3_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_x, rug_o) = rug_sqrt_3_prec_round(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_x)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(rug_o, o);\n    }\n}\n\n#[test]\npub fn test_sqrt_3_prec_round() {\n    test_sqrt_3_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_sqrt_3_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_3_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_sqrt_3_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_3_prec_round_helper(1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test_sqrt_3_prec_round_helper(2, Floor, \"1.5\", \"0x1.8#2\", Less);\n    test_sqrt_3_prec_round_helper(2, Ceiling, \"2.0\", \"0x2.0#2\", Greater);\n    test_sqrt_3_prec_round_helper(2, Down, \"1.5\", \"0x1.8#2\", Less);\n    test_sqrt_3_prec_round_helper(2, Up, \"2.0\", \"0x2.0#2\", Greater);\n    test_sqrt_3_prec_round_helper(2, Nearest, \"1.5\", \"0x1.8#2\", Less);\n\n    test_sqrt_3_prec_round_helper(3, Floor, \"1.5\", \"0x1.8#3\", Less);\n    test_sqrt_3_prec_round_helper(3, Ceiling, \"1.8\", \"0x1.c#3\", Greater);\n    test_sqrt_3_prec_round_helper(3, Down, \"1.5\", \"0x1.8#3\", Less);\n    test_sqrt_3_prec_round_helper(3, Up, \"1.8\", \"0x1.c#3\", Greater);\n    test_sqrt_3_prec_round_helper(3, Nearest, \"1.8\", \"0x1.c#3\", Greater);\n\n    test_sqrt_3_prec_round_helper(4, Floor, \"1.6\", \"0x1.a#4\", Less);\n    test_sqrt_3_prec_round_helper(4, Ceiling, \"1.8\", \"0x1.c#4\", Greater);\n    test_sqrt_3_prec_round_helper(4, Down, \"1.6\", \"0x1.a#4\", Less);\n    test_sqrt_3_prec_round_helper(4, Up, \"1.8\", \"0x1.c#4\", Greater);\n    test_sqrt_3_prec_round_helper(4, Nearest, \"1.8\", \"0x1.c#4\", Greater);\n\n    test_sqrt_3_prec_round_helper(5, Floor, \"1.7\", \"0x1.b#5\", Less);\n    test_sqrt_3_prec_round_helper(5, Ceiling, \"1.75\", \"0x1.c#5\", Greater);\n    test_sqrt_3_prec_round_helper(5, Down, \"1.7\", \"0x1.b#5\", Less);\n    test_sqrt_3_prec_round_helper(5, Up, \"1.75\", \"0x1.c#5\", Greater);\n    test_sqrt_3_prec_round_helper(5, Nearest, \"1.75\", \"0x1.c#5\", Greater);\n\n    test_sqrt_3_prec_round_helper(6, Floor, \"1.72\", \"0x1.b8#6\", Less);\n    test_sqrt_3_prec_round_helper(6, Ceiling, \"1.75\", \"0x1.c0#6\", Greater);\n    test_sqrt_3_prec_round_helper(6, Down, \"1.72\", \"0x1.b8#6\", Less);\n    test_sqrt_3_prec_round_helper(6, Up, \"1.75\", \"0x1.c0#6\", Greater);\n    test_sqrt_3_prec_round_helper(6, Nearest, \"1.72\", \"0x1.b8#6\", Less);\n\n    test_sqrt_3_prec_round_helper(7, Floor, \"1.72\", \"0x1.b8#7\", Less);\n    test_sqrt_3_prec_round_helper(7, Ceiling, \"1.73\", \"0x1.bc#7\", Greater);\n    test_sqrt_3_prec_round_helper(7, Down, \"1.72\", \"0x1.b8#7\", Less);\n    test_sqrt_3_prec_round_helper(7, Up, \"1.73\", \"0x1.bc#7\", Greater);\n    test_sqrt_3_prec_round_helper(7, Nearest, \"1.73\", \"0x1.bc#7\", Greater);\n\n    test_sqrt_3_prec_round_helper(8, Floor, \"1.727\", \"0x1.ba#8\", Less);\n    test_sqrt_3_prec_round_helper(8, Ceiling, \"1.734\", \"0x1.bc#8\", Greater);\n    test_sqrt_3_prec_round_helper(8, Down, \"1.727\", \"0x1.ba#8\", Less);\n    test_sqrt_3_prec_round_helper(8, Up, \"1.734\", \"0x1.bc#8\", Greater);\n    test_sqrt_3_prec_round_helper(8, Nearest, \"1.734\", \"0x1.bc#8\", Greater);\n\n    test_sqrt_3_prec_round_helper(9, Floor, \"1.73\", \"0x1.bb#9\", Less);\n    test_sqrt_3_prec_round_helper(9, Ceiling, \"1.734\", \"0x1.bc#9\", Greater);\n    test_sqrt_3_prec_round_helper(9, Down, \"1.73\", \"0x1.bb#9\", Less);\n    test_sqrt_3_prec_round_helper(9, Up, \"1.734\", \"0x1.bc#9\", Greater);\n    test_sqrt_3_prec_round_helper(9, Nearest, \"1.73\", \"0x1.bb#9\", Less);\n\n    test_sqrt_3_prec_round_helper(10, Floor, \"1.73\", \"0x1.bb0#10\", Less);\n    test_sqrt_3_prec_round_helper(10, Ceiling, \"1.732\", \"0x1.bb8#10\", Greater);\n    test_sqrt_3_prec_round_helper(10, Down, \"1.73\", \"0x1.bb0#10\", Less);\n    test_sqrt_3_prec_round_helper(10, Up, \"1.732\", \"0x1.bb8#10\", Greater);\n    test_sqrt_3_prec_round_helper(10, Nearest, \"1.732\", \"0x1.bb8#10\", Greater);\n\n    test_sqrt_3_prec_round_helper(\n        100,\n        Floor,\n        \"1.732050807568877293527446341505\",\n        \"0x1.bb67ae8584caa73b25742d706#100\",\n        Less,\n    );\n    test_sqrt_3_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n    test_sqrt_3_prec_round_helper(\n        100,\n        Down,\n        \"1.732050807568877293527446341505\",\n        \"0x1.bb67ae8584caa73b25742d706#100\",\n        Less,\n    );\n    test_sqrt_3_prec_round_helper(\n        100,\n        Up,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n    test_sqrt_3_prec_round_helper(\n        100,\n        Nearest,\n        \"1.732050807568877293527446341506\",\n        \"0x1.bb67ae8584caa73b25742d708#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_prec_round_fail_1() {\n    Float::sqrt_3_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_prec_round_fail_2() {\n    Float::sqrt_3_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_prec_round_fail_3() {\n    Float::sqrt_3_prec_round(1000, Exact);\n}\n\n#[test]\nfn sqrt_3_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (sqrt_3, o) = Float::sqrt_3_prec(prec);\n        assert!(sqrt_3.is_valid());\n        assert_eq!(sqrt_3.get_prec(), Some(prec));\n        assert_eq!(sqrt_3.get_exponent(), Some(if prec == 1 { 2 } else { 1 }));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_3_alt, o_alt) = Float::sqrt_3_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_3.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(sqrt_3_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_3.is_power_of_2() {\n            let (sqrt_3_alt, o_alt) = Float::sqrt_3_prec_round(prec, Floor);\n            let mut next_lower = sqrt_3.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(sqrt_3_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (sqrt_3_alt, o_alt) = Float::sqrt_3_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&sqrt_3_alt), ComparableFloatRef(&sqrt_3));\n        assert_eq!(o_alt, o);\n\n        let (rug_sqrt_3, rug_o) =\n            rug_sqrt_3_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt_3)),\n            ComparableFloatRef(&sqrt_3)\n        );\n        assert_eq!(rug_o, o);\n    });\n}\n\n#[test]\nfn sqrt_3_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (sqrt_3, o) = Float::sqrt_3_prec_round(prec, rm);\n        assert!(sqrt_3.is_valid());\n        assert_eq!(sqrt_3.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 2,\n            _ => 1,\n        };\n        assert_eq!(sqrt_3.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_3_alt, o_alt) = Float::sqrt_3_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_3.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(sqrt_3_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_3.is_power_of_2() {\n            let (sqrt_3_alt, o_alt) = Float::sqrt_3_prec_round(prec, Floor);\n            let mut next_lower = sqrt_3.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(sqrt_3_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sqrt_3, rug_o) = rug_sqrt_3_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sqrt_3)),\n                ComparableFloatRef(&sqrt_3)\n            );\n            assert_eq!(rug_o, o);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::sqrt_3_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::sqrt_3_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/sqrt_3_over_3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Sqrt3Over3;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{\n    rug_round_try_from_rounding_mode, test_constant, to_hex_string,\n};\nuse malachite_float::test_util::constants::sqrt_3_over_3::rug_sqrt_3_over_3_prec_round;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_sqrt_3_over_3_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::sqrt_3_over_3_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (rug_x, rug_o) =\n        rug_sqrt_3_over_3_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n    assert_eq!(\n        ComparableFloatRef(&Float::from(&rug_x)),\n        ComparableFloatRef(&x)\n    );\n    assert_eq!(rug_o, o);\n}\n\n#[test]\npub fn test_sqrt_3_over_3_prec() {\n    test_sqrt_3_over_3_prec_helper(1, \"0.5\", \"0x0.8#1\", Less);\n    test_sqrt_3_over_3_prec_helper(2, \"0.5\", \"0x0.8#2\", Less);\n    test_sqrt_3_over_3_prec_helper(3, \"0.6\", \"0x0.a#3\", Greater);\n    test_sqrt_3_over_3_prec_helper(4, \"0.56\", \"0x0.9#4\", Less);\n    test_sqrt_3_over_3_prec_helper(5, \"0.56\", \"0x0.90#5\", Less);\n    test_sqrt_3_over_3_prec_helper(6, \"0.58\", \"0x0.94#6\", Greater);\n    test_sqrt_3_over_3_prec_helper(7, \"0.58\", \"0x0.94#7\", Greater);\n    test_sqrt_3_over_3_prec_helper(8, \"0.578\", \"0x0.94#8\", Greater);\n    test_sqrt_3_over_3_prec_helper(9, \"0.578\", \"0x0.940#9\", Greater);\n    test_sqrt_3_over_3_prec_helper(10, \"0.577\", \"0x0.93c#10\", Less);\n    test_sqrt_3_over_3_prec_helper(\n        100,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n    test_sqrt_3_over_3_prec_helper(\n        1000,\n        \"0.577350269189625764509148780501957455647601751270126876018602326483977672302933345693715\\\n        395585749525225208713805135567676656648364999650826270551837364791216176031077300768527355\\\n        991606700361558307755005104114422301107628883557418222973945990409015710553455953862673016\\\n        6621791266197964892167825021920169\",\n        \"0x0.93cd3a2c8198e2690c7c0f257d92be830c9d66eec69e17dd97b58cc2cf6c8cf61859454874fb1f3f38865\\\n        8e4b0b62fd7eec450c48be0a422f044668ab39de12be8a060f75bd968f79f74f4be9c0f3d100923fc713a7e58a\\\n        9cf94fbbe338aa1d2631625104c830e3c7b80799a541d88671fd505ebf61a67cd8c97ee859c#1000\",\n        Less,\n    );\n    test_sqrt_3_over_3_prec_helper(\n        10000,\n        \"0.577350269189625764509148780501957455647601751270126876018602326483977672302933345693715\\\n        395585749525225208713805135567676656648364999650826270551837364791216176031077300768527355\\\n        991606700361558307755005104114422301107628883557418222973945990409015710553455953862673016\\\n        662179126619796489216782502192016918872782709868700315867395730108361048609841319944332596\\\n        608169429571487944305782408054661529285132555986021272784555370281057926964792772034029435\\\n        174967223341173570381429565330318788599029056166024299831098828094340262136201329579565845\\\n        860772439277131997661002612900959017971123187770701235754673083035589410399762791880380474\\\n        005580917367457664756943686632819825329221429632598715945986130076284950967858677950936021\\\n        460657448220353229907624288421384607554899473340398494718426147060428844835678397216672229\\\n        764805160282023759047999920975611543192479453965036709049546248992181994150596183658459671\\\n        293554987303987407652370185080974574397399246087520543822947344284572227646216537305683246\\\n        278798498646048585890617791211041970299885141541611595732535078665923064107856740101767613\\\n        461971804990357476519735568734169840058654395290922119991761221143693383555284570215776179\\\n        541974086860740170134560090099168266242693153886033472350893980006365244487391981297890083\\\n        106807563678123270821240037061753694756303433240103734033354502392124860801734615851732426\\\n        644599204968702631661848074442001339617101210520381628949093863096054415062421688881794959\\\n        199720858880957370413614022672254505700034314393571838396987214153635679802709738967839164\\\n        320454668046556810347084544109010307525775986764125532581845698489705247380141410260664109\\\n        205800635474837484959172287565368444564738737868464868081884713376177669271211149952245468\\\n        901325780743270653680975178167200468646826515718178182802423912552087455516388880077668671\\\n        088581356702612286156150771053489251493500134080213303990120739534306746289050237005723133\\\n        432289586554500013631772071411141742652278022337823395300676120238920715914497816521198602\\\n        694043480862156489507536969421117669585537534486890731801351994709637658664936666924019146\\\n        743349224419600030504790496491814959719063764886361190291320505179265880087356123616015357\\\n        656460906528563253253208701386384219192596927444993522613340967177350712978457925178855475\\\n        682275624763321147131914555357914815194362159297737661767382732465113826056838871650850587\\\n        763997899855248174213037506364513795663122272476979408808245642067357663655943718043982161\\\n        459305153305307976095904898383091342136404548551347214860496733981916473101756334204657548\\\n        693688357146534402025836864729266094931328731749988055071046571764533140632472215691729078\\\n        596209822036186723476289868599464684302135810270611129559293854211955718669465586748449743\\\n        314646289019918105147647810319086156996071821037086922258022621523859353549149166583451514\\\n        853104428849729949778857582542099138246078562304945943787787094542634608280054602223869059\\\n        949576185280977116408697746855319184550378918214795944761104488881518060130273966327764875\\\n        44833872370733897653982005644020701101324831\",\n        \"0x0.93cd3a2c8198e2690c7c0f257d92be830c9d66eec69e17dd97b58cc2cf6c8cf61859454874fb1f3f38865\\\n        8e4b0b62fd7eec450c48be0a422f044668ab39de12be8a060f75bd968f79f74f4be9c0f3d100923fc713a7e58a\\\n        9cf94fbbe338aa1d2631625104c830e3c7b80799a541d88671fd505ebf61a67cd8c97ee859c7100c574a55c425\\\n        8f3b4eb3e51da5816bbeaf1ccdce013487648166b318e3b219cc0fd24b98529ea476e689e4653527b79786596d\\\n        f1855449605b18cebce639255d8fcc95afd578da9a6b2da5127f0f1e7545dc0f7a9c0a89b692228069fc0ae784\\\n        65be6828f559d35f49c038cde91bc64670b70de26233a5e44cb9810c9a459b2eb6cbc9ccb453c22ea0903254cd\\\n        28d2d1cffc23c7024600e9391f66706707d202af7c5f7e24f0f99474390116a77d3eba6f100ae5b97369f1c07a\\\n        c5c509db04218d2cf351a9f4bacf544af4d6cce59590587d55bc2e3187e437c949b3b992e01611053c371500fe\\\n        a00e594773bd64c6827ede691b2fd67fade8a36a39e19f7d17c19777fa27d8d4a0b004fbd6d1d1482ea73127de\\\n        5208c179c9a7cebdf891f68da2ba39e69392e94f1d142b666433cdb8f2d86213122d419a9b783fd95b51a686da\\\n        bd5cab015c40bb47391a31c4436708ae87e895f54340cbe95daa0902ddfa8f7f415f215359b88ca1f1c0a70cb2\\\n        8e6cd099f9d1dc124baf36116db3b30f4245daff79074d0f58b1643710ebdd0a04c7e1af1b2661e70c074450a1\\\n        aa3dfa93695030a896aa913890c13e555e1fe2ededb7b5b1ec9352450310ca4421de917e13b9ea77597ea9c017\\\n        808c95595ae96ed3284c61ca95e35b6597d22fcbb443e1ff8265c1b7c12540a081b554502585755c091f7ed59b\\\n        a8041d4bfc50616217496d364d73eea192f28d5d74d00052771c3337806cd47b0003f01b6c46d317ddb4ab480b\\\n        69807ec1d2acb29635ff9d506fbbc2073a74467d90dd9678ff6dd4f1a247c3da8265b997f34013b3b758f704e4\\\n        d69060a7322ccd78c15b1adc1cb7c644da2a4fb93a712be3a77ec3deebf5b9cf9fb6b6fe3b4b0a9f8d46bbe98c\\\n        19c560f9c25f0ae4caf26e8714103e958d98ccda8240baffc3c0f5c4f75a8b7c64c20cc0ef93c968148ac2658a\\\n        54ecfffb433913d324fd9b3c17a79292d17139a697d499e3d474e65afe83ad355c4deabf5a5f5a99f2c094174b\\\n        5d78ff72f585f779df25bdc653fb9a52d732e4a6ef62500ac19c64fcdf4370619db39eaad8dbd1f37f973c2871\\\n        0550b179808e58754ae331e15da474fa88e59016facbcdf14bd3b3dd3e505a4b227ab38b9499f62f691390861a\\\n        35313aa9ca15642bfe9674340a3f59187e5f90a906669b3126a1e7bb7e5f372fa8896009fa4b02e2d753472346\\\n        7d6bf7d1e13d37a3f6b413ada7c0180dbc1b341480ee3f23eb26dd8f346d6c623b8fc8a3183b15400337e4dd47\\\n        f9b49b89f79743faa59f9152565190572d12c7fba8d17074437afd6c69e53c947b018b1e4861dd62417eb28ecd\\\n        e1aee762ac1d38d3a236f4511dcb2d5ce77737318758807553be88c98bf3cdc08e5a8e8b32a482d02158ad06e9\\\n        96874906af139129fd1e1eb13a7ff6f2e7d6f2c86e1de2219900a43cdb03f77b0e5fc0f2ab82cfc64475feb6e2\\\n        b1456e7de1bea7e9d41e10d7578c57f209884c01c5f9adb694b0428629a9666e88d0c2cf544a607bdc9a7d05bb\\\n        6008aeb2b16188af9f27d0866a8c8b318082865064e58f9d4076e78dc967d7aa76cbcb47c65#10000\",\n        Greater,\n    );\n\n    let sqrt_3_over_3_f32 = Float::sqrt_3_over_3_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_3_over_3_f32.to_string(), \"0.57735026\");\n    assert_eq!(to_hex_string(&sqrt_3_over_3_f32), \"0x0.93cd3a#24\");\n    assert_eq!(sqrt_3_over_3_f32, f32::SQRT_3_OVER_3);\n\n    let sqrt_3_over_3_f64 = Float::sqrt_3_over_3_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_3_over_3_f64.to_string(), \"0.5773502691896257\");\n    assert_eq!(to_hex_string(&sqrt_3_over_3_f64), \"0x0.93cd3a2c8198e0#53\");\n    assert_eq!(sqrt_3_over_3_f64, f64::SQRT_3_OVER_3);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_over_3_prec_fail_1() {\n    Float::sqrt_3_over_3_prec(0);\n}\n\nfn test_sqrt_3_over_3_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::sqrt_3_over_3_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n        let (rug_x, rug_o) = rug_sqrt_3_over_3_prec_round(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_x)),\n            ComparableFloatRef(&x)\n        );\n        assert_eq!(rug_o, o);\n    }\n}\n\n#[test]\npub fn test_sqrt_3_over_3_prec_round() {\n    test_sqrt_3_over_3_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_sqrt_3_over_3_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_sqrt_3_over_3_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test_sqrt_3_over_3_prec_round_helper(2, Floor, \"0.5\", \"0x0.8#2\", Less);\n    test_sqrt_3_over_3_prec_round_helper(2, Ceiling, \"0.8\", \"0x0.c#2\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(2, Down, \"0.5\", \"0x0.8#2\", Less);\n    test_sqrt_3_over_3_prec_round_helper(2, Up, \"0.8\", \"0x0.c#2\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(2, Nearest, \"0.5\", \"0x0.8#2\", Less);\n\n    test_sqrt_3_over_3_prec_round_helper(3, Floor, \"0.5\", \"0x0.8#3\", Less);\n    test_sqrt_3_over_3_prec_round_helper(3, Ceiling, \"0.6\", \"0x0.a#3\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(3, Down, \"0.5\", \"0x0.8#3\", Less);\n    test_sqrt_3_over_3_prec_round_helper(3, Up, \"0.6\", \"0x0.a#3\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(3, Nearest, \"0.6\", \"0x0.a#3\", Greater);\n\n    test_sqrt_3_over_3_prec_round_helper(4, Floor, \"0.56\", \"0x0.9#4\", Less);\n    test_sqrt_3_over_3_prec_round_helper(4, Ceiling, \"0.62\", \"0x0.a#4\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(4, Down, \"0.56\", \"0x0.9#4\", Less);\n    test_sqrt_3_over_3_prec_round_helper(4, Up, \"0.62\", \"0x0.a#4\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(4, Nearest, \"0.56\", \"0x0.9#4\", Less);\n\n    test_sqrt_3_over_3_prec_round_helper(5, Floor, \"0.56\", \"0x0.90#5\", Less);\n    test_sqrt_3_over_3_prec_round_helper(5, Ceiling, \"0.59\", \"0x0.98#5\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(5, Down, \"0.56\", \"0x0.90#5\", Less);\n    test_sqrt_3_over_3_prec_round_helper(5, Up, \"0.59\", \"0x0.98#5\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(5, Nearest, \"0.56\", \"0x0.90#5\", Less);\n\n    test_sqrt_3_over_3_prec_round_helper(6, Floor, \"0.56\", \"0x0.90#6\", Less);\n    test_sqrt_3_over_3_prec_round_helper(6, Ceiling, \"0.58\", \"0x0.94#6\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(6, Down, \"0.56\", \"0x0.90#6\", Less);\n    test_sqrt_3_over_3_prec_round_helper(6, Up, \"0.58\", \"0x0.94#6\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(6, Nearest, \"0.58\", \"0x0.94#6\", Greater);\n\n    test_sqrt_3_over_3_prec_round_helper(7, Floor, \"0.57\", \"0x0.92#7\", Less);\n    test_sqrt_3_over_3_prec_round_helper(7, Ceiling, \"0.58\", \"0x0.94#7\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(7, Down, \"0.57\", \"0x0.92#7\", Less);\n    test_sqrt_3_over_3_prec_round_helper(7, Up, \"0.58\", \"0x0.94#7\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(7, Nearest, \"0.58\", \"0x0.94#7\", Greater);\n\n    test_sqrt_3_over_3_prec_round_helper(8, Floor, \"0.574\", \"0x0.93#8\", Less);\n    test_sqrt_3_over_3_prec_round_helper(8, Ceiling, \"0.578\", \"0x0.94#8\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(8, Down, \"0.574\", \"0x0.93#8\", Less);\n    test_sqrt_3_over_3_prec_round_helper(8, Up, \"0.578\", \"0x0.94#8\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(8, Nearest, \"0.578\", \"0x0.94#8\", Greater);\n\n    test_sqrt_3_over_3_prec_round_helper(9, Floor, \"0.576\", \"0x0.938#9\", Less);\n    test_sqrt_3_over_3_prec_round_helper(9, Ceiling, \"0.578\", \"0x0.940#9\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(9, Down, \"0.576\", \"0x0.938#9\", Less);\n    test_sqrt_3_over_3_prec_round_helper(9, Up, \"0.578\", \"0x0.940#9\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(9, Nearest, \"0.578\", \"0x0.940#9\", Greater);\n\n    test_sqrt_3_over_3_prec_round_helper(10, Floor, \"0.577\", \"0x0.93c#10\", Less);\n    test_sqrt_3_over_3_prec_round_helper(10, Ceiling, \"0.578\", \"0x0.940#10\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(10, Down, \"0.577\", \"0x0.93c#10\", Less);\n    test_sqrt_3_over_3_prec_round_helper(10, Up, \"0.578\", \"0x0.940#10\", Greater);\n    test_sqrt_3_over_3_prec_round_helper(10, Nearest, \"0.577\", \"0x0.93c#10\", Less);\n\n    test_sqrt_3_over_3_prec_round_helper(\n        100,\n        Floor,\n        \"0.577350269189625764509148780501\",\n        \"0x0.93cd3a2c8198e2690c7c0f257#100\",\n        Less,\n    );\n    test_sqrt_3_over_3_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n    test_sqrt_3_over_3_prec_round_helper(\n        100,\n        Down,\n        \"0.577350269189625764509148780501\",\n        \"0x0.93cd3a2c8198e2690c7c0f257#100\",\n        Less,\n    );\n    test_sqrt_3_over_3_prec_round_helper(\n        100,\n        Up,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n    test_sqrt_3_over_3_prec_round_helper(\n        100,\n        Nearest,\n        \"0.577350269189625764509148780502\",\n        \"0x0.93cd3a2c8198e2690c7c0f258#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_over_3_prec_round_fail_1() {\n    Float::sqrt_3_over_3_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_over_3_prec_round_fail_2() {\n    Float::sqrt_3_over_3_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_3_over_3_prec_round_fail_3() {\n    Float::sqrt_3_over_3_prec_round(1000, Exact);\n}\n\n#[test]\nfn sqrt_3_over_3_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (sqrt_3_over_3, o) = Float::sqrt_3_over_3_prec(prec);\n        assert!(sqrt_3_over_3.is_valid());\n        assert_eq!(sqrt_3_over_3.get_prec(), Some(prec));\n        assert_eq!(sqrt_3_over_3.get_exponent(), Some(0));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_3_over_3_alt, o_alt) = Float::sqrt_3_over_3_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_3_over_3.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(sqrt_3_over_3_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_3_over_3.is_power_of_2() {\n            let (sqrt_3_over_3_alt, o_alt) = Float::sqrt_3_over_3_prec_round(prec, Floor);\n            let mut next_lower = sqrt_3_over_3.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(sqrt_3_over_3_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (sqrt_3_over_3_alt, o_alt) = Float::sqrt_3_over_3_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&sqrt_3_over_3_alt),\n            ComparableFloatRef(&sqrt_3_over_3)\n        );\n        assert_eq!(o_alt, o);\n\n        let (rug_sqrt_3_over_3, rug_o) =\n            rug_sqrt_3_over_3_prec_round(prec, rug_round_try_from_rounding_mode(Nearest).unwrap());\n        assert_eq!(\n            ComparableFloatRef(&Float::from(&rug_sqrt_3_over_3)),\n            ComparableFloatRef(&sqrt_3_over_3)\n        );\n        assert_eq!(rug_o, o);\n    });\n}\n\n#[test]\nfn sqrt_3_over_3_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (sqrt_3_over_3, o) = Float::sqrt_3_over_3_prec_round(prec, rm);\n        assert!(sqrt_3_over_3.is_valid());\n        assert_eq!(sqrt_3_over_3.get_prec(), Some(prec));\n        assert_eq!(\n            sqrt_3_over_3.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                1\n            } else {\n                0\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_3_over_3_alt, o_alt) = Float::sqrt_3_over_3_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_3_over_3.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(sqrt_3_over_3_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_3_over_3.is_power_of_2() {\n            let (sqrt_3_over_3_alt, o_alt) = Float::sqrt_3_over_3_prec_round(prec, Floor);\n            let mut next_lower = sqrt_3_over_3.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(sqrt_3_over_3_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_sqrt_3_over_3, rug_o) = rug_sqrt_3_over_3_prec_round(prec, rm);\n            assert_eq!(\n                ComparableFloatRef(&Float::from(&rug_sqrt_3_over_3)),\n                ComparableFloatRef(&sqrt_3_over_3)\n            );\n            assert_eq!(rug_o, o);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::sqrt_3_over_3_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::sqrt_3_over_3_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::SqrtPi;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::test_util::constants::sqrt_pi::sqrt_pi_prec_round_simple;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_sqrt_pi_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::sqrt_pi_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = sqrt_pi_prec_round_simple(prec, Nearest);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_sqrt_pi_prec() {\n    test_sqrt_pi_prec_helper(1, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_pi_prec_helper(2, \"2.0\", \"0x2.0#2\", Greater);\n    test_sqrt_pi_prec_helper(3, \"1.8\", \"0x1.c#3\", Less);\n    test_sqrt_pi_prec_helper(4, \"1.8\", \"0x1.c#4\", Less);\n    test_sqrt_pi_prec_helper(5, \"1.75\", \"0x1.c#5\", Less);\n    test_sqrt_pi_prec_helper(6, \"1.78\", \"0x1.c8#6\", Greater);\n    test_sqrt_pi_prec_helper(7, \"1.77\", \"0x1.c4#7\", Less);\n    test_sqrt_pi_prec_helper(8, \"1.773\", \"0x1.c6#8\", Greater);\n    test_sqrt_pi_prec_helper(9, \"1.773\", \"0x1.c6#9\", Greater);\n    test_sqrt_pi_prec_helper(10, \"1.771\", \"0x1.c58#10\", Less);\n    test_sqrt_pi_prec_helper(\n        100,\n        \"1.772453850905516027298167483341\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d6#100\",\n        Greater,\n    );\n    test_sqrt_pi_prec_helper(\n        1000,\n        \"1.772453850905516027298167483341145182797549456122387128213807789852911284591032181374950\\\n        656738544665416226823624282570666236152865724422602525093709602787068462037698653105122849\\\n        925173028950826228932095379267962800174639015351479720516700190185234018585446974494912640\\\n        3139217755259062164054193325009063\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d5db9383fe3921546f63b252dca100bd3ea14746ed76ffd6f941f1dbacd8e7\\\n        6141e0c77476c521446ddc35851524490c34a42174dcbafdf109d1b3acfb553ade465bea6c5032aa8a111a626e\\\n        2c702f124d16fb3a90b8b1717835c4e1ec9c08f40a3db6d8123741ca788a38e7a619ffb5bae#1000\",\n        Less,\n    );\n    test_sqrt_pi_prec_helper(\n        10000,\n        \"1.772453850905516027298167483341145182797549456122387128213807789852911284591032181374950\\\n        656738544665416226823624282570666236152865724422602525093709602787068462037698653105122849\\\n        925173028950826228932095379267962800174639015351479720516700190185234018585446974494912640\\\n        313921775525906216405419332500906398407613733477475153433667989789365851836408795451165161\\\n        738760059067393431791332809854846248184902054654852195613251561647467515042738761056107996\\\n        127107210060372044483672365296613708094323498831668424213845709609120420427785778068694766\\\n        570005218305685125413396636944654181510716693883321942929357062268865224420542149948049920\\\n        756486398874838505930640218214029285811233064978945203621149078962287389403245978198513134\\\n        871266512506293260044656382109675026812496930595420461560761952217391525070207792758099054\\\n        332900662223067614469661248188743069978835205061464443854185307973574257179185635959749959\\\n        952263849242203889103966406447293972841345043002140564233433039261756134176336320017037654\\\n        163476320669276541812835762490326904508485320134192435989730871193799482938730111262561658\\\n        818884785977875963761363218634246546641333954355703201522654193952186030497310513829498439\\\n        659165614245955421226615102478536098095510395600789402188099613382854025016800745802729119\\\n        366425192820510001936350073914643295493433951928853735459200563766502880540575532123189009\\\n        126322819150914980836695624483100852221923973646324842863261145766932425371577377894414090\\\n        544573595351225626391080239236909732127905807617134603914574791879794124850218445145811341\\\n        888880413220955332184646709727491028565262707845453262227848800982385836300754950954764062\\\n        377083388357225436621567481327668384244972420874516161833205077991480184666814236693651902\\\n        845463857614827857037774388376297479982737705431583682410998683228503805526355369722293133\\\n        805264428410372312043967004307612454138311792278275363715598398376884537027842985707090511\\\n        223840536779013385414585316208073043138069739987436693166013817079272056041954882858063093\\\n        111636297047867814026963272962701226135985897754505289483113016684001532074851982402463337\\\n        555851713568019341228975980719568740250571502141783792543643030365928211250925880618903117\\\n        074543127903953553660682611001188965742048727593919976995538352115086696255596441370503829\\\n        244953590310636234530564717116216858725458687440029611757921723190554057198681727588419089\\\n        649657906696515601728351482903856551169807210795330916130843598524389465440682165500327537\\\n        996023866503798886481521186579995857186563775113315974753596043413776645119143460134292508\\\n        116324806409073773212629335747472967679341271602966512080989809057799660305102181625557978\\\n        907487076211076238026267854297015027109153504985351492390832484280828987595575678848892608\\\n        420885521269510357370208661259115541320440373560864338837123962064293902378666311632616788\\\n        841922798194995240394245784220443030420430420710969273392946085104969289739161855607837870\\\n        336428902342932718872968029721581659426129728366395905041130374745743509749058016326916537\\\n        5769098109748562537785034287994219223771859\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d5db9383fe3921546f63b252dca100bd3ea14746ed76ffd6f941f1dbacd8e7\\\n        6141e0c77476c521446ddc35851524490c34a42174dcbafdf109d1b3acfb553ade465bea6c5032aa8a111a626e\\\n        2c702f124d16fb3a90b8b1717835c4e1ec9c08f40a3db6d8123741ca788a38e7a619ffb5baebf7b166df28b5d2\\\n        ce89be636c040bb4096804fd2cd93812fbb09908b40ae5eede4891596c00af6afa05395faf6c86dc08b42b2eb0\\\n        dfb3a4876c1b058529354f2d429308d212dfcafadc0b046f3bc362555d119aaf416e879d013f2c8f4a2d55dab8\\\n        c4a398e161c9a5ba77ff284c3fdf892bf0f36805c5b0f813e47b36432ae9abfb8c2df6620a343b71239bd6f0ff\\\n        6e4525e14f2fd52776201d3e8ef4114462465d2552a8f30a26da0b28395985eaf57168b0fc66f7c6a5b8866f58\\\n        404028f9bf801f152865bb9b5adc90f6db648f9cfb609ca9193da29454c09450a4c8efbec6b5aeb4f075432e78\\\n        235da1447372389183627d449bafefcf9fd8a7267a98772baffa71b8d310c9d4f58bfd3d7299db12456357ddd5\\\n        2d6a9c56cf29d0303cbc0bf54a3ba39a725c78e8f19a0e59bfa4c7f915be3ff44c6c5d7b325585276abd43e221\\\n        ca9aafdd05c54a3fed2de03ba9b2606683f2870665e21a663c1387b4e02b4b90cc94033cc9775f2372e04174f5\\\n        19c42b9f65ec003149951eab1053ac0b7b77d251a898259637e3f17aea75bf15a08060348c31a61bd0b7e27e7c\\\n        68c614857ab238b36c1c64718de50ddc4293720630dbd5452b0d542e3f897e6bde585711e016e030e5dec6161b\\\n        a79dff01f061ca3b961fc02e77db5d73f2ef6d47c471d57f97a9a134cce64b48479d0628117f4350aff9d0d8ac\\\n        b474bdea6af441f7ade16dd2b1d90e128a91425fbef3609a23ee55c413660fee0224e4ff76fd23e43f11038c51\\\n        fef6ab1c0b9c2a50c5e15f92f5c998d5fac7d979367efd2277ccb66a735d3480c02f6dbdff7ac4e13dc41ec140\\\n        1b7424ad067f21c1f72464177ce2d902a6d60868b14aeed4385e55c94e0264549528cff2d94ecb0f9ea6febc17\\\n        8e7c440d9f1fa1e2c8bce21f2aa74067c08073707df38ff04fb731fe11753c63e5178fb6e0856db51bf8ae3f46\\\n        f3db7248a242f320803db8570f9ba75cea2e97d479ecfa6c84a3d9fe177eb2610ead682efed92bc297e843d696\\\n        f9797852fe0da2230c230757c48bf6172d2a8f6c94af315ffd09d9fc3fbe5f9146b2da2de051f6b0914fe89a2e\\\n        142e02ab85f76391911ff1eaaa0fe03cea3f7ccb93a1581dec1650dd6b1a1ff53eca03f427bf879f02ec73b2c0\\\n        cc2109c261083c4810c681d4fcdc970239432382a9cae18656ca343b831e1e720d4b4121472f039ac06c3dd3a6\\\n        ee46f70e2e929ca487dda488e4f4f80a00ad9bf6f7aaed026102f31a2d2f858c91ec18d5d8948940b306095746\\\n        8b4536d01bd00313ddf4685220b51c9b72856b906526488af9b2aaf0850915918a621fe23a63fb2594cf359db7\\\n        0377bb3a408a210dc230fa803135e46c1f2914f43ad8275f98dde221a0c93c23905fd6ae77eb55dc2c017d7e3b\\\n        84c564107577e6bd0f9817cc73db32a279d38fe586e954296ace2e7901a15b8974ec1b87c419d75684f61076cb\\\n        f653eae047e7f31c0c50e27f992c19f3059f632baa5aae158021bb870bbc9162f579d3ca45d2208e000d91a4fb\\\n        a0750031b19a4ab6e88733c2a86de645b7bf87676bcfa4347b1b40ad01adaba2967096f969e#10000\",\n        Greater,\n    );\n\n    let sqrt_pi_f32 = Float::sqrt_pi_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_pi_f32.to_string(), \"1.7724539\");\n    assert_eq!(to_hex_string(&sqrt_pi_f32), \"0x1.c5bf8a#24\");\n    assert_eq!(sqrt_pi_f32, f32::SQRT_PI);\n\n    let sqrt_pi_f64 = Float::sqrt_pi_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(sqrt_pi_f64.to_string(), \"1.7724538509055161\");\n    assert_eq!(to_hex_string(&sqrt_pi_f64), \"0x1.c5bf891b4ef6b#53\");\n    assert_eq!(sqrt_pi_f64, f64::SQRT_PI);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_pi_prec_fail_1() {\n    Float::sqrt_pi_prec(0);\n}\n\nfn test_sqrt_pi_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::sqrt_pi_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n\n    let (x_alt, o_alt) = sqrt_pi_prec_round_simple(prec, rm);\n    assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n    assert_eq!(o_alt, o);\n}\n\n#[test]\npub fn test_sqrt_pi_prec_round() {\n    test_sqrt_pi_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_sqrt_pi_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_pi_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_sqrt_pi_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_sqrt_pi_prec_round_helper(1, Nearest, \"2.0\", \"0x2.0#1\", Greater);\n\n    test_sqrt_pi_prec_round_helper(2, Floor, \"1.5\", \"0x1.8#2\", Less);\n    test_sqrt_pi_prec_round_helper(2, Ceiling, \"2.0\", \"0x2.0#2\", Greater);\n    test_sqrt_pi_prec_round_helper(2, Down, \"1.5\", \"0x1.8#2\", Less);\n    test_sqrt_pi_prec_round_helper(2, Up, \"2.0\", \"0x2.0#2\", Greater);\n    test_sqrt_pi_prec_round_helper(2, Nearest, \"2.0\", \"0x2.0#2\", Greater);\n\n    test_sqrt_pi_prec_round_helper(3, Floor, \"1.8\", \"0x1.c#3\", Less);\n    test_sqrt_pi_prec_round_helper(3, Ceiling, \"2.0\", \"0x2.0#3\", Greater);\n    test_sqrt_pi_prec_round_helper(3, Down, \"1.8\", \"0x1.c#3\", Less);\n    test_sqrt_pi_prec_round_helper(3, Up, \"2.0\", \"0x2.0#3\", Greater);\n    test_sqrt_pi_prec_round_helper(3, Nearest, \"1.8\", \"0x1.c#3\", Less);\n\n    test_sqrt_pi_prec_round_helper(4, Floor, \"1.8\", \"0x1.c#4\", Less);\n    test_sqrt_pi_prec_round_helper(4, Ceiling, \"1.9\", \"0x1.e#4\", Greater);\n    test_sqrt_pi_prec_round_helper(4, Down, \"1.8\", \"0x1.c#4\", Less);\n    test_sqrt_pi_prec_round_helper(4, Up, \"1.9\", \"0x1.e#4\", Greater);\n    test_sqrt_pi_prec_round_helper(4, Nearest, \"1.8\", \"0x1.c#4\", Less);\n\n    test_sqrt_pi_prec_round_helper(5, Floor, \"1.75\", \"0x1.c#5\", Less);\n    test_sqrt_pi_prec_round_helper(5, Ceiling, \"1.81\", \"0x1.d#5\", Greater);\n    test_sqrt_pi_prec_round_helper(5, Down, \"1.75\", \"0x1.c#5\", Less);\n    test_sqrt_pi_prec_round_helper(5, Up, \"1.81\", \"0x1.d#5\", Greater);\n    test_sqrt_pi_prec_round_helper(5, Nearest, \"1.75\", \"0x1.c#5\", Less);\n\n    test_sqrt_pi_prec_round_helper(6, Floor, \"1.75\", \"0x1.c0#6\", Less);\n    test_sqrt_pi_prec_round_helper(6, Ceiling, \"1.78\", \"0x1.c8#6\", Greater);\n    test_sqrt_pi_prec_round_helper(6, Down, \"1.75\", \"0x1.c0#6\", Less);\n    test_sqrt_pi_prec_round_helper(6, Up, \"1.78\", \"0x1.c8#6\", Greater);\n    test_sqrt_pi_prec_round_helper(6, Nearest, \"1.78\", \"0x1.c8#6\", Greater);\n\n    test_sqrt_pi_prec_round_helper(7, Floor, \"1.77\", \"0x1.c4#7\", Less);\n    test_sqrt_pi_prec_round_helper(7, Ceiling, \"1.78\", \"0x1.c8#7\", Greater);\n    test_sqrt_pi_prec_round_helper(7, Down, \"1.77\", \"0x1.c4#7\", Less);\n    test_sqrt_pi_prec_round_helper(7, Up, \"1.78\", \"0x1.c8#7\", Greater);\n    test_sqrt_pi_prec_round_helper(7, Nearest, \"1.77\", \"0x1.c4#7\", Less);\n\n    test_sqrt_pi_prec_round_helper(8, Floor, \"1.766\", \"0x1.c4#8\", Less);\n    test_sqrt_pi_prec_round_helper(8, Ceiling, \"1.773\", \"0x1.c6#8\", Greater);\n    test_sqrt_pi_prec_round_helper(8, Down, \"1.766\", \"0x1.c4#8\", Less);\n    test_sqrt_pi_prec_round_helper(8, Up, \"1.773\", \"0x1.c6#8\", Greater);\n    test_sqrt_pi_prec_round_helper(8, Nearest, \"1.773\", \"0x1.c6#8\", Greater);\n\n    test_sqrt_pi_prec_round_helper(9, Floor, \"1.77\", \"0x1.c5#9\", Less);\n    test_sqrt_pi_prec_round_helper(9, Ceiling, \"1.773\", \"0x1.c6#9\", Greater);\n    test_sqrt_pi_prec_round_helper(9, Down, \"1.77\", \"0x1.c5#9\", Less);\n    test_sqrt_pi_prec_round_helper(9, Up, \"1.773\", \"0x1.c6#9\", Greater);\n    test_sqrt_pi_prec_round_helper(9, Nearest, \"1.773\", \"0x1.c6#9\", Greater);\n\n    test_sqrt_pi_prec_round_helper(10, Floor, \"1.771\", \"0x1.c58#10\", Less);\n    test_sqrt_pi_prec_round_helper(10, Ceiling, \"1.773\", \"0x1.c60#10\", Greater);\n    test_sqrt_pi_prec_round_helper(10, Down, \"1.771\", \"0x1.c58#10\", Less);\n    test_sqrt_pi_prec_round_helper(10, Up, \"1.773\", \"0x1.c60#10\", Greater);\n    test_sqrt_pi_prec_round_helper(10, Nearest, \"1.771\", \"0x1.c58#10\", Less);\n\n    test_sqrt_pi_prec_round_helper(\n        100,\n        Floor,\n        \"1.77245385090551602729816748334\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d4#100\",\n        Less,\n    );\n    test_sqrt_pi_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.772453850905516027298167483341\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d6#100\",\n        Greater,\n    );\n    test_sqrt_pi_prec_round_helper(\n        100,\n        Down,\n        \"1.77245385090551602729816748334\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d4#100\",\n        Less,\n    );\n    test_sqrt_pi_prec_round_helper(\n        100,\n        Up,\n        \"1.772453850905516027298167483341\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d6#100\",\n        Greater,\n    );\n    test_sqrt_pi_prec_round_helper(\n        100,\n        Nearest,\n        \"1.772453850905516027298167483341\",\n        \"0x1.c5bf891b4ef6aa79c3b0520d6#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn sqrt_pi_prec_round_fail_1() {\n    Float::sqrt_pi_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_pi_prec_round_fail_2() {\n    Float::sqrt_pi_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn sqrt_pi_prec_round_fail_3() {\n    Float::sqrt_pi_prec_round(1000, Exact);\n}\n\n#[test]\nfn sqrt_pi_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (sqrt_pi, o) = Float::sqrt_pi_prec(prec);\n        assert!(sqrt_pi.is_valid());\n        assert_eq!(sqrt_pi.get_prec(), Some(prec));\n        assert_eq!(sqrt_pi.get_exponent(), Some(if prec <= 2 { 2 } else { 1 }));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_pi_alt, o_alt) = Float::sqrt_pi_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(sqrt_pi_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_pi.is_power_of_2() {\n            let (sqrt_pi_alt, o_alt) = Float::sqrt_pi_prec_round(prec, Floor);\n            let mut next_lower = sqrt_pi.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(sqrt_pi_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (sqrt_pi_alt, o_alt) = Float::sqrt_pi_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&sqrt_pi_alt),\n            ComparableFloatRef(&sqrt_pi)\n        );\n        assert_eq!(o_alt, o);\n\n        let (sqrt_pi_alt, o_alt) = sqrt_pi_prec_round_simple(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&sqrt_pi_alt),\n            ComparableFloatRef(&sqrt_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn sqrt_pi_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (sqrt_pi, o) = Float::sqrt_pi_prec_round(prec, rm);\n        assert!(sqrt_pi.is_valid());\n        assert_eq!(sqrt_pi.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1 | 2, Ceiling | Up | Nearest) | (3, Ceiling | Up) => 2,\n            _ => 1,\n        };\n        assert_eq!(sqrt_pi.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (sqrt_pi_alt, o_alt) = Float::sqrt_pi_prec_round(prec, Ceiling);\n            let mut next_upper = sqrt_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(sqrt_pi_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !sqrt_pi.is_power_of_2() {\n            let (sqrt_pi_alt, o_alt) = Float::sqrt_pi_prec_round(prec, Floor);\n            let mut next_lower = sqrt_pi.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(sqrt_pi_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n\n        let (sqrt_pi_alt, o_alt) = sqrt_pi_prec_round_simple(prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&sqrt_pi_alt),\n            ComparableFloatRef(&sqrt_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::sqrt_pi_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::sqrt_pi_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/tau.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::Tau;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_tau_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::tau_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_tau_prec() {\n    test_tau_prec_helper(1, \"8.0\", \"0x8.0#1\", Greater);\n    test_tau_prec_helper(2, \"6.0\", \"0x6.0#2\", Less);\n    test_tau_prec_helper(3, \"6.0\", \"0x6.0#3\", Less);\n    test_tau_prec_helper(4, \"6.5\", \"0x6.8#4\", Greater);\n    test_tau_prec_helper(5, \"6.2\", \"0x6.4#5\", Less);\n    test_tau_prec_helper(6, \"6.2\", \"0x6.4#6\", Less);\n    test_tau_prec_helper(7, \"6.3\", \"0x6.5#7\", Greater);\n    test_tau_prec_helper(8, \"6.28\", \"0x6.48#8\", Less);\n    test_tau_prec_helper(9, \"6.28\", \"0x6.48#9\", Less);\n    test_tau_prec_helper(10, \"6.28\", \"0x6.48#10\", Less);\n    test_tau_prec_helper(\n        100,\n        \"6.283185307179586476925286766559\",\n        \"0x6.487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n    test_tau_prec_helper(\n        1000,\n        \"6.283185307179586476925286766559005768394338798750211641949889184615632812572417997256069\\\n        650684234135964296173026564613294187689219101164463450718816256962234900568205403877042211\\\n        119289245897909860763928857621951331866892256951296467573566330542403818291297133846920697\\\n        220908653296426787214520498282547\",\n        \"0x6.487ed5110b4611a62633145c06e0e68948127044533e63a0105df531d89cd9128a5043cc71a026ef7ca8c\\\n        d9e69d218d98158536f92f8a1ba7f09ab6b6a8e122f242dabb312f3f637a262174d31bf6b585ffae5b7a035bf6\\\n        f71c35fdad44cfd2d74f9208be258ff324943328f6722d9ee1003e5c50b1df82cc6d241b0e0#1000\",\n        Less,\n    );\n    test_tau_prec_helper(\n        10000,\n        \"6.283185307179586476925286766559005768394338798750211641949889184615632812572417997256069\\\n        650684234135964296173026564613294187689219101164463450718816256962234900568205403877042211\\\n        119289245897909860763928857621951331866892256951296467573566330542403818291297133846920697\\\n        220908653296426787214520498282547449174013212631176349763041841925658508183430728735785180\\\n        720022661061097640933042768293903883023218866114540731519183906184372234763865223586210237\\\n        096148924759925499134703771505449782455876366023898259667346724881313286172042789892790449\\\n        474381404359721887405541078434352586353504769349636935338810264001136254290527121655571542\\\n        685515579218347274357442936881802449906860293099170742101584559378517847084039912224258043\\\n        921728068836319627259549542619921037414422699999996745956099902119463465632192637190048918\\\n        910693816605285044616506689370070523862376342020006275677505773175066416762841234355338294\\\n        607196506980857510937462319125727764707575187503915563715561064342453613226003855753222391\\\n        818432840397876190514402130971726557731872306763655936460603904070603705937991547245198827\\\n        782499443550566958263031149714484908301391901659066233723455711778150196763509274929878638\\\n        510120801855403342278019697648025716723207127415320209420363885911192397893535674898896510\\\n        759549453694208095069292416093368518138982586627354057978304209504324113932048116076300387\\\n        022506764860071175280494992946527828398545208539845593564709563272018683443282439849172630\\\n        060572365949111413499677010989177173853991381854421595018605910642330689974405511920472961\\\n        330998239763669595507132739614853085055725103636835149345781955545587600163294120032290498\\\n        384346434429544700282883947137096322722314705104266951483698936877046647814788286669095524\\\n        833725037967138971124198438444368545100508513775343580989203306933609977254465583572171568\\\n        767655935953362908201907767572721901360128450250410234785969792168256977253891208483930570\\\n        044421322372613488557244078389890094247427573921912728743834574935529315147924827781731665\\\n        291991626780956055180198931528157902538936796705191419651645241044978815453438956536965202\\\n        953981805280272788874910610136406992504903498799302862859618381318501874443392923031419716\\\n        774821195771919545950997860323507856936276537367737885548311983711850491907918862099945049\\\n        361691974547289391697307673472445252198249216102487768780902488273099525561595431382871995\\\n        400259232178883389737111696812706844144451656977296316912057012033685478904534935357790504\\\n        277045099909333455647972913192232709772461154912996071187269136348648225030152138958902193\\\n        192188050457759421786291338273734457497881120203006617235857361841749521835649877178019429\\\n        819351970522731099563786259569643365997897445317609715128028540955110264759282903047492468\\\n        729085716889590531735642102282709471479046226854332204271939072462885904969874374220291530\\\n        807180559868807484014621157078124396774895616956979366642891427737503887012860436906382096\\\n        962010741229361349838556382395879904122839326857508881287490247436384359996782031839123629\\\n        3502853824794978818143729884639231358904161\",\n        \"0x6.487ed5110b4611a62633145c06e0e68948127044533e63a0105df531d89cd9128a5043cc71a026ef7ca8c\\\n        d9e69d218d98158536f92f8a1ba7f09ab6b6a8e122f242dabb312f3f637a262174d31bf6b585ffae5b7a035bf6\\\n        f71c35fdad44cfd2d74f9208be258ff324943328f6722d9ee1003e5c50b1df82cc6d241b0e2ae9cd348b1fd47e\\\n        9267afc1b2ae91ee51d6cb0e3179ab1042a95dcf6a9483b84b4b36b3861aa7255e4c0278ba3604650c10be1948\\\n        2f23171b671df1cf3b960c074301cd93c1d17603d147dae2aef837a62964ef15e5fb4aac0b8c1ccaa4be754ab5\\\n        728ae9130c4c7d02880ab9472d45556216d6998b8682283d19d42a90d5ef8e5d32767dc2822c6df785457538ab\\\n        ae83063ed9cb87c2d370f263d5fad7466d8499eb8f464a702512b0cee771e9130d697735f897fd036cc504326c\\\n        3b01399f643532290f958c0bbd90065df08babbd30aeb63b84c4605d6ca371047127d03a72d598a1edadfe707e\\\n        884725c16890549084008d391e0953c3f36bc438cd085edd2d934ce1938c357a711e0d4a341a5b0a85ed12c1f4\\\n        e5156a26746ddde16d826f477c97477e0a0fdf6553143e2ca3a735e02eccd94b27d04861d1119dd0c328adf3f6\\\n        8fb094b867716bd7dc0deebb10b8240e68034893ead82d54c9da754c46c7eee0c37fdbee48536047a6fa1ae49a\\\n        0142491b61fd5a693e381360ea6e593013236f64ba8f3b1edd1bdefc7fca0356cf298772ed9c17a09800d75835\\\n        29f6c813ec188bcb93d8432d448c6d1f6df5e7cd8a76a267365d676a5d8dedbf8a23f36612a5999028a895ebd7\\\n        a137dc7a009bc6695facc1e500e325c9767819750ae8b90e81fa416be7373a7f7b6aaf3817a34c06415ad42018\\\n        c8058e4f2cf3e4bfdf63f47991d4bd3f1b66445f078ea2dbffac2d62a5ea03d915a0aa556647b6bf5fa470ec0a\\\n        662f6907c01bf053cb8af7794df1940350eac5dbe2ed3b7aa8551ec50fdff8758ce658d189eaae6d2b64f61779\\\n        4b191c3ff46bb71e0234021f47b31fa43077095f96ad85ba3a6b734a7c8f36df08acba51c937897f72f21c3bbe\\\n        5b54996fc66c5f626839dc98dd1de4195b46cee9803a0fd3dfc57e23f692bb7b49b5d212331d55b1ce2d727ab4\\\n        1a11da3a15f8e4bc11c78b65f1ceb296f1fedc5f7e42456c911117025201be0389f5abd40d11f8639a39fe3236\\\n        751835a5e5e44317c1c2eefd4ea5bfd16043f43cb41981f6adee9d03159e7ad9d13c53369509fc1fa27c16ef98\\\n        87703a55b51b22cbf44cd012aee0b2798e628423428efcd5a40caef6bf50d8ea885ebf73a6b9fd79b5e18f67d1\\\n        341ac8237a75c3cfc92004a1c5a40e366bc44d00176af71c15e48c86d37e013723caac7223ab3bf4d54f182871\\\n        3b2b4a6fe40fab74405cb738b064c06ecc52b9f52239032d09ce69483668e5b94f629529436a200a534a6522ba\\\n        c1eae7f79378dc856c148ed03cce8001174df6aae37d23fe52dd8d6541bb22b6cc6ca43cf73f36dfe680a5d8b0\\\n        aacc8a7605abb533f1f4211748f32dd0a0ed496f4e1d36b665289b6ea125d88324c475add4d60934fbefb39dcc\\\n        1711fdb64cdd95518e2d3342ffeacc8a4d985633dc2326c054aea12985340b22681c830747c7ea93134b6853ac\\\n        ad71fc9ad33ee7fad43a5380fdfd061ea9a5a71cde04abb8299ba410d08e1d64cc705d38c043d98bc12d0d67e7\\\n        d75df92792e3028d6d4e142d0fe6b08a541c50d6f38a60b54a00e6e7c0f0838ffbd5cb91cf8#10000\",\n        Less,\n    );\n\n    let tau_f32 = Float::tau_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(tau_f32.to_string(), \"6.2831855\");\n    assert_eq!(to_hex_string(&tau_f32), \"0x6.487ed8#24\");\n    assert_eq!(tau_f32, f32::TAU);\n\n    let tau_f64 = Float::tau_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(tau_f64.to_string(), \"6.283185307179586\");\n    assert_eq!(to_hex_string(&tau_f64), \"0x6.487ed5110b460#53\");\n    assert_eq!(tau_f64, f64::TAU);\n}\n\n#[test]\n#[should_panic]\nfn tau_prec_fail_1() {\n    Float::tau_prec(0);\n}\n\nfn test_tau_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::tau_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_tau_prec_round() {\n    test_tau_prec_round_helper(1, Floor, \"4.0\", \"0x4.0#1\", Less);\n    test_tau_prec_round_helper(1, Ceiling, \"8.0\", \"0x8.0#1\", Greater);\n    test_tau_prec_round_helper(1, Down, \"4.0\", \"0x4.0#1\", Less);\n    test_tau_prec_round_helper(1, Up, \"8.0\", \"0x8.0#1\", Greater);\n    test_tau_prec_round_helper(1, Nearest, \"8.0\", \"0x8.0#1\", Greater);\n\n    test_tau_prec_round_helper(2, Floor, \"6.0\", \"0x6.0#2\", Less);\n    test_tau_prec_round_helper(2, Ceiling, \"8.0\", \"0x8.0#2\", Greater);\n    test_tau_prec_round_helper(2, Down, \"6.0\", \"0x6.0#2\", Less);\n    test_tau_prec_round_helper(2, Up, \"8.0\", \"0x8.0#2\", Greater);\n    test_tau_prec_round_helper(2, Nearest, \"6.0\", \"0x6.0#2\", Less);\n\n    test_tau_prec_round_helper(3, Floor, \"6.0\", \"0x6.0#3\", Less);\n    test_tau_prec_round_helper(3, Ceiling, \"7.0\", \"0x7.0#3\", Greater);\n    test_tau_prec_round_helper(3, Down, \"6.0\", \"0x6.0#3\", Less);\n    test_tau_prec_round_helper(3, Up, \"7.0\", \"0x7.0#3\", Greater);\n    test_tau_prec_round_helper(3, Nearest, \"6.0\", \"0x6.0#3\", Less);\n\n    test_tau_prec_round_helper(4, Floor, \"6.0\", \"0x6.0#4\", Less);\n    test_tau_prec_round_helper(4, Ceiling, \"6.5\", \"0x6.8#4\", Greater);\n    test_tau_prec_round_helper(4, Down, \"6.0\", \"0x6.0#4\", Less);\n    test_tau_prec_round_helper(4, Up, \"6.5\", \"0x6.8#4\", Greater);\n    test_tau_prec_round_helper(4, Nearest, \"6.5\", \"0x6.8#4\", Greater);\n\n    test_tau_prec_round_helper(5, Floor, \"6.2\", \"0x6.4#5\", Less);\n    test_tau_prec_round_helper(5, Ceiling, \"6.5\", \"0x6.8#5\", Greater);\n    test_tau_prec_round_helper(5, Down, \"6.2\", \"0x6.4#5\", Less);\n    test_tau_prec_round_helper(5, Up, \"6.5\", \"0x6.8#5\", Greater);\n    test_tau_prec_round_helper(5, Nearest, \"6.2\", \"0x6.4#5\", Less);\n\n    test_tau_prec_round_helper(6, Floor, \"6.2\", \"0x6.4#6\", Less);\n    test_tau_prec_round_helper(6, Ceiling, \"6.4\", \"0x6.6#6\", Greater);\n    test_tau_prec_round_helper(6, Down, \"6.2\", \"0x6.4#6\", Less);\n    test_tau_prec_round_helper(6, Up, \"6.4\", \"0x6.6#6\", Greater);\n    test_tau_prec_round_helper(6, Nearest, \"6.2\", \"0x6.4#6\", Less);\n\n    test_tau_prec_round_helper(7, Floor, \"6.25\", \"0x6.4#7\", Less);\n    test_tau_prec_round_helper(7, Ceiling, \"6.3\", \"0x6.5#7\", Greater);\n    test_tau_prec_round_helper(7, Down, \"6.25\", \"0x6.4#7\", Less);\n    test_tau_prec_round_helper(7, Up, \"6.3\", \"0x6.5#7\", Greater);\n    test_tau_prec_round_helper(7, Nearest, \"6.3\", \"0x6.5#7\", Greater);\n\n    test_tau_prec_round_helper(8, Floor, \"6.28\", \"0x6.48#8\", Less);\n    test_tau_prec_round_helper(8, Ceiling, \"6.31\", \"0x6.50#8\", Greater);\n    test_tau_prec_round_helper(8, Down, \"6.28\", \"0x6.48#8\", Less);\n    test_tau_prec_round_helper(8, Up, \"6.31\", \"0x6.50#8\", Greater);\n    test_tau_prec_round_helper(8, Nearest, \"6.28\", \"0x6.48#8\", Less);\n\n    test_tau_prec_round_helper(9, Floor, \"6.28\", \"0x6.48#9\", Less);\n    test_tau_prec_round_helper(9, Ceiling, \"6.3\", \"0x6.4c#9\", Greater);\n    test_tau_prec_round_helper(9, Down, \"6.28\", \"0x6.48#9\", Less);\n    test_tau_prec_round_helper(9, Up, \"6.3\", \"0x6.4c#9\", Greater);\n    test_tau_prec_round_helper(9, Nearest, \"6.28\", \"0x6.48#9\", Less);\n\n    test_tau_prec_round_helper(10, Floor, \"6.28\", \"0x6.48#10\", Less);\n    test_tau_prec_round_helper(10, Ceiling, \"6.29\", \"0x6.4a#10\", Greater);\n    test_tau_prec_round_helper(10, Down, \"6.28\", \"0x6.48#10\", Less);\n    test_tau_prec_round_helper(10, Up, \"6.29\", \"0x6.4a#10\", Greater);\n    test_tau_prec_round_helper(10, Nearest, \"6.28\", \"0x6.48#10\", Less);\n\n    test_tau_prec_round_helper(\n        100,\n        Floor,\n        \"6.283185307179586476925286766559\",\n        \"0x6.487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n    test_tau_prec_round_helper(\n        100,\n        Ceiling,\n        \"6.283185307179586476925286766565\",\n        \"0x6.487ed5110b4611a62633145c8#100\",\n        Greater,\n    );\n    test_tau_prec_round_helper(\n        100,\n        Down,\n        \"6.283185307179586476925286766559\",\n        \"0x6.487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n    test_tau_prec_round_helper(\n        100,\n        Up,\n        \"6.283185307179586476925286766565\",\n        \"0x6.487ed5110b4611a62633145c8#100\",\n        Greater,\n    );\n    test_tau_prec_round_helper(\n        100,\n        Nearest,\n        \"6.283185307179586476925286766559\",\n        \"0x6.487ed5110b4611a62633145c0#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn tau_prec_round_fail_1() {\n    Float::tau_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn tau_prec_round_fail_2() {\n    Float::tau_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn tau_prec_round_fail_3() {\n    Float::tau_prec_round(1000, Exact);\n}\n\n#[test]\nfn tau_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (tau, o) = Float::tau_prec(prec);\n        assert!(tau.is_valid());\n        assert_eq!(tau.get_prec(), Some(prec));\n        assert_eq!(tau.get_exponent(), Some(if prec == 1 { 4 } else { 3 }));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (tau_alt, o_alt) = Float::tau_prec_round(prec, Ceiling);\n            let mut next_upper = tau.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(tau_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !tau.is_power_of_2() {\n            let (tau_alt, o_alt) = Float::tau_prec_round(prec, Floor);\n            let mut next_lower = tau.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(tau_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n        let (tau_alt, o_alt) = Float::tau_prec_round(prec, Nearest);\n        assert_eq!(ComparableFloatRef(&tau_alt), ComparableFloatRef(&tau));\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn tau_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (tau, o) = Float::tau_prec_round(prec, rm);\n        assert!(tau.is_valid());\n        assert_eq!(tau.get_prec(), Some(prec));\n        let expected_exponent = match (prec, rm) {\n            (1, Ceiling | Up | Nearest) | (2, Ceiling | Up) => 4,\n            _ => 3,\n        };\n        assert_eq!(tau.get_exponent(), Some(expected_exponent));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (tau_alt, o_alt) = Float::tau_prec_round(prec, Ceiling);\n            let mut next_upper = tau.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(ComparableFloat(tau_alt), ComparableFloat(next_upper));\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !tau.is_power_of_2() {\n            let (tau_alt, o_alt) = Float::tau_prec_round(prec, Floor);\n            let mut next_lower = tau.clone();\n            next_lower.decrement();\n            assert_eq!(ComparableFloat(tau_alt), ComparableFloat(next_lower));\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::tau_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::tau_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/two_over_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::TwoOverPi;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_two_over_pi_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::two_over_pi_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_two_over_pi_prec() {\n    test_two_over_pi_prec_helper(1, \"0.5\", \"0x0.8#1\", Less);\n    test_two_over_pi_prec_helper(2, \"0.8\", \"0x0.c#2\", Greater);\n    test_two_over_pi_prec_helper(3, \"0.6\", \"0x0.a#3\", Less);\n    test_two_over_pi_prec_helper(4, \"0.62\", \"0x0.a#4\", Less);\n    test_two_over_pi_prec_helper(5, \"0.62\", \"0x0.a0#5\", Less);\n    test_two_over_pi_prec_helper(6, \"0.64\", \"0x0.a4#6\", Greater);\n    test_two_over_pi_prec_helper(7, \"0.63\", \"0x0.a2#7\", Less);\n    test_two_over_pi_prec_helper(8, \"0.637\", \"0x0.a3#8\", Greater);\n    test_two_over_pi_prec_helper(9, \"0.637\", \"0x0.a30#9\", Greater);\n    test_two_over_pi_prec_helper(10, \"0.637\", \"0x0.a30#10\", Greater);\n    test_two_over_pi_prec_helper(\n        100,\n        \"0.63661977236758134307553505349\",\n        \"0x0.a2f9836e4e441529fc2757d1f#100\",\n        Less,\n    );\n    test_two_over_pi_prec_helper(\n        1000,\n        \"0.636619772367581343075535053490057448137838582961825794990669376235587190536906140360455\\\n        211065012343824291370907031832147571647384458314611511869642926799356916959867749636310292\\\n        310985587701230754869571584869590646773449560966894516047329520456890799022863761847560347\\\n        6106958244819576437477513763421149\",\n        \"0x0.a2f9836e4e441529fc2757d1f534ddc0db6295993c439041fe5163abdebbc561b7246e3a424dd2e006492\\\n        eea09d1921cfe1deb1cb129a73ee88235f52ebb4484e99c7026b45f7e413991d639835339f49c845f8bbdf9283\\\n        b1ff897ffde05980fef2f118b5a0a6d1f6d367ecf27cb09b74f463f669e5fea2d7527bac7ec#1000\",\n        Greater,\n    );\n    test_two_over_pi_prec_helper(\n        10000,\n        \"0.636619772367581343075535053490057448137838582961825794990669376235587190536906140360455\\\n        211065012343824291370907031832147571647384458314611511869642926799356916959867749636310292\\\n        310985587701230754869571584869590646773449560966894516047329520456890799022863761847560347\\\n        610695824481957643747751376342114892399785773600994689390957838443593292387132299624667945\\\n        851218797794608751526299146267856964155983496557394439935472396799849771502340684715433724\\\n        470075068642186190147952038957841459037335072237209977986541221308627102012881299111265588\\\n        664091786992478392663362424067212143992535647949995331146617741119020280064962710257555398\\\n        285243520488797504590725511058951562532272185831913927045249709256279843100098001191039428\\\n        356227611187140526100840065270984083699246424962245824812585936356993836765740846301630224\\\n        803486106427208868636563029898330890390985141599500621317563255927089637433019188293314876\\\n        162799903630630831397388157435931234869370256146758046650182823773310525074600104490871884\\\n        612845039801754671780150502243345268467810390325128997664933372580424494147514252454546768\\\n        668568278987840517002313344212478434378039358226874839818986041726495262070323357771919883\\\n        998021017550264517783533227384203141166060564161957195402555264310478797229364155998314767\\\n        562392374951088247501728908757205465021044955121550155524427256270617363313114107733707198\\\n        224283161544241410955984980503982997105188094376382337204659318564742310849623017797828087\\\n        159079169637961309179080866598414261272614176015362759498870766355052763866027857619107882\\\n        750734627112419119181801413583033207527354751751064499259812239862320876334395004140508516\\\n        172926321994878747511037862653848841368177634219914015170954777174146477511317149437513738\\\n        812920948583351694228474545367717840732729167856660035132317325413991163989834597161069802\\\n        439574756378353220134812215221892492863237727907041291325256759238999289753340697427959390\\\n        004158002735520159146894398432096010956043499819419151694273044559795613075989708333984459\\\n        683315615107138972142018273824334685917233826893308141941570224808347357296398248847013273\\\n        576083883174283099861995234744265443874647868149898168411324877007384899339964644598266224\\\n        151878704559725131984310433111960403132144009353091951634160955046229781723704047640217351\\\n        993556186196849931806428291412020908840944070093252692719037244201312620437495654558581223\\\n        170428720334471819506898583921895909169792436803748503147673331583545135961743474666559026\\\n        937805638014549308766972455522655322903692110389380242192851112148261351132128683950939866\\\n        273963201307954026967165858734033126467413257344642923980599412479278935033776839366623816\\\n        609002573577251457761535534246035190865800682588270075098242366434867431431756904939025326\\\n        844531994623766387562879402754976920230076790822760152873570248813549694145027233416626069\\\n        188435246887183747330259540749998994834212466393224405568578178406459538110810045644280994\\\n        086958980415466945615491440398699572694247248284696191559747554622769231394009222822857625\\\n        45545280947408042964022994369124462887872014\",\n        \"0x0.a2f9836e4e441529fc2757d1f534ddc0db6295993c439041fe5163abdebbc561b7246e3a424dd2e006492\\\n        eea09d1921cfe1deb1cb129a73ee88235f52ebb4484e99c7026b45f7e413991d639835339f49c845f8bbdf9283\\\n        b1ff897ffde05980fef2f118b5a0a6d1f6d367ecf27cb09b74f463f669e5fea2d7527bac7ebe5f17b3d0739f78\\\n        a5292ea6bfb5fb11f8d5d0856033046fc7b6babf0cfbc209af4361da9e391615ee61b086599855f14a068408df\\\n        fd8804d73273106061556ca73a8c960e27bc08c6b47c419c367cddce8092a8359c4768b961ca6ddaf44d157190\\\n        53ea5ff07053f7e33e832c2de4f98327dbbc33d26ef6b1e5ef89f3a1f35caf27f1d87f121907c7c246afa6ed57\\\n        72d30433b15c614b59d19c3c2c4ad414d2c5d000c467d862d71e39ac69b0062337cd2b497a7b4d55537f63ed71\\\n        810a3fc764d2a9d64abd770f87c6357b07ae715175649c0d9d63b3884a7cb2324778ad623545ab91f001b0af1d\\\n        fce19ff319f6a1e6661579947fbacd87f7eb7652289e83260bfe6cdc4ef09366cd43f5dd7de16de3b58929bde2\\\n        822d2e886284d58e232cac616e308cb7de050c017a71df35be01834132e6212830148835b8ef57fb0adf2e91e4\\\n        34a48d36710d8ddaa425faece616aa4280ab499d3f2a6067f775c83c2a3883c6178738a5a8cafbdd76f63a62dc\\\n        bbff4ef818d67c12645ca5536d9cad2a8288d61c277c9121426049b4612c459c444c5c891b24df31700ad43d4e\\\n        5492910d5fdfcbe00cc941eeece70f53e1380f1ecc3e7b328f8c79405933e71c1b3092ef3450b9c12887b20ab9\\\n        fb52ec292472f327b6d550c90a7721fe76b96cb314a1679e2794189dff49794e884e6e29731996bed88365f5f0\\\n        efdbbb49a486ca467427271325d8db8159f09e5bc25318d3974f71c0530010c0d68084b58ee2c90aa4702e7742\\\n        4d6bda67df772486eef169fa6948ef691b45153d1f20acf3398207e4bf56863b25f3edd035d407f8985295255c\\\n        0643710d86d324832754c5bd4714e6e5445c1090b69f52ad566149d072750045ddb3bb4c576ea17f9877d6b49b\\\n        a271d296996acccc65414ad6ae29089d98850722cbea4049407777030f327fc00a871ea49c2663de06483dd979\\\n        73fa3fd94438c860dde41319d39928c70dde7b7173bdf082b3715a0805c93805a921110d8e80faf806c4bffdb0\\\n        f903876185915a562bbcb61b989c7bd401004f2d2277549f6b6ebbb22dbaa140a2f2689768364333b091a940ea\\\n        a3a51c2a31daeedaf12265c4dc26d9c7a2d9756c0833f03f6f0098c402b99316d07b43915200c5bc3d8c492f54\\\n        badc6a5ca4ecd37a736a9e69492ab6842ddde6319ef8c76528b6837dbfcaba1ae3115dfa1ae00dafb0c664d64b\\\n        705ed306529bf56573aff47b9f96af3be75df93283080abf68c6615cb040622fa1de4d9a4b33d8f1b5709cd36e\\\n        9424ea4be13b523331aaaf0a8654fa5c1d20f3f0bcd785b76f923048b7b72178953a6c6e26e6f00ebef584a9bb\\\n        7dac4ba66aacfcf761d02d12df1b1c1998c77adc3da4886a05df7f480c62ff0ac9aecddbc5c3f6dded01fc790b\\\n        6db2a3a25a39aaf009353ad0457b6b42d297e804ba707da0eaa76a1597b2a12162db7dcfde5fafedb89fdbe896\\\n        c76e4fca90670803e156e85ff87fd073e2833676186182aeabd4dafe7b36e6d8f3967955bbf3148d78416df304\\\n        32dc7356125ce70c9b8cb30fd6cbfa200a4e46c05a0dd5a476f21d21262845cb9496170e056#10000\",\n        Less,\n    );\n\n    let two_over_pi_f32 = Float::two_over_pi_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(two_over_pi_f32.to_string(), \"0.63661975\");\n    assert_eq!(to_hex_string(&two_over_pi_f32), \"0x0.a2f983#24\");\n    assert_eq!(two_over_pi_f32, f32::TWO_OVER_PI);\n\n    let two_over_pi_f64 = Float::two_over_pi_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(two_over_pi_f64.to_string(), \"0.6366197723675814\");\n    assert_eq!(to_hex_string(&two_over_pi_f64), \"0x0.a2f9836e4e4418#53\");\n    assert_eq!(two_over_pi_f64, f64::TWO_OVER_PI);\n}\n\n#[test]\n#[should_panic]\nfn two_over_pi_prec_fail_1() {\n    Float::two_over_pi_prec(0);\n}\n\nfn test_two_over_pi_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::two_over_pi_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_two_over_pi_prec_round() {\n    test_two_over_pi_prec_round_helper(1, Floor, \"0.5\", \"0x0.8#1\", Less);\n    test_two_over_pi_prec_round_helper(1, Ceiling, \"1.0\", \"0x1.0#1\", Greater);\n    test_two_over_pi_prec_round_helper(1, Down, \"0.5\", \"0x0.8#1\", Less);\n    test_two_over_pi_prec_round_helper(1, Up, \"1.0\", \"0x1.0#1\", Greater);\n    test_two_over_pi_prec_round_helper(1, Nearest, \"0.5\", \"0x0.8#1\", Less);\n\n    test_two_over_pi_prec_round_helper(2, Floor, \"0.5\", \"0x0.8#2\", Less);\n    test_two_over_pi_prec_round_helper(2, Ceiling, \"0.8\", \"0x0.c#2\", Greater);\n    test_two_over_pi_prec_round_helper(2, Down, \"0.5\", \"0x0.8#2\", Less);\n    test_two_over_pi_prec_round_helper(2, Up, \"0.8\", \"0x0.c#2\", Greater);\n    test_two_over_pi_prec_round_helper(2, Nearest, \"0.8\", \"0x0.c#2\", Greater);\n\n    test_two_over_pi_prec_round_helper(3, Floor, \"0.6\", \"0x0.a#3\", Less);\n    test_two_over_pi_prec_round_helper(3, Ceiling, \"0.8\", \"0x0.c#3\", Greater);\n    test_two_over_pi_prec_round_helper(3, Down, \"0.6\", \"0x0.a#3\", Less);\n    test_two_over_pi_prec_round_helper(3, Up, \"0.8\", \"0x0.c#3\", Greater);\n    test_two_over_pi_prec_round_helper(3, Nearest, \"0.6\", \"0x0.a#3\", Less);\n\n    test_two_over_pi_prec_round_helper(4, Floor, \"0.62\", \"0x0.a#4\", Less);\n    test_two_over_pi_prec_round_helper(4, Ceiling, \"0.7\", \"0x0.b#4\", Greater);\n    test_two_over_pi_prec_round_helper(4, Down, \"0.62\", \"0x0.a#4\", Less);\n    test_two_over_pi_prec_round_helper(4, Up, \"0.7\", \"0x0.b#4\", Greater);\n    test_two_over_pi_prec_round_helper(4, Nearest, \"0.62\", \"0x0.a#4\", Less);\n\n    test_two_over_pi_prec_round_helper(5, Floor, \"0.62\", \"0x0.a0#5\", Less);\n    test_two_over_pi_prec_round_helper(5, Ceiling, \"0.66\", \"0x0.a8#5\", Greater);\n    test_two_over_pi_prec_round_helper(5, Down, \"0.62\", \"0x0.a0#5\", Less);\n    test_two_over_pi_prec_round_helper(5, Up, \"0.66\", \"0x0.a8#5\", Greater);\n    test_two_over_pi_prec_round_helper(5, Nearest, \"0.62\", \"0x0.a0#5\", Less);\n\n    test_two_over_pi_prec_round_helper(6, Floor, \"0.62\", \"0x0.a0#6\", Less);\n    test_two_over_pi_prec_round_helper(6, Ceiling, \"0.64\", \"0x0.a4#6\", Greater);\n    test_two_over_pi_prec_round_helper(6, Down, \"0.62\", \"0x0.a0#6\", Less);\n    test_two_over_pi_prec_round_helper(6, Up, \"0.64\", \"0x0.a4#6\", Greater);\n    test_two_over_pi_prec_round_helper(6, Nearest, \"0.64\", \"0x0.a4#6\", Greater);\n\n    test_two_over_pi_prec_round_helper(7, Floor, \"0.63\", \"0x0.a2#7\", Less);\n    test_two_over_pi_prec_round_helper(7, Ceiling, \"0.64\", \"0x0.a4#7\", Greater);\n    test_two_over_pi_prec_round_helper(7, Down, \"0.63\", \"0x0.a2#7\", Less);\n    test_two_over_pi_prec_round_helper(7, Up, \"0.64\", \"0x0.a4#7\", Greater);\n    test_two_over_pi_prec_round_helper(7, Nearest, \"0.63\", \"0x0.a2#7\", Less);\n\n    test_two_over_pi_prec_round_helper(8, Floor, \"0.633\", \"0x0.a2#8\", Less);\n    test_two_over_pi_prec_round_helper(8, Ceiling, \"0.637\", \"0x0.a3#8\", Greater);\n    test_two_over_pi_prec_round_helper(8, Down, \"0.633\", \"0x0.a2#8\", Less);\n    test_two_over_pi_prec_round_helper(8, Up, \"0.637\", \"0x0.a3#8\", Greater);\n    test_two_over_pi_prec_round_helper(8, Nearest, \"0.637\", \"0x0.a3#8\", Greater);\n\n    test_two_over_pi_prec_round_helper(9, Floor, \"0.635\", \"0x0.a28#9\", Less);\n    test_two_over_pi_prec_round_helper(9, Ceiling, \"0.637\", \"0x0.a30#9\", Greater);\n    test_two_over_pi_prec_round_helper(9, Down, \"0.635\", \"0x0.a28#9\", Less);\n    test_two_over_pi_prec_round_helper(9, Up, \"0.637\", \"0x0.a30#9\", Greater);\n    test_two_over_pi_prec_round_helper(9, Nearest, \"0.637\", \"0x0.a30#9\", Greater);\n\n    test_two_over_pi_prec_round_helper(10, Floor, \"0.636\", \"0x0.a2c#10\", Less);\n    test_two_over_pi_prec_round_helper(10, Ceiling, \"0.637\", \"0x0.a30#10\", Greater);\n    test_two_over_pi_prec_round_helper(10, Down, \"0.636\", \"0x0.a2c#10\", Less);\n    test_two_over_pi_prec_round_helper(10, Up, \"0.637\", \"0x0.a30#10\", Greater);\n    test_two_over_pi_prec_round_helper(10, Nearest, \"0.637\", \"0x0.a30#10\", Greater);\n\n    test_two_over_pi_prec_round_helper(\n        100,\n        Floor,\n        \"0.63661977236758134307553505349\",\n        \"0x0.a2f9836e4e441529fc2757d1f#100\",\n        Less,\n    );\n    test_two_over_pi_prec_round_helper(\n        100,\n        Ceiling,\n        \"0.6366197723675813430755350534906\",\n        \"0x0.a2f9836e4e441529fc2757d20#100\",\n        Greater,\n    );\n    test_two_over_pi_prec_round_helper(\n        100,\n        Down,\n        \"0.63661977236758134307553505349\",\n        \"0x0.a2f9836e4e441529fc2757d1f#100\",\n        Less,\n    );\n    test_two_over_pi_prec_round_helper(\n        100,\n        Up,\n        \"0.6366197723675813430755350534906\",\n        \"0x0.a2f9836e4e441529fc2757d20#100\",\n        Greater,\n    );\n    test_two_over_pi_prec_round_helper(\n        100,\n        Nearest,\n        \"0.63661977236758134307553505349\",\n        \"0x0.a2f9836e4e441529fc2757d1f#100\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn two_over_pi_prec_round_fail_1() {\n    Float::two_over_pi_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn two_over_pi_prec_round_fail_2() {\n    Float::two_over_pi_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn two_over_pi_prec_round_fail_3() {\n    Float::two_over_pi_prec_round(1000, Exact);\n}\n\n#[test]\nfn two_over_pi_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (two_over_pi, o) = Float::two_over_pi_prec(prec);\n        assert!(two_over_pi.is_valid());\n        assert_eq!(two_over_pi.get_prec(), Some(prec));\n        assert_eq!(two_over_pi.get_exponent(), Some(0));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (two_over_pi_alt, o_alt) = Float::two_over_pi_prec_round(prec, Ceiling);\n            let mut next_upper = two_over_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(two_over_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !two_over_pi.is_power_of_2() {\n            let (two_over_pi_alt, o_alt) = Float::two_over_pi_prec_round(prec, Floor);\n            let mut next_lower = two_over_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(two_over_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (two_over_pi_alt, o_alt) = Float::two_over_pi_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&two_over_pi_alt),\n            ComparableFloatRef(&two_over_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn two_over_pi_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (two_over_pi, o) = Float::two_over_pi_prec_round(prec, rm);\n        assert!(two_over_pi.is_valid());\n        assert_eq!(two_over_pi.get_prec(), Some(prec));\n        assert_eq!(\n            two_over_pi.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                1\n            } else {\n                0\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (two_over_pi_alt, o_alt) = Float::two_over_pi_prec_round(prec, Ceiling);\n            let mut next_upper = two_over_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(two_over_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !two_over_pi.is_power_of_2() {\n            let (two_over_pi_alt, o_alt) = Float::two_over_pi_prec_round(prec, Floor);\n            let mut next_lower = two_over_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(two_over_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::two_over_pi_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::two_over_pi_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/constants/two_over_sqrt_pi.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::traits::TwoOverSqrtPi;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_rounding_mode_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{test_constant, to_hex_string};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\nfn test_two_over_sqrt_pi_prec_helper(prec: u64, out: &str, out_hex: &str, out_o: Ordering) {\n    let (x, o) = Float::two_over_sqrt_pi_prec(prec);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_two_over_sqrt_pi_prec() {\n    test_two_over_sqrt_pi_prec_helper(1, \"1.0\", \"0x1.0#1\", Less);\n    test_two_over_sqrt_pi_prec_helper(2, \"1.0\", \"0x1.0#2\", Less);\n    test_two_over_sqrt_pi_prec_helper(3, \"1.2\", \"0x1.4#3\", Greater);\n    test_two_over_sqrt_pi_prec_helper(4, \"1.1\", \"0x1.2#4\", Less);\n    test_two_over_sqrt_pi_prec_helper(5, \"1.12\", \"0x1.2#5\", Less);\n    test_two_over_sqrt_pi_prec_helper(6, \"1.12\", \"0x1.20#6\", Less);\n    test_two_over_sqrt_pi_prec_helper(7, \"1.12\", \"0x1.20#7\", Less);\n    test_two_over_sqrt_pi_prec_helper(8, \"1.125\", \"0x1.20#8\", Less);\n    test_two_over_sqrt_pi_prec_helper(9, \"1.129\", \"0x1.21#9\", Greater);\n    test_two_over_sqrt_pi_prec_helper(10, \"1.129\", \"0x1.210#10\", Greater);\n    test_two_over_sqrt_pi_prec_helper(\n        100,\n        \"1.128379167095512573896158903122\",\n        \"0x1.20dd750429b6d11ae3a914fee#100\",\n        Greater,\n    );\n    test_two_over_sqrt_pi_prec_helper(\n        1000,\n        \"1.128379167095512573896158903121545171688101258657997713688171443421284936882986828973487\\\n        320404214726886056695812723414703379862989652325732730979040035537986585675274119196879520\\\n        704928700435945142423160491545640441109017054346433244416926616222799025526908972046136475\\\n        3818374903174932317026021327967155\",\n        \"0x1.20dd750429b6d11ae3a914fed7fd8688281341d7587cea2e7342b06199cc416180eb39f0b24e1e2281806\\\n        c12d98f35d77a3e9ddc91c394f0e9eedf0efffd84a2a4ac3b98489b8cbd3845e8fef6ff6af92a45e5f27c2d654\\\n        7a4f46505b5b4e62dd73fd6486de5e4e5585911777503638ea0ea96813d29a65a31a7d235ba#1000\",\n        Greater,\n    );\n    test_two_over_sqrt_pi_prec_helper(\n        10000,\n        \"1.128379167095512573896158903121545171688101258657997713688171443421284936882986828973487\\\n        320404214726886056695812723414703379862989652325732730979040035537986585675274119196879520\\\n        704928700435945142423160491545640441109017054346433244416926616222799025526908972046136475\\\n        381837490317493231702602132796715543998754668320715597752333488152466078760432701203287243\\\n        392470100916625063893758913312576651631043248869097731406379754861763556365896778950217001\\\n        836917068443263565178670503666024049245124447449894540067794862528599318852700856608980726\\\n        631607875391971216318675658441114765847576463158466211523929554936506180343123616119044459\\\n        235264930718080170688589725005789478432836238548619548451139757591558099749638273874479384\\\n        145721266849535939897219177526087267452911757503086161868839476966576982758350723791327018\\\n        482697850617660789930811682114508296549646950349484018793976683355429771178335667478997183\\\n        163300275371977372408792825814573857927614754653462236857357604231049732437943817793615062\\\n        990240294910543518259630544244126468693514830520512369964555789973905060333899393713277246\\\n        184408849722866262122203479408633108870729232600533621778609544108260549664286731729420583\\\n        709898167677538495392748117508206316946634152433906289780994634796224277050525789933163762\\\n        144944610034611200146111014760538140478418650258730371308816054606091217117786637305172610\\\n        517669441962183230451102680326896192154681258135304184955488915831319872573827621301394798\\\n        442321270036762403269655890511176091794390559806184597712231091256394888644636818979096451\\\n        397846378693640734006412458420064879125851437050838091157673662671192611457760297346542852\\\n        808312236531894105842976564219243112231755769151738741538633137951466072661211616085355310\\\n        857774493679173076256383508892008233851964641402029759551974793310482402462041711945161548\\\n        326464873039374115874373991373282632741414920329349124653295705526587225112073460916295019\\\n        351673851763550205032343583177087022638899559022604128931488470928339695796081675002149402\\\n        705503760956452458569391936454552087427059271324878358397026924524406044511662789633794884\\\n        312566085791783949166112065856075232662140149368936155086704776086186500364186886553943513\\\n        209170716292378586966001695043767126312269700601051262635023004805630507146960562075511746\\\n        193744116099678233570896735643276617479233229464677226737161287382607246540458402419168410\\\n        369080032442595204449841004182771241558536904090276184130382096457426893023177519552932669\\\n        910328559505543058012609185253324264204948243252385345305151663497890783280043012055166242\\\n        868647524427377318531773354446540102614567355680535177054052252524092466096556675461869194\\\n        502097950414221238045052862533170581314105649117929016110826071463050044902113986948490263\\\n        880543969640100358021024367307867000301735766682570676407886519783729177203642562064756387\\\n        522705452837219505239146678435510613803649417614863894095412079053170504045514553464488107\\\n        056711353135654973323610571363687790680289636128613293872689308014945837435447842138998905\\\n        2458651564368105546071376972806302466513398\",\n        \"0x1.20dd750429b6d11ae3a914fed7fd8688281341d7587cea2e7342b06199cc416180eb39f0b24e1e2281806\\\n        c12d98f35d77a3e9ddc91c394f0e9eedf0efffd84a2a4ac3b98489b8cbd3845e8fef6ff6af92a45e5f27c2d654\\\n        7a4f46505b5b4e62dd73fd6486de5e4e5585911777503638ea0ea96813d29a65a31a7d235b9fed80735a739f0c\\\n        dba12c519a4d0308fceb248f76d1a1b6642fad251a58a530d43df05fad7bc33a90c79b03bcd7729e27b629a758\\\n        4a30de9e46e24a71a8c3d52f6003ce62af51cbfa1129bfaf37d42219a1910d82dc1985ae3e4662f05fc75ed5e7\\\n        1b2bd75e97b95e80fe24ff9dc42273cac1e83311f7493092145e08d7abb2500c1067f03dfdff9363e8edcef4b8\\\n        ac1a2da635fe6ab630cb1893bfff7e5649d7b0aae1d49c6aa3cc08ba146db963c8dfd22432b1cbc010b48c3a5c\\\n        d3dfa2509f6be88b407d1059307b923d91ffb1db6618afd15a92a5ba06cc83afaa446091eaacf54b522f1945d1\\\n        91e4dacda113387974af3a343f7ce369957efdc384258530fcf9037413bb07fa3705b934bac814576820d20740\\\n        aa64c532696cc455b79c64ad5cce5fff52d9aa114ec9ff1074edc6309a26029b70a9232e59eaaa501aa0aca4a2\\\n        7728273c272ec6bb3470b095b7c747a2ef9e3c620e65f0f648cc2d13a4b4302e197a71e8ecdbc01118580a1c11\\\n        a341c7934d311d73f344b85d072c47b21e844d6b92cb6738ad4aeef5149c0f4beedcbb58ba8d1a4138068ddfc4\\\n        afdf301a3bd5f02b99abc0cc348add7d5e09ccd55b1dac8c54e22fc24f30c8c4ce5a86e55205efb686835d5904\\\n        a675e2c8135ba596719fbaa19ba789266db7b1ab4db36b1cb412b4d5ee13fddf1768dbc347d2a6d4c536bac90f\\\n        fffe356c775ee06458e42d744d6a16ed51ac40e9e2033422963d77a545f8b5aee2ea3b37c23db4f504d47b986c\\\n        a2d543ab7f158f26d46f44ba838e2cea777469249aff72afd71755af1ceac1fa7ad0c8c536ed4f2b2425458583\\\n        3d07df62553eb1ffffc1d0f3df7714180ace2618d12251cfea9e6a60a5ff086d8cd2d7a0f42e90b054aeadc826\\\n        803b731044178f676b13f2294d97b99ed318e0aa55fa0d4f2b6ab619c577093cce0852386de4f542e39dcfd5cb\\\n        4c8d73693cb51fccd163f7d0f8553874137d7a9d03886c41b7a347a8831e1add4f861d48e93b7bdb34a69871d4\\\n        e8af6148204ec26c6d1a154b3331efde63e122929a6dceb7786262d41694e2ba47da460a8a6e130b982445ea0e\\\n        45b400ea6ea6a7044e25163551bc27945081d344524130f3f1e8d0fc0a21a5b5a2dca8624b0501a0a00737ea60\\\n        4328ee18c6a983887ec3a2325eaf3f288194a7ef259177ff866265e4030896fd1b5f757135db4ad9164768e3bc\\\n        05755d775c9466c11c1a9cd9d3805fd322c9abff54269ff248d5c01e998dacac195aa549174422e94b1775e758\\\n        33cc9ef905054e08c1488ba83a5f846f053cd01762f2b68f4c9978ec41a53f8ee6c5b90ed2c27e83fa68f02bca\\\n        516823862007222eee333565e467ceafd23310af018dd80ba829818b82c9e9625c711e87079fca694ddbd3fbbf\\\n        6d0113ee672fc425c1bf33fe92da8753e6b576bc07f16f5381ad615fc5d82278d2308edc3ec6853ec1c7220860\\\n        f5d5e1d380d8a3e93c6395f420f4ad28f7da5583282ac819cdb68a6e5a6761e1ab90f8d78981c1fa1503b46dfb\\\n        78235f460132e2eb2877c1fca3e7a1644373b339635421e388ec3d17c19ef2417f476d13aa6#10000\",\n        Less,\n    );\n\n    let two_over_sqrt_pi_f32 = Float::two_over_sqrt_pi_prec(u64::from(f32::MANTISSA_DIGITS)).0;\n    assert_eq!(two_over_sqrt_pi_f32.to_string(), \"1.1283792\");\n    assert_eq!(to_hex_string(&two_over_sqrt_pi_f32), \"0x1.20dd76#24\");\n    assert_eq!(two_over_sqrt_pi_f32, f32::TWO_OVER_SQRT_PI);\n\n    let two_over_sqrt_pi_f64 = Float::two_over_sqrt_pi_prec(u64::from(f64::MANTISSA_DIGITS)).0;\n    assert_eq!(two_over_sqrt_pi_f64.to_string(), \"1.1283791670955126\");\n    assert_eq!(to_hex_string(&two_over_sqrt_pi_f64), \"0x1.20dd750429b6d#53\");\n    assert_eq!(two_over_sqrt_pi_f64, f64::TWO_OVER_SQRT_PI);\n}\n\n#[test]\n#[should_panic]\nfn two_over_sqrt_pi_prec_fail_1() {\n    Float::two_over_sqrt_pi_prec(0);\n}\n\nfn test_two_over_sqrt_pi_prec_round_helper(\n    prec: u64,\n    rm: RoundingMode,\n    out: &str,\n    out_hex: &str,\n    out_o: Ordering,\n) {\n    let (x, o) = Float::two_over_sqrt_pi_prec_round(prec, rm);\n    assert!(x.is_valid());\n    assert_eq!(x.to_string(), out);\n    assert_eq!(to_hex_string(&x), out_hex);\n    assert_eq!(o, out_o);\n}\n\n#[test]\npub fn test_two_over_sqrt_pi_prec_round() {\n    test_two_over_sqrt_pi_prec_round_helper(1, Floor, \"1.0\", \"0x1.0#1\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(1, Ceiling, \"2.0\", \"0x2.0#1\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(1, Down, \"1.0\", \"0x1.0#1\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(1, Up, \"2.0\", \"0x2.0#1\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(1, Nearest, \"1.0\", \"0x1.0#1\", Less);\n\n    test_two_over_sqrt_pi_prec_round_helper(2, Floor, \"1.0\", \"0x1.0#2\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(2, Ceiling, \"1.5\", \"0x1.8#2\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(2, Down, \"1.0\", \"0x1.0#2\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(2, Up, \"1.5\", \"0x1.8#2\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(2, Nearest, \"1.0\", \"0x1.0#2\", Less);\n\n    test_two_over_sqrt_pi_prec_round_helper(3, Floor, \"1.0\", \"0x1.0#3\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(3, Ceiling, \"1.2\", \"0x1.4#3\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(3, Down, \"1.0\", \"0x1.0#3\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(3, Up, \"1.2\", \"0x1.4#3\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(3, Nearest, \"1.2\", \"0x1.4#3\", Greater);\n\n    test_two_over_sqrt_pi_prec_round_helper(4, Floor, \"1.1\", \"0x1.2#4\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(4, Ceiling, \"1.2\", \"0x1.4#4\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(4, Down, \"1.1\", \"0x1.2#4\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(4, Up, \"1.2\", \"0x1.4#4\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(4, Nearest, \"1.1\", \"0x1.2#4\", Less);\n\n    test_two_over_sqrt_pi_prec_round_helper(5, Floor, \"1.12\", \"0x1.2#5\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(5, Ceiling, \"1.19\", \"0x1.3#5\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(5, Down, \"1.12\", \"0x1.2#5\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(5, Up, \"1.19\", \"0x1.3#5\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(5, Nearest, \"1.12\", \"0x1.2#5\", Less);\n\n    test_two_over_sqrt_pi_prec_round_helper(6, Floor, \"1.12\", \"0x1.20#6\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(6, Ceiling, \"1.16\", \"0x1.28#6\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(6, Down, \"1.12\", \"0x1.20#6\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(6, Up, \"1.16\", \"0x1.28#6\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(6, Nearest, \"1.12\", \"0x1.20#6\", Less);\n\n    test_two_over_sqrt_pi_prec_round_helper(7, Floor, \"1.12\", \"0x1.20#7\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(7, Ceiling, \"1.14\", \"0x1.24#7\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(7, Down, \"1.12\", \"0x1.20#7\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(7, Up, \"1.14\", \"0x1.24#7\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(7, Nearest, \"1.12\", \"0x1.20#7\", Less);\n\n    test_two_over_sqrt_pi_prec_round_helper(8, Floor, \"1.125\", \"0x1.20#8\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(8, Ceiling, \"1.13\", \"0x1.22#8\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(8, Down, \"1.125\", \"0x1.20#8\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(8, Up, \"1.13\", \"0x1.22#8\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(8, Nearest, \"1.125\", \"0x1.20#8\", Less);\n\n    test_two_over_sqrt_pi_prec_round_helper(9, Floor, \"1.125\", \"0x1.20#9\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(9, Ceiling, \"1.129\", \"0x1.21#9\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(9, Down, \"1.125\", \"0x1.20#9\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(9, Up, \"1.129\", \"0x1.21#9\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(9, Nearest, \"1.129\", \"0x1.21#9\", Greater);\n\n    test_two_over_sqrt_pi_prec_round_helper(10, Floor, \"1.127\", \"0x1.208#10\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(10, Ceiling, \"1.129\", \"0x1.210#10\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(10, Down, \"1.127\", \"0x1.208#10\", Less);\n    test_two_over_sqrt_pi_prec_round_helper(10, Up, \"1.129\", \"0x1.210#10\", Greater);\n    test_two_over_sqrt_pi_prec_round_helper(10, Nearest, \"1.129\", \"0x1.210#10\", Greater);\n\n    test_two_over_sqrt_pi_prec_round_helper(\n        100,\n        Floor,\n        \"1.12837916709551257389615890312\",\n        \"0x1.20dd750429b6d11ae3a914fec#100\",\n        Less,\n    );\n    test_two_over_sqrt_pi_prec_round_helper(\n        100,\n        Ceiling,\n        \"1.128379167095512573896158903122\",\n        \"0x1.20dd750429b6d11ae3a914fee#100\",\n        Greater,\n    );\n    test_two_over_sqrt_pi_prec_round_helper(\n        100,\n        Down,\n        \"1.12837916709551257389615890312\",\n        \"0x1.20dd750429b6d11ae3a914fec#100\",\n        Less,\n    );\n    test_two_over_sqrt_pi_prec_round_helper(\n        100,\n        Up,\n        \"1.128379167095512573896158903122\",\n        \"0x1.20dd750429b6d11ae3a914fee#100\",\n        Greater,\n    );\n    test_two_over_sqrt_pi_prec_round_helper(\n        100,\n        Nearest,\n        \"1.128379167095512573896158903122\",\n        \"0x1.20dd750429b6d11ae3a914fee#100\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn two_over_sqrt_pi_prec_round_fail_1() {\n    Float::two_over_sqrt_pi_prec_round(0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn two_over_sqrt_pi_prec_round_fail_2() {\n    Float::two_over_sqrt_pi_prec_round(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn two_over_sqrt_pi_prec_round_fail_3() {\n    Float::two_over_sqrt_pi_prec_round(1000, Exact);\n}\n\n#[test]\nfn two_over_sqrt_pi_prec_properties() {\n    unsigned_gen_var_11().test_properties(|prec| {\n        let (two_over_sqrt_pi, o) = Float::two_over_sqrt_pi_prec(prec);\n        assert!(two_over_sqrt_pi.is_valid());\n        assert_eq!(two_over_sqrt_pi.get_prec(), Some(prec));\n        assert_eq!(two_over_sqrt_pi.get_exponent(), Some(1));\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (two_over_sqrt_pi_alt, o_alt) = Float::two_over_sqrt_pi_prec_round(prec, Ceiling);\n            let mut next_upper = two_over_sqrt_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(two_over_sqrt_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !two_over_sqrt_pi.is_power_of_2() {\n            let (two_over_sqrt_pi_alt, o_alt) = Float::two_over_sqrt_pi_prec_round(prec, Floor);\n            let mut next_lower = two_over_sqrt_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(two_over_sqrt_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n        let (two_over_sqrt_pi_alt, o_alt) = Float::two_over_sqrt_pi_prec_round(prec, Nearest);\n        assert_eq!(\n            ComparableFloatRef(&two_over_sqrt_pi_alt),\n            ComparableFloatRef(&two_over_sqrt_pi)\n        );\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn two_over_sqrt_pi_prec_round_properties() {\n    unsigned_rounding_mode_pair_gen_var_4().test_properties(|(prec, rm)| {\n        let (two_over_sqrt_pi, o) = Float::two_over_sqrt_pi_prec_round(prec, rm);\n        assert!(two_over_sqrt_pi.is_valid());\n        assert_eq!(two_over_sqrt_pi.get_prec(), Some(prec));\n        assert_eq!(\n            two_over_sqrt_pi.get_exponent(),\n            Some(if prec == 1 && (rm == Ceiling || rm == Up) {\n                2\n            } else {\n                1\n            })\n        );\n        assert_ne!(o, Equal);\n        if o == Less {\n            let (two_over_sqrt_pi_alt, o_alt) = Float::two_over_sqrt_pi_prec_round(prec, Ceiling);\n            let mut next_upper = two_over_sqrt_pi.clone();\n            next_upper.increment();\n            if !next_upper.is_power_of_2() {\n                assert_eq!(\n                    ComparableFloat(two_over_sqrt_pi_alt),\n                    ComparableFloat(next_upper)\n                );\n                assert_eq!(o_alt, Greater);\n            }\n        } else if !two_over_sqrt_pi.is_power_of_2() {\n            let (two_over_sqrt_pi_alt, o_alt) = Float::two_over_sqrt_pi_prec_round(prec, Floor);\n            let mut next_lower = two_over_sqrt_pi.clone();\n            next_lower.decrement();\n            assert_eq!(\n                ComparableFloat(two_over_sqrt_pi_alt),\n                ComparableFloat(next_lower)\n            );\n            assert_eq!(o_alt, Less);\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|prec| {\n        assert_panic!(Float::two_over_sqrt_pi_prec_round(prec, Exact));\n    });\n\n    test_constant(Float::two_over_sqrt_pi_prec_round, 10000);\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_12, float_pair_gen, float_pair_gen_var_10,\n};\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse rug;\n\n#[test]\n#[allow(clippy::redundant_clone)]\nfn test_clone() {\n    let test = |s, s_hex| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let x_alt = x.clone();\n        assert!(x.is_valid());\n        assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n\n        let r_x = rug::Float::exact_from(&x).clone();\n        assert_eq!(ComparableFloat(Float::from(&r_x)), ComparableFloat(x));\n    };\n    test(\"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\");\n    test(\"0.0\", \"0x0.0\");\n    test(\"-0.0\", \"-0x0.0\");\n\n    test(\"1.0\", \"0x1.0#1\");\n    test(\"2.0\", \"0x2.0#1\");\n    test(\"0.5\", \"0x0.8#1\");\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\");\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\");\n    test(\"3.1415926535897931\", \"0x3.243f6a8885a30#53\");\n\n    test(\"-1.0\", \"-0x1.0#1\");\n    test(\"-2.0\", \"-0x2.0#1\");\n    test(\"-0.5\", \"-0x0.8#1\");\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\");\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\");\n    test(\"-3.1415926535897931\", \"-0x3.243f6a8885a30#53\");\n}\n\n#[test]\nfn test_clone_from() {\n    let test = |s, s_hex, t, t_hex| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n        let y = parse_hex_string(t_hex);\n        assert_eq!(y.to_string(), t);\n\n        let mut x_alt = x.clone();\n        x_alt.clone_from(&y);\n        assert!(x_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&y));\n\n        let mut rug_x = rug::Float::exact_from(&x);\n        let rug_y = rug::Float::exact_from(&y);\n        rug_x.clone_from(&rug_y);\n        assert_eq!(\n            ComparableFloat(Float::from(&rug_x)),\n            ComparableFloat(Float::from(&rug_y))\n        );\n    };\n    test(\"NaN\", \"NaN\", \"NaN\", \"NaN\");\n    test(\"NaN\", \"NaN\", \"0.0\", \"0x0.0\");\n    test(\"NaN\", \"NaN\", \"Infinity\", \"Infinity\");\n    test(\"NaN\", \"NaN\", \"-Infinity\", \"-Infinity\");\n    test(\"NaN\", \"NaN\", \"0.33333333333333331\", \"0x0.55555555555554#53\");\n\n    test(\"0.0\", \"0x0.0\", \"NaN\", \"NaN\");\n    test(\"0.0\", \"0x0.0\", \"0.0\", \"0x0.0\");\n    test(\"0.0\", \"0x0.0\", \"Infinity\", \"Infinity\");\n    test(\"0.0\", \"0x0.0\", \"-Infinity\", \"-Infinity\");\n    test(\n        \"0.0\",\n        \"0x0.0\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n\n    test(\"Infinity\", \"Infinity\", \"NaN\", \"NaN\");\n    test(\"Infinity\", \"Infinity\", \"0.0\", \"0x0.0\");\n    test(\"Infinity\", \"Infinity\", \"Infinity\", \"Infinity\");\n    test(\"Infinity\", \"Infinity\", \"-Infinity\", \"-Infinity\");\n    test(\n        \"Infinity\",\n        \"Infinity\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n\n    test(\"-Infinity\", \"-Infinity\", \"NaN\", \"NaN\");\n    test(\"-Infinity\", \"-Infinity\", \"0.0\", \"0x0.0\");\n    test(\"-Infinity\", \"-Infinity\", \"Infinity\", \"Infinity\");\n    test(\"-Infinity\", \"-Infinity\", \"-Infinity\", \"-Infinity\");\n    test(\n        \"-Infinity\",\n        \"-Infinity\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", \"NaN\", \"NaN\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0.0\",\n        \"0x0.0\",\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"Infinity\",\n        \"Infinity\",\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"-Infinity\",\n        \"-Infinity\",\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n}\n\nfn clone_and_clone_from_properties_helper_1(x: Float) {\n    let mut_x = x.clone();\n    assert!(mut_x.is_valid());\n    assert_eq!(ComparableFloatRef(&mut_x), ComparableFloatRef(&x));\n\n    assert_eq!(\n        ComparableFloat(Float::from(&rug::Float::exact_from(&x).clone())),\n        ComparableFloat(x)\n    );\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn clone_and_clone_from_properties_helper_2(x: Float, y: Float) {\n    let mut mut_x = x.clone();\n    mut_x.clone_from(&y);\n    assert!(mut_x.is_valid());\n    assert_eq!(ComparableFloatRef(&mut_x), ComparableFloatRef(&y));\n\n    let mut rug_x = rug::Float::exact_from(&x);\n    rug_x.clone_from(&rug::Float::exact_from(&y));\n    assert_eq!(ComparableFloat(Float::from(&rug_x)), ComparableFloat(y));\n}\n\n#[allow(clippy::redundant_clone)]\n#[test]\nfn clone_and_clone_from_properties() {\n    float_gen().test_properties(|x| {\n        clone_and_clone_from_properties_helper_1(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        clone_and_clone_from_properties_helper_1(x);\n    });\n\n    float_pair_gen().test_properties(|(x, y)| {\n        clone_and_clone_from_properties_helper_2(x, y);\n    });\n\n    float_pair_gen_var_10().test_properties(|(x, y)| {\n        clone_and_clone_from_properties_helper_2(x, y);\n    });\n\n    integer_pair_gen().test_properties(|(i, j)| {\n        let x = Float::exact_from(&i);\n        let y = Float::exact_from(&j);\n\n        let mut mut_i = i.clone();\n        let mut mut_x = x.clone();\n        mut_i.clone_from(&j);\n        mut_x.clone_from(&y);\n        assert_eq!(mut_x, mut_i);\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_float::test_util::common::{rug_round_try_from_rounding_mode, to_hex_string};\nuse malachite_float::test_util::generators::*;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_unsigned_pair_gen_var_6};\nuse malachite_q::Rational;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_integer_prec() {\n    let test = |s, prec, out, out_hex, out_o| {\n        let u = Integer::from_str(s).unwrap();\n\n        let (x, o) = Float::from_integer_prec(u.clone(), prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_integer_prec_ref(&u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), rug::Integer::from(&u));\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    };\n    test(\"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 20, \"1.0\", \"0x1.00000#20\", Equal);\n\n    test(\"123\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123\", 10, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 20, \"123.0\", \"0x7b.0000#20\", Equal);\n\n    test(\"1000000000000\", 1, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test(\"1000000000000\", 10, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test(\"1000000000000\", 20, \"9.999997e11\", \"0xe.8d4aE+9#20\", Less);\n\n    test(\"-1\", 1, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 10, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 20, \"-1.0\", \"-0x1.00000#20\", Equal);\n\n    test(\"-123\", 1, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n    test(\"-123\", 10, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123\", 20, \"-123.0\", \"-0x7b.0000#20\", Equal);\n\n    test(\"-1000000000000\", 1, \"-1.0e12\", \"-0x1.0E+10#1\", Less);\n    test(\"-1000000000000\", 10, \"-9.997e11\", \"-0xe.8cE+9#10\", Greater);\n    test(\n        \"-1000000000000\",\n        20,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n    let test_big = |u: Integer, prec, out, out_hex, out_o| {\n        let (x, o) = Float::from_integer_prec(u.clone(), prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_integer_prec_ref(&u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), rug::Integer::from(&u));\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    };\n    test_big(\n        Integer::power_of_2(1000),\n        10,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n\n    test_big(\n        -Integer::power_of_2(1000),\n        10,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n}\n\n#[test]\nfn from_integer_prec_fail() {\n    assert_panic!(Float::from_integer_prec(Integer::ZERO, 0));\n    assert_panic!(Float::from_integer_prec(Integer::ONE, 0));\n    assert_panic!(Float::from_integer_prec(Integer::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn from_integer_prec_ref_fail() {\n    assert_panic!(Float::from_integer_prec_ref(&Integer::ZERO, 0));\n    assert_panic!(Float::from_integer_prec_ref(&Integer::ONE, 0));\n    assert_panic!(Float::from_integer_prec_ref(&Integer::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn test_from_integer_prec_round() {\n    let test = |s, prec, rm, out, out_hex, out_o| {\n        let u = Integer::from_str(s).unwrap();\n\n        let (x, o) = Float::from_integer_prec_round(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_integer_prec_round_ref(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, rug_o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Integer::from(&u), rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(rug_o, out_o);\n        }\n    };\n    test(\"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 20, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\"1\", 20, Floor, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Ceiling, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Down, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Up, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Nearest, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Exact, \"1.0\", \"0x1.00000#20\", Equal);\n\n    test(\"123\", 1, Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"123\", 1, Ceiling, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123\", 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"123\", 1, Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123\", 1, Nearest, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n\n    test(\"123\", 10, Floor, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Ceiling, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Down, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Nearest, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Exact, \"123.0\", \"0x7b.0#10\", Equal);\n\n    test(\"123\", 20, Floor, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Ceiling, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Down, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Up, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Nearest, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Exact, \"123.0\", \"0x7b.0000#20\", Equal);\n\n    test(\"1000000000000\", 1, Floor, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test(\n        \"1000000000000\",\n        1,\n        Ceiling,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n    test(\"1000000000000\", 1, Down, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test(\"1000000000000\", 1, Up, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test(\n        \"1000000000000\",\n        1,\n        Nearest,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n\n    test(\"1000000000000\", 10, Floor, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test(\n        \"1000000000000\",\n        10,\n        Ceiling,\n        \"1.001e12\",\n        \"0xe.90E+9#10\",\n        Greater,\n    );\n    test(\"1000000000000\", 10, Down, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test(\"1000000000000\", 10, Up, \"1.001e12\", \"0xe.90E+9#10\", Greater);\n    test(\n        \"1000000000000\",\n        10,\n        Nearest,\n        \"9.997e11\",\n        \"0xe.8cE+9#10\",\n        Less,\n    );\n\n    test(\n        \"1000000000000\",\n        20,\n        Floor,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Ceiling,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Down,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Up,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Nearest,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n\n    test(\"-1\", 1, Floor, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Ceiling, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Down, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Up, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Nearest, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Exact, \"-1.0\", \"-0x1.0#1\", Equal);\n\n    test(\"-1\", 10, Floor, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Ceiling, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Down, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Up, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Nearest, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Exact, \"-1.0\", \"-0x1.000#10\", Equal);\n\n    test(\"-1\", 20, Floor, \"-1.0\", \"-0x1.00000#20\", Equal);\n    test(\"-1\", 20, Ceiling, \"-1.0\", \"-0x1.00000#20\", Equal);\n    test(\"-1\", 20, Down, \"-1.0\", \"-0x1.00000#20\", Equal);\n    test(\"-1\", 20, Up, \"-1.0\", \"-0x1.00000#20\", Equal);\n    test(\"-1\", 20, Nearest, \"-1.0\", \"-0x1.00000#20\", Equal);\n    test(\"-1\", 20, Exact, \"-1.0\", \"-0x1.00000#20\", Equal);\n\n    test(\"-123\", 1, Floor, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n    test(\"-123\", 1, Ceiling, \"-6.0e1\", \"-0x4.0E+1#1\", Greater);\n    test(\"-123\", 1, Down, \"-6.0e1\", \"-0x4.0E+1#1\", Greater);\n    test(\"-123\", 1, Up, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n    test(\"-123\", 1, Nearest, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n\n    test(\"-123\", 10, Floor, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123\", 10, Ceiling, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123\", 10, Down, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123\", 10, Up, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123\", 10, Nearest, \"-123.0\", \"-0x7b.0#10\", Equal);\n    test(\"-123\", 10, Exact, \"-123.0\", \"-0x7b.0#10\", Equal);\n\n    test(\"-123\", 20, Floor, \"-123.0\", \"-0x7b.0000#20\", Equal);\n    test(\"-123\", 20, Ceiling, \"-123.0\", \"-0x7b.0000#20\", Equal);\n    test(\"-123\", 20, Down, \"-123.0\", \"-0x7b.0000#20\", Equal);\n    test(\"-123\", 20, Up, \"-123.0\", \"-0x7b.0000#20\", Equal);\n    test(\"-123\", 20, Nearest, \"-123.0\", \"-0x7b.0000#20\", Equal);\n    test(\"-123\", 20, Exact, \"-123.0\", \"-0x7b.0000#20\", Equal);\n\n    test(\"-1000000000000\", 1, Floor, \"-1.0e12\", \"-0x1.0E+10#1\", Less);\n    test(\n        \"-1000000000000\",\n        1,\n        Ceiling,\n        \"-5.0e11\",\n        \"-0x8.0E+9#1\",\n        Greater,\n    );\n    test(\"-1000000000000\", 1, Down, \"-5.0e11\", \"-0x8.0E+9#1\", Greater);\n    test(\"-1000000000000\", 1, Up, \"-1.0e12\", \"-0x1.0E+10#1\", Less);\n    test(\n        \"-1000000000000\",\n        1,\n        Nearest,\n        \"-1.0e12\",\n        \"-0x1.0E+10#1\",\n        Less,\n    );\n\n    test(\n        \"-1000000000000\",\n        10,\n        Floor,\n        \"-1.001e12\",\n        \"-0xe.90E+9#10\",\n        Less,\n    );\n    test(\n        \"-1000000000000\",\n        10,\n        Ceiling,\n        \"-9.997e11\",\n        \"-0xe.8cE+9#10\",\n        Greater,\n    );\n    test(\n        \"-1000000000000\",\n        10,\n        Down,\n        \"-9.997e11\",\n        \"-0xe.8cE+9#10\",\n        Greater,\n    );\n    test(\"-1000000000000\", 10, Up, \"-1.001e12\", \"-0xe.90E+9#10\", Less);\n    test(\n        \"-1000000000000\",\n        10,\n        Nearest,\n        \"-9.997e11\",\n        \"-0xe.8cE+9#10\",\n        Greater,\n    );\n\n    test(\n        \"-1000000000000\",\n        20,\n        Floor,\n        \"-1.000001e12\",\n        \"-0xe.8d4bE+9#20\",\n        Less,\n    );\n    test(\n        \"-1000000000000\",\n        20,\n        Ceiling,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n    test(\n        \"-1000000000000\",\n        20,\n        Down,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n    test(\n        \"-1000000000000\",\n        20,\n        Up,\n        \"-1.000001e12\",\n        \"-0xe.8d4bE+9#20\",\n        Less,\n    );\n    test(\n        \"-1000000000000\",\n        20,\n        Nearest,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n    let test_big = |u: Integer, prec, rm, out, out_hex, out_o| {\n        let (x, o) = Float::from_integer_prec_round(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_integer_prec_round_ref(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Integer::from(&u), rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(o, out_o);\n        }\n    };\n    test_big(\n        Integer::power_of_2(1000),\n        10,\n        Floor,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(1000),\n        10,\n        Ceiling,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(1000),\n        10,\n        Down,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(1000),\n        10,\n        Up,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(1000),\n        10,\n        Nearest,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(1000),\n        10,\n        Exact,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x7.feE+268435455#10\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"too_big\",\n        \"0x7.feE+268435455#10\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Nearest,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n\n    test_big(\n        -Integer::power_of_2(1000),\n        10,\n        Floor,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(1000),\n        10,\n        Ceiling,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(1000),\n        10,\n        Down,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(1000),\n        10,\n        Up,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(1000),\n        10,\n        Nearest,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(1000),\n        10,\n        Exact,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"-too_big\",\n        \"-0x7.feE+268435455#10\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"-too_big\",\n        \"-0x7.feE+268435455#10\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Exact,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        1,\n        Nearest,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n}\n\n#[test]\nfn from_integer_prec_round_fail() {\n    assert_panic!(Float::from_integer_prec_round(Integer::ZERO, 0, Floor));\n    assert_panic!(Float::from_integer_prec_round(Integer::ONE, 0, Floor));\n    assert_panic!(Float::from_integer_prec_round(\n        Integer::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::from_integer_prec_round(\n        Integer::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_integer_prec_round(\n        Integer::from(-123),\n        1,\n        Exact\n    ));\n}\n\n#[test]\nfn from_integer_prec_round_ref_fail() {\n    assert_panic!(Float::from_integer_prec_round_ref(&Integer::ZERO, 0, Floor));\n    assert_panic!(Float::from_integer_prec_round_ref(&Integer::ONE, 0, Floor));\n    assert_panic!(Float::from_integer_prec_round_ref(\n        &Integer::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::from_integer_prec_round_ref(\n        &Integer::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_integer_prec_round_ref(\n        &Integer::from(-123),\n        1,\n        Exact\n    ));\n}\n\n#[allow(clippy::needless_borrow)]\n#[test]\nfn test_try_from_integer() {\n    let test = |s, out, out_hex| {\n        let x = Integer::from_str(s).unwrap();\n\n        let of = Float::try_from(x.clone());\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n    };\n    test(\"0\", Ok(\"0.0\"), Ok(\"0x0.0\"));\n    test(\"1\", Ok(\"1.0\"), Ok(\"0x1.0#1\"));\n    test(\"123\", Ok(\"123.0\"), Ok(\"0x7b.0#7\"));\n    test(\"1000000000000\", Ok(\"1.0e12\"), Ok(\"0xe.8d4a51E+9#28\"));\n\n    test(\"-1\", Ok(\"-1.0\"), Ok(\"-0x1.0#1\"));\n    test(\"-123\", Ok(\"-123.0\"), Ok(\"-0x7b.0#7\"));\n    test(\"-1000000000000\", Ok(\"-1.0e12\"), Ok(\"-0xe.8d4a51E+9#28\"));\n\n    let test_big = |x: Integer, out, out_hex| {\n        let of = Float::try_from(x.clone());\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n    };\n    test_big(Integer::power_of_2(1000), Ok(\"1.0e301\"), Ok(\"0x1.0E+250#1\"));\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        Err(&&FloatConversionError::Overflow),\n        Err(&&FloatConversionError::Overflow),\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        Ok(\"too_big\"),\n        Ok(\"0x4.0E+268435455#1\"),\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        Ok(\"too_big\"),\n        Ok(\"0x6.0E+268435455#2\"),\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        Ok(\"too_big\"),\n        Ok(\"0x6.008E+268435455#12\"),\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        Ok(\"too_big\"),\n        Ok(\"0x5.ff8E+268435455#12\"),\n    );\n\n    test_big(\n        -Integer::power_of_2(1000),\n        Ok(\"-1.0e301\"),\n        Ok(\"-0x1.0E+250#1\"),\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        Err(&&FloatConversionError::Overflow),\n        Err(&&FloatConversionError::Overflow),\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        Ok(\"-too_big\"),\n        Ok(\"-0x4.0E+268435455#1\"),\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        Ok(\"-too_big\"),\n        Ok(\"-0x6.0E+268435455#2\"),\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        Ok(\"-too_big\"),\n        Ok(\"-0x6.008E+268435455#12\"),\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        Ok(\"-too_big\"),\n        Ok(\"-0x5.ff8E+268435455#12\"),\n    );\n}\n\n#[test]\nfn test_convertible_from_integer() {\n    let test = |s, out| {\n        let x = Integer::from_str(s).unwrap();\n        assert_eq!(Float::convertible_from(&x), out);\n    };\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"123\", true);\n    test(\"-1\", true);\n    test(\"-123\", true);\n\n    let test_big = |x: Integer, out| {\n        assert_eq!(Float::convertible_from(&x), out);\n    };\n    test_big(Integer::power_of_2(1000), true);\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        false,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)) - Integer::ONE,\n        true,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        true,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        true,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        true,\n    );\n    test_big(\n        Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        true,\n    );\n\n    test_big(-Integer::power_of_2(1000), true);\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        false,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT)) + Integer::ONE,\n        true,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        true,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Integer::from(3u8),\n        true,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3073u16),\n        true,\n    );\n    test_big(\n        -Integer::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Integer::from(3071u16),\n        true,\n    );\n}\n\n#[test]\nfn from_integer_prec_properties() {\n    integer_unsigned_pair_gen_var_6().test_properties(|(n, prec)| {\n        let (float_n, o) = Float::from_integer_prec(n.clone(), prec);\n        assert!(float_n.is_valid());\n\n        let (float_n_alt, o_alt) = Float::from_integer_prec_ref(&n, prec);\n        assert!(float_n_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o, o_alt);\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n\n        let rug_n = rug::Float::with_val(u32::exact_from(prec), rug::Integer::from(&n));\n        assert_eq!(\n            ComparableFloatRef(&float_n),\n            ComparableFloatRef(&Float::from(&rug_n))\n        );\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == 0u32 { None } else { Some(prec) }\n        );\n    });\n}\n\n#[test]\nfn from_integer_prec_round_properties() {\n    integer_unsigned_rounding_mode_triple_gen_var_3().test_properties(|(n, prec, rm)| {\n        let (float_n, o) = Float::from_integer_prec_round(n.clone(), prec, rm);\n        assert!(float_n.is_valid());\n\n        let (float_n_alt, o_alt) = Float::from_integer_prec_round_ref(&n, prec, rm);\n        assert!(float_n_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o, o_alt);\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n        match (n >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_n, rug_o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Integer::from(&n), rm);\n            assert_eq!(\n                ComparableFloatRef(&float_n),\n                ComparableFloatRef(&Float::from(&rug_n))\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == 0u32 { None } else { Some(prec) }\n        );\n    });\n\n    integer_unsigned_pair_gen_var_6().test_properties(|(n, prec)| {\n        let floor = Float::from_integer_prec_round_ref(&n, prec, Floor);\n        let r_floor = Rational::exact_from(&floor.0);\n        assert!(r_floor <= n);\n        if r_floor != 0u32 {\n            assert!(r_floor + Rational::exact_from(floor.0.ulp().unwrap()) > n);\n        }\n        let (floor_n_alt, o_alt) =\n            Float::from_integer_prec_round_ref(&n, prec, if n >= 0 { Down } else { Up });\n        assert_eq!(\n            ComparableFloatRef(&floor_n_alt),\n            ComparableFloatRef(&floor.0)\n        );\n        assert_eq!(o_alt, floor.1);\n\n        let ceiling = Float::from_integer_prec_round_ref(&n, prec, Ceiling);\n        let r_ceiling = Rational::exact_from(&ceiling.0);\n        assert!(r_ceiling >= n);\n        if r_ceiling != 0u32 {\n            assert!(r_ceiling - Rational::exact_from(ceiling.0.ulp().unwrap()) < n);\n        }\n        let (ceiling_n_alt, o_alt) =\n            Float::from_integer_prec_round_ref(&n, prec, if n >= 0 { Up } else { Down });\n        assert_eq!(\n            ComparableFloatRef(&ceiling_n_alt),\n            ComparableFloatRef(&ceiling.0)\n        );\n        assert_eq!(o_alt, ceiling.1);\n\n        let nearest = Float::from_integer_prec_round_ref(&n, prec, Nearest);\n        let r_nearest = Rational::exact_from(&nearest.0);\n        assert!(\n            ComparableFloatRef(&nearest.0) == ComparableFloatRef(&floor.0) && nearest.1 == floor.1\n                || ComparableFloatRef(&nearest.0) == ComparableFloatRef(&ceiling.0)\n                    && nearest.1 == ceiling.1\n        );\n        if r_nearest != 0u32 {\n            assert!(\n                (r_nearest - Rational::from(&n))\n                    .le_abs(&(Rational::exact_from(nearest.0.ulp().unwrap()) >> 1))\n            );\n        }\n    });\n}\n\n#[test]\nfn float_try_from_integer_properties() {\n    integer_gen().test_properties(|x| {\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        assert_eq!(\n            Float::try_from(x.clone()).map(ComparableFloat),\n            of.clone().map(ComparableFloat)\n        );\n        if let Ok(f) = of {\n            assert_eq!(-x, -f);\n        }\n    });\n}\n\n#[test]\nfn float_convertible_from_integer_properties() {\n    integer_gen().test_properties(|x| {\n        assert_eq!(Float::convertible_from(&x), Float::try_from(&x).is_ok());\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_float::test_util::common::{rug_round_try_from_rounding_mode, to_hex_string};\nuse malachite_float::test_util::generators::*;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_7};\nuse malachite_q::Rational;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_natural_prec() {\n    let test = |s, prec, out, out_hex, out_o| {\n        let u = Natural::from_str(s).unwrap();\n\n        let (x, o) = Float::from_natural_prec(u.clone(), prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_natural_prec_ref(&u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), rug::Integer::from(&u));\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    };\n    test(\"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 20, \"1.0\", \"0x1.00000#20\", Equal);\n\n    test(\"123\", 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123\", 10, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 20, \"123.0\", \"0x7b.0000#20\", Equal);\n\n    test(\"1000000000000\", 1, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test(\"1000000000000\", 10, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test(\"1000000000000\", 20, \"9.999997e11\", \"0xe.8d4aE+9#20\", Less);\n    test(\n        \"289905948138435080392\",\n        64,\n        \"2.8990594813843508038e20\",\n        \"0xf.b740d3d8283d70cE+16#64\",\n        Less,\n    );\n\n    let test_big = |u: Natural, prec, out, out_hex, out_o| {\n        let (x, o) = Float::from_natural_prec(u.clone(), prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_natural_prec_ref(&u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), rug::Integer::from(&u));\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    };\n    test_big(\n        Natural::power_of_2(1000),\n        10,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        1,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n}\n\n#[test]\nfn from_natural_prec_fail() {\n    assert_panic!(Float::from_natural_prec(Natural::ZERO, 0));\n    assert_panic!(Float::from_natural_prec(Natural::ONE, 0));\n}\n\n#[test]\nfn from_natural_prec_ref_fail() {\n    assert_panic!(Float::from_natural_prec_ref(&Natural::ZERO, 0));\n    assert_panic!(Float::from_natural_prec_ref(&Natural::ONE, 0));\n}\n\n#[test]\nfn test_from_natural_prec_round() {\n    let test = |s, prec, rm, out, out_hex, out_o| {\n        let u = Natural::from_str(s).unwrap();\n\n        let (x, o) = Float::from_natural_prec_round(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_natural_prec_round_ref(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, rug_o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Integer::from(&u), rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(rug_o, out_o);\n        }\n    };\n    test(\"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 20, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 20, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\"1\", 20, Floor, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Ceiling, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Down, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Up, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Nearest, \"1.0\", \"0x1.00000#20\", Equal);\n    test(\"1\", 20, Exact, \"1.0\", \"0x1.00000#20\", Equal);\n\n    test(\"123\", 1, Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"123\", 1, Ceiling, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123\", 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n    test(\"123\", 1, Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n    test(\"123\", 1, Nearest, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n\n    test(\"123\", 10, Floor, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Ceiling, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Down, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Nearest, \"123.0\", \"0x7b.0#10\", Equal);\n    test(\"123\", 10, Exact, \"123.0\", \"0x7b.0#10\", Equal);\n\n    test(\"123\", 20, Floor, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Ceiling, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Down, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Up, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Nearest, \"123.0\", \"0x7b.0000#20\", Equal);\n    test(\"123\", 20, Exact, \"123.0\", \"0x7b.0000#20\", Equal);\n\n    test(\"1000000000000\", 1, Floor, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test(\n        \"1000000000000\",\n        1,\n        Ceiling,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n    test(\"1000000000000\", 1, Down, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test(\"1000000000000\", 1, Up, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test(\n        \"1000000000000\",\n        1,\n        Nearest,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n\n    test(\"1000000000000\", 10, Floor, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test(\n        \"1000000000000\",\n        10,\n        Ceiling,\n        \"1.001e12\",\n        \"0xe.90E+9#10\",\n        Greater,\n    );\n    test(\"1000000000000\", 10, Down, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test(\"1000000000000\", 10, Up, \"1.001e12\", \"0xe.90E+9#10\", Greater);\n    test(\n        \"1000000000000\",\n        10,\n        Nearest,\n        \"9.997e11\",\n        \"0xe.8cE+9#10\",\n        Less,\n    );\n\n    test(\n        \"1000000000000\",\n        20,\n        Floor,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Ceiling,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Down,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Up,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test(\n        \"1000000000000\",\n        20,\n        Nearest,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n\n    test(\n        \"20928269765806917927943182622889\",\n        64,\n        Nearest,\n        \"2.0928269765806917929e31\",\n        \"0x1.0826e3012a87296eE+26#64\",\n        Greater,\n    );\n\n    // - in from_natural_prec_round\n    // - x == 0 in from_natural_prec_round\n    test(\"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    // - x != 0 in from_natural_prec_round\n    // - bits <= prec in from_natural_prec_round\n    test(\"1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    // - bits > prec in from_natural_prec_round\n    // - needed_bits == 0 in from_natural_prec_round\n    // - mask_width < Limb::WIDTH in from_natural_prec_round\n    // - rm == Floor || rm == Down in from_natural_prec_round\n    // - (rm == Floor || rm == Down) && !inexact in from_natural_prec_round\n    test(\"2\", 1, Down, \"2.0\", \"0x2.0#1\", Equal);\n    // - rm == Ceiling || rm == Up in from_natural_prec_round\n    // - (rm == Ceiling || rm == Up) && !inexact in from_natural_prec_round\n    test(\"2\", 1, Up, \"2.0\", \"0x2.0#1\", Equal);\n    // - rm == Nearest in from_natural_prec_round\n    // - rm == Nearest && (!half_bit || !inexact_after_half && !x.get_bit(bits - prec) && !inexact\n    //   in from_natural_prec_round\n    test(\"2\", 1, Nearest, \"2.0\", \"0x2.0#1\", Equal);\n    // - rm == Exact in from_natural_prec_round\n    test(\"2\", 1, Exact, \"2.0\", \"0x2.0#1\", Equal);\n    // - (rm == Floor || rm == Down) && inexact in from_natural_prec_round\n    test(\"3\", 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    // - (rm == Ceiling || rm == Up) && inexact in from_natural_prec_round\n    // - (rm == Ceiling || rm == Up) && significand.limb_count() > original_limb_count in\n    //   from_natural_prec_round\n    test(\"3\", 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    // - rm == Nearest && half_bit && (inexact_after_half || x.get_bit(bits - prec)) in\n    //   from_natural_prec_round\n    // - rm == Nearest && half_bit && (inexact_after_half || x.get_bit(bits - prec)) &&\n    //   significand.limb_count() > original_limb_count in from_natural_prec_round\n    test(\"3\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater);\n    // - rm == Nearest && (!half_bit || !inexact_after_half && !x.get_bit(bits - prec) && inexact in\n    //   from_natural_prec_round\n    test(\"5\", 1, Nearest, \"4.0\", \"0x4.0#1\", Less);\n    // - (rm == Ceiling || rm == Up) && significand.limb_count() <= original_limb_count in\n    //   from_natural_prec_round\n    test(\"5\", 2, Up, \"6.0\", \"0x6.0#2\", Greater);\n    // - rm == Nearest && half_bit && (inexact_after_half || x.get_bit(bits - prec)) &&\n    //   significand.limb_count() <= original_limb_count in from_natural_prec_round\n    test(\"11\", 2, Nearest, \"1.0e1\", \"0xc.0#2\", Greater);\n    // - needed_bits != 0 in from_natural_prec_round\n    // - mask_width >= Limb::WIDTH in from_natural_prec_round\n    test(\n        \"10524811972430560515843\",\n        15,\n        Floor,\n        \"1.05244e22\",\n        \"0x2.3a88E+18#15\",\n        Less,\n    );\n    let test_big = |u: Natural, prec, rm, out, out_hex, out_o| {\n        let (x, o) = Float::from_natural_prec_round(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_natural_prec_round_ref(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Integer::from(&u), rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(o, out_o);\n        }\n    };\n    test_big(\n        Natural::power_of_2(1000),\n        10,\n        Floor,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(1000),\n        10,\n        Ceiling,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(1000),\n        10,\n        Down,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(1000),\n        10,\n        Up,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(1000),\n        10,\n        Nearest,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(1000),\n        10,\n        Exact,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x7.feE+268435455#10\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"too_big\",\n        \"0x7.feE+268435455#10\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        1,\n        Nearest,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n}\n\n#[test]\nfn from_natural_prec_round_fail() {\n    assert_panic!(Float::from_natural_prec_round(Natural::ZERO, 0, Floor));\n    assert_panic!(Float::from_natural_prec_round(Natural::ONE, 0, Floor));\n    assert_panic!(Float::from_natural_prec_round(\n        Natural::from(123u32),\n        1,\n        Exact\n    ));\n}\n\n#[test]\nfn from_natural_prec_round_ref_fail() {\n    assert_panic!(Float::from_natural_prec_round_ref(&Natural::ZERO, 0, Floor));\n    assert_panic!(Float::from_natural_prec_round_ref(&Natural::ONE, 0, Floor));\n    assert_panic!(Float::from_natural_prec_round_ref(\n        &Natural::from(123u32),\n        1,\n        Exact\n    ));\n}\n\n#[allow(clippy::needless_borrow)]\n#[test]\nfn test_try_from_natural() {\n    let test = |s, out, out_hex| {\n        let x = Natural::from_str(s).unwrap();\n\n        let of = Float::try_from(x.clone());\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n    };\n    test(\"0\", Ok(\"0.0\"), Ok(\"0x0.0\"));\n    test(\"1\", Ok(\"1.0\"), Ok(\"0x1.0#1\"));\n    test(\"123\", Ok(\"123.0\"), Ok(\"0x7b.0#7\"));\n    test(\"1000000000000\", Ok(\"1.0e12\"), Ok(\"0xe.8d4a51E+9#28\"));\n\n    let test_big = |x: Natural, out, out_hex| {\n        let of = Float::try_from(x.clone());\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n    };\n    test_big(Natural::power_of_2(1000), Ok(\"1.0e301\"), Ok(\"0x1.0E+250#1\"));\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        Err(&&FloatConversionError::Overflow),\n        Err(&&FloatConversionError::Overflow),\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        Ok(\"too_big\"),\n        Ok(\"0x4.0E+268435455#1\"),\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        Ok(\"too_big\"),\n        Ok(\"0x6.0E+268435455#2\"),\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        Ok(\"too_big\"),\n        Ok(\"0x6.008E+268435455#12\"),\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        Ok(\"too_big\"),\n        Ok(\"0x5.ff8E+268435455#12\"),\n    );\n}\n\n#[test]\nfn test_convertible_from_natural() {\n    let test = |s, out| {\n        let x = Natural::from_str(s).unwrap();\n        assert_eq!(Float::convertible_from(&x), out);\n    };\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"123\", true);\n\n    let test_big = |x: Natural, out| {\n        assert_eq!(Float::convertible_from(&x), out);\n    };\n    test_big(Natural::power_of_2(1000), true);\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)),\n        false,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT)) - Natural::ONE,\n        true,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 1),\n        true,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 2) * Natural::from(3u8),\n        true,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3073u16),\n        true,\n    );\n    test_big(\n        Natural::power_of_2(u64::exact_from(Float::MAX_EXPONENT) - 12) * Natural::from(3071u16),\n        true,\n    );\n}\n\n#[test]\nfn from_natural_prec_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, prec)| {\n        let (float_n, o) = Float::from_natural_prec(n.clone(), prec);\n        assert!(float_n.is_valid());\n\n        let (float_n_alt, o_alt) = Float::from_natural_prec_ref(&n, prec);\n        assert!(float_n_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o, o_alt);\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n\n        let rug_n = rug::Float::with_val(u32::exact_from(prec), rug::Integer::from(&n));\n        assert_eq!(\n            ComparableFloatRef(&float_n),\n            ComparableFloatRef(&Float::from(&rug_n))\n        );\n\n        let (float_n_alt, o_alt) = Float::from_integer_prec(Integer::from(&n), prec);\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o_alt, o);\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == 0u32 { None } else { Some(prec) }\n        );\n    });\n}\n\n#[test]\nfn from_natural_prec_round_properties() {\n    natural_unsigned_rounding_mode_triple_gen_var_2().test_properties(|(n, prec, rm)| {\n        let (float_n, o) = Float::from_natural_prec_round(n.clone(), prec, rm);\n        assert!(float_n.is_valid());\n\n        let (float_n_alt, o_alt) = Float::from_natural_prec_round_ref(&n, prec, rm);\n        assert!(float_n_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o, o_alt);\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n        match rm {\n            Floor | Down => {\n                assert_ne!(o, Greater);\n            }\n            Ceiling | Up => {\n                assert_ne!(o, Less);\n            }\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_n, rug_o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Integer::from(&n), rm);\n            assert_eq!(\n                ComparableFloatRef(&float_n),\n                ComparableFloatRef(&Float::from(&rug_n))\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (float_n_alt, o_alt) = Float::from_integer_prec_round(Integer::from(&n), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o_alt, o);\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == 0u32 { None } else { Some(prec) }\n        );\n    });\n\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, prec)| {\n        let floor = Float::from_natural_prec_round_ref(&n, prec, Floor);\n        let r_floor = Rational::exact_from(&floor.0);\n        assert!(r_floor <= n);\n        if r_floor != 0u32 {\n            assert!(r_floor + Rational::exact_from(floor.0.ulp().unwrap()) > n);\n        }\n        let (floor_alt, floor_o_alt) = Float::from_natural_prec_round_ref(&n, prec, Down);\n        assert_eq!(ComparableFloatRef(&floor_alt), ComparableFloatRef(&floor.0));\n        assert_eq!(floor_o_alt, floor.1);\n\n        let ceiling = Float::from_natural_prec_round_ref(&n, prec, Ceiling);\n        let r_ceiling = Rational::exact_from(&ceiling.0);\n        assert!(r_ceiling >= n);\n        if r_ceiling != 0u32 {\n            assert!(r_ceiling - Rational::exact_from(ceiling.0.ulp().unwrap()) < n);\n        }\n        let (ceiling_alt, ceiling_o_alt) = Float::from_natural_prec_round_ref(&n, prec, Up);\n        assert_eq!(\n            ComparableFloatRef(&ceiling_alt),\n            ComparableFloatRef(&ceiling.0)\n        );\n        assert_eq!(ceiling_o_alt, ceiling.1);\n\n        let nearest = Float::from_natural_prec_round_ref(&n, prec, Nearest);\n        assert!(\n            ComparableFloatRef(&nearest.0) == ComparableFloatRef(&floor.0) && nearest.1 == floor.1\n                || ComparableFloatRef(&nearest.0) == ComparableFloatRef(&ceiling.0)\n                    && nearest.1 == ceiling.1\n        );\n        let r_nearest = Rational::exact_from(&nearest.0);\n        if r_nearest != 0u32 {\n            assert!(\n                (r_nearest - Rational::from(&n))\n                    .le_abs(&(Rational::exact_from(nearest.0.ulp().unwrap()) >> 1))\n            );\n        }\n    });\n}\n\n#[test]\nfn float_try_from_natural_properties() {\n    natural_gen().test_properties(|x| {\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        assert_eq!(\n            Float::try_from(x.clone()).map(ComparableFloat),\n            of.clone().map(ComparableFloat)\n        );\n        if let Ok(f) = of {\n            assert_eq!(-x, -f);\n        }\n    });\n}\n\n#[test]\nfn float_convertible_from_natural_properties() {\n    natural_gen().test_properties(|x| {\n        assert_eq!(Float::convertible_from(&x), Float::try_from(&x).is_ok());\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{\n    NegativeInfinity, NegativeOne, NegativeZero, One, OneHalf, Two, Zero,\n};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::{SignificantBits, TrailingZeros};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_unsigned_pair_gen_var_4,\n};\nuse malachite_float::test_util::common::{rug_round_try_from_rounding_mode, to_hex_string};\nuse malachite_float::test_util::generators::primitive_float_unsigned_rounding_mode_triple_gen_var_3;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_q::Rational;\nuse rug::Assign;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::{\n    Ordering::{self, *},\n    max,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_from_primitive_float() {\n    fn test_helper<T: PrimitiveFloat>(u: T, out: &str, out_hex: &str)\n    where\n        Float: From<T>,\n        rug::Float: Assign<T>,\n    {\n        let x = Float::from(u);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        let prec = if !u.is_finite() || u == T::ZERO {\n            1\n        } else {\n            let n = u.integer_mantissa();\n            u32::exact_from(n.significant_bits() - TrailingZeros::trailing_zeros(n))\n        };\n        let rug_x = rug::Float::with_val(prec, u);\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    }\n    test_helper(f32::NAN, \"NaN\", \"NaN\");\n    test_helper(f32::INFINITY, \"Infinity\", \"Infinity\");\n    test_helper(f32::NEGATIVE_INFINITY, \"-Infinity\", \"-Infinity\");\n    test_helper(f32::ZERO, \"0.0\", \"0x0.0\");\n    test_helper(f32::NEGATIVE_ZERO, \"-0.0\", \"-0x0.0\");\n\n    test_helper(f32::ONE, \"1.0\", \"0x1.0#1\");\n    test_helper(f32::TWO, \"2.0\", \"0x2.0#1\");\n    test_helper(f32::ONE_HALF, \"0.5\", \"0x0.8#1\");\n    test_helper(1.0f32 / 3.0, \"0.33333334\", \"0x0.5555558#24\");\n    test_helper(std::f32::consts::SQRT_2, \"1.4142135\", \"0x1.6a09e6#24\");\n    test_helper(std::f32::consts::PI, \"3.1415927\", \"0x3.243f6c#24\");\n    test_helper(f32::MIN_POSITIVE_SUBNORMAL, \"1.0e-45\", \"0x8.0E-38#1\");\n    test_helper(f32::MAX_SUBNORMAL, \"1.1754942e-38\", \"0x3.fffff8E-32#23\");\n    test_helper(f32::MIN_POSITIVE_NORMAL, \"1.0e-38\", \"0x4.0E-32#1\");\n    test_helper(f32::MAX_FINITE, \"3.4028235e38\", \"0xf.fffffE+31#24\");\n\n    test_helper(f32::NEGATIVE_ONE, \"-1.0\", \"-0x1.0#1\");\n    test_helper(-f32::TWO, \"-2.0\", \"-0x2.0#1\");\n    test_helper(-f32::ONE_HALF, \"-0.5\", \"-0x0.8#1\");\n    test_helper(-1.0f32 / 3.0, \"-0.33333334\", \"-0x0.5555558#24\");\n    test_helper(-std::f32::consts::SQRT_2, \"-1.4142135\", \"-0x1.6a09e6#24\");\n    test_helper(-std::f32::consts::PI, \"-3.1415927\", \"-0x3.243f6c#24\");\n    test_helper(-f32::MIN_POSITIVE_SUBNORMAL, \"-1.0e-45\", \"-0x8.0E-38#1\");\n    test_helper(-f32::MAX_SUBNORMAL, \"-1.1754942e-38\", \"-0x3.fffff8E-32#23\");\n    test_helper(-f32::MIN_POSITIVE_NORMAL, \"-1.0e-38\", \"-0x4.0E-32#1\");\n    test_helper(-f32::MAX_FINITE, \"-3.4028235e38\", \"-0xf.fffffE+31#24\");\n\n    test_helper(f64::NAN, \"NaN\", \"NaN\");\n    test_helper(f64::INFINITY, \"Infinity\", \"Infinity\");\n    test_helper(f64::NEGATIVE_INFINITY, \"-Infinity\", \"-Infinity\");\n    test_helper(f64::ZERO, \"0.0\", \"0x0.0\");\n    test_helper(f64::NEGATIVE_ZERO, \"-0.0\", \"-0x0.0\");\n\n    test_helper(f64::ONE, \"1.0\", \"0x1.0#1\");\n    test_helper(f64::TWO, \"2.0\", \"0x2.0#1\");\n    test_helper(f64::ONE_HALF, \"0.5\", \"0x0.8#1\");\n    test_helper(1.0f64 / 3.0, \"0.33333333333333331\", \"0x0.55555555555554#53\");\n    test_helper(\n        std::f64::consts::SQRT_2,\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n    );\n    test_helper(\n        std::f64::consts::PI,\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n    );\n    test_helper(f64::MIN_POSITIVE_SUBNORMAL, \"5.0e-324\", \"0x4.0E-269#1\");\n    test_helper(\n        f64::MAX_SUBNORMAL,\n        \"2.2250738585072009e-308\",\n        \"0x3.ffffffffffffcE-256#52\",\n    );\n    test_helper(f64::MIN_POSITIVE_NORMAL, \"2.0e-308\", \"0x4.0E-256#1\");\n    test_helper(\n        f64::MAX_FINITE,\n        \"1.7976931348623157e308\",\n        \"0xf.ffffffffffff8E+255#53\",\n    );\n\n    test_helper(f64::NEGATIVE_ONE, \"-1.0\", \"-0x1.0#1\");\n    test_helper(-f64::TWO, \"-2.0\", \"-0x2.0#1\");\n    test_helper(-f64::ONE_HALF, \"-0.5\", \"-0x0.8#1\");\n    test_helper(\n        -1.0f64 / 3.0,\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n    );\n    test_helper(\n        -std::f64::consts::SQRT_2,\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n    );\n    test_helper(\n        -std::f64::consts::PI,\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n    );\n    test_helper(-f64::MIN_POSITIVE_SUBNORMAL, \"-5.0e-324\", \"-0x4.0E-269#1\");\n    test_helper(\n        -f64::MAX_SUBNORMAL,\n        \"-2.2250738585072009e-308\",\n        \"-0x3.ffffffffffffcE-256#52\",\n    );\n    test_helper(-f64::MIN_POSITIVE_NORMAL, \"-2.0e-308\", \"-0x4.0E-256#1\");\n    test_helper(\n        -f64::MAX_FINITE,\n        \"-1.7976931348623157e308\",\n        \"-0xf.ffffffffffff8E+255#53\",\n    );\n}\n\n#[test]\nfn test_from_primitive_float_prec() {\n    fn test_helper<T: PrimitiveFloat>(u: T, prec: u64, out: &str, out_hex: &str, out_o: Ordering)\n    where\n        Float: From<T>,\n        rug::Float: Assign<T>,\n    {\n        let (x, o) = Float::from_primitive_float_prec(u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(max(1, u32::exact_from(prec)), u);\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    }\n    test_helper(f32::NAN, 1, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 10, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 100, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::INFINITY, 1, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 10, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 100, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::NEGATIVE_INFINITY, 1, \"-Infinity\", \"-Infinity\", Equal);\n    test_helper(f32::NEGATIVE_INFINITY, 10, \"-Infinity\", \"-Infinity\", Equal);\n    test_helper(f32::NEGATIVE_INFINITY, 100, \"-Infinity\", \"-Infinity\", Equal);\n    test_helper(f32::ZERO, 1, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 10, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 100, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 10, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 100, \"-0.0\", \"-0x0.0\", Equal);\n\n    test_helper(f32::ONE, 1, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f32::ONE, 10, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(\n        f32::ONE,\n        100,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(1.0f32 / 3.0, 1, \"0.2\", \"0x0.4#1\", Less);\n    test_helper(1.0f32 / 3.0, 10, \"0.3335\", \"0x0.556#10\", Greater);\n    test_helper(\n        1.0f32 / 3.0,\n        100,\n        \"0.3333333432674407958984375\",\n        \"0x0.55555580000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(std::f32::consts::PI, 1, \"4.0\", \"0x4.0#1\", Greater);\n    test_helper(std::f32::consts::PI, 10, \"3.141\", \"0x3.24#10\", Less);\n    test_helper(\n        std::f32::consts::PI,\n        100,\n        \"3.1415927410125732421875\",\n        \"0x3.243f6c0000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(\n        f32::MIN_POSITIVE_SUBNORMAL,\n        1,\n        \"1.0e-45\",\n        \"0x8.0E-38#1\",\n        Equal,\n    );\n    test_helper(\n        f32::MIN_POSITIVE_SUBNORMAL,\n        10,\n        \"1.401e-45\",\n        \"0x8.00E-38#10\",\n        Equal,\n    );\n    test_helper(\n        f32::MIN_POSITIVE_SUBNORMAL,\n        100,\n        \"1.40129846432481707092372958329e-45\",\n        \"0x8.000000000000000000000000E-38#100\",\n        Equal,\n    );\n\n    test_helper(f32::NEGATIVE_ONE, 1, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 10, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(\n        f32::NEGATIVE_ONE,\n        100,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(-1.0f32 / 3.0, 1, \"-0.2\", \"-0x0.4#1\", Greater);\n    test_helper(-1.0f32 / 3.0, 10, \"-0.3335\", \"-0x0.556#10\", Less);\n    test_helper(\n        -1.0f32 / 3.0,\n        100,\n        \"-0.3333333432674407958984375\",\n        \"-0x0.55555580000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(-std::f32::consts::PI, 1, \"-4.0\", \"-0x4.0#1\", Less);\n    test_helper(-std::f32::consts::PI, 10, \"-3.141\", \"-0x3.24#10\", Greater);\n    test_helper(\n        -std::f32::consts::PI,\n        100,\n        \"-3.1415927410125732421875\",\n        \"-0x3.243f6c0000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        1,\n        \"-1.0e-45\",\n        \"-0x8.0E-38#1\",\n        Equal,\n    );\n    test_helper(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        10,\n        \"-1.401e-45\",\n        \"-0x8.00E-38#10\",\n        Equal,\n    );\n    test_helper(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        100,\n        \"-1.40129846432481707092372958329e-45\",\n        \"-0x8.000000000000000000000000E-38#100\",\n        Equal,\n    );\n\n    test_helper(f64::NAN, 1, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 10, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 100, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::INFINITY, 1, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 10, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 100, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::NEGATIVE_INFINITY, 1, \"-Infinity\", \"-Infinity\", Equal);\n    test_helper(f64::NEGATIVE_INFINITY, 10, \"-Infinity\", \"-Infinity\", Equal);\n    test_helper(f64::NEGATIVE_INFINITY, 100, \"-Infinity\", \"-Infinity\", Equal);\n    test_helper(f64::ZERO, 1, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 10, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 100, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 1, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 10, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 100, \"-0.0\", \"-0x0.0\", Equal);\n\n    test_helper(f64::ONE, 1, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f64::ONE, 10, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(\n        f64::ONE,\n        100,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(1.0f64 / 3.0, 1, \"0.2\", \"0x0.4#1\", Less);\n    test_helper(1.0f64 / 3.0, 10, \"0.3335\", \"0x0.556#10\", Greater);\n    test_helper(\n        1.0f64 / 3.0,\n        100,\n        \"0.3333333333333333148296162562474\",\n        \"0x0.55555555555554000000000000#100\",\n        Equal,\n    );\n\n    test_helper(std::f64::consts::PI, 1, \"4.0\", \"0x4.0#1\", Greater);\n    test_helper(std::f64::consts::PI, 10, \"3.141\", \"0x3.24#10\", Less);\n    test_helper(\n        std::f64::consts::PI,\n        100,\n        \"3.141592653589793115997963468544\",\n        \"0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n\n    test_helper(\n        f64::MIN_POSITIVE_SUBNORMAL,\n        1,\n        \"5.0e-324\",\n        \"0x4.0E-269#1\",\n        Equal,\n    );\n    test_helper(\n        f64::MIN_POSITIVE_SUBNORMAL,\n        10,\n        \"4.94e-324\",\n        \"0x4.00E-269#10\",\n        Equal,\n    );\n    test_helper(\n        f64::MIN_POSITIVE_SUBNORMAL,\n        100,\n        \"4.94065645841246544176568792868e-324\",\n        \"0x4.0000000000000000000000000E-269#100\",\n        Equal,\n    );\n\n    test_helper(f64::NEGATIVE_ONE, 1, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 10, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(\n        f64::NEGATIVE_ONE,\n        100,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test_helper(-1.0f64 / 3.0, 1, \"-0.2\", \"-0x0.4#1\", Greater);\n    test_helper(-1.0f64 / 3.0, 10, \"-0.3335\", \"-0x0.556#10\", Less);\n    test_helper(\n        -1.0f64 / 3.0,\n        100,\n        \"-0.3333333333333333148296162562474\",\n        \"-0x0.55555555555554000000000000#100\",\n        Equal,\n    );\n\n    test_helper(-std::f64::consts::PI, 1, \"-4.0\", \"-0x4.0#1\", Less);\n    test_helper(-std::f64::consts::PI, 10, \"-3.141\", \"-0x3.24#10\", Greater);\n    test_helper(\n        -std::f64::consts::PI,\n        100,\n        \"-3.141592653589793115997963468544\",\n        \"-0x3.243f6a8885a30000000000000#100\",\n        Equal,\n    );\n\n    test_helper(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        1,\n        \"-5.0e-324\",\n        \"-0x4.0E-269#1\",\n        Equal,\n    );\n    test_helper(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        10,\n        \"-4.94e-324\",\n        \"-0x4.00E-269#10\",\n        Equal,\n    );\n    test_helper(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        100,\n        \"-4.94065645841246544176568792868e-324\",\n        \"-0x4.0000000000000000000000000E-269#100\",\n        Equal,\n    );\n}\n\nfn from_primitive_float_prec_fail_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T>,\n{\n    assert_panic!(Float::from_primitive_float_prec(T::NAN, 0));\n    assert_panic!(Float::from_primitive_float_prec(T::INFINITY, 0));\n    assert_panic!(Float::from_primitive_float_prec(T::NEGATIVE_INFINITY, 0));\n    assert_panic!(Float::from_primitive_float_prec(T::ZERO, 0));\n    assert_panic!(Float::from_primitive_float_prec(T::NEGATIVE_ZERO, 0));\n    assert_panic!(Float::from_primitive_float_prec(T::ONE, 0));\n    assert_panic!(Float::from_primitive_float_prec(T::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn from_primitive_float_prec_fail() {\n    apply_fn_to_primitive_floats!(from_primitive_float_prec_fail_helper);\n}\n\n#[test]\nfn test_from_primitive_float_prec_round() {\n    fn test_helper<T: PrimitiveFloat>(\n        u: T,\n        prec: u64,\n        rm: RoundingMode,\n        out: &str,\n        out_hex: &str,\n        out_o: Ordering,\n    ) where\n        rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n    {\n        let (x, o) = Float::from_primitive_float_prec_round(u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, rug_o) = rug::Float::with_val_round(max(1, u32::exact_from(prec)), u, rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(rug_o, out_o);\n        }\n    }\n    test_helper(f32::NAN, 1, Floor, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 1, Down, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 1, Up, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test_helper(f32::NAN, 10, Floor, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 10, Down, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 10, Up, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test_helper(f32::NAN, 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test_helper(f32::INFINITY, 1, Floor, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 1, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 1, Down, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 1, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 1, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test_helper(f32::INFINITY, 10, Floor, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 10, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 10, Down, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 10, Up, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 10, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f32::INFINITY, 10, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        10,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        10,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        10,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        10,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        10,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f32::NEGATIVE_INFINITY,\n        10,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test_helper(f32::ZERO, 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test_helper(f32::ZERO, 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f32::ZERO, 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test_helper(f32::NEGATIVE_ZERO, 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test_helper(f32::NEGATIVE_ZERO, 10, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 10, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 10, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 10, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 10, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f32::NEGATIVE_ZERO, 10, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test_helper(f32::ONE, 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f32::ONE, 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f32::ONE, 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f32::ONE, 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f32::ONE, 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f32::ONE, 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test_helper(f32::ONE, 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f32::ONE, 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f32::ONE, 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f32::ONE, 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f32::ONE, 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f32::ONE, 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test_helper(1.0f32 / 3.0, 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test_helper(1.0f32 / 3.0, 1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test_helper(1.0f32 / 3.0, 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test_helper(1.0f32 / 3.0, 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test_helper(1.0f32 / 3.0, 1, Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test_helper(1.0f32 / 3.0, 10, Floor, \"0.333\", \"0x0.554#10\", Less);\n    test_helper(1.0f32 / 3.0, 10, Ceiling, \"0.3335\", \"0x0.556#10\", Greater);\n    test_helper(1.0f32 / 3.0, 10, Down, \"0.333\", \"0x0.554#10\", Less);\n    test_helper(1.0f32 / 3.0, 10, Up, \"0.3335\", \"0x0.556#10\", Greater);\n    test_helper(1.0f32 / 3.0, 10, Nearest, \"0.3335\", \"0x0.556#10\", Greater);\n\n    test_helper(std::f32::consts::PI, 1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test_helper(std::f32::consts::PI, 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test_helper(std::f32::consts::PI, 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test_helper(std::f32::consts::PI, 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test_helper(std::f32::consts::PI, 1, Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test_helper(std::f32::consts::PI, 10, Floor, \"3.141\", \"0x3.24#10\", Less);\n    test_helper(\n        std::f32::consts::PI,\n        10,\n        Ceiling,\n        \"3.145\",\n        \"0x3.25#10\",\n        Greater,\n    );\n    test_helper(std::f32::consts::PI, 10, Down, \"3.141\", \"0x3.24#10\", Less);\n    test_helper(std::f32::consts::PI, 10, Up, \"3.145\", \"0x3.25#10\", Greater);\n    test_helper(\n        std::f32::consts::PI,\n        10,\n        Nearest,\n        \"3.141\",\n        \"0x3.24#10\",\n        Less,\n    );\n\n    test_helper(f32::MAX_FINITE, 1, Floor, \"2.0e38\", \"0x8.0E+31#1\", Less);\n    test_helper(\n        f32::MAX_FINITE,\n        1,\n        Ceiling,\n        \"3.0e38\",\n        \"0x1.0E+32#1\",\n        Greater,\n    );\n    test_helper(f32::MAX_FINITE, 1, Down, \"2.0e38\", \"0x8.0E+31#1\", Less);\n    test_helper(f32::MAX_FINITE, 1, Up, \"3.0e38\", \"0x1.0E+32#1\", Greater);\n    test_helper(\n        f32::MAX_FINITE,\n        1,\n        Nearest,\n        \"3.0e38\",\n        \"0x1.0E+32#1\",\n        Greater,\n    );\n\n    test_helper(f32::MAX_FINITE, 10, Floor, \"3.4e38\", \"0xf.fcE+31#10\", Less);\n    test_helper(\n        f32::MAX_FINITE,\n        10,\n        Ceiling,\n        \"3.403e38\",\n        \"0x1.000E+32#10\",\n        Greater,\n    );\n    test_helper(f32::MAX_FINITE, 10, Down, \"3.4e38\", \"0xf.fcE+31#10\", Less);\n    test_helper(\n        f32::MAX_FINITE,\n        10,\n        Up,\n        \"3.403e38\",\n        \"0x1.000E+32#10\",\n        Greater,\n    );\n    test_helper(\n        f32::MAX_FINITE,\n        10,\n        Nearest,\n        \"3.403e38\",\n        \"0x1.000E+32#10\",\n        Greater,\n    );\n\n    test_helper(f32::NEGATIVE_ONE, 1, Floor, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 1, Ceiling, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 1, Down, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 1, Up, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 1, Nearest, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 1, Exact, \"-1.0\", \"-0x1.0#1\", Equal);\n\n    test_helper(f32::NEGATIVE_ONE, 10, Floor, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 10, Ceiling, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 10, Down, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 10, Up, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 10, Nearest, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f32::NEGATIVE_ONE, 10, Exact, \"-1.0\", \"-0x1.000#10\", Equal);\n\n    test_helper(-1.0f32 / 3.0, 1, Floor, \"-0.5\", \"-0x0.8#1\", Less);\n    test_helper(-1.0f32 / 3.0, 1, Ceiling, \"-0.2\", \"-0x0.4#1\", Greater);\n    test_helper(-1.0f32 / 3.0, 1, Down, \"-0.2\", \"-0x0.4#1\", Greater);\n    test_helper(-1.0f32 / 3.0, 1, Up, \"-0.5\", \"-0x0.8#1\", Less);\n    test_helper(-1.0f32 / 3.0, 1, Nearest, \"-0.2\", \"-0x0.4#1\", Greater);\n\n    test_helper(-1.0f32 / 3.0, 10, Floor, \"-0.3335\", \"-0x0.556#10\", Less);\n    test_helper(-1.0f32 / 3.0, 10, Ceiling, \"-0.333\", \"-0x0.554#10\", Greater);\n    test_helper(-1.0f32 / 3.0, 10, Down, \"-0.333\", \"-0x0.554#10\", Greater);\n    test_helper(-1.0f32 / 3.0, 10, Up, \"-0.3335\", \"-0x0.556#10\", Less);\n    test_helper(-1.0f32 / 3.0, 10, Nearest, \"-0.3335\", \"-0x0.556#10\", Less);\n\n    test_helper(-std::f32::consts::PI, 1, Floor, \"-4.0\", \"-0x4.0#1\", Less);\n    test_helper(\n        -std::f32::consts::PI,\n        1,\n        Ceiling,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test_helper(-std::f32::consts::PI, 1, Down, \"-2.0\", \"-0x2.0#1\", Greater);\n    test_helper(-std::f32::consts::PI, 1, Up, \"-4.0\", \"-0x4.0#1\", Less);\n    test_helper(-std::f32::consts::PI, 1, Nearest, \"-4.0\", \"-0x4.0#1\", Less);\n\n    test_helper(\n        -std::f32::consts::PI,\n        10,\n        Floor,\n        \"-3.145\",\n        \"-0x3.25#10\",\n        Less,\n    );\n    test_helper(\n        -std::f32::consts::PI,\n        10,\n        Ceiling,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    test_helper(\n        -std::f32::consts::PI,\n        10,\n        Down,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    test_helper(-std::f32::consts::PI, 10, Up, \"-3.145\", \"-0x3.25#10\", Less);\n    test_helper(\n        -std::f32::consts::PI,\n        10,\n        Nearest,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n\n    test_helper(-f32::MAX_FINITE, 1, Floor, \"-3.0e38\", \"-0x1.0E+32#1\", Less);\n    test_helper(\n        -f32::MAX_FINITE,\n        1,\n        Ceiling,\n        \"-2.0e38\",\n        \"-0x8.0E+31#1\",\n        Greater,\n    );\n    test_helper(\n        -f32::MAX_FINITE,\n        1,\n        Down,\n        \"-2.0e38\",\n        \"-0x8.0E+31#1\",\n        Greater,\n    );\n    test_helper(-f32::MAX_FINITE, 1, Up, \"-3.0e38\", \"-0x1.0E+32#1\", Less);\n    test_helper(\n        -f32::MAX_FINITE,\n        1,\n        Nearest,\n        \"-3.0e38\",\n        \"-0x1.0E+32#1\",\n        Less,\n    );\n\n    test_helper(\n        -f32::MAX_FINITE,\n        10,\n        Floor,\n        \"-3.403e38\",\n        \"-0x1.000E+32#10\",\n        Less,\n    );\n    test_helper(\n        -f32::MAX_FINITE,\n        10,\n        Ceiling,\n        \"-3.4e38\",\n        \"-0xf.fcE+31#10\",\n        Greater,\n    );\n    test_helper(\n        -f32::MAX_FINITE,\n        10,\n        Down,\n        \"-3.4e38\",\n        \"-0xf.fcE+31#10\",\n        Greater,\n    );\n    test_helper(\n        -f32::MAX_FINITE,\n        10,\n        Up,\n        \"-3.403e38\",\n        \"-0x1.000E+32#10\",\n        Less,\n    );\n    test_helper(\n        -f32::MAX_FINITE,\n        10,\n        Nearest,\n        \"-3.403e38\",\n        \"-0x1.000E+32#10\",\n        Less,\n    );\n\n    test_helper(f64::NAN, 1, Floor, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 1, Ceiling, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 1, Down, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 1, Up, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 1, Nearest, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 1, Exact, \"NaN\", \"NaN\", Equal);\n\n    test_helper(f64::NAN, 10, Floor, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 10, Ceiling, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 10, Down, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 10, Up, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 10, Nearest, \"NaN\", \"NaN\", Equal);\n    test_helper(f64::NAN, 10, Exact, \"NaN\", \"NaN\", Equal);\n\n    test_helper(f64::INFINITY, 1, Floor, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 1, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 1, Down, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 1, Up, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 1, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 1, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test_helper(f64::INFINITY, 10, Floor, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 10, Ceiling, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 10, Down, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 10, Up, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 10, Nearest, \"Infinity\", \"Infinity\", Equal);\n    test_helper(f64::INFINITY, 10, Exact, \"Infinity\", \"Infinity\", Equal);\n\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        1,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        1,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        1,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        10,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        10,\n        Ceiling,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        10,\n        Down,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        10,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        10,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n    test_helper(\n        f64::NEGATIVE_INFINITY,\n        10,\n        Exact,\n        \"-Infinity\",\n        \"-Infinity\",\n        Equal,\n    );\n\n    test_helper(f64::ZERO, 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test_helper(f64::ZERO, 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test_helper(f64::ZERO, 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test_helper(f64::NEGATIVE_ZERO, 1, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 1, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 1, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 1, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 1, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 1, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test_helper(f64::NEGATIVE_ZERO, 10, Floor, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 10, Ceiling, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 10, Down, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 10, Up, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 10, Nearest, \"-0.0\", \"-0x0.0\", Equal);\n    test_helper(f64::NEGATIVE_ZERO, 10, Exact, \"-0.0\", \"-0x0.0\", Equal);\n\n    test_helper(f64::ONE, 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f64::ONE, 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f64::ONE, 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f64::ONE, 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f64::ONE, 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test_helper(f64::ONE, 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test_helper(f64::ONE, 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f64::ONE, 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f64::ONE, 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f64::ONE, 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f64::ONE, 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test_helper(f64::ONE, 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test_helper(1.0f64 / 3.0, 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test_helper(1.0f64 / 3.0, 1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test_helper(1.0f64 / 3.0, 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test_helper(1.0f64 / 3.0, 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test_helper(1.0f64 / 3.0, 1, Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test_helper(1.0f64 / 3.0, 10, Floor, \"0.333\", \"0x0.554#10\", Less);\n    test_helper(1.0f64 / 3.0, 10, Ceiling, \"0.3335\", \"0x0.556#10\", Greater);\n    test_helper(1.0f64 / 3.0, 10, Down, \"0.333\", \"0x0.554#10\", Less);\n    test_helper(1.0f64 / 3.0, 10, Up, \"0.3335\", \"0x0.556#10\", Greater);\n    test_helper(1.0f64 / 3.0, 10, Nearest, \"0.3335\", \"0x0.556#10\", Greater);\n\n    test_helper(std::f64::consts::PI, 1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test_helper(std::f64::consts::PI, 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test_helper(std::f64::consts::PI, 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test_helper(std::f64::consts::PI, 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test_helper(std::f64::consts::PI, 1, Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test_helper(std::f64::consts::PI, 10, Floor, \"3.141\", \"0x3.24#10\", Less);\n    test_helper(\n        std::f64::consts::PI,\n        10,\n        Ceiling,\n        \"3.145\",\n        \"0x3.25#10\",\n        Greater,\n    );\n    test_helper(std::f64::consts::PI, 10, Down, \"3.141\", \"0x3.24#10\", Less);\n    test_helper(std::f64::consts::PI, 10, Up, \"3.145\", \"0x3.25#10\", Greater);\n    test_helper(\n        std::f64::consts::PI,\n        10,\n        Nearest,\n        \"3.141\",\n        \"0x3.24#10\",\n        Less,\n    );\n\n    test_helper(f64::MAX_FINITE, 1, Floor, \"9.0e307\", \"0x8.0E+255#1\", Less);\n    test_helper(\n        f64::MAX_FINITE,\n        1,\n        Ceiling,\n        \"2.0e308\",\n        \"0x1.0E+256#1\",\n        Greater,\n    );\n    test_helper(f64::MAX_FINITE, 1, Down, \"9.0e307\", \"0x8.0E+255#1\", Less);\n    test_helper(f64::MAX_FINITE, 1, Up, \"2.0e308\", \"0x1.0E+256#1\", Greater);\n    test_helper(\n        f64::MAX_FINITE,\n        1,\n        Nearest,\n        \"2.0e308\",\n        \"0x1.0E+256#1\",\n        Greater,\n    );\n\n    test_helper(\n        f64::MAX_FINITE,\n        10,\n        Floor,\n        \"1.796e308\",\n        \"0xf.fcE+255#10\",\n        Less,\n    );\n    test_helper(\n        f64::MAX_FINITE,\n        10,\n        Ceiling,\n        \"1.798e308\",\n        \"0x1.000E+256#10\",\n        Greater,\n    );\n    test_helper(\n        f64::MAX_FINITE,\n        10,\n        Down,\n        \"1.796e308\",\n        \"0xf.fcE+255#10\",\n        Less,\n    );\n    test_helper(\n        f64::MAX_FINITE,\n        10,\n        Up,\n        \"1.798e308\",\n        \"0x1.000E+256#10\",\n        Greater,\n    );\n    test_helper(\n        f64::MAX_FINITE,\n        10,\n        Nearest,\n        \"1.798e308\",\n        \"0x1.000E+256#10\",\n        Greater,\n    );\n\n    test_helper(f64::NEGATIVE_ONE, 1, Floor, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 1, Ceiling, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 1, Down, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 1, Up, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 1, Nearest, \"-1.0\", \"-0x1.0#1\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 1, Exact, \"-1.0\", \"-0x1.0#1\", Equal);\n\n    test_helper(f64::NEGATIVE_ONE, 10, Floor, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 10, Ceiling, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 10, Down, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 10, Up, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 10, Nearest, \"-1.0\", \"-0x1.000#10\", Equal);\n    test_helper(f64::NEGATIVE_ONE, 10, Exact, \"-1.0\", \"-0x1.000#10\", Equal);\n\n    test_helper(-1.0f64 / 3.0, 1, Floor, \"-0.5\", \"-0x0.8#1\", Less);\n    test_helper(-1.0f64 / 3.0, 1, Ceiling, \"-0.2\", \"-0x0.4#1\", Greater);\n    test_helper(-1.0f64 / 3.0, 1, Down, \"-0.2\", \"-0x0.4#1\", Greater);\n    test_helper(-1.0f64 / 3.0, 1, Up, \"-0.5\", \"-0x0.8#1\", Less);\n    test_helper(-1.0f64 / 3.0, 1, Nearest, \"-0.2\", \"-0x0.4#1\", Greater);\n\n    test_helper(-1.0f64 / 3.0, 10, Floor, \"-0.3335\", \"-0x0.556#10\", Less);\n    test_helper(-1.0f64 / 3.0, 10, Ceiling, \"-0.333\", \"-0x0.554#10\", Greater);\n    test_helper(-1.0f64 / 3.0, 10, Down, \"-0.333\", \"-0x0.554#10\", Greater);\n    test_helper(-1.0f64 / 3.0, 10, Up, \"-0.3335\", \"-0x0.556#10\", Less);\n    test_helper(-1.0f64 / 3.0, 10, Nearest, \"-0.3335\", \"-0x0.556#10\", Less);\n\n    test_helper(-std::f64::consts::PI, 1, Floor, \"-4.0\", \"-0x4.0#1\", Less);\n    test_helper(\n        -std::f64::consts::PI,\n        1,\n        Ceiling,\n        \"-2.0\",\n        \"-0x2.0#1\",\n        Greater,\n    );\n    test_helper(-std::f64::consts::PI, 1, Down, \"-2.0\", \"-0x2.0#1\", Greater);\n    test_helper(-std::f64::consts::PI, 1, Up, \"-4.0\", \"-0x4.0#1\", Less);\n    test_helper(-std::f64::consts::PI, 1, Nearest, \"-4.0\", \"-0x4.0#1\", Less);\n\n    test_helper(\n        -std::f64::consts::PI,\n        10,\n        Floor,\n        \"-3.145\",\n        \"-0x3.25#10\",\n        Less,\n    );\n    test_helper(\n        -std::f64::consts::PI,\n        10,\n        Ceiling,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    test_helper(\n        -std::f64::consts::PI,\n        10,\n        Down,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n    test_helper(-std::f64::consts::PI, 10, Up, \"-3.145\", \"-0x3.25#10\", Less);\n    test_helper(\n        -std::f64::consts::PI,\n        10,\n        Nearest,\n        \"-3.141\",\n        \"-0x3.24#10\",\n        Greater,\n    );\n\n    test_helper(\n        -f64::MAX_FINITE,\n        1,\n        Floor,\n        \"-2.0e308\",\n        \"-0x1.0E+256#1\",\n        Less,\n    );\n    test_helper(\n        -f64::MAX_FINITE,\n        1,\n        Ceiling,\n        \"-9.0e307\",\n        \"-0x8.0E+255#1\",\n        Greater,\n    );\n    test_helper(\n        -f64::MAX_FINITE,\n        1,\n        Down,\n        \"-9.0e307\",\n        \"-0x8.0E+255#1\",\n        Greater,\n    );\n    test_helper(-f64::MAX_FINITE, 1, Up, \"-2.0e308\", \"-0x1.0E+256#1\", Less);\n    test_helper(\n        -f64::MAX_FINITE,\n        1,\n        Nearest,\n        \"-2.0e308\",\n        \"-0x1.0E+256#1\",\n        Less,\n    );\n\n    test_helper(\n        -f64::MAX_FINITE,\n        10,\n        Floor,\n        \"-1.798e308\",\n        \"-0x1.000E+256#10\",\n        Less,\n    );\n    test_helper(\n        -f64::MAX_FINITE,\n        10,\n        Ceiling,\n        \"-1.796e308\",\n        \"-0xf.fcE+255#10\",\n        Greater,\n    );\n    test_helper(\n        -f64::MAX_FINITE,\n        10,\n        Down,\n        \"-1.796e308\",\n        \"-0xf.fcE+255#10\",\n        Greater,\n    );\n    test_helper(\n        -f64::MAX_FINITE,\n        10,\n        Up,\n        \"-1.798e308\",\n        \"-0x1.000E+256#10\",\n        Less,\n    );\n    test_helper(\n        -f64::MAX_FINITE,\n        10,\n        Nearest,\n        \"-1.798e308\",\n        \"-0x1.000E+256#10\",\n        Less,\n    );\n}\n\nfn from_primitive_float_prec_round_fail_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T>,\n{\n    assert_panic!(Float::from_primitive_float_prec_round(T::NAN, 0, Floor));\n    assert_panic!(Float::from_primitive_float_prec_round(\n        T::INFINITY,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_primitive_float_prec_round(\n        T::NEGATIVE_INFINITY,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_primitive_float_prec_round(T::ZERO, 0, Floor));\n    assert_panic!(Float::from_primitive_float_prec_round(\n        T::NEGATIVE_ZERO,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_primitive_float_prec_round(T::ONE, 0, Floor));\n    assert_panic!(Float::from_primitive_float_prec_round(\n        T::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n\n    assert_panic!(Float::from_primitive_float_prec_round(\n        T::from(1.0f32) / T::from(3.0f32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::from_primitive_float_prec_round(\n        T::from(-1.0f32) / T::from(3.0f32),\n        1,\n        Exact\n    ));\n}\n\n#[test]\nfn from_primitive_float_prec_round_fail() {\n    apply_fn_to_primitive_floats!(from_primitive_float_prec_round_fail_helper);\n}\n\nfn from_primitive_float_prec_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: PartialOrd<T>,\n    Rational: TryFrom<T>,\n    rug::Float: Assign<T>,\n{\n    primitive_float_unsigned_pair_gen_var_4::<T, u64>().test_properties(|(x, prec)| {\n        let (float_x, o) = Float::from_primitive_float_prec(x, prec);\n        assert!(float_x.is_valid());\n\n        assert_eq!(\n            float_x.partial_cmp(&x),\n            if x.is_nan() { None } else { Some(o) }\n        );\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), x);\n        assert_eq!(\n            ComparableFloatRef(&float_x),\n            ComparableFloatRef(&Float::from(&rug_x))\n        );\n\n        if let Ok(r_x) = Rational::try_from(x) {\n            let (float_x_alt, o_alt) = Float::from_rational_prec(r_x, prec);\n            assert_eq!(\n                ComparableFloatRef(&float_x_alt),\n                ComparableFloatRef(&float_x.abs_negative_zero_ref())\n            );\n            assert_eq!(o_alt, o);\n        }\n\n        assert_eq!(\n            float_x.get_prec(),\n            if x.is_finite() && x != T::ZERO {\n                Some(prec)\n            } else {\n                None\n            }\n        );\n\n        let (float_x_alt, o_alt) = Float::from_primitive_float_prec(x, prec);\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o_alt, o);\n\n        let (float_x_alt, o_alt) = Float::from_primitive_float_prec_round(x, prec, Nearest);\n        assert_eq!(ComparableFloat(float_x_alt), ComparableFloat(float_x));\n        assert_eq!(o_alt, o);\n    });\n}\n\n#[test]\nfn from_primitive_float_prec_properties() {\n    apply_fn_to_primitive_floats!(from_primitive_float_prec_properties_helper);\n}\n\nfn from_primitive_float_prec_round_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    Rational: PartialOrd<T> + TryFrom<T>,\n    rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n{\n    primitive_float_unsigned_rounding_mode_triple_gen_var_3::<T>().test_properties(\n        |(x, prec, rm)| {\n            let (float_x, o) = Float::from_primitive_float_prec_round(x, prec, rm);\n            assert!(float_x.is_valid());\n\n            assert_eq!(\n                float_x.partial_cmp(&x),\n                if x.is_nan() { None } else { Some(o) }\n            );\n            match (x >= T::ZERO, rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n\n            if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n                let (rug_x, rug_o) = rug::Float::with_val_round(u32::exact_from(prec), x, rm);\n                let float_x_alt: Float = From::from(&rug_x);\n                assert_eq!(\n                    ComparableFloatRef(&float_x),\n                    ComparableFloatRef(&float_x_alt)\n                );\n                assert_eq!(rug_o, o);\n            }\n\n            if let Ok(r_x) = Rational::try_from(x) {\n                let (float_x_alt, o_alt) = Float::from_rational_prec_round(r_x, prec, rm);\n                assert_eq!(\n                    ComparableFloatRef(&float_x_alt),\n                    ComparableFloatRef(&float_x.abs_negative_zero_ref())\n                );\n                assert_eq!(o_alt, o);\n            }\n\n            assert_eq!(\n                float_x.get_prec(),\n                if x.is_finite() && x != T::ZERO {\n                    Some(prec)\n                } else {\n                    None\n                }\n            );\n        },\n    );\n\n    primitive_float_unsigned_pair_gen_var_4::<T, u64>().test_properties(|(x, prec)| {\n        let floor = Float::from_primitive_float_prec_round(x, prec, Floor);\n        if x.is_nan() {\n            assert!(floor.0.is_nan());\n        } else {\n            let or_floor: Result<Rational, _> = TryFrom::try_from(&floor.0);\n            if let Ok(r_floor) = or_floor {\n                assert!(r_floor <= x);\n                if r_floor != T::ZERO {\n                    let rulp: Rational = ExactFrom::exact_from(floor.0.ulp().unwrap());\n                    assert!(r_floor + rulp > x);\n                }\n                let (floor_x_alt, o_alt) = Float::from_primitive_float_prec_round(\n                    x,\n                    prec,\n                    if x >= T::ZERO { Down } else { Up },\n                );\n                assert_eq!(\n                    ComparableFloatRef(&floor_x_alt),\n                    ComparableFloatRef(&floor.0)\n                );\n                assert_eq!(o_alt, floor.1);\n            }\n        }\n\n        let ceiling = Float::from_primitive_float_prec_round(x, prec, Ceiling);\n        if x.is_nan() {\n            assert!(ceiling.0.is_nan());\n        } else {\n            let or_ceiling: Result<Rational, _> = TryFrom::try_from(&ceiling.0);\n            if let Ok(r_ceiling) = or_ceiling {\n                assert!(r_ceiling >= x);\n                if r_ceiling != T::ZERO {\n                    let rulp: Rational = ExactFrom::exact_from(ceiling.0.ulp().unwrap());\n                    assert!(r_ceiling - rulp < x);\n                }\n                let (ceiling_x_alt, o_alt) = Float::from_primitive_float_prec_round(\n                    x,\n                    prec,\n                    if x >= T::ZERO { Up } else { Down },\n                );\n                assert_eq!(\n                    ComparableFloatRef(&ceiling_x_alt),\n                    ComparableFloatRef(&ceiling.0)\n                );\n                assert_eq!(o_alt, ceiling.1);\n            }\n        }\n\n        let nearest = Float::from_primitive_float_prec_round(x, prec, Nearest);\n        assert!(\n            ComparableFloatRef(&nearest.0) == ComparableFloatRef(&floor.0) && nearest.1 == floor.1\n                || ComparableFloatRef(&nearest.0) == ComparableFloatRef(&ceiling.0)\n                    && nearest.1 == ceiling.1\n        );\n        let or_nearest: Result<Rational, _> = TryFrom::try_from(&nearest.0);\n        if let Ok(r_nearest) = or_nearest\n            && r_nearest != T::ZERO\n        {\n            let rulp: Rational = ExactFrom::exact_from(nearest.0.ulp().unwrap());\n            assert!((r_nearest - Rational::exact_from(x)).le_abs(&(rulp >> 1)));\n        }\n    });\n}\n\n#[test]\nfn from_primitive_float_prec_round_properties() {\n    apply_fn_to_primitive_floats!(from_primitive_float_prec_round_properties_helper);\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn from_primitive_float_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T>,\n    rug::Float: Assign<T>,\n    for<'a> T: ExactFrom<&'a Float>,\n{\n    primitive_float_gen::<T>().test_properties(|x| {\n        let float_x = Float::from(x);\n        assert!(float_x.is_valid());\n\n        let expected_prec = if !x.is_finite() || x == T::ZERO {\n            None\n        } else {\n            let n = x.integer_mantissa();\n            Some(n.significant_bits() - TrailingZeros::trailing_zeros(n))\n        };\n        let rug_x = rug::Float::with_val(expected_prec.map_or(1, u32::exact_from), x);\n        assert_eq!(\n            ComparableFloatRef(&float_x),\n            ComparableFloatRef(&From::<&rug::Float>::from(&rug_x))\n        );\n\n        assert_eq!(float_x.get_prec(), expected_prec);\n        assert_eq!(NiceFloat(T::exact_from(&float_x)), NiceFloat(x));\n        let (f, o) = Float::from_primitive_float_prec(x, expected_prec.unwrap_or(1));\n        assert_eq!(ComparableFloat(f), ComparableFloat(float_x));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[test]\nfn from_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(from_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, signed_pair_gen_var_2, signed_unsigned_pair_gen_var_20,\n    unsigned_gen, unsigned_pair_gen_var_32, unsigned_signed_pair_gen_var_1,\n};\nuse malachite_float::test_util::common::{rug_round_try_from_rounding_mode, to_hex_string};\nuse malachite_float::test_util::generators::*;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_q::Rational;\nuse rug::Assign;\nuse rug::float::Round;\nuse rug::ops::AssignRound;\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_from_primitive_int() {\n    fn test_helper<T: PrimitiveInt>(u: T, out: &str, out_hex: &str)\n    where\n        Float: From<T>,\n        rug::Float: Assign<T>,\n        Limb: WrappingFrom<T>,\n        SignedLimb: WrappingFrom<T>,\n    {\n        let x = Float::from(u);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        let rug_x = rug::Float::with_val(\n            if u == T::ZERO {\n                1\n            } else {\n                u32::exact_from(u.significant_bits() - TrailingZeros::trailing_zeros(u))\n            },\n            u,\n        );\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        if T::NAME == Limb::NAME {\n            let x_alt = Float::const_from_unsigned(Limb::wrapping_from(u));\n            assert!(x_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&x_alt), ComparableFloatRef(&x));\n        }\n\n        if T::NAME == SignedLimb::NAME {\n            let x_alt = Float::const_from_signed(SignedLimb::wrapping_from(u));\n            assert!(x_alt.is_valid());\n            assert_eq!(ComparableFloat(x_alt), ComparableFloat(x));\n        }\n    }\n    fn test_helper_ui<T: PrimitiveInt>()\n    where\n        Float: From<T>,\n        rug::Float: Assign<T>,\n        Limb: WrappingFrom<T>,\n        SignedLimb: WrappingFrom<T>,\n    {\n        test_helper(T::ZERO, \"0.0\", \"0x0.0\");\n        test_helper(T::ONE, \"1.0\", \"0x1.0#1\");\n        test_helper(T::exact_from(123u8), \"123.0\", \"0x7b.0#7\");\n    }\n    apply_fn_to_primitive_ints!(test_helper_ui);\n    test_helper(1000000000000u64, \"1.0e12\", \"0xe.8d4a51E+9#28\");\n\n    fn test_helper_i<T: PrimitiveSigned>()\n    where\n        Float: From<T>,\n        rug::Float: Assign<T>,\n        Limb: WrappingFrom<T>,\n        SignedLimb: WrappingFrom<T>,\n    {\n        test_helper(T::NEGATIVE_ONE, \"-1.0\", \"-0x1.0#1\");\n        test_helper(T::from(-123i8), \"-123.0\", \"-0x7b.0#7\");\n    }\n    apply_fn_to_signeds!(test_helper_i);\n    test_helper(-1000000000000i64, \"-1.0e12\", \"-0xe.8d4a51E+9#28\");\n}\n\n#[test]\nfn test_from_primitive_int_prec() {\n    fn test_helper_u<T: PrimitiveUnsigned>(\n        u: T,\n        prec: u64,\n        out: &str,\n        out_hex: &str,\n        out_o: Ordering,\n    ) where\n        Natural: From<T>,\n        rug::Float: Assign<T>,\n    {\n        let (x, o) = Float::from_unsigned_prec(u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), u);\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    }\n    fn test_helper_u2<T: PrimitiveUnsigned>()\n    where\n        Natural: From<T>,\n        rug::Float: Assign<T>,\n    {\n        test_helper_u(T::ZERO, 1, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 10, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 20, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_u(T::ONE, 1, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_u(T::ONE, 10, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_u(T::ONE, 20, \"1.0\", \"0x1.00000#20\", Equal);\n\n        test_helper_u(T::from(123u8), 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n        test_helper_u(T::from(123u8), 10, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_u(T::from(123u8), 20, \"123.0\", \"0x7b.0000#20\", Equal);\n    }\n    apply_fn_to_unsigneds!(test_helper_u2);\n    test_helper_u(1000000000000u64, 1, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test_helper_u(1000000000000u64, 10, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test_helper_u(1000000000000u64, 20, \"9.999997e11\", \"0xe.8d4aE+9#20\", Less);\n\n    fn test_helper_i<T: PrimitiveSigned>(u: T, prec: u64, out: &str, out_hex: &str, out_o: Ordering)\n    where\n        Integer: From<T>,\n        rug::Float: Assign<T>,\n    {\n        let (x, o) = Float::from_signed_prec(u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), u);\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    }\n    fn test_helper_i2<T: PrimitiveSigned>()\n    where\n        Integer: From<T>,\n        rug::Float: Assign<T>,\n    {\n        test_helper_i(T::ZERO, 1, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 10, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 20, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_i(T::ONE, 1, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_i(T::ONE, 10, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_i(T::ONE, 20, \"1.0\", \"0x1.00000#20\", Equal);\n\n        test_helper_i(T::from(123i8), 1, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n        test_helper_i(T::from(123i8), 10, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_i(T::from(123i8), 20, \"123.0\", \"0x7b.0000#20\", Equal);\n\n        test_helper_i(T::NEGATIVE_ONE, 1, \"-1.0\", \"-0x1.0#1\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 10, \"-1.0\", \"-0x1.000#10\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 20, \"-1.0\", \"-0x1.00000#20\", Equal);\n\n        test_helper_i(T::from(-123i8), 1, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n        test_helper_i(T::from(-123i8), 10, \"-123.0\", \"-0x7b.0#10\", Equal);\n        test_helper_i(T::from(-123i8), 20, \"-123.0\", \"-0x7b.0000#20\", Equal);\n    }\n    apply_fn_to_signeds!(test_helper_i2);\n    test_helper_i(1000000000000i64, 1, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test_helper_i(1000000000000i64, 10, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test_helper_i(1000000000000i64, 20, \"9.999997e11\", \"0xe.8d4aE+9#20\", Less);\n    test_helper_i(-1000000000000i64, 1, \"-1.0e12\", \"-0x1.0E+10#1\", Less);\n    test_helper_i(-1000000000000i64, 10, \"-9.997e11\", \"-0xe.8cE+9#10\", Greater);\n    test_helper_i(\n        -1000000000000i64,\n        20,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n}\n\nfn from_unsigned_prec_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n{\n    assert_panic!(Float::from_unsigned_prec(T::ZERO, 0));\n    assert_panic!(Float::from_unsigned_prec(T::ONE, 0));\n}\n\nfn from_signed_prec_fail_helper<T: PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n{\n    assert_panic!(Float::from_signed_prec(T::ZERO, 0));\n    assert_panic!(Float::from_signed_prec(T::ONE, 0));\n    assert_panic!(Float::from_signed_prec(T::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn from_primitive_int_prec_fail() {\n    apply_fn_to_unsigneds!(from_unsigned_prec_fail_helper);\n    apply_fn_to_signeds!(from_signed_prec_fail_helper);\n}\n\n#[test]\nfn test_from_primitive_int_prec_round() {\n    fn test_helper_u<T: PrimitiveUnsigned>(\n        u: T,\n        prec: u64,\n        rm: RoundingMode,\n        out: &str,\n        out_hex: &str,\n        out_o: Ordering,\n    ) where\n        Natural: From<T>,\n        rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n    {\n        let (x, o) = Float::from_unsigned_prec_round(u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, rug_o) = rug::Float::with_val_round(u32::exact_from(prec), u, rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(rug_o, out_o);\n        }\n    }\n    fn test_helper_u2<T: PrimitiveUnsigned>()\n    where\n        Natural: From<T>,\n        rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n    {\n        test_helper_u(T::ZERO, 1, Floor, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 1, Down, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 1, Up, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_u(T::ZERO, 10, Floor, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 10, Down, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 10, Up, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_u(T::ZERO, 20, Floor, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 20, Ceiling, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 20, Down, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 20, Up, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 20, Nearest, \"0.0\", \"0x0.0\", Equal);\n        test_helper_u(T::ZERO, 20, Exact, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_u(T::ONE, 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_u(T::ONE, 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_u(T::ONE, 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_u(T::ONE, 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_u(T::ONE, 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_u(T::ONE, 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n        test_helper_u(T::ONE, 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_u(T::ONE, 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_u(T::ONE, 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_u(T::ONE, 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_u(T::ONE, 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_u(T::ONE, 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n        test_helper_u(T::ONE, 20, Floor, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_u(T::ONE, 20, Ceiling, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_u(T::ONE, 20, Down, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_u(T::ONE, 20, Up, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_u(T::ONE, 20, Nearest, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_u(T::ONE, 20, Exact, \"1.0\", \"0x1.00000#20\", Equal);\n\n        test_helper_u(T::from(123u8), 1, Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n        test_helper_u(T::from(123u8), 1, Ceiling, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n        test_helper_u(T::from(123u8), 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n        test_helper_u(T::from(123u8), 1, Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n        test_helper_u(T::from(123u8), 1, Nearest, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n\n        test_helper_u(T::from(123u8), 10, Floor, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_u(T::from(123u8), 10, Ceiling, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_u(T::from(123u8), 10, Down, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_u(T::from(123u8), 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_u(T::from(123u8), 10, Nearest, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_u(T::from(123u8), 10, Exact, \"123.0\", \"0x7b.0#10\", Equal);\n\n        test_helper_u(T::from(123u8), 20, Floor, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_u(T::from(123u8), 20, Ceiling, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_u(T::from(123u8), 20, Down, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_u(T::from(123u8), 20, Up, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_u(T::from(123u8), 20, Nearest, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_u(T::from(123u8), 20, Exact, \"123.0\", \"0x7b.0000#20\", Equal);\n    }\n    apply_fn_to_unsigneds!(test_helper_u2);\n    test_helper_u(1000000000000u64, 1, Floor, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test_helper_u(\n        1000000000000u64,\n        1,\n        Ceiling,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n    test_helper_u(1000000000000u64, 1, Down, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test_helper_u(1000000000000u64, 1, Up, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test_helper_u(\n        1000000000000u64,\n        1,\n        Nearest,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n\n    test_helper_u(\n        1000000000000u64,\n        10,\n        Floor,\n        \"9.997e11\",\n        \"0xe.8cE+9#10\",\n        Less,\n    );\n    test_helper_u(\n        1000000000000u64,\n        10,\n        Ceiling,\n        \"1.001e12\",\n        \"0xe.90E+9#10\",\n        Greater,\n    );\n    test_helper_u(1000000000000u64, 10, Down, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test_helper_u(\n        1000000000000u64,\n        10,\n        Up,\n        \"1.001e12\",\n        \"0xe.90E+9#10\",\n        Greater,\n    );\n    test_helper_u(\n        1000000000000u64,\n        10,\n        Nearest,\n        \"9.997e11\",\n        \"0xe.8cE+9#10\",\n        Less,\n    );\n\n    test_helper_u(\n        1000000000000u64,\n        20,\n        Floor,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test_helper_u(\n        1000000000000u64,\n        20,\n        Ceiling,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test_helper_u(\n        1000000000000u64,\n        20,\n        Down,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test_helper_u(\n        1000000000000u64,\n        20,\n        Up,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test_helper_u(\n        1000000000000u64,\n        20,\n        Nearest,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n\n    fn test_helper_i<T: PrimitiveSigned>(\n        u: T,\n        prec: u64,\n        rm: RoundingMode,\n        out: &str,\n        out_hex: &str,\n        out_o: Ordering,\n    ) where\n        Integer: From<T>,\n        rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n    {\n        let (x, o) = Float::from_signed_prec_round(u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, rug_o) = rug::Float::with_val_round(u32::exact_from(prec), u, rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(rug_o, out_o);\n        }\n    }\n    fn test_helper_i2<T: PrimitiveSigned>()\n    where\n        Integer: From<T>,\n        rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n    {\n        test_helper_i(T::ZERO, 1, Floor, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 1, Down, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 1, Up, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_i(T::ZERO, 10, Floor, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 10, Down, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 10, Up, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_i(T::ZERO, 20, Floor, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 20, Ceiling, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 20, Down, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 20, Up, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 20, Nearest, \"0.0\", \"0x0.0\", Equal);\n        test_helper_i(T::ZERO, 20, Exact, \"0.0\", \"0x0.0\", Equal);\n\n        test_helper_i(T::ONE, 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_i(T::ONE, 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_i(T::ONE, 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_i(T::ONE, 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_i(T::ONE, 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n        test_helper_i(T::ONE, 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n        test_helper_i(T::ONE, 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_i(T::ONE, 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_i(T::ONE, 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_i(T::ONE, 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_i(T::ONE, 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n        test_helper_i(T::ONE, 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n        test_helper_i(T::ONE, 20, Floor, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_i(T::ONE, 20, Ceiling, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_i(T::ONE, 20, Down, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_i(T::ONE, 20, Up, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_i(T::ONE, 20, Nearest, \"1.0\", \"0x1.00000#20\", Equal);\n        test_helper_i(T::ONE, 20, Exact, \"1.0\", \"0x1.00000#20\", Equal);\n\n        test_helper_i(T::from(123i8), 1, Floor, \"6.0e1\", \"0x4.0E+1#1\", Less);\n        test_helper_i(T::from(123i8), 1, Ceiling, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n        test_helper_i(T::from(123i8), 1, Down, \"6.0e1\", \"0x4.0E+1#1\", Less);\n        test_helper_i(T::from(123i8), 1, Up, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n        test_helper_i(T::from(123i8), 1, Nearest, \"1.0e2\", \"0x8.0E+1#1\", Greater);\n\n        test_helper_i(T::from(123i8), 10, Floor, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_i(T::from(123i8), 10, Ceiling, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_i(T::from(123i8), 10, Down, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_i(T::from(123i8), 10, Up, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_i(T::from(123i8), 10, Nearest, \"123.0\", \"0x7b.0#10\", Equal);\n        test_helper_i(T::from(123i8), 10, Exact, \"123.0\", \"0x7b.0#10\", Equal);\n\n        test_helper_i(T::from(123i8), 20, Floor, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_i(T::from(123i8), 20, Ceiling, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_i(T::from(123i8), 20, Down, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_i(T::from(123i8), 20, Up, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_i(T::from(123i8), 20, Nearest, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_i(T::from(123i8), 20, Exact, \"123.0\", \"0x7b.0000#20\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 1, Floor, \"-1.0\", \"-0x1.0#1\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 1, Ceiling, \"-1.0\", \"-0x1.0#1\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 1, Down, \"-1.0\", \"-0x1.0#1\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 1, Up, \"-1.0\", \"-0x1.0#1\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 1, Nearest, \"-1.0\", \"-0x1.0#1\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 1, Exact, \"-1.0\", \"-0x1.0#1\", Equal);\n\n        test_helper_i(T::NEGATIVE_ONE, 10, Floor, \"-1.0\", \"-0x1.000#10\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 10, Ceiling, \"-1.0\", \"-0x1.000#10\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 10, Down, \"-1.0\", \"-0x1.000#10\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 10, Up, \"-1.0\", \"-0x1.000#10\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 10, Nearest, \"-1.0\", \"-0x1.000#10\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 10, Exact, \"-1.0\", \"-0x1.000#10\", Equal);\n\n        test_helper_i(T::NEGATIVE_ONE, 20, Floor, \"-1.0\", \"-0x1.00000#20\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 20, Ceiling, \"-1.0\", \"-0x1.00000#20\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 20, Down, \"-1.0\", \"-0x1.00000#20\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 20, Up, \"-1.0\", \"-0x1.00000#20\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 20, Nearest, \"-1.0\", \"-0x1.00000#20\", Equal);\n        test_helper_i(T::NEGATIVE_ONE, 20, Exact, \"-1.0\", \"-0x1.00000#20\", Equal);\n\n        test_helper_i(T::from(-123i8), 1, Floor, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n        test_helper_i(\n            T::from(-123i8),\n            1,\n            Ceiling,\n            \"-6.0e1\",\n            \"-0x4.0E+1#1\",\n            Greater,\n        );\n        test_helper_i(T::from(-123i8), 1, Down, \"-6.0e1\", \"-0x4.0E+1#1\", Greater);\n        test_helper_i(T::from(-123i8), 1, Up, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n        test_helper_i(T::from(-123i8), 1, Nearest, \"-1.0e2\", \"-0x8.0E+1#1\", Less);\n\n        test_helper_i(T::from(-123i8), 10, Floor, \"-123.0\", \"-0x7b.0#10\", Equal);\n        test_helper_i(T::from(-123i8), 10, Ceiling, \"-123.0\", \"-0x7b.0#10\", Equal);\n        test_helper_i(T::from(-123i8), 10, Down, \"-123.0\", \"-0x7b.0#10\", Equal);\n        test_helper_i(T::from(-123i8), 10, Up, \"-123.0\", \"-0x7b.0#10\", Equal);\n        test_helper_i(T::from(-123i8), 10, Nearest, \"-123.0\", \"-0x7b.0#10\", Equal);\n        test_helper_i(T::from(-123i8), 10, Exact, \"-123.0\", \"-0x7b.0#10\", Equal);\n\n        test_helper_i(T::from(-123i8), 20, Floor, \"-123.0\", \"-0x7b.0000#20\", Equal);\n        test_helper_i(\n            T::from(-123i8),\n            20,\n            Ceiling,\n            \"-123.0\",\n            \"-0x7b.0000#20\",\n            Equal,\n        );\n        test_helper_i(T::from(-123i8), 20, Down, \"-123.0\", \"-0x7b.0000#20\", Equal);\n        test_helper_i(T::from(-123i8), 20, Up, \"-123.0\", \"-0x7b.0000#20\", Equal);\n        test_helper_i(\n            T::from(-123i8),\n            20,\n            Nearest,\n            \"-123.0\",\n            \"-0x7b.0000#20\",\n            Equal,\n        );\n        test_helper_i(T::from(-123i8), 20, Exact, \"-123.0\", \"-0x7b.0000#20\", Equal);\n    }\n    apply_fn_to_signeds!(test_helper_i2);\n    test_helper_i(1000000000000i64, 1, Floor, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test_helper_i(\n        1000000000000i64,\n        1,\n        Ceiling,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n    test_helper_i(1000000000000i64, 1, Down, \"5.0e11\", \"0x8.0E+9#1\", Less);\n    test_helper_i(1000000000000i64, 1, Up, \"1.0e12\", \"0x1.0E+10#1\", Greater);\n    test_helper_i(\n        1000000000000i64,\n        1,\n        Nearest,\n        \"1.0e12\",\n        \"0x1.0E+10#1\",\n        Greater,\n    );\n\n    test_helper_i(\n        1000000000000i64,\n        10,\n        Floor,\n        \"9.997e11\",\n        \"0xe.8cE+9#10\",\n        Less,\n    );\n    test_helper_i(\n        1000000000000i64,\n        10,\n        Ceiling,\n        \"1.001e12\",\n        \"0xe.90E+9#10\",\n        Greater,\n    );\n    test_helper_i(1000000000000i64, 10, Down, \"9.997e11\", \"0xe.8cE+9#10\", Less);\n    test_helper_i(\n        1000000000000i64,\n        10,\n        Up,\n        \"1.001e12\",\n        \"0xe.90E+9#10\",\n        Greater,\n    );\n    test_helper_i(\n        1000000000000i64,\n        10,\n        Nearest,\n        \"9.997e11\",\n        \"0xe.8cE+9#10\",\n        Less,\n    );\n\n    test_helper_i(\n        1000000000000i64,\n        20,\n        Floor,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test_helper_i(\n        1000000000000i64,\n        20,\n        Ceiling,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test_helper_i(\n        1000000000000i64,\n        20,\n        Down,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test_helper_i(\n        1000000000000i64,\n        20,\n        Up,\n        \"1.000001e12\",\n        \"0xe.8d4bE+9#20\",\n        Greater,\n    );\n    test_helper_i(\n        1000000000000i64,\n        20,\n        Nearest,\n        \"9.999997e11\",\n        \"0xe.8d4aE+9#20\",\n        Less,\n    );\n    test_helper_i(-1000000000000i64, 1, Floor, \"-1.0e12\", \"-0x1.0E+10#1\", Less);\n    test_helper_i(\n        -1000000000000i64,\n        1,\n        Ceiling,\n        \"-5.0e11\",\n        \"-0x8.0E+9#1\",\n        Greater,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        1,\n        Down,\n        \"-5.0e11\",\n        \"-0x8.0E+9#1\",\n        Greater,\n    );\n    test_helper_i(-1000000000000i64, 1, Up, \"-1.0e12\", \"-0x1.0E+10#1\", Less);\n    test_helper_i(\n        -1000000000000i64,\n        1,\n        Nearest,\n        \"-1.0e12\",\n        \"-0x1.0E+10#1\",\n        Less,\n    );\n\n    test_helper_i(\n        -1000000000000i64,\n        10,\n        Floor,\n        \"-1.001e12\",\n        \"-0xe.90E+9#10\",\n        Less,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        10,\n        Ceiling,\n        \"-9.997e11\",\n        \"-0xe.8cE+9#10\",\n        Greater,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        10,\n        Down,\n        \"-9.997e11\",\n        \"-0xe.8cE+9#10\",\n        Greater,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        10,\n        Up,\n        \"-1.001e12\",\n        \"-0xe.90E+9#10\",\n        Less,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        10,\n        Nearest,\n        \"-9.997e11\",\n        \"-0xe.8cE+9#10\",\n        Greater,\n    );\n\n    test_helper_i(\n        -1000000000000i64,\n        20,\n        Floor,\n        \"-1.000001e12\",\n        \"-0xe.8d4bE+9#20\",\n        Less,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        20,\n        Ceiling,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        20,\n        Down,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        20,\n        Up,\n        \"-1.000001e12\",\n        \"-0xe.8d4bE+9#20\",\n        Less,\n    );\n    test_helper_i(\n        -1000000000000i64,\n        20,\n        Nearest,\n        \"-9.999997e11\",\n        \"-0xe.8d4aE+9#20\",\n        Greater,\n    );\n}\n\nfn from_unsigned_prec_round_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n{\n    assert_panic!(Float::from_unsigned_prec_round(T::ZERO, 0, Floor));\n    assert_panic!(Float::from_unsigned_prec_round(T::ONE, 0, Floor));\n    assert_panic!(Float::from_unsigned_prec_round(T::from(123u8), 1, Exact));\n}\n\nfn from_signed_prec_round_fail_helper<T: PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n{\n    assert_panic!(Float::from_signed_prec_round(T::ZERO, 0, Floor));\n    assert_panic!(Float::from_signed_prec_round(T::ONE, 0, Floor));\n    assert_panic!(Float::from_signed_prec_round(T::from(123i8), 1, Exact));\n    assert_panic!(Float::from_signed_prec_round(T::NEGATIVE_ONE, 0, Floor));\n    assert_panic!(Float::from_signed_prec_round(T::from(-123i8), 1, Exact));\n}\n\n#[test]\nfn from_primitive_int_prec_round_fail() {\n    apply_fn_to_unsigneds!(from_unsigned_prec_round_fail_helper);\n    apply_fn_to_signeds!(from_signed_prec_round_fail_helper);\n}\n\n#[test]\nfn test_const_from_unsigned_times_power_of_2() {\n    fn test_helper(u: Limb, pow: i32, out: &str, out_hex: &str) {\n        let x = Float::const_from_unsigned_times_power_of_2(u, pow);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    }\n    test_helper(0, 0, \"0.0\", \"0x0.0\");\n    test_helper(0, 10, \"0.0\", \"0x0.0\");\n    test_helper(0, -10, \"0.0\", \"0x0.0\");\n    test_helper(1, 0, \"1.0\", \"0x1.0#1\");\n    test_helper(1, 10, \"1.0e3\", \"0x4.0E+2#1\");\n    test_helper(1, -10, \"0.001\", \"0x0.004#1\");\n    test_helper(1, 1073741822, \"too_big\", \"0x4.0E+268435455#1\");\n    test_helper(1, -1073741824, \"too_small\", \"0x1.0E-268435456#1\");\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test_helper(\n            884279719003555,\n            -48,\n            \"3.141592653589793\",\n            \"0x3.243f6a8885a3#50\",\n        );\n    }\n}\n\n#[test]\nfn const_from_unsigned_times_power_of_2_fail() {\n    assert_panic!(Float::const_from_unsigned_times_power_of_2(1, 1073741823));\n    assert_panic!(Float::const_from_unsigned_times_power_of_2(1, -1073741825));\n}\n\n#[test]\nfn test_const_from_signed_times_power_of_2() {\n    fn test_helper(u: SignedLimb, pow: i32, out: &str, out_hex: &str) {\n        let x = Float::const_from_signed_times_power_of_2(u, pow);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n    }\n    test_helper(0, 0, \"0.0\", \"0x0.0\");\n    test_helper(0, 10, \"0.0\", \"0x0.0\");\n    test_helper(0, -10, \"0.0\", \"0x0.0\");\n    test_helper(1, 0, \"1.0\", \"0x1.0#1\");\n    test_helper(1, 10, \"1.0e3\", \"0x4.0E+2#1\");\n    test_helper(1, -10, \"0.001\", \"0x0.004#1\");\n    test_helper(-1, 0, \"-1.0\", \"-0x1.0#1\");\n    test_helper(-1, 10, \"-1.0e3\", \"-0x4.0E+2#1\");\n    test_helper(-1, -10, \"-0.001\", \"-0x0.004#1\");\n    test_helper(1, 1073741822, \"too_big\", \"0x4.0E+268435455#1\");\n    test_helper(1, -1073741824, \"too_small\", \"0x1.0E-268435456#1\");\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test_helper(\n            884279719003555,\n            -48,\n            \"3.141592653589793\",\n            \"0x3.243f6a8885a3#50\",\n        );\n        test_helper(\n            -884279719003555,\n            -48,\n            \"-3.141592653589793\",\n            \"-0x3.243f6a8885a3#50\",\n        );\n    }\n}\n\n#[test]\nfn const_from_signed_times_power_of_2_fail() {\n    assert_panic!(Float::const_from_signed_times_power_of_2(1, 1073741823));\n    assert_panic!(Float::const_from_signed_times_power_of_2(1, -1073741825));\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn from_primitive_int_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    Float: From<T>,\n    rug::Float: Assign<T>,\n    Natural: From<T> + PartialEq<T>,\n    for<'a> T: ExactFrom<&'a Float>,\n    Limb: WrappingFrom<T>,\n{\n    unsigned_gen::<T>().test_properties(|n| {\n        let float_n = Float::from(n);\n        assert!(float_n.is_valid());\n\n        if T::WIDTH == Limb::WIDTH {\n            let n_alt = Float::const_from_unsigned(Limb::wrapping_from(n));\n            assert!(n_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&n_alt), ComparableFloatRef(&float_n));\n\n            let n_alt = Float::const_from_unsigned_times_power_of_2(Limb::wrapping_from(n), 0);\n            assert!(n_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&n_alt), ComparableFloatRef(&float_n));\n        }\n\n        let expected_prec = if n == T::ZERO {\n            None\n        } else {\n            Some(n.significant_bits() - TrailingZeros::trailing_zeros(n))\n        };\n        let rug_n = rug::Float::with_val(expected_prec.map_or(1, u32::exact_from), n);\n        assert_eq!(\n            ComparableFloatRef(&float_n),\n            ComparableFloatRef(&From::<&rug::Float>::from(&rug_n))\n        );\n\n        let n_alt: Float = ExactFrom::exact_from(Natural::exact_from(n));\n        assert_eq!(ComparableFloatRef(&n_alt), ComparableFloatRef(&float_n));\n\n        assert_eq!(float_n.get_prec(), expected_prec);\n        assert_eq!(T::exact_from(&float_n), n);\n        let (f, o) = Float::from_unsigned_prec(n, expected_prec.unwrap_or(1));\n        assert_eq!(ComparableFloat(f), ComparableFloat(float_n));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn from_primitive_int_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    Float: From<T>,\n    rug::Float: Assign<T>,\n    Integer: From<T> + PartialEq<T>,\n    for<'a> T: ExactFrom<&'a Float>,\n    SignedLimb: WrappingFrom<T>,\n{\n    signed_gen::<T>().test_properties(|n| {\n        let float_n = Float::from(n);\n        assert!(float_n.is_valid());\n\n        if T::WIDTH == SignedLimb::WIDTH {\n            let n_alt = Float::const_from_signed(SignedLimb::wrapping_from(n));\n            assert!(n_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&n_alt), ComparableFloatRef(&float_n));\n\n            let n_alt = Float::const_from_signed_times_power_of_2(SignedLimb::wrapping_from(n), 0);\n            assert!(n_alt.is_valid());\n            assert_eq!(ComparableFloatRef(&n_alt), ComparableFloatRef(&float_n));\n        }\n\n        let expected_prec = if n == T::ZERO {\n            None\n        } else {\n            Some(n.significant_bits() - TrailingZeros::trailing_zeros(n))\n        };\n        let rug_n = rug::Float::with_val(expected_prec.map_or(1, u32::exact_from), n);\n        assert_eq!(\n            ComparableFloatRef(&float_n),\n            ComparableFloatRef(&From::<&rug::Float>::from(&rug_n))\n        );\n\n        let n_alt: Float = ExactFrom::exact_from(Integer::from(n));\n        assert_eq!(ComparableFloatRef(&n_alt), ComparableFloatRef(&float_n));\n\n        assert_eq!(float_n.get_prec(), expected_prec);\n        assert_eq!(T::exact_from(&float_n), n);\n        let (f, o) = Float::from_signed_prec(n, expected_prec.unwrap_or(1));\n        assert_eq!(ComparableFloat(f), ComparableFloat(float_n));\n        assert_eq!(o, Equal);\n    });\n}\n\n#[test]\nfn from_primitive_int_properties() {\n    apply_fn_to_unsigneds!(from_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(from_primitive_int_properties_helper_signed);\n}\n\nfn from_primitive_int_prec_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n    Float: PartialOrd<T>,\n    rug::Float: Assign<T>,\n{\n    unsigned_pair_gen_var_32::<T, u64>().test_properties(|(n, prec)| {\n        let (float_n, o) = Float::from_unsigned_prec(n, prec);\n        assert!(float_n.is_valid());\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n\n        let rug_n = rug::Float::with_val(u32::exact_from(prec), n);\n        assert_eq!(\n            ComparableFloatRef(&float_n),\n            ComparableFloatRef(&Float::from(&rug_n))\n        );\n\n        let (float_n_alt, o_alt) = Float::from_natural_prec(Natural::from(n), prec);\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o_alt, o);\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == T::ZERO { None } else { Some(prec) }\n        );\n    });\n}\n\nfn from_primitive_int_prec_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n    Float: PartialOrd<T>,\n    rug::Float: Assign<T>,\n{\n    signed_unsigned_pair_gen_var_20::<T, u64>().test_properties(|(n, prec)| {\n        let (float_n, o) = Float::from_signed_prec(n, prec);\n        assert!(float_n.is_valid());\n\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n\n        let rug_n = rug::Float::with_val(u32::exact_from(prec), n);\n        assert_eq!(\n            ComparableFloatRef(&float_n),\n            ComparableFloatRef(&Float::from(&rug_n))\n        );\n\n        let (float_n_alt, o_alt) = Float::from_integer_prec(Integer::from(n), prec);\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o_alt, o);\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == T::ZERO { None } else { Some(prec) }\n        );\n    });\n}\n\n#[test]\nfn from_primitive_int_prec_properties() {\n    apply_fn_to_unsigneds!(from_primitive_int_prec_properties_helper_unsigned);\n    apply_fn_to_signeds!(from_primitive_int_prec_properties_helper_signed);\n}\n\nfn from_primitive_int_prec_round_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n    Float: PartialOrd<T>,\n    Rational: From<T> + PartialOrd<T>,\n    rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n{\n    unsigned_unsigned_rounding_mode_triple_gen_var_5::<T>().test_properties(|(n, prec, rm)| {\n        let (float_n, o) = Float::from_unsigned_prec_round(n, prec, rm);\n        assert!(float_n.is_valid());\n\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n        match rm {\n            Floor | Down => {\n                assert_ne!(o, Greater);\n            }\n            Ceiling | Up => {\n                assert_ne!(o, Less);\n            }\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_n, rug_o) = rug::Float::with_val_round(u32::exact_from(prec), n, rm);\n            assert_eq!(\n                ComparableFloatRef(&float_n),\n                ComparableFloatRef(&Float::from(&rug_n))\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (float_n_alt, o_alt) = Float::from_natural_prec_round(Natural::from(n), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o_alt, o);\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == T::ZERO { None } else { Some(prec) }\n        );\n    });\n\n    unsigned_pair_gen_var_32::<T, u64>().test_properties(|(n, prec)| {\n        let floor = Float::from_unsigned_prec_round(n, prec, Floor);\n        let r_floor = Rational::exact_from(&floor.0);\n        assert!(r_floor <= n);\n        if r_floor != T::ZERO {\n            assert!(r_floor + Rational::exact_from(floor.0.ulp().unwrap()) > n);\n        }\n        let (floor_alt, floor_o_alt) = Float::from_unsigned_prec_round(n, prec, Down);\n        assert_eq!(ComparableFloatRef(&floor_alt), ComparableFloatRef(&floor.0));\n        assert_eq!(floor_o_alt, floor.1);\n\n        let ceiling = Float::from_unsigned_prec_round(n, prec, Ceiling);\n        let r_ceiling = Rational::exact_from(&ceiling.0);\n        assert!(r_ceiling >= n);\n        if r_ceiling != T::ZERO {\n            assert!(r_ceiling - Rational::exact_from(ceiling.0.ulp().unwrap()) < n);\n        }\n        let (ceiling_alt, ceiling_o_alt) = Float::from_unsigned_prec_round(n, prec, Up);\n        assert_eq!(\n            ComparableFloatRef(&ceiling_alt),\n            ComparableFloatRef(&ceiling.0)\n        );\n        assert_eq!(ceiling_o_alt, ceiling.1);\n\n        let nearest = Float::from_unsigned_prec_round(n, prec, Nearest);\n        assert!(\n            ComparableFloatRef(&nearest.0) == ComparableFloatRef(&floor.0) && nearest.1 == floor.1\n                || ComparableFloatRef(&nearest.0) == ComparableFloatRef(&ceiling.0)\n                    && nearest.1 == ceiling.1\n        );\n        let r_nearest = Rational::exact_from(&nearest.0);\n        if r_nearest != T::ZERO {\n            assert!(\n                (r_nearest - Rational::from(n))\n                    .le_abs(&(Rational::exact_from(nearest.0.ulp().unwrap()) >> 1))\n            );\n        }\n    });\n}\n\nfn from_primitive_int_prec_round_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n    Float: PartialOrd<T>,\n    Rational: From<T> + PartialOrd<T>,\n    rug::Float: AssignRound<T, Round = Round, Ordering = Ordering>,\n{\n    signed_unsigned_rounding_mode_triple_gen_var_3::<T>().test_properties(|(n, prec, rm)| {\n        let (float_n, o) = Float::from_signed_prec_round(n, prec, rm);\n        assert!(float_n.is_valid());\n\n        assert_eq!(float_n.partial_cmp(&n), Some(o));\n        match (n >= T::ZERO, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_n, rug_o) = rug::Float::with_val_round(u32::exact_from(prec), n, rm);\n            assert_eq!(\n                ComparableFloatRef(&float_n),\n                ComparableFloatRef(&Float::from(&rug_n))\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        let (float_n_alt, o_alt) = Float::from_integer_prec_round(Integer::from(n), prec, rm);\n        assert_eq!(\n            ComparableFloatRef(&float_n_alt),\n            ComparableFloatRef(&float_n)\n        );\n        assert_eq!(o_alt, o);\n\n        assert_eq!(\n            float_n.get_prec(),\n            if n == T::ZERO { None } else { Some(prec) }\n        );\n    });\n\n    signed_unsigned_pair_gen_var_20::<T, u64>().test_properties(|(n, prec)| {\n        let floor = Float::from_signed_prec_round(n, prec, Floor);\n        let r_floor = Rational::exact_from(&floor.0);\n        assert!(r_floor <= n);\n        if r_floor != T::ZERO {\n            assert!(r_floor + Rational::exact_from(floor.0.ulp().unwrap()) > n);\n        }\n        let (floor_n_alt, o_alt) =\n            Float::from_signed_prec_round(n, prec, if n >= T::ZERO { Down } else { Up });\n        assert_eq!(\n            ComparableFloatRef(&floor_n_alt),\n            ComparableFloatRef(&floor.0)\n        );\n        assert_eq!(o_alt, floor.1);\n\n        let ceiling = Float::from_signed_prec_round(n, prec, Ceiling);\n        let r_ceiling = Rational::exact_from(&ceiling.0);\n        assert!(r_ceiling >= n);\n        if r_ceiling != T::ZERO {\n            assert!(r_ceiling - Rational::exact_from(ceiling.0.ulp().unwrap()) < n);\n        }\n        let (ceiling_n_alt, o_alt) =\n            Float::from_signed_prec_round(n, prec, if n >= T::ZERO { Up } else { Down });\n        assert_eq!(\n            ComparableFloatRef(&ceiling_n_alt),\n            ComparableFloatRef(&ceiling.0)\n        );\n        assert_eq!(o_alt, ceiling.1);\n\n        let nearest = Float::from_signed_prec_round(n, prec, Nearest);\n        let r_nearest = Rational::exact_from(&nearest.0);\n        assert!(\n            ComparableFloatRef(&nearest.0) == ComparableFloatRef(&floor.0) && nearest.1 == floor.1\n                || ComparableFloatRef(&nearest.0) == ComparableFloatRef(&ceiling.0)\n                    && nearest.1 == ceiling.1\n        );\n        if r_nearest != T::ZERO {\n            assert!(\n                (r_nearest - Rational::from(n))\n                    .le_abs(&(Rational::exact_from(nearest.0.ulp().unwrap()) >> 1))\n            );\n        }\n    });\n}\n\n#[test]\nfn from_primitive_int_prec_round_properties() {\n    apply_fn_to_unsigneds!(from_primitive_int_prec_round_properties_helper_unsigned);\n    apply_fn_to_signeds!(from_primitive_int_prec_round_properties_helper_signed);\n}\n\n#[test]\nfn const_from_unsigned_times_power_of_2_properties() {\n    unsigned_signed_pair_gen_var_1().test_properties(|(n, pow)| {\n        let float_n = Float::const_from_unsigned_times_power_of_2(n, pow);\n        assert!(float_n.is_valid());\n        assert!(float_n >= 0);\n        assert_eq!(\n            ComparableFloat(float_n),\n            ComparableFloat(Float::from(n) << pow)\n        );\n    });\n\n    signed_gen_var_5().test_properties(|pow| {\n        assert_eq!(\n            ComparableFloat(Float::const_from_unsigned_times_power_of_2(1, pow)),\n            ComparableFloat(Float::power_of_2(i64::from(pow)))\n        );\n    });\n}\n\n#[test]\nfn const_from_signed_times_power_of_2_properties() {\n    signed_pair_gen_var_2().test_properties(|(n, pow)| {\n        let float_n = Float::const_from_signed_times_power_of_2(n, pow);\n        assert!(float_n.is_valid());\n        assert_eq!(float_n >= 0, n >= 0);\n        assert_eq!(\n            ComparableFloat(float_n),\n            ComparableFloat(Float::from(n) << pow)\n        );\n    });\n\n    signed_gen_var_5().test_properties(|pow| {\n        assert_eq!(\n            ComparableFloat(Float::const_from_signed_times_power_of_2(1, pow)),\n            ComparableFloat(Float::power_of_2(i64::from(pow)))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_float::conversion::from_rational::{\n    from_rational_prec_round_direct, from_rational_prec_round_ref_direct,\n    from_rational_prec_round_ref_using_div, from_rational_prec_round_using_div,\n};\nuse malachite_float::test_util::common::rug_round_try_from_rounding_mode;\nuse malachite_float::test_util::common::to_hex_string;\nuse malachite_float::test_util::generators::rational_unsigned_rounding_mode_triple_gen_var_1;\nuse malachite_float::{ComparableFloat, ComparableFloatRef, Float, emulate_rational_to_float_fn};\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\nuse malachite_q::test_util::generators::{rational_gen, rational_unsigned_pair_gen_var_3};\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\n#[allow(clippy::type_repetition_in_bounds)]\nfn test_from_rational_prec() {\n    fn float_helper<T: PrimitiveFloat>(x: &Rational)\n    where\n        Float: PartialOrd<T>,\n        for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + RoundingFrom<&'a Rational>,\n        Rational: TryFrom<T>,\n    {\n        let xf = emulate_rational_to_float_fn::<T, _>(Float::from_rational_prec_ref, x);\n        assert_eq!(NiceFloat(xf), NiceFloat(T::rounding_from(x, Nearest).0));\n    }\n\n    let test = |s, prec, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (x, o) = Float::from_rational_prec(u.clone(), prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_rational_prec_ref(&u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_direct(u.clone(), prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_direct(&u, prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_using_div(u.clone(), prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_using_div(&u, prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), rug::Rational::from(&u));\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        float_helper::<f32>(&u);\n        float_helper::<f64>(&u);\n    };\n    test(\"0\", 1, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, \"0.0\", \"0x0.0\", Equal);\n    test(\"1\", 1, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 10, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 100, \"1.0\", \"0x1.0000000000000000000000000#100\", Equal);\n    test(\"1/2\", 1, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1/2\", 10, \"0.5\", \"0x0.800#10\", Equal);\n    test(\n        \"1/2\",\n        100,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\"1/3\", 1, \"0.2\", \"0x0.4#1\", Less);\n    test(\"1/3\", 10, \"0.3335\", \"0x0.556#10\", Greater);\n    test(\n        \"1/3\",\n        100,\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n        Greater,\n    );\n    test(\"22/7\", 1, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"22/7\", 10, \"3.145\", \"0x3.25#10\", Greater);\n    test(\n        \"22/7\",\n        100,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n\n    let test_big = |u: Rational, prec, out, out_hex, out_o| {\n        let (x, o) = Float::from_rational_prec(u.clone(), prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_rational_prec_ref(&u, prec);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_direct(u.clone(), prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_direct(&u, prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_using_div(u.clone(), prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_using_div(&u, prec, Nearest);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), rug::Rational::from(&u));\n        let x = Float::exact_from(&rug_x);\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        float_helper::<f32>(&u);\n        float_helper::<f64>(&u);\n    };\n\n    test_big(\n        Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL),\n        10,\n        \"1.401e-45\",\n        \"0x8.00E-38#10\",\n        Equal,\n    );\n    test_big(\n        Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL) >> 1,\n        10,\n        \"7.01e-46\",\n        \"0x4.00E-38#10\",\n        Equal,\n    );\n    test_big(\n        (Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL) >> 1) + Rational::power_of_2(-1000i64),\n        10,\n        \"7.01e-46\",\n        \"0x4.00E-38#10\",\n        Less,\n    );\n    test_big(\n        (Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL) >> 1) - Rational::power_of_2(-1000i64),\n        10,\n        \"7.01e-46\",\n        \"0x4.00E-38#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::exact_from(f64::MIN_POSITIVE_SUBNORMAL),\n        10,\n        \"4.94e-324\",\n        \"0x4.00E-269#10\",\n        Equal,\n    );\n    test_big(\n        Rational::exact_from(f64::MIN_POSITIVE_SUBNORMAL) >> 1,\n        10,\n        \"2.47e-324\",\n        \"0x2.00E-269#10\",\n        Equal,\n    );\n    test_big(\n        (Rational::exact_from(f64::MIN_POSITIVE_SUBNORMAL) >> 1) + Rational::power_of_2(-2000i64),\n        10,\n        \"2.47e-324\",\n        \"0x2.00E-269#10\",\n        Less,\n    );\n    test_big(\n        (Rational::exact_from(f64::MIN_POSITIVE_SUBNORMAL) >> 1) - Rational::power_of_2(-2000i64),\n        10,\n        \"2.47e-324\",\n        \"0x2.00E-269#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        \"9.33e-302\",\n        \"0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        \"too_small\",\n        \"0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        1,\n        \"9.0e-302\",\n        \"0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n\n    test_big(\n        -Rational::power_of_2(1000i64),\n        10,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        10,\n        \"-9.33e-302\",\n        \"-0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        \"-too_small\",\n        \"-0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        1,\n        \"-9.0e-302\",\n        \"-0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\nfn from_rational_prec_fail() {\n    assert_panic!(Float::from_rational_prec(Rational::ZERO, 0));\n    assert_panic!(Float::from_rational_prec(Rational::ONE, 0));\n    assert_panic!(Float::from_rational_prec(Rational::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn from_rational_prec_ref_fail() {\n    assert_panic!(Float::from_rational_prec_ref(&Rational::ZERO, 0));\n    assert_panic!(Float::from_rational_prec_ref(&Rational::ONE, 0));\n    assert_panic!(Float::from_rational_prec_ref(&Rational::NEGATIVE_ONE, 0));\n}\n\n#[test]\nfn test_from_rational_prec_round() {\n    let test = |s, prec, rm, out, out_hex, out_o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (x, o) = Float::from_rational_prec_round(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_rational_prec_round_ref(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_direct(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_using_div(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_direct(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_using_div(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Rational::from(&u), rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(o, out_o);\n        }\n    };\n    test(\"0\", 1, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 1, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 10, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 10, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"0\", 100, Floor, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Ceiling, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Down, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Up, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Nearest, \"0.0\", \"0x0.0\", Equal);\n    test(\"0\", 100, Exact, \"0.0\", \"0x0.0\", Equal);\n\n    test(\"1\", 1, Floor, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Ceiling, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Down, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Up, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Nearest, \"1.0\", \"0x1.0#1\", Equal);\n    test(\"1\", 1, Exact, \"1.0\", \"0x1.0#1\", Equal);\n\n    test(\"1\", 10, Floor, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Ceiling, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Down, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Up, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Nearest, \"1.0\", \"0x1.000#10\", Equal);\n    test(\"1\", 10, Exact, \"1.0\", \"0x1.000#10\", Equal);\n\n    test(\n        \"1\",\n        100,\n        Floor,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Ceiling,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Down,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Up,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Nearest,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1\",\n        100,\n        Exact,\n        \"1.0\",\n        \"0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"1/2\", 1, Floor, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1/2\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1/2\", 1, Down, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1/2\", 1, Up, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1/2\", 1, Nearest, \"0.5\", \"0x0.8#1\", Equal);\n    test(\"1/2\", 1, Exact, \"0.5\", \"0x0.8#1\", Equal);\n\n    test(\"1/2\", 10, Floor, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"1/2\", 10, Ceiling, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"1/2\", 10, Down, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"1/2\", 10, Up, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"1/2\", 10, Nearest, \"0.5\", \"0x0.800#10\", Equal);\n    test(\"1/2\", 10, Exact, \"0.5\", \"0x0.800#10\", Equal);\n\n    test(\n        \"1/2\",\n        100,\n        Floor,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1/2\",\n        100,\n        Ceiling,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1/2\",\n        100,\n        Down,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1/2\",\n        100,\n        Up,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1/2\",\n        100,\n        Nearest,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"1/2\",\n        100,\n        Exact,\n        \"0.5\",\n        \"0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"1/3\", 1, Floor, \"0.2\", \"0x0.4#1\", Less);\n    test(\"1/3\", 1, Ceiling, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"1/3\", 1, Down, \"0.2\", \"0x0.4#1\", Less);\n    test(\"1/3\", 1, Up, \"0.5\", \"0x0.8#1\", Greater);\n    test(\"1/3\", 1, Nearest, \"0.2\", \"0x0.4#1\", Less);\n\n    test(\"1/3\", 10, Floor, \"0.333\", \"0x0.554#10\", Less);\n    test(\"1/3\", 10, Ceiling, \"0.3335\", \"0x0.556#10\", Greater);\n    test(\"1/3\", 10, Down, \"0.333\", \"0x0.554#10\", Less);\n    test(\"1/3\", 10, Up, \"0.3335\", \"0x0.556#10\", Greater);\n    test(\"1/3\", 10, Nearest, \"0.3335\", \"0x0.556#10\", Greater);\n\n    test(\n        \"1/3\",\n        100,\n        Floor,\n        \"0.3333333333333333333333333333331\",\n        \"0x0.55555555555555555555555550#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Ceiling,\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Down,\n        \"0.3333333333333333333333333333331\",\n        \"0x0.55555555555555555555555550#100\",\n        Less,\n    );\n    test(\n        \"1/3\",\n        100,\n        Up,\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n        Greater,\n    );\n    test(\n        \"1/3\",\n        100,\n        Nearest,\n        \"0.3333333333333333333333333333335\",\n        \"0x0.55555555555555555555555558#100\",\n        Greater,\n    );\n\n    test(\"22/7\", 1, Floor, \"2.0\", \"0x2.0#1\", Less);\n    test(\"22/7\", 1, Ceiling, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"22/7\", 1, Down, \"2.0\", \"0x2.0#1\", Less);\n    test(\"22/7\", 1, Up, \"4.0\", \"0x4.0#1\", Greater);\n    test(\"22/7\", 1, Nearest, \"4.0\", \"0x4.0#1\", Greater);\n\n    test(\"22/7\", 10, Floor, \"3.141\", \"0x3.24#10\", Less);\n    test(\"22/7\", 10, Ceiling, \"3.145\", \"0x3.25#10\", Greater);\n    test(\"22/7\", 10, Down, \"3.141\", \"0x3.24#10\", Less);\n    test(\"22/7\", 10, Up, \"3.145\", \"0x3.25#10\", Greater);\n    test(\"22/7\", 10, Nearest, \"3.145\", \"0x3.25#10\", Greater);\n\n    test(\n        \"22/7\",\n        100,\n        Floor,\n        \"3.142857142857142857142857142855\",\n        \"0x3.2492492492492492492492490#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Ceiling,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Down,\n        \"3.142857142857142857142857142855\",\n        \"0x3.2492492492492492492492490#100\",\n        Less,\n    );\n    test(\n        \"22/7\",\n        100,\n        Up,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n    test(\n        \"22/7\",\n        100,\n        Nearest,\n        \"3.142857142857142857142857142858\",\n        \"0x3.2492492492492492492492494#100\",\n        Greater,\n    );\n\n    test(\"-1\", 1, Floor, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Ceiling, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Down, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Up, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Nearest, \"-1.0\", \"-0x1.0#1\", Equal);\n    test(\"-1\", 1, Exact, \"-1.0\", \"-0x1.0#1\", Equal);\n\n    test(\"-1\", 10, Floor, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Ceiling, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Down, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Up, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Nearest, \"-1.0\", \"-0x1.000#10\", Equal);\n    test(\"-1\", 10, Exact, \"-1.0\", \"-0x1.000#10\", Equal);\n\n    test(\n        \"-1\",\n        100,\n        Floor,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1\",\n        100,\n        Ceiling,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1\",\n        100,\n        Down,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1\",\n        100,\n        Up,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1\",\n        100,\n        Nearest,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1\",\n        100,\n        Exact,\n        \"-1.0\",\n        \"-0x1.0000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"-1/2\", 1, Floor, \"-0.5\", \"-0x0.8#1\", Equal);\n    test(\"-1/2\", 1, Ceiling, \"-0.5\", \"-0x0.8#1\", Equal);\n    test(\"-1/2\", 1, Down, \"-0.5\", \"-0x0.8#1\", Equal);\n    test(\"-1/2\", 1, Up, \"-0.5\", \"-0x0.8#1\", Equal);\n    test(\"-1/2\", 1, Nearest, \"-0.5\", \"-0x0.8#1\", Equal);\n    test(\"-1/2\", 1, Exact, \"-0.5\", \"-0x0.8#1\", Equal);\n\n    test(\"-1/2\", 10, Floor, \"-0.5\", \"-0x0.800#10\", Equal);\n    test(\"-1/2\", 10, Ceiling, \"-0.5\", \"-0x0.800#10\", Equal);\n    test(\"-1/2\", 10, Down, \"-0.5\", \"-0x0.800#10\", Equal);\n    test(\"-1/2\", 10, Up, \"-0.5\", \"-0x0.800#10\", Equal);\n    test(\"-1/2\", 10, Nearest, \"-0.5\", \"-0x0.800#10\", Equal);\n    test(\"-1/2\", 10, Exact, \"-0.5\", \"-0x0.800#10\", Equal);\n\n    test(\n        \"-1/2\",\n        100,\n        Floor,\n        \"-0.5\",\n        \"-0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1/2\",\n        100,\n        Ceiling,\n        \"-0.5\",\n        \"-0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1/2\",\n        100,\n        Down,\n        \"-0.5\",\n        \"-0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1/2\",\n        100,\n        Up,\n        \"-0.5\",\n        \"-0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1/2\",\n        100,\n        Nearest,\n        \"-0.5\",\n        \"-0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n    test(\n        \"-1/2\",\n        100,\n        Exact,\n        \"-0.5\",\n        \"-0x0.8000000000000000000000000#100\",\n        Equal,\n    );\n\n    test(\"-1/3\", 1, Floor, \"-0.5\", \"-0x0.8#1\", Less);\n    test(\"-1/3\", 1, Ceiling, \"-0.2\", \"-0x0.4#1\", Greater);\n    test(\"-1/3\", 1, Down, \"-0.2\", \"-0x0.4#1\", Greater);\n    test(\"-1/3\", 1, Up, \"-0.5\", \"-0x0.8#1\", Less);\n    test(\"-1/3\", 1, Nearest, \"-0.2\", \"-0x0.4#1\", Greater);\n\n    test(\"-1/3\", 10, Floor, \"-0.3335\", \"-0x0.556#10\", Less);\n    test(\"-1/3\", 10, Ceiling, \"-0.333\", \"-0x0.554#10\", Greater);\n    test(\"-1/3\", 10, Down, \"-0.333\", \"-0x0.554#10\", Greater);\n    test(\"-1/3\", 10, Up, \"-0.3335\", \"-0x0.556#10\", Less);\n    test(\"-1/3\", 10, Nearest, \"-0.3335\", \"-0x0.556#10\", Less);\n\n    test(\n        \"-1/3\",\n        100,\n        Floor,\n        \"-0.3333333333333333333333333333335\",\n        \"-0x0.55555555555555555555555558#100\",\n        Less,\n    );\n    test(\n        \"-1/3\",\n        100,\n        Ceiling,\n        \"-0.3333333333333333333333333333331\",\n        \"-0x0.55555555555555555555555550#100\",\n        Greater,\n    );\n    test(\n        \"-1/3\",\n        100,\n        Down,\n        \"-0.3333333333333333333333333333331\",\n        \"-0x0.55555555555555555555555550#100\",\n        Greater,\n    );\n    test(\n        \"-1/3\",\n        100,\n        Up,\n        \"-0.3333333333333333333333333333335\",\n        \"-0x0.55555555555555555555555558#100\",\n        Less,\n    );\n    test(\n        \"-1/3\",\n        100,\n        Nearest,\n        \"-0.3333333333333333333333333333335\",\n        \"-0x0.55555555555555555555555558#100\",\n        Less,\n    );\n\n    test(\"-22/7\", 1, Floor, \"-4.0\", \"-0x4.0#1\", Less);\n    test(\"-22/7\", 1, Ceiling, \"-2.0\", \"-0x2.0#1\", Greater);\n    test(\"-22/7\", 1, Down, \"-2.0\", \"-0x2.0#1\", Greater);\n    test(\"-22/7\", 1, Up, \"-4.0\", \"-0x4.0#1\", Less);\n    test(\"-22/7\", 1, Nearest, \"-4.0\", \"-0x4.0#1\", Less);\n\n    test(\"-22/7\", 10, Floor, \"-3.145\", \"-0x3.25#10\", Less);\n    test(\"-22/7\", 10, Ceiling, \"-3.141\", \"-0x3.24#10\", Greater);\n    test(\"-22/7\", 10, Down, \"-3.141\", \"-0x3.24#10\", Greater);\n    test(\"-22/7\", 10, Up, \"-3.145\", \"-0x3.25#10\", Less);\n    test(\"-22/7\", 10, Nearest, \"-3.145\", \"-0x3.25#10\", Less);\n\n    test(\n        \"-22/7\",\n        100,\n        Floor,\n        \"-3.142857142857142857142857142858\",\n        \"-0x3.2492492492492492492492494#100\",\n        Less,\n    );\n    test(\n        \"-22/7\",\n        100,\n        Ceiling,\n        \"-3.142857142857142857142857142855\",\n        \"-0x3.2492492492492492492492490#100\",\n        Greater,\n    );\n    test(\n        \"-22/7\",\n        100,\n        Down,\n        \"-3.142857142857142857142857142855\",\n        \"-0x3.2492492492492492492492490#100\",\n        Greater,\n    );\n    test(\n        \"-22/7\",\n        100,\n        Up,\n        \"-3.142857142857142857142857142858\",\n        \"-0x3.2492492492492492492492494#100\",\n        Less,\n    );\n    test(\n        \"-22/7\",\n        100,\n        Nearest,\n        \"-3.142857142857142857142857142858\",\n        \"-0x3.2492492492492492492492494#100\",\n        Less,\n    );\n\n    let test_big = |u: Rational, prec, rm, out, out_hex, out_o| {\n        let (x, o) = Float::from_rational_prec_round(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = Float::from_rational_prec_round_ref(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_direct(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_using_div(u.clone(), prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_direct(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        let (x, o) = from_rational_prec_round_ref_using_div(&u, prec, rm);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n        assert_eq!(o, out_o);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Rational::from(&u), rm);\n            let x = Float::exact_from(&rug_x);\n            assert_eq!(x.to_string(), out);\n            assert_eq!(to_hex_string(&x), out_hex);\n            assert_eq!(o, out_o);\n        }\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Floor,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Ceiling,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Down,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Up,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Nearest,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(1000i64),\n        10,\n        Exact,\n        \"1.072e301\",\n        \"0x1.000E+250#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x7.feE+268435455#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"too_big\",\n        \"0x7.feE+268435455#10\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_big\",\n        \"0x4.00E+268435455#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Nearest,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Floor,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Ceiling,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Down,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Up,\n        \"Infinity\",\n        \"Infinity\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Nearest,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Floor,\n        \"9.33e-302\",\n        \"0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Ceiling,\n        \"9.33e-302\",\n        \"0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Down,\n        \"9.33e-302\",\n        \"0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Up,\n        \"9.33e-302\",\n        \"0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Nearest,\n        \"9.33e-302\",\n        \"0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        10,\n        Exact,\n        \"9.33e-302\",\n        \"0x1.000E-250#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Floor,\n        \"too_small\",\n        \"0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Down,\n        \"too_small\",\n        \"0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Up,\n        \"too_small\",\n        \"0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Exact,\n        \"too_small\",\n        \"0x2.00E-268435456#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Floor,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Down,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Exact,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"too_small\",\n        \"0x1.000E-268435456#10\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        1,\n        Floor,\n        \"9.0e-302\",\n        \"0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        1,\n        Ceiling,\n        \"9.0e-302\",\n        \"0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        1,\n        Down,\n        \"9.0e-302\",\n        \"0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        1,\n        Up,\n        \"9.0e-302\",\n        \"0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        1,\n        Nearest,\n        \"9.0e-302\",\n        \"0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(-1000i64),\n        1,\n        Exact,\n        \"9.0e-302\",\n        \"0x1.0E-250#1\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Floor,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Down,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Up,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Exact,\n        \"too_small\",\n        \"0x2.0E-268435456#1\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Floor,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Down,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Exact,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Nearest,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Floor,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Ceiling,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Down,\n        \"0.0\",\n        \"0x0.0\",\n        Less,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Up,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Nearest,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Greater,\n    );\n\n    test_big(\n        -Rational::power_of_2(1000i64),\n        10,\n        Floor,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(1000i64),\n        10,\n        Ceiling,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(1000i64),\n        10,\n        Down,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(1000i64),\n        10,\n        Up,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(1000i64),\n        10,\n        Nearest,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(1000i64),\n        10,\n        Exact,\n        \"-1.072e301\",\n        \"-0x1.000E+250#10\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Ceiling,\n        \"-too_big\",\n        \"-0x7.feE+268435455#10\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Down,\n        \"-too_big\",\n        \"-0x7.feE+268435455#10\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        10,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Floor,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Down,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Up,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        10,\n        Exact,\n        \"-too_big\",\n        \"-0x4.00E+268435455#10\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        1,\n        Nearest,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Floor,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Ceiling,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Down,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Up,\n        \"-Infinity\",\n        \"-Infinity\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        1,\n        Nearest,\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Greater,\n    );\n\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        10,\n        Floor,\n        \"-9.33e-302\",\n        \"-0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        10,\n        Ceiling,\n        \"-9.33e-302\",\n        \"-0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        10,\n        Down,\n        \"-9.33e-302\",\n        \"-0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        10,\n        Up,\n        \"-9.33e-302\",\n        \"-0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        10,\n        Nearest,\n        \"-9.33e-302\",\n        \"-0x1.000E-250#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        10,\n        Exact,\n        \"-9.33e-302\",\n        \"-0x1.000E-250#10\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Ceiling,\n        \"-too_small\",\n        \"-0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Down,\n        \"-too_small\",\n        \"-0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Nearest,\n        \"-too_small\",\n        \"-0x2.00E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        10,\n        Exact,\n        \"-too_small\",\n        \"-0x2.00E-268435456#10\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Ceiling,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Down,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        10,\n        Exact,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        10,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        10,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        10,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Floor,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Up,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        10,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.000E-268435456#10\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        1,\n        Floor,\n        \"-9.0e-302\",\n        \"-0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        1,\n        Ceiling,\n        \"-9.0e-302\",\n        \"-0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        1,\n        Down,\n        \"-9.0e-302\",\n        \"-0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        1,\n        Up,\n        \"-9.0e-302\",\n        \"-0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        1,\n        Nearest,\n        \"-9.0e-302\",\n        \"-0x1.0E-250#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        1,\n        Exact,\n        \"-9.0e-302\",\n        \"-0x1.0E-250#1\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Ceiling,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Down,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        1,\n        Exact,\n        \"-too_small\",\n        \"-0x2.0E-268435456#1\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Ceiling,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Down,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        1,\n        Exact,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Equal,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        1,\n        Nearest,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Floor,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Ceiling,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Down,\n        \"-0.0\",\n        \"-0x0.0\",\n        Greater,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Up,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        1,\n        Nearest,\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Less,\n    );\n}\n\n#[test]\nfn from_rational_prec_round_fail() {\n    assert_panic!(Float::from_rational_prec_round(Rational::ZERO, 0, Floor));\n    assert_panic!(Float::from_rational_prec_round(Rational::ONE, 0, Floor));\n    assert_panic!(Float::from_rational_prec_round(\n        Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::from_rational_prec_round(\n        Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::from_rational_prec_round(\n        Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_rational_prec_round(\n        Rational::from(-123),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::from_rational_prec_round(\n        Rational::from_signeds(-1i8, 3),\n        100,\n        Exact\n    ));\n}\n\n#[test]\nfn from_rational_prec_round_ref_fail() {\n    assert_panic!(Float::from_rational_prec_round_ref(\n        &Rational::ZERO,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_rational_prec_round_ref(\n        &Rational::ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_rational_prec_round_ref(\n        &Rational::from(123u32),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::from_rational_prec_round_ref(\n        &Rational::from_unsigneds(1u8, 3),\n        100,\n        Exact\n    ));\n    assert_panic!(Float::from_rational_prec_round_ref(\n        &Rational::NEGATIVE_ONE,\n        0,\n        Floor\n    ));\n    assert_panic!(Float::from_rational_prec_round_ref(\n        &Rational::from(-123),\n        1,\n        Exact\n    ));\n    assert_panic!(Float::from_rational_prec_round_ref(\n        &Rational::from_signeds(-1i8, 3),\n        100,\n        Exact\n    ));\n}\n\n#[allow(clippy::needless_borrow)]\n#[test]\nfn test_try_from_rational() {\n    let test = |s, out, out_hex| {\n        let x = Rational::from_str(s).unwrap();\n\n        let of = Float::try_from(x.clone());\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n    };\n    test(\"0\", Ok(\"0.0\"), Ok(\"0x0.0\"));\n    test(\"1\", Ok(\"1.0\"), Ok(\"0x1.0#1\"));\n    test(\"1/2\", Ok(\"0.5\"), Ok(\"0x0.8#1\"));\n    test(\"117/256\", Ok(\"0.457\"), Ok(\"0x0.75#7\"));\n    test(\n        \"6369051672525773/4503599627370496\",\n        Ok(\"1.4142135623730951\"),\n        Ok(\"0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        Ok(\"3.141592653589793\"),\n        Ok(\"0x3.243f6a8885a3#50\"),\n    );\n    test(\n        \"6121026514868073/2251799813685248\",\n        Ok(\"2.7182818284590451\"),\n        Ok(\"0x2.b7e151628aed2#53\"),\n    );\n    test(\"-1\", Ok(\"-1.0\"), Ok(\"-0x1.0#1\"));\n    test(\"-1/2\", Ok(\"-0.5\"), Ok(\"-0x0.8#1\"));\n    test(\"-117/256\", Ok(\"-0.457\"), Ok(\"-0x0.75#7\"));\n    test(\n        \"-6369051672525773/4503599627370496\",\n        Ok(\"-1.4142135623730951\"),\n        Ok(\"-0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        Ok(\"-3.141592653589793\"),\n        Ok(\"-0x3.243f6a8885a3#50\"),\n    );\n    test(\n        \"-6121026514868073/2251799813685248\",\n        Ok(\"-2.7182818284590451\"),\n        Ok(\"-0x2.b7e151628aed2#53\"),\n    );\n\n    test(\n        \"1/3\",\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test(\n        \"22/7\",\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test(\n        \"-1/3\",\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test(\n        \"-22/7\",\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n\n    let test_big = |x: Rational, out, out_hex| {\n        let of = Float::try_from(x.clone());\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        let ofs = of.as_ref().map(ToString::to_string);\n        assert_eq!(ofs.as_ref().map(String::as_str), out);\n        let ofs = of.map(|f| to_hex_string(&f));\n        assert_eq!(ofs.as_ref().map(String::as_str), out_hex);\n    };\n    test_big(\n        Rational::power_of_2(1000i64),\n        Ok(\"1.0e301\"),\n        Ok(\"0x1.0E+250#1\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Err(&&FloatConversionError::Overflow),\n        Err(&&FloatConversionError::Overflow),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        Ok(\"too_big\"),\n        Ok(\"0x4.0E+268435455#1\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        Ok(\"too_big\"),\n        Ok(\"0x6.0E+268435455#2\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3073u16, 2048),\n        Ok(\"too_big\"),\n        Ok(\"0x6.008E+268435455#12\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3071u16, 2048),\n        Ok(\"too_big\"),\n        Ok(\"0x5.ff8E+268435455#12\"),\n    );\n\n    test_big(\n        Rational::power_of_2(-1000i64),\n        Ok(\"9.0e-302\"),\n        Ok(\"0x1.0E-250#1\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        Ok(\"too_small\"),\n        Ok(\"0x2.0E-268435456#1\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        Ok(\"too_small\"),\n        Ok(\"0x1.0E-268435456#1\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        Err(&&FloatConversionError::Underflow),\n        Err(&&FloatConversionError::Underflow),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        Err(&&FloatConversionError::Underflow),\n        Err(&&FloatConversionError::Underflow),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        Err(&&FloatConversionError::Underflow),\n        Err(&&FloatConversionError::Underflow),\n    );\n\n    test_big(\n        Rational::power_of_2(1000i64),\n        Ok(\"1.0e301\"),\n        Ok(\"0x1.0E+250#1\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Err(&&FloatConversionError::Overflow),\n        Err(&&FloatConversionError::Overflow),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        Ok(\"too_big\"),\n        Ok(\"0x4.0E+268435455#1\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        Ok(\"too_big\"),\n        Ok(\"0x6.0E+268435455#2\"),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n\n    test_big(\n        -Rational::power_of_2(-1000i64),\n        Ok(\"-9.0e-302\"),\n        Ok(\"-0x1.0E-250#1\"),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT)),\n        Ok(\"-too_small\"),\n        Ok(\"-0x2.0E-268435456#1\"),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        Ok(\"-too_small\"),\n        Ok(\"-0x1.0E-268435456#1\"),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        Err(&&FloatConversionError::Underflow),\n        Err(&&FloatConversionError::Underflow),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        Err(&&FloatConversionError::Underflow),\n        Err(&&FloatConversionError::Underflow),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        Err(&&FloatConversionError::Underflow),\n        Err(&&FloatConversionError::Underflow),\n    );\n\n    test_big(\n        -Rational::power_of_2(1000i64),\n        Ok(\"-1.0e301\"),\n        Ok(\"-0x1.0E+250#1\"),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT)),\n        Err(&&FloatConversionError::Overflow),\n        Err(&&FloatConversionError::Overflow),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        Ok(\"-too_big\"),\n        Ok(\"-0x4.0E+268435455#1\"),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        Ok(\"-too_big\"),\n        Ok(\"-0x6.0E+268435455#2\"),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        Err(&&FloatConversionError::Inexact),\n        Err(&&FloatConversionError::Inexact),\n    );\n}\n\n#[test]\nfn test_convertible_from_rational() {\n    let test = |s, out| {\n        let x = Rational::from_str(s).unwrap();\n        assert_eq!(Float::convertible_from(&x), out);\n    };\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"1/2\", true);\n    test(\"117/256\", true);\n    test(\"6369051672525773/4503599627370496\", true);\n    test(\"884279719003555/281474976710656\", true);\n    test(\"6121026514868073/2251799813685248\", true);\n    test(\"-1\", true);\n    test(\"-1/2\", true);\n    test(\"-117/256\", true);\n    test(\"-6369051672525773/4503599627370496\", true);\n    test(\"-884279719003555/281474976710656\", true);\n    test(\"-6121026514868073/2251799813685248\", true);\n\n    test(\"1/3\", false);\n    test(\"22/7\", false);\n    test(\"-1/3\", false);\n    test(\"-22/7\", false);\n\n    let test_big = |x: Rational, out| {\n        assert_eq!(Float::convertible_from(&x), out);\n    };\n    test_big(Rational::power_of_2(1000i64), true);\n    test_big(Rational::power_of_2(i64::from(Float::MAX_EXPONENT)), false);\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        true,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1) * Rational::from_unsigneds(3u8, 2),\n        true,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        false,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        false,\n    );\n\n    test_big(Rational::power_of_2(-1000i64), true);\n    test_big(Rational::power_of_2(i64::from(Float::MIN_EXPONENT)), true);\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        true,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        false,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        false,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        false,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        false,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        false,\n    );\n    test_big(\n        Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        false,\n    );\n\n    test_big(-Rational::power_of_2(1000i64), true);\n    test_big(-Rational::power_of_2(i64::from(Float::MAX_EXPONENT)), false);\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1),\n        true,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(3u8, 2),\n        true,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(300u16, 199),\n        false,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MAX_EXPONENT) - 1)\n            * Rational::from_unsigneds(299u16, 200),\n        false,\n    );\n\n    test_big(-Rational::power_of_2(-1000i64), true);\n    test_big(-Rational::power_of_2(i64::from(Float::MIN_EXPONENT)), true);\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 1),\n        true,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2),\n        false,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        false,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        false,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1024u16, 1023),\n        false,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1001u16, 1000),\n        false,\n    );\n    test_big(\n        -Rational::power_of_2(i64::from(Float::MIN_EXPONENT) - 2)\n            * Rational::from_unsigneds(1025u16, 1024),\n        false,\n    );\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn from_rational_prec_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: PartialOrd<T>,\n    for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + RoundingFrom<&'a Rational>,\n    Rational: TryFrom<T>,\n{\n    rational_gen().test_properties(|x| {\n        let xf = emulate_rational_to_float_fn::<T, _>(Float::from_rational_prec_ref, &x);\n        assert_eq!(NiceFloat(xf), NiceFloat(T::rounding_from(&x, Nearest).0));\n    });\n}\n\n#[test]\nfn from_rational_prec_properties() {\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let (float_x, o) = Float::from_rational_prec(x.clone(), prec);\n        assert!(float_x.is_valid());\n\n        let (float_x_alt, o_alt) = Float::from_rational_prec_ref(&x, prec);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n        assert_eq!(float_x.partial_cmp(&x), Some(o));\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_direct(x.clone(), prec, Nearest);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_using_div(x.clone(), prec, Nearest);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_ref_direct(&x, prec, Nearest);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_ref_using_div(&x, prec, Nearest);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        let rug_x = rug::Float::with_val(u32::exact_from(prec), rug::Rational::from(&x));\n        assert_eq!(\n            ComparableFloatRef(&float_x),\n            ComparableFloatRef(&Float::from(&rug_x))\n        );\n\n        assert_eq!(x == 0u32, float_x == 0u32);\n        assert_eq!(\n            float_x.get_prec(),\n            if x == 0u32 { None } else { Some(prec) }\n        );\n        if x != 0u32 {\n            assert!(\n                (Rational::exact_from(&float_x) - &x)\n                    .le_abs(&(Rational::exact_from(float_x.ulp().unwrap()) >> 1))\n            );\n        }\n    });\n\n    apply_fn_to_primitive_floats!(from_rational_prec_properties_helper);\n}\n\n#[test]\nfn from_rational_prec_round_properties() {\n    rational_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(x, prec, rm)| {\n        let (float_x, o) = Float::from_rational_prec_round(x.clone(), prec, rm);\n        assert!(float_x.is_valid());\n\n        let (float_x_alt, o_alt) = Float::from_rational_prec_round_ref(&x, prec, rm);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n        assert_eq!(float_x.partial_cmp(&x), Some(o));\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_direct(x.clone(), prec, rm);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_using_div(x.clone(), prec, rm);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_ref_direct(&x, prec, rm);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        let (float_x_alt, o_alt) = from_rational_prec_round_ref_using_div(&x, prec, rm);\n        assert!(float_x_alt.is_valid());\n        assert_eq!(\n            ComparableFloatRef(&float_x_alt),\n            ComparableFloatRef(&float_x)\n        );\n        assert_eq!(o, o_alt);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rug_x, rug_o) =\n                rug::Float::with_val_round(u32::exact_from(prec), rug::Rational::from(&x), rm);\n            assert_eq!(\n                ComparableFloatRef(&float_x),\n                ComparableFloatRef(&Float::from(&rug_x))\n            );\n            assert_eq!(rug_o, o);\n        }\n\n        assert_eq!(x == 0u32, float_x == 0u32);\n        assert_eq!(\n            float_x.get_prec(),\n            if x == 0u32 { None } else { Some(prec) }\n        );\n        if x != 0u32 {\n            assert!(\n                (Rational::exact_from(&float_x) - &x)\n                    .le_abs(&Rational::exact_from(float_x.ulp().unwrap()))\n            );\n        }\n    });\n\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, prec)| {\n        let floor = Float::from_rational_prec_round_ref(&x, prec, Floor);\n        let r_floor = Rational::exact_from(&floor.0);\n        assert!(r_floor <= x);\n        if r_floor != 0u32 {\n            assert!(r_floor + Rational::exact_from(floor.0.ulp().unwrap()) > x);\n        }\n        let (floor_x_alt, o_alt) =\n            Float::from_rational_prec_round_ref(&x, prec, if x >= 0 { Down } else { Up });\n        assert_eq!(\n            ComparableFloatRef(&floor_x_alt),\n            ComparableFloatRef(&floor.0)\n        );\n        assert_eq!(o_alt, floor.1);\n\n        let ceiling = Float::from_rational_prec_round_ref(&x, prec, Ceiling);\n        let r_ceiling = Rational::exact_from(&ceiling.0);\n        assert!(r_ceiling >= x);\n        if r_ceiling != 0u32 {\n            assert!(r_ceiling - Rational::exact_from(ceiling.0.ulp().unwrap()) < x);\n        }\n        let (ceiling_x_alt, o_alt) =\n            Float::from_rational_prec_round_ref(&x, prec, if x >= 0 { Up } else { Down });\n        assert_eq!(\n            ComparableFloatRef(&ceiling_x_alt),\n            ComparableFloatRef(&ceiling.0)\n        );\n        assert_eq!(o_alt, ceiling.1);\n\n        let nearest = Float::from_rational_prec_round_ref(&x, prec, Nearest);\n        let r_nearest = Rational::exact_from(&nearest.0);\n        assert!(\n            ComparableFloatRef(&nearest.0) == ComparableFloatRef(&floor.0) && nearest.1 == floor.1\n                || ComparableFloatRef(&nearest.0) == ComparableFloatRef(&ceiling.0)\n                    && nearest.1 == ceiling.1\n        );\n        if r_nearest != 0u32 {\n            assert!((r_nearest - x).le_abs(&(Rational::exact_from(nearest.0.ulp().unwrap()) >> 1)));\n        }\n    });\n}\n\n#[test]\nfn float_try_from_rational_properties() {\n    rational_gen().test_properties(|x| {\n        let of = Float::try_from(&x);\n        assert!(of.as_ref().map_or(true, Float::is_valid));\n        assert_eq!(\n            Float::try_from(x.clone()).map(ComparableFloat),\n            of.clone().map(ComparableFloat)\n        );\n        if let Ok(f) = of {\n            assert_eq!(-x, -f);\n        }\n    });\n}\n\n#[test]\nfn float_convertible_from_rational_properties() {\n    rational_gen().test_properties(|x| {\n        assert_eq!(Float::convertible_from(&x), Float::try_from(&x).is_ok());\n    });\n\n    integer_gen().test_properties(|n| {\n        assert!(Float::convertible_from(&Rational::from(n)));\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/integer_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ceiling, Floor, Parity};\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, One, OneHalf};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::ToDebugString;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::{parse_hex_string, rug_round_try_from_rounding_mode};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_4, float_rounding_mode_pair_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_try_from_float() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let on = Integer::try_from(x.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n\n        let on = Integer::try_from(&x);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(\"NaN\", \"NaN\", \"Err(FloatInfiniteOrNan)\");\n    test(\"Infinity\", \"Infinity\", \"Err(FloatInfiniteOrNan)\");\n    test(\"-Infinity\", \"-Infinity\", \"Err(FloatInfiniteOrNan)\");\n    test(\"0.0\", \"0x0.0\", \"Ok(0)\");\n    test(\"-0.0\", \"-0x0.0\", \"Ok(0)\");\n\n    test(\"1.0\", \"0x1.0#1\", \"Ok(1)\");\n    test(\"2.0\", \"0x2.0#1\", \"Ok(2)\");\n    test(\"0.5\", \"0x0.8#1\", \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"Err(FloatNonIntegerOrOutOfRange)\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"Ok(123)\");\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", \"Ok(1000000000000)\");\n\n    test(\"-1.0\", \"-0x1.0#1\", \"Ok(-1)\");\n    test(\"-2.0\", \"-0x2.0#1\", \"Ok(-2)\");\n    test(\"-0.5\", \"-0x0.8#1\", \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"Err(FloatNonIntegerOrOutOfRange)\",\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"Ok(-123)\");\n    test(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        \"Ok(-1000000000000)\",\n    );\n}\n\n#[test]\nfn test_convertible_from_float() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(Integer::convertible_from(&x), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"123.0\", \"0x7b.0#7\", true);\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", true);\n\n    test(\"-1.0\", \"-0x1.0#1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", true);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-123.0\", \"-0x7b.0#7\", true);\n    test(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", true);\n}\n\n#[test]\nfn test_rounding_from_float() {\n    let test = |s, s_hex, rm, out, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (n, o) = Integer::rounding_from(x.clone(), rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n\n        let (n, o) = Integer::rounding_from(&x, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rn, ro) = rug::Float::exact_from(&x).to_integer_round(rm).unwrap();\n            assert_eq!(Integer::from(&rn), n);\n            assert_eq!(ro, o);\n        }\n    };\n    test(\"0.0\", \"0x0.0\", Floor, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Ceiling, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Down, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Up, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Nearest, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Exact, \"0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", Floor, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Ceiling, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Down, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Up, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Nearest, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Exact, \"0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", Floor, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Ceiling, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Down, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Up, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Exact, \"1\", Equal);\n\n    test(\"2.0\", \"0x2.0#1\", Floor, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Ceiling, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Down, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Up, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Nearest, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Exact, \"2\", Equal);\n\n    test(\"0.5\", \"0x0.8#1\", Floor, \"0\", Less);\n    test(\"0.5\", \"0x0.8#1\", Ceiling, \"1\", Greater);\n    test(\"0.5\", \"0x0.8#1\", Down, \"0\", Less);\n    test(\"0.5\", \"0x0.8#1\", Up, \"1\", Greater);\n    test(\"0.5\", \"0x0.8#1\", Nearest, \"0\", Less);\n\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Floor,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Ceiling,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Down,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Up,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Nearest,\n        \"0\",\n        Less,\n    );\n\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Floor,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Ceiling,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Down,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Up,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Nearest,\n        \"1\",\n        Greater,\n    );\n\n    test(\"1.5\", \"0x1.8#2\", Floor, \"1\", Less);\n    test(\"1.5\", \"0x1.8#2\", Ceiling, \"2\", Greater);\n    test(\"1.5\", \"0x1.8#2\", Down, \"1\", Less);\n    test(\"1.5\", \"0x1.8#2\", Up, \"2\", Greater);\n    test(\"1.5\", \"0x1.8#2\", Nearest, \"2\", Greater);\n\n    test(\"2.5\", \"0x2.8#3\", Floor, \"2\", Less);\n    test(\"2.5\", \"0x2.8#3\", Ceiling, \"3\", Greater);\n    test(\"2.5\", \"0x2.8#3\", Down, \"2\", Less);\n    test(\"2.5\", \"0x2.8#3\", Up, \"3\", Greater);\n    test(\"2.5\", \"0x2.8#3\", Nearest, \"2\", Less);\n\n    test(\"123.0\", \"0x7b.0#7\", Floor, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Ceiling, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Down, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Up, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Nearest, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Exact, \"123\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", Floor, \"-1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Ceiling, \"-1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Down, \"-1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Up, \"-1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Nearest, \"-1\", Equal);\n    test(\"-1.0\", \"-0x1.0#1\", Exact, \"-1\", Equal);\n\n    test(\"-2.0\", \"-0x2.0#1\", Floor, \"-2\", Equal);\n    test(\"-2.0\", \"-0x2.0#1\", Ceiling, \"-2\", Equal);\n    test(\"-2.0\", \"-0x2.0#1\", Down, \"-2\", Equal);\n    test(\"-2.0\", \"-0x2.0#1\", Up, \"-2\", Equal);\n    test(\"-2.0\", \"-0x2.0#1\", Nearest, \"-2\", Equal);\n    test(\"-2.0\", \"-0x2.0#1\", Exact, \"-2\", Equal);\n\n    test(\"-0.5\", \"-0x0.8#1\", Floor, \"-1\", Less);\n    test(\"-0.5\", \"-0x0.8#1\", Ceiling, \"0\", Greater);\n    test(\"-0.5\", \"-0x0.8#1\", Down, \"0\", Greater);\n    test(\"-0.5\", \"-0x0.8#1\", Up, \"-1\", Less);\n    test(\"-0.5\", \"-0x0.8#1\", Nearest, \"0\", Greater);\n\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Floor,\n        \"-1\",\n        Less,\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Ceiling,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Down,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Up,\n        \"-1\",\n        Less,\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Nearest,\n        \"0\",\n        Greater,\n    );\n\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Floor,\n        \"-1\",\n        Less,\n    );\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Ceiling,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Down,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Up,\n        \"-1\",\n        Less,\n    );\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Nearest,\n        \"-1\",\n        Less,\n    );\n\n    test(\"-1.5\", \"-0x1.8#2\", Floor, \"-2\", Less);\n    test(\"-1.5\", \"-0x1.8#2\", Ceiling, \"-1\", Greater);\n    test(\"-1.5\", \"-0x1.8#2\", Down, \"-1\", Greater);\n    test(\"-1.5\", \"-0x1.8#2\", Up, \"-2\", Less);\n    test(\"-1.5\", \"-0x1.8#2\", Nearest, \"-2\", Less);\n\n    test(\"-2.5\", \"-0x2.8#3\", Floor, \"-3\", Less);\n    test(\"-2.5\", \"-0x2.8#3\", Ceiling, \"-2\", Greater);\n    test(\"-2.5\", \"-0x2.8#3\", Down, \"-2\", Greater);\n    test(\"-2.5\", \"-0x2.8#3\", Up, \"-3\", Less);\n    test(\"-2.5\", \"-0x2.8#3\", Nearest, \"-2\", Greater);\n\n    test(\"-123.0\", \"-0x7b.0#7\", Floor, \"-123\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"-123\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Down, \"-123\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Up, \"-123\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Nearest, \"-123\", Equal);\n    test(\"-123.0\", \"-0x7b.0#7\", Exact, \"-123\", Equal);\n}\n\n#[test]\nfn integer_rounding_from_float_fail() {\n    assert_panic!(Integer::rounding_from(Float::NAN, Floor));\n    assert_panic!(Integer::rounding_from(Float::NAN, Ceiling));\n    assert_panic!(Integer::rounding_from(Float::NAN, Down));\n    assert_panic!(Integer::rounding_from(Float::NAN, Up));\n    assert_panic!(Integer::rounding_from(Float::NAN, Nearest));\n    assert_panic!(Integer::rounding_from(Float::NAN, Exact));\n\n    assert_panic!(Integer::rounding_from(Float::INFINITY, Floor));\n    assert_panic!(Integer::rounding_from(Float::INFINITY, Ceiling));\n    assert_panic!(Integer::rounding_from(Float::INFINITY, Down));\n    assert_panic!(Integer::rounding_from(Float::INFINITY, Up));\n    assert_panic!(Integer::rounding_from(Float::INFINITY, Nearest));\n    assert_panic!(Integer::rounding_from(Float::INFINITY, Exact));\n\n    assert_panic!(Integer::rounding_from(Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(Integer::rounding_from(Float::NEGATIVE_INFINITY, Ceiling));\n    assert_panic!(Integer::rounding_from(Float::NEGATIVE_INFINITY, Down));\n    assert_panic!(Integer::rounding_from(Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(Integer::rounding_from(Float::NEGATIVE_INFINITY, Nearest));\n    assert_panic!(Integer::rounding_from(Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(Integer::rounding_from(Float::from(3u8) >> 1, Exact));\n    assert_panic!(Integer::rounding_from(Float::from(-3i8) >> 1, Exact));\n}\n\n#[test]\nfn integer_rounding_from_float_ref_fail() {\n    assert_panic!(Integer::rounding_from(&Float::NAN, Floor));\n    assert_panic!(Integer::rounding_from(&Float::NAN, Ceiling));\n    assert_panic!(Integer::rounding_from(&Float::NAN, Down));\n    assert_panic!(Integer::rounding_from(&Float::NAN, Up));\n    assert_panic!(Integer::rounding_from(&Float::NAN, Nearest));\n    assert_panic!(Integer::rounding_from(&Float::NAN, Exact));\n\n    assert_panic!(Integer::rounding_from(&Float::INFINITY, Floor));\n    assert_panic!(Integer::rounding_from(&Float::INFINITY, Ceiling));\n    assert_panic!(Integer::rounding_from(&Float::INFINITY, Down));\n    assert_panic!(Integer::rounding_from(&Float::INFINITY, Up));\n    assert_panic!(Integer::rounding_from(&Float::INFINITY, Nearest));\n    assert_panic!(Integer::rounding_from(&Float::INFINITY, Exact));\n\n    assert_panic!(Integer::rounding_from(&Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(Integer::rounding_from(&Float::NEGATIVE_INFINITY, Ceiling));\n    assert_panic!(Integer::rounding_from(&Float::NEGATIVE_INFINITY, Down));\n    assert_panic!(Integer::rounding_from(&Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(Integer::rounding_from(&Float::NEGATIVE_INFINITY, Nearest));\n    assert_panic!(Integer::rounding_from(&Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(Integer::rounding_from(&(Float::from(3u8) >> 1), Exact));\n    assert_panic!(Integer::rounding_from(&(Float::from(-3i8) >> 1), Exact));\n}\n\n#[test]\nfn try_from_float_properties() {\n    float_gen().test_properties(|x| {\n        let integer_x = Integer::try_from(x.clone());\n        assert!(integer_x.as_ref().map_or(true, Integer::is_valid));\n\n        let integer_x_alt = Integer::try_from(&x);\n        assert!(integer_x_alt.as_ref().map_or(true, Integer::is_valid));\n        assert_eq!(integer_x, integer_x_alt);\n\n        assert_eq!(integer_x.is_ok(), Integer::convertible_from(&x));\n        if let Ok(n) = integer_x {\n            assert_eq!(Integer::exact_from(&x), n);\n            assert_eq!(n, x);\n            assert_eq!(Float::exact_from(&n), x);\n            assert_eq!(Float::exact_from(n), x);\n        }\n    });\n}\n\n#[test]\nfn convertible_from_float_properties() {\n    float_gen().test_properties(|x| {\n        Integer::convertible_from(&x);\n    });\n}\n\n#[test]\nfn rounding_from_float_properties() {\n    float_rounding_mode_pair_gen_var_2().test_properties(|(x, rm)| {\n        let no = Integer::rounding_from(&x, rm);\n        assert_eq!(Integer::rounding_from(x.clone(), rm), no);\n        let (n, o) = no;\n        assert!((Rational::from(&n) - Rational::exact_from(&x)).lt_abs(&1));\n\n        assert_eq!(n.partial_cmp(&x), Some(o));\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        if let Ok(rm) = rug_round_try_from_rounding_mode(rm) {\n            let (rn, ro) = rug::Float::exact_from(&x).to_integer_round(rm).unwrap();\n            assert_eq!(Integer::from(&rn), n);\n            assert_eq!(ro, o);\n        }\n    });\n\n    float_gen_var_4().test_properties(|x| {\n        let floor = Integer::rounding_from(&x, Floor);\n        assert_eq!(floor.0, Rational::exact_from(&x).floor());\n        assert!(floor.0 <= x);\n        assert!(&floor.0 + Integer::ONE > x);\n        assert_eq!(\n            Integer::rounding_from(&x, if x >= 0 { Down } else { Up }),\n            floor\n        );\n\n        let ceiling = Integer::rounding_from(&x, Ceiling);\n        assert_eq!(ceiling.0, Rational::exact_from(&x).ceiling());\n        assert!(ceiling.0 >= x);\n        assert!(&ceiling.0 - Integer::ONE < x);\n        assert_eq!(\n            Integer::rounding_from(&x, if x >= 0 { Up } else { Down }),\n            ceiling\n        );\n\n        let nearest = Integer::rounding_from(&x, Nearest);\n        assert!(nearest == floor || nearest == ceiling);\n        assert!((Rational::from(nearest.0) - Rational::exact_from(x)).le_abs(&Rational::ONE_HALF));\n    });\n\n    integer_gen().test_properties(|n| {\n        let x = Float::exact_from(&n);\n        let no = (n, Equal);\n        assert_eq!(Integer::rounding_from(&x, Floor), no);\n        assert_eq!(Integer::rounding_from(&x, Down), no);\n        assert_eq!(Integer::rounding_from(&x, Ceiling), no);\n        assert_eq!(Integer::rounding_from(&x, Up), no);\n        assert_eq!(Integer::rounding_from(&x, Nearest), no);\n        assert_eq!(Integer::rounding_from(&x, Exact), no);\n\n        let x = Float::exact_from((no.0 << 1) | Integer::ONE) >> 1;\n        assert!(Integer::rounding_from(x, Nearest).0.even());\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{float_gen, float_gen_var_12};\nuse malachite_q::Rational;\n\n#[test]\nfn test_is_integer() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(x.is_integer(), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"123.0\", \"0x7b.0#7\", true);\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", true);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", false);\n    test(\"3.141592653589793\", \"0x3.243f6a8885a3#50\", false);\n    test(\"2.7182818284590451\", \"0x2.b7e151628aed2#53\", false);\n    test(\"too_big\", \"0x4.0E+268435455#1\", true);\n    test(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n    test(\"-1.0\", \"-0x1.0#1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", true);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-123.0\", \"-0x7b.0#7\", true);\n    test(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", true);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", false);\n    test(\"-3.141592653589793\", \"-0x3.243f6a8885a3#50\", false);\n    test(\"-2.7182818284590451\", \"-0x2.b7e151628aed2#53\", false);\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", true);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn is_integer_properties_helper(x: Float, extreme: bool) {\n    assert_eq!(x.is_integer(), (-&x).is_integer());\n    if !extreme && let Ok(q) = Rational::try_from(&x) {\n        assert_eq!(q.is_integer(), x.is_integer());\n    }\n}\n\n#[test]\nfn is_integer_properties() {\n    float_gen().test_properties(|x| is_integer_properties_helper(x, false));\n\n    float_gen_var_12().test_properties(|x| is_integer_properties_helper(x, true));\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, DivisibleByPowerOf2, Parity};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeZero, One, Zero,\n};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, IntegerMantissaAndExponent, RawMantissaAndExponent, SciMantissaAndExponent,\n};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen_var_12, primitive_float_signed_pair_gen_var_3,\n};\nuse malachite_float::test_util::common::{parse_hex_string, to_hex_string};\nuse malachite_float::test_util::generators::{\n    float_gen_var_3, float_gen_var_13, float_rounding_mode_pair_gen,\n    float_rounding_mode_pair_gen_var_21, float_signed_pair_gen_var_1,\n};\nuse malachite_float::{ComparableFloatRef, Float};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_signed_pair_gen_var_2, natural_signed_pair_gen_var_4,\n};\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_sci_mantissa_and_exponent_round() {\n    fn test<T: PrimitiveFloat>(s: &str, s_hex: &str, rm: RoundingMode, out: &str) {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let meo: Option<(T, i32, Ordering)> = x.sci_mantissa_and_exponent_round(rm);\n        if let Some((m, e, o)) = meo {\n            assert_eq!(format!(\"Some({}, {}, {:?})\", NiceFloat(m), e, o), out);\n        } else {\n            assert_eq!(\"None\", out);\n        }\n    }\n    test::<f32>(\"NaN\", \"NaN\", Floor, \"None\");\n    test::<f32>(\"NaN\", \"NaN\", Ceiling, \"None\");\n    test::<f32>(\"NaN\", \"NaN\", Down, \"None\");\n    test::<f32>(\"NaN\", \"NaN\", Up, \"None\");\n    test::<f32>(\"NaN\", \"NaN\", Nearest, \"None\");\n    test::<f32>(\"NaN\", \"NaN\", Exact, \"None\");\n\n    test::<f32>(\"Infinity\", \"Infinity\", Floor, \"None\");\n    test::<f32>(\"Infinity\", \"Infinity\", Ceiling, \"None\");\n    test::<f32>(\"Infinity\", \"Infinity\", Down, \"None\");\n    test::<f32>(\"Infinity\", \"Infinity\", Up, \"None\");\n    test::<f32>(\"Infinity\", \"Infinity\", Nearest, \"None\");\n    test::<f32>(\"Infinity\", \"Infinity\", Exact, \"None\");\n\n    test::<f32>(\"-Infinity\", \"-Infinity\", Floor, \"None\");\n    test::<f32>(\"-Infinity\", \"-Infinity\", Ceiling, \"None\");\n    test::<f32>(\"-Infinity\", \"-Infinity\", Down, \"None\");\n    test::<f32>(\"-Infinity\", \"-Infinity\", Up, \"None\");\n    test::<f32>(\"-Infinity\", \"-Infinity\", Nearest, \"None\");\n    test::<f32>(\"-Infinity\", \"-Infinity\", Exact, \"None\");\n\n    test::<f32>(\"0.0\", \"0x0.0\", Floor, \"None\");\n    test::<f32>(\"0.0\", \"0x0.0\", Ceiling, \"None\");\n    test::<f32>(\"0.0\", \"0x0.0\", Down, \"None\");\n    test::<f32>(\"0.0\", \"0x0.0\", Up, \"None\");\n    test::<f32>(\"0.0\", \"0x0.0\", Nearest, \"None\");\n    test::<f32>(\"0.0\", \"0x0.0\", Exact, \"None\");\n\n    test::<f32>(\"-0.0\", \"-0x0.0\", Floor, \"None\");\n    test::<f32>(\"-0.0\", \"-0x0.0\", Ceiling, \"None\");\n    test::<f32>(\"-0.0\", \"-0x0.0\", Down, \"None\");\n    test::<f32>(\"-0.0\", \"-0x0.0\", Up, \"None\");\n    test::<f32>(\"-0.0\", \"-0x0.0\", Nearest, \"None\");\n    test::<f32>(\"-0.0\", \"-0x0.0\", Exact, \"None\");\n\n    test::<f32>(\"1.0\", \"0x1.0#1\", Floor, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"1.0\", \"0x1.0#1\", Ceiling, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"1.0\", \"0x1.0#1\", Down, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"1.0\", \"0x1.0#1\", Up, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"1.0\", \"0x1.0#1\", Nearest, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"1.0\", \"0x1.0#1\", Exact, \"Some(1.0, 0, Equal)\");\n\n    test::<f32>(\"123.0\", \"0x7b.0#7\", Floor, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"123.0\", \"0x7b.0#7\", Ceiling, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"123.0\", \"0x7b.0#7\", Down, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"123.0\", \"0x7b.0#7\", Up, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"123.0\", \"0x7b.0#7\", Nearest, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"123.0\", \"0x7b.0#7\", Exact, \"Some(1.921875, 6, Equal)\");\n\n    test::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Floor,\n        \"Some(1.3333333, -2, Less)\",\n    );\n    test::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Ceiling,\n        \"Some(1.3333334, -2, Greater)\",\n    );\n    test::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Down,\n        \"Some(1.3333333, -2, Less)\",\n    );\n    test::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Up,\n        \"Some(1.3333334, -2, Greater)\",\n    );\n    test::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Nearest,\n        \"Some(1.3333334, -2, Greater)\",\n    );\n    test::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f32>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Floor,\n        \"Some(1.5707963, 1, Less)\",\n    );\n    test::<f32>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Ceiling,\n        \"Some(1.5707964, 1, Greater)\",\n    );\n    test::<f32>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Down,\n        \"Some(1.5707963, 1, Less)\",\n    );\n    test::<f32>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Up,\n        \"Some(1.5707964, 1, Greater)\",\n    );\n    test::<f32>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Nearest,\n        \"Some(1.5707964, 1, Greater)\",\n    );\n    test::<f32>(\"3.141592653589793\", \"0x3.243f6a8885a3#50\", Exact, \"None\");\n\n    test::<f32>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Floor,\n        \"Some(1.8189894, 39, Less)\",\n    );\n    test::<f32>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Ceiling,\n        \"Some(1.8189895, 39, Greater)\",\n    );\n    test::<f32>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Down,\n        \"Some(1.8189894, 39, Less)\",\n    );\n    test::<f32>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Up,\n        \"Some(1.8189895, 39, Greater)\",\n    );\n    test::<f32>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Nearest,\n        \"Some(1.8189894, 39, Less)\",\n    );\n    test::<f32>(\"1000000000000.0\", \"0xe8d4a51000.0#40\", Exact, \"None\");\n\n    test::<f32>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Floor,\n        \"Some(1.6543611, 79, Less)\",\n    );\n    test::<f32>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Ceiling,\n        \"Some(1.6543612, 79, Greater)\",\n    );\n    test::<f32>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Down,\n        \"Some(1.6543611, 79, Less)\",\n    );\n    test::<f32>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Up,\n        \"Some(1.6543612, 79, Greater)\",\n    );\n    test::<f32>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Nearest,\n        \"Some(1.6543612, 79, Greater)\",\n    );\n    test::<f32>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f32>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Floor,\n        \"Some(1.9999999, -1, Less)\",\n    );\n    test::<f32>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Ceiling,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f32>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Down,\n        \"Some(1.9999999, -1, Less)\",\n    );\n    test::<f32>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Up,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f32>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Nearest,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f32>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Floor,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Ceiling,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Down,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Up,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Nearest,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Exact,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n\n    test::<f32>(\n        \"too_big\",\n        \"0x4.000001E+268435455#27\",\n        Floor,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.000001E+268435455#27\",\n        Ceiling,\n        \"Some(1.0000001, 1073741822, Greater)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.000001E+268435455#27\",\n        Down,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.000001E+268435455#27\",\n        Up,\n        \"Some(1.0000001, 1073741822, Greater)\",\n    );\n    test::<f32>(\n        \"too_big\",\n        \"0x4.000001E+268435455#27\",\n        Nearest,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f32>(\"too_big\", \"0x4.000001E+268435455#27\", Exact, \"None\");\n\n    test::<f32>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Floor,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Ceiling,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Down,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Up,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Nearest,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Exact,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n\n    test::<f32>(\"-1.0\", \"-0x1.0#1\", Floor, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"-1.0\", \"-0x1.0#1\", Ceiling, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"-1.0\", \"-0x1.0#1\", Down, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"-1.0\", \"-0x1.0#1\", Up, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"-1.0\", \"-0x1.0#1\", Nearest, \"Some(1.0, 0, Equal)\");\n    test::<f32>(\"-1.0\", \"-0x1.0#1\", Exact, \"Some(1.0, 0, Equal)\");\n\n    test::<f32>(\"-123.0\", \"-0x7b.0#7\", Floor, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"-123.0\", \"-0x7b.0#7\", Down, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"-123.0\", \"-0x7b.0#7\", Up, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"-123.0\", \"-0x7b.0#7\", Nearest, \"Some(1.921875, 6, Equal)\");\n    test::<f32>(\"-123.0\", \"-0x7b.0#7\", Exact, \"Some(1.921875, 6, Equal)\");\n\n    test::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Floor,\n        \"Some(1.3333333, -2, Less)\",\n    );\n    test::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Ceiling,\n        \"Some(1.3333334, -2, Greater)\",\n    );\n    test::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Down,\n        \"Some(1.3333333, -2, Less)\",\n    );\n    test::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Up,\n        \"Some(1.3333334, -2, Greater)\",\n    );\n    test::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Nearest,\n        \"Some(1.3333334, -2, Greater)\",\n    );\n    test::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f32>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Floor,\n        \"Some(1.5707963, 1, Less)\",\n    );\n    test::<f32>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Ceiling,\n        \"Some(1.5707964, 1, Greater)\",\n    );\n    test::<f32>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Down,\n        \"Some(1.5707963, 1, Less)\",\n    );\n    test::<f32>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Up,\n        \"Some(1.5707964, 1, Greater)\",\n    );\n    test::<f32>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Nearest,\n        \"Some(1.5707964, 1, Greater)\",\n    );\n    test::<f32>(\"-3.141592653589793\", \"-0x3.243f6a8885a3#50\", Exact, \"None\");\n\n    test::<f32>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Floor,\n        \"Some(1.8189894, 39, Less)\",\n    );\n    test::<f32>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Ceiling,\n        \"Some(1.8189895, 39, Greater)\",\n    );\n    test::<f32>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Down,\n        \"Some(1.8189894, 39, Less)\",\n    );\n    test::<f32>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Up,\n        \"Some(1.8189895, 39, Greater)\",\n    );\n    test::<f32>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Nearest,\n        \"Some(1.8189894, 39, Less)\",\n    );\n    test::<f32>(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", Exact, \"None\");\n\n    test::<f32>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Floor,\n        \"Some(1.6543611, 79, Less)\",\n    );\n    test::<f32>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Ceiling,\n        \"Some(1.6543612, 79, Greater)\",\n    );\n    test::<f32>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Down,\n        \"Some(1.6543611, 79, Less)\",\n    );\n    test::<f32>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Up,\n        \"Some(1.6543612, 79, Greater)\",\n    );\n    test::<f32>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Nearest,\n        \"Some(1.6543612, 79, Greater)\",\n    );\n    test::<f32>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f32>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Floor,\n        \"Some(1.9999999, -1, Less)\",\n    );\n    test::<f32>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Ceiling,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f32>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Down,\n        \"Some(1.9999999, -1, Less)\",\n    );\n    test::<f32>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Up,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f32>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Nearest,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f32>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Floor,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Ceiling,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Down,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Up,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Nearest,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Exact,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.000001E+268435455#27\",\n        Floor,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.000001E+268435455#27\",\n        Ceiling,\n        \"Some(1.0000001, 1073741822, Greater)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.000001E+268435455#27\",\n        Down,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.000001E+268435455#27\",\n        Up,\n        \"Some(1.0000001, 1073741822, Greater)\",\n    );\n    test::<f32>(\n        \"-too_big\",\n        \"-0x4.000001E+268435455#27\",\n        Nearest,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f32>(\"-too_big\", \"-0x4.000001E+268435455#27\", Exact, \"None\");\n\n    test::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Floor,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Ceiling,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Down,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Up,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Nearest,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Exact,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n\n    test::<f64>(\"NaN\", \"NaN\", Floor, \"None\");\n    test::<f64>(\"NaN\", \"NaN\", Ceiling, \"None\");\n    test::<f64>(\"NaN\", \"NaN\", Down, \"None\");\n    test::<f64>(\"NaN\", \"NaN\", Up, \"None\");\n    test::<f64>(\"NaN\", \"NaN\", Nearest, \"None\");\n    test::<f64>(\"NaN\", \"NaN\", Exact, \"None\");\n\n    test::<f64>(\"Infinity\", \"Infinity\", Floor, \"None\");\n    test::<f64>(\"Infinity\", \"Infinity\", Ceiling, \"None\");\n    test::<f64>(\"Infinity\", \"Infinity\", Down, \"None\");\n    test::<f64>(\"Infinity\", \"Infinity\", Up, \"None\");\n    test::<f64>(\"Infinity\", \"Infinity\", Nearest, \"None\");\n    test::<f64>(\"Infinity\", \"Infinity\", Exact, \"None\");\n\n    test::<f64>(\"-Infinity\", \"-Infinity\", Floor, \"None\");\n    test::<f64>(\"-Infinity\", \"-Infinity\", Ceiling, \"None\");\n    test::<f64>(\"-Infinity\", \"-Infinity\", Down, \"None\");\n    test::<f64>(\"-Infinity\", \"-Infinity\", Up, \"None\");\n    test::<f64>(\"-Infinity\", \"-Infinity\", Nearest, \"None\");\n    test::<f64>(\"-Infinity\", \"-Infinity\", Exact, \"None\");\n\n    test::<f64>(\"0.0\", \"0x0.0\", Floor, \"None\");\n    test::<f64>(\"0.0\", \"0x0.0\", Ceiling, \"None\");\n    test::<f64>(\"0.0\", \"0x0.0\", Down, \"None\");\n    test::<f64>(\"0.0\", \"0x0.0\", Up, \"None\");\n    test::<f64>(\"0.0\", \"0x0.0\", Nearest, \"None\");\n    test::<f64>(\"0.0\", \"0x0.0\", Exact, \"None\");\n\n    test::<f64>(\"-0.0\", \"-0x0.0\", Floor, \"None\");\n    test::<f64>(\"-0.0\", \"-0x0.0\", Ceiling, \"None\");\n    test::<f64>(\"-0.0\", \"-0x0.0\", Down, \"None\");\n    test::<f64>(\"-0.0\", \"-0x0.0\", Up, \"None\");\n    test::<f64>(\"-0.0\", \"-0x0.0\", Nearest, \"None\");\n    test::<f64>(\"-0.0\", \"-0x0.0\", Exact, \"None\");\n\n    test::<f64>(\"1.0\", \"0x1.0#1\", Floor, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"1.0\", \"0x1.0#1\", Ceiling, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"1.0\", \"0x1.0#1\", Down, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"1.0\", \"0x1.0#1\", Up, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"1.0\", \"0x1.0#1\", Nearest, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"1.0\", \"0x1.0#1\", Exact, \"Some(1.0, 0, Equal)\");\n\n    test::<f64>(\"123.0\", \"0x7b.0#7\", Floor, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"123.0\", \"0x7b.0#7\", Ceiling, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"123.0\", \"0x7b.0#7\", Down, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"123.0\", \"0x7b.0#7\", Up, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"123.0\", \"0x7b.0#7\", Nearest, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"123.0\", \"0x7b.0#7\", Exact, \"Some(1.921875, 6, Equal)\");\n\n    test::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Floor,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Ceiling,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Down,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Up,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Nearest,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Exact,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n\n    test::<f64>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Floor,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Ceiling,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Down,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Up,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Nearest,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        Exact,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n\n    test::<f64>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Floor,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Ceiling,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Down,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Up,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Nearest,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        Exact,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n\n    test::<f64>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Floor,\n        \"Some(1.6543612251060553, 79, Less)\",\n    );\n    test::<f64>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Ceiling,\n        \"Some(1.6543612251060555, 79, Greater)\",\n    );\n    test::<f64>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Down,\n        \"Some(1.6543612251060553, 79, Less)\",\n    );\n    test::<f64>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Up,\n        \"Some(1.6543612251060555, 79, Greater)\",\n    );\n    test::<f64>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Nearest,\n        \"Some(1.6543612251060553, 79, Less)\",\n    );\n    test::<f64>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f64>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Floor,\n        \"Some(1.9999999999999998, -1, Less)\",\n    );\n    test::<f64>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Ceiling,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f64>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Down,\n        \"Some(1.9999999999999998, -1, Less)\",\n    );\n    test::<f64>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Up,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f64>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Nearest,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f64>(\n        \"0.999999999999999999999999\",\n        \"0x0.ffffffffffffffffffff#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Floor,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Ceiling,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Down,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Up,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Nearest,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Exact,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0000000000001E+268435455#55\",\n        Floor,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0000000000001E+268435455#55\",\n        Ceiling,\n        \"Some(1.0000000000000002, 1073741822, Greater)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0000000000001E+268435455#55\",\n        Down,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0000000000001E+268435455#55\",\n        Up,\n        \"Some(1.0000000000000002, 1073741822, Greater)\",\n    );\n    test::<f64>(\n        \"too_big\",\n        \"0x4.0000000000001E+268435455#55\",\n        Nearest,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f64>(\"too_big\", \"0x4.0000000000001E+268435455#55\", Exact, \"None\");\n\n    test::<f64>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Floor,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Ceiling,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Down,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Up,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Nearest,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Exact,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n\n    test::<f64>(\"-1.0\", \"-0x1.0#1\", Floor, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"-1.0\", \"-0x1.0#1\", Ceiling, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"-1.0\", \"-0x1.0#1\", Down, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"-1.0\", \"-0x1.0#1\", Up, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"-1.0\", \"-0x1.0#1\", Nearest, \"Some(1.0, 0, Equal)\");\n    test::<f64>(\"-1.0\", \"-0x1.0#1\", Exact, \"Some(1.0, 0, Equal)\");\n\n    test::<f64>(\"-123.0\", \"-0x7b.0#7\", Floor, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"-123.0\", \"-0x7b.0#7\", Down, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"-123.0\", \"-0x7b.0#7\", Up, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"-123.0\", \"-0x7b.0#7\", Nearest, \"Some(1.921875, 6, Equal)\");\n    test::<f64>(\"-123.0\", \"-0x7b.0#7\", Exact, \"Some(1.921875, 6, Equal)\");\n\n    test::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Floor,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Ceiling,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Down,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Up,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Nearest,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n    test::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Exact,\n        \"Some(1.3333333333333333, -2, Equal)\",\n    );\n\n    test::<f64>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Floor,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Ceiling,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Down,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Up,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Nearest,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n    test::<f64>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        Exact,\n        \"Some(1.5707963267948966, 1, Equal)\",\n    );\n\n    test::<f64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Floor,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Ceiling,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Down,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Up,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Nearest,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n    test::<f64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        Exact,\n        \"Some(1.8189894035458565, 39, Equal)\",\n    );\n\n    test::<f64>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Floor,\n        \"Some(1.6543612251060553, 79, Less)\",\n    );\n    test::<f64>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Ceiling,\n        \"Some(1.6543612251060555, 79, Greater)\",\n    );\n    test::<f64>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Down,\n        \"Some(1.6543612251060553, 79, Less)\",\n    );\n    test::<f64>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Up,\n        \"Some(1.6543612251060555, 79, Greater)\",\n    );\n    test::<f64>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Nearest,\n        \"Some(1.6543612251060553, 79, Less)\",\n    );\n    test::<f64>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f64>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Floor,\n        \"Some(1.9999999999999998, -1, Less)\",\n    );\n    test::<f64>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Ceiling,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f64>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Down,\n        \"Some(1.9999999999999998, -1, Less)\",\n    );\n    test::<f64>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Up,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f64>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Nearest,\n        \"Some(1.0, 0, Greater)\",\n    );\n    test::<f64>(\n        \"-0.999999999999999999999999\",\n        \"-0x0.ffffffffffffffffffff#80\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Floor,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Ceiling,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Down,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Up,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Nearest,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Exact,\n        \"Some(1.0, 1073741822, Equal)\",\n    );\n\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0000000000001E+268435455#55\",\n        Floor,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0000000000001E+268435455#55\",\n        Ceiling,\n        \"Some(1.0000000000000002, 1073741822, Greater)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0000000000001E+268435455#55\",\n        Down,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0000000000001E+268435455#55\",\n        Up,\n        \"Some(1.0000000000000002, 1073741822, Greater)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0000000000001E+268435455#55\",\n        Nearest,\n        \"Some(1.0, 1073741822, Less)\",\n    );\n    test::<f64>(\n        \"-too_big\",\n        \"-0x4.0000000000001E+268435455#55\",\n        Exact,\n        \"None\",\n    );\n\n    test::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Floor,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Ceiling,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Down,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Up,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Nearest,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n    test::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Exact,\n        \"Some(1.0, -1073741824, Equal)\",\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_raw_mantissa_and_exponent() {\n    let test = |s, s_hex, m_out, e_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (m, e) = x.clone().raw_mantissa_and_exponent();\n        assert_eq!(m.to_string(), m_out);\n        assert_eq!(e, e_out);\n\n        let (m_alt, e_alt) = (&x).raw_mantissa_and_exponent();\n        assert_eq!(m_alt, m);\n        assert_eq!(e_alt, e);\n\n        assert_eq!(x.clone().raw_mantissa(), m);\n        assert_eq!((&x).raw_mantissa(), m);\n        assert_eq!(x.clone().raw_exponent(), e);\n        assert_eq!((&x).raw_exponent(), e);\n    };\n    test(\"1.0\", \"0x1.0#1\", \"9223372036854775808\", 1);\n    test(\"2.0\", \"0x2.0#1\", \"9223372036854775808\", 2);\n    test(\"0.5\", \"0x0.8#1\", \"9223372036854775808\", 0);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"12297829382473033728\",\n        -1,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"17726168133330272256\", 7);\n    test(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        \"16777216000000000000\",\n        40,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"13043817825332783104\",\n        1,\n    );\n    test(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        \"14488038916154245120\",\n        2,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        \"12535862302449813504\",\n        2,\n    );\n    test(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        \"281474976710656000000000000000000000000\",\n        80,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"9223372036854775808\",\n        1073741823,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"9223372036854775808\",\n        -1073741823,\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"9223372036854775808\", 1);\n    test(\"-2.0\", \"-0x2.0#1\", \"9223372036854775808\", 2);\n    test(\"-0.5\", \"-0x0.8#1\", \"9223372036854775808\", 0);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"12297829382473033728\",\n        -1,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"17726168133330272256\", 7);\n    test(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        \"16777216000000000000\",\n        40,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"13043817825332783104\",\n        1,\n    );\n    test(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        \"14488038916154245120\",\n        2,\n    );\n    test(\n        \"-2.7182818284590451\",\n        \"-0x2.b7e151628aed2#53\",\n        \"12535862302449813504\",\n        2,\n    );\n    test(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        \"281474976710656000000000000000000000000\",\n        80,\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"9223372036854775808\",\n        1073741823,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"9223372036854775808\",\n        -1073741823,\n    );\n}\n\n#[test]\nfn raw_mantissa_and_exponent_fail() {\n    assert_panic!(Float::NAN.raw_mantissa_and_exponent());\n    assert_panic!(Float::INFINITY.raw_mantissa_and_exponent());\n    assert_panic!(Float::NEGATIVE_INFINITY.raw_mantissa_and_exponent());\n    assert_panic!(Float::ZERO.raw_mantissa_and_exponent());\n    assert_panic!(Float::NEGATIVE_ZERO.raw_mantissa_and_exponent());\n\n    assert_panic!(Float::NAN.raw_mantissa());\n    assert_panic!(Float::INFINITY.raw_mantissa());\n    assert_panic!(Float::NEGATIVE_INFINITY.raw_mantissa());\n    assert_panic!(Float::ZERO.raw_mantissa());\n    assert_panic!(Float::NEGATIVE_ZERO.raw_mantissa());\n\n    assert_panic!(Float::NAN.raw_exponent());\n    assert_panic!(Float::INFINITY.raw_exponent());\n    assert_panic!(Float::NEGATIVE_INFINITY.raw_exponent());\n    assert_panic!(Float::ZERO.raw_exponent());\n    assert_panic!(Float::NEGATIVE_ZERO.raw_exponent());\n}\n\n#[test]\nfn raw_mantissa_and_exponent_ref_fail() {\n    assert_panic!((&Float::NAN).raw_mantissa_and_exponent());\n    assert_panic!((&Float::INFINITY).raw_mantissa_and_exponent());\n    assert_panic!((&Float::NEGATIVE_INFINITY).raw_mantissa_and_exponent());\n    assert_panic!((&Float::ZERO).raw_mantissa_and_exponent());\n    assert_panic!((&Float::NEGATIVE_ZERO).raw_mantissa_and_exponent());\n\n    assert_panic!((&Float::NAN).raw_mantissa());\n    assert_panic!((&Float::INFINITY).raw_mantissa());\n    assert_panic!((&Float::NEGATIVE_INFINITY).raw_mantissa());\n    assert_panic!((&Float::ZERO).raw_mantissa());\n    assert_panic!((&Float::NEGATIVE_ZERO).raw_mantissa());\n\n    assert_panic!((&Float::NAN).raw_exponent());\n    assert_panic!((&Float::INFINITY).raw_exponent());\n    assert_panic!((&Float::NEGATIVE_INFINITY).raw_exponent());\n    assert_panic!((&Float::ZERO).raw_exponent());\n    assert_panic!((&Float::NEGATIVE_ZERO).raw_exponent());\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_from_raw_mantissa_and_exponent() {\n    let test = |m, e, out, out_hex| {\n        let m = Natural::from_str(m).unwrap();\n        let x = Float::from_raw_mantissa_and_exponent(m.clone(), e);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(to_hex_string(&x), out_hex);\n\n        let x_alt =\n            <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(m, e);\n        assert!(x_alt.is_valid());\n        assert_eq!(x_alt, x);\n    };\n    test(\"9223372036854775808\", 1, \"1.0\", \"0x1.0#1\");\n    test(\n        \"9223372036854775809\",\n        1,\n        \"1.0000000000000000001\",\n        \"0x1.0000000000000002#64\",\n    );\n    test(\n        \"18446744073709551615\",\n        1,\n        \"1.9999999999999999999\",\n        \"0x1.fffffffffffffffe#64\",\n    );\n    test(\n        \"170141183460469231731687303715884105728\",\n        1,\n        \"1.0\",\n        \"0x1.0000000000000000#65\",\n    );\n\n    test(\"9223372036854775808\", 2, \"2.0\", \"0x2.0#1\");\n    test(\"9223372036854775808\", 0, \"0.5\", \"0x0.8#1\");\n    test(\n        \"12297829382473033728\",\n        -1,\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n    );\n    test(\"17726168133330272256\", 7, \"123.0\", \"0x7b.0#7\");\n    test(\"16777216000000000000\", 40, \"1.0e12\", \"0xe.8d4a51E+9#28\");\n    test(\n        \"13043817825332783104\",\n        1,\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n    );\n    test(\n        \"14488038916154245120\",\n        2,\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n    );\n    test(\n        \"12535862302449813504\",\n        2,\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n    );\n    test(\n        \"281474976710656000000000000000000000000\",\n        80,\n        \"1.0e24\",\n        \"0xd.3c21bcecceda1000E+19#65\",\n    );\n    test(\n        \"9223372036854775808\",\n        1073741823,\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n    );\n    test(\n        \"9223372036854775808\",\n        -1073741823,\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n    );\n}\n\n#[test]\nfn from_raw_mantissa_and_exponent_float_fail() {\n    assert_panic!(Float::from_raw_mantissa_and_exponent(Natural::ZERO, 0));\n    assert_panic!(Float::from_raw_mantissa_and_exponent(Natural::ONE, 0));\n    assert_panic!(Float::from_raw_mantissa_and_exponent(\n        Natural::from_str(\"9223372036854775808\").unwrap(),\n        1073741824\n    ));\n    assert_panic!(Float::from_raw_mantissa_and_exponent(\n        Natural::from_str(\"9223372036854775808\").unwrap(),\n        -1073741824\n    ));\n\n    assert_panic!(\n        <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n            Natural::ZERO,\n            0\n        )\n    );\n    assert_panic!(\n        <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n            Natural::ONE,\n            0\n        )\n    );\n    assert_panic!(\n        <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n            Natural::from_str(\"9223372036854775808\").unwrap(),\n            1073741824\n        )\n    );\n    assert_panic!(\n        <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n            Natural::from_str(\"9223372036854775808\").unwrap(),\n            -1073741824\n        )\n    );\n}\n\n#[test]\nfn test_integer_mantissa_and_exponent() {\n    let test = |s, s_hex, m_out, e_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (m, e) = x.clone().integer_mantissa_and_exponent();\n        assert_eq!(m.to_string(), m_out);\n        assert_eq!(e, e_out);\n\n        let (m_alt, e_alt) = (&x).integer_mantissa_and_exponent();\n        assert_eq!(m_alt, m);\n        assert_eq!(e_alt, e);\n\n        assert_eq!(x.clone().integer_mantissa(), m);\n        assert_eq!((&x).integer_mantissa(), m);\n        assert_eq!(x.clone().integer_exponent(), e);\n        assert_eq!((&x).integer_exponent(), e);\n    };\n    test(\"1.0\", \"0x1.0#1\", \"1\", 0);\n    test(\"2.0\", \"0x2.0#1\", \"1\", 1);\n    test(\"0.5\", \"0x0.8#1\", \"1\", -1);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"6004799503160661\",\n        -54,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"123\", 0);\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", \"244140625\", 12);\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"6369051672525773\",\n        -52,\n    );\n    test(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        \"884279719003555\",\n        -48,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        \"6121026514868073\",\n        -51,\n    );\n    test(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        \"59604644775390625\",\n        24,\n    );\n    test(\"too_big\", \"0x4.0E+268435455#1\", \"1\", 1073741822);\n    test(\"too_small\", \"0x1.0E-268435456#1\", \"1\", -1073741824);\n    test(\n        \"too_small\",\n        \"0x1.0000001E-268435456#29\",\n        \"268435457\",\n        -1073741852,\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"1\", 0);\n    test(\"-2.0\", \"-0x2.0#1\", \"1\", 1);\n    test(\"-0.5\", \"-0x0.8#1\", \"1\", -1);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"6004799503160661\",\n        -54,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"123\", 0);\n    test(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", \"244140625\", 12);\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"6369051672525773\",\n        -52,\n    );\n    test(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        \"884279719003555\",\n        -48,\n    );\n    test(\n        \"-2.7182818284590451\",\n        \"-0x2.b7e151628aed2#53\",\n        \"6121026514868073\",\n        -51,\n    );\n    test(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        \"59604644775390625\",\n        24,\n    );\n    test(\"-too_big\", \"-0x4.0E+268435455#1\", \"1\", 1073741822);\n    test(\"-too_small\", \"-0x1.0E-268435456#1\", \"1\", -1073741824);\n    test(\n        \"-too_small\",\n        \"-0x1.0000001E-268435456#29\",\n        \"268435457\",\n        -1073741852,\n    );\n}\n\n#[test]\nfn integer_mantissa_and_exponent_fail() {\n    assert_panic!(Float::NAN.integer_mantissa_and_exponent());\n    assert_panic!(Float::INFINITY.integer_mantissa_and_exponent());\n    assert_panic!(Float::NEGATIVE_INFINITY.integer_mantissa_and_exponent());\n    assert_panic!(Float::ZERO.integer_mantissa_and_exponent());\n    assert_panic!(Float::NEGATIVE_ZERO.integer_mantissa_and_exponent());\n\n    assert_panic!(Float::NAN.integer_mantissa());\n    assert_panic!(Float::INFINITY.integer_mantissa());\n    assert_panic!(Float::NEGATIVE_INFINITY.integer_mantissa());\n    assert_panic!(Float::ZERO.integer_mantissa());\n    assert_panic!(Float::NEGATIVE_ZERO.integer_mantissa());\n\n    assert_panic!(Float::NAN.integer_exponent());\n    assert_panic!(Float::INFINITY.integer_exponent());\n    assert_panic!(Float::NEGATIVE_INFINITY.integer_exponent());\n    assert_panic!(Float::ZERO.integer_exponent());\n    assert_panic!(Float::NEGATIVE_ZERO.integer_exponent());\n}\n\n#[test]\nfn integer_mantissa_and_exponent_ref_fail() {\n    assert_panic!((&Float::NAN).integer_mantissa_and_exponent());\n    assert_panic!((&Float::INFINITY).integer_mantissa_and_exponent());\n    assert_panic!((&Float::NEGATIVE_INFINITY).integer_mantissa_and_exponent());\n    assert_panic!((&Float::ZERO).integer_mantissa_and_exponent());\n    assert_panic!((&Float::NEGATIVE_ZERO).integer_mantissa_and_exponent());\n\n    assert_panic!((&Float::NAN).integer_mantissa());\n    assert_panic!((&Float::INFINITY).integer_mantissa());\n    assert_panic!((&Float::NEGATIVE_INFINITY).integer_mantissa());\n    assert_panic!((&Float::ZERO).integer_mantissa());\n    assert_panic!((&Float::NEGATIVE_ZERO).integer_mantissa());\n\n    assert_panic!((&Float::NAN).integer_exponent());\n    assert_panic!((&Float::INFINITY).integer_exponent());\n    assert_panic!((&Float::NEGATIVE_INFINITY).integer_exponent());\n    assert_panic!((&Float::ZERO).integer_exponent());\n    assert_panic!((&Float::NEGATIVE_ZERO).integer_exponent());\n}\n\n#[test]\nfn test_from_integer_mantissa_and_exponent() {\n    let test = |m, e, out, out_hex| {\n        let m = Natural::from_str(m).unwrap();\n        let ox = Float::from_integer_mantissa_and_exponent(m.clone(), e);\n        assert!(ox.as_ref().is_none_or(Float::is_valid));\n        let os = ox.as_ref().map(ToString::to_string);\n        assert_eq!(os.as_deref(), out);\n        let os = ox.as_ref().map(to_hex_string);\n        assert_eq!(os.as_deref(), out_hex);\n\n        let ox_alt =\n            <&Float as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n                m, e,\n            );\n        assert!(ox_alt.as_ref().is_none_or(Float::is_valid));\n        assert_eq!(ox_alt, ox);\n    };\n    test(\"0\", 0, Some(\"0.0\"), Some(\"0x0.0\"));\n    test(\"0\", 10, Some(\"0.0\"), Some(\"0x0.0\"));\n    test(\"0\", -10, Some(\"0.0\"), Some(\"0x0.0\"));\n    test(\"1\", 0, Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test(\"1\", 1, Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test(\"1\", -1, Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test(\"2\", -1, Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test(\"2\", 0, Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test(\"2\", -2, Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test(\n        \"6004799503160661\",\n        -54,\n        Some(\"0.33333333333333331\"),\n        Some(\"0x0.55555555555554#53\"),\n    );\n    test(\"123\", 0, Some(\"123.0\"), Some(\"0x7b.0#7\"));\n    test(\"244140625\", 12, Some(\"1.0e12\"), Some(\"0xe.8d4a51E+9#28\"));\n    test(\n        \"6369051672525773\",\n        -52,\n        Some(\"1.4142135623730951\"),\n        Some(\"0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"884279719003555\",\n        -48,\n        Some(\"3.141592653589793\"),\n        Some(\"0x3.243f6a8885a3#50\"),\n    );\n    test(\n        \"6121026514868073\",\n        -51,\n        Some(\"2.7182818284590451\"),\n        Some(\"0x2.b7e151628aed2#53\"),\n    );\n    test(\n        \"59604644775390625\",\n        24,\n        Some(\"1.0e24\"),\n        Some(\"0xd.3c21bcecceda1E+19#56\"),\n    );\n    test(\"1\", 1073741822, Some(\"too_big\"), Some(\"0x4.0E+268435455#1\"));\n    test(\n        \"1\",\n        -1073741824,\n        Some(\"too_small\"),\n        Some(\"0x1.0E-268435456#1\"),\n    );\n    test(\n        \"268435457\",\n        -1073741852,\n        Some(\"too_small\"),\n        Some(\"0x1.0000001E-268435456#29\"),\n    );\n    test(\"1\", 1073741823, None, None);\n    test(\"1\", -1073741852, None, None);\n}\n\n#[test]\nfn test_sci_mantissa_and_exponent_float() {\n    let test = |s, s_hex, m_out, m_out_hex, e_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (m, e) = x.clone().sci_mantissa_and_exponent();\n        assert!(m.is_valid());\n        assert_eq!(m.to_string(), m_out);\n        assert_eq!(to_hex_string(&m), m_out_hex);\n        assert_eq!(e, e_out);\n\n        let (m_alt, e_alt): (Float, i32) = (&x).sci_mantissa_and_exponent();\n        assert!(m_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&m_alt), ComparableFloatRef(&m));\n        assert_eq!(e_alt, e);\n\n        let mantissa_alt: Float = x.clone().sci_mantissa();\n        assert!(mantissa_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&mantissa_alt), ComparableFloatRef(&m));\n        let mantissa_alt: Float = (&x).sci_mantissa();\n        assert!(mantissa_alt.is_valid());\n        assert_eq!(ComparableFloatRef(&mantissa_alt), ComparableFloatRef(&m));\n        assert_eq!(x.clone().sci_exponent(), e);\n        assert_eq!(\n            <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&x),\n            e\n        );\n    };\n    test(\"1.0\", \"0x1.0#1\", \"1.0\", \"0x1.0#1\", 0);\n    test(\"2.0\", \"0x2.0#1\", \"1.0\", \"0x1.0#1\", 1);\n    test(\"0.5\", \"0x0.8#1\", \"1.0\", \"0x1.0#1\", -1);\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1.3333333333333333\",\n        \"0x1.5555555555555#53\",\n        -2,\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"1.92\", \"0x1.ec#7\", 6);\n    test(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        \"1.818989403546\",\n        \"0x1.d1a94a2000#40\",\n        39,\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n    );\n    test(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        \"1.570796326794897\",\n        \"0x1.921fb54442d18#50\",\n        1,\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        \"1.3591409142295225\",\n        \"0x1.5bf0a8b145769#53\",\n        1,\n    );\n    test(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        \"1.654361225106055349742817\",\n        \"0x1.a784379d99db42000000#80\",\n        79,\n    );\n    test(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1073741822,\n    );\n    test(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        -1073741824,\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"1.0\", \"0x1.0#1\", 0);\n    test(\"-2.0\", \"-0x2.0#1\", \"1.0\", \"0x1.0#1\", 1);\n    test(\"-0.5\", \"-0x0.8#1\", \"1.0\", \"0x1.0#1\", -1);\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1.3333333333333333\",\n        \"0x1.5555555555555#53\",\n        -2,\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"1.92\", \"0x1.ec#7\", 6);\n    test(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        \"1.818989403546\",\n        \"0x1.d1a94a2000#40\",\n        39,\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n    );\n    test(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        \"1.570796326794897\",\n        \"0x1.921fb54442d18#50\",\n        1,\n    );\n    test(\n        \"-2.7182818284590451\",\n        \"-0x2.b7e151628aed2#53\",\n        \"1.3591409142295225\",\n        \"0x1.5bf0a8b145769#53\",\n        1,\n    );\n    test(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        \"1.654361225106055349742817\",\n        \"0x1.a784379d99db42000000#80\",\n        79,\n    );\n    test(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        1073741822,\n    );\n    test(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        \"1.0\",\n        \"0x1.0#1\",\n        -1073741824,\n    );\n}\n\n#[test]\nfn sci_mantissa_and_exponent_float_fail() {\n    assert_panic!(Float::NAN.sci_mantissa_and_exponent());\n    assert_panic!(Float::INFINITY.sci_mantissa_and_exponent());\n    assert_panic!(Float::NEGATIVE_INFINITY.sci_mantissa_and_exponent());\n    assert_panic!(Float::ZERO.sci_mantissa_and_exponent());\n    assert_panic!(Float::NEGATIVE_ZERO.sci_mantissa_and_exponent());\n\n    assert_panic!(Float::NAN.sci_mantissa());\n    assert_panic!(Float::INFINITY.sci_mantissa());\n    assert_panic!(Float::NEGATIVE_INFINITY.sci_mantissa());\n    assert_panic!(Float::ZERO.sci_mantissa());\n    assert_panic!(Float::NEGATIVE_ZERO.sci_mantissa());\n\n    assert_panic!(Float::NAN.sci_exponent());\n    assert_panic!(Float::INFINITY.sci_exponent());\n    assert_panic!(Float::NEGATIVE_INFINITY.sci_exponent());\n    assert_panic!(Float::ZERO.sci_exponent());\n    assert_panic!(Float::NEGATIVE_ZERO.sci_exponent());\n}\n\n#[test]\nfn sci_mantissa_and_exponent_float_ref_fail() {\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa_and_exponent(&Float::NAN)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa_and_exponent(\n            &Float::INFINITY\n        )\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa_and_exponent(\n            &Float::NEGATIVE_INFINITY\n        )\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa_and_exponent(&Float::ZERO)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa_and_exponent(\n            &Float::NEGATIVE_ZERO\n        )\n    );\n\n    assert_panic!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa(&Float::NAN));\n    assert_panic!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa(&Float::INFINITY));\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa(&Float::NEGATIVE_INFINITY)\n    );\n    assert_panic!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa(&Float::ZERO));\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa(&Float::NEGATIVE_ZERO)\n    );\n\n    assert_panic!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::NAN));\n    assert_panic!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::INFINITY));\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::NEGATIVE_INFINITY)\n    );\n    assert_panic!(<&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::ZERO));\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&Float::NEGATIVE_ZERO)\n    );\n}\n\n#[test]\nfn test_from_sci_mantissa_and_exponent_float() {\n    let test = |ms, ms_hex, e, out, out_hex| {\n        let m = parse_hex_string(ms_hex);\n        assert_eq!(m.to_string(), ms);\n        let ox = Float::from_sci_mantissa_and_exponent(m.clone(), e);\n        assert!(ox.as_ref().is_none_or(Float::is_valid));\n        let os = ox.as_ref().map(ToString::to_string);\n        assert_eq!(os.as_deref(), out);\n        let os = ox.as_ref().map(to_hex_string);\n        assert_eq!(os.as_deref(), out_hex);\n\n        let ox_alt =\n            <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e);\n        assert!(ox_alt.as_ref().is_none_or(Float::is_valid));\n        assert_eq!(ox_alt, ox);\n    };\n    test(\"1.0\", \"0x1.0#1\", 0, Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test(\"1.0\", \"0x1.0#1\", 1, Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test(\"1.0\", \"0x1.0#1\", -1, Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test(\n        \"1.3333333333333333\",\n        \"0x1.5555555555555#53\",\n        -2,\n        Some(\"0.33333333333333331\"),\n        Some(\"0x0.55555555555554#53\"),\n    );\n    test(\"1.92\", \"0x1.ec#7\", 6, Some(\"123.0\"), Some(\"0x7b.0#7\"));\n    test(\n        \"1.818989403546\",\n        \"0x1.d1a94a2000#40\",\n        39,\n        Some(\"1000000000000.0\"),\n        Some(\"0xe8d4a51000.0#40\"),\n    );\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        0,\n        Some(\"1.4142135623730951\"),\n        Some(\"0x1.6a09e667f3bcd#53\"),\n    );\n    test(\n        \"1.570796326794897\",\n        \"0x1.921fb54442d18#50\",\n        1,\n        Some(\"3.141592653589793\"),\n        Some(\"0x3.243f6a8885a3#50\"),\n    );\n    test(\n        \"1.3591409142295225\",\n        \"0x1.5bf0a8b145769#53\",\n        1,\n        Some(\"2.7182818284590451\"),\n        Some(\"0x2.b7e151628aed2#53\"),\n    );\n    test(\n        \"1.654361225106055349742817\",\n        \"0x1.a784379d99db42000000#80\",\n        79,\n        Some(\"1000000000000000000000000.0\"),\n        Some(\"0xd3c21bcecceda1000000.0#80\"),\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        1073741822,\n        Some(\"too_big\"),\n        Some(\"0x4.0E+268435455#1\"),\n    );\n    test(\n        \"1.0\",\n        \"0x1.0#1\",\n        -1073741824,\n        Some(\"too_small\"),\n        Some(\"0x1.0E-268435456#1\"),\n    );\n    test(\"1.0\", \"0x1.0#1\", 1073741823, None, None);\n    test(\"1.0\", \"0x1.0#1\", -1073741825, None, None);\n\n    test(\"-1.0\", \"-0x1.0#1\", 0, None, None);\n    test(\"2.0\", \"0x2.0#1\", 0, None, None);\n    test(\"0.5\", \"0x0.8#1\", 0, None, None);\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_float_fail() {\n    assert_panic!(Float::from_sci_mantissa_and_exponent(Float::NAN, 0));\n    assert_panic!(Float::from_sci_mantissa_and_exponent(Float::INFINITY, 0));\n    assert_panic!(Float::from_sci_mantissa_and_exponent(\n        Float::NEGATIVE_INFINITY,\n        0\n    ));\n    assert_panic!(Float::from_sci_mantissa_and_exponent(Float::ZERO, 0));\n    assert_panic!(Float::from_sci_mantissa_and_exponent(\n        Float::NEGATIVE_ZERO,\n        0\n    ));\n}\n\n#[test]\nfn test_sci_mantissa_and_exponent_primitive_float() {\n    fn test<T: PrimitiveFloat>(s: &str, s_hex: &str, m_out: &str, e_out: i32)\n    where\n        for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (m, e): (T, i32) = (&x).sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(m).to_string(), m_out);\n        assert_eq!(e, e_out);\n\n        assert_eq!(NiceFloat((&x).sci_mantissa()), NiceFloat(m));\n        assert_eq!(\n            <&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(&x),\n            e\n        );\n    }\n    test::<f32>(\"1.0\", \"0x1.0#1\", \"1.0\", 0);\n    test::<f32>(\"2.0\", \"0x2.0#1\", \"1.0\", 1);\n    test::<f32>(\"0.5\", \"0x0.8#1\", \"1.0\", -1);\n    test::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1.3333334\",\n        -2,\n    );\n    test::<f32>(\"123.0\", \"0x7b.0#7\", \"1.921875\", 6);\n    test::<f32>(\"1000000000000.0\", \"0xe8d4a51000.0#40\", \"1.8189894\", 39);\n    test::<f32>(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", \"1.4142135\", 0);\n    test::<f32>(\"3.141592653589793\", \"0x3.243f6a8885a3#50\", \"1.5707964\", 1);\n    test::<f32>(\"2.7182818284590451\", \"0x2.b7e151628aed2#53\", \"1.3591409\", 1);\n    test::<f32>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        \"1.6543612\",\n        79,\n    );\n    test::<f32>(\"too_big\", \"0x4.0E+268435455#1\", \"1.0\", 1073741822);\n    test::<f32>(\"too_small\", \"0x1.0E-268435456#1\", \"1.0\", -1073741824);\n\n    test::<f32>(\"-1.0\", \"-0x1.0#1\", \"1.0\", 0);\n    test::<f32>(\"-2.0\", \"-0x2.0#1\", \"1.0\", 1);\n    test::<f32>(\"-0.5\", \"-0x0.8#1\", \"1.0\", -1);\n    test::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1.3333334\",\n        -2,\n    );\n    test::<f32>(\"-123.0\", \"-0x7b.0#7\", \"1.921875\", 6);\n    test::<f32>(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", \"1.8189894\", 39);\n    test::<f32>(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1.4142135\",\n        0,\n    );\n    test::<f32>(\"-3.141592653589793\", \"-0x3.243f6a8885a3#50\", \"1.5707964\", 1);\n    test::<f32>(\n        \"-2.7182818284590451\",\n        \"-0x2.b7e151628aed2#53\",\n        \"1.3591409\",\n        1,\n    );\n    test::<f32>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        \"1.6543612\",\n        79,\n    );\n\n    test::<f64>(\"1.0\", \"0x1.0#1\", \"1.0\", 0);\n    test::<f64>(\"2.0\", \"0x2.0#1\", \"1.0\", 1);\n    test::<f64>(\"0.5\", \"0x0.8#1\", \"1.0\", -1);\n    test::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"1.3333333333333333\",\n        -2,\n    );\n    test::<f64>(\"123.0\", \"0x7b.0#7\", \"1.921875\", 6);\n    test::<f64>(\n        \"1000000000000.0\",\n        \"0xe8d4a51000.0#40\",\n        \"1.8189894035458565\",\n        39,\n    );\n    test::<f64>(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        0,\n    );\n    test::<f64>(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        \"1.5707963267948966\",\n        1,\n    );\n    test::<f64>(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        \"1.3591409142295225\",\n        1,\n    );\n    test::<f64>(\n        \"1000000000000000000000000.0\",\n        \"0xd3c21bcecceda1000000.0#80\",\n        \"1.6543612251060553\",\n        79,\n    );\n\n    test::<f64>(\"-1.0\", \"-0x1.0#1\", \"1.0\", 0);\n    test::<f64>(\"-2.0\", \"-0x2.0#1\", \"1.0\", 1);\n    test::<f64>(\"-0.5\", \"-0x0.8#1\", \"1.0\", -1);\n    test::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"1.3333333333333333\",\n        -2,\n    );\n    test::<f64>(\"-123.0\", \"-0x7b.0#7\", \"1.921875\", 6);\n    test::<f64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        \"1.8189894035458565\",\n        39,\n    );\n    test::<f64>(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"1.4142135623730951\",\n        0,\n    );\n    test::<f64>(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        \"1.5707963267948966\",\n        1,\n    );\n    test::<f64>(\n        \"-2.7182818284590451\",\n        \"-0x2.b7e151628aed2#53\",\n        \"1.3591409142295225\",\n        1,\n    );\n    test::<f64>(\n        \"-1000000000000000000000000.0\",\n        \"-0xd3c21bcecceda1000000.0#80\",\n        \"1.6543612251060553\",\n        79,\n    );\n    test::<f32>(\"-too_big\", \"-0x4.0E+268435455#1\", \"1.0\", 1073741822);\n    test::<f32>(\"-too_small\", \"-0x1.0E-268435456#1\", \"1.0\", -1073741824);\n}\n\nfn sci_mantissa_and_exponent_primitive_float_fail_helper<T: PrimitiveFloat>()\nwhere\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa_and_exponent(&Float::NAN)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa_and_exponent(&Float::INFINITY)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa_and_exponent(\n            &Float::NEGATIVE_INFINITY\n        )\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa_and_exponent(&Float::ZERO)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa_and_exponent(\n            &Float::NEGATIVE_ZERO\n        )\n    );\n\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa(\n        &Float::NAN\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa(\n        &Float::INFINITY\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa(\n        &Float::NEGATIVE_INFINITY\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa(\n        &Float::ZERO\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa(\n        &Float::NEGATIVE_ZERO\n    ));\n\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(\n        &Float::NAN\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(\n        &Float::INFINITY\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(\n        &Float::NEGATIVE_INFINITY\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(\n        &Float::ZERO\n    ));\n    assert_panic!(<&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(\n        &Float::NEGATIVE_ZERO\n    ));\n}\n\n#[test]\nfn sci_mantissa_and_exponent_primitive_float_fail() {\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_primitive_float_fail_helper);\n}\n\n#[test]\nfn test_from_sci_mantissa_and_exponent_primitive_float() {\n    fn test<T: PrimitiveFloat>(m: T, e: i32, out: Option<&str>, out_hex: Option<&str>)\n    where\n        for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n    {\n        let ox = <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e);\n        assert!(ox.as_ref().is_none_or(Float::is_valid));\n        let os = ox.as_ref().map(ToString::to_string);\n        assert_eq!(os.as_deref(), out);\n        let os = ox.as_ref().map(to_hex_string);\n        assert_eq!(os.as_deref(), out_hex);\n    }\n    test::<f32>(1.0, 0, Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test::<f32>(1.0, 1, Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test::<f32>(1.0, -1, Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test::<f32>(1.3333334, -2, Some(\"0.33333334\"), Some(\"0x0.5555558#24\"));\n    test::<f32>(1.921875, 6, Some(\"123.0\"), Some(\"0x7b.0#7\"));\n    test::<f32>(1.8189894, 39, Some(\"1.0e12\"), Some(\"0xe.8d4a5E+9#24\"));\n    test::<f32>(\n        std::f32::consts::SQRT_2,\n        0,\n        Some(\"1.4142135\"),\n        Some(\"0x1.6a09e6#24\"),\n    );\n    test::<f32>(1.5707964, 1, Some(\"3.1415927\"), Some(\"0x3.243f6c#24\"));\n    test::<f32>(1.3591409, 1, Some(\"2.718282\"), Some(\"0x2.b7e15#22\"));\n    test::<f32>(1.6543612, 79, Some(\"1.0e24\"), Some(\"0xd.3c21cE+19#22\"));\n    test(1.0, 1073741822, Some(\"too_big\"), Some(\"0x4.0E+268435455#1\"));\n    test(1.0, 1073741823, None, None);\n    test(\n        1.0,\n        -1073741824,\n        Some(\"too_small\"),\n        Some(\"0x1.0E-268435456#1\"),\n    );\n    test(1.0, -1073741825, None, None);\n\n    test::<f32>(-1.0, 0, None, None);\n    test::<f32>(2.0, 0, None, None);\n    test::<f32>(0.5, 0, None, None);\n\n    test::<f64>(1.0, 0, Some(\"1.0\"), Some(\"0x1.0#1\"));\n    test::<f64>(1.0, 1, Some(\"2.0\"), Some(\"0x2.0#1\"));\n    test::<f64>(1.0, -1, Some(\"0.5\"), Some(\"0x0.8#1\"));\n    test::<f64>(\n        1.3333333333333333,\n        -2,\n        Some(\"0.33333333333333331\"),\n        Some(\"0x0.55555555555554#53\"),\n    );\n    test::<f64>(1.921875, 6, Some(\"123.0\"), Some(\"0x7b.0#7\"));\n    test::<f64>(\n        1.8189894035458565,\n        39,\n        Some(\"1.0e12\"),\n        Some(\"0xe.8d4a51E+9#28\"),\n    );\n    test::<f64>(\n        std::f64::consts::SQRT_2,\n        0,\n        Some(\"1.4142135623730951\"),\n        Some(\"0x1.6a09e667f3bcd#53\"),\n    );\n    test::<f64>(\n        std::f64::consts::FRAC_PI_2,\n        1,\n        Some(\"3.141592653589793\"),\n        Some(\"0x3.243f6a8885a3#50\"),\n    );\n    test::<f64>(\n        1.3591409142295225,\n        1,\n        Some(\"2.7182818284590451\"),\n        Some(\"0x2.b7e151628aed2#53\"),\n    );\n    test::<f64>(\n        1.6543612251060553,\n        79,\n        Some(\"1.0e24\"),\n        Some(\"0xd.3c21bceccedaE+19#51\"),\n    );\n\n    test::<f64>(-1.0, 0, None, None);\n    test::<f64>(2.0, 0, None, None);\n    test::<f64>(0.5, 0, None, None);\n}\n\nfn from_sci_mantissa_and_exponent_primitive_float_fail_helper<T: PrimitiveFloat>()\nwhere\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n{\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(T::NAN, 0)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(T::INFINITY, 0)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n            T::NEGATIVE_INFINITY,\n            0\n        )\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(T::ZERO, 0)\n    );\n    assert_panic!(\n        <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n            T::NEGATIVE_ZERO,\n            0\n        )\n    );\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_primitive_float_fail() {\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_primitive_float_fail_helper);\n}\n\nfn raw_mantissa_and_exponent_properties_helper(x: Float) {\n    let (mantissa, exponent) = x.clone().raw_mantissa_and_exponent();\n    let (mantissa_alt, exponent_alt) = (&x).raw_mantissa_and_exponent();\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(exponent_alt, exponent);\n    let (mantissa_alt, exponent_alt) = (-&x).raw_mantissa_and_exponent();\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(exponent_alt, exponent);\n\n    assert_eq!(x.clone().raw_mantissa(), mantissa);\n    assert_eq!((&x).raw_mantissa(), mantissa);\n    assert_eq!(x.clone().raw_exponent(), exponent);\n    assert_eq!((&x).raw_exponent(), exponent);\n\n    assert_eq!(x.to_significand().unwrap(), mantissa);\n    assert_eq!(x.get_exponent().unwrap(), exponent);\n\n    assert_eq!(\n        Float::from_raw_mantissa_and_exponent(mantissa.clone(), exponent),\n        (&x).abs()\n    );\n    assert_eq!(\n        <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n            mantissa.clone(),\n            exponent\n        ),\n        x.abs()\n    );\n\n    let bits = mantissa.significant_bits();\n    assert_ne!(bits, 0);\n    assert!(bits.divisible_by_power_of_2(Limb::LOG_WIDTH));\n    assert!(exponent <= Float::MAX_EXPONENT);\n    assert!(exponent >= Float::MIN_EXPONENT);\n}\n\n#[test]\nfn raw_mantissa_and_exponent_properties() {\n    float_gen_var_3().test_properties(|x| {\n        raw_mantissa_and_exponent_properties_helper(x);\n    });\n\n    float_gen_var_13().test_properties(|x| {\n        raw_mantissa_and_exponent_properties_helper(x);\n    });\n}\n\n#[test]\nfn from_raw_mantissa_and_exponent_properties() {\n    natural_signed_pair_gen_var_4::<i32>().test_properties(|(mantissa, exponent)| {\n        let x = Float::from_raw_mantissa_and_exponent(mantissa.clone(), exponent);\n        assert!(x.is_valid());\n        assert!(x.is_finite());\n        assert!(x > 0u32);\n        assert_eq!((&x).raw_mantissa(), mantissa);\n        assert_eq!((&x).raw_exponent(), exponent);\n\n        let x_alt = <&Float as RawMantissaAndExponent<_, _, _>>::from_raw_mantissa_and_exponent(\n            mantissa, exponent,\n        );\n        assert!(x_alt.is_valid());\n        assert_eq!(x_alt, x);\n    });\n}\n\nfn integer_mantissa_and_exponent_properties_helper<T: PrimitiveFloat>()\nwhere\n    Float: From<T>,\n{\n    primitive_float_gen_var_12::<T>().test_properties(|x| {\n        let (mantissa, exponent) = x.integer_mantissa_and_exponent();\n        let (mantissa_alt, exponent_alt) = Float::from(x).integer_mantissa_and_exponent();\n        assert_eq!(mantissa_alt, mantissa);\n        assert_eq!(exponent_alt, exponent);\n    });\n}\n\nfn integer_mantissa_and_exponent_properties_helper_2(x: Float) {\n    let (mantissa, exponent) = x.clone().integer_mantissa_and_exponent();\n    let (mantissa_alt, exponent_alt) = (&x).integer_mantissa_and_exponent();\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(exponent_alt, exponent);\n    let (mantissa_alt, exponent_alt) = (-&x).integer_mantissa_and_exponent();\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(exponent_alt, exponent);\n\n    assert_eq!(x.clone().integer_mantissa(), mantissa);\n    assert_eq!((&x).integer_mantissa(), mantissa);\n    assert_eq!(x.clone().integer_exponent(), exponent);\n    assert_eq!((&x).integer_exponent(), exponent);\n\n    assert_eq!(\n        Float::from_integer_mantissa_and_exponent(mantissa.clone(), exponent),\n        Some(x.clone().abs())\n    );\n    assert_eq!(\n        <&Float as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n            mantissa.clone(),\n            exponent\n        ),\n        Some(x.abs())\n    );\n\n    assert!(mantissa.odd());\n    assert!(exponent < i64::from(Float::MAX_EXPONENT));\n}\n\n#[test]\nfn integer_mantissa_and_exponent_properties() {\n    float_gen_var_3().test_properties(|x| {\n        integer_mantissa_and_exponent_properties_helper_2(x);\n    });\n\n    float_gen_var_13().test_properties(|x| {\n        integer_mantissa_and_exponent_properties_helper_2(x);\n    });\n\n    apply_fn_to_primitive_floats!(integer_mantissa_and_exponent_properties_helper);\n}\n\n#[test]\nfn from_integer_mantissa_and_exponent_properties() {\n    natural_signed_pair_gen_var_2::<i64>().test_properties(|(mantissa, exponent)| {\n        let ox = Float::from_integer_mantissa_and_exponent(mantissa.clone(), exponent);\n        if let Some(x) = ox.as_ref() {\n            assert!(x.is_valid());\n            assert!(x.is_finite());\n            assert!(*x >= 0u32);\n            if mantissa.odd() {\n                assert_eq!(x.integer_mantissa(), mantissa);\n                assert_eq!(x.integer_exponent(), exponent);\n            }\n        }\n\n        let ox_alt =\n            <&Float as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n                mantissa, exponent,\n            );\n        assert!(ox_alt.as_ref().is_none_or(Float::is_valid));\n        assert_eq!(ox_alt, ox);\n    });\n}\n\nfn sci_mantissa_and_exponent_round_properties_helper_helper<T: PrimitiveFloat>(\n    x: Float,\n    rm: RoundingMode,\n    extreme: bool,\n) where\n    Rational: TryFrom<T>,\n{\n    let meo = x.sci_mantissa_and_exponent_round::<T>(rm);\n    assert_eq!((-&x).sci_mantissa_and_exponent_round(rm), meo);\n    if let Some((mantissa, exponent, o)) = meo {\n        assert!(mantissa >= T::ONE);\n        assert!(mantissa < T::TWO);\n        assert!(x.is_valid());\n        // Although the maximum sci-exponent for a Float is Float::MAX_EXPONENT, this function may\n        // return an exponent that is larger by 1, due to rounding.\n        assert!(exponent <= Float::MAX_EXPONENT);\n        assert!(exponent >= Float::MIN_EXPONENT - 1);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if !extreme {\n            let x_alt = Rational::exact_from(mantissa) << exponent;\n            assert_eq!(x_alt.partial_cmp_abs(&x), Some(o));\n            if rm == Exact {\n                assert_eq!(x_alt.partial_cmp_abs(&x), Some(Equal));\n            }\n\n            let r_x: Rational = ExactFrom::exact_from(x);\n            assert_eq!(\n                r_x.sci_mantissa_and_exponent_round(rm).unwrap(),\n                (mantissa, i64::from(exponent), o)\n            );\n        }\n    } else {\n        assert!(!x.is_finite() || x == 0u32 || rm == Exact);\n    }\n}\n\nfn sci_mantissa_and_exponent_round_properties_helper<T: PrimitiveFloat>()\nwhere\n    Rational: TryFrom<T>,\n{\n    float_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        sci_mantissa_and_exponent_round_properties_helper_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_21().test_properties(|(x, rm)| {\n        sci_mantissa_and_exponent_round_properties_helper_helper(x, rm, true);\n    });\n\n    float_gen_var_3().test_properties(|n| {\n        let (floor_mantissa, floor_exponent, floor_o) =\n            n.sci_mantissa_and_exponent_round::<T>(Floor).unwrap();\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round::<T>(Down).unwrap(),\n            (floor_mantissa, floor_exponent, floor_o)\n        );\n        let (ceiling_mantissa, ceiling_exponent, ceiling_o) =\n            n.sci_mantissa_and_exponent_round::<T>(Ceiling).unwrap();\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round::<T>(Up).unwrap(),\n            (ceiling_mantissa, ceiling_exponent, ceiling_o)\n        );\n        let (nearest_mantissa, nearest_exponent, nearest_o) =\n            n.sci_mantissa_and_exponent_round::<T>(Nearest).unwrap();\n        if let Some((mantissa, exponent, o)) = n.sci_mantissa_and_exponent_round::<T>(Exact) {\n            assert_eq!(o, Equal);\n            assert_eq!(floor_mantissa, mantissa);\n            assert_eq!(ceiling_mantissa, mantissa);\n            assert_eq!(nearest_mantissa, mantissa);\n            assert_eq!(floor_exponent, exponent);\n            assert_eq!(ceiling_exponent, exponent);\n            assert_eq!(nearest_exponent, exponent);\n        } else {\n            assert_eq!(floor_o, Less);\n            assert_eq!(ceiling_o, Greater);\n            assert_ne!(\n                (floor_mantissa, floor_exponent),\n                (ceiling_mantissa, ceiling_exponent)\n            );\n            assert!(\n                (nearest_mantissa, nearest_exponent, nearest_o)\n                    == (floor_mantissa, floor_exponent, floor_o)\n                    || (nearest_mantissa, nearest_exponent, nearest_o)\n                        == (ceiling_mantissa, ceiling_exponent, ceiling_o)\n            );\n            if ceiling_mantissa == T::ONE {\n                assert_eq!(floor_mantissa, T::TWO.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent - 1);\n            } else {\n                assert_eq!(floor_mantissa, ceiling_mantissa.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent);\n            }\n        }\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_round_properties() {\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_round_properties_helper);\n}\n\nfn sci_mantissa_and_exponent_float_properties_helper(x: Float) {\n    let (mantissa, exponent): (Float, i32) = x.clone().sci_mantissa_and_exponent();\n    assert!(mantissa.is_valid());\n    let (mantissa_alt, exponent_alt): (Float, i32) = (&x).sci_mantissa_and_exponent();\n    assert!(mantissa_alt.is_valid());\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(exponent_alt, exponent);\n    let (mantissa_alt, exponent_alt): (Float, i32) = (-&x).sci_mantissa_and_exponent();\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(exponent_alt, exponent);\n\n    let mantissa_alt: Float = (&x).sci_mantissa();\n    assert!(mantissa_alt.is_valid());\n    assert_eq!(mantissa_alt, mantissa);\n    let mantissa_alt: Float = x.clone().sci_mantissa();\n    assert!(mantissa_alt.is_valid());\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(\n        <Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(x.clone()),\n        exponent\n    );\n    assert_eq!(\n        <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(&x),\n        exponent\n    );\n\n    assert_eq!(\n        Float::from_sci_mantissa_and_exponent(mantissa.clone(), exponent),\n        Some(x.clone().abs())\n    );\n    assert_eq!(\n        <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n            mantissa.clone(),\n            exponent\n        ),\n        Some(x.abs())\n    );\n    assert!(mantissa >= 1u32);\n    assert!(mantissa < 2u32);\n    assert!(exponent < Float::MAX_EXPONENT);\n    assert!(exponent >= Float::MIN_EXPONENT - 1);\n}\n\n#[test]\nfn sci_mantissa_and_exponent_float_properties() {\n    float_gen_var_3().test_properties(|x| {\n        sci_mantissa_and_exponent_float_properties_helper(x);\n    });\n\n    float_gen_var_13().test_properties(|x| {\n        sci_mantissa_and_exponent_float_properties_helper(x);\n    });\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_float_properties() {\n    float_signed_pair_gen_var_1::<i32>().test_properties(|(mantissa, exponent)| {\n        let ox = Float::from_sci_mantissa_and_exponent(mantissa.clone(), exponent);\n        if let Some(x) = ox.as_ref() {\n            assert!(x.is_valid());\n            assert!(x.is_finite());\n            assert!(*x > 0u32);\n            assert_eq!(\n                <&Float as SciMantissaAndExponent<Float, _, _>>::sci_mantissa(x),\n                mantissa\n            );\n            assert_eq!(\n                <&Float as SciMantissaAndExponent<Float, _, _>>::sci_exponent(x),\n                exponent\n            );\n        }\n\n        let ox_alt = <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n            mantissa, exponent,\n        );\n        assert!(ox_alt.as_ref().is_none_or(Float::is_valid));\n        assert_eq!(ox_alt, ox);\n    });\n}\n\nfn sci_mantissa_and_exponent_primitive_float_properties_helper_helper<T: PrimitiveFloat>(\n    x: Float,\n    extreme: bool,\n) where\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n    Float: From<T>,\n{\n    let (mantissa, exponent): (T, i32) = (&x).sci_mantissa_and_exponent();\n\n    assert_eq!(\n        <&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa(&x),\n        mantissa\n    );\n    assert_eq!(\n        <&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(&x),\n        exponent\n    );\n    let (mantissa_alt, exponent_alt): (T, i32) = (&-&x).sci_mantissa_and_exponent();\n    assert_eq!(mantissa_alt, mantissa);\n    assert_eq!(exponent_alt, exponent);\n\n    if !extreme {\n        let x_alt = <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n            mantissa, exponent,\n        )\n        .unwrap();\n        assert!(\n            Rational::exact_from(x) - Rational::exact_from(&x_alt)\n                <= Rational::exact_from(x_alt.ulp().unwrap()) >> 1u32\n        );\n    }\n\n    assert!(mantissa >= T::ONE);\n    assert!(mantissa < T::TWO);\n}\n\nfn sci_mantissa_and_exponent_primitive_float_properties_helper<T: PrimitiveFloat>()\nwhere\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n    Float: From<T>,\n{\n    float_gen_var_3().test_properties(|x| {\n        sci_mantissa_and_exponent_primitive_float_properties_helper_helper(x, false);\n    });\n\n    float_gen_var_13().test_properties(|x| {\n        sci_mantissa_and_exponent_primitive_float_properties_helper_helper(x, true);\n    });\n\n    primitive_float_gen_var_12::<T>().test_properties(|x| {\n        let (mantissa, exponent) = x.sci_mantissa_and_exponent();\n        let (mantissa_alt, exponent_alt): (T, i32) = (&Float::from(x)).sci_mantissa_and_exponent();\n        assert_eq!(mantissa_alt, mantissa);\n        assert_eq!(i64::from(exponent_alt), exponent);\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_primitive_float_properties_helper);\n}\n\nfn from_sci_mantissa_and_exponent_primitive_float_properties_helper<T: PrimitiveFloat>()\nwhere\n    for<'a> &'a Float: SciMantissaAndExponent<T, i32, Float>,\n    Float: From<T>,\n{\n    primitive_float_signed_pair_gen_var_3::<T>().test_properties(|(mantissa, exponent)| {\n        let ox = <&Float as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n            mantissa,\n            i32::exact_from(exponent),\n        );\n        if let Some(x) = ox.as_ref() {\n            assert!(x.is_valid());\n            assert!(x.is_finite());\n            assert!(*x > 0u32);\n            assert_eq!(\n                <&Float as SciMantissaAndExponent<T, _, _>>::sci_mantissa(x),\n                mantissa\n            );\n            assert_eq!(\n                i64::from(<&Float as SciMantissaAndExponent<T, _, _>>::sci_exponent(x)),\n                exponent\n            );\n        }\n\n        let ox_alt =\n            Float::from_sci_mantissa_and_exponent(Float::from(mantissa), i32::exact_from(exponent));\n        assert!(ox_alt.as_ref().is_none_or(Float::is_valid));\n        assert_eq!(ox_alt, ox);\n    });\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/natural_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ceiling, Floor, Parity};\nuse malachite_base::num::basic::traits::{\n    Infinity, NaN, NegativeInfinity, NegativeOne, One, OneHalf,\n};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::ToDebugString;\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_5, float_rounding_mode_pair_gen_var_1,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_q::Rational;\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_try_from_float() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let on = Natural::try_from(x.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n\n        let on = Natural::try_from(&x);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(\"NaN\", \"NaN\", \"Err(FloatInfiniteOrNan)\");\n    test(\"Infinity\", \"Infinity\", \"Err(FloatInfiniteOrNan)\");\n    test(\"-Infinity\", \"-Infinity\", \"Err(FloatInfiniteOrNan)\");\n    test(\"0.0\", \"0x0.0\", \"Ok(0)\");\n    test(\"-0.0\", \"-0x0.0\", \"Ok(0)\");\n\n    test(\"1.0\", \"0x1.0#1\", \"Ok(1)\");\n    test(\"2.0\", \"0x2.0#1\", \"Ok(2)\");\n    test(\"0.5\", \"0x0.8#1\", \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"Err(FloatNonIntegerOrOutOfRange)\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"Ok(123)\");\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", \"Ok(1000000000000)\");\n\n    test(\"-1.0\", \"-0x1.0#1\", \"Err(FloatNegative)\");\n    test(\"-2.0\", \"-0x2.0#1\", \"Err(FloatNegative)\");\n    test(\"-0.5\", \"-0x0.8#1\", \"Err(FloatNegative)\");\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"Err(FloatNegative)\",\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"Err(FloatNegative)\");\n    test(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        \"Err(FloatNegative)\",\n    );\n}\n\n#[test]\nfn test_convertible_from_float() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(Natural::convertible_from(&x), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", false);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test(\"123.0\", \"0x7b.0#7\", true);\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", true);\n\n    test(\"-1.0\", \"-0x1.0#1\", false);\n    test(\"-2.0\", \"-0x2.0#1\", false);\n    test(\"-0.5\", \"-0x0.8#1\", false);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test(\"-123.0\", \"-0x7b.0#7\", false);\n    test(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", false);\n}\n\n#[test]\nfn test_rounding_from_float() {\n    let test = |s, s_hex, rm, out, o_out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (n, o) = Natural::rounding_from(x.clone(), rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n\n        let (n, o) = Natural::rounding_from(&x, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n    };\n    test(\"-Infinity\", \"-Infinity\", Ceiling, \"0\", Greater);\n    test(\"-Infinity\", \"-Infinity\", Down, \"0\", Greater);\n    test(\"-Infinity\", \"-Infinity\", Nearest, \"0\", Greater);\n\n    test(\"0.0\", \"0x0.0\", Floor, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Ceiling, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Down, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Up, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Nearest, \"0\", Equal);\n    test(\"0.0\", \"0x0.0\", Exact, \"0\", Equal);\n\n    test(\"-0.0\", \"-0x0.0\", Floor, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Ceiling, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Down, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Up, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Nearest, \"0\", Equal);\n    test(\"-0.0\", \"-0x0.0\", Exact, \"0\", Equal);\n\n    test(\"1.0\", \"0x1.0#1\", Floor, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Ceiling, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Down, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Up, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Nearest, \"1\", Equal);\n    test(\"1.0\", \"0x1.0#1\", Exact, \"1\", Equal);\n\n    test(\"2.0\", \"0x2.0#1\", Floor, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Ceiling, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Down, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Up, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Nearest, \"2\", Equal);\n    test(\"2.0\", \"0x2.0#1\", Exact, \"2\", Equal);\n\n    test(\"0.5\", \"0x0.8#1\", Floor, \"0\", Less);\n    test(\"0.5\", \"0x0.8#1\", Ceiling, \"1\", Greater);\n    test(\"0.5\", \"0x0.8#1\", Down, \"0\", Less);\n    test(\"0.5\", \"0x0.8#1\", Up, \"1\", Greater);\n    test(\"0.5\", \"0x0.8#1\", Nearest, \"0\", Less);\n\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Floor,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Ceiling,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Down,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Up,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Nearest,\n        \"0\",\n        Less,\n    );\n\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Floor,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Ceiling,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Down,\n        \"0\",\n        Less,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Up,\n        \"1\",\n        Greater,\n    );\n    test(\n        \"0.6666666666666666\",\n        \"0x0.aaaaaaaaaaaaa8#53\",\n        Nearest,\n        \"1\",\n        Greater,\n    );\n\n    test(\"1.5\", \"0x1.8#2\", Floor, \"1\", Less);\n    test(\"1.5\", \"0x1.8#2\", Ceiling, \"2\", Greater);\n    test(\"1.5\", \"0x1.8#2\", Down, \"1\", Less);\n    test(\"1.5\", \"0x1.8#2\", Up, \"2\", Greater);\n    test(\"1.5\", \"0x1.8#2\", Nearest, \"2\", Greater);\n\n    test(\"2.5\", \"0x2.8#3\", Floor, \"2\", Less);\n    test(\"2.5\", \"0x2.8#3\", Ceiling, \"3\", Greater);\n    test(\"2.5\", \"0x2.8#3\", Down, \"2\", Less);\n    test(\"2.5\", \"0x2.8#3\", Up, \"3\", Greater);\n    test(\"2.5\", \"0x2.8#3\", Nearest, \"2\", Less);\n\n    test(\"123.0\", \"0x7b.0#7\", Floor, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Ceiling, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Down, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Up, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Nearest, \"123\", Equal);\n    test(\"123.0\", \"0x7b.0#7\", Exact, \"123\", Equal);\n\n    test(\"-1.0\", \"-0x1.0#1\", Ceiling, \"0\", Greater);\n    test(\"-1.0\", \"-0x1.0#1\", Down, \"0\", Greater);\n    test(\"-1.0\", \"-0x1.0#1\", Nearest, \"0\", Greater);\n\n    test(\"-2.0\", \"-0x2.0#1\", Ceiling, \"0\", Greater);\n    test(\"-2.0\", \"-0x2.0#1\", Down, \"0\", Greater);\n    test(\"-2.0\", \"-0x2.0#1\", Nearest, \"0\", Greater);\n\n    test(\"-0.5\", \"-0x0.8#1\", Ceiling, \"0\", Greater);\n    test(\"-0.5\", \"-0x0.8#1\", Down, \"0\", Greater);\n    test(\"-0.5\", \"-0x0.8#1\", Nearest, \"0\", Greater);\n\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Ceiling,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Down,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Nearest,\n        \"0\",\n        Greater,\n    );\n\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Ceiling,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Down,\n        \"0\",\n        Greater,\n    );\n    test(\n        \"-0.6666666666666666\",\n        \"-0x0.aaaaaaaaaaaaa8#53\",\n        Nearest,\n        \"0\",\n        Greater,\n    );\n\n    test(\"-1.5\", \"-0x1.8#2\", Ceiling, \"0\", Greater);\n    test(\"-1.5\", \"-0x1.8#2\", Down, \"0\", Greater);\n    test(\"-1.5\", \"-0x1.8#2\", Nearest, \"0\", Greater);\n\n    test(\"-2.5\", \"-0x2.8#3\", Ceiling, \"0\", Greater);\n    test(\"-2.5\", \"-0x2.8#3\", Down, \"0\", Greater);\n    test(\"-2.5\", \"-0x2.8#3\", Nearest, \"0\", Greater);\n\n    test(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"0\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", Down, \"0\", Greater);\n    test(\"-123.0\", \"-0x7b.0#7\", Nearest, \"0\", Greater);\n}\n\n#[test]\nfn natural_rounding_from_float_fail() {\n    assert_panic!(Natural::rounding_from(Float::NAN, Floor));\n    assert_panic!(Natural::rounding_from(Float::NAN, Ceiling));\n    assert_panic!(Natural::rounding_from(Float::NAN, Down));\n    assert_panic!(Natural::rounding_from(Float::NAN, Up));\n    assert_panic!(Natural::rounding_from(Float::NAN, Nearest));\n    assert_panic!(Natural::rounding_from(Float::NAN, Exact));\n\n    assert_panic!(Natural::rounding_from(Float::INFINITY, Floor));\n    assert_panic!(Natural::rounding_from(Float::INFINITY, Ceiling));\n    assert_panic!(Natural::rounding_from(Float::INFINITY, Down));\n    assert_panic!(Natural::rounding_from(Float::INFINITY, Up));\n    assert_panic!(Natural::rounding_from(Float::INFINITY, Nearest));\n    assert_panic!(Natural::rounding_from(Float::INFINITY, Exact));\n\n    assert_panic!(Natural::rounding_from(Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(Natural::rounding_from(Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(Natural::rounding_from(Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(Natural::rounding_from(Float::NEGATIVE_ONE, Floor));\n    assert_panic!(Natural::rounding_from(Float::NEGATIVE_ONE, Up));\n    assert_panic!(Natural::rounding_from(Float::NEGATIVE_ONE, Exact));\n\n    assert_panic!(Natural::rounding_from(Float::from(3u8) >> 1, Exact));\n}\n\n#[test]\nfn natural_rounding_from_float_ref_fail() {\n    assert_panic!(Natural::rounding_from(&Float::NAN, Floor));\n    assert_panic!(Natural::rounding_from(&Float::NAN, Ceiling));\n    assert_panic!(Natural::rounding_from(&Float::NAN, Down));\n    assert_panic!(Natural::rounding_from(&Float::NAN, Up));\n    assert_panic!(Natural::rounding_from(&Float::NAN, Nearest));\n    assert_panic!(Natural::rounding_from(&Float::NAN, Exact));\n\n    assert_panic!(Natural::rounding_from(&Float::INFINITY, Floor));\n    assert_panic!(Natural::rounding_from(&Float::INFINITY, Ceiling));\n    assert_panic!(Natural::rounding_from(&Float::INFINITY, Down));\n    assert_panic!(Natural::rounding_from(&Float::INFINITY, Up));\n    assert_panic!(Natural::rounding_from(&Float::INFINITY, Nearest));\n    assert_panic!(Natural::rounding_from(&Float::INFINITY, Exact));\n\n    assert_panic!(Natural::rounding_from(&Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(Natural::rounding_from(&Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(Natural::rounding_from(&Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(Natural::rounding_from(&Float::NEGATIVE_ONE, Floor));\n    assert_panic!(Natural::rounding_from(&Float::NEGATIVE_ONE, Up));\n    assert_panic!(Natural::rounding_from(&Float::NEGATIVE_ONE, Exact));\n\n    assert_panic!(Natural::rounding_from(&(Float::from(3u8) >> 1), Exact));\n}\n\n#[test]\nfn try_from_float_properties() {\n    float_gen().test_properties(|x| {\n        let natural_x = Natural::try_from(x.clone());\n        assert!(natural_x.as_ref().map_or(true, Natural::is_valid));\n\n        let natural_x_alt = Natural::try_from(&x);\n        assert!(natural_x_alt.as_ref().map_or(true, Natural::is_valid));\n        assert_eq!(natural_x, natural_x_alt);\n\n        assert_eq!(natural_x.is_ok(), Natural::convertible_from(&x));\n        if let Ok(n) = natural_x {\n            assert_eq!(Natural::exact_from(&x), n);\n            assert_eq!(n, x);\n            assert_eq!(Float::exact_from(&n), x);\n            assert_eq!(Float::exact_from(n), x);\n        }\n    });\n}\n\n#[test]\nfn convertible_from_float_properties() {\n    float_gen().test_properties(|x| {\n        Natural::convertible_from(&x);\n    });\n}\n\n#[test]\nfn rounding_from_float_properties() {\n    float_rounding_mode_pair_gen_var_1().test_properties(|(x, rm)| {\n        let no = Natural::rounding_from(&x, rm);\n        assert_eq!(Natural::rounding_from(x.clone(), rm), no);\n        let (n, o) = no;\n        if x >= 0 {\n            assert_eq!(Integer::rounding_from(&x, rm), (Integer::from(&n), o));\n            assert!((Rational::from(&n) - Rational::exact_from(&x)).lt_abs(&1));\n        }\n\n        assert_eq!(n.partial_cmp(&x), Some(o));\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    float_gen_var_5().test_properties(|x| {\n        let floor = Natural::rounding_from(&x, Floor);\n        assert_eq!(floor.0, Rational::exact_from(&x).floor());\n        assert!(floor.0 <= x);\n        assert!(&floor.0 + Natural::ONE > x);\n        assert_eq!(Natural::rounding_from(&x, Down), floor);\n\n        let ceiling = Natural::rounding_from(&x, Ceiling);\n        assert_eq!(ceiling.0, Rational::exact_from(&x).ceiling());\n        assert!(ceiling.0 >= x);\n        if x > 0 {\n            assert!(&ceiling.0 - Natural::ONE < x);\n        }\n        assert_eq!(Natural::rounding_from(&x, Up), ceiling);\n\n        let nearest = Natural::rounding_from(&x, Nearest);\n        assert!(nearest == floor || nearest == ceiling);\n        assert!((Rational::from(nearest.0) - Rational::exact_from(x)).le_abs(&Rational::ONE_HALF));\n    });\n\n    natural_gen().test_properties(|n| {\n        let x = Float::exact_from(&n);\n        let no = (n, Equal);\n        assert_eq!(Natural::rounding_from(&x, Floor), no);\n        assert_eq!(Natural::rounding_from(&x, Down), no);\n        assert_eq!(Natural::rounding_from(&x, Ceiling), no);\n        assert_eq!(Natural::rounding_from(&x, Up), no);\n        assert_eq!(Natural::rounding_from(&x, Nearest), no);\n        assert_eq!(Natural::rounding_from(&x, Exact), no);\n\n        let x = Float::exact_from((no.0 << 1) | Natural::ONE) >> 1;\n        assert!(Natural::rounding_from(x, Nearest).0.even());\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/primitive_float_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_float::Float;\nuse malachite_float::conversion::primitive_float_from_float::FloatFromFloatError;\nuse malachite_float::test_util::common::{parse_hex_string, rug_round_try_from_rounding_mode};\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_4, float_gen_var_12, float_rounding_mode_pair_gen_var_6,\n    float_rounding_mode_pair_gen_var_20,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[allow(clippy::type_repetition_in_bounds)]\n#[test]\nfn test_try_from_float() {\n    fn test_helper<T: PrimitiveFloat + TryFrom<Float, Error = FloatFromFloatError>>(\n        s: &str,\n        s_hex: &str,\n        out: &str,\n    ) where\n        for<'a> T: TryFrom<&'a Float, Error = FloatFromFloatError>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let on = match T::try_from(x.clone()) {\n            Ok(n) => format!(\"Ok({})\", NiceFloat(n)),\n            e => e.to_debug_string(),\n        };\n        assert_eq!(on, out);\n\n        let on = match T::try_from(&x) {\n            Ok(n) => format!(\"Ok({})\", NiceFloat(n)),\n            e => e.to_debug_string(),\n        };\n        assert_eq!(on, out);\n    }\n    fn test_helper_2<T: PrimitiveFloat + TryFrom<Float, Error = FloatFromFloatError>>()\n    where\n        for<'a> T: TryFrom<&'a Float, Error = FloatFromFloatError>,\n    {\n        test_helper::<T>(\"NaN\", \"NaN\", \"Ok(NaN)\");\n        test_helper::<T>(\"Infinity\", \"Infinity\", \"Ok(Infinity)\");\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", \"Ok(-Infinity)\");\n        test_helper::<T>(\"0.0\", \"0x0.0\", \"Ok(0.0)\");\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", \"Ok(-0.0)\");\n\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", \"Ok(1.0)\");\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", \"Ok(2.0)\");\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", \"Ok(0.5)\");\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", \"Ok(123.0)\");\n        test_helper::<T>(\n            \"0.333333333333333332\",\n            \"0x0.555555555555554#57\",\n            \"Err(Inexact)\",\n        );\n        test_helper::<T>(\"2.0e2408\", \"0x1.0E+2000#1\", \"Err(Overflow)\");\n        test_helper::<T>(\"6.0e-2409\", \"0x1.0E-2000#1\", \"Err(Underflow)\");\n        test_helper::<T>(\"too_big\", \"0x4.0E+268435455#1\", \"Err(Overflow)\");\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", \"Err(Underflow)\");\n\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", \"Ok(-1.0)\");\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", \"Ok(-2.0)\");\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", \"Ok(-0.5)\");\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", \"Ok(-123.0)\");\n        test_helper::<T>(\n            \"-0.333333333333333332\",\n            \"-0x0.555555555555554#57\",\n            \"Err(Inexact)\",\n        );\n        test_helper::<T>(\"-2.0e2408\", \"-0x1.0E+2000#1\", \"Err(Overflow)\");\n        test_helper::<T>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", \"Err(Underflow)\");\n        test_helper::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", \"Err(Overflow)\");\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", \"Err(Underflow)\");\n    }\n    apply_fn_to_primitive_floats!(test_helper_2);\n    test_helper::<f32>(\"0.33333334\", \"0x0.5555558#24\", \"Ok(0.33333334)\");\n    test_helper::<f64>(\"0.33333334\", \"0x0.5555558#24\", \"Ok(0.3333333432674408)\");\n    test_helper::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"Err(Inexact)\",\n    );\n    test_helper::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"Ok(0.3333333333333333)\",\n    );\n    test_helper::<f32>(\"7.0e240\", \"0x1.0E+200#1\", \"Err(Overflow)\");\n    test_helper::<f64>(\"7.0e240\", \"0x1.0E+200#1\", \"Ok(6.668014432879854e240)\");\n    test_helper::<f32>(\"1.0e-241\", \"0x1.0E-200#1\", \"Err(Underflow)\");\n    test_helper::<f64>(\"1.0e-241\", \"0x1.0E-200#1\", \"Ok(1.499696813895631e-241)\");\n\n    test_helper::<f32>(\"-0.33333334\", \"-0x0.5555558#24\", \"Ok(-0.33333334)\");\n    test_helper::<f64>(\"-0.33333334\", \"-0x0.5555558#24\", \"Ok(-0.3333333432674408)\");\n    test_helper::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"Err(Inexact)\",\n    );\n    test_helper::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"Ok(-0.3333333333333333)\",\n    );\n    test_helper::<f32>(\"-7.0e240\", \"-0x1.0E+200#1\", \"Err(Overflow)\");\n    test_helper::<f64>(\"-7.0e240\", \"-0x1.0E+200#1\", \"Ok(-6.668014432879854e240)\");\n    test_helper::<f32>(\"-1.0e-241\", \"-0x1.0E-200#1\", \"Err(Underflow)\");\n    test_helper::<f64>(\"-1.0e-241\", \"-0x1.0E-200#1\", \"Ok(-1.499696813895631e-241)\");\n}\n\n#[test]\nfn test_convertible_from_float() {\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper<T: PrimitiveFloat>(s: &str, s_hex: &str, out: bool)\n    where\n        for<'a> T: ConvertibleFrom<&'a Float>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(T::convertible_from(&x), out);\n    }\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper_2<T: PrimitiveFloat>()\n    where\n        for<'a> T: ConvertibleFrom<&'a Float>,\n    {\n        test_helper::<T>(\"NaN\", \"NaN\", true);\n        test_helper::<T>(\"Infinity\", \"Infinity\", true);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", true);\n        test_helper::<T>(\"0.0\", \"0x0.0\", true);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", true);\n\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", true);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", true);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", true);\n        test_helper::<T>(\"0.33333334\", \"0x0.5555558#24\", true);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", true);\n        test_helper::<T>(\"0.333333333333333332\", \"0x0.555555555555554#57\", false);\n        test_helper::<T>(\"2.0e2408\", \"0x1.0E+2000#1\", false);\n        test_helper::<T>(\"6.0e-2409\", \"0x1.0E-2000#1\", false);\n        test_helper::<T>(\"too_big\", \"0x4.0E+268435455#1\", false);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", true);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", true);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", true);\n        test_helper::<T>(\"-0.33333334\", \"-0x0.5555558#24\", true);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", true);\n        test_helper::<T>(\"-0.333333333333333332\", \"-0x0.555555555555554#57\", false);\n        test_helper::<T>(\"-2.0e2408\", \"-0x1.0E+2000#1\", false);\n        test_helper::<T>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", false);\n        test_helper::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n    }\n    apply_fn_to_primitive_floats!(test_helper_2);\n    test_helper::<f32>(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n    test_helper::<f64>(\"0.33333333333333331\", \"0x0.55555555555554#53\", true);\n    test_helper::<f32>(\"7.0e240\", \"0x1.0E+200#1\", false);\n    test_helper::<f64>(\"7.0e240\", \"0x1.0E+200#1\", true);\n    test_helper::<f32>(\"1.0e-241\", \"0x1.0E-200#1\", false);\n    test_helper::<f64>(\"1.0e-241\", \"0x1.0E-200#1\", true);\n\n    test_helper::<f32>(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n    test_helper::<f64>(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", true);\n    test_helper::<f32>(\"-7.0e240\", \"-0x1.0E+200#1\", false);\n    test_helper::<f64>(\"-7.0e240\", \"-0x1.0E+200#1\", true);\n    test_helper::<f32>(\"-1.0e-241\", \"-0x1.0E-200#1\", false);\n    test_helper::<f64>(\"-1.0e-241\", \"-0x1.0E-200#1\", true);\n}\n\n#[test]\nfn test_rounding_from_float() {\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper<T: PrimitiveFloat + RoundingFrom<Float>>(\n        s: &str,\n        s_hex: &str,\n        rm: RoundingMode,\n        out: &str,\n        o_out: Ordering,\n    ) where\n        for<'a> T: RoundingFrom<&'a Float>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (n, o) = T::rounding_from(x.clone(), rm);\n        assert_eq!(NiceFloat(n).to_string(), out);\n        assert_eq!(o, o_out);\n\n        let (n, o) = T::rounding_from(&x, rm);\n        assert_eq!(NiceFloat(n).to_string(), out);\n        assert_eq!(o, o_out);\n    }\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper_2<T: PrimitiveFloat + RoundingFrom<Float>>()\n    where\n        for<'a> T: RoundingFrom<&'a Float>,\n    {\n        test_helper::<T>(\"NaN\", \"NaN\", Floor, \"NaN\", Equal);\n        test_helper::<T>(\"NaN\", \"NaN\", Ceiling, \"NaN\", Equal);\n        test_helper::<T>(\"NaN\", \"NaN\", Down, \"NaN\", Equal);\n        test_helper::<T>(\"NaN\", \"NaN\", Up, \"NaN\", Equal);\n        test_helper::<T>(\"NaN\", \"NaN\", Nearest, \"NaN\", Equal);\n        test_helper::<T>(\"NaN\", \"NaN\", Exact, \"NaN\", Equal);\n\n        test_helper::<T>(\"Infinity\", \"Infinity\", Floor, \"Infinity\", Equal);\n        test_helper::<T>(\"Infinity\", \"Infinity\", Ceiling, \"Infinity\", Equal);\n        test_helper::<T>(\"Infinity\", \"Infinity\", Down, \"Infinity\", Equal);\n        test_helper::<T>(\"Infinity\", \"Infinity\", Up, \"Infinity\", Equal);\n        test_helper::<T>(\"Infinity\", \"Infinity\", Nearest, \"Infinity\", Equal);\n        test_helper::<T>(\"Infinity\", \"Infinity\", Exact, \"Infinity\", Equal);\n\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Floor, \"-Infinity\", Equal);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Ceiling, \"-Infinity\", Equal);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Down, \"-Infinity\", Equal);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Up, \"-Infinity\", Equal);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Nearest, \"-Infinity\", Equal);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Exact, \"-Infinity\", Equal);\n\n        test_helper::<T>(\"0.0\", \"0x0.0\", Floor, \"0.0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Ceiling, \"0.0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Down, \"0.0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Up, \"0.0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Nearest, \"0.0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Exact, \"0.0\", Equal);\n\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Floor, \"-0.0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Ceiling, \"-0.0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Down, \"-0.0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Up, \"-0.0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Nearest, \"-0.0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Exact, \"-0.0\", Equal);\n\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Floor, \"1.0\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Ceiling, \"1.0\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Down, \"1.0\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Up, \"1.0\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Nearest, \"1.0\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Exact, \"1.0\", Equal);\n\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Floor, \"-1.0\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Ceiling, \"-1.0\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Down, \"-1.0\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Up, \"-1.0\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Nearest, \"-1.0\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Exact, \"-1.0\", Equal);\n    }\n    apply_fn_to_primitive_floats!(test_helper_2);\n\n    test_helper::<f32>(\"0.33333334\", \"0x0.5555558#24\", Floor, \"0.33333334\", Equal);\n    test_helper::<f32>(\"0.33333334\", \"0x0.5555558#24\", Ceiling, \"0.33333334\", Equal);\n    test_helper::<f32>(\"0.33333334\", \"0x0.5555558#24\", Down, \"0.33333334\", Equal);\n    test_helper::<f32>(\"0.33333334\", \"0x0.5555558#24\", Up, \"0.33333334\", Equal);\n    test_helper::<f32>(\"0.33333334\", \"0x0.5555558#24\", Nearest, \"0.33333334\", Equal);\n    test_helper::<f32>(\"0.33333334\", \"0x0.5555558#24\", Exact, \"0.33333334\", Equal);\n\n    test_helper::<f64>(\n        \"0.33333334\",\n        \"0x0.5555558#24\",\n        Floor,\n        \"0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333334\",\n        \"0x0.5555558#24\",\n        Ceiling,\n        \"0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333334\",\n        \"0x0.5555558#24\",\n        Down,\n        \"0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333334\",\n        \"0x0.5555558#24\",\n        Up,\n        \"0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333334\",\n        \"0x0.5555558#24\",\n        Nearest,\n        \"0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333334\",\n        \"0x0.5555558#24\",\n        Exact,\n        \"0.3333333432674408\",\n        Equal,\n    );\n\n    test_helper::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Floor,\n        \"0.3333333\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Ceiling,\n        \"0.33333334\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Down,\n        \"0.3333333\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Up,\n        \"0.33333334\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Nearest,\n        \"0.33333334\",\n        Greater,\n    );\n\n    test_helper::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Floor,\n        \"0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Ceiling,\n        \"0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Down,\n        \"0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Up,\n        \"0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Nearest,\n        \"0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        Exact,\n        \"0.3333333333333333\",\n        Equal,\n    );\n\n    test_helper::<f32>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Floor,\n        \"0.3333333\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Ceiling,\n        \"0.33333334\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Down,\n        \"0.3333333\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Up,\n        \"0.33333334\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Nearest,\n        \"0.33333334\",\n        Greater,\n    );\n\n    test_helper::<f64>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Floor,\n        \"0.3333333333333333\",\n        Less,\n    );\n    test_helper::<f64>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Ceiling,\n        \"0.33333333333333337\",\n        Greater,\n    );\n    test_helper::<f64>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Down,\n        \"0.3333333333333333\",\n        Less,\n    );\n    test_helper::<f64>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Up,\n        \"0.33333333333333337\",\n        Greater,\n    );\n    test_helper::<f64>(\n        \"0.333333333333333332\",\n        \"0x0.555555555555554#57\",\n        Nearest,\n        \"0.3333333333333333\",\n        Less,\n    );\n\n    test_helper::<f32>(\"7.0e240\", \"0x1.0E+200#1\", Floor, \"3.4028235e38\", Less);\n    test_helper::<f32>(\"7.0e240\", \"0x1.0E+200#1\", Ceiling, \"Infinity\", Greater);\n    test_helper::<f32>(\"7.0e240\", \"0x1.0E+200#1\", Down, \"3.4028235e38\", Less);\n    test_helper::<f32>(\"7.0e240\", \"0x1.0E+200#1\", Up, \"Infinity\", Greater);\n    test_helper::<f32>(\"7.0e240\", \"0x1.0E+200#1\", Nearest, \"Infinity\", Greater);\n\n    test_helper::<f64>(\n        \"7.0e240\",\n        \"0x1.0E+200#1\",\n        Floor,\n        \"6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"7.0e240\",\n        \"0x1.0E+200#1\",\n        Ceiling,\n        \"6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"7.0e240\",\n        \"0x1.0E+200#1\",\n        Down,\n        \"6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"7.0e240\",\n        \"0x1.0E+200#1\",\n        Up,\n        \"6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"7.0e240\",\n        \"0x1.0E+200#1\",\n        Nearest,\n        \"6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"7.0e240\",\n        \"0x1.0E+200#1\",\n        Exact,\n        \"6.668014432879854e240\",\n        Equal,\n    );\n\n    test_helper::<f32>(\"2.0e2408\", \"0x1.0E+2000#1\", Floor, \"3.4028235e38\", Less);\n    test_helper::<f32>(\"2.0e2408\", \"0x1.0E+2000#1\", Ceiling, \"Infinity\", Greater);\n    test_helper::<f32>(\"2.0e2408\", \"0x1.0E+2000#1\", Down, \"3.4028235e38\", Less);\n    test_helper::<f32>(\"2.0e2408\", \"0x1.0E+2000#1\", Up, \"Infinity\", Greater);\n    test_helper::<f32>(\"2.0e2408\", \"0x1.0E+2000#1\", Nearest, \"Infinity\", Greater);\n\n    test_helper::<f64>(\n        \"2.0e2408\",\n        \"0x1.0E+2000#1\",\n        Floor,\n        \"1.7976931348623157e308\",\n        Less,\n    );\n    test_helper::<f64>(\"2.0e2408\", \"0x1.0E+2000#1\", Ceiling, \"Infinity\", Greater);\n    test_helper::<f64>(\n        \"2.0e2408\",\n        \"0x1.0E+2000#1\",\n        Down,\n        \"1.7976931348623157e308\",\n        Less,\n    );\n    test_helper::<f64>(\"2.0e2408\", \"0x1.0E+2000#1\", Up, \"Infinity\", Greater);\n    test_helper::<f64>(\"2.0e2408\", \"0x1.0E+2000#1\", Nearest, \"Infinity\", Greater);\n    test_helper::<f32>(\"1.0e-241\", \"0x1.0E-200#1\", Floor, \"0.0\", Less);\n    test_helper::<f32>(\"1.0e-241\", \"0x1.0E-200#1\", Ceiling, \"1.0e-45\", Greater);\n    test_helper::<f32>(\"1.0e-241\", \"0x1.0E-200#1\", Down, \"0.0\", Less);\n    test_helper::<f32>(\"1.0e-241\", \"0x1.0E-200#1\", Up, \"1.0e-45\", Greater);\n    test_helper::<f32>(\"1.0e-241\", \"0x1.0E-200#1\", Nearest, \"0.0\", Less);\n\n    test_helper::<f64>(\n        \"1.0e-241\",\n        \"0x1.0E-200#1\",\n        Floor,\n        \"1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"1.0e-241\",\n        \"0x1.0E-200#1\",\n        Ceiling,\n        \"1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"1.0e-241\",\n        \"0x1.0E-200#1\",\n        Down,\n        \"1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"1.0e-241\",\n        \"0x1.0E-200#1\",\n        Up,\n        \"1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"1.0e-241\",\n        \"0x1.0E-200#1\",\n        Nearest,\n        \"1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"1.0e-241\",\n        \"0x1.0E-200#1\",\n        Exact,\n        \"1.499696813895631e-241\",\n        Equal,\n    );\n\n    test_helper::<f32>(\"6.0e-2409\", \"0x1.0E-2000#1\", Floor, \"0.0\", Less);\n    test_helper::<f32>(\"6.0e-2409\", \"0x1.0E-2000#1\", Ceiling, \"1.0e-45\", Greater);\n    test_helper::<f32>(\"6.0e-2409\", \"0x1.0E-2000#1\", Down, \"0.0\", Less);\n    test_helper::<f32>(\"6.0e-2409\", \"0x1.0E-2000#1\", Up, \"1.0e-45\", Greater);\n    test_helper::<f32>(\"6.0e-2409\", \"0x1.0E-2000#1\", Nearest, \"0.0\", Less);\n\n    test_helper::<f64>(\"6.0e-2409\", \"0x1.0E-2000#1\", Floor, \"0.0\", Less);\n    test_helper::<f64>(\"6.0e-2409\", \"0x1.0E-2000#1\", Ceiling, \"5.0e-324\", Greater);\n    test_helper::<f64>(\"6.0e-2409\", \"0x1.0E-2000#1\", Down, \"0.0\", Less);\n    test_helper::<f64>(\"6.0e-2409\", \"0x1.0E-2000#1\", Up, \"5.0e-324\", Greater);\n    test_helper::<f64>(\"6.0e-2409\", \"0x1.0E-2000#1\", Nearest, \"0.0\", Less);\n\n    test_helper::<f32>(\"too_big\", \"0x4.0E+268435455#1\", Floor, \"3.4028235e38\", Less);\n    test_helper::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Ceiling,\n        \"Infinity\",\n        Greater,\n    );\n    test_helper::<f32>(\"too_big\", \"0x4.0E+268435455#1\", Down, \"3.4028235e38\", Less);\n    test_helper::<f32>(\"too_big\", \"0x4.0E+268435455#1\", Up, \"Infinity\", Greater);\n    test_helper::<f32>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Nearest,\n        \"Infinity\",\n        Greater,\n    );\n\n    test_helper::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Floor,\n        \"1.7976931348623157e308\",\n        Less,\n    );\n    test_helper::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Ceiling,\n        \"Infinity\",\n        Greater,\n    );\n    test_helper::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Down,\n        \"1.7976931348623157e308\",\n        Less,\n    );\n    test_helper::<f64>(\"too_big\", \"0x4.0E+268435455#1\", Up, \"Infinity\", Greater);\n    test_helper::<f64>(\n        \"too_big\",\n        \"0x4.0E+268435455#1\",\n        Nearest,\n        \"Infinity\",\n        Greater,\n    );\n\n    test_helper::<f32>(\"too_small\", \"0x1.0E-268435456#1\", Floor, \"0.0\", Less);\n    test_helper::<f32>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Ceiling,\n        \"1.0e-45\",\n        Greater,\n    );\n    test_helper::<f32>(\"too_small\", \"0x1.0E-268435456#1\", Down, \"0.0\", Less);\n    test_helper::<f32>(\"too_small\", \"0x1.0E-268435456#1\", Up, \"1.0e-45\", Greater);\n    test_helper::<f32>(\"too_small\", \"0x1.0E-268435456#1\", Nearest, \"0.0\", Less);\n\n    test_helper::<f64>(\"too_small\", \"0x1.0E-268435456#1\", Floor, \"0.0\", Less);\n    test_helper::<f64>(\n        \"too_small\",\n        \"0x1.0E-268435456#1\",\n        Ceiling,\n        \"5.0e-324\",\n        Greater,\n    );\n    test_helper::<f64>(\"too_small\", \"0x1.0E-268435456#1\", Down, \"0.0\", Less);\n    test_helper::<f64>(\"too_small\", \"0x1.0E-268435456#1\", Up, \"5.0e-324\", Greater);\n    test_helper::<f64>(\"too_small\", \"0x1.0E-268435456#1\", Nearest, \"0.0\", Less);\n\n    test_helper::<f32>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Floor,\n        \"-0.33333334\",\n        Equal,\n    );\n    test_helper::<f32>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Ceiling,\n        \"-0.33333334\",\n        Equal,\n    );\n    test_helper::<f32>(\"-0.33333334\", \"-0x0.5555558#24\", Down, \"-0.33333334\", Equal);\n    test_helper::<f32>(\"-0.33333334\", \"-0x0.5555558#24\", Up, \"-0.33333334\", Equal);\n    test_helper::<f32>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Nearest,\n        \"-0.33333334\",\n        Equal,\n    );\n    test_helper::<f32>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Exact,\n        \"-0.33333334\",\n        Equal,\n    );\n\n    test_helper::<f64>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Floor,\n        \"-0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Ceiling,\n        \"-0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Down,\n        \"-0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Up,\n        \"-0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Nearest,\n        \"-0.3333333432674408\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333334\",\n        \"-0x0.5555558#24\",\n        Exact,\n        \"-0.3333333432674408\",\n        Equal,\n    );\n\n    test_helper::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Floor,\n        \"-0.33333334\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Ceiling,\n        \"-0.3333333\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Down,\n        \"-0.3333333\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Up,\n        \"-0.33333334\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Nearest,\n        \"-0.33333334\",\n        Less,\n    );\n\n    test_helper::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Floor,\n        \"-0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Ceiling,\n        \"-0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Down,\n        \"-0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Up,\n        \"-0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Nearest,\n        \"-0.3333333333333333\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        Exact,\n        \"-0.3333333333333333\",\n        Equal,\n    );\n\n    test_helper::<f32>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Floor,\n        \"-0.33333334\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Ceiling,\n        \"-0.3333333\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Down,\n        \"-0.3333333\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Up,\n        \"-0.33333334\",\n        Less,\n    );\n    test_helper::<f32>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Nearest,\n        \"-0.33333334\",\n        Less,\n    );\n\n    test_helper::<f64>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Floor,\n        \"-0.33333333333333337\",\n        Less,\n    );\n    test_helper::<f64>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Ceiling,\n        \"-0.3333333333333333\",\n        Greater,\n    );\n    test_helper::<f64>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Down,\n        \"-0.3333333333333333\",\n        Greater,\n    );\n    test_helper::<f64>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Up,\n        \"-0.33333333333333337\",\n        Less,\n    );\n    test_helper::<f64>(\n        \"-0.333333333333333332\",\n        \"-0x0.555555555555554#57\",\n        Nearest,\n        \"-0.3333333333333333\",\n        Greater,\n    );\n\n    test_helper::<f32>(\"-7.0e240\", \"-0x1.0E+200#1\", Floor, \"-Infinity\", Less);\n    test_helper::<f32>(\n        \"-7.0e240\",\n        \"-0x1.0E+200#1\",\n        Ceiling,\n        \"-3.4028235e38\",\n        Greater,\n    );\n    test_helper::<f32>(\"-7.0e240\", \"-0x1.0E+200#1\", Down, \"-3.4028235e38\", Greater);\n    test_helper::<f32>(\"-7.0e240\", \"-0x1.0E+200#1\", Up, \"-Infinity\", Less);\n    test_helper::<f32>(\"-7.0e240\", \"-0x1.0E+200#1\", Nearest, \"-Infinity\", Less);\n\n    test_helper::<f64>(\n        \"-7.0e240\",\n        \"-0x1.0E+200#1\",\n        Floor,\n        \"-6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-7.0e240\",\n        \"-0x1.0E+200#1\",\n        Ceiling,\n        \"-6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-7.0e240\",\n        \"-0x1.0E+200#1\",\n        Down,\n        \"-6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-7.0e240\",\n        \"-0x1.0E+200#1\",\n        Up,\n        \"-6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-7.0e240\",\n        \"-0x1.0E+200#1\",\n        Nearest,\n        \"-6.668014432879854e240\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-7.0e240\",\n        \"-0x1.0E+200#1\",\n        Exact,\n        \"-6.668014432879854e240\",\n        Equal,\n    );\n\n    test_helper::<f32>(\"-2.0e2408\", \"-0x1.0E+2000#1\", Floor, \"-Infinity\", Less);\n    test_helper::<f32>(\n        \"-2.0e2408\",\n        \"-0x1.0E+2000#1\",\n        Ceiling,\n        \"-3.4028235e38\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"-2.0e2408\",\n        \"-0x1.0E+2000#1\",\n        Down,\n        \"-3.4028235e38\",\n        Greater,\n    );\n    test_helper::<f32>(\"-2.0e2408\", \"-0x1.0E+2000#1\", Up, \"-Infinity\", Less);\n    test_helper::<f32>(\"-2.0e2408\", \"-0x1.0E+2000#1\", Nearest, \"-Infinity\", Less);\n\n    test_helper::<f64>(\"-2.0e2408\", \"-0x1.0E+2000#1\", Floor, \"-Infinity\", Less);\n    test_helper::<f64>(\n        \"-2.0e2408\",\n        \"-0x1.0E+2000#1\",\n        Ceiling,\n        \"-1.7976931348623157e308\",\n        Greater,\n    );\n    test_helper::<f64>(\n        \"-2.0e2408\",\n        \"-0x1.0E+2000#1\",\n        Down,\n        \"-1.7976931348623157e308\",\n        Greater,\n    );\n    test_helper::<f64>(\"-2.0e2408\", \"-0x1.0E+2000#1\", Up, \"-Infinity\", Less);\n    test_helper::<f64>(\"-2.0e2408\", \"-0x1.0E+2000#1\", Nearest, \"-Infinity\", Less);\n\n    test_helper::<f32>(\"-1.0e-241\", \"-0x1.0E-200#1\", Floor, \"-1.0e-45\", Less);\n    test_helper::<f32>(\"-1.0e-241\", \"-0x1.0E-200#1\", Ceiling, \"-0.0\", Greater);\n    test_helper::<f32>(\"-1.0e-241\", \"-0x1.0E-200#1\", Down, \"-0.0\", Greater);\n    test_helper::<f32>(\"-1.0e-241\", \"-0x1.0E-200#1\", Up, \"-1.0e-45\", Less);\n    test_helper::<f32>(\"-1.0e-241\", \"-0x1.0E-200#1\", Nearest, \"-0.0\", Greater);\n\n    test_helper::<f64>(\n        \"-1.0e-241\",\n        \"-0x1.0E-200#1\",\n        Floor,\n        \"-1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-1.0e-241\",\n        \"-0x1.0E-200#1\",\n        Ceiling,\n        \"-1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-1.0e-241\",\n        \"-0x1.0E-200#1\",\n        Down,\n        \"-1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-1.0e-241\",\n        \"-0x1.0E-200#1\",\n        Up,\n        \"-1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-1.0e-241\",\n        \"-0x1.0E-200#1\",\n        Nearest,\n        \"-1.499696813895631e-241\",\n        Equal,\n    );\n    test_helper::<f64>(\n        \"-1.0e-241\",\n        \"-0x1.0E-200#1\",\n        Exact,\n        \"-1.499696813895631e-241\",\n        Equal,\n    );\n\n    test_helper::<f32>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Floor, \"-1.0e-45\", Less);\n    test_helper::<f32>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Ceiling, \"-0.0\", Greater);\n    test_helper::<f32>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Down, \"-0.0\", Greater);\n    test_helper::<f32>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Up, \"-1.0e-45\", Less);\n    test_helper::<f32>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Nearest, \"-0.0\", Greater);\n\n    test_helper::<f64>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Floor, \"-5.0e-324\", Less);\n    test_helper::<f64>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Ceiling, \"-0.0\", Greater);\n    test_helper::<f64>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Down, \"-0.0\", Greater);\n    test_helper::<f64>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Up, \"-5.0e-324\", Less);\n    test_helper::<f64>(\"-6.0e-2409\", \"-0x1.0E-2000#1\", Nearest, \"-0.0\", Greater);\n\n    test_helper::<f32>(\"-too_big\", \"-0x4.0E+268435455#1\", Floor, \"-Infinity\", Less);\n    test_helper::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Ceiling,\n        \"-3.4028235e38\",\n        Greater,\n    );\n    test_helper::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Down,\n        \"-3.4028235e38\",\n        Greater,\n    );\n    test_helper::<f32>(\"-too_big\", \"-0x4.0E+268435455#1\", Up, \"-Infinity\", Less);\n    test_helper::<f32>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Nearest,\n        \"-Infinity\",\n        Less,\n    );\n\n    test_helper::<f64>(\"-too_big\", \"-0x4.0E+268435455#1\", Floor, \"-Infinity\", Less);\n    test_helper::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Ceiling,\n        \"-1.7976931348623157e308\",\n        Greater,\n    );\n    test_helper::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Down,\n        \"-1.7976931348623157e308\",\n        Greater,\n    );\n    test_helper::<f64>(\"-too_big\", \"-0x4.0E+268435455#1\", Up, \"-Infinity\", Less);\n    test_helper::<f64>(\n        \"-too_big\",\n        \"-0x4.0E+268435455#1\",\n        Nearest,\n        \"-Infinity\",\n        Less,\n    );\n\n    test_helper::<f32>(\"-too_small\", \"-0x1.0E-268435456#1\", Floor, \"-1.0e-45\", Less);\n    test_helper::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Ceiling,\n        \"-0.0\",\n        Greater,\n    );\n    test_helper::<f32>(\"-too_small\", \"-0x1.0E-268435456#1\", Down, \"-0.0\", Greater);\n    test_helper::<f32>(\"-too_small\", \"-0x1.0E-268435456#1\", Up, \"-1.0e-45\", Less);\n    test_helper::<f32>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Nearest,\n        \"-0.0\",\n        Greater,\n    );\n\n    test_helper::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Floor,\n        \"-5.0e-324\",\n        Less,\n    );\n    test_helper::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Ceiling,\n        \"-0.0\",\n        Greater,\n    );\n    test_helper::<f64>(\"-too_small\", \"-0x1.0E-268435456#1\", Down, \"-0.0\", Greater);\n    test_helper::<f64>(\"-too_small\", \"-0x1.0E-268435456#1\", Up, \"-5.0e-324\", Less);\n    test_helper::<f64>(\n        \"-too_small\",\n        \"-0x1.0E-268435456#1\",\n        Nearest,\n        \"-0.0\",\n        Greater,\n    );\n}\n\nfn rounding_from_float_fail_helper<T: PrimitiveFloat + RoundingFrom<Float>>() {\n    assert_panic!(T::rounding_from(\n        Float::from_rational_prec(Rational::from_unsigneds(1u8, 3), 100).0,\n        Exact\n    ));\n    assert_panic!(T::rounding_from(\n        Float::exact_from(Rational::power_of_2(10000i64)),\n        Exact\n    ));\n    assert_panic!(T::rounding_from(\n        Float::exact_from(Rational::power_of_2(-10000i64)),\n        Exact\n    ));\n    assert_panic!(T::rounding_from(\n        Float::from_rational_prec(Rational::from_signeds(-1, 3), 100).0,\n        Exact\n    ));\n    assert_panic!(T::rounding_from(\n        Float::exact_from(-Rational::power_of_2(10000i64)),\n        Exact\n    ));\n    assert_panic!(T::rounding_from(\n        Float::exact_from(-Rational::power_of_2(-10000i64)),\n        Exact\n    ));\n}\n\n#[test]\nfn rounding_from_float_fail() {\n    apply_fn_to_primitive_floats!(rounding_from_float_fail_helper);\n}\n\n#[allow(\n    clippy::type_repetition_in_bounds,\n    clippy::op_ref,\n    clippy::needless_pass_by_value\n)]\nfn try_from_float_properties_helper_helper<\n    T: PrimitiveFloat + PartialEq<Float> + TryFrom<Float, Error = FloatFromFloatError>,\n>(\n    x: Float,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + TryFrom<&'a Float, Error = FloatFromFloatError>,\n    Float: From<T> + PartialEq<T>,\n{\n    let t_x = T::try_from(x.clone());\n\n    let t_x_alt = T::try_from(&x);\n    assert_eq!(t_x.map(NiceFloat), t_x_alt.map(NiceFloat));\n\n    assert_eq!(t_x.is_ok(), T::convertible_from(&x));\n    if let Ok(n) = t_x {\n        assert_eq!(NiceFloat(T::exact_from(&x)), NiceFloat(n));\n        assert!(n.is_nan() && x.is_nan() || n == x);\n        let n_alt = Float::from(n);\n        assert!(n_alt.is_nan() && x.is_nan() || &n_alt == &x);\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds, clippy::op_ref)]\nfn try_from_float_properties_helper<\n    T: PrimitiveFloat + PartialEq<Float> + TryFrom<Float, Error = FloatFromFloatError>,\n>()\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float> + TryFrom<&'a Float, Error = FloatFromFloatError>,\n    Float: From<T> + PartialEq<T>,\n{\n    float_gen().test_properties(|x| {\n        try_from_float_properties_helper_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        try_from_float_properties_helper_helper(x);\n    });\n}\n\n#[test]\nfn try_from_float_properties() {\n    apply_fn_to_primitive_floats!(try_from_float_properties_helper);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn convertible_from_float_properties_helper_helper<T>(x: Float)\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    T::convertible_from(&x);\n}\n\nfn convertible_from_float_properties_helper<T>()\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    float_gen().test_properties(|x| {\n        convertible_from_float_properties_helper_helper::<T>(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        convertible_from_float_properties_helper_helper::<T>(x);\n    });\n}\n\n#[test]\nfn convertible_from_float_properties() {\n    apply_fn_to_primitive_floats!(convertible_from_float_properties_helper);\n}\n\nconst fn wrap_nice_float<T: PrimitiveFloat>(p: (T, Ordering)) -> (NiceFloat<T>, Ordering) {\n    (NiceFloat(p.0), p.1)\n}\n\n#[allow(clippy::type_repetition_in_bounds, clippy::needless_pass_by_value)]\nfn rounding_from_float_properties_helper_helper<\n    T: PrimitiveFloat + RoundingFrom<Float> + PartialOrd<Integer>,\n>(\n    x: Float,\n    rm: RoundingMode,\n    extreme: bool,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + PartialOrd<Float> + RoundingFrom<&'a Float>,\n    Float: From<T> + PartialOrd<T>,\n    Rational: TryFrom<T>,\n{\n    let no = T::rounding_from(&x, rm);\n    let no_alt = T::rounding_from(x.clone(), rm);\n    assert_eq!(NiceFloat(no_alt.0), NiceFloat(no.0));\n    assert_eq!(no_alt.1, no.1);\n    let (n, o) = no;\n    if !extreme && n > -T::MAX_FINITE && n < T::MAX_FINITE && n != T::ZERO {\n        let r_x: Rational = ExactFrom::<&Float>::exact_from(&x);\n        assert!((Rational::exact_from(n) - r_x).lt_abs(&Float::from(n).ulp().unwrap()));\n    }\n\n    assert_eq!(n.partial_cmp(&x), if x.is_nan() { None } else { Some(o) });\n    match (x >= T::ZERO, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn rounding_from_float_properties_helper<\n    T: PrimitiveFloat + RoundingFrom<Float> + PartialOrd<Integer>,\n>()\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float> + PartialOrd<Float> + RoundingFrom<&'a Float>,\n    Float: From<T> + PartialOrd<T>,\n    Rational: TryFrom<T>,\n{\n    float_rounding_mode_pair_gen_var_6::<T>().test_properties(|(x, rm)| {\n        rounding_from_float_properties_helper_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_20::<T>().test_properties(|(x, rm)| {\n        rounding_from_float_properties_helper_helper(x, rm, true);\n    });\n\n    float_gen_var_4().test_properties(|x| {\n        let floor = T::rounding_from(&x, Floor);\n        assert!(floor.0 <= x);\n        assert_eq!(\n            T::rounding_from(&x, if x >= T::ZERO { Down } else { Up }),\n            floor\n        );\n        let ceiling = T::rounding_from(&x, Ceiling);\n        assert!(ceiling.0 >= x);\n        assert_eq!(\n            T::rounding_from(&x, if x >= T::ZERO { Up } else { Down }),\n            ceiling\n        );\n        let nearest = T::rounding_from(&x, Nearest);\n        assert!(nearest == floor || nearest == ceiling);\n        if nearest.0 > -T::MAX_FINITE && nearest.0 < T::MAX_FINITE && nearest.0 != T::ZERO {\n            let r_x: Rational = ExactFrom::<&Float>::exact_from(&x);\n            let rulp: Rational = ExactFrom::exact_from(Float::from(nearest.0).ulp().unwrap());\n            assert!((Rational::exact_from(nearest.0) - r_x).le_abs(&(rulp >> 1u32)));\n        }\n    });\n\n    primitive_float_gen::<T>().test_properties(|n| {\n        let x = Float::from(n);\n        let no = (NiceFloat(n), Equal);\n        assert_eq!(wrap_nice_float(T::rounding_from(&x, Floor)), no);\n        assert_eq!(wrap_nice_float(T::rounding_from(&x, Down)), no);\n        assert_eq!(wrap_nice_float(T::rounding_from(&x, Ceiling)), no);\n        assert_eq!(wrap_nice_float(T::rounding_from(&x, Up)), no);\n        assert_eq!(wrap_nice_float(T::rounding_from(&x, Nearest)), no);\n        assert_eq!(wrap_nice_float(T::rounding_from(&x, Exact)), no);\n    });\n}\n\n#[allow(clippy::manual_range_contains)]\n#[test]\nfn rounding_from_float_properties() {\n    apply_fn_to_primitive_floats!(rounding_from_float_properties_helper);\n\n    float_rounding_mode_pair_gen_var_6::<f32>().test_properties(|(x, rm)| {\n        if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n            assert_eq!(\n                NiceFloat(f32::rounding_from(&x, rm).0),\n                NiceFloat(rug::Float::exact_from(&x).to_f32_round(rug_rm)),\n            );\n        }\n    });\n\n    float_rounding_mode_pair_gen_var_6::<f64>().test_properties(|(x, rm)| {\n        if let Ok(rug_rm) = rug_round_try_from_rounding_mode(rm) {\n            assert_eq!(\n                NiceFloat(f64::rounding_from(&x, rm).0),\n                NiceFloat(rug::Float::exact_from(&x).to_f64_round(rug_rm)),\n            );\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/primitive_int_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ceiling, Floor};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{Infinity, NaN, NegativeInfinity, NegativeOne, OneHalf};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::from::{SignedFromFloatError, UnsignedFromFloatError};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_float::Float;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::{\n    float_gen, float_gen_var_4, float_gen_var_5, float_gen_var_12,\n    float_rounding_mode_pair_gen_var_4, float_rounding_mode_pair_gen_var_5,\n    float_rounding_mode_pair_gen_var_18, float_rounding_mode_pair_gen_var_19,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\n\n#[allow(clippy::type_repetition_in_bounds)]\n#[test]\nfn test_try_from_float() {\n    fn test_helper_u<T: PrimitiveUnsigned + TryFrom<Float, Error = UnsignedFromFloatError>>(\n        s: &str,\n        s_hex: &str,\n        out: &str,\n    ) where\n        for<'a> T: TryFrom<&'a Float, Error = UnsignedFromFloatError>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let on = T::try_from(x.clone());\n        assert_eq!(on.to_debug_string(), out);\n\n        let on = T::try_from(&x);\n        assert_eq!(on.to_debug_string(), out);\n    }\n    fn test_helper_u2<T: PrimitiveUnsigned + TryFrom<Float, Error = UnsignedFromFloatError>>()\n    where\n        for<'a> T: TryFrom<&'a Float, Error = UnsignedFromFloatError>,\n    {\n        test_helper_u::<T>(\"NaN\", \"NaN\", \"Err(FloatInfiniteOrNan)\");\n        test_helper_u::<T>(\"Infinity\", \"Infinity\", \"Err(FloatInfiniteOrNan)\");\n        test_helper_u::<T>(\"-Infinity\", \"-Infinity\", \"Err(FloatInfiniteOrNan)\");\n        test_helper_u::<T>(\"0.0\", \"0x0.0\", \"Ok(0)\");\n        test_helper_u::<T>(\"-0.0\", \"-0x0.0\", \"Ok(0)\");\n\n        test_helper_u::<T>(\"1.0\", \"0x1.0#1\", \"Ok(1)\");\n        test_helper_u::<T>(\"2.0\", \"0x2.0#1\", \"Ok(2)\");\n        test_helper_u::<T>(\"0.5\", \"0x0.8#1\", \"Err(FloatNonIntegerOrOutOfRange)\");\n        test_helper_u::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n        test_helper_u::<T>(\"123.0\", \"0x7b.0#7\", \"Ok(123)\");\n        test_helper_u::<T>(\n            \"too_big\",\n            \"0x4.0E+268435455#1\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n        test_helper_u::<T>(\n            \"too_small\",\n            \"0x1.0E-268435456#1\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n\n        test_helper_u::<T>(\"-1.0\", \"-0x1.0#1\", \"Err(FloatNegative)\");\n        test_helper_u::<T>(\"-2.0\", \"-0x2.0#1\", \"Err(FloatNegative)\");\n        test_helper_u::<T>(\"-0.5\", \"-0x0.8#1\", \"Err(FloatNegative)\");\n        test_helper_u::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            \"Err(FloatNegative)\",\n        );\n        test_helper_u::<T>(\"-123.0\", \"-0x7b.0#7\", \"Err(FloatNegative)\");\n        test_helper_u::<T>(\n            \"-1000000000000.0\",\n            \"-0xe8d4a51000.0#40\",\n            \"Err(FloatNegative)\",\n        );\n        test_helper_u::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", \"Err(FloatNegative)\");\n        test_helper_u::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", \"Err(FloatNegative)\");\n    }\n    apply_fn_to_unsigneds!(test_helper_u2);\n    test_helper_u::<u64>(\"1000000000000.0\", \"0xe8d4a51000.0#40\", \"Ok(1000000000000)\");\n\n    fn test_helper_i<T: PrimitiveSigned + TryFrom<Float, Error = SignedFromFloatError>>(\n        s: &str,\n        s_hex: &str,\n        out: &str,\n    ) where\n        for<'a> T: TryFrom<&'a Float, Error = SignedFromFloatError>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let on = T::try_from(x.clone());\n        assert_eq!(on.to_debug_string(), out);\n\n        let on = T::try_from(&x);\n        assert_eq!(on.to_debug_string(), out);\n    }\n    fn test_helper_i2<T: PrimitiveSigned + TryFrom<Float, Error = SignedFromFloatError>>()\n    where\n        for<'a> T: TryFrom<&'a Float, Error = SignedFromFloatError>,\n    {\n        test_helper_i::<T>(\"NaN\", \"NaN\", \"Err(FloatInfiniteOrNan)\");\n        test_helper_i::<T>(\"Infinity\", \"Infinity\", \"Err(FloatInfiniteOrNan)\");\n        test_helper_i::<T>(\"-Infinity\", \"-Infinity\", \"Err(FloatInfiniteOrNan)\");\n        test_helper_i::<T>(\"0.0\", \"0x0.0\", \"Ok(0)\");\n        test_helper_i::<T>(\"-0.0\", \"-0x0.0\", \"Ok(0)\");\n\n        test_helper_i::<T>(\"1.0\", \"0x1.0#1\", \"Ok(1)\");\n        test_helper_i::<T>(\"2.0\", \"0x2.0#1\", \"Ok(2)\");\n        test_helper_i::<T>(\"0.5\", \"0x0.8#1\", \"Err(FloatNonIntegerOrOutOfRange)\");\n        test_helper_i::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n        test_helper_i::<T>(\"123.0\", \"0x7b.0#7\", \"Ok(123)\");\n        test_helper_i::<T>(\n            \"too_big\",\n            \"0x4.0E+268435455#1\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n        test_helper_i::<T>(\n            \"too_small\",\n            \"0x1.0E-268435456#1\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n\n        test_helper_i::<T>(\"-1.0\", \"-0x1.0#1\", \"Ok(-1)\");\n        test_helper_i::<T>(\"-2.0\", \"-0x2.0#1\", \"Ok(-2)\");\n        test_helper_i::<T>(\"-0.5\", \"-0x0.8#1\", \"Err(FloatNonIntegerOrOutOfRange)\");\n        test_helper_i::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n        test_helper_i::<T>(\"-123.0\", \"-0x7b.0#7\", \"Ok(-123)\");\n        test_helper_i::<T>(\n            \"-too_big\",\n            \"-0x4.0E+268435455#1\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n        test_helper_i::<T>(\n            \"-too_small\",\n            \"-0x1.0E-268435456#1\",\n            \"Err(FloatNonIntegerOrOutOfRange)\",\n        );\n    }\n    apply_fn_to_signeds!(test_helper_i2);\n    test_helper_i::<i64>(\"1000000000000.0\", \"0xe8d4a51000.0#40\", \"Ok(1000000000000)\");\n    test_helper_i::<i64>(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        \"Ok(-1000000000000)\",\n    );\n}\n\n#[test]\nfn test_convertible_from_float() {\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper<T: PrimitiveInt>(s: &str, s_hex: &str, out: bool)\n    where\n        for<'a> T: ConvertibleFrom<&'a Float>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(T::convertible_from(&x), out);\n    }\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper_u<T: PrimitiveUnsigned>()\n    where\n        for<'a> T: ConvertibleFrom<&'a Float>,\n    {\n        test_helper::<T>(\"NaN\", \"NaN\", false);\n        test_helper::<T>(\"Infinity\", \"Infinity\", false);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", false);\n        test_helper::<T>(\"0.0\", \"0x0.0\", true);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", true);\n\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", true);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", true);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", false);\n        test_helper::<T>(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", true);\n        test_helper::<T>(\"too_big\", \"0x4.0E+268435455#1\", false);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", false);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", false);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", false);\n        test_helper::<T>(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", false);\n        test_helper::<T>(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", false);\n        test_helper::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n    }\n    apply_fn_to_unsigneds!(test_helper_u);\n    test_helper::<u64>(\"1000000000000.0\", \"0xe8d4a51000.0#40\", true);\n\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper_i<T: PrimitiveSigned>()\n    where\n        for<'a> T: ConvertibleFrom<&'a Float>,\n    {\n        test_helper::<T>(\"NaN\", \"NaN\", false);\n        test_helper::<T>(\"Infinity\", \"Infinity\", false);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", false);\n        test_helper::<T>(\"0.0\", \"0x0.0\", true);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", true);\n\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", true);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", true);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", false);\n        test_helper::<T>(\"0.33333333333333331\", \"0x0.55555555555554#53\", false);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", true);\n        test_helper::<T>(\"too_big\", \"0x4.0E+268435455#1\", false);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", false);\n\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", true);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", true);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", false);\n        test_helper::<T>(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", false);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", true);\n        test_helper::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", false);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", false);\n    }\n    apply_fn_to_signeds!(test_helper_i);\n    test_helper::<i64>(\"1000000000000.0\", \"0xe8d4a51000.0#40\", true);\n    test_helper::<i64>(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", true);\n}\n\n#[test]\nfn test_rounding_from_float() {\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper<T: PrimitiveInt + RoundingFrom<Float>>(\n        s: &str,\n        s_hex: &str,\n        rm: RoundingMode,\n        out: &str,\n        o_out: Ordering,\n    ) where\n        for<'a> T: RoundingFrom<&'a Float>,\n    {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let (n, o) = T::rounding_from(x.clone(), rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(o, o_out);\n\n        let (n, o) = T::rounding_from(&x, rm);\n        assert_eq!(n.to_string(), out);\n        assert_eq!(o, o_out);\n    }\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper_u<T: PrimitiveUnsigned + RoundingFrom<Float>>()\n    where\n        for<'a> T: RoundingFrom<&'a Float>,\n    {\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Down, \"0\", Greater);\n        test_helper::<T>(\"-Infinity\", \"-Infinity\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\"0.0\", \"0x0.0\", Floor, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Ceiling, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Down, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Up, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Nearest, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Exact, \"0\", Equal);\n\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Floor, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Ceiling, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Down, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Up, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Nearest, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Exact, \"0\", Equal);\n\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Floor, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Ceiling, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Down, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Up, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Nearest, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Exact, \"1\", Equal);\n\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Floor, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Ceiling, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Down, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Up, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Nearest, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Exact, \"2\", Equal);\n\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Floor, \"0\", Less);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Ceiling, \"1\", Greater);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Down, \"0\", Less);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Up, \"1\", Greater);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Nearest, \"0\", Less);\n\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Floor,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Ceiling,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Down,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Up,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Nearest,\n            \"0\",\n            Less,\n        );\n\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Floor,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Ceiling,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Down,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Up,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Nearest,\n            \"1\",\n            Greater,\n        );\n\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Floor, \"1\", Less);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Ceiling, \"2\", Greater);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Down, \"1\", Less);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Up, \"2\", Greater);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Nearest, \"2\", Greater);\n\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Floor, \"2\", Less);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Ceiling, \"3\", Greater);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Down, \"2\", Less);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Up, \"3\", Greater);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Nearest, \"2\", Less);\n\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Floor, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Ceiling, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Down, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Up, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Nearest, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Exact, \"123\", Equal);\n\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Floor, \"0\", Less);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Ceiling, \"1\", Greater);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Down, \"0\", Less);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Up, \"1\", Greater);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Nearest, \"0\", Less);\n\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Down, \"0\", Greater);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Down, \"0\", Greater);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Down, \"0\", Greater);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Ceiling,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Down,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Nearest,\n            \"0\",\n            Greater,\n        );\n\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Ceiling,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Down,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Nearest,\n            \"0\",\n            Greater,\n        );\n\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Down, \"0\", Greater);\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Down, \"0\", Greater);\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Down, \"0\", Greater);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", Down, \"0\", Greater);\n        test_helper::<T>(\"-too_big\", \"-0x4.0E+268435455#1\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Down, \"0\", Greater);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Nearest, \"0\", Greater);\n    }\n    apply_fn_to_unsigneds!(test_helper_u);\n    test_helper::<u8>(\"too_big\", \"0x4.0E+268435455#1\", Floor, \"255\", Less);\n    test_helper::<u8>(\"too_big\", \"0x4.0E+268435455#1\", Down, \"255\", Less);\n    test_helper::<u8>(\"too_big\", \"0x4.0E+268435455#1\", Nearest, \"255\", Less);\n\n    #[allow(clippy::type_repetition_in_bounds)]\n    fn test_helper_i<T: PrimitiveSigned + RoundingFrom<Float>>()\n    where\n        for<'a> T: RoundingFrom<&'a Float>,\n    {\n        test_helper::<T>(\"0.0\", \"0x0.0\", Floor, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Ceiling, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Down, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Up, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Nearest, \"0\", Equal);\n        test_helper::<T>(\"0.0\", \"0x0.0\", Exact, \"0\", Equal);\n\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Floor, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Ceiling, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Down, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Up, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Nearest, \"0\", Equal);\n        test_helper::<T>(\"-0.0\", \"-0x0.0\", Exact, \"0\", Equal);\n\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Floor, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Ceiling, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Down, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Up, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Nearest, \"1\", Equal);\n        test_helper::<T>(\"1.0\", \"0x1.0#1\", Exact, \"1\", Equal);\n\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Floor, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Ceiling, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Down, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Up, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Nearest, \"2\", Equal);\n        test_helper::<T>(\"2.0\", \"0x2.0#1\", Exact, \"2\", Equal);\n\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Floor, \"0\", Less);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Ceiling, \"1\", Greater);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Down, \"0\", Less);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Up, \"1\", Greater);\n        test_helper::<T>(\"0.5\", \"0x0.8#1\", Nearest, \"0\", Less);\n\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Floor,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Ceiling,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Down,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Up,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.33333333333333331\",\n            \"0x0.55555555555554#53\",\n            Nearest,\n            \"0\",\n            Less,\n        );\n\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Floor,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Ceiling,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Down,\n            \"0\",\n            Less,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Up,\n            \"1\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"0.6666666666666666\",\n            \"0x0.aaaaaaaaaaaaa8#53\",\n            Nearest,\n            \"1\",\n            Greater,\n        );\n\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Floor, \"1\", Less);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Ceiling, \"2\", Greater);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Down, \"1\", Less);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Up, \"2\", Greater);\n        test_helper::<T>(\"1.5\", \"0x1.8#2\", Nearest, \"2\", Greater);\n\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Floor, \"2\", Less);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Ceiling, \"3\", Greater);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Down, \"2\", Less);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Up, \"3\", Greater);\n        test_helper::<T>(\"2.5\", \"0x2.8#3\", Nearest, \"2\", Less);\n\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Floor, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Ceiling, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Down, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Up, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Nearest, \"123\", Equal);\n        test_helper::<T>(\"123.0\", \"0x7b.0#7\", Exact, \"123\", Equal);\n\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Floor, \"0\", Less);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Ceiling, \"1\", Greater);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Down, \"0\", Less);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Up, \"1\", Greater);\n        test_helper::<T>(\"too_small\", \"0x1.0E-268435456#1\", Nearest, \"0\", Less);\n\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Floor, \"-1\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Ceiling, \"-1\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Down, \"-1\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Up, \"-1\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Nearest, \"-1\", Equal);\n        test_helper::<T>(\"-1.0\", \"-0x1.0#1\", Exact, \"-1\", Equal);\n\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Floor, \"-2\", Equal);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Ceiling, \"-2\", Equal);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Down, \"-2\", Equal);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Up, \"-2\", Equal);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Nearest, \"-2\", Equal);\n        test_helper::<T>(\"-2.0\", \"-0x2.0#1\", Exact, \"-2\", Equal);\n\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Floor, \"-1\", Less);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Down, \"0\", Greater);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Up, \"-1\", Less);\n        test_helper::<T>(\"-0.5\", \"-0x0.8#1\", Nearest, \"0\", Greater);\n\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Floor,\n            \"-1\",\n            Less,\n        );\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Ceiling,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Down,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Up,\n            \"-1\",\n            Less,\n        );\n        test_helper::<T>(\n            \"-0.33333333333333331\",\n            \"-0x0.55555555555554#53\",\n            Nearest,\n            \"0\",\n            Greater,\n        );\n\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Floor,\n            \"-1\",\n            Less,\n        );\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Ceiling,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Down,\n            \"0\",\n            Greater,\n        );\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Up,\n            \"-1\",\n            Less,\n        );\n        test_helper::<T>(\n            \"-0.6666666666666666\",\n            \"-0x0.aaaaaaaaaaaaa8#53\",\n            Nearest,\n            \"-1\",\n            Less,\n        );\n\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Floor, \"-2\", Less);\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Ceiling, \"-1\", Greater);\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Down, \"-1\", Greater);\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Up, \"-2\", Less);\n        test_helper::<T>(\"-1.5\", \"-0x1.8#2\", Nearest, \"-2\", Less);\n\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Floor, \"-3\", Less);\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Ceiling, \"-2\", Greater);\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Down, \"-2\", Greater);\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Up, \"-3\", Less);\n        test_helper::<T>(\"-2.5\", \"-0x2.8#3\", Nearest, \"-2\", Greater);\n\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Floor, \"-123\", Equal);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Ceiling, \"-123\", Equal);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Down, \"-123\", Equal);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Up, \"-123\", Equal);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Nearest, \"-123\", Equal);\n        test_helper::<T>(\"-123.0\", \"-0x7b.0#7\", Exact, \"-123\", Equal);\n\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Floor, \"-1\", Less);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Ceiling, \"0\", Greater);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Down, \"0\", Greater);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Up, \"-1\", Less);\n        test_helper::<T>(\"-too_small\", \"-0x1.0E-268435456#1\", Nearest, \"0\", Greater);\n    }\n    apply_fn_to_signeds!(test_helper_i);\n    test_helper::<i8>(\"too_big\", \"0x4.0E+268435455#1\", Floor, \"127\", Less);\n    test_helper::<i8>(\"too_big\", \"0x4.0E+268435455#1\", Down, \"127\", Less);\n    test_helper::<i8>(\"too_big\", \"0x4.0E+268435455#1\", Nearest, \"127\", Less);\n\n    test_helper::<i8>(\"-too_big\", \"-0x4.0E+268435455#1\", Ceiling, \"-128\", Greater);\n    test_helper::<i8>(\"-too_big\", \"-0x4.0E+268435455#1\", Down, \"-128\", Greater);\n    test_helper::<i8>(\"-too_big\", \"-0x4.0E+268435455#1\", Nearest, \"-128\", Greater);\n}\n\nfn unsigned_rounding_from_float_fail_helper<T: PrimitiveUnsigned + RoundingFrom<Float>>() {\n    assert_panic!(T::rounding_from(Float::NAN, Floor));\n    assert_panic!(T::rounding_from(Float::NAN, Ceiling));\n    assert_panic!(T::rounding_from(Float::NAN, Down));\n    assert_panic!(T::rounding_from(Float::NAN, Up));\n    assert_panic!(T::rounding_from(Float::NAN, Nearest));\n    assert_panic!(T::rounding_from(Float::NAN, Exact));\n\n    assert_panic!(T::rounding_from(Float::INFINITY, Ceiling));\n    assert_panic!(T::rounding_from(Float::INFINITY, Up));\n    assert_panic!(T::rounding_from(Float::INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(T::rounding_from(Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(T::rounding_from(Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(Float::NEGATIVE_ONE, Floor));\n    assert_panic!(T::rounding_from(Float::NEGATIVE_ONE, Up));\n    assert_panic!(T::rounding_from(Float::NEGATIVE_ONE, Exact));\n\n    assert_panic!(T::rounding_from(Float::from(3u8) >> 1, Exact));\n}\n\nfn signed_rounding_from_float_fail_helper<T: PrimitiveSigned + RoundingFrom<Float>>() {\n    assert_panic!(T::rounding_from(Float::NAN, Floor));\n    assert_panic!(T::rounding_from(Float::NAN, Ceiling));\n    assert_panic!(T::rounding_from(Float::NAN, Down));\n    assert_panic!(T::rounding_from(Float::NAN, Up));\n    assert_panic!(T::rounding_from(Float::NAN, Nearest));\n    assert_panic!(T::rounding_from(Float::NAN, Exact));\n\n    assert_panic!(T::rounding_from(Float::INFINITY, Ceiling));\n    assert_panic!(T::rounding_from(Float::INFINITY, Up));\n    assert_panic!(T::rounding_from(Float::INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(T::rounding_from(Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(T::rounding_from(Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(Float::from(3u8) >> 1, Exact));\n    assert_panic!(T::rounding_from(Float::from(-3i8) >> 1, Exact));\n}\n\n#[test]\nfn rounding_from_float_fail() {\n    apply_fn_to_unsigneds!(unsigned_rounding_from_float_fail_helper);\n    apply_fn_to_signeds!(signed_rounding_from_float_fail_helper);\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn unsigned_rounding_from_float_ref_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    for<'a> T: RoundingFrom<&'a Float>,\n{\n    assert_panic!(T::rounding_from(&Float::NAN, Floor));\n    assert_panic!(T::rounding_from(&Float::NAN, Ceiling));\n    assert_panic!(T::rounding_from(&Float::NAN, Down));\n    assert_panic!(T::rounding_from(&Float::NAN, Up));\n    assert_panic!(T::rounding_from(&Float::NAN, Nearest));\n    assert_panic!(T::rounding_from(&Float::NAN, Exact));\n\n    assert_panic!(T::rounding_from(&Float::INFINITY, Ceiling));\n    assert_panic!(T::rounding_from(&Float::INFINITY, Up));\n    assert_panic!(T::rounding_from(&Float::INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_ONE, Floor));\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_ONE, Up));\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_ONE, Exact));\n\n    assert_panic!(T::rounding_from(&(Float::from(3u8) >> 1), Exact));\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn signed_rounding_from_float_ref_fail_helper<T: PrimitiveSigned>()\nwhere\n    for<'a> T: RoundingFrom<&'a Float>,\n{\n    assert_panic!(T::rounding_from(&Float::NAN, Floor));\n    assert_panic!(T::rounding_from(&Float::NAN, Ceiling));\n    assert_panic!(T::rounding_from(&Float::NAN, Down));\n    assert_panic!(T::rounding_from(&Float::NAN, Up));\n    assert_panic!(T::rounding_from(&Float::NAN, Nearest));\n    assert_panic!(T::rounding_from(&Float::NAN, Exact));\n\n    assert_panic!(T::rounding_from(&Float::INFINITY, Ceiling));\n    assert_panic!(T::rounding_from(&Float::INFINITY, Up));\n    assert_panic!(T::rounding_from(&Float::INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_INFINITY, Floor));\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_INFINITY, Up));\n    assert_panic!(T::rounding_from(&Float::NEGATIVE_INFINITY, Exact));\n\n    assert_panic!(T::rounding_from(&(Float::from(3u8) >> 1), Exact));\n    assert_panic!(T::rounding_from(&(Float::from(-3i8) >> 1), Exact));\n}\n\n#[test]\nfn rounding_from_float_ref_fail() {\n    apply_fn_to_unsigneds!(unsigned_rounding_from_float_ref_fail_helper);\n    apply_fn_to_signeds!(signed_rounding_from_float_ref_fail_helper);\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::type_repetition_in_bounds)]\nfn try_from_float_properties_helper_unsigned_helper<\n    T: PrimitiveUnsigned + PartialEq<Float> + TryFrom<Float, Error = UnsignedFromFloatError>,\n>(\n    x: Float,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + TryFrom<&'a Float, Error = UnsignedFromFloatError>,\n    Float: From<T> + PartialEq<T>,\n{\n    let t_x = T::try_from(x.clone());\n\n    let t_x_alt = T::try_from(&x);\n    assert_eq!(t_x, t_x_alt);\n\n    assert_eq!(t_x.is_ok(), T::convertible_from(&x));\n    if let Ok(n) = t_x {\n        assert_eq!(T::exact_from(&x), n);\n        assert_eq!(n, x);\n        assert_eq!(&Float::from(n), &x);\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn try_from_float_properties_helper_unsigned<\n    T: PrimitiveUnsigned + PartialEq<Float> + TryFrom<Float, Error = UnsignedFromFloatError>,\n>()\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float> + TryFrom<&'a Float, Error = UnsignedFromFloatError>,\n    Float: From<T> + PartialEq<T>,\n{\n    float_gen().test_properties(|x| {\n        try_from_float_properties_helper_unsigned_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        try_from_float_properties_helper_unsigned_helper(x);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value, clippy::type_repetition_in_bounds)]\nfn try_from_float_properties_helper_signed_helper<\n    T: PrimitiveSigned + PartialEq<Float> + TryFrom<Float, Error = SignedFromFloatError>,\n>(\n    x: Float,\n) where\n    for<'a> T: ConvertibleFrom<&'a Float> + TryFrom<&'a Float, Error = SignedFromFloatError>,\n    Float: From<T> + PartialEq<T>,\n{\n    let t_x = T::try_from(x.clone());\n\n    let t_x_alt = T::try_from(&x);\n    assert_eq!(t_x, t_x_alt);\n\n    assert_eq!(t_x.is_ok(), T::convertible_from(&x));\n    if let Ok(n) = t_x {\n        assert_eq!(T::exact_from(&x), n);\n        assert_eq!(n, x);\n        assert_eq!(&Float::from(n), &x);\n    }\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn try_from_float_properties_helper_signed<\n    T: PrimitiveSigned + PartialEq<Float> + TryFrom<Float, Error = SignedFromFloatError>,\n>()\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float> + TryFrom<&'a Float, Error = SignedFromFloatError>,\n    Float: From<T> + PartialEq<T>,\n{\n    float_gen().test_properties(|x| {\n        try_from_float_properties_helper_signed_helper(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        try_from_float_properties_helper_signed_helper(x);\n    });\n}\n\n#[test]\nfn try_from_float_properties() {\n    apply_fn_to_unsigneds!(try_from_float_properties_helper_unsigned);\n    apply_fn_to_signeds!(try_from_float_properties_helper_signed);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn convertible_from_float_properties_helper_helper<T>(x: Float)\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    T::convertible_from(&x);\n}\n\nfn convertible_from_float_properties_helper<T>()\nwhere\n    for<'a> T: ConvertibleFrom<&'a Float>,\n{\n    float_gen().test_properties(|x| {\n        convertible_from_float_properties_helper_helper::<T>(x);\n    });\n\n    float_gen_var_12().test_properties(|x| {\n        convertible_from_float_properties_helper_helper::<T>(x);\n    });\n}\n\n#[test]\nfn convertible_from_float_properties() {\n    apply_fn_to_primitive_ints!(convertible_from_float_properties_helper);\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn rounding_from_float_properties_helper_unsigned_helper<\n    T: PrimitiveUnsigned + PartialOrd<Integer> + PartialOrd<Float> + RoundingFrom<Float>,\n>(\n    x: Float,\n    rm: RoundingMode,\n    extreme: bool,\n) where\n    Float: From<T> + PartialOrd<T>,\n    Natural: From<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n    for<'a> Rational: From<T>,\n{\n    let no = T::rounding_from(&x, rm);\n    assert_eq!(T::rounding_from(x.clone(), rm), no);\n    let (n, o) = no;\n    if !extreme && x >= T::ZERO && x <= T::MAX {\n        assert!((Rational::from(n) - Rational::exact_from(&x)).lt_abs(&1));\n    }\n\n    assert_eq!(n.partial_cmp(&x), Some(o));\n    match (x >= T::ZERO, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n}\n\nfn rounding_from_float_properties_helper_unsigned<\n    T: PrimitiveUnsigned + PartialOrd<Integer> + PartialOrd<Float> + RoundingFrom<Float>,\n>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    Natural: From<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n    for<'a> Rational: From<T>,\n{\n    float_rounding_mode_pair_gen_var_4::<T>().test_properties(|(x, rm)| {\n        rounding_from_float_properties_helper_unsigned_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_18::<T>().test_properties(|(x, rm)| {\n        rounding_from_float_properties_helper_unsigned_helper(x, rm, true);\n    });\n\n    float_gen_var_5().test_properties(|x| {\n        let floor = T::rounding_from(&x, Floor);\n        if x <= T::MAX {\n            assert_eq!(floor.0, Rational::exact_from(&x).floor());\n        }\n        assert!(floor.0 <= x);\n        if floor.0 != T::MAX {\n            assert!(floor.0 + T::ONE > x);\n        }\n        assert_eq!(T::rounding_from(&x, Down), floor);\n\n        let nearest = T::rounding_from(&x, Nearest);\n        if x <= T::MAX {\n            let ceiling = T::rounding_from(&x, Ceiling);\n            assert_eq!(ceiling.0, Rational::exact_from(&x).ceiling());\n            assert!(ceiling.0 >= x);\n            if x > T::ZERO {\n                assert!(ceiling.0 - T::ONE < x);\n            }\n            assert_eq!(T::rounding_from(&x, Up), ceiling);\n            assert!(nearest == floor || nearest == ceiling);\n            assert!(\n                (Rational::from(nearest.0) - Rational::exact_from(x)).le_abs(&Rational::ONE_HALF)\n            );\n        } else {\n            assert!(nearest == (T::MAX, Less));\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| {\n        let x = Float::from(n);\n        let no = (n, Equal);\n        assert_eq!(T::rounding_from(&x, Floor), no);\n        assert_eq!(T::rounding_from(&x, Down), no);\n        assert_eq!(T::rounding_from(&x, Ceiling), no);\n        assert_eq!(T::rounding_from(&x, Up), no);\n        assert_eq!(T::rounding_from(&x, Nearest), no);\n        assert_eq!(T::rounding_from(&x, Exact), no);\n\n        let x = Float::from((no.0 << 1) | T::ONE) >> 1;\n        assert!(T::rounding_from(x, Nearest).0.even());\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn rounding_from_float_properties_helper_signed_helper<\n    T: PrimitiveSigned + RoundingFrom<Float> + PartialOrd<Float> + PartialOrd<Integer>,\n>(\n    x: Float,\n    rm: RoundingMode,\n    extreme: bool,\n) where\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n    Integer: From<T> + PartialEq<T>,\n    Rational: From<T>,\n{\n    let no = T::rounding_from(&x, rm);\n    assert_eq!(T::rounding_from(x.clone(), rm), no);\n    let (n, o) = no;\n    if !extreme && x >= T::MIN && x <= T::MAX {\n        assert!((Rational::from(n) - Rational::exact_from(&x)).lt_abs(&1));\n    }\n\n    assert_eq!(n.partial_cmp(&x), Some(o));\n    match (x >= T::ZERO, rm) {\n        (_, Floor) | (true, Down) | (false, Up) => {\n            assert_ne!(o, Greater);\n        }\n        (_, Ceiling) | (true, Up) | (false, Down) => {\n            assert_ne!(o, Less);\n        }\n        (_, Exact) => assert_eq!(o, Equal),\n        _ => {}\n    }\n}\n\nfn rounding_from_float_properties_helper_signed<\n    T: PrimitiveSigned + RoundingFrom<Float> + PartialOrd<Float> + PartialOrd<Integer>,\n>()\nwhere\n    Float: From<T> + PartialOrd<T>,\n    for<'a> T: ConvertibleFrom<&'a Float> + RoundingFrom<&'a Float>,\n    Integer: From<T> + PartialEq<T>,\n    Rational: From<T>,\n{\n    float_rounding_mode_pair_gen_var_5::<T>().test_properties(|(x, rm)| {\n        rounding_from_float_properties_helper_signed_helper(x, rm, false);\n    });\n\n    float_rounding_mode_pair_gen_var_19::<T>().test_properties(|(x, rm)| {\n        rounding_from_float_properties_helper_signed_helper(x, rm, true);\n    });\n\n    float_gen_var_4().test_properties(|x| {\n        let mut o_floor = None;\n        if x >= T::MIN {\n            let floor = T::rounding_from(&x, Floor);\n            assert!(floor.0 <= x);\n            if x <= T::MAX {\n                assert_eq!(floor.0, Rational::exact_from(&x).floor());\n            }\n            if floor.0 != T::MAX {\n                assert!(floor.0 + T::ONE > x);\n            }\n            assert_eq!(\n                T::rounding_from(&x, if x >= T::ZERO { Down } else { Up }),\n                floor\n            );\n            o_floor = Some(floor);\n        }\n        let mut o_ceiling = None;\n        if x <= T::MAX {\n            let ceiling = T::rounding_from(&x, Ceiling);\n            assert!(ceiling.0 >= x);\n            if x >= T::MIN {\n                assert_eq!(ceiling.0, Rational::exact_from(&x).ceiling());\n            }\n            if ceiling.0 != T::MIN {\n                assert!(ceiling.0 - T::ONE < x);\n            }\n            assert_eq!(\n                T::rounding_from(&x, if x >= T::ZERO { Up } else { Down }),\n                ceiling\n            );\n            o_ceiling = Some(ceiling);\n        }\n        let nearest = T::rounding_from(&x, Nearest);\n        if let Some(floor) = o_floor\n            && let Some(ceiling) = o_ceiling\n        {\n            assert!(nearest == floor || nearest == ceiling);\n        }\n        if x >= T::MIN && x <= T::MAX {\n            assert!(\n                (Rational::from(nearest.0) - Rational::exact_from(x)).le_abs(&Rational::ONE_HALF)\n            );\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| {\n        let x = Float::from(n);\n        let no = (n, Equal);\n        assert_eq!(T::rounding_from(&x, Floor), no);\n        assert_eq!(T::rounding_from(&x, Down), no);\n        assert_eq!(T::rounding_from(&x, Ceiling), no);\n        assert_eq!(T::rounding_from(&x, Up), no);\n        assert_eq!(T::rounding_from(&x, Nearest), no);\n        assert_eq!(T::rounding_from(&x, Exact), no);\n\n        let x = Float::from((no.0 << 1) | T::ONE) >> 1;\n        assert!(T::rounding_from(x, Nearest).0.even());\n    });\n}\n\n#[test]\nfn rounding_from_float_properties() {\n    apply_fn_to_unsigneds!(rounding_from_float_properties_helper_unsigned);\n    apply_fn_to_signeds!(rounding_from_float_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-float/tests/conversion/rational_from_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom};\nuse malachite_base::strings::ToDebugString;\nuse malachite_float::Float;\nuse malachite_float::conversion::rational_from_float::RationalFromFloatError;\nuse malachite_float::test_util::common::parse_hex_string;\nuse malachite_float::test_util::generators::float_gen;\nuse malachite_q::Rational;\n\n#[test]\nfn test_try_from_float() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        let on = Rational::try_from(x.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n\n        let on = Rational::try_from(&x);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(\"NaN\", \"NaN\", \"Err(RationalFromFloatError)\");\n    test(\"Infinity\", \"Infinity\", \"Err(RationalFromFloatError)\");\n    test(\"-Infinity\", \"-Infinity\", \"Err(RationalFromFloatError)\");\n    test(\"0.0\", \"0x0.0\", \"Ok(0)\");\n    test(\"-0.0\", \"-0x0.0\", \"Ok(0)\");\n\n    test(\"1.0\", \"0x1.0#1\", \"Ok(1)\");\n    test(\"2.0\", \"0x2.0#1\", \"Ok(2)\");\n    test(\"0.5\", \"0x0.8#1\", \"Ok(1/2)\");\n    test(\n        \"0.33333333333333331\",\n        \"0x0.55555555555554#53\",\n        \"Ok(6004799503160661/18014398509481984)\",\n    );\n    test(\"123.0\", \"0x7b.0#7\", \"Ok(123)\");\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", \"Ok(1000000000000)\");\n    test(\n        \"1.4142135623730951\",\n        \"0x1.6a09e667f3bcd#53\",\n        \"Ok(6369051672525773/4503599627370496)\",\n    );\n    test(\n        \"3.141592653589793\",\n        \"0x3.243f6a8885a3#50\",\n        \"Ok(884279719003555/281474976710656)\",\n    );\n    test(\n        \"2.7182818284590451\",\n        \"0x2.b7e151628aed2#53\",\n        \"Ok(6121026514868073/2251799813685248)\",\n    );\n\n    test(\"-1.0\", \"-0x1.0#1\", \"Ok(-1)\");\n    test(\"-2.0\", \"-0x2.0#1\", \"Ok(-2)\");\n    test(\"-0.5\", \"-0x0.8#1\", \"Ok(-1/2)\");\n    test(\n        \"-0.33333333333333331\",\n        \"-0x0.55555555555554#53\",\n        \"Ok(-6004799503160661/18014398509481984)\",\n    );\n    test(\"-123.0\", \"-0x7b.0#7\", \"Ok(-123)\");\n    test(\n        \"-1000000000000.0\",\n        \"-0xe8d4a51000.0#40\",\n        \"Ok(-1000000000000)\",\n    );\n    test(\n        \"-1.4142135623730951\",\n        \"-0x1.6a09e667f3bcd#53\",\n        \"Ok(-6369051672525773/4503599627370496)\",\n    );\n    test(\n        \"-3.141592653589793\",\n        \"-0x3.243f6a8885a3#50\",\n        \"Ok(-884279719003555/281474976710656)\",\n    );\n    test(\n        \"-2.7182818284590451\",\n        \"-0x2.b7e151628aed2#53\",\n        \"Ok(-6121026514868073/2251799813685248)\",\n    );\n}\n\n#[test]\nfn test_convertible_from_float() {\n    let test = |s, s_hex, out| {\n        let x = parse_hex_string(s_hex);\n        assert_eq!(x.to_string(), s);\n\n        assert_eq!(Rational::convertible_from(&x), out);\n    };\n    test(\"NaN\", \"NaN\", false);\n    test(\"Infinity\", \"Infinity\", false);\n    test(\"-Infinity\", \"-Infinity\", false);\n    test(\"0.0\", \"0x0.0\", true);\n    test(\"-0.0\", \"-0x0.0\", true);\n\n    test(\"1.0\", \"0x1.0#1\", true);\n    test(\"2.0\", \"0x2.0#1\", true);\n    test(\"0.5\", \"0x0.8#1\", true);\n    test(\"0.33333333333333331\", \"0x0.55555555555554#53\", true);\n    test(\"123.0\", \"0x7b.0#7\", true);\n    test(\"1000000000000.0\", \"0xe8d4a51000.0#40\", true);\n    test(\"1.4142135623730951\", \"0x1.6a09e667f3bcd#53\", true);\n    test(\"3.141592653589793\", \"0x3.243f6a8885a3#50\", true);\n    test(\"2.7182818284590451\", \"0x2.b7e151628aed2#53\", true);\n\n    test(\"-1.0\", \"-0x1.0#1\", true);\n    test(\"-2.0\", \"-0x2.0#1\", true);\n    test(\"-0.5\", \"-0x0.8#1\", true);\n    test(\"-0.33333333333333331\", \"-0x0.55555555555554#53\", true);\n    test(\"-123.0\", \"-0x7b.0#7\", true);\n    test(\"-1000000000000.0\", \"-0xe8d4a51000.0#40\", true);\n    test(\"-1.4142135623730951\", \"-0x1.6a09e667f3bcd#53\", true);\n    test(\"-3.141592653589793\", \"-0x3.243f6a8885a3#50\", true);\n    test(\"-2.7182818284590451\", \"-0x2.b7e151628aed2#53\", true);\n}\n\n#[test]\nfn try_from_float_properties() {\n    float_gen().test_properties(|x| {\n        let rational_x = Rational::try_from(x.clone());\n        assert!(rational_x.as_ref().map_or(true, Rational::is_valid));\n\n        let rational_x_alt = Rational::try_from(&x);\n        assert!(rational_x_alt.as_ref().map_or(true, Rational::is_valid));\n        assert_eq!(rational_x, rational_x_alt);\n\n        assert_eq!(\n            rug::Rational::try_from(rug::Float::exact_from(&x))\n                .map(|q| Rational::from(&q))\n                .map_err(|_| RationalFromFloatError),\n            rational_x\n        );\n\n        assert_eq!(rational_x.is_ok(), Rational::convertible_from(&x));\n        if let Ok(n) = rational_x {\n            assert_eq!(Rational::exact_from(&x), n);\n            assert_eq!(n, x);\n            assert_eq!(Float::exact_from(&n), x);\n            assert_eq!(Float::exact_from(n.clone()), x);\n            assert!(n.denominator_ref().is_power_of_2());\n        }\n    });\n}\n\n#[test]\nfn convertible_from_float_properties() {\n    float_gen().test_properties(|x| {\n        assert_eq!(Rational::convertible_from(&x), x.is_finite());\n    });\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_finite_floats;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\n#[test]\nfn test_exhaustive_finite_floats() {\n    exhaustive_floats_helper_helper_with_limit(\n        100,\n        exhaustive_finite_floats(),\n        &[\n            \"0.0\", \"-0.0\", \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"0.5\",\n            \"-0.5\", \"4.0\", \"-4.0\", \"0.5\", \"-0.5\", \"4.0\", \"-4.0\", \"1.5\", \"-1.5\", \"3.0\", \"-3.0\",\n            \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"0.8\", \"-0.8\", \"6.0\", \"-6.0\", \"0.5\", \"-0.5\", \"4.0\",\n            \"-4.0\", \"0.2\", \"-0.2\", \"8.0\", \"-8.0\", \"0.2\", \"-0.2\", \"8.0\", \"-8.0\", \"0.1\", \"-0.1\",\n            \"2.0e1\", \"-2.0e1\", \"0.1\", \"-0.1\", \"16.0\", \"-16.0\", \"0.4\", \"-0.4\", \"1.0e1\", \"-1.0e1\",\n            \"0.25\", \"-0.25\", \"8.0\", \"-8.0\", \"0.19\", \"-0.19\", \"24.0\", \"-24.0\", \"0.1\", \"-0.1\",\n            \"16.0\", \"-16.0\", \"1.2\", \"-1.2\", \"2.5\", \"-2.5\", \"1.5\", \"-1.5\", \"3.0\", \"-3.0\", \"0.6\",\n            \"-0.6\", \"5.0\", \"-5.0\", \"0.8\", \"-0.8\", \"6.0\", \"-6.0\", \"1.8\", \"-1.8\", \"3.5\", \"-3.5\",\n            \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"0.9\", \"-0.9\", \"7.0\", \"-7.0\", \"0.5\", \"-0.5\", \"4.0\",\n            \"-4.0\", \"0.3\", \"-0.3\",\n        ],\n        &[\n            \"0x0.0\",\n            \"-0x0.0\",\n            \"0x1.0#1\",\n            \"-0x1.0#1\",\n            \"0x2.0#1\",\n            \"-0x2.0#1\",\n            \"0x1.0#2\",\n            \"-0x1.0#2\",\n            \"0x2.0#2\",\n            \"-0x2.0#2\",\n            \"0x0.8#1\",\n            \"-0x0.8#1\",\n            \"0x4.0#1\",\n            \"-0x4.0#1\",\n            \"0x0.8#2\",\n            \"-0x0.8#2\",\n            \"0x4.0#2\",\n            \"-0x4.0#2\",\n            \"0x1.8#2\",\n            \"-0x1.8#2\",\n            \"0x3.0#2\",\n            \"-0x3.0#2\",\n            \"0x1.0#3\",\n            \"-0x1.0#3\",\n            \"0x2.0#3\",\n            \"-0x2.0#3\",\n            \"0x0.c#2\",\n            \"-0x0.c#2\",\n            \"0x6.0#2\",\n            \"-0x6.0#2\",\n            \"0x0.8#3\",\n            \"-0x0.8#3\",\n            \"0x4.0#3\",\n            \"-0x4.0#3\",\n            \"0x0.4#1\",\n            \"-0x0.4#1\",\n            \"0x8.0#1\",\n            \"-0x8.0#1\",\n            \"0x0.4#2\",\n            \"-0x0.4#2\",\n            \"0x8.0#2\",\n            \"-0x8.0#2\",\n            \"0x0.2#1\",\n            \"-0x0.2#1\",\n            \"0x1.0E+1#1\",\n            \"-0x1.0E+1#1\",\n            \"0x0.2#2\",\n            \"-0x0.2#2\",\n            \"0x10.0#2\",\n            \"-0x10.0#2\",\n            \"0x0.6#2\",\n            \"-0x0.6#2\",\n            \"0xc.0#2\",\n            \"-0xc.0#2\",\n            \"0x0.4#3\",\n            \"-0x0.4#3\",\n            \"0x8.0#3\",\n            \"-0x8.0#3\",\n            \"0x0.3#2\",\n            \"-0x0.3#2\",\n            \"0x18.0#2\",\n            \"-0x18.0#2\",\n            \"0x0.20#3\",\n            \"-0x0.20#3\",\n            \"0x10.0#3\",\n            \"-0x10.0#3\",\n            \"0x1.4#3\",\n            \"-0x1.4#3\",\n            \"0x2.8#3\",\n            \"-0x2.8#3\",\n            \"0x1.8#3\",\n            \"-0x1.8#3\",\n            \"0x3.0#3\",\n            \"-0x3.0#3\",\n            \"0x0.a#3\",\n            \"-0x0.a#3\",\n            \"0x5.0#3\",\n            \"-0x5.0#3\",\n            \"0x0.c#3\",\n            \"-0x0.c#3\",\n            \"0x6.0#3\",\n            \"-0x6.0#3\",\n            \"0x1.c#3\",\n            \"-0x1.c#3\",\n            \"0x3.8#3\",\n            \"-0x3.8#3\",\n            \"0x1.0#4\",\n            \"-0x1.0#4\",\n            \"0x2.0#4\",\n            \"-0x2.0#4\",\n            \"0x0.e#3\",\n            \"-0x0.e#3\",\n            \"0x7.0#3\",\n            \"-0x7.0#3\",\n            \"0x0.8#4\",\n            \"-0x0.8#4\",\n            \"0x4.0#4\",\n            \"-0x4.0#4\",\n            \"0x0.5#3\",\n            \"-0x0.5#3\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_floats;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\n#[test]\nfn test_exhaustive_floats() {\n    exhaustive_floats_helper_helper_with_limit(\n        100,\n        exhaustive_floats(),\n        &[\n            \"NaN\",\n            \"Infinity\",\n            \"-Infinity\",\n            \"0.0\",\n            \"-0.0\",\n            \"1.0\",\n            \"-1.0\",\n            \"2.0\",\n            \"-2.0\",\n            \"1.0\",\n            \"-1.0\",\n            \"2.0\",\n            \"-2.0\",\n            \"0.5\",\n            \"-0.5\",\n            \"4.0\",\n            \"-4.0\",\n            \"0.5\",\n            \"-0.5\",\n            \"4.0\",\n            \"-4.0\",\n            \"1.5\",\n            \"-1.5\",\n            \"3.0\",\n            \"-3.0\",\n            \"1.0\",\n            \"-1.0\",\n            \"2.0\",\n            \"-2.0\",\n            \"0.8\",\n            \"-0.8\",\n            \"6.0\",\n            \"-6.0\",\n            \"0.5\",\n            \"-0.5\",\n            \"4.0\",\n            \"-4.0\",\n            \"0.2\",\n            \"-0.2\",\n            \"8.0\",\n            \"-8.0\",\n            \"0.2\",\n            \"-0.2\",\n            \"8.0\",\n            \"-8.0\",\n            \"0.1\",\n            \"-0.1\",\n            \"2.0e1\",\n            \"-2.0e1\",\n            \"0.1\",\n            \"-0.1\",\n            \"16.0\",\n            \"-16.0\",\n            \"0.4\",\n            \"-0.4\",\n            \"1.0e1\",\n            \"-1.0e1\",\n            \"0.25\",\n            \"-0.25\",\n            \"8.0\",\n            \"-8.0\",\n            \"0.19\",\n            \"-0.19\",\n            \"24.0\",\n            \"-24.0\",\n            \"0.1\",\n            \"-0.1\",\n            \"16.0\",\n            \"-16.0\",\n            \"1.2\",\n            \"-1.2\",\n            \"2.5\",\n            \"-2.5\",\n            \"1.5\",\n            \"-1.5\",\n            \"3.0\",\n            \"-3.0\",\n            \"0.6\",\n            \"-0.6\",\n            \"5.0\",\n            \"-5.0\",\n            \"0.8\",\n            \"-0.8\",\n            \"6.0\",\n            \"-6.0\",\n            \"1.8\",\n            \"-1.8\",\n            \"3.5\",\n            \"-3.5\",\n            \"1.0\",\n            \"-1.0\",\n            \"2.0\",\n            \"-2.0\",\n            \"0.9\",\n            \"-0.9\",\n            \"7.0\",\n            \"-7.0\",\n            \"0.5\",\n            \"-0.5\",\n            \"4.0\",\n        ],\n        &[\n            \"NaN\",\n            \"Infinity\",\n            \"-Infinity\",\n            \"0x0.0\",\n            \"-0x0.0\",\n            \"0x1.0#1\",\n            \"-0x1.0#1\",\n            \"0x2.0#1\",\n            \"-0x2.0#1\",\n            \"0x1.0#2\",\n            \"-0x1.0#2\",\n            \"0x2.0#2\",\n            \"-0x2.0#2\",\n            \"0x0.8#1\",\n            \"-0x0.8#1\",\n            \"0x4.0#1\",\n            \"-0x4.0#1\",\n            \"0x0.8#2\",\n            \"-0x0.8#2\",\n            \"0x4.0#2\",\n            \"-0x4.0#2\",\n            \"0x1.8#2\",\n            \"-0x1.8#2\",\n            \"0x3.0#2\",\n            \"-0x3.0#2\",\n            \"0x1.0#3\",\n            \"-0x1.0#3\",\n            \"0x2.0#3\",\n            \"-0x2.0#3\",\n            \"0x0.c#2\",\n            \"-0x0.c#2\",\n            \"0x6.0#2\",\n            \"-0x6.0#2\",\n            \"0x0.8#3\",\n            \"-0x0.8#3\",\n            \"0x4.0#3\",\n            \"-0x4.0#3\",\n            \"0x0.4#1\",\n            \"-0x0.4#1\",\n            \"0x8.0#1\",\n            \"-0x8.0#1\",\n            \"0x0.4#2\",\n            \"-0x0.4#2\",\n            \"0x8.0#2\",\n            \"-0x8.0#2\",\n            \"0x0.2#1\",\n            \"-0x0.2#1\",\n            \"0x1.0E+1#1\",\n            \"-0x1.0E+1#1\",\n            \"0x0.2#2\",\n            \"-0x0.2#2\",\n            \"0x10.0#2\",\n            \"-0x10.0#2\",\n            \"0x0.6#2\",\n            \"-0x0.6#2\",\n            \"0xc.0#2\",\n            \"-0xc.0#2\",\n            \"0x0.4#3\",\n            \"-0x0.4#3\",\n            \"0x8.0#3\",\n            \"-0x8.0#3\",\n            \"0x0.3#2\",\n            \"-0x0.3#2\",\n            \"0x18.0#2\",\n            \"-0x18.0#2\",\n            \"0x0.20#3\",\n            \"-0x0.20#3\",\n            \"0x10.0#3\",\n            \"-0x10.0#3\",\n            \"0x1.4#3\",\n            \"-0x1.4#3\",\n            \"0x2.8#3\",\n            \"-0x2.8#3\",\n            \"0x1.8#3\",\n            \"-0x1.8#3\",\n            \"0x3.0#3\",\n            \"-0x3.0#3\",\n            \"0x0.a#3\",\n            \"-0x0.a#3\",\n            \"0x5.0#3\",\n            \"-0x5.0#3\",\n            \"0x0.c#3\",\n            \"-0x0.c#3\",\n            \"0x6.0#3\",\n            \"-0x6.0#3\",\n            \"0x1.c#3\",\n            \"-0x1.c#3\",\n            \"0x3.8#3\",\n            \"-0x3.8#3\",\n            \"0x1.0#4\",\n            \"-0x1.0#4\",\n            \"0x2.0#4\",\n            \"-0x2.0#4\",\n            \"0x0.e#3\",\n            \"-0x0.e#3\",\n            \"0x7.0#3\",\n            \"-0x7.0#3\",\n            \"0x0.8#4\",\n            \"-0x0.8#4\",\n            \"0x4.0#4\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_floats_with_precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_floats_with_precision;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\nuse std::panic::catch_unwind;\n\nfn exhaustive_floats_with_precision_helper(precision: u64, out: &[&str], out_hex: &[&str]) {\n    exhaustive_floats_helper_helper_with_limit(\n        20,\n        exhaustive_floats_with_precision(precision),\n        out,\n        out_hex,\n    );\n}\n\n#[test]\nfn test_exhaustive_floats_with_precision() {\n    exhaustive_floats_with_precision_helper(\n        1,\n        &[\n            \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"0.5\", \"-0.5\", \"0.2\", \"-0.2\", \"4.0\", \"-4.0\", \"8.0\",\n            \"-8.0\", \"0.1\", \"-0.1\", \"3.0e1\", \"-3.0e1\", \"2.0e1\", \"-2.0e1\", \"0.06\", \"-0.06\",\n        ],\n        &[\n            \"0x1.0#1\",\n            \"-0x1.0#1\",\n            \"0x2.0#1\",\n            \"-0x2.0#1\",\n            \"0x0.8#1\",\n            \"-0x0.8#1\",\n            \"0x0.4#1\",\n            \"-0x0.4#1\",\n            \"0x4.0#1\",\n            \"-0x4.0#1\",\n            \"0x8.0#1\",\n            \"-0x8.0#1\",\n            \"0x0.2#1\",\n            \"-0x0.2#1\",\n            \"0x2.0E+1#1\",\n            \"-0x2.0E+1#1\",\n            \"0x1.0E+1#1\",\n            \"-0x1.0E+1#1\",\n            \"0x0.1#1\",\n            \"-0x0.1#1\",\n        ],\n    );\n    exhaustive_floats_with_precision_helper(\n        2,\n        &[\n            \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"1.5\", \"-1.5\", \"0.5\", \"-0.5\", \"3.0\", \"-3.0\", \"0.8\",\n            \"-0.8\", \"4.0\", \"-4.0\", \"0.1\", \"-0.1\", \"6.0\", \"-6.0\", \"0.2\", \"-0.2\",\n        ],\n        &[\n            \"0x1.0#2\", \"-0x1.0#2\", \"0x2.0#2\", \"-0x2.0#2\", \"0x1.8#2\", \"-0x1.8#2\", \"0x0.8#2\",\n            \"-0x0.8#2\", \"0x3.0#2\", \"-0x3.0#2\", \"0x0.c#2\", \"-0x0.c#2\", \"0x4.0#2\", \"-0x4.0#2\",\n            \"0x0.2#2\", \"-0x0.2#2\", \"0x6.0#2\", \"-0x6.0#2\", \"0x0.4#2\", \"-0x0.4#2\",\n        ],\n    );\n    exhaustive_floats_with_precision_helper(\n        10,\n        &[\n            \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"1.002\", \"-1.002\", \"0.5\", \"-0.5\", \"1.004\", \"-1.004\",\n            \"2.004\", \"-2.004\", \"1.006\", \"-1.006\", \"4.0\", \"-4.0\", \"1.008\", \"-1.008\", \"2.008\",\n            \"-2.008\",\n        ],\n        &[\n            \"0x1.000#10\",\n            \"-0x1.000#10\",\n            \"0x2.00#10\",\n            \"-0x2.00#10\",\n            \"0x1.008#10\",\n            \"-0x1.008#10\",\n            \"0x0.800#10\",\n            \"-0x0.800#10\",\n            \"0x1.010#10\",\n            \"-0x1.010#10\",\n            \"0x2.01#10\",\n            \"-0x2.01#10\",\n            \"0x1.018#10\",\n            \"-0x1.018#10\",\n            \"0x4.00#10\",\n            \"-0x4.00#10\",\n            \"0x1.020#10\",\n            \"-0x1.020#10\",\n            \"0x2.02#10\",\n            \"-0x2.02#10\",\n        ],\n    );\n    exhaustive_floats_with_precision_helper(\n        100,\n        &[\n            \"1.0\",\n            \"-1.0\",\n            \"2.0\",\n            \"-2.0\",\n            \"1.000000000000000000000000000002\",\n            \"-1.000000000000000000000000000002\",\n            \"0.5\",\n            \"-0.5\",\n            \"1.000000000000000000000000000003\",\n            \"-1.000000000000000000000000000003\",\n            \"2.000000000000000000000000000003\",\n            \"-2.000000000000000000000000000003\",\n            \"1.000000000000000000000000000005\",\n            \"-1.000000000000000000000000000005\",\n            \"4.0\",\n            \"-4.0\",\n            \"1.000000000000000000000000000006\",\n            \"-1.000000000000000000000000000006\",\n            \"2.000000000000000000000000000006\",\n            \"-2.000000000000000000000000000006\",\n        ],\n        &[\n            \"0x1.0000000000000000000000000#100\",\n            \"-0x1.0000000000000000000000000#100\",\n            \"0x2.0000000000000000000000000#100\",\n            \"-0x2.0000000000000000000000000#100\",\n            \"0x1.0000000000000000000000002#100\",\n            \"-0x1.0000000000000000000000002#100\",\n            \"0x0.8000000000000000000000000#100\",\n            \"-0x0.8000000000000000000000000#100\",\n            \"0x1.0000000000000000000000004#100\",\n            \"-0x1.0000000000000000000000004#100\",\n            \"0x2.0000000000000000000000004#100\",\n            \"-0x2.0000000000000000000000004#100\",\n            \"0x1.0000000000000000000000006#100\",\n            \"-0x1.0000000000000000000000006#100\",\n            \"0x4.0000000000000000000000000#100\",\n            \"-0x4.0000000000000000000000000#100\",\n            \"0x1.0000000000000000000000008#100\",\n            \"-0x1.0000000000000000000000008#100\",\n            \"0x2.0000000000000000000000008#100\",\n            \"-0x2.0000000000000000000000008#100\",\n        ],\n    );\n}\n\n#[test]\nfn exhaustive_floats_with_precision_fail() {\n    assert_panic!(exhaustive_floats_with_precision(0));\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_negative_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_negative_finite_floats;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\n#[test]\nfn test_exhaustive_negative_finite_floats() {\n    exhaustive_floats_helper_helper_with_limit(\n        100,\n        exhaustive_negative_finite_floats(),\n        &[\n            \"-1.0\", \"-2.0\", \"-1.0\", \"-2.0\", \"-0.5\", \"-4.0\", \"-0.5\", \"-4.0\", \"-1.5\", \"-3.0\", \"-1.0\",\n            \"-2.0\", \"-0.8\", \"-6.0\", \"-0.5\", \"-4.0\", \"-0.2\", \"-8.0\", \"-0.2\", \"-8.0\", \"-0.1\",\n            \"-2.0e1\", \"-0.1\", \"-16.0\", \"-0.4\", \"-1.0e1\", \"-0.25\", \"-8.0\", \"-0.19\", \"-24.0\", \"-0.1\",\n            \"-16.0\", \"-1.2\", \"-2.5\", \"-1.5\", \"-3.0\", \"-0.6\", \"-5.0\", \"-0.8\", \"-6.0\", \"-1.8\",\n            \"-3.5\", \"-1.0\", \"-2.0\", \"-0.9\", \"-7.0\", \"-0.5\", \"-4.0\", \"-0.3\", \"-10.0\", \"-0.38\",\n            \"-12.0\", \"-0.16\", \"-20.0\", \"-0.19\", \"-24.0\", \"-0.44\", \"-14.0\", \"-0.25\", \"-8.0\",\n            \"-0.22\", \"-28.0\", \"-0.12\", \"-16.0\", \"-0.06\", \"-3.0e1\", \"-0.06\", \"-3.0e1\", \"-0.03\",\n            \"-6.0e1\", \"-0.03\", \"-6.0e1\", \"-0.09\", \"-5.0e1\", \"-0.06\", \"-3.0e1\", \"-0.05\", \"-96.0\",\n            \"-0.03\", \"-6.0e1\", \"-0.02\", \"-1.0e2\", \"-0.016\", \"-1.0e2\", \"-0.008\", \"-3.0e2\", \"-0.008\",\n            \"-3.0e2\", \"-0.023\", \"-2.0e2\", \"-0.016\", \"-1.3e2\", \"-0.01\", \"-4.0e2\", \"-0.008\",\n            \"-2.6e2\", \"-0.08\", \"-4.0e1\", \"-0.09\", \"-5.0e1\",\n        ],\n        &[\n            \"-0x1.0#1\",\n            \"-0x2.0#1\",\n            \"-0x1.0#2\",\n            \"-0x2.0#2\",\n            \"-0x0.8#1\",\n            \"-0x4.0#1\",\n            \"-0x0.8#2\",\n            \"-0x4.0#2\",\n            \"-0x1.8#2\",\n            \"-0x3.0#2\",\n            \"-0x1.0#3\",\n            \"-0x2.0#3\",\n            \"-0x0.c#2\",\n            \"-0x6.0#2\",\n            \"-0x0.8#3\",\n            \"-0x4.0#3\",\n            \"-0x0.4#1\",\n            \"-0x8.0#1\",\n            \"-0x0.4#2\",\n            \"-0x8.0#2\",\n            \"-0x0.2#1\",\n            \"-0x1.0E+1#1\",\n            \"-0x0.2#2\",\n            \"-0x10.0#2\",\n            \"-0x0.6#2\",\n            \"-0xc.0#2\",\n            \"-0x0.4#3\",\n            \"-0x8.0#3\",\n            \"-0x0.3#2\",\n            \"-0x18.0#2\",\n            \"-0x0.20#3\",\n            \"-0x10.0#3\",\n            \"-0x1.4#3\",\n            \"-0x2.8#3\",\n            \"-0x1.8#3\",\n            \"-0x3.0#3\",\n            \"-0x0.a#3\",\n            \"-0x5.0#3\",\n            \"-0x0.c#3\",\n            \"-0x6.0#3\",\n            \"-0x1.c#3\",\n            \"-0x3.8#3\",\n            \"-0x1.0#4\",\n            \"-0x2.0#4\",\n            \"-0x0.e#3\",\n            \"-0x7.0#3\",\n            \"-0x0.8#4\",\n            \"-0x4.0#4\",\n            \"-0x0.5#3\",\n            \"-0xa.0#3\",\n            \"-0x0.6#3\",\n            \"-0xc.0#3\",\n            \"-0x0.28#3\",\n            \"-0x14.0#3\",\n            \"-0x0.30#3\",\n            \"-0x18.0#3\",\n            \"-0x0.7#3\",\n            \"-0xe.0#3\",\n            \"-0x0.40#4\",\n            \"-0x8.0#4\",\n            \"-0x0.38#3\",\n            \"-0x1c.0#3\",\n            \"-0x0.20#4\",\n            \"-0x10.0#4\",\n            \"-0x0.1#1\",\n            \"-0x2.0E+1#1\",\n            \"-0x0.10#2\",\n            \"-0x2.0E+1#2\",\n            \"-0x0.08#1\",\n            \"-0x4.0E+1#1\",\n            \"-0x0.08#2\",\n            \"-0x4.0E+1#2\",\n            \"-0x0.18#2\",\n            \"-0x3.0E+1#2\",\n            \"-0x0.10#3\",\n            \"-0x20.0#3\",\n            \"-0x0.0c#2\",\n            \"-0x6.0E+1#2\",\n            \"-0x0.08#3\",\n            \"-0x4.0E+1#3\",\n            \"-0x0.04#1\",\n            \"-0x8.0E+1#1\",\n            \"-0x0.04#2\",\n            \"-0x8.0E+1#2\",\n            \"-0x0.02#1\",\n            \"-0x1.0E+2#1\",\n            \"-0x0.02#2\",\n            \"-0x1.0E+2#2\",\n            \"-0x0.06#2\",\n            \"-0xc.0E+1#2\",\n            \"-0x0.04#3\",\n            \"-0x8.0E+1#3\",\n            \"-0x0.03#2\",\n            \"-0x1.8E+2#2\",\n            \"-0x0.020#3\",\n            \"-0x1.0E+2#3\",\n            \"-0x0.14#3\",\n            \"-0x28.0#3\",\n            \"-0x0.18#3\",\n            \"-0x30.0#3\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_non_negative_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_non_negative_finite_floats;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\n#[test]\nfn test_exhaustive_non_negative_finite_floats() {\n    exhaustive_floats_helper_helper_with_limit(\n        100,\n        exhaustive_non_negative_finite_floats(),\n        &[\n            \"0.0\", \"1.0\", \"2.0\", \"1.0\", \"2.0\", \"0.5\", \"4.0\", \"0.5\", \"4.0\", \"1.5\", \"3.0\", \"1.0\",\n            \"2.0\", \"0.8\", \"6.0\", \"0.5\", \"4.0\", \"0.2\", \"8.0\", \"0.2\", \"8.0\", \"0.1\", \"2.0e1\", \"0.1\",\n            \"16.0\", \"0.4\", \"1.0e1\", \"0.25\", \"8.0\", \"0.19\", \"24.0\", \"0.1\", \"16.0\", \"1.2\", \"2.5\",\n            \"1.5\", \"3.0\", \"0.6\", \"5.0\", \"0.8\", \"6.0\", \"1.8\", \"3.5\", \"1.0\", \"2.0\", \"0.9\", \"7.0\",\n            \"0.5\", \"4.0\", \"0.3\", \"10.0\", \"0.38\", \"12.0\", \"0.16\", \"20.0\", \"0.19\", \"24.0\", \"0.44\",\n            \"14.0\", \"0.25\", \"8.0\", \"0.22\", \"28.0\", \"0.12\", \"16.0\", \"0.06\", \"3.0e1\", \"0.06\",\n            \"3.0e1\", \"0.03\", \"6.0e1\", \"0.03\", \"6.0e1\", \"0.09\", \"5.0e1\", \"0.06\", \"3.0e1\", \"0.05\",\n            \"96.0\", \"0.03\", \"6.0e1\", \"0.02\", \"1.0e2\", \"0.016\", \"1.0e2\", \"0.008\", \"3.0e2\", \"0.008\",\n            \"3.0e2\", \"0.023\", \"2.0e2\", \"0.016\", \"1.3e2\", \"0.01\", \"4.0e2\", \"0.008\", \"2.6e2\", \"0.08\",\n            \"4.0e1\", \"0.09\",\n        ],\n        &[\n            \"0x0.0\",\n            \"0x1.0#1\",\n            \"0x2.0#1\",\n            \"0x1.0#2\",\n            \"0x2.0#2\",\n            \"0x0.8#1\",\n            \"0x4.0#1\",\n            \"0x0.8#2\",\n            \"0x4.0#2\",\n            \"0x1.8#2\",\n            \"0x3.0#2\",\n            \"0x1.0#3\",\n            \"0x2.0#3\",\n            \"0x0.c#2\",\n            \"0x6.0#2\",\n            \"0x0.8#3\",\n            \"0x4.0#3\",\n            \"0x0.4#1\",\n            \"0x8.0#1\",\n            \"0x0.4#2\",\n            \"0x8.0#2\",\n            \"0x0.2#1\",\n            \"0x1.0E+1#1\",\n            \"0x0.2#2\",\n            \"0x10.0#2\",\n            \"0x0.6#2\",\n            \"0xc.0#2\",\n            \"0x0.4#3\",\n            \"0x8.0#3\",\n            \"0x0.3#2\",\n            \"0x18.0#2\",\n            \"0x0.20#3\",\n            \"0x10.0#3\",\n            \"0x1.4#3\",\n            \"0x2.8#3\",\n            \"0x1.8#3\",\n            \"0x3.0#3\",\n            \"0x0.a#3\",\n            \"0x5.0#3\",\n            \"0x0.c#3\",\n            \"0x6.0#3\",\n            \"0x1.c#3\",\n            \"0x3.8#3\",\n            \"0x1.0#4\",\n            \"0x2.0#4\",\n            \"0x0.e#3\",\n            \"0x7.0#3\",\n            \"0x0.8#4\",\n            \"0x4.0#4\",\n            \"0x0.5#3\",\n            \"0xa.0#3\",\n            \"0x0.6#3\",\n            \"0xc.0#3\",\n            \"0x0.28#3\",\n            \"0x14.0#3\",\n            \"0x0.30#3\",\n            \"0x18.0#3\",\n            \"0x0.7#3\",\n            \"0xe.0#3\",\n            \"0x0.40#4\",\n            \"0x8.0#4\",\n            \"0x0.38#3\",\n            \"0x1c.0#3\",\n            \"0x0.20#4\",\n            \"0x10.0#4\",\n            \"0x0.1#1\",\n            \"0x2.0E+1#1\",\n            \"0x0.10#2\",\n            \"0x2.0E+1#2\",\n            \"0x0.08#1\",\n            \"0x4.0E+1#1\",\n            \"0x0.08#2\",\n            \"0x4.0E+1#2\",\n            \"0x0.18#2\",\n            \"0x3.0E+1#2\",\n            \"0x0.10#3\",\n            \"0x20.0#3\",\n            \"0x0.0c#2\",\n            \"0x6.0E+1#2\",\n            \"0x0.08#3\",\n            \"0x4.0E+1#3\",\n            \"0x0.04#1\",\n            \"0x8.0E+1#1\",\n            \"0x0.04#2\",\n            \"0x8.0E+1#2\",\n            \"0x0.02#1\",\n            \"0x1.0E+2#1\",\n            \"0x0.02#2\",\n            \"0x1.0E+2#2\",\n            \"0x0.06#2\",\n            \"0xc.0E+1#2\",\n            \"0x0.04#3\",\n            \"0x8.0E+1#3\",\n            \"0x0.03#2\",\n            \"0x1.8E+2#2\",\n            \"0x0.020#3\",\n            \"0x1.0E+2#3\",\n            \"0x0.14#3\",\n            \"0x28.0#3\",\n            \"0x0.18#3\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_non_positive_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_non_positive_finite_floats;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\n#[test]\nfn test_exhaustive_non_positive_finite_floats() {\n    exhaustive_floats_helper_helper_with_limit(\n        100,\n        exhaustive_non_positive_finite_floats(),\n        &[\n            \"-0.0\", \"-1.0\", \"-2.0\", \"-1.0\", \"-2.0\", \"-0.5\", \"-4.0\", \"-0.5\", \"-4.0\", \"-1.5\", \"-3.0\",\n            \"-1.0\", \"-2.0\", \"-0.8\", \"-6.0\", \"-0.5\", \"-4.0\", \"-0.2\", \"-8.0\", \"-0.2\", \"-8.0\", \"-0.1\",\n            \"-2.0e1\", \"-0.1\", \"-16.0\", \"-0.4\", \"-1.0e1\", \"-0.25\", \"-8.0\", \"-0.19\", \"-24.0\", \"-0.1\",\n            \"-16.0\", \"-1.2\", \"-2.5\", \"-1.5\", \"-3.0\", \"-0.6\", \"-5.0\", \"-0.8\", \"-6.0\", \"-1.8\",\n            \"-3.5\", \"-1.0\", \"-2.0\", \"-0.9\", \"-7.0\", \"-0.5\", \"-4.0\", \"-0.3\", \"-10.0\", \"-0.38\",\n            \"-12.0\", \"-0.16\", \"-20.0\", \"-0.19\", \"-24.0\", \"-0.44\", \"-14.0\", \"-0.25\", \"-8.0\",\n            \"-0.22\", \"-28.0\", \"-0.12\", \"-16.0\", \"-0.06\", \"-3.0e1\", \"-0.06\", \"-3.0e1\", \"-0.03\",\n            \"-6.0e1\", \"-0.03\", \"-6.0e1\", \"-0.09\", \"-5.0e1\", \"-0.06\", \"-3.0e1\", \"-0.05\", \"-96.0\",\n            \"-0.03\", \"-6.0e1\", \"-0.02\", \"-1.0e2\", \"-0.016\", \"-1.0e2\", \"-0.008\", \"-3.0e2\", \"-0.008\",\n            \"-3.0e2\", \"-0.023\", \"-2.0e2\", \"-0.016\", \"-1.3e2\", \"-0.01\", \"-4.0e2\", \"-0.008\",\n            \"-2.6e2\", \"-0.08\", \"-4.0e1\", \"-0.09\",\n        ],\n        &[\n            \"-0x0.0\",\n            \"-0x1.0#1\",\n            \"-0x2.0#1\",\n            \"-0x1.0#2\",\n            \"-0x2.0#2\",\n            \"-0x0.8#1\",\n            \"-0x4.0#1\",\n            \"-0x0.8#2\",\n            \"-0x4.0#2\",\n            \"-0x1.8#2\",\n            \"-0x3.0#2\",\n            \"-0x1.0#3\",\n            \"-0x2.0#3\",\n            \"-0x0.c#2\",\n            \"-0x6.0#2\",\n            \"-0x0.8#3\",\n            \"-0x4.0#3\",\n            \"-0x0.4#1\",\n            \"-0x8.0#1\",\n            \"-0x0.4#2\",\n            \"-0x8.0#2\",\n            \"-0x0.2#1\",\n            \"-0x1.0E+1#1\",\n            \"-0x0.2#2\",\n            \"-0x10.0#2\",\n            \"-0x0.6#2\",\n            \"-0xc.0#2\",\n            \"-0x0.4#3\",\n            \"-0x8.0#3\",\n            \"-0x0.3#2\",\n            \"-0x18.0#2\",\n            \"-0x0.20#3\",\n            \"-0x10.0#3\",\n            \"-0x1.4#3\",\n            \"-0x2.8#3\",\n            \"-0x1.8#3\",\n            \"-0x3.0#3\",\n            \"-0x0.a#3\",\n            \"-0x5.0#3\",\n            \"-0x0.c#3\",\n            \"-0x6.0#3\",\n            \"-0x1.c#3\",\n            \"-0x3.8#3\",\n            \"-0x1.0#4\",\n            \"-0x2.0#4\",\n            \"-0x0.e#3\",\n            \"-0x7.0#3\",\n            \"-0x0.8#4\",\n            \"-0x4.0#4\",\n            \"-0x0.5#3\",\n            \"-0xa.0#3\",\n            \"-0x0.6#3\",\n            \"-0xc.0#3\",\n            \"-0x0.28#3\",\n            \"-0x14.0#3\",\n            \"-0x0.30#3\",\n            \"-0x18.0#3\",\n            \"-0x0.7#3\",\n            \"-0xe.0#3\",\n            \"-0x0.40#4\",\n            \"-0x8.0#4\",\n            \"-0x0.38#3\",\n            \"-0x1c.0#3\",\n            \"-0x0.20#4\",\n            \"-0x10.0#4\",\n            \"-0x0.1#1\",\n            \"-0x2.0E+1#1\",\n            \"-0x0.10#2\",\n            \"-0x2.0E+1#2\",\n            \"-0x0.08#1\",\n            \"-0x4.0E+1#1\",\n            \"-0x0.08#2\",\n            \"-0x4.0E+1#2\",\n            \"-0x0.18#2\",\n            \"-0x3.0E+1#2\",\n            \"-0x0.10#3\",\n            \"-0x20.0#3\",\n            \"-0x0.0c#2\",\n            \"-0x6.0E+1#2\",\n            \"-0x0.08#3\",\n            \"-0x4.0E+1#3\",\n            \"-0x0.04#1\",\n            \"-0x8.0E+1#1\",\n            \"-0x0.04#2\",\n            \"-0x8.0E+1#2\",\n            \"-0x0.02#1\",\n            \"-0x1.0E+2#1\",\n            \"-0x0.02#2\",\n            \"-0x1.0E+2#2\",\n            \"-0x0.06#2\",\n            \"-0xc.0E+1#2\",\n            \"-0x0.04#3\",\n            \"-0x8.0E+1#3\",\n            \"-0x0.03#2\",\n            \"-0x1.8E+2#2\",\n            \"-0x0.020#3\",\n            \"-0x1.0E+2#3\",\n            \"-0x0.14#3\",\n            \"-0x28.0#3\",\n            \"-0x0.18#3\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_nonzero_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_nonzero_finite_floats;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\n#[test]\nfn test_exhaustive_nonzero_finite_floats() {\n    exhaustive_floats_helper_helper_with_limit(\n        100,\n        exhaustive_nonzero_finite_floats(),\n        &[\n            \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"1.0\", \"-1.0\", \"2.0\", \"-2.0\", \"0.5\", \"-0.5\", \"4.0\",\n            \"-4.0\", \"0.5\", \"-0.5\", \"4.0\", \"-4.0\", \"1.5\", \"-1.5\", \"3.0\", \"-3.0\", \"1.0\", \"-1.0\",\n            \"2.0\", \"-2.0\", \"0.8\", \"-0.8\", \"6.0\", \"-6.0\", \"0.5\", \"-0.5\", \"4.0\", \"-4.0\", \"0.2\",\n            \"-0.2\", \"8.0\", \"-8.0\", \"0.2\", \"-0.2\", \"8.0\", \"-8.0\", \"0.1\", \"-0.1\", \"2.0e1\", \"-2.0e1\",\n            \"0.1\", \"-0.1\", \"16.0\", \"-16.0\", \"0.4\", \"-0.4\", \"1.0e1\", \"-1.0e1\", \"0.25\", \"-0.25\",\n            \"8.0\", \"-8.0\", \"0.19\", \"-0.19\", \"24.0\", \"-24.0\", \"0.1\", \"-0.1\", \"16.0\", \"-16.0\", \"1.2\",\n            \"-1.2\", \"2.5\", \"-2.5\", \"1.5\", \"-1.5\", \"3.0\", \"-3.0\", \"0.6\", \"-0.6\", \"5.0\", \"-5.0\",\n            \"0.8\", \"-0.8\", \"6.0\", \"-6.0\", \"1.8\", \"-1.8\", \"3.5\", \"-3.5\", \"1.0\", \"-1.0\", \"2.0\",\n            \"-2.0\", \"0.9\", \"-0.9\", \"7.0\", \"-7.0\", \"0.5\", \"-0.5\", \"4.0\", \"-4.0\", \"0.3\", \"-0.3\",\n            \"10.0\", \"-10.0\",\n        ],\n        &[\n            \"0x1.0#1\",\n            \"-0x1.0#1\",\n            \"0x2.0#1\",\n            \"-0x2.0#1\",\n            \"0x1.0#2\",\n            \"-0x1.0#2\",\n            \"0x2.0#2\",\n            \"-0x2.0#2\",\n            \"0x0.8#1\",\n            \"-0x0.8#1\",\n            \"0x4.0#1\",\n            \"-0x4.0#1\",\n            \"0x0.8#2\",\n            \"-0x0.8#2\",\n            \"0x4.0#2\",\n            \"-0x4.0#2\",\n            \"0x1.8#2\",\n            \"-0x1.8#2\",\n            \"0x3.0#2\",\n            \"-0x3.0#2\",\n            \"0x1.0#3\",\n            \"-0x1.0#3\",\n            \"0x2.0#3\",\n            \"-0x2.0#3\",\n            \"0x0.c#2\",\n            \"-0x0.c#2\",\n            \"0x6.0#2\",\n            \"-0x6.0#2\",\n            \"0x0.8#3\",\n            \"-0x0.8#3\",\n            \"0x4.0#3\",\n            \"-0x4.0#3\",\n            \"0x0.4#1\",\n            \"-0x0.4#1\",\n            \"0x8.0#1\",\n            \"-0x8.0#1\",\n            \"0x0.4#2\",\n            \"-0x0.4#2\",\n            \"0x8.0#2\",\n            \"-0x8.0#2\",\n            \"0x0.2#1\",\n            \"-0x0.2#1\",\n            \"0x1.0E+1#1\",\n            \"-0x1.0E+1#1\",\n            \"0x0.2#2\",\n            \"-0x0.2#2\",\n            \"0x10.0#2\",\n            \"-0x10.0#2\",\n            \"0x0.6#2\",\n            \"-0x0.6#2\",\n            \"0xc.0#2\",\n            \"-0xc.0#2\",\n            \"0x0.4#3\",\n            \"-0x0.4#3\",\n            \"0x8.0#3\",\n            \"-0x8.0#3\",\n            \"0x0.3#2\",\n            \"-0x0.3#2\",\n            \"0x18.0#2\",\n            \"-0x18.0#2\",\n            \"0x0.20#3\",\n            \"-0x0.20#3\",\n            \"0x10.0#3\",\n            \"-0x10.0#3\",\n            \"0x1.4#3\",\n            \"-0x1.4#3\",\n            \"0x2.8#3\",\n            \"-0x2.8#3\",\n            \"0x1.8#3\",\n            \"-0x1.8#3\",\n            \"0x3.0#3\",\n            \"-0x3.0#3\",\n            \"0x0.a#3\",\n            \"-0x0.a#3\",\n            \"0x5.0#3\",\n            \"-0x5.0#3\",\n            \"0x0.c#3\",\n            \"-0x0.c#3\",\n            \"0x6.0#3\",\n            \"-0x6.0#3\",\n            \"0x1.c#3\",\n            \"-0x1.c#3\",\n            \"0x3.8#3\",\n            \"-0x3.8#3\",\n            \"0x1.0#4\",\n            \"-0x1.0#4\",\n            \"0x2.0#4\",\n            \"-0x2.0#4\",\n            \"0x0.e#3\",\n            \"-0x0.e#3\",\n            \"0x7.0#3\",\n            \"-0x7.0#3\",\n            \"0x0.8#4\",\n            \"-0x0.8#4\",\n            \"0x4.0#4\",\n            \"-0x4.0#4\",\n            \"0x0.5#3\",\n            \"-0x0.5#3\",\n            \"0xa.0#3\",\n            \"-0xa.0#3\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_positive_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_positive_finite_floats;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\n#[test]\nfn test_exhaustive_positive_finite_floats() {\n    exhaustive_floats_helper_helper_with_limit(\n        100,\n        exhaustive_positive_finite_floats(),\n        &[\n            \"1.0\", \"2.0\", \"1.0\", \"2.0\", \"0.5\", \"4.0\", \"0.5\", \"4.0\", \"1.5\", \"3.0\", \"1.0\", \"2.0\",\n            \"0.8\", \"6.0\", \"0.5\", \"4.0\", \"0.2\", \"8.0\", \"0.2\", \"8.0\", \"0.1\", \"2.0e1\", \"0.1\", \"16.0\",\n            \"0.4\", \"1.0e1\", \"0.25\", \"8.0\", \"0.19\", \"24.0\", \"0.1\", \"16.0\", \"1.2\", \"2.5\", \"1.5\",\n            \"3.0\", \"0.6\", \"5.0\", \"0.8\", \"6.0\", \"1.8\", \"3.5\", \"1.0\", \"2.0\", \"0.9\", \"7.0\", \"0.5\",\n            \"4.0\", \"0.3\", \"10.0\", \"0.38\", \"12.0\", \"0.16\", \"20.0\", \"0.19\", \"24.0\", \"0.44\", \"14.0\",\n            \"0.25\", \"8.0\", \"0.22\", \"28.0\", \"0.12\", \"16.0\", \"0.06\", \"3.0e1\", \"0.06\", \"3.0e1\",\n            \"0.03\", \"6.0e1\", \"0.03\", \"6.0e1\", \"0.09\", \"5.0e1\", \"0.06\", \"3.0e1\", \"0.05\", \"96.0\",\n            \"0.03\", \"6.0e1\", \"0.02\", \"1.0e2\", \"0.016\", \"1.0e2\", \"0.008\", \"3.0e2\", \"0.008\", \"3.0e2\",\n            \"0.023\", \"2.0e2\", \"0.016\", \"1.3e2\", \"0.01\", \"4.0e2\", \"0.008\", \"2.6e2\", \"0.08\", \"4.0e1\",\n            \"0.09\", \"5.0e1\",\n        ],\n        &[\n            \"0x1.0#1\",\n            \"0x2.0#1\",\n            \"0x1.0#2\",\n            \"0x2.0#2\",\n            \"0x0.8#1\",\n            \"0x4.0#1\",\n            \"0x0.8#2\",\n            \"0x4.0#2\",\n            \"0x1.8#2\",\n            \"0x3.0#2\",\n            \"0x1.0#3\",\n            \"0x2.0#3\",\n            \"0x0.c#2\",\n            \"0x6.0#2\",\n            \"0x0.8#3\",\n            \"0x4.0#3\",\n            \"0x0.4#1\",\n            \"0x8.0#1\",\n            \"0x0.4#2\",\n            \"0x8.0#2\",\n            \"0x0.2#1\",\n            \"0x1.0E+1#1\",\n            \"0x0.2#2\",\n            \"0x10.0#2\",\n            \"0x0.6#2\",\n            \"0xc.0#2\",\n            \"0x0.4#3\",\n            \"0x8.0#3\",\n            \"0x0.3#2\",\n            \"0x18.0#2\",\n            \"0x0.20#3\",\n            \"0x10.0#3\",\n            \"0x1.4#3\",\n            \"0x2.8#3\",\n            \"0x1.8#3\",\n            \"0x3.0#3\",\n            \"0x0.a#3\",\n            \"0x5.0#3\",\n            \"0x0.c#3\",\n            \"0x6.0#3\",\n            \"0x1.c#3\",\n            \"0x3.8#3\",\n            \"0x1.0#4\",\n            \"0x2.0#4\",\n            \"0x0.e#3\",\n            \"0x7.0#3\",\n            \"0x0.8#4\",\n            \"0x4.0#4\",\n            \"0x0.5#3\",\n            \"0xa.0#3\",\n            \"0x0.6#3\",\n            \"0xc.0#3\",\n            \"0x0.28#3\",\n            \"0x14.0#3\",\n            \"0x0.30#3\",\n            \"0x18.0#3\",\n            \"0x0.7#3\",\n            \"0xe.0#3\",\n            \"0x0.40#4\",\n            \"0x8.0#4\",\n            \"0x0.38#3\",\n            \"0x1c.0#3\",\n            \"0x0.20#4\",\n            \"0x10.0#4\",\n            \"0x0.1#1\",\n            \"0x2.0E+1#1\",\n            \"0x0.10#2\",\n            \"0x2.0E+1#2\",\n            \"0x0.08#1\",\n            \"0x4.0E+1#1\",\n            \"0x0.08#2\",\n            \"0x4.0E+1#2\",\n            \"0x0.18#2\",\n            \"0x3.0E+1#2\",\n            \"0x0.10#3\",\n            \"0x20.0#3\",\n            \"0x0.0c#2\",\n            \"0x6.0E+1#2\",\n            \"0x0.08#3\",\n            \"0x4.0E+1#3\",\n            \"0x0.04#1\",\n            \"0x8.0E+1#1\",\n            \"0x0.04#2\",\n            \"0x8.0E+1#2\",\n            \"0x0.02#1\",\n            \"0x1.0E+2#1\",\n            \"0x0.02#2\",\n            \"0x1.0E+2#2\",\n            \"0x0.06#2\",\n            \"0xc.0E+1#2\",\n            \"0x0.04#3\",\n            \"0x8.0E+1#3\",\n            \"0x0.03#2\",\n            \"0x1.8E+2#2\",\n            \"0x0.020#3\",\n            \"0x1.0E+2#3\",\n            \"0x0.14#3\",\n            \"0x28.0#3\",\n            \"0x0.18#3\",\n            \"0x30.0#3\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_positive_floats_with_precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_positive_floats_with_precision;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\nuse std::panic::catch_unwind;\n\nfn exhaustive_positive_floats_with_precision_helper(\n    precision: u64,\n    out: &[&str],\n    out_hex: &[&str],\n) {\n    exhaustive_floats_helper_helper_with_limit(\n        20,\n        exhaustive_positive_floats_with_precision(precision),\n        out,\n        out_hex,\n    );\n}\n\n#[test]\nfn test_exhaustive_positive_floats_with_precision() {\n    exhaustive_positive_floats_with_precision_helper(\n        1,\n        &[\n            \"1.0\", \"2.0\", \"0.5\", \"0.2\", \"4.0\", \"8.0\", \"0.1\", \"3.0e1\", \"2.0e1\", \"0.06\", \"0.03\",\n            \"0.02\", \"6.0e1\", \"1.0e2\", \"0.008\", \"0.002\", \"3.0e2\", \"0.004\", \"5.0e2\", \"1.0e3\",\n        ],\n        &[\n            \"0x1.0#1\",\n            \"0x2.0#1\",\n            \"0x0.8#1\",\n            \"0x0.4#1\",\n            \"0x4.0#1\",\n            \"0x8.0#1\",\n            \"0x0.2#1\",\n            \"0x2.0E+1#1\",\n            \"0x1.0E+1#1\",\n            \"0x0.1#1\",\n            \"0x0.08#1\",\n            \"0x0.04#1\",\n            \"0x4.0E+1#1\",\n            \"0x8.0E+1#1\",\n            \"0x0.02#1\",\n            \"0x0.008#1\",\n            \"0x1.0E+2#1\",\n            \"0x0.01#1\",\n            \"0x2.0E+2#1\",\n            \"0x4.0E+2#1\",\n        ],\n    );\n    exhaustive_positive_floats_with_precision_helper(\n        2,\n        &[\n            \"1.0\", \"2.0\", \"1.5\", \"0.5\", \"3.0\", \"0.8\", \"4.0\", \"0.1\", \"6.0\", \"0.2\", \"0.4\", \"0.19\",\n            \"8.0\", \"16.0\", \"1.0e1\", \"0.03\", \"24.0\", \"0.06\", \"0.09\", \"0.05\",\n        ],\n        &[\n            \"0x1.0#2\", \"0x2.0#2\", \"0x1.8#2\", \"0x0.8#2\", \"0x3.0#2\", \"0x0.c#2\", \"0x4.0#2\", \"0x0.2#2\",\n            \"0x6.0#2\", \"0x0.4#2\", \"0x0.6#2\", \"0x0.3#2\", \"0x8.0#2\", \"0x10.0#2\", \"0xc.0#2\",\n            \"0x0.08#2\", \"0x18.0#2\", \"0x0.10#2\", \"0x0.18#2\", \"0x0.0c#2\",\n        ],\n    );\n    exhaustive_positive_floats_with_precision_helper(\n        10,\n        &[\n            \"1.0\", \"2.0\", \"1.002\", \"0.5\", \"1.004\", \"2.004\", \"1.006\", \"4.0\", \"1.008\", \"2.008\",\n            \"1.01\", \"0.501\", \"1.012\", \"2.012\", \"1.014\", \"0.25\", \"1.016\", \"2.016\", \"1.018\", \"0.502\",\n        ],\n        &[\n            \"0x1.000#10\",\n            \"0x2.00#10\",\n            \"0x1.008#10\",\n            \"0x0.800#10\",\n            \"0x1.010#10\",\n            \"0x2.01#10\",\n            \"0x1.018#10\",\n            \"0x4.00#10\",\n            \"0x1.020#10\",\n            \"0x2.02#10\",\n            \"0x1.028#10\",\n            \"0x0.804#10\",\n            \"0x1.030#10\",\n            \"0x2.03#10\",\n            \"0x1.038#10\",\n            \"0x0.400#10\",\n            \"0x1.040#10\",\n            \"0x2.04#10\",\n            \"0x1.048#10\",\n            \"0x0.808#10\",\n        ],\n    );\n    exhaustive_positive_floats_with_precision_helper(\n        100,\n        &[\n            \"1.0\",\n            \"2.0\",\n            \"1.000000000000000000000000000002\",\n            \"0.5\",\n            \"1.000000000000000000000000000003\",\n            \"2.000000000000000000000000000003\",\n            \"1.000000000000000000000000000005\",\n            \"4.0\",\n            \"1.000000000000000000000000000006\",\n            \"2.000000000000000000000000000006\",\n            \"1.000000000000000000000000000008\",\n            \"0.500000000000000000000000000001\",\n            \"1.000000000000000000000000000009\",\n            \"2.000000000000000000000000000009\",\n            \"1.000000000000000000000000000011\",\n            \"0.25\",\n            \"1.000000000000000000000000000013\",\n            \"2.000000000000000000000000000013\",\n            \"1.000000000000000000000000000014\",\n            \"0.5000000000000000000000000000016\",\n        ],\n        &[\n            \"0x1.0000000000000000000000000#100\",\n            \"0x2.0000000000000000000000000#100\",\n            \"0x1.0000000000000000000000002#100\",\n            \"0x0.8000000000000000000000000#100\",\n            \"0x1.0000000000000000000000004#100\",\n            \"0x2.0000000000000000000000004#100\",\n            \"0x1.0000000000000000000000006#100\",\n            \"0x4.0000000000000000000000000#100\",\n            \"0x1.0000000000000000000000008#100\",\n            \"0x2.0000000000000000000000008#100\",\n            \"0x1.000000000000000000000000a#100\",\n            \"0x0.8000000000000000000000001#100\",\n            \"0x1.000000000000000000000000c#100\",\n            \"0x2.000000000000000000000000c#100\",\n            \"0x1.000000000000000000000000e#100\",\n            \"0x0.40000000000000000000000000#100\",\n            \"0x1.0000000000000000000000010#100\",\n            \"0x2.0000000000000000000000010#100\",\n            \"0x1.0000000000000000000000012#100\",\n            \"0x0.8000000000000000000000002#100\",\n        ],\n    );\n}\n\n#[test]\nfn exhaustive_positive_floats_with_precision_fail() {\n    assert_panic!(exhaustive_positive_floats_with_precision(0));\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_positive_floats_with_sci_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_positive_floats_with_sci_exponent;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\n\nfn exhaustive_positive_floats_with_sci_exponent_helper(\n    sci_exponent: i32,\n    out: &[&str],\n    out_hex: &[&str],\n) {\n    exhaustive_floats_helper_helper_with_limit(\n        20,\n        exhaustive_positive_floats_with_sci_exponent(sci_exponent),\n        out,\n        out_hex,\n    );\n}\n\n#[test]\nfn test_exhaustive_positive_floats_with_sci_exponent() {\n    exhaustive_positive_floats_with_sci_exponent_helper(\n        0,\n        &[\n            \"1.0\", \"1.0\", \"1.5\", \"1.0\", \"1.2\", \"1.5\", \"1.8\", \"1.0\", \"1.1\", \"1.2\", \"1.4\", \"1.5\",\n            \"1.6\", \"1.8\", \"1.9\", \"1.0\", \"1.06\", \"1.12\", \"1.19\", \"1.25\",\n        ],\n        &[\n            \"0x1.0#1\", \"0x1.0#2\", \"0x1.8#2\", \"0x1.0#3\", \"0x1.4#3\", \"0x1.8#3\", \"0x1.c#3\", \"0x1.0#4\",\n            \"0x1.2#4\", \"0x1.4#4\", \"0x1.6#4\", \"0x1.8#4\", \"0x1.a#4\", \"0x1.c#4\", \"0x1.e#4\", \"0x1.0#5\",\n            \"0x1.1#5\", \"0x1.2#5\", \"0x1.3#5\", \"0x1.4#5\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_helper(\n        1,\n        &[\n            \"2.0\", \"2.0\", \"3.0\", \"2.0\", \"2.5\", \"3.0\", \"3.5\", \"2.0\", \"2.2\", \"2.5\", \"2.8\", \"3.0\",\n            \"3.2\", \"3.5\", \"3.8\", \"2.0\", \"2.1\", \"2.2\", \"2.4\", \"2.5\",\n        ],\n        &[\n            \"0x2.0#1\", \"0x2.0#2\", \"0x3.0#2\", \"0x2.0#3\", \"0x2.8#3\", \"0x3.0#3\", \"0x3.8#3\", \"0x2.0#4\",\n            \"0x2.4#4\", \"0x2.8#4\", \"0x2.c#4\", \"0x3.0#4\", \"0x3.4#4\", \"0x3.8#4\", \"0x3.c#4\", \"0x2.0#5\",\n            \"0x2.2#5\", \"0x2.4#5\", \"0x2.6#5\", \"0x2.8#5\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_helper(\n        2,\n        &[\n            \"4.0\", \"4.0\", \"6.0\", \"4.0\", \"5.0\", \"6.0\", \"7.0\", \"4.0\", \"4.5\", \"5.0\", \"5.5\", \"6.0\",\n            \"6.5\", \"7.0\", \"7.5\", \"4.0\", \"4.2\", \"4.5\", \"4.8\", \"5.0\",\n        ],\n        &[\n            \"0x4.0#1\", \"0x4.0#2\", \"0x6.0#2\", \"0x4.0#3\", \"0x5.0#3\", \"0x6.0#3\", \"0x7.0#3\", \"0x4.0#4\",\n            \"0x4.8#4\", \"0x5.0#4\", \"0x5.8#4\", \"0x6.0#4\", \"0x6.8#4\", \"0x7.0#4\", \"0x7.8#4\", \"0x4.0#5\",\n            \"0x4.4#5\", \"0x4.8#5\", \"0x4.c#5\", \"0x5.0#5\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_helper(\n        10,\n        &[\n            \"1.0e3\", \"1.0e3\", \"1.5e3\", \"1.0e3\", \"1.3e3\", \"1.5e3\", \"1.8e3\", \"1.0e3\", \"1.2e3\",\n            \"1.3e3\", \"1.4e3\", \"1.5e3\", \"1.7e3\", \"1.8e3\", \"1.9e3\", \"1.0e3\", \"1.1e3\", \"1.15e3\",\n            \"1.22e3\", \"1.28e3\",\n        ],\n        &[\n            \"0x4.0E+2#1\",\n            \"0x4.0E+2#2\",\n            \"0x6.0E+2#2\",\n            \"0x4.0E+2#3\",\n            \"0x5.0E+2#3\",\n            \"0x6.0E+2#3\",\n            \"0x7.0E+2#3\",\n            \"0x4.0E+2#4\",\n            \"0x4.8E+2#4\",\n            \"0x5.0E+2#4\",\n            \"0x5.8E+2#4\",\n            \"0x6.0E+2#4\",\n            \"0x6.8E+2#4\",\n            \"0x7.0E+2#4\",\n            \"0x7.8E+2#4\",\n            \"0x4.0E+2#5\",\n            \"0x4.4E+2#5\",\n            \"0x4.8E+2#5\",\n            \"0x4.cE+2#5\",\n            \"0x5.0E+2#5\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_helper(\n        -1,\n        &[\n            \"0.5\", \"0.5\", \"0.8\", \"0.5\", \"0.6\", \"0.8\", \"0.9\", \"0.5\", \"0.56\", \"0.62\", \"0.7\", \"0.75\",\n            \"0.81\", \"0.88\", \"0.94\", \"0.5\", \"0.53\", \"0.56\", \"0.59\", \"0.62\",\n        ],\n        &[\n            \"0x0.8#1\", \"0x0.8#2\", \"0x0.c#2\", \"0x0.8#3\", \"0x0.a#3\", \"0x0.c#3\", \"0x0.e#3\", \"0x0.8#4\",\n            \"0x0.9#4\", \"0x0.a#4\", \"0x0.b#4\", \"0x0.c#4\", \"0x0.d#4\", \"0x0.e#4\", \"0x0.f#4\",\n            \"0x0.80#5\", \"0x0.88#5\", \"0x0.90#5\", \"0x0.98#5\", \"0x0.a0#5\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_helper(\n        -2,\n        &[\n            \"0.2\", \"0.2\", \"0.4\", \"0.25\", \"0.3\", \"0.38\", \"0.44\", \"0.25\", \"0.28\", \"0.31\", \"0.34\",\n            \"0.38\", \"0.41\", \"0.44\", \"0.47\", \"0.25\", \"0.27\", \"0.28\", \"0.3\", \"0.31\",\n        ],\n        &[\n            \"0x0.4#1\", \"0x0.4#2\", \"0x0.6#2\", \"0x0.4#3\", \"0x0.5#3\", \"0x0.6#3\", \"0x0.7#3\",\n            \"0x0.40#4\", \"0x0.48#4\", \"0x0.50#4\", \"0x0.58#4\", \"0x0.60#4\", \"0x0.68#4\", \"0x0.70#4\",\n            \"0x0.78#4\", \"0x0.40#5\", \"0x0.44#5\", \"0x0.48#5\", \"0x0.4c#5\", \"0x0.50#5\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_helper(\n        -10,\n        &[\n            \"0.001\", \"0.00098\", \"0.0015\", \"0.00098\", \"0.0012\", \"0.0015\", \"0.0017\", \"0.00098\",\n            \"0.0011\", \"0.0012\", \"0.0013\", \"0.0015\", \"0.0016\", \"0.0017\", \"0.0018\", \"0.00098\",\n            \"0.001\", \"0.0011\", \"0.00116\", \"0.00122\",\n        ],\n        &[\n            \"0x0.004#1\",\n            \"0x0.004#2\",\n            \"0x0.006#2\",\n            \"0x0.004#3\",\n            \"0x0.005#3\",\n            \"0x0.006#3\",\n            \"0x0.007#3\",\n            \"0x0.0040#4\",\n            \"0x0.0048#4\",\n            \"0x0.0050#4\",\n            \"0x0.0058#4\",\n            \"0x0.0060#4\",\n            \"0x0.0068#4\",\n            \"0x0.0070#4\",\n            \"0x0.0078#4\",\n            \"0x0.0040#5\",\n            \"0x0.0044#5\",\n            \"0x0.0048#5\",\n            \"0x0.004c#5\",\n            \"0x0.0050#5\",\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-float/tests/exhaustive/exhaustive_positive_floats_with_sci_exponent_and_precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_float::exhaustive::exhaustive_positive_floats_with_sci_exponent_and_precision;\nuse malachite_float::test_util::exhaustive::exhaustive_floats_helper_helper_with_limit;\nuse std::panic::catch_unwind;\n\nfn exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n    sci_exponent: i32,\n    prec: u64,\n    out: &[&str],\n    out_hex: &[&str],\n) {\n    exhaustive_floats_helper_helper_with_limit(\n        20,\n        exhaustive_positive_floats_with_sci_exponent_and_precision(sci_exponent, prec),\n        out,\n        out_hex,\n    );\n}\n\n#[test]\nfn test_exhaustive_positive_floats_with_sci_exponent_and_precision() {\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(0, 1, &[\"1.0\"], &[\"0x1.0#1\"]);\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        0,\n        2,\n        &[\"1.0\", \"1.5\"],\n        &[\"0x1.0#2\", \"0x1.8#2\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        0,\n        3,\n        &[\"1.0\", \"1.2\", \"1.5\", \"1.8\"],\n        &[\"0x1.0#3\", \"0x1.4#3\", \"0x1.8#3\", \"0x1.c#3\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        0,\n        4,\n        &[\"1.0\", \"1.1\", \"1.2\", \"1.4\", \"1.5\", \"1.6\", \"1.8\", \"1.9\"],\n        &[\"0x1.0#4\", \"0x1.2#4\", \"0x1.4#4\", \"0x1.6#4\", \"0x1.8#4\", \"0x1.a#4\", \"0x1.c#4\", \"0x1.e#4\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        0,\n        5,\n        &[\n            \"1.0\", \"1.06\", \"1.12\", \"1.19\", \"1.25\", \"1.3\", \"1.38\", \"1.44\", \"1.5\", \"1.56\", \"1.62\",\n            \"1.7\", \"1.75\", \"1.81\", \"1.88\", \"1.94\",\n        ],\n        &[\n            \"0x1.0#5\", \"0x1.1#5\", \"0x1.2#5\", \"0x1.3#5\", \"0x1.4#5\", \"0x1.5#5\", \"0x1.6#5\", \"0x1.7#5\",\n            \"0x1.8#5\", \"0x1.9#5\", \"0x1.a#5\", \"0x1.b#5\", \"0x1.c#5\", \"0x1.d#5\", \"0x1.e#5\", \"0x1.f#5\",\n        ],\n    );\n\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(1, 1, &[\"2.0\"], &[\"0x2.0#1\"]);\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        1,\n        2,\n        &[\"2.0\", \"3.0\"],\n        &[\"0x2.0#2\", \"0x3.0#2\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        1,\n        3,\n        &[\"2.0\", \"2.5\", \"3.0\", \"3.5\"],\n        &[\"0x2.0#3\", \"0x2.8#3\", \"0x3.0#3\", \"0x3.8#3\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        1,\n        4,\n        &[\"2.0\", \"2.2\", \"2.5\", \"2.8\", \"3.0\", \"3.2\", \"3.5\", \"3.8\"],\n        &[\"0x2.0#4\", \"0x2.4#4\", \"0x2.8#4\", \"0x2.c#4\", \"0x3.0#4\", \"0x3.4#4\", \"0x3.8#4\", \"0x3.c#4\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        1,\n        5,\n        &[\n            \"2.0\", \"2.1\", \"2.2\", \"2.4\", \"2.5\", \"2.6\", \"2.8\", \"2.9\", \"3.0\", \"3.1\", \"3.2\", \"3.4\",\n            \"3.5\", \"3.6\", \"3.8\", \"3.9\",\n        ],\n        &[\n            \"0x2.0#5\", \"0x2.2#5\", \"0x2.4#5\", \"0x2.6#5\", \"0x2.8#5\", \"0x2.a#5\", \"0x2.c#5\", \"0x2.e#5\",\n            \"0x3.0#5\", \"0x3.2#5\", \"0x3.4#5\", \"0x3.6#5\", \"0x3.8#5\", \"0x3.a#5\", \"0x3.c#5\", \"0x3.e#5\",\n        ],\n    );\n\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        4,\n        1,\n        &[\"2.0e1\"],\n        &[\"0x1.0E+1#1\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        4,\n        2,\n        &[\"16.0\", \"24.0\"],\n        &[\"0x10.0#2\", \"0x18.0#2\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        4,\n        3,\n        &[\"16.0\", \"20.0\", \"24.0\", \"28.0\"],\n        &[\"0x10.0#3\", \"0x14.0#3\", \"0x18.0#3\", \"0x1c.0#3\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        4,\n        4,\n        &[\"16.0\", \"18.0\", \"20.0\", \"22.0\", \"24.0\", \"26.0\", \"28.0\", \"30.0\"],\n        &[\n            \"0x10.0#4\", \"0x12.0#4\", \"0x14.0#4\", \"0x16.0#4\", \"0x18.0#4\", \"0x1a.0#4\", \"0x1c.0#4\",\n            \"0x1e.0#4\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        4,\n        5,\n        &[\n            \"16.0\", \"17.0\", \"18.0\", \"19.0\", \"20.0\", \"21.0\", \"22.0\", \"23.0\", \"24.0\", \"25.0\", \"26.0\",\n            \"27.0\", \"28.0\", \"29.0\", \"30.0\", \"31.0\",\n        ],\n        &[\n            \"0x10.0#5\", \"0x11.0#5\", \"0x12.0#5\", \"0x13.0#5\", \"0x14.0#5\", \"0x15.0#5\", \"0x16.0#5\",\n            \"0x17.0#5\", \"0x18.0#5\", \"0x19.0#5\", \"0x1a.0#5\", \"0x1b.0#5\", \"0x1c.0#5\", \"0x1d.0#5\",\n            \"0x1e.0#5\", \"0x1f.0#5\",\n        ],\n    );\n\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        100,\n        1,\n        &[\"1.0e30\"],\n        &[\"0x1.0E+25#1\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        100,\n        2,\n        &[\"1.0e30\", \"2.0e30\"],\n        &[\"0x1.0E+25#2\", \"0x1.8E+25#2\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        100,\n        3,\n        &[\"1.3e30\", \"1.6e30\", \"1.9e30\", \"2.2e30\"],\n        &[\"0x1.0E+25#3\", \"0x1.4E+25#3\", \"0x1.8E+25#3\", \"0x1.cE+25#3\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        100,\n        4,\n        &[\"1.3e30\", \"1.4e30\", \"1.6e30\", \"1.7e30\", \"1.9e30\", \"2.1e30\", \"2.2e30\", \"2.4e30\"],\n        &[\n            \"0x1.0E+25#4\",\n            \"0x1.2E+25#4\",\n            \"0x1.4E+25#4\",\n            \"0x1.6E+25#4\",\n            \"0x1.8E+25#4\",\n            \"0x1.aE+25#4\",\n            \"0x1.cE+25#4\",\n            \"0x1.eE+25#4\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        100,\n        5,\n        &[\n            \"1.27e30\", \"1.35e30\", \"1.4e30\", \"1.5e30\", \"1.6e30\", \"1.66e30\", \"1.74e30\", \"1.8e30\",\n            \"1.9e30\", \"2.0e30\", \"2.06e30\", \"2.14e30\", \"2.2e30\", \"2.3e30\", \"2.4e30\", \"2.46e30\",\n        ],\n        &[\n            \"0x1.0E+25#5\",\n            \"0x1.1E+25#5\",\n            \"0x1.2E+25#5\",\n            \"0x1.3E+25#5\",\n            \"0x1.4E+25#5\",\n            \"0x1.5E+25#5\",\n            \"0x1.6E+25#5\",\n            \"0x1.7E+25#5\",\n            \"0x1.8E+25#5\",\n            \"0x1.9E+25#5\",\n            \"0x1.aE+25#5\",\n            \"0x1.bE+25#5\",\n            \"0x1.cE+25#5\",\n            \"0x1.dE+25#5\",\n            \"0x1.eE+25#5\",\n            \"0x1.fE+25#5\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        100,\n        30,\n        &[\n            \"1.2676506e30\",\n            \"1.267650603e30\",\n            \"1.267650605e30\",\n            \"1.267650607e30\",\n            \"1.26765061e30\",\n            \"1.267650612e30\",\n            \"1.267650614e30\",\n            \"1.267650617e30\",\n            \"1.267650619e30\",\n            \"1.267650621e30\",\n            \"1.267650624e30\",\n            \"1.267650626e30\",\n            \"1.267650629e30\",\n            \"1.267650631e30\",\n            \"1.267650633e30\",\n            \"1.267650636e30\",\n            \"1.267650638e30\",\n            \"1.26765064e30\",\n            \"1.267650643e30\",\n            \"1.267650645e30\",\n        ],\n        &[\n            \"0x1.00000000E+25#30\",\n            \"0x1.00000008E+25#30\",\n            \"0x1.00000010E+25#30\",\n            \"0x1.00000018E+25#30\",\n            \"0x1.00000020E+25#30\",\n            \"0x1.00000028E+25#30\",\n            \"0x1.00000030E+25#30\",\n            \"0x1.00000038E+25#30\",\n            \"0x1.00000040E+25#30\",\n            \"0x1.00000048E+25#30\",\n            \"0x1.00000050E+25#30\",\n            \"0x1.00000058E+25#30\",\n            \"0x1.00000060E+25#30\",\n            \"0x1.00000068E+25#30\",\n            \"0x1.00000070E+25#30\",\n            \"0x1.00000078E+25#30\",\n            \"0x1.00000080E+25#30\",\n            \"0x1.00000088E+25#30\",\n            \"0x1.00000090E+25#30\",\n            \"0x1.00000098E+25#30\",\n        ],\n    );\n\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -1,\n        1,\n        &[\"0.5\"],\n        &[\"0x0.8#1\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -1,\n        2,\n        &[\"0.5\", \"0.8\"],\n        &[\"0x0.8#2\", \"0x0.c#2\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -1,\n        3,\n        &[\"0.5\", \"0.6\", \"0.8\", \"0.9\"],\n        &[\"0x0.8#3\", \"0x0.a#3\", \"0x0.c#3\", \"0x0.e#3\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -1,\n        4,\n        &[\"0.5\", \"0.56\", \"0.62\", \"0.7\", \"0.75\", \"0.81\", \"0.88\", \"0.94\"],\n        &[\"0x0.8#4\", \"0x0.9#4\", \"0x0.a#4\", \"0x0.b#4\", \"0x0.c#4\", \"0x0.d#4\", \"0x0.e#4\", \"0x0.f#4\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -1,\n        5,\n        &[\n            \"0.5\", \"0.53\", \"0.56\", \"0.59\", \"0.62\", \"0.66\", \"0.69\", \"0.72\", \"0.75\", \"0.78\", \"0.81\",\n            \"0.84\", \"0.88\", \"0.91\", \"0.94\", \"0.97\",\n        ],\n        &[\n            \"0x0.80#5\", \"0x0.88#5\", \"0x0.90#5\", \"0x0.98#5\", \"0x0.a0#5\", \"0x0.a8#5\", \"0x0.b0#5\",\n            \"0x0.b8#5\", \"0x0.c0#5\", \"0x0.c8#5\", \"0x0.d0#5\", \"0x0.d8#5\", \"0x0.e0#5\", \"0x0.e8#5\",\n            \"0x0.f0#5\", \"0x0.f8#5\",\n        ],\n    );\n\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -10,\n        1,\n        &[\"0.001\"],\n        &[\"0x0.004#1\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -10,\n        2,\n        &[\"0.00098\", \"0.0015\"],\n        &[\"0x0.004#2\", \"0x0.006#2\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -10,\n        3,\n        &[\"0.00098\", \"0.0012\", \"0.0015\", \"0.0017\"],\n        &[\"0x0.004#3\", \"0x0.005#3\", \"0x0.006#3\", \"0x0.007#3\"],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -10,\n        4,\n        &[\"0.00098\", \"0.0011\", \"0.0012\", \"0.0013\", \"0.0015\", \"0.0016\", \"0.0017\", \"0.0018\"],\n        &[\n            \"0x0.0040#4\",\n            \"0x0.0048#4\",\n            \"0x0.0050#4\",\n            \"0x0.0058#4\",\n            \"0x0.0060#4\",\n            \"0x0.0068#4\",\n            \"0x0.0070#4\",\n            \"0x0.0078#4\",\n        ],\n    );\n    exhaustive_positive_floats_with_sci_exponent_and_precision_helper(\n        -10,\n        5,\n        &[\n            \"0.00098\", \"0.001\", \"0.0011\", \"0.00116\", \"0.00122\", \"0.00128\", \"0.00134\", \"0.0014\",\n            \"0.00146\", \"0.00153\", \"0.00159\", \"0.00165\", \"0.0017\", \"0.00177\", \"0.00183\", \"0.0019\",\n        ],\n        &[\n            \"0x0.0040#5\",\n            \"0x0.0044#5\",\n            \"0x0.0048#5\",\n            \"0x0.004c#5\",\n            \"0x0.0050#5\",\n            \"0x0.0054#5\",\n            \"0x0.0058#5\",\n            \"0x0.005c#5\",\n            \"0x0.0060#5\",\n            \"0x0.0064#5\",\n            \"0x0.0068#5\",\n            \"0x0.006c#5\",\n            \"0x0.0070#5\",\n            \"0x0.0074#5\",\n            \"0x0.0078#5\",\n            \"0x0.007c#5\",\n        ],\n    );\n}\n\n#[test]\nfn exhaustive_positive_floats_with_sci_exponent_and_precision_fail() {\n    assert_panic!(exhaustive_positive_floats_with_sci_exponent_and_precision(\n        1, 0\n    ));\n}\n"
  },
  {
    "path": "malachite-float/tests/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::bool_assert_comparison,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::excessive_precision,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::float_cmp,\n    clippy::type_complexity,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::option_if_let_else,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::borrow_as_ptr,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns\n)]\n\n#[macro_use]\nextern crate malachite_base;\n\npub mod arithmetic {\n    pub mod abs;\n    pub mod add;\n    pub mod agm;\n    pub mod div;\n    pub mod is_power_of_2;\n    pub mod ln;\n    pub mod mul;\n    pub mod neg;\n    pub mod power_of_2;\n    pub mod reciprocal;\n    pub mod reciprocal_sqrt;\n    pub mod shl;\n    pub mod shl_round;\n    pub mod shr;\n    pub mod shr_round;\n    pub mod sign;\n    pub mod sqrt;\n    pub mod square;\n    pub mod sub;\n}\npub mod basic {\n    pub mod classification;\n    pub mod complexity;\n    pub mod constants;\n    pub mod get_and_set;\n    pub mod named;\n    pub mod overflow_and_underflow;\n    pub mod size;\n    pub mod ulp;\n}\npub mod comparison {\n    pub mod cmp;\n    pub mod cmp_abs;\n    pub mod eq;\n    pub mod eq_abs;\n    pub mod eq_abs_integer;\n    pub mod eq_abs_natural;\n    pub mod eq_abs_primitive_float;\n    pub mod eq_abs_primitive_int;\n    pub mod eq_abs_rational;\n    pub mod hash;\n    pub mod partial_cmp_abs_integer;\n    pub mod partial_cmp_abs_natural;\n    pub mod partial_cmp_abs_primitive_float;\n    pub mod partial_cmp_abs_primitive_int;\n    pub mod partial_cmp_abs_rational;\n    pub mod partial_cmp_integer;\n    pub mod partial_cmp_natural;\n    pub mod partial_cmp_primitive_float;\n    pub mod partial_cmp_primitive_int;\n    pub mod partial_cmp_rational;\n    pub mod partial_eq_integer;\n    pub mod partial_eq_natural;\n    pub mod partial_eq_primitive_float;\n    pub mod partial_eq_primitive_int;\n    pub mod partial_eq_rational;\n}\npub mod constants {\n    pub mod gauss_constant;\n    pub mod lemniscate_constant;\n    pub mod ln_2;\n    pub mod log_2_e;\n    pub mod one_over_pi;\n    pub mod one_over_sqrt_pi;\n    pub mod one_over_sqrt_tau;\n    pub mod phi;\n    pub mod pi;\n    pub mod pi_over_2;\n    pub mod pi_over_3;\n    pub mod pi_over_4;\n    pub mod pi_over_6;\n    pub mod pi_over_8;\n    pub mod prime_constant;\n    pub mod prouhet_thue_morse_constant;\n    pub mod sqrt_2;\n    pub mod sqrt_2_over_2;\n    pub mod sqrt_3;\n    pub mod sqrt_3_over_3;\n    pub mod sqrt_pi;\n    pub mod tau;\n    pub mod two_over_pi;\n    pub mod two_over_sqrt_pi;\n}\npub mod conversion {\n    pub mod clone;\n    pub mod from_integer;\n    pub mod from_natural;\n    pub mod from_primitive_float;\n    pub mod from_primitive_int;\n    pub mod from_rational;\n    pub mod integer_from_float;\n    pub mod is_integer;\n    pub mod mantissa_and_exponent;\n    pub mod natural_from_float;\n    pub mod primitive_float_from_float;\n    pub mod primitive_int_from_float;\n    pub mod rational_from_float;\n}\npub mod exhaustive {\n    pub mod exhaustive_finite_floats;\n    pub mod exhaustive_floats;\n    pub mod exhaustive_negative_finite_floats;\n    pub mod exhaustive_non_negative_finite_floats;\n    pub mod exhaustive_non_positive_finite_floats;\n    pub mod exhaustive_nonzero_finite_floats;\n    pub mod exhaustive_positive_finite_floats;\n    pub mod exhaustive_positive_floats_with_sci_exponent;\n    pub mod exhaustive_positive_floats_with_sci_exponent_and_precision;\n}\npub mod random {\n    pub mod random_finite_floats;\n    pub mod random_floats;\n    pub mod random_negative_finite_floats;\n    pub mod random_non_negative_finite_floats;\n    pub mod random_non_positive_finite_floats;\n    pub mod random_nonzero_finite_floats;\n    pub mod random_positive_finite_floats;\n    pub mod striped_random_negative_finite_floats;\n    pub mod striped_random_non_negative_finite_floats;\n    pub mod striped_random_non_positive_finite_floats;\n    pub mod striped_random_nonzero_finite_floats;\n    pub mod striped_random_positive_finite_floats;\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn random_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2, special probability 1/10\n    let values = &[\n        \"-3.0\", \"-1.0\", \"-2.0\", \"1.12\", \"-1.0\", \"1.5\", \"-2.0\", \"-0.3\", \"-1.0\", \"0.8\", \"0.0\",\n        \"0.338\", \"-1.2\", \"-0.59\", \"8.0\", \"-6.0\", \"-3.0\", \"-0.2\", \"-0.8\", \"-0.5\",\n    ];\n    let values_hex = &[\n        \"-0x3.0#3\",\n        \"-0x1.0#3\",\n        \"-0x2.0#2\",\n        \"0x1.2#5\",\n        \"-0x1.0#2\",\n        \"0x1.8#3\",\n        \"-0x2.0#1\",\n        \"-0x0.5#3\",\n        \"-0x1.0#1\",\n        \"0x0.c#2\",\n        \"0x0.0\",\n        \"0x0.568#9\",\n        \"-0x1.4#3\",\n        \"-0x0.98#5\",\n        \"0x8.0#1\",\n        \"-0x6.0#2\",\n        \"-0x3.0#2\",\n        \"-0x0.4#1\",\n        \"-0x0.c#2\",\n        \"-0x0.8#2\",\n    ];\n    let common_values = &[\n        (\"1.0\", 75012),\n        (\"-1.0\", 74560),\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"0.5\", 37822),\n        (\"2.0\", 37501),\n        (\"-0.5\", 37342),\n        (\"-2.0\", 37246),\n        (\"-0.2\", 18908),\n        (\"-1.0\", 18873),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 75012),\n        (\"-0x1.0#1\", 74560),\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"0x0.8#1\", 37822),\n        (\"0x2.0#1\", 37501),\n        (\"-0x0.8#1\", 37342),\n        (\"-0x2.0#1\", 37246),\n        (\"-0x0.4#1\", 18908),\n        (\"-0x1.0#2\", 18873),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.7164152871702301),\n        standard_deviation: NiceFloat(1678.2398853586644),\n        skewness: NiceFloat(-81.29182513358477),\n        excess_kurtosis: NiceFloat(334895.7379317797),\n    };\n    random_finite_floats_helper(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64, special probability 1/10\n    let values = &[\n        \"-2.55291108846570214097387565888051871482698844535\",\n        \"-1.42916620847224432\",\n        \"-2.8\",\n        \"1.627895434494957473077687019296248257966273\",\n        \"-1.7636659376\",\n        \"1.0673947\",\n        \"-2.56646360702751047\",\n        \"-0.26139226673975317791585341\",\n        \"-1.1299945035408183423314884117645901537\",\n        \"0.85631649\",\n        \"0.0\",\n        \"0.38895408170042664025227\",\n        \"-1.12207115063093089756992765\",\n        \"-0.934062407041679788538190170179503\",\n        \"11.30718\",\n        \"-5.0\",\n        \"-3.2134957439331342\",\n        \"-0.35078847666770333344764253961\",\n        \"-0.8696\",\n        \"-0.61703047474\",\n    ];\n    let values_hex = &[\n        \"-0x2.8d8b94c28e52f82d1e50104590476568ffae14e#158\",\n        \"-0x1.6dddd62defc582#57\",\n        \"-0x2.c#5\",\n        \"0x1.a0bdc15476ab627f1b98bc51ab2497603df6#145\",\n        \"-0x1.c37f9c630#34\",\n        \"0x1.1140c8#22\",\n        \"-0x2.9103c24a8eaeb4#57\",\n        \"-0x0.42ea9a8513159b517a2ee8#84\",\n        \"-0x1.214751dd5e1921c008153fce88b687c#123\",\n        \"0x0.db378ec#26\",\n        \"0x0.0\",\n        \"0x0.63927ea48c8e2dfcdd8#75\",\n        \"-0x1.1f400e0fbeb4413f6af44#85\",\n        \"-0x0.ef1eb6c2aac41a798ac240288da#107\",\n        \"0xb.4ea38#21\",\n        \"-0x5.0#4\",\n        \"-0x3.36a7a836072b20#55\",\n        \"-0x0.59cd460b19f84a9b4a9886c4#94\",\n        \"-0x0.dea0#13\",\n        \"-0x0.9df5b58da#36\",\n    ];\n    let common_values = &[\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"1.0\", 2360),\n        (\"-1.0\", 2302),\n        (\"2.0\", 1209),\n        (\"-1.0\", 1197),\n        (\"-0.5\", 1177),\n        (\"1.0\", 1168),\n        (\"0.5\", 1158),\n        (\"-2.0\", 1158),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"0x1.0#1\", 2360),\n        (\"-0x1.0#1\", 2302),\n        (\"0x2.0#1\", 1209),\n        (\"-0x1.0#2\", 1197),\n        (\"-0x0.8#1\", 1177),\n        (\"0x1.0#2\", 1168),\n        (\"0x0.8#1\", 1158),\n        (\"-0x2.0#1\", 1158),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.6054865970994369),\n        standard_deviation: NiceFloat(1644.9473368833571),\n        skewness: NiceFloat(-6.939646339338025),\n        excess_kurtosis: NiceFloat(322737.3533747247),\n    };\n    random_finite_floats_helper(\n        1,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2, special probability 1/10\n    let values = &[\n        \"-5.0e13\", \"-2.2e-16\", \"-0.5\", \"3.0e8\", \"-9.5e-7\", \"0.38\", \"-1.0e-11\", \"-7.0e-17\",\n        \"-3.0e10\", \"1.7e-13\", \"0.0\", \"3.99e20\", \"-1.6e-29\", \"-4.7e28\", \"1.0e-8\", \"-2.5e-21\",\n        \"-1.0e10\", \"-1.0e43\", \"-0.19\", \"-0.1\",\n    ];\n    let values_hex = &[\n        \"-0x3.0E+11#3\",\n        \"-0x1.0E-13#3\",\n        \"-0x0.8#2\",\n        \"0x1.2E+7#5\",\n        \"-0x0.000010#2\",\n        \"0x0.6#3\",\n        \"-0x1.0E-9#1\",\n        \"-0x5.0E-14#3\",\n        \"-0x8.0E+8#1\",\n        \"0x3.0E-11#2\",\n        \"0x0.0\",\n        \"0x1.5aE+17#9\",\n        \"-0x1.4E-24#3\",\n        \"-0x9.8E+23#5\",\n        \"0x4.0E-7#1\",\n        \"-0xc.0E-18#2\",\n        \"-0x3.0E+8#2\",\n        \"-0x8.0E+35#1\",\n        \"-0x0.3#2\",\n        \"-0x0.2#2\",\n    ];\n    let common_values = &[\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"1.0\", 1791),\n        (\"0.5\", 1788),\n        (\"-1.0\", 1782),\n        (\"-4.0\", 1778),\n        (\"-0.5\", 1727),\n        (\"2.0\", 1695),\n        (\"4.0\", 1690),\n        (\"2.0e1\", 1689),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"0x1.0#1\", 1791),\n        (\"0x0.8#1\", 1788),\n        (\"-0x1.0#1\", 1782),\n        (\"-0x4.0#1\", 1778),\n        (\"-0x0.8#1\", 1727),\n        (\"0x2.0#1\", 1695),\n        (\"0x4.0#1\", 1690),\n        (\"0x1.0E+1#1\", 1689),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.7899297879002272e243),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_finite_floats_helper(\n        64,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64, special probability 1/10\n    let values = &[\n        \"-44911286823141.1855899032680253942982725544577883\",\n        \"-3.17338646132424422e-16\",\n        \"-0.69\",\n        \"436984853.27897203898621663845006920021638213\",\n        \"-1.6819629074e-6\",\n        \"0.2668487\",\n        \"-1.86734804230764746e-11\",\n        \"-5.8040742598686895873572801e-17\",\n        \"-38826315498.940567851125400956255170888\",\n        \"1.94703828e-13\",\n        \"0.0\",\n        \"459195929699359096631.38\",\n        \"-1.41625290177455750344133296e-29\",\n        \"-74004048183563132066750152744.5532\",\n        \"2.106127e-8\",\n        \"-2.1e-21\",\n        \"-13801859126.0280018\",\n        \"-1.5645688873494313277150105805e43\",\n        \"-0.21741\",\n        \"-0.154257618684\",\n    ];\n    let values_hex = &[\n        \"-0x28d8b94c28e5.2f82d1e50104590476568ffae14e#158\",\n        \"-0x1.6dddd62defc582E-13#57\",\n        \"-0x0.b0#5\",\n        \"0x1a0bdc15.476ab627f1b98bc51ab2497603df6#145\",\n        \"-0x0.00001c37f9c630#34\",\n        \"0x0.445032#22\",\n        \"-0x1.4881e12547575aE-9#57\",\n        \"-0x4.2ea9a8513159b517a2ee8E-14#84\",\n        \"-0x90a3a8eea.f0c90e0040a9fe7445b43e#123\",\n        \"0x3.6cde3bE-11#26\",\n        \"0x0.0\",\n        \"0x18e49fa923238b7f37.60#75\",\n        \"-0x1.1f400e0fbeb4413f6af44E-24#85\",\n        \"-0xef1eb6c2aac41a798ac24028.8da#107\",\n        \"0x5.a751cE-7#21\",\n        \"-0xa.0E-18#4\",\n        \"-0x336a7a836.072b20#55\",\n        \"-0xb.39a8c1633f0953695310d88E+35#94\",\n        \"-0x0.37a8#13\",\n        \"-0x0.277d6d6368#36\",\n    ];\n    let common_values = &[\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"-2.0e1\", 77),\n        (\"2.0\", 66),\n        (\"-2.0\", 61),\n        (\"-8.0\", 61),\n        (\"-3.0e1\", 59),\n        (\"-0.2\", 58),\n        (\"0.5\", 57),\n        (\"4.0e3\", 57),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"-0x1.0E+1#1\", 77),\n        (\"0x2.0#1\", 66),\n        (\"-0x2.0#1\", 61),\n        (\"-0x8.0#1\", 61),\n        (\"-0x2.0E+1#1\", 59),\n        (\"-0x0.4#1\", 58),\n        (\"0x0.8#1\", 57),\n        (\"0x1.0E+3#1\", 57),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.2330178132397616e243),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_finite_floats_helper(\n        64,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_finite_floats_fail_1() {\n    random_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_finite_floats_fail_2() {\n    random_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_finite_floats_fail_3() {\n    random_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_finite_floats_fail_4() {\n    random_finite_floats(EXAMPLE_SEED, 1, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_finite_floats_fail_5() {\n    random_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_finite_floats_fail_6() {\n    random_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn random_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_floats() {\n    // mean |sci_exponent| 1, mean precision 2, zero probability 1/10\n    let values = &[\n        \"1.0\", \"0.2\", \"0.0\", \"NaN\", \"-0.2\", \"-1.0\", \"-1.0\", \"-1.5\", \"2.0\", \"0.2\", \"-1.0\", \"-0.2\",\n        \"-2.0\", \"Infinity\", \"-0.5\", \"-1.0\", \"-0.4\", \"NaN\", \"0.5\", \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0x1.0#1\", \"0x0.4#1\", \"0x0.0\", \"NaN\", \"-0x0.4#1\", \"-0x1.0#2\", \"-0x1.0#1\", \"-0x1.8#2\",\n        \"0x2.0#1\", \"0x0.4#1\", \"-0x1.0#3\", \"-0x0.4#2\", \"-0x2.0#1\", \"Infinity\", \"-0x0.8#1\",\n        \"-0x1.0#2\", \"-0x0.6#2\", \"NaN\", \"0x0.8#1\", \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 67626),\n        (\"1.0\", 67293),\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"-2.0\", 33918),\n        (\"2.0\", 33760),\n        (\"0.5\", 33658),\n        (\"Infinity\", 33640),\n        (\"-0.5\", 33629),\n        (\"NaN\", 33393),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 67626),\n        (\"0x1.0#1\", 67293),\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"-0x2.0#1\", 33918),\n        (\"0x2.0#1\", 33760),\n        (\"0x0.8#1\", 33658),\n        (\"Infinity\", 33640),\n        (\"-0x0.8#1\", 33629),\n        (\"NaN\", 33393),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_floats_helper(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64, zero probability 1/10\n    let values = &[\n        \"1.60469\",\n        \"0.3689021918822\",\n        \"0.0\",\n        \"NaN\",\n        \"-0.28085087121796634898241172643\",\n        \"-1.753651001\",\n        \"-1.76635021435647835233096910201935186533898089\",\n        \"-1.43252385721349903405196303338780402302813416810241256872117258\",\n        \"2.0\",\n        \"0.250602502656981020491543289450999271\",\n        \"-1.8960717298288877935\",\n        \"-0.25858\",\n        \"-2.6358228847359354842130018065396119276102632191023\",\n        \"Infinity\",\n        \"-0.9541023510530255\",\n        \"-1.5\",\n        \"-0.464323\",\n        \"NaN\",\n        \"0.725643469742899\",\n        \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0x1.9acd0#18\",\n        \"0x0.5e705fc18e8#40\",\n        \"0x0.0\",\n        \"NaN\",\n        \"-0x0.47e5d7baef2c868cbb8316be#95\",\n        \"-0x1.c0ef45a0#30\",\n        \"-0x1.c42f8713f193fa44085ebdae1b4419f73e3d8#146\",\n        \"-0x1.6eb9e22d78c4bde3d56b1e7932a0b849250a5abf6d02e887830#205\",\n        \"0x2.00#7\",\n        \"0x0.40277c51351dd7528f4d46d26a8156#118\",\n        \"-0x1.e564f4f67c376d50#62\",\n        \"-0x0.4232#14\",\n        \"-0x2.a2c549dffd3d8e02dee8e02a95b00cb3a36c841e#162\",\n        \"Infinity\",\n        \"-0x0.f4400d3acf388#51\",\n        \"-0x1.8#2\",\n        \"-0x0.76dde0#20\",\n        \"NaN\",\n        \"0x0.b9c3c53b1a0a#48\",\n        \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"1.0\", 2133),\n        (\"-1.0\", 2122),\n        (\"-2.0\", 1103),\n        (\"0.5\", 1094),\n        (\"1.5\", 1091),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0x1.0#1\", 2133),\n        (\"-0x1.0#1\", 2122),\n        (\"-0x2.0#1\", 1103),\n        (\"0x0.8#1\", 1094),\n        (\"0x1.8#2\", 1091),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_floats_helper(\n        1,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2, zero probability 1/10\n    let values = &[\n        \"5.0e11\", \"7.0e122\", \"0.0\", \"NaN\", \"-2.0e25\", \"-2.0e21\", \"-2.0e-9\", \"-4.0e33\", \"4.0e-9\",\n        \"5.0e2\", \"-4.0e-16\", \"-7.0e-18\", \"-2.0e-19\", \"Infinity\", \"-2.0e50\", \"-1.0e12\", \"-3.0e-28\",\n        \"NaN\", \"0.02\", \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0x8.0E+9#1\",\n        \"0x1.0E+102#1\",\n        \"0x0.0\",\n        \"NaN\",\n        \"-0x1.0E+21#1\",\n        \"-0x8.0E+17#2\",\n        \"-0x8.0E-8#1\",\n        \"-0xc.0E+27#2\",\n        \"0x1.0E-7#1\",\n        \"0x2.0E+2#1\",\n        \"-0x2.0E-13#3\",\n        \"-0x8.0E-15#2\",\n        \"-0x4.0E-16#1\",\n        \"Infinity\",\n        \"-0x8.0E+41#1\",\n        \"-0x1.0E+10#2\",\n        \"-0x1.8E-23#2\",\n        \"NaN\",\n        \"0x0.04#1\",\n        \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0.5\", 1583),\n        (\"-1.0\", 1560),\n        (\"2.0\", 1542),\n        (\"-2.0\", 1523),\n        (\"1.0\", 1518),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0x0.8#1\", 1583),\n        (\"-0x1.0#1\", 1560),\n        (\"0x2.0#1\", 1542),\n        (\"-0x2.0#1\", 1523),\n        (\"0x1.0#1\", 1518),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_floats_helper(\n        64,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64, zero probability 1/10\n    let values = &[\n        \"8.82188e11\",\n        \"9.75459983374e122\",\n        \"0.0\",\n        \"NaN\",\n        \"-21729783659306408649613509.686\",\n        \"-4.140691354e21\",\n        \"-3.29008365861415556134836580980448399733562188e-9\",\n        \"-3719044561792922503530448846362960.3599330496921301151502834994\",\n        \"3.73e-9\",\n        \"513.233925441497129966680656795646506\",\n        \"-8.420249963187521806e-16\",\n        \"-7.177e-18\",\n        \"-2.8577648979177105962332201291018926848163080599637e-19\",\n        \"Infinity\",\n        \"-3.569720699507868e50\",\n        \"-1.6e12\",\n        \"-3.750772e-28\",\n        \"NaN\",\n        \"0.0226763584294656\",\n        \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0xc.d668E+9#18\",\n        \"0x1.79c17f063aE+102#40\",\n        \"0x0.0\",\n        \"NaN\",\n        \"-0x11f975eebbcb21a32ee0c5.af8#95\",\n        \"-0xe.077a2d0E+17#30\",\n        \"-0xe.217c389f8c9fd22042f5ed70da20cfb9f1ecE-8#146\",\n        \"-0xb75cf116bc625ef1eab58f3c9950.5c2492852d5fb6817443c180#205\",\n        \"0x1.00E-7#7\",\n        \"0x201.3be289a8eeba947a6a3693540ab#118\",\n        \"-0x3.cac9e9ecf86edaaE-13#62\",\n        \"-0x8.464E-15#14\",\n        \"-0x5.458a93bffa7b1c05bdd1c0552b60196746d9083cE-16#162\",\n        \"Infinity\",\n        \"-0xf.4400d3acf388E+41#51\",\n        \"-0x1.8E+10#2\",\n        \"-0x1.db778E-23#20\",\n        \"NaN\",\n        \"0x0.05ce1e29d8d050#48\",\n        \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0.00003\", 60),\n        (\"-0.5\", 57),\n        (\"-6.0e1\", 56),\n        (\"-5.0e2\", 55),\n        (\"8.0\", 54),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0x0.0002#1\", 60),\n        (\"-0x0.8#1\", 57),\n        (\"-0x4.0E+1#1\", 56),\n        (\"-0x2.0E+2#1\", 55),\n        (\"0x8.0#1\", 54),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_floats_helper(\n        64,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_floats_fail_1() {\n    random_floats(EXAMPLE_SEED, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_floats_fail_2() {\n    random_floats(EXAMPLE_SEED, 0, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_floats_fail_3() {\n    random_floats(EXAMPLE_SEED, 1, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_floats_fail_4() {\n    random_floats(EXAMPLE_SEED, 1, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_floats_fail_5() {\n    random_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_floats_fail_6() {\n    random_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_negative_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_negative_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn random_negative_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_negative_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_negative_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"-1.5\", \"-1.0\", \"-2.0\", \"-1.0\", \"-1.0\", \"-2.0\", \"-2.0\", \"-1.2\", \"-2.0\", \"-1.0\", \"-2.0\",\n        \"-2.0\", \"-4.0\", \"-1.0\", \"-1.8\", \"-2.5\", \"-0.1\", \"-1.0\", \"-0.2\", \"-1.2\",\n    ];\n    let values_hex = &[\n        \"-0x1.8#2\", \"-0x1.0#1\", \"-0x2.0#2\", \"-0x1.0#2\", \"-0x1.0#1\", \"-0x2.0#1\", \"-0x2.0#1\",\n        \"-0x1.4#3\", \"-0x2.0#1\", \"-0x1.0#1\", \"-0x2.0#1\", \"-0x2.0#1\", \"-0x4.0#1\", \"-0x1.0#1\",\n        \"-0x1.c#3\", \"-0x2.8#4\", \"-0x0.2#1\", \"-0x1.0#1\", \"-0x0.4#1\", \"-0x1.4#3\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 166114),\n        (\"-0.5\", 83464),\n        (\"-2.0\", 83434),\n        (\"-1.5\", 42025),\n        (\"-0.2\", 41531),\n        (\"-1.0\", 41506),\n        (\"-4.0\", 41483),\n        (\"-3.0\", 21005),\n        (\"-2.0\", 20892),\n        (\"-0.1\", 20888),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 166114),\n        (\"-0x0.8#1\", 83464),\n        (\"-0x2.0#1\", 83434),\n        (\"-0x1.8#2\", 42025),\n        (\"-0x0.4#1\", 41531),\n        (\"-0x1.0#2\", 41506),\n        (\"-0x4.0#1\", 41483),\n        (\"-0x3.0#2\", 21005),\n        (\"-0x2.0#2\", 20892),\n        (\"-0x0.2#1\", 20888),\n    ];\n    let sample_median = (\"-1.0\", None);\n    let sample_median_hex = (\"-0x1.0#2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.292847587427611),\n        standard_deviation: NiceFloat(416.97010060005687),\n        skewness: NiceFloat(-334.72226371600976),\n        excess_kurtosis: NiceFloat(139648.08254659182),\n    };\n    random_negative_finite_floats_helper(\n        1,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"-1.8\",\n        \"-1.3850071337780625300836\",\n        \"-3.21176241813\",\n        \"-1.981013494834061409257349\",\n        \"-1.665272\",\n        \"-3.0477509378551710980549069671536911164880571509\",\n        \"-3.86646429082638580413691355062141611967080168780483321308586\",\n        \"-1.1383718\",\n        \"-3.005438259332186398250782844\",\n        \"-1.31402772840010613\",\n        \"-2.2954821356993\",\n        \"-3.341070237\",\n        \"-6.42834377982969296\",\n        \"-1.055708800484474\",\n        \"-1.09154149257425903017951075071293557661092806\",\n        \"-2.750421277483313\",\n        \"-0.2219335998\",\n        \"-1.1563594283786540769774526007723931560664\",\n        \"-0.39596234107597\",\n        \"-1.3496675\",\n    ];\n    let values_hex = &[\n        \"-0x1.c#3\",\n        \"-0x1.628fd3d84db091d430#71\",\n        \"-0x3.36360fd46#38\",\n        \"-0x1.fb23b34d3f38af725038#79\",\n        \"-0x1.aa4f4#19\",\n        \"-0x3.0c3967cc70f8444c90df6c12283a15fa4637da#153\",\n        \"-0x3.ddd09a90404c02ee3c715fa17bf84c143354d47adb8aff3c0#195\",\n        \"-0x1.236c56#24\",\n        \"-0x3.016466d9fa99ac91c2dfb4#89\",\n        \"-0x1.50641f07840015#57\",\n        \"-0x2.4ba4b79d6178#48\",\n        \"-0x3.57506108#31\",\n        \"-0x6.6da7f01dd04530#57\",\n        \"-0x1.0e42ee942e22#48\",\n        \"-0x1.176f4364d55e3feb51571e25ef39e528b86a#145\",\n        \"-0x2.c01b9bdd036c4#54\",\n        \"-0x0.38d0a3f10#31\",\n        \"-0x1.28072be74ebd242348b5852a9e4a3c62e#132\",\n        \"-0x0.655dc9b95e7#43\",\n        \"-0x1.5983d0#24\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 5069),\n        (\"-1.0\", 2626),\n        (\"-0.5\", 2623),\n        (\"-2.0\", 2623),\n        (\"-1.5\", 2488),\n        (\"-2.0\", 1309),\n        (\"-0.2\", 1301),\n        (\"-4.0\", 1299),\n        (\"-1.2\", 1293),\n        (\"-0.8\", 1283),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 5069),\n        (\"-0x1.0#2\", 2626),\n        (\"-0x0.8#1\", 2623),\n        (\"-0x2.0#1\", 2623),\n        (\"-0x1.8#2\", 2488),\n        (\"-0x2.0#2\", 1309),\n        (\"-0x0.4#1\", 1301),\n        (\"-0x4.0#1\", 1299),\n        (\"-0x1.4#3\", 1293),\n        (\"-0x0.c#2\", 1283),\n    ];\n    let sample_median = (\n        \"-1.492048772960956\",\n        Some(\"-1.492046225515012964994532213857812720544842101177086840260174\"),\n    );\n    let sample_median_hex = (\n        \"-0x1.7df6e88be77c#49\",\n        Some(\"-0x1.7df6bdceb50c76e2fdee90d7296fa9b4a2cc3ae315ce8cf010#199\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-9.138627718915657),\n        standard_deviation: NiceFloat(468.606797626186),\n        skewness: NiceFloat(-309.74563573271297),\n        excess_kurtosis: NiceFloat(127224.11304735676),\n    };\n    random_negative_finite_floats_helper(\n        1,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"-3.0e-37\", \"-8.0e-34\", \"-4.0e-6\", \"-3.0e-45\", \"-2.0e15\", \"-5.0e-10\", \"-2.0e4\", \"-0.08\",\n        \"-0.0001\", \"-1.0e14\", \"-2.0e34\", \"-9.0e-13\", \"-0.0001\", \"-9.0e9\", \"-2.3e33\", \"-0.16\",\n        \"-0.00003\", \"-5.0e18\", \"-0.06\", \"-7.0e8\",\n    ];\n    let values_hex = &[\n        \"-0x6.0E-31#2\",\n        \"-0x4.0E-28#1\",\n        \"-0x0.00004#2\",\n        \"-0x1.0E-37#2\",\n        \"-0x8.0E+12#1\",\n        \"-0x2.0E-8#1\",\n        \"-0x4.0E+3#1\",\n        \"-0x0.14#3\",\n        \"-0x0.0008#1\",\n        \"-0x8.0E+11#1\",\n        \"-0x4.0E+28#1\",\n        \"-0x1.0E-10#1\",\n        \"-0x0.0008#1\",\n        \"-0x2.0E+8#1\",\n        \"-0x7.0E+27#3\",\n        \"-0x0.28#4\",\n        \"-0x0.0002#1\",\n        \"-0x4.0E+15#1\",\n        \"-0x0.1#1\",\n        \"-0x2.8E+7#3\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 3831),\n        (\"-0.2\", 3830),\n        (\"-0.5\", 3826),\n        (\"-2.0\", 3753),\n        (\"-4.0\", 3716),\n        (\"-8.0\", 3653),\n        (\"-0.1\", 3639),\n        (\"-0.06\", 3637),\n        (\"-3.0e1\", 3632),\n        (\"-2.0e1\", 3617),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 3831),\n        (\"-0x0.4#1\", 3830),\n        (\"-0x0.8#1\", 3826),\n        (\"-0x2.0#1\", 3753),\n        (\"-0x4.0#1\", 3716),\n        (\"-0x8.0#1\", 3653),\n        (\"-0x0.2#1\", 3639),\n        (\"-0x0.1#1\", 3637),\n        (\"-0x2.0E+1#1\", 3632),\n        (\"-0x1.0E+1#1\", 3617),\n    ];\n    let sample_median = (\"-1.0\", None);\n    let sample_median_hex = (\"-0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.9680504915704222e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_finite_floats_helper(\n        64,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"-3.3e-37\",\n        \"-1.066970684853243558372e-33\",\n        \"-6.12595065713e-6\",\n        \"-5.55198233623541837705276e-45\",\n        \"-3.74986e15\",\n        \"-7.096098125575043023691761696603361322749539164e-10\",\n        \"-31674.0754704497525074895958066906408523432074264971936815994\",\n        \"-0.07114824\",\n        \"-0.0001834373937580680174713612576\",\n        \"-184932962124288.041\",\n        \"-2.38376493640286e34\",\n        \"-1.519342839e-12\",\n        \"-0.000196177483515310454\",\n        \"-9068469544.36041\",\n        \"-1416901865713435510498832543218638.47378814837\",\n        \"-0.17190132984270706\",\n        \"-0.00005418300776\",\n        \"-5332766608130525448.821004944540229640534\",\n        \"-0.09899058526899\",\n        \"-7.2459725e8\",\n    ];\n    let values_hex = &[\n        \"-0x7.0E-31#3\",\n        \"-0x5.8a3f4f6136c24750cE-28#71\",\n        \"-0x0.000066c6c1fa8c#38\",\n        \"-0x1.fb23b34d3f38af725038E-37#79\",\n        \"-0xd.527aE+12#19\",\n        \"-0x3.0c3967cc70f8444c90df6c12283a15fa4637daE-8#153\",\n        \"-0x7bba.13520809805dc78e2bf42f7f0982866a9a8f5b715fe78#195\",\n        \"-0x0.1236c56#24\",\n        \"-0x0.000c05919b67ea66b2470b7ed0#89\",\n        \"-0xa8320f83c200.0a8#57\",\n        \"-0x4.97496f3ac2f0E+28#48\",\n        \"-0x1.aba83084E-10#31\",\n        \"-0x0.000cdb4fe03ba08a60#57\",\n        \"-0x21c85dd28.5c44#48\",\n        \"-0x45dbd0d935578ffad455c7897bce.794a2e1a8#145\",\n        \"-0x0.2c01b9bdd036c4#54\",\n        \"-0x0.00038d0a3f10#31\",\n        \"-0x4a01caf9d3af4908.d22d614aa7928f18b8#132\",\n        \"-0x0.1957726e579c#43\",\n        \"-0x2.b307a0E+7#24\",\n    ];\n    let common_values = &[\n        (\"-2.0\", 130),\n        (\"-2.0e1\", 129),\n        (\"-0.2\", 122),\n        (\"-3.0e1\", 117),\n        (\"-0.004\", 116),\n        (\"-1.0e5\", 114),\n        (\"-0.02\", 112),\n        (\"-0.00002\", 112),\n        (\"-0.1\", 109),\n        (\"-8.0\", 108),\n    ];\n    let common_values_hex = &[\n        (\"-0x2.0#1\", 130),\n        (\"-0x1.0E+1#1\", 129),\n        (\"-0x0.4#1\", 122),\n        (\"-0x2.0E+1#1\", 117),\n        (\"-0x0.01#1\", 116),\n        (\"-0x2.0E+4#1\", 114),\n        (\"-0x0.04#1\", 112),\n        (\"-0x0.0001#1\", 112),\n        (\"-0x0.2#1\", 109),\n        (\"-0x8.0#1\", 108),\n    ];\n    let sample_median = (\n        \"-1.4527665236460671657422963814630798553398772791\",\n        Some(\"-1.45263\"),\n    );\n    let sample_median_hex = (\n        \"-0x1.73e881c3c8916f41f0bcfa9b4958a2e850b2da0#154\",\n        Some(\"-0x1.73df8#18\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.9911135832684696e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_finite_floats_helper(\n        64,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_negative_finite_floats_fail_1() {\n    random_negative_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_negative_finite_floats_fail_2() {\n    random_negative_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_negative_finite_floats_fail_3() {\n    random_negative_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_negative_finite_floats_fail_4() {\n    random_negative_finite_floats(EXAMPLE_SEED, 1, 1, 1, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_non_negative_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_non_negative_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn random_non_negative_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_non_negative_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_non_negative_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2, zero probability 1/10\n    let values = &[\n        \"8.0\", \"1.0\", \"0.8\", \"0.0\", \"4.0\", \"2.0\", \"1.0\", \"2.0\", \"0.8\", \"0.9536\", \"2.0\", \"3.0e1\",\n        \"0.5\", \"0.0\", \"1.0\", \"2.0\", \"0.5\", \"0.0\", \"1.5\", \"0.1\",\n    ];\n    let values_hex = &[\n        \"0x8.0#1\",\n        \"0x1.0#1\",\n        \"0x0.c#2\",\n        \"0x0.0\",\n        \"0x4.0#1\",\n        \"0x2.0#3\",\n        \"0x1.0#1\",\n        \"0x2.0#1\",\n        \"0x0.c#2\",\n        \"0x0.f42#12\",\n        \"0x2.0#1\",\n        \"0x2.0E+1#1\",\n        \"0x0.8#1\",\n        \"0x0.0\",\n        \"0x1.0#1\",\n        \"0x2.0#2\",\n        \"0x0.8#1\",\n        \"0x0.0\",\n        \"0x1.8#2\",\n        \"0x0.2#1\",\n    ];\n    let common_values = &[\n        (\"1.0\", 149586),\n        (\"0.0\", 100224),\n        (\"2.0\", 74929),\n        (\"0.5\", 74827),\n        (\"1.0\", 37902),\n        (\"4.0\", 37612),\n        (\"0.2\", 37602),\n        (\"1.5\", 37600),\n        (\"0.5\", 18934),\n        (\"0.8\", 18834),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 149586),\n        (\"0x0.0\", 100224),\n        (\"0x2.0#1\", 74929),\n        (\"0x0.8#1\", 74827),\n        (\"0x1.0#2\", 37902),\n        (\"0x4.0#1\", 37612),\n        (\"0x0.4#1\", 37602),\n        (\"0x1.8#2\", 37600),\n        (\"0x0.8#2\", 18934),\n        (\"0x0.c#2\", 18834),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.693371936934735),\n        standard_deviation: NiceFloat(1671.7840625385452),\n        skewness: NiceFloat(718.2460436055444),\n        excess_kurtosis: NiceFloat(578520.0792964109),\n    };\n    random_non_negative_finite_floats_helper(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64, zero probability 1/10\n    let values = &[\n        \"8.288616155488807101232282300740634937242230275473095947256061292584667312127693953525219\\\n        033439102\",\n        \"1.0\",\n        \"0.6651592248\",\n        \"0.0\",\n        \"4.2345242873846765390825841\",\n        \"2.38320785690539951782446111823006788535\",\n        \"1.036853813\",\n        \"2.4027026671793265640566992824\",\n        \"0.52666405862440172\",\n        \"0.5366\",\n        \"3.42175\",\n        \"61.701080114490962438\",\n        \"0.8336708437\",\n        \"0.0\",\n        \"1.0\",\n        \"2.5\",\n        \"0.658027364385\",\n        \"0.0\",\n        \"1.246\",\n        \"0.14\",\n    ];\n    let values_hex = &[\n        \"0x8.49e2bf94ebf30cb80717aab089ffe81a4240bd550c84a499a4753e306f26fd3913222c258d89033b#324\",\n        \"0x1.0#1\",\n        \"0x0.aa47dffd#32\",\n        \"0x0.0\",\n        \"0x4.3c09c8a06f55060972e84#86\",\n        \"0x2.6219e8fcfa9bb9ef41add9535f62860#125\",\n        \"0x1.096f406#28\",\n        \"0x2.671785a18c13ffbbe8b27f4#93\",\n        \"0x0.86d374abc53b0a#55\",\n        \"0x0.896#12\",\n        \"0x3.6bf8#16\",\n        \"0x3d.b379fc839d57b1c#65\",\n        \"0x0.d56b73d18#33\",\n        \"0x0.0\",\n        \"0x1.0#2\",\n        \"0x2.8#4\",\n        \"0x0.a8747b39e8#37\",\n        \"0x0.0\",\n        \"0x1.3f#9\",\n        \"0x0.24#4\",\n    ];\n    let common_values = &[\n        (\"0.0\", 100224),\n        (\"1.0\", 4643),\n        (\"2.0\", 2373),\n        (\"0.5\", 2353),\n        (\"1.5\", 2327),\n        (\"1.0\", 2294),\n        (\"0.5\", 1219),\n        (\"4.0\", 1204),\n        (\"2.0\", 1195),\n        (\"0.8\", 1191),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 100224),\n        (\"0x1.0#1\", 4643),\n        (\"0x2.0#1\", 2373),\n        (\"0x0.8#1\", 2353),\n        (\"0x1.8#2\", 2327),\n        (\"0x1.0#2\", 2294),\n        (\"0x0.8#2\", 1219),\n        (\"0x4.0#1\", 1204),\n        (\"0x2.0#2\", 1195),\n        (\"0x0.c#2\", 1191),\n    ];\n    let sample_median = (\n        \"1.31267178118571998379\",\n        Some(\"1.31268190290298901432879852014280461789620659172002407\"),\n    );\n    let sample_median_hex = (\n        \"0x1.500b42029321dc7ec#67\",\n        Some(\"0x1.500bebd304f66efb8d7a481eef659ad171581e14dea8#175\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(10.510498034617717),\n        standard_deviation: NiceFloat(1688.742389206287),\n        skewness: NiceFloat(594.3533044311691),\n        excess_kurtosis: NiceFloat(387838.0226770939),\n    };\n    random_non_negative_finite_floats_helper(\n        1,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2, zero probability 1/10\n    let values = &[\n        \"1.0e9\", \"2.0e-6\", \"24.0\", \"0.0\", \"5.0e-7\", \"0.06\", \"8.0e22\", \"7.0e19\", \"0.05\", \"6.4e7\",\n        \"2.0e38\", \"7.0e-9\", \"2.0e15\", \"0.0\", \"3.0e11\", \"1.0e-8\", \"6.0e14\", \"0.0\", \"0.05\",\n        \"2.0e-34\",\n    ];\n    let values_hex = &[\n        \"0x4.0E+7#1\",\n        \"0x0.00002#1\",\n        \"0x18.0#2\",\n        \"0x0.0\",\n        \"0x8.0E-6#1\",\n        \"0x0.10#3\",\n        \"0x1.0E+19#1\",\n        \"0x4.0E+16#1\",\n        \"0x0.0c#2\",\n        \"0x3.d08E+6#12\",\n        \"0x8.0E+31#1\",\n        \"0x2.0E-7#1\",\n        \"0x8.0E+12#1\",\n        \"0x0.0\",\n        \"0x4.0E+9#1\",\n        \"0x4.0E-7#2\",\n        \"0x2.0E+12#1\",\n        \"0x0.0\",\n        \"0x0.0c#2\",\n        \"0x1.0E-28#1\",\n    ];\n    let common_values = &[\n        (\"0.0\", 100224),\n        (\"1.0\", 3531),\n        (\"2.0\", 3503),\n        (\"4.0\", 3399),\n        (\"0.5\", 3381),\n        (\"0.1\", 3375),\n        (\"0.2\", 3369),\n        (\"0.06\", 3330),\n        (\"8.0\", 3283),\n        (\"2.0e1\", 3250),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 100224),\n        (\"0x1.0#1\", 3531),\n        (\"0x2.0#1\", 3503),\n        (\"0x4.0#1\", 3399),\n        (\"0x0.8#1\", 3381),\n        (\"0x0.2#1\", 3375),\n        (\"0x0.4#1\", 3369),\n        (\"0x0.1#1\", 3330),\n        (\"0x8.0#1\", 3283),\n        (\"0x1.0E+1#1\", 3250),\n    ];\n    let sample_median = (\"0.006\", Some(\"0.0059\"));\n    let sample_median_hex = (\"0x0.018#3\", Some(\"0x0.018#4\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.237414368630999e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_non_negative_finite_floats_helper(\n        64,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64, zero probability 1/10\n    let values = &[\n        \"1112479228.653802418557662930660020738554074733226813063166716380919457294269645928321492\\\n        4893705523\",\n        \"2.0e-6\",\n        \"21.285095192\",\n        \"0.0\",\n        \"5.0479463188465553988010694e-7\",\n        \"0.074475245528293734932014409944689621417\",\n        \"7.83424591e22\",\n        \"88644082373352750967.8179473\",\n        \"0.032916503664025107\",\n        \"3.601e7\",\n        \"2.91091e38\",\n        \"1.43659021971959067597e-8\",\n        \"3.7545197012e15\",\n        \"0.0\",\n        \"3.0e11\",\n        \"1.9e-8\",\n        \"7.4087294826e14\",\n        \"0.0\",\n        \"0.0389\",\n        \"2.2e-34\",\n    ];\n    let values_hex = &[\n        \"0x424f15fc.a75f9865c038bd55844fff40d21205eaa8642524cd23a9f1837937e9c89911612c6c4819d8#324\",\n        \"0x0.00002#1\",\n        \"0x15.48fbffa#32\",\n        \"0x0.0\",\n        \"0x8.78139140deaa0c12e5d08E-6#86\",\n        \"0x0.1310cf47e7d4ddcf7a0d6eca9afb1430#125\",\n        \"0x1.096f406E+19#28\",\n        \"0x4ce2f0b431827ff77.d164fe8#93\",\n        \"0x0.086d374abc53b0a#55\",\n        \"0x2.258E+6#12\",\n        \"0xd.afeE+31#16\",\n        \"0x3.db379fc839d57b1cE-7#65\",\n        \"0xd.56b73d18E+12#33\",\n        \"0x0.0\",\n        \"0x4.0E+9#2\",\n        \"0x5.0E-7#4\",\n        \"0x2.a1d1ece7aE+12#37\",\n        \"0x0.0\",\n        \"0x0.09f8#9\",\n        \"0x1.2E-28#4\",\n    ];\n    let common_values = &[\n        (\"0.0\", 100224),\n        (\"8.0\", 129),\n        (\"4.0\", 120),\n        (\"2.0\", 107),\n        (\"0.06\", 107),\n        (\"1.0e3\", 106),\n        (\"3.0e1\", 105),\n        (\"4.0e3\", 104),\n        (\"0.5\", 102),\n        (\"1.0e2\", 102),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 100224),\n        (\"0x8.0#1\", 129),\n        (\"0x4.0#1\", 120),\n        (\"0x2.0#1\", 107),\n        (\"0x0.1#1\", 107),\n        (\"0x4.0E+2#1\", 106),\n        (\"0x2.0E+1#1\", 105),\n        (\"0x1.0E+3#1\", 104),\n        (\"0x0.8#1\", 102),\n        (\"0x8.0E+1#1\", 102),\n    ];\n    let sample_median = (\"0.007447481\", Some(\"0.0074479832945\"));\n    let sample_median_hex = (\"0x0.01e8140#21\", Some(\"0x0.01e81c6cabc#35\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.6946902524964283e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_non_negative_finite_floats_helper(\n        64,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_finite_floats_fail_1() {\n    random_non_negative_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_finite_floats_fail_2() {\n    random_non_negative_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_finite_floats_fail_3() {\n    random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_finite_floats_fail_4() {\n    random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_finite_floats_fail_5() {\n    random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_finite_floats_fail_6() {\n    random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_non_positive_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_non_positive_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn random_non_positive_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_non_positive_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_non_positive_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2, zero probability 1/10\n    let values = &[\n        \"-8.0\", \"-1.0\", \"-0.8\", \"-0.0\", \"-4.0\", \"-2.0\", \"-1.0\", \"-2.0\", \"-0.8\", \"-0.9536\", \"-2.0\",\n        \"-3.0e1\", \"-0.5\", \"-0.0\", \"-1.0\", \"-2.0\", \"-0.5\", \"-0.0\", \"-1.5\", \"-0.1\",\n    ];\n    let values_hex = &[\n        \"-0x8.0#1\",\n        \"-0x1.0#1\",\n        \"-0x0.c#2\",\n        \"-0x0.0\",\n        \"-0x4.0#1\",\n        \"-0x2.0#3\",\n        \"-0x1.0#1\",\n        \"-0x2.0#1\",\n        \"-0x0.c#2\",\n        \"-0x0.f42#12\",\n        \"-0x2.0#1\",\n        \"-0x2.0E+1#1\",\n        \"-0x0.8#1\",\n        \"-0x0.0\",\n        \"-0x1.0#1\",\n        \"-0x2.0#2\",\n        \"-0x0.8#1\",\n        \"-0x0.0\",\n        \"-0x1.8#2\",\n        \"-0x0.2#1\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 149586),\n        (\"-0.0\", 100224),\n        (\"-2.0\", 74929),\n        (\"-0.5\", 74827),\n        (\"-1.0\", 37902),\n        (\"-4.0\", 37612),\n        (\"-0.2\", 37602),\n        (\"-1.5\", 37600),\n        (\"-0.5\", 18934),\n        (\"-0.8\", 18834),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 149586),\n        (\"-0x0.0\", 100224),\n        (\"-0x2.0#1\", 74929),\n        (\"-0x0.8#1\", 74827),\n        (\"-0x1.0#2\", 37902),\n        (\"-0x4.0#1\", 37612),\n        (\"-0x0.4#1\", 37602),\n        (\"-0x1.8#2\", 37600),\n        (\"-0x0.8#2\", 18934),\n        (\"-0x0.c#2\", 18834),\n    ];\n    let sample_median = (\"-1.0\", None);\n    let sample_median_hex = (\"-0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.693371936934735),\n        standard_deviation: NiceFloat(1671.7840625385452),\n        skewness: NiceFloat(-718.2460436055444),\n        excess_kurtosis: NiceFloat(578520.0792964109),\n    };\n    random_non_positive_finite_floats_helper(\n        1,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64, zero probability 1/10\n    let values = &[\n        \"-8.28861615548880710123228230074063493724223027547309594725606129258466731212769395352521\\\n        9033439102\",\n        \"-1.0\",\n        \"-0.6651592248\",\n        \"-0.0\",\n        \"-4.2345242873846765390825841\",\n        \"-2.38320785690539951782446111823006788535\",\n        \"-1.036853813\",\n        \"-2.4027026671793265640566992824\",\n        \"-0.52666405862440172\",\n        \"-0.5366\",\n        \"-3.42175\",\n        \"-61.701080114490962438\",\n        \"-0.8336708437\",\n        \"-0.0\",\n        \"-1.0\",\n        \"-2.5\",\n        \"-0.658027364385\",\n        \"-0.0\",\n        \"-1.246\",\n        \"-0.14\",\n    ];\n    let values_hex = &[\n        \"-0x8.49e2bf94ebf30cb80717aab089ffe81a4240bd550c84a499a4753e306f26fd3913222c258d89033b\\\n        #324\",\n        \"-0x1.0#1\",\n        \"-0x0.aa47dffd#32\",\n        \"-0x0.0\",\n        \"-0x4.3c09c8a06f55060972e84#86\",\n        \"-0x2.6219e8fcfa9bb9ef41add9535f62860#125\",\n        \"-0x1.096f406#28\",\n        \"-0x2.671785a18c13ffbbe8b27f4#93\",\n        \"-0x0.86d374abc53b0a#55\",\n        \"-0x0.896#12\",\n        \"-0x3.6bf8#16\",\n        \"-0x3d.b379fc839d57b1c#65\",\n        \"-0x0.d56b73d18#33\",\n        \"-0x0.0\",\n        \"-0x1.0#2\",\n        \"-0x2.8#4\",\n        \"-0x0.a8747b39e8#37\",\n        \"-0x0.0\",\n        \"-0x1.3f#9\",\n        \"-0x0.24#4\",\n    ];\n    let common_values = &[\n        (\"-0.0\", 100224),\n        (\"-1.0\", 4643),\n        (\"-2.0\", 2373),\n        (\"-0.5\", 2353),\n        (\"-1.5\", 2327),\n        (\"-1.0\", 2294),\n        (\"-0.5\", 1219),\n        (\"-4.0\", 1204),\n        (\"-2.0\", 1195),\n        (\"-0.8\", 1191),\n    ];\n    let common_values_hex = &[\n        (\"-0x0.0\", 100224),\n        (\"-0x1.0#1\", 4643),\n        (\"-0x2.0#1\", 2373),\n        (\"-0x0.8#1\", 2353),\n        (\"-0x1.8#2\", 2327),\n        (\"-0x1.0#2\", 2294),\n        (\"-0x0.8#2\", 1219),\n        (\"-0x4.0#1\", 1204),\n        (\"-0x2.0#2\", 1195),\n        (\"-0x0.c#2\", 1191),\n    ];\n    let sample_median = (\n        \"-1.31268190290298901432879852014280461789620659172002407\",\n        Some(\"-1.31267178118571998379\"),\n    );\n    let sample_median_hex = (\n        \"-0x1.500bebd304f66efb8d7a481eef659ad171581e14dea8#175\",\n        Some(\"-0x1.500b42029321dc7ec#67\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-10.510498034617717),\n        standard_deviation: NiceFloat(1688.742389206287),\n        skewness: NiceFloat(-594.3533044311691),\n        excess_kurtosis: NiceFloat(387838.0226770939),\n    };\n    random_non_positive_finite_floats_helper(\n        1,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2, zero probability 1/10\n    let values = &[\n        \"-1.0e9\", \"-2.0e-6\", \"-24.0\", \"-0.0\", \"-5.0e-7\", \"-0.06\", \"-8.0e22\", \"-7.0e19\", \"-0.05\",\n        \"-6.4e7\", \"-2.0e38\", \"-7.0e-9\", \"-2.0e15\", \"-0.0\", \"-3.0e11\", \"-1.0e-8\", \"-6.0e14\", \"-0.0\",\n        \"-0.05\", \"-2.0e-34\",\n    ];\n    let values_hex = &[\n        \"-0x4.0E+7#1\",\n        \"-0x0.00002#1\",\n        \"-0x18.0#2\",\n        \"-0x0.0\",\n        \"-0x8.0E-6#1\",\n        \"-0x0.10#3\",\n        \"-0x1.0E+19#1\",\n        \"-0x4.0E+16#1\",\n        \"-0x0.0c#2\",\n        \"-0x3.d08E+6#12\",\n        \"-0x8.0E+31#1\",\n        \"-0x2.0E-7#1\",\n        \"-0x8.0E+12#1\",\n        \"-0x0.0\",\n        \"-0x4.0E+9#1\",\n        \"-0x4.0E-7#2\",\n        \"-0x2.0E+12#1\",\n        \"-0x0.0\",\n        \"-0x0.0c#2\",\n        \"-0x1.0E-28#1\",\n    ];\n    let common_values = &[\n        (\"-0.0\", 100224),\n        (\"-1.0\", 3531),\n        (\"-2.0\", 3503),\n        (\"-4.0\", 3399),\n        (\"-0.5\", 3381),\n        (\"-0.1\", 3375),\n        (\"-0.2\", 3369),\n        (\"-0.06\", 3330),\n        (\"-8.0\", 3283),\n        (\"-2.0e1\", 3250),\n    ];\n    let common_values_hex = &[\n        (\"-0x0.0\", 100224),\n        (\"-0x1.0#1\", 3531),\n        (\"-0x2.0#1\", 3503),\n        (\"-0x4.0#1\", 3399),\n        (\"-0x0.8#1\", 3381),\n        (\"-0x0.2#1\", 3375),\n        (\"-0x0.4#1\", 3369),\n        (\"-0x0.1#1\", 3330),\n        (\"-0x8.0#1\", 3283),\n        (\"-0x1.0E+1#1\", 3250),\n    ];\n    let sample_median = (\"-0.0059\", Some(\"-0.006\"));\n    let sample_median_hex = (\"-0x0.018#4\", Some(\"-0x0.018#3\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.237414368630999e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_non_positive_finite_floats_helper(\n        64,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64, zero probability 1/10\n    let values = &[\n        \"-1112479228.65380241855766293066002073855407473322681306316671638091945729426964592832149\\\n        24893705523\",\n        \"-2.0e-6\",\n        \"-21.285095192\",\n        \"-0.0\",\n        \"-5.0479463188465553988010694e-7\",\n        \"-0.074475245528293734932014409944689621417\",\n        \"-7.83424591e22\",\n        \"-88644082373352750967.8179473\",\n        \"-0.032916503664025107\",\n        \"-3.601e7\",\n        \"-2.91091e38\",\n        \"-1.43659021971959067597e-8\",\n        \"-3.7545197012e15\",\n        \"-0.0\",\n        \"-3.0e11\",\n        \"-1.9e-8\",\n        \"-7.4087294826e14\",\n        \"-0.0\",\n        \"-0.0389\",\n        \"-2.2e-34\",\n    ];\n    let values_hex = &[\n        \"-0x424f15fc.a75f9865c038bd55844fff40d21205eaa8642524cd23a9f1837937e9c89911612c6c4819d8\\\n        #324\",\n        \"-0x0.00002#1\",\n        \"-0x15.48fbffa#32\",\n        \"-0x0.0\",\n        \"-0x8.78139140deaa0c12e5d08E-6#86\",\n        \"-0x0.1310cf47e7d4ddcf7a0d6eca9afb1430#125\",\n        \"-0x1.096f406E+19#28\",\n        \"-0x4ce2f0b431827ff77.d164fe8#93\",\n        \"-0x0.086d374abc53b0a#55\",\n        \"-0x2.258E+6#12\",\n        \"-0xd.afeE+31#16\",\n        \"-0x3.db379fc839d57b1cE-7#65\",\n        \"-0xd.56b73d18E+12#33\",\n        \"-0x0.0\",\n        \"-0x4.0E+9#2\",\n        \"-0x5.0E-7#4\",\n        \"-0x2.a1d1ece7aE+12#37\",\n        \"-0x0.0\",\n        \"-0x0.09f8#9\",\n        \"-0x1.2E-28#4\",\n    ];\n    let common_values = &[\n        (\"-0.0\", 100224),\n        (\"-8.0\", 129),\n        (\"-4.0\", 120),\n        (\"-2.0\", 107),\n        (\"-0.06\", 107),\n        (\"-1.0e3\", 106),\n        (\"-3.0e1\", 105),\n        (\"-4.0e3\", 104),\n        (\"-0.5\", 102),\n        (\"-1.0e2\", 102),\n    ];\n    let common_values_hex = &[\n        (\"-0x0.0\", 100224),\n        (\"-0x8.0#1\", 129),\n        (\"-0x4.0#1\", 120),\n        (\"-0x2.0#1\", 107),\n        (\"-0x0.1#1\", 107),\n        (\"-0x4.0E+2#1\", 106),\n        (\"-0x2.0E+1#1\", 105),\n        (\"-0x1.0E+3#1\", 104),\n        (\"-0x0.8#1\", 102),\n        (\"-0x8.0E+1#1\", 102),\n    ];\n    let sample_median = (\"-0.0074479832945\", Some(\"-0.007447481\"));\n    let sample_median_hex = (\"-0x0.01e81c6cabc#35\", Some(\"-0x0.01e8140#21\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.6946902524964283e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_non_positive_finite_floats_helper(\n        64,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_non_positive_finite_floats_fail_1() {\n    random_non_positive_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_positive_finite_floats_fail_2() {\n    random_non_positive_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_positive_finite_floats_fail_3() {\n    random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_positive_finite_floats_fail_4() {\n    random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn random_non_positive_finite_floats_fail_5() {\n    random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_non_positive_finite_floats_fail_6() {\n    random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_nonzero_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_nonzero_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn random_nonzero_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_nonzero_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_nonzero_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"-8.0\", \"-1.0\", \"-0.8\", \"4.0\", \"-2.0\", \"1.0\", \"-2.0\", \"-0.8\", \"-0.9536\", \"2.0\", \"3.0e1\",\n        \"0.5\", \"-1.0\", \"-2.0\", \"0.5\", \"-1.5\", \"-0.1\", \"-1.0\", \"-0.047\", \"-1.0\",\n    ];\n    let values_hex = &[\n        \"-0x8.0#1\",\n        \"-0x1.0#1\",\n        \"-0x0.c#2\",\n        \"0x4.0#1\",\n        \"-0x2.0#3\",\n        \"0x1.0#1\",\n        \"-0x2.0#1\",\n        \"-0x0.c#2\",\n        \"-0x0.f42#12\",\n        \"0x2.0#1\",\n        \"0x2.0E+1#1\",\n        \"0x0.8#1\",\n        \"-0x1.0#1\",\n        \"-0x2.0#2\",\n        \"0x0.8#1\",\n        \"-0x1.8#2\",\n        \"-0x0.2#1\",\n        \"-0x1.0#1\",\n        \"-0x0.0c#3\",\n        \"-0x1.0#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 83167),\n        (\"-1.0\", 83060),\n        (\"2.0\", 41731),\n        (\"-2.0\", 41688),\n        (\"0.5\", 41643),\n        (\"-0.5\", 41534),\n        (\"-4.0\", 21185),\n        (\"1.0\", 21166),\n        (\"0.2\", 21077),\n        (\"-1.0\", 20914),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 83167),\n        (\"-0x1.0#1\", 83060),\n        (\"0x2.0#1\", 41731),\n        (\"-0x2.0#1\", 41688),\n        (\"0x0.8#1\", 41643),\n        (\"-0x0.8#1\", 41534),\n        (\"-0x4.0#1\", 21185),\n        (\"0x1.0#2\", 21166),\n        (\"0x0.4#1\", 21077),\n        (\"-0x1.0#2\", 20914),\n    ];\n    let sample_median = (\"0.002\", None);\n    let sample_median_hex = (\"0x0.008#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.137441392805658),\n        standard_deviation: NiceFloat(1753.4002861490633),\n        skewness: NiceFloat(-540.308156545252),\n        excess_kurtosis: NiceFloat(486100.3517515351),\n    };\n    random_nonzero_finite_floats_helper(\n        1,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"-8.28861615548880710123228230074063493724223027547309594725606129258466731212769395352521\\\n        9033439102\",\n        \"-1.0\",\n        \"-0.6651592248\",\n        \"4.2345242873846765390825841\",\n        \"-2.38320785690539951782446111823006788535\",\n        \"1.036853813\",\n        \"-2.4027026671793265640566992824\",\n        \"-0.52666405862440172\",\n        \"-0.5366\",\n        \"3.42175\",\n        \"61.701080114490962438\",\n        \"0.8336708437\",\n        \"-1.0\",\n        \"-2.5\",\n        \"0.658027364385\",\n        \"-1.246\",\n        \"-0.14\",\n        \"-1.245722352956368383395858819\",\n        \"-0.03962809021\",\n        \"-1.0011\",\n    ];\n    let values_hex = &[\n        \"-0x8.49e2bf94ebf30cb80717aab089ffe81a4240bd550c84a499a4753e306f26fd3913222c258d89033b\\\n        #324\",\n        \"-0x1.0#1\",\n        \"-0x0.aa47dffd#32\",\n        \"0x4.3c09c8a06f55060972e84#86\",\n        \"-0x2.6219e8fcfa9bb9ef41add9535f62860#125\",\n        \"0x1.096f406#28\",\n        \"-0x2.671785a18c13ffbbe8b27f4#93\",\n        \"-0x0.86d374abc53b0a#55\",\n        \"-0x0.896#12\",\n        \"0x3.6bf8#16\",\n        \"0x3d.b379fc839d57b1c#65\",\n        \"0x0.d56b73d18#33\",\n        \"-0x1.0#2\",\n        \"-0x2.8#4\",\n        \"0x0.a8747b39e8#37\",\n        \"-0x1.3f#9\",\n        \"-0x0.24#4\",\n        \"-0x1.3ee7a8fdd801625ca3c1028#90\",\n        \"-0x0.0a2511077#32\",\n        \"-0x1.0048#14\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 2594),\n        (\"1.0\", 2582),\n        (\"2.0\", 1322),\n        (\"0.5\", 1316),\n        (\"-2.0\", 1310),\n        (\"-1.5\", 1295),\n        (\"1.5\", 1288),\n        (\"1.0\", 1286),\n        (\"-0.5\", 1282),\n        (\"-1.0\", 1256),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 2594),\n        (\"0x1.0#1\", 2582),\n        (\"0x2.0#1\", 1322),\n        (\"0x0.8#1\", 1316),\n        (\"-0x2.0#1\", 1310),\n        (\"-0x1.8#2\", 1295),\n        (\"0x1.8#2\", 1288),\n        (\"0x1.0#2\", 1286),\n        (\"-0x0.8#1\", 1282),\n        (\"-0x1.0#2\", 1256),\n    ];\n    let sample_median = (\n        \"0.0027890310577504986877\",\n        Some(\"0.0027891362634973129863915401\"),\n    );\n    let sample_median_hex = (\n        \"0x0.00b6c82d2e399e2de0#63\",\n        Some(\"0x0.00b6c9f1092ac094b9e5264#84\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.6942588764777254),\n        standard_deviation: NiceFloat(1892.6524949864393),\n        skewness: NiceFloat(-231.427091034788),\n        excess_kurtosis: NiceFloat(286498.2528287583),\n    };\n    random_nonzero_finite_floats_helper(\n        1,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"-1.0e9\", \"-2.0e-6\", \"-24.0\", \"5.0e-7\", \"-0.06\", \"8.0e22\", \"-7.0e19\", \"-0.05\", \"-6.4e7\",\n        \"2.0e38\", \"7.0e-9\", \"2.0e15\", \"-3.0e11\", \"-1.0e-8\", \"6.0e14\", \"-0.05\", \"-2.0e-34\",\n        \"-6.0e14\", \"-3.8e30\", \"-1.6e57\",\n    ];\n    let values_hex = &[\n        \"-0x4.0E+7#1\",\n        \"-0x0.00002#1\",\n        \"-0x18.0#2\",\n        \"0x8.0E-6#1\",\n        \"-0x0.10#3\",\n        \"0x1.0E+19#1\",\n        \"-0x4.0E+16#1\",\n        \"-0x0.0c#2\",\n        \"-0x3.d08E+6#12\",\n        \"0x8.0E+31#1\",\n        \"0x2.0E-7#1\",\n        \"0x8.0E+12#1\",\n        \"-0x4.0E+9#1\",\n        \"-0x4.0E-7#2\",\n        \"0x2.0E+12#1\",\n        \"-0x0.0c#2\",\n        \"-0x1.0E-28#1\",\n        \"-0x2.0E+12#1\",\n        \"-0x3.0E+25#3\",\n        \"-0x4.0E+47#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 2018),\n        (\"-2.0\", 2004),\n        (\"-1.0\", 1938),\n        (\"4.0\", 1933),\n        (\"0.5\", 1901),\n        (\"0.1\", 1900),\n        (\"-0.2\", 1883),\n        (\"-4.0\", 1875),\n        (\"0.2\", 1874),\n        (\"2.0\", 1873),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 2018),\n        (\"-0x2.0#1\", 2004),\n        (\"-0x1.0#1\", 1938),\n        (\"0x4.0#1\", 1933),\n        (\"0x0.8#1\", 1901),\n        (\"0x0.2#1\", 1900),\n        (\"-0x0.4#1\", 1883),\n        (\"-0x4.0#1\", 1875),\n        (\"0x0.4#1\", 1874),\n        (\"0x2.0#1\", 1873),\n    ];\n    let sample_median = (\"1.0e-122\", Some(\"1.0e-122\"));\n    let sample_median_hex = (\"0x8.0E-102#2\", Some(\"0x8.0E-102#3\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.2374143686309846e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_finite_floats_helper(\n        64,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"-1112479228.65380241855766293066002073855407473322681306316671638091945729426964592832149\\\n        24893705523\",\n        \"-2.0e-6\",\n        \"-21.285095192\",\n        \"5.0479463188465553988010694e-7\",\n        \"-0.074475245528293734932014409944689621417\",\n        \"7.83424591e22\",\n        \"-88644082373352750967.8179473\",\n        \"-0.032916503664025107\",\n        \"-3.601e7\",\n        \"2.91091e38\",\n        \"1.43659021971959067597e-8\",\n        \"3.7545197012e15\",\n        \"-3.0e11\",\n        \"-1.9e-8\",\n        \"7.4087294826e14\",\n        \"-0.0389\",\n        \"-2.2e-34\",\n        \"-701279340572674.768452138179\",\n        \"-3.215012629e30\",\n        \"-1.571e57\",\n    ];\n    let values_hex = &[\n        \"-0x424f15fc.a75f9865c038bd55844fff40d21205eaa8642524cd23a9f1837937e9c89911612c6c4819d8\\\n        #324\",\n        \"-0x0.00002#1\",\n        \"-0x15.48fbffa#32\",\n        \"0x8.78139140deaa0c12e5d08E-6#86\",\n        \"-0x0.1310cf47e7d4ddcf7a0d6eca9afb1430#125\",\n        \"0x1.096f406E+19#28\",\n        \"-0x4ce2f0b431827ff77.d164fe8#93\",\n        \"-0x0.086d374abc53b0a#55\",\n        \"-0x2.258E+6#12\",\n        \"0xd.afeE+31#16\",\n        \"0x3.db379fc839d57b1cE-7#65\",\n        \"0xd.56b73d18E+12#33\",\n        \"-0x4.0E+9#2\",\n        \"-0x5.0E-7#4\",\n        \"0x2.a1d1ece7aE+12#37\",\n        \"-0x0.09f8#9\",\n        \"-0x1.2E-28#4\",\n        \"-0x27dcf51fbb002.c4b9478205#90\",\n        \"-0x2.894441dcE+25#32\",\n        \"-0x4.012E+47#14\",\n    ];\n    let common_values = &[\n        (\"-8.0\", 73),\n        (\"1.0e3\", 70),\n        (\"4.0\", 69),\n        (\"2.0\", 68),\n        (\"8.0\", 68),\n        (\"-1.0e2\", 67),\n        (\"-0.02\", 65),\n        (\"-0.5\", 64),\n        (\"2.0e1\", 64),\n        (\"-4.0\", 62),\n    ];\n    let common_values_hex = &[\n        (\"-0x8.0#1\", 73),\n        (\"0x4.0E+2#1\", 70),\n        (\"0x4.0#1\", 69),\n        (\"0x2.0#1\", 68),\n        (\"0x8.0#1\", 68),\n        (\"-0x8.0E+1#1\", 67),\n        (\"-0x0.04#1\", 65),\n        (\"-0x0.8#1\", 64),\n        (\"0x1.0E+1#1\", 64),\n        (\"-0x4.0#1\", 62),\n    ];\n    let sample_median = (\n        \"2.22082266973856198260258239259022e-122\",\n        Some(\"2.35472681582314e-122\"),\n    );\n    let sample_median_hex = (\n        \"0xe.ae4e347efb6723ba8a9c199b48E-102#105\",\n        Some(\"0xf.90e97334e78E-102#45\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.6946902524964396e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_finite_floats_helper(\n        64,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_finite_floats_fail_1() {\n    random_nonzero_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_finite_floats_fail_2() {\n    random_nonzero_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_finite_floats_fail_3() {\n    random_nonzero_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_finite_floats_fail_4() {\n    random_nonzero_finite_floats(EXAMPLE_SEED, 1, 1, 1, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_positive_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_positive_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn random_positive_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_positive_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"1.5\", \"1.0\", \"2.0\", \"1.0\", \"1.0\", \"2.0\", \"2.0\", \"1.2\", \"2.0\", \"1.0\", \"2.0\", \"2.0\", \"4.0\",\n        \"1.0\", \"1.8\", \"2.5\", \"0.1\", \"1.0\", \"0.2\", \"1.2\",\n    ];\n    let values_hex = &[\n        \"0x1.8#2\", \"0x1.0#1\", \"0x2.0#2\", \"0x1.0#2\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x1.4#3\",\n        \"0x2.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x4.0#1\", \"0x1.0#1\", \"0x1.c#3\", \"0x2.8#4\",\n        \"0x0.2#1\", \"0x1.0#1\", \"0x0.4#1\", \"0x1.4#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 166114),\n        (\"0.5\", 83464),\n        (\"2.0\", 83434),\n        (\"1.5\", 42025),\n        (\"0.2\", 41531),\n        (\"1.0\", 41506),\n        (\"4.0\", 41483),\n        (\"3.0\", 21005),\n        (\"2.0\", 20892),\n        (\"0.1\", 20888),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 166114),\n        (\"0x0.8#1\", 83464),\n        (\"0x2.0#1\", 83434),\n        (\"0x1.8#2\", 42025),\n        (\"0x0.4#1\", 41531),\n        (\"0x1.0#2\", 41506),\n        (\"0x4.0#1\", 41483),\n        (\"0x3.0#2\", 21005),\n        (\"0x2.0#2\", 20892),\n        (\"0x0.2#1\", 20888),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.292847587427611),\n        standard_deviation: NiceFloat(416.97010060005687),\n        skewness: NiceFloat(334.72226371600976),\n        excess_kurtosis: NiceFloat(139648.08254659182),\n    };\n    random_positive_finite_floats_helper(\n        1,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"1.8\",\n        \"1.3850071337780625300836\",\n        \"3.21176241813\",\n        \"1.981013494834061409257349\",\n        \"1.665272\",\n        \"3.0477509378551710980549069671536911164880571509\",\n        \"3.86646429082638580413691355062141611967080168780483321308586\",\n        \"1.1383718\",\n        \"3.005438259332186398250782844\",\n        \"1.31402772840010613\",\n        \"2.2954821356993\",\n        \"3.341070237\",\n        \"6.42834377982969296\",\n        \"1.055708800484474\",\n        \"1.09154149257425903017951075071293557661092806\",\n        \"2.750421277483313\",\n        \"0.2219335998\",\n        \"1.1563594283786540769774526007723931560664\",\n        \"0.39596234107597\",\n        \"1.3496675\",\n    ];\n    let values_hex = &[\n        \"0x1.c#3\",\n        \"0x1.628fd3d84db091d430#71\",\n        \"0x3.36360fd46#38\",\n        \"0x1.fb23b34d3f38af725038#79\",\n        \"0x1.aa4f4#19\",\n        \"0x3.0c3967cc70f8444c90df6c12283a15fa4637da#153\",\n        \"0x3.ddd09a90404c02ee3c715fa17bf84c143354d47adb8aff3c0#195\",\n        \"0x1.236c56#24\",\n        \"0x3.016466d9fa99ac91c2dfb4#89\",\n        \"0x1.50641f07840015#57\",\n        \"0x2.4ba4b79d6178#48\",\n        \"0x3.57506108#31\",\n        \"0x6.6da7f01dd04530#57\",\n        \"0x1.0e42ee942e22#48\",\n        \"0x1.176f4364d55e3feb51571e25ef39e528b86a#145\",\n        \"0x2.c01b9bdd036c4#54\",\n        \"0x0.38d0a3f10#31\",\n        \"0x1.28072be74ebd242348b5852a9e4a3c62e#132\",\n        \"0x0.655dc9b95e7#43\",\n        \"0x1.5983d0#24\",\n    ];\n    let common_values = &[\n        (\"1.0\", 5069),\n        (\"1.0\", 2626),\n        (\"0.5\", 2623),\n        (\"2.0\", 2623),\n        (\"1.5\", 2488),\n        (\"2.0\", 1309),\n        (\"0.2\", 1301),\n        (\"4.0\", 1299),\n        (\"1.2\", 1293),\n        (\"0.8\", 1283),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 5069),\n        (\"0x1.0#2\", 2626),\n        (\"0x0.8#1\", 2623),\n        (\"0x2.0#1\", 2623),\n        (\"0x1.8#2\", 2488),\n        (\"0x2.0#2\", 1309),\n        (\"0x0.4#1\", 1301),\n        (\"0x4.0#1\", 1299),\n        (\"0x1.4#3\", 1293),\n        (\"0x0.c#2\", 1283),\n    ];\n    let sample_median = (\n        \"1.492046225515012964994532213857812720544842101177086840260174\",\n        Some(\"1.492048772960956\"),\n    );\n    let sample_median_hex = (\n        \"0x1.7df6bdceb50c76e2fdee90d7296fa9b4a2cc3ae315ce8cf010#199\",\n        Some(\"0x1.7df6e88be77c#49\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.138627718915657),\n        standard_deviation: NiceFloat(468.606797626186),\n        skewness: NiceFloat(309.74563573271297),\n        excess_kurtosis: NiceFloat(127224.11304735676),\n    };\n    random_positive_finite_floats_helper(\n        1,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"3.0e-37\", \"8.0e-34\", \"4.0e-6\", \"3.0e-45\", \"2.0e15\", \"5.0e-10\", \"2.0e4\", \"0.08\", \"0.0001\",\n        \"1.0e14\", \"2.0e34\", \"9.0e-13\", \"0.0001\", \"9.0e9\", \"2.3e33\", \"0.16\", \"0.00003\", \"5.0e18\",\n        \"0.06\", \"7.0e8\",\n    ];\n    let values_hex = &[\n        \"0x6.0E-31#2\",\n        \"0x4.0E-28#1\",\n        \"0x0.00004#2\",\n        \"0x1.0E-37#2\",\n        \"0x8.0E+12#1\",\n        \"0x2.0E-8#1\",\n        \"0x4.0E+3#1\",\n        \"0x0.14#3\",\n        \"0x0.0008#1\",\n        \"0x8.0E+11#1\",\n        \"0x4.0E+28#1\",\n        \"0x1.0E-10#1\",\n        \"0x0.0008#1\",\n        \"0x2.0E+8#1\",\n        \"0x7.0E+27#3\",\n        \"0x0.28#4\",\n        \"0x0.0002#1\",\n        \"0x4.0E+15#1\",\n        \"0x0.1#1\",\n        \"0x2.8E+7#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 3831),\n        (\"0.2\", 3830),\n        (\"0.5\", 3826),\n        (\"2.0\", 3753),\n        (\"4.0\", 3716),\n        (\"8.0\", 3653),\n        (\"0.1\", 3639),\n        (\"0.06\", 3637),\n        (\"3.0e1\", 3632),\n        (\"2.0e1\", 3617),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 3831),\n        (\"0x0.4#1\", 3830),\n        (\"0x0.8#1\", 3826),\n        (\"0x2.0#1\", 3753),\n        (\"0x4.0#1\", 3716),\n        (\"0x8.0#1\", 3653),\n        (\"0x0.2#1\", 3639),\n        (\"0x0.1#1\", 3637),\n        (\"0x2.0E+1#1\", 3632),\n        (\"0x1.0E+1#1\", 3617),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.9680504915704222e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_finite_floats_helper(\n        64,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"3.3e-37\",\n        \"1.066970684853243558372e-33\",\n        \"6.12595065713e-6\",\n        \"5.55198233623541837705276e-45\",\n        \"3.74986e15\",\n        \"7.096098125575043023691761696603361322749539164e-10\",\n        \"31674.0754704497525074895958066906408523432074264971936815994\",\n        \"0.07114824\",\n        \"0.0001834373937580680174713612576\",\n        \"184932962124288.041\",\n        \"2.38376493640286e34\",\n        \"1.519342839e-12\",\n        \"0.000196177483515310454\",\n        \"9068469544.36041\",\n        \"1416901865713435510498832543218638.47378814837\",\n        \"0.17190132984270706\",\n        \"0.00005418300776\",\n        \"5332766608130525448.821004944540229640534\",\n        \"0.09899058526899\",\n        \"7.2459725e8\",\n    ];\n    let values_hex = &[\n        \"0x7.0E-31#3\",\n        \"0x5.8a3f4f6136c24750cE-28#71\",\n        \"0x0.000066c6c1fa8c#38\",\n        \"0x1.fb23b34d3f38af725038E-37#79\",\n        \"0xd.527aE+12#19\",\n        \"0x3.0c3967cc70f8444c90df6c12283a15fa4637daE-8#153\",\n        \"0x7bba.13520809805dc78e2bf42f7f0982866a9a8f5b715fe78#195\",\n        \"0x0.1236c56#24\",\n        \"0x0.000c05919b67ea66b2470b7ed0#89\",\n        \"0xa8320f83c200.0a8#57\",\n        \"0x4.97496f3ac2f0E+28#48\",\n        \"0x1.aba83084E-10#31\",\n        \"0x0.000cdb4fe03ba08a60#57\",\n        \"0x21c85dd28.5c44#48\",\n        \"0x45dbd0d935578ffad455c7897bce.794a2e1a8#145\",\n        \"0x0.2c01b9bdd036c4#54\",\n        \"0x0.00038d0a3f10#31\",\n        \"0x4a01caf9d3af4908.d22d614aa7928f18b8#132\",\n        \"0x0.1957726e579c#43\",\n        \"0x2.b307a0E+7#24\",\n    ];\n    let common_values = &[\n        (\"2.0\", 130),\n        (\"2.0e1\", 129),\n        (\"0.2\", 122),\n        (\"3.0e1\", 117),\n        (\"0.004\", 116),\n        (\"1.0e5\", 114),\n        (\"0.02\", 112),\n        (\"0.00002\", 112),\n        (\"0.1\", 109),\n        (\"8.0\", 108),\n    ];\n    let common_values_hex = &[\n        (\"0x2.0#1\", 130),\n        (\"0x1.0E+1#1\", 129),\n        (\"0x0.4#1\", 122),\n        (\"0x2.0E+1#1\", 117),\n        (\"0x0.01#1\", 116),\n        (\"0x2.0E+4#1\", 114),\n        (\"0x0.04#1\", 112),\n        (\"0x0.0001#1\", 112),\n        (\"0x0.2#1\", 109),\n        (\"0x8.0#1\", 108),\n    ];\n    let sample_median = (\n        \"1.45263\",\n        Some(\"1.4527665236460671657422963814630798553398772791\"),\n    );\n    let sample_median_hex = (\n        \"0x1.73df8#18\",\n        Some(\"0x1.73e881c3c8916f41f0bcfa9b4958a2e850b2da0#154\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.9911135832684696e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_finite_floats_helper(\n        64,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_positive_finite_floats_fail_1() {\n    random_positive_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_finite_floats_fail_2() {\n    random_positive_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_finite_floats_fail_3() {\n    random_positive_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_finite_floats_fail_4() {\n    random_positive_finite_floats(EXAMPLE_SEED, 1, 1, 1, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/random_positive_floats_with_precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::random_positive_floats_with_precision;\nuse malachite_float::test_util::random::{\n    random_floats_helper_helper, random_floats_helper_helper_no_common_values,\n};\n\nfn random_positive_floats_with_precision_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    precision: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            precision,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    )\n}\n\nfn random_positive_floats_with_precision_helper_no_common_values(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    precision: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper_no_common_values(\n        random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            precision,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    )\n}\n\n#[test]\nfn test_random_positive_floats_with_precision() {\n    // mean |sci_exponent| 1, precision 1\n    let values = &[\n        \"1.0\", \"1.0\", \"2.0\", \"1.0\", \"1.0\", \"2.0\", \"2.0\", \"1.0\", \"2.0\", \"1.0\", \"2.0\", \"2.0\", \"4.0\",\n        \"1.0\", \"1.0\", \"2.0\", \"0.1\", \"1.0\", \"0.2\", \"1.0\",\n    ];\n    let values_hex = &[\n        \"0x1.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x1.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x1.0#1\",\n        \"0x2.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x4.0#1\", \"0x1.0#1\", \"0x1.0#1\", \"0x2.0#1\",\n        \"0x0.2#1\", \"0x1.0#1\", \"0x0.4#1\", \"0x1.0#1\",\n    ];\n    let common_values = &[\n        (\"1.0\", 333085),\n        (\"2.0\", 167041),\n        (\"0.5\", 166671),\n        (\"0.2\", 83200),\n        (\"4.0\", 83177),\n        (\"8.0\", 41643),\n        (\"0.1\", 41551),\n        (\"0.06\", 20981),\n        (\"2.0e1\", 20919),\n        (\"3.0e1\", 10411),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 333085),\n        (\"0x2.0#1\", 167041),\n        (\"0x0.8#1\", 166671),\n        (\"0x0.4#1\", 83200),\n        (\"0x4.0#1\", 83177),\n        (\"0x8.0#1\", 41643),\n        (\"0x0.2#1\", 41551),\n        (\"0x0.1#1\", 20981),\n        (\"0x1.0E+1#1\", 20919),\n        (\"0x2.0E+1#1\", 10411),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(6.111051015726221),\n        standard_deviation: NiceFloat(305.2547556508084),\n        skewness: NiceFloat(297.86495510456103),\n        excess_kurtosis: NiceFloat(112470.88988361698),\n    };\n    random_positive_floats_with_precision_helper(\n        1,\n        1,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, precision 10\n    let values = &[\n        \"1.918\", \"1.98\", \"3.305\", \"1.42\", \"1.557\", \"3.023\", \"2.5\", \"1.541\", \"3.621\", \"1.834\",\n        \"3.102\", \"2.617\", \"7.15\", \"1.43\", \"1.943\", \"3.727\", \"0.2124\", \"1.869\", \"0.272\", \"1.172\",\n    ];\n    let values_hex = &[\n        \"0x1.eb0#10\",\n        \"0x1.fb0#10\",\n        \"0x3.4e#10\",\n        \"0x1.6b8#10\",\n        \"0x1.8e8#10\",\n        \"0x3.06#10\",\n        \"0x2.80#10\",\n        \"0x1.8a8#10\",\n        \"0x3.9f#10\",\n        \"0x1.d58#10\",\n        \"0x3.1a#10\",\n        \"0x2.9e#10\",\n        \"0x7.26#10\",\n        \"0x1.6e0#10\",\n        \"0x1.f18#10\",\n        \"0x3.ba#10\",\n        \"0x0.366#10\",\n        \"0x1.de8#10\",\n        \"0x0.45a#10\",\n        \"0x1.2c0#10\",\n    ];\n    let common_values = &[\n        (\"1.381\", 721),\n        (\"1.869\", 717),\n        (\"1.084\", 711),\n        (\"1.033\", 710),\n        (\"1.635\", 707),\n        (\"1.059\", 706),\n        (\"1.469\", 706),\n        (\"1.252\", 705),\n        (\"1.205\", 702),\n        (\"1.047\", 700),\n    ];\n    let common_values_hex = &[\n        (\"0x1.618#10\", 721),\n        (\"0x1.de8#10\", 717),\n        (\"0x1.158#10\", 711),\n        (\"0x1.088#10\", 710),\n        (\"0x1.a28#10\", 707),\n        (\"0x1.0f0#10\", 706),\n        (\"0x1.780#10\", 706),\n        (\"0x1.408#10\", 705),\n        (\"0x1.348#10\", 702),\n        (\"0x1.0c0#10\", 700),\n    ];\n    let sample_median = (\"1.5\", None);\n    let sample_median_hex = (\"0x1.800#10\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.056696785111221),\n        standard_deviation: NiceFloat(431.29029073720193),\n        skewness: NiceFloat(278.5706756279952),\n        excess_kurtosis: NiceFloat(97797.38656215608),\n    };\n    random_positive_floats_with_precision_helper(\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, precision 64\n    let values = &[\n        \"1.740199402817679648\",\n        \"1.0192449215156261222\",\n        \"3.1130307619404870736\",\n        \"1.0471449172912252423\",\n        \"1.3840640877665362527\",\n        \"3.0460668755070546289\",\n        \"3.476526206271118552\",\n        \"1.8118954029598159672\",\n        \"3.728977157780790176\",\n        \"1.9336753518355031441\",\n        \"2.157307006970948965\",\n        \"3.4498871850383974534\",\n        \"6.9412040614053056114\",\n        \"1.7943152699644272746\",\n        \"1.2440394513671251233\",\n        \"2.6137809712053548931\",\n        \"0.2398662564271449353\",\n        \"1.6629773022545155586\",\n        \"0.25533214025794003077\",\n        \"1.900690880541109083\",\n    ];\n    let values_hex = &[\n        \"0x1.bd7db5439ee3dbac#64\",\n        \"0x1.04ed3c34861143ec#64\",\n        \"0x3.1cef9581f9f24d38#64\",\n        \"0x1.0c11b075f03d6dae#64\",\n        \"0x1.62520628867d223a#64\",\n        \"0x3.0bcb09ebbb50e418#64\",\n        \"0x3.79fd9f179f145a00#64\",\n        \"0x1.cfd8608b7c32de2a#64\",\n        \"0x3.ba9e3f3c33141e7c#64\",\n        \"0x1.ef05590d36fbcb56#64\",\n        \"0x2.284545a25f32dc68#64\",\n        \"0x3.732bce7aa1218278#64\",\n        \"0x6.f0f2bfd699213c98#64\",\n        \"0x1.cb583edb35eb99b8#64\",\n        \"0x1.3e795e968e3acfc6#64\",\n        \"0x2.9d20bfee3bef16e8#64\",\n        \"0x0.3d67dffec4bedc598#64\",\n        \"0x1.a9b8e1672c674f7a#64\",\n        \"0x0.415d727806899f168#64\",\n        \"0x1.e693ad73bac0ecb0#64\",\n    ];\n    let sample_median = (\"1.5021401700224458548\", Some(\"1.5021411966182242309\"));\n    let sample_median_hex = (\"0x1.808c42184118ca86#64\", Some(\"0x1.808c5351731799cc#64\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.06512816951906),\n        standard_deviation: NiceFloat(439.97218971420835),\n        skewness: NiceFloat(280.6616264514779),\n        excess_kurtosis: NiceFloat(99433.37467826756),\n    };\n    random_positive_floats_with_precision_helper_no_common_values(\n        1,\n        1,\n        64,\n        values,\n        values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, precision 1\n    let values = &[\n        \"2.0e-37\", \"8.0e-34\", \"4.0e-6\", \"3.0e-45\", \"2.0e15\", \"5.0e-10\", \"2.0e4\", \"0.06\", \"0.0001\",\n        \"1.0e14\", \"2.0e34\", \"9.0e-13\", \"0.0001\", \"9.0e9\", \"1.0e33\", \"0.1\", \"0.00003\", \"5.0e18\",\n        \"0.06\", \"5.0e8\",\n    ];\n    let values_hex = &[\n        \"0x4.0E-31#1\",\n        \"0x4.0E-28#1\",\n        \"0x0.00004#1\",\n        \"0x1.0E-37#1\",\n        \"0x8.0E+12#1\",\n        \"0x2.0E-8#1\",\n        \"0x4.0E+3#1\",\n        \"0x0.1#1\",\n        \"0x0.0008#1\",\n        \"0x8.0E+11#1\",\n        \"0x4.0E+28#1\",\n        \"0x1.0E-10#1\",\n        \"0x0.0008#1\",\n        \"0x2.0E+8#1\",\n        \"0x4.0E+27#1\",\n        \"0x0.2#1\",\n        \"0x0.0002#1\",\n        \"0x4.0E+15#1\",\n        \"0x0.1#1\",\n        \"0x2.0E+7#1\",\n    ];\n    let common_values = &[\n        (\"1.0\", 7698),\n        (\"0.2\", 7624),\n        (\"0.5\", 7597),\n        (\"2.0\", 7563),\n        (\"4.0\", 7402),\n        (\"8.0\", 7362),\n        (\"0.06\", 7323),\n        (\"0.1\", 7239),\n        (\"3.0e1\", 7225),\n        (\"2.0e1\", 7161),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 7698),\n        (\"0x0.4#1\", 7624),\n        (\"0x0.8#1\", 7597),\n        (\"0x2.0#1\", 7563),\n        (\"0x4.0#1\", 7402),\n        (\"0x8.0#1\", 7362),\n        (\"0x0.1#1\", 7323),\n        (\"0x0.2#1\", 7239),\n        (\"0x2.0E+1#1\", 7225),\n        (\"0x1.0E+1#1\", 7161),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.9680504915704222e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_floats_with_precision_helper(\n        64,\n        1,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, precision 10\n    let values = &[\n        \"3.607e-37\",\n        \"1.526e-33\",\n        \"6.303e-6\",\n        \"3.979e-45\",\n        \"3.505e15\",\n        \"7.04e-10\",\n        \"2.048e4\",\n        \"0.0963\",\n        \"0.000221\",\n        \"2.581e14\",\n        \"3.221e34\",\n        \"1.19e-12\",\n        \"0.0002182\",\n        \"1.228e10\",\n        \"2.523e33\",\n        \"0.2329\",\n        \"0.00005186\",\n        \"8.62e18\",\n        \"0.068\",\n        \"6.29e8\",\n    ];\n    let values_hex = &[\n        \"0x7.acE-31#10\",\n        \"0x7.ecE-28#10\",\n        \"0x0.000069c#10\",\n        \"0x1.6b8E-37#10\",\n        \"0xc.74E+12#10\",\n        \"0x3.06E-8#10\",\n        \"0x5.00E+3#10\",\n        \"0x0.18a8#10\",\n        \"0x0.000e7c#10\",\n        \"0xe.acE+11#10\",\n        \"0x6.34E+28#10\",\n        \"0x1.4f0E-10#10\",\n        \"0x0.000e4c#10\",\n        \"0x2.dcE+8#10\",\n        \"0x7.c6E+27#10\",\n        \"0x0.3ba#10\",\n        \"0x0.000366#10\",\n        \"0x7.7aE+15#10\",\n        \"0x0.1168#10\",\n        \"0x2.58E+7#10\",\n    ];\n    let common_values = &[\n        (\"0.001066\", 31),\n        (\"1.35\", 29),\n        (\"0.814\", 29),\n        (\"1.688\", 29),\n        (\"0.4429\", 29),\n        (\"0.569\", 28),\n        (\"2.883\", 28),\n        (\"496.0\", 28),\n        (\"0.02191\", 28),\n        (\"0.02954\", 28),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0045e#10\", 31),\n        (\"0x1.598#10\", 29),\n        (\"0x0.d08#10\", 29),\n        (\"0x1.b00#10\", 29),\n        (\"0x0.716#10\", 29),\n        (\"0x0.91c#10\", 28),\n        (\"0x2.e2#10\", 28),\n        (\"0x1f0.0#10\", 28),\n        (\"0x0.059c#10\", 28),\n        (\"0x0.0790#10\", 28),\n    ];\n    let sample_median = (\"1.471\", None);\n    let sample_median_hex = (\"0x1.788#10\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.163487411254837e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_floats_with_precision_helper(\n        64,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, precision 64\n    let values = &[\n        \"3.2729513077064011786e-37\",\n        \"7.8519772600462495573e-34\",\n        \"5.9376349676904431794e-6\",\n        \"2.9347251290514630352e-45\",\n        \"3116635254961129.0696\",\n        \"7.092177112370390978e-10\",\n        \"28479.702681773003178\",\n        \"0.113243462684988497952\",\n        \"0.00022759870347783143164\",\n        \"272140612311933.89714\",\n        \"2.2402756790380859597e34\",\n        \"1.5688270582533720942e-12\",\n        \"0.00021182873722550371128\",\n        \"15413050806.4212524556\",\n        \"1.6148555338067285629e33\",\n        \"0.16336131070033468082\",\n        \"0.000058561097760533431471\",\n        \"7669129173769245662.5\",\n        \"0.063833035064485007692\",\n        \"1020425646.4661882869\",\n    ];\n    let values_hex = &[\n        \"0x6.f5f6d50e7b8f6eb0E-31#64\",\n        \"0x4.13b4f0d218450fb0E-28#64\",\n        \"0x0.0000639df2b03f3e49a70#64\",\n        \"0x1.0c11b075f03d6daeE-37#64\",\n        \"0xb1290314433e9.11d#64\",\n        \"0x3.0bcb09ebbb50e418E-8#64\",\n        \"0x6f3f.b3e2f3e28b400#64\",\n        \"0x0.1cfd8608b7c32de2a#64\",\n        \"0x0.000eea78fcf0cc5079f#64\",\n        \"0xf782ac869b7d.e5ab#64\",\n        \"0x4.508a8b44be65b8d0E+28#64\",\n        \"0x1.b995e73d5090c13cE-10#64\",\n        \"0x0.000de1e57fad3242793#64\",\n        \"0x396b07db6.6bd73370#64\",\n        \"0x4.f9e57a5a38eb3f18E+27#64\",\n        \"0x0.29d20bfee3bef16e8#64\",\n        \"0x0.0003d67dffec4bedc598#64\",\n        \"0x6a6e3859cb19d3de.8#64\",\n        \"0x0.10575c9e01a267c5a#64\",\n        \"0x3cd275ae.77581d960#64\",\n    ];\n    let sample_median = (\"1.4744048330756642118\", Some(\"1.4745500033376170913\"));\n    let sample_median_hex = (\"0x1.7972985b1fd33b34#64\", Some(\"0x1.797c1be8a6d97f72#64\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.1785863803225345e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_floats_with_precision_helper_no_common_values(\n        64,\n        1,\n        64,\n        values,\n        values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_positive_floats_with_precision_fail_1() {\n    random_positive_floats_with_precision(EXAMPLE_SEED, 1, 0, 2);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_floats_with_precision_fail_2() {\n    random_positive_floats_with_precision(EXAMPLE_SEED, 0, 1, 2);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_floats_with_precision_fail_3() {\n    random_positive_floats_with_precision(EXAMPLE_SEED, 1, 1, 0);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn striped_random_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_zero_p_numerator: u64,\n    mean_zero_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_zero_p_numerator,\n            mean_zero_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    )\n}\n\n#[test]\nfn test_striped_random_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2, special probability 1/10\n    let values = &[\n        \"-3.0\", \"-1.2\", \"-2.0\", \"1.12\", \"-1.5\", \"1.0\", \"-2.0\", \"-0.25\", \"-1.0\", \"0.8\", \"0.0\",\n        \"0.262\", \"-1.2\", \"-0.59\", \"8.0\", \"-6.0\", \"-2.0\", \"-0.2\", \"-0.5\", \"-0.5\",\n    ];\n    let values_hex = &[\n        \"-0x3.0#3\",\n        \"-0x1.4#3\",\n        \"-0x2.0#2\",\n        \"0x1.2#5\",\n        \"-0x1.8#2\",\n        \"0x1.0#3\",\n        \"-0x2.0#1\",\n        \"-0x0.4#3\",\n        \"-0x1.0#1\",\n        \"0x0.c#2\",\n        \"0x0.0\",\n        \"0x0.430#9\",\n        \"-0x1.4#3\",\n        \"-0x0.98#5\",\n        \"0x8.0#1\",\n        \"-0x6.0#2\",\n        \"-0x2.0#2\",\n        \"-0x0.4#1\",\n        \"-0x0.8#2\",\n        \"-0x0.8#2\",\n    ];\n    let common_values = &[\n        (\"1.0\", 75012),\n        (\"-1.0\", 74560),\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"0.5\", 37822),\n        (\"2.0\", 37501),\n        (\"-0.5\", 37342),\n        (\"-2.0\", 37246),\n        (\"1.5\", 18939),\n        (\"-0.2\", 18908),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 75012),\n        (\"-0x1.0#1\", 74560),\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"0x0.8#1\", 37822),\n        (\"0x2.0#1\", 37501),\n        (\"-0x0.8#1\", 37342),\n        (\"-0x2.0#1\", 37246),\n        (\"0x1.8#2\", 18939),\n        (\"-0x0.4#1\", 18908),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.15755047615569168),\n        standard_deviation: NiceFloat(1365.3366507063222),\n        skewness: NiceFloat(296.763954633545),\n        excess_kurtosis: NiceFloat(413698.88164587686),\n    };\n    striped_random_finite_floats_helper(\n        1,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64, special probability 1/10\n    let values = &[\n        \"-2.00000000000727595760740716232528665608530686987\",\n        \"-1.99999999999999999\",\n        \"-2.0\",\n        \"1.99999955296516418457031249999999999999990816\",\n        \"-1.992248535\",\n        \"1.75\",\n        \"-2.0\",\n        \"-0.49999999953433871269226074\",\n        \"-1.9843754917383193414615082757658364469\",\n        \"0.99999999\",\n        \"0.0\",\n        \"0.25000005867354957271587\",\n        \"-1.99999999906867742711924491\",\n        \"-0.500000119209289544709704599191368\",\n        \"15.999985\",\n        \"-7.5\",\n        \"-3.9999999999999432\",\n        \"-0.49999999999999999998644747284\",\n        \"-0.5\",\n        \"-0.53118896484\",\n    ];\n    let values_hex = &[\n        \"-0x2.0000000007ffffffe00000000003dfffffffff0#158\",\n        \"-0x1.ffffffffffffff#57\",\n        \"-0x2.0#5\",\n        \"0x1.fffff87ffffffffffffffffffffffffff800#145\",\n        \"-0x1.fe03ffff8#34\",\n        \"0x1.c00000#22\",\n        \"-0x2.00000000000000#57\",\n        \"-0x0.7ffffffe00000000000000#84\",\n        \"-0x1.fc00083ffffffc000003f0000007ffc#123\",\n        \"0x0.ffffffc#26\",\n        \"0x0.0\",\n        \"0x0.400000fc003fffe0000#75\",\n        \"-0x1.fffffffc0000001ffffff#85\",\n        \"-0x0.800001ffffffff8fffefffffffe#107\",\n        \"0xf.ffff0#21\",\n        \"-0x7.8#4\",\n        \"-0x3.fffffffffff000#55\",\n        \"-0x0.7fffffffffffffffc0000000#94\",\n        \"-0x0.8000#13\",\n        \"-0x0.87fc00000#36\",\n    ];\n    let common_values = &[\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"1.0\", 2360),\n        (\"-1.0\", 2302),\n        (\"-1.0\", 1217),\n        (\"2.0\", 1209),\n        (\"1.0\", 1193),\n        (\"-0.5\", 1177),\n        (\"0.5\", 1158),\n        (\"-2.0\", 1158),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"0x1.0#1\", 2360),\n        (\"-0x1.0#1\", 2302),\n        (\"-0x1.0#2\", 1217),\n        (\"0x2.0#1\", 1209),\n        (\"0x1.0#2\", 1193),\n        (\"-0x0.8#1\", 1177),\n        (\"0x0.8#1\", 1158),\n        (\"-0x2.0#1\", 1158),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.10376383630935192),\n        standard_deviation: NiceFloat(1990.1410792105194),\n        skewness: NiceFloat(339.3581426358755),\n        excess_kurtosis: NiceFloat(463204.1189100673),\n    };\n    striped_random_finite_floats_helper(\n        1,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2, special probability 1/10\n    let values = &[\n        \"-5.0e13\", \"-2.8e-16\", \"-0.5\", \"3.0e8\", \"-1.4e-6\", \"0.25\", \"-1.0e-11\", \"-6.0e-17\",\n        \"-3.0e10\", \"1.7e-13\", \"0.0\", \"3.09e20\", \"-1.6e-29\", \"-4.7e28\", \"1.0e-8\", \"-2.5e-21\",\n        \"-9.0e9\", \"-1.0e43\", \"-0.1\", \"-0.1\",\n    ];\n    let values_hex = &[\n        \"-0x3.0E+11#3\",\n        \"-0x1.4E-13#3\",\n        \"-0x0.8#2\",\n        \"0x1.2E+7#5\",\n        \"-0x0.000018#2\",\n        \"0x0.4#3\",\n        \"-0x1.0E-9#1\",\n        \"-0x4.0E-14#3\",\n        \"-0x8.0E+8#1\",\n        \"0x3.0E-11#2\",\n        \"0x0.0\",\n        \"0x1.0cE+17#9\",\n        \"-0x1.4E-24#3\",\n        \"-0x9.8E+23#5\",\n        \"0x4.0E-7#1\",\n        \"-0xc.0E-18#2\",\n        \"-0x2.0E+8#2\",\n        \"-0x8.0E+35#1\",\n        \"-0x0.2#2\",\n        \"-0x0.2#2\",\n    ];\n    let common_values = &[\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"1.0\", 1791),\n        (\"0.5\", 1788),\n        (\"-1.0\", 1782),\n        (\"-4.0\", 1778),\n        (\"-0.5\", 1727),\n        (\"2.0\", 1695),\n        (\"4.0\", 1690),\n        (\"2.0e1\", 1689),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"0x1.0#1\", 1791),\n        (\"0x0.8#1\", 1788),\n        (\"-0x1.0#1\", 1782),\n        (\"-0x4.0#1\", 1778),\n        (\"-0x0.8#1\", 1727),\n        (\"0x2.0#1\", 1695),\n        (\"0x4.0#1\", 1690),\n        (\"0x1.0E+1#1\", 1689),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.789929787900277e243),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_finite_floats_helper(\n        64,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64, special probability 1/10\n    let values = &[\n        \"-35184372088959.9999998807907104492318790106824386\",\n        \"-4.44089209850062613e-16\",\n        \"-0.5\",\n        \"536870791.99999999999999999999999999999997535\",\n        \"-1.8999562598e-6\",\n        \"0.4375\",\n        \"-1.45519152283668518e-11\",\n        \"-1.11022302359118077473234707e-16\",\n        \"-68182622719.99999809265147909798093515\",\n        \"2.27373672e-13\",\n        \"0.0\",\n        \"295147974448853809152.0\",\n        \"-2.5243548955317434286847727e-29\",\n        \"-39614090701865134055025016831.9995\",\n        \"2.980229e-8\",\n        \"-3.2e-21\",\n        \"-17179869183.9997559\",\n        \"-2.2300745198530623140931255363e43\",\n        \"-0.125\",\n        \"-0.132797241211\",\n    ];\n    let values_hex = &[\n        \"-0x20000000007f.fffffe00000000003dfffffffff0#158\",\n        \"-0x1.ffffffffffffffE-13#57\",\n        \"-0x0.80#5\",\n        \"0x1fffff87.ffffffffffffffffffffffffff800#145\",\n        \"-0x0.00001fe03ffff8#34\",\n        \"0x0.700000#22\",\n        \"-0x1.00000000000000E-9#57\",\n        \"-0x7.ffffffe00000000000000E-14#84\",\n        \"-0xfe00041ff.ffffe000001f8000003ffe#123\",\n        \"0x3.ffffffE-11#26\",\n        \"0x0.0\",\n        \"0x1000003f000ffff800.00#75\",\n        \"-0x1.fffffffc0000001ffffffE-24#85\",\n        \"-0x800001ffffffff8fffefffff.ffe#107\",\n        \"0x7.ffff8E-7#21\",\n        \"-0xf.0E-18#4\",\n        \"-0x3ffffffff.fff000#55\",\n        \"-0xf.fffffffffffffff80000000E+35#94\",\n        \"-0x0.2000#13\",\n        \"-0x0.21ff000000#36\",\n    ];\n    let common_values = &[\n        (\"0.0\", 49991),\n        (\"-0.0\", 49908),\n        (\"-2.0e1\", 77),\n        (\"2.0\", 66),\n        (\"-2.0\", 61),\n        (\"-8.0\", 61),\n        (\"-3.0e1\", 59),\n        (\"-0.2\", 58),\n        (\"0.5\", 57),\n        (\"4.0e3\", 57),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 49991),\n        (\"-0x0.0\", 49908),\n        (\"-0x1.0E+1#1\", 77),\n        (\"0x2.0#1\", 66),\n        (\"-0x2.0#1\", 61),\n        (\"-0x8.0#1\", 61),\n        (\"-0x2.0E+1#1\", 59),\n        (\"-0x0.4#1\", 58),\n        (\"0x0.8#1\", 57),\n        (\"0x1.0E+3#1\", 57),\n    ];\n    let sample_median = (\"0.0\", None);\n    let sample_median_hex = (\"0x0.0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.7908037774743073e243),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_finite_floats_helper(\n        64,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_finite_floats_fail_1() {\n    striped_random_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_finite_floats_fail_2() {\n    striped_random_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_finite_floats_fail_3() {\n    striped_random_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_finite_floats_fail_4() {\n    striped_random_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_finite_floats_fail_5() {\n    striped_random_finite_floats(EXAMPLE_SEED, 1, 1, 2, 3, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_finite_floats_fail_6() {\n    striped_random_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_finite_floats_fail_7() {\n    striped_random_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1, 1, 0);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn striped_random_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    mean_special_p_numerator: u64,\n    mean_special_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            mean_special_p_numerator,\n            mean_special_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    )\n}\n\n#[test]\nfn test_striped_random_floats() {\n    // mean |sci_exponent| 1, mean precision 2, special probability 1/10\n    let values = &[\n        \"1.0\", \"0.2\", \"0.0\", \"NaN\", \"-0.2\", \"-1.0\", \"-1.0\", \"-1.5\", \"2.0\", \"0.2\", \"-1.0\", \"-0.2\",\n        \"-2.0\", \"Infinity\", \"-0.5\", \"-1.5\", \"-0.2\", \"NaN\", \"0.5\", \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0x1.0#1\", \"0x0.4#1\", \"0x0.0\", \"NaN\", \"-0x0.4#1\", \"-0x1.0#2\", \"-0x1.0#1\", \"-0x1.8#2\",\n        \"0x2.0#1\", \"0x0.4#1\", \"-0x1.0#3\", \"-0x0.4#2\", \"-0x2.0#1\", \"Infinity\", \"-0x0.8#1\",\n        \"-0x1.8#2\", \"-0x0.4#2\", \"NaN\", \"0x0.8#1\", \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 67626),\n        (\"1.0\", 67293),\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"-2.0\", 33918),\n        (\"2.0\", 33760),\n        (\"0.5\", 33658),\n        (\"Infinity\", 33640),\n        (\"-0.5\", 33629),\n        (\"NaN\", 33393),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 67626),\n        (\"0x1.0#1\", 67293),\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"-0x2.0#1\", 33918),\n        (\"0x2.0#1\", 33760),\n        (\"0x0.8#1\", 33658),\n        (\"Infinity\", 33640),\n        (\"-0x0.8#1\", 33629),\n        (\"NaN\", 33393),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_floats_helper(\n        1,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64, special probability 1/10\n    let values = &[\n        \"1.99999\",\n        \"0.4999999850988\",\n        \"0.0\",\n        \"NaN\",\n        \"-0.25000000005820766091346740721\",\n        \"-1.0\",\n        \"-1.99999999999999999999978989612421431724891016\",\n        \"-1.0000000000145519117589199127777235073172084570819473318104658\",\n        \"3.97\",\n        \"0.250057220575342853408074206771059911\",\n        \"-1.0000305175708774606\",\n        \"-0.49988\",\n        \"-2.999969497323036190378209298059007584907370931259\",\n        \"Infinity\",\n        \"-0.9999999999999996\",\n        \"-1.5\",\n        \"-0.25\",\n        \"NaN\",\n        \"0.531249999999943\",\n        \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0x1.ffff8#18\",\n        \"0x0.7fffffc0000#40\",\n        \"0x0.0\",\n        \"NaN\",\n        \"-0x0.400000003fffffffffffffff#95\",\n        \"-0x1.00000000#30\",\n        \"-0x1.ffffffffffffffffff01fffffc0001ffffff8#146\",\n        \"-0x1.000000000fffffc0000003ffffffffffffffffffffff80003ff#205\",\n        \"0x3.f8#7\",\n        \"0x0.4003c0007ff0000000003dfffffffe#118\",\n        \"-0x1.0001fffff807ffc0#62\",\n        \"-0x0.7ff8#14\",\n        \"-0x2.fffe003fffffffc000000000ffffff000001ffff#162\",\n        \"Infinity\",\n        \"-0x0.ffffffffffffe#51\",\n        \"-0x1.8#2\",\n        \"-0x0.400000#20\",\n        \"NaN\",\n        \"0x0.87fffffffff0#48\",\n        \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"1.0\", 2133),\n        (\"-1.0\", 2122),\n        (\"-2.0\", 1103),\n        (\"0.5\", 1094),\n        (\"2.0\", 1075),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0x1.0#1\", 2133),\n        (\"-0x1.0#1\", 2122),\n        (\"-0x2.0#1\", 1103),\n        (\"0x0.8#1\", 1094),\n        (\"0x2.0#1\", 1075),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_floats_helper(\n        1,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2, special probability 1/10\n    let values = &[\n        \"5.0e11\", \"7.0e122\", \"0.0\", \"NaN\", \"-2.0e25\", \"-2.0e21\", \"-2.0e-9\", \"-4.0e33\", \"4.0e-9\",\n        \"5.0e2\", \"-4.0e-16\", \"-7.0e-18\", \"-2.0e-19\", \"Infinity\", \"-2.0e50\", \"-1.6e12\", \"-2.0e-28\",\n        \"NaN\", \"0.02\", \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0x8.0E+9#1\",\n        \"0x1.0E+102#1\",\n        \"0x0.0\",\n        \"NaN\",\n        \"-0x1.0E+21#1\",\n        \"-0x8.0E+17#2\",\n        \"-0x8.0E-8#1\",\n        \"-0xc.0E+27#2\",\n        \"0x1.0E-7#1\",\n        \"0x2.0E+2#1\",\n        \"-0x2.0E-13#3\",\n        \"-0x8.0E-15#2\",\n        \"-0x4.0E-16#1\",\n        \"Infinity\",\n        \"-0x8.0E+41#1\",\n        \"-0x1.8E+10#2\",\n        \"-0x1.0E-23#2\",\n        \"NaN\",\n        \"0x0.04#1\",\n        \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0.5\", 1583),\n        (\"-1.0\", 1560),\n        (\"2.0\", 1542),\n        (\"-2.0\", 1523),\n        (\"1.0\", 1518),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0x0.8#1\", 1583),\n        (\"-0x1.0#1\", 1560),\n        (\"0x2.0#1\", 1542),\n        (\"-0x2.0#1\", 1523),\n        (\"0x1.0#1\", 1518),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_floats_helper(\n        64,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64, special probability 1/10\n    let values = &[\n        \"1.099507e12\",\n        \"1.322111898178e123\",\n        \"0.0\",\n        \"NaN\",\n        \"-19342813118337666422669311.999\",\n        \"-2.361183241e21\",\n        \"-3.72529029846191406249960865103493317449262395e-9\",\n        \"-2596148429305192737121006105133055.9999999999999999999864475761\",\n        \"7.4e-9\",\n        \"512.117187738302163779735975467130698\",\n        \"-4.441027623740001309e-16\",\n        \"-1.38744e-17\",\n        \"-3.252573446387882516080103398476707881754715262554e-19\",\n        \"Infinity\",\n        \"-3.74144419156711e50\",\n        \"-1.6e12\",\n        \"-2.019484e-28\",\n        \"NaN\",\n        \"0.0166015624999982\",\n        \"-0.0\",\n    ];\n    let values_hex = &[\n        \"0xf.fffcE+9#18\",\n        \"0x1.ffffff0000E+102#40\",\n        \"0x0.0\",\n        \"NaN\",\n        \"-0x100000000fffffffffffff.ffc#95\",\n        \"-0x8.0000000E+17#30\",\n        \"-0xf.fffffffffffffffff80fffffe0000ffffffcE-8#146\",\n        \"-0x8000000007ffffe0000001ffffff.ffffffffffffffffc0001ff8#205\",\n        \"0x1.fcE-7#7\",\n        \"0x200.1e0003ff8000000001effffffff#118\",\n        \"-0x2.0003fffff00fff8E-13#62\",\n        \"-0xf.ff0E-15#14\",\n        \"-0x5.fffc007fffffff8000000001fffffe000003fffeE-16#162\",\n        \"Infinity\",\n        \"-0xf.fffffffffffeE+41#51\",\n        \"-0x1.8E+10#2\",\n        \"-0x1.00000E-23#20\",\n        \"NaN\",\n        \"0x0.043fffffffff80#48\",\n        \"-0x0.0\",\n    ];\n    let common_values = &[\n        (\"0.0\", 45033),\n        (\"-0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0.00003\", 60),\n        (\"-0.5\", 57),\n        (\"-6.0e1\", 56),\n        (\"-5.0e2\", 55),\n        (\"8.0\", 54),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 45033),\n        (\"-0x0.0\", 44760),\n        (\"Infinity\", 33640),\n        (\"NaN\", 33393),\n        (\"-Infinity\", 33191),\n        (\"0x0.0002#1\", 60),\n        (\"-0x0.8#1\", 57),\n        (\"-0x4.0E+1#1\", 56),\n        (\"-0x2.0E+2#1\", 55),\n        (\"0x8.0#1\", 54),\n    ];\n    let sample_median = (\"NaN\", None);\n    let sample_median_hex = (\"NaN\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_floats_helper(\n        64,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_floats_fail_1() {\n    striped_random_floats(EXAMPLE_SEED, 1, 0, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_floats_fail_2() {\n    striped_random_floats(EXAMPLE_SEED, 0, 1, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_floats_fail_3() {\n    striped_random_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_floats_fail_4() {\n    striped_random_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_floats_fail_5() {\n    striped_random_floats(EXAMPLE_SEED, 1, 1, 2, 3, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_floats_fail_6() {\n    striped_random_floats(EXAMPLE_SEED, 1, 1, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_floats_fail_7() {\n    striped_random_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1, 1, 0);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_negative_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_negative_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn striped_random_negative_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_negative_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_negative_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"-1.5\", \"-1.0\", \"-2.0\", \"-1.0\", \"-1.0\", \"-2.0\", \"-2.0\", \"-1.8\", \"-2.0\", \"-1.0\", \"-2.0\",\n        \"-2.0\", \"-4.0\", \"-1.0\", \"-1.0\", \"-2.0\", \"-0.1\", \"-1.0\", \"-0.2\", \"-1.0\",\n    ];\n    let values_hex = &[\n        \"-0x1.8#2\", \"-0x1.0#1\", \"-0x2.0#2\", \"-0x1.0#2\", \"-0x1.0#1\", \"-0x2.0#1\", \"-0x2.0#1\",\n        \"-0x1.c#3\", \"-0x2.0#1\", \"-0x1.0#1\", \"-0x2.0#1\", \"-0x2.0#1\", \"-0x4.0#1\", \"-0x1.0#1\",\n        \"-0x1.0#3\", \"-0x2.0#4\", \"-0x0.2#1\", \"-0x1.0#1\", \"-0x0.4#1\", \"-0x1.0#3\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 166114),\n        (\"-0.5\", 83464),\n        (\"-2.0\", 83434),\n        (\"-1.0\", 42010),\n        (\"-0.2\", 41531),\n        (\"-1.5\", 41521),\n        (\"-4.0\", 41483),\n        (\"-3.0\", 21125),\n        (\"-0.1\", 20888),\n        (\"-8.0\", 20800),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 166114),\n        (\"-0x0.8#1\", 83464),\n        (\"-0x2.0#1\", 83434),\n        (\"-0x1.0#2\", 42010),\n        (\"-0x0.4#1\", 41531),\n        (\"-0x1.8#2\", 41521),\n        (\"-0x4.0#1\", 41483),\n        (\"-0x3.0#2\", 21125),\n        (\"-0x0.2#1\", 20888),\n        (\"-0x8.0#1\", 20800),\n    ];\n    let sample_median = (\"-1.0\", None);\n    let sample_median_hex = (\"-0x1.0#2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.102812885245132),\n        standard_deviation: NiceFloat(351.5541728670195),\n        skewness: NiceFloat(-274.1565025440714),\n        excess_kurtosis: NiceFloat(92676.98806519402),\n    };\n    striped_random_negative_finite_floats_helper(\n        1,\n        1,\n        8,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"-1.8\",\n        \"-1.999992251396406572893\",\n        \"-2.0\",\n        \"-1.000007629394303879793997\",\n        \"-1.0\",\n        \"-3.9999999999999999861222122955831198138315944982\",\n        \"-2.00048828124999999999322373803755273042776921295151896098423\",\n        \"-1.0000609\",\n        \"-3.98439049720059301762375898\",\n        \"-1.9921875\",\n        \"-3.99609375186263\",\n        \"-3.9921875\",\n        \"-4.0\",\n        \"-1.998046875\",\n        \"-1.0000000894069671630893256317890172009801151\",\n        \"-3.9999997615814209\",\n        \"-0.2499990481\",\n        \"-1.0000000000000000034694465383634065199217\",\n        \"-0.49999999998545\",\n        \"-1.9852905\",\n    ];\n    let values_hex = &[\n        \"-0x1.c#3\",\n        \"-0x1.ffff7e00003ffffffc#71\",\n        \"-0x2.000000000#38\",\n        \"-0x1.00007fffffc0003ffff8#79\",\n        \"-0x1.00000#19\",\n        \"-0x3.ffffffffffffff0000001fffffffffff8007fe#153\",\n        \"-0x2.001fffffffffffffe000007fffffff0000000000000001ff8#195\",\n        \"-0x1.0003fe#24\",\n        \"-0x3.fc0103fff83fffffffff00#89\",\n        \"-0x1.fe000000000000#57\",\n        \"-0x3.ff000007fffc#48\",\n        \"-0x3.fe000000#31\",\n        \"-0x4.00000000000000#57\",\n        \"-0x1.ff8000000000#48\",\n        \"-0x1.00000180000000000fffffffffffff800000#145\",\n        \"-0x3.fffffc0000000#54\",\n        \"-0x0.3ffff0078#31\",\n        \"-0x1.000000000000003fffff800001ffffff8#132\",\n        \"-0x0.7ffffffff00#43\",\n        \"-0x1.fc3c00#24\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 5069),\n        (\"-0.5\", 2623),\n        (\"-2.0\", 2623),\n        (\"-1.0\", 2567),\n        (\"-1.5\", 2547),\n        (\"-1.8\", 2419),\n        (\"-1.0\", 2408),\n        (\"-1.9\", 2381),\n        (\"-1.0\", 2336),\n        (\"-1.0\", 2240),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 5069),\n        (\"-0x0.8#1\", 2623),\n        (\"-0x2.0#1\", 2623),\n        (\"-0x1.0#2\", 2567),\n        (\"-0x1.8#2\", 2547),\n        (\"-0x1.c#3\", 2419),\n        (\"-0x1.0#3\", 2408),\n        (\"-0x1.e#4\", 2381),\n        (\"-0x1.0#4\", 2336),\n        (\"-0x1.00#6\", 2240),\n    ];\n    let sample_median = (\"-1.4999997616\", Some(\"-1.4999997616\"));\n    let sample_median_hex = (\"-0x1.7ffffc00#33\", Some(\"-0x1.7ffffc00#32\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-9.303344556597335),\n        standard_deviation: NiceFloat(516.4696271945669),\n        skewness: NiceFloat(-332.951705809113),\n        excess_kurtosis: NiceFloat(144341.98602578667),\n    };\n    striped_random_negative_finite_floats_helper(\n        1,\n        1,\n        32,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"-3.0e-37\", \"-8.0e-34\", \"-4.0e-6\", \"-3.0e-45\", \"-2.0e15\", \"-5.0e-10\", \"-2.0e4\", \"-0.11\",\n        \"-0.0001\", \"-1.0e14\", \"-2.0e34\", \"-9.0e-13\", \"-0.0001\", \"-9.0e9\", \"-1.3e33\", \"-0.12\",\n        \"-0.00003\", \"-5.0e18\", \"-0.06\", \"-5.0e8\",\n    ];\n    let values_hex = &[\n        \"-0x6.0E-31#2\",\n        \"-0x4.0E-28#1\",\n        \"-0x0.00004#2\",\n        \"-0x1.0E-37#2\",\n        \"-0x8.0E+12#1\",\n        \"-0x2.0E-8#1\",\n        \"-0x4.0E+3#1\",\n        \"-0x0.1c#3\",\n        \"-0x0.0008#1\",\n        \"-0x8.0E+11#1\",\n        \"-0x4.0E+28#1\",\n        \"-0x1.0E-10#1\",\n        \"-0x0.0008#1\",\n        \"-0x2.0E+8#1\",\n        \"-0x4.0E+27#3\",\n        \"-0x0.20#4\",\n        \"-0x0.0002#1\",\n        \"-0x4.0E+15#1\",\n        \"-0x0.1#1\",\n        \"-0x2.0E+7#3\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 3831),\n        (\"-0.2\", 3830),\n        (\"-0.5\", 3826),\n        (\"-2.0\", 3753),\n        (\"-4.0\", 3716),\n        (\"-8.0\", 3653),\n        (\"-0.1\", 3639),\n        (\"-0.06\", 3637),\n        (\"-3.0e1\", 3632),\n        (\"-2.0e1\", 3617),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 3831),\n        (\"-0x0.4#1\", 3830),\n        (\"-0x0.8#1\", 3826),\n        (\"-0x2.0#1\", 3753),\n        (\"-0x4.0#1\", 3716),\n        (\"-0x8.0#1\", 3653),\n        (\"-0x0.2#1\", 3639),\n        (\"-0x0.1#1\", 3637),\n        (\"-0x2.0E+1#1\", 3632),\n        (\"-0x1.0E+1#1\", 3617),\n    ];\n    let sample_median = (\"-1.0\", None);\n    let sample_median_hex = (\"-0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.952075737355551e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_negative_finite_floats_helper(\n        64,\n        1,\n        8,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"-3.3e-37\",\n        \"-1.5407379862027135753234e-33\",\n        \"-3.81469726562e-6\",\n        \"-2.80261831076667765237162e-45\",\n        \"-2.2518e15\",\n        \"-9.3132257461547851239382575628885994987366592936e-10\",\n        \"-16387.9999999999999999444888620036319676642853924988433283828\",\n        \"-0.062503807\",\n        \"-0.000243187896557653382423325133\",\n        \"-280375465082880.0\",\n        \"-4.1497810068414e34\",\n        \"-1.81543669e-12\",\n        \"-0.0001220703125\",\n        \"-17163091968.0\",\n        \"-1298074330690585590141422900609023.99951171875\",\n        \"-0.24999998509883881\",\n        \"-0.00006103492385\",\n        \"-4611686018427387919.999998092651821934844\",\n        \"-0.12499999999636\",\n        \"-1.06584474e9\",\n    ];\n    let values_hex = &[\n        \"-0x7.0E-31#3\",\n        \"-0x7.fffdf80000fffffffE-28#71\",\n        \"-0x0.00004000000000#38\",\n        \"-0x1.00007fffffc0003ffff8E-37#79\",\n        \"-0x8.0000E+12#19\",\n        \"-0x3.ffffffffffffff0000001fffffffffff8007feE-8#153\",\n        \"-0x4003.fffffffffffffc00000fffffffe0000000000000003ff#195\",\n        \"-0x0.10003fe#24\",\n        \"-0x0.000ff0040fffe0fffffffffc00#89\",\n        \"-0xff0000000000.000#57\",\n        \"-0x7.fe00000ffff8E+28#48\",\n        \"-0x1.ff000000E-10#31\",\n        \"-0x0.000800000000000000#57\",\n        \"-0x3ff000000.0000#48\",\n        \"-0x400000600000000003ffffffffff.ffe000000#145\",\n        \"-0x0.3fffffc0000000#54\",\n        \"-0x0.0003ffff0078#31\",\n        \"-0x400000000000000f.ffffe000007fffffe0#132\",\n        \"-0x0.1ffffffffc00#43\",\n        \"-0x3.f87800E+7#24\",\n    ];\n    let common_values = &[\n        (\"-2.0\", 130),\n        (\"-2.0e1\", 129),\n        (\"-0.2\", 122),\n        (\"-3.0e1\", 117),\n        (\"-0.004\", 116),\n        (\"-1.0e5\", 114),\n        (\"-0.02\", 112),\n        (\"-0.00002\", 112),\n        (\"-0.1\", 109),\n        (\"-8.0\", 108),\n    ];\n    let common_values_hex = &[\n        (\"-0x2.0#1\", 130),\n        (\"-0x1.0E+1#1\", 129),\n        (\"-0x0.4#1\", 122),\n        (\"-0x2.0E+1#1\", 117),\n        (\"-0x0.01#1\", 116),\n        (\"-0x2.0E+4#1\", 114),\n        (\"-0x0.04#1\", 112),\n        (\"-0x0.0001#1\", 112),\n        (\"-0x0.2#1\", 109),\n        (\"-0x8.0#1\", 108),\n    ];\n    let sample_median = (\"-1.1249998807907122255\", Some(\"-1.12499988079071\"));\n    let sample_median_hex = (\"-0x1.1ffffe0000007ffe#64\", Some(\"-0x1.1ffffe000000#49\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.8054101301847865e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_negative_finite_floats_helper(\n        64,\n        1,\n        32,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_finite_floats_fail_1() {\n    striped_random_negative_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_finite_floats_fail_2() {\n    striped_random_negative_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_finite_floats_fail_3() {\n    striped_random_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_finite_floats_fail_4() {\n    striped_random_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_finite_floats_fail_5() {\n    striped_random_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 3, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_finite_floats_fail_6() {\n    striped_random_negative_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 2, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_non_negative_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_non_negative_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn striped_random_non_negative_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_non_negative_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_non_negative_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"8.0\", \"1.0\", \"0.8\", \"0.0\", \"4.0\", \"3.5\", \"1.0\", \"2.0\", \"0.5\", \"0.5\", \"2.0\", \"3.0e1\",\n        \"0.5\", \"0.0\", \"1.0\", \"3.0\", \"0.5\", \"0.0\", \"1.0\", \"0.1\",\n    ];\n    let values_hex = &[\n        \"0x8.0#1\",\n        \"0x1.0#1\",\n        \"0x0.c#2\",\n        \"0x0.0\",\n        \"0x4.0#1\",\n        \"0x3.8#3\",\n        \"0x1.0#1\",\n        \"0x2.0#1\",\n        \"0x0.8#2\",\n        \"0x0.800#12\",\n        \"0x2.0#1\",\n        \"0x2.0E+1#1\",\n        \"0x0.8#1\",\n        \"0x0.0\",\n        \"0x1.0#1\",\n        \"0x3.0#2\",\n        \"0x0.8#1\",\n        \"0x0.0\",\n        \"0x1.0#2\",\n        \"0x0.2#1\",\n    ];\n    let common_values = &[\n        (\"1.0\", 149586),\n        (\"0.0\", 100224),\n        (\"2.0\", 74929),\n        (\"0.5\", 74827),\n        (\"1.0\", 38123),\n        (\"4.0\", 37612),\n        (\"0.2\", 37602),\n        (\"1.5\", 37379),\n        (\"0.5\", 18928),\n        (\"0.8\", 18840),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 149586),\n        (\"0x0.0\", 100224),\n        (\"0x2.0#1\", 74929),\n        (\"0x0.8#1\", 74827),\n        (\"0x1.0#2\", 38123),\n        (\"0x4.0#1\", 37612),\n        (\"0x0.4#1\", 37602),\n        (\"0x1.8#2\", 37379),\n        (\"0x0.8#2\", 18928),\n        (\"0x0.c#2\", 18840),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.756520872349506),\n        standard_deviation: NiceFloat(1567.2504048767603),\n        skewness: NiceFloat(588.0046776041995),\n        excess_kurtosis: NiceFloat(368204.8297165849),\n    };\n    striped_random_non_negative_finite_floats_helper(\n        1,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"15.99996948242187500002710174558968740475801788817904844007080242775028492173761449748527\\\n        50344620578\",\n        \"1.0\",\n        \"0.9999961855\",\n        \"0.0\",\n        \"7.9999923707218827326204245\",\n        \"3.99902343750000005551115123125625546225\",\n        \"1.999999963\",\n        \"3.9687500000000568434188608076\",\n        \"0.99999999999999645\",\n        \"0.5\",\n        \"3.5\",\n        \"63.9375\",\n        \"0.5019531249\",\n        \"0.0\",\n        \"1.5\",\n        \"3.8\",\n        \"0.5\",\n        \"0.0\",\n        \"1.0\",\n        \"0.23\",\n    ];\n    let values_hex = &[\n        \"0xf.fffe0000000000007ffc0000000007ffffff8003fe00000000000003fff0003ffffffff8ff000000#324\",\n        \"0x1.0#1\",\n        \"0x0.ffffc001#32\",\n        \"0x0.0\",\n        \"0x7.ffff80007fff9f80000fe#86\",\n        \"0x3.ffc00000000003ffffffffffe01fffe#125\",\n        \"0x1.ffffff6#28\",\n        \"0x3.f8000000000fffffffffffe#93\",\n        \"0x0.ffffffffffff00#55\",\n        \"0x0.800#12\",\n        \"0x3.8000#16\",\n        \"0x3f.f00000000000000#65\",\n        \"0x0.807fffff8#33\",\n        \"0x0.0\",\n        \"0x1.8#2\",\n        \"0x3.c#4\",\n        \"0x0.8000000000#37\",\n        \"0x0.0\",\n        \"0x1.00#9\",\n        \"0x0.3c#4\",\n    ];\n    let common_values = &[\n        (\"0.0\", 100224),\n        (\"1.0\", 4643),\n        (\"2.0\", 2373),\n        (\"0.5\", 2353),\n        (\"1.5\", 2346),\n        (\"1.0\", 2275),\n        (\"1.0\", 2183),\n        (\"1.8\", 2131),\n        (\"1.0\", 2125),\n        (\"1.9\", 2082),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 100224),\n        (\"0x1.0#1\", 4643),\n        (\"0x2.0#1\", 2373),\n        (\"0x0.8#1\", 2353),\n        (\"0x1.8#2\", 2346),\n        (\"0x1.0#2\", 2275),\n        (\"0x1.0#3\", 2183),\n        (\"0x1.c#3\", 2131),\n        (\"0x1.0#4\", 2125),\n        (\"0x1.e#4\", 2082),\n    ];\n    let sample_median = (\n        \"1.000007629394531249993647252693644355720408559059500172572\",\n        Some(\"1.000007629394531249997\"),\n    );\n    let sample_median_hex = (\n        \"0x1.00007fffffffffffe1fffff000000000000000000000000#189\",\n        Some(\"0x1.00007ffffffffffff#69\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(11.589283909473794),\n        standard_deviation: NiceFloat(2398.6644729176514),\n        skewness: NiceFloat(671.6561608456597),\n        excess_kurtosis: NiceFloat(499631.39656685427),\n    };\n    striped_random_non_negative_finite_floats_helper(\n        1,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"1.0e9\", \"2.0e-6\", \"24.0\", \"0.0\", \"5.0e-7\", \"0.11\", \"8.0e22\", \"7.0e19\", \"0.03\", \"3.355e7\",\n        \"2.0e38\", \"7.0e-9\", \"2.0e15\", \"0.0\", \"3.0e11\", \"2.0e-8\", \"6.0e14\", \"0.0\", \"0.03\",\n        \"2.0e-34\",\n    ];\n    let values_hex = &[\n        \"0x4.0E+7#1\",\n        \"0x0.00002#1\",\n        \"0x18.0#2\",\n        \"0x0.0\",\n        \"0x8.0E-6#1\",\n        \"0x0.1c#3\",\n        \"0x1.0E+19#1\",\n        \"0x4.0E+16#1\",\n        \"0x0.08#2\",\n        \"0x2.000E+6#12\",\n        \"0x8.0E+31#1\",\n        \"0x2.0E-7#1\",\n        \"0x8.0E+12#1\",\n        \"0x0.0\",\n        \"0x4.0E+9#1\",\n        \"0x6.0E-7#2\",\n        \"0x2.0E+12#1\",\n        \"0x0.0\",\n        \"0x0.08#2\",\n        \"0x1.0E-28#1\",\n    ];\n    let common_values = &[\n        (\"0.0\", 100224),\n        (\"1.0\", 3531),\n        (\"2.0\", 3503),\n        (\"4.0\", 3399),\n        (\"0.5\", 3381),\n        (\"0.1\", 3375),\n        (\"0.2\", 3369),\n        (\"0.06\", 3330),\n        (\"8.0\", 3283),\n        (\"2.0e1\", 3250),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 100224),\n        (\"0x1.0#1\", 3531),\n        (\"0x2.0#1\", 3503),\n        (\"0x4.0#1\", 3399),\n        (\"0x0.8#1\", 3381),\n        (\"0x0.2#1\", 3375),\n        (\"0x0.4#1\", 3369),\n        (\"0x0.1#1\", 3330),\n        (\"0x8.0#1\", 3283),\n        (\"0x1.0E+1#1\", 3250),\n    ];\n    let sample_median = (\"0.007\", None);\n    let sample_median_hex = (\"0x0.01c#3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.2374143686309695e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_non_negative_finite_floats_helper(\n        64,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"2147479552.000000000003637534717881863696837550734749938828247260989527393548280429992335\\\n        3285806191\",\n        \"2.0e-6\",\n        \"31.999877937\",\n        \"0.0\",\n        \"9.5367340692542585523371988e-7\",\n        \"0.124969482421875001734723475976757983195\",\n        \"1.511157246e23\",\n        \"146421031085071663103.99999999\",\n        \"0.062499999999999778\",\n        \"3.355e7\",\n        \"2.97747e38\",\n        \"1.48866092786192893982e-8\",\n        \"2.2605959062e15\",\n        \"0.0\",\n        \"4.0e11\",\n        \"2.8e-8\",\n        \"5.6294995342e14\",\n        \"0.0\",\n        \"0.0312\",\n        \"3.6e-34\",\n    ];\n    let values_hex = &[\n        \"0x7ffff000.0000000003ffe0000000003ffffffc001ff00000000000001fff8001ffffffffc7f8000000\\\n        #324\",\n        \"0x0.00002#1\",\n        \"0x1f.fff8002#32\",\n        \"0x0.0\",\n        \"0xf.ffff0000ffff3f00001fcE-6#86\",\n        \"0x0.1ffe00000000001fffffffffff00ffff#125\",\n        \"0x1.ffffff6E+19#28\",\n        \"0x7f0000000001fffff.ffffffc#93\",\n        \"0x0.0ffffffffffff00#55\",\n        \"0x2.000E+6#12\",\n        \"0xe.000E+31#16\",\n        \"0x3.ff00000000000000E-7#65\",\n        \"0x8.07fffff8E+12#33\",\n        \"0x0.0\",\n        \"0x6.0E+9#2\",\n        \"0x7.8E-7#4\",\n        \"0x2.000000000E+12#37\",\n        \"0x0.0\",\n        \"0x0.0800#9\",\n        \"0x1.eE-28#4\",\n    ];\n    let common_values = &[\n        (\"0.0\", 100224),\n        (\"8.0\", 129),\n        (\"4.0\", 120),\n        (\"2.0\", 107),\n        (\"0.06\", 107),\n        (\"1.0e3\", 106),\n        (\"3.0e1\", 105),\n        (\"4.0e3\", 104),\n        (\"0.5\", 102),\n        (\"1.0e2\", 102),\n    ];\n    let common_values_hex = &[\n        (\"0x0.0\", 100224),\n        (\"0x8.0#1\", 129),\n        (\"0x4.0#1\", 120),\n        (\"0x2.0#1\", 107),\n        (\"0x0.1#1\", 107),\n        (\"0x4.0E+2#1\", 106),\n        (\"0x2.0E+1#1\", 105),\n        (\"0x1.0E+3#1\", 104),\n        (\"0x0.8#1\", 102),\n        (\"0x8.0E+1#1\", 102),\n    ];\n    let sample_median = (\n        \"0.007812499999971581759\",\n        Some(\"0.007812499999971581759170316330143455009\"),\n    );\n    let sample_median_hex = (\n        \"0x0.01fffffffff8003ffc#63\",\n        Some(\"0x0.01fffffffff8003ffc00f800000000ff#121\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.238472715881828e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_non_negative_finite_floats_helper(\n        64,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_1() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_2() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_3() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_4() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_5() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 3, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_6() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_7() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_finite_floats_fail_8() {\n    striped_random_non_negative_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1, 1, 0);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_non_positive_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_non_positive_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn striped_random_non_positive_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    zero_p_numerator: u64,\n    zero_p_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_non_positive_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n            zero_p_numerator,\n            zero_p_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_non_positive_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"-8.0\", \"-1.0\", \"-0.8\", \"-0.0\", \"-4.0\", \"-3.5\", \"-1.0\", \"-2.0\", \"-0.5\", \"-0.5\", \"-2.0\",\n        \"-3.0e1\", \"-0.5\", \"-0.0\", \"-1.0\", \"-3.0\", \"-0.5\", \"-0.0\", \"-1.0\", \"-0.1\",\n    ];\n    let values_hex = &[\n        \"-0x8.0#1\",\n        \"-0x1.0#1\",\n        \"-0x0.c#2\",\n        \"-0x0.0\",\n        \"-0x4.0#1\",\n        \"-0x3.8#3\",\n        \"-0x1.0#1\",\n        \"-0x2.0#1\",\n        \"-0x0.8#2\",\n        \"-0x0.800#12\",\n        \"-0x2.0#1\",\n        \"-0x2.0E+1#1\",\n        \"-0x0.8#1\",\n        \"-0x0.0\",\n        \"-0x1.0#1\",\n        \"-0x3.0#2\",\n        \"-0x0.8#1\",\n        \"-0x0.0\",\n        \"-0x1.0#2\",\n        \"-0x0.2#1\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 149586),\n        (\"-0.0\", 100224),\n        (\"-2.0\", 74929),\n        (\"-0.5\", 74827),\n        (\"-1.0\", 38123),\n        (\"-4.0\", 37612),\n        (\"-0.2\", 37602),\n        (\"-1.5\", 37379),\n        (\"-0.5\", 18928),\n        (\"-0.8\", 18840),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 149586),\n        (\"-0x0.0\", 100224),\n        (\"-0x2.0#1\", 74929),\n        (\"-0x0.8#1\", 74827),\n        (\"-0x1.0#2\", 38123),\n        (\"-0x4.0#1\", 37612),\n        (\"-0x0.4#1\", 37602),\n        (\"-0x1.8#2\", 37379),\n        (\"-0x0.8#2\", 18928),\n        (\"-0x0.c#2\", 18840),\n    ];\n    let sample_median = (\"-1.0\", None);\n    let sample_median_hex = (\"-0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.756520872349506),\n        standard_deviation: NiceFloat(1567.2504048767603),\n        skewness: NiceFloat(-588.0046776041995),\n        excess_kurtosis: NiceFloat(368204.8297165849),\n    };\n    striped_random_non_positive_finite_floats_helper(\n        1,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"-15.9999694824218750000271017455896874047580178881790484400708024277502849217376144974852\\\n        750344620578\",\n        \"-1.0\",\n        \"-0.9999961855\",\n        \"-0.0\",\n        \"-7.9999923707218827326204245\",\n        \"-3.99902343750000005551115123125625546225\",\n        \"-1.999999963\",\n        \"-3.9687500000000568434188608076\",\n        \"-0.99999999999999645\",\n        \"-0.5\",\n        \"-3.5\",\n        \"-63.9375\",\n        \"-0.5019531249\",\n        \"-0.0\",\n        \"-1.5\",\n        \"-3.8\",\n        \"-0.5\",\n        \"-0.0\",\n        \"-1.0\",\n        \"-0.23\",\n    ];\n    let values_hex = &[\n        \"-0xf.fffe0000000000007ffc0000000007ffffff8003fe00000000000003fff0003ffffffff8ff000000\\\n        #324\",\n        \"-0x1.0#1\",\n        \"-0x0.ffffc001#32\",\n        \"-0x0.0\",\n        \"-0x7.ffff80007fff9f80000fe#86\",\n        \"-0x3.ffc00000000003ffffffffffe01fffe#125\",\n        \"-0x1.ffffff6#28\",\n        \"-0x3.f8000000000fffffffffffe#93\",\n        \"-0x0.ffffffffffff00#55\",\n        \"-0x0.800#12\",\n        \"-0x3.8000#16\",\n        \"-0x3f.f00000000000000#65\",\n        \"-0x0.807fffff8#33\",\n        \"-0x0.0\",\n        \"-0x1.8#2\",\n        \"-0x3.c#4\",\n        \"-0x0.8000000000#37\",\n        \"-0x0.0\",\n        \"-0x1.00#9\",\n        \"-0x0.3c#4\",\n    ];\n    let common_values = &[\n        (\"-0.0\", 100224),\n        (\"-1.0\", 4643),\n        (\"-2.0\", 2373),\n        (\"-0.5\", 2353),\n        (\"-1.5\", 2346),\n        (\"-1.0\", 2275),\n        (\"-1.0\", 2183),\n        (\"-1.8\", 2131),\n        (\"-1.0\", 2125),\n        (\"-1.9\", 2082),\n    ];\n    let common_values_hex = &[\n        (\"-0x0.0\", 100224),\n        (\"-0x1.0#1\", 4643),\n        (\"-0x2.0#1\", 2373),\n        (\"-0x0.8#1\", 2353),\n        (\"-0x1.8#2\", 2346),\n        (\"-0x1.0#2\", 2275),\n        (\"-0x1.0#3\", 2183),\n        (\"-0x1.c#3\", 2131),\n        (\"-0x1.0#4\", 2125),\n        (\"-0x1.e#4\", 2082),\n    ];\n    let sample_median = (\n        \"-1.000007629394531249997\",\n        Some(\"-1.000007629394531249993647252693644355720408559059500172572\"),\n    );\n    let sample_median_hex = (\n        \"-0x1.00007ffffffffffff#69\",\n        Some(\"-0x1.00007fffffffffffe1fffff000000000000000000000000#189\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-11.589283909473794),\n        standard_deviation: NiceFloat(2398.6644729176514),\n        skewness: NiceFloat(-671.6561608456597),\n        excess_kurtosis: NiceFloat(499631.39656685427),\n    };\n    striped_random_non_positive_finite_floats_helper(\n        1,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"-1.0e9\", \"-2.0e-6\", \"-24.0\", \"-0.0\", \"-5.0e-7\", \"-0.11\", \"-8.0e22\", \"-7.0e19\", \"-0.03\",\n        \"-3.355e7\", \"-2.0e38\", \"-7.0e-9\", \"-2.0e15\", \"-0.0\", \"-3.0e11\", \"-2.0e-8\", \"-6.0e14\",\n        \"-0.0\", \"-0.03\", \"-2.0e-34\",\n    ];\n    let values_hex = &[\n        \"-0x4.0E+7#1\",\n        \"-0x0.00002#1\",\n        \"-0x18.0#2\",\n        \"-0x0.0\",\n        \"-0x8.0E-6#1\",\n        \"-0x0.1c#3\",\n        \"-0x1.0E+19#1\",\n        \"-0x4.0E+16#1\",\n        \"-0x0.08#2\",\n        \"-0x2.000E+6#12\",\n        \"-0x8.0E+31#1\",\n        \"-0x2.0E-7#1\",\n        \"-0x8.0E+12#1\",\n        \"-0x0.0\",\n        \"-0x4.0E+9#1\",\n        \"-0x6.0E-7#2\",\n        \"-0x2.0E+12#1\",\n        \"-0x0.0\",\n        \"-0x0.08#2\",\n        \"-0x1.0E-28#1\",\n    ];\n    let common_values = &[\n        (\"-0.0\", 100224),\n        (\"-1.0\", 3531),\n        (\"-2.0\", 3503),\n        (\"-4.0\", 3399),\n        (\"-0.5\", 3381),\n        (\"-0.1\", 3375),\n        (\"-0.2\", 3369),\n        (\"-0.06\", 3330),\n        (\"-8.0\", 3283),\n        (\"-2.0e1\", 3250),\n    ];\n    let common_values_hex = &[\n        (\"-0x0.0\", 100224),\n        (\"-0x1.0#1\", 3531),\n        (\"-0x2.0#1\", 3503),\n        (\"-0x4.0#1\", 3399),\n        (\"-0x0.8#1\", 3381),\n        (\"-0x0.2#1\", 3375),\n        (\"-0x0.4#1\", 3369),\n        (\"-0x0.1#1\", 3330),\n        (\"-0x8.0#1\", 3283),\n        (\"-0x1.0E+1#1\", 3250),\n    ];\n    let sample_median = (\"-0.007\", None);\n    let sample_median_hex = (\"-0x0.01c#3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.2374143686309695e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_non_positive_finite_floats_helper(\n        64,\n        1,\n        8,\n        1,\n        2,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"-2147479552.00000000000363753471788186369683755073474993882824726098952739354828042999233\\\n        53285806191\",\n        \"-2.0e-6\",\n        \"-31.999877937\",\n        \"-0.0\",\n        \"-9.5367340692542585523371988e-7\",\n        \"-0.124969482421875001734723475976757983195\",\n        \"-1.511157246e23\",\n        \"-146421031085071663103.99999999\",\n        \"-0.062499999999999778\",\n        \"-3.355e7\",\n        \"-2.97747e38\",\n        \"-1.48866092786192893982e-8\",\n        \"-2.2605959062e15\",\n        \"-0.0\",\n        \"-4.0e11\",\n        \"-2.8e-8\",\n        \"-5.6294995342e14\",\n        \"-0.0\",\n        \"-0.0312\",\n        \"-3.6e-34\",\n    ];\n    let values_hex = &[\n        \"-0x7ffff000.0000000003ffe0000000003ffffffc001ff00000000000001fff8001ffffffffc7f8000000\\\n        #324\",\n        \"-0x0.00002#1\",\n        \"-0x1f.fff8002#32\",\n        \"-0x0.0\",\n        \"-0xf.ffff0000ffff3f00001fcE-6#86\",\n        \"-0x0.1ffe00000000001fffffffffff00ffff#125\",\n        \"-0x1.ffffff6E+19#28\",\n        \"-0x7f0000000001fffff.ffffffc#93\",\n        \"-0x0.0ffffffffffff00#55\",\n        \"-0x2.000E+6#12\",\n        \"-0xe.000E+31#16\",\n        \"-0x3.ff00000000000000E-7#65\",\n        \"-0x8.07fffff8E+12#33\",\n        \"-0x0.0\",\n        \"-0x6.0E+9#2\",\n        \"-0x7.8E-7#4\",\n        \"-0x2.000000000E+12#37\",\n        \"-0x0.0\",\n        \"-0x0.0800#9\",\n        \"-0x1.eE-28#4\",\n    ];\n    let common_values = &[\n        (\"-0.0\", 100224),\n        (\"-8.0\", 129),\n        (\"-4.0\", 120),\n        (\"-2.0\", 107),\n        (\"-0.06\", 107),\n        (\"-1.0e3\", 106),\n        (\"-3.0e1\", 105),\n        (\"-4.0e3\", 104),\n        (\"-0.5\", 102),\n        (\"-1.0e2\", 102),\n    ];\n    let common_values_hex = &[\n        (\"-0x0.0\", 100224),\n        (\"-0x8.0#1\", 129),\n        (\"-0x4.0#1\", 120),\n        (\"-0x2.0#1\", 107),\n        (\"-0x0.1#1\", 107),\n        (\"-0x4.0E+2#1\", 106),\n        (\"-0x2.0E+1#1\", 105),\n        (\"-0x1.0E+3#1\", 104),\n        (\"-0x0.8#1\", 102),\n        (\"-0x8.0E+1#1\", 102),\n    ];\n    let sample_median = (\n        \"-0.007812499999971581759170316330143455009\",\n        Some(\"-0.007812499999971581759\"),\n    );\n    let sample_median_hex = (\n        \"-0x0.01fffffffff8003ffc00f800000000ff#121\",\n        Some(\"-0x0.01fffffffff8003ffc#63\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.238472715881828e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_non_positive_finite_floats_helper(\n        64,\n        1,\n        32,\n        1,\n        64,\n        1,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_1() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_2() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_3() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_4() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_5() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 3, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_6() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 2, 1, 1, 10);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_7() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_positive_finite_floats_fail_8() {\n    striped_random_non_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 2, 1, 1, 0);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_nonzero_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_nonzero_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn striped_random_nonzero_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_nonzero_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_nonzero_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"-8.0\", \"-1.0\", \"-0.8\", \"4.0\", \"-3.5\", \"1.0\", \"-2.0\", \"-0.5\", \"-0.5\", \"2.0\", \"3.0e1\",\n        \"0.5\", \"-1.0\", \"-3.0\", \"0.5\", \"-1.0\", \"-0.1\", \"-1.0\", \"-0.055\", \"-1.8\",\n    ];\n    let values_hex = &[\n        \"-0x8.0#1\",\n        \"-0x1.0#1\",\n        \"-0x0.c#2\",\n        \"0x4.0#1\",\n        \"-0x3.8#3\",\n        \"0x1.0#1\",\n        \"-0x2.0#1\",\n        \"-0x0.8#2\",\n        \"-0x0.800#12\",\n        \"0x2.0#1\",\n        \"0x2.0E+1#1\",\n        \"0x0.8#1\",\n        \"-0x1.0#1\",\n        \"-0x3.0#2\",\n        \"0x0.8#1\",\n        \"-0x1.0#2\",\n        \"-0x0.2#1\",\n        \"-0x1.0#1\",\n        \"-0x0.0e#3\",\n        \"-0x1.c#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 83167),\n        (\"-1.0\", 83060),\n        (\"2.0\", 41731),\n        (\"-2.0\", 41688),\n        (\"0.5\", 41643),\n        (\"-0.5\", 41534),\n        (\"1.0\", 21186),\n        (\"-4.0\", 21185),\n        (\"-1.0\", 21101),\n        (\"0.2\", 21077),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 83167),\n        (\"-0x1.0#1\", 83060),\n        (\"0x2.0#1\", 41731),\n        (\"-0x2.0#1\", 41688),\n        (\"0x0.8#1\", 41643),\n        (\"-0x0.8#1\", 41534),\n        (\"0x1.0#2\", 21186),\n        (\"-0x4.0#1\", 21185),\n        (\"-0x1.0#2\", 21101),\n        (\"0x0.4#1\", 21077),\n    ];\n    let sample_median = (\"0.002\", None);\n    let sample_median_hex = (\"0x0.008#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.1181422910011878),\n        standard_deviation: NiceFloat(1654.3094882610405),\n        skewness: NiceFloat(-398.68071157281685),\n        excess_kurtosis: NiceFloat(306701.41416153224),\n    };\n    striped_random_nonzero_finite_floats_helper(\n        1,\n        1,\n        8,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"-15.9999694824218750000271017455896874047580178881790484400708024277502849217376144974852\\\n        750344620578\",\n        \"-1.0\",\n        \"-0.9999961855\",\n        \"7.9999923707218827326204245\",\n        \"-3.99902343750000005551115123125625546225\",\n        \"1.999999963\",\n        \"-3.9687500000000568434188608076\",\n        \"-0.99999999999999645\",\n        \"-0.5\",\n        \"3.5\",\n        \"63.9375\",\n        \"0.5019531249\",\n        \"-1.5\",\n        \"-3.8\",\n        \"0.5\",\n        \"-1.0\",\n        \"-0.23\",\n        \"-1.624816894531249999999999173\",\n        \"-0.06225609778\",\n        \"-1.9999\",\n    ];\n    let values_hex = &[\n        \"-0xf.fffe0000000000007ffc0000000007ffffff8003fe00000000000003fff0003ffffffff8ff000000\\\n        #324\",\n        \"-0x1.0#1\",\n        \"-0x0.ffffc001#32\",\n        \"0x7.ffff80007fff9f80000fe#86\",\n        \"-0x3.ffc00000000003ffffffffffe01fffe#125\",\n        \"0x1.ffffff6#28\",\n        \"-0x3.f8000000000fffffffffffe#93\",\n        \"-0x0.ffffffffffff00#55\",\n        \"-0x0.800#12\",\n        \"0x3.8000#16\",\n        \"0x3f.f00000000000000#65\",\n        \"0x0.807fffff8#33\",\n        \"-0x1.8#2\",\n        \"-0x3.c#4\",\n        \"0x0.8000000000#37\",\n        \"-0x1.00#9\",\n        \"-0x0.3c#4\",\n        \"-0x1.9ff3ffffffffffffffff000#90\",\n        \"-0x0.0ff003fff#32\",\n        \"-0x1.fff8#14\",\n    ];\n    let common_values = &[\n        (\"-1.0\", 2594),\n        (\"1.0\", 2582),\n        (\"2.0\", 1322),\n        (\"0.5\", 1316),\n        (\"-2.0\", 1310),\n        (\"-1.5\", 1300),\n        (\"1.0\", 1293),\n        (\"-0.5\", 1282),\n        (\"1.5\", 1281),\n        (\"-1.0\", 1251),\n    ];\n    let common_values_hex = &[\n        (\"-0x1.0#1\", 2594),\n        (\"0x1.0#1\", 2582),\n        (\"0x2.0#1\", 1322),\n        (\"0x0.8#1\", 1316),\n        (\"-0x2.0#1\", 1310),\n        (\"-0x1.8#2\", 1300),\n        (\"0x1.0#2\", 1293),\n        (\"-0x0.8#1\", 1282),\n        (\"0x1.8#2\", 1281),\n        (\"-0x1.0#2\", 1251),\n    ];\n    let sample_median = (\n        \"0.0019826889\",\n        Some(\"0.00198341719988093245774507522583003\"),\n    );\n    let sample_median_hex = (\n        \"0x0.0081f0000#26\",\n        Some(\"0x0.0081fc3801ffffffffffffffffffc#106\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.535338105008931),\n        standard_deviation: NiceFloat(2619.656937757806),\n        skewness: NiceFloat(-395.5135549279457),\n        excess_kurtosis: NiceFloat(376873.9371275132),\n    };\n    striped_random_nonzero_finite_floats_helper(\n        1,\n        1,\n        32,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"-1.0e9\", \"-2.0e-6\", \"-24.0\", \"5.0e-7\", \"-0.11\", \"8.0e22\", \"-7.0e19\", \"-0.03\", \"-3.355e7\",\n        \"2.0e38\", \"7.0e-9\", \"2.0e15\", \"-3.0e11\", \"-2.0e-8\", \"6.0e14\", \"-0.03\", \"-2.0e-34\",\n        \"-6.0e14\", \"-4.4e30\", \"-2.7e57\",\n    ];\n    let values_hex = &[\n        \"-0x4.0E+7#1\",\n        \"-0x0.00002#1\",\n        \"-0x18.0#2\",\n        \"0x8.0E-6#1\",\n        \"-0x0.1c#3\",\n        \"0x1.0E+19#1\",\n        \"-0x4.0E+16#1\",\n        \"-0x0.08#2\",\n        \"-0x2.000E+6#12\",\n        \"0x8.0E+31#1\",\n        \"0x2.0E-7#1\",\n        \"0x8.0E+12#1\",\n        \"-0x4.0E+9#1\",\n        \"-0x6.0E-7#2\",\n        \"0x2.0E+12#1\",\n        \"-0x0.08#2\",\n        \"-0x1.0E-28#1\",\n        \"-0x2.0E+12#1\",\n        \"-0x3.8E+25#3\",\n        \"-0x7.0E+47#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 2018),\n        (\"-2.0\", 2004),\n        (\"-1.0\", 1938),\n        (\"4.0\", 1933),\n        (\"0.5\", 1901),\n        (\"0.1\", 1900),\n        (\"-0.2\", 1883),\n        (\"-4.0\", 1875),\n        (\"0.2\", 1874),\n        (\"2.0\", 1873),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 2018),\n        (\"-0x2.0#1\", 2004),\n        (\"-0x1.0#1\", 1938),\n        (\"0x4.0#1\", 1933),\n        (\"0x0.8#1\", 1901),\n        (\"0x0.2#1\", 1900),\n        (\"-0x0.4#1\", 1883),\n        (\"-0x4.0#1\", 1875),\n        (\"0x0.4#1\", 1874),\n        (\"0x2.0#1\", 1873),\n    ];\n    let sample_median = (\"1.0e-122\", None);\n    let sample_median_hex = (\"0x8.0E-102#2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.237414368630952e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_nonzero_finite_floats_helper(\n        64,\n        1,\n        8,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"-2147479552.00000000000363753471788186369683755073474993882824726098952739354828042999233\\\n        53285806191\",\n        \"-2.0e-6\",\n        \"-31.999877937\",\n        \"9.5367340692542585523371988e-7\",\n        \"-0.124969482421875001734723475976757983195\",\n        \"1.511157246e23\",\n        \"-146421031085071663103.99999999\",\n        \"-0.062499999999999778\",\n        \"-3.355e7\",\n        \"2.97747e38\",\n        \"1.48866092786192893982e-8\",\n        \"2.2605959062e15\",\n        \"-4.0e11\",\n        \"-2.8e-8\",\n        \"5.6294995342e14\",\n        \"-0.0312\",\n        \"-3.6e-34\",\n        \"-914690595094527.999999999534\",\n        \"-5.050814702e30\",\n        \"-3.1384e57\",\n    ];\n    let values_hex = &[\n        \"-0x7ffff000.0000000003ffe0000000003ffffffc001ff00000000000001fff8001ffffffffc7f8000000\\\n        #324\",\n        \"-0x0.00002#1\",\n        \"-0x1f.fff8002#32\",\n        \"0xf.ffff0000ffff3f00001fcE-6#86\",\n        \"-0x0.1ffe00000000001fffffffffff00ffff#125\",\n        \"0x1.ffffff6E+19#28\",\n        \"-0x7f0000000001fffff.ffffffc#93\",\n        \"-0x0.0ffffffffffff00#55\",\n        \"-0x2.000E+6#12\",\n        \"0xe.000E+31#16\",\n        \"0x3.ff00000000000000E-7#65\",\n        \"0x8.07fffff8E+12#33\",\n        \"-0x6.0E+9#2\",\n        \"-0x7.8E-7#4\",\n        \"0x2.000000000E+12#37\",\n        \"-0x0.0800#9\",\n        \"-0x1.eE-28#4\",\n        \"-0x33fe7ffffffff.fffffffe00#90\",\n        \"-0x3.fc00fffcE+25#32\",\n        \"-0x7.ffeE+47#14\",\n    ];\n    let common_values = &[\n        (\"-8.0\", 73),\n        (\"1.0e3\", 70),\n        (\"4.0\", 69),\n        (\"2.0\", 68),\n        (\"8.0\", 68),\n        (\"-1.0e2\", 67),\n        (\"-0.02\", 65),\n        (\"-0.5\", 64),\n        (\"2.0e1\", 64),\n        (\"-4.0\", 62),\n    ];\n    let common_values_hex = &[\n        (\"-0x8.0#1\", 73),\n        (\"0x4.0E+2#1\", 70),\n        (\"0x4.0#1\", 69),\n        (\"0x2.0#1\", 68),\n        (\"0x8.0#1\", 68),\n        (\"-0x8.0E+1#1\", 67),\n        (\"-0x0.04#1\", 65),\n        (\"-0x0.8#1\", 64),\n        (\"0x1.0E+1#1\", 64),\n        (\"-0x4.0#1\", 62),\n    ];\n    let sample_median = (\n        \"1.21019420636902759627106091036435e-122\",\n        Some(\"1.81527747811658e-122\"),\n    );\n    let sample_median_hex = (\n        \"0x8.0003fffffffc00000000000000E-102#105\",\n        Some(\"0xc.000001fff00E-102#45\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.2384727158818326e242),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_nonzero_finite_floats_helper(\n        64,\n        1,\n        32,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_finite_floats_fail_1() {\n    striped_random_nonzero_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_finite_floats_fail_2() {\n    striped_random_nonzero_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_finite_floats_fail_3() {\n    striped_random_nonzero_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_finite_floats_fail_4() {\n    striped_random_nonzero_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_finite_floats_fail_5() {\n    striped_random_nonzero_finite_floats(EXAMPLE_SEED, 1, 1, 2, 3, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_finite_floats_fail_6() {\n    striped_random_nonzero_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 2, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_positive_finite_floats.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_positive_finite_floats;\nuse malachite_float::test_util::random::random_floats_helper_helper;\n\nfn striped_random_positive_finite_floats_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_precision_numerator: u64,\n    mean_precision_denominator: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_positive_finite_floats(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_precision_numerator,\n            mean_precision_denominator,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_positive_finite_floats() {\n    // mean |sci_exponent| 1, mean precision 2\n    let values = &[\n        \"1.5\", \"1.0\", \"2.0\", \"1.0\", \"1.0\", \"2.0\", \"2.0\", \"1.8\", \"2.0\", \"1.0\", \"2.0\", \"2.0\", \"4.0\",\n        \"1.0\", \"1.0\", \"2.0\", \"0.1\", \"1.0\", \"0.2\", \"1.0\",\n    ];\n    let values_hex = &[\n        \"0x1.8#2\", \"0x1.0#1\", \"0x2.0#2\", \"0x1.0#2\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x1.c#3\",\n        \"0x2.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x4.0#1\", \"0x1.0#1\", \"0x1.0#3\", \"0x2.0#4\",\n        \"0x0.2#1\", \"0x1.0#1\", \"0x0.4#1\", \"0x1.0#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 166114),\n        (\"0.5\", 83464),\n        (\"2.0\", 83434),\n        (\"1.0\", 42010),\n        (\"0.2\", 41531),\n        (\"1.5\", 41521),\n        (\"4.0\", 41483),\n        (\"3.0\", 21125),\n        (\"0.1\", 20888),\n        (\"8.0\", 20800),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 166114),\n        (\"0x0.8#1\", 83464),\n        (\"0x2.0#1\", 83434),\n        (\"0x1.0#2\", 42010),\n        (\"0x0.4#1\", 41531),\n        (\"0x1.8#2\", 41521),\n        (\"0x4.0#1\", 41483),\n        (\"0x3.0#2\", 21125),\n        (\"0x0.2#1\", 20888),\n        (\"0x8.0#1\", 20800),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.102812885245132),\n        standard_deviation: NiceFloat(351.5541728670195),\n        skewness: NiceFloat(274.1565025440714),\n        excess_kurtosis: NiceFloat(92676.98806519402),\n    };\n    striped_random_positive_finite_floats_helper(\n        1,\n        1,\n        8,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, mean precision 64\n    let values = &[\n        \"1.8\",\n        \"1.999992251396406572893\",\n        \"2.0\",\n        \"1.000007629394303879793997\",\n        \"1.0\",\n        \"3.9999999999999999861222122955831198138315944982\",\n        \"2.00048828124999999999322373803755273042776921295151896098423\",\n        \"1.0000609\",\n        \"3.98439049720059301762375898\",\n        \"1.9921875\",\n        \"3.99609375186263\",\n        \"3.9921875\",\n        \"4.0\",\n        \"1.998046875\",\n        \"1.0000000894069671630893256317890172009801151\",\n        \"3.9999997615814209\",\n        \"0.2499990481\",\n        \"1.0000000000000000034694465383634065199217\",\n        \"0.49999999998545\",\n        \"1.9852905\",\n    ];\n    let values_hex = &[\n        \"0x1.c#3\",\n        \"0x1.ffff7e00003ffffffc#71\",\n        \"0x2.000000000#38\",\n        \"0x1.00007fffffc0003ffff8#79\",\n        \"0x1.00000#19\",\n        \"0x3.ffffffffffffff0000001fffffffffff8007fe#153\",\n        \"0x2.001fffffffffffffe000007fffffff0000000000000001ff8#195\",\n        \"0x1.0003fe#24\",\n        \"0x3.fc0103fff83fffffffff00#89\",\n        \"0x1.fe000000000000#57\",\n        \"0x3.ff000007fffc#48\",\n        \"0x3.fe000000#31\",\n        \"0x4.00000000000000#57\",\n        \"0x1.ff8000000000#48\",\n        \"0x1.00000180000000000fffffffffffff800000#145\",\n        \"0x3.fffffc0000000#54\",\n        \"0x0.3ffff0078#31\",\n        \"0x1.000000000000003fffff800001ffffff8#132\",\n        \"0x0.7ffffffff00#43\",\n        \"0x1.fc3c00#24\",\n    ];\n    let common_values = &[\n        (\"1.0\", 5069),\n        (\"0.5\", 2623),\n        (\"2.0\", 2623),\n        (\"1.0\", 2567),\n        (\"1.5\", 2547),\n        (\"1.8\", 2419),\n        (\"1.0\", 2408),\n        (\"1.9\", 2381),\n        (\"1.0\", 2336),\n        (\"1.0\", 2240),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 5069),\n        (\"0x0.8#1\", 2623),\n        (\"0x2.0#1\", 2623),\n        (\"0x1.0#2\", 2567),\n        (\"0x1.8#2\", 2547),\n        (\"0x1.c#3\", 2419),\n        (\"0x1.0#3\", 2408),\n        (\"0x1.e#4\", 2381),\n        (\"0x1.0#4\", 2336),\n        (\"0x1.00#6\", 2240),\n    ];\n    let sample_median = (\"1.4999997616\", Some(\"1.4999997616\"));\n    let sample_median_hex = (\"0x1.7ffffc00#32\", Some(\"0x1.7ffffc00#33\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.303344556597335),\n        standard_deviation: NiceFloat(516.4696271945669),\n        skewness: NiceFloat(332.951705809113),\n        excess_kurtosis: NiceFloat(144341.98602578667),\n    };\n    striped_random_positive_finite_floats_helper(\n        1,\n        1,\n        32,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 2\n    let values = &[\n        \"3.0e-37\", \"8.0e-34\", \"4.0e-6\", \"3.0e-45\", \"2.0e15\", \"5.0e-10\", \"2.0e4\", \"0.11\", \"0.0001\",\n        \"1.0e14\", \"2.0e34\", \"9.0e-13\", \"0.0001\", \"9.0e9\", \"1.3e33\", \"0.12\", \"0.00003\", \"5.0e18\",\n        \"0.06\", \"5.0e8\",\n    ];\n    let values_hex = &[\n        \"0x6.0E-31#2\",\n        \"0x4.0E-28#1\",\n        \"0x0.00004#2\",\n        \"0x1.0E-37#2\",\n        \"0x8.0E+12#1\",\n        \"0x2.0E-8#1\",\n        \"0x4.0E+3#1\",\n        \"0x0.1c#3\",\n        \"0x0.0008#1\",\n        \"0x8.0E+11#1\",\n        \"0x4.0E+28#1\",\n        \"0x1.0E-10#1\",\n        \"0x0.0008#1\",\n        \"0x2.0E+8#1\",\n        \"0x4.0E+27#3\",\n        \"0x0.20#4\",\n        \"0x0.0002#1\",\n        \"0x4.0E+15#1\",\n        \"0x0.1#1\",\n        \"0x2.0E+7#3\",\n    ];\n    let common_values = &[\n        (\"1.0\", 3831),\n        (\"0.2\", 3830),\n        (\"0.5\", 3826),\n        (\"2.0\", 3753),\n        (\"4.0\", 3716),\n        (\"8.0\", 3653),\n        (\"0.1\", 3639),\n        (\"0.06\", 3637),\n        (\"3.0e1\", 3632),\n        (\"2.0e1\", 3617),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 3831),\n        (\"0x0.4#1\", 3830),\n        (\"0x0.8#1\", 3826),\n        (\"0x2.0#1\", 3753),\n        (\"0x4.0#1\", 3716),\n        (\"0x8.0#1\", 3653),\n        (\"0x0.2#1\", 3639),\n        (\"0x0.1#1\", 3637),\n        (\"0x2.0E+1#1\", 3632),\n        (\"0x1.0E+1#1\", 3617),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.952075737355551e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_finite_floats_helper(\n        64,\n        1,\n        8,\n        1,\n        2,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, mean precision 64\n    let values = &[\n        \"3.3e-37\",\n        \"1.5407379862027135753234e-33\",\n        \"3.81469726562e-6\",\n        \"2.80261831076667765237162e-45\",\n        \"2.2518e15\",\n        \"9.3132257461547851239382575628885994987366592936e-10\",\n        \"16387.9999999999999999444888620036319676642853924988433283828\",\n        \"0.062503807\",\n        \"0.000243187896557653382423325133\",\n        \"280375465082880.0\",\n        \"4.1497810068414e34\",\n        \"1.81543669e-12\",\n        \"0.0001220703125\",\n        \"17163091968.0\",\n        \"1298074330690585590141422900609023.99951171875\",\n        \"0.24999998509883881\",\n        \"0.00006103492385\",\n        \"4611686018427387919.999998092651821934844\",\n        \"0.12499999999636\",\n        \"1.06584474e9\",\n    ];\n    let values_hex = &[\n        \"0x7.0E-31#3\",\n        \"0x7.fffdf80000fffffffE-28#71\",\n        \"0x0.00004000000000#38\",\n        \"0x1.00007fffffc0003ffff8E-37#79\",\n        \"0x8.0000E+12#19\",\n        \"0x3.ffffffffffffff0000001fffffffffff8007feE-8#153\",\n        \"0x4003.fffffffffffffc00000fffffffe0000000000000003ff#195\",\n        \"0x0.10003fe#24\",\n        \"0x0.000ff0040fffe0fffffffffc00#89\",\n        \"0xff0000000000.000#57\",\n        \"0x7.fe00000ffff8E+28#48\",\n        \"0x1.ff000000E-10#31\",\n        \"0x0.000800000000000000#57\",\n        \"0x3ff000000.0000#48\",\n        \"0x400000600000000003ffffffffff.ffe000000#145\",\n        \"0x0.3fffffc0000000#54\",\n        \"0x0.0003ffff0078#31\",\n        \"0x400000000000000f.ffffe000007fffffe0#132\",\n        \"0x0.1ffffffffc00#43\",\n        \"0x3.f87800E+7#24\",\n    ];\n    let common_values = &[\n        (\"2.0\", 130),\n        (\"2.0e1\", 129),\n        (\"0.2\", 122),\n        (\"3.0e1\", 117),\n        (\"0.004\", 116),\n        (\"1.0e5\", 114),\n        (\"0.02\", 112),\n        (\"0.00002\", 112),\n        (\"0.1\", 109),\n        (\"8.0\", 108),\n    ];\n    let common_values_hex = &[\n        (\"0x2.0#1\", 130),\n        (\"0x1.0E+1#1\", 129),\n        (\"0x0.4#1\", 122),\n        (\"0x2.0E+1#1\", 117),\n        (\"0x0.01#1\", 116),\n        (\"0x2.0E+4#1\", 114),\n        (\"0x0.04#1\", 112),\n        (\"0x0.0001#1\", 112),\n        (\"0x0.2#1\", 109),\n        (\"0x8.0#1\", 108),\n    ];\n    let sample_median = (\"1.12499988079071\", Some(\"1.1249998807907122255\"));\n    let sample_median_hex = (\"0x1.1ffffe000000#49\", Some(\"0x1.1ffffe0000007ffe#64\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.8054101301847865e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_finite_floats_helper(\n        64,\n        1,\n        32,\n        1,\n        64,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_finite_floats_fail_1() {\n    striped_random_positive_finite_floats(EXAMPLE_SEED, 1, 0, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_finite_floats_fail_2() {\n    striped_random_positive_finite_floats(EXAMPLE_SEED, 0, 1, 2, 1, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_finite_floats_fail_3() {\n    striped_random_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_finite_floats_fail_4() {\n    striped_random_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 1, 1, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_finite_floats_fail_5() {\n    striped_random_positive_finite_floats(EXAMPLE_SEED, 1, 1, 2, 3, 2, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_finite_floats_fail_6() {\n    striped_random_positive_finite_floats(EXAMPLE_SEED, 1, 1, 1, 0, 2, 1);\n}\n"
  },
  {
    "path": "malachite-float/tests/random/striped_random_positive_floats_with_precision.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_float::random::striped_random_positive_floats_with_precision;\nuse malachite_float::test_util::random::{\n    random_floats_helper_helper, random_floats_helper_helper_no_common_values,\n};\n\nfn striped_random_positive_floats_with_precision_helper(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    prec: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_common_values_hex: &[(&str, usize)],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper(\n        striped_random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            prec,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_common_values,\n        expected_common_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    )\n}\n\nfn striped_random_positive_floats_with_precision_helper_no_common_values(\n    mean_sci_exponent_abs_numerator: u64,\n    mean_sci_exponent_abs_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    prec: u64,\n    expected_values: &[&str],\n    expected_values_hex: &[&str],\n    expected_median: (&str, Option<&str>),\n    expected_median_hex: (&str, Option<&str>),\n    expected_moment_stats: MomentStats,\n) {\n    random_floats_helper_helper_no_common_values(\n        striped_random_positive_floats_with_precision(\n            EXAMPLE_SEED,\n            mean_sci_exponent_abs_numerator,\n            mean_sci_exponent_abs_denominator,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            prec,\n        ),\n        expected_values,\n        expected_values_hex,\n        expected_median,\n        expected_median_hex,\n        expected_moment_stats,\n    )\n}\n\n#[test]\nfn test_striped_random_positive_floats_with_precision() {\n    // mean |sci_exponent| 1, precision 1\n    let values = &[\n        \"1.0\", \"1.0\", \"2.0\", \"1.0\", \"1.0\", \"2.0\", \"2.0\", \"1.0\", \"2.0\", \"1.0\", \"2.0\", \"2.0\", \"4.0\",\n        \"1.0\", \"1.0\", \"2.0\", \"0.1\", \"1.0\", \"0.2\", \"1.0\",\n    ];\n    let values_hex = &[\n        \"0x1.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x1.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x1.0#1\",\n        \"0x2.0#1\", \"0x1.0#1\", \"0x2.0#1\", \"0x2.0#1\", \"0x4.0#1\", \"0x1.0#1\", \"0x1.0#1\", \"0x2.0#1\",\n        \"0x0.2#1\", \"0x1.0#1\", \"0x0.4#1\", \"0x1.0#1\",\n    ];\n    let common_values = &[\n        (\"1.0\", 333085),\n        (\"2.0\", 167041),\n        (\"0.5\", 166671),\n        (\"0.2\", 83200),\n        (\"4.0\", 83177),\n        (\"8.0\", 41643),\n        (\"0.1\", 41551),\n        (\"0.06\", 20981),\n        (\"2.0e1\", 20919),\n        (\"3.0e1\", 10411),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 333085),\n        (\"0x2.0#1\", 167041),\n        (\"0x0.8#1\", 166671),\n        (\"0x0.4#1\", 83200),\n        (\"0x4.0#1\", 83177),\n        (\"0x8.0#1\", 41643),\n        (\"0x0.2#1\", 41551),\n        (\"0x0.1#1\", 20981),\n        (\"0x1.0E+1#1\", 20919),\n        (\"0x2.0E+1#1\", 10411),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(6.111051015726221),\n        standard_deviation: NiceFloat(305.2547556508084),\n        skewness: NiceFloat(297.86495510456103),\n        excess_kurtosis: NiceFloat(112470.88988361698),\n    };\n    striped_random_positive_floats_with_precision_helper(\n        1,\n        1,\n        8,\n        1,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, precision 10\n    let values = &[\n        \"1.998\", \"1.0\", \"3.996\", \"1.123\", \"1.0\", \"3.996\", \"2.0\", \"1.971\", \"3.996\", \"1.998\",\n        \"3.996\", \"3.996\", \"7.99\", \"1.0\", \"1.998\", \"2.0\", \"0.2498\", \"1.998\", \"0.2505\", \"1.0\",\n    ];\n    let values_hex = &[\n        \"0x1.ff8#10\",\n        \"0x1.000#10\",\n        \"0x3.ff#10\",\n        \"0x1.1f8#10\",\n        \"0x1.000#10\",\n        \"0x3.ff#10\",\n        \"0x2.00#10\",\n        \"0x1.f88#10\",\n        \"0x3.ff#10\",\n        \"0x1.ff8#10\",\n        \"0x3.ff#10\",\n        \"0x3.ff#10\",\n        \"0x7.fe#10\",\n        \"0x1.000#10\",\n        \"0x1.ff8#10\",\n        \"0x2.00#10\",\n        \"0x0.3ff#10\",\n        \"0x1.ff8#10\",\n        \"0x0.402#10\",\n        \"0x1.000#10\",\n    ];\n    let common_values = &[\n        (\"1.998\", 129180),\n        (\"1.0\", 129087),\n        (\"2.0\", 64918),\n        (\"0.999\", 64782),\n        (\"3.996\", 64781),\n        (\"0.5\", 64602),\n        (\"7.99\", 32474),\n        (\"0.4995\", 32422),\n        (\"4.0\", 32040),\n        (\"0.25\", 32029),\n    ];\n    let common_values_hex = &[\n        (\"0x1.ff8#10\", 129180),\n        (\"0x1.000#10\", 129087),\n        (\"0x2.00#10\", 64918),\n        (\"0x0.ffc#10\", 64782),\n        (\"0x3.ff#10\", 64781),\n        (\"0x0.800#10\", 64602),\n        (\"0x7.fe#10\", 32474),\n        (\"0x0.7fe#10\", 32422),\n        (\"0x4.00#10\", 32040),\n        (\"0x0.400#10\", 32029),\n    ];\n    let sample_median = (\"1.5\", None);\n    let sample_median_hex = (\"0x1.800#10\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.349869877794564),\n        standard_deviation: NiceFloat(520.151410587591),\n        skewness: NiceFloat(337.57543940728004),\n        excess_kurtosis: NiceFloat(145252.3259106671),\n    };\n    striped_random_positive_floats_with_precision_helper(\n        1,\n        1,\n        32,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 1, precision 64\n    let values = &[\n        \"1.9999999925494194034\",\n        \"1.2499999999999999999\",\n        \"3.9999999925494194031\",\n        \"1.0000000000018189893\",\n        \"1.0000610351562482236\",\n        \"3.9999389648437526645\",\n        \"2.0\",\n        \"1.9843750001164152663\",\n        \"3.8750004768369308294\",\n        \"1.9999923706636728582\",\n        \"3.9999999999999431566\",\n        \"3.9960937504656541819\",\n        \"7.9999999999998863132\",\n        \"1.0000305175781248889\",\n        \"1.9999999999990905053\",\n        \"2.0000000001164153216\",\n        \"0.24999999906869163623\",\n        \"1.9990539550781179222\",\n        \"0.25\",\n        \"1.0000000000001136799\",\n    ];\n    let values_hex = &[\n        \"0x1.ffffffe000000006#64\",\n        \"0x1.3ffffffffffffffe#64\",\n        \"0x3.ffffffe000000000#64\",\n        \"0x1.0000000001fffffe#64\",\n        \"0x1.0003ffffffff8000#64\",\n        \"0x3.fffc00000000c000#64\",\n        \"0x2.0000000000000000#64\",\n        \"0x1.fc0000007ffffc00#64\",\n        \"0x3.e00007ffffc00000#64\",\n        \"0x1.ffff80003fff0000#64\",\n        \"0x3.fffffffffff00000#64\",\n        \"0x3.ff000001fffe0000#64\",\n        \"0x7.ffffffffffe00000#64\",\n        \"0x1.0001fffffffff7fe#64\",\n        \"0x1.ffffffffff000000#64\",\n        \"0x2.000000007ffffffc#64\",\n        \"0x0.3ffffffc0003ffffc#64\",\n        \"0x1.ffc1fffffffe01fe#64\",\n        \"0x0.40000000000000000#64\",\n        \"0x1.00000000001fff80#64\",\n    ];\n    let sample_median = (\"1.5\", None);\n    let sample_median_hex = (\"0x1.8000000000000000#64\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9.337530231284171),\n        standard_deviation: NiceFloat(520.317614819243),\n        skewness: NiceFloat(340.99301578218797),\n        excess_kurtosis: NiceFloat(147660.4928189293),\n    };\n    striped_random_positive_floats_with_precision_helper_no_common_values(\n        1,\n        1,\n        32,\n        1,\n        64,\n        values,\n        values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, precision 1\n    let values = &[\n        \"2.0e-37\", \"8.0e-34\", \"4.0e-6\", \"3.0e-45\", \"2.0e15\", \"5.0e-10\", \"2.0e4\", \"0.06\", \"0.0001\",\n        \"1.0e14\", \"2.0e34\", \"9.0e-13\", \"0.0001\", \"9.0e9\", \"1.0e33\", \"0.1\", \"0.00003\", \"5.0e18\",\n        \"0.06\", \"5.0e8\",\n    ];\n    let values_hex = &[\n        \"0x4.0E-31#1\",\n        \"0x4.0E-28#1\",\n        \"0x0.00004#1\",\n        \"0x1.0E-37#1\",\n        \"0x8.0E+12#1\",\n        \"0x2.0E-8#1\",\n        \"0x4.0E+3#1\",\n        \"0x0.1#1\",\n        \"0x0.0008#1\",\n        \"0x8.0E+11#1\",\n        \"0x4.0E+28#1\",\n        \"0x1.0E-10#1\",\n        \"0x0.0008#1\",\n        \"0x2.0E+8#1\",\n        \"0x4.0E+27#1\",\n        \"0x0.2#1\",\n        \"0x0.0002#1\",\n        \"0x4.0E+15#1\",\n        \"0x0.1#1\",\n        \"0x2.0E+7#1\",\n    ];\n    let common_values = &[\n        (\"1.0\", 7698),\n        (\"0.2\", 7624),\n        (\"0.5\", 7597),\n        (\"2.0\", 7563),\n        (\"4.0\", 7402),\n        (\"8.0\", 7362),\n        (\"0.06\", 7323),\n        (\"0.1\", 7239),\n        (\"3.0e1\", 7225),\n        (\"2.0e1\", 7161),\n    ];\n    let common_values_hex = &[\n        (\"0x1.0#1\", 7698),\n        (\"0x0.4#1\", 7624),\n        (\"0x0.8#1\", 7597),\n        (\"0x2.0#1\", 7563),\n        (\"0x4.0#1\", 7402),\n        (\"0x8.0#1\", 7362),\n        (\"0x0.1#1\", 7323),\n        (\"0x0.2#1\", 7239),\n        (\"0x2.0E+1#1\", 7225),\n        (\"0x1.0E+1#1\", 7161),\n    ];\n    let sample_median = (\"1.0\", None);\n    let sample_median_hex = (\"0x1.0#1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.9680504915704222e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_floats_with_precision_helper(\n        64,\n        1,\n        8,\n        1,\n        1,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, precision 64\n    let values = &[\n        \"3.758e-37\",\n        \"7.7e-34\",\n        \"7.62e-6\",\n        \"3.147e-45\",\n        \"2.252e15\",\n        \"9.304e-10\",\n        \"1.638e4\",\n        \"0.1232\",\n        \"0.0002439\",\n        \"2.812e14\",\n        \"4.15e34\",\n        \"1.817e-12\",\n        \"0.0002439\",\n        \"8.59e9\",\n        \"2.594e33\",\n        \"0.125\",\n        \"0.00006098\",\n        \"9.214e18\",\n        \"0.0626\",\n        \"5.37e8\",\n    ];\n    let values_hex = &[\n        \"0x7.feE-31#10\",\n        \"0x4.00E-28#10\",\n        \"0x0.00007fe#10\",\n        \"0x1.1f8E-37#10\",\n        \"0x8.00E+12#10\",\n        \"0x3.ffE-8#10\",\n        \"0x4.00E+3#10\",\n        \"0x0.1f88#10\",\n        \"0x0.000ffc#10\",\n        \"0xf.fcE+11#10\",\n        \"0x7.feE+28#10\",\n        \"0x1.ff8E-10#10\",\n        \"0x0.000ffc#10\",\n        \"0x2.00E+8#10\",\n        \"0x7.feE+27#10\",\n        \"0x0.200#10\",\n        \"0x0.0003ff#10\",\n        \"0x7.feE+15#10\",\n        \"0x0.1008#10\",\n        \"0x2.00E+7#10\",\n    ];\n    let common_values = &[\n        (\"1.0\", 3037),\n        (\"1.998\", 2989),\n        (\"3.996\", 2983),\n        (\"0.5\", 2957),\n        (\"0.25\", 2940),\n        (\"0.4995\", 2931),\n        (\"0.999\", 2926),\n        (\"2.0\", 2913),\n        (\"15.98\", 2904),\n        (\"7.99\", 2887),\n    ];\n    let common_values_hex = &[\n        (\"0x1.000#10\", 3037),\n        (\"0x1.ff8#10\", 2989),\n        (\"0x3.ff#10\", 2983),\n        (\"0x0.800#10\", 2957),\n        (\"0x0.400#10\", 2940),\n        (\"0x0.7fe#10\", 2931),\n        (\"0x0.ffc#10\", 2926),\n        (\"0x2.00#10\", 2913),\n        (\"0xf.fc#10\", 2904),\n        (\"0x7.fe#10\", 2887),\n    ];\n    let sample_median = (\"1.127\", Some(\"1.188\"));\n    let sample_median_hex = (\"0x1.208#10\", Some(\"0x1.300#10\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.932257134524397e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_floats_with_precision_helper(\n        64,\n        1,\n        32,\n        1,\n        10,\n        values,\n        values_hex,\n        common_values,\n        common_values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n\n    // mean |sci_exponent| 64, precision 64\n    let values = &[\n        \"3.7615819086183353829e-37\",\n        \"9.6296497219361792644e-34\",\n        \"7.6293945170391452848e-6\",\n        \"2.8025969286547320357e-45\",\n        \"2251937252638716.0\",\n        \"9.3130836376076393401e-10\",\n        \"16384.0\",\n        \"0.124023437507275954145\",\n        \"0.00023651125957256657895\",\n        \"281473902977023.5\",\n        \"4.1538374868278030732e34\",\n        \"1.817213046918211231e-12\",\n        \"0.00024414062499999653055\",\n        \"8590196735.999999045\",\n        \"2.5961484292662332226e33\",\n        \"0.1250000000072759576\",\n        \"0.000061035156022629794\",\n        \"9219009174715727999.5\",\n        \"0.0625\",\n        \"536870912.00006103143\",\n    ];\n    let values_hex = &[\n        \"0x7.ffffff8000000018E-31#64\",\n        \"0x4.fffffffffffffff8E-28#64\",\n        \"0x0.00007ffffffc000000000#64\",\n        \"0x1.0000000001fffffeE-37#64\",\n        \"0x8001ffffffffc.000#64\",\n        \"0x3.fffc00000000c000E-8#64\",\n        \"0x4000.0000000000000#64\",\n        \"0x0.1fc0000007ffffc00#64\",\n        \"0x0.000f80001fffff00000#64\",\n        \"0xffffc0001fff.8000#64\",\n        \"0x7.ffffffffffe00000E+28#64\",\n        \"0x1.ff800000ffff0000E-10#64\",\n        \"0x0.000fffffffffffc0000#64\",\n        \"0x20003ffff.ffffeffc#64\",\n        \"0x7.fffffffffc000000E+27#64\",\n        \"0x0.2000000007ffffffc#64\",\n        \"0x0.0003ffffffc0003ffffc#64\",\n        \"0x7ff07fffffff807f.8#64\",\n        \"0x0.10000000000000000#64\",\n        \"0x20000000.0003fff00#64\",\n    ];\n    let sample_median = (\"1.2490234375\", Some(\"1.2490234449505805968\"));\n    let sample_median_hex = (\"0x1.3fc0000000000000#64\", Some(\"0x1.3fc0001ffffffffe#64\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.9361009831408444e255),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_floats_with_precision_helper_no_common_values(\n        64,\n        1,\n        32,\n        1,\n        64,\n        values,\n        values_hex,\n        sample_median,\n        sample_median_hex,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_floats_with_precision_fail_1() {\n    striped_random_positive_floats_with_precision(EXAMPLE_SEED, 1, 0, 2, 1, 2);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_floats_with_precision_fail_2() {\n    striped_random_positive_floats_with_precision(EXAMPLE_SEED, 0, 1, 2, 1, 2);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_floats_with_precision_fail_3() {\n    striped_random_positive_floats_with_precision(EXAMPLE_SEED, 1, 1, 2, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_floats_with_precision_fail_4() {\n    striped_random_positive_floats_with_precision(EXAMPLE_SEED, 1, 1, 2, 3, 2);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_floats_with_precision_fail_5() {\n    striped_random_positive_floats_with_precision(EXAMPLE_SEED, 1, 1, 1, 0, 2);\n}\n"
  },
  {
    "path": "malachite-nz/.gitignore",
    "content": "target\n*.bk\n.idea*\n*.iml\n"
  },
  {
    "path": "malachite-nz/Cargo.toml",
    "content": "[package]\nname = \"malachite-nz\"\nversion = \"0.9.1\"\nauthors = [\"Mikhail Hogrefe <mikhailhogrefe@gmail.com>\"]\nrust-version.workspace = true\nedition.workspace = true\ndescription = \"The bignum types Natural and Integer, with efficient algorithms partially derived from GMP and FLINT.\"\nreadme = \"README.md\"\nhomepage = \"https://malachite.rs/\"\nrepository = \"https://github.com/mhogrefe/malachite\"\nlicense = \"LGPL-3.0-only\"\nkeywords = [\"mathematics\", \"math\", \"numerics\", \"bignum\"]\ncategories = [\"mathematics\"]\n\n[lib]\nname = \"malachite_nz\"\npath = \"src/lib.rs\"\n\n[[bin]]\nname = \"malachite_nz_main\"\npath = \"src/bin.rs\"\n\n[dependencies]\nitertools = { version = \"0.14.0\", default-features = false, features = [\"use_alloc\"] }\nlibm = { version = \"0.2.16\", default-features = false }\nmalachite-base = { version = \"0.9.1\", default-features = false, path = \"../malachite-base\" }\nserde = { version = \"1.0.228\", optional = true, default-features = false, features = [\"alloc\", \"derive\"] }\nwide = { version = \"1.1.1\" }\n\nindoc = { version = \"2.0.7\", optional = true}\npyo3 = { version = \"0.27.2\", optional = true }\nserde_json = { version = \"1.0.149\", optional = true }\nnum = { version = \"0.4.3\", optional = true, features = [\"serde\"] }\nrug = { version = \"1.28.1\", default-features = false, optional = true, features = [\"integer\", \"serde\"] }\n\nembed-doc-image = { version = \"0.1.4\", optional = true }\n\n[dev-dependencies]\nmalachite-nz = { path = \".\", features = [\"test_build\"] }\n\n[build-dependencies]\npyo3-build-config = { version = \"0.27.2\", features = [\"resolve-config\"], optional = true }\n\n[features]\ndefault = [\"std\"]\nstd = [\"malachite-base/std\"]\n32_bit_limbs = []\nrandom = [\"malachite-base/random\"]\nenable_pyo3 = [\"pyo3\", \"pyo3-build-config\"]\nenable_serde = [\"serde\"]\ntest_build = [\"malachite-base/test_build\", \"random\", \"serde\", \"serde_json\", \"num\", \"rug\", \"pyo3\", \"pyo3-build-config\", \"indoc\"]\nbin_build = [\"test_build\"]\nfloat_helpers = []\ndoc-images = [\"embed-doc-image\"]\n\n[package.metadata.docs.rs]\n# docs.rs uses a nightly compiler, so by instructing it to use our `doc-images` feature we\n# ensure that it will render any images that we may have in inner attribute documentation.\nfeatures = [\"doc-images\", \"random\"]\nrustdoc-args = [ \"--html-in-header\", \"katex-header.html\" ]\n"
  },
  {
    "path": "malachite-nz/README.md",
    "content": "- [crates.io](https://crates.io/crates/malachite-nz)\n- [docs.rs](https://docs.rs/malachite-nz/latest/malachite_nz/)\n\nRather than using this crate directly, use the\n[`malachite`](https://crates.io/crates/malachite) meta-crate. It re-exports all of this crate's\npublic members.\n\nIn `malachite-nz`'s doctests you will frequently see import paths beginning with\n`malachite_nz::`. When using the `malachite` crate, replace this part of the paths with\n`malachite::`.\n\nThe import paths of the `Natural` and `Integer` types are shortened further, to\n`malachite::Natural` and `malachite::Integer`.\n\n# malachite-nz\nThis crate defines\n[`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s\n(non-negative integers) and\n[`Integer`](https://docs.rs/malachite-nz/latest/malachite_nz/integer/struct.Integer.html)s. Unlike\nprimitive integers ([`u32`](https://doc.rust-lang.org/nightly/std/primitive.u32.html),\n[`i32`](https://doc.rust-lang.org/nightly/std/primitive.i32.html), and so on), these may be\narbitrarily large. The name of this crate refers to the mathematical symbols for natural numbers\nand integers, ℕ and ℤ.\n- There are many functions defined on\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s and\n  [`Integer`](https://docs.rs/malachite-nz/latest/malachite_nz/integer/struct.Integer.html)s. These\n  include\n  - All the ones you'd expect, like addition, subtraction, multiplication, and integer division;\n  - Implementations of\n    [`DivRound`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.DivRound.html),\n    which provides division that rounds according to a specified\n    [`RoundingMode`](https://docs.rs/malachite-base/latest/malachite_base/rounding_modes/enum.RoundingMode.html);\n  - Various mathematical functions, like implementations of\n    [`FloorSqrt`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.FloorSqrt.html)\n    and\n    [`Gcd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.Gcd.html);\n  - Modular arithmetic functions, like implementations of\n    [`ModAdd`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModAdd.html)\n    and\n    [`ModPow`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPow.html),\n    and of traits for arithmetic modulo a power of 2, like\n    [`ModPowerOf2Add`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPowerOf2Add.html)\n    and\n    [`ModPowerOf2Pow`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPowerOf2Pow.html);\n  - Various functions for logic and bit manipulation, like\n    [`BitAnd`](https://doc.rust-lang.org/nightly/core/ops/trait.BitAnd.html) and\n    [`BitAccess`](https://docs.rs/malachite-base/latest/malachite_base/num/logic/traits/trait.BitAccess.html).\n- The implementations of these functions use high-performance algorithms that work efficiently\n  for large numbers. For example, multiplication uses the naive quadratic algorithm, or one of\n  13 variants of\n  [Toom-Cook multiplication](https://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication),\n  or\n  [Schönhage-Strassen (FFT) multiplication](https://en.wikipedia.org/wiki/Schonhage-Strassen_algorithm),\n  depending on the input size.\n- Small numbers are also handled efficiently. Any\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html) smaller\n  than 2<sup>64</sup> does not use any allocated memory, and working with such numbers is almost as\n  fast as working with primitive integers. As a result, Malachite does not provide implementations\n  for _e.g._ adding a\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)\n  to a [`u64`](https://doc.rust-lang.org/nightly/std/primitive.u64.html), since the\n  [`u64`](https://doc.rust-lang.org/nightly/std/primitive.u64.html) can be converted to a\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html) very\n  cheaply.\n- Malachite handles memory intelligently. Consider the problem of adding a 1000-bit\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html) and a\n  500-bit\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html). If we\n  only have references to the\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s, then\n  we must allocate new memory for the result, and this is what the `&Natural + &Natural`\n  implementation does. However, if we can take the first (larger)\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html) by\n  value, then we do not need to allocate any memory (except in the unlikely case of a carry): we\n  can reuse the memory of the first\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html) to\n  store the result, and this is what the `Natural + &Natural` implementation does. On the other\n  hand, if we can only take the second (smaller)\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html) by\n  value, then we only have 500 bits of memory available, which is not enough to store the sum. In\n  this case, the [`Vec`](https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html) containing\n  the smaller\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)'s data\n  can be extended to hold 1000 bits, in hopes that this will be more efficient than allocating 1000\n  bits in a completely new [`Vec`](https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html).\n  Finally, if both\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s are\n  taken by value, then the `Natural + Natural` implementation chooses to reuse the memory of the\n  larger one.\n\n  Now consider what happens when evaluating the expression `&x + &y + &z`, where each [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html) has\n  _n_ bits. Malachite must allocate about _n_ bits for the result, but what about the intermediate\n  sum `&x + &y`? Does Malachite need to allocate another _n_ bits for that, for a total of 2 _n_\n  bits? No! Malachite first allocates _n_ bits for `&x + &y`, but then that partial sum is taken by\n  _value_ using the `Natural + &Natural` implementation described above; so those _n_ bits are\n  reused for the final sum.\n\n# Limbs\nLarge [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s\nand [`Integer`](https://docs.rs/malachite-nz/latest/malachite_nz/integer/struct.Integer.html)s\nstore their data as [`Vec`](https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html)s of some\nprimitive type. The elements of these\n[`Vec`](https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html)s are called \"limbs\" in GMP\nterminology, since they're large digits. By default, the type of a `Limb` is\n[`u64`](https://doc.rust-lang.org/nightly/std/primitive.u64.html), but you can set it to\n[`u32`](https://doc.rust-lang.org/nightly/std/primitive.u32.html) using the `32_bit_limbs` feature.\n\n# Demos and benchmarks\nThis crate comes with a `bin` target that can be used for running demos and benchmarks.\n- Almost all of the public functions in this crate have an associated demo. Running a demo shows\n  you a function's behavior on a large number of inputs. For example, to demo the\n  [`mod_pow`](https://docs.rs/malachite-base/latest/malachite_base/num/arithmetic/traits/trait.ModPow.html#tymethod.mod_pow)\n  function on [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s, you can use the following command:\n  ```text\n  cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_natural_mod_pow\n  ```\n  This command uses the `exhaustive` mode, which generates every possible input, generally\n  starting with the simplest input and progressing to more complex ones. Another mode is\n  `random`. The `-l` flag specifies how many inputs should be generated.\n- You can use a similar command to run benchmarks. The following command benchmarks various\n  GCD algorithms for [`u64`](https://doc.rust-lang.org/nightly/std/primitive.u64.html)s:\n  ```text\n  cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n      benchmark_natural_gcd_algorithms -o gcd-bench.gp\n  ```\n  or GCD implementations of other libraries:\n  ```text\n  cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n      benchmark_natural_gcd_library_comparison -o gcd-bench.gp\n  ```\n  This creates a file called gcd-bench.gp. You can use gnuplot to create an SVG from it like\n  so:\n  ```text\n  gnuplot -e \"set terminal svg; l \\\"gcd-bench.gp\\\"\" > gcd-bench.svg\n  ```\n\nThe list of available demos and benchmarks is not documented anywhere; you must find them by\nbrowsing through\n[`bin_util/demo_and_bench`](https://github.com/mhogrefe/malachite/tree/master/malachite-nz/src/bin_util/demo_and_bench).\n\n# Features\n- `32_bit_limbs`: Sets the type of `Limb` to [`u32`](https://doc.rust-lang.org/nightly/std/primitive.u32.html) instead of the default, [`u64`](https://doc.rust-lang.org/nightly/std/primitive.u64.html).\n- `random`: This feature provides some functions for randomly generating values. It is off by\n  default to avoid pulling in some extra dependencies.\n- `enable_serde`: Enables serialization and deserialization using [serde](`https://serde.rs/`).\n- `test_build`: A large proportion of the code in this crate is only used for testing. For a\n  typical user, building this code would result in an unnecessarily long compilation time and\n  an unnecessarily large binary. Some of it is also used for testing\n  [`malachite-q`](https://crates.io/crates/malachite-q), so it can't just be confined to the\n  `tests` directory. My solution is to only build this code when the `test_build` feature is\n  enabled. If you want to run unit tests, you must enable `test_build`. However, doctests don't\n  require it, since they only test the public interface. Enabling this feature also enables\n  `random`.\n- `bin_build`: This feature is used to build the code for demos and benchmarks, which also\n  takes a long time to build. Enabling this feature also enables `test_build` and `random`.\n\nMalachite is developed by Mikhail Hogrefe. Thanks to b4D8, florian1345, konstin, Rowan Hart, YunWon Jeong, Park Joon-Kyu, Antonio Mamić, OliverNChalk, shekohex, and skycloudd for additional contributions.\n\nCopyright © 2026 Mikhail Hogrefe\n"
  },
  {
    "path": "malachite-nz/build.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// PyO3 integration contributed by Antonio Mamić.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nfn main() {\n    #[cfg(feature = \"enable_pyo3\")]\n    pyo3_build_config::use_pyo3_cfgs();\n}\n"
  },
  {
    "path": "malachite-nz/extra-tests.py",
    "content": "import subprocess\n\ndef substitute_constant(const_prefix, input_filename, output_filename, value):\n    prefix = f'{const_prefix}: usize = '\n    with open(input_filename, 'r') as in_f:\n        with open(output_filename, 'w') as out_f:\n            for line in in_f.readlines():\n                line = line.rstrip()\n                if line.startswith(prefix):\n                    original_value = line[len(prefix):-1]\n                    out_f.write(prefix + value + ';\\n')\n                else:\n                    out_f.write(line + '\\n')\n\ndef substitute_hgcd_reduce_threshold(input_filename, output_filename, value):\n    substitute_constant('const HGCD_REDUCE_THRESHOLD', input_filename, output_filename, value)\n\npath = 'src/natural/arithmetic/gcd/half_gcd.rs'\nassert subprocess.call('cp ' + path + ' backup.rs', shell = True) == 0\nsubstitute_hgcd_reduce_threshold('backup.rs', 'temp.rs', '200')\nassert subprocess.call('mv temp.rs ' + path, shell = True) == 0\nassert subprocess.call('cargo test --test lib --features 32_bit_limbs --features serde --features test_build -- test_limbs_gcd_reduced', shell = True) == 0\nassert subprocess.call('cargo test --test lib --features serde --features test_build -- test_limbs_gcd_reduced', shell = True) == 0\nassert subprocess.call('mv backup.rs ' + path, shell = True) == 0\n"
  },
  {
    "path": "malachite-nz/images/natural-mem-layout.asy",
    "content": "defaultpen(fontsize(14pt));\nsize(400,400);\nreal height = 10;\nreal tag_width = 35;\nreal small_width = 26;\nreal text_offset = 17.5;\nreal text_offset_2 = 49;\nreal text_offset_3 = 104;\nreal col_2 = 90;\nstring small_label = \"{\\tt Natural::Small}\";\nstring large_label = \"{\\tt Natural::Large}\";\n\nfilldraw(box((-5,5),(121,-85)),rgb(150.0/255,150.0/255,150.0/255));\n\nfilldraw(box((col_2,-height),(col_2+small_width,-2*height)),lightblue);\nlabel(\"{\\tt 0xa8dc8417 }\", (text_offset_3,-3*height/2));\nfilldraw(box((col_2,-2*height),(col_2+small_width,-3*height)),lightblue);\nlabel(\"{\\tt 0x000009af }\", (text_offset_3,-5*height/2));\n\nfilldraw(box((col_2,-4*height),(col_2+small_width,-5*height)),lightblue);\nlabel(\"{\\tt 0xd2d335fb }\", (text_offset_3,-9*height/2));\nfilldraw(box((col_2,-5*height),(col_2+small_width,-6*height)),lightblue);\nlabel(\"{\\tt 0xce285713 }\", (text_offset_3,-11*height/2));\nfilldraw(box((col_2,-6*height),(col_2+small_width,-7*height)),lightblue);\nlabel(\"{\\tt 0x005dd267 }\", (text_offset_3,-13*height/2));\n\ndraw((tag_width+small_width,-13*height/2) -- (70,-13*height/2));\ndraw((70,-13*height/2) -- (70,-3*height/2));\ndraw((70,-3*height/2) -- (col_2,-3*height/2), arrow=Arrow);\ndraw((tag_width+small_width,-15*height/2) -- (80,-15*height/2));\ndraw((80,-15*height/2) -- (80,-9*height/2));\ndraw((80,-9*height/2) -- (col_2,-9*height/2), arrow=Arrow);\n\nfilldraw(box((0,0),(tag_width,-height)),mediumgray);\nlabel(small_label, (text_offset,-height/2));\nfilldraw(box((tag_width,0),(tag_width+small_width,-height)),lightblue);\nlabel(\"{\\tt 0x00000002 }\", (text_offset_2,-height/2));\n\nfilldraw(box((0,-height),(tag_width,-2*height)),mediumgray);\nlabel(small_label, (text_offset,-3*height/2));\nfilldraw(box((tag_width,-height),(tag_width+small_width,-2*height)),lightblue);\nlabel(\"{\\tt 0x00000003 }\", (text_offset_2,-3*height/2));\n\nfilldraw(box((0,-2*height),(tag_width,-3*height)),mediumgray);\nlabel(small_label, (text_offset,-5*height/2));\nfilldraw(box((tag_width,-2*height),(tag_width+small_width,-3*height)),lightblue);\nlabel(\"{\\tt 0x00000007 }\", (text_offset_2,-5*height/2));\n\nfilldraw(box((0,-3*height),(tag_width,-4*height)),mediumgray);\nlabel(small_label, (text_offset,-7*height/2));\nfilldraw(box((tag_width,-3*height),(tag_width+small_width,-4*height)),lightblue);\nlabel(\"{\\tt 0x0000002b }\", (text_offset_2,-7*height/2));\n\nfilldraw(box((0,-4*height),(tag_width,-5*height)),mediumgray);\nlabel(small_label, (text_offset,-9*height/2));\nfilldraw(box((tag_width,-4*height),(tag_width+small_width,-5*height)),lightblue);\nlabel(\"{\\tt 0x0000070f }\", (text_offset_2,-9*height/2));\n\nfilldraw(box((0,-5*height),(tag_width,-6*height)),mediumgray);\nlabel(small_label, (text_offset,-11*height/2));\nfilldraw(box((tag_width,-5*height),(tag_width+small_width,-6*height)),lightblue);\nlabel(\"{\\tt 0x0031cbd3 }\", (text_offset_2,-11*height/2));\n\nfilldraw(box((0,-6*height),(tag_width,-7*height)),mediumgray);\nlabel(large_label, (text_offset,-13*height/2));\nfilldraw(box((tag_width,-6*height),(tag_width+small_width,-7*height)),mediumgray);\nlabel(\"{\\tt Vec }\", (text_offset_2,-13*height/2));\n\nfilldraw(box((0,-7*height),(tag_width,-8*height)),mediumgray);\nlabel(large_label, (text_offset,-15*height/2));\nfilldraw(box((tag_width,-7*height),(tag_width+small_width,-8*height)),mediumgray);\nlabel(\"{\\tt Vec }\", (text_offset_2,-15*height/2));\n"
  },
  {
    "path": "malachite-nz/katex-header.html",
    "content": "<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css\" integrity=\"sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y\" crossorigin=\"anonymous\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js\"                  integrity=\"sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js\"    integrity=\"sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe\" crossorigin=\"anonymous\"></script>\n<script>\n    document.addEventListener(\"DOMContentLoaded\", function() {\n        renderMathInElement(document.body, {\n            delimiters: [\n                {left: \"$$\", right: \"$$\", display: true},\n                {left: \"\\\\(\", right: \"\\\\)\", display: false},\n                {left: \"$\", right: \"$\", display: false},\n                {left: \"\\\\[\", right: \"\\\\]\", display: true}\n            ]\n        });\n    });\n</script>\n"
  },
  {
    "path": "malachite-nz/rustfmt.toml",
    "content": "max_width = 100\narray_width = 100\n"
  },
  {
    "path": "malachite-nz/src/bin.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n\n#[cfg(feature = \"bin_build\")]\nextern crate itertools;\n#[cfg(feature = \"bin_build\")]\n#[macro_use]\nextern crate malachite_base;\n#[cfg(feature = \"bin_build\")]\nextern crate malachite_nz;\n#[cfg(feature = \"bin_build\")]\nextern crate num;\n#[cfg(feature = \"bin_build\")]\nextern crate rug;\n#[cfg(feature = \"bin_build\")]\nextern crate serde;\n#[cfg(feature = \"bin_build\")]\nextern crate serde_json;\n\n#[cfg(feature = \"bin_build\")]\nuse crate::bin_util::demo_and_bench::register;\n#[cfg(feature = \"bin_build\")]\nuse crate::bin_util::generate::digits_data::generate_string_data;\n#[cfg(feature = \"bin_build\")]\nuse crate::bin_util::generate::factorial_data::generate_factorial_data;\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::Runner;\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::cmd::read_command_line_arguments;\n\n// Examples:\n//\n// ```\n// cargo run --release --features bin_build -- -l 100000 -m special_random -d\n//     demo_natural_from_unsigned_u128 -c \"mean_run_length_n 4 mean_run_length_d 1\"\n//\n// cargo run --release --features bin_build -- -l 100000 -m random -b\n//     benchmark_limbs_to_digits_small_base_algorithms\n//\n// cargo run --features bin_build -- -g digits_data\n// ```\n#[cfg(feature = \"bin_build\")]\nfn main() {\n    let args = read_command_line_arguments(\"malachite-nz test utils\");\n    let mut runner = Runner::new();\n    register(&mut runner);\n    if let Some(demo_key) = args.demo_key {\n        runner.run_demo(&demo_key, args.generation_mode, &args.config, args.limit);\n    } else if let Some(bench_key) = args.bench_key {\n        runner.run_bench(\n            &bench_key,\n            args.generation_mode,\n            &args.config,\n            args.limit,\n            &args.out,\n        );\n    } else {\n        let codegen_key = args.codegen_key.unwrap();\n        match codegen_key.as_str() {\n            \"digits_data\" => generate_string_data(),\n            \"factorial_data\" => generate_factorial_data(),\n            _ => panic!(\"Invalid codegen key: {codegen_key}\"),\n        }\n    }\n}\n\n#[cfg(not(feature = \"bin_build\"))]\nconst fn main() {}\n\n#[cfg(feature = \"bin_build\")]\npub mod bin_util {\n    pub mod demo_and_bench;\n    pub mod generate;\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign, UnsignedAbs};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, triple_1_integer_bit_bucketer, triple_3_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_nrm, integer_integer_natural_triple_gen,\n};\nuse num::Signed;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_abs);\n    register_demo!(runner, demo_integer_abs_ref);\n    register_demo!(runner, demo_integer_abs_assign);\n    register_demo!(runner, demo_integer_unsigned_abs);\n    register_demo!(runner, demo_integer_unsigned_abs_ref);\n    register_demo!(runner, demo_integer_unsigned_abs_ref_out);\n    register_demo!(runner, demo_integer_mutate_unsigned_abs);\n\n    register_bench!(runner, benchmark_integer_abs_library_comparison);\n    register_bench!(runner, benchmark_integer_abs_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_abs_assign);\n    register_bench!(runner, benchmark_integer_unsigned_abs_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_mutate_unsigned_abs);\n}\n\nfn demo_integer_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"|{}| = {}\", n.clone(), n.abs());\n    }\n}\n\nfn demo_integer_abs_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"|&{}| = {}\", n, (&n).abs());\n    }\n}\n\nfn demo_integer_abs_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in integer_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.abs_assign();\n        println!(\"n := {n_old}; n.abs_assign(); n = {n}\");\n    }\n}\n\nfn demo_integer_unsigned_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"unsigned_abs({}) = {}\", n.clone(), n.unsigned_abs());\n    }\n}\n\nfn demo_integer_unsigned_abs_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"unsigned_abs(&{}) = {}\", n, (&n).unsigned_abs());\n    }\n}\n\nfn demo_integer_unsigned_abs_ref_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{}.unsigned_abs_ref() = {}\", n, n.unsigned_abs_ref());\n    }\n}\n\nfn demo_integer_mutate_unsigned_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, out, new_abs) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n.clone();\n        let old_out = out.clone();\n        let old_new_abs = new_abs.clone();\n        let actual_out = n.mutate_unsigned_abs(|x| {\n            *x = new_abs;\n            out\n        });\n        println!(\n            \"n := {old_n}; \\\n            n.mutate_unsigned_abs(|x| {{ *x = {old_new_abs}; {old_out} }}) = {actual_out}; \\\n            n = {n}\",\n        );\n    }\n}\n\nfn benchmark_integer_abs_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.abs()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.abs())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.abs())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.abs().cmp0())),\n        ],\n    );\n}\n\nfn benchmark_integer_abs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.abs()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.abs()\", &mut |n| no_out!(n.abs())),\n            (\"(&Integer).abs()\", &mut |n| no_out!((&n).abs())),\n        ],\n    );\n}\n\nfn benchmark_integer_abs_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.abs_assign()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.abs_assign())],\n    );\n}\n\nfn benchmark_integer_unsigned_abs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.unsigned_abs()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.unsigned_abs()\", &mut |n| no_out!(n.unsigned_abs())),\n            (\"(&Integer).unsigned_abs()\", &mut |n| {\n                no_out!((&n).unsigned_abs());\n            }),\n            (\"Integer.unsigned_abs_ref()\", &mut |n| {\n                no_out!(n.unsigned_abs_ref());\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_mutate_unsigned_abs(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.mutate_unsigned_abs(FnOnce(&mut Natural) -> T)\",\n        BenchmarkType::Single,\n        integer_integer_natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, out, new_abs)| {\n            no_out!(n.mutate_unsigned_abs(|x| {\n                *x = new_abs;\n                out\n            }));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AbsDiff, AbsDiffAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_integer_max_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_abs_diff);\n    register_demo!(runner, demo_integer_abs_diff_val_ref);\n    register_demo!(runner, demo_integer_abs_diff_ref_val);\n    register_demo!(runner, demo_integer_abs_diff_ref_ref);\n    register_demo!(runner, demo_integer_abs_diff_assign);\n    register_demo!(runner, demo_integer_abs_diff_assign_ref);\n\n    register_bench!(\n        runner,\n        benchmark_integer_abs_diff_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_integer_abs_diff_evaluation_strategy);\n}\n\nfn demo_integer_abs_diff(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"|{} - {}| = {:?}\", x_old, y_old, x.abs_diff(y));\n    }\n}\n\nfn demo_integer_abs_diff_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"|{} - &{}| = {:?}\", x_old, y, x.abs_diff(&y));\n    }\n}\n\nfn demo_integer_abs_diff_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"|&{} - {}| = {:?}\", x, y_old, (&x).abs_diff(y));\n    }\n}\n\nfn demo_integer_abs_diff_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"|&{} - &{}| = {:?}\", x, y, (&x).abs_diff(&y));\n    }\n}\n\nfn demo_integer_abs_diff_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.abs_diff_assign(y);\n        println!(\"x := {x_old}; x.abs_diff_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_integer_abs_diff_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.abs_diff_assign(&y);\n        println!(\"x := {x_old}; x.abs_diff_assign(&{y}); x = {x}\");\n    }\n}\n\nfn benchmark_integer_abs_diff_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.abs_diff_assign(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer.abs_diff_assign(Integer)\", &mut |(mut x, y)| {\n                x.abs_diff_assign(y);\n            }),\n            (\"Integer.abs_diff_assign(&Integer)\", &mut |(mut x, y)| {\n                x.abs_diff_assign(&y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_abs_diff_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.abs_diff(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer.abs_diff(Integer)\", &mut |(x, y)| {\n                no_out!(x.abs_diff(y));\n            }),\n            (\"Integer.abs_diff(&Integer)\", &mut |(x, y)| {\n                no_out!(x.abs_diff(&y));\n            }),\n            (\"&Integer.abs_diff(Integer)\", &mut |(x, y)| {\n                no_out!((&x).abs_diff(y));\n            }),\n            (\"&Integer.abs_diff(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).abs_diff(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n    triple_3_pair_integer_max_bit_bucketer, triple_3_vec_integer_sum_bits_bucketer,\n    vec_integer_sum_bits_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen, integer_pair_gen_nrm, integer_pair_gen_rm, integer_vec_gen,\n    integer_vec_gen_nrm,\n};\nuse malachite_nz::test_util::integer::arithmetic::add::integer_sum_alt;\nuse num::BigInt;\nuse std::iter::Sum;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_add);\n    register_demo!(runner, demo_integer_add_val_ref);\n    register_demo!(runner, demo_integer_add_ref_val);\n    register_demo!(runner, demo_integer_add_ref_ref);\n    register_demo!(runner, demo_integer_add_assign);\n    register_demo!(runner, demo_integer_add_assign_ref);\n    register_demo!(runner, demo_integer_sum);\n    register_demo!(runner, demo_integer_ref_sum);\n\n    register_bench!(runner, benchmark_integer_add_library_comparison);\n    register_bench!(runner, benchmark_integer_add_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_add_assign_library_comparison);\n    register_bench!(runner, benchmark_integer_add_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_sum_algorithms);\n    register_bench!(runner, benchmark_integer_sum_library_comparison);\n    register_bench!(runner, benchmark_integer_sum_evaluation_strategy);\n}\n\nfn demo_integer_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_integer_add_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} + &{} = {}\", x_old, y, x + &y);\n    }\n}\n\nfn demo_integer_add_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} + {} = {}\", x, y_old, &x + y);\n    }\n}\n\nfn demo_integer_add_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} + &{} = {}\", x, y, &x + &y);\n    }\n}\n\nfn demo_integer_add_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\"x := {x_old}; x += {y}; x = {x}\");\n    }\n}\n\nfn demo_integer_add_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\"x := {x_old}; x += &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_sum(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in integer_vec_gen().get(gm, config).take(limit) {\n        println!(\"sum({:?}) = {}\", xs.clone(), Integer::sum(xs.into_iter()));\n    }\n}\n\nfn demo_integer_ref_sum(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in integer_vec_gen().get(gm, config).take(limit) {\n        println!(\"sum({:?}) = {}\", xs, Integer::sum(xs.iter()));\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_add_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer + Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x + y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x + y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x + y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_add_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer + Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer + Integer\", &mut |(x, y)| no_out!(x + y)),\n            (\"Integer + &Integer\", &mut |(x, y)| no_out!(x + &y)),\n            (\"&Integer + Integer\", &mut |(x, y)| no_out!(&x + y)),\n            (\"&Integer + &Integer\", &mut |(x, y)| no_out!(&x + &y)),\n        ],\n    );\n}\n\nfn benchmark_integer_add_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer += Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x += y), (\"rug\", &mut |((mut x, y), _)| x += y)],\n    );\n}\n\nfn benchmark_integer_add_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer += Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer += Integer\", &mut |(mut x, y)| no_out!(x += y)),\n            (\"Integer += &Integer\", &mut |(mut x, y)| no_out!(x += &y)),\n        ],\n    );\n}\n\nfn benchmark_integer_sum_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::sum(Iterator<Item=Integer>)\",\n        BenchmarkType::LibraryComparison,\n        integer_vec_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_integer_sum_bits_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, xs)| {\n                no_out!(Integer::sum(xs.into_iter()));\n            }),\n            (\"num\", &mut |(xs, _, _)| {\n                no_out!(BigInt::sum(xs.into_iter()));\n            }),\n            (\"rug\", &mut |(_, xs, _)| {\n                no_out!(rug::Integer::sum(xs.iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_sum_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::sum(Iterator<Item=Integer>)\",\n        BenchmarkType::Algorithms,\n        integer_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_integer_sum_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |xs| no_out!(Integer::sum(xs.into_iter()))),\n            (\"alt\", &mut |xs| no_out!(integer_sum_alt(xs.into_iter()))),\n        ],\n    );\n}\n\nfn benchmark_integer_sum_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::sum(Iterator<Item=Integer>)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_integer_sum_bits_bucketer(),\n        &mut [\n            (\"Integer::sum(Iterator<Item=Integer>)\", &mut |xs| {\n                no_out!(Integer::sum(xs.into_iter()));\n            }),\n            (\"Integer::sum(Iterator<Item=&Integer>)\", &mut |xs| {\n                no_out!(Integer::sum(xs.iter()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AddMul, AddMulAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_integer_max_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_triple_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_add_mul);\n    register_demo!(runner, demo_integer_add_mul_val_val_ref);\n    register_demo!(runner, demo_integer_add_mul_val_ref_val);\n    register_demo!(runner, demo_integer_add_mul_val_ref_ref);\n    register_demo!(runner, demo_integer_add_mul_ref_ref_ref);\n    register_demo!(runner, demo_integer_add_mul_assign);\n    register_demo!(runner, demo_integer_add_mul_assign_val_ref);\n    register_demo!(runner, demo_integer_add_mul_assign_ref_val);\n    register_demo!(runner, demo_integer_add_mul_assign_ref_ref);\n\n    register_bench!(runner, benchmark_integer_add_mul_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_add_mul_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_val_val_ref_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_val_ref_val_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_val_ref_ref_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_ref_ref_ref_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_add_mul_assign_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_assign_val_ref_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_assign_ref_val_algorithms);\n    register_bench!(runner, benchmark_integer_add_mul_assign_ref_ref_algorithms);\n}\n\nfn demo_integer_add_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let z_old = z.clone();\n        println!(\n            \"{}.add_mul({}, {}) = {}\",\n            x_old,\n            y_old,\n            z_old,\n            x.add_mul(y, z)\n        );\n    }\n}\n\nfn demo_integer_add_mul_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.add_mul({}, &({})) = {}\",\n            x_old,\n            y_old,\n            z,\n            x.add_mul(y, &z)\n        );\n    }\n}\n\nfn demo_integer_add_mul_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let z_old = z.clone();\n        println!(\n            \"{}.add_mul(&({}), {}) = {}\",\n            x_old,\n            y,\n            z_old,\n            x.add_mul(&y, z)\n        );\n    }\n}\n\nfn demo_integer_add_mul_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{}.add_mul(&({}), &({})) = {}\",\n            x_old,\n            y,\n            z,\n            x.add_mul(&y, &z)\n        );\n    }\n}\n\nfn demo_integer_add_mul_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).add_mul(&({}), &({})) = {}\",\n            x,\n            y,\n            z,\n            (&x).add_mul(&y, &z)\n        );\n    }\n}\n\nfn demo_integer_add_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let z_old = z.clone();\n        x.add_mul_assign(y, z);\n        println!(\"x := {x_old}; x.add_mul_assign({y_old}, {z_old}); x = {x}\");\n    }\n}\n\nfn demo_integer_add_mul_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.add_mul_assign(y, &z);\n        println!(\"x := {x_old}; x.add_mul_assign({y_old}, &({z})); x = {x}\");\n    }\n}\n\nfn demo_integer_add_mul_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let z_old = z.clone();\n        x.add_mul_assign(&y, z);\n        println!(\"x := {x_old}; x.add_mul_assign(&({y}), {z_old}); x = {x}\");\n    }\n}\n\nfn demo_integer_add_mul_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.add_mul_assign(&y, &z);\n        println!(\"x := {x_old}; x.add_mul_assign(&({y}), &({z})); x = {x}\");\n    }\n}\n\nfn benchmark_integer_add_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul(Integer, Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.add_mul(Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, c));\n            }),\n            (\"Integer.add_mul(Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, &c));\n            }),\n            (\"Integer.add_mul(&Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, c));\n            }),\n            (\"Integer.add_mul(&Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, &c));\n            }),\n            (\n                \"(&Integer).add_mul(&Integer, &Integer)\",\n                &mut |(a, b, c)| no_out!((&a).add_mul(&b, &c)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_add_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul(Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.add_mul(Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, c));\n            }),\n            (\"Integer + Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(a + b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_add_mul_val_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul(Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.add_mul(Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, &c));\n            }),\n            (\"Integer + Integer * &Integer\", &mut |(a, b, c)| {\n                no_out!(a + b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_add_mul_val_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul(&Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.add_mul(&Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, c));\n            }),\n            (\"Integer + &Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(a + &b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_add_mul_val_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul(&Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.add_mul(&Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, &c));\n            }),\n            (\"Integer + Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(a + &b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_add_mul_ref_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul(&Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"(&Integer).add_mul(&Integer, &Integer)\",\n                &mut |(a, b, c)| no_out!((&a).add_mul(&b, &c)),\n            ),\n            (\"&Integer + Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(&a + &b * &c);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_add_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul_assign(Integer, Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.add_mul_assign(Integer, Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, c),\n            ),\n            (\n                \"Integer.add_mul_assign(Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, &c),\n            ),\n            (\n                \"Integer.add_mul_assign(&Integer, Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, c),\n            ),\n            (\n                \"Integer.add_mul_assign(&Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, &c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_add_mul_assign_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul_assign(Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.add_mul_assign(Integer, Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, c),\n            ),\n            (\"Integer += Integer * Integer\", &mut |(mut a, b, c)| {\n                a += b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_add_mul_assign_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul_assign(Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.add_mul_assign(Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, &c),\n            ),\n            (\"Integer += Integer * &Integer\", &mut |(mut a, b, c)| {\n                a += b * &c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_add_mul_assign_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul_assign(&Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.add_mul_assign(&Integer, Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, c),\n            ),\n            (\"Integer += &Integer * Integer\", &mut |(mut a, b, c)| {\n                a += &b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_add_mul_assign_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.add_mul_assign(&Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.add_mul_assign(&Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, &c),\n            ),\n            (\"Integer += &Integer * &Integer\", &mut |(mut a, b, c)| {\n                a += &b * &c;\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::BinomialCoefficient;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen_var_7, integer_pair_gen_var_7_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_binomial_coefficient);\n    register_demo!(runner, demo_integer_binomial_coefficient_ref);\n\n    register_bench!(\n        runner,\n        benchmark_integer_binomial_coefficient_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_binomial_coefficient_library_comparison\n    );\n}\n\nfn demo_integer_binomial_coefficient(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, k) in integer_pair_gen_var_7().get(gm, config).take(limit) {\n        let n_orig = n.clone();\n        let k_orig = k.clone();\n        println!(\n            \"C({}, {}) = {}\",\n            n_orig,\n            k_orig,\n            Integer::binomial_coefficient(n, k)\n        );\n    }\n}\n\nfn demo_integer_binomial_coefficient_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, k) in integer_pair_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"C({}, {}) = {}\",\n            n,\n            k,\n            Integer::binomial_coefficient(&n, &k)\n        );\n    }\n}\n\nfn benchmark_integer_binomial_coefficient_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.binomial_coefficient(Integer, Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Integer.binomial_coefficient(Integer, Integer)\",\n                &mut |(n, k)| no_out!(Integer::binomial_coefficient(n, k)),\n            ),\n            (\n                \"Integer.binomial_coefficient(&Integer, &Integer)\",\n                &mut |(n, k)| no_out!(Integer::binomial_coefficient(&n, &k)),\n            ),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_binomial_coefficient_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.binomial_coefficient(Integer, Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_7_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, k))| {\n                no_out!(Integer::binomial_coefficient(n, k));\n            }),\n            (\"rug\", &mut |((n, k), _)| no_out!(n.binomial(k))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedDiv, DivRem};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, pair_2_pair_1_integer_bit_bucketer,\n    triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen, integer_pair_gen_nm, integer_pair_gen_var_1, integer_pair_gen_var_1_nrm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_div);\n    register_demo!(runner, demo_integer_div_val_ref);\n    register_demo!(runner, demo_integer_div_ref_val);\n    register_demo!(runner, demo_integer_div_ref_ref);\n    register_demo!(runner, demo_integer_div_assign);\n    register_demo!(runner, demo_integer_div_assign_ref);\n    register_demo!(runner, demo_integer_checked_div);\n    register_demo!(runner, demo_integer_checked_div_val_ref);\n    register_demo!(runner, demo_integer_checked_div_ref_val);\n    register_demo!(runner, demo_integer_checked_div_ref_ref);\n\n    register_bench!(runner, benchmark_integer_div_library_comparison);\n    register_bench!(runner, benchmark_integer_div_algorithms);\n    register_bench!(runner, benchmark_integer_div_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_div_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_checked_div_library_comparison);\n    register_bench!(runner, benchmark_integer_checked_div_evaluation_strategy);\n}\n\nfn demo_integer_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_integer_div_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} / &{} = {}\", x_old, y, x / &y);\n    }\n}\n\nfn demo_integer_div_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} / {} = {}\", x, y_old, &x / y);\n    }\n}\n\nfn demo_integer_div_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"&{} / &{} = {}\", x, y, &x / &y);\n    }\n}\n\nfn demo_integer_div_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= y.clone();\n        println!(\"x := {x_old}; x /= {y}; x = {x}\");\n    }\n}\n\nfn demo_integer_div_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= &y;\n        println!(\"x := {x_old}; x /= &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_checked_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).checked_div({}) = {:?}\",\n            x_old,\n            y_old,\n            x.checked_div(y)\n        );\n    }\n}\n\nfn demo_integer_checked_div_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).checked_div(&{}) = {:?}\", x_old, y, x.checked_div(&y));\n    }\n}\n\nfn demo_integer_checked_div_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).checked_div({}) = {:?}\",\n            x,\n            y_old,\n            (&x).checked_div(y)\n        );\n    }\n}\n\nfn demo_integer_checked_div_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_div(&{}) = {:?}\", x, y, (&x).checked_div(&y));\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_div_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer / Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x / y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x / y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x / y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_div_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer / Integer\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x / y)),\n            (\"using div_rem\", &mut |(x, y)| no_out!(x.div_rem(y).0)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer / Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer / Integer\", &mut |(x, y)| no_out!(x / y)),\n            (\"Integer / &Integer\", &mut |(x, y)| no_out!(x / &y)),\n            (\"&Integer / Integer\", &mut |(x, y)| no_out!(&x / y)),\n            (\"&Integer / &Integer\", &mut |(x, y)| no_out!(&x / &y)),\n        ],\n    );\n}\n\nfn benchmark_integer_div_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer /= Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer /= Integer\", &mut |(mut x, y)| no_out!(x /= y)),\n            (\"Integer /= &Integer\", &mut |(mut x, y)| no_out!(x /= &y)),\n        ],\n    );\n}\n\nfn benchmark_integer_checked_div_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.checked_div(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.checked_div(&y))),\n            (\"num\", &mut |((x, y), _)| no_out!(x.checked_div(&y))),\n        ],\n    );\n}\n\nfn benchmark_integer_checked_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.checked_div(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.checked_div(Integer)\", &mut |(x, y)| {\n                no_out!(x.checked_div(y));\n            }),\n            (\"Integer.checked_div(&Integer)\", &mut |(x, y)| {\n                no_out!(x.checked_div(&y));\n            }),\n            (\"(&Integer).checked_div(Integer)\", &mut |(x, y)| {\n                no_out!((&x).checked_div(y));\n            }),\n            (\"(&Integer).checked_div(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).checked_div(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivExact, DivExactAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen_var_2, integer_pair_gen_var_2_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_div_exact);\n    register_demo!(runner, demo_integer_div_exact_val_ref);\n    register_demo!(runner, demo_integer_div_exact_ref_val);\n    register_demo!(runner, demo_integer_div_exact_ref_ref);\n    register_demo!(runner, demo_integer_div_exact_assign);\n    register_demo!(runner, demo_integer_div_exact_assign_ref);\n\n    register_bench!(runner, benchmark_integer_div_exact_library_comparison);\n    register_bench!(runner, benchmark_integer_div_exact_algorithms);\n    register_bench!(runner, benchmark_integer_div_exact_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_div_exact_assign_algorithms);\n    register_bench!(\n        runner,\n        benchmark_integer_div_exact_assign_evaluation_strategy\n    );\n}\n\nfn demo_integer_div_exact(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.div_exact({}) = {}\", x_old, y_old, x.div_exact(y));\n    }\n}\n\nfn demo_integer_div_exact_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.div_exact(&{}) = {}\", x_old, y, x.div_exact(&y));\n    }\n}\n\nfn demo_integer_div_exact_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).div_exact({}) = {}\", x, y_old, (&x).div_exact(y));\n    }\n}\n\nfn demo_integer_div_exact_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\"(&{}).div_exact(&{}) = {}\", x, y, (&x).div_exact(&y));\n    }\n}\n\nfn demo_integer_div_exact_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.div_exact_assign(y.clone());\n        println!(\"x := {x_old}; x.div_exact_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_integer_div_exact_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.div_exact_assign(&y);\n        println!(\"x := {x_old}; x.div_exact_assign(&{y}); x = {x}\");\n    }\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_div_exact_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_exact(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_2_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"num\", &mut |((x, y), _, _)| no_out!(x / y)),\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.div_exact(y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_exact(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_div_exact_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_exact(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"ordinary division\", &mut |(x, y)| no_out!(x / y)),\n            (\"exact division\", &mut |(x, y)| no_out!(x.div_exact(y))),\n        ],\n    );\n}\n\nfn benchmark_integer_div_exact_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_exact(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.div_exact(Integer)\", &mut |(x, y)| {\n                no_out!(x.div_exact(y));\n            }),\n            (\"Integer.div_exact(&Integer)\", &mut |(x, y)| {\n                no_out!(x.div_exact(&y));\n            }),\n            (\"(&Integer).div_exact(Integer)\", &mut |(x, y)| {\n                no_out!((&x).div_exact(y));\n            }),\n            (\"(&Integer).div_exact(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).div_exact(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_div_exact_assign_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_exact_assign(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"ordinary division\", &mut |(mut x, y)| x /= y),\n            (\"exact division\", &mut |(mut x, y)| x.div_exact_assign(y)),\n        ],\n    );\n}\n\nfn benchmark_integer_div_exact_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_exact_assign(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.div_exact_assign(Integer)\", &mut |(mut x, y)| {\n                x.div_exact_assign(y);\n            }),\n            (\"Integer.div_exact_assign(&Integer)\", &mut |(mut x, y)| {\n                x.div_exact_assign(&y);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivAssignMod, CeilingDivMod, CeilingMod, DivAssignMod, DivAssignRem, DivMod, DivRem,\n    DivRound, Mod,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, pair_2_pair_1_integer_bit_bucketer,\n    triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen_var_1, integer_pair_gen_var_1_nrm, integer_pair_gen_var_1_rm,\n};\nuse num::Integer as NumInteger;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_div_mod);\n    register_demo!(runner, demo_integer_div_mod_val_ref);\n    register_demo!(runner, demo_integer_div_mod_ref_val);\n    register_demo!(runner, demo_integer_div_mod_ref_ref);\n    register_demo!(runner, demo_integer_div_assign_mod);\n    register_demo!(runner, demo_integer_div_assign_mod_ref);\n    register_demo!(runner, demo_integer_div_rem);\n    register_demo!(runner, demo_integer_div_rem_val_ref);\n    register_demo!(runner, demo_integer_div_rem_ref_val);\n    register_demo!(runner, demo_integer_div_rem_ref_ref);\n    register_demo!(runner, demo_integer_div_assign_rem);\n    register_demo!(runner, demo_integer_div_assign_rem_ref);\n    register_demo!(runner, demo_integer_ceiling_div_mod);\n    register_demo!(runner, demo_integer_ceiling_div_mod_val_ref);\n    register_demo!(runner, demo_integer_ceiling_div_mod_ref_val);\n    register_demo!(runner, demo_integer_ceiling_div_mod_ref_ref);\n    register_demo!(runner, demo_integer_ceiling_div_assign_mod);\n    register_demo!(runner, demo_integer_ceiling_div_assign_mod_ref);\n\n    register_bench!(runner, benchmark_integer_div_mod_library_comparison);\n    register_bench!(runner, benchmark_integer_div_mod_algorithms);\n    register_bench!(runner, benchmark_integer_div_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_div_assign_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_div_rem_library_comparison);\n    register_bench!(runner, benchmark_integer_div_rem_algorithms);\n    register_bench!(runner, benchmark_integer_div_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_div_assign_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_ceiling_div_mod_library_comparison);\n    register_bench!(runner, benchmark_integer_ceiling_div_mod_algorithms);\n    register_bench!(\n        runner,\n        benchmark_integer_ceiling_div_mod_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_ceiling_div_assign_mod_evaluation_strategy\n    );\n}\n\nfn demo_integer_div_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.div_mod({}) = {:?}\", x_old, y_old, x.div_mod(y));\n    }\n}\n\nfn demo_integer_div_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.div_mod(&{}) = {:?}\", x_old, y, x.div_mod(&y));\n    }\n}\n\nfn demo_integer_div_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).div_mod({}) = {:?}\", x, y_old, (&x).div_mod(y));\n    }\n}\n\nfn demo_integer_div_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"(&{}).div_mod(&{}) = {:?}\", x, y, (&x).div_mod(&y));\n    }\n}\n\nfn demo_integer_div_assign_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let remainder = x.div_assign_mod(y);\n        println!(\"x := {x_old}; x.div_assign_mod({y_old}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_integer_div_assign_mod_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let remainder = x.div_assign_mod(&y);\n        println!(\"x := {x_old}; x.div_assign_mod(&{y}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_integer_div_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.div_rem({}) = {:?}\", x_old, y_old, x.div_rem(y));\n    }\n}\n\nfn demo_integer_div_rem_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.div_rem(&{}) = {:?}\", x_old, y, x.div_rem(&y));\n    }\n}\n\nfn demo_integer_div_rem_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).div_rem({}) = {:?}\", x, y_old, (&x).div_rem(y));\n    }\n}\n\nfn demo_integer_div_rem_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"(&{}).div_rem(&{}) = {:?}\", x, y, (&x).div_rem(&y));\n    }\n}\n\nfn demo_integer_div_assign_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let remainder = x.div_assign_rem(y);\n        println!(\"x := {x_old}; x.div_assign_rem({y_old}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_integer_div_assign_rem_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let remainder = x.div_assign_rem(&y);\n        println!(\"x := {x_old}; x.div_assign_rem(&{y}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_integer_ceiling_div_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.ceiling_div_mod({}) = {:?}\",\n            x_old,\n            y_old,\n            x.ceiling_div_mod(y)\n        );\n    }\n}\n\nfn demo_integer_ceiling_div_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{}.ceiling_div_mod(&{}) = {:?}\",\n            x_old,\n            y,\n            x.ceiling_div_mod(&y)\n        );\n    }\n}\n\nfn demo_integer_ceiling_div_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).ceiling_div_mod({}) = {:?}\",\n            x,\n            y_old,\n            (&x).ceiling_div_mod(y)\n        );\n    }\n}\n\nfn demo_integer_ceiling_div_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).ceiling_div_mod(&{}) = {:?}\",\n            x,\n            y,\n            (&x).ceiling_div_mod(&y)\n        );\n    }\n}\n\nfn demo_integer_ceiling_div_assign_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let remainder = x.ceiling_div_assign_mod(y);\n        println!(\"x := {x_old}; x.ceiling_div_assign_mod({y_old}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_integer_ceiling_div_assign_mod_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let remainder = x.ceiling_div_assign_mod(&y);\n        println!(\"x := {x_old}; x.ceiling_div_assign_mod(&{y}) = {remainder}; x = {x}\");\n    }\n}\n\nfn benchmark_integer_div_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_mod(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.div_mod(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.div_mod_floor(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_rem_floor(y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_div_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_mod(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.div_mod(y))),\n            (\"using div_round and mod_op\", &mut |(x, y)| {\n                no_out!(((&x).div_round(&y, Floor), x.mod_op(y)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_div_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_mod(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.div_mod(Integer)\", &mut |(x, y)| {\n                no_out!(x.div_mod(y));\n            }),\n            (\"Integer.div_mod(&Integer)\", &mut |(x, y)| {\n                no_out!(x.div_mod(&y));\n            }),\n            (\"(&Integer).div_mod(Integer)\", &mut |(x, y)| {\n                no_out!((&x).div_mod(y));\n            }),\n            (\"(&Integer).div_mod(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).div_mod(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_div_assign_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_assign_mod(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.div_assign_mod(Integer)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_mod(y));\n            }),\n            (\"Integer.div_assign_mod(&Integer)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_mod(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_div_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_rem(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.div_rem(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.div_rem(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_rem(y))),\n        ],\n    );\n}\n#[allow(clippy::no_effect)]\nfn benchmark_integer_div_rem_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_rem(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.div_rem(y))),\n            (\"using / and %\", &mut |(x, y)| no_out!((&x / &y, x % y))),\n        ],\n    );\n}\n\nfn benchmark_integer_div_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_rem(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.div_rem(Integer)\", &mut |(x, y)| {\n                no_out!(x.div_rem(y));\n            }),\n            (\"Integer.div_rem(&Integer)\", &mut |(x, y)| {\n                no_out!(x.div_rem(&y));\n            }),\n            (\"(&Integer).div_rem(Integer)\", &mut |(x, y)| {\n                no_out!((&x).div_rem(y));\n            }),\n            (\"(&Integer).div_rem(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).div_rem(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_div_assign_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_assign_rem(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.div_assign_rem(Integer)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_rem(y));\n            }),\n            (\"Integer.div_assign_rem(&Integer)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_rem(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_div_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_div_mod(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.ceiling_div_mod(y));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.div_rem_ceil(y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_ceiling_div_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_div_mod(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.ceiling_div_mod(y))),\n            (\"using div_round and ceiling_mod\", &mut |(x, y)| {\n                ((&x).div_round(&y, Ceiling), x.ceiling_mod(y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_div_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_div_mod(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.ceiling_div_mod(Integer)\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_mod(y));\n            }),\n            (\"Integer.ceiling_div_mod(&Integer)\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_mod(&y));\n            }),\n            (\"(&Integer).ceiling_div_mod(Integer)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_div_mod(y));\n            }),\n            (\"(&Integer).ceiling_div_mod(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_div_mod(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_div_assign_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_div_assign_mod(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Integer.ceiling_div_assign_mod(Integer)\",\n                &mut |(mut x, y)| no_out!(x.ceiling_div_assign_mod(y)),\n            ),\n            (\n                \"Integer.ceiling_div_assign_mod(&Integer)\",\n                &mut |(mut x, y)| no_out!(x.ceiling_div_assign_mod(&y)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CeilingDivMod, DivRound, DivRoundAssign};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, pair_2_pair_1_integer_bit_bucketer, triple_1_integer_bit_bucketer,\n    triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_integer_rounding_mode_triple_gen_var_1, integer_pair_gen_var_1,\n    integer_pair_gen_var_1_nrm, integer_pair_gen_var_1_rm,\n};\nuse num::Integer as NumInteger;\nuse rug::ops::DivRounding;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_div_round);\n    register_demo!(runner, demo_integer_div_round_val_ref);\n    register_demo!(runner, demo_integer_div_round_ref_val);\n    register_demo!(runner, demo_integer_div_round_ref_ref);\n    register_demo!(runner, demo_integer_div_round_assign);\n    register_demo!(runner, demo_integer_div_round_assign_ref);\n\n    register_bench!(runner, benchmark_integer_div_round_down_library_comparison);\n    register_bench!(runner, benchmark_integer_div_round_floor_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_integer_div_round_ceiling_library_comparison\n    );\n    register_bench!(runner, benchmark_integer_div_round_ceiling_algorithms);\n    register_bench!(runner, benchmark_integer_div_round_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_integer_div_round_assign_evaluation_strategy\n    );\n}\n\nfn demo_integer_div_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.div_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.div_round(y, rm)\n        );\n    }\n}\n\nfn demo_integer_div_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"{}.div_round(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.div_round(&y, rm)\n        );\n    }\n}\n\nfn demo_integer_div_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_round({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            (&x).div_round(y, rm)\n        );\n    }\n}\n\nfn demo_integer_div_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).div_round(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            (&x).div_round(&y, rm)\n        );\n    }\n}\n\nfn demo_integer_div_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in integer_integer_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_round_assign(y, rm);\n        println!(\"x := {x_old}; x.div_round_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_integer_div_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in integer_integer_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_round_assign(&y, rm);\n        println!(\"x := {x_old}; x.div_round_assign(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn benchmark_integer_div_round_down_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_round(Integer, Down)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.div_round(y, Down));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.div_trunc(y))),\n        ],\n    );\n}\n\nfn benchmark_integer_div_round_floor_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_round(Integer, Floor)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| {\n                no_out!(x.div_round(y, Floor));\n            }),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.div_floor(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_floor(y))),\n        ],\n    );\n}\n\nfn benchmark_integer_div_round_ceiling_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_round(Integer, Ceiling)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.div_round(y, Ceiling));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.div_ceil(y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_div_round_ceiling_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_round(Integer, Ceiling)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.div_round(y, Ceiling))),\n            (\"using ceiling_div_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_mod(y).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_div_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_round(Integer, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_integer_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Integer.div_round(Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_round(y, rm)),\n            ),\n            (\n                \"Integer.div_round(&Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_round(&y, rm)),\n            ),\n            (\n                \"(&Integer).div_round(Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).div_round(y, rm)),\n            ),\n            (\n                \"(&Integer).div_round(&Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).div_round(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_div_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.div_round_assign(Integer, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_integer_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Integer.div_round_assign(Integer, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_round_assign(y, rm)),\n            ),\n            (\n                \"Integer.div_round_assign(&Integer, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_round_assign(&y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_nrm};\nuse malachite_nz::test_util::integer::arithmetic::divisible_by::num_divisible_by;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_divisible_by);\n    register_demo!(runner, demo_integer_divisible_by_val_ref);\n    register_demo!(runner, demo_integer_divisible_by_ref_val);\n    register_demo!(runner, demo_integer_divisible_by_ref_ref);\n\n    register_bench!(runner, benchmark_integer_divisible_by_library_comparison);\n    register_bench!(runner, benchmark_integer_divisible_by_algorithms);\n    register_bench!(runner, benchmark_integer_divisible_by_evaluation_strategy);\n}\n\nfn demo_integer_divisible_by(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        if x.divisible_by(y) {\n            println!(\"{x_old} is divisible by {y_old}\");\n        } else {\n            println!(\"{x_old} is not divisible by {y_old}\");\n        }\n    }\n}\n\nfn demo_integer_divisible_by_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        if x.divisible_by(&y) {\n            println!(\"{x_old} is divisible by {y}\");\n        } else {\n            println!(\"{x_old} is not divisible by {y}\");\n        }\n    }\n}\n\nfn demo_integer_divisible_by_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        if (&x).divisible_by(y) {\n            println!(\"{x} is divisible by {y_old}\");\n        } else {\n            println!(\"{x} is not divisible by {y_old}\");\n        }\n    }\n}\n\nfn demo_integer_divisible_by_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        if (&x).divisible_by(&y) {\n            println!(\"{x} is divisible by {y}\");\n        } else {\n            println!(\"{x} is not divisible by {y}\");\n        }\n    }\n}\n\nfn benchmark_integer_divisible_by_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.divisible_by(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| {\n                no_out!(x.divisible_by(y));\n            }),\n            (\"num\", &mut |((x, y), _, _)| {\n                no_out!(num_divisible_by(&x, &y));\n            }),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.is_divisible(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::short_circuit_statement, unused_must_use)]\nfn benchmark_integer_divisible_by_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.divisible_by(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.divisible_by(y))),\n            (\"using %\", &mut |(x, y)| {\n                no_out!(x == 0 || y != 0 && x % y == 0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_divisible_by_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.divisible_by(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.divisible_by(Integer)\", &mut |(x, y)| {\n                no_out!(x.divisible_by(y));\n            }),\n            (\"Integer.divisible_by(&Integer)\", &mut |(x, y)| {\n                no_out!(x.divisible_by(&y));\n            }),\n            (\"(&Integer).divisible_by(Integer)\", &mut |(x, y)| {\n                no_out!((&x).divisible_by(y));\n            }),\n            (\"(&Integer).divisible_by(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).divisible_by(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, pair_2_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_2_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_divisible_by_power_of_2);\n\n    register_bench!(\n        runner,\n        benchmark_integer_divisible_by_power_of_2_library_comparison\n    );\n    register_bench!(runner, benchmark_integer_divisible_by_power_of_2_algorithms);\n}\n\nfn demo_integer_divisible_by_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.divisible_by_power_of_2(pow) {\n            println!(\"{n} is divisible by 2^{pow}\");\n        } else {\n            println!(\"{n} is not divisible by 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_integer_divisible_by_power_of_2_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.divisible_by_power_of_2(u64)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, pow))| {\n                no_out!(n.divisible_by_power_of_2(pow));\n            }),\n            (\"rug\", &mut |((n, pow), _)| {\n                n.is_divisible_2pow(u32::exact_from(pow));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_divisible_by_power_of_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.divisible_by_power_of_2(u64)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.divisible_by_power_of_2(u64)\", &mut |(n, pow)| {\n                no_out!(n.divisible_by_power_of_2(pow));\n            }),\n            (\n                \"Integer.trailing_zeros().map_or(true, |z| z >= u64)\",\n                &mut |(n, pow)| no_out!(n.trailing_zeros().is_none_or(|z| z >= pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleBy, EqMod, UnsignedAbs};\nuse malachite_base::test_util::bench::bucketers::{\n    triple_1_2_vec_max_len_bucketer, triple_1_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_triple_gen_var_36, unsigned_vec_unsigned_unsigned_triple_gen_var_5,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_7,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::arithmetic::eq_mod::{\n    limbs_eq_neg_limb_mod_limb, limbs_pos_eq_neg_limb_mod, limbs_pos_eq_neg_limb_mod_ref,\n    limbs_pos_eq_neg_mod, limbs_pos_eq_neg_mod_limb, limbs_pos_eq_neg_mod_ref,\n    limbs_pos_limb_eq_neg_limb_mod,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_triple_1_2_integer_max_bit_bucketer, triple_1_2_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_integer_natural_triple_gen, integer_integer_natural_triple_gen_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_eq_neg_limb_mod_limb);\n    register_demo!(runner, demo_limbs_pos_limb_eq_neg_limb_mod);\n    register_demo!(runner, demo_limbs_pos_eq_neg_limb_mod);\n    register_demo!(runner, demo_limbs_pos_eq_neg_limb_mod_ref);\n    register_demo!(runner, demo_limbs_pos_eq_neg_mod_limb);\n    register_demo!(runner, demo_limbs_pos_eq_neg_mod);\n    register_demo!(runner, demo_limbs_pos_eq_neg_mod_ref);\n    register_demo!(runner, demo_integer_eq_mod);\n    register_demo!(runner, demo_integer_eq_mod_val_val_ref);\n    register_demo!(runner, demo_integer_eq_mod_val_ref_val);\n    register_demo!(runner, demo_integer_eq_mod_val_ref_ref);\n    register_demo!(runner, demo_integer_eq_mod_ref_val_val);\n    register_demo!(runner, demo_integer_eq_mod_ref_val_ref);\n    register_demo!(runner, demo_integer_eq_mod_ref_ref_val);\n    register_demo!(runner, demo_integer_eq_mod_ref_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_eq_neg_limb_mod_limb);\n    register_bench!(runner, benchmark_limbs_pos_limb_eq_neg_limb_mod);\n    register_bench!(\n        runner,\n        benchmark_limbs_pos_eq_neg_limb_mod_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_limbs_pos_eq_neg_mod_limb);\n    register_bench!(runner, benchmark_limbs_pos_eq_neg_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_eq_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_eq_mod_library_comparison);\n    register_bench!(runner, benchmark_integer_eq_mod_algorithms);\n}\n\nfn demo_limbs_eq_neg_limb_mod_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y, m) in unsigned_vec_unsigned_unsigned_triple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_neg_limb_mod_limb({:?}, {}, {}) = {}\",\n            xs,\n            y,\n            m,\n            limbs_eq_neg_limb_mod_limb(&xs, y, m)\n        );\n    }\n}\n\nfn demo_limbs_pos_limb_eq_neg_limb_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (m, x, y) in unsigned_vec_unsigned_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_pos_limb_eq_neg_limb_mod({}, {}, {:?}) = {}\",\n            x,\n            y,\n            m,\n            limbs_pos_limb_eq_neg_limb_mod(x, y, &m)\n        );\n    }\n}\n\nfn demo_limbs_pos_eq_neg_limb_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut m, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_m = m.clone();\n        println!(\n            \"limbs_pos_eq_neg_limb_mod({:?}, {}, {:?}) = {}\",\n            xs,\n            y,\n            old_m,\n            limbs_pos_eq_neg_limb_mod(&xs, y, &mut m)\n        );\n    }\n}\n\nfn demo_limbs_pos_eq_neg_limb_mod_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, m, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_pos_eq_neg_limb_mod_ref({:?}, {}, {:?}) = {}\",\n            xs,\n            y,\n            m,\n            limbs_pos_eq_neg_limb_mod_ref(&xs, y, &m)\n        );\n    }\n}\n\nfn demo_limbs_pos_eq_neg_mod_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, m) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_pos_eq_neg_mod_limb({:?}, {:?}, {}) = {}\",\n            xs,\n            ys,\n            m,\n            limbs_pos_eq_neg_mod_limb(&xs, &ys, m)\n        );\n    }\n}\n\nfn demo_limbs_pos_eq_neg_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, mut m) in unsigned_vec_triple_gen_var_36().get(gm, config).take(limit) {\n        let old_m = m.clone();\n        println!(\n            \"limbs_pos_eq_neg_mod({:?}, {:?}, {:?}) = {}\",\n            xs,\n            ys,\n            old_m,\n            limbs_pos_eq_neg_mod(&xs, &ys, &mut m)\n        );\n    }\n}\n\nfn demo_limbs_pos_eq_neg_mod_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, m) in unsigned_vec_triple_gen_var_36().get(gm, config).take(limit) {\n        println!(\n            \"limbs_pos_eq_neg_mod_ref({:?}, {:?}, {:?}) = {}\",\n            xs,\n            ys,\n            m,\n            limbs_pos_eq_neg_mod_ref(&xs, &ys, &m)\n        );\n    }\n}\n\nfn demo_integer_eq_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        if x.eq_mod(y, m) {\n            println!(\"{x_old} is equal to {y_old} mod {m_old}\");\n        } else {\n            println!(\"{x_old} is not equal to {y_old} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_integer_eq_mod_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        if x.eq_mod(y, &m) {\n            println!(\"{x_old} is equal to {y_old} mod &{m}\");\n        } else {\n            println!(\"{x_old} is not equal to {y_old} mod &{m}\");\n        }\n    }\n}\n\nfn demo_integer_eq_mod_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        if x.eq_mod(&y, m) {\n            println!(\"{x_old} is equal to &{y} mod {m_old}\");\n        } else {\n            println!(\"{x_old} is not equal to &{y} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_integer_eq_mod_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        if x.eq_mod(&y, &m) {\n            println!(\"{x_old} is equal to &{y} mod &{m}\");\n        } else {\n            println!(\"{x_old} is not equal to &{y} mod &{m}\");\n        }\n    }\n}\n\nfn demo_integer_eq_mod_ref_val_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        let m_old = m.clone();\n        if (&x).eq_mod(y, m) {\n            println!(\"&{x} is equal to {y_old} mod {m_old}\");\n        } else {\n            println!(\"&{x} is not equal to {y_old} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_integer_eq_mod_ref_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        if (&x).eq_mod(y, &m) {\n            println!(\"&{x} is equal to {y_old} mod &{m}\");\n        } else {\n            println!(\"&{x} is not equal to {y_old} mod &{m}\");\n        }\n    }\n}\n\nfn demo_integer_eq_mod_ref_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let m_old = m.clone();\n        if (&x).eq_mod(&y, m) {\n            println!(\"&{x} is equal to &{y} mod {m_old}\");\n        } else {\n            println!(\"&{x} is not equal to &{y} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_integer_eq_mod_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in integer_integer_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        if (&x).eq_mod(&y, &m) {\n            println!(\"&{x} is equal to &{y} mod &{m}\");\n        } else {\n            println!(\"&{x} is not equal to &{y} mod &{m}\");\n        }\n    }\n}\n\nfn benchmark_limbs_eq_neg_limb_mod_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_neg_limb_mod_limb(&mut [Limb], Limb, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"limbs_eq_neg_limb_mod_limb\", &mut |(xs, y, m)| {\n            no_out!(limbs_eq_neg_limb_mod_limb(&xs, y, m));\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_limb_eq_neg_limb_mod(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_pos_limb_eq_neg_limb_mod(Limb, Limb, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"m\"),\n        &mut [(\"limbs_pos_limb_eq_neg_limb_mod\", &mut |(m, x, y)| {\n            no_out!(limbs_pos_limb_eq_neg_limb_mod(x, y, &m));\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_eq_neg_limb_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_limb(&[Limb], Limb, &[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_pos_eq_neg_limb_mod\", &mut |(xs, mut m, y)| {\n                no_out!(limbs_pos_eq_neg_limb_mod(&xs, y, &mut m));\n            }),\n            (\"limbs_pos_eq_neg_limb_mod_ref\", &mut |(xs, m, y)| {\n                no_out!(limbs_pos_eq_neg_limb_mod_ref(&xs, y, &m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_pos_eq_neg_mod_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_pos_eq_neg_mod_limb(&[Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"limbs_pos_eq_neg_mod_limb\", &mut |(xs, ys, m)| {\n            no_out!(limbs_pos_eq_neg_mod_limb(&xs, &ys, m));\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_eq_neg_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_limb(&[Limb], &[Limb], &[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_triple_gen_var_36().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"limbs_pos_eq_neg_mod\", &mut |(ref xs, ref y, ref mut m)| {\n                no_out!(limbs_pos_eq_neg_mod(xs, y, m));\n            }),\n            (\"limbs_pos_eq_neg_mod_ref\", &mut |(ref xs, ref y, ref m)| {\n                no_out!(limbs_pos_eq_neg_mod_ref(xs, y, m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_eq_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_mod(Integer, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_integer_natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer.eq_mod(Integer, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(y, m));\n            }),\n            (\"Integer.eq_mod(Integer, &Integer)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(y, &m));\n            }),\n            (\"Integer.eq_mod(&Integer, Integer)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(&y, m));\n            }),\n            (\"Integer.eq_mod(&Integer, &Integer)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(&y, &m));\n            }),\n            (\"(&Integer).eq_mod(Integer, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(y, m));\n            }),\n            (\"(&Integer).eq_mod(Integer, &Integer)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(y, &m));\n            }),\n            (\"(&Integer).eq_mod(&Integer, Integer)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(&y, m));\n            }),\n            (\"(&Integer).eq_mod(&Integer, &Integer)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(&y, &m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_eq_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_mod(Integer, Natural)\",\n        BenchmarkType::LibraryComparison,\n        integer_integer_natural_triple_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, m))| no_out!(x.eq_mod(y, m))),\n            (\"rug\", &mut |((x, y, m), _)| no_out!(x.is_congruent(&y, &m))),\n        ],\n    );\n}\n\n#[allow(clippy::short_circuit_statement, unused_must_use)]\nfn benchmark_integer_eq_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_mod(Integer, Natural)\",\n        BenchmarkType::Algorithms,\n        integer_integer_natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer.eq_mod(Integer, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(y, m));\n            }),\n            (\n                \"Integer == Integer || Integer != 0 && Integer % Natural == Integer % Natural\",\n                &mut |(x, y, m)| {\n                    no_out!(x == y || m != 0 && x.unsigned_abs() % &m == y.unsigned_abs() % m);\n                },\n            ),\n            (\n                \"(Integer - Integer).divisible_by(Natural)\",\n                &mut |(x, y, m)| no_out!((x - y).divisible_by(Integer::from(m))),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::EqModPowerOf2;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::{\n    triple_1_2_vec_max_len_bucketer, triple_1_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_unsigned_triple_gen_var_8,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::arithmetic::eq_mod_power_of_2::{\n    limbs_eq_mod_power_of_2_neg_limb, limbs_eq_mod_power_of_2_neg_pos,\n};\nuse malachite_nz::test_util::bench::bucketers::pair_2_triple_1_2_integer_max_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    integer_integer_unsigned_triple_gen_var_1, integer_integer_unsigned_triple_gen_var_1_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_eq_mod_power_of_2_neg_limb);\n    register_demo!(runner, demo_limbs_eq_mod_power_of_2_neg_pos);\n    register_demo!(runner, demo_integer_eq_mod_power_of_2);\n\n    register_bench!(runner, benchmark_limbs_eq_mod_power_of_2_neg_limb);\n    register_bench!(runner, benchmark_limbs_eq_mod_power_of_2_neg_pos);\n    register_bench!(\n        runner,\n        benchmark_integer_eq_mod_power_of_2_library_comparison\n    );\n}\n\nfn demo_limbs_eq_mod_power_of_2_neg_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y, pow) in unsigned_vec_unsigned_unsigned_triple_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_mod_power_of_2_neg_limb({:?}, {}, {}) = {:?}\",\n            xs,\n            y,\n            pow,\n            limbs_eq_mod_power_of_2_neg_limb(&xs, y, pow)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_power_of_2_neg_pos(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_mod_power_of_2_neg_pos({:?}, {:?}, {}) = {:?}\",\n            xs,\n            ys,\n            pow,\n            limbs_eq_mod_power_of_2_neg_pos(&xs, &ys, pow)\n        );\n    }\n}\n\nfn demo_integer_eq_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in integer_integer_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_mod_power_of_2(&y, pow) {\n            println!(\"{x} is equal to {y} mod 2^{pow}\");\n        } else {\n            println!(\"{x} is not equal to {y} mod 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_limbs_eq_mod_power_of_2_neg_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_power_of_2_neg_limb(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y, pow)| {\n            no_out!(limbs_eq_mod_power_of_2_neg_limb(&xs, y, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_eq_mod_power_of_2_neg_pos(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_power_of_2_neg_pos(&[Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys, pow)| {\n            no_out!(limbs_eq_mod_power_of_2_neg_pos(xs, ys, pow));\n        })],\n    );\n}\n\nfn benchmark_integer_eq_mod_power_of_2_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_mod_power_of_2(&Integer, u64)\",\n        BenchmarkType::LibraryComparison,\n        integer_integer_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (ref n, ref u, pow))| {\n                no_out!(n.eq_mod_power_of_2(u, pow));\n            }),\n            (\"rug\", &mut |((ref n, ref u, pow), _)| {\n                no_out!(n.is_congruent_2pow(u, u32::exact_from(pow)));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ExtendedGcd;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_integer_max_bit_bucketer, triple_3_pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_nrm};\nuse num::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_extended_gcd);\n    register_demo!(runner, demo_integer_extended_gcd_val_ref);\n    register_demo!(runner, demo_integer_extended_gcd_ref_val);\n    register_demo!(runner, demo_integer_extended_gcd_ref_ref);\n\n    register_bench!(runner, benchmark_integer_extended_gcd_library_comparison);\n    register_bench!(runner, benchmark_integer_extended_gcd_evaluation_strategy);\n}\n\nfn demo_integer_extended_gcd(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).extended_gcd({}) = {:?}\",\n            x_old,\n            y_old,\n            x.extended_gcd(y)\n        );\n    }\n}\n\nfn demo_integer_extended_gcd_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"({}).extended_gcd(&{}) = {:?}\",\n            x_old,\n            y,\n            x.extended_gcd(&y)\n        );\n    }\n}\n\nfn demo_integer_extended_gcd_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).extended_gcd({}) = {:?}\",\n            x,\n            y_old,\n            (&x).extended_gcd(y)\n        );\n    }\n}\n\nfn demo_integer_extended_gcd_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).extended_gcd(&{}) = {:?}\",\n            x,\n            y,\n            (&x).extended_gcd(&y)\n        );\n    }\n}\n\nfn benchmark_integer_extended_gcd_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.extended_gcd(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| {\n                no_out!(x.extended_gcd(y));\n            }),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.extended_gcd(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| {\n                no_out!(x.extended_gcd(y, rug::Integer::new()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_extended_gcd_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.extended_gcd(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer.extended_gcd(Integer)\", &mut |(x, y)| {\n                no_out!(x.extended_gcd(y));\n            }),\n            (\"Integer.extended_gcd(&Integer)\", &mut |(x, y)| {\n                no_out!(x.extended_gcd(&y));\n            }),\n            (\"&Integer.extended_gcd(Integer)\", &mut |(x, y)| {\n                no_out!((&x).extended_gcd(y));\n            }),\n            (\"&Integer.extended_gcd(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).extended_gcd(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{JacobiSymbol, KroneckerSymbol};\nuse malachite_base::test_util::bench::bucketers::quadruple_1_3_vec_max_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::large_type_gen_var_27;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::arithmetic::kronecker_symbol::limbs_kronecker_symbol;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_integer_bit_bucketer, pair_2_pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen, integer_pair_gen_rm, integer_pair_gen_var_4, integer_pair_gen_var_4_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_kronecker_symbol);\n    register_demo!(runner, demo_integer_jacobi_symbol);\n    register_demo!(runner, demo_integer_jacobi_symbol_val_ref);\n    register_demo!(runner, demo_integer_jacobi_symbol_ref_val);\n    register_demo!(runner, demo_integer_jacobi_symbol_ref_ref);\n    register_demo!(runner, demo_integer_kronecker_symbol);\n    register_demo!(runner, demo_integer_kronecker_symbol_val_ref);\n    register_demo!(runner, demo_integer_kronecker_symbol_ref_val);\n    register_demo!(runner, demo_integer_kronecker_symbol_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_kronecker_symbol);\n    register_bench!(runner, benchmark_integer_jacobi_symbol_library_comparison);\n    register_bench!(runner, benchmark_integer_jacobi_symbol_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_integer_kronecker_symbol_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_kronecker_symbol_evaluation_strategy\n    );\n}\n\nfn demo_limbs_kronecker_symbol(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_sign, xs, y_sign, ys) in large_type_gen_var_27().get(gm, config).take(limit) {\n        println!(\n            \"limbs_kronecker_symbol({}, {:?}, {}, {:?}) = {}\",\n            x_sign,\n            xs,\n            y_sign,\n            ys,\n            limbs_kronecker_symbol(x_sign, &xs, y_sign, &ys)\n        );\n    }\n}\n\nfn demo_integer_jacobi_symbol(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen_var_4().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        println!(\n            \"({}).jacobi_symbol({}) = {}\",\n            n_old,\n            m_old,\n            n.jacobi_symbol(m)\n        );\n    }\n}\n\nfn demo_integer_jacobi_symbol_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen_var_4().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\"({}).jacobi_symbol({}) = {}\", n_old, m, n.jacobi_symbol(&m));\n    }\n}\n\nfn demo_integer_jacobi_symbol_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen_var_4().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\n            \"({}).jacobi_symbol({}) = {}\",\n            n,\n            m_old,\n            (&n).jacobi_symbol(m)\n        );\n    }\n}\n\nfn demo_integer_jacobi_symbol_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen_var_4().get(gm, config).take(limit) {\n        println!(\"({}).jacobi_symbol({}) = {}\", n, m, (&n).jacobi_symbol(&m));\n    }\n}\n\nfn demo_integer_kronecker_symbol(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        println!(\n            \"({}).kronecker_symbol({}) = {}\",\n            n_old,\n            m_old,\n            n.kronecker_symbol(m)\n        );\n    }\n}\n\nfn demo_integer_kronecker_symbol_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\n            \"({}).kronecker_symbol({}) = {}\",\n            n_old,\n            m,\n            n.kronecker_symbol(&m)\n        );\n    }\n}\n\nfn demo_integer_kronecker_symbol_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\n            \"({}).kronecker_symbol({}) = {}\",\n            n,\n            m_old,\n            (&n).kronecker_symbol(m)\n        );\n    }\n}\n\nfn demo_integer_kronecker_symbol_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"({}).kronecker_symbol({}) = {}\",\n            n,\n            m,\n            (&n).kronecker_symbol(&m)\n        );\n    }\n}\n\nfn benchmark_limbs_kronecker_symbol(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_kronecker_symbol(bool, &[Limb], bool, &[Limb])\",\n        BenchmarkType::Single,\n        large_type_gen_var_27().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_3_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(x_sign, xs, y_sign, ys)| {\n            no_out!(limbs_kronecker_symbol(x_sign, &xs, y_sign, &ys));\n        })],\n    );\n}\n\nfn benchmark_integer_jacobi_symbol_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.jacobi_symbol(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_4_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.jacobi_symbol(y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.jacobi(&y))),\n        ],\n    );\n}\n\nfn benchmark_integer_jacobi_symbol_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.jacobi_symbol(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"m\"),\n        &mut [\n            (\"Integer.jacobi_symbol(Integer)\", &mut |(n, m)| {\n                no_out!(n.jacobi_symbol(m));\n            }),\n            (\"Integer.jacobi_symbol(&Integer)\", &mut |(n, m)| {\n                no_out!(n.jacobi_symbol(&m));\n            }),\n            (\"(&Integer).jacobi_symbol(Integer)\", &mut |(n, m)| {\n                no_out!((&n).jacobi_symbol(m));\n            }),\n            (\"(&Integer).jacobi_symbol(&Integer)\", &mut |(n, m)| {\n                no_out!((&n).jacobi_symbol(&m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_kronecker_symbol_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.kronecker_symbol(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.kronecker_symbol(y));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.kronecker(&y))),\n        ],\n    );\n}\n\nfn benchmark_integer_kronecker_symbol_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.kronecker_symbol(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"m\"),\n        &mut [\n            (\"Integer.kronecker_symbol(Integer)\", &mut |(n, m)| {\n                no_out!(n.kronecker_symbol(m));\n            }),\n            (\"Integer.kronecker_symbol(&Integer)\", &mut |(n, m)| {\n                no_out!(n.kronecker_symbol(&m));\n            }),\n            (\"(&Integer).kronecker_symbol(Integer)\", &mut |(n, m)| {\n                no_out!((&n).kronecker_symbol(m));\n            }),\n            (\"(&Integer).kronecker_symbol(&Integer)\", &mut |(n, m)| {\n                no_out!((&n).kronecker_symbol(&m));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    abs::register(runner);\n    abs_diff::register(runner);\n    add::register(runner);\n    add_mul::register(runner);\n    binomial_coefficient::register(runner);\n    div::register(runner);\n    div_exact::register(runner);\n    div_mod::register(runner);\n    div_round::register(runner);\n    divisible_by::register(runner);\n    divisible_by_power_of_2::register(runner);\n    eq_mod::register(runner);\n    eq_mod_power_of_2::register(runner);\n    extended_gcd::register(runner);\n    kronecker_symbol::register(runner);\n    mod_op::register(runner);\n    mod_power_of_2::register(runner);\n    mul::register(runner);\n    neg::register(runner);\n    parity::register(runner);\n    pow::register(runner);\n    power_of_2::register(runner);\n    root::register(runner);\n    round_to_multiple::register(runner);\n    round_to_multiple_of_power_of_2::register(runner);\n    shl::register(runner);\n    shl_round::register(runner);\n    shr::register(runner);\n    shr_round::register(runner);\n    sign::register(runner);\n    sqrt::register(runner);\n    square::register(runner);\n    sub::register(runner);\n    sub_mul::register(runner);\n}\n\nmod abs;\nmod abs_diff;\nmod add;\nmod add_mul;\nmod binomial_coefficient;\nmod div;\nmod div_exact;\nmod div_mod;\nmod div_round;\nmod divisible_by;\nmod divisible_by_power_of_2;\nmod eq_mod;\nmod eq_mod_power_of_2;\nmod extended_gcd;\nmod kronecker_symbol;\nmod mod_op;\nmod mod_power_of_2;\nmod mul;\nmod neg;\nmod parity;\nmod pow;\nmod power_of_2;\nmod root;\nmod round_to_multiple;\nmod round_to_multiple_of_power_of_2;\nmod shl;\nmod shl_round;\nmod shr;\nmod shr_round;\nmod sign;\nmod sqrt;\nmod square;\nmod sub;\nmod sub_mul;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivMod, CeilingMod, CeilingModAssign, DivMod, DivRem, Mod, ModAssign,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, pair_2_pair_1_integer_bit_bucketer,\n    triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen_var_1, integer_pair_gen_var_1_nrm, integer_pair_gen_var_1_rm,\n};\nuse num::Integer as NumInteger;\nuse rug::ops::RemRounding;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_mod);\n    register_demo!(runner, demo_integer_mod_val_ref);\n    register_demo!(runner, demo_integer_mod_ref_val);\n    register_demo!(runner, demo_integer_mod_ref_ref);\n    register_demo!(runner, demo_integer_mod_assign);\n    register_demo!(runner, demo_integer_mod_assign_ref);\n    register_demo!(runner, demo_integer_rem);\n    register_demo!(runner, demo_integer_rem_val_ref);\n    register_demo!(runner, demo_integer_rem_ref_val);\n    register_demo!(runner, demo_integer_rem_ref_ref);\n    register_demo!(runner, demo_integer_rem_assign);\n    register_demo!(runner, demo_integer_rem_assign_ref);\n    register_demo!(runner, demo_integer_ceiling_mod);\n    register_demo!(runner, demo_integer_ceiling_mod_val_ref);\n    register_demo!(runner, demo_integer_ceiling_mod_ref_val);\n    register_demo!(runner, demo_integer_ceiling_mod_ref_ref);\n    register_demo!(runner, demo_integer_ceiling_mod_assign);\n    register_demo!(runner, demo_integer_ceiling_mod_assign_ref);\n\n    register_bench!(runner, benchmark_integer_mod_library_comparison);\n    register_bench!(runner, benchmark_integer_mod_algorithms);\n    register_bench!(runner, benchmark_integer_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_mod_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_rem_library_comparison);\n    register_bench!(runner, benchmark_integer_rem_algorithms);\n    register_bench!(runner, benchmark_integer_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_rem_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_ceiling_mod_library_comparison);\n    register_bench!(runner, benchmark_integer_ceiling_mod_algorithms);\n    register_bench!(runner, benchmark_integer_ceiling_mod_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_integer_ceiling_mod_assign_evaluation_strategy\n    );\n}\n\nfn demo_integer_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.mod_op({}) = {}\", x_old, y_old, x.mod_op(y));\n    }\n}\n\nfn demo_integer_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.mod_op(&{}) = {}\", x_old, y, x.mod_op(&y));\n    }\n}\n\nfn demo_integer_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).mod_op({}) = {:?}\", x, y_old, (&x).mod_op(y));\n    }\n}\n\nfn demo_integer_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"(&{}).mod_op(&{}) = {:?}\", x, y, (&x).mod_op(&y));\n    }\n}\n\nfn demo_integer_mod_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mod_assign(y);\n        println!(\"x := {x_old}; x.mod_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_integer_mod_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.mod_assign(&y);\n        println!(\"x := {x_old}; x.mod_assign(&{y}); x = {x}\");\n    }\n}\n\nfn demo_integer_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} % {} = {:?}\", x_old, y_old, x % y);\n    }\n}\n\nfn demo_integer_rem_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} % &{} = {:?}\", x_old, y, x % &y);\n    }\n}\n\nfn demo_integer_rem_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} % {} = {:?}\", x, y_old, &x % y);\n    }\n}\n\nfn demo_integer_rem_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"&{} % &{} = {:?}\", x, y, &x % &y);\n    }\n}\n\nfn demo_integer_rem_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x %= y;\n        println!(\"x := {x_old}; x %= {y_old}; x = {x}\");\n    }\n}\n\nfn demo_integer_rem_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x %= &y;\n        println!(\"x := {x_old}; x %= &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_ceiling_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.ceiling_mod({}) = {}\", x_old, y_old, x.ceiling_mod(y));\n    }\n}\n\nfn demo_integer_ceiling_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.ceiling_mod(&{}) = {}\", x_old, y, x.ceiling_mod(&y));\n    }\n}\n\nfn demo_integer_ceiling_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).ceiling_mod({}) = {}\", x, y_old, (&x).ceiling_mod(y));\n    }\n}\n\nfn demo_integer_ceiling_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"(&{}).ceiling_mod(&{}) = {}\", x, y, (&x).ceiling_mod(&y));\n    }\n}\n\nfn demo_integer_ceiling_mod_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.ceiling_mod_assign(y);\n        println!(\"x := {x_old}; x.ceiling_mod_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_integer_ceiling_mod_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.ceiling_mod_assign(&y);\n        println!(\"x := {x_old}; x.ceiling_mod_assign(&{y}); x = {x}\");\n    }\n}\n\nfn benchmark_integer_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.mod_op(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.mod_op(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.mod_floor(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.rem_floor(y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.mod_op(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.mod_op(y))),\n            (\"using div_mod\", &mut |(x, y)| no_out!(x.div_mod(y).1)),\n        ],\n    );\n}\n\nfn benchmark_integer_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.mod_op(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.mod_op(Integer)\", &mut |(x, y)| {\n                no_out!(x.mod_op(y));\n            }),\n            (\"Integer.mod_op(&Integer)\", &mut |(x, y)| {\n                no_out!(x.mod_op(&y));\n            }),\n            (\"(&Integer).mod_op(Integer)\", &mut |(x, y)| {\n                no_out!((&x).mod_op(y));\n            }),\n            (\"(&Integer).mod_op(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).mod_op(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_mod_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.mod_assign(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.mod_assign(Integer)\", &mut |(mut x, y)| {\n                no_out!(x.mod_assign(y));\n            }),\n            (\"Integer.mod_assign(&Integer)\", &mut |(mut x, y)| {\n                no_out!(x.mod_assign(&y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.rem(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x % y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x % y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x % y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_rem_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.rem(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x % y)),\n            (\"using div_rem\", &mut |(x, y)| no_out!(x.div_rem(y).1)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.rem(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer % Integer\", &mut |(x, y)| no_out!(x % y)),\n            (\"Integer % &Integer\", &mut |(x, y)| no_out!(x % &y)),\n            (\"&Integer % Integer\", &mut |(x, y)| no_out!(&x % y)),\n            (\"&Integer % &Integer\", &mut |(x, y)| no_out!(&x % &y)),\n        ],\n    );\n}\n\nfn benchmark_integer_rem_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.rem_assign(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer %= Integer\", &mut |(mut x, y)| x %= y),\n            (\"Integer %= &Integer\", &mut |(mut x, y)| x %= &y),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_mod(Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.ceiling_mod(y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.rem_ceil(y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_ceiling_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_mod(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.ceiling_mod(y))),\n            (\"using ceiling_div_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_mod(y).1);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_mod(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.ceiling_mod(Integer)\", &mut |(x, y)| {\n                no_out!(x.ceiling_mod(y));\n            }),\n            (\"Integer.ceiling_mod(&Integer)\", &mut |(x, y)| {\n                no_out!(x.ceiling_mod(&y));\n            }),\n            (\"(&Integer).ceiling_mod(Integer)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_mod(y));\n            }),\n            (\"(&Integer).ceiling_mod(&Integer)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_mod(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_mod_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_mod_assign(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.ceiling_mod_assign(Integer)\", &mut |(mut x, y)| {\n                no_out!(x.ceiling_mod_assign(y));\n            }),\n            (\"Integer.ceiling_mod_assign(&Integer)\", &mut |(mut x, y)| {\n                no_out!(x.ceiling_mod_assign(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingModPowerOf2, CeilingModPowerOf2Assign, ModPowerOf2, ModPowerOf2Assign, RemPowerOf2,\n    RemPowerOf2Assign,\n};\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_mod_power_of_2_assign);\n    register_demo!(runner, demo_integer_mod_power_of_2);\n    register_demo!(runner, demo_integer_mod_power_of_2_ref);\n    register_demo!(runner, demo_integer_rem_power_of_2_assign);\n    register_demo!(runner, demo_integer_rem_power_of_2);\n    register_demo!(runner, demo_integer_rem_power_of_2_ref);\n    register_demo!(runner, demo_integer_ceiling_mod_power_of_2_assign);\n    register_demo!(runner, demo_integer_ceiling_mod_power_of_2);\n    register_demo!(runner, demo_integer_ceiling_mod_power_of_2_ref);\n\n    register_bench!(runner, benchmark_integer_mod_power_of_2_assign);\n    register_bench!(runner, benchmark_integer_mod_power_of_2_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_rem_power_of_2_assign);\n    register_bench!(runner, benchmark_integer_rem_power_of_2_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_ceiling_mod_power_of_2_assign);\n    register_bench!(\n        runner,\n        benchmark_integer_ceiling_mod_power_of_2_evaluation_strategy\n    );\n}\n\nfn demo_integer_mod_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_power_of_2_assign(u);\n        println!(\"x := {n_old}; x.mod_power_of_2_assign({u}); x = {n}\");\n    }\n}\n\nfn demo_integer_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.mod_power_of_2({}) = {}\", n_old, u, n.mod_power_of_2(u));\n    }\n}\n\nfn demo_integer_mod_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mod_power_of_2({}) = {}\",\n            n,\n            u,\n            (&n).mod_power_of_2(u)\n        );\n    }\n}\n\nfn demo_integer_rem_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.rem_power_of_2_assign(u);\n        println!(\"x := {n_old}; x.rem_power_of_2_assign({u}); x = {n}\");\n    }\n}\n\nfn demo_integer_rem_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.rem_power_of_2({}) = {}\", n_old, u, n.rem_power_of_2(u));\n    }\n}\n\nfn demo_integer_rem_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).rem_power_of_2({}) = {}\",\n            n,\n            u,\n            (&n).rem_power_of_2(u)\n        );\n    }\n}\n\nfn demo_integer_ceiling_mod_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.ceiling_mod_power_of_2_assign(u);\n        println!(\"x := {n_old}; x.ceiling_mod_power_of_2_assign({u}); x = {n}\");\n    }\n}\n\nfn demo_integer_ceiling_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.ceiling_mod_power_of_2({}) = {}\",\n            n_old,\n            u,\n            n.ceiling_mod_power_of_2(u)\n        );\n    }\n}\n\nfn demo_integer_ceiling_mod_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).ceiling_mod_power_of_2({}) = {}\",\n            n,\n            u,\n            (&n).ceiling_mod_power_of_2(u)\n        );\n    }\n}\n\nfn benchmark_integer_mod_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.mod_power_of_2_assign(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n.mod_power_of_2_assign(u))],\n    );\n}\n\nfn benchmark_integer_mod_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.mod_power_of_2(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [\n            (\"Integer.mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!(n.mod_power_of_2(u));\n            }),\n            (\"(&Integer).mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!((&n).mod_power_of_2(u));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_rem_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.rem_power_of_2_assign(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n.rem_power_of_2_assign(u))],\n    );\n}\n\nfn benchmark_integer_rem_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.rem_power_of_2(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [\n            (\"Integer.rem_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!(n.rem_power_of_2(u));\n            }),\n            (\"(&Integer).rem_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!((&n).rem_power_of_2(u));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_mod_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_mod_power_of_2_assign(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| {\n            n.ceiling_mod_power_of_2_assign(u);\n        })],\n    );\n}\n\nfn benchmark_integer_ceiling_mod_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_mod_power_of_2(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [\n            (\"Integer.ceiling_mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!(n.ceiling_mod_power_of_2(u));\n            }),\n            (\"(&Integer).ceiling_mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!((&n).ceiling_mod_power_of_2(u));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n    triple_3_pair_integer_max_bit_bucketer, triple_3_vec_integer_sum_bits_bucketer,\n    vec_integer_sum_bits_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen, integer_pair_gen_nrm, integer_pair_gen_rm, integer_vec_gen,\n    integer_vec_gen_nrm,\n};\nuse malachite_nz::test_util::integer::arithmetic::mul::integer_product_naive;\nuse num::BigInt;\nuse std::iter::Product;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_mul);\n    register_demo!(runner, demo_integer_mul_val_ref);\n    register_demo!(runner, demo_integer_mul_ref_val);\n    register_demo!(runner, demo_integer_mul_ref_ref);\n    register_demo!(runner, demo_integer_mul_assign);\n    register_demo!(runner, demo_integer_mul_assign_ref);\n    register_demo!(runner, demo_integer_product);\n    register_demo!(runner, demo_integer_ref_product);\n\n    register_bench!(runner, benchmark_integer_mul_library_comparison);\n    register_bench!(runner, benchmark_integer_mul_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_mul_assign_library_comparison);\n    register_bench!(runner, benchmark_integer_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_product_algorithms);\n    register_bench!(runner, benchmark_integer_product_library_comparison);\n    register_bench!(runner, benchmark_integer_product_evaluation_strategy);\n}\n\nfn demo_integer_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_integer_mul_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} * &{} = {}\", x_old, y, x * &y);\n    }\n}\n\nfn demo_integer_mul_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} * {} = {}\", x, y_old, &x * y);\n    }\n}\n\nfn demo_integer_mul_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} * &{} = {}\", x, y, &x * &y);\n    }\n}\n\nfn demo_integer_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\"x := {x_old}; x *= {y}; x = {x}\");\n    }\n}\n\nfn demo_integer_mul_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\"x := {x_old}; x *= &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_product(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in integer_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"product({:?}) = {}\",\n            xs.clone(),\n            Integer::product(xs.into_iter())\n        );\n    }\n}\n\nfn demo_integer_ref_product(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in integer_vec_gen().get(gm, config).take(limit) {\n        println!(\"product({:?}) = {}\", xs, Integer::product(xs.iter()));\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_mul_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer * Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x * y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x * y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x * y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer * Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer * Integer\", &mut |(x, y)| no_out!(x * y)),\n            (\"Integer * &Integer\", &mut |(x, y)| no_out!(x * &y)),\n            (\"&Integer * Integer\", &mut |(x, y)| no_out!(&x * y)),\n            (\"&Integer * &Integer\", &mut |(x, y)| no_out!(&x * &y)),\n        ],\n    );\n}\n\nfn benchmark_integer_mul_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer *= Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x *= y), (\"rug\", &mut |((mut x, y), _)| x *= y)],\n    );\n}\n\nfn benchmark_integer_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer *= Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer *= Integer\", &mut |(mut x, y)| no_out!(x *= y)),\n            (\"Integer *= &Integer\", &mut |(mut x, y)| no_out!(x *= &y)),\n        ],\n    );\n}\n\nfn benchmark_integer_product_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::product(Iterator<Item=Integer>)\",\n        BenchmarkType::LibraryComparison,\n        integer_vec_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_integer_sum_bits_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, xs)| {\n                no_out!(Integer::product(xs.into_iter()));\n            }),\n            (\"num\", &mut |(xs, _, _)| {\n                no_out!(BigInt::product(xs.into_iter()));\n            }),\n            (\"rug\", &mut |(_, xs, _)| {\n                no_out!(rug::Integer::product(xs.iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_product_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::product(Iterator<Item=Integer>)\",\n        BenchmarkType::Algorithms,\n        integer_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_integer_sum_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |xs| {\n                no_out!(Integer::product(xs.into_iter()));\n            }),\n            (\"naive\", &mut |xs| {\n                no_out!(integer_product_naive(xs.into_iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_product_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::product(Iterator<Item=Integer>)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_integer_sum_bits_bucketer(),\n        &mut [\n            (\"Integer::product(Iterator<Item=Integer>)\", &mut |xs| {\n                no_out!(Integer::product(xs.into_iter()));\n            }),\n            (\"Integer::product(Iterator<Item=&Integer>)\", &mut |xs| {\n                no_out!(Integer::product(xs.iter()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, triple_3_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_neg);\n    register_demo!(runner, demo_integer_neg_ref);\n    register_demo!(runner, demo_integer_neg_assign);\n\n    register_bench!(runner, benchmark_integer_neg_library_comparison);\n    register_bench!(runner, benchmark_integer_neg_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_neg_assign);\n}\n\nfn demo_integer_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"-{} = {}\", n.clone(), -n);\n    }\n}\n\nfn demo_integer_neg_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"-(&{}) = {}\", n.clone(), -n);\n    }\n}\n\nfn demo_integer_neg_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in integer_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.neg_assign();\n        println!(\"n := {n_old}; n.neg_assign(); n = {n}\");\n    }\n}\n\n#[allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)]\nfn benchmark_integer_neg_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(-x)),\n            (\"num\", &mut |(x, _, _)| no_out!(-x)),\n            (\"rug\", &mut |(_, x, _)| no_out!(-x)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_integer_neg_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"-Integer\", &mut |x| no_out!(-x)), (\"-&Integer\", &mut |x| no_out!(-&x))],\n    );\n}\n\nfn benchmark_integer_neg_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"-Integer\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.neg_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_even);\n    register_demo!(runner, demo_integer_odd);\n\n    register_bench!(runner, benchmark_integer_even);\n    register_bench!(runner, benchmark_integer_odd);\n}\n\nfn demo_integer_even(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        if n.even() {\n            println!(\"{n} is even\");\n        } else {\n            println!(\"{n} is not even\");\n        }\n    }\n}\n\nfn demo_integer_odd(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        if n.even() {\n            println!(\"{n} is odd\");\n        } else {\n            println!(\"{n} is not odd\");\n        }\n    }\n}\n\nfn benchmark_integer_even(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.even()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.even()))],\n    );\n}\n\nfn benchmark_integer_odd(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.odd()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.odd()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Pow, PowAssign};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::pair_1_bits_times_pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_pair_1_integer_bits_times_pair_2_bucketer;\nuse malachite_nz::test_util::generators::{\n    integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_2_nrm,\n};\nuse rug::ops::Pow as RugPow;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_pow_assign);\n    register_demo!(runner, demo_integer_pow);\n    register_demo!(runner, demo_integer_pow_ref);\n\n    register_bench!(runner, benchmark_integer_pow_assign);\n    register_bench!(runner, benchmark_integer_pow_library_comparison);\n    register_bench!(runner, benchmark_integer_pow_evaluation_strategy);\n}\n\nfn demo_integer_pow_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, pow) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.pow_assign(pow);\n        println!(\"x := {n_old}; x.pow_assign({pow}); x = {n}\");\n    }\n}\n\nfn demo_integer_pow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"({}).pow({}) = {}\", n_old, pow, n.pow(pow));\n    }\n}\n\nfn demo_integer_pow_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).pow({}) = {}\", n, pow, (&n).pow(pow));\n    }\n}\n\nfn benchmark_integer_pow_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.pow_assign(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bits_times_pair_2_bucketer(\"n\", \"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp)| x.pow_assign(exp))],\n    );\n}\n\nfn benchmark_integer_pow_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.pow_assign(u64)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bits_times_pair_2_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, exp))| no_out!(x.pow(exp))),\n            (\"num\", &mut |((x, exp), _, _)| {\n                no_out!(x.pow(u32::exact_from(exp)));\n            }),\n            (\"rug\", &mut |(_, (x, exp), _)| {\n                no_out!(x.pow(u32::exact_from(exp)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_pow_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.pow(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bits_times_pair_2_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\"Integer.pow(u64)\", &mut |(x, exp)| no_out!(x.pow(exp))),\n            (\"(&Integer).pow(u64)\", &mut |(x, exp)| {\n                no_out!((&x).pow(exp));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_5;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_power_of_2);\n    register_bench!(runner, benchmark_integer_power_of_2);\n}\n\nfn demo_integer_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for pow in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"2^{} = {}\", pow, Integer::power_of_2(pow));\n    }\n}\n\nfn benchmark_integer_power_of_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer::power_of_2(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |pow| no_out!(Integer::power_of_2(pow)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingRootAssign, CheckedRoot, FloorRoot, FloorRootAssign,\n};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_1_integer_bit_bucketer, triple_3_integer_bit_bucketer,\n    triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_nrm, integer_unsigned_pair_gen_var_3,\n    integer_unsigned_pair_gen_var_3_nrm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_floor_cbrt);\n    register_demo!(runner, demo_integer_floor_cbrt_ref);\n    register_demo!(runner, demo_integer_floor_cbrt_assign);\n    register_demo!(runner, demo_integer_ceiling_cbrt);\n    register_demo!(runner, demo_integer_ceiling_cbrt_ref);\n    register_demo!(runner, demo_integer_ceiling_cbrt_assign);\n    register_demo!(runner, demo_integer_checked_cbrt);\n    register_demo!(runner, demo_integer_checked_cbrt_ref);\n\n    register_demo!(runner, demo_integer_floor_root);\n    register_demo!(runner, demo_integer_floor_root_ref);\n    register_demo!(runner, demo_integer_floor_root_assign);\n    register_demo!(runner, demo_integer_ceiling_root);\n    register_demo!(runner, demo_integer_ceiling_root_ref);\n    register_demo!(runner, demo_integer_ceiling_root_assign);\n    register_demo!(runner, demo_integer_checked_root);\n    register_demo!(runner, demo_integer_checked_root_ref);\n\n    register_bench!(runner, benchmark_integer_floor_cbrt_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_floor_cbrt_library_comparison);\n    register_bench!(runner, benchmark_integer_floor_cbrt_assign);\n    register_bench!(runner, benchmark_integer_ceiling_cbrt_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_ceiling_cbrt_assign);\n    register_bench!(runner, benchmark_integer_checked_cbrt_evaluation_strategy);\n\n    register_bench!(runner, benchmark_integer_floor_root_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_floor_root_library_comparison);\n    register_bench!(runner, benchmark_integer_floor_root_assign);\n    register_bench!(runner, benchmark_integer_ceiling_root_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_ceiling_root_assign);\n    register_bench!(runner, benchmark_integer_checked_root_evaluation_strategy);\n}\n\nfn demo_integer_floor_cbrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"({}).floor_root(3) = {}\", x, x.clone().floor_root(3));\n    }\n}\n\nfn demo_integer_floor_cbrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).floor_root(3) = {}\", x, (&x).floor_root(3));\n    }\n}\n\nfn demo_integer_floor_cbrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in integer_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.floor_root_assign(3);\n        println!(\"x := {old_x}; x.floor_root_assign(3); x = {x}\");\n    }\n}\n\nfn demo_integer_ceiling_cbrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"({}).ceiling_root(3) = {}\", x, x.clone().ceiling_root(3));\n    }\n}\n\nfn demo_integer_ceiling_cbrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).ceiling_root(3) = {}\", x, (&x).ceiling_root(3));\n    }\n}\n\nfn demo_integer_ceiling_cbrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in integer_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.ceiling_root_assign(3);\n        println!(\"x := {old_x}; x.ceiling_root_assign(3); x = {x}\");\n    }\n}\n\nfn demo_integer_checked_cbrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"({}).checked_root(3) = {:?}\", x, x.clone().checked_root(3));\n    }\n}\n\nfn demo_integer_checked_cbrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_root(3) = {:?}\", x, (&x).checked_root(3));\n    }\n}\n\nfn demo_integer_floor_root(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).floor_root({}) = {}\",\n            x,\n            exp,\n            x.clone().floor_root(exp)\n        );\n    }\n}\n\nfn demo_integer_floor_root_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).floor_root({}) = {}\", x, exp, (&x).floor_root(exp));\n    }\n}\n\nfn demo_integer_floor_root_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        x.floor_root_assign(exp);\n        println!(\"x := {old_x}; x.floor_root_assign(); x = {x}\");\n    }\n}\n\nfn demo_integer_ceiling_root(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).ceiling_root({}) = {}\",\n            x,\n            exp,\n            x.clone().ceiling_root(exp)\n        );\n    }\n}\n\nfn demo_integer_ceiling_root_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).ceiling_root({}) = {}\",\n            x,\n            exp,\n            (&x).ceiling_root(exp)\n        );\n    }\n}\n\nfn demo_integer_ceiling_root_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        x.ceiling_root_assign(exp);\n        println!(\"x := {old_x}; x.ceiling_root_assign({exp}); x = {x}\");\n    }\n}\n\nfn demo_integer_checked_root(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).checked_root({}) = {:?}\",\n            x,\n            exp,\n            x.clone().checked_root(exp)\n        );\n    }\n}\n\nfn demo_integer_checked_root_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in integer_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).checked_root({}) = {:?}\",\n            x,\n            exp,\n            (&x).checked_root(exp)\n        );\n    }\n}\n\nfn benchmark_integer_floor_cbrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_root(3)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.floor_root(3)\", &mut |x| no_out!(x.floor_root(3))),\n            (\"(&Integer).floor_root(3)\", &mut |x| {\n                no_out!((&x).floor_root(3));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_floor_cbrt_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_root()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"num\", &mut |(x, _, _)| {\n                no_out!(x.nth_root(u32::exact_from(3)));\n            }),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.root(u32::exact_from(3)))),\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.floor_root(3))),\n        ],\n    );\n}\n\nfn benchmark_integer_floor_cbrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_root_assign(3)\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.floor_root_assign(3))],\n    );\n}\n\nfn benchmark_integer_ceiling_cbrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_root(3)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.ceiling_root(3)\", &mut |x| {\n                no_out!(x.ceiling_root(3));\n            }),\n            (\"(&Integer).ceiling_root(3)\", &mut |x| {\n                no_out!((&x).ceiling_root(3));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_cbrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_root_assign(3)\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.ceiling_root_assign(3))],\n    );\n}\n\nfn benchmark_integer_checked_cbrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.checked_root(3)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.checked_root(3)\", &mut |x| {\n                no_out!(x.checked_root(3));\n            }),\n            (\"(&Integer).checked_root(3)\", &mut |x| {\n                no_out!((&x).checked_root(3));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_floor_root_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_root(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.floor_root(u64)\", &mut |(x, exp)| {\n                no_out!(x.floor_root(exp));\n            }),\n            (\"(&Integer).floor_root(u64)\", &mut |(x, exp)| {\n                no_out!((&x).floor_root(exp));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_floor_root_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_root()\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_3_nrm::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"num\", &mut |((x, exp), _, _)| {\n                no_out!(x.nth_root(u32::exact_from(exp)));\n            }),\n            (\"rug\", &mut |(_, (x, exp), _)| {\n                no_out!(x.root(u32::exact_from(exp)));\n            }),\n            (\"Malachite\", &mut |(_, _, (x, exp))| {\n                no_out!(x.floor_root(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_floor_root_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_root_assign(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp)| x.floor_root_assign(exp))],\n    );\n}\n\nfn benchmark_integer_ceiling_root_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_root(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.ceiling_root(u64)\", &mut |(x, exp)| {\n                no_out!(x.ceiling_root(exp));\n            }),\n            (\"(&Integer).ceiling_root(u64)\", &mut |(x, exp)| {\n                no_out!((&x).ceiling_root(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_root_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_root_assign(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp)| x.ceiling_root_assign(exp))],\n    );\n}\n\nfn benchmark_integer_checked_root_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.checked_root(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.checked_root(u64)\", &mut |(x, exp)| {\n                no_out!(x.checked_root(exp));\n            }),\n            (\"(&Integer).checked_root(u64)\", &mut |(x, exp)| {\n                no_out!((&x).checked_root(exp));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{RoundToMultiple, RoundToMultipleAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_integer_rounding_mode_triple_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_round_to_multiple_assign);\n    register_demo!(runner, demo_integer_round_to_multiple_assign_ref);\n    register_demo!(runner, demo_integer_round_to_multiple);\n    register_demo!(runner, demo_integer_round_to_multiple_val_ref);\n    register_demo!(runner, demo_integer_round_to_multiple_ref_val);\n    register_demo!(runner, demo_integer_round_to_multiple_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_integer_round_to_multiple_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_round_to_multiple_evaluation_strategy\n    );\n}\n\nfn demo_integer_round_to_multiple_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in integer_integer_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.round_to_multiple_assign(y, rm);\n        println!(\"x := {x_old}; x.round_to_multiple_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_integer_round_to_multiple_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in integer_integer_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.round_to_multiple_assign(&y, rm);\n        println!(\"x := {x_old}; x.round_to_multiple_assign(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_integer_round_to_multiple(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).round_to_multiple({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_integer_round_to_multiple_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).round_to_multiple(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.round_to_multiple(&y, rm)\n        );\n    }\n}\n\nfn demo_integer_round_to_multiple_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).round_to_multiple({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            (&x).round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_integer_round_to_multiple_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in integer_integer_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).round_to_multiple(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            (&x).round_to_multiple(&y, rm)\n        );\n    }\n}\n\nfn benchmark_integer_round_to_multiple_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.round_to_multiple_assign(Integer, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_integer_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"Integer.round_to_multiple_assign(Integer, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.round_to_multiple_assign(y, rm)),\n            ),\n            (\n                \"Integer.round_to_multiple_assign(&Integer, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.round_to_multiple_assign(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_round_to_multiple_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.round_to_multiple(Integer, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_integer_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"Integer.round_to_multiple(Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple(y, rm)),\n            ),\n            (\n                \"Integer.round_to_multiple(&Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple(&y, rm)),\n            ),\n            (\n                \"(&Integer).round_to_multiple(Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple(y, rm)),\n            ),\n            (\n                \"(&Integer).round_to_multiple(&Integer, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple(&y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    PowerOf2, RoundToMultiple, RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign, ShrRound,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::triple_1_2_integer_bit_u64_max_bucketer;\nuse malachite_nz::test_util::generators::integer_unsigned_rounding_mode_triple_gen_var_1;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_round_to_multiple_of_power_of_2_assign);\n    register_demo!(runner, demo_integer_round_to_multiple_of_power_of_2);\n    register_demo!(runner, demo_integer_round_to_multiple_of_power_of_2_ref);\n\n    register_bench!(\n        runner,\n        benchmark_integer_round_to_multiple_of_power_of_2_assign\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_round_to_multiple_of_power_of_2_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_round_to_multiple_of_power_of_2_evaluation_strategy\n    );\n}\n\nfn demo_integer_round_to_multiple_of_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow, rm) in integer_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.round_to_multiple_of_power_of_2_assign(pow, rm);\n        println!(\n            \"x := {n_old}; x.round_to_multiple_of_power_of_2_assign({pow}, {rm}) = {o:?}; x = {n}\"\n        );\n    }\n}\n\nfn demo_integer_round_to_multiple_of_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow, rm) in integer_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"({}).round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            n_old,\n            pow,\n            rm,\n            n.round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn demo_integer_round_to_multiple_of_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow, rm) in integer_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            n,\n            pow,\n            rm,\n            (&n).round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn benchmark_integer_round_to_multiple_of_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.round_to_multiple_of_power_of_2_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        integer_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_integer_bit_u64_max_bucketer(\"n\", \"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.round_to_multiple_of_power_of_2_assign(y, rm));\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_round_to_multiple_of_power_of_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_integer_bit_u64_max_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.round_to_multiple_of_power_of_2(y, rm));\n            }),\n            (\"using shr_round\", &mut |(x, y, rm)| {\n                no_out!(x.shr_round(y, rm).0 << y);\n            }),\n            (\"using round_to_multiple\", &mut |(x, y, rm)| {\n                no_out!(x.round_to_multiple(Integer::power_of_2(y), rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_round_to_multiple_of_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_integer_bit_u64_max_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\n                \"Integer.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple_of_power_of_2(y, rm)),\n            ),\n            (\n                \"(&Integer).round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple_of_power_of_2(y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, pair_2_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_signed_pair_gen_var_1, integer_signed_pair_gen_var_1_rm,\n    integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_2_rm,\n};\nuse std::ops::{Shl, ShlAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_shl_assign_unsigned);\n    register_signed_demos!(runner, demo_integer_shl_assign_signed);\n    register_unsigned_demos!(runner, demo_integer_shl_unsigned);\n    register_signed_demos!(runner, demo_integer_shl_signed);\n    register_unsigned_demos!(runner, demo_integer_shl_unsigned_ref);\n    register_signed_demos!(runner, demo_integer_shl_signed_ref);\n\n    register_unsigned_benches!(runner, benchmark_integer_shl_assign_unsigned);\n    register_signed_benches!(runner, benchmark_integer_shl_assign_signed);\n    register_unsigned_benches!(runner, benchmark_integer_shl_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_integer_shl_signed_evaluation_strategy);\n\n    register_bench!(runner, benchmark_integer_shl_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_integer_shl_u32_library_comparison);\n    register_bench!(runner, benchmark_integer_shl_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_integer_shl_i32_library_comparison);\n}\n\nfn demo_integer_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: ShlAssign<T>,\n{\n    for (mut n, u) in integer_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= u;\n        println!(\"x := {n_old}; x <<= {u}; x = {n}\");\n    }\n}\n\nfn demo_integer_shl_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: ShlAssign<T>,\n{\n    for (mut n, i) in integer_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= i;\n        println!(\"x := {n_old}; x <<= {i}; x = {n}\");\n    }\n}\n\nfn demo_integer_shl_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    for (n, u) in integer_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, u, n << u);\n    }\n}\n\nfn demo_integer_shl_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    for (n, i) in integer_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, i, n << i);\n    }\n}\n\nfn demo_integer_shl_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n{\n    for (n, u) in integer_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, u, &n << u);\n    }\n}\n\nfn demo_integer_shl_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n{\n    for (n, i) in integer_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, i, &n << i);\n    }\n}\n\nfn benchmark_integer_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Integer <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n <<= u)],\n    );\n}\n\nfn benchmark_integer_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Integer <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, i)| n <<= i)],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_shl_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: Shl<T, Output = Integer>,\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Integer << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Integer << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_shl_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: Shl<T, Output = Integer>,\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        integer_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Integer << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Integer << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_shl_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer <<= u32\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_shl_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer << u32\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n\nfn benchmark_integer_shl_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer <<= i32\",\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_shl_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer << i32\",\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShlRound, ShlRoundAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::triple_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_signed_rounding_mode_triple_gen_var_1;\nuse std::ops::Shr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_integer_shl_round_assign);\n    register_signed_demos!(runner, demo_integer_shl_round);\n    register_signed_demos!(runner, demo_integer_shl_round_ref);\n\n    register_signed_benches!(runner, benchmark_integer_shl_round_assign);\n    register_signed_benches!(runner, benchmark_integer_shl_round_evaluation_strategy);\n}\n\nfn demo_integer_shl_round_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: ShlRoundAssign<T> + Shr<T, Output = Integer>,\n{\n    for (mut n, i, rm) in integer_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_round_assign(i, rm);\n        println!(\"x := {n_old}; x.shl_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_integer_shl_round<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: ShlRound<T, Output = Integer> + Shr<T, Output = Integer>,\n{\n    for (n, i, rm) in integer_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shl_round(i, rm)\n        );\n    }\n}\n\nfn demo_integer_shl_round_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: Shr<T, Output = Integer>,\n    for<'a> &'a Integer: ShlRound<T, Output = Integer>,\n{\n    for (n, i, rm) in integer_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shl_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            (&n).shl_round(i, rm)\n        );\n    }\n}\n\nfn benchmark_integer_shl_round_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShlRoundAssign<T> + Shr<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer.shl_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.shl_round_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_integer_shl_round_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShlRound<T, Output = Integer> + Shr<T, Output = Integer>,\n    for<'a> &'a Integer: ShlRound<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer.shl_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        integer_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Integer.shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!(x.shl_round(y, rm)),\n            ),\n            (\n                &format!(\"(&Integer).shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!((&x).shl_round(y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_integer_bit_bucketer, pair_2_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_signed_pair_gen_var_1, integer_signed_pair_gen_var_1_rm,\n    integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_2_rm,\n};\nuse std::ops::{Shr, ShrAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_shr_assign_unsigned);\n    register_signed_demos!(runner, demo_integer_shr_assign_signed);\n    register_unsigned_demos!(runner, demo_integer_shr_unsigned);\n    register_signed_demos!(runner, demo_integer_shr_signed);\n    register_unsigned_demos!(runner, demo_integer_shr_unsigned_ref);\n    register_signed_demos!(runner, demo_integer_shr_signed_ref);\n\n    register_unsigned_benches!(runner, benchmark_integer_shr_assign_unsigned);\n    register_signed_benches!(runner, benchmark_integer_shr_assign_signed);\n    register_unsigned_benches!(runner, benchmark_integer_shr_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_integer_shr_signed_evaluation_strategy);\n\n    register_bench!(runner, benchmark_integer_shr_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_integer_shr_u32_library_comparison);\n    register_bench!(runner, benchmark_integer_shr_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_integer_shr_i32_library_comparison);\n}\n\nfn demo_integer_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: ShrAssign<T>,\n{\n    for (mut n, u) in integer_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= u;\n        println!(\"x := {n_old}; x >>= {u}; x = {n}\");\n    }\n}\n\nfn demo_integer_shr_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: ShrAssign<T>,\n{\n    for (mut n, i) in integer_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= i;\n        println!(\"x := {n_old}; x >>= {i}; x = {n}\");\n    }\n}\n\nfn demo_integer_shr_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: Shr<T, Output = Integer>,\n{\n    for (n, u) in integer_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, u, n >> u);\n    }\n}\n\nfn demo_integer_shr_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: Shr<T, Output = Integer>,\n{\n    for (n, i) in integer_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, i, n >> i);\n    }\n}\n\nfn demo_integer_shr_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n{\n    for (n, u) in integer_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, u, &n >> u);\n    }\n}\n\nfn demo_integer_shr_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n{\n    for (n, i) in integer_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, i, &n >> i);\n    }\n}\n\nfn benchmark_integer_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Integer >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n >>= u)],\n    );\n}\n\nfn benchmark_integer_shr_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Integer >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, i)| n >>= i)],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_shr_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: Shr<T, Output = Integer>,\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Integer >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Integer >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_shr_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: Shr<T, Output = Integer>,\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        integer_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Integer >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Integer >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_shr_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer >>= u32\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_shr_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer >> u32\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n\nfn benchmark_integer_shr_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer >>= i32\",\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_shr_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer >> i32\",\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShrRound, ShrRoundAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::triple_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    integer_signed_rounding_mode_triple_gen_var_2, integer_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse std::ops::Shl;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_shr_round_assign_unsigned);\n    register_signed_demos!(runner, demo_integer_shr_round_assign_signed);\n    register_unsigned_demos!(runner, demo_integer_shr_round_unsigned);\n    register_signed_demos!(runner, demo_integer_shr_round_signed);\n    register_unsigned_demos!(runner, demo_integer_shr_round_ref_unsigned);\n    register_signed_demos!(runner, demo_integer_shr_round_ref_signed);\n\n    register_unsigned_benches!(runner, benchmark_integer_shr_round_assign_unsigned);\n    register_signed_benches!(runner, benchmark_integer_shr_round_assign_signed);\n    register_unsigned_benches!(\n        runner,\n        benchmark_integer_shr_round_evaluation_strategy_unsigned\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_integer_shr_round_evaluation_strategy_signed\n    );\n}\n\nfn demo_integer_shr_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: ShrRoundAssign<T> + Shl<T, Output = Integer>,\n{\n    for (mut n, u, rm) in integer_unsigned_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(u, rm);\n        println!(\"x := {n_old}; x.shr_round_assign({u}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_integer_shr_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: ShrRoundAssign<T> + Shl<T, Output = Integer>,\n{\n    for (mut n, i, rm) in integer_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(i, rm);\n        println!(\"x := {n_old}; x.shr_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_integer_shr_round_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: ShrRound<T, Output = Integer> + Shl<T, Output = Integer>,\n{\n    for (n, u, rm) in integer_unsigned_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            u,\n            rm,\n            n.shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_integer_shr_round_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: ShrRound<T, Output = Integer> + Shl<T, Output = Integer>,\n{\n    for (n, i, rm) in integer_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shr_round(i, rm)\n        );\n    }\n}\n\nfn demo_integer_shr_round_ref_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: Shl<T, Output = Integer>,\n    for<'a> &'a Integer: ShrRound<T, Output = Integer>,\n{\n    for (n, u, rm) in integer_unsigned_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shr_round({}, {}) = {:?}\",\n            n,\n            u,\n            rm,\n            (&n).shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_integer_shr_round_ref_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: Shl<T, Output = Integer>,\n    for<'a> &'a Integer: ShrRound<T, Output = Integer>,\n{\n    for (n, i, rm) in integer_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shr_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            (&n).shr_round(i, rm)\n        );\n    }\n}\n\nfn benchmark_integer_shr_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShrRoundAssign<T> + Shl<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer.shr_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.shr_round_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_integer_shr_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShrRoundAssign<T> + Shl<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer.shr_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.shr_round_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_integer_shr_round_evaluation_strategy_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShrRound<T, Output = Integer> + Shl<T, Output = Integer>,\n    for<'a> &'a Integer: ShrRound<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Integer.shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!(x.shr_round(y, rm)),\n            ),\n            (\n                &format!(\"(&Integer).shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!((&x).shr_round(y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_shr_round_evaluation_strategy_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ShrRound<T, Output = Integer> + Shl<T, Output = Integer>,\n    for<'a> &'a Integer: ShrRound<T, Output = Integer>,\n{\n    run_benchmark(\n        &format!(\"Integer.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        integer_signed_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Integer.shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!(x.shr_round(y, rm)),\n            ),\n            (\n                &format!(\"(&Integer).shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!((&x).shr_round(y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_nrm};\nuse malachite_nz::test_util::integer::arithmetic::sign::num_sign;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_sign);\n    register_bench!(runner, benchmark_integer_sign_library_comparison);\n}\n\nfn demo_integer_sign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        match n.sign() {\n            Less => println!(\"{n} is negative\"),\n            Equal => println!(\"{n} is zero\"),\n            Greater => println!(\"{n} is positive\"),\n        }\n    }\n}\n\nfn benchmark_integer_sign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sign()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.sign())),\n            (\"num\", &mut |(n, _, _)| no_out!(num_sign(&n))),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.cmp0())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingSqrt, CeilingSqrtAssign, CheckedSqrt, FloorSqrt, FloorSqrtAssign,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, triple_3_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_gen_var_4, integer_gen_var_4_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_floor_sqrt);\n    register_demo!(runner, demo_integer_floor_sqrt_ref);\n    register_demo!(runner, demo_integer_floor_sqrt_assign);\n    register_demo!(runner, demo_integer_ceiling_sqrt);\n    register_demo!(runner, demo_integer_ceiling_sqrt_ref);\n    register_demo!(runner, demo_integer_ceiling_sqrt_assign);\n    register_demo!(runner, demo_integer_checked_sqrt);\n    register_demo!(runner, demo_integer_checked_sqrt_ref);\n    register_bench!(runner, benchmark_integer_floor_sqrt_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_floor_sqrt_library_comparison);\n    register_bench!(runner, benchmark_integer_floor_sqrt_assign);\n    register_bench!(runner, benchmark_integer_ceiling_sqrt_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_ceiling_sqrt_assign);\n    register_bench!(runner, benchmark_integer_checked_sqrt_evaluation_strategy);\n}\n\nfn demo_integer_floor_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen_var_4().get(gm, config).take(limit) {\n        println!(\"{}.floor_sqrt() = {}\", x, x.clone().floor_sqrt());\n    }\n}\n\nfn demo_integer_floor_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen_var_4().get(gm, config).take(limit) {\n        println!(\"(&{}).floor_sqrt() = {}\", x, (&x).floor_sqrt());\n    }\n}\n\nfn demo_integer_floor_sqrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in integer_gen_var_4().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.floor_sqrt_assign();\n        println!(\"x := {old_x}; x.floor_sqrt_assign(); x = {x}\");\n    }\n}\n\nfn demo_integer_ceiling_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen_var_4().get(gm, config).take(limit) {\n        println!(\"{}.ceiling_sqrt() = {}\", x, x.clone().ceiling_sqrt());\n    }\n}\n\nfn demo_integer_ceiling_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen_var_4().get(gm, config).take(limit) {\n        println!(\"(&{}).ceiling_sqrt() = {}\", x, (&x).ceiling_sqrt());\n    }\n}\n\nfn demo_integer_ceiling_sqrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in integer_gen_var_4().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.ceiling_sqrt_assign();\n        println!(\"x := {old_x}; x.ceiling_sqrt_assign(); x = {x}\");\n    }\n}\n\nfn demo_integer_checked_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen_var_4().get(gm, config).take(limit) {\n        println!(\"{}.checked_sqrt() = {:?}\", x, x.clone().checked_sqrt());\n    }\n}\n\nfn demo_integer_checked_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen_var_4().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_sqrt() = {:?}\", x, (&x).checked_sqrt());\n    }\n}\n\nfn benchmark_integer_floor_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.floor_sqrt()\", &mut |x| no_out!(x.floor_sqrt())),\n            (\"(&Integer).floor_sqrt()\", &mut |x| {\n                no_out!((&x).floor_sqrt());\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_floor_sqrt_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_sqrt()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_var_4_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"num\", &mut |(x, _, _)| no_out!(x.sqrt())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.sqrt())),\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.floor_sqrt())),\n        ],\n    );\n}\n\nfn benchmark_integer_floor_sqrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.floor_sqrt_assign()\",\n        BenchmarkType::Single,\n        integer_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.floor_sqrt_assign())],\n    );\n}\n\nfn benchmark_integer_ceiling_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.ceiling_sqrt()\", &mut |x| no_out!(x.ceiling_sqrt())),\n            (\"(&Integer).ceiling_sqrt()\", &mut |x| {\n                no_out!((&x).ceiling_sqrt());\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_ceiling_sqrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ceiling_sqrt_assign()\",\n        BenchmarkType::Single,\n        integer_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.ceiling_sqrt_assign())],\n    );\n}\n\nfn benchmark_integer_checked_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.checked_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.checked_sqrt()\", &mut |x| no_out!(x.checked_sqrt())),\n            (\"(&Integer).checked_sqrt()\", &mut |x| {\n                no_out!((&x).checked_sqrt());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Square, SquareAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_square_assign);\n    register_demo!(runner, demo_integer_square);\n    register_demo!(runner, demo_integer_square_ref);\n\n    register_bench!(runner, benchmark_integer_square_assign);\n    register_bench!(runner, benchmark_integer_square_algorithms);\n    register_bench!(runner, benchmark_integer_square_evaluation_strategy);\n}\n\nfn demo_integer_square_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in integer_gen().get(gm, config).take(limit) {\n        let old_n = n.clone();\n        n.square_assign();\n        println!(\"n := {n}; n.square_assign(); n = {old_n}\");\n    }\n}\n\nfn demo_integer_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"({}) ^ 2 = {}\", n.clone(), n.square());\n    }\n}\n\nfn demo_integer_square_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"&{} ^ 2 = {}\", n, (&n).square());\n    }\n}\n\nfn benchmark_integer_square_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.square_assign()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |mut n| n.square_assign())],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_square_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.square()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |ref n| no_out!(n.square())),\n            (\"using *\", &mut |ref n| no_out!(n * n)),\n        ],\n    );\n}\n\nfn benchmark_integer_square_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.square()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Integer.square()\", &mut |n| no_out!(n.square())),\n            (\"(&Integer).square()\", &mut |n| no_out!((&n).square())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n    triple_3_pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen, integer_pair_gen_nrm, integer_pair_gen_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_sub_assign);\n    register_demo!(runner, demo_integer_sub_assign_ref);\n    register_demo!(runner, demo_integer_sub);\n    register_demo!(runner, demo_integer_sub_val_ref);\n    register_demo!(runner, demo_integer_sub_ref_val);\n    register_demo!(runner, demo_integer_sub_ref_ref);\n\n    register_bench!(runner, benchmark_integer_sub_assign_library_comparison);\n    register_bench!(runner, benchmark_integer_sub_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_sub_library_comparison);\n    register_bench!(runner, benchmark_integer_sub_evaluation_strategy);\n}\n\nfn demo_integer_sub_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x -= y.clone();\n        println!(\"x := {x_old}; x -= {y}; x = {x}\");\n    }\n}\n\nfn demo_integer_sub_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x -= &y;\n        println!(\"x := {x_old}; x -= &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_integer_sub_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} - &{} = {}\", x_old, y, x - &y);\n    }\n}\n\nfn demo_integer_sub_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} - {} = {}\", x, y_old, &x - y);\n    }\n}\n\nfn demo_integer_sub_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} - &{} = {}\", x, y, &x - &y);\n    }\n}\n\nfn benchmark_integer_sub_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer -= Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x -= y), (\"rug\", &mut |((mut x, y), _)| x -= y)],\n    );\n}\n\nfn benchmark_integer_sub_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer -= Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer -= Integer\", &mut |(mut x, y)| no_out!(x -= y)),\n            (\"Integer -= &Integer\", &mut |(mut x, y)| no_out!(x -= &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_sub_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer - Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x - y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x - y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x - y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer - Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer - Integer\", &mut |(x, y)| no_out!(x - y)),\n            (\"Integer - &Integer\", &mut |(x, y)| no_out!(x - &y)),\n            (\"&Integer - Integer\", &mut |(x, y)| no_out!(&x - y)),\n            (\"&Integer - &Integer\", &mut |(x, y)| no_out!(&x - &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{SubMul, SubMulAssign};\nuse malachite_base::test_util::bench::bucketers::{\n    triple_1_2_vec_max_len_bucketer, triple_vec_max_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_triple_gen_var_39, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::arithmetic::sub_mul::{\n    limbs_overflowing_sub_mul, limbs_overflowing_sub_mul_in_place_left,\n    limbs_overflowing_sub_mul_limb, limbs_overflowing_sub_mul_limb_in_place_either,\n    limbs_overflowing_sub_mul_limb_in_place_left, limbs_overflowing_sub_mul_limb_in_place_right,\n};\nuse malachite_nz::test_util::bench::bucketers::triple_integer_max_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_triple_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_overflowing_sub_mul_limb);\n    register_demo!(runner, demo_limbs_overflowing_sub_mul_limb_in_place_left);\n    register_demo!(runner, demo_limbs_overflowing_sub_mul_limb_in_place_right);\n    register_demo!(runner, demo_limbs_overflowing_sub_mul_limb_in_place_either);\n    register_demo!(runner, demo_limbs_overflowing_sub_mul);\n    register_demo!(runner, demo_limbs_overflowing_sub_mul_in_place_left);\n\n    register_demo!(runner, demo_integer_sub_mul);\n    register_demo!(runner, demo_integer_sub_mul_val_val_ref);\n    register_demo!(runner, demo_integer_sub_mul_val_ref_val);\n    register_demo!(runner, demo_integer_sub_mul_val_ref_ref);\n    register_demo!(runner, demo_integer_sub_mul_ref_ref_ref);\n    register_demo!(runner, demo_integer_sub_mul_assign);\n    register_demo!(runner, demo_integer_sub_mul_assign_val_ref);\n    register_demo!(runner, demo_integer_sub_mul_assign_ref_val);\n    register_demo!(runner, demo_integer_sub_mul_assign_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_overflowing_sub_mul_limb);\n    register_bench!(\n        runner,\n        benchmark_limbs_overflowing_sub_mul_limb_in_place_left\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_overflowing_sub_mul_limb_in_place_right\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_overflowing_sub_mul_limb_in_place_either\n    );\n    register_bench!(runner, benchmark_limbs_overflowing_sub_mul);\n    register_bench!(runner, benchmark_limbs_overflowing_sub_mul_in_place_left);\n\n    register_bench!(runner, benchmark_integer_sub_mul_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_sub_mul_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_val_val_ref_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_val_ref_val_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_val_ref_ref_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_ref_ref_ref_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_sub_mul_assign_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_assign_val_ref_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_assign_ref_val_algorithms);\n    register_bench!(runner, benchmark_integer_sub_mul_assign_ref_ref_algorithms);\n}\n\nfn demo_limbs_overflowing_sub_mul_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_overflowing_sub_mul_limb({:?}, {:?}, {}) = {:?}\",\n            a,\n            b,\n            c,\n            limbs_overflowing_sub_mul_limb(&a, &b, c),\n        );\n    }\n}\n\nfn demo_limbs_overflowing_sub_mul_limb_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut a, b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let a_old = a.clone();\n        let borrow = limbs_overflowing_sub_mul_limb_in_place_left(&mut a, &b, c);\n        println!(\n            \"a := {a_old:?}; \\\n            limbs_overflowing_sub_mul_limb_in_place_left(&mut a, {b:?}, {c}) = {borrow}; \\\n            a = {a:?}\",\n        );\n    }\n}\n\nfn demo_limbs_overflowing_sub_mul_limb_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (a, mut b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let b_old = b.clone();\n        let borrow = limbs_overflowing_sub_mul_limb_in_place_right(&a, &mut b, c);\n        println!(\n            \"b := {b_old:?}; \\\n            limbs_overflowing_sub_mul_limb_in_place_right({a:?}, &mut b, {c}) = {borrow}; \\\n            b = {b:?}\",\n        );\n    }\n}\n\nfn demo_limbs_overflowing_sub_mul_limb_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut a, mut b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        limbs_overflowing_sub_mul_limb_in_place_either(&mut a, &mut b, c);\n        println!(\n            \"a := {a_old:?}; b := {b_old:?}; \\\n            limbs_overflowing_sub_mul_limb_in_place_either(&mut a, &mut b, {c}); \\\n            a = {a:?}; b = {b:?}\",\n        );\n    }\n}\n\nfn demo_limbs_overflowing_sub_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in unsigned_vec_triple_gen_var_39().get(gm, config).take(limit) {\n        println!(\n            \"limbs_overflowing_sub_mul({:?}, {:?}, {:?}) = {:?}\",\n            a,\n            b,\n            c,\n            limbs_overflowing_sub_mul(&a, &b, &c),\n        );\n    }\n}\n\nfn demo_limbs_overflowing_sub_mul_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in unsigned_vec_triple_gen_var_39().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let sign = limbs_overflowing_sub_mul_in_place_left(&mut a, &b, &c);\n        println!(\n            \"a := {a_old:?}; \\\n            limbs_overflowing_sub_mul_in_place_left(&mut a, {b:?}, {c:?}) = {sign}; \\\n            a = {a:?}\",\n        );\n    }\n}\n\nfn demo_integer_sub_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let z_old = z.clone();\n        println!(\n            \"{}.sub_mul({}, {}) = {}\",\n            x_old,\n            y_old,\n            z_old,\n            x.sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_integer_sub_mul_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.sub_mul({}, &({})) = {}\",\n            x_old,\n            y_old,\n            z,\n            x.sub_mul(y, &z)\n        );\n    }\n}\n\nfn demo_integer_sub_mul_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let z_old = z.clone();\n        println!(\n            \"{}.sub_mul(&({}), {}) = {}\",\n            x_old,\n            y,\n            z_old,\n            x.sub_mul(&y, z)\n        );\n    }\n}\n\nfn demo_integer_sub_mul_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{}.sub_mul(&({}), &({})) = {}\",\n            x_old,\n            y,\n            z,\n            x.sub_mul(&y, &z)\n        );\n    }\n}\n\nfn demo_integer_sub_mul_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).sub_mul(&({}), &({})) = {}\",\n            x,\n            y,\n            z,\n            (&x).sub_mul(&y, &z)\n        );\n    }\n}\n\nfn demo_integer_sub_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let z_old = z.clone();\n        x.sub_mul_assign(y, z);\n        println!(\"x := {x_old}; x.sub_mul_assign({y_old}, {z_old}); x = {x}\");\n    }\n}\n\nfn demo_integer_sub_mul_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.sub_mul_assign(y, &z);\n        println!(\"x := {x_old}; x.sub_mul_assign({y_old}, &({z})); x = {x}\");\n    }\n}\n\nfn demo_integer_sub_mul_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let z_old = z.clone();\n        x.sub_mul_assign(&y, z);\n        println!(\"x := {x_old}; x.sub_mul_assign(&({y}), {z_old}); x = {x}\");\n    }\n}\n\nfn demo_integer_sub_mul_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in integer_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.sub_mul_assign(&y, &z);\n        println!(\"x := {x_old}; x.sub_mul_assign(&({y}), &({z})); x = {x}\");\n    }\n}\n\nfn benchmark_limbs_overflowing_sub_mul_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_overflowing_sub_mul_limb(&[Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(a, b, c)| {\n            no_out!(limbs_overflowing_sub_mul_limb(&a, &b, c));\n        })],\n    );\n}\n\nfn benchmark_limbs_overflowing_sub_mul_limb_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_overflowing_sub_mul_limb_in_place_left(&mut Vec<Limb>, &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut a, b, c)| {\n            no_out!(limbs_overflowing_sub_mul_limb_in_place_left(&mut a, &b, c));\n        })],\n    );\n}\n\nfn benchmark_limbs_overflowing_sub_mul_limb_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_overflowing_sub_mul_limb_in_place_right(&[Limb], &mut Vec<Limb>, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(a, mut b, c)| {\n            no_out!(limbs_overflowing_sub_mul_limb_in_place_right(&a, &mut b, c));\n        })],\n    );\n}\n\nfn benchmark_limbs_overflowing_sub_mul_limb_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_overflowing_sub_mul_limb_in_place_either(&mut Vec<Limb>, &mut Vec<Limb>, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut a, mut b, c)| {\n            no_out!(limbs_overflowing_sub_mul_limb_in_place_either(\n                &mut a, &mut b, c\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_overflowing_sub_mul(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_overflowing_sub_mul(&[Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_39().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_vec_max_len_bucketer(\"xs\", \"ys\", \"zs\"),\n        &mut [(\"Malachite\", &mut |(a, b, c)| {\n            no_out!(limbs_overflowing_sub_mul(&a, &b, &c));\n        })],\n    );\n}\n\nfn benchmark_limbs_overflowing_sub_mul_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_overflowing_sub_mul_in_place_left(&mut Vec<Limb>, &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_39().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_vec_max_len_bucketer(\"xs\", \"ys\", \"zs\"),\n        &mut [(\"Malachite\", &mut |(mut a, b, c)| {\n            no_out!(limbs_overflowing_sub_mul_in_place_left(&mut a, &b, &c));\n        })],\n    );\n}\n\nfn benchmark_integer_sub_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul(Integer, Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.sub_mul(Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, c));\n            }),\n            (\"Integer.sub_mul(Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, &c));\n            }),\n            (\"Integer.sub_mul(&Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, c));\n            }),\n            (\"Integer.sub_mul(&Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, &c));\n            }),\n            (\n                \"(&Integer).sub_mul(&Integer, &Integer)\",\n                &mut |(a, b, c)| no_out!((&a).sub_mul(&b, &c)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_sub_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul(Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.sub_mul(Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, c));\n            }),\n            (\"Integer - Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(a - b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_sub_mul_val_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul(Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.sub_mul(Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, &c));\n            }),\n            (\"Integer - Integer * &Integer\", &mut |(a, b, c)| {\n                no_out!(a - b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_sub_mul_val_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul(&Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.sub_mul(&Integer, Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, c));\n            }),\n            (\"Integer - &Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(a - &b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_sub_mul_val_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul(&Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Integer.sub_mul(&Integer, &Integer)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, &c));\n            }),\n            (\"Integer - Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(a - &b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_sub_mul_ref_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul(&Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"(&Integer).sub_mul(&Integer, &Integer)\",\n                &mut |(a, b, c)| no_out!((&a).sub_mul(&b, &c)),\n            ),\n            (\"&Integer - Integer * Integer\", &mut |(a, b, c)| {\n                no_out!(&a - &b * &c);\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_sub_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul_assign(Integer, Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.sub_mul_assign(Integer, Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, c),\n            ),\n            (\n                \"Integer.sub_mul_assign(Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, &c),\n            ),\n            (\n                \"Integer.sub_mul_assign(&Integer, Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, c),\n            ),\n            (\n                \"Integer.sub_mul_assign(&Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, &c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_sub_mul_assign_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul_assign(Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.sub_mul_assign(Integer, Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, c),\n            ),\n            (\"Integer -= Integer * Integer\", &mut |(mut a, b, c)| {\n                a -= b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_sub_mul_assign_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul_assign(Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.sub_mul_assign(Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, &c),\n            ),\n            (\"Integer -= Integer * &Integer\", &mut |(mut a, b, c)| {\n                a -= b * &c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_sub_mul_assign_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul_assign(&Integer, Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.sub_mul_assign(&Integer, Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, c),\n            ),\n            (\"Integer -= &Integer * Integer\", &mut |(mut a, b, c)| {\n                a -= &b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_sub_mul_assign_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.sub_mul_assign(&Integer, &Integer)\",\n        BenchmarkType::Algorithms,\n        integer_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_integer_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Integer.sub_mul_assign(&Integer, &Integer)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, &c),\n            ),\n            (\"Integer -= &Integer * &Integer\", &mut |(mut a, b, c)| {\n                a -= &b * &c;\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/basic/from_sign_and_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_bool_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_from_sign_and_abs);\n    register_demo!(runner, demo_from_sign_and_abs_ref);\n\n    register_bench!(runner, benchmark_from_sign_and_abs_evaluation_strategy);\n}\n\nfn demo_from_sign_and_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (abs, sign) in natural_bool_pair_gen().get(gm, config).take(limit) {\n        let abs_old = abs.clone();\n        println!(\n            \"Integer::from_sign_and_abs({}, {}) = {}\",\n            sign,\n            abs_old,\n            Integer::from_sign_and_abs(sign, abs)\n        );\n    }\n}\n\nfn demo_from_sign_and_abs_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (abs, sign) in natural_bool_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"Integer::from_sign_and_abs_ref({}, {}) = {}\",\n            sign,\n            abs,\n            Integer::from_sign_and_abs_ref(sign, &abs)\n        );\n    }\n}\n\nfn benchmark_from_sign_and_abs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_sign_and_abs(bool, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_bool_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"abs\"),\n        &mut [\n            (\"from_sign_and_abs\", &mut |(abs, sign)| {\n                no_out!(Integer::from_sign_and_abs(sign, abs));\n            }),\n            (\"from_sign_and_abs_ref\", &mut |(abs, sign)| {\n                no_out!(Integer::from_sign_and_abs_ref(sign, &abs));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/basic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_sign_and_abs::register(runner);\n}\n\nmod from_sign_and_abs;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_pair_integer_max_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_nrm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_cmp);\n    register_bench!(runner, benchmark_integer_cmp_library_comparison);\n}\n\nfn demo_integer_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        match x.cmp(&y) {\n            Less => println!(\"{x} < {y}\"),\n            Equal => println!(\"{x} = {y}\"),\n            Greater => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_cmp_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.cmp(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.cmp(&y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.cmp(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.cmp(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_rm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_cmp_abs);\n    register_demo!(runner, demo_integer_lt_abs);\n    register_demo!(runner, demo_integer_gt_abs);\n    register_demo!(runner, demo_integer_le_abs);\n    register_demo!(runner, demo_integer_ge_abs);\n\n    register_bench!(runner, benchmark_integer_cmp_abs_library_comparison);\n    register_bench!(runner, benchmark_integer_cmp_abs_algorithms);\n    register_bench!(runner, benchmark_integer_lt_abs);\n    register_bench!(runner, benchmark_integer_gt_abs);\n    register_bench!(runner, benchmark_integer_le_abs);\n    register_bench!(runner, benchmark_integer_ge_abs);\n}\n\nfn demo_integer_cmp_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        match x.cmp_abs(&y) {\n            Less => println!(\"|{x}| < |{y}|\"),\n            Equal => println!(\"|{x}| = |{y}|\"),\n            Greater => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_integer_lt_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        if x.lt_abs(&y) {\n            println!(\"|{x}| < |{y}|\");\n        } else {\n            println!(\"|{x}| ≮ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_gt_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        if x.gt_abs(&y) {\n            println!(\"|{x}| > |{y}|\");\n        } else {\n            println!(\"|{x}| ≯ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_le_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        if x.le_abs(&y) {\n            println!(\"|{x}| ≤ |{y}|\");\n        } else {\n            println!(\"|{x}| ≰ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_ge_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        if x.ge_abs(&y) {\n            println!(\"|{x}| ≥ |{y}|\");\n        } else {\n            println!(\"|{x}| ≱ |{y}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_cmp_abs_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.cmp_abs(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.cmp_abs(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.cmp_abs(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_cmp_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.cmp_abs(&Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs().cmp(&y.abs()))),\n        ],\n    );\n}\n\nfn benchmark_integer_lt_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.lt_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_gt_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.gt_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_le_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.le_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_ge_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.ge_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_pair_integer_max_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_eq);\n    register_bench!(runner, benchmark_integer_eq_library_comparison);\n}\n\nfn demo_integer_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_eq_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer == Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x == y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x == y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_integer_max_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_eq_abs);\n    register_bench!(runner, benchmark_integer_eq_abs_algorithms);\n}\n\nfn demo_integer_eq_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_eq_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::integer_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_natural_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_eq_abs_natural);\n    register_demo!(runner, demo_natural_eq_abs_integer);\n\n    register_bench!(runner, benchmark_integer_eq_abs_natural_algorithms);\n    register_bench!(runner, benchmark_natural_eq_abs_integer_algorithms);\n}\n\nfn demo_integer_eq_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_natural_eq_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if y.eq_abs(&x) {\n            println!(\"|{y}| = |{x}|\");\n        } else {\n            println!(\"|{y}| ≠ |{x}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_eq_abs_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_eq_abs_integer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_abs(&Integer)\",\n        BenchmarkType::Algorithms,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y == x.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_primitive_float_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_integer_eq_abs_primitive_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_eq_abs_integer);\n\n    register_primitive_float_benches!(runner, benchmark_integer_eq_abs_primitive_float_algorithms);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_eq_abs_integer_algorithms);\n}\n\nfn demo_integer_eq_abs_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: EqAbs<T>,\n{\n    for (n, x) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.eq_abs(&x) {\n            println!(\"|{}| = |{}|\", n, NiceFloat(x));\n        } else {\n            println!(\"|{}| ≠ |{}|\", n, NiceFloat(x));\n        }\n    }\n}\n\nfn demo_primitive_float_eq_abs_integer<T: EqAbs<Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, x) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&n) {\n            println!(\"|{}| = |{}|\", NiceFloat(x), n);\n        } else {\n            println!(\"|{}| ≠ |{}|\", NiceFloat(x), n);\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_eq_abs_primitive_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: EqAbs<T> + PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_primitive_float_eq_abs_integer_algorithms<\n    T: EqAbs<Integer> + PartialEq<Integer> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y == x.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_signed_pair_gen, integer_unsigned_pair_gen};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_partial_eq_abs_unsigned);\n    register_signed_demos!(runner, demo_integer_partial_eq_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_abs_integer);\n    register_signed_demos!(runner, demo_signed_partial_eq_abs_integer);\n\n    register_unsigned_benches!(runner, benchmark_integer_eq_abs_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_integer_eq_abs_signed_algorithms);\n    register_unsigned_benches!(runner, benchmark_unsigned_eq_abs_integer_algorithms);\n    register_signed_benches!(runner, benchmark_signed_eq_abs_integer_algorithms);\n}\n\nfn demo_integer_partial_eq_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: EqAbs<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.eq_abs(&u) {\n            println!(\"|{n}| = |{u}|\");\n        } else {\n            println!(\"|{n}| ≠ |{u}|\");\n        }\n    }\n}\n\nfn demo_integer_partial_eq_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: EqAbs<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.eq_abs(&i) {\n            println!(\"|{n}| = |{i}|\");\n        } else {\n            println!(\"|{n}| ≠ |{i}|\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_abs_integer<T: EqAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.eq_abs(&n) {\n            println!(\"|{u}| = |{n}|\");\n        } else {\n            println!(\"|{u}| ≠ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_abs_integer<T: EqAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.eq_abs(&n) {\n            println!(\"|{i}| = |{n}|\");\n        } else {\n            println!(\"|{i}| ≠ |{n}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_eq_abs_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: EqAbs<T> + PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.eq_abs({})\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_eq_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: EqAbs<T> + PartialEq<<T as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"Integer.eq_abs({})\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs() == y.unsigned_abs());\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_eq_abs_integer_algorithms<\n    T: EqAbs<Integer> + PartialEq<Integer> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y == x.abs())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_eq_abs_integer_algorithms<T: EqAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PartialEq<Integer>,\n{\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(y.unsigned_abs() == x.abs());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::hash::hash;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_hash);\n    register_bench!(runner, benchmark_integer_hash_library_comparison);\n}\n\nfn demo_integer_hash(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"hash({}) = {}\", n, hash(&n));\n    }\n}\n\nfn benchmark_integer_hash_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer hash\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(hash(&n))),\n            (\"num\", &mut |(_, n, _)| no_out!(hash(&n))),\n            (\"rug\", &mut |(n, _, _)| no_out!(hash(&n))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    cmp::register(runner);\n    cmp_abs::register(runner);\n    eq::register(runner);\n    eq_abs::register(runner);\n    eq_abs_natural::register(runner);\n    eq_abs_primitive_float::register(runner);\n    eq_abs_primitive_int::register(runner);\n    hash::register(runner);\n    partial_cmp_abs_natural::register(runner);\n    partial_cmp_abs_primitive_float::register(runner);\n    partial_cmp_abs_primitive_int::register(runner);\n    partial_cmp_natural::register(runner);\n    partial_cmp_primitive_float::register(runner);\n    partial_cmp_primitive_int::register(runner);\n    partial_eq_natural::register(runner);\n    partial_eq_primitive_float::register(runner);\n    partial_eq_primitive_int::register(runner);\n}\n\nmod cmp;\nmod cmp_abs;\nmod eq;\nmod eq_abs;\nmod eq_abs_natural;\nmod eq_abs_primitive_float;\nmod eq_abs_primitive_int;\nmod hash;\nmod partial_cmp_abs_natural;\nmod partial_cmp_abs_primitive_float;\nmod partial_cmp_abs_primitive_int;\nmod partial_cmp_natural;\nmod partial_cmp_primitive_float;\nmod partial_cmp_primitive_int;\nmod partial_eq_natural;\nmod partial_eq_primitive_float;\nmod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_natural_max_bit_bucketer, pair_2_integer_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_natural_pair_gen, integer_natural_pair_gen_rm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_partial_cmp_abs_natural);\n    register_demo!(runner, demo_natural_partial_cmp_abs_integer);\n    register_demo!(runner, demo_integer_lt_abs_natural);\n    register_demo!(runner, demo_integer_gt_abs_natural);\n    register_demo!(runner, demo_integer_le_abs_natural);\n    register_demo!(runner, demo_integer_ge_abs_natural);\n    register_demo!(runner, demo_natural_lt_abs_integer);\n    register_demo!(runner, demo_natural_gt_abs_integer);\n    register_demo!(runner, demo_natural_le_abs_integer);\n    register_demo!(runner, demo_natural_ge_abs_integer);\n\n    register_bench!(\n        runner,\n        benchmark_integer_partial_cmp_abs_natural_library_comparison\n    );\n    register_bench!(runner, benchmark_integer_partial_cmp_abs_natural_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_partial_cmp_abs_integer_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_partial_cmp_abs_integer_algorithms);\n    register_bench!(runner, benchmark_integer_lt_abs_natural);\n    register_bench!(runner, benchmark_integer_gt_abs_natural);\n    register_bench!(runner, benchmark_integer_le_abs_natural);\n    register_bench!(runner, benchmark_integer_ge_abs_natural);\n    register_bench!(runner, benchmark_natural_lt_abs_integer);\n    register_bench!(runner, benchmark_natural_gt_abs_integer);\n    register_bench!(runner, benchmark_natural_le_abs_integer);\n    register_bench!(runner, benchmark_natural_ge_abs_integer);\n}\n\nfn demo_integer_partial_cmp_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y).unwrap() {\n            Less => println!(\"|{x}| < |{y}|\"),\n            Equal => println!(\"|{x}| = |{y}|\"),\n            Greater => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        match y.partial_cmp_abs(&x).unwrap() {\n            Less => println!(\"|{y}| < |{x}|\"),\n            Equal => println!(\"|{y}| = |{x}|\"),\n            Greater => println!(\"|{y}| > |{x}|\"),\n        }\n    }\n}\n\nfn demo_integer_lt_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if x.lt_abs(&y) {\n            println!(\"|{x}| < |{y}|\");\n        } else {\n            println!(\"|{x}| ≮ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_gt_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if x.gt_abs(&y) {\n            println!(\"|{x}| > |{y}|\");\n        } else {\n            println!(\"|{x}| ≯ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_le_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if x.le_abs(&y) {\n            println!(\"|{x}| ≤ |{y}|\");\n        } else {\n            println!(\"|{x}| ≰ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_ge_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if x.ge_abs(&y) {\n            println!(\"|{x}| ≥ |{y}|\");\n        } else {\n            println!(\"|{x}| ≱ |{y}|\");\n        }\n    }\n}\n\nfn demo_natural_lt_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if y.lt_abs(&x) {\n            println!(\"|{y}| < |{x}|\");\n        } else {\n            println!(\"|{y}| ≮ |{x}|\");\n        }\n    }\n}\n\nfn demo_natural_gt_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if y.gt_abs(&x) {\n            println!(\"|{y}| > |{x}|\");\n        } else {\n            println!(\"|{y}| ≯ |{x}|\");\n        }\n    }\n}\n\nfn demo_natural_le_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if y.le_abs(&x) {\n            println!(\"|{y}| ≤ |{x}|\");\n        } else {\n            println!(\"|{y}| ≰ |{x}|\");\n        }\n    }\n}\n\nfn demo_natural_ge_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if y.ge_abs(&x) {\n            println!(\"|{y}| ≥ |{x}|\");\n        } else {\n            println!(\"|{y}| ≱ |{x}|\");\n        }\n    }\n}\n\nfn benchmark_integer_partial_cmp_abs_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.partial_cmp_abs(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        integer_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.cmp_abs(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_abs_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.partial_cmp_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(x.partial_cmp_abs(&y));\n            }),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_partial_cmp_abs_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp_abs(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(y.partial_cmp_abs(&x));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.cmp_abs(&x))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_partial_cmp_abs_integer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp_abs(&Integer)\",\n        BenchmarkType::Algorithms,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(y.partial_cmp_abs(&x));\n            }),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(y.partial_cmp(&x.abs()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_lt_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.lt_abs(&Natural)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_gt_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.gt_abs(&Natural)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_le_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.le_abs(&Natural)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_ge_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ge_abs(&Natural)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_lt_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.lt_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_natural_gt_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gt_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_natural_le_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.le_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_natural_ge_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ge_abs(&Integer)\",\n        BenchmarkType::Single,\n        integer_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_primitive_float_pair_gen;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_integer_partial_cmp_abs_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_abs_integer);\n\n    register_primitive_float_benches!(runner, benchmark_integer_partial_cmp_abs_float_algorithms);\n    register_primitive_float_benches!(runner, benchmark_float_partial_cmp_abs_integer_algorithms);\n}\n\nfn demo_integer_partial_cmp_abs_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, f) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp_abs(&f) {\n            None => println!(\"{} is not comparable with {}\", n, NiceFloat(f)),\n            Some(Less) => println!(\"|{}| < |{}|\", n, NiceFloat(f)),\n            Some(Equal) => println!(\"|{}| = |{}|\", n, NiceFloat(f)),\n            Some(Greater) => println!(\"|{}| > |{}|\", n, NiceFloat(f)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match f.partial_cmp_abs(&n) {\n            None => println!(\"{} is not comparable with {}\", NiceFloat(f), n),\n            Some(Less) => println!(\"|{}| < |{}|\", NiceFloat(f), n),\n            Some(Equal) => println!(\"|{}| = |{}|\", NiceFloat(f), n),\n            Some(Greater) => println!(\"|{}| > |{}|\", NiceFloat(f), n),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_abs_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T> + PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_integer_algorithms<\n    T: PartialOrdAbs<Integer> + PartialOrd<Integer> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(y.abs().partial_cmp(&x.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_signed_pair_gen, integer_unsigned_pair_gen};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_partial_cmp_abs_unsigned);\n    register_signed_demos!(runner, demo_integer_partial_cmp_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_abs_integer);\n    register_signed_demos!(runner, demo_signed_partial_cmp_abs_integer);\n    register_unsigned_demos!(runner, demo_integer_lt_abs_unsigned);\n    register_signed_demos!(runner, demo_integer_lt_abs_signed);\n    register_unsigned_demos!(runner, demo_integer_gt_abs_unsigned);\n    register_signed_demos!(runner, demo_integer_gt_abs_signed);\n    register_unsigned_demos!(runner, demo_integer_le_abs_unsigned);\n    register_signed_demos!(runner, demo_integer_le_abs_signed);\n    register_unsigned_demos!(runner, demo_integer_ge_abs_unsigned);\n    register_signed_demos!(runner, demo_integer_ge_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_lt_abs_integer);\n    register_signed_demos!(runner, demo_signed_lt_abs_integer);\n    register_unsigned_demos!(runner, demo_unsigned_gt_abs_integer);\n    register_signed_demos!(runner, demo_signed_gt_abs_integer);\n    register_unsigned_demos!(runner, demo_unsigned_le_abs_integer);\n    register_signed_demos!(runner, demo_signed_le_abs_integer);\n    register_unsigned_demos!(runner, demo_unsigned_ge_abs_integer);\n    register_signed_demos!(runner, demo_signed_ge_abs_integer);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_integer_partial_cmp_abs_unsigned_algorithms\n    );\n    register_signed_benches!(runner, benchmark_integer_partial_cmp_abs_signed_algorithms);\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_cmp_abs_integer_algorithms\n    );\n    register_signed_benches!(runner, benchmark_signed_partial_cmp_abs_integer_algorithms);\n    register_unsigned_benches!(runner, benchmark_integer_lt_abs_unsigned);\n    register_signed_benches!(runner, benchmark_integer_lt_abs_signed);\n    register_unsigned_benches!(runner, benchmark_integer_gt_abs_unsigned);\n    register_signed_benches!(runner, benchmark_integer_gt_abs_signed);\n    register_unsigned_benches!(runner, benchmark_integer_le_abs_unsigned);\n    register_signed_benches!(runner, benchmark_integer_le_abs_signed);\n    register_unsigned_benches!(runner, benchmark_integer_ge_abs_unsigned);\n    register_signed_benches!(runner, benchmark_integer_ge_abs_signed);\n    register_unsigned_benches!(runner, benchmark_unsigned_lt_abs_integer);\n    register_signed_benches!(runner, benchmark_signed_lt_abs_integer);\n    register_unsigned_benches!(runner, benchmark_unsigned_gt_abs_integer);\n    register_signed_benches!(runner, benchmark_signed_gt_abs_integer);\n    register_unsigned_benches!(runner, benchmark_unsigned_le_abs_integer);\n    register_signed_benches!(runner, benchmark_signed_le_abs_integer);\n    register_unsigned_benches!(runner, benchmark_unsigned_ge_abs_integer);\n    register_signed_benches!(runner, benchmark_signed_ge_abs_integer);\n}\n\nfn demo_integer_partial_cmp_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp_abs(&u).unwrap() {\n            Less => println!(\"|{n}| < |{u}|\"),\n            Equal => println!(\"|{n}| = |{u}|\"),\n            Greater => println!(\"|{n}| > |{u}|\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp_abs(&i).unwrap() {\n            Less => println!(\"|{n}| < |{i}|\"),\n            Equal => println!(\"|{n}| = |{i}|\"),\n            Greater => println!(\"|{n}| > |{i}|\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match u.partial_cmp_abs(&n).unwrap() {\n            Less => println!(\"|{u}| < |{n}|\"),\n            Equal => println!(\"|{u}| = |{n}|\"),\n            Greater => println!(\"|{u}| > |{n}|\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match i.partial_cmp_abs(&n).unwrap() {\n            Less => println!(\"|{i}| < |{n}|\"),\n            Equal => println!(\"|{i}| = |{n}|\"),\n            Greater => println!(\"|{i}| > |{n}|\"),\n        }\n    }\n}\n\nfn demo_integer_lt_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.lt_abs(&u) {\n            println!(\"|{n}| < |{u}|\");\n        } else {\n            println!(\"|{n}| ≮ |{u}|\");\n        }\n    }\n}\n\nfn demo_integer_lt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.lt_abs(&i) {\n            println!(\"|{n}| < |{i}|\");\n        } else {\n            println!(\"|{n}| ≮ |{i}|\");\n        }\n    }\n}\n\nfn demo_integer_gt_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.gt_abs(&u) {\n            println!(\"|{n}| > |{u}|\");\n        } else {\n            println!(\"|{n}| ≯ |{u}|\");\n        }\n    }\n}\n\nfn demo_integer_gt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.gt_abs(&i) {\n            println!(\"|{n}| > |{i}|\");\n        } else {\n            println!(\"|{n}| ≯ |{i}|\");\n        }\n    }\n}\n\nfn demo_integer_le_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.le_abs(&u) {\n            println!(\"|{n}| ≤ |{u}|\");\n        } else {\n            println!(\"|{n}| ≰ |{u}|\");\n        }\n    }\n}\n\nfn demo_integer_le_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.le_abs(&i) {\n            println!(\"|{n}| ≤ |{i}|\");\n        } else {\n            println!(\"|{n}| ≰ |{i}|\");\n        }\n    }\n}\n\nfn demo_integer_ge_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.ge_abs(&u) {\n            println!(\"|{n}| ≥ |{u}|\");\n        } else {\n            println!(\"|{n}| ≱ |{u}|\");\n        }\n    }\n}\n\nfn demo_integer_ge_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrdAbs<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.ge_abs(&i) {\n            println!(\"|{n}| ≥ |{i}|\");\n        } else {\n            println!(\"|{n}| ≱ |{i}|\");\n        }\n    }\n}\n\nfn demo_unsigned_lt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.lt_abs(&n) {\n            println!(\"|{u}| < |{n}|\");\n        } else {\n            println!(\"|{u}| ≮ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_lt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.lt_abs(&n) {\n            println!(\"|{i}| < |{n}|\");\n        } else {\n            println!(\"|{i}| ≮ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_gt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.gt_abs(&n) {\n            println!(\"|{u}| > |{n}|\");\n        } else {\n            println!(\"|{u}| ≯ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_gt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.gt_abs(&n) {\n            println!(\"|{i}| > |{n}|\");\n        } else {\n            println!(\"|{i}| ≯ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_le_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.le_abs(&n) {\n            println!(\"|{u}| ≤ |{n}|\");\n        } else {\n            println!(\"|{u}| ≰ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_le_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.le_abs(&n) {\n            println!(\"|{i}| ≤ |{n}|\");\n        } else {\n            println!(\"|{i}| ≰ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_ge_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.ge_abs(&n) {\n            println!(\"|{u}| ≥ |{n}|\");\n        } else {\n            println!(\"|{u}| ≱ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_ge_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.ge_abs(&n) {\n            println!(\"|{i}| ≥ |{n}|\");\n        } else {\n            println!(\"|{i}| ≱ |{n}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_abs_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T> + PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs().partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T> + PartialOrd<<T as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"Integer.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.unsigned_abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_partial_cmp_abs_integer_algorithms<\n    T: PartialOrdAbs<Integer> + PartialOrd<Integer> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y.partial_cmp(&x.abs()))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_partial_cmp_abs_integer_algorithms<\n    T: PartialOrdAbs<Integer> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PartialOrd<Integer>,\n{\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(y.unsigned_abs().partial_cmp(&x.abs()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_lt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.lt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_lt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.lt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_gt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.gt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_gt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.gt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_le_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.le_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_le_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.le_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_ge_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.ge_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_ge_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.ge_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_unsigned_lt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lt_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_lt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lt_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_gt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gt_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_gt_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gt_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_le_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.le_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_le_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.le_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_ge_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ge_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_ge_abs_integer<T: PartialOrdAbs<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ge_abs(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_2_integer_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_natural_pair_gen, integer_natural_pair_gen_rm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_partial_cmp_natural);\n    register_demo!(runner, demo_natural_partial_cmp_integer);\n    register_bench!(\n        runner,\n        benchmark_integer_partial_cmp_natural_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_partial_cmp_integer_library_comparison\n    );\n}\n\nfn demo_integer_partial_cmp_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y).unwrap() {\n            Less => println!(\"{x} < {y}\"),\n            Equal => println!(\"{x} = {y}\"),\n            Greater => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        match y.partial_cmp(&x).unwrap() {\n            Less => println!(\"{y} < {x}\"),\n            Equal => println!(\"{y} = {x}\"),\n            Greater => println!(\"{y} > {x}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.partial_cmp(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        integer_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_partial_cmp_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::pair_2_pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    integer_primitive_float_pair_gen, integer_primitive_float_pair_gen_rm,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_integer_partial_cmp_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_integer);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_integer_partial_cmp_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_cmp_integer_library_comparison\n    );\n}\n\nfn demo_integer_partial_cmp_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialOrd<T>,\n{\n    for (n, f) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp(&f) {\n            None => println!(\"{} is not comparable with {}\", n, NiceFloat(f)),\n            Some(Less) => println!(\"{} < {}\", n, NiceFloat(f)),\n            Some(Equal) => println!(\"{} = {}\", n, NiceFloat(f)),\n            Some(Greater) => println!(\"{} > {}\", n, NiceFloat(f)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_integer<T: PartialOrd<Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match f.partial_cmp(&n) {\n            None => println!(\"{} is not comparable with {}\", NiceFloat(f), n),\n            Some(Less) => println!(\"{} < {}\", NiceFloat(f), n),\n            Some(Equal) => println!(\"{} = {}\", NiceFloat(f), n),\n            Some(Greater) => println!(\"{} > {}\", NiceFloat(f), n),\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_partial_cmp_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_partial_cmp_integer_library_comparison<\n    T: PartialOrd<Integer> + PartialOrd<rug::Integer> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Integer)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_1_integer_bit_bucketer, triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_signed_pair_gen, integer_signed_pair_gen_rm, integer_unsigned_pair_gen,\n    integer_unsigned_pair_gen_nrm, integer_unsigned_pair_gen_rm,\n};\nuse malachite_nz::test_util::integer::comparison::partial_cmp_primitive_int::*;\nuse num::BigInt;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_partial_cmp_unsigned);\n    register_signed_demos!(runner, demo_integer_partial_cmp_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_integer);\n    register_signed_demos!(runner, demo_signed_partial_cmp_integer);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_integer_partial_cmp_unsigned_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_integer_partial_cmp_signed_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_cmp_integer_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_cmp_integer_library_comparison\n    );\n}\n\nfn demo_integer_partial_cmp_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: PartialOrd<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp(&u).unwrap() {\n            Less => println!(\"{n} < {u}\"),\n            Equal => println!(\"{n} = {u}\"),\n            Greater => println!(\"{n} > {u}\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: PartialOrd<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp(&i).unwrap() {\n            Less => println!(\"{n} < {i}\"),\n            Equal => println!(\"{n} = {i}\"),\n            Greater => println!(\"{n} > {i}\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_integer<T: PartialOrd<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match u.partial_cmp(&n).unwrap() {\n            Less => println!(\"{u} < {n}\"),\n            Equal => println!(\"{u} = {n}\"),\n            Greater => println!(\"{u} > {n}\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_integer<T: PartialOrd<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match i.partial_cmp(&n).unwrap() {\n            Less => println!(\"{i} < {n}\"),\n            Equal => println!(\"{i} = {n}\"),\n            Greater => println!(\"{i} > {n}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BigInt: From<T>,\n    Integer: PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_nrm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| {\n                no_out!(x.partial_cmp(&y));\n            }),\n            (\"num\", &mut |((x, y), _, _)| {\n                no_out!(num_partial_cmp_primitive(&x, y));\n            }),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Integer.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_partial_cmp_integer_library_comparison<\n    T: PartialOrd<Integer> + PartialOrd<rug::Integer> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Integer)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_partial_cmp_integer_library_comparison<\n    T: PartialOrd<Integer> + PartialOrd<rug::Integer> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Integer)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_2_integer_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_natural_pair_gen, integer_natural_pair_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_partial_eq_natural);\n    register_demo!(runner, demo_natural_partial_eq_integer);\n    register_bench!(\n        runner,\n        benchmark_integer_partial_eq_natural_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_partial_eq_integer_library_comparison\n    );\n}\n\nfn demo_integer_partial_eq_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_natural_partial_eq_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_natural_pair_gen().get(gm, config).take(limit) {\n        if y == x {\n            println!(\"{y} = {x}\");\n        } else {\n            println!(\"{y} ≠ {x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_partial_eq_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer == Natural\",\n        BenchmarkType::LibraryComparison,\n        integer_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_partial_eq_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural == Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::pair_2_pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    integer_primitive_float_pair_gen, integer_primitive_float_pair_gen_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_integer_partial_eq_float);\n    register_primitive_float_demos!(runner, demo_float_partial_eq_integer);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_integer_partial_eq_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_eq_integer_library_comparison\n    );\n}\n\nfn demo_integer_partial_eq_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialEq<T>,\n{\n    for (n, f) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n == f {\n            println!(\"{} = {}\", n, NiceFloat(f));\n        } else {\n            println!(\"{} ≠ {}\", n, NiceFloat(f));\n        }\n    }\n}\n\nfn demo_float_partial_eq_integer<T: PartialEq<Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in integer_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if f == n {\n            println!(\"{} = {}\", NiceFloat(f), n);\n        } else {\n            println!(\"{} ≠ {}\", NiceFloat(f), n);\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_partial_eq_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Integer == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_partial_eq_integer_library_comparison<\n    T: PartialEq<Integer> + PartialEq<rug::Integer> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Integer\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_1_integer_bit_bucketer, triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_signed_pair_gen, integer_signed_pair_gen_rm, integer_unsigned_pair_gen,\n    integer_unsigned_pair_gen_nrm, integer_unsigned_pair_gen_rm,\n};\nuse malachite_nz::test_util::integer::comparison::partial_eq_primitive_int::*;\nuse num::BigInt;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_partial_eq_unsigned);\n    register_signed_demos!(runner, demo_integer_partial_eq_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_integer);\n    register_signed_demos!(runner, demo_signed_partial_eq_integer);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_integer_partial_eq_unsigned_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_integer_partial_eq_signed_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_eq_integer_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_eq_integer_library_comparison\n    );\n}\n\nfn demo_integer_partial_eq_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: PartialEq<T>,\n{\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n == u {\n            println!(\"{n} = {u}\");\n        } else {\n            println!(\"{n} ≠ {u}\");\n        }\n    }\n}\n\nfn demo_integer_partial_eq_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: PartialEq<T>,\n{\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n == i {\n            println!(\"{n} = {i}\");\n        } else {\n            println!(\"{n} ≠ {i}\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_integer<T: PartialEq<Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in integer_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u == n {\n            println!(\"{u} = {n}\");\n        } else {\n            println!(\"{u} ≠ {n}\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_integer<T: PartialEq<Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in integer_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i == n {\n            println!(\"{i} = {n}\");\n        } else {\n            println!(\"{i} ≠ {n}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_partial_eq_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BigInt: From<T>,\n    Integer: PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Integer == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_nrm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x == y)),\n            (\"num\", &mut |((x, y), _, _)| {\n                no_out!(num_partial_eq_primitive(&x, y));\n            }),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_partial_eq_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Integer == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_unsigned_partial_eq_integer_library_comparison<\n    T: PartialEq<Integer> + PartialEq<rug::Integer> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Integer\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_signed_partial_eq_integer_library_comparison<\n    T: PartialEq<Integer> + PartialEq<rug::Integer> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Integer\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        integer_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    triple_3_integer_bit_bucketer, triple_3_pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_nrm, integer_pair_gen, integer_pair_gen_nrm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_clone);\n    register_demo!(runner, demo_integer_clone_from);\n    register_bench!(runner, benchmark_integer_clone_library_comparison);\n    register_bench!(runner, benchmark_integer_clone_from_library_comparison);\n}\n\nfn demo_integer_clone(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"clone({}) = {}\", n, n.clone());\n    }\n}\n\nfn demo_integer_clone_from(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.clone_from(&y);\n        println!(\"x := {x_old}; x.clone_from({y}); x = {x}\");\n    }\n}\n\n#[allow(clippy::redundant_clone, unused_must_use)]\nfn benchmark_integer_clone_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.clone()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.clone())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.clone())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.clone())),\n        ],\n    );\n}\n\nfn benchmark_integer_clone_from_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.clone_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (mut x, y))| x.clone_from(&y)),\n            (\"num\", &mut |((mut x, y), _, _)| x.clone_from(&y)),\n            (\"rug\", &mut |(_, (mut x, y), _)| x.clone_from(&y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/floating_point_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::conversion::primitive_float_from_integer::PrimitiveFloatFromIntegerError;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_1, integer_rounding_mode_pair_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_rounding_from_integer);\n    register_primitive_float_demos!(runner, demo_float_try_from_integer);\n    register_primitive_float_demos!(runner, demo_float_exact_from_integer);\n    register_primitive_float_demos!(runner, demo_float_convertible_from_integer);\n\n    register_primitive_float_benches!(runner, benchmark_float_rounding_from_integer);\n    register_primitive_float_benches!(runner, benchmark_float_try_from_integer);\n    register_primitive_float_benches!(runner, benchmark_float_exact_from_integer);\n    register_primitive_float_benches!(runner, benchmark_float_convertible_from_integer);\n}\n\nfn demo_float_rounding_from_integer<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat + for<'a> RoundingFrom<&'a Integer>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in integer_rounding_mode_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (x, o) = T::rounding_from(&n, rm);\n        println!(\n            \"{}::rounding_from(&{}, {}) = {:?}\",\n            T::NAME,\n            n,\n            rm,\n            (NiceFloat(x), o)\n        );\n    }\n}\n\nfn demo_float_try_from_integer<\n    T: for<'a> TryFrom<&'a Integer, Error = PrimitiveFloatFromIntegerError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from(&{}) = {:?}\",\n            T::NAME,\n            n.clone(),\n            T::try_from(&n).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_float_exact_from_integer<T: for<'a> ExactFrom<&'a Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    for n in integer_gen_var_1::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::exact_from(&{}) = {}\",\n            T::NAME,\n            n.clone(),\n            NiceFloat(T::exact_from(&n))\n        );\n    }\n}\n\nfn demo_float_convertible_from_integer<T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        if T::convertible_from(&n) {\n            println!(\"{} is convertible to an {}\", n, T::NAME);\n        } else {\n            println!(\"{} is not convertible to an {}\", n, T::NAME);\n        }\n    }\n}\n\nfn benchmark_float_rounding_from_integer<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat + for<'a> RoundingFrom<&'a Integer>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::rounding_from(Integer, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        integer_rounding_mode_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, rm)| {\n            no_out!(T::rounding_from(&n, rm));\n        })],\n    );\n}\n\nfn benchmark_float_try_from_integer<T: for<'a> TryFrom<&'a Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::try_from(Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::try_from(&n).ok()))],\n    );\n}\n\nfn benchmark_float_exact_from_integer<T: for<'a> ExactFrom<&'a Integer> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    run_benchmark(\n        &format!(\"{}::exact_from(Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(&n)))],\n    );\n}\n\nfn benchmark_float_convertible_from_integer<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::convertible_from(Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::convertible_from(&n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::bool_gen;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_from_bool);\n}\n\nfn demo_integer_from_bool(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in bool_gen().get(gm, config).take(limit) {\n        println!(\"Integer::from({}) = {}\", b, Integer::from(b));\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/from_floating_point.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::from::SignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_primitive_float_bucketer, primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_gen_var_5, primitive_float_rounding_mode_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_integer_rounding_from_float);\n    register_primitive_float_demos!(runner, demo_integer_try_from_float);\n    register_primitive_float_demos!(runner, demo_integer_exact_from_float);\n    register_primitive_float_demos!(runner, demo_integer_convertible_from_float);\n\n    register_primitive_float_benches!(runner, benchmark_integer_rounding_from_float);\n    register_primitive_float_benches!(runner, benchmark_integer_try_from_float);\n    register_primitive_float_benches!(runner, benchmark_integer_exact_from_float);\n    register_primitive_float_benches!(runner, benchmark_integer_convertible_from_float_algorithms);\n}\n\nfn demo_integer_rounding_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: RoundingFrom<T>,\n{\n    for (f, rm) in primitive_float_rounding_mode_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::rounding_from({}, {}) = {:?}\",\n            NiceFloat(f),\n            rm,\n            Integer::rounding_from(f, rm)\n        );\n    }\n}\n\nfn demo_integer_try_from_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: TryFrom<T, Error = SignedFromFloatError>,\n{\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Integer::try_from({}) = {:?}\",\n            NiceFloat(f),\n            Integer::try_from(f)\n        );\n    }\n}\n\nfn demo_integer_exact_from_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: ExactFrom<T>,\n{\n    for f in primitive_float_gen_var_5::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Integer::exact_from({}) = {}\",\n            NiceFloat(f),\n            Integer::exact_from(f)\n        );\n    }\n}\n\nfn demo_integer_convertible_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: ConvertibleFrom<T>,\n{\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        if Integer::convertible_from(f) {\n            println!(\"{} is convertible to a Integer\", NiceFloat(f));\n        } else {\n            println!(\"{} is not convertible to a Integer\", NiceFloat(f));\n        }\n    }\n}\n\nfn benchmark_integer_rounding_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: RoundingFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Integer::rounding_from({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_rounding_mode_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |(f, rm)| {\n            no_out!(Integer::rounding_from(f, rm));\n        })],\n    );\n}\n\nfn benchmark_integer_try_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Integer::try_from({})\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Integer::try_from(f).ok()))],\n    );\n}\n\nfn benchmark_integer_exact_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: ExactFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Integer::exact_from({})\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Integer::exact_from(f)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_convertible_from_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: TryFrom<T> + ConvertibleFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Integer::convertible_from({})\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"standard\", &mut |f| no_out!(Integer::convertible_from(f))),\n            (\"using try_from\", &mut |f| {\n                no_out!(Integer::try_from(f).is_ok());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_from_natural);\n    register_demo!(runner, demo_integer_from_natural_ref);\n    register_bench!(runner, benchmark_integer_from_natural_evaluation_strategy);\n}\n\nfn demo_integer_from_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        let n_clone = n.clone();\n        println!(\"Integer::from({}) = {}\", n_clone, Integer::from(n));\n    }\n}\n\nfn demo_integer_from_natural_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"Integer::from(&{}) = {}\", n, Integer::from(&n));\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_from_natural_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Integer::from(Natural)\", &mut |n| no_out!(Integer::from(n))),\n            (\"Integer::from(&Natural)\", &mut |n| {\n                no_out!(Integer::from(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse num::BigInt;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_integer_from_unsigned);\n    register_signed_demos!(runner, demo_integer_from_signed);\n    register_demo!(runner, demo_integer_const_from_unsigned);\n    register_demo!(runner, demo_integer_const_from_signed);\n\n    register_unsigned_benches!(runner, benchmark_integer_from_unsigned);\n    register_signed_benches!(runner, benchmark_integer_from_signed);\n    register_bench!(runner, benchmark_integer_from_u32_library_comparison);\n    register_bench!(runner, benchmark_integer_from_u64_library_comparison);\n    register_bench!(runner, benchmark_integer_from_i32_library_comparison);\n    register_bench!(runner, benchmark_integer_from_i64_library_comparison);\n    register_bench!(runner, benchmark_integer_const_from_unsigned);\n    register_bench!(runner, benchmark_integer_const_from_signed);\n}\n\nfn demo_integer_from_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: From<T>,\n{\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Integer::from({}) = {}\", u, Integer::from(u));\n    }\n}\n\nfn demo_integer_from_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: From<T>,\n{\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Integer::from({}) = {}\", i, Integer::from(i));\n    }\n}\n\nfn demo_integer_const_from_unsigned(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"Integer::const_from_unsigned({}) = {}\",\n            u,\n            Integer::const_from_unsigned(u)\n        );\n    }\n}\n\nfn demo_integer_const_from_signed(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen().get(gm, config).take(limit) {\n        println!(\n            \"Integer::const_from_signed({}) = {}\",\n            i,\n            Integer::const_from_signed(i)\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_from_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: From<T>,\n{\n    run_benchmark(\n        &format!(\"Integer::from({})\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(Integer::from(u)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_from_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: From<T>,\n{\n    run_benchmark(\n        &format!(\"Integer::from({})\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(Integer::from(u)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_from_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from(u32)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |u| no_out!(Integer::from(u))),\n            (\"num\", &mut |u| no_out!(BigInt::from(u))),\n            (\"rug\", &mut |u| no_out!(rug::Integer::from(u))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_from_u64_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |u| no_out!(Integer::from(u))),\n            (\"num\", &mut |u| no_out!(BigInt::from(u))),\n            (\"rug\", &mut |u| no_out!(rug::Integer::from(u))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_from_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from(i32)\",\n        BenchmarkType::LibraryComparison,\n        signed_gen::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |i| no_out!(Integer::from(i))),\n            (\"num\", &mut |i| no_out!(BigInt::from(i))),\n            (\"rug\", &mut |i| no_out!(rug::Integer::from(i))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_from_i64_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from(i64)\",\n        BenchmarkType::LibraryComparison,\n        signed_gen::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |i| no_out!(Integer::from(i))),\n            (\"num\", &mut |i| no_out!(BigInt::from(i))),\n            (\"rug\", &mut |i| no_out!(rug::Integer::from(i))),\n        ],\n    );\n}\n\nfn benchmark_integer_const_from_unsigned(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::const_from_unsigned(Limb)\",\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| {\n            no_out!(Integer::const_from_unsigned(u));\n        })],\n    );\n}\n\nfn benchmark_integer_const_from_signed(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::const_from_signed(Limb)\",\n        BenchmarkType::Single,\n        signed_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |i| no_out!(Integer::const_from_signed(i)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/from_twos_complement_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_from_twos_complement_limbs_asc);\n    register_demo!(runner, demo_integer_from_twos_complement_limbs_desc);\n    register_demo!(runner, demo_integer_from_owned_twos_complement_limbs_asc);\n    register_demo!(runner, demo_integer_from_owned_twos_complement_limbs_desc);\n\n    register_bench!(\n        runner,\n        benchmark_integer_from_twos_complement_limbs_asc_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_from_twos_complement_limbs_desc_evaluation_strategy\n    );\n}\n\nfn demo_integer_from_twos_complement_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_twos_complement_limbs_asc({:?}) = {:?}\",\n            xs,\n            Integer::from_twos_complement_limbs_asc(&xs)\n        );\n    }\n}\n\nfn demo_integer_from_twos_complement_limbs_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_twos_complement_limbs_desc({:?}) = {:?}\",\n            xs,\n            Integer::from_twos_complement_limbs_desc(&xs)\n        );\n    }\n}\n\nfn demo_integer_from_owned_twos_complement_limbs_asc(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_owned_twos_complement_limbs_asc({:?}) = {:?}\",\n            xs.clone(),\n            Integer::from_owned_twos_complement_limbs_asc(xs)\n        );\n    }\n}\n\nfn demo_integer_from_owned_twos_complement_limbs_desc(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_owned_twos_complement_limbs_desc({:?}) = {:?}\",\n            xs.clone(),\n            Integer::from_owned_twos_complement_limbs_desc(xs)\n        );\n    }\n}\n\nfn benchmark_integer_from_twos_complement_limbs_asc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_twos_complement_limbs_asc(&[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\n                \"Integer::from_twos_complement_limbs_asc(&[Limb])\",\n                &mut |xs| no_out!(Integer::from_twos_complement_limbs_asc(&xs)),\n            ),\n            (\n                \"Integer::from_owned_twos_complement_limbs_asc(Vec<Limb>)\",\n                &mut |xs| no_out!(Integer::from_owned_twos_complement_limbs_asc(xs)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_from_twos_complement_limbs_desc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_twos_complement_limbs_desc(&[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\n                \"Integer::from_twos_complement_limbs_desc(&[Limb])\",\n                &mut |xs| no_out!(Integer::from_twos_complement_limbs_desc(&xs)),\n            ),\n            (\n                \"Integer::from_owned_twos_complement_limbs_desc(Vec<Limb>)\",\n                &mut |xs| no_out!(Integer::from_owned_twos_complement_limbs_desc(xs)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_is_integer);\n    register_bench!(runner, benchmark_integer_is_integer);\n}\n\nfn demo_integer_is_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        if n.is_integer() {\n            println!(\"{n} is an integer\");\n        } else {\n            println!(\"{n} is not an integer\");\n        }\n    }\n}\n\nfn benchmark_integer_is_integer(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.is_integer()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_integer()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    clone::register(runner);\n    floating_point_from_integer::register(runner);\n    from_bool::register(runner);\n    from_floating_point::register(runner);\n    from_natural::register(runner);\n    from_primitive_int::register(runner);\n    from_twos_complement_limbs::register(runner);\n    is_integer::register(runner);\n    natural_from_integer::register(runner);\n    primitive_int_from_integer::register(runner);\n    serde::register(runner);\n    string::register(runner);\n    to_twos_complement_limbs::register(runner);\n}\n\nmod clone;\nmod floating_point_from_integer;\nmod from_bool;\nmod from_floating_point;\nmod from_natural;\nmod from_primitive_int;\nmod from_twos_complement_limbs;\nmod is_integer;\nmod natural_from_integer;\nmod primitive_int_from_integer;\nmod serde;\nmod string;\nmod to_twos_complement_limbs;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/natural_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_var_4};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_try_from_integer);\n    register_demo!(runner, demo_natural_try_from_integer_ref);\n    register_demo!(runner, demo_natural_exact_from_integer);\n    register_demo!(runner, demo_natural_exact_from_integer_ref);\n    register_demo!(runner, demo_natural_saturating_from_integer);\n    register_demo!(runner, demo_natural_saturating_from_integer_ref);\n    register_demo!(runner, demo_natural_convertible_from_integer);\n    register_demo!(runner, demo_natural_convertible_from_integer_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_try_from_integer_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_exact_from_integer_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_from_integer_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_convertible_from_integer_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_convertible_from_integer_algorithms\n    );\n}\n\nfn demo_natural_try_from_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        let n_clone = n.clone();\n        println!(\n            \"Natural::try_from({}) = {:?}\",\n            n_clone,\n            Natural::try_from(n)\n        );\n    }\n}\n\nfn demo_natural_try_from_integer_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"Natural::try_from(&{}) = {:?}\", n, Natural::try_from(&n));\n    }\n}\n\nfn demo_natural_exact_from_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen_var_4().get(gm, config).take(limit) {\n        let n_clone = n.clone();\n        println!(\n            \"Natural::exact_from({}) = {}\",\n            n_clone,\n            Natural::exact_from(n)\n        );\n    }\n}\n\nfn demo_natural_exact_from_integer_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen_var_4().get(gm, config).take(limit) {\n        println!(\"Natural::exact_from(&{}) = {}\", n, Natural::exact_from(&n));\n    }\n}\n\nfn demo_natural_saturating_from_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        let n_clone = n.clone();\n        println!(\n            \"Natural::saturating_from({}) = {}\",\n            n_clone,\n            Natural::saturating_from(n)\n        );\n    }\n}\n\nfn demo_natural_saturating_from_integer_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"Natural::saturating_from(&{}) = {}\",\n            n,\n            Natural::saturating_from(&n)\n        );\n    }\n}\n\nfn demo_natural_convertible_from_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        let n_clone = n.clone();\n        println!(\n            \"{} is {}convertible to a Natural\",\n            n_clone,\n            if Natural::convertible_from(n) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn demo_natural_convertible_from_integer_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Natural\",\n            n,\n            if Natural::convertible_from(&n) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn benchmark_natural_try_from_integer_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::try_from(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural::try_from(Integer)\", &mut |n| {\n                no_out!(Natural::try_from(n).ok());\n            }),\n            (\"Natural::try_from(&Integer)\", &mut |n| {\n                no_out!(Natural::try_from(&n).ok());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_exact_from_integer_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::exact_from(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural::exact_from(Integer)\", &mut |n| {\n                no_out!(Natural::exact_from(n));\n            }),\n            (\"Natural::exact_from(&Integer)\", &mut |n| {\n                no_out!(Natural::exact_from(&n));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_from_integer_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::saturating_from(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural::saturating_from(Integer)\", &mut |n| {\n                no_out!(Natural::saturating_from(n));\n            }),\n            (\"Natural::saturating_from(&Integer)\", &mut |n| {\n                no_out!(Natural::saturating_from(&n));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_convertible_from_integer_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::convertible_from(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural::convertible_from(Integer)\", &mut |n| {\n                no_out!(Natural::convertible_from(n));\n            }),\n            (\"Natural::convertible_from(&Integer)\", &mut |n| {\n                no_out!(Natural::convertible_from(&n));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_convertible_from_integer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::convertible_from(Integer)\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(Natural::convertible_from(n))),\n            (\"using try_from\", &mut |n| {\n                no_out!(Natural::try_from(n).is_ok());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/primitive_int_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, OverflowingFrom, SaturatingFrom, WrappingFrom,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_2_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_rm, integer_gen_var_5, integer_gen_var_6,\n};\nuse std::fmt::Debug;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_demos!(runner, demo_primitive_int_try_from_integer);\n    register_unsigned_demos!(runner, demo_unsigned_exact_from_integer);\n    register_signed_demos!(runner, demo_signed_exact_from_integer);\n    register_primitive_int_demos!(runner, demo_primitive_int_wrapping_from_integer);\n    register_primitive_int_demos!(runner, demo_primitive_int_saturating_from_integer);\n    register_primitive_int_demos!(runner, demo_primitive_int_overflowing_from_integer);\n    register_primitive_int_demos!(runner, demo_primitive_int_convertible_from_integer);\n\n    register_primitive_int_benches!(runner, benchmark_primitive_int_try_from_integer_algorithms);\n    register_unsigned_benches!(runner, benchmark_unsigned_exact_from_integer);\n    register_signed_benches!(runner, benchmark_signed_exact_from_integer);\n    register_primitive_int_benches!(\n        runner,\n        benchmark_primitive_int_wrapping_from_integer_algorithms\n    );\n    register_primitive_int_benches!(runner, benchmark_primitive_int_saturating_from_integer);\n    register_primitive_int_benches!(\n        runner,\n        benchmark_primitive_int_overflowing_from_integer_algorithms\n    );\n    register_primitive_int_benches!(\n        runner,\n        benchmark_primitive_int_convertible_from_integer_algorithms\n    );\n    register_bench!(runner, benchmark_u32_try_from_integer_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_u32_wrapping_from_integer_library_comparison\n    );\n    register_bench!(runner, benchmark_u64_try_from_integer_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_u64_wrapping_from_integer_library_comparison\n    );\n    register_bench!(runner, benchmark_i32_try_from_integer_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_i32_wrapping_from_integer_library_comparison\n    );\n    register_bench!(runner, benchmark_i64_try_from_integer_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_i64_wrapping_from_integer_library_comparison\n    );\n}\n\nfn demo_primitive_int_try_from_integer<T: for<'a> TryFrom<&'a Integer> + PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> <T as TryFrom<&'a Integer>>::Error: Debug,\n{\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{}::try_from(&{}) = {:?}\", T::NAME, n, T::try_from(&n));\n    }\n}\n\nfn demo_unsigned_exact_from_integer<T: for<'a> ExactFrom<&'a Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: From<T>,\n{\n    for n in integer_gen_var_5::<T>().get(gm, config).take(limit) {\n        println!(\"{}::exact_from(&{}) = {}\", T::NAME, n, T::exact_from(&n));\n    }\n}\n\nfn demo_signed_exact_from_integer<T: for<'a> ExactFrom<&'a Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Integer: From<T>,\n{\n    for n in integer_gen_var_6::<T>().get(gm, config).take(limit) {\n        println!(\"{}::exact_from(&{}) = {}\", T::NAME, n, T::exact_from(&n));\n    }\n}\n\nfn demo_primitive_int_wrapping_from_integer<T: PrimitiveInt + for<'a> WrappingFrom<&'a Integer>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::wrapping_from(&{}) = {}\",\n            T::NAME,\n            n,\n            T::wrapping_from(&n)\n        );\n    }\n}\n\nfn demo_primitive_int_saturating_from_integer<\n    T: PrimitiveInt + for<'a> SaturatingFrom<&'a Integer>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::saturating_from(&{}) = {}\",\n            T::NAME,\n            n,\n            T::saturating_from(&n)\n        );\n    }\n}\n\nfn demo_primitive_int_overflowing_from_integer<\n    T: for<'a> OverflowingFrom<&'a Integer> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::overflowing_from(&{}) = {:?}\",\n            T::NAME,\n            n,\n            T::overflowing_from(&n)\n        );\n    }\n}\n\nfn demo_primitive_int_convertible_from_integer<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            n,\n            if T::convertible_from(&n) { \"\" } else { \"not \" },\n            T::NAME,\n        );\n    }\n}\n\nfn benchmark_primitive_int_try_from_integer_algorithms<\n    T: for<'a> TryFrom<&'a Integer> + for<'a> OverflowingFrom<&'a Integer> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::try_from(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::try_from(&n).ok())),\n            (\"using overflowing_from\", &mut |n| {\n                let (value, overflow) = T::overflowing_from(&n);\n                if overflow {\n                    None\n                } else {\n                    Some(value)\n                };\n            }),\n        ],\n    );\n}\n\nfn benchmark_unsigned_exact_from_integer<T: for<'a> ExactFrom<&'a Integer> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: From<T>,\n{\n    run_benchmark(\n        &format!(\"{}::exact_from(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(&n)))],\n    );\n}\n\nfn benchmark_signed_exact_from_integer<T: for<'a> ExactFrom<&'a Integer> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: From<T>,\n{\n    run_benchmark(\n        &format!(\"{}::exact_from(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(&n)))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_primitive_int_wrapping_from_integer_algorithms<\n    T: for<'a> OverflowingFrom<&'a Integer> + PrimitiveInt + for<'a> WrappingFrom<&'a Integer>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::wrapping_from(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::wrapping_from(&n))),\n            (\"using overflowing_from\", &mut |n| {\n                T::overflowing_from(&n).0;\n            }),\n        ],\n    );\n}\n\nfn benchmark_primitive_int_saturating_from_integer<\n    T: PrimitiveInt + for<'a> SaturatingFrom<&'a Integer>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::saturating_from(&Integer)\", T::NAME),\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::saturating_from(&n)))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_primitive_int_overflowing_from_integer_algorithms<\n    T: for<'a> ConvertibleFrom<&'a Integer>\n        + for<'a> OverflowingFrom<&'a Integer>\n        + PrimitiveInt\n        + for<'a> WrappingFrom<&'a Integer>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::overflowing_from(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::overflowing_from(&n))),\n            (\"using wrapping_from and convertible_from\", &mut |n| {\n                no_out!((T::wrapping_from(&n), !T::convertible_from(&n)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_primitive_int_convertible_from_integer_algorithms<\n    T: for<'a> TryFrom<&'a Integer> + for<'a> ConvertibleFrom<&'a Integer> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::convertible_from(&Integer)\", T::NAME),\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::convertible_from(&n))),\n            (\"using try_from\", &mut |n| no_out!(T::try_from(&n).is_ok())),\n        ],\n    );\n}\n\nfn benchmark_u32_try_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32::try_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u32::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u32())),\n        ],\n    );\n}\n\nfn benchmark_u32_wrapping_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32::wrapping_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u32::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u32_wrapping())),\n        ],\n    );\n}\n\nfn benchmark_u64_try_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64::try_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u64::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u64())),\n        ],\n    );\n}\n\nfn benchmark_u64_wrapping_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64::wrapping_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u64::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u64_wrapping())),\n        ],\n    );\n}\n\nfn benchmark_i32_try_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i32::try_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i32::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i32())),\n        ],\n    );\n}\n\nfn benchmark_i32_wrapping_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i32::wrapping_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i32::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i32_wrapping())),\n        ],\n    );\n}\n\nfn benchmark_i64_try_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i64::try_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i64::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i64())),\n        ],\n    );\n}\n\nfn benchmark_i64_wrapping_from_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i64::wrapping_from(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i64::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i64_wrapping())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_9};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_deserialize_bucketer, triple_3_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_nrm, string_triple_gen_var_2};\nuse num::BigInt;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_serialize_json);\n    register_demo!(runner, demo_integer_deserialize_json);\n    register_demo!(runner, demo_integer_deserialize_json_targeted);\n\n    register_bench!(runner, benchmark_integer_serialize_json_library_comparison);\n    register_bench!(runner, benchmark_integer_deserialize_json);\n    register_bench!(\n        runner,\n        benchmark_integer_deserialize_json_library_comparison\n    );\n}\n\nfn demo_integer_serialize_json(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"serde_json::to_string({}) = {}\",\n            n,\n            serde_json::to_string(&n).unwrap()\n        );\n    }\n}\n\nfn demo_integer_deserialize_json(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        let n: Result<Integer, _> = serde_json::from_str(&s);\n        println!(\"serde_json::from_str({s}) = {n:?}\");\n    }\n}\n\nfn demo_integer_deserialize_json_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_9().get(gm, config).take(limit) {\n        let n: Integer = serde_json::from_str(&s).unwrap();\n        println!(\"serde_json::from_str({s}) = {n}\");\n    }\n}\n\nfn benchmark_integer_serialize_json_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::to_string(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n            (\"num\", &mut |(x, _, _)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n            (\"rug\", &mut |(_, x, _)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_deserialize_json(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::from_str(&str)\",\n        BenchmarkType::Single,\n        string_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| {\n            let _n: Integer = serde_json::from_str(&s).unwrap();\n        })],\n    );\n}\n\nfn benchmark_integer_deserialize_json_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::from_str(&str)\",\n        BenchmarkType::LibraryComparison,\n        string_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_deserialize_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, s)| {\n                let _n: Integer = serde_json::from_str(&s).unwrap();\n            }),\n            (\"num\", &mut |(s, _, _)| {\n                let _n: BigInt = serde_json::from_str(&s).unwrap();\n            }),\n            (\"rug\", &mut |(_, s, _)| {\n                let _n: rug::Integer = serde_json::from_str(&s).unwrap();\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::FromSciString;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_string_len_bucketer, string_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    string_from_sci_string_options_pair_gen_var_2, string_from_sci_string_options_pair_gen_var_3,\n    string_gen_var_14, string_gen_var_15,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_from_sci_string);\n    register_demo!(runner, demo_integer_from_sci_string_targeted);\n    register_demo!(runner, demo_integer_from_sci_string_with_options);\n    register_demo!(runner, demo_integer_from_sci_string_with_options_targeted);\n\n    register_bench!(runner, benchmark_integer_from_sci_string);\n    register_bench!(runner, benchmark_integer_from_sci_string_with_options);\n}\n\nfn demo_integer_from_sci_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_14().get(gm, config).take(limit) {\n        println!(\n            \"Integer::from_sci_string({}) = {:?}\",\n            s,\n            Integer::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_integer_from_sci_string_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_15().get(gm, config).take(limit) {\n        println!(\n            \"Integer::from_sci_string({}) = {:?}\",\n            s,\n            Integer::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_integer_from_sci_string_with_options(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (s, options) in string_from_sci_string_options_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::from_sci_string_with_options({}, {:?}) = {:?}\",\n            s,\n            options,\n            Integer::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn demo_integer_from_sci_string_with_options_targeted(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (s, options) in string_from_sci_string_options_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::from_sci_string_with_options({}, {:?}) = {:?}\",\n            s,\n            options,\n            Integer::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn benchmark_integer_from_sci_string(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_sci_string(&str)\",\n        BenchmarkType::Single,\n        string_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(Integer::from_sci_string(&s)))],\n    );\n}\n\nfn benchmark_integer_from_sci_string_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_sci_string_with_options(&str, FromSciStringOptions)\",\n        BenchmarkType::Single,\n        string_from_sci_string_options_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_string_len_bucketer(\"s\"),\n        &mut [(\"Malachite\", &mut |(s, options)| {\n            no_out!(Integer::from_sci_string_with_options(&s, options));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{FromStringBase, WrappingFrom};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_2_string_len_bucketer, string_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    string_gen, string_gen_var_4, unsigned_string_pair_gen_var_2, unsigned_string_pair_gen_var_3,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse num::{BigInt, Num};\nuse std::str::FromStr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_from_str);\n    register_demo!(runner, demo_integer_from_str_targeted);\n    register_demo!(runner, demo_integer_from_string_base);\n    register_demo!(runner, demo_integer_from_string_base_targeted);\n    register_bench!(runner, benchmark_integer_from_str_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_integer_from_string_base_library_comparison\n    );\n}\n\nfn demo_integer_from_string_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (base, s) in unsigned_string_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"Integer::from_string_base({}, {}) = {:?}\",\n            base,\n            s,\n            Integer::from_string_base(base, &s)\n        );\n    }\n}\n\nfn demo_integer_from_string_base_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (base, s) in unsigned_string_pair_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"Integer::from_string_base({}, {}) = {}\",\n            base,\n            s,\n            Integer::from_string_base(base, &s).unwrap()\n        );\n    }\n}\n\nfn demo_integer_from_str(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\"Integer::from_str({}) = {:?}\", s, Integer::from_str(&s));\n    }\n}\n\nfn demo_integer_from_str_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_4().get(gm, config).take(limit) {\n        println!(\n            \"Integer::from_str({}) = {}\",\n            s,\n            Integer::from_str(&s).unwrap()\n        );\n    }\n}\n\nfn benchmark_integer_from_str_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_str(&str)\",\n        BenchmarkType::LibraryComparison,\n        string_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |s| {\n                no_out!(Integer::from_str(&s).unwrap());\n            }),\n            (\"num\", &mut |s| no_out!(BigInt::from_str(&s).unwrap())),\n            (\"rug\", &mut |s| no_out!(rug::Integer::from_str(&s).unwrap())),\n        ],\n    );\n}\n\nfn benchmark_integer_from_string_base_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_string_base(u64, &str)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_string_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_string_len_bucketer(\"s\"),\n        &mut [\n            (\"Malachite\", &mut |(base, s)| {\n                no_out!(Integer::from_string_base(base, &s).unwrap());\n            }),\n            (\"num\", &mut |(base, s)| {\n                no_out!(BigInt::from_str_radix(&s, u32::wrapping_from(base)).unwrap());\n            }),\n            (\"rug\", &mut |(base, s)| {\n                no_out!(rug::Integer::from_str_radix(&s, i32::wrapping_from(base)).unwrap());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_sci_string::register(runner);\n    from_string::register(runner);\n    to_sci::register(runner);\n    to_string::register(runner);\n}\n\nmod from_sci_string;\nmod from_string;\nmod to_sci;\nmod to_string;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ToSci;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_to_sci_options_pair_gen, integer_to_sci_options_pair_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_to_sci);\n    register_demo!(runner, demo_integer_fmt_sci_valid);\n    register_demo!(runner, demo_integer_to_sci_with_options);\n\n    register_bench!(runner, benchmark_integer_to_sci);\n    register_bench!(runner, benchmark_integer_fmt_sci_valid);\n    register_bench!(runner, benchmark_integer_to_sci_with_options);\n}\n\nfn demo_integer_to_sci(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in integer_gen().get(gm, config).take(limit) {\n        println!(\"({}).to_sci() = {}\", x, x.to_sci());\n    }\n}\n\nfn demo_integer_fmt_sci_valid(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, options) in integer_to_sci_options_pair_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.fmt_sci_valid(options) {\n            println!(\"{x} can be converted to sci using {options:?}\");\n        } else {\n            println!(\"{x} cannot be converted to sci using {options:?}\");\n        }\n    }\n}\n\nfn demo_integer_to_sci_with_options(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, options) in integer_to_sci_options_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_sci_with_options({}, {:?}) = {}\",\n            x,\n            options,\n            x.to_sci_with_options(options)\n        );\n    }\n}\n\nfn benchmark_integer_to_sci(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.to_sci()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.to_sci().to_string()))],\n    );\n}\n\nfn benchmark_integer_fmt_sci_valid(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.fmt_sci_valid(ToSciOptions)\",\n        BenchmarkType::Single,\n        integer_to_sci_options_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.fmt_sci_valid(options));\n        })],\n    );\n}\n\nfn benchmark_integer_to_sci_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_sci_with_options(ToSciOptions)\",\n        BenchmarkType::Single,\n        integer_to_sci_options_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.to_sci_with_options(options).to_string());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ToStringBase, WrappingFrom};\nuse malachite_base::strings::{ToBinaryString, ToLowerHexString, ToOctalString, ToUpperHexString};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_1_integer_bit_bucketer, triple_1_integer_bit_bucketer,\n    triple_3_integer_bit_bucketer, triple_3_pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_nrm, integer_unsigned_pair_gen_var_1,\n    integer_unsigned_pair_gen_var_1_nrm, integer_unsigned_pair_gen_var_2,\n    integer_unsigned_unsigned_triple_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_to_string);\n    register_demo!(runner, demo_integer_to_string_with_width);\n    register_demo!(runner, demo_integer_to_binary_string);\n    register_demo!(runner, demo_integer_to_binary_string_with_0b);\n    register_demo!(runner, demo_integer_to_binary_string_with_width);\n    register_demo!(runner, demo_integer_to_binary_string_with_0b_and_width);\n    register_demo!(runner, demo_integer_to_octal_string);\n    register_demo!(runner, demo_integer_to_octal_string_with_0o);\n    register_demo!(runner, demo_integer_to_octal_string_with_width);\n    register_demo!(runner, demo_integer_to_octal_string_with_0o_and_width);\n    register_demo!(runner, demo_integer_to_lower_hex_string);\n    register_demo!(runner, demo_integer_to_lower_hex_string_with_0x);\n    register_demo!(runner, demo_integer_to_lower_hex_string_with_width);\n    register_demo!(runner, demo_integer_to_lower_hex_string_with_0x_and_width);\n    register_demo!(runner, demo_integer_to_upper_hex_string);\n    register_demo!(runner, demo_integer_to_upper_hex_string_with_0x);\n    register_demo!(runner, demo_integer_to_upper_hex_string_with_width);\n    register_demo!(runner, demo_integer_to_upper_hex_string_with_0x_and_width);\n    register_demo!(runner, demo_integer_to_string_base);\n    register_demo!(runner, demo_integer_to_string_base_upper);\n    register_demo!(runner, demo_integer_base_fmt_wrapper_fmt);\n    register_demo!(runner, demo_integer_base_fmt_wrapper_fmt_upper);\n    register_demo!(runner, demo_integer_base_fmt_wrapper_fmt_with_width);\n    register_demo!(runner, demo_integer_base_fmt_wrapper_fmt_upper_with_width);\n    register_bench!(runner, benchmark_integer_to_string_library_comparison);\n    register_bench!(runner, benchmark_integer_to_string_algorithms);\n    register_bench!(runner, benchmark_integer_to_string_with_width);\n    register_bench!(\n        runner,\n        benchmark_integer_to_binary_string_library_comparison\n    );\n    register_bench!(runner, benchmark_integer_to_binary_string_algorithms);\n    register_bench!(runner, benchmark_integer_to_binary_string_with_width);\n    register_bench!(runner, benchmark_integer_to_octal_string_library_comparison);\n    register_bench!(runner, benchmark_integer_to_octal_string_algorithms);\n    register_bench!(runner, benchmark_integer_to_octal_string_with_width);\n    register_bench!(\n        runner,\n        benchmark_integer_to_lower_hex_string_library_comparison\n    );\n    register_bench!(runner, benchmark_integer_to_lower_hex_string_algorithms);\n    register_bench!(runner, benchmark_integer_to_lower_hex_string_with_width);\n    register_bench!(\n        runner,\n        benchmark_integer_to_upper_hex_string_library_comparison\n    );\n    register_bench!(runner, benchmark_integer_to_upper_hex_string_with_width);\n    register_bench!(runner, benchmark_integer_to_string_base_library_comparison);\n    register_bench!(runner, benchmark_integer_to_string_base_algorithms);\n    register_bench!(runner, benchmark_integer_to_string_base_upper_algorithms);\n    register_bench!(runner, benchmark_integer_base_fmt_wrapper_fmt_with_width);\n    register_bench!(\n        runner,\n        benchmark_integer_base_fmt_wrapper_fmt_upper_with_width\n    );\n}\n\nfn demo_integer_to_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$}\")\n        );\n    }\n}\n\nfn demo_integer_to_binary_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:b}\");\n    }\n}\n\nfn demo_integer_to_binary_string_with_0b(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:#b}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_binary_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}b}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$b}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_binary_string_with_0b_and_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}b}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$b}\")\n        );\n    }\n}\n\nfn demo_integer_to_octal_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:o}\");\n    }\n}\n\nfn demo_integer_to_octal_string_with_0o(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:#o}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_octal_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}o}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$o}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_octal_string_with_0o_and_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}o}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$o}\")\n        );\n    }\n}\n\nfn demo_integer_to_lower_hex_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:x}\");\n    }\n}\n\nfn demo_integer_to_lower_hex_string_with_0x(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:#x}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_lower_hex_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}x}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$x}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_lower_hex_string_with_0x_and_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}x}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$x}\")\n        );\n    }\n}\n\nfn demo_integer_to_upper_hex_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:X}\");\n    }\n}\n\nfn demo_integer_to_upper_hex_string_with_0x(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"{n:#X}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_upper_hex_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}X}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$X}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_to_upper_hex_string_with_0x_and_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, width) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}X}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$X}\")\n        );\n    }\n}\n\nfn demo_integer_to_string_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in integer_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).to_string_base({}) = {}\",\n            x,\n            base,\n            x.to_string_base(base)\n        );\n    }\n}\n\nfn demo_integer_to_string_base_upper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in integer_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).to_string_base_upper({}) = {}\",\n            x,\n            base,\n            x.to_string_base_upper(base)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_base_fmt_wrapper_fmt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in integer_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{}\", BaseFmtWrapper::new(&x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_base_fmt_wrapper_fmt_upper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in integer_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{:#}\", BaseFmtWrapper::new(&x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_base_fmt_wrapper_fmt_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base, width) in integer_unsigned_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, base), width = width)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_integer_base_fmt_wrapper_fmt_upper_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, base, width) in integer_unsigned_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, base), width = width)\n        );\n    }\n}\n\nfn benchmark_integer_to_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_string()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_string())),\n        ],\n    );\n}\n\nfn benchmark_integer_to_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_string()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(10))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_to_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usize}}\\\", Integer)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$}\"));\n        })],\n    );\n}\n\nfn benchmark_integer_to_binary_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_binary_string()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_binary_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_binary_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_binary_string())),\n        ],\n    );\n}\n\nfn benchmark_integer_to_binary_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_binary_string()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_binary_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(2))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_to_binary_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizeb}}\\\", Integer)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$b}\"));\n        })],\n    );\n}\n\nfn benchmark_integer_to_octal_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_octal_string()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_octal_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_octal_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_octal_string())),\n        ],\n    );\n}\n\nfn benchmark_integer_to_octal_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_octal_string()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_octal_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(8))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_to_octal_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizeo}}\\\", Integer)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$o}\"));\n        })],\n    );\n}\n\nfn benchmark_integer_to_lower_hex_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_lower_hex_string()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| {\n                no_out!(x.to_lower_hex_string());\n            }),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_lower_hex_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_lower_hex_string())),\n        ],\n    );\n}\n\nfn benchmark_integer_to_lower_hex_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_lower_hex_string()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_lower_hex_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(16))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_to_lower_hex_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizex}}\\\", Integer)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$x}\"));\n        })],\n    );\n}\n\nfn benchmark_integer_to_upper_hex_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_upper_hex_string()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| {\n                no_out!(x.to_upper_hex_string());\n            }),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_upper_hex_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_upper_hex_string())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_to_upper_hex_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizeX}}\\\", Integer)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$X}\"));\n        })],\n    );\n}\n\nfn benchmark_integer_to_string_base_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_string_base(u64)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, base))| {\n                no_out!(x.to_string_base(base));\n            }),\n            (\"num\", &mut |((x, base), _, _)| {\n                no_out!(x.to_str_radix(u32::wrapping_from(base)));\n            }),\n            (\"rug\", &mut |(_, (x, base), _)| {\n                no_out!(x.to_string_radix(i32::wrapping_from(base)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_to_string_base_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_string_base(u64)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_string\", &mut |(x, base)| {\n                no_out!(x.to_string_base(base));\n            }),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{}\", BaseFmtWrapper::new(&x, base)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_to_string_base_upper_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_string_base_upper(u64)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_string\", &mut |(x, base)| {\n                no_out!(x.to_string_base_upper(base));\n            }),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{:#}\", BaseFmtWrapper::new(&x, base)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_base_fmt_wrapper_fmt_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usize}}\\\", BaseFmtWrapper::new(Integer, u64))\",\n        BenchmarkType::Single,\n        integer_unsigned_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:0width$}\",\n                BaseFmtWrapper::new(&x, base),\n                width = width\n            ));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_base_fmt_wrapper_fmt_upper_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:#0usize}}\\\", BaseFmtWrapper::new(Integer, u64))\",\n        BenchmarkType::Single,\n        integer_unsigned_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:#0width$}\",\n                BaseFmtWrapper::new(&x, base),\n                width = width\n            ));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/conversion/to_twos_complement_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{unsigned_vec_gen, unsigned_vec_gen_var_2};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::conversion::to_twos_complement_limbs::{\n    limbs_maybe_sign_extend_non_negative_in_place, limbs_twos_complement,\n    limbs_twos_complement_and_maybe_sign_extend_negative_in_place, limbs_twos_complement_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_1_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_gen, integer_unsigned_pair_gen_var_2};\nuse malachite_nz::test_util::integer::conversion::to_twos_complement_limbs::{\n    limbs_twos_complement_in_place_alt_1, limbs_twos_complement_in_place_alt_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_twos_complement);\n    register_demo!(runner, demo_limbs_maybe_sign_extend_non_negative_in_place);\n    register_demo!(runner, demo_limbs_twos_complement_in_place);\n    register_demo!(\n        runner,\n        demo_limbs_twos_complement_and_maybe_sign_extend_negative_in_place\n    );\n    register_demo!(runner, demo_integer_to_twos_complement_limbs_asc);\n    register_demo!(runner, demo_integer_to_twos_complement_limbs_desc);\n    register_demo!(runner, demo_integer_into_twos_complement_limbs_asc);\n    register_demo!(runner, demo_integer_into_twos_complement_limbs_desc);\n    register_demo!(runner, demo_integer_twos_complement_limbs);\n    register_demo!(runner, demo_integer_twos_complement_limbs_rev);\n    register_demo!(runner, demo_integer_twos_complement_limbs_get_limb);\n    register_demo!(runner, demo_integer_twos_complement_limb_count);\n\n    register_bench!(runner, benchmark_limbs_twos_complement);\n    register_bench!(\n        runner,\n        benchmark_limbs_maybe_sign_extend_non_negative_in_place\n    );\n    register_bench!(runner, benchmark_limbs_twos_complement_in_place_algorithms);\n    register_bench!(\n        runner,\n        benchmark_limbs_twos_complement_and_maybe_sign_extend_negative_in_place\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_to_twos_complement_limbs_asc_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_to_twos_complement_limbs_desc_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_twos_complement_limbs_get_limb_algorithms\n    );\n    register_bench!(runner, benchmark_integer_twos_complement_limb_count);\n}\n\nfn demo_limbs_twos_complement(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"limbs_twos_complement({:?}) = {:?}\",\n            xs,\n            limbs_twos_complement(&xs)\n        );\n    }\n}\n\nfn demo_limbs_maybe_sign_extend_non_negative_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        let mut mut_xs = xs.clone();\n        limbs_maybe_sign_extend_non_negative_in_place(&mut mut_xs);\n        println!(\n            \"xs := {xs:?}; limbs_maybe_sign_extend_non_negative_in_place(&mut xs); xs = {mut_xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_twos_complement_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        let mut mut_xs = xs.clone();\n        let carry = limbs_twos_complement_in_place(&mut mut_xs);\n        println!(\n            \"xs := {xs:?}; limbs_twos_complement_in_place(&mut xs) = {carry}; xs = {mut_xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_twos_complement_and_maybe_sign_extend_negative_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for xs in unsigned_vec_gen_var_2().get(gm, config).take(limit) {\n        let mut mut_xs = xs.clone();\n        limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut mut_xs);\n        println!(\n            \"xs := {xs:?}; limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut xs); \\\n            xs = {mut_xs:?}\",\n        );\n    }\n}\n\nfn demo_integer_to_twos_complement_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"to_twos_complement_limbs_asc({}) = {:?}\",\n            n,\n            n.to_twos_complement_limbs_asc()\n        );\n    }\n}\n\nfn demo_integer_to_twos_complement_limbs_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"to_twos_complement_limbs_desc({}) = {:?}\",\n            n,\n            n.to_twos_complement_limbs_desc()\n        );\n    }\n}\n\nfn demo_integer_into_twos_complement_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"into_twos_complement_limbs_asc({}) = {:?}\",\n            n,\n            n.clone().into_twos_complement_limbs_asc()\n        );\n    }\n}\n\nfn demo_integer_into_twos_complement_limbs_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"into_twos_complement_limbs_desc({}) = {:?}\",\n            n,\n            n.clone().into_twos_complement_limbs_desc()\n        );\n    }\n}\n\nfn demo_integer_twos_complement_limbs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"twos_complement_limbs({}) = {:?}\",\n            n,\n            n.twos_complement_limbs().collect_vec()\n        );\n    }\n}\n\nfn demo_integer_twos_complement_limbs_rev(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"twos_complement_limbs({}).rev() = {:?}\",\n            n,\n            n.twos_complement_limbs().rev().collect_vec()\n        );\n    }\n}\n\nfn demo_integer_twos_complement_limbs_get_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, i) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"twos_complement_limbs({}).get_limb({}) = {:?}\",\n            n,\n            i,\n            n.twos_complement_limbs().get_limb(i)\n        );\n    }\n}\n\nfn demo_integer_twos_complement_limb_count(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\n            \"twos_complement_limb_count({}) = {}\",\n            n,\n            n.twos_complement_limb_count()\n        );\n    }\n}\n\nfn benchmark_limbs_twos_complement(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_twos_complement(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_twos_complement(&xs)))],\n    );\n}\n\nfn benchmark_limbs_maybe_sign_extend_non_negative_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_maybe_sign_extend_non_negative_in_place(&mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |ref mut xs| {\n            limbs_maybe_sign_extend_non_negative_in_place(xs);\n        })],\n    );\n}\n\nfn benchmark_limbs_twos_complement_in_place_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_twos_complement_in_place(&mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |ref mut xs| {\n                no_out!(limbs_twos_complement_in_place(xs));\n            }),\n            (\"integrated\", &mut |ref mut xs| {\n                no_out!(limbs_twos_complement_in_place_alt_1(xs));\n            }),\n            (\"sub 1 and not\", &mut |ref mut xs| {\n                no_out!(limbs_twos_complement_in_place_alt_2(xs));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_twos_complement_and_maybe_sign_extend_negative_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |ref mut xs| {\n            limbs_twos_complement_and_maybe_sign_extend_negative_in_place(xs);\n        })],\n    );\n}\n\nfn benchmark_integer_to_twos_complement_limbs_asc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_twos_complement_limbs_asc()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Integer.to_twos_complement_limbs_asc()\", &mut |n| {\n                no_out!(n.to_twos_complement_limbs_asc());\n            }),\n            (\"Integer.into_twos_complement_limbs_asc()\", &mut |n| {\n                no_out!(n.into_twos_complement_limbs_asc());\n            }),\n            (\"Integer.twos_complement_limbs().collect_vec()\", &mut |n| {\n                no_out!(n.twos_complement_limbs().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_to_twos_complement_limbs_desc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_twos_complement_limbs_desc()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Integer.to_twos_complement_limbs_desc()\", &mut |n| {\n                no_out!(n.to_twos_complement_limbs_desc());\n            }),\n            (\"Integer.into_twos_complement_limbs_desc()\", &mut |n| {\n                no_out!(n.into_twos_complement_limbs_desc());\n            }),\n            (\n                \"Integer.twos_complement_limbs().rev().collect_vec()\",\n                &mut |n| no_out!(n.twos_complement_limbs().collect_vec()),\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_twos_complement_limbs_get_limb_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.twos_complement_limbs().get_limb()\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"Integer.twos_complement_limbs().get_limb(u)\",\n                &mut |(n, u)| no_out!(n.twos_complement_limbs().get_limb(u)),\n            ),\n            (\n                \"Integer.into_twos_complement_limbs_asc()[u]\",\n                &mut |(n, u)| {\n                    let u = usize::exact_from(u);\n                    let non_negative = n >= 0;\n                    let limbs = n.into_twos_complement_limbs_asc();\n                    if u >= limbs.len() {\n                        if non_negative { 0 } else { Limb::MAX }\n                    } else {\n                        limbs[u]\n                    };\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_integer_twos_complement_limb_count(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.twos_complement_limb_count()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| {\n            no_out!(n.twos_complement_limb_count());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_8, unsigned_vec_pair_gen_var_9, unsigned_vec_triple_gen_var_33,\n    unsigned_vec_triple_gen_var_34, unsigned_vec_unsigned_pair_gen_var_15,\n    unsigned_vec_unsigned_pair_gen_var_18, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::and::{\n    limbs_and_neg_neg, limbs_and_neg_neg_to_out, limbs_and_pos_neg,\n    limbs_and_pos_neg_in_place_left, limbs_and_pos_neg_to_out, limbs_neg_and_limb_neg,\n    limbs_neg_and_limb_neg_to_out, limbs_pos_and_limb_neg, limbs_pos_and_limb_neg_in_place,\n    limbs_pos_and_limb_neg_to_out, limbs_slice_and_neg_neg_in_place_either,\n    limbs_slice_and_neg_neg_in_place_left, limbs_slice_and_pos_neg_in_place_right,\n    limbs_slice_neg_and_limb_neg_in_place, limbs_vec_and_neg_neg_in_place_either,\n    limbs_vec_and_neg_neg_in_place_left, limbs_vec_and_pos_neg_in_place_right,\n    limbs_vec_neg_and_limb_neg_in_place,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_rm};\nuse malachite_nz::test_util::integer::logic::and::{integer_and_alt_1, integer_and_alt_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_pos_and_limb_neg);\n    register_demo!(runner, demo_limbs_pos_and_limb_neg_to_out);\n    register_demo!(runner, demo_limbs_pos_and_limb_neg_in_place);\n    register_demo!(runner, demo_limbs_neg_and_limb_neg);\n    register_demo!(runner, demo_limbs_neg_and_limb_neg_to_out);\n    register_demo!(runner, demo_limbs_slice_neg_and_limb_neg_in_place);\n    register_demo!(runner, demo_limbs_vec_neg_and_limb_neg_in_place);\n    register_demo!(runner, demo_limbs_and_pos_neg);\n    register_demo!(runner, demo_limbs_and_pos_neg_to_out);\n    register_demo!(runner, demo_limbs_and_pos_neg_in_place_left);\n    register_demo!(runner, demo_limbs_slice_and_pos_neg_in_place_right);\n    register_demo!(runner, demo_limbs_vec_and_pos_neg_in_place_right);\n    register_demo!(runner, demo_limbs_and_neg_neg);\n    register_demo!(runner, demo_limbs_and_neg_neg_to_out);\n    register_demo!(runner, demo_limbs_slice_and_neg_neg_in_place_left);\n    register_demo!(runner, demo_limbs_vec_and_neg_neg_in_place_left);\n    register_demo!(runner, demo_limbs_slice_and_neg_neg_in_place_either);\n    register_demo!(runner, demo_limbs_vec_and_neg_neg_in_place_either);\n    register_demo!(runner, demo_integer_and_assign);\n    register_demo!(runner, demo_integer_and_assign_ref);\n    register_demo!(runner, demo_integer_and);\n    register_demo!(runner, demo_integer_and_val_ref);\n    register_demo!(runner, demo_integer_and_ref_val);\n    register_demo!(runner, demo_integer_and_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_pos_and_limb_neg);\n    register_bench!(runner, benchmark_limbs_pos_and_limb_neg_to_out);\n    register_bench!(runner, benchmark_limbs_pos_and_limb_neg_in_place);\n    register_bench!(runner, benchmark_limbs_neg_and_limb_neg);\n    register_bench!(runner, benchmark_limbs_neg_and_limb_neg_to_out);\n    register_bench!(runner, benchmark_limbs_slice_neg_and_limb_neg_in_place);\n    register_bench!(runner, benchmark_limbs_vec_neg_and_limb_neg_in_place);\n    register_bench!(runner, benchmark_limbs_and_pos_neg);\n    register_bench!(runner, benchmark_limbs_and_pos_neg_to_out);\n    register_bench!(runner, benchmark_limbs_and_pos_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_slice_and_pos_neg_in_place_right);\n    register_bench!(runner, benchmark_limbs_vec_and_pos_neg_in_place_right);\n    register_bench!(runner, benchmark_limbs_and_neg_neg);\n    register_bench!(runner, benchmark_limbs_and_neg_neg_to_out);\n    register_bench!(runner, benchmark_limbs_slice_and_neg_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_vec_and_neg_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_slice_and_neg_neg_in_place_either);\n    register_bench!(runner, benchmark_limbs_vec_and_neg_neg_in_place_either);\n    register_bench!(runner, benchmark_integer_and_assign_library_comparison);\n    register_bench!(runner, benchmark_integer_and_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_and_library_comparison);\n    register_bench!(runner, benchmark_integer_and_algorithms);\n    register_bench!(runner, benchmark_integer_and_evaluation_strategy);\n}\n\nfn demo_limbs_pos_and_limb_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_pos_and_limb_neg({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_pos_and_limb_neg(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_pos_and_limb_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_pos_and_limb_neg_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_pos_and_limb_neg_to_out(&mut out, {xs:?}, {y}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_pos_and_limb_neg_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_pos_and_limb_neg_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_pos_and_limb_neg_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_neg_and_limb_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_neg_and_limb_neg({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_neg_and_limb_neg(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_neg_and_limb_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let carry = limbs_neg_and_limb_neg_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; limbs_neg_and_limb_neg_to_out(&mut out, {xs:?}, {y}) = {carry}; \\\n            out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_neg_and_limb_neg_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_neg_and_limb_neg_in_place(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_neg_and_limb_neg_in_place(&mut xs, {y}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_neg_and_limb_neg_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_neg_and_limb_neg_in_place(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; limbs_vec_neg_and_limb_neg_in_place(&mut xs, {y}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_and_pos_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\n            \"limbs_and_pos_neg({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_and_pos_neg(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_and_pos_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_33().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_and_pos_neg_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; limbs_and_pos_neg_to_out(&mut out, {xs:?}, {ys:?}); \\\n             out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_and_pos_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_and_pos_neg_in_place_left(&mut xs, &ys);\n        println!(\"xs := {xs_old:?}; limbs_and_pos_neg_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_slice_and_pos_neg_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let ys_old = ys.clone();\n        limbs_vec_and_pos_neg_in_place_right(&xs, &mut ys);\n        println!(\n            \"ys := {xs:?}; limbs_vec_and_pos_neg_in_place_right({ys_old:?}, &mut ys); ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_and_pos_neg_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let ys_old = ys.clone();\n        limbs_slice_and_pos_neg_in_place_right(&xs, &mut ys);\n        println!(\n            \"ys := {xs:?}; \\\n            limbs_slice_and_pos_neg_in_place_right({ys_old:?}, &mut ys); ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_and_neg_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\n            \"limbs_and_neg_neg({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_and_neg_neg(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_and_neg_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_34().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let b = limbs_and_neg_neg_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_and_neg_neg_to_out(&mut out, {xs:?}, {ys:?}) = {b}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_and_neg_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_9().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let b = limbs_slice_and_neg_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_and_neg_neg_in_place_left(&mut xs, {ys:?}) = {b}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_and_neg_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_vec_and_neg_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; limbs_vec_and_neg_neg_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_and_neg_neg_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let p = limbs_slice_and_neg_neg_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_slice_and_neg_neg_in_place_either(&mut xs, &mut ys) = \\\n            {p:?}; xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_and_neg_neg_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let b = limbs_vec_and_neg_neg_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_vec_and_neg_neg_in_place_either(&mut xs, &mut ys) = \\\n            {b}; xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_integer_and_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x &= y.clone();\n        println!(\"x := {x_old}; x &= {y}; x = {x}\");\n    }\n}\n\nfn demo_integer_and_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x &= &y;\n        println!(\"x := {x_old}; x &= &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_and(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} & {} = {}\", x_old, y_old, x & y);\n    }\n}\n\nfn demo_integer_and_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} & &{} = {}\", x_old, y, x & &y);\n    }\n}\n\nfn demo_integer_and_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} & {} = {}\", x, y_old, &x & y);\n    }\n}\n\nfn demo_integer_and_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} & &{} = {}\", x, y, &x & &y);\n    }\n}\n\nfn benchmark_limbs_pos_and_limb_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_pos_and_limb_neg(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_pos_and_limb_neg(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_and_limb_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_pos_and_limb_neg_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            limbs_pos_and_limb_neg_to_out(&mut out, &xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_and_limb_neg_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_pos_and_limb_neg_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_pos_and_limb_neg_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_and_limb_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_and_limb_neg(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(limbs, limb)| {\n            no_out!(limbs_neg_and_limb_neg(&limbs, limb));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_and_limb_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_and_limb_neg_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_neg_and_limb_neg_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_neg_and_limb_neg_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_neg_and_limb_neg_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            no_out!(limbs_slice_neg_and_limb_neg_in_place(&mut xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_neg_and_limb_neg_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_neg_and_limb_neg_in_place(&Vec[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_vec_neg_and_limb_neg_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_and_pos_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_and_pos_neg(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys)| {\n            no_out!(limbs_and_pos_neg(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_and_pos_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_and_pos_neg_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_33().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut out, ref xs, ref ys)| {\n            limbs_and_pos_neg_to_out(out, xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_and_pos_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_and_pos_neg_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            limbs_and_pos_neg_in_place_left(xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_and_pos_neg_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_and_pos_neg_in_place_right(&[Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref mut ys)| {\n            limbs_slice_and_pos_neg_in_place_right(xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_and_pos_neg_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_and_pos_neg_in_place_right(&[Limb], &mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref mut ys)| {\n            limbs_vec_and_pos_neg_in_place_right(xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_and_neg_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_and_neg_neg(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys)| {\n            no_out!(limbs_and_neg_neg(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_and_neg_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_and_neg_neg_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_34().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut out, ref xs, ref ys)| {\n            no_out!(limbs_and_neg_neg_to_out(out, xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_and_neg_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_and_neg_neg_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            no_out!(limbs_slice_and_neg_neg_in_place_left(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_and_neg_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_and_neg_neg_in_place_left(&mut Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            no_out!(limbs_vec_and_neg_neg_in_place_left(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_and_neg_neg_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_and_neg_neg_in_place_either(&mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref mut ys)| {\n            no_out!(limbs_slice_and_neg_neg_in_place_either(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_and_neg_neg_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_and_neg_neg_in_place_either(&mut Vec<Limb>, &mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref mut ys)| {\n            no_out!(limbs_vec_and_neg_neg_in_place_either(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_integer_and_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer &= Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x &= y), (\"rug\", &mut |((mut x, y), _)| x &= y)],\n    );\n}\n\nfn benchmark_integer_and_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer &= Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer &= Integer\", &mut |(mut x, y)| no_out!(x &= y)),\n            (\"Integer &= &Integer\", &mut |(mut x, y)| no_out!(x &= &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_and_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer &= Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x & y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x & y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_and_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer & Integer\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(ref x, ref y)| no_out!(x & y)),\n            (\"using bits explicitly\", &mut |(ref x, ref y)| {\n                no_out!(integer_and_alt_1(x, y));\n            }),\n            (\"using limbs explicitly\", &mut |(ref x, ref y)| {\n                no_out!(integer_and_alt_2(x, y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_and_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer & Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer & Integer\", &mut |(x, y)| no_out!(x & y)),\n            (\"Integer & &Integer\", &mut |(x, y)| no_out!(x & &y)),\n            (\"&Integer & Integer\", &mut |(x, y)| no_out!(&x & y)),\n            (\"&Integer & &Integer\", &mut |(x, y)| no_out!(&x & &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/assign_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::pair_2_triple_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::generators::{\n    integer_unsigned_bool_triple_gen_var_1, integer_unsigned_bool_triple_gen_var_1_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_assign_bit);\n    register_bench!(runner, benchmark_integer_assign_bit_library_comparison);\n}\n\nfn demo_integer_assign_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index, bit) in integer_unsigned_bool_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.assign_bit(index, bit);\n        println!(\"x := {n_old}; x.assign_bit({index}, {bit}); x = {n}\");\n    }\n}\n\nfn benchmark_integer_assign_bit_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.assign_bit(u64, bool)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_bool_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_2_bucketer(\"index\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut n, index, bit))| {\n                n.assign_bit(index, bit);\n            }),\n            (\"rug\", &mut |((mut n, index, bit), _)| {\n                no_out!(n.set_bit(u32::exact_from(index), bit));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/assign_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::bench::bucketers::quadruple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::large_type_gen_var_4;\nuse malachite_base::test_util::num::logic::bit_block_access::assign_bits_naive;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_block_access::limbs_neg_assign_bits;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::integer_unsigned_unsigned_natural_quadruple_gen_var_1;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_neg_assign_bits);\n    register_demo!(runner, demo_integer_assign_bits);\n    register_bench!(runner, benchmark_limbs_neg_assign_bits);\n    register_bench!(runner, benchmark_integer_assign_bits_algorithms);\n}\n\nfn demo_limbs_neg_assign_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, start, end, bits) in large_type_gen_var_4().get(gm, config).take(limit) {\n        let old_xs = xs.clone();\n        limbs_neg_assign_bits(&mut xs, start, end, &bits);\n        println!(\n            \"xs := {old_xs:?}; \\\n            limbs_neg_assign_bits(&mut xs, {start}, {end}, &{bits:?}); limbs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_integer_assign_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, start, end, bits) in integer_unsigned_unsigned_natural_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n.clone();\n        n.assign_bits(start, end, &bits);\n        println!(\"n := {old_n}; n.assign_bits({start}, {end}, &{bits}); n = {n}\");\n    }\n}\n\nfn benchmark_limbs_neg_assign_bits(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_neg_assign_bits(&mut Vec<Limb>, u64, u64, &[Limb])\",\n        BenchmarkType::Single,\n        large_type_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_bucketer(\"end\"),\n        &mut [(\"limbs_neg_assign_bits\", &mut |(\n            ref mut limbs,\n            start,\n            end,\n            ref bits,\n        )| {\n            limbs_neg_assign_bits(limbs, start, end, bits);\n        })],\n    );\n}\n\nfn benchmark_integer_assign_bits_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.assign_bits(u64, u64, &Natural)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_unsigned_natural_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_bucketer(\"end\"),\n        &mut [\n            (\"default\", &mut |(mut n, start, end, bits)| {\n                n.assign_bits(start, end, &bits);\n            }),\n            (\"naive\", &mut |(mut n, start, end, bits)| {\n                assign_bits_naive::<Integer, Natural>(&mut n, start, end, &bits);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_unsigned_pair_gen_var_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_bits);\n    register_demo!(runner, demo_integer_bits_rev);\n    register_demo!(runner, demo_integer_bits_index);\n\n    register_bench!(runner, benchmark_integer_bits_get_algorithms);\n}\n\nfn demo_integer_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"bits({}) = {:?}\", n, n.bits().collect_vec());\n    }\n}\n\nfn demo_integer_bits_rev(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"bits({}).rev() = {:?}\", n, n.bits().rev().collect_vec());\n    }\n}\n\nfn demo_integer_bits_index(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, i) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"bits({})[{}] = {:?}\", n, i, n.bits()[i]);\n    }\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_integer_bits_get_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.bits()[u64]\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer.bits()[u]\", &mut |(n, u)| no_out!(n.bits()[u])),\n            (\"Integer.to_bits_asc()[u]\", &mut |(n, u)| {\n                let bits = n.to_bits_asc();\n                let u = usize::exact_from(u);\n                if u >= bits.len() {\n                    n < 0\n                } else {\n                    bits[u]\n                };\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/checked_count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::checked_count_ones::{\n    integer_checked_count_ones_alt_1, integer_checked_count_ones_alt_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_checked_count_ones);\n    register_bench!(runner, benchmark_integer_checked_count_ones_algorithms);\n}\n\nfn demo_integer_checked_count_ones(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"checked_count_ones({}) = {:?}\", n, n.checked_count_ones());\n    }\n}\n\nfn benchmark_integer_checked_count_ones_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.count_ones()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.checked_count_ones())),\n            (\"using bits explicitly\", &mut |n| {\n                no_out!(integer_checked_count_ones_alt_1(&n));\n            }),\n            (\"using limbs explicitly\", &mut |n| {\n                no_out!(integer_checked_count_ones_alt_2(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/checked_count_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_4;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::checked_count_zeros::limbs_count_zeros_neg;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::checked_count_zeros::{\n    integer_checked_count_zeros_alt_1, integer_checked_count_zeros_alt_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_count_zeros_neg);\n    register_demo!(runner, demo_integer_checked_count_zeros);\n\n    register_bench!(runner, benchmark_limbs_count_zeros_neg);\n    register_bench!(runner, benchmark_integer_checked_count_zeros_algorithms);\n}\n\nfn demo_limbs_count_zeros_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_4().get(gm, config).take(limit) {\n        println!(\n            \"limbs_count_zeros_neg({:?}) = {}\",\n            xs,\n            limbs_count_zeros_neg(&xs)\n        );\n    }\n}\n\nfn demo_integer_checked_count_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"checked_count_zeros({}) = {:?}\", n, n.checked_count_zeros());\n    }\n}\n\nfn benchmark_limbs_count_zeros_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_count_zeros_neg(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_count_zeros_neg(&xs)))],\n    );\n}\n\nfn benchmark_integer_checked_count_zeros_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.count_zeros()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.checked_count_zeros())),\n            (\"using bits explicitly\", &mut |n| {\n                no_out!(integer_checked_count_zeros_alt_1(&n));\n            }),\n            (\"using limbs explicitly\", &mut |n| {\n                no_out!(integer_checked_count_zeros_alt_2(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/checked_hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::CheckedHammingDistance;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_vec_max_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_8, unsigned_vec_unsigned_pair_gen_var_19,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::checked_hamming_distance::{\n    limbs_hamming_distance_limb_neg, limbs_hamming_distance_neg,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_rm};\nuse malachite_nz::test_util::integer::logic::checked_hamming_distance::rug_checked_hamming_distance;\nuse malachite_nz::test_util::integer::logic::checked_hamming_distance::{\n    integer_checked_hamming_distance_alt_1, integer_checked_hamming_distance_alt_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_hamming_distance_limb_neg);\n    register_demo!(runner, demo_limbs_hamming_distance_neg);\n    register_demo!(runner, demo_integer_checked_hamming_distance);\n\n    register_bench!(runner, benchmark_limbs_hamming_distance_limb_neg);\n    register_bench!(runner, benchmark_limbs_hamming_distance_neg);\n    register_bench!(\n        runner,\n        benchmark_integer_checked_hamming_distance_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_checked_hamming_distance_algorithms\n    );\n}\n\nfn demo_limbs_hamming_distance_limb_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_hamming_distance_limb_neg({:?}, {}) = {}\",\n            xs,\n            y,\n            limbs_hamming_distance_limb_neg(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_hamming_distance_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\n            \"limbs_hamming_distance_neg({:?}, {:?}) = {}\",\n            xs,\n            ys,\n            limbs_hamming_distance_neg(&xs, &ys)\n        );\n    }\n}\n\nfn demo_integer_checked_hamming_distance(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"checked_hamming_distance({}, {}) = {:?}\",\n            x,\n            y,\n            x.checked_hamming_distance(&y)\n        );\n    }\n}\n\nfn benchmark_limbs_hamming_distance_limb_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_hamming_distance_limb_neg(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_hamming_distance_limb_neg(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_hamming_distance_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_hamming_distance_neg(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys)| {\n            no_out!(limbs_hamming_distance_neg(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_integer_checked_hamming_distance_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.checked_hamming_distance(&Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.checked_hamming_distance(&y));\n            }),\n            (\"rug\", &mut |((x, y), _)| {\n                no_out!(rug_checked_hamming_distance(&x, &y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_checked_hamming_distance_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.checked_hamming_distance(&Integer)\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(n, other)| {\n                no_out!(n.checked_hamming_distance(&other));\n            }),\n            (\"using bits explicitly\", &mut |(n, other)| {\n                no_out!(integer_checked_hamming_distance_alt_1(&n, &other));\n            }),\n            (\"using limbs explicitly\", &mut |(n, other)| {\n                no_out!(integer_checked_hamming_distance_alt_2(&n, &other));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/clear_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_20;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::bit_access::{\n    limbs_slice_clear_bit_neg, limbs_vec_clear_bit_neg,\n};\nuse malachite_nz::test_util::bench::bucketers::pair_integer_bit_u64_max_bucketer;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\nuse malachite_nz::test_util::generators::unsigned_vec_unsigned_pair_gen_var_21;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_slice_clear_bit_neg);\n    register_demo!(runner, demo_limbs_vec_clear_bit_neg);\n    register_demo!(runner, demo_integer_clear_bit);\n\n    register_bench!(runner, benchmark_limbs_slice_clear_bit_neg);\n    register_bench!(runner, benchmark_limbs_vec_clear_bit_neg);\n    register_bench!(runner, benchmark_integer_clear_bit);\n}\n\nfn demo_limbs_slice_clear_bit_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, index) in unsigned_vec_unsigned_pair_gen_var_21()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_slice_clear_bit_neg(&mut xs, index);\n        println!(\"xs := {xs_old:?}; limbs_slice_clear_bit_neg(&mut xs, {index}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_vec_clear_bit_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, index) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        limbs_vec_clear_bit_neg(&mut xs, index);\n        println!(\"xs := {old_xs:?}; limbs_vec_clear_bit_neg(&mut xs, {index}); xs = {xs:?}\");\n    }\n}\n\nfn demo_integer_clear_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.clear_bit(index);\n        println!(\"x := {n_old}; x.clear_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_limbs_slice_clear_bit_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_clear_bit_neg(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_21().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut xs, index)| {\n            no_out!(limbs_slice_clear_bit_neg(&mut xs, index));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_clear_bit_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_clear_bit_neg(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut xs, index)| {\n            no_out!(limbs_vec_clear_bit_neg(&mut xs, index));\n        })],\n    );\n}\n\nfn benchmark_integer_clear_bit(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.clear_bit(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_bit_u64_max_bucketer(\"x\", \"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.clear_bit(index))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/flip_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_2_pair_integer_bit_u64_max_bucketer;\nuse malachite_nz::test_util::generators::{\n    integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_2_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_flip_bit);\n    register_bench!(runner, benchmark_integer_flip_bit_library_comparison);\n}\n\nfn demo_integer_flip_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.flip_bit(index);\n        println!(\"x := {n_old}; x.flip_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_integer_flip_bit_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.flip_bit(u64)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_bit_u64_max_bucketer(\"x\", \"index\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut n, index))| n.flip_bit(index)),\n            (\"rug\", &mut |((mut n, index), _)| {\n                no_out!(n.toggle_bit(u32::exact_from(index)));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitConvertible;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::bool_vec_gen;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    from_bits_asc_alt, from_bits_desc_alt,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::integer::logic::from_bits::{\n    from_bits_asc_naive, from_bits_desc_naive,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_from_bits_asc);\n    register_demo!(runner, demo_integer_from_bits_desc);\n\n    register_bench!(runner, benchmark_integer_from_bits_asc_algorithms);\n    register_bench!(runner, benchmark_integer_from_bits_desc_algorithms);\n}\n\nfn demo_integer_from_bits_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in bool_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_bits_asc({:?}) = {:?}\",\n            bits,\n            Integer::from_bits_asc(bits.iter().copied())\n        );\n    }\n}\n\nfn demo_integer_from_bits_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in bool_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_bits_desc({:?}) = {:?}\",\n            bits,\n            Integer::from_bits_desc(bits.iter().copied())\n        );\n    }\n}\n\nfn benchmark_integer_from_bits_asc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_bits_asc<I: Iterator<Item=bool>>(I)\",\n        BenchmarkType::Algorithms,\n        bool_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |bits| {\n                no_out!(Integer::from_bits_asc(bits.into_iter()));\n            }),\n            (\"alt\", &mut |bits| {\n                no_out!(from_bits_asc_alt::<Integer, _>(bits.into_iter()));\n            }),\n            (\"naive\", &mut |bits| {\n                no_out!(from_bits_asc_naive(bits.into_iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_from_bits_desc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::from_bits_desc<I: Iterator<Item=bool>>(I)\",\n        BenchmarkType::Algorithms,\n        bool_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |bits| {\n                no_out!(Integer::from_bits_desc(bits.into_iter()));\n            }),\n            (\"alt\", &mut |bits| {\n                no_out!(from_bits_desc_alt::<Integer, _>(bits.into_iter()));\n            }),\n            (\"naive\", &mut |bits| {\n                no_out!(from_bits_desc_naive(bits.into_iter()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/get_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::{pair_2_bucketer, pair_2_pair_2_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_18;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::bit_access::limbs_get_bit_neg;\nuse malachite_nz::test_util::generators::{\n    integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_2_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_get_bit_neg);\n    register_demo!(runner, demo_integer_get_bit);\n\n    register_bench!(runner, benchmark_limbs_get_bit_neg);\n    register_bench!(runner, benchmark_integer_get_bit_library_comparison);\n}\n\nfn demo_limbs_get_bit_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, index) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_get_bit_neg({:?}, {}) = {}\",\n            xs,\n            index,\n            limbs_get_bit_neg(&xs, index)\n        );\n    }\n}\n\nfn demo_integer_get_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, index) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"get_bit({}, {}) = {}\", n, index, n.get_bit(index));\n    }\n}\n\nfn benchmark_limbs_get_bit_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_get_bit_neg(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(xs, index)| {\n            no_out!(limbs_get_bit_neg(&xs, index));\n        })],\n    );\n}\n\nfn benchmark_integer_get_bit_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.get_bit(u64)\",\n        BenchmarkType::LibraryComparison,\n        integer_unsigned_pair_gen_var_2_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_2_bucketer(\"index\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, index))| {\n                no_out!(n.get_bit(index));\n            }),\n            (\"rug\", &mut |((n, index), _)| {\n                no_out!(n.get_bit(u32::exact_from(index)));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/get_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::bench::bucketers::{triple_1_vec_len_bucketer, triple_3_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_20, unsigned_vec_unsigned_unsigned_triple_gen_var_4,\n};\nuse malachite_base::test_util::num::logic::bit_block_access::get_bits_naive;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_block_access::{\n    limbs_neg_limb_get_bits, limbs_slice_neg_get_bits, limbs_vec_neg_get_bits,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::triple_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_unsigned_unsigned_triple_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_neg_limb_get_bits);\n    register_demo!(runner, demo_limbs_slice_neg_get_bits);\n    register_demo!(runner, demo_limbs_vec_neg_get_bits);\n    register_demo!(runner, demo_integer_get_bits);\n\n    register_bench!(runner, benchmark_limbs_neg_limb_get_bits);\n    register_bench!(runner, benchmark_limbs_neg_get_bits_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_get_bits_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_get_bits_algorithms);\n}\n\nfn demo_limbs_neg_limb_get_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, start, end) in unsigned_triple_gen_var_20().get(gm, config).take(limit) {\n        println!(\n            \"limbs_neg_limb_get_bits({}, {}, {}) = {:?}\",\n            x,\n            start,\n            end,\n            limbs_neg_limb_get_bits(x, start, end)\n        );\n    }\n}\n\nfn demo_limbs_slice_neg_get_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, start, end) in unsigned_vec_unsigned_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_slice_neg_get_bits({:?}, {}, {}) = {:?}\",\n            xs,\n            start,\n            end,\n            limbs_slice_neg_get_bits(&xs, start, end)\n        );\n    }\n}\n\nfn demo_limbs_vec_neg_get_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, start, end) in unsigned_vec_unsigned_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        println!(\n            \"limbs_vec_neg_get_bits({:?}, {}, {}) = {:?}\",\n            old_xs,\n            start,\n            end,\n            limbs_vec_neg_get_bits(xs, start, end)\n        );\n    }\n}\n\nfn demo_integer_get_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, start, end) in integer_unsigned_unsigned_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).get_bits({}, {}) = {}\",\n            n,\n            start,\n            end,\n            n.get_bits(start, end)\n        );\n    }\n}\n\nfn benchmark_limbs_neg_limb_get_bits(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_limb_get_bits(Limb, u64, u64)\",\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"end\"),\n        &mut [(\"limbs_neg_limb_get_bits\", &mut |(x, start, end)| {\n            no_out!(limbs_neg_limb_get_bits(x, start, end));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_get_bits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_get_bits(&[Limb], u64, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_slice_neg_get_bits\", &mut |(xs, start, end)| {\n                no_out!(limbs_slice_neg_get_bits(&xs, start, end));\n            }),\n            (\"limbs_vec_neg_get_bits\", &mut |(xs, start, end)| {\n                no_out!(limbs_vec_neg_get_bits(xs, start, end));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_get_bits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.get_bits(u64, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_unsigned_unsigned_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"get_bits\", &mut |(n, start, end)| {\n                no_out!(n.get_bits(start, end));\n            }),\n            (\"get_bits_owned\", &mut |(n, start, end)| {\n                no_out!(n.get_bits_owned(start, end));\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_get_bits_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.get_bits(u64, u64)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_unsigned_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, start, end)| {\n                no_out!(n.get_bits(start, end));\n            }),\n            (\"naive\", &mut |(n, start, end)| {\n                no_out!(get_bits_naive::<Integer, Natural>(&n, start, end));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitScan;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_20;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::bit_scan::limbs_index_of_next_false_bit_neg;\nuse malachite_nz::test_util::bench::bucketers::pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\nuse malachite_nz::test_util::integer::logic::index_of_next_false_bit::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_index_of_next_false_bit_neg);\n    register_demo!(runner, demo_integer_index_of_next_false_bit);\n\n    register_bench!(runner, benchmark_limbs_index_of_next_false_bit_neg);\n    register_bench!(runner, benchmark_integer_index_of_next_false_bit_algorithms);\n}\n\nfn demo_limbs_index_of_next_false_bit_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, u) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_index_of_next_false_bit_neg({:?}, {}) = {:?}\",\n            xs,\n            u,\n            limbs_index_of_next_false_bit_neg(&xs, u)\n        );\n    }\n}\n\nfn demo_integer_index_of_next_false_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"index_of_next_false_bit({}, {}) = {:?}\",\n            n,\n            u,\n            n.index_of_next_false_bit(u)\n        );\n    }\n}\n\nfn benchmark_limbs_index_of_next_false_bit_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_index_of_next_false_bit_neg(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, u)| {\n            no_out!(limbs_index_of_next_false_bit_neg(&xs, u));\n        })],\n    );\n}\n\n#[allow(clippy::needless_borrow)]\nfn benchmark_integer_index_of_next_false_bit_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.index_of_next_false_bit(u64)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(ref n, u)| {\n                no_out!(n.index_of_next_false_bit(u));\n            }),\n            (\"using bits explicitly\", &mut |(ref n, u)| {\n                no_out!(integer_index_of_next_false_bit_alt(&n, u));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitScan;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_20;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::bit_scan::limbs_index_of_next_true_bit_neg;\nuse malachite_nz::test_util::bench::bucketers::pair_1_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\nuse malachite_nz::test_util::integer::logic::index_of_next_true_bit::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_index_of_next_true_bit_neg);\n    register_demo!(runner, demo_integer_index_of_next_true_bit);\n\n    register_bench!(runner, benchmark_limbs_index_of_next_true_bit_neg);\n    register_bench!(runner, benchmark_integer_index_of_next_true_bit_algorithms);\n}\n\nfn demo_limbs_index_of_next_true_bit_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, u) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_index_of_next_true_bit_neg({:?}, {}) = {:?}\",\n            xs,\n            u,\n            limbs_index_of_next_true_bit_neg(&xs, u)\n        );\n    }\n}\n\nfn demo_integer_index_of_next_true_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"index_of_next_true_bit({}, {}) = {:?}\",\n            n,\n            u,\n            n.index_of_next_true_bit(u)\n        );\n    }\n}\n\nfn benchmark_limbs_index_of_next_true_bit_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_index_of_next_true_bit_neg(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, u)| {\n            no_out!(limbs_index_of_next_true_bit_neg(&xs, u));\n        })],\n    );\n}\n\nfn benchmark_integer_index_of_next_true_bit_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.index_of_next_true_bit(u64)\",\n        BenchmarkType::Algorithms,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_integer_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(ref n, u)| {\n                no_out!(n.index_of_next_true_bit(u));\n            }),\n            (\"using bits explicitly\", &mut |(ref n, u)| {\n                no_out!(integer_index_of_next_true_bit_alt(n, u));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_5;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_low_mask);\n    register_bench!(runner, benchmark_integer_low_mask);\n}\n\nfn demo_integer_low_mask(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"Integer::low_mask({}) = {}\", bits, Integer::low_mask(bits));\n    }\n}\n\nfn benchmark_integer_low_mask(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.low_mask(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |bits| no_out!(Integer::low_mask(bits)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    and::register(runner);\n    assign_bit::register(runner);\n    assign_bits::register(runner);\n    bits::register(runner);\n    checked_count_ones::register(runner);\n    checked_count_zeros::register(runner);\n    checked_hamming_distance::register(runner);\n    clear_bit::register(runner);\n    flip_bit::register(runner);\n    from_bits::register(runner);\n    get_bit::register(runner);\n    get_bits::register(runner);\n    index_of_next_false_bit::register(runner);\n    index_of_next_true_bit::register(runner);\n    low_mask::register(runner);\n    not::register(runner);\n    or::register(runner);\n    set_bit::register(runner);\n    significant_bits::register(runner);\n    to_bits::register(runner);\n    trailing_zeros::register(runner);\n    xor::register(runner);\n}\n\nmod and;\nmod assign_bit;\nmod assign_bits;\nmod bits;\nmod checked_count_ones;\nmod checked_count_zeros;\nmod checked_hamming_distance;\nmod clear_bit;\nmod flip_bit;\nmod from_bits;\nmod get_bit;\nmod get_bits;\nmod index_of_next_false_bit;\nmod index_of_next_true_bit;\nmod low_mask;\nmod not;\nmod or;\nmod set_bit;\nmod significant_bits;\nmod to_bits;\nmod trailing_zeros;\nmod xor;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/not.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::NotAssign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    integer_bit_bucketer, pair_2_integer_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_not_assign);\n    register_demo!(runner, demo_integer_not);\n    register_demo!(runner, demo_integer_not_ref);\n\n    register_bench!(runner, benchmark_integer_not_assign);\n    register_bench!(runner, benchmark_integer_not_library_comparison);\n    register_bench!(runner, benchmark_integer_not_evaluation_strategy);\n}\n\nfn demo_integer_not_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in integer_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.not_assign();\n        println!(\"n := {n_old}; n.not_assign(); n = {n}\");\n    }\n}\n\nfn demo_integer_not(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"!({}) = {}\", n.clone(), !n);\n    }\n}\n\nfn demo_integer_not_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"!(&{}) = {}\", n, !&n);\n    }\n}\n\nfn benchmark_integer_not_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.not_assign()\",\n        BenchmarkType::Single,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |mut n| n.not_assign())],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_not_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.not()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_integer_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(_, n)| no_out!(!n)), (\"rug\", &mut |(n, _)| no_out!(!n))],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_not_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.not()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [(\"!Integer\", &mut |n| no_out!(!n)), (\"!&Integer\", &mut |n| no_out!(!&n))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, triple_2_vec_len_bucketer, triple_3_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_8, unsigned_vec_triple_gen_var_33, unsigned_vec_triple_gen_var_35,\n    unsigned_vec_unsigned_pair_gen_var_18, unsigned_vec_unsigned_pair_gen_var_19,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::or::{\n    limbs_neg_or_limb, limbs_neg_or_limb_in_place, limbs_neg_or_limb_to_out, limbs_neg_or_neg_limb,\n    limbs_or_neg_neg, limbs_or_neg_neg_in_place_either, limbs_or_neg_neg_to_out, limbs_or_pos_neg,\n    limbs_or_pos_neg_in_place_right, limbs_or_pos_neg_to_out, limbs_pos_or_neg_limb,\n    limbs_slice_or_neg_neg_in_place_left, limbs_slice_or_pos_neg_in_place_left,\n    limbs_vec_or_neg_neg_in_place_left, limbs_vec_or_pos_neg_in_place_left,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_rm};\nuse malachite_nz::test_util::integer::logic::or::{integer_or_alt_1, integer_or_alt_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_neg_or_limb);\n    register_demo!(runner, demo_limbs_neg_or_limb_to_out);\n    register_demo!(runner, demo_limbs_neg_or_limb_in_place);\n    register_demo!(runner, demo_limbs_pos_or_neg_limb);\n    register_demo!(runner, demo_limbs_neg_or_neg_limb);\n    register_demo!(runner, demo_limbs_or_pos_neg);\n    register_demo!(runner, demo_limbs_or_pos_neg_to_out);\n    register_demo!(runner, demo_limbs_slice_or_pos_neg_in_place_left);\n    register_demo!(runner, demo_limbs_vec_or_pos_neg_in_place_left);\n    register_demo!(runner, demo_limbs_or_pos_neg_in_place_right);\n    register_demo!(runner, demo_limbs_or_neg_neg);\n    register_demo!(runner, demo_limbs_or_neg_neg_to_out);\n    register_demo!(runner, demo_limbs_slice_or_neg_neg_in_place_left);\n    register_demo!(runner, demo_limbs_vec_or_neg_neg_in_place_left);\n    register_demo!(runner, demo_limbs_or_neg_neg_in_place_either);\n    register_demo!(runner, demo_integer_or_assign);\n    register_demo!(runner, demo_integer_or_assign_ref);\n    register_demo!(runner, demo_integer_or);\n    register_demo!(runner, demo_integer_or_val_ref);\n    register_demo!(runner, demo_integer_or_ref_val);\n    register_demo!(runner, demo_integer_or_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_neg_or_limb);\n    register_bench!(runner, benchmark_limbs_neg_or_limb_to_out);\n    register_bench!(runner, benchmark_limbs_neg_or_limb_in_place);\n    register_bench!(runner, benchmark_limbs_pos_or_neg_limb);\n    register_bench!(runner, benchmark_limbs_neg_or_neg_limb);\n    register_bench!(runner, benchmark_limbs_or_pos_neg);\n    register_bench!(runner, benchmark_limbs_or_pos_neg_to_out);\n    register_bench!(runner, benchmark_limbs_slice_or_pos_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_vec_or_pos_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_or_pos_neg_in_place_right);\n    register_bench!(runner, benchmark_limbs_or_neg_neg);\n    register_bench!(runner, benchmark_limbs_or_neg_neg_to_out);\n    register_bench!(runner, benchmark_limbs_slice_or_neg_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_vec_or_neg_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_or_neg_neg_in_place_either);\n    register_bench!(runner, benchmark_integer_or_assign_library_comparison);\n    register_bench!(runner, benchmark_integer_or_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_or_library_comparison);\n    register_bench!(runner, benchmark_integer_or_algorithms);\n    register_bench!(runner, benchmark_integer_or_evaluation_strategy);\n}\n\nfn demo_limbs_neg_or_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_neg_or_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_neg_or_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_neg_or_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_neg_or_limb_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; limbs_neg_or_limb_to_out(&mut out, {xs:?}, {y}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_neg_or_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_neg_or_limb_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_neg_or_limb_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_pos_or_neg_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_pos_or_neg_limb({:?}, {}) = {}\",\n            xs,\n            y,\n            limbs_pos_or_neg_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_neg_or_neg_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_neg_or_neg_limb({:?}, {}) = {}\",\n            xs,\n            y,\n            limbs_neg_or_neg_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_or_pos_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\n            \"limbs_or_pos_neg({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_or_pos_neg(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_or_pos_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, ys, xs) in unsigned_vec_triple_gen_var_33().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_or_pos_neg_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; limbs_or_pos_neg_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_or_pos_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let out = limbs_slice_or_pos_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_or_pos_neg_in_place_left(&mut xs, {ys:?}) = {out}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_or_pos_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_vec_or_pos_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; limbs_vec_or_pos_neg_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_or_pos_neg_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let ys_old = ys.clone();\n        limbs_or_pos_neg_in_place_right(&xs, &mut ys);\n        println!(\n            \"ys := {xs:?}; \\\n            limbs_or_pos_neg_in_place_right({ys_old:?}, &mut ys); ys = {ys:?}\"\n        );\n    }\n}\n\nfn demo_limbs_or_neg_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\n            \"limbs_or_neg_neg({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_or_neg_neg(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_or_neg_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_35().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_or_neg_neg_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; limbs_or_neg_neg_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_or_neg_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_slice_or_neg_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; limbs_slice_or_neg_neg_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_or_neg_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_vec_or_neg_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; limbs_vec_or_neg_neg_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_or_neg_neg_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let b = limbs_or_neg_neg_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_or_neg_neg_in_place_either(&mut xs, &mut ys) = {b}; \\\n             xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_integer_or_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x |= y.clone();\n        println!(\"x := {x_old}; x |= {y}; x = {x}\");\n    }\n}\n\nfn demo_integer_or_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x |= &y;\n        println!(\"x := {x_old}; x |= &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_or(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} | {} = {}\", x_old, y_old, x | y);\n    }\n}\n\nfn demo_integer_or_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} | &{} = {}\", x_old, y, x | &y);\n    }\n}\n\nfn demo_integer_or_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} | {} = {}\", x, y_old, &x | y);\n    }\n}\n\nfn demo_integer_or_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} | &{} = {}\", x, y, &x | &y);\n    }\n}\n\nfn benchmark_limbs_neg_or_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_neg_or_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_neg_or_limb(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_or_limb_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_or_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            limbs_neg_or_limb_to_out(&mut out, &xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_or_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_or_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_neg_or_limb_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_or_neg_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_pos_or_neg_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_pos_or_neg_limb(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_or_neg_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_neg_or_neg_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_neg_or_neg_limb(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_or_pos_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_or_pos_neg(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys)| {\n            no_out!(limbs_or_pos_neg(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_or_pos_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_pos_neg_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_33().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, ys, xs)| {\n            limbs_or_pos_neg_to_out(&mut out, &xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_or_pos_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_or_pos_neg_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            no_out!(limbs_slice_or_pos_neg_in_place_left(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_or_pos_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_or_pos_neg_in_place_left(&Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            limbs_vec_or_pos_neg_in_place_left(xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_pos_neg_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_pos_neg_in_place_right(&[Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref mut ys)| {\n            limbs_or_pos_neg_in_place_right(xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_neg_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_or_neg_neg(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys)| {\n            no_out!(limbs_or_neg_neg(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_or_neg_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_neg_neg_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_35().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut out, ref xs, ref ys)| {\n            limbs_or_neg_neg_to_out(out, xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_or_neg_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_or_neg_neg_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            limbs_slice_or_neg_neg_in_place_left(xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_or_neg_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_or_neg_neg_in_place_left(&mut Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            limbs_vec_or_neg_neg_in_place_left(xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_neg_neg_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_neg_neg_in_place_either(&mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref mut ys)| {\n            no_out!(limbs_or_neg_neg_in_place_either(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_integer_or_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer |= Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x |= y), (\"rug\", &mut |((mut x, y), _)| x |= y)],\n    );\n}\n\nfn benchmark_integer_or_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer |= Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer |= Integer\", &mut |(mut x, y)| no_out!(x |= y)),\n            (\"Integer |= &Integer\", &mut |(mut x, y)| no_out!(x |= &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_or_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer | Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x | y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x | y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_or_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer | Integer\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(ref x, ref y)| no_out!(x | y)),\n            (\"using bits explicitly\", &mut |(ref x, ref y)| {\n                no_out!(integer_or_alt_1(x, y));\n            }),\n            (\"using limbs explicitly\", &mut |(ref x, ref y)| {\n                no_out!(integer_or_alt_2(x, y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_or_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer | Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Integer | Integer\", &mut |(x, y)| no_out!(x | y)),\n            (\"Integer | &Integer\", &mut |(x, y)| no_out!(x | &y)),\n            (\"&Integer | Integer\", &mut |(x, y)| no_out!(&x | y)),\n            (\"&Integer | &Integer\", &mut |(x, y)| no_out!(&x | &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/set_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_20;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::bit_access::limbs_set_bit_neg;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_set_bit_neg);\n    register_demo!(runner, demo_integer_set_bit);\n\n    register_bench!(runner, benchmark_limbs_set_bit_neg);\n    register_bench!(runner, benchmark_integer_set_bit);\n}\n\nfn demo_limbs_set_bit_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, index) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        limbs_set_bit_neg(&mut xs, index);\n        println!(\"xs := {old_xs:?}; limbs_set_bit_neg(&mut xs, {index}); xs = {xs:?}\");\n    }\n}\n\nfn demo_integer_set_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in integer_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.set_bit(index);\n        println!(\"x := {n_old}; x.set_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_limbs_set_bit_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_set_bit_neg(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut xs, index)| {\n            no_out!(limbs_set_bit_neg(&mut xs, index));\n        })],\n    );\n}\n\nfn benchmark_integer_set_bit(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Integer.set_bit(u64)\",\n        BenchmarkType::Single,\n        integer_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.set_bit(index))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_integer_bit_bucketer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_significant_bits);\n    register_bench!(\n        runner,\n        benchmark_integer_significant_bits_library_comparison\n    );\n}\n\nfn demo_integer_significant_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"significant_bits({}) = {}\", n, n.significant_bits());\n    }\n}\n\nfn benchmark_integer_significant_bits_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.significant_bits()\",\n        BenchmarkType::LibraryComparison,\n        integer_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.significant_bits())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.bits())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.significant_bits())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable};\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{bool_vec_gen, bool_vec_gen_var_5};\nuse malachite_base::test_util::num::logic::bit_convertible::{to_bits_asc_alt, to_bits_desc_alt};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::bit_convertible::{\n    bits_slice_to_twos_complement_bits_negative, bits_to_twos_complement_bits_non_negative,\n    bits_vec_to_twos_complement_bits_negative,\n};\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::to_bits::{to_bits_asc_naive, to_bits_desc_naive};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_bits_to_twos_complement_bits_non_negative);\n    register_demo!(runner, demo_bits_slice_to_twos_complement_bits_negative);\n    register_demo!(runner, demo_bits_vec_to_twos_complement_bits_negative);\n    register_demo!(runner, demo_integer_to_bits_asc);\n    register_demo!(runner, demo_integer_to_bits_desc);\n\n    register_bench!(runner, benchmark_bits_to_twos_complement_bits_non_negative);\n    register_bench!(\n        runner,\n        benchmark_bits_slice_to_twos_complement_bits_negative\n    );\n    register_bench!(runner, benchmark_bits_vec_to_twos_complement_bits_negative);\n    register_bench!(runner, benchmark_integer_to_bits_asc_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_to_bits_asc_algorithms);\n    register_bench!(runner, benchmark_integer_to_bits_desc_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_to_bits_desc_algorithms);\n}\n\nfn demo_bits_to_twos_complement_bits_non_negative(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut bits in bool_vec_gen().get(gm, config).take(limit) {\n        let old_bits = bits.clone();\n        bits_to_twos_complement_bits_non_negative(&mut bits);\n        println!(\n            \"bits := {old_bits:?}; \\\n            bits_to_twos_complement_bits_non_negative(&mut bits); bits = {bits:?}\",\n        );\n    }\n}\n\nfn demo_bits_slice_to_twos_complement_bits_negative(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut bits in bool_vec_gen().get(gm, config).take(limit) {\n        let old_bits = bits.clone();\n        let carry = bits_slice_to_twos_complement_bits_negative(&mut bits);\n        println!(\n            \"bits := {old_bits:?}; \\\n            bits_slice_to_twos_complement_bits_negative(&mut bits) = {carry}; bits = {bits:?}\",\n        );\n    }\n}\n\nfn demo_bits_vec_to_twos_complement_bits_negative(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut bits in bool_vec_gen_var_5().get(gm, config).take(limit) {\n        let old_bits = bits.clone();\n        bits_vec_to_twos_complement_bits_negative(&mut bits);\n        println!(\n            \"bits := {old_bits:?}; \\\n            bits_vec_to_twos_complement_bits_negative(&mut bits); bits = {bits:?}\",\n        );\n    }\n}\n\nfn demo_integer_to_bits_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"to_bits_asc({}) = {:?}\", n, n.to_bits_asc());\n    }\n}\n\nfn demo_integer_to_bits_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"to_bits_desc({}) = {:?}\", n, n.to_bits_desc());\n    }\n}\n\nfn benchmark_bits_to_twos_complement_bits_non_negative(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"bits_to_twos_complement_bits_non_negative(&mut [bool])\",\n        BenchmarkType::Single,\n        bool_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |mut bits| {\n            bits_to_twos_complement_bits_non_negative(&mut bits);\n        })],\n    );\n}\n\nfn benchmark_bits_slice_to_twos_complement_bits_negative(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"bits_slice_to_twos_complement_bits_negative(&mut [bool])\",\n        BenchmarkType::Single,\n        bool_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |mut bits| {\n            no_out!(bits_slice_to_twos_complement_bits_negative(&mut bits));\n        })],\n    );\n}\n\nfn benchmark_bits_vec_to_twos_complement_bits_negative(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"bits_vec_to_twos_complement_bits_negative(&mut [bool])\",\n        BenchmarkType::Single,\n        bool_vec_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |ref mut bits| {\n            bits_vec_to_twos_complement_bits_negative(bits);\n        })],\n    );\n}\n\nfn benchmark_integer_to_bits_asc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_bits_asc()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Integer.to_bits_asc()\", &mut |n| no_out!(n.to_bits_asc())),\n            (\"Integer.bits().collect_vec()\", &mut |n| {\n                no_out!(n.bits().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_to_bits_asc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_bits_asc()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.to_bits_asc())),\n            (\"alt\", &mut |n| no_out!(to_bits_asc_alt(&n))),\n            (\"naive\", &mut |n| no_out!(to_bits_asc_naive(&n))),\n        ],\n    );\n}\n\nfn benchmark_integer_to_bits_desc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_bits_desc()\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Integer.to_bits_desc()\", &mut |n| no_out!(n.to_bits_desc())),\n            (\"Integer.bits().rev().collect_vec()\", &mut |n| {\n                no_out!(n.bits().rev().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_to_bits_desc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.to_bits_desc()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.to_bits_desc())),\n            (\"alt\", &mut |n| no_out!(to_bits_desc_alt(&n))),\n            (\"naive\", &mut |n| no_out!(to_bits_desc_naive(&n))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::trailing_zeros::integer_trailing_zeros_alt;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_trailing_zeros);\n    register_bench!(runner, benchmark_integer_trailing_zeros_algorithms);\n}\n\nfn demo_integer_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"trailing_zeros({}) = {:?}\", n, n.trailing_zeros());\n    }\n}\n\nfn benchmark_integer_trailing_zeros_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.trailing_zeros()\",\n        BenchmarkType::Algorithms,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.trailing_zeros())),\n            (\"using bits explicitly\", &mut |n| {\n                no_out!(integer_trailing_zeros_alt(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_vec_max_len_bucketer, triple_2_3_vec_max_len_bucketer,\n    triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_8, unsigned_vec_triple_gen_var_34,\n    unsigned_vec_unsigned_pair_gen_var_15, unsigned_vec_unsigned_pair_gen_var_18,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::logic::xor::{\n    limbs_neg_xor_limb, limbs_neg_xor_limb_neg, limbs_neg_xor_limb_neg_in_place,\n    limbs_neg_xor_limb_neg_to_out, limbs_neg_xor_limb_to_out, limbs_pos_xor_limb_neg,\n    limbs_pos_xor_limb_neg_to_out, limbs_slice_neg_xor_limb_in_place,\n    limbs_slice_pos_xor_limb_neg_in_place, limbs_vec_neg_xor_limb_in_place,\n    limbs_vec_pos_xor_limb_neg_in_place, limbs_xor_neg_neg, limbs_xor_neg_neg_in_place_either,\n    limbs_xor_neg_neg_in_place_left, limbs_xor_neg_neg_to_out, limbs_xor_pos_neg,\n    limbs_xor_pos_neg_in_place_either, limbs_xor_pos_neg_in_place_left,\n    limbs_xor_pos_neg_in_place_right, limbs_xor_pos_neg_to_out,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_integer_max_bit_bucketer, pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{integer_pair_gen, integer_pair_gen_rm};\nuse malachite_nz::test_util::integer::logic::xor::{integer_xor_alt_1, integer_xor_alt_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_neg_xor_limb);\n    register_demo!(runner, demo_limbs_neg_xor_limb_to_out);\n    register_demo!(runner, demo_limbs_slice_neg_xor_limb_in_place);\n    register_demo!(runner, demo_limbs_vec_neg_xor_limb_in_place);\n    register_demo!(runner, demo_limbs_pos_xor_limb_neg);\n    register_demo!(runner, demo_limbs_pos_xor_limb_neg_to_out);\n    register_demo!(runner, demo_limbs_slice_pos_xor_limb_neg_in_place);\n    register_demo!(runner, demo_limbs_vec_pos_xor_limb_neg_in_place);\n    register_demo!(runner, demo_limbs_neg_xor_limb_neg);\n    register_demo!(runner, demo_limbs_neg_xor_limb_neg_to_out);\n    register_demo!(runner, demo_limbs_neg_xor_limb_neg_in_place);\n    register_demo!(runner, demo_limbs_xor_pos_neg);\n    register_demo!(runner, demo_limbs_xor_pos_neg_to_out);\n    register_demo!(runner, demo_limbs_xor_pos_neg_in_place_left);\n    register_demo!(runner, demo_limbs_xor_pos_neg_in_place_right);\n    register_demo!(runner, demo_limbs_xor_pos_neg_in_place_either);\n    register_demo!(runner, demo_limbs_xor_neg_neg);\n    register_demo!(runner, demo_limbs_xor_neg_neg_to_out);\n    register_demo!(runner, demo_limbs_xor_neg_neg_in_place_left);\n    register_demo!(runner, demo_limbs_xor_neg_neg_in_place_either);\n    register_demo!(runner, demo_integer_xor_assign);\n    register_demo!(runner, demo_integer_xor_assign_ref);\n    register_demo!(runner, demo_integer_xor);\n    register_demo!(runner, demo_integer_xor_val_ref);\n    register_demo!(runner, demo_integer_xor_ref_val);\n    register_demo!(runner, demo_integer_xor_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_neg_xor_limb);\n    register_bench!(runner, benchmark_limbs_neg_xor_limb_to_out);\n    register_bench!(runner, benchmark_limbs_slice_neg_xor_limb_in_place);\n    register_bench!(runner, benchmark_limbs_vec_neg_xor_limb_in_place);\n    register_bench!(runner, benchmark_limbs_pos_xor_limb_neg);\n    register_bench!(runner, benchmark_limbs_pos_xor_limb_neg_to_out);\n    register_bench!(runner, benchmark_limbs_slice_pos_xor_limb_neg_in_place);\n    register_bench!(runner, benchmark_limbs_vec_pos_xor_limb_neg_in_place);\n    register_bench!(runner, benchmark_limbs_neg_xor_limb_neg);\n    register_bench!(runner, benchmark_limbs_neg_xor_limb_neg_to_out);\n    register_bench!(runner, benchmark_limbs_neg_xor_limb_neg_in_place);\n    register_bench!(runner, benchmark_limbs_xor_pos_neg);\n    register_bench!(runner, benchmark_limbs_xor_pos_neg_to_out);\n    register_bench!(runner, benchmark_limbs_xor_pos_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_xor_pos_neg_in_place_right);\n    register_bench!(runner, benchmark_limbs_xor_pos_neg_in_place_either);\n    register_bench!(runner, benchmark_limbs_xor_neg_neg);\n    register_bench!(runner, benchmark_limbs_xor_neg_neg_to_out);\n    register_bench!(runner, benchmark_limbs_xor_neg_neg_in_place_left);\n    register_bench!(runner, benchmark_limbs_xor_neg_neg_in_place_either);\n    register_bench!(runner, benchmark_integer_xor_assign_library_comparison);\n    register_bench!(runner, benchmark_integer_xor_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_integer_xor_library_comparison);\n    register_bench!(runner, benchmark_integer_xor_algorithms);\n    register_bench!(runner, benchmark_integer_xor_evaluation_strategy);\n}\n\nfn demo_limbs_neg_xor_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_neg_xor_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_neg_xor_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_neg_xor_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let carry = limbs_neg_xor_limb_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_neg_xor_limb_to_out(&mut out, {xs:?}, {y}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_neg_xor_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_neg_xor_limb_in_place(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_neg_xor_limb_in_place(&mut xs, {y}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_neg_xor_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_neg_xor_limb_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_vec_neg_xor_limb_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_pos_xor_limb_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_pos_xor_limb_neg({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_pos_xor_limb_neg(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_pos_xor_limb_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let carry = limbs_pos_xor_limb_neg_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_pos_xor_limb_neg_to_out(&mut out, {xs:?}, {y}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_pos_xor_limb_neg_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_pos_xor_limb_neg_in_place(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_pos_xor_limb_neg_in_place(&mut xs, {y}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_pos_xor_limb_neg_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_pos_xor_limb_neg_in_place(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; limbs_vec_pos_xor_limb_neg_in_place(&mut xs, {y}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_neg_xor_limb_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_neg_xor_limb_neg({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_neg_xor_limb_neg(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_neg_xor_limb_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_neg_xor_limb_neg_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_neg_xor_limb_neg_to_out(&mut out, {xs:?}, {y}) = out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_neg_xor_limb_neg_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_neg_xor_limb_neg_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_neg_xor_limb_neg_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_xor_pos_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\n            \"limbs_xor_pos_neg({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_xor_pos_neg(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_xor_pos_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_34().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let carry = limbs_xor_pos_neg_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_xor_pos_neg_to_out(&mut out, {xs:?}, {ys:?}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_xor_pos_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_xor_pos_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_xor_pos_neg_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\"\n        );\n    }\n}\n\nfn demo_limbs_xor_pos_neg_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let ys_old = ys.clone();\n        limbs_xor_pos_neg_in_place_right(&xs, &mut ys);\n        println!(\n            \"ys := {xs:?}; limbs_xor_pos_neg_in_place_right({ys_old:?}, &mut ys); ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_xor_pos_neg_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let b = limbs_xor_pos_neg_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_xor_pos_neg_in_place_either(&mut xs, &mut ys) = {b}; \\\n            xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_xor_neg_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\n            \"limbs_xor_neg_neg({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_xor_neg_neg(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_xor_neg_neg_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_34().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_xor_neg_neg_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_xor_neg_neg_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_xor_neg_neg_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_xor_neg_neg_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_xor_neg_neg_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\"\n        );\n    }\n}\n\nfn demo_limbs_xor_neg_neg_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_8().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let b = limbs_xor_neg_neg_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_xor_neg_neg_in_place_either(&mut xs, &mut ys) = {b}; \\\n            xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_integer_xor_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x ^= y.clone();\n        println!(\"x := {x_old}; x ^= {y}; x = {x}\");\n    }\n}\n\nfn demo_integer_xor_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x ^= &y;\n        println!(\"x := {x_old}; x ^= &{y}; x = {x}\");\n    }\n}\n\nfn demo_integer_xor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} ^ {} = {}\", x_old, y_old, x ^ y);\n    }\n}\n\nfn demo_integer_xor_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} ^ &{} = {}\", x_old, y, x ^ &y);\n    }\n}\n\nfn demo_integer_xor_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} ^ {} = {}\", x, y_old, &x ^ y);\n    }\n}\n\nfn demo_integer_xor_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in integer_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} ^ &{} = {}\", x, y, &x ^ &y);\n    }\n}\n\nfn benchmark_limbs_neg_xor_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_neg_xor_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_neg_xor_limb(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_xor_limb_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_xor_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_neg_xor_limb_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_neg_xor_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_slice_xor_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            no_out!(limbs_slice_neg_xor_limb_in_place(&mut xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_neg_xor_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_vec_xor_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_vec_neg_xor_limb_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_xor_limb_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_pos_xor_limb_neg(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_pos_xor_limb_neg(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_pos_xor_limb_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_pos_xor_limb_neg_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_pos_xor_limb_neg_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_pos_xor_limb_neg_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_pos_xor_limb_neg_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            no_out!(limbs_slice_pos_xor_limb_neg_in_place(&mut xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_pos_xor_limb_neg_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_pos_xor_limb_neg_in_place(&Vec[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_vec_pos_xor_limb_neg_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_xor_limb_neg(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_xor_limb_neg(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_neg_xor_limb_neg(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_xor_limb_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_xor_limb_neg_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_neg_xor_limb_neg_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_xor_limb_neg_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_xor_limb_neg_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_neg_xor_limb_neg_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_pos_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_xor_pos_neg(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys)| {\n            no_out!(limbs_xor_pos_neg(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_pos_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_pos_neg_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_34().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref mut out, ref xs, ref ys)| {\n            no_out!(limbs_xor_pos_neg_to_out(out, xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_pos_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_pos_neg_in_place_left(&mut Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            no_out!(limbs_xor_pos_neg_in_place_left(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_pos_neg_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_pos_neg_in_place_right(&[Limb], &mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref mut ys)| {\n            no_out!(limbs_xor_pos_neg_in_place_right(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_pos_neg_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_pos_neg_in_place_either(&mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref mut ys)| {\n            no_out!(limbs_xor_pos_neg_in_place_either(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_neg_neg(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_xor_neg_neg(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys)| {\n            no_out!(limbs_xor_neg_neg(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_neg_neg_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_neg_neg_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_34().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref mut out, ref xs, ref ys)| {\n            limbs_xor_neg_neg_to_out(out, xs, ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_neg_neg_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_neg_neg_in_place_left(&mut Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys)| {\n            no_out!(limbs_xor_neg_neg_in_place_left(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_neg_neg_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_neg_neg_in_place_either(&mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref mut ys)| {\n            no_out!(limbs_xor_neg_neg_in_place_either(xs, ys));\n        })],\n    );\n}\n\nfn benchmark_integer_xor_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer ^= Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x ^= y), (\"rug\", &mut |((mut x, y), _)| x ^= y)],\n    );\n}\n\nfn benchmark_integer_xor_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer ^= Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"Integer ^= Integer\", &mut |(mut x, y)| no_out!(x ^= y)),\n            (\"Integer ^= &Integer\", &mut |(mut x, y)| no_out!(x ^= &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_xor_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer ^ Integer\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_integer_max_bit_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x ^ y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x ^ y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_xor_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer ^ Integer\",\n        BenchmarkType::Algorithms,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"default\", &mut |(ref x, ref y)| no_out!(x ^ y)),\n            (\"using bits explicitly\", &mut |(ref x, ref y)| {\n                no_out!(integer_xor_alt_1(x, y));\n            }),\n            (\"using limbs explicitly\", &mut |(ref x, ref y)| {\n                no_out!(integer_xor_alt_2(x, y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_integer_xor_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer ^ Integer\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"Integer ^ Integer\", &mut |(x, y)| no_out!(x ^ y)),\n            (\"Integer ^ &Integer\", &mut |(x, y)| no_out!(x ^ &y)),\n            (\"&Integer ^ Integer\", &mut |(x, y)| no_out!(&x ^ y)),\n            (\"&Integer ^ &Integer\", &mut |(x, y)| no_out!(&x ^ &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/integer/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    arithmetic::register(runner);\n    basic::register(runner);\n    comparison::register(runner);\n    conversion::register(runner);\n    logic::register(runner);\n}\n\nmod arithmetic;\nmod basic;\nmod comparison;\nmod conversion;\nmod logic;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\nmacro_rules! natural_signed_single_arg_demo_with_trait {\n    ($name: ident, $f: ident, $gen: ident, $tr: ident) => {\n        fn $name<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\n        where\n            Natural: $tr<T>,\n        {\n            for x in $gen::<T>().get(gm, config).take(limit) {\n                println!(\n                    concat!(\"Natural::\", stringify!($f), \"({}) = {}\"),\n                    x,\n                    Natural::$f(x)\n                );\n            }\n        }\n    };\n}\n\nmacro_rules! natural_signed_single_arg_bench_with_trait {\n    ($name: ident, $f: ident, $gen: ident, $tr: ident) => {\n        fn $name<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str)\n        where\n            Natural: $tr<T>,\n        {\n            run_benchmark(\n                &format!(concat!(\"Natural::\", stringify!($f), \"({})\"), T::NAME),\n                BenchmarkType::Single,\n                $gen::<T>().get(gm, config),\n                gm.name(),\n                limit,\n                file_name,\n                &signed_bit_bucketer(),\n                &mut [(\"Malachite\", &mut |x| no_out!(Natural::$f(x)))],\n            );\n        }\n    };\n}\n\npub(crate) fn register(runner: &mut Runner) {\n    integer::register(runner);\n    natural::register(runner);\n}\n\nmod integer;\nmod natural;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AbsDiff, AbsDiffAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_abs_diff);\n    register_demo!(runner, demo_natural_abs_diff_val_ref);\n    register_demo!(runner, demo_natural_abs_diff_ref_val);\n    register_demo!(runner, demo_natural_abs_diff_ref_ref);\n    register_demo!(runner, demo_natural_abs_diff_assign);\n    register_demo!(runner, demo_natural_abs_diff_assign_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_abs_diff_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_abs_diff_evaluation_strategy);\n}\n\nfn demo_natural_abs_diff(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"|{} - {}| = {:?}\", x_old, y_old, x.abs_diff(y));\n    }\n}\n\nfn demo_natural_abs_diff_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"|{} - &{}| = {:?}\", x_old, y, x.abs_diff(&y));\n    }\n}\n\nfn demo_natural_abs_diff_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"|&{} - {}| = {:?}\", x, y_old, (&x).abs_diff(y));\n    }\n}\n\nfn demo_natural_abs_diff_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"|&{} - &{}| = {:?}\", x, y, (&x).abs_diff(&y));\n    }\n}\n\nfn demo_natural_abs_diff_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.abs_diff_assign(y);\n        println!(\"x := {x_old}; x.abs_diff_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_abs_diff_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.abs_diff_assign(&y);\n        println!(\"x := {x_old}; x.abs_diff_assign(&{y}); x = {x}\");\n    }\n}\n\nfn benchmark_natural_abs_diff_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.abs_diff_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.abs_diff_assign(Natural)\", &mut |(mut x, y)| {\n                x.abs_diff_assign(y);\n            }),\n            (\"Natural.abs_diff_assign(&Natural)\", &mut |(mut x, y)| {\n                x.abs_diff_assign(&y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_abs_diff_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.abs_diff(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.abs_diff(Natural)\", &mut |(x, y)| {\n                no_out!(x.abs_diff(y));\n            }),\n            (\"Natural.abs_diff(&Natural)\", &mut |(x, y)| {\n                no_out!(x.abs_diff(&y));\n            }),\n            (\"&Natural.abs_diff(Natural)\", &mut |(x, y)| {\n                no_out!((&x).abs_diff(y));\n            }),\n            (\"&Natural.abs_diff(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).abs_diff(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_vec_max_len_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen, unsigned_vec_pair_gen_var_1, unsigned_vec_pair_gen_var_6,\n    unsigned_vec_triple_gen_var_31, unsigned_vec_triple_gen_var_32, unsigned_vec_triple_gen_var_40,\n    unsigned_vec_unsigned_pair_gen, unsigned_vec_unsigned_pair_gen_var_15,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::add::{\n    limbs_add, limbs_add_greater, limbs_add_greater_to_out, limbs_add_limb, limbs_add_limb_to_out,\n    limbs_add_same_length_to_out, limbs_add_to_out, limbs_add_to_out_aliased,\n    limbs_slice_add_greater_in_place_left, limbs_slice_add_in_place_either,\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n    limbs_vec_add_in_place_either, limbs_vec_add_in_place_left, limbs_vec_add_limb_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n    triple_3_pair_natural_max_bit_bucketer, triple_3_vec_natural_sum_bits_bucketer,\n    vec_natural_sum_bits_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_pair_gen_nrm, natural_pair_gen_rm, natural_vec_gen,\n    natural_vec_gen_nrm,\n};\nuse malachite_nz::test_util::natural::arithmetic::add::natural_sum_alt;\nuse num::BigUint;\nuse std::iter::Sum;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_add_limb);\n    register_demo!(runner, demo_limbs_add_limb_to_out);\n    register_demo!(runner, demo_limbs_slice_add_limb_in_place);\n    register_demo!(runner, demo_limbs_vec_add_limb_in_place);\n    register_demo!(runner, demo_limbs_add_greater);\n    register_demo!(runner, demo_limbs_add);\n    register_demo!(runner, demo_limbs_add_same_length_to_out);\n    register_demo!(runner, demo_limbs_add_greater_to_out);\n    register_demo!(runner, demo_limbs_add_to_out);\n    register_demo!(runner, demo_limbs_add_to_out_aliased);\n    register_demo!(runner, demo_limbs_slice_add_same_length_in_place_left);\n    register_demo!(runner, demo_limbs_slice_add_greater_in_place_left);\n    register_demo!(runner, demo_limbs_vec_add_in_place_left);\n    register_demo!(runner, demo_limbs_slice_add_in_place_either);\n    register_demo!(runner, demo_limbs_vec_add_in_place_either);\n    register_demo!(runner, demo_natural_add_assign);\n    register_demo!(runner, demo_natural_add_assign_ref);\n    register_demo!(runner, demo_natural_add);\n    register_demo!(runner, demo_natural_add_val_ref);\n    register_demo!(runner, demo_natural_add_ref_val);\n    register_demo!(runner, demo_natural_add_ref_ref);\n    register_demo!(runner, demo_natural_sum);\n    register_demo!(runner, demo_natural_ref_sum);\n\n    register_bench!(runner, benchmark_limbs_add_limb);\n    register_bench!(runner, benchmark_limbs_add_limb_to_out);\n    register_bench!(runner, benchmark_limbs_slice_add_limb_in_place);\n    register_bench!(runner, benchmark_limbs_vec_add_limb_in_place);\n    register_bench!(runner, benchmark_limbs_add_greater);\n    register_bench!(runner, benchmark_limbs_add);\n    register_bench!(runner, benchmark_limbs_add_same_length_to_out);\n    register_bench!(runner, benchmark_limbs_add_greater_to_out);\n    register_bench!(runner, benchmark_limbs_add_to_out);\n    register_bench!(runner, benchmark_limbs_add_to_out_aliased);\n    register_bench!(runner, benchmark_limbs_slice_add_same_length_in_place_left);\n    register_bench!(runner, benchmark_limbs_slice_add_greater_in_place_left);\n    register_bench!(runner, benchmark_limbs_vec_add_in_place_left);\n    register_bench!(runner, benchmark_limbs_slice_add_in_place_either);\n    register_bench!(runner, benchmark_limbs_vec_add_in_place_either);\n    register_bench!(runner, benchmark_natural_add_assign_library_comparison);\n    register_bench!(runner, benchmark_natural_add_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_add_library_comparison);\n    register_bench!(runner, benchmark_natural_add_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_sum_algorithms);\n    register_bench!(runner, benchmark_natural_sum_library_comparison);\n    register_bench!(runner, benchmark_natural_sum_evaluation_strategy);\n}\n\nfn demo_limbs_add_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"limbs_add_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_add_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_add_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let carry = limbs_add_limb_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_add_limb_to_out(&mut out, {xs:?}, {y}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_add_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen::<Limb, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_add_limb_in_place(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; limbs_slice_add_limb_in_place(&mut xs, {y}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_add_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_add_limb_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_vec_add_limb_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_add_greater(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_add_greater({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_add_greater(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        println!(\"limbs_add({:?}, {:?}) = {:?}\", xs, ys, limbs_add(&xs, &ys));\n    }\n}\n\nfn demo_limbs_add_same_length_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_31().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let carry = limbs_add_same_length_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_add_same_length_to_out(&mut out, {xs:?}, {ys:?}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_add_greater_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_40().get(gm, config).take(limit) {\n        let out_old = xs.clone();\n        let carry = limbs_add_greater_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_add_greater_to_out(&mut out, {xs:?}, {ys:?}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_add_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_32().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let carry = limbs_add_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_add_to_out(&mut out, {xs:?}, {ys:?}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_add_to_out_aliased(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys, xs_len) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_add_to_out_aliased(&mut xs, xs_len, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_add_to_out_aliased(&mut xs, {xs_len}, {ys:?}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_add_same_length_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_add_same_length_in_place_left::<Limb>(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_add_same_length_in_place_left(&mut xs, {ys:?}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_add_greater_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_1().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_add_greater_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_add_greater_in_place_left(&mut xs, {ys:?}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_add_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_vec_add_in_place_left(&mut xs, &ys);\n        println!(\"xs := {xs_old:?}; limbs_vec_add_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_slice_add_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let result = limbs_slice_add_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_slice_add_in_place_either(&mut xs, &mut ys) = {result:?}; \\\n            xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_add_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_vec_add_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_vec_add_in_place_either(&mut xs, &mut ys) = {right}; \\\n             xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_natural_add_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\"x := {x_old}; x += {y}; x = {x}\");\n    }\n}\n\nfn demo_natural_add_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\"x := {x_old}; x += &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_natural_add_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} + &{} = {}\", x_old, y, x + &y);\n    }\n}\n\nfn demo_natural_add_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} + {} = {}\", x, y_old, &x + y);\n    }\n}\n\nfn demo_natural_add_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} + &{} = {}\", x, y, &x + &y);\n    }\n}\n\nfn demo_natural_sum(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in natural_vec_gen().get(gm, config).take(limit) {\n        println!(\"sum({:?}) = {}\", xs.clone(), Natural::sum(xs.into_iter()));\n    }\n}\n\nfn demo_natural_ref_sum(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in natural_vec_gen().get(gm, config).take(limit) {\n        println!(\"sum({:?}) = {}\", xs, Natural::sum(xs.iter()));\n    }\n}\n\nfn benchmark_limbs_add_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_add_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_add_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_limbs_add_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_add_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_add_limb_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_add_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_add_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen::<Limb, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            no_out!(limbs_slice_add_limb_in_place(&mut xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_add_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_add_limb_in_place(&mut Vec<Limb>, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_vec_add_limb_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_add_greater(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_add_greater(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_add_greater(&xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_add(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_add(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(limbs_add(&xs, &ys)))],\n    );\n}\n\nfn benchmark_limbs_add_same_length_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_add_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            no_out!(limbs_add_same_length_to_out(&mut out, &xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_add_greater_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_add_greater_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_40().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            no_out!(limbs_add_greater_to_out(&mut out, &xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_add_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_add_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_32().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            no_out!(limbs_add_to_out(&mut out, &xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_add_to_out_aliased(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_add_to_out_aliased(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys, xs_len)| {\n            no_out!(limbs_add_to_out_aliased(&mut xs, xs_len, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_add_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_add_same_length_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            no_out!(limbs_slice_add_same_length_in_place_left::<Limb>(\n                &mut xs, &ys\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_add_greater_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_add_greater_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            no_out!(limbs_slice_add_greater_in_place_left(&mut xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_add_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_add_in_place_left(&mut Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            no_out!(limbs_vec_add_in_place_left(&mut xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_add_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_add_in_place_either(&mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            no_out!(limbs_slice_add_in_place_either(&mut xs, &mut ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_add_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_add_in_place_either(&mut Vec<Limb>, &mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            no_out!(limbs_vec_add_in_place_either(&mut xs, &mut ys));\n        })],\n    );\n}\n\nfn benchmark_natural_add_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural += Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x += y), (\"rug\", &mut |((mut x, y), _)| x += y)],\n    );\n}\n\nfn benchmark_natural_add_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural += Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural += Natural\", &mut |(mut x, y)| no_out!(x += y)),\n            (\"Natural += &Natural\", &mut |(mut x, y)| no_out!(x += &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_add_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural + Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x + y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x + y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x + y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_add_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural + Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural + Natural\", &mut |(x, y)| no_out!(x + y)),\n            (\"Natural + &Natural\", &mut |(x, y)| no_out!(x + &y)),\n            (\"&Natural + Natural\", &mut |(x, y)| no_out!(&x + y)),\n            (\"&Natural + &Natural\", &mut |(x, y)| no_out!(&x + &y)),\n        ],\n    );\n}\n\nfn benchmark_natural_sum_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::sum(Iterator<Item=Natural>)\",\n        BenchmarkType::LibraryComparison,\n        natural_vec_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, xs)| {\n                no_out!(Natural::sum(xs.into_iter()));\n            }),\n            (\"num\", &mut |(xs, _, _)| {\n                no_out!(BigUint::sum(xs.into_iter()));\n            }),\n            (\"rug\", &mut |(_, xs, _)| {\n                no_out!(rug::Integer::sum(xs.iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_sum_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::sum(Iterator<Item=Natural>)\",\n        BenchmarkType::Algorithms,\n        natural_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |xs| no_out!(Natural::sum(xs.into_iter()))),\n            (\"alt\", &mut |xs| no_out!(natural_sum_alt(xs.into_iter()))),\n        ],\n    );\n}\n\nfn benchmark_natural_sum_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::sum(Iterator<Item=Natural>)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\"Natural::sum(Iterator<Item=Natural>)\", &mut |xs| {\n                no_out!(Natural::sum(xs.into_iter()));\n            }),\n            (\"Natural::sum(Iterator<Item=&Natural>)\", &mut |xs| {\n                no_out!(Natural::sum(xs.iter()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AddMul, AddMulAssign};\nuse malachite_base::test_util::bench::bucketers::{\n    triple_1_2_vec_max_len_bucketer, triple_vec_max_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_triple_gen_var_41, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::add_mul::{\n    limbs_add_mul, limbs_add_mul_in_place_left, limbs_add_mul_limb,\n    limbs_slice_add_mul_limb_same_length_in_place_left,\n    limbs_slice_add_mul_limb_same_length_in_place_right, limbs_vec_add_mul_limb_in_place_either,\n    limbs_vec_add_mul_limb_in_place_left, limbs_vec_add_mul_limb_in_place_right,\n};\nuse malachite_nz::test_util::bench::bucketers::triple_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_triple_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_add_mul_limb);\n    register_demo!(\n        runner,\n        demo_limbs_slice_add_mul_limb_same_length_in_place_left\n    );\n    register_demo!(\n        runner,\n        demo_limbs_slice_add_mul_limb_same_length_in_place_right\n    );\n    register_demo!(runner, demo_limbs_vec_add_mul_limb_in_place_left);\n    register_demo!(runner, demo_limbs_vec_add_mul_limb_in_place_right);\n    register_demo!(runner, demo_limbs_vec_add_mul_limb_in_place_either);\n    register_demo!(runner, demo_limbs_add_mul);\n    register_demo!(runner, demo_limbs_add_mul_in_place_left);\n    register_demo!(runner, demo_natural_add_mul_assign);\n    register_demo!(runner, demo_natural_add_mul_assign_val_ref);\n    register_demo!(runner, demo_natural_add_mul_assign_ref_val);\n    register_demo!(runner, demo_natural_add_mul_assign_ref_ref);\n    register_demo!(runner, demo_natural_add_mul);\n    register_demo!(runner, demo_natural_add_mul_val_val_ref);\n    register_demo!(runner, demo_natural_add_mul_val_ref_val);\n    register_demo!(runner, demo_natural_add_mul_val_ref_ref);\n    register_demo!(runner, demo_natural_add_mul_ref_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_add_mul_limb);\n    register_bench!(\n        runner,\n        benchmark_limbs_slice_add_mul_limb_same_length_in_place_left\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_slice_add_mul_limb_same_length_in_place_right\n    );\n    register_bench!(runner, benchmark_limbs_vec_add_mul_limb_in_place_left);\n    register_bench!(runner, benchmark_limbs_vec_add_mul_limb_in_place_right);\n    register_bench!(runner, benchmark_limbs_vec_add_mul_limb_in_place_either);\n    register_bench!(runner, benchmark_limbs_add_mul);\n    register_bench!(runner, benchmark_limbs_add_mul_in_place_left);\n    register_bench!(runner, benchmark_natural_add_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_add_mul_assign_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_assign_val_ref_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_assign_ref_val_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_assign_ref_ref_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_evaluation_stategy);\n    register_bench!(runner, benchmark_natural_add_mul_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_val_val_ref_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_val_ref_val_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_val_ref_ref_algorithms);\n    register_bench!(runner, benchmark_natural_add_mul_ref_ref_ref_algorithms);\n}\n\nfn demo_limbs_add_mul_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_add_mul_limb({:?}, {:?}, {}) = {:?}\",\n            a,\n            b,\n            c,\n            limbs_add_mul_limb(&a, &b, c),\n        );\n    }\n}\n\nfn demo_limbs_slice_add_mul_limb_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut a, b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12()\n        .get(gm, config)\n        .take(limit)\n    {\n        let a_old = a.clone();\n        let carry = limbs_slice_add_mul_limb_same_length_in_place_left(&mut a, &b, c);\n        println!(\n            \"a := {a_old:?}; \\\n            limbs_slice_add_mul_limb_same_length_in_place_left(&mut a, {b:?}, {c}) = {carry}; \\\n             a = {a:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_add_mul_limb_same_length_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (a, mut b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12()\n        .get(gm, config)\n        .take(limit)\n    {\n        let b_old = b.clone();\n        let carry = limbs_slice_add_mul_limb_same_length_in_place_right(&a, &mut b, c);\n        println!(\n            \"b := {b_old:?}; \\\n            limbs_slice_add_mul_limb_same_length_in_place_right({a:?}, &mut b, {c}) \\\n             = {carry}; b = {b:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_add_mul_limb_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let a_old = a.clone();\n        limbs_vec_add_mul_limb_in_place_left(&mut a, &b, c);\n        println!(\n            \"a := {a_old:?}; limbs_vec_add_mul_limb_in_place_left(&mut a, {b:?}, {c}); a = {a:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_add_mul_limb_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, mut b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let b_old = b.clone();\n        limbs_vec_add_mul_limb_in_place_right(&a, &mut b, c);\n        println!(\n            \"b := {b_old:?}; limbs_vec_add_mul_limb_in_place_right({a:?}, &mut b, {c}); b = {b:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_add_mul_limb_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, mut b, c) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        limbs_vec_add_mul_limb_in_place_either(&mut a, &mut b, c);\n        println!(\n            \"a := {a_old:?}; \\\n            b := {b_old:?}; limbs_vec_add_mul_limb_in_place_either(&mut a, &mut b, {c}); \\\n             a = {a:?}; b = {b:?}\",\n        );\n    }\n}\n\nfn demo_limbs_add_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in unsigned_vec_triple_gen_var_41().get(gm, config).take(limit) {\n        println!(\n            \"limbs_add_mul({:?}, {:?}, {:?}) = {:?}\",\n            a,\n            b,\n            c,\n            limbs_add_mul(&a, &b, &c),\n        );\n    }\n}\n\nfn demo_limbs_add_mul_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in unsigned_vec_triple_gen_var_41().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        limbs_add_mul_in_place_left(&mut a, &b, &c);\n        println!(\"a := {a_old:?}; limbs_add_mul_in_place_left(&mut a, {b:?}, {c:?}); a = {a:?}\");\n    }\n}\n\nfn demo_natural_add_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        let c_old = c.clone();\n        a.add_mul_assign(b, c);\n        println!(\"a := {a_old}; x.add_mul_assign({b_old}, {c_old}); x = {a}\");\n    }\n}\n\nfn demo_natural_add_mul_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        a.add_mul_assign(b, &c);\n        println!(\"a := {a_old}; x.add_mul_assign({b_old}, &{c}); x = {a}\");\n    }\n}\n\nfn demo_natural_add_mul_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let c_old = c.clone();\n        a.add_mul_assign(&b, c);\n        println!(\"a := {a_old}; x.add_mul_assign(&{b}, {c_old}); x = {a}\");\n    }\n}\n\nfn demo_natural_add_mul_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        a.add_mul_assign(&b, &c);\n        println!(\"a := {a_old}; x.add_mul_assign(&{b}, &{c}); x = {a}\");\n    }\n}\n\nfn demo_natural_add_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        let c_old = c.clone();\n        println!(\n            \"{}.add_mul({}, {}) = {}\",\n            a_old,\n            b_old,\n            c_old,\n            a.add_mul(b, c)\n        );\n    }\n}\n\nfn demo_natural_add_mul_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        println!(\n            \"{}.add_mul({}, &{}) = {}\",\n            a_old,\n            b_old,\n            c,\n            a.add_mul(b, &c)\n        );\n    }\n}\n\nfn demo_natural_add_mul_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let c_old = c.clone();\n        println!(\n            \"{}.add_mul(&{}, {}) = {}\",\n            a_old,\n            b,\n            c_old,\n            a.add_mul(&b, c)\n        );\n    }\n}\n\nfn demo_natural_add_mul_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        println!(\"{}.add_mul(&{}, &{}) = {}\", a_old, b, c, a.add_mul(&b, &c));\n    }\n}\n\nfn demo_natural_add_mul_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).add_mul(&{}, &{}) = {}\",\n            a,\n            b,\n            c,\n            (&a).add_mul(&b, &c)\n        );\n    }\n}\n\nfn benchmark_limbs_add_mul_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_add_mul_limb(&[Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"a\", \"b\"),\n        &mut [(\"Malachite\", &mut |(a, b, c)| {\n            no_out!(limbs_add_mul_limb(&a, &b, c));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_add_mul_limb_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_add_mul_limb_same_length_in_place_left(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"a\", \"b\"),\n        &mut [(\"Malachite\", &mut |(mut a, b, c)| {\n            no_out!(limbs_slice_add_mul_limb_same_length_in_place_left(\n                &mut a, &b, c\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_add_mul_limb_same_length_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_add_mul_limb_same_length_in_place_left(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"a\", \"b\"),\n        &mut [(\"Malachite\", &mut |(a, mut b, c)| {\n            no_out!(limbs_slice_add_mul_limb_same_length_in_place_right(\n                &a, &mut b, c\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_add_mul_limb_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_add_mul_limb_in_place_left(&mut Vec<Limb>, &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"a\", \"b\"),\n        &mut [(\"Malachite\", &mut |(mut a, b, c)| {\n            limbs_vec_add_mul_limb_in_place_left(&mut a, &b, c);\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_add_mul_limb_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_add_mul_limb_in_place_left(&mut Vec<Limb>, &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"a\", \"b\"),\n        &mut [(\"Malachite\", &mut |(a, mut b, c)| {\n            limbs_vec_add_mul_limb_in_place_right(&a, &mut b, c);\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_add_mul_limb_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_add_mul_limb_in_place_either(&mut Vec<Limb>, &mut Vec<Limb>, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"a\", \"b\"),\n        &mut [(\"Malachite\", &mut |(mut a, b, c)| {\n            limbs_vec_add_mul_limb_in_place_left(&mut a, &b, c);\n        })],\n    );\n}\n\nfn benchmark_limbs_add_mul(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_add_mul(&[Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_41().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_vec_max_len_bucketer(\"a\", \"b\", \"c\"),\n        &mut [(\"Malachite\", &mut |(a, b, c)| {\n            no_out!(limbs_add_mul(&a, &b, &c));\n        })],\n    );\n}\n\nfn benchmark_limbs_add_mul_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_add_mul_in_place_left(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_41().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_vec_max_len_bucketer(\"a\", \"b\", \"c\"),\n        &mut [(\"Malachite\", &mut |(mut a, b, c)| {\n            no_out!(limbs_add_mul_in_place_left(&mut a, &b, &c));\n        })],\n    );\n}\n\nfn benchmark_natural_add_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.add_mul_assign(Natural, Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, c),\n            ),\n            (\n                \"Natural.add_mul_assign(Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, &c),\n            ),\n            (\n                \"Natural.add_mul_assign(&Natural, Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, c),\n            ),\n            (\n                \"Natural.add_mul_assign(&Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, &c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_add_mul_assign_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.add_mul_assign(Natural, Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, c),\n            ),\n            (\"Natural += Natural * Natural\", &mut |(mut a, b, c)| {\n                a += b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_add_mul_assign_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul_assign(Natural, &Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.add_mul_assign(Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(b, &c),\n            ),\n            (\"Natural += Natural * &Natural\", &mut |(mut a, b, c)| {\n                a += b * &c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_add_mul_assign_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul_assign(&Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.add_mul_assign(&Natural, Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, c),\n            ),\n            (\"Natural += &Natural * Natural\", &mut |(mut a, b, c)| {\n                a += &b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_add_mul_assign_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul_assign(&Natural, &Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.add_mul_assign(&Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.add_mul_assign(&b, &c),\n            ),\n            (\"Natural += &Natural * &Natural\", &mut |(mut a, b, c)| {\n                a += &b * &c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_add_mul_evaluation_stategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.add_mul(Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, c));\n            }),\n            (\"Natural.add_mul(Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, &c));\n            }),\n            (\"Natural.add_mul(&Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, c));\n            }),\n            (\"Natural.add_mul(&Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, &c));\n            }),\n            (\n                \"(&Natural).add_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).add_mul(&b, &c)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_add_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.add_mul(Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, c));\n            }),\n            (\"Natural + Natural * Natural\", &mut |(a, b, c)| {\n                no_out!(a + b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_add_mul_val_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul(Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.add_mul(Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(b, &c));\n            }),\n            (\"Natural + Natural * &Natural\", &mut |(a, b, c)| {\n                no_out!(a + b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_add_mul_val_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul(&Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.add_mul(&Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, c));\n            }),\n            (\"Natural + &Natural * Natural\", &mut |(a, b, c)| {\n                no_out!(a + &b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_add_mul_val_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.add_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.add_mul(&Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.add_mul(&b, &c));\n            }),\n            (\"Natural + &Natural * &Natural\", &mut |(a, b, c)| {\n                no_out!(a + &b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_add_mul_ref_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Natural).add_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"(&Natural).add_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).add_mul(&b, &c)),\n            ),\n            (\"(&Natural) + &Natural * &Natural\", &mut |(a, b, c)| {\n                no_out!((&a) + &b * &c);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::BinomialCoefficient;\nuse malachite_base::test_util::bench::bucketers::usize_convertible_pair_max_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_28;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::binomial_coefficient::*;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen_var_15, natural_pair_gen_var_15_rm, unsigned_pair_gen_var_45,\n    unsigned_pair_gen_var_46, unsigned_pair_gen_var_47, unsigned_pair_gen_var_48,\n    unsigned_pair_gen_var_49,\n};\nuse malachite_nz::test_util::natural::arithmetic::binomial_coefficient::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_binomial_coefficient_limb_limb_bdiv);\n    register_demo!(runner, demo_limbs_binomial_coefficient_limb_limb_small_k);\n    register_demo!(runner, demo_limbs_binomial_coefficient_limb_limb_basecase);\n    register_demo!(\n        runner,\n        demo_limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer\n    );\n    register_demo!(\n        runner,\n        demo_limbs_binomial_coefficient_limb_limb_goetgheluck\n    );\n    register_demo!(runner, demo_binomial_coefficient_limb_limb);\n    register_demo!(runner, demo_natural_binomial_coefficient);\n    register_demo!(runner, demo_natural_binomial_coefficient_ref);\n\n    register_bench!(runner, benchmark_binomial_coefficient_limb_limb_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_binomial_coefficient_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_binomial_coefficient_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_binomial_coefficient_library_comparison\n    );\n}\n\nfn demo_limbs_binomial_coefficient_limb_limb_bdiv(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, k) in unsigned_pair_gen_var_45().get(gm, config).take(limit) {\n        println!(\n            \"limbs_binomial_coefficient_limb_limb_bdiv({}, {}) = {:?}\",\n            n,\n            k,\n            limbs_binomial_coefficient_limb_limb_bdiv(n, k),\n        );\n    }\n}\n\nfn demo_limbs_binomial_coefficient_limb_limb_small_k(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in unsigned_pair_gen_var_46().get(gm, config).take(limit) {\n        println!(\n            \"limbs_binomial_coefficient_limb_limb_small_k({}, {}) = {:?}\",\n            n,\n            k,\n            limbs_binomial_coefficient_limb_limb_small_k(n, k),\n        );\n    }\n}\n\nfn demo_limbs_binomial_coefficient_limb_limb_basecase(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in unsigned_pair_gen_var_47().get(gm, config).take(limit) {\n        println!(\n            \"limbs_binomial_coefficient_limb_limb_basecase({}, {}) = {}\",\n            n,\n            k,\n            limbs_binomial_coefficient_limb_limb_basecase(n, k),\n        );\n    }\n}\n\nfn demo_limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in unsigned_pair_gen_var_48().get(gm, config).take(limit) {\n        println!(\n            \"limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer({}, {}) = {:?}\",\n            n,\n            k,\n            limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(n, k),\n        );\n    }\n}\n\nfn demo_limbs_binomial_coefficient_limb_limb_goetgheluck(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, k) in unsigned_pair_gen_var_49().get(gm, config).take(limit) {\n        println!(\n            \"limbs_binomial_coefficient_limb_limb_goetgheluck({}, {}) = {:?}\",\n            n,\n            k,\n            limbs_binomial_coefficient_limb_limb_goetgheluck(n, k),\n        );\n    }\n}\n\nfn demo_binomial_coefficient_limb_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, k) in unsigned_pair_gen_var_28().get(gm, config).take(limit) {\n        println!(\n            \"binomial_coefficient_limb_limb({}, {}) = {}\",\n            n,\n            k,\n            binomial_coefficient_limb_limb(n, k),\n        );\n    }\n}\n\nfn demo_natural_binomial_coefficient(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, k) in natural_pair_gen_var_15().get(gm, config).take(limit) {\n        let n_orig = n.clone();\n        let k_orig = k.clone();\n        println!(\n            \"C({}, {}) = {}\",\n            n_orig,\n            k_orig,\n            Natural::binomial_coefficient(n, k)\n        );\n    }\n}\n\nfn demo_natural_binomial_coefficient_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, k) in natural_pair_gen_var_15().get(gm, config).take(limit) {\n        println!(\n            \"C({}, {}) = {}\",\n            n,\n            k,\n            Natural::binomial_coefficient(&n, &k)\n        );\n    }\n}\n\nfn benchmark_binomial_coefficient_limb_limb_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"binomial_coefficient_limb_limb(Limb, Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_28().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &usize_convertible_pair_max_bucketer(\"n\", \"k\"),\n        &mut [\n            (\"default\", &mut |(n, k)| {\n                no_out!(binomial_coefficient_limb_limb(n, k));\n            }),\n            (\"naive\", &mut |(n, k)| {\n                no_out!(Natural::binomial_coefficient(\n                    Natural::from(n),\n                    Natural::from(k)\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_binomial_coefficient_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.binomial_coefficient(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Natural.binomial_coefficient(Natural, Natural)\",\n                &mut |(n, k)| no_out!(Natural::binomial_coefficient(n, k)),\n            ),\n            (\n                \"Natural.binomial_coefficient(&Natural, &Natural)\",\n                &mut |(n, k)| no_out!(Natural::binomial_coefficient(&n, &k)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_binomial_coefficient_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.binomial_coefficient(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(n, k)| {\n                no_out!(Natural::binomial_coefficient(n, k));\n            }),\n            (\"naive 1\", &mut |(n, k)| {\n                no_out!(binomial_coefficient_naive_1(n, k));\n            }),\n            (\"naive 2\", &mut |(n, k)| {\n                no_out!(binomial_coefficient_naive_2(n, k));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_binomial_coefficient_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.binomial_coefficient(Natural, Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_15_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, k))| {\n                no_out!(Natural::binomial_coefficient(n, k));\n            }),\n            (\"rug\", &mut |((n, k), _)| no_out!(n.binomial(k))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/checked_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::CheckedSub;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_natural_max_bit_bucketer, triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_pair_gen, natural_pair_gen_nrm};\nuse malachite_nz::test_util::natural::arithmetic::checked_sub::checked_sub;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_checked_sub);\n    register_demo!(runner, demo_natural_checked_sub_val_ref);\n    register_demo!(runner, demo_natural_checked_sub_ref_val);\n    register_demo!(runner, demo_natural_checked_sub_ref_ref);\n\n    register_bench!(runner, benchmark_natural_checked_sub_library_comparison);\n    register_bench!(runner, benchmark_natural_checked_sub_evaluation_strategy);\n}\n\nfn demo_natural_checked_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.checked_sub({}) = {:?}\", x_old, y_old, x.checked_sub(y));\n    }\n}\n\nfn demo_natural_checked_sub_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.checked_sub(&{}) = {:?}\", x_old, y, x.checked_sub(&y));\n    }\n}\n\nfn demo_natural_checked_sub_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).checked_sub({}) = {:?}\",\n            x,\n            y_old,\n            (&x).checked_sub(y)\n        );\n    }\n}\n\nfn demo_natural_checked_sub_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_sub(&{}) = {:?}\", x, y, (&x).checked_sub(&y));\n    }\n}\n\nfn benchmark_natural_checked_sub_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sub(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.checked_sub(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(checked_sub(x, y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(checked_sub(x, y))),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sub(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.checked_sub(Natural)\", &mut |(x, y)| {\n                no_out!(x.checked_sub(y));\n            }),\n            (\"Natural.checked_sub(&Natural)\", &mut |(x, y)| {\n                no_out!(x.checked_sub(&y));\n            }),\n            (\"&Natural.checked_sub(Natural)\", &mut |(x, y)| {\n                no_out!((&x).checked_sub(y));\n            }),\n            (\"&Natural.checked_sub(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).checked_sub(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/checked_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedSub, CheckedSubMul};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_triple_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_checked_sub_mul);\n    register_demo!(runner, demo_natural_checked_sub_mul_val_val_ref);\n    register_demo!(runner, demo_natural_checked_sub_mul_val_ref_val);\n    register_demo!(runner, demo_natural_checked_sub_mul_val_ref_ref);\n    register_demo!(runner, demo_natural_checked_sub_mul_ref_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_checked_sub_mul_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_checked_sub_mul_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_checked_sub_mul_val_val_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_checked_sub_mul_val_ref_val_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_checked_sub_mul_val_ref_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_checked_sub_mul_ref_ref_ref_algorithms\n    );\n}\n\nfn demo_natural_checked_sub_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        let c_old = c.clone();\n        println!(\n            \"{}.checked_sub_mul({}, {}) = {:?}\",\n            a_old,\n            b_old,\n            c_old,\n            a.checked_sub_mul(b, c)\n        );\n    }\n}\n\nfn demo_natural_checked_sub_mul_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        println!(\n            \"{}.checked_sub_mul({}, &{}) = {:?}\",\n            a_old,\n            b_old,\n            c,\n            a.checked_sub_mul(b, &c)\n        );\n    }\n}\n\nfn demo_natural_checked_sub_mul_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let c_old = c.clone();\n        println!(\n            \"{}.checked_sub_mul(&{}, {}) = {:?}\",\n            a_old,\n            b,\n            c_old,\n            a.checked_sub_mul(&b, c)\n        );\n    }\n}\n\nfn demo_natural_checked_sub_mul_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        println!(\n            \"{}.checked_sub_mul(&{}, &{}) = {:?}\",\n            a_old,\n            b,\n            c,\n            a.checked_sub_mul(&b, &c)\n        );\n    }\n}\n\nfn demo_natural_checked_sub_mul_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        println!(\n            \"(&{}).checked_sub_mul(&{}, &{}) = {:?}\",\n            a_old,\n            b,\n            c,\n            (&a).checked_sub_mul(&b, &c)\n        );\n    }\n}\n\nfn benchmark_natural_checked_sub_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sub_mul(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.checked_sub_mul(Natural, Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub_mul(b, c)),\n            ),\n            (\n                \"Natural.checked_sub_mul(Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub_mul(b, &c)),\n            ),\n            (\n                \"Natural.checked_sub_mul(&Natural, Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub_mul(&b, c)),\n            ),\n            (\n                \"Natural.checked_sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub_mul(&b, &c)),\n            ),\n            (\n                \"(&Natural).checked_sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).checked_sub_mul(&b, &c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_sub_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sub_mul(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Natural.sub_mul(Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.checked_sub_mul(b, c));\n            }),\n            (\n                \"Natural.checked_sub(Natural * Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub(b * c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_sub_mul_val_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sub_mul(Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Natural.sub_mul(Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.checked_sub_mul(b, &c));\n            }),\n            (\n                \"Natural.checked_sub(Natural * &Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub(b * &c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_sub_mul_val_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sub_mul(&Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Natural.sub_mul(&Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.checked_sub_mul(&b, c));\n            }),\n            (\n                \"Natural.checked_sub(&Natural * Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub(&b * c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_sub_mul_val_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sub_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\"Natural.sub_mul(&Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.checked_sub_mul(&b, &c));\n            }),\n            (\n                \"Natural.checked_sub(&Natural * &Natural)\",\n                &mut |(a, b, c)| no_out!(a.checked_sub(&b * &c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_sub_mul_ref_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Natural).checked_sub_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"(&Natural).checked_sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).checked_sub_mul(&b, &c)),\n            ),\n            (\n                \"(&Natural).checked_sub(&Natural * &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).checked_sub(&b * &c)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/coprime_with.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CoprimeWith, Gcd};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::coprime_with::{\n    coprime_with_check_2, coprime_with_check_2_3, coprime_with_check_2_3_5,\n};\nuse malachite_nz::test_util::bench::bucketers::pair_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_coprime_with);\n    register_demo!(runner, demo_natural_coprime_with_val_ref);\n    register_demo!(runner, demo_natural_coprime_with_ref_val);\n    register_demo!(runner, demo_natural_coprime_with_ref_ref);\n\n    register_bench!(runner, benchmark_natural_coprime_with_algorithms);\n    register_bench!(runner, benchmark_natural_coprime_with_evaluation_strategy);\n}\n\nfn demo_natural_coprime_with(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        if x.coprime_with(y) {\n            println!(\"{x_old} is coprime with {y_old}\");\n        } else {\n            println!(\"{x_old} is not coprime with {y_old}\");\n        }\n    }\n}\n\nfn demo_natural_coprime_with_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        if x.coprime_with(&y) {\n            println!(\"{x_old} is coprime with {y}\");\n        } else {\n            println!(\"{x_old} is not coprime with {y}\");\n        }\n    }\n}\n\nfn demo_natural_coprime_with_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        if (&x).coprime_with(y) {\n            println!(\"{x} is coprime with {y_old}\");\n        } else {\n            println!(\"{x} is not coprime with {y_old}\");\n        }\n    }\n}\n\nfn demo_natural_coprime_with_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        if (&x).coprime_with(&y) {\n            println!(\"{x} is coprime with {y}\");\n        } else {\n            println!(\"{x} is not coprime with {y}\");\n        }\n    }\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_coprime_with_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.coprime_with(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.coprime_with(y))),\n            (\"no divisibility check\", &mut |(x, y)| {\n                no_out!(x.gcd(y) == 1);\n            }),\n            (\"check divisibility by 2\", &mut |(x, y)| {\n                no_out!(coprime_with_check_2(x, y));\n            }),\n            (\"check divisibility by 2 and 3\", &mut |(x, y)| {\n                no_out!(coprime_with_check_2_3(x, y));\n            }),\n            (\"check divisibility by 2, 3, and 5\", &mut |(x, y)| {\n                no_out!(coprime_with_check_2_3_5(x, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_coprime_with_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.coprime_with(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.coprime_with(Natural)\", &mut |(x, y)| {\n                no_out!(x.coprime_with(y));\n            }),\n            (\"Natural.coprime_with(&Natural)\", &mut |(x, y)| {\n                no_out!(x.coprime_with(&y));\n            }),\n            (\"&Natural.coprime_with(Natural)\", &mut |(x, y)| {\n                no_out!((&x).coprime_with(y));\n            }),\n            (\"&Natural.coprime_with(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).coprime_with(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedDiv, DivMod};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, quadruple_2_3_diff_vec_len_bucketer, quadruple_2_vec_len_bucketer,\n    quadruple_3_vec_len_bucketer, triple_1_vec_len_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_11, unsigned_vec_unsigned_pair_gen_var_22,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::div::{\n    limbs_div, limbs_div_barrett, limbs_div_barrett_approx, limbs_div_barrett_approx_scratch_len,\n    limbs_div_barrett_scratch_len, limbs_div_divide_and_conquer,\n    limbs_div_divide_and_conquer_approx, limbs_div_divisor_of_limb_max_with_carry_in_place,\n    limbs_div_divisor_of_limb_max_with_carry_to_out, limbs_div_limb, limbs_div_limb_in_place,\n    limbs_div_limb_to_out, limbs_div_schoolbook, limbs_div_schoolbook_approx, limbs_div_to_out,\n    limbs_div_to_out_balanced, limbs_div_to_out_ref_ref, limbs_div_to_out_ref_val,\n    limbs_div_to_out_unbalanced, limbs_div_to_out_val_ref,\n};\nuse malachite_nz::natural::arithmetic::div_mod::{\n    limbs_div_mod, limbs_div_mod_barrett, limbs_div_mod_barrett_scratch_len,\n    limbs_div_mod_divide_and_conquer, limbs_div_mod_schoolbook, limbs_div_mod_to_out,\n    limbs_two_limb_inverse_helper,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::bench::bucketers::{\n    limbs_div_to_out_balancing_bucketer, pair_1_natural_bit_bucketer,\n    pair_2_pair_1_natural_bit_bucketer, triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_10, large_type_gen_var_11, large_type_gen_var_12, natural_pair_gen,\n    natural_pair_gen_nm, natural_pair_gen_var_5, natural_pair_gen_var_5_nrm,\n    unsigned_vec_quadruple_gen_var_1, unsigned_vec_triple_gen_var_42,\n    unsigned_vec_triple_gen_var_43, unsigned_vec_triple_gen_var_44, unsigned_vec_triple_gen_var_45,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_9,\n};\nuse malachite_nz::test_util::natural::arithmetic::div::{\n    limbs_div_limb_in_place_alt, limbs_div_limb_to_out_alt,\n};\nuse num::CheckedDiv as NumCheckedDiv;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_div_limb);\n    register_demo!(runner, demo_limbs_div_limb_to_out);\n    register_demo!(runner, demo_limbs_div_limb_in_place);\n    register_demo!(runner, demo_limbs_div_divisor_of_limb_max_with_carry_to_out);\n    register_demo!(\n        runner,\n        demo_limbs_div_divisor_of_limb_max_with_carry_in_place\n    );\n    register_demo!(runner, demo_limbs_div_schoolbook);\n    register_demo!(runner, demo_limbs_div_divide_and_conquer);\n    register_demo!(runner, demo_limbs_div_barrett);\n    register_demo!(runner, demo_limbs_div_schoolbook_approx);\n    register_demo!(runner, demo_limbs_div_divide_and_conquer_approx);\n    register_demo!(runner, demo_limbs_div_barrett_approx);\n    register_demo!(runner, demo_limbs_div);\n    register_demo!(runner, demo_limbs_div_to_out);\n    register_demo!(runner, demo_limbs_div_to_out_val_ref);\n    register_demo!(runner, demo_limbs_div_to_out_ref_val);\n    register_demo!(runner, demo_limbs_div_to_out_ref_ref);\n    register_demo!(runner, demo_natural_div_assign);\n    register_demo!(runner, demo_natural_div_assign_ref);\n    register_demo!(runner, demo_natural_div);\n    register_demo!(runner, demo_natural_div_val_ref);\n    register_demo!(runner, demo_natural_div_ref_val);\n    register_demo!(runner, demo_natural_div_ref_ref);\n    register_demo!(runner, demo_natural_checked_div);\n    register_demo!(runner, demo_natural_checked_div_val_ref);\n    register_demo!(runner, demo_natural_checked_div_ref_val);\n    register_demo!(runner, demo_natural_checked_div_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_div_limb);\n    register_bench!(runner, benchmark_limbs_div_limb_to_out_algorithms);\n    register_bench!(runner, benchmark_limbs_div_limb_in_place_algorithms);\n    register_bench!(\n        runner,\n        benchmark_limbs_div_divisor_of_limb_max_with_carry_to_out\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_div_divisor_of_limb_max_with_carry_in_place\n    );\n    register_bench!(runner, benchmark_limbs_div_schoolbook_algorithms);\n    register_bench!(runner, benchmark_limbs_div_divide_and_conquer_algorithms);\n    register_bench!(runner, benchmark_limbs_div_barrett_algorithms);\n    register_bench!(runner, benchmark_limbs_div_schoolbook_approx_algorithms);\n    register_bench!(\n        runner,\n        benchmark_limbs_div_divide_and_conquer_approx_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_div_barrett_approx_algorithms);\n    register_bench!(runner, benchmark_limbs_div_algorithms);\n    register_bench!(runner, benchmark_limbs_div_to_out_balancing_algorithms);\n    register_bench!(runner, benchmark_limbs_div_to_out_evaluation_strategy);\n    register_bench!(runner, benchmark_limbs_div_to_out_ref_ref_algorithms);\n    register_bench!(runner, benchmark_natural_div_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_div_library_comparison);\n    register_bench!(runner, benchmark_natural_div_algorithms);\n    register_bench!(runner, benchmark_natural_div_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_checked_div_library_comparison);\n    register_bench!(runner, benchmark_natural_checked_div_evaluation_strategy);\n}\n\nfn demo_limbs_div_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_div_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_div_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_div_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_div_limb_to_out(&mut out, &xs, y);\n        println!(\"out := {out_old:?}; limbs_div_limb_to_out(&mut out, {xs:?}, {y}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_div_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_div_limb_in_place(&mut xs, y);\n        println!(\"limbs := {xs_old:?}; limbs_div_limb_in_place(&mut limbs, {y}); limbs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_div_divisor_of_limb_max_with_carry_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut out, xs, divisor, carry) in large_type_gen_var_10().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let carry_out = limbs_div_divisor_of_limb_max_with_carry_to_out::<DoubleLimb, Limb>(\n            &mut out, &xs, divisor, carry,\n        );\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_div_divisor_of_limb_max_with_carry_to_out(&mut out, {xs:?}, {divisor}, {carry}) \\\n             = {carry_out}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_divisor_of_limb_max_with_carry_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, divisor, carry) in unsigned_vec_unsigned_unsigned_triple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry_out = limbs_div_divisor_of_limb_max_with_carry_in_place(&mut xs, divisor, carry);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_div_divisor_of_limb_max_with_carry_in_place(&mut xs, {divisor}, {carry}) = \\\n            {carry_out}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_schoolbook(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_11().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        let highest_q = limbs_div_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {old_qs:?}; \\\n            ns := {old_ns:?}; limbs_div_schoolbook(&mut qs, &mut ns, {ds:?}, {inverse}) = \\\n            {highest_q}; qs = {qs:?}, ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_divide_and_conquer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, ds, inverse) in large_type_gen_var_12().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let highest_q = limbs_div_divide_and_conquer(&mut qs, &ns, &ds, inverse);\n        println!(\n            \"qs := {old_qs:?}; \\\n            ns := {ns:?}; limbs_div_divide_and_conquer(&mut qs, &ns, {ds:?}, {inverse}) = \\\n            {highest_q}; qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_barrett(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, ds) in unsigned_vec_triple_gen_var_43().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n        let highest_q = limbs_div_barrett(&mut qs, &ns, &ds, &mut scratch);\n        println!(\n            \"qs := {old_qs:?}; ns := {ns:?}; \\\n             limbs_div_barrett(&mut qs, ns, {ds:?}, &mut scratch) = {highest_q}; qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_schoolbook_approx(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_11().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        let highest_q = limbs_div_schoolbook_approx(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {old_qs:?}; ns := {old_ns:?}; \\\n             limbs_div_schoolbook_approx(&mut qs, &mut ns, {ds:?}, {inverse}) = {highest_q}; \\\n             qs = {qs:?}, ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_divide_and_conquer_approx(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_12().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        let highest_q = limbs_div_divide_and_conquer_approx(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {old_qs:?}; ns := {old_ns:?}; \\\n             limbs_div_divide_and_conquer_approx(&mut qs, &mut ns, {ds:?}, {inverse}) = \\\n             {highest_q}; qs = {qs:?}, ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_barrett_approx(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, ds) in unsigned_vec_triple_gen_var_42().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n        let highest_q = limbs_div_barrett_approx(&mut qs, &ns, &ds, &mut scratch);\n        println!(\n            \"qs := {old_qs:?}; ns := {ns:?}; \\\n             limbs_div_barrett_approx(&mut qs, ns, {ds:?}, &mut scratch) = {highest_q}; \\\n             qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, ds) in unsigned_vec_pair_gen_var_11().get(gm, config).take(limit) {\n        println!(\"limbs_div({:?}, {:?}) = {:?}\", ns, ds, limbs_div(&ns, &ds));\n    }\n}\n\nfn demo_limbs_div_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, mut ds) in unsigned_vec_triple_gen_var_44().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        let old_ds = ds.clone();\n        limbs_div_to_out(&mut qs, &mut ns, &mut ds);\n        println!(\n            \"qs := {old_qs:?}; \\\n            ns := {old_ns:?}; ds := {old_ds:?}; limbs_div_to_out(&mut qs, &mut ns, &mut ds); \\\n             qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_to_out_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds) in unsigned_vec_triple_gen_var_44().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        limbs_div_to_out_val_ref(&mut qs, &mut ns, &ds);\n        println!(\n            \"qs := {old_qs:?}; \\\n            ns := {old_ns:?}; limbs_div_to_out_val_ref(&mut qs, &mut ns, {ds:?}); qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_to_out_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, mut ds) in unsigned_vec_triple_gen_var_44().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ds = ds.clone();\n        limbs_div_to_out_ref_val(&mut qs, &ns, &mut ds);\n        println!(\n            \"qs := {old_qs:?}; \\\n            ds := {old_ds:?}; limbs_div_to_out_ref_val(&mut qs, {ns:?}, &mut ds); qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_to_out_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, ds) in unsigned_vec_triple_gen_var_44().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        limbs_div_to_out_ref_ref(&mut qs, &ns, &ds);\n        println!(\n            \"qs := {old_qs:?}; limbs_div_to_out_ref_ref(&mut qs, {ns:?}, {ds:?}); qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_natural_div_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x /= y;\n        println!(\"x := {x_old}; x /= {y_old}; x = {x}\");\n    }\n}\n\nfn demo_natural_div_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x /= &y;\n        println!(\"x := {x_old}; x /= &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_natural_div_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} / &{} = {}\", x_old, y, x / &y);\n    }\n}\n\nfn demo_natural_div_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} / {} = {}\", x, y_old, &x / y);\n    }\n}\n\nfn demo_natural_div_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\"&{} / &{} = {}\", x, y, &x / &y);\n    }\n}\n\nfn demo_natural_checked_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).checked_div({}) = {:?}\",\n            x_old,\n            y_old,\n            x.checked_div(y)\n        );\n    }\n}\n\nfn demo_natural_checked_div_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).checked_div(&{}) = {:?}\", x_old, y, x.checked_div(&y));\n    }\n}\n\nfn demo_natural_checked_div_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).checked_div({}) = {:?}\",\n            x,\n            y_old,\n            (&x).checked_div(y)\n        );\n    }\n}\n\nfn demo_natural_checked_div_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_div(&{}) = {:?}\", x, y, (&x).checked_div(&y));\n    }\n}\n\nfn benchmark_limbs_div_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_div_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_div_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_limbs_div_limb_to_out_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut out, xs, y)| {\n                limbs_div_limb_to_out(&mut out, &xs, y);\n            }),\n            (\"alt\", &mut |(mut out, xs, y)| {\n                limbs_div_limb_to_out_alt(&mut out, &xs, y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_limb_in_place_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut xs, y)| {\n                limbs_div_limb_in_place(&mut xs, y);\n            }),\n            (\"alt\", &mut |(mut xs, y)| {\n                limbs_div_limb_in_place_alt(&mut xs, y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_divisor_of_limb_max_with_carry_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_divisor_of_limb_max_with_carry_to_out(&mut [Limb], &[Limb], Limb, Limb)\",\n        BenchmarkType::Single,\n        large_type_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, divisor, carry)| {\n            no_out!(limbs_div_divisor_of_limb_max_with_carry_to_out::<\n                DoubleLimb,\n                Limb,\n            >(&mut out, &xs, divisor, carry));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_divisor_of_limb_max_with_carry_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_divisor_of_limb_max_with_carry_in_place(&mut [Limb], Limb, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, divisor, carry)| {\n            no_out!(limbs_div_divisor_of_limb_max_with_carry_in_place(\n                &mut xs, divisor, carry\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_schoolbook_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_schoolbook(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"Schoolbook div/mod\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse));\n            }),\n            (\"Schoolbook div\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_div_schoolbook(&mut qs, &mut ns, &ds, inverse));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_divide_and_conquer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_divide_and_conquer(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"Schoolbook div\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_div_schoolbook(&mut qs, &mut ns, &ds, inverse));\n            }),\n            (\"divide-and-conquer div/mod\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_div_mod_divide_and_conquer(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n            (\"divide-and-conquer div\", &mut |(\n                mut qs,\n                ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_div_divide_and_conquer(&mut qs, &ns, &ds, inverse));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_barrett_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_barrett(&mut [Limb], &[Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"divide-and-conquer div\", &mut |(\n                mut qs,\n                ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_div_divide_and_conquer(&mut qs, &ns, &ds, inverse));\n            }),\n            (\"Barrett div/mod\", &mut |(mut qs, ns, ds, _)| {\n                let mut rs = vec![0; ds.len()];\n                let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n                no_out!(limbs_div_mod_barrett(\n                    &mut qs,\n                    &mut rs,\n                    &ns,\n                    &ds,\n                    &mut scratch\n                ));\n            }),\n            (\"Barrett div\", &mut |(mut qs, ns, ds, _)| {\n                let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n                no_out!(limbs_div_barrett(&mut qs, &ns, &ds, &mut scratch));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_schoolbook_approx_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_schoolbook_approx(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"Schoolbook\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_div_schoolbook(&mut qs, &mut ns, &ds, inverse));\n            }),\n            (\"Schoolbook approx\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_div_schoolbook_approx(&mut qs, &mut ns, &ds, inverse));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_divide_and_conquer_approx_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_divide_and_conquer_approx(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"Schoolbook approx\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_div_schoolbook_approx(&mut qs, &mut ns, &ds, inverse));\n            }),\n            (\"divide-and-conquer\", &mut |(mut qs, ns, ds, inverse)| {\n                no_out!(limbs_div_divide_and_conquer(&mut qs, &ns, &ds, inverse));\n            }),\n            (\"divide-and-conquer approx\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_div_divide_and_conquer_approx(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_barrett_approx_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_barrett_approx(&mut [Limb], &[Limb], &[Limb], &mut Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"divide-and-conquer approx\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                _,\n            )| {\n                // recompute inverse to make benchmark fair\n                let inverse = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n                no_out!(limbs_div_divide_and_conquer_approx(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n            (\"Barrett\", &mut |(mut qs, ns, ds, _)| {\n                let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n                no_out!(limbs_div_barrett(&mut qs, &ns, &ds, &mut scratch));\n            }),\n            (\"Barrett approx\", &mut |(mut qs, ns, ds, _)| {\n                let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n                no_out!(limbs_div_barrett_approx(&mut qs, &ns, &ds, &mut scratch));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_div(&[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"div_mod\", &mut |(ns, ds)| no_out!(limbs_div_mod(&ns, &ds))),\n            (\"div\", &mut |(ns, ds)| no_out!(limbs_div(&ns, &ds))),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_to_out_balancing_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_to_out(&mut [Limb], &mut [Limb], &mut [Limb]) balancing\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_45().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limbs_div_to_out_balancing_bucketer(),\n        &mut [\n            (\"unbalanced\", &mut |(mut qs, mut ns, mut ds)| {\n                limbs_div_to_out_unbalanced(&mut qs, &mut ns, &mut ds);\n            }),\n            (\"balanced\", &mut |(mut qs, ns, ds)| {\n                limbs_div_to_out_balanced(&mut qs, &ns, &ds);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_to_out_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_to_out(&mut [Limb], &mut [Limb], &mut [Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_triple_gen_var_44().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\n                \"limbs_div_to_out(&mut [Limb], &mut [Limb], &mut [Limb])\",\n                &mut |(mut qs, mut ns, mut ds)| limbs_div_to_out(&mut qs, &mut ns, &mut ds),\n            ),\n            (\n                \"limbs_div_to_out_val_ref(&mut [Limb], &mut [Limb], &[Limb])\",\n                &mut |(mut qs, mut ns, ds)| limbs_div_to_out_val_ref(&mut qs, &mut ns, &ds),\n            ),\n            (\n                \"limbs_div_to_out_ref_val(&mut [Limb], &[Limb], &mut [Limb])\",\n                &mut |(mut qs, ns, mut ds)| limbs_div_to_out_ref_val(&mut qs, &ns, &mut ds),\n            ),\n            (\n                \"limbs_div_to_out_ref_ref(&mut [Limb], &[Limb], &[Limb])\",\n                &mut |(mut qs, ns, ds)| limbs_div_to_out_ref_ref(&mut qs, &ns, &ds),\n            ),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_to_out_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_to_out_ref_ref(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"div_mod\", &mut |(mut qs, mut rs, ns, ds)| {\n                limbs_div_mod_to_out(&mut qs, &mut rs, &ns, &ds);\n            }),\n            (\"div\", &mut |(mut qs, _, ns, ds)| {\n                limbs_div_to_out_ref_ref(&mut qs, &ns, &ds);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_div_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural /= Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural /= Natural\", &mut |(mut x, y)| x /= y),\n            (\"Natural /= &Natural\", &mut |(mut x, y)| x /= &y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_div_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural / Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x / y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x / &y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x / y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_div_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural / Natural\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x / y)),\n            (\"using div_mod\", &mut |(x, y)| no_out!(x.div_mod(y).0)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural / Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural / Natural\", &mut |(x, y)| no_out!(x / y)),\n            (\"Natural / &Natural\", &mut |(x, y)| no_out!(x / &y)),\n            (\"&Natural / Natural\", &mut |(x, y)| no_out!(&x / y)),\n            (\"&Natural / &Natural\", &mut |(x, y)| no_out!(&x / &y)),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_div_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_div(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.checked_div(&y))),\n            (\"num\", &mut |((x, y), _)| no_out!(x.checked_div(&y))),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_div(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.checked_div(Natural)\", &mut |(x, y)| {\n                no_out!(x.checked_div(y));\n            }),\n            (\"Natural.checked_div(&Natural)\", &mut |(x, y)| {\n                no_out!(x.checked_div(&y));\n            }),\n            (\"(&Natural).checked_div(Natural)\", &mut |(x, y)| {\n                no_out!((&x).checked_div(y));\n            }),\n            (\"(&Natural).checked_div(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).checked_div(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivExact, DivExactAssign};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_2_vec_len_bucketer, quadruple_2_vec_len_bucketer,\n    quadruple_3_vec_len_bucketer, triple_2_vec_len_bucketer, unsigned_bit_bucketer,\n    vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{unsigned_gen_var_22, unsigned_vec_pair_gen_var_12};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::div::{\n    limbs_div, limbs_div_limb, limbs_div_limb_in_place, limbs_div_limb_to_out, limbs_div_to_out,\n};\nuse malachite_nz::natural::arithmetic::div_exact::{\n    limbs_div_exact, limbs_div_exact_3, limbs_div_exact_3_in_place, limbs_div_exact_3_to_out,\n    limbs_div_exact_limb, limbs_div_exact_limb_in_place,\n    limbs_div_exact_limb_in_place_no_special_3, limbs_div_exact_limb_no_special_3,\n    limbs_div_exact_limb_to_out, limbs_div_exact_limb_to_out_no_special_3, limbs_div_exact_to_out,\n    limbs_div_exact_to_out_ref_ref, limbs_div_exact_to_out_ref_val, limbs_div_exact_to_out_val_ref,\n    limbs_modular_div, limbs_modular_div_barrett, limbs_modular_div_barrett_scratch_len,\n    limbs_modular_div_divide_and_conquer, limbs_modular_div_mod_barrett,\n    limbs_modular_div_mod_barrett_scratch_len, limbs_modular_div_mod_divide_and_conquer,\n    limbs_modular_div_mod_schoolbook, limbs_modular_div_ref, limbs_modular_div_ref_scratch_len,\n    limbs_modular_div_schoolbook, limbs_modular_div_scratch_len, limbs_modular_invert,\n    limbs_modular_invert_limb, limbs_modular_invert_scratch_len, limbs_modular_invert_small,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_natural_bit_bucketer, triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_13, large_type_gen_var_14, large_type_gen_var_15, large_type_gen_var_16,\n    large_type_gen_var_17, natural_pair_gen_var_6, natural_pair_gen_var_6_nrm,\n    unsigned_vec_gen_var_5, unsigned_vec_pair_gen_var_13, unsigned_vec_pair_gen_var_14,\n    unsigned_vec_quadruple_gen_var_2, unsigned_vec_quadruple_gen_var_3,\n    unsigned_vec_triple_gen_var_46, unsigned_vec_triple_gen_var_47, unsigned_vec_triple_gen_var_48,\n    unsigned_vec_triple_gen_var_49, unsigned_vec_unsigned_pair_gen_var_29,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14,\n};\nuse malachite_nz::test_util::natural::arithmetic::div_exact::{\n    limbs_div_exact_3_in_place_alt, limbs_div_exact_3_to_out_alt,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_modular_invert_limb);\n    register_demo!(runner, demo_limbs_div_exact_limb);\n    register_demo!(runner, demo_limbs_div_exact_limb_to_out);\n    register_demo!(runner, demo_limbs_div_exact_limb_in_place);\n    register_demo!(runner, demo_limbs_div_exact_3);\n    register_demo!(runner, demo_limbs_div_exact_3_to_out);\n    register_demo!(runner, demo_limbs_div_exact_3_in_place);\n    register_demo!(runner, demo_limbs_modular_invert);\n    register_demo!(runner, demo_limbs_modular_div_mod_schoolbook);\n    register_demo!(runner, demo_limbs_modular_div_mod_divide_and_conquer);\n    register_demo!(runner, demo_limbs_modular_div_mod_barrett);\n    register_demo!(runner, demo_limbs_modular_div_schoolbook);\n    register_demo!(runner, demo_limbs_modular_div_divide_and_conquer);\n    register_demo!(runner, demo_limbs_modular_div_barrett);\n    register_demo!(runner, demo_limbs_modular_div);\n    register_demo!(runner, demo_limbs_modular_div_ref);\n    register_demo!(runner, demo_limbs_div_exact);\n    register_demo!(runner, demo_limbs_div_exact_to_out);\n    register_demo!(runner, demo_limbs_div_exact_to_out_val_ref);\n    register_demo!(runner, demo_limbs_div_exact_to_out_ref_val);\n    register_demo!(runner, demo_limbs_div_exact_to_out_ref_ref);\n    register_demo!(runner, demo_natural_div_exact_assign);\n    register_demo!(runner, demo_natural_div_exact_assign_ref);\n    register_demo!(runner, demo_natural_div_exact);\n    register_demo!(runner, demo_natural_div_exact_val_ref);\n    register_demo!(runner, demo_natural_div_exact_ref_val);\n    register_demo!(runner, demo_natural_div_exact_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_modular_invert_limb);\n    register_bench!(runner, benchmark_limbs_div_exact_limb_algorithms);\n    register_bench!(runner, benchmark_limbs_div_exact_limb_to_out_algorithms);\n    register_bench!(runner, benchmark_limbs_div_exact_limb_in_place_algorithms);\n    register_bench!(runner, benchmark_limbs_div_exact_3_algorithms);\n    register_bench!(runner, benchmark_limbs_div_exact_3_to_out_algorithms);\n    register_bench!(runner, benchmark_limbs_div_exact_3_in_place_algorithms);\n    register_bench!(runner, benchmark_limbs_modular_invert_algorithms);\n    register_bench!(runner, benchmark_limbs_modular_div_mod_schoolbook);\n    register_bench!(\n        runner,\n        benchmark_limbs_modular_div_mod_divide_and_conquer_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_modular_div_mod_barrett_algorithms);\n    register_bench!(runner, benchmark_limbs_modular_div_schoolbook);\n    register_bench!(\n        runner,\n        benchmark_limbs_modular_div_divide_and_conquer_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_modular_div_barrett_algorithms);\n    register_bench!(runner, benchmark_limbs_modular_div_evaluation_strategy);\n    register_bench!(runner, benchmark_limbs_div_exact_algorithms);\n    register_bench!(runner, benchmark_limbs_div_exact_to_out_algorithms);\n    register_bench!(runner, benchmark_limbs_div_exact_to_out_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_div_exact_assign_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_div_exact_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_div_exact_library_comparison);\n    register_bench!(runner, benchmark_natural_div_exact_algorithms);\n    register_bench!(runner, benchmark_natural_div_exact_evaluation_strategy);\n}\n\nfn demo_limbs_modular_invert_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen_var_22().get(gm, config).take(limit) {\n        println!(\n            \"limbs_modular_invert_limb({}) = {}\",\n            x,\n            limbs_modular_invert_limb::<Limb>(x)\n        );\n    }\n}\n\nfn demo_limbs_div_exact_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_29()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_div_exact_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_div_exact_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_div_exact_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; limbs_exact_div_limb_to_out(&mut out, {xs:?}, {y}); \\\n             out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_exact_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_29()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_div_exact_limb_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_div_exact_limb_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_div_exact_3(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_5().get(gm, config).take(limit) {\n        println!(\"limbs_div_exact_3({:?}) = {:?}\", xs, limbs_div_exact_3(&xs));\n    }\n}\n\nfn demo_limbs_div_exact_3_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs) in unsigned_vec_pair_gen_var_13().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_div_exact_3_to_out::<DoubleLimb, Limb>(&mut out, &xs);\n        println!(\"out := {out_old:?}; limbs_exact_div_3_to_out(&mut out, {xs:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_div_exact_3_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut xs in unsigned_vec_gen_var_5().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_div_exact_3_in_place(&mut xs);\n        println!(\"xs := {xs_old:?}; limbs_div_exact_3_in_place(&mut xs); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_modular_invert(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut is, ds) in unsigned_vec_pair_gen_var_12().get(gm, config).take(limit) {\n        let old_is = is.clone();\n        let mut scratch = vec![0; limbs_modular_invert_scratch_len(ds.len())];\n        limbs_modular_invert(&mut is, &ds, &mut scratch);\n        println!(\n            \"is := {old_is:?}; limbs_modular_invert(&mut is, {ds:?}, &mut scratch); is = {is:?}, \"\n        );\n    }\n}\n\nfn demo_limbs_modular_div_mod_schoolbook(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_14().get(gm, config).take(limit) {\n        let qs_old = qs.clone();\n        let ns_old = ns.clone();\n        let borrow = limbs_modular_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {qs_old:?}; ns := {ns_old:?}; \\\n             limbs_modular_div_mod_schoolbook(&mut qs, &mut ns, {ds:?}, {inverse}) = {borrow}; \\\n             qs = {qs:?}; ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_modular_div_mod_divide_and_conquer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_15().get(gm, config).take(limit) {\n        let qs_old = qs.clone();\n        let ns_old = ns.clone();\n        let borrow = limbs_modular_div_mod_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {qs_old:?}; ns := {ns_old:?}; \\\n             limbs_modular_div_mod_divide_and_conquer(&mut qs, &mut ns, {ds:?}, {inverse}) = \\\n             {borrow}; qs = {qs:?}; ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_modular_div_mod_barrett(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut rs, ns, ds) in unsigned_vec_quadruple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let qs_old = qs.clone();\n        let rs_old = rs.clone();\n        let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n        let borrow = limbs_modular_div_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n        println!(\n            \"qs := {qs_old:?}; rs := {rs_old:?}; limbs_modular_div_mod_divide_and_conquer(\\\n             &mut qs, &mut rs, {ns:?}, {ds:?} &mut scratch) = {borrow}; qs = {qs:?}; rs = {rs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_modular_div_schoolbook(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_13().get(gm, config).take(limit) {\n        let qs_old = qs.clone();\n        let ns_old = ns.clone();\n        limbs_modular_div_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {qs_old:?}; \\\n            ns := {ns_old:?}; limbs_modular_div_schoolbook(&mut qs, &mut ns, {ds:?}, {inverse}); \\\n             qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_modular_div_divide_and_conquer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_16().get(gm, config).take(limit) {\n        let qs_old = qs.clone();\n        let ns_old = ns.clone();\n        limbs_modular_div_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {qs_old:?}; ns := {ns_old:?}; \\\n             limbs_modular_div_divide_and_conquer(&mut qs, &mut ns, {ds:?}, {inverse}); \\\n             qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_modular_div_barrett(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, ds) in unsigned_vec_triple_gen_var_46().get(gm, config).take(limit) {\n        let qs_old = qs.clone();\n        let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n        limbs_modular_div_barrett(&mut qs, &ns, &ds, &mut scratch);\n        println!(\n            \"qs := {qs_old:?}; limbs_modular_div_barrett(&mut qs, {ns:?}, {ds:?} &mut scratch); \\\n            qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_modular_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds) in unsigned_vec_triple_gen_var_47().get(gm, config).take(limit) {\n        let ns_old = ns.clone();\n        let qs_old = qs.clone();\n        let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n        limbs_modular_div(&mut qs, &mut ns, &ds, &mut scratch);\n        println!(\n            \"qs := {qs_old:?}; limbs_modular_div(&mut qs, {ns_old:?}, {ds:?} &mut scratch); \\\n            qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_modular_div_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, ds) in unsigned_vec_triple_gen_var_47().get(gm, config).take(limit) {\n        let qs_old = qs.clone();\n        let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n        limbs_modular_div_ref(&mut qs, &ns, &ds, &mut scratch);\n        println!(\n            \"qs := {qs_old:?}; limbs_modular_div_ref(&mut qs, {ns:?}, {ds:?} &mut scratch); \\\n            qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_exact(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, ds) in unsigned_vec_pair_gen_var_14().get(gm, config).take(limit) {\n        println!(\n            \"limbs_div_exact({:?}, {:?}) = {:?}\",\n            ns,\n            ds,\n            limbs_div_exact(&ns, &ds)\n        );\n    }\n}\n\nfn demo_limbs_div_exact_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, mut ds) in unsigned_vec_triple_gen_var_48().get(gm, config).take(limit) {\n        let ns_old = ns.clone();\n        let ds_old = ds.clone();\n        let qs_old = qs.clone();\n        limbs_div_exact_to_out(&mut qs, &mut ns, &mut ds);\n        println!(\n            \"qs := {qs_old:?}; limbs_div_exact_to_out(&mut qs, {ns_old:?}, {ds_old:?}); \\\n            qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_exact_to_out_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds) in unsigned_vec_triple_gen_var_48().get(gm, config).take(limit) {\n        let ns_old = ns.clone();\n        let qs_old = qs.clone();\n        limbs_div_exact_to_out_val_ref(&mut qs, &mut ns, &ds);\n        println!(\n            \"qs := {qs_old:?}; limbs_div_exact_to_out_val_ref(&mut qs, {ns_old:?}, {ds:?}); \\\n            qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_exact_to_out_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, mut ds) in unsigned_vec_triple_gen_var_48().get(gm, config).take(limit) {\n        let ds_old = ds.clone();\n        let qs_old = qs.clone();\n        limbs_div_exact_to_out_ref_val(&mut qs, &ns, &mut ds);\n        println!(\n            \"qs := {qs_old:?}; limbs_div_exact_to_out_ref_val(&mut qs, {ns:?}, {ds_old:?}); \\\n            qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_exact_to_out_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, ns, ds) in unsigned_vec_triple_gen_var_48().get(gm, config).take(limit) {\n        let qs_old = qs.clone();\n        limbs_div_exact_to_out_ref_ref(&mut qs, &ns, &ds);\n        println!(\n            \"qs := {qs_old:?}; limbs_div_exact_to_out_ref_ref(&mut qs, {ns:?}, {ds:?}); \\\n            qs = {qs:?}\",\n        );\n    }\n}\n\nfn demo_natural_div_exact_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_6().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.div_exact_assign(y);\n        println!(\"x := {x_old}; x.div_exact_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_div_exact_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_6().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.div_exact_assign(&y);\n        println!(\"x := {x_old}; x.div_exact_assign(&{y}); x = {x}\");\n    }\n}\n\nfn demo_natural_div_exact(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_6().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.div_exact({}) = {}\", x_old, y_old, x.div_exact(y));\n    }\n}\n\nfn demo_natural_div_exact_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_6().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.div_exact(&{}) = {}\", x_old, y, x.div_exact(&y));\n    }\n}\n\nfn demo_natural_div_exact_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_6().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).div_exact({}) = {}\", x, y_old, (&x).div_exact(y));\n    }\n}\n\nfn demo_natural_div_exact_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_6().get(gm, config).take(limit) {\n        println!(\"(&{}).div_exact(&{}) = {}\", x, y, (&x).div_exact(&y));\n    }\n}\n\nfn benchmark_limbs_modular_invert_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_invert_limb(Limb)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(limbs_modular_invert_limb::<Limb>(x));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_exact_limb_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_limb(&[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_29().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"div_exact\", &mut |(xs, y)| {\n                no_out!(limbs_div_exact_limb(&xs, y));\n            }),\n            (\"div\", &mut |(xs, y)| no_out!(limbs_div_limb(&xs, y))),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_limb_to_out_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"div_exact\", &mut |(mut out, xs, y)| {\n                limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut out, &xs, y);\n            }),\n            (\"div\", &mut |(mut out, xs, y)| {\n                limbs_div_limb_to_out(&mut out, &xs, y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_limb_in_place_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_29().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"div_exact\", &mut |(mut xs, y)| {\n                limbs_div_exact_limb_in_place(&mut xs, y);\n            }),\n            (\"div\", &mut |(mut xs, y)| {\n                limbs_div_limb_in_place(&mut xs, y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_3_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_3(&[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"limbs_div_exact_3\", &mut |xs| {\n                no_out!(limbs_div_exact_3(&xs));\n            }),\n            (\"limbs_div_exact_limb_no_special_3\", &mut |xs| {\n                no_out!(limbs_div_exact_limb_no_special_3(&xs, 3));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_3_to_out_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_limb_to_out(&mut [Limb], 3)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\n                \"limbs_div_exact_limb_to_out_no_special_3\",\n                &mut |(mut out, xs)| {\n                    limbs_div_exact_limb_to_out_no_special_3::<DoubleLimb, Limb>(&mut out, &xs, 3);\n                },\n            ),\n            (\"limbs_div_exact_3_to_out\", &mut |(mut out, xs)| {\n                limbs_div_exact_3_to_out::<DoubleLimb, Limb>(&mut out, &xs);\n            }),\n            (\"limbs_div_exact_3_to_out_alt\", &mut |(mut out, xs)| {\n                limbs_div_exact_3_to_out_alt(&mut out, &xs);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_3_in_place_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_limb_in_place(&mut [Limb], 3)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\n                \"limbs_div_exact_limb_in_place_no_special_3\",\n                &mut |mut xs| limbs_div_exact_limb_in_place_no_special_3(&mut xs, 3),\n            ),\n            (\"limbs_div_exact_3_in_place\", &mut |mut xs| {\n                limbs_div_exact_3_in_place(&mut xs);\n            }),\n            (\"limbs_div_exact_3_in_place_alt\", &mut |mut xs| {\n                limbs_div_exact_3_in_place_alt(&mut xs);\n            }),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_limbs_modular_invert_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_invert(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_17().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"ds\"),\n        &mut [\n            (\"modular invert small\", &mut |(\n                mut is,\n                mut scratch,\n                ds,\n                inverse,\n            )| {\n                let n = ds.len();\n                limbs_modular_invert_small(n, &mut is, &mut scratch[..n], &ds, inverse);\n            }),\n            (\"modular invert\", &mut |(mut is, mut scratch, ds, _)| {\n                limbs_modular_invert(&mut is, &ds, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_modular_div_mod_schoolbook(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_div_mod_schoolbook(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        large_type_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"ns\"),\n        &mut [(\"Malachite\", &mut |(mut qs, mut ns, ds, inverse)| {\n            no_out!(limbs_modular_div_mod_schoolbook(\n                &mut qs, &mut ns, &ds, inverse\n            ));\n        })],\n    );\n}\n\n// use large params\nfn benchmark_limbs_modular_div_mod_divide_and_conquer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_div_mod_divide_and_conquer(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"ds\"),\n        &mut [\n            (\"schoolbook\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_modular_div_mod_schoolbook(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n            (\"divide-and-conquer\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_modular_div_mod_divide_and_conquer(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_modular_div_mod_barrett_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_div_mod_barrett(&mut [Limb], &mut [Limb], &[Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_quadruple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"divide-and-conquer\", &mut |(mut qs, _, mut ns, ds)| {\n                let inverse = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n                no_out!(limbs_modular_div_mod_divide_and_conquer(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n            (\"Barrett\", &mut |(mut qs, mut rs, ns, ds)| {\n                let mut scratch =\n                    vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n                no_out!(limbs_modular_div_mod_barrett(\n                    &mut qs,\n                    &mut rs,\n                    &ns,\n                    &ds,\n                    &mut scratch\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_modular_div_schoolbook(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_div_schoolbook(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        large_type_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"ns\"),\n        &mut [(\"Malachite\", &mut |(mut qs, mut ns, ds, inverse)| {\n            limbs_modular_div_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        })],\n    );\n}\n\n// use large params\nfn benchmark_limbs_modular_div_divide_and_conquer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_div_divide_and_conquer(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"schoolbook\", &mut |(mut qs, mut ns, ds, inverse)| {\n                limbs_modular_div_schoolbook(&mut qs, &mut ns, &ds, inverse);\n            }),\n            (\"divide-and-conquer\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                limbs_modular_div_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_modular_div_barrett_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_div_divide_and_conquer(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_46().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"divide-and-conquer\", &mut |(mut qs, mut ns, ds)| {\n                let inverse = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n                limbs_modular_div_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n            }),\n            (\"Barrett\", &mut |(mut qs, ns, ds)| {\n                let mut scratch =\n                    vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n                limbs_modular_div_barrett(&mut qs, &ns, &ds, &mut scratch);\n            }),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_limbs_modular_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_modular_div(&mut [Limb], &[Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_triple_gen_var_47().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\n                \"limbs_modular_div(&mut [Limb], &mut [Limb], &[Limb], &mut [Limb])\",\n                &mut |(mut qs, mut ns, ds)| {\n                    let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n                    limbs_modular_div(&mut qs, &mut ns, &ds, &mut scratch);\n                },\n            ),\n            (\n                \"limbs_modular_div_ref(&mut [Limb], &[Limb], &[Limb], &mut [Limb])\",\n                &mut |(mut qs, ns, ds)| {\n                    let mut scratch =\n                        vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n                    limbs_modular_div_ref(&mut qs, &ns, &ds, &mut scratch);\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact(&[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"div_exact\", &mut |(ns, ds)| {\n                no_out!(limbs_div_exact(&ns, &ds));\n            }),\n            (\"div\", &mut |(ns, ds)| no_out!(limbs_div(&ns, &ds))),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_to_out_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_to_out(&mut [Limb], &mut [Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_49().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"div\", &mut |(mut qs, mut ns, mut ds)| {\n                limbs_div_to_out(&mut qs, &mut ns, &mut ds);\n            }),\n            (\"div exact\", &mut |(mut qs, mut ns, mut ds)| {\n                limbs_div_exact_to_out(&mut qs, &mut ns, &mut ds);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_exact_to_out_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_exact_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_triple_gen_var_49().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\n                \"limbs_div_exact_to_out(&mut [Limb], &mut [Limb], &mut [Limb])\",\n                &mut |(mut qs, mut ns, mut ds)| limbs_div_exact_to_out(&mut qs, &mut ns, &mut ds),\n            ),\n            (\n                \"limbs_div_exact_to_out_val_ref(&mut [Limb], &mut [Limb], &[Limb])\",\n                &mut |(mut qs, mut ns, ds)| limbs_div_exact_to_out_val_ref(&mut qs, &mut ns, &ds),\n            ),\n            (\n                \"limbs_div_exact_to_out_ref_val(&mut [Limb], &[Limb], &mut [Limb])\",\n                &mut |(mut qs, ns, mut ds)| limbs_div_exact_to_out_ref_val(&mut qs, &ns, &mut ds),\n            ),\n            (\n                \"limbs_div_exact_to_out_ref_ref(&mut [Limb], &[Limb], &[Limb])\",\n                &mut |(mut qs, ns, ds)| limbs_div_exact_to_out_ref_ref(&mut qs, &ns, &ds),\n            ),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_natural_div_exact_assign_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_exact_assign(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"ordinary division\", &mut |(mut x, y)| x /= y),\n            (\"exact division\", &mut |(mut x, y)| x.div_exact_assign(y)),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_natural_div_exact_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_exact_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.div_exact_assign(Natural)\", &mut |(mut x, y)| {\n                x.div_exact_assign(y);\n            }),\n            (\"Natural.div_exact_assign(&Natural)\", &mut |(mut x, y)| {\n                x.div_exact_assign(&y);\n            }),\n        ],\n    );\n}\n\n// use large params\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_div_exact_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_exact(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_6_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"num\", &mut |((x, y), _, _)| no_out!(x / y)),\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.div_exact(y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_exact(&y))),\n        ],\n    );\n}\n\n// use large params\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_div_exact_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_exact(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"ordinary division\", &mut |(x, y)| no_out!(x / y)),\n            (\"exact division\", &mut |(x, y)| no_out!(x.div_exact(y))),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_natural_div_exact_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_exact(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.div_exact(Natural)\", &mut |(x, y)| {\n                no_out!(x.div_exact(y));\n            }),\n            (\"Natural.div_exact(&Natural)\", &mut |(x, y)| {\n                no_out!(x.div_exact(&y));\n            }),\n            (\"(&Natural).div_exact(Natural)\", &mut |(x, y)| {\n                no_out!((&x).div_exact(y));\n            }),\n            (\"(&Natural).div_exact(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).div_exact(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivAssignNegMod, CeilingDivNegMod, DivAssignMod, DivAssignRem, DivMod, DivRem, DivRound,\n    NegMod,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, quadruple_2_3_diff_vec_len_bucketer, quadruple_2_vec_len_bucketer,\n    quadruple_3_vec_len_bucketer, quadruple_4_vec_len_bucketer, quintuple_1_vec_len_bucketer,\n    triple_2_3_diff_vec_len_bucketer, triple_2_vec_len_bucketer, unsigned_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_12, unsigned_pair_gen_var_35, unsigned_vec_pair_gen_var_11,\n    unsigned_vec_triple_gen_var_50, unsigned_vec_triple_gen_var_51, unsigned_vec_triple_gen_var_52,\n    unsigned_vec_triple_gen_var_53, unsigned_vec_unsigned_pair_gen_var_22,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::div_mod::{\n    limbs_div_barrett_large_product, limbs_div_limb_in_place_mod, limbs_div_limb_mod,\n    limbs_div_limb_to_out_mod, limbs_div_mod, limbs_div_mod_barrett, limbs_div_mod_barrett_helper,\n    limbs_div_mod_barrett_large_helper, limbs_div_mod_barrett_scratch_len,\n    limbs_div_mod_by_two_limb_normalized, limbs_div_mod_divide_and_conquer, limbs_div_mod_extra,\n    limbs_div_mod_extra_in_place, limbs_div_mod_schoolbook, limbs_div_mod_three_limb_by_two_limb,\n    limbs_div_mod_to_out, limbs_invert_approx, limbs_invert_basecase_approx, limbs_invert_limb,\n    limbs_invert_newton_approx, limbs_two_limb_inverse_helper,\n};\nuse malachite_nz::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::bench::bucketers::{\n    limbs_div_mod_barrett_helper_bucketer, limbs_div_mod_barrett_product_bucketer,\n    limbs_div_mod_extra_bucketer, pair_1_natural_bit_bucketer, pair_2_pair_1_natural_bit_bucketer,\n    triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_11, large_type_gen_var_12, large_type_gen_var_18, large_type_gen_var_19,\n    large_type_gen_var_20, natural_pair_gen_var_5, natural_pair_gen_var_5_nrm,\n    natural_pair_gen_var_5_rm, unsigned_sextuple_gen_var_2, unsigned_vec_quadruple_gen_var_1,\n    unsigned_vec_quadruple_gen_var_4, unsigned_vec_quadruple_gen_var_5,\n};\nuse malachite_nz::test_util::natural::arithmetic::div_mod::{\n    limbs_div_limb_in_place_mod_alt, limbs_div_limb_in_place_mod_naive,\n    limbs_div_limb_to_out_mod_alt, limbs_div_limb_to_out_mod_naive, rug_ceiling_div_neg_mod,\n};\nuse num::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_invert_limb);\n    register_demo!(runner, demo_limbs_div_limb_mod);\n    register_demo!(runner, demo_limbs_div_limb_to_out_mod);\n    register_demo!(runner, demo_limbs_div_limb_in_place_mod);\n    register_demo!(runner, demo_limbs_div_mod_extra);\n    register_demo!(runner, demo_limbs_div_mod_extra_in_place);\n    register_demo!(runner, demo_limbs_two_limb_inverse_helper);\n    register_demo!(runner, demo_limbs_div_mod_three_limb_by_two_limb);\n    register_demo!(runner, demo_limbs_div_mod_by_two_limb_normalized);\n    register_demo!(runner, demo_limbs_div_mod_schoolbook);\n    register_demo!(runner, demo_limbs_div_mod_divide_and_conquer);\n    register_demo!(runner, demo_limbs_invert_basecase_approx);\n    register_demo!(runner, demo_limbs_invert_newton_approx);\n    register_demo!(runner, demo_limbs_invert_approx);\n    register_demo!(runner, demo_limbs_div_mod_barrett);\n    register_demo!(runner, demo_limbs_div_mod);\n    register_demo!(runner, demo_limbs_div_mod_to_out);\n    register_demo!(runner, demo_natural_div_assign_mod);\n    register_demo!(runner, demo_natural_div_assign_mod_ref);\n    register_demo!(runner, demo_natural_div_mod);\n    register_demo!(runner, demo_natural_div_mod_val_ref);\n    register_demo!(runner, demo_natural_div_mod_ref_val);\n    register_demo!(runner, demo_natural_div_mod_ref_ref);\n    register_demo!(runner, demo_natural_div_assign_rem);\n    register_demo!(runner, demo_natural_div_assign_rem_ref);\n    register_demo!(runner, demo_natural_div_rem);\n    register_demo!(runner, demo_natural_div_rem_val_ref);\n    register_demo!(runner, demo_natural_div_rem_ref_val);\n    register_demo!(runner, demo_natural_div_rem_ref_ref);\n    register_demo!(runner, demo_natural_ceiling_div_assign_neg_mod);\n    register_demo!(runner, demo_natural_ceiling_div_assign_neg_mod_ref);\n    register_demo!(runner, demo_natural_ceiling_div_neg_mod);\n    register_demo!(runner, demo_natural_ceiling_div_neg_mod_val_ref);\n    register_demo!(runner, demo_natural_ceiling_div_neg_mod_ref_val);\n    register_demo!(runner, demo_natural_ceiling_div_neg_mod_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_invert_limb);\n    register_bench!(runner, benchmark_limbs_div_limb_mod);\n    register_bench!(runner, benchmark_limbs_div_limb_to_out_mod_algorithms);\n    register_bench!(runner, benchmark_limbs_div_limb_in_place_mod_algorithms);\n    register_bench!(runner, benchmark_limbs_div_mod_extra);\n    register_bench!(runner, benchmark_limbs_div_mod_extra_in_place);\n    register_bench!(runner, benchmark_limbs_div_mod_by_two_limb_normalized);\n    register_bench!(runner, benchmark_limbs_div_mod_schoolbook);\n    register_bench!(\n        runner,\n        benchmark_limbs_div_mod_divide_and_conquer_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_invert_basecase_approx);\n    register_bench!(runner, benchmark_limbs_invert_newton_approx_algorithms);\n    register_bench!(runner, benchmark_limbs_invert_approx_algorithms);\n    register_bench!(runner, benchmark_limbs_div_mod_barrett);\n    register_bench!(\n        runner,\n        benchmark_limbs_div_mod_divide_and_conquer_to_barrett_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_div_mod_barrett_product_algorithms);\n    register_bench!(runner, benchmark_limbs_div_mod_barrett_helper_algorithms);\n    register_bench!(runner, benchmark_limbs_div_mod);\n    register_bench!(runner, benchmark_limbs_div_mod_to_out);\n    register_bench!(runner, benchmark_natural_div_assign_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_div_mod_library_comparison);\n    register_bench!(runner, benchmark_natural_div_mod_algorithms);\n    register_bench!(runner, benchmark_natural_div_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_div_assign_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_div_rem_library_comparison);\n    register_bench!(runner, benchmark_natural_div_rem_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_natural_ceiling_div_assign_neg_mod_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_ceiling_div_neg_mod_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_ceiling_div_neg_mod_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_ceiling_div_neg_mod_evaluation_strategy\n    );\n}\n\nfn demo_limbs_invert_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"limbs_invert_limb({}) = {}\",\n            x,\n            limbs_invert_limb::<DoubleLimb, Limb>(x)\n        );\n    }\n}\n\nfn demo_limbs_div_limb_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_div_limb_mod({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_div_limb_mod(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_div_limb_to_out_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let remainder = limbs_div_limb_to_out_mod(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; limbs_div_limb_to_out_mod(&mut out, {xs:?}, {y}) = {remainder}; \\\n             out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_limb_in_place_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let remainder = limbs_div_limb_in_place_mod(&mut xs, y);\n        println!(\n            \"limbs := {xs_old:?}; limbs_div_limb_in_place_mod(&mut limbs, {y}) = {remainder}; \\\n            limbs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_mod_extra(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, fraction_len, ns, d, d_inv, shift) in\n        large_type_gen_var_19().get(gm, config).take(limit)\n    {\n        let out_old = out.clone();\n        let remainder = limbs_div_mod_extra(&mut out, fraction_len, &ns, d, d_inv, shift);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_div_mod_extra(&mut out, {fraction_len}, {ns:?}, {d}, {d_inv}, {shift}) = \\\n            {remainder}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_mod_extra_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut ns, fraction_len, d, d_inv, shift) in\n        large_type_gen_var_18().get(gm, config).take(limit)\n    {\n        let ns_old = ns.clone();\n        let remainder = limbs_div_mod_extra_in_place(&mut ns, fraction_len, d, d_inv, shift);\n        println!(\n            \"ns := {ns_old:?}; \\\n            limbs_div_mod_extra_in_place(&mut ns, {fraction_len}, {d}, {d_inv}, {shift}) = \\\n            {remainder}; ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_two_limb_inverse_helper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (hi, lo) in unsigned_pair_gen_var_35().get(gm, config).take(limit) {\n        println!(\n            \"limbs_two_limb_inverse_helper({}, {}) = {}\",\n            hi,\n            lo,\n            limbs_two_limb_inverse_helper(hi, lo)\n        );\n    }\n}\n\nfn demo_limbs_div_mod_three_limb_by_two_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n2, n1, n0, d1, d0, inverse) in unsigned_sextuple_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"limbs_div_mod_three_limb_by_two_limb({}, {}, {}, {}, {}, {}) = {:?}\",\n            n2,\n            n1,\n            n0,\n            d1,\n            d0,\n            inverse,\n            limbs_div_mod_three_limb_by_two_limb(n2, n1, n0, d1, d0, inverse)\n        );\n    }\n}\n\nfn demo_limbs_div_mod_by_two_limb_normalized(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds) in unsigned_vec_triple_gen_var_53().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        let highest_q = limbs_div_mod_by_two_limb_normalized(&mut qs, &mut ns, &ds);\n        println!(\n            \"qs := {old_qs:?}; ns := {old_ns:?}; \\\n             limbs_div_mod_by_two_limb_normalized(&mut qs, &mut ns, {ds:?}) = {highest_q}; \\\n             qs = {qs:?}, ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_mod_schoolbook(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_11().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        let highest_q = limbs_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {old_qs:?}; \\\n            ns := {old_ns:?}; \\\n            limbs_div_mod_schoolbook(&mut qs, &mut ns, {ds:?}, {inverse}) = {highest_q}; \\\n             qs = {qs:?}, ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_mod_divide_and_conquer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_12().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        let highest_q = limbs_div_mod_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {old_qs:?}; ns := {old_ns:?}; \\\n             limbs_div_mod_divide_and_conquer(&mut qs, &mut ns, {ds:?}, {inverse}) = {highest_q}; \\\n             qs = {qs:?}, ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_invert_basecase_approx(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut is, ds, mut scratch) in unsigned_vec_triple_gen_var_50().get(gm, config).take(limit) {\n        let old_is = is.clone();\n        let old_scratch = scratch.clone();\n        let result_definitely_exact = limbs_invert_basecase_approx(&mut is, &ds, &mut scratch);\n        println!(\n            \"is := {old_is:?}; scratch := {old_scratch:?}; \\\n             limbs_invert_basecase_approx(&mut is, {ds:?}, &mut scratch) = \\\n             {result_definitely_exact}; \\\n             is = {is:?}, scratch = {scratch:?}\",\n        );\n    }\n}\n\nfn demo_limbs_invert_newton_approx(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut is, ds, mut scratch) in unsigned_vec_triple_gen_var_51().get(gm, config).take(limit) {\n        let old_is = is.clone();\n        let old_scratch = scratch.clone();\n        let result_definitely_exact = limbs_invert_newton_approx(&mut is, &ds, &mut scratch);\n        println!(\n            \"is := {old_is:?}; scratch := {old_scratch:?}; \\\n             limbs_invert_newton_approx(&mut is, {ds:?}, &mut scratch) = \\\n             {result_definitely_exact}; \\\n             is = {is:?}, scratch = {scratch:?}\",\n        );\n    }\n}\n\nfn demo_limbs_invert_approx(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut is, ds, mut scratch) in unsigned_vec_triple_gen_var_50().get(gm, config).take(limit) {\n        let old_is = is.clone();\n        let old_scratch = scratch.clone();\n        let result_definitely_exact = limbs_invert_approx(&mut is, &ds, &mut scratch);\n        println!(\n            \"is := {old_is:?}; scratch := {old_scratch:?}; \\\n             limbs_invert_approx(&mut is, {ds:?}, &mut scratch) = {result_definitely_exact}; \\\n             is = {is:?}, scratch = {scratch:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_mod_barrett(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut rs, ns, ds) in unsigned_vec_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_qs = qs.clone();\n        let old_rs = rs.clone();\n        let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n        let highest_q = limbs_div_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n        println!(\n            \"qs := {old_qs:?}; \\\n            rs := {old_rs:?}; \\\n            limbs_div_mod_barrett(&mut qs, &mut ns, {ns:?}, {ds:?}) = {highest_q}; \\\n             qs = {qs:?}, rs = {rs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_div_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, ds) in unsigned_vec_pair_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"limbs_div_mod({:?}, {:?}) = {:?}\",\n            ns,\n            ds,\n            limbs_div_mod(&ns, &ds)\n        );\n    }\n}\n\nfn demo_limbs_div_mod_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut rs, ns, ds) in unsigned_vec_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_qs = qs.clone();\n        let old_rs = rs.clone();\n        limbs_div_mod_to_out(&mut qs, &mut rs, &ns, &ds);\n        println!(\n            \"qs := {old_qs:?}; \\\n            rs := {old_rs:?}; limbs_div_mod_to_out(&mut qs, &mut ns, {ns:?}, {ds:?}); \\\n             qs = {qs:?}, rs = {rs:?}\",\n        );\n    }\n}\n\nfn demo_natural_div_assign_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let remainder = x.div_assign_mod(y);\n        println!(\"x := {x_old}; x.div_assign_mod({y_old}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_natural_div_assign_mod_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let remainder = x.div_assign_mod(&y);\n        println!(\"x := {x_old}; x.div_assign_mod(&{y}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_natural_div_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.div_mod({}) = {:?}\", x_old, y_old, x.div_mod(y));\n    }\n}\n\nfn demo_natural_div_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.div_mod(&{}) = {:?}\", x_old, y, x.div_mod(&y));\n    }\n}\n\nfn demo_natural_div_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).div_mod({}) = {:?}\", x, y_old, (&x).div_mod(y));\n    }\n}\n\nfn demo_natural_div_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\"(&{}).div_mod(&{}) = {:?}\", x, y, (&x).div_mod(&y));\n    }\n}\n\nfn demo_natural_div_assign_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let remainder = x.div_assign_rem(y);\n        println!(\"x := {x_old}; x.div_assign_rem({y_old}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_natural_div_assign_rem_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let remainder = x.div_assign_rem(&y);\n        println!(\"x := {x_old}; x.div_assign_rem(&{y}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_natural_div_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.div_rem({}) = {:?}\", x_old, y_old, x.div_rem(y));\n    }\n}\n\nfn demo_natural_div_rem_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.div_rem(&{}) = {:?}\", x_old, y, x.div_rem(&y));\n    }\n}\n\nfn demo_natural_div_rem_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).div_rem({}) = {:?}\", x, y_old, (&x).div_rem(y));\n    }\n}\n\nfn demo_natural_div_rem_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\"(&{}).div_rem(&{}) = {:?}\", x, y, (&x).div_rem(&y));\n    }\n}\n\nfn demo_natural_ceiling_div_assign_neg_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let remainder = x.ceiling_div_assign_neg_mod(y);\n        println!(\"x := {x_old}; x.ceiling_div_assign_neg_mod({y_old}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_natural_ceiling_div_assign_neg_mod_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let remainder = x.ceiling_div_assign_neg_mod(&y);\n        println!(\"x := {x_old}; x.ceiling_div_assign_neg_mod(&{y}) = {remainder}; x = {x}\");\n    }\n}\n\nfn demo_natural_ceiling_div_neg_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.ceiling_div_neg_mod({}) = {:?}\",\n            x_old,\n            y_old,\n            x.ceiling_div_neg_mod(y)\n        );\n    }\n}\n\nfn demo_natural_ceiling_div_neg_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{}.ceiling_div_neg_mod(&{}) = {:?}\",\n            x_old,\n            y,\n            x.ceiling_div_neg_mod(&y)\n        );\n    }\n}\n\nfn demo_natural_ceiling_div_neg_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).ceiling_div_neg_mod({}) = {:?}\",\n            x,\n            y_old,\n            (&x).ceiling_div_neg_mod(y)\n        );\n    }\n}\n\nfn demo_natural_ceiling_div_neg_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).ceiling_div_neg_mod(&{}) = {:?}\",\n            x,\n            y,\n            (&x).ceiling_div_neg_mod(&y)\n        );\n    }\n}\n\nfn benchmark_limbs_invert_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_invert_limb(Limb)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(limbs_invert_limb::<DoubleLimb, Limb>(x));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_limb_mod(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_div_limb_mod(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_div_limb_mod(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_limb_to_out_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_limb_to_out_mod(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut out, xs, y)| {\n                no_out!(limbs_div_limb_to_out_mod(&mut out, &xs, y));\n            }),\n            (\"alt\", &mut |(mut out, xs, y)| {\n                no_out!(limbs_div_limb_to_out_mod_alt(&mut out, &xs, y));\n            }),\n            (\"naive\", &mut |(mut out, xs, y)| {\n                no_out!(limbs_div_limb_to_out_mod_naive(&mut out, &xs, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_limb_in_place_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_limb_in_place_mod(&mut [Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut xs, y)| {\n                no_out!(limbs_div_limb_in_place_mod(&mut xs, y));\n            }),\n            (\"alt\", &mut |(mut xs, y)| {\n                no_out!(limbs_div_limb_in_place_mod_alt(&mut xs, y));\n            }),\n            (\"naive\", &mut |(mut xs, y)| {\n                no_out!(limbs_div_limb_in_place_mod_naive(&mut xs, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_mod_extra(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_div_mod_extra(&mut [Limb], usize, &[Limb], Limb, Limb, u64)\",\n        BenchmarkType::Single,\n        large_type_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limbs_div_mod_extra_bucketer(),\n        &mut [(\"Malachite\", &mut |(\n            mut out,\n            fraction_len,\n            ns,\n            d,\n            d_inv,\n            shift,\n        )| {\n            no_out!(limbs_div_mod_extra(\n                &mut out,\n                fraction_len,\n                &ns,\n                d,\n                d_inv,\n                shift\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_mod_extra_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_mod_extra(&mut [Limb], usize, Limb, Limb, u64)\",\n        BenchmarkType::Single,\n        large_type_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quintuple_1_vec_len_bucketer(\"out\"),\n        &mut [(\"Malachite\", &mut |(\n            mut ns,\n            fraction_len,\n            d,\n            d_inv,\n            shift,\n        )| {\n            no_out!(limbs_div_mod_extra_in_place(\n                &mut ns,\n                fraction_len,\n                d,\n                d_inv,\n                shift\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_mod_by_two_limb_normalized(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_mod_by_two_limb_normalized(&mut [Limb], &mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_53().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ns\"),\n        &mut [(\"Malachite\", &mut |(mut qs, mut ns, ds)| {\n            no_out!(limbs_div_mod_by_two_limb_normalized(&mut qs, &mut ns, &ds));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_mod_schoolbook(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_mod_schoolbook(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        large_type_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"ns\"),\n        &mut [(\"Malachite\", &mut |(mut qs, mut ns, ds, inverse)| {\n            no_out!(limbs_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse));\n        })],\n    );\n}\n\n// use large params\nfn benchmark_limbs_div_mod_divide_and_conquer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_mod_divide_and_conquer(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"Schoolbook\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse));\n            }),\n            (\"divide-and-conquer\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_div_mod_divide_and_conquer(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_invert_basecase_approx(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_invert_basecase_approx(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_50().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ds\"),\n        &mut [(\"Malachite\", &mut |(mut is, ds, mut scratch)| {\n            no_out!(limbs_invert_basecase_approx(&mut is, &ds, &mut scratch));\n        })],\n    );\n}\n\n// use very large params\nfn benchmark_limbs_invert_newton_approx_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_invert_newton_approx(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_51().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ds\"),\n        &mut [\n            (\"basecase\", &mut |(mut is, ds, mut scratch)| {\n                no_out!(limbs_invert_basecase_approx(&mut is, &ds, &mut scratch));\n            }),\n            (\"Newton\", &mut |(mut is, ds, mut scratch)| {\n                no_out!(limbs_invert_newton_approx(&mut is, &ds, &mut scratch));\n            }),\n        ],\n    );\n}\n\n// use very large params\nfn benchmark_limbs_invert_approx_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_invert_approx(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_50().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ds\"),\n        &mut [\n            (\"basecase\", &mut |(mut is, ds, mut scratch)| {\n                no_out!(limbs_invert_basecase_approx(&mut is, &ds, &mut scratch));\n            }),\n            (\"default\", &mut |(mut is, ds, mut scratch)| {\n                no_out!(limbs_invert_approx(&mut is, &ds, &mut scratch));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_mod_barrett(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_div_mod_barrett(&mut [Limb], &mut [Limb], &[Limb], &[Limb], &mut Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_quadruple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_4_vec_len_bucketer(\"ds\"),\n        &mut [(\"Malachite\", &mut |(mut qs, mut rs, ns, ds)| {\n            let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n            no_out!(limbs_div_mod_barrett(\n                &mut qs,\n                &mut rs,\n                &ns,\n                &ds,\n                &mut scratch\n            ));\n        })],\n    );\n}\n\n// use very large params\nfn benchmark_limbs_div_mod_divide_and_conquer_to_barrett_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_mod_barrett(&mut [Limb], &mut [Limb], &[Limb], &[Limb], &mut Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_52::<Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"divide-and-conquer\", &mut |(mut qs, mut ns, mut ds)| {\n                let q_len = ns.len() - ds.len() + 1;\n                ds[q_len - 1].set_bit(Limb::WIDTH - 1);\n                let inverse = limbs_two_limb_inverse_helper(ds[q_len - 1], ds[q_len - 2]);\n                no_out!(limbs_div_mod_divide_and_conquer(\n                    &mut qs,\n                    &mut ns[..q_len << 1],\n                    &ds[..q_len],\n                    inverse\n                ));\n            }),\n            (\"Barrett\", &mut |(mut qs, mut ns, mut ds)| {\n                let d_len = ds.len();\n                let mut rs = vec![0; d_len];\n                let q_len = ns.len() - d_len + 1;\n                let q_len_2 = q_len << 1;\n                ds[q_len - 1].set_bit(Limb::WIDTH - 1);\n                limbs_two_limb_inverse_helper(ds[q_len - 1], ds[q_len - 2]);\n                let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(q_len_2, q_len)];\n                limbs_div_mod_barrett(&mut qs, &mut rs, &ns[..q_len_2], &ds[..q_len], &mut scratch);\n                ns[..q_len].copy_from_slice(&rs[..q_len]);\n            }),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_limbs_div_mod_barrett_product_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_barrett_large_product(&mut [Limb], &[Limb], &[Limb], &[Limb], usize, usize)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limbs_div_mod_barrett_product_bucketer(),\n        &mut [\n            (\"limbs_mul_greater_to_out\", &mut |(\n                mut scratch,\n                ds,\n                qs,\n                _,\n                _,\n                _,\n            )| {\n                let mut mul_scratch =\n                    vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs.len())];\n                no_out!(limbs_mul_greater_to_out(\n                    &mut scratch,\n                    &ds,\n                    &qs,\n                    &mut mul_scratch,\n                ));\n            }),\n            (\"limbs_div_barrett_large_product\", &mut |(\n                mut scratch,\n                ds,\n                qs,\n                rs_hi,\n                scratch_len,\n                i_len,\n            )| {\n                limbs_div_barrett_large_product(&mut scratch, &ds, &qs, &rs_hi, scratch_len, i_len);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_mod_barrett_helper_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_div_mod_barrett_helper(&mut [Limb], &mut [Limb], &[Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_quadruple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limbs_div_mod_barrett_helper_bucketer(),\n        &mut [\n            (\"limbs_div_mod_barrett_helper\", &mut |(\n                mut qs,\n                mut rs,\n                ns,\n                ds,\n            )| {\n                let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n                let q_len = ns.len() - ds.len();\n                no_out!(limbs_div_mod_barrett_helper(\n                    &mut qs[..q_len],\n                    &mut rs[..ds.len()],\n                    &ns,\n                    &ds,\n                    &mut scratch\n                ));\n            }),\n            (\"limbs_div_mod_barrett_large_helper\", &mut |(\n                mut qs,\n                mut rs,\n                ns,\n                ds,\n            )| {\n                let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n                let q_len = ns.len() - ds.len();\n                no_out!(limbs_div_mod_barrett_large_helper(\n                    &mut qs[..q_len],\n                    &mut rs[..ds.len()],\n                    &ns,\n                    &ds,\n                    &mut scratch\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_div_mod(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_div_mod(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [(\"Malachite\", &mut |(ns, ds)| {\n            no_out!(limbs_div_mod(&ns, &ds));\n        })],\n    );\n}\n\nfn benchmark_limbs_div_mod_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_div_mod_to_out(&mut [Limb], &mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"ns\"),\n        &mut [(\"Malachite\", &mut |(mut qs, mut rs, ns, ds)| {\n            limbs_div_mod_to_out(&mut qs, &mut rs, &ns, &ds);\n        })],\n    );\n}\n\nfn benchmark_natural_div_assign_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_assign_mod(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.div_assign_mod(Natural)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_mod(y));\n            }),\n            (\"Natural.div_mod(&Natural)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_mod(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_div_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_mod(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.div_mod(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.div_mod_floor(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_rem_floor(y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_natural_div_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_mod(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.div_mod(y))),\n            (\"using / and %\", &mut |(x, y)| no_out!((&x / &y, x % y))),\n        ],\n    );\n}\n\nfn benchmark_natural_div_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_mod(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.div_mod(Natural)\", &mut |(x, y)| {\n                no_out!(x.div_mod(y));\n            }),\n            (\"Natural.div_mod(&Natural)\", &mut |(x, y)| {\n                no_out!(x.div_mod(&y));\n            }),\n            (\"(&Natural).div_mod(Natural)\", &mut |(x, y)| {\n                no_out!((&x).div_mod(y));\n            }),\n            (\"(&Natural).div_mod(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).div_mod(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_div_assign_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_assign_rem(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.div_assign_rem(Natural)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_rem(y));\n            }),\n            (\"Natural.div_assign_rem(&Natural)\", &mut |(mut x, y)| {\n                no_out!(x.div_assign_rem(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_div_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_rem(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.div_rem(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.div_rem(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_rem(y))),\n        ],\n    );\n}\n\nfn benchmark_natural_div_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_mod(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.div_rem(Natural)\", &mut |(x, y)| {\n                no_out!(x.div_rem(y));\n            }),\n            (\"Natural.div_rem(&Natural)\", &mut |(x, y)| {\n                no_out!(x.div_rem(&y));\n            }),\n            (\"(&Natural).div_rem(Natural)\", &mut |(x, y)| {\n                no_out!((&x).div_rem(y));\n            }),\n            (\"(&Natural).div_rem(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).div_rem(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_div_assign_neg_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_div_assign_neg_mod(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Natural.ceiling_div_assign_neg_mod(Natural)\",\n                &mut |(mut x, y)| no_out!(x.ceiling_div_assign_neg_mod(y)),\n            ),\n            (\n                \"Natural.ceiling_div_assign_neg_mod(&Natural)\",\n                &mut |(mut x, y)| no_out!(x.ceiling_div_assign_neg_mod(&y)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_div_neg_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_div_neg_mod(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.ceiling_div_neg_mod(y));\n            }),\n            (\"rug\", &mut |((x, y), _)| {\n                no_out!(rug_ceiling_div_neg_mod(x, y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_natural_ceiling_div_neg_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_div_neg_mod(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.ceiling_div_neg_mod(y))),\n            (\"using div_round and %\", &mut |(x, y)| {\n                ((&x).div_round(&y, Ceiling), x.neg_mod(y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_div_neg_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_div_neg_mod(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.ceiling_div_neg_mod(Natural)\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_neg_mod(y));\n            }),\n            (\"Natural.ceiling_div_neg_mod(&Natural)\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_neg_mod(&y));\n            }),\n            (\"(&Natural).ceiling_div_neg_mod(Natural)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_div_neg_mod(y));\n            }),\n            (\"(&Natural).ceiling_div_neg_mod(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_div_neg_mod(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CeilingDivNegMod, DivRound, DivRoundAssign};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::bucketers::triple_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_rounding_mode_triple_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::div_round::limbs_limb_div_round_limbs;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_natural_bit_bucketer, pair_2_pair_1_natural_bit_bucketer, triple_1_natural_bit_bucketer,\n    triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_natural_rounding_mode_triple_gen_var_1, natural_pair_gen_var_5,\n    natural_pair_gen_var_5_nrm, natural_pair_gen_var_5_rm,\n};\nuse num::Integer;\nuse rug::ops::DivRounding;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_limb_div_round_limbs);\n    register_demo!(runner, demo_natural_div_round);\n    register_demo!(runner, demo_natural_div_round_val_ref);\n    register_demo!(runner, demo_natural_div_round_ref_val);\n    register_demo!(runner, demo_natural_div_round_ref_ref);\n    register_demo!(runner, demo_natural_div_round_assign);\n    register_demo!(runner, demo_natural_div_round_assign_ref);\n\n    register_bench!(runner, benchmark_limbs_limb_div_round_limbs);\n    register_bench!(runner, benchmark_natural_div_round_down_library_comparison);\n    register_bench!(runner, benchmark_natural_div_round_floor_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_natural_div_round_ceiling_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_div_round_ceiling_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_div_round_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_div_round_evaluation_strategy);\n}\n\nfn demo_limbs_limb_div_round_limbs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ys, x, rm) in unsigned_vec_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_limb_div_round_limbs({}, {:?}, {}) = {:?}\",\n            x,\n            ys,\n            rm,\n            limbs_limb_div_round_limbs(x, &ys, rm)\n        );\n    }\n}\n\nfn demo_natural_div_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.div_round({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.div_round(y, rm)\n        );\n    }\n}\n\nfn demo_natural_div_round_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"{}.div_round(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.div_round(&y, rm)\n        );\n    }\n}\n\nfn demo_natural_div_round_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).div_round({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            (&x).div_round(y, rm)\n        );\n    }\n}\n\nfn demo_natural_div_round_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).div_round(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            (&x).div_round(&y, rm)\n        );\n    }\n}\n\nfn demo_natural_div_round_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in natural_natural_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.div_round_assign(y, rm);\n        println!(\"x := {x_old}; x.div_round_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_natural_div_round_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in natural_natural_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.div_round_assign(&y, rm);\n        println!(\"x := {x_old}; x.div_round_assign(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn benchmark_limbs_limb_div_round_limbs(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_limb_div_round_limbs(Limb, &[Limb], RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"ys\"),\n        &mut [(\"Malachite\", &mut |(ys, x, rm)| {\n            no_out!(limbs_limb_div_round_limbs(x, &ys, rm));\n        })],\n    );\n}\n\nfn benchmark_natural_div_round_down_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_round(Natural, Down)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.div_round(y, Down));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.div_trunc(y))),\n        ],\n    );\n}\n\nfn benchmark_natural_div_round_floor_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_round(Natural, Floor)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| {\n                no_out!(x.div_round(y, Floor));\n            }),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.div_floor(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.div_floor(y))),\n        ],\n    );\n}\n\nfn benchmark_natural_div_round_ceiling_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_round(Natural, Ceiling)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.div_round(y, Ceiling));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.div_ceil(y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_natural_div_round_ceiling_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_round(Natural, Ceiling)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.div_round(y, Ceiling))),\n            (\"using ceiling_div_neg_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_neg_mod(y).0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_div_round_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_round_assign(Natural, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Natural.div_round_assign(Natural, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_round_assign(y, rm)),\n            ),\n            (\n                \"Natural.div_round_assign(&Natural, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.div_round_assign(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_div_round_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.div_round(Natural, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Natural.div_round(Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_round(y, rm)),\n            ),\n            (\n                \"Natural.div_round(&Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.div_round(&y, rm)),\n            ),\n            (\n                \"(&Natural).div_round(Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).div_round(y, rm)),\n            ),\n            (\n                \"(&Natural).div_round(&Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).div_round(&y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::slices::slice_test_zero;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_15, unsigned_vec_pair_gen_var_16,\n    unsigned_vec_unsigned_pair_gen_var_22,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::divisible_by::{\n    limbs_divisible_by, limbs_divisible_by_limb, limbs_divisible_by_ref_ref,\n    limbs_divisible_by_ref_val, limbs_divisible_by_val_ref,\n};\nuse malachite_nz::natural::arithmetic::mod_op::{limbs_mod, limbs_mod_limb};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_natural_bit_bucketer, triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_pair_gen, natural_pair_gen_nrm};\nuse malachite_nz::test_util::natural::arithmetic::divisible_by::{\n    combined_limbs_divisible_by_limb, num_divisible_by,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_divisible_by_limb);\n    register_demo!(runner, demo_limbs_divisible_by);\n    register_demo!(runner, demo_limbs_divisible_by_val_ref);\n    register_demo!(runner, demo_limbs_divisible_by_ref_val);\n    register_demo!(runner, demo_limbs_divisible_by_ref_ref);\n    register_demo!(runner, demo_natural_divisible_by);\n    register_demo!(runner, demo_natural_divisible_by_val_ref);\n    register_demo!(runner, demo_natural_divisible_by_ref_val);\n    register_demo!(runner, demo_natural_divisible_by_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_divisible_by_limb_algorithms);\n    register_bench!(runner, benchmark_limbs_divisible_by_algorithms);\n    register_bench!(runner, benchmark_limbs_divisible_by_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_divisible_by_algorithms);\n    register_bench!(runner, benchmark_natural_divisible_by_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_divisible_by_library_comparison);\n}\n\nfn demo_limbs_divisible_by_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_divisible_by_limb({:?}, {}) = {}\",\n            xs,\n            y,\n            limbs_divisible_by_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_divisible_by(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut ns, mut ds) in unsigned_vec_pair_gen_var_15().get(gm, config).take(limit) {\n        let ns_old = ns.clone();\n        let ds_old = ds.clone();\n        println!(\n            \"limbs_divisible_by({:?}, {:?}) = {}\",\n            ns_old,\n            ds_old,\n            limbs_divisible_by(&mut ns, &mut ds)\n        );\n    }\n}\n\nfn demo_limbs_divisible_by_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut ns, ds) in unsigned_vec_pair_gen_var_15().get(gm, config).take(limit) {\n        let ns_old = ns.clone();\n        println!(\n            \"limbs_divisible_by_val_ref({:?}, {:?}) = {}\",\n            ns_old,\n            ds,\n            limbs_divisible_by_val_ref(&mut ns, &ds)\n        );\n    }\n}\n\nfn demo_limbs_divisible_by_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, mut ds) in unsigned_vec_pair_gen_var_15().get(gm, config).take(limit) {\n        let ds_old = ds.clone();\n        println!(\n            \"limbs_divisible_by_ref_val({:?}, {:?}) = {}\",\n            ns,\n            ds_old,\n            limbs_divisible_by_ref_val(&ns, &mut ds)\n        );\n    }\n}\n\nfn demo_limbs_divisible_by_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, ds) in unsigned_vec_pair_gen_var_15().get(gm, config).take(limit) {\n        println!(\n            \"limbs_divisible_by_ref_ref({:?}, {:?}) = {}\",\n            ns,\n            ds,\n            limbs_divisible_by_ref_ref(&ns, &ds)\n        );\n    }\n}\n\nfn demo_natural_divisible_by(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        if x.divisible_by(y) {\n            println!(\"{x_old} is divisible by {y_old}\");\n        } else {\n            println!(\"{x_old} is not divisible by {y_old}\");\n        }\n    }\n}\n\nfn demo_natural_divisible_by_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        if x.divisible_by(&y) {\n            println!(\"{x_old} is divisible by {y}\");\n        } else {\n            println!(\"{x_old} is not divisible by {y}\");\n        }\n    }\n}\n\nfn demo_natural_divisible_by_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        if (&x).divisible_by(y) {\n            println!(\"{x} is divisible by {y_old}\");\n        } else {\n            println!(\"{x} is not divisible by {y_old}\");\n        }\n    }\n}\n\nfn demo_natural_divisible_by_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        if (&x).divisible_by(y) {\n            println!(\"{x} is divisible by {y_old}\");\n        } else {\n            println!(\"{x} is not divisible by {y_old}\");\n        }\n    }\n}\n\n// use large params\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_limbs_divisible_by_limb_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_divisible_by_limb(&[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_divisible_by_limb\", &mut |(xs, y)| {\n                no_out!(limbs_divisible_by_limb(&xs, y));\n            }),\n            (\"divisibility using limbs_mod_limb\", &mut |(xs, y)| {\n                no_out!(limbs_mod_limb::<DoubleLimb, Limb>(&xs, y) == 0);\n            }),\n            (\"combined_limbs_divisible_by_limb\", &mut |(xs, y)| {\n                no_out!(combined_limbs_divisible_by_limb(&xs, y));\n            }),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_limbs_divisible_by_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_divisible_by(&[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_divisible_by\", &mut |(mut ns, mut ds)| {\n                no_out!(limbs_divisible_by(&mut ns, &mut ds));\n            }),\n            (\"divisibility using limbs_mod\", &mut |(ns, ds)| {\n                no_out!(slice_test_zero(&limbs_mod(&ns, &ds)));\n            }),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_limbs_divisible_by_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_divisible_by(&[Limb], &[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\n                \"limbs_divisible_by(&mut [Limb], &mut [Limb])\",\n                &mut |(mut ns, mut ds)| no_out!(limbs_divisible_by(&mut ns, &mut ds)),\n            ),\n            (\n                \"limbs_divisible_by_val_ref(&mut [Limb], &mut [Limb])\",\n                &mut |(mut ns, ds)| no_out!(limbs_divisible_by_val_ref(&mut ns, &ds)),\n            ),\n            (\n                \"limbs_divisible_by_ref_val(&mut [Limb], &mut [Limb])\",\n                &mut |(ns, mut ds)| no_out!(limbs_divisible_by_ref_val(&ns, &mut ds)),\n            ),\n            (\n                \"limbs_divisible_by_ref_ref(&mut [Limb], &mut [Limb])\",\n                &mut |(ns, ds)| no_out!(limbs_divisible_by_ref_ref(&ns, &ds)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::short_circuit_statement, unused_must_use)]\nfn benchmark_natural_divisible_by_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.divisible_by(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.divisible_by(y))),\n            (\"using %\", &mut |(x, y)| {\n                no_out!(x == 0 || y != 0 && x % y == 0);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_divisible_by_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.divisible_by(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.divisible_by(Natural)\", &mut |(x, y)| {\n                no_out!(x.divisible_by(y));\n            }),\n            (\"Natural.divisible_by(&Natural)\", &mut |(x, y)| {\n                no_out!(x.divisible_by(&y));\n            }),\n            (\"(&Natural).divisible_by(Natural)\", &mut |(x, y)| {\n                no_out!((&x).divisible_by(y));\n            }),\n            (\"(&Natural).divisible_by(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).divisible_by(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_divisible_by_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.divisible_by(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| {\n                no_out!(x.divisible_by(y));\n            }),\n            (\"num\", &mut |((x, y), _, _)| {\n                no_out!(num_divisible_by(&x, &y));\n            }),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.is_divisible(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_20, unsigned_vec_unsigned_pair_gen_var_22,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::divisible_by_power_of_2::limbs_divisible_by_power_of_2;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_natural_bit_bucketer, pair_2_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_4_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_divisible_by_power_of_2);\n    register_demo!(runner, demo_natural_divisible_by_power_of_2);\n\n    register_bench!(runner, benchmark_limbs_divisible_by_power_of_2);\n    register_bench!(\n        runner,\n        benchmark_natural_divisible_by_power_of_2_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_divisible_by_power_of_2_algorithms);\n}\n\nfn demo_limbs_divisible_by_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_divisible_by_power_of_2({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_divisible_by_power_of_2(&xs, pow)\n        );\n    }\n}\n\nfn demo_natural_divisible_by_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.divisible_by_power_of_2(pow) {\n            println!(\"{n} is divisible by 2^{pow}\");\n        } else {\n            println!(\"{n} is not divisible by 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_limbs_divisible_by_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_divisible_by_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, pow)| {\n            no_out!(limbs_divisible_by_power_of_2(&xs, pow));\n        })],\n    );\n}\n\nfn benchmark_natural_divisible_by_power_of_2_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.divisible_by_power_of_2(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (n, pow))| {\n                no_out!(n.divisible_by_power_of_2(pow));\n            }),\n            (\"rug\", &mut |((n, pow), _)| {\n                n.is_divisible_2pow(u32::exact_from(pow));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_divisible_by_power_of_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.divisible_by_power_of_2(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.divisible_by_power_of_2(u64)\", &mut |(n, pow)| {\n                no_out!(n.divisible_by_power_of_2(pow));\n            }),\n            (\n                \"Natural.trailing_zeros().map_or(true, |z| z >= u64)\",\n                &mut |(n, pow)| no_out!(n.trailing_zeros().is_none_or(|z| z >= pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleBy, EqMod, UnsignedAbs};\nuse malachite_base::test_util::bench::bucketers::{\n    triple_1_2_vec_max_len_bucketer, triple_1_bit_bucketer, triple_1_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_21, unsigned_vec_triple_gen_var_36,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_7,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_10,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::arithmetic::eq_mod::{\n    limbs_eq_limb_mod, limbs_eq_limb_mod_limb, limbs_eq_limb_mod_ref_ref,\n    limbs_eq_limb_mod_ref_val, limbs_eq_limb_mod_val_ref, limbs_eq_mod_limb_ref_ref,\n    limbs_eq_mod_limb_ref_val, limbs_eq_mod_limb_val_ref, limbs_eq_mod_ref_ref_ref,\n    limbs_eq_mod_ref_ref_val, limbs_eq_mod_ref_val_ref, limbs_eq_mod_ref_val_val,\n    limbs_limb_mod_exact_odd_limb, limbs_mod_exact_odd_limb,\n};\nuse malachite_nz::natural::arithmetic::mod_op::limbs_mod_limb;\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_triple_1_2_natural_max_bit_bucketer, triple_1_2_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_triple_gen, natural_triple_gen_rm};\nuse malachite_nz::test_util::natural::arithmetic::eq_mod::{\n    combined_limbs_eq_limb_mod_limb, limbs_eq_limb_mod_naive_1, limbs_eq_limb_mod_naive_2,\n    limbs_eq_mod_limb_naive_1, limbs_eq_mod_limb_naive_2, limbs_eq_mod_naive_1,\n    limbs_eq_mod_naive_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_limb_mod_exact_odd_limb);\n    register_demo!(runner, demo_limbs_mod_exact_odd_limb);\n    register_demo!(runner, demo_limbs_eq_limb_mod_limb);\n    register_demo!(runner, demo_limbs_eq_limb_mod);\n    register_demo!(runner, demo_limbs_eq_limb_mod_val_ref);\n    register_demo!(runner, demo_limbs_eq_limb_mod_ref_val);\n    register_demo!(runner, demo_limbs_eq_limb_mod_ref_ref);\n    register_demo!(runner, demo_limbs_eq_mod_limb_val_ref);\n    register_demo!(runner, demo_limbs_eq_mod_limb_ref_val);\n    register_demo!(runner, demo_limbs_eq_mod_limb_ref_ref);\n    register_demo!(runner, demo_limbs_eq_mod_ref_val_val);\n    register_demo!(runner, demo_limbs_eq_mod_ref_val_ref);\n    register_demo!(runner, demo_limbs_eq_mod_ref_ref_val);\n    register_demo!(runner, demo_limbs_eq_mod_ref_ref_ref);\n    register_demo!(runner, demo_natural_eq_mod);\n    register_demo!(runner, demo_natural_eq_mod_val_val_ref);\n    register_demo!(runner, demo_natural_eq_mod_val_ref_val);\n    register_demo!(runner, demo_natural_eq_mod_val_ref_ref);\n    register_demo!(runner, demo_natural_eq_mod_ref_val_val);\n    register_demo!(runner, demo_natural_eq_mod_ref_val_ref);\n    register_demo!(runner, demo_natural_eq_mod_ref_ref_val);\n    register_demo!(runner, demo_natural_eq_mod_ref_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_limb_mod_exact_odd_limb);\n    register_bench!(runner, benchmark_limbs_mod_exact_odd_limb);\n    register_bench!(runner, benchmark_limbs_eq_limb_mod_limb_algorithms);\n    register_bench!(runner, benchmark_limbs_eq_limb_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_limbs_eq_limb_mod_algorithms);\n    register_bench!(runner, benchmark_limbs_eq_mod_limb_evaluation_strategy);\n    register_bench!(runner, benchmark_limbs_eq_mod_limb_algorithms);\n    register_bench!(runner, benchmark_limbs_eq_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_limbs_eq_mod_algorithms);\n    register_bench!(runner, benchmark_natural_eq_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_eq_mod_library_comparison);\n    register_bench!(runner, benchmark_natural_eq_mod_algorithms);\n}\n\nfn demo_limbs_limb_mod_exact_odd_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d, carry) in unsigned_triple_gen_var_21().get(gm, config).take(limit) {\n        println!(\n            \"limbs_limb_mod_exact_odd_limb({}, {}, {}) = {}\",\n            n,\n            d,\n            carry,\n            limbs_limb_mod_exact_odd_limb(n, d, carry)\n        );\n    }\n}\n\nfn demo_limbs_mod_exact_odd_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d, carry) in unsigned_vec_unsigned_unsigned_triple_gen_var_10()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_exact_odd_limb({:?}, {}, {}) = {}\",\n            ns,\n            d,\n            carry,\n            limbs_mod_exact_odd_limb(&ns, d, carry)\n        );\n    }\n}\n\nfn demo_limbs_eq_limb_mod_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y, m) in unsigned_vec_unsigned_unsigned_triple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_limb_mod_limb({:?}, {}, {}) = {}\",\n            xs,\n            y,\n            m,\n            limbs_eq_limb_mod_limb(&xs, y, m)\n        );\n    }\n}\n\nfn demo_limbs_eq_limb_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ms, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        let old_ms = ms.clone();\n        println!(\n            \"limbs_eq_limb_mod({:?}, {}, {:?}) = {}\",\n            old_xs,\n            y,\n            old_ms,\n            limbs_eq_limb_mod(&mut xs, y, &mut ms)\n        );\n    }\n}\n\nfn demo_limbs_eq_limb_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ms, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        println!(\n            \"limbs_eq_limb_mod_val_ref({:?}, {}, {:?}) = {}\",\n            old_xs,\n            y,\n            ms,\n            limbs_eq_limb_mod_val_ref(&mut xs, y, &ms)\n        );\n    }\n}\n\nfn demo_limbs_eq_limb_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ms, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_ms = ms.clone();\n        println!(\n            \"limbs_eq_limb_mod_ref_val({:?}, {}, {:?}) = {}\",\n            xs,\n            y,\n            old_ms,\n            limbs_eq_limb_mod_ref_val(&xs, y, &mut ms)\n        );\n    }\n}\n\nfn demo_limbs_eq_limb_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ms, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_limb_mod_ref_ref({:?}, {}, {:?}) = {}\",\n            xs,\n            y,\n            ms,\n            limbs_eq_limb_mod_ref_ref(&xs, y, &ms)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_limb_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys, m) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        println!(\n            \"limbs_eq_mod_limb_val_ref({:?}, {:?}, {}) = {}\",\n            old_xs,\n            ys,\n            m,\n            limbs_eq_mod_limb_val_ref(&mut xs, &ys, m)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_limb_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys, m) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_ys = ys.clone();\n        println!(\n            \"limbs_eq_mod_limb_ref_val({:?}, {:?}, {}) = {}\",\n            xs,\n            old_ys,\n            m,\n            limbs_eq_mod_limb_ref_val(&xs, &mut ys, m)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_limb_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, m) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_mod_limb_ref_ref({:?}, {:?}, {}) = {}\",\n            xs,\n            ys,\n            m,\n            limbs_eq_mod_limb_ref_ref(&xs, &ys, m)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_ref_val_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys, mut ms) in unsigned_vec_triple_gen_var_36().get(gm, config).take(limit) {\n        let old_ys = ys.clone();\n        let old_ms = ms.clone();\n        println!(\n            \"limbs_eq_mod_ref_val_val({:?}, {:?}, {:?}) = {}\",\n            xs,\n            old_ys,\n            old_ms,\n            limbs_eq_mod_ref_val_val(&xs, &mut ys, &mut ms)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_ref_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys, ms) in unsigned_vec_triple_gen_var_36().get(gm, config).take(limit) {\n        let old_ys = ys.clone();\n        println!(\n            \"limbs_eq_mod_ref_val_ref({:?}, {:?}, {:?}) = {}\",\n            xs,\n            old_ys,\n            ms,\n            limbs_eq_mod_ref_val_ref(&xs, &mut ys, &ms)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_ref_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, mut ms) in unsigned_vec_triple_gen_var_36().get(gm, config).take(limit) {\n        let old_ms = ms.clone();\n        println!(\n            \"limbs_eq_mod_ref_ref_val({:?}, {:?}, {:?}) = {}\",\n            xs,\n            ys,\n            old_ms,\n            limbs_eq_mod_ref_ref_val(&xs, &ys, &mut ms)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, ms) in unsigned_vec_triple_gen_var_36().get(gm, config).take(limit) {\n        println!(\n            \"limbs_eq_mod_ref_ref_ref({:?}, {:?}, {:?}) = {}\",\n            xs,\n            ys,\n            ms,\n            limbs_eq_mod_ref_ref_ref(&xs, &ys, &ms)\n        );\n    }\n}\n\nfn demo_natural_eq_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        if x.eq_mod(y, m) {\n            println!(\"{x_old} is equal to {y_old} mod {m_old}\");\n        } else {\n            println!(\"{x_old} is not equal to {y_old} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_natural_eq_mod_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        if x.eq_mod(y, &m) {\n            println!(\"{x_old} is equal to {y_old} mod &{m}\");\n        } else {\n            println!(\"{x_old} is not equal to {y_old} mod &{m}\");\n        }\n    }\n}\n\nfn demo_natural_eq_mod_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        if x.eq_mod(&y, m) {\n            println!(\"{x_old} is equal to &{y} mod {m_old}\");\n        } else {\n            println!(\"{x_old} is not equal to &{y} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_natural_eq_mod_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        if x.eq_mod(&y, &m) {\n            println!(\"{x_old} is equal to &{y} mod &{m}\");\n        } else {\n            println!(\"{x_old} is not equal to &{y} mod &{m}\");\n        }\n    }\n}\n\nfn demo_natural_eq_mod_ref_val_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        let m_old = m.clone();\n        if (&x).eq_mod(y, m) {\n            println!(\"&{x} is equal to {y_old} mod {m_old}\");\n        } else {\n            println!(\"&{x} is not equal to {y_old} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_natural_eq_mod_ref_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        if (&x).eq_mod(y, &m) {\n            println!(\"&{x} is equal to {y_old} mod &{m}\");\n        } else {\n            println!(\"&{x} is not equal to {y_old} mod &{m}\");\n        }\n    }\n}\n\nfn demo_natural_eq_mod_ref_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        if (&x).eq_mod(&y, m) {\n            println!(\"&{x} is equal to &{y} mod {m_old}\");\n        } else {\n            println!(\"&{x} is not equal to &{y} mod {m_old}\");\n        }\n    }\n}\n\nfn demo_natural_eq_mod_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen().get(gm, config).take(limit) {\n        if (&x).eq_mod(&y, &m) {\n            println!(\"&{x} is equal to &{y} mod &{m}\");\n        } else {\n            println!(\"&{x} is not equal to &{y} mod &{m}\");\n        }\n    }\n}\n\nfn benchmark_limbs_limb_mod_exact_odd_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_limb_mod_exact_odd_limb(Limb, Limb, Limb)\",\n        BenchmarkType::Single,\n        unsigned_triple_gen_var_21().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, d, carry)| {\n            no_out!(limbs_limb_mod_exact_odd_limb(n, d, carry));\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_exact_odd_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_exact_odd_limb(&[Limb], Limb, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"ns\"),\n        &mut [(\"Malachite\", &mut |(ref ns, d, carry)| {\n            no_out!(limbs_mod_exact_odd_limb(ns, d, carry));\n        })],\n    );\n}\n\n// use large params\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_limbs_eq_limb_mod_limb_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_limb_mod_limb(&mut [Limb], Limb, Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_eq_limb_mod_limb\", &mut |(ref xs, y, m)| {\n                no_out!(limbs_eq_limb_mod_limb(xs, y, m));\n            }),\n            (\"limbs_mod_limb\", &mut |(ref xs, y, m)| {\n                no_out!(limbs_mod_limb::<DoubleLimb, Limb>(xs, m) == y % m);\n            }),\n            (\"combined_limbs_eq_limb_mod_limb\", &mut |(ref xs, y, m)| {\n                no_out!(combined_limbs_eq_limb_mod_limb(xs, y, m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_eq_limb_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_limb_mod(&[Limb], Limb, &[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_eq_limb_mod\", &mut |(ref mut xs, ref mut ms, y)| {\n                no_out!(limbs_eq_limb_mod(xs, y, ms));\n            }),\n            (\"limbs_eq_limb_mod_val_ref\", &mut |(\n                ref mut xs,\n                ref mut ms,\n                y,\n            )| {\n                no_out!(limbs_eq_limb_mod_val_ref(xs, y, ms));\n            }),\n            (\"limbs_eq_limb_mod_ref_val\", &mut |(\n                ref xs,\n                ref mut ms,\n                y,\n            )| {\n                no_out!(limbs_eq_limb_mod_ref_val(xs, y, ms));\n            }),\n            (\"limbs_eq_limb_mod_ref_ref\", &mut |(\n                ref xs,\n                ref mut ms,\n                y,\n            )| {\n                no_out!(limbs_eq_limb_mod_ref_ref(xs, y, ms));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_eq_limb_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_limb_mod_ref_ref(&[Limb], Limb, &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(ref xs, ref ms, y)| {\n                no_out!(limbs_eq_limb_mod_ref_ref(xs, y, ms));\n            }),\n            (\"naive 1\", &mut |(ref xs, ref ms, y)| {\n                no_out!(limbs_eq_limb_mod_naive_1(xs, y, ms));\n            }),\n            (\"naive 2\", &mut |(ref xs, ref ms, y)| {\n                no_out!(limbs_eq_limb_mod_naive_2(xs, y, ms));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_eq_mod_limb_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_limb_val_ref(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"limbs_eq_mod_limb_val_ref\", &mut |(\n                ref mut xs,\n                ref ys,\n                ms,\n            )| {\n                no_out!(limbs_eq_mod_limb_val_ref(xs, ys, ms));\n            }),\n            (\"limbs_eq_mod_limb_ref_val\", &mut |(\n                ref xs,\n                ref mut ys,\n                ms,\n            )| {\n                no_out!(limbs_eq_mod_limb_ref_val(xs, ys, ms));\n            }),\n            (\"limbs_eq_mod_limb_ref_ref\", &mut |(ref xs, ref ys, ms)| {\n                no_out!(limbs_eq_mod_limb_ref_ref(xs, ys, ms));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_eq_mod_limb_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_limb_val_ref(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"standard\", &mut |(ref xs, ref ys, ms)| {\n                no_out!(limbs_eq_mod_limb_ref_ref(xs, ys, ms));\n            }),\n            (\"naive 1\", &mut |(ref xs, ref ys, ms)| {\n                no_out!(limbs_eq_mod_limb_naive_1(xs, ys, ms));\n            }),\n            (\"naive 2\", &mut |(ref xs, ref ys, ms)| {\n                no_out!(limbs_eq_mod_limb_naive_2(xs, ys, ms));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_eq_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_ref_ref_ref(&[Limb], &[Limb], &[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_triple_gen_var_36().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"limbs_eq_mod_ref_val_val\", &mut |(\n                ref xs,\n                ref mut ys,\n                ref mut ms,\n            )| {\n                no_out!(limbs_eq_mod_ref_val_val(xs, ys, ms));\n            }),\n            (\"limbs_eq_mod_ref_val_ref\", &mut |(\n                ref xs,\n                ref mut ys,\n                ref ms,\n            )| {\n                no_out!(limbs_eq_mod_ref_val_ref(xs, ys, ms));\n            }),\n            (\"limbs_eq_mod_ref_ref_val\", &mut |(\n                ref xs,\n                ref ys,\n                ref mut ms,\n            )| {\n                no_out!(limbs_eq_mod_ref_ref_val(xs, ys, ms));\n            }),\n            (\"limbs_eq_mod_ref_ref_ref\", &mut |(\n                ref xs,\n                ref ys,\n                ref ms,\n            )| {\n                no_out!(limbs_eq_mod_ref_ref_ref(xs, ys, ms));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_eq_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_ref_ref_ref(&[Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_36().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"standard\", &mut |(ref xs, ref ys, ref ms)| {\n                no_out!(limbs_eq_mod_ref_ref_ref(xs, ys, ms));\n            }),\n            (\"naive 1\", &mut |(ref xs, ref ys, ref ms)| {\n                no_out!(limbs_eq_mod_naive_1(xs, ys, ms));\n            }),\n            (\"naive 2\", &mut |(ref xs, ref ys, ref ms)| {\n                no_out!(limbs_eq_mod_naive_2(xs, ys, ms));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_eq_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_mod(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.eq_mod(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(y, m));\n            }),\n            (\"Natural.eq_mod(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(y, &m));\n            }),\n            (\"Natural.eq_mod(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(&y, m));\n            }),\n            (\"Natural.eq_mod(&Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(&y, &m));\n            }),\n            (\"(&Natural).eq_mod(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(y, m));\n            }),\n            (\"(&Natural).eq_mod(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(y, &m));\n            }),\n            (\"(&Natural).eq_mod(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(&y, m));\n            }),\n            (\"(&Natural).eq_mod(&Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).eq_mod(&y, &m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_eq_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_mod(Natural, Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_triple_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y, m))| no_out!(x.eq_mod(y, m))),\n            (\"rug\", &mut |((x, y, m), _)| no_out!(x.is_congruent(&y, &m))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::short_circuit_statement, unused_must_use)]\nfn benchmark_natural_eq_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_mod(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.eq_mod(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.eq_mod(y, m));\n            }),\n            (\n                \"Natural == Natural || Natural != 0 && Natural % Natural == Natural % Natural\",\n                &mut |(x, y, m)| no_out!(x == y || m != 0 && x % &m == y % m),\n            ),\n            (\n                \"|Natural - Natural|.divisible_by(Natural)\",\n                &mut |(x, y, m)| {\n                    no_out!(\n                        (Integer::from(x) - Integer::from(y))\n                            .unsigned_abs()\n                            .divisible_by(m)\n                    );\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{EqModPowerOf2, ModPowerOf2};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::{\n    triple_1_2_vec_max_len_bucketer, triple_1_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_unsigned_triple_gen_var_13,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::eq_mod_power_of_2::{\n    limbs_eq_limb_mod_power_of_2, limbs_eq_mod_power_of_2,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_triple_1_2_natural_max_bit_bucketer, triple_1_2_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_natural_unsigned_triple_gen_var_1, natural_natural_unsigned_triple_gen_var_1_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_eq_limb_mod_power_of_2);\n    register_demo!(runner, demo_limbs_eq_mod_power_of_2);\n    register_demo!(runner, demo_natural_eq_mod_power_of_2);\n\n    register_bench!(runner, benchmark_limbs_eq_limb_mod_power_of_2);\n    register_bench!(runner, benchmark_limbs_eq_mod_power_of_2);\n    register_bench!(\n        runner,\n        benchmark_natural_eq_mod_power_of_2_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_eq_mod_power_of_2_algorithms);\n}\n\nfn demo_limbs_eq_limb_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y, pow) in unsigned_vec_unsigned_unsigned_triple_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_limb_mod_power_of_2({:?}, {}, {}) = {:?}\",\n            xs,\n            y,\n            pow,\n            limbs_eq_limb_mod_power_of_2(&xs, y, pow)\n        );\n    }\n}\n\nfn demo_limbs_eq_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_eq_mod_power_of_2({:?}, {:?}, {}) = {:?}\",\n            xs,\n            ys,\n            pow,\n            limbs_eq_mod_power_of_2(&xs, &ys, pow)\n        );\n    }\n}\n\nfn demo_natural_eq_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_mod_power_of_2(&y, pow) {\n            println!(\"{x} is equal to {y} mod 2^{pow}\");\n        } else {\n            println!(\"{x} is not equal to {y} mod 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_limbs_eq_limb_mod_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_limb_mod_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, y, pow)| {\n            no_out!(limbs_eq_limb_mod_power_of_2(xs, y, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_eq_mod_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_eq_mod_power_of_2(&[Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys, pow)| {\n            no_out!(limbs_eq_mod_power_of_2(xs, ys, pow));\n        })],\n    );\n}\n\nfn benchmark_natural_eq_mod_power_of_2_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_mod_power_of_2(&Natural, u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_natural_unsigned_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_1_2_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (ref n, ref u, pow))| {\n                no_out!(n.eq_mod_power_of_2(u, pow));\n            }),\n            (\"rug\", &mut |((ref n, ref u, pow), _)| {\n                no_out!(n.is_congruent_2pow(u, u32::exact_from(pow)));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_eq_mod_power_of_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_mod_power_of_2(&Natural, u64)\",\n        BenchmarkType::Algorithms,\n        natural_natural_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Natural.eq_mod_power_of_2(&Natural, u64)\",\n                &mut |(ref x, ref y, pow)| no_out!(x.eq_mod_power_of_2(y, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2(u64) == Natural.mod_power_of_2(u64)\",\n                &mut |(ref x, ref y, pow)| no_out!(x.mod_power_of_2(pow) == y.mod_power_of_2(pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ExtendedGcd;\nuse malachite_base::test_util::bench::bucketers::pair_vec_max_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_pair_gen_var_11;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::gcd::extended_gcd::limbs_extended_gcd;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_pair_gen, natural_pair_gen_rm};\nuse malachite_nz::test_util::natural::arithmetic::extended_gcd::{\n    extended_gcd_binary_natural, extended_gcd_euclidean_natural,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_extended_gcd);\n    register_demo!(runner, demo_natural_extended_gcd);\n    register_demo!(runner, demo_natural_extended_gcd_val_ref);\n    register_demo!(runner, demo_natural_extended_gcd_ref_val);\n    register_demo!(runner, demo_natural_extended_gcd_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_extended_gcd);\n    register_bench!(runner, benchmark_natural_extended_gcd_algorithms);\n    register_bench!(runner, benchmark_natural_extended_gcd_library_comparison);\n    register_bench!(runner, benchmark_natural_extended_gcd_evaluation_strategy);\n}\n\nfn demo_limbs_extended_gcd(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_11().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let mut gs = vec![0; ys.len()];\n        let mut ss = vec![0; ys.len() + 1];\n        let result = limbs_extended_gcd(&mut gs, &mut ss, &mut xs, &mut ys);\n        println!(\n            \"limbs_gcd_extended_gcd(&mut gs, &mut ss, {xs_old:?}, {ys_old:?}) = {result:?}; \\\n            gs = {gs:?}, ss = {ss:?}\",\n        );\n    }\n}\n\nfn demo_natural_extended_gcd(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.extended_gcd({}) = {:?}\",\n            x_old,\n            y_old,\n            x.extended_gcd(y)\n        );\n    }\n}\n\nfn demo_natural_extended_gcd_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.extended_gcd(&{}) = {:?}\", x_old, y, x.extended_gcd(&y));\n    }\n}\n\nfn demo_natural_extended_gcd_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).extended_gcd({}) = {:?}\",\n            x,\n            y_old,\n            (&x).extended_gcd(y)\n        );\n    }\n}\n\nfn demo_natural_extended_gcd_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).extended_gcd(&{}) = {:?}\",\n            x,\n            y,\n            (&x).extended_gcd(&y)\n        );\n    }\n}\n\nfn benchmark_limbs_extended_gcd(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_extended_gcd(&mut [Limb], &mut [Limb], &mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            let mut gs = vec![0; ys.len()];\n            let mut ss = vec![0; ys.len() + 1];\n            limbs_extended_gcd(&mut gs, &mut ss, &mut xs, &mut ys);\n        })],\n    );\n}\n\nfn benchmark_natural_extended_gcd_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.extended_gcd(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.extended_gcd(y))),\n            (\"Euclidean\", &mut |(x, y)| {\n                no_out!(extended_gcd_euclidean_natural(x, y));\n            }),\n            (\"binary\", &mut |(x, y)| {\n                no_out!(extended_gcd_binary_natural(x, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_extended_gcd_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.extended_gcd(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.extended_gcd(y))),\n            (\"rug\", &mut |((x, y), _)| {\n                no_out!(x.extended_gcd(y, rug::Integer::new()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_extended_gcd_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.extended_gcd(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.extended_gcd(Natural)\", &mut |(x, y)| {\n                no_out!(x.extended_gcd(y));\n            }),\n            (\"Natural.extended_gcd(&Natural)\", &mut |(x, y)| {\n                no_out!(x.extended_gcd(&y));\n            }),\n            (\"&Natural.extended_gcd(Natural)\", &mut |(x, y)| {\n                no_out!((&x).extended_gcd(y));\n            }),\n            (\"&Natural.extended_gcd(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).extended_gcd(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    DoubleFactorial, Factorial, Multifactorial, Subfactorial,\n};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bucketer, unsigned_direct_bucketer, usize_convertible_pair_ratio_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{unsigned_gen_var_5, unsigned_pair_gen_var_18};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::factorial::limbs_odd_factorial;\nuse malachite_nz::test_util::generators::unsigned_bool_pair_gen_var_1;\nuse malachite_nz::test_util::natural::arithmetic::factorial::{\n    double_factorial_naive, factorial_naive, multifactorial_naive,\n};\nuse rug::Complete;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_odd_factorial);\n    register_demo!(runner, demo_factorial);\n    register_demo!(runner, demo_double_factorial);\n    register_demo!(runner, demo_multifactorial);\n    register_demo!(runner, demo_subfactorial);\n\n    register_bench!(runner, benchmark_limbs_odd_factorial);\n    register_bench!(runner, benchmark_factorial_algorithms);\n    register_bench!(runner, benchmark_factorial_library_comparison);\n    register_bench!(runner, benchmark_double_factorial_algorithms);\n    register_bench!(runner, benchmark_double_factorial_library_comparison);\n    register_bench!(runner, benchmark_multifactorial_algorithms);\n    register_bench!(runner, benchmark_multifactorial_library_comparison);\n    register_bench!(runner, benchmark_subfactorial);\n}\n\nfn demo_limbs_odd_factorial(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, double) in unsigned_bool_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_odd_factorial({:?}, {}) = {:?}\",\n            n,\n            double,\n            limbs_odd_factorial(n, double)\n        );\n    }\n}\n\nfn demo_factorial(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"{}! = {}\", n, Natural::factorial(n));\n    }\n}\n\nfn demo_double_factorial(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"{}!! = {}\", n, Natural::double_factorial(n));\n    }\n}\n\nfn demo_multifactorial(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in unsigned_pair_gen_var_18().get(gm, config).take(limit) {\n        if m <= 5 {\n            print!(\"{n}\");\n            for _ in 0..m {\n                print!(\"!\");\n            }\n            println!(\" = {}\", Natural::multifactorial(n, m));\n        } else {\n            println!(\"{}[!^{}] = {}\", n, m, Natural::multifactorial(n, m));\n        }\n    }\n}\n\nfn demo_subfactorial(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"!{} = {}\", n, Natural::subfactorial(n));\n    }\n}\n\nfn benchmark_limbs_odd_factorial(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_odd_factorial(u64, bool)\",\n        BenchmarkType::Single,\n        unsigned_bool_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, double)| {\n            no_out!(limbs_odd_factorial(n, double));\n        })],\n    );\n}\n\nfn benchmark_factorial_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.factorial(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(Natural::factorial(n))),\n            (\"naive\", &mut |n| no_out!(factorial_naive(n))),\n        ],\n    );\n}\n\nfn benchmark_factorial_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.factorial(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |n| no_out!(Natural::factorial(n))),\n            (\"rug\", &mut |n| {\n                no_out!(rug::Integer::factorial(u32::exact_from(n)).complete());\n            }),\n        ],\n    );\n}\n\nfn benchmark_double_factorial_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.double_factorial(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(Natural::double_factorial(n))),\n            (\"naive\", &mut |n| no_out!(double_factorial_naive(n))),\n        ],\n    );\n}\n\nfn benchmark_double_factorial_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.double_factorial(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |n| no_out!(Natural::double_factorial(n))),\n            (\"rug\", &mut |n| {\n                no_out!(rug::Integer::factorial_2(u32::exact_from(n)).complete());\n            }),\n        ],\n    );\n}\n\nfn benchmark_multifactorial_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.multifactorial(u64, u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &usize_convertible_pair_ratio_bucketer(\"n\", \"m\"),\n        &mut [\n            (\"default\", &mut |(n, m)| {\n                no_out!(Natural::multifactorial(n, m));\n            }),\n            (\"naive\", &mut |(n, m)| no_out!(multifactorial_naive(n, m))),\n        ],\n    );\n}\n\nfn benchmark_multifactorial_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.multifactorial(u64, u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_pair_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &usize_convertible_pair_ratio_bucketer(\"n\", \"m\"),\n        &mut [\n            (\"Malachite\", &mut |(m, n)| {\n                no_out!(Natural::multifactorial(m, n));\n            }),\n            (\"rug\", &mut |(m, n)| {\n                no_out!(\n                    rug::Integer::factorial_m(u32::exact_from(n), u32::exact_from(m)).complete()\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_subfactorial(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.subfactorial(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| no_out!(Natural::subfactorial(n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Gcd, GcdAssign};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, quadruple_3_vec_len_bucketer, quadruple_max_bit_bucketer,\n    unsigned_direct_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_quadruple_gen_var_11, unsigned_vec_unsigned_pair_gen_var_23,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::gcd::half_gcd::{\n    HalfGcdMatrix, limbs_gcd_div, limbs_gcd_reduced, limbs_half_gcd_matrix_1_mul_vector,\n};\nuse malachite_nz::natural::arithmetic::gcd::limbs_gcd_limb;\nuse malachite_nz::natural::arithmetic::gcd::matrix_2_2::{\n    limbs_matrix_2_2_mul, limbs_matrix_2_2_mul_small, limbs_matrix_2_2_mul_strassen,\n    limbs_matrix_mul_2_2_scratch_len,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    limbs_matrix_2_2_mul_bucketer, pair_1_half_gcd_matrix_bucketer, pair_natural_max_bit_bucketer,\n    triple_1_half_gcd_matrix_bucketer, triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_5, large_type_gen_var_6, large_type_gen_var_7, large_type_gen_var_8,\n    natural_pair_gen, natural_pair_gen_nrm, natural_pair_gen_var_4, natural_pair_gen_var_4_nrm,\n    unsigned_vec_pair_gen_var_10,\n};\nuse malachite_nz::test_util::natural::arithmetic::gcd::{\n    OwnedHalfGcdMatrix, gcd_binary_nz, gcd_euclidean_nz, limbs_gcd_div_alt, limbs_gcd_div_naive,\n};\nuse num::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_gcd_limb);\n    register_demo!(runner, demo_half_gcd_matrix_init);\n    register_demo!(runner, demo_half_gcd_matrix_update_q);\n    register_demo!(runner, demo_half_gcd_matrix_mul_matrix_1);\n    register_demo!(runner, demo_half_gcd_matrix_1_mul_vector);\n    register_demo!(runner, demo_limbs_matrix_2_2_mul);\n    register_demo!(runner, demo_limbs_gcd_div);\n    register_demo!(runner, demo_limbs_gcd_reduced);\n    register_demo!(runner, demo_natural_gcd);\n    register_demo!(runner, demo_natural_gcd_val_ref);\n    register_demo!(runner, demo_natural_gcd_ref_val);\n    register_demo!(runner, demo_natural_gcd_ref_ref);\n    register_demo!(runner, demo_natural_gcd_assign);\n    register_demo!(runner, demo_natural_gcd_assign_ref);\n    register_demo!(runner, demo_natural_gcd_2);\n\n    register_bench!(runner, benchmark_limbs_gcd_limb);\n    register_bench!(runner, benchmark_half_gcd_matrix_init);\n    register_bench!(runner, benchmark_half_gcd_matrix_update_q);\n    register_bench!(runner, benchmark_half_gcd_matrix_mul_matrix_1);\n    register_bench!(runner, benchmark_half_gcd_matrix_1_mul_vector);\n    register_bench!(runner, benchmark_limbs_matrix_2_2_mul_algorithms);\n    register_bench!(runner, benchmark_limbs_gcd_div_algorithms);\n    register_bench!(runner, benchmark_limbs_gcd_reduced);\n    register_bench!(runner, benchmark_natural_gcd_algorithms);\n    register_bench!(runner, benchmark_natural_gcd_library_comparison);\n    register_bench!(runner, benchmark_natural_gcd_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_gcd_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_gcd_algorithms_2);\n    register_bench!(runner, benchmark_natural_gcd_library_comparison_2);\n    register_bench!(runner, benchmark_natural_gcd_evaluation_strategy_2);\n}\n\nfn demo_limbs_gcd_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_23()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_gcd_limb({:?}, {}) = {}\",\n            xs,\n            y,\n            limbs_gcd_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_half_gcd_matrix_init(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_11().get(gm, config).take(limit) {\n        let scratch_len = HalfGcdMatrix::min_init_scratch(n);\n        println!(\n            \"HalfGcdMatrix::init({}, vec![0; {}]) = {:?}\",\n            n,\n            scratch_len,\n            OwnedHalfGcdMatrix::init(n, vec![0; scratch_len])\n        );\n    }\n}\n\nfn demo_half_gcd_matrix_update_q(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut m, qs, column) in large_type_gen_var_5().get(gm, config).take(limit) {\n        let old_m = m.clone();\n        let mut scratch = vec![0; OwnedHalfGcdMatrix::update_q_scratch_len(&m, qs.len())];\n        m.update_q(&qs, column, &mut scratch);\n        println!(\"HalfGcdMatrix::update_q({old_m:?}, {qs:?}, {column}) = {m:?}\");\n    }\n}\n\nfn demo_half_gcd_matrix_mul_matrix_1(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut m, m_1) in large_type_gen_var_7().get(gm, config).take(limit) {\n        let old_m = m.clone();\n        let mut scratch = vec![0; m.n];\n        m.mul_matrix_1(&m_1, &mut scratch);\n        println!(\"m := {old_m:?}; m.mul_matrix_1({m_1:?}); m = {m:?}\");\n    }\n}\n\nfn demo_half_gcd_matrix_1_mul_vector(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (m, mut out, xs, mut ys) in large_type_gen_var_6().get(gm, config).take(limit) {\n        let old_out = out.clone();\n        let old_ys = ys.clone();\n        let out_len = limbs_half_gcd_matrix_1_mul_vector(&m, &mut out, &xs, &mut ys);\n        println!(\n            \"out := {old_out:?}; ys := {old_ys:?}; \\\n            limbs_half_gcd_matrix_1_mul_vector({m:?}, &mut out, {xs:?}, &mut ys) = {out_len}; \\\n            out = {out:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_matrix_2_2_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs00, mut xs01, mut xs10, mut xs11, xs_len, ys00, ys01, ys10, ys11) in\n        large_type_gen_var_8().get(gm, config).take(limit)\n    {\n        let xs00_old = xs00.clone();\n        let xs01_old = xs01.clone();\n        let xs10_old = xs10.clone();\n        let xs11_old = xs11.clone();\n        let mut scratch = vec![0; limbs_matrix_mul_2_2_scratch_len(xs_len, ys00.len())];\n        limbs_matrix_2_2_mul(\n            &mut xs00,\n            &mut xs01,\n            &mut xs10,\n            &mut xs11,\n            xs_len,\n            &ys00,\n            &ys01,\n            &ys10,\n            &ys11,\n            &mut scratch,\n        );\n        println!(\n            \"(xs00, xs01, xs10, xs11) := {:?}; \\\n            limbs_matrix_2_2_mul(..., {}, {:?}, {:?}, {:?}, {:?}); \\\n            (xs00, xs01, xs10, xs11) = {:?}\",\n            (xs00_old, xs01_old, xs10_old, xs11_old),\n            xs_len,\n            ys00,\n            ys01,\n            ys10,\n            ys11,\n            (xs00, xs01, xs10, xs11)\n        );\n    }\n}\n\nfn demo_limbs_gcd_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n1, n0, d1, d0) in unsigned_quadruple_gen_var_11().get(gm, config).take(limit) {\n        println!(\n            \"limbs_gcd_div({}, {}, {}, {}) = {:?}\",\n            n1,\n            n0,\n            d1,\n            d0,\n            limbs_gcd_div(n1, n0, d1, d0)\n        );\n    }\n}\n\nfn demo_limbs_gcd_reduced(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_10().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let mut out = vec![0; xs.len()];\n        let out_len = limbs_gcd_reduced(&mut out, &mut xs, &mut ys);\n        out.resize(out_len, 0);\n        println!(\"limbs_gcd_reduced(&mut out, {xs_old:?}, {ys_old:?}); out = {out:?}\");\n    }\n}\n\nfn demo_natural_gcd(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.gcd({}) = {}\", x_old, y_old, x.gcd(y));\n    }\n}\n\nfn demo_natural_gcd_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.gcd(&{}) = {}\", x_old, y, x.gcd(&y));\n    }\n}\n\nfn demo_natural_gcd_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).gcd({}) = {}\", x, y_old, (&x).gcd(y));\n    }\n}\n\nfn demo_natural_gcd_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).gcd(&{}) = {}\", x, y, (&x).gcd(&y));\n    }\n}\n\nfn demo_natural_gcd_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.gcd_assign(y.clone());\n        println!(\"x := {x_old}; x.gcd_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_natural_gcd_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.gcd_assign(&y);\n        println!(\"x := {x_old}; x.gcd_assign(&{y}); x = {x}\");\n    }\n}\n\nfn demo_natural_gcd_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_4().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.gcd({}) = {}\", x_old, y_old, x.gcd(y));\n    }\n}\n\nfn benchmark_limbs_gcd_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"HalfGcdMatrix::init(usize, Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_23().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_gcd_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_half_gcd_matrix_init(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_gcd_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |n| {\n            let scratch_len = HalfGcdMatrix::min_init_scratch(n);\n            OwnedHalfGcdMatrix::init(n, vec![0; scratch_len]);\n        })],\n    );\n}\n\nfn benchmark_half_gcd_matrix_update_q(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"HalfGcdMatrix::update_q(&[Limb], u8, &mut [Limb])\",\n        BenchmarkType::Single,\n        large_type_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_half_gcd_matrix_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(mut m, qs, column)| {\n            let mut scratch = vec![0; OwnedHalfGcdMatrix::update_q_scratch_len(&m, qs.len())];\n            m.update_q(&qs, column, &mut scratch);\n        })],\n    );\n}\n\nfn benchmark_half_gcd_matrix_mul_matrix_1(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"HalfGcdMatrix::mul_matrix_1(&HalfGcdMatrix1, &mut [Limb])\",\n        BenchmarkType::Single,\n        large_type_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_half_gcd_matrix_bucketer(\"m\"),\n        &mut [(\"Malachite\", &mut |(mut m, m_1)| {\n            let mut scratch = vec![0; m.n];\n            m.mul_matrix_1(&m_1, &mut scratch);\n        })],\n    );\n}\n\nfn benchmark_half_gcd_matrix_1_mul_vector(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_half_gcd_matrix_1_mul_vector(&HalfGcdMatrix1, &mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        large_type_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(m, mut out, xs, mut ys)| {\n            no_out!(limbs_half_gcd_matrix_1_mul_vector(\n                &m, &mut out, &xs, &mut ys\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_matrix_2_2_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_matrix_2_2_mul\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limbs_matrix_2_2_mul_bucketer(),\n        &mut [\n            (\"default\", &mut |(\n                mut xs00,\n                mut xs01,\n                mut xs10,\n                mut xs11,\n                xs_len,\n                ys00,\n                ys01,\n                ys10,\n                ys11,\n            )| {\n                let scratch_len = 3 * (xs_len + ys00.len()) + 5;\n                let mut scratch = vec![0; scratch_len];\n                limbs_matrix_2_2_mul(\n                    &mut xs00,\n                    &mut xs01,\n                    &mut xs10,\n                    &mut xs11,\n                    xs_len,\n                    &ys00,\n                    &ys01,\n                    &ys10,\n                    &ys11,\n                    &mut scratch,\n                );\n            }),\n            (\"small\", &mut |(\n                mut xs00,\n                mut xs01,\n                mut xs10,\n                mut xs11,\n                xs_len,\n                ys00,\n                ys01,\n                ys10,\n                ys11,\n            )| {\n                let scratch_len = 3 * (xs_len + ys00.len()) + 5;\n                let mut scratch = vec![0; scratch_len];\n                limbs_matrix_2_2_mul_small(\n                    &mut xs00,\n                    &mut xs01,\n                    &mut xs10,\n                    &mut xs11,\n                    xs_len,\n                    &ys00,\n                    &ys01,\n                    &ys10,\n                    &ys11,\n                    &mut scratch,\n                );\n            }),\n            (\"Strassen\", &mut |(\n                mut xs00,\n                mut xs01,\n                mut xs10,\n                mut xs11,\n                xs_len,\n                ys00,\n                ys01,\n                ys10,\n                ys11,\n            )| {\n                let scratch_len = 3 * (xs_len + ys00.len()) + 5;\n                let mut scratch = vec![0; scratch_len];\n                limbs_matrix_2_2_mul_strassen(\n                    &mut xs00,\n                    &mut xs01,\n                    &mut xs10,\n                    &mut xs11,\n                    xs_len,\n                    &ys00,\n                    &ys01,\n                    &ys10,\n                    &ys11,\n                    &mut scratch,\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_gcd_div_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_gcd_div(Limb, Limb, Limb, Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_quadruple_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_max_bit_bucketer(\"n1\", \"n0\", \"d1\", \"d0\"),\n        &mut [\n            (\"default\", &mut |(n1, n0, d1, d0)| {\n                no_out!(limbs_gcd_div(n1, n0, d1, d0));\n            }),\n            (\"alt\", &mut |(n1, n0, d1, d0)| {\n                no_out!(limbs_gcd_div_alt(n1, n0, d1, d0));\n            }),\n            (\"naive\", &mut |(n1, n0, d1, d0)| {\n                no_out!(limbs_gcd_div_naive(n1, n0, d1, d0));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_gcd_reduced(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_gcd_reduced(&mut [Limb], &mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            let mut out = vec![0; xs.len()];\n            limbs_gcd_reduced(&mut out, &mut xs, &mut ys);\n        })],\n    );\n}\n\nfn benchmark_natural_gcd_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gcd(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.gcd(y))),\n            (\"Euclidean\", &mut |(x, y)| no_out!(gcd_euclidean_nz(x, y))),\n            (\"binary\", &mut |(x, y)| no_out!(gcd_binary_nz(x, y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_gcd_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gcd(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.gcd(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.gcd(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.gcd(&y))),\n        ],\n    );\n}\n\nfn benchmark_natural_gcd_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gcd(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.gcd(Natural)\", &mut |(x, y)| no_out!(x.gcd(y))),\n            (\"Natural.gcd(&Natural)\", &mut |(x, y)| no_out!(x.gcd(&y))),\n            (\"&Natural.gcd(Natural)\", &mut |(x, y)| no_out!((&x).gcd(y))),\n            (\"&Natural.gcd(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).gcd(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_gcd_algorithms_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gcd(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.gcd(y))),\n            (\"Euclidean\", &mut |(x, y)| no_out!(gcd_euclidean_nz(x, y))),\n            (\"binary\", &mut |(x, y)| no_out!(gcd_binary_nz(x, y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_gcd_library_comparison_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gcd(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_4_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.gcd(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.gcd(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.gcd(&y))),\n        ],\n    );\n}\n\nfn benchmark_natural_gcd_evaluation_strategy_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gcd(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.gcd(Natural)\", &mut |(x, y)| no_out!(x.gcd(y))),\n            (\"Natural.gcd(&Natural)\", &mut |(x, y)| no_out!(x.gcd(&y))),\n            (\"&Natural.gcd(Natural)\", &mut |(x, y)| no_out!((&x).gcd(y))),\n            (\"&Natural.gcd(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).gcd(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_gcd_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gcd_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.gcd(Natural)\", &mut |(x, y)| no_out!(x.gcd(y))),\n            (\"Natural.gcd(&Natural)\", &mut |(x, y)| no_out!(x.gcd(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::is_power_of_2::limbs_is_power_of_2;\nuse malachite_nz::test_util::bench::bucketers::pair_2_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_is_power_of_2);\n    register_demo!(runner, demo_natural_is_power_of_2);\n\n    register_bench!(runner, benchmark_limbs_is_power_of_2);\n    register_bench!(runner, benchmark_natural_is_power_of_2_library_comparison);\n}\n\nfn demo_limbs_is_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_is_power_of_2({:?}) = {:?}\",\n            xs,\n            limbs_is_power_of_2(&xs)\n        );\n    }\n}\n\nfn demo_natural_is_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        if n.is_power_of_2() {\n            println!(\"{n} is a power of 2\");\n        } else {\n            println!(\"{n} is not a power of 2\");\n        }\n    }\n}\n\nfn benchmark_limbs_is_power_of_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_is_power_of_2(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_is_power_of_2(&xs)))],\n    );\n}\n\nfn benchmark_natural_is_power_of_2_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.is_power_of_2()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(n.is_power_of_2())),\n            (\"rug\", &mut |(n, _)| no_out!(n.is_power_of_two())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{JacobiSymbol, KroneckerSymbol};\nuse malachite_base::test_util::bench::bucketers::pair_vec_max_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_pair_gen_var_32;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::kronecker_symbol::{\n    limbs_jacobi_symbol_init, limbs_jacobi_symbol_same_length,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_natural_bit_bucketer, pair_2_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_pair_gen_rm, natural_pair_gen_var_12, natural_pair_gen_var_12_rm,\n};\nuse malachite_nz::test_util::natural::arithmetic::kronecker_symbol::jacobi_symbol_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_jacobi_symbol_same_length);\n    register_demo!(runner, demo_natural_jacobi_symbol);\n    register_demo!(runner, demo_natural_jacobi_symbol_val_ref);\n    register_demo!(runner, demo_natural_jacobi_symbol_ref_val);\n    register_demo!(runner, demo_natural_jacobi_symbol_ref_ref);\n    register_demo!(runner, demo_natural_kronecker_symbol);\n    register_demo!(runner, demo_natural_kronecker_symbol_val_ref);\n    register_demo!(runner, demo_natural_kronecker_symbol_ref_val);\n    register_demo!(runner, demo_natural_kronecker_symbol_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_jacobi_symbol_same_length);\n    register_bench!(runner, benchmark_natural_jacobi_symbol_library_comparison);\n    register_bench!(runner, benchmark_natural_jacobi_symbol_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_jacobi_symbol_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_kronecker_symbol_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_kronecker_symbol_evaluation_strategy\n    );\n}\n\nfn demo_limbs_jacobi_symbol_same_length(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen_var_32().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let bits = limbs_jacobi_symbol_init(xs[0], ys[0], 0);\n        let s = limbs_jacobi_symbol_same_length(&mut xs, &mut ys, bits);\n        println!(\"limbs_jacobi_symbol_same_length({xs_old:?}, {ys_old:?}) = {s}\");\n    }\n}\n\nfn demo_natural_jacobi_symbol(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_12().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        println!(\n            \"{}.jacobi_symbol({}) = {}\",\n            n_old,\n            m_old,\n            n.jacobi_symbol(m)\n        );\n    }\n}\n\nfn demo_natural_jacobi_symbol_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_12().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\"{}.jacobi_symbol({}) = {}\", n_old, m, n.jacobi_symbol(&m));\n    }\n}\n\nfn demo_natural_jacobi_symbol_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_12().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\"{}.jacobi_symbol({}) = {}\", n, m_old, (&n).jacobi_symbol(m));\n    }\n}\n\nfn demo_natural_jacobi_symbol_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_12().get(gm, config).take(limit) {\n        println!(\"{}.jacobi_symbol({}) = {}\", n, m, (&n).jacobi_symbol(&m));\n    }\n}\n\nfn demo_natural_kronecker_symbol(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        println!(\n            \"{}.kronecker_symbol({}) = {}\",\n            n_old,\n            m_old,\n            n.kronecker_symbol(m)\n        );\n    }\n}\n\nfn demo_natural_kronecker_symbol_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\n            \"{}.kronecker_symbol({}) = {}\",\n            n_old,\n            m,\n            n.kronecker_symbol(&m)\n        );\n    }\n}\n\nfn demo_natural_kronecker_symbol_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\n            \"{}.kronecker_symbol({}) = {}\",\n            n,\n            m_old,\n            (&n).kronecker_symbol(m)\n        );\n    }\n}\n\nfn demo_natural_kronecker_symbol_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}.kronecker_symbol({}) = {}\",\n            n,\n            m,\n            (&n).kronecker_symbol(&m)\n        );\n    }\n}\n\nfn benchmark_limbs_jacobi_symbol_same_length(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_jacobi_symbol_same_length(&mut [Limb], &mut [Limb], u8)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_32().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            let bits = limbs_jacobi_symbol_init(xs[0], ys[0], 0);\n            limbs_jacobi_symbol_same_length(&mut xs, &mut ys, bits);\n        })],\n    );\n}\n\nfn benchmark_natural_jacobi_symbol_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.jacobi_symbol(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_12_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.jacobi_symbol(y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.jacobi(&y))),\n        ],\n    );\n}\n\nfn benchmark_natural_jacobi_symbol_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.jacobi_symbol(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.jacobi_symbol(Natural)\", &mut |(n, m)| {\n                no_out!(n.jacobi_symbol(m));\n            }),\n            (\"Natural.jacobi_symbol(&Natural)\", &mut |(n, m)| {\n                no_out!(n.jacobi_symbol(&m));\n            }),\n            (\"(&Natural).jacobi_symbol(Natural)\", &mut |(n, m)| {\n                no_out!((&n).jacobi_symbol(m));\n            }),\n            (\"(&Natural).jacobi_symbol(&Natural)\", &mut |(n, m)| {\n                no_out!((&n).jacobi_symbol(&m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_jacobi_symbol_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.jacobi_symbol(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(n, m)| no_out!(n.jacobi_symbol(m))),\n            (\"simple\", &mut |(n, m)| no_out!(jacobi_symbol_simple(n, m))),\n        ],\n    );\n}\n\nfn benchmark_natural_kronecker_symbol_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.kronecker_symbol(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.kronecker_symbol(y));\n            }),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.kronecker(&y))),\n        ],\n    );\n}\n\nfn benchmark_natural_kronecker_symbol_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.kronecker_symbol(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.kronecker_symbol(Natural)\", &mut |(n, m)| {\n                no_out!(n.kronecker_symbol(m));\n            }),\n            (\"Natural.kronecker_symbol(&Natural)\", &mut |(n, m)| {\n                no_out!(n.kronecker_symbol(&m));\n            }),\n            (\"(&Natural).kronecker_symbol(Natural)\", &mut |(n, m)| {\n                no_out!((&n).kronecker_symbol(m));\n            }),\n            (\"(&Natural).kronecker_symbol(&Natural)\", &mut |(n, m)| {\n                no_out!((&n).kronecker_symbol(&m));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/lcm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Lcm, LcmAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_natural_max_bit_bucketer, triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_pair_gen, natural_pair_gen_nrm};\nuse num::Integer;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_lcm);\n    register_demo!(runner, demo_natural_lcm_val_ref);\n    register_demo!(runner, demo_natural_lcm_ref_val);\n    register_demo!(runner, demo_natural_lcm_ref_ref);\n    register_demo!(runner, demo_natural_lcm_assign);\n    register_demo!(runner, demo_natural_lcm_assign_ref);\n\n    register_bench!(runner, benchmark_natural_lcm_library_comparison);\n    register_bench!(runner, benchmark_natural_lcm_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_lcm_assign_evaluation_strategy);\n}\n\nfn demo_natural_lcm(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.lcm({}) = {}\", x_old, y_old, x.lcm(y));\n    }\n}\n\nfn demo_natural_lcm_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.lcm(&{}) = {}\", x_old, y, x.lcm(&y));\n    }\n}\n\nfn demo_natural_lcm_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).lcm({}) = {}\", x, y_old, (&x).lcm(y));\n    }\n}\n\nfn demo_natural_lcm_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).lcm(&{}) = {}\", x, y, (&x).lcm(&y));\n    }\n}\n\nfn demo_natural_lcm_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.lcm_assign(y);\n        println!(\"x := {x_old}; x.lcm_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_lcm_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.lcm_assign(&y);\n        println!(\"x := {x_old}; x.lcm_assign(&{y}); x = {x}\");\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_lcm_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.lcm(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.lcm(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.lcm(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.lcm(&y))),\n        ],\n    );\n}\n\nfn benchmark_natural_lcm_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.lcm(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.lcm(Natural)\", &mut |(x, y)| no_out!(x.lcm(y))),\n            (\"Natural.lcm(&Natural)\", &mut |(x, y)| no_out!(x.lcm(&y))),\n            (\"&Natural.lcm(Natural)\", &mut |(x, y)| no_out!((&x).lcm(y))),\n            (\"&Natural.lcm(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).lcm(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_lcm_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.lcm_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.lcm(Natural)\", &mut |(x, y)| no_out!(x.lcm(y))),\n            (\"Natural.lcm(&Natural)\", &mut |(x, y)| no_out!(x.lcm(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase, CheckedLogBase, FloorLogBase};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{natural_bit_bucketer, natural_bit_ratio_bucketer};\nuse malachite_nz::test_util::generators::{natural_gen_var_2, natural_pair_gen_var_3};\nuse malachite_nz::test_util::natural::arithmetic::log_base::{\n    ceiling_log_base_by_squaring, ceiling_log_base_naive, checked_log_base_by_squaring,\n    checked_log_base_naive, floor_log_base_by_squaring, floor_log_base_naive,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_approx_ln);\n    register_demo!(runner, demo_natural_floor_log_base);\n    register_demo!(runner, demo_natural_ceiling_log_base);\n    register_demo!(runner, demo_natural_checked_log_base);\n    register_bench!(runner, benchmark_approx_ln);\n    register_bench!(runner, benchmark_natural_floor_log_base_algorithms);\n    register_bench!(runner, benchmark_natural_ceiling_log_base_algorithms);\n    register_bench!(runner, benchmark_natural_checked_log_base_algorithms);\n}\n\nfn demo_natural_approx_ln(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"ln({}) ≈ {}\", n, NiceFloat(n.approx_ln()));\n    }\n}\n\nfn demo_natural_floor_log_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in natural_pair_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"floor_log_base({}, {}) = {}\",\n            n,\n            base,\n            n.floor_log_base(&base)\n        );\n    }\n}\n\nfn demo_natural_ceiling_log_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in natural_pair_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"ceiling_log_base({}, {}) = {}\",\n            n,\n            base,\n            n.ceiling_log_base(&base)\n        );\n    }\n}\n\nfn demo_natural_checked_log_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in natural_pair_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"checked_log_base({}, {}) = {:?}\",\n            n,\n            base,\n            n.checked_log_base(&base)\n        );\n    }\n}\n\nfn benchmark_approx_ln(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"(&Natural).approx_ln()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"default\", &mut |n| no_out!(n.approx_ln()))],\n    );\n}\n\nfn benchmark_natural_floor_log_base_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Natural).floor_log_base(&Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_ratio_bucketer(\"n\", \"base\"),\n        &mut [\n            (\"default\", &mut |(n, base)| no_out!(n.floor_log_base(&base))),\n            (\"naive\", &mut |(n, base)| {\n                no_out!(floor_log_base_naive(&n, &base));\n            }),\n            (\"by squaring\", &mut |(n, base)| {\n                no_out!(floor_log_base_by_squaring(&n, &base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_log_base_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Natural).ceiling_log_base(&Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_ratio_bucketer(\"n\", \"base\"),\n        &mut [\n            (\"default\", &mut |(n, base)| {\n                no_out!(n.ceiling_log_base(&base));\n            }),\n            (\"naive\", &mut |(n, base)| {\n                no_out!(ceiling_log_base_naive(&n, &base));\n            }),\n            (\"by squaring\", &mut |(n, base)| {\n                no_out!(ceiling_log_base_by_squaring(&n, &base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_log_base_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Natural).checked_log_base(&Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_ratio_bucketer(\"n\", \"base\"),\n        &mut [\n            (\"default\", &mut |(n, base)| {\n                no_out!(n.checked_log_base(&base));\n            }),\n            (\"naive\", &mut |(n, base)| {\n                no_out!(checked_log_base_naive(&n, &base));\n            }),\n            (\"by squaring\", &mut |(n, base)| {\n                no_out!(checked_log_base_by_squaring(&n, &base));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase2, CheckedLogBase2, FloorLogBase2};\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::log_base_2::{\n    limbs_ceiling_log_base_2, limbs_checked_log_base_2, limbs_floor_log_base_2,\n};\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_floor_log_base_2);\n    register_demo!(runner, demo_limbs_ceiling_log_base_2);\n    register_demo!(runner, demo_limbs_checked_log_base_2);\n    register_demo!(runner, demo_natural_floor_log_base_2);\n    register_demo!(runner, demo_natural_ceiling_log_base_2);\n    register_demo!(runner, demo_natural_checked_log_base_2);\n    register_bench!(runner, benchmark_limbs_floor_log_base_2);\n    register_bench!(runner, benchmark_limbs_ceiling_log_base_2);\n    register_bench!(runner, benchmark_limbs_checked_log_base_2);\n    register_bench!(runner, benchmark_natural_floor_log_base_2);\n    register_bench!(runner, benchmark_natural_ceiling_log_base_2);\n    register_bench!(runner, benchmark_natural_checked_log_base_2);\n}\n\nfn demo_limbs_floor_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_floor_log_base_2({:?}) = {}\",\n            xs,\n            limbs_floor_log_base_2(&xs)\n        );\n    }\n}\n\nfn demo_limbs_ceiling_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_ceiling_log_base_2({:?}) = {}\",\n            xs,\n            limbs_ceiling_log_base_2(&xs)\n        );\n    }\n}\n\nfn demo_limbs_checked_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_checked_log_base_2({:?}) = {:?}\",\n            xs,\n            limbs_checked_log_base_2(&xs)\n        );\n    }\n}\n\nfn demo_natural_floor_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"floor_log_base_2({}) = {}\", n, n.floor_log_base_2());\n    }\n}\n\nfn demo_natural_ceiling_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"ceiling_log_base_2({}) = {}\", n, n.ceiling_log_base_2());\n    }\n}\n\nfn demo_natural_checked_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"checked_log_base_2({}) = {:?}\", n, n.checked_log_base_2());\n    }\n}\n\nfn benchmark_limbs_floor_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_floor_log_base_2(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |ref xs| {\n            no_out!(limbs_floor_log_base_2(xs));\n        })],\n    );\n}\n\nfn benchmark_limbs_ceiling_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_ceiling_log_base_2(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |ref xs| {\n            no_out!(limbs_ceiling_log_base_2(xs));\n        })],\n    );\n}\n\nfn benchmark_limbs_checked_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_checked_log_base_2(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |ref xs| {\n            no_out!(limbs_checked_log_base_2(xs));\n        })],\n    );\n}\n\nfn benchmark_natural_floor_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_log_base_2()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.floor_log_base_2()))],\n    );\n}\n\nfn benchmark_natural_ceiling_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_log_base_2()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.ceiling_log_base_2()))],\n    );\n}\n\nfn benchmark_natural_checked_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_log_base_2()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.checked_log_base_2()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBasePowerOf2, CheckedLogBasePowerOf2, FloorLogBasePowerOf2,\n};\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_13;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::log_base_power_of_2::{\n    limbs_ceiling_log_base_power_of_2, limbs_checked_log_base_power_of_2,\n    limbs_floor_log_base_power_of_2,\n};\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_8;\nuse malachite_nz::test_util::natural::arithmetic::log_base_power_of_2::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_floor_log_base_power_of_2);\n    register_demo!(runner, demo_limbs_ceiling_log_base_power_of_2);\n    register_demo!(runner, demo_limbs_checked_log_base_power_of_2);\n    register_demo!(runner, demo_natural_floor_log_base_power_of_2);\n    register_demo!(runner, demo_natural_ceiling_log_base_power_of_2);\n    register_demo!(runner, demo_natural_checked_log_base_power_of_2);\n    register_bench!(runner, benchmark_limbs_floor_log_base_power_of_2);\n    register_bench!(runner, benchmark_limbs_ceiling_log_base_power_of_2);\n    register_bench!(runner, benchmark_limbs_checked_log_base_power_of_2);\n    register_bench!(runner, benchmark_natural_floor_log_base_power_of_2);\n    register_bench!(\n        runner,\n        benchmark_natural_ceiling_log_base_power_of_2_algorithms\n    );\n    register_bench!(runner, benchmark_natural_checked_log_base_power_of_2);\n}\n\nfn demo_limbs_floor_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_floor_log_base_power_of_2({:?}, {}) = {}\",\n            xs,\n            pow,\n            limbs_floor_log_base_power_of_2(&xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_ceiling_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_ceiling_log_base_power_of_2({:?}, {}) = {}\",\n            xs,\n            pow,\n            limbs_ceiling_log_base_power_of_2(&xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_checked_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_13()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_checked_log_base_power_of_2({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_checked_log_base_power_of_2(&xs, pow)\n        );\n    }\n}\n\nfn demo_natural_floor_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"floor_log_base_power_of_2({}, {}) = {}\",\n            n,\n            pow,\n            n.floor_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_natural_ceiling_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"ceiling_log_base_power_of_2({}, {}) = {}\",\n            n,\n            pow,\n            n.ceiling_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_natural_checked_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_8()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"checked_log_base_power_of_2({}, {}) = {:?}\",\n            n,\n            pow,\n            n.checked_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn benchmark_limbs_floor_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_floor_log_base_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, pow)| {\n            no_out!(limbs_floor_log_base_power_of_2(xs, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_ceiling_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_ceiling_log_base_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, pow)| {\n            no_out!(limbs_ceiling_log_base_power_of_2(xs, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_checked_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_checked_log_base_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_13().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, pow)| {\n            no_out!(limbs_checked_log_base_power_of_2(xs, pow));\n        })],\n    );\n}\n\nfn benchmark_natural_floor_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_log_base_power_of_2(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.floor_log_base_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_natural_ceiling_log_base_power_of_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_log_base_power_of_2(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(n, pow)| {\n                no_out!(n.ceiling_log_base_power_of_2(pow));\n            }),\n            (\"naive\", &mut |(ref n, pow)| {\n                no_out!(ceiling_log_base_power_of_2_naive_nz(n, pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_log_base_power_of_2(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.checked_log_base_power_of_2(pow));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    abs_diff::register(runner);\n    add::register(runner);\n    add_mul::register(runner);\n    binomial_coefficient::register(runner);\n    checked_sub::register(runner);\n    checked_sub_mul::register(runner);\n    coprime_with::register(runner);\n    div::register(runner);\n    div_exact::register(runner);\n    div_mod::register(runner);\n    div_round::register(runner);\n    divisible_by::register(runner);\n    divisible_by_power_of_2::register(runner);\n    eq_mod::register(runner);\n    eq_mod_power_of_2::register(runner);\n    extended_gcd::register(runner);\n    factorial::register(runner);\n    gcd::register(runner);\n    is_power_of_2::register(runner);\n    kronecker_symbol::register(runner);\n    lcm::register(runner);\n    log_base::register(runner);\n    log_base_2::register(runner);\n    log_base_power_of_2::register(runner);\n    mod_add::register(runner);\n    mod_inverse::register(runner);\n    mod_is_reduced::register(runner);\n    mod_mul::register(runner);\n    mod_neg::register(runner);\n    mod_op::register(runner);\n    mod_pow::register(runner);\n    mod_power_of_2::register(runner);\n    mod_power_of_2_add::register(runner);\n    mod_power_of_2_inverse::register(runner);\n    mod_power_of_2_is_reduced::register(runner);\n    mod_power_of_2_mul::register(runner);\n    mod_power_of_2_neg::register(runner);\n    mod_power_of_2_pow::register(runner);\n    mod_power_of_2_shl::register(runner);\n    mod_power_of_2_shr::register(runner);\n    mod_power_of_2_square::register(runner);\n    mod_power_of_2_sub::register(runner);\n    mod_shl::register(runner);\n    mod_shr::register(runner);\n    mod_square::register(runner);\n    mod_sub::register(runner);\n    mul::register(runner);\n    neg::register(runner);\n    next_power_of_2::register(runner);\n    parity::register(runner);\n    pow::register(runner);\n    power_of_2::register(runner);\n    primorial::register(runner);\n    root::register(runner);\n    round_to_multiple::register(runner);\n    round_to_multiple_of_power_of_2::register(runner);\n    saturating_sub::register(runner);\n    saturating_sub_mul::register(runner);\n    shl::register(runner);\n    shl_round::register(runner);\n    shr::register(runner);\n    shr_round::register(runner);\n    sign::register(runner);\n    sqrt::register(runner);\n    square::register(runner);\n    sub::register(runner);\n    sub_mul::register(runner);\n}\n\nmod abs_diff;\nmod add;\nmod add_mul;\nmod binomial_coefficient;\nmod checked_sub;\nmod checked_sub_mul;\nmod coprime_with;\nmod div;\nmod div_exact;\nmod div_mod;\nmod div_round;\nmod divisible_by;\nmod divisible_by_power_of_2;\nmod eq_mod;\nmod eq_mod_power_of_2;\nmod extended_gcd;\nmod factorial;\nmod gcd;\nmod is_power_of_2;\nmod kronecker_symbol;\nmod lcm;\nmod log_base;\nmod log_base_2;\nmod log_base_power_of_2;\nmod mod_add;\nmod mod_inverse;\nmod mod_is_reduced;\nmod mod_mul;\nmod mod_neg;\nmod mod_op;\nmod mod_pow;\nmod mod_power_of_2;\nmod mod_power_of_2_add;\nmod mod_power_of_2_inverse;\nmod mod_power_of_2_is_reduced;\nmod mod_power_of_2_mul;\nmod mod_power_of_2_neg;\nmod mod_power_of_2_pow;\nmod mod_power_of_2_shl;\nmod mod_power_of_2_shr;\nmod mod_power_of_2_square;\nmod mod_power_of_2_sub;\nmod mod_shl;\nmod mod_shr;\nmod mod_square;\nmod mod_sub;\nmod mul;\nmod neg;\nmod next_power_of_2;\nmod parity;\nmod pow;\nmod power_of_2;\nmod primorial;\nmod root;\nmod round_to_multiple;\nmod round_to_multiple_of_power_of_2;\nmod saturating_sub;\nmod saturating_sub_mul;\nmod shl;\nmod shl_round;\nmod shr;\nmod shr_round;\nmod sign;\nmod sqrt;\nmod square;\nmod sub;\nmod sub_mul;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModAdd, ModAddAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_triple_gen_var_3;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_add_assign);\n    register_demo!(runner, demo_natural_mod_add_assign_val_ref);\n    register_demo!(runner, demo_natural_mod_add_assign_ref_val);\n    register_demo!(runner, demo_natural_mod_add_assign_ref_ref);\n    register_demo!(runner, demo_natural_mod_add);\n    register_demo!(runner, demo_natural_mod_add_val_val_ref);\n    register_demo!(runner, demo_natural_mod_add_val_ref_val);\n    register_demo!(runner, demo_natural_mod_add_val_ref_ref);\n    register_demo!(runner, demo_natural_mod_add_ref_val_val);\n    register_demo!(runner, demo_natural_mod_add_ref_val_ref);\n    register_demo!(runner, demo_natural_mod_add_ref_ref_val);\n    register_demo!(runner, demo_natural_mod_add_ref_ref_ref);\n\n    register_bench!(runner, benchmark_natural_mod_add_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_add_algorithms);\n    register_bench!(runner, benchmark_natural_mod_add_evaluation_strategy);\n}\n\nfn demo_natural_mod_add_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        x.mod_add_assign(y, m);\n        println!(\"x := {x_old}; x.mod_add_assign({y_old}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_add_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        let y_old = y.clone();\n        x.mod_add_assign(y, &m);\n        println!(\"x := {x}; x.mod_add_assign({y_old}, &{m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_add_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        x.mod_add_assign(&y, m);\n        println!(\"x := {x_old}; x.mod_add_assign(&{y}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_add_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.mod_add_assign(&y, &m);\n        println!(\"x := {x_old}; x.mod_add_assign(&{y}, &{m}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        println!(\"{} + {} ≡ {} mod {}\", x_old, y_old, x.mod_add(y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_add_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} ≡ {} mod {}\", x_old, y_old, x.mod_add(y, &m), m);\n    }\n}\n\nfn demo_natural_mod_add_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        println!(\"{} + {} ≡ {} mod {}\", x_old, y, x.mod_add(&y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_add_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} + {} ≡ {} mod {}\", x_old, y, x.mod_add(&y, &m), m);\n    }\n}\n\nfn demo_natural_mod_add_ref_val_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        let m_old = m.clone();\n        println!(\"{} + {} ≡ {} mod {}\", x, y_old, (&x).mod_add(y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_add_ref_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"{} + {} ≡ {} mod {}\", x, y_old, (&x).mod_add(y, &m), m);\n    }\n}\n\nfn demo_natural_mod_add_ref_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\"{} + {} ≡ {} mod {}\", x, y, (&x).mod_add(&y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_add_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        println!(\"{} + {} ≡ {} mod {}\", x, y, (&x).mod_add(&y, &m), m);\n    }\n}\n\nfn benchmark_natural_mod_add_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_add_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\n                \"Natural.mod_add_assign(Natural, Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_add_assign(y, m)),\n            ),\n            (\n                \"Natural.mod_add_assign(Natural, &Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_add_assign(y, &m)),\n            ),\n            (\n                \"Natural.mod_add_assign(&Natural, Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_add_assign(&y, m)),\n            ),\n            (\n                \"Natural.mod_add_assign(&Natural, &Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_add_assign(&y, &m)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_mod_add_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_add(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, y, m)| no_out!(x.mod_add(y, m))),\n            (\"naive\", &mut |(x, y, m)| no_out!((x + y) % m)),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_add_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_add(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_add(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_add(y, m));\n            }),\n            (\"Natural.mod_add(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_add(y, &m));\n            }),\n            (\"Natural.mod_add(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_add(&y, m));\n            }),\n            (\"Natural.mod_add(&Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_add(&y, &m));\n            }),\n            (\"(&Natural).mod_add(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_add(y, m));\n            }),\n            (\"(&Natural).mod_add(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_add(y, &m));\n            }),\n            (\"(&Natural).mod_add(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_add(&y, m));\n            }),\n            (\n                \"(&Natural).mod_add(&Natural, &Natural)\",\n                &mut |(x, y, m)| no_out!((&x).mod_add(&y, &m)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ModInverse;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_2_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_11;\nuse malachite_nz::test_util::natural::arithmetic::mod_inverse::mod_inverse_simple;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_inverse);\n    register_demo!(runner, demo_natural_mod_inverse_val_ref);\n    register_demo!(runner, demo_natural_mod_inverse_ref_val);\n    register_demo!(runner, demo_natural_mod_inverse_ref_ref);\n\n    register_bench!(runner, benchmark_natural_mod_inverse_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_inverse_algorithms);\n}\n\nfn demo_natural_mod_inverse(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_11().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        if let Some(inverse) = n.mod_inverse(m) {\n            println!(\"{n_old}⁻¹ ≡ {inverse} mod {m_old}\");\n        } else {\n            println!(\"{n_old} is not invertible mod {m_old}\");\n        }\n    }\n}\n\nfn demo_natural_mod_inverse_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_11().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        if let Some(inverse) = n.mod_inverse(&m) {\n            println!(\"{n_old}⁻¹ ≡ {inverse} mod {m}\");\n        } else {\n            println!(\"{n_old} is not invertible mod {m}\");\n        }\n    }\n}\n\nfn demo_natural_mod_inverse_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_11().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        if let Some(inverse) = (&n).mod_inverse(m) {\n            println!(\"{n}⁻¹ ≡ {inverse} mod {m_old}\");\n        } else {\n            println!(\"{n} is not invertible mod {m_old}\");\n        }\n    }\n}\n\nfn demo_natural_mod_inverse_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_11().get(gm, config).take(limit) {\n        if let Some(inverse) = (&n).mod_inverse(&m) {\n            println!(\"{n}⁻¹ ≡ {inverse} mod {m}\");\n        } else {\n            println!(\"{n} is not invertible mod {m}\");\n        }\n    }\n}\n\nfn benchmark_natural_mod_inverse_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_inverse(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_inverse(Natural)\", &mut |(n, m)| {\n                no_out!(n.mod_inverse(m));\n            }),\n            (\"Natural.mod_inverse(&Natural)\", &mut |(n, m)| {\n                no_out!(n.mod_inverse(&m));\n            }),\n            (\"(&Natural).mod_inverse(Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_inverse(m));\n            }),\n            (\"(&Natural).mod_inverse(&Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_inverse(&m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_inverse_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_inverse(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(n, m)| no_out!(n.mod_inverse(m))),\n            (\"simple\", &mut |(n, m)| no_out!(mod_inverse_simple(n, m))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ModIsReduced;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_5;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_is_reduced);\n\n    register_bench!(runner, benchmark_natural_mod_is_reduced);\n}\n\nfn demo_natural_mod_is_reduced(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        if n.mod_is_reduced(&m) {\n            println!(\"{n} is reduced mod {m}\");\n        } else {\n            println!(\"{n} is not reduced mod {m}\");\n        }\n    }\n}\n\nfn benchmark_natural_mod_is_reduced(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_is_reduced(&Natural)\",\n        BenchmarkType::Single,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, m)| no_out!(n.mod_is_reduced(&m)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModMul, ModMulAssign, ModMulPrecomputed};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_36;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_mul::{\n    limbs_mod_mul_two_limbs, limbs_precompute_mod_mul_two_limbs,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    limb_pair_significant_bits_bucketer, limbs_mod_mul_two_limbs_bucketer,\n    triple_3_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{large_type_gen_var_21, natural_triple_gen_var_3};\nuse malachite_nz::test_util::natural::arithmetic::mod_mul::{\n    limbs_mod_mul_two_limbs_naive, limbs_precompute_mod_mul_two_limbs_alt,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_precompute_mod_mul_two_limbs);\n    register_demo!(runner, demo_limbs_mod_mul_two_limbs);\n    register_demo!(runner, demo_natural_mod_mul_assign);\n    register_demo!(runner, demo_natural_mod_mul_assign_val_ref);\n    register_demo!(runner, demo_natural_mod_mul_assign_ref_val);\n    register_demo!(runner, demo_natural_mod_mul_assign_ref_ref);\n    register_demo!(runner, demo_natural_mod_mul);\n    register_demo!(runner, demo_natural_mod_mul_val_val_ref);\n    register_demo!(runner, demo_natural_mod_mul_val_ref_val);\n    register_demo!(runner, demo_natural_mod_mul_val_ref_ref);\n    register_demo!(runner, demo_natural_mod_mul_ref_val_val);\n    register_demo!(runner, demo_natural_mod_mul_ref_val_ref);\n    register_demo!(runner, demo_natural_mod_mul_ref_ref_val);\n    register_demo!(runner, demo_natural_mod_mul_ref_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_limbs_precompute_mod_mul_two_limbs_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_mod_mul_two_limbs);\n    register_bench!(runner, benchmark_natural_mod_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_mul_algorithms);\n    register_bench!(runner, benchmark_natural_mod_mul_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_mul_precomputed_algorithms);\n}\n\nfn demo_limbs_precompute_mod_mul_two_limbs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (m_1, m_0) in unsigned_pair_gen_var_36().get(gm, config).take(limit) {\n        println!(\n            \"limbs_precompute_mod_mul_two_limbs({}, {}) = {:?}\",\n            m_1,\n            m_0,\n            limbs_precompute_mod_mul_two_limbs(m_1, m_0)\n        );\n    }\n}\n\nfn demo_limbs_mod_mul_two_limbs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x_1, x_0, y_1, y_0, m_1, m_0, inv_2, inv_1, inv_0) in\n        large_type_gen_var_21().get(gm, config).take(limit)\n    {\n        println!(\n            \"limbs_mod_mul_two_limbs({}, {}, {}, {}, {}, {}, {}, {}, {}) = {:?}\",\n            x_1,\n            x_0,\n            y_1,\n            y_0,\n            m_1,\n            m_0,\n            inv_2,\n            inv_1,\n            inv_0,\n            limbs_mod_mul_two_limbs(x_1, x_0, y_1, y_0, m_1, m_0, inv_2, inv_1, inv_0)\n        );\n    }\n}\n\nfn demo_natural_mod_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        x.mod_mul_assign(y, m);\n        println!(\"x := {x_old}; x.mod_mul_assign({y_old}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_mul_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        let y_old = y.clone();\n        x.mod_mul_assign(y, &m);\n        println!(\"x := {x}; x.mod_mul_assign({y_old}, &{m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_mul_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        x.mod_mul_assign(&y, m);\n        println!(\"x := {x_old}; x.mod_mul_assign(&{y}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_mul_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.mod_mul_assign(&y, &m);\n        println!(\"x := {x_old}; x.mod_mul_assign(&{y}, &{m}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        println!(\"{} * {} ≡ {} mod {}\", x_old, y_old, x.mod_mul(y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_mul_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} ≡ {} mod {}\", x_old, y_old, x.mod_mul(y, &m), m);\n    }\n}\n\nfn demo_natural_mod_mul_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        println!(\"{} * {} ≡ {} mod {}\", x_old, y, x.mod_mul(&y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_mul_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} * {} ≡ {} mod {}\", x_old, y, x.mod_mul(&y, &m), m);\n    }\n}\n\nfn demo_natural_mod_mul_ref_val_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        let m_old = m.clone();\n        println!(\"{} * {} ≡ {} mod {}\", x, y_old, (&x).mod_mul(y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_mul_ref_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"{} * {} ≡ {} mod {}\", x, y_old, (&x).mod_mul(y, &m), m);\n    }\n}\n\nfn demo_natural_mod_mul_ref_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\"{} * {} ≡ {} mod {}\", x, y, (&x).mod_mul(&y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_mul_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        println!(\"{} * {} ≡ {} mod {}\", x, y, (&x).mod_mul(&y, &m), m);\n    }\n}\n\nfn benchmark_limbs_precompute_mod_mul_two_limbs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_precompute_mod_mul_two_limbs(Limb, Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_pair_gen_var_36().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limb_pair_significant_bits_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(m_1, m_0)| {\n                no_out!(limbs_precompute_mod_mul_two_limbs(m_1, m_0));\n            }),\n            (\"alt\", &mut |(m_1, m_0)| {\n                no_out!(limbs_precompute_mod_mul_two_limbs_alt(m_1, m_0));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_mul_two_limbs(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_mul_two_limbs(Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb)\",\n        BenchmarkType::Single,\n        large_type_gen_var_21().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limbs_mod_mul_two_limbs_bucketer(),\n        &mut [\n            (\"default\", &mut |(\n                x_1,\n                x_0,\n                y_1,\n                y_0,\n                m_1,\n                m_0,\n                inv_2,\n                inv_1,\n                inv_0,\n            )| {\n                no_out!(limbs_mod_mul_two_limbs(\n                    x_1, x_0, y_1, y_0, m_1, m_0, inv_2, inv_1, inv_0\n                ));\n            }),\n            (\"naive\", &mut |(x_1, x_0, y_1, y_0, m_1, m_0, _, _, _)| {\n                no_out!(limbs_mod_mul_two_limbs_naive(x_1, x_0, y_1, y_0, m_1, m_0));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_mul_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\n                \"Natural.mod_mul_assign(Natural, Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_mul_assign(y, m)),\n            ),\n            (\n                \"Natural.mod_mul_assign(Natural, &Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_mul_assign(y, &m)),\n            ),\n            (\n                \"Natural.mod_mul_assign(&Natural, Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_mul_assign(&y, m)),\n            ),\n            (\n                \"Natural.mod_mul_assign(&Natural, &Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_mul_assign(&y, &m)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_mod_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_mul(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, y, m)| no_out!(x.mod_mul(y, m))),\n            (\"naive\", &mut |(x, y, m)| no_out!((x * y) % m)),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_mul(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_mul(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_mul(y, m));\n            }),\n            (\"Natural.mod_mul(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_mul(y, &m));\n            }),\n            (\"Natural.mod_mul(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_mul(&y, m));\n            }),\n            (\"Natural.mod_mul(&Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_mul(&y, &m));\n            }),\n            (\"(&Natural).mod_mul(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_mul(y, m));\n            }),\n            (\"(&Natural).mod_mul(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_mul(y, &m));\n            }),\n            (\"(&Natural).mod_mul(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_mul(&y, m));\n            }),\n            (\n                \"(&Natural).mod_mul(&Natural, &Natural)\",\n                &mut |(x, y, m)| no_out!((&x).mod_mul(&y, &m)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_mul_precomputed_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_mul_precomputed(Natural, Natural, &ModMulData)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, y, m)| {\n                for _ in 0..10 {\n                    (&x).mod_mul(&y, &m);\n                }\n            }),\n            (\"precomputed\", &mut |(x, y, m)| {\n                let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&m);\n                for _ in 0..10 {\n                    (&x).mod_mul_precomputed(&y, &m, &data);\n                }\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Mod, ModNeg, ModNegAssign};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_2_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_8;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_neg_assign);\n    register_demo!(runner, demo_natural_mod_neg_assign_ref);\n    register_demo!(runner, demo_natural_mod_neg);\n    register_demo!(runner, demo_natural_mod_neg_val_ref);\n    register_demo!(runner, demo_natural_mod_neg_ref_val);\n    register_demo!(runner, demo_natural_mod_neg_ref_ref);\n\n    register_bench!(runner, benchmark_natural_mod_neg_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_neg_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_neg_algorithms);\n}\n\nfn demo_natural_mod_neg_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        n.mod_neg_assign(m);\n        println!(\"x := {n_old}; x.mod_neg_assign({m_old}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_neg_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.mod_neg_assign(&m);\n        println!(\"x := {n_old}; x.mod_neg_assign(&{m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        println!(\"-{} ≡ {} mod {}\", n_old, n.mod_neg(m), m_old);\n    }\n}\n\nfn demo_natural_mod_neg_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\"-{} ≡ {} mod &{}\", n_old, n.mod_neg(&m), m);\n    }\n}\n\nfn demo_natural_mod_neg_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\"&(-{}) ≡ {} mod {}\", n, (&n).mod_neg(m), m_old);\n    }\n}\n\nfn demo_natural_mod_neg_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\"&(-{}) ≡ {} mod &{}\", n, (&n).mod_neg(&m), m);\n    }\n}\n\nfn benchmark_natural_mod_neg_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_neg_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_neg_assign(Natural)\", &mut |(mut n, m)| {\n                n.mod_neg_assign(m);\n            }),\n            (\"Natural.mod_neg_assign(&Natural)\", &mut |(mut n, m)| {\n                n.mod_neg_assign(&m);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_neg_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_neg(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_neg(Natural)\", &mut |(n, m)| {\n                no_out!(n.mod_neg(m));\n            }),\n            (\"Natural.mod_neg(&Natural)\", &mut |(n, m)| {\n                no_out!(n.mod_neg(&m));\n            }),\n            (\"(&Natural).mod_neg(Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_neg(m));\n            }),\n            (\"(&Natural).mod_neg(&Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_neg(&m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_neg_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_neg(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_neg(Natural)\", &mut |(n, m)| {\n                no_out!(n.mod_neg(m));\n            }),\n            (\"(-Natural).mod(Natural)\", &mut |(n, m)| {\n                no_out!(Natural::exact_from((-n).mod_op(Integer::from(m))));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivMod;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivNegMod, Mod, ModAssign, NegMod, NegModAssign,\n};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_1_vec_len_sub_1_bucketer, quadruple_2_3_diff_vec_len_bucketer,\n    quadruple_2_vec_len_bucketer, quadruple_3_vec_len_bucketer, quadruple_4_vec_len_bucketer,\n    triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_24;\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_11, unsigned_vec_pair_gen_var_18, unsigned_vec_triple_gen_var_57,\n    unsigned_vec_unsigned_pair_gen_var_22, unsigned_vec_unsigned_pair_gen_var_25,\n    unsigned_vec_unsigned_pair_gen_var_26, unsigned_vec_unsigned_pair_gen_var_27,\n    unsigned_vec_unsigned_pair_gen_var_28,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::div_mod::{\n    limbs_div_mod_barrett, limbs_div_mod_barrett_scratch_len, limbs_div_mod_by_two_limb_normalized,\n    limbs_div_mod_divide_and_conquer, limbs_div_mod_schoolbook, limbs_div_mod_to_out,\n};\nuse malachite_nz::natural::arithmetic::mod_op::{\n    limbs_mod, limbs_mod_barrett, limbs_mod_by_two_limb_normalized, limbs_mod_divide_and_conquer,\n    limbs_mod_limb, limbs_mod_limb_alt_1, limbs_mod_limb_alt_2, limbs_mod_limb_any_leading_zeros,\n    limbs_mod_limb_any_leading_zeros_1, limbs_mod_limb_any_leading_zeros_2,\n    limbs_mod_limb_at_least_1_leading_zero, limbs_mod_limb_at_least_2_leading_zeros,\n    limbs_mod_limb_small_normalized, limbs_mod_limb_small_normalized_large,\n    limbs_mod_limb_small_small, limbs_mod_limb_small_unnormalized,\n    limbs_mod_limb_small_unnormalized_large, limbs_mod_schoolbook,\n    limbs_mod_three_limb_by_two_limb, limbs_mod_to_out,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::bench::bucketers::{\n    limbs_mod_limb_small_unnormalized_bucketer, pair_1_natural_bit_bucketer,\n    pair_2_pair_1_natural_bit_bucketer, triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_11, large_type_gen_var_12, natural_pair_gen_var_5,\n    natural_pair_gen_var_5_nrm, natural_pair_gen_var_5_rm, unsigned_sextuple_gen_var_2,\n    unsigned_vec_quadruple_gen_var_1, unsigned_vec_quadruple_gen_var_5,\n    unsigned_vec_triple_gen_var_56, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_17,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_op::{limbs_mod_limb_alt_3, rug_neg_mod};\nuse num::Integer;\nuse rug::ops::RemRounding;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_mod_limb);\n    register_demo!(runner, demo_limbs_mod_limb_small_normalized);\n    register_demo!(runner, demo_limbs_mod_limb_small_unnormalized);\n    register_demo!(runner, demo_limbs_mod_limb_any_leading_zeros_1);\n    register_demo!(runner, demo_limbs_mod_limb_any_leading_zeros_2);\n    register_demo!(runner, demo_limbs_mod_limb_at_least_1_leading_zero);\n    register_demo!(runner, demo_limbs_mod_limb_at_least_2_leading_zeros);\n    register_demo!(runner, demo_limbs_mod_three_limb_by_two_limb);\n    register_demo!(runner, demo_limbs_mod_by_two_limb_normalized);\n    register_demo!(runner, demo_limbs_mod_schoolbook);\n    register_demo!(runner, demo_limbs_mod_divide_and_conquer);\n    register_demo!(runner, demo_limbs_mod_barrett);\n    register_demo!(runner, demo_limbs_mod);\n    register_demo!(runner, demo_limbs_mod_to_out);\n    register_demo!(runner, demo_natural_mod_assign);\n    register_demo!(runner, demo_natural_mod_assign_ref);\n    register_demo!(runner, demo_natural_mod);\n    register_demo!(runner, demo_natural_mod_val_ref);\n    register_demo!(runner, demo_natural_mod_ref_val);\n    register_demo!(runner, demo_natural_mod_ref_ref);\n    register_demo!(runner, demo_natural_rem_assign);\n    register_demo!(runner, demo_natural_rem_assign_ref);\n    register_demo!(runner, demo_natural_rem);\n    register_demo!(runner, demo_natural_rem_val_ref);\n    register_demo!(runner, demo_natural_rem_ref_val);\n    register_demo!(runner, demo_natural_rem_ref_ref);\n    register_demo!(runner, demo_natural_neg_mod_assign);\n    register_demo!(runner, demo_natural_neg_mod_assign_ref);\n    register_demo!(runner, demo_natural_neg_mod);\n    register_demo!(runner, demo_natural_neg_mod_val_ref);\n    register_demo!(runner, demo_natural_neg_mod_ref_val);\n    register_demo!(runner, demo_natural_neg_mod_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_mod_limb_algorithms);\n    register_bench!(runner, benchmark_limbs_mod_limb_small_normalized_algorithms);\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_limb_small_unnormalized_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_limb_any_leading_zeros_from_normalized_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_limb_any_leading_zeros_from_unnormalized_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_limb_at_least_1_leading_zero_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_limb_at_least_2_leading_zeros_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_by_two_limb_normalized_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_mod_schoolbook_algorithms);\n    register_bench!(runner, benchmark_limbs_mod_divide_and_conquer_algorithms);\n    register_bench!(runner, benchmark_limbs_mod_barrett_algorithms);\n    register_bench!(runner, benchmark_limbs_mod);\n    register_bench!(runner, benchmark_limbs_mod_to_out_algorithms);\n    register_bench!(runner, benchmark_natural_mod_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_library_comparison);\n    register_bench!(runner, benchmark_natural_mod_algorithms);\n    register_bench!(runner, benchmark_natural_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_rem_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_rem_library_comparison);\n    register_bench!(runner, benchmark_natural_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_neg_mod_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_neg_mod_library_comparison);\n    register_bench!(runner, benchmark_natural_neg_mod_algorithms);\n    register_bench!(runner, benchmark_natural_neg_mod_evaluation_strategy);\n}\n\nfn demo_limbs_mod_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_limb({:?}, {}) = {}\",\n            ns,\n            d,\n            limbs_mod_limb::<DoubleLimb, Limb>(&ns, d)\n        );\n    }\n}\n\nfn demo_limbs_mod_limb_small_normalized(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d) in unsigned_vec_unsigned_pair_gen_var_26()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_limb_small_normalized({:?}, {}) = {}\",\n            ns,\n            d,\n            limbs_mod_limb_small_normalized::<DoubleLimb, Limb>(&ns, d)\n        );\n    }\n}\n\nfn demo_limbs_mod_limb_small_unnormalized(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d) in unsigned_vec_unsigned_pair_gen_var_27()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_limb_small_unnormalized({:?}, {}) = {}\",\n            ns,\n            d,\n            limbs_mod_limb_small_unnormalized::<DoubleLimb, Limb>(&ns, d)\n        );\n    }\n}\n\nfn demo_limbs_mod_limb_any_leading_zeros_1(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_limb_any_leading_zeros_1({:?}, {}) = {}\",\n            ns,\n            d,\n            limbs_mod_limb_any_leading_zeros_1::<DoubleLimb, Limb>(&ns, d)\n        );\n    }\n}\n\nfn demo_limbs_mod_limb_any_leading_zeros_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d) in unsigned_vec_unsigned_pair_gen_var_22()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_limb_any_leading_zeros_2({:?}, {}) = {}\",\n            ns,\n            d,\n            limbs_mod_limb_any_leading_zeros_2::<DoubleLimb, Limb>(&ns, d)\n        );\n    }\n}\n\nfn demo_limbs_mod_limb_at_least_1_leading_zero(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d) in unsigned_vec_unsigned_pair_gen_var_27()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_limb_at_least_1_leading_zero({:?}, {}) = {}\",\n            ns,\n            d,\n            limbs_mod_limb_at_least_1_leading_zero::<DoubleLimb, Limb>(&ns, d)\n        );\n    }\n}\n\nfn demo_limbs_mod_limb_at_least_2_leading_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, d) in unsigned_vec_unsigned_pair_gen_var_28()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_limb_at_least_2_leading_zeros({:?}, {}) = {}\",\n            ns,\n            d,\n            limbs_mod_limb_at_least_2_leading_zeros::<DoubleLimb, Limb>(&ns, d)\n        );\n    }\n}\n\nfn demo_limbs_mod_three_limb_by_two_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n2, n1, n0, d1, d0, inverse) in unsigned_sextuple_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"limbs_mod_three_limb_by_two_limb({}, {}, {}, {}, {}, {}) = {}\",\n            n2,\n            n1,\n            n0,\n            d1,\n            d0,\n            inverse,\n            limbs_mod_three_limb_by_two_limb(n2, n1, n0, d1, d0, inverse)\n        );\n    }\n}\n\nfn demo_limbs_mod_by_two_limb_normalized(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, ds) in unsigned_vec_pair_gen_var_18().get(gm, config).take(limit) {\n        println!(\n            \"limbs_mod_by_two_limb_normalized({:?}, {:?}) = {:?}\",\n            ns,\n            ds,\n            limbs_mod_by_two_limb_normalized(&ns, &ds),\n        );\n    }\n}\n\nfn demo_limbs_mod_schoolbook(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut ns, ds, inverse) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_17()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_ns = ns.clone();\n        limbs_mod_schoolbook(&mut ns, &ds, inverse);\n        println!(\"ns := {old_ns:?}; limbs_mod_schoolbook(&mut ns, {ds:?}, {inverse}); ns = {ns:?}\");\n    }\n}\n\nfn demo_limbs_mod_divide_and_conquer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut ns, ds, inverse) in large_type_gen_var_12().get(gm, config).take(limit) {\n        let old_qs = qs.clone();\n        let old_ns = ns.clone();\n        limbs_mod_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n        println!(\n            \"qs := {old_qs:?}; ns := {old_ns:?}; \\\n             limbs_mod_divide_and_conquer(&mut qs, &mut ns, {ds:?}, {inverse}); ns = {ns:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod_barrett(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut qs, mut rs, ns, ds) in unsigned_vec_quadruple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_qs = qs.clone();\n        let old_rs = rs.clone();\n        let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n        limbs_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n        println!(\n            \"qs := {old_qs:?}; \\\n            rs := {old_rs:?}; limbs_mod_barrett(&mut qs, &mut ns, {ns:?}, {ds:?}); rs = {rs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ns, ds) in unsigned_vec_pair_gen_var_11().get(gm, config).take(limit) {\n        println!(\"limbs_mod({:?}, {:?}) = {:?}\", ns, ds, limbs_mod(&ns, &ds));\n    }\n}\n\nfn demo_limbs_mod_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut rs, ns, ds) in unsigned_vec_triple_gen_var_57().get(gm, config).take(limit) {\n        let old_rs = rs.clone();\n        limbs_mod_to_out(&mut rs, &ns, &ds);\n        println!(\"rs := {old_rs:?}; limbs_mod_to_out(&mut rs, {ns:?}, {ds:?}); rs = {rs:?}\");\n    }\n}\n\nfn demo_natural_mod_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mod_assign(y);\n        println!(\"x := {x_old}; x.mod_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.mod_assign(&y);\n        println!(\"x := {x_old}; x.mod_assign(&{y}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.mod_op({}) = {}\", x_old, y_old, x.mod_op(y));\n    }\n}\n\nfn demo_natural_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.mod_op(&{}) = {}\", x_old, y, x.mod_op(&y));\n    }\n}\n\nfn demo_natural_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).mod_op({}) = {:?}\", x, y_old, (&x).mod_op(y));\n    }\n}\n\nfn demo_natural_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\"(&{}).mod_op(&{}) = {:?}\", x, y, (&x).mod_op(&y));\n    }\n}\n\nfn demo_natural_rem_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x %= y;\n        println!(\"x := {x_old}; x %= {y_old}; x = {x}\");\n    }\n}\n\nfn demo_natural_rem_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x %= &y;\n        println!(\"x := {x_old}; x %= &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} % {} = {:?}\", x_old, y_old, x % y);\n    }\n}\n\nfn demo_natural_rem_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} % &{} = {:?}\", x_old, y, x % &y);\n    }\n}\n\nfn demo_natural_rem_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} % {} = {:?}\", x, y_old, &x % y);\n    }\n}\n\nfn demo_natural_rem_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\"&{} % &{} = {:?}\", x, y, &x % &y);\n    }\n}\n\nfn demo_natural_neg_mod_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.neg_mod_assign(y);\n        println!(\"x := {x_old}; x.neg_mod_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_neg_mod_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.neg_mod_assign(&y);\n        println!(\"x := {x_old}; x.neg_mod_assign(&{y}); x = {x}\");\n    }\n}\n\nfn demo_natural_neg_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.neg_mod({}) = {}\", x_old, y_old, x.neg_mod(y));\n    }\n}\n\nfn demo_natural_neg_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.neg_mod(&{}) = {}\", x_old, y, x.neg_mod(&y));\n    }\n}\n\nfn demo_natural_neg_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).neg_mod({}) = {}\", x, y_old, (&x).neg_mod(y));\n    }\n}\n\nfn demo_natural_neg_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\"(&{}).neg_mod(&{}) = {}\", x, y, (&x).neg_mod(&y));\n    }\n}\n\nfn benchmark_limbs_mod_limb_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_limb(&[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"alt 1\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_alt_1::<DoubleLimb, Limb>(&ns, d));\n            }),\n            (\"alt 2\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_alt_2::<DoubleLimb, Limb>(&ns, d));\n            }),\n            (\"alt 3\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_alt_3(&ns, d));\n            }),\n            (\"limbs_mod_limb_any_leading_zeros_1\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_any_leading_zeros_1::<DoubleLimb, Limb>(\n                    &ns, d\n                ));\n            }),\n            (\"limbs_mod_limb_any_leading_zeros_2\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_any_leading_zeros_2::<DoubleLimb, Limb>(\n                    &ns, d\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_limb_small_normalized_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_limb_small_normalized(&[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_26().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_sub_1_bucketer(\"ns\"),\n        &mut [\n            (\"small\", &mut |(ns, d)| {\n                let mut len = ns.len();\n                let mut r = ns[len - 1];\n                if r >= d {\n                    r -= d;\n                }\n                len -= 1;\n                if len == 0 {\n                    return;\n                }\n                limbs_mod_limb_small_small::<DoubleLimb, Limb>(&ns[..len], d, r);\n            }),\n            (\"large\", &mut |(ns, d)| {\n                let mut len = ns.len();\n                let mut r = ns[len - 1];\n                if r >= d {\n                    r -= d;\n                }\n                len -= 1;\n                if len == 0 {\n                    return;\n                }\n                limbs_mod_limb_small_normalized_large::<DoubleLimb, Limb>(&ns[..len], d, r);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_limb_small_unnormalized_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_limb_small_unnormalized(&[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_27().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &limbs_mod_limb_small_unnormalized_bucketer(),\n        &mut [\n            (\"small\", &mut |(ns, d)| {\n                let mut len = ns.len();\n                let mut r = ns[len - 1];\n                if r < d {\n                    len -= 1;\n                    if len == 0 {\n                        return;\n                    }\n                } else {\n                    r = 0;\n                }\n                limbs_mod_limb_small_small::<DoubleLimb, Limb>(&ns[..len], d, r);\n            }),\n            (\"large\", &mut |(ns, d)| {\n                let mut len = ns.len();\n                let mut r = ns[len - 1];\n                if r < d {\n                    len -= 1;\n                    if len == 0 {\n                        return;\n                    }\n                } else {\n                    r = 0;\n                }\n                limbs_mod_limb_small_unnormalized_large::<DoubleLimb, Limb>(&ns[..len], d, r);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_limb_any_leading_zeros_from_normalized_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_limb_any_leading_zeros(&[Limb], Limb) from normalized\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_24().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"limbs_mod_limb_small_normalized\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_small_normalized::<DoubleLimb, Limb>(&ns, d));\n            }),\n            (\"limbs_mod_limb_any_leading_zeros\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_any_leading_zeros::<DoubleLimb, Limb>(&ns, d));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_limb_any_leading_zeros_from_unnormalized_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_limb_any_leading_zeros(&[Limb], Limb) from unnormalized\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_25().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"limbs_mod_limb_small_unnormalized\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_small_unnormalized::<DoubleLimb, Limb>(\n                    &ns, d\n                ));\n            }),\n            (\"limbs_mod_limb_any_leading_zeros\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_any_leading_zeros::<DoubleLimb, Limb>(&ns, d));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_limb_at_least_1_leading_zero_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_limb_at_least_1_leading_zero(&[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_25().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"limbs_mod_limb_any_leading_zeros\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_any_leading_zeros::<DoubleLimb, Limb>(&ns, d));\n            }),\n            (\"limbs_mod_limb_at_least_1_leading_zero\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_at_least_1_leading_zero::<DoubleLimb, Limb>(\n                    &ns, d\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_limb_at_least_2_leading_zeros_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_limb_at_least_2_leading_zeros(&[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_28().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"Malachite\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_at_least_1_leading_zero::<DoubleLimb, Limb>(\n                    &ns, d\n                ));\n            }),\n            (\"limbs_mod_limb_at_least_2_leading_zeros\", &mut |(ns, d)| {\n                no_out!(limbs_mod_limb_at_least_2_leading_zeros::<DoubleLimb, Limb>(\n                    &ns, d\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_by_two_limb_normalized_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_by_two_limb_normalized(&[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_56().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"using div/mod\", &mut |(mut qs, mut ns, ds)| {\n                no_out!(limbs_div_mod_by_two_limb_normalized(&mut qs, &mut ns, &ds));\n            }),\n            (\"standard\", &mut |(_, ns, ds)| {\n                no_out!(limbs_mod_by_two_limb_normalized(&ns, &ds));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_schoolbook_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_schoolbook(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"using div/mod\", &mut |(mut qs, mut ns, ds, inverse)| {\n                no_out!(limbs_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse));\n            }),\n            (\"standard\", &mut |(_, mut ns, ds, inverse)| {\n                limbs_mod_schoolbook(&mut ns, &ds, inverse);\n            }),\n        ],\n    );\n}\n\n// use large params\nfn benchmark_limbs_mod_divide_and_conquer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_divide_and_conquer(&mut [Limb], &mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Algorithms,\n        large_type_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_3_diff_vec_len_bucketer(\"ns\", \"ds\"),\n        &mut [\n            (\"Schoolbook\", &mut |(_, mut ns, ds, inverse)| {\n                limbs_mod_schoolbook(&mut ns, &ds, inverse);\n            }),\n            (\"divide-and-conquer using div/mod\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                no_out!(limbs_div_mod_divide_and_conquer(\n                    &mut qs, &mut ns, &ds, inverse\n                ));\n            }),\n            (\"divide-and-conquer\", &mut |(\n                mut qs,\n                mut ns,\n                ds,\n                inverse,\n            )| {\n                limbs_mod_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod_barrett_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_barrett(&mut [Limb], &mut [Limb], &[Limb], &[Limb], &mut Limb)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_quadruple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_4_vec_len_bucketer(\"ds\"),\n        &mut [\n            (\"Barrett using div/mod\", &mut |(mut qs, mut rs, ns, ds)| {\n                let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n                limbs_div_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n            }),\n            (\"Barrett\", &mut |(mut qs, mut rs, ns, ds)| {\n                let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n                limbs_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mod(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mod(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"ds\"),\n        &mut [(\"Malachite\", &mut |(ns, ds)| no_out!(limbs_mod(&ns, &ds)))],\n    );\n}\n\nfn benchmark_limbs_mod_to_out_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"ns\"),\n        &mut [\n            (\"using div/mod\", &mut |(qs, mut rs, ns, ds)| {\n                // Allocate again to make benchmark fair\n                let mut qs = vec![0; qs.len()];\n                limbs_div_mod_to_out(&mut qs, &mut rs, &ns, &ds);\n            }),\n            (\"standard\", &mut |(_, mut rs, ns, ds)| {\n                limbs_mod_to_out(&mut rs, &ns, &ds);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.mod_assign(Natural)\", &mut |(mut x, y)| {\n                no_out!(x.mod_assign(y));\n            }),\n            (\"Natural.mod_assign(&Natural)\", &mut |(mut x, y)| {\n                no_out!(x.mod_assign(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_op(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.mod_op(y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.mod_floor(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.rem_floor(y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_natural_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_op(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.mod_op(y))),\n            (\"using div_mod\", &mut |(x, y)| no_out!(x.div_mod(y).1)),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_op(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.mod_op(Natural)\", &mut |(x, y)| {\n                no_out!(x.mod_op(y));\n            }),\n            (\"Natural.mod_op(&Natural)\", &mut |(x, y)| {\n                no_out!(x.mod_op(&y));\n            }),\n            (\"(&Natural).mod_op(Natural)\", &mut |(x, y)| {\n                no_out!((&x).mod_op(y));\n            }),\n            (\"(&Natural).mod_op(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).mod_op(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_rem_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural %= Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural %= Natural\", &mut |(mut x, y)| x %= y),\n            (\"Natural %= &Natural\", &mut |(mut x, y)| x %= &y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural % Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x % y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x % y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x % y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural % Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural % Natural\", &mut |(x, y)| no_out!(x % y)),\n            (\"Natural % &Natural\", &mut |(x, y)| no_out!(x % &y)),\n            (\"&Natural % Natural\", &mut |(x, y)| no_out!(&x % y)),\n            (\"&Natural % &Natural\", &mut |(x, y)| no_out!(&x % &y)),\n        ],\n    );\n}\n\nfn benchmark_natural_neg_mod_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.neg_mod_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.neg_mod_assign(Natural)\", &mut |(mut x, y)| {\n                no_out!(x.neg_mod_assign(y));\n            }),\n            (\"Natural.neg_mod_assign(&Natural)\", &mut |(mut x, y)| {\n                no_out!(x.neg_mod_assign(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_neg_mod_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.neg_mod(Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_5_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.neg_mod(y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(rug_neg_mod(x, y))),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_natural_neg_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.neg_mod(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |(x, y)| no_out!(x.neg_mod(y))),\n            (\"using ceiling_div_neg_mod\", &mut |(x, y)| {\n                no_out!(x.ceiling_div_neg_mod(y).1);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_neg_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.neg_mod(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.neg_mod(Natural)\", &mut |(x, y)| {\n                no_out!(x.neg_mod(y));\n            }),\n            (\"Natural.neg_mod(&Natural)\", &mut |(x, y)| {\n                no_out!(x.neg_mod(&y));\n            }),\n            (\"(&Natural).neg_mod(Natural)\", &mut |(x, y)| {\n                no_out!((&x).neg_mod(y));\n            }),\n            (\"(&Natural).neg_mod(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).neg_mod(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPow, ModPowAssign};\nuse malachite_base::test_util::bench::bucketers::quadruple_4_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::mod_pow::{\n    limbs_mod_pow, limbs_mod_pow_odd, limbs_mod_pow_odd_scratch_len,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    triple_1_3_prod_natural_bits_bucketer, triple_3_triple_1_3_prod_natural_bits_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_triple_gen_var_5, natural_triple_gen_var_5_nrm, unsigned_vec_quadruple_gen_var_6,\n    unsigned_vec_quadruple_gen_var_7,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_pow::simple_binary_mod_pow;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_mod_pow_odd);\n    register_demo!(runner, demo_limbs_mod_pow);\n    register_demo!(runner, demo_natural_mod_pow_assign);\n    register_demo!(runner, demo_natural_mod_pow_assign_val_ref);\n    register_demo!(runner, demo_natural_mod_pow_assign_ref_val);\n    register_demo!(runner, demo_natural_mod_pow_assign_ref_ref);\n    register_demo!(runner, demo_natural_mod_pow);\n    register_demo!(runner, demo_natural_mod_pow_val_val_ref);\n    register_demo!(runner, demo_natural_mod_pow_val_ref_val);\n    register_demo!(runner, demo_natural_mod_pow_val_ref_ref);\n    register_demo!(runner, demo_natural_mod_pow_ref_val_val);\n    register_demo!(runner, demo_natural_mod_pow_ref_val_ref);\n    register_demo!(runner, demo_natural_mod_pow_ref_ref_val);\n    register_demo!(runner, demo_natural_mod_pow_ref_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_mod_pow_odd);\n    register_bench!(runner, benchmark_limbs_mod_pow);\n    register_bench!(runner, benchmark_natural_mod_pow_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_pow_algorithms);\n    register_bench!(runner, benchmark_natural_mod_pow_library_comparison);\n    register_bench!(runner, benchmark_natural_mod_pow_evaluation_strategy);\n}\n\nfn demo_limbs_mod_pow_odd(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, es, ms) in unsigned_vec_quadruple_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(ms.len())];\n        limbs_mod_pow_odd(&mut out, &xs, &es, &ms, &mut scratch);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mod_pow_odd(&mut out, {xs:?}, {es:?}, {ms:?}, &mut scratch); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod_pow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, es, ms) in unsigned_vec_quadruple_gen_var_6()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_mod_pow(&mut out, &xs, &es, &ms);\n        println!(\n            \"out := {out_old:?}; limbs_mod_pow(&mut out, {xs:?}, {es:?}, {ms:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_natural_mod_pow_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let exp_old = exp.clone();\n        let m_old = m.clone();\n        x.mod_pow_assign(exp, m);\n        println!(\"x := {x_old}; x.mod_pow_assign({exp_old}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_pow_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        let exp_old = exp.clone();\n        x.mod_pow_assign(exp, &m);\n        println!(\"x := {x}; x.mod_pow_assign({exp_old}, &{m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_pow_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        x.mod_pow_assign(&exp, m);\n        println!(\"x := {x_old}; x.mod_pow_assign(&{exp}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_pow_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.mod_pow_assign(&exp, &m);\n        println!(\"x := {x_old}; x.mod_pow_assign(&{exp}, &{m}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_pow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let exp_old = exp.clone();\n        let m_old = m.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod {}\",\n            x_old,\n            exp_old,\n            x.mod_pow(exp, m),\n            m_old\n        );\n    }\n}\n\nfn demo_natural_mod_pow_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let exp_old = exp.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod {}\",\n            x_old,\n            exp_old,\n            x.mod_pow(exp, &m),\n            m\n        );\n    }\n}\n\nfn demo_natural_mod_pow_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod {}\",\n            x_old,\n            exp,\n            x.mod_pow(&exp, m),\n            m_old\n        );\n    }\n}\n\nfn demo_natural_mod_pow_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.pow({}) ≡ {} mod {}\", x_old, exp, x.mod_pow(&exp, &m), m);\n    }\n}\n\nfn demo_natural_mod_pow_ref_val_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let exp_old = exp.clone();\n        let m_old = m.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod {}\",\n            x,\n            exp_old,\n            (&x).mod_pow(exp, m),\n            m_old\n        );\n    }\n}\n\nfn demo_natural_mod_pow_ref_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let exp_old = exp.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod {}\",\n            x,\n            exp_old,\n            (&x).mod_pow(exp, &m),\n            m\n        );\n    }\n}\n\nfn demo_natural_mod_pow_ref_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod {}\",\n            x,\n            exp,\n            (&x).mod_pow(&exp, m),\n            m_old\n        );\n    }\n}\n\nfn demo_natural_mod_pow_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, m) in natural_triple_gen_var_5().get(gm, config).take(limit) {\n        println!(\"{}.pow({}) ≡ {} mod {}\", x, exp, (&x).mod_pow(&exp, &m), m);\n    }\n}\n\nfn benchmark_limbs_mod_pow_odd(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mod_pow_odd(&mut [Limb], &[Limb], &[Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_quadruple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_4_vec_len_bucketer(\"ms\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, es, ms)| {\n            let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(ms.len())];\n            limbs_mod_pow_odd(&mut out, &xs, &es, &ms, &mut scratch);\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_pow(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mod_pow(&mut [Limb], &[Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_quadruple_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_4_vec_len_bucketer(\"ms\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, es, ms)| {\n            limbs_mod_pow(&mut out, &xs, &es, &ms);\n        })],\n    );\n}\n\nfn benchmark_natural_mod_pow_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_pow_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_3_prod_natural_bits_bucketer(\"exp\", \"m\"),\n        &mut [\n            (\n                \"Natural.mod_pow_assign(Natural, Natural)\",\n                &mut |(mut x, exp, m)| no_out!(x.mod_pow_assign(exp, m)),\n            ),\n            (\n                \"Natural.mod_pow_assign(Natural, &Natural)\",\n                &mut |(mut x, exp, m)| no_out!(x.mod_pow_assign(exp, &m)),\n            ),\n            (\n                \"Natural.mod_pow_assign(&Natural, Natural)\",\n                &mut |(mut x, exp, m)| no_out!(x.mod_pow_assign(&exp, m)),\n            ),\n            (\n                \"Natural.mod_pow_assign(&Natural, &Natural)\",\n                &mut |(mut x, exp, m)| no_out!(x.mod_pow_assign(&exp, &m)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_pow_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_pow(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_3_prod_natural_bits_bucketer(\"exp\", \"m\"),\n        &mut [\n            (\"default\", &mut |(x, exp, m)| no_out!(x.mod_pow(exp, m))),\n            (\"simple binary\", &mut |(x, exp, m)| {\n                no_out!(simple_binary_mod_pow(&x, &exp, &m));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_pow_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_pow(Natural, Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_triple_gen_var_5_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_triple_1_3_prod_natural_bits_bucketer(\"exp\", \"m\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, exp, m))| {\n                no_out!(x.mod_pow(exp, m));\n            }),\n            (\"num\", &mut |((x, exp, m), _, _)| {\n                no_out!(x.modpow(&exp, &m));\n            }),\n            (\"rug\", &mut |(_, (x, exp, m), _)| {\n                no_out!(x.pow_mod(&exp, &m).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_pow_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_pow(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_3_prod_natural_bits_bucketer(\"exp\", \"m\"),\n        &mut [\n            (\"Natural.mod_pow(Natural, Natural)\", &mut |(x, exp, m)| {\n                no_out!(x.mod_pow(exp, m));\n            }),\n            (\"Natural.mod_pow(Natural, &Natural)\", &mut |(x, exp, m)| {\n                no_out!(x.mod_pow(exp, &m));\n            }),\n            (\"Natural.mod_pow(&Natural, Natural)\", &mut |(x, exp, m)| {\n                no_out!(x.mod_pow(&exp, m));\n            }),\n            (\"Natural.mod_pow(&Natural, &Natural)\", &mut |(x, exp, m)| {\n                no_out!(x.mod_pow(&exp, &m));\n            }),\n            (\"(&Natural).mod_pow(Natural, Natural)\", &mut |(\n                x,\n                exp,\n                m,\n            )| {\n                no_out!((&x).mod_pow(exp, m));\n            }),\n            (\n                \"(&Natural).mod_pow(Natural, &Natural)\",\n                &mut |(x, exp, m)| no_out!((&x).mod_pow(exp, &m)),\n            ),\n            (\n                \"(&Natural).mod_pow(&Natural, Natural)\",\n                &mut |(x, exp, m)| no_out!((&x).mod_pow(&exp, m)),\n            ),\n            (\n                \"(&Natural).mod_pow(&Natural, &Natural)\",\n                &mut |(x, exp, m)| no_out!((&x).mod_pow(&exp, &m)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Assign, NegModPowerOf2, NegModPowerOf2Assign, RemPowerOf2,\n    RemPowerOf2Assign,\n};\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::mod_power_of_2::{\n    limbs_mod_power_of_2, limbs_neg_mod_power_of_2, limbs_neg_mod_power_of_2_in_place,\n    limbs_slice_mod_power_of_2_in_place, limbs_vec_mod_power_of_2_in_place,\n};\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_mod_power_of_2);\n    register_demo!(runner, demo_limbs_slice_mod_power_of_2_in_place);\n    register_demo!(runner, demo_limbs_vec_mod_power_of_2_in_place);\n    register_demo!(runner, demo_limbs_neg_mod_power_of_2);\n    register_demo!(runner, demo_limbs_neg_mod_power_of_2_in_place);\n    register_demo!(runner, demo_natural_mod_power_of_2_assign);\n    register_demo!(runner, demo_natural_mod_power_of_2);\n    register_demo!(runner, demo_natural_mod_power_of_2_ref);\n    register_demo!(runner, demo_natural_rem_power_of_2_assign);\n    register_demo!(runner, demo_natural_rem_power_of_2);\n    register_demo!(runner, demo_natural_rem_power_of_2_ref);\n    register_demo!(runner, demo_natural_neg_mod_power_of_2_assign);\n    register_demo!(runner, demo_natural_neg_mod_power_of_2);\n    register_demo!(runner, demo_natural_neg_mod_power_of_2_ref);\n\n    register_bench!(runner, benchmark_limbs_mod_power_of_2);\n    register_bench!(runner, benchmark_limbs_slice_mod_power_of_2_in_place);\n    register_bench!(runner, benchmark_limbs_vec_mod_power_of_2_in_place);\n    register_bench!(runner, benchmark_limbs_neg_mod_power_of_2);\n    register_bench!(runner, benchmark_limbs_neg_mod_power_of_2_in_place);\n    register_bench!(runner, benchmark_natural_mod_power_of_2_assign);\n    register_bench!(runner, benchmark_natural_mod_power_of_2_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_rem_power_of_2_assign);\n    register_bench!(runner, benchmark_natural_rem_power_of_2_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_neg_mod_power_of_2_assign);\n    register_bench!(\n        runner,\n        benchmark_natural_neg_mod_power_of_2_evaluation_strategy\n    );\n}\n\nfn demo_limbs_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_power_of_2({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_mod_power_of_2(&xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_slice_mod_power_of_2_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_slice_mod_power_of_2_in_place(&mut xs, pow);\n        println!(\n            \"xs := {xs_old:?}; limbs_slice_mod_power_of_2_in_place(&mut xs, {pow}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_mod_power_of_2_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_mod_power_of_2_in_place(&mut xs, pow);\n        println!(\n            \"xs := {xs_old:?}; limbs_vec_mod_power_of_2_in_place(&mut xs, {pow}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_neg_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_neg_mod_power_of_2({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_neg_mod_power_of_2(&xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_neg_mod_power_of_2_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_neg_mod_power_of_2_in_place(&mut xs, pow);\n        println!(\n            \"xs := {xs_old:?}; limbs_neg_mod_power_of_2_in_place(&mut xs, {pow}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_power_of_2_assign(u);\n        println!(\"x := {n_old}; x.mod_power_of_2_assign({u}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.mod_power_of_2({}) = {}\", n_old, u, n.mod_power_of_2(u));\n    }\n}\n\nfn demo_natural_mod_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mod_power_of_2({}) = {}\",\n            n,\n            u,\n            (&n).mod_power_of_2(u)\n        );\n    }\n}\n\nfn demo_natural_rem_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.rem_power_of_2_assign(u);\n        println!(\"x := {n_old}; x.rem_power_of_2_assign({u}); x = {n}\");\n    }\n}\n\nfn demo_natural_rem_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.rem_power_of_2({}) = {}\", n_old, u, n.rem_power_of_2(u));\n    }\n}\n\nfn demo_natural_rem_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).rem_power_of_2({}) = {}\",\n            n,\n            u,\n            (&n).rem_power_of_2(u)\n        );\n    }\n}\n\nfn demo_natural_neg_mod_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.neg_mod_power_of_2_assign(u);\n        println!(\"x := {n_old}; x.neg_mod_power_of_2_assign({u}); x = {n}\");\n    }\n}\n\nfn demo_natural_neg_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.neg_mod_power_of_2({}) = {}\",\n            n_old,\n            u,\n            n.neg_mod_power_of_2(u)\n        );\n    }\n}\n\nfn demo_natural_neg_mod_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).neg_mod_power_of_2({}) = {}\",\n            n,\n            u,\n            (&n).neg_mod_power_of_2(u)\n        );\n    }\n}\n\nfn benchmark_limbs_mod_power_of_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mod_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(xs, pow)| {\n            no_out!(limbs_mod_power_of_2(&xs, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_mod_power_of_2_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_mod_power_of_2_in_place(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pow)| {\n            limbs_slice_mod_power_of_2_in_place(&mut xs, pow);\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_mod_power_of_2_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_mod_power_of_2_in_place(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pow)| {\n            limbs_vec_mod_power_of_2_in_place(&mut xs, pow);\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_mod_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_mod_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(xs, pow)| {\n            no_out!(limbs_neg_mod_power_of_2(&xs, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_neg_mod_power_of_2_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_neg_mod_power_of_2(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pow)| {\n            limbs_neg_mod_power_of_2_in_place(&mut xs, pow);\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n.mod_power_of_2_assign(u))],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!(n.mod_power_of_2(u));\n            }),\n            (\"(&Natural).mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!((&n).mod_power_of_2(u));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_rem_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.rem_power_of_2_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n.rem_power_of_2_assign(u))],\n    );\n}\n\nfn benchmark_natural_rem_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.rem_power_of_2(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.rem_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!(n.rem_power_of_2(u));\n            }),\n            (\"(&Natural).rem_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!((&n).rem_power_of_2(u));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_neg_mod_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.neg_mod_power_of_2_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| {\n            n.neg_mod_power_of_2_assign(u);\n        })],\n    );\n}\n\nfn benchmark_natural_neg_mod_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.neg_mod_power_of_2(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.neg_mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!(n.neg_mod_power_of_2(u));\n            }),\n            (\"(&Natural).neg_mod_power_of_2(u64)\", &mut |(n, u)| {\n                no_out!((&n).neg_mod_power_of_2(u));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModAdd, ModPowerOf2, ModPowerOf2Add, ModPowerOf2AddAssign, PowerOf2,\n};\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::{triple_1_vec_len_bucketer, triple_3_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_add::{\n    limbs_mod_power_of_2_add, limbs_mod_power_of_2_add_greater,\n    limbs_mod_power_of_2_add_in_place_either, limbs_mod_power_of_2_add_limb,\n    limbs_slice_mod_power_of_2_add_greater_in_place_left,\n    limbs_slice_mod_power_of_2_add_limb_in_place, limbs_vec_mod_power_of_2_add_in_place_left,\n    limbs_vec_mod_power_of_2_add_limb_in_place,\n};\nuse malachite_nz::test_util::generators::{\n    natural_natural_unsigned_triple_gen_var_4, unsigned_vec_unsigned_unsigned_triple_gen_var_14,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_15,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_mod_power_of_2_add_limb);\n    register_demo!(runner, demo_limbs_slice_mod_power_of_2_add_limb_in_place);\n    register_demo!(runner, demo_limbs_vec_mod_power_of_2_add_limb_in_place);\n    register_demo!(runner, demo_limbs_mod_power_of_2_add_greater);\n    register_demo!(runner, demo_limbs_mod_power_of_2_add);\n    register_demo!(\n        runner,\n        demo_limbs_slice_mod_power_of_2_add_greater_in_place_left\n    );\n    register_demo!(runner, demo_limbs_vec_mod_power_of_2_add_in_place_left);\n    register_demo!(runner, demo_limbs_mod_power_of_2_add_in_place_either);\n    register_demo!(runner, demo_natural_mod_power_of_2_add_assign);\n    register_demo!(runner, demo_natural_mod_power_of_2_add_assign_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_add);\n    register_demo!(runner, demo_natural_mod_power_of_2_add_val_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_add_ref_val);\n    register_demo!(runner, demo_natural_mod_power_of_2_add_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_add_limb);\n    register_bench!(\n        runner,\n        benchmark_limbs_slice_mod_power_of_2_add_limb_in_place\n    );\n    register_bench!(runner, benchmark_limbs_vec_mod_power_of_2_add_limb_in_place);\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_add_greater);\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_add);\n    register_bench!(\n        runner,\n        benchmark_limbs_slice_mod_power_of_2_add_greater_in_place_left\n    );\n    register_bench!(runner, benchmark_limbs_vec_mod_power_of_2_add_in_place_left);\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_add_in_place_either);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_add_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_add_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_add_evaluation_strategy\n    );\n}\n\nfn demo_limbs_mod_power_of_2_add_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y, pow) in unsigned_vec_unsigned_unsigned_triple_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_power_of_2_add_limb({:?}, {}, {}) = {:?}\",\n            xs,\n            y,\n            pow,\n            limbs_mod_power_of_2_add_limb(&xs, y, pow)\n        );\n    }\n}\n\nfn demo_limbs_slice_mod_power_of_2_add_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, y, pow) in unsigned_vec_unsigned_unsigned_triple_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_mod_power_of_2_add_limb_in_place(&mut xs, y, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_mod_power_of_2_add_limb_in_place(&mut xs, {y}, {pow}) = {carry}; \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_mod_power_of_2_add_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y, pow) in unsigned_vec_unsigned_unsigned_triple_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_mod_power_of_2_add_limb_in_place(&mut xs, y, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_vec_mod_power_of_2_add_limb_in_place(&mut xs, {y}, {pow}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_add_greater(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_add_greater({:?}, {:?}, {}) = {:?}\",\n            xs,\n            ys,\n            pow,\n            limbs_mod_power_of_2_add_greater(&xs, &ys, pow)\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_power_of_2_add({:?}, {:?}, {}) = {:?}\",\n            xs,\n            ys,\n            pow,\n            limbs_mod_power_of_2_add(&xs, &ys, pow)\n        );\n    }\n}\n\nfn demo_limbs_slice_mod_power_of_2_add_greater_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_mod_power_of_2_add_greater_in_place_left(&mut xs, &ys, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_mod_power_of_2_add_greater_in_place_left(&mut xs, {ys:?}, {pow}) \\\n            = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_mod_power_of_2_add_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_mod_power_of_2_add_in_place_left(&mut xs, &ys, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_vec_mod_power_of_2_add_in_place_left(&mut xs, {ys:?}, {pow}); \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_add_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_mod_power_of_2_add_in_place_either(&mut xs, &mut ys, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_mod_power_of_2_add_in_place_either(&mut xs, &mut ys, \\\n            {pow}) = {right}; xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_add_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mod_power_of_2_add_assign(y, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_add_assign({y_old}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_add_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.mod_power_of_2_add_assign(&y, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_add_assign(&{y}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} + {} ≡ {} mod 2^{}\",\n            x_old,\n            y_old,\n            x.mod_power_of_2_add(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_add_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"{} + {} ≡ {} mod 2^{}\",\n            x_old,\n            y,\n            x.mod_power_of_2_add(&y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_add_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"{} + {} ≡ {} mod 2^{}\",\n            x,\n            y_old,\n            (&x).mod_power_of_2_add(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_add_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{} + {} ≡ {} mod 2^{}\",\n            x,\n            y,\n            (&x).mod_power_of_2_add(&y, pow),\n            pow\n        );\n    }\n}\n\nfn benchmark_limbs_mod_power_of_2_add_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_add_limb(&[Limb], Limb, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y, pow)| {\n            no_out!(limbs_mod_power_of_2_add_limb(&xs, y, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_mod_power_of_2_add_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_mod_power_of_2_add_limb_in_place(&mut [Limb], Limb, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y, pow)| {\n            no_out!(limbs_slice_mod_power_of_2_add_limb_in_place(\n                &mut xs, y, pow\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_mod_power_of_2_add_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_mod_power_of_2_add_limb_in_place(&mut Vec<Limb>, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y, pow)| {\n            limbs_vec_mod_power_of_2_add_limb_in_place(&mut xs, y, pow);\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_add_greater(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_add_greater(&[Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys, pow)| {\n            no_out!(limbs_mod_power_of_2_add_greater(xs, ys, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_add(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_add(&[Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys, pow)| {\n            no_out!(limbs_mod_power_of_2_add(xs, ys, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_mod_power_of_2_add_greater_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_mod_power_of_2_add_greater_in_place_left(&mut [Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys, pow)| {\n            no_out!(limbs_slice_mod_power_of_2_add_greater_in_place_left(\n                &mut xs, &ys, pow\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_mod_power_of_2_add_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_mod_power_of_2_add_in_place_left(&Vec<Limb>, &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys, pow)| {\n            no_out!(limbs_vec_mod_power_of_2_add_in_place_left(\n                &mut xs, &ys, pow\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_add_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_add_in_place_either(&mut [Limb], &mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys, pow)| {\n            no_out!(limbs_mod_power_of_2_add_in_place_either(\n                &mut xs, &mut ys, pow\n            ));\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_add_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_add_assign(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_add_assign(Natural, u64)\",\n                &mut |(mut x, y, pow)| no_out!(x.mod_power_of_2_add_assign(y, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_add_assign(&Natural, u64)\",\n                &mut |(mut x, y, pow)| no_out!(x.mod_power_of_2_add_assign(&y, pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_add_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_add(Natural, u64)\",\n        BenchmarkType::Algorithms,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, pow)| {\n                no_out!(x.mod_power_of_2_add(y, pow));\n            }),\n            (\"alt\", &mut |(x, y, pow)| {\n                let mut sum = x + y;\n                sum.clear_bit(pow);\n            }),\n            (\"naive\", &mut |(x, y, pow)| {\n                no_out!((x + y).mod_power_of_2(pow));\n            }),\n            (\"using mod_add\", &mut |(x, y, pow)| {\n                no_out!(x.mod_add(y, Natural::power_of_2(pow)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_add_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_add(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_add(Natural, u64)\",\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_add(y, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_add(&Natural, u64)\",\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_add(&y, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_add(Natural, u64)\",\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_add(y, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_add(&Natural, u64)\",\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_add(&y, pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModInverse, ModPowerOf2Inverse, PowerOf2};\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_14;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_power_of_2_inverse);\n    register_demo!(runner, demo_natural_mod_power_of_2_inverse_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_inverse_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_inverse_algorithms);\n}\n\nfn demo_natural_mod_power_of_2_inverse(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        if let Some(inverse) = n.mod_power_of_2_inverse(pow) {\n            println!(\"{n_old}⁻¹ ≡ {inverse} mod 2^{pow}\");\n        } else {\n            println!(\"{n_old} is not invertible mod 2^{pow}\");\n        }\n    }\n}\n\nfn demo_natural_mod_power_of_2_inverse_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        if let Some(inverse) = (&n).mod_power_of_2_inverse(pow) {\n            println!(\"{n}⁻¹ ≡ {inverse} mod 2^{pow}\");\n        } else {\n            println!(\"{n} is not invertible mod 2^{pow}\");\n        }\n    }\n}\n\nfn benchmark_natural_mod_power_of_2_inverse_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_inverse(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.mod_power_of_2_inverse(u64)\", &mut |(n, pow)| {\n                no_out!(n.mod_power_of_2_inverse(pow));\n            }),\n            (\"(&Natural).mod_power_of_2_inverse(u64)\", &mut |(n, pow)| {\n                no_out!((&n).mod_power_of_2_inverse(pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_inverse_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_inverse(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(n, pow)| {\n                no_out!(n.mod_power_of_2_inverse(pow));\n            }),\n            (\"simple\", &mut |(n, pow)| {\n                no_out!(n.mod_inverse(Natural::power_of_2(pow)));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModIsReduced, ModPowerOf2IsReduced, PowerOf2};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_power_of_2_is_reduced);\n\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_is_reduced_algorithms\n    );\n}\n\nfn demo_natural_mod_power_of_2_is_reduced(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.mod_power_of_2_is_reduced(log_base) {\n            println!(\"{n} is reduced mod 2^{log_base}\");\n        } else {\n            println!(\"{n} is not reduced mod 2^{log_base}\");\n        }\n    }\n}\n\nfn benchmark_natural_mod_power_of_2_is_reduced_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_add_limb(&[Limb], Limb, u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, log_base)| {\n                no_out!(n.mod_power_of_2_is_reduced(log_base));\n            }),\n            (\"using mod_is_reduced\", &mut |(n, log_base)| {\n                no_out!(n.mod_is_reduced(&Natural::power_of_2(log_base)));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModMul, ModPowerOf2, ModPowerOf2Mul, ModPowerOf2MulAssign, PowerOf2,\n};\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_mul::{\n    limbs_mod_power_of_2_mul, limbs_mod_power_of_2_mul_ref_ref, limbs_mod_power_of_2_mul_val_ref,\n};\nuse malachite_nz::test_util::generators::{\n    natural_natural_unsigned_triple_gen_var_4, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_mod_power_of_2_mul);\n    register_demo!(runner, demo_limbs_mod_power_of_2_mul_val_ref);\n    register_demo!(runner, demo_limbs_mod_power_of_2_mul_ref_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_mul_assign);\n    register_demo!(runner, demo_natural_mod_power_of_2_mul_assign_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_mul);\n    register_demo!(runner, demo_natural_mod_power_of_2_mul_val_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_mul_ref_val);\n    register_demo!(runner, demo_natural_mod_power_of_2_mul_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_power_of_2_mul_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_mul_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_mul_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_mul_evaluation_strategy\n    );\n}\n\nfn demo_limbs_mod_power_of_2_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        println!(\n            \"limbs_mod_power_of_2_mul({:?}, {:?}, {}) = {:?}\",\n            xs_old,\n            ys_old,\n            pow,\n            limbs_mod_power_of_2_mul(&mut xs, &mut ys, pow)\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_mul_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        println!(\n            \"limbs_mod_power_of_2_mul({:?}, {:?}, {}) = {:?}\",\n            xs_old,\n            ys,\n            pow,\n            limbs_mod_power_of_2_mul_val_ref(&mut xs, &ys, pow)\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_mul_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_power_of_2_mul_ref_ref({:?}, {:?}, {}) = {:?}\",\n            xs,\n            ys,\n            pow,\n            limbs_mod_power_of_2_mul_ref_ref(&xs, &ys, pow)\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mod_power_of_2_mul_assign(y, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_mul_assign({y_old}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_mul_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.mod_power_of_2_mul_assign(&y, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_mul_assign(&{y}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} * {} ≡ {} mod 2^{}\",\n            x_old,\n            y_old,\n            x.mod_power_of_2_mul(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_mul_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"{} * {} ≡ {} mod 2^{}\",\n            x_old,\n            y,\n            x.mod_power_of_2_mul(&y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_mul_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"{} * {} ≡ {} mod 2^{}\",\n            x,\n            y_old,\n            (&x).mod_power_of_2_mul(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_mul_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{} * {} ≡ {} mod 2^{}\",\n            x,\n            y,\n            (&x).mod_power_of_2_mul(&y, pow),\n            pow\n        );\n    }\n}\n\nfn benchmark_limbs_mod_power_of_2_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_mul(&[Limb], &[Limb], u64)\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\"limbs_mod_power_of_2_mul\", &mut |(\n                ref mut xs,\n                ref mut ys,\n                pow,\n            )| {\n                no_out!(limbs_mod_power_of_2_mul(xs, ys, pow));\n            }),\n            (\"limbs_mod_power_of_2_mul_val_ref\", &mut |(\n                ref mut xs,\n                ref ys,\n                pow,\n            )| {\n                no_out!(limbs_mod_power_of_2_mul_val_ref(xs, ys, pow));\n            }),\n            (\"limbs_mod_power_of_2_mul_ref_ref\", &mut |(\n                ref xs,\n                ref ys,\n                pow,\n            )| {\n                no_out!(limbs_mod_power_of_2_mul_ref_ref(xs, ys, pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_mul_assign(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_mul_assign(Natural, u64)\",\n                &mut |(mut x, y, pow)| no_out!(x.mod_power_of_2_mul_assign(y, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_mul_assign(&Natural, u64)\",\n                &mut |(mut x, y, pow)| no_out!(x.mod_power_of_2_mul_assign(&y, pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_mul(Natural, u64)\",\n        BenchmarkType::Algorithms,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, pow)| {\n                no_out!(x.mod_power_of_2_mul(y, pow));\n            }),\n            (\"naive\", &mut |(x, y, pow)| {\n                no_out!((x * y).mod_power_of_2(pow));\n            }),\n            (\"using mod_mul\", &mut |(x, y, pow)| {\n                no_out!(x.mod_mul(y, Natural::power_of_2(pow)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_mul(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_mul(Natural, u64)\",\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_mul(y, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_mul(&Natural, u64)\",\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_mul(&y, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_mul(Natural, u64)\",\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_mul(y, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_mul(&Natural, u64)\",\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_mul(&y, pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModNeg, ModPowerOf2, ModPowerOf2Neg, ModPowerOf2NegAssign, PowerOf2,\n};\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_11;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_power_of_2_neg_assign);\n    register_demo!(runner, demo_natural_mod_power_of_2_neg);\n    register_demo!(runner, demo_natural_mod_power_of_2_neg_ref);\n\n    register_bench!(runner, benchmark_natural_mod_power_of_2_neg_assign);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_neg_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_neg_algorithms);\n}\n\nfn demo_natural_mod_power_of_2_neg_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, pow) in natural_unsigned_pair_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_power_of_2_neg_assign(pow);\n        println!(\"x := {n_old}; x.mod_power_of_2_neg_assign({pow}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"-{} ≡ {} mod 2^{}\", n_old, n.mod_power_of_2_neg(pow), pow);\n    }\n}\n\nfn demo_natural_mod_power_of_2_neg_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"-(&{}) ≡ {} mod 2^{}\",\n            n_old,\n            n.mod_power_of_2_neg(pow),\n            pow\n        );\n    }\n}\n\nfn benchmark_natural_mod_power_of_2_neg_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_neg_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\"Natural.mod_power_of_2_neg_assign(u64)\", &mut |(\n            mut n,\n            pow,\n        )| {\n            n.mod_power_of_2_neg_assign(pow);\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_neg_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_neg(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.mod_power_of_2_neg(u64)\", &mut |(n, pow)| {\n                no_out!(n.mod_power_of_2_neg(pow));\n            }),\n            (\"(&Natural).mod_power_of_2_neg(u64)\", &mut |(n, pow)| {\n                no_out!((&n).mod_power_of_2_neg(pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_neg_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_neg(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.mod_power_of_2_neg(u64)\", &mut |(n, pow)| {\n                no_out!(n.mod_power_of_2_neg(pow));\n            }),\n            (\"(-Natural).mod_power_of_2(u64)\", &mut |(n, pow)| {\n                no_out!((-n).mod_power_of_2(pow));\n            }),\n            (\n                \"Natural.mod_neg(Natural::power_of_2(u64))\",\n                &mut |(n, pow)| no_out!(n.mod_neg(Natural::power_of_2(pow))),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2Pow, ModPowerOf2PowAssign};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_product_vec_len_bucketer, triple_1_2_product_vec_len_bucketer,\n    triple_2_bits_times_triple_3_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_pair_gen_var_3;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_pow::{\n    limbs_mod_power_of_2_pow, limbs_pow_low,\n};\nuse malachite_nz::test_util::generators::{\n    natural_natural_unsigned_triple_gen_var_5, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_power_of_2_pow::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_pow_low);\n    register_demo!(runner, demo_limbs_mod_power_of_2_pow);\n    register_demo!(runner, demo_natural_mod_power_of_2_pow_assign);\n    register_demo!(runner, demo_natural_mod_power_of_2_pow_assign_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_pow);\n    register_demo!(runner, demo_natural_mod_power_of_2_pow_val_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_pow_ref_val);\n    register_demo!(runner, demo_natural_mod_power_of_2_pow_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_pow_low);\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_pow);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_pow_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_pow_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_pow_evaluation_strategy\n    );\n}\n\nfn demo_limbs_pow_low(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, es) in unsigned_vec_pair_gen_var_3().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let mut scratch = vec![0; xs.len()];\n        limbs_pow_low(&mut xs, &es, &mut scratch);\n        println!(\"xs := {xs_old:?}; limbs_pow_low(&mut xs, {es:?}, &mut scratch); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_mod_power_of_2_pow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, es, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_mod_power_of_2_pow(&mut xs, &es, pow);\n        println!(\"xs := {xs_old:?}; limbs_mod_power_of_2_pow(&mut xs, {es:?}, {pow}); xs = {xs:?}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_pow_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp, pow) in natural_natural_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let exp_old = exp.clone();\n        x.mod_power_of_2_pow_assign(exp, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_pow_assign({exp_old}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_pow_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp, pow) in natural_natural_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.mod_power_of_2_pow_assign(&exp, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_pow_assign({exp}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_pow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, pow) in natural_natural_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let exp_old = exp.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod 2^{}\",\n            x_old,\n            exp_old,\n            x.mod_power_of_2_pow(exp, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_pow_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, pow) in natural_natural_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod 2^{}\",\n            x_old,\n            exp,\n            x.mod_power_of_2_pow(&exp, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_pow_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, pow) in natural_natural_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        let exp_old = exp.clone();\n        println!(\n            \"{}.pow({}) ≡ {} mod 2^{}\",\n            x,\n            exp_old,\n            (&x).mod_power_of_2_pow(exp, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_pow_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp, pow) in natural_natural_unsigned_triple_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.pow({}) ≡ {} mod 2^{}\",\n            x,\n            exp,\n            (&x).mod_power_of_2_pow(&exp, pow),\n            pow\n        );\n    }\n}\n\nfn benchmark_limbs_pow_low(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_pow_low(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_product_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, es)| {\n            let mut scratch = vec![0; xs.len()];\n            limbs_pow_low(&mut xs, &es, &mut scratch);\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_pow(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_pow(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_product_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, es, pow)| {\n            limbs_mod_power_of_2_pow(&mut xs, &es, pow);\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_pow_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_pow_assign(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bits_times_triple_3_bucketer(\"exp\", \"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_pow_assign(Natural, u64)\",\n                &mut |(mut x, exp, pow)| no_out!(x.mod_power_of_2_pow_assign(exp, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_pow_assign(&Natural, u64)\",\n                &mut |(mut x, exp, pow)| no_out!(x.mod_power_of_2_pow_assign(&exp, pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_pow_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_pow(Natural, u64)\",\n        BenchmarkType::Algorithms,\n        natural_natural_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bits_times_triple_3_bucketer(\"exp\", \"pow\"),\n        &mut [\n            (\"default\", &mut |(x, exp, pow)| {\n                no_out!(x.mod_power_of_2_pow(exp, pow));\n            }),\n            (\"simple binary\", &mut |(x, exp, pow)| {\n                no_out!(simple_binary_mod_power_of_2_pow(&x, &exp, pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_pow_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_pow(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_bits_times_triple_3_bucketer(\"exp\", \"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_pow(Natural, u64)\",\n                &mut |(x, exp, pow)| no_out!(x.mod_power_of_2_pow(exp, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_pow(&Natural, u64)\",\n                &mut |(x, exp, pow)| no_out!(x.mod_power_of_2_pow(&exp, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_pow(Natural, u64)\",\n                &mut |(x, exp, pow)| no_out!((&x).mod_power_of_2_pow(exp, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_pow(&Natural, u64)\",\n                &mut |(x, exp, pow)| no_out!((&x).mod_power_of_2_pow(&exp, pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, ModPowerOf2Shl, ModPowerOf2ShlAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_signed_unsigned_triple_gen_var_1, natural_unsigned_unsigned_triple_gen_var_6,\n};\nuse std::ops::Shl;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_mod_power_of_2_shl_assign_unsigned);\n    register_unsigned_demos!(runner, demo_natural_mod_power_of_2_shl_unsigned);\n    register_unsigned_demos!(runner, demo_natural_mod_power_of_2_shl_unsigned_ref);\n    register_signed_demos!(runner, demo_natural_mod_power_of_2_shl_assign_signed);\n    register_signed_demos!(runner, demo_natural_mod_power_of_2_shl_signed);\n    register_signed_demos!(runner, demo_natural_mod_power_of_2_shl_signed_ref);\n\n    register_unsigned_benches!(runner, benchmark_natural_mod_power_of_2_shl_assign_unsigned);\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_mod_power_of_2_shl_unsigned_evaluation_strategy\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_mod_power_of_2_shl_unsigned_algorithms\n    );\n    register_signed_benches!(runner, benchmark_natural_mod_power_of_2_shl_assign_signed);\n    register_signed_benches!(\n        runner,\n        benchmark_natural_mod_power_of_2_shl_signed_evaluation_strategy\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_natural_mod_power_of_2_shl_signed_algorithms\n    );\n}\n\nfn demo_natural_mod_power_of_2_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModPowerOf2ShlAssign<T>,\n{\n    for (mut n, u, pow) in natural_unsigned_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_power_of_2_shl_assign(u, pow);\n        println!(\"x := {n_old}; x.mod_power_of_2_shl_assign({u}, {pow}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_shl_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModPowerOf2Shl<T, Output = Natural>,\n{\n    for (n, u, pow) in natural_unsigned_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.mod_power_of_2_shl({}, {}) = {}\",\n            n_old,\n            u,\n            pow,\n            n.mod_power_of_2_shl(u, pow)\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_shl_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: ModPowerOf2Shl<T, Output = Natural>,\n{\n    for (n, u, pow) in natural_unsigned_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"(&{}).mod_power_of_2_shl({}, {}) = {}\",\n            n_old,\n            u,\n            pow,\n            (&n).mod_power_of_2_shl(u, pow)\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModPowerOf2ShlAssign<T>,\n{\n    for (mut n, i, pow) in natural_signed_unsigned_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_power_of_2_shl_assign(i, pow);\n        println!(\"x := {n_old}; x.mod_power_of_2_shl_assign({i}, {pow}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_shl_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModPowerOf2Shl<T, Output = Natural>,\n{\n    for (n, i, pow) in natural_signed_unsigned_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.mod_power_of_2_shl({}, {}) = {}\",\n            n_old,\n            i,\n            pow,\n            n.mod_power_of_2_shl(i, pow)\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_shl_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: ModPowerOf2Shl<T, Output = Natural>,\n{\n    for (n, i, pow) in natural_signed_unsigned_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"(&{}).mod_power_of_2_shl({}, {}) = {}\",\n            n_old,\n            i,\n            pow,\n            (&n).mod_power_of_2_shl(i, pow)\n        );\n    }\n}\n\nfn benchmark_natural_mod_power_of_2_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shl_assign({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_unsigned_triple_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_shl_assign(y, pow);\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_shl_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2Shl<T>,\n    for<'a> &'a Natural: ModPowerOf2Shl<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shl_assign({}, u64)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_unsigned_triple_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_power_of_2_shl({}, u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_shl(y, pow)),\n            ),\n            (\n                &format!(\"(&Natural).mod_power_of_2_shl({}, u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_shl(y, pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_shl_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2Shl<T> + Shl<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shl_assign({}, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_unsigned_unsigned_triple_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, pow)| {\n                no_out!(x.mod_power_of_2_shl(y, pow));\n            }),\n            (\n                &format!(\"(Natural << {}).mod_power_of_2(u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!((x << y).mod_power_of_2(pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shl_assign({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_shl_assign(y, pow);\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_shl_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2Shl<T>,\n    for<'a> &'a Natural: ModPowerOf2Shl<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shl_assign({}, u64)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_power_of_2_shl({}, u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_shl(y, pow)),\n            ),\n            (\n                &format!(\"(&Natural).mod_power_of_2_shl({}, u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_shl(y, pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_shl_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2Shl<T> + Shl<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shl_assign({}, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_signed_unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, pow)| {\n                no_out!(x.mod_power_of_2_shl(y, pow));\n            }),\n            (\n                &format!(\"(Natural << {}).mod_power_of_2(u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!((x << y).mod_power_of_2(pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, ModPowerOf2Shr, ModPowerOf2ShrAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_signed_unsigned_triple_gen_var_1;\nuse std::ops::Shr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_natural_mod_power_of_2_shr_assign);\n    register_signed_demos!(runner, demo_natural_mod_power_of_2_shr);\n    register_signed_demos!(runner, demo_natural_mod_power_of_2_shr_ref);\n\n    register_signed_benches!(runner, benchmark_natural_mod_power_of_2_shr_assign);\n    register_signed_benches!(\n        runner,\n        benchmark_natural_mod_power_of_2_shr_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_natural_mod_power_of_2_shr_algorithms);\n}\n\nfn demo_natural_mod_power_of_2_shr_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModPowerOf2ShrAssign<T>,\n{\n    for (mut n, i, pow) in natural_signed_unsigned_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_power_of_2_shr_assign(i, pow);\n        println!(\"x := {n_old}; x.mod_power_of_2_shr_assign({i}, {pow}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_shr<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModPowerOf2Shr<T, Output = Natural>,\n{\n    for (n, i, pow) in natural_signed_unsigned_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.mod_power_of_2_shr({}, {}) = {}\",\n            n_old,\n            i,\n            pow,\n            n.mod_power_of_2_shr(i, pow)\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_shr_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: ModPowerOf2Shr<T, Output = Natural>,\n{\n    for (n, i, pow) in natural_signed_unsigned_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"(&{}).mod_power_of_2_shr({}, {}) = {}\",\n            n_old,\n            i,\n            pow,\n            (&n).mod_power_of_2_shr(i, pow)\n        );\n    }\n}\n\nfn benchmark_natural_mod_power_of_2_shr_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shr_assign({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, pow)| {\n            x.mod_power_of_2_shr_assign(y, pow);\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_shr_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2Shr<T>,\n    for<'a> &'a Natural: ModPowerOf2Shr<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shr_assign({}, u64)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_power_of_2_shr({}, u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_shr(y, pow)),\n            ),\n            (\n                &format!(\"(&Natural).mod_power_of_2_shr({}, u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_shr(y, pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_shr_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModPowerOf2Shr<T> + Shr<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_power_of_2_shr_assign({}, u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_signed_unsigned_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, pow)| {\n                no_out!(x.mod_power_of_2_shr(y, pow));\n            }),\n            (\n                &format!(\"(Natural >> {}).mod_power_of_2(u64)\", T::NAME),\n                &mut |(x, y, pow)| no_out!((x >> y).mod_power_of_2(pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Mul, ModPowerOf2Square, ModPowerOf2SquareAssign, ModSquare, PowerOf2,\n    Square,\n};\nuse malachite_base::test_util::bench::bucketers::{pair_2_bucketer, pair_2_vec_len_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_1, unsigned_vec_pair_gen_var_20,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_square::{\n    limbs_mod_power_of_2_square, limbs_mod_power_of_2_square_ref, limbs_square_low,\n    limbs_square_low_basecase, limbs_square_low_divide_and_conquer, limbs_square_low_scratch_len,\n};\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_11, unsigned_vec_pair_gen_var_21,\n    unsigned_vec_unsigned_pair_gen_var_30,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_power_of_2_square::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_square_low_basecase);\n    register_demo!(runner, demo_limbs_square_low_divide_and_conquer);\n    register_demo!(runner, demo_limbs_square_low);\n    register_demo!(runner, demo_limbs_mod_power_of_2_square);\n    register_demo!(runner, demo_limbs_mod_power_of_2_square_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_square_assign);\n    register_demo!(runner, demo_natural_mod_power_of_2_square);\n    register_demo!(runner, demo_natural_mod_power_of_2_square_ref);\n\n    register_bench!(runner, benchmark_limbs_square_low_basecase);\n    register_bench!(\n        runner,\n        benchmark_limbs_square_low_divide_and_conquer_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_square_low);\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_power_of_2_square_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_square_assign);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_square_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_square_algorithms);\n}\n\nfn demo_limbs_square_low_basecase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs) in unsigned_vec_pair_gen_var_21().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_square_low_basecase(&mut out, &xs);\n        println!(\"out := {out_old:?}; limbs_square_low_basecase(&mut out, {xs:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_square_low_divide_and_conquer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs) in unsigned_vec_pair_gen_var_20().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let mut scratch = vec![0; limbs_square_low_scratch_len(xs.len())];\n        limbs_square_low_divide_and_conquer(&mut out, &xs, &mut scratch);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_square_low_divide_and_conquer(&mut out, {xs:?}, &mut scratch); \\\n            out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_square_low(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs) in unsigned_vec_pair_gen_var_1().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_square_low(&mut out, &xs);\n        println!(\"out := {out_old:?}; limbs_square_low(&mut out, {xs:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_mod_power_of_2_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, pow) in unsigned_vec_unsigned_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        println!(\n            \"limbs_mod_power_of_2_square({:?}, {}) = {:?}\",\n            xs_old,\n            pow,\n            limbs_mod_power_of_2_square(&mut xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_square_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_30()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_power_of_2_square_ref({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_mod_power_of_2_square_ref(&xs, pow)\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_square_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, pow) in natural_unsigned_pair_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_power_of_2_square_assign(pow);\n        println!(\"x := {n_old}; x.mod_power_of_2_square_assign({pow}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.square() ≡ {} mod 2^{}\",\n            n_old,\n            n.mod_power_of_2_square(pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_square_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_11()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).square() ≡ {} mod 2^{}\",\n            n,\n            (&n).mod_power_of_2_square(pow),\n            pow\n        );\n    }\n}\n\nfn benchmark_limbs_square_low_basecase(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_low_basecase(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_21().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs)| {\n            limbs_square_low_basecase(&mut out, &xs);\n        })],\n    );\n}\n\nfn benchmark_limbs_square_low_divide_and_conquer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_low_divide_and_conquer(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs)| {\n                limbs_square_low_basecase_unrestricted(&mut out, &xs);\n            }),\n            (\"divide and conquer\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_low_scratch_len(xs.len())];\n                limbs_square_low_divide_and_conquer(&mut out, &xs, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_square_low(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_square_low(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs)| {\n            limbs_square_low(&mut out, &xs);\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_square_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_square(&[Limb], u64)\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_unsigned_pair_gen_var_30().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"limbs_mod_power_of_2_square\", &mut |(ref mut xs, pow)| {\n                no_out!(limbs_mod_power_of_2_square(xs, pow));\n            }),\n            (\"limbs_mod_power_of_2_square_ref\", &mut |(\n                ref mut xs,\n                pow,\n            )| {\n                no_out!(limbs_mod_power_of_2_square_ref(xs, pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_square_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_square_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [(\n            \"Natural.mod_power_of_2_square_assign(u64)\",\n            &mut |(mut n, pow)| n.mod_power_of_2_square_assign(pow),\n        )],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_square_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_square(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.mod_power_of_2_square(u64)\", &mut |(n, pow)| {\n                no_out!(n.mod_power_of_2_square(pow));\n            }),\n            (\"(&Natural).mod_power_of_2_square(u64)\", &mut |(n, pow)| {\n                no_out!((&n).mod_power_of_2_square(pow));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_square_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_square(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"pow\"),\n        &mut [\n            (\"Natural.mod_power_of_2_square(u64)\", &mut |(n, pow)| {\n                no_out!(n.mod_power_of_2_square(pow));\n            }),\n            (\n                \"Natural.mod_power_of_2_mul(Natural, u64)\",\n                &mut |(n, pow)| no_out!(n.clone().mod_power_of_2_mul(n, pow)),\n            ),\n            (\"Natural.square().mod_power_of_2(u64)\", &mut |(n, pow)| {\n                no_out!(n.square().mod_power_of_2(pow));\n            }),\n            (\n                \"Natural.mod_square(Natural::power_of_2(u64))\",\n                &mut |(n, pow)| no_out!(n.mod_square(Natural::power_of_2(pow))),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_power_of_2_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Sub, ModPowerOf2SubAssign, ModSub, PowerOf2,\n};\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::triple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_sub::{\n    limbs_mod_power_of_2_limb_sub_limbs, limbs_mod_power_of_2_limb_sub_limbs_in_place,\n    limbs_mod_power_of_2_sub, limbs_mod_power_of_2_sub_in_place_either,\n    limbs_mod_power_of_2_sub_in_place_left, limbs_mod_power_of_2_sub_in_place_right,\n};\nuse malachite_nz::test_util::generators::{\n    natural_natural_unsigned_triple_gen_var_4, unsigned_vec_unsigned_unsigned_triple_gen_var_16,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_mod_power_of_2_limb_sub_limbs);\n    register_demo!(runner, demo_limbs_mod_power_of_2_limb_sub_limbs_in_place);\n    register_demo!(runner, demo_limbs_mod_power_of_2_sub);\n    register_demo!(runner, demo_limbs_mod_power_of_2_sub_in_place_left);\n    register_demo!(runner, demo_limbs_mod_power_of_2_sub_in_place_right);\n    register_demo!(runner, demo_limbs_mod_power_of_2_sub_in_place_either);\n    register_demo!(runner, demo_natural_mod_power_of_2_sub_assign);\n    register_demo!(runner, demo_natural_mod_power_of_2_sub_assign_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_sub);\n    register_demo!(runner, demo_natural_mod_power_of_2_sub_val_ref);\n    register_demo!(runner, demo_natural_mod_power_of_2_sub_ref_val);\n    register_demo!(runner, demo_natural_mod_power_of_2_sub_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_limb_sub_limbs);\n    register_bench!(\n        runner,\n        benchmark_limbs_mod_power_of_2_limb_sub_limbs_in_place\n    );\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_sub);\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_sub_in_place_left);\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_sub_in_place_right);\n    register_bench!(runner, benchmark_limbs_mod_power_of_2_sub_in_place_either);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_sub_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_power_of_2_sub_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_mod_power_of_2_sub_evaluation_strategy\n    );\n}\n\nfn demo_limbs_mod_power_of_2_limb_sub_limbs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (ys, x, pow) in unsigned_vec_unsigned_unsigned_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_power_of_2_limb_sub_limbs({}, {:?}, {}) = {:?}\",\n            x,\n            ys,\n            pow,\n            limbs_mod_power_of_2_limb_sub_limbs(x, &ys, pow)\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_limb_sub_limbs_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut ys, x, pow) in unsigned_vec_unsigned_unsigned_triple_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let ys_old = ys.clone();\n        limbs_mod_power_of_2_limb_sub_limbs_in_place(x, &mut ys, pow);\n        println!(\n            \"ys := {ys_old:?}; limbs_mod_power_of_2_limb_sub_limbs_in_place({x}, &mut ys, {pow}); \\\n            ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_mod_power_of_2_sub({:?}, {:?}, {}) = {:?}\",\n            xs,\n            ys,\n            pow,\n            limbs_mod_power_of_2_sub(&xs, &ys, pow)\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_sub_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_mod_power_of_2_sub_in_place_left(&mut xs, &ys, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_mod_power_of_2_sub_in_place_left(&mut xs, {ys:?}, {pow}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_sub_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let ys_old = ys.clone();\n        limbs_mod_power_of_2_sub_in_place_right(&xs, &mut ys, pow);\n        println!(\n            \"ys := {ys_old:?}; \\\n            limbs_mod_power_of_2_sub_in_place_right({xs:?}, &mut ys, {pow}); ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mod_power_of_2_sub_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys, pow) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_mod_power_of_2_sub_in_place_either(&mut xs, &mut ys, pow);\n        println!(\n            \"xs := {xs_old:?}; ys := {ys_old:?}; \\\n            limbs_mod_power_of_2_sub_in_place_either(&mut xs, &mut ys, {pow}) = {right}; \\\n            xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_sub_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mod_power_of_2_sub_assign(y, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_sub_assign({y_old}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_sub_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.mod_power_of_2_sub_assign(&y, pow);\n        println!(\"x := {x_old}; x.mod_power_of_2_sub_assign(&{y}, {pow}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_power_of_2_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{} - {} ≡ {} mod 2^{}\",\n            x_old,\n            y_old,\n            x.mod_power_of_2_sub(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_sub_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"{} - {} ≡ {} mod 2^{}\",\n            x_old,\n            y,\n            x.mod_power_of_2_sub(&y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_sub_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"{} - {} ≡ {} mod 2^{}\",\n            x,\n            y_old,\n            (&x).mod_power_of_2_sub(y, pow),\n            pow\n        );\n    }\n}\n\nfn demo_natural_mod_power_of_2_sub_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, pow) in natural_natural_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{} - {} ≡ {} mod 2^{}\",\n            x,\n            y,\n            (&x).mod_power_of_2_sub(&y, pow),\n            pow\n        );\n    }\n}\n\nfn benchmark_limbs_mod_power_of_2_limb_sub_limbs(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_limb_sub_limbs(Limb, &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(ys, x, pow)| {\n            no_out!(limbs_mod_power_of_2_limb_sub_limbs(x, &ys, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_limb_sub_limbs_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_limb_sub_limbs_in_place(Limb, &mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(mut ys, x, pow)| {\n            limbs_mod_power_of_2_limb_sub_limbs_in_place(x, &mut ys, pow);\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_sub(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_sub(&[Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref ys, pow)| {\n            no_out!(limbs_mod_power_of_2_sub(xs, ys, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_sub_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_sub_in_place_left(&mut Vec<Limb>, &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref ys, pow)| {\n            limbs_mod_power_of_2_sub_in_place_left(xs, ys, pow);\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_sub_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_sub_in_place_right(&[Limb], &mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(ref xs, ref mut ys, pow)| {\n            limbs_mod_power_of_2_sub_in_place_right(xs, ys, pow);\n        })],\n    );\n}\n\nfn benchmark_limbs_mod_power_of_2_sub_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mod_power_of_2_sub_in_place_left(&mut Vec<Limb>, &mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [(\"Malachite\", &mut |(ref mut xs, ref mut ys, pow)| {\n            no_out!(limbs_mod_power_of_2_sub_in_place_either(xs, ys, pow));\n        })],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_sub_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_sub_assign(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_sub_assign(Natural, u64)\",\n                &mut |(mut x, y, pow)| no_out!(x.mod_power_of_2_sub_assign(y, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_sub_assign(&Natural, u64)\",\n                &mut |(mut x, y, pow)| no_out!(x.mod_power_of_2_sub_assign(&y, pow)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_sub_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_sub(Natural, u64)\",\n        BenchmarkType::Algorithms,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, pow)| {\n                no_out!(x.mod_power_of_2_sub(y, pow));\n            }),\n            (\"alt\", &mut |(x, y, pow)| {\n                if x >= y {\n                    x - y\n                } else {\n                    let mut x = x;\n                    x.set_bit(pow);\n                    x - y\n                };\n            }),\n            (\"naive\", &mut |(x, y, pow)| {\n                no_out!((Integer::from(x) - Integer::from(y)).mod_power_of_2(pow));\n            }),\n            (\"using mod_sub\", &mut |(x, y, pow)| {\n                no_out!(x.mod_sub(y, Natural::power_of_2(pow)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_power_of_2_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_power_of_2_sub(Natural, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bucketer(\"pow\"),\n        &mut [\n            (\n                \"Natural.mod_power_of_2_sub(Natural, u64)\",\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_sub(y, pow)),\n            ),\n            (\n                \"Natural.mod_power_of_2_sub(&Natural, u64)\",\n                &mut |(x, y, pow)| no_out!(x.mod_power_of_2_sub(&y, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_sub(Natural, u64)\",\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_sub(y, pow)),\n            ),\n            (\n                \"(&Natural).mod_power_of_2_sub(&Natural, u64)\",\n                &mut |(x, y, pow)| no_out!((&x).mod_power_of_2_sub(&y, pow)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModShl, ModShlAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_natural_signed_triple_gen_var_1, natural_natural_unsigned_triple_gen_var_6,\n};\nuse std::ops::Shl;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_mod_shl_assign_unsigned);\n    register_unsigned_demos!(runner, demo_natural_mod_shl_assign_unsigned_ref);\n    register_unsigned_demos!(runner, demo_natural_mod_shl_unsigned);\n    register_unsigned_demos!(runner, demo_natural_mod_shl_unsigned_val_ref);\n    register_unsigned_demos!(runner, demo_natural_mod_shl_unsigned_ref_val);\n    register_unsigned_demos!(runner, demo_natural_mod_shl_unsigned_ref_ref);\n    register_signed_demos!(runner, demo_natural_mod_shl_assign_signed);\n    register_signed_demos!(runner, demo_natural_mod_shl_assign_signed_ref);\n    register_signed_demos!(runner, demo_natural_mod_shl_signed);\n    register_signed_demos!(runner, demo_natural_mod_shl_signed_val_ref);\n    register_signed_demos!(runner, demo_natural_mod_shl_signed_ref_val);\n    register_signed_demos!(runner, demo_natural_mod_shl_signed_ref_ref);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_mod_shl_assign_unsigned_evaluation_strategy\n    );\n    register_unsigned_benches!(runner, benchmark_natural_mod_shl_unsigned_algorithms);\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_mod_shl_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_natural_mod_shl_assign_signed_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_natural_mod_shl_signed_algorithms);\n    register_signed_benches!(runner, benchmark_natural_mod_shl_signed_evaluation_strategy);\n}\n\nfn demo_natural_mod_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModShlAssign<T>,\n{\n    for (mut n, m, u) in natural_natural_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_shl_assign(u, m.clone());\n        println!(\"x := {n_old}; x.mod_shl_assign({u}, {m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_shl_assign_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> Natural: ModShlAssign<T, &'a Natural>,\n{\n    for (mut n, m, u) in natural_natural_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_shl_assign(u, &m);\n        println!(\"x := {n_old}; x.mod_shl_assign({u}, &{m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_shl_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModShl<T, Output = Natural>,\n{\n    for (n, m, u) in natural_natural_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.mod_shl({}, {}) = {}\",\n            n_old,\n            u,\n            m.clone(),\n            n.mod_shl(u, m)\n        );\n    }\n}\n\nfn demo_natural_mod_shl_unsigned_val_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> Natural: ModShl<T, &'a Natural, Output = Natural>,\n{\n    for (n, m, u) in natural_natural_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.mod_shl({}, &{}) = {}\", n_old, u, m, n.mod_shl(u, &m));\n    }\n}\n\nfn demo_natural_mod_shl_unsigned_ref_val<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: ModShl<T, Natural, Output = Natural>,\n{\n    for (n, m, u) in natural_natural_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mod_shl({}, {}) = {}\",\n            n,\n            u,\n            m.clone(),\n            (&n).mod_shl(u, m)\n        );\n    }\n}\n\nfn demo_natural_mod_shl_unsigned_ref_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a, 'b> &'a Natural: ModShl<T, &'b Natural, Output = Natural>,\n{\n    for (n, m, u) in natural_natural_unsigned_triple_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).mod_shl({}, &{}) = {}\", n, u, m, (&n).mod_shl(u, &m));\n    }\n}\n\nfn demo_natural_mod_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ModShlAssign<T>,\n{\n    for (mut n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_shl_assign(i, m.clone());\n        println!(\"x := {n_old}; x.mod_shl_assign({i}, {m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_shl_assign_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> Natural: ModShlAssign<T, &'a Natural>,\n{\n    for (mut n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_shl_assign(i, &m);\n        println!(\"x := {n_old}; x.mod_shl_assign({i}, &{m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_shl_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ModShl<T, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.mod_shl({}, {}) = {}\",\n            n_old,\n            i,\n            m.clone(),\n            n.mod_shl(i, m)\n        );\n    }\n}\n\nfn demo_natural_mod_shl_signed_val_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> Natural: ModShl<T, &'a Natural, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.mod_shl({}, &{}) = {}\", n_old, i, m, n.mod_shl(i, &m));\n    }\n}\n\nfn demo_natural_mod_shl_signed_ref_val<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: ModShl<T, Natural, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mod_shl({}, {}) = {}\",\n            n,\n            i,\n            m.clone(),\n            (&n).mod_shl(i, m)\n        );\n    }\n}\n\nfn demo_natural_mod_shl_signed_ref_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a, 'b> &'a Natural: ModShl<T, &'b Natural, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).mod_shl({}, &{}) = {}\", n, i, m, (&n).mod_shl(i, &m));\n    }\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn benchmark_natural_mod_shl_assign_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> Natural: ModShlAssign<T> + ModShlAssign<T, &'a Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shl_assign({}, Natural)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_shl_assign({}, Natural)\", T::NAME),\n                &mut |(mut x, m, y)| no_out!(x.mod_shl_assign(y, m)),\n            ),\n            (\n                &format!(\"Natural.mod_shl_assign({}, &Natural)\", T::NAME),\n                &mut |(mut x, m, y)| no_out!(x.mod_shl_assign(y, &m)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_mod_shl_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModShl<T, Output = Natural> + Shl<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shl({}, Natural)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_natural_unsigned_triple_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, m, y)| no_out!(x.mod_shl(y, m))),\n            (\"using << and %\", &mut |(x, m, y)| no_out!((x << y) % m)),\n        ],\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn benchmark_natural_mod_shl_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> Natural: ModShl<T, Output = Natural> + ModShl<T, &'a Natural, Output = Natural>,\n    for<'a, 'b> &'a Natural:\n        ModShl<T, Natural, Output = Natural> + ModShl<T, &'b Natural, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shl({}, Natural)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_unsigned_triple_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_shl({}, Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!(x.mod_shl(y, m)),\n            ),\n            (\n                &format!(\"Natural.mod_shl({}, &Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!(x.mod_shl(y, &m)),\n            ),\n            (\n                &format!(\"(&Natural).mod_shl({}, Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!((&x).mod_shl(y, m)),\n            ),\n            (\n                &format!(\"(&Natural).mod_shl({}, &Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!((&x).mod_shl(y, &m)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn benchmark_natural_mod_shl_assign_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> Natural: ModShlAssign<T> + ModShlAssign<T, &'a Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shl_assign({}, Natural)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_shl_assign({}, Natural)\", T::NAME),\n                &mut |(mut x, m, y)| no_out!(x.mod_shl_assign(y, m)),\n            ),\n            (\n                &format!(\"Natural.mod_shl_assign({}, &Natural)\", T::NAME),\n                &mut |(mut x, m, y)| no_out!(x.mod_shl_assign(y, &m)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_mod_shl_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModShl<T, Output = Natural> + Shl<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shl({}, Natural)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_natural_signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, m, y)| no_out!(x.mod_shl(y, m))),\n            (\"using << and %\", &mut |(x, m, y)| no_out!((x << y) % m)),\n        ],\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn benchmark_natural_mod_shl_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> Natural: ModShl<T, Output = Natural> + ModShl<T, &'a Natural, Output = Natural>,\n    for<'a, 'b> &'a Natural:\n        ModShl<T, Natural, Output = Natural> + ModShl<T, &'b Natural, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shl({}, Natural)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_shl({}, Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!(x.mod_shl(y, m)),\n            ),\n            (\n                &format!(\"Natural.mod_shl({}, &Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!(x.mod_shl(y, &m)),\n            ),\n            (\n                &format!(\"(&Natural).mod_shl({}, Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!((&x).mod_shl(y, m)),\n            ),\n            (\n                &format!(\"(&Natural).mod_shl({}, &Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!((&x).mod_shl(y, &m)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModShr, ModShrAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::bucketers::triple_3_bit_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_natural_signed_triple_gen_var_1;\nuse std::ops::Shr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_natural_mod_shr_assign);\n    register_signed_demos!(runner, demo_natural_mod_shr_assign_ref);\n    register_signed_demos!(runner, demo_natural_mod_shr);\n    register_signed_demos!(runner, demo_natural_mod_shr_val_ref);\n    register_signed_demos!(runner, demo_natural_mod_shr_ref_val);\n    register_signed_demos!(runner, demo_natural_mod_shr_ref_ref);\n\n    register_signed_benches!(runner, benchmark_natural_mod_shr_assign_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_natural_mod_shr_algorithms);\n    register_signed_benches!(runner, benchmark_natural_mod_shr_evaluation_strategy);\n}\n\nfn demo_natural_mod_shr_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ModShrAssign<T>,\n{\n    for (mut n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_shr_assign(i, m.clone());\n        println!(\"x := {n_old}; x.mod_shr_assign({i}, {m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_shr_assign_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> Natural: ModShrAssign<T, &'a Natural>,\n{\n    for (mut n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.mod_shr_assign(i, &m);\n        println!(\"x := {n_old}; x.mod_shr_assign({i}, &{m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_shr<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ModShr<T, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.mod_shr({}, {}) = {}\",\n            n_old,\n            i,\n            m.clone(),\n            n.mod_shr(i, m)\n        );\n    }\n}\n\nfn demo_natural_mod_shr_val_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> Natural: ModShr<T, &'a Natural, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.mod_shr({}, &{}) = {}\", n_old, i, m, n.mod_shr(i, &m));\n    }\n}\n\nfn demo_natural_mod_shr_ref_val<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Natural: ModShr<T, Natural, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).mod_shr({}, {}) = {}\",\n            n,\n            i,\n            m.clone(),\n            (&n).mod_shr(i, m)\n        );\n    }\n}\n\nfn demo_natural_mod_shr_ref_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a, 'b> &'a Natural: ModShr<T, &'b Natural, Output = Natural>,\n{\n    for (n, m, i) in natural_natural_signed_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).mod_shr({}, &{}) = {}\", n, i, m, (&n).mod_shr(i, &m));\n    }\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn benchmark_natural_mod_shr_assign_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> Natural: ModShrAssign<T> + ModShrAssign<T, &'a Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shr_assign({}, Natural)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_shr_assign({}, Natural)\", T::NAME),\n                &mut |(mut x, m, y)| no_out!(x.mod_shr_assign(y, m)),\n            ),\n            (\n                &format!(\"Natural.mod_shr_assign({}, &Natural)\", T::NAME),\n                &mut |(mut x, m, y)| no_out!(x.mod_shr_assign(y, &m)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_mod_shr_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ModShr<T, Output = Natural> + Shr<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shr({}, Natural)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_natural_signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, m, y)| no_out!(x.mod_shr(y, m))),\n            (\"using >> and %\", &mut |(x, m, y)| no_out!((x >> y) % m)),\n        ],\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn benchmark_natural_mod_shr_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> Natural: ModShr<T, Output = Natural> + ModShr<T, &'a Natural, Output = Natural>,\n    for<'a, 'b> &'a Natural:\n        ModShr<T, Natural, Output = Natural> + ModShr<T, &'b Natural, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.mod_shr({}, Natural)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_signed_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_bit_bucketer(\"m\"),\n        &mut [\n            (\n                &format!(\"Natural.mod_shr({}, Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!(x.mod_shr(y, m)),\n            ),\n            (\n                &format!(\"Natural.mod_shr({}, &Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!(x.mod_shr(y, &m)),\n            ),\n            (\n                &format!(\"(&Natural).mod_shr({}, Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!((&x).mod_shr(y, m)),\n            ),\n            (\n                &format!(\"(&Natural).mod_shr({}, &Natural)\", T::NAME),\n                &mut |(x, m, y)| no_out!((&x).mod_shr(y, &m)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModMul, ModSquare, ModSquareAssign, Square};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_2_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_8;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_square_assign);\n    register_demo!(runner, demo_natural_mod_square_assign_ref);\n    register_demo!(runner, demo_natural_mod_square);\n    register_demo!(runner, demo_natural_mod_square_val_ref);\n    register_demo!(runner, demo_natural_mod_square_ref_val);\n    register_demo!(runner, demo_natural_mod_square_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_mod_square_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_mod_square_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_square_algorithms);\n}\n\nfn demo_natural_mod_square_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        n.mod_square_assign(m);\n        println!(\"x := {n_old}; x.mod_square_assign({m_old}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_square_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.mod_square_assign(&m);\n        println!(\"x := {n_old}; x.mod_square_assign(&{m}); x = {n}\");\n    }\n}\n\nfn demo_natural_mod_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let m_old = m.clone();\n        println!(\"{}.square() ≡ {} mod {}\", n_old, n.mod_square(m), m_old);\n    }\n}\n\nfn demo_natural_mod_square_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\"{}.square() ≡ {} mod &{}\", n_old, n.mod_square(&m), m);\n    }\n}\n\nfn demo_natural_mod_square_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\"(&{}).square() ≡ {} mod {}\", n, (&n).mod_square(m), m_old);\n    }\n}\n\nfn demo_natural_mod_square_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, m) in natural_pair_gen_var_8().get(gm, config).take(limit) {\n        println!(\"(&{}).square() ≡ {} mod &{}\", n, (&n).mod_square(&m), m);\n    }\n}\n\nfn benchmark_natural_mod_square_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_square_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_square_assign(Natural)\", &mut |(mut n, m)| {\n                n.mod_square_assign(m);\n            }),\n            (\"Natural.mod_square_assign(&Natural)\", &mut |(mut n, m)| {\n                n.mod_square_assign(&m);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_square_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_square(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_square(Natural)\", &mut |(n, m)| {\n                no_out!(n.mod_square(m));\n            }),\n            (\"Natural.mod_square(&Natural)\", &mut |(n, m)| {\n                no_out!(n.mod_square(&m));\n            }),\n            (\"(&Natural).mod_square(Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_square(m));\n            }),\n            (\"(&Natural).mod_square(&Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_square(&m));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_mod_square_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_square(Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_8().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_square(Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_square(&m));\n            }),\n            (\"Natural.mod_mul(Natural, Natural)\", &mut |(n, m)| {\n                no_out!((&n).mod_mul(&n, &m));\n            }),\n            (\"Natural.square() % Natural\", &mut |(n, m)| {\n                no_out!((&n).square() % &m);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mod_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Mod, ModSub, ModSubAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::bench::bucketers::triple_3_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_triple_gen_var_3;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_mod_sub_assign);\n    register_demo!(runner, demo_natural_mod_sub_assign_val_ref);\n    register_demo!(runner, demo_natural_mod_sub_assign_ref_val);\n    register_demo!(runner, demo_natural_mod_sub_assign_ref_ref);\n    register_demo!(runner, demo_natural_mod_sub);\n    register_demo!(runner, demo_natural_mod_sub_val_val_ref);\n    register_demo!(runner, demo_natural_mod_sub_val_ref_val);\n    register_demo!(runner, demo_natural_mod_sub_val_ref_ref);\n    register_demo!(runner, demo_natural_mod_sub_ref_val_val);\n    register_demo!(runner, demo_natural_mod_sub_ref_val_ref);\n    register_demo!(runner, demo_natural_mod_sub_ref_ref_val);\n    register_demo!(runner, demo_natural_mod_sub_ref_ref_ref);\n\n    register_bench!(runner, benchmark_natural_mod_sub_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mod_sub_algorithms);\n    register_bench!(runner, benchmark_natural_mod_sub_evaluation_strategy);\n}\n\nfn demo_natural_mod_sub_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        x.mod_sub_assign(y, m);\n        println!(\"x := {x_old}; x.mod_sub_assign({y_old}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_sub_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        let y_old = y.clone();\n        x.mod_sub_assign(y, &m);\n        println!(\"x := {x_old}; x.mod_sub_assign({y_old}, &{m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_sub_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        x.mod_sub_assign(&y, m);\n        println!(\"x := {x_old}; x.mod_sub_assign(&{y}, {m_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_sub_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.mod_sub_assign(&y, &m);\n        println!(\"x := {x_old}; x.mod_sub_assign(&{y}, &{m}); x = {x}\");\n    }\n}\n\nfn demo_natural_mod_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let m_old = m.clone();\n        println!(\"{} - {} ≡ {} mod {}\", x_old, y_old, x.mod_sub(y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_sub_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} ≡ {} mod {}\", x_old, y_old, x.mod_sub(y, &m), m);\n    }\n}\n\nfn demo_natural_mod_sub_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let m_old = m.clone();\n        println!(\"{} - {} ≡ {} mod {}\", x_old, y, x.mod_sub(&y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_sub_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} - {} ≡ {} mod {}\", x_old, y, x.mod_sub(&y, &m), m);\n    }\n}\n\nfn demo_natural_mod_sub_ref_val_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        let m_old = m.clone();\n        println!(\"{} - {} ≡ {} mod {}\", x, y_old, (&x).mod_sub(y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_sub_ref_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"{} - {} ≡ {} mod {}\", x, y_old, (&x).mod_sub(y, &m), m);\n    }\n}\n\nfn demo_natural_mod_sub_ref_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        let m_old = m.clone();\n        println!(\"{} - {} ≡ {} mod {}\", x, y, (&x).mod_sub(&y, m), m_old);\n    }\n}\n\nfn demo_natural_mod_sub_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, m) in natural_triple_gen_var_3().get(gm, config).take(limit) {\n        println!(\"{} - {} ≡ {} mod {}\", x, y, (&x).mod_sub(&y, &m), m);\n    }\n}\n\nfn benchmark_natural_mod_sub_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_sub_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\n                \"Natural.mod_sub_assign(Natural, Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_sub_assign(y, m)),\n            ),\n            (\n                \"Natural.mod_sub_assign(Natural, &Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_sub_assign(y, &m)),\n            ),\n            (\n                \"Natural.mod_sub_assign(&Natural, Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_sub_assign(&y, m)),\n            ),\n            (\n                \"Natural.mod_sub_assign(&Natural, &Natural)\",\n                &mut |(mut x, y, m)| no_out!(x.mod_sub_assign(&y, &m)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_mod_sub_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_sub(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"default\", &mut |(x, y, m)| no_out!(x.mod_sub(y, m))),\n            (\"naive\", &mut |(x, y, m)| {\n                no_out!((Integer::from(x) - Integer::from(y)).mod_op(Integer::from(m)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_mod_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.mod_sub(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"m\"),\n        &mut [\n            (\"Natural.mod_sub(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_sub(y, m));\n            }),\n            (\"Natural.mod_sub(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_sub(y, &m));\n            }),\n            (\"Natural.mod_sub(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_sub(&y, m));\n            }),\n            (\"Natural.mod_sub(&Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!(x.mod_sub(&y, &m));\n            }),\n            (\"(&Natural).mod_sub(Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_sub(y, m));\n            }),\n            (\"(&Natural).mod_sub(Natural, &Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_sub(y, &m));\n            }),\n            (\"(&Natural).mod_sub(&Natural, Natural)\", &mut |(x, y, m)| {\n                no_out!((&x).mod_sub(&y, m));\n            }),\n            (\n                \"(&Natural).mod_sub(&Natural, &Natural)\",\n                &mut |(x, y, m)| no_out!((&x).mod_sub(&y, &m)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_sum_vec_len_bucketer, quadruple_2_vec_len_bucketer,\n    triple_1_vec_len_bucketer, triple_2_3_sum_vec_len_bucketer, triple_2_vec_len_bucketer,\n    triple_3_vec_len_bucketer, vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    large_type_gen_var_1, unsigned_pair_gen_var_27, unsigned_vec_gen_var_6,\n    unsigned_vec_pair_gen_var_1, unsigned_vec_pair_gen_var_2, unsigned_vec_triple_gen_var_1,\n    unsigned_vec_triple_gen_var_2, unsigned_vec_triple_gen_var_3, unsigned_vec_triple_gen_var_24,\n    unsigned_vec_triple_gen_var_25, unsigned_vec_triple_gen_var_26, unsigned_vec_triple_gen_var_27,\n    unsigned_vec_unsigned_pair_gen, unsigned_vec_unsigned_unsigned_triple_gen,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mul::limb::{\n    limbs_mul_limb, limbs_mul_limb_to_out, limbs_mul_limb_with_carry_to_out,\n    limbs_slice_mul_limb_in_place, limbs_slice_mul_limb_with_carry_in_place,\n    limbs_vec_mul_limb_in_place,\n};\nuse malachite_nz::natural::arithmetic::mul::mul_low::{\n    limbs_mul_low_same_length, limbs_mul_low_same_length_basecase,\n    limbs_mul_low_same_length_basecase_alt, limbs_mul_low_same_length_divide_and_conquer,\n    limbs_mul_low_same_length_divide_and_conquer_scratch_len,\n    limbs_mul_low_same_length_divide_and_conquer_shared_scratch, limbs_mul_low_same_length_large,\n};\nuse malachite_nz::natural::arithmetic::mul::product_of_limbs::limbs_product;\nuse malachite_nz::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_6h, limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_6h_scratch_len, limbs_mul_greater_to_out_toom_8h,\n    limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_8h_scratch_len, limbs_mul_greater_to_out_toom_22,\n    limbs_mul_greater_to_out_toom_22_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_22_scratch_len, limbs_mul_greater_to_out_toom_32,\n    limbs_mul_greater_to_out_toom_32_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_32_scratch_len, limbs_mul_greater_to_out_toom_33,\n    limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_33_scratch_len, limbs_mul_greater_to_out_toom_42,\n    limbs_mul_greater_to_out_toom_42_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_42_scratch_len, limbs_mul_greater_to_out_toom_43,\n    limbs_mul_greater_to_out_toom_43_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_43_scratch_len, limbs_mul_greater_to_out_toom_44,\n    limbs_mul_greater_to_out_toom_44_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_44_scratch_len, limbs_mul_greater_to_out_toom_52,\n    limbs_mul_greater_to_out_toom_52_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_52_scratch_len, limbs_mul_greater_to_out_toom_53,\n    limbs_mul_greater_to_out_toom_53_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_53_scratch_len, limbs_mul_greater_to_out_toom_54,\n    limbs_mul_greater_to_out_toom_54_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_54_scratch_len, limbs_mul_greater_to_out_toom_62,\n    limbs_mul_greater_to_out_toom_62_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_62_scratch_len, limbs_mul_greater_to_out_toom_63,\n    limbs_mul_greater_to_out_toom_63_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_63_scratch_len,\n};\nuse malachite_nz::natural::arithmetic::mul::{\n    limbs_mul, limbs_mul_greater, limbs_mul_greater_to_out, limbs_mul_greater_to_out_basecase,\n    limbs_mul_greater_to_out_scratch_len, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n    triple_3_pair_natural_max_bit_bucketer, triple_3_vec_natural_sum_bits_bucketer,\n    vec_natural_sum_bits_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_pair_gen_nrm, natural_pair_gen_rm, natural_vec_gen,\n    natural_vec_gen_nrm, unsigned_vec_triple_gen_var_4, unsigned_vec_triple_gen_var_5,\n    unsigned_vec_triple_gen_var_6, unsigned_vec_triple_gen_var_7, unsigned_vec_triple_gen_var_8,\n    unsigned_vec_triple_gen_var_9, unsigned_vec_triple_gen_var_10, unsigned_vec_triple_gen_var_11,\n    unsigned_vec_triple_gen_var_12, unsigned_vec_triple_gen_var_13, unsigned_vec_triple_gen_var_14,\n    unsigned_vec_triple_gen_var_15, unsigned_vec_triple_gen_var_16, unsigned_vec_triple_gen_var_18,\n    unsigned_vec_triple_gen_var_19, unsigned_vec_triple_gen_var_20, unsigned_vec_triple_gen_var_22,\n    unsigned_vec_triple_gen_var_23, unsigned_vec_triple_gen_var_58,\n};\nuse malachite_nz::test_util::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out_basecase_mem_opt, limbs_product_naive, natural_product_naive,\n};\nuse num::BigUint;\nuse std::iter::Product;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_mul_limb);\n    register_demo!(runner, demo_limbs_mul_limb_with_carry_to_out);\n    register_demo!(runner, demo_limbs_mul_limb_to_out);\n    register_demo!(runner, demo_limbs_slice_mul_limb_with_carry_in_place);\n    register_demo!(runner, demo_limbs_slice_mul_limb_in_place);\n    register_demo!(runner, demo_limbs_vec_mul_limb_in_place);\n    register_demo!(runner, demo_limbs_mul_greater);\n    register_demo!(runner, demo_limbs_mul);\n    register_demo!(runner, demo_limbs_mul_same_length_to_out);\n    register_demo!(runner, demo_limbs_mul_greater_to_out);\n    register_demo!(runner, demo_limbs_mul_to_out);\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_22_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_32_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_33_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_42_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_43_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_44_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_52_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_53_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_54_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_62_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_63_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_6h_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_8h_input_sizes_valid\n    );\n    register_demo!(\n        runner,\n        demo_limbs_mul_greater_to_out_toom_33_and_toom_44_input_sizes_valid\n    );\n    register_demo!(runner, demo_limbs_mul_low_same_length_basecase);\n    register_demo!(\n        runner,\n        demo_limbs_mul_low_same_length_divide_and_conquer_shared_scratch\n    );\n    register_demo!(runner, demo_limbs_mul_low_same_length_divide_and_conquer);\n    register_demo!(runner, demo_limbs_mul_low_same_length);\n    register_demo!(runner, demo_limbs_product);\n    register_demo!(runner, demo_natural_mul);\n    register_demo!(runner, demo_natural_mul_val_ref);\n    register_demo!(runner, demo_natural_mul_ref_val);\n    register_demo!(runner, demo_natural_mul_ref_ref);\n    register_demo!(runner, demo_natural_mul_assign);\n    register_demo!(runner, demo_natural_mul_assign_ref);\n    register_demo!(runner, demo_natural_product);\n    register_demo!(runner, demo_natural_ref_product);\n\n    register_bench!(runner, benchmark_limbs_mul_limb);\n    register_bench!(runner, benchmark_limbs_mul_limb_with_carry_to_out);\n    register_bench!(runner, benchmark_limbs_mul_limb_to_out);\n    register_bench!(runner, benchmark_limbs_slice_mul_limb_with_carry_in_place);\n    register_bench!(runner, benchmark_limbs_slice_mul_limb_in_place);\n    register_bench!(runner, benchmark_limbs_vec_mul_limb_in_place);\n    register_bench!(runner, benchmark_limbs_mul_greater);\n    register_bench!(runner, benchmark_limbs_mul);\n    register_bench!(runner, benchmark_limbs_mul_same_length_to_out);\n    register_bench!(runner, benchmark_limbs_mul_greater_to_out_algorithms);\n    register_bench!(runner, benchmark_limbs_mul_to_out);\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_basecase_mem_opt_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_22_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_32_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_33_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_33_same_length_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_42_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_43_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_44_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_44_same_length_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_52_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_53_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_54_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_62_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_63_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_6h_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_6h_same_length_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_8h_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_8h_same_length_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_32_to_43_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_greater_to_out_toom_42_to_53_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_low_same_length_basecase_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_low_same_length_basecase_algorithms_2\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_low_same_length_divide_and_conquer_shared_scratch_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_mul_low_same_length_divide_and_conquer_algorithms\n    );\n    register_bench!(runner, benchmark_limbs_mul_low_same_length_large_algorithms);\n    register_bench!(runner, benchmark_limbs_mul_low_same_length_algorithms);\n    register_bench!(runner, benchmark_limbs_product_algorithms);\n    register_bench!(runner, benchmark_natural_mul_library_comparison);\n    register_bench!(runner, benchmark_natural_mul_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_mul_assign_library_comparison);\n    register_bench!(runner, benchmark_natural_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_product_algorithms);\n    register_bench!(runner, benchmark_natural_product_library_comparison);\n    register_bench!(runner, benchmark_natural_product_evaluation_strategy);\n}\n\nfn demo_limbs_mul_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"limbs_mul_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_mul_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_mul_limb_with_carry_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y, carry) in large_type_gen_var_1().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let carry_out =\n            limbs_mul_limb_with_carry_to_out::<DoubleLimb, Limb>(&mut out, &xs, y, carry);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_limb_with_carry_to_out(&mut out, {xs:?}, {y}, {carry}) = {carry_out}; \\\n             out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mul_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let carry = limbs_mul_limb_to_out::<DoubleLimb, Limb>(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_limb_to_out(&mut out, {xs:?}, {y}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_mul_limb_with_carry_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y, carry) in unsigned_vec_unsigned_unsigned_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry_out = limbs_slice_mul_limb_with_carry_in_place(&mut xs, y, carry);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_mul_limb_with_carry_in_place(&mut xs, {y}, {carry}) = {carry_out}; \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_mul_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_mul_limb_in_place(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_mul_limb_in_place(&mut xs, {y}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_mul_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_vec_mul_limb_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_vec_mul_limb_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_mul_greater(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_mul_greater({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_mul_greater(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\"limbs_mul({:?}, {:?}) = {:?}\", xs, ys, limbs_mul(&xs, &ys));\n    }\n}\n\nfn demo_limbs_mul_same_length_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_1().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(xs.len())];\n        limbs_mul_same_length_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_same_length_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mul_greater_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_2().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs.len(), ys.len())];\n        let carry = limbs_mul_greater_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_greater_to_out(&mut out, {xs:?}, {ys:?}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mul_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_3().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(xs.len(), ys.len())];\n        let carry = limbs_mul_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_to_out(&mut out, {xs:?}, {ys:?}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nmacro_rules! mul_valid_helper {\n    ($name: ident, $demo_name: ident) => {\n        fn $demo_name(gm: GenMode, config: &GenConfig, limit: usize) {\n            for (x, y) in unsigned_pair_gen_var_27().get(gm, config).take(limit) {\n                println!(\n                    concat!(stringify!($name), \"({}, {}) = {}\"),\n                    x,\n                    y,\n                    $name(x, y)\n                );\n            }\n        }\n    };\n}\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_22_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_22_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_32_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_32_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_33_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_42_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_42_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_43_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_43_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_44_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_44_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_52_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_52_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_53_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_53_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_54_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_54_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_62_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_62_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_63_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_63_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_6h_input_sizes_valid\n);\nmul_valid_helper!(\n    limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n    demo_limbs_mul_greater_to_out_toom_8h_input_sizes_valid\n);\n\nfn demo_limbs_mul_greater_to_out_toom_33_and_toom_44_input_sizes_valid(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, y) in unsigned_pair_gen_var_27().get(gm, config).take(limit) {\n        println!(\n            \"Toom-33 and Toom-44 ({}, {}) = {}\",\n            x,\n            y,\n            limbs_mul_greater_to_out_toom_33_input_sizes_valid(x, y)\n                && limbs_mul_greater_to_out_toom_44_input_sizes_valid(x, y)\n        );\n    }\n}\n\nfn demo_limbs_mul_low_same_length_basecase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_24().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_mul_low_same_length_basecase(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_low_same_length_basecase(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mul_low_same_length_divide_and_conquer_shared_scratch(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_25().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_mul_low_same_length_divide_and_conquer_shared_scratch(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n             limbs_mul_low_same_length_divide_and_conquer_shared_scratch\\\n             (&mut out, {xs:?}, {ys:?}); \\\n             out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mul_low_same_length_divide_and_conquer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_26().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let mut scratch = vec![0; xs.len() << 1];\n        limbs_mul_low_same_length_divide_and_conquer(&mut out, &xs, &ys, &mut scratch);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_low_same_length_divide_and_conquer(&mut out, {xs:?}, {ys:?}); \\\n             out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_mul_low_same_length(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_1().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_mul_low_same_length(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_mul_low_same_length(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_product(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut xs in unsigned_vec_gen_var_6().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let mut out = Vec::new();\n        let (size, new_out) = limbs_product(&mut out, &mut xs);\n        out = new_out.unwrap();\n        out.truncate(size);\n        println!(\"product_of_limbs({xs_old:?}) = {out:?}\");\n    }\n}\n\nfn demo_natural_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_natural_mul_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} * &{} = {}\", x_old, y, x * &y);\n    }\n}\n\nfn demo_natural_mul_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} * {} = {}\", x, y_old, &x * y);\n    }\n}\n\nfn demo_natural_mul_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} * &{} = {}\", x, y, &x * &y);\n    }\n}\n\nfn demo_natural_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\"x := {x_old}; x *= {y}; x = {x}\");\n    }\n}\n\nfn demo_natural_mul_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\"x := {x_old}; x *= &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_product(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in natural_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"product({:?}) = {}\",\n            xs.clone(),\n            Natural::product(xs.into_iter())\n        );\n    }\n}\n\nfn demo_natural_ref_product(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in natural_vec_gen().get(gm, config).take(limit) {\n        println!(\"product({:?}) = {}\", xs, Natural::product(xs.iter()));\n    }\n}\n\nfn benchmark_limbs_mul_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mul_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_mul_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_limbs_mul_limb_with_carry_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_limb_with_carry_to_out(&mut [Limb], &[Limb], Limb, Limb)\",\n        BenchmarkType::Single,\n        large_type_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y, carry)| {\n            no_out!(limbs_mul_limb_with_carry_to_out::<DoubleLimb, Limb>(\n                &mut out, &xs, y, carry\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_mul_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mul_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_mul_limb_to_out::<DoubleLimb, Limb>(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_mul_limb_with_carry_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_mul_limb_with_carry_in_place(&mut [Limb], Limb, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_unsigned_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y, carry)| {\n            no_out!(limbs_slice_mul_limb_with_carry_in_place(&mut xs, y, carry));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_mul_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_mul_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            no_out!(limbs_slice_mul_limb_in_place(&mut xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_mul_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_mul_limb_in_place(&mut Vec<Limb>, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_vec_mul_limb_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_mul_greater(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mul_greater(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_mul_greater(&xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_mul(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mul(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(limbs_mul(&xs, &ys)))],\n    );\n}\n\nfn benchmark_limbs_mul_same_length_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(xs.len())];\n            limbs_mul_same_length_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        })],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs, ys)| {\n                limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n            }),\n            (\"full\", &mut |(mut out, xs, ys)| {\n                let mut mul_scratch =\n                    vec![0; limbs_mul_greater_to_out_scratch_len(xs.len(), ys.len())];\n                no_out!(limbs_mul_greater_to_out(\n                    &mut out,\n                    &xs,\n                    &ys,\n                    &mut mul_scratch,\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_mul_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(xs.len(), ys.len())];\n            no_out!(limbs_mul_to_out(&mut out, &xs, &ys, &mut mul_scratch));\n        })],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_basecase_mem_opt_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out_basecase_mem_opt(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"limbs_mul_greater_to_out_basecase\", &mut |(\n                mut out,\n                xs,\n                ys,\n            )| {\n                limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n            }),\n            (\n                \"limbs_mul_greater_to_out_basecase_mem_opt\",\n                &mut |(mut out, xs, ys)| {\n                    limbs_mul_greater_to_out_basecase_mem_opt(&mut out, &xs, &ys);\n                },\n            ),\n        ],\n    );\n}\n\nmacro_rules! bench_mul_helper {\n    ($bench: ident, $mul: ident, $scratch: ident, $gen: ident, $name: expr) => {\n        fn $bench(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n            run_benchmark(\n                concat!(stringify!($mul), \"(&mut [Limb], &[Limb], &[Limb])\"),\n                BenchmarkType::Algorithms,\n                $gen().get(gm, config),\n                gm.name(),\n                limit,\n                file_name,\n                &triple_2_3_sum_vec_len_bucketer(\"xs\", \"ys\"),\n                &mut [\n                    (\"basecase\", &mut |(mut out, xs, ys)| {\n                        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys)\n                    }),\n                    ($name, &mut |(mut out, xs, ys)| {\n                        let mut scratch = vec![0; $scratch(xs.len(), ys.len())];\n                        $mul(&mut out, &xs, &ys, &mut scratch)\n                    }),\n                ],\n            );\n        }\n    };\n}\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_22_algorithms,\n    limbs_mul_greater_to_out_toom_22,\n    limbs_mul_greater_to_out_toom_22_scratch_len,\n    unsigned_vec_triple_gen_var_4,\n    \"Toom22\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_32_algorithms,\n    limbs_mul_greater_to_out_toom_32,\n    limbs_mul_greater_to_out_toom_32_scratch_len,\n    unsigned_vec_triple_gen_var_5,\n    \"Toom32\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_33_algorithms,\n    limbs_mul_greater_to_out_toom_33,\n    limbs_mul_greater_to_out_toom_33_scratch_len,\n    unsigned_vec_triple_gen_var_6,\n    \"Toom33\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_42_algorithms,\n    limbs_mul_greater_to_out_toom_42,\n    limbs_mul_greater_to_out_toom_42_scratch_len,\n    unsigned_vec_triple_gen_var_7,\n    \"Toom42\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_43_algorithms,\n    limbs_mul_greater_to_out_toom_43,\n    limbs_mul_greater_to_out_toom_43_scratch_len,\n    unsigned_vec_triple_gen_var_8,\n    \"Toom43\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_44_algorithms,\n    limbs_mul_greater_to_out_toom_44,\n    limbs_mul_greater_to_out_toom_44_scratch_len,\n    unsigned_vec_triple_gen_var_9,\n    \"Toom44\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_52_algorithms,\n    limbs_mul_greater_to_out_toom_52,\n    limbs_mul_greater_to_out_toom_52_scratch_len,\n    unsigned_vec_triple_gen_var_10,\n    \"Toom52\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_54_algorithms,\n    limbs_mul_greater_to_out_toom_54,\n    limbs_mul_greater_to_out_toom_54_scratch_len,\n    unsigned_vec_triple_gen_var_12,\n    \"Toom54\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_62_algorithms,\n    limbs_mul_greater_to_out_toom_62,\n    limbs_mul_greater_to_out_toom_62_scratch_len,\n    unsigned_vec_triple_gen_var_13,\n    \"Toom62\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_6h_algorithms,\n    limbs_mul_greater_to_out_toom_6h,\n    limbs_mul_greater_to_out_toom_6h_scratch_len,\n    unsigned_vec_triple_gen_var_15,\n    \"Toom6h\"\n);\nbench_mul_helper!(\n    benchmark_limbs_mul_greater_to_out_toom_8h_algorithms,\n    limbs_mul_greater_to_out_toom_8h,\n    limbs_mul_greater_to_out_toom_8h_scratch_len,\n    unsigned_vec_triple_gen_var_16,\n    \"Toom8h\"\n);\n\nfn benchmark_limbs_mul_greater_to_out_toom_53_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out_toom_53(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_11().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs, ys)| {\n                limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n            }),\n            (\"Toom32\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_32(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom42\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_42(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom53\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_53(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_toom_63_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out_toom_63(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_sum_vec_len_bucketer(\"xs\", \"ys\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs, ys)| {\n                limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n            }),\n            (\"Toom42\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_42(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom63\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_63(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_toom_33_same_length_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out_toom_33(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_18().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs, ys)| {\n                limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n            }),\n            (\"Toom22\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_22_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_22(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom33\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_33(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_toom_44_same_length_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out_toom_44(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_58().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"Toom33\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_33(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom44\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_44(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_toom_6h_same_length_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out_toom_6h(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"Toom33\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_33(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom44\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_44(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom6h\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_toom_8h_same_length_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_greater_to_out_toom_8h(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"Toom6h\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom8h\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_toom_32_to_43_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Toom32 to Toom43\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_len_bucketer(\"ys\"),\n        &mut [\n            (\"Toom32\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_32(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom43\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_43(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_greater_to_out_toom_42_to_53_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Toom42 to Toom53\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_23().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_len_bucketer(\"ys\"),\n        &mut [\n            (\"Toom42\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_42(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"Toom53\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(xs.len(), ys.len())];\n                limbs_mul_greater_to_out_toom_53(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_low_same_length_basecase_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_low_same_length_basecase(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_24().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut out, xs, ys)| {\n                limbs_mul_low_same_length_basecase(&mut out, &xs, &ys);\n            }),\n            (\"alt\", &mut |(mut out, xs, ys)| {\n                limbs_mul_low_same_length_basecase_alt(&mut out, &xs, &ys);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_low_same_length_basecase_algorithms_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_low_same_length_basecase(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase mul\", &mut |(mut out, xs, ys)| {\n                limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n            }),\n            (\"basecase mul low\", &mut |(mut out, xs, ys)| {\n                limbs_mul_low_same_length_basecase(&mut out, &xs, &ys);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_low_same_length_divide_and_conquer_shared_scratch_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_low_same_length_divide_and_conquer_shared_scratch\\\n         (&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_25().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs, ys)| {\n                limbs_mul_low_same_length_basecase(&mut out, &xs, &ys);\n            }),\n            (\"divide-and-conquer\", &mut |(mut out, xs, ys)| {\n                limbs_mul_low_same_length_divide_and_conquer_shared_scratch(&mut out, &xs, &ys);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_low_same_length_divide_and_conquer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_low_same_length_divide_and_conquer(&mut [Limb], &[Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_26().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs, ys)| {\n                limbs_mul_low_same_length_basecase(&mut out, &xs, &ys);\n            }),\n            (\"divide-and-conquer\", &mut |(mut out, xs, ys)| {\n                let mut scratch = vec![0; ys.len() << 1];\n                limbs_mul_low_same_length_divide_and_conquer(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_low_same_length_large_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_low_same_length_large(&mut [Limb], &[Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_27().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"mul low divide-and-conquer\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_low_same_length_divide_and_conquer_scratch_len(xs.len())];\n                limbs_mul_low_same_length_divide_and_conquer(&mut out, &xs, &ys, &mut scratch);\n            }),\n            (\"mul low large\", &mut |(mut out, xs, ys)| {\n                let mut scratch =\n                    vec![0; limbs_mul_low_same_length_divide_and_conquer_scratch_len(xs.len())];\n                limbs_mul_low_same_length_large(&mut out, &xs, &ys, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_mul_low_same_length_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_mul_low_same_length(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"mul low\", &mut |(mut out, xs, ys)| {\n                limbs_mul_low_same_length(&mut out, &xs, &ys);\n            }),\n            (\"mul\", &mut |(mut out, xs, ys)| {\n                let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(xs.len())];\n                limbs_mul_same_length_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_product_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_product(&mut [Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |mut xs| {\n                let mut out = Vec::new();\n                let (size, new_out) = limbs_product(&mut out, &mut xs);\n                out = new_out.unwrap();\n                out.truncate(size);\n            }),\n            (\"naive\", &mut |xs| {\n                let mut out = vec![0; xs.len()];\n                let out_len = limbs_product_naive(&mut out, &xs);\n                out.truncate(out_len);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_mul_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural * Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x * y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x * y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x * y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural * Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural * Natural\", &mut |(x, y)| no_out!(x * y)),\n            (\"Natural * &Natural\", &mut |(x, y)| no_out!(x * &y)),\n            (\"&Natural * Natural\", &mut |(x, y)| no_out!(&x * y)),\n            (\"&Natural * &Natural\", &mut |(x, y)| no_out!(&x * &y)),\n        ],\n    );\n}\n\nfn benchmark_natural_mul_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural *= Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x *= y), (\"rug\", &mut |((mut x, y), _)| x *= y)],\n    );\n}\n\nfn benchmark_natural_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural *= Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural *= Natural\", &mut |(mut x, y)| no_out!(x *= y)),\n            (\"Natural *= &Natural\", &mut |(mut x, y)| no_out!(x *= &y)),\n        ],\n    );\n}\n\nfn benchmark_natural_product_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::product(Iterator<Item=Natural>)\",\n        BenchmarkType::LibraryComparison,\n        natural_vec_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, xs)| {\n                no_out!(Natural::product(xs.into_iter()));\n            }),\n            (\"num\", &mut |(xs, _, _)| {\n                no_out!(BigUint::product(xs.into_iter()));\n            }),\n            (\"rug\", &mut |(_, xs, _)| {\n                no_out!(rug::Integer::product(xs.iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_product_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::product(Iterator<Item=Natural>)\",\n        BenchmarkType::Algorithms,\n        natural_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |xs| {\n                no_out!(Natural::product(xs.into_iter()));\n            }),\n            (\"naive\", &mut |xs| {\n                no_out!(natural_product_naive(xs.into_iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_product_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::product(Iterator<Item=Natural>)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\"Natural::product(Iterator<Item=Natural>)\", &mut |xs| {\n                no_out!(Natural::product(xs.into_iter()));\n            }),\n            (\"Natural::product(Iterator<Item=&Natural>)\", &mut |xs| {\n                no_out!(Natural::product(xs.iter()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, triple_3_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_nrm};\nuse malachite_nz::test_util::natural::arithmetic::neg::neg_num;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_neg);\n    register_demo!(runner, demo_natural_neg_ref);\n    register_bench!(runner, benchmark_natural_neg_library_comparison);\n    register_bench!(runner, benchmark_natural_neg_evaluation_strategy);\n}\n\nfn demo_natural_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"-{} = {}\", n.clone(), -n);\n    }\n}\n\nfn demo_natural_neg_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"-(&{}) = {}\", n.clone(), -n);\n    }\n}\n\n#[allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)]\nfn benchmark_natural_neg_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(-x)),\n            (\"num\", &mut |(x, _, _)| no_out!(neg_num(x))),\n            (\"rug\", &mut |(_, x, _)| no_out!(-x)),\n        ],\n    );\n}\n\n#[allow(unused_must_use, clippy::no_effect)]\nfn benchmark_natural_neg_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"-Natural\", &mut |x| no_out!(-x)), (\"-&Natural\", &mut |x| no_out!(-&x))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{NextPowerOf2, NextPowerOf2Assign};\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::next_power_of_2::{\n    limbs_next_power_of_2, limbs_slice_next_power_of_2_in_place, limbs_vec_next_power_of_2_in_place,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_2_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_next_power_of_2);\n    register_demo!(runner, demo_limbs_slice_next_power_of_2_in_place);\n    register_demo!(runner, demo_limbs_vec_next_power_of_2_in_place);\n    register_demo!(runner, demo_natural_next_power_of_2_assign);\n    register_demo!(runner, demo_natural_next_power_of_2);\n    register_demo!(runner, demo_natural_next_power_of_2_ref);\n\n    register_bench!(runner, benchmark_limbs_next_power_of_2);\n    register_bench!(runner, benchmark_limbs_slice_next_power_of_2_in_place);\n    register_bench!(runner, benchmark_limbs_vec_next_power_of_2_in_place);\n    register_bench!(runner, benchmark_natural_next_power_of_2_assign);\n    register_bench!(runner, benchmark_natural_next_power_of_2_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_natural_next_power_of_2_evaluation_strategy\n    );\n}\n\nfn demo_limbs_next_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_next_power_of_2({:?}) = {:?}\",\n            xs,\n            limbs_next_power_of_2(&xs)\n        );\n    }\n}\n\nfn demo_limbs_slice_next_power_of_2_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_next_power_of_2_in_place(&mut xs);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_next_power_of_2_in_place(&mut xs) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_next_power_of_2_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_vec_next_power_of_2_in_place(&mut xs);\n        println!(\"xs := {xs_old:?}; limbs_vec_next_power_of_2_in_place(&mut xs); xs = {xs:?}\");\n    }\n}\n\nfn demo_natural_next_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in natural_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.next_power_of_2_assign();\n        println!(\"x := {n_old}; x.next_power_of_2_assign(); x = {n}\");\n    }\n}\n\nfn demo_natural_next_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\"{}.next_power_of_2() = {}\", n_old, n.next_power_of_2());\n    }\n}\n\nfn demo_natural_next_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).next_power_of_2() = {}\", n, (&n).next_power_of_2());\n    }\n}\n\nfn benchmark_limbs_next_power_of_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_next_power_of_2(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_next_power_of_2(&xs)))],\n    );\n}\n\nfn benchmark_limbs_slice_next_power_of_2_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_next_power_of_2_in_place(&mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |mut xs| {\n            no_out!(limbs_slice_next_power_of_2_in_place(&mut xs));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_next_power_of_2_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_next_power_of_2_in_place(&mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |mut xs| {\n            limbs_vec_next_power_of_2_in_place(&mut xs);\n        })],\n    );\n}\n\nfn benchmark_natural_next_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.next_power_of_2_assign()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |mut n| n.next_power_of_2_assign())],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_next_power_of_2_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.next_power_of_2()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(n.next_power_of_2())),\n            (\"rug\", &mut |(n, _)| no_out!(n.next_power_of_two())),\n        ],\n    );\n}\n\nfn benchmark_natural_next_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.next_power_of_2()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.next_power_of_2()\", &mut |n| {\n                no_out!(n.next_power_of_2());\n            }),\n            (\"(&Natural).next_power_of_2()\", &mut |n| {\n                no_out!((&n).next_power_of_2());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_even);\n    register_demo!(runner, demo_natural_odd);\n\n    register_bench!(runner, benchmark_natural_even);\n    register_bench!(runner, benchmark_natural_odd);\n}\n\nfn demo_natural_even(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        if n.even() {\n            println!(\"{n} is even\");\n        } else {\n            println!(\"{n} is not even\");\n        }\n    }\n}\n\nfn demo_natural_odd(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        if n.odd() {\n            println!(\"{n} is odd\");\n        } else {\n            println!(\"{n} is not odd\");\n        }\n    }\n}\n\nfn benchmark_natural_even(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.even()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.even()))],\n    );\n}\n\nfn benchmark_natural_odd(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.odd()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.odd()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Pow, PowAssign};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_bits_times_pair_2_bucketer, pair_1_vec_len_times_pair_2_bucketer,\n    triple_3_pair_1_bits_times_pair_2_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_31;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::pow::limbs_pow;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_4_nrm,\n};\nuse malachite_nz::test_util::natural::arithmetic::pow::{\n    natural_pow_naive, natural_pow_simple_binary,\n};\nuse num::traits::Pow as NumPow;\nuse rug::ops::Pow as RugPow;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_pow);\n    register_demo!(runner, demo_natural_pow_assign);\n    register_demo!(runner, demo_natural_pow);\n    register_demo!(runner, demo_natural_pow_ref);\n\n    register_bench!(runner, benchmark_limbs_pow);\n    register_bench!(runner, benchmark_natural_pow_assign);\n    register_bench!(runner, benchmark_natural_pow_algorithms);\n    register_bench!(runner, benchmark_natural_pow_library_comparison);\n    register_bench!(runner, benchmark_natural_pow_evaluation_strategy);\n}\n\nfn demo_limbs_pow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, exp) in unsigned_vec_unsigned_pair_gen_var_31()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"limbs_pow({:?}, {}) = {:?}\", xs, exp, limbs_pow(&xs, exp));\n    }\n}\n\nfn demo_natural_pow_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, pow) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.pow_assign(pow);\n        println!(\"x := {n_old}; x.pow_assign({pow}); x = {n}\");\n    }\n}\n\nfn demo_natural_pow(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{}.pow({}) = {}\", n_old, pow, n.pow(pow));\n    }\n}\n\nfn demo_natural_pow_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).pow({}) = {}\", n, pow, (&n).pow(pow));\n    }\n}\n\nfn benchmark_limbs_pow(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_pow(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_bucketer(\"xs\", \"exp\"),\n        &mut [(\"Malachite\", &mut |(ref xs, exp)| {\n            no_out!(limbs_pow(xs, exp));\n        })],\n    );\n}\n\nfn benchmark_natural_pow_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.pow_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bits_times_pair_2_bucketer(\"x\", \"exp\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp)| x.pow_assign(exp))],\n    );\n}\n\nfn benchmark_natural_pow_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.pow(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bits_times_pair_2_bucketer(\"x\", \"exp\"),\n        &mut [\n            (\"default\", &mut |(x, exp)| no_out!((&x).pow(exp))),\n            (\"naive\", &mut |(x, exp)| no_out!(natural_pow_naive(&x, exp))),\n            (\"simple binary\", &mut |(x, exp)| {\n                no_out!(natural_pow_simple_binary(&x, exp));\n            }),\n            (\"alt\", &mut |(x, exp)| no_out!(x.pow_ref_alt(exp))),\n        ],\n    );\n}\n\nfn benchmark_natural_pow_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.pow(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_bits_times_pair_2_bucketer(\"x\", \"exp\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, exp))| no_out!(x.pow(exp))),\n            (\"num\", &mut |((x, exp), _, _)| no_out!(x.pow(exp))),\n            (\"rug\", &mut |(_, (x, exp), _)| {\n                no_out!(x.pow(u32::exact_from(exp)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_pow_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.pow(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_bits_times_pair_2_bucketer(\"x\", \"exp\"),\n        &mut [\n            (\"Natural.pow(u64)\", &mut |(x, exp)| no_out!(x.pow(exp))),\n            (\"(&Natural).pow(u64)\", &mut |(x, exp)| {\n                no_out!((&x).pow(exp));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_5;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_power_of_2);\n    register_bench!(runner, benchmark_natural_power_of_2);\n}\n\nfn demo_natural_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for pow in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"2^{} = {}\", pow, Natural::power_of_2(pow));\n    }\n}\n\nfn benchmark_natural_power_of_2(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.power_of_2(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |pow| no_out!(Natural::power_of_2(pow)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Primorial;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_5;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::natural::arithmetic::primorial::{\n    primorial_naive, product_of_first_n_primes_naive,\n};\nuse rug::Complete;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_primorial);\n    register_demo!(runner, demo_product_of_first_n_primes);\n\n    register_bench!(runner, benchmark_primorial_library_comparison);\n    register_bench!(runner, benchmark_primorial_algorithms);\n    register_bench!(runner, benchmark_product_of_first_n_primes_algorithms);\n}\n\nfn demo_primorial(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"{}# = {}\", n, Natural::primorial(n));\n    }\n}\n\nfn demo_product_of_first_n_primes(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"p_{}# = {}\", n, Natural::product_of_first_n_primes(n));\n    }\n}\n\nfn benchmark_primorial_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.primorial(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |n| no_out!(Natural::primorial(n))),\n            (\"rug\", &mut |n| {\n                no_out!(rug::Integer::primorial(u32::exact_from(n)).complete());\n            }),\n        ],\n    );\n}\n\nfn benchmark_primorial_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.primorial(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| no_out!(Natural::primorial(n))),\n            (\"naive\", &mut |n| no_out!(primorial_naive(n))),\n        ],\n    );\n}\n\nfn benchmark_product_of_first_n_primes_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.product_of_first_n_primes(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"default\", &mut |n| {\n                no_out!(Natural::product_of_first_n_primes(n));\n            }),\n            (\"naive\", &mut |n| {\n                no_out!(product_of_first_n_primes_naive(n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingRootAssign, CheckedRoot, FloorRoot, FloorRootAssign, Pow, RootAssignRem,\n    RootRem,\n};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_14;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::root::{limbs_floor_root, limbs_root_rem};\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer, pair_2_natural_bit_bucketer,\n    pair_2_pair_1_natural_bit_bucketer, triple_3_natural_bit_bucketer,\n    triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_nrm, natural_gen_rm, natural_unsigned_pair_gen_var_7,\n    natural_unsigned_pair_gen_var_7_nrm, natural_unsigned_pair_gen_var_7_rm,\n};\nuse malachite_nz::test_util::natural::arithmetic::root::{\n    ceiling_root_binary, checked_root_binary, floor_root_binary, root_rem_binary,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_floor_root);\n    register_demo!(runner, demo_limbs_root_rem);\n\n    register_demo!(runner, demo_natural_floor_cbrt);\n    register_demo!(runner, demo_natural_floor_cbrt_ref);\n    register_demo!(runner, demo_natural_floor_cbrt_assign);\n    register_demo!(runner, demo_natural_ceiling_cbrt);\n    register_demo!(runner, demo_natural_ceiling_cbrt_ref);\n    register_demo!(runner, demo_natural_ceiling_cbrt_assign);\n    register_demo!(runner, demo_natural_checked_cbrt);\n    register_demo!(runner, demo_natural_checked_cbrt_ref);\n    register_demo!(runner, demo_natural_cbrt_rem);\n    register_demo!(runner, demo_natural_cbrt_rem_ref);\n    register_demo!(runner, demo_natural_cbrt_assign_rem);\n\n    register_demo!(runner, demo_natural_floor_root);\n    register_demo!(runner, demo_natural_floor_root_ref);\n    register_demo!(runner, demo_natural_floor_root_assign);\n    register_demo!(runner, demo_natural_ceiling_root);\n    register_demo!(runner, demo_natural_ceiling_root_ref);\n    register_demo!(runner, demo_natural_ceiling_root_assign);\n    register_demo!(runner, demo_natural_checked_root);\n    register_demo!(runner, demo_natural_checked_root_ref);\n    register_demo!(runner, demo_natural_root_rem);\n    register_demo!(runner, demo_natural_root_rem_ref);\n    register_demo!(runner, demo_natural_root_assign_rem);\n\n    register_bench!(runner, benchmark_limbs_floor_root);\n    register_bench!(runner, benchmark_limbs_root_rem);\n\n    register_bench!(runner, benchmark_natural_floor_cbrt_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_floor_cbrt_algorithms);\n    register_bench!(runner, benchmark_natural_floor_cbrt_library_comparison);\n    register_bench!(runner, benchmark_natural_floor_cbrt_assign);\n    register_bench!(runner, benchmark_natural_ceiling_cbrt_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_ceiling_cbrt_algorithms);\n    register_bench!(runner, benchmark_natural_ceiling_cbrt_assign);\n    register_bench!(runner, benchmark_natural_checked_cbrt_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_checked_cbrt_algorithms);\n    register_bench!(runner, benchmark_natural_cbrt_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_cbrt_rem_algorithms);\n    register_bench!(runner, benchmark_natural_cbrt_rem_library_comparison);\n    register_bench!(runner, benchmark_natural_cbrt_assign_rem);\n\n    register_bench!(runner, benchmark_natural_floor_root_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_floor_root_algorithms);\n    register_bench!(runner, benchmark_natural_floor_root_library_comparison);\n    register_bench!(runner, benchmark_natural_floor_root_assign);\n    register_bench!(runner, benchmark_natural_ceiling_root_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_ceiling_root_algorithms);\n    register_bench!(runner, benchmark_natural_ceiling_root_assign);\n    register_bench!(runner, benchmark_natural_checked_root_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_checked_root_algorithms);\n    register_bench!(runner, benchmark_natural_root_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_root_rem_algorithms);\n    register_bench!(runner, benchmark_natural_root_rem_library_comparison);\n    register_bench!(runner, benchmark_natural_root_assign_rem);\n}\n\nfn demo_limbs_floor_root(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, exp) in unsigned_vec_unsigned_pair_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_root({:?}, {}) = {:?}\",\n            xs,\n            exp,\n            limbs_floor_root(&xs, exp)\n        );\n    }\n}\n\nfn demo_limbs_root_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, exp) in unsigned_vec_unsigned_pair_gen_var_14()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_root_rem({:?}, {}) = {:?}\",\n            xs,\n            exp,\n            limbs_root_rem(&xs, exp)\n        );\n    }\n}\n\nfn demo_natural_floor_cbrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.floor_root(3) = {}\", x, x.clone().floor_root(3));\n    }\n}\n\nfn demo_natural_floor_cbrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).floor_root(3) = {}\", x, (&x).floor_root(3));\n    }\n}\n\nfn demo_natural_floor_cbrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in natural_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.floor_root_assign(3);\n        println!(\"x := {old_x}; x.floor_root_assign(3); x = {x}\");\n    }\n}\n\nfn demo_natural_ceiling_cbrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.ceiling_root(3) = {}\", x, x.clone().ceiling_root(3));\n    }\n}\n\nfn demo_natural_ceiling_cbrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).ceiling_root(3) = {}\", x, (&x).ceiling_root(3));\n    }\n}\n\nfn demo_natural_ceiling_cbrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in natural_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.ceiling_root_assign(3);\n        println!(\"x := {old_x}; x.ceiling_root_assign(3); x = {x}\");\n    }\n}\n\nfn demo_natural_checked_cbrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.checked_root(3) = {:?}\", x, x.clone().checked_root(3));\n    }\n}\n\nfn demo_natural_checked_cbrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_root(3) = {:?}\", x, (&x).checked_root(3));\n    }\n}\n\nfn demo_natural_cbrt_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.root_rem(3) = {:?}\", x, x.clone().root_rem(3));\n    }\n}\n\nfn demo_natural_cbrt_rem_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).root_rem(3) = {:?}\", x, (&x).root_rem(3));\n    }\n}\n\nfn demo_natural_cbrt_assign_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in natural_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        let rem = x.root_assign_rem(3);\n        println!(\"x := {old_x}; x.root_assign_rem(3) = {rem}; x = {x}\");\n    }\n}\n\nfn demo_natural_floor_root(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.floor_root({}) = {}\", x, exp, x.clone().floor_root(exp));\n    }\n}\n\nfn demo_natural_floor_root_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).floor_root({}) = {}\", x, exp, (&x).floor_root(exp));\n    }\n}\n\nfn demo_natural_floor_root_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        x.floor_root_assign(exp);\n        println!(\"x := {old_x}; x.floor_root_assign({exp}); x = {x}\");\n    }\n}\n\nfn demo_natural_ceiling_root(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.ceiling_root({}) = {}\",\n            x,\n            exp,\n            x.clone().ceiling_root(exp)\n        );\n    }\n}\n\nfn demo_natural_ceiling_root_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).ceiling_root({}) = {}\",\n            x,\n            exp,\n            (&x).ceiling_root(exp)\n        );\n    }\n}\n\nfn demo_natural_ceiling_root_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        x.ceiling_root_assign(exp);\n        println!(\"x := {old_x}; x.ceiling_root_assign({exp}); x = {x}\");\n    }\n}\n\nfn demo_natural_checked_root(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.checked_root({}) = {:?}\",\n            x,\n            exp,\n            x.clone().checked_root(exp)\n        );\n    }\n}\n\nfn demo_natural_checked_root_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).checked_root({}) = {:?}\",\n            x,\n            exp,\n            (&x).checked_root(exp)\n        );\n    }\n}\n\nfn demo_natural_root_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.root_rem({}) = {:?}\", x, exp, x.clone().root_rem(exp));\n    }\n}\n\nfn demo_natural_root_rem_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).root_rem({}) = {:?}\", x, exp, (&x).root_rem(exp));\n    }\n}\n\nfn demo_natural_root_assign_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, exp) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_x = x.clone();\n        let rem = x.root_assign_rem(exp);\n        println!(\"x := {old_x}; x.root_assign_rem({exp}) = {rem}; x = {x}\");\n    }\n}\n\nfn benchmark_limbs_floor_root(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_floor_root(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, exp)| {\n            no_out!(limbs_floor_root(&xs, exp));\n        })],\n    );\n}\n\nfn benchmark_limbs_root_rem(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_root_rem(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_14().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, exp)| {\n            no_out!(limbs_root_rem(&xs, exp));\n        })],\n    );\n}\n\nfn benchmark_natural_floor_cbrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root(3)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.floor_root(3)\", &mut |x| no_out!(x.floor_root(3))),\n            (\"(&Natural).floor_root(3)\", &mut |x| {\n                no_out!((&x).floor_root(3));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_floor_cbrt_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root(3)\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.floor_root(3))),\n            (\"binary\", &mut |x| no_out!(floor_root_binary(&x, 3))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_floor_cbrt_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root(3)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"num\", &mut |(x, _, _)| no_out!(x.nth_root(3))),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.root(3))),\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.floor_root(3))),\n        ],\n    );\n}\n\nfn benchmark_natural_floor_cbrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root_assign(3)\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.floor_root_assign(3))],\n    );\n}\n\nfn benchmark_natural_ceiling_cbrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_root(3)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.ceiling_root(3)\", &mut |x| {\n                no_out!(x.ceiling_root(3));\n            }),\n            (\"(&Natural).ceiling_root(3)\", &mut |x| {\n                no_out!((&x).ceiling_root(3));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_cbrt_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_root(3)\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.ceiling_root(3))),\n            (\"binary\", &mut |x| no_out!(ceiling_root_binary(&x, 3))),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_cbrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_root_assign(3)\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.ceiling_root_assign(3))],\n    );\n}\n\nfn benchmark_natural_checked_cbrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_root(3)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.checked_root(3)\", &mut |x| {\n                no_out!(x.checked_root(3));\n            }),\n            (\"(&Natural).checked_root(3)\", &mut |x| {\n                no_out!((&x).checked_root(3));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_cbrt_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_root(3)\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.checked_root(3))),\n            (\"binary\", &mut |x| no_out!(checked_root_binary(&x, 3))),\n        ],\n    );\n}\n\nfn benchmark_natural_cbrt_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_rem(3)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.root_rem(3)\", &mut |x| no_out!(x.root_rem(3))),\n            (\"(&Natural).root_rem(3)\", &mut |x| no_out!((&x).root_rem(3))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_natural_cbrt_rem_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_rem(3)\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.root_rem(3))),\n            (\"floor and subtraction\", &mut |x| {\n                let root = (&x).floor_root(3);\n                let pow = (&root).pow(3);\n                (root, x - pow);\n            }),\n            (\"binary\", &mut |x| no_out!(root_rem_binary(&x, 3))),\n        ],\n    );\n}\n\nfn benchmark_natural_cbrt_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_rem(3)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"rug\", &mut |(x, _)| {\n                no_out!(x.root_rem(rug::Integer::new(), 3));\n            }),\n            (\"Malachite\", &mut |(_, x)| no_out!(x.root_rem(3))),\n        ],\n    );\n}\n\nfn benchmark_natural_cbrt_assign_rem(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_assign_rem(3)\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| no_out!(x.root_assign_rem(3)))],\n    );\n}\n\nfn benchmark_natural_floor_root_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.floor_root()\", &mut |(x, exp)| {\n                no_out!(x.floor_root(exp));\n            }),\n            (\"(&Natural).floor_root()\", &mut |(x, exp)| {\n                no_out!((&x).floor_root(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_floor_root_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, exp)| no_out!(x.floor_root(exp))),\n            (\"binary\", &mut |(x, exp)| {\n                no_out!(floor_root_binary(&x, exp));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_floor_root_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_7_nrm::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"num\", &mut |((x, exp), _, _)| {\n                no_out!(x.nth_root(u32::exact_from(exp)));\n            }),\n            (\"rug\", &mut |(_, (x, exp), _)| {\n                no_out!(x.root(u32::exact_from(exp)));\n            }),\n            (\"Malachite\", &mut |(_, _, (x, exp))| {\n                no_out!(x.floor_root(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_floor_root_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_root_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp)| x.floor_root_assign(exp))],\n    );\n}\n\nfn benchmark_natural_ceiling_root_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_root(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.ceiling_root()\", &mut |(x, exp)| {\n                no_out!(x.ceiling_root(exp));\n            }),\n            (\"(&Natural).ceiling_root()\", &mut |(x, exp)| {\n                no_out!((&x).ceiling_root(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_root_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_root(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, exp)| no_out!(x.ceiling_root(exp))),\n            (\"binary\", &mut |(x, exp)| {\n                no_out!(ceiling_root_binary(&x, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_root_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_root_assign(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp)| x.ceiling_root_assign(exp))],\n    );\n}\n\nfn benchmark_natural_checked_root_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_root(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.checked_root()\", &mut |(x, exp)| {\n                no_out!(x.checked_root(exp));\n            }),\n            (\"(&Natural).checked_root()\", &mut |(x, exp)| {\n                no_out!((&x).checked_root(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_root_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_root(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, exp)| no_out!(x.checked_root(exp))),\n            (\"binary\", &mut |(x, exp)| {\n                no_out!(checked_root_binary(&x, exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_root_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_rem(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.root_rem()\", &mut |(x, exp)| {\n                no_out!(x.root_rem(exp));\n            }),\n            (\"(&Natural).root_rem()\", &mut |(x, exp)| {\n                no_out!((&x).root_rem(exp));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_natural_root_rem_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_rem(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, exp)| no_out!(x.root_rem(exp))),\n            (\"floor and subtraction\", &mut |(x, exp)| {\n                let root = (&x).floor_root(exp);\n                let pow = (&root).pow(exp);\n                (root, x - pow);\n            }),\n            (\"binary\", &mut |(x, exp)| no_out!(root_rem_binary(&x, exp))),\n        ],\n    );\n}\n\nfn benchmark_natural_root_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_rem(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_7_rm::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"rug\", &mut |((x, exp), _)| {\n                no_out!(x.root_rem(rug::Integer::new(), u32::exact_from(exp)));\n            }),\n            (\"Malachite\", &mut |(_, (x, exp))| no_out!(x.root_rem(exp))),\n        ],\n    );\n}\n\nfn benchmark_natural_root_assign_rem(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.root_assign_rem(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut x, exp)| {\n            no_out!(x.root_assign_rem(exp));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{RoundToMultiple, RoundToMultipleAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_natural_rounding_mode_triple_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_round_to_multiple_assign);\n    register_demo!(runner, demo_natural_round_to_multiple_assign_ref);\n    register_demo!(runner, demo_natural_round_to_multiple);\n    register_demo!(runner, demo_natural_round_to_multiple_val_ref);\n    register_demo!(runner, demo_natural_round_to_multiple_ref_val);\n    register_demo!(runner, demo_natural_round_to_multiple_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_round_to_multiple_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_round_to_multiple_evaluation_strategy\n    );\n}\n\nfn demo_natural_round_to_multiple_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in natural_natural_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.round_to_multiple_assign(y, rm);\n        println!(\"x := {x_old}; x.round_to_multiple_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_natural_round_to_multiple_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in natural_natural_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.round_to_multiple_assign(&y, rm);\n        println!(\"x := {x_old}; x.round_to_multiple_assign(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_natural_round_to_multiple(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.round_to_multiple({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_natural_round_to_multiple_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"{}.round_to_multiple(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.round_to_multiple(&y, rm)\n        );\n    }\n}\n\nfn demo_natural_round_to_multiple_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).round_to_multiple({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            (&x).round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_natural_round_to_multiple_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in natural_natural_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).round_to_multiple(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            (&x).round_to_multiple(&y, rm)\n        );\n    }\n}\n\nfn benchmark_natural_round_to_multiple_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.round_to_multiple_assign(Natural, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Natural.round_to_multiple_assign(Natural, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.round_to_multiple_assign(y, rm)),\n            ),\n            (\n                \"Natural.round_to_multiple_assign(&Natural, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.round_to_multiple_assign(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_round_to_multiple_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.round_to_multiple(Natural, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Natural.round_to_multiple(Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple(y, rm)),\n            ),\n            (\n                \"Natural.round_to_multiple(&Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple(&y, rm)),\n            ),\n            (\n                \"(&Natural).round_to_multiple(Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple(y, rm)),\n            ),\n            (\n                \"(&Natural).round_to_multiple(&Natural, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple(&y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    PowerOf2, RoundToMultiple, RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign, ShrRound,\n};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, triple_1_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_16, unsigned_vec_unsigned_pair_gen_var_20,\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::round_to_multiple_of_power_of_2::*;\nuse malachite_nz::test_util::bench::bucketers::triple_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_unsigned_rounding_mode_triple_gen_var_1;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_round_to_multiple_of_power_of_2_down);\n    register_demo!(runner, demo_limbs_round_to_multiple_of_power_of_2_up);\n    register_demo!(runner, demo_limbs_round_to_multiple_of_power_of_2_nearest);\n    register_demo!(runner, demo_limbs_round_to_multiple_of_power_of_2);\n    register_demo!(\n        runner,\n        demo_limbs_round_to_multiple_of_power_of_2_down_in_place\n    );\n    register_demo!(\n        runner,\n        demo_limbs_round_to_multiple_of_power_of_2_up_in_place\n    );\n    register_demo!(\n        runner,\n        demo_limbs_round_to_multiple_of_power_of_2_nearest_in_place\n    );\n    register_demo!(runner, demo_limbs_round_to_multiple_of_power_of_2_in_place);\n    register_demo!(runner, demo_natural_round_to_multiple_of_power_of_2_assign);\n    register_demo!(runner, demo_natural_round_to_multiple_of_power_of_2);\n    register_demo!(runner, demo_natural_round_to_multiple_of_power_of_2_ref);\n\n    register_bench!(runner, benchmark_limbs_round_to_multiple_of_power_of_2_down);\n    register_bench!(runner, benchmark_limbs_round_to_multiple_of_power_of_2_up);\n    register_bench!(\n        runner,\n        benchmark_limbs_round_to_multiple_of_power_of_2_nearest\n    );\n    register_bench!(runner, benchmark_limbs_round_to_multiple_of_power_of_2);\n    register_bench!(\n        runner,\n        benchmark_limbs_round_to_multiple_of_power_of_2_down_in_place\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_round_to_multiple_of_power_of_2_up_in_place\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_round_to_multiple_of_power_of_2_nearest_in_place\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_round_to_multiple_of_power_of_2_in_place\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_round_to_multiple_of_power_of_2_assign\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_round_to_multiple_of_power_of_2_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_round_to_multiple_of_power_of_2_evaluation_strategy\n    );\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2_down(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_round_to_multiple_of_power_of_2_down({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_round_to_multiple_of_power_of_2_down(&xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2_up(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_round_to_multiple_of_power_of_2_up({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_round_to_multiple_of_power_of_2_up(&xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2_nearest(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_round_to_multiple_of_power_of_2_nearest({:?}, {}) = {:?}\",\n            xs,\n            pow,\n            limbs_round_to_multiple_of_power_of_2_nearest(&xs, pow)\n        );\n    }\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, pow, rm) in unsigned_vec_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_round_to_multiple_of_power_of_2({:?}, {}, {}) = {:?}\",\n            xs,\n            pow,\n            rm,\n            limbs_round_to_multiple_of_power_of_2(&xs, pow, rm)\n        );\n    }\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2_down_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let o = limbs_round_to_multiple_of_power_of_2_down_in_place(&mut xs, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_round_to_multiple_of_power_of_2_down_in_place(&mut xs, {pow}) = {o:?}; \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2_up_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, pow) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let o = limbs_round_to_multiple_of_power_of_2_up_in_place(&mut xs, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_round_to_multiple_of_power_of_2_up_in_place(&mut xs, {pow}) = {o:?}; \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2_nearest_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, pow) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let o = limbs_round_to_multiple_of_power_of_2_nearest_in_place(&mut xs, pow);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_round_to_multiple_of_power_of_2_nearest_in_place(&mut xs, {pow}) = {o:?}; \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_round_to_multiple_of_power_of_2_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, pow, rm) in unsigned_vec_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let oo = limbs_round_to_multiple_of_power_of_2_in_place(&mut xs, pow, rm);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_round_to_multiple_of_power_of_2_in_place(&mut xs, {pow}, {rm}) = {oo:?}; \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_natural_round_to_multiple_of_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow, rm) in natural_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.round_to_multiple_of_power_of_2_assign(pow, rm);\n        println!(\n            \"x := {n_old}; x.round_to_multiple_of_power_of_2_assign({pow}, {rm}) = {o:?}; x = {n}\"\n        );\n    }\n}\n\nfn demo_natural_round_to_multiple_of_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow, rm) in natural_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            n_old,\n            pow,\n            rm,\n            n.round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn demo_natural_round_to_multiple_of_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow, rm) in natural_unsigned_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            n,\n            pow,\n            rm,\n            (&n).round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2_down(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2_down(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, pow)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2_down(&xs, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2_up(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2_up(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, pow)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2_up(&xs, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2_nearest(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2_nearest(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, pow)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2_nearest(&xs, pow));\n        })],\n    );\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2(&[Limb], u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, pow, rm)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2(&xs, pow, rm));\n        })],\n    );\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2_down_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2_down_in_place(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pow)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2_down_in_place(\n                &mut xs, pow\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2_up_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2_up_in_place(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pow)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2_up_in_place(\n                &mut xs, pow\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2_nearest_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2_nearest_in_place(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pow)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2_nearest_in_place(\n                &mut xs, pow\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_round_to_multiple_of_power_of_2_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_round_to_multiple_of_power_of_2_in_place(&mut Vec<Limb>, u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, pow, rm)| {\n            no_out!(limbs_round_to_multiple_of_power_of_2_in_place(\n                &mut xs, pow, rm\n            ));\n        })],\n    );\n}\n\nfn benchmark_natural_round_to_multiple_of_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.round_to_multiple_of_power_of_2_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        natural_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.round_to_multiple_of_power_of_2_assign(y, rm));\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_round_to_multiple_of_power_of_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.round_to_multiple_of_power_of_2(y, rm));\n            }),\n            (\"using shr_round\", &mut |(x, y, rm)| {\n                no_out!(x.shr_round(y, rm).0 << y);\n            }),\n            (\"using round_to_multiple\", &mut |(x, y, rm)| {\n                no_out!(x.round_to_multiple(Natural::power_of_2(y), rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_round_to_multiple_of_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"Natural.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple_of_power_of_2(y, rm)),\n            ),\n            (\n                \"(&Natural).round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple_of_power_of_2(y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/saturating_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{SaturatingSub, SaturatingSubAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_saturating_sub);\n    register_demo!(runner, demo_natural_saturating_sub_val_ref);\n    register_demo!(runner, demo_natural_saturating_sub_ref_val);\n    register_demo!(runner, demo_natural_saturating_sub_ref_ref);\n    register_demo!(runner, demo_natural_saturating_sub_assign);\n    register_demo!(runner, demo_natural_saturating_sub_assign_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_saturating_sub_evaluation_strategy);\n}\n\nfn demo_natural_saturating_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.saturating_sub({}) = {:?}\",\n            x_old,\n            y_old,\n            x.saturating_sub(y)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{}.saturating_sub(&{}) = {:?}\",\n            x_old,\n            y,\n            x.saturating_sub(&y)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).saturating_sub({}) = {:?}\",\n            x,\n            y_old,\n            (&x).saturating_sub(y)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).saturating_sub(&{}) = {:?}\",\n            x,\n            y,\n            (&x).saturating_sub(&y)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.saturating_sub_assign(y);\n        println!(\"x := {x_old}; x.saturating_sub_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_saturating_sub_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.saturating_sub_assign(&y);\n        println!(\"x := {x_old}; x.saturating_sub_assign(&{y}); x = {x}\");\n    }\n}\n\nfn benchmark_natural_saturating_sub_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_assign(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_assign(Natural)\",\n                &mut |(mut x, y)| x.saturating_sub_assign(y),\n            ),\n            (\n                \"Natural.saturating_sub_assign(&Natural)\",\n                &mut |(mut x, y)| x.saturating_sub_assign(&y),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural.saturating_sub(Natural)\", &mut |(x, y)| {\n                no_out!(x.saturating_sub(y));\n            }),\n            (\"Natural.saturating_sub(&Natural)\", &mut |(x, y)| {\n                no_out!(x.saturating_sub(&y));\n            }),\n            (\"&Natural.saturating_sub(Natural)\", &mut |(x, y)| {\n                no_out!((&x).saturating_sub(y));\n            }),\n            (\"&Natural.saturating_sub(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).saturating_sub(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/saturating_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    SaturatingSub, SaturatingSubAssign, SaturatingSubMul, SaturatingSubMulAssign,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_triple_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_saturating_sub_mul);\n    register_demo!(runner, demo_natural_saturating_sub_mul_val_val_ref);\n    register_demo!(runner, demo_natural_saturating_sub_mul_val_ref_val);\n    register_demo!(runner, demo_natural_saturating_sub_mul_val_ref_ref);\n    register_demo!(runner, demo_natural_saturating_sub_mul_ref_ref_ref);\n    register_demo!(runner, demo_natural_saturating_sub_mul_assign);\n    register_demo!(runner, demo_natural_saturating_sub_mul_assign_val_ref);\n    register_demo!(runner, demo_natural_saturating_sub_mul_assign_ref_val);\n    register_demo!(runner, demo_natural_saturating_sub_mul_assign_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_saturating_sub_mul_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_val_val_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_val_ref_val_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_val_ref_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_ref_ref_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_assign_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_assign_val_ref_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_assign_ref_val_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_saturating_sub_mul_assign_ref_ref_algorithms\n    );\n}\n\nfn demo_natural_saturating_sub_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let z_old = z.clone();\n        println!(\n            \"{}.saturating_sub_mul({}, {}) = {}\",\n            x_old,\n            y_old,\n            z_old,\n            x.saturating_sub_mul(y, z)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_mul_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"{}.saturating_sub_mul({}, &({})) = {}\",\n            x_old,\n            y_old,\n            z,\n            x.saturating_sub_mul(y, &z)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_mul_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let z_old = z.clone();\n        println!(\n            \"{}.saturating_sub_mul(&({}), {}) = {}\",\n            x_old,\n            y,\n            z_old,\n            x.saturating_sub_mul(&y, z)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_mul_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\n            \"{}.saturating_sub_mul(&({}), &({})) = {}\",\n            x_old,\n            y,\n            z,\n            x.saturating_sub_mul(&y, &z)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_mul_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).saturating_sub_mul(&({}), &({})) = {}\",\n            x,\n            y,\n            z,\n            (&x).saturating_sub_mul(&y, &z)\n        );\n    }\n}\n\nfn demo_natural_saturating_sub_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let z_old = z.clone();\n        x.saturating_sub_mul_assign(y, z);\n        println!(\"x := {x_old}; x.saturating_sub_mul_assign({y_old}, {z_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_saturating_sub_mul_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.saturating_sub_mul_assign(y, &z);\n        println!(\"x := {x_old}; x.saturating_sub_mul_assign({y_old}, &({z})); x = {x}\");\n    }\n}\n\nfn demo_natural_saturating_sub_mul_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let z_old = z.clone();\n        x.saturating_sub_mul_assign(&y, z);\n        println!(\"x := {x_old}; x.saturating_sub_mul_assign(&({y}), {z_old}); x = {x}\");\n    }\n}\n\nfn demo_natural_saturating_sub_mul_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, z) in natural_triple_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.saturating_sub_mul_assign(&y, &z);\n        println!(\"x := {x_old}; x.saturating_sub_mul_assign(&({y}), &({z})); x = {x}\");\n    }\n}\n\nfn benchmark_natural_saturating_sub_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul(Natural, Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(b, c)),\n            ),\n            (\n                \"Natural.saturating_sub_mul(Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(b, &c)),\n            ),\n            (\n                \"Natural.saturating_sub_mul(&Natural, Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(&b, c)),\n            ),\n            (\n                \"Natural.saturating_sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(&b, &c)),\n            ),\n            (\n                \"(&Natural).saturating_sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).saturating_sub_mul(&b, &c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul(Natural, Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(b, c)),\n            ),\n            (\n                \"Natural.saturating_sub(Natural * Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub(b * c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_val_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul(Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul(Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(b, &c)),\n            ),\n            (\n                \"Natural.saturating_sub(Natural * &Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub(b * &c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_val_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul(&Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul(&Natural, Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(&b, c)),\n            ),\n            (\n                \"Natural.saturating_sub(&Natural * Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub(&b * c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_val_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub_mul(&b, &c)),\n            ),\n            (\n                \"Natural.saturating_sub(Natural * Natural)\",\n                &mut |(a, b, c)| no_out!(a.saturating_sub(&b * &c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_ref_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"(&Natural).saturating_sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).saturating_sub_mul(&b, &c)),\n            ),\n            (\n                \"(&Natural).saturating_sub(Natural * Natural)\",\n                &mut |(a, b, c)| no_out!((&a).saturating_sub(&b * &c)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul_assign(Natural, Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(b, c),\n            ),\n            (\n                \"Natural.saturating_sub_mul_assign(Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(b, &c),\n            ),\n            (\n                \"Natural.saturating_sub_mul_assign(&Natural, Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(&b, c),\n            ),\n            (\n                \"Natural.saturating_sub_mul_assign(&Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(&b, &c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_assign_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul_assign(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul_assign(Natural, Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(b, c),\n            ),\n            (\n                \"Natural.saturating_sub_assign(Natural * Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_assign(b * c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_assign_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul_assign(Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul_assign(Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(b, &c),\n            ),\n            (\n                \"Natural.saturating_sub_assign(Natural * &Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_assign(b * &c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_assign_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul_assign(&Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul_assign(&Natural, Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(&b, c),\n            ),\n            (\n                \"Natural.saturating_sub_assign(&Natural * Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_assign(&b * c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_saturating_sub_mul_assign_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.saturating_sub_mul_assign(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"x\", \"y\", \"z\"),\n        &mut [\n            (\n                \"Natural.saturating_sub_mul_assign(&Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_mul_assign(&b, &c),\n            ),\n            (\n                \"Natural.saturating_sub_assign(&Natural * &Natural)\",\n                &mut |(mut a, b, c)| a.saturating_sub_assign(&b * &c),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_16, unsigned_vec_unsigned_pair_gen_var_32,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::shl::{\n    limbs_shl, limbs_shl_to_out, limbs_shl_with_complement_to_out, limbs_slice_shl_in_place,\n    limbs_vec_shl_in_place,\n};\nuse malachite_nz::natural::logic::not::limbs_not_in_place;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_natural_bit_bucketer, pair_2_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_signed_pair_gen_var_2, natural_signed_pair_gen_var_2_rm,\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_4_rm,\n};\nuse std::ops::{Shl, ShlAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_shl);\n    register_demo!(runner, demo_limbs_shl_to_out);\n    register_demo!(runner, demo_limbs_slice_shl_in_place);\n    register_demo!(runner, demo_limbs_vec_shl_in_place);\n    register_demo!(runner, demo_limbs_shl_with_complement_to_out);\n    register_unsigned_demos!(runner, demo_natural_shl_assign_unsigned);\n    register_unsigned_demos!(runner, demo_natural_shl_unsigned);\n    register_unsigned_demos!(runner, demo_natural_shl_unsigned_ref);\n    register_signed_demos!(runner, demo_natural_shl_assign_signed);\n    register_signed_demos!(runner, demo_natural_shl_signed);\n    register_signed_demos!(runner, demo_natural_shl_signed_ref);\n\n    register_bench!(runner, benchmark_limbs_shl);\n    register_bench!(runner, benchmark_limbs_shl_to_out);\n    register_bench!(runner, benchmark_limbs_slice_shl_in_place);\n    register_bench!(runner, benchmark_limbs_vec_shl_in_place);\n    register_bench!(\n        runner,\n        benchmark_limbs_shl_with_complement_to_out_algorithms\n    );\n    register_bench!(runner, benchmark_natural_shl_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_natural_shl_u32_library_comparison);\n    register_bench!(runner, benchmark_natural_shl_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_natural_shl_i32_library_comparison);\n    register_unsigned_benches!(runner, benchmark_natural_shl_assign_unsigned);\n    register_unsigned_benches!(runner, benchmark_natural_shl_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_natural_shl_assign_signed);\n    register_signed_benches!(runner, benchmark_natural_shl_signed_evaluation_strategy);\n}\n\nfn demo_limbs_shl(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, bits) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"limbs_shl({:?}, {}) = {:?}\", xs, bits, limbs_shl(&xs, bits));\n    }\n}\n\nfn demo_limbs_shl_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, bits) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22::<Limb, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let carry = limbs_shl_to_out(&mut out, &xs, bits);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_shl_to_out(&mut out, {xs:?}, {bits}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_shl_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits) in unsigned_vec_unsigned_pair_gen_var_32::<Limb, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_shl_in_place(&mut xs, bits);\n        println!(\n            \"xs := {xs_old:?}; limbs_slice_shl_in_place(&mut xs, {bits}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_shl_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits) in unsigned_vec_unsigned_pair_gen_var_16::<Limb, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_shl_in_place(&mut xs, bits);\n        println!(\"xs := {xs_old:?}; limbs_vec_shl_in_place(&mut xs, {bits}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_shl_with_complement_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, bits) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<Limb, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let carry = limbs_shl_with_complement_to_out(&mut out, &xs, bits);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_shl_with_complement_to_out(&mut out, {xs:?}, {bits}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_natural_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ShlAssign<T>,\n{\n    for (mut n, u) in natural_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= u;\n        println!(\"x := {n_old}; x <<= {u}; x = {n}\");\n    }\n}\n\nfn demo_natural_shl_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    for (n, u) in natural_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, u, n << u);\n    }\n}\n\nfn demo_natural_shl_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    for (n, u) in natural_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, u, &n << u);\n    }\n}\n\nfn demo_natural_shl_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ShlAssign<T>,\n{\n    for (mut n, i) in natural_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= i;\n        println!(\"x := {n_old}; x <<= {i}; x = {n}\");\n    }\n}\n\nfn demo_natural_shl_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    for (n, i) in natural_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, i, n << i);\n    }\n}\n\nfn demo_natural_shl_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    for (n, i) in natural_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, i, &n << i);\n    }\n}\n\nfn benchmark_limbs_shl(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_shl(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, bits)| no_out!(limbs_shl(&xs, bits)))],\n    );\n}\n\nfn benchmark_limbs_shl_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_shl_to_out(&mut [Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22::<Limb, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, bits)| {\n            no_out!(limbs_shl_to_out(&mut out, &xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_shl_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_shl_in_place(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_32::<Limb, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits)| {\n            no_out!(limbs_slice_shl_in_place(&mut xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_shl_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_shl_in_place(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16::<Limb, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits)| {\n            limbs_vec_shl_in_place(&mut xs, bits);\n        })],\n    );\n}\n\nfn benchmark_limbs_shl_with_complement_to_out_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_shl_with_complement_to_out(&mut [Limb], &[Limb], u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<Limb, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut out, xs, bits)| {\n                no_out!(limbs_shl_with_complement_to_out(&mut out, &xs, bits));\n            }),\n            (\n                \"limbs_shl_to_out and limbs_not_in_place\",\n                &mut |(mut out, xs, bits)| {\n                    limbs_shl_to_out(&mut out, &xs, bits);\n                    limbs_not_in_place(&mut out);\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_shl_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural <<= u32\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_shl_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural << u32\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n\nfn benchmark_natural_shl_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural <<= u32\",\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_shl_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural << i32\",\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n\nfn benchmark_natural_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x <<= y))],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_shl_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shl<T, Output = Natural>,\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Natural << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Natural << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x <<= y))],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_shl_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shl<T, Output = Natural>,\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Natural << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Natural << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShlRound, ShlRoundAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::triple_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_signed_rounding_mode_triple_gen_var_1;\nuse std::ops::Shr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_signed_demos!(runner, demo_natural_shl_round_assign);\n    register_signed_demos!(runner, demo_natural_shl_round);\n    register_signed_demos!(runner, demo_natural_shl_round_ref);\n\n    register_signed_benches!(runner, benchmark_natural_shl_round_assign);\n    register_signed_benches!(runner, benchmark_natural_shl_round_evaluation_strategy);\n}\n\nfn demo_natural_shl_round_assign<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ShlRoundAssign<T> + Shr<T, Output = Natural>,\n{\n    for (mut n, i, rm) in natural_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shl_round_assign(i, rm);\n        println!(\"x := {n_old}; x.shl_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_natural_shl_round<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ShlRound<T, Output = Natural> + Shr<T, Output = Natural>,\n{\n    for (n, i, rm) in natural_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shl_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shl_round(i, rm)\n        );\n    }\n}\n\nfn demo_natural_shl_round_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Shr<T, Output = Natural>,\n    for<'a> &'a Natural: ShlRound<T, Output = Natural>,\n{\n    for (n, i, rm) in natural_signed_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shl_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            (&n).shl_round(i, rm)\n        );\n    }\n}\n\nfn benchmark_natural_shl_round_assign<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ShlRoundAssign<T> + Shr<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.shl_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.shl_round_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_natural_shl_round_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ShlRound<T, Output = Natural> + Shr<T, Output = Natural>,\n    for<'a> &'a Natural: ShlRound<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.shl_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Natural.shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!(x.shl_round(y, rm)),\n            ),\n            (\n                &format!(\"(&Natural).shl_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!((&x).shl_round(y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_16, unsigned_vec_unsigned_pair_gen_var_33,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::shr::{\n    limbs_shr, limbs_shr_to_out, limbs_slice_shr_in_place, limbs_vec_shr_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_natural_bit_bucketer, pair_2_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_signed_pair_gen_var_2, natural_signed_pair_gen_var_2_rm,\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_4_rm,\n};\nuse std::ops::{Shr, ShrAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_shr);\n    register_demo!(runner, demo_limbs_shr_to_out);\n    register_demo!(runner, demo_limbs_slice_shr_in_place);\n    register_demo!(runner, demo_limbs_vec_shr_in_place);\n    register_unsigned_demos!(runner, demo_natural_shr_assign_unsigned);\n    register_unsigned_demos!(runner, demo_natural_shr_unsigned);\n    register_unsigned_demos!(runner, demo_natural_shr_unsigned_ref);\n    register_signed_demos!(runner, demo_natural_shr_assign_signed);\n    register_signed_demos!(runner, demo_natural_shr_signed);\n    register_signed_demos!(runner, demo_natural_shr_signed_ref);\n\n    register_bench!(runner, benchmark_limbs_shr);\n    register_bench!(runner, benchmark_limbs_shr_to_out);\n    register_bench!(runner, benchmark_limbs_slice_shr_in_place);\n    register_bench!(runner, benchmark_limbs_vec_shr_in_place);\n    register_bench!(runner, benchmark_natural_shr_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_natural_shr_u32_library_comparison);\n    register_bench!(runner, benchmark_natural_shr_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_natural_shr_i32_library_comparison);\n    register_unsigned_benches!(runner, benchmark_natural_shr_assign_unsigned);\n    register_unsigned_benches!(runner, benchmark_natural_shr_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_natural_shr_assign_signed);\n    register_signed_benches!(runner, benchmark_natural_shr_signed_evaluation_strategy);\n}\n\nfn demo_limbs_shr(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, bits) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"limbs_shr({:?}, {}) = {:?}\", xs, bits, limbs_shr(&xs, bits));\n    }\n}\n\nfn demo_limbs_shr_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (out, xs, bits) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<Limb, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let mut out = out.to_vec();\n        let out_old = out.clone();\n        let carry = limbs_shr_to_out(&mut out, &xs, bits);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_shr_to_out(&mut out, {xs:?}, {bits}) = {carry}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_shr_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits) in unsigned_vec_unsigned_pair_gen_var_33::<Limb, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let carry = limbs_slice_shr_in_place(&mut xs, bits);\n        println!(\n            \"xs := {xs_old:?}; limbs_slice_shr_in_place(&mut xs, {bits}) = {carry}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_shr_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_vec_shr_in_place(&mut xs, bits);\n        println!(\"xs := {xs_old:?}; limbs_vec_shr_in_place(&mut xs, {bits}); xs = {xs:?}\");\n    }\n}\n\nfn demo_natural_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ShrAssign<T>,\n{\n    for (mut n, u) in natural_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= u;\n        println!(\"x := {n_old}; x >>= {u}; x = {n}\");\n    }\n}\n\nfn demo_natural_shr_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Shr<T, Output = Natural>,\n{\n    for (n, u) in natural_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, u, n >> u);\n    }\n}\n\nfn demo_natural_shr_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    for (n, u) in natural_unsigned_pair_gen_var_4::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, u, &n >> u);\n    }\n}\n\nfn demo_natural_shr_assign_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ShrAssign<T>,\n{\n    for (mut n, u) in natural_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= u;\n        println!(\"x := {n_old}; x >>= {u}; x = {n}\");\n    }\n}\n\nfn demo_natural_shr_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Shr<T, Output = Natural>,\n{\n    for (n, u) in natural_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, u, n >> u);\n    }\n}\n\nfn demo_natural_shr_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    for (n, u) in natural_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, u, &n >> u);\n    }\n}\n\nfn benchmark_limbs_shr(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_shr(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, bits)| no_out!(limbs_shr(&xs, bits)))],\n    );\n}\n\nfn benchmark_limbs_shr_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_shr_to_out(&mut [Limb], &[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<Limb, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, bits)| {\n            no_out!(limbs_shr_to_out(&mut out, &xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_shr_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_shr_in_place(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_33::<Limb, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits)| {\n            no_out!(limbs_slice_shr_in_place(&mut xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_shr_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_shr_in_place(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16::<Limb, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits)| {\n            limbs_vec_shr_in_place(&mut xs, bits);\n        })],\n    );\n}\n\nfn benchmark_natural_shr_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural >>= u32\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_shr_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural >> u32\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n\nfn benchmark_natural_shr_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural >>= u32\",\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_shr_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural >> i32\",\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_var_2_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n\nfn benchmark_natural_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x >>= y))],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_shr_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shr<T, Output = Natural>,\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Natural >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Natural >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_shr_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| no_out!(x >>= y))],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_shr_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shr<T, Output = Natural>,\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Natural >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Natural >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShrRound, ShrRoundAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, triple_1_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_16, unsigned_vec_unsigned_pair_gen_var_20,\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::shr_round::{\n    limbs_shr_exact, limbs_shr_round, limbs_shr_round_nearest, limbs_shr_round_up,\n    limbs_vec_shr_exact_in_place, limbs_vec_shr_round_in_place,\n    limbs_vec_shr_round_nearest_in_place, limbs_vec_shr_round_up_in_place,\n};\nuse malachite_nz::test_util::bench::bucketers::triple_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    natural_signed_rounding_mode_triple_gen_var_2, natural_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse std::ops::Shl;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_shr_round_up);\n    register_demo!(runner, demo_limbs_shr_round_nearest);\n    register_demo!(runner, demo_limbs_shr_exact);\n    register_demo!(runner, demo_limbs_shr_round);\n    register_demo!(runner, demo_limbs_vec_shr_round_up_in_place);\n    register_demo!(runner, demo_limbs_vec_shr_round_nearest_in_place);\n    register_demo!(runner, demo_limbs_vec_shr_exact_in_place);\n    register_demo!(runner, demo_limbs_vec_shr_round_in_place);\n    register_unsigned_demos!(runner, demo_natural_shr_round_assign_unsigned);\n    register_unsigned_demos!(runner, demo_natural_shr_round_unsigned);\n    register_unsigned_demos!(runner, demo_natural_shr_round_unsigned_ref);\n    register_signed_demos!(runner, demo_natural_shr_round_assign_signed);\n    register_signed_demos!(runner, demo_natural_shr_round_signed);\n    register_signed_demos!(runner, demo_natural_shr_round_signed_ref);\n\n    register_bench!(runner, benchmark_limbs_shr_round_up);\n    register_bench!(runner, benchmark_limbs_shr_round_nearest);\n    register_bench!(runner, benchmark_limbs_shr_exact);\n    register_bench!(runner, benchmark_limbs_shr_round);\n    register_bench!(runner, benchmark_limbs_vec_shr_round_up_in_place);\n    register_bench!(runner, benchmark_limbs_vec_shr_round_nearest_in_place);\n    register_bench!(runner, benchmark_limbs_vec_shr_exact_in_place);\n    register_bench!(runner, benchmark_limbs_vec_shr_round_in_place);\n    register_unsigned_benches!(runner, benchmark_natural_shr_round_assign_unsigned);\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_shr_round_unsigned_evaluation_strategy\n    );\n    register_signed_benches!(runner, benchmark_natural_shr_round_assign_signed);\n    register_signed_benches!(\n        runner,\n        benchmark_natural_shr_round_signed_evaluation_strategy\n    );\n}\n\nfn demo_limbs_shr_round_up(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, bits) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_shr_round_up({:?}, {}) = {:?}\",\n            xs,\n            bits,\n            limbs_shr_round_up(&xs, bits)\n        );\n    }\n}\n\nfn demo_limbs_shr_round_nearest(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, bits) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_shr_round_nearest({:?}, {}) = {:?}\",\n            xs,\n            bits,\n            limbs_shr_round_nearest(&xs, bits)\n        );\n    }\n}\n\nfn demo_limbs_shr_exact(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, bits) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_shr_exact({:?}, {}) = {:?}\",\n            xs,\n            bits,\n            limbs_shr_exact(&xs, bits)\n        );\n    }\n}\n\nfn demo_limbs_shr_round(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, bits, rm) in unsigned_vec_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_shr_round({:?}, {}, {}) = {:?}\",\n            xs,\n            bits,\n            rm,\n            limbs_shr_round(&xs, bits, rm)\n        );\n    }\n}\n\nfn demo_limbs_vec_shr_round_up_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let o = limbs_vec_shr_round_up_in_place(&mut xs, bits);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_vec_shr_round_up_in_place(&mut xs, {bits}) = {o:?}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_shr_round_nearest_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let o = limbs_vec_shr_round_nearest_in_place(&mut xs, bits);\n        println!(\n            \"limbs := {xs_old:?}; \\\n            limbs_vec_shr_round_nearest_in_place(&mut limbs, {bits}) = {o:?}; limbs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_shr_exact_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits) in unsigned_vec_unsigned_pair_gen_var_20()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let result = limbs_vec_shr_exact_in_place(&mut xs, bits);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_vec_shr_exact_in_place(&mut xs, {bits}) = {result}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_shr_round_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, bits, rm) in unsigned_vec_unsigned_rounding_mode_triple_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let result = limbs_vec_shr_round_in_place(&mut xs, bits, rm);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_vec_shr_round_in_place(&mut xs, {bits}, {rm}) = {result:?}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_natural_shr_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: Shl<T, Output = Natural> + ShrRoundAssign<T>,\n{\n    for (mut n, u, rm) in natural_unsigned_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(u, rm);\n        println!(\"x := {n_old}; x.shr_round_assign({u}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_natural_shr_round_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: Shl<T, Output = Natural> + ShrRound<T, Output = Natural>,\n{\n    for (n, u, rm) in natural_unsigned_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            u,\n            rm,\n            n.shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_natural_shr_round_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: Shl<T, Output = Natural>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n{\n    for (n, u, rm) in natural_unsigned_rounding_mode_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shr_round({}, {}) = {:?}\",\n            n,\n            u,\n            rm,\n            (&n).shr_round(u, rm)\n        );\n    }\n}\n\nfn demo_natural_shr_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: Shl<T, Output = Natural> + ShrRoundAssign<T>,\n{\n    for (mut n, i, rm) in natural_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.shr_round_assign(i, rm);\n        println!(\"x := {n_old}; x.shr_round_assign({i}, {rm}) = {o:?}; x = {n}\");\n    }\n}\n\nfn demo_natural_shr_round_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Shl<T, Output = Natural> + ShrRound<T, Output = Natural>,\n{\n    for (n, i, rm) in natural_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"{}.shr_round({}, {}) = {:?}\",\n            n_old,\n            i,\n            rm,\n            n.shr_round(i, rm)\n        );\n    }\n}\n\nfn demo_natural_shr_round_signed_ref<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: Shl<T, Output = Natural>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n{\n    for (n, i, rm) in natural_signed_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).shr_round({}, {}) = {:?}\",\n            n,\n            i,\n            rm,\n            (&n).shr_round(i, rm)\n        );\n    }\n}\n\nfn benchmark_limbs_shr_round_up(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_shr_round_up(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, bits)| {\n            no_out!(limbs_shr_round_up(&xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_shr_round_nearest(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_shr_round_nearest(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, bits)| {\n            no_out!(limbs_shr_round_nearest(&xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_shr_exact(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_shr_exact(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, bits)| {\n            no_out!(limbs_shr_exact(&xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_shr_round(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_shr_round(&[Limb], u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, bits, rm)| {\n            no_out!(limbs_shr_round(&xs, bits, rm));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_shr_round_up_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_shr_round_up_in_place(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits)| {\n            no_out!(limbs_vec_shr_round_up_in_place(&mut xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_shr_round_nearest_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_shr_round_nearest_in_place(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits)| {\n            no_out!(limbs_vec_shr_round_nearest_in_place(&mut xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_shr_exact_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_shr_exact_in_place(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_20().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits)| {\n            no_out!(limbs_vec_shr_exact_in_place(&mut xs, bits));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_shr_round_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_shr_round_in_place(&mut Vec<Limb>, u64, RoundingMode)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, bits, rm)| {\n            no_out!(limbs_vec_shr_round_in_place(&mut xs, bits, rm));\n        })],\n    );\n}\n\nfn benchmark_natural_shr_round_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shl<T, Output = Natural> + ShrRoundAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.shr_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.shr_round_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_natural_shr_round_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shl<T, Output = Natural> + ShrRound<T, Output = Natural>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_rounding_mode_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Natural.shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!(x.shr_round(y, rm)),\n            ),\n            (\n                &format!(\"(&Natural).shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!((&x).shr_round(y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_shr_round_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shl<T, Output = Natural> + ShrRoundAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.shr_round_assign({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.shr_round_assign(y, rm));\n        })],\n    );\n}\n\nfn benchmark_natural_shr_round_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Shl<T, Output = Natural> + ShrRound<T, Output = Natural>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural.shr_round({}, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        natural_signed_rounding_mode_triple_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"Natural.shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!(x.shr_round(y, rm)),\n            ),\n            (\n                &format!(\"(&Natural).shr_round({}, RoundingMode)\", T::NAME),\n                &mut |(x, y, rm)| no_out!((&x).shr_round(y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_2_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_rm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_sign);\n    register_bench!(runner, benchmark_natural_sign_library_comparison);\n}\n\nfn demo_natural_sign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        match n.sign() {\n            Less => println!(\"{n} is negative\"),\n            Equal => println!(\"{n} is zero\"),\n            Greater => println!(\"{n} is positive\"),\n        }\n    }\n}\n\nfn benchmark_natural_sign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sign()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(n.sign())),\n            (\"rug\", &mut |(n, _)| no_out!(n.cmp0())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::sqrt::sqrt_rem_2_newton;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingSqrt, CeilingSqrtAssign, CheckedSqrt, FloorSqrt, FloorSqrtAssign, SqrtAssignRem,\n    SqrtRem, Square,\n};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_2_vec_len_bucketer, pair_max_bit_bucketer, quadruple_2_vec_len_bucketer,\n    triple_3_vec_len_bucketer, vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    large_type_gen_var_2, unsigned_pair_gen_var_31, unsigned_vec_gen_var_1,\n    unsigned_vec_pair_gen_var_4, unsigned_vec_pair_gen_var_5, unsigned_vec_triple_gen_var_28,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::sqrt::{\n    limbs_ceiling_sqrt, limbs_checked_sqrt, limbs_floor_sqrt, limbs_sqrt_helper, limbs_sqrt_rem,\n    limbs_sqrt_rem_helper, limbs_sqrt_rem_helper_scratch_len, limbs_sqrt_rem_to_out,\n    limbs_sqrt_to_out,\n};\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_2_natural_bit_bucketer, triple_3_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_nrm, natural_gen_rm};\nuse malachite_nz::test_util::natural::arithmetic::sqrt::{\n    ceiling_sqrt_binary, checked_sqrt_binary, floor_sqrt_binary, sqrt_rem_binary,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_sqrt_rem_2_newton);\n    register_demo!(runner, demo_limbs_sqrt_rem_helper);\n    register_demo!(runner, demo_limbs_sqrt_helper);\n    register_demo!(runner, demo_limbs_sqrt_to_out);\n    register_demo!(runner, demo_limbs_sqrt_rem_to_out);\n    register_demo!(runner, demo_limbs_floor_sqrt);\n    register_demo!(runner, demo_limbs_ceiling_sqrt);\n    register_demo!(runner, demo_limbs_checked_sqrt);\n    register_demo!(runner, demo_limbs_sqrt_rem);\n    register_demo!(runner, demo_natural_floor_sqrt);\n    register_demo!(runner, demo_natural_floor_sqrt_ref);\n    register_demo!(runner, demo_natural_floor_sqrt_assign);\n    register_demo!(runner, demo_natural_ceiling_sqrt);\n    register_demo!(runner, demo_natural_ceiling_sqrt_ref);\n    register_demo!(runner, demo_natural_ceiling_sqrt_assign);\n    register_demo!(runner, demo_natural_checked_sqrt);\n    register_demo!(runner, demo_natural_checked_sqrt_ref);\n    register_demo!(runner, demo_natural_sqrt_rem);\n    register_demo!(runner, demo_natural_sqrt_rem_ref);\n    register_demo!(runner, demo_natural_sqrt_assign_rem);\n    register_bench!(runner, benchmark_sqrt_rem_2_newton);\n    register_bench!(runner, benchmark_limbs_sqrt_rem_helper);\n    register_bench!(runner, benchmark_limbs_sqrt_helper);\n    register_bench!(runner, benchmark_limbs_sqrt_to_out);\n    register_bench!(runner, benchmark_limbs_sqrt_rem_to_out);\n    register_bench!(runner, benchmark_limbs_floor_sqrt);\n    register_bench!(runner, benchmark_limbs_ceiling_sqrt);\n    register_bench!(runner, benchmark_limbs_checked_sqrt);\n    register_bench!(runner, benchmark_limbs_sqrt_rem);\n    register_bench!(runner, benchmark_natural_floor_sqrt_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_floor_sqrt_algorithms);\n    register_bench!(runner, benchmark_natural_floor_sqrt_library_comparison);\n    register_bench!(runner, benchmark_natural_floor_sqrt_assign);\n    register_bench!(runner, benchmark_natural_ceiling_sqrt_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_ceiling_sqrt_algorithms);\n    register_bench!(runner, benchmark_natural_ceiling_sqrt_assign);\n    register_bench!(runner, benchmark_natural_checked_sqrt_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_checked_sqrt_algorithms);\n    register_bench!(runner, benchmark_natural_sqrt_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_sqrt_rem_algorithms);\n    register_bench!(runner, benchmark_natural_sqrt_rem_library_comparison);\n    register_bench!(runner, benchmark_natural_sqrt_assign_rem);\n}\n\nfn demo_sqrt_rem_2_newton(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (h_hi, h_lo) in unsigned_pair_gen_var_31::<Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sqrt_rem_2_newton({}, {}) = {:?}\",\n            h_hi,\n            h_lo,\n            sqrt_rem_2_newton::<Limb, SignedLimb>(h_hi, h_lo)\n        );\n    }\n}\n\nfn demo_limbs_sqrt_rem_helper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, mut xs) in unsigned_vec_pair_gen_var_4().get(gm, config).take(limit) {\n        let mut scratch = vec![0; limbs_sqrt_rem_helper_scratch_len(out.len())];\n        let old_out = out.clone();\n        let old_xs = xs.clone();\n        let r_hi = limbs_sqrt_rem_helper(&mut out, &mut xs, 0, &mut scratch);\n        println!(\n            \"out := {old_out:?}, xs := {old_xs:?}; \\\n            limbs_sqrt_rem_helper(&mut out, &mut xs, 0, &mut scratch) = {r_hi}; \\\n            out = {out:?}, xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sqrt_helper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, shift, odd) in large_type_gen_var_2().get(gm, config).take(limit) {\n        let old_out = out.clone();\n        let r = limbs_sqrt_helper(&mut out, &xs, shift, odd);\n        println!(\n            \"out := {old_out:?}, \\\n            limbs_sqrt_helper(&mut out, {xs:?}, {shift}, {odd}) = {r}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sqrt_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs) in unsigned_vec_pair_gen_var_5().get(gm, config).take(limit) {\n        let old_out = out.clone();\n        limbs_sqrt_to_out(&mut out, &xs);\n        println!(\"out := {old_out:?}, limbs_sqrt_to_out(&mut out, {xs:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_sqrt_rem_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut sqrt_out, mut rem_out, xs) in\n        unsigned_vec_triple_gen_var_28().get(gm, config).take(limit)\n    {\n        let old_sqrt_out = sqrt_out.clone();\n        let old_rem_out = rem_out.clone();\n        let r = limbs_sqrt_rem_to_out(&mut sqrt_out, &mut rem_out, &xs);\n        println!(\n            \"out := {old_sqrt_out:?}, rem_out := {old_rem_out:?}; \\\n            limbs_sqrt_rem_to_out(&mut sqrt_out, &mut rem_out, {xs:?}) = {r}; \\\n            sqrt_out = {sqrt_out:?}, rem_out = {rem_out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_floor_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\"limbs_floor_sqrt({:?}) = {:?}\", xs, limbs_floor_sqrt(&xs));\n    }\n}\n\nfn demo_limbs_ceiling_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_ceiling_sqrt({:?}) = {:?}\",\n            xs,\n            limbs_ceiling_sqrt(&xs)\n        );\n    }\n}\n\nfn demo_limbs_checked_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"limbs_checked_sqrt({:?}) = {:?}\",\n            xs,\n            limbs_checked_sqrt(&xs)\n        );\n    }\n}\n\nfn demo_limbs_sqrt_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1().get(gm, config).take(limit) {\n        println!(\"limbs_sqrt_rem({:?}) = {:?}\", xs, limbs_sqrt_rem(&xs));\n    }\n}\n\nfn demo_natural_floor_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.floor_sqrt() = {}\", x, x.clone().floor_sqrt());\n    }\n}\n\nfn demo_natural_floor_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).floor_sqrt() = {}\", x, (&x).floor_sqrt());\n    }\n}\n\nfn demo_natural_floor_sqrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in natural_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.floor_sqrt_assign();\n        println!(\"x := {old_x}; x.floor_sqrt_assign(); x = {x}\");\n    }\n}\n\nfn demo_natural_ceiling_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.ceiling_sqrt() = {}\", x, x.clone().ceiling_sqrt());\n    }\n}\n\nfn demo_natural_ceiling_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).ceiling_sqrt() = {}\", x, (&x).ceiling_sqrt());\n    }\n}\n\nfn demo_natural_ceiling_sqrt_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in natural_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.ceiling_sqrt_assign();\n        println!(\"x := {old_x}; x.ceiling_sqrt_assign(); x = {x}\");\n    }\n}\n\nfn demo_natural_checked_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.checked_sqrt() = {:?}\", x, x.clone().checked_sqrt());\n    }\n}\n\nfn demo_natural_checked_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_sqrt() = {:?}\", x, (&x).checked_sqrt());\n    }\n}\n\nfn demo_natural_sqrt_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.sqrt_rem() = {:?}\", x, x.clone().sqrt_rem());\n    }\n}\n\nfn demo_natural_sqrt_rem_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).sqrt_rem() = {:?}\", x, (&x).sqrt_rem());\n    }\n}\n\nfn demo_natural_sqrt_assign_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in natural_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        let rem = x.sqrt_assign_rem();\n        println!(\"x := {old_x}; x.sqrt_assign_rem() = {rem}; x = {x}\");\n    }\n}\n\nfn benchmark_sqrt_rem_2_newton(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"sqrt_rem_2_newton(Limb, Limb)\",\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_31::<Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"n_hi\", \"n_lo\"),\n        &mut [(\"sqrt_rem_2_newton(Limb, Limb)\", &mut |(n_hi, n_lo)| {\n            no_out!(sqrt_rem_2_newton::<Limb, SignedLimb>(n_hi, n_lo));\n        })],\n    );\n}\n\nfn benchmark_limbs_sqrt_rem_helper(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sqrt_rem_helper(&mut [Limb], &mut [Limb], Limb, &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [(\n            \"limbs_sqrt_rem_helper(&mut [Limb], &mut [Limb], Limb, &mut [Limb])\",\n            &mut |(mut out, mut xs)| {\n                let mut scratch = vec![0; limbs_sqrt_rem_helper_scratch_len(out.len())];\n                limbs_sqrt_rem_helper(&mut out, &mut xs, 0, &mut scratch);\n            },\n        )],\n    );\n}\n\nfn benchmark_limbs_sqrt_helper(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sqrt_helper(&mut [Limb], &[Limb], u64, bool)\",\n        BenchmarkType::Single,\n        large_type_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\n            \"limbs_sqrt_helper(&mut [Limb], &[Limb], u64, bool)\",\n            &mut |(mut out, xs, shift, odd)| no_out!(limbs_sqrt_helper(&mut out, &xs, shift, odd)),\n        )],\n    );\n}\n\nfn benchmark_limbs_sqrt_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sqrt_to_out(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"limbs_sqrt_to_out(&mut [Limb], &[Limb])\", &mut |(\n            mut out,\n            xs,\n        )| {\n            limbs_sqrt_to_out(&mut out, &xs);\n        })],\n    );\n}\n\nfn benchmark_limbs_sqrt_rem_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sqrt_rem_to_out(&mut [Limb], &mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_28().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_len_bucketer(\"xs\"),\n        &mut [(\n            \"limbs_sqrt_rem_to_out(&mut [Limb], &mut [Limb], &[Limb])\",\n            &mut |(mut sqrt_out, mut rem_out, xs)| {\n                no_out!(limbs_sqrt_rem_to_out(&mut sqrt_out, &mut rem_out, &xs));\n            },\n        )],\n    );\n}\n\nfn benchmark_limbs_floor_sqrt(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_floor_sqrt(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"limbs_floor_sqrt(&[Limb])\", &mut |xs| {\n            no_out!(limbs_floor_sqrt(&xs));\n        })],\n    );\n}\n\nfn benchmark_limbs_ceiling_sqrt(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_floor_sqrt(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"limbs_ceiling_sqrt(&[Limb])\", &mut |xs| {\n            no_out!(limbs_ceiling_sqrt(&xs));\n        })],\n    );\n}\n\nfn benchmark_limbs_checked_sqrt(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_checked_sqrt(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"limbs_checked_sqrt(&[Limb])\", &mut |xs| {\n            no_out!(limbs_checked_sqrt(&xs));\n        })],\n    );\n}\n\nfn benchmark_limbs_sqrt_rem(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sqrt_rem(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"limbs_sqrt_rem(&[Limb])\", &mut |xs| {\n            no_out!(limbs_sqrt_rem(&xs));\n        })],\n    );\n}\n\nfn benchmark_natural_floor_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.floor_sqrt()\", &mut |x| no_out!(x.floor_sqrt())),\n            (\"(&Natural).floor_sqrt()\", &mut |x| {\n                no_out!((&x).floor_sqrt());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_floor_sqrt_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_sqrt()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.floor_sqrt())),\n            (\"binary\", &mut |x| no_out!(floor_sqrt_binary(&x))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_floor_sqrt_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_sqrt()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"num\", &mut |(x, _, _)| no_out!(x.sqrt())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.sqrt())),\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.floor_sqrt())),\n        ],\n    );\n}\n\nfn benchmark_natural_floor_sqrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.floor_sqrt_assign()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.floor_sqrt_assign())],\n    );\n}\n\nfn benchmark_natural_ceiling_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.ceiling_sqrt()\", &mut |x| no_out!(x.ceiling_sqrt())),\n            (\"(&Natural).ceiling_sqrt()\", &mut |x| {\n                no_out!((&x).ceiling_sqrt());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_sqrt_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_sqrt()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.ceiling_sqrt())),\n            (\"binary\", &mut |x| no_out!(ceiling_sqrt_binary(&x))),\n        ],\n    );\n}\n\nfn benchmark_natural_ceiling_sqrt_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ceiling_sqrt_assign()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.ceiling_sqrt_assign())],\n    );\n}\n\nfn benchmark_natural_checked_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.checked_sqrt()\", &mut |x| no_out!(x.checked_sqrt())),\n            (\"(&Natural).checked_sqrt()\", &mut |x| {\n                no_out!((&x).checked_sqrt());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_checked_sqrt_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.checked_sqrt()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.checked_sqrt())),\n            (\"binary\", &mut |x| no_out!(checked_sqrt_binary(&x))),\n        ],\n    );\n}\n\nfn benchmark_natural_sqrt_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sqrt_rem()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.sqrt_rem()\", &mut |x| no_out!(x.sqrt_rem())),\n            (\"(&Natural).sqrt_rem()\", &mut |x| no_out!((&x).sqrt_rem())),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect)]\nfn benchmark_natural_sqrt_rem_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sqrt_rem()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.sqrt_rem())),\n            (\"floor and subtraction\", &mut |x| {\n                let sqrt = (&x).floor_sqrt();\n                let square = (&sqrt).square();\n                (sqrt, x - square);\n            }),\n            (\"binary\", &mut |x| no_out!(sqrt_rem_binary(&x))),\n        ],\n    );\n}\n\nfn benchmark_natural_sqrt_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sqrt_rem()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"rug\", &mut |(x, _)| {\n                no_out!(x.sqrt_rem(rug::Integer::new()));\n            }),\n            (\"Malachite\", &mut |(_, x)| no_out!(x.sqrt_rem())),\n        ],\n    );\n}\n\nfn benchmark_natural_sqrt_assign_rem(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sqrt_assign_rem()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| no_out!(x.sqrt_assign_rem()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Square, SquareAssign};\nuse malachite_base::test_util::bench::bucketers::pair_2_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::mul::limbs_mul_greater_to_out_basecase;\nuse malachite_nz::natural::arithmetic::square::{\n    limbs_square_to_out_basecase, limbs_square_to_out_toom_2,\n    limbs_square_to_out_toom_2_scratch_len, limbs_square_to_out_toom_3,\n    limbs_square_to_out_toom_3_scratch_len, limbs_square_to_out_toom_4,\n    limbs_square_to_out_toom_4_scratch_len, limbs_square_to_out_toom_6,\n    limbs_square_to_out_toom_6_scratch_len, limbs_square_to_out_toom_8,\n    limbs_square_to_out_toom_8_scratch_len,\n};\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    natural_gen, unsigned_vec_pair_gen_var_22, unsigned_vec_pair_gen_var_23,\n    unsigned_vec_pair_gen_var_24, unsigned_vec_pair_gen_var_26, unsigned_vec_pair_gen_var_27,\n    unsigned_vec_pair_gen_var_28,\n};\nuse malachite_nz::test_util::natural::arithmetic::square::limbs_square_to_out_basecase_unrestricted;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_square_to_out_basecase);\n    register_demo!(runner, demo_natural_square_assign);\n    register_demo!(runner, demo_natural_square);\n    register_demo!(runner, demo_natural_square_ref);\n\n    register_bench!(runner, benchmark_limbs_square_to_out_basecase_algorithms);\n    register_bench!(runner, benchmark_limbs_square_to_out_toom_2_algorithms);\n    register_bench!(runner, benchmark_limbs_square_to_out_toom_3_algorithms);\n    register_bench!(runner, benchmark_limbs_square_to_out_toom_4_algorithms);\n    register_bench!(runner, benchmark_limbs_square_to_out_toom_6_algorithms);\n    register_bench!(runner, benchmark_limbs_square_to_out_toom_8_algorithms);\n    register_bench!(runner, benchmark_natural_square_assign);\n    register_bench!(runner, benchmark_natural_square_algorithms);\n    register_bench!(runner, benchmark_natural_square_evaluation_strategy);\n}\n\nfn demo_limbs_square_to_out_basecase(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs) in unsigned_vec_pair_gen_var_22().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_square_to_out_basecase(&mut out, &xs);\n        println!(\n            \"out := {out_old:?}; limbs_square_to_out_basecase(&mut out, {xs:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_natural_square_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in natural_gen().get(gm, config).take(limit) {\n        let old_n = n.clone();\n        n.square_assign();\n        println!(\"n := {n}; n.square_assign(); n = {old_n}\");\n    }\n}\n\nfn demo_natural_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{} ^ 2 = {}\", n.clone(), n.square());\n    }\n}\n\nfn demo_natural_square_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"&{} ^ 2 = {}\", n, (&n).square());\n    }\n}\n\nfn benchmark_limbs_square_to_out_basecase_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_to_out_basecase(&mut [Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_22().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"default\", &mut |(mut out, xs)| {\n                limbs_square_to_out_basecase(&mut out, &xs);\n            }),\n            (\n                \"using limbs_mul_greater_to_out_basecase\",\n                &mut |(mut out, xs)| limbs_mul_greater_to_out_basecase(&mut out, &xs, &xs),\n            ),\n        ],\n    );\n}\n\nfn benchmark_limbs_square_to_out_toom_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_to_out_toom_2(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_23().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs)| {\n                limbs_square_to_out_basecase_unrestricted(&mut out, &xs);\n            }),\n            (\"Toom2\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_2_scratch_len(xs.len())];\n                limbs_square_to_out_toom_2(&mut out, &xs, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_square_to_out_toom_3_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_to_out_toom_3(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_24().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"Toom2\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_2_scratch_len(xs.len())];\n                limbs_square_to_out_toom_2(&mut out, &xs, &mut scratch);\n            }),\n            (\"Toom3\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_3_scratch_len(xs.len())];\n                limbs_square_to_out_toom_3(&mut out, &xs, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_square_to_out_toom_4_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_to_out_toom_4(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_26().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"Toom3\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_3_scratch_len(xs.len())];\n                limbs_square_to_out_toom_3(&mut out, &xs, &mut scratch);\n            }),\n            (\"Toom4\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_4_scratch_len(xs.len())];\n                limbs_square_to_out_toom_4(&mut out, &xs, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_square_to_out_toom_6_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_to_out_toom_6(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_27().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"Toom4\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_4_scratch_len(xs.len())];\n                limbs_square_to_out_toom_4(&mut out, &xs, &mut scratch);\n            }),\n            (\"Toom6\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_6_scratch_len(xs.len())];\n                limbs_square_to_out_toom_6(&mut out, &xs, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_square_to_out_toom_8_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_square_to_out_toom_8(&mut [Limb], &[Limb], &mut [Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_28().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"Toom6\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_6_scratch_len(xs.len())];\n                limbs_square_to_out_toom_6(&mut out, &xs, &mut scratch);\n            }),\n            (\"Toom8\", &mut |(mut out, xs)| {\n                let mut scratch = vec![0; limbs_square_to_out_toom_8_scratch_len(xs.len())];\n                limbs_square_to_out_toom_8(&mut out, &xs, &mut scratch);\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_square_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.square_assign()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |mut n| n.square_assign())],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_square_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.square()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"standard\", &mut |n| no_out!(n.square())), (\"using *\", &mut |n| no_out!(&n * &n))],\n    );\n}\n\nfn benchmark_natural_square_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.square()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.square()\", &mut |n| no_out!(n.square())),\n            (\"(&Natural).square()\", &mut |n| no_out!((&n).square())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_vec_min_len_bucketer, triple_1_2_vec_min_len_bucketer,\n    triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_6, unsigned_vec_pair_gen_var_31, unsigned_vec_triple_gen_var_31,\n    unsigned_vec_triple_gen_var_40, unsigned_vec_unsigned_pair_gen,\n    unsigned_vec_unsigned_pair_gen_var_1, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::sub::{\n    limbs_slice_sub_in_place_right, limbs_sub, limbs_sub_greater_in_place_left,\n    limbs_sub_greater_to_out, limbs_sub_limb, limbs_sub_limb_in_place, limbs_sub_limb_to_out,\n    limbs_sub_same_length_in_place_left, limbs_sub_same_length_in_place_right,\n    limbs_sub_same_length_in_place_with_overlap, limbs_sub_same_length_to_out,\n    limbs_sub_same_length_to_out_with_overlap, limbs_vec_sub_in_place_right,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n    triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen_var_10, natural_pair_gen_var_10_nrm, natural_pair_gen_var_10_rm,\n};\nuse malachite_nz::test_util::natural::arithmetic::sub::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_sub_limb);\n    register_demo!(runner, demo_limbs_sub_limb_to_out);\n    register_demo!(runner, demo_limbs_sub_limb_in_place);\n    register_demo!(runner, demo_limbs_sub);\n    register_demo!(runner, demo_limbs_sub_same_length_to_out);\n    register_demo!(runner, demo_limbs_sub_greater_to_out);\n    register_demo!(runner, demo_limbs_sub_same_length_in_place_left);\n    register_demo!(runner, demo_limbs_sub_greater_in_place_left);\n    register_demo!(runner, demo_limbs_sub_same_length_in_place_right);\n    register_demo!(runner, demo_limbs_slice_sub_in_place_right);\n    register_demo!(runner, demo_limbs_vec_sub_in_place_right);\n    register_demo!(runner, demo_limbs_sub_same_length_in_place_with_overlap);\n    register_demo!(runner, demo_limbs_sub_same_length_to_out_with_overlap);\n    register_demo!(runner, demo_natural_sub_assign);\n    register_demo!(runner, demo_natural_sub_assign_ref);\n    register_demo!(runner, demo_natural_sub);\n    register_demo!(runner, demo_natural_sub_val_ref);\n    register_demo!(runner, demo_natural_sub_ref_val);\n    register_demo!(runner, demo_natural_sub_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_sub_limb);\n    register_bench!(runner, benchmark_limbs_sub_limb_to_out);\n    register_bench!(runner, benchmark_limbs_sub_limb_in_place);\n    register_bench!(runner, benchmark_limbs_sub);\n    register_bench!(runner, benchmark_limbs_sub_same_length_to_out);\n    register_bench!(runner, benchmark_limbs_sub_greater_to_out);\n    register_bench!(runner, benchmark_limbs_sub_same_length_in_place_left);\n    register_bench!(runner, benchmark_limbs_sub_greater_in_place_left);\n    register_bench!(runner, benchmark_limbs_sub_same_length_in_place_right);\n    register_bench!(runner, benchmark_limbs_slice_sub_in_place_right);\n    register_bench!(runner, benchmark_limbs_vec_sub_in_place_right);\n    register_bench!(\n        runner,\n        benchmark_limbs_sub_same_length_in_place_with_overlap_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_limbs_sub_same_length_to_out_with_overlap_algorithms\n    );\n    register_bench!(runner, benchmark_natural_sub_assign_library_comparison);\n    register_bench!(runner, benchmark_natural_sub_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_sub_library_comparison);\n    register_bench!(runner, benchmark_natural_sub_evaluation_strategy);\n}\n\nfn demo_limbs_sub_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"limbs_sub_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_sub_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_sub_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        let borrow = limbs_sub_limb_to_out(&mut out, &xs, y);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_sub_limb_to_out(&mut out, {xs:?}, {y}) = {borrow}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_limb_in_place::<Limb>(&mut xs, y);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_sub_limb_in_place(&mut xs, {y}) = {borrow}; xs = {xs:?}\"\n        );\n    }\n}\n\nfn demo_limbs_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_31().get(gm, config).take(limit) {\n        println!(\"limbs_sub({:?}, {:?}) = {:?}\", xs, ys, limbs_sub(&xs, &ys));\n    }\n}\n\nfn demo_limbs_sub_same_length_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_31().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let borrow = limbs_sub_same_length_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_sub_same_length_to_out(&mut out, {xs:?}, {ys:?}) = {borrow}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_greater_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_40().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        let borrow = limbs_sub_greater_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_sub_greater_to_out(&mut out, {xs:?}, {ys:?}) = {borrow}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_same_length_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_same_length_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_sub_same_length_in_place_left(&mut xs, {ys:?}) = {borrow}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_greater_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_31().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_greater_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_sub_greater_in_place_left(&mut xs, {ys:?}) = {borrow}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_same_length_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        let ys_old = ys.clone();\n        let borrow = limbs_sub_same_length_in_place_right(&xs, &mut ys);\n        println!(\n            \"ys := {ys_old:?}; \\\n            limbs_sub_same_length_in_place_right({xs:?}, &mut ys) = {borrow}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_sub_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys, len) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24()\n        .get(gm, config)\n        .take(limit)\n    {\n        let ys_old = ys.clone();\n        let borrow = limbs_slice_sub_in_place_right(&xs, &mut ys, len);\n        println!(\n            \"ys := {ys_old:?}; \\\n            limbs_slice_sub_in_place_right({xs:?}, &mut ys, {len}) = {borrow}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_sub_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys) in unsigned_vec_pair_gen_var_31().get(gm, config).take(limit) {\n        let ys_old = ys.clone();\n        let borrow = limbs_vec_sub_in_place_right(&xs, &mut ys);\n        println!(\n            \"ys := {ys_old:?}; \\\n            limbs_vec_sub_in_place_right({xs:?}, &mut ys) = {borrow}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_same_length_in_place_with_overlap(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, right_start) in unsigned_vec_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_same_length_in_place_with_overlap(&mut xs, right_start);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_sub_same_length_in_place_with_overlap(&mut xs, {right_start}) = {borrow}; \\\n            xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_same_length_to_out_with_overlap(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_31().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_same_length_to_out_with_overlap(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_sub_same_length_to_out_with_overlap(&mut xs, {ys:?}) = {borrow}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_natural_sub_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x -= y.clone();\n        println!(\"x := {x_old}; x -= {y}; x = {x}\");\n    }\n}\n\nfn demo_natural_sub_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x -= &y;\n        println!(\"x := {x_old}; x -= &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_natural_sub_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_10().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} - &{} = {}\", x_old, y, x - &y);\n    }\n}\n\nfn demo_natural_sub_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_10().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} - {} = {}\", x, y_old, &x - y);\n    }\n}\n\nfn demo_natural_sub_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_10().get(gm, config).take(limit) {\n        println!(\"&{} - &{} = {}\", x, y, &x - &y);\n    }\n}\n\nfn benchmark_limbs_sub_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sub_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_sub_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_limbs_sub_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sub_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_sub_limb_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            no_out!(limbs_sub_limb_in_place::<Limb>(&mut xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sub(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(limbs_sub(&xs, &ys)))],\n    );\n}\n\nfn benchmark_limbs_sub_same_length_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            no_out!(limbs_sub_same_length_to_out(&mut out, &xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_greater_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_greater_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_40().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            no_out!(limbs_sub_greater_to_out(&mut out, &xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_same_length_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            no_out!(limbs_sub_same_length_in_place_left(&mut xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_greater_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_greater_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            no_out!(limbs_sub_greater_in_place_left(&mut xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_same_length_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_same_length_in_place_right(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, mut ys)| {\n            no_out!(limbs_sub_same_length_in_place_right(&xs, &mut ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_sub_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_sub_in_place_right(&[Limb], &mut [Limb], usize)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, mut ys, len)| {\n            no_out!(limbs_slice_sub_in_place_right(&xs, &mut ys, len));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_sub_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_sub_in_place_right(&[Limb], &mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, mut ys)| {\n            no_out!(limbs_vec_sub_in_place_right(&xs, &mut ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_same_length_in_place_with_overlap_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_same_length_in_place_with_overlap(&mut [Limb], usize)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut xs, right_start)| {\n                no_out!(limbs_sub_same_length_in_place_with_overlap(\n                    &mut xs,\n                    right_start\n                ));\n            }),\n            (\"naive\", &mut |(mut xs, right_start)| {\n                no_out!(limbs_sub_same_length_in_place_with_overlap_naive(\n                    &mut xs,\n                    right_start\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_sub_same_length_to_out_with_overlap_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_same_length_to_out_with_overlap(&mut [Limb], &[Limb])\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_pair_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"standard\", &mut |(mut xs, ys)| {\n                no_out!(limbs_sub_same_length_to_out_with_overlap(&mut xs, &ys));\n            }),\n            (\"naive\", &mut |(mut xs, ys)| {\n                no_out!(limbs_sub_same_length_to_out_with_overlap_naive(\n                    &mut xs, &ys\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_sub_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural -= Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_10_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x -= y), (\"rug\", &mut |((mut x, y), _)| x -= y)],\n    );\n}\n\nfn benchmark_natural_sub_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural -= Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural -= Natural\", &mut |(mut x, y)| x -= y),\n            (\"Natural -= &Natural\", &mut |(mut x, y)| x -= &y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_sub_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural - Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_var_10_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x - y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x - y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x - y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural - Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_10().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural - Natural\", &mut |(x, y)| no_out!(x - y)),\n            (\"Natural - &Natural\", &mut |(x, y)| no_out!(x - &y)),\n            (\"&Natural - Natural\", &mut |(x, y)| no_out!(&x - y)),\n            (\"&Natural - &Natural\", &mut |(x, y)| no_out!(&x - &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{SubMul, SubMulAssign};\nuse malachite_base::test_util::bench::bucketers::triple_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_triple_gen_var_59, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::arithmetic::sub_mul::{\n    limbs_sub_mul, limbs_sub_mul_in_place_left, limbs_sub_mul_limb_greater,\n    limbs_sub_mul_limb_greater_in_place_left, limbs_sub_mul_limb_greater_in_place_right,\n    limbs_sub_mul_limb_same_length_in_place_left, limbs_sub_mul_limb_same_length_in_place_right,\n};\nuse malachite_nz::test_util::bench::bucketers::triple_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_triple_gen_var_7;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_sub_mul_limb_greater);\n    register_demo!(runner, demo_limbs_sub_mul_limb_same_length_in_place_left);\n    register_demo!(runner, demo_limbs_sub_mul_limb_greater_in_place_left);\n    register_demo!(runner, demo_limbs_sub_mul_limb_same_length_in_place_right);\n    register_demo!(runner, demo_limbs_sub_mul_limb_greater_in_place_right);\n    register_demo!(runner, demo_limbs_sub_mul);\n    register_demo!(runner, demo_limbs_sub_mul_in_place_left);\n    register_demo!(runner, demo_natural_sub_mul_assign);\n    register_demo!(runner, demo_natural_sub_mul_assign_val_ref);\n    register_demo!(runner, demo_natural_sub_mul_assign_ref_val);\n    register_demo!(runner, demo_natural_sub_mul_assign_ref_ref);\n    register_demo!(runner, demo_natural_sub_mul);\n    register_demo!(runner, demo_natural_sub_mul_val_val_ref);\n    register_demo!(runner, demo_natural_sub_mul_val_ref_val);\n    register_demo!(runner, demo_natural_sub_mul_val_ref_ref);\n    register_demo!(runner, demo_natural_sub_mul_ref_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_sub_mul_limb_greater);\n    register_bench!(\n        runner,\n        benchmark_limbs_sub_mul_limb_same_length_in_place_left\n    );\n    register_bench!(runner, benchmark_limbs_sub_mul_limb_greater_in_place_left);\n    register_bench!(\n        runner,\n        benchmark_limbs_sub_mul_limb_same_length_in_place_right\n    );\n    register_bench!(runner, benchmark_limbs_sub_mul_limb_greater_in_place_right);\n    register_bench!(runner, benchmark_limbs_sub_mul);\n    register_bench!(runner, benchmark_limbs_sub_mul_in_place_left);\n    register_bench!(runner, benchmark_natural_sub_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_sub_mul_assign_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_assign_val_ref_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_assign_ref_val_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_assign_ref_ref_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_evaluation_stategy);\n    register_bench!(runner, benchmark_natural_sub_mul_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_val_val_ref_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_val_ref_val_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_val_ref_ref_algorithms);\n    register_bench!(runner, benchmark_natural_sub_mul_ref_ref_ref_algorithms);\n}\n\nfn demo_limbs_sub_mul_limb_greater(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, z) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_sub_mul_limb_greater({:?}, {:?}, {}) = {:?}\",\n            xs,\n            ys,\n            z,\n            limbs_sub_mul_limb_greater(&xs, &ys, z),\n        );\n    }\n}\n\nfn demo_limbs_sub_mul_limb_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut xs, ys, z) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_mul_limb_same_length_in_place_left(&mut xs, &ys, z);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_sub_mul_limb_same_length_in_place_left(&mut xs, {ys:?}, {z}) = {borrow}; \\\n             xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_mul_limb_greater_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys, z) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_mul_limb_greater_in_place_left(&mut xs, &ys, z);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_sub_mul_limb_greater_in_place_left(&mut xs, {ys:?}, {z}) = {borrow}; \\\n             xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_mul_limb_same_length_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (xs, mut ys, z) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12()\n        .get(gm, config)\n        .take(limit)\n    {\n        let ys_old = ys.clone();\n        limbs_sub_mul_limb_same_length_in_place_right(&xs, &mut ys, z);\n        println!(\n            \"ys := {ys_old:?}; \\\n            limbs_sub_mul_limb_same_length_in_place_right({xs:?}, &mut ys, {z}); \\\n            ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_mul_limb_greater_in_place_right(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, mut ys, z) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let ys_old = ys.clone();\n        limbs_sub_mul_limb_greater_in_place_right(&xs, &mut ys, z);\n        println!(\n            \"ys := {ys_old:?}; \\\n            limbs_sub_mul_limb_greater_in_place_right({xs:?}, &mut ys, {z}); ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_limbs_sub_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys, zs) in unsigned_vec_triple_gen_var_59().get(gm, config).take(limit) {\n        println!(\n            \"limbs_sub_mul({:?}, {:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            zs,\n            limbs_sub_mul(&xs, &ys, &zs),\n        );\n    }\n}\n\nfn demo_limbs_sub_mul_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys, zs) in unsigned_vec_triple_gen_var_59().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_sub_mul_in_place_left(&mut xs, &ys, &zs);\n        println!(\n            \"xs := {xs_old:?}; limbs_sub_mul_in_place_left(&mut xs, {ys:?}, {zs:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_natural_sub_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        let c_old = c.clone();\n        a.sub_mul_assign(b, c);\n        println!(\"a := {a_old}; x.sub_mul_assign({b_old}, {c_old}); x = {a}\");\n    }\n}\n\nfn demo_natural_sub_mul_assign_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        a.sub_mul_assign(b, &c);\n        println!(\"a := {a_old}; x.sub_mul_assign({b_old}, &{c}); x = {a}\");\n    }\n}\n\nfn demo_natural_sub_mul_assign_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let c_old = c.clone();\n        a.sub_mul_assign(&b, c);\n        println!(\"a := {a_old}; x.sub_mul_assign(&{b}, {c_old}); x = {a}\");\n    }\n}\n\nfn demo_natural_sub_mul_assign_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        a.sub_mul_assign(&b, &c);\n        println!(\"a := {a_old}; x.sub_mul_assign(&{b}, &{c}); x = {a}\");\n    }\n}\n\nfn demo_natural_sub_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        let c_old = c.clone();\n        println!(\n            \"{}.sub_mul({}, {}) = {}\",\n            a_old,\n            b_old,\n            c_old,\n            a.sub_mul(b, c)\n        );\n    }\n}\n\nfn demo_natural_sub_mul_val_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        println!(\n            \"{}.sub_mul({}, &{}) = {}\",\n            a_old,\n            b_old,\n            c,\n            a.sub_mul(b, &c)\n        );\n    }\n}\n\nfn demo_natural_sub_mul_val_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        let c_old = c.clone();\n        println!(\n            \"{}.sub_mul(&{}, {}) = {}\",\n            a_old,\n            b,\n            c_old,\n            a.sub_mul(&b, c)\n        );\n    }\n}\n\nfn demo_natural_sub_mul_val_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        let a_old = a.clone();\n        println!(\"{}.sub_mul(&{}, &{}) = {}\", a_old, b, c, a.sub_mul(&b, &c));\n    }\n}\n\nfn demo_natural_sub_mul_ref_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b, c) in natural_triple_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"(&{}).sub_mul(&{}, &{}) = {}\",\n            a,\n            b,\n            c,\n            (&a).sub_mul(&b, &c)\n        );\n    }\n}\n\nfn benchmark_limbs_sub_mul_limb_greater(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_mul_limb_greater(&[Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys, z)| {\n            no_out!(limbs_sub_mul_limb_greater(&xs, &ys, z));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_mul_limb_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_mul_limb_same_length_in_place_left(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys, z)| {\n            no_out!(limbs_sub_mul_limb_same_length_in_place_left(\n                &mut xs, &ys, z\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_mul_limb_greater_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_mul_limb_greater_in_place_left(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys, z)| {\n            no_out!(limbs_sub_mul_limb_greater_in_place_left(&mut xs, &ys, z));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_mul_limb_same_length_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_mul_limb_same_length_in_place_right(&[Limb], &mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, mut ys, z)| {\n            no_out!(limbs_sub_mul_limb_same_length_in_place_right(\n                &xs, &mut ys, z\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_mul_limb_greater_in_place_right(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_mul_limb_greater_in_place_right(&[Limb], &mut Vec<Limb>, Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, mut ys, z)| {\n            no_out!(limbs_sub_mul_limb_same_length_in_place_right(\n                &xs, &mut ys, z\n            ));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_mul(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_sub_mul(&[Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_59().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys, zs)| {\n            no_out!(limbs_sub_mul(&xs, &ys, &zs));\n        })],\n    );\n}\n\nfn benchmark_limbs_sub_mul_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_sub_mul_in_place_left(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_59().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys, zs)| {\n            no_out!(limbs_sub_mul_in_place_left(&mut xs, &ys, &zs));\n        })],\n    );\n}\n\nfn benchmark_natural_sub_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.sub_mul_assign(Natural, Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, c),\n            ),\n            (\n                \"Natural.sub_mul_assign(Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, &c),\n            ),\n            (\n                \"Natural.sub_mul_assign(&Natural, Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, c),\n            ),\n            (\n                \"Natural.sub_mul_assign(&Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, &c),\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_sub_mul_assign_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul_assign(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.sub_mul_assign(Natural, Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, c),\n            ),\n            (\"Natural += Natural * Natural\", &mut |(mut a, b, c)| {\n                a += b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_sub_mul_assign_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul_assign(Natural, &Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.sub_mul_assign(Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(b, &c),\n            ),\n            (\"Natural += Natural * &Natural\", &mut |(mut a, b, c)| {\n                a += b * &c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_sub_mul_assign_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul_assign(&Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.sub_mul_assign(&Natural, Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, c),\n            ),\n            (\"Natural += &Natural * Natural\", &mut |(mut a, b, c)| {\n                a += &b * c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_sub_mul_assign_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul_assign(&Natural, &Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"Natural.sub_mul_assign(&Natural, &Natural)\",\n                &mut |(mut a, b, c)| a.sub_mul_assign(&b, &c),\n            ),\n            (\"Natural += &Natural * &Natural\", &mut |(mut a, b, c)| {\n                a += &b * &c;\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_sub_mul_evaluation_stategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.sub_mul(Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, c));\n            }),\n            (\"Natural.sub_mul(Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, &c));\n            }),\n            (\"Natural.sub_mul(&Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, c));\n            }),\n            (\"Natural.sub_mul(&Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, &c));\n            }),\n            (\n                \"(&Natural).sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).sub_mul(&b, &c)),\n            ),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_sub_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul(Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.sub_mul(Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, c));\n            }),\n            (\"Natural - Natural * Natural\", &mut |(a, b, c)| {\n                no_out!(a - b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_sub_mul_val_val_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul(Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.sub_mul(Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(b, &c));\n            }),\n            (\"Natural - Natural * &Natural\", &mut |(a, b, c)| {\n                no_out!(a - b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_sub_mul_val_ref_val_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul(&Natural, Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.sub_mul(&Natural, Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, c));\n            }),\n            (\"Natural - &Natural * Natural\", &mut |(a, b, c)| {\n                no_out!(a - &b * c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_sub_mul_val_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sub_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\"Natural.sub_mul(&Natural, &Natural)\", &mut |(a, b, c)| {\n                no_out!(a.sub_mul(&b, &c));\n            }),\n            (\"Natural - &Natural * &Natural\", &mut |(a, b, c)| {\n                no_out!(a - &b * &c);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_sub_mul_ref_ref_ref_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Natural).sub_mul(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_triple_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_natural_max_bit_bucketer(\"a\", \"b\", \"c\"),\n        &mut [\n            (\n                \"(&Natural).sub_mul(&Natural, &Natural)\",\n                &mut |(a, b, c)| no_out!((&a).sub_mul(&b, &c)),\n            ),\n            (\"(&Natural) - &Natural * &Natural\", &mut |(a, b, c)| {\n                no_out!((&a) - &b * &c);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_vec_max_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_6, unsigned_vec_pair_gen_var_7, unsigned_vec_pair_gen_var_19,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::comparison::cmp::{\n    limbs_cmp, limbs_cmp_normalized, limbs_cmp_same_length,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_natural_max_bit_bucketer, triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_pair_gen_nrm, natural_pair_gen_var_9,\n};\nuse malachite_nz::test_util::natural::comparison::cmp::natural_cmp_normalized_naive;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_cmp_same_length);\n    register_demo!(runner, demo_limbs_cmp);\n    register_demo!(runner, demo_limbs_cmp_normalized);\n    register_demo!(runner, demo_natural_cmp);\n    register_demo!(runner, demo_natural_cmp_normalized);\n\n    register_bench!(runner, benchmark_limbs_cmp_same_length);\n    register_bench!(runner, benchmark_limbs_cmp);\n    register_bench!(runner, benchmark_limbs_cmp_normalized);\n    register_bench!(runner, benchmark_natural_cmp_library_comparison);\n    register_bench!(runner, benchmark_natural_cmp_normalized_algorithms);\n}\n\nfn demo_limbs_cmp_same_length(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        println!(\n            \"limbs_cmp_same_length({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_cmp_same_length(&xs, &ys),\n        );\n    }\n}\n\nfn demo_limbs_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_7().get(gm, config).take(limit) {\n        println!(\"limbs_cmp({:?}, {:?}) = {:?}\", xs, ys, limbs_cmp(&xs, &ys));\n    }\n}\n\nfn demo_limbs_cmp_normalized(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_19().get(gm, config).take(limit) {\n        println!(\n            \"limbs_cmp_normalized({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_cmp_normalized(&xs, &ys),\n        );\n    }\n}\n\nfn demo_natural_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        match x.cmp(&y) {\n            Less => println!(\"{x} < {y}\"),\n            Equal => println!(\"{x} = {y}\"),\n            Greater => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_natural_cmp_normalized(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen_var_9().get(gm, config).take(limit) {\n        println!(\"cmp_normalized({}, {}) = {:?}\", x, y, x.cmp_normalized(&y));\n    }\n}\n\nfn benchmark_limbs_cmp_same_length(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_cmp_same_length(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_cmp_same_length(&xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_cmp(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_cmp(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(limbs_cmp(&xs, &ys)))],\n    );\n}\n\nfn benchmark_limbs_cmp_normalized(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_cmp_normalized(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_19().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_cmp_normalized(&xs, &ys));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_cmp_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.cmp(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.cmp(&y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.cmp(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.cmp(&y))),\n        ],\n    );\n}\n\nfn benchmark_natural_cmp_normalized_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.cmp_normalized(&Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.cmp_normalized(&y))),\n            (\"naive\", &mut |(x, y)| {\n                no_out!(natural_cmp_normalized_naive(&x, &y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_pair_natural_max_bit_bucketer;\nuse malachite_nz::test_util::generators::{natural_pair_gen, natural_pair_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_eq);\n    register_bench!(runner, benchmark_natural_eq_library_comparison);\n}\n\nfn demo_natural_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_eq_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural == Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x == y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x == y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_primitive_float_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_natural_eq_abs_primitive_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_eq_abs_natural);\n\n    register_primitive_float_benches!(runner, benchmark_natural_eq_abs_primitive_float);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_eq_abs_natural);\n}\n\nfn demo_natural_eq_abs_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: EqAbs<T>,\n{\n    for (n, x) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.eq_abs(&x) {\n            println!(\"|{}| = |{}|\", n, NiceFloat(x));\n        } else {\n            println!(\"|{}| ≠ |{}|\", n, NiceFloat(x));\n        }\n    }\n}\n\nfn demo_primitive_float_eq_abs_natural<T: EqAbs<Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, x) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&n) {\n            println!(\"|{}| = |{}|\", NiceFloat(x), n);\n        } else {\n            println!(\"|{}| ≠ |{}|\", NiceFloat(x), n);\n        }\n    }\n}\n\nfn benchmark_natural_eq_abs_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: EqAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.eq_abs(&y)))],\n    );\n}\n\nfn benchmark_primitive_float_eq_abs_natural<T: EqAbs<Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.eq_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{natural_signed_pair_gen, natural_unsigned_pair_gen};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_eq_abs_unsigned);\n    register_signed_demos!(runner, demo_natural_eq_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_eq_abs_natural);\n    register_signed_demos!(runner, demo_signed_eq_abs_natural);\n\n    register_unsigned_benches!(runner, benchmark_natural_eq_abs_unsigned);\n    register_signed_benches!(runner, benchmark_natural_eq_abs_signed);\n    register_unsigned_benches!(runner, benchmark_unsigned_eq_abs_natural);\n    register_signed_benches!(runner, benchmark_signed_eq_abs_natural);\n}\n\nfn demo_natural_eq_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: EqAbs<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.eq_abs(&u) {\n            println!(\"|{n}| = |{u}|\");\n        } else {\n            println!(\"|{n}| ≠ |{u}|\");\n        }\n    }\n}\n\nfn demo_natural_eq_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: EqAbs<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.eq_abs(&i) {\n            println!(\"|{n}| = |{i}|\");\n        } else {\n            println!(\"|{n}| ≠ |{i}|\");\n        }\n    }\n}\n\nfn demo_unsigned_eq_abs_natural<T: EqAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.eq_abs(&n) {\n            println!(\"|{u}| = |{n}|\");\n        } else {\n            println!(\"|{u}| ≠ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_eq_abs_natural<T: EqAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.eq_abs(&n) {\n            println!(\"|{i}| = |{n}|\");\n        } else {\n            println!(\"|{i}| ≠ |{n}|\");\n        }\n    }\n}\n\nfn benchmark_natural_eq_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: EqAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.eq_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_eq_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: EqAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.eq_abs(&y)))],\n    );\n}\n\nfn benchmark_unsigned_eq_abs_natural<T: EqAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.eq_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_eq_abs_natural<T: EqAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.eq_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::hash::hash;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::triple_3_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_hash);\n    register_bench!(runner, benchmark_natural_hash_library_comparison);\n}\n\nfn demo_natural_hash(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"hash({}) = {}\", n, hash(&n));\n    }\n}\n\nfn benchmark_natural_hash_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural hash\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(hash(&n))),\n            (\"num\", &mut |(_, n, _)| no_out!(hash(&n))),\n            (\"rug\", &mut |(n, _, _)| no_out!(hash(&n))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    cmp::register(runner);\n    eq::register(runner);\n    eq_abs_primitive_float::register(runner);\n    eq_abs_primitive_int::register(runner);\n    hash::register(runner);\n    partial_cmp_abs_primitive_float::register(runner);\n    partial_cmp_abs_primitive_int::register(runner);\n    partial_cmp_primitive_float::register(runner);\n    partial_cmp_primitive_int::register(runner);\n    partial_eq_primitive_int::register(runner);\n    partial_eq_primitive_float::register(runner);\n}\n\nmod cmp;\nmod eq;\nmod eq_abs_primitive_float;\nmod eq_abs_primitive_int;\nmod hash;\nmod partial_cmp_abs_primitive_float;\nmod partial_cmp_abs_primitive_int;\nmod partial_cmp_primitive_float;\nmod partial_cmp_primitive_int;\nmod partial_eq_primitive_float;\nmod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_primitive_float_pair_gen;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_natural_partial_cmp_abs_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_abs_natural);\n\n    register_primitive_float_benches!(runner, benchmark_natural_partial_cmp_abs_float);\n    register_primitive_float_benches!(runner, benchmark_float_partial_cmp_abs_natural);\n}\n\nfn demo_natural_partial_cmp_abs_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, f) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp_abs(&f) {\n            None => println!(\"{} is not comparable with {}\", n, NiceFloat(f)),\n            Some(Less) => println!(\"|{}| < |{}|\", n, NiceFloat(f)),\n            Some(Equal) => println!(\"|{}| = |{}|\", n, NiceFloat(f)),\n            Some(Greater) => println!(\"|{}| > |{}|\", n, NiceFloat(f)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match f.partial_cmp_abs(&n) {\n            None => println!(\"{} is not comparable with {}\", NiceFloat(f), n),\n            Some(Less) => println!(\"|{}| < |{}|\", NiceFloat(f), n),\n            Some(Equal) => println!(\"|{}| = |{}|\", NiceFloat(f), n),\n            Some(Greater) => println!(\"|{}| > |{}|\", NiceFloat(f), n),\n        }\n    }\n}\n\nfn benchmark_natural_partial_cmp_abs_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y)))],\n    );\n}\n\nfn benchmark_float_partial_cmp_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{natural_signed_pair_gen, natural_unsigned_pair_gen};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_partial_cmp_abs_unsigned);\n    register_signed_demos!(runner, demo_natural_partial_cmp_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_abs_natural);\n    register_signed_demos!(runner, demo_signed_partial_cmp_abs_natural);\n    register_unsigned_demos!(runner, demo_natural_lt_abs_unsigned);\n    register_signed_demos!(runner, demo_natural_lt_abs_signed);\n    register_unsigned_demos!(runner, demo_natural_gt_abs_unsigned);\n    register_signed_demos!(runner, demo_natural_gt_abs_signed);\n    register_unsigned_demos!(runner, demo_natural_le_abs_unsigned);\n    register_signed_demos!(runner, demo_natural_le_abs_signed);\n    register_unsigned_demos!(runner, demo_natural_ge_abs_unsigned);\n    register_signed_demos!(runner, demo_natural_ge_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_lt_abs_natural);\n    register_signed_demos!(runner, demo_signed_lt_abs_natural);\n    register_unsigned_demos!(runner, demo_unsigned_gt_abs_natural);\n    register_signed_demos!(runner, demo_signed_gt_abs_natural);\n    register_unsigned_demos!(runner, demo_unsigned_le_abs_natural);\n    register_signed_demos!(runner, demo_signed_le_abs_natural);\n    register_unsigned_demos!(runner, demo_unsigned_ge_abs_natural);\n    register_signed_demos!(runner, demo_signed_ge_abs_natural);\n\n    register_unsigned_benches!(runner, benchmark_natural_partial_cmp_abs_unsigned);\n    register_signed_benches!(runner, benchmark_natural_partial_cmp_abs_signed);\n    register_unsigned_benches!(runner, benchmark_unsigned_partial_cmp_abs_natural);\n    register_signed_benches!(runner, benchmark_signed_partial_cmp_abs_natural);\n    register_unsigned_benches!(runner, benchmark_natural_lt_abs_unsigned);\n    register_signed_benches!(runner, benchmark_natural_lt_abs_signed);\n    register_unsigned_benches!(runner, benchmark_natural_gt_abs_unsigned);\n    register_signed_benches!(runner, benchmark_natural_gt_abs_signed);\n    register_unsigned_benches!(runner, benchmark_natural_le_abs_unsigned);\n    register_signed_benches!(runner, benchmark_natural_le_abs_signed);\n    register_unsigned_benches!(runner, benchmark_natural_ge_abs_unsigned);\n    register_signed_benches!(runner, benchmark_natural_ge_abs_signed);\n    register_unsigned_benches!(runner, benchmark_unsigned_lt_abs_natural);\n    register_signed_benches!(runner, benchmark_signed_lt_abs_natural);\n    register_unsigned_benches!(runner, benchmark_unsigned_gt_abs_natural);\n    register_signed_benches!(runner, benchmark_signed_gt_abs_natural);\n    register_unsigned_benches!(runner, benchmark_unsigned_le_abs_natural);\n    register_signed_benches!(runner, benchmark_signed_le_abs_natural);\n    register_unsigned_benches!(runner, benchmark_unsigned_ge_abs_natural);\n    register_signed_benches!(runner, benchmark_signed_ge_abs_natural);\n}\n\nfn demo_natural_partial_cmp_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp_abs(&u).unwrap() {\n            Less => println!(\"|{n}| < |{u}|\"),\n            Equal => println!(\"|{n}| = |{u}|\"),\n            Greater => println!(\"|{n}| > |{u}|\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp_abs(&i).unwrap() {\n            Less => println!(\"|{n}| < |{i}|\"),\n            Equal => println!(\"|{n}| = |{i}|\"),\n            Greater => println!(\"|{n}| > |{i}|\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match u.partial_cmp_abs(&n).unwrap() {\n            Less => println!(\"|{u}| < |{n}|\"),\n            Equal => println!(\"|{u}| = |{n}|\"),\n            Greater => println!(\"|{u}| > |{n}|\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match i.partial_cmp_abs(&n).unwrap() {\n            Less => println!(\"|{i}| < |{n}|\"),\n            Equal => println!(\"|{i}| = |{n}|\"),\n            Greater => println!(\"|{i}| > |{n}|\"),\n        }\n    }\n}\n\nfn demo_natural_lt_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.lt_abs(&u) {\n            println!(\"|{n}| < |{u}|\");\n        } else {\n            println!(\"|{n}| ≮ |{u}|\");\n        }\n    }\n}\n\nfn demo_natural_lt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.lt_abs(&i) {\n            println!(\"|{n}| < |{i}|\");\n        } else {\n            println!(\"|{n}| ≮ |{i}|\");\n        }\n    }\n}\n\nfn demo_natural_gt_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.gt_abs(&u) {\n            println!(\"|{n}| > |{u}|\");\n        } else {\n            println!(\"|{n}| ≯ |{u}|\");\n        }\n    }\n}\n\nfn demo_natural_gt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.gt_abs(&i) {\n            println!(\"|{n}| > |{i}|\");\n        } else {\n            println!(\"|{n}| ≯ |{i}|\");\n        }\n    }\n}\n\nfn demo_natural_le_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.le_abs(&u) {\n            println!(\"|{n}| ≤ |{u}|\");\n        } else {\n            println!(\"|{n}| ≰ |{u}|\");\n        }\n    }\n}\n\nfn demo_natural_le_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.le_abs(&i) {\n            println!(\"|{n}| ≤ |{i}|\");\n        } else {\n            println!(\"|{n}| ≰ |{i}|\");\n        }\n    }\n}\n\nfn demo_natural_ge_abs_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.ge_abs(&u) {\n            println!(\"|{n}| ≥ |{u}|\");\n        } else {\n            println!(\"|{n}| ≱ |{u}|\");\n        }\n    }\n}\n\nfn demo_natural_ge_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrdAbs<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.ge_abs(&i) {\n            println!(\"|{n}| ≥ |{i}|\");\n        } else {\n            println!(\"|{n}| ≱ |{i}|\");\n        }\n    }\n}\n\nfn demo_unsigned_lt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.lt_abs(&n) {\n            println!(\"|{u}| < |{n}|\");\n        } else {\n            println!(\"|{u}| ≮ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_lt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.lt_abs(&n) {\n            println!(\"|{i}| < |{n}|\");\n        } else {\n            println!(\"|{i}| ≮ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_gt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.gt_abs(&n) {\n            println!(\"|{u}| > |{n}|\");\n        } else {\n            println!(\"|{u}| ≯ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_gt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.gt_abs(&n) {\n            println!(\"|{i}| > |{n}|\");\n        } else {\n            println!(\"|{i}| ≯ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_le_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.le_abs(&n) {\n            println!(\"|{u}| ≤ |{n}|\");\n        } else {\n            println!(\"|{u}| ≰ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_le_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.le_abs(&n) {\n            println!(\"|{i}| ≤ |{n}|\");\n        } else {\n            println!(\"|{i}| ≰ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_ge_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u.ge_abs(&n) {\n            println!(\"|{u}| ≥ |{n}|\");\n        } else {\n            println!(\"|{u}| ≱ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_ge_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.ge_abs(&n) {\n            println!(\"|{i}| ≥ |{n}|\");\n        } else {\n            println!(\"|{i}| ≱ |{n}|\");\n        }\n    }\n}\n\nfn benchmark_natural_partial_cmp_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_partial_cmp_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y)))],\n    );\n}\n\nfn benchmark_unsigned_partial_cmp_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_partial_cmp_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x)))],\n    );\n}\n\nfn benchmark_natural_lt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.lt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_lt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.lt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_gt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.gt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_gt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.gt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_le_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.le_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_le_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.le_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_ge_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.ge_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_ge_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.ge_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_unsigned_lt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lt_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_lt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lt_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_gt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gt_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_gt_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gt_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_le_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.le_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_le_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.le_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_ge_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ge_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_ge_abs_natural<T: PartialOrdAbs<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ge_abs(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_2_pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    natural_primitive_float_pair_gen, natural_primitive_float_pair_gen_rm,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_natural_partial_cmp_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_natural);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_natural_partial_cmp_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_cmp_natural_library_comparison\n    );\n}\n\nfn demo_natural_partial_cmp_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialOrd<T>,\n{\n    for (n, f) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp(&f) {\n            None => println!(\"{} is not comparable with {}\", n, NiceFloat(f)),\n            Some(Less) => println!(\"{} < {}\", n, NiceFloat(f)),\n            Some(Equal) => println!(\"{} = {}\", n, NiceFloat(f)),\n            Some(Greater) => println!(\"{} > {}\", n, NiceFloat(f)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_natural<T: PartialOrd<Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match f.partial_cmp(&n) {\n            None => println!(\"{} is not comparable with {}\", NiceFloat(f), n),\n            Some(Less) => println!(\"{} < {}\", NiceFloat(f), n),\n            Some(Equal) => println!(\"{} = {}\", NiceFloat(f), n),\n            Some(Greater) => println!(\"{} > {}\", NiceFloat(f), n),\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_partial_cmp_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_partial_cmp_natural_library_comparison<\n    T: PartialOrd<Natural> + PartialOrd<rug::Integer> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Natural)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_1_natural_bit_bucketer, triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_signed_pair_gen, natural_signed_pair_gen_rm, natural_unsigned_pair_gen,\n    natural_unsigned_pair_gen_nrm, natural_unsigned_pair_gen_rm,\n};\nuse malachite_nz::test_util::natural::comparison::partial_cmp_primitive_int::*;\nuse num::BigUint;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_partial_cmp_unsigned);\n    register_signed_demos!(runner, demo_natural_partial_cmp_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_natural);\n    register_signed_demos!(runner, demo_signed_partial_cmp_natural);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_partial_cmp_unsigned_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_natural_partial_cmp_signed_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_cmp_natural_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_cmp_natural_library_comparison\n    );\n}\n\nfn demo_natural_partial_cmp_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PartialOrd<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp(&u).unwrap() {\n            Less => println!(\"{n} < {u}\"),\n            Equal => println!(\"{n} = {u}\"),\n            Greater => println!(\"{n} > {u}\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PartialOrd<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp(&i).unwrap() {\n            Less => println!(\"{n} < {i}\"),\n            Equal => println!(\"{n} = {i}\"),\n            Greater => println!(\"{n} > {i}\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_natural<T: PartialOrd<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        match u.partial_cmp(&n).unwrap() {\n            Less => println!(\"{u} < {n}\"),\n            Equal => println!(\"{u} = {n}\"),\n            Greater => println!(\"{u} > {n}\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_natural<T: PartialOrd<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match i.partial_cmp(&n).unwrap() {\n            Less => println!(\"{i} < {n}\"),\n            Equal => println!(\"{i} = {n}\"),\n            Greater => println!(\"{i} > {n}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_partial_cmp_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BigUint: From<T>,\n    Natural: PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_nrm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| {\n                no_out!(x.partial_cmp(&y));\n            }),\n            (\"num\", &mut |((x, y), _, _)| {\n                no_out!(num_partial_cmp_unsigned(&x, y));\n            }),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_partial_cmp_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_partial_cmp_natural_library_comparison<\n    T: PartialOrd<Natural> + PartialOrd<rug::Integer> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Natural)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_partial_cmp_natural_library_comparison<\n    T: PartialOrd<Natural> + PartialOrd<rug::Integer> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Natural)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_2_pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    natural_primitive_float_pair_gen, natural_primitive_float_pair_gen_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_natural_partial_eq_float);\n    register_primitive_float_demos!(runner, demo_float_partial_eq_natural);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_natural_partial_eq_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_eq_natural_library_comparison\n    );\n}\n\nfn demo_natural_partial_eq_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialEq<T>,\n{\n    for (n, f) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n == f {\n            println!(\"{} = {}\", n, NiceFloat(f));\n        } else {\n            println!(\"{} ≠ {}\", n, NiceFloat(f));\n        }\n    }\n}\n\nfn demo_float_partial_eq_natural<T: PartialEq<Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in natural_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if f == n {\n            println!(\"{} = {}\", NiceFloat(f), n);\n        } else {\n            println!(\"{} ≠ {}\", NiceFloat(f), n);\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_partial_eq_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Natural == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_partial_eq_natural_library_comparison<\n    T: PartialEq<Natural> + PartialEq<rug::Integer> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Natural\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_1_natural_bit_bucketer, triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_signed_pair_gen, natural_signed_pair_gen_rm, natural_unsigned_pair_gen,\n    natural_unsigned_pair_gen_nrm, natural_unsigned_pair_gen_rm,\n};\nuse malachite_nz::test_util::natural::comparison::partial_eq_primitive_int::num_partial_eq_unsigned;\nuse num::BigUint;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_partial_eq_unsigned);\n    register_signed_demos!(runner, demo_natural_partial_eq_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_natural);\n    register_signed_demos!(runner, demo_signed_partial_eq_natural);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_partial_eq_unsigned_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_natural_partial_eq_signed_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_eq_natural_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_eq_natural_library_comparison\n    );\n}\n\nfn demo_natural_partial_eq_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PartialEq<T>,\n{\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if n == u {\n            println!(\"{n} = {u}\");\n        } else {\n            println!(\"{n} ≠ {u}\");\n        }\n    }\n}\n\nfn demo_natural_partial_eq_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: PartialEq<T>,\n{\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n == i {\n            println!(\"{n} = {i}\");\n        } else {\n            println!(\"{n} ≠ {i}\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_natural<T: PartialEq<Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in natural_unsigned_pair_gen::<T>().get(gm, config).take(limit) {\n        if u == n {\n            println!(\"{u} = {n}\");\n        } else {\n            println!(\"{u} ≠ {n}\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_natural<T: PartialEq<Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in natural_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i == n {\n            println!(\"{i} = {n}\");\n        } else {\n            println!(\"{i} ≠ {n}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_partial_eq_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    BigUint: From<T>,\n    Natural: PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Natural == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_nrm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x == y)),\n            (\"num\", &mut |((x, y), _, _)| {\n                no_out!(num_partial_eq_unsigned(&x, y));\n            }),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_partial_eq_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Natural == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_unsigned_partial_eq_natural_library_comparison<\n    T: PartialEq<Natural> + PartialEq<rug::Integer> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Natural\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_signed_partial_eq_natural_library_comparison<\n    T: PartialEq<Natural> + PartialEq<rug::Integer> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Natural\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        natural_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    triple_3_natural_bit_bucketer, triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_nrm, natural_pair_gen, natural_pair_gen_nrm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_clone);\n    register_demo!(runner, demo_natural_clone_from);\n    register_bench!(runner, benchmark_natural_clone_library_comparison);\n    register_bench!(runner, benchmark_natural_clone_from_library_comparison);\n}\n\nfn demo_natural_clone(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"clone({}) = {}\", n, n.clone());\n    }\n}\n\nfn demo_natural_clone_from(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.clone_from(&y);\n        println!(\"x := {x_old}; x.clone_from({y}); x = {x}\");\n    }\n}\n\n#[allow(clippy::redundant_clone, unused_must_use)]\nfn benchmark_natural_clone_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.clone()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.clone())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.clone())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.clone())),\n        ],\n    );\n}\n\nfn benchmark_natural_clone_from_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.clone_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (mut x, y))| x.clone_from(&y)),\n            (\"num\", &mut |((mut x, y), _, _)| x.clone_from(&y)),\n            (\"rug\", &mut |(_, (mut x, y), _)| x.clone_from(&y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/digits/from_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, PowerOf2Digits, SaturatingFrom, WrappingFrom,\n};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_1_vec_len_times_pair_2_bits_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_5, unsigned_vec_unsigned_pair_gen_var_12,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::digits::general_digits::{\n    from_digits_asc_large, from_digits_asc_limb, from_digits_desc_basecase, from_digits_desc_large,\n    from_digits_desc_limb, from_digits_desc_naive, from_digits_desc_naive_primitive,\n    limbs_from_digits_small_base, limbs_from_digits_small_base_basecase,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::pair_1_vec_len_times_pair_2_natural_bits_bucketer;\nuse malachite_nz::test_util::generators::{\n    natural_vec_natural_pair_gen_var_1, natural_vec_natural_pair_gen_var_2,\n    natural_vec_natural_pair_gen_var_3, natural_vec_natural_pair_gen_var_4,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_limbs_from_digits_small_base_basecase);\n    register_unsigned_demos!(runner, demo_limbs_from_digits_small_base_basecase_targeted);\n    register_unsigned_demos!(runner, demo_limbs_from_digits_small_base);\n    register_unsigned_demos!(runner, demo_limbs_from_digits_small_base_targeted);\n    register_unsigned_demos!(runner, demo_from_digits_desc_basecase);\n    register_unsigned_demos!(runner, demo_from_digits_desc_basecase_targeted);\n    register_unsigned_demos!(runner, demo_from_digits_asc_limb);\n    register_unsigned_demos!(runner, demo_from_digits_desc_limb);\n    register_unsigned_demos!(runner, demo_from_digits_asc_limb_targeted);\n    register_unsigned_demos!(runner, demo_from_digits_desc_limb_targeted);\n    register_demo!(runner, demo_from_digits_asc_large);\n    register_demo!(runner, demo_from_digits_desc_large);\n    register_demo!(runner, demo_from_digits_asc_large_targeted);\n    register_demo!(runner, demo_from_digits_desc_large_targeted);\n    register_unsigned_demos!(runner, demo_from_digits_asc_unsigned);\n    register_unsigned_demos!(runner, demo_from_digits_desc_unsigned);\n    register_unsigned_demos!(runner, demo_from_digits_asc_unsigned_targeted);\n    register_unsigned_demos!(runner, demo_from_digits_desc_unsigned_targeted);\n    register_demo!(runner, demo_from_digits_asc);\n    register_demo!(runner, demo_from_digits_desc);\n    register_demo!(runner, demo_from_digits_asc_targeted);\n    register_demo!(runner, demo_from_digits_desc_targeted);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_limbs_from_digits_small_base_basecase_algorithms\n    );\n    register_unsigned_benches!(runner, benchmark_limbs_from_digits_small_base_algorithms);\n    register_unsigned_benches!(runner, benchmark_from_digits_desc_basecase_algorithms);\n    register_unsigned_benches!(runner, benchmark_from_digits_asc_limb);\n    register_unsigned_benches!(runner, benchmark_from_digits_desc_limb_algorithms);\n    register_bench!(runner, benchmark_from_digits_asc_large);\n    register_bench!(runner, benchmark_from_digits_desc_large_algorithms);\n    register_unsigned_benches!(runner, benchmark_from_digits_asc_unsigned);\n    register_unsigned_benches!(runner, benchmark_from_digits_desc_unsigned_algorithms);\n    register_bench!(runner, benchmark_from_digits_asc);\n    register_bench!(runner, benchmark_from_digits_desc_algorithms);\n}\n\nfn demo_limbs_from_digits_small_base_basecase<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: WrappingFrom<T>,\n{\n    for (mut out, xs, base) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_out = out.to_vec();\n        let out_len = limbs_from_digits_small_base_basecase(&mut out, &xs, base);\n        println!(\n            \"out := {old_out:?}; \\\n            limbs_from_digits_small_base_basecase(&mut out, {xs:?}, {base}) = {out_len:?}; \\\n            out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_from_digits_small_base_basecase_targeted<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: WrappingFrom<T>,\n{\n    for (mut out, xs, base) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_out = out.to_vec();\n        let out_len = limbs_from_digits_small_base_basecase(&mut out, &xs, base).unwrap();\n        println!(\n            \"out := {old_out:?}; \\\n            limbs_from_digits_small_base_basecase(&mut out, {xs:?}, {base}) = {out_len}; \\\n            out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_from_digits_small_base<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: WrappingFrom<T>,\n{\n    for (mut out, xs, base) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_out = out.to_vec();\n        let out_len = limbs_from_digits_small_base(&mut out, &xs, base);\n        println!(\n            \"out := {old_out:?}; \\\n            limbs_from_digits_small_base(&mut out, {xs:?}, {base}) = {out_len:?}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_from_digits_small_base_targeted<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: WrappingFrom<T>,\n{\n    for (mut out, xs, base) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_out = out.to_vec();\n        let out_len = limbs_from_digits_small_base(&mut out, &xs, base).unwrap();\n        println!(\n            \"out := {old_out:?}; \\\n            limbs_from_digits_small_base(&mut out, {xs:?}, {base}) = {out_len}; \\\n            out = {out:?}\",\n        );\n    }\n}\n\nfn demo_from_digits_desc_basecase<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: SaturatingFrom<T> + WrappingFrom<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_12::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_desc_basecase(&{:?}, {}) = {:?}\",\n            xs,\n            base,\n            from_digits_desc_basecase(&xs, base)\n        );\n    }\n}\n\nfn demo_from_digits_desc_basecase_targeted<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: SaturatingFrom<T> + WrappingFrom<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_desc_basecase(&{:?}, {}) = {}\",\n            xs,\n            base,\n            from_digits_desc_basecase(&xs, base).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_asc_limb<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_12::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_asc_limb(&{:?}, {}) = {:?}\",\n            xs.clone(),\n            base,\n            from_digits_asc_limb(xs.into_iter(), base)\n        );\n    }\n}\n\nfn demo_from_digits_desc_limb<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_12::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_desc_limb(&{:?}, {}) = {:?}\",\n            xs.clone(),\n            base,\n            from_digits_desc_limb(xs.into_iter(), base)\n        );\n    }\n}\n\nfn demo_from_digits_asc_limb_targeted<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_asc_limb(&{:?}, {}) = {}\",\n            xs.clone(),\n            base,\n            from_digits_asc_limb(xs.into_iter(), base).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_desc_limb_targeted<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_12::<T, Limb>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_desc_limb(&{:?}, {}) = {}\",\n            xs.clone(),\n            base,\n            from_digits_desc_limb(xs.into_iter(), base).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_asc_large(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_asc_large(&{:?}, {}) = {:?}\",\n            xs.clone(),\n            base,\n            from_digits_asc_large(xs.into_iter(), &base)\n        );\n    }\n}\n\nfn demo_from_digits_desc_large(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_desc_large(&{:?}, {}) = {:?}\",\n            xs.clone(),\n            base,\n            from_digits_desc_large(xs.into_iter(), &base)\n        );\n    }\n}\n\nfn demo_from_digits_asc_large_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_asc_large(&{:?}, {}) = {}\",\n            xs.clone(),\n            base,\n            from_digits_asc_large(xs.into_iter(), &base).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_desc_large_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_digits_desc_large(&{:?}, {}) = {}\",\n            xs.clone(),\n            base,\n            from_digits_desc_large(xs.into_iter(), &base).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_asc_unsigned<T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: SaturatingFrom<T>,\n    Natural: Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_asc({}, &{:?}) = {:?}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_asc(&base, xs.into_iter())\n        );\n    }\n}\n\nfn demo_from_digits_desc_unsigned<T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: SaturatingFrom<T>,\n    Natural: Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_desc({}, &{:?}) = {:?}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_desc(&base, xs.into_iter())\n        );\n    }\n}\n\nfn demo_from_digits_asc_unsigned_targeted<\n    T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: SaturatingFrom<T>,\n    Natural: Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_5::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_asc({}, &{:?}) = {}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_asc(&base, xs.into_iter()).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_desc_unsigned_targeted<\n    T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: SaturatingFrom<T>,\n    Natural: Digits<T>,\n{\n    for (xs, base) in unsigned_vec_unsigned_pair_gen_var_5::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_desc({}, &{:?}) = {}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_desc(&base, xs.into_iter()).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_asc({}, &{:?}) = {:?}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_asc(&base, xs.into_iter())\n        );\n    }\n}\n\nfn demo_from_digits_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_desc({}, &{:?}) = {:?}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_desc(&base, xs.into_iter())\n        );\n    }\n}\n\nfn demo_from_digits_asc_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_asc({}, &{:?}) = {}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_asc(&base, xs.into_iter()).unwrap()\n        );\n    }\n}\n\nfn demo_from_digits_desc_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, base) in natural_vec_natural_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_digits_desc({}, &{:?}) = {}\",\n            base,\n            xs.clone(),\n            Natural::from_digits_desc(&base, xs.into_iter()).unwrap()\n        );\n    }\n}\n\nfn benchmark_limbs_from_digits_small_base_basecase_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: WrappingFrom<T>,\n    Natural: From<T>,\n{\n    run_benchmark(\n        &format!(\n            \"limbs_from_digits_small_base_basecase(&mut [Limb], &[{}], u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2::<T, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, xs, base)| {\n                no_out!(limbs_from_digits_small_base_basecase(&mut out, &xs, base).unwrap());\n            }),\n            (\"naive\", &mut |(_, xs, base)| {\n                from_digits_desc_naive_primitive(&xs, T::exact_from(base))\n                    .unwrap()\n                    .into_limbs_asc();\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_from_digits_small_base_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: WrappingFrom<T>,\n    Natural: From<T>,\n{\n    run_benchmark(\n        &format!(\n            \"limbs_from_digits_small_base(&mut [Limb], &[{}], u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2::<T, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"full\", &mut |(mut out, xs, base)| {\n                no_out!(limbs_from_digits_small_base(&mut out, &xs, base));\n            }),\n            (\"basecase\", &mut |(mut out, xs, base)| {\n                no_out!(limbs_from_digits_small_base_basecase(&mut out, &xs, base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_digits_desc_basecase_algorithms<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T>,\n{\n    run_benchmark(\n        &format!(\"from_digits_desc_basecase(&[{}], u64)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"default\", &mut |(xs, base)| {\n                no_out!(from_digits_desc_basecase(&xs, base).unwrap());\n            }),\n            (\"naive\", &mut |(xs, base)| {\n                from_digits_desc_naive_primitive(&xs, T::exact_from(base))\n                    .unwrap()\n                    .into_limbs_asc();\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_digits_asc_limb<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    run_benchmark(\n        &format!(\"from_digits_asc_limb(&[{}], Limb)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_bits_bucketer(\"xs\", \"base\"),\n        &mut [(\"Malachite\", &mut |(xs, base)| {\n            no_out!(from_digits_asc_limb(xs.into_iter(), base));\n        })],\n    );\n}\n\nfn benchmark_from_digits_desc_limb_algorithms<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    run_benchmark(\n        &format!(\"from_digits_desc_limb(&[{}], Limb)\", T::NAME),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_bits_bucketer(\"xs\", \"base\"),\n        &mut [\n            (\"full\", &mut |(xs, base)| {\n                no_out!(from_digits_desc_limb(xs.into_iter(), base));\n            }),\n            (\"basecase\", &mut |(xs, base)| {\n                no_out!(from_digits_desc_basecase(&xs, base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_digits_asc_large(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"from_digits_asc_large(&[Natural], Natural)\",\n        BenchmarkType::Single,\n        natural_vec_natural_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_natural_bits_bucketer(\"xs\", \"base\"),\n        &mut [(\"Malachite\", &mut |(xs, base)| {\n            no_out!(from_digits_desc_large(xs.into_iter(), &base));\n        })],\n    );\n}\n\nfn benchmark_from_digits_desc_large_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"from_digits_desc_large(&[Natural], Natural)\",\n        BenchmarkType::Algorithms,\n        natural_vec_natural_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_natural_bits_bucketer(\"xs\", \"base\"),\n        &mut [\n            (\"large\", &mut |(xs, base)| {\n                no_out!(from_digits_desc_large(xs.into_iter(), &base));\n            }),\n            (\"naive\", &mut |(xs, base)| {\n                no_out!(from_digits_desc_naive(&xs, &base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_digits_asc_unsigned<T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Digits<T>,\n{\n    run_benchmark(\n        &format!(\n            \"Natural::from_digits_asc({}, Iterator<Item = {}>)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_5::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, base)| {\n            no_out!(Natural::from_digits_asc(&base, xs.into_iter()));\n        })],\n    );\n}\n\nfn benchmark_from_digits_desc_unsigned_algorithms<\n    T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Digits<T> + From<T>,\n{\n    run_benchmark(\n        &format!(\n            \"Natural::from_digits_desc({}, Iterator<Item = {}>)\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_5::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"default\", &mut |(xs, base)| {\n                no_out!(Natural::from_digits_desc(&base, xs.into_iter()));\n            }),\n            (\"naive\", &mut |(xs, base)| {\n                from_digits_desc_naive_primitive(&xs, T::exact_from(base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_digits_asc(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural::from_digits_asc(&Natural, Iterator<Item = Natural>)\",\n        BenchmarkType::Single,\n        natural_vec_natural_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_natural_bits_bucketer(\"xs\", \"base\"),\n        &mut [(\"Malachite\", &mut |(xs, base)| {\n            no_out!(Natural::from_digits_asc(&base, xs.into_iter()));\n        })],\n    );\n}\n\nfn benchmark_from_digits_desc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_digits_desc(&Natural, Iterator<Item = Natural>)\",\n        BenchmarkType::Algorithms,\n        natural_vec_natural_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_natural_bits_bucketer(\"xs\", \"base\"),\n        &mut [\n            (\"default\", &mut |(xs, base)| {\n                no_out!(Natural::from_digits_desc(&base, xs.into_iter()));\n            }),\n            (\"naive\", &mut |(xs, base)| {\n                from_digits_desc_naive(&xs, &base);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/digits/from_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::PowerOf2Digits;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_10, unsigned_vec_unsigned_pair_gen_var_11,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_vec_len_times_pair_2_bucketer;\nuse malachite_nz::test_util::generators::{\n    natural_vec_unsigned_pair_gen_var_1, natural_vec_unsigned_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_from_power_of_2_digits_asc);\n    register_unsigned_demos!(runner, demo_from_power_of_2_digits_desc);\n    register_unsigned_demos!(runner, demo_from_power_of_2_digits_asc_targeted);\n    register_unsigned_demos!(runner, demo_from_power_of_2_digits_desc_targeted);\n    register_demo!(runner, demo_natural_from_power_of_2_digits_asc_natural);\n    register_demo!(runner, demo_natural_from_power_of_2_digits_desc_natural);\n    register_demo!(\n        runner,\n        demo_natural_from_power_of_2_digits_asc_natural_targeted\n    );\n    register_demo!(\n        runner,\n        demo_natural_from_power_of_2_digits_desc_natural_targeted\n    );\n\n    register_unsigned_benches!(runner, benchmark_from_power_of_2_digits_asc_algorithms);\n    register_unsigned_benches!(runner, benchmark_from_power_of_2_digits_desc);\n    register_bench!(\n        runner,\n        benchmark_natural_from_power_of_2_digits_asc_natural_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_from_power_of_2_digits_desc_natural\n    );\n}\n\nfn demo_from_power_of_2_digits_asc<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    for (digits, log_base) in unsigned_vec_unsigned_pair_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_power_of_2_digits_asc({}, {:?}) = {:?}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied())\n        );\n    }\n}\n\nfn demo_from_power_of_2_digits_desc<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    for (digits, log_base) in unsigned_vec_unsigned_pair_gen_var_11::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_power_of_2_digits_desc({}, {:?}) = {:?}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied())\n        );\n    }\n}\n\nfn demo_from_power_of_2_digits_asc_targeted<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    for (digits, log_base) in unsigned_vec_unsigned_pair_gen_var_10::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_power_of_2_digits_asc({}, {:?}) = {}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap()\n        );\n    }\n}\n\nfn demo_from_power_of_2_digits_desc_targeted<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    for (digits, log_base) in unsigned_vec_unsigned_pair_gen_var_10::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_power_of_2_digits_desc({}, {:?}) = {}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap()\n        );\n    }\n}\n\nfn demo_natural_from_power_of_2_digits_asc_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (digits, log_base) in natural_vec_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural.from_power_of_2_digits_asc({}, {:?}) = {:?}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned())\n        );\n    }\n}\n\nfn demo_natural_from_power_of_2_digits_desc_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (digits, log_base) in natural_vec_unsigned_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural.from_power_of_2_digits_desc({}, {:?}) = {:?}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned())\n        );\n    }\n}\n\nfn demo_natural_from_power_of_2_digits_asc_natural_targeted(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (digits, log_base) in natural_vec_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural.from_power_of_2_digits_asc({}, {:?}) = {}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned()).unwrap()\n        );\n    }\n}\n\nfn demo_natural_from_power_of_2_digits_desc_natural_targeted(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (digits, log_base) in natural_vec_unsigned_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural.from_power_of_2_digits_desc({}, {:?}) = {}\",\n            log_base,\n            digits,\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned()).unwrap()\n        );\n    }\n}\n\nfn benchmark_from_power_of_2_digits_asc_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    run_benchmark(\n        &format!(\n            \"PowerOf2Digits::<Natural>::from_power_of_2_digits_asc\\\n                <I: Iterator<Item={}>>(I, u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_10::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"digits\"),\n        &mut [\n            (\"default\", &mut |(digits, log_base)| {\n                no_out!(Natural::from_power_of_2_digits_asc(\n                    log_base,\n                    digits.into_iter()\n                ));\n            }),\n            (\"naive\", &mut |(digits, log_base)| {\n                no_out!(Natural::from_power_of_2_digits_asc_naive(\n                    log_base,\n                    digits.into_iter()\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_power_of_2_digits_desc<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    run_benchmark(\n        &format!(\n            \"PowerOf2Digits::<Natural>::from_power_of_2_digits_desc\\\n                <I: Iterator<Item={}>>(I, u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_10::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"digits\"),\n        &mut [(\"Malachite\", &mut |(digits, log_base)| {\n            no_out!(Natural::from_power_of_2_digits_desc(\n                log_base,\n                digits.into_iter()\n            ));\n        })],\n    );\n}\n\nfn benchmark_natural_from_power_of_2_digits_asc_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_power_of_2_digits_asc<I: Iterator<Item=Natural>>(u64, I)\",\n        BenchmarkType::Algorithms,\n        natural_vec_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_bucketer(\"digits\", \"log_base\"),\n        &mut [\n            (\"default\", &mut |(digits, log_base)| {\n                no_out!(Natural::from_power_of_2_digits_asc(\n                    log_base,\n                    digits.into_iter()\n                ));\n            }),\n            (\"naive\", &mut |(digits, log_base)| {\n                no_out!(Natural::from_power_of_2_digits_asc_natural_naive(\n                    log_base,\n                    digits.into_iter()\n                ));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_power_of_2_digits_desc_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_power_of_2_digits_desc<I: Iterator<Item=Natural>>(u64, I)\",\n        BenchmarkType::Single,\n        natural_vec_unsigned_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_times_pair_2_bucketer(\"digits\", \"log_base\"),\n        &mut [(\"Malachite\", &mut |(digits, log_base)| {\n            no_out!(Natural::from_power_of_2_digits_desc(\n                log_base,\n                digits.into_iter()\n            ));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_digits::register(runner);\n    from_power_of_2_digits::register(runner);\n    power_of_2_digits::register(runner);\n    to_digits::register(runner);\n    to_power_of_2_digits::register(runner);\n}\n\nmod from_digits;\nmod from_power_of_2_digits;\nmod power_of_2_digits;\nmod to_digits;\nmod to_power_of_2_digits;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/digits/power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, PowerOf2DigitIterable, PowerOf2DigitIterator, PowerOf2Digits,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_1_natural_bit_bucketer, triple_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_6, natural_unsigned_pair_gen_var_7,\n    natural_unsigned_unsigned_triple_gen_var_2, natural_unsigned_unsigned_triple_gen_var_3,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_power_of_2_digits);\n    register_unsigned_demos!(runner, demo_natural_power_of_2_digits_rev);\n    register_unsigned_demos!(runner, demo_natural_power_of_2_digits_size_hint);\n    register_unsigned_demos!(runner, demo_natural_power_of_2_digits_get_digit);\n    register_demo!(runner, demo_natural_power_of_2_digits_natural);\n    register_demo!(runner, demo_natural_power_of_2_digits_rev_natural);\n    register_demo!(runner, demo_natural_power_of_2_digits_size_hint_natural);\n    register_demo!(runner, demo_natural_power_of_2_digits_get_digit_natural);\n\n    register_unsigned_benches!(runner, benchmark_natural_power_of_2_digits_size_hint);\n    register_unsigned_benches!(\n        runner,\n        benchmark_natural_power_of_2_digits_get_digit_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_power_of_2_digits_size_hint_natural\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_power_of_2_digits_get_digit_natural_algorithms\n    );\n}\n\nfn demo_natural_power_of_2_digits<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n{\n    for (n, log_base) in natural_unsigned_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}) = {:?}\",\n            n,\n            log_base,\n            PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base).collect_vec()\n        );\n    }\n}\n\nfn demo_natural_power_of_2_digits_rev<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n{\n    for (n, log_base) in natural_unsigned_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).rev() = {:?}\",\n            n,\n            log_base,\n            PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base)\n                .rev()\n                .collect_vec()\n        );\n    }\n}\n\nfn demo_natural_power_of_2_digits_size_hint<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n{\n    for (n, log_base) in natural_unsigned_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).size_hint() = {:?}\",\n            n,\n            log_base,\n            PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base).size_hint()\n        );\n    }\n}\n\nfn demo_natural_power_of_2_digits_get_digit<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n{\n    for (n, log_base, i) in natural_unsigned_unsigned_triple_gen_var_2::<u64, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).get_digit({}) = {:?}\",\n            n,\n            log_base,\n            i,\n            PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base).get_digit(i)\n        );\n    }\n}\n\nfn demo_natural_power_of_2_digits_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}) = {:?}\",\n            n,\n            log_base,\n            PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base).collect_vec()\n        );\n    }\n}\n\nfn demo_natural_power_of_2_digits_rev_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).rev() = {:?}\",\n            n,\n            log_base,\n            PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base)\n                .rev()\n                .collect_vec()\n        );\n    }\n}\n\nfn demo_natural_power_of_2_digits_size_hint_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).size_hint() = {:?}\",\n            n,\n            log_base,\n            PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base).size_hint()\n        );\n    }\n}\n\nfn demo_natural_power_of_2_digits_get_digit_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base, i) in natural_unsigned_unsigned_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"power_of_2_digits({}, {}).get_digit({}) = {:?}\",\n            n,\n            log_base,\n            i,\n            PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base).get_digit(i)\n        );\n    }\n}\n\nfn benchmark_natural_power_of_2_digits_size_hint<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n{\n    run_benchmark(\n        &format!(\n            \"PowerOf2DigitIterable::<{}>::power_of_2_digits(&Natural, u64).size_hint()\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\n            &format!(\n                \"PowerOf2DigitIterable::<{}>::power_of_2_digits(&Natural, u64).size_hint()\",\n                T::NAME\n            ),\n            &mut |(n, log_base)| {\n                no_out!(PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base).size_hint());\n            },\n        )],\n    );\n}\n\nfn benchmark_natural_power_of_2_digits_get_digit_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n    Natural: PowerOf2Digits<T>,\n{\n    run_benchmark(\n        &format!(\n            \"PowerOf2DigitIterable::<{}>::power_of_2_digits(&Natural, u64).get_digit(u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        natural_unsigned_unsigned_triple_gen_var_2::<u64, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"power_of_2_digits(&Natural, u64).get_digit(u64)\",\n                &mut |(n, log_base, i)| {\n                    no_out!(\n                        PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base).get_digit(i)\n                    );\n                },\n            ),\n            (\n                \"Natural.to_power_of_2_digits_asc(u64)[u64]\",\n                &mut |(n, log_base, i)| {\n                    let digits = PowerOf2Digits::<T>::to_power_of_2_digits_asc(&n, log_base);\n                    let i = usize::exact_from(i);\n                    if i >= digits.len() {\n                        T::ZERO\n                    } else {\n                        digits[i]\n                    };\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_power_of_2_digits_size_hint_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"PowerOf2DigitIterable::<Natural>::power_of_2_digits(&Natural, u64).size_hint()\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\n            \"PowerOf2DigitIterable::<Natural>::power_of_2_digits(&Natural, u64).size_hint()\",\n            &mut |(n, log_base)| {\n                no_out!(\n                    PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base).size_hint()\n                );\n            },\n        )],\n    );\n}\n\n#[allow(clippy::let_unit_value)]\nfn benchmark_natural_power_of_2_digits_get_digit_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"PowerOf2DigitIterable::<Natural>::power_of_2_digits(&Natural, u64).get_digit(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_unsigned_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"power_of_2_digits(&Natural, u64).get_digit(u64)\",\n                &mut |(n, log_base, i)| {\n                    no_out!(\n                        PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base)\n                            .get_digit(i)\n                    );\n                },\n            ),\n            (\n                \"Natural.to_power_of_2_digits_asc(u64)[u64]\",\n                &mut |(n, log_base, i)| {\n                    let digits = PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, log_base);\n                    let i = usize::exact_from(i);\n                    let _result = if i >= digits.len() {\n                        let _ = Natural::ZERO;\n                    } else {\n                        let _ = digits[i];\n                    };\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/digits/to_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, Digits, PowerOf2Digits, SaturatingFrom,\n};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, quadruple_3_vec_len_bucketer, triple_3_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::digits::general_digits::{\n    limbs_to_digits_basecase, limbs_to_digits_small_base, limbs_to_digits_small_base_basecase,\n    to_digits_asc_large, to_digits_asc_limb, to_digits_asc_naive, to_digits_asc_naive_primitive,\n    to_digits_desc_large, to_digits_desc_limb,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_ratio_bucketer, pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_limbs_to_digits_small_base_basecase);\n    register_unsigned_demos!(runner, demo_limbs_to_digits_small_base);\n    register_unsigned_demos!(runner, demo_limbs_to_digits_basecase);\n    register_unsigned_demos!(runner, demo_to_digits_asc_limb);\n    register_unsigned_demos!(runner, demo_to_digits_desc_limb);\n    register_demo!(runner, demo_to_digits_asc_large);\n    register_demo!(runner, demo_to_digits_desc_large);\n    register_unsigned_demos!(runner, demo_to_digits_asc);\n    register_unsigned_demos!(runner, demo_to_digits_desc);\n    register_demo!(runner, demo_to_digits_asc_natural);\n    register_demo!(runner, demo_to_digits_desc_natural);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_limbs_to_digits_small_base_basecase_algorithms\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_limbs_to_digits_small_base_basecase_algorithms_2\n    );\n    register_unsigned_benches!(runner, benchmark_limbs_to_digits_small_base_algorithms);\n    register_unsigned_benches!(runner, benchmark_limbs_to_digits_basecase_algorithms);\n    register_unsigned_benches!(runner, benchmark_to_digits_asc_limb);\n    register_unsigned_benches!(runner, benchmark_to_digits_desc_limb);\n    register_bench!(runner, benchmark_to_digits_asc_large);\n    register_bench!(runner, benchmark_to_digits_desc_large);\n    register_unsigned_benches!(runner, benchmark_to_digits_asc_algorithms);\n    register_unsigned_benches!(runner, benchmark_to_digits_desc);\n    register_bench!(runner, benchmark_to_digits_asc_natural_algorithms);\n    register_bench!(runner, benchmark_to_digits_desc_natural);\n}\n\nfn demo_limbs_to_digits_small_base_basecase<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut out, len, xs, base) in\n        unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1::<T>()\n            .get(gm, config)\n            .take(limit)\n    {\n        let old_out = out.to_vec();\n        let out_len = limbs_to_digits_small_base_basecase(&mut out, len, &xs, base);\n        println!(\n            \"out := {old_out:?}; \\\n            limbs_to_digits_small_base_basecase(&mut out, {len}, {xs:?}, {base}) = {out_len}; \\\n            out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_to_digits_small_base<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut out, base, mut xs) in unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_out = out.to_vec();\n        let out_len = limbs_to_digits_small_base(&mut out, base, &mut xs, None);\n        println!(\n            \"out := {old_out:?}; \\\n            limbs_to_digits_small_base(&mut out, {base}, {xs:?}) = {out_len}; out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_to_digits_basecase<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: SaturatingFrom<T>,\n{\n    for (mut xs, base) in unsigned_vec_unsigned_pair_gen_var_4::<Limb, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        let mut digits = Vec::new();\n        limbs_to_digits_basecase::<T>(&mut digits, &mut xs, base);\n        println!(\n            \"limbs_to_digits_basecase(&mut digits, &{xs_old:?}, {base}); \\\n            digits = {digits:?}\"\n        );\n    }\n}\n\nfn demo_to_digits_asc_limb<\n    T: ConvertibleFrom<Limb> + for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: Digits<T> + SaturatingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    for (x, base) in natural_unsigned_pair_gen_var_1::<Limb, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_digits_asc_limb({}, {}) = {:?}\",\n            x,\n            base,\n            to_digits_asc_limb::<T>(&x, base)\n        );\n    }\n}\n\nfn demo_to_digits_desc_limb<\n    T: ConvertibleFrom<Limb> + for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Limb: Digits<T> + SaturatingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    for (x, base) in natural_unsigned_pair_gen_var_1::<Limb, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_digits_desc_limb({}, {}) = {:?}\",\n            x,\n            base,\n            to_digits_desc_limb::<T>(&x, base)\n        );\n    }\n}\n\nfn demo_to_digits_asc_large(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"to_digits_asc_large({}, {}) = {:?}\",\n            x,\n            base,\n            to_digits_asc_large(&x, &base)\n        );\n    }\n}\n\nfn demo_to_digits_desc_large(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"to_digits_asc_large({}, {}) = {:?}\",\n            x,\n            base,\n            to_digits_desc_large(&x, &base)\n        );\n    }\n}\n\nfn demo_to_digits_asc<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Digits<T>,\n{\n    for (x, base) in natural_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_digits_asc({}, {}) = {:?}\",\n            x,\n            base,\n            x.to_digits_asc(&base)\n        );\n    }\n}\n\nfn demo_to_digits_desc<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: Digits<T>,\n{\n    for (x, base) in natural_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_digits_desc({}, {}) = {:?}\",\n            x,\n            base,\n            x.to_digits_desc(&base)\n        );\n    }\n}\n\nfn demo_to_digits_asc_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"to_digits_asc({}, {}) = {:?}\",\n            x,\n            base,\n            x.to_digits_asc(&base)\n        );\n    }\n}\n\nfn demo_to_digits_desc_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"to_digits_desc({}, {}) = {:?}\",\n            x,\n            base,\n            x.to_digits_desc(&base)\n        );\n    }\n}\n\nfn benchmark_limbs_to_digits_small_base_basecase_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"limbs_to_digits_small_base_basecase(&mut [{}], usize, &[Limb], u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut out, len, xs, base)| {\n                no_out!(limbs_to_digits_small_base_basecase(\n                    &mut out, len, &xs, base\n                ));\n            }),\n            (\"naive\", &mut |(_, _, xs, base)| {\n                let mut digits = Vec::new();\n                to_digits_asc_naive_primitive(\n                    &mut digits,\n                    &Natural::from_owned_limbs_asc(xs),\n                    base,\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_to_digits_small_base_basecase_algorithms_2<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"limbs_to_digits_small_base_basecase(&mut [{}], usize, &[Limb], u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_to_digits_small_base_basecase\", &mut |(\n                mut out,\n                _,\n                xs,\n                base,\n            )| {\n                no_out!(limbs_to_digits_small_base_basecase(&mut out, 0, &xs, base));\n            }),\n            (\"limbs_to_digits_small_base\", &mut |(\n                mut out,\n                _,\n                mut xs,\n                base,\n            )| {\n                no_out!(limbs_to_digits_small_base(&mut out, base, &mut xs, None));\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_to_digits_small_base_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"limbs_to_digits_small_base(&mut [{}], u64, &[Limb])\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"default\", &mut |(mut out, base, mut xs)| {\n                no_out!(limbs_to_digits_small_base(&mut out, base, &mut xs, None));\n            }),\n            (\"naive\", &mut |(_, base, xs)| {\n                let mut digits = Vec::new();\n                to_digits_asc_naive_primitive(\n                    &mut digits,\n                    &Natural::from_owned_limbs_asc(xs),\n                    base,\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_limbs_to_digits_basecase_algorithms<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: Digits<T> + SaturatingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    run_benchmark(\n        \"limbs_to_digits_basecase(&mut [Limb], u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_vec_unsigned_pair_gen_var_4::<Limb, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"basecase\", &mut |(mut xs, base)| {\n                let mut digits = Vec::new();\n                limbs_to_digits_basecase::<T>(&mut digits, &mut xs, base);\n            }),\n            (\"full\", &mut |(xs, base)| {\n                to_digits_asc_limb::<T>(&Natural::from_owned_limbs_asc(xs), base);\n            }),\n        ],\n    );\n}\n\nfn benchmark_to_digits_asc_limb<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: Digits<T> + SaturatingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    run_benchmark(\n        \"to_digits_asc_limb(&Natural, Limb)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_1::<Limb, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            to_digits_asc_limb::<T>(&x, base);\n        })],\n    );\n}\n\nfn benchmark_to_digits_desc_limb<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Limb: Digits<T> + SaturatingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    run_benchmark(\n        \"to_digits_desc_limb(&Natural, Limb)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_1::<Limb, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            to_digits_desc_limb::<T>(&x, base);\n        })],\n    );\n}\n\nfn benchmark_to_digits_asc_large(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"to_digits_asc_large(&Natural, &Natural)\",\n        BenchmarkType::Single,\n        natural_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_ratio_bucketer(\"x\", \"base\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            to_digits_asc_large(&x, &base);\n        })],\n    );\n}\n\nfn benchmark_to_digits_desc_large(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"to_digits_desc_large(&Natural, &Natural)\",\n        BenchmarkType::Single,\n        natural_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_ratio_bucketer(\"x\", \"base\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            to_digits_desc_large(&x, &base);\n        })],\n    );\n}\n\nfn benchmark_to_digits_asc_algorithms<T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Digits<T> + From<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.to_digits_asc(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, base)| {\n                x.to_digits_asc(&base);\n            }),\n            (\"naive\", &mut |(x, base)| {\n                let mut digits = Vec::new();\n                to_digits_asc_naive_primitive(&mut digits, &x, base);\n            }),\n        ],\n    );\n}\n\nfn benchmark_to_digits_desc<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: Digits<T>,\n{\n    run_benchmark(\n        &format!(\"Natural.to_digits_desc(&{})\", T::NAME),\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            x.to_digits_desc(&base);\n        })],\n    );\n}\n\nfn benchmark_to_digits_asc_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"to_digits_asc::<Natural, Natural>(&Natural, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_ratio_bucketer(\"x\", \"base\"),\n        &mut [\n            (\"default\", &mut |(x, base)| no_out!(x.to_digits_asc(&base))),\n            (\"naive\", &mut |(x, base)| {\n                let mut digits: Vec<Natural> = Vec::new();\n                to_digits_asc_naive(&mut digits, &x, &base);\n            }),\n        ],\n    );\n}\n\nfn benchmark_to_digits_desc_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"to_digits_desc::<Natural, Natural>(&Natural, &Natural)\",\n        BenchmarkType::Single,\n        natural_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_ratio_bucketer(\"x\", \"base\"),\n        &mut [(\"Malachite\", &mut |(x, base)| {\n            no_out!(x.to_digits_desc(&base));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/digits/to_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{PowerOf2DigitIterable, PowerOf2Digits};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_6, natural_unsigned_pair_gen_var_7,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_to_power_of_2_digits_asc);\n    register_unsigned_demos!(runner, demo_to_power_of_2_digits_desc);\n    register_demo!(runner, demo_natural_to_power_of_2_digits_asc_natural);\n    register_demo!(runner, demo_natural_to_power_of_2_digits_desc_natural);\n\n    register_unsigned_benches!(runner, benchmark_to_power_of_2_digits_asc_algorithms);\n    register_unsigned_benches!(\n        runner,\n        benchmark_to_power_of_2_digits_asc_evaluation_strategy\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_to_power_of_2_digits_desc_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_to_power_of_2_digits_asc_natural_algorithms\n    );\n    register_bench!(runner, benchmark_natural_to_power_of_2_digits_desc_natural);\n}\n\nfn demo_to_power_of_2_digits_asc<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    for (n, log_base) in natural_unsigned_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_power_of_2_digits_asc({}) = {:?}\",\n            n,\n            log_base,\n            PowerOf2Digits::<T>::to_power_of_2_digits_asc(&n, log_base)\n        );\n    }\n}\n\nfn demo_to_power_of_2_digits_desc<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    for (n, log_base) in natural_unsigned_pair_gen_var_6::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_power_of_2_digits_desc({}) = {:?}\",\n            n,\n            log_base,\n            PowerOf2Digits::<T>::to_power_of_2_digits_desc(&n, log_base)\n        );\n    }\n}\n\nfn demo_natural_to_power_of_2_digits_asc_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_power_of_2_digits_asc({}) = {:?}\",\n            n,\n            log_base,\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, log_base)\n        );\n    }\n}\n\nfn demo_natural_to_power_of_2_digits_desc_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in natural_unsigned_pair_gen_var_7()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_power_of_2_digits_desc({}) = {:?}\",\n            n,\n            log_base,\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&n, log_base)\n        );\n    }\n}\n\nfn benchmark_to_power_of_2_digits_asc_algorithms<\n    T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PowerOf2Digits<T>,\n{\n    run_benchmark(\n        &format!(\n            \"PowerOf2Digits::<{}>::to_power_of_2_digits_asc(&Natural, u64)\",\n            T::NAME\n        ),\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, log_base)| {\n                no_out!(PowerOf2Digits::<T>::to_power_of_2_digits_asc(&n, log_base));\n            }),\n            (\"naive\", &mut |(n, log_base)| {\n                no_out!(Natural::to_power_of_2_digits_asc_naive::<T>(&n, log_base));\n            }),\n            (\"using iterator\", &mut |(n, log_base)| {\n                no_out!(\n                    PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base).collect_vec()\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_to_power_of_2_digits_asc_evaluation_strategy<\n    T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PowerOf2Digits<T>,\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n{\n    run_benchmark(\n        &format!(\n            \"PowerOf2Digits::<{}>::to_power_of_2_digits_asc(&Natural, u64)\",\n            T::NAME\n        ),\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, log_base)| {\n                no_out!(PowerOf2Digits::<T>::to_power_of_2_digits_asc(&n, log_base));\n            }),\n            (\n                \"Natural.power_of_2_digits(u64).collect_vec()\",\n                &mut |(n, log_base)| {\n                    no_out!(\n                        PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base).collect_vec()\n                    );\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_to_power_of_2_digits_desc_evaluation_strategy<\n    T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: PowerOf2Digits<T>,\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n{\n    run_benchmark(\n        &format!(\n            \"PowerOf2Digits::<{}>::to_power_of_2_digits_desc(&Natural, u64)\",\n            T::NAME\n        ),\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, log_base)| {\n                no_out!(PowerOf2Digits::<T>::to_power_of_2_digits_desc(&n, log_base));\n            }),\n            (\n                \"Natural.power_of_2_digits(u64).rev().collect_vec()\",\n                &mut |(n, log_base)| {\n                    no_out!(\n                        PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base)\n                            .rev()\n                            .collect_vec()\n                    );\n                },\n            ),\n        ],\n    );\n}\n\nfn benchmark_natural_to_power_of_2_digits_asc_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&Natural, u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, log_base)| {\n                no_out!(PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(\n                    &n, log_base\n                ));\n            }),\n            (\"naive\", &mut |(n, log_base)| {\n                no_out!(n.to_power_of_2_digits_asc_natural_naive(log_base));\n            }),\n            (\"using iterator\", &mut |(n, log_base)| {\n                no_out!(\n                    PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base)\n                        .rev()\n                        .collect_vec()\n                );\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_to_power_of_2_digits_desc_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&Natural, u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, log_base)| {\n            no_out!(PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(\n                &n, log_base\n            ));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/floating_point_from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::primitive_float_from_natural::PrimitiveFloatFromNaturalError;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_var_3, natural_rounding_mode_pair_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_rounding_from_natural);\n    register_primitive_float_demos!(runner, demo_float_try_from_natural);\n    register_primitive_float_demos!(runner, demo_float_exact_from_natural);\n    register_primitive_float_demos!(runner, demo_float_convertible_from_natural);\n\n    register_primitive_float_benches!(runner, benchmark_float_rounding_from_natural);\n    register_primitive_float_benches!(runner, benchmark_float_try_from_natural);\n    register_primitive_float_benches!(runner, benchmark_float_exact_from_natural);\n    register_primitive_float_benches!(runner, benchmark_float_convertible_from_natural);\n}\n\nfn demo_float_rounding_from_natural<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat + for<'a> RoundingFrom<&'a Natural>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in natural_rounding_mode_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = T::rounding_from(&n, rm);\n        println!(\n            \"{}::rounding_from(&{}, {}) = {:?}\",\n            T::NAME,\n            n,\n            rm,\n            (NiceFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_try_from_natural<\n    T: for<'a> TryFrom<&'a Natural, Error = PrimitiveFloatFromNaturalError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from(&{}) = {:?}\",\n            T::NAME,\n            n.clone(),\n            T::try_from(&n).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_float_exact_from_natural<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    for n in natural_gen_var_3::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::exact_from(&{}) = {}\",\n            T::NAME,\n            n.clone(),\n            NiceFloat(T::exact_from(&n))\n        );\n    }\n}\n\nfn demo_float_convertible_from_natural<T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        if T::convertible_from(&n) {\n            println!(\"{} is convertible to an {}\", n, T::NAME);\n        } else {\n            println!(\"{} is not convertible to an {}\", n, T::NAME);\n        }\n    }\n}\n\nfn benchmark_float_rounding_from_natural<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat + for<'a> RoundingFrom<&'a Natural>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::rounding_from(Natural, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        natural_rounding_mode_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, rm)| {\n            no_out!(T::rounding_from(&n, rm));\n        })],\n    );\n}\n\nfn benchmark_float_try_from_natural<T: for<'a> TryFrom<&'a Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::try_from(Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::try_from(&n).ok()))],\n    );\n}\n\nfn benchmark_float_exact_from_natural<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    run_benchmark(\n        &format!(\"{}::exact_from(Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(&n)))],\n    );\n}\n\nfn benchmark_float_convertible_from_natural<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::convertible_from(Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::convertible_from(&n)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::bool_gen;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_from_bool);\n}\n\nfn demo_natural_from_bool(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in bool_gen().get(gm, config).take(limit) {\n        println!(\"Natural::from({}) = {}\", b, Natural::from(b));\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/from_floating_point.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_primitive_float_bucketer, primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_gen_var_2, primitive_float_rounding_mode_pair_gen_var_1,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_natural_rounding_from_float);\n    register_primitive_float_demos!(runner, demo_natural_try_from_float);\n    register_primitive_float_demos!(runner, demo_natural_exact_from_float);\n    register_primitive_float_demos!(runner, demo_natural_convertible_from_float);\n\n    register_primitive_float_benches!(runner, benchmark_natural_rounding_from_float);\n    register_primitive_float_benches!(runner, benchmark_natural_try_from_float);\n    register_primitive_float_benches!(runner, benchmark_natural_exact_from_float);\n    register_primitive_float_benches!(runner, benchmark_natural_convertible_from_float_algorithms);\n}\n\nfn demo_natural_rounding_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: RoundingFrom<T>,\n{\n    for (f, rm) in primitive_float_rounding_mode_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::rounding_from({}, {}) = {:?}\",\n            NiceFloat(f),\n            rm,\n            Natural::rounding_from(f, rm)\n        );\n    }\n}\n\nfn demo_natural_try_from_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Natural::try_from({}) = {:?}\",\n            NiceFloat(f),\n            Natural::try_from(f)\n        );\n    }\n}\n\nfn demo_natural_exact_from_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: ExactFrom<T>,\n{\n    for f in primitive_float_gen_var_2::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Natural::exact_from({}) = {}\",\n            NiceFloat(f),\n            Natural::exact_from(f)\n        );\n    }\n}\n\nfn demo_natural_convertible_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ConvertibleFrom<T>,\n{\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        if Natural::convertible_from(f) {\n            println!(\"{} is convertible to a Natural\", NiceFloat(f));\n        } else {\n            println!(\"{} is not convertible to a Natural\", NiceFloat(f));\n        }\n    }\n}\n\nfn benchmark_natural_rounding_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: RoundingFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Natural::rounding_from({}, RoundingMode)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_rounding_mode_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |(f, rm)| {\n            no_out!(Natural::rounding_from(f, rm));\n        })],\n    );\n}\n\nfn benchmark_natural_try_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Natural::try_from({})\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Natural::try_from(f).ok()))],\n    );\n}\n\nfn benchmark_natural_exact_from_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ExactFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Natural::exact_from({})\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_2::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Natural::exact_from(f)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_convertible_from_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: TryFrom<T> + ConvertibleFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Natural::convertible_from({})\", T::NAME),\n        BenchmarkType::Algorithms,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"standard\", &mut |f| no_out!(Natural::convertible_from(f))),\n            (\"using try_from\", &mut |f| {\n                no_out!(Natural::try_from(f).is_ok());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/from_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_from_limbs_asc);\n    register_demo!(runner, demo_natural_from_limbs_desc);\n    register_demo!(runner, demo_natural_from_owned_limbs_asc);\n    register_demo!(runner, demo_natural_from_owned_limbs_desc);\n    register_bench!(runner, benchmark_natural_from_limbs_asc_evaluation_strategy);\n    register_bench!(\n        runner,\n        benchmark_natural_from_limbs_desc_evaluation_strategy\n    );\n}\n\nfn demo_natural_from_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_limbs_asc({:?}) = {:?}\",\n            xs,\n            Natural::from_limbs_asc(&xs)\n        );\n    }\n}\n\nfn demo_natural_from_limbs_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_limbs_desc({:?}) = {:?}\",\n            xs,\n            Natural::from_limbs_desc(&xs)\n        );\n    }\n}\n\nfn demo_natural_from_owned_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_owned_limbs_asc({:?}) = {:?}\",\n            xs,\n            Natural::from_owned_limbs_asc(xs.clone())\n        );\n    }\n}\n\nfn demo_natural_from_owned_limbs_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_owned_limbs_desc({:?}) = {:?}\",\n            xs,\n            Natural::from_owned_limbs_desc(xs.clone())\n        );\n    }\n}\n\nfn benchmark_natural_from_limbs_asc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.from_limbs_asc(&[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"Natural::from_limbs_asc(&[u32])\", &mut |ref xs| {\n                no_out!(Natural::from_limbs_asc(xs));\n            }),\n            (\"Natural::from_owned_limbs_asc(&[u32])\", &mut |xs| {\n                no_out!(Natural::from_owned_limbs_asc(xs));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_limbs_desc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.from_limbs_desc(&[Limb])\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"Natural::from_limbs_desc(&[u32])\", &mut |ref xs| {\n                no_out!(Natural::from_limbs_desc(xs));\n            }),\n            (\"Natural::from_owned_limbs_desc(&[u32])\", &mut |xs| {\n                no_out!(Natural::from_owned_limbs_desc(xs));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, signed_gen_var_2, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::from_primitive_int::NaturalFromSignedError;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_natural_from_unsigned);\n    register_signed_demos!(runner, demo_natural_try_from_signed);\n    register_signed_demos!(runner, demo_natural_exact_from_signed);\n    register_signed_demos!(runner, demo_natural_saturating_from_signed);\n    register_signed_demos!(runner, demo_natural_convertible_from_signed);\n    register_demo!(runner, demo_natural_const_from);\n\n    register_unsigned_benches!(runner, benchmark_natural_from_unsigned);\n    register_signed_benches!(runner, benchmark_natural_try_from_signed);\n    register_signed_benches!(runner, benchmark_natural_exact_from_signed);\n    register_signed_benches!(runner, benchmark_natural_saturating_from_signed);\n    register_signed_benches!(runner, benchmark_natural_convertible_from_signed);\n    register_bench!(runner, benchmark_natural_const_from);\n}\n\nfn demo_natural_from_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: From<T>,\n{\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Natural::from({}) = {}\", u, Natural::from(u));\n    }\n}\n\nfn demo_natural_try_from_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: TryFrom<T, Error = NaturalFromSignedError>,\n{\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Natural::try_from({}) = {:?}\", i, Natural::try_from(i));\n    }\n}\n\nnatural_signed_single_arg_demo_with_trait!(\n    demo_natural_exact_from_signed,\n    exact_from,\n    signed_gen_var_2,\n    ExactFrom\n);\nnatural_signed_single_arg_demo_with_trait!(\n    demo_natural_saturating_from_signed,\n    saturating_from,\n    signed_gen,\n    SaturatingFrom\n);\n\nfn demo_natural_convertible_from_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ConvertibleFrom<T>,\n{\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Limb\",\n            i,\n            if Natural::convertible_from(i) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn demo_natural_const_from(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen().get(gm, config).take(limit) {\n        println!(\"Natural::const_from({}) = {}\", u, Natural::const_from(u));\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_from_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: From<T>,\n{\n    run_benchmark(\n        &format!(\"Natural::from({})\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(Natural::from(u)))],\n    );\n}\n\nfn benchmark_natural_try_from_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Natural::try_from({})\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(Natural::try_from(x).ok()))],\n    );\n}\n\nnatural_signed_single_arg_bench_with_trait!(\n    benchmark_natural_exact_from_signed,\n    exact_from,\n    signed_gen_var_2,\n    ExactFrom\n);\nnatural_signed_single_arg_bench_with_trait!(\n    benchmark_natural_saturating_from_signed,\n    saturating_from,\n    signed_gen,\n    SaturatingFrom\n);\nnatural_signed_single_arg_bench_with_trait!(\n    benchmark_natural_convertible_from_signed,\n    convertible_from,\n    signed_gen,\n    ConvertibleFrom\n);\n\nfn benchmark_natural_const_from(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural::const_from(Limb)\",\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(Natural::const_from(u)))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/integer_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen_var_2, natural_unsigned_pair_gen_var_4};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_integer_mantissa_and_exponent);\n    register_demo!(runner, demo_natural_integer_mantissa);\n    register_demo!(runner, demo_natural_integer_exponent);\n    register_demo!(runner, demo_natural_from_integer_mantissa_and_exponent);\n    register_bench!(runner, benchmark_natural_integer_mantissa_and_exponent);\n    register_bench!(runner, benchmark_natural_integer_mantissa);\n    register_bench!(runner, benchmark_natural_integer_exponent);\n    register_bench!(runner, benchmark_natural_from_integer_mantissa_and_exponent);\n}\n\nfn demo_natural_integer_mantissa_and_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"{}.integer_mantissa_and_exponent() = {:?}\",\n            n,\n            n.integer_mantissa_and_exponent()\n        );\n    }\n}\n\nfn demo_natural_integer_mantissa(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"{}.integer_mantissa() = {}\", n, n.integer_mantissa());\n    }\n}\n\nfn demo_natural_integer_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"{}.integer_exponent() = {}\", n, n.integer_exponent());\n    }\n}\n\nfn demo_natural_from_integer_mantissa_and_exponent(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mantissa, exponent) in natural_unsigned_pair_gen_var_4::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n = <&Natural as IntegerMantissaAndExponent::<Natural, u64, Natural>>\n            ::from_integer_mantissa_and_exponent(mantissa.clone(), exponent);\n        println!(\n            \"Natural::from_integer_mantissa_and_exponent({}, {}) = {}\",\n            mantissa,\n            exponent,\n            n.unwrap()\n        );\n    }\n}\n\nfn benchmark_natural_integer_mantissa_and_exponent(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.integer_mantissa_and_exponent()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| {\n            no_out!(x.integer_mantissa_and_exponent());\n        })],\n    );\n}\n\nfn benchmark_natural_integer_mantissa(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.integer_mantissa()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.integer_mantissa()))],\n    );\n}\n\nfn benchmark_natural_integer_exponent(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.integer_exponent()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.integer_exponent()))],\n    );\n}\n\nfn benchmark_natural_from_integer_mantissa_and_exponent(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_integer_mantissa_and_exponent(Natural, u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mantissa, exponent)| {\n            no_out!(<&Natural as IntegerMantissaAndExponent::<\n                Natural,\n                u64,\n                Natural,\n            >>::from_integer_mantissa_and_exponent(\n                mantissa, exponent\n            ));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_is_integer);\n    register_bench!(runner, benchmark_natural_is_integer);\n}\n\nfn demo_natural_is_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        if n.is_integer() {\n            println!(\"{n} is an integer\");\n        } else {\n            println!(\"{n} is not an integer\");\n        }\n    }\n}\n\nfn benchmark_natural_is_integer(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.is_integer()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_integer()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    clone::register(runner);\n    digits::register(runner);\n    floating_point_from_natural::register(runner);\n    from_bool::register(runner);\n    from_floating_point::register(runner);\n    from_limbs::register(runner);\n    from_primitive_int::register(runner);\n    integer_mantissa_and_exponent::register(runner);\n    is_integer::register(runner);\n    primitive_int_from_natural::register(runner);\n    sci_mantissa_and_exponent::register(runner);\n    serde::register(runner);\n    string::register(runner);\n    to_limbs::register(runner);\n}\n\nmod clone;\nmod digits;\nmod floating_point_from_natural;\nmod from_bool;\nmod from_floating_point;\nmod from_limbs;\nmod from_primitive_int;\nmod integer_mantissa_and_exponent;\nmod is_integer;\nmod primitive_int_from_natural;\nmod sci_mantissa_and_exponent;\nmod serde;\nmod string;\nmod to_limbs;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/primitive_int_from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, OverflowingFrom, SaturatingFrom, WrappingFrom,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_2_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_rm, natural_gen_var_6, natural_gen_var_7,\n};\nuse std::fmt::Debug;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_demos!(runner, demo_primitive_int_try_from_natural);\n    register_unsigned_demos!(runner, demo_unsigned_exact_from_natural);\n    register_signed_demos!(runner, demo_signed_exact_from_natural);\n    register_primitive_int_demos!(runner, demo_primitive_int_wrapping_from_natural);\n    register_primitive_int_demos!(runner, demo_primitive_int_saturating_from_natural);\n    register_primitive_int_demos!(runner, demo_primitive_int_overflowing_from_natural);\n    register_primitive_int_demos!(runner, demo_primitive_int_convertible_from_natural);\n\n    register_primitive_int_benches!(runner, benchmark_primitive_int_try_from_natural_algorithms);\n    register_unsigned_benches!(runner, benchmark_unsigned_exact_from_natural);\n    register_signed_benches!(runner, benchmark_signed_exact_from_natural);\n    register_primitive_int_benches!(\n        runner,\n        benchmark_primitive_int_wrapping_from_natural_algorithms\n    );\n    register_primitive_int_benches!(runner, benchmark_primitive_int_saturating_from_natural);\n    register_primitive_int_benches!(\n        runner,\n        benchmark_primitive_int_overflowing_from_natural_algorithms\n    );\n    register_primitive_int_benches!(\n        runner,\n        benchmark_primitive_int_convertible_from_natural_algorithms\n    );\n\n    register_bench!(runner, benchmark_u32_try_from_natural_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_u32_wrapping_from_natural_library_comparison\n    );\n    register_bench!(runner, benchmark_u64_try_from_natural_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_u64_wrapping_from_natural_library_comparison\n    );\n    register_bench!(runner, benchmark_i32_try_from_natural_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_i32_wrapping_from_natural_library_comparison\n    );\n    register_bench!(runner, benchmark_i64_try_from_natural_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_i64_wrapping_from_natural_library_comparison\n    );\n}\n\nfn demo_primitive_int_try_from_natural<T: for<'a> TryFrom<&'a Natural> + PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> <T as TryFrom<&'a Natural>>::Error: Debug,\n{\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}::try_from(&{}) = {:?}\", T::NAME, n, T::try_from(&n));\n    }\n}\n\nfn demo_unsigned_exact_from_natural<T: for<'a> ExactFrom<&'a Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: From<T>,\n{\n    for n in natural_gen_var_6::<T>().get(gm, config).take(limit) {\n        println!(\"{}::exact_from(&{}) = {}\", T::NAME, n, T::exact_from(&n));\n    }\n}\n\nfn demo_signed_exact_from_natural<T: for<'a> ExactFrom<&'a Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Natural: ExactFrom<T>,\n{\n    for n in natural_gen_var_7::<T>().get(gm, config).take(limit) {\n        println!(\"{}::exact_from(&{}) = {}\", T::NAME, n, T::exact_from(&n));\n    }\n}\n\nfn demo_primitive_int_wrapping_from_natural<T: for<'a> WrappingFrom<&'a Natural> + PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::wrapping_from(&{}) = {}\",\n            T::NAME,\n            n,\n            T::wrapping_from(&n)\n        );\n    }\n}\n\nfn demo_primitive_int_saturating_from_natural<\n    T: for<'a> SaturatingFrom<&'a Natural> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::saturating_from(&{}) = {}\",\n            T::NAME,\n            n,\n            T::saturating_from(&n)\n        );\n    }\n}\n\nfn demo_primitive_int_overflowing_from_natural<\n    T: for<'a> OverflowingFrom<&'a Natural> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::overflowing_from(&{}) = {:?}\",\n            T::NAME,\n            n,\n            T::overflowing_from(&n)\n        );\n    }\n}\n\nfn demo_primitive_int_convertible_from_natural<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            n,\n            if T::convertible_from(&n) { \"\" } else { \"not \" },\n            T::NAME,\n        );\n    }\n}\n\nfn benchmark_primitive_int_try_from_natural_algorithms<\n    T: for<'a> TryFrom<&'a Natural> + for<'a> OverflowingFrom<&'a Natural> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::try_from(&Natural)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::try_from(&n).ok())),\n            (\"using overflowing_from\", &mut |n| {\n                let (value, overflow) = T::overflowing_from(&n);\n                if overflow {\n                    None\n                } else {\n                    Some(value)\n                };\n            }),\n        ],\n    );\n}\n\nfn benchmark_unsigned_exact_from_natural<T: for<'a> ExactFrom<&'a Natural> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: From<T>,\n{\n    run_benchmark(\n        &format!(\"{}::exact_from(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(&n)))],\n    );\n}\n\nfn benchmark_signed_exact_from_natural<T: for<'a> ExactFrom<&'a Natural> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: ExactFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}::exact_from(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_gen_var_7::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::exact_from(&n)))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_primitive_int_wrapping_from_natural_algorithms<\n    T: for<'a> OverflowingFrom<&'a Natural> + PrimitiveInt + for<'a> WrappingFrom<&'a Natural>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::wrapping_from(&Natural)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::wrapping_from(&n))),\n            (\"using overflowing_from\", &mut |n| {\n                T::overflowing_from(&n).0;\n            }),\n        ],\n    );\n}\n\nfn benchmark_primitive_int_saturating_from_natural<\n    T: PrimitiveInt + for<'a> SaturatingFrom<&'a Natural>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::saturating_from(&Natural)\", T::NAME),\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(T::saturating_from(&n)))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_primitive_int_overflowing_from_natural_algorithms<\n    T: for<'a> ConvertibleFrom<&'a Natural>\n        + for<'a> OverflowingFrom<&'a Natural>\n        + PrimitiveInt\n        + for<'a> WrappingFrom<&'a Natural>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::overflowing_from(&Natural)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::overflowing_from(&n))),\n            (\"using wrapping_from and convertible_from\", &mut |n| {\n                no_out!((T::wrapping_from(&n), !T::convertible_from(&n)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_primitive_int_convertible_from_natural_algorithms<\n    T: for<'a> TryFrom<&'a Natural> + for<'a> ConvertibleFrom<&'a Natural> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::convertible_from(&Natural)\", T::NAME),\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"standard\", &mut |n| no_out!(T::convertible_from(&n))),\n            (\"using try_from\", &mut |n| no_out!(T::try_from(&n).is_ok())),\n        ],\n    );\n}\n\nfn benchmark_u32_try_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32::try_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u32::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u32())),\n        ],\n    );\n}\n\nfn benchmark_u32_wrapping_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u32::wrapping_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u32::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u32_wrapping())),\n        ],\n    );\n}\n\nfn benchmark_u64_try_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64::try_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u64::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u64())),\n        ],\n    );\n}\n\nfn benchmark_u64_wrapping_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"u64::wrapping_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(u64::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_u64_wrapping())),\n        ],\n    );\n}\n\nfn benchmark_i32_try_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i32::try_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i32::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i32())),\n        ],\n    );\n}\n\nfn benchmark_i32_wrapping_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i32::wrapping_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i32::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i32_wrapping())),\n        ],\n    );\n}\n\nfn benchmark_i64_try_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i64::try_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i64::try_from(&n).ok())),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i64())),\n        ],\n    );\n}\n\nfn benchmark_i64_wrapping_from_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"i64::wrapping_from(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(i64::wrapping_from(&n))),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_i64_wrapping())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/sci_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::SciMantissaAndExponent;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_primitive_float_bucketer, triple_1_primitive_float_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_unsigned_pair_gen_var_1, primitive_float_unsigned_pair_gen_var_2,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_1,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_gen_var_2, natural_rounding_mode_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_natural_sci_mantissa_and_exponent);\n    register_primitive_float_demos!(runner, demo_natural_sci_mantissa);\n    register_primitive_float_demos!(runner, demo_natural_sci_exponent);\n    register_primitive_float_demos!(runner, demo_natural_sci_mantissa_and_exponent_round);\n    register_primitive_float_demos!(runner, demo_natural_from_sci_mantissa_and_exponent);\n    register_primitive_float_demos!(runner, demo_natural_from_sci_mantissa_and_exponent_targeted);\n    register_primitive_float_demos!(runner, demo_natural_from_sci_mantissa_and_exponent_round);\n    register_primitive_float_demos!(\n        runner,\n        demo_natural_from_sci_mantissa_and_exponent_round_targeted\n    );\n    register_primitive_float_benches!(runner, benchmark_natural_sci_mantissa_and_exponent);\n    register_primitive_float_benches!(runner, benchmark_natural_sci_mantissa_and_exponent_round);\n    register_primitive_float_benches!(runner, benchmark_natural_from_sci_mantissa_and_exponent);\n    register_primitive_float_benches!(\n        runner,\n        benchmark_natural_from_sci_mantissa_and_exponent_round\n    );\n}\n\nfn demo_natural_sci_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        let (mantissa, exponent) = n.sci_mantissa_and_exponent();\n        println!(\n            \"sci_mantissa_and_exponent({}) = {:?}\",\n            n,\n            (NiceFloat(mantissa), exponent)\n        );\n    }\n}\n\nfn demo_natural_sci_mantissa<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"sci_mantissa({}) = {}\", n, NiceFloat(n.sci_mantissa()));\n    }\n}\n\nfn demo_natural_sci_exponent<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    for n in natural_gen_var_2().get(gm, config).take(limit) {\n        println!(\"sci_exponent({}) = {}\", n, n.sci_exponent());\n    }\n}\n\nfn demo_natural_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in natural_rounding_mode_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sci_mantissa_and_exponent_round({}, {}) = {:?}\",\n            n,\n            rm,\n            n.sci_mantissa_and_exponent_round::<T>(rm)\n                .map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    }\n}\n\nfn demo_natural_from_sci_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    for (m, e) in primitive_float_unsigned_pair_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_sci_mantissa_and_exponent({}, {}) = {:?}\",\n            NiceFloat(m),\n            e,\n            <&Natural as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e)\n        );\n    }\n}\n\nfn demo_natural_from_sci_mantissa_and_exponent_targeted<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    for (m, e) in primitive_float_unsigned_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_sci_mantissa_and_exponent({}, {}) = {:?}\",\n            NiceFloat(m),\n            e,\n            <&Natural as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e)\n        );\n    }\n}\n\nfn demo_natural_from_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (m, e, rm) in primitive_float_unsigned_rounding_mode_triple_gen_var_1::<T, u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_sci_mantissa_and_exponent_round({}, {}, {}) = {:?}\",\n            NiceFloat(m),\n            e,\n            rm,\n            Natural::from_sci_mantissa_and_exponent_round(m, e, rm)\n        );\n    }\n}\n\nfn demo_natural_from_sci_mantissa_and_exponent_round_targeted<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (m, e, rm) in primitive_float_unsigned_rounding_mode_triple_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_sci_mantissa_and_exponent_round({}, {}, {}) = {:?}\",\n            NiceFloat(m),\n            e,\n            rm,\n            Natural::from_sci_mantissa_and_exponent_round(m, e, rm)\n        );\n    }\n}\n\nfn benchmark_natural_sci_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    run_benchmark(\n        \"Natural.sci_mantissa_and_exponent()\",\n        BenchmarkType::Single,\n        natural_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.sci_mantissa_and_exponent()))],\n    );\n}\n\nfn benchmark_natural_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.sci_mantissa_and_exponent_round(RoundingMode)\",\n        BenchmarkType::Single,\n        natural_rounding_mode_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(n, rm)| {\n            no_out!(n.sci_mantissa_and_exponent_round::<T>(rm));\n        })],\n    );\n}\n\nfn benchmark_natural_from_sci_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    run_benchmark(\n        &format!(\"Natural::from_sci_mantissa_and_exponent({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_unsigned_pair_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(m, e)| {\n            no_out!(\n                <&Natural as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e)\n            );\n        })],\n    );\n}\n\nfn benchmark_natural_from_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\n            \"Natural::from_sci_mantissa_and_exponent_round({}, u64, RoundingMode)\",\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        primitive_float_unsigned_rounding_mode_triple_gen_var_1::<T, u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(m, e, rm)| {\n            no_out!(Natural::from_sci_mantissa_and_exponent_round(m, e, rm));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_8};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_deserialize_bucketer, triple_3_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_nrm, string_triple_gen_var_1};\nuse num::BigUint;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_serialize_json);\n    register_demo!(runner, demo_natural_deserialize_json);\n    register_demo!(runner, demo_natural_deserialize_json_targeted);\n\n    register_bench!(runner, benchmark_natural_serialize_json_library_comparison);\n    register_bench!(runner, benchmark_natural_deserialize_json);\n    register_bench!(\n        runner,\n        benchmark_natural_deserialize_json_library_comparison\n    );\n}\n\nfn demo_natural_serialize_json(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\n            \"serde_json::to_string({}) = {}\",\n            n,\n            serde_json::to_string(&n).unwrap()\n        );\n    }\n}\n\nfn demo_natural_deserialize_json(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        let n: Result<Natural, _> = serde_json::from_str(&s);\n        println!(\"serde_json::from_str({s}) = {n:?}\");\n    }\n}\n\nfn demo_natural_deserialize_json_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_8().get(gm, config).take(limit) {\n        let n: Natural = serde_json::from_str(&s).unwrap();\n        println!(\"serde_json::from_str({s}) = {n}\");\n    }\n}\n\nfn benchmark_natural_serialize_json_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::to_string(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n            (\"num\", &mut |(x, _, _)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n            (\"rug\", &mut |(_, x, _)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_deserialize_json(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::from_str(&str)\",\n        BenchmarkType::Single,\n        string_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| {\n            let _n: Natural = serde_json::from_str(&s).unwrap();\n        })],\n    );\n}\n\nfn benchmark_natural_deserialize_json_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::from_str(&str)\",\n        BenchmarkType::LibraryComparison,\n        string_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_deserialize_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, s)| {\n                let _n: Natural = serde_json::from_str(&s).unwrap();\n            }),\n            (\"num\", &mut |(s, _, _)| {\n                let _n: BigUint = serde_json::from_str(&s).unwrap();\n            }),\n            (\"rug\", &mut |(_, s, _)| {\n                let _n: rug::Integer = serde_json::from_str(&s).unwrap();\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::FromSciString;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_string_len_bucketer, string_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    string_from_sci_string_options_pair_gen_var_2, string_from_sci_string_options_pair_gen_var_3,\n    string_gen_var_14, string_gen_var_15,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_from_sci_string);\n    register_demo!(runner, demo_natural_from_sci_string_targeted);\n    register_demo!(runner, demo_natural_from_sci_string_with_options);\n    register_demo!(runner, demo_natural_from_sci_string_with_options_targeted);\n\n    register_bench!(runner, benchmark_natural_from_sci_string);\n    register_bench!(runner, benchmark_natural_from_sci_string_with_options);\n}\n\nfn demo_natural_from_sci_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_14().get(gm, config).take(limit) {\n        println!(\n            \"Natural::from_sci_string({}) = {:?}\",\n            s,\n            Natural::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_natural_from_sci_string_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_15().get(gm, config).take(limit) {\n        println!(\n            \"Natural::from_sci_string({}) = {:?}\",\n            s,\n            Natural::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_natural_from_sci_string_with_options(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (s, options) in string_from_sci_string_options_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_sci_string_with_options({}, {:?}) = {:?}\",\n            s,\n            options,\n            Natural::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn demo_natural_from_sci_string_with_options_targeted(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (s, options) in string_from_sci_string_options_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::from_sci_string_with_options({}, {:?}) = {:?}\",\n            s,\n            options,\n            Natural::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn benchmark_natural_from_sci_string(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_sci_string(&str)\",\n        BenchmarkType::Single,\n        string_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(Natural::from_sci_string(&s)))],\n    );\n}\n\nfn benchmark_natural_from_sci_string_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_sci_string_with_options(&str, FromSciStringOptions)\",\n        BenchmarkType::Single,\n        string_from_sci_string_options_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_string_len_bucketer(\"s\"),\n        &mut [(\"Malachite\", &mut |(s, options)| {\n            no_out!(Natural::from_sci_string_with_options(&s, options));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{FromStringBase, WrappingFrom};\nuse malachite_base::test_util::bench::bucketers::{\n    pair_2_string_len_bucketer, string_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    string_gen, string_gen_var_3, string_gen_var_5, string_gen_var_6, string_gen_var_7,\n    unsigned_string_pair_gen_var_1, unsigned_string_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::natural::conversion::string::from_string::from_string_base_naive;\nuse num::{BigUint, Num};\nuse std::str::FromStr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_from_str);\n    register_demo!(runner, demo_natural_from_str_targeted);\n    register_demo!(runner, demo_natural_from_string_base);\n    register_demo!(runner, demo_natural_from_string_base_targeted);\n    register_bench!(runner, benchmark_natural_from_str_library_comparison);\n    register_bench!(runner, benchmark_natural_from_str_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_from_string_base_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_from_string_base_binary_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_from_string_base_octal_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_from_string_base_hex_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_from_string_base_algorithms);\n}\n\nfn demo_natural_from_string_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (base, s) in unsigned_string_pair_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"Natural::from_string_base({}, {}) = {:?}\",\n            base,\n            s,\n            Natural::from_string_base(base, &s)\n        );\n    }\n}\n\nfn demo_natural_from_string_base_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (base, s) in unsigned_string_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"Natural::from_string_base({}, {}) = {}\",\n            base,\n            s,\n            Natural::from_string_base(base, &s).unwrap()\n        );\n    }\n}\n\nfn demo_natural_from_str(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\"Natural::from_str({}) = {:?}\", s, Natural::from_str(&s));\n    }\n}\n\nfn demo_natural_from_str_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"Natural::from_str({}) = {}\",\n            s,\n            Natural::from_str(&s).unwrap()\n        );\n    }\n}\n\nfn benchmark_natural_from_str_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_str(&str)\",\n        BenchmarkType::LibraryComparison,\n        string_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |s| {\n                no_out!(Natural::from_str(&s).unwrap());\n            }),\n            (\"num\", &mut |s| no_out!(BigUint::from_str(&s).unwrap())),\n            (\"rug\", &mut |s| no_out!(rug::Integer::from_str(&s).unwrap())),\n        ],\n    );\n}\n\nfn benchmark_natural_from_str_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_str(&str)\",\n        BenchmarkType::Algorithms,\n        string_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [\n            (\"default\", &mut |s| no_out!(Natural::from_str(&s).unwrap())),\n            (\"naive\", &mut |s| {\n                no_out!(from_string_base_naive(10, &s).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_string_base_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_string_base(u64, &str)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_string_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_string_len_bucketer(\"s\"),\n        &mut [\n            (\"Malachite\", &mut |(base, s)| {\n                no_out!(Natural::from_string_base(base, &s).unwrap());\n            }),\n            (\"num\", &mut |(base, s)| {\n                no_out!(BigUint::from_str_radix(&s, u32::wrapping_from(base)).unwrap());\n            }),\n            (\"rug\", &mut |(base, s)| {\n                no_out!(rug::Integer::from_str_radix(&s, i32::wrapping_from(base)).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_string_base_binary_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_string_base(2, &str)\",\n        BenchmarkType::LibraryComparison,\n        string_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |s| {\n                no_out!(Natural::from_string_base(2, &s).unwrap());\n            }),\n            (\"num\", &mut |s| {\n                no_out!(BigUint::from_str_radix(&s, 2).unwrap());\n            }),\n            (\"rug\", &mut |s| {\n                no_out!(rug::Integer::from_str_radix(&s, 2).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_string_base_octal_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_string_base(8, &str)\",\n        BenchmarkType::LibraryComparison,\n        string_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |s| {\n                no_out!(Natural::from_string_base(8, &s).unwrap());\n            }),\n            (\"num\", &mut |s| {\n                no_out!(BigUint::from_str_radix(&s, 8).unwrap());\n            }),\n            (\"rug\", &mut |s| {\n                no_out!(rug::Integer::from_str_radix(&s, 8).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_string_base_hex_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_string_base(16, &str)\",\n        BenchmarkType::LibraryComparison,\n        string_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |s| {\n                no_out!(Natural::from_string_base(16, &s).unwrap());\n            }),\n            (\"num\", &mut |s| {\n                no_out!(BigUint::from_str_radix(&s, 16).unwrap());\n            }),\n            (\"rug\", &mut |s| {\n                no_out!(rug::Integer::from_str_radix(&s, 16).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_string_base_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_string_base(u8, &str)\",\n        BenchmarkType::Algorithms,\n        unsigned_string_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_string_len_bucketer(\"s\"),\n        &mut [\n            (\"default\", &mut |(base, s)| {\n                no_out!(Natural::from_string_base(base, &s).unwrap());\n            }),\n            (\"naive\", &mut |(base, s)| {\n                no_out!(from_string_base_naive(base, &s).unwrap());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_sci_string::register(runner);\n    from_string::register(runner);\n    to_sci::register(runner);\n    to_string::register(runner);\n}\n\nmod from_sci_string;\nmod from_string;\nmod to_sci;\nmod to_string;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ToSci;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_to_sci_options_pair_gen, natural_to_sci_options_pair_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_to_sci);\n    register_demo!(runner, demo_natural_fmt_sci_valid);\n    register_demo!(runner, demo_natural_to_sci_with_options);\n\n    register_bench!(runner, benchmark_natural_to_sci);\n    register_bench!(runner, benchmark_natural_fmt_sci_valid);\n    register_bench!(runner, benchmark_natural_to_sci_with_options);\n}\n\nfn demo_natural_to_sci(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.to_sci() = {}\", x, x.to_sci());\n    }\n}\n\nfn demo_natural_fmt_sci_valid(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, options) in natural_to_sci_options_pair_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.fmt_sci_valid(options) {\n            println!(\"{x} can be converted to sci using {options:?}\");\n        } else {\n            println!(\"{x} cannot be converted to sci using {options:?}\");\n        }\n    }\n}\n\nfn demo_natural_to_sci_with_options(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, options) in natural_to_sci_options_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_sci_with_options({}, {:?}) = {}\",\n            x,\n            options,\n            x.to_sci_with_options(options)\n        );\n    }\n}\n\nfn benchmark_natural_to_sci(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.to_sci()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.to_sci().to_string()))],\n    );\n}\n\nfn benchmark_natural_fmt_sci_valid(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.fmt_sci_valid(ToSciOptions)\",\n        BenchmarkType::Single,\n        natural_to_sci_options_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.fmt_sci_valid(options));\n        })],\n    );\n}\n\nfn benchmark_natural_to_sci_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_sci_with_options(ToSciOptions)\",\n        BenchmarkType::Single,\n        natural_to_sci_options_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.to_sci_with_options(options).to_string());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ToStringBase, WrappingFrom};\nuse malachite_base::strings::{ToBinaryString, ToLowerHexString, ToOctalString, ToUpperHexString};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::conversion::string::to_string::{\n    BaseFmtWrapper, NaturalAlt, NaturalAlt2,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer, triple_1_natural_bit_bucketer,\n    triple_3_natural_bit_bucketer, triple_3_pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_nrm, natural_unsigned_pair_gen_var_3,\n    natural_unsigned_pair_gen_var_3_nrm, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_unsigned_triple_gen_var_1,\n};\nuse malachite_nz::test_util::natural::conversion::string::to_string::to_string_base_naive;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_to_string);\n    register_demo!(runner, demo_natural_to_string_with_width);\n    register_demo!(runner, demo_natural_to_binary_string);\n    register_demo!(runner, demo_natural_to_binary_string_with_0b);\n    register_demo!(runner, demo_natural_to_binary_string_with_width);\n    register_demo!(runner, demo_natural_to_binary_string_with_0b_and_width);\n    register_demo!(runner, demo_natural_to_octal_string);\n    register_demo!(runner, demo_natural_to_octal_string_with_0o);\n    register_demo!(runner, demo_natural_to_octal_string_with_width);\n    register_demo!(runner, demo_natural_to_octal_string_with_0o_and_width);\n    register_demo!(runner, demo_natural_to_lower_hex_string);\n    register_demo!(runner, demo_natural_to_lower_hex_string_with_0x);\n    register_demo!(runner, demo_natural_to_lower_hex_string_with_width);\n    register_demo!(runner, demo_natural_to_lower_hex_string_with_0x_and_width);\n    register_demo!(runner, demo_natural_to_upper_hex_string);\n    register_demo!(runner, demo_natural_to_upper_hex_string_with_0x);\n    register_demo!(runner, demo_natural_to_upper_hex_string_with_width);\n    register_demo!(runner, demo_natural_to_upper_hex_string_with_0x_and_width);\n    register_demo!(runner, demo_natural_to_string_base);\n    register_demo!(runner, demo_natural_to_string_base_upper);\n    register_demo!(runner, demo_natural_base_fmt_wrapper_fmt);\n    register_demo!(runner, demo_natural_base_fmt_wrapper_fmt_upper);\n    register_demo!(runner, demo_natural_base_fmt_wrapper_fmt_with_width);\n    register_demo!(runner, demo_natural_base_fmt_wrapper_fmt_upper_with_width);\n    register_bench!(runner, benchmark_natural_to_string_library_comparison);\n    register_bench!(runner, benchmark_natural_to_string_algorithms);\n    register_bench!(runner, benchmark_natural_to_string_with_width);\n    register_bench!(\n        runner,\n        benchmark_natural_to_binary_string_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_to_binary_string_algorithms);\n    register_bench!(runner, benchmark_natural_to_binary_string_with_width);\n    register_bench!(runner, benchmark_natural_to_octal_string_library_comparison);\n    register_bench!(runner, benchmark_natural_to_octal_string_algorithms);\n    register_bench!(runner, benchmark_natural_to_octal_string_with_width);\n    register_bench!(\n        runner,\n        benchmark_natural_to_lower_hex_string_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_to_lower_hex_string_algorithms);\n    register_bench!(runner, benchmark_natural_to_lower_hex_string_with_width);\n    register_bench!(\n        runner,\n        benchmark_natural_to_upper_hex_string_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_to_upper_hex_string_with_width);\n    register_bench!(runner, benchmark_natural_to_string_base_library_comparison);\n    register_bench!(runner, benchmark_natural_to_string_base_algorithms);\n    register_bench!(runner, benchmark_natural_to_string_base_upper_algorithms);\n    register_bench!(runner, benchmark_natural_base_fmt_wrapper_fmt_with_width);\n    register_bench!(\n        runner,\n        benchmark_natural_base_fmt_wrapper_fmt_upper_with_width\n    );\n}\n\nfn demo_natural_to_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$}\")\n        );\n    }\n}\n\nfn demo_natural_to_binary_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:b}\");\n    }\n}\n\nfn demo_natural_to_binary_string_with_0b(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:#b}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_binary_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}b}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$b}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_binary_string_with_0b_and_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}b}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$b}\")\n        );\n    }\n}\n\nfn demo_natural_to_octal_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:o}\");\n    }\n}\n\nfn demo_natural_to_octal_string_with_0o(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:#o}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_octal_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}o}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$o}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_octal_string_with_0o_and_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}o}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$o}\")\n        );\n    }\n}\n\nfn demo_natural_to_lower_hex_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:x}\");\n    }\n}\n\nfn demo_natural_to_lower_hex_string_with_0x(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:#x}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_lower_hex_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}x}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$x}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_lower_hex_string_with_0x_and_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}x}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$x}\")\n        );\n    }\n}\n\nfn demo_natural_to_upper_hex_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:X}\");\n    }\n}\n\nfn demo_natural_to_upper_hex_string_with_0x(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{n:#X}\");\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_upper_hex_string_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}X}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:0width$X}\")\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_to_upper_hex_string_with_0x_and_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, width) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}X}}\\\", {}) = {}\",\n            width,\n            n,\n            format!(\"{n:#0width$X}\")\n        );\n    }\n}\n\nfn demo_natural_to_string_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_string_base({}) = {}\",\n            x,\n            base,\n            x.to_string_base(base)\n        );\n    }\n}\n\nfn demo_natural_to_string_base_upper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.to_string_base_upper({}) = {}\",\n            x,\n            base,\n            x.to_string_base_upper(base)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_base_fmt_wrapper_fmt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{}\", BaseFmtWrapper::new(&x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_base_fmt_wrapper_fmt_upper(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base) in natural_unsigned_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            x,\n            base,\n            format!(\"{:#}\", BaseFmtWrapper::new(&x, base))\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_base_fmt_wrapper_fmt_with_width(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, base, width) in natural_unsigned_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, base), width = width)\n        );\n    }\n}\n\n#[allow(clippy::format_in_format_args)]\nfn demo_natural_base_fmt_wrapper_fmt_upper_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (x, base, width) in natural_unsigned_unsigned_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"format!(\\\"{{:#0{}}}\\\", BaseFmtWrapper::new({}, {})) = {}\",\n            width,\n            x,\n            base,\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, base), width = width)\n        );\n    }\n}\n\nfn benchmark_natural_to_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_string()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_string())),\n        ],\n    );\n}\n\nfn benchmark_natural_to_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_string()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(10))),\n            (\"naive\", &mut |x| no_out!(to_string_base_naive(&x, 10))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_to_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usize}}\\\", Natural)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$}\"));\n        })],\n    );\n}\n\nfn benchmark_natural_to_binary_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_binary_string()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_binary_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_binary_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_binary_string())),\n        ],\n    );\n}\n\nfn benchmark_natural_to_binary_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_binary_string()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_binary_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(2))),\n            (\"naive\", &mut |x| no_out!(to_string_base_naive(&x, 2))),\n            (\"alt\", &mut |x| no_out!(NaturalAlt(x).to_binary_string())),\n            (\"alt 2\", &mut |x| no_out!(NaturalAlt2(x).to_binary_string())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_to_binary_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizeb}}\\\", Natural)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$b}\"));\n        })],\n    );\n}\n\nfn benchmark_natural_to_octal_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_octal_string()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_octal_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_octal_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_octal_string())),\n        ],\n    );\n}\n\nfn benchmark_natural_to_octal_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_octal_string()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_octal_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(8))),\n            (\"naive\", &mut |x| no_out!(to_string_base_naive(&x, 8))),\n            (\"alt\", &mut |x| no_out!(NaturalAlt(x).to_octal_string())),\n            (\"alt 2\", &mut |x| no_out!(NaturalAlt2(x).to_octal_string())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_to_octal_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizeo}}\\\", Natural)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$o}\"));\n        })],\n    );\n}\n\nfn benchmark_natural_to_lower_hex_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_lower_hex_string()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| {\n                no_out!(x.to_lower_hex_string());\n            }),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_lower_hex_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_lower_hex_string())),\n        ],\n    );\n}\n\nfn benchmark_natural_to_lower_hex_string_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_lower_hex_string()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.to_lower_hex_string())),\n            (\"to_string_base\", &mut |x| no_out!(x.to_string_base(16))),\n            (\"naive\", &mut |x| no_out!(to_string_base_naive(&x, 16))),\n            (\"alt\", &mut |x| no_out!(NaturalAlt(x).to_lower_hex_string())),\n            (\"alt 2\", &mut |x| {\n                no_out!(NaturalAlt2(x).to_lower_hex_string());\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_to_lower_hex_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizex}}\\\", Natural)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$x}\"));\n        })],\n    );\n}\n\nfn benchmark_natural_to_upper_hex_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_upper_hex_string()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| {\n                no_out!(x.to_upper_hex_string());\n            }),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_upper_hex_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_upper_hex_string())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_to_upper_hex_string_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usizeX}}\\\", Natural)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, width)| {\n            no_out!(format!(\"{x:0width$X}\"));\n        })],\n    );\n}\n\nfn benchmark_natural_to_string_base_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_string_base(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_3_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, base))| {\n                no_out!(x.to_string_base(base));\n            }),\n            (\"num\", &mut |((x, base), _, _)| {\n                no_out!(x.to_str_radix(u32::wrapping_from(base)));\n            }),\n            (\"rug\", &mut |(_, (x, base), _)| {\n                no_out!(x.to_string_radix(i32::wrapping_from(base)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_to_string_base_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_string_base(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, base)| no_out!(x.to_string_base(base))),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{}\", BaseFmtWrapper::new(&x, base)));\n            }),\n            (\"naive\", &mut |(x, base)| {\n                no_out!(to_string_base_naive(&x, base));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_to_string_base_upper_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_string_base_upper(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_string\", &mut |(x, base)| {\n                no_out!(x.to_string_base_upper(base));\n            }),\n            (\"using fmt\", &mut |(x, base)| {\n                no_out!(format!(\"{:#}\", BaseFmtWrapper::new(&x, base)));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_base_fmt_wrapper_fmt_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:0usize}}\\\", BaseFmtWrapper::new(Natural, u64))\",\n        BenchmarkType::Single,\n        natural_unsigned_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:0width$}\",\n                BaseFmtWrapper::new(&x, base),\n                width = width\n            ));\n        })],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_base_fmt_wrapper_fmt_upper_with_width(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"format!(\\\"{{:#0usize}}\\\", BaseFmtWrapper::new(Natural, u64))\",\n        BenchmarkType::Single,\n        natural_unsigned_unsigned_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, base, width)| {\n            no_out!(format!(\n                \"{:#0width$}\",\n                BaseFmtWrapper::new(&x, base),\n                width = width\n            ));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/conversion/to_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_4};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_to_limbs_asc);\n    register_demo!(runner, demo_natural_to_limbs_desc);\n    register_demo!(runner, demo_natural_into_limbs_asc);\n    register_demo!(runner, demo_natural_into_limbs_desc);\n    register_demo!(runner, demo_natural_as_limbs_asc);\n    register_demo!(runner, demo_natural_limbs);\n    register_demo!(runner, demo_natural_limbs_rev);\n    register_demo!(runner, demo_natural_limbs_size_hint);\n    register_demo!(runner, demo_natural_limbs_index);\n    register_demo!(runner, demo_natural_limb_count);\n\n    register_bench!(runner, benchmark_natural_limbs_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_limbs_rev_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_limbs_size_hint);\n    register_bench!(runner, benchmark_natural_limbs_index_algorithms);\n    register_bench!(runner, benchmark_natural_limb_count);\n}\n\nfn demo_natural_to_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"to_limbs_asc({}) = {:?}\", n, n.to_limbs_asc());\n    }\n}\n\nfn demo_natural_to_limbs_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"to_limbs_desc({}) = {:?}\", n, n.to_limbs_desc());\n    }\n}\n\nfn demo_natural_into_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"into_limbs_asc({}) = {:?}\", n, n.clone().into_limbs_asc());\n    }\n}\n\nfn demo_natural_into_limbs_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"into_limbs_desc({}) = {:?}\", n, n.clone().into_limbs_desc());\n    }\n}\n\nfn demo_natural_as_limbs_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"as_limbs_asc({}) = {:?}\", n, n.as_limbs_asc());\n    }\n}\n\nfn demo_natural_limbs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"limbs({}) = {:?}\", n, n.limbs().collect_vec());\n    }\n}\n\nfn demo_natural_limbs_rev(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"limbs({}).rev() = {:?}\", n, n.limbs().rev().collect_vec());\n    }\n}\n\nfn demo_natural_limbs_size_hint(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"limbs({}).size_hint() = {:?}\", n, n.limbs().size_hint());\n    }\n}\n\nfn demo_natural_limbs_index(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, i) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"limbs({})[{}] = {:?}\", n, i, n.limbs()[i]);\n    }\n}\n\nfn demo_natural_limb_count(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"limb_count({}) = {}\", n, n.limb_count());\n    }\n}\n\nfn benchmark_natural_limbs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.limbs()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.to_limbs_asc()\", &mut |n| no_out!(n.to_limbs_asc())),\n            (\"Natural.into_limbs_asc()\", &mut |n| {\n                no_out!(n.into_limbs_asc());\n            }),\n            (\"Natural.as_limbs_asc()\", &mut |n| {\n                no_out!(n.as_limbs_asc());\n            }),\n            (\"Natural.limbs().collect_vec()\", &mut |n| {\n                no_out!(n.limbs().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_limbs_rev_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.limbs().rev()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.to_limbs_desc()\", &mut |n| {\n                no_out!(n.to_limbs_desc());\n            }),\n            (\"Natural.into_limbs_desc()\", &mut |n| {\n                no_out!(n.into_limbs_desc());\n            }),\n            (\"Natural.limbs().rev().collect_vec()\", &mut |n| {\n                no_out!(n.limbs().rev().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_limbs_size_hint(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.limbs().size_hint()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Natural.limbs().size_hint()\", &mut |n| {\n            no_out!(n.limbs().size_hint());\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_natural_limbs_index_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.limbs()[usize]\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.limbs()[u]\", &mut |(n, u)| no_out!(n.limbs()[u])),\n            (\"Natural.into_limbs_asc()[u]\", &mut |(n, u)| {\n                let limbs = n.into_limbs_asc();\n                if u >= limbs.len() {\n                    0\n                } else {\n                    limbs[u]\n                };\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_limb_count(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.limb_count()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.limb_count()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/factorization/is_power.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::factorization::traits::{ExpressAsPower, IsPower};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_2_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_is_power);\n    register_demo!(runner, demo_natural_express_as_power);\n\n    register_bench!(runner, benchmark_natural_is_power_library_comparison);\n    register_bench!(runner, benchmark_natural_is_power_algorithms);\n    register_bench!(runner, benchmark_natural_express_as_power);\n}\n\nfn demo_natural_is_power(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        if n.is_power() {\n            println!(\"{n} is a perfect power\");\n        } else {\n            println!(\"{n} is not a perfect power\");\n        }\n    }\n}\n\nfn demo_natural_express_as_power(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"{}.express_as_power() = {:?}\", n, n.express_as_power());\n    }\n}\n\nfn benchmark_natural_is_power_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.is_power()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(n.is_power())),\n            (\"rug\", &mut |(n, _)| no_out!(n.is_perfect_power())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_is_power_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.is_power()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.is_power())),\n            (\"using express_as_power\", &mut |n| {\n                no_out!(n.express_as_power().is_some());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_express_as_power(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.express_as_power()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.express_as_power()))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/factorization/is_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::CheckedSqrt;\nuse malachite_base::num::factorization::traits::IsSquare;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_2_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_is_square);\n    register_bench!(runner, benchmark_natural_is_square_library_comparison);\n    register_bench!(runner, benchmark_natural_is_square_algorithms);\n}\n\nfn demo_natural_is_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        if n.is_square() {\n            println!(\"{n} is a perfect square\");\n        } else {\n            println!(\"{n} is not a perfect square\");\n        }\n    }\n}\n\nfn benchmark_natural_is_square_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.is_square()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| no_out!(n.is_square())),\n            (\"rug\", &mut |(n, _)| no_out!(n.is_perfect_square())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_is_square_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.is_square()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.is_square())),\n            (\"using checked_sqrt\", &mut |n| {\n                no_out!(n.checked_sqrt().is_some());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/factorization/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    is_power::register(runner);\n    is_square::register(runner);\n    primes::register(runner);\n}\n\nmod is_power;\nmod is_square;\nmod primes;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/factorization/primes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::factorization::traits::Primes;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::natural_bucketer;\nuse malachite_nz::test_util::generators::natural_gen_var_9;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_primes_less_than);\n    register_demo!(runner, demo_natural_primes_less_than_or_equal_to);\n    register_demo!(runner, demo_natural_primes);\n\n    register_bench!(runner, benchmark_natural_primes_less_than_algorithms);\n    register_bench!(\n        runner,\n        benchmark_natural_primes_less_than_or_equal_to_algorithms\n    );\n}\n\nfn demo_natural_primes_less_than(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_9().get(gm, config).take(limit) {\n        println!(\n            \"primes_less_than({}) = {:?}\",\n            n,\n            Natural::primes_less_than(&n).collect_vec()\n        );\n    }\n}\n\nfn demo_natural_primes_less_than_or_equal_to(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen_var_9().get(gm, config).take(limit) {\n        println!(\n            \"primes_less_than_or_equal_to({}) = {:?}\",\n            n,\n            Natural::primes_less_than_or_equal_to(&n).collect_vec()\n        );\n    }\n}\nfn demo_natural_primes(_gm: GenMode, _config: &GenConfig, limit: usize) {\n    for p in Natural::primes().take(limit) {\n        println!(\"{p}\");\n    }\n}\n\nfn benchmark_natural_primes_less_than_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::primes_less_than(&Natural)\",\n        BenchmarkType::Algorithms,\n        natural_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| {\n                no_out!(Natural::primes_less_than(&n).count());\n            }),\n            (\"using primes\", &mut |n| {\n                no_out!(Natural::primes().take_while(|p| *p < n).count());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_primes_less_than_or_equal_to_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::primes_less_than_or_equal_to(&Natural)\",\n        BenchmarkType::Algorithms,\n        natural_gen_var_9().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| {\n                no_out!(Natural::primes_less_than_or_equal_to(&n).count());\n            }),\n            (\"using primes\", &mut |n| {\n                no_out!(Natural::primes().take_while(|p| *p <= n).count());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_vec_min_len_bucketer, triple_2_3_vec_min_len_bucketer,\n    triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen, unsigned_vec_pair_gen_var_1, unsigned_vec_pair_gen_var_6,\n    unsigned_vec_triple_gen_var_31, unsigned_vec_triple_gen_var_32,\n    unsigned_vec_unsigned_pair_gen_var_15,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::and::{\n    limbs_and, limbs_and_in_place_either, limbs_and_limb, limbs_and_same_length_to_out,\n    limbs_and_to_out, limbs_slice_and_in_place_left, limbs_slice_and_same_length_in_place_left,\n    limbs_vec_and_in_place_left,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_min_bit_bucketer, pair_natural_min_bit_bucketer,\n    triple_3_pair_natural_min_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_pair_gen_nrm, natural_pair_gen_rm,\n};\nuse malachite_nz::test_util::natural::logic::and::{natural_and_alt_1, natural_and_alt_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_and_limb);\n    register_demo!(runner, demo_limbs_and);\n    register_demo!(runner, demo_limbs_and_same_length_to_out);\n    register_demo!(runner, demo_limbs_and_to_out);\n    register_demo!(runner, demo_limbs_slice_and_same_length_in_place_left);\n    register_demo!(runner, demo_limbs_slice_and_in_place_left);\n    register_demo!(runner, demo_limbs_vec_and_in_place_left);\n    register_demo!(runner, demo_limbs_and_in_place_either);\n    register_demo!(runner, demo_natural_and_assign);\n    register_demo!(runner, demo_natural_and_assign_ref);\n    register_demo!(runner, demo_natural_and);\n    register_demo!(runner, demo_natural_and_val_ref);\n    register_demo!(runner, demo_natural_and_ref_val);\n    register_demo!(runner, demo_natural_and_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_and_limb);\n    register_bench!(runner, benchmark_limbs_and);\n    register_bench!(runner, benchmark_limbs_and_same_length_to_out);\n    register_bench!(runner, benchmark_limbs_and_to_out);\n    register_bench!(runner, benchmark_limbs_slice_and_same_length_in_place_left);\n    register_bench!(runner, benchmark_limbs_slice_and_in_place_left);\n    register_bench!(runner, benchmark_limbs_vec_and_in_place_left);\n    register_bench!(runner, benchmark_limbs_and_in_place_either);\n    register_bench!(runner, benchmark_natural_and_assign_library_comparison);\n    register_bench!(runner, benchmark_natural_and_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_and_library_comparison);\n    register_bench!(runner, benchmark_natural_and_algorithms);\n    register_bench!(runner, benchmark_natural_and_evaluation_strategy);\n}\n\nfn demo_limbs_and_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_and_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_and_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_and(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        println!(\"limbs_and({:?}, {:?}) = {:?}\", xs, ys, limbs_and(&xs, &ys));\n    }\n}\n\nfn demo_limbs_and_same_length_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_31().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_and_same_length_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_and_same_length_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_and_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_32().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_and_to_out(&mut out, &xs, &ys);\n        println!(\"out := {out_old:?}; limbs_and_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_slice_and_same_length_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        let mut xs = xs.to_vec();\n        let xs_old = xs.clone();\n        limbs_slice_and_same_length_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_and_same_length_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_slice_and_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let truncate_size = limbs_slice_and_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            limbs_slice_and_in_place_left(&mut xs, {ys:?}) = {truncate_size:?}; xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_vec_and_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_vec_and_in_place_left(&mut xs, &ys);\n        println!(\"xs := {xs_old:?}; limbs_vec_and_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_and_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_and_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_and_in_place_either(&mut xs, &mut ys) = {right}; \\\n             xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_natural_and_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x &= y.clone();\n        println!(\"x := {x_old}; x &= {y}; x = {x}\");\n    }\n}\n\nfn demo_natural_and_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x &= &y;\n        println!(\"x := {x_old}; x &= &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_and(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} & {} = {}\", x_old, y_old, x & y);\n    }\n}\n\nfn demo_natural_and_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} & &{} = {}\", x_old, y, x & &y);\n    }\n}\n\nfn demo_natural_and_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} & {} = {}\", x, y_old, &x & y);\n    }\n}\n\nfn demo_natural_and_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} & &{} = {}\", x, y, &x & &y);\n    }\n}\n\nfn benchmark_limbs_and_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_and_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_and_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_limbs_and(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_and(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(limbs_and(&xs, &ys)))],\n    );\n}\n\nfn benchmark_limbs_and_same_length_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_and_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            limbs_and_same_length_to_out(&mut out, &xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_and_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_and_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            limbs_and_to_out(&mut out, &xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_and_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_and_same_length_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            limbs_slice_and_same_length_in_place_left(&mut xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_slice_and_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_slice_and_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            no_out!(limbs_slice_and_in_place_left(&mut xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_and_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_vec_and_in_place_left(&Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            limbs_vec_and_in_place_left(&mut xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_and_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_and_in_place_either(&mut [Limb], &mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_min_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            no_out!(limbs_and_in_place_either(&mut xs, &mut ys));\n        })],\n    );\n}\n\nfn benchmark_natural_and_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural &= Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_min_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x &= y), (\"rug\", &mut |((mut x, y), _)| x &= y)],\n    );\n}\n\nfn benchmark_natural_and_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural &= Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_min_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural &= Natural\", &mut |(mut x, y)| no_out!(x &= y)),\n            (\"Natural &= &Natural\", &mut |(mut x, y)| no_out!(x &= &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_and_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural & Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_min_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x & y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x & y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x & y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_and_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural & Natural\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_min_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(ref x, ref y)| no_out!(x & y)),\n            (\"using bits explicitly\", &mut |(ref x, ref y)| {\n                no_out!(natural_and_alt_1(x, y));\n            }),\n            (\"using limbs explicitly\", &mut |(ref x, ref y)| {\n                no_out!(natural_and_alt_2(x, y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_and_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural & Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_min_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural & Natural\", &mut |(x, y)| no_out!(x & y)),\n            (\"Natural & &Natural\", &mut |(x, y)| no_out!(x & &y)),\n            (\"&Natural & Natural\", &mut |(x, y)| no_out!(&x & y)),\n            (\"&Natural & &Natural\", &mut |(x, y)| no_out!(&x & &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/assign_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::pair_2_triple_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_bool_triple_gen_var_1, natural_unsigned_bool_triple_gen_var_1_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_assign_bit);\n    register_bench!(runner, benchmark_natural_assign_bit_library_comparison);\n}\n\nfn demo_natural_assign_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index, bit) in natural_unsigned_bool_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.assign_bit(index, bit);\n        println!(\"x := {n_old}; x.assign_bit({index}, {bit}); x = {n}\");\n    }\n}\n\nfn benchmark_natural_assign_bit_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.assign_bit(u64, bool)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_bool_triple_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_triple_2_bucketer(\"index\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut n, index, bit))| {\n                n.assign_bit(index, bit);\n            }),\n            (\"rug\", &mut |((mut n, index, bit), _)| {\n                no_out!(n.set_bit(u32::exact_from(index), bit));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/assign_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::bench::bucketers::quadruple_3_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::large_type_gen_var_3;\nuse malachite_base::test_util::num::logic::bit_block_access::assign_bits_naive;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_block_access::limbs_assign_bits;\nuse malachite_nz::test_util::generators::natural_unsigned_unsigned_natural_quadruple_gen_var_1;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_assign_bits);\n    register_demo!(runner, demo_natural_assign_bits);\n    register_bench!(runner, benchmark_limbs_assign_bits);\n    register_bench!(runner, benchmark_natural_assign_bits_algorithms);\n}\n\nfn demo_limbs_assign_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, start, end, bits) in large_type_gen_var_3().get(gm, config).take(limit) {\n        let old_xs = xs.clone();\n        limbs_assign_bits(&mut xs, start, end, &bits);\n        println!(\n            \"xs := {old_xs:?}; limbs_assign_bits(&mut xs, {start}, {end}, &{bits:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_natural_assign_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, start, end, bits) in natural_unsigned_unsigned_natural_quadruple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n.clone();\n        n.assign_bits(start, end, &bits);\n        println!(\"n := {old_n}; n.assign_bits({start}, {end}, &{bits}); n = {n}\");\n    }\n}\n\nfn benchmark_limbs_assign_bits(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_assign_bits(&mut Vec<Limb>, u64, u64, &[Limb])\",\n        BenchmarkType::Single,\n        large_type_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_bucketer(\"end\"),\n        &mut [(\"limbs_assign_bits\", &mut |(\n            ref mut limbs,\n            start,\n            end,\n            ref bits,\n        )| {\n            limbs_assign_bits(limbs, start, end, bits);\n        })],\n    );\n}\n\nfn benchmark_natural_assign_bits_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.assign_bits(u64, u64, &Natural)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_unsigned_natural_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_3_bucketer(\"end\"),\n        &mut [\n            (\"default\", &mut |(mut n, start, end, bits)| {\n                n.assign_bits(start, end, &bits);\n            }),\n            (\"naive\", &mut |(mut n, start, end, bits)| {\n                assign_bits_naive::<Natural, Natural>(&mut n, start, end, &bits);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_1_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_4};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_bits);\n    register_demo!(runner, demo_natural_bits_rev);\n    register_demo!(runner, demo_natural_bits_size_hint);\n\n    register_bench!(runner, benchmark_natural_bits_size_hint);\n    register_bench!(runner, benchmark_natural_bits_get_algorithms);\n}\n\nfn demo_natural_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"bits({}) = {:?}\", n, n.bits().collect_vec());\n    }\n}\n\nfn demo_natural_bits_rev(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"bits({}).rev() = {:?}\", n, n.bits().rev().collect_vec());\n    }\n}\n\nfn demo_natural_bits_size_hint(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"bits({}).size_hint() = {:?}\", n, n.bits().size_hint());\n    }\n}\n\nfn benchmark_natural_bits_size_hint(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.bits().size_hint()\",\n        BenchmarkType::Single,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"x\"),\n        &mut [(\"Natural.bits().size_hint()\", &mut |n| {\n            no_out!(n.bits().size_hint());\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation)]\nfn benchmark_natural_bits_get_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.bits()[u64]\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural.bits()[u]\", &mut |(n, u)| no_out!(n.bits()[u])),\n            (\"Natural.to_bits_asc()[u]\", &mut |(n, u)| {\n                let bits = n.to_bits_asc();\n                let u = usize::exact_from(u);\n                if u >= bits.len() {\n                    n < 0\n                } else {\n                    bits[u]\n                };\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/clear_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::bit_access::limbs_clear_bit;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_clear_bit);\n    register_demo!(runner, demo_natural_clear_bit);\n\n    register_bench!(runner, benchmark_limbs_clear_bit);\n    register_bench!(runner, benchmark_natural_clear_bit);\n}\n\nfn demo_limbs_clear_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, index) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_clear_bit(&mut xs, index);\n        println!(\"xs := {xs_old:?}; limbs_clear_bit(&mut xs, {index}); xs = {xs:?}\");\n    }\n}\n\nfn demo_natural_clear_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.clear_bit(index);\n        println!(\"x := {n_old}; x.clear_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_limbs_clear_bit(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_clear_bit(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut xs, index)| {\n            no_out!(limbs_clear_bit(&mut xs, index));\n        })],\n    );\n}\n\nfn benchmark_natural_clear_bit(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural.clear_bit(u64)\",\n        BenchmarkType::Single,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut n, index)| n.clear_bit(index))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::CountOnes;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::count_ones::limbs_count_ones;\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::logic::count_ones::{\n    natural_count_ones_alt_1, natural_count_ones_alt_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_count_ones);\n    register_demo!(runner, demo_natural_count_ones);\n\n    register_bench!(runner, benchmark_limbs_count_ones);\n    register_bench!(runner, benchmark_natural_count_ones_algorithms);\n}\n\nfn demo_limbs_count_ones(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\"limbs_count_ones({:?}) = {}\", xs, limbs_count_ones(&xs));\n    }\n}\n\nfn demo_natural_count_ones(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"count_ones({}) = {}\", n, n.count_ones());\n    }\n}\n\nfn benchmark_limbs_count_ones(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_count_ones(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_count_ones(&xs)))],\n    );\n}\n\nfn benchmark_natural_count_ones_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.count_ones()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.count_ones())),\n            (\"using bits explicitly\", &mut |n| {\n                no_out!(natural_count_ones_alt_1(&n));\n            }),\n            (\"using limbs explicitly\", &mut |n| {\n                no_out!(natural_count_ones_alt_2(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/flip_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::pair_2_pair_2_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_4_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_flip_bit);\n    register_bench!(runner, benchmark_natural_flip_bit_library_comparison);\n}\n\nfn demo_natural_flip_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.flip_bit(index);\n        println!(\"x := {n_old}; x.flip_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_natural_flip_bit_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.flip_bit(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_2_bucketer(\"index\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut n, index))| n.flip_bit(index)),\n            (\"rug\", &mut |((mut n, index), _)| {\n                no_out!(n.toggle_bit(u32::exact_from(index)));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitConvertible;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::bool_vec_gen;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    from_bits_asc_alt, from_bits_desc_alt,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::natural::logic::from_bits::{\n    from_bits_asc_naive, from_bits_desc_naive,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_from_bits_asc);\n    register_demo!(runner, demo_natural_from_bits_desc);\n\n    register_bench!(runner, benchmark_natural_from_bits_asc_algorithms);\n    register_bench!(runner, benchmark_natural_from_bits_desc_algorithms);\n}\n\nfn demo_natural_from_bits_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in bool_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_bits_asc({:?}) = {:?}\",\n            bits,\n            Natural::from_bits_asc(bits.iter().copied())\n        );\n    }\n}\n\nfn demo_natural_from_bits_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in bool_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"from_bits_desc({:?}) = {:?}\",\n            bits,\n            Natural::from_bits_desc(bits.iter().copied())\n        );\n    }\n}\n\nfn benchmark_natural_from_bits_asc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_bits_asc<I: Iterator<Item=bool>>(I)\",\n        BenchmarkType::Algorithms,\n        bool_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |bits| {\n                no_out!(Natural::from_bits_asc(bits.into_iter()));\n            }),\n            (\"alt\", &mut |bits| {\n                no_out!(from_bits_asc_alt::<Natural, _>(bits.into_iter()));\n            }),\n            (\"naive\", &mut |bits| {\n                no_out!(from_bits_asc_naive(bits.into_iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_from_bits_desc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::from_bits_desc<I: Iterator<Item=bool>>(I)\",\n        BenchmarkType::Algorithms,\n        bool_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [\n            (\"default\", &mut |ref bits| {\n                no_out!(Natural::from_bits_desc(bits.iter().copied()));\n            }),\n            (\"alt\", &mut |ref bits| {\n                no_out!(from_bits_desc_alt::<Natural, _>(bits.iter().copied()));\n            }),\n            (\"naive\", &mut |ref bits| {\n                no_out!(from_bits_desc_naive(bits.iter().copied()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/get_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::{pair_2_bucketer, triple_3_pair_2_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::bit_access::limbs_get_bit;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_4_nrm,\n};\nuse malachite_nz::test_util::natural::logic::get_bit::num_get_bit;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_get_bit);\n    register_demo!(runner, demo_natural_get_bit);\n\n    register_bench!(runner, benchmark_limbs_get_bit);\n    register_bench!(runner, benchmark_natural_get_bit_library_comparison);\n}\n\nfn demo_limbs_get_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, index) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_get_bit({:?}, {}) = {}\",\n            xs,\n            index,\n            limbs_get_bit(&xs, index)\n        );\n    }\n}\n\nfn demo_natural_get_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, index) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"{}.get_bit({}) = {}\", n, index, n.get_bit(index));\n    }\n}\n\nfn benchmark_limbs_get_bit(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_get_bit(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(xs, index)| {\n            no_out!(limbs_get_bit(&xs, index));\n        })],\n    );\n}\n\nfn benchmark_natural_get_bit_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.get_bit(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_2_bucketer(\"index\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (n, index))| {\n                no_out!(n.get_bit(index));\n            }),\n            (\"num\", &mut |((n, index), _, _)| {\n                no_out!(num_get_bit(&n, index));\n            }),\n            (\"rug\", &mut |(_, (n, index), _)| {\n                no_out!(n.get_bit(u32::exact_from(index)));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/get_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitBlockAccess;\nuse malachite_base::test_util::bench::bucketers::triple_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_unsigned_triple_gen_var_3;\nuse malachite_base::test_util::num::logic::bit_block_access::get_bits_naive;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_block_access::{limbs_slice_get_bits, limbs_vec_get_bits};\nuse malachite_nz::test_util::bench::bucketers::triple_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_unsigned_unsigned_triple_gen_var_4;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_slice_get_bits);\n    register_demo!(runner, demo_limbs_vec_get_bits);\n    register_demo!(runner, demo_natural_get_bits);\n    register_demo!(runner, demo_natural_get_bits_owned);\n\n    register_bench!(runner, benchmark_limbs_get_bits_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_get_bits_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_get_bits_algorithms);\n}\n\nfn demo_limbs_slice_get_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, start, end) in unsigned_vec_unsigned_unsigned_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_slice_get_bits({:?}, {}, {}) = {:?}\",\n            xs,\n            start,\n            end,\n            limbs_slice_get_bits(&xs, start, end)\n        );\n    }\n}\n\nfn demo_limbs_vec_get_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, start, end) in unsigned_vec_unsigned_unsigned_triple_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        println!(\n            \"limbs_vec_get_bits({:?}, {}, {}) = {:?}\",\n            old_xs,\n            start,\n            end,\n            limbs_vec_get_bits(xs, start, end)\n        );\n    }\n}\n\nfn demo_natural_get_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, start, end) in natural_unsigned_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}.get_bits({}, {}) = {}\",\n            n,\n            start,\n            end,\n            n.get_bits(start, end)\n        );\n    }\n}\n\nfn demo_natural_get_bits_owned(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, start, end) in natural_unsigned_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_n = n.clone();\n        println!(\n            \"{}.get_bits_owned({}, {}) = {}\",\n            old_n,\n            start,\n            end,\n            n.get_bits_owned(start, end)\n        );\n    }\n}\n\nfn benchmark_limbs_get_bits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_get_bits(&[Limb], u64, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        unsigned_vec_unsigned_unsigned_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_vec_len_bucketer(\"xs\"),\n        &mut [\n            (\"limbs_slice_get_bits\", &mut |(xs, start, end)| {\n                no_out!(limbs_slice_get_bits(&xs, start, end));\n            }),\n            (\"limbs_vec_get_bits\", &mut |(xs, start, end)| {\n                no_out!(limbs_vec_get_bits(xs, start, end));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_get_bits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.get_bits(u64, u64)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_unsigned_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"get_bits\", &mut |(n, start, end)| {\n                no_out!(n.get_bits(start, end));\n            }),\n            (\"get_bits_owned\", &mut |(n, start, end)| {\n                no_out!(n.get_bits_owned(start, end));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_get_bits_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.get_bits(u64, u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, start, end)| {\n                no_out!(n.get_bits(start, end));\n            }),\n            (\"naive\", &mut |(n, start, end)| {\n                no_out!(get_bits_naive::<Natural, Natural>(&n, start, end));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::HammingDistance;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_vec_max_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_6, unsigned_vec_pair_gen_var_7, unsigned_vec_unsigned_pair_gen_var_15,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::hamming_distance::{\n    limbs_hamming_distance, limbs_hamming_distance_limb, limbs_hamming_distance_same_length,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_pair_gen, natural_pair_gen_rm};\nuse malachite_nz::test_util::natural::logic::hamming_distance::{\n    natural_hamming_distance_alt_1, natural_hamming_distance_alt_2, rug_hamming_distance,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_hamming_distance_limb);\n    register_demo!(runner, demo_limbs_hamming_distance_same_length);\n    register_demo!(runner, demo_limbs_hamming_distance);\n    register_demo!(runner, demo_natural_hamming_distance);\n\n    register_bench!(runner, benchmark_limbs_hamming_distance_limb);\n    register_bench!(runner, benchmark_limbs_hamming_distance_same_length);\n    register_bench!(runner, benchmark_limbs_hamming_distance);\n    register_bench!(\n        runner,\n        benchmark_natural_hamming_distance_library_comparison\n    );\n    register_bench!(runner, benchmark_natural_hamming_distance_algorithms);\n}\n\nfn demo_limbs_hamming_distance_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_hamming_distance_limb({:?}, {}) = {}\",\n            xs,\n            y,\n            limbs_hamming_distance_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_hamming_distance_same_length(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        println!(\n            \"limbs_hamming_distance_same_length({:?}, {:?}) = {}\",\n            xs,\n            ys,\n            limbs_hamming_distance_same_length(&xs, &ys),\n        );\n    }\n}\n\nfn demo_limbs_hamming_distance(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"limbs_hamming_distance({:?}, {:?}) = {}\",\n            xs,\n            ys,\n            limbs_hamming_distance(&xs, &ys)\n        );\n    }\n}\n\nfn demo_natural_hamming_distance(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"hamming_distance({}, {}) = {}\",\n            x,\n            y,\n            x.hamming_distance(&y)\n        );\n    }\n}\n\nfn benchmark_limbs_hamming_distance_limb(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_hamming_distance_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| {\n            no_out!(limbs_hamming_distance_limb(&xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_hamming_distance_same_length(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_hamming_distance_same_length(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_hamming_distance_same_length(&xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_hamming_distance(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_hamming_distance(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_hamming_distance(&xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_natural_hamming_distance_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.hamming_distance(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| {\n                no_out!(x.hamming_distance(&y));\n            }),\n            (\"rug\", &mut |((x, y), _)| {\n                no_out!(rug_hamming_distance(&x, &y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_hamming_distance_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.hamming_distance(&Natural)\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.hamming_distance(&y))),\n            (\"using bits explicitly\", &mut |(x, y)| {\n                no_out!(natural_hamming_distance_alt_1(&x, &y));\n            }),\n            (\"using limbs explicitly\", &mut |(x, y)| {\n                no_out!(natural_hamming_distance_alt_2(&x, &y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitScan;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::bit_scan::limbs_index_of_next_false_bit;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\nuse malachite_nz::test_util::natural::logic::index_of_next_false_bit::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_index_of_next_false_bit);\n    register_demo!(runner, demo_natural_index_of_next_false_bit);\n\n    register_bench!(runner, benchmark_limbs_index_of_next_false_bit);\n    register_bench!(runner, benchmark_natural_index_of_next_false_bit_algorithms);\n}\n\nfn demo_limbs_index_of_next_false_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, u) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_index_of_next_false_bit({:?}, {}) = {}\",\n            xs,\n            u,\n            limbs_index_of_next_false_bit(&xs, u)\n        );\n    }\n}\n\nfn demo_natural_index_of_next_false_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"index_of_next_false_bit({}, {}) = {:?}\",\n            n,\n            u,\n            n.index_of_next_false_bit(u)\n        );\n    }\n}\n\nfn benchmark_limbs_index_of_next_false_bit(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_index_of_next_false_bit(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, u)| {\n            no_out!(limbs_index_of_next_false_bit(&xs, u));\n        })],\n    );\n}\n\nfn benchmark_natural_index_of_next_false_bit_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.index_of_next_false_bit(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u)| {\n                no_out!(n.index_of_next_false_bit(u));\n            }),\n            (\"using bits explicitly\", &mut |(n, u)| {\n                no_out!(natural_index_of_next_false_bit_alt(&n, u));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitScan;\nuse malachite_base::test_util::bench::bucketers::pair_1_vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_16;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::bit_scan::limbs_index_of_next_true_bit;\nuse malachite_nz::test_util::bench::bucketers::pair_1_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\nuse malachite_nz::test_util::natural::logic::index_of_next_true_bit::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_index_of_next_true_bit);\n    register_demo!(runner, demo_natural_index_of_next_true_bit);\n\n    register_bench!(runner, benchmark_limbs_index_of_next_true_bit);\n    register_bench!(runner, benchmark_natural_index_of_next_true_bit_algorithms);\n}\n\nfn demo_limbs_index_of_next_true_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, u) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_index_of_next_true_bit({:?}, {}) = {:?}\",\n            xs,\n            u,\n            limbs_index_of_next_true_bit(&xs, u)\n        );\n    }\n}\n\nfn demo_natural_index_of_next_true_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, u) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"index_of_next_true_bit({}, {}) = {:?}\",\n            n,\n            u,\n            n.index_of_next_true_bit(u)\n        );\n    }\n}\n\nfn benchmark_limbs_index_of_next_true_bit(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_index_of_next_true_bit(&[Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, u)| {\n            no_out!(limbs_index_of_next_true_bit(&xs, u));\n        })],\n    );\n}\n\nfn benchmark_natural_index_of_next_true_bit_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.index_of_next_true_bit(u64)\",\n        BenchmarkType::Algorithms,\n        natural_unsigned_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(n, u)| {\n                no_out!(n.index_of_next_true_bit(u));\n            }),\n            (\"using bits explicitly\", &mut |(n, u)| {\n                no_out!(natural_index_of_next_true_bit_alt(&n, u));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::test_util::bench::bucketers::unsigned_direct_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_gen_var_5;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::low_mask::limbs_low_mask;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_low_mask);\n    register_demo!(runner, demo_natural_low_mask);\n\n    register_bench!(runner, benchmark_limbs_low_mask);\n    register_bench!(runner, benchmark_natural_low_mask_algorithms);\n}\n\nfn demo_limbs_low_mask(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"limbs_low_mask({}) = {:?}\", bits, limbs_low_mask(bits));\n    }\n}\n\nfn demo_natural_low_mask(gm: GenMode, config: &GenConfig, limit: usize) {\n    for bits in unsigned_gen_var_5().get(gm, config).take(limit) {\n        println!(\"Natural::low_mask({}) = {}\", bits, Natural::low_mask(bits));\n    }\n}\n\nfn benchmark_limbs_low_mask(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_low_mask(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |bits| no_out!(limbs_low_mask(bits)))],\n    );\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_low_mask_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.low_mask(u64)\",\n        BenchmarkType::Algorithms,\n        unsigned_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [\n            (\"Natural.low_mask(u64)\", &mut |bits| {\n                no_out!(Natural::low_mask(bits));\n            }),\n            (\"Natural.power_of_2(u64) - 1\", &mut |bits| {\n                no_out!(Natural::power_of_2(bits) - Natural::ONE);\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    and::register(runner);\n    assign_bit::register(runner);\n    assign_bits::register(runner);\n    bits::register(runner);\n    clear_bit::register(runner);\n    count_ones::register(runner);\n    flip_bit::register(runner);\n    from_bits::register(runner);\n    get_bit::register(runner);\n    get_bits::register(runner);\n    hamming_distance::register(runner);\n    index_of_next_false_bit::register(runner);\n    index_of_next_true_bit::register(runner);\n    low_mask::register(runner);\n    not::register(runner);\n    or::register(runner);\n    set_bit::register(runner);\n    significant_bits::register(runner);\n    to_bits::register(runner);\n    trailing_zeros::register(runner);\n    xor::register(runner);\n}\n\nmod and;\nmod assign_bit;\nmod assign_bits;\nmod bits;\nmod clear_bit;\nmod count_ones;\nmod flip_bit;\nmod from_bits;\nmod get_bit;\nmod get_bits;\nmod hamming_distance;\nmod index_of_next_false_bit;\nmod index_of_next_true_bit;\nmod low_mask;\nmod not;\nmod or;\nmod set_bit;\nmod significant_bits;\nmod to_bits;\nmod trailing_zeros;\nmod xor;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/not.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{pair_2_vec_len_bucketer, vec_len_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{unsigned_vec_gen, unsigned_vec_pair_gen_var_1};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::not::{limbs_not, limbs_not_in_place, limbs_not_to_out};\nuse malachite_nz::test_util::bench::bucketers::{\n    natural_bit_bucketer, pair_2_natural_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_not);\n    register_demo!(runner, demo_limbs_not_to_out);\n    register_demo!(runner, demo_limbs_not_in_place);\n    register_demo!(runner, demo_natural_not);\n    register_demo!(runner, demo_natural_not_ref);\n\n    register_bench!(runner, benchmark_limbs_not);\n    register_bench!(runner, benchmark_limbs_not_to_out);\n    register_bench!(runner, benchmark_limbs_not_in_place);\n    register_bench!(runner, benchmark_natural_not_library_comparison);\n    register_bench!(runner, benchmark_natural_not_evaluation_strategy);\n}\n\nfn demo_limbs_not(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        println!(\"limbs_not({:?}) = {:?}\", xs, limbs_not(&xs));\n    }\n}\n\nfn demo_limbs_not_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs) in unsigned_vec_pair_gen_var_1().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_not_to_out(&mut out, &xs);\n        println!(\"out := {out_old:?}; limbs_not_to_out(&mut out, &{xs:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_not_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut xs in unsigned_vec_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_not_in_place(&mut xs);\n        println!(\"xs := {xs_old:?}; limbs_not_in_place(&mut xs); xs = {xs:?}\");\n    }\n}\n\nfn demo_natural_not(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"!{} = {}\", n.clone(), !n);\n    }\n}\n\nfn demo_natural_not_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"!&{} = {}\", n, !&n);\n    }\n}\n\nfn benchmark_limbs_not(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_not(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_not(&xs)))],\n    );\n}\n\nfn benchmark_limbs_not_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_not_to_out(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs)| {\n            limbs_not_to_out(&mut out, &xs);\n        })],\n    );\n}\n\nfn benchmark_limbs_not_in_place(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_not_in_place(&mut [Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |mut xs| limbs_not_in_place(&mut xs))],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_not_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"!Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_natural_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(_, n)| no_out!(!n)), (\"rug\", &mut |(n, _)| no_out!(!n))],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_not_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"!Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [(\"-Natural\", &mut |n| no_out!(!n)), (\"-&Natural\", &mut |n| no_out!(!&n))],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_2_vec_len_bucketer, pair_vec_max_len_bucketer,\n    triple_2_3_vec_max_len_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen, unsigned_vec_pair_gen_var_6, unsigned_vec_triple_gen_var_31,\n    unsigned_vec_triple_gen_var_32, unsigned_vec_unsigned_pair_gen_var_15,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::or::{\n    limbs_or, limbs_or_in_place_either, limbs_or_in_place_left, limbs_or_limb,\n    limbs_or_limb_in_place, limbs_or_limb_to_out, limbs_or_same_length,\n    limbs_or_same_length_in_place_left, limbs_or_same_length_to_out, limbs_or_to_out,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n    triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_pair_gen_nrm, natural_pair_gen_rm,\n};\nuse malachite_nz::test_util::natural::logic::or::{natural_or_alt_1, natural_or_alt_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_or_limb);\n    register_demo!(runner, demo_limbs_or_limb_to_out);\n    register_demo!(runner, demo_limbs_or_limb_in_place);\n    register_demo!(runner, demo_limbs_or_same_length);\n    register_demo!(runner, demo_limbs_or);\n    register_demo!(runner, demo_limbs_or_same_length_to_out);\n    register_demo!(runner, demo_limbs_or_to_out);\n    register_demo!(runner, demo_limbs_or_same_length_in_place_left);\n    register_demo!(runner, demo_limbs_or_in_place_left);\n    register_demo!(runner, demo_limbs_or_in_place_either);\n    register_demo!(runner, demo_natural_or_assign);\n    register_demo!(runner, demo_natural_or_assign_ref);\n    register_demo!(runner, demo_natural_or);\n    register_demo!(runner, demo_natural_or_val_ref);\n    register_demo!(runner, demo_natural_or_ref_val);\n    register_demo!(runner, demo_natural_or_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_or_limb);\n    register_bench!(runner, benchmark_limbs_or_limb_to_out);\n    register_bench!(runner, benchmark_limbs_or_limb_in_place);\n    register_bench!(runner, benchmark_limbs_or_same_length);\n    register_bench!(runner, benchmark_limbs_or);\n    register_bench!(runner, benchmark_limbs_or_same_length_to_out);\n    register_bench!(runner, benchmark_limbs_or_to_out);\n    register_bench!(runner, benchmark_limbs_or_same_length_in_place_left);\n    register_bench!(runner, benchmark_limbs_or_in_place_left);\n    register_bench!(runner, benchmark_limbs_or_in_place_either);\n    register_bench!(runner, benchmark_natural_or_assign_library_comparison);\n    register_bench!(runner, benchmark_natural_or_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_or_library_comparison);\n    register_bench!(runner, benchmark_natural_or_algorithms);\n    register_bench!(runner, benchmark_natural_or_evaluation_strategy);\n}\n\nfn demo_limbs_or_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_or_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_or_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_or_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_or_limb_to_out(&mut out, &xs, y);\n        println!(\"out := {out_old:?}; limbs_or_limb_to_out(&mut out, {xs:?}, {y}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_or_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_or_limb_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_or_limb_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_or_same_length(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        println!(\n            \"limbs_or_same_length({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_or_same_length(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_or(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        println!(\"limbs_or({:?}, {:?}) = {:?}\", xs, ys, limbs_or(&xs, &ys));\n    }\n}\n\nfn demo_limbs_or_same_length_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_31().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_or_same_length_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_or_same_length_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_or_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_32().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_or_to_out(&mut out, &xs, &ys);\n        println!(\"out := {out_old:?}; limbs_or_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_or_same_length_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_or_same_length_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; limbs_or_same_length_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_or_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_or_in_place_left(&mut xs, &ys);\n        println!(\"xs := {xs_old:?}; limbs_or_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_or_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_or_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_or_in_place_either(&mut xs, &mut ys) = {right}; \\\n             xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_natural_or_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x |= y.clone();\n        println!(\"x := {x_old}; x |= {y}; x = {x}\");\n    }\n}\n\nfn demo_natural_or_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x |= &y;\n        println!(\"x := {x_old}; x |= &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_or(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} | {} = {}\", x_old, y_old, x | y);\n    }\n}\n\nfn demo_natural_or_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} | &{} = {}\", x_old, y, x | &y);\n    }\n}\n\nfn demo_natural_or_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} | {} = {}\", x, y_old, &x | y);\n    }\n}\n\nfn demo_natural_or_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} | &{} = {}\", x, y, &x | &y);\n    }\n}\n\nfn benchmark_limbs_or_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_or_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_or_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_limbs_or_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_or_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_or_limb_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_or_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_or_limb_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_same_length(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_or_same_length(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_or_same_length(&xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_or(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_or(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(limbs_or(&xs, &ys)))],\n    );\n}\n\nfn benchmark_limbs_or_same_length_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            limbs_or_same_length_to_out(&mut out, &xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_or_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_32().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            limbs_or_to_out(&mut out, &xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_same_length_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            limbs_or_same_length_in_place_left(&mut xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_in_place_left(&mut Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            limbs_or_in_place_left(&mut xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_or_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_or_in_place_either(&mut Vec<Limb>, &mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            no_out!(limbs_or_in_place_either(&mut xs, &mut ys));\n        })],\n    );\n}\n\nfn benchmark_natural_or_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural |= Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x |= y), (\"rug\", &mut |((mut x, y), _)| x |= y)],\n    );\n}\n\nfn benchmark_natural_or_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural |= Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural |= Natural\", &mut |(mut x, y)| no_out!(x |= y)),\n            (\"Natural |= &Natural\", &mut |(mut x, y)| no_out!(x |= &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_or_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural | Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x | y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x | y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x | y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_or_algorithms(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Natural | Natural\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(ref x, ref y)| no_out!(x | y)),\n            (\"using bits explicitly\", &mut |(ref x, ref y)| {\n                no_out!(natural_or_alt_1(x, y));\n            }),\n            (\"using limbs explicitly\", &mut |(ref x, ref y)| {\n                no_out!(natural_or_alt_2(x, y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_or_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural | Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural | Natural\", &mut |(x, y)| no_out!(x | y)),\n            (\"Natural | &Natural\", &mut |(x, y)| no_out!(x | &y)),\n            (\"&Natural | Natural\", &mut |(x, y)| no_out!(&x | y)),\n            (\"&Natural | &Natural\", &mut |(x, y)| no_out!(&x | &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/set_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::bench::bucketers::{pair_2_bucketer, pair_2_pair_2_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_16, unsigned_vec_unsigned_pair_gen_var_17,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::bit_access::{limbs_slice_set_bit, limbs_vec_set_bit};\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_4_nm,\n};\nuse malachite_nz::test_util::natural::logic::set_bit::num_set_bit;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_slice_set_bit);\n    register_demo!(runner, demo_limbs_vec_set_bit);\n    register_demo!(runner, demo_natural_set_bit);\n\n    register_bench!(runner, benchmark_limbs_slice_set_bit);\n    register_bench!(runner, benchmark_limbs_vec_set_bit);\n    register_bench!(runner, benchmark_natural_set_bit_library_comparison);\n}\n\nfn demo_limbs_slice_set_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, index) in unsigned_vec_unsigned_pair_gen_var_17()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_slice_set_bit(&mut xs, index);\n        println!(\"xs := {xs_old:?}; limbs_slice_set_bit(&mut xs, {index}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_vec_set_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, index) in unsigned_vec_unsigned_pair_gen_var_16()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_xs = xs.clone();\n        limbs_vec_set_bit(&mut xs, index);\n        println!(\"xs := {old_xs:?}; limbs_vec_set_bit(&mut xs, {index}); xs = {xs:?}\");\n    }\n}\n\nfn demo_natural_set_bit(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, index) in natural_unsigned_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.set_bit(index);\n        println!(\"x := {n_old}; x.set_bit({index}); x = {n}\");\n    }\n}\n\nfn benchmark_limbs_slice_set_bit(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_slice_set_bit(&mut [Limb], u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_17().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut xs, index)| {\n            no_out!(limbs_slice_set_bit(&mut xs, index));\n        })],\n    );\n}\n\nfn benchmark_limbs_vec_set_bit(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_vec_set_bit(&mut Vec<Limb>, u64)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_16().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_bucketer(\"index\"),\n        &mut [(\"Malachite\", &mut |(mut xs, index)| {\n            no_out!(limbs_vec_set_bit(&mut xs, index));\n        })],\n    );\n}\n\nfn benchmark_natural_set_bit_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.set_bit(u64)\",\n        BenchmarkType::LibraryComparison,\n        natural_unsigned_pair_gen_var_4_nm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_2_bucketer(\"index\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut n, index))| n.set_bit(index)),\n            (\"num\", &mut |((mut n, index), _)| num_set_bit(&mut n, index)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_1;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::significant_bits::limbs_significant_bits;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::bench::bucketers::triple_3_natural_bit_bucketer;\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_significant_bits);\n    register_demo!(runner, demo_natural_significant_bits);\n\n    register_bench!(runner, benchmark_limbs_significant_bits);\n    register_bench!(\n        runner,\n        benchmark_natural_significant_bits_library_comparison\n    );\n}\n\nfn demo_limbs_significant_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_1::<Limb>().get(gm, config).take(limit) {\n        println!(\n            \"limbs_significant_bits({:?}) = {}\",\n            xs,\n            limbs_significant_bits(&xs)\n        );\n    }\n}\n\nfn demo_natural_significant_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"significant_bits({}) = {}\", n, n.significant_bits());\n    }\n}\n\nfn benchmark_limbs_significant_bits(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_significant_bits(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_1::<Limb>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_significant_bits(&xs)))],\n    );\n}\n\nfn benchmark_natural_significant_bits_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.significant_bits()\",\n        BenchmarkType::LibraryComparison,\n        natural_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.significant_bits())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.bits())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.significant_bits())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::num::logic::bit_convertible::{to_bits_asc_alt, to_bits_desc_alt};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::logic::to_bits::{to_bits_asc_naive, to_bits_desc_naive};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_to_bits_asc);\n    register_demo!(runner, demo_natural_to_bits_desc);\n\n    register_bench!(runner, benchmark_natural_to_bits_asc_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_to_bits_asc_algorithms);\n    register_bench!(runner, benchmark_natural_to_bits_desc_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_to_bits_desc_algorithms);\n}\n\nfn demo_natural_to_bits_asc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"to_bits_asc({}) = {:?}\", n, n.to_bits_asc());\n    }\n}\n\nfn demo_natural_to_bits_desc(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"to_bits_desc({}) = {:?}\", n, n.to_bits_desc());\n    }\n}\n\nfn benchmark_natural_to_bits_asc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_bits_asc()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.to_bits_asc()\", &mut |n| no_out!(n.to_bits_asc())),\n            (\"Natural.bits().collect_vec()\", &mut |n| {\n                no_out!(n.bits().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_to_bits_asc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_bits_asc()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.to_bits_asc())),\n            (\"alt\", &mut |n| no_out!(to_bits_asc_alt(&n))),\n            (\"naive\", &mut |n| no_out!(to_bits_asc_naive(&n))),\n        ],\n    );\n}\n\nfn benchmark_natural_to_bits_desc_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_bits_desc()\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Natural.to_bits_asc()\", &mut |n| no_out!(n.to_bits_desc())),\n            (\"Natural.bits().rev().collect_vec()\", &mut |n| {\n                no_out!(n.bits().rev().collect_vec());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_to_bits_desc_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.to_bits_desc()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.to_bits_desc())),\n            (\"alt\", &mut |n| no_out!(to_bits_desc_alt(&n))),\n            (\"naive\", &mut |n| no_out!(to_bits_desc_naive(&n))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::vec_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_2;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::trailing_zeros::limbs_trailing_zeros;\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::logic::trailing_zeros::natural_trailing_zeros_alt;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_trailing_zeros);\n    register_demo!(runner, demo_natural_trailing_zeros);\n\n    register_bench!(runner, benchmark_limbs_trailing_zeros);\n    register_bench!(runner, benchmark_natural_trailing_zeros_algorithms);\n}\n\nfn demo_limbs_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in unsigned_vec_gen_var_2().get(gm, config).take(limit) {\n        println!(\n            \"limbs_trailing_zeros({:?}) = {}\",\n            xs,\n            limbs_trailing_zeros(&xs)\n        );\n    }\n}\n\nfn demo_natural_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"trailing_zeros({}) = {:?}\", n, n.trailing_zeros());\n    }\n}\n\nfn benchmark_limbs_trailing_zeros(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_trailing_zeros(&[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_len_bucketer(),\n        &mut [(\"Malachite\", &mut |xs| no_out!(limbs_trailing_zeros(&xs)))],\n    );\n}\n\nfn benchmark_natural_trailing_zeros_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.trailing_zeros()\",\n        BenchmarkType::Algorithms,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |n| no_out!(n.trailing_zeros())),\n            (\"using bits explicitly\", &mut |n| {\n                no_out!(natural_trailing_zeros_alt(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_vec_len_bucketer, pair_2_vec_len_bucketer, pair_vec_max_len_bucketer,\n    triple_2_3_vec_max_len_bucketer, triple_2_vec_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen, unsigned_vec_pair_gen_var_6, unsigned_vec_triple_gen_var_31,\n    unsigned_vec_triple_gen_var_32, unsigned_vec_unsigned_pair_gen_var_15,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::logic::xor::{\n    limbs_xor, limbs_xor_in_place_either, limbs_xor_in_place_left, limbs_xor_limb,\n    limbs_xor_limb_in_place, limbs_xor_limb_to_out, limbs_xor_same_length,\n    limbs_xor_same_length_in_place_left, limbs_xor_same_length_to_out, limbs_xor_to_out,\n};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_2_pair_natural_max_bit_bucketer, pair_natural_max_bit_bucketer,\n    triple_3_pair_natural_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_pair_gen_nrm, natural_pair_gen_rm,\n};\nuse malachite_nz::test_util::natural::logic::xor::{natural_xor_alt_1, natural_xor_alt_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_limbs_xor_limb);\n    register_demo!(runner, demo_limbs_xor_limb_to_out);\n    register_demo!(runner, demo_limbs_xor_limb_in_place);\n    register_demo!(runner, demo_limbs_xor_same_length);\n    register_demo!(runner, demo_limbs_xor);\n    register_demo!(runner, demo_limbs_xor_same_length_to_out);\n    register_demo!(runner, demo_limbs_xor_to_out);\n    register_demo!(runner, demo_limbs_xor_same_length_in_place_left);\n    register_demo!(runner, demo_limbs_xor_in_place_left);\n    register_demo!(runner, demo_limbs_xor_in_place_either);\n    register_demo!(runner, demo_natural_xor_assign);\n    register_demo!(runner, demo_natural_xor_assign_ref);\n    register_demo!(runner, demo_natural_xor);\n    register_demo!(runner, demo_natural_xor_val_ref);\n    register_demo!(runner, demo_natural_xor_ref_val);\n    register_demo!(runner, demo_natural_xor_ref_ref);\n\n    register_bench!(runner, benchmark_limbs_xor_limb);\n    register_bench!(runner, benchmark_limbs_xor_limb_to_out);\n    register_bench!(runner, benchmark_limbs_xor_limb_in_place);\n    register_bench!(runner, benchmark_limbs_xor_same_length);\n    register_bench!(runner, benchmark_limbs_xor);\n    register_bench!(runner, benchmark_limbs_xor_same_length_to_out);\n    register_bench!(runner, benchmark_limbs_xor_to_out);\n    register_bench!(runner, benchmark_limbs_xor_same_length_in_place_left);\n    register_bench!(runner, benchmark_limbs_xor_in_place_left);\n    register_bench!(runner, benchmark_limbs_xor_in_place_either);\n    register_bench!(runner, benchmark_natural_xor_assign_library_comparison);\n    register_bench!(runner, benchmark_natural_xor_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_natural_xor_library_comparison);\n    register_bench!(runner, benchmark_natural_xor_algorithms);\n    register_bench!(runner, benchmark_natural_xor_evaluation_strategy);\n}\n\nfn demo_limbs_xor_limb(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"limbs_xor_limb({:?}, {}) = {:?}\",\n            xs,\n            y,\n            limbs_xor_limb(&xs, y)\n        );\n    }\n}\n\nfn demo_limbs_xor_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, y) in unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let out_old = out.clone();\n        limbs_xor_limb_to_out(&mut out, &xs, y);\n        println!(\"out := {out_old:?}; limbs_xor_limb_to_out(&mut out, {xs:?}, {y}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_xor_limb_in_place(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, y) in unsigned_vec_unsigned_pair_gen_var_15()\n        .get(gm, config)\n        .take(limit)\n    {\n        let xs_old = xs.clone();\n        limbs_xor_limb_in_place(&mut xs, y);\n        println!(\"xs := {xs_old:?}; limbs_xor_limb_in_place(&mut xs, {y}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_xor_same_length(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        println!(\n            \"limbs_xor_same_length({:?}, {:?}) = {:?}\",\n            xs,\n            ys,\n            limbs_xor_same_length(&xs, &ys)\n        );\n    }\n}\n\nfn demo_limbs_xor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        println!(\"limbs_xor({:?}, {:?}) = {:?}\", xs, ys, limbs_xor(&xs, &ys));\n    }\n}\n\nfn demo_limbs_xor_same_length_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_31().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_xor_same_length_to_out(&mut out, &xs, &ys);\n        println!(\n            \"out := {out_old:?}; \\\n            limbs_xor_same_length_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\",\n        );\n    }\n}\n\nfn demo_limbs_xor_to_out(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut out, xs, ys) in unsigned_vec_triple_gen_var_32().get(gm, config).take(limit) {\n        let out_old = out.clone();\n        limbs_xor_to_out(&mut out, &xs, &ys);\n        println!(\"out := {out_old:?}; limbs_xor_to_out(&mut out, {xs:?}, {ys:?}); out = {out:?}\");\n    }\n}\n\nfn demo_limbs_xor_same_length_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen_var_6().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_xor_same_length_in_place_left(&mut xs, &ys);\n        println!(\n            \"xs := {xs_old:?}; limbs_xor_same_length_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\",\n        );\n    }\n}\n\nfn demo_limbs_xor_in_place_left(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        limbs_xor_in_place_left(&mut xs, &ys);\n        println!(\"xs := {xs_old:?}; limbs_xor_in_place_left(&mut xs, {ys:?}); xs = {xs:?}\");\n    }\n}\n\nfn demo_limbs_xor_in_place_either(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut xs, mut ys) in unsigned_vec_pair_gen().get(gm, config).take(limit) {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_xor_in_place_either(&mut xs, &mut ys);\n        println!(\n            \"xs := {xs_old:?}; \\\n            ys := {ys_old:?}; limbs_xor_in_place_either(&mut xs, &mut ys) = {right}; \\\n             xs = {xs:?}; ys = {ys:?}\",\n        );\n    }\n}\n\nfn demo_natural_xor_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x ^= y.clone();\n        println!(\"x := {x_old}; x ^= {y}; x = {x}\");\n    }\n}\n\nfn demo_natural_xor_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x ^= &y;\n        println!(\"x := {x_old}; x ^= &{y}; x = {x}\");\n    }\n}\n\nfn demo_natural_xor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} ^ {} = {}\", x_old, y_old, x ^ y);\n    }\n}\n\nfn demo_natural_xor_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} ^ &{} = {}\", x_old, y, x ^ &y);\n    }\n}\n\nfn demo_natural_xor_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} ^ {} = {}\", x, y_old, &x ^ y);\n    }\n}\n\nfn demo_natural_xor_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in natural_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} ^ &{} = {}\", x, y, &x ^ &y);\n    }\n}\n\nfn benchmark_limbs_xor_limb(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_xor_limb(&[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, y)| no_out!(limbs_xor_limb(&xs, y)))],\n    );\n}\n\nfn benchmark_limbs_xor_limb_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_xor_limb_to_out(&mut [Limb], &[Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, y)| {\n            no_out!(limbs_xor_limb_to_out(&mut out, &xs, y));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_limb_in_place(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_limb_in_place(&mut [Limb], Limb)\",\n        BenchmarkType::Single,\n        unsigned_vec_unsigned_pair_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, y)| {\n            limbs_xor_limb_in_place(&mut xs, y);\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_same_length(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_xor_same_length(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| {\n            no_out!(limbs_xor_same_length(&xs, &ys));\n        })],\n    );\n}\n\nfn benchmark_limbs_xor(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_xor(&[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(xs, ys)| no_out!(limbs_xor(&xs, &ys)))],\n    );\n}\n\nfn benchmark_limbs_xor_same_length_to_out(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_31().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            limbs_xor_same_length_to_out(&mut out, &xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_to_out(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"limbs_xor_same_length_to_out(&mut [Limb], &[Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_triple_gen_var_32().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_2_3_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut out, xs, ys)| {\n            limbs_xor_to_out(&mut out, &xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_same_length_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_same_length_in_place_left(&mut [Limb], &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_len_bucketer(\"xs\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            limbs_xor_same_length_in_place_left(&mut xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_in_place_left(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_in_place_left(&mut Vec<Limb>, &[Limb])\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_vec_len_bucketer(\"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, ys)| {\n            limbs_xor_in_place_left(&mut xs, &ys);\n        })],\n    );\n}\n\nfn benchmark_limbs_xor_in_place_either(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"limbs_xor_in_place_either(&mut Vec<Limb>, &mut Vec<Limb>)\",\n        BenchmarkType::Single,\n        unsigned_vec_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_vec_max_len_bucketer(\"xs\", \"ys\"),\n        &mut [(\"Malachite\", &mut |(mut xs, mut ys)| {\n            no_out!(limbs_xor_in_place_either(&mut xs, &mut ys));\n        })],\n    );\n}\n\nfn benchmark_natural_xor_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural ^= Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x ^= y), (\"rug\", &mut |((mut x, y), _)| x ^= y)],\n    );\n}\n\nfn benchmark_natural_xor_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural ^= Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural ^= Natural\", &mut |(mut x, y)| no_out!(x ^= y)),\n            (\"Natural ^= &Natural\", &mut |(mut x, y)| no_out!(x ^= &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_xor_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural ^ Natural\",\n        BenchmarkType::LibraryComparison,\n        natural_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x ^ y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x ^ y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x ^ y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_xor_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural ^ Natural\",\n        BenchmarkType::Algorithms,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(ref x, ref y)| no_out!(x ^ y)),\n            (\"using bits explicitly\", &mut |(ref x, ref y)| {\n                no_out!(natural_xor_alt_1(x, y));\n            }),\n            (\"using limbs explicitly\", &mut |(ref x, ref y)| {\n                no_out!(natural_xor_alt_2(x, y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_natural_xor_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural ^ Natural\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Natural ^ Natural\", &mut |(x, y)| no_out!(x ^ y)),\n            (\"Natural ^ &Natural\", &mut |(x, y)| no_out!(x ^ &y)),\n            (\"&Natural ^ Natural\", &mut |(x, y)| no_out!(&x ^ y)),\n            (\"&Natural ^ &Natural\", &mut |(x, y)| no_out!(&x ^ &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/demo_and_bench/natural/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    arithmetic::register(runner);\n    comparison::register(runner);\n    conversion::register(runner);\n    factorization::register(runner);\n    logic::register(runner);\n}\n\nmod arithmetic;\nmod comparison;\nmod conversion;\nmod factorization;\nmod logic;\n"
  },
  {
    "path": "malachite-nz/src/bin_util/generate/digits_data.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 2000, 2001, 2002, 2004, 2011, 2012, 2015-2018 Free\n//      Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{FloorSqrt, ModPowerOf2, Parity, Pow, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, LowMask, SignificantBits};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\n// Calculate r satisfying r*d == 1 mod 2^n.\n//\n// This is equivalent to `mpz_invert_2exp` from `bootstrap.c`, GMP 6.2.1.\nfn invert_mod_power_of_2(x: &Natural, pow: u64) -> Natural {\n    assert!(x.odd());\n    let mut inverse = Natural::ONE;\n    for i in 0..pow {\n        if (&inverse * x).get_bit(i) {\n            inverse.set_bit(i);\n        }\n    }\n    assert_eq!((&inverse * x).mod_power_of_2(pow), 1);\n    inverse\n}\n\n// Compute log(2) / log(b) as a fixnum.\n//\n// This is equivalent to `mp_2logb` from `gen-bases.c`, GMP 6.2.1.\nfn get_log_base_of_2(base: u64, precision: u64) -> Natural {\n    let extended_precision = precision + 16;\n    let mut t = Natural::power_of_2(extended_precision);\n    let two = &t << 1;\n    let mut log = Natural::ZERO;\n    let mut base = Natural::from(base) << extended_precision;\n    for i in (0..precision).rev() {\n        base = (&base << extended_precision).floor_sqrt();\n        let next_t = (&t * &base) >> extended_precision;\n        if next_t < two {\n            log.set_bit(i);\n            t = next_t;\n        }\n    }\n    log\n}\n\nstruct BaseData {\n    chars_per_limb: u64,\n    big_base_trailing_zeros: u64,\n    big_base: Natural,\n    normalization_steps: u64,\n    big_base_inverted: Natural,\n    big_base_inverted_mod_b: Natural,\n}\n\n// This is equivalent to `generate` from `gen-bases.c`, GMP 6.2.1.\nfn generate(base: u64) -> BaseData {\n    let limit = Natural::power_of_2(Limb::WIDTH);\n    let mut big_base = Natural::ONE;\n    let mut chars_per_limb = 0;\n    while big_base <= limit {\n        chars_per_limb += 1;\n        big_base *= Natural::from(base);\n    }\n    chars_per_limb -= 1;\n    big_base = Natural::from(base).pow(chars_per_limb);\n    let normalization_steps = Limb::WIDTH.wrapping_sub(big_base.significant_bits());\n    let mut big_base_inverted =\n        Natural::power_of_2((Limb::WIDTH << 1).wrapping_sub(normalization_steps)) / &big_base;\n    big_base_inverted.clear_bit(Limb::WIDTH);\n    let big_base_trailing_zeros = big_base.trailing_zeros().unwrap();\n    let big_base_odd = &big_base >> big_base_trailing_zeros;\n    let big_base_inverted_mod_b = invert_mod_power_of_2(&big_base_odd, Limb::WIDTH);\n    BaseData {\n        chars_per_limb,\n        big_base_trailing_zeros,\n        big_base,\n        normalization_steps,\n        big_base_inverted,\n        big_base_inverted_mod_b,\n    }\n}\n\n// This is equivalent to `header` from `gen-bases.c`, GMP 6.2.1.\nfn header() {\n    let data = generate(10);\n    println!(\"// mp_bases[10] data, as literal values\");\n    println!(\n        \"pub const MP_BASES_CHARS_PER_LIMB_10: usize = {};\",\n        data.chars_per_limb\n    );\n    println!(\n        \"pub const MP_BASES_BIG_BASE_CTZ_10: usize = {};\",\n        data.big_base_trailing_zeros\n    );\n    println!(\n        \"pub const MP_BASES_BIG_BASE_10: Limb = {:#x};\",\n        Limb::exact_from(&data.big_base)\n    );\n    println!(\n        \"pub const MP_BASES_BIG_BASE_INVERTED_10: Limb = {:#x};\",\n        Limb::exact_from(&data.big_base_inverted)\n    );\n    println!(\n        \"pub const MP_BASES_BIG_BASE_BINVERTED_10: Limb = {:#x};\",\n        Limb::exact_from(&data.big_base_inverted_mod_b)\n    );\n    println!(\n        \"pub const MP_BASES_NORMALIZATION_STEPS_10: u64 = {};\",\n        data.normalization_steps\n    );\n}\n\n// This is equivalent to `table` from `gen-bases.c`, GMP 6.2.1.\nfn table() {\n    println!(\"// Format is (chars_per_limb, logb2, log2b, big_base, big_base_inverted)\");\n    println!(\"pub const BASES: [(usize, Limb, Limb, Limb, Limb); 257] = [\");\n    println!(\"    (0, 0, 0, 0, 0), // 0\");\n    println!(\"    (0, 0, 0, 0, 0), // 1\");\n    for base in 2..=256 {\n        let mut data = generate(base);\n        let raw = get_log_base_of_2(base, Limb::WIDTH + 8);\n        let log_base_of_2 = &raw >> 8;\n        let log_2_of_base = Natural::low_mask((Limb::WIDTH << 1) + 5) / (raw + Natural::ONE);\n        if base.is_power_of_two() {\n            data.big_base = Natural::from(base.significant_bits() - 1);\n            data.big_base_inverted = Natural::ZERO;\n        }\n        println!(\n            \"    ({}, {:#x}, {:#x}, {:#x}, {:#x}), // {}\",\n            data.chars_per_limb,\n            Limb::exact_from(&log_base_of_2),\n            Limb::exact_from(&log_2_of_base),\n            Limb::exact_from(&data.big_base),\n            Limb::exact_from(&data.big_base_inverted),\n            base\n        );\n    }\n    println!(\"];\");\n}\n\npub(crate) fn generate_string_data() {\n    println!(\"// This section is created by digits_data.rs.\");\n    println!();\n    header();\n    println!();\n    table();\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/generate/factorial_data.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2002, 2010-2018 Free Software Foundation, Inc.\n//\n//      `mpz/bin_uiui.c` contributed to the GNU project by Torbjörn Granlund and Marco Bodrato.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, BinomialCoefficient, CheckedDoubleFactorial, DivExactAssign, FloorRoot,\n    ModPowerOf2Inverse, OverflowingMulAssign, WrappingMulAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::CountOnes;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\n#[allow(clippy::useless_conversion)]\nfn odd_factorial_table() -> (u64, u64) {\n    let mut xs = vec![1, 1, 1];\n    let mut x: Limb = 1;\n    let mut limit = 0;\n    for b in Limb::from(3u32).. {\n        if x.overflowing_mul_assign(b >> b.trailing_zeros()) {\n            limit = b;\n            break;\n        }\n        xs.push(x);\n    }\n    xs.push(x);\n    let mut y = Limb::binomial_coefficient(limit, limit >> 1);\n    let mut ext_limit = 0;\n    for b in limit + 1.. {\n        let a = b >> b.trailing_zeros();\n        if a == b {\n            y.div_exact_assign((a >> 1) + 1);\n            if y.overflowing_mul_assign(a) {\n                ext_limit = b;\n                break;\n            }\n        } else if let Some(shifted) = y.arithmetic_checked_shl(1) {\n            y = shifted;\n        } else {\n            ext_limit = b;\n            break;\n        }\n        x.wrapping_mul_assign(a);\n        xs.push(x);\n    }\n    println!(\n        \"// This is equivalent to `__gmp_oddfac_table` in `mpn/comb_tables.c`, GMP 6.2.1, which \\\n        is the\"\n    );\n    println!(\n        \"// combination of `ONE_LIMB_ODD_FACTORIAL_TABLE` and `ONE_LIMB_ODD_FACTORIAL_EXTTABLE` in\"\n    );\n    println!(\"// `fac_table.h`, GMP 6.2.1.\");\n    print!(\n        \"pub const ONE_LIMB_ODD_FACTORIAL_TABLE: [Limb; {}] = [\",\n        xs.len()\n    );\n    let mut first = true;\n    for &x in &xs {\n        if first {\n            first = false;\n        } else {\n            print!(\", \");\n        }\n        print!(\"{x:#x}\");\n    }\n    println!(\"];\");\n    limit -= 1;\n    ext_limit -= 1;\n    println!(\"// This is equivalent to `ODD_FACTORIAL_TABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\");\n    println!(\"pub const ODD_FACTORIAL_TABLE_LIMIT: usize = {limit};\");\n    println!(\n        \"// This is equivalent to `ODD_FACTORIAL_EXTTABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\"\n    );\n    println!(\"pub const ODD_FACTORIAL_EXTTABLE_LIMIT: usize = {ext_limit};\");\n    println!(\"// This is equivalent to `ODD_FACTORIAL_TABLE_MAX` in `fac_table.h`, GMP 6.2.1.\");\n    println!(\n        \"pub const ODD_FACTORIAL_TABLE_MAX: Limb = {:#x};\",\n        xs[usize::wrapping_from(limit)]\n    );\n    (u64::from(limit), u64::from(ext_limit))\n}\n\nfn odd_double_factorial_table() {\n    let mut xs = vec![];\n    let mut limit = 0;\n    for n in 0.. {\n        let n = (n << 1) | 1;\n        if let Some(x) = Limb::checked_double_factorial(n) {\n            xs.push(x);\n        } else {\n            limit = n;\n            break;\n        }\n    }\n    println!(\n        \"// This is equivalent to `__gmp_odd2fac_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\"\n    );\n    println!(\"// `ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE` from `fac_table.h`, GMP 6.2.1.\");\n    print!(\n        \"pub const ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE: [Limb; {}] = [\",\n        xs.len()\n    );\n    let mut first = true;\n    for &x in &xs {\n        if first {\n            first = false;\n        } else {\n            print!(\", \");\n        }\n        print!(\"{x:#x}\");\n    }\n    println!(\"];\");\n    limit -= 2;\n    println!(\n        \"// This is equivalent to `ODD_DOUBLEFACTORIAL_TABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\"\n    );\n    println!(\"pub const ODD_DOUBLEFACTORIAL_TABLE_LIMIT: usize = {limit};\");\n    println!(\n        \"// This is equivalent to `ODD_DOUBLEFACTORIAL_TABLE_MAX` in `fac_table.h`, GMP 6.2.1.\"\n    );\n    println!(\n        \"pub const ODD_DOUBLEFACTORIAL_TABLE_MAX: Limb = {:#x};\",\n        xs[usize::wrapping_from(limit >> 1)]\n    );\n}\n\nfn nth_root_mask_table() {\n    println!(\n        \"// This is equivalent to `__gmp_limbroots_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\"\n    );\n    println!(\"// `NTH_ROOT_NUMB_MASK_TABLE` from `fac_table.h`, GMP 6.2.1.\");\n    print!(\"pub const NTH_ROOT_NUMB_MASK_TABLE: [Limb; 8] = [Limb::MAX\");\n    for b in 2..=8 {\n        print!(\", {:#x}\", Limb::MAX.floor_root(b));\n    }\n    println!(\"];\");\n}\n\nfn factorial_inverse_table(limit: u64) {\n    println!(\n        \"// This is equivalent to `ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE` from `fac_table.h`, \\\n        GMP 6.2.1.\"\n    );\n    print!(\n        \"pub const ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE: [Limb; {}] = [0x1\",\n        limit - 3\n    );\n    let limit = Limb::wrapping_from(limit);\n    let mut x: Limb = 1;\n    for b in 3..=limit - 2 {\n        x.wrapping_mul_assign(b >> b.trailing_zeros());\n        print!(\", {:#x}\", x.mod_power_of_2_inverse(Limb::WIDTH).unwrap());\n    }\n    println!(\"];\");\n}\n\nfn factorial_2_count_table(limit: u64) {\n    println!(\"// https://oeis.org/A005187, skipping the initial 0\");\n    println!(\"//\");\n    println!(\n        \"// This is equivalent to `__gmp_fac2cnt_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\"\n    );\n    println!(\"// `TABLE_2N_MINUS_POPC_2N` from `fac_table.h`, GMP 6.2.1.\");\n    let limit = ((limit >> 4) + 1) << 4;\n    let mut b = 4;\n    print!(\n        \"pub const TABLE_2N_MINUS_POPC_2N: [u8; {}] = [1\",\n        ((limit - b) >> 1) + 2\n    );\n    while b <= limit {\n        print!(\", {}\", b - CountOnes::count_ones(b));\n        b += 2;\n    }\n    println!(\"];\");\n    println!();\n    println!(\n        \"pub const TABLE_LIMIT_2N_MINUS_POPC_2N: u64 = {};\",\n        limit + 1\n    );\n}\n\nfn odd_central_binomial_table(limit: u64) -> u64 {\n    println!(\"pub const ODD_CENTRAL_BINOMIAL_OFFSET: usize = {limit};\");\n    println!();\n    println!(\"// This table contains binomial(2k, k) / 2 ^ t.\");\n    println!(\"//\");\n    println!(\"// This is equivalent to `bin2kk` in `mpz/bin_uiui.c`, GMP 6.2.1, and\");\n    println!(\"// `ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE` from `fac_table.h`, GMP 6.2.1.\");\n    let mut xs = Vec::new();\n    let mut binomial_limit = 0;\n    for b in limit.. {\n        binomial_limit = b;\n        let mut x = Natural::binomial_coefficient(Natural::from(b) << 1u32, Natural::from(b));\n        x >>= x.trailing_zeros().unwrap();\n        if let Ok(x) = Limb::try_from(&x) {\n            xs.push(x);\n        } else {\n            break;\n        }\n    }\n    print!(\n        \"pub const ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE: [Limb; {}] = [\",\n        xs.len()\n    );\n    let mut first = true;\n    for &x in &xs {\n        if first {\n            first = false;\n        } else {\n            print!(\", \");\n        }\n        print!(\"{x:#x}\");\n    }\n    println!(\"];\");\n    u64::wrapping_from(binomial_limit)\n}\n\nfn odd_central_binomial_inverse_table(limit: u64, binomial_limit: u64) {\n    let binomial_limit = binomial_limit - 1;\n    println!(\"pub const ODD_CENTRAL_BINOMIAL_TABLE_LIMIT: usize = {binomial_limit};\");\n    println!();\n    println!(\"// This table contains the inverses of elements in the previous table.\");\n    println!(\"//\");\n    println!(\"// This is equivalent to `bin2kkinv` in `mpz/bin_uiui.c`, GMP 6.2.1, and\");\n    println!(\"// `ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE` from `fac_table.h`, GMP 6.2.1.\");\n    let mut xs = Vec::new();\n    for b in limit..=binomial_limit {\n        let mut x = Natural::binomial_coefficient(Natural::from(b) << 1u32, Natural::from(b));\n        x >>= x.trailing_zeros().unwrap();\n        xs.push(Limb::exact_from(\n            &(x.mod_power_of_2_inverse(Limb::WIDTH).unwrap()),\n        ));\n    }\n    print!(\n        \"pub const ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE: [Limb; {}] = [\",\n        xs.len()\n    );\n    let mut first = true;\n    for &x in &xs {\n        if first {\n            first = false;\n        } else {\n            print!(\", \");\n        }\n        print!(\"{x:#x}\");\n    }\n    println!(\"];\");\n}\n\nfn central_binomial_2_fac_table(limit: u64, binomial_limit: u64) {\n    let binomial_limit = binomial_limit - 1;\n    println!(\"// This table contains the values t in the formula binomial(2k, k) / 2 ^ t.\");\n    println!(\"//\");\n    println!(\"// This is equivalent to `fac2bin` in `mpz/bin_uiui.c`, GMP 6.2.1, and\");\n    println!(\"// `CENTRAL_BINOMIAL_2FAC_TABLE` from `fac_table.h`, GMP 6.2.1.\");\n    let mut xs = Vec::new();\n    for b in limit..=binomial_limit {\n        xs.push(\n            Natural::binomial_coefficient(Natural::from(b) << 1u32, Natural::from(b))\n                .trailing_zeros()\n                .unwrap(),\n        );\n    }\n    print!(\n        \"pub const CENTRAL_BINOMIAL_2FAC_TABLE: [u64; {}] = [\",\n        xs.len()\n    );\n    let mut first = true;\n    for &x in &xs {\n        if first {\n            first = false;\n        } else {\n            print!(\", \");\n        }\n        print!(\"{x}\");\n    }\n    println!(\"];\");\n}\n\npub(crate) fn generate_factorial_data() {\n    println!(\"// This section is created by factorial_data.rs.\");\n    println!();\n    let (mut of_limit, ext_limit) = odd_factorial_table();\n    println!();\n    odd_double_factorial_table();\n    println!();\n    nth_root_mask_table();\n    println!();\n    factorial_inverse_table(ext_limit);\n    println!();\n    of_limit = (of_limit + 1) >> 1;\n    let binomial_limit = odd_central_binomial_table(of_limit);\n    println!();\n    odd_central_binomial_inverse_table(of_limit, binomial_limit);\n    println!();\n    central_binomial_2_fac_table(of_limit, binomial_limit);\n    println!();\n    factorial_2_count_table(u64::exact_from(ext_limit));\n}\n"
  },
  {
    "path": "malachite-nz/src/bin_util/generate/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod digits_data;\npub mod factorial_data;\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign, UnsignedAbs};\n\nimpl Abs for Integer {\n    type Output = Self;\n\n    /// Takes the absolute value of an [`Integer`], taking the [`Integer`] by value.\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Abs;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.abs(), 0);\n    /// assert_eq!(Integer::from(123).abs(), 123);\n    /// assert_eq!(Integer::from(-123).abs(), 123);\n    /// ```\n    #[inline]\n    fn abs(mut self) -> Self {\n        self.sign = true;\n        self\n    }\n}\n\nimpl Abs for &Integer {\n    type Output = Integer;\n\n    /// Takes the absolute value of an [`Integer`], taking the [`Integer`] by reference.\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Abs;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::ZERO).abs(), 0);\n    /// assert_eq!((&Integer::from(123)).abs(), 123);\n    /// assert_eq!((&Integer::from(-123)).abs(), 123);\n    /// ```\n    fn abs(self) -> Integer {\n        Integer {\n            sign: true,\n            abs: self.abs.clone(),\n        }\n    }\n}\n\nimpl AbsAssign for Integer {\n    /// Replaces an [`Integer`] with its absolute value.\n    ///\n    /// $$\n    /// x \\gets |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x.abs_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Integer::from(123);\n    /// x.abs_assign();\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Integer::from(-123);\n    /// x.abs_assign();\n    /// assert_eq!(x, 123);\n    /// ```\n    #[inline]\n    fn abs_assign(&mut self) {\n        self.sign = true;\n    }\n}\n\nimpl UnsignedAbs for Integer {\n    type Output = Natural;\n\n    /// Takes the absolute value of an [`Integer`], taking the [`Integer`] by value and converting\n    /// the result to a [`Natural`].\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::UnsignedAbs;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.unsigned_abs(), 0);\n    /// assert_eq!(Integer::from(123).unsigned_abs(), 123);\n    /// assert_eq!(Integer::from(-123).unsigned_abs(), 123);\n    /// ```\n    #[inline]\n    fn unsigned_abs(self) -> Natural {\n        self.abs\n    }\n}\n\nimpl UnsignedAbs for &Integer {\n    type Output = Natural;\n\n    /// Takes the absolute value of an [`Integer`], taking the [`Integer`] by reference and\n    /// converting the result to a [`Natural`].\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::UnsignedAbs;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::ZERO).unsigned_abs(), 0);\n    /// assert_eq!((&Integer::from(123)).unsigned_abs(), 123);\n    /// assert_eq!((&Integer::from(-123)).unsigned_abs(), 123);\n    /// ```\n    #[inline]\n    fn unsigned_abs(self) -> Natural {\n        self.abs.clone()\n    }\n}\n\nimpl Integer {\n    /// Finds the absolute value of an [`Integer`], taking the [`Integer`] by reference and\n    /// returning a reference to the internal [`Natural`] absolute value.\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(*Integer::ZERO.unsigned_abs_ref(), 0);\n    /// assert_eq!(*Integer::from(123).unsigned_abs_ref(), 123);\n    /// assert_eq!(*Integer::from(-123).unsigned_abs_ref(), 123);\n    /// ```\n    #[inline]\n    pub const fn unsigned_abs_ref(&self) -> &Natural {\n        &self.abs\n    }\n\n    /// Mutates the absolute value of an [`Integer`] using a provided closure, and then returns\n    /// whatever the closure returns.\n    ///\n    /// This function is similar to the [`unsigned_abs_ref`](Integer::unsigned_abs_ref) function,\n    /// which returns a reference to the absolute value. A function that returns a _mutable_\n    /// reference would be too dangerous, as it could leave the [`Integer`] in an invalid state\n    /// (specifically, with a negative sign but a zero absolute value). So rather than returning a\n    /// mutable reference, this function allows mutation of the absolute value using a closure.\n    /// After the closure executes, this function ensures that the [`Integer`] remains valid.\n    ///\n    /// There is only constant time and memory overhead on top of the time and memory used by the\n    /// closure.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivAssignMod;\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Integer::from(-123);\n    /// let remainder = n.mutate_unsigned_abs(|x| x.div_assign_mod(Natural::TWO));\n    /// assert_eq!(n, -61);\n    /// assert_eq!(remainder, 1);\n    ///\n    /// let mut n = Integer::from(-123);\n    /// n.mutate_unsigned_abs(|x| *x >>= 10);\n    /// assert_eq!(n, 0);\n    /// ```\n    pub fn mutate_unsigned_abs<F: FnOnce(&mut Natural) -> T, T>(&mut self, f: F) -> T {\n        let out = f(&mut self.abs);\n        if !self.sign && self.abs == 0 {\n            self.sign = true;\n        }\n        out\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{AbsAssign, AbsDiff, AbsDiffAssign, UnsignedAbs};\n\nimpl AbsDiff<Self> for Integer {\n    type Output = Natural;\n\n    /// Computes the absolute value of the difference between two [`Integer`]s, taking both by\n    /// value. A [`Natural`] is returned.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(123).abs_diff(Integer::ZERO), 123);\n    /// assert_eq!(Integer::ZERO.abs_diff(Integer::from(123)), 123);\n    /// assert_eq!(Integer::from(456).abs_diff(Integer::from(-123)), 579);\n    /// assert_eq!(Integer::from(123).abs_diff(Integer::from(-456)), 579);\n    /// assert_eq!(\n    ///     (Integer::from(10).pow(12) * Integer::from(3)).abs_diff(Integer::from(10).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10).pow(12)).abs_diff(-Integer::from(10).pow(12) * Integer::from(3)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: Self) -> Natural {\n        (self - other).unsigned_abs()\n    }\n}\n\nimpl AbsDiff<&Self> for Integer {\n    type Output = Natural;\n\n    /// Computes the absolute value of the difference between two [`Integer`]s, taking the first by\n    /// value and the second by reference. A [`Natural`] is returned.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(123).abs_diff(&Integer::ZERO), 123);\n    /// assert_eq!(Integer::ZERO.abs_diff(&Integer::from(123)), 123);\n    /// assert_eq!(Integer::from(456).abs_diff(&Integer::from(-123)), 579);\n    /// assert_eq!(Integer::from(123).abs_diff(&Integer::from(-456)), 579);\n    /// assert_eq!(\n    ///     (Integer::from(10).pow(12) * Integer::from(3)).abs_diff(&Integer::from(10).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10).pow(12)).abs_diff(&(-Integer::from(10).pow(12) * Integer::from(3))),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: &Self) -> Natural {\n        (self - other).unsigned_abs()\n    }\n}\n\nimpl AbsDiff<Integer> for &Integer {\n    type Output = Natural;\n\n    /// Computes the absolute value of the difference between two [`Integer`]s, taking the first by\n    /// reference and the second by value. A [`Natural`] is returned.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(123)).abs_diff(Integer::ZERO), 123);\n    /// assert_eq!((&Integer::ZERO).abs_diff(Integer::from(123)), 123);\n    /// assert_eq!((&Integer::from(456)).abs_diff(Integer::from(-123)), 579);\n    /// assert_eq!((&Integer::from(123)).abs_diff(Integer::from(-456)), 579);\n    /// assert_eq!(\n    ///     (&(Integer::from(10).pow(12) * Integer::from(3))).abs_diff(Integer::from(10).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     (&(-Integer::from(10).pow(12))).abs_diff(-Integer::from(10).pow(12) * Integer::from(3)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: Integer) -> Natural {\n        (self - other).unsigned_abs()\n    }\n}\n\nimpl AbsDiff<&Integer> for &Integer {\n    type Output = Natural;\n\n    /// Computes the absolute value of the difference between two [`Integer`]s, taking both by\n    /// reference. A [`Natural`] is returned.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(123)).abs_diff(&Integer::ZERO), 123);\n    /// assert_eq!((&Integer::ZERO).abs_diff(&Integer::from(123)), 123);\n    /// assert_eq!((&Integer::from(456)).abs_diff(&Integer::from(-123)), 579);\n    /// assert_eq!((&Integer::from(123)).abs_diff(&Integer::from(-456)), 579);\n    /// assert_eq!(\n    ///     (&(Integer::from(10).pow(12) * Integer::from(3))).abs_diff(&Integer::from(10).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     (&(-Integer::from(10).pow(12)))\n    ///         .abs_diff(&(-Integer::from(10).pow(12) * Integer::from(3))),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: &Integer) -> Natural {\n        (self - other).unsigned_abs()\n    }\n}\n\nimpl AbsDiffAssign<Self> for Integer {\n    /// Subtracts an [`Integer`] by another [`Integer`] in place and takes the absolute value,\n    /// taking the [`Integer`] on the right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiffAssign, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(123);\n    /// x.abs_diff_assign(Integer::ZERO);\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x.abs_diff_assign(Integer::from(123));\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Integer::from(456);\n    /// x.abs_diff_assign(Integer::from(-123));\n    /// assert_eq!(x, 579);\n    ///\n    /// let mut x = Integer::from(-123);\n    /// x.abs_diff_assign(Integer::from(456));\n    /// assert_eq!(x, 579);\n    ///\n    /// let mut x = Integer::from(10).pow(12) * Integer::from(3);\n    /// x.abs_diff_assign(Integer::from(10u32).pow(12));\n    /// assert_eq!(x, 2000000000000u64);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.abs_diff_assign(-(Integer::from(10).pow(12) * Integer::from(3)));\n    /// assert_eq!(x, 2000000000000u64);\n    /// ```\n    #[inline]\n    fn abs_diff_assign(&mut self, other: Self) {\n        *self -= other;\n        self.abs_assign();\n    }\n}\n\nimpl<'a> AbsDiffAssign<&'a Self> for Integer {\n    /// Subtracts an [`Integer`] by another [`Integer`] in place and takes the absolute value,\n    /// taking the [`Integer`] on the right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiffAssign, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(123);\n    /// x.abs_diff_assign(&Integer::ZERO);\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x.abs_diff_assign(&Integer::from(123));\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Integer::from(456);\n    /// x.abs_diff_assign(&Integer::from(-123));\n    /// assert_eq!(x, 579);\n    ///\n    /// let mut x = Integer::from(-123);\n    /// x.abs_diff_assign(&Integer::from(456));\n    /// assert_eq!(x, 579);\n    ///\n    /// let mut x = Integer::from(10).pow(12) * Integer::from(3);\n    /// x.abs_diff_assign(&Integer::from(10u32).pow(12));\n    /// assert_eq!(x, 2000000000000u64);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.abs_diff_assign(&(-(Integer::from(10).pow(12) * Integer::from(3))));\n    /// assert_eq!(x, 2000000000000u64);\n    /// ```\n    #[inline]\n    fn abs_diff_assign(&mut self, other: &'a Self) {\n        *self -= other;\n        self.abs_assign();\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::iter::Sum;\nuse core::mem::swap;\nuse core::ops::{Add, AddAssign};\nuse malachite_base::num::basic::traits::Zero;\n\nimpl Add<Self> for Integer {\n    type Output = Self;\n\n    /// Adds two [`Integer`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO + Integer::from(123), 123);\n    /// assert_eq!(Integer::from(-123) + Integer::ZERO, -123);\n    /// assert_eq!(Integer::from(-123) + Integer::from(456), 333);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) + (Integer::from(10u32).pow(12) << 1),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    fn add(mut self, mut other: Self) -> Self {\n        if self.abs.limb_count() >= other.abs.limb_count() {\n            self += other;\n            self\n        } else {\n            other += self;\n            other\n        }\n    }\n}\n\nimpl Add<&Self> for Integer {\n    type Output = Self;\n\n    /// Adds two [`Integer`]s, taking the first by reference and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO + &Integer::from(123), 123);\n    /// assert_eq!(Integer::from(-123) + &Integer::ZERO, -123);\n    /// assert_eq!(Integer::from(-123) + &Integer::from(456), 333);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) + &(Integer::from(10u32).pow(12) << 1),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add(mut self, other: &Self) -> Self {\n        self += other;\n        self\n    }\n}\n\nimpl Add<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Adds two [`Integer`]s, taking the first by value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::ZERO + Integer::from(123), 123);\n    /// assert_eq!(&Integer::from(-123) + Integer::ZERO, -123);\n    /// assert_eq!(&Integer::from(-123) + Integer::from(456), 333);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) + (Integer::from(10u32).pow(12) << 1),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add(self, mut other: Integer) -> Integer {\n        other += self;\n        other\n    }\n}\n\nimpl Add<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Adds two [`Integer`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::ZERO + &Integer::from(123), 123);\n    /// assert_eq!(&Integer::from(-123) + &Integer::ZERO, -123);\n    /// assert_eq!(&Integer::from(-123) + &Integer::from(456), 333);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) + &(Integer::from(10u32).pow(12) << 1),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    fn add(self, other: &Integer) -> Integer {\n        match (self, other) {\n            (x, y) if core::ptr::eq(x, y) => x << 1,\n            (&integer_zero!(), y) => y.clone(),\n            (x, &integer_zero!()) => x.clone(),\n            // e.g. 10 + 5 or -10 + -5; sign of result is sign of self\n            (\n                &Integer {\n                    sign: sx,\n                    abs: ref ax,\n                },\n                &Integer {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) if sx == (sy && *ay != 0) => Integer {\n                sign: sx,\n                abs: ax + ay,\n            },\n            // e.g. 10 + -5, -10 + 5, or 5 + -5; sign of result is sign of self\n            (\n                &Integer {\n                    sign: sx,\n                    abs: ref ax,\n                },\n                Integer { abs: ay, .. },\n            ) if sx && *ax == *ay || *ax > *ay => Integer {\n                sign: sx,\n                abs: ax - ay,\n            },\n            // e.g. 5 + -10, -5 + 10, or -5 + 5; sign of result is sign of other\n            (\n                Integer { abs: ax, .. },\n                &Integer {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) => Integer {\n                sign: sy,\n                abs: ay - ax,\n            },\n        }\n    }\n}\n\nimpl AddAssign<Self> for Integer {\n    /// Adds an [`Integer`] to an [`Integer`] in place, taking the [`Integer`] on the right-hand\n    /// side by value.\n    ///\n    /// $$\n    /// x \\gets x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x += -Integer::from(10u32).pow(12);\n    /// x += Integer::from(10u32).pow(12) * Integer::from(2u32);\n    /// x += -Integer::from(10u32).pow(12) * Integer::from(3u32);\n    /// x += Integer::from(10u32).pow(12) * Integer::from(4u32);\n    /// assert_eq!(x, 2000000000000u64);\n    /// ```\n    fn add_assign(&mut self, mut other: Self) {\n        match (&mut *self, &other) {\n            (_, &integer_zero!()) => {}\n            (&mut integer_zero!(), _) => {\n                *self = other;\n            }\n            // e.g. 10 += 5 or -10 += -5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                &Self {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) if sx == (sy && *ay != 0) => *ax += ay,\n            // e.g. 10 += -5, -10 += 5, or 5 += -5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                Self { abs: ay, .. },\n            ) if sx && *ax == *ay || *ax > *ay => *ax -= ay,\n            // e.g. 5 += -10, -5 += 10, or -5 += 5; sign of self is flipped\n            _ => {\n                swap(self, &mut other);\n                self.abs -= other.abs;\n            }\n        };\n    }\n}\n\nimpl AddAssign<&Self> for Integer {\n    /// Adds an [`Integer`] to an [`Integer`] in place, taking the [`Integer`] on the right-hand\n    /// side by reference.\n    ///\n    /// $$\n    /// x \\gets x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x += &(-Integer::from(10u32).pow(12));\n    /// x += &(Integer::from(10u32).pow(12) * Integer::from(2u32));\n    /// x += &(-Integer::from(10u32).pow(12) * Integer::from(3u32));\n    /// x += &(Integer::from(10u32).pow(12) * Integer::from(4u32));\n    /// assert_eq!(x, 2000000000000u64);\n    /// ```\n    fn add_assign(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (_, &integer_zero!()) => {}\n            (&mut integer_zero!(), _) => {\n                *self = other.clone();\n            }\n            // e.g. 10 += 5 or -10 += -5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                &Self {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) if sx == (sy && *ay != 0) => *ax += ay,\n            // e.g. 10 += -5, -10 += 5, or 5 += -5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                Self { abs: ay, .. },\n            ) if sx && *ax == *ay || *ax > *ay => *ax -= ay,\n            // e.g. 5 += -10, -5 += 10, or -5 += 5; sign of self is flipped\n            (\n                &mut Self {\n                    sign: ref mut sx,\n                    abs: ref mut ax,\n                },\n                &Self {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) => {\n                *sx = sy;\n                ax.sub_right_assign_no_panic(ay);\n            }\n        };\n    }\n}\n\nimpl Sum for Integer {\n    /// Adds up all the [`Integer`]s in an iterator.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\sum_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Integer::sum(xs.map(Integer::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Sum;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::sum(\n    ///         vec_from_str::<Integer>(\"[2, -3, 5, 7]\")\n    ///             .unwrap()\n    ///             .into_iter()\n    ///     ),\n    ///     11\n    /// );\n    /// ```\n    fn sum<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = Self>,\n    {\n        let mut s = Self::ZERO;\n        for x in xs {\n            s += x;\n        }\n        s\n    }\n}\n\nimpl<'a> Sum<&'a Self> for Integer {\n    /// Adds up all the [`Integer`]s in an iterator of [`Integer`] references.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\sum_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Integer::sum(xs.map(Integer::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Sum;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::sum(vec_from_str::<Integer>(\"[2, -3, 5, 7]\").unwrap().iter()),\n    ///     11\n    /// );\n    /// ```\n    fn sum<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = &'a Self>,\n    {\n        let mut s = Self::ZERO;\n        for x in xs {\n            s += x;\n        }\n        s\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::arithmetic::sub_mul::{\n    limbs_overflowing_sub_mul, limbs_overflowing_sub_mul_in_place_left,\n    limbs_overflowing_sub_mul_limb, limbs_overflowing_sub_mul_limb_in_place_either,\n    limbs_overflowing_sub_mul_limb_in_place_left,\n};\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{AddMul, AddMulAssign};\nuse malachite_base::num::basic::traits::Zero;\n\nimpl Natural {\n    // self - b * c, returns sign (true means non-negative)\n    fn add_mul_limb_neg(&self, b: &Self, c: Limb) -> (Self, bool) {\n        match (self, b, c) {\n            (x, &Self::ZERO, _) | (x, _, 0) => (x.clone(), true),\n            (x, y, 1) if x >= y => (x - y, true),\n            (x, y, 1) => (y - x, false),\n            (Self(Large(xs)), Self(Large(ys)), z) => {\n                let (out_limbs, sign) = limbs_overflowing_sub_mul_limb(xs, ys, z);\n                (Self::from_owned_limbs_asc(out_limbs), sign)\n            }\n            (x, y, z) => {\n                let yz = y * Self::from(z);\n                if *x >= yz {\n                    (x - yz, true)\n                } else {\n                    (yz - x, false)\n                }\n            }\n        }\n    }\n\n    // self -= b * c, returns sign (true means non-negative)\n    fn add_mul_assign_limb_neg(&mut self, mut b: Self, c: Limb) -> bool {\n        match (&mut *self, &mut b, c) {\n            (_, &mut Self::ZERO, _) | (_, _, 0) => true,\n            (x, y, 1) if *x >= *y => {\n                self.sub_assign_no_panic(b);\n                true\n            }\n            (x, y, 1) => {\n                x.sub_right_assign_no_panic(&*y);\n                false\n            }\n            (Self(Large(xs)), Self(Large(ys)), z) => {\n                let (right, sign) = limbs_overflowing_sub_mul_limb_in_place_either(xs, ys, z);\n                if right {\n                    b.trim();\n                    *self = b;\n                } else {\n                    self.trim();\n                }\n                sign\n            }\n            (x, _, z) => {\n                let yz = b * Self(Small(z));\n                let sign = *x >= yz;\n                if sign {\n                    x.sub_assign_no_panic(yz);\n                } else {\n                    x.sub_right_assign_no_panic(&yz);\n                }\n                sign\n            }\n        }\n    }\n\n    // self -= &b * c, returns sign (true means non-negative)\n    fn add_mul_assign_limb_neg_ref(&mut self, b: &Self, c: Limb) -> bool {\n        match (&mut *self, b, c) {\n            (_, &Self::ZERO, _) | (_, _, 0) => true,\n            (x, y, 1) if *x >= *y => {\n                self.sub_assign_ref_no_panic(y);\n                true\n            }\n            (x, y, 1) => {\n                x.sub_right_assign_no_panic(y);\n                false\n            }\n            (Self(Large(xs)), Self(Large(ys)), z) => {\n                let sign = limbs_overflowing_sub_mul_limb_in_place_left(xs, ys, z);\n                self.trim();\n                sign\n            }\n            (x, _, z) => {\n                let yz = b * Self(Small(z));\n                let sign = *x >= yz;\n                if sign {\n                    x.sub_assign_no_panic(yz);\n                } else {\n                    x.sub_right_assign_no_panic(&yz);\n                }\n                sign\n            }\n        }\n    }\n\n    // self - &b * c, returns sign (true means non-negative)\n    pub(crate) fn add_mul_neg(&self, b: &Self, c: &Self) -> (Self, bool) {\n        match (self, b, c) {\n            (x, &Self(Small(y)), z) => x.add_mul_limb_neg(z, y),\n            (x, y, &Self(Small(z))) => x.add_mul_limb_neg(y, z),\n            (&Self(Small(x)), y, z) => ((y * z).sub_limb(x), false),\n            (Self(Large(xs)), Self(Large(ys)), Self(Large(zs))) => {\n                let (out_limbs, sign) = limbs_overflowing_sub_mul(xs, ys, zs);\n                (Self::from_owned_limbs_asc(out_limbs), sign)\n            }\n        }\n    }\n\n    fn add_mul_assign_neg_large(&mut self, ys: &[Limb], zs: &[Limb]) -> bool {\n        let xs = self.promote_in_place();\n        let sign = limbs_overflowing_sub_mul_in_place_left(xs, ys, zs);\n        self.trim();\n        sign\n    }\n\n    // self -= b * c, returns sign (true means non-negative)\n    fn add_mul_assign_neg(&mut self, b: Self, c: Self) -> bool {\n        match (&mut *self, b, c) {\n            (x, Self(Small(y)), z) => x.add_mul_assign_limb_neg(z, y),\n            (x, y, Self(Small(z))) => x.add_mul_assign_limb_neg(y, z),\n            (&mut Self::ZERO, y, z) => {\n                *self = y * z;\n                false\n            }\n            (_, Self(Large(ys)), Self(Large(zs))) => self.add_mul_assign_neg_large(&ys, &zs),\n        }\n    }\n\n    // self -= b * &c, returns sign (true means non-negative)\n    fn add_mul_assign_neg_val_ref(&mut self, b: Self, c: &Self) -> bool {\n        match (&mut *self, b, c) {\n            (x, Self(Small(y)), z) => x.add_mul_assign_limb_neg_ref(z, y),\n            (x, y, &Self(Small(z))) => x.add_mul_assign_limb_neg(y, z),\n            (&mut Self::ZERO, y, z) => {\n                *self = y * z;\n                false\n            }\n            (_, Self(Large(ys)), Self(Large(zs))) => self.add_mul_assign_neg_large(&ys, zs),\n        }\n    }\n\n    // self -= &b * c, returns sign (true means non-negative)\n    fn add_mul_assign_neg_ref_val(&mut self, b: &Self, c: Self) -> bool {\n        match (&mut *self, b, c) {\n            (x, &Self(Small(y)), z) => x.add_mul_assign_limb_neg(z, y),\n            (x, y, Self(Small(z))) => x.add_mul_assign_limb_neg_ref(y, z),\n            (&mut Self::ZERO, y, z) => {\n                *self = y * z;\n                false\n            }\n            (_, Self(Large(ys)), Self(Large(zs))) => self.add_mul_assign_neg_large(ys, &zs),\n        }\n    }\n\n    // self -= &b * &c, returns sign (true means non-negative)\n    fn add_mul_assign_neg_ref_ref(&mut self, b: &Self, c: &Self) -> bool {\n        match (&mut *self, b, c) {\n            (x, &Self(Small(y)), z) => x.add_mul_assign_limb_neg_ref(z, y),\n            (x, y, &Self(Small(z))) => x.add_mul_assign_limb_neg_ref(y, z),\n            (&mut Self::ZERO, y, z) => {\n                *self = y * z;\n                false\n            }\n            (_, Self(Large(ys)), Self(Large(zs))) => self.add_mul_assign_neg_large(ys, zs),\n        }\n    }\n}\n\nimpl AddMul<Self, Self> for Integer {\n    type Output = Self;\n\n    /// Adds an [`Integer`] and the product of two other [`Integer`]s, taking all three by value.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).add_mul(Integer::from(3u32), Integer::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .add_mul(Integer::from(0x10000), -Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: Self, z: Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a> AddMul<Self, &'a Self> for Integer {\n    type Output = Self;\n\n    /// Adds an [`Integer`] and the product of two other [`Integer`]s, taking the first two by value\n    /// and the third by reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).add_mul(Integer::from(3u32), &Integer::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .add_mul(Integer::from(0x10000), &-Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: Self, z: &'a Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a> AddMul<&'a Self, Self> for Integer {\n    type Output = Self;\n\n    /// Adds an [`Integer`] and the product of two other [`Integer`]s, taking the first and third by\n    /// value and the second by reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).add_mul(&Integer::from(3u32), Integer::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .add_mul(&Integer::from(0x10000), -Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: &'a Self, z: Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a, 'b> AddMul<&'a Self, &'b Self> for Integer {\n    type Output = Self;\n\n    /// Adds an [`Integer`] and the product of two other [`Integer`]s, taking the first by value and\n    /// the second and third by reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).add_mul(&Integer::from(3u32), &Integer::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .add_mul(&Integer::from(0x10000), &-Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: &'a Self, z: &'b Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl AddMul<&Integer, &Integer> for &Integer {\n    type Output = Integer;\n\n    /// Adds an [`Integer`] and the product of two other [`Integer`]s, taking all three by\n    /// reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n, m) = O(m + n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(10u32)).add_mul(&Integer::from(3u32), &Integer::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12))\n    ///         .add_mul(&Integer::from(0x10000), &-Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    fn add_mul(self, y: &Integer, z: &Integer) -> Integer {\n        if self.sign == (y.sign == z.sign) {\n            Integer {\n                sign: self.sign,\n                abs: (&self.abs).add_mul(&y.abs, &z.abs),\n            }\n        } else {\n            let (abs, abs_result_sign) = self.abs.add_mul_neg(&y.abs, &z.abs);\n            Integer {\n                sign: (self.sign == abs_result_sign) || abs == 0,\n                abs,\n            }\n        }\n    }\n}\n\nimpl AddMulAssign<Self, Self> for Integer {\n    /// Adds the product of two other [`Integer`]s to an [`Integer`] in place, taking both\n    /// [`Integer`]s on the right-hand side by value.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.add_mul_assign(Integer::from(3u32), Integer::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.add_mul_assign(Integer::from(0x10000), -Integer::from(10u32).pow(12));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn add_mul_assign(&mut self, y: Self, z: Self) {\n        if self.sign == (y.sign == z.sign) {\n            self.abs.add_mul_assign(y.abs, z.abs);\n        } else {\n            let sign = self.abs.add_mul_assign_neg(y.abs, z.abs);\n            self.sign = (self.sign == sign) || self.abs == 0;\n        }\n    }\n}\n\nimpl<'a> AddMulAssign<Self, &'a Self> for Integer {\n    /// Adds the product of two other [`Integer`]s to an [`Integer`] in place, taking the first\n    /// [`Integer`] on the right-hand side by value and the second by reference.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.add_mul_assign(Integer::from(3u32), &Integer::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.add_mul_assign(Integer::from(0x10000), &-Integer::from(10u32).pow(12));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn add_mul_assign(&mut self, y: Self, z: &'a Self) {\n        if self.sign == (y.sign == z.sign) {\n            self.abs.add_mul_assign(y.abs, &z.abs);\n        } else {\n            let sign = self.abs.add_mul_assign_neg_val_ref(y.abs, &z.abs);\n            self.sign = (self.sign == sign) || self.abs == 0;\n        }\n    }\n}\n\nimpl<'a> AddMulAssign<&'a Self, Self> for Integer {\n    /// Adds the product of two other [`Integer`]s to an [`Integer`] in place, taking the first\n    /// [`Integer`] on the right-hand side by reference and the second by value.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.add_mul_assign(&Integer::from(3u32), Integer::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.add_mul_assign(&Integer::from(0x10000), -Integer::from(10u32).pow(12));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn add_mul_assign(&mut self, y: &'a Self, z: Self) {\n        if self.sign == (y.sign == z.sign) {\n            self.abs.add_mul_assign(&y.abs, z.abs);\n        } else {\n            let sign = self.abs.add_mul_assign_neg_ref_val(&y.abs, z.abs);\n            self.sign = (self.sign == sign) || self.abs == 0;\n        }\n    }\n}\n\nimpl<'a, 'b> AddMulAssign<&'a Self, &'b Self> for Integer {\n    /// Adds the product of two other [`Integer`]s to an [`Integer`] in place, taking both\n    /// [`Integer`]s on the right-hand side by reference.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.add_mul_assign(&Integer::from(3u32), &Integer::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.add_mul_assign(&Integer::from(0x10000), &-Integer::from(10u32).pow(12));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn add_mul_assign(&mut self, y: &'a Self, z: &'b Self) {\n        if self.sign == (y.sign == z.sign) {\n            self.abs.add_mul_assign(&y.abs, &z.abs);\n        } else {\n            let sign = self.abs.add_mul_assign_neg_ref_ref(&y.abs, &z.abs);\n            self.sign = (self.sign == sign) || self.abs == 0;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{BinomialCoefficient, Parity};\nuse malachite_base::num::basic::traits::One;\n\nimpl BinomialCoefficient for Integer {\n    /// Computes the binomial coefficient of two [`Integer`]s, taking both by value.\n    ///\n    /// The second argument must be non-negative, but the first may be negative. If it is, the\n    /// identity $\\binom{-n}{k} = (-1)^k \\binom{n+k-1}{k}$ is used.\n    ///\n    /// $$\n    /// f(n, k) = \\\\begin{cases}\n    ///     \\binom{n}{k} & \\text{if} \\\\quad n \\geq 0, \\\\\\\\\n    ///     (-1)^k \\binom{-n+k-1}{k} & \\text{if} \\\\quad n < 0.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// TODO\n    ///\n    /// # Panics\n    /// Panics if $k$ is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::BinomialCoefficient;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(4), Integer::from(0)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(4), Integer::from(1)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(4), Integer::from(2)),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(4), Integer::from(3)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(4), Integer::from(4)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(10), Integer::from(5)),\n    ///     252\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(100), Integer::from(50)).to_string(),\n    ///     \"100891344545564193334812497256\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(-3), Integer::from(0)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(-3), Integer::from(1)),\n    ///     -3\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(-3), Integer::from(2)),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(Integer::from(-3), Integer::from(3)),\n    ///     -10\n    /// );\n    /// ```\n    fn binomial_coefficient(n: Self, k: Self) -> Self {\n        assert!(k.sign);\n        if n.sign {\n            Self::from(Natural::binomial_coefficient(n.abs, k.abs))\n        } else {\n            let k_abs = k.abs;\n            Self {\n                sign: k_abs.even(),\n                abs: Natural::binomial_coefficient(n.abs + &k_abs - Natural::ONE, k_abs),\n            }\n        }\n    }\n}\n\nimpl<'a> BinomialCoefficient<&'a Self> for Integer {\n    /// Computes the binomial coefficient of two [`Integer`]s, taking both by reference.\n    ///\n    /// The second argument must be non-negative, but the first may be negative. If it is, the\n    /// identity $\\binom{-n}{k} = (-1)^k \\binom{n+k-1}{k}$ is used.\n    ///\n    /// $$\n    /// f(n, k) = \\\\begin{cases}\n    ///     \\binom{n}{k} & \\text{if} \\\\quad n \\geq 0, \\\\\\\\\n    ///     (-1)^k \\binom{-n+k-1}{k} & \\text{if} \\\\quad n < 0.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// TODO\n    ///\n    /// # Panics\n    /// Panics if $k$ is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::BinomialCoefficient;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(4), &Integer::from(0)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(4), &Integer::from(1)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(4), &Integer::from(2)),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(4), &Integer::from(3)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(4), &Integer::from(4)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(10), &Integer::from(5)),\n    ///     252\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(100), &Integer::from(50)).to_string(),\n    ///     \"100891344545564193334812497256\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(-3), &Integer::from(0)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(-3), &Integer::from(1)),\n    ///     -3\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(-3), &Integer::from(2)),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Integer::binomial_coefficient(&Integer::from(-3), &Integer::from(3)),\n    ///     -10\n    /// );\n    /// ```\n    fn binomial_coefficient(n: &'a Self, k: &'a Self) -> Self {\n        assert!(k.sign);\n        if n.sign {\n            Self::from(Natural::binomial_coefficient(&n.abs, &k.abs))\n        } else {\n            let k_abs = &k.abs;\n            Self {\n                sign: k_abs.even(),\n                abs: Natural::binomial_coefficient(&(&n.abs + k_abs - Natural::ONE), k_abs),\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::ops::{Div, DivAssign};\nuse malachite_base::num::arithmetic::traits::CheckedDiv;\nuse malachite_base::num::basic::traits::Zero;\n\nimpl Div<Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value. The quotient is rounded\n    /// towards zero. The quotient and remainder (which is not computed) satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23) / Integer::from(10), 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(Integer::from(23) / Integer::from(-10), -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(Integer::from(-23) / Integer::from(10), -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23) / Integer::from(-10), 2);\n    /// ```\n    #[inline]\n    fn div(mut self, other: Self) -> Self {\n        self /= other;\n        self\n    }\n}\n\nimpl Div<&Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference. The quotient is rounded towards zero. The quotient and remainder (which is not\n    /// computed) satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23) / &Integer::from(10), 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(Integer::from(23) / &Integer::from(-10), -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(Integer::from(-23) / &Integer::from(10), -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23) / &Integer::from(-10), 2);\n    /// ```\n    #[inline]\n    fn div(mut self, other: &Self) -> Self {\n        self /= other;\n        self\n    }\n}\n\nimpl Div<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value. The quotient is rounded towards zero. The quotient and remainder (which is not\n    /// computed) satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Integer::from(23) / Integer::from(10), 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(&Integer::from(23) / Integer::from(-10), -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(&Integer::from(-23) / Integer::from(10), -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(&Integer::from(-23) / Integer::from(-10), 2);\n    /// ```\n    #[inline]\n    fn div(self, other: Integer) -> Integer {\n        Integer::from_sign_and_abs(self.sign == other.sign, &self.abs / other.abs)\n    }\n}\n\nimpl Div<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference. The quotient is\n    /// rounded towards zero. The quotient and remainder (which is not computed) satisfy $x = qy +\n    /// r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Integer::from(23) / &Integer::from(10), 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(&Integer::from(23) / &Integer::from(-10), -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(&Integer::from(-23) / &Integer::from(10), -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(&Integer::from(-23) / &Integer::from(-10), 2);\n    /// ```\n    #[inline]\n    fn div(self, other: &Integer) -> Integer {\n        Integer::from_sign_and_abs(self.sign == other.sign, &self.abs / &other.abs)\n    }\n}\n\nimpl DivAssign<Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value. The quotient is rounded towards zero. The quotient and remainder\n    /// (which is not computed) satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x /= Integer::from(10);\n    /// assert_eq!(x, 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x /= Integer::from(-10);\n    /// assert_eq!(x, -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x /= Integer::from(10);\n    /// assert_eq!(x, -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x /= Integer::from(-10);\n    /// assert_eq!(x, 2);\n    /// ```\n    #[inline]\n    fn div_assign(&mut self, other: Self) {\n        self.abs /= other.abs;\n        self.sign = self.sign == other.sign || self.abs == 0;\n    }\n}\n\nimpl DivAssign<&Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference. The quotient is rounded towards zero. The quotient and\n    /// remainder (which is not computed) satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x /= &Integer::from(10);\n    /// assert_eq!(x, 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x /= &Integer::from(-10);\n    /// assert_eq!(x, -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x /= &Integer::from(10);\n    /// assert_eq!(x, -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x /= &Integer::from(-10);\n    /// assert_eq!(x, 2);\n    /// ```\n    #[inline]\n    fn div_assign(&mut self, other: &Self) {\n        self.abs /= &other.abs;\n        self.sign = self.sign == other.sign || self.abs == 0;\n    }\n}\n\nimpl CheckedDiv<Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value. The quotient is rounded\n    /// towards negative infinity. The quotient and remainder (which is not computed) satisfy $x =\n    /// qy + r$ and $0 \\leq r < y$. Returns `None` when the second [`Integer`] is zero, `Some`\n    /// otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    ///         \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .checked_div(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"Some(-2)\"\n    /// );\n    /// assert_eq!(Integer::ONE.checked_div(Integer::ZERO), None);\n    /// ```\n    #[inline]\n    fn checked_div(self, other: Self) -> Option<Self> {\n        match (self, other) {\n            (_, integer_zero!()) => None,\n            (x, y) => Some(x / y),\n        }\n    }\n}\n\nimpl CheckedDiv<&Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference. The quotient is rounded towards negative infinity. The quotient and remainder\n    /// (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$. Returns `None` when the\n    /// second [`Integer`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    ///         \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .checked_div(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"Some(-2)\"\n    /// );\n    /// assert_eq!(Integer::ONE.checked_div(&Integer::ZERO), None);\n    /// ```\n    #[inline]\n    fn checked_div(self, other: &Self) -> Option<Self> {\n        match (self, other) {\n            (_, &integer_zero!()) => None,\n            (x, y) => Some(x / y),\n        }\n    }\n}\n\nimpl CheckedDiv<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value. The quotient is rounded towards negative infinity. The quotient and remainder\n    /// (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$. Returns `None` when the\n    /// second [`Integer`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    ///         \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .checked_div(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"Some(-2)\"\n    /// );\n    /// assert_eq!((&Integer::ONE).checked_div(Integer::ZERO), None);\n    /// ```\n    fn checked_div(self, other: Integer) -> Option<Integer> {\n        match (self, other) {\n            (_, integer_zero!()) => None,\n            (x, y) => Some(x / y),\n        }\n    }\n}\n\nimpl CheckedDiv<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference. The quotient is\n    /// rounded towards negative infinity. The quotient and remainder (which is not computed)\n    /// satisfy $x = qy + r$ and $0 \\leq r < y$. Returns `None` when the second [`Integer`] is zero,\n    /// `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    /// \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .checked_div(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"Some(-2)\"\n    /// );\n    /// assert_eq!((&Integer::ONE).checked_div(&Integer::ZERO), None);\n    /// ```\n    fn checked_div(self, other: &Integer) -> Option<Integer> {\n        match (self, other) {\n            (_, &integer_zero!()) => None,\n            (x, y) => Some(x / y),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::{DivExact, DivExactAssign};\n\nimpl DivExact<Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value. The first [`Integer`]\n    /// must be exactly divisible by the second. If it isn't, this function may panic or return a\n    /// meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self / other` instead. If you're\n    /// unsure and you want to know, use `self.div_mod(other)` and check whether the remainder is\n    /// zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round(other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -123 * 456 = -56088\n    /// assert_eq!(Integer::from(-56088).div_exact(Integer::from(456)), -123);\n    ///\n    /// // -123456789000 * -987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     Integer::from_str(\"121932631112635269000000\")\n    ///         .unwrap()\n    ///         .div_exact(Integer::from_str(\"-987654321000\").unwrap()),\n    ///     -123456789000i64\n    /// );\n    /// ```\n    #[inline]\n    fn div_exact(mut self, other: Self) -> Self {\n        self.div_exact_assign(other);\n        self\n    }\n}\n\nimpl DivExact<&Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference. The first [`Integer`] must be exactly divisible by the second. If it isn't, this\n    /// function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self / &other` instead. If you're\n    /// unsure and you want to know, use `self.div_mod(&other)` and check whether the remainder is\n    /// zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round(&other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -123 * 456 = -56088\n    /// assert_eq!(Integer::from(-56088).div_exact(&Integer::from(456)), -123);\n    ///\n    /// // -123456789000 * -987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     Integer::from_str(\"121932631112635269000000\")\n    ///         .unwrap()\n    ///         .div_exact(&Integer::from_str(\"-987654321000\").unwrap()),\n    ///     -123456789000i64\n    /// );\n    /// ```\n    #[inline]\n    fn div_exact(mut self, other: &Self) -> Self {\n        self.div_exact_assign(other);\n        self\n    }\n}\n\nimpl DivExact<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value. The first [`Integer`] must be exactly divisible by the second. If it isn't, this\n    /// function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `&self / other` instead. If you're\n    /// unsure and you want to know, use `self.div_mod(other)` and check whether the remainder is\n    /// zero. If you want a function that panics if the division is not exact, use\n    /// `(&self).div_round(other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -123 * 456 = -56088\n    /// assert_eq!((&Integer::from(-56088)).div_exact(Integer::from(456)), -123);\n    ///\n    /// // -123456789000 * -987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"121932631112635269000000\").unwrap())\n    ///         .div_exact(Integer::from_str(\"-987654321000\").unwrap()),\n    ///     -123456789000i64\n    /// );\n    /// ```\n    fn div_exact(self, other: Integer) -> Integer {\n        let q_abs = (&self.abs).div_exact(other.abs);\n        Integer {\n            sign: self.sign == other.sign || q_abs == 0,\n            abs: q_abs,\n        }\n    }\n}\n\nimpl DivExact<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference. The first\n    /// [`Integer`] must be exactly divisible by the second. If it isn't, this function may panic or\n    /// return a meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `&self / &other` instead. If\n    /// you're unsure and you want to know, use `(&self).div_mod(&other)` and check whether the\n    /// remainder is zero. If you want a function that panics if the division is not exact, use\n    /// `(&self).div_round(&other, Exact)`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -123 * 456 = -56088\n    /// assert_eq!(\n    ///     (&Integer::from(-56088)).div_exact(&Integer::from(456)),\n    ///     -123\n    /// );\n    ///\n    /// // -123456789000 * -987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"121932631112635269000000\").unwrap())\n    ///         .div_exact(&Integer::from_str(\"-987654321000\").unwrap()),\n    ///     -123456789000i64\n    /// );\n    /// ```\n    fn div_exact(self, other: &Integer) -> Integer {\n        let q_abs = (&self.abs).div_exact(&other.abs);\n        Integer {\n            sign: self.sign == other.sign || q_abs == 0,\n            abs: q_abs,\n        }\n    }\n}\n\nimpl DivExactAssign<Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value. The first [`Integer`] must be exactly divisible by the second. If\n    /// it isn't, this function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// x \\gets \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self /= other` instead. If you're\n    /// unsure and you want to know, use `self.div_assign_mod(other)` and check whether the\n    /// remainder is zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round_assign(other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExactAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -123 * 456 = -56088\n    /// let mut x = Integer::from(-56088);\n    /// x.div_exact_assign(Integer::from(456));\n    /// assert_eq!(x, -123);\n    ///\n    /// // -123456789000 * -987654321000 = 121932631112635269000000\n    /// let mut x = Integer::from_str(\"121932631112635269000000\").unwrap();\n    /// x.div_exact_assign(Integer::from_str(\"-987654321000\").unwrap());\n    /// assert_eq!(x, -123456789000i64);\n    /// ```\n    fn div_exact_assign(&mut self, other: Self) {\n        self.abs.div_exact_assign(other.abs);\n        self.sign = self.sign == other.sign || self.abs == 0;\n    }\n}\n\nimpl DivExactAssign<&Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference. The first [`Integer`] must be exactly divisible by the second.\n    /// If it isn't, this function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// x \\gets \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self /= &other` instead. If\n    /// you're unsure and you want to know, use `self.div_assign_mod(&other)` and check whether the\n    /// remainder is zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round_assign(&other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExactAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // -123 * 456 = -56088\n    /// let mut x = Integer::from(-56088);\n    /// x.div_exact_assign(&Integer::from(456));\n    /// assert_eq!(x, -123);\n    ///\n    /// // -123456789000 * -987654321000 = 121932631112635269000000\n    /// let mut x = Integer::from_str(\"121932631112635269000000\").unwrap();\n    /// x.div_exact_assign(&Integer::from_str(\"-987654321000\").unwrap());\n    /// assert_eq!(x, -123456789000i64);\n    /// ```\n    fn div_exact_assign(&mut self, other: &Self) {\n        self.abs.div_exact_assign(&other.abs);\n        self.sign = self.sign == other.sign || self.abs == 0;\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivAssignMod, CeilingDivAssignNegMod, CeilingDivMod, CeilingDivNegMod, DivAssignMod,\n    DivAssignRem, DivMod, DivRem,\n};\n\nimpl DivMod<Self> for Integer {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value and returning the\n    /// quotient and remainder. The quotient is rounded towards negative infinity, and the remainder\n    /// has the same sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-3, -7)\"\n    /// );\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-3, 7)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_mod(mut self, other: Self) -> (Self, Self) {\n        let r = self.div_assign_mod(other);\n        (self, r)\n    }\n}\n\nimpl DivMod<&Self> for Integer {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference and returning the quotient and remainder. The quotient is rounded towards negative\n    /// infinity, and the remainder has the same sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-3, -7)\"\n    /// );\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-3, 7)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_mod(mut self, other: &Self) -> (Self, Self) {\n        let r = self.div_assign_mod(other);\n        (self, r)\n    }\n}\n\nimpl DivMod<Integer> for &Integer {\n    type DivOutput = Integer;\n    type ModOutput = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value and returning the quotient and remainder. The quotient is rounded towards negative\n    /// infinity, and the remainder has the same sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-3, -7)\"\n    /// );\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-3, 7)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    fn div_mod(self, other: Integer) -> (Integer, Integer) {\n        let q_sign = self.sign == other.sign;\n        let (q, r) = if q_sign {\n            (&self.abs).div_mod(other.abs)\n        } else {\n            (&self.abs).ceiling_div_neg_mod(other.abs)\n        };\n        (\n            Integer::from_sign_and_abs(q_sign, q),\n            Integer::from_sign_and_abs(other.sign, r),\n        )\n    }\n}\n\nimpl DivMod<&Integer> for &Integer {\n    type DivOutput = Integer;\n    type ModOutput = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference and returning the\n    /// quotient and remainder. The quotient is rounded towards negative infinity, and the remainder\n    /// has the same sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-3, -7)\"\n    /// );\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-3, 7)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    fn div_mod(self, other: &Integer) -> (Integer, Integer) {\n        let q_sign = self.sign == other.sign;\n        let (q, r) = if q_sign {\n            (&self.abs).div_mod(&other.abs)\n        } else {\n            (&self.abs).ceiling_div_neg_mod(&other.abs)\n        };\n        (\n            Integer::from_sign_and_abs(q_sign, q),\n            Integer::from_sign_and_abs(other.sign, r),\n        )\n    }\n}\n\nimpl DivAssignMod<Self> for Integer {\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value and returning the remainder. The quotient is rounded towards\n    /// negative infinity, and the remainder has the same sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivAssignMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_mod(Integer::from(10)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_mod(Integer::from(-10)), -7);\n    /// assert_eq!(x, -3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_mod(Integer::from(10)), 7);\n    /// assert_eq!(x, -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_mod(Integer::from(-10)), -3);\n    /// assert_eq!(x, 2);\n    /// ```\n    fn div_assign_mod(&mut self, other: Self) -> Self {\n        let r = if self.sign == other.sign {\n            self.sign = true;\n            self.abs.div_assign_mod(other.abs)\n        } else {\n            let r = self.abs.ceiling_div_assign_neg_mod(other.abs);\n            if self.abs != 0 {\n                self.sign = false;\n            }\n            r\n        };\n        Self::from_sign_and_abs(other.sign, r)\n    }\n}\n\nimpl DivAssignMod<&Self> for Integer {\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference and returning the remainder. The quotient is rounded towards\n    /// negative infinity, and the remainder has the same sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivAssignMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_mod(&Integer::from(10)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_mod(&Integer::from(-10)), -7);\n    /// assert_eq!(x, -3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_mod(&Integer::from(10)), 7);\n    /// assert_eq!(x, -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_mod(&Integer::from(-10)), -3);\n    /// assert_eq!(x, 2);\n    /// ```\n    fn div_assign_mod(&mut self, other: &Self) -> Self {\n        let r = if self.sign == other.sign {\n            self.sign = true;\n            self.abs.div_assign_mod(&other.abs)\n        } else {\n            let r = self.abs.ceiling_div_assign_neg_mod(&other.abs);\n            if self.abs != 0 {\n                self.sign = false;\n            }\n            r\n        };\n        Self::from_sign_and_abs(other.sign, r)\n    }\n}\n\nimpl DivRem<Self> for Integer {\n    type DivOutput = Self;\n    type RemOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value and returning the\n    /// quotient and remainder. The quotient is rounded towards zero and the remainder has the same\n    /// sign as the first [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n    /// \\right \\rfloor, \\space\n    /// x - y \\operatorname{sgn}(xy)\n    /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_rem(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_rem(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_rem(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_rem(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(mut self, other: Self) -> (Self, Self) {\n        let r = self.div_assign_rem(other);\n        (self, r)\n    }\n}\n\nimpl DivRem<&Self> for Integer {\n    type DivOutput = Self;\n    type RemOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference and returning the quotient and remainder. The quotient is rounded towards zero and\n    /// the remainder has the same sign as the first [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n    /// \\right \\rfloor, \\space\n    /// x - y \\operatorname{sgn}(xy)\n    /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_rem(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .div_rem(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_rem(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .div_rem(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(mut self, other: &Self) -> (Self, Self) {\n        let r = self.div_assign_rem(other);\n        (self, r)\n    }\n}\n\nimpl DivRem<Integer> for &Integer {\n    type DivOutput = Integer;\n    type RemOutput = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value and returning the quotient and remainder. The quotient is rounded towards zero and\n    /// the remainder has the same sign as the first [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n    /// \\right \\rfloor, \\space\n    /// x - y \\operatorname{sgn}(xy)\n    /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_rem(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_rem(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_rem(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_rem(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(self, other: Integer) -> (Integer, Integer) {\n        let (q, r) = (&self.abs).div_mod(other.abs);\n        (\n            Integer::from_sign_and_abs(self.sign == other.sign, q),\n            Integer::from_sign_and_abs(self.sign, r),\n        )\n    }\n}\n\nimpl DivRem<&Integer> for &Integer {\n    type DivOutput = Integer;\n    type RemOutput = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference and returning the\n    /// quotient and remainder. The quotient is rounded towards zero and the remainder has the same\n    /// sign as the first [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n    /// \\right \\rfloor, \\space\n    /// x - y \\operatorname{sgn}(xy)\n    /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_rem(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .div_rem(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_rem(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .div_rem(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(2, -3)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(self, other: &Integer) -> (Integer, Integer) {\n        let (q, r) = (&self.abs).div_mod(&other.abs);\n        (\n            Integer::from_sign_and_abs(self.sign == other.sign, q),\n            Integer::from_sign_and_abs(self.sign, r),\n        )\n    }\n}\n\nimpl DivAssignRem<Self> for Integer {\n    type RemOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value and returning the remainder. The quotient is rounded towards zero\n    /// and the remainder has the same sign as the first [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n    /// \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivAssignRem;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_rem(Integer::from(10)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_rem(Integer::from(-10)), 3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_rem(Integer::from(10)), -3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_rem(Integer::from(-10)), -3);\n    /// assert_eq!(x, 2);\n    /// ```\n    #[inline]\n    fn div_assign_rem(&mut self, other: Self) -> Self {\n        let r = Self::from_sign_and_abs(self.sign, self.abs.div_assign_mod(other.abs));\n        self.sign = self.sign == other.sign || self.abs == 0;\n        r\n    }\n}\n\nimpl DivAssignRem<&Self> for Integer {\n    type RemOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference and returning the remainder. The quotient is rounded towards\n    /// zero and the remainder has the same sign as the first [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    /// \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\operatorname{sgn}(xy) \\left \\lfloor \\left | \\frac{x}{y} \\right |\n    /// \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DivAssignRem;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_rem(&Integer::from(10)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.div_assign_rem(&Integer::from(-10)), 3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_rem(&Integer::from(10)), -3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.div_assign_rem(&Integer::from(-10)), -3);\n    /// assert_eq!(x, 2);\n    /// ```\n    #[inline]\n    fn div_assign_rem(&mut self, other: &Self) -> Self {\n        let r = Self::from_sign_and_abs(self.sign, self.abs.div_assign_mod(&other.abs));\n        self.sign = self.sign == other.sign || self.abs == 0;\n        r\n    }\n}\n\nimpl CeilingDivMod<Self> for Integer {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value and returning the\n    /// quotient and remainder. The quotient is rounded towards positive infinity and the remainder\n    /// has the opposite sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// x - y\\left \\lceil \\frac{x}{y} \\right \\rceil \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingDivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 3 * 10 + -7 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .ceiling_div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(3, -7)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .ceiling_div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .ceiling_div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 3 * -10 + 7 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .ceiling_div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    /// ```\n    #[inline]\n    fn ceiling_div_mod(mut self, other: Self) -> (Self, Self) {\n        let r = self.ceiling_div_assign_mod(other);\n        (self, r)\n    }\n}\n\nimpl CeilingDivMod<&Self> for Integer {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both the first by value and the second\n    /// by reference and returning the quotient and remainder. The quotient is rounded towards\n    /// positive infinity and the remainder has the opposite sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// x - y\\left \\lceil \\frac{x}{y} \\right \\rceil \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingDivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 3 * 10 + -7 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .ceiling_div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(3, -7)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     Integer::from(23)\n    ///         .ceiling_div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .ceiling_div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 3 * -10 + 7 = -23\n    /// assert_eq!(\n    ///     Integer::from(-23)\n    ///         .ceiling_div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    /// ```\n    #[inline]\n    fn ceiling_div_mod(mut self, other: &Self) -> (Self, Self) {\n        let r = self.ceiling_div_assign_mod(other);\n        (self, r)\n    }\n}\n\nimpl CeilingDivMod<Integer> for &Integer {\n    type DivOutput = Integer;\n    type ModOutput = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value and returning the quotient and remainder. The quotient is rounded towards positive\n    /// infinity and the remainder has the opposite sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// x - y\\left \\lceil \\frac{x}{y} \\right \\rceil \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingDivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 3 * 10 + -7 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .ceiling_div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(3, -7)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .ceiling_div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .ceiling_div_mod(Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 3 * -10 + 7 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .ceiling_div_mod(Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    /// ```\n    fn ceiling_div_mod(self, other: Integer) -> (Integer, Integer) {\n        let q_sign = self.sign == other.sign;\n        let (q, r) = if q_sign {\n            (&self.abs).ceiling_div_neg_mod(other.abs)\n        } else {\n            (&self.abs).div_mod(other.abs)\n        };\n        (\n            Integer::from_sign_and_abs(q_sign, q),\n            Integer::from_sign_and_abs(!other.sign, r),\n        )\n    }\n}\n\nimpl CeilingDivMod<&Integer> for &Integer {\n    type DivOutput = Integer;\n    type ModOutput = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference and returning the\n    /// quotient and remainder. The quotient is rounded towards positive infinity and the remainder\n    /// has the opposite sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// x - y\\left \\lceil \\frac{x}{y} \\right \\rceil \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingDivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 3 * 10 + -7 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .ceiling_div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(3, -7)\"\n    /// );\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Integer::from(23))\n    ///         .ceiling_div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(-2, 3)\"\n    /// );\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .ceiling_div_mod(&Integer::from(10))\n    ///         .to_debug_string(),\n    ///     \"(-2, -3)\"\n    /// );\n    ///\n    /// // 3 * -10 + 7 = -23\n    /// assert_eq!(\n    ///     (&Integer::from(-23))\n    ///         .ceiling_div_mod(&Integer::from(-10))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    /// ```\n    fn ceiling_div_mod(self, other: &Integer) -> (Integer, Integer) {\n        let q_sign = self.sign == other.sign;\n        let (q, r) = if q_sign {\n            (&self.abs).ceiling_div_neg_mod(&other.abs)\n        } else {\n            (&self.abs).div_mod(&other.abs)\n        };\n        (\n            Integer::from_sign_and_abs(q_sign, q),\n            Integer::from_sign_and_abs(!other.sign, r),\n        )\n    }\n}\n\nimpl CeilingDivAssignMod<Self> for Integer {\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value and returning the remainder. The quotient is rounded towards\n    /// positive infinity and the remainder has the opposite sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lceil\\frac{x}{y} \\right \\rceil,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingDivAssignMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 3 * 10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.ceiling_div_assign_mod(Integer::from(10)), -7);\n    /// assert_eq!(x, 3);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.ceiling_div_assign_mod(Integer::from(-10)), 3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.ceiling_div_assign_mod(Integer::from(10)), -3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // 3 * -10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.ceiling_div_assign_mod(Integer::from(-10)), 7);\n    /// assert_eq!(x, 3);\n    /// ```\n    fn ceiling_div_assign_mod(&mut self, other: Self) -> Self {\n        let r = if self.sign == other.sign {\n            self.sign = true;\n            self.abs.ceiling_div_assign_neg_mod(other.abs)\n        } else {\n            let r = self.abs.div_assign_mod(other.abs);\n            self.sign = self.abs == 0;\n            r\n        };\n        Self::from_sign_and_abs(!other.sign, r)\n    }\n}\n\nimpl CeilingDivAssignMod<&Self> for Integer {\n    type ModOutput = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference and returning the remainder. The quotient is rounded towards\n    /// positive infinity and the remainder has the opposite sign as the second [`Integer`].\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lceil\\frac{x}{y} \\right \\rceil,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingDivAssignMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 3 * 10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.ceiling_div_assign_mod(&Integer::from(10)), -7);\n    /// assert_eq!(x, 3);\n    ///\n    /// // -2 * -10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// assert_eq!(x.ceiling_div_assign_mod(&Integer::from(-10)), 3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // -2 * 10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.ceiling_div_assign_mod(&Integer::from(10)), -3);\n    /// assert_eq!(x, -2);\n    ///\n    /// // 3 * -10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// assert_eq!(x.ceiling_div_assign_mod(&Integer::from(-10)), 7);\n    /// assert_eq!(x, 3);\n    /// ```\n    fn ceiling_div_assign_mod(&mut self, other: &Self) -> Self {\n        let r = if self.sign == other.sign {\n            self.sign = true;\n            self.abs.ceiling_div_assign_neg_mod(&other.abs)\n        } else {\n            let r = self.abs.div_assign_mod(&other.abs);\n            self.sign = self.abs == 0;\n            r\n        };\n        Self::from_sign_and_abs(!other.sign, r)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::{DivRound, DivRoundAssign};\nuse malachite_base::rounding_modes::RoundingMode;\n\nimpl DivRound<Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value and rounding according\n    /// to a specified rounding mode. An [`Ordering`] is also returned, indicating whether the\n    /// returned value is less than, equal to, or greater than the exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(4), Down),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(Integer::from(3), Floor),\n    ///     (Integer::from(-333333333334i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(4), Up),\n    ///     (Integer::from(-3), Less)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(Integer::from(3), Ceiling),\n    ///     (Integer::from(-333333333333i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(5), Exact),\n    ///     (Integer::from(-2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(3), Nearest),\n    ///     (Integer::from(-3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20).div_round(Integer::from(3), Nearest),\n    ///     (Integer::from(-7), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(4), Nearest),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14).div_round(Integer::from(4), Nearest),\n    ///     (Integer::from(-4), Less)\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(-4), Down),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(Integer::from(-3), Floor),\n    ///     (Integer::from(333333333333i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(-4), Up),\n    ///     (Integer::from(3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(Integer::from(-3), Ceiling),\n    ///     (Integer::from(333333333334i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(-5), Exact),\n    ///     (Integer::from(2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(-3), Nearest),\n    ///     (Integer::from(3), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20).div_round(Integer::from(-3), Nearest),\n    ///     (Integer::from(7), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(-4), Nearest),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14).div_round(Integer::from(-4), Nearest),\n    ///     (Integer::from(4), Greater)\n    /// );\n    /// ```\n    #[inline]\n    fn div_round(mut self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.div_round_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl DivRound<&Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference and rounding according to a specified rounding mode. An [`Ordering`] is also\n    /// returned, indicating whether the returned value is less than, equal to, or greater than the\n    /// exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(4), Down),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(&Integer::from(3), Floor),\n    ///     (Integer::from(-333333333334i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(4), Up),\n    ///     (Integer::from(-3), Less)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(&Integer::from(3), Ceiling),\n    ///     (Integer::from(-333333333333i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(5), Exact),\n    ///     (Integer::from(-2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(3), Nearest),\n    ///     (Integer::from(-3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20).div_round(&Integer::from(3), Nearest),\n    ///     (Integer::from(-7), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(4), Nearest),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14).div_round(&Integer::from(4), Nearest),\n    ///     (Integer::from(-4), Less)\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(-4), Down),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(&Integer::from(-3), Floor),\n    ///     (Integer::from(333333333333i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(-4), Up),\n    ///     (Integer::from(3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).div_round(&Integer::from(-3), Ceiling),\n    ///     (Integer::from(333333333334i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(-5), Exact),\n    ///     (Integer::from(2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(-3), Nearest),\n    ///     (Integer::from(3), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20).div_round(&Integer::from(-3), Nearest),\n    ///     (Integer::from(7), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(-4), Nearest),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14).div_round(&Integer::from(-4), Nearest),\n    ///     (Integer::from(4), Greater)\n    /// );\n    /// ```\n    #[inline]\n    fn div_round(mut self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.div_round_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl DivRound<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value and rounding according to a specified rounding mode. An [`Ordering`] is also\n    /// returned, indicating whether the returned value is less than, equal to, or greater than the\n    /// exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(4), Down),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(Integer::from(3), Floor),\n    ///     (Integer::from(-333333333334i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(Integer::from(4), Up),\n    ///     (Integer::from(-3), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(Integer::from(3), Ceiling),\n    ///     (Integer::from(-333333333333i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(5), Exact),\n    ///     (Integer::from(-2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(3), Nearest),\n    ///     (Integer::from(-3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20)).div_round(Integer::from(3), Nearest),\n    ///     (Integer::from(-7), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(4), Nearest),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14)).div_round(Integer::from(4), Nearest),\n    ///     (Integer::from(-4), Less)\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(-4), Down),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(Integer::from(-3), Floor),\n    ///     (Integer::from(333333333333i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(-4), Up),\n    ///     (Integer::from(3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(Integer::from(-3), Ceiling),\n    ///     (Integer::from(333333333334i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(-5), Exact),\n    ///     (Integer::from(2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(-3), Nearest),\n    ///     (Integer::from(3), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20)).div_round(Integer::from(-3), Nearest),\n    ///     (Integer::from(7), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(Integer::from(-4), Nearest),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14)).div_round(Integer::from(-4), Nearest),\n    ///     (Integer::from(4), Greater)\n    /// );\n    /// ```\n    fn div_round(self, other: Integer, rm: RoundingMode) -> (Integer, Ordering) {\n        let q_sign = self.sign == other.sign;\n        let (q_abs, o) = (&self.abs).div_round(other.abs, if q_sign { rm } else { -rm });\n        (\n            Integer::from_sign_and_abs(q_sign, q_abs),\n            if q_sign { o } else { o.reverse() },\n        )\n    }\n}\n\nimpl DivRound<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference and rounding\n    /// according to a specified rounding mode. An [`Ordering`] is also returned, indicating whether\n    /// the returned value is less than, equal to, or greater than the exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n    ///     \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(4), Down),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(&Integer::from(3), Floor),\n    ///     (Integer::from(-333333333334i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10).div_round(&Integer::from(4), Up),\n    ///     (Integer::from(-3), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(&Integer::from(3), Ceiling),\n    ///     (Integer::from(-333333333333i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(5), Exact),\n    ///     (Integer::from(-2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(3), Nearest),\n    ///     (Integer::from(-3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20)).div_round(&Integer::from(3), Nearest),\n    ///     (Integer::from(-7), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(4), Nearest),\n    ///     (Integer::from(-2), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14)).div_round(&Integer::from(4), Nearest),\n    ///     (Integer::from(-4), Less)\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(-4), Down),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(&Integer::from(-3), Floor),\n    ///     (Integer::from(333333333333i64), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(-4), Up),\n    ///     (Integer::from(3), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12)).div_round(&Integer::from(-3), Ceiling),\n    ///     (Integer::from(333333333334i64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(-5), Exact),\n    ///     (Integer::from(2), Equal)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(-3), Nearest),\n    ///     (Integer::from(3), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20)).div_round(&Integer::from(-3), Nearest),\n    ///     (Integer::from(7), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10)).div_round(&Integer::from(-4), Nearest),\n    ///     (Integer::from(2), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14)).div_round(&Integer::from(-4), Nearest),\n    ///     (Integer::from(4), Greater)\n    /// );\n    /// ```\n    fn div_round(self, other: &Integer, rm: RoundingMode) -> (Integer, Ordering) {\n        let q_sign = self.sign == other.sign;\n        let (q_abs, o) = (&self.abs).div_round(&other.abs, if q_sign { rm } else { -rm });\n        (\n            Integer::from_sign_and_abs(q_sign, q_abs),\n            if q_sign { o } else { o.reverse() },\n        )\n    }\n}\n\nimpl DivRoundAssign<Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value and rounding according to a specified rounding mode. An\n    /// [`Ordering`] is returned, indicating whether the assigned value is less than, equal to, or\n    /// greater than the exact value.\n    ///\n    /// See the [`DivRound`] documentation for details.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRoundAssign, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(4), Down), Greater);\n    /// assert_eq!(n, -2);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(Integer::from(3), Floor), Less);\n    /// assert_eq!(n, -333333333334i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(4), Up), Less);\n    /// assert_eq!(n, -3);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(Integer::from(3), Ceiling), Greater);\n    /// assert_eq!(n, -333333333333i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(5), Exact), Equal);\n    /// assert_eq!(n, -2);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(3), Nearest), Greater);\n    /// assert_eq!(n, -3);\n    ///\n    /// let mut n = Integer::from(-20);\n    /// assert_eq!(n.div_round_assign(Integer::from(3), Nearest), Less);\n    /// assert_eq!(n, -7);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(4), Nearest), Greater);\n    /// assert_eq!(n, -2);\n    ///\n    /// let mut n = Integer::from(-14);\n    /// assert_eq!(n.div_round_assign(Integer::from(4), Nearest), Less);\n    /// assert_eq!(n, -4);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(-4), Down), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(Integer::from(-3), Floor), Less);\n    /// assert_eq!(n, 333333333333i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(-4), Up), Greater);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(Integer::from(-3), Ceiling), Greater);\n    /// assert_eq!(n, 333333333334i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(-5), Exact), Equal);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(-3), Nearest), Less);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Integer::from(-20);\n    /// assert_eq!(n.div_round_assign(Integer::from(-3), Nearest), Greater);\n    /// assert_eq!(n, 7);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(Integer::from(-4), Nearest), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Integer::from(-14);\n    /// assert_eq!(n.div_round_assign(Integer::from(-4), Nearest), Greater);\n    /// assert_eq!(n, 4);\n    /// ```\n    fn div_round_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        let q_sign = self.sign == other.sign;\n        let o = self\n            .abs\n            .div_round_assign(other.abs, if q_sign { rm } else { -rm });\n        self.sign = q_sign || self.abs == 0;\n        if q_sign { o } else { o.reverse() }\n    }\n}\n\nimpl DivRoundAssign<&Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference and rounding according to a specified rounding mode. An\n    /// [`Ordering`] is returned, indicating whether the assigned value is less than, equal to, or\n    /// greater than the exact value.\n    ///\n    /// See the [`DivRound`] documentation for details.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRoundAssign, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(4), Down), Greater);\n    /// assert_eq!(n, -2);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(&Integer::from(3), Floor), Less);\n    /// assert_eq!(n, -333333333334i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(4), Up), Less);\n    /// assert_eq!(n, -3);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(&Integer::from(3), Ceiling), Greater);\n    /// assert_eq!(n, -333333333333i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(5), Exact), Equal);\n    /// assert_eq!(n, -2);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(3), Nearest), Greater);\n    /// assert_eq!(n, -3);\n    ///\n    /// let mut n = Integer::from(-20);\n    /// assert_eq!(n.div_round_assign(&Integer::from(3), Nearest), Less);\n    /// assert_eq!(n, -7);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(4), Nearest), Greater);\n    /// assert_eq!(n, -2);\n    ///\n    /// let mut n = Integer::from(-14);\n    /// assert_eq!(n.div_round_assign(&Integer::from(4), Nearest), Less);\n    /// assert_eq!(n, -4);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-4), Down), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-3), Floor), Less);\n    /// assert_eq!(n, 333333333333i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-4), Up), Greater);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = -Integer::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-3), Ceiling), Greater);\n    /// assert_eq!(n, 333333333334i64);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-5), Exact), Equal);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-3), Nearest), Less);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Integer::from(-20);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-3), Nearest), Greater);\n    /// assert_eq!(n, 7);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-4), Nearest), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Integer::from(-14);\n    /// assert_eq!(n.div_round_assign(&Integer::from(-4), Nearest), Greater);\n    /// assert_eq!(n, 4);\n    /// ```\n    fn div_round_assign(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        let q_sign = self.sign == other.sign;\n        let o = self\n            .abs\n            .div_round_assign(&other.abs, if q_sign { rm } else { -rm });\n        self.sign = q_sign || self.abs == 0;\n        if q_sign { o } else { o.reverse() }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\n\nimpl DivisibleBy<Self> for Integer {\n    /// Returns whether an [`Integer`] is divisible by another [`Integer`]; in other words, whether\n    /// the first is a multiple of the second. Both [`Integer`]s are taken by value.\n    ///\n    /// This means that zero is divisible by any [`Integer`], including zero; but a nonzero\n    /// [`Integer`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.divisible_by(Integer::ZERO), true);\n    /// assert_eq!(Integer::from(-100).divisible_by(Integer::from(-3)), false);\n    /// assert_eq!(Integer::from(102).divisible_by(Integer::from(-3)), true);\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .divisible_by(Integer::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(self, other: Self) -> bool {\n        self.abs.divisible_by(other.abs)\n    }\n}\n\nimpl DivisibleBy<&Self> for Integer {\n    /// Returns whether an [`Integer`] is divisible by another [`Integer`]; in other words, whether\n    /// the first is a multiple of the second. The first [`Integer`] is taken by value and the\n    /// second by reference.\n    ///\n    /// This means that zero is divisible by any [`Integer`], including zero; but a nonzero\n    /// [`Integer`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.divisible_by(&Integer::ZERO), true);\n    /// assert_eq!(Integer::from(-100).divisible_by(&Integer::from(-3)), false);\n    /// assert_eq!(Integer::from(102).divisible_by(&Integer::from(-3)), true);\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .divisible_by(&Integer::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(self, other: &Self) -> bool {\n        self.abs.divisible_by(&other.abs)\n    }\n}\n\nimpl DivisibleBy<Integer> for &Integer {\n    /// Returns whether an [`Integer`] is divisible by another [`Integer`]; in other words, whether\n    /// the first is a multiple of the second. The first [`Integer`] is taken by reference and the\n    /// second by value.\n    ///\n    /// This means that zero is divisible by any [`Integer`], including zero; but a nonzero\n    /// [`Integer`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::ZERO).divisible_by(Integer::ZERO), true);\n    /// assert_eq!(\n    ///     (&Integer::from(-100)).divisible_by(Integer::from(-3)),\n    ///     false\n    /// );\n    /// assert_eq!((&Integer::from(102)).divisible_by(Integer::from(-3)), true);\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"-1000000000000000000000000\").unwrap())\n    ///         .divisible_by(Integer::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(self, other: Integer) -> bool {\n        (&self.abs).divisible_by(other.abs)\n    }\n}\n\nimpl DivisibleBy<&Integer> for &Integer {\n    /// Returns whether an [`Integer`] is divisible by another [`Integer`]; in other words, whether\n    /// the first is a multiple of the second. Both [`Integer`]s are taken by reference.\n    ///\n    /// This means that zero is divisible by any [`Integer`], including zero; but a nonzero\n    /// [`Integer`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::ZERO).divisible_by(&Integer::ZERO), true);\n    /// assert_eq!(\n    ///     (&Integer::from(-100)).divisible_by(&Integer::from(-3)),\n    ///     false\n    /// );\n    /// assert_eq!((&Integer::from(102)).divisible_by(&Integer::from(-3)), true);\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"-1000000000000000000000000\").unwrap())\n    ///         .divisible_by(&Integer::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(self, other: &Integer) -> bool {\n        (&self.abs).divisible_by(&other.abs)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\n\nimpl DivisibleByPowerOf2 for &Integer {\n    /// Returns whether an [`Integer`] is divisible by $2^k$.\n    ///\n    /// $f(x, k) = (2^k|x)$.\n    ///\n    /// $f(x, k) = (\\exists n \\in \\N : \\ x = n2^k)$.\n    ///\n    /// If `self` is 0, the result is always true; otherwise, it is equivalent to\n    /// `self.trailing_zeros().unwrap() <= pow`, but more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(pow, self.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.divisible_by_power_of_2(100), true);\n    /// assert_eq!(Integer::from(-100).divisible_by_power_of_2(2), true);\n    /// assert_eq!(Integer::from(100u32).divisible_by_power_of_2(3), false);\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).divisible_by_power_of_2(12),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).divisible_by_power_of_2(13),\n    ///     false\n    /// );\n    /// ```\n    fn divisible_by_power_of_2(self, pow: u64) -> bool {\n        self.abs.divisible_by_power_of_2(pow)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{limbs_add, limbs_add_limb};\nuse crate::natural::arithmetic::divisible_by::{\n    limbs_divisible_by, limbs_divisible_by_limb, limbs_divisible_by_val_ref,\n};\nuse crate::natural::arithmetic::eq_mod::{limbs_eq_limb_mod_limb, limbs_mod_exact_odd_limb};\nuse crate::natural::arithmetic::mod_op::limbs_mod_limb;\nuse crate::platform::{BMOD_1_TO_MOD_1_THRESHOLD, DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::{\n    DivisibleBy, EqMod, EqModPowerOf2, NegMod, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::TrailingZeros;\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, determines\n// whether that `Natural` is equal to the negative of a limb mod a given `Limb` m.\n//\n// This function assumes that `m` is nonzero, `limbs` has at least two elements, and the last\n// element of `limbs` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `limbs` is less than 2.\n//\n// This is equivalent to `mpz_congruent_ui_p` from `mpz/cong_ui.c`, GMP 6.2.1, where `a` is\n// negative.\npub_test! {limbs_eq_neg_limb_mod_limb(xs: &[Limb], y: Limb, m: Limb) -> bool {\n    limbs_eq_limb_mod_limb(xs, y.neg_mod(m), m)\n}}\n\n/// Set r to -n mod d. n >= d is allowed. Can give r > d. d cannot equal 0.\n///\n/// This is equivalent to `NEG_MOD` from `gmp-impl.h`, GMP 6.2.1, where `r` is returned.\nconst fn quick_neg_mod(n: Limb, d: Limb) -> Limb {\n    if n <= d {\n        d - n\n    } else {\n        let d = d << d.leading_zeros();\n        (if n <= d { d } else { d << 1 }).wrapping_sub(n)\n    }\n}\n\n// Interpreting two limbs `x` and `y` and slice of `Limb`s `m` as three numbers x, y, and m,\n// determines whether x ≡ -y mod m.\n//\n// This function assumes that the input slice has at least two elements, its last element is\n// nonzero, and `x` and `y` are nonzero.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a` and `d` are\n// positive, `c` is negative, `a` and `d` are one limb long, and `c` is longer than one limb.\npub_const_test! {limbs_pos_limb_eq_neg_limb_mod(x: Limb, y: Limb, ms: &[Limb]) -> bool {\n    // We are checking whether x ≡ -y mod m; that is, whether x + y = k * m for some k in Z. But\n    // because of the preconditions on m, the lowest possible value of m is `2 ^ Limb::WIDTH`, while\n    // the highest possible value of x + y is `2 ^ (Limb::WIDTH + 1) - 2`, so we have x + y < 2 * m.\n    // This means that k can only be 1, so we're actually checking whether x + y = m.\n    ms.len() == 2 && ms[1] == 1 && {\n        let (sum, overflow) = x.overflowing_add(y);\n        overflow && sum == ms[0]\n    }\n}}\n\n#[allow(clippy::absurd_extreme_comparisons)]\nfn limbs_pos_eq_neg_limb_mod_helper(xs: &[Limb], y: Limb, ms: &[Limb]) -> Option<bool> {\n    let m_len = ms.len();\n    let x_len = xs.len();\n    assert!(m_len > 1);\n    assert!(x_len > 1);\n    assert_ne!(y, 0);\n    assert_ne!(*xs.last().unwrap(), 0);\n    assert_ne!(*ms.last().unwrap(), 0);\n    let m_0 = ms[0];\n    // Check x == y mod low zero bits of m_0. This might catch a few cases of x != y quickly.\n    let twos = TrailingZeros::trailing_zeros(m_0);\n    if !xs[0].wrapping_neg().eq_mod_power_of_2(y, twos) {\n        return Some(false);\n    }\n    // m_0 == 0 is avoided since we don't want to bother handling extra low zero bits if m_1 is even\n    // (would involve borrow if x_0, y_0 != 0).\n    if m_len == 2 && m_0 != 0 {\n        let m_1 = ms[1];\n        if m_1 < Limb::power_of_2(twos) {\n            let m_0 = (m_0 >> twos) | (m_1 << (Limb::WIDTH - twos));\n            let y = quick_neg_mod(y, m_0);\n            return Some(if x_len >= BMOD_1_TO_MOD_1_THRESHOLD {\n                limbs_mod_limb::<DoubleLimb, Limb>(xs, m_0) == if y < m_0 { y } else { y % m_0 }\n            } else {\n                let r = limbs_mod_exact_odd_limb(xs, m_0, y);\n                r == 0 || r == m_0\n            });\n        }\n    }\n    None\n}\n\n// Interpreting a slice of `Limb`s `xs`, a Limb `y`, and another slice of `Limb`s `m` as three\n// numbers x, y, and m, determines whether x ≡ -y mod m. The second input slice is immutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `y` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `xs` or `ms` is less than 2, if the last element of either of the slices\n// is zero, or if `y` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a` and `d` are\n// positive, `c` is negative, `a` and `d` are longer than one limb, and `c` is one limb long.\npub_test! {limbs_pos_eq_neg_limb_mod_ref(xs: &[Limb], y: Limb, ms: &[Limb]) -> bool {\n    if let Some(equal) = limbs_pos_eq_neg_limb_mod_helper(xs, y, ms) {\n        return equal;\n    }\n    // calculate |x - y|. Different signs, add\n    let mut scratch = limbs_add_limb(xs, y);\n    scratch.len() >= ms.len() && limbs_divisible_by_val_ref(&mut scratch, ms)\n}}\n\n// Interpreting a slice of `Limb`s `xs`, a Limb `y`, and another slice of `Limb`s `ms` as three\n// numbers x, y, and m, determines whether x ≡ -y mod m. The second input slice is mutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `y` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `xs` or `ms` is less than 2, if the last element of either of the slices\n// is zero, or if `y` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a` and `d` are\n// positive, `c` is negative, `a` and `d` are longer than one limb, and `c` is one limb long.\npub_test! {limbs_pos_eq_neg_limb_mod(xs: &[Limb], y: Limb, ms: &mut [Limb]) -> bool {\n    if let Some(equal) = limbs_pos_eq_neg_limb_mod_helper(xs, y, ms) {\n        return equal;\n    }\n    // calculate |x - y|. Different signs, add\n    let mut scratch = limbs_add_limb(xs, y);\n    scratch.len() >= ms.len() && limbs_divisible_by(&mut scratch, ms)\n}}\n\n// Interpreting two slices of `Limb`s `xs` and `ys` and a Limb `m` as three numbers x, y, and m,\n// determines whether x ≡ -y mod m.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `m` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs` or `ys` is less than 2, if the last element of either of the slices\n// is zero, or if `m` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a` and `d` are\n// positive, `c` is negative, `a` and `c` are longer than one limb, and `m` is one limb long.\npub_test! {limbs_pos_eq_neg_mod_limb(xs: &[Limb], ys: &[Limb], m: Limb) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_pos_eq_mod_neg_limb_greater(xs, ys, m)\n    } else {\n        limbs_pos_eq_mod_neg_limb_greater(ys, xs, m)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_pos_eq_mod_neg_limb_greater(xs: &[Limb], ys: &[Limb], m: Limb) -> bool {\n    assert!(xs.len() > 1);\n    assert!(ys.len() > 1);\n    assert_ne!(*xs.last().unwrap(), 0);\n    assert_ne!(*ys.last().unwrap(), 0);\n    assert_ne!(m, 0);\n    // Check x == y mod low zero bits of m_0. This might catch a few cases of x != y quickly.\n    if !xs[0]\n        .wrapping_neg()\n        .eq_mod_power_of_2(ys[0], TrailingZeros::trailing_zeros(m))\n    {\n        return false;\n    }\n    // calculate |x - y|. Different signs, add\n    limbs_divisible_by_limb(&limbs_add(xs, ys), m)\n}\n\nfn limbs_pos_eq_neg_mod_greater_helper(xs: &[Limb], ys: &[Limb], ms: &[Limb]) -> Option<bool> {\n    assert!(ms.len() > 1);\n    assert!(xs.len() > 1);\n    assert!(ys.len() > 1);\n    assert_ne!(*xs.last().unwrap(), 0);\n    assert_ne!(*ys.last().unwrap(), 0);\n    assert_ne!(*ms.last().unwrap(), 0);\n    // Check x == y mod low zero bits of m_0. This might catch a few cases of x != y quickly.\n    if xs[0]\n        .wrapping_neg()\n        .eq_mod_power_of_2(ys[0], TrailingZeros::trailing_zeros(ms[0]))\n    {\n        None\n    } else {\n        Some(false)\n    }\n}\n\n// Interpreting three slice of `Limb`s as the limbs of three `Natural`s, determines whether the\n// first `Natural` is equal to the negative of the second `Natural` mod the third `Natural`. The\n// second input slice is immutable.\n//\n// This function assumes that each of the three input slices have at least two elements, and their\n// last elements are nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs`, `ys`, or `ms` is less than 2, or if the last element of any of the\n// slices is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a` and `d` are\n// positive, `c` is negative, and each is longer than one limb.\npub_test! {limbs_pos_eq_neg_mod_ref(xs: &[Limb], ys: &[Limb], ms: &[Limb]) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_pos_eq_neg_mod_greater_ref(xs, ys, ms)\n    } else {\n        limbs_pos_eq_neg_mod_greater_ref(ys, xs, ms)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_pos_eq_neg_mod_greater_ref(xs: &[Limb], ys: &[Limb], ms: &[Limb]) -> bool {\n    if let Some(equal) = limbs_pos_eq_neg_mod_greater_helper(xs, ys, ms) {\n        return equal;\n    }\n    // calculate |x - y|. Different signs, add\n    let mut scratch = limbs_add(xs, ys);\n    scratch.len() >= ms.len() && limbs_divisible_by_val_ref(&mut scratch, ms)\n}\n\n// Interpreting three slice of `Limb`s as the limbs of three `Natural`s, determines whether the\n// first `Natural` is equal to the negative of the second `Natural` mod the third `Natural`. The\n// second input slice is mutable.\n//\n// This function assumes that each of the three input slices have at least two elements, and their\n// last elements are nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs`, `ys`, or `ms` is less than 2, or if the last element of any of the\n// slices is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a` and `d` are\n// positive, `c` is negative, and each is longer than one limb.\npub_test! {limbs_pos_eq_neg_mod(xs: &[Limb], ys: &[Limb], ms: &mut [Limb]) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_pos_eq_neg_mod_greater(xs, ys, ms)\n    } else {\n        limbs_pos_eq_neg_mod_greater(ys, xs, ms)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_pos_eq_neg_mod_greater(xs: &[Limb], ys: &[Limb], ms: &mut [Limb]) -> bool {\n    if let Some(equal) = limbs_pos_eq_neg_mod_greater_helper(xs, ys, ms) {\n        return equal;\n    }\n    // calculate |x - y|. Different signs, add\n    let mut scratch = limbs_add(xs, ys);\n    scratch.len() >= ms.len() && limbs_divisible_by(&mut scratch, ms)\n}\n\nimpl Natural {\n    fn eq_neg_limb_mod_limb(&self, other: Limb, m: Limb) -> bool {\n        m != 0\n            && match self {\n                Self(Small(small)) => small % m == other.neg_mod(m),\n                Self(Large(limbs)) => limbs_eq_neg_limb_mod_limb(limbs, other, m),\n            }\n    }\n\n    fn pos_eq_neg_mod(&self, other: &Self, m: Self) -> bool {\n        match (self, other, m) {\n            (_, _, Self::ZERO) => false,\n            (x, &Self::ZERO, m) => x.divisible_by(m),\n            (&Self::ZERO, y, m) => y.divisible_by(m),\n            (x, &Self(Small(y)), Self(Small(m))) => x.eq_neg_limb_mod_limb(y, m),\n            (&Self(Small(x)), y, Self(Small(m))) => y.eq_neg_limb_mod_limb(x, m),\n            (&Self(Small(x)), &Self(Small(y)), Self(Large(ref m))) => {\n                limbs_pos_limb_eq_neg_limb_mod(x, y, m)\n            }\n            (&Self(Large(ref xs)), &Self(Large(ref ys)), Self(Small(m))) => {\n                limbs_pos_eq_neg_mod_limb(xs, ys, m)\n            }\n            (&Self(Large(ref xs)), &Self(Small(y)), Self(Large(ref mut m))) => {\n                limbs_pos_eq_neg_limb_mod(xs, y, m)\n            }\n            (&Self(Small(x)), &Self(Large(ref ys)), Self(Large(ref mut m))) => {\n                limbs_pos_eq_neg_limb_mod(ys, x, m)\n            }\n            (&Self(Large(ref xs)), &Self(Large(ref ys)), Self(Large(ref mut m))) => {\n                limbs_pos_eq_neg_mod(xs, ys, m)\n            }\n        }\n    }\n\n    fn pos_eq_neg_mod_ref(&self, other: &Self, m: &Self) -> bool {\n        match (self, other, m) {\n            (_, _, &Self::ZERO) => false,\n            (x, &Self::ZERO, m) => x.divisible_by(m),\n            (&Self::ZERO, y, m) => y.divisible_by(m),\n            (x, &Self(Small(y)), &Self(Small(m))) => x.eq_neg_limb_mod_limb(y, m),\n            (&Self(Small(x)), y, &Self(Small(m))) => y.eq_neg_limb_mod_limb(x, m),\n            (&Self(Small(x)), &Self(Small(y)), &Self(Large(ref m))) => {\n                limbs_pos_limb_eq_neg_limb_mod(x, y, m)\n            }\n            (&Self(Large(ref xs)), &Self(Large(ref ys)), &Self(Small(m))) => {\n                limbs_pos_eq_neg_mod_limb(xs, ys, m)\n            }\n            (&Self(Large(ref xs)), &Self(Small(y)), &Self(Large(ref m))) => {\n                limbs_pos_eq_neg_limb_mod_ref(xs, y, m)\n            }\n            (&Self(Small(x)), &Self(Large(ref ys)), &Self(Large(ref m))) => {\n                limbs_pos_eq_neg_limb_mod_ref(ys, x, m)\n            }\n            (&Self(Large(ref xs)), &Self(Large(ref ys)), &Self(Large(ref m))) => {\n                limbs_pos_eq_neg_mod_ref(xs, ys, m)\n            }\n        }\n    }\n}\n\nimpl EqMod<Self, Natural> for Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. All three numbers are taken by value.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(123).eq_mod(Integer::from(223), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Integer::from_str(\"-999999012346\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Integer::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Self, m: Natural) -> bool {\n        if self.sign == other.sign {\n            self.abs.eq_mod(other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod(&other.abs, m)\n        }\n    }\n}\n\nimpl EqMod<Self, &Natural> for Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. The first two numbers are taken by value and the third by reference.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(123).eq_mod(Integer::from(223), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Integer::from_str(\"-999999012346\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Integer::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Self, m: &Natural) -> bool {\n        if self.sign == other.sign {\n            self.abs.eq_mod(other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod_ref(&other.abs, m)\n        }\n    }\n}\n\nimpl EqMod<&Self, Natural> for Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. The first and third numbers are taken by value and the second by reference.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(123).eq_mod(&Integer::from(223), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Integer::from_str(\"-999999012346\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Integer::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &Self, m: Natural) -> bool {\n        if self.sign == other.sign {\n            self.abs.eq_mod(&other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod(&other.abs, m)\n        }\n    }\n}\n\nimpl EqMod<&Self, &Natural> for Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. The first number is taken by value and the second and third by reference.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(123).eq_mod(&Integer::from(223), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Integer::from_str(\"-999999012346\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Integer::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &Self, m: &Natural) -> bool {\n        if self.sign == other.sign {\n            self.abs.eq_mod(&other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod_ref(&other.abs, m)\n        }\n    }\n}\n\nimpl EqMod<Integer, Natural> for &Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. The first number is taken by reference and the second and third by value.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(123)).eq_mod(Integer::from(223), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Integer::from_str(\"-999999012346\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Integer::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Integer, m: Natural) -> bool {\n        if self.sign == other.sign {\n            (&self.abs).eq_mod(other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod(&other.abs, m)\n        }\n    }\n}\n\nimpl EqMod<Integer, &Natural> for &Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. The first and third numbers are taken by reference and the third by value.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(123)).eq_mod(Integer::from(223), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Integer::from_str(\"-999999012346\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Integer::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Integer, m: &Natural) -> bool {\n        if self.sign == other.sign {\n            (&self.abs).eq_mod(other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod_ref(&other.abs, m)\n        }\n    }\n}\n\nimpl EqMod<&Integer, Natural> for &Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. The first two numbers are taken by reference and the third by value.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(123)).eq_mod(&Integer::from(223), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Integer::from_str(\"-999999012346\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Integer::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &Integer, m: Natural) -> bool {\n        if self.sign == other.sign {\n            (&self.abs).eq_mod(&other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod(&other.abs, m)\n        }\n    }\n}\n\nimpl EqMod<&Integer, &Natural> for &Integer {\n    /// Returns whether an [`Integer`] is equivalent to another [`Integer`] modulo a [`Natural`];\n    /// that is, whether the difference between the two [`Integer`]s is a multiple of the\n    /// [`Natural`]. All three numbers are taken by reference.\n    ///\n    /// Two [`Integer`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(123)).eq_mod(&Integer::from(223), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Integer::from_str(\"-999999012346\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Integer::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &Integer, m: &Natural) -> bool {\n        if self.sign == other.sign {\n            (&self.abs).eq_mod(&other.abs, m)\n        } else {\n            self.abs.pos_eq_neg_mod_ref(&other.abs, m)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2001, 2002, 2013 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::divisible_by_power_of_2::limbs_divisible_by_power_of_2;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::EqModPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns whether\n// the negative of the `Natural` is equivalent to a limb mod two to the power of `pow`; that is,\n// whether the `pow` least-significant bits of the negative of the `Natural` and the limb are equal.\n//\n// This function assumes that `limbs` has length at least 2 and the last (most significant) limb is\n// nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_eq_mod_power_of_2_neg_limb(xs: &[Limb], y: Limb, pow: u64) -> bool {\n    if y == 0 {\n        return limbs_divisible_by_power_of_2(xs, pow);\n    }\n    let i = bit_to_limb_count_floor(pow);\n    match i.cmp(&xs.len()) {\n        Greater => false,\n        Equal => {\n            if pow & Limb::WIDTH_MASK == 0 {\n                // Check whether the sum of X and y is 0 mod B ^ xs.len().\n                let mut carry = y;\n                for &x in xs {\n                    let sum = x.wrapping_add(carry);\n                    if sum != 0 {\n                        return false;\n                    }\n                    carry = 1;\n                }\n                true\n            } else {\n                false\n            }\n        }\n        Less => {\n            if i == 0 {\n                xs[0].eq_mod_power_of_2(y.wrapping_neg(), pow)\n            } else {\n                xs[0] == y.wrapping_neg()\n                    && xs[1..i].iter().all(|&x| x == Limb::MAX)\n                    && xs[i].eq_mod_power_of_2(Limb::MAX, pow & Limb::WIDTH_MASK)\n            }\n        }\n    }\n}}\n\nfn limbs_eq_mod_power_of_2_neg_pos_greater(xs: &[Limb], ys: &[Limb], pow: u64) -> bool {\n    let xs_len = xs.len();\n    let i = bit_to_limb_count_floor(pow);\n    let small_pow = pow & Limb::WIDTH_MASK;\n    if i > xs_len || i == xs_len && small_pow != 0 {\n        false\n    } else {\n        let ys_len = ys.len();\n        let mut y_nonzero_seen = false;\n        for j in 0..i {\n            let y = if j >= ys_len {\n                Limb::MAX\n            } else if y_nonzero_seen {\n                !ys[j]\n            } else if ys[j] == 0 {\n                0\n            } else {\n                y_nonzero_seen = true;\n                ys[j].wrapping_neg()\n            };\n            if xs[j] != y {\n                return false;\n            }\n        }\n        if small_pow == 0 {\n            true\n        } else {\n            // i < xs_len\n            let y = if i >= ys_len {\n                Limb::MAX\n            } else if y_nonzero_seen {\n                !ys[i]\n            } else {\n                ys[i].wrapping_neg()\n            };\n            xs[i].eq_mod_power_of_2(y, small_pow)\n        }\n    }\n}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns\n// whether the first `Natural` and the negative of the second natural (equivalently, the negative of\n// the first `Natural` and the second `Natural`) are equivalent mod two to the power of `pow`; that\n// is, whether their `pow` least-significant bits are equal.\n//\n// This function assumes that neither slice is empty and their last elements are nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_congruent_2exp_p` from `mpz/cong_2exp.c`, GMP 6.2.1, where `a` is\n// negative and `c` is positive.\npub_test! {limbs_eq_mod_power_of_2_neg_pos(xs: &[Limb], ys: &[Limb], pow: u64) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_power_of_2_neg_pos_greater(xs, ys, pow)\n    } else {\n        limbs_eq_mod_power_of_2_neg_pos_greater(ys, xs, pow)\n    }\n}}\n\nimpl Natural {\n    fn eq_mod_power_of_2_neg_limb(&self, other: Limb, pow: u64) -> bool {\n        match self {\n            Self(Small(small)) => {\n                pow <= Limb::WIDTH && small.wrapping_neg().eq_mod_power_of_2(other, pow)\n            }\n            Self(Large(limbs)) => limbs_eq_mod_power_of_2_neg_limb(limbs, other, pow),\n        }\n    }\n\n    fn eq_mod_power_of_2_neg_pos(&self, other: &Self, pow: u64) -> bool {\n        match (self, other) {\n            (_, &Self(Small(y))) => self.eq_mod_power_of_2_neg_limb(y, pow),\n            (&Self(Small(x)), _) => other.eq_mod_power_of_2_neg_limb(x, pow),\n            (Self(Large(xs)), Self(Large(ys))) => limbs_eq_mod_power_of_2_neg_pos(xs, ys, pow),\n        }\n    }\n}\n\nimpl EqModPowerOf2<&Integer> for &Integer {\n    /// Returns whether one [`Integer`] is equal to another modulo $2^k$; that is, whether their $k$\n    /// least-significant bits (in two's complement) are equal.\n    ///\n    /// $f(x, y, k) = (x \\equiv y \\mod 2^k)$.\n    ///\n    /// $f(x, y, k) = (\\exists n \\in \\Z : x - y = n2^k)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(pow, self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::EqModPowerOf2;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::ZERO.eq_mod_power_of_2(&Integer::from(-256), 8),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-0b1101).eq_mod_power_of_2(&Integer::from(0b11011), 3),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-0b1101).eq_mod_power_of_2(&Integer::from(0b11011), 4),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod_power_of_2(self, other: &Integer, pow: u64) -> bool {\n        if self.sign == other.sign {\n            self.abs.eq_mod_power_of_2(&other.abs, pow)\n        } else {\n            self.abs.eq_mod_power_of_2_neg_pos(&other.abs, pow)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ExtendedGcd, NegAssign, UnsignedAbs};\n\nimpl ExtendedGcd for Integer {\n    type Gcd = Natural;\n    type Cofactor = Self;\n\n    /// Computes the GCD (greatest common divisor) of two [`Integer`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. Both [`Integer`]s are\n    /// taken by value.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(a, ak) = (-a, -1, 0)$ if $a < 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(bk, b) = (-b, 0, -1)$ if $b < 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(|a|, |b|)$,\n    ///   where $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq\n    ///   \\lfloor a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(3)\n    ///         .extended_gcd(Integer::from(5))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(240)\n    ///         .extended_gcd(Integer::from(46))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-111)\n    ///         .extended_gcd(Integer::from(300))\n    ///         .to_debug_string(),\n    ///     \"(3, 27, 10)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: Self) -> (Natural, Self, Self) {\n        let a_sign = self.sign;\n        let b_sign = other.sign;\n        let (gcd, mut x, mut y) = self.unsigned_abs().extended_gcd(other.unsigned_abs());\n        if !a_sign {\n            x.neg_assign();\n        }\n        if !b_sign {\n            y.neg_assign();\n        }\n        (gcd, x, y)\n    }\n}\n\nimpl ExtendedGcd<&Self> for Integer {\n    type Gcd = Natural;\n    type Cofactor = Self;\n\n    /// Computes the GCD (greatest common divisor) of two [`Integer`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. The first [`Integer`] is\n    /// taken by value and the second by reference.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(a, ak) = (-a, -1, 0)$ if $a < 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(bk, b) = (-b, 0, -1)$ if $b < 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(|a|, |b|)$,\n    ///   where $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq\n    ///   \\lfloor a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(3)\n    ///         .extended_gcd(&Integer::from(5))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(240)\n    ///         .extended_gcd(&Integer::from(46))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-111)\n    ///         .extended_gcd(&Integer::from(300))\n    ///         .to_debug_string(),\n    ///     \"(3, 27, 10)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: &Self) -> (Natural, Self, Self) {\n        let a_sign = self.sign;\n        let (gcd, mut x, mut y) = self.unsigned_abs().extended_gcd(other.unsigned_abs_ref());\n        if !a_sign {\n            x.neg_assign();\n        }\n        if !other.sign {\n            y.neg_assign();\n        }\n        (gcd, x, y)\n    }\n}\n\nimpl ExtendedGcd<Integer> for &Integer {\n    type Gcd = Natural;\n    type Cofactor = Integer;\n\n    /// Computes the GCD (greatest common divisor) of two [`Integer`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. The first [`Integer`] is\n    /// taken by reference and the second by value.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(a, ak) = (-a, -1, 0)$ if $a < 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(bk, b) = (-b, 0, -1)$ if $b < 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(|a|, |b|)$,\n    ///   where $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq\n    ///   \\lfloor a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(3))\n    ///         .extended_gcd(Integer::from(5))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(240))\n    ///         .extended_gcd(Integer::from(46))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-111))\n    ///         .extended_gcd(Integer::from(300))\n    ///         .to_debug_string(),\n    ///     \"(3, 27, 10)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: Integer) -> (Natural, Integer, Integer) {\n        let b_sign = other.sign;\n        let (gcd, mut x, mut y) = self.unsigned_abs_ref().extended_gcd(other.unsigned_abs());\n        if !self.sign {\n            x.neg_assign();\n        }\n        if !b_sign {\n            y.neg_assign();\n        }\n        (gcd, x, y)\n    }\n}\n\nimpl ExtendedGcd<&Integer> for &Integer {\n    type Gcd = Natural;\n    type Cofactor = Integer;\n\n    /// Computes the GCD (greatest common divisor) of two [`Integer`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. Both [`Integer`]s are\n    /// taken by reference.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(a, ak) = (-a, -1, 0)$ if $a < 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(bk, b) = (-b, 0, -1)$ if $b < 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(|a|, |b|)$,\n    ///   where $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq\n    ///   \\lfloor a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(3))\n    ///         .extended_gcd(&Integer::from(5))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(240))\n    ///         .extended_gcd(&Integer::from(46))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-111))\n    ///         .extended_gcd(&Integer::from(300))\n    ///         .to_debug_string(),\n    ///     \"(3, 27, 10)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: &Integer) -> (Natural, Integer, Integer) {\n        let (gcd, mut x, mut y) = self\n            .unsigned_abs_ref()\n            .extended_gcd(other.unsigned_abs_ref());\n        if !self.sign {\n            x.neg_assign();\n        }\n        if !other.sign {\n            y.neg_assign();\n        }\n        (gcd, x, y)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2000-2002, 2005, 2010-2012 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::div_mod::limbs_div_mod_to_out;\nuse crate::natural::arithmetic::eq_mod::limbs_mod_exact_odd_limb;\nuse crate::natural::arithmetic::kronecker_symbol::{\n    limbs_jacobi_symbol_init, limbs_jacobi_symbol_same_length,\n};\nuse crate::natural::arithmetic::mod_op::limbs_mod_limb_alt_2;\nuse crate::natural::arithmetic::shr::limbs_shr_to_out;\nuse crate::platform::{BMOD_1_TO_MOD_1_THRESHOLD, DoubleLimb, Limb};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    JacobiSymbol, KroneckerSymbol, LegendreSymbol, Parity,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::{BitAccess, NotAssign, TrailingZeros};\nuse malachite_base::slices::slice_leading_zeros;\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpz_jacobi` from `mpz/jacobi.c`, GMP 6.2.1, where the absolute values of\n// both `a` and `b` fit in a limb.\npub_crate_test! {limbs_kronecker_symbol_single(\n    x_sign: bool,\n    x: Limb,\n    y_sign: bool,\n    mut y: Limb,\n) -> i8 {\n    // Common factor of 2 => (a/b) = 0\n    if (x | y).even() {\n        return 0;\n    }\n    // (a/-1) = -1 if a < 0, +1 if a >= 0\n    let mut negate = !x_sign && !y_sign;\n    let y_twos = TrailingZeros::trailing_zeros(y);\n    y >>= y_twos;\n    // (-1/b) = -1 iff b = 3 (mod 4)\n    if !x_sign && y.get_bit(1) {\n        negate.not_assign();\n    }\n    if y_twos.odd() & ((x >> 1) ^ x).get_bit(1) {\n        negate.not_assign();\n    }\n    let j = if y == 1 { 1 } else { x.jacobi_symbol(y) };\n    if negate {\n        -j\n    } else {\n        j\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_jacobi` from `mpz/jacobi.c`, GMP 6.2.1.\npub_crate_test! {\n    limbs_kronecker_symbol(x_sign: bool, xs: &[Limb], y_sign: bool, ys: &[Limb]) -> i8 {\n    let mut xs_len = xs.len();\n    let mut ys_len = ys.len();\n    // The `limbs_jacobi_symbol_same_length` function requires positive x and y, and x odd. So we\n    // must handle the cases of x or y zero, then signs, and then the case of even y.\n    //\n    // (x / 0) = (x = 1 or x = -1)\n    if ys_len == 0 {\n        return i8::from(xs == [1]);\n    }\n    // (0 / y) = (y = 1 or y = -1)\n    if xs_len == 0 {\n        return i8::from(ys == [1]);\n    }\n    assert_ne!(xs[xs_len - 1], 0);\n    assert_ne!(ys[ys_len - 1], 0);\n    let mut xs = xs;\n    let mut ys = ys;\n    // Common factor of 2 => (x / y) = 0\n    if (xs[0] | ys[0]).even() {\n        return 0;\n    }\n    // (x / -1) = -1 if x < 0, 1 if x >= 0\n    let mut negate = !x_sign && !y_sign;\n    ys = &ys[slice_leading_zeros(ys)..];\n    ys_len = ys.len();\n    let mut y_lo = ys[0];\n    let mut y_twos = TrailingZeros::trailing_zeros(y_lo);\n    y_lo >>= y_twos;\n    if ys_len > 1 && y_twos != 0 {\n        let y_1 = ys[1];\n        y_lo |= y_1 << (Limb::WIDTH - y_twos);\n        if ys_len == 2 && y_1 >> y_twos == 0 {\n            ys_len = 1;\n        }\n    }\n    // (-1 / y) = -1 iff y ≡ 3 mod 4\n    if !x_sign && y_lo.get_bit(1) {\n        negate.not_assign();\n    }\n    xs = &xs[slice_leading_zeros(xs)..];\n    xs_len = xs.len();\n    let mut x_lo = xs[0];\n    // Ensure xs_len >= ys_len. Take advantage of the generalized reciprocity law: (x / y * 2 ^ n) =\n    // (y * 2 ^ n / x) * recip(x, y)\n    if xs_len < ys_len {\n        swap(&mut xs, &mut ys);\n        swap(&mut xs_len, &mut ys_len);\n        swap(&mut x_lo, &mut y_lo);\n        // The value of x_lo (old y_lo) is a bit subtle. For this code path, we get x_lo as the low,\n        // always odd, limb of shifted x. Which is what we need for the reciprocity update below.\n        //\n        // However, all other uses of x_lo assumes that it is *not* shifted. Luckily, x_lo matters\n        // only when either\n        // - y_twos > 0, in which case x is always odd\n        // - xs_len = ys_len = 1, in which case this code path is never taken.\n        y_twos = TrailingZeros::trailing_zeros(y_lo);\n        y_lo >>= y_twos;\n        if ys_len > 1 && y_twos != 0 {\n            let y_1 = ys[1];\n            y_lo |= y_1 << (Limb::WIDTH - y_twos);\n            if ys_len == 2 && y_1 >> y_twos == 0 {\n                ys_len = 1;\n            }\n        }\n        if (x_lo & y_lo).get_bit(1) {\n            negate.not_assign();\n        }\n    }\n    if ys_len == 1 {\n        if y_twos.odd() & ((x_lo >> 1) ^ x_lo).get_bit(1) {\n            negate.not_assign();\n        }\n        if y_lo == 1 {\n            return if negate { -1 } else { 1 };\n        }\n        if xs_len > 1 {\n            assert!(y_lo.odd());\n            x_lo = if xs.len() >= BMOD_1_TO_MOD_1_THRESHOLD {\n                limbs_mod_limb_alt_2::<DoubleLimb, Limb>(xs, y_lo)\n            } else {\n                if y_lo.get_bit(1) {\n                    negate.not_assign();\n                }\n                limbs_mod_exact_odd_limb(xs, y_lo, 0)\n            };\n        }\n        let j = x_lo.jacobi_symbol(y_lo);\n        return if negate { -j } else { j };\n    }\n    // Allocation strategy: For x, we allocate a working copy only for x % y, but when x is much\n    // larger than y, we have to allocate space for the large quotient. We use the same area,\n    // pointed to by ys_alt, for both the quotient x / y and the working copy of y.\n    let mut scratch = vec![\n        0;\n        if xs_len >= ys_len << 1 {\n            xs_len + 1\n        } else {\n            ys_len << 1\n        }\n    ];\n    let (mut xs_alt, mut ys_alt) = scratch.split_at_mut(ys_len);\n    // In the case of even y, we conceptually shift out the powers of two first, and then divide x %\n    // y. Hence, when taking those powers of two into account, we must use alow *before* the\n    // division. Doing the actual division first is ok, because the point is to remove multiples of\n    // y from x, and multiples of 2 ^ k y are good enough.\n    if xs_len > ys_len {\n        limbs_div_mod_to_out(ys_alt, xs_alt, xs, ys);\n        ys_alt = &mut ys_alt[..ys_len];\n    } else {\n        xs_alt.copy_from_slice(xs);\n    }\n    if y_twos != 0 {\n        if y_twos.odd() & ((x_lo >> 1) ^ x_lo).get_bit(1) {\n            negate.not_assign();\n        }\n        limbs_shr_to_out(ys_alt, ys, y_twos);\n        if xs_alt[ys_len - 1] == 0 && ys_alt[ys_len - 1] == 0 {\n            xs_alt = &mut xs_alt[..ys_len - 1];\n            ys_alt = &mut ys_alt[..ys_len - 1];\n        }\n    } else {\n        ys_alt.copy_from_slice(ys);\n    }\n    assert_eq!(y_lo, ys_alt[0]);\n    let bits = limbs_jacobi_symbol_init(xs_alt[0], y_lo, u8::from(negate));\n    limbs_jacobi_symbol_same_length(xs_alt, ys_alt, bits)\n}}\n\nimpl LegendreSymbol<Self> for Integer {\n    /// Computes the Legendre symbol of two [`Integer`]s, taking both by value.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(10).legendre_symbol(Integer::from(5)), 0);\n    /// assert_eq!(Integer::from(7).legendre_symbol(Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(11).legendre_symbol(Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(-7).legendre_symbol(Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(-11).legendre_symbol(Integer::from(5)), 1);\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: Self) -> i8 {\n        assert!(other > 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(&other)\n    }\n}\n\nimpl LegendreSymbol<&Self> for Integer {\n    /// Computes the Legendre symbol of two [`Integer`]s, taking the first by value and the second\n    /// by reference.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(10).legendre_symbol(&Integer::from(5)), 0);\n    /// assert_eq!(Integer::from(7).legendre_symbol(&Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(11).legendre_symbol(&Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(-7).legendre_symbol(&Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(-11).legendre_symbol(&Integer::from(5)), 1);\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: &Self) -> i8 {\n        assert!(*other > 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(other)\n    }\n}\n\nimpl LegendreSymbol<Integer> for &Integer {\n    /// Computes the Legendre symbol of two [`Integer`]s, taking the first by reference and the\n    /// second by value.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(10)).legendre_symbol(Integer::from(5)), 0);\n    /// assert_eq!((&Integer::from(7)).legendre_symbol(Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(11)).legendre_symbol(Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(-7)).legendre_symbol(Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(-11)).legendre_symbol(Integer::from(5)), 1);\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: Integer) -> i8 {\n        assert!(other > 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(&other)\n    }\n}\n\nimpl LegendreSymbol<&Integer> for &Integer {\n    /// Computes the Legendre symbol of two [`Integer`]s, taking both by reference.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(10)).legendre_symbol(&Integer::from(5)), 0);\n    /// assert_eq!((&Integer::from(7)).legendre_symbol(&Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(11)).legendre_symbol(&Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(-7)).legendre_symbol(&Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(-11)).legendre_symbol(&Integer::from(5)), 1);\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: &Integer) -> i8 {\n        assert!(*other > 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(other)\n    }\n}\n\nimpl JacobiSymbol<Self> for Integer {\n    /// Computes the Jacobi symbol of two [`Integer`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(10).jacobi_symbol(Integer::from(5)), 0);\n    /// assert_eq!(Integer::from(7).jacobi_symbol(Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(11).jacobi_symbol(Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(11).jacobi_symbol(Integer::from(9)), 1);\n    /// assert_eq!(Integer::from(-7).jacobi_symbol(Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(-11).jacobi_symbol(Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(-11).jacobi_symbol(Integer::from(9)), 1);\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: Self) -> i8 {\n        assert!(other > 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(&other)\n    }\n}\n\nimpl JacobiSymbol<&Self> for Integer {\n    /// Computes the Jacobi symbol of two [`Integer`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(10).jacobi_symbol(&Integer::from(5)), 0);\n    /// assert_eq!(Integer::from(7).jacobi_symbol(&Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(11).jacobi_symbol(&Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(11).jacobi_symbol(&Integer::from(9)), 1);\n    /// assert_eq!(Integer::from(-7).jacobi_symbol(&Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(-11).jacobi_symbol(&Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(-11).jacobi_symbol(&Integer::from(9)), 1);\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: &Self) -> i8 {\n        assert!(*other > 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(other)\n    }\n}\n\nimpl JacobiSymbol<Integer> for &Integer {\n    /// Computes the Jacobi symbol of two [`Integer`]s, taking the first by reference and the second\n    /// by value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(10)).jacobi_symbol(Integer::from(5)), 0);\n    /// assert_eq!((&Integer::from(7)).jacobi_symbol(Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(11)).jacobi_symbol(Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(11)).jacobi_symbol(Integer::from(9)), 1);\n    /// assert_eq!((&Integer::from(-7)).jacobi_symbol(Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(-11)).jacobi_symbol(Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(-11)).jacobi_symbol(Integer::from(9)), 1);\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: Integer) -> i8 {\n        assert!(other > 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(&other)\n    }\n}\n\nimpl JacobiSymbol<&Integer> for &Integer {\n    /// Computes the Jacobi symbol of two [`Integer`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative or if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(10)).jacobi_symbol(&Integer::from(5)), 0);\n    /// assert_eq!((&Integer::from(7)).jacobi_symbol(&Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(11)).jacobi_symbol(&Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(11)).jacobi_symbol(&Integer::from(9)), 1);\n    /// assert_eq!((&Integer::from(-7)).jacobi_symbol(&Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(-11)).jacobi_symbol(&Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(-11)).jacobi_symbol(&Integer::from(9)), 1);\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: &Integer) -> i8 {\n        assert!(*other > 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(other)\n    }\n}\n\nimpl KroneckerSymbol<Self> for Integer {\n    /// Computes the Kronecker symbol of two [`Integer`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(10).kronecker_symbol(Integer::from(5)), 0);\n    /// assert_eq!(Integer::from(7).kronecker_symbol(Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(11).kronecker_symbol(Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(11).kronecker_symbol(Integer::from(9)), 1);\n    /// assert_eq!(Integer::from(11).kronecker_symbol(Integer::from(8)), -1);\n    /// assert_eq!(Integer::from(-7).kronecker_symbol(Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(Integer::from(9)), 1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(Integer::from(8)), -1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(Integer::from(-8)), 1);\n    /// ```\n    #[inline]\n    fn kronecker_symbol(self, other: Self) -> i8 {\n        (&self).kronecker_symbol(&other)\n    }\n}\n\nimpl KroneckerSymbol<&Self> for Integer {\n    /// Computes the Kronecker symbol of two [`Integer`]s, taking the first by value and the second\n    /// by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(10).kronecker_symbol(&Integer::from(5)), 0);\n    /// assert_eq!(Integer::from(7).kronecker_symbol(&Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(11).kronecker_symbol(&Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(11).kronecker_symbol(&Integer::from(9)), 1);\n    /// assert_eq!(Integer::from(11).kronecker_symbol(&Integer::from(8)), -1);\n    /// assert_eq!(Integer::from(-7).kronecker_symbol(&Integer::from(5)), -1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(&Integer::from(5)), 1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(&Integer::from(9)), 1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(&Integer::from(8)), -1);\n    /// assert_eq!(Integer::from(-11).kronecker_symbol(&Integer::from(-8)), 1);\n    /// ```\n    #[inline]\n    fn kronecker_symbol(self, other: &Self) -> i8 {\n        (&self).kronecker_symbol(other)\n    }\n}\n\nimpl KroneckerSymbol<Integer> for &Integer {\n    /// Computes the Kronecker symbol of two [`Integer`]s, taking the first by reference and the\n    /// second value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(10)).kronecker_symbol(Integer::from(5)), 0);\n    /// assert_eq!((&Integer::from(7)).kronecker_symbol(Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(11)).kronecker_symbol(Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(11)).kronecker_symbol(Integer::from(9)), 1);\n    /// assert_eq!((&Integer::from(11)).kronecker_symbol(Integer::from(8)), -1);\n    /// assert_eq!((&Integer::from(-7)).kronecker_symbol(Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(-11)).kronecker_symbol(Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(-11)).kronecker_symbol(Integer::from(9)), 1);\n    /// assert_eq!((&Integer::from(-11)).kronecker_symbol(Integer::from(8)), -1);\n    /// assert_eq!((&Integer::from(-11)).kronecker_symbol(Integer::from(-8)), 1);\n    /// ```\n    #[inline]\n    fn kronecker_symbol(self, other: Integer) -> i8 {\n        self.kronecker_symbol(&other)\n    }\n}\n\nimpl KroneckerSymbol<&Integer> for &Integer {\n    /// Computes the Kronecker symbol of two [`Integer`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(10)).kronecker_symbol(&Integer::from(5)), 0);\n    /// assert_eq!((&Integer::from(7)).kronecker_symbol(&Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(11)).kronecker_symbol(&Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(11)).kronecker_symbol(&Integer::from(9)), 1);\n    /// assert_eq!((&Integer::from(11)).kronecker_symbol(&Integer::from(8)), -1);\n    /// assert_eq!((&Integer::from(-7)).kronecker_symbol(&Integer::from(5)), -1);\n    /// assert_eq!((&Integer::from(-11)).kronecker_symbol(&Integer::from(5)), 1);\n    /// assert_eq!((&Integer::from(-11)).kronecker_symbol(&Integer::from(9)), 1);\n    /// assert_eq!(\n    ///     (&Integer::from(-11)).kronecker_symbol(&Integer::from(8)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-11)).kronecker_symbol(&Integer::from(-8)),\n    ///     1\n    /// );\n    /// ```\n    fn kronecker_symbol(self, other: &Integer) -> i8 {\n        match (self, other) {\n            (x, integer_zero!()) => i8::from(*x.unsigned_abs_ref() == 1u32),\n            (integer_zero!(), y) => i8::from(*y.unsigned_abs_ref() == 1u32),\n            (\n                Integer {\n                    sign: x_sign,\n                    abs: Natural(Small(x_abs)),\n                },\n                Integer {\n                    sign: y_sign,\n                    abs: Natural(Small(y_abs)),\n                },\n            ) => limbs_kronecker_symbol_single(*x_sign, *x_abs, *y_sign, *y_abs),\n            (\n                Integer {\n                    sign: x_sign,\n                    abs: Natural(Small(x_abs)),\n                },\n                Integer {\n                    sign: y_sign,\n                    abs: Natural(Large(ys)),\n                },\n            ) => limbs_kronecker_symbol(*x_sign, &[*x_abs], *y_sign, ys),\n            (\n                Integer {\n                    sign: x_sign,\n                    abs: Natural(Large(xs)),\n                },\n                Integer {\n                    sign: y_sign,\n                    abs: Natural(Small(y_abs)),\n                },\n            ) => limbs_kronecker_symbol(*x_sign, xs, *y_sign, &[*y_abs]),\n            (\n                Integer {\n                    sign: x_sign,\n                    abs: Natural(Large(xs)),\n                },\n                Integer {\n                    sign: y_sign,\n                    abs: Natural(Large(ys)),\n                },\n            ) => limbs_kronecker_symbol(*x_sign, xs, *y_sign, ys),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Absolute value of [`Integer`](super::Integer)s, including implementations of\n/// [`UnsignedAbs`](malachite_base::num::arithmetic::traits::UnsignedAbs).\npub mod abs;\n/// Implementations of [`AbsDiff`](malachite_base::num::arithmetic::traits::AbsDiff) and\n/// [`AbsDiffAssign`](malachite_base::num::arithmetic::traits::AbsDiffAssign), traits for getting\n/// the absolute value of the difference between two numbers.\npub mod abs_diff;\n/// Addition of [`Integer`](super::Integer)s.\npub mod add;\n/// Implementations of [`AddMul`](malachite_base::num::arithmetic::traits::AddMul) and\n/// [`AddMulAssign`](malachite_base::num::arithmetic::traits::AddMulAssign), traits for adding a\n/// number and the product of two other numbers.\npub mod add_mul;\n/// Implementations of\n/// [`BinomialCoefficient`](malachite_base::num::arithmetic::traits::BinomialCoefficient), a trait\n/// for computing the binomial coefficient of two numbers.\npub mod binomial_coefficient;\n/// Division of [`Integer`](super::Integer)s.\npub mod div;\n/// Implementations of [`DivExact`](malachite_base::num::arithmetic::traits::DivExact) and\n/// [`DivExactAssign`](malachite_base::num::arithmetic::traits::DivExactAssign), traits for dividing\n/// two numbers when it's known that the division is exact.\npub mod div_exact;\n/// Implementations of raits for simultaneously finding the quotient and remainder of two numbers,\n/// subject to various rounding rules.\n///\n/// These are the traits:\n///\n/// | rounding     | by value or reference           | by mutable reference (assignment)      |\n/// |--------------|---------------------------------|----------------------------------------|\n/// | towards $-\\infty$ | [`DivMod`](malachite_base::num::arithmetic::traits::DivMod) | [`DivAssignMod`](malachite_base::num::arithmetic::traits::DivAssignMod) |\n/// | towards 0         | [`DivRem`](malachite_base::num::arithmetic::traits::DivRem) | [`DivAssignRem`](malachite_base::num::arithmetic::traits::DivAssignRem) |\n/// | towards $\\infty$  | [`CeilingDivMod`](malachite_base::num::arithmetic::traits::CeilingDivMod) | [`CeilingDivAssignMod`](malachite_base::num::arithmetic::traits::CeilingDivAssignMod) |\npub mod div_mod;\n/// Implementations of [`DivRound`](malachite_base::num::arithmetic::traits::DivRound) and\n/// [`DivExactAssign`](malachite_base::num::arithmetic::traits::DivRoundAssign), traits for dividing\n/// two numbers according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode).\npub mod div_round;\n/// Implementations of [`DivisibleBy`](malachite_base::num::arithmetic::traits::DivisibleBy), a\n/// trait for determining whether one number is divisible by another.\npub mod divisible_by;\n/// Implementations of\n/// [`DivisibleByPowerOf2`](malachite_base::num::arithmetic::traits::DivisibleByPowerOf2), a trait\n/// for determining whether a number is divisible by $2^k$.\npub mod divisible_by_power_of_2;\n/// Implementations of [`EqMod`](malachite_base::num::arithmetic::traits::EqMod), a trait for\n/// determining whether one number is equal by another modulo a third.\npub mod eq_mod;\n/// Implementations of [`EqModPowerOf2`](malachite_base::num::arithmetic::traits::EqModPowerOf2), a\n/// trait for determining whether one number is equal to another modulo $2^k$.\npub mod eq_mod_power_of_2;\n/// Implementations of [`ExtendedGcd`](malachite_base::num::arithmetic::traits::ExtendedGcd), a\n/// trait for computing the extended GCD of two numbers.\npub mod extended_gcd;\n/// Implementations of [`LegendreSymbol`](malachite_base::num::arithmetic::traits::LegendreSymbol),\n/// [`JacobiSymbol`](malachite_base::num::arithmetic::traits::JacobiSymbol), and\n/// [`KroneckerSymbol`](malachite_base::num::arithmetic::traits::KroneckerSymbol), traits for\n/// computing the Legendre, Jacobi, and Kronecker symbols of two numbers.\npub mod kronecker_symbol;\n/// Implementations of traits for finding the remainder of two numbers, subject to various rounding\n/// rules.\n///\n/// These are the traits:\n///\n/// | rounding          | by value or reference      | by mutable reference (assignment)      |\n/// |-------------------|----------------------------|----------------------------------------|\n/// | towards $-\\infty$ | [`Mod`](malachite_base::num::arithmetic::traits::Mod) | [`ModAssign`](malachite_base::num::arithmetic::traits::ModAssign)       |\n/// | towards $\\infty$ | [`CeilingMod`](malachite_base::num::arithmetic::traits::CeilingMod) | [`CeilingModAssign`](malachite_base::num::arithmetic::traits::CeilingModAssign) |\n///\n/// The [`Rem`](core::ops::Rem) trait in the standard library rounds towards 0.\npub mod mod_op;\n/// Implementations of traits for finding the remainder of a number divided by $2^k$, subject to\n/// various rounding rules.\n///\n/// These are the traits:\n///\n/// | rounding | by value or reference | by mutable reference (assignment) |\n/// |----------|-----------------------|-----------------------------------|\n/// | towards $-\\infty$ | [`ModPowerOf2`](malachite_base::num::arithmetic::traits::ModPowerOf2) | [`ModPowerOf2Assign`](malachite_base::num::arithmetic::traits::ModPowerOf2Assign)       |\n/// | towards 0 | [`RemPowerOf2`](malachite_base::num::arithmetic::traits::RemPowerOf2) | [`RemPowerOf2Assign`](malachite_base::num::arithmetic::traits::RemPowerOf2Assign)       |\n/// | towards $\\infty$  | [`CeilingModPowerOf2`](malachite_base::num::arithmetic::traits::CeilingModPowerOf2) | [`CeilingModPowerOf2Assign`](malachite_base::num::arithmetic::traits::CeilingModPowerOf2Assign) |\npub mod mod_power_of_2;\n/// Multiplication of [`Integer`](super::Integer)s.\npub mod mul;\n/// Negation of an [`Integer`](super::Integer).\npub mod neg;\n/// Implementations of [`Parity`](malachite_base::num::arithmetic::traits::Parity), a trait for\n/// determining whether a number is even or odd.\npub mod parity;\n/// Implementations of [`Pow`](malachite_base::num::arithmetic::traits::Pow) and\n/// [`PowAssign`](malachite_base::num::arithmetic::traits::PowAssign), traits for raising a number\n/// to a power.\npub mod pow;\n/// Implementations of [`PowerOf2`](malachite_base::num::arithmetic::traits::PowerOf2), a trait for\n/// computing a power of 2.\npub mod power_of_2;\n/// Implementations of traits for taking the $n$th root of a number.\n///\n/// The traits are [`FloorRoot`](malachite_base::num::arithmetic::traits::FloorRoot),\n/// [`FloorRootAssign`](malachite_base::num::arithmetic::traits::FloorRootAssign),\n/// [`CeilingRoot`](malachite_base::num::arithmetic::traits::CeilingRoot),\n/// [`CeilingRootAssign`](malachite_base::num::arithmetic::traits::CeilingRootAssign), and\n/// [`CheckedRoot`](malachite_base::num::arithmetic::traits::CheckedRoot).\npub mod root;\n/// Implementations of [`RoundToMultiple`](malachite_base::num::arithmetic::traits::RoundToMultiple)\n/// and [`RoundToMultipleAssign`](malachite_base::num::arithmetic::traits::RoundToMultipleAssign),\n/// traits for rounding a number to a multiple of another number.\npub mod round_to_multiple;\n/// Implementations of\n/// [`RoundToMultipleOfPowerOf2`](malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2)\n/// and\n/// [`RoundToMultipleOfPowerOf2Assign`](malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign),\n/// traits for rounding a number to a multiple of a power of 2.\npub mod round_to_multiple_of_power_of_2;\n/// Left-shifting an [`Integer`](super::Integer) (multiplying it by a power of 2).\n///\n/// # shl\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(Integer::ZERO << 10u8, 0);\n/// assert_eq!(Integer::from(123) << 2u16, 492);\n/// assert_eq!(\n///     (Integer::from(123) << 100u32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!(Integer::from(-123) << 2u64, -492);\n/// assert_eq!(\n///     (Integer::from(-123) << 100u8).to_string(),\n///     \"-155921023828072216384094494261248\"\n/// );\n/// assert_eq!(&Integer::ZERO << 10u8, 0);\n/// assert_eq!(&Integer::from(123) << 2u16, 492);\n/// assert_eq!(\n///     (&Integer::from(123) << 100u32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!(&Integer::from(-123) << 2u64, -492);\n/// assert_eq!(\n///     (&Integer::from(-123) << 100u8).to_string(),\n///     \"-155921023828072216384094494261248\"\n/// );\n///\n/// assert_eq!(Integer::ZERO << 10i8, 0);\n/// assert_eq!(Integer::from(123) << 2i16, 492);\n/// assert_eq!(\n///     (Integer::from(123) << 100i32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!(Integer::from(-123) << 2i64, -492);\n/// assert_eq!(\n///     (Integer::from(-123) << 100i8).to_string(),\n///     \"-155921023828072216384094494261248\"\n/// );\n/// assert_eq!(Integer::ZERO << -10i16, 0);\n/// assert_eq!(Integer::from(492) << -2i32, 123);\n/// assert_eq!(-Integer::from(10u32).pow(12) << -10i64, -976562500);\n/// assert_eq!(&Integer::ZERO << 10i8, 0);\n/// assert_eq!(&Integer::from(123) << 2i16, 492);\n/// assert_eq!(\n///     (&Integer::from(123) << 100i32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!(&Integer::from(-123) << 2i64, -492);\n/// assert_eq!(\n///     (&Integer::from(-123) << 100i8).to_string(),\n///     \"-155921023828072216384094494261248\"\n/// );\n/// assert_eq!(&Integer::ZERO << -10i16, 0);\n/// assert_eq!(&Integer::from(492) << -2i32, 123);\n/// assert_eq!(&(-Integer::from(10u32).pow(12)) << -10i64, -976562500);\n/// ```\n///\n/// # shl_assign\n/// ```\n/// use malachite_base::num::basic::traits::{NegativeOne, One};\n/// use malachite_nz::integer::Integer;\n///\n/// let mut x = Integer::ONE;\n/// x <<= 1u8;\n/// x <<= 2u16;\n/// x <<= 3u32;\n/// x <<= 4u64;\n/// assert_eq!(x, 1024);\n/// let mut x = Integer::NEGATIVE_ONE;\n/// x <<= 1u8;\n/// x <<= 2u16;\n/// x <<= 3u32;\n/// x <<= 4u64;\n/// assert_eq!(x, -1024);\n///\n/// let mut x = Integer::ONE;\n/// x <<= 1i8;\n/// x <<= 2i16;\n/// x <<= 3i32;\n/// x <<= 4i64;\n/// assert_eq!(x, 1024);\n/// let mut x = Integer::NEGATIVE_ONE;\n/// x <<= 1i8;\n/// x <<= 2i16;\n/// x <<= 3i32;\n/// x <<= 4i64;\n/// assert_eq!(x, -1024);\n///\n/// let mut x = Integer::from(1024);\n/// x <<= -1i8;\n/// x <<= -2i16;\n/// x <<= -3i32;\n/// x <<= -4i64;\n/// assert_eq!(x, 1);\n/// ```\npub mod shl;\n/// Implementations of [`ShlRound`](malachite_base::num::arithmetic::traits::ShlRound) and\n/// [`ShlRoundAssign`](malachite_base::num::arithmetic::traits::ShlRoundAssign), traits for\n/// multiplying a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode).\n///\n/// # shl_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShlRound;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     Integer::from(0x101).shl_round(-8i8, Down).to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(0x101).shl_round(-8i16, Up).to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::from(-0x101)\n///         .shl_round(-9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x101).shl_round(-9i64, Up).to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x101)\n///         .shl_round(-9i8, Nearest)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0xff)\n///         .shl_round(-9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x100)\n///         .shl_round(-9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::from(0x100)\n///         .shl_round(-8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::ZERO.shl_round(10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::from(123u32)\n///         .shl_round(2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::from(123u32)\n///         .shl_round(100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(0x101))\n///         .shl_round(-8i8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(0x101))\n///         .shl_round(-8i16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shl_round(-9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shl_round(-9i64, Up)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shl_round(-9i8, Nearest)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0xff))\n///         .shl_round(-9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x100))\n///         .shl_round(-9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(0x100))\n///         .shl_round(-8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::ZERO).shl_round(10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(123u32))\n///         .shl_round(2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(123u32))\n///         .shl_round(100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n/// ```\n///\n/// # shl_round_assign\n/// ```\n/// use core::cmp::Ordering::*;\n/// use malachite_base::num::arithmetic::traits::ShlRoundAssign;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_nz::integer::Integer;\n///\n/// let mut n = Integer::from(0x101);\n/// assert_eq!(n.shl_round_assign(-8i8, Down), Less);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Integer::from(0x101);\n/// assert_eq!(n.shl_round_assign(-8i16, Up), Greater);\n/// assert_eq!(n, 2);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shl_round_assign(-9i32, Down), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shl_round_assign(-9i64, Up), Less);\n/// assert_eq!(n, -1);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shl_round_assign(-9i8, Nearest), Less);\n/// assert_eq!(n, -1);\n///\n/// let mut n = Integer::from(-0xff);\n/// assert_eq!(n.shl_round_assign(-9i16, Nearest), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(-0x100);\n/// assert_eq!(n.shl_round_assign(-9i32, Nearest), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(0x100);\n/// assert_eq!(n.shl_round_assign(-8i64, Exact), Equal);\n/// assert_eq!(n, 1);\n///\n/// let mut x = Integer::ONE;\n/// assert_eq!(x.shl_round_assign(1i8, Exact), Equal);\n/// assert_eq!(x.shl_round_assign(2i16, Exact), Equal);\n/// assert_eq!(x.shl_round_assign(3i32, Exact), Equal);\n/// assert_eq!(x.shl_round_assign(4i64, Exact), Equal);\n/// assert_eq!(x, 1024);\n/// ```\npub mod shl_round;\n/// Right-shifting an [`Integer`](super::Integer) (dividing it by a power of 2).\n///\n/// # shr\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(Integer::ZERO >> 10u8, 0);\n/// assert_eq!(Integer::from(492) >> 2u16, 123);\n/// assert_eq!(-Integer::from(10u32).pow(12) >> 10u32, -976562500);\n/// assert_eq!(&Integer::ZERO >> 10u8, 0);\n/// assert_eq!(&Integer::from(492) >> 2u16, 123);\n/// assert_eq!(&-Integer::from(10u32).pow(12) >> 10u32, -976562500);\n///\n/// assert_eq!(Integer::ZERO >> 10i8, 0);\n/// assert_eq!(Integer::from(492) >> 2i16, 123);\n/// assert_eq!(-Integer::from(10u32).pow(12) >> 10i64, -976562500);\n/// assert_eq!(Integer::ZERO >> -10i8, 0);\n/// assert_eq!(Integer::from(123) >> -2i16, 492);\n/// assert_eq!(\n///     (Integer::from(123) >> -100i32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!(Integer::from(-123) >> -2i64, -492);\n/// assert_eq!(\n///     (Integer::from(-123) >> -100i8).to_string(),\n///     \"-155921023828072216384094494261248\"\n/// );\n/// assert_eq!(&Integer::ZERO >> 10i8, 0);\n/// assert_eq!(&Integer::from(492) >> 2i16, 123);\n/// assert_eq!(&-Integer::from(10u32).pow(12) >> 10i64, -976562500);\n/// assert_eq!(&Integer::ZERO >> -10i8, 0);\n/// assert_eq!(&Integer::from(123) >> -2i16, 492);\n/// assert_eq!(\n///     (&Integer::from(123) >> -100i32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!(&Integer::from(-123) >> -2i64, -492);\n/// assert_eq!(\n///     (&Integer::from(-123) >> -100i8).to_string(),\n///     \"-155921023828072216384094494261248\"\n/// );\n/// ```\n///\n/// # shr_assign\n/// ```\n/// use malachite_base::num::basic::traits::{NegativeOne, One};\n/// use malachite_nz::integer::Integer;\n///\n/// let mut x = Integer::from(1024);\n/// x >>= 1u8;\n/// x >>= 2u16;\n/// x >>= 3u32;\n/// x >>= 4u64;\n/// assert_eq!(x, 1);\n///\n/// let mut x = Integer::from(1024);\n/// x >>= 1i8;\n/// x >>= 2i16;\n/// x >>= 3i32;\n/// x >>= 4i64;\n/// assert_eq!(x, 1);\n///\n/// let mut x = Integer::ONE;\n/// x >>= -1i8;\n/// x >>= -2i16;\n/// x >>= -3i32;\n/// x >>= -4i64;\n/// assert_eq!(x, 1024);\n///\n/// let mut x = Integer::NEGATIVE_ONE;\n/// x >>= -1i8;\n/// x >>= -2i16;\n/// x >>= -3i32;\n/// x >>= -4i64;\n/// assert_eq!(x, -1024);\n/// ```\npub mod shr;\n/// Implementations of [`ShrRound`](malachite_base::num::arithmetic::traits::ShrRound) and\n/// [`ShrRoundAssign`](malachite_base::num::arithmetic::traits::ShrRoundAssign), traits for dividing\n/// a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode).\n///\n/// # shr_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShrRound;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     Integer::from(0x101).shr_round(8u8, Down).to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(0x101).shr_round(8u16, Up).to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::from(-0x101)\n///         .shr_round(9u32, Down)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x101).shr_round(9u64, Up).to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x101)\n///         .shr_round(9u8, Nearest)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0xff)\n///         .shr_round(9u16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x100)\n///         .shr_round(9u64, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::from(0x100u32)\n///         .shr_round(8u32, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(0x101))\n///         .shr_round(8u8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(0x101))\n///         .shr_round(8u16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shr_round(9u32, Down)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shr_round(9u64, Up)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shr_round(9u8, Nearest)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0xff))\n///         .shr_round(9u16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x100))\n///         .shr_round(9u64, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(0x100u32))\n///         .shr_round(8u32, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::from(0x101u32)\n///         .shr_round(8i8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(0x101u32)\n///         .shr_round(8i16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::from(-0x101)\n///         .shr_round(9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x101).shr_round(9i64, Up).to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x101)\n///         .shr_round(9i8, Nearest)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0xff)\n///         .shr_round(9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::from(-0x100)\n///         .shr_round(9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::from(0x100u32)\n///         .shr_round(8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     Integer::ZERO.shr_round(-10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::from(123u32)\n///         .shr_round(-2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::from(123u32)\n///         .shr_round(-100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(0x101u32))\n///         .shr_round(8i8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(0x101u32))\n///         .shr_round(8i16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shr_round(9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shr_round(9i64, Up)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x101))\n///         .shr_round(9i8, Nearest)\n///         .to_debug_string(),\n///     \"(-1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0xff))\n///         .shr_round(9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(-0x100))\n///         .shr_round(9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::from(0x100u32))\n///         .shr_round(8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     (&Integer::ZERO).shr_round(-10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(123u32))\n///         .shr_round(-2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Integer::from(123u32))\n///         .shr_round(-100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n/// ```\n///\n/// # shr_round_assign\n/// ```\n/// use core::cmp::Ordering::*;\n/// use malachite_base::num::arithmetic::traits::ShrRoundAssign;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_nz::integer::Integer;\n///\n/// let mut n = Integer::from(0x101);\n/// assert_eq!(n.shr_round_assign(8u8, Down), Less);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Integer::from(0x101);\n/// assert_eq!(n.shr_round_assign(8u16, Up), Greater);\n/// assert_eq!(n, 2);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shr_round_assign(9u32, Down), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shr_round_assign(9u64, Up), Less);\n/// assert_eq!(n, -1);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shr_round_assign(9u8, Nearest), Less);\n/// assert_eq!(n, -1);\n///\n/// let mut n = Integer::from(-0xff);\n/// assert_eq!(n.shr_round_assign(9u16, Nearest), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(-0x100);\n/// assert_eq!(n.shr_round_assign(9u32, Nearest), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(0x100);\n/// assert_eq!(n.shr_round_assign(8u64, Exact), Equal);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Integer::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(8i8, Down), Less);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Integer::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(8i16, Up), Greater);\n/// assert_eq!(n, 2);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shr_round_assign(9i32, Down), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shr_round_assign(9i64, Up), Less);\n/// assert_eq!(n, -1);\n///\n/// let mut n = Integer::from(-0x101);\n/// assert_eq!(n.shr_round_assign(9i8, Nearest), Less);\n/// assert_eq!(n, -1);\n///\n/// let mut n = Integer::from(-0xff);\n/// assert_eq!(n.shr_round_assign(9i16, Nearest), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(-0x100);\n/// assert_eq!(n.shr_round_assign(9i32, Nearest), Greater);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Integer::from(0x100u32);\n/// assert_eq!(n.shr_round_assign(8i64, Exact), Equal);\n/// assert_eq!(n, 1);\n///\n/// let mut x = Integer::ONE;\n/// assert_eq!(x.shr_round_assign(-1i8, Exact), Equal);\n/// assert_eq!(x.shr_round_assign(-2i16, Exact), Equal);\n/// assert_eq!(x.shr_round_assign(-3i32, Exact), Equal);\n/// assert_eq!(x.shr_round_assign(-4i64, Exact), Equal);\n/// assert_eq!(x, 1024);\n/// ```\npub mod shr_round;\n/// Implementations of [`Sign`](malachite_base::num::arithmetic::traits::Sign), a trait for\n/// determining the sign of a number.\npub mod sign;\n/// Implementations of traits for taking the square root of a number.\n///\n/// The traits are [`FloorSqrt`](malachite_base::num::arithmetic::traits::FloorSqrt),\n/// [`FloorSqrtAssign`](malachite_base::num::arithmetic::traits::FloorSqrtAssign),\n/// [`CeilingSqrt`](malachite_base::num::arithmetic::traits::CeilingSqrt),\n/// [`CeilingSqrtAssign`](malachite_base::num::arithmetic::traits::CeilingSqrtAssign), and\n/// [`CheckedSqrt`](malachite_base::num::arithmetic::traits::CheckedSqrt).\npub mod sqrt;\n/// Implementations of [`Square`](malachite_base::num::arithmetic::traits::Square) and\n/// [`SquareAssign`](malachite_base::num::arithmetic::traits::SquareAssign), traits for squaring a\n/// number.\npub mod square;\n/// Subtraction of [`Integer`](super::Integer)s.\npub mod sub;\n/// Implementations of [`SubMul`](malachite_base::num::arithmetic::traits::SubMul) and\n/// [`SubMulAssign`](malachite_base::num::arithmetic::traits::SubMulAssign), traits for subtracting\n/// the product of two numbers from a number.\npub mod sub_mul;\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::ops::{Rem, RemAssign};\nuse malachite_base::num::arithmetic::traits::{\n    CeilingMod, CeilingModAssign, Mod, ModAssign, NegMod, NegModAssign,\n};\n\nimpl Mod<Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value and returning just the\n    /// remainder. The remainder has the same sign as the second [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23).mod_op(Integer::from(10)), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(Integer::from(23).mod_op(Integer::from(-10)), -7);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(Integer::from(-23).mod_op(Integer::from(10)), 7);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23).mod_op(Integer::from(-10)), -3);\n    /// ```\n    #[inline]\n    fn mod_op(mut self, other: Self) -> Self {\n        self.mod_assign(other);\n        self\n    }\n}\n\nimpl Mod<&Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference and returning just the remainder. The remainder has the same sign as the second\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23).mod_op(&Integer::from(10)), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(Integer::from(23).mod_op(&Integer::from(-10)), -7);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(Integer::from(-23).mod_op(&Integer::from(10)), 7);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23).mod_op(&Integer::from(-10)), -3);\n    /// ```\n    #[inline]\n    fn mod_op(mut self, other: &Self) -> Self {\n        self.mod_assign(other);\n        self\n    }\n}\n\nimpl Mod<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value and returning just the remainder. The remainder has the same sign as the second\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!((&Integer::from(23)).mod_op(Integer::from(10)), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!((&Integer::from(23)).mod_op(Integer::from(-10)), -7);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!((&Integer::from(-23)).mod_op(Integer::from(10)), 7);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!((&Integer::from(-23)).mod_op(Integer::from(-10)), -3);\n    /// ```\n    fn mod_op(self, other: Integer) -> Integer {\n        Integer::from_sign_and_abs(\n            other.sign,\n            if self.sign == other.sign {\n                &self.abs % other.abs\n            } else {\n                (&self.abs).neg_mod(other.abs)\n            },\n        )\n    }\n}\n\nimpl Mod<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference and returning just\n    /// the remainder. The remainder has the same sign as the second [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!((&Integer::from(23)).mod_op(&Integer::from(10)), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!((&Integer::from(23)).mod_op(&Integer::from(-10)), -7);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!((&Integer::from(-23)).mod_op(&Integer::from(10)), 7);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!((&Integer::from(-23)).mod_op(&Integer::from(-10)), -3);\n    /// ```\n    fn mod_op(self, other: &Integer) -> Integer {\n        Integer::from_sign_and_abs(\n            other.sign,\n            if self.sign == other.sign {\n                &self.abs % &other.abs\n            } else {\n                (&self.abs).neg_mod(&other.abs)\n            },\n        )\n    }\n}\n\nimpl ModAssign<Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`], taking the second [`Integer`] by value and\n    /// replacing the first by the remainder. The remainder has the same sign as the second\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x.mod_assign(Integer::from(10));\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// x.mod_assign(Integer::from(-10));\n    /// assert_eq!(x, -7);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.mod_assign(Integer::from(10));\n    /// assert_eq!(x, 7);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.mod_assign(Integer::from(-10));\n    /// assert_eq!(x, -3);\n    /// ```\n    fn mod_assign(&mut self, other: Self) {\n        if self.sign == other.sign {\n            self.abs %= other.abs;\n        } else {\n            self.abs.neg_mod_assign(other.abs);\n        };\n        self.sign = other.sign || self.abs == 0;\n    }\n}\n\nimpl ModAssign<&Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`], taking the second [`Integer`] by reference\n    /// and replacing the first by the remainder. The remainder has the same sign as the second\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x.mod_assign(&Integer::from(10));\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// x.mod_assign(&Integer::from(-10));\n    /// assert_eq!(x, -7);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.mod_assign(&Integer::from(10));\n    /// assert_eq!(x, 7);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.mod_assign(&Integer::from(-10));\n    /// assert_eq!(x, -3);\n    /// ```\n    fn mod_assign(&mut self, other: &Self) {\n        if self.sign == other.sign {\n            self.abs %= &other.abs;\n        } else {\n            self.abs.neg_mod_assign(&other.abs);\n        };\n        self.sign = other.sign || self.abs == 0;\n    }\n}\n\nimpl Rem<Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value and returning just the\n    /// remainder. The remainder has the same sign as the first [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23) % Integer::from(10), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(Integer::from(23) % Integer::from(-10), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(Integer::from(-23) % Integer::from(10), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23) % Integer::from(-10), -3);\n    /// ```\n    #[inline]\n    fn rem(mut self, other: Self) -> Self {\n        self %= other;\n        self\n    }\n}\n\nimpl Rem<&Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference and returning just the remainder. The remainder has the same sign as the first\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23) % &Integer::from(10), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(Integer::from(23) % &Integer::from(-10), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(Integer::from(-23) % &Integer::from(10), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23) % &Integer::from(-10), -3);\n    /// ```\n    #[inline]\n    fn rem(mut self, other: &Self) -> Self {\n        self %= other;\n        self\n    }\n}\n\nimpl Rem<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value and returning just the remainder. The remainder has the same sign as the first\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Integer::from(23) % Integer::from(10), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(&Integer::from(23) % Integer::from(-10), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(&Integer::from(-23) % Integer::from(10), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(&Integer::from(-23) % Integer::from(-10), -3);\n    /// ```\n    #[inline]\n    fn rem(self, other: Integer) -> Integer {\n        Integer::from_sign_and_abs(self.sign, &self.abs % other.abs)\n    }\n}\n\nimpl Rem<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference and returning just\n    /// the remainder. The remainder has the same sign as the first [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Integer::from(23) % &Integer::from(10), 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(&Integer::from(23) % &Integer::from(-10), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(&Integer::from(-23) % &Integer::from(10), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(&Integer::from(-23) % &Integer::from(-10), -3);\n    /// ```\n    #[inline]\n    fn rem(self, other: &Integer) -> Integer {\n        Integer::from_sign_and_abs(self.sign, &self.abs % &other.abs)\n    }\n}\n\nimpl RemAssign<Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`], taking the second [`Integer`] by value and\n    /// replacing the first by the remainder. The remainder has the same sign as the first\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x %= Integer::from(10);\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// x %= Integer::from(-10);\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// x %= Integer::from(10);\n    /// assert_eq!(x, -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x %= Integer::from(-10);\n    /// assert_eq!(x, -3);\n    /// ```\n    #[inline]\n    fn rem_assign(&mut self, other: Self) {\n        self.abs %= other.abs;\n        self.sign = self.sign || self.abs == 0;\n    }\n}\n\nimpl RemAssign<&Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`], taking the second [`Integer`] by reference\n    /// and replacing the first by the remainder. The remainder has the same sign as the first\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x %= &Integer::from(10);\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// x %= &Integer::from(-10);\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// x %= &Integer::from(10);\n    /// assert_eq!(x, -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x %= &Integer::from(-10);\n    /// assert_eq!(x, -3);\n    /// ```\n    #[inline]\n    fn rem_assign(&mut self, other: &Self) {\n        self.abs %= &other.abs;\n        self.sign = self.sign || self.abs == 0;\n    }\n}\n\nimpl CeilingMod<Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by value and returning just the\n    /// remainder. The remainder has the opposite sign as the second [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23).ceiling_mod(Integer::from(10)), -7);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(Integer::from(23).ceiling_mod(Integer::from(-10)), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(Integer::from(-23).ceiling_mod(Integer::from(10)), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23).ceiling_mod(Integer::from(-10)), 7);\n    /// ```\n    #[inline]\n    fn ceiling_mod(mut self, other: Self) -> Self {\n        self.ceiling_mod_assign(other);\n        self\n    }\n}\n\nimpl CeilingMod<&Self> for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference and returning just the remainder. The remainder has the opposite sign as the\n    /// second [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Integer::from(23).ceiling_mod(&Integer::from(10)), -7);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!(Integer::from(23).ceiling_mod(&Integer::from(-10)), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!(Integer::from(-23).ceiling_mod(&Integer::from(10)), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!(Integer::from(-23).ceiling_mod(&Integer::from(-10)), 7);\n    /// ```\n    #[inline]\n    fn ceiling_mod(mut self, other: &Self) -> Self {\n        self.ceiling_mod_assign(other);\n        self\n    }\n}\n\nimpl CeilingMod<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking the first by reference and the second\n    /// by value and returning just the remainder. The remainder has the opposite sign as the second\n    /// [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!((&Integer::from(23)).ceiling_mod(Integer::from(10)), -7);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!((&Integer::from(23)).ceiling_mod(Integer::from(-10)), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!((&Integer::from(-23)).ceiling_mod(Integer::from(10)), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!((&Integer::from(-23)).ceiling_mod(Integer::from(-10)), 7);\n    /// ```\n    fn ceiling_mod(self, other: Integer) -> Integer {\n        Integer::from_sign_and_abs(\n            !other.sign,\n            if self.sign == other.sign {\n                (&self.abs).neg_mod(other.abs)\n            } else {\n                &self.abs % other.abs\n            },\n        )\n    }\n}\n\nimpl CeilingMod<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by another [`Integer`], taking both by reference and returning just\n    /// the remainder. The remainder has the opposite sign as the second [`Integer`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!((&Integer::from(23)).ceiling_mod(&Integer::from(10)), -7);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// assert_eq!((&Integer::from(23)).ceiling_mod(&Integer::from(-10)), 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// assert_eq!((&Integer::from(-23)).ceiling_mod(&Integer::from(10)), -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// assert_eq!((&Integer::from(-23)).ceiling_mod(&Integer::from(-10)), 7);\n    /// ```\n    fn ceiling_mod(self, other: &Integer) -> Integer {\n        Integer::from_sign_and_abs(\n            !other.sign,\n            if self.sign == other.sign {\n                (&self.abs).neg_mod(&other.abs)\n            } else {\n                &self.abs % &other.abs\n            },\n        )\n    }\n}\n\nimpl CeilingModAssign<Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`], taking the [`Integer`] on the right-hand side\n    /// by value and replacing the first number by the remainder. The remainder has the opposite\n    /// sign as the second number.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lceil\\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingModAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x.ceiling_mod_assign(Integer::from(10));\n    /// assert_eq!(x, -7);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// x.ceiling_mod_assign(Integer::from(-10));\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.ceiling_mod_assign(Integer::from(10));\n    /// assert_eq!(x, -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.ceiling_mod_assign(Integer::from(-10));\n    /// assert_eq!(x, 7);\n    /// ```\n    fn ceiling_mod_assign(&mut self, other: Self) {\n        if self.sign == other.sign {\n            self.abs.neg_mod_assign(other.abs);\n        } else {\n            self.abs %= other.abs;\n        };\n        self.sign = !other.sign || self.abs == 0;\n    }\n}\n\nimpl CeilingModAssign<&Self> for Integer {\n    /// Divides an [`Integer`] by another [`Integer`], taking the [`Integer`] on the right-hand side\n    /// by reference and replacing the first number by the remainder. The remainder has the opposite\n    /// sign as the second number.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lceil\\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingModAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Integer::from(23);\n    /// x.ceiling_mod_assign(&Integer::from(10));\n    /// assert_eq!(x, -7);\n    ///\n    /// // -3 * -10 + -7 = 23\n    /// let mut x = Integer::from(23);\n    /// x.ceiling_mod_assign(&Integer::from(-10));\n    /// assert_eq!(x, 3);\n    ///\n    /// // -3 * 10 + 7 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.ceiling_mod_assign(&Integer::from(10));\n    /// assert_eq!(x, -3);\n    ///\n    /// // 2 * -10 + -3 = -23\n    /// let mut x = Integer::from(-23);\n    /// x.ceiling_mod_assign(&Integer::from(-10));\n    /// assert_eq!(x, 7);\n    /// ```\n    fn ceiling_mod_assign(&mut self, other: &Self) {\n        if self.sign == other.sign {\n            self.abs.neg_mod_assign(&other.abs);\n        } else {\n            self.abs %= &other.abs;\n        };\n        self.sign = !other.sign || self.abs == 0;\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingModPowerOf2, CeilingModPowerOf2Assign, ModPowerOf2, ModPowerOf2Assign, NegModPowerOf2,\n    NegModPowerOf2Assign, RemPowerOf2, RemPowerOf2Assign,\n};\n\nimpl ModPowerOf2 for Integer {\n    type Output = Natural;\n\n    /// Divides an [`Integer`] by $2^k$, taking it by value and returning just the remainder. The\n    /// remainder is non-negative.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// Unlike\n    /// [`rem_power_of_2`](malachite_base::num::arithmetic::traits::RemPowerOf2::rem_power_of_2),\n    /// this function always returns a non-negative number.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!(Integer::from(260).mod_power_of_2(8), 4);\n    ///\n    /// // -101 * 2^4 + 5 = -1611\n    /// assert_eq!(Integer::from(-1611).mod_power_of_2(4), 5);\n    /// ```\n    fn mod_power_of_2(self, pow: u64) -> Natural {\n        if self.sign {\n            self.abs.mod_power_of_2(pow)\n        } else {\n            self.abs.neg_mod_power_of_2(pow)\n        }\n    }\n}\n\nimpl ModPowerOf2 for &Integer {\n    type Output = Natural;\n\n    /// Divides an [`Integer`] by $2^k$, taking it by reference and returning just the remainder.\n    /// The remainder is non-negative.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// Unlike\n    /// [`rem_power_of_2`](malachite_base::num::arithmetic::traits::RemPowerOf2::rem_power_of_2),\n    /// this function always returns a non-negative number.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!((&Integer::from(260)).mod_power_of_2(8), 4);\n    /// // -101 * 2^4 + 5 = -1611\n    /// assert_eq!((&Integer::from(-1611)).mod_power_of_2(4), 5);\n    /// ```\n    fn mod_power_of_2(self, pow: u64) -> Natural {\n        if self.sign {\n            (&self.abs).mod_power_of_2(pow)\n        } else {\n            (&self.abs).neg_mod_power_of_2(pow)\n        }\n    }\n}\n\nimpl ModPowerOf2Assign for Integer {\n    /// Divides an [`Integer`] by $2^k$, replacing the [`Integer`] by the remainder. The remainder\n    /// is non-negative.\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = q2^k + r$ and $0\n    /// \\leq r < 2^k$.\n    ///\n    /// $$\n    /// x \\gets x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// Unlike [`rem_power_of_2_assign`](RemPowerOf2Assign::rem_power_of_2_assign), this function\n    /// always assigns a non-negative number.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Assign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// let mut x = Integer::from(260);\n    /// x.mod_power_of_2_assign(8);\n    /// assert_eq!(x, 4);\n    ///\n    /// // -101 * 2^4 + 5 = -1611\n    /// let mut x = Integer::from(-1611);\n    /// x.mod_power_of_2_assign(4);\n    /// assert_eq!(x, 5);\n    /// ```\n    fn mod_power_of_2_assign(&mut self, pow: u64) {\n        if self.sign {\n            self.abs.mod_power_of_2_assign(pow);\n        } else {\n            self.sign = true;\n            self.abs.neg_mod_power_of_2_assign(pow);\n        }\n    }\n}\n\nimpl RemPowerOf2 for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by $2^k$, taking it by value and returning just the remainder. The\n    /// remainder has the same sign as the first number.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq |r| < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = x - 2^k\\operatorname{sgn}(x)\\left \\lfloor \\frac{|x|}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// Unlike\n    /// [`mod_power_of_2`](malachite_base::num::arithmetic::traits::ModPowerOf2::mod_power_of_2),\n    /// this function always returns zero or a number with the same sign as `self`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RemPowerOf2;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!(Integer::from(260).rem_power_of_2(8), 4);\n    ///\n    /// // -100 * 2^4 + -11 = -1611\n    /// assert_eq!(Integer::from(-1611).rem_power_of_2(4), -11);\n    /// ```\n    fn rem_power_of_2(self, pow: u64) -> Self {\n        let abs_rem = self.abs.mod_power_of_2(pow);\n        Self {\n            sign: self.sign || abs_rem == 0,\n            abs: abs_rem,\n        }\n    }\n}\n\nimpl RemPowerOf2 for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by $2^k$, taking it by reference and returning just the remainder.\n    /// The remainder has the same sign as the first number.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq |r| < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = x - 2^k\\operatorname{sgn}(x)\\left \\lfloor \\frac{|x|}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// Unlike\n    /// [`mod_power_of_2`](malachite_base::num::arithmetic::traits::ModPowerOf2::mod_power_of_2),\n    /// this function always returns zero or a number with the same sign as `self`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RemPowerOf2;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!((&Integer::from(260)).rem_power_of_2(8), 4);\n    /// // -100 * 2^4 + -11 = -1611\n    /// assert_eq!((&Integer::from(-1611)).rem_power_of_2(4), -11);\n    /// ```\n    fn rem_power_of_2(self, pow: u64) -> Integer {\n        let abs_rem = (&self.abs).mod_power_of_2(pow);\n        Integer {\n            sign: self.sign || abs_rem == 0,\n            abs: abs_rem,\n        }\n    }\n}\n\nimpl RemPowerOf2Assign for Integer {\n    /// Divides an [`Integer`] by $2^k$, replacing the [`Integer`] by the remainder. The remainder\n    /// has the same sign as the [`Integer`].\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = q2^k + r$ and $0\n    /// \\leq r < 2^k$.\n    ///\n    /// $$\n    /// x \\gets x - 2^k\\operatorname{sgn}(x)\\left \\lfloor \\frac{|x|}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// Unlike [`mod_power_of_2_assign`](ModPowerOf2Assign::mod_power_of_2_assign), this function\n    /// does never changes the sign of `self`, except possibly to set `self` to 0.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RemPowerOf2Assign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// let mut x = Integer::from(260);\n    /// x.rem_power_of_2_assign(8);\n    /// assert_eq!(x, 4);\n    ///\n    /// // -100 * 2^4 + -11 = -1611\n    /// let mut x = Integer::from(-1611);\n    /// x.rem_power_of_2_assign(4);\n    /// assert_eq!(x, -11);\n    /// ```\n    fn rem_power_of_2_assign(&mut self, pow: u64) {\n        self.abs.mod_power_of_2_assign(pow);\n        if self.abs == 0 {\n            self.sign = true;\n        }\n    }\n}\n\nimpl CeilingModPowerOf2 for Integer {\n    type Output = Self;\n\n    /// Divides an [`Integer`] by $2^k$, taking it by value and returning just the remainder. The\n    /// remainder is non-positive.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq -r < 2^k$.\n    ///\n    /// $$\n    /// f(x, y) =  x - 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingModPowerOf2;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 2^8 + -252 = 260\n    /// assert_eq!(Integer::from(260).ceiling_mod_power_of_2(8), -252);\n    ///\n    /// // -100 * 2^4 + -11 = -1611\n    /// assert_eq!(Integer::from(-1611).ceiling_mod_power_of_2(4), -11);\n    /// ```\n    fn ceiling_mod_power_of_2(self, pow: u64) -> Self {\n        let abs_mod = if self.sign {\n            self.abs.neg_mod_power_of_2(pow)\n        } else {\n            self.abs.mod_power_of_2(pow)\n        };\n        Self {\n            sign: abs_mod == 0,\n            abs: abs_mod,\n        }\n    }\n}\n\nimpl CeilingModPowerOf2 for &Integer {\n    type Output = Integer;\n\n    /// Divides an [`Integer`] by $2^k$, taking it by reference and returning just the remainder.\n    /// The remainder is non-positive.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq -r < 2^k$.\n    ///\n    /// $$\n    /// f(x, y) =  x - 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingModPowerOf2;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 2^8 + -252 = 260\n    /// assert_eq!((&Integer::from(260)).ceiling_mod_power_of_2(8), -252);\n    /// // -100 * 2^4 + -11 = -1611\n    /// assert_eq!((&Integer::from(-1611)).ceiling_mod_power_of_2(4), -11);\n    /// ```\n    fn ceiling_mod_power_of_2(self, pow: u64) -> Integer {\n        let abs_mod = if self.sign {\n            (&self.abs).neg_mod_power_of_2(pow)\n        } else {\n            (&self.abs).mod_power_of_2(pow)\n        };\n        Integer {\n            sign: abs_mod == 0,\n            abs: abs_mod,\n        }\n    }\n}\n\nimpl CeilingModPowerOf2Assign for Integer {\n    /// Divides an [`Integer`] by $2^k$, replacing the [`Integer`] by the remainder. The remainder\n    /// is non-positive.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq -r < 2^k$.\n    ///\n    /// $$\n    /// x \\gets x - 2^k\\left \\lceil\\frac{x}{2^k} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingModPowerOf2Assign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// // 2 * 2^8 + -252 = 260\n    /// let mut x = Integer::from(260);\n    /// x.ceiling_mod_power_of_2_assign(8);\n    /// assert_eq!(x, -252);\n    ///\n    /// // -100 * 2^4 + -11 = -1611\n    /// let mut x = Integer::from(-1611);\n    /// x.ceiling_mod_power_of_2_assign(4);\n    /// assert_eq!(x, -11);\n    /// ```\n    fn ceiling_mod_power_of_2_assign(&mut self, pow: u64) {\n        if self.sign {\n            self.abs.neg_mod_power_of_2_assign(pow);\n        } else {\n            self.abs.mod_power_of_2_assign(pow);\n        };\n        self.sign = self.abs == 0;\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse alloc::vec::Vec;\nuse core::iter::Product;\nuse core::ops::{Mul, MulAssign};\nuse malachite_base::num::basic::traits::{One, Zero};\n\nimpl Mul<Self> for Integer {\n    type Output = Self;\n\n    /// Multiplies two [`Integer`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ONE * Integer::from(123), 123);\n    /// assert_eq!(Integer::from(123) * Integer::ZERO, 0);\n    /// assert_eq!(Integer::from(123) * Integer::from(-456), -56088);\n    /// assert_eq!(\n    ///     (Integer::from(-123456789000i64) * Integer::from(-987654321000i64)).to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    fn mul(mut self, other: Self) -> Self {\n        self *= other;\n        self\n    }\n}\n\nimpl Mul<&Self> for Integer {\n    type Output = Self;\n\n    /// Multiplies two [`Integer`]s, taking the first by value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ONE * &Integer::from(123), 123);\n    /// assert_eq!(Integer::from(123) * &Integer::ZERO, 0);\n    /// assert_eq!(Integer::from(123) * &Integer::from(-456), -56088);\n    /// assert_eq!(\n    ///     (Integer::from(-123456789000i64) * &Integer::from(-987654321000i64)).to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    fn mul(mut self, other: &Self) -> Self {\n        self *= other;\n        self\n    }\n}\n\nimpl Mul<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Multiplies two [`Integer`]s, taking the first by reference and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::ONE * Integer::from(123), 123);\n    /// assert_eq!(&Integer::from(123) * Integer::ZERO, 0);\n    /// assert_eq!(&Integer::from(123) * Integer::from(-456), -56088);\n    /// assert_eq!(\n    ///     (&Integer::from(-123456789000i64) * Integer::from(-987654321000i64)).to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    fn mul(self, mut other: Integer) -> Integer {\n        other *= self;\n        other\n    }\n}\n\nimpl Mul<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Multiplies two [`Integer`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::ONE * &Integer::from(123), 123);\n    /// assert_eq!(&Integer::from(123) * &Integer::ZERO, 0);\n    /// assert_eq!(&Integer::from(123) * &Integer::from(-456), -56088);\n    /// assert_eq!(\n    ///     (&Integer::from(-123456789000i64) * &Integer::from(-987654321000i64)).to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    fn mul(self, other: &Integer) -> Integer {\n        let product_abs = &self.abs * &other.abs;\n        Integer {\n            sign: self.sign == other.sign || product_abs == 0,\n            abs: product_abs,\n        }\n    }\n}\n\nimpl MulAssign<Self> for Integer {\n    /// Multiplies an [`Integer`] by an [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::NegativeOne;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::NEGATIVE_ONE;\n    /// x *= Integer::from(1000);\n    /// x *= Integer::from(2000);\n    /// x *= Integer::from(3000);\n    /// x *= Integer::from(4000);\n    /// assert_eq!(x, -24000000000000i64);\n    /// ```\n    fn mul_assign(&mut self, other: Self) {\n        self.abs *= other.abs;\n        self.sign = self.sign == other.sign || self.abs == 0;\n    }\n}\n\nimpl MulAssign<&Self> for Integer {\n    /// Multiplies an [`Integer`] by an [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::NegativeOne;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::NEGATIVE_ONE;\n    /// x *= &Integer::from(1000);\n    /// x *= &Integer::from(2000);\n    /// x *= &Integer::from(3000);\n    /// x *= &Integer::from(4000);\n    /// assert_eq!(x, -24000000000000i64);\n    /// ```\n    fn mul_assign(&mut self, other: &Self) {\n        self.abs *= &other.abs;\n        self.sign = self.sign == other.sign || self.abs == 0;\n    }\n}\n\nimpl Product for Integer {\n    /// Multiplies together all the [`Integer`]s in an iterator.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\prod_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Integer::sum(xs.map(Integer::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Product;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::product(\n    ///         vec_from_str::<Integer>(\"[2, -3, 5, 7]\")\n    ///             .unwrap()\n    ///             .into_iter()\n    ///     ),\n    ///     -210\n    /// );\n    /// ```\n    fn product<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate().map(|(i, x)| (i + 1, x)) {\n            if x == 0 {\n                return Self::ZERO;\n            }\n            let mut p = x;\n            for _ in 0..i.trailing_zeros() {\n                p *= stack.pop().unwrap();\n            }\n            stack.push(p);\n        }\n        let mut p = Self::ONE;\n        for x in stack.into_iter().rev() {\n            p *= x;\n        }\n        p\n    }\n}\n\nimpl<'a> Product<&'a Self> for Integer {\n    /// Multiplies together all the [`Integer`]s in an iterator of [`Integer`] references.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\prod_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Integer::sum(xs.map(Integer::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Product;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::product(vec_from_str::<Integer>(\"[2, -3, 5, 7]\").unwrap().iter()),\n    ///     -210\n    /// );\n    /// ```\n    fn product<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = &'a Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate().map(|(i, x)| (i + 1, x)) {\n            if *x == 0 {\n                return Self::ZERO;\n            }\n            let mut p = x.clone();\n            for _ in 0..i.trailing_zeros() {\n                p *= stack.pop().unwrap();\n            }\n            stack.push(p);\n        }\n        let mut p = Self::ONE;\n        for x in stack.into_iter().rev() {\n            p *= x;\n        }\n        p\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::ops::Neg;\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::NotAssign;\n\nimpl Neg for Integer {\n    type Output = Self;\n\n    /// Negates an [`Integer`], taking it by value.\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(-Integer::ZERO, 0);\n    /// assert_eq!(-Integer::from(123), -123);\n    /// assert_eq!(-Integer::from(-123), 123);\n    /// ```\n    fn neg(mut self) -> Self {\n        if self.abs != 0 {\n            self.sign.not_assign();\n        }\n        self\n    }\n}\n\nimpl Neg for &Integer {\n    type Output = Integer;\n\n    /// Negates an [`Integer`], taking it by reference.\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(-&Integer::ZERO, 0);\n    /// assert_eq!(-&Integer::from(123), -123);\n    /// assert_eq!(-&Integer::from(-123), 123);\n    /// ```\n    fn neg(self) -> Integer {\n        if self.abs == 0 {\n            Integer::ZERO\n        } else {\n            Integer {\n                sign: !self.sign,\n                abs: self.abs.clone(),\n            }\n        }\n    }\n}\n\nimpl NegAssign for Integer {\n    /// Negates an [`Integer`] in place.\n    ///\n    /// $$\n    /// x \\gets -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NegAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x.neg_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Integer::from(123);\n    /// x.neg_assign();\n    /// assert_eq!(x, -123);\n    ///\n    /// let mut x = Integer::from(-123);\n    /// x.neg_assign();\n    /// assert_eq!(x, 123);\n    /// ```\n    fn neg_assign(&mut self) {\n        if self.abs != 0 {\n            self.sign.not_assign();\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::Parity;\n\nimpl Parity for &Integer {\n    /// Tests whether an [`Integer`] is even.\n    ///\n    /// $f(x) = (2|x)$.\n    ///\n    /// $f(x) = (\\exists k \\in \\N : x = 2k)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Parity, Pow};\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.even(), true);\n    /// assert_eq!(Integer::from(123).even(), false);\n    /// assert_eq!(Integer::from(-0x80).even(), true);\n    /// assert_eq!(Integer::from(10u32).pow(12).even(), true);\n    /// assert_eq!((-Integer::from(10u32).pow(12) - Integer::ONE).even(), false);\n    /// ```\n    fn even(self) -> bool {\n        self.abs.even()\n    }\n\n    /// Tests whether an [`Integer`] is odd.\n    ///\n    /// $f(x) = (2\\nmid x)$.\n    ///\n    /// $f(x) = (\\exists k \\in \\N : x = 2k+1)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Parity, Pow};\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.odd(), false);\n    /// assert_eq!(Integer::from(123).odd(), true);\n    /// assert_eq!(Integer::from(-0x80).odd(), false);\n    /// assert_eq!(Integer::from(10u32).pow(12).odd(), false);\n    /// assert_eq!((-Integer::from(10u32).pow(12) - Integer::ONE).odd(), true);\n    /// ```\n    fn odd(self) -> bool {\n        self.abs.odd()\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::{Parity, Pow, PowAssign};\n\nimpl Pow<u64> for Integer {\n    type Output = Self;\n\n    /// Raises an [`Integer`] to a power, taking the [`Integer`] by value.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-3).pow(100).to_string(),\n    ///     \"515377520732011331036461129765621272702107522001\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_str(\"-12345678987654321\")\n    ///         .unwrap()\n    ///         .pow(3)\n    ///         .to_string(),\n    ///     \"-1881676411868862234942354805142998028003108518161\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(mut self, exp: u64) -> Self {\n        self.pow_assign(exp);\n        self\n    }\n}\n\nimpl Pow<u64> for &Integer {\n    type Output = Integer;\n\n    /// Raises an [`Integer`] to a power, taking the [`Integer`] by reference.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-3)).pow(100).to_string(),\n    ///     \"515377520732011331036461129765621272702107522001\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from_str(\"-12345678987654321\").unwrap())\n    ///         .pow(3)\n    ///         .to_string(),\n    ///     \"-1881676411868862234942354805142998028003108518161\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(self, exp: u64) -> Integer {\n        Integer {\n            sign: exp.even() || self.sign,\n            abs: (&self.abs).pow(exp),\n        }\n    }\n}\n\nimpl PowAssign<u64> for Integer {\n    /// Raises an [`Integer`] to a power in place.\n    ///\n    /// $x \\gets x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::PowAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(-3);\n    /// x.pow_assign(100);\n    /// assert_eq!(\n    ///     x.to_string(),\n    ///     \"515377520732011331036461129765621272702107522001\"\n    /// );\n    ///\n    /// let mut x = Integer::from_str(\"-12345678987654321\").unwrap();\n    /// x.pow_assign(3);\n    /// assert_eq!(\n    ///     x.to_string(),\n    ///     \"-1881676411868862234942354805142998028003108518161\"\n    /// );\n    /// ```\n    fn pow_assign(&mut self, exp: u64) {\n        self.sign = self.sign || exp.even();\n        self.abs.pow_assign(exp);\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::One;\n\nimpl PowerOf2<u64> for Integer {\n    /// Raises 2 to an integer power.\n    ///\n    /// $f(k) = 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::power_of_2(0), 1);\n    /// assert_eq!(Integer::power_of_2(3), 8);\n    /// assert_eq!(\n    ///     Integer::power_of_2(100).to_string(),\n    ///     \"1267650600228229401496703205376\"\n    /// );\n    /// ```\n    #[inline]\n    fn power_of_2(pow: u64) -> Self {\n        Self::ONE << pow\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::ops::Neg;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingRootAssign, CheckedRoot, FloorRoot, FloorRootAssign, Parity, UnsignedAbs,\n};\n\nimpl FloorRoot<u64> for Integer {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of an [`Integer`], taking the [`Integer`] by value.\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorRoot;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(999).floor_root(3), 9);\n    /// assert_eq!(Integer::from(1000).floor_root(3), 10);\n    /// assert_eq!(Integer::from(1001).floor_root(3), 10);\n    /// assert_eq!(Integer::from(100000000000i64).floor_root(5), 158);\n    /// assert_eq!(Integer::from(-100000000000i64).floor_root(5), -159);\n    /// ```\n    #[inline]\n    fn floor_root(mut self, exp: u64) -> Self {\n        self.floor_root_assign(exp);\n        self\n    }\n}\n\nimpl FloorRoot<u64> for &Integer {\n    type Output = Integer;\n\n    /// Returns the floor of the $n$th root of an [`Integer`], taking the [`Integer`] by reference.\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorRoot;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(999)).floor_root(3), 9);\n    /// assert_eq!((&Integer::from(1000)).floor_root(3), 10);\n    /// assert_eq!((&Integer::from(1001)).floor_root(3), 10);\n    /// assert_eq!((&Integer::from(100000000000i64)).floor_root(5), 158);\n    /// assert_eq!((&Integer::from(-100000000000i64)).floor_root(5), -159);\n    /// ```\n    #[inline]\n    fn floor_root(self, exp: u64) -> Integer {\n        if *self >= 0 {\n            Integer::from(self.unsigned_abs_ref().floor_root(exp))\n        } else if exp.odd() {\n            -self.unsigned_abs_ref().ceiling_root(exp)\n        } else {\n            panic!(\"Cannot take even root of {self}\")\n        }\n    }\n}\n\nimpl FloorRootAssign<u64> for Integer {\n    /// Replaces an [`Integer`] with the floor of its $n$th root.\n    ///\n    /// $x \\gets \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorRootAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(999);\n    /// x.floor_root_assign(3);\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Integer::from(1000);\n    /// x.floor_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(1001);\n    /// x.floor_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(100000000000i64);\n    /// x.floor_root_assign(5);\n    /// assert_eq!(x, 158);\n    ///\n    /// let mut x = Integer::from(-100000000000i64);\n    /// x.floor_root_assign(5);\n    /// assert_eq!(x, -159);\n    /// ```\n    #[inline]\n    fn floor_root_assign(&mut self, exp: u64) {\n        if *self >= 0 {\n            self.mutate_unsigned_abs(|n| n.floor_root_assign(exp));\n        } else if exp.odd() {\n            self.mutate_unsigned_abs(|n| n.ceiling_root_assign(exp));\n        } else {\n            panic!(\"Cannot take even root of {self}\")\n        }\n    }\n}\n\nimpl CeilingRoot<u64> for Integer {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of an [`Integer`], taking the [`Integer`] by value.\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingRoot;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(999).ceiling_root(3), 10);\n    /// assert_eq!(Integer::from(1000).ceiling_root(3), 10);\n    /// assert_eq!(Integer::from(1001).ceiling_root(3), 11);\n    /// assert_eq!(Integer::from(100000000000i64).ceiling_root(5), 159);\n    /// assert_eq!(Integer::from(-100000000000i64).ceiling_root(5), -158);\n    /// ```\n    #[inline]\n    fn ceiling_root(mut self, exp: u64) -> Self {\n        self.ceiling_root_assign(exp);\n        self\n    }\n}\n\nimpl CeilingRoot<u64> for &Integer {\n    type Output = Integer;\n\n    /// Returns the ceiling of the $n$th root of an [`Integer`], taking the [`Integer`] by\n    /// reference.\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingRoot;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(999).ceiling_root(3), 10);\n    /// assert_eq!(Integer::from(1000).ceiling_root(3), 10);\n    /// assert_eq!(Integer::from(1001).ceiling_root(3), 11);\n    /// assert_eq!(Integer::from(100000000000i64).ceiling_root(5), 159);\n    /// assert_eq!(Integer::from(-100000000000i64).ceiling_root(5), -158);\n    /// ```\n    #[inline]\n    fn ceiling_root(self, exp: u64) -> Integer {\n        if *self >= 0 {\n            Integer::from(self.unsigned_abs_ref().ceiling_root(exp))\n        } else if exp.odd() {\n            -self.unsigned_abs_ref().floor_root(exp)\n        } else {\n            panic!(\"Cannot take even root of {self}\")\n        }\n    }\n}\n\nimpl CeilingRootAssign<u64> for Integer {\n    /// Replaces an [`Integer`] with the ceiling of its $n$th root.\n    ///\n    /// $x \\gets \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingRootAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(999);\n    /// x.ceiling_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(1000);\n    /// x.ceiling_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(1001);\n    /// x.ceiling_root_assign(3);\n    /// assert_eq!(x, 11);\n    ///\n    /// let mut x = Integer::from(100000000000i64);\n    /// x.ceiling_root_assign(5);\n    /// assert_eq!(x, 159);\n    ///\n    /// let mut x = Integer::from(-100000000000i64);\n    /// x.ceiling_root_assign(5);\n    /// assert_eq!(x, -158);\n    /// ```\n    #[inline]\n    fn ceiling_root_assign(&mut self, exp: u64) {\n        if *self >= 0 {\n            self.mutate_unsigned_abs(|n| n.ceiling_root_assign(exp));\n        } else if exp.odd() {\n            self.mutate_unsigned_abs(|n| n.floor_root_assign(exp));\n        } else {\n            panic!(\"Cannot take even root of {self}\")\n        }\n    }\n}\n\nimpl CheckedRoot<u64> for Integer {\n    type Output = Self;\n\n    /// Returns the the $n$th root of an [`Integer`], or `None` if the [`Integer`] is not a perfect\n    /// $n$th power. The [`Integer`] is taken by value.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(999).checked_root(3).to_debug_string(), \"None\");\n    /// assert_eq!(\n    ///     Integer::from(1000).checked_root(3).to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(1001).checked_root(3).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(100000000000i64)\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-100000000000i64)\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(10000000000i64)\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"Some(100)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10000000000i64)\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"Some(-100)\"\n    /// );\n    /// ```\n    #[inline]\n    fn checked_root(self, exp: u64) -> Option<Self> {\n        if self >= 0 {\n            self.unsigned_abs().checked_root(exp).map(Self::from)\n        } else if exp.odd() {\n            self.unsigned_abs().checked_root(exp).map(Natural::neg)\n        } else {\n            panic!(\"Cannot take even root of {self}\")\n        }\n    }\n}\n\nimpl CheckedRoot<u64> for &Integer {\n    type Output = Integer;\n\n    /// Returns the the $n$th root of an [`Integer`], or `None` if the [`Integer`] is not a perfect\n    /// $n$th power. The [`Integer`] is taken by reference.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(999)).checked_root(3).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(1000)).checked_root(3).to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(1001)).checked_root(3).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(100000000000i64))\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-100000000000i64))\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(10000000000i64))\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"Some(100)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10000000000i64))\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"Some(-100)\"\n    /// );\n    /// ```\n    #[inline]\n    fn checked_root(self, exp: u64) -> Option<Integer> {\n        if *self >= 0 {\n            self.unsigned_abs_ref().checked_root(exp).map(Integer::from)\n        } else if exp.odd() {\n            self.unsigned_abs_ref().checked_root(exp).map(Natural::neg)\n        } else {\n            panic!(\"Cannot take even root of {self}\")\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::{RoundToMultiple, RoundToMultipleAssign};\nuse malachite_base::rounding_modes::RoundingMode;\n\nimpl RoundToMultiple<Self> for Integer {\n    type Output = Self;\n\n    /// Rounds an [`Integer`] to a multiple of another [`Integer`], according to a specified\n    /// rounding mode. Both [`Integer`]s are taken by value. An [`Ordering`] is also returned,\n    /// indicating whether the returned value is less than, equal to, or greater than the original\n    /// value.\n    ///\n    /// Let $q = \\frac{x}{|y|}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) =  \\operatorname{sgn}(q) |y| \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) |y| \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, y, \\mathrm{Floor}) = |y| \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Ceiling}) = |y| \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-5)\n    ///         .round_to_multiple(Integer::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20)\n    ///         .round_to_multiple(Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14)\n    ///         .round_to_multiple(Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(-4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(-4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(-5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20)\n    ///         .round_to_multiple(Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14)\n    ///         .round_to_multiple(Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple(mut self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultiple<&Self> for Integer {\n    type Output = Self;\n\n    /// Rounds an [`Integer`] to a multiple of another [`Integer`], according to a specified\n    /// rounding mode. The first [`Integer`] is taken by value and the second by reference. An\n    /// [`Ordering`] is also returned, indicating whether the returned value is less than, equal to,\n    /// or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{|y|}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) =  \\operatorname{sgn}(q) |y| \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) |y| \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, y, \\mathrm{Floor}) = |y| \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Ceiling}) = |y| \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-5)\n    ///         .round_to_multiple(&Integer::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20)\n    ///         .round_to_multiple(&Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14)\n    ///         .round_to_multiple(&Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(-4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(-4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(-5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-20)\n    ///         .round_to_multiple(&Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple(&Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-14)\n    ///         .round_to_multiple(&Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple(mut self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultiple<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Rounds an [`Integer`] to a multiple of another [`Integer`], according to a specified\n    /// rounding mode. The first [`Integer`] is taken by reference and the second by value. An\n    /// [`Ordering`] is also returned, indicating whether the returned value is less than, equal to,\n    /// or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{|y|}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) =  \\operatorname{sgn}(q) |y| \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) |y| \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, y, \\mathrm{Floor}) = |y| \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Ceiling}) = |y| \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-5))\n    ///         .round_to_multiple(Integer::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20))\n    ///         .round_to_multiple(Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14))\n    ///         .round_to_multiple(Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(-4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(-4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(-5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20))\n    ///         .round_to_multiple(Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14))\n    ///         .round_to_multiple(Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    /// ```\n    fn round_to_multiple(self, other: Integer, rm: RoundingMode) -> (Integer, Ordering) {\n        let (n, o) = (&self.abs).round_to_multiple(other.abs, if self.sign { rm } else { -rm });\n        (\n            Integer::from_sign_and_abs(self.sign, n),\n            if self.sign { o } else { o.reverse() },\n        )\n    }\n}\n\nimpl RoundToMultiple<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Rounds an [`Integer`] to a multiple of another [`Integer`], according to a specified\n    /// rounding mode. Both [`Integer`]s are taken by reference. An [`Ordering`] is also returned,\n    /// indicating whether the returned value is less than, equal to, or greater than the original\n    /// value.\n    ///\n    /// Let $q = \\frac{x}{|y|}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) =  \\operatorname{sgn}(q) |y| \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = \\operatorname{sgn}(q) |y| \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, y, \\mathrm{Floor}) = |y| \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Ceiling}) = |y| \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-5))\n    ///         .round_to_multiple(&Integer::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20))\n    ///         .round_to_multiple(&Integer::from(3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14))\n    ///         .round_to_multiple(&Integer::from(4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(-4), Down)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(-4), Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(-5), Exact)\n    ///         .to_debug_string(),\n    ///     \"(-10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-9, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-20))\n    ///         .round_to_multiple(&Integer::from(-3), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-21, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple(&Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-14))\n    ///         .round_to_multiple(&Integer::from(-4), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(-16, Less)\"\n    /// );\n    /// ```\n    fn round_to_multiple(self, other: &Integer, rm: RoundingMode) -> (Integer, Ordering) {\n        let (n, o) = (&self.abs).round_to_multiple(&other.abs, if self.sign { rm } else { -rm });\n        (\n            Integer::from_sign_and_abs(self.sign, n),\n            if self.sign { o } else { o.reverse() },\n        )\n    }\n}\n\nimpl RoundToMultipleAssign<Self> for Integer {\n    /// Rounds an [`Integer`] to a multiple of another [`Integer`] in place, according to a\n    /// specified rounding mode. The [`Integer`] on the right-hand side is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the returned value is less than, equal to, or\n    /// greater than the original value.\n    ///\n    /// See the [`RoundToMultiple`] documentation for details.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_assign(other, Exact);`\n    /// - `assert!(x.divisible_by(other));`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(-5);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::ZERO, Down), Greater);\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(4), Down), Greater);\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(4), Up), Less);\n    /// assert_eq!(x, -12);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(5), Exact), Equal);\n    /// assert_eq!(x, -10);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Integer::from(3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -9);\n    ///\n    /// let mut x = Integer::from(-20);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(3), Nearest), Less);\n    /// assert_eq!(x, -21);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Integer::from(4), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-14);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(4), Nearest), Less);\n    /// assert_eq!(x, -16);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(-4), Down), Greater);\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(-4), Up), Less);\n    /// assert_eq!(x, -12);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(-5), Exact), Equal);\n    /// assert_eq!(x, -10);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Integer::from(-3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -9);\n    ///\n    /// let mut x = Integer::from(-20);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(-3), Nearest), Less);\n    /// assert_eq!(x, -21);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Integer::from(-4), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-14);\n    /// assert_eq!(x.round_to_multiple_assign(Integer::from(-4), Nearest), Less);\n    /// assert_eq!(x, -16);\n    /// ```\n    fn round_to_multiple_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        if self.sign {\n            self.abs.round_to_multiple_assign(other.abs, rm)\n        } else {\n            let o = self.abs.round_to_multiple_assign(other.abs, -rm);\n            self.sign = self.abs == 0;\n            o.reverse()\n        }\n    }\n}\n\nimpl RoundToMultipleAssign<&Self> for Integer {\n    /// Rounds an [`Integer`] to a multiple of another [`Integer`] in place, according to a\n    /// specified rounding mode. The [`Integer`] on the right-hand side is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the returned value is less than, equal to, or\n    /// greater than the original value.\n    ///\n    /// See the [`RoundToMultiple`] documentation for details.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_assign(other, Exact);`\n    /// - `assert!(x.divisible_by(other));`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(-5);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::ZERO, Down), Greater);\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::from(4), Down), Greater);\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::from(4), Up), Less);\n    /// assert_eq!(x, -12);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::from(5), Exact), Equal);\n    /// assert_eq!(x, -10);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Integer::from(3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -9);\n    ///\n    /// let mut x = Integer::from(-20);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::from(3), Nearest), Less);\n    /// assert_eq!(x, -21);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Integer::from(4), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-14);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::from(4), Nearest), Less);\n    /// assert_eq!(x, -16);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Integer::from(-4), Down),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::from(-4), Up), Less);\n    /// assert_eq!(x, -12);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(x.round_to_multiple_assign(&Integer::from(-5), Exact), Equal);\n    /// assert_eq!(x, -10);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Integer::from(-3), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -9);\n    ///\n    /// let mut x = Integer::from(-20);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Integer::from(-3), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x, -21);\n    ///\n    /// let mut x = Integer::from(-10);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Integer::from(-4), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, -8);\n    ///\n    /// let mut x = Integer::from(-14);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Integer::from(-4), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x, -16);\n    /// ```\n    fn round_to_multiple_assign(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        if self.sign {\n            self.abs.round_to_multiple_assign(&other.abs, rm)\n        } else {\n            let o = self.abs.round_to_multiple_assign(&other.abs, -rm);\n            self.sign = self.abs == 0;\n            o.reverse()\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::{\n    RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign,\n};\nuse malachite_base::rounding_modes::RoundingMode;\n\nimpl RoundToMultipleOfPowerOf2<u64> for Integer {\n    type Output = Self;\n\n    /// Rounds an [`Integer`] to a multiple of $2^k$ according to a specified rounding mode. The\n    /// [`Integer`] is taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{2^k}$:\n    ///\n    /// $f(x, k, \\mathrm{Down}) = 2^k \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Up}) = 2^k \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, k, \\mathrm{Floor}) = 2^k \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Ceiling}) = 2^k \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n    ///     2^k \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///     q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     2^k \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, k, \\mathrm{Exact}) = 2^k q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_of_power_of_2(pow, Exact)`\n    /// - `{ assert!(x.divisible_by_power_of_2(pow)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10)\n    ///         .round_to_multiple_of_power_of_2(2, Floor)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple_of_power_of_2(2, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(10)\n    ///         .round_to_multiple_of_power_of_2(2, Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-10)\n    ///         .round_to_multiple_of_power_of_2(2, Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(10)\n    ///         .round_to_multiple_of_power_of_2(2, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-12)\n    ///         .round_to_multiple_of_power_of_2(2, Exact)\n    ///         .to_debug_string(),\n    ///     \"(-12, Equal)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple_of_power_of_2(mut self, pow: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_of_power_of_2_assign(pow, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultipleOfPowerOf2<u64> for &Integer {\n    type Output = Integer;\n\n    /// Rounds an [`Integer`] to a multiple of $2^k$ according to a specified rounding mode. The\n    /// [`Integer`] is taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{2^k}$:\n    ///\n    /// $f(x, k, \\mathrm{Down}) = 2^k \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Up}) = 2^k \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, k, \\mathrm{Floor}) = 2^k \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Ceiling}) = 2^k \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n    ///     2^k \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///     q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     2^k \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, k, \\mathrm{Exact}) = 2^k q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_of_power_of_2(pow, Exact)`\n    /// - `{ assert!(x.divisible_by_power_of_2(pow)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(10))\n    ///         .round_to_multiple_of_power_of_2(2, Floor)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple_of_power_of_2(2, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(-8, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(10))\n    ///         .round_to_multiple_of_power_of_2(2, Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-10))\n    ///         .round_to_multiple_of_power_of_2(2, Up)\n    ///         .to_debug_string(),\n    ///     \"(-12, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(10))\n    ///         .round_to_multiple_of_power_of_2(2, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(-12))\n    ///         .round_to_multiple_of_power_of_2(2, Exact)\n    ///         .to_debug_string(),\n    ///     \"(-12, Equal)\"\n    /// );\n    /// ```\n    fn round_to_multiple_of_power_of_2(self, pow: u64, rm: RoundingMode) -> (Integer, Ordering) {\n        if self.sign {\n            let (abs, o) = (&self.abs).round_to_multiple_of_power_of_2(pow, rm);\n            (\n                Integer {\n                    sign: self.sign,\n                    abs,\n                },\n                o,\n            )\n        } else {\n            let (abs, o) = (&self.abs).round_to_multiple_of_power_of_2(pow, -rm);\n            (-abs, o.reverse())\n        }\n    }\n}\n\nimpl RoundToMultipleOfPowerOf2Assign<u64> for Integer {\n    /// Rounds an [`Integer`] to a multiple of $2^k$ in place, according to a specified rounding\n    /// mode. An [`Ordering`] is returned, indicating whether the returned value is less than, equal\n    /// to, or greater than the original value.\n    ///\n    /// See the [`RoundToMultipleOfPowerOf2`] documentation for details.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_of_power_of_2_assign(pow, Exact);`\n    /// - `assert!(x.divisible_by_power_of_2(pow));`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut n = Integer::from(10);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Floor), Less);\n    /// assert_eq!(n, 8);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(\n    ///     n.round_to_multiple_of_power_of_2_assign(2, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(n, -8);\n    ///\n    /// let mut n = Integer::from(10);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Down), Less);\n    /// assert_eq!(n, 8);\n    ///\n    /// let mut n = Integer::from(-10);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Up), Less);\n    /// assert_eq!(n, -12);\n    ///\n    /// let mut n = Integer::from(10);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Nearest), Less);\n    /// assert_eq!(n, 8);\n    ///\n    /// let mut n = Integer::from(-12);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Exact), Equal);\n    /// assert_eq!(n, -12);\n    /// ```\n    fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode) -> Ordering {\n        if self.sign {\n            self.abs.round_to_multiple_of_power_of_2_assign(pow, rm)\n        } else {\n            let o = self.abs.round_to_multiple_of_power_of_2_assign(pow, -rm);\n            if self.abs == 0 {\n                self.sign = true;\n            }\n            o.reverse()\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::traits::Zero;\n\nfn shl_unsigned<T>(x: Integer, bits: T) -> Integer\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Integer {\n        sign: x.sign,\n        abs: x.abs << bits,\n    }\n}\n\nfn shl_unsigned_ref<'a, T>(x: &'a Integer, bits: T) -> Integer\nwhere\n    &'a Natural: Shl<T, Output = Natural>,\n{\n    Integer {\n        sign: x.sign,\n        abs: &x.abs << bits,\n    }\n}\n\nmacro_rules! impl_shl_unsigned {\n    ($t:ident) => {\n        impl Shl<$t> for Integer {\n            type Output = Integer;\n\n            /// Left-shifts an [`Integer`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Integer {\n                shl_unsigned(self, bits)\n            }\n        }\n\n        impl<'a> Shl<$t> for &Integer {\n            type Output = Integer;\n\n            /// Left-shifts an [`Integer`] (multiplies it by a power of 2), taking it by reference.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Integer {\n                shl_unsigned_ref(self, bits)\n            }\n        }\n\n        impl ShlAssign<$t> for Integer {\n            /// Left-shifts an [`Integer`] (multiplies it by a power of 2), in place.\n            ///\n            /// $$\n            /// x \\gets x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl_assign).\n            #[inline]\n            fn shl_assign(&mut self, bits: $t) {\n                self.abs <<= bits;\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_shl_unsigned);\n\nfn shl_signed_ref<'a, U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &'a Integer,\n    bits: S,\n) -> Integer\nwhere\n    &'a Integer: Shl<U, Output = Integer> + Shr<U, Output = Integer>,\n{\n    if bits >= S::ZERO {\n        x << bits.unsigned_abs()\n    } else {\n        x >> bits.unsigned_abs()\n    }\n}\n\nfn shl_assign_signed<U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(x: &mut Integer, bits: S)\nwhere\n    Integer: ShlAssign<U> + ShrAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x <<= bits.unsigned_abs();\n    } else {\n        *x >>= bits.unsigned_abs();\n    }\n}\n\nmacro_rules! impl_shl_signed {\n    ($t:ident) => {\n        impl Shl<$t> for Integer {\n            type Output = Integer;\n\n            /// Left-shifts an [`Integer`] (multiplies it by a power of 2 or divides it by a power\n            /// of 2 and takes the floor), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\lfloor x2^k \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(mut self, bits: $t) -> Integer {\n                self <<= bits;\n                self\n            }\n        }\n\n        impl<'a> Shl<$t> for &Integer {\n            type Output = Integer;\n\n            /// Left-shifts an [`Integer`] (multiplies it by a power of 2 or divides it by a power\n            /// of 2 and takes the floor), taking it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\lfloor x2^k \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Integer {\n                shl_signed_ref(self, bits)\n            }\n        }\n\n        impl ShlAssign<$t> for Integer {\n            /// Left-shifts an [`Integer`] (multiplies it by a power of 2 or divides it by a power\n            /// of 2 and takes the floor), in place.\n            ///\n            /// $$\n            /// x \\gets \\lfloor x2^k \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl_assign).\n            fn shl_assign(&mut self, bits: $t) {\n                shl_assign_signed(self, bits)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_shl_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering::{self, *};\nuse core::ops::{Shl, ShlAssign};\nuse malachite_base::num::arithmetic::traits::{\n    ShlRound, ShlRoundAssign, ShrRound, ShrRoundAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::rounding_modes::RoundingMode;\n\nfn shl_round_signed_ref<'a, U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &'a Integer,\n    bits: S,\n    rm: RoundingMode,\n) -> (Integer, Ordering)\nwhere\n    &'a Integer: Shl<U, Output = Integer> + ShrRound<U, Output = Integer>,\n{\n    if bits >= S::ZERO {\n        (x << bits.unsigned_abs(), Equal)\n    } else {\n        x.shr_round(bits.unsigned_abs(), rm)\n    }\n}\n\nfn shl_round_assign_i<U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &mut Integer,\n    bits: S,\n    rm: RoundingMode,\n) -> Ordering\nwhere\n    Integer: ShlAssign<U> + ShrRoundAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x <<= bits.unsigned_abs();\n        Equal\n    } else {\n        x.shr_round_assign(bits.unsigned_abs(), rm)\n    }\n}\n\nmacro_rules! impl_shl_round_signed {\n    ($t:ident) => {\n        impl ShlRound<$t> for Integer {\n            type Output = Integer;\n\n            /// Left-shifts an [`Integer`] (multiplies or divides it by a power of 2), taking it by\n            /// value, and rounds according to the specified rounding mode. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the exact value. If `bits` is non-negative, then the returned [`Ordering`] is\n            /// always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `bits > 0 || self.divisible_by_power_of_2(bits)`. Rounding might only be\n            /// necessary if `bits` is negative.\n            ///\n            /// Let $q = x2^k$, and let $g$ be the function that just returns the first element of\n            /// the pair, without the [`Ordering`]:\n            ///\n            /// $g(x, k, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $g(x, k, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// g(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is negative and `rm` is `Exact` but `self` is not\n            /// divisible by $2^{-k}$.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round).\n            #[inline]\n            fn shl_round(mut self, bits: $t, rm: RoundingMode) -> (Integer, Ordering) {\n                let o = self.shl_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl<'a> ShlRound<$t> for &Integer {\n            type Output = Integer;\n\n            /// Left-shifts an [`Integer`] (multiplies or divides it by a power of 2), taking it by\n            /// reference, and rounds according to the specified rounding mode. An [`Ordering`] is\n            /// also returned, indicating whether the returned value is less than, equal to, or\n            /// greater than the exact value. If `bits` is non-negative, then the returned\n            /// [`Ordering`] is always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `bits > 0 || self.divisible_by_power_of_2(bits)`. Rounding might only be\n            /// necessary if `bits` is negative.\n            ///\n            /// Let $q = x2^k$, and let $g$ be the function that just returns the first element of\n            /// the pair, without the [`Ordering`]:\n            ///\n            /// $g(x, k, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $g(x, k, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// g(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is negative and `rm` is `Exact` but `self` is not\n            /// divisible by $2^{-k}$.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round).\n            #[inline]\n            fn shl_round(self, bits: $t, rm: RoundingMode) -> (Integer, Ordering) {\n                shl_round_signed_ref(self, bits, rm)\n            }\n        }\n\n        impl ShlRoundAssign<$t> for Integer {\n            /// Left-shifts an [`Integer`] (multiplies or divides it by a power of 2) and rounds\n            /// according to the specified rounding mode, in place. An [`Ordering`] is returned,\n            /// indicating whether the assigned value is less than, equal to, or greater than the\n            /// exact value.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `bits > 0 || self.divisible_by_power_of_2(bits)`. Rounding might only be\n            /// necessary if `bits` is negative.\n            ///\n            /// See the [`ShlRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round_assign).\n            #[inline]\n            fn shl_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shl_round_assign_i(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_shl_round_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::{ShrRound, ShrRoundAssign, UnsignedAbs};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nfn shr_unsigned_ref<'a, T>(x: &'a Integer, bits: T) -> Integer\nwhere\n    &'a Natural: Shr<T, Output = Natural> + ShrRound<T, Output = Natural>,\n{\n    match *x {\n        Integer {\n            sign: true,\n            ref abs,\n        } => Integer {\n            sign: true,\n            abs: abs >> bits,\n        },\n        Integer {\n            sign: false,\n            ref abs,\n        } => {\n            let abs_shifted = abs.shr_round(bits, Ceiling).0;\n            if abs_shifted == 0 {\n                Integer::ZERO\n            } else {\n                Integer {\n                    sign: false,\n                    abs: abs_shifted,\n                }\n            }\n        }\n    }\n}\n\nfn shr_assign_unsigned<T>(x: &mut Integer, bits: T)\nwhere\n    Natural: ShrAssign<T> + ShrRoundAssign<T>,\n{\n    match *x {\n        Integer {\n            sign: true,\n            ref mut abs,\n        } => {\n            *abs >>= bits;\n        }\n        Integer {\n            sign: false,\n            ref mut abs,\n        } => {\n            abs.shr_round_assign(bits, Ceiling);\n            if *abs == 0 {\n                x.sign = true;\n            }\n        }\n    }\n}\n\nmacro_rules! impl_shr_unsigned {\n    ($t:ident) => {\n        impl Shr<$t> for Integer {\n            type Output = Integer;\n\n            /// Right-shifts an [`Integer`] (divides it by a power of 2 and takes the floor), taking\n            /// it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(mut self, bits: $t) -> Integer {\n                self >>= bits;\n                self\n            }\n        }\n\n        impl<'a> Shr<$t> for &Integer {\n            type Output = Integer;\n\n            /// Right-shifts an [`Integer`] (divides it by a power of 2 and takes the floor), taking\n            /// it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Integer {\n                shr_unsigned_ref(self, bits)\n            }\n        }\n\n        impl ShrAssign<$t> for Integer {\n            /// Right-shifts an [`Integer`] (divides it by a power of 2 and takes the floor), in\n            /// place.\n            ///\n            /// $$\n            /// x \\gets \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr_assign).\n            #[inline]\n            fn shr_assign(&mut self, bits: $t) {\n                shr_assign_unsigned(self, bits);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_shr_unsigned);\n\nfn shr_signed_ref<'a, U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &'a Integer,\n    bits: S,\n) -> Integer\nwhere\n    &'a Integer: Shl<U, Output = Integer> + Shr<U, Output = Integer>,\n{\n    if bits >= S::ZERO {\n        x >> bits.unsigned_abs()\n    } else {\n        x << bits.unsigned_abs()\n    }\n}\n\nfn shr_assign_signed<U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(x: &mut Integer, bits: S)\nwhere\n    Integer: ShlAssign<U> + ShrAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x >>= bits.unsigned_abs();\n    } else {\n        *x <<= bits.unsigned_abs();\n    }\n}\n\nmacro_rules! impl_shr_signed {\n    ($t:ident) => {\n        impl Shr<$t> for Integer {\n            type Output = Integer;\n\n            /// Right-shifts an [`Integer`] (divides it by a power of 2 and takes the floor or\n            /// multiplies it by a power of 2), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(mut self, bits: $t) -> Integer {\n                self >>= bits;\n                self\n            }\n        }\n\n        impl<'a> Shr<$t> for &Integer {\n            type Output = Integer;\n\n            /// Right-shifts an [`Integer`] (divides it by a power of 2 and takes the floor or\n            /// multiplies it by a power of 2), taking it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Integer {\n                shr_signed_ref(self, bits)\n            }\n        }\n\n        impl ShrAssign<$t> for Integer {\n            /// Right-shifts an [`Integer`] (divides it by a power of 2 and takes the floor or\n            /// multiplies it by a power of 2), in place.\n            ///\n            /// $$\n            /// x \\gets \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr_assign).\n            #[inline]\n            fn shr_assign(&mut self, bits: $t) {\n                shr_assign_signed(self, bits)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_shr_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse core::ops::{Shl, ShlAssign};\nuse malachite_base::num::arithmetic::traits::{ShrRound, ShrRoundAssign, UnsignedAbs};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::rounding_modes::RoundingMode;\n\nfn shr_round_unsigned_ref_i<'a, T>(x: &'a Integer, bits: T, rm: RoundingMode) -> (Integer, Ordering)\nwhere\n    &'a Natural: ShrRound<T, Output = Natural>,\n{\n    match *x {\n        Integer {\n            sign: true,\n            ref abs,\n        } => {\n            let (s, o) = abs.shr_round(bits, rm);\n            (Integer { sign: true, abs: s }, o)\n        }\n        Integer {\n            sign: false,\n            ref abs,\n        } => {\n            let (abs_shifted, o) = abs.shr_round(bits, -rm);\n            (\n                if abs_shifted == 0 {\n                    Integer::ZERO\n                } else {\n                    Integer {\n                        sign: false,\n                        abs: abs_shifted,\n                    }\n                },\n                o.reverse(),\n            )\n        }\n    }\n}\n\nfn shr_round_assign_unsigned_i<T>(x: &mut Integer, bits: T, rm: RoundingMode) -> Ordering\nwhere\n    Natural: ShrRoundAssign<T>,\n{\n    match *x {\n        Integer {\n            sign: true,\n            ref mut abs,\n        } => abs.shr_round_assign(bits, rm),\n        Integer {\n            sign: false,\n            ref mut abs,\n        } => {\n            let o = abs.shr_round_assign(bits, -rm);\n            if *abs == 0 {\n                x.sign = true;\n            }\n            o.reverse()\n        }\n    }\n}\n\nmacro_rules! impl_shr_round_unsigned {\n    ($t:ident) => {\n        impl ShrRound<$t> for Integer {\n            type Output = Integer;\n\n            /// Shifts an [`Integer`] right (divides it by a power of 2), taking it by value, and\n            /// rounds according to the specified rounding mode. An [`Ordering`] is also returned,\n            /// indicating whether the returned value is less than, equal to, or greater than the\n            /// exact value.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n            ///\n            /// $f(x, k, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if `rm` is `Exact` but `self` is not divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(mut self, bits: $t, rm: RoundingMode) -> (Integer, Ordering) {\n                let o = self.shr_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl<'a> ShrRound<$t> for &Integer {\n            type Output = Integer;\n\n            /// Shifts an [`Integer`] right (divides it by a power of 2), taking it by reference,\n            /// and rounds according to the specified rounding mode. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the exact value.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n            ///\n            /// $f(x, k, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if `rm` is `Exact` but `self` is not divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(self, bits: $t, rm: RoundingMode) -> (Integer, Ordering) {\n                shr_round_unsigned_ref_i(self, bits, rm)\n            }\n        }\n\n        impl ShrRoundAssign<$t> for Integer {\n            /// Shifts a [`Natural`] right (divides it by a power of 2) and rounds according to the\n            /// specified rounding mode, in place. Passing `Floor` is equivalent to using `>>=`. To\n            /// test whether `Exact` can be passed, use `self.divisible_by_power_of_2(bits)`. An\n            /// [`Ordering`] is returned, indicating whether the assigned value is less than, equal\n            /// to, or greater than the exact value.\n            ///\n            /// See the [`ShrRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if `rm` is `Exact` but `self` is not divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round_assign).\n            fn shr_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shr_round_assign_unsigned_i(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_shr_round_unsigned);\n\nfn shr_round_signed_ref_i<'a, U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &'a Integer,\n    bits: S,\n    rm: RoundingMode,\n) -> (Integer, Ordering)\nwhere\n    &'a Integer: Shl<U, Output = Integer> + ShrRound<U, Output = Integer>,\n{\n    if bits >= S::ZERO {\n        x.shr_round(bits.unsigned_abs(), rm)\n    } else {\n        (x << bits.unsigned_abs(), Equal)\n    }\n}\n\nfn shr_round_assign_signed_i<U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &mut Integer,\n    bits: S,\n    rm: RoundingMode,\n) -> Ordering\nwhere\n    Integer: ShlAssign<U> + ShrRoundAssign<U>,\n{\n    if bits >= S::ZERO {\n        x.shr_round_assign(bits.unsigned_abs(), rm)\n    } else {\n        *x <<= bits.unsigned_abs();\n        Equal\n    }\n}\n\nmacro_rules! impl_shr_round_signed {\n    ($t:ident) => {\n        impl ShrRound<$t> for Integer {\n            type Output = Integer;\n\n            /// Shifts an [`Integer`] right (divides or multiplies it by a power of 2), taking it by\n            /// value, and rounds according to the specified rounding mode. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the exact value. If `bits` is negative, then the returned [`Ordering`] is\n            /// always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n            ///\n            /// $f(x, k, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(-bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is positive and `rm` is `Exact` but `self` is not\n            /// divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(mut self, bits: $t, rm: RoundingMode) -> (Integer, Ordering) {\n                let o = self.shr_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl<'a> ShrRound<$t> for &Integer {\n            type Output = Integer;\n\n            /// Shifts an [`Integer`] right (divides or multiplies it by a power of 2), taking it by\n            /// reference, and rounds according to the specified rounding mode. An [`Ordering`] is\n            /// also returned, indicating whether the returned value is less than, equal to, or\n            /// greater than the exact value. If `bits` is negative, then the returned [`Ordering`]\n            /// is always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n            ///\n            /// $f(x, k, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\Z$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(-bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is positive and `rm` is `Exact` but `self` is not\n            /// divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(self, bits: $t, rm: RoundingMode) -> (Integer, Ordering) {\n                shr_round_signed_ref_i(self, bits, rm)\n            }\n        }\n\n        impl ShrRoundAssign<$t> for Integer {\n            /// Shifts an [`Integer`] right (divides or multiplies it by a power of 2) and rounds\n            /// according to the specified rounding mode, in place. An [`Ordering`] is returned,\n            /// indicating whether the assigned value is less than, equal to, or greater than the\n            /// exact value. If `bits` is negative, then the returned [`Ordering`] is always\n            /// `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` is equivalent to using `>>`. To test whether `Exact` can be passed,\n            /// use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// See the [`ShrRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(-bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is positive and `rm` is `Exact` but `self` is not\n            /// divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round_assign).\n            #[inline]\n            fn shr_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shr_round_assign_signed_i(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_shr_round_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\n\nimpl Sign for Integer {\n    /// Compares an [`Integer`] to zero.\n    ///\n    /// Returns `Greater`, `Equal`, or `Less`, depending on whether the [`Integer`] is positive,\n    /// zero, or negative, respectively.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::Sign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.sign(), Equal);\n    /// assert_eq!(Integer::from(123).sign(), Greater);\n    /// assert_eq!(Integer::from(-123).sign(), Less);\n    /// ```\n    fn sign(&self) -> Ordering {\n        if self.sign {\n            if self.abs == 0 { Equal } else { Greater }\n        } else {\n            Less\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingSqrt, CeilingSqrtAssign, CheckedSqrt, FloorSqrt, FloorSqrtAssign, UnsignedAbs,\n};\n\nimpl FloorSqrt for Integer {\n    type Output = Self;\n\n    /// Returns the floor of the square root of an [`Integer`], taking it by value.\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorSqrt;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(99).floor_sqrt(), 9);\n    /// assert_eq!(Integer::from(100).floor_sqrt(), 10);\n    /// assert_eq!(Integer::from(101).floor_sqrt(), 10);\n    /// assert_eq!(Integer::from(1000000000).floor_sqrt(), 31622);\n    /// assert_eq!(Integer::from(10000000000u64).floor_sqrt(), 100000);\n    /// ```\n    #[inline]\n    fn floor_sqrt(mut self) -> Self {\n        self.floor_sqrt_assign();\n        self\n    }\n}\n\nimpl FloorSqrt for &Integer {\n    type Output = Integer;\n\n    /// Returns the floor of the square root of an [`Integer`], taking it by reference.\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorSqrt;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::from(99)).floor_sqrt(), 9);\n    /// assert_eq!((&Integer::from(100)).floor_sqrt(), 10);\n    /// assert_eq!((&Integer::from(101)).floor_sqrt(), 10);\n    /// assert_eq!((&Integer::from(1000000000)).floor_sqrt(), 31622);\n    /// assert_eq!((&Integer::from(10000000000u64)).floor_sqrt(), 100000);\n    /// ```\n    #[inline]\n    fn floor_sqrt(self) -> Integer {\n        if *self >= 0 {\n            Integer::from(self.unsigned_abs_ref().floor_sqrt())\n        } else {\n            panic!(\"Cannot take square root of {self}\")\n        }\n    }\n}\n\nimpl FloorSqrtAssign for Integer {\n    /// Replaces an [`Integer`] with the floor of its square root.\n    ///\n    /// $x \\gets \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorSqrtAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(99);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Integer::from(100);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(101);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(1000000000);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 31622);\n    ///\n    /// let mut x = Integer::from(10000000000u64);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 100000);\n    /// ```\n    #[inline]\n    fn floor_sqrt_assign(&mut self) {\n        if *self >= 0 {\n            self.mutate_unsigned_abs(Natural::floor_sqrt_assign);\n        } else {\n            panic!(\"Cannot take square root of {self}\")\n        }\n    }\n}\n\nimpl CeilingSqrt for Integer {\n    type Output = Self;\n\n    /// Returns the ceiling of the square root of an [`Integer`], taking it by value.\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingSqrt;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(99).ceiling_sqrt(), 10);\n    /// assert_eq!(Integer::from(100).ceiling_sqrt(), 10);\n    /// assert_eq!(Integer::from(101).ceiling_sqrt(), 11);\n    /// assert_eq!(Integer::from(1000000000).ceiling_sqrt(), 31623);\n    /// assert_eq!(Integer::from(10000000000u64).ceiling_sqrt(), 100000);\n    /// ```\n    #[inline]\n    fn ceiling_sqrt(mut self) -> Self {\n        self.ceiling_sqrt_assign();\n        self\n    }\n}\n\nimpl CeilingSqrt for &Integer {\n    type Output = Integer;\n\n    /// Returns the ceiling of the square root of an [`Integer`], taking it by reference.\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingSqrt;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(99).ceiling_sqrt(), 10);\n    /// assert_eq!(Integer::from(100).ceiling_sqrt(), 10);\n    /// assert_eq!(Integer::from(101).ceiling_sqrt(), 11);\n    /// assert_eq!(Integer::from(1000000000).ceiling_sqrt(), 31623);\n    /// assert_eq!(Integer::from(10000000000u64).ceiling_sqrt(), 100000);\n    /// ```\n    #[inline]\n    fn ceiling_sqrt(self) -> Integer {\n        if *self >= 0 {\n            Integer::from(self.unsigned_abs_ref().ceiling_sqrt())\n        } else {\n            panic!(\"Cannot take square root of {self}\")\n        }\n    }\n}\n\nimpl CeilingSqrtAssign for Integer {\n    /// Replaces an [`Integer`] with the ceiling of its square root.\n    ///\n    /// $x \\gets \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingSqrtAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(99u8);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(100);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Integer::from(101);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 11);\n    ///\n    /// let mut x = Integer::from(1000000000);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 31623);\n    ///\n    /// let mut x = Integer::from(10000000000u64);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 100000);\n    /// ```\n    #[inline]\n    fn ceiling_sqrt_assign(&mut self) {\n        if *self >= 0 {\n            self.mutate_unsigned_abs(Natural::ceiling_sqrt_assign);\n        } else {\n            panic!(\"Cannot take square root of {self}\")\n        }\n    }\n}\n\nimpl CheckedSqrt for Integer {\n    type Output = Self;\n\n    /// Returns the the square root of an [`Integer`], or `None` if it is not a perfect square. The\n    /// [`Integer`] is taken by value.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedSqrt;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(99u8).checked_sqrt().to_debug_string(), \"None\");\n    /// assert_eq!(\n    ///     Integer::from(100u8).checked_sqrt().to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(101u8).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(1000000000u32)\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(10000000000u64)\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"Some(100000)\"\n    /// );\n    /// ```\n    #[inline]\n    fn checked_sqrt(self) -> Option<Self> {\n        if self >= 0 {\n            self.unsigned_abs().checked_sqrt().map(Self::from)\n        } else {\n            panic!(\"Cannot take square root of {self}\")\n        }\n    }\n}\n\nimpl CheckedSqrt for &Integer {\n    type Output = Integer;\n\n    /// Returns the the square root of an [`Integer`], or `None` if it is not a perfect square. The\n    /// [`Integer`] is taken by reference.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedSqrt;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(99u8)).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(100u8)).checked_sqrt().to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(101u8)).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(1000000000u32))\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Integer::from(10000000000u64))\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"Some(100000)\"\n    /// );\n    /// ```\n    #[inline]\n    fn checked_sqrt(self) -> Option<Integer> {\n        if *self >= 0 {\n            self.unsigned_abs_ref().checked_sqrt().map(Integer::from)\n        } else {\n            panic!(\"Cannot take square root of {self}\")\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::{Square, SquareAssign};\n\nimpl Square for Integer {\n    type Output = Self;\n\n    /// Squares an [`Integer`], taking it by value.\n    ///\n    /// $$\n    /// f(x) = x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.square(), 0);\n    /// assert_eq!(Integer::from(123).square(), 15129);\n    /// assert_eq!(Integer::from(-123).square(), 15129);\n    /// ```\n    #[inline]\n    fn square(mut self) -> Self {\n        self.square_assign();\n        self\n    }\n}\n\nimpl Square for &Integer {\n    type Output = Integer;\n\n    /// Squares an [`Integer`], taking it by reference.\n    ///\n    /// $$\n    /// f(x) = x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!((&Integer::ZERO).square(), 0);\n    /// assert_eq!((&Integer::from(123)).square(), 15129);\n    /// assert_eq!((&Integer::from(-123)).square(), 15129);\n    /// ```\n    #[inline]\n    fn square(self) -> Integer {\n        Integer {\n            sign: true,\n            abs: (&self.abs).square(),\n        }\n    }\n}\n\nimpl SquareAssign for Integer {\n    /// Squares an [`Integer`] in place.\n    ///\n    /// $$\n    /// x \\gets x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SquareAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x.square_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Integer::from(123);\n    /// x.square_assign();\n    /// assert_eq!(x, 15129);\n    ///\n    /// let mut x = Integer::from(-123);\n    /// x.square_assign();\n    /// assert_eq!(x, 15129);\n    /// ```\n    fn square_assign(&mut self) {\n        self.sign = true;\n        self.abs.square_assign();\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::mem::swap;\nuse core::ops::{Sub, SubAssign};\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::NotAssign;\n\nimpl Sub<Self> for Integer {\n    type Output = Self;\n\n    /// Subtracts an [`Integer`] by another [`Integer`], taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO - Integer::from(123), -123);\n    /// assert_eq!(Integer::from(123) - Integer::ZERO, 123);\n    /// assert_eq!(Integer::from(456) - Integer::from(-123), 579);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) - -Integer::from(10u32).pow(12) * Integer::from(2u32),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn sub(mut self, other: Self) -> Self {\n        self -= other;\n        self\n    }\n}\n\nimpl Sub<&Self> for Integer {\n    type Output = Self;\n\n    /// Subtracts an [`Integer`] by another [`Integer`], taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO - &Integer::from(123), -123);\n    /// assert_eq!(Integer::from(123) - &Integer::ZERO, 123);\n    /// assert_eq!(Integer::from(456) - &Integer::from(-123), 579);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) - &(-Integer::from(10u32).pow(12) * Integer::from(2u32)),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn sub(mut self, other: &Self) -> Self {\n        self -= other;\n        self\n    }\n}\n\nimpl Sub<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Subtracts an [`Integer`] by another [`Integer`], taking the first by reference and the\n    /// second by value.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::ZERO - Integer::from(123), -123);\n    /// assert_eq!(&Integer::from(123) - Integer::ZERO, 123);\n    /// assert_eq!(&Integer::from(456) - Integer::from(-123), 579);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) - -Integer::from(10u32).pow(12) * Integer::from(2u32),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    fn sub(self, mut other: Integer) -> Integer {\n        other -= self;\n        -other\n    }\n}\n\nimpl Sub<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Subtracts an [`Integer`] by another [`Integer`], taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::ZERO - &Integer::from(123), -123);\n    /// assert_eq!(&Integer::from(123) - &Integer::ZERO, 123);\n    /// assert_eq!(&Integer::from(456) - &Integer::from(-123), 579);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) - &(-Integer::from(10u32).pow(12) * Integer::from(2u32)),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    fn sub(self, other: &Integer) -> Integer {\n        match (self, other) {\n            (x, y) if core::ptr::eq(x, y) => Integer::ZERO,\n            (integer_zero!(), y) => -y.clone(),\n            (x, &integer_zero!()) => x.clone(),\n            // e.g. 10 - -5 or -10 - 5; sign of result is sign of self\n            (\n                &Integer {\n                    sign: sx,\n                    abs: ref ax,\n                },\n                &Integer {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) if sx == (!sy && *ay != 0) => Integer {\n                sign: sx,\n                abs: ax + ay,\n            },\n            // e.g. 10 - 5, -10 - -5, or 5 - 5; sign of result is sign of self\n            (\n                &Integer {\n                    sign: sx,\n                    abs: ref ax,\n                },\n                Integer { abs: ay, .. },\n            ) if sx && *ax == *ay || *ax > *ay => Integer {\n                sign: sx,\n                abs: ax - ay,\n            },\n            // e.g. 5 - 10, -5 - -10, or -5 - -5; sign of result is opposite of sign of other\n            (\n                Integer { abs: ax, .. },\n                &Integer {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) => Integer {\n                sign: !sy,\n                abs: ay - ax,\n            },\n        }\n    }\n}\n\nimpl SubAssign<Self> for Integer {\n    /// Subtracts an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x -= -Integer::from(10u32).pow(12);\n    /// x -= Integer::from(10u32).pow(12) * Integer::from(2u32);\n    /// x -= -Integer::from(10u32).pow(12) * Integer::from(3u32);\n    /// x -= Integer::from(10u32).pow(12) * Integer::from(4u32);\n    /// assert_eq!(x, -2000000000000i64);\n    /// ```\n    fn sub_assign(&mut self, mut other: Self) {\n        match (&mut *self, &other) {\n            (_, &integer_zero!()) => {}\n            (&mut integer_zero!(), _) => {\n                *self = other;\n                self.neg_assign();\n            }\n            // e.g. 10 - -5 or -10 - 5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                &Self {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) if sx == (!sy && *ay != 0) => *ax += ay,\n            // e.g. 10 - 5, -10 - -5, or 5 - 5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                Self { abs: ay, .. },\n            ) if sx && *ax == *ay || *ax > *ay => *ax -= ay,\n            // e.g. 5 - 10, -5 - -10, or -5 - -5; sign of self is flipped\n            _ => {\n                swap(self, &mut other);\n                self.abs -= other.abs;\n                self.sign.not_assign();\n            }\n        }\n    }\n}\n\nimpl SubAssign<&Self> for Integer {\n    /// Subtracts an [`Integer`] by another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x -= &(-Integer::from(10u32).pow(12));\n    /// x -= &(Integer::from(10u32).pow(12) * Integer::from(2u32));\n    /// x -= &(-Integer::from(10u32).pow(12) * Integer::from(3u32));\n    /// x -= &(Integer::from(10u32).pow(12) * Integer::from(4u32));\n    /// assert_eq!(x, -2000000000000i64);\n    /// ```\n    fn sub_assign(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (_, &integer_zero!()) => {}\n            (&mut integer_zero!(), y) => *self = -y.clone(),\n            // e.g. 10 - -5 or -10 - 5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                &Self {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) if sx == (!sy && *ay != 0) => *ax += ay,\n            // e.g. 10 - 5, -10 - -5, or 5 - 5; sign of self is unchanged\n            (\n                &mut Self {\n                    sign: sx,\n                    abs: ref mut ax,\n                },\n                Self { abs: ay, .. },\n            ) if sx && *ax == *ay || *ax > *ay => *ax -= ay,\n            (\n                &mut Self {\n                    sign: ref mut sx,\n                    abs: ref mut ax,\n                },\n                &Self {\n                    sign: sy,\n                    abs: ref ay,\n                },\n            ) => {\n                *sx = !sy;\n                *ax = ay - &*ax;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2001, 2004, 2005, 2012 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::mul::limb::{\n    limbs_mul_limb_with_carry_to_out, limbs_slice_mul_limb_with_carry_in_place,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::sub::{\n    limbs_slice_sub_in_place_right, limbs_sub_greater_in_place_left, limbs_sub_limb_in_place,\n    limbs_sub_limb_to_out,\n};\nuse crate::natural::arithmetic::sub_mul::{\n    limbs_sub_mul_limb_same_length_in_place_left, limbs_sub_mul_limb_same_length_in_place_right,\n};\nuse crate::natural::comparison::cmp::limbs_cmp;\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{\n    AddMul, AddMulAssign, NegAssign, SubMul, SubMulAssign, WrappingAddAssign, WrappingSubAssign,\n};\nuse malachite_base::slices::slice_test_zero;\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, calculates x - y * z, returning the\n// limbs of the absolute value and the sign (true means non-negative). `xs` and `ys` should be\n// nonempty and have no trailing zeros, and `z` should be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is negative, and `w` is returned instead of overwriting the first input. `w_sign`\n// is also returned.\npub_crate_test! {limbs_overflowing_sub_mul_limb(\n    xs: &[Limb],\n    ys: &[Limb],\n    z: Limb\n) -> (Vec<Limb>, bool) {\n    let mut result;\n    let sign = if xs.len() >= ys.len() {\n        result = xs.to_vec();\n        limbs_overflowing_sub_mul_limb_greater_in_place_left(&mut result, ys, z)\n    } else {\n        result = ys.to_vec();\n        limbs_overflowing_sub_mul_limb_smaller_in_place_right(xs, &mut result, z)\n    };\n    (result, sign)\n}}\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, calculates x - y * z, writing the\n// limbs of the absolute value to the first (left) slice and returning the sign (true means non-\n// negative). `xs` and `ys` should be nonempty and have no trailing zeros, and `z` should be\n// nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is negative, and `w_sign` is returned.\npub_crate_test! {limbs_overflowing_sub_mul_limb_in_place_left(\n    xs: &mut Vec<Limb>,\n    ys: &[Limb],\n    z: Limb,\n) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len >= ys_len {\n        limbs_overflowing_sub_mul_limb_greater_in_place_left(xs, ys, z)\n    } else {\n        let (ys_lo, ys_hi) = ys.split_at(xs_len);\n        // submul of absolute values\n        let mut borrow = limbs_sub_mul_limb_same_length_in_place_left(xs, ys_lo, z);\n        // ys bigger than xs, so want ys * limb - xs. Submul has given xs - ys * limb, so take twos'\n        // complement and use an limbs_mul_limb_with_carry_to_out for the rest. -(-borrow * b ^ n +\n        // xs - ys * limb) = (borrow - 1) * b ^ n + ~(xs - ys * limb) + 1\n        limbs_not_in_place(xs);\n        if !limbs_slice_add_limb_in_place(xs, 1) {\n            borrow.wrapping_sub_assign(1);\n        }\n        // If borrow - 1 == -1, then hold that -1 for later.\n        // limbs_sub_mul_limb_same_length_in_place_left never returns borrow == Limb::MAX, so that\n        // value always indicates a -1.\n        let negative_one = borrow == Limb::MAX;\n        if negative_one {\n            borrow.wrapping_add_assign(1);\n        }\n        xs.resize(ys_len + 1, 0);\n        let xs_hi = &mut xs[xs_len..];\n        let (xs_hi_last, xs_hi_init) = xs_hi.split_last_mut().unwrap();\n        *xs_hi_last =\n            limbs_mul_limb_with_carry_to_out::<DoubleLimb, Limb>(xs_hi_init, ys_hi, z, borrow);\n        // Apply any -1 from above. The value at xs_hi is non-zero because z != 0 and the high limb\n        // of ys will be non-zero.\n        if negative_one {\n            assert!(!limbs_sub_limb_in_place(xs_hi, 1));\n        }\n        false\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_overflowing_sub_mul_limb_greater_in_place_left(\n    xs: &mut Vec<Limb>,\n    ys: &[Limb],\n    z: Limb,\n) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    xs.push(0);\n    // submul of absolute values\n    let (xs_lo, xs_hi) = xs.split_at_mut(ys_len);\n    let mut borrow = limbs_sub_mul_limb_same_length_in_place_left(xs_lo, ys, z);\n    // If xs bigger than ys, then propagate borrow through it.\n    if xs_len != ys_len {\n        borrow = Limb::from(limbs_sub_limb_in_place(xs_hi, borrow));\n    }\n    if borrow == 0 {\n        true\n    } else {\n        // Borrow out of xs, take twos' complement negative to get absolute value, flip sign of xs.\n        let (xs_last, xs_init) = xs.split_last_mut().unwrap();\n        *xs_last = borrow.wrapping_sub(1);\n        limbs_not_in_place(xs_init);\n        limbs_slice_add_limb_in_place(xs, 1);\n        false\n    }\n}\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, calculates x - y * z, writing the\n// limbs of the absolute value to the second (right) slice and returning the sign (true means non-\n// negative). `xs` and `ys` should be nonempty and have no trailing zeros, and `z` should be\n// nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is negative, the limbs of the result are written to the second input rather than\n// the first, and `w_sign` is returned.\npub_test! {limbs_overflowing_sub_mul_limb_in_place_right(\n    xs: &[Limb],\n    ys: &mut Vec<Limb>,\n    z: Limb,\n) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len >= ys_len {\n        ys.resize(xs_len + 1, 0);\n        // submul of absolute values\n        let (xs_lo, xs_hi) = xs.split_at(ys_len);\n        let (ys_lo, ys_hi) = ys.split_at_mut(ys_len);\n        let mut borrow = limbs_sub_mul_limb_same_length_in_place_right(xs_lo, ys_lo, z);\n        // If xs bigger than ys, then propagate borrow through it.\n        if xs_len != ys_len {\n            borrow = Limb::from(limbs_sub_limb_to_out(ys_hi, xs_hi, borrow));\n        }\n        if borrow == 0 {\n            true\n        } else {\n            // Borrow out of ys, take twos' complement negative to get absolute value, flip sign of\n            // ys.\n            let (ys_last, ys_init) = ys.split_last_mut().unwrap();\n            *ys_last = borrow.wrapping_sub(1);\n            limbs_not_in_place(ys_init);\n            limbs_slice_add_limb_in_place(ys, 1);\n            false\n        }\n    } else {\n        limbs_overflowing_sub_mul_limb_smaller_in_place_right(xs, ys, z)\n    }\n}}\n\n// xs.len() < ys.len()\nfn limbs_overflowing_sub_mul_limb_smaller_in_place_right(\n    xs: &[Limb],\n    ys: &mut Vec<Limb>,\n    z: Limb,\n) -> bool {\n    ys.push(0);\n    let (ys_lo, ys_hi) = ys.split_at_mut(xs.len());\n    // submul of absolute values\n    let mut borrow = limbs_sub_mul_limb_same_length_in_place_right(xs, ys_lo, z);\n    // ys bigger than xs, so want ys * z - xs. Submul has given xs - ys * z, so take twos'\n    // complement and use an limbs_mul_limb_with_carry_to_out for the rest. -(-borrow * b ^ n + xs\n    // - ys * z) = (borrow - 1) * b ^ n + ~(xs - ys * z) + 1\n    limbs_not_in_place(ys_lo);\n    if !limbs_slice_add_limb_in_place(ys_lo, 1) {\n        borrow.wrapping_sub_assign(1);\n    }\n    // If borrow - 1 == -1, then hold that -1 for later.\n    // limbs_sub_mul_limb_same_length_in_place_left never returns borrow == Limb::MAX, so that value\n    // always indicates a -1.\n    let negative_one = borrow == Limb::MAX;\n    if negative_one {\n        borrow.wrapping_add_assign(1);\n    }\n    let (ys_hi_last, ys_hi_init) = ys_hi.split_last_mut().unwrap();\n    *ys_hi_last = limbs_slice_mul_limb_with_carry_in_place(ys_hi_init, z, borrow);\n    if negative_one {\n        assert!(!limbs_sub_limb_in_place(ys_hi, 1));\n    }\n    false\n}\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, calculates x - y * z, writing the\n// limbs of the absolute value to whichever input is longer. The first `bool` returned is `false` if\n// the result is written to the first input, and `true` if it is written to the second. The second\n// `bool` is the sign of the result (true means non-negative). `xs` and `ys` should be nonempty and\n// have no trailing zeros, and `z` should be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is negative, the result is written to the longer input, and `w_sign` is returned.\npub_crate_test! {limbs_overflowing_sub_mul_limb_in_place_either(\n    xs: &mut Vec<Limb>,\n    ys: &mut Vec<Limb>,\n    z: Limb,\n) -> (bool, bool) {\n    if xs.len() >= ys.len() {\n        (\n            false,\n            limbs_overflowing_sub_mul_limb_greater_in_place_left(xs, ys, z),\n        )\n    } else {\n        (\n            true,\n            limbs_overflowing_sub_mul_limb_smaller_in_place_right(xs, ys, z),\n        )\n    }\n}}\n\n// Given the limbs of three `Natural`s x, y, and z, calculates x - y * z, returning the limbs of the\n// absolute value and the sign (true means non-negative). All of the input slices should be\n// non-empty and have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n, m) = O(m + n \\log n \\log\\log n)$\n//\n// $M(n, m) = O(m + n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(ys.len(), zs.len())`, and $m$ is\n// `xs.len()`.\n//\n// # Panics\n// Panics if `ys` or `zs` are empty.\n//\n// This is equivalent to `mpz_aorsmul` from `mpz/aorsmul.c`, GMP 6.2.1, where `w`, `x`, and `y` are\n// positive, `sub` is negative, and `w` is returned instead of overwriting the first input. `w_sign`\n// is also returned.\npub_crate_test! {limbs_overflowing_sub_mul(\n    xs: &[Limb],\n    ys: &[Limb],\n    zs: &[Limb]\n) -> (Vec<Limb>, bool) {\n    let mut xs = xs.to_vec();\n    let sign = limbs_overflowing_sub_mul_in_place_left(&mut xs, ys, zs);\n    (xs, sign)\n}}\n\n// Given the limbs of three `Natural`s x, y, and z, calculates x - y * z, writing the limbs of the\n// absolute value to the first (left) slice and returning the sign (true means non-negative). All of\n// the input slices should be non-empty and have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n, m) = O(m + n \\log n \\log\\log n)$\n//\n// $M(n, m) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(ys.len(), zs.len())`, and $m$ is\n// `xs.len()`.\n//\n// # Panics\n// Panics if `ys` or `zs` are empty.\n//\n// This is equivalent to `mpz_aorsmul` from `mpz/aorsmul.c`, GMP 6.2.1, where `w`, `x`, and `y` are\n// positive, `sub` is negative, and `w_sign` is returned.\npub_crate_test! {limbs_overflowing_sub_mul_in_place_left(\n    xs: &mut Vec<Limb>,\n    ys: &[Limb],\n    zs: &[Limb],\n) -> bool {\n    if ys.len() >= zs.len() {\n        limbs_overflowing_sub_mul_greater_in_place_left(xs, ys, zs)\n    } else {\n        limbs_overflowing_sub_mul_greater_in_place_left(xs, zs, ys)\n    }\n}}\n\n// zs.len() >= ys.len()\nfn limbs_overflowing_sub_mul_greater_in_place_left(\n    xs: &mut Vec<Limb>,\n    ys: &[Limb],\n    zs: &[Limb],\n) -> bool {\n    let xs_len = xs.len();\n    let product_len = ys.len() + zs.len();\n    let mut product = vec![0; product_len];\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ys.len(), zs.len())];\n    if limbs_mul_greater_to_out(&mut product, ys, zs, &mut mul_scratch) == 0 {\n        product.pop();\n    }\n    assert_ne!(*product.last().unwrap(), 0);\n    if limbs_cmp(xs, &product) == Less {\n        if xs_len < product_len {\n            xs.resize(product.len(), 0);\n        }\n        assert!(!limbs_slice_sub_in_place_right(\n            &product,\n            &mut xs[..product.len()],\n            xs_len,\n        ));\n        false\n    } else {\n        assert!(!limbs_sub_greater_in_place_left(xs, &product));\n        !slice_test_zero(xs)\n    }\n}\n\nimpl SubMul<Self, Self> for Integer {\n    type Output = Self;\n\n    /// Subtracts an [`Integer`] by the product of two other [`Integer`]s, taking all three by\n    /// value.\n    ///\n    /// $f(x, y, z) = x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).sub_mul(Integer::from(3u32), Integer::from(-4)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .sub_mul(Integer::from(-0x10000), -Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn sub_mul(mut self, y: Self, z: Self) -> Self {\n        self.sub_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a> SubMul<Self, &'a Self> for Integer {\n    type Output = Self;\n\n    /// Subtracts an [`Integer`] by the product of two other [`Integer`]s, taking the first two by\n    /// value and the third by reference.\n    ///\n    /// $f(x, y, z) = x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).sub_mul(Integer::from(3u32), &Integer::from(-4)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .sub_mul(Integer::from(-0x10000), &-Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn sub_mul(mut self, y: Self, z: &'a Self) -> Self {\n        self.sub_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a> SubMul<&'a Self, Self> for Integer {\n    type Output = Self;\n\n    /// Subtracts an [`Integer`] by the product of two other [`Integer`]s, taking the first and\n    /// third by value and the second by reference.\n    ///\n    /// $f(x, y, z) = x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).sub_mul(&Integer::from(3u32), Integer::from(-4)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .sub_mul(&Integer::from(-0x10000), -Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn sub_mul(mut self, y: &'a Self, z: Self) -> Self {\n        self.sub_mul_assign(y, z);\n        self\n    }\n}\n\nimpl SubMul<&Self, &Self> for Integer {\n    type Output = Self;\n\n    /// Subtracts an [`Integer`] by the product of two other [`Integer`]s, taking the first by value\n    /// and the second and third by reference.\n    ///\n    /// $f(x, y, z) = x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(10u32).sub_mul(&Integer::from(3u32), &Integer::from(-4)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12))\n    ///         .sub_mul(&Integer::from(-0x10000), &-Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    #[inline]\n    fn sub_mul(mut self, y: &Self, z: &Self) -> Self {\n        self.sub_mul_assign(y, z);\n        self\n    }\n}\n\nimpl SubMul<&Integer, &Integer> for &Integer {\n    type Output = Integer;\n\n    /// Subtracts an [`Integer`] by the product of two other [`Integer`]s, taking all three by\n    /// reference.\n    ///\n    /// $f(x, y, z) = x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n, m) = O(m + n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (&Integer::from(10u32)).sub_mul(&Integer::from(3u32), &Integer::from(-4)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (&-Integer::from(10u32).pow(12))\n    ///         .sub_mul(&Integer::from(-0x10000), &-Integer::from(10u32).pow(12)),\n    ///     -65537000000000000i64\n    /// );\n    /// ```\n    fn sub_mul(self, y: &Integer, z: &Integer) -> Integer {\n        if self.sign == (y.sign != z.sign) {\n            Integer {\n                sign: self.sign,\n                abs: (&self.abs).add_mul(&y.abs, &z.abs),\n            }\n        } else {\n            let (abs, abs_result_sign) = self.abs.add_mul_neg(&y.abs, &z.abs);\n            Integer {\n                sign: (self.sign == abs_result_sign) || abs == 0,\n                abs,\n            }\n        }\n    }\n}\n\nimpl SubMulAssign<Self, Self> for Integer {\n    /// Subtracts the product of two other [`Integer`]s from an [`Integer`] in place, taking both\n    /// [`Integer`]s on the right-hand side by value.\n    ///\n    /// $x \\gets x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.sub_mul_assign(Integer::from(3u32), Integer::from(-4));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.sub_mul_assign(Integer::from(-0x10000), -Integer::from(10u32).pow(12));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: Self, z: Self) {\n        self.add_mul_assign(-y, z);\n    }\n}\n\nimpl<'a> SubMulAssign<Self, &'a Self> for Integer {\n    /// Subtracts the product of two other [`Integer`]s from an [`Integer`] in place, taking the\n    /// first [`Integer`] on the right-hand side by value and the second by reference.\n    ///\n    /// $x \\gets x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.sub_mul_assign(Integer::from(3u32), &Integer::from(-4));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.sub_mul_assign(Integer::from(-0x10000), &(-Integer::from(10u32).pow(12)));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: Self, z: &'a Self) {\n        self.add_mul_assign(-y, z);\n    }\n}\n\nimpl<'a> SubMulAssign<&'a Self, Self> for Integer {\n    /// Subtracts the product of two other [`Integer`]s from an [`Integer`] in place, taking the\n    /// first [`Integer`] on the right-hand side by reference and the second by value.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.sub_mul_assign(&Integer::from(3u32), Integer::from(-4));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.sub_mul_assign(&Integer::from(-0x10000), -Integer::from(10u32).pow(12));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: &'a Self, z: Self) {\n        self.add_mul_assign(y, -z);\n    }\n}\n\nimpl<'a, 'b> SubMulAssign<&'a Self, &'b Self> for Integer {\n    /// Subtracts the product of two other [`Integer`]s from an [`Integer`] in place, taking both\n    /// [`Integer`]s on the right-hand side by reference.\n    ///\n    /// $x \\gets x - yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(10u32);\n    /// x.sub_mul_assign(&Integer::from(3u32), &Integer::from(-4));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = -Integer::from(10u32).pow(12);\n    /// x.sub_mul_assign(&Integer::from(-0x10000), &(-Integer::from(10u32).pow(12)));\n    /// assert_eq!(x, -65537000000000000i64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: &'a Self, z: &'b Self) {\n        self.neg_assign();\n        self.add_mul_assign(y, z);\n        self.neg_assign();\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering::{self, *};\n\nimpl PartialOrd for Integer {\n    /// Compares two [`Integer`]s.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp(other))\n    }\n}\n\nimpl Ord for Integer {\n    /// Compares two [`Integer`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::from(-123) < Integer::from(-122));\n    /// assert!(Integer::from(-123) <= Integer::from(-122));\n    /// assert!(Integer::from(-123) > Integer::from(-124));\n    /// assert!(Integer::from(-123) >= Integer::from(-124));\n    /// ```\n    fn cmp(&self, other: &Self) -> Ordering {\n        if core::ptr::eq(self, other) {\n            Equal\n        } else {\n            match (self.sign, other.sign) {\n                (true, false) => Greater,\n                (false, true) => Less,\n                (true, true) => self.abs.cmp(&other.abs),\n                (false, false) => other.abs.cmp(&self.abs),\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\n\nimpl PartialOrdAbs for Integer {\n    /// Compares the absolute values of two [`Integer`]s.\n    ///\n    /// See the documentation for the [`OrdAbs`] implementation.\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp_abs(other))\n    }\n}\n\nimpl OrdAbs for Integer {\n    /// Compares the absolute values of two [`Integer`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::from(-123).lt_abs(&Integer::from(-124)));\n    /// assert!(Integer::from(-123).le_abs(&Integer::from(-124)));\n    /// assert!(Integer::from(-124).gt_abs(&Integer::from(-123)));\n    /// assert!(Integer::from(-124).ge_abs(&Integer::from(-123)));\n    /// ```\n    fn cmp_abs(&self, other: &Self) -> Ordering {\n        self.abs.cmp(&other.abs)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::cmp::Ordering;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\n\nimpl PartialOrdAbs<Natural> for Integer {\n    /// Compares the absolute values of an [`Integer`] and a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Integer::from(123).gt_abs(&Natural::from(122u32)));\n    /// assert!(Integer::from(123).ge_abs(&Natural::from(122u32)));\n    /// assert!(Integer::from(123).lt_abs(&Natural::from(124u32)));\n    /// assert!(Integer::from(123).le_abs(&Natural::from(124u32)));\n    /// assert!(Integer::from(-124).gt_abs(&Natural::from(123u32)));\n    /// assert!(Integer::from(-124).ge_abs(&Natural::from(123u32)));\n    /// ```\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {\n        self.abs.partial_cmp(other)\n    }\n}\n\nimpl PartialOrdAbs<Integer> for Natural {\n    /// Compares the absolute values of a [`Natural`] and an [`Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(123u32).gt_abs(&Integer::from(122)));\n    /// assert!(Natural::from(123u32).ge_abs(&Integer::from(122)));\n    /// assert!(Natural::from(123u32).lt_abs(&Integer::from(124)));\n    /// assert!(Natural::from(123u32).le_abs(&Integer::from(124)));\n    /// assert!(Natural::from(123u32).lt_abs(&Integer::from(-124)));\n    /// assert!(Natural::from(123u32).le_abs(&Integer::from(-124)));\n    /// ```\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Integer) -> Option<Ordering> {\n        self.partial_cmp(&other.abs)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Integer {\n            /// Compares the absolute values of an [`Integer`] and a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::cmp_abs_primitive_float#partial_cmp_abs).\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                self.unsigned_abs().partial_cmp(&other.abs())\n            }\n        }\n\n        impl PartialOrdAbs<Integer> for $t {\n            /// Compares the absolute values of a primitive float and an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// See [here](super::cmp_abs_primitive_float#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Integer) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Integer {\n            /// Compares the absolute values of an [`Integer`] and an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                self.abs.partial_cmp(other)\n            }\n        }\n\n        impl PartialOrdAbs<Integer> for $t {\n            /// Compares the absolute values of an unsigned primitive integer and an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Integer) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Integer {\n            /// Compares the absolute values of an [`Integer`] and a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::cmp_abs_primitive_int#partial_cmp_abs).\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                self.abs.partial_cmp(&other.unsigned_abs())\n            }\n        }\n\n        impl PartialOrdAbs<Integer> for $t {\n            /// Compares the absolute values of a signed primitive integer and an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Integer) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nimpl EqAbs for Integer {\n    /// Determines whether the absolute values of two [`Integer`]s are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(-123).eq_abs(&Integer::from(-122)), false);\n    /// assert_eq!(Integer::from(-123).eq_abs(&Integer::from(-124)), false);\n    /// assert_eq!(Integer::from(123).eq_abs(&Integer::from(123)), true);\n    /// assert_eq!(Integer::from(123).eq_abs(&Integer::from(-123)), true);\n    /// assert_eq!(Integer::from(-123).eq_abs(&Integer::from(123)), true);\n    /// assert_eq!(Integer::from(-123).eq_abs(&Integer::from(-123)), true);\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Self) -> bool {\n        self.abs == other.abs\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nimpl EqAbs<Natural> for Integer {\n    /// Determines whether the absolute values of an [`Integer`] and a [`Natural`] are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Integer::from(-123).eq_abs(&Natural::from(122u32)), false);\n    /// assert_eq!(Integer::from(-123).eq_abs(&Natural::from(124u32)), false);\n    /// assert_eq!(Integer::from(123).eq_abs(&Natural::from(123u32)), true);\n    /// assert_eq!(Integer::from(-123).eq_abs(&Natural::from(123u32)), true);\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Natural) -> bool {\n        self.abs == *other\n    }\n}\n\nimpl EqAbs<Integer> for Natural {\n    /// Determines whether the absolute values of an [`Integer`] and a [`Natural`] are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(122u32).eq_abs(&Integer::from(-123)), false);\n    /// assert_eq!(Natural::from(124u32).eq_abs(&Integer::from(-123)), false);\n    /// assert_eq!(Natural::from(123u32).eq_abs(&Integer::from(123)), true);\n    /// assert_eq!(Natural::from(123u32).eq_abs(&Integer::from(-123)), true);\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Integer) -> bool {\n        *self == other.abs\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nmacro_rules! impl_eq_abs {\n    ($t: ident) => {\n        impl EqAbs<$t> for Integer {\n            /// Determines whether the absolute values of an [`Integer`] and a primitive float are\n            /// equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                *self.unsigned_abs_ref() == other.abs()\n            }\n        }\n\n        impl EqAbs<Integer> for $t {\n            /// Determines whether the absolute values of a primitive float and an [`Integer`] are\n            /// equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Integer) -> bool {\n                self.abs() == *other.unsigned_abs_ref()\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_eq_abs);\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl EqAbs<$t> for Integer {\n            /// Determines whether the absolute values of an [`Integer`] and a primitive unsigned\n            /// integer are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                self.unsigned_abs_ref() == other\n            }\n        }\n\n        impl EqAbs<Integer> for $t {\n            /// Determines whether the absolute values of a primitive unsigned integer and an\n            /// [`Integer`] are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Integer) -> bool {\n                self == other.unsigned_abs_ref()\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl EqAbs<$t> for Integer {\n            /// Determines whether the absolute values of an [`Integer`] and a primitive signed\n            /// integer are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                *self.unsigned_abs_ref() == other.unsigned_abs()\n            }\n        }\n\n        impl EqAbs<Integer> for $t {\n            /// Determines whether the absolute values of a primitive signed integer and an\n            /// [`Integer`] are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Integer) -> bool {\n                self.unsigned_abs() == *other.unsigned_abs_ref()\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Comparison of [`Integer`](crate::integer::Integer)s.\npub mod cmp;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// and [`OrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`) (traits for comparing\n/// the absolute values of numbers by order) for [`Integer`](crate::integer::Integer)s.\npub mod cmp_abs;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Integer`](crate::integer::Integer)s and [`Natural`](crate::natural::Natural)s.\npub mod cmp_abs_natural;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Integer`](crate::integer::Integer)s and primitive floats.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use malachite_nz::integer::Integer;\n///\n/// assert!(Integer::from(-123).gt_abs(&-122.5f32));\n/// assert!(Integer::from(123).lt_abs(&f32::NEGATIVE_INFINITY));\n///\n/// assert!((-122.5f32).lt_abs(&Integer::from(-123)));\n/// assert!(f32::NEGATIVE_INFINITY.gt_abs(&Integer::from(123)));\n/// ```\npub mod cmp_abs_primitive_float;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Integer`](crate::integer::Integer)s and primitive integers.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use malachite_nz::integer::Integer;\n///\n/// assert!(Integer::from(-122).lt_abs(&123u64));\n/// assert!(Integer::from(-122).le_abs(&123u64));\n/// assert!(Integer::from(-123).lt_abs(&124u64));\n/// assert!(Integer::from(-123).le_abs(&124u64));\n/// assert!(Integer::from(10u32).pow(12).gt_abs(&123u64));\n/// assert!(Integer::from(10u32).pow(12).ge_abs(&123u64));\n/// assert!((-Integer::from(10u32).pow(12)).gt_abs(&123u64));\n/// assert!((-Integer::from(10u32).pow(12)).ge_abs(&123u64));\n///\n/// assert!(Integer::from(-122).lt_abs(&-123i64));\n/// assert!(Integer::from(-122).le_abs(&-123i64));\n/// assert!(Integer::from(-124).gt_abs(&-123i64));\n/// assert!(Integer::from(-124).ge_abs(&-123i64));\n/// assert!(Integer::from(10u32).pow(12).gt_abs(&123i64));\n/// assert!(Integer::from(10u32).pow(12).ge_abs(&123i64));\n/// assert!((-Integer::from(10u32).pow(12)).gt_abs(&123i64));\n/// assert!((-Integer::from(10u32).pow(12)).ge_abs(&123i64));\n///\n/// assert!(123u64.gt_abs(&Integer::from(-122)));\n/// assert!(123u64.ge_abs(&Integer::from(-122)));\n/// assert!(124u64.gt_abs(&Integer::from(-123)));\n/// assert!(124u64.ge_abs(&Integer::from(-123)));\n/// assert!(123u64.lt_abs(&Integer::from(10u32).pow(12)));\n/// assert!(123u64.le_abs(&Integer::from(10u32).pow(12)));\n/// assert!(123u64.lt_abs(&-Integer::from(10u32).pow(12)));\n/// assert!(123u64.le_abs(&-Integer::from(10u32).pow(12)));\n///\n/// assert!((-123i64).gt_abs(&Integer::from(-122)));\n/// assert!((-123i64).ge_abs(&Integer::from(-122)));\n/// assert!((-123i64).lt_abs(&Integer::from(-124)));\n/// assert!((-123i64).le_abs(&Integer::from(-124)));\n/// assert!(123i64.lt_abs(&Integer::from(10u32).pow(12)));\n/// assert!(123i64.le_abs(&Integer::from(10u32).pow(12)));\n/// assert!(123i64.lt_abs(&-Integer::from(10u32).pow(12)));\n/// assert!(123i64.le_abs(&-Integer::from(10u32).pow(12)));\n/// ```\npub mod cmp_abs_primitive_int;\n/// Equality of the absolute values of two [`Integer`](crate::integer::Integer)s.\npub mod eq_abs;\n/// Equality of the absolute values of an [`Integer`](crate::integer::Integer) and a\n/// [`Natural`](crate::integer::Natural).\npub mod eq_abs_natural;\n/// Equality of the absolute values of an [`Integer`](crate::integer::Integer) and a primitive\n/// float.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::basic::traits::{NegativeInfinity, Zero};\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(Integer::from(123).eq_abs(&123.0), true);\n/// assert_eq!(Integer::from(123).eq_abs(&5.0), false);\n/// assert_eq!(Integer::from(123).eq_abs(&-123.0), true);\n/// assert_eq!(Integer::from(123).eq_abs(&-5.0), false);\n/// assert_eq!(Integer::from(-123).eq_abs(&123.0), true);\n/// assert_eq!(Integer::from(-123).eq_abs(&5.0), false);\n/// assert_eq!(Integer::from(-123).eq_abs(&-123.0), true);\n/// assert_eq!(Integer::from(-123).eq_abs(&-5.0), false);\n/// assert_eq!(Integer::ZERO.eq_abs(&0.0), true);\n/// assert_eq!(Integer::ZERO.eq_abs(&-0.0), true);\n/// assert_eq!(Integer::ZERO.eq_abs(&f64::NAN), false);\n/// assert_eq!(Integer::ZERO.eq_abs(&f64::INFINITY), false);\n/// assert_eq!(Integer::ZERO.eq_abs(&f64::NEGATIVE_INFINITY), false);\n///\n/// assert_eq!(123.0.eq_abs(&Integer::from(123)), true);\n/// assert_eq!(5.0.eq_abs(&Integer::from(123)), false);\n/// assert_eq!((-123.0).eq_abs(&Integer::from(123)), true);\n/// assert_eq!((-5.0).eq_abs(&Integer::from(123)), false);\n/// assert_eq!(123.0.eq_abs(&Integer::from(-123)), true);\n/// assert_eq!(5.0.eq_abs(&Integer::from(-123)), false);\n/// assert_eq!((-123.0).eq_abs(&Integer::from(-123)), true);\n/// assert_eq!((-5.0).eq_abs(&Integer::from(-123)), false);\n/// assert_eq!(0.0.eq_abs(&Integer::ZERO), true);\n/// assert_eq!((-0.0).eq_abs(&Integer::ZERO), true);\n/// assert_eq!(f64::NAN.eq_abs(&Integer::ZERO), false);\n/// assert_eq!(f64::INFINITY.eq_abs(&Integer::ZERO), false);\n/// assert_eq!(f64::NEGATIVE_INFINITY.eq_abs(&Integer::ZERO), false);\n/// ```\npub mod eq_abs_primitive_float;\n/// Equality of the absolute values of an [`Integer`](crate::integer::Integer) and a primitive\n/// integer.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(Integer::from(123).eq_abs(&123u32), true);\n/// assert_eq!(Integer::from(-123).eq_abs(&123u32), true);\n/// assert_eq!(Integer::from(123).eq_abs(&5u32), false);\n/// assert_eq!(Integer::from(-123).eq_abs(&5u32), false);\n///\n/// assert_eq!(Integer::from(123).eq_abs(&123u64), true);\n/// assert_eq!(Integer::from(-123).eq_abs(&123u64), true);\n/// assert_eq!(Integer::from(123).eq_abs(&5u64), false);\n/// assert_eq!(Integer::from(-123).eq_abs(&5u64), false);\n///\n/// assert_eq!(Integer::from(123).eq_abs(&123i64), true);\n/// assert_eq!(Integer::from(-123).eq_abs(&123i64), true);\n/// assert_eq!(Integer::from(123).eq_abs(&-123i64), true);\n/// assert_eq!(Integer::from(-123).eq_abs(&-123i64), true);\n///\n/// assert_eq!(123u8.eq_abs(&Integer::from(123)), true);\n/// assert_eq!(123u8.eq_abs(&Integer::from(-123)), true);\n/// assert_eq!(5u8.eq_abs(&Integer::from(123)), false);\n/// assert_eq!(5u8.eq_abs(&Integer::from(-123)), false);\n///\n/// assert_eq!(123u64.eq_abs(&Integer::from(123)), true);\n/// assert_eq!(123u64.eq_abs(&Integer::from(-123)), true);\n/// assert_eq!(5u64.eq_abs(&Integer::from(123)), false);\n/// assert_eq!(5u64.eq_abs(&Integer::from(-123)), false);\n///\n/// assert_eq!(123i64.eq_abs(&Integer::from(123)), true);\n/// assert_eq!(123i64.eq_abs(&Integer::from(-123)), true);\n/// assert_eq!((-123i64).eq_abs(&Integer::from(123)), true);\n/// assert_eq!((-123i64).eq_abs(&Integer::from(-123)), true);\n/// ```\npub mod eq_abs_primitive_int;\n/// Comparison of [`Integer`](crate::integer::Integer)s and [`Natural`](crate::natural::Natural)s.\npub mod partial_cmp_natural;\n/// Comparison of [`Integer`](crate::integer::Integer)s and primitive floats.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_nz::integer::Integer;\n///\n/// assert!(Integer::from(-123) < -122.5f32);\n/// assert!(Integer::from(123) < f32::INFINITY);\n/// assert!(-122.5f32 > Integer::from(-123));\n/// assert!(f32::INFINITY > Integer::from(123));\n/// ```\npub mod partial_cmp_primitive_float;\n/// Comparison of [`Integer`](crate::integer::Integer)s and primitive integers.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_nz::integer::Integer;\n///\n/// assert!(Integer::from(-123) < 122u64);\n/// assert!(Integer::from(-123) <= 122u64);\n/// assert!(Integer::from(-123) < 124u64);\n/// assert!(Integer::from(-123) <= 124u64);\n/// assert!(Integer::from(10u32).pow(12) > 123u64);\n/// assert!(Integer::from(10u32).pow(12) >= 123u64);\n/// assert!(-Integer::from(10u32).pow(12) < 123u64);\n/// assert!(-Integer::from(10u32).pow(12) <= 123u64);\n///\n/// assert!(Integer::from(-123) < -122i64);\n/// assert!(Integer::from(-123) <= -122i64);\n/// assert!(Integer::from(-123) > -124i64);\n/// assert!(Integer::from(-123) >= -124i64);\n/// assert!(Integer::from(10u32).pow(12) > 123i64);\n/// assert!(Integer::from(10u32).pow(12) >= 123i64);\n/// assert!(-Integer::from(10u32).pow(12) < 123i64);\n/// assert!(-Integer::from(10u32).pow(12) <= 123i64);\n///\n/// assert!(122u64 > Integer::from(-123));\n/// assert!(122u64 >= Integer::from(-123));\n/// assert!(124u64 > Integer::from(-123));\n/// assert!(124u64 >= Integer::from(-123));\n/// assert!(123u64 < Integer::from(10u32).pow(12));\n/// assert!(123u64 <= Integer::from(10u32).pow(12));\n/// assert!(123u64 > -Integer::from(10u32).pow(12));\n/// assert!(123u64 >= -Integer::from(10u32).pow(12));\n///\n/// assert!(-122i64 > Integer::from(-123));\n/// assert!(-122i64 >= Integer::from(-123));\n/// assert!(-124i64 < Integer::from(-123));\n/// assert!(-124i64 <= Integer::from(-123));\n/// assert!(123i64 < Integer::from(10u32).pow(12));\n/// assert!(123i64 <= Integer::from(10u32).pow(12));\n/// assert!(123i64 > -Integer::from(10u32).pow(12));\n/// assert!(123i64 >= -Integer::from(10u32).pow(12));\n/// ```\npub mod partial_cmp_primitive_int;\n/// Equality of [`Integer`](crate::integer::Integer)s and [`Natural`](crate::natural::Natural)s.\npub mod partial_eq_natural;\n/// Equality of [`Integer`](crate::integer::Integer)s and primitive floats.\n///\n/// # partial_eq\n/// ```\n/// use malachite_nz::integer::Integer;\n///\n/// assert!(Integer::from(123u32) == 123.0f32);\n/// assert!(Integer::from(123u32) != -5.0f32);\n///\n/// assert!(123.0f32 == Integer::from(123u32));\n/// assert!(-5.0f32 != Integer::from(123u32));\n/// ```\npub mod partial_eq_primitive_float;\n/// Equality of [`Integer`](crate::integer::Integer)s and primitive integers.\n///\n/// # partial_eq\n/// ```\n/// use malachite_nz::integer::Integer;\n///\n/// assert!(Integer::from(123) == 123u64);\n/// assert!(Integer::from(-123) != 123u64);\n///\n/// assert!(123u64 == Integer::from(123));\n/// assert!(123u64 != Integer::from(-123));\n///\n/// assert!(123u64 == Integer::from(123));\n/// assert!(123u64 != Integer::from(-123));\n///\n/// assert!(23i64 != Integer::from(123));\n/// assert!(-123i64 == Integer::from(-123));\n/// ```\npub mod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\n\nimpl PartialOrd<Natural> for Integer {\n    /// Compares an [`Integer`] to a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where n = `min(self.significant_bits(), other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Integer::from(123) > Natural::from(122u32));\n    /// assert!(Integer::from(123) >= Natural::from(122u32));\n    /// assert!(Integer::from(123) < Natural::from(124u32));\n    /// assert!(Integer::from(123) <= Natural::from(124u32));\n    /// assert!(Integer::from(-123) < Natural::from(123u32));\n    /// assert!(Integer::from(-123) <= Natural::from(123u32));\n    /// ```\n    fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n        if self.sign {\n            self.abs.partial_cmp(other)\n        } else {\n            Some(Less)\n        }\n    }\n}\n\nimpl PartialOrd<Integer> for Natural {\n    /// Compares a [`Natural`] to an [`Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where n = `min(self.significant_bits(), other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(123u32) > Integer::from(122));\n    /// assert!(Natural::from(123u32) >= Integer::from(122));\n    /// assert!(Natural::from(123u32) < Integer::from(124));\n    /// assert!(Natural::from(123u32) <= Integer::from(124));\n    /// assert!(Natural::from(123u32) > Integer::from(-123));\n    /// assert!(Natural::from(123u32) >= Integer::from(-123));\n    /// ```\n    fn partial_cmp(&self, other: &Integer) -> Option<Ordering> {\n        if other.sign {\n            self.partial_cmp(&other.abs)\n        } else {\n            Some(Greater)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Integer {\n            /// Compares an [`Integer`] to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where n = `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                if self.sign {\n                    self.unsigned_abs().partial_cmp(other)\n                } else {\n                    self.unsigned_abs()\n                        .partial_cmp(&-other)\n                        .map(Ordering::reverse)\n                }\n            }\n        }\n\n        impl PartialOrd<Integer> for $t {\n            /// Compares a primitive float to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where n = `other.significant_bits()`\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Integer) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::traits::Zero;\n\nfn partial_cmp_unsigned<T>(x: &Integer, other: &T) -> Option<Ordering>\nwhere\n    Natural: PartialOrd<T>,\n{\n    if x.sign {\n        x.abs.partial_cmp(other)\n    } else {\n        Some(Less)\n    }\n}\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Integer {\n            /// Compares an [`Integer`] to an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                partial_cmp_unsigned(self, other)\n            }\n        }\n\n        impl PartialOrd<Integer> for $t {\n            /// Compares an unsigned primitive integer to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Integer) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nfn partial_cmp_signed<U: PartialOrd<Natural>, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &Integer,\n    other: &S,\n) -> Option<Ordering>\nwhere\n    Natural: PartialOrd<U>,\n{\n    if x.sign {\n        if *other >= S::ZERO {\n            x.abs.partial_cmp(&other.unsigned_abs())\n        } else {\n            Some(Greater)\n        }\n    } else if *other >= S::ZERO {\n        Some(Less)\n    } else {\n        other.unsigned_abs().partial_cmp(&x.abs)\n    }\n}\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Integer {\n            /// Compares an [`Integer`] to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                partial_cmp_signed(self, other)\n            }\n        }\n\n        impl PartialOrd<Integer> for $t {\n            /// Compares a signed primitive integer to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Integer) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\n\nimpl PartialEq<Natural> for Integer {\n    /// Determines whether an [`Integer`] is equal to a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where n = `min(self.significant_bits(), other.significant_bits())`\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Integer::from(123) == Natural::from(123u32));\n    /// assert!(Integer::from(123) != Natural::from(5u32));\n    /// ```\n    fn eq(&self, other: &Natural) -> bool {\n        self.sign && self.abs == *other\n    }\n}\n\nimpl PartialEq<Integer> for Natural {\n    /// Determines whether a [`Natural`] is equal to an [`Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where n = `min(self.significant_bits(), other.significant_bits())`\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(123u32) == Integer::from(123));\n    /// assert!(Natural::from(123u32) != Integer::from(5));\n    /// ```\n    fn eq(&self, other: &Integer) -> bool {\n        other.sign && *self == other.abs\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialEq<$t> for Integer {\n            /// Determines whether an [`Integer`] is equal to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            fn eq(&self, other: &$t) -> bool {\n                if self.sign {\n                    self.unsigned_abs() == *other\n                } else {\n                    self.unsigned_abs() == -other\n                }\n            }\n        }\n\n        impl PartialEq<Integer> for $t {\n            /// Determines whether a primitive float is equal to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Integer) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-nz/src/integer/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::traits::Zero;\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl PartialEq<$t> for Integer {\n            /// Determines whether an [`Integer`] is equal to an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &$t) -> bool {\n                self.sign && self.abs == *other\n            }\n        }\n\n        impl PartialEq<Integer> for $t {\n            /// Determines whether an unsigned primitive integer is equal to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Integer) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nfn eq_signed<U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(x: &Integer, other: &S) -> bool\nwhere\n    Natural: PartialEq<U>,\n{\n    x.sign == (*other >= S::ZERO) && x.abs == other.unsigned_abs()\n}\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialEq<$t> for Integer {\n            /// Determines whether an [`Integer`] is equal to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            fn eq(&self, other: &$t) -> bool {\n                eq_signed(self, other)\n            }\n        }\n\n        impl PartialEq<Integer> for $t {\n            /// Determines whether a signed primitive integer is equal to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Integer) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::basic::traits::{One, Zero};\n\nimpl From<bool> for Integer {\n    /// Converts a [`bool`] to 0 or 1.\n    ///\n    /// This function is known as the [Iverson\n    /// bracket](https://en.wikipedia.org/wiki/Iverson_bracket).\n    ///\n    /// $$\n    /// f(P) = \\[P\\] = \\\\begin{cases}\n    ///     1 & \\text{if} \\\\quad P, \\\\\\\\\n    ///     0 & \\\\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(false), 0);\n    /// assert_eq!(Integer::from(true), 1);\n    /// ```\n    #[inline]\n    fn from(b: bool) -> Self {\n        if b { Self::ONE } else { Self::ZERO }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\n\nimpl Integer {\n    /// Converts a sign and a [`Natural`] to an [`Integer`], taking the [`Natural`] by value. The\n    /// [`Natural`] becomes the [`Integer`]'s absolute value, and the sign indicates whether the\n    /// [`Integer`] should be non-negative. If the [`Natural`] is zero, then the [`Integer`] will be\n    /// non-negative regardless of the sign.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Integer::from_sign_and_abs(true, Natural::from(123u32)), 123);\n    /// assert_eq!(\n    ///     Integer::from_sign_and_abs(false, Natural::from(123u32)),\n    ///     -123\n    /// );\n    /// ```\n    pub fn from_sign_and_abs(sign: bool, abs: Natural) -> Self {\n        Self {\n            sign: sign || abs == 0,\n            abs,\n        }\n    }\n\n    /// Converts a sign and an [`Natural`] to an [`Integer`], taking the [`Natural`] by reference.\n    /// The [`Natural`] becomes the [`Integer`]'s absolute value, and the sign indicates whether the\n    /// [`Integer`] should be non-negative. If the [`Natural`] is zero, then the [`Integer`] will be\n    /// non-negative regardless of the sign.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `abs.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Integer::from_sign_and_abs_ref(true, &Natural::from(123u32)),\n    ///     123\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_sign_and_abs_ref(false, &Natural::from(123u32)),\n    ///     -123\n    /// );\n    /// ```\n    pub fn from_sign_and_abs_ref(sign: bool, abs: &Natural) -> Self {\n        Self {\n            sign: sign || *abs == 0,\n            abs: abs.clone(),\n        }\n    }\n}\n\nimpl From<Natural> for Integer {\n    /// Converts a [`Natural`] to an [`Integer`], taking the [`Natural`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Integer::from(Natural::from(123u32)), 123);\n    /// assert_eq!(\n    ///     Integer::from(Natural::from(10u32).pow(12)),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    fn from(value: Natural) -> Self {\n        Self {\n            sign: true,\n            abs: value,\n        }\n    }\n}\n\nimpl<'a> From<&'a Natural> for Integer {\n    /// Converts a [`Natural`] to an [`Integer`], taking the [`Natural`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Integer::from(&Natural::from(123u32)), 123);\n    /// assert_eq!(\n    ///     Integer::from(&Natural::from(10u32).pow(12)),\n    ///     1000000000000u64\n    /// );\n    /// ```\n    fn from(value: &'a Natural) -> Self {\n        Self {\n            sign: true,\n            abs: value.clone(),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::cmp::Ordering;\nuse malachite_base::num::conversion::from::{SignedFromFloatError, UnsignedFromFloatError};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode;\n\nmacro_rules! float_impls {\n    ($f: ident) => {\n        impl RoundingFrom<$f> for Integer {\n            /// Converts a primitive float to an [`Integer`], using the specified rounding mode. An\n            /// [`Ordering`] is also returned, indicating whether the returned value is less than,\n            /// equal to, or greater than the original value.\n            ///\n            /// The floating-point value cannot be NaN or infinite.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.sci_exponent()`.\n            ///\n            /// # Panics\n            /// Panics if `value` is NaN or infinite or if the rounding mode is `Exact` and `value`\n            /// is not an integer.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#rounding_from).\n            fn rounding_from(value: $f, rm: RoundingMode) -> (Self, Ordering) {\n                if value >= 0.0 {\n                    let (abs, o) = Natural::rounding_from(value, rm);\n                    (Integer { sign: true, abs }, o)\n                } else {\n                    let (n, o) = Natural::rounding_from(-value, -rm);\n                    (-n, o.reverse())\n                }\n            }\n        }\n\n        impl TryFrom<$f> for Integer {\n            type Error = SignedFromFloatError;\n\n            /// Converts a primitive float to an [`Integer`].\n            ///\n            /// If the input isn't exactly equal to some [`Integer`], an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.sci_exponent()`.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#try_from).\n            fn try_from(value: $f) -> Result<Integer, Self::Error> {\n                Natural::try_from(value.abs())\n                    .map(|n| Integer {\n                        sign: value >= 0.0,\n                        abs: n,\n                    })\n                    .map_err(|e| match e {\n                        UnsignedFromFloatError::FloatInfiniteOrNan => {\n                            SignedFromFloatError::FloatInfiniteOrNan\n                        }\n                        UnsignedFromFloatError::FloatNonIntegerOrOutOfRange => {\n                            SignedFromFloatError::FloatNonIntegerOrOutOfRange\n                        }\n                        _ => unreachable!(),\n                    })\n            }\n        }\n\n        impl ConvertibleFrom<$f> for Integer {\n            /// Determines whether a primitive float can be exactly converted to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#convertible_from).\n            fn convertible_from(value: $f) -> bool {\n                Natural::convertible_from(value.abs())\n            }\n        }\n    };\n}\napply_to_primitive_floats!(float_impls);\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::platform::{Limb, SignedLimb};\n\nimpl Integer {\n    /// Converts a [`Limb`](crate#limbs) to an [`Integer`].\n    ///\n    /// This function is const, so it may be used to define constants.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// const TEN: Integer = Integer::const_from_unsigned(10);\n    /// assert_eq!(TEN, 10);\n    /// ```\n    pub const fn const_from_unsigned(x: Limb) -> Self {\n        Self {\n            sign: true,\n            abs: Natural::const_from(x),\n        }\n    }\n\n    /// Converts a [`SignedLimb`](crate#limbs) to an [`Integer`].\n    ///\n    /// This function is const, so it may be used to define constants.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// const TEN: Integer = Integer::const_from_signed(10);\n    /// assert_eq!(TEN, 10);\n    ///\n    /// const NEGATIVE_TEN: Integer = Integer::const_from_signed(-10);\n    /// assert_eq!(NEGATIVE_TEN, -10);\n    /// ```\n    pub const fn const_from_signed(x: SignedLimb) -> Self {\n        Self {\n            sign: x >= 0,\n            abs: Natural::const_from(x.unsigned_abs()),\n        }\n    }\n}\n\nmacro_rules! impl_from_unsigned {\n    ($t: ident) => {\n        impl From<$t> for Integer {\n            /// Converts an unsigned primitive integer to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(u: $t) -> Integer {\n                Integer {\n                    sign: true,\n                    abs: Natural::from(u),\n                }\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_from_unsigned);\n\nmacro_rules! impl_from_signed {\n    ($t: ident) => {\n        impl From<$t> for Integer {\n            /// Converts a signed primitive integer to an [`Integer`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(i: $t) -> Integer {\n                Integer {\n                    sign: i >= 0,\n                    abs: Natural::from(i.unsigned_abs()),\n                }\n            }\n        }\n    };\n}\napply_to_signeds!(impl_from_signed);\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/from_twos_complement_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::conversion::to_twos_complement_limbs::{\n    limbs_twos_complement, limbs_twos_complement_in_place,\n};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\n\nimpl Integer {\n    /// Converts a slice of [limbs](crate#limbs) to an [`Integer`], in ascending order, so that less\n    /// significant limbs have lower indices in the input slice.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is non-negative, and if the bit is one it is\n    /// negative. If the slice is empty, zero is returned.\n    ///\n    /// This function borrows a slice. If taking ownership of a [`Vec`] is possible instead,\n    /// [`from_owned_twos_complement_limbs_asc`](`Self::from_owned_twos_complement_limbs_asc`) is\n    /// more efficient.\n    ///\n    /// This function is more efficient than\n    /// [`from_twos_complement_limbs_desc`](`Self::from_twos_complement_limbs_desc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::from_twos_complement_limbs_asc(&[]), 0);\n    ///     assert_eq!(Integer::from_twos_complement_limbs_asc(&[123]), 123);\n    ///     assert_eq!(Integer::from_twos_complement_limbs_asc(&[4294967173]), -123);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from_twos_complement_limbs_asc(&[3567587328, 232]),\n    ///         1000000000000u64\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from_twos_complement_limbs_asc(&[727379968, 4294967063]),\n    ///         -1000000000000i64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_twos_complement_limbs_asc(xs: &[Limb]) -> Self {\n        match xs {\n            &[] => Self::ZERO,\n            &[.., last] if !last.get_highest_bit() => Self::from(Natural::from_limbs_asc(xs)),\n            xs => -Natural::from_owned_limbs_asc(limbs_twos_complement(xs)),\n        }\n    }\n\n    /// Converts a slice of [limbs](crate#limbs) to an [`Integer`], in descending order, so that\n    /// less significant limbs have higher indices in the input slice.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is non-negative, and if the bit is one it is\n    /// negative. If the slice is empty, zero is returned.\n    ///\n    /// This function borrows a slice. If taking ownership of a [`Vec`] is possible instead,\n    /// [`from_owned_twos_complement_limbs_desc`](`Self::from_owned_twos_complement_limbs_desc`) is\n    /// more efficient.\n    ///\n    /// This function is less efficient than\n    /// [`from_twos_complement_limbs_asc`](`Self::from_twos_complement_limbs_asc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::from_twos_complement_limbs_desc(&[]), 0);\n    ///     assert_eq!(Integer::from_twos_complement_limbs_desc(&[123]), 123);\n    ///     assert_eq!(\n    ///         Integer::from_twos_complement_limbs_desc(&[4294967173]),\n    ///         -123\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from_twos_complement_limbs_desc(&[232, 3567587328]),\n    ///         1000000000000u64\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from_twos_complement_limbs_desc(&[4294967063, 727379968]),\n    ///         -1000000000000i64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_twos_complement_limbs_desc(xs: &[Limb]) -> Self {\n        Self::from_owned_twos_complement_limbs_asc(xs.iter().copied().rev().collect())\n    }\n\n    /// Converts a slice of [limbs](crate#limbs) to an [`Integer`], in ascending order, so that less\n    /// significant limbs have lower indices in the input slice.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is non-negative, and if the bit is one it is\n    /// negative. If the slice is empty, zero is returned.\n    ///\n    /// This function takes ownership of a [`Vec`]. If it's necessary to borrow a slice instead, use\n    /// [`from_twos_complement_limbs_asc`](`Self::from_twos_complement_limbs_asc`)\n    ///\n    /// This function is more efficient than\n    /// [`from_owned_twos_complement_limbs_desc`](`Self::from_owned_twos_complement_limbs_desc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::from_owned_twos_complement_limbs_asc(vec![]), 0);\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_asc(vec![123]),\n    ///         123\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_asc(vec![4294967173]),\n    ///         -123\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_asc(vec![3567587328, 232]),\n    ///         1000000000000i64\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_asc(vec![727379968, 4294967063]),\n    ///         -1000000000000i64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_owned_twos_complement_limbs_asc(mut xs: Vec<Limb>) -> Self {\n        match *xs.as_slice() {\n            [] => Self::ZERO,\n            [.., last] if !last.get_highest_bit() => Self::from(Natural::from_owned_limbs_asc(xs)),\n            _ => {\n                assert!(!limbs_twos_complement_in_place(&mut xs));\n                -Natural::from_owned_limbs_asc(xs)\n            }\n        }\n    }\n\n    /// Converts a slice of [limbs](crate#limbs) to an [`Integer`], in descending order, so that\n    /// less significant limbs have higher indices in the input slice.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is non-negative, and if the bit is one it is\n    /// negative. If the slice is empty, zero is returned.\n    ///\n    /// This function takes ownership of a [`Vec`]. If it's necessary to borrow a slice instead, use\n    /// [`from_twos_complement_limbs_desc`](`Self::from_twos_complement_limbs_desc`).\n    ///\n    /// This function is less efficient than\n    /// [`from_owned_twos_complement_limbs_asc`](`Self::from_owned_twos_complement_limbs_asc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::from_owned_twos_complement_limbs_desc(vec![]), 0);\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_desc(vec![123]),\n    ///         123\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_desc(vec![4294967173]),\n    ///         -123\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_desc(vec![232, 3567587328]),\n    ///         1000000000000i64\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from_owned_twos_complement_limbs_desc(vec![4294967063, 727379968]),\n    ///         -1000000000000i64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_owned_twos_complement_limbs_desc(mut xs: Vec<Limb>) -> Self {\n        xs.reverse();\n        Self::from_owned_twos_complement_limbs_asc(xs)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::conversion::traits::IsInteger;\n\nimpl IsInteger for &Integer {\n    /// Determines whether an [`Integer`] is an integer. It always returns `true`.\n    ///\n    /// $f(x) = \\textrm{true}$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NegativeOne, One, Zero};\n    /// use malachite_base::num::conversion::traits::IsInteger;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.is_integer(), true);\n    /// assert_eq!(Integer::ONE.is_integer(), true);\n    /// assert_eq!(Integer::from(100).is_integer(), true);\n    /// assert_eq!(Integer::NEGATIVE_ONE.is_integer(), true);\n    /// assert_eq!(Integer::from(-100).is_integer(), true);\n    /// ```\n    #[inline]\n    fn is_integer(self) -> bool {\n        true\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// An implementation of the [`From`] trait for converting a [`bool`] to an\n/// [`Integer`](crate::integer::Integer).\npub mod from_bool;\n/// Functions for converting a [`Natural`](crate::natural::Natural) to an\n/// [`Integer`](crate::integer::Integer), and an implementation of the [`From`] trait.\npub mod from_natural;\n/// Implementations of traits for converting a primitive float to an\n/// [`Integer`](crate::integer::Integer).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # rounding_from\n/// ```\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     Integer::rounding_from(0.0, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(-0.0, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.0, Exact).to_debug_string(),\n///     \"(123, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(1.0e9, Exact).to_debug_string(),\n///     \"(1000000000, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(1.0e9, Exact).to_debug_string(),\n///     \"(1000000000, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(4294967295.0, Exact).to_debug_string(),\n///     \"(4294967295, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(4294967296.0, Exact).to_debug_string(),\n///     \"(4294967296, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(1.0e100, Exact).to_debug_string(),\n///     \"(1000000000000000015902891109759918046836080856394528138978132755774783877217038106081346\\\n///     9985856815104, Equal)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.1, Floor).to_debug_string(),\n///     \"(123, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.1, Ceiling).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.1, Nearest).to_debug_string(),\n///     \"(123, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.9, Floor).to_debug_string(),\n///     \"(123, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.9, Ceiling).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.9, Nearest).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(123.5, Nearest).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(124.5, Nearest).to_debug_string(),\n///     \"(124, Less)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(-0.99, Ceiling).to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(-0.499, Nearest).to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Integer::rounding_from(-0.5, Nearest).to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// ```\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     Integer::try_from(f64::NAN).to_debug_string(),\n///     \"Err(FloatInfiniteOrNan)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(f64::INFINITY).to_debug_string(),\n///     \"Err(FloatInfiniteOrNan)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(f64::NEGATIVE_INFINITY).to_debug_string(),\n///     \"Err(FloatInfiniteOrNan)\"\n/// );\n/// assert_eq!(Integer::try_from(0.0).to_debug_string(), \"Ok(0)\");\n/// assert_eq!(Integer::try_from(-0.0).to_debug_string(), \"Ok(0)\");\n/// assert_eq!(Integer::try_from(123.0).to_debug_string(), \"Ok(123)\");\n/// assert_eq!(Integer::try_from(-123.0).to_debug_string(), \"Ok(-123)\");\n/// assert_eq!(Integer::try_from(1.0e9).to_debug_string(), \"Ok(1000000000)\");\n/// assert_eq!(\n///     Integer::try_from(4294967295.0).to_debug_string(),\n///     \"Ok(4294967295)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(4294967296.0).to_debug_string(),\n///     \"Ok(4294967296)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(1.0e100).to_debug_string(),\n///     \"Ok(10000000000000000159028911097599180468360808563945281389781327557747838772170381060813\\\n///     469985856815104)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(123.1).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(123.9).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(123.5).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(124.5).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(-0.499).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Integer::try_from(-0.5).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(Integer::convertible_from(f64::NAN), false);\n/// assert_eq!(Integer::convertible_from(f64::INFINITY), false);\n/// assert_eq!(Integer::convertible_from(f64::NEGATIVE_INFINITY), false);\n/// assert_eq!(Integer::convertible_from(0.0), true);\n/// assert_eq!(Integer::convertible_from(-0.0), true);\n/// assert_eq!(Integer::convertible_from(123.0), true);\n/// assert_eq!(Integer::convertible_from(-123.0), true);\n/// assert_eq!(Integer::convertible_from(1.0e9), true);\n/// assert_eq!(Integer::convertible_from(4294967295.0), true);\n/// assert_eq!(Integer::convertible_from(4294967296.0), true);\n/// assert_eq!(Integer::convertible_from(1.0e100), true);\n/// assert_eq!(Integer::convertible_from(123.1), false);\n/// assert_eq!(Integer::convertible_from(123.9), false);\n/// assert_eq!(Integer::convertible_from(123.5), false);\n/// assert_eq!(Integer::convertible_from(124.5), false);\n/// assert_eq!(Integer::convertible_from(-0.499), false);\n/// assert_eq!(Integer::convertible_from(-0.5), false);\n/// ```\npub mod from_primitive_float;\n/// Implementations of traits for converting a primitive integer to an\n/// [`Integer`](crate::integer::Integer).\n///\n/// The traits are [`From`], [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`SaturatingFrom`](malachite_base::num::conversion::traits::SaturatingFrom).\n///\n/// # from\n/// ```\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(Integer::from(123u32).to_string(), \"123\");\n/// assert_eq!(Integer::from(-123i32).to_string(), \"-123\");\n/// ```\npub mod from_primitive_int;\n/// Functions for constructing an [`Integer`](crate::integer::Integer) from two's complement\n/// [`Limb`](crate#limbs)s.\npub mod from_twos_complement_limbs;\n/// An implementation of [`IsInteger`](malachite_base::num::conversion::traits::IsInteger), a trait\n/// for determining whether a number is an integer.\n///\n/// An [`Integer`](crate::integer::Integer) is always an integer.\npub mod is_integer;\n/// Implementations of traits for converting an [`Integer`](crate::integer::Integer) to a\n/// [`Natural`](crate::natural::Natural).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`SaturatingFrom`](malachite_base::num::conversion::traits::SaturatingFrom).\npub mod natural_from_integer;\n/// Implementations of traits for converting an [`Integer`](crate::integer::Integer) to a primitive\n/// float.\n///\n/// The traits are [`TryFrom`]\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # rounding_from\n/// ```\n/// use core::cmp::Ordering::*;\n/// use core::str::FromStr;\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     f32::rounding_from(&Integer::from_str(\"123\").unwrap(), Exact),\n///     (123.0, Equal)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(&Integer::from_str(\"1000000001\").unwrap(), Floor),\n///     (1.0e9, Less)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(&Integer::from_str(\"1000000001\").unwrap(), Ceiling),\n///     (1.00000006e9, Greater)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(&Integer::from_str(\"-1000000001\").unwrap(), Floor),\n///     (-1.00000006e9, Less)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(&Integer::from_str(\"-1000000001\").unwrap(), Ceiling),\n///     (-1.0e9, Greater)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(\n///         &Integer::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n///         Nearest\n///     ),\n///     (f32::INFINITY, Greater)\n/// );\n/// ```\n///\n/// # try_from\n/// ```\n/// use core::str::FromStr;\n/// use malachite_nz::integer::conversion::primitive_float_from_integer::*;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(f32::try_from(&Integer::from_str(\"123\").unwrap()), Ok(123.0));\n/// assert_eq!(\n///     f32::try_from(&Integer::from_str(\"-1000000000\").unwrap()),\n///     Ok(-1.0e9)\n/// );\n/// assert_eq!(\n///     f32::try_from(&Integer::from_str(\"1000000001\").unwrap()),\n///     Err(PrimitiveFloatFromIntegerError)\n/// );\n/// assert_eq!(\n///     f32::try_from(\n///         &Integer::from_str(\"-10000000000000000000000000000000000000000000000000000\").unwrap()\n///     ),\n///     Err(PrimitiveFloatFromIntegerError)\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use core::str::FromStr;\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     f32::convertible_from(&Integer::from_str(\"123\").unwrap()),\n///     true\n/// );\n/// assert_eq!(\n///     f32::convertible_from(&Integer::from_str(\"-1000000000\").unwrap()),\n///     true\n/// );\n/// assert_eq!(\n///     f32::convertible_from(&Integer::from_str(\"1000000001\").unwrap()),\n///     false\n/// );\n/// assert_eq!(\n///     f32::convertible_from(\n///         &Integer::from_str(\"-10000000000000000000000000000000000000000000000000000\").unwrap()\n///     ),\n///     false\n/// );\n/// ```\npub mod primitive_float_from_integer;\n/// Implementations of traits for converting an [`Integer`](crate::integer::Integer) to a primitive\n/// integer.\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom),\n/// [`OverflowingFrom`](malachite_base::num::conversion::traits::OverflowingFrom),\n/// [`SaturatingFrom`](malachite_base::num::conversion::traits::SaturatingFrom), and\n/// [`WrappingFrom`](malachite_base::num::conversion::traits::WrappingFrom).\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_nz::integer::conversion::primitive_int_from_integer::{\n///     SignedFromIntegerError, UnsignedFromIntegerError,\n/// };\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(u32::try_from(&Integer::from(123)), Ok(123));\n/// assert_eq!(\n///     u32::try_from(&Integer::from(-123)),\n///     Err(UnsignedFromIntegerError)\n/// );\n/// assert_eq!(\n///     u32::try_from(&Integer::from(10u32).pow(12)),\n///     Err(UnsignedFromIntegerError)\n/// );\n/// assert_eq!(\n///     u32::try_from(&-Integer::from(10u32).pow(12)),\n///     Err(UnsignedFromIntegerError)\n/// );\n///\n/// assert_eq!(i32::try_from(&Integer::from(123)), Ok(123));\n/// assert_eq!(i32::try_from(&Integer::from(-123)), Ok(-123));\n/// assert_eq!(\n///     i32::try_from(&Integer::from(10u32).pow(12)),\n///     Err(SignedFromIntegerError)\n/// );\n/// assert_eq!(\n///     i32::try_from(&-Integer::from(10u32).pow(12)),\n///     Err(SignedFromIntegerError)\n/// );\n/// ```\n///\n/// # wrapping_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::conversion::traits::WrappingFrom;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(u32::wrapping_from(&Integer::from(123)), 123);\n/// assert_eq!(u32::wrapping_from(&Integer::from(-123)), 4294967173);\n/// assert_eq!(\n///     u32::wrapping_from(&Integer::from(10u32).pow(12)),\n///     3567587328\n/// );\n/// assert_eq!(\n///     u32::wrapping_from(&-Integer::from(10u32).pow(12)),\n///     727379968\n/// );\n///\n/// assert_eq!(i32::wrapping_from(&Integer::from(123)), 123);\n/// assert_eq!(i32::wrapping_from(&Integer::from(-123)), -123);\n/// assert_eq!(\n///     i32::wrapping_from(&Integer::from(10u32).pow(12)),\n///     -727379968\n/// );\n/// assert_eq!(\n///     i32::wrapping_from(&-Integer::from(10u32).pow(12)),\n///     727379968\n/// );\n/// ```\n///\n/// # saturating_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::conversion::traits::SaturatingFrom;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(u32::saturating_from(&Integer::from(123)), 123);\n/// assert_eq!(u32::saturating_from(&Integer::from(-123)), 0);\n/// assert_eq!(\n///     u32::saturating_from(&Integer::from(10u32).pow(12)),\n///     u32::MAX\n/// );\n/// assert_eq!(u32::saturating_from(&-Integer::from(10u32).pow(12)), 0);\n///\n/// assert_eq!(i32::saturating_from(&Integer::from(123)), 123);\n/// assert_eq!(i32::saturating_from(&Integer::from(-123)), -123);\n/// assert_eq!(\n///     i32::saturating_from(&Integer::from(10u32).pow(12)),\n///     2147483647\n/// );\n/// assert_eq!(\n///     i32::saturating_from(&-Integer::from(10u32).pow(12)),\n///     -2147483648\n/// );\n/// ```\n///\n/// # overflowing_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::conversion::traits::OverflowingFrom;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(u32::overflowing_from(&Integer::from(123)), (123, false));\n/// assert_eq!(\n///     u32::overflowing_from(&Integer::from(-123)),\n///     (4294967173, true)\n/// );\n/// assert_eq!(\n///     u32::overflowing_from(&Integer::from(10u32).pow(12)),\n///     (3567587328, true)\n/// );\n/// assert_eq!(\n///     u32::overflowing_from(&-Integer::from(10u32).pow(12)),\n///     (727379968, true)\n/// );\n///\n/// assert_eq!(i32::overflowing_from(&Integer::from(123)), (123, false));\n/// assert_eq!(i32::overflowing_from(&Integer::from(-123)), (-123, false));\n/// assert_eq!(\n///     i32::overflowing_from(&Integer::from(10u32).pow(12)),\n///     (-727379968, true)\n/// );\n/// assert_eq!(\n///     i32::overflowing_from(&-Integer::from(10u32).pow(12)),\n///     (727379968, true)\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(u32::convertible_from(&Integer::from(123)), true);\n/// assert_eq!(u32::convertible_from(&Integer::from(-123)), false);\n/// assert_eq!(u32::convertible_from(&Integer::from(10u32).pow(12)), false);\n/// assert_eq!(u32::convertible_from(&-Integer::from(10u32).pow(12)), false);\n///\n/// assert_eq!(i32::convertible_from(&Integer::from(123)), true);\n/// assert_eq!(i32::convertible_from(&Integer::from(-123)), true);\n/// assert_eq!(i32::convertible_from(&Integer::from(10u32).pow(12)), false);\n/// assert_eq!(i32::convertible_from(&-Integer::from(10u32).pow(12)), false);\n/// ```\npub mod primitive_int_from_integer;\n/// Implementations of traits for conversions between Python integers and\n/// [`Integer`](crate::integer::Integer)s using [pyo3](https://pyo3.rs/).\npub mod pyo3;\n/// Implementations of traits for serialization and deserialization using\n/// [serde](https://serde.rs/).\npub mod serde;\n/// Implementations of traits for converting [`Integer`](crate::integer::Integer)s to and from\n/// [`String`]s.\npub mod string;\n/// Functions for extracting two's complement [`Limb`](crate#limbs)s from an\n/// [`Integer`](crate::integer::Integer).\npub mod to_twos_complement_limbs;\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/natural_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, SaturatingFrom};\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct NaturalFromIntegerError;\n\nimpl TryFrom<Integer> for Natural {\n    type Error = NaturalFromIntegerError;\n\n    /// Converts an [`Integer`] to a [`Natural`], taking the [`Natural`] by value. If the\n    /// [`Integer`] is negative, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::try_from(Integer::from(123)).to_debug_string(),\n    ///     \"Ok(123)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(Integer::from(-123)).to_debug_string(),\n    ///     \"Err(NaturalFromIntegerError)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(Integer::from(10u32).pow(12)).to_debug_string(),\n    ///     \"Ok(1000000000000)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(-Integer::from(10u32).pow(12)).to_debug_string(),\n    ///     \"Err(NaturalFromIntegerError)\"\n    /// );\n    /// ```\n    fn try_from(value: Integer) -> Result<Self, Self::Error> {\n        match value {\n            Integer { sign: false, .. } => Err(NaturalFromIntegerError),\n            Integer { sign: true, abs } => Ok(abs),\n        }\n    }\n}\n\nimpl<'a> TryFrom<&'a Integer> for Natural {\n    type Error = NaturalFromIntegerError;\n\n    /// Converts an [`Integer`] to a [`Natural`], taking the [`Natural`] by reference. If the\n    /// [`Integer`] is negative, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::try_from(&Integer::from(123)).to_debug_string(),\n    ///     \"Ok(123)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(&Integer::from(-123)).to_debug_string(),\n    ///     \"Err(NaturalFromIntegerError)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(&Integer::from(10u32).pow(12)).to_debug_string(),\n    ///     \"Ok(1000000000000)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(&(-Integer::from(10u32).pow(12))).to_debug_string(),\n    ///     \"Err(NaturalFromIntegerError)\"\n    /// );\n    /// ```\n    fn try_from(value: &'a Integer) -> Result<Self, Self::Error> {\n        match *value {\n            Integer { sign: false, .. } => Err(NaturalFromIntegerError),\n            Integer {\n                sign: true,\n                ref abs,\n            } => Ok(abs.clone()),\n        }\n    }\n}\n\nimpl SaturatingFrom<Integer> for Natural {\n    /// Converts an [`Integer`] to a [`Natural`], taking the [`Natural`] by value. If the\n    /// [`Integer`] is negative, 0 is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::conversion::traits::SaturatingFrom;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::saturating_from(Integer::from(123)), 123);\n    /// assert_eq!(Natural::saturating_from(Integer::from(-123)), 0);\n    /// assert_eq!(\n    ///     Natural::saturating_from(Integer::from(10u32).pow(12)),\n    ///     1000000000000u64\n    /// );\n    /// assert_eq!(Natural::saturating_from(-Integer::from(10u32).pow(12)), 0);\n    /// ```\n    fn saturating_from(value: Integer) -> Self {\n        match value {\n            Integer { sign: false, .. } => Self::ZERO,\n            Integer { sign: true, abs } => abs,\n        }\n    }\n}\n\nimpl<'a> SaturatingFrom<&'a Integer> for Natural {\n    /// Converts an [`Integer`] to a [`Natural`], taking the [`Natural`] by reference. If the\n    /// [`Integer`] is negative, 0 is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::conversion::traits::SaturatingFrom;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::saturating_from(&Integer::from(123)), 123);\n    /// assert_eq!(Natural::saturating_from(&Integer::from(-123)), 0);\n    /// assert_eq!(\n    ///     Natural::saturating_from(&Integer::from(10u32).pow(12)),\n    ///     1000000000000u64\n    /// );\n    /// assert_eq!(Natural::saturating_from(&-Integer::from(10u32).pow(12)), 0);\n    /// ```\n    fn saturating_from(value: &'a Integer) -> Self {\n        match *value {\n            Integer { sign: false, .. } => Self::ZERO,\n            Integer {\n                sign: true,\n                ref abs,\n            } => abs.clone(),\n        }\n    }\n}\n\nimpl ConvertibleFrom<Integer> for Natural {\n    /// Determines whether an [`Integer`] can be converted to a [`Natural`] (when the [`Integer`] is\n    /// non-negative). Takes the [`Integer`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::convertible_from(Integer::from(123)), true);\n    /// assert_eq!(Natural::convertible_from(Integer::from(-123)), false);\n    /// assert_eq!(\n    ///     Natural::convertible_from(Integer::from(10u32).pow(12)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::convertible_from(-Integer::from(10u32).pow(12)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn convertible_from(value: Integer) -> bool {\n        value.sign\n    }\n}\n\nimpl<'a> ConvertibleFrom<&'a Integer> for Natural {\n    /// Determines whether an [`Integer`] can be converted to a [`Natural`] (when the [`Integer`] is\n    /// non-negative). Takes the [`Integer`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::convertible_from(&Integer::from(123)), true);\n    /// assert_eq!(Natural::convertible_from(&Integer::from(-123)), false);\n    /// assert_eq!(\n    ///     Natural::convertible_from(&Integer::from(10u32).pow(12)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::convertible_from(&-Integer::from(10u32).pow(12)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn convertible_from(value: &'a Integer) -> bool {\n        value.sign\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/primitive_float_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::cmp::Ordering;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct PrimitiveFloatFromIntegerError;\n\nmacro_rules! float_impls {\n    ($f: ident) => {\n        impl<'a> RoundingFrom<&'a Integer> for $f {\n            /// Converts an [`Integer`] to a primitive float according to a specified\n            /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the returned\n            /// value is less than, equal to, or greater than the original value.\n            ///\n            /// - If the rounding mode is `Floor` the largest float less than or equal to the\n            ///   [`Integer`] is returned. If the [`Integer`] is greater than the maximum finite\n            ///   float, then the maximum finite float is returned. If it is smaller than the\n            ///   minimum finite float, then $-\\infty$ is returned.\n            /// - If the rounding mode is `Ceiling`, the smallest float greater than or equal to the\n            ///   [`Integer`] is returned. If the [`Integer`] is greater than the maximum finite\n            ///   float, then $\\infty$ is returned. If it is smaller than the minimum finite float,\n            ///   then the minimum finite float is returned.\n            /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor` if the\n            ///   [`Integer`] is non-negative and as with `Ceiling` if the [`Integer`] is negative.\n            /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling` if the\n            ///   [`Integer`] is non-negative and as with `Floor` if the [`Integer`] is negative.\n            /// - If the rounding mode is `Nearest`, then the nearest float is returned. If the\n            ///   [`Integer`] is exactly between two floats, the float with the zero\n            ///   least-significant bit in its representation is selected. If the [`Integer`] is\n            ///   greater than the maximum finite float, then $\\infty$ is returned. If the\n            ///   [`Integer`] is smaller than the minimum finite float, then $-\\infty$ is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the rounding mode is `Exact` and `value` cannot be represented exactly.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_integer#rounding_from).\n            fn rounding_from(value: &'a Integer, rm: RoundingMode) -> ($f, Ordering) {\n                if value.sign {\n                    $f::rounding_from(&value.abs, rm)\n                } else {\n                    let (f, o) = $f::rounding_from(&value.abs, -rm);\n                    (-f, o.reverse())\n                }\n            }\n        }\n\n        impl<'a> TryFrom<&'a Integer> for $f {\n            type Error = PrimitiveFloatFromIntegerError;\n\n            /// Converts an [`Integer`] to a primitive float.\n            ///\n            /// If the input isn't exactly equal to some float, an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_integer#try_from).\n            fn try_from(value: &'a Integer) -> Result<$f, Self::Error> {\n                $f::try_from(&value.abs)\n                    .map(|f| if value.sign { f } else { -f })\n                    .map_err(|_| PrimitiveFloatFromIntegerError)\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Integer> for $f {\n            /// Determines whether an [`Integer`] can be exactly converted to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_integer#convertible_from).\n            fn convertible_from(value: &'a Integer) -> bool {\n                $f::convertible_from(&value.abs)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(float_impls);\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/primitive_int_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::ops::Neg;\nuse malachite_base::comparison::traits::Min;\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, WrappingNeg};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, OverflowingFrom, SaturatingFrom, WrappingFrom,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct UnsignedFromIntegerError;\n\nfn try_from_unsigned<'a, T: TryFrom<&'a Natural>>(\n    value: &'a Integer,\n) -> Result<T, UnsignedFromIntegerError> {\n    match *value {\n        Integer { sign: false, .. } => Err(UnsignedFromIntegerError),\n        Integer {\n            sign: true,\n            ref abs,\n        } => T::try_from(abs).map_err(|_| UnsignedFromIntegerError),\n    }\n}\n\nfn wrapping_from_unsigned<'a, T: WrappingFrom<&'a Natural> + WrappingNeg<Output = T>>(\n    value: &'a Integer,\n) -> T {\n    match *value {\n        Integer {\n            sign: true,\n            ref abs,\n        } => T::wrapping_from(abs),\n        Integer {\n            sign: false,\n            ref abs,\n        } => T::wrapping_from(abs).wrapping_neg(),\n    }\n}\n\nfn saturating_from_unsigned<'a, T: Copy + SaturatingFrom<&'a Natural> + Zero>(\n    value: &'a Integer,\n) -> T {\n    match *value {\n        Integer {\n            sign: true,\n            ref abs,\n        } => T::saturating_from(abs),\n        _ => T::ZERO,\n    }\n}\n\nfn overflowing_from_unsigned<\n    'a,\n    T: OverflowingFrom<&'a Natural> + WrappingFrom<&'a Natural> + WrappingNeg<Output = T>,\n>(\n    value: &'a Integer,\n) -> (T, bool) {\n    match *value {\n        Integer {\n            sign: true,\n            ref abs,\n        } => T::overflowing_from(abs),\n        Integer {\n            sign: false,\n            ref abs,\n        } => (T::wrapping_from(abs).wrapping_neg(), true),\n    }\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct SignedFromIntegerError;\n\nfn try_from_signed<'a, T: ConvertibleFrom<&'a Integer> + WrappingFrom<&'a Integer>>(\n    value: &'a Integer,\n) -> Result<T, SignedFromIntegerError> {\n    if T::convertible_from(value) {\n        Ok(T::wrapping_from(value))\n    } else {\n        Err(SignedFromIntegerError)\n    }\n}\n\nfn saturating_from_signed<\n    'a,\n    U: PrimitiveInt + SaturatingFrom<&'a Natural>,\n    S: Min + Neg<Output = S> + SaturatingFrom<U> + WrappingFrom<U>,\n>(\n    value: &'a Integer,\n) -> S {\n    match *value {\n        Integer {\n            sign: true,\n            ref abs,\n        } => S::saturating_from(U::saturating_from(abs)),\n        Integer {\n            sign: false,\n            ref abs,\n        } => {\n            let abs = U::saturating_from(abs);\n            if abs.get_highest_bit() {\n                S::MIN\n            } else {\n                -S::wrapping_from(abs)\n            }\n        }\n    }\n}\n\nfn convertible_from_signed<T: PrimitiveInt>(value: &Integer) -> bool {\n    match *value {\n        Integer {\n            sign: true,\n            ref abs,\n        } => abs.significant_bits() < T::WIDTH,\n        Integer {\n            sign: false,\n            ref abs,\n        } => {\n            let significant_bits = abs.significant_bits();\n            significant_bits < T::WIDTH\n                || significant_bits == T::WIDTH && abs.divisible_by_power_of_2(T::WIDTH - 1)\n        }\n    }\n}\n\nmacro_rules! impl_from {\n    ($u: ident, $s: ident) => {\n        impl<'a> TryFrom<&'a Integer> for $u {\n            type Error = UnsignedFromIntegerError;\n\n            /// Converts an [`Integer`] to an unsigned primitive integer, returning an error if the\n            /// [`Integer`] cannot be represented.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#try_from).\n            #[inline]\n            fn try_from(value: &Integer) -> Result<$u, Self::Error> {\n                try_from_unsigned(value)\n            }\n        }\n\n        impl<'a> WrappingFrom<&'a Integer> for $u {\n            /// Converts an [`Integer`] to an unsigned primitive integer, wrapping modulo $2^W$,\n            /// where $W$ is the width of the primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: &Integer) -> $u {\n                wrapping_from_unsigned(value)\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Integer> for $u {\n            /// Converts an [`Integer`] to an unsigned primitive integer.\n            ///\n            /// If the [`Integer`] cannot be represented by the output type, then either zero or the\n            /// maximum representable value is returned, whichever is closer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#saturating_from).\n            #[inline]\n            fn saturating_from(value: &Integer) -> $u {\n                saturating_from_unsigned(value)\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Integer> for $u {\n            /// Converts an [`Integer`] to an unsigned primitive integer, wrapping modulo $2^W$,\n            /// where $W$ is the width of the primitive integer.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#overflowing_from).\n            #[inline]\n            fn overflowing_from(value: &Integer) -> ($u, bool) {\n                overflowing_from_unsigned(value)\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Integer> for $u {\n            /// Determines whether an [`Integer`] can be converted to an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#convertible_from).\n            #[inline]\n            fn convertible_from(value: &Integer) -> bool {\n                value.sign && $u::convertible_from(&value.abs)\n            }\n        }\n\n        impl<'a> TryFrom<&'a Integer> for $s {\n            type Error = SignedFromIntegerError;\n\n            /// Converts an [`Integer`] to a signed primitive integer, returning an error if the\n            /// [`Integer`] cannot be represented.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#try_from).\n            #[inline]\n            fn try_from(value: &Integer) -> Result<$s, Self::Error> {\n                try_from_signed(value)\n            }\n        }\n\n        impl<'a> WrappingFrom<&'a Integer> for $s {\n            /// Converts an [`Integer`] to a signed primitive integer, wrapping modulo $2^W$, where\n            /// $W$ is the width of the primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: &Integer) -> $s {\n                $s::wrapping_from($u::wrapping_from(value))\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Integer> for $s {\n            /// Converts an [`Integer`] to a signed primitive integer.\n            ///\n            /// If the [`Integer`] cannot be represented by the output type, then either the maximum\n            /// or the minimum representable value is returned, whichever is closer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#saturating_from).\n            #[inline]\n            fn saturating_from(value: &Integer) -> $s {\n                saturating_from_signed::<$u, $s>(value)\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Integer> for $s {\n            /// Converts an [`Integer`] to a signed primitive integer, wrapping modulo $2^W$, where\n            /// $W$ is the width of the primitive integer.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#overflowing_from).\n            #[inline]\n            fn overflowing_from(value: &Integer) -> ($s, bool) {\n                ($s::wrapping_from(value), !$s::convertible_from(value))\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Integer> for $s {\n            /// Determines whether an [`Integer`] can be converted to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_integer#convertible_from).\n            #[inline]\n            fn convertible_from(value: &Integer) -> bool {\n                convertible_from_signed::<$u>(value)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_from);\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/pyo3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// PyO3 integration contributed by Antonio Mamić.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![cfg(feature = \"enable_pyo3\")]\n\n//!\n//! This is useful for converting Python integers when they may not fit in Rust's built-in integer\n//! types.\n//!\n//! To use this enable the `enable_pyo3` feature.\n//!\n//! ## Examples\n//!\n//! Using [`Integer`](crate::integer::Integer) to correctly increment an arbitrary precision\n//! integer. This is not possible with Rust's native integers if the Python integer is too large,\n//! in which case it will fail its conversion and raise `OverflowError`.\n//! ```rust\n//! use malachite::Integer;\n//! use malachite::num::basic::traits::One;\n//! use pyo3::prelude::*;\n//!\n//! #[pyfunction]\n//! fn add_one(n: Integer) -> Integer {\n//!     n + Integer::ONE\n//! }\n//!\n//! #[pymodule]\n//! fn my_module(_py: Python<'_>, m: &PyModule) -> PyResult<()> {\n//!     m.add_function(wrap_pyfunction!(add_one, m)?)?;\n//!     Ok(())\n//! }\n//! ```\n//!\n//! Python code:\n//! ```python\n//! from my_module import add_one\n//!\n//! n = 1 << 1337\n//! value = add_one(n)\n//!\n//! assert n + 1 == value\n//! ```\n\nuse crate::integer::Integer;\nuse alloc::vec::Vec;\nuse core::convert::Infallible;\nuse malachite_base::num::basic::traits::Zero;\n#[cfg(Py_LIMITED_API)]\nuse pyo3::intern;\n#[allow(unused_imports)]\nuse pyo3::{\n    Bound, FromPyObject, IntoPyObject, IntoPyObjectExt, Py, PyErr, PyObject, PyResult, Python, ffi,\n    types::*,\n};\n\n#[cfg_attr(docsrs, doc(cfg(feature = \"enable_pyo3\")))]\nimpl<'source> FromPyObject<'source> for Integer {\n    fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult<Integer> {\n        // get the Python interpreter\n        let py = ob.py();\n\n        // get PyInt object\n        let num_owned: Py<PyInt>;\n        let num = if let Ok(long) = ob.downcast::<PyInt>() {\n            long\n        } else {\n            num_owned = unsafe { Py::from_owned_ptr_or_err(py, ffi::PyNumber_Index(ob.as_ptr()))? };\n            num_owned.bind(py)\n        };\n\n        // check if number is zero, and if so, return zero\n        let n_bits = int_n_bits(num)?;\n        if n_bits == 0 {\n            return Ok(Integer::ZERO);\n        }\n\n        // the number of bytes needed to store the integer\n        let mut n_bytes = (n_bits + 7 + 1) >> 3; // +1 for the sign bit\n\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            // convert the number of bytes to a multiple of 4, because of 32-bit limbs\n            n_bytes = ((n_bytes + 7) >> 2) << 2;\n        }\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            // convert the number of bytes to a multiple of 8, because of 64-bit limbs\n            n_bytes = ((n_bytes + 7) >> 3) << 3;\n        }\n\n        #[cfg(not(Py_LIMITED_API))]\n        {\n            let limbs = int_to_limbs(num, n_bytes, true)?;\n            Ok(Integer::from_owned_twos_complement_limbs_asc(limbs))\n        }\n        #[cfg(all(Py_LIMITED_API, feature = \"32_bit_limbs\"))]\n        {\n            let py_bytes = int_to_py_bytes(num, n_bytes, true)?;\n            let bytes = py_bytes.as_bytes();\n            let n_limbs_32 = n_bytes >> 2; // the number of 32-bit limbs needed to store the integer\n            let mut limbs_32 = Vec::with_capacity(n_limbs_32);\n            for i in (0..n_bytes).step_by(4) {\n                limbs_32.push(u32::from_le_bytes(bytes[i..(i + 4)].try_into().unwrap()));\n            }\n            Ok(Integer::from_owned_twos_complement_limbs_asc(limbs_32))\n        }\n        #[cfg(all(Py_LIMITED_API, not(feature = \"32_bit_limbs\")))]\n        {\n            let bytes = int_to_py_bytes(num, n_bytes, true)?.as_bytes();\n            let n_limbs_64 = n_bytes >> 3; // the number of 64-bit limbs needed to store the integer\n            let mut limbs_64 = Vec::with_capacity(n_limbs_64);\n            for i in (0..n_bytes).step_by(8) {\n                limbs_64.push(u64::from_le_bytes(bytes[i..(i + 8)].try_into().unwrap()));\n            }\n            Ok(Integer::from_owned_twos_complement_limbs_asc(limbs_64))\n        }\n    }\n}\n\n#[cfg_attr(docsrs, doc(cfg(feature = \"enable_pyo3\")))]\nimpl<'py> IntoPyObject<'py> for Integer {\n    type Target = PyInt;\n    type Output = Bound<'py, Self::Target>;\n    type Error = Infallible;\n\n    fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {\n        (&self).into_pyobject(py)\n    }\n}\n\n#[cfg_attr(docsrs, doc(cfg(feature = \"enable_pyo3\")))]\nimpl<'py> IntoPyObject<'py> for &Integer {\n    type Target = PyInt;\n    type Output = Bound<'py, Self::Target>;\n    type Error = Infallible;\n\n    fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {\n        if self == &Integer::ZERO {\n            return Ok(0i32.into_pyobject(py).unwrap());\n        }\n\n        let bytes = limbs_to_bytes(\n            self.twos_complement_limbs(),\n            self.twos_complement_limb_count(),\n        );\n\n        #[cfg(not(Py_LIMITED_API))]\n        unsafe {\n            let obj = ffi::_PyLong_FromByteArray(\n                bytes.as_ptr().cast(),\n                bytes.len(),\n                1,           // little endian\n                true.into(), // signed\n            );\n            Ok(Bound::from_owned_ptr(py, obj).downcast_into_unchecked::<PyInt>())\n        }\n\n        #[cfg(Py_LIMITED_API)]\n        {\n            let bytes_obj = PyBytes::new(py, &bytes);\n            let kwargs = PyDict::new(py);\n            kwargs.set_item(intern!(py, \"signed\"), true).unwrap();\n            let result: Bound<'py, PyAny> = py\n                .get_type::<PyInt>()\n                .call_method(\"from_bytes\", (bytes_obj, \"little\"), Some(&kwargs))\n                .expect(\"int.from_bytes() failed during into_pyobject()\");\n            Ok(result)\n        }\n    }\n}\n\n/// Convert 32-bit limbs (little endian) used by malachite to bytes (little endian)\n#[cfg(feature = \"32_bit_limbs\")]\n#[inline]\nfn limbs_to_bytes(limbs: impl Iterator<Item = u32>, limb_count: u64) -> Vec<u8> {\n    let mut bytes = Vec::with_capacity((limb_count << 3) as usize);\n\n    for limb in limbs {\n        for byte in limb.to_le_bytes() {\n            bytes.push(byte);\n        }\n    }\n\n    bytes\n}\n\n/// Convert 64-bit limbs (little endian) used by malachite to bytes (little endian)\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[inline]\nfn limbs_to_bytes(limbs: impl Iterator<Item = u64>, limb_count: u64) -> Vec<u8> {\n    let mut bytes = Vec::with_capacity((limb_count << 3) as usize);\n\n    for limb in limbs {\n        for byte in limb.to_le_bytes() {\n            bytes.push(byte);\n        }\n    }\n\n    bytes\n}\n\n/// Converts a Python integer to a vector of 32-bit limbs (little endian). Takes number of bytes to\n/// convert to. Multiple of 4. If `is_signed` is true, the integer is treated as signed, and two's\n/// complement is returned.\n#[cfg(all(not(Py_LIMITED_API), feature = \"32_bit_limbs\"))]\n#[inline]\nfn int_to_limbs(long: &Bound<PyInt>, n_bytes: usize, is_signed: bool) -> PyResult<Vec<u32>> {\n    let mut buffer = Vec::with_capacity(n_bytes);\n    unsafe {\n        let error_code = ffi::_PyLong_AsByteArray(\n            long.as_ptr().cast(),           // ptr to PyLong object\n            buffer.as_mut_ptr() as *mut u8, // ptr to first byte of buffer\n            n_bytes << 2,                   // 4 bytes per u32\n            1,                              // little endian\n            is_signed.into(),               // signed flag\n        );\n        if error_code == -1 {\n            return Err(PyErr::fetch(long.py()));\n        }\n        buffer.set_len(n_bytes); // set buffer length to the number of bytes\n    };\n    buffer\n        .iter_mut()\n        .for_each(|chunk| *chunk = u32::from_le(*chunk));\n\n    Ok(buffer)\n}\n\n/// Converts a Python integer to a vector of 64-bit limbs (little endian). Takes number of bytes to\n/// convert to. Multiple of 8. If `is_signed` is true, the integer is treated as signed, and two's\n/// complement is returned.\n#[cfg(all(not(Py_LIMITED_API), not(feature = \"32_bit_limbs\")))]\n#[inline]\nfn int_to_limbs(long: &Bound<PyInt>, n_bytes: usize, is_signed: bool) -> PyResult<Vec<u64>> {\n    let mut buffer = Vec::with_capacity(n_bytes);\n    unsafe {\n        let error_code = ffi::_PyLong_AsByteArray(\n            long.as_ptr().cast(),           // ptr to PyLong object\n            buffer.as_mut_ptr() as *mut u8, // ptr to first byte of buffer\n            n_bytes << 3,                   // 8 bytes per u64\n            1,                              // little endian\n            is_signed.into(),               // signed flag\n        );\n        if error_code == -1 {\n            return Err(PyErr::fetch(long.py()));\n        }\n        buffer.set_len(n_bytes); // set buffer length to the number of bytes\n    };\n    buffer\n        .iter_mut()\n        .for_each(|chunk| *chunk = u64::from_le(*chunk));\n\n    Ok(buffer)\n}\n\n/// Converts a Python integer to a Python bytes object. Bytes are in little endian order. Takes\n/// number of bytes to convert to (can be calculated from the number of bits in the integer). If\n/// `is_signed` is true, the integer is treated as signed, and two's complement is returned.\n#[cfg(Py_LIMITED_API)]\n#[inline]\nfn int_to_py_bytes<'py>(\n    long: &Bound<'py, PyInt>,\n    n_bytes: usize,\n    is_signed: bool,\n) -> PyResult<Bound<'py, PyBytes>> {\n    // get the Python interpreter\n    let py = long.py();\n\n    // setup kwargs for to_bytes (only if signed)\n    let kwargs_dict = PyDict::new(py);\n    let kwargs = if is_signed {\n        kwargs_dict.set_item(intern!(py, \"signed\"), true)?;\n        Some(&kwargs_dict)\n    } else {\n        None\n    };\n\n    // call to_bytes\n    let bytes = long.call_method(\n        intern!(py, \"to_bytes\"),\n        (n_bytes, intern!(py, \"little\")),\n        kwargs,\n    )?;\n\n    // downcast to PyBytes\n    Ok(bytes.downcast_into()?)\n}\n\n/// Returns the number of bits in the absolute value of the given integer. The number of bits\n/// returned is the smallest number of bits that can represent the integer, not the multiple of 8\n/// (bytes) that it would take up in memory.\n#[inline]\nfn int_n_bits(long: &Bound<PyInt>) -> PyResult<usize> {\n    let py = long.py();\n\n    #[cfg(not(Py_LIMITED_API))]\n    {\n        // fast path\n        let n_bits = unsafe { ffi::_PyLong_NumBits(long.as_ptr()) };\n        if n_bits == (-1isize as usize) {\n            return Err(PyErr::fetch(py));\n        }\n        Ok(n_bits)\n    }\n\n    #[cfg(Py_LIMITED_API)]\n    {\n        // slow path\n        long.call_method0(intern!(py, \"bit_length\"))\n            .and_then(|ob| ob.extract())\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    /// Prepare Python\n    fn prepare_python() {\n        pyo3::prepare_freethreaded_python();\n    }\n\n    /// Fibonacci sequence iterator (Rust)\n    fn rust_fib<T>() -> impl Iterator<Item = T>\n    where\n        T: From<u8>,\n        for<'a> &'a T: std::ops::Add<Output = T>,\n    {\n        let mut f0: T = T::from(1);\n        let mut f1: T = T::from(1);\n        std::iter::from_fn(move || {\n            let f2 = &f0 + &f1;\n            Some(std::mem::replace(&mut f0, std::mem::replace(&mut f1, f2)))\n        })\n    }\n\n    /// Fibonacci sequence iterator (Python)\n    fn python_fib(py: Python<'_>) -> impl Iterator<Item = Py<PyInt>> {\n        let mut f0 = 1i32.into_pyobject(py).unwrap();\n        let mut f1 = 1i32.into_pyobject(py).unwrap();\n        std::iter::from_fn(move || {\n            let f2 = f0\n                .call_method1(\"__add__\", (&f1,))\n                .unwrap()\n                .downcast_into::<PyInt>()\n                .unwrap();\n            Some(std::mem::replace(&mut f0, std::mem::replace(&mut f1, f2)).unbind())\n        })\n    }\n\n    /// Generate test python class\n    fn python_index_class(py: Python<'_>) -> Bound<'_, PyModule> {\n        let index_code = std::ffi::CStr::from_bytes_with_nul(\n            concat!(\n                r#\"\n                class C:\n                    def __init__(self, x):\n                        self.x = x\n                    def __index__(self):\n                        return self.x\n                \"#,\n                \"\\0\"\n            )\n            .as_bytes(),\n        )\n        .unwrap();\n        let filename = c\"index.py\";\n        let modulename = c\"index\";\n        PyModule::from_code(py, index_code, filename, modulename).unwrap()\n    }\n\n    /// - Test conversion to and from Integer\n    /// - Tests the first 2000 numbers in the fibonacci sequence and their negations\n    #[test]\n    fn convert_integer() {\n        prepare_python();\n        Python::with_gil(|py| {\n            // check the first 2000 numbers in the fibonacci sequence\n            for (py_result, rs_result) in python_fib(py).zip(rust_fib::<Integer>()).take(2000) {\n                // Python -> Rust\n                assert_eq!(py_result.extract::<Integer>(py).unwrap(), rs_result);\n                // Rust -> Python\n                assert!(\n                    py_result\n                        .bind(py)\n                        .as_any()\n                        .eq(rs_result.clone().into_pyobject(py).unwrap())\n                        .unwrap()\n                );\n\n                // negate\n                let rs_result = rs_result * Integer::from(-1);\n                let py_result = py_result.call_method0(py, \"__neg__\").unwrap();\n\n                // Python -> Rust\n                assert_eq!(py_result.extract::<Integer>(py).unwrap(), rs_result);\n                // Rust -> Python\n                assert!(py_result.bind(py).eq(&rs_result).unwrap());\n            }\n        });\n    }\n\n    /// Test Python class conversion\n    #[test]\n    fn convert_index_class() {\n        prepare_python();\n        Python::with_gil(|py| {\n            let index = python_index_class(py);\n            let locals = PyDict::new(py);\n            locals.set_item(\"index\", &index).unwrap();\n            let expr = c\"index.C(10)\";\n            let ob = py.eval(expr, None, Some(&locals)).unwrap();\n            let integer: Integer = <Integer as FromPyObject>::extract_bound(&ob).unwrap();\n\n            assert_eq!(integer, Integer::from(10));\n\n            let expr2 = c\"index.C(-10)\";\n            let ob2 = py.eval(expr2, None, Some(&locals)).unwrap();\n            let integer2: Integer = <Integer as FromPyObject>::extract_bound(&ob2).unwrap();\n\n            assert_eq!(integer2, Integer::from(-10));\n        });\n    }\n\n    /// Test conversion to and from zero\n    #[test]\n    fn handle_zero() {\n        prepare_python();\n        Python::with_gil(|py| {\n            // Python -> Rust\n            let zero_integer: Integer = 0u8.into_pyobject(py).unwrap().extract().unwrap();\n            assert_eq!(zero_integer, Integer::from(0));\n\n            // Rust -> Python\n            let zero_integer = zero_integer.into_pyobject(py).unwrap();\n            assert!(\n                zero_integer\n                    .as_any()\n                    .eq(0u8.into_py_any(py).unwrap())\n                    .unwrap()\n            );\n        });\n    }\n\n    /// Test for possible overflows\n    #[test]\n    fn check_overflow() {\n        prepare_python();\n        Python::with_gil(|py| {\n            macro_rules! test {\n                ($T:ty, $value:expr, $py:expr) => {\n                    let value = $value;\n                    println!(\"{}: {}\", stringify!($T), value);\n                    let python_value = value.clone().into_pyobject(py).unwrap();\n                    let roundtrip_value =\n                        <$T as FromPyObject>::extract_bound(&python_value).unwrap();\n                    assert_eq!(value, roundtrip_value);\n                };\n            }\n\n            for i in 0..=256usize {\n                // test a lot of values to help catch other bugs too\n                test!(Integer, Integer::from(i), py);\n                test!(Integer, -Integer::from(i), py);\n                test!(Integer, Integer::from(1) << i, py);\n                test!(Integer, -Integer::from(1) << i, py);\n                test!(Integer, (Integer::from(1) << i) + Integer::from(1u32), py);\n                test!(Integer, (-Integer::from(1) << i) + Integer::from(1u32), py);\n                test!(Integer, (Integer::from(1) << i) - Integer::from(1u32), py);\n                test!(Integer, (-Integer::from(1) << i) - Integer::from(1u32), py);\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::{Integer, SerdeInteger};\nuse crate::natural::Natural;\nuse alloc::string::String;\nuse core::convert::TryFrom;\nuse malachite_base::num::conversion::traits::FromStringBase;\n\nimpl From<Integer> for SerdeInteger {\n    #[inline]\n    fn from(x: Integer) -> Self {\n        Self(format!(\"{x:#x}\"))\n    }\n}\n\nimpl TryFrom<SerdeInteger> for Integer {\n    type Error = String;\n\n    #[inline]\n    fn try_from(s: SerdeInteger) -> Result<Self, String> {\n        if s.0.starts_with('-') {\n            if s.0.starts_with(\"-0x\") {\n                Ok(Self::from_sign_and_abs(\n                    false,\n                    Natural::from_string_base(16, &s.0[3..])\n                        .ok_or_else(|| format!(\"Unrecognized digits in {}\", s.0))?,\n                ))\n            } else {\n                Err(format!(\n                    \"String '{}' starts with '-' but not with '-0x'\",\n                    s.0\n                ))\n            }\n        } else if s.0.starts_with(\"0x\") {\n            Ok(Self::from(\n                Natural::from_string_base(16, &s.0[2..])\n                    .ok_or_else(|| format!(\"Unrecognized digits in {}\", s.0))?,\n            ))\n        } else {\n            Err(format!(\n                \"String '{}' does not start with '0x' or '-0x'\",\n                s.0\n            ))\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::conversion::string::from_sci_string::{\n    FromSciStringHelper, from_sci_string_with_options_helper,\n};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::num::conversion::traits::{FromSciString, FromStringBase};\n\nimpl FromSciStringHelper for Integer {\n    fn parse_int(mut cs: &[u8], base: u8) -> Option<Self> {\n        if let Some(b'+') = cs.first() {\n            cs = &cs[1..];\n            // If the string begins with a '+', the second character cannot be '+' or '-'\n            match cs {\n                [] | [b'+' | b'-', ..] => return None,\n                _ => {}\n            }\n        }\n        Self::from_string_base(base, core::str::from_utf8(cs).ok()?)\n    }\n\n    fn up_1(self, neg: bool) -> Option<Self> {\n        Some(if neg {\n            self - Self::ONE\n        } else {\n            self + Self::ONE\n        })\n    }\n}\n\nimpl FromSciString for Integer {\n    /// Converts a string, possibly in scientfic notation, to an [`Integer`].\n    ///\n    /// Use [`FromSciStringOptions`] to specify the base (from 2 to 36, inclusive) and the rounding\n    /// mode, in case rounding is necessary because the string represents a non-integer.\n    ///\n    /// If the base is greater than 10, the higher digits are represented by the letters `'a'`\n    /// through `'z'` or `'A'` through `'Z'`; the case doesn't matter and doesn't need to be\n    /// consistent.\n    ///\n    /// Exponents are allowed, and are indicated using the character `'e'` or `'E'`. If the base is\n    /// 15 or greater, an ambiguity arises where it may not be clear whether `'e'` is a digit or an\n    /// exponent indicator. To resolve this ambiguity, always use a `'+'` or `'-'` sign after the\n    /// exponent indicator when the base is 15 or greater.\n    ///\n    /// The exponent itself is always parsed using base 10.\n    ///\n    /// Decimal (or other-base) points are allowed. These are most useful in conjunction with\n    /// exponents, but they may be used on their own. If the string represents a non-integer, the\n    /// rounding mode specified in `options` is used to round to an integer.\n    ///\n    /// If the string is unparseable, `None` is returned. `None` is also returned if the rounding\n    /// mode in options is `Exact`, but rounding is necessary.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m^n n \\log m (\\log n + \\log\\log m))$\n    ///\n    /// $M(n, m) = O(m^n n \\log m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `s.len()`, and $m$ is `options.base`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::FromSciStringOptions;\n    /// use malachite_base::num::conversion::traits::FromSciString;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from_sci_string(\"123\").unwrap(), 123);\n    /// assert_eq!(Integer::from_sci_string(\"123.5\").unwrap(), 124);\n    /// assert_eq!(Integer::from_sci_string(\"-123.5\").unwrap(), -124);\n    /// assert_eq!(Integer::from_sci_string(\"1.23e10\").unwrap(), 12300000000i64);\n    ///\n    /// let mut options = FromSciStringOptions::default();\n    /// assert_eq!(\n    ///     Integer::from_sci_string_with_options(\"123.5\", options).unwrap(),\n    ///     124\n    /// );\n    ///\n    /// options.set_rounding_mode(Floor);\n    /// assert_eq!(\n    ///     Integer::from_sci_string_with_options(\"123.5\", options).unwrap(),\n    ///     123\n    /// );\n    ///\n    /// options = FromSciStringOptions::default();\n    /// options.set_base(16);\n    /// assert_eq!(\n    ///     Integer::from_sci_string_with_options(\"ff\", options).unwrap(),\n    ///     255\n    /// );\n    /// ```\n    #[inline]\n    fn from_sci_string_with_options(s: &str, options: FromSciStringOptions) -> Option<Self> {\n        from_sci_string_with_options_helper(s, options)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::ops::Neg;\nuse core::str::FromStr;\nuse malachite_base::num::conversion::traits::FromStringBase;\n\nimpl FromStr for Integer {\n    type Err = ();\n\n    /// Converts an string to an [`Integer`].\n    ///\n    /// If the string does not represent a valid [`Integer`], an `Err` is returned. To be valid, the\n    /// string must be nonempty and only contain the [`char`]s `'0'` through `'9'`, with an optional\n    /// leading `'-'`. Leading zeros are allowed, as is the string `\"-0\"`. The string `\"-\"` is not.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from_str(\"123456\").unwrap(), 123456);\n    /// assert_eq!(Integer::from_str(\"00123456\").unwrap(), 123456);\n    /// assert_eq!(Integer::from_str(\"0\").unwrap(), 0);\n    /// assert_eq!(Integer::from_str(\"-123456\").unwrap(), -123456);\n    /// assert_eq!(Integer::from_str(\"-00123456\").unwrap(), -123456);\n    /// assert_eq!(Integer::from_str(\"-0\").unwrap(), 0);\n    ///\n    /// assert!(Integer::from_str(\"\").is_err());\n    /// assert!(Integer::from_str(\"a\").is_err());\n    /// ```\n    #[inline]\n    fn from_str(s: &str) -> Result<Self, ()> {\n        Self::from_string_base(10, s).ok_or(())\n    }\n}\n\nimpl FromStringBase for Integer {\n    /// Converts an string, in a specified base, to an [`Integer`].\n    ///\n    /// If the string does not represent a valid [`Integer`], an `Err` is returned. To be valid, the\n    /// string must be nonempty and only contain the [`char`]s `'0'` through `'9'`, `'a'` through\n    /// `'z'`, and `'A'` through `'Z'`, with an optional single leading `'-'` or `'+'`; and only\n    /// characters that represent digits smaller than the base are allowed. Leading zeros are\n    /// allowed, as is the string `\"-0\"`. The string `\"-\"` is not.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::FromStringBase;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from_string_base(10, \"123456\").unwrap(), 123456);\n    /// assert_eq!(Integer::from_string_base(10, \"00123456\").unwrap(), 123456);\n    /// assert_eq!(Integer::from_string_base(16, \"0\").unwrap(), 0);\n    /// assert_eq!(\n    ///     Integer::from_string_base(16, \"deadbeef\").unwrap(),\n    ///     3735928559i64\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_string_base(16, \"deAdBeEf\").unwrap(),\n    ///     3735928559i64\n    /// );\n    /// assert_eq!(Integer::from_string_base(10, \"-123456\").unwrap(), -123456);\n    /// assert_eq!(Integer::from_string_base(10, \"-00123456\").unwrap(), -123456);\n    /// assert_eq!(Integer::from_string_base(16, \"-0\").unwrap(), 0);\n    /// assert_eq!(\n    ///     Integer::from_string_base(16, \"-deadbeef\").unwrap(),\n    ///     -3735928559i64\n    /// );\n    /// assert_eq!(\n    ///     Integer::from_string_base(16, \"-deAdBeEf\").unwrap(),\n    ///     -3735928559i64\n    /// );\n    ///\n    /// assert!(Integer::from_string_base(10, \"\").is_none());\n    /// assert!(Integer::from_string_base(10, \"a\").is_none());\n    /// assert!(Integer::from_string_base(2, \"2\").is_none());\n    /// assert!(Integer::from_string_base(2, \"-2\").is_none());\n    /// ```\n    #[inline]\n    fn from_string_base(base: u8, s: &str) -> Option<Self> {\n        if let Some(abs_string) = s.strip_prefix('-') {\n            if abs_string.starts_with('+') {\n                None\n            } else {\n                Natural::from_string_base(base, abs_string).map(Neg::neg)\n            }\n        } else {\n            Natural::from_string_base(base, s).map(Self::from)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of [`FromSciString`](malachite_base::num::conversion::traits::FromSciString).\n/// This is a trait for converting strings, possibly using scientific notation, to numbers.\npub mod from_sci_string;\n/// Implementations of [`FromStr`](core::str::FromStr) and of\n/// [`FromStringBase`](malachite_base::num::conversion::traits::FromStringBase), a trait for\n/// converting strings in a specified base to numbers.\npub mod from_string;\n/// Implementations of [`ToSci`](malachite_base::num::conversion::traits::ToSci), a trait for\n/// converting a number to string, possibly using scientific notation.\npub mod to_sci;\n/// Implementations of [`Display`](core::fmt::Display), [`Debug`], [`Binary`](core::fmt::Binary),\n/// [`Octal`](core::fmt::Octal), [`LowerHex`](core::fmt::LowerHex), and\n/// [`UpperHex`](core::fmt::UpperHex), and of the\n/// [`ToStringBase`](malachite_base::num::conversion::traits::ToStringBase) trait, used for\n/// converting numbers to strings.\npub mod to_string;\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::fmt::{Formatter, Write};\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::traits::ToSci;\n\nimpl ToSci for Integer {\n    /// Determines whether an [`Integer`] can be converted to a string using\n    /// [`to_sci`](`Self::to_sci`) and a particular set of options.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::ToSciOptions;\n    /// use malachite_base::num::conversion::traits::ToSci;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut options = ToSciOptions::default();\n    /// assert!(Integer::from(123).fmt_sci_valid(options));\n    /// assert!(Integer::from(u128::MAX).fmt_sci_valid(options));\n    /// // u128::MAX has more than 16 significant digits\n    /// options.set_rounding_mode(Exact);\n    /// assert!(!Integer::from(u128::MAX).fmt_sci_valid(options));\n    /// options.set_precision(50);\n    /// assert!(Integer::from(u128::MAX).fmt_sci_valid(options));\n    /// ```\n    #[inline]\n    fn fmt_sci_valid(&self, options: ToSciOptions) -> bool {\n        self.unsigned_abs_ref().fmt_sci_valid(options)\n    }\n\n    /// Converts an [`Integer`] to a string using a specified base, possibly formatting the number\n    /// using scientific notation.\n    ///\n    /// See [`ToSciOptions`] for details on the available options. Note that setting\n    /// `neg_exp_threshold` has no effect, since there is never a need to use negative exponents\n    /// when representing an [`Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `options.rounding_mode` is `Exact`, but the size options are such that the input\n    /// must be rounded.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::ToSciOptions;\n    /// use malachite_base::num::conversion::traits::ToSci;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(u128::MAX).to_sci().to_string(),\n    ///     \"3.402823669209385e38\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(i128::MIN).to_sci().to_string(),\n    ///     \"-1.701411834604692e38\"\n    /// );\n    ///\n    /// let n = Integer::from(123456u32);\n    /// let mut options = ToSciOptions::default();\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"123456\");\n    ///\n    /// options.set_precision(3);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.23e5\");\n    ///\n    /// options.set_rounding_mode(Ceiling);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.24e5\");\n    ///\n    /// options.set_e_uppercase();\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.24E5\");\n    ///\n    /// options.set_force_exponent_plus_sign(true);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.24E+5\");\n    ///\n    /// options = ToSciOptions::default();\n    /// options.set_base(36);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"2n9c\");\n    ///\n    /// options.set_uppercase();\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"2N9C\");\n    ///\n    /// options.set_base(2);\n    /// options.set_precision(10);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.1110001e16\");\n    ///\n    /// options.set_include_trailing_zeros(true);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.111000100e16\");\n    /// ```\n    fn fmt_sci(&self, f: &mut Formatter, mut options: ToSciOptions) -> core::fmt::Result {\n        let abs = self.unsigned_abs_ref();\n        if *self >= 0u32 {\n            abs.fmt_sci(f, options)\n        } else {\n            options.set_rounding_mode(-options.get_rounding_mode());\n            f.write_char('-')?;\n            abs.fmt_sci(f, options)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::conversion::string::to_string::BaseFmtWrapper;\nuse alloc::string::String;\nuse alloc::string::ToString;\nuse core::fmt::{Binary, Debug, Display, Formatter, LowerHex, Octal, Result, UpperHex, Write};\nuse malachite_base::num::conversion::string::to_string::{\n    digit_to_display_byte_lower, digit_to_display_byte_upper,\n};\nuse malachite_base::num::conversion::traits::{Digits, ToStringBase};\nuse malachite_base::vecs::vec_pad_left;\n\nimpl Display for BaseFmtWrapper<&Integer> {\n    /// Writes a wrapped [`Integer`] to a string using a specified base.\n    ///\n    /// If the base is greater than 10, lowercase alphabetic letters are used by default. Using the\n    /// `#` flag switches to uppercase letters. Padding with zeros works as usual.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\n    ///\n    /// let n = Integer::from(-1000000000);\n    /// let x = BaseFmtWrapper::new(&n, 36);\n    /// assert_eq!(format!(\"{}\", x), \"-gjdgxs\");\n    /// assert_eq!(format!(\"{:#}\", x), \"-GJDGXS\");\n    /// assert_eq!(format!(\"{:010}\", x), \"-000gjdgxs\");\n    /// assert_eq!(format!(\"{:#010}\", x), \"-000GJDGXS\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if !self.x.sign {\n            f.write_char('-')?;\n            if let Some(width) = f.width() {\n                return if f.alternate() {\n                    write!(\n                        f,\n                        \"{:#0width$}\",\n                        &BaseFmtWrapper::new(self.x.unsigned_abs_ref(), self.base),\n                        width = width.saturating_sub(1)\n                    )\n                } else {\n                    write!(\n                        f,\n                        \"{:0width$}\",\n                        &BaseFmtWrapper::new(self.x.unsigned_abs_ref(), self.base),\n                        width = width.saturating_sub(1)\n                    )\n                };\n            }\n        }\n        Display::fmt(\n            &BaseFmtWrapper::new(self.x.unsigned_abs_ref(), self.base),\n            f,\n        )\n    }\n}\n\nimpl Debug for BaseFmtWrapper<&Integer> {\n    /// Writes a wrapped [`Integer`] to a string using a specified base.\n    ///\n    /// If the base is greater than 10, lowercase alphabetic letters are used by default. Using the\n    /// `#` flag switches to uppercase letters. Padding with zeros works as usual.\n    ///\n    /// This is the same as the [`Display::fmt`] implementation.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\n    ///\n    /// let n = Integer::from(-1000000000);\n    /// let x = BaseFmtWrapper::new(&n, 36);\n    /// assert_eq!(format!(\"{:?}\", x), \"-gjdgxs\");\n    /// assert_eq!(format!(\"{:#?}\", x), \"-GJDGXS\");\n    /// assert_eq!(format!(\"{:010?}\", x), \"-000gjdgxs\");\n    /// assert_eq!(format!(\"{:#010?}\", x), \"-000GJDGXS\");\n    /// ```\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n\nimpl ToStringBase for Integer {\n    /// Converts an [`Integer`] to a [`String`] using a specified base.\n    ///\n    /// Digits from 0 to 9 become [`char`]s from `'0'` to `'9'`. Digits from 10 to 35 become the\n    /// lowercase [`char`]s `'a'` to `'z'`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ToStringBase;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(1000).to_string_base(2), \"1111101000\");\n    /// assert_eq!(Integer::from(1000).to_string_base(10), \"1000\");\n    /// assert_eq!(Integer::from(1000).to_string_base(36), \"rs\");\n    ///\n    /// assert_eq!(Integer::from(-1000).to_string_base(2), \"-1111101000\");\n    /// assert_eq!(Integer::from(-1000).to_string_base(10), \"-1000\");\n    /// assert_eq!(Integer::from(-1000).to_string_base(36), \"-rs\");\n    /// ```\n    fn to_string_base(&self, base: u8) -> String {\n        assert!((2..=36).contains(&base), \"base out of range\");\n        if *self == 0 {\n            \"0\".to_string()\n        } else {\n            let mut digits = self.unsigned_abs_ref().to_digits_desc(&base);\n            for digit in &mut digits {\n                *digit = digit_to_display_byte_lower(*digit).unwrap();\n            }\n            if *self < 0 {\n                vec_pad_left(&mut digits, 1, b'-');\n            }\n            String::from_utf8(digits).unwrap()\n        }\n    }\n\n    /// Converts an [`Integer`] to a [`String`] using a specified base.\n    ///\n    /// Digits from 0 to 9 become [`char`]s from `'0'` to `'9'`. Digits from 10 to 35 become the\n    /// uppercase [`char`]s `'A'` to `'Z'`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ToStringBase;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(1000).to_string_base_upper(2), \"1111101000\");\n    /// assert_eq!(Integer::from(1000).to_string_base_upper(10), \"1000\");\n    /// assert_eq!(Integer::from(1000).to_string_base_upper(36), \"RS\");\n    ///\n    /// assert_eq!(Integer::from(-1000).to_string_base_upper(2), \"-1111101000\");\n    /// assert_eq!(Integer::from(-1000).to_string_base_upper(10), \"-1000\");\n    /// assert_eq!(Integer::from(-1000).to_string_base_upper(36), \"-RS\");\n    /// ```\n    fn to_string_base_upper(&self, base: u8) -> String {\n        assert!((2..=36).contains(&base), \"base out of range\");\n        if *self == 0 {\n            \"0\".to_string()\n        } else {\n            let mut digits = self.unsigned_abs_ref().to_digits_desc(&base);\n            for digit in &mut digits {\n                *digit = digit_to_display_byte_upper(*digit).unwrap();\n            }\n            if *self < 0 {\n                vec_pad_left(&mut digits, 1, b'-');\n            }\n            String::from_utf8(digits).unwrap()\n        }\n    }\n}\n\nimpl Display for Integer {\n    /// Converts an [`Integer`] to a [`String`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.to_string(), \"0\");\n    ///\n    /// assert_eq!(Integer::from(123).to_string(), \"123\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000000000\").unwrap().to_string(),\n    ///     \"1000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:05}\", Integer::from(123)), \"00123\");\n    ///\n    /// assert_eq!(Integer::from(-123).to_string(), \"-123\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000\").unwrap().to_string(),\n    ///     \"-1000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:05}\", Integer::from(-123)), \"-0123\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if *self < 0 {\n            f.write_char('-')?;\n            if let Some(width) = f.width() {\n                return write!(\n                    f,\n                    \"{:0width$}\",\n                    self.unsigned_abs_ref(),\n                    width = width.saturating_sub(1)\n                );\n            }\n        }\n        Display::fmt(self.unsigned_abs_ref(), f)\n    }\n}\n\nimpl Debug for Integer {\n    /// Converts an [`Integer`] to a [`String`].\n    ///\n    /// This is the same as the [`Display::fmt`] implementation.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.to_debug_string(), \"0\");\n    ///\n    /// assert_eq!(Integer::from(123).to_debug_string(), \"123\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_debug_string(),\n    ///     \"1000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:05?}\", Integer::from(123)), \"00123\");\n    ///\n    /// assert_eq!(Integer::from(-123).to_debug_string(), \"-123\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000\")\n    ///         .unwrap()\n    ///         .to_debug_string(),\n    ///     \"-1000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:05?}\", Integer::from(-123)), \"-0123\");\n    /// ```\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n\nimpl Binary for Integer {\n    /// Converts an [`Integer`] to a binary [`String`].\n    ///\n    /// Using the `#` format flag prepends `\"0b\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToBinaryString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.to_binary_string(), \"0\");\n    /// assert_eq!(Integer::from(123).to_binary_string(), \"1111011\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_binary_string(),\n    ///     \"1110100011010100101001010001000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:011b}\", Integer::from(123)), \"00001111011\");\n    /// assert_eq!(Integer::from(-123).to_binary_string(), \"-1111011\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000\")\n    ///         .unwrap()\n    ///         .to_binary_string(),\n    ///     \"-1110100011010100101001010001000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:011b}\", Integer::from(-123)), \"-0001111011\");\n    ///\n    /// assert_eq!(format!(\"{:#b}\", Integer::ZERO), \"0b0\");\n    /// assert_eq!(format!(\"{:#b}\", Integer::from(123)), \"0b1111011\");\n    /// assert_eq!(\n    ///     format!(\"{:#b}\", Integer::from_str(\"1000000000000\").unwrap()),\n    ///     \"0b1110100011010100101001010001000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:#011b}\", Integer::from(123)), \"0b001111011\");\n    /// assert_eq!(format!(\"{:#b}\", Integer::from(-123)), \"-0b1111011\");\n    /// assert_eq!(\n    ///     format!(\"{:#b}\", Integer::from_str(\"-1000000000000\").unwrap()),\n    ///     \"-0b1110100011010100101001010001000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:#011b}\", Integer::from(-123)), \"-0b01111011\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if *self < 0 {\n            f.write_char('-')?;\n            if let Some(width) = f.width() {\n                return if f.alternate() {\n                    write!(\n                        f,\n                        \"{:#0width$b}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                } else {\n                    write!(\n                        f,\n                        \"{:0width$b}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                };\n            }\n        }\n        Binary::fmt(self.unsigned_abs_ref(), f)\n    }\n}\n\nimpl Octal for Integer {\n    /// Converts an [`Integer`] to an octal [`String`].\n    ///\n    /// Using the `#` format flag prepends `\"0o\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToOctalString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.to_octal_string(), \"0\");\n    /// assert_eq!(Integer::from(123).to_octal_string(), \"173\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_octal_string(),\n    ///     \"16432451210000\"\n    /// );\n    /// assert_eq!(format!(\"{:07o}\", Integer::from(123)), \"0000173\");\n    /// assert_eq!(Integer::from(-123).to_octal_string(), \"-173\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000\")\n    ///         .unwrap()\n    ///         .to_octal_string(),\n    ///     \"-16432451210000\"\n    /// );\n    /// assert_eq!(format!(\"{:07o}\", Integer::from(-123)), \"-000173\");\n    ///\n    /// assert_eq!(format!(\"{:#o}\", Integer::ZERO), \"0o0\");\n    /// assert_eq!(format!(\"{:#o}\", Integer::from(123)), \"0o173\");\n    /// assert_eq!(\n    ///     format!(\"{:#o}\", Integer::from_str(\"1000000000000\").unwrap()),\n    ///     \"0o16432451210000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07o}\", Integer::from(123)), \"0o00173\");\n    /// assert_eq!(format!(\"{:#o}\", Integer::from(-123)), \"-0o173\");\n    /// assert_eq!(\n    ///     format!(\"{:#o}\", Integer::from_str(\"-1000000000000\").unwrap()),\n    ///     \"-0o16432451210000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07o}\", Integer::from(-123)), \"-0o0173\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if *self < 0 {\n            f.write_char('-')?;\n            if let Some(width) = f.width() {\n                return if f.alternate() {\n                    write!(\n                        f,\n                        \"{:#0width$o}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                } else {\n                    write!(\n                        f,\n                        \"{:0width$o}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                };\n            }\n        }\n        Octal::fmt(self.unsigned_abs_ref(), f)\n    }\n}\n\nimpl LowerHex for Integer {\n    /// Converts an [`Integer`] to a hexadecimal [`String`] using lowercase characters.\n    ///\n    /// Using the `#` format flag prepends `\"0x\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToLowerHexString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.to_lower_hex_string(), \"0\");\n    /// assert_eq!(Integer::from(123).to_lower_hex_string(), \"7b\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_lower_hex_string(),\n    ///     \"e8d4a51000\"\n    /// );\n    /// assert_eq!(format!(\"{:07x}\", Integer::from(123)), \"000007b\");\n    /// assert_eq!(Integer::from(-123).to_lower_hex_string(), \"-7b\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000\")\n    ///         .unwrap()\n    ///         .to_lower_hex_string(),\n    ///     \"-e8d4a51000\"\n    /// );\n    /// assert_eq!(format!(\"{:07x}\", Integer::from(-123)), \"-00007b\");\n    ///\n    /// assert_eq!(format!(\"{:#x}\", Integer::ZERO), \"0x0\");\n    /// assert_eq!(format!(\"{:#x}\", Integer::from(123)), \"0x7b\");\n    /// assert_eq!(\n    ///     format!(\"{:#x}\", Integer::from_str(\"1000000000000\").unwrap()),\n    ///     \"0xe8d4a51000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07x}\", Integer::from(123)), \"0x0007b\");\n    /// assert_eq!(format!(\"{:#x}\", Integer::from(-123)), \"-0x7b\");\n    /// assert_eq!(\n    ///     format!(\"{:#x}\", Integer::from_str(\"-1000000000000\").unwrap()),\n    ///     \"-0xe8d4a51000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07x}\", Integer::from(-123)), \"-0x007b\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if *self < 0 {\n            f.write_char('-')?;\n            if let Some(width) = f.width() {\n                return if f.alternate() {\n                    write!(\n                        f,\n                        \"{:#0width$x}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                } else {\n                    write!(\n                        f,\n                        \"{:0width$x}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                };\n            }\n        }\n        LowerHex::fmt(self.unsigned_abs_ref(), f)\n    }\n}\n\nimpl UpperHex for Integer {\n    /// Converts an [`Integer`] to a hexadecimal [`String`] using uppercase characters.\n    ///\n    /// Using the `#` format flag prepends `\"0x\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToUpperHexString;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.to_upper_hex_string(), \"0\");\n    /// assert_eq!(Integer::from(123).to_upper_hex_string(), \"7B\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_upper_hex_string(),\n    ///     \"E8D4A51000\"\n    /// );\n    /// assert_eq!(format!(\"{:07X}\", Integer::from(123)), \"000007B\");\n    /// assert_eq!(Integer::from(-123).to_upper_hex_string(), \"-7B\");\n    /// assert_eq!(\n    ///     Integer::from_str(\"-1000000000000\")\n    ///         .unwrap()\n    ///         .to_upper_hex_string(),\n    ///     \"-E8D4A51000\"\n    /// );\n    /// assert_eq!(format!(\"{:07X}\", Integer::from(-123)), \"-00007B\");\n    ///\n    /// assert_eq!(format!(\"{:#X}\", Integer::ZERO), \"0x0\");\n    /// assert_eq!(format!(\"{:#X}\", Integer::from(123)), \"0x7B\");\n    /// assert_eq!(\n    ///     format!(\"{:#X}\", Integer::from_str(\"1000000000000\").unwrap()),\n    ///     \"0xE8D4A51000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07X}\", Integer::from(123)), \"0x0007B\");\n    /// assert_eq!(format!(\"{:#X}\", Integer::from(-123)), \"-0x7B\");\n    /// assert_eq!(\n    ///     format!(\"{:#X}\", Integer::from_str(\"-1000000000000\").unwrap()),\n    ///     \"-0xE8D4A51000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07X}\", Integer::from(-123)), \"-0x007B\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if *self < 0 {\n            f.write_char('-')?;\n            if let Some(width) = f.width() {\n                return if f.alternate() {\n                    write!(\n                        f,\n                        \"{:#0width$X}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                } else {\n                    write!(\n                        f,\n                        \"{:0width$X}\",\n                        self.unsigned_abs_ref(),\n                        width = width.saturating_sub(1)\n                    )\n                };\n            }\n        }\n        UpperHex::fmt(self.unsigned_abs_ref(), f)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/conversion/to_twos_complement_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::conversion::to_limbs::LimbIterator;\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::slices::slice_leading_zeros;\n\n// Given the limbs of the absolute value of an `Integer`, in ascending order, returns the two's\n// complement limbs. The input limbs should not be all zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_crate_test! {limbs_twos_complement(xs: &[Limb]) -> Vec<Limb> {\n    let i = slice_leading_zeros(xs);\n    let mut result = vec![0; i];\n    if i != xs.len() {\n        result.push(xs[i].wrapping_neg());\n        for x in &xs[i + 1..] {\n            result.push(!x);\n        }\n    }\n    result\n}}\n\n// Given the limbs of a non-negative `Integer`, in ascending order, checks whether the most\n// significant bit is `false`; if it isn't, appends an extra zero bit. This way the `Integer`'s\n// non-negativity is preserved in its limbs.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {limbs_maybe_sign_extend_non_negative_in_place(xs: &mut Vec<Limb>) {\n    if let Some(last) = xs.last() && last.get_highest_bit() {\n            // Sign-extend with an extra 0 limb to indicate a positive Integer\n            xs.push(0);\n    }\n}}\n\n// Given the limbs of the absolute value of an `Integer`, in ascending order, converts the limbs to\n// two's complement. Returns whether there is a carry left over from the two's complement conversion\n// process.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_crate_test! {limbs_twos_complement_in_place(xs: &mut [Limb]) -> bool {\n    limbs_not_in_place(xs);\n    limbs_slice_add_limb_in_place(xs, 1)\n}}\n\n// Given the limbs of the absolute value of a negative `Integer`, in ascending order, converts the\n// limbs to two's complement and checks whether the most significant bit is `true`; if it isn't,\n// appends an extra `Limb::MAX` bit. This way the `Integer`'s negativity is preserved in its limbs.\n// The limbs cannot be empty or contain only zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` contains only zeros.\npub_test! {limbs_twos_complement_and_maybe_sign_extend_negative_in_place(xs: &mut Vec<Limb>) {\n    assert!(!limbs_twos_complement_in_place(xs));\n    if let Some(last) = xs.last() && !last.get_highest_bit() {\n            // Sign-extend with an extra !0 limb to indicate a negative Integer\n            xs.push(Limb::MAX);\n    }\n}}\n\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct NegativeLimbIterator<'a>(NLIterator<'a>);\n\n// A double-ended iterator over the two's complement [limbs](crate#limbs) of the negative of an\n// [`Integer`].\n//\n// The forward order is ascending (least-significant first). There may be at most one\n// most-significant `Limb::MAX` limb.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\nstruct NLIterator<'a> {\n    pub(crate) limbs: LimbIterator<'a>,\n    first_nonzero_index: Option<usize>,\n}\n\nimpl NLIterator<'_> {\n    fn get_limb(&self, index: u64) -> Limb {\n        let index = usize::exact_from(index);\n        if index >= self.limbs.len() {\n            // We're indexing into the infinite suffix of Limb::MAXs\n            Limb::MAX\n        } else {\n            for i in 0..index {\n                if self.limbs[i] != 0 {\n                    return !self.limbs[index];\n                }\n            }\n            self.limbs[index].wrapping_neg()\n        }\n    }\n}\n\nimpl Iterator for NLIterator<'_> {\n    type Item = Limb;\n\n    // A function to iterate through the two's complement limbs of the negative of a `Natural` in\n    // ascending order (least-significant first).\n    //\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    fn next(&mut self) -> Option<Limb> {\n        let previous_i = self.limbs.i;\n        self.limbs.next().map(|limb| {\n            if let Some(first_nonzero_index) = self.first_nonzero_index {\n                if previous_i <= u64::wrapping_from(first_nonzero_index) {\n                    limb.wrapping_neg()\n                } else {\n                    !limb\n                }\n            } else {\n                if limb != 0 {\n                    self.first_nonzero_index = Some(usize::exact_from(previous_i));\n                }\n                limb.wrapping_neg()\n            }\n        })\n    }\n\n    // A function that returns the length of the negative limbs iterator; that is, the `Natural`'s\n    // negative limb count (this is the same as its limb count). The format is (lower bound,\n    // Option<upper bound>), but in this case it's trivial to always have an exact bound.\n    //\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        self.limbs.size_hint()\n    }\n}\n\nimpl DoubleEndedIterator for NLIterator<'_> {\n    // A function to iterate through the two's complement limbs of the negative of a `Natural` in\n    // descending order (most-significant first). This is worst-case linear since the first\n    // `next_back` call needs to determine the index of the least-significant nonzero limb.\n    //\n    // # Worst-case complexity\n    // $T(n) = O(n)$\n    //\n    // $M(n) = O(1)$\n    //\n    // where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    fn next_back(&mut self) -> Option<Limb> {\n        let previous_j = self.limbs.j;\n        self.limbs.next_back().map(|limb| {\n            if self.first_nonzero_index.is_none() {\n                let mut i = 0;\n                while self.limbs[i] == 0 {\n                    i += 1;\n                }\n                self.first_nonzero_index = Some(i);\n            }\n            let first_nonzero_index = self.first_nonzero_index.unwrap();\n            if previous_j <= u64::wrapping_from(first_nonzero_index) {\n                limb.wrapping_neg()\n            } else {\n                !limb\n            }\n        })\n    }\n}\n\ntrait SignExtendedLimbIterator: DoubleEndedIterator<Item = Limb> {\n    const EXTENSION: Limb;\n\n    fn needs_sign_extension(&self) -> bool;\n\n    fn iterate_forward(&mut self, extension_checked: &mut bool) -> Option<Limb> {\n        let next = self.next();\n        if next.is_none() {\n            if *extension_checked {\n                None\n            } else {\n                *extension_checked = true;\n                if self.needs_sign_extension() {\n                    Some(Self::EXTENSION)\n                } else {\n                    None\n                }\n            }\n        } else {\n            next\n        }\n    }\n\n    fn iterate_backward(&mut self, extension_checked: &mut bool) -> Option<Limb> {\n        if !*extension_checked {\n            *extension_checked = true;\n            if self.needs_sign_extension() {\n                return Some(Self::EXTENSION);\n            }\n        }\n        self.next_back()\n    }\n}\n\nimpl SignExtendedLimbIterator for LimbIterator<'_> {\n    const EXTENSION: Limb = 0;\n\n    fn needs_sign_extension(&self) -> bool {\n        self[self.limb_count - 1].get_highest_bit()\n    }\n}\n\nimpl SignExtendedLimbIterator for NLIterator<'_> {\n    const EXTENSION: Limb = Limb::MAX;\n\n    fn needs_sign_extension(&self) -> bool {\n        let mut i = 0;\n        while self.limbs[i] == 0 {\n            i += 1;\n        }\n        let last_limb_index = self.limbs.limb_count - 1;\n        let last_limb = self.limbs[last_limb_index];\n        let twos_complement_limb = if i == last_limb_index {\n            last_limb.wrapping_neg()\n        } else {\n            !last_limb\n        };\n        !twos_complement_limb.get_highest_bit()\n    }\n}\n\n/// A double-ended iterator over the twos-complement [limbs](crate#limbs) of an [`Integer`].\n///\n/// The forward order is ascending (least-significant first). The most significant bit of the most\n/// significant limb corresponds to the sign of the [`Integer`]; `false` for non-negative and `true`\n/// for negative. This means that there may be a single most-significant sign-extension limb that is\n/// 0 or `Limb::MAX`.\n///\n/// This struct also supports retrieving limbs by index. This functionality is completely\n/// independent of the iterator's state. Indexing the implicit leading limbs is allowed.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub enum TwosComplementLimbIterator<'a> {\n    Zero,\n    Positive(LimbIterator<'a>, bool),\n    Negative(NegativeLimbIterator<'a>, bool),\n}\n\nimpl TwosComplementLimbIterator<'_> {\n    /// A function to retrieve twos-complement [limbs](crate#limbs) by index. Indexing at or above\n    /// the limb count returns zero or `Limb::MAX` limbs, depending on the sign of the `[Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::ZERO.twos_complement_limbs().get_limb(0), 0);\n    ///\n    ///     // 2^64 - 10^12 = 4294967063 * 2^32 + 727379968\n    ///     let negative_trillion = -Integer::from(10u32).pow(12);\n    ///     let limbs = negative_trillion.twos_complement_limbs();\n    ///     assert_eq!(limbs.get_limb(0), 727379968);\n    ///     assert_eq!(limbs.get_limb(1), 4294967063);\n    ///     assert_eq!(limbs.get_limb(2), 4294967295);\n    ///     assert_eq!(limbs.get_limb(100), 4294967295);\n    /// }\n    /// ```\n    pub fn get_limb(&self, index: u64) -> Limb {\n        match self {\n            Self::Zero => 0,\n            Self::Positive(limbs, _) => limbs[usize::exact_from(index)],\n            Self::Negative(limbs, _) => limbs.0.get_limb(index),\n        }\n    }\n}\n\nimpl Iterator for TwosComplementLimbIterator<'_> {\n    type Item = Limb;\n\n    /// A function to iterate through the twos-complement [limbs](crate#limbs) of an [`Integer`] in\n    /// ascending order (least-significant first). The last limb may be a sign-extension limb.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::ZERO.twos_complement_limbs().next(), None);\n    ///\n    ///     // 2^64 - 10^12 = 4294967063 * 2^32 + 727379968\n    ///     let negative_trillion = -Integer::from(10u32).pow(12);\n    ///     let mut limbs = negative_trillion.twos_complement_limbs();\n    ///     assert_eq!(limbs.next(), Some(727379968));\n    ///     assert_eq!(limbs.next(), Some(4294967063));\n    ///     assert_eq!(limbs.next(), None);\n    /// }\n    /// ```\n    fn next(&mut self) -> Option<Limb> {\n        match self {\n            Self::Zero => None,\n            Self::Positive(limbs, extension_checked) => limbs.iterate_forward(extension_checked),\n            Self::Negative(limbs, extension_checked) => limbs.0.iterate_forward(extension_checked),\n        }\n    }\n}\n\nimpl DoubleEndedIterator for TwosComplementLimbIterator<'_> {\n    /// A function to iterate through the twos-complement [limbs](crate#limbs) of an [`Integer`] in\n    /// descending order (most-significant first). The first limb may be a sign-extension limb.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::ZERO.twos_complement_limbs().next_back(), None);\n    ///\n    ///     // 2^64 - 10^12 = 4294967063 * 2^32 + 727379968\n    ///     let negative_trillion = -Integer::from(10u32).pow(12);\n    ///     let mut limbs = negative_trillion.twos_complement_limbs();\n    ///     assert_eq!(limbs.next_back(), Some(4294967063));\n    ///     assert_eq!(limbs.next_back(), Some(727379968));\n    ///     assert_eq!(limbs.next_back(), None);\n    /// }\n    /// ```\n    fn next_back(&mut self) -> Option<Limb> {\n        match self {\n            Self::Zero => None,\n            Self::Positive(limbs, extension_checked) => limbs.iterate_backward(extension_checked),\n            Self::Negative(limbs, extension_checked) => limbs.0.iterate_backward(extension_checked),\n        }\n    }\n}\n\nimpl Natural {\n    /// Returns a double-ended iterator over the two's complement limbs of the negative of a\n    /// [`Natural`]. The forward order is ascending, so that less significant limbs appear first.\n    /// There may be at most one trailing `Limb::MAX` limb going forward, or leading `Limb::MAX`\n    /// limb going backward. The [`Natural`] cannot be zero.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    fn negative_limbs(&self) -> NegativeLimbIterator<'_> {\n        assert_ne!(*self, 0, \"Cannot get negative limbs of 0.\");\n        NegativeLimbIterator(NLIterator {\n            limbs: self.limbs(),\n            first_nonzero_index: None,\n        })\n    }\n}\n\nimpl Integer {\n    /// Returns the [limbs](crate#limbs) of an [`Integer`], in ascending order, so that less\n    /// significant limbs have lower indices in the output vector.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is positive, and if the bit is one it is negative.\n    /// There are no trailing zero limbs if the [`Integer`] is positive or trailing `Limb::MAX`\n    /// limbs if the [`Integer`] is negative, except as necessary to include the correct sign bit.\n    /// Zero is a special case: it contains no limbs.\n    ///\n    /// This function borrows `self`. If taking ownership of `self` is possible,\n    /// [`into_twos_complement_limbs_asc`](`Self::into_twos_complement_limbs_asc`) is more\n    /// efficient.\n    ///\n    /// This function is more efficient than\n    /// [`to_twos_complement_limbs_desc`](`Self::to_twos_complement_limbs_desc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Integer::ZERO.to_twos_complement_limbs_asc().is_empty());\n    ///     assert_eq!(Integer::from(123).to_twos_complement_limbs_asc(), &[123]);\n    ///     assert_eq!(\n    ///         Integer::from(-123).to_twos_complement_limbs_asc(),\n    ///         &[4294967173]\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from(10u32).pow(12).to_twos_complement_limbs_asc(),\n    ///         &[3567587328, 232]\n    ///     );\n    ///     assert_eq!(\n    ///         (-Integer::from(10u32).pow(12)).to_twos_complement_limbs_asc(),\n    ///         &[727379968, 4294967063]\n    ///     );\n    /// }\n    /// ```\n    pub fn to_twos_complement_limbs_asc(&self) -> Vec<Limb> {\n        let mut limbs = self.abs.to_limbs_asc();\n        if self.sign {\n            limbs_maybe_sign_extend_non_negative_in_place(&mut limbs);\n        } else {\n            limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut limbs);\n        }\n        limbs\n    }\n\n    /// Returns the [limbs](crate#limbs) of an [`Integer`], in descending order, so that less\n    /// significant limbs have higher indices in the output vector.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is positive, and if the bit is one it is negative.\n    /// There are no leading zero limbs if the [`Integer`] is non-negative or leading `Limb::MAX`\n    /// limbs if the [`Integer`] is negative, except as necessary to include the correct sign bit.\n    /// Zero is a special case: it contains no limbs.\n    ///\n    /// This is similar to how `BigInteger`s in Java are represented.\n    ///\n    /// This function borrows `self`. If taking ownership of `self` is possible,\n    /// [`into_twos_complement_limbs_desc`](`Self::into_twos_complement_limbs_desc`) is more\n    /// efficient.\n    ///\n    /// This function is less efficient than\n    /// [`to_twos_complement_limbs_asc`](`Self::to_twos_complement_limbs_asc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Integer::ZERO.to_twos_complement_limbs_desc().is_empty());\n    ///     assert_eq!(Integer::from(123).to_twos_complement_limbs_desc(), &[123]);\n    ///     assert_eq!(\n    ///         Integer::from(-123).to_twos_complement_limbs_desc(),\n    ///         &[4294967173]\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from(10u32).pow(12).to_twos_complement_limbs_desc(),\n    ///         &[232, 3567587328]\n    ///     );\n    ///     assert_eq!(\n    ///         (-Integer::from(10u32).pow(12)).to_twos_complement_limbs_desc(),\n    ///         &[4294967063, 727379968]\n    ///     );\n    /// }\n    /// ```\n    pub fn to_twos_complement_limbs_desc(&self) -> Vec<Limb> {\n        let mut xs = self.to_twos_complement_limbs_asc();\n        xs.reverse();\n        xs\n    }\n\n    /// Returns the [limbs](crate#limbs) of an [`Integer`], in ascending order, so that less\n    /// significant limbs have lower indices in the output vector.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is positive, and if the bit is one it is negative.\n    /// There are no trailing zero limbs if the [`Integer`] is positive or trailing `Limb::MAX`\n    /// limbs if the [`Integer`] is negative, except as necessary to include the correct sign bit.\n    /// Zero is a special case: it contains no limbs.\n    ///\n    /// This function takes ownership of `self`. If it's necessary to borrow `self` instead, use\n    /// [`to_twos_complement_limbs_asc`](`Self::to_twos_complement_limbs_asc`).\n    ///\n    /// This function is more efficient than\n    /// [`into_twos_complement_limbs_desc`](`Self::into_twos_complement_limbs_desc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Integer::ZERO.into_twos_complement_limbs_asc().is_empty());\n    ///     assert_eq!(Integer::from(123).into_twos_complement_limbs_asc(), &[123]);\n    ///     assert_eq!(\n    ///         Integer::from(-123).into_twos_complement_limbs_asc(),\n    ///         &[4294967173]\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from(10u32)\n    ///             .pow(12)\n    ///             .into_twos_complement_limbs_asc(),\n    ///         &[3567587328, 232]\n    ///     );\n    ///     assert_eq!(\n    ///         (-Integer::from(10u32).pow(12)).into_twos_complement_limbs_asc(),\n    ///         &[727379968, 4294967063]\n    ///     );\n    /// }\n    /// ```\n    pub fn into_twos_complement_limbs_asc(self) -> Vec<Limb> {\n        let mut xs = self.abs.into_limbs_asc();\n        if self.sign {\n            limbs_maybe_sign_extend_non_negative_in_place(&mut xs);\n        } else {\n            limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut xs);\n        }\n        xs\n    }\n\n    /// Returns the [limbs](crate#limbs) of an [`Integer`], in descending order, so that less\n    /// significant limbs have higher indices in the output vector.\n    ///\n    /// The limbs are in two's complement, and the most significant bit of the limbs indicates the\n    /// sign; if the bit is zero, the [`Integer`] is positive, and if the bit is one it is negative.\n    /// There are no leading zero limbs if the [`Integer`] is non-negative or leading `Limb::MAX`\n    /// limbs if the [`Integer`] is negative, except as necessary to include the correct sign bit.\n    /// Zero is a special case: it contains no limbs.\n    ///\n    /// This is similar to how `BigInteger`s in Java are represented.\n    ///\n    /// This function takes ownership of `self`. If it's necessary to borrow `self` instead, use\n    /// [`to_twos_complement_limbs_desc`](`Self::to_twos_complement_limbs_desc`).\n    ///\n    /// This function is less efficient than\n    /// [`into_twos_complement_limbs_asc`](`Self::into_twos_complement_limbs_asc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Integer::ZERO.into_twos_complement_limbs_desc().is_empty());\n    ///     assert_eq!(Integer::from(123).into_twos_complement_limbs_desc(), &[123]);\n    ///     assert_eq!(\n    ///         Integer::from(-123).into_twos_complement_limbs_desc(),\n    ///         &[4294967173]\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from(10u32)\n    ///             .pow(12)\n    ///             .into_twos_complement_limbs_desc(),\n    ///         &[232, 3567587328]\n    ///     );\n    ///     assert_eq!(\n    ///         (-Integer::from(10u32).pow(12)).into_twos_complement_limbs_desc(),\n    ///         &[4294967063, 727379968]\n    ///     );\n    /// }\n    /// ```\n    pub fn into_twos_complement_limbs_desc(self) -> Vec<Limb> {\n        let mut xs = self.into_twos_complement_limbs_asc();\n        xs.reverse();\n        xs\n    }\n\n    /// Returns a double-ended iterator over the twos-complement [limbs](crate#limbs) of an\n    /// [`Integer`].\n    ///\n    /// The forward order is ascending, so that less significant limbs appear first. There may be a\n    /// most-significant sign-extension limb.\n    ///\n    /// If it's necessary to get a [`Vec`] of all the twos_complement limbs, consider using\n    /// [`to_twos_complement_limbs_asc`](`Self::to_twos_complement_limbs_asc`),\n    /// [`to_twos_complement_limbs_desc`](`Self::to_twos_complement_limbs_desc`),\n    /// [`into_twos_complement_limbs_asc`](`Self::into_twos_complement_limbs_asc`), or\n    /// [`into_twos_complement_limbs_desc`](`Self::into_twos_complement_limbs_desc`) instead.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Integer::ZERO.twos_complement_limbs().next().is_none());\n    ///     assert_eq!(\n    ///         Integer::from(123).twos_complement_limbs().collect_vec(),\n    ///         &[123]\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from(-123).twos_complement_limbs().collect_vec(),\n    ///         &[4294967173]\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from(10u32)\n    ///             .pow(12)\n    ///             .twos_complement_limbs()\n    ///             .collect_vec(),\n    ///         &[3567587328, 232]\n    ///     );\n    ///     // Sign-extension for a non-negative `Integer`\n    ///     assert_eq!(\n    ///         Integer::from(4294967295i64)\n    ///             .twos_complement_limbs()\n    ///             .collect_vec(),\n    ///         &[4294967295, 0]\n    ///     );\n    ///     assert_eq!(\n    ///         (-Integer::from(10u32).pow(12))\n    ///             .twos_complement_limbs()\n    ///             .collect_vec(),\n    ///         &[727379968, 4294967063]\n    ///     );\n    ///     // Sign-extension for a negative `Integer`\n    ///     assert_eq!(\n    ///         (-Integer::from(4294967295i64))\n    ///             .twos_complement_limbs()\n    ///             .collect_vec(),\n    ///         &[1, 4294967295]\n    ///     );\n    ///\n    ///     assert!(Integer::ZERO.twos_complement_limbs().next_back().is_none());\n    ///     assert_eq!(\n    ///         Integer::from(123)\n    ///             .twos_complement_limbs()\n    ///             .rev()\n    ///             .collect_vec(),\n    ///         &[123]\n    ///     );\n    ///     assert_eq!(\n    ///         Integer::from(-123)\n    ///             .twos_complement_limbs()\n    ///             .rev()\n    ///             .collect_vec(),\n    ///         &[4294967173]\n    ///     );\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Integer::from(10u32)\n    ///             .pow(12)\n    ///             .twos_complement_limbs()\n    ///             .rev()\n    ///             .collect_vec(),\n    ///         &[232, 3567587328]\n    ///     );\n    ///     // Sign-extension for a non-negative `Integer`\n    ///     assert_eq!(\n    ///         Integer::from(4294967295i64)\n    ///             .twos_complement_limbs()\n    ///             .rev()\n    ///             .collect_vec(),\n    ///         &[0, 4294967295]\n    ///     );\n    ///     assert_eq!(\n    ///         (-Integer::from(10u32).pow(12))\n    ///             .twos_complement_limbs()\n    ///             .rev()\n    ///             .collect_vec(),\n    ///         &[4294967063, 727379968]\n    ///     );\n    ///     // Sign-extension for a negative `Integer`\n    ///     assert_eq!(\n    ///         (-Integer::from(4294967295i64))\n    ///             .twos_complement_limbs()\n    ///             .rev()\n    ///             .collect_vec(),\n    ///         &[4294967295, 1]\n    ///     );\n    /// }\n    /// ```\n    pub fn twos_complement_limbs(&self) -> TwosComplementLimbIterator<'_> {\n        if *self == 0 {\n            TwosComplementLimbIterator::Zero\n        } else if self.sign {\n            TwosComplementLimbIterator::Positive(self.abs.limbs(), false)\n        } else {\n            TwosComplementLimbIterator::Negative(self.abs.negative_limbs(), false)\n        }\n    }\n\n    /// Returns the number of twos-complement limbs of an [`Integer`]. There may be a\n    /// most-significant sign-extension limb, which is included in the count.\n    ///\n    /// Zero has 0 limbs.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, PowerOf2};\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Integer::ZERO.twos_complement_limb_count(), 0);\n    ///     assert_eq!(Integer::from(123u32).twos_complement_limb_count(), 1);\n    ///     assert_eq!(Integer::from(10u32).pow(12).twos_complement_limb_count(), 2);\n    ///\n    ///     let n = Integer::power_of_2(Limb::WIDTH - 1);\n    ///     assert_eq!((&n - Integer::ONE).twos_complement_limb_count(), 1);\n    ///     assert_eq!(n.twos_complement_limb_count(), 2);\n    ///     assert_eq!((&n + Integer::ONE).twos_complement_limb_count(), 2);\n    ///     assert_eq!((-(&n - Integer::ONE)).twos_complement_limb_count(), 1);\n    ///     assert_eq!((-&n).twos_complement_limb_count(), 1);\n    ///     assert_eq!((-(&n + Integer::ONE)).twos_complement_limb_count(), 2);\n    /// }\n    /// ```\n    pub fn twos_complement_limb_count(&self) -> u64 {\n        if *self == 0 {\n            return 0;\n        }\n        let abs_limbs_count = self.unsigned_abs_ref().limb_count();\n        let highest_bit_of_highest_limb =\n            self.unsigned_abs().limbs()[usize::exact_from(abs_limbs_count - 1)].get_highest_bit();\n        if highest_bit_of_highest_limb\n            && (*self > 0 || (*self < 0 && !self.unsigned_abs_ref().is_power_of_2()))\n        {\n            abs_limbs_count + 1\n        } else {\n            abs_limbs_count\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse core::iter::{Chain, Once, Rev, once};\nuse itertools::{Interleave, Itertools};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\n\n/// Generates all [`Integer`]s in a finite interval, in ascending order.\n///\n/// This `struct` is created by the [`integer_increasing_range`] and\n/// [`integer_increasing_inclusive_range`]; see their documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct IntegerIncreasingRange {\n    a: Integer,\n    b: Integer,\n}\n\nimpl Iterator for IntegerIncreasingRange {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        if self.a == self.b {\n            None\n        } else {\n            let result = self.a.clone();\n            self.a += Integer::ONE;\n            Some(result)\n        }\n    }\n}\n\nimpl DoubleEndedIterator for IntegerIncreasingRange {\n    fn next_back(&mut self) -> Option<Integer> {\n        if self.a == self.b {\n            None\n        } else {\n            self.b -= Integer::ONE;\n            Some(self.b.clone())\n        }\n    }\n}\n\n/// Generates all [`Integer`]s greater than or equal to some [`Integer`], in ascending order.\n///\n/// This `struct` is created by [`integer_increasing_range_to_infinity`]; see its documentation for\n/// more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct IntegerIncreasingRangeToInfinity {\n    a: Integer,\n}\n\nimpl Iterator for IntegerIncreasingRangeToInfinity {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        let result = self.a.clone();\n        self.a += Integer::ONE;\n        Some(result)\n    }\n}\n\n/// Generates all [`Integer`]s less than or equal to some [`Integer`], in ascending order.\n///\n/// This `struct` is created by [`integer_decreasing_range_to_negative_infinity`]; see its\n/// documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct IntegerDecreasingRangeToNegativeInfinity {\n    a: Integer,\n}\n\nimpl Iterator for IntegerDecreasingRangeToNegativeInfinity {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        let result = self.a.clone();\n        self.a -= Integer::ONE;\n        Some(result)\n    }\n}\n\n/// Generates all [`Integer`]s in a finite interval, in order of increasing absolute value.\n///\n/// This `struct` is created [`exhaustive_integer_range`] and\n/// [`exhaustive_integer_inclusive_range`]; see their documentation for more.\n#[derive(Clone, Debug)]\npub enum ExhaustiveIntegerRange {\n    NonNegative(IntegerIncreasingRange),\n    NonPositive(Rev<IntegerIncreasingRange>),\n    BothSigns(\n        Chain<Once<Integer>, Interleave<IntegerIncreasingRange, Rev<IntegerIncreasingRange>>>,\n    ),\n}\n\nimpl Iterator for ExhaustiveIntegerRange {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        match self {\n            Self::NonNegative(xs) => xs.next(),\n            Self::NonPositive(xs) => xs.next(),\n            Self::BothSigns(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates all [`Integer`]s greater than or equal to some [`Integer`], in order of increasing\n/// absolute value.\n///\n/// This `struct` is created by [`exhaustive_integer_range_to_infinity`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub enum ExhaustiveIntegerRangeToInfinity {\n    NonNegative(IntegerIncreasingRangeToInfinity),\n    BothSigns(\n        Chain<\n            Once<Integer>,\n            Interleave<IntegerIncreasingRangeToInfinity, Rev<IntegerIncreasingRange>>,\n        >,\n    ),\n}\n\nimpl Iterator for ExhaustiveIntegerRangeToInfinity {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        match self {\n            Self::NonNegative(xs) => xs.next(),\n            Self::BothSigns(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates all [`Integer`]s less than or equal to some [`Integer`], in order of increasing\n/// absolute value.\n///\n/// This `struct` is created by [`exhaustive_integer_range_to_negative_infinity`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub enum ExhaustiveIntegerRangeToNegativeInfinity {\n    NonPositive(IntegerDecreasingRangeToNegativeInfinity),\n    BothSigns(\n        Chain<\n            Once<Integer>,\n            Interleave<IntegerIncreasingRange, IntegerDecreasingRangeToNegativeInfinity>,\n        >,\n    ),\n}\n\nimpl Iterator for ExhaustiveIntegerRangeToNegativeInfinity {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        match self {\n            Self::NonPositive(xs) => xs.next(),\n            Self::BothSigns(xs) => xs.next(),\n        }\n    }\n}\n\n#[doc(hidden)]\npub type IntegerUpDown =\n    Interleave<IntegerIncreasingRangeToInfinity, IntegerDecreasingRangeToNegativeInfinity>;\n\n/// Generates all [`Integer`]s, in order of increasing absolute value. When two [`Integer`]s have\n/// the same absolute value, the positive one comes first.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(1)$, amortized.\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::exhaustive_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_integers(), 10),\n///     \"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_integers() -> Chain<Once<Integer>, IntegerUpDown> {\n    once(Integer::ZERO).chain(exhaustive_nonzero_integers())\n}\n\n/// Generates all natural [`Integer`]s in ascending order.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(1)$, amortized.\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::exhaustive_natural_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_natural_integers(), 10),\n///     \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn exhaustive_natural_integers() -> IntegerIncreasingRangeToInfinity {\n    integer_increasing_range_to_infinity(Integer::ZERO)\n}\n\n/// Generates all positive [`Integer`]s in ascending order.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(1)$, amortized.\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::exhaustive_positive_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_positive_integers(), 10),\n///     \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn exhaustive_positive_integers() -> IntegerIncreasingRangeToInfinity {\n    integer_increasing_range_to_infinity(Integer::ONE)\n}\n\n/// Generates all negative [`Integer`]s in descending order.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(1)$, amortized.\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::exhaustive_negative_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_negative_integers(), 10),\n///     \"[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn exhaustive_negative_integers() -> IntegerDecreasingRangeToNegativeInfinity {\n    integer_decreasing_range_to_negative_infinity(Integer::NEGATIVE_ONE)\n}\n\n/// Generates all nonzero [`Integer`]s, in order of increasing absolute value. When two [`Integer`]s\n/// have the same absolute value, the positive one comes first.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(1)$, amortized.\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::exhaustive_nonzero_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_nonzero_integers(), 10),\n///     \"[1, -1, 2, -2, 3, -3, 4, -4, 5, -5, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_nonzero_integers() -> IntegerUpDown {\n    exhaustive_positive_integers().interleave(exhaustive_negative_integers())\n}\n\n/// Generates all [`Integer`]s in the half-open interval $[a, b)$, in ascending order.\n///\n/// $a$ must be less than or equal to $b$. If $a$ and $b$ are equal, the range is empty. To generate\n/// all [`Integer`]s in an infinite interval in ascending or descending order, use\n/// [`integer_increasing_range_to_infinity`] or [`integer_decreasing_range_to_negative_infinity`].\n///\n/// The output is $(k)_{k=a}^{b-1}$.\n///\n/// The output length is $b - a$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the previously-generated value is positive and its\n/// least-significant limb is `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::exhaustive::integer_increasing_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     integer_increasing_range(Integer::from(-4), Integer::from(4))\n///         .collect_vec()\n///         .to_debug_string(),\n///     \"[-4, -3, -2, -1, 0, 1, 2, 3]\"\n/// )\n/// ```\n#[inline]\npub fn integer_increasing_range(a: Integer, b: Integer) -> IntegerIncreasingRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    IntegerIncreasingRange { a, b }\n}\n\n/// Generates all [`Integer`]s in the closed interval $[a, b]$, in ascending order.\n///\n/// $a$ must be less than or equal to $b$. If $a$ and $b$ are equal, the range contains a single\n/// element. To generate all [`Integer`]s in an infinite interval in ascending or descending order,\n/// use [`integer_increasing_range_to_infinity`] or\n/// [`integer_decreasing_range_to_negative_infinity`].\n///\n/// The output is $(k)_{k=a}^{b}$.\n///\n/// The output length is $b - a + 1$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the previously-generated value is positive and its\n/// least-significant limb is `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::exhaustive::integer_increasing_inclusive_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     integer_increasing_inclusive_range(Integer::from(-4), Integer::from(4))\n///         .collect_vec()\n///         .to_debug_string(),\n///     \"[-4, -3, -2, -1, 0, 1, 2, 3, 4]\"\n/// )\n/// ```\n#[inline]\npub fn integer_increasing_inclusive_range(a: Integer, b: Integer) -> IntegerIncreasingRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    IntegerIncreasingRange {\n        a,\n        b: b + Integer::ONE,\n    }\n}\n\n/// Generates all [`Integer`]s greater than or equal to some number $a$, in ascending order.\n///\n/// The output is $(k)_{k=a}^{\\infty}$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the previously-generated value is positive and its\n/// least-significant limb is `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::integer_increasing_range_to_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(integer_increasing_range_to_infinity(Integer::from(-4)), 10),\n///     \"[-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn integer_increasing_range_to_infinity(a: Integer) -> IntegerIncreasingRangeToInfinity {\n    IntegerIncreasingRangeToInfinity { a }\n}\n\n/// Generates all [`Integer`]s less than or equal to some number $a$, in descending order.\n///\n/// The output is $(-k)_{k=-a}^{\\infty}$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the previously-generated value is negative and the\n/// least-significant limb of its absolute value is `Limb::MAX`, the worst case space and time\n/// complexities are constant.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::integer_decreasing_range_to_negative_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         integer_decreasing_range_to_negative_infinity(Integer::from(4)),\n///         10\n///     ),\n///     \"[4, 3, 2, 1, 0, -1, -2, -3, -4, -5, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn integer_decreasing_range_to_negative_infinity(\n    a: Integer,\n) -> IntegerDecreasingRangeToNegativeInfinity {\n    IntegerDecreasingRangeToNegativeInfinity { a }\n}\n\n/// Generates all [`Integer`]s in the half-open interval $[a, b)$, in order of increasing absolute\n/// value.\n///\n/// When two [`Integer`]s have the same absolute value, the positive one comes first. $a$ must be\n/// less than or equal to $b$. If $a$ and $b$ are equal, the range is empty.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i, j \\\\in [0, b - a)$ and $i < j$.\n///\n/// The output length is $b - a$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the least-significant limb of the absolute value of the\n/// previously-generated value is `Limb::MAX`, the worst case space and time complexities are\n/// constant.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::exhaustive::exhaustive_integer_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     exhaustive_integer_range(Integer::from(-4), Integer::from(4))\n///         .collect_vec()\n///         .to_debug_string(),\n///     \"[0, 1, -1, 2, -2, 3, -3, -4]\"\n/// )\n/// ```\npub fn exhaustive_integer_range(a: Integer, b: Integer) -> ExhaustiveIntegerRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    if a >= 0 {\n        ExhaustiveIntegerRange::NonNegative(integer_increasing_range(a, b))\n    } else if b <= 0 {\n        ExhaustiveIntegerRange::NonPositive(integer_increasing_range(a, b).rev())\n    } else {\n        ExhaustiveIntegerRange::BothSigns(\n            once(Integer::ZERO).chain(\n                integer_increasing_range(Integer::ONE, b)\n                    .interleave(integer_increasing_range(a, Integer::ZERO).rev()),\n            ),\n        )\n    }\n}\n\n/// Generates all [`Integer`]s in the closed interval $[a, b]$, in order of increasing absolute\n/// value.\n///\n/// When two [`Integer`]s have the same absolute value, the positive one comes first. $a$ must be\n/// less than or equal to $b$. If $a$ and $b$ are equal, the range contains a single element.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i, j \\\\in [0, b - a]$ and $i < j$.\n///\n/// The output length is $b - a + 1$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the least-significant limb of the absolute value of the\n/// previously-generated value is `Limb::MAX`, the worst case space and time complexities are\n/// constant.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::integer::exhaustive::exhaustive_integer_inclusive_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     exhaustive_integer_inclusive_range(Integer::from(-4), Integer::from(4))\n///         .collect_vec()\n///         .to_debug_string(),\n///     \"[0, 1, -1, 2, -2, 3, -3, 4, -4]\"\n/// )\n/// ```\npub fn exhaustive_integer_inclusive_range(a: Integer, b: Integer) -> ExhaustiveIntegerRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    if a >= 0 {\n        ExhaustiveIntegerRange::NonNegative(integer_increasing_inclusive_range(a, b))\n    } else if b <= 0 {\n        ExhaustiveIntegerRange::NonPositive(integer_increasing_inclusive_range(a, b).rev())\n    } else {\n        ExhaustiveIntegerRange::BothSigns(\n            once(Integer::ZERO).chain(\n                integer_increasing_inclusive_range(Integer::ONE, b)\n                    .interleave(integer_increasing_inclusive_range(a, Integer::NEGATIVE_ONE).rev()),\n            ),\n        )\n    }\n}\n\n/// Generates all [`Integer`]s greater than or equal to some number $a$, in order of increasing\n/// absolute value.\n///\n/// When two [`Integer`]s have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i < j$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the previously-generated value is positive and its\n/// least-significant limb is `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::exhaustive_integer_range_to_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_integer_range_to_infinity(Integer::from(-2)), 10),\n///     \"[0, 1, -1, 2, -2, 3, 4, 5, 6, 7, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_integer_range_to_infinity(a: Integer) -> ExhaustiveIntegerRangeToInfinity {\n    if a >= 0 {\n        ExhaustiveIntegerRangeToInfinity::NonNegative(integer_increasing_range_to_infinity(a))\n    } else {\n        ExhaustiveIntegerRangeToInfinity::BothSigns(\n            once(Integer::ZERO).chain(\n                integer_increasing_range_to_infinity(Integer::ONE)\n                    .interleave(integer_increasing_range(a, Integer::ZERO).rev()),\n            ),\n        )\n    }\n}\n\n/// Generates all [`Integer`]s less than or equal to some number $a$, in order of increasing\n/// absolute value.\n///\n/// When two [`Integer`]s have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i < j$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the the previously-generated value is positive and its\n/// least-significant limb is `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::integer::exhaustive::exhaustive_integer_range_to_negative_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_integer_range_to_negative_infinity(Integer::from(2)),\n///         10\n///     ),\n///     \"[0, 1, -1, 2, -2, -3, -4, -5, -6, -7, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_integer_range_to_negative_infinity(\n    a: Integer,\n) -> ExhaustiveIntegerRangeToNegativeInfinity {\n    if a <= 0 {\n        ExhaustiveIntegerRangeToNegativeInfinity::NonPositive(\n            integer_decreasing_range_to_negative_infinity(a),\n        )\n    } else {\n        ExhaustiveIntegerRangeToNegativeInfinity::BothSigns(once(Integer::ZERO).chain(\n            integer_increasing_range(Integer::ONE, a + Integer::ONE).interleave(\n                integer_decreasing_range_to_negative_infinity(Integer::NEGATIVE_ONE),\n            ),\n        ))\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2003, 2005, 2012, 2015-2018 Free\n//      Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{limbs_add_limb_to_out, limbs_slice_add_limb_in_place};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, max};\nuse core::ops::{BitAnd, BitAndAssign};\nuse malachite_base::num::arithmetic::traits::WrappingNegAssign;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::NotAssign;\nuse malachite_base::slices::{slice_leading_zeros, slice_set_zero};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of an `Integer`, returns the\n// limbs of the bitwise and of the `Integer` and a negative number whose lowest limb is given by `y`\n// and whose other limbs are full of `true` bits. `xs` may not be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_pos_and_limb_neg(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    let mut out = xs.to_vec();\n    out[0] &= y;\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of an `Integer`, writes the\n// limbs of the bitwise and of the `Integer` and a negative number whose lowest limb is given by `y`\n// and whose other limbs are full of `true` bits, to an output slice. `xs` may not be empty. The\n// output slice must be at least as long as the input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or if `out` is shorter than `xs`.\npub_test! {limbs_pos_and_limb_neg_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) {\n    let len = xs.len();\n    assert!(out.len() >= len);\n    let (xs_head, xs_tail) = xs.split_first().unwrap();\n    let (out_head, out_tail) = out[..len].split_first_mut().unwrap();\n    *out_head = xs_head & y;\n    out_tail.copy_from_slice(xs_tail);\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of an `Integer`, writes the\n// limbs of the bitwise and of the `Integer` and a negative number whose lowest limb is given by `y`\n// and whose other limbs are full of `true` bits, to the input slice. `xs` may not be empty.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_pos_and_limb_neg_in_place(xs: &mut [Limb], ys: Limb) {\n    xs[0] &= ys;\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, returns the limbs of the bitwise and of the `Integer` and a negative number whose\n// lowest limb is given by `y` and whose other limbs are full of `true` bits. `xs` may not be empty\n// or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_neg_and_limb_neg(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    let mut out = xs.to_vec();\n    limbs_vec_neg_and_limb_neg_in_place(&mut out, y);\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, writes the limbs of the bitwise and of the `Integer` and a negative number whose\n// lowest limb is given by `y` and whose other limbs are full of `true` bits to an output slice.\n// `xs` may not be empty or only contain zeros. Returns whether a carry occurs. The output slice\n// must be at least as long as the input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or if `out` is shorter than `xs`.\npub_test! {limbs_neg_and_limb_neg_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) -> bool {\n    let out = &mut out[..xs.len()];\n    if xs[0] == 0 {\n        out.copy_from_slice(xs);\n        false\n    } else {\n        let (xs_head, xs_tail) = xs.split_first().unwrap();\n        let (out_head, out_tail) = out.split_first_mut().unwrap();\n        let result_head = xs_head.wrapping_neg() & y;\n        if result_head == 0 {\n            *out_head = 0;\n            limbs_add_limb_to_out(out_tail, xs_tail, 1)\n        } else {\n            *out_head = result_head.wrapping_neg();\n            out_tail.copy_from_slice(xs_tail);\n            false\n        }\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, takes the bitwise and of the `Integer` and a negative number whose lowest limb is\n// given by `y` and whose other limbs are full of `true` bits, in place. `xs` may not be empty or\n// only contain zeros. Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_slice_neg_and_limb_neg_in_place(xs: &mut [Limb], y: Limb) -> bool {\n    let (xs_head, xs_tail) = xs.split_first_mut().unwrap();\n    if *xs_head == 0 {\n        false\n    } else {\n        *xs_head = xs_head.wrapping_neg() & y;\n        if *xs_head == 0 {\n            limbs_slice_add_limb_in_place(xs_tail, 1)\n        } else {\n            xs_head.wrapping_neg_assign();\n            false\n        }\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, takes the bitwise and of the `Integer` and a negative number whose lowest limb is\n// given by `y` and whose other limbs are full of `true` bits, in place. `xs` may not be empty or\n// only contain zeros. If there is a carry, increases the length of the `Vec` by 1.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_vec_neg_and_limb_neg_in_place(xs: &mut Vec<Limb>, y: Limb) {\n    if limbs_slice_neg_and_limb_neg_in_place(xs, y) {\n        xs.push(1);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, returns the limbs of the bitwise and of the `Integer`s. `xs` and `ys` may\n// not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res` is returned, the first\n// input is positive, and the second is negative.\npub_test! {limbs_and_pos_neg(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        return Vec::new();\n    } else if x_i >= ys_len {\n        return xs.to_vec();\n    }\n    let max_i = max(x_i, y_i);\n    let mut out = vec![0; max_i];\n    out.push(\n        xs[max_i]\n            & if x_i <= y_i {\n                ys[max_i].wrapping_neg()\n            } else {\n                !ys[max_i]\n            },\n    );\n    out.extend(\n        xs[max_i + 1..]\n            .iter()\n            .zip(ys[max_i + 1..].iter())\n            .map(|(&x, &y)| x & !y),\n    );\n    if xs_len > ys_len {\n        out.extend_from_slice(&xs[ys_len..]);\n    }\n    out\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise and of the `Integer`s to an output slice.\n// `xs` and `ys` may not be empty or only contain zeros. The output slice must be at least as long\n// as the first input slice. `xs.len()` limbs will be written; if the number of significant limbs of\n// the result is lower, some of the written limbs will be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros, or if `out` is shorter than `xs`.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where the first input is positive\n// and the second is negative.\npub_test! {limbs_and_pos_neg_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(out.len() >= xs_len);\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        slice_set_zero(&mut out[..xs_len]);\n        return;\n    } else if x_i >= ys_len {\n        out[..xs_len].copy_from_slice(xs);\n        return;\n    }\n    let max_i = max(x_i, y_i);\n    slice_set_zero(&mut out[..max_i]);\n    out[max_i] = xs[max_i]\n        & if x_i <= y_i {\n            ys[max_i].wrapping_neg()\n        } else {\n            !ys[max_i]\n        };\n    for (z, (x, y)) in out[max_i + 1..]\n        .iter_mut()\n        .zip(xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter()))\n    {\n        *z = x & !y;\n    }\n    if xs_len > ys_len {\n        out[ys_len..xs_len].copy_from_slice(&xs[ys_len..]);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise and of the `Integer`s to the first (left)\n// slice. `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res == op1`, the first input\n// is positive, and the second is negative.\npub_test! {limbs_and_pos_neg_in_place_left(xs: &mut [Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        slice_set_zero(xs);\n        return;\n    } else if x_i >= ys_len {\n        return;\n    }\n    let max_i = max(x_i, y_i);\n    slice_set_zero(&mut xs[..max_i]);\n    xs[max_i] &= if x_i <= y_i {\n        ys[max_i].wrapping_neg()\n    } else {\n        !ys[max_i]\n    };\n    for (x, y) in xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..].iter()) {\n        *x &= !y;\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the lowest min(`xs.len()`, `ys.len()`) limbs of the bitwise and of\n// the `Integer`s to the second (right) slice. `xs` and `ys` may not be empty or only contain zeros.\n// If `ys` is shorter than `xs`, the result may be too long to fit in `ys`. The extra limbs in this\n// case are just `xs[ys.len()..]`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res == op2`, the first input\n// is positive, the second is negative, and the length of `op2` is not changed; instead, a carry is\n// returned.\npub_test! {limbs_slice_and_pos_neg_in_place_right(xs: &[Limb], ys: &mut [Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len || x_i >= ys_len {\n        slice_set_zero(ys);\n        return;\n    }\n    let max_i = max(x_i, y_i);\n    slice_set_zero(&mut ys[..max_i]);\n    {\n        let ys_max_i = &mut ys[max_i];\n        if x_i <= y_i {\n            ys_max_i.wrapping_neg_assign();\n        } else {\n            ys_max_i.not_assign();\n        }\n        *ys_max_i &= xs[max_i];\n    }\n    for (x, y) in xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter_mut()) {\n        *y = !*y & x;\n    }\n}}\n\n// Interpreting a slice of `Limb`s and a `Vec` of `Limb`s as the limbs (in ascending order) of one\n// `Integer` and the negative of another, writes the limbs of the bitwise and of the `Integer`s to\n// the `Vec`. `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res == op2`, the first input\n// is positive, and the second is negative.\npub_test! {limbs_vec_and_pos_neg_in_place_right(xs: &[Limb], ys: &mut Vec<Limb>) {\n    limbs_slice_and_pos_neg_in_place_right(xs, ys);\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    match xs_len.cmp(&ys_len) {\n        Greater => {\n            let ys_len = ys.len();\n            ys.extend(xs[ys_len..].iter());\n        }\n        Less => {\n            ys.truncate(xs_len);\n        }\n        _ => {}\n    }\n}}\n\nconst fn limbs_and_neg_neg_helper(input: Limb, boundary_limb_seen: &mut bool) -> Limb {\n    if *boundary_limb_seen {\n        input\n    } else {\n        let result = input.wrapping_add(1);\n        if result != 0 {\n            *boundary_limb_seen = true;\n        }\n        result\n    }\n}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, returns the limbs of the bitwise and of the `Integer`s. `xs` and `ys` may not be\n// empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res` is returned and both\n// inputs are negative.\npub_test! {limbs_and_neg_neg(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        return ys.to_vec();\n    } else if x_i >= ys_len {\n        return xs.to_vec();\n    }\n    let max_i = max(x_i, y_i);\n    let mut out = vec![0; max_i];\n    let x = if x_i >= y_i {\n        xs[max_i].wrapping_sub(1)\n    } else {\n        xs[max_i]\n    };\n    let y = if x_i <= y_i {\n        ys[max_i].wrapping_sub(1)\n    } else {\n        ys[max_i]\n    };\n    let mut boundary_limb_seen = false;\n    out.push(limbs_and_neg_neg_helper(x | y, &mut boundary_limb_seen));\n    let xys = xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter());\n    if boundary_limb_seen {\n        out.extend(xys.map(|(&x, &y)| x | y));\n    } else {\n        for (&x, &y) in xys {\n            out.push(limbs_and_neg_neg_helper(x | y, &mut boundary_limb_seen));\n        }\n    }\n    if xs_len != ys_len {\n        let zs = if xs_len > ys_len {\n            &xs[ys_len..]\n        } else {\n            &ys[xs_len..]\n        };\n        if boundary_limb_seen {\n            out.extend_from_slice(zs);\n        } else {\n            for &z in zs {\n                out.push(limbs_and_neg_neg_helper(z, &mut boundary_limb_seen));\n            }\n        }\n    }\n    if !boundary_limb_seen {\n        out.push(1);\n    }\n    out\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the max(`xs.len()`, `ys.len()`) limbs of the bitwise and of the `Integer`s to\n// an output slice. `xs` and `ys` may not be empty or only contain zeros. Returns whether the\n// least-significant max(`xs.len()`, `ys.len()`) limbs of the output are not all zero. The output\n// slice must be at least as long as the longer input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros, or if `out` is shorter than the longer of\n// `xs` and `ys`.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where both inputs are negative.\npub_test! {limbs_and_neg_neg_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        out[..ys_len].copy_from_slice(ys);\n        if xs_len > ys_len {\n            slice_set_zero(&mut out[ys_len..xs_len]);\n        }\n        return true;\n    } else if x_i >= ys_len {\n        out[..xs_len].copy_from_slice(xs);\n        if ys_len > xs_len {\n            slice_set_zero(&mut out[xs_len..ys_len]);\n        }\n        return true;\n    }\n    let max_i = max(x_i, y_i);\n    slice_set_zero(&mut out[..max_i]);\n    let x = if x_i >= y_i {\n        xs[max_i].wrapping_sub(1)\n    } else {\n        xs[max_i]\n    };\n    let y = if x_i <= y_i {\n        ys[max_i].wrapping_sub(1)\n    } else {\n        ys[max_i]\n    };\n    let mut boundary_limb_seen = false;\n    out[max_i] = limbs_and_neg_neg_helper(x | y, &mut boundary_limb_seen);\n    let xys = xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter());\n    if boundary_limb_seen {\n        for (z, (x, y)) in out[max_i + 1..].iter_mut().zip(xys) {\n            *z = x | y;\n        }\n    } else {\n        for (z, (x, y)) in out[max_i + 1..].iter_mut().zip(xys) {\n            *z = limbs_and_neg_neg_helper(x | y, &mut boundary_limb_seen);\n        }\n    }\n    let (xs, xs_len, ys_len) = if xs_len >= ys_len {\n        (xs, xs_len, ys_len)\n    } else {\n        (ys, ys_len, xs_len)\n    };\n    if xs_len != ys_len {\n        let zs = &xs[ys_len..];\n        if boundary_limb_seen {\n            out[ys_len..xs_len].copy_from_slice(zs);\n        } else {\n            for (z_out, &z_in) in out[ys_len..xs_len].iter_mut().zip(zs.iter()) {\n                *z_out = limbs_and_neg_neg_helper(z_in, &mut boundary_limb_seen);\n            }\n        }\n    }\n    boundary_limb_seen\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the lower `xs.len()` limbs of the bitwise and of the `Integer`s to the first\n// (left) slice. `xs` and `ys` may not be empty or only contain zeros, and `xs` must be at least as\n// long as `ys`. Returns whether the least-significant `xs.len()` limbs of the output are not all\n// zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros, or if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res == op1`, both inputs are\n// negative, and the length of `op1` is not changed; instead, a carry is returned.\npub_test! {limbs_slice_and_neg_neg_in_place_left(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if x_i >= ys_len {\n        return true;\n    }\n    let max_i = max(x_i, y_i);\n    if y_i > x_i {\n        slice_set_zero(&mut xs[x_i..y_i]);\n    }\n    let x = if x_i >= y_i {\n        xs[max_i].wrapping_sub(1)\n    } else {\n        xs[max_i]\n    };\n    let y = if x_i <= y_i {\n        ys[max_i].wrapping_sub(1)\n    } else {\n        ys[max_i]\n    };\n    let mut boundary_limb_seen = false;\n    xs[max_i] = limbs_and_neg_neg_helper(x | y, &mut boundary_limb_seen);\n    let xys = xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..].iter());\n    if boundary_limb_seen {\n        for (x, &y) in xys {\n            *x |= y;\n        }\n    } else {\n        for (x, &y) in xys {\n            *x = limbs_and_neg_neg_helper(*x | y, &mut boundary_limb_seen);\n        }\n    }\n    if xs_len > ys_len && !boundary_limb_seen {\n        for x in &mut xs[ys_len..] {\n            *x = limbs_and_neg_neg_helper(*x, &mut boundary_limb_seen);\n        }\n    }\n    boundary_limb_seen\n}}\n\n// Interpreting a slice of `Limb`s and a `Vec` of `Limb`s as the limbs (in ascending order) of the\n// negatives of two `Integer`s, writes the limbs of the bitwise and of the `Integer`s to the `Vec`.\n// `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res == op1` and both inputs\n// are negative.\npub_test! {limbs_vec_and_neg_neg_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let y_i = slice_leading_zeros(ys);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        xs.resize(ys_len, 0);\n        xs.copy_from_slice(ys);\n        return;\n    }\n    let boundary_limb_seen = if ys_len > xs_len {\n        let mut boundary_limb_seen = limbs_slice_and_neg_neg_in_place_left(xs, &ys[..xs_len]);\n        let zs = &ys[xs_len..];\n        if boundary_limb_seen {\n            xs.extend_from_slice(zs);\n        } else {\n            for &z in zs {\n                xs.push(limbs_and_neg_neg_helper(z, &mut boundary_limb_seen));\n            }\n        }\n        boundary_limb_seen\n    } else {\n        limbs_slice_and_neg_neg_in_place_left(xs, ys)\n    };\n    if !boundary_limb_seen {\n        xs.push(1);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the lower max(`xs.len()`, `ys.len()`) limbs of the bitwise and of the\n// `Integer`s to the longer slice (or the first one, if they are equally long). `xs` and `ys` may\n// not be empty or only contain zeros. Returns a pair of `bool`s. The first is `false` when the\n// output is to the first slice and `true` when it's to the second slice, and the second is whether\n// the least-significant max(`xs.len()`, `ys.len()`) limbs of the output are not all zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where both inputs are negative, the\n// result is written to the longer input slice, and the length of `op1` is not changed; instead, a\n// carry is returned.\npub_test! {limbs_slice_and_neg_neg_in_place_either(\n    xs: &mut [Limb],\n    ys: &mut [Limb]\n) -> (bool, bool) {\n    if xs.len() >= ys.len() {\n        (false, limbs_slice_and_neg_neg_in_place_left(xs, ys))\n    } else {\n        (true, limbs_slice_and_neg_neg_in_place_left(ys, xs))\n    }\n}}\n\n// Interpreting two `Vec`s of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the limbs of the bitwise and of the `Integer`s to the longer `Vec` (or the\n// first one, if they are equally long). `xs` and `ys` may not be empty or only contain zeros.\n// Returns a `bool` which is `false` when the output is to the first slice and `true` when it's to\n// the second slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where both inputs are negative and\n// the result is written to the longer input slice.\npub_test! {limbs_vec_and_neg_neg_in_place_either(xs: &mut Vec<Limb>, ys: &mut Vec<Limb>) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_vec_and_neg_neg_in_place_left(xs, ys);\n        false\n    } else {\n        limbs_vec_and_neg_neg_in_place_left(ys, xs);\n        true\n    }\n}}\n\nimpl Natural {\n    fn and_assign_pos_limb_neg(&mut self, other: Limb) {\n        match self {\n            Self(Small(small)) => *small &= other,\n            Self(Large(limbs)) => limbs_pos_and_limb_neg_in_place(limbs, other),\n        }\n    }\n\n    fn and_pos_limb_neg(&self, other: Limb) -> Self {\n        Self(match self {\n            Self(Small(small)) => Small(small & other),\n            Self(Large(limbs)) => Large(limbs_pos_and_limb_neg(limbs, other)),\n        })\n    }\n\n    fn and_assign_neg_limb_neg(&mut self, other: Limb) {\n        match self {\n            &mut Self::ZERO => {}\n            Self(Small(small)) => {\n                let result = small.wrapping_neg() & other;\n                if result == 0 {\n                    *self = Self(Large(vec![0, 1]));\n                } else {\n                    *small = result.wrapping_neg();\n                }\n            }\n            Self(Large(limbs)) => limbs_vec_neg_and_limb_neg_in_place(limbs, other),\n        }\n    }\n\n    fn and_assign_pos_neg(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (_, Self(Small(y))) => self.and_assign_pos_limb_neg(y.wrapping_neg()),\n            (Self(Small(x)), Self(Large(ys))) => *x &= ys[0].wrapping_neg(),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_and_pos_neg_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n\n    fn and_assign_neg_pos(&mut self, mut other: Self) {\n        other.and_assign_pos_neg(self);\n        *self = other;\n    }\n\n    fn and_assign_neg_pos_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (Self(Small(x)), y) => *self = y.and_pos_limb_neg(x.wrapping_neg()),\n            (Self(Large(xs)), Self(Small(y))) => {\n                *self = Self(Small(xs[0].wrapping_neg() & *y));\n            }\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_vec_and_pos_neg_in_place_right(ys, xs);\n                self.trim();\n            }\n        }\n    }\n\n    fn and_pos_neg(&self, other: &Self) -> Self {\n        match (self, other) {\n            (_, &Self(Small(y))) => self.and_pos_limb_neg(y.wrapping_neg()),\n            (Self(Small(x)), Self(Large(ys))) => Self(Small(x & ys[0].wrapping_neg())),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                Self::from_owned_limbs_asc(limbs_and_pos_neg(xs, ys))\n            }\n        }\n    }\n\n    fn and_neg_limb_neg(&self, other: Limb) -> Self {\n        Self(match self {\n            Self(Small(small)) => {\n                let result = small.wrapping_neg() & other;\n                if result == 0 {\n                    Large(vec![0, 1])\n                } else {\n                    Small(result.wrapping_neg())\n                }\n            }\n            Self(Large(limbs)) => Large(limbs_neg_and_limb_neg(limbs, other)),\n        })\n    }\n\n    fn and_assign_neg_neg(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (Self(Small(x)), _) => *self = other.and_neg_limb_neg(x.wrapping_neg()),\n            (_, Self(Small(y))) => self.and_assign_neg_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_vec_and_neg_neg_in_place_either(xs, ys) {\n                    *self = other;\n                }\n                self.trim();\n            }\n        }\n    }\n\n    fn and_assign_neg_neg_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (Self(Small(x)), _) => *self = other.and_neg_limb_neg(x.wrapping_neg()),\n            (_, Self(Small(y))) => self.and_assign_neg_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_vec_and_neg_neg_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n\n    fn and_neg_neg(&self, other: &Self) -> Self {\n        match (self, other) {\n            (_, &Self(Small(y))) => self.and_neg_limb_neg(y.wrapping_neg()),\n            (&Self(Small(x)), _) => other.and_neg_limb_neg(x.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                Self::from_owned_limbs_asc(limbs_and_neg_neg(xs, ys))\n            }\n        }\n    }\n}\n\nimpl BitAnd<Self> for Integer {\n    type Output = Self;\n\n    /// Takes the bitwise and of two [`Integer`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(-123) & Integer::from(-456), -512);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) & -(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -1000000004096i64\n    /// );\n    /// ```\n    #[inline]\n    fn bitand(mut self, other: Self) -> Self {\n        self &= other;\n        self\n    }\n}\n\nimpl BitAnd<&Self> for Integer {\n    type Output = Self;\n\n    /// Takes the bitwise and of two [`Integer`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(-123) & &Integer::from(-456), -512);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) & &-(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -1000000004096i64\n    /// );\n    /// ```\n    #[inline]\n    fn bitand(mut self, other: &Self) -> Self {\n        self &= other;\n        self\n    }\n}\n\nimpl BitAnd<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Takes the bitwise and of two [`Integer`]s, taking the first by reference and the seocnd by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::from(-123) & Integer::from(-456), -512);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) & -(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -1000000004096i64\n    /// );\n    /// ```\n    #[inline]\n    fn bitand(self, mut other: Integer) -> Integer {\n        other &= self;\n        other\n    }\n}\n\nimpl BitAnd<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Takes the bitwise and of two [`Integer`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::from(-123) & &Integer::from(-456), -512);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) & &-(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -1000000004096i64\n    /// );\n    /// ```\n    fn bitand(self, other: &Integer) -> Integer {\n        match (self.sign, other.sign) {\n            (true, true) => Integer {\n                sign: true,\n                abs: &self.abs & &other.abs,\n            },\n            (true, false) => Integer {\n                sign: true,\n                abs: self.abs.and_pos_neg(&other.abs),\n            },\n            (false, true) => Integer {\n                sign: true,\n                abs: other.abs.and_pos_neg(&self.abs),\n            },\n            (false, false) => Integer {\n                sign: false,\n                abs: self.abs.and_neg_neg(&other.abs),\n            },\n        }\n    }\n}\n\nimpl BitAndAssign<Self> for Integer {\n    /// Bitwise-ands an [`Integer`] with another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::NegativeOne;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::NEGATIVE_ONE;\n    /// x &= Integer::from(0x70ffffff);\n    /// x &= Integer::from(0x7ff0_ffff);\n    /// x &= Integer::from(0x7ffff0ff);\n    /// x &= Integer::from(0x7ffffff0);\n    /// assert_eq!(x, 0x70f0f0f0);\n    /// ```\n    fn bitand_assign(&mut self, other: Self) {\n        match (self.sign, other.sign) {\n            (true, true) => self.abs.bitand_assign(other.abs),\n            (true, false) => self.abs.and_assign_pos_neg(&other.abs),\n            (false, true) => {\n                self.sign = true;\n                self.abs.and_assign_neg_pos(other.abs);\n            }\n            (false, false) => self.abs.and_assign_neg_neg(other.abs),\n        }\n    }\n}\n\nimpl BitAndAssign<&Self> for Integer {\n    /// Bitwise-ands an [`Integer`] with another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::NegativeOne;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::NEGATIVE_ONE;\n    /// x &= &Integer::from(0x70ffffff);\n    /// x &= &Integer::from(0x7ff0_ffff);\n    /// x &= &Integer::from(0x7ffff0ff);\n    /// x &= &Integer::from(0x7ffffff0);\n    /// assert_eq!(x, 0x70f0f0f0);\n    /// ```\n    fn bitand_assign(&mut self, other: &Self) {\n        match (self.sign, other.sign) {\n            (true, true) => self.abs.bitand_assign(&other.abs),\n            (true, false) => self.abs.and_assign_pos_neg(&other.abs),\n            (false, true) => {\n                self.sign = true;\n                self.abs.and_assign_neg_pos_ref(&other.abs);\n            }\n            (false, false) => self.abs.and_assign_neg_neg_ref(&other.abs),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/bit_access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1995, 1997, 1999, 2000, 2001, 2002, 2012 Free Software Foundation,\n//      Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::sub::limbs_sub_limb_in_place;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{PowerOf2, WrappingAddAssign, WrappingNegAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::slices::{slice_leading_zeros, slice_test_zero};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, performs an\n// action equivalent to taking the two's complement of the limbs and getting the bit at the\n// specified index. Sufficiently high indices will return `true`. The slice cannot be empty or\n// contain only zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpz_tstbit` from `mpz/tstbit.c`, GMP 6.2.1, where `d` is negative.\npub_test! {limbs_get_bit_neg(xs: &[Limb], index: u64) -> bool {\n    let x_i = bit_to_limb_count_floor(index);\n    if x_i >= xs.len() {\n        // We're indexing into the infinite suffix of 1s\n        true\n    } else {\n        let x = if slice_test_zero(&xs[..x_i]) {\n            xs[x_i].wrapping_neg()\n        } else {\n            !xs[x_i]\n        };\n        x.get_bit(index & Limb::WIDTH_MASK)\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, performs an\n// action equivalent to taking the two's complement of the limbs, setting a bit at the specified\n// index to `true`, and taking the two's complement again. Indices that are outside the bounds of\n// the slice will result in no action being taken, since negative numbers in two's complement have\n// infinitely many leading 1s. The slice cannot be empty or contain only zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n//\n// # Panics\n// If the slice contains only zeros a panic may occur.\n//\n// This is equivalent to `mpz_setbit` from `mpz/setbit.c`, GMP 6.2.1, where `d` is negative.\npub_test! {limbs_set_bit_neg(xs: &mut [Limb], index: u64) {\n    let x_i = bit_to_limb_count_floor(index);\n    if x_i >= xs.len() {\n        return;\n    }\n    let reduced_index = index & Limb::WIDTH_MASK;\n    let zero_bound = slice_leading_zeros(xs);\n    match x_i.cmp(&zero_bound) {\n        Equal => {\n            let boundary = &mut xs[x_i];\n            // boundary != 0 here\n            *boundary -= 1;\n            boundary.clear_bit(reduced_index);\n            // boundary != Limb::MAX here\n            *boundary += 1;\n        }\n        Less => {\n            assert!(!limbs_sub_limb_in_place(\n                &mut xs[x_i..],\n                Limb::power_of_2(reduced_index),\n            ));\n        }\n        Greater => {\n            xs[x_i].clear_bit(reduced_index);\n        }\n    }\n}}\n\nfn limbs_clear_bit_neg_helper(xs: &mut [Limb], x_i: usize, reduced_index: u64) -> bool {\n    let zero_bound = slice_leading_zeros(xs);\n    match x_i.cmp(&zero_bound) {\n        Equal => {\n            // xs[x_i] != 0 here\n            let mut boundary = xs[x_i] - 1;\n            boundary.set_bit(reduced_index);\n            boundary.wrapping_add_assign(1);\n            xs[x_i] = boundary;\n            boundary == 0 && limbs_slice_add_limb_in_place(&mut xs[x_i + 1..], 1)\n        }\n        Greater => {\n            xs[x_i].set_bit(reduced_index);\n            false\n        }\n        _ => false,\n    }\n}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, performs an\n// action equivalent to taking the two's complement of the limbs, setting a bit at the specified\n// index to `false`, and taking the two's complement again. Inputs that would result in new `true`\n// bits outside of the slice will cause a panic. The slice cannot be empty or contain only zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n//\n// # Panics\n// Panics if evaluation would require new `true` bits outside of the slice. If the slice contains\n// only zeros a panic may occur.\n//\n// This is equivalent to `mpz_clrbit` from `mpz/clrbit.c`, GMP 6.2.1, where `d` is negative and\n// `bit_idx` small enough that no additional memory needs to be given to `d`.\npub fn limbs_slice_clear_bit_neg(xs: &mut [Limb], index: u64) {\n    let x_i = bit_to_limb_count_floor(index);\n    let reduced_index = index & Limb::WIDTH_MASK;\n    assert!(\n        x_i < xs.len() && !limbs_clear_bit_neg_helper(xs, x_i, reduced_index),\n        \"Setting bit cannot be done within existing slice\"\n    );\n}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, performs an\n// action equivalent to taking the two's complement of the limbs, setting a bit at the specified\n// index to `false`, and taking the two's complement again. Sufficiently high indices will increase\n// the length of the limbs vector. The slice cannot be empty or contain only zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n//\n// # Panics\n// If the slice contains only zeros a panic may occur.\n//\n// This is equivalent to `mpz_clrbit` from `mpz/clrbit.c`, GMP 6.2.1, where `d` is negative.\npub_test! {limbs_vec_clear_bit_neg(xs: &mut Vec<Limb>, index: u64) {\n    let x_i = bit_to_limb_count_floor(index);\n    let reduced_index = index & Limb::WIDTH_MASK;\n    if x_i < xs.len() {\n        if limbs_clear_bit_neg_helper(xs, x_i, reduced_index) {\n            xs.push(1);\n        }\n    } else {\n        xs.resize(x_i, 0);\n        xs.push(Limb::power_of_2(reduced_index));\n    }\n}}\n\nimpl Natural {\n    // self cannot be zero\n    pub(crate) fn get_bit_neg(&self, index: u64) -> bool {\n        match self {\n            Self(Small(small)) => index >= Limb::WIDTH || small.wrapping_neg().get_bit(index),\n            Self(Large(limbs)) => limbs_get_bit_neg(limbs, index),\n        }\n    }\n\n    // self cannot be zero\n    fn set_bit_neg(&mut self, index: u64) {\n        match self {\n            Self(Small(small)) => {\n                if index < Limb::WIDTH {\n                    small.wrapping_neg_assign();\n                    small.set_bit(index);\n                    small.wrapping_neg_assign();\n                }\n            }\n            Self(Large(limbs)) => {\n                limbs_set_bit_neg(limbs, index);\n                self.trim();\n            }\n        }\n    }\n\n    // self cannot be zero\n    fn clear_bit_neg(&mut self, index: u64) {\n        match self {\n            Self(Small(small)) if index < Limb::WIDTH => {\n                let mut cleared_small = small.wrapping_neg();\n                cleared_small.clear_bit(index);\n                if cleared_small == 0 {\n                    *self = Self(Large(vec![0, 1]));\n                } else {\n                    *small = cleared_small.wrapping_neg();\n                }\n            }\n            Self(Small(_)) => {\n                let limbs = self.promote_in_place();\n                limbs_vec_clear_bit_neg(limbs, index);\n            }\n            Self(Large(limbs)) => {\n                limbs_vec_clear_bit_neg(limbs, index);\n            }\n        }\n    }\n}\n\n/// Provides functions for accessing and modifying the $i$th bit of a [`Integer`], or the\n/// coefficient of $2^i$ in its two's complement binary expansion.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::{NegativeOne, Zero};\n/// use malachite_base::num::logic::traits::BitAccess;\n/// use malachite_nz::integer::Integer;\n///\n/// let mut x = Integer::ZERO;\n/// x.assign_bit(2, true);\n/// x.assign_bit(5, true);\n/// x.assign_bit(6, true);\n/// assert_eq!(x, 100);\n/// x.assign_bit(2, false);\n/// x.assign_bit(5, false);\n/// x.assign_bit(6, false);\n/// assert_eq!(x, 0);\n///\n/// let mut x = Integer::from(-0x100);\n/// x.assign_bit(2, true);\n/// x.assign_bit(5, true);\n/// x.assign_bit(6, true);\n/// assert_eq!(x, -156);\n/// x.assign_bit(2, false);\n/// x.assign_bit(5, false);\n/// x.assign_bit(6, false);\n/// assert_eq!(x, -256);\n///\n/// let mut x = Integer::ZERO;\n/// x.flip_bit(10);\n/// assert_eq!(x, 1024);\n/// x.flip_bit(10);\n/// assert_eq!(x, 0);\n///\n/// let mut x = Integer::NEGATIVE_ONE;\n/// x.flip_bit(10);\n/// assert_eq!(x, -1025);\n/// x.flip_bit(10);\n/// assert_eq!(x, -1);\n/// ```\nimpl BitAccess for Integer {\n    /// Determines whether the $i$th bit of an [`Integer`], or the coefficient of $2^i$ in its two's\n    /// complement binary expansion, is 0 or 1.\n    ///\n    /// `false` means 0 and `true` means 1. Getting bits beyond the [`Integer`]'s width is allowed;\n    /// those bits are `false` if the [`Integer`] is non-negative and `true` if it is negative.\n    ///\n    /// If $n \\geq 0$, let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i};\n    /// $$\n    /// but if $n < 0$, let\n    /// $$\n    /// -n - 1 = \\sum_{i=0}^\\infty 2^{1 - b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$.\n    ///\n    /// $f(n, i) = (b_i = 1)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::logic::traits::BitAccess;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(123).get_bit(2), false);\n    /// assert_eq!(Integer::from(123).get_bit(3), true);\n    /// assert_eq!(Integer::from(123).get_bit(100), false);\n    /// assert_eq!(Integer::from(-123).get_bit(0), true);\n    /// assert_eq!(Integer::from(-123).get_bit(1), false);\n    /// assert_eq!(Integer::from(-123).get_bit(100), true);\n    /// assert_eq!(Integer::from(10u32).pow(12).get_bit(12), true);\n    /// assert_eq!(Integer::from(10u32).pow(12).get_bit(100), false);\n    /// assert_eq!((-Integer::from(10u32).pow(12)).get_bit(12), true);\n    /// assert_eq!((-Integer::from(10u32).pow(12)).get_bit(100), true);\n    /// ```\n    fn get_bit(&self, index: u64) -> bool {\n        match self {\n            Self { sign: true, abs } => abs.get_bit(index),\n            Self { sign: false, abs } => abs.get_bit_neg(index),\n        }\n    }\n\n    /// Sets the $i$th bit of an [`Integer`], or the coefficient of $2^i$ in its two's complement\n    /// binary expansion, to 1.\n    ///\n    /// If $n \\geq 0$, let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i};\n    /// $$\n    /// but if $n < 0$, let\n    /// $$\n    /// -n - 1 = \\sum_{i=0}^\\infty 2^{1 - b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$.\n    /// $$\n    /// n \\gets \\\\begin{cases}\n    ///     n + 2^j & \\text{if} \\\\quad b_j = 0, \\\\\\\\\n    ///     n & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitAccess;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x.set_bit(2);\n    /// x.set_bit(5);\n    /// x.set_bit(6);\n    /// assert_eq!(x, 100);\n    ///\n    /// let mut x = Integer::from(-0x100);\n    /// x.set_bit(2);\n    /// x.set_bit(5);\n    /// x.set_bit(6);\n    /// assert_eq!(x, -156);\n    /// ```\n    fn set_bit(&mut self, index: u64) {\n        match self {\n            Self { sign: true, abs } => abs.set_bit(index),\n            Self { sign: false, abs } => abs.set_bit_neg(index),\n        }\n    }\n\n    /// Sets the $i$th bit of an [`Integer`], or the coefficient of $2^i$ in its binary expansion,\n    /// to 0.\n    ///\n    /// If $n \\geq 0$, let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i};\n    /// $$\n    /// but if $n < 0$, let\n    /// $$\n    /// -n - 1 = \\sum_{i=0}^\\infty 2^{1 - b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$.\n    /// $$\n    /// n \\gets \\\\begin{cases}\n    ///     n - 2^j & \\text{if} \\\\quad b_j = 1, \\\\\\\\\n    ///     n & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitAccess;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(0x7f);\n    /// x.clear_bit(0);\n    /// x.clear_bit(1);\n    /// x.clear_bit(3);\n    /// x.clear_bit(4);\n    /// assert_eq!(x, 100);\n    ///\n    /// let mut x = Integer::from(-156);\n    /// x.clear_bit(2);\n    /// x.clear_bit(5);\n    /// x.clear_bit(6);\n    /// assert_eq!(x, -256);\n    /// ```\n    fn clear_bit(&mut self, index: u64) {\n        match self {\n            Self { sign: true, abs } => abs.clear_bit(index),\n            Self { sign: false, abs } => abs.clear_bit_neg(index),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/bit_block_access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::conversion::to_twos_complement_limbs::limbs_twos_complement_in_place;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_vec_add_limb_in_place;\nuse crate::natural::arithmetic::mod_power_of_2::limbs_vec_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::arithmetic::sub::limbs_sub_limb_in_place;\nuse crate::natural::logic::bit_block_access::limbs_assign_bits_helper;\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::natural::logic::trailing_zeros::limbs_trailing_zeros;\nuse crate::natural::{Natural, bit_to_limb_count_ceiling, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::ModPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{BitBlockAccess, LeadingZeros, TrailingZeros};\nuse malachite_base::vecs::vec_delete_left;\n\n// Returns the limbs obtained by taking a slice of bits beginning at index `start` of the negative\n// of `limb` and ending at index `end - 1`. `start` must be less than or equal to `end`, but apart\n// from that there are no restrictions on the index values. If they index beyond the physical size\n// of the input limbs, the function interprets them as pointing to `true` bits. `x` must be\n// positive.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `end`.\n//\n// # Panics\n// Panics if `start > end`.\npub_test! {limbs_neg_limb_get_bits(x: Limb, start: u64, end: u64) -> Vec<Limb> {\n    assert!(start <= end);\n    let trailing_zeros = TrailingZeros::trailing_zeros(x);\n    if trailing_zeros >= end {\n        return Vec::new();\n    }\n    let bit_len = end - start;\n    let mut out = if start >= Limb::WIDTH {\n        vec![\n            Limb::MAX;\n            bit_to_limb_count_ceiling(bit_len)\n        ]\n    } else {\n        let mut out = vec![x >> start];\n        out.resize(bit_to_limb_count_floor(end) + 1, 0);\n        if trailing_zeros >= start {\n            limbs_twos_complement_in_place(&mut out);\n        } else {\n            limbs_not_in_place(&mut out);\n        }\n        out\n    };\n    limbs_vec_mod_power_of_2_in_place(&mut out, bit_len);\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs obtained by taking a slice of bits beginning at index `start` of the negative of the\n// `Natural` and ending at index `end - 1`. `start` must be less than or equal to `end`, but apart\n// from that there are no restrictions on the index values. If they index beyond the physical size\n// of the input limbs, the function interprets them as pointing to `true` bits. The input slice\n// cannot only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(xs.len(), end * Limb::WIDTH)`.\n//\n// # Panics\n// Panics if `start > end`.\npub_test! {limbs_slice_neg_get_bits(xs: &[Limb], start: u64, end: u64) -> Vec<Limb> {\n    assert!(start <= end);\n    let trailing_zeros = limbs_trailing_zeros(xs);\n    if trailing_zeros >= end {\n        return Vec::new();\n    }\n    let start_i = bit_to_limb_count_floor(start);\n    let len = xs.len();\n    let bit_len = end - start;\n    if start_i >= len {\n        let mut out = vec![Limb::MAX; bit_to_limb_count_ceiling(bit_len)];\n        limbs_vec_mod_power_of_2_in_place(&mut out, bit_len);\n        return out;\n    }\n    let end_i = bit_to_limb_count_floor(end) + 1;\n    let mut out = (if end_i >= len {\n        &xs[start_i..]\n    } else {\n        &xs[start_i..end_i]\n    })\n    .to_vec();\n    let offset = start & Limb::WIDTH_MASK;\n    if offset != 0 {\n        limbs_slice_shr_in_place(&mut out, offset);\n    }\n    out.resize(end_i - start_i, 0);\n    if trailing_zeros >= start {\n        limbs_twos_complement_in_place(&mut out);\n    } else {\n        limbs_not_in_place(&mut out);\n    }\n    limbs_vec_mod_power_of_2_in_place(&mut out, bit_len);\n    out\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs obtained by taking a slice of bits beginning at index `start` of the negative of the\n// `Natural` and ending at index `end - 1`. `start` must be less than or equal to `end`, but apart\n// from that there are no restrictions on the index values. If they index beyond the physical size\n// of the input limbs, the function interprets them as pointing to `true` bits. The input slice\n// cannot only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(xs.len(), end * Limb::WIDTH)`.\n//\n// # Panics\n// Panics if `start > end`.\npub_test! {limbs_vec_neg_get_bits(mut xs: Vec<Limb>, start: u64, end: u64) -> Vec<Limb> {\n    assert!(start <= end);\n    let trailing_zeros = limbs_trailing_zeros(&xs);\n    if trailing_zeros >= end {\n        return Vec::new();\n    }\n    let start_i = bit_to_limb_count_floor(start);\n    let len = xs.len();\n    let bit_len = end - start;\n    if start_i >= len {\n        xs = vec![Limb::MAX; bit_to_limb_count_ceiling(bit_len)];\n        limbs_vec_mod_power_of_2_in_place(&mut xs, bit_len);\n        return xs;\n    }\n    let end_i = bit_to_limb_count_floor(end) + 1;\n    xs.truncate(end_i);\n    vec_delete_left(&mut xs, start_i);\n    let offset = start & Limb::WIDTH_MASK;\n    if offset != 0 {\n        limbs_slice_shr_in_place(&mut xs, offset);\n    }\n    xs.resize(end_i - start_i, 0);\n    if trailing_zeros >= start {\n        limbs_twos_complement_in_place(&mut xs);\n    } else {\n        limbs_not_in_place(&mut xs);\n    }\n    limbs_vec_mod_power_of_2_in_place(&mut xs, bit_len);\n    xs\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural` n, writes the\n// limbs of `bits` into the limbs of -n, starting at bit `start` of -n (inclusive) and ending at bit\n// `end` of -n (exclusive). The bit indices do not need to be aligned with any limb boundaries. If\n// `bits` has more than `end` - `start` bits, only the first `end` - `start` bits are written. If\n// `bits` has fewer than `end` - `start` bits, the remaining written bits are one. `xs` may be\n// extended to accommodate the new bits. `start` must be smaller than `end`, and `xs` cannot only\n// contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(n / 2 ^ Limb::WIDTH, m)`, and $m$ is\n// `end`.\n//\n// # Panics\n// Panics if `start >= end` or `xs` only contains zeros.\npub_test! {limbs_neg_assign_bits(xs: &mut Vec<Limb>, start: u64, end: u64, bits: &[Limb]) {\n    assert!(start < end);\n    assert!(!limbs_sub_limb_in_place(xs, 1));\n    limbs_assign_bits_helper(xs, start, end, bits, true);\n    limbs_vec_add_limb_in_place(xs, 1);\n}}\n\nimpl Natural {\n    fn neg_get_bits(&self, start: u64, end: u64) -> Self {\n        Self::from_owned_limbs_asc(match self {\n            Self(Small(small)) => limbs_neg_limb_get_bits(*small, start, end),\n            Self(Large(limbs)) => limbs_slice_neg_get_bits(limbs, start, end),\n        })\n    }\n\n    fn neg_get_bits_owned(self, start: u64, end: u64) -> Self {\n        Self::from_owned_limbs_asc(match self {\n            Self(Small(small)) => limbs_neg_limb_get_bits(small, start, end),\n            Self(Large(limbs)) => limbs_vec_neg_get_bits(limbs, start, end),\n        })\n    }\n\n    fn neg_assign_bits(&mut self, start: u64, end: u64, bits: &Self) {\n        if start == end {\n            return;\n        }\n        let bits_width = end - start;\n        if bits_width <= Limb::WIDTH\n            && let (&mut Self(Small(ref mut small_self)), &Self(Small(small_bits))) =\n                (&mut *self, bits)\n        {\n            let small_bits = (!small_bits).mod_power_of_2(bits_width);\n            if small_bits == 0 || LeadingZeros::leading_zeros(small_bits) >= start {\n                let mut new_small_self = *small_self - 1;\n                new_small_self.assign_bits(start, end, &small_bits);\n                let (sum, overflow) = new_small_self.overflowing_add(1);\n                if !overflow {\n                    *small_self = sum;\n                    return;\n                }\n            }\n        }\n        let limbs = self.promote_in_place();\n        match bits {\n            Self(Small(small_bits)) => limbs_neg_assign_bits(limbs, start, end, &[*small_bits]),\n            Self(Large(bits_limbs)) => limbs_neg_assign_bits(limbs, start, end, bits_limbs),\n        }\n        self.trim();\n    }\n}\n\nimpl BitBlockAccess for Integer {\n    type Bits = Natural;\n\n    /// Extracts a block of adjacent two's complement bits from an [`Integer`], taking the\n    /// [`Integer`] by reference.\n    ///\n    /// The first index is `start` and last index is `end - 1`.\n    ///\n    /// Let $n$ be `self`, and let $p$ and $q$ be `start` and `end`, respectively.\n    ///\n    /// If $n \\geq 0$, let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i};\n    /// $$\n    /// but if $n < 0$, let\n    /// $$\n    /// -n - 1 = \\sum_{i=0}^\\infty 2^{1 - b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$. Then\n    /// $$\n    /// f(n, p, q) = \\sum_{i=p}^{q-1} 2^{b_{i-p}}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), end)`.\n    ///\n    /// # Panics\n    /// Panics if `start > end`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitBlockAccess;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (-Natural::from(0xabcdef0112345678u64)).get_bits(16, 48),\n    ///     Natural::from(0x10feedcbu32)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(0xabcdef0112345678u64).get_bits(4, 16),\n    ///     Natural::from(0x567u32)\n    /// );\n    /// assert_eq!(\n    ///     (-Natural::from(0xabcdef0112345678u64)).get_bits(0, 100),\n    ///     Natural::from_str(\"1267650600215849587758112418184\").unwrap()\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(0xabcdef0112345678u64).get_bits(10, 10),\n    ///     Natural::ZERO\n    /// );\n    /// ```\n    fn get_bits(&self, start: u64, end: u64) -> Natural {\n        if self.sign {\n            self.abs.get_bits(start, end)\n        } else {\n            self.abs.neg_get_bits(start, end)\n        }\n    }\n\n    /// Extracts a block of adjacent two's complement bits from an [`Integer`], taking the\n    /// [`Integer`] by value.\n    ///\n    /// The first index is `start` and last index is `end - 1`.\n    ///\n    /// Let $n$ be `self`, and let $p$ and $q$ be `start` and `end`, respectively.\n    ///\n    /// If $n \\geq 0$, let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i};\n    /// $$\n    /// but if $n < 0$, let\n    /// $$\n    /// -n - 1 = \\sum_{i=0}^\\infty 2^{1 - b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$. Then\n    /// $$\n    /// f(n, p, q) = \\sum_{i=p}^{q-1} 2^{b_{i-p}}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), end)`.\n    ///\n    /// # Panics\n    /// Panics if `start > end`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitBlockAccess;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (-Natural::from(0xabcdef0112345678u64)).get_bits_owned(16, 48),\n    ///     Natural::from(0x10feedcbu32)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(0xabcdef0112345678u64).get_bits_owned(4, 16),\n    ///     Natural::from(0x567u32)\n    /// );\n    /// assert_eq!(\n    ///     (-Natural::from(0xabcdef0112345678u64)).get_bits_owned(0, 100),\n    ///     Natural::from_str(\"1267650600215849587758112418184\").unwrap()\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(0xabcdef0112345678u64).get_bits_owned(10, 10),\n    ///     Natural::ZERO\n    /// );\n    /// ```\n    fn get_bits_owned(self, start: u64, end: u64) -> Natural {\n        if self.sign {\n            self.abs.get_bits_owned(start, end)\n        } else {\n            self.abs.neg_get_bits_owned(start, end)\n        }\n    }\n\n    /// Replaces a block of adjacent two's complement bits in an [`Integer`] with other bits.\n    ///\n    /// The least-significant `end - start` bits of `bits` are assigned to bits `start` through `end\n    /// - 1`, inclusive, of `self`.\n    ///\n    /// Let $n$ be `self` and let $m$ be `bits`, and let $p$ and $q$ be `start` and `end`,\n    /// respectively.\n    ///\n    /// Let\n    /// $$\n    /// m = \\sum_{i=0}^k 2^{d_i},\n    /// $$\n    /// where for all $i$, $d_i\\in \\\\{0, 1\\\\}$.\n    ///\n    /// If $n \\geq 0$, let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i};\n    /// $$\n    /// but if $n < 0$, let\n    /// $$\n    /// -n - 1 = \\sum_{i=0}^\\infty 2^{1 - b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$. Then\n    /// $$\n    /// n \\gets \\sum_{i=0}^\\infty 2^{c_i},\n    /// $$\n    /// where\n    /// $$\n    /// \\\\{c_0, c_1, c_2, \\ldots \\\\} =\n    /// \\\\{b_0, b_1, b_2, \\ldots, b_{p-1}, d_0, d_1, \\ldots, d_{p-q-1}, b_q, b_{q+1}, \\ldots \\\\}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(), end)`, and\n    /// $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `start > end`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitBlockAccess;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Integer::from(123);\n    /// n.assign_bits(5, 7, &Natural::from(456u32));\n    /// assert_eq!(n.to_string(), \"27\");\n    ///\n    /// let mut n = Integer::from(-123);\n    /// n.assign_bits(64, 128, &Natural::from(456u32));\n    /// assert_eq!(n.to_string(), \"-340282366920938455033212565746503123067\");\n    ///\n    /// let mut n = Integer::from(-123);\n    /// n.assign_bits(80, 100, &Natural::from(456u32));\n    /// assert_eq!(n.to_string(), \"-1267098121128665515963862483067\");\n    /// ```\n    fn assign_bits(&mut self, start: u64, end: u64, bits: &Natural) {\n        if self.sign {\n            self.abs.assign_bits(start, end, bits);\n        } else {\n            self.abs.neg_assign_bits(start, end, bits);\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/bit_convertible.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::conversion::to_twos_complement_limbs::limbs_twos_complement_in_place;\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::platform::{Limb, SignedLimb};\nuse alloc::vec::Vec;\nuse itertools::Itertools;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::{BitConvertible, LowMask, NotAssign};\n\n// Given the bits of a non-negative `Integer`, in ascending order, checks whether the most\n// significant bit is `false`; if it isn't, appends an extra `false` bit. This way the `Integer`'s\n// non-negativity is preserved in its bits.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {bits_to_twos_complement_bits_non_negative(bits: &mut Vec<bool>) {\n    if !bits.is_empty() && *bits.last().unwrap() {\n        // Sign-extend with an extra false bit to indicate a positive Integer\n        bits.push(false);\n    }\n}}\n\n// Given the bits of the absolute value of a negative `Integer`, in ascending order, converts the\n// bits to two's complement. Returns whether there is a carry left over from the two's complement\n// conversion process.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bits.len()`.\npub_test! {bits_slice_to_twos_complement_bits_negative(bits: &mut [bool]) -> bool {\n    let mut true_seen = false;\n    for bit in &mut *bits {\n        if true_seen {\n            bit.not_assign();\n        } else if *bit {\n            true_seen = true;\n        }\n    }\n    !true_seen\n}}\n\n// Given the bits of the absolute value of a negative `Integer`, in ascending order, converts the\n// bits to two's complement and checks whether the most significant bit is `true`; if it isn't,\n// appends an extra `true` bit. This way the `Integer`'s negativity is preserved in its bits. The\n// bits cannot be empty or contain only `false`s.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bits.len()`.\n//\n// # Panics\n// Panics if `bits` contains only `false`s.\npub_test! {bits_vec_to_twos_complement_bits_negative(bits: &mut Vec<bool>) {\n    assert!(!bits_slice_to_twos_complement_bits_negative(bits));\n    if bits.last() == Some(&false) {\n        // Sign-extend with an extra true bit to indicate a negative Integer\n        bits.push(true);\n    }\n}}\n\nfn from_bits_helper(mut limbs: Vec<Limb>, sign_bit: bool, last_width: u64) -> Integer {\n    if sign_bit {\n        if last_width != Limb::WIDTH {\n            *limbs.last_mut().unwrap() |= !Limb::low_mask(last_width);\n        }\n        assert!(!limbs_twos_complement_in_place(&mut limbs));\n    }\n    Integer::from_sign_and_abs(!sign_bit, Natural::from_owned_limbs_asc(limbs))\n}\n\nimpl BitConvertible for Integer {\n    /// Returns a [`Vec`] containing the twos-complement bits of an [`Integer`] in ascending order:\n    /// least- to most-significant.\n    ///\n    /// The most significant bit indicates the sign; if the bit is `false`, the [`Integer`] is\n    /// positive, and if the bit is `true` it is negative. There are no trailing `false` bits if the\n    /// [`Integer`] is positive or trailing `true` bits if the [`Integer`] is negative, except as\n    /// necessary to include the correct sign bit. Zero is a special case: it contains no bits.\n    ///\n    /// This function is more efficient than [`to_bits_desc`](`Self::to_bits_desc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::ZERO.to_bits_asc().is_empty());\n    /// // 105 = 01101001b, with a leading false bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(105).to_bits_asc(),\n    ///     &[true, false, false, true, false, true, true, false]\n    /// );\n    /// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(-105).to_bits_asc(),\n    ///     &[true, true, true, false, true, false, false, true]\n    /// );\n    /// ```\n    fn to_bits_asc(&self) -> Vec<bool> {\n        let mut bits = self.abs.to_bits_asc();\n        if self.sign {\n            bits_to_twos_complement_bits_non_negative(&mut bits);\n        } else {\n            bits_vec_to_twos_complement_bits_negative(&mut bits);\n        }\n        bits\n    }\n\n    /// Returns a [`Vec`] containing the twos-complement bits of an [`Integer`] in descending order:\n    /// most- to least-significant.\n    ///\n    /// The most significant bit indicates the sign; if the bit is `false`, the [`Integer`] is\n    /// positive, and if the bit is `true` it is negative. There are no leading `false` bits if the\n    /// [`Integer`] is positive or leading `true` bits if the [`Integer`] is negative, except as\n    /// necessary to include the correct sign bit. Zero is a special case: it contains no bits.\n    ///\n    /// This is similar to how `BigInteger`s in Java are represented.\n    ///\n    /// This function is less efficient than [`to_bits_asc`](`Self::to_bits_asc`).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert!(Integer::ZERO.to_bits_desc().is_empty());\n    /// // 105 = 01101001b, with a leading false bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(105).to_bits_desc(),\n    ///     &[false, true, true, false, true, false, false, true]\n    /// );\n    /// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(-105).to_bits_desc(),\n    ///     &[true, false, false, true, false, true, true, true]\n    /// );\n    /// ```\n    fn to_bits_desc(&self) -> Vec<bool> {\n        let mut bits = self.to_bits_asc();\n        bits.reverse();\n        bits\n    }\n\n    /// Converts an iterator of twos-complement bits into an [`Integer`]. The bits should be in\n    /// ascending order (least- to most-significant).\n    ///\n    /// Let $k$ be `bits.count()`. If $k = 0$ or $b_{k-1}$ is `false`, then\n    /// $$\n    /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^i \\[b_i\\],\n    /// $$\n    /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n    ///\n    /// If $b_{k-1}$ is `true`, then\n    /// $$\n    /// f((b_i)_ {i=0}^{k-1}) = \\left ( \\sum_{i=0}^{k-1}2^i \\[b_i\\] \\right ) - 2^k.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.count()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::empty;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from_bits_asc(empty()), 0);\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Integer::from_bits_asc(\n    ///         [true, false, false, true, false, true, true, false]\n    ///             .iter()\n    ///             .cloned()\n    ///     ),\n    ///     105\n    /// );\n    /// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from_bits_asc(\n    ///         [true, true, true, false, true, false, false, true]\n    ///             .iter()\n    ///             .cloned()\n    ///     ),\n    ///     -105\n    /// );\n    /// ```\n    fn from_bits_asc<I: Iterator<Item = bool>>(xs: I) -> Self {\n        let mut limbs = Vec::new();\n        let mut last_width = 0;\n        let mut last_bit = false;\n        for chunk in &xs.chunks(usize::exact_from(Limb::WIDTH)) {\n            let mut limb = 0;\n            let mut i = 0;\n            let mut mask = 1;\n            for bit in chunk {\n                if bit {\n                    limb |= mask;\n                }\n                mask <<= 1;\n                i += 1;\n                last_bit = bit;\n            }\n            last_width = i;\n            limbs.push(limb);\n        }\n        from_bits_helper(limbs, last_bit, last_width)\n    }\n\n    /// Converts an iterator of twos-complement bits into an [`Integer`]. The bits should be in\n    /// descending order (most- to least-significant).\n    ///\n    /// If `bits` is empty or $b_0$ is `false`, then\n    /// $$\n    /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^{k-i-1} \\[b_i\\],\n    /// $$\n    /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n    ///\n    /// If $b_0$ is `true`, then\n    /// $$\n    /// f((b_i)_ {i=0}^{k-1}) = \\left ( \\sum_{i=0}^{k-1}2^{k-i-1} \\[b_i\\] \\right ) - 2^k.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.count()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::empty;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from_bits_desc(empty()), 0);\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Integer::from_bits_desc(\n    ///         [false, true, true, false, true, false, false, true]\n    ///             .iter()\n    ///             .cloned()\n    ///     ),\n    ///     105\n    /// );\n    /// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from_bits_desc(\n    ///         [true, false, false, true, false, true, true, true]\n    ///             .iter()\n    ///             .cloned()\n    ///     ),\n    ///     -105\n    /// );\n    /// ```\n    fn from_bits_desc<I: Iterator<Item = bool>>(xs: I) -> Self {\n        let mut limbs = Vec::new();\n        let mut last_width = 0;\n        let mut first_bit = false;\n        let mut first = true;\n        for chunk in &xs.chunks(usize::exact_from(Limb::WIDTH)) {\n            let mut limb = 0;\n            let mut i = 0;\n            for bit in chunk {\n                if first {\n                    first_bit = bit;\n                    first = false;\n                }\n                limb <<= 1;\n                if bit {\n                    limb |= 1;\n                }\n                i += 1;\n            }\n            last_width = i;\n            limbs.push(limb);\n        }\n        match limbs.len() {\n            0 => Self::ZERO,\n            1 => {\n                if first_bit {\n                    if last_width != Limb::WIDTH {\n                        limbs[0] |= !Limb::low_mask(last_width);\n                    }\n                    Self::from(SignedLimb::wrapping_from(limbs[0]))\n                } else {\n                    Self::from(limbs[0])\n                }\n            }\n            _ => {\n                limbs.reverse();\n                if last_width != Limb::WIDTH {\n                    let smallest_limb = limbs[0];\n                    limbs[0] = 0;\n                    limbs_slice_shr_in_place(&mut limbs, Limb::WIDTH - last_width);\n                    limbs[0] |= smallest_limb;\n                }\n                from_bits_helper(limbs, first_bit, last_width)\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/bit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::natural::logic::bit_iterable::NaturalBitIterator;\nuse core::ops::Index;\nuse malachite_base::num::logic::traits::{BitAccess, BitIterable};\n\n/// A double-ended iterator over the two's complement bits of the negative of an [`Integer`].\n///\n/// The forward order is ascending (least-significant first). There may be at most one implicit\n/// most-significant `true` bit.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct NegativeBitIterator<'a> {\n    pub(crate) bits: NaturalBitIterator<'a>,\n    i: u64,\n    j: u64,\n    first_true_index: Option<u64>,\n}\n\nimpl Iterator for NegativeBitIterator<'_> {\n    type Item = bool;\n\n    fn next(&mut self) -> Option<bool> {\n        let previous_i = self.i;\n        self.bits.next().map(|bit| {\n            self.i += 1;\n            if let Some(first_true_index) = self.first_true_index {\n                if previous_i <= first_true_index {\n                    bit\n                } else {\n                    !bit\n                }\n            } else {\n                if bit {\n                    self.first_true_index = Some(previous_i);\n                }\n                bit\n            }\n        })\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        self.bits.size_hint()\n    }\n}\n\nimpl DoubleEndedIterator for NegativeBitIterator<'_> {\n    fn next_back(&mut self) -> Option<bool> {\n        let previous_j = self.j;\n        self.bits.next_back().map(|bit| {\n            if self.j != 0 {\n                self.j -= 1;\n            }\n            if self.first_true_index.is_none() {\n                let mut i = 0;\n                while !self.bits[i] {\n                    i += 1;\n                }\n                self.first_true_index = Some(i);\n            }\n            let first_true_index = self.first_true_index.unwrap();\n            if previous_j <= first_true_index {\n                bit\n            } else {\n                !bit\n            }\n        })\n    }\n}\n\nimpl ExactSizeIterator for NegativeBitIterator<'_> {}\n\ntrait SignExtendedBitIterator: DoubleEndedIterator<Item = bool> {\n    const EXTENSION: bool;\n\n    fn needs_sign_extension(&self) -> bool;\n\n    fn iterate_forward(&mut self, extension_checked: &mut bool) -> Option<bool> {\n        let next = self.next();\n        if next.is_none() {\n            if *extension_checked {\n                None\n            } else {\n                *extension_checked = true;\n                if self.needs_sign_extension() {\n                    Some(Self::EXTENSION)\n                } else {\n                    None\n                }\n            }\n        } else {\n            next\n        }\n    }\n\n    fn iterate_backward(&mut self, extension_checked: &mut bool) -> Option<bool> {\n        if !*extension_checked {\n            *extension_checked = true;\n            if self.needs_sign_extension() {\n                return Some(Self::EXTENSION);\n            }\n        }\n        self.next_back()\n    }\n}\n\nimpl SignExtendedBitIterator for NaturalBitIterator<'_> {\n    const EXTENSION: bool = false;\n\n    fn needs_sign_extension(&self) -> bool {\n        self[self.significant_bits - 1]\n    }\n}\n\nimpl SignExtendedBitIterator for NegativeBitIterator<'_> {\n    const EXTENSION: bool = true;\n\n    fn needs_sign_extension(&self) -> bool {\n        let mut i = 0;\n        while !self.bits[i] {\n            i += 1;\n        }\n        let last_bit_index = self.bits.significant_bits - 1;\n        if i == last_bit_index {\n            !self.bits[last_bit_index]\n        } else {\n            self.bits[last_bit_index]\n        }\n    }\n}\n\n/// A double-ended iterator over the twos-complement bits of an [`Integer`].\n///\n/// The forward order is ascending (least-significant first). The most significant bit corresponds\n/// to the sign of the [`Integer`]; `false` for non-negative and `true` for negative. This means\n/// that there may be a single most-significant sign-extension bit.\n///\n/// This `struct` is created by [`BitIterable::bits`]; see its documentation for more.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub enum IntegerBitIterator<'a> {\n    Zero,\n    Positive(NaturalBitIterator<'a>, bool),\n    Negative(NegativeBitIterator<'a>, bool),\n}\n\nimpl Iterator for IntegerBitIterator<'_> {\n    type Item = bool;\n\n    fn next(&mut self) -> Option<bool> {\n        match self {\n            Self::Zero => None,\n            Self::Positive(bits, extension_checked) => bits.iterate_forward(extension_checked),\n            Self::Negative(bits, extension_checked) => bits.iterate_forward(extension_checked),\n        }\n    }\n}\n\nimpl DoubleEndedIterator for IntegerBitIterator<'_> {\n    fn next_back(&mut self) -> Option<bool> {\n        match self {\n            Self::Zero => None,\n            Self::Positive(bits, extension_checked) => bits.iterate_backward(extension_checked),\n            Self::Negative(bits, extension_checked) => bits.iterate_backward(extension_checked),\n        }\n    }\n}\n\nimpl Index<u64> for IntegerBitIterator<'_> {\n    type Output = bool;\n\n    /// A function to retrieve an [`Integer`]'s two's complement bits by index. Indexing at or above\n    /// the significant bit count returns `false` or `true` bits, depending on the [`Integer`]'s\n    /// sign.\n    ///\n    /// This is equivalent to [`get_bit`](malachite_base::num::logic::traits::BitAccess::get_bit).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitIterable;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.bits()[0], false);\n    ///\n    /// // -105 = 10010111 in two's complement\n    /// let n = Integer::from(-105);\n    /// let bits = n.bits();\n    /// assert_eq!(bits[0], true);\n    /// assert_eq!(bits[1], true);\n    /// assert_eq!(bits[2], true);\n    /// assert_eq!(bits[3], false);\n    /// assert_eq!(bits[4], true);\n    /// assert_eq!(bits[5], false);\n    /// assert_eq!(bits[6], false);\n    /// assert_eq!(bits[7], true);\n    /// assert_eq!(bits[100], true);\n    /// ```\n    fn index(&self, index: u64) -> &bool {\n        let bit = match self {\n            Self::Zero => false,\n            Self::Positive(bits, _) => bits.limbs.n.get_bit(index),\n            Self::Negative(bits, _) => bits.bits.limbs.n.get_bit_neg(index),\n        };\n        if bit { &true } else { &false }\n    }\n}\n\nimpl Natural {\n    // Returns a double-ended iterator over the two's complement bits of the negative of a\n    // `Natural`. The forward order is ascending, so that less significant bits appear first. There\n    // may be at most one trailing `true` bit going forward, or leading `true` bit going backward.\n    // The `Natural` cannot be zero.\n    //\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    fn negative_bits(&self) -> NegativeBitIterator<'_> {\n        assert_ne!(*self, 0, \"Cannot get negative bits of 0.\");\n        let bits = self.bits();\n        NegativeBitIterator {\n            bits,\n            first_true_index: None,\n            i: 0,\n            j: bits.significant_bits - 1,\n        }\n    }\n}\n\nimpl<'a> BitIterable for &'a Integer {\n    type BitIterator = IntegerBitIterator<'a>;\n\n    /// Returns a double-ended iterator over the bits of an [`Integer`].\n    ///\n    /// The forward order is ascending, so that less significant bits appear first. There are no\n    /// trailing false bits going forward, or leading falses going backward, except for possibly a\n    /// most-significant sign-extension bit.\n    ///\n    /// If it's necessary to get a [`Vec`] of all the bits, consider using\n    /// [`to_bits_asc`](malachite_base::num::logic::traits::BitConvertible::to_bits_asc) or\n    /// [`to_bits_desc`](malachite_base::num::logic::traits::BitConvertible::to_bits_desc) instead.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitIterable;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.bits().next(), None);\n    /// // 105 = 01101001b, with a leading false bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(105).bits().collect_vec(),\n    ///     &[true, false, false, true, false, true, true, false]\n    /// );\n    /// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(-105).bits().collect_vec(),\n    ///     &[true, true, true, false, true, false, false, true]\n    /// );\n    ///\n    /// assert_eq!(Integer::ZERO.bits().next_back(), None);\n    /// // 105 = 01101001b, with a leading false bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(105).bits().rev().collect_vec(),\n    ///     &[false, true, true, false, true, false, false, true]\n    /// );\n    /// // -105 = 10010111 in two's complement, with a leading true bit to indicate sign\n    /// assert_eq!(\n    ///     Integer::from(-105).bits().rev().collect_vec(),\n    ///     &[true, false, false, true, false, true, true, true]\n    /// );\n    /// ```\n    fn bits(self) -> IntegerBitIterator<'a> {\n        if *self == 0 {\n            IntegerBitIterator::Zero\n        } else if self.sign {\n            IntegerBitIterator::Positive(self.abs.bits(), false)\n        } else {\n            IntegerBitIterator::Negative(self.abs.negative_bits(), false)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/bit_scan.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2000-2002, 2004, 2012, 2015 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::logic::bit_scan::{\n    limbs_index_of_next_false_bit, limbs_index_of_next_true_bit,\n};\nuse crate::natural::{Natural, bit_to_limb_count_floor, limb_to_bit_count};\nuse crate::platform::Limb;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{BitScan, LowMask, TrailingZeros};\nuse malachite_base::slices::slice_leading_zeros;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, finds the lowest index greater than or equal to `starting_index` at which the\n// `Integer` has a `false` bit. If the starting index is too large and there are no more `false`\n// bits above it, `None` is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpz_scan0` from `mpz/scan0.c`, GMP 6.2.1.\npub_test! {limbs_index_of_next_false_bit_neg(xs: &[Limb], mut starting_index: u64) -> Option<u64> {\n    let n = xs.len();\n    let i = slice_leading_zeros(xs);\n    assert!(i < n);\n    let starting_limb_index = bit_to_limb_count_floor(starting_index);\n    if starting_limb_index >= n {\n        return None;\n    }\n    let after_boundary_offset = limb_to_bit_count(i + 1);\n    match starting_limb_index.cmp(&i) {\n        Equal => {\n            let within_limb_index = starting_index & Limb::WIDTH_MASK;\n            if let Some(result) = xs[i]\n                .wrapping_neg()\n                .index_of_next_false_bit(within_limb_index)\n            {\n                if result < Limb::WIDTH {\n                    return Some(limb_to_bit_count(i) + result);\n                }\n                starting_index = 0;\n            }\n        }\n        Less => {\n            return Some(starting_index);\n        }\n        Greater => {\n            starting_index -= after_boundary_offset;\n        }\n    }\n    limbs_index_of_next_true_bit(&xs[i + 1..], starting_index)\n        .map(|result| result + after_boundary_offset)\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, finds the lowest index greater than or equal to `starting_index` at which the\n// `Integer` has a `true` bit.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpz_scan1` from `mpz/scan1.c`, GMP 6.2.1.\npub_test! {limbs_index_of_next_true_bit_neg(xs: &[Limb], mut starting_index: u64) -> u64 {\n    let n = xs.len();\n    let i = slice_leading_zeros(xs);\n    assert!(i < n);\n    let mut starting_limb_index = bit_to_limb_count_floor(starting_index);\n    if starting_limb_index >= n {\n        return starting_index;\n    }\n    let after_boundary_offset = limb_to_bit_count(i + 1);\n    if starting_limb_index < i {\n        starting_index = limb_to_bit_count(i);\n        starting_limb_index = i;\n    }\n    if starting_limb_index == i {\n        let within_limb_index = starting_index & Limb::WIDTH_MASK;\n        if let Some(result) = xs[i]\n            .wrapping_neg()\n            .index_of_next_true_bit(within_limb_index)\n        {\n            return limb_to_bit_count(i) + result;\n        }\n        starting_index = 0;\n    } else {\n        starting_index -= after_boundary_offset;\n    }\n    limbs_index_of_next_false_bit(&xs[i + 1..], starting_index) + after_boundary_offset\n}}\n\nimpl Natural {\n    // self != 0\n    fn index_of_next_false_bit_neg(&self, starting_index: u64) -> Option<u64> {\n        match self {\n            Self(Small(small)) => {\n                if starting_index >= Limb::WIDTH {\n                    None\n                } else {\n                    let index = TrailingZeros::trailing_zeros(\n                        (small - 1) & !Limb::low_mask(starting_index),\n                    );\n                    if index == Limb::WIDTH {\n                        None\n                    } else {\n                        Some(index)\n                    }\n                }\n            }\n            Self(Large(limbs)) => limbs_index_of_next_false_bit_neg(limbs, starting_index),\n        }\n    }\n\n    // self != 0\n    fn index_of_next_true_bit_neg(&self, starting_index: u64) -> u64 {\n        match self {\n            Self(Small(small)) => {\n                if starting_index >= Limb::WIDTH {\n                    starting_index\n                } else {\n                    TrailingZeros::trailing_zeros(!((small - 1) | Limb::low_mask(starting_index)))\n                }\n            }\n            Self(Large(limbs)) => limbs_index_of_next_true_bit_neg(limbs, starting_index),\n        }\n    }\n}\n\nimpl BitScan for &Integer {\n    /// Given an [`Integer`] and a starting index, searches the [`Integer`] for the smallest index\n    /// of a `false` bit that is greater than or equal to the starting index.\n    ///\n    /// If the [`Integer]` is negative, and the starting index is too large and there are no more\n    /// `false` bits above it, `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitScan;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(0),\n    ///     Some(0)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(20),\n    ///     Some(20)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(31),\n    ///     Some(31)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(32),\n    ///     Some(34)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(33),\n    ///     Some(34)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(34),\n    ///     Some(34)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(35),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_false_bit(100),\n    ///     None\n    /// );\n    /// ```\n    fn index_of_next_false_bit(self, starting_index: u64) -> Option<u64> {\n        if self.sign {\n            self.abs.index_of_next_false_bit(starting_index)\n        } else {\n            self.abs.index_of_next_false_bit_neg(starting_index)\n        }\n    }\n\n    /// Given an [`Integer`] and a starting index, searches the [`Integer`] for the smallest index\n    /// of a `true` bit that is greater than or equal to the starting index.\n    ///\n    /// If the [`Integer`] is non-negative, and the starting index is too large and there are no\n    /// more `true` bits above it, `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitScan;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(0),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(20),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(31),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(32),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(33),\n    ///     Some(33)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(34),\n    ///     Some(35)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(35),\n    ///     Some(35)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(36),\n    ///     Some(36)\n    /// );\n    /// assert_eq!(\n    ///     (-Integer::from(0x500000000u64)).index_of_next_true_bit(100),\n    ///     Some(100)\n    /// );\n    /// ```\n    fn index_of_next_true_bit(self, starting_index: u64) -> Option<u64> {\n        if self.sign {\n            self.abs.index_of_next_true_bit(starting_index)\n        } else {\n            Some(self.abs.index_of_next_true_bit_neg(starting_index))\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/checked_count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::logic::traits::CountOnes;\n\nimpl Integer {\n    /// Counts the number of ones in the binary expansion of an [`Integer`]. If the [`Integer`] is\n    /// negative, then the number of ones is infinite, so `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.checked_count_ones(), Some(0));\n    /// // 105 = 1101001b\n    /// assert_eq!(Integer::from(105).checked_count_ones(), Some(4));\n    /// assert_eq!(Integer::from(-105).checked_count_ones(), None);\n    /// // 10^12 = 1110100011010100101001010001000000000000b\n    /// assert_eq!(Integer::from(10u32).pow(12).checked_count_ones(), Some(13));\n    /// ```\n    pub fn checked_count_ones(&self) -> Option<u64> {\n        if self.sign {\n            Some(self.abs.count_ones())\n        } else {\n            None\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/checked_count_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{CountOnes, CountZeros};\n\n// Interpreting a slice of `Limb`s, as the limbs (in ascending order) of a `Natural`, counts the\n// number of zeros in the binary expansion of the negative (two's complement) of the `Natural`.\n// `limbs` cannot be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_crate_test! {limbs_count_zeros_neg(xs: &[Limb]) -> u64 {\n    let mut sum = 0;\n    let mut nonzero_seen = false;\n    for &x in xs {\n        sum += if nonzero_seen {\n            CountOnes::count_ones(x)\n        } else if x == 0 {\n            Limb::WIDTH\n        } else {\n            nonzero_seen = true;\n            CountZeros::count_zeros(x.wrapping_neg())\n        };\n    }\n    sum\n}}\n\nimpl Natural {\n    fn count_zeros_neg(&self) -> u64 {\n        match self {\n            Self(Small(small)) => CountZeros::count_zeros(small.wrapping_neg()),\n            Self(Large(limbs)) => limbs_count_zeros_neg(limbs),\n        }\n    }\n}\n\nimpl Integer {\n    /// Counts the number of zeros in the binary expansion of an [`Integer`]. If the [`Integer`] is\n    /// non-negative, then the number of zeros is infinite, so `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.checked_count_zeros(), None);\n    /// // -105 = 10010111 in two's complement\n    /// assert_eq!(Integer::from(-105).checked_count_zeros(), Some(3));\n    /// assert_eq!(Integer::from(105).checked_count_zeros(), None);\n    /// // -10^12 = 10001011100101011010110101111000000000000 in two's complement\n    /// assert_eq!(\n    ///     (-Integer::from(10u32).pow(12)).checked_count_zeros(),\n    ///     Some(24)\n    /// );\n    /// ```\n    pub fn checked_count_zeros(&self) -> Option<u64> {\n        if self.sign {\n            None\n        } else {\n            Some(self.abs.count_zeros_neg())\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/checked_hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1994, 1996, 2001, 2002, 2009-2011 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::logic::checked_count_zeros::limbs_count_zeros_neg;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::logic::count_ones::limbs_count_ones;\nuse crate::natural::logic::hamming_distance::limbs_hamming_distance_same_length;\nuse crate::platform::Limb;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::logic::traits::{\n    CheckedHammingDistance, CountOnes, CountZeros, HammingDistance,\n};\nuse malachite_base::slices::slice_leading_zeros;\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, returns the\n// Hamming distance between the negative of that `Natural` (two's complement) and the negative of a\n// `Limb`. Both have infinitely many implicit leading ones. `xs` cannot be empty or only contain\n// zeros; `y` cannot be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_hamming_distance_limb_neg(xs: &[Limb], y: Limb) -> u64 {\n    let x_lo = xs[0].wrapping_neg();\n    limbs_count_zeros_neg(xs) - CountZeros::count_zeros(x_lo)\n        + x_lo.hamming_distance(y.wrapping_neg())\n}}\n\nfn limbs_count_zeros(xs: &[Limb]) -> u64 {\n    xs.iter().map(|&limb| CountZeros::count_zeros(limb)).sum()\n}\n\nfn limbs_hamming_distance_neg_leading_limbs_helper(xs: &[Limb], ys: &[Limb], i: usize) -> u64 {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    match xs_len.cmp(&ys_len) {\n        Equal => limbs_hamming_distance_same_length(&xs[i + 1..], &ys[i + 1..]),\n        Less => {\n            let (ys_lo, ys_hi) = ys.split_at(xs_len);\n            limbs_hamming_distance_same_length(&ys_lo[i + 1..], &xs[i + 1..])\n                + limbs_count_ones(ys_hi)\n        }\n        Greater => {\n            let (xs_lo, xs_hi) = xs.split_at(ys_len);\n            limbs_hamming_distance_same_length(&xs_lo[i + 1..], &ys[i + 1..])\n                + limbs_count_ones(xs_hi)\n        }\n    }\n}\n\n// ```\n// xs: nnnnnnnb000\n// ys:   nnb000000\n// ```\n//\n// or\n// ```\n// xs:   nnnnnb000\n// ys: nnnnb000000\n// ```\n//\n// where 0 is a zero limb, n is a nonzero limb, and b is the boundary (least-significant) nonzero\n// limb. xs_i and ys_i are the indices of the boundary limbs in xs and ys. xs_i < ys_i but xs may be\n// shorter, longer, or the same length as ys.\nfn limbs_hamming_distance_neg_helper(xs: &[Limb], ys: &[Limb], xs_i: usize, ys_i: usize) -> u64 {\n    let mut distance = CountOnes::count_ones(xs[xs_i].wrapping_neg());\n    let xs_len = xs.len();\n    if xs_i == xs_len - 1 {\n        return distance + limbs_count_zeros_neg(&ys[xs_len..]);\n    }\n    if xs_len < ys_i {\n        return distance\n            + limbs_count_zeros(&xs[xs_i + 1..])\n            + limbs_count_zeros_neg(&ys[xs_len..]);\n    }\n    distance += limbs_count_zeros(&xs[xs_i + 1..ys_i]);\n    if xs_len == ys_i {\n        return distance + limbs_count_zeros_neg(&ys[xs_len..]);\n    }\n    distance += ys[ys_i].wrapping_neg().hamming_distance(!xs[ys_i]);\n    if xs_len == ys_i + 1 {\n        return distance + limbs_count_ones(&ys[xs_len..]);\n    }\n    distance + limbs_hamming_distance_neg_leading_limbs_helper(xs, ys, ys_i)\n}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs of `Natural`s in ascending order,\n// returns the Hamming distance between their negatives (two's complement). Both have infinitely\n// many implicit leading ones. Neither slice may be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if `xs` or `ys` only contain zeros.\n//\n// This is equivalent to `mpz_hamdist` from `mpz/hamdist.c`, GMP 6.2.1, where both arguments are\n// negative and have the same length.\npub_test! {limbs_hamming_distance_neg(xs: &[Limb], ys: &[Limb]) -> u64 {\n    let xs_i = slice_leading_zeros(xs);\n    let ys_i = slice_leading_zeros(ys);\n    match xs_i.cmp(&ys_i) {\n        Equal => {\n            xs[xs_i]\n                .wrapping_neg()\n                .hamming_distance(ys[ys_i].wrapping_neg())\n                + limbs_hamming_distance_neg_leading_limbs_helper(xs, ys, xs_i)\n        }\n        Less => limbs_hamming_distance_neg_helper(xs, ys, xs_i, ys_i),\n        Greater => limbs_hamming_distance_neg_helper(ys, xs, ys_i, xs_i),\n    }\n}}\n\nimpl Natural {\n    fn hamming_distance_neg_limb(&self, other: Limb) -> u64 {\n        match self {\n            Self(Small(small)) => small.wrapping_neg().hamming_distance(other.wrapping_neg()),\n            Self(Large(limbs)) => limbs_hamming_distance_limb_neg(limbs, other),\n        }\n    }\n\n    fn hamming_distance_neg(&self, other: &Self) -> u64 {\n        match (self, other) {\n            (&Self(Small(x)), _) => other.hamming_distance_neg_limb(x),\n            (_, &Self(Small(y))) => self.hamming_distance_neg_limb(y),\n            (Self(Large(xs)), Self(Large(ys))) => limbs_hamming_distance_neg(xs, ys),\n        }\n    }\n}\n\nimpl CheckedHammingDistance<&Integer> for &Integer {\n    /// Determines the Hamming distance between two [`Integer`]s.\n    ///\n    /// The two [`Integer`]s have infinitely many leading zeros or infinitely many leading ones,\n    /// depending on their signs. If they are both non-negative or both negative, the Hamming\n    /// distance is finite. If one is non-negative and the other is negative, the Hamming distance\n    /// is infinite, so `None` is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::CheckedHammingDistance;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(123).checked_hamming_distance(&Integer::from(123)),\n    ///     Some(0)\n    /// );\n    /// // 105 = 1101001b, 123 = 1111011\n    /// assert_eq!(\n    ///     Integer::from(-105).checked_hamming_distance(&Integer::from(-123)),\n    ///     Some(2)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-105).checked_hamming_distance(&Integer::from(123)),\n    ///     None\n    /// );\n    /// ```\n    fn checked_hamming_distance(self, other: &Integer) -> Option<u64> {\n        match (self.sign, other.sign) {\n            (true, true) => Some(self.abs.hamming_distance(&other.abs)),\n            (false, false) => Some(self.abs.hamming_distance_neg(&other.abs)),\n            _ => None,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::logic::traits::LowMask;\n\nimpl LowMask for Integer {\n    /// Returns an [`Integer`] whose least significant $b$ bits are `true` and whose other bits are\n    /// `false`.\n    ///\n    /// $f(b) = 2^b - 1$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `bits`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::LowMask;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::low_mask(0), 0);\n    /// assert_eq!(Integer::low_mask(3), 7);\n    /// assert_eq!(\n    ///     Integer::low_mask(100).to_string(),\n    ///     \"1267650600228229401496703205375\"\n    /// );\n    /// ```\n    #[inline]\n    fn low_mask(bits: u64) -> Self {\n        Self::from(Natural::low_mask(bits))\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Bitwise and of [`Integer`](super::Integer)s.\npub mod and;\n/// An implementation of [`BitAccess`](malachite_base::num::logic::traits::BitAccess), a trait for\n/// getting and setting individual bits of a number.\npub mod bit_access;\n/// An implementation of [`BitBlockAccess`](malachite_base::num::logic::traits::BitBlockAccess), a\n/// trait for getting and setting adjacent blocks of bits in a number.\npub mod bit_block_access;\n/// An implementation of [`BitConvertible`](malachite_base::num::logic::traits::BitConvertible), a\n/// trait for extracting all bits from a number or constructing a number from bits.\npub mod bit_convertible;\n/// An implementation of [`BitIterable`](malachite_base::num::logic::traits::BitIterable), a trait\n/// for producing a double-ended iterator over a number's bits.\npub mod bit_iterable;\n/// An implementation of [`BitScan`](malachite_base::num::logic::traits::BitScan), a trait for\n/// finding the next `true` or `false` bit in a number after a provided index.\npub mod bit_scan;\n/// A function counting the number of ones in the binary representation of a number.\npub mod checked_count_ones;\n/// A function counting the number of zeros in the binary representation of a number.\npub mod checked_count_zeros;\n/// An implementation of\n/// [`CheckedHammingDistance`](malachite_base::num::logic::traits::CheckedHammingDistance), a trait\n/// for computing the Hamming distance between two numbers.\npub mod checked_hamming_distance;\n/// An implementation of [`LowMask`](malachite_base::num::logic::traits::LowMask), a trait for\n/// generating a low bit mask (a number in which only the $k$ least-significant bits are 1).\npub mod low_mask;\n/// Bitwise negation of [`Integer`](super::Integer)s.\npub mod not;\n/// Bitwise or of [`Integer`](super::Integer)s.\npub mod or;\n/// An implementation of [`SignificantBits`](malachite_base::num::logic::traits::SignificantBits), a\n/// trait for determining how many significant bits a number has.\npub mod significant_bits;\n/// An implementation of [`TrailingZeros`](malachite_base::num::logic::traits::TrailingZeros), a\n/// trait for determining the number of zeros that a number ends with when written in binary.\npub mod trailing_zeros;\n/// Bitwise xor of [`Integer`](super::Integer)s.\npub mod xor;\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/not.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse core::ops::Not;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::logic::traits::NotAssign;\n\nimpl Not for Integer {\n    type Output = Self;\n\n    /// Returns the bitwise negation of an [`Integer`], taking it by value.\n    ///\n    /// $$\n    /// f(n) = -n - 1.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(!Integer::ZERO, -1);\n    /// assert_eq!(!Integer::from(123), -124);\n    /// assert_eq!(!Integer::from(-123), 122);\n    /// ```\n    #[inline]\n    fn not(mut self) -> Self {\n        self.not_assign();\n        self\n    }\n}\n\nimpl Not for &Integer {\n    type Output = Integer;\n\n    /// Returns the bitwise negation of an [`Integer`], taking it by reference.\n    ///\n    /// $$\n    /// f(n) = -n - 1.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(!&Integer::ZERO, -1);\n    /// assert_eq!(!&Integer::from(123), -124);\n    /// assert_eq!(!&Integer::from(-123), 122);\n    /// ```\n    fn not(self) -> Integer {\n        match self {\n            Integer { sign: true, abs } => Integer {\n                sign: false,\n                abs: abs.add_limb_ref(1),\n            },\n            Integer { sign: false, abs } => Integer {\n                sign: true,\n                abs: abs.sub_limb_ref(1),\n            },\n        }\n    }\n}\n\nimpl NotAssign for Integer {\n    /// Replaces an [`Integer`] with its bitwise negation.\n    ///\n    /// $$\n    /// n \\gets -n - 1.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::NotAssign;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x.not_assign();\n    /// assert_eq!(x, -1);\n    ///\n    /// let mut x = Integer::from(123);\n    /// x.not_assign();\n    /// assert_eq!(x, -124);\n    ///\n    /// let mut x = Integer::from(-123);\n    /// x.not_assign();\n    /// assert_eq!(x, 122);\n    /// ```\n    fn not_assign(&mut self) {\n        if self.sign {\n            self.sign = false;\n            self.abs += Natural::ONE;\n        } else {\n            self.sign = true;\n            self.abs -= Natural::ONE;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2005, 2012, 2013, 2015-2018 Free\n//      Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::logic::not::{limbs_not_in_place, limbs_not_to_out};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, max};\nuse core::ops::{BitOr, BitOrAssign};\nuse itertools::repeat_n;\nuse malachite_base::num::arithmetic::traits::WrappingNegAssign;\nuse malachite_base::slices::{slice_leading_zeros, slice_set_zero};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, returns the limbs of the bitwise or of the `Integer` and a `Limb`. `xs` cannot be\n// empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if `xs` is empty or only contains zeros.\npub_test! {limbs_neg_or_limb(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    if y == 0 {\n        return xs.to_vec();\n    }\n    let mut out = vec![0; xs.len()];\n    let i = slice_leading_zeros(xs);\n    if i == 0 {\n        out[0] = (xs[0].wrapping_neg() | y).wrapping_neg();\n        out[1..].copy_from_slice(&xs[1..]);\n    } else {\n        out[0] = y.wrapping_neg();\n        for x in &mut out[1..i] {\n            *x = Limb::MAX;\n        }\n        out[i] = xs[i] - 1;\n        out[i + 1..].copy_from_slice(&xs[i + 1..]);\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, writes the limbs of the bitwise or of the `Integer` and a `Limb` to an output slice.\n// The output slice must be at least as long as the input slice. `xs` cannot be empty or only\n// contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if `xs` is empty or only contains zeros, or if `out` is shorter than `xs`.\npub_test! {limbs_neg_or_limb_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) {\n    let len = xs.len();\n    assert!(out.len() >= len);\n    if y == 0 {\n        out[..len].copy_from_slice(xs);\n        return;\n    }\n    let i = slice_leading_zeros(xs);\n    if i == 0 {\n        out[0] = (xs[0].wrapping_neg() | y).wrapping_neg();\n        out[1..len].copy_from_slice(&xs[1..]);\n    } else {\n        out[0] = y.wrapping_neg();\n        for x in &mut out[1..i] {\n            *x = Limb::MAX;\n        }\n        out[i] = xs[i] - 1;\n        out[i + 1..len].copy_from_slice(&xs[i + 1..]);\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, writes the limbs of the bitwise or of the `Integer`, writes the limbs of the bitwise\n// or of the `Integer` and a `Limb` to the input slice. `xs` cannot be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if `xs` is empty or only contains zeros.\npub_test! {limbs_neg_or_limb_in_place(xs: &mut [Limb], y: Limb) {\n    if y == 0 {\n        return;\n    }\n    let i = slice_leading_zeros(xs);\n    if i == 0 {\n        xs[0] = (xs[0].wrapping_neg() | y).wrapping_neg();\n    } else {\n        xs[0] = y.wrapping_neg();\n        for x in &mut xs[1..i] {\n            *x = Limb::MAX;\n        }\n        xs[i] -= 1;\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of an `Integer`, returns the\n// negative of the bitwise or of the `Integer` and a negative number whose lowest limb is given by\n// `y` and whose other limbs are full of `true` bits. The slice cannot be empty or only contain\n// zeros.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_const_test! {limbs_pos_or_neg_limb(xs: &[Limb], y: Limb) -> Limb {\n    (xs[0] | y).wrapping_neg()\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, returns the negative of the bitwise or of the `Integer` and a negative number whose\n// lowest limb is given by `y` and whose other limbs are full of `true` bits. The slice cannot be\n// empty or only contain zeros.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_const_test! {limbs_neg_or_neg_limb(xs: &[Limb], y: Limb) -> Limb {\n    (xs[0].wrapping_neg() | y).wrapping_neg()\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, returns the limbs of the bitwise or of the `Integer`s. `xs` and `ys` may not\n// be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is\n// `ys.len()`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res` is returned, the first\n// input is positive, and the second is negative.\npub_test! {limbs_or_pos_neg(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        let mut out = vec![0; x_i];\n        out.push(xs[x_i].wrapping_neg());\n        out.extend(xs[x_i + 1..].iter().map(|x| !x));\n        out.extend(repeat_n(Limb::MAX, y_i - xs_len));\n        out.push(ys[y_i] - 1);\n        out.extend_from_slice(&ys[y_i + 1..]);\n        out\n    } else if x_i >= ys_len {\n        ys.to_vec()\n    } else {\n        let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n        let mut out = vec![0; min_i];\n        match x_i.cmp(&y_i) {\n            Equal => {\n                out.push((!xs[x_i] & (ys[y_i] - 1)) + 1);\n            }\n            Less => {\n                out.push(xs[x_i].wrapping_neg());\n                out.extend(xs[x_i + 1..y_i].iter().map(|x| !x));\n                out.push(!xs[y_i] & (ys[y_i] - 1));\n            }\n            Greater => {\n                out.extend_from_slice(&ys[y_i..x_i]);\n                out.push(!xs[x_i] & ys[x_i]);\n            }\n        }\n        out.extend(\n            xs[max_i + 1..]\n                .iter()\n                .zip(ys[max_i + 1..].iter())\n                .map(|(x, y)| !x & y),\n        );\n        if xs_len < ys_len {\n            out.extend_from_slice(&ys[xs_len..]);\n        }\n        out\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise or of the `Integer`s to an output slice.\n// `xs` and `ys` may not be empty or only contain zeros. The output slice must be at least as long\n// as the second input slice. `ys.len()` limbs will be written; if the number of significant limbs\n// of the result is lower, some of the written limbs will be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros, or if `out` is shorter than `ys`.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where the first input is positive\n// and the second is negative.\npub_test! {limbs_or_pos_neg_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(out.len() >= ys_len);\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        slice_set_zero(&mut out[..x_i]);\n        out[x_i] = xs[x_i].wrapping_neg();\n        limbs_not_to_out(&mut out[x_i + 1..xs_len], &xs[x_i + 1..]);\n        for x in &mut out[xs_len..y_i] {\n            *x = Limb::MAX;\n        }\n        out[y_i] = ys[y_i] - 1;\n        out[y_i + 1..ys_len].copy_from_slice(&ys[y_i + 1..]);\n    } else if x_i >= ys_len {\n        out[..ys_len].copy_from_slice(ys);\n    } else {\n        let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n        slice_set_zero(&mut out[..min_i]);\n        match x_i.cmp(&y_i) {\n            Equal => {\n                out[x_i] = (!xs[x_i] & (ys[y_i] - 1)) + 1;\n            }\n            Less => {\n                out[x_i] = xs[x_i].wrapping_neg();\n                limbs_not_to_out(&mut out[x_i + 1..y_i], &xs[x_i + 1..y_i]);\n                out[y_i] = !xs[y_i] & (ys[y_i] - 1);\n            }\n            Greater => {\n                out[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n                out[x_i] = !xs[x_i] & ys[x_i];\n            }\n        }\n        for (out, (x, y)) in out[max_i + 1..]\n            .iter_mut()\n            .zip(xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter()))\n        {\n            *out = !x & y;\n        }\n        if xs_len < ys_len {\n            out[xs_len..ys_len].copy_from_slice(&ys[xs_len..]);\n        }\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise or of the `Integer`s to the first (left)\n// slice. `xs` and `ys` may not be empty or only contain zeros. Returns whether the result is too\n// large to be contained in the first slice; if it is, only the lowest `xs.len()` limbs are written.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res == op1`, the first input\n// is positive and the second is negative, and the length of `op1` is not changed; instead, a carry\n// is returned.\npub_test! {limbs_slice_or_pos_neg_in_place_left(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        xs[x_i].wrapping_neg_assign();\n        limbs_not_in_place(&mut xs[x_i + 1..]);\n        true\n    } else if x_i >= ys_len {\n        xs[..ys_len].copy_from_slice(ys);\n        slice_set_zero(&mut xs[ys_len..]);\n        false\n    } else {\n        let max_i = max(x_i, y_i);\n        match x_i.cmp(&y_i) {\n            Equal => {\n                xs[x_i] = (!xs[x_i] & (ys[y_i] - 1)) + 1;\n            }\n            Less => {\n                xs[x_i].wrapping_neg_assign();\n                limbs_not_in_place(&mut xs[x_i + 1..y_i]);\n                xs[y_i] = !xs[y_i] & (ys[y_i] - 1);\n            }\n            Greater => {\n                xs[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n                xs[x_i] = !xs[x_i] & ys[x_i];\n            }\n        }\n        if xs_len < ys_len {\n            for (x, y) in xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..xs_len].iter()) {\n                *x = !*x & y;\n            }\n            true\n        } else {\n            for (x, y) in xs[max_i + 1..ys_len].iter_mut().zip(ys[max_i + 1..].iter()) {\n                *x = !*x & y;\n            }\n            slice_set_zero(&mut xs[ys_len..]);\n            false\n        }\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise or of the `Integer`s to the first (left)\n// slice. `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res == op1` and the first\n// input is positive and the second is negative.\npub_test! {limbs_vec_or_pos_neg_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        xs[x_i].wrapping_neg_assign();\n        limbs_not_in_place(&mut xs[x_i + 1..]);\n        xs.extend(repeat_n(Limb::MAX, y_i - xs_len));\n        xs.push(ys[y_i] - 1);\n        xs.extend_from_slice(&ys[y_i + 1..]);\n    } else if x_i >= ys_len {\n        *xs = ys.to_vec();\n    } else {\n        let max_i = max(x_i, y_i);\n        match x_i.cmp(&y_i) {\n            Equal => {\n                xs[x_i] = (!xs[x_i] & (ys[y_i] - 1)) + 1;\n            }\n            Less => {\n                xs[x_i].wrapping_neg_assign();\n                limbs_not_in_place(&mut xs[x_i + 1..y_i]);\n                xs[y_i] = !xs[y_i] & (ys[y_i] - 1);\n            }\n            Greater => {\n                xs[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n                xs[x_i] = !xs[x_i] & ys[x_i];\n            }\n        }\n        if xs_len < ys_len {\n            for (x, y) in xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..xs_len].iter()) {\n                *x = !*x & y;\n            }\n            xs.extend_from_slice(&ys[xs_len..]);\n        } else {\n            for (x, y) in xs[max_i + 1..ys_len].iter_mut().zip(ys[max_i + 1..].iter()) {\n                *x = !*x & y;\n            }\n            xs.truncate(ys_len);\n        }\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise or of the `Integer`s to the second (right)\n// slice. `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res == op2` and the first\n// input is positive and the second is negative.\npub_test! {limbs_or_pos_neg_in_place_right(xs: &[Limb], ys: &mut [Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        ys[x_i] = xs[x_i].wrapping_neg();\n        limbs_not_to_out(&mut ys[x_i + 1..xs_len], &xs[x_i + 1..]);\n        for y in &mut ys[xs_len..y_i] {\n            *y = Limb::MAX;\n        }\n        ys[y_i] -= 1;\n    } else if x_i < ys_len {\n        let max_i = max(x_i, y_i);\n        match x_i.cmp(&y_i) {\n            Equal => {\n                ys[y_i] = (!xs[x_i] & (ys[y_i] - 1)) + 1;\n            }\n            Less => {\n                ys[x_i] = xs[x_i].wrapping_neg();\n                limbs_not_to_out(&mut ys[x_i + 1..y_i], &xs[x_i + 1..y_i]);\n                ys[y_i] = !xs[y_i] & (ys[y_i] - 1);\n            }\n            Greater => {\n                ys[x_i] &= !xs[x_i];\n            }\n        }\n        if xs_len < ys_len {\n            for (x, y) in xs[max_i + 1..].iter().zip(ys[max_i + 1..xs_len].iter_mut()) {\n                *y &= !x;\n            }\n        } else {\n            for (x, y) in xs[max_i + 1..ys_len].iter().zip(ys[max_i + 1..].iter_mut()) {\n                *y &= !x;\n            }\n        }\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, returns the limbs of the bitwise or of the `Integer`s. `xs` and `ys` may not be empty\n// or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is\n// `min(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res` is returned and both\n// inputs are negative.\npub_test! {limbs_or_neg_neg(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        xs.to_vec()\n    } else if x_i >= ys_len {\n        ys.to_vec()\n    } else {\n        let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n        let mut out = vec![0; min_i];\n        let x = match x_i.cmp(&y_i) {\n            Equal => ((xs[x_i] - 1) & (ys[y_i] - 1)) + 1,\n            Less => {\n                out.extend_from_slice(&xs[x_i..y_i]);\n                xs[y_i] & (ys[y_i] - 1)\n            }\n            Greater => {\n                out.extend_from_slice(&ys[y_i..x_i]);\n                (xs[x_i] - 1) & ys[x_i]\n            }\n        };\n        out.push(x);\n        out.extend(\n            xs[max_i + 1..]\n                .iter()\n                .zip(ys[max_i + 1..].iter())\n                .map(|(x, y)| x & y),\n        );\n        out\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the max(`xs.len()`, `ys.len()`) limbs of the bitwise or of the `Integer`s to\n// an output slice. `xs` and `ys` may not be empty or only contain zeros. The output slice must be\n// at least as long as the shorter input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros, or if `out` is shorter than the shorter\n// of `xs` and `ys`.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where both inputs are negative.\npub_test! {limbs_or_neg_neg_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(out.len() >= xs_len || out.len() >= ys_len);\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        out[..xs_len].copy_from_slice(xs);\n    } else if x_i >= ys_len {\n        out[..ys_len].copy_from_slice(ys);\n    } else {\n        let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n        slice_set_zero(&mut out[..min_i]);\n        let x = match x_i.cmp(&y_i) {\n            Equal => ((xs[x_i] - 1) & (ys[y_i] - 1)) + 1,\n            Less => {\n                out[x_i..y_i].copy_from_slice(&xs[x_i..y_i]);\n                xs[y_i] & (ys[y_i] - 1)\n            }\n            Greater => {\n                out[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n                (xs[x_i] - 1) & ys[x_i]\n            }\n        };\n        out[max_i] = x;\n        for (out, (x, y)) in out[max_i + 1..]\n            .iter_mut()\n            .zip(xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter()))\n        {\n            *out = x & y;\n        }\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the limbs of the bitwise or of the `Integer`s to the first (left) slice. `xs`\n// and `ys` may not be empty or only contain zeros. If the result has fewer significant limbs than\n// the left slice, the remaining limbs in the left slice are set to `Limb::MAX`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res == op1`, both inputs are\n// negative, and the length of `op1` is not changed.\npub_test! {limbs_slice_or_neg_neg_in_place_left(xs: &mut [Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n    } else if x_i >= ys_len {\n        xs[..ys_len].copy_from_slice(ys);\n        slice_set_zero(&mut xs[ys_len..]);\n    } else {\n        let max_i = max(x_i, y_i);\n        if x_i > y_i {\n            xs[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n        }\n        xs[max_i] = match x_i.cmp(&y_i) {\n            Equal => ((xs[x_i] - 1) & (ys[y_i] - 1)) + 1,\n            Less => xs[y_i] & (ys[y_i] - 1),\n            Greater => (xs[x_i] - 1) & ys[x_i],\n        };\n        for (x, y) in xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..].iter()) {\n            *x &= y;\n        }\n        if xs_len > ys_len {\n            slice_set_zero(&mut xs[ys_len..]);\n        }\n    }\n}}\n\n// Interpreting a slice of `Limb`s and a `Vec` of `Limb`s as the limbs (in ascending order) of the\n// negatives of two `Integer`s, writes the limbs of the bitwise or of the `Integer`s to the `Vec`.\n// `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res == op1` and both inputs\n// are negative.\npub_test! {limbs_vec_or_neg_neg_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n    } else if x_i >= ys_len {\n        xs.truncate(ys_len);\n        xs.copy_from_slice(ys);\n    } else {\n        let max_i = max(x_i, y_i);\n        if x_i > y_i {\n            xs[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n        }\n        xs[max_i] = match x_i.cmp(&y_i) {\n            Equal => ((xs[x_i] - 1) & (ys[y_i] - 1)) + 1,\n            Less => xs[y_i] & (ys[y_i] - 1),\n            Greater => (xs[x_i] - 1) & ys[x_i],\n        };\n        for (x, y) in xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..].iter()) {\n            *x &= y;\n        }\n        xs.truncate(ys_len);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the lower min(`xs.len()`, `ys.len()`) limbs of the bitwise or of the\n// `Integer`s to the shorter slice (or the first one, if they are equally long). `xs` and `ys` may\n// not be empty or only contain zeros. Returns a `bool` which is `false` when the output is to the\n// first slice and `true` when it's to the second slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where both inputs are negative and\n// the result is written to the shorter input slice.\npub_test! {limbs_or_neg_neg_in_place_either(xs: &mut [Limb], ys: &mut [Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        false\n    } else if x_i >= ys_len {\n        true\n    } else {\n        let max_i = max(x_i, y_i);\n        let boundary = match x_i.cmp(&y_i) {\n            Equal => ((xs[x_i] - 1) & (ys[y_i] - 1)) + 1,\n            Less => xs[y_i] & (ys[y_i] - 1),\n            Greater => (xs[x_i] - 1) & ys[x_i],\n        };\n        if xs_len > ys_len {\n            if y_i > x_i {\n                ys[x_i..y_i].copy_from_slice(&xs[x_i..y_i]);\n            }\n            ys[max_i] = boundary;\n            for (y, x) in ys[max_i + 1..].iter_mut().zip(xs[max_i + 1..].iter()) {\n                *y &= x;\n            }\n            true\n        } else {\n            if x_i > y_i {\n                xs[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n            }\n            xs[max_i] = boundary;\n            for (x, y) in xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..].iter()) {\n                *x &= y;\n            }\n            false\n        }\n    }\n}}\n\nimpl Natural {\n    fn or_assign_pos_limb_neg(&mut self, other: Limb) {\n        *self = self.or_pos_limb_neg(other);\n    }\n\n    fn or_pos_limb_neg(&self, other: Limb) -> Self {\n        Self(Small(match self {\n            Self(Small(small)) => (small | other).wrapping_neg(),\n            Self(Large(limbs)) => limbs_pos_or_neg_limb(limbs, other),\n        }))\n    }\n\n    fn or_assign_neg_limb_neg(&mut self, other: Limb) {\n        *self = self.or_neg_limb_neg(other);\n    }\n\n    #[allow(clippy::missing_const_for_fn)]\n    fn or_neg_limb_neg(&self, other: Limb) -> Self {\n        Self(Small(match self {\n            Self(Small(small)) => (small.wrapping_neg() | other).wrapping_neg(),\n            Self(Large(limbs)) => limbs_neg_or_neg_limb(limbs, other),\n        }))\n    }\n\n    fn or_assign_neg_limb_pos(&mut self, other: Limb) {\n        match self {\n            Self(Small(small)) => {\n                *small = (small.wrapping_neg() | other).wrapping_neg();\n            }\n            Self(Large(limbs)) => {\n                limbs_neg_or_limb_in_place(limbs, other);\n                self.trim();\n            }\n        }\n    }\n\n    fn or_neg_limb_pos(&self, other: Limb) -> Self {\n        match self {\n            Self(Small(small)) => Self(Small((small.wrapping_neg() | other).wrapping_neg())),\n            Self(Large(limbs)) => Self::from_owned_limbs_asc(limbs_neg_or_limb(limbs, other)),\n        }\n    }\n\n    fn or_assign_pos_neg_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (_, Self(Small(y))) => self.or_assign_pos_limb_neg(y.wrapping_neg()),\n            (Self(Small(x)), _) => *self = other.or_neg_limb_pos(*x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_vec_or_pos_neg_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n\n    fn or_assign_pos_neg(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (_, Self(Small(y))) => self.or_assign_pos_limb_neg(y.wrapping_neg()),\n            (Self(Small(x)), _) => {\n                other.or_assign_neg_limb_pos(*x);\n                *self = other;\n            }\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_or_pos_neg_in_place_right(xs, ys);\n                *self = other;\n                self.trim();\n            }\n        }\n    }\n\n    fn or_assign_neg_pos_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (_, Self(Small(y))) => self.or_assign_neg_limb_pos(*y),\n            (Self(Small(x)), _) => *self = other.or_pos_limb_neg(x.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_or_pos_neg_in_place_right(ys, xs);\n                self.trim();\n            }\n        }\n    }\n\n    fn or_assign_neg_pos(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (_, Self(Small(y))) => self.or_assign_neg_limb_pos(*y),\n            (Self(Small(x)), _) => {\n                other.or_assign_pos_limb_neg(x.wrapping_neg());\n                *self = other;\n            }\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_or_pos_neg_in_place_right(ys, xs);\n                self.trim();\n            }\n        }\n    }\n\n    fn or_pos_neg(&self, other: &Self) -> Self {\n        match (self, other) {\n            (_, &Self(Small(y))) => self.or_pos_limb_neg(y.wrapping_neg()),\n            (&Self(Small(x)), _) => other.or_neg_limb_pos(x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                Self::from_owned_limbs_asc(limbs_or_pos_neg(xs, ys))\n            }\n        }\n    }\n\n    fn or_assign_neg_neg_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (_, Self(Small(y))) => self.or_assign_neg_limb_neg(y.wrapping_neg()),\n            (Self(Small(x)), _) => *self = other.or_neg_limb_neg(x.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_vec_or_neg_neg_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n\n    fn or_assign_neg_neg(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (_, Self(Small(y))) => self.or_assign_neg_limb_neg(y.wrapping_neg()),\n            (Self(Small(x)), _) => {\n                other.or_assign_neg_limb_neg(x.wrapping_neg());\n                *self = other;\n            }\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_or_neg_neg_in_place_either(xs, ys) {\n                    *self = other;\n                }\n                self.trim();\n            }\n        }\n    }\n\n    fn or_neg_neg(&self, other: &Self) -> Self {\n        match (self, other) {\n            (_, &Self(Small(y))) => self.or_neg_limb_neg(y.wrapping_neg()),\n            (&Self(Small(x)), _) => other.or_neg_limb_neg(x.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                Self::from_owned_limbs_asc(limbs_or_neg_neg(xs, ys))\n            }\n        }\n    }\n}\n\nimpl BitOr<Self> for Integer {\n    type Output = Self;\n\n    /// Takes the bitwise or of two [`Integer`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(-123) | Integer::from(-456), -67);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) | -(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -999999995905i64\n    /// );\n    /// ```\n    #[inline]\n    fn bitor(mut self, other: Self) -> Self {\n        self |= other;\n        self\n    }\n}\n\nimpl<'a> BitOr<&'a Self> for Integer {\n    type Output = Self;\n\n    /// Takes the bitwise or of two [`Integer`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(-123) | &Integer::from(-456), -67);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) | &-(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -999999995905i64\n    /// );\n    /// ```\n    #[inline]\n    fn bitor(mut self, other: &'a Self) -> Self {\n        self |= other;\n        self\n    }\n}\n\nimpl BitOr<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Takes the bitwise or of two [`Integer`]s, taking the first by reference and the second by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::from(-123) | Integer::from(-456), -67);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) | -(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -999999995905i64\n    /// );\n    /// ```\n    #[inline]\n    fn bitor(self, mut other: Integer) -> Integer {\n        other |= self;\n        other\n    }\n}\n\nimpl BitOr<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Takes the bitwise or of two [`Integer`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::from(-123) | &Integer::from(-456), -67);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) | &-(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     -999999995905i64\n    /// );\n    /// ```\n    fn bitor(self, other: &Integer) -> Integer {\n        match (self.sign, other.sign) {\n            (true, true) => Integer {\n                sign: true,\n                abs: &self.abs | &other.abs,\n            },\n            (true, false) => Integer {\n                sign: false,\n                abs: self.abs.or_pos_neg(&other.abs),\n            },\n            (false, true) => Integer {\n                sign: false,\n                abs: other.abs.or_pos_neg(&self.abs),\n            },\n            (false, false) => Integer {\n                sign: false,\n                abs: self.abs.or_neg_neg(&other.abs),\n            },\n        }\n    }\n}\n\nimpl BitOrAssign<Self> for Integer {\n    /// Bitwise-ors an [`Integer`] with another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x |= Integer::from(0x0000000f);\n    /// x |= Integer::from(0x00000f00);\n    /// x |= Integer::from(0x000f_0000);\n    /// x |= Integer::from(0x0f000000);\n    /// assert_eq!(x, 0x0f0f_0f0f);\n    /// ```\n    fn bitor_assign(&mut self, other: Self) {\n        match (self.sign, other.sign) {\n            (true, true) => self.abs.bitor_assign(other.abs),\n            (true, false) => {\n                self.sign = false;\n                self.abs.or_assign_pos_neg(other.abs);\n            }\n            (false, true) => self.abs.or_assign_neg_pos(other.abs),\n            (false, false) => self.abs.or_assign_neg_neg(other.abs),\n        }\n    }\n}\n\nimpl<'a> BitOrAssign<&'a Self> for Integer {\n    /// Bitwise-ors an [`Integer`] with another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::ZERO;\n    /// x |= &Integer::from(0x0000000f);\n    /// x |= &Integer::from(0x00000f00);\n    /// x |= &Integer::from(0x000f_0000);\n    /// x |= &Integer::from(0x0f000000);\n    /// assert_eq!(x, 0x0f0f_0f0f);\n    /// ```\n    fn bitor_assign(&mut self, other: &'a Self) {\n        match (self.sign, other.sign) {\n            (true, true) => self.abs.bitor_assign(&other.abs),\n            (true, false) => {\n                self.sign = false;\n                self.abs.or_assign_pos_neg_ref(&other.abs);\n            }\n            (false, true) => self.abs.or_assign_neg_pos_ref(&other.abs),\n            (false, false) => self.abs.or_assign_neg_neg_ref(&other.abs),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nimpl SignificantBits for &Integer {\n    /// Returns the number of significant bits of an [`Integer`]'s absolute value.\n    ///\n    /// $$\n    /// f(n) = \\\\begin{cases}\n    ///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n    ///     \\lfloor \\log_2 |n| \\rfloor + 1 & \\\\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::SignificantBits;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.significant_bits(), 0);\n    /// assert_eq!(Integer::from(100).significant_bits(), 7);\n    /// assert_eq!(Integer::from(-100).significant_bits(), 7);\n    /// ```\n    fn significant_bits(self) -> u64 {\n        self.abs.significant_bits()\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\n\nimpl Integer {\n    /// Returns the number of trailing zeros in the binary expansion of an [`Integer`]\n    /// (equivalently, the multiplicity of 2 in its prime factorization), or `None` is the\n    /// [`Integer`] is 0.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::ZERO.trailing_zeros(), None);\n    /// assert_eq!(Integer::from(3).trailing_zeros(), Some(0));\n    /// assert_eq!(Integer::from(-72).trailing_zeros(), Some(3));\n    /// assert_eq!(Integer::from(100).trailing_zeros(), Some(2));\n    /// assert_eq!((-Integer::from(10u32).pow(12)).trailing_zeros(), Some(12));\n    /// ```\n    pub fn trailing_zeros(&self) -> Option<u64> {\n        self.abs.trailing_zeros()\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2005, 2012, 2015-2018 Free Software\n//      Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb, limbs_add_limb_to_out, limbs_slice_add_limb_in_place,\n};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub, limbs_sub_greater_in_place_left, limbs_sub_greater_to_out, limbs_sub_limb,\n    limbs_sub_limb_in_place, limbs_sub_limb_to_out, limbs_vec_sub_in_place_right,\n};\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, max};\nuse core::ops::{BitXor, BitXorAssign};\nuse itertools::repeat_n;\nuse malachite_base::num::arithmetic::traits::WrappingNegAssign;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::slices::{slice_leading_zeros, slice_set_zero, slice_test_zero};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, returns the limbs of the bitwise xor of the `Integer` and a `Limb`. `xs` cannot be\n// empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_neg_xor_limb(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    if y == 0 {\n        return xs.to_vec();\n    }\n    let head = xs[0];\n    let tail = &xs[1..];\n    let mut out = Vec::with_capacity(xs.len());\n    if head != 0 {\n        let head = head.wrapping_neg() ^ y;\n        if head == 0 {\n            out.push(0);\n            out.extend_from_slice(&limbs_add_limb(tail, 1));\n        } else {\n            out.push(head.wrapping_neg());\n            out.extend_from_slice(tail);\n        }\n    } else {\n        out.push(y.wrapping_neg());\n        out.extend_from_slice(&limbs_sub_limb(tail, 1).0);\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, writes the limbs of the bitwise and of the `Integer`, writes the limbs of the bitwise\n// xor of the `Integer` and a `Limb` to an output slice. The output slice must be at least as long\n// as the input slice. `xs` cannot be empty or only contain zeros. Returns whether a carry occurs.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_neg_xor_limb_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) -> bool {\n    let len = xs.len();\n    assert!(out.len() >= len);\n    if y == 0 {\n        out[..len].copy_from_slice(xs);\n        return false;\n    }\n    let head = xs[0];\n    let tail = &xs[1..];\n    if head != 0 {\n        let head = head.wrapping_neg() ^ y;\n        if head == 0 {\n            out[0] = 0;\n            limbs_add_limb_to_out(&mut out[1..len], tail, 1)\n        } else {\n            out[0] = head.wrapping_neg();\n            out[1..len].copy_from_slice(tail);\n            false\n        }\n    } else {\n        out[0] = y.wrapping_neg();\n        limbs_sub_limb_to_out(&mut out[1..len], tail, 1);\n        false\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, writes the limbs of the bitwise xor of the `Integer` and a `Limb` to the input slice.\n// `xs` cannot be empty or only contain zeros. Returns whether a carry occurs.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_slice_neg_xor_limb_in_place(xs: &mut [Limb], y: Limb) -> bool {\n    if y == 0 {\n        return false;\n    }\n    let (head, tail) = xs.split_at_mut(1);\n    let head = &mut head[0];\n    if *head != 0 {\n        *head = head.wrapping_neg() ^ y;\n        if *head == 0 {\n            limbs_slice_add_limb_in_place(tail, 1)\n        } else {\n            head.wrapping_neg_assign();\n            false\n        }\n    } else {\n        *head = y.wrapping_neg();\n        limbs_sub_limb_in_place(tail, 1);\n        false\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, writes the limbs of the bitwise xor of the `Integer` and a `Limb` to the input slice.\n// `xs` cannot be empty or only contain zeros. If a carry occurs, extends the `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_vec_neg_xor_limb_in_place(xs: &mut Vec<Limb>, y: Limb) {\n    if limbs_slice_neg_xor_limb_in_place(xs, y) {\n        xs.push(1);\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of an `Integer`, returns the\n// limbs of the bitwise xor of the `Integer` and a negative number whose lowest limb is given by `y`\n// and whose other limbs are full of `true` bits. `xs` may not be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_pos_xor_limb_neg(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    let (head, tail) = xs.split_first().unwrap();\n    let lo = head ^ y;\n    let mut out;\n    if lo == 0 {\n        out = limbs_add_limb(tail, 1);\n        out.insert(0, 0);\n    } else {\n        out = xs.to_vec();\n        out[0] = lo.wrapping_neg();\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of an `Integer`, writes the\n// limbs of the bitwise xor of the `Integer` and a negative number whose lowest limb is given by `y`\n// and whose other limbs are full of `true` bits to an output slice. `xs` may not be empty or only\n// contain zeros. The output slice must be at least as long as the input slice. Returns whether\n// there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or if `out` is shorter than `xs`.\npub_test! {limbs_pos_xor_limb_neg_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) -> bool {\n    let (head, tail) = xs.split_first().unwrap();\n    let (out_head, out_tail) = out[..xs.len()].split_first_mut().unwrap();\n    let lo = head ^ y;\n    if lo == 0 {\n        *out_head = 0;\n        limbs_add_limb_to_out(out_tail, tail, 1)\n    } else {\n        *out_head = lo.wrapping_neg();\n        out_tail.copy_from_slice(tail);\n        false\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of an `Integer`, takes the\n// bitwise xor of the `Integer` and a negative number whose lowest limb is given by `y` and whose\n// other limbs are full of `true` bits, in place. `xs` may not be empty. Returns whether there is a\n// carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_slice_pos_xor_limb_neg_in_place(xs: &mut [Limb], y: Limb) -> bool {\n    let (head, tail) = xs.split_at_mut(1);\n    let head = &mut head[0];\n    *head ^= y;\n    if *head == 0 {\n        limbs_slice_add_limb_in_place(tail, 1)\n    } else {\n        *head = head.wrapping_neg();\n        false\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of an `Integer`, takes the\n// bitwise xor of the `Integer` and a negative number whose lowest limb is given by `y` and whose\n// other limbs are full of `true` bits, in place. `xs` may not be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_vec_pos_xor_limb_neg_in_place(xs: &mut Vec<Limb>, y: Limb) {\n    if limbs_slice_pos_xor_limb_neg_in_place(xs, y) {\n        xs.push(1);\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, returns the limbs of the bitwise xor of the `Integer` and a negative number whose\n// lowest limb is given by `y` and whose other limbs are full of `true` bits. `xs` may not be empty\n// or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or only contains zeros.\npub_test! {limbs_neg_xor_limb_neg(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    let mut out;\n    if xs[0] == 0 {\n        let carry;\n        (out, carry) = limbs_sub_limb(xs, 1);\n        assert!(!carry);\n        out[0] = y;\n    } else {\n        out = xs.to_vec();\n        out[0] = xs[0].wrapping_neg() ^ y;\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, writes the limbs of the bitwise xor of the `Integer` and a negative number whose\n// lowest limb is given by `y` and whose other limbs are full of `true` bits to an output slice.\n// `xs` may not be empty or only contain zeros. The output slice must be at least as long as the\n// input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or only contains zeros, or if `out` is shorter than `xs`.\npub_test! {limbs_neg_xor_limb_neg_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) {\n    let (head, tail) = xs.split_first().unwrap();\n    let (out_head, out_tail) = out[..xs.len()].split_first_mut().unwrap();\n    if *head == 0 {\n        *out_head = y;\n        assert!(!limbs_sub_limb_to_out(out_tail, tail, 1));\n    } else {\n        *out_head = xs[0].wrapping_neg() ^ y;\n        out_tail.copy_from_slice(tail);\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of the negative of an\n// `Integer`, takes the bitwise xor of the `Integer` and a negative number whose lowest limb is\n// given by `y` and whose other limbs are full of `true` bits, in place. `xs` may not be empty or\n// only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or only contains zeros.\npub_test! {limbs_neg_xor_limb_neg_in_place(xs: &mut [Limb], y: Limb) {\n    let (head, tail) = xs.split_first_mut().unwrap();\n    if *head == 0 {\n        assert!(!limbs_sub_limb_in_place(tail, 1));\n        *head = y;\n    } else {\n        head.wrapping_neg_assign();\n        *head ^= y;\n    }\n}}\n\nconst fn limbs_xor_pos_neg_helper(x: Limb, boundary_seen: &mut bool) -> Limb {\n    if *boundary_seen {\n        !x\n    } else if x == 0 {\n        0\n    } else {\n        *boundary_seen = true;\n        x.wrapping_neg()\n    }\n}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, returns the limbs of the bitwise xor of the `Integer`s. `xs` and `ys` may\n// not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where `res` is returned, the first\n// input is positive, and the second is negative.\npub_test! {limbs_xor_pos_neg(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        let mut out = vec![0; x_i];\n        out.push(xs[x_i].wrapping_neg());\n        out.extend(xs[x_i + 1..].iter().map(|x| !x));\n        out.extend(repeat_n(Limb::MAX, y_i - xs_len));\n        out.push(ys[y_i] - 1);\n        out.extend_from_slice(&ys[y_i + 1..]);\n        return out;\n    } else if x_i >= ys_len {\n        let mut out = ys.to_vec();\n        out.extend_from_slice(&xs[ys_len..]);\n        return out;\n    }\n    let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n    let mut out = vec![0; min_i];\n    let mut boundary_seen = false;\n    let x = match x_i.cmp(&y_i) {\n        Equal => {\n            limbs_xor_pos_neg_helper(xs[x_i] ^ ys[y_i].wrapping_neg(), &mut boundary_seen)\n        }\n        Less => {\n            boundary_seen = true;\n            out.push(xs[x_i].wrapping_neg());\n            out.extend(xs[x_i + 1..y_i].iter().map(|x| !x));\n            xs[y_i] ^ (ys[y_i] - 1)\n        }\n        Greater => {\n            boundary_seen = true;\n            out.extend_from_slice(&ys[y_i..x_i]);\n            xs[x_i] ^ ys[x_i]\n        }\n    };\n    out.push(x);\n    let xys = xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter());\n    if boundary_seen {\n        out.extend(xys.map(|(x, y)| x ^ y));\n    } else {\n        for (&x, &y) in xys {\n            out.push(limbs_xor_pos_neg_helper(x ^ !y, &mut boundary_seen));\n        }\n    }\n    if xs_len != ys_len {\n        let zs = if xs_len > ys_len {\n            &xs[ys_len..]\n        } else {\n            &ys[xs_len..]\n        };\n        if boundary_seen {\n            out.extend_from_slice(zs);\n        } else {\n            for &z in zs {\n                out.push(limbs_xor_pos_neg_helper(!z, &mut boundary_seen));\n            }\n        }\n    }\n    if slice_test_zero(&out) {\n        out.push(1);\n    }\n    out\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise xor of the `Integer`s to an output slice.\n// `xs` and `ys` may not be empty or only contain zeros. The output slice must be at least as long\n// as the longer of the two input slices. max(`xs.len()`, `ys.len()`) limbs will be written; if the\n// number of significant limbs of the result is lower, some of the written limbs will be zero.\n//\n// Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros, or if `out` is shorter than the longer of\n// `xs` and `ys`.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where the first input is positive\n// and the second is negative.\npub_test! {limbs_xor_pos_neg_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(out.len() >= xs_len);\n    assert!(out.len() >= ys_len);\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        slice_set_zero(&mut out[..x_i]);\n        out[x_i] = xs[x_i].wrapping_neg();\n        for (out, &x) in out[x_i + 1..xs_len].iter_mut().zip(xs[x_i + 1..].iter()) {\n            *out = !x;\n        }\n        for out in &mut out[xs_len..y_i] {\n            *out = Limb::MAX;\n        }\n        out[y_i] = ys[y_i] - 1;\n        out[y_i + 1..ys_len].copy_from_slice(&ys[y_i + 1..]);\n        return false;\n    } else if x_i >= ys_len {\n        out[..ys_len].copy_from_slice(ys);\n        out[ys_len..xs_len].copy_from_slice(&xs[ys_len..]);\n        return false;\n    }\n    let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n    slice_set_zero(&mut out[..min_i]);\n    let mut boundary_seen = false;\n    match x_i.cmp(&y_i) {\n        Equal => {\n            out[x_i] =\n                limbs_xor_pos_neg_helper(xs[x_i] ^ ys[y_i].wrapping_neg(), &mut boundary_seen);\n        }\n        Less => {\n            boundary_seen = true;\n            out[x_i] = xs[x_i].wrapping_neg();\n            for (out, &x) in out[x_i + 1..y_i].iter_mut().zip(xs[x_i + 1..y_i].iter()) {\n                *out = !x;\n            }\n            out[y_i] = xs[y_i] ^ (ys[y_i] - 1);\n        }\n        Greater => {\n            boundary_seen = true;\n            out[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n            out[x_i] = xs[x_i] ^ ys[x_i];\n        }\n    }\n    let xys = out[max_i + 1..]\n        .iter_mut()\n        .zip(xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter()));\n    if boundary_seen {\n        for (out, (&x, &y)) in xys {\n            *out = x ^ y;\n        }\n    } else {\n        for (out, (&x, &y)) in xys {\n            *out = limbs_xor_pos_neg_helper(x ^ !y, &mut boundary_seen);\n        }\n    }\n    let max_len = max(xs_len, ys_len);\n    if xs_len != ys_len {\n        let (min_len, zs) = if max_len == xs_len {\n            (ys_len, &xs[ys_len..])\n        } else {\n            (xs_len, &ys[xs_len..])\n        };\n        if boundary_seen {\n            out[min_len..max_len].copy_from_slice(zs);\n        } else {\n            for (out, &z) in out[min_len..].iter_mut().zip(zs.iter()) {\n                *out = limbs_xor_pos_neg_helper(!z, &mut boundary_seen);\n            }\n        }\n    }\n    slice_test_zero(&out[..max_len])\n}}\n\nfn limbs_xor_pos_neg_in_place_left_helper(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    x_i: usize,\n    y_i: usize,\n) -> bool {\n    let max_i = max(x_i, y_i);\n    let mut boundary_seen = false;\n    match x_i.cmp(&y_i) {\n        Equal => {\n            xs[x_i] =\n                limbs_xor_pos_neg_helper(xs[x_i] ^ ys[y_i].wrapping_neg(), &mut boundary_seen);\n        }\n        Less => {\n            boundary_seen = true;\n            xs[x_i].wrapping_neg_assign();\n            limbs_not_in_place(&mut xs[x_i + 1..y_i]);\n            xs[y_i] ^= ys[y_i] - 1;\n        }\n        Greater => {\n            boundary_seen = true;\n            xs[y_i..x_i].copy_from_slice(&ys[y_i..x_i]);\n            xs[x_i] ^= ys[x_i];\n        }\n    }\n    let xys = xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..].iter());\n    if boundary_seen {\n        for (x, &y) in xys {\n            *x ^= y;\n        }\n    } else {\n        for (x, &y) in xys {\n            *x = limbs_xor_pos_neg_helper(*x ^ !y, &mut boundary_seen);\n        }\n    }\n    boundary_seen\n}\n\n// Interpreting a `Vec` of `Limb`s and a slice of `Limb`s as the limbs (in ascending order) of one\n// `Integer` and the negative of another, writes the limbs of the bitwise xor of the `Integer`s to\n// the `Vec`. `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where `res == op1` and the first\n// input is positive and the second is negative.\npub_test! {limbs_xor_pos_neg_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        xs[x_i].wrapping_neg_assign();\n        limbs_not_in_place(&mut xs[x_i + 1..]);\n        xs.extend(repeat_n(Limb::MAX, y_i - xs_len));\n        xs.push(ys[y_i] - 1);\n        xs.extend_from_slice(&ys[y_i + 1..]);\n        return;\n    } else if x_i >= ys_len {\n        xs[..ys_len].copy_from_slice(ys);\n        return;\n    }\n    let mut boundary_seen = limbs_xor_pos_neg_in_place_left_helper(xs, ys, x_i, y_i);\n    match xs_len.cmp(&ys_len) {\n        Less => {\n            if boundary_seen {\n                xs.extend_from_slice(&ys[xs_len..]);\n            } else {\n                for &y in &ys[xs_len..] {\n                    xs.push(limbs_xor_pos_neg_helper(!y, &mut boundary_seen));\n                }\n            }\n        }\n        Greater => {\n            if !boundary_seen {\n                for x in &mut xs[ys_len..] {\n                    *x = limbs_xor_pos_neg_helper(!*x, &mut boundary_seen);\n                }\n            }\n        }\n        _ => {}\n    }\n    if slice_test_zero(xs) {\n        xs.push(1);\n    }\n}}\n\nfn limbs_xor_pos_neg_in_place_right_helper(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    x_i: usize,\n    y_i: usize,\n) -> bool {\n    let max_i = max(x_i, y_i);\n    let mut boundary_seen = false;\n    match x_i.cmp(&y_i) {\n        Equal => {\n            ys[y_i] =\n                limbs_xor_pos_neg_helper(xs[x_i] ^ ys[y_i].wrapping_neg(), &mut boundary_seen);\n        }\n        Less => {\n            boundary_seen = true;\n            ys[x_i] = xs[x_i].wrapping_neg();\n            for (y, &x) in ys[x_i + 1..].iter_mut().zip(xs[x_i + 1..y_i].iter()) {\n                *y = !x;\n            }\n            ys[y_i] -= 1;\n            ys[y_i] ^= xs[y_i];\n        }\n        Greater => {\n            boundary_seen = true;\n            ys[x_i] ^= xs[x_i];\n        }\n    }\n    let xys = xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter_mut());\n    if boundary_seen {\n        for (&x, y) in xys {\n            *y ^= x;\n        }\n    } else {\n        for (&x, y) in xys {\n            *y = limbs_xor_pos_neg_helper(x ^ !*y, &mut boundary_seen);\n        }\n    }\n    boundary_seen\n}\n\n// Interpreting a slice of `Limb`s and a `Vec` of `Limb`s as the limbs (in ascending order) of one\n// `Integer` and the negative of another, writes the limbs of the bitwise xor of the `Integer`s to\n// the second (right) slice. `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where `res == op2` and the first\n// input is positive and the second is negative.\npub_test! {limbs_xor_pos_neg_in_place_right(xs: &[Limb], ys: &mut Vec<Limb>) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        ys[x_i] = xs[x_i].wrapping_neg();\n        for (y, &x) in ys[x_i + 1..].iter_mut().zip(xs[x_i + 1..].iter()) {\n            *y = !x;\n        }\n        for y in ys.iter_mut().take(y_i).skip(xs_len) {\n            *y = Limb::MAX;\n        }\n        ys[y_i] -= 1;\n        return;\n    } else if x_i >= ys_len {\n        ys.extend_from_slice(&xs[ys_len..]);\n        return;\n    }\n    let mut boundary_seen = limbs_xor_pos_neg_in_place_right_helper(xs, ys, x_i, y_i);\n    if xs_len > ys_len {\n        if boundary_seen {\n            ys.extend_from_slice(&xs[ys_len..]);\n        } else {\n            for &x in &xs[ys_len..] {\n                ys.push(limbs_xor_pos_neg_helper(!x, &mut boundary_seen));\n            }\n        }\n    } else if xs_len < ys_len && !boundary_seen {\n        for y in &mut ys[xs_len..] {\n            *y = limbs_xor_pos_neg_helper(!*y, &mut boundary_seen);\n        }\n    }\n    if slice_test_zero(ys) {\n        ys.push(1);\n    }\n}}\n\n// Interpreting two `Vec`s of `Limb`s as the limbs (in ascending order) of one `Integer` and the\n// negative of another, writes the limbs of the bitwise xor of the `Integer`s to the longer `Vec`\n// (or the first one, if they are equally long). `xs` and `ys` may not be empty or only contain\n// zeros. Returns a `bool` which is `false` when the output is to the first `Vec` and `true` when\n// it's to the second `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where the first input is positive,\n// the second is negative, and the result is written to the longer input slice.\npub_test! {limbs_xor_pos_neg_in_place_either(xs: &mut Vec<Limb>, ys: &mut Vec<Limb>) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        ys[x_i] = xs[x_i].wrapping_neg();\n        for (y, &x) in ys[x_i + 1..].iter_mut().zip(xs[x_i + 1..].iter()) {\n            *y = !x;\n        }\n        for y in &mut ys[xs_len..y_i] {\n            *y = Limb::MAX;\n        }\n        ys[y_i] -= 1;\n        return true;\n    } else if x_i >= ys_len {\n        xs[..ys_len].copy_from_slice(ys);\n        return false;\n    }\n    if xs_len >= ys_len {\n        let mut boundary_seen = limbs_xor_pos_neg_in_place_left_helper(xs, ys, x_i, y_i);\n        if xs_len != ys_len && !boundary_seen {\n            for x in &mut xs[ys_len..] {\n                *x = limbs_xor_pos_neg_helper(!*x, &mut boundary_seen);\n            }\n        }\n        if slice_test_zero(xs) {\n            xs.push(1);\n        }\n        false\n    } else {\n        let mut boundary_seen = limbs_xor_pos_neg_in_place_right_helper(xs, ys, x_i, y_i);\n        if !boundary_seen {\n            for y in &mut ys[xs_len..] {\n                *y = limbs_xor_pos_neg_helper(!*y, &mut boundary_seen);\n            }\n        }\n        if slice_test_zero(ys) {\n            ys.push(1);\n        }\n        true\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, returns the limbs of the bitwise xor of the `Integer`s. `xs` and `ys` may not be\n// empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where `res` is returned and both\n// inputs are negative.\npub_test! {limbs_xor_neg_neg(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        let (result, borrow) = limbs_sub(ys, xs);\n        assert!(!borrow);\n        return result;\n    } else if x_i >= ys_len {\n        let (result, borrow) = limbs_sub(xs, ys);\n        assert!(!borrow);\n        return result;\n    }\n    let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n    let mut out = vec![0; min_i];\n    if x_i == y_i {\n        out.push(xs[x_i].wrapping_neg() ^ ys[x_i].wrapping_neg());\n    } else {\n        let (min_zs, max_zs) = if x_i <= y_i { (xs, ys) } else { (ys, xs) };\n        out.push(min_zs[min_i].wrapping_neg());\n        out.extend(min_zs[min_i + 1..max_i].iter().map(|z| !z));\n        out.push((max_zs[max_i] - 1) ^ min_zs[max_i]);\n    }\n    out.extend(\n        xs[max_i + 1..]\n            .iter()\n            .zip(ys[max_i + 1..].iter())\n            .map(|(x, y)| x ^ y),\n    );\n    match xs_len.cmp(&ys_len) {\n        Less => out.extend_from_slice(&ys[xs_len..]),\n        Greater => out.extend_from_slice(&xs[ys_len..]),\n        _ => {}\n    }\n    out\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the max(`xs.len()`, `ys.len()`) limbs of the bitwise xor of the `Integer`s to\n// an output slice. `xs` and `ys` may not be empty or only contain zeros. The output slice must be\n// at least as long as the longer input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros, or if `out` is shorter than the longer of\n// `xs` and `ys`.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where both inputs are negative.\npub_test! {limbs_xor_neg_neg_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(out.len() >= xs_len);\n    assert!(out.len() >= ys_len);\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        assert!(!limbs_sub_greater_to_out(out, ys, xs));\n        return;\n    } else if x_i >= ys_len {\n        assert!(!limbs_sub_greater_to_out(out, xs, ys));\n        return;\n    }\n    let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n    slice_set_zero(&mut out[..min_i]);\n    if x_i == y_i {\n        out[x_i] = xs[x_i].wrapping_neg() ^ ys[x_i].wrapping_neg();\n    } else {\n        let (min_zs, max_zs) = if x_i <= y_i { (xs, ys) } else { (ys, xs) };\n        out[min_i] = min_zs[min_i].wrapping_neg();\n        for (out, &z) in out[min_i + 1..max_i]\n            .iter_mut()\n            .zip(min_zs[min_i + 1..max_i].iter())\n        {\n            *out = !z;\n        }\n        out[max_i] = (max_zs[max_i] - 1) ^ min_zs[max_i];\n    }\n    for (out, (&x, &y)) in out[max_i + 1..]\n        .iter_mut()\n        .zip(xs[max_i + 1..].iter().zip(ys[max_i + 1..].iter()))\n    {\n        *out = x ^ y;\n    }\n    match xs_len.cmp(&ys_len) {\n        Less => out[xs_len..ys_len].copy_from_slice(&ys[xs_len..]),\n        Greater => out[ys_len..xs_len].copy_from_slice(&xs[ys_len..]),\n        _ => {}\n    }\n}}\n\nfn limbs_xor_neg_neg_in_place_helper(xs: &mut [Limb], ys: &[Limb], x_i: usize, y_i: usize) {\n    let (min_i, max_i) = if x_i <= y_i { (x_i, y_i) } else { (y_i, x_i) };\n    if x_i == y_i {\n        xs[x_i] = xs[x_i].wrapping_neg() ^ ys[x_i].wrapping_neg();\n    } else if x_i <= y_i {\n        xs[min_i].wrapping_neg_assign();\n        limbs_not_in_place(&mut xs[min_i + 1..max_i]);\n        xs[max_i] ^= ys[max_i] - 1;\n    } else {\n        xs[min_i] = ys[min_i].wrapping_neg();\n        for (x, &y) in xs[min_i + 1..max_i].iter_mut().zip(ys[min_i + 1..].iter()) {\n            *x = !y;\n        }\n        xs[max_i] -= 1;\n        xs[max_i] ^= ys[max_i];\n    }\n    for (x, &y) in xs[max_i + 1..].iter_mut().zip(ys[max_i + 1..].iter()) {\n        *x ^= y;\n    }\n}\n\n// Interpreting a `Vec` of `Limb`s and a slice of `Limb`s as the limbs (in ascending order) of the\n// negatives of two `Integer`s, writes the limbs of the bitwise xor of the `Integer`s to the `Vec`.\n// `xs` and `ys` may not be empty or only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where `res == op1` and both inputs\n// are negative.\npub_test! {limbs_xor_neg_neg_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        assert!(!limbs_vec_sub_in_place_right(ys, xs));\n    } else if x_i >= ys_len {\n        assert!(!limbs_sub_greater_in_place_left(xs, ys));\n    } else {\n        limbs_xor_neg_neg_in_place_helper(xs, ys, x_i, y_i);\n        if xs_len < ys_len {\n            xs.extend_from_slice(&ys[xs_len..]);\n        }\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of the negatives of two\n// `Integer`s, writes the limbs of the bitwise xor of the `Integer`s to the longer slice (or the\n// first one, if they are equally long). `xs` and `ys` may not be empty or only contain zeros.\n// Returns `false` when the output is to the first slice and `true` when it's to the second slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` or `ys` are empty or contain only zeros.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where both inputs are negative and\n// the result is written to the longer input slice.\npub_test! {limbs_xor_neg_neg_in_place_either(xs: &mut [Limb], ys: &mut [Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let x_i = slice_leading_zeros(xs);\n    let y_i = slice_leading_zeros(ys);\n    assert!(x_i < xs_len);\n    assert!(y_i < ys_len);\n    if y_i >= xs_len {\n        assert!(!limbs_sub_greater_in_place_left(ys, xs));\n        true\n    } else if x_i >= ys_len {\n        assert!(!limbs_sub_greater_in_place_left(xs, ys));\n        false\n    } else if xs_len >= ys_len {\n        limbs_xor_neg_neg_in_place_helper(xs, ys, x_i, y_i);\n        false\n    } else {\n        limbs_xor_neg_neg_in_place_helper(ys, xs, y_i, x_i);\n        true\n    }\n}}\n\nimpl Natural {\n    fn xor_assign_neg_limb_pos(&mut self, other: Limb) {\n        match self {\n            &mut Self::ZERO => {}\n            Self(Small(small)) => {\n                let result = small.wrapping_neg() ^ other;\n                if result == 0 {\n                    *self = Self(Large(vec![0, 1]));\n                } else {\n                    *small = result.wrapping_neg();\n                }\n            }\n            Self(Large(limbs)) => {\n                limbs_vec_neg_xor_limb_in_place(limbs, other);\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_neg_limb_pos(&self, other: Limb) -> Self {\n        match self {\n            &Self::ZERO => self.clone(),\n            Self(Small(small)) => {\n                let result = small.wrapping_neg() ^ other;\n                Self(if result == 0 {\n                    Large(vec![0, 1])\n                } else {\n                    Small(result.wrapping_neg())\n                })\n            }\n            Self(Large(limbs)) => Self::from_owned_limbs_asc(limbs_neg_xor_limb(limbs, other)),\n        }\n    }\n\n    fn xor_assign_pos_limb_neg(&mut self, other: Limb) {\n        match self {\n            Self(Small(small)) => {\n                let result = *small ^ other;\n                if result == 0 {\n                    *self = Self(Large(vec![0, 1]));\n                } else {\n                    *small = result.wrapping_neg();\n                }\n            }\n            Self(Large(limbs)) => {\n                limbs_vec_pos_xor_limb_neg_in_place(limbs, other);\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_pos_limb_neg(&self, other: Limb) -> Self {\n        Self(match self {\n            Self(Small(small)) => {\n                let result = small ^ other;\n                if result == 0 {\n                    Large(vec![0, 1])\n                } else {\n                    Small(result.wrapping_neg())\n                }\n            }\n            Self(Large(limbs)) => Large(limbs_pos_xor_limb_neg(limbs, other)),\n        })\n    }\n\n    fn xor_assign_neg_limb_neg(&mut self, other: Limb) {\n        match &mut *self {\n            Self(Small(small)) => *small = small.wrapping_neg() ^ other,\n            Self(Large(limbs)) => {\n                limbs_neg_xor_limb_neg_in_place(limbs, other);\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_neg_limb_neg(&self, other: Limb) -> Self {\n        match self {\n            Self(Small(small)) => Self(Small(small.wrapping_neg() ^ other)),\n            Self(Large(limbs)) => Self::from_owned_limbs_asc(limbs_neg_xor_limb_neg(limbs, other)),\n        }\n    }\n\n    fn xor_assign_pos_neg(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (Self(Small(x)), _) => {\n                other.xor_assign_neg_limb_pos(*x);\n                *self = other;\n            }\n            (_, Self(Small(y))) => self.xor_assign_pos_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_xor_pos_neg_in_place_either(xs, ys) {\n                    *self = other;\n                }\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_assign_pos_neg_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (Self(Small(x)), _) => *self = other.xor_neg_limb_pos(*x),\n            (_, Self(Small(y))) => self.xor_assign_pos_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_xor_pos_neg_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_assign_neg_pos(&mut self, mut other: Self) {\n        other.xor_assign_pos_neg_ref(&*self);\n        *self = other;\n    }\n\n    fn xor_assign_neg_pos_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (Self(Small(x)), _) => *self = other.xor_pos_limb_neg(x.wrapping_neg()),\n            (_, Self(Small(y))) => self.xor_assign_neg_limb_pos(*y),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_xor_pos_neg_in_place_right(ys, xs);\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_pos_neg(&self, other: &Self) -> Self {\n        match (self, other) {\n            (&Self(Small(x)), _) => other.xor_neg_limb_pos(x),\n            (_, &Self(Small(y))) => self.xor_pos_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                Self::from_owned_limbs_asc(limbs_xor_pos_neg(xs, ys))\n            }\n        }\n    }\n\n    fn xor_assign_neg_neg(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (Self(Small(x)), _) => *self = other.xor_neg_limb_neg(x.wrapping_neg()),\n            (_, Self(Small(y))) => self.xor_assign_neg_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_xor_neg_neg_in_place_either(xs, ys) {\n                    *self = other;\n                }\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_assign_neg_neg_ref(&mut self, other: &Self) {\n        match (&mut *self, other) {\n            (Self(Small(x)), _) => *self = other.xor_neg_limb_neg(x.wrapping_neg()),\n            (_, Self(Small(y))) => self.xor_assign_neg_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_xor_neg_neg_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n\n    fn xor_neg_neg(&self, other: &Self) -> Self {\n        match (self, other) {\n            (&Self(Small(x)), _) => other.xor_neg_limb_neg(x.wrapping_neg()),\n            (_, &Self(Small(y))) => self.xor_neg_limb_neg(y.wrapping_neg()),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                Self::from_owned_limbs_asc(limbs_xor_neg_neg(xs, ys))\n            }\n        }\n    }\n}\n\nimpl BitXor<Self> for Integer {\n    type Output = Self;\n\n    /// Takes the bitwise xor of two [`Integer`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(-123) ^ Integer::from(-456), 445);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) ^ -(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     8191\n    /// );\n    /// ```\n    #[inline]\n    fn bitxor(mut self, other: Self) -> Self {\n        self ^= other;\n        self\n    }\n}\n\nimpl BitXor<&Self> for Integer {\n    type Output = Self;\n\n    /// Takes the bitwise xor of two [`Integer`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(Integer::from(-123) ^ &Integer::from(-456), 445);\n    /// assert_eq!(\n    ///     -Integer::from(10u32).pow(12) ^ &-(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     8191\n    /// );\n    /// ```\n    #[inline]\n    fn bitxor(mut self, other: &Self) -> Self {\n        self ^= other;\n        self\n    }\n}\n\nimpl BitXor<Integer> for &Integer {\n    type Output = Integer;\n\n    /// Takes the bitwise xor of two [`Integer`]s, taking the first by reference and the second by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::from(-123) ^ Integer::from(-456), 445);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) ^ -(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     8191\n    /// );\n    /// ```\n    #[inline]\n    fn bitxor(self, mut other: Integer) -> Integer {\n        other ^= self;\n        other\n    }\n}\n\nimpl BitXor<&Integer> for &Integer {\n    type Output = Integer;\n\n    /// Takes the bitwise xor of two [`Integer`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// assert_eq!(&Integer::from(-123) ^ &Integer::from(-456), 445);\n    /// assert_eq!(\n    ///     &-Integer::from(10u32).pow(12) ^ &-(Integer::from(10u32).pow(12) + Integer::ONE),\n    ///     8191\n    /// );\n    /// ```\n    fn bitxor(self, other: &Integer) -> Integer {\n        match (self.sign, other.sign) {\n            (true, true) => Integer {\n                sign: true,\n                abs: &self.abs ^ &other.abs,\n            },\n            (true, false) => Integer {\n                sign: false,\n                abs: self.abs.xor_pos_neg(&other.abs),\n            },\n            (false, true) => Integer {\n                sign: false,\n                abs: other.abs.xor_pos_neg(&self.abs),\n            },\n            (false, false) => Integer {\n                sign: true,\n                abs: self.abs.xor_neg_neg(&other.abs),\n            },\n        }\n    }\n}\n\nimpl BitXorAssign<Self> for Integer {\n    /// Bitwise-xors an [`Integer`] with another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(u32::MAX);\n    /// x ^= Integer::from(0x0000000f);\n    /// x ^= Integer::from(0x00000f00);\n    /// x ^= Integer::from(0x000f_0000);\n    /// x ^= Integer::from(0x0f000000);\n    /// assert_eq!(x, 0xf0f0_f0f0u32);\n    /// ```\n    fn bitxor_assign(&mut self, other: Self) {\n        match (self.sign, other.sign) {\n            (true, true) => self.abs.bitxor_assign(other.abs),\n            (true, false) => {\n                self.sign = false;\n                self.abs.xor_assign_pos_neg(other.abs);\n            }\n            (false, true) => self.abs.xor_assign_neg_pos(other.abs),\n            (false, false) => {\n                self.sign = true;\n                self.abs.xor_assign_neg_neg(other.abs);\n            }\n        }\n    }\n}\n\nimpl BitXorAssign<&Self> for Integer {\n    /// Bitwise-xors an [`Integer`] with another [`Integer`] in place, taking the [`Integer`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(m) = O(m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`, and $m$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    ///\n    /// let mut x = Integer::from(u32::MAX);\n    /// x ^= &Integer::from(0x0000000f);\n    /// x ^= &Integer::from(0x00000f00);\n    /// x ^= &Integer::from(0x000f_0000);\n    /// x ^= &Integer::from(0x0f000000);\n    /// assert_eq!(x, 0xf0f0_f0f0u32);\n    /// ```\n    fn bitxor_assign(&mut self, other: &Self) {\n        match (self.sign, other.sign) {\n            (true, true) => self.abs.bitxor_assign(&other.abs),\n            (true, false) => {\n                self.sign = false;\n                self.abs.xor_assign_pos_neg_ref(&other.abs);\n            }\n            (false, true) => self.abs.xor_assign_neg_pos_ref(&other.abs),\n            (false, false) => {\n                self.sign = true;\n                self.abs.xor_assign_neg_neg_ref(&other.abs);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/integer/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse alloc::string::String;\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Two, Zero};\n\n/// An integer.\n///\n/// Any `Integer` whose absolute value is small enough to fit into a [`Limb`](crate#limbs) is\n/// represented inline. Only integers outside this range incur the costs of heap-allocation.\n#[derive(Clone, Hash, Eq, PartialEq)]\n#[cfg_attr(feature = \"serde\", derive(Deserialize, Serialize))]\n#[cfg_attr(\n    feature = \"serde\",\n    serde(try_from = \"SerdeInteger\", into = \"SerdeInteger\")\n)]\npub struct Integer {\n    // whether the `Integer` is non-negative\n    pub(crate) sign: bool,\n    pub(crate) abs: Natural,\n}\n\n#[cfg_attr(feature = \"serde\", derive(Serialize, Deserialize))]\n#[cfg_attr(feature = \"serde\", serde(transparent))]\npub(crate) struct SerdeInteger(String);\n\nimpl Integer {\n    // Returns true iff `self` is valid.\n    //\n    // To be valid, its absolute value must be valid, and if the absolute value is zero, the sign\n    // must be `true`. All `Integer`s must be valid.\n    #[cfg(feature = \"test_build\")]\n    pub fn is_valid(&self) -> bool {\n        self.abs.is_valid() && (self.sign || self.abs != 0)\n    }\n}\n\nmacro_rules! integer_zero {\n    () => {\n        Integer {\n            sign: true,\n            abs: Natural::ZERO,\n        }\n    };\n}\n\nmacro_rules! integer_one {\n    () => {\n        Integer {\n            sign: true,\n            abs: Natural::ONE,\n        }\n    };\n}\n\nmacro_rules! integer_two {\n    () => {\n        Integer {\n            sign: true,\n            abs: Natural::TWO,\n        }\n    };\n}\n\nmacro_rules! integer_negative_one {\n    () => {\n        Integer {\n            sign: false,\n            abs: Natural::ONE,\n        }\n    };\n}\n\n/// The constant 0.\nimpl Zero for Integer {\n    const ZERO: Self = integer_zero!();\n}\n\n/// The constant 1.\nimpl One for Integer {\n    const ONE: Self = integer_one!();\n}\n\n/// The constant 2.\nimpl Two for Integer {\n    const TWO: Self = integer_two!();\n}\n\n/// The constant -1.\nimpl NegativeOne for Integer {\n    const NEGATIVE_ONE: Self = integer_negative_one!();\n}\n\nimpl Default for Integer {\n    /// The default value of an [`Integer`], 0.\n    fn default() -> Self {\n        Self::ZERO\n    }\n}\n\n// Implements `Named` for `Integer`.\nimpl_named!(Integer);\n\n/// Traits for arithmetic.\npub mod arithmetic;\n/// Traits for comparing [`Integer`]s for equality or order.\npub mod comparison;\n/// Traits for converting to and from [`Integer`]s, converting to and from strings, and extracting\n/// digits.\npub mod conversion;\n/// Iterators that generate [`Integer`]s without repetition.\npub mod exhaustive;\n/// Traits for logic and bit manipulation.\npub mod logic;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`Integer`]s randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-nz/src/integer/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::natural::random::{\n    RandomNaturalsLessThan, StripedRandomNaturalInclusiveRange, get_random_natural_less_than,\n    get_random_natural_with_bits, get_striped_random_natural_from_inclusive_range,\n    get_striped_random_natural_with_bits, random_naturals_less_than,\n    striped_random_natural_inclusive_range,\n};\nuse malachite_base::bools::random::{RandomBools, random_bools};\nuse malachite_base::num::arithmetic::traits::{PowerOf2, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomNegativeSigneds, GeometricRandomNonzeroSigneds,\n    GeometricRandomSignedRange, GeometricRandomSigneds, geometric_random_natural_signeds,\n    geometric_random_negative_signeds, geometric_random_nonzero_signeds,\n    geometric_random_positive_signeds, geometric_random_signed_inclusive_range,\n    geometric_random_signeds, get_geometric_random_signed_from_inclusive_range,\n};\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::num::random::{\n    RandomPrimitiveInts, VariableRangeGenerator, random_primitive_ints,\n};\nuse malachite_base::random::Seed;\n\n/// Generates random [`Integer`]s, given an iterator of random signed bit lengths.\n///\n/// The [`Integer`]'s signs are taken from the signs of the bit lengths.\n#[derive(Clone, Debug)]\npub struct RandomIntegers<I: Iterator<Item = i64>> {\n    bits: I,\n    limbs: RandomPrimitiveInts<u64>,\n}\n\nimpl<I: Iterator<Item = i64>> Iterator for RandomIntegers<I> {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        let bits = self.bits.next().unwrap();\n        Some(Integer::from_sign_and_abs(\n            bits >= 0,\n            get_random_natural_with_bits(&mut self.limbs, bits.unsigned_abs()),\n        ))\n    }\n}\n\n/// Generates random natural (non-negative) [`Integer`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 0. Then an [`Integer`]\n/// is chosen uniformly among all non-negative [`Integer`]s with that bit length. The resulting\n/// distribution resembles a Pareto distribution. It has no mean or higher-order statistics (unless\n/// $m < 1$, which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     0 & \\text{if} \\\\quad n < 0, \\\\\\\\\n///     \\\\frac{1}{m + 1} & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     \\\\frac{2}{m+1} \\\\left ( \\\\frac{m}{2(m+1)} \\\\right ) ^ {\\\\lfloor \\\\log_2 n \\\\rfloor + 1} &\n///     \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, or, if after being reduced\n/// to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_natural_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(random_natural_integers(EXAMPLE_SEED, 32, 1), 10),\n///     \"[20431208470830262, 2777240, 114, 12184833305054, 1121025855008623490210, \\\n///     13478874522577592, 115311695, 7, 18, 54522366353, ...]\"\n/// )\n/// ```\npub fn random_natural_integers(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegers<GeometricRandomNaturalValues<i64>> {\n    RandomIntegers {\n        bits: geometric_random_natural_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n    }\n}\n\n/// Generates random positive [`Integer`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. Then an [`Integer`]\n/// is chosen uniformly among all positive [`Integer`]s with that bit length. The resulting\n/// distribution resembles a Pareto distribution. It has no mean or higher-order statistics (unless\n/// $m < 2$, which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     0 & \\text{if} \\\\quad n \\leq 0, \\\\\\\\\n///     \\frac{1}{m} \\left ( \\frac{m-1}{2m} \\right ) ^ {\\lfloor \\log_2 n \\rfloor} &\n///         \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_positive_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(random_positive_integers(EXAMPLE_SEED, 32, 1), 10),\n///     \"[22, 4, 178, 55845661150, 93254818, 7577967529619388, 8, 11316951483471, 11, \\\n///     1005760138411689342464923704482, ...]\"\n/// )\n/// ```\npub fn random_positive_integers(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegers<GeometricRandomNaturalValues<i64>> {\n    RandomIntegers {\n        bits: geometric_random_positive_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n    }\n}\n\n/// Generates random negative [`Integer`]s whose absolute values have a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. Then an [`Integer`]\n/// is chosen uniformly among all positive [`Integer`]s with that bit length, and negated. The\n/// resulting distribution resembles a negated Pareto distribution. It has no mean or higher-order\n/// statistics (unless $m < 2$, which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     0 & \\text{if} \\\\quad n \\geq 0 ,\\\\\\\\\n///     \\frac{1}{m} \\left ( \\frac{m-1}{2m} \\right ) ^ {\\lfloor \\log_2 (-n) \\rfloor}\n///     & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_negative_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(random_negative_integers(EXAMPLE_SEED, 32, 1), 10),\n///     \"[-22, -4, -178, -55845661150, -93254818, -7577967529619388, -8, -11316951483471, -11, \\\n///     -1005760138411689342464923704482, ...]\"\n/// )\n/// ```\npub fn random_negative_integers(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegers<GeometricRandomNegativeSigneds<i64>> {\n    RandomIntegers {\n        bits: geometric_random_negative_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n    }\n}\n\n/// Generates random nonzero [`Integer`]s whose absolute values have a specified mean bit length.\n///\n/// The actual signed bit length is chosen from a distribution that produces values whose mean\n/// absolute values are $m$, where $m$ is `mean_bits_numerator / mean_bits_denominator` (see\n/// [`geometric_random_nonzero_signeds`]); $m$ must be greater than 1. Then an [`Integer`] is chosen\n/// uniformly among all positive [`Integer`]s with that bit length, and its sign is set to the sign\n/// of the signed bit length. The resulting distribution has no mean or higher-order statistics\n/// (unless $m < 2$, which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     \\\\frac{1}{2m} \\\\left ( \\\\frac{m-1}{2m} \\\\right ) ^ {\\\\lfloor \\\\log_2 |n| \\\\rfloor}\n///     & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_nonzero_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(random_nonzero_integers(EXAMPLE_SEED, 32, 1), 10),\n///     \"[6, 373973144, 46887963477285686350042496363292819122, -93254818, -126908, \\\n///     -4471675267836600, 1860142159, -118004986915853475, -98, 346513, ...]\"\n/// )\n/// ```\npub fn random_nonzero_integers(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegers<GeometricRandomNonzeroSigneds<i64>> {\n    RandomIntegers {\n        bits: geometric_random_nonzero_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n    }\n}\n\n/// Generates random [`Integer`]s whose absolute values have a specified mean bit length.\n///\n/// The actual signed bit length is chosen from a distribution that produces values whose mean\n/// absolute values are $m$, where $m$ is `mean_bits_numerator / mean_bits_denominator` (see\n/// [`geometric_random_signeds`]); $m$ must be greater than 0. Then an [`Integer`] is chosen\n/// uniformly among all [`Integer`]s with that bit length, and its sign is set to the sign of the\n/// signed bit length. The resulting distribution has no mean or higher-order statistics (unless $m\n/// < 1$, which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\\\frac{1}{2m+1} & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     \\\\frac{2}{2m+1} \\\\left ( \\\\frac{m}{2(m+1)} \\\\right ) ^ {\\\\lfloor \\\\log_2 |n| \\\\rfloor + 1}\n///     & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, or, if after being reduced\n/// to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(random_integers(EXAMPLE_SEED, 32, 1), 10),\n///     \"[89270, 69403499476962893258904, 62, -1848070042786, -64671510460, -696, 0, -79, 70819, \\\n///     7330, ...]\"\n/// )\n/// ```\npub fn random_integers(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegers<GeometricRandomSigneds<i64>> {\n    RandomIntegers {\n        bits: geometric_random_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n    }\n}\n\n/// Generates striped random [`Integer`]s, given an iterator of random signed bit lengths.\n///\n/// The [`Integer`]s signs are taken from the signs of the bit lengths.\n#[derive(Clone, Debug)]\npub struct StripedRandomIntegers<I: Iterator<Item = i64>> {\n    bits: I,\n    bit_source: StripedBitSource,\n}\n\nimpl<I: Iterator<Item = i64>> Iterator for StripedRandomIntegers<I> {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        let bits = self.bits.next().unwrap();\n        Some(Integer::from_sign_and_abs(\n            bits >= 0,\n            get_striped_random_natural_with_bits(&mut self.bit_source, bits.unsigned_abs()),\n        ))\n    }\n}\n\n/// Generates striped random natural (non-negative) [`Integer`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 0. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Integer`] is generated from the sequence.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or, if\n/// after being reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::striped_random_natural_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_natural_integers(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[18014656207519744, 2228160, 64, 17592184995840, 1179440951012584587264, \\\n///     9007749010526207, 67108864, 5, 24, 34359738879, ...]\"\n/// )\n/// ```\npub fn striped_random_natural_integers(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomIntegers<GeometricRandomNaturalValues<i64>> {\n    StripedRandomIntegers {\n        bits: geometric_random_natural_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates striped random positive [`Integer`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Integer`] is generated from the sequence.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::striped_random_positive_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_positive_integers(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[16, 4, 128, 34391195648, 75493376, 9007199120523391, 8, 8796094070783, 8, \\\n///     950737950171027935941967741439, ...]\"\n/// )\n/// ```\npub fn striped_random_positive_integers(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomIntegers<GeometricRandomNaturalValues<i64>> {\n    StripedRandomIntegers {\n        bits: geometric_random_positive_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates striped random negative [`Integer`]s whose absolute values have a specified mean bit\n/// length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Integer`] is generated from the sequence and negated.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::striped_random_negative_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_negative_integers(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[-16, -4, -128, -34391195648, -75493376, -9007199120523391, -8, -8796094070783, -8, \\\n///     -950737950171027935941967741439, ...]\"\n/// )\n/// ```\npub fn striped_random_negative_integers(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomIntegers<GeometricRandomNegativeSigneds<i64>> {\n    StripedRandomIntegers {\n        bits: geometric_random_negative_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates striped random nonzero [`Integer`]s whose absolute values have a specified mean bit\n/// length.\n///\n/// The actual signed bit length is chosen from a distribution that produces values whose mean\n/// absolute values are $m$, where $m$ is `mean_bits_numerator / mean_bits_denominator` (see\n/// [`geometric_random_nonzero_signeds`]); $m$ must be greater than 1. A striped bit sequence with\n/// the given stripe parameter is generated and truncated at the bit length. The highest bit is\n/// forced to be 1, an [`Integer`] is generated from the sequence, and its sign is set to the sign\n/// of the signed bit length. The resulting distribution has no mean or higher-order statistics\n/// (unless $m < 2$, which is not typical).\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::striped_random_nonzero_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_nonzero_integers(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[4, 268435456, 84405977732342160290572740160760316144, -133169152, -131064, \\\n///     -2251834173421823, 1577058304, -126100789566374399, -76, 270335, ...]\"\n/// )\n/// ```\npub fn striped_random_nonzero_integers(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomIntegers<GeometricRandomNonzeroSigneds<i64>> {\n    StripedRandomIntegers {\n        bits: geometric_random_nonzero_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates striped random [`Integer`]s whose absolute values have a specified mean bit length.\n///\n/// The actual signed bit length is chosen from a distribution that produces values whose mean\n/// absolute values are $m$, where $m$ is `mean_bits_numerator / mean_bits_denominator` (see\n/// [`geometric_random_signeds`]); $m$ must be greater than 0. A striped bit sequence with the given\n/// stripe parameter is generated and truncated at the bit length. The highest bit is forced to be\n/// 1, an [`Integer`] is generated from the sequence, and its sign is set to the sign of the signed\n/// bit length. The resulting distribution has no mean or higher-order statistics (unless $m < 1$,\n/// which is not typical).\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or, if\n/// after being reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::striped_random_integers;\n///\n/// assert_eq!(\n///     prefix_to_string(striped_random_integers(EXAMPLE_SEED, 16, 1, 32, 1), 10),\n///     \"[65536, 75521006248971741167616, 32, -2199023255520, -68719468544, -527, 0, -112, \\\n///     131071, 4152, ...]\"\n/// )\n/// ```\npub fn striped_random_integers(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomIntegers<GeometricRandomSigneds<i64>> {\n    StripedRandomIntegers {\n        bits: geometric_random_signeds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Uniformly generates random [`Integer`]s in an interval.\n#[derive(Clone, Debug)]\npub struct UniformRandomIntegerRange {\n    xs: RandomNaturalsLessThan,\n    a: Integer,\n}\n\nimpl Iterator for UniformRandomIntegerRange {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        self.xs.next().map(|x| &self.a + Integer::from(x))\n    }\n}\n\n/// Uniformly generates random [`Integer`]s in the half-open interval $[a, b)$.\n///\n/// $a$ must be less than $b$.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a} & \\text{if} \\\\quad a \\leq x < b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::uniform_random_integer_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         uniform_random_integer_range(EXAMPLE_SEED, Integer::from(-10), Integer::from(100)),\n///         10\n///     ),\n///     \"[77, 83, -3, 95, 94, 97, 74, 17, 36, 83, ...]\"\n/// )\n/// ```\npub fn uniform_random_integer_range(\n    seed: Seed,\n    a: Integer,\n    b: Integer,\n) -> UniformRandomIntegerRange {\n    assert!(a < b);\n    UniformRandomIntegerRange {\n        xs: random_naturals_less_than(seed, Natural::exact_from(b - &a)),\n        a,\n    }\n}\n\n/// Uniformly generates random [`Integer`]s in the closed interval $[a, b]$.\n///\n/// $a$ must be less than or equal to $b$.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a+1} & \\text{if} \\\\quad a \\leq x \\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::uniform_random_integer_inclusive_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         uniform_random_integer_inclusive_range(\n///             EXAMPLE_SEED,\n///             Integer::from(-10),\n///             Integer::from(100)\n///         ),\n///         10\n///     ),\n///     \"[77, 83, -3, 95, 94, 97, 74, 17, 36, 83, ...]\"\n/// )\n/// ```\n#[inline]\npub fn uniform_random_integer_inclusive_range(\n    seed: Seed,\n    a: Integer,\n    b: Integer,\n) -> UniformRandomIntegerRange {\n    assert!(a <= b);\n    uniform_random_integer_range(seed, a, b + Integer::ONE)\n}\n\n/// Generates a random [`Integer`] in the half-open interval $[a, b)$.\n///\n/// The [`Integer`] is chosen uniformly from the interval.\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     1/(b-a) & \\text{if} a\\leq n<b, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $\\ell$ is `limit`.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(m) = O(m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_bits_numerator +\n/// mean_bits_denominator`, and $m$ is `max(a.significant_bits(), b.significant_bits())`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_uniform_random_integer_from_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_uniform_random_integer_from_range(\n///         &mut random_primitive_ints(EXAMPLE_SEED),\n///         Integer::from(500u32),\n///         Integer::from(1000u32)\n///     ),\n///     869\n/// );\n/// ```\npub fn get_uniform_random_integer_from_range(\n    limbs: &mut RandomPrimitiveInts<u64>,\n    a: Integer,\n    b: Integer,\n) -> Integer {\n    assert!(a < b);\n    Integer::from(get_random_natural_less_than(\n        limbs,\n        &Natural::exact_from(b - &a),\n    )) + a\n}\n\n/// Generates a random [`Integer`] in the closed interval $[a, b]$.\n///\n/// The [`Integer`] is chosen uniformly from the interval.\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     1/(b-a+1) & \\text{if} a\\leq n\\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $\\ell$ is `limit`.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(m) = O(m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_bits_numerator +\n/// mean_bits_denominator`, and $m$ is `max(a.significant_bits(), b.significant_bits())`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_uniform_random_integer_from_inclusive_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_uniform_random_integer_from_inclusive_range(\n///         &mut random_primitive_ints(EXAMPLE_SEED),\n///         Integer::from(500u32),\n///         Integer::from(1001u32)\n///     ),\n///     869\n/// );\n/// ```\npub fn get_uniform_random_integer_from_inclusive_range(\n    limbs: &mut RandomPrimitiveInts<u64>,\n    a: Integer,\n    b: Integer,\n) -> Integer {\n    assert!(a <= b);\n    get_uniform_random_integer_from_range(limbs, a, b + Integer::ONE)\n}\n\nfn signed_significant_bits(a: &Integer) -> (u64, i64) {\n    let unsigned_bits = a.significant_bits();\n    let bits = if *a >= 0 {\n        i64::exact_from(unsigned_bits)\n    } else {\n        -i64::exact_from(unsigned_bits)\n    };\n    (unsigned_bits, bits)\n}\n\nfn signed_min_bit_range(\n    seed: Seed,\n    a: Integer,\n    unsigned_min_bits: u64,\n) -> UniformRandomIntegerRange {\n    if a >= 0 {\n        uniform_random_integer_range(seed, a, Integer::power_of_2(unsigned_min_bits))\n    } else {\n        uniform_random_integer_inclusive_range(seed, a, -Integer::power_of_2(unsigned_min_bits - 1))\n    }\n}\n\nfn signed_max_bit_range(\n    seed: Seed,\n    a: Integer,\n    unsigned_max_bits: u64,\n) -> UniformRandomIntegerRange {\n    if a > 0 {\n        uniform_random_integer_inclusive_range(seed, Integer::power_of_2(unsigned_max_bits - 1), a)\n    } else {\n        // also handles a == 0\n        uniform_random_integer_inclusive_range(\n            seed,\n            -Integer::power_of_2(unsigned_max_bits) + Integer::ONE,\n            a,\n        )\n    }\n}\n\nfn get_random_integer_from_signed_min_bit_range(\n    limbs: &mut RandomPrimitiveInts<u64>,\n    a: Integer,\n    unsigned_min_bits: u64,\n) -> Integer {\n    if a >= 0 {\n        get_uniform_random_integer_from_range(limbs, a, Integer::power_of_2(unsigned_min_bits))\n    } else {\n        get_uniform_random_integer_from_inclusive_range(\n            limbs,\n            a,\n            -Integer::power_of_2(unsigned_min_bits - 1),\n        )\n    }\n}\n\nfn get_random_integer_from_signed_max_bit_range(\n    limbs: &mut RandomPrimitiveInts<u64>,\n    a: Integer,\n    unsigned_max_bits: u64,\n) -> Integer {\n    if a > 0 {\n        get_uniform_random_integer_from_inclusive_range(\n            limbs,\n            Integer::power_of_2(unsigned_max_bits - 1),\n            a,\n        )\n    } else {\n        // also handles a == 0\n        get_uniform_random_integer_from_inclusive_range(\n            limbs,\n            -Integer::power_of_2(unsigned_max_bits) + Integer::ONE,\n            a,\n        )\n    }\n}\n\nfn get_striped_random_integer_from_signed_min_bit_range(\n    xs: &mut StripedBitSource,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    unsigned_min_bits: u64,\n) -> Integer {\n    if a >= 0 {\n        get_striped_random_integer_from_range(\n            xs,\n            range_generator,\n            a,\n            Integer::power_of_2(unsigned_min_bits),\n        )\n    } else {\n        get_striped_random_integer_from_inclusive_range(\n            xs,\n            range_generator,\n            a,\n            -Integer::power_of_2(unsigned_min_bits - 1),\n        )\n    }\n}\n\nfn get_striped_random_integer_from_signed_max_bit_range(\n    xs: &mut StripedBitSource,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    unsigned_max_bits: u64,\n) -> Integer {\n    if a > 0 {\n        get_striped_random_integer_from_inclusive_range(\n            xs,\n            range_generator,\n            Integer::power_of_2(unsigned_max_bits - 1),\n            a,\n        )\n    } else {\n        // also handles a == 0\n        get_striped_random_integer_from_inclusive_range(\n            xs,\n            range_generator,\n            -Integer::power_of_2(unsigned_max_bits) + Integer::ONE,\n            a,\n        )\n    }\n}\n\n/// Generates random [`Integer`]s greater than or equal to a lower bound, or less than or equal to\n/// an upper bound.\n#[derive(Clone, Debug)]\npub struct RandomIntegerRangeToInfinity {\n    boundary_bits: i64,\n    bits: GeometricRandomSignedRange<i64>,\n    limbs: RandomPrimitiveInts<u64>,\n    boundary_bit_xs: UniformRandomIntegerRange,\n}\n\nimpl Iterator for RandomIntegerRangeToInfinity {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        let bits = self.bits.next().unwrap();\n        if bits == self.boundary_bits {\n            self.boundary_bit_xs.next()\n        } else {\n            Some(Integer::from_sign_and_abs(\n                bits >= 0,\n                get_random_natural_with_bits(&mut self.limbs, bits.unsigned_abs()),\n            ))\n        }\n    }\n}\n\n/// Generates random [`Integer`]s greater than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the absolute values of the generated values is specified. $m$ is\n/// equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a > 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_integer_range_to_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_integer_range_to_infinity(EXAMPLE_SEED, Integer::from(-1000), 10, 1),\n///         10\n///     ),\n///     \"[15542, 2, 1714, 27863518, -162, 956, 8, 14648399, -419, -98, ...]\"\n/// )\n/// ```\npub fn random_integer_range_to_infinity(\n    seed: Seed,\n    a: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegerRangeToInfinity {\n    let (unsigned_min_bits, min_bits) = signed_significant_bits(&a);\n    RandomIntegerRangeToInfinity {\n        boundary_bits: min_bits,\n        bits: geometric_random_signed_inclusive_range(\n            seed.fork(\"bits\"),\n            min_bits,\n            i64::MAX,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n        boundary_bit_xs: signed_min_bit_range(seed.fork(\"min_bit_xs\"), a, unsigned_min_bits),\n    }\n}\n\n/// Generates a random [`Integer`] greater than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the absolute values of the generated value is specified. $m$ is equal\n/// to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// # Expected complexity\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a > 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_random_integer_from_range_to_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_random_integer_from_range_to_infinity(\n///         &mut random_primitive_ints(EXAMPLE_SEED.fork(\"limbs\")),\n///         &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"rg\")),\n///         Integer::from(-1000),\n///         20,\n///         1\n///     ),\n///     -2\n/// )\n/// ```\npub fn get_random_integer_from_range_to_infinity(\n    limbs: &mut RandomPrimitiveInts<u64>,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> Integer {\n    let (unsigned_min_bits, min_bits) = signed_significant_bits(&a);\n    let bits = get_geometric_random_signed_from_inclusive_range(\n        range_generator,\n        min_bits,\n        i64::MAX,\n        mean_bits_numerator,\n        mean_bits_denominator,\n    );\n    if bits == min_bits {\n        get_random_integer_from_signed_min_bit_range(limbs, a, unsigned_min_bits)\n    } else {\n        Integer::from_sign_and_abs(\n            bits >= 0,\n            get_random_natural_with_bits(limbs, bits.unsigned_abs()),\n        )\n    }\n}\n\n/// Generates random [`Integer`]s less than or equal to an upper bound $a$.\n///\n/// The mean bit length $m$ of the absolute values of the generated values is specified. $m$ is\n/// equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a < 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_integer_range_to_negative_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_integer_range_to_negative_infinity(EXAMPLE_SEED, Integer::from(1000), 10, 1),\n///         10\n///     ),\n///     \"[6, 2, -1714, -235958584061012446, -455842, 514, -12, -14936760, 335, 99, ...]\"\n/// )\n/// ```\npub fn random_integer_range_to_negative_infinity(\n    seed: Seed,\n    a: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegerRangeToInfinity {\n    let (unsigned_max_bits, max_bits) = signed_significant_bits(&a);\n    RandomIntegerRangeToInfinity {\n        boundary_bits: max_bits,\n        bits: geometric_random_signed_inclusive_range(\n            seed.fork(\"bits\"),\n            i64::MIN,\n            max_bits,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n        boundary_bit_xs: signed_max_bit_range(seed.fork(\"max_bit_xs\"), a, unsigned_max_bits),\n    }\n}\n\n/// Generates a random [`Integer`] less than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the absolute values of the generated value is specified. $m$ is equal\n/// to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// # Expected complexity\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a < 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_random_integer_from_range_to_negative_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_random_integer_from_range_to_negative_infinity(\n///         &mut random_primitive_ints(EXAMPLE_SEED.fork(\"limbs\")),\n///         &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"rg\")),\n///         Integer::from(-1000),\n///         20,\n///         1\n///     ),\n///     -3254\n/// )\n/// ```\npub fn get_random_integer_from_range_to_negative_infinity(\n    limbs: &mut RandomPrimitiveInts<u64>,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> Integer {\n    let (unsigned_max_bits, max_bits) = signed_significant_bits(&a);\n    let bits = get_geometric_random_signed_from_inclusive_range(\n        range_generator,\n        i64::MIN,\n        max_bits,\n        mean_bits_numerator,\n        mean_bits_denominator,\n    );\n    if bits == max_bits {\n        get_random_integer_from_signed_max_bit_range(limbs, a, unsigned_max_bits)\n    } else {\n        Integer::from_sign_and_abs(\n            bits >= 0,\n            get_random_natural_with_bits(limbs, bits.unsigned_abs()),\n        )\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct RandomIntegerRangeMultipleOrders {\n    min_bits: i64,\n    max_bits: i64,\n    bits: GeometricRandomSignedRange<i64>,\n    limbs: RandomPrimitiveInts<u64>,\n    min_bit_xs: UniformRandomIntegerRange,\n    max_bit_xs: UniformRandomIntegerRange,\n}\n\nimpl Iterator for RandomIntegerRangeMultipleOrders {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        let bits = self.bits.next().unwrap();\n        if bits == self.min_bits {\n            self.min_bit_xs.next()\n        } else if bits == self.max_bits {\n            self.max_bit_xs.next()\n        } else {\n            Some(Integer::from_sign_and_abs(\n                bits >= 0,\n                get_random_natural_with_bits(&mut self.limbs, bits.unsigned_abs()),\n            ))\n        }\n    }\n}\n\n/// Generates random [`Integer`]s in an interval.\n#[derive(Clone, Debug)]\n#[allow(clippy::large_enum_variant)]\npub enum RandomIntegerRange {\n    SingleOrder(UniformRandomIntegerRange),\n    MultipleOrders(RandomIntegerRangeMultipleOrders),\n}\n\nimpl Iterator for RandomIntegerRange {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        match self {\n            Self::SingleOrder(xs) => xs.next(),\n            Self::MultipleOrders(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates random [`Integer`]s in the half-open interval $[a, b)$.\n///\n/// In general, the [`Integer`]s are not generated uniformly; for that, use\n/// [`uniform_random_integer_range`]. Instead, [`Integer`]s with smaller bit lengths are generated\n/// more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_bits_numerator / mean_bits_denominator`. It is not actually the mean bit length, though it\n/// approaches the mean bit length of the values minus $a$ as $\\log (b/a)$ approaches infinity. $m$\n/// cannot be 0, and must be greater than the bit length of the smallest integer in the range, but\n/// it may be arbitrarily large. The smaller it is, the more quickly the probabilities decrease as\n/// bit length increases. The larger it is, the more closely the distribution approaches a uniform\n/// distribution over the bit lengths.\n///\n/// Once a bit length is selected, the [`Integer`] is chosen uniformly from all [`Integer`]s with\n/// that bit length that are in $[a, b)$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(m) = O(m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_bits_numerator +\n/// mean_bits_denominator`, and $m$ is `max(a.significant_bits(), b.significant_bits())`.\n///\n/// # Panics\n/// Panics if $a \\geq b$, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if their\n/// ratio is less than or equal to the bit length of the smallest integer in the range, or if they\n/// are too large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_integer_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_integer_range(\n///             EXAMPLE_SEED,\n///             Integer::from(-1000),\n///             Integer::from(1000000000),\n///             20,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[1, 1728664, 434, -30, 5282, 515436476, 2353848, -15, 19, 418, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_integer_range(\n    seed: Seed,\n    a: Integer,\n    b: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegerRange {\n    assert!(a < b);\n    random_integer_inclusive_range(\n        seed,\n        a,\n        b - Integer::ONE,\n        mean_bits_numerator,\n        mean_bits_denominator,\n    )\n}\n\n/// Generates random [`Integer`]s in the closed interval $[a, b]$.\n///\n/// In general, the [`Integer`]s are not generated uniformly; for that, use\n/// [`uniform_random_integer_inclusive_range`]. Instead, [`Integer`]s with smaller bit lengths are\n/// generated more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_bits_numerator / mean_bits_denominator`. It is not actually the mean bit length, though it\n/// approaches the mean bit length of the values minus $a$ as $\\log (b/a)$ approaches infinity. $m$\n/// cannot be 0, and must be greater than the bit length of the smallest integer in the range, but\n/// it may be arbitrarily large. The smaller it is, the more quickly the probabilities decrease as\n/// bit length increases. The larger it is, the more closely the distribution approaches a uniform\n/// distribution over the bit lengths.\n///\n/// Once a bit length is selected, the [`Integer`] is chosen uniformly from all [`Integer`]s with\n/// that bit length that are in $[a, b]$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(m) = O(m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_bits_numerator +\n/// mean_bits_denominator`, and $m$ is `max(a.significant_bits(), b.significant_bits())`.\n///\n/// # Panics\n/// Panics if $a > b$, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if their ratio\n/// is less than or equal to the bit length of the smallest integer in the range, or if they are too\n/// large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::random_integer_inclusive_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_integer_inclusive_range(\n///             EXAMPLE_SEED,\n///             Integer::from(-1000),\n///             Integer::from(999999999),\n///             20,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[1, 1728664, 434, -30, 5282, 515436476, 2353848, -15, 19, 418, ...]\"\n/// )\n/// ```\npub fn random_integer_inclusive_range(\n    seed: Seed,\n    a: Integer,\n    b: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomIntegerRange {\n    assert!(a <= b);\n    let (unsigned_min_bits, min_bits) = signed_significant_bits(&a);\n    let (unsigned_max_bits, max_bits) = signed_significant_bits(&b);\n    if min_bits == max_bits {\n        RandomIntegerRange::SingleOrder(uniform_random_integer_inclusive_range(seed, a, b))\n    } else {\n        RandomIntegerRange::MultipleOrders(RandomIntegerRangeMultipleOrders {\n            min_bits,\n            max_bits,\n            bits: geometric_random_signed_inclusive_range(\n                seed.fork(\"bits\"),\n                min_bits,\n                max_bits,\n                mean_bits_numerator,\n                mean_bits_denominator,\n            ),\n            limbs: random_primitive_ints(seed.fork(\"limbs\")),\n            min_bit_xs: signed_min_bit_range(seed.fork(\"min_bit_xs\"), a, unsigned_min_bits),\n            max_bit_xs: signed_max_bit_range(seed.fork(\"max_bit_xs\"), b, unsigned_max_bits),\n        })\n    }\n}\n\n/// Generates random striped [`Integer`]s from a range.\n#[derive(Clone, Debug)]\npub enum StripedRandomIntegerInclusiveRange {\n    NonNegative(StripedRandomNaturalInclusiveRange),\n    Negative(StripedRandomNaturalInclusiveRange),\n    Both(\n        RandomBools,\n        Box<StripedRandomNaturalInclusiveRange>,\n        Box<StripedRandomNaturalInclusiveRange>,\n    ),\n}\n\nimpl Iterator for StripedRandomIntegerInclusiveRange {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        match self {\n            Self::NonNegative(xs) => xs.next().map(Integer::from),\n            Self::Negative(xs) => xs.next().map(|x| Integer::from_sign_and_abs(false, x)),\n            Self::Both(bs, xs_nn, xs_n) => {\n                if bs.next().unwrap() {\n                    xs_nn.next().map(Integer::from)\n                } else {\n                    xs_n.next().map(|x| Integer::from_sign_and_abs(false, x))\n                }\n            }\n        }\n    }\n}\n\n/// Generates random striped [`Integer`]s in the range $[a, b)$.\n///\n/// Because the [`Integer`]s are constrained to be within a certain range, the actual mean run\n/// length will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean\n/// run length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n/// use malachite_nz::integer::random::striped_random_integer_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_integer_range(EXAMPLE_SEED, Integer::from(-4), Integer::from(7), 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[-100, -100, 110, 11, -100, 0, 110, 11, 0, 110, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_integer_range(\n    seed: Seed,\n    a: Integer,\n    b: Integer,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomIntegerInclusiveRange {\n    assert!(a < b);\n    striped_random_integer_inclusive_range(\n        seed,\n        a,\n        b - Integer::ONE,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped [`Integer`]s in the range $[a, b]$.\n///\n/// Because the [`Integer`]s are constrained to be within a certain range, the actual mean run\n/// length will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean\n/// run length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n/// use malachite_nz::integer::random::striped_random_integer_inclusive_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_integer_inclusive_range(\n///             EXAMPLE_SEED,\n///             Integer::from(-4),\n///             Integer::from(6),\n///             4,\n///             1\n///         )\n///         .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[-100, -100, 110, 11, -100, 0, 110, 11, 0, 110, ...]\"\n/// );\n/// ```\npub fn striped_random_integer_inclusive_range(\n    seed: Seed,\n    a: Integer,\n    b: Integer,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomIntegerInclusiveRange {\n    assert!(a <= b);\n    if a >= 0u32 {\n        StripedRandomIntegerInclusiveRange::NonNegative(striped_random_natural_inclusive_range(\n            seed,\n            a.unsigned_abs(),\n            b.unsigned_abs(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ))\n    } else if b < 0u32 {\n        StripedRandomIntegerInclusiveRange::Negative(striped_random_natural_inclusive_range(\n            seed,\n            b.unsigned_abs(),\n            a.unsigned_abs(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ))\n    } else {\n        StripedRandomIntegerInclusiveRange::Both(\n            random_bools(seed.fork(\"sign\")),\n            Box::new(striped_random_natural_inclusive_range(\n                seed.fork(\"non-negative\"),\n                Natural::ZERO,\n                b.unsigned_abs(),\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n            )),\n            Box::new(striped_random_natural_inclusive_range(\n                seed.fork(\"negative\"),\n                Natural::ONE,\n                a.unsigned_abs(),\n                mean_stripe_numerator,\n                mean_stripe_denominator,\n            )),\n        )\n    }\n}\n\n/// Generates a random striped [`Integer`] in the range $[a, b)$.\n///\n/// Because the [`Integer`] is constrained to be within a certain range, the actual mean run length\n/// will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean run\n/// length.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_striped_random_integer_from_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_striped_random_integer_from_range(\n///         &mut StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1),\n///         &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"rg\")),\n///         Integer::from(-4),\n///         Integer::from(7),\n///     ),\n///     -4\n/// );\n/// ```\n#[inline]\npub fn get_striped_random_integer_from_range(\n    xs: &mut StripedBitSource,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    b: Integer,\n) -> Integer {\n    assert!(a < b);\n    get_striped_random_integer_from_inclusive_range(xs, range_generator, a, b - Integer::ONE)\n}\n\n/// Generates a random striped [`Integer`] in the range $[a, b]$.\n///\n/// Because the [`Integer`] is constrained to be within a certain range, the actual mean run length\n/// will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean run\n/// length.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.significant_bits(),\n/// b.significant_bits())`.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_striped_random_integer_from_inclusive_range;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_striped_random_integer_from_inclusive_range(\n///         &mut StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1),\n///         &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"rg\")),\n///         Integer::from(-4),\n///         Integer::from(7),\n///     ),\n///     -4\n/// );\n/// ```\npub fn get_striped_random_integer_from_inclusive_range(\n    xs: &mut StripedBitSource,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    b: Integer,\n) -> Integer {\n    assert!(a <= b);\n    if a >= 0u32 {\n        Integer::from(get_striped_random_natural_from_inclusive_range(\n            xs,\n            a.unsigned_abs(),\n            b.unsigned_abs(),\n        ))\n    } else if b < 0u32 {\n        Integer::from_sign_and_abs(\n            false,\n            get_striped_random_natural_from_inclusive_range(xs, b.unsigned_abs(), a.unsigned_abs()),\n        )\n    } else if range_generator.next_bool() {\n        Integer::from(get_striped_random_natural_from_inclusive_range(\n            xs,\n            Natural::ZERO,\n            b.unsigned_abs(),\n        ))\n    } else {\n        Integer::from_sign_and_abs(\n            false,\n            get_striped_random_natural_from_inclusive_range(xs, Natural::ONE, a.unsigned_abs()),\n        )\n    }\n}\n\nfn striped_signed_min_bit_range(\n    seed: Seed,\n    a: Integer,\n    unsigned_min_bits: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomIntegerInclusiveRange {\n    if a >= 0 {\n        striped_random_integer_range(\n            seed.fork(\"min_bit_xs\"),\n            a,\n            Integer::power_of_2(unsigned_min_bits),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        )\n    } else {\n        striped_random_integer_inclusive_range(\n            seed.fork(\"min_bit_xs\"),\n            a,\n            -Integer::power_of_2(unsigned_min_bits - 1),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        )\n    }\n}\n\nfn striped_signed_max_bit_range(\n    seed: Seed,\n    a: Integer,\n    unsigned_max_bits: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomIntegerInclusiveRange {\n    if a > 0 {\n        striped_random_integer_inclusive_range(\n            seed.fork(\"max_bit_xs\"),\n            Integer::power_of_2(unsigned_max_bits - 1),\n            a,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        )\n    } else {\n        // also handles a == 0\n        striped_random_integer_inclusive_range(\n            seed.fork(\"max_bit_xs\"),\n            -Integer::power_of_2(unsigned_max_bits) + Integer::ONE,\n            a,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        )\n    }\n}\n\n/// Generates striped random [`Integer`]s greater than or equal to a lower bound, or less than or\n/// equal to an upper bound.\n#[derive(Clone, Debug)]\npub struct StripedRandomIntegerRangeToInfinity {\n    boundary_bits: i64,\n    bits: GeometricRandomSignedRange<i64>,\n    bit_source: StripedBitSource,\n    boundary_bit_xs: StripedRandomIntegerInclusiveRange,\n}\n\nimpl Iterator for StripedRandomIntegerRangeToInfinity {\n    type Item = Integer;\n\n    fn next(&mut self) -> Option<Integer> {\n        let bits = self.bits.next().unwrap();\n        if bits == self.boundary_bits {\n            self.boundary_bit_xs.next()\n        } else {\n            Some(Integer::from_sign_and_abs(\n                bits >= 0,\n                get_striped_random_natural_with_bits(&mut self.bit_source, bits.unsigned_abs()),\n            ))\n        }\n    }\n}\n\n/// Generates striped random [`Integer`]s greater than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the [`Integer`]s is specified; it must be greater than the bit length\n/// of $a$. $m$ is equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The actual bit length is chosen from a geometric distribution with lower bound $a$ and mean $m$.\n/// The resulting distribution has no mean or higher-order statistics (unless $a < m < a + 1$, which\n/// is not typical).\n///\n/// Because the [`Integer`]s are constrained to be within a certain range, the actual mean run\n/// length will usually not be $\\mu$. Nonetheless, setting a higher $\\mu$ will result in a higher\n/// mean run length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a >\n/// 0$ and their ratio is less than or equal to the bit length of $a$, or if they are too large and\n/// manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::striped_random_integer_range_to_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_integer_range_to_infinity(\n///             EXAMPLE_SEED,\n///             Integer::from(-1000),\n///             20,\n///             1,\n///             10,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[8192, 2, 1024, 33554400, -128, 1023, 8, 14745599, -256, -67, ...]\"\n/// )\n/// ```\npub fn striped_random_integer_range_to_infinity(\n    seed: Seed,\n    a: Integer,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomIntegerRangeToInfinity {\n    let (unsigned_min_bits, min_bits) = signed_significant_bits(&a);\n    StripedRandomIntegerRangeToInfinity {\n        boundary_bits: min_bits,\n        bits: geometric_random_signed_inclusive_range(\n            seed.fork(\"bits\"),\n            min_bits,\n            i64::MAX,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        boundary_bit_xs: striped_signed_min_bit_range(\n            seed.fork(\"min_bit_xs\"),\n            a,\n            unsigned_min_bits,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates a striped random [`Integer`] greater than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the [`Integer`] is specified; it must be greater than the bit length\n/// of $a$. $m$ is equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The actual bit length is chosen from a geometric distribution with lower bound $a$ and mean $m$.\n/// The resulting distribution has no mean or higher-order statistics (unless $a < m < a + 1$, which\n/// is not typical).\n///\n/// Because the [`Integer`] is constrained to be within a certain range, the actual mean run length\n/// will usually not be $\\mu$. Nonetheless, setting a higher $\\mu$ will result in a higher mean run\n/// length.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a > 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_striped_random_integer_from_range_to_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_striped_random_integer_from_range_to_infinity(\n///         &mut StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1),\n///         &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"rg\")),\n///         Integer::from(-1000),\n///         20,\n///         1\n///     ),\n///     -3\n/// );\n/// ```\npub fn get_striped_random_integer_from_range_to_infinity(\n    xs: &mut StripedBitSource,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> Integer {\n    let (unsigned_min_bits, min_bits) = signed_significant_bits(&a);\n    let bits = get_geometric_random_signed_from_inclusive_range(\n        range_generator,\n        min_bits,\n        i64::MAX,\n        mean_bits_numerator,\n        mean_bits_denominator,\n    );\n    if bits == min_bits {\n        get_striped_random_integer_from_signed_min_bit_range(\n            xs,\n            range_generator,\n            a,\n            unsigned_min_bits,\n        )\n    } else {\n        Integer::from_sign_and_abs(\n            bits >= 0,\n            get_striped_random_natural_with_bits(xs, bits.unsigned_abs()),\n        )\n    }\n}\n\n/// Generates a striped random [`Integer`] less than or equal to an upper bound $a$.\n///\n/// The mean bit length $m$ of the [`Integer`] is specified; it must be greater than the bit length\n/// of $a$. $m$ is equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The actual bit length is chosen from a geometric distribution with lower bound $a$ and mean $m$.\n/// The resulting distribution has no mean or higher-order statistics (unless $a < m < a + 1$, which\n/// is not typical).\n///\n/// Because the [`Integer`] is constrained to be within a certain range, the actual mean run length\n/// will usually not be $\\mu$. Nonetheless, setting a higher $\\mu$ will result in a higher mean run\n/// length.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $b < 0$ and their ratio\n/// is less than or equal to the bit length of $b$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::num::random::VariableRangeGenerator;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::get_striped_random_integer_from_range_to_negative_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     get_striped_random_integer_from_range_to_negative_infinity(\n///         &mut StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1),\n///         &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"rg\")),\n///         Integer::from(-1000),\n///         20,\n///         1\n///     ),\n///     -3975\n/// );\n/// ```\npub fn get_striped_random_integer_from_range_to_negative_infinity(\n    xs: &mut StripedBitSource,\n    range_generator: &mut VariableRangeGenerator,\n    a: Integer,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> Integer {\n    let (unsigned_max_bits, max_bits) = signed_significant_bits(&a);\n    let bits = get_geometric_random_signed_from_inclusive_range(\n        range_generator,\n        i64::MIN,\n        max_bits,\n        mean_bits_numerator,\n        mean_bits_denominator,\n    );\n    if bits == max_bits {\n        get_striped_random_integer_from_signed_max_bit_range(\n            xs,\n            range_generator,\n            a,\n            unsigned_max_bits,\n        )\n    } else {\n        Integer::from_sign_and_abs(\n            bits >= 0,\n            get_striped_random_natural_with_bits(xs, bits.unsigned_abs()),\n        )\n    }\n}\n\n/// Generates striped random [`Integer`]s less than or equal to an upper bound $a$.\n///\n/// The mean bit length $m$ of the [`Integer`]s is specified; it must be greater than the bit length\n/// of $a$. $m$ is equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The actual bit length is chosen from a geometric distribution with lower bound $a$ and mean $m$.\n/// The resulting distribution has no mean or higher-order statistics (unless $a < m < a + 1$, which\n/// is not typical).\n///\n/// Because the [`Integer`]s are constrained to be within a certain range, the actual mean run\n/// length will usually not be $\\mu$. Nonetheless, setting a higher $\\mu$ will result in a higher\n/// mean run length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $b <\n/// 0$ and their ratio is less than or equal to the bit length of $b$, or if they are too large and\n/// manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::integer::random::striped_random_integer_range_to_negative_infinity;\n/// use malachite_nz::integer::Integer;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_integer_range_to_negative_infinity(\n///             EXAMPLE_SEED,\n///             Integer::from(1000),\n///             20,\n///             1,\n///             10,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[4, 2, -1024, -144115188075919360, -516096, 992, -15, -16776704, 511, 64, ...]\"\n/// )\n/// ```\npub fn striped_random_integer_range_to_negative_infinity(\n    seed: Seed,\n    a: Integer,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomIntegerRangeToInfinity {\n    let (unsigned_max_bits, max_bits) = signed_significant_bits(&a);\n    StripedRandomIntegerRangeToInfinity {\n        boundary_bits: max_bits,\n        bits: geometric_random_signed_inclusive_range(\n            seed.fork(\"bits\"),\n            i64::MIN,\n            max_bits,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        boundary_bit_xs: striped_signed_max_bit_range(\n            seed.fork(\"max_bit_xs\"),\n            a,\n            unsigned_max_bits,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n//! This crate defines [`Natural`](natural::Natural)s (non-negative integers) and\n//! [`Integer`](integer::Integer)s. Unlike primitive integers ([`u32`], [`i32`], and so on), these\n//! may be arbitrarily large. The name of this crate refers to the mathematical symbols for natural\n//! numbers and integers, $\\N$ and $\\Z$.\n//! - There are many functions defined on [`Natural`](natural::Natural)s and\n//!   [`Integer`](integer::Integer)s. These include\n//!   - All the ones you'd expect, like addition, subtraction, multiplication, and integer\n//!     division;\n//!   - Implementations of [`DivRound`](malachite_base::num::arithmetic::traits::DivRound), which\n//!     provides division that rounds according to a specified\n//!     [`RoundingMode`](malachite_base::rounding_modes::RoundingMode);\n//!   - Various mathematical functions, like implementations of\n//!     [`FloorSqrt`](malachite_base::num::arithmetic::traits::FloorSqrt) and\n//!     [`Gcd`](malachite_base::num::arithmetic::traits::Gcd);\n//!   - Modular arithmetic functions, like implementations of\n//!     [`ModAdd`](malachite_base::num::arithmetic::traits::ModAdd) and\n//!     [`ModPow`](malachite_base::num::arithmetic::traits::ModPow), and of traits for arithmetic\n//!     modulo a power of 2, like\n//!     [`ModPowerOf2Add`](malachite_base::num::arithmetic::traits::ModPowerOf2Add) and\n//!     [`ModPowerOf2Pow`](malachite_base::num::arithmetic::traits::ModPowerOf2Pow);\n//!   - Various functions for logic and bit manipulation, like [`BitAnd`](core::ops::BitAnd) and\n//!     [`BitAccess`](malachite_base::num::logic::traits::BitAccess).\n//! - The implementations of these functions use high-performance algorithms that work efficiently\n//!   for large numbers. For example, multiplication uses the naive quadratic algorithm, or one of\n//!   13 variants of\n//!   [Toom-Cook multiplication](https://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication),\n//!   or\n//!   [Schönhage-Strassen (FFT) multiplication](https://en.wikipedia.org/wiki/Schonhage-Strassen_algorithm),\n//!   depending on the input size.\n//! - Small numbers are also handled efficiently. Any [`Natural`](natural::Natural) smaller than\n//!   $2^{64}$ does not use any allocated memory, and working with such numbers is almost as fast\n//!   as working with primitive integers. As a result, Malachite does not provide implementations\n//!   for _e.g._ adding a [`Natural`](natural::Natural) to a [`u64`], since the [`u64`] can be\n//!   converted to a [`Natural`](natural::Natural) very cheaply.\n//! - Malachite handles memory intelligently. Consider the problem of adding a 1000-bit\n//!   [`Natural`](natural::Natural) and a 500-bit [`Natural`](natural::Natural). If we only have\n//!   references to the [`Natural`](natural::Natural)s, then we must allocate new memory for the\n//!   result, and this is what the `&Natural + &Natural` implementation does. However, if we can\n//!   take the first (larger) [`Natural`](natural::Natural) by value, then we do not need to\n//!   allocate any memory (except in the unlikely case of a carry): we can reuse the memory of the\n//!   first [`Natural`](natural::Natural) to store the result, and this is what the\n//!   `Natural + &Natural` implementation does. On the other hand, if we can only take the second\n//!   (smaller) [`Natural`](natural::Natural) by value, then we only have 500 bits of memory\n//!   available, which is not enough to store the sum. In this case, the [`Vec`] containing the\n//!   smaller [`Natural`](natural::Natural)'s data can be extended to hold 1000 bits, in hopes that\n//!   this will be more efficient than allocating 1000 bits in a completely new [`Vec`]. Finally,\n//!   if both [`Natural`](natural::Natural)s are taken by value, then the `Natural + Natural`\n//!   implementation chooses to reuse the memory of the larger one.\n//!\n//!   Now consider what happens when evaluating the expression `&x + &y + &z`, where each\n//!   [`Natural`](natural::Natural) has $n$ bits. Malachite must allocate about $n$ bits for the\n//!   result, but what about the intermediate sum `&x + &y`? Does Malachite need to allocate\n//!   another $n$ bits for that, for a total of $2n$ bits? No! Malachite first allocates $n$ bits\n//!   for `&x + &y`, but then that partial sum is taken by _value_ using the `Natural + &Natural`\n//!   implementation described above; so those $n$ bits are reused for the final sum.\n//!\n//! # Limbs\n//! Large [`Natural`](natural::Natural)s and [`Integer`](integer::Integer)s store their data as\n//! [`Vec`]s of some primitive type. The elements of these\n//! [`Vec`]s are called \"limbs\" in GMP terminology, since they're large digits.\n//! By default, the type of a `Limb` is [`u64`], but you can set it to [`u32`] using the\n//! `32_bit_limbs` feature.\n//!\n//! # Demos and benchmarks\n//! This crate comes with a `bin` target that can be used for running demos and benchmarks.\n//! - Almost all of the public functions in this crate have an associated demo. Running a demo\n//!   shows you a function's behavior on a large number of inputs. For example, to demo the\n//!   [`mod_pow`](malachite_base::num::arithmetic::traits::ModPow::mod_pow) function on\n//!   [`Natural`](natural::Natural)s, you can use the following command:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_natural_mod_pow\n//!   ```\n//!   This command uses the `exhaustive` mode, which generates every possible input, generally\n//!   starting with the simplest input and progressing to more complex ones. Another mode is\n//!   `random`. The `-l` flag specifies how many inputs should be generated.\n//! - You can use a similar command to run benchmarks. The following command benchmarks various\n//!   GCD algorithms for [`u64`]s:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n//!       benchmark_natural_gcd_algorithms -o gcd-bench.gp\n//!   ```\n//!   or GCD implementations of other libraries:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n//!       benchmark_natural_gcd_library_comparison -o gcd-bench.gp\n//!   ```\n//!   This creates a file called gcd-bench.gp. You can use gnuplot to create an SVG from it like\n//!   so:\n//!   ```text\n//!   gnuplot -e \"set terminal svg; l \\\"gcd-bench.gp\\\"\" > gcd-bench.svg\n//!   ```\n//!\n//! The list of available demos and benchmarks is not documented anywhere; you must find them by\n//! browsing through\n//! [`bin_util/demo_and_bench`](https://github.com/mhogrefe/malachite/tree/master/malachite-nz/src/bin_util/demo_and_bench).\n//!\n//! # Features\n//! - `32_bit_limbs`: Sets the type of [`Limb`](crate#limbs) to [`u32`] instead of the default,\n//!   [`u64`].\n//! - `test_build`: A large proportion of the code in this crate is only used for testing. For a\n//!   typical user, building this code would result in an unnecessarily long compilation time and\n//!   an unnecessarily large binary. Some of it is also used for testing `malachite-q`, so it can't\n//!   just be confined to the `tests` directory. My solution is to only build this code when the\n//!   `test_build` feature is enabled. If you want to run unit tests, you must enable `test_build`.\n//!   However, doctests don't require it, since they only test the public interface.\n//! - `bin_build`: This feature is used to build the code for demos and benchmarks, which also\n//!   takes a long time to build. Enabling this feature also enables `test_build`.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n#![cfg_attr(\n    not(any(feature = \"test_build\", feature = \"random\", feature = \"std\")),\n    no_std\n)]\n\n#[macro_use]\nextern crate alloc;\n\nextern crate itertools;\n#[macro_use]\nextern crate malachite_base;\n#[cfg(feature = \"serde\")]\n#[macro_use]\nextern crate serde;\n\n#[cfg(feature = \"test_build\")]\nextern crate num;\n#[cfg(feature = \"test_build\")]\nextern crate rug;\n\n#[doc(hidden)]\n#[cfg(not(feature = \"32_bit_limbs\"))]\npub use crate::platform_64 as platform;\n#[doc(hidden)]\n#[cfg(feature = \"32_bit_limbs\")]\npub use platform_32 as platform;\n\n#[doc(hidden)]\n#[cfg(feature = \"32_bit_limbs\")]\npub mod platform_32;\n#[doc(hidden)]\n#[cfg(not(feature = \"32_bit_limbs\"))]\npub mod platform_64;\n\n#[cfg(feature = \"doc-images\")]\nextern crate embed_doc_image;\n\n/// [`Natural`](natural::Natural), a type representing arbitrarily large non-negative integers.\n#[macro_use]\npub mod natural;\n/// [`Integer`](integer::Integer), a type representing integers with arbitrarily large absolute\n/// values.\npub mod integer;\n\n#[cfg(feature = \"test_build\")]\npub mod test_util;\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{AbsDiff, AbsDiffAssign};\n\nimpl AbsDiff<Self> for Natural {\n    type Output = Self;\n\n    /// Computes the absolute value of the difference between two [`Natural`]s, taking both by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32).abs_diff(Natural::ZERO), 123);\n    /// assert_eq!(Natural::ZERO.abs_diff(Natural::from(123u32)), 123);\n    /// assert_eq!(Natural::from(456u32).abs_diff(Natural::from(123u32)), 333);\n    /// assert_eq!(Natural::from(123u32).abs_diff(Natural::from(456u32)), 333);\n    /// assert_eq!(\n    ///     (Natural::from(10u32).pow(12) * Natural::from(3u32))\n    ///         .abs_diff(Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .abs_diff(Natural::from(10u32).pow(12) * Natural::from(3u32)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn abs_diff(self, other: Self) -> Self {\n        if self >= other {\n            self - other\n        } else {\n            other - self\n        }\n    }\n}\n\nimpl<'a> AbsDiff<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Computes the absolute value of the difference between two [`Natural`]s, taking the first by\n    /// value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32).abs_diff(&Natural::ZERO), 123);\n    /// assert_eq!(Natural::ZERO.abs_diff(&Natural::from(123u32)), 123);\n    /// assert_eq!(Natural::from(456u32).abs_diff(&Natural::from(123u32)), 333);\n    /// assert_eq!(Natural::from(123u32).abs_diff(&Natural::from(456u32)), 333);\n    /// assert_eq!(\n    ///     (Natural::from(10u32).pow(12) * Natural::from(3u32))\n    ///         .abs_diff(&Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .abs_diff(&(Natural::from(10u32).pow(12) * Natural::from(3u32))),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn abs_diff(self, other: &'a Self) -> Self {\n        if self >= *other {\n            self - other\n        } else {\n            other - self\n        }\n    }\n}\n\nimpl AbsDiff<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the absolute value of the difference between two [`Natural`]s, taking the first by\n    /// reference and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(123u32)).abs_diff(Natural::ZERO), 123);\n    /// assert_eq!((&Natural::ZERO).abs_diff(Natural::from(123u32)), 123);\n    /// assert_eq!(\n    ///     (&Natural::from(456u32)).abs_diff(Natural::from(123u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(123u32)).abs_diff(Natural::from(456u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (&(Natural::from(10u32).pow(12) * Natural::from(3u32)))\n    ///         .abs_diff(Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12))\n    ///         .abs_diff(Natural::from(10u32).pow(12) * Natural::from(3u32)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn abs_diff(self, other: Natural) -> Natural {\n        if *self >= other {\n            self - other\n        } else {\n            other - self\n        }\n    }\n}\n\nimpl AbsDiff<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the absolute value of the difference between two [`Natural`]s, taking both by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiff, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(123u32)).abs_diff(&Natural::ZERO), 123);\n    /// assert_eq!((&Natural::ZERO).abs_diff(&Natural::from(123u32)), 123);\n    /// assert_eq!(\n    ///     (&Natural::from(456u32)).abs_diff(&Natural::from(123u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(123u32)).abs_diff(&Natural::from(456u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (&(Natural::from(10u32).pow(12) * Natural::from(3u32)))\n    ///         .abs_diff(&Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12))\n    ///         .abs_diff(&(Natural::from(10u32).pow(12) * Natural::from(3u32))),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn abs_diff(self, other: &Natural) -> Natural {\n        if self >= other {\n            self - other\n        } else {\n            other - self\n        }\n    }\n}\n\nimpl AbsDiffAssign<Self> for Natural {\n    /// Subtracts a [`Natural`] by another [`Natural`] in place and takes the absolute value, taking\n    /// the [`Natural`] on the right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiffAssign, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.abs_diff_assign(Natural::ZERO);\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.abs_diff_assign(Natural::from(123u32));\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Natural::from(456u32);\n    /// x.abs_diff_assign(Natural::from(123u32));\n    /// assert_eq!(x, 333);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.abs_diff_assign(Natural::from(456u32));\n    /// assert_eq!(x, 333);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12) * Natural::from(3u32);\n    /// x.abs_diff_assign(Natural::from(10u32).pow(12));\n    /// assert_eq!(x, 2000000000000u64);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.abs_diff_assign(Natural::from(10u32).pow(12) * Natural::from(3u32));\n    /// assert_eq!(x, 2000000000000u64);\n    /// ```\n    fn abs_diff_assign(&mut self, other: Self) {\n        if *self >= other {\n            *self -= other;\n        } else {\n            self.sub_right_assign_no_panic(&other);\n        }\n    }\n}\n\nimpl<'a> AbsDiffAssign<&'a Self> for Natural {\n    /// Subtracts a [`Natural`] by another [`Natural`] in place and takes the absolute value, taking\n    /// the [`Natural`] on the right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AbsDiffAssign, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.abs_diff_assign(&Natural::ZERO);\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.abs_diff_assign(&Natural::from(123u32));\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Natural::from(456u32);\n    /// x.abs_diff_assign(&Natural::from(123u32));\n    /// assert_eq!(x, 333);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.abs_diff_assign(&Natural::from(456u32));\n    /// assert_eq!(x, 333);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12) * Natural::from(3u32);\n    /// x.abs_diff_assign(&Natural::from(10u32).pow(12));\n    /// assert_eq!(x, 2000000000000u64);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.abs_diff_assign(&Natural::from(10u32).pow(12) * Natural::from(3u32));\n    /// assert_eq!(x, 2000000000000u64);\n    /// ```\n    fn abs_diff_assign(&mut self, other: &'a Self) {\n        if *self >= *other {\n            *self -= other;\n        } else {\n            self.sub_right_assign_no_panic(other);\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Some optimizations contributed by florian1345.\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::shl::{limbs_shl, limbs_vec_shl_in_place};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::iter::Sum;\nuse core::ops::{Add, AddAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the sum of the `Natural` and a `Limb`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_add_1` from `gmp.h`, GMP 6.2.1, where the result is returned.\npub_crate_test! {limbs_add_limb(xs: &[Limb], mut y: Limb) -> Vec<Limb> {\n    let len = xs.len();\n    let mut out = Vec::with_capacity(len);\n    for i in 0..len {\n        let (sum, overflow) = xs[i].overflowing_add(y);\n        out.push(sum);\n        if overflow {\n            y = 1;\n        } else {\n            y = 0;\n            out.extend_from_slice(&xs[i + 1..]);\n            break;\n        }\n    }\n    if y != 0 {\n        out.push(y);\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the sum of the `Natural` and a `Limb` to an output slice. The output slice must be at\n// least as long as the input slice. Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs`.\n//\n// This is equivalent to `mpn_add_1` from `gmp.h`, GMP 6.2.1.\npub_crate_test! {limbs_add_limb_to_out(out: &mut [Limb], xs: &[Limb], mut y: Limb) -> bool {\n    let len = xs.len();\n    assert!(out.len() >= len);\n    for i in 0..len {\n        let overflow;\n        (out[i], overflow) = xs[i].overflowing_add(y);\n        if overflow {\n            y = 1;\n        } else {\n            y = 0;\n            let copy_index = i + 1;\n            out[copy_index..len].copy_from_slice(&xs[copy_index..]);\n            break;\n        }\n    }\n    y != 0\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the sum of the `Natural` and a `Limb` to the input slice. Returns whether there is a\n// carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_add_1` from `gmp.h`, GMP 6.2.1, where the result is written to the\n// input slice.\npub_crate_test! {limbs_slice_add_limb_in_place<T: PrimitiveUnsigned>(\n    xs: &mut [T],\n    mut y: T\n) -> bool {\n    for x in &mut *xs {\n        if x.overflowing_add_assign(y) {\n            y = T::ONE;\n        } else {\n            return false;\n        }\n    }\n    y != T::ZERO\n}}\n\n// Interpreting a nonempty `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes\n// the limbs of the sum of the `Natural` and a `Limb` to the input `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$ (only if the `Vec` reallocates)\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\n//\n// This is equivalent to `mpz_add_ui` from `mpz/aors_ui.h`, GMP 6.2.1, where the input is\n// non-negative.\npub_crate_test! {limbs_vec_add_limb_in_place(xs: &mut Vec<Limb>, y: Limb) {\n    assert!(!xs.is_empty());\n    if limbs_slice_add_limb_in_place(xs, y) {\n        xs.push(1);\n    }\n}}\n\n#[inline]\npub(crate) fn add_with_carry_limb<T: PrimitiveUnsigned>(x: T, y: T, carry: T) -> (T, T) {\n    let result_no_carry = x.wrapping_add(y);\n    let result = result_no_carry.wrapping_add(carry);\n    let carry = T::from((result_no_carry < x) || (result < result_no_carry));\n    (result, carry)\n}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, where the\n// first slice is at least as long as the second, returns a `Vec` of the limbs of the sum of the\n// `Natural`s.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpn_add` from `gmp.h`, GMP 6.2.1, where the first input is at least as\n// long as the second, and the output is returned.\npub_crate_test! {limbs_add_greater(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    if core::ptr::eq(xs, ys) {\n        return limbs_shl(xs, 1);\n    }\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let mut out = Vec::with_capacity(xs_len);\n    let mut carry = 0;\n    for (&x, &y) in xs.iter().zip(ys.iter()) {\n        let o;\n        (o, carry) = add_with_carry_limb(x, y, carry);\n        out.push(o);\n    }\n    if xs_len == ys_len {\n        if carry != 0 {\n            out.push(1);\n        }\n    } else {\n        out.extend_from_slice(&xs[ys_len..]);\n        if carry != 0 && limbs_slice_add_limb_in_place(&mut out[ys_len..], 1) {\n            out.push(1);\n        }\n    }\n    out\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns a\n// `Vec` of the limbs of the sum of the `Natural`s.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpn_add` from `gmp.h`, GMP 6.2.1, where the output is returned.\npub_crate_test! {limbs_add(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    if xs.len() >= ys.len() {\n        limbs_add_greater(xs, ys)\n    } else {\n        limbs_add_greater(ys, xs)\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the `xs.len()` least-significant limbs of the sum of the `Natural`s to an\n// output slice. The output must be at least as long as one of the input slices. Returns whether\n// there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths or if `out` is too short.\n//\n// This is equivalent to `mpn_add_n` from `gmp.h`, GMP 6.2.1.\npub_crate_test! {limbs_add_same_length_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(out.len() >= len);\n    let mut carry = 0;\n    for (out, (&x, &y)) in out.iter_mut().zip(xs.iter().zip(ys.iter())) {\n        (*out, carry) = add_with_carry_limb(x, y, carry);\n    }\n    carry != 0\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, where the\n// first slice is at least as long as the second, writes the `xs.len()` least-significant limbs of\n// the sum of the `Natural`s to an output slice. The output must be at least as long as `xs`.\n// Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys` or if `out` is too short.\n//\n// This is equivalent to `mpn_add` from `gmp.h`, GMP 6.2.1, where the first input is at least as\n// long as the second.\npub_crate_test! {limbs_add_greater_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    assert!(out.len() >= xs_len);\n    let carry = limbs_add_same_length_to_out(out, &xs[..ys_len], ys);\n    if xs_len == ys_len {\n        carry\n    } else if carry {\n        limbs_add_limb_to_out(&mut out[ys_len..], &xs[ys_len..], 1)\n    } else {\n        out[ys_len..xs_len].copy_from_slice(&xs[ys_len..]);\n        false\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `max(xs.len(), ys.len())` least-significant limbs of the sum of the `Natural`s to an output\n// slice. The output must be at least as long as the longer input slice. Returns whether there is a\n// carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `out` is too short.\n//\n// This is equivalent to `mpn_add` from `gmp.h`, GMP 6.2.1.\npub_crate_test! {limbs_add_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_add_greater_to_out(out, xs, ys)\n    } else {\n        limbs_add_greater_to_out(out, ys, xs)\n    }\n}}\n\n// Given two slices of `Limb`s as the limbs `xs` and `ys`, where `xs` is at least as long as `ys`\n// and `xs_len` is no greater than `ys.len()`, writes the `ys.len()` lowest limbs of the sum of\n// `xs[..xs_len]` and `ys` to `xs`. Returns whether there is a carry.\n//\n// For example, `limbs_add_to_out_aliased(&mut xs[..12], 7, &ys[..10])` would be equivalent to\n// `limbs_add_to_out(&mut xs[..12], &xs[..7], &ys[..10])` although the latter expression is not\n// allowed because `xs` cannot be borrowed in that way.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys` or `xs_len` is greater than `ys.len()`.\n//\n// This is equivalent to `mpn_add` from `gmp.h`, GMP 6.2.1, where the second argument is at least as\n// long as the first and the output pointer is the same as the first input pointer.\npub_crate_test! {limbs_add_to_out_aliased(xs: &mut [Limb], xs_len: usize, ys: &[Limb]) -> bool {\n    let ys_len = ys.len();\n    assert!(xs.len() >= ys_len);\n    assert!(xs_len <= ys_len);\n    let (ys_lo, ys_hi) = ys.split_at(xs_len);\n    xs[xs_len..ys_len].copy_from_slice(ys_hi);\n    limbs_slice_add_greater_in_place_left(&mut xs[..ys_len], ys_lo)\n}}\n\n// For example, `limbs_add_to_out_aliased_2(&mut xs[..15], 5, &ys[..10])` would be equivalent to\n// `limbs_add_to_out(&mut xs[..10], &xs[5..15], &ys[..10])` although the latter expression is not\n// allowed because `xs` cannot be borrowed in that way.\npub_crate_test! {\n    limbs_add_to_out_aliased_2(xs: &mut [Limb], xs_offset: usize, ys: &[Limb]) -> bool {\n    let len = ys.len();\n    assert_eq!(xs.len(), len + xs_offset);\n    let mut carry = 0;\n    for i in 0..len {\n        (xs[i], carry) = add_with_carry_limb(xs[i + xs_offset], ys[i], carry);\n    }\n    carry != 0\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the `xs.len()` least-significant limbs of the sum of the `Natural`s to the\n// first (left) slice. Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_add_n` from `gmp.h`, GMP 6.2.1, where the output is written to the\n// first input.\npub_crate_test! {limbs_slice_add_same_length_in_place_left<T: PrimitiveUnsigned>(\n    xs: &mut [T],\n    ys: &[T],\n) -> bool {\n    let xs_len = xs.len();\n    assert_eq!(xs_len, ys.len());\n    let mut carry = T::ZERO;\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        (*x, carry) = add_with_carry_limb(*x, y, carry);\n    }\n    carry != T::ZERO\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, where the\n// length of the first slice is greater than or equal to the length of the second, writes the\n// `xs.len()` least-significant limbs of the sum of the `Natural`s to the first (left) slice.\n// Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpn_add` from `gmp.h`, GMP 6.2.1, where the first input is at least as\n// long as the second, and the output is written to the first input.\npub_crate_test! {limbs_slice_add_greater_in_place_left(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let (xs_lo, xs_hi) = xs.split_at_mut(ys_len);\n    let carry = limbs_slice_add_same_length_in_place_left(xs_lo, ys);\n    if xs_len == ys_len {\n        carry\n    } else if carry {\n        limbs_slice_add_limb_in_place(xs_hi, 1)\n    } else {\n        false\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s and a slice of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the sum of the `Natural`s to the first (left) slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// This is equivalent to `mpz_add` from `mpz/aors.h`, GMP 6.2.1, where both inputs are non-negative\n// and the output is written to the first input.\npub_crate_test! {limbs_vec_add_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    if core::ptr::eq(xs.as_slice(), ys) {\n        limbs_vec_shl_in_place(xs, 1);\n        return;\n    }\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let carry = if xs_len >= ys_len {\n        limbs_slice_add_greater_in_place_left(xs, ys)\n    } else {\n        let (ys_lo, ys_hi) = ys.split_at(xs_len);\n        let mut carry = limbs_slice_add_same_length_in_place_left(xs, ys_lo);\n        xs.extend_from_slice(ys_hi);\n        if carry {\n            carry = limbs_slice_add_limb_in_place(&mut xs[xs_len..], 1);\n        }\n        carry\n    };\n    if carry {\n        xs.push(1);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `max(xs.len(), ys.len())` least-significant limbs of the sum of the `Natural`s to the longer\n// slice (or the first one, if they are equally long). Returns a pair of `bool`s. The first is\n// `false` when the output is to the first slice and `true` when it's to the second slice, and the\n// second is whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpn_add` from `gmp.h`, GMP 6.2.1, where the output is written to the\n// longer input.\npub_test! {limbs_slice_add_in_place_either(xs: &mut [Limb], ys: &mut [Limb]) -> (bool, bool) {\n    if xs.len() >= ys.len() {\n        (false, limbs_slice_add_greater_in_place_left(xs, ys))\n    } else {\n        (true, limbs_slice_add_greater_in_place_left(ys, xs))\n    }\n}}\n\n// Interpreting two `Vec`s of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the sum of the `Natural`s to the longer slice (or the first one, if they are equally\n// long). Returns a `bool` which is `false` when the output is to the first `Vec` and `true` when\n// it's to the second `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$ (only if the `Vec` reallocates)\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_add` from `mpz/aors.h`, GMP 6.2.1, where both inputs are non-negative\n// and the output is written to the longer input.\npub_test! {limbs_vec_add_in_place_either(xs: &mut Vec<Limb>, ys: &mut Vec<Limb>) -> bool {\n    if xs.len() >= ys.len() {\n        if limbs_slice_add_greater_in_place_left(xs, ys) {\n            xs.push(1);\n        }\n        false\n    } else {\n        if limbs_slice_add_greater_in_place_left(ys, xs) {\n            ys.push(1);\n        }\n        true\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the `xs.len()` least-significant limbs of the sum of the `Natural`s and a\n// carry (`false` is 0, `true` is 1) to an output slice. The output must be at least as long as one\n// of the input slices. Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths or if `out` is too short.\n//\n// This is equivalent to `mpn_add_nc` from `gmp-impl.h`, GMP 6.2.1, where `rp` and `up` are\n// disjoint.\npub_crate_test! {limbs_add_same_length_with_carry_in_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    carry_in: bool,\n) -> bool {\n    let mut carry = limbs_add_same_length_to_out(out, xs, ys);\n    if carry_in {\n        carry |= limbs_slice_add_limb_in_place(&mut out[..xs.len()], 1);\n    }\n    carry\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the `xs.len()` least-significant limbs of the sum of the `Natural`s and a\n// carry (`false` is 0, `true` is 1) to the first (left) slice. Returns whether there is a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_add_nc` from `gmp-impl.h`, GMP 6.2.1, where `rp` is the same as `up`.\npub_crate_test! {limbs_add_same_length_with_carry_in_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    carry_in: bool,\n) -> bool {\n    let mut carry = limbs_slice_add_same_length_in_place_left(xs, ys);\n    if carry_in {\n        carry |= limbs_slice_add_limb_in_place(xs, 1);\n    }\n    carry\n}}\n\nimpl Natural {\n    #[inline]\n    pub(crate) fn add_limb(mut self, other: Limb) -> Self {\n        self.add_assign_limb(other);\n        self\n    }\n\n    pub(crate) fn add_limb_ref(&self, other: Limb) -> Self {\n        match (self, other) {\n            (x, 0) => x.clone(),\n            (Self(Small(small)), other) => match small.overflowing_add(other) {\n                (sum, false) => Self::from(sum),\n                (sum, true) => Self(Large(vec![sum, 1])),\n            },\n            (Self(Large(limbs)), other) => Self(Large(limbs_add_limb(limbs, other))),\n        }\n    }\n\n    fn add_assign_limb(&mut self, other: Limb) {\n        match (&mut *self, other) {\n            (_, 0) => {}\n            (&mut Self::ZERO, _) => *self = Self::from(other),\n            (&mut Self(Small(ref mut small)), other) => {\n                let (sum, overflow) = small.overflowing_add(other);\n                if overflow {\n                    *self = Self(Large(vec![sum, 1]));\n                } else {\n                    *small = sum;\n                }\n            }\n            (&mut Self(Large(ref mut limbs)), other) => {\n                limbs_vec_add_limb_in_place(limbs, other);\n            }\n        }\n    }\n\n    #[cfg(feature = \"float_helpers\")]\n    pub fn add_assign_at_limb(&mut self, i: usize, y: Limb) {\n        if i == 0 {\n            *self += Self::from(y);\n            return;\n        }\n        let xs = self.promote_in_place();\n        if xs.len() <= i {\n            xs.resize(i + 1, 0);\n        }\n        if limbs_slice_add_limb_in_place(&mut xs[i..], y) {\n            xs.push(1);\n        }\n    }\n}\n\nimpl Add<Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO + Natural::from(123u32), 123);\n    /// assert_eq!(Natural::from(123u32) + Natural::ZERO, 123);\n    /// assert_eq!(Natural::from(123u32) + Natural::from(456u32), 579);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) + (Natural::from(10u32).pow(12) << 1),\n    ///     3000000000000u64\n    /// );\n    /// ```\n    fn add(mut self, other: Self) -> Self {\n        self += other;\n        self\n    }\n}\n\nimpl<'a> Add<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s, taking the first by reference and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO + &Natural::from(123u32), 123);\n    /// assert_eq!(Natural::from(123u32) + &Natural::ZERO, 123);\n    /// assert_eq!(Natural::from(123u32) + &Natural::from(456u32), 579);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) + &(Natural::from(10u32).pow(12) << 1),\n    ///     3000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add(mut self, other: &'a Self) -> Self {\n        self += other;\n        self\n    }\n}\n\nimpl Add<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s, taking the first by value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::ZERO + Natural::from(123u32), 123);\n    /// assert_eq!(&Natural::from(123u32) + Natural::ZERO, 123);\n    /// assert_eq!(&Natural::from(123u32) + Natural::from(456u32), 579);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) + (Natural::from(10u32).pow(12) << 1),\n    ///     3000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add(self, mut other: Natural) -> Natural {\n        other += self;\n        other\n    }\n}\n\nimpl Add<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::ZERO + &Natural::from(123u32), 123);\n    /// assert_eq!(&Natural::from(123u32) + &Natural::ZERO, 123);\n    /// assert_eq!(&Natural::from(123u32) + &Natural::from(456u32), 579);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) + &(Natural::from(10u32).pow(12) << 1),\n    ///     3000000000000u64\n    /// );\n    /// ```\n    fn add(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (x, &Natural(Small(y))) => x.add_limb_ref(y),\n            (&Natural(Small(x)), y) => y.add_limb_ref(x),\n            (&Natural(Large(ref xs)), &Natural(Large(ref ys))) => Natural(Large(limbs_add(xs, ys))),\n        }\n    }\n}\n\nimpl AddAssign<Self> for Natural {\n    /// Adds a [`Natural`] to a [`Natural`] in place, taking the [`Natural`] on the right-hand side\n    /// by value.\n    ///\n    /// $$\n    /// x \\gets x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x += Natural::from(10u32).pow(12);\n    /// x += Natural::from(10u32).pow(12) * Natural::from(2u32);\n    /// x += Natural::from(10u32).pow(12) * Natural::from(3u32);\n    /// x += Natural::from(10u32).pow(12) * Natural::from(4u32);\n    /// assert_eq!(x, 10000000000000u64);\n    /// ```\n    fn add_assign(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (x, &mut Self(Small(y))) => x.add_assign_limb(y),\n            (&mut Self(Small(x)), y) => *self = y.add_limb_ref(x),\n            (&mut Self(Large(ref mut xs)), &mut Self(Large(ref mut ys))) => {\n                if limbs_vec_add_in_place_either(xs, ys) {\n                    *self = other;\n                }\n            }\n        }\n    }\n}\n\nimpl<'a> AddAssign<&'a Self> for Natural {\n    /// Adds a [`Natural`] to a [`Natural`] in place, taking the [`Natural`] on the right-hand side\n    /// by reference.\n    ///\n    /// $$\n    /// x \\gets x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x += &Natural::from(10u32).pow(12);\n    /// x += &(Natural::from(10u32).pow(12) * Natural::from(2u32));\n    /// x += &(Natural::from(10u32).pow(12) * Natural::from(3u32));\n    /// x += &(Natural::from(10u32).pow(12) * Natural::from(4u32));\n    /// assert_eq!(x, 10000000000000u64);\n    /// ```\n    fn add_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (x, &Self(Small(y))) => x.add_assign_limb(y),\n            (&mut Self(Small(x)), y) => *self = y.add_limb_ref(x),\n            (&mut Self(Large(ref mut xs)), &Self(Large(ref ys))) => {\n                limbs_vec_add_in_place_left(xs, ys);\n            }\n        }\n    }\n}\n\nimpl Sum for Natural {\n    /// Adds up all the [`Natural`]s in an iterator.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\sum_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Natural::sum(xs.map(Natural::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Sum;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::sum(vec_from_str::<Natural>(\"[2, 3, 5, 7]\").unwrap().into_iter()),\n    ///     17\n    /// );\n    /// ```\n    fn sum<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = Self>,\n    {\n        let mut s = Self::ZERO;\n        for x in xs {\n            s += x;\n        }\n        s\n    }\n}\n\nimpl<'a> Sum<&'a Self> for Natural {\n    /// Adds up all the [`Natural`]s in an iterator of [`Natural`] references.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\sum_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Natural::sum(xs.map(Natural::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Sum;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::sum(vec_from_str::<Natural>(\"[2, 3, 5, 7]\").unwrap().iter()),\n    ///     17\n    /// );\n    /// ```\n    fn sum<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = &'a Self>,\n    {\n        let mut s = Self::ZERO;\n        for x in xs {\n            s += x;\n        }\n        s\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Some optimizations contributed by florian1345.\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1992-1994, 1996, 2000, 2001, 2002, 2004, 2005, 2012, 2016 Free Software\n//      Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_add_greater, limbs_slice_add_greater_in_place_left, limbs_slice_add_limb_in_place,\n};\nuse crate::natural::arithmetic::mul::limb::{limbs_mul_limb_to_out, limbs_slice_mul_limb_in_place};\nuse crate::natural::arithmetic::mul::{limbs_mul_to_out, limbs_mul_to_out_scratch_len};\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{AddMul, AddMulAssign, XMulYToZZ};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{SplitInHalf, WrappingFrom};\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, returns the limbs of x + y * z. `xs`\n// and `ys` should be nonempty and have no trailing zeros, and `z` should be nonzero. The result\n// will have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is positive, and `w` is returned instead of overwriting the first input.\npub_test! {limbs_add_mul_limb(xs: &[Limb], ys: &[Limb], limb: Limb) -> Vec<Limb> {\n    let mut out;\n    if xs.len() >= ys.len() {\n        out = xs.to_vec();\n        limbs_vec_add_mul_limb_greater_in_place_left(&mut out, ys, limb);\n    } else {\n        out = ys.to_vec();\n        limbs_vec_add_mul_limb_smaller_in_place_right(xs, &mut out, limb);\n    }\n    out\n}}\n\n// Given the equal-length limbs of two `Natural`s x and y, and a limb `z`, computes x + y * z. The\n// lowest `xs.len()` limbs of the result are written to `xs`, and the highest limb of y * z, plus\n// the carry-out from the addition, is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_addmul_1` from `mpn/generic/addmul_1.c`, GMP 6.2.1.\npub_crate_test! {limbs_slice_add_mul_limb_same_length_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    z: Limb,\n) -> Limb {\n    let len = xs.len();\n    assert_eq!(ys.len(), len);\n    let mut carry = 0;\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        let (product_hi, mut product_lo) = XMulYToZZ::x_mul_y_to_zz(y, z);\n        product_lo = (*x).wrapping_add(product_lo);\n        let mut add_carry = Limb::from(*x > product_lo);\n        *x = product_lo.wrapping_add(carry);\n        add_carry += Limb::from(product_lo > *x);\n        carry = product_hi.wrapping_add(add_carry);\n    }\n    carry\n}}\n\npub(crate) fn limbs_slice_add_mul_two_limbs_matching_length_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    zs: [Limb; 2],\n) -> Limb {\n    let len = ys.len();\n    assert_eq!(xs.len(), len + 1);\n    let mut carry_hi: Limb = 0;\n    let mut carry_lo: Limb = 0;\n\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        let (mut product_hi, mut product_lo) = XMulYToZZ::x_mul_y_to_zz(y, zs[0]);\n\n        product_lo = (*x).wrapping_add(product_lo);\n        let mut add_carry = Limb::from(*x > product_lo);\n\n        *x = product_lo.wrapping_add(carry_lo);\n        add_carry += Limb::from(product_lo > *x);\n\n        carry_lo = product_hi.wrapping_add(add_carry);\n        carry_lo = carry_hi.wrapping_add(carry_lo);\n        add_carry = Limb::from(carry_hi > carry_lo);\n\n        (product_hi, product_lo) = XMulYToZZ::x_mul_y_to_zz(y, zs[1]);\n        carry_lo = product_lo.wrapping_add(carry_lo);\n        add_carry += Limb::from(product_lo > carry_lo);\n        carry_hi = product_hi.wrapping_add(add_carry);\n    }\n\n    xs[len] = carry_lo;\n\n    carry_hi\n}\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, computes x + y * z. The lowest limbs\n// of the result are written to `ys` and the highest limb is returned. `xs` must have the same\n// length as `ys`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive and have the same lengths, `sub` is positive, the lowest limbs of the result are written\n// to the second input rather than the first, and the highest limb is returned.\npub_test! {limbs_slice_add_mul_limb_same_length_in_place_right(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    z: Limb,\n) -> Limb {\n    let xs_len = xs.len();\n    assert_eq!(ys.len(), xs_len);\n    let mut carry = 0;\n    let dz = DoubleLimb::from(z);\n    for (&x, y) in xs.iter().zip(ys.iter_mut()) {\n        let out = DoubleLimb::from(x) + DoubleLimb::from(*y) * dz + carry;\n        *y = out.lower_half();\n        carry = out >> Limb::WIDTH;\n    }\n    Limb::wrapping_from(carry)\n}}\n\n// Given the limbs of two `Natural`s a and b, and a limb c, writes the limbs of a + b * c to the\n// first (left) input, corresponding to the limbs of a. `xs` and `ys` should be nonempty and have no\n// trailing zeros, and `z` should be nonzero. The result will have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())` and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive and sub is positive.\npub_test! {limbs_vec_add_mul_limb_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb], z: Limb) {\n    let xs_len = xs.len();\n    if xs_len >= ys.len() {\n        limbs_vec_add_mul_limb_greater_in_place_left(xs, ys, z);\n    } else {\n        xs.resize(ys.len(), 0);\n        let (xs_lo, xs_hi) = xs.split_at_mut(xs_len);\n        let (ys_lo, ys_hi) = ys.split_at(xs_len);\n        let mut carry = limbs_mul_limb_to_out::<DoubleLimb, Limb>(xs_hi, ys_hi, z);\n        let inner_carry = limbs_slice_add_mul_limb_same_length_in_place_left(xs_lo, ys_lo, z);\n        if inner_carry != 0 && limbs_slice_add_limb_in_place(xs_hi, inner_carry) {\n            carry += 1;\n        }\n        if carry != 0 {\n            xs.push(carry);\n        }\n    }\n}}\n\n// ys.len() > 0, xs.len() >= ys.len(), z != 0\nfn limbs_vec_add_mul_limb_greater_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb], z: Limb) {\n    let ys_len = ys.len();\n    let carry = limbs_slice_add_mul_limb_same_length_in_place_left(&mut xs[..ys_len], ys, z);\n    if carry != 0 {\n        if xs.len() == ys_len {\n            xs.push(carry);\n        } else if limbs_slice_add_limb_in_place(&mut xs[ys_len..], carry) {\n            xs.push(1);\n        }\n    }\n}\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, writes the limbs of x + y * z to the\n// second (right) input, corresponding to the limbs of y. `xs` and `ys` should be nonempty and have\n// no trailing zeros, and `z` should be nonzero. The result will have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())` and $m$ is `max(1,\n// ys.len() - xs.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is positive, and the result is written to the second input rather than the first.\npub_test! {limbs_vec_add_mul_limb_in_place_right(xs: &[Limb], ys: &mut Vec<Limb>, z: Limb) {\n    let ys_len = ys.len();\n    if xs.len() >= ys_len {\n        let carry = limbs_slice_add_mul_limb_same_length_in_place_right(&xs[..ys_len], ys, z);\n        ys.extend_from_slice(&xs[ys_len..]);\n        if carry != 0 {\n            if xs.len() == ys_len {\n                ys.push(carry);\n            } else if limbs_slice_add_limb_in_place(&mut ys[ys_len..], carry) {\n                ys.push(1);\n            }\n        }\n    } else {\n        limbs_vec_add_mul_limb_smaller_in_place_right(xs, ys, z);\n    }\n}}\n\n// xs.len() > 0, xs.len() < ys.len(), z != 0\nfn limbs_vec_add_mul_limb_smaller_in_place_right(xs: &[Limb], ys: &mut Vec<Limb>, z: Limb) {\n    let (ys_lo, ys_hi) = ys.split_at_mut(xs.len());\n    let mut carry = limbs_slice_mul_limb_in_place(ys_hi, z);\n    let inner_carry = limbs_slice_add_mul_limb_same_length_in_place_right(xs, ys_lo, z);\n    if inner_carry != 0 && limbs_slice_add_limb_in_place(ys_hi, inner_carry) {\n        carry += 1;\n    }\n    if carry != 0 {\n        ys.push(carry);\n    }\n}\n\n// Given the limbs of two `Natural`s x and y, and a limb `z`, writes the limbs of x + y * z to\n// whichever input is longer. If the result is written to the first input, `false` is returned; if\n// to the second, `true` is returned. `xs` and `ys` should be nonempty and have no trailing zeros,\n// and `z` should be nonzero. The result will have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is positive, and the result is written to the longer input.\npub_test! {limbs_vec_add_mul_limb_in_place_either(\n    xs: &mut Vec<Limb>,\n    ys: &mut Vec<Limb>,\n    z: Limb,\n) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_vec_add_mul_limb_greater_in_place_left(xs, ys, z);\n        false\n    } else {\n        limbs_vec_add_mul_limb_smaller_in_place_right(xs, ys, z);\n        true\n    }\n}}\n\n// Given the limbs `xs`, `ys` and `zs` of three `Natural`s x, y, and z, returns the limbs of x + y\n// * z. `xs` should be nonempty and `ys` and `zs` should have length at least 2. None of the slices\n// should have any trailing zeros. The result will have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n, m) = O(m + n \\log n \\log\\log n)$\n//\n// $M(n, m) = O(m + n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(ys.len(), zs.len())`, and $m$ is\n// `xs.len()`.\n//\n// # Panics\n// Panics if `ys` or `zs` are empty.\n//\n// This is equivalent to `mpz_aorsmul` from `mpz/aorsmul.c`, GMP 6.2.1, where `w`, `x`, and `y` are\n// positive, `sub` is positive, and `w` is returned instead of overwriting the first input.\npub_test! {limbs_add_mul(xs: &[Limb], ys: &[Limb], zs: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let mut out_len = ys.len() + zs.len();\n    let mut out = vec![0; out_len];\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(ys.len(), zs.len())];\n    if limbs_mul_to_out(&mut out, ys, zs, &mut mul_scratch) == 0 {\n        out_len -= 1;\n        out.pop();\n    }\n    assert_ne!(*out.last().unwrap(), 0);\n    if xs_len >= out_len {\n        limbs_add_greater(xs, &out)\n    } else {\n        if limbs_slice_add_greater_in_place_left(&mut out, xs) {\n            out.push(1);\n        }\n        out\n    }\n}}\n\n// Given the limbs `xs`, `ys` and `zs` of three `Natural`s x, y, and z, computes x + y * z. The\n// limbs of the result are written to `xs`. `xs` should be nonempty and `ys` and `zs` should have\n// length at least 2. None of the slices should have any trailing zeros. The result will have no\n// trailing zeros.\n//\n// # Worst-case complexity\n// $T(n, m) = O(m + n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(ys.len(), zs.len())`, and $m$ is\n// `xs.len()`.\n//\n// # Panics\n// Panics if `ys` or `zs` are empty.\n//\n// This is equivalent to `mpz_aorsmul` from `mpz/aorsmul.c`, GMP 6.2.1, where `w`, `x`, and `y` are\n// positive and `sub` is positive.\npub_test! {limbs_add_mul_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb], zs: &[Limb]) {\n    let xs_len = xs.len();\n    let mut out_len = ys.len() + zs.len();\n    let mut out = vec![0; out_len];\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(ys.len(), zs.len())];\n    if limbs_mul_to_out(&mut out, ys, zs, &mut mul_scratch) == 0 {\n        out_len -= 1;\n        out.pop();\n    }\n    assert_ne!(*out.last().unwrap(), 0);\n    if xs_len < out_len {\n        swap(xs, &mut out);\n    }\n    if limbs_slice_add_greater_in_place_left(xs, &out) {\n        xs.push(1);\n    }\n}}\n\nimpl Natural {\n    fn add_mul_limb_ref_ref(&self, y: &Self, z: Limb) -> Self {\n        match (self, y, z) {\n            (x, _, 0) | (x, &Self::ZERO, _) => x.clone(),\n            (x, y, 1) => x + y,\n            (x, &Self::ONE, z) => x + Self::from(z),\n            (Self(Large(xs)), Self(Large(ys)), z) => Self(Large(limbs_add_mul_limb(xs, ys, z))),\n            (x, y, z) => x + y * Self::from(z),\n        }\n    }\n\n    fn add_mul_assign_limb(&mut self, mut y: Self, z: Limb) {\n        match (&mut *self, &mut y, z) {\n            (_, _, 0) | (_, &mut Self::ZERO, _) => {}\n            (x, _, 1) => *x += y,\n            (x, &mut Self::ONE, z) => *x += Self::from(z),\n            (Self(Large(xs)), Self(Large(ys)), z) => {\n                if limbs_vec_add_mul_limb_in_place_either(xs, ys, z) {\n                    *self = y;\n                }\n            }\n            (x, _, z) => *x += y * Self::from(z),\n        }\n    }\n\n    fn add_mul_assign_limb_ref(&mut self, y: &Self, z: Limb) {\n        match (&mut *self, y, z) {\n            (_, _, 0) | (_, &Self::ZERO, _) => {}\n            (x, y, 1) => *x += y,\n            (x, &Self::ONE, z) => *x += Self::from(z),\n            (Self(Large(xs)), Self(Large(ys)), z) => {\n                limbs_vec_add_mul_limb_in_place_left(xs, ys, z);\n            }\n            (x, y, z) => *x += y * Self::from(z),\n        }\n    }\n}\n\nimpl AddMul<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Adds a [`Natural`] and the product of two other [`Natural`]s, taking all three by value.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).add_mul(Natural::from(3u32), Natural::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .add_mul(Natural::from(0x10000u32), Natural::from(10u32).pow(12)),\n    ///     65537000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: Self, z: Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a> AddMul<Self, &'a Self> for Natural {\n    type Output = Self;\n\n    /// Adds a [`Natural`] and the product of two other [`Natural`]s, taking the first two by value\n    /// and the third by reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).add_mul(Natural::from(3u32), &Natural::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .add_mul(Natural::from(0x10000u32), &Natural::from(10u32).pow(12)),\n    ///     65537000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: Self, z: &'a Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a> AddMul<&'a Self, Self> for Natural {\n    type Output = Self;\n\n    /// Adds a [`Natural`] and the product of two other [`Natural`]s, taking the first and third by\n    /// value and the second by reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).add_mul(&Natural::from(3u32), Natural::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .add_mul(&Natural::from(0x10000u32), Natural::from(10u32).pow(12)),\n    ///     65537000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: &'a Self, z: Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl<'a, 'b> AddMul<&'a Self, &'b Self> for Natural {\n    type Output = Self;\n\n    /// Adds a [`Natural`] and the product of two other [`Natural`]s, taking the first by value and\n    /// the second and third by reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).add_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .add_mul(&Natural::from(0x10000u32), &Natural::from(10u32).pow(12)),\n    ///     65537000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn add_mul(mut self, y: &'a Self, z: &'b Self) -> Self {\n        self.add_mul_assign(y, z);\n        self\n    }\n}\n\nimpl AddMul<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds a [`Natural`] and the product of two other [`Natural`]s, taking all three by reference.\n    ///\n    /// $f(x, y, z) = x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n, m) = O(m + n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMul, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).add_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     22\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12))\n    ///         .add_mul(&Natural::from(0x10000u32), &Natural::from(10u32).pow(12)),\n    ///     65537000000000000u64\n    /// );\n    /// ```\n    fn add_mul(self, y: &Natural, z: &Natural) -> Natural {\n        match (self, y, z) {\n            (Natural(Small(x)), y, z) => (y * z).add_limb(*x),\n            (x, Natural(Small(y)), z) => x.add_mul_limb_ref_ref(z, *y),\n            (x, y, Natural(Small(z))) => x.add_mul_limb_ref_ref(y, *z),\n            (Natural(Large(xs)), Natural(Large(ys)), Natural(Large(zs))) => {\n                Natural(Large(limbs_add_mul(xs, ys, zs)))\n            }\n        }\n    }\n}\n\nimpl AddMulAssign<Self, Self> for Natural {\n    /// Adds the product of two other [`Natural`]s to a [`Natural`] in place, taking both\n    /// [`Natural`]s on the right-hand side by value.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.add_mul_assign(Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.add_mul_assign(Natural::from(0x10000u32), Natural::from(10u32).pow(12));\n    /// assert_eq!(x, 65537000000000000u64);\n    /// ```\n    fn add_mul_assign(&mut self, mut y: Self, mut z: Self) {\n        match (&mut *self, &mut y, &mut z) {\n            (Self(Small(x)), _, _) => *self = (y * z).add_limb(*x),\n            (_, Self(Small(y)), _) => self.add_mul_assign_limb(z, *y),\n            (_, _, Self(Small(z))) => self.add_mul_assign_limb(y, *z),\n            (Self(Large(xs)), Self(Large(ys)), Self(Large(zs))) => {\n                limbs_add_mul_in_place_left(xs, ys, zs);\n            }\n        }\n    }\n}\n\nimpl<'a> AddMulAssign<Self, &'a Self> for Natural {\n    /// Adds the product of two other [`Natural`]s to a [`Natural`] in place, taking the first\n    /// [`Natural`] on the right-hand side by value and the second by reference.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.add_mul_assign(Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.add_mul_assign(Natural::from(0x10000u32), &Natural::from(10u32).pow(12));\n    /// assert_eq!(x, 65537000000000000u64);\n    /// ```\n    fn add_mul_assign(&mut self, mut y: Self, z: &'a Self) {\n        match (&mut *self, &mut y, z) {\n            (Self(Small(x)), _, _) => *self = (y * z).add_limb(*x),\n            (_, Self(Small(y)), _) => self.add_mul_assign_limb_ref(z, *y),\n            (_, _, Self(Small(z))) => self.add_mul_assign_limb(y, *z),\n            (Self(Large(xs)), Self(Large(ys)), Self(Large(zs))) => {\n                limbs_add_mul_in_place_left(xs, ys, zs);\n            }\n        }\n    }\n}\n\nimpl<'a> AddMulAssign<&'a Self, Self> for Natural {\n    /// Adds the product of two other [`Natural`]s to a [`Natural`] in place, taking the first\n    /// [`Natural`] on the right-hand side by reference and the second by value.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.add_mul_assign(&Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.add_mul_assign(&Natural::from(0x10000u32), Natural::from(10u32).pow(12));\n    /// assert_eq!(x, 65537000000000000u64);\n    /// ```\n    fn add_mul_assign(&mut self, y: &'a Self, mut z: Self) {\n        match (&mut *self, y, &mut z) {\n            (Self(Small(x)), _, _) => *self = (y * z).add_limb(*x),\n            (_, Self(Small(y)), _) => self.add_mul_assign_limb(z, *y),\n            (_, _, Self(Small(z))) => self.add_mul_assign_limb_ref(y, *z),\n            (Self(Large(xs)), Self(Large(ys)), Self(Large(zs))) => {\n                limbs_add_mul_in_place_left(xs, ys, zs);\n            }\n        }\n    }\n}\n\nimpl<'a, 'b> AddMulAssign<&'a Self, &'b Self> for Natural {\n    /// Adds the product of two other [`Natural`]s to a [`Natural`] in place, taking both\n    /// [`Natural`]s on the right-hand side by reference.\n    ///\n    /// $x \\gets x + yz$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{AddMulAssign, Pow};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.add_mul_assign(&Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 22);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.add_mul_assign(&Natural::from(0x10000u32), &Natural::from(10u32).pow(12));\n    /// assert_eq!(x, 65537000000000000u64);\n    /// ```\n    fn add_mul_assign(&mut self, y: &'a Self, z: &'b Self) {\n        match (&mut *self, y, z) {\n            (Self(Small(x)), _, _) => *self = (y * z).add_limb(*x),\n            (_, Self(Small(y)), _) => self.add_mul_assign_limb_ref(z, *y),\n            (_, _, Self(Small(z))) => self.add_mul_assign_limb_ref(y, *z),\n            (Self(Large(xs)), Self(Large(ys)), Self(Large(zs))) => {\n                limbs_add_mul_in_place_left(xs, ys, zs);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Contributed to the GNU project by Torbjörn Granlund and Marco Bodrato.\n//\n//      Copyright © 1998-2012, 2013, 2015-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::div::limbs_hensel_div_limb_in_place;\nuse crate::natural::arithmetic::div_exact::{\n    limbs_modular_div_schoolbook_in_place, limbs_modular_invert_limb,\n};\nuse crate::natural::arithmetic::div_round::double_cmp;\nuse crate::natural::arithmetic::factorial::{bit_to_n, limbs_odd_factorial, log_n_max};\nuse crate::natural::arithmetic::mul::limb::limbs_slice_mul_limb_in_place;\nuse crate::natural::arithmetic::mul::limbs_mul;\nuse crate::natural::arithmetic::mul::product_of_limbs::limbs_product;\nuse crate::natural::arithmetic::neg::limbs_neg_in_place;\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::{\n    CENTRAL_BINOMIAL_2FAC_TABLE, Limb, ODD_CENTRAL_BINOMIAL_OFFSET,\n    ODD_CENTRAL_BINOMIAL_TABLE_LIMIT, ODD_FACTORIAL_EXTTABLE_LIMIT, ODD_FACTORIAL_TABLE_LIMIT,\n    ODD_FACTORIAL_TABLE_MAX, ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE,\n    ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE, ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE,\n    ONE_LIMB_ODD_FACTORIAL_TABLE, TABLE_2N_MINUS_POPC_2N,\n};\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, max, min};\nuse malachite_base::num::arithmetic::traits::{\n    AddMulAssign, BinomialCoefficient, DivAssignMod, DivExact, Parity, PowerOf2, Square,\n    WrappingAddAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::factorization::prime_sieve::limbs_prime_sieve_u32;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse malachite_base::num::factorization::prime_sieve::limbs_prime_sieve_u64;\nuse malachite_base::num::factorization::prime_sieve::{id_to_n, limbs_prime_sieve_size, n_to_bit};\nuse malachite_base::num::logic::traits::{CountOnes, LeadingZeros, SignificantBits};\n\n// This is similar to `mulfunc` from `mpz/bin_uiui.c`, GMP 6.2.1.\nconst fn apply_mul_func(n: Limb, m: Limb) -> Limb {\n    match n {\n        1 => m,\n        2 => (m | 1) * ((m + 1) >> 1),\n        3 => {\n            let m01 = (m * (m + 1)) >> 1;\n            let m2 = m + 2;\n            m01 * m2\n        }\n        4 => {\n            let m03 = (m * (m + 3)) >> 1;\n            m03 * (m03 + 1)\n        }\n        5 => {\n            let m03 = (m * (m + 3)) >> 1;\n            let m034 = m03 * (m + 4);\n            (m03 + 1) * m034\n        }\n        6 => {\n            let m05 = m * (m + 5);\n            let m1234 = ((m05 + 5) * (m05 + 5)) >> 3;\n            m1234 * (m05 >> 1)\n        }\n        7 => {\n            let m05 = m * (m + 5);\n            let m1234 = ((m05 + 5) * (m05 + 5)) >> 3;\n            let m056 = (m05 * (m + 6)) >> 1;\n            m1234 * m056\n        }\n        8 => {\n            let m07 = m * (m + 7);\n            let m0257 = (m07 * (m07 + 10)) >> 3;\n            let m1346 = m07 + 9 + m0257;\n            m0257 * m1346\n        }\n        _ => panic!(),\n    }\n}\n\nconst M: Limb = 8;\n\nconst SOME_THRESHOLD: usize = 20;\n\n// This is equivalent to `mpz_bdiv_bin_uiui` from `mpz/bin_uiui.c`, GMP 6.2.1, where a `Vec` of\n// limbs is returned.\npub_test! {limbs_binomial_coefficient_limb_limb_bdiv(n: Limb, k: Limb) -> Vec<Limb> {\n    assert!(k > Limb::wrapping_from(ODD_FACTORIAL_TABLE_LIMIT));\n    let max_n = 1 + usize::exact_from(n >> Limb::LOG_WIDTH);\n    let alloc = min(\n        SOME_THRESHOLD - 1 + max((3 * max_n) >> 1, SOME_THRESHOLD),\n        usize::exact_from(k),\n    ) + 1;\n    let mut big_scratch = vec![0; alloc + SOME_THRESHOLD + 1];\n    let (ns, ks) = big_scratch.split_at_mut(alloc);\n    let n_max = Limb::wrapping_from(log_n_max(n));\n    assert!(n_max <= M);\n    let mut k_max = Limb::wrapping_from(log_n_max(k));\n    assert!(k_max <= M);\n    assert!(k >= M);\n    assert!(n >= k);\n    let mut i = n - k + 1;\n    ns[0] = 1;\n    let mut n_len = 1;\n    let mut num_fac = 1;\n    let mut j = Limb::wrapping_from(ODD_FACTORIAL_TABLE_LIMIT + 1);\n    let mut jjj = ODD_FACTORIAL_TABLE_MAX;\n    assert_eq!(\n        ONE_LIMB_ODD_FACTORIAL_TABLE[ODD_FACTORIAL_TABLE_LIMIT],\n        ODD_FACTORIAL_TABLE_MAX\n    );\n    loop {\n        ks[0] = jjj;\n        let mut k_len = 1;\n        let mut t = k + 1 - j;\n        k_max = min(k_max, t);\n        while k_max != 0 && k_len < SOME_THRESHOLD {\n            jjj = apply_mul_func(k_max, j);\n            j += k_max;\n            jjj >>= jjj.trailing_zeros();\n            let cy = limbs_slice_mul_limb_in_place(&mut ks[..k_len], jjj);\n            ks[k_len] = cy;\n            if cy != 0 {\n                k_len += 1;\n            }\n            t = k + 1 - j;\n            k_max = min(k_max, t);\n        }\n        num_fac = j - num_fac;\n        while num_fac != 0 {\n            let n_max_now = min(n_max, num_fac);\n            let mut iii = apply_mul_func(n_max_now, i);\n            i.wrapping_add_assign(n_max_now);\n            iii >>= iii.trailing_zeros();\n            let carry = limbs_slice_mul_limb_in_place(&mut ns[..n_len], iii);\n            ns[n_len] = carry;\n            if carry != 0 {\n                n_len += 1;\n            }\n            num_fac -= n_max_now;\n        }\n        if ns[n_len - 1] >= ks[k_len - 1] {\n            n_len += 1;\n        }\n        n_len -= k_len;\n        let d_inv = limbs_modular_invert_limb(ks[0]);\n        limbs_modular_div_schoolbook_in_place(ns, &ks[..min(k_len, n_len)], d_inv.wrapping_neg());\n        limbs_neg_in_place(&mut ns[..n_len]);\n        if k_max == 0 {\n            break;\n        }\n        num_fac = j;\n        jjj = apply_mul_func(k_max, j);\n        j += k_max;\n        jjj >>= jjj.trailing_zeros();\n    }\n    // Put back the right number of factors of 2.\n    let ones = CountOnes::count_ones(n - k) + CountOnes::count_ones(k) - CountOnes::count_ones(n);\n    if ones != 0 {\n        assert!(ones < Limb::WIDTH);\n        let carry = limbs_slice_shl_in_place(&mut ns[..n_len], ones);\n        ns[n_len] = carry;\n        if carry != 0 {\n            n_len += 1;\n        }\n    }\n    if ns[n_len - 1] == 0 {\n        n_len -= 1;\n    }\n    let mut ns = big_scratch;\n    ns.truncate(n_len);\n    ns\n}}\n\n// Number of factors-of-2 removed by the corresponding mulN function.\n//\n// This is equivalent to `tcnttab` from `mpz/bin_uiui.c`, GMP 6.2.1.\nconst TCNT_TAB: [u8; 8] = [0, 1, 1, 2, 2, 4, 4, 6];\n\n// This is equivalent to `mpz_smallk_bin_uiui` from `mpz/bin_uiui.c`, GMP 6.2.1, where a `Vec` of\n// limbs is returned.\npub_test! {limbs_binomial_coefficient_limb_limb_small_k(n: Limb, k: Limb) -> Vec<Limb> {\n    let n_max = Limb::wrapping_from(log_n_max(n));\n    let mut n_max = min(n_max, M);\n    let mut i = n - k + 1;\n    let k_u = usize::exact_from(k);\n    assert!(k_u <= ODD_FACTORIAL_TABLE_LIMIT);\n    let mut i2_count = TABLE_2N_MINUS_POPC_2N[(k_u >> 1) - 1];\n    let factorial_inverse = ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE[k_u - 2];\n    if n_max >= k {\n        return vec![\n            (apply_mul_func(k, i).wrapping_mul(factorial_inverse))\n                >> (i2_count - TCNT_TAB[k_u - 1]),\n        ];\n    }\n    let alloc =\n        bit_to_limb_count_floor(n.significant_bits() * u64::exact_from(k)) + 3;\n    let mut out = vec![0; alloc];\n    out[0] = apply_mul_func(n_max, i);\n    let mut out_len = 1;\n    i += n_max;\n    i2_count -= TCNT_TAB[usize::exact_from(n_max - 1)];\n    let mut num_fac = k - n_max;\n    while num_fac != 0 {\n        n_max = min(n_max, num_fac);\n        let iii = apply_mul_func(n_max, i);\n        i.wrapping_add_assign(n_max);\n        i2_count -= TCNT_TAB[usize::exact_from(n_max - 1)];\n        let carry = limbs_slice_mul_limb_in_place(&mut out[..out_len], iii);\n        out[out_len] = carry;\n        if carry != 0 {\n            out_len += 1;\n        }\n        num_fac -= n_max;\n    }\n    assert!(out_len < alloc);\n    limbs_hensel_div_limb_in_place(\n        &mut out[..out_len],\n        ONE_LIMB_ODD_FACTORIAL_TABLE[k_u],\n        factorial_inverse,\n        u64::from(i2_count),\n    );\n    while *out.last().unwrap() == 0 {\n        out.pop();\n    }\n    out\n}}\n\n// Tabulate factorials (k!/2^t)^(-1) mod B (where t is chosen such that k!/2^t is odd).\n//\n// This is equivalent to `bc_bin_uiui` from `mpz/bin_uiui.c`, GMP 6.2.1, where a single limb is\n// returned.\npub_test! {limbs_binomial_coefficient_limb_limb_basecase(n: Limb, k: Limb) -> Limb {\n    assert!(n <= ODD_FACTORIAL_EXTTABLE_LIMIT as Limb);\n    assert!(n >= k + 2);\n    assert!(k >= 2);\n    let n = usize::wrapping_from(n);\n    let k = usize::wrapping_from(k);\n    let diff = n - k;\n    (ONE_LIMB_ODD_FACTORIAL_TABLE[n]\n        .wrapping_mul(ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE[k - 2])\n        .wrapping_mul(ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE[diff - 2]))\n        << (TABLE_2N_MINUS_POPC_2N[(n >> 1) - 1]\n            - TABLE_2N_MINUS_POPC_2N[(k >> 1) - 1]\n            - TABLE_2N_MINUS_POPC_2N[(diff >> 1) - 1])\n}}\n\npub(crate) const BIN_UIUI_RECURSIVE_SMALLDC: bool = Limb::WIDTH > u32::WIDTH;\n\n// Recursively exploit the relation bin(n, k) = bin(n, k >> 1) * bin(n - k >> 1, k - k >> 1) /\n// bin(k, k >> 1).\n//\n// Values for binomial(k, k >> 1) that fit in a limb are precomputed (with inverses).\n//\n// This is equivalent to `mpz_smallkdc_bin_uiui` from `mpz/bin_uiui.c`, GMP 6.2.1, where a `Vec` of\n// limbs is returned.\npub_test! {limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(\n    mut n: Limb,\n    mut k: Limb,\n) -> Vec<Limb> {\n    let half_k = k >> 1;\n    let mut out = if !BIN_UIUI_RECURSIVE_SMALLDC || half_k <= ODD_FACTORIAL_TABLE_LIMIT as Limb {\n        limbs_binomial_coefficient_limb_limb_small_k(n, half_k)\n    } else {\n        limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(n, half_k)\n    };\n    k -= half_k;\n    n -= half_k;\n    let mut out_len = out.len();\n    if n <= ODD_FACTORIAL_EXTTABLE_LIMIT as Limb {\n        out.push(0);\n        let carry = limbs_slice_mul_limb_in_place(\n            &mut out[..out_len],\n            limbs_binomial_coefficient_limb_limb_basecase(n, k),\n        );\n        out[out_len] = carry;\n        if carry != 0 {\n            out_len += 1;\n        }\n    } else {\n        let t = if !BIN_UIUI_RECURSIVE_SMALLDC || k <= ODD_FACTORIAL_TABLE_LIMIT as Limb {\n            limbs_binomial_coefficient_limb_limb_small_k(n, k)\n        } else {\n            limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(n, k)\n        };\n        let out_copy = out[..out_len].to_vec();\n        out = limbs_mul(&out_copy, &t);\n        out_len = out.len();\n    }\n    let k_u = usize::exact_from(k);\n    let mut shift = CENTRAL_BINOMIAL_2FAC_TABLE[k_u - ODD_CENTRAL_BINOMIAL_OFFSET];\n    if k != half_k {\n        // k was odd\n        shift -= 1;\n    }\n    let k_offset = k_u - ODD_CENTRAL_BINOMIAL_OFFSET;\n    limbs_hensel_div_limb_in_place(\n        &mut out[..out_len],\n        ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE[k_offset],\n        ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE[k_offset],\n        shift,\n    );\n    while *out.last().unwrap() == 0 {\n        out.pop();\n    }\n    out\n}}\n\n// Returns an approximation of the square root of x. It gives:\n// ```\n//   limb_apprsqrt (x) ^ 2 <= x < (limb_apprsqrt (x)+1) ^ 2\n// ```\n// or\n// ```\n// x <= limb_apprsqrt (x) ^ 2 <= x * 9/8\n// ```\nfn limbs_approx_sqrt(x: Limb) -> Limb {\n    assert!(x > 2);\n    let s = (Limb::WIDTH - LeadingZeros::leading_zeros(x)) >> 1;\n    (Limb::power_of_2(s) + (x >> s)) >> 1\n}\n\npub(crate) const BIN_GOETGHELUCK_THRESHOLD: Limb = 512;\n\n// Implementation of the algorithm by P. Goetgheluck, \"Computing Binomial Coefficients\", The\n// American Mathematical Monthly, Vol. 94, No. 4 (April 1987), pp. 360-365.\n//\n// This is equivalent to `mpz_goetgheluck_bin_uiui` from `mpz/bin_uiui.c`, GMP 6.2.1, where a `Vec`\n// of limbs is returned.\npub_test! {\n#[allow(clippy::useless_conversion)]\nlimbs_binomial_coefficient_limb_limb_goetgheluck(n: Limb, k: Limb) -> Vec<Limb> {\n    assert!(BIN_GOETGHELUCK_THRESHOLD >= 13);\n    assert!(n >= 25);\n    let n_64 = u64::from(n);\n    let k_64 = u64::from(k);\n    let mut sieve = vec![0; limbs_prime_sieve_size::<Limb>(n_64)];\n    #[cfg(feature = \"32_bit_limbs\")]\n    let count = limbs_prime_sieve_u32(&mut sieve, n_64) + 1;\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    let count = limbs_prime_sieve_u64(&mut sieve, n) + 1;\n    let mut factors = vec![0; usize::exact_from(count / log_n_max(n) + 1)];\n    let mut max_prod = Limb::MAX / n;\n    // Handle primes = 2, 3 separately.\n    let mut prod = Limb::power_of_2(\n        CountOnes::count_ones(n - k) + CountOnes::count_ones(k) - CountOnes::count_ones(n),\n    );\n    let mut j = 0;\n    let mut a = n;\n    let mut b = k;\n    let mut mb = 0;\n    if prod > max_prod {\n        // would only happen for very large outputs\n        factors[j] = prod;\n        j += 1;\n        prod = 1;\n    }\n    while a >= 3 {\n        mb += b.div_assign_mod(3);\n        let ma = a.div_assign_mod(3);\n        if ma < mb {\n            mb = 1;\n            prod *= 3;\n        } else {\n            mb = 0;\n        }\n    }\n    // Accumulate prime factors from 5 to n / 2\n    let s = n_to_bit(u64::from(limbs_approx_sqrt(n)));\n    assert!(bit_to_n(s + 1).square() > n_64);\n    let half_n_bit = n_to_bit(n_64 >> 1);\n    assert!(s <= half_n_bit);\n    let mut index = 0;\n    let mut mask = 1;\n    for i in 1..=s + 1 {\n        if sieve[index] & mask == 0 {\n            let prime = Limb::exact_from(id_to_n(i));\n            let mut a = n;\n            let mut b = k;\n            let mut mb = 0;\n            if prod > max_prod {\n                factors[j] = prod;\n                j += 1;\n                prod = 1;\n            }\n            while a >= prime {\n                mb += b.div_assign_mod(prime);\n                let ma = a.div_assign_mod(prime);\n                if ma < mb {\n                    mb = 1;\n                    prod *= prime;\n                } else {\n                    mb = 0;\n                }\n            }\n        }\n        mask <<= 1;\n        if mask == 0 {\n            mask = 1;\n            index += 1;\n        }\n    }\n    assert!(max_prod <= Limb::MAX >> 1);\n    max_prod <<= 1;\n    for i in s + 2..=half_n_bit + 1 {\n        if sieve[index] & mask == 0 {\n            let prime = Limb::exact_from(id_to_n(i));\n            if n % prime < k % prime {\n                if prod > max_prod {\n                    factors[j] = prod;\n                    j += 1;\n                    prod = prime;\n                } else {\n                    prod *= prime;\n                }\n            }\n        }\n        mask <<= 1;\n        if mask == 0 {\n            mask = 1;\n            index += 1;\n        }\n    }\n    max_prod >>= 1;\n    // Store primes from (n-k)+1 to n\n    let n_bit = n_to_bit(n_64);\n    let n_minus_k_bit = n_to_bit(n_64 - k_64);\n    assert!(n_minus_k_bit < n_bit);\n    let i = n_minus_k_bit + 1;\n    let mut index = bit_to_limb_count_floor(i);\n    let mut mask = Limb::power_of_2(i & Limb::WIDTH_MASK);\n    for i in i + 1..=n_bit + 1 {\n        if sieve[index] & mask == 0 {\n            let prime = Limb::exact_from(id_to_n(i));\n            if prod > max_prod {\n                factors[j] = prod;\n                j += 1;\n                prod = prime;\n            } else {\n                prod *= prime;\n            }\n        }\n        mask <<= 1;\n        if mask == 0 {\n            mask = 1;\n            index += 1;\n        }\n    }\n    assert_ne!(j, 0);\n    factors[j] = Limb::wrapping_from(prod);\n    j += 1;\n    let mut r = Vec::new();\n    let (size, new_r) = limbs_product(&mut r, &mut factors[..j]);\n    r = new_r.unwrap();\n    r.truncate(size);\n    r\n}}\n\nconst BIN_UIUI_ENABLE_SMALLDC: bool = true;\n\n// This is equivalent to `mpz_bin_uiui` from `mpz/bin_uiui.c`, GMP 6.2.1, where a `Natural` is\n// returned.\npub_test! {binomial_coefficient_limb_limb(n: Limb, mut k: Limb) -> Natural {\n    if n < k {\n        Natural::ZERO\n    } else {\n        // Rewrite bin(n, k) as bin(n, n - k) if that is smaller.\n        k = min(k, n - k);\n        if k == 0 {\n            Natural::ONE\n        } else if k == 1 {\n            Natural::from(n)\n        } else if n <= ODD_FACTORIAL_EXTTABLE_LIMIT as Limb {\n            // k >= 2, n >= 4\n            Natural::from(limbs_binomial_coefficient_limb_limb_basecase(n, k))\n        } else if k <= ODD_FACTORIAL_TABLE_LIMIT as Limb {\n            Natural::from_owned_limbs_asc(limbs_binomial_coefficient_limb_limb_small_k(n, k))\n        } else if BIN_UIUI_ENABLE_SMALLDC\n            && k <= (if BIN_UIUI_RECURSIVE_SMALLDC {\n                ODD_CENTRAL_BINOMIAL_TABLE_LIMIT\n            } else {\n                ODD_FACTORIAL_TABLE_LIMIT\n            } as Limb)\n                << 1\n        {\n            Natural::from_owned_limbs_asc(\n                limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(n, k),\n            )\n        } else if k >= BIN_GOETGHELUCK_THRESHOLD && k > n >> 4 {\n            // k > ODD_FACTORIAL_TABLE_LIMIT\n            Natural::from_owned_limbs_asc(limbs_binomial_coefficient_limb_limb_goetgheluck(n, k))\n        } else {\n            Natural::from_owned_limbs_asc(limbs_binomial_coefficient_limb_limb_bdiv(n, k))\n        }\n    }\n}}\n\n// Computes r = n * (n + (2 * k - 1)) / 2.\n//\n// It uses a square instead of a product, computing r = ((n + k - 1) ^ 2 + n - (k - 1) ^ 2) / 2 As a\n// side effect, sets t = n + k - 1.\n//\n// This is equivalent to `mpz_hmul_nbnpk` from `mpz/bin_ui.c`, GMP 6.2.1.\nfn binomial_coefficient_hmul_nbnpk(n: &Natural, mut k: Limb) -> Natural {\n    assert_ne!(k, 0);\n    assert_ne!(*n, 0u32);\n    k -= 1;\n    (((n + Natural::from(k)).square() + n) >> 1u32)\n        - Natural::from(k + (k & 1)) * Natural::from(k >> 1)\n}\n\n// This is equivalent to `rek_raising_fac4` from `mpz/bin_ui.c`, GMP 6.2.1.\nfn binomial_coefficient_raising_factorial_4_rec(\n    r: &mut Natural,\n    p: &mut Natural,\n    big_p: &mut Natural,\n    k: Limb,\n    lk: Limb,\n) {\n    assert!(k >= lk);\n    if k - lk < 5 {\n        for i in (lk + 1..=k).rev() {\n            let four_i = i << 2;\n            *p += Natural::from(four_i + 2);\n            big_p.add_mul_assign(&*p, Natural::from(four_i));\n            *big_p -= Natural::from(i);\n            *r *= &*big_p;\n        }\n    } else {\n        let m = ((k + lk) >> 1) + 1;\n        binomial_coefficient_raising_factorial_4_rec(r, p, big_p, k, m);\n        let four_m = m << 2;\n        *p += Natural::from(four_m + 2);\n        big_p.add_mul_assign(&*p, Natural::from(four_m));\n        *big_p -= Natural::from(m);\n        let mut t = big_p.clone();\n        binomial_coefficient_raising_factorial_4_rec(&mut t, p, big_p, m - 1, lk);\n        *r *= t;\n    }\n}\n\n// This is equivalent to `mpz_raising_fac4` from `mpz/bin_ui.c`, GMP 6.2.1, where r is returned.\nfn binomial_coefficient_raising_factorial_4(mut n: Natural, mut k: Limb) -> Natural {\n    assert!(k >= 2);\n    n += Natural::ONE;\n    let mut r = Natural::ZERO;\n    if k.odd() {\n        r = n.clone();\n        n += Natural::ONE;\n    }\n    k >>= 1;\n    let mut p = binomial_coefficient_hmul_nbnpk(&n, k);\n    if k.odd() {\n        if r != 0u32 {\n            r *= &p;\n        } else {\n            r = p.clone();\n        }\n        p += Natural::from(k - 1);\n    }\n    k >>= 1;\n    if k == 0 {\n        return r;\n    }\n    let mut t = binomial_coefficient_hmul_nbnpk(&p, k);\n    if r != 0u32 {\n        r *= &t;\n    } else {\n        r = t.clone();\n    }\n    if k > 1 {\n        p -= Natural::from(k);\n        binomial_coefficient_raising_factorial_4_rec(&mut r, &mut p, &mut t, k - 1, 0);\n    }\n    r\n}\n\n// This is equivalent to `mpz_bin_ui` from `mpz/bin_ui.c`, GMP 6.2.1, where n is non-negative, n >=\n// k, k <= n - k, and r is returned.\nfn binomial_coefficient_helper(n: Natural, k: Limb) -> Natural {\n    assert_ne!(k, 0);\n    if k < 2 {\n        n\n    } else if let Ok(small_n) = Limb::try_from(&n) {\n        binomial_coefficient_limb_limb(small_n, k)\n    } else {\n        (binomial_coefficient_raising_factorial_4(n - Natural::from(k), k)\n            >> (k - (k >> 1) - (k >> 2))\n                .checked_sub(Limb::wrapping_from(CountOnes::count_ones(k)))\n                .unwrap())\n        .div_exact(Natural::from_owned_limbs_asc(limbs_odd_factorial(\n            usize::exact_from(k),\n            false,\n        )))\n    }\n}\n\nimpl BinomialCoefficient for Natural {\n    /// Computes the binomial coefficient of two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(n, k) =binom{n}{k} =frac{n!}{k!(n-k)!}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// TODO\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::BinomialCoefficient;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(Natural::from(4u32), Natural::from(0u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(Natural::from(4u32), Natural::from(1u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(Natural::from(4u32), Natural::from(2u32)),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(Natural::from(4u32), Natural::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(Natural::from(4u32), Natural::from(4u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(Natural::from(10u32), Natural::from(5u32)),\n    ///     252\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(Natural::from(100u32), Natural::from(50u32)).to_string(),\n    ///     \"100891344545564193334812497256\"\n    /// );\n    /// ```\n    fn binomial_coefficient(n: Self, mut k: Self) -> Self {\n        if k > n {\n            return Self::ZERO;\n        }\n        if k == 0u32 || n == k {\n            return Self::ONE;\n        }\n        if double_cmp(&k, &n) == Greater {\n            k = &n - &k;\n        }\n        binomial_coefficient_helper(n, Limb::try_from(&k).expect(\"k is too large\"))\n    }\n}\n\nimpl<'a> BinomialCoefficient<&'a Self> for Natural {\n    /// Computes the binomial coefficient of two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(n, k) =binom{n}{k} =frac{n!}{k!(n-k)!}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// TODO\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::BinomialCoefficient;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(&Natural::from(4u32), &Natural::from(0u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(&Natural::from(4u32), &Natural::from(1u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(&Natural::from(4u32), &Natural::from(2u32)),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(&Natural::from(4u32), &Natural::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(&Natural::from(4u32), &Natural::from(4u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(&Natural::from(10u32), &Natural::from(5u32)),\n    ///     252\n    /// );\n    /// assert_eq!(\n    ///     Natural::binomial_coefficient(&Natural::from(100u32), &Natural::from(50u32))\n    ///         .to_string(),\n    ///     \"100891344545564193334812497256\"\n    /// );\n    /// ```\n    fn binomial_coefficient(n: &'a Self, k: &'a Self) -> Self {\n        if k > n {\n            return Self::ZERO;\n        }\n        if *k == 0u32 || n == k {\n            return Self::ONE;\n        }\n        let k = if double_cmp(k, n) == Greater {\n            Limb::try_from(&(n - k))\n        } else {\n            Limb::try_from(k)\n        }\n        .expect(\"k is too large\");\n        binomial_coefficient_helper(n.clone(), k)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/checked_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub, limbs_sub_greater_in_place_left, limbs_sub_limb, limbs_sub_limb_in_place,\n    limbs_vec_sub_in_place_right,\n};\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::CheckedSub;\nuse malachite_base::num::basic::traits::Zero;\n\nimpl Natural {\n    pub(crate) fn checked_sub_limb(mut self, other: Limb) -> Option<Self> {\n        if self.sub_assign_limb_no_panic(other) {\n            None\n        } else {\n            Some(self)\n        }\n    }\n\n    pub(crate) fn checked_sub_limb_ref(&self, other: Limb) -> Option<Self> {\n        match (self, other) {\n            (_, 0) => Some(self.clone()),\n            (Self(Small(small)), other) => small.checked_sub(other).map(Self::from),\n            (Self(Large(limbs)), other) => {\n                if *self < other {\n                    None\n                } else {\n                    Some(Self::from_owned_limbs_asc(limbs_sub_limb(limbs, other).0))\n                }\n            }\n        }\n    }\n\n    // self -= other, return borrow\n    fn sub_assign_limb_no_panic(&mut self, other: Limb) -> bool {\n        match (&mut *self, other) {\n            (_, 0) => false,\n            (Self(Small(x)), y) => match x.checked_sub(y) {\n                Some(diff) => {\n                    *x = diff;\n                    false\n                }\n                None => true,\n            },\n            (Self(Large(xs)), y) => {\n                let borrow = limbs_sub_limb_in_place(xs, y);\n                if !borrow {\n                    self.trim();\n                }\n                borrow\n            }\n        }\n    }\n\n    // self -= other, return borrow\n    pub(crate) fn sub_assign_no_panic(&mut self, other: Self) -> bool {\n        match (&mut *self, other) {\n            (_, Self::ZERO) => false,\n            (x, Self(Small(y))) => x.sub_assign_limb_no_panic(y),\n            (Self(Small(_)), _) => true,\n            (&mut Self(Large(ref mut xs)), Self(Large(ys))) => {\n                let borrow = xs.len() < ys.len() || limbs_sub_greater_in_place_left(xs, &ys);\n                if !borrow {\n                    self.trim();\n                }\n                borrow\n            }\n        }\n    }\n\n    // self -= &other, return borrow\n    pub(crate) fn sub_assign_ref_no_panic(&mut self, other: &Self) -> bool {\n        match (&mut *self, other) {\n            (_, &Self::ZERO) => false,\n            (x, y) if core::ptr::eq(&*x, y) => {\n                *self = Self::ZERO;\n                false\n            }\n            (x, &Self(Small(y))) => x.sub_assign_limb_no_panic(y),\n            (Self(Small(_)), _) => true,\n            (Self(Large(xs)), &Self(Large(ref ys))) => {\n                let borrow = xs.len() < ys.len() || limbs_sub_greater_in_place_left(xs, ys);\n                if !borrow {\n                    self.trim();\n                }\n                borrow\n            }\n        }\n    }\n\n    // self = &other - self, return borrow\n    pub(crate) fn sub_right_assign_no_panic(&mut self, other: &Self) -> bool {\n        match (&mut *self, other) {\n            (&mut Self::ZERO, y) => {\n                *self = y.clone();\n                false\n            }\n            (x, y) if core::ptr::eq(x, y) => {\n                *self = Self::ZERO;\n                false\n            }\n            (Self(Small(x)), y) => y.checked_sub_limb_ref(*x).is_none_or(|result| {\n                *self = result;\n                false\n            }),\n            (_, Self(Small(_))) => true,\n            (Self(Large(xs)), Self(Large(ys))) => {\n                let borrow = xs.len() > ys.len() || limbs_vec_sub_in_place_right(ys, xs);\n                if !borrow {\n                    self.trim();\n                }\n                borrow\n            }\n        }\n    }\n}\n\nimpl CheckedSub<Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking both by value and returning `None` if\n    /// the result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - y) & \\text{if} \\\\quad x \\geq y, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSub, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO\n    ///         .checked_sub(Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(123u32)\n    ///         .checked_sub(Natural::ZERO)\n    ///         .to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(456u32)\n    ///         .checked_sub(Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"Some(333)\"\n    /// );\n    /// assert_eq!(\n    ///     (Natural::from(10u32).pow(12) * Natural::from(3u32))\n    ///         .checked_sub(Natural::from(10u32).pow(12))\n    ///         .to_debug_string(),\n    ///     \"Some(2000000000000)\"\n    /// );\n    /// ```\n    fn checked_sub(mut self, other: Self) -> Option<Self> {\n        if self.sub_assign_no_panic(other) {\n            None\n        } else {\n            Some(self)\n        }\n    }\n}\n\nimpl<'a> CheckedSub<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and returning `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - y) & \\text{if} \\\\quad x \\geq y, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSub, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO\n    ///         .checked_sub(&Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(123u32)\n    ///         .checked_sub(&Natural::ZERO)\n    ///         .to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(456u32)\n    ///         .checked_sub(&Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"Some(333)\"\n    /// );\n    /// assert_eq!(\n    ///     (Natural::from(10u32).pow(12) * Natural::from(3u32))\n    ///         .checked_sub(&Natural::from(10u32).pow(12))\n    ///         .to_debug_string(),\n    ///     \"Some(2000000000000)\"\n    /// );\n    /// ```\n    fn checked_sub(mut self, other: &'a Self) -> Option<Self> {\n        if self.sub_assign_ref_no_panic(other) {\n            None\n        } else {\n            Some(self)\n        }\n    }\n}\n\nimpl CheckedSub<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and returning `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - y) & \\text{if} \\\\quad x \\geq y, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSub, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO)\n    ///         .checked_sub(Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(123u32))\n    ///         .checked_sub(Natural::ZERO)\n    ///         .to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(456u32))\n    ///         .checked_sub(Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"Some(333)\"\n    /// );\n    /// assert_eq!(\n    ///     (&(Natural::from(10u32).pow(12) * Natural::from(3u32)))\n    ///         .checked_sub(Natural::from(10u32).pow(12))\n    ///         .to_debug_string(),\n    ///     \"Some(2000000000000)\"\n    /// );\n    /// ```\n    fn checked_sub(self, mut other: Natural) -> Option<Natural> {\n        if other.sub_right_assign_no_panic(self) {\n            None\n        } else {\n            Some(other)\n        }\n    }\n}\n\nimpl CheckedSub<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking both by reference and returning\n    /// `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - y) & \\text{if} \\\\quad x \\geq y, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSub, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO)\n    ///         .checked_sub(&Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(123u32))\n    ///         .checked_sub(&Natural::ZERO)\n    ///         .to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(456u32))\n    ///         .checked_sub(&Natural::from(123u32))\n    ///         .to_debug_string(),\n    ///     \"Some(333)\"\n    /// );\n    /// assert_eq!(\n    ///     (&(Natural::from(10u32).pow(12) * Natural::from(3u32)))\n    ///         .checked_sub(&Natural::from(10u32).pow(12))\n    ///         .to_debug_string(),\n    ///     \"Some(2000000000000)\"\n    /// );\n    /// ```\n    fn checked_sub(self, other: &Natural) -> Option<Natural> {\n        match (self, other) {\n            (x, y) if core::ptr::eq(x, y) => Some(Natural::ZERO),\n            (x, &Natural::ZERO) => Some(x.clone()),\n            (x, &Natural(Small(y))) => x.checked_sub_limb_ref(y),\n            (Natural(Small(_)), _) => None,\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if self < other {\n                    None\n                } else {\n                    Some(Natural::from_owned_limbs_asc(limbs_sub(xs, ys).0))\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/checked_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::sub_mul::{\n    limbs_sub_mul, limbs_sub_mul_in_place_left, limbs_sub_mul_limb_greater,\n    limbs_sub_mul_limb_greater_in_place_left,\n};\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{CheckedSub, CheckedSubMul};\nuse malachite_base::num::basic::traits::Zero;\n\nmacro_rules! large_left {\n    ($a_limbs: ident, $b_limbs: ident, $c_limbs: ident) => {\n        (\n            Natural(Large($a_limbs)),\n            Natural(Large($b_limbs)),\n            Natural(Large($c_limbs)),\n        )\n    };\n}\n\nmacro_rules! large_right {\n    ($self: ident, $a_limbs: ident, $b_limbs: ident, $c_limbs: ident) => {{\n        let borrow = $a_limbs.len() < $b_limbs.len() + $c_limbs.len() - 1\n            || limbs_sub_mul_in_place_left($a_limbs, &$b_limbs, &$c_limbs);\n        if !borrow {\n            $self.trim();\n        }\n        borrow\n    }};\n}\n\nimpl Natural {\n    fn checked_sub_mul_limb_ref_ref(&self, b: &Self, c: Limb) -> Option<Self> {\n        match (self, b, c) {\n            (a, _, 0) | (a, &Self::ZERO, _) => Some(a.clone()),\n            (a, b @ Self(Small(_)), c) => a.checked_sub(b * Self::from(c)),\n            (Self(Small(_)), _, _) => None,\n            (Self(Large(a_limbs)), Self(Large(b_limbs)), c) => {\n                if a_limbs.len() >= b_limbs.len() {\n                    limbs_sub_mul_limb_greater(a_limbs, b_limbs, c).map(Self::from_owned_limbs_asc)\n                } else {\n                    None\n                }\n            }\n        }\n    }\n\n    fn sub_mul_assign_limb_no_panic(&mut self, b: Self, c: Limb) -> bool {\n        match (&mut *self, b, c) {\n            (_, _, 0) | (_, Self::ZERO, _) => false,\n            (a, b @ Self(Small(_)), c) => a.sub_assign_no_panic(b * Self::from(c)),\n            (Self(Small(_)), _, _) => true,\n            (Self(Large(a_limbs)), Self(Large(b_limbs)), c) => {\n                let borrow = a_limbs.len() < b_limbs.len()\n                    || limbs_sub_mul_limb_greater_in_place_left(a_limbs, &b_limbs, c) != 0;\n                if !borrow {\n                    self.trim();\n                }\n                borrow\n            }\n        }\n    }\n\n    fn sub_mul_assign_limb_ref_no_panic(&mut self, b: &Self, c: Limb) -> bool {\n        match (&mut *self, b, c) {\n            (_, _, 0) | (_, &Self::ZERO, _) => false,\n            (a, b @ Self(Small(_)), c) => a.sub_assign_no_panic(b * Self::from(c)),\n            (Self(Small(_)), _, _) => true,\n            (Self(Large(a_limbs)), Self(Large(b_limbs)), c) => {\n                let borrow = a_limbs.len() < b_limbs.len()\n                    || limbs_sub_mul_limb_greater_in_place_left(a_limbs, b_limbs, c) != 0;\n                if !borrow {\n                    self.trim();\n                }\n                borrow\n            }\n        }\n    }\n\n    pub(crate) fn sub_mul_assign_no_panic(&mut self, b: Self, c: Self) -> bool {\n        match (&mut *self, b, c) {\n            (a, Self(Small(small_b)), c) => a.sub_mul_assign_limb_no_panic(c, small_b),\n            (a, b, Self(Small(small_c))) => a.sub_mul_assign_limb_no_panic(b, small_c),\n            (Self(Small(_)), _, _) => true,\n            large_left!(a_limbs, b_limbs, c_limbs) => large_right!(self, a_limbs, b_limbs, c_limbs),\n        }\n    }\n\n    pub(crate) fn sub_mul_assign_val_ref_no_panic(&mut self, b: Self, c: &Self) -> bool {\n        match (&mut *self, &b, c) {\n            (a, Self(Small(small_b)), c) => a.sub_mul_assign_limb_ref_no_panic(c, *small_b),\n            (a, _, Self(Small(small_c))) => a.sub_mul_assign_limb_no_panic(b, *small_c),\n            (Self(Small(_)), _, _) => true,\n            large_left!(a_limbs, b_limbs, c_limbs) => large_right!(self, a_limbs, b_limbs, c_limbs),\n        }\n    }\n\n    pub(crate) fn sub_mul_assign_ref_val_no_panic(&mut self, b: &Self, c: Self) -> bool {\n        match (&mut *self, b, &c) {\n            (a, Self(Small(small_b)), _) => a.sub_mul_assign_limb_no_panic(c, *small_b),\n            (a, b, Self(Small(small_c))) => a.sub_mul_assign_limb_ref_no_panic(b, *small_c),\n            (Self(Small(_)), _, _) => true,\n            large_left!(a_limbs, b_limbs, c_limbs) => large_right!(self, a_limbs, b_limbs, c_limbs),\n        }\n    }\n\n    pub(crate) fn sub_mul_assign_ref_ref_no_panic(&mut self, b: &Self, c: &Self) -> bool {\n        match (&mut *self, b, c) {\n            (a, Self(Small(small_b)), c) => a.sub_mul_assign_limb_ref_no_panic(c, *small_b),\n            (a, b, Self(Small(small_c))) => a.sub_mul_assign_limb_ref_no_panic(b, *small_c),\n            (Self(Small(_)), _, _) => true,\n            large_left!(a_limbs, b_limbs, c_limbs) => large_right!(self, a_limbs, b_limbs, c_limbs),\n        }\n    }\n}\n\nimpl CheckedSubMul<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking all three by value\n    /// and returning `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - yz) & \\text{if} \\\\quad x \\geq yz, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSubMul, Pow};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32)\n    ///         .checked_sub_mul(Natural::from(3u32), Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"Some(8)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .checked_sub_mul(Natural::from(3u32), Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .checked_sub_mul(Natural::from(0x10000u32), Natural::from(0x10000u32))\n    ///         .to_debug_string(),\n    ///     \"Some(995705032704)\"\n    /// );\n    /// ```\n    fn checked_sub_mul(mut self, y: Self, z: Self) -> Option<Self> {\n        if self.sub_mul_assign_no_panic(y, z) {\n            None\n        } else {\n            Some(self)\n        }\n    }\n}\n\nimpl<'a> CheckedSubMul<Self, &'a Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first two by\n    /// value and the third by reference and returning `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - yz) & \\text{if} \\\\quad x \\geq yz, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSubMul, Pow};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32)\n    ///         .checked_sub_mul(Natural::from(3u32), &Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"Some(8)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .checked_sub_mul(Natural::from(3u32), &Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .checked_sub_mul(Natural::from(0x10000u32), &Natural::from(0x10000u32))\n    ///         .to_debug_string(),\n    ///     \"Some(995705032704)\"\n    /// );\n    /// ```\n    fn checked_sub_mul(mut self, y: Self, z: &'a Self) -> Option<Self> {\n        if self.sub_mul_assign_val_ref_no_panic(y, z) {\n            None\n        } else {\n            Some(self)\n        }\n    }\n}\n\nimpl<'a> CheckedSubMul<&'a Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first and third\n    /// by value and the second by reference and returning `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - yz) & \\text{if} \\\\quad x \\geq yz, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSubMul, Pow};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32)\n    ///         .checked_sub_mul(&Natural::from(3u32), Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"Some(8)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .checked_sub_mul(&Natural::from(3u32), Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .checked_sub_mul(&Natural::from(0x10000u32), Natural::from(0x10000u32))\n    ///         .to_debug_string(),\n    ///     \"Some(995705032704)\"\n    /// );\n    /// ```\n    fn checked_sub_mul(mut self, y: &'a Self, z: Self) -> Option<Self> {\n        if self.sub_mul_assign_ref_val_no_panic(y, z) {\n            None\n        } else {\n            Some(self)\n        }\n    }\n}\n\nimpl<'a, 'b> CheckedSubMul<&'a Self, &'b Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first by value\n    /// and the second and third by reference and returning `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - yz) & \\text{if} \\\\quad x \\geq yz, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSubMul, Pow};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32)\n    ///         .checked_sub_mul(&Natural::from(3u32), &Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"Some(8)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .checked_sub_mul(&Natural::from(3u32), &Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .checked_sub_mul(&Natural::from(0x10000u32), &Natural::from(0x10000u32))\n    ///         .to_debug_string(),\n    ///     \"Some(995705032704)\"\n    /// );\n    /// ```\n    fn checked_sub_mul(mut self, y: &'a Self, z: &'b Self) -> Option<Self> {\n        if self.sub_mul_assign_ref_ref_no_panic(y, z) {\n            None\n        } else {\n            Some(self)\n        }\n    }\n}\n\nimpl CheckedSubMul<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking all three by\n    /// reference and returning `None` if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\\\begin{cases}\n    ///     \\operatorname{Some}(x - yz) & \\text{if} \\\\quad x \\geq yz, \\\\\\\\\n    ///     \\operatorname{None} & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n, m) = O(m + n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{CheckedSubMul, Pow};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(20u32))\n    ///         .checked_sub_mul(&Natural::from(3u32), &Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"Some(8)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .checked_sub_mul(&Natural::from(3u32), &Natural::from(4u32))\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12))\n    ///         .checked_sub_mul(&Natural::from(0x10000u32), &Natural::from(0x10000u32))\n    ///         .to_debug_string(),\n    ///     \"Some(995705032704)\"\n    /// );\n    /// ```\n    fn checked_sub_mul(self, y: &Natural, z: &Natural) -> Option<Natural> {\n        match (self, y, z) {\n            (x, Natural(Small(small_y)), z) => x.checked_sub_mul_limb_ref_ref(z, *small_y),\n            (x, y, Natural(Small(small_z))) => x.checked_sub_mul_limb_ref_ref(y, *small_z),\n            (Natural(Small(_)), _, _) => None,\n            (Natural(Large(x_limbs)), Natural(Large(y_limbs)), Natural(Large(z_limbs))) => {\n                if x_limbs.len() >= y_limbs.len() + z_limbs.len() - 1 {\n                    limbs_sub_mul(x_limbs, y_limbs, z_limbs).map(Natural::from_owned_limbs_asc)\n                } else {\n                    None\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/coprime_with.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::num::arithmetic::traits::{CoprimeWith, Gcd, Parity};\n\npub_test! {coprime_with_check_2(x: Natural, y: Natural) -> bool {\n    (x.odd() || y.odd()) && x.gcd(y) == 1u32\n}}\n\n#[cfg(feature = \"test_build\")]\npub fn coprime_with_check_2_3(x: Natural, y: Natural) -> bool {\n    (x.odd() || y.odd())\n        && (!(&x).divisible_by(Natural::from(3u32)) || !(&y).divisible_by(Natural::from(3u32)))\n        && x.gcd(y) == 1u32\n}\n\n#[cfg(feature = \"test_build\")]\npub fn coprime_with_check_2_3_5(x: Natural, y: Natural) -> bool {\n    if x.even() && y.even() {\n        false\n    } else {\n        let x15 = &x % Natural::from(15u32);\n        let y15 = &y % Natural::from(15u32);\n        if (x15 == 0u32 || x15 == 3u32 || x15 == 6u32 || x15 == 9u32 || x15 == 12u32)\n            && (y15 == 0u32 || y15 == 3u32 || y15 == 6u32 || y15 == 9u32 || y15 == 12u32)\n        {\n            return false;\n        }\n        if (x15 == 0u32 || x15 == 5u32 || x15 == 10u32)\n            && (y15 == 0u32 || y15 == 5u32 || y15 == 10u32)\n        {\n            return false;\n        }\n        x.gcd(y) == 1u32\n    }\n}\n\npub_test! {coprime_with_check_2_val_ref(x: Natural, y: &Natural) -> bool {\n    (x.odd() || y.odd()) && x.gcd(y) == 1u32\n}}\n\npub_test! {coprime_with_check_2_ref_val(x: &Natural, y: Natural) -> bool {\n    (x.odd() || y.odd()) && x.gcd(y) == 1u32\n}}\n\npub_test! {coprime_with_check_2_ref_ref(x: &Natural, y: &Natural) -> bool {\n    (x.odd() || y.odd()) && x.gcd(y) == 1u32\n}}\n\nimpl CoprimeWith<Self> for Natural {\n    /// Returns whether two [`Natural`]s are coprime; that is, whether they have no common factor\n    /// other than 1. Both [`Natural`]s are taken by value.\n    ///\n    /// Every [`Natural`] is coprime with 1. No [`Natural`] is coprime with 0, except 1.\n    ///\n    /// $f(x, y) = (\\gcd(x, y) = 1)$.\n    ///\n    /// $f(x, y) = ((k,m,n \\in \\N \\land x=km \\land y=kn) \\implies k=1)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CoprimeWith;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).coprime_with(Natural::from(5u32)), true);\n    /// assert_eq!(\n    ///     Natural::from(12u32).coprime_with(Natural::from(90u32)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn coprime_with(self, other: Self) -> bool {\n        coprime_with_check_2(self, other)\n    }\n}\n\nimpl<'a> CoprimeWith<&'a Self> for Natural {\n    /// Returns whether two [`Natural`]s are coprime; that is, whether they have no common factor\n    /// other than 1. The first [`Natural`] is taken by value and the second by reference.\n    ///\n    /// Every [`Natural`] is coprime with 1. No [`Natural`] is coprime with 0, except 1.\n    ///\n    /// $f(x, y) = (\\gcd(x, y) = 1)$.\n    ///\n    /// $f(x, y) = ((k,m,n \\in \\N \\land x=km \\land y=kn) \\implies k=1)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CoprimeWith;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).coprime_with(&Natural::from(5u32)), true);\n    /// assert_eq!(\n    ///     Natural::from(12u32).coprime_with(&Natural::from(90u32)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn coprime_with(self, other: &'a Self) -> bool {\n        coprime_with_check_2_val_ref(self, other)\n    }\n}\n\nimpl CoprimeWith<Natural> for &Natural {\n    /// Returns whether two [`Natural`]s are coprime; that is, whether they have no common factor\n    /// other than 1. The first [`Natural`] is taken by reference and the second by value.\n    ///\n    /// Every [`Natural`] is coprime with 1. No [`Natural`] is coprime with 0, except 1.\n    ///\n    /// $f(x, y) = (\\gcd(x, y) = 1)$.\n    ///\n    /// $f(x, y) = ((k,m,n \\in \\N \\land x=km \\land y=kn) \\implies k=1)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CoprimeWith;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).coprime_with(Natural::from(5u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(12u32)).coprime_with(Natural::from(90u32)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn coprime_with(self, other: Natural) -> bool {\n        coprime_with_check_2_ref_val(self, other)\n    }\n}\n\nimpl CoprimeWith<&Natural> for &Natural {\n    /// Returns whether two [`Natural`]s are coprime; that is, whether they have no common factor\n    /// other than 1. Both [`Natural`]s are taken by reference.\n    ///\n    /// Every [`Natural`] is coprime with 1. No [`Natural`] is coprime with 0, except 1.\n    ///\n    /// $f(x, y) = (\\gcd(x, y) = 1)$.\n    ///\n    /// $f(x, y) = ((k,m,n \\in \\N \\land x=km \\land y=kn) \\implies k=1)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CoprimeWith;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).coprime_with(Natural::from(5u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(12u32)).coprime_with(Natural::from(90u32)),\n    ///     false\n    /// );\n    /// ```\n    fn coprime_with(self, other: &Natural) -> bool {\n        coprime_with_check_2_ref_ref(self, other)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_dcpi1_divappr_q`, `mpn_dcpi1_divappr_q_n`, `mpn_div_q`, `mpn_mu_divappr_q`,\n//      `mpn_mu_divappr_q_choose_in`, `mpn_mu_divappr_q_itch`, `mpn_preinv_mu_divappr_q`,\n//      `mpn_sbpi1_div_q`, and `mpn_sbpi1_divappr_q` contributed to the GNU project by Torbjörn\n//      Granlund.\n//\n//      `mpn_dcpi1_div_q`, `mpn_mu_div_q`, and `mpn_mu_div_q_itch` contributed to the GNU project by\n//      Torbjörn Granlund and Marco Bodrato.\n//\n//      `mpn_div_qr_1` contributed to the GNU project by Niels Möller and Torbjörn Granlund.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out, limbs_slice_add_limb_in_place,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::div_mod::{\n    MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD, MUPI_DIV_QR_THRESHOLD, div_mod_by_preinversion,\n    limbs_div_barrett_large_product, limbs_div_mod_by_two_limb_normalized,\n    limbs_div_mod_divide_and_conquer_helper, limbs_div_mod_schoolbook,\n    limbs_div_mod_three_limb_by_two_limb, limbs_invert_approx, limbs_invert_approx_scratch_len,\n    limbs_invert_limb, limbs_two_limb_inverse_helper,\n};\nuse crate::natural::arithmetic::mul::mul_mod::{\n    limbs_mul_mod_base_pow_n_minus_1_next_size, limbs_mul_mod_base_pow_n_minus_1_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_limb_in_place, limbs_sub_limb_to_out, limbs_sub_same_length_in_place_left,\n    limbs_sub_same_length_in_place_right, limbs_sub_same_length_to_out,\n    limbs_sub_same_length_with_borrow_in_in_place_right,\n};\nuse crate::natural::arithmetic::sub_mul::limbs_sub_mul_limb_same_length_in_place_left;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{\n    DC_DIV_QR_THRESHOLD, DC_DIVAPPR_Q_THRESHOLD, DoubleLimb, FUDGE, Limb, MU_DIVAPPR_Q_THRESHOLD,\n};\nuse alloc::boxed::Box;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse core::cmp::max;\nuse core::iter::once;\nuse core::mem::swap;\nuse core::ops::{Div, DivAssign};\nuse malachite_base::fail_on_untested_path;\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::arithmetic::traits::DivRem;\nuse malachite_base::num::arithmetic::traits::{\n    CheckedDiv, WrappingAddAssign, WrappingMulAssign, WrappingSubAssign, XMulYToZZ, XXAddYYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, HasHalf, JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::slices::{slice_move_left, slice_set_zero};\n\n// Divide an number by a divisor of B - 1, where B is the limb base.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `ns`.\n//\n// This is equivalent to `mpn_bdiv_dbm1c` from `mpn/generic/bdiv_dbm1c.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_divisor_of_limb_max_with_carry_to_out<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    out: &mut [T],\n    ns: &[T],\n    d: T,\n    mut carry: T,\n) -> T {\n    assert!(out.len() >= ns.len());\n    let d = DT::from(d);\n    for (q, &n) in out.iter_mut().zip(ns.iter()) {\n        let (hi, lo) = (DT::from(n) * d).split_in_half();\n        let inner_carry = carry < lo;\n        carry.wrapping_sub_assign(lo);\n        *q = carry;\n        carry.wrapping_sub_assign(hi);\n        if inner_carry {\n            carry.wrapping_sub_assign(T::ONE);\n        }\n    }\n    carry\n}}\n\n// Divide an number by a divisor of B - 1, where B is the limb base.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_bdiv_dbm1c` from `mpn/generic/bdiv_dbm1c.c`, GMP 6.2.1, where `qp ==\n// ap`.\npub_crate_test! {limbs_div_divisor_of_limb_max_with_carry_in_place(\n    ns: &mut [Limb],\n    d: Limb,\n    mut carry: Limb,\n) -> Limb {\n    let d = DoubleLimb::from(d);\n    for n in &mut *ns {\n        let (hi, lo) = (DoubleLimb::from(*n) * d).split_in_half();\n        let inner_carry = carry < lo;\n        carry.wrapping_sub_assign(lo);\n        *n = carry;\n        carry.wrapping_sub_assign(hi);\n        if inner_carry {\n            carry.wrapping_sub_assign(1);\n        }\n    }\n    carry\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `udiv_qrnnd_preinv` from `gmp-impl.h`, GMP 6.2.1, but not computing the\n// remainder.\npub_test! {div_by_preinversion(n_high: Limb, n_low: Limb, d: Limb, d_inv: Limb) -> Limb {\n    let (mut q_high, q_low) = (DoubleLimb::from(n_high) * DoubleLimb::from(d_inv))\n        .wrapping_add(DoubleLimb::join_halves(n_high.wrapping_add(1), n_low))\n        .split_in_half();\n    let mut r = n_low.wrapping_sub(q_high.wrapping_mul(d));\n    if r > q_low {\n        q_high.wrapping_sub_assign(1);\n        r.wrapping_add_assign(d);\n    }\n    if r >= d {\n        q_high.wrapping_add_assign(1);\n    }\n    q_high\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// quotient limbs of the `Natural` divided by a `Limb`. The divisor limb cannot be zero and the limb\n// slice must have at least two elements.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if the length of `ns` is less than 2 or if `d` is zero.\n//\n// This is equivalent to `mpn_div_qr_1` from `mpn/generic/div_qr_1.c`, GMP 6.2.1, where the quotient\n// is returned, but not computing the remainder.\npub_test! {limbs_div_limb(ns: &[Limb], d: Limb) -> Vec<Limb> {\n    let mut qs = vec![0; ns.len()];\n    limbs_div_limb_to_out(&mut qs, ns, d);\n    qs\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and a `Limb` to an output slice. The output slice must be\n// at least as long as the input slice. The divisor limb cannot be zero and the input limb slice\n// must have at least two elements.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `ns`, the length of `ns` is less than 2, or if `d` is zero.\n//\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, where `qxn == 0`\n// and `un > 1`, but not computing the remainder.\npub_crate_test! {limbs_div_limb_to_out(out: &mut [Limb], ns: &[Limb], d: Limb) {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let out = &mut out[..len];\n    let bits = LeadingZeros::leading_zeros(d);\n    if bits == 0 {\n        // High quotient limb is 0 or 1, skip a divide step.\n        let (r, ns_init) = ns.split_last().unwrap();\n        let mut r = *r;\n        let (out_last, out_init) = out.split_last_mut().unwrap();\n        let adjust = r >= d;\n        if adjust {\n            r -= d;\n        }\n        *out_last = Limb::from(adjust);\n        // Multiply-by-inverse, divisor already normalized.\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        for (out_q, &n) in out_init.iter_mut().zip(ns_init.iter()).rev() {\n            (*out_q, r) = div_mod_by_preinversion(r, n, d, d_inv);\n        }\n    } else {\n        // Skip a division if high < divisor (high quotient 0). Testing here before normalizing will\n        // still skip as often as possible.\n        let (ns_last, ns_init) = ns.split_last().unwrap();\n        let (ns, mut r) = if *ns_last < d {\n            *out.last_mut().unwrap() = 0;\n            (ns_init, *ns_last)\n        } else {\n            (ns, 0)\n        };\n        let d = d << bits;\n        r <<= bits;\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let (previous_n, ns_init) = ns.split_last().unwrap();\n        let mut previous_n = *previous_n;\n        let cobits = Limb::WIDTH - bits;\n        r |= previous_n >> cobits;\n        let (out_first, out_tail) = out.split_first_mut().unwrap();\n        for (out_q, &n) in out_tail.iter_mut().zip(ns_init.iter()).rev() {\n            let shifted_n = (previous_n << bits) | (n >> cobits);\n            (*out_q, r) = div_mod_by_preinversion(r, shifted_n, d, d_inv);\n            previous_n = n;\n        }\n        *out_first = div_by_preinversion(r, previous_n << bits, d, d_inv);\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and a `Limb` to the input slice. The divisor limb cannot\n// be zero and the input limb slice must have at least two elements.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if the length of `ns` is less than 2 or if `d` is zero.\n//\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, where `qp == up`,\n// `qxn == 0`, and `un > 1`, but not computing the remainder.\npub_test! {limbs_div_limb_in_place(ns: &mut [Limb], d: Limb) {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let bits = LeadingZeros::leading_zeros(d);\n    let (ns_last, ns_init) = ns.split_last_mut().unwrap();\n    if bits == 0 {\n        // High quotient limb is 0 or 1, skip a divide step.\n        let mut r = *ns_last;\n        let adjust = r >= d;\n        if adjust {\n            r -= d;\n        }\n        *ns_last = Limb::from(adjust);\n        // Multiply-by-inverse, divisor already normalized.\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        for n in ns_init.iter_mut().rev() {\n            (*n, r) = div_mod_by_preinversion(r, *n, d, d_inv);\n        }\n    } else {\n        // Skip a division if high < divisor (high quotient 0). Testing here before normalizing will\n        // still skip as often as possible.\n        let (ns, mut r) = if *ns_last < d {\n            let r = *ns_last;\n            *ns_last = 0;\n            (ns_init, r)\n        } else {\n            (ns, 0)\n        };\n        let d = d << bits;\n        r <<= bits;\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let last_index = ns.len() - 1;\n        let mut previous_n = ns[last_index];\n        let cobits = Limb::WIDTH - bits;\n        r |= previous_n >> cobits;\n        for i in (0..last_index).rev() {\n            let n = ns[i];\n            let shifted_n = (previous_n << bits) | (n >> cobits);\n            (ns[i + 1], r) = div_mod_by_preinversion(r, shifted_n, d, d_inv);\n            previous_n = n;\n        }\n        ns[0] = div_by_preinversion(r, previous_n << bits, d, d_inv);\n    }\n}}\n\n// Schoolbook division using the Möller-Granlund 3/2 division algorithm.\n//\n// Divides `ns` by `ds` and writes the `ns.len()` - `ds.len()` least-significant quotient limbs to\n// `qs`. Returns the most significant limb of the quotient; `true` means 1 and `false` means 0. `ds`\n// must have length greater than 2, `ns` must be at least as long as `ds`, and the most significant\n// bit of `ds` must be set. `d_inv` should be the result of `limbs_two_limb_inverse_helper` applied\n// to the two highest limbs of the denominator.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 3, `ns` is shorter than `ds`, `qs` has length less than\n// `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_sbpi1_div_q` from `mpn/generic/sbpi1_div_q.c`, GMP 6.2.1.\npub_test! {limbs_div_schoolbook(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len > 2);\n    assert!(n_len >= d_len);\n    let d_len_m_1 = d_len - 1;\n    let d_1 = ds[d_len_m_1];\n    assert!(d_1.get_highest_bit());\n    let q_len = n_len - d_len;\n    let ds_s = if q_len < d_len_m_1 {\n        &ds[d_len_m_1 - q_len..]\n    } else {\n        ds\n    };\n    let d_len_s = ds_s.len(); // d_len or n_len - d_len + 1\n    let d_sum = d_len + d_len_s; // 2 * d_len or n_len + 1\n    let d_diff = d_len - d_len_s; // 0 or 2 * d_len - n_len - 1\n    let ns_hi = &mut ns[n_len - d_len_s..];\n    let highest_q = limbs_cmp_same_length(ns_hi, ds_s) >= Equal;\n    if highest_q {\n        limbs_sub_same_length_in_place_left(ns_hi, ds_s);\n    }\n    // Offset d_len by 2 for main division loops, saving two iterations in\n    // limbs_sub_mul_limb_same_length_in_place_left.\n    let d_len_m_2 = d_len - 2;\n    let d_len_s_m_1 = d_len_s - 1;\n    let d_len_s_m_2 = d_len_s.wrapping_sub(2); // only used when d_len_s >= 2\n    let d_2 = ds[d_len_m_2];\n    let mut n_1 = ns[n_len - 1];\n    for i in (d_sum - 1..n_len).rev() {\n        let ns = &mut ns[i - d_len_s..i];\n        let mut q;\n        if n_1 == d_1 && ns[d_len_s_m_1] == d_2 {\n            q = Limb::MAX;\n            limbs_sub_mul_limb_same_length_in_place_left(ns, ds_s, q);\n            n_1 = ns[d_len_s_m_1]; // update n_1; last loop's value will now be invalid\n        } else {\n            let n;\n            (q, n) = limbs_div_mod_three_limb_by_two_limb(\n                n_1,\n                ns[d_len_s_m_1],\n                ns[d_len_s - 2],\n                d_1,\n                d_2,\n                d_inv,\n            );\n            let mut n_0;\n            (n_1, n_0) = n.split_in_half();\n            let carry = limbs_sub_mul_limb_same_length_in_place_left(\n                &mut ns[..d_len_s - 2],\n                &ds_s[..d_len_s - 2],\n                q,\n            );\n            let carry_2 = n_0 < carry;\n            n_0.wrapping_sub_assign(carry);\n            let carry = carry_2 && n_1 == 0;\n            if carry_2 {\n                n_1.wrapping_sub_assign(1);\n            }\n            ns[d_len_s_m_2] = n_0;\n            if carry {\n                n_1.wrapping_add_assign(d_1);\n                if limbs_slice_add_same_length_in_place_left(\n                    &mut ns[..d_len_s_m_1],\n                    &ds_s[..d_len_s_m_1],\n                ) {\n                    n_1.wrapping_add_assign(1);\n                }\n                q.wrapping_sub_assign(1);\n            }\n        }\n        qs[i - d_len] = q;\n    }\n    let mut flag = true;\n    let offset = if d_len_s >= 2 {\n        let mut ds_suffix = &ds[d_diff..];\n        for i in (1..d_len_s_m_1).rev() {\n            let ns = &mut ns[d_len_m_2..d_len + i];\n            let mut q;\n            if !flag || n_1 >= d_1 {\n                q = Limb::MAX;\n                let carry = limbs_sub_mul_limb_same_length_in_place_left(ns, ds_suffix, q);\n                if n_1 != carry {\n                    if flag && n_1 < carry {\n                        q.wrapping_sub_assign(1);\n                        limbs_slice_add_same_length_in_place_left(ns, ds_suffix);\n                    } else {\n                        flag = false;\n                    }\n                }\n                n_1 = ns[i + 1];\n            } else {\n                let n;\n                (q, n) =\n                    limbs_div_mod_three_limb_by_two_limb(n_1, ns[i + 1], ns[i], d_1, d_2, d_inv);\n                let mut n_0;\n                (n_1, n_0) = n.split_in_half();\n                let carry = limbs_sub_mul_limb_same_length_in_place_left(\n                    &mut ns[..i],\n                    &ds_suffix[..ds_suffix.len() - 2],\n                    q,\n                );\n                let carry_2 = n_0 < carry;\n                n_0.wrapping_sub_assign(carry);\n                let carry = carry_2 && n_1 == 0;\n                if carry_2 {\n                    n_1.wrapping_sub_assign(1);\n                }\n                ns[i] = n_0;\n                if carry {\n                    n_1.wrapping_add_assign(d_1);\n                    if limbs_slice_add_same_length_in_place_left(\n                        &mut ns[..=i],\n                        &ds_suffix[..ds_suffix.len() - 1],\n                    ) {\n                        n_1.wrapping_add_assign(1);\n                    }\n                    q.wrapping_sub_assign(1);\n                }\n            }\n            qs[i] = q;\n            ds_suffix = &ds_suffix[1..];\n        }\n        let mut q;\n        let ns = &mut ns[d_len_m_2..d_len];\n        if !flag || n_1 >= d_1 {\n            q = Limb::MAX;\n            let ds_hi = &ds[d_len_m_2..];\n            let carry = limbs_sub_mul_limb_same_length_in_place_left(ns, &ds_hi[..2], q);\n            if n_1 != carry {\n                if flag && n_1 < carry {\n                    q.wrapping_sub_assign(1);\n                    (ns[1], ns[0]) = Limb::xx_add_yy_to_zz(ns[1], ns[0], d_2, ds_hi[0]);\n                } else {\n                    flag = false;\n                }\n            }\n            n_1 = ns[1];\n        } else {\n            let new_n;\n            (q, new_n) = limbs_div_mod_three_limb_by_two_limb(n_1, ns[1], ns[0], d_1, d_2, d_inv);\n            (n_1, ns[0]) = new_n.split_in_half();\n            ns[1] = n_1;\n        }\n        qs[0] = q;\n        d_len\n    } else {\n        d_sum - 1\n    };\n    let (ns_last, ns_init) = ns[..offset].split_last_mut().unwrap();\n    assert_eq!(*ns_last, n_1);\n    if flag && n_1 < Limb::exact_from(d_len) {\n        let qs = &mut qs[offset - d_len..];\n        let qs = &mut qs[..q_len];\n        // The quotient may be too large if the remainder is small. Recompute for above ignored\n        // operand parts, until the remainder spills. Compensate for triangularization.\n        let ns = ns_init;\n        {\n            let (ns_last, ns_init) = ns.split_last_mut().unwrap();\n            for i in 3..=d_len_s {\n                let q = qs[d_len_s - i];\n                let carry = limbs_sub_mul_limb_same_length_in_place_left(\n                    &mut ns_init[offset - i..],\n                    &ds_s[..i - 2],\n                    q,\n                );\n                if *ns_last < carry {\n                    if n_1 == 0 {\n                        assert!(!limbs_sub_limb_in_place(qs, 1));\n                        return highest_q;\n                    }\n                    n_1 -= 1;\n                }\n                ns_last.wrapping_sub_assign(carry);\n            }\n        }\n        if d_diff != 0 {\n            // Compensate for ignored dividend and divisor tails.\n            if highest_q {\n                let mut carry =\n                    limbs_sub_same_length_in_place_left(&mut ns[q_len..d_len_m_1], &ds[..d_diff]);\n                if carry {\n                    if n_1 == 0 {\n                        if q_len != 0 {\n                            carry = limbs_sub_limb_in_place(qs, 1);\n                        }\n                        assert!(highest_q || !carry);\n                        return highest_q != carry;\n                    }\n                    n_1 -= 1;\n                }\n            }\n            if q_len == 0 {\n                return highest_q;\n            }\n            let ns = &mut ns[..d_len_m_1];\n            for i in (0..d_diff).rev() {\n                let (ns_lo, ns_hi) = ns[i..].split_at_mut(q_len);\n                if limbs_sub_limb_in_place(\n                    ns_hi,\n                    limbs_sub_mul_limb_same_length_in_place_left(ns_lo, qs, ds[i]),\n                ) {\n                    if n_1 == 0 {\n                        limbs_sub_limb_in_place(qs, 1);\n                        return highest_q;\n                    }\n                    n_1 -= 1;\n                }\n            }\n        }\n    }\n    highest_q\n}}\n\n// Recursive divide-and-conquer division.\n//\n// Divides `ns` by `ds` and writes the `ns.len()` - `ds.len()` least-significant quotient limbs to\n// `qs`. Returns the most significant limb of the quotient; `true` means 1 and `false` means 0. `ds`\n// must have length greater than 2, `ns` must be at least as long as `ds`, and the most significant\n// bit of `ds` must be set. `d_inv` should be the result of `limbs_two_limb_inverse_helper` applied\n// to the two highest limbs of the denominator.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 6, `ns` is shorter than or the same length as `ds`, `qs`\n// has length less than `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest\n// bit set.\n//\n// This is equivalent to `mpn_dcpi1_div_q` from `mpn/generic/dcpi1_div_q.c`, GMP 6.2.1.\npub_test! {limbs_div_divide_and_conquer(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 6);\n    assert!(n_len - d_len >= 3);\n    let q_len = n_len - d_len;\n    assert!(ds[d_len - 1].get_highest_bit());\n    let qs = &mut qs[..q_len];\n    let mut scratch = Vec::with_capacity(n_len + 1);\n    scratch.push(1);\n    scratch.extend_from_slice(ns);\n    let mut scratch_2 = vec![0; q_len + 1];\n    let highest_q = limbs_div_divide_and_conquer_approx(&mut scratch_2, &mut scratch, ds, d_inv);\n    let (scratch_2_head, scratch_2_tail) = scratch_2.split_first_mut().unwrap();\n    if *scratch_2_head == 0 {\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(q_len, d_len)];\n        limbs_mul_to_out(&mut scratch, scratch_2_tail, ds, &mut mul_scratch);\n        let scratch_init = &mut scratch[..n_len];\n        // At most is wrong by one, no cycle.\n        if highest_q && limbs_slice_add_same_length_in_place_left(&mut scratch_init[q_len..], ds)\n            || limbs_cmp_same_length(scratch_init, ns) == Greater\n        {\n            return if limbs_sub_limb_to_out(qs, scratch_2_tail, 1) {\n                assert!(highest_q);\n                false\n            } else {\n                highest_q\n            };\n        }\n    }\n    qs.copy_from_slice(scratch_2_tail);\n    highest_q\n}}\n\n// Divides `ns` by `ds` and writes the `ns.len()` - `ds.len()` least-significant quotient limbs to\n// `qs`. Returns the most significant limb of the quotient; `true` means 1 and `false` means 0. `ds`\n// must have length greater than 2, `ns` must be longer than `ds`, and the most significant bit of\n// `ds` must be set.\n//\n// The idea of the algorithm used herein is to compute a smaller inverted value than used in the\n// standard Barrett algorithm, and thus save time in the Newton iterations, and pay just a small\n// price when using the inverted value for developing quotient bits. This algorithm was presented at\n// ICMS 2006.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mu_div_q` from `mpn/generic/mu_div_q.c`, GMP 6.2.1.\npub_test! {limbs_div_barrett(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb]\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(n_len > d_len);\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    let q_len_plus_1 = q_len + 1;\n    let mut scratch_2 = vec![0; q_len_plus_1];\n    let highest_q;\n    if q_len >= d_len {\n        // ```\n        // |_______________________|   dividend\n        // |________|   divisor\n        // ```\n        let mut rs = Vec::with_capacity(n_len + 1);\n        rs.push(0);\n        rs.extend_from_slice(ns);\n        let rs_hi = &mut rs[q_len_plus_1..];\n        highest_q = limbs_cmp_same_length(rs_hi, ds) >= Equal;\n        if highest_q {\n            limbs_sub_same_length_in_place_left(rs_hi, ds);\n        }\n        if limbs_div_barrett_approx(&mut scratch_2, &rs, ds, scratch) {\n            // Since the partial remainder fed to limbs_div_barrett_approx_preinverted was\n            // canonically reduced, replace the returned value of B ^ (q_len - d_len) + epsilon by\n            // the largest possible value.\n            scratch_2.fill(Limb::MAX);\n        }\n        // The max error of limbs_div_barrett_approx is +4. If the low quotient limb is smaller than\n        // the max error, we cannot trust the quotient.\n        let (scratch_2_head, scratch_2_tail) = scratch_2.split_first().unwrap();\n        if *scratch_2_head > 4 {\n            qs.copy_from_slice(scratch_2_tail);\n        } else {\n            let rs = &mut rs[..n_len];\n            let mut mul_scratch =\n                vec![0; limbs_mul_greater_to_out_scratch_len(scratch_2_tail.len(), ds.len())];\n            limbs_mul_greater_to_out(rs, scratch_2_tail, ds, &mut mul_scratch);\n            if highest_q && limbs_slice_add_same_length_in_place_left(&mut rs[q_len..], ds)\n                || limbs_cmp_same_length(rs, ns) == Greater\n            {\n                // At most is wrong by one, no cycle.\n                if limbs_sub_limb_to_out(qs, scratch_2_tail, 1) {\n                    fail_on_untested_path(\"limbs_div_barrett, limbs_sub_greater_to_out 1\");\n                    assert!(highest_q);\n                    return false;\n                }\n            } else {\n                qs.copy_from_slice(scratch_2_tail);\n            }\n        }\n    } else {\n        // ```\n        // |_______________________|   dividend\n        // |________________|   divisor\n        // ```\n        let ghost_n = n_len == (d_len << 1) - 1;\n        highest_q = limbs_div_barrett_approx_helper(\n            &mut scratch_2,\n            &ns[if ghost_n {\n                0\n            } else {\n                n_len - (q_len_plus_1 << 1)\n            }..],\n            ghost_n,\n            &ds[d_len - q_len_plus_1..],\n            scratch,\n        );\n        // The max error of limbs_div_barrett_approx is +4, but we get an additional error from the\n        // divisor truncation.\n        let (scratch_2_head, scratch_2_tail) = scratch_2.split_first().unwrap();\n        if *scratch_2_head > 6 {\n            qs.copy_from_slice(scratch_2_tail);\n        } else {\n            let mut rs = vec![0; n_len];\n            let mut mul_scratch =\n                vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), scratch_2_tail.len())];\n            limbs_mul_greater_to_out(&mut rs, ds, scratch_2_tail, &mut mul_scratch);\n            if highest_q && limbs_slice_add_same_length_in_place_left(&mut rs[q_len..], ds)\n                || limbs_cmp_same_length(&rs, ns) == Greater\n            {\n                // At most is wrong by one, no cycle.\n                if limbs_sub_limb_to_out(qs, scratch_2_tail, 1) {\n                    assert!(highest_q);\n                    return false;\n                }\n            } else {\n                qs.copy_from_slice(scratch_2_tail);\n            }\n        }\n    }\n    highest_q\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// The result is $O(n)$, where $n$ is `n_len`.\n//\n// This is equivalent to `mpn_mu_div_q_itch` from `mpn/generic/mu_div_q.c`, GMP 6.2.1, where `mua_k\n// == 0`.\npub_test! {limbs_div_barrett_scratch_len(n_len: usize, d_len: usize) -> usize {\n    let q_len = n_len - d_len;\n    if q_len >= d_len {\n        limbs_div_barrett_approx_scratch_len(n_len + 1, d_len)\n    } else {\n        let q_len_plus_1 = q_len + 1;\n        limbs_div_barrett_approx_scratch_len(q_len_plus_1 << 1, q_len_plus_1)\n    }\n}}\n\n// Schoolbook division using the Möller-Granlund 3/2 division algorithm, returning approximate\n// quotient.\n//\n// Divides `ns` by `ds` and writes the `ns.len()` - `ds.len()` least-significant quotient limbs to\n// `qs`. Returns the most significant limb of the quotient; `true` means 1 and `false` means 0. The\n// quotient is either correct, or one too large. `ds` must have length greater than 2, `ns` must be\n// at least as long as `ds`, and the most significant bit of `ds` must be set. `d_inv` should be the\n// result of `limbs_two_limb_inverse_helper` applied to the two highest limbs of the denominator.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 3, `ns` is shorter than `ds`, `qs` has length less than\n// `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_sbpi1_divappr_q` from `mpn/generic/sbpi1_divappr_q.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_schoolbook_approx(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    mut ds: &[Limb],\n    d_inv: Limb,\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len > 2);\n    assert!(n_len >= d_len);\n    let a = d_len - 1;\n    let d_1 = ds[a];\n    assert!(d_1.get_highest_bit());\n    let b = d_len - 2;\n    let d_0 = ds[b];\n    let q_len = n_len - d_len;\n    assert!(qs.len() >= q_len);\n    if q_len + 1 < d_len {\n        ds = &ds[d_len - (q_len + 1)..];\n    }\n    let d_len = ds.len();\n    let d_len_minus_1 = d_len - 1;\n    let ns_hi = &mut ns[n_len - d_len..];\n    let highest_q = limbs_cmp_same_length(ns_hi, ds) >= Equal;\n    if highest_q {\n        limbs_sub_same_length_in_place_left(ns_hi, ds);\n    }\n    let mut n_1 = *ns.last().unwrap();\n    let mut q;\n    let mut n_0;\n    for i in (d_len_minus_1..q_len).rev() {\n        let j = i + a;\n        if n_1 == d_1 && ns[j] == d_0 {\n            q = Limb::MAX;\n            limbs_sub_mul_limb_same_length_in_place_left(&mut ns[j - d_len_minus_1..=j], ds, q);\n            n_1 = ns[j]; // update n_1, last loop's value will now be invalid\n        } else {\n            let n;\n            (q, n) = limbs_div_mod_three_limb_by_two_limb(n_1, ns[j], ns[j - 1], d_1, d_0, d_inv);\n            (n_1, n_0) = n.split_in_half();\n            let local_carry_1 = limbs_sub_mul_limb_same_length_in_place_left(\n                &mut ns[j - d_len_minus_1..j - 1],\n                &ds[..d_len_minus_1 - 1],\n                q,\n            );\n            let local_carry_2 = n_0 < local_carry_1;\n            n_0.wrapping_sub_assign(local_carry_1);\n            let carry = local_carry_2 && n_1 == 0;\n            if local_carry_2 {\n                n_1.wrapping_sub_assign(1);\n            }\n            ns[j - 1] = n_0;\n            if carry {\n                n_1.wrapping_add_assign(d_1);\n                if limbs_slice_add_same_length_in_place_left(\n                    &mut ns[j - d_len_minus_1..j],\n                    &ds[..d_len_minus_1],\n                ) {\n                    n_1.wrapping_add_assign(1);\n                }\n                q.wrapping_sub_assign(1);\n            }\n        }\n        qs[i] = q;\n    }\n    let mut flag = true;\n    if d_len_minus_1 > 0 {\n        for i in (1..d_len_minus_1).rev() {\n            let j = i + a;\n            if !flag || n_1 >= d_1 {\n                q = Limb::MAX;\n                let carry = limbs_sub_mul_limb_same_length_in_place_left(&mut ns[b..=j], ds, q);\n                if n_1 != carry {\n                    if flag && n_1 < carry {\n                        q.wrapping_sub_assign(1);\n                        limbs_slice_add_same_length_in_place_left(&mut ns[b..=j], ds);\n                    } else {\n                        flag = false;\n                    }\n                }\n                n_1 = ns[j];\n            } else {\n                let n;\n                (q, n) =\n                    limbs_div_mod_three_limb_by_two_limb(n_1, ns[j], ns[j - 1], d_1, d_0, d_inv);\n                (n_1, n_0) = n.split_in_half();\n                let local_carry_1 =\n                    limbs_sub_mul_limb_same_length_in_place_left(&mut ns[b..j - 1], &ds[..i], q);\n                let local_carry_2 = n_0 < local_carry_1;\n                n_0.wrapping_sub_assign(local_carry_1);\n                let carry = local_carry_2 && n_1 == 0;\n                if local_carry_2 {\n                    n_1.wrapping_sub_assign(1);\n                }\n                ns[j - 1] = n_0;\n                if carry {\n                    n_1.wrapping_add_assign(d_1);\n                    if limbs_slice_add_same_length_in_place_left(&mut ns[b..j], &ds[..=i]) {\n                        n_1.wrapping_add_assign(1);\n                    }\n                    q.wrapping_sub_assign(1);\n                }\n            }\n            qs[i] = q;\n            ds = &ds[1..];\n        }\n        let ns = &mut ns[b..];\n        if !flag || n_1 >= d_1 {\n            q = Limb::MAX;\n            let carry = limbs_sub_mul_limb_same_length_in_place_left(&mut ns[..2], &ds[..2], q);\n            if flag && n_1 < carry {\n                q.wrapping_sub_assign(1);\n                limbs_slice_add_same_length_in_place_left(&mut ns[..2], &ds[..2]);\n            }\n            n_1 = ns[1];\n        } else {\n            let n;\n            (q, n) = limbs_div_mod_three_limb_by_two_limb(n_1, ns[1], ns[0], d_1, d_0, d_inv);\n            (n_1, ns[0]) = n.split_in_half();\n            ns[1] = n_1;\n        }\n        qs[0] = q;\n    }\n    assert_eq!(ns[a], n_1);\n    highest_q\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// This is equivalent to `mpn_dcpi1_divappr_q_n` from `mpn/generic/dcpi1_divappr_q.c`, GMP 6.2.1,\n// where `ns` here is `np + (n >> 1)`.\nfn limbs_div_divide_and_conquer_approx_helper(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n    scratch: &mut [Limb],\n) -> bool {\n    let d_len = ds.len();\n    let lo = d_len >> 1; // floor(d_len / 2)\n    let hi = d_len - lo; // ceil(d_len / 2)\n    assert!(ns.len() >= d_len + hi);\n    let (ds_lo, ds_hi) = ds.split_at(lo);\n    let qs_hi = &mut qs[lo..];\n    let ns_hi = &mut ns[lo..];\n    let mut highest_q = if hi < DC_DIV_QR_THRESHOLD {\n        limbs_div_mod_schoolbook(qs_hi, &mut ns_hi[..hi << 1], ds_hi, d_inv)\n    } else {\n        limbs_div_mod_divide_and_conquer_helper(qs_hi, ns_hi, ds_hi, d_inv, scratch)\n    };\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(hi, ds_lo.len())];\n    limbs_mul_greater_to_out(scratch, &qs_hi[..hi], ds_lo, &mut mul_scratch);\n    let ns_lo = &mut ns[..d_len];\n    let mut carry = Limb::from(limbs_sub_same_length_in_place_left(\n        ns_lo,\n        &scratch[..d_len],\n    ));\n    if highest_q && limbs_sub_same_length_in_place_left(&mut ns_lo[hi..], ds_lo) {\n        carry += 1;\n    }\n    while carry != 0 {\n        if limbs_sub_limb_in_place(&mut qs_hi[..hi], 1) {\n            assert!(highest_q);\n            highest_q = false;\n        }\n        if limbs_slice_add_same_length_in_place_left(ns_lo, ds) {\n            carry -= 1;\n        }\n    }\n    let ds_hi = &ds[hi..];\n    let ns_hi = &mut ns[hi - lo..];\n    let q_lo = if lo < DC_DIVAPPR_Q_THRESHOLD {\n        limbs_div_schoolbook_approx(qs, &mut ns_hi[..lo << 1], ds_hi, d_inv)\n    } else {\n        limbs_div_divide_and_conquer_approx_helper(qs, &mut ns_hi[lo >> 1..], ds_hi, d_inv, scratch)\n    };\n    if q_lo {\n        for q in &mut qs[..lo] {\n            *q = Limb::MAX;\n        }\n    }\n    highest_q\n}\n\n// Recursive divide-and-conquer division, returning approximate quotient.\n//\n// Divides `ns` by `ds` and writes the `ns.len()` - `ds.len()` least-significant quotient limbs to\n// `qs`. Returns the most significant limb of the quotient; `true` means 1 and `false` means 0. The\n// quotient is either correct, or one too large. `ds` must have length greater than 2, `ns` must be\n// at least as long as `ds`, and the most significant bit of `ds` must be set. `d_inv` should be the\n// result of `limbs_two_limb_inverse_helper` applied to the two highest limbs of the denominator.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 6, `ns` is shorter than or the same length as `ds`, `qs`\n// has length less than `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest\n// bit set.\n//\n// This is equivalent to `mpn_dcpi1_divappr_q` from `mpn/generic/dcpi1_divappr_q.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_divide_and_conquer_approx(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 6);\n    assert!(n_len > d_len);\n    let a = d_len - 1;\n    assert!(ds[a].get_highest_bit());\n    let b = d_len - 2;\n    let q_len = n_len - d_len;\n    let mut highest_q;\n    if q_len >= d_len {\n        let q_len_mod_d_len = {\n            let mut m = (q_len + 1) % d_len;\n            if m == 0 {\n                m = d_len;\n            }\n            m\n        };\n        let mut scratch = vec![0; d_len];\n        let offset = q_len - q_len_mod_d_len;\n        let ns_hi = &mut ns[offset..];\n        let qs_hi = &mut qs[offset..];\n        let r = d_len - q_len_mod_d_len;\n        let (ds_lo, ds_hi) = ds.split_at(r);\n        // Perform the typically smaller block first.\n        if q_len_mod_d_len == 1 {\n            // Handle highest_q up front, for simplicity.\n            let ns_2 = &mut ns_hi[1..=d_len];\n            highest_q = limbs_cmp_same_length(ns_2, ds) >= Equal;\n            if highest_q {\n                assert!(!limbs_sub_same_length_in_place_left(ns_2, ds));\n            }\n            // A single iteration of schoolbook: One 3/2 division, followed by the bignum update and\n            // adjustment.\n            let n_2 = ns_hi[d_len];\n            let mut n_1 = ns_hi[a];\n            let mut n_0 = ns_hi[b];\n            let d_1 = ds[a];\n            let d_0 = ds[b];\n            assert!(n_2 < d_1 || (n_2 == d_1 && n_1 <= d_0));\n            let mut q;\n            if n_2 == d_1 && n_1 == d_0 {\n                q = Limb::MAX;\n                assert_eq!(\n                    limbs_sub_mul_limb_same_length_in_place_left(&mut ns_hi[..d_len], ds, q),\n                    n_2\n                );\n            } else {\n                let n;\n                (q, n) = limbs_div_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, d_inv);\n                (n_1, n_0) = n.split_in_half();\n                // d_len > 2\n                let local_carry_1 =\n                    limbs_sub_mul_limb_same_length_in_place_left(&mut ns_hi[..b], &ds[..b], q);\n                let local_carry_2 = n_0 < local_carry_1;\n                n_0.wrapping_sub_assign(local_carry_1);\n                let carry = local_carry_2 && n_1 == 0;\n                if local_carry_2 {\n                    n_1.wrapping_sub_assign(1);\n                }\n                ns_hi[b] = n_0;\n                if carry {\n                    n_1.wrapping_add_assign(d_1);\n                    if limbs_slice_add_same_length_in_place_left(&mut ns_hi[..a], &ds[..a]) {\n                        n_1.wrapping_add_assign(1);\n                    }\n                    if q == 0 {\n                        fail_on_untested_path(\"limbs_div_divide_and_conquer_approx, q == 0\");\n                        assert!(highest_q);\n                        highest_q = false;\n                    }\n                    q.wrapping_sub_assign(1);\n                }\n                ns_hi[a] = n_1;\n            }\n            qs_hi[0] = q;\n        } else {\n            let ns_hi_2 = &mut ns_hi[r..];\n            highest_q = if q_len_mod_d_len == 2 {\n                limbs_div_mod_by_two_limb_normalized(\n                    qs_hi,\n                    &mut ns_hi_2[..q_len_mod_d_len + 2],\n                    ds_hi,\n                )\n            } else if q_len_mod_d_len < DC_DIV_QR_THRESHOLD {\n                limbs_div_mod_schoolbook(qs_hi, ns_hi_2, ds_hi, d_inv)\n            } else {\n                limbs_div_mod_divide_and_conquer_helper(qs_hi, ns_hi_2, ds_hi, d_inv, &mut scratch)\n            };\n            let qs = &mut qs_hi[..q_len_mod_d_len];\n            if q_len_mod_d_len != d_len {\n                let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(qs.len(), ds_lo.len())];\n                limbs_mul_to_out(&mut scratch, qs, ds_lo, &mut mul_scratch);\n                let mut carry = Limb::from(limbs_sub_same_length_in_place_left(\n                    &mut ns_hi[..d_len],\n                    &scratch[..d_len],\n                ));\n                if highest_q\n                    && limbs_sub_same_length_in_place_left(\n                        &mut ns_hi[q_len_mod_d_len..d_len],\n                        ds_lo,\n                    )\n                {\n                    carry += 1;\n                }\n                while carry != 0 {\n                    if limbs_sub_limb_in_place(qs, 1) {\n                        assert!(highest_q);\n                        highest_q = false;\n                    }\n                    if limbs_slice_add_same_length_in_place_left(&mut ns_hi[..d_len], ds) {\n                        carry -= 1;\n                    }\n                }\n            }\n        }\n        let mut offset = q_len.checked_sub(q_len_mod_d_len).unwrap();\n        while offset >= d_len {\n            offset -= d_len;\n            limbs_div_mod_divide_and_conquer_helper(\n                &mut qs[offset..],\n                &mut ns[offset..],\n                ds,\n                d_inv,\n                &mut scratch,\n            );\n        }\n        // Since we pretended we'd need an extra quotient limb before, we now have made sure the\n        // code above left just ds.len() - 1 = qs.len() quotient limbs to develop. Develop that plus\n        // a guard limb.\n        let ns = &mut ns[offset + (d_len >> 1) - d_len..];\n        let q_save = qs[offset];\n        limbs_div_divide_and_conquer_approx_helper(qs, ns, ds, d_inv, &mut scratch);\n        slice_move_left(&mut qs[..=offset], 1);\n        qs[offset] = q_save;\n    } else {\n        let offset = a - q_len;\n        let q_len_plus_one = q_len + 1;\n        let mut qs_2 = vec![0; q_len_plus_one];\n        let ds = &ds[offset..];\n        highest_q = if q_len < DC_DIVAPPR_Q_THRESHOLD && offset > 0 {\n            limbs_div_schoolbook_approx(&mut qs_2, &mut ns[offset - 1..], ds, d_inv)\n        } else {\n            let mut scratch = vec![0; q_len_plus_one];\n            limbs_div_divide_and_conquer_approx_helper(\n                &mut qs_2,\n                &mut ns[offset + (q_len_plus_one >> 1) - 1..],\n                ds,\n                d_inv,\n                &mut scratch,\n            )\n        };\n        qs[..q_len].copy_from_slice(&qs_2[1..]);\n    }\n    highest_q\n}}\n\n// Compute Q = floor(N / D) + e. N has n_len limbs, D has d_len limbs and must be normalized, and Q\n// must have n_len - d_len limbs, 0 <= e <= 4. The requirement that Q has n_len - d_len limbs (and\n// not n_len - d_len + 1 limbs) was put in place in order to allow us to let N be unmodified during\n// the operation.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mu_divappr_q` from `mpn/generic/mu_divappr_q.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_barrett_approx(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    limbs_div_barrett_approx_helper(qs, ns, false, ds, scratch)\n}}\n\nfn limbs_div_barrett_approx_helper(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    mut ns_ghost_limb: bool,\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = if ns_ghost_limb {\n        ns.len() + 1\n    } else {\n        ns.len()\n    };\n    let d_len = ds.len();\n    assert!(d_len > 1);\n    assert!(n_len >= d_len);\n    assert!(ds[d_len - 1].get_highest_bit());\n    let q_len = n_len - d_len;\n    // If Q is smaller than D, truncate operands.\n    let (ns, ds) = if q_len + 1 < d_len {\n        let start = d_len - q_len - 1; // start > 0\n        if ns_ghost_limb {\n            ns_ghost_limb = false;\n            (&ns[start - 1..], &ds[start..])\n        } else {\n            (&ns[start..], &ds[start..])\n        }\n    } else {\n        (ns, ds)\n    };\n    let d_len_s = ds.len();\n    // Compute the inverse size.\n    let i_len = limbs_div_barrett_approx_is_len(q_len, d_len_s);\n    assert!(i_len <= d_len_s);\n    let n = i_len + 1;\n    let (is, scratch_2) = scratch.split_at_mut(n);\n    // compute an approximate inverse on i_len + 1 limbs\n    if d_len_s == i_len {\n        scratch_2[1..n].copy_from_slice(&ds[..i_len]);\n        scratch_2[0] = 1;\n        let (scratch_2_lo, scratch_2_hi) = scratch_2.split_at_mut(n);\n        limbs_invert_approx(is, scratch_2_lo, scratch_2_hi);\n        slice_move_left(is, 1);\n    } else if limbs_add_limb_to_out(scratch_2, &ds[d_len_s - n..], 1) {\n        slice_set_zero(&mut is[..i_len]);\n    } else {\n        let (scratch_2_lo, scratch_2_hi) = scratch_2.split_at_mut(n);\n        limbs_invert_approx(is, scratch_2_lo, scratch_2_hi);\n        slice_move_left(is, 1);\n    }\n    let (is, scratch_hi) = scratch.split_at_mut(i_len);\n    limbs_div_barrett_approx_preinverted(qs, ns, ns_ghost_limb, ds, is, scratch_hi)\n}\n\n// $T(n, d) = O(n \\log d \\log\\log d)$\n//\n// $M(n) = O(d \\log d)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ns.len()`, and $d$ is `ds.len()`.\n//\n// This is equivalent to `mpn_preinv_mu_divappr_q` from `mpn/generic/mu_divappr_q.c`, GMP 6.2.1.\nfn limbs_div_barrett_approx_preinverted(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ns_ghost_limb: bool,\n    ds: &[Limb],\n    mut is: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = if ns_ghost_limb {\n        ns.len() + 1\n    } else {\n        ns.len()\n    };\n    let d_len = ds.len();\n    let mut i_len = is.len();\n    let mut q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    if ns_ghost_limb {\n        assert_ne!(q_len, 0);\n        assert_ne!(i_len, 0);\n    }\n    let (ns_lo, ns_hi) = ns.split_at(if ns_ghost_limb { q_len - 1 } else { q_len });\n    let highest_q = limbs_cmp_same_length(ns_hi, ds) >= Equal;\n    if q_len == 0 {\n        return highest_q;\n    }\n    let (rs, scratch) = scratch.split_at_mut(d_len);\n    if highest_q {\n        limbs_sub_same_length_to_out(rs, ns_hi, ds);\n    } else {\n        rs.copy_from_slice(ns_hi);\n    }\n    let scratch_len = if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        0\n    } else {\n        limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1)\n    };\n    let mut carry = false; // This value is never used\n    let mut n = d_len - i_len;\n    let empty_slice: &[Limb] = &[];\n    let ns_iter: Box<dyn Iterator<Item = &[Limb]>> = if ns_ghost_limb {\n        Box::new(ns_lo.rchunks(i_len).chain(once(empty_slice)))\n    } else {\n        Box::new(ns_lo.rchunks(i_len))\n    };\n    let mut mul_scratch = vec![\n        0;\n        max(\n            limbs_mul_same_length_to_out_scratch_len(q_len % i_len),\n            limbs_mul_same_length_to_out_scratch_len(i_len)\n        )\n    ];\n    for (ns, qs) in ns_iter.zip(qs.rchunks_mut(i_len)) {\n        let chunk_len = qs.len();\n        if i_len != chunk_len {\n            // last iteration\n            is = &is[i_len - chunk_len..];\n            i_len = chunk_len;\n            n = d_len - i_len;\n        }\n        let (rs_lo, rs_hi) = rs.split_at_mut(n);\n        // Compute the next block of quotient limbs by multiplying the inverse I by the upper part\n        // of the partial remainder R.\n        limbs_mul_same_length_to_out(scratch, rs_hi, is, &mut mul_scratch);\n        // i's highest bit is implicit\n        carry = limbs_add_same_length_to_out(qs, &scratch[i_len..i_len << 1], rs_hi);\n        assert!(!carry);\n        q_len -= i_len;\n        if q_len == 0 {\n            break;\n        }\n        // Compute the product of the quotient block and the divisor D, to be subtracted from the\n        // partial remainder combined with new limbs from the dividend N. We only really need the\n        // low d_len limbs.\n        if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs.len())];\n            limbs_mul_greater_to_out(scratch, ds, qs, &mut mul_scratch);\n        } else {\n            limbs_div_barrett_large_product(scratch, ds, qs, rs_hi, scratch_len, i_len);\n        }\n        let mut r = rs_hi[0].wrapping_sub(scratch[d_len]);\n        // Subtract the product from the partial remainder combined with new limbs from the dividend\n        // N, generating a new partial remainder R.\n        let scratch = &mut scratch[..d_len];\n        if n == 0 {\n            // get next i_len limbs from N\n            carry = limbs_sub_same_length_to_out(rs, ns, scratch);\n        } else {\n            // get next i_len limbs from N.\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(i_len);\n            carry = limbs_sub_same_length_with_borrow_in_in_place_right(\n                rs_lo,\n                scratch_hi,\n                limbs_sub_same_length_in_place_right(ns, scratch_lo),\n            );\n            rs.copy_from_slice(scratch);\n        }\n        // Check the remainder R and adjust the quotient as needed.\n        if carry {\n            r.wrapping_sub_assign(1);\n        }\n        while r != 0 {\n            // We loop 0 times with about 69% probability, 1 time with about 31% probability, and 2\n            // times with about 0.6% probability, if inverse is computed as recommended.\n            assert!(!limbs_slice_add_limb_in_place(qs, 1));\n            carry = limbs_sub_same_length_in_place_left(rs, ds);\n            if carry {\n                r -= 1;\n            }\n        }\n        if limbs_cmp_same_length(rs, ds) >= Equal {\n            // This is executed with about 76% probability.\n            assert!(!limbs_slice_add_limb_in_place(qs, 1));\n            carry = limbs_sub_same_length_in_place_left(rs, ds);\n        }\n    }\n    if limbs_slice_add_limb_in_place(qs, 3) || carry {\n        if highest_q {\n            // Return a quotient of just 1-bits, with highest_q set.\n            for q in &mut *qs {\n                *q = Limb::MAX;\n            }\n        }\n        true\n    } else {\n        highest_q\n    }\n}\n\n// We distinguish 3 cases:\n//\n// - d_len < q_len:              i_len = ceil(q_len / ceil(q_len / d_len))\n// - d_len / 3 < q_len <= d_len: i_len = ceil(q_len / 2)\n// - q_len < d_len / 3:          i_len = q_len\n//\n// In all cases we have i_len <= d_len.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// The result is $O(n)$, where $n$ is `q_len`.\n//\n// This is equivalent to `mpn_mu_divappr_q_choose_in` from `mpn/generic/mu_divappr_q.c`, GMP 6.2.1,\n// where `k == 0`.\n#[allow(clippy::missing_const_for_fn)]\nfn limbs_div_barrett_approx_is_len(q_len: usize, d_len: usize) -> usize {\n    if q_len > d_len {\n        // Compute an inverse size that is a nice partition of the quotient.\n        let b = q_len.saturating_sub(1) / d_len + 1; // ceil(q_len / d_len), number of blocks\n        q_len.saturating_sub(1) / b + 1 // ceil(q_len / b) = ceil(q_len / ceil(q_len / d_len))\n    } else if 3 * q_len > d_len {\n        q_len.saturating_sub(1) / 2 + 1 // b = 2\n    } else {\n        q_len.saturating_sub(1) + 1 // b = 1\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// The result is $O(n)$, where $n$ is `n_len`.\n//\n// This is equivalent to `mpn_mu_divappr_q_itch` from `mpn/generic/mu_divappr_q.c`, GMP 6.2.1, where\n// `mua_k == 0`.\npub_crate_test! {limbs_div_barrett_approx_scratch_len(n_len: usize, mut d_len: usize) -> usize {\n    let qn = n_len - d_len;\n    if qn + 1 < d_len {\n        d_len = qn + 1;\n    }\n    let is_len = limbs_div_barrett_approx_is_len(qn, d_len);\n    let local_len = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1);\n    let out_len = limbs_mul_mod_base_pow_n_minus_1_scratch_len(local_len, d_len, is_len);\n    // 3 * is_len + 4\n    let inv_approx_len = limbs_invert_approx_scratch_len(is_len + 1) + is_len + 2;\n    assert!(d_len + local_len + out_len >= inv_approx_len);\n    is_len + d_len + local_len + out_len\n}}\n\n// TODO tune\nconst DC_DIV_Q_THRESHOLD: usize = DC_DIVAPPR_Q_THRESHOLD;\n// TODO tune\nconst MU_DIV_Q_THRESHOLD: usize = MU_DIVAPPR_Q_THRESHOLD;\n// TODO tune\nconst MUPI_DIV_Q_THRESHOLD: usize = MUPI_DIVAPPR_Q_THRESHOLD;\n// TODO tune\nconst MUPI_DIVAPPR_Q_THRESHOLD: usize = MUPI_DIV_QR_THRESHOLD;\n\nfn limbs_div_dc_condition(n_len: usize, d_len: usize) -> bool {\n    let n_64 = n_len as f64;\n    let d_64 = d_len as f64;\n    d_len < MUPI_DIV_Q_THRESHOLD\n        || n_len < MU_DIV_Q_THRESHOLD << 1\n        || fma!(\n            ((MU_DIV_Q_THRESHOLD - MUPI_DIV_Q_THRESHOLD) << 1) as f64,\n            d_64,\n            MUPI_DIV_Q_THRESHOLD as f64 * n_64\n        ) > d_64 * n_64\n}\n\n// Division when n_len >= 2 * d_len - FUDGE.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub_crate_test! {limbs_div_to_out_unbalanced(qs: &mut [Limb], ns: &mut [Limb], ds: &mut [Limb]) {\n    // ```\n    // |________________________|\n    //                  |_______|\n    // ```\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let highest_d = ds[d_len - 1];\n    let bits = LeadingZeros::leading_zeros(highest_d);\n    if bits == 0 {\n        let highest_q = if d_len == 2 {\n            limbs_div_mod_by_two_limb_normalized(qs, ns, ds)\n        } else if d_len < DC_DIV_Q_THRESHOLD || n_len - d_len < DC_DIV_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n            limbs_div_schoolbook(qs, ns, ds, d_inv)\n        } else if limbs_div_dc_condition(n_len, d_len) {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n            limbs_div_divide_and_conquer(qs, ns, ds, d_inv)\n        } else {\n            let mut scratch = vec![0; limbs_div_barrett_scratch_len(n_len, d_len)];\n            limbs_div_barrett(qs, ns, ds, &mut scratch)\n        };\n        qs[n_len - d_len] = Limb::from(highest_q);\n    } else {\n        let mut scratch = vec![0; n_len + 1];\n        let carry = limbs_shl_to_out(&mut scratch, ns, bits);\n        scratch[n_len] = carry;\n        let new_n_len = if carry == 0 { n_len } else { n_len + 1 };\n        let new_ns = &mut scratch[..new_n_len];\n        limbs_slice_shl_in_place(ds, bits);\n        let highest_q = if d_len == 2 {\n            limbs_div_mod_by_two_limb_normalized(qs, new_ns, ds)\n        } else if d_len < DC_DIV_Q_THRESHOLD || new_n_len - d_len < DC_DIV_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(ds[d_len - 1], ds[d_len - 2]);\n            limbs_div_schoolbook(qs, new_ns, ds, d_inv)\n        } else if limbs_div_dc_condition(n_len, d_len) {\n            let d_inv = limbs_two_limb_inverse_helper(ds[d_len - 1], ds[d_len - 2]);\n            limbs_div_divide_and_conquer(qs, new_ns, ds, d_inv)\n        } else {\n            let mut scratch = vec![0; limbs_div_barrett_scratch_len(new_n_len, d_len)];\n            limbs_div_barrett(qs, new_ns, ds, &mut scratch)\n        };\n        if carry == 0 {\n            qs[n_len - d_len] = Limb::from(highest_q);\n        } else {\n            assert!(!highest_q);\n        }\n    }\n}}\n\npub_test! {limbs_div_q_dc_helper(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb]) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let highest_d = ds[d_len - 1];\n    if d_len < DC_DIV_Q_THRESHOLD || ns.len() - d_len < DC_DIV_Q_THRESHOLD {\n        let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n        limbs_div_schoolbook(qs, ns, ds, d_inv)\n    } else if limbs_div_dc_condition(n_len, d_len) {\n        let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n        limbs_div_divide_and_conquer(qs, ns, ds, d_inv)\n    } else {\n        let mut scratch = vec![0; limbs_div_barrett_scratch_len(n_len, d_len)];\n        limbs_div_barrett(qs, ns, ds, &mut scratch)\n    }\n}}\n\n/// Division when n_len >= 2 * d_len - FUDGE.\n///\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_div_to_out_unbalanced_val_ref(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb]) {\n    // ```\n    // |________________________|\n    //                  |_______|\n    // ```\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let highest_d = ds[d_len - 1];\n    let bits = LeadingZeros::leading_zeros(highest_d);\n    if bits == 0 {\n        let highest_q = if d_len == 2 {\n            limbs_div_mod_by_two_limb_normalized(qs, ns, ds)\n        } else {\n            limbs_div_q_dc_helper(qs, ns, ds)\n        };\n        qs[n_len - d_len] = Limb::from(highest_q);\n    } else {\n        let mut scratch = vec![0; n_len + 1];\n        let carry = limbs_shl_to_out(&mut scratch, ns, bits);\n        scratch[n_len] = carry;\n        let new_n_len = if carry == 0 { n_len } else { n_len + 1 };\n        let new_ns = &mut scratch[..new_n_len];\n        let mut new_ds = vec![0; d_len];\n        limbs_shl_to_out(&mut new_ds, ds, bits);\n        let highest_q = if d_len == 2 {\n            limbs_div_mod_by_two_limb_normalized(qs, new_ns, &new_ds)\n        } else if d_len < DC_DIV_Q_THRESHOLD || new_n_len - d_len < DC_DIV_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(new_ds[d_len - 1], new_ds[d_len - 2]);\n            limbs_div_schoolbook(qs, new_ns, &new_ds, d_inv)\n        } else if limbs_div_dc_condition(n_len, d_len) {\n            let d_inv = limbs_two_limb_inverse_helper(new_ds[d_len - 1], new_ds[d_len - 2]);\n            limbs_div_divide_and_conquer(qs, new_ns, &new_ds, d_inv)\n        } else {\n            let mut scratch = vec![0; limbs_div_barrett_scratch_len(new_n_len, d_len)];\n            limbs_div_barrett(qs, new_ns, &new_ds, &mut scratch)\n        };\n        if carry == 0 {\n            qs[n_len - d_len] = Limb::from(highest_q);\n        } else {\n            assert!(!highest_q);\n        }\n    }\n}\n\n// Division when n_len >= 2 * d_len - FUDGE.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_div_to_out_unbalanced_ref_val(qs: &mut [Limb], ns: &[Limb], ds: &mut [Limb]) {\n    // ```\n    // |________________________|\n    //                  |_______|\n    // ```\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let highest_d = ds[d_len - 1];\n    let bits = LeadingZeros::leading_zeros(highest_d);\n    if bits == 0 {\n        let highest_q = if d_len == 2 {\n            let mut new_ns = ns.to_vec();\n            limbs_div_mod_by_two_limb_normalized(qs, &mut new_ns, ds)\n        } else if d_len < DC_DIV_Q_THRESHOLD || n_len - d_len < DC_DIV_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n            let mut new_ns = ns.to_vec();\n            limbs_div_schoolbook(qs, &mut new_ns, ds, d_inv)\n        } else if limbs_div_dc_condition(n_len, d_len) {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n            limbs_div_divide_and_conquer(qs, ns, ds, d_inv)\n        } else {\n            let mut scratch = vec![0; limbs_div_barrett_scratch_len(n_len, d_len)];\n            limbs_div_barrett(qs, ns, ds, &mut scratch)\n        };\n        qs[n_len - d_len] = Limb::from(highest_q);\n    } else {\n        let mut scratch = vec![0; n_len + 1];\n        let carry = limbs_shl_to_out(&mut scratch, ns, bits);\n        scratch[n_len] = carry;\n        let new_n_len = if carry == 0 { n_len } else { n_len + 1 };\n        let new_ns = &mut scratch[..new_n_len];\n        limbs_slice_shl_in_place(ds, bits);\n        let highest_q = if d_len == 2 {\n            limbs_div_mod_by_two_limb_normalized(qs, new_ns, ds)\n        } else if d_len < DC_DIV_Q_THRESHOLD || new_n_len - d_len < DC_DIV_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(ds[d_len - 1], ds[d_len - 2]);\n            limbs_div_schoolbook(qs, new_ns, ds, d_inv)\n        } else if limbs_div_dc_condition(n_len, d_len) {\n            let d_inv = limbs_two_limb_inverse_helper(ds[d_len - 1], ds[d_len - 2]);\n            limbs_div_divide_and_conquer(qs, new_ns, ds, d_inv)\n        } else {\n            let mut scratch = vec![0; limbs_div_barrett_scratch_len(new_n_len, d_len)];\n            limbs_div_barrett(qs, new_ns, ds, &mut scratch)\n        };\n        if carry == 0 {\n            qs[n_len - d_len] = Limb::from(highest_q);\n        } else {\n            assert!(!highest_q);\n        }\n    }\n}\n\n// Division when n_len >= 2 * d_len - FUDGE.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_div_to_out_unbalanced_ref_ref(qs: &mut [Limb], ns: &[Limb], ds: &[Limb]) {\n    // ```\n    // |________________________|\n    //                  |_______|\n    // ```\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let highest_d = ds[d_len - 1];\n    let bits = LeadingZeros::leading_zeros(highest_d);\n    if bits == 0 {\n        let highest_q = if d_len == 2 {\n            let mut new_ns = ns.to_vec();\n            limbs_div_mod_by_two_limb_normalized(qs, &mut new_ns, ds)\n        } else if d_len < DC_DIV_Q_THRESHOLD || n_len - d_len < DC_DIV_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n            let mut new_ns = ns.to_vec();\n            limbs_div_schoolbook(qs, &mut new_ns, ds, d_inv)\n        } else if limbs_div_dc_condition(n_len, d_len) {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n            limbs_div_divide_and_conquer(qs, ns, ds, d_inv)\n        } else {\n            let mut scratch = vec![0; limbs_div_barrett_scratch_len(n_len, d_len)];\n            limbs_div_barrett(qs, ns, ds, &mut scratch)\n        };\n        qs[n_len - d_len] = Limb::from(highest_q);\n    } else {\n        let mut scratch = vec![0; n_len + 1];\n        let carry = limbs_shl_to_out(&mut scratch, ns, bits);\n        scratch[n_len] = carry;\n        let new_n_len = if carry == 0 { n_len } else { n_len + 1 };\n        let new_ns = &mut scratch[..new_n_len];\n        let mut new_ds = vec![0; d_len];\n        limbs_shl_to_out(&mut new_ds, ds, bits);\n        let highest_q = if d_len == 2 {\n            limbs_div_mod_by_two_limb_normalized(qs, new_ns, &new_ds)\n        } else if d_len < DC_DIV_Q_THRESHOLD || new_n_len - d_len < DC_DIV_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(new_ds[d_len - 1], new_ds[d_len - 2]);\n            limbs_div_schoolbook(qs, new_ns, &new_ds, d_inv)\n        } else if limbs_div_dc_condition(n_len, d_len) {\n            let d_inv = limbs_two_limb_inverse_helper(new_ds[d_len - 1], new_ds[d_len - 2]);\n            limbs_div_divide_and_conquer(qs, new_ns, &new_ds, d_inv)\n        } else {\n            let mut scratch = vec![0; limbs_div_barrett_scratch_len(new_n_len, d_len)];\n            limbs_div_barrett(qs, new_ns, &new_ds, &mut scratch)\n        };\n        if carry == 0 {\n            qs[n_len - d_len] = Limb::from(highest_q);\n        } else {\n            assert!(!highest_q);\n        }\n    }\n}\n\n// Division when n_len < 2 * d_len - FUDGE.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub_test! {limbs_div_to_out_balanced(qs: &mut [Limb], ns: &[Limb], ds: &[Limb]) {\n    // ```\n    // |________________________|\n    //        |_________________|\n    // ```\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = n_len - d_len + 1;\n    let q_len_plus_1 = q_len + 1;\n    let mut scratch_2 = vec![0; q_len_plus_1];\n    let new_n_len = q_len + q_len_plus_1;\n    let ns_tail = &ns[n_len.checked_sub(new_n_len).unwrap()..];\n    let highest_d = ds[d_len - 1];\n    let bits = LeadingZeros::leading_zeros(highest_d);\n    if bits == 0 {\n        let new_ds = &ds[d_len - q_len_plus_1..];\n        let highest_q = if q_len_plus_1 == 2 {\n            let mut new_ns = ns_tail.to_vec();\n            limbs_div_mod_by_two_limb_normalized(&mut scratch_2, &mut new_ns, new_ds)\n        } else if q_len_plus_1 < DC_DIVAPPR_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, new_ds[q_len - 1]);\n            let mut new_ns = ns_tail.to_vec();\n            limbs_div_schoolbook_approx(&mut scratch_2, &mut new_ns, new_ds, d_inv)\n        } else if q_len_plus_1 < MU_DIVAPPR_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, new_ds[q_len - 1]);\n            let mut new_ns = ns_tail.to_vec();\n            limbs_div_divide_and_conquer_approx(&mut scratch_2, &mut new_ns, new_ds, d_inv)\n        } else {\n            let mut scratch =\n                vec![0; limbs_div_barrett_approx_scratch_len(new_n_len, q_len_plus_1)];\n            limbs_div_barrett_approx(&mut scratch_2, ns_tail, new_ds, &mut scratch)\n        };\n        scratch_2[q_len] = Limb::from(highest_q);\n    } else {\n        let mut scratch = vec![0; n_len + 1];\n        let carry = limbs_shl_to_out(&mut scratch, ns_tail, bits);\n        scratch[new_n_len] = carry;\n        let new_n_len = if carry == 0 { new_n_len } else { new_n_len + 1 };\n        let new_ns = &mut scratch[..new_n_len];\n        let mut new_ds = vec![0; q_len_plus_1];\n        limbs_shl_to_out(&mut new_ds, &ds[d_len - q_len_plus_1..], bits);\n        new_ds[0] |= ds[d_len - q_len_plus_1 - 1] >> (Limb::WIDTH - bits);\n        let highest_q = if q_len_plus_1 == 2 {\n            limbs_div_mod_by_two_limb_normalized(&mut scratch_2, new_ns, &new_ds)\n        } else if q_len_plus_1 < DC_DIVAPPR_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(new_ds[q_len], new_ds[q_len - 1]);\n            limbs_div_schoolbook_approx(&mut scratch_2, new_ns, &new_ds, d_inv)\n        } else if q_len_plus_1 < MU_DIVAPPR_Q_THRESHOLD {\n            let d_inv = limbs_two_limb_inverse_helper(new_ds[q_len], new_ds[q_len - 1]);\n            limbs_div_divide_and_conquer_approx(&mut scratch_2, new_ns, &new_ds, d_inv)\n        } else {\n            let mut scratch =\n                vec![0; limbs_div_barrett_approx_scratch_len(new_n_len, q_len_plus_1)];\n            limbs_div_barrett_approx(&mut scratch_2, new_ns, &new_ds, &mut scratch)\n        };\n        if carry == 0 {\n            scratch_2[q_len] = Limb::from(highest_q);\n        } else if highest_q {\n            fail_on_untested_path(\"limbs_div_to_out_balanced, highest_q\");\n            // This happens only when the quotient is close to B ^ n and one of the approximate\n            // division functions returned B ^ n.\n            for s in &mut scratch_2[..new_n_len - q_len_plus_1] {\n                *s = Limb::MAX;\n            }\n        }\n    }\n    let (scratch_2_head, scratch_2_tail) = scratch_2.split_first().unwrap();\n    qs[..q_len].copy_from_slice(scratch_2_tail);\n    if *scratch_2_head <= 4 {\n        let mut rs = vec![0; n_len + 1];\n        let mut mul_scratch =\n            vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), scratch_2_tail.len())];\n        limbs_mul_greater_to_out(&mut rs, ds, scratch_2_tail, &mut mul_scratch);\n        let r_len = if rs[n_len] == 0 { n_len } else { n_len + 1 };\n        if r_len > n_len || limbs_cmp_same_length(ns, &rs[..n_len]) == Less {\n            assert!(!limbs_sub_limb_in_place(qs, 1));\n        }\n    }\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, returning the quotient. The quotient has `ns.len() - ds.len() + 1`\n// limbs.\n//\n// `ns` must be at least as long as `ds` and `ds` must have length at least 2 and its most\n// significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` has length less than 2, or the most-significant limb of\n// `ds` is zero.\n//\n// This is equivalent to `mpn_div_q` from `mpn/generic/div_q.c`, GMP 6.2.1, where `scratch` is\n// allocated internally and `qp` is returned.\npub_test! {limbs_div(ns: &[Limb], ds: &[Limb]) -> Vec<Limb> {\n    let mut qs = vec![0; ns.len() - ds.len() + 1];\n    limbs_div_to_out_ref_ref(&mut qs, ns, ds);\n    qs\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must have length at least 2 and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` has length less than 2, or the\n// most-significant limb of `ds` is zero.\n//\n// This is equivalent to `mpn_div_q` from `mpn/generic/div_q.c`, GMP 6.2.1, where `scratch` is\n// allocated internally and `np` and `dp` are consumed, saving some memory allocations.\npub_crate_test! {limbs_div_to_out(qs: &mut [Limb], ns: &mut [Limb], ds: &mut [Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(n_len >= d_len);\n    assert!(d_len > 1);\n    assert_ne!(ds[d_len - 1], 0);\n    assert!(FUDGE >= 2);\n    let q_len = n_len - d_len + 1; // Quotient size, high limb might be zero\n    if q_len + FUDGE >= d_len {\n        limbs_div_to_out_unbalanced(qs, ns, ds);\n    } else {\n        limbs_div_to_out_balanced(qs, ns, ds);\n    }\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must have length at least 2 and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` has length less than 2, or the\n// most-significant limb of `ds` is zero.\n//\n// This is equivalent to `mpn_div_q` from `mpn/generic/div_q.c`, GMP 6.2.1, where `scratch` is\n// allocated internally and `np` is consumed, saving some memory allocations.\npub_test! {limbs_div_to_out_val_ref(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(n_len >= d_len);\n    assert!(d_len > 1);\n    assert_ne!(ds[d_len - 1], 0);\n    assert!(FUDGE >= 2);\n    let q_len = n_len - d_len + 1; // Quotient size, high limb might be zero\n    if q_len + FUDGE >= d_len {\n        limbs_div_to_out_unbalanced_val_ref(qs, ns, ds);\n    } else {\n        limbs_div_to_out_balanced(qs, ns, ds);\n    }\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must have length at least 2 and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` has length less than 2, or the\n// most-significant limb of `ds` is zero.\n//\n// This is equivalent to `mpn_div_q` from `mpn/generic/div_q.c`, GMP 6.2.1, where `scratch` is\n// allocated internally and `dp` is consumed, saving some memory allocations.\npub_test! {limbs_div_to_out_ref_val(qs: &mut [Limb], ns: &[Limb], ds: &mut [Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(n_len >= d_len);\n    assert!(d_len > 1);\n    assert_ne!(ds[d_len - 1], 0);\n    assert!(FUDGE >= 2);\n    let q_len = n_len - d_len + 1; // Quotient size, high limb might be zero\n    if q_len + FUDGE >= d_len {\n        limbs_div_to_out_unbalanced_ref_val(qs, ns, ds);\n    } else {\n        limbs_div_to_out_balanced(qs, ns, ds);\n    }\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must have length at least 2 and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` has length less than 2, or the\n// most-significant limb of `ds` is zero.\n//\n// This is equivalent to `mpn_div_q` from `mpn/generic/div_q.c`, GMP 6.2.1, where `scratch` is\n// allocated internally.\npub_test! {limbs_div_to_out_ref_ref(qs: &mut [Limb], ns: &[Limb], ds: &[Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(n_len >= d_len);\n    assert!(d_len > 1);\n    assert_ne!(ds[d_len - 1], 0);\n    assert!(FUDGE >= 2);\n    let q_len = n_len - d_len + 1; // Quotient size, high limb might be zero\n    if q_len + FUDGE >= d_len {\n        limbs_div_to_out_unbalanced_ref_ref(qs, ns, ds);\n    } else {\n        limbs_div_to_out_balanced(qs, ns, ds);\n    }\n}}\n\n// Divides using the naive (schoolbook) algorithm.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n#[cfg(feature = \"test_build\")]\nfn limbs_div_in_place_naive(ns: &mut [Limb], d: Limb) {\n    let limb = DoubleLimb::from(d);\n    let mut upper = 0;\n    for n in ns.iter_mut().rev() {\n        let lower = *n;\n        let (q, r) = DoubleLimb::join_halves(upper, lower).div_rem(limb);\n        *n = q.lower_half();\n        upper = r.lower_half();\n    }\n}\n\n// This is equivalent to `mpn_pi1_bdiv_q_1` from `mpn/generic/bdiv_q_1.c`, GMP 6.2.1, where rp ==\n// up.\npub(crate) fn limbs_hensel_div_limb_in_place(\n    ns: &mut [Limb],\n    d: Limb,\n    d_inv: Limb,\n    shift: u64,\n) -> bool {\n    let n_len = ns.len();\n    assert_ne!(n_len, 0);\n    assert_ne!(d, 0);\n    let mut carry = 0;\n    if shift == 0 {\n        let (ns_head, ns_tail) = ns.split_first_mut().unwrap();\n        let mut l = ns_head.wrapping_mul(d_inv);\n        *ns_head = l;\n        let mut carry_2 = false;\n        for n in ns_tail {\n            let mut carry = Limb::x_mul_y_to_zz(l, d).0;\n            if carry_2 {\n                carry += 1;\n            }\n            (l, carry_2) = n.overflowing_sub(carry);\n            l.wrapping_mul_assign(d_inv);\n            *n = l;\n        }\n        carry_2\n    } else {\n        for i in 0..n_len - 1 {\n            let n = (ns[i] >> shift) | (ns[i + 1] << (Limb::WIDTH - shift));\n            let (mut l, carry_2) = n.overflowing_sub(carry);\n            l.wrapping_mul_assign(d_inv);\n            ns[i] = l;\n            carry = Limb::x_mul_y_to_zz(l, d).0;\n            if carry_2 {\n                carry += 1;\n            }\n        }\n        let ns_last = ns.last_mut().unwrap();\n        let (l, carry_2) = (*ns_last >> shift).overflowing_sub(carry);\n        *ns_last = l.wrapping_mul(d_inv);\n        carry_2\n    }\n}\n\nimpl Natural {\n    fn div_limb_ref(&self, other: Limb) -> Self {\n        match (self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (n, 1) => n.clone(),\n            (Self(Small(small)), other) => Self(Small(small / other)),\n            (Self(Large(limbs)), other) => Self::from_owned_limbs_asc(limbs_div_limb(limbs, other)),\n        }\n    }\n\n    #[cfg(feature = \"test_build\")]\n    #[inline]\n    pub fn div_limb_naive(mut self, other: Limb) -> Self {\n        self.div_assign_limb_naive(other);\n        self\n    }\n\n    fn div_assign_limb(&mut self, other: Limb) {\n        match (&mut *self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (_, 1) => {}\n            (Self(Small(small)), other) => *small /= other,\n            (Self(Large(limbs)), other) => {\n                limbs_div_limb_in_place(limbs, other);\n                self.trim();\n            }\n        }\n    }\n\n    #[cfg(feature = \"test_build\")]\n    pub fn div_assign_limb_naive(&mut self, other: Limb) {\n        match (&mut *self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (_, 1) => {}\n            (Self(Small(small)), other) => {\n                *small /= other;\n            }\n            (Self(Large(limbs)), other) => {\n                limbs_div_in_place_naive(limbs, other);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl Div<Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value. The quotient is rounded\n    /// towards negative infinity. The quotient and remainder (which is not computed) satisfy $x =\n    /// qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Natural::from(23u32) / Natural::from(10u32), 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         / Natural::from_str(\"1234567890987\").unwrap(),\n    ///     810000006723u64\n    /// );\n    /// ```\n    #[inline]\n    fn div(mut self, other: Self) -> Self {\n        self /= other;\n        self\n    }\n}\n\nimpl<'a> Div<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference. The quotient is rounded towards negative infinity. The quotient and remainder\n    /// (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Natural::from(23u32) / &Natural::from(10u32), 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         / &Natural::from_str(\"1234567890987\").unwrap(),\n    ///     810000006723u64\n    /// );\n    /// ```\n    #[inline]\n    fn div(mut self, other: &'a Self) -> Self {\n        self /= other;\n        self\n    }\n}\n\nimpl Div<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value. The quotient is rounded towards negative infinity. The quotient and remainder\n    /// (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Natural::from(23u32) / Natural::from(10u32), 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     &Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         / Natural::from_str(\"1234567890987\").unwrap(),\n    ///     810000006723u64\n    /// );\n    /// ```\n    fn div(self, mut other: Natural) -> Natural {\n        match (self, &mut other) {\n            (_, &mut Natural::ZERO) => panic!(\"division by zero\"),\n            (x, y) if x == y => Natural::ONE,\n            (n, &mut Natural::ONE) => n.clone(),\n            (n, &mut Natural(Small(d))) => n.div_limb_ref(d),\n            (Natural(Small(_)), _) => Natural::ZERO,\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                if ns_len < ds_len {\n                    Natural::ZERO\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_to_out_ref_val(&mut qs, ns, ds);\n                    Natural::from_owned_limbs_asc(qs)\n                }\n            }\n        }\n    }\n}\n\nimpl Div<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference. The quotient is\n    /// rounded towards negative infinity. The quotient and remainder (which is not computed)\n    /// satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Natural::from(23u32) / &Natural::from(10u32), 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     &Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         / &Natural::from_str(\"1234567890987\").unwrap(),\n    ///     810000006723u64\n    /// );\n    /// ```\n    fn div(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (_, &Natural::ZERO) => panic!(\"division by zero\"),\n            (x, y) if x == y => Natural::ONE,\n            (n, &Natural::ONE) => n.clone(),\n            (n, &Natural(Small(d))) => n.div_limb_ref(d),\n            (Natural(Small(_)), _) => Natural::ZERO,\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                if ns.len() < ds.len() {\n                    Natural::ZERO\n                } else {\n                    Natural::from_owned_limbs_asc(limbs_div(ns, ds))\n                }\n            }\n        }\n    }\n}\n\nimpl DivAssign<Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value. The quotient is rounded towards negative infinity. The quotient\n    /// and remainder (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x /= Natural::from(10u32);\n    /// assert_eq!(x, 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x /= Natural::from_str(\"1234567890987\").unwrap();\n    /// assert_eq!(x, 810000006723u64);\n    /// ```\n    fn div_assign(&mut self, other: Self) {\n        match (&mut *self, other) {\n            (_, Self::ZERO) => panic!(\"division by zero\"),\n            (x, y) if *x == y => {\n                *self = Self::ONE;\n            }\n            (_, Self::ONE) => {}\n            (n, Self(Small(d))) => n.div_assign_limb(d),\n            (Self(Small(_)), _) => *self = Self::ZERO,\n            (Self(Large(ns)), Self(Large(mut ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                if ns_len < ds_len {\n                    *self = Self::ZERO;\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_to_out(&mut qs, ns, &mut ds);\n                    swap(&mut qs, ns);\n                    self.trim();\n                }\n            }\n        }\n    }\n}\n\nimpl<'a> DivAssign<&'a Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference. The quotient is rounded towards negative infinity. The\n    /// quotient and remainder (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x /= &Natural::from(10u32);\n    /// assert_eq!(x, 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x /= &Natural::from_str(\"1234567890987\").unwrap();\n    /// assert_eq!(x, 810000006723u64);\n    /// ```\n    fn div_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (_, &Self::ZERO) => panic!(\"division by zero\"),\n            (x, y) if x == y => {\n                *self = Self::ONE;\n            }\n            (_, &Self::ONE) => {}\n            (n, &Self(Small(d))) => n.div_assign_limb(d),\n            (Self(Small(_)), _) => *self = Self::ZERO,\n            (Self(Large(ns)), Self(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                if ns_len < ds_len {\n                    *self = Self::ZERO;\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_to_out_val_ref(&mut qs, ns, ds);\n                    swap(&mut qs, ns);\n                    self.trim();\n                }\n            }\n        }\n    }\n}\n\nimpl CheckedDiv<Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value. The quotient is rounded\n    /// towards negative infinity. The quotient and remainder (which is not computed) satisfy $x =\n    /// qy + r$ and $0 \\leq r < y$. Returns `None` when the second [`Natural`] is zero, `Some`\n    /// otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    ///         \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .checked_div(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"Some(2)\"\n    /// );\n    /// assert_eq!(Natural::ONE.checked_div(Natural::ZERO), None);\n    /// ```\n    #[inline]\n    fn checked_div(self, mut other: Self) -> Option<Self> {\n        match (self, &mut other) {\n            (_, &mut Self::ZERO) => None,\n            (x, y) if x == *y => Some(Self::ONE),\n            (n, &mut Self::ONE) => Some(n),\n            (mut n, &mut Self(Small(d))) => {\n                n.div_assign_limb(d);\n                Some(n)\n            }\n            (Self(Small(_)), _) => Some(Self::ZERO),\n            (Self(Large(mut ns)), Self(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                Some(if ns_len < ds_len {\n                    Self::ZERO\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_to_out(&mut qs, &mut ns, ds);\n                    Self::from_owned_limbs_asc(qs)\n                })\n            }\n        }\n    }\n}\n\nimpl<'a> CheckedDiv<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference. The quotient is rounded towards negative infinity. The quotient and remainder\n    /// (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$. Returns `None` when the\n    /// second [`Natural`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    ///         \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .checked_div(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"Some(2)\"\n    /// );\n    /// assert_eq!(Natural::ONE.checked_div(&Natural::ZERO), None);\n    /// ```\n    #[inline]\n    fn checked_div(self, other: &'a Self) -> Option<Self> {\n        match (self, other) {\n            (_, &Self::ZERO) => None,\n            (x, y) if x == *y => Some(Self::ONE),\n            (n, &Self::ONE) => Some(n.clone()),\n            (mut n, &Self(Small(d))) => {\n                n.div_assign_limb(d);\n                Some(n)\n            }\n            (Self(Small(_)), _) => Some(Self::ZERO),\n            (Self(Large(mut ns)), Self(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                Some(if ns_len < ds_len {\n                    Self::ZERO\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_to_out_val_ref(&mut qs, &mut ns, ds);\n                    Self::from_owned_limbs_asc(qs)\n                })\n            }\n        }\n    }\n}\n\nimpl CheckedDiv<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value. The quotient is rounded towards negative infinity. The quotient and remainder\n    /// (which is not computed) satisfy $x = qy + r$ and $0 \\leq r < y$. Returns `None` when the\n    /// second [`Natural`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    ///         \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .checked_div(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"Some(2)\"\n    /// );\n    /// assert_eq!((&Natural::ONE).checked_div(Natural::ZERO), None);\n    /// ```\n    fn checked_div(self, mut other: Natural) -> Option<Natural> {\n        match (self, &mut other) {\n            (_, &mut Natural::ZERO) => None,\n            (x, y) if x == y => Some(Natural::ONE),\n            (n, &mut Natural::ONE) => Some(n.clone()),\n            (n, &mut Natural(Small(d))) => Some(n.div_limb_ref(d)),\n            (Natural(Small(_)), _) => Some(Natural::ZERO),\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                Some(if ns_len < ds_len {\n                    Natural::ZERO\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_to_out_ref_val(&mut qs, ns, ds);\n                    Natural::from_owned_limbs_asc(qs)\n                })\n            }\n        }\n    }\n}\n\nimpl CheckedDiv<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference. The quotient is\n    /// rounded towards negative infinity. The quotient and remainder (which is not computed)\n    /// satisfy $x = qy + r$ and $0 \\leq r < y$. Returns `None` when the second [`Natural`] is zero,\n    /// `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ) &\n    /// \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .checked_div(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"Some(2)\"\n    /// );\n    /// assert_eq!((&Natural::ONE).checked_div(&Natural::ZERO), None);\n    /// ```\n    fn checked_div(self, other: &Natural) -> Option<Natural> {\n        match (self, other) {\n            (_, &Natural::ZERO) => None,\n            (x, y) if x == y => Some(Natural::ONE),\n            (n, &Natural::ONE) => Some(n.clone()),\n            (n, &Natural(Small(d))) => Some(n.div_limb_ref(d)),\n            (Natural(Small(_)), _) => Some(Natural::ZERO),\n            (Natural(Large(ns)), Natural(Large(ds))) => Some(if ns.len() < ds.len() {\n                Natural::ZERO\n            } else {\n                Natural::from_owned_limbs_asc(limbs_div(ns, ds))\n            }),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_bdiv_q`, `mpn_bdiv_q_itch`, `mpn_binvert`, `mpn_binvert_itch`, `mpn_divexact`,\n//      `mpn_mu_bdiv_q`, `mpn_mu_bdiv_q_itch`, `mpn_dcpi1_bdiv_qr`, `mpn_dcpi1_bdiv_qr_n`,\n//      `mpn_dcpi1_bdiv_qr_n_itch`, and `mpn_sbpi1_bdiv_q` contributed to the GNU project by\n//      Torbjörn Granlund.\n//\n//      `mpn_dcpi1_bdiv_q`, `mpn_dcpi1_bdiv_q_n`, `mpn_dcpi1_bdiv_q_n_itch`, `mpn_dcpi1_bdiv_qr`,\n//      `mpn_dcpi1_bdiv_qr_n`, `mpn_dcpi1_bdiv_qr_n_itch`, and `mpn_sbpi1_bdiv_qr` contributed to\n//      the GNU project by Niels Möller and Torbjörn Granlund.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::conversion::to_twos_complement_limbs::limbs_twos_complement_in_place;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_greater_in_place_left, limbs_slice_add_limb_in_place,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::div::{\n    limbs_div_divisor_of_limb_max_with_carry_in_place,\n    limbs_div_divisor_of_limb_max_with_carry_to_out,\n};\nuse crate::natural::arithmetic::div_mod::MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD;\nuse crate::natural::arithmetic::mul::mul_low::limbs_mul_low_same_length;\nuse crate::natural::arithmetic::mul::mul_mod::{\n    limbs_mul_mod_base_pow_n_minus_1, limbs_mul_mod_base_pow_n_minus_1_next_size,\n    limbs_mul_mod_base_pow_n_minus_1_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len, limbs_mul_to_out,\n    limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::neg::limbs_neg_in_place;\nuse crate::natural::arithmetic::shr::{limbs_shr_to_out, limbs_slice_shr_in_place};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_limb_in_place, limbs_sub_limb_to_out,\n    limbs_sub_same_length_in_place_left, limbs_sub_same_length_to_out,\n    limbs_sub_same_length_to_out_with_overlap, limbs_sub_same_length_with_borrow_in_to_out,\n};\nuse crate::natural::arithmetic::sub_mul::limbs_sub_mul_limb_same_length_in_place_left;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{\n    BINV_NEWTON_THRESHOLD, DC_BDIV_Q_THRESHOLD, DC_BDIV_QR_THRESHOLD, DoubleLimb, Limb,\n    MU_BDIV_Q_THRESHOLD, MU_BDIV_QR_THRESHOLD,\n};\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, max, min};\nuse core::mem::swap;\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    DivExact, DivExactAssign, Parity, ShrRound, ShrRoundAssign, WrappingAddAssign,\n    WrappingMulAssign, WrappingSubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, HasHalf, SplitInHalf};\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::{slice_leading_zeros, slice_set_zero, slice_test_zero};\n\nconst INVERT_LIMB_TABLE_LOG_SIZE: u64 = 7;\n\nconst INVERT_LIMB_TABLE_SIZE: usize = 1 << INVERT_LIMB_TABLE_LOG_SIZE;\n\n// The entry at index `i` is the multiplicative inverse of `2 * i + 1 mod 2 ^ 8`.\nconst INVERT_LIMB_TABLE: [u8; INVERT_LIMB_TABLE_SIZE] = [\n    0x01, 0xab, 0xcd, 0xb7, 0x39, 0xa3, 0xc5, 0xef, 0xf1, 0x1b, 0x3d, 0xa7, 0x29, 0x13, 0x35, 0xdf,\n    0xe1, 0x8b, 0xad, 0x97, 0x19, 0x83, 0xa5, 0xcf, 0xd1, 0xfb, 0x1d, 0x87, 0x09, 0xf3, 0x15, 0xbf,\n    0xc1, 0x6b, 0x8d, 0x77, 0xf9, 0x63, 0x85, 0xaf, 0xb1, 0xdb, 0xfd, 0x67, 0xe9, 0xd3, 0xf5, 0x9f,\n    0xa1, 0x4b, 0x6d, 0x57, 0xd9, 0x43, 0x65, 0x8f, 0x91, 0xbb, 0xdd, 0x47, 0xc9, 0xb3, 0xd5, 0x7f,\n    0x81, 0x2b, 0x4d, 0x37, 0xb9, 0x23, 0x45, 0x6f, 0x71, 0x9b, 0xbd, 0x27, 0xa9, 0x93, 0xb5, 0x5f,\n    0x61, 0x0b, 0x2d, 0x17, 0x99, 0x03, 0x25, 0x4f, 0x51, 0x7b, 0x9d, 0x07, 0x89, 0x73, 0x95, 0x3f,\n    0x41, 0xeb, 0x0d, 0xf7, 0x79, 0xe3, 0x05, 0x2f, 0x31, 0x5b, 0x7d, 0xe7, 0x69, 0x53, 0x75, 0x1f,\n    0x21, 0xcb, 0xed, 0xd7, 0x59, 0xc3, 0xe5, 0x0f, 0x11, 0x3b, 0x5d, 0xc7, 0x49, 0x33, 0x55, 0xff,\n];\n\n// Tests that `INVERT_LIMB_TABLE` is correct.\n#[cfg(feature = \"test_build\")]\npub fn test_invert_limb_table() {\n    for (i, &inv) in INVERT_LIMB_TABLE.iter().enumerate() {\n        let value = (u8::exact_from(i) << 1) + 1;\n        let product = value.wrapping_mul(inv);\n        assert_eq!(\n            product, 1,\n            \"INVERT_LIMB_TABLE gives incorrect inverse, {inv}, for value {value}\",\n        );\n    }\n}\n\n// Finds the inverse of a `Limb` mod `2 ^ Limb::WIDTH`; given x, returns y such that x * y ≡ 1 mod\n// `2 ^ Limb::WIDTH`. This inverse only exists for odd `Limb`s, so `x` must be odd.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `x` is even.\n//\n// This is equivalent to `binvert_limb` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_modular_invert_limb<T: PrimitiveUnsigned>(x: T) -> T\nwhere\n    usize: ExactFrom<T>,\n{\n    assert!(x.odd());\n    let index = (x >> 1u32).mod_power_of_2(INVERT_LIMB_TABLE_LOG_SIZE);\n    let mut inv = T::from(INVERT_LIMB_TABLE[usize::exact_from(index)]);\n    inv = (inv << 1u32).wrapping_sub((inv * inv).wrapping_mul(x));\n    inv = (inv << 1u32).wrapping_sub(inv.wrapping_mul(inv).wrapping_mul(x));\n    if T::WIDTH != u32::WIDTH {\n        assert_eq!(T::WIDTH, u64::WIDTH);\n        inv = (inv << 1u32).wrapping_sub(inv.wrapping_mul(inv).wrapping_mul(x));\n    }\n    inv\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// quotient limbs of the `Natural` divided by a `Limb`. The divisor limb cannot be zero and the limb\n// slice must be nonempty. The `Natural` must be exactly divisible by the `Limb`. If it isn't, the\n// behavior of this function is undefined.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is empty or if `d` is zero.\n//\n// This is equivalent to `mpn_divexact_1` from `mpn/generic/dive_1.c`, GMP 6.2.1, where the result\n// is returned.\npub_test! {limbs_div_exact_limb_no_special_3(ns: &[Limb], d: Limb) -> Vec<Limb> {\n    let mut q = vec![0; ns.len()];\n    limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut q, ns, d);\n    q\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `ns`, `ns` is empty, or if `d` is zero.\n//\n// This is equivalent to `mpn_divexact_1` from `mpn/generic/dive_1.c`, GMP 6.2.1.\npub_test! {limbs_div_exact_limb_to_out_no_special_3<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    out: &mut [T],\n    ns: &[T],\n    d: T,\n) where\n    usize: ExactFrom<T>,\n{\n    assert_ne!(d, T::ZERO);\n    let len = ns.len();\n    assert_ne!(len, 0);\n    let out = &mut out[..len];\n    let (ns_head, ns_tail) = ns.split_first().unwrap();\n    if d.even() {\n        let shift = TrailingZeros::trailing_zeros(d);\n        let shift_complement = T::WIDTH - shift;\n        let shifted_d = d >> shift;\n        let d_inv = limbs_modular_invert_limb(shifted_d);\n        let (out_last, out_init) = out.split_last_mut().unwrap();\n        let mut upper_half = T::ZERO;\n        let mut previous_n = *ns_head;\n        for (out_q, n) in out_init.iter_mut().zip(ns_tail.iter()) {\n            let shifted_n = (previous_n >> shift) | (*n << shift_complement);\n            previous_n = *n;\n            let (diff, carry) = shifted_n.overflowing_sub(upper_half);\n            let q = diff.wrapping_mul(d_inv);\n            *out_q = q;\n            upper_half = (DT::from(q) * DT::from(shifted_d)).upper_half();\n            if carry {\n                upper_half += T::ONE;\n            }\n        }\n        *out_last = (previous_n >> shift)\n            .wrapping_sub(upper_half)\n            .wrapping_mul(d_inv);\n    } else {\n        let d_inv = limbs_modular_invert_limb(d);\n        let (out_head, out_tail) = out.split_first_mut().unwrap();\n        let mut q = ns_head.wrapping_mul(d_inv);\n        *out_head = q;\n        let mut previous_carry = false;\n        for (out_q, n) in out_tail.iter_mut().zip(ns_tail.iter()) {\n            let mut upper_half = (DT::from(q) * DT::from(d)).upper_half();\n            if previous_carry {\n                upper_half += T::ONE;\n            }\n            let diff;\n            (diff, previous_carry) = n.overflowing_sub(upper_half);\n            q = diff.wrapping_mul(d_inv);\n            *out_q = q;\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is empty or if `d` is zero.\n//\n// This is equivalent to `mpn_divexact_1` from `mpn/generic/dive_1.c`, GMP 6.2.1, where `dst ==\n// src`.\npub_test! {limbs_div_exact_limb_in_place_no_special_3(ns: &mut [Limb], d: Limb) {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert_ne!(len, 0);\n    if d.even() {\n        let shift = TrailingZeros::trailing_zeros(d);\n        let shift_complement = Limb::WIDTH - shift;\n        let shifted_d = d >> shift;\n        let d_inv = limbs_modular_invert_limb(shifted_d);\n        let shifted_d = DoubleLimb::from(shifted_d);\n        let mut upper_half = 0;\n        let mut previous_n = ns[0];\n        for i in 1..len {\n            let n = ns[i];\n            let shifted_n = (previous_n >> shift) | (n << shift_complement);\n            previous_n = n;\n            let (diff, carry) = shifted_n.overflowing_sub(upper_half);\n            let q = diff.wrapping_mul(d_inv);\n            ns[i - 1] = q;\n            upper_half = (DoubleLimb::from(q) * shifted_d).upper_half();\n            if carry {\n                upper_half += 1;\n            }\n        }\n        ns[len - 1] = (previous_n >> shift)\n            .wrapping_sub(upper_half)\n            .wrapping_mul(d_inv);\n    } else {\n        let d_inv = limbs_modular_invert_limb(d);\n        let d = DoubleLimb::from(d);\n        let (ns_head, ns_tail) = ns.split_first_mut().unwrap();\n        let mut q = ns_head.wrapping_mul(d_inv);\n        *ns_head = q;\n        let mut previous_carry = false;\n        for n in &mut *ns_tail {\n            let mut upper_half = (DoubleLimb::from(q) * d).upper_half();\n            if previous_carry {\n                upper_half += 1;\n            }\n            let diff;\n            (diff, previous_carry) = n.overflowing_sub(upper_half);\n            q = diff.wrapping_mul(d_inv);\n            *n = q;\n        }\n    }\n}}\n\n#[cfg(feature = \"test_build\")]\npub(crate) const MAX_OVER_3: Limb = Limb::MAX / 3;\n\n#[cfg(not(feature = \"test_build\"))]\nconst MAX_OVER_3: Limb = Limb::MAX / 3;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// quotient limbs of the `Natural` divided by 3. The limb slice must be nonempty. The `Natural` must\n// be exactly divisible by 3. If it isn't, the behavior of this function is undefined.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is empty.\n//\n// This is equivalent to `mpn_divexact_by3c` from `mpn/generic/diveby3.c`, GMP 6.2.1, with\n// `DIVEXACT_BY3_METHOD == 0` and no carry-in, where the result is returned.\npub_test! {limbs_div_exact_3(ns: &[Limb]) -> Vec<Limb> {\n    let mut q = vec![0; ns.len()];\n    limbs_div_exact_3_to_out::<DoubleLimb, Limb>(&mut q, ns);\n    q\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and 3 to an output slice. The output slice must be at\n// least as long as the input slice. The input limb slice must be nonempty. The `Natural` must be\n// exactly divisible by 3. If it isn't, the behavior of this function is undefined.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `ns` or if `ns` is empty.\n//\n// This is equivalent to `mpn_divexact_by3c` from `mpn/generic/diveby3.c`, GMP 6.2.1, with\n// `DIVEXACT_BY3_METHOD == 0`, no carry-in, and no return value.\npub_test! {limbs_div_exact_3_to_out<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    out: &mut [T],\n    ns: &[T],\n) {\n    let (out_last, out_init) = out[..ns.len()].split_last_mut().unwrap();\n    let (ns_last, ns_init) = ns.split_last().unwrap();\n    let max_over_3 = T::MAX / T::from(3u8);\n    let q = limbs_div_divisor_of_limb_max_with_carry_to_out::<DT, T>(\n        out_init,\n        ns_init,\n        max_over_3,\n        T::ZERO,\n    );\n    let lower = (DT::from(*ns_last) * DT::from(max_over_3)).lower_half();\n    *out_last = q.wrapping_sub(lower);\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and 3 to the input slice. The input limb slice must be\n// nonempty. The `Natural` must be exactly divisible by 3. If it isn't, the behavior of this\n// function is undefined.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is empty.\n//\n// This is equivalent to `mpn_divexact_by3c` from `mpn/generic/diveby3.c`, GMP 6.2.1, with\n// `DIVEXACT_BY3_METHOD == 0`, no carry-in, and no return value, where `rp == up`.\npub_crate_test! {limbs_div_exact_3_in_place(ns: &mut [Limb]) {\n    let (ns_last, ns_init) = ns.split_last_mut().unwrap();\n    let q = limbs_div_divisor_of_limb_max_with_carry_in_place(ns_init, MAX_OVER_3, 0);\n    let lower = (DoubleLimb::from(*ns_last) * DoubleLimb::from(MAX_OVER_3)).lower_half();\n    *ns_last = q.wrapping_sub(lower);\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and a `Limb` to an output slice. The output slice must be\n// at least as long as the input slice. The divisor limb cannot be zero and the input limb slice\n// must be nonempty. The `Natural` must be exactly divisible by the `Limb`. If it isn't, the\n// behavior of this function is undefined.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `ns`, `ns` is empty, or if `d` is zero.\n//\n// This is equivalent to `mpn_divexact_1` from `mpn/generic/dive_1.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_exact_limb_to_out<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    out: &mut [T],\n    ns: &[T],\n    d: T,\n) where\n    usize: ExactFrom<T>,\n{\n    if d == T::from(3u8) {\n        limbs_div_exact_3_to_out::<DT, T>(out, ns);\n    } else {\n        limbs_div_exact_limb_to_out_no_special_3::<DT, T>(out, ns, d);\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// quotient limbs of the `Natural` divided by a `Limb`. The divisor limb cannot be zero and the limb\n// slice must be nonempty. The `Natural` must be exactly divisible by the `Limb`. If it isn't, the\n// behavior of this function is undefined.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is empty or if `d` is zero.\n//\n// This is equivalent to `mpn_divexact_1` from `mpn/generic/dive_1.c`, GMP 6.2.1, where the result\n// is returned.\npub_test! {limbs_div_exact_limb(ns: &[Limb], d: Limb) -> Vec<Limb> {\n    if d == 3 {\n        limbs_div_exact_3(ns)\n    } else {\n        limbs_div_exact_limb_no_special_3(ns, d)\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and a `Limb` to the input slice. The divisor limb cannot\n// be zero and the input limb slice must be nonempty. The `Natural` must be exactly divisible by the\n// `Limb`. If it isn't, the behavior of this function is undefined.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is empty or if `d` is zero.\n//\n// This is equivalent to `mpn_divexact_1` from `mpn/generic/dive_1.c`, GMP 6.2.1, where `dest ==\n// src`.\npub_crate_test! {limbs_div_exact_limb_in_place(ns: &mut [Limb], d: Limb) {\n    if d == 3 {\n        limbs_div_exact_3_in_place(ns);\n    } else {\n        limbs_div_exact_limb_in_place_no_special_3(ns, d);\n    }\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// The result is $O(n)$.\n//\n// This is equivalent to `mpn_binvert_itch` from `mpn/generic/binvert.c`, GMP 6.2.1.\npub_crate_test! {limbs_modular_invert_scratch_len(n: usize) -> usize {\n    let itch_local = limbs_mul_mod_base_pow_n_minus_1_next_size(n);\n    let itch_out = limbs_mul_mod_base_pow_n_minus_1_scratch_len(\n        itch_local,\n        n,\n        n.shr_round(1, Ceiling).0,\n    );\n    itch_local + itch_out\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\npub_test! {limbs_modular_invert_small(\n    size: usize,\n    is: &mut [Limb],\n    scratch: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) {\n    if size < DC_BDIV_Q_THRESHOLD {\n        limbs_modular_div_schoolbook(is, scratch, ds, d_inv);\n        limbs_neg_in_place(is);\n    } else {\n        limbs_modular_div_divide_and_conquer(is, scratch, ds, d_inv);\n    }\n}}\n\n// Finds the inverse of a slice `Limb` mod `2 ^ (ds.len() * Limb::WIDTH)`; given x, returns y such\n// that x * y ≡ 1 mod `2 ^ (ds.len() * Limb::WIDTH)`. This inverse only exists for odd x, so the\n// least-significant limb of `ds` must be odd.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// # Panics\n// Panics if `is` is shorter than `ds`, if `ds` is empty, or if `scratch` is too short.\n//\n// This is equivalent to `mpn_binvert` from `mpn/generic/binvert.c`, GMP 6.2.1.\npub_crate_test! {limbs_modular_invert(is: &mut [Limb], ds: &[Limb], scratch: &mut [Limb]) {\n    let d_len = ds.len();\n    // Compute the computation precisions from highest to lowest, leaving the basecase size in\n    // `size`.\n    let mut size = d_len;\n    let mut sizes = Vec::new();\n    while size >= BINV_NEWTON_THRESHOLD {\n        sizes.push(size);\n        size.shr_round_assign(1, Ceiling);\n    }\n    // Compute a base value of `size` limbs.\n    let scratch_lo = &mut scratch[..size];\n    let ds_lo = &ds[..size];\n    slice_set_zero(scratch_lo);\n    scratch_lo[0] = 1;\n    let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n    limbs_modular_invert_small(size, is, scratch_lo, ds_lo, d_inv);\n    let mut previous_size = size;\n    // Use Newton iterations to get the desired precision.\n    for &size in sizes.iter().rev() {\n        let mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(size);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n        let (is_lo, is_hi) = is.split_at_mut(previous_size);\n        limbs_mul_mod_base_pow_n_minus_1(scratch_lo, mul_size, &ds[..size], is_lo, scratch_hi);\n        limbs_sub_limb_to_out(\n            scratch_hi,\n            &scratch_lo[..previous_size - (mul_size - size)],\n            1,\n        );\n        let diff = size - previous_size;\n        limbs_mul_low_same_length(is_hi, &is_lo[..diff], &scratch[previous_size..size]);\n        limbs_twos_complement_in_place(&mut is_hi[..diff]);\n        previous_size = size;\n    }\n}}\n\n// Computes a binary quotient of size `q_len` = `ns.len()` - `ds.len()`. D must be odd. `d_inv` is\n// (-D) ^ -1 mod 2 ^ `Limb::WIDTH`, or `limbs_modular_invert_limb(ds[0]).wrapping_neg()`.\n//\n// Output:\n// ```\n//    Q = N / D mod 2 ^ (`Limb::WIDTH` * `q_len`)\n//    R = (N - Q * D) / 2 ^ (`Limb::WIDTH` * `q_len`)\n// ```\n//\n// Stores the `ds.len()` least-significant limbs of R at `&np[q_len..]` and returns the borrow from\n// the subtraction N - Q * D.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_sbpi1_bdiv_qr` from `mpn/generic/sbpi1_bdiv_qr.c`, GMP 6.2.1.\n// Investigate changes from 6.1.2?\npub_crate_test! {limbs_modular_div_mod_schoolbook(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len > d_len);\n    assert!(ds[0].odd());\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    let mut highest_r = false;\n    // To complete the negation, this value is added to the quotient.\n    let mut lowest_q = true;\n    let mut q_len_s = q_len;\n    while q_len_s > d_len {\n        let q_diff = q_len - q_len_s;\n        for i in q_diff..n_len - q_len_s {\n            let ns = &mut ns[i..i + d_len];\n            let q = d_inv.wrapping_mul(ns[0]);\n            ns[0] = limbs_slice_add_mul_limb_same_length_in_place_left(ns, ds, q);\n            qs[i] = !q;\n        }\n        let (np_lo, np_hi) = ns[q_diff..].split_at_mut(d_len);\n        if limbs_slice_add_greater_in_place_left(&mut np_hi[..q_len_s], np_lo) {\n            highest_r = true;\n        }\n        if lowest_q && !limbs_slice_add_limb_in_place(&mut qs[q_diff..n_len - q_len_s], 1) {\n            lowest_q = false;\n        }\n        q_len_s -= d_len;\n    }\n    let q_len_s = q_len_s;\n    let q_diff = q_len - q_len_s;\n    for i in q_diff..q_len {\n        let ns = &mut ns[i..i + d_len];\n        let q = d_inv.wrapping_mul(ns[0]);\n        ns[0] = limbs_slice_add_mul_limb_same_length_in_place_left(ns, ds, q);\n        qs[i] = !q;\n    }\n    let (np_lo, np_hi) = ns[q_diff..].split_at_mut(d_len);\n    if limbs_slice_add_same_length_in_place_left(&mut np_hi[..q_len_s], &np_lo[..q_len_s]) {\n        assert!(!highest_r);\n        highest_r = true;\n    }\n    if lowest_q && limbs_slice_add_limb_in_place(&mut qs[q_diff..], 1) {\n        // quotient is zero\n        assert!(!highest_r);\n        false\n    } else {\n        let carry = limbs_sub_same_length_in_place_left(&mut ns[q_len..], ds);\n        assert!(carry || !highest_r);\n        carry != highest_r\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\nfn limbs_modular_div_mod_helper(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    len: usize,\n    ds_lo: &[Limb],\n    d_inv: Limb,\n    scratch: &mut [Limb],\n) -> bool {\n    if len < DC_BDIV_QR_THRESHOLD {\n        limbs_modular_div_mod_schoolbook(qs, &mut ns[..len << 1], ds_lo, d_inv)\n    } else {\n        limbs_modular_div_mod_divide_and_conquer_helper(qs, ns, ds_lo, d_inv, scratch)\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// This is equivalent to `mpn_dcpi1_bdiv_qr_n` from `mpn/generic/dcpi1_bdiv_qr.c`, GMP 6.2.1.\nfn limbs_modular_div_mod_divide_and_conquer_helper(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n    scratch: &mut [Limb],\n) -> bool {\n    let n = ds.len();\n    let ns = &mut ns[..n << 1];\n    let scratch = &mut scratch[..n];\n    let lo = n >> 1; // floor(n / 2)\n    let hi = n - lo; // ceil(n / 2)\n    let (ds_lo, ds_hi) = ds.split_at(lo);\n    let carry = limbs_modular_div_mod_helper(qs, ns, lo, ds_lo, d_inv, scratch);\n    let (qs_lo, qs_hi) = qs.split_at_mut(lo);\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds_hi.len(), qs_lo.len())];\n    limbs_mul_greater_to_out(scratch, ds_hi, qs_lo, &mut mul_scratch);\n    if carry {\n        assert!(!limbs_slice_add_limb_in_place(&mut scratch[lo..], 1));\n    }\n    let ns = &mut ns[lo..];\n    let highest_r = limbs_sub_greater_in_place_left(ns, scratch);\n    let (ds_lo, ds_hi) = ds.split_at(hi);\n    let carry = limbs_modular_div_mod_helper(qs_hi, ns, hi, ds_lo, d_inv, scratch);\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(hi, ds_hi.len())];\n    limbs_mul_greater_to_out(scratch, &qs_hi[..hi], ds_hi, &mut mul_scratch);\n    if carry {\n        assert!(!limbs_slice_add_limb_in_place(&mut scratch[hi..], 1));\n    }\n    if limbs_sub_same_length_in_place_left(&mut ns[hi..], scratch) {\n        assert!(!highest_r);\n        true\n    } else {\n        highest_r\n    }\n}\n\n// Computes a binary quotient of size `q_len` = `ns.len()` - `ds.len()` and a remainder of size\n// `rs.len()`. D must be odd. `d_inv` is (-D) ^ -1 mod 2 ^ `Limb::WIDTH`, or\n// `limbs_modular_invert_limb(ds[0]).wrapping_neg()`.\n//\n// Output:\n// ```\n//    Q = N / D mod 2 ^ (`Limb::WIDTH` * `q_len`)\n//    R = (N - Q * D) / 2 ^ (`Limb::WIDTH` * `q_len`)\n// ```\n//\n// Stores the `ds.len()` least-significant limbs of R at `&np[q_len..]` and returns the borrow from\n// the subtraction N - Q * D.\n//\n// # Worst-case complexity\n// $T(n, d) = O(n (\\log d)^2 \\log \\log d)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ns.len()`, and $d$ is `ds.len()`.\n//\n// This is equivalent to `mpn_dcpi1_bdiv_qr` from `mpn/generic/dcpi1_bdiv_qr.c`, GMP 6.2.1.\npub_crate_test! {limbs_modular_div_mod_divide_and_conquer(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 2); // to adhere to limbs_modular_div_mod_schoolbook's limits\n    assert!(n_len > d_len); // to adhere to limbs_modular_div_mod_schoolbook's limits\n    assert!(ds[0].odd());\n    let mut scratch = vec![0; d_len];\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    let mut borrow = false;\n    let mut carry;\n    if q_len > d_len {\n        let q_len_mod_d_len = {\n            let mut m = q_len % d_len;\n            if m == 0 {\n                m = d_len;\n            }\n            m\n        };\n        let (ds_lo, ds_hi) = ds.split_at(q_len_mod_d_len);\n        // Perform the typically smaller block first.\n        carry = limbs_modular_div_mod_helper(qs, ns, q_len_mod_d_len, ds_lo, d_inv, &mut scratch);\n        if q_len_mod_d_len != d_len {\n            let mut mul_scratch =\n                vec![0; limbs_mul_to_out_scratch_len(ds_hi.len(), q_len_mod_d_len)];\n            limbs_mul_to_out(\n                &mut scratch,\n                ds_hi,\n                &qs[..q_len_mod_d_len],\n                &mut mul_scratch,\n            );\n            if carry {\n                assert!(!limbs_slice_add_limb_in_place(\n                    &mut scratch[q_len_mod_d_len..],\n                    1\n                ));\n            }\n            borrow = limbs_sub_greater_in_place_left(&mut ns[q_len_mod_d_len..], &scratch[..d_len]);\n            carry = false;\n        }\n        let mut q_len_s = q_len - q_len_mod_d_len; // q_len_s is a multiple of d_len\n        while q_len_s != 0 {\n            let q_diff = q_len - q_len_s;\n            let ns = &mut ns[q_diff..];\n            if carry && limbs_sub_limb_in_place(&mut ns[d_len..], 1) {\n                assert!(!borrow);\n                borrow = true;\n            }\n            carry = limbs_modular_div_mod_divide_and_conquer_helper(\n                &mut qs[q_diff..],\n                ns,\n                ds,\n                d_inv,\n                &mut scratch,\n            );\n            q_len_s -= d_len;\n        }\n    } else {\n        let (ds_lo, ds_hi) = ds.split_at(q_len);\n        carry = limbs_modular_div_mod_helper(qs, ns, q_len, ds_lo, d_inv, &mut scratch);\n        if q_len != d_len {\n            let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(ds_hi.len(), qs.len())];\n            limbs_mul_to_out(&mut scratch, ds_hi, qs, &mut mul_scratch);\n            if carry {\n                assert!(!limbs_slice_add_limb_in_place(&mut scratch[q_len..], 1));\n            }\n            borrow = limbs_sub_greater_in_place_left(&mut ns[q_len..], &scratch[..d_len]);\n            carry = false;\n        }\n    }\n    if carry {\n        assert!(!borrow);\n        borrow = true;\n    }\n    borrow\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_dcpi1_bdiv_qr_n_itch` from `mpn/generic/dcpi1_bdiv_qr.c`, GMP 6.2.1.\npub_const_test! {limbs_modular_div_mod_divide_and_conquer_helper_scratch_len(n: usize) -> usize {\n    n\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_mu_bdiv_qr_itch` from `mpn/generic/mu_bdiv_qr.c`, GMP 6.2.1.\npub_crate_test! {limbs_modular_div_mod_barrett_scratch_len(n_len: usize, d_len: usize) -> usize {\n    assert!(DC_BDIV_Q_THRESHOLD < MU_BDIV_Q_THRESHOLD);\n    let q_len = n_len - d_len;\n    let i_len = if q_len > d_len {\n        let blocks = (q_len - 1) / d_len + 1; // ceil(q_len / d_len), number of blocks\n        (q_len - 1) / blocks + 1 // ceil(q_len / ceil(q_len / d_len))\n    } else {\n        q_len - (q_len >> 1)\n    };\n    let (mul_len_1, mul_len_2) = if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        (d_len + i_len, 0)\n    } else {\n        let t_len = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n        (\n            t_len,\n            limbs_mul_mod_base_pow_n_minus_1_scratch_len(t_len, d_len, i_len),\n        )\n    };\n    let modular_invert_scratch_len = limbs_modular_invert_scratch_len(i_len);\n    let scratch_len = mul_len_1 + mul_len_2;\n    i_len + max(scratch_len, modular_invert_scratch_len)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_modular_div_mod_barrett_unbalanced(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    let rs = &mut rs[..d_len];\n    // ```\n    // |_______________________| dividend\n    // |________| divisor\n    // ```\n    //\n    // Compute an inverse size that is a nice partition of the quotient.\n    let blocks = (q_len - 1) / d_len + 1; // ceil(q_len / d_len), number of blocks\n    let i_len = (q_len - 1) / blocks + 1; // ceil(q_len / b) = ceil(q_len / ceil(q_len / d_len))\n    let (is, scratch) = scratch.split_at_mut(i_len);\n    limbs_modular_invert(is, &ds[..i_len], scratch);\n    rs.copy_from_slice(&ns[..d_len]);\n    let mut carry = false;\n    let mut q_len_s = q_len;\n    while q_len_s > i_len {\n        let qs = &mut qs[q_len - q_len_s..];\n        let qs = &mut qs[..i_len];\n        let ns = &ns[n_len - q_len_s..];\n        limbs_mul_low_same_length(qs, &rs[..i_len], is);\n        if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs.len())];\n            limbs_mul_greater_to_out(scratch, ds, qs, &mut mul_scratch);\n        } else {\n            let mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n            limbs_mul_mod_base_pow_n_minus_1(scratch_lo, mul_size, ds, qs, scratch_hi);\n            if let Some(wrapped_len) = (d_len + i_len).checked_sub(mul_size) {\n                if wrapped_len != 0 {\n                    let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n                    if limbs_sub_same_length_to_out(\n                        scratch_hi,\n                        &scratch_lo[..wrapped_len],\n                        &rs[..wrapped_len],\n                    ) {\n                        assert!(!limbs_sub_limb_in_place(&mut scratch[wrapped_len..], 1));\n                    }\n                }\n            } else {\n                fail_on_untested_path(\n                    \"limbs_modular_div_mod_barrett_unbalanced, wrapped_len is None\",\n                );\n            }\n        }\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(d_len);\n        if d_len != i_len {\n            let (rp_lo, rp_hi) = rs.split_at_mut(i_len);\n            if limbs_sub_same_length_to_out(rp_lo, &rp_hi[..d_len - i_len], &scratch_lo[i_len..]) {\n                if carry {\n                    assert!(!limbs_slice_add_limb_in_place(scratch_hi, 1));\n                } else {\n                    carry = true;\n                }\n            }\n        }\n        carry = limbs_sub_same_length_with_borrow_in_to_out(\n            &mut rs[d_len - i_len..],\n            &ns[..i_len],\n            &scratch_hi[..i_len],\n            carry,\n        );\n        q_len_s -= i_len;\n    }\n    // high q_len quotient limbs\n    let qs = &mut qs[q_len - q_len_s..];\n    limbs_mul_low_same_length(qs, &rs[..q_len_s], &is[..q_len_s]);\n    if q_len_s < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs.len())];\n        limbs_mul_greater_to_out(scratch, ds, qs, &mut mul_scratch);\n    } else {\n        let tn = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(tn);\n        limbs_mul_mod_base_pow_n_minus_1(scratch_lo, tn, ds, qs, scratch_hi);\n        if let Some(wrapped_len) = (d_len + q_len_s).checked_sub(tn)\n            && wrapped_len != 0\n        {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(tn);\n            if limbs_sub_same_length_to_out(\n                scratch_hi,\n                &scratch_lo[..wrapped_len],\n                &rs[..wrapped_len],\n            ) {\n                assert!(!limbs_sub_limb_in_place(&mut scratch[wrapped_len..], 1));\n            }\n        }\n    }\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(d_len);\n    if d_len != q_len_s && limbs_sub_same_length_to_out_with_overlap(rs, &scratch_lo[q_len_s..]) {\n        if carry {\n            assert!(!limbs_slice_add_limb_in_place(scratch_hi, 1));\n        } else {\n            carry = true;\n        }\n    }\n    limbs_sub_same_length_with_borrow_in_to_out(\n        &mut rs[d_len - q_len_s..],\n        &ns[n_len - q_len_s..],\n        &scratch_hi[..q_len_s],\n        carry,\n    )\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_modular_div_mod_barrett_balanced(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    let rs = &mut rs[..d_len];\n    // ```\n    // |_______________________| dividend\n    // |________________| divisor\n    // ```\n    //\n    // Compute a half-sized inverse.\n    let i_len = q_len - (q_len >> 1);\n    let (is, scratch) = scratch.split_at_mut(i_len);\n    let (qs_lo, qs_hi) = qs.split_at_mut(i_len);\n    limbs_modular_invert(is, &ds[..i_len], scratch);\n    limbs_mul_low_same_length(qs_lo, &ns[..i_len], is); // low i_len quotient limbs\n    if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs_lo.len())];\n        limbs_mul_greater_to_out(scratch, ds, qs_lo, &mut mul_scratch);\n    } else {\n        let mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n        limbs_mul_mod_base_pow_n_minus_1(scratch_lo, mul_size, ds, qs_lo, scratch_hi);\n        if let Some(wrapped_len) = (d_len + i_len).checked_sub(mul_size)\n            && wrapped_len != 0\n        {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n            if limbs_sub_same_length_to_out(\n                scratch_hi,\n                &scratch_lo[..wrapped_len],\n                &ns[..wrapped_len],\n            ) {\n                assert!(!limbs_sub_limb_in_place(&mut scratch[wrapped_len..], 1));\n            }\n        }\n    }\n    let q_len_s = q_len - i_len;\n    let (ns_lo, ns_hi) = ns.split_at(i_len + d_len);\n    let mut carry =\n        limbs_sub_same_length_to_out(rs, &ns_lo[i_len..], &scratch[i_len..i_len + d_len]);\n    // high q_len quotient limbs\n    limbs_mul_low_same_length(qs_hi, &rs[..q_len_s], &is[..q_len_s]);\n    if q_len_s < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs_hi.len())];\n        limbs_mul_greater_to_out(scratch, ds, qs_hi, &mut mul_scratch);\n    } else {\n        let mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n        limbs_mul_mod_base_pow_n_minus_1(scratch_lo, mul_size, ds, qs_hi, scratch_hi);\n        if let Some(wrapped_len) = (d_len + q_len_s).checked_sub(mul_size)\n            && wrapped_len != 0\n        {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n            if limbs_sub_same_length_to_out(\n                scratch_hi,\n                &scratch_lo[..wrapped_len],\n                &rs[..wrapped_len],\n            ) {\n                assert!(!limbs_sub_limb_in_place(&mut scratch[wrapped_len..], 1));\n            }\n        }\n    }\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(d_len);\n    if limbs_sub_same_length_to_out_with_overlap(rs, &scratch_lo[q_len_s..]) {\n        if carry {\n            assert!(!limbs_slice_add_limb_in_place(scratch_hi, 1));\n        } else {\n            carry = true;\n        }\n    }\n    limbs_sub_same_length_with_borrow_in_to_out(\n        &mut rs[d_len - q_len_s..],\n        ns_hi,\n        &scratch_hi[..q_len_s],\n        carry,\n    )\n}\n\n// Computes a binary quotient of size `q_len` = `ns.len()` - `ds.len()` and a remainder of size\n// `ds.len()`. D must be odd.\n//\n// Output:\n// ```\n//    Q = N / D mod 2 ^ (`Limb::WIDTH` * `q_len`)\n//    R = (N - Q * D) / 2 ^ (`Limb::WIDTH` * `q_len`)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 2, `ns.len()` is less than `ds.len()` + 2, `qs` has length\n// less than `ns.len()` - `ds.len()`, `rs` is shorter than `ds`, `scratch` is to short, or the last\n// limb of `ds` is even.\n//\n// This is equivalent to `mpn_mu_bdiv_qr` from `mpn/generic/mu_bdiv_qr.c`, GMP 6.2.1.\npub_crate_test! {limbs_modular_div_mod_barrett(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 2);\n    assert!(n_len >= d_len + 2);\n    if n_len > d_len << 1 {\n        limbs_modular_div_mod_barrett_unbalanced(qs, rs, ns, ds, scratch)\n    } else {\n        limbs_modular_div_mod_barrett_balanced(qs, rs, ns, ds, scratch)\n    }\n}}\n\n// Computes Q = -N/D mod B^un, destroys N.\n//\n// D must be odd. d_inv is (-D)^-1 mod B.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_sbpi1_bdiv_q` from `mpn/generic/sbpi1_bdiv_q.c`, GMP 6.2.1.\npub_crate_test! {limbs_modular_div_schoolbook(\n    mut qs: &mut [Limb],\n    mut ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert!(ds[0].odd());\n    if n_len > d_len {\n        let mut carry = 0;\n        let limit = n_len - d_len - 1;\n        for i in 0..limit {\n            let (ns_lo, ns_hi) = ns[i..].split_at_mut(d_len);\n            let q = d_inv.wrapping_mul(ns_lo[0]);\n            let mut hi = limbs_slice_add_mul_limb_same_length_in_place_left(ns_lo, ds, q);\n            assert_eq!(ns_lo[0], 0);\n            qs[i] = q;\n            let mut carry_b;\n            (hi, carry_b) = hi.overflowing_add(carry);\n            carry = Limb::from(carry_b);\n            (hi, carry_b) = hi.overflowing_add(ns_hi[0]);\n            if carry_b {\n                carry += 1;\n            }\n            ns_hi[0] = hi;\n        }\n        ns = &mut ns[limit..];\n        qs = &mut qs[limit..];\n        let q = d_inv.wrapping_mul(ns[0]);\n        let (ns_lo, ns_hi) = ns.split_at_mut(d_len);\n        let hi = carry.wrapping_add(limbs_slice_add_mul_limb_same_length_in_place_left(\n            ns_lo, ds, q,\n        ));\n        qs[0] = q;\n        ns_hi[0].wrapping_add_assign(hi);\n        ns = &mut ns[1..];\n        qs = &mut qs[1..];\n    }\n    let ns = &mut ns[..d_len];\n    for i in 0..d_len - 1 {\n        let ns_hi = &mut ns[i..];\n        let q = d_inv.wrapping_mul(ns_hi[0]);\n        limbs_slice_add_mul_limb_same_length_in_place_left(ns_hi, &ds[..d_len - i], q);\n        qs[i] = q;\n    }\n    let last_index = d_len - 1;\n    qs[last_index] = d_inv.wrapping_mul(ns[last_index]);\n}}\n\n// This is equivalent to `mpn_sbpi1_bdiv_q` from `mpn/generic/sbpi1_bdiv_q.c`, GMP 6.2.1, where qp\n// == up.\npub fn limbs_modular_div_schoolbook_in_place(mut ns: &mut [Limb], ds: &[Limb], d_inv: Limb) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert!(ds[0].odd());\n    if n_len > d_len {\n        let mut carry = 0;\n        let limit = n_len - d_len - 1;\n        for i in 0..limit {\n            let (ns_lo, ns_hi) = ns[i..].split_at_mut(d_len);\n            let q = d_inv.wrapping_mul(ns_lo[0]);\n            let mut hi = limbs_slice_add_mul_limb_same_length_in_place_left(ns_lo, ds, q);\n            assert_eq!(ns_lo[0], 0);\n            ns_lo[0] = q;\n            let mut carry_b;\n            (hi, carry_b) = hi.overflowing_add(carry);\n            carry = Limb::from(carry_b);\n            (hi, carry_b) = hi.overflowing_add(ns_hi[0]);\n            if carry_b {\n                carry += 1;\n            }\n            ns_hi[0] = hi;\n        }\n        ns = &mut ns[limit..];\n        let q = d_inv.wrapping_mul(ns[0]);\n        let (ns_lo, ns_hi) = ns.split_at_mut(d_len);\n        let hi = carry + limbs_slice_add_mul_limb_same_length_in_place_left(ns_lo, ds, q);\n        ns_lo[0] = q;\n        ns_hi[0].wrapping_add_assign(hi);\n        ns = &mut ns[1..];\n    }\n    let ns = &mut ns[..d_len];\n    for i in 0..d_len - 1 {\n        let ns_hi = &mut ns[i..];\n        let q = d_inv.wrapping_mul(ns_hi[0]);\n        limbs_slice_add_mul_limb_same_length_in_place_left(ns_hi, &ds[..d_len - i], q);\n        ns_hi[0] = q;\n    }\n    let last_index = d_len - 1;\n    ns[last_index].wrapping_mul_assign(d_inv);\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_dcpi1_bdiv_q_n_itch` from `mpn/generic/dcpi1_bdiv_q.c`, GMP 6.2.1.\npub_const_test! {limbs_modular_div_divide_and_conquer_helper_scratch_len(n: usize) -> usize {\n    n\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// This is equivalent to `mpn_dcpi1_bdiv_q_n` from `mpn/generic/dcpi1_bdiv_q.c`, GMP 6.2.1.\n// Investigate changes from 6.1.2?\nfn limbs_modular_div_divide_and_conquer_helper(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n    scratch: &mut [Limb],\n) {\n    let n = ds.len();\n    let mut n_rem = n;\n    while n_rem >= DC_BDIV_Q_THRESHOLD {\n        let m = n - n_rem;\n        let lo = n_rem >> 1; // floor(n / 2)\n        let hi = n_rem - lo; // ceil(n / 2)\n        let qs = &mut qs[m..];\n        let ns = &mut ns[m..];\n        let carry_1 =\n            limbs_modular_div_mod_divide_and_conquer_helper(qs, ns, &ds[..lo], d_inv, scratch);\n        let qs = &qs[..lo];\n        limbs_mul_low_same_length(scratch, qs, &ds[hi..n_rem]);\n        limbs_sub_same_length_in_place_left(&mut ns[hi..n_rem], &scratch[..lo]);\n        if lo < hi {\n            let carry_2 =\n                limbs_sub_mul_limb_same_length_in_place_left(&mut ns[lo..lo << 1], qs, ds[lo]);\n            let n_limb = &mut ns[n_rem - 1];\n            n_limb.wrapping_sub_assign(carry_2);\n            if carry_1 {\n                n_limb.wrapping_sub_assign(1);\n            }\n        }\n        n_rem = hi;\n    }\n    let m = n - n_rem;\n    limbs_modular_div_schoolbook(&mut qs[m..], &mut ns[m..n], &ds[..n_rem], d_inv);\n    limbs_neg_in_place(&mut qs[m..]);\n}\n\n// Computes Q = N / D mod 2 ^ (`Limb::WIDTH` * `ns.len()`), destroying N. D must be odd. `d_inv` is\n// (-D) ^ -1 mod 2 ^ `Limb::WIDTH`, or `limbs_modular_invert_limb(ds[0]).wrapping_neg()`.\n//\n// # Worst-case complexity\n// $T(n, d) = O(n (\\log d)^2 \\log \\log d)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ns.len()`, and $d$ is `ds.len()`.\n//\n// This is equivalent to `mpn_dcpi1_bdiv_q` from `mpn/generic/dcpi1_bdiv_q.c`, GMP 6.2.1.\n// Investigate changes from 6.1.2?\npub_test! {limbs_modular_div_divide_and_conquer(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 2);\n    assert!(n_len >= d_len);\n    assert!(ds[0].odd());\n    if n_len > d_len {\n        let n_len_mod_d_len = {\n            let mut m = n_len % d_len;\n            if m == 0 {\n                m = d_len;\n            }\n            m\n        };\n        let mut scratch = vec![0; d_len];\n        // Perform the typically smaller block first.\n        let (ds_lo, ds_hi) = ds.split_at(n_len_mod_d_len);\n        let mut carry = if n_len_mod_d_len < DC_BDIV_QR_THRESHOLD {\n            limbs_modular_div_mod_schoolbook(qs, &mut ns[..n_len_mod_d_len << 1], ds_lo, d_inv)\n        } else {\n            limbs_modular_div_mod_divide_and_conquer_helper(qs, ns, ds_lo, d_inv, &mut scratch)\n        };\n        if n_len_mod_d_len != d_len {\n            let mut mul_scratch =\n                vec![0; limbs_mul_to_out_scratch_len(ds_hi.len(), n_len_mod_d_len)];\n            limbs_mul_to_out(\n                &mut scratch,\n                ds_hi,\n                &qs[..n_len_mod_d_len],\n                &mut mul_scratch,\n            );\n            if carry {\n                assert!(!limbs_slice_add_limb_in_place(\n                    &mut scratch[n_len_mod_d_len..],\n                    1\n                ));\n            }\n            limbs_sub_greater_in_place_left(&mut ns[n_len_mod_d_len..], &scratch[..d_len]);\n            carry = false;\n        }\n        let mut m = n_len_mod_d_len;\n        let diff = n_len - d_len;\n        while m != diff {\n            if carry {\n                limbs_sub_limb_in_place(&mut ns[m + d_len..], 1);\n            }\n            carry = limbs_modular_div_mod_divide_and_conquer_helper(\n                &mut qs[m..],\n                &mut ns[m..],\n                ds,\n                d_inv,\n                &mut scratch,\n            );\n            m += d_len;\n        }\n        limbs_modular_div_divide_and_conquer_helper(\n            &mut qs[diff..],\n            &mut ns[diff..],\n            ds,\n            d_inv,\n            &mut scratch,\n        );\n    } else if n_len < DC_BDIV_Q_THRESHOLD {\n        limbs_modular_div_schoolbook(qs, ns, ds, d_inv);\n        limbs_neg_in_place(qs);\n    } else {\n        let mut scratch = vec![0; n_len];\n        limbs_modular_div_divide_and_conquer_helper(qs, ns, ds, d_inv, &mut scratch);\n    }\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_mu_bdiv_q_itch` from `mpn/generic/mu_bdiv_q.c`, GMP 6.2.1.\npub_test! {limbs_modular_div_barrett_scratch_len(n_len: usize, d_len: usize) -> usize {\n    assert!(DC_BDIV_Q_THRESHOLD < MU_BDIV_Q_THRESHOLD);\n    let i_len;\n    let mul_len = if n_len > d_len {\n        let blocks = (n_len - 1) / d_len + 1; // ceil(q_len / d_len), number of blocks\n        i_len = (n_len - 1) / blocks + 1; // ceil(q_len / b) = ceil(q_len / ceil(q_len / d_len))\n        let (mul_len_1, mul_len_2) = if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n            (d_len + i_len, 0)\n        } else {\n            let mul_len_1 = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n            (\n                mul_len_1,\n                limbs_mul_mod_base_pow_n_minus_1_scratch_len(mul_len_1, d_len, i_len),\n            )\n        };\n        d_len + mul_len_1 + mul_len_2\n    } else {\n        i_len = n_len - (n_len >> 1);\n        let (mul_len_1, mul_len_2) = if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n            (n_len + i_len, 0)\n        } else {\n            let mul_len_1 = limbs_mul_mod_base_pow_n_minus_1_next_size(n_len);\n            (\n                mul_len_1,\n                limbs_mul_mod_base_pow_n_minus_1_scratch_len(mul_len_1, n_len, i_len),\n            )\n        };\n        mul_len_1 + mul_len_2\n    };\n    let invert_len = limbs_modular_invert_scratch_len(i_len);\n    i_len + max(mul_len, invert_len)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_modular_div_barrett_greater(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    // ```\n    // |_______________________| dividend\n    // |________| divisor\n    // ```\n    //\n    // Compute an inverse size that is a nice partition of the quotient.\n    let blocks = (n_len - 1) / d_len + 1; // ceil(q_len / d_len), number of blocks\n    let i_len = (n_len - 1) / blocks + 1; // ceil(q_len / b) = ceil(q_len / ceil(q_len / d_len))\n    let (is, rs) = scratch.split_at_mut(i_len);\n    limbs_modular_invert(is, &ds[..i_len], rs);\n    let mut carry = false;\n    let (rs, scratch) = rs.split_at_mut(d_len);\n    rs.copy_from_slice(&ns[..d_len]);\n    limbs_mul_low_same_length(qs, &rs[..i_len], is);\n    let mut n_len_s = n_len;\n    let limit = i_len << 1;\n    while n_len_s > limit {\n        let diff = n_len - n_len_s;\n        let (qs_lo, qs_hi) = qs[diff..].split_at_mut(i_len);\n        if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n            let mut mul_scratch =\n                vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs_lo.len())];\n            limbs_mul_greater_to_out(scratch, ds, qs_lo, &mut mul_scratch);\n        } else {\n            let mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n            limbs_mul_mod_base_pow_n_minus_1(scratch_lo, mul_size, ds, qs_lo, scratch_hi);\n            if let Some(wrapped_len) = (d_len + i_len).checked_sub(mul_size) {\n                if wrapped_len != 0 {\n                    let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n                    if limbs_sub_same_length_to_out(\n                        scratch_hi,\n                        &scratch_lo[..wrapped_len],\n                        &rs[..wrapped_len],\n                    ) {\n                        assert!(!limbs_sub_limb_in_place(&mut scratch[wrapped_len..], 1));\n                    }\n                }\n            } else {\n                fail_on_untested_path(\"limbs_modular_div_mod_barrett_greater, wrapped_len is None\");\n            }\n        }\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(d_len);\n        if d_len != i_len {\n            let (rs_lo, rs_hi) = rs.split_at_mut(i_len);\n            if limbs_sub_same_length_to_out(rs_lo, &rs_hi[..d_len - i_len], &scratch_lo[i_len..]) {\n                if carry {\n                    assert!(!limbs_slice_add_limb_in_place(scratch_hi, 1));\n                } else {\n                    carry = true;\n                }\n            }\n        }\n        let ns = &ns[diff + d_len..];\n        carry = limbs_sub_same_length_with_borrow_in_to_out(\n            &mut rs[d_len - i_len..],\n            &ns[..i_len],\n            &scratch_hi[..i_len],\n            carry,\n        );\n        limbs_mul_low_same_length(qs_hi, &rs[..i_len], is);\n        n_len_s -= i_len;\n    }\n    let n_len_s = n_len_s;\n    let diff = n_len - n_len_s;\n    let (qs_lo, qs_hi) = qs[diff..].split_at_mut(i_len);\n    // Generate last q_len limbs.\n    if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs_lo.len())];\n        limbs_mul_greater_to_out(scratch, ds, qs_lo, &mut mul_scratch);\n    } else {\n        let mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n        limbs_mul_mod_base_pow_n_minus_1(scratch_lo, mul_size, ds, qs_lo, scratch_hi);\n        if let Some(wrapped_len) = (d_len + i_len).checked_sub(mul_size)\n            && wrapped_len != 0\n        {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n            if limbs_sub_same_length_to_out(\n                scratch_hi,\n                &scratch_lo[..wrapped_len],\n                &rs[..wrapped_len],\n            ) {\n                assert!(!limbs_sub_limb_in_place(&mut scratch[wrapped_len..], 1));\n            }\n        }\n    }\n    if d_len != i_len {\n        let (rs_lo, rs_hi) = rs.split_at_mut(i_len);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(d_len);\n        if limbs_sub_same_length_to_out(rs_lo, rs_hi, &scratch_lo[i_len..]) {\n            if carry {\n                assert!(!limbs_slice_add_limb_in_place(scratch_hi, 1));\n            } else {\n                carry = true;\n            }\n        }\n    }\n    limbs_sub_same_length_with_borrow_in_to_out(\n        &mut rs[d_len - i_len..],\n        &ns[diff + d_len..],\n        &scratch[d_len..n_len_s],\n        carry,\n    );\n    let limit = n_len_s - i_len;\n    limbs_mul_low_same_length(qs_hi, &rs[..limit], &is[..limit]);\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_modular_div_barrett_same_length(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n_len = ns.len();\n    // ```\n    // |________________| dividend\n    // |________________| divisor\n    // ```\n    //\n    // Compute a half-sized inverse.\n    let i_len = n_len - (n_len >> 1);\n    let (is, scratch) = scratch.split_at_mut(i_len);\n    limbs_modular_invert(is, &ds[..i_len], scratch);\n    let (ns_lo, ns_hi) = ns.split_at(i_len);\n    limbs_mul_low_same_length(qs, ns_lo, is); // low i_len quotient limbs\n    let (qs_lo, qs_hi) = qs.split_at_mut(i_len);\n    if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs_lo.len())];\n        limbs_mul_greater_to_out(scratch, ds, qs_lo, &mut mul_scratch);\n    } else {\n        let mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(n_len);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(mul_size);\n        limbs_mul_mod_base_pow_n_minus_1(scratch_lo, mul_size, ds, qs_lo, scratch_hi);\n        if let Some(wrapped_len) = (n_len + i_len).checked_sub(mul_size) {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(wrapped_len);\n            if wrapped_len != 0 && limbs_cmp_same_length(scratch_lo, &ns[..wrapped_len]) == Less {\n                assert!(!limbs_sub_limb_in_place(scratch_hi, 1));\n            }\n        } else {\n            fail_on_untested_path(\"limbs_modular_div_mod_barrett_same_length, wrapped_len is None\");\n        }\n    }\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(i_len);\n    let diff = n_len - i_len;\n    limbs_sub_same_length_to_out(scratch_lo, ns_hi, &scratch_hi[..diff]);\n    // high n_len - i_len quotient limbs\n    limbs_mul_low_same_length(qs_hi, &scratch[..diff], &is[..diff]);\n}\n\n// Computes Q = N / D mod 2 ^ (`Limb::WIDTH` * `ns.len()`). D must be odd.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mu_bdiv_q` from `mpn/generic/mu_bdiv_q.c`, GMP 6.2.1.\npub_test! {limbs_modular_div_barrett(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb]\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 2);\n    assert!(n_len >= d_len);\n    if n_len > d_len {\n        limbs_modular_div_barrett_greater(qs, ns, ds, scratch);\n    } else {\n        limbs_modular_div_barrett_same_length(qs, ns, ds, scratch);\n    }\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_bdiv_q_itch` from `mpn/generic/bdiv_q.c`, GMP 6.2.1, where nothing is\n// allocated for inputs that are too small for Barrett division. Investigate changes from 6.1.2?\npub_test! {limbs_modular_div_scratch_len(n_len: usize, d_len: usize) -> usize {\n    if d_len < MU_BDIV_Q_THRESHOLD {\n        0\n    } else {\n        limbs_modular_div_barrett_scratch_len(n_len, d_len)\n    }\n}}\n\n// Computes Q = N / D mod 2 ^ (`Limb::WIDTH` * `ns.len()`), taking N by value. D must be odd.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_bdiv_q` from `mpn/generic/bdiv_q.c`, GMP 6.2.1. Investigate changes\n// from 6.1.2?\npub_test! {limbs_modular_div(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb], scratch: &mut [Limb]) {\n    let d_len = ds.len();\n    if d_len < DC_BDIV_Q_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_schoolbook(qs, ns, ds, d_inv);\n        limbs_neg_in_place(qs);\n    } else if d_len < MU_BDIV_Q_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_divide_and_conquer(qs, ns, ds, d_inv);\n    } else {\n        limbs_modular_div_barrett(qs, ns, ds, scratch);\n    }\n}}\n\n// This is equivalent to `mpn_bdiv_qr` from `mpn/generic/bdiv_qr.c` GMP 6.3.0.\npub(crate) fn limbs_modular_div_mod(\n    qp: &mut [Limb], // Quotient output\n    rp: &mut [Limb], // Remainder output\n    np: &[Limb],     // Dividend\n    dp: &[Limb],     // Divisor\n    tp: &mut [Limb], // Scratch workspace\n) -> bool {\n    let nn = np.len();\n    let dn = dp.len();\n    assert!(nn > dn, \"Dividend must be larger than divisor\");\n\n    let rh: bool;\n\n    if dn < DC_BDIV_QR_THRESHOLD || (nn - dn) < DC_BDIV_QR_THRESHOLD {\n        // **Small divisor case: Use simple binary division**\n        //\n        // Copy dividend to scratch space for in-place computation\n        tp[..nn].copy_from_slice(np);\n\n        // Compute modular inverse: di = -D[0]^(-1) mod B\n        let mut di = limbs_modular_invert_limb(dp[0]);\n        di = di.wrapping_neg(); // Negate the inverse\n\n        // Perform simple binary division with precomputed inverse\n        rh = limbs_modular_div_mod_schoolbook(qp, &mut tp[..nn], dp, di);\n\n        // Extract remainder from high limbs of temp buffer\n        rp.copy_from_slice(&tp[nn - dn..nn]);\n    } else if dn < MU_BDIV_QR_THRESHOLD {\n        // **Medium divisor case: Use divide-and-conquer binary division**\n        //\n        // Copy dividend to scratch space\n        tp[..nn].copy_from_slice(np);\n\n        // Compute modular inverse\n        let mut di = limbs_modular_invert_limb(dp[0]);\n        di = di.wrapping_neg();\n\n        // Perform divide-and-conquer binary division\n        rh = limbs_modular_div_mod_divide_and_conquer(qp, &mut tp[..nn], dp, di);\n\n        // Extract remainder\n        rp.copy_from_slice(&tp[nn - dn..nn]);\n    } else {\n        // **Large divisor case: Use μ-division algorithm**\n        rh = limbs_modular_div_mod_barrett(qp, rp, np, dp, tp);\n    }\n    rh\n}\n\n// This is equivalent to `mpn_bdiv_qr_itch` from `mpn/generic/bdiv_qr.c`, GMP 6.3.0.\npub(crate) fn limbs_modular_div_mod_scratch_len(nn: usize, dn: usize) -> usize {\n    if dn < MU_BDIV_QR_THRESHOLD {\n        return nn;\n    }\n    limbs_modular_div_mod_barrett_scratch_len(nn, dn)\n}\n\n// This is equivalent to `mpn_bdiv_qr_wrap` from `mpn/generic/remove.c`, GMP 6.3.0.\npub(crate) fn limbs_modular_div_mod_wrap(\n    qp: &mut [Limb], // Quotient output\n    rp: &mut [Limb], // Remainder output\n    np: &[Limb],     // Dividend\n    dp: &[Limb],     // Divisor\n) {\n    // Calculate required scratch space\n    let scratch_size = limbs_modular_div_mod_scratch_len(np.len(), dp.len());\n    let mut scratch = vec![0; scratch_size];\n\n    // Perform the division\n    limbs_modular_div_mod(qp, rp, np, dp, &mut scratch);\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_bdiv_q_itch` from `mpn/generic/bdiv_q.c`, GMP 6.2.1.\npub_test! {limbs_modular_div_ref_scratch_len(n_len: usize, d_len: usize) -> usize {\n    if d_len < MU_BDIV_Q_THRESHOLD {\n        n_len\n    } else {\n        limbs_modular_div_barrett_scratch_len(n_len, d_len)\n    }\n}}\n\n// Computes Q = N / D mod 2 ^ (`Limb::WIDTH` * `ns.len()`), taking N by reference. D must be odd.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_bdiv_q` from `mpn/generic/bdiv_q.c`, GMP 6.2.1.\npub_test! {limbs_modular_div_ref(qs: &mut [Limb], ns: &[Limb], ds: &[Limb], scratch: &mut [Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    if d_len < DC_BDIV_Q_THRESHOLD {\n        let scratch = &mut scratch[..n_len];\n        scratch.copy_from_slice(ns);\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_schoolbook(qs, scratch, ds, d_inv);\n        limbs_neg_in_place(qs);\n    } else if d_len < MU_BDIV_Q_THRESHOLD {\n        let scratch = &mut scratch[..n_len];\n        scratch.copy_from_slice(ns);\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_divide_and_conquer(qs, scratch, ds, d_inv);\n    } else {\n        limbs_modular_div_barrett(qs, ns, ds, scratch);\n    }\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, returning the quotient. The quotient has `ns.len() - ds.len() + 1`\n// limbs.\n//\n// `ns` must be exactly divisible by `ds`! If it isn't, the function will panic or return a\n// meaningless result.\n//\n// `ns` must be at least as long as `ds` and `ds` must have length at least 2 and its most\n// significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` is empty, or the most-significant limb of `ds` is zero.\n//\n// This is equivalent to `mpn_divexact` from `mpn/generic/divexact.c`, GMP 6.2.1, where `scratch` is\n// allocated internally and `qp` is returned.\npub_test! {limbs_div_exact(ns: &[Limb], ds: &[Limb]) -> Vec<Limb> {\n    let mut qs = vec![0; ns.len() - ds.len() + 1];\n    limbs_div_exact_to_out_ref_ref(&mut qs, ns, ds);\n    qs\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n// `ns` and `ds` are taken by value.\n//\n// `ns` must be exactly divisible by `ds`! If it isn't, the function will panic or return a\n// meaningless result.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must be nonempty and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` is empty, or the most-significant\n// limb of `ds` is zero.\n//\n// This is equivalent to `mpn_divexact` from `mpn/generic/divexact.c`, GMP 6.2.1, except that `np`\n// and `dp` are consumed.\npub_crate_test! {limbs_div_exact_to_out(qs: &mut [Limb], ns: &mut [Limb], ds: &mut [Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(ds[d_len - 1], 0);\n    let leading_zeros = slice_leading_zeros(ds);\n    let (ns_lo, ns) = ns.split_at_mut(leading_zeros);\n    assert!(slice_test_zero(ns_lo), \"division not exact\");\n    let ds = &mut ds[leading_zeros..];\n    let n_len = ns.len();\n    let d_len = ds.len();\n    if d_len == 1 {\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(qs, ns, ds[0]);\n        return;\n    }\n    let q_len = n_len - d_len + 1;\n    let shift = TrailingZeros::trailing_zeros(ds[0]);\n    if shift != 0 {\n        let q_len_plus_1 = q_len + 1;\n        let ds_limit_len = if d_len > q_len { q_len_plus_1 } else { d_len };\n        limbs_slice_shr_in_place(&mut ds[..ds_limit_len], shift);\n        // Since we have excluded d_len == 1, we have n_len > q_len, and we need to shift one limb\n        // beyond q_len.\n        limbs_slice_shr_in_place(&mut ns[..q_len_plus_1], shift);\n    }\n    let d_len = min(d_len, q_len);\n    let mut scratch = vec![0; limbs_modular_div_scratch_len(q_len, d_len)];\n    limbs_modular_div(qs, &mut ns[..q_len], &ds[..d_len], &mut scratch);\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n// `ns` is taken by value and `ds` by reference.\n//\n// `ns` must be exactly divisible by `ds`! If it isn't, the function will panic or return a\n// meaningless result.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must be nonempty and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` is empty, or the most-significant\n// limb of `ds` is zero.\n//\n// This is equivalent to `mpn_divexact` from `mpn/generic/divexact.c`, GMP 6.2.1, except that `np`\n// is consumed.\npub_test! {limbs_div_exact_to_out_val_ref(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(ds[d_len - 1], 0);\n    let leading_zeros = slice_leading_zeros(ds);\n    let (ns_lo, ns) = ns.split_at_mut(leading_zeros);\n    assert!(slice_test_zero(ns_lo), \"division not exact\");\n    let mut ds_scratch;\n    let mut ds = &ds[leading_zeros..];\n    let n_len = ns.len();\n    let d_len = ds.len();\n    if d_len == 1 {\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(qs, ns, ds[0]);\n        return;\n    }\n    let q_len = n_len - d_len + 1;\n    let shift = TrailingZeros::trailing_zeros(ds[0]);\n    if shift != 0 {\n        let q_len_plus_1 = q_len + 1;\n        let ds_scratch_len = if d_len > q_len { q_len_plus_1 } else { d_len };\n        ds_scratch = vec![0; ds_scratch_len];\n        limbs_shr_to_out(&mut ds_scratch, &ds[..ds_scratch_len], shift);\n        ds = &ds_scratch;\n        // Since we have excluded d_len == 1, we have n_len > q_len, and we need to shift one limb\n        // beyond q_len.\n        limbs_slice_shr_in_place(&mut ns[..q_len_plus_1], shift);\n    }\n    let d_len = min(d_len, q_len);\n    let mut scratch = vec![0; limbs_modular_div_scratch_len(q_len, d_len)];\n    limbs_modular_div(qs, &mut ns[..q_len], &ds[..d_len], &mut scratch);\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n// `ns` is taken by reference and `ds` by value.\n//\n// `ns` must be exactly divisible by `ds`! If it isn't, the function will panic or return a\n// meaningless result.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must be nonempty and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` is empty, or the most-significant\n// limb of `ds` is zero.\n//\n// This is equivalent to `mpn_divexact` from `mpn/generic/divexact.c`, GMP 6.2.1, except that `dp`\n// is consumed.\npub_test! {limbs_div_exact_to_out_ref_val(qs: &mut [Limb], ns: &[Limb], ds: &mut [Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(ds[d_len - 1], 0);\n    let leading_zeros = slice_leading_zeros(ds);\n    let (ns_lo, ns_hi) = ns.split_at(leading_zeros);\n    assert!(slice_test_zero(ns_lo), \"division not exact\");\n    let mut ns_scratch;\n    let mut ns = ns_hi;\n    let ds = &mut ds[leading_zeros..];\n    let n_len = ns.len();\n    let d_len = ds.len();\n    if d_len == 1 {\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(qs, ns, ds[0]);\n        return;\n    }\n    let q_len = n_len - d_len + 1;\n    let shift = TrailingZeros::trailing_zeros(ds[0]);\n    if shift != 0 {\n        let q_len_plus_1 = q_len + 1;\n        let ds_limit_len = if d_len > q_len { q_len_plus_1 } else { d_len };\n        limbs_slice_shr_in_place(&mut ds[..ds_limit_len], shift);\n        // Since we have excluded d_len == 1, we have n_len > q_len, and we need to shift one limb\n        // beyond q_len.\n        ns_scratch = vec![0; q_len_plus_1];\n        limbs_shr_to_out(&mut ns_scratch, &ns[..q_len_plus_1], shift);\n        ns = &ns_scratch;\n    }\n    let d_len = min(d_len, q_len);\n    let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(q_len, d_len)];\n    limbs_modular_div_ref(qs, &ns[..q_len], &ds[..d_len], &mut scratch);\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs`.\n// `ns` and `ds` are taken by reference.\n//\n// `ns` must be exactly divisible by `ds`! If it isn't, the function will panic or return a\n// meaningless result.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// and `ds` must be nonempty and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` is too short, `ns` is shorter than `ds`, `ds` is empty, or the most-significant\n// limb of `ds` is zero.\n//\n// This is equivalent to `mpn_divexact` from `mpn/generic/divexact.c`, GMP 6.2.1.\npub_test! {limbs_div_exact_to_out_ref_ref(qs: &mut [Limb], ns: &[Limb], ds: &[Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(ds[d_len - 1], 0);\n    let leading_zeros = slice_leading_zeros(ds);\n    let (ns_lo, ns_hi) = ns.split_at(leading_zeros);\n    assert!(slice_test_zero(ns_lo), \"division not exact\");\n    let mut ns_scratch;\n    let mut ds_scratch;\n    let mut ns = ns_hi;\n    let mut ds = &ds[leading_zeros..];\n    let n_len = ns.len();\n    let d_len = ds.len();\n    if d_len == 1 {\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(qs, ns, ds[0]);\n        return;\n    }\n    let q_len = n_len - d_len + 1;\n    let shift = TrailingZeros::trailing_zeros(ds[0]);\n    if shift != 0 {\n        let q_len_plus_1 = q_len + 1;\n        let ds_scratch_len = if d_len > q_len { q_len_plus_1 } else { d_len };\n        ds_scratch = vec![0; ds_scratch_len];\n        limbs_shr_to_out(&mut ds_scratch, &ds[..ds_scratch_len], shift);\n        ds = &ds_scratch;\n        // Since we have excluded d_len == 1, we have n_len > q_len, and we need to shift one limb\n        // beyond q_len.\n        ns_scratch = vec![0; q_len_plus_1];\n        limbs_shr_to_out(&mut ns_scratch, &ns[..q_len_plus_1], shift);\n        ns = &ns_scratch;\n    }\n    let d_len = min(d_len, q_len);\n    let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(q_len, d_len)];\n    limbs_modular_div_ref(qs, &ns[..q_len], &ds[..d_len], &mut scratch);\n}}\n\nimpl Natural {\n    fn div_exact_limb_ref(&self, other: Limb) -> Self {\n        match (self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (x, 1) => x.clone(),\n            (Self(Small(small)), other) => Self(Small(small / other)),\n            (Self(Large(limbs)), other) => {\n                Self::from_owned_limbs_asc(limbs_div_exact_limb(limbs, other))\n            }\n        }\n    }\n\n    fn div_exact_assign_limb(&mut self, other: Limb) {\n        match (&mut *self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (_, 1) => {}\n            (Self(Small(small)), other) => *small /= other,\n            (Self(Large(limbs)), other) => {\n                limbs_div_exact_limb_in_place(limbs, other);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl DivExact<Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value. The first [`Natural`]\n    /// must be exactly divisible by the second. If it isn't, this function may panic or return a\n    /// meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self / other` instead. If you're\n    /// unsure and you want to know, use `self.div_mod(other)` and check whether the remainder is\n    /// zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round(other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 123 * 456 = 56088\n    /// assert_eq!(\n    ///     Natural::from(56088u32).div_exact(Natural::from(456u32)),\n    ///     123\n    /// );\n    ///\n    /// // 123456789000 * 987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"121932631112635269000000\")\n    ///         .unwrap()\n    ///         .div_exact(Natural::from_str(\"987654321000\").unwrap()),\n    ///     123456789000u64\n    /// );\n    /// ```\n    #[inline]\n    fn div_exact(mut self, other: Self) -> Self {\n        self.div_exact_assign(other);\n        self\n    }\n}\n\nimpl<'a> DivExact<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference. The first [`Natural`] must be exactly divisible by the second. If it isn't, this\n    /// function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self / &other` instead. If you're\n    /// unsure and you want to know, use `self.div_mod(&other)` and check whether the remainder is\n    /// zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round(&other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 123 * 456 = 56088\n    /// assert_eq!(\n    ///     Natural::from(56088u32).div_exact(&Natural::from(456u32)),\n    ///     123\n    /// );\n    ///\n    /// // 123456789000 * 987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"121932631112635269000000\")\n    ///         .unwrap()\n    ///         .div_exact(&Natural::from_str(\"987654321000\").unwrap()),\n    ///     123456789000u64\n    /// );\n    /// ```\n    #[inline]\n    fn div_exact(mut self, other: &'a Self) -> Self {\n        self.div_exact_assign(other);\n        self\n    }\n}\n\nimpl DivExact<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value. The first [`Natural`] must be exactly divisible by the second. If it isn't, this\n    /// function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `&self / other` instead. If you're\n    /// unsure and you want to know, use `self.div_mod(other)` and check whether the remainder is\n    /// zero. If you want a function that panics if the division is not exact, use\n    /// `(&self).div_round(other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 123 * 456 = 56088\n    /// assert_eq!(\n    ///     (&Natural::from(56088u32)).div_exact(Natural::from(456u32)),\n    ///     123\n    /// );\n    ///\n    /// // 123456789000 * 987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"121932631112635269000000\").unwrap())\n    ///         .div_exact(Natural::from_str(\"987654321000\").unwrap()),\n    ///     123456789000u64\n    /// );\n    /// ```\n    fn div_exact(self, mut other: Natural) -> Natural {\n        if *self == other {\n            return Natural::ONE;\n        }\n        match (self, &mut other) {\n            (_, &mut Natural::ZERO) => panic!(\"division by zero\"),\n            (n, &mut Natural::ONE) => n.clone(),\n            (&Natural::ZERO, _) => Natural::ZERO,\n            (n, &mut Natural(Small(d))) => n.div_exact_limb_ref(d),\n            (Natural(Small(_)), Natural(Large(_))) => panic!(\"division not exact\"),\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                if ns_len < ds_len {\n                    panic!(\"division not exact\");\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_exact_to_out_ref_val(&mut qs, ns, ds);\n                    Natural::from_owned_limbs_asc(qs)\n                }\n            }\n        }\n    }\n}\n\nimpl DivExact<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference. The first\n    /// [`Natural`] must be exactly divisible by the second. If it isn't, this function may panic or\n    /// return a meaningless result.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `&self / &other` instead. If\n    /// you're unsure and you want to know, use `(&self).div_mod(&other)` and check whether the\n    /// remainder is zero. If you want a function that panics if the division is not exact, use\n    /// `(&self).div_round(&other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExact;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 123 * 456 = 56088\n    /// assert_eq!(\n    ///     (&Natural::from(56088u32)).div_exact(&Natural::from(456u32)),\n    ///     123\n    /// );\n    ///\n    /// // 123456789000 * 987654321000 = 121932631112635269000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"121932631112635269000000\").unwrap())\n    ///         .div_exact(&Natural::from_str(\"987654321000\").unwrap()),\n    ///     123456789000u64\n    /// );\n    /// ```\n    fn div_exact(self, other: &Natural) -> Natural {\n        if self == other {\n            return Natural::ONE;\n        }\n        match (self, other) {\n            (_, &Natural::ZERO) => panic!(\"division by zero\"),\n            (n, &Natural::ONE) => n.clone(),\n            (&Natural::ZERO, _) => Natural::ZERO,\n            (n, Natural(Small(d))) => n.div_exact_limb_ref(*d),\n            (Natural(Small(_)), Natural(Large(_))) => panic!(\"division not exact\"),\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                if ns_len < ds_len {\n                    panic!(\"division not exact\");\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_exact_to_out_ref_ref(&mut qs, ns, ds);\n                    Natural::from_owned_limbs_asc(qs)\n                }\n            }\n        }\n    }\n}\n\nimpl DivExactAssign<Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value. The first [`Natural`] must be exactly divisible by the second. If\n    /// it isn't, this function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// x \\gets \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self /= other` instead. If you're\n    /// unsure and you want to know, use `self.div_assign_mod(other)` and check whether the\n    /// remainder is zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round_assign(other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExactAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 123 * 456 = 56088\n    /// let mut x = Natural::from(56088u32);\n    /// x.div_exact_assign(Natural::from(456u32));\n    /// assert_eq!(x, 123);\n    ///\n    /// // 123456789000 * 987654321000 = 121932631112635269000000\n    /// let mut x = Natural::from_str(\"121932631112635269000000\").unwrap();\n    /// x.div_exact_assign(Natural::from_str(\"987654321000\").unwrap());\n    /// assert_eq!(x, 123456789000u64);\n    /// ```\n    fn div_exact_assign(&mut self, mut other: Self) {\n        if *self == other {\n            *self = Self::ONE;\n            return;\n        }\n        match (&mut *self, &mut other) {\n            (_, &mut Self::ZERO) => panic!(\"division by zero\"),\n            (_, &mut Self::ONE) | (&mut Self::ZERO, _) => {}\n            (n, &mut Self(Small(d))) => n.div_exact_assign_limb(d),\n            (Self(Small(_)), Self(Large(_))) => panic!(\"division not exact\"),\n            (Self(Large(ns)), Self(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                if ns_len < ds_len {\n                    panic!(\"division not exact\");\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_exact_to_out(&mut qs, ns, ds);\n                    swap(&mut qs, ns);\n                    self.trim();\n                }\n            }\n        }\n    }\n}\n\nimpl<'a> DivExactAssign<&'a Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference. The first [`Natural`] must be exactly divisible by the second.\n    /// If it isn't, this function may panic or return a meaningless result.\n    ///\n    /// $$\n    /// x \\gets \\frac{x}{y}.\n    /// $$\n    ///\n    /// If you are unsure whether the division will be exact, use `self /= &other` instead. If\n    /// you're unsure and you want to know, use `self.div_assign_mod(&other)` and check whether the\n    /// remainder is zero. If you want a function that panics if the division is not exact, use\n    /// `self.div_round_assign(&other, Exact)`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero. May panic if `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivExactAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 123 * 456 = 56088\n    /// let mut x = Natural::from(56088u32);\n    /// x.div_exact_assign(&Natural::from(456u32));\n    /// assert_eq!(x, 123);\n    ///\n    /// // 123456789000 * 987654321000 = 121932631112635269000000\n    /// let mut x = Natural::from_str(\"121932631112635269000000\").unwrap();\n    /// x.div_exact_assign(&Natural::from_str(\"987654321000\").unwrap());\n    /// assert_eq!(x, 123456789000u64);\n    /// ```\n    fn div_exact_assign(&mut self, other: &'a Self) {\n        if self == other {\n            *self = Self::ONE;\n            return;\n        }\n        match (&mut *self, other) {\n            (_, &Self::ZERO) => panic!(\"division by zero\"),\n            (_, &Self::ONE) | (&mut Self::ZERO, _) => {}\n            (_, Self(Small(d))) => self.div_exact_assign_limb(*d),\n            (Self(Small(_)), Self(Large(_))) => panic!(\"division not exact\"),\n            (Self(Large(ns)), Self(Large(ds))) => {\n                let ns_len = ns.len();\n                let ds_len = ds.len();\n                if ns_len < ds_len {\n                    panic!(\"division not exact\");\n                } else {\n                    let mut qs = vec![0; ns_len - ds_len + 1];\n                    limbs_div_exact_to_out_val_ref(&mut qs, ns, ds);\n                    swap(&mut qs, ns);\n                    self.trim();\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_dcpi1_div_qr`, `mpn_dcpi1_div_qr_n`, `mpn_preinv_mu_div_qr_itch`,\n//      `mpn_preinv_mu_div_qr`, `mpn_mu_div_qr_choose_in`, `mpn_mu_div_qr2`, `mpn_mu_div_qr`,\n//      `mpn_mu_div_qr_itch`, and `mpn_sbpi1_div_qr` contributed to the GNU project by Torbjörn\n//      Granlund.\n//\n//      `mpn_invertappr`, `mpn_bc_invertappr`, and `mpn_ni_invertappr` contributed to the GNU\n//      project by Marco Bodrato. The algorithm used here was inspired by ApproximateReciprocal from\n//      \"Modern Computer Arithmetic\", by Richard P. Brent and Paul Zimmermann. Special thanks to\n//      Paul Zimmermann for his very valuable suggestions on all the theoretical aspects during the\n//      work on this code.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out,\n    limbs_add_same_length_with_carry_in_in_place_left, limbs_add_same_length_with_carry_in_to_out,\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::div::{\n    limbs_div_divide_and_conquer_approx, limbs_div_schoolbook_approx,\n};\nuse crate::natural::arithmetic::mul::mul_mod::{\n    limbs_mul_mod_base_pow_n_minus_1, limbs_mul_mod_base_pow_n_minus_1_next_size,\n    limbs_mul_mod_base_pow_n_minus_1_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::natural::arithmetic::shr::{limbs_shr_to_out, limbs_slice_shr_in_place};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n    limbs_sub_same_length_in_place_right, limbs_sub_same_length_to_out,\n    limbs_sub_same_length_with_borrow_in_in_place_left,\n    limbs_sub_same_length_with_borrow_in_in_place_right,\n    limbs_sub_same_length_with_borrow_in_to_out,\n};\nuse crate::natural::arithmetic::sub_mul::limbs_sub_mul_limb_same_length_in_place_left;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::natural::logic::not::limbs_not_to_out;\nuse crate::platform::{\n    DC_DIV_QR_THRESHOLD, DC_DIVAPPR_Q_THRESHOLD, DoubleLimb, INV_MULMOD_BNM1_THRESHOLD,\n    INV_NEWTON_THRESHOLD, Limb, MAYBE_DCP1_DIVAPPR, MU_DIV_QR_SKEW_THRESHOLD, MU_DIV_QR_THRESHOLD,\n};\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, min};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivAssignNegMod, CeilingDivNegMod, DivAssignMod, DivAssignRem, DivMod, DivRem,\n    WrappingAddAssign, WrappingSub, WrappingSubAssign, XMulYToZZ, XXDivModYToQR,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::slices::{slice_move_left, slice_set_zero};\n\n// The highest bit of the input must be set.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `d` is zero.\n//\n// This is equivalent to `mpn_invert_limb`, or `invert_limb`, from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_invert_limb<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves<Half = T> + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    d: T,\n) -> T {\n    (DT::join_halves(!d, T::MAX) / DT::from(d)).lower_half()\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `udiv_qrnnd_preinv` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {div_mod_by_preinversion(\n    n_high: Limb,\n    n_low: Limb,\n    d: Limb,\n    d_inv: Limb\n) -> (Limb, Limb) {\n    let (mut q_high, q_low) = (DoubleLimb::from(n_high) * DoubleLimb::from(d_inv))\n        .wrapping_add(DoubleLimb::join_halves(n_high.wrapping_add(1), n_low))\n        .split_in_half();\n    let mut r = n_low.wrapping_sub(q_high.wrapping_mul(d));\n    if r > q_low {\n        let (r_plus_d, overflow) = r.overflowing_add(d);\n        if overflow {\n            q_high.wrapping_sub_assign(1);\n            r = r_plus_d;\n        }\n    } else if r >= d {\n        q_high.wrapping_add_assign(1);\n        r -= d;\n    }\n    (q_high, r)\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// quotient limbs and remainder of the `Natural` divided by a `Limb`. The divisor limb cannot be\n// zero and the limb slice must have at least two elements.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if the length of `ns` is less than 2 or if `d` is zero.\n//\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, where `qxn == 0`,\n// `un > 1`, and both results are returned. Experiments show that `DIVREM_1_NORM_THRESHOLD` and\n// `DIVREM_1_UNNORM_THRESHOLD` are unnecessary (they would always be 0).\npub_test! {limbs_div_limb_mod(ns: &[Limb], d: Limb) -> (Vec<Limb>, Limb) {\n    let mut qs = vec![0; ns.len()];\n    let r = limbs_div_limb_to_out_mod(&mut qs, ns, d);\n    (qs, r)\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and a `Limb` to an output slice, and returns the\n// remainder. The output slice must be at least as long as the input slice. The divisor limb cannot\n// be zero and the input limb slice must have at least two elements.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `ns`, the length of `ns` is less than 2, or if `d` is zero.\n//\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, where `qxn == 0`\n// and `un > 1`. Experiments show that `DIVREM_1_NORM_THRESHOLD` and `DIVREM_1_UNNORM_THRESHOLD` are\n// unnecessary (they would always be 0).\npub_crate_test! {limbs_div_limb_to_out_mod(out: &mut [Limb], ns: &[Limb], d: Limb) -> Limb {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let out = &mut out[..len];\n    let bits = LeadingZeros::leading_zeros(d);\n    if bits == 0 {\n        // High quotient limb is 0 or 1, skip a divide step.\n        let (r, ns_init) = ns.split_last().unwrap();\n        let mut r = *r;\n        let (out_last, out_init) = out.split_last_mut().unwrap();\n        let adjust = r >= d;\n        if adjust {\n            r -= d;\n        }\n        *out_last = Limb::from(adjust);\n        // Multiply-by-inverse, divisor already normalized.\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        for (out_q, &n) in out_init.iter_mut().zip(ns_init.iter()).rev() {\n            (*out_q, r) = div_mod_by_preinversion(r, n, d, d_inv);\n        }\n        r\n    } else {\n        // Skip a division if high < divisor (high quotient 0). Testing here before normalizing will\n        // still skip as often as possible.\n        let (ns_last, ns_init) = ns.split_last().unwrap();\n        let (ns, mut r) = if *ns_last < d {\n            *out.last_mut().unwrap() = 0;\n            (ns_init, *ns_last)\n        } else {\n            (ns, 0)\n        };\n        let d = d << bits;\n        r <<= bits;\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let (previous_n, ns_init) = ns.split_last().unwrap();\n        let mut previous_n = *previous_n;\n        let cobits = Limb::WIDTH - bits;\n        r |= previous_n >> cobits;\n        let (out_head, out_tail) = out.split_first_mut().unwrap();\n        for (out_q, &n) in out_tail.iter_mut().zip(ns_init.iter()).rev() {\n            let n_shifted = (previous_n << bits) | (n >> cobits);\n            (*out_q, r) = div_mod_by_preinversion(r, n_shifted, d, d_inv);\n            previous_n = n;\n        }\n        let out_r;\n        (*out_head, out_r) = div_mod_by_preinversion(r, previous_n << bits, d, d_inv);\n        out_r >> bits\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the quotient of the `Natural` and a `Limb` to the input slice and returns the remainder.\n// The divisor limb cannot be zero and the input limb slice must have at least two elements.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if the length of `ns` is less than 2 or if `d` is zero.\n//\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, where `qp == up`,\n// `qxn == 0`, and `un > 1`. Experiments show that `DIVREM_1_NORM_THRESHOLD` and\n// `DIVREM_1_UNNORM_THRESHOLD` are unnecessary (they would always be 0).\npub_crate_test! {limbs_div_limb_in_place_mod(ns: &mut [Limb], d: Limb) -> Limb {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let bits = LeadingZeros::leading_zeros(d);\n    let (ns_last, ns_init) = ns.split_last_mut().unwrap();\n    if bits == 0 {\n        // High quotient limb is 0 or 1, skip a divide step.\n        let mut r = *ns_last;\n        let adjust = r >= d;\n        if adjust {\n            r -= d;\n        }\n        *ns_last = Limb::from(adjust);\n        // Multiply-by-inverse, divisor already normalized.\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        for n in ns_init.iter_mut().rev() {\n            (*n, r) = div_mod_by_preinversion(r, *n, d, d_inv);\n        }\n        r\n    } else {\n        // Skip a division if high < divisor (high quotient 0). Testing here before normalizing will\n        // still skip as often as possible.\n        let (ns, mut r) = if *ns_last < d {\n            let r = *ns_last;\n            *ns_last = 0;\n            (ns_init, r)\n        } else {\n            (ns, 0)\n        };\n        let d = d << bits;\n        r <<= bits;\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let last_index = ns.len() - 1;\n        let mut previous_n = ns[last_index];\n        let cobits = Limb::WIDTH - bits;\n        r |= previous_n >> cobits;\n        for i in (0..last_index).rev() {\n            let n = ns[i];\n            let shifted_n = (previous_n << bits) | (n >> cobits);\n            (ns[i + 1], r) = div_mod_by_preinversion(r, shifted_n, d, d_inv);\n            previous_n = n;\n        }\n        let out_r;\n        (ns[0], out_r) = div_mod_by_preinversion(r, previous_n << bits, d, d_inv);\n        out_r >> bits\n    }\n}}\n\n// Let `ns` be the limbs of a `Natural` $n$, and let $f$ be `fraction_len`. This function performs\n// the integer division $B^fn / d$, writing the `ns.len() + fraction_len` limbs of the quotient to\n// `out` and returning the remainder.\n//\n// `shift` must be the number of leading zeros of `d`, and `d_inv` must be `limbs_invert_limb(d <<\n// shift)`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len() + fraction_len`.\n//\n// # Panics\n// Panics if `out` is shorter than `ns.len()` + `fraction_len`, if `ns` is empty, or if `d` is zero.\n//\n// This is equivalent to `mpn_preinv_divrem_1` from `mpn/generic/pre_divrem_1.c`, GMP 6.2.1, where\n// `qp != ap`.\npub_test! {limbs_div_mod_extra(\n    out: &mut [Limb],\n    fraction_len: usize,\n    mut ns: &[Limb],\n    d: Limb,\n    d_inv: Limb,\n    shift: u64,\n) -> Limb {\n    assert!(!ns.is_empty());\n    assert_ne!(d, 0);\n    let (ns_last, ns_init) = ns.split_last().unwrap();\n    let ns_last = *ns_last;\n    let d_norm = d << shift;\n    let (fraction_out, integer_out) = out.split_at_mut(fraction_len);\n    let mut integer_out = &mut integer_out[..ns.len()];\n    let mut r;\n    if shift == 0 {\n        r = ns_last;\n        let q_high = r >= d_norm;\n        if r >= d_norm {\n            r -= d_norm;\n        }\n        let (integer_out_last, integer_out_init) = integer_out.split_last_mut().unwrap();\n        *integer_out_last = Limb::from(q_high);\n        for (q, &n) in integer_out_init.iter_mut().zip(ns_init.iter()).rev() {\n            (*q, r) = div_mod_by_preinversion(r, n, d_norm, d_inv);\n        }\n    } else {\n        r = 0;\n        if ns_last < d {\n            r = ns_last << shift;\n            let integer_out_last;\n            (integer_out_last, integer_out) = integer_out.split_last_mut().unwrap();\n            *integer_out_last = 0;\n            ns = ns_init;\n        }\n        if !ns.is_empty() {\n            let co_shift = Limb::WIDTH - shift;\n            let (ns_last, ns_init) = ns.split_last().unwrap();\n            let mut previous_n = *ns_last;\n            r |= previous_n >> co_shift;\n            let (integer_out_head, integer_out_tail) = integer_out.split_first_mut().unwrap();\n            for (q, &n) in integer_out_tail.iter_mut().zip(ns_init.iter()).rev() {\n                assert!(r < d_norm);\n                (*q, r) = div_mod_by_preinversion(\n                    r,\n                    (previous_n << shift) | (n >> co_shift),\n                    d_norm,\n                    d_inv,\n                );\n                previous_n = n;\n            }\n            (*integer_out_head, r) = div_mod_by_preinversion(r, previous_n << shift, d_norm, d_inv);\n        }\n    }\n    for q in fraction_out.iter_mut().rev() {\n        (*q, r) = div_mod_by_preinversion(r, 0, d_norm, d_inv);\n    }\n    r >> shift\n}}\n\n// Let `&ns[fraction_len..]` be the limbs of a `Natural` $n$, and let $f$ be `fraction_len`. This\n// function performs the integer division $B^fn / d$, writing the `ns.len() + fraction_len` limbs of\n// the quotient to `ns` and returning the remainder.\n//\n// `shift` must be the number of leading zeros of `d`, and `d_inv` must be `limbs_invert_limb(d <<\n// shift)`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len() + fraction_len`.\n//\n// # Panics\n// Panics if `ns` is empty, if `ns.len()` is less than `fraction_len`, or if `d` is zero.\n//\n// This is equivalent to `mpn_preinv_divrem_1` from `mpn/generic/pre_divrem_1.c`, GMP 6.2.1, where\n// `qp == ap`.\npub_crate_test! {limbs_div_mod_extra_in_place(\n    ns: &mut [Limb],\n    fraction_len: usize,\n    d: Limb,\n    d_inv: Limb,\n    shift: u64,\n) -> Limb {\n    assert_ne!(d, 0);\n    let (fraction_ns, mut integer_ns) = ns.split_at_mut(fraction_len);\n    let ns_last = *integer_ns.last().unwrap();\n    let d_norm = d << shift;\n    let mut r;\n    if shift == 0 {\n        r = ns_last;\n        let q_high = r >= d_norm;\n        if r >= d_norm {\n            r -= d_norm;\n        }\n        let (integer_ns_last, integer_ns_init) = integer_ns.split_last_mut().unwrap();\n        *integer_ns_last = Limb::from(q_high);\n        for q in integer_ns_init.iter_mut().rev() {\n            (*q, r) = div_mod_by_preinversion(r, *q, d_norm, d_inv);\n        }\n    } else {\n        r = 0;\n        if ns_last < d {\n            r = ns_last << shift;\n            let integer_ns_last;\n            (integer_ns_last, integer_ns) = integer_ns.split_last_mut().unwrap();\n            *integer_ns_last = 0;\n        }\n        if !integer_ns.is_empty() {\n            let co_shift = Limb::WIDTH - shift;\n            let mut previous_n = *integer_ns.last().unwrap();\n            r |= previous_n >> co_shift;\n            for i in (1..integer_ns.len()).rev() {\n                assert!(r < d_norm);\n                let n = integer_ns[i - 1];\n                (integer_ns[i], r) = div_mod_by_preinversion(\n                    r,\n                    (previous_n << shift) | (n >> co_shift),\n                    d_norm,\n                    d_inv,\n                );\n                previous_n = n;\n            }\n            (integer_ns[0], r) = div_mod_by_preinversion(r, previous_n << shift, d_norm, d_inv);\n        }\n    }\n    for q in fraction_ns.iter_mut().rev() {\n        (*q, r) = div_mod_by_preinversion(r, 0, d_norm, d_inv);\n    }\n    r >> shift\n}}\n\n// Computes floor((B ^ 3 - 1) / (`hi` * B + `lo`)) - B, where B = 2 ^ `Limb::WIDTH`, assuming the\n// highest bit of `hi` is set.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `hi` is zero.\n//\n// This is equivalent to `invert_pi1` from `gmp-impl.h`, GMP 6.2.1, where the result is returned\n// instead of being written to `dinv`.\npub_crate_test! {limbs_two_limb_inverse_helper(hi: Limb, lo: Limb) -> Limb {\n    let mut d_inv = limbs_invert_limb::<DoubleLimb, Limb>(hi);\n    let mut hi_product = hi.wrapping_mul(d_inv);\n    hi_product.wrapping_add_assign(lo);\n    if hi_product < lo {\n        d_inv.wrapping_sub_assign(1);\n        if hi_product >= hi {\n            hi_product.wrapping_sub_assign(hi);\n            d_inv.wrapping_sub_assign(1);\n        }\n        hi_product.wrapping_sub_assign(hi);\n    }\n    let (lo_product_hi, lo_product_lo) = Limb::x_mul_y_to_zz(lo, d_inv);\n    hi_product.wrapping_add_assign(lo_product_hi);\n    if hi_product < lo_product_hi {\n        d_inv.wrapping_sub_assign(1);\n        if hi_product > hi || hi_product == hi && lo_product_lo >= lo {\n            d_inv.wrapping_sub_assign(1);\n        }\n    }\n    d_inv\n}}\n\n// Computes the quotient and remainder of `[n_2, n_1, n_0]` / `[d_1, d_0]`. Requires the highest bit\n// of `d_1` to be set, and `[n_2, n_1]` < `[d_1, d_0]`. `d_inv` is the inverse of `[d_1, d_0]`\n// computed by `limbs_two_limb_inverse_helper`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `udiv_qr_3by2` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_div_mod_three_limb_by_two_limb(\n    n_2: Limb,\n    n_1: Limb,\n    n_0: Limb,\n    d_1: Limb,\n    d_0: Limb,\n    d_inv: Limb,\n) -> (Limb, DoubleLimb) {\n    let (mut q, q_lo) = (DoubleLimb::from(n_2) * DoubleLimb::from(d_inv))\n        .wrapping_add(DoubleLimb::join_halves(n_2, n_1))\n        .split_in_half();\n    let d = DoubleLimb::join_halves(d_1, d_0);\n    // Compute the two most significant limbs of n - q * d\n    let mut r = DoubleLimb::join_halves(n_1.wrapping_sub(d_1.wrapping_mul(q)), n_0)\n        .wrapping_sub(d)\n        .wrapping_sub(DoubleLimb::from(d_0) * DoubleLimb::from(q));\n    q.wrapping_add_assign(1);\n    // Conditionally adjust q and the remainder\n    if r.upper_half() >= q_lo {\n        let (r_plus_d, overflow) = r.overflowing_add(d);\n        if overflow {\n            q.wrapping_sub_assign(1);\n            r = r_plus_d;\n        }\n    } else if r >= d {\n        q.wrapping_add_assign(1);\n        r.wrapping_sub_assign(d);\n    }\n    (q, r)\n}}\n\n// Divides `ns` by `ds` and writes the `ns.len()` - 2 least-significant quotient limbs to `qs` and\n// the 2-long remainder to `ns`. Returns the most significant limb of the quotient; `true` means 1\n// and `false` means 0. `ds` must have length 2, `ns` must have length at least 2, and the most\n// significant bit of `ds[1]` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` does not have length 2, `ns` has length less than 2, `qs` has length less than\n// `ns.len() - 2`, or `ds[1]` does not have its highest bit set.\n//\n// This is equivalent to `mpn_divrem_2` from `mpn/generic/divrem_2.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_mod_by_two_limb_normalized(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb]\n) -> bool {\n    assert_eq!(ds.len(), 2);\n    let n_len = ns.len();\n    assert!(n_len >= 2);\n    let n_limit = n_len - 2;\n    assert!(ds[1].get_highest_bit());\n    let d_1 = ds[1];\n    let d_0 = ds[0];\n    let d = DoubleLimb::join_halves(d_1, d_0);\n    let mut r = DoubleLimb::join_halves(ns[n_limit + 1], ns[n_limit]);\n    let highest_q = r >= d;\n    if highest_q {\n        r.wrapping_sub_assign(d);\n    }\n    let (mut r_1, mut r_0) = r.split_in_half();\n    let d_inv = limbs_two_limb_inverse_helper(d_1, d_0);\n    for (&n, q) in ns[..n_limit].iter().zip(qs[..n_limit].iter_mut()).rev() {\n        let r;\n        (*q, r) = limbs_div_mod_three_limb_by_two_limb(r_1, r_0, n, d_1, d_0, d_inv);\n        (r_1, r_0) = r.split_in_half();\n    }\n    ns[1] = r_1;\n    ns[0] = r_0;\n    highest_q\n}}\n\n// Schoolbook division using the Möller-Granlund 3/2 division algorithm.\n//\n// Divides `ns` by `ds` and writes the `ns.len()` - `ds.len()` least-significant quotient limbs to\n// `qs` and the `ds.len()` limbs of the remainder to `ns`. Returns the most significant limb of the\n// quotient; `true` means 1 and `false` means 0. `ds` must have length greater than 2, `ns` must be\n// at least as long as `ds`, and the most significant bit of `ds` must be set. `d_inv` should be the\n// result of `limbs_two_limb_inverse_helper` applied to the two highest limbs of the denominator.\n//\n// # Worst-case complexity\n// $T(n, d) = O(d(n - d + 1)) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ns.len()`, and $d$ is `ds.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 3, `ns` is shorter than `ds`, `qs` has length less than\n// `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_sbpi1_div_qr` from `mpn/generic/sbpi1_div_qr.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_mod_schoolbook(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) -> bool {\n    let d_len = ds.len();\n    assert!(d_len > 2);\n    let n_len = ns.len();\n    assert!(n_len >= d_len);\n    let d_1 = ds[d_len - 1];\n    assert!(d_1.get_highest_bit());\n    let d_0 = ds[d_len - 2];\n    let ds_except_last = &ds[..d_len - 1];\n    let ds_except_last_two = &ds[..d_len - 2];\n    let ns_hi = &mut ns[n_len - d_len..];\n    let highest_q = limbs_cmp_same_length(ns_hi, ds) >= Equal;\n    if highest_q {\n        limbs_sub_same_length_in_place_left(ns_hi, ds);\n    }\n    let mut n_1 = ns[n_len - 1];\n    for i in (d_len..n_len).rev() {\n        let j = i - d_len;\n        let mut q;\n        if n_1 == d_1 && ns[i - 1] == d_0 {\n            q = Limb::MAX;\n            limbs_sub_mul_limb_same_length_in_place_left(&mut ns[j..i], ds, q);\n            n_1 = ns[i - 1]; // update n_1, last loop's value will now be invalid\n        } else {\n            let (ns_lo, ns_hi) = ns.split_at_mut(i - 2);\n            let n;\n            (q, n) = limbs_div_mod_three_limb_by_two_limb(n_1, ns_hi[1], ns_hi[0], d_1, d_0, d_inv);\n            let mut n_0;\n            (n_1, n_0) = n.split_in_half();\n            let local_carry_1 = limbs_sub_mul_limb_same_length_in_place_left(\n                &mut ns_lo[j..],\n                ds_except_last_two,\n                q,\n            );\n            let local_carry_2 = n_0 < local_carry_1;\n            n_0.wrapping_sub_assign(local_carry_1);\n            let carry = local_carry_2 && n_1 == 0;\n            if local_carry_2 {\n                n_1.wrapping_sub_assign(1);\n            }\n            ns_hi[0] = n_0;\n            if carry {\n                n_1.wrapping_add_assign(d_1);\n                if limbs_slice_add_same_length_in_place_left(&mut ns[j..i - 1], ds_except_last) {\n                    n_1.wrapping_add_assign(1);\n                }\n                q.wrapping_sub_assign(1);\n            }\n        }\n        qs[j] = q;\n    }\n    ns[d_len - 1] = n_1;\n    highest_q\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// This is equivalent to `mpn_dcpi1_div_qr_n` from `mpn/generic/dcpi1_div_qr.c`, GMP 6.2.1.\npub(crate) fn limbs_div_mod_divide_and_conquer_helper(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n    scratch: &mut [Limb],\n) -> bool {\n    let n = ds.len();\n    let lo = n >> 1; // floor(n / 2)\n    let hi = n - lo; // ceil(n / 2)\n    let qs_hi = &mut qs[lo..];\n    let (ds_lo, ds_hi) = ds.split_at(lo);\n    let mut highest_q = if hi < DC_DIV_QR_THRESHOLD {\n        limbs_div_mod_schoolbook(qs_hi, &mut ns[lo << 1..n << 1], ds_hi, d_inv)\n    } else {\n        limbs_div_mod_divide_and_conquer_helper(qs_hi, &mut ns[lo << 1..], ds_hi, d_inv, scratch)\n    };\n    let qs_hi = &mut qs_hi[..hi];\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(qs_hi.len(), ds_lo.len())];\n    limbs_mul_greater_to_out(scratch, qs_hi, ds_lo, &mut mul_scratch);\n    let ns_lo = &mut ns[..n + lo];\n    let mut carry = Limb::from(limbs_sub_same_length_in_place_left(\n        &mut ns_lo[lo..],\n        &scratch[..n],\n    ));\n    if highest_q && limbs_sub_same_length_in_place_left(&mut ns_lo[n..], ds_lo) {\n        carry += 1;\n    }\n    while carry != 0 {\n        if limbs_sub_limb_in_place(qs_hi, 1) {\n            assert!(highest_q);\n            highest_q = false;\n        }\n        if limbs_slice_add_same_length_in_place_left(&mut ns_lo[lo..], ds) {\n            carry -= 1;\n        }\n    }\n    let (ds_lo, ds_hi) = ds.split_at(hi);\n    let q_lo = if lo < DC_DIV_QR_THRESHOLD {\n        limbs_div_mod_schoolbook(qs, &mut ns[hi..n + lo], ds_hi, d_inv)\n    } else {\n        limbs_div_mod_divide_and_conquer_helper(qs, &mut ns[hi..], ds_hi, d_inv, scratch)\n    };\n    let qs_lo = &mut qs[..lo];\n    let ns_lo = &mut ns[..n];\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds_lo.len(), lo)];\n    limbs_mul_greater_to_out(scratch, ds_lo, qs_lo, &mut mul_scratch);\n    let mut carry = Limb::from(limbs_sub_same_length_in_place_left(ns_lo, &scratch[..n]));\n    if q_lo && limbs_sub_same_length_in_place_left(&mut ns_lo[lo..], ds_lo) {\n        carry += 1;\n    }\n    while carry != 0 {\n        limbs_sub_limb_in_place(qs_lo, 1);\n        if limbs_slice_add_same_length_in_place_left(ns_lo, ds) {\n            carry -= 1;\n        }\n    }\n    highest_q\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\npub_test! {limbs_div_dc_helper(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n    scratch: &mut [Limb],\n) -> bool {\n    if qs.len() < DC_DIV_QR_THRESHOLD {\n        limbs_div_mod_schoolbook(qs, ns, ds, d_inv)\n    } else {\n        limbs_div_mod_divide_and_conquer_helper(qs, ns, ds, d_inv, scratch)\n    }\n}}\n\n// Recursive divide-and-conquer division.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 6, `ns.len()` is less than `ds.len()` + 3, `qs` has length\n// less than `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_dcpi1_div_qr` from `mpn/generic/dcpi1_div_qr.c`, GMP 6.2.1.\npub_test! {limbs_div_mod_divide_and_conquer(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 6); // to adhere to limbs_div_mod_schoolbook's limits\n    assert!(n_len >= d_len + 3); // to adhere to limbs_div_mod_schoolbook's limits\n    let a = d_len - 1;\n    let d_1 = ds[a];\n    let b = d_len - 2;\n    assert!(d_1.get_highest_bit());\n    let mut scratch = vec![0; d_len];\n    let mut highest_q;\n    let q_len = n_len - d_len;\n    if q_len > d_len {\n        let q_len_mod_d_len = {\n            let mut m = q_len % d_len;\n            if m == 0 {\n                m = d_len;\n            }\n            m\n        };\n        // Perform the typically smaller block first. Point at low limb of next quotient block\n        let qs_alt = &mut qs[q_len - q_len_mod_d_len..q_len];\n        if q_len_mod_d_len == 1 {\n            // Handle highest_q up front, for simplicity.\n            let ns_hi = &mut ns[q_len - 1..];\n            let ns_hi_hi = &mut ns_hi[1..];\n            highest_q = limbs_cmp_same_length(ns_hi_hi, ds) >= Equal;\n            if highest_q {\n                assert!(!limbs_sub_same_length_in_place_left(ns_hi_hi, ds));\n            }\n            // A single iteration of schoolbook: One 3/2 division, followed by the bignum update and\n            // adjustment.\n            let (last_n, ns) = ns_hi.split_last_mut().unwrap();\n            let n_2 = *last_n;\n            let mut n_1 = ns[a];\n            let mut n_0 = ns[b];\n            let d_0 = ds[b];\n            assert!(n_2 < d_1 || n_2 == d_1 && n_1 <= d_0);\n            let mut q;\n            if n_2 == d_1 && n_1 == d_0 {\n                q = Limb::MAX;\n                assert_eq!(limbs_sub_mul_limb_same_length_in_place_left(ns, ds, q), n_2);\n            } else {\n                let n;\n                (q, n) = limbs_div_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, d_inv);\n                (n_1, n_0) = n.split_in_half();\n                // d_len > 2 because of precondition. No need to check\n                let local_carry_1 =\n                    limbs_sub_mul_limb_same_length_in_place_left(&mut ns[..b], &ds[..b], q);\n                let local_carry_2 = n_0 < local_carry_1;\n                n_0.wrapping_sub_assign(local_carry_1);\n                let carry = local_carry_2 && n_1 == 0;\n                if local_carry_2 {\n                    n_1.wrapping_sub_assign(1);\n                }\n                ns[b] = n_0;\n                let (last_n, ns) = ns.split_last_mut().unwrap();\n                if carry {\n                    n_1.wrapping_add_assign(d_1);\n                    if limbs_slice_add_same_length_in_place_left(ns, &ds[..a]) {\n                        n_1.wrapping_add_assign(1);\n                    }\n                    if q == 0 {\n                        assert!(highest_q);\n                        highest_q = false;\n                    }\n                    q.wrapping_sub_assign(1);\n                }\n                *last_n = n_1;\n            }\n            qs_alt[0] = q;\n        } else {\n            // Do a 2 * q_len_mod_d_len / q_len_mod_d_len division\n            let (ds_lo, ds_hi) = ds.split_at(d_len - q_len_mod_d_len);\n            highest_q = {\n                let ns = &mut ns[n_len - (q_len_mod_d_len << 1)..];\n                if q_len_mod_d_len == 2 {\n                    limbs_div_mod_by_two_limb_normalized(qs_alt, ns, ds_hi)\n                } else {\n                    limbs_div_dc_helper(qs_alt, ns, ds_hi, d_inv, &mut scratch)\n                }\n            };\n            if q_len_mod_d_len != d_len {\n                let mut mul_scratch =\n                    vec![0; limbs_mul_to_out_scratch_len(qs_alt.len(), ds_lo.len())];\n                limbs_mul_to_out(&mut scratch, qs_alt, ds_lo, &mut mul_scratch);\n                let ns = &mut ns[q_len - q_len_mod_d_len..n_len - q_len_mod_d_len];\n                let mut carry = Limb::from(limbs_sub_same_length_in_place_left(ns, &scratch));\n                if highest_q\n                    && limbs_sub_same_length_in_place_left(&mut ns[q_len_mod_d_len..], ds_lo)\n                {\n                    carry += 1;\n                }\n                while carry != 0 {\n                    if limbs_sub_limb_in_place(qs_alt, 1) {\n                        assert!(highest_q);\n                        highest_q = false;\n                    }\n                    if limbs_slice_add_same_length_in_place_left(ns, ds) {\n                        carry -= 1;\n                    }\n                }\n            }\n        }\n        // offset is a multiple of d_len\n        let mut offset = n_len.checked_sub(d_len + q_len_mod_d_len).unwrap();\n        while offset != 0 {\n            offset -= d_len;\n            limbs_div_mod_divide_and_conquer_helper(\n                &mut qs[offset..],\n                &mut ns[offset..],\n                ds,\n                d_inv,\n                &mut scratch,\n            );\n        }\n    } else {\n        let m = d_len - q_len;\n        let (ds_lo, ds_hi) = ds.split_at(m);\n        highest_q = if q_len < DC_DIV_QR_THRESHOLD {\n            limbs_div_mod_schoolbook(qs, &mut ns[m..], ds_hi, d_inv)\n        } else {\n            limbs_div_mod_divide_and_conquer_helper(qs, &mut ns[m..], ds_hi, d_inv, &mut scratch)\n        };\n        if m != 0 {\n            let qs = &mut qs[..q_len];\n            let ns = &mut ns[..d_len];\n            let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(q_len, ds_lo.len())];\n            limbs_mul_to_out(&mut scratch, qs, ds_lo, &mut mul_scratch);\n            let mut carry = Limb::from(limbs_sub_same_length_in_place_left(ns, &scratch));\n            if highest_q && limbs_sub_same_length_in_place_left(&mut ns[q_len..], ds_lo) {\n                carry += 1;\n            }\n            while carry != 0 {\n                if limbs_sub_limb_in_place(qs, 1) {\n                    assert!(highest_q);\n                    highest_q = false;\n                }\n                if limbs_slice_add_same_length_in_place_left(ns, ds) {\n                    carry -= 1;\n                }\n            }\n        }\n    }\n    highest_q\n}}\n\npub_test! {limbs_div_approx_helper(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb], d_inv: Limb) {\n    if ds.len() < DC_DIVAPPR_Q_THRESHOLD {\n        limbs_div_schoolbook_approx(qs, ns, ds, d_inv);\n    } else {\n        limbs_div_divide_and_conquer_approx(qs, ns, ds, d_inv);\n    }\n}}\n\n// Takes the strictly normalized value ds (i.e., most significant bit must be set) as an input, and\n// computes the approximate reciprocal of `ds`, with the same length as `ds`. See documentation for\n// `limbs_invert_approx` for an explanation of the return value.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// # Panics\n// Panics if `ds` is empty, `is` is shorter than `ds`, `scratch` is shorter than twice the length of\n// `ds`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_bc_invertappr` from `mpn/generic/invertappr.c`, GMP 6.2.1, where the\n// return value is `true` iff the return value of `mpn_bc_invertappr` would be 0.\npub_test! {limbs_invert_basecase_approx(\n    is: &mut [Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb]\n) -> bool {\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    let highest_d = ds[d_len - 1];\n    assert!(highest_d.get_highest_bit());\n    if d_len == 1 {\n        let d = ds[0];\n        is[0] = limbs_invert_limb::<DoubleLimb, Limb>(d);\n    } else {\n        let scratch = &mut scratch[..d_len << 1];\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(d_len);\n        for s in &mut *scratch_lo {\n            *s = Limb::MAX;\n        }\n        limbs_not_to_out(scratch_hi, ds);\n        // Now scratch contains 2 ^ (2 * d_len * Limb::WIDTH) - d * 2 ^ (d_len * Limb::WIDTH) - 1\n        if d_len == 2 {\n            limbs_div_mod_by_two_limb_normalized(is, scratch, ds);\n        } else {\n            let d_inv = limbs_two_limb_inverse_helper(highest_d, ds[d_len - 2]);\n            if MAYBE_DCP1_DIVAPPR {\n                limbs_div_approx_helper(is, scratch, ds, d_inv);\n            } else {\n                limbs_div_schoolbook_approx(is, scratch, ds, d_inv);\n            }\n            assert!(!limbs_sub_limb_in_place(&mut is[..d_len], 1));\n            return false;\n        }\n    }\n    true\n}}\n\n// Takes the strictly normalized value ds (i.e., most significant bit must be set) as an input, and\n// computes the approximate reciprocal of `ds`, with the same length as `ds`. See documentation for\n// `limbs_invert_approx` for an explanation of the return value.\n//\n// Uses Newton's iterations (at least one). Inspired by Algorithm \"ApproximateReciprocal\", published\n// in \"Modern Computer Arithmetic\" by Richard P. Brent and Paul Zimmermann, algorithm 3.5, page 121\n// in version 0.4 of the book.\n//\n// Some adaptations were introduced, to allow product mod B ^ m - 1 and return the value e.\n//\n// We introduced a correction in such a way that \"the value of B ^ {n + h} - T computed at step 8\n// cannot exceed B ^ n - 1\" (the book reads \"2 * B ^ n - 1\").\n//\n// Maximum scratch needed by this branch <= 2 * n, but have to fit 3 * rn in the scratch, i.e. 3 *\n// rn <= 2 * n: we require n > 4.\n//\n// We use a wrapped product modulo B ^ m - 1.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `is.len()`.\n//\n// # Panics\n// Panics if `ds` has length less than 5, `is` is shorter than `ds`, `scratch` is shorter than twice\n// the length of `ds`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_ni_invertappr` from `mpn/generic/invertappr.c`, GMP 6.2.1, where the\n// return value is `true` iff the return value of `mpn_ni_invertappr` would be 0.\npub_test! {limbs_invert_newton_approx(is: &mut [Limb], ds: &[Limb], scratch: &mut [Limb]) -> bool {\n    let d_len = ds.len();\n    assert!(d_len > 4);\n    assert!(ds[d_len - 1].get_highest_bit());\n    let is = &mut is[..d_len];\n    // Compute the computation precisions from highest to lowest, leaving the base case size in\n    // 'previous_d'.\n    let mut size = d_len;\n    let mut sizes = vec![size];\n    size = (size >> 1) + 1;\n    let mut scratch2 = vec![];\n    let mut mul_size = 0;\n    if d_len >= INV_MULMOD_BNM1_THRESHOLD {\n        mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1);\n        scratch2 = vec![0; limbs_mul_mod_base_pow_n_minus_1_scratch_len(mul_size, d_len, size)];\n    }\n    while size >= INV_NEWTON_THRESHOLD {\n        sizes.push(size);\n        size = (size >> 1) + 1;\n    }\n    // We compute the inverse of 0.ds as 1.is. Compute a base value of previous_d limbs.\n    limbs_invert_basecase_approx(&mut is[d_len - size..], &ds[d_len - size..], scratch);\n    let mut previous_size = size;\n    let mut a = 0;\n    // Use Newton's iterations to get the desired precision.\n    for &size in sizes.iter().rev() {\n        // ```\n        // v    d       v\n        // +----+-------+\n        // ^ previous_d ^\n        // ```\n        //\n        // Compute i_j * d\n        let ds_hi = &ds[d_len - size..];\n        let condition = size < INV_MULMOD_BNM1_THRESHOLD || {\n            mul_size = limbs_mul_mod_base_pow_n_minus_1_next_size(size + 1);\n            mul_size > size + previous_size\n        };\n        let diff = size - previous_size;\n        let is_hi = &mut is[d_len - previous_size..];\n        if condition {\n            let mut mul_scratch =\n                vec![0; limbs_mul_greater_to_out_scratch_len(ds_hi.len(), is_hi.len())];\n            limbs_mul_greater_to_out(scratch, ds_hi, is_hi, &mut mul_scratch);\n            limbs_slice_add_same_length_in_place_left(\n                &mut scratch[previous_size..=size],\n                &ds_hi[..=diff],\n            );\n        } else {\n            // Remember we truncated mod B ^ (d + 1) We computed (truncated) xp of length d + 1 <-\n            // 1.is * 0.ds Use B ^ mul_size - 1 wraparound\n            limbs_mul_mod_base_pow_n_minus_1(scratch, mul_size, ds_hi, is_hi, &mut scratch2);\n            let scratch = &mut scratch[..=mul_size];\n            // We computed {xp, mul_size} <- {is, previous_d} * {ds, d} mod (B ^ mul_size - 1) We\n            // know that 2 * |is * ds + ds * B ^ previous_d - B ^ {previous_d + d}| < B ^ mul_size\n            // - 1 Add ds * B ^ previous_d mod (B ^ mul_size - 1)\n            let mul_diff = mul_size - previous_size;\n            assert!(size >= mul_diff);\n            let (ds_hi_lo, ds_hi_hi) = ds_hi.split_at(mul_diff);\n            let carry = limbs_slice_add_same_length_in_place_left(\n                &mut scratch[previous_size..mul_size],\n                ds_hi_lo,\n            );\n            // Subtract B ^ {previous_d + d}, maybe only compensate the carry\n            scratch[mul_size] = 1; // set a limit for decrement\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(size - mul_diff);\n            if !limbs_add_same_length_with_carry_in_in_place_left(scratch_lo, ds_hi_hi, carry) {\n                assert!(!limbs_sub_limb_in_place(scratch_hi, 1));\n            }\n            // if decrement eroded xp[mul_size]\n            let (scratch_last, scratch_init) = scratch.split_last_mut().unwrap();\n            assert!(!limbs_sub_limb_in_place(\n                scratch_init,\n                1.wrapping_sub(*scratch_last)\n            ));\n            // Remember we are working mod B ^ mul_size - 1\n        }\n        if scratch[size] < 2 {\n            // \"positive\" residue class\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(size);\n            let mut carry = scratch_hi[0] + 1; // 1 <= carry <= 2 here.\n            if carry == 2 && !limbs_sub_same_length_in_place_left(scratch_lo, ds_hi) {\n                carry = 3;\n                assert!(limbs_sub_same_length_in_place_left(scratch_lo, ds_hi));\n            }\n            // 1 <= carry <= 3 here.\n            if limbs_cmp_same_length(scratch_lo, ds_hi) == Greater {\n                assert!(!limbs_sub_same_length_in_place_left(scratch_lo, ds_hi));\n                carry += 1;\n            }\n            let (scratch_lo, scratch_mid) = scratch_lo.split_at_mut(diff);\n            let (ds_hi_lo, ds_hi_hi) = ds_hi.split_at(diff);\n            let borrow = limbs_cmp_same_length(scratch_lo, ds_hi_lo) == Greater;\n            assert!(!limbs_sub_same_length_with_borrow_in_to_out(\n                &mut scratch_hi[diff..],\n                ds_hi_hi,\n                scratch_mid,\n                borrow\n            ));\n            assert!(!limbs_sub_limb_in_place(is_hi, carry)); // 1 <= carry <= 4 here\n        } else {\n            // \"negative\" residue class\n            assert!(scratch[size] >= Limb::MAX - 1);\n            if condition {\n                assert!(!limbs_sub_limb_in_place(&mut scratch[..=size], 1));\n            }\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(size);\n            if scratch_hi[0] != Limb::MAX {\n                assert!(!limbs_slice_add_limb_in_place(is_hi, 1));\n                assert!(limbs_slice_add_same_length_in_place_left(scratch_lo, ds_hi));\n            }\n            limbs_not_to_out(&mut scratch_hi[diff..size], &scratch_lo[diff..]);\n        }\n        // Compute x_j * u_j\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(size + diff);\n        let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(is_hi.len())];\n        limbs_mul_same_length_to_out(\n            scratch_lo,\n            &scratch_hi[..previous_size],\n            is_hi,\n            &mut mul_scratch,\n        );\n        a = (previous_size << 1) - diff;\n        let carry = {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(a);\n            limbs_slice_add_same_length_in_place_left(\n                &mut scratch_lo[previous_size..],\n                &scratch_hi[3 * diff - previous_size..diff << 1],\n            )\n        };\n        if limbs_add_same_length_with_carry_in_to_out(\n            &mut is[d_len - size..],\n            &scratch[a..previous_size << 1],\n            &scratch[size + previous_size..size << 1],\n            carry,\n        ) {\n            assert!(!limbs_slice_add_limb_in_place(\n                &mut is[d_len - previous_size..],\n                1\n            ));\n        }\n        previous_size = size;\n    }\n    // Check for possible carry propagation from below. Be conservative.\n    scratch[a - 1] <= Limb::MAX - 7\n}}\n\n// Takes the strictly normalized value ds (i.e., most significant bit must be set) as an input, and\n// computes the approximate reciprocal of `ds`, with the same length as `ds`.\n//\n// Let result_definitely_exact = limbs_invert_basecase_approx(is, ds, scratch) be the returned\n// value. If result_definitely_exact is `true`, the error e is 0; otherwise, it may be 0 or 1. The\n// following condition is satisfied by the output:\n//\n// ds * (2 ^ (n * Limb::WIDTH) + is) < 2 ^ (2 * n * Limb::WIDTH) <= ds * (2 ^ (n * Limb::WIDTH) + is\n// + 1 + e), where n = `ds.len()`.\n//\n// When the strict result is needed, i.e., e = 0 in the relation above, the function `mpn_invert`\n// (TODO!) should be used instead.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `is.len()`.\n//\n// # Panics\n// Panics if `ds` is empty, `is` is shorter than `ds`, `scratch` is shorter than twice the length of\n// `ds`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_invertappr` from `mpn/generic/invertappr.c`, GMP 6.2.1, where the\n// return value is `true` iff the return value of `mpn_invertappr` would be 0.\npub_crate_test! {limbs_invert_approx(is: &mut [Limb], ds: &[Limb], scratch: &mut [Limb]) -> bool {\n    if ds.len() < INV_NEWTON_THRESHOLD {\n        limbs_invert_basecase_approx(is, ds, scratch)\n    } else {\n        limbs_invert_newton_approx(is, ds, scratch)\n    }\n}}\n\n// TODO tune\npub(crate) const MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD: usize = INV_MULMOD_BNM1_THRESHOLD >> 1;\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// - ds.len() >= 2\n// - n_len >= 3\n// - n_len >= ds.len()\n// - i_len == limbs_div_mod_barrett_is_len(n_len - ds.len(), ds.len())\n// - qs.len() == i_len\n// - scratch_len ==  limbs_mul_mod_base_pow_n_minus_1_next_size(ds.len() + 1)\n// - scratch.len() == limbs_div_mod_barrett_scratch_len(n_len, d_len) - i_len\n// - rs_hi.len() == i_len\npub_crate_test! {limbs_div_barrett_large_product(\n    scratch: &mut [Limb],\n    ds: &[Limb],\n    qs: &[Limb],\n    rs_hi: &[Limb],\n    scratch_len: usize,\n    i_len: usize,\n) {\n    let d_len = ds.len();\n    let (scratch, scratch_out) = scratch.split_at_mut(scratch_len);\n    limbs_mul_mod_base_pow_n_minus_1(scratch, scratch_len, ds, qs, scratch_out);\n    if d_len + i_len > scratch_len {\n        let (rs_hi_lo, rs_hi_hi) = rs_hi.split_at(scratch_len - d_len);\n        let carry_1 = limbs_sub_greater_in_place_left(scratch, rs_hi_hi);\n        let carry_2 = limbs_cmp_same_length(rs_hi_lo, &scratch[d_len..]) == Less;\n        if !carry_1 && carry_2 {\n            assert!(!limbs_slice_add_limb_in_place(scratch, 1));\n        } else {\n            assert_eq!(carry_1, carry_2);\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n, d) = O(n \\log d \\log\\log d)$\n//\n// $M(n) = O(d \\log d)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ns.len()`, and $d$ is `ds.len()`.\n//\n// This is equivalent to `mpn_preinv_mu_div_qr` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1.\nfn limbs_div_mod_barrett_preinverted(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    mut is: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_eq!(rs.len(), d_len);\n    let mut i_len = is.len();\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    let (ns_lo, ns_hi) = ns.split_at(q_len);\n    let highest_q = limbs_cmp_same_length(ns_hi, ds) >= Equal;\n    if highest_q {\n        limbs_sub_same_length_to_out(rs, ns_hi, ds);\n    } else {\n        rs.copy_from_slice(ns_hi);\n    }\n    let scratch_len = if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        0\n    } else {\n        limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1)\n    };\n    let mut n = d_len - i_len;\n    for (ns, qs) in ns_lo.rchunks(i_len).zip(qs.rchunks_mut(i_len)) {\n        let chunk_len = ns.len();\n        if i_len != chunk_len {\n            // last iteration\n            is = &is[i_len - chunk_len..];\n            i_len = chunk_len;\n            n = d_len - i_len;\n        }\n        let (rs_lo, rs_hi) = rs.split_at_mut(n);\n        // Compute the next block of quotient limbs by multiplying the inverse by the upper part of\n        // the partial remainder.\n        let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(is.len())];\n        limbs_mul_same_length_to_out(scratch, rs_hi, is, &mut mul_scratch);\n        // The inverse's most significant bit is implicit.\n        assert!(!limbs_add_same_length_to_out(\n            qs,\n            &scratch[i_len..i_len << 1],\n            rs_hi,\n        ));\n        // Compute the product of the quotient block and the divisor, to be subtracted from the\n        // partial remainder combined with new limbs from the dividend. We only really need the low\n        // d_len + 1 limbs.\n        if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs.len())];\n            limbs_mul_greater_to_out(scratch, ds, qs, &mut mul_scratch);\n        } else {\n            limbs_div_barrett_large_product(scratch, ds, qs, rs_hi, scratch_len, i_len);\n        }\n        let mut r = rs_hi[0].wrapping_sub(scratch[d_len]);\n        // Subtract the product from the partial remainder combined with new limbs from the\n        // dividend, generating a new partial remainder.\n        let scratch = &mut scratch[..d_len];\n        let carry = if n == 0 {\n            // Get next i_len limbs from n.\n            limbs_sub_same_length_to_out(rs, ns, scratch)\n        } else {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(i_len);\n            // Get next i_len limbs from n.\n            let carry = limbs_sub_same_length_with_borrow_in_in_place_right(\n                rs_lo,\n                scratch_hi,\n                limbs_sub_same_length_in_place_right(ns, scratch_lo),\n            );\n            rs.copy_from_slice(scratch);\n            carry\n        };\n        // Check the remainder and adjust the quotient as needed.\n        if carry {\n            r.wrapping_sub_assign(1);\n        }\n        while r != 0 {\n            // We loop 0 times with about 69% probability, 1 time with about 31% probability, and 2\n            // times with about 0.6% probability, if the inverse is computed as recommended.\n            assert!(!limbs_slice_add_limb_in_place(qs, 1));\n            if limbs_sub_same_length_in_place_left(rs, ds) {\n                r -= 1;\n            }\n        }\n        if limbs_cmp_same_length(rs, ds) >= Equal {\n            // This is executed with about 76% probability.\n            assert!(!limbs_slice_add_limb_in_place(qs, 1));\n            limbs_sub_same_length_in_place_left(rs, ds);\n        }\n    }\n    highest_q\n}\n\n// We distinguish 3 cases:\n//\n// - d_len < q_len:              i_len = ceil(q_len / ceil(q_len / d_len))\n// - d_len / 3 < q_len <= d_len: i_len = ceil(q_len / 2)\n// - q_len < d_len / 3:          i_len = q_len\n//\n// In all cases we have i_len <= d_len.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// Result is O(`q_len`)\n//\n// This is equivalent to `mpn_mu_div_qr_choose_in` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1, where\n// `k == 0`.\npub_const_crate_test! {limbs_div_mod_barrett_is_len(q_len: usize, d_len: usize) -> usize {\n    let q_len_minus_1 = q_len - 1;\n    if q_len > d_len {\n        // Compute an inverse size that is a nice partition of the quotient.\n        let b = q_len_minus_1 / d_len + 1; // ceil(q_len / d_len), number of blocks\n        q_len_minus_1 / b + 1 // ceil(q_len / b) = ceil(q_len / ceil(q_len / d_len))\n    } else if 3 * q_len > d_len {\n        (q_len_minus_1 >> 1) + 1 // b = 2\n    } else {\n        q_len_minus_1 + 1 // b = 1\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mu_div_qr2` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1.\npub_crate_test! {limbs_div_mod_barrett_helper(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_eq!(rs.len(), d_len);\n    assert!(d_len > 1);\n    assert!(n_len > d_len);\n    let q_len = n_len - d_len;\n    // Compute the inverse size.\n    let i_len = limbs_div_mod_barrett_is_len(q_len, d_len);\n    assert!(i_len <= d_len);\n    let i_len_plus_1 = i_len + 1;\n    let (is, scratch_hi) = scratch.split_at_mut(i_len_plus_1);\n    // compute an approximate inverse on i_len + 1 limbs\n    if d_len == i_len {\n        let (scratch_lo, scratch_hi) = scratch_hi.split_at_mut(i_len_plus_1);\n        let (scratch_first, scratch_lo_tail) = scratch_lo.split_first_mut().unwrap();\n        scratch_lo_tail.copy_from_slice(&ds[..i_len]);\n        *scratch_first = 1;\n        limbs_invert_approx(is, scratch_lo, scratch_hi);\n        slice_move_left(is, 1);\n    } else if limbs_add_limb_to_out(scratch_hi, &ds[d_len - i_len_plus_1..], 1) {\n        slice_set_zero(&mut is[..i_len]);\n    } else {\n        let (scratch_lo, scratch_hi) = scratch_hi.split_at_mut(i_len_plus_1);\n        limbs_invert_approx(is, scratch_lo, scratch_hi);\n        slice_move_left(is, 1);\n    }\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(i_len);\n    limbs_div_mod_barrett_preinverted(qs, rs, ns, ds, scratch_lo, scratch_hi)\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// Result is O(`d_len`)\n//\n// This is equivalent to `mpn_preinv_mu_div_qr_itch` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1, but\n// `nn` is omitted from the arguments as it is unused.\nfn limbs_div_mod_barrett_preinverse_scratch_len(d_len: usize, is_len: usize) -> usize {\n    let itch_local = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1);\n    let itch_out = limbs_mul_mod_base_pow_n_minus_1_scratch_len(itch_local, d_len, is_len);\n    itch_local + itch_out\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_invertappr_itch` from `gmp-impl.h`, GMP 6.2.1.\npub(crate) const fn limbs_invert_approx_scratch_len(is_len: usize) -> usize {\n    is_len << 1\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// Result is O(`n_len`)\n//\n// This is equivalent to `mpn_mu_div_qr_itch` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1, where\n// `mua_k == 0`.\npub_crate_test! {limbs_div_mod_barrett_scratch_len(n_len: usize, d_len: usize) -> usize {\n    let is_len = limbs_div_mod_barrett_is_len(n_len - d_len, d_len);\n    let preinverse_len = limbs_div_mod_barrett_preinverse_scratch_len(d_len, is_len);\n    // 3 * is_len + 4\n    let inv_approx_len = limbs_invert_approx_scratch_len(is_len + 1) + is_len + 2;\n    assert!(preinverse_len >= inv_approx_len);\n    is_len + preinverse_len\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\npub_test! {limbs_div_mod_barrett_large_helper(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = qs.len();\n    let q_len_plus_one = q_len + 1;\n    let n = n_len - q_len - q_len_plus_one; // 2 * d_len - n_len - 1\n    let (ns_lo, ns_hi) = ns.split_at(n);\n    let (ds_lo, ds_hi) = ds.split_at(d_len - q_len_plus_one);\n    let (rs_lo, rs_hi) = rs.split_at_mut(n);\n    let rs_hi = &mut rs_hi[..q_len_plus_one];\n    let mut highest_q = limbs_div_mod_barrett_helper(qs, rs_hi, ns_hi, ds_hi, scratch);\n    // Multiply the quotient by the divisor limbs ignored above. The product is d_len - 1 limbs\n    // long.\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(ds_lo.len(), qs.len())];\n    limbs_mul_to_out(scratch, ds_lo, qs, &mut mul_scratch);\n    let (scratch_last, scratch_init) = scratch[..d_len].split_last_mut().unwrap();\n    *scratch_last = Limb::from(\n        highest_q && limbs_slice_add_same_length_in_place_left(&mut scratch_init[q_len..], ds_lo),\n    );\n    let (scratch_lo, scratch_hi) = scratch.split_at(n);\n    let scratch_hi = &scratch_hi[..q_len_plus_one];\n    if limbs_sub_same_length_with_borrow_in_in_place_left(\n        rs_hi,\n        scratch_hi,\n        limbs_sub_same_length_to_out(rs_lo, ns_lo, scratch_lo),\n    ) {\n        if limbs_sub_limb_in_place(qs, 1) {\n            assert!(highest_q);\n            highest_q = false;\n        }\n        limbs_slice_add_same_length_in_place_left(&mut rs[..d_len], ds);\n    }\n    highest_q\n}}\n\n// Block-wise Barrett division. The idea of the algorithm used herein is to compute a smaller\n// inverted value than used in the standard Barrett algorithm, and thus save time in the Newton\n// iterations, and pay just a small price when using the inverted value for developing quotient\n// bits. This algorithm was presented at ICMS 2006.\n//\n// `ns` must have length at least 3, `ds` must have length at least 2 and be no longer than `ns`,\n// and the most significant bit of `ds` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 2, `ns.len()` is less than `ds.len()`, `qs` has length\n// less than `ns.len()` - `ds.len()`, `scratch` is too short, or the last limb of `ds` does not have\n// its highest bit set.\n//\n// This is equivalent to `mpn_mu_div_qr` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1.\npub_test! {limbs_div_mod_barrett(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    // Test whether 2 * d_len - n_len > MU_DIV_QR_SKEW_THRESHOLD\n    if d_len <= q_len + MU_DIV_QR_SKEW_THRESHOLD {\n        limbs_div_mod_barrett_helper(qs, &mut rs[..d_len], ns, ds, scratch)\n    } else {\n        limbs_div_mod_barrett_large_helper(qs, rs, ns, ds, scratch)\n    }\n}}\n\n// `ds` must have length 2, `ns` must have length at least 2, `qs` must have length at least\n// `ns.len() - 2`, `rs` must have length at least 2, and the most-significant limb of `ds` must be\n// nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_div_mod_by_two_limb(qs: &mut [Limb], rs: &mut [Limb], ns: &[Limb], ds: &[Limb]) {\n    let n_len = ns.len();\n    let ds_1 = ds[1];\n    let bits = LeadingZeros::leading_zeros(ds_1);\n    if bits == 0 {\n        let mut ns = ns.to_vec();\n        // always store n_len - 1 quotient limbs\n        qs[n_len - 2] = Limb::from(limbs_div_mod_by_two_limb_normalized(qs, &mut ns, ds));\n        rs[0] = ns[0];\n        rs[1] = ns[1];\n    } else {\n        let ds_0 = ds[0];\n        let cobits = Limb::WIDTH - bits;\n        let mut ns_shifted = vec![0; n_len + 1];\n        let ns_shifted = &mut ns_shifted;\n        let carry = limbs_shl_to_out(ns_shifted, ns, bits);\n        let ds_shifted = &mut [ds_0 << bits, (ds_1 << bits) | (ds_0 >> cobits)];\n        if carry == 0 {\n            // always store n_len - 1 quotient limbs\n            qs[n_len - 2] = Limb::from(limbs_div_mod_by_two_limb_normalized(\n                qs,\n                &mut ns_shifted[..n_len],\n                ds_shifted,\n            ));\n        } else {\n            ns_shifted[n_len] = carry;\n            limbs_div_mod_by_two_limb_normalized(qs, ns_shifted, ds_shifted);\n        }\n        let ns_shifted_1 = ns_shifted[1];\n        rs[0] = (ns_shifted[0] >> bits) | (ns_shifted_1 << cobits);\n        rs[1] = ns_shifted_1 >> bits;\n    }\n}\n\n// TODO tune\npub(crate) const MUPI_DIV_QR_THRESHOLD: usize = 74;\n\n// # Worst-case complexity\n// Constant time and additional memory.\nfn limbs_div_mod_dc_condition(n_len: usize, d_len: usize) -> bool {\n    let n_64 = n_len as f64;\n    let d_64 = d_len as f64;\n    d_len < MUPI_DIV_QR_THRESHOLD\n        || n_len < MU_DIV_QR_THRESHOLD << 1\n        || fma!(\n            ((MU_DIV_QR_THRESHOLD - MUPI_DIV_QR_THRESHOLD) << 1) as f64,\n            d_64,\n            MUPI_DIV_QR_THRESHOLD as f64 * n_64\n        ) > d_64 * n_64\n}\n\n// This function is optimized for the case when the numerator has at least twice the length of the\n// denominator.\n//\n// `ds` must have length at least 3, `ns` must be at least as long as `ds`, `qs` must have length at\n// least `ns.len() - ds.len() + 1`, `rs` must have the same length as `ds`, and the most-\n// significant limb of `ds` must be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\nfn limbs_div_mod_unbalanced(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    adjusted_n_len: usize,\n) {\n    let mut n_len = ns.len();\n    let d_len = ds.len();\n    qs[n_len - d_len] = 0; // zero high quotient limb\n    let mut ds_shifted_vec;\n    let ds_shifted: &[Limb];\n    let mut ns_shifted_vec = vec![0; n_len + 1];\n    let ns_shifted = &mut ns_shifted_vec;\n    let bits = LeadingZeros::leading_zeros(*ds.last().unwrap());\n    if bits == 0 {\n        ds_shifted = ds;\n        ns_shifted[..n_len].copy_from_slice(ns);\n    } else {\n        // normalize divisor\n        ds_shifted_vec = vec![0; d_len];\n        limbs_shl_to_out(&mut ds_shifted_vec, ds, bits);\n        ds_shifted = &ds_shifted_vec;\n        let (ns_shifted_last, ns_shifted_init) = ns_shifted.split_last_mut().unwrap();\n        *ns_shifted_last = limbs_shl_to_out(ns_shifted_init, ns, bits);\n    }\n    n_len = adjusted_n_len;\n    let d_inv = limbs_two_limb_inverse_helper(ds_shifted[d_len - 1], ds_shifted[d_len - 2]);\n    let ns_shifted = &mut ns_shifted[..n_len];\n    if d_len < DC_DIV_QR_THRESHOLD {\n        limbs_div_mod_schoolbook(qs, ns_shifted, ds_shifted, d_inv);\n        let ns_shifted = &ns_shifted[..d_len];\n        if bits == 0 {\n            rs.copy_from_slice(ns_shifted);\n        } else {\n            limbs_shr_to_out(rs, ns_shifted, bits);\n        }\n    } else if limbs_div_mod_dc_condition(n_len, d_len) {\n        limbs_div_mod_divide_and_conquer(qs, ns_shifted, ds_shifted, d_inv);\n        let ns_shifted = &ns_shifted[..d_len];\n        if bits == 0 {\n            rs.copy_from_slice(ns_shifted);\n        } else {\n            limbs_shr_to_out(rs, ns_shifted, bits);\n        }\n    } else {\n        let scratch_len = limbs_div_mod_barrett_scratch_len(n_len, d_len);\n        let mut scratch = vec![0; scratch_len];\n        limbs_div_mod_barrett(qs, rs, ns_shifted, ds_shifted, &mut scratch);\n        if bits != 0 {\n            limbs_slice_shr_in_place(rs, bits);\n        }\n    }\n}\n\n// The numerator must have less than twice the length of the denominator.\n//\n// Problem:\n//\n// Divide a numerator N with `n_len` limbs by a denominator D with `d_len` limbs, forming a quotient\n// of `q_len` = `n_len` - `d_len` + 1 limbs. When `q_len` is small compared to `d_len`, conventional\n// division algorithms perform poorly. We want an algorithm that has an expected running time that\n// is dependent only on `q_len`.\n//\n// Algorithm (very informally stated):\n//\n// 1) Divide the 2 * `q_len` most significant limbs from the numerator by the `q_len` most-\n// significant limbs from the denominator. Call the result `qest`. This is either the correct\n// quotient, or 1 or 2 too large. Compute the remainder from the division.\n//\n// 2) Is the most significant limb from the remainder < p, where p is the product of the most-\n// significant limb from the quotient and the next(d)? (Next(d) denotes the next ignored limb from\n// the denominator.)  If it is, decrement `qest`, and adjust the remainder accordingly.\n//\n// 3) Is the remainder >= `qest`?  If it is, `qest` is the desired quotient. The algorithm\n// terminates.\n//\n// 4) Subtract `qest` * next(d) from the remainder. If there is borrow out, decrement `qest`, and\n// adjust the remainder accordingly.\n//\n// 5) Skip one word from the denominator (i.e., let next(d) denote the next less significant limb).\n//\n// `ds` must have length at least 3, `ns` must be at least as long as `ds` but no more than twice as\n// long, `qs` must have length at least `ns.len() - ds.len() + 1`,`rs` must have the same length as\n// `ds`, and the most-significant limb of `ds` must be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub(crate) fn limbs_div_mod_balanced(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    adjust: bool,\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let mut q_len = n_len - d_len;\n    assert!(d_len >= q_len);\n    qs[q_len] = 0; // zero high quotient limb\n    if adjust {\n        q_len += 1;\n    } else if q_len == 0 {\n        rs.copy_from_slice(&ns[..d_len]);\n        return;\n    }\n    let q_len = q_len;\n    // `i_len` is the (at least partially) ignored number of limbs.\n    let i_len = d_len - q_len;\n    // Normalize the denominator by shifting it to the left such that its most significant bit is\n    // set. Then shift the numerator the same amount, to mathematically preserve the quotient.\n    let bits = LeadingZeros::leading_zeros(ds[d_len - 1]);\n    let cobits = Limb::WIDTH - bits;\n    let q_len_2 = q_len << 1;\n    let m = n_len - q_len_2;\n    let mut ns_shifted_vec = vec![0; q_len_2 + 1];\n    let mut ds_shifted_vec;\n    let ds_shifted: &[Limb];\n    let ds_hi = &ds[i_len..];\n    let ds_lo_last = ds[i_len - 1];\n    let carry = if bits == 0 {\n        ds_shifted = ds_hi;\n        ns_shifted_vec[..q_len_2].copy_from_slice(&ns[m..]);\n        0\n    } else {\n        ds_shifted_vec = vec![0; q_len];\n        limbs_shl_to_out(&mut ds_shifted_vec, ds_hi, bits);\n        ds_shifted_vec[0] |= ds_lo_last >> cobits;\n        ds_shifted = &ds_shifted_vec;\n        let carry = limbs_shl_to_out(&mut ns_shifted_vec, &ns[m..], bits);\n        if !adjust {\n            ns_shifted_vec[0] |= ns[m - 1] >> cobits;\n        }\n        carry\n    };\n    let ns_shifted = if adjust {\n        ns_shifted_vec[q_len_2] = carry;\n        &mut ns_shifted_vec[1..]\n    } else {\n        &mut ns_shifted_vec\n    };\n    // Get an approximate quotient using the extracted operands.\n    if q_len == 1 {\n        (qs[0], ns_shifted[0]) =\n            Limb::xx_div_mod_y_to_qr(ns_shifted[1], ns_shifted[0], ds_shifted[0]);\n    } else if q_len == 2 {\n        limbs_div_mod_by_two_limb_normalized(qs, ns_shifted, ds_shifted);\n    } else {\n        let ns_shifted = &mut ns_shifted[..q_len_2];\n        let d_inv = limbs_two_limb_inverse_helper(ds_shifted[q_len - 1], ds_shifted[q_len - 2]);\n        if q_len < DC_DIV_QR_THRESHOLD {\n            limbs_div_mod_schoolbook(qs, ns_shifted, ds_shifted, d_inv);\n        } else if q_len < MU_DIV_QR_THRESHOLD {\n            limbs_div_mod_divide_and_conquer(qs, ns_shifted, ds_shifted, d_inv);\n        } else {\n            let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(q_len_2, q_len)];\n            limbs_div_mod_barrett(qs, rs, ns_shifted, ds_shifted, &mut scratch);\n            ns_shifted[..q_len].copy_from_slice(&rs[..q_len]);\n        }\n    }\n    // Multiply the first ignored divisor limb by the most significant quotient limb. If that\n    // product is > the partial remainder's most significant limb, we know the quotient is too\n    // large. This test quickly catches most cases where the quotient is too large; it catches all\n    // cases where the quotient is 2 too large.\n    let mut r_len = q_len;\n    let mut x = ds_lo_last << bits;\n    if i_len >= 2 {\n        x |= ds[i_len - 2] >> 1 >> (!bits & Limb::WIDTH_MASK);\n    }\n    if ns_shifted[q_len - 1] < (DoubleLimb::from(x) * DoubleLimb::from(qs[q_len - 1])).upper_half()\n    {\n        assert!(!limbs_sub_limb_in_place(qs, 1));\n        let carry = limbs_slice_add_same_length_in_place_left(&mut ns_shifted[..q_len], ds_shifted);\n        if carry {\n            // The partial remainder is safely large.\n            ns_shifted[q_len] = 1;\n            r_len += 1;\n        }\n    }\n    let mut q_too_large = false;\n    let mut do_extra_cleanup = true;\n    let mut scratch = vec![0; d_len];\n    let mut i_len_alt = i_len;\n    let qs_lo = &mut qs[..q_len];\n    if bits != 0 {\n        // Append the partially used numerator limb to the partial remainder.\n        let carry_1 = limbs_slice_shl_in_place(&mut ns_shifted[..r_len], cobits);\n        let mask = Limb::MAX >> bits;\n        ns_shifted[0] |= ns[i_len - 1] & mask;\n        // Update partial remainder with partially used divisor limb.\n        let (ns_shifted_last, ns_shifted_init) = ns_shifted[..=q_len].split_last_mut().unwrap();\n        let carry_2 = limbs_sub_mul_limb_same_length_in_place_left(\n            ns_shifted_init,\n            qs_lo,\n            ds[i_len - 1] & mask,\n        );\n        if q_len == r_len {\n            (*ns_shifted_last, q_too_large) = carry_1.overflowing_sub(carry_2);\n            r_len += 1;\n        } else {\n            assert!(*ns_shifted_last >= carry_2);\n            ns_shifted_last.wrapping_sub_assign(carry_2);\n        }\n        i_len_alt -= 1;\n    }\n    // True: partial remainder now is neutral, i.e., it is not shifted up.\n    if i_len_alt == 0 {\n        rs.copy_from_slice(&ns_shifted[..r_len]);\n        do_extra_cleanup = false;\n    } else {\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(qs_lo.len(), i_len_alt)];\n        limbs_mul_to_out(&mut scratch, qs_lo, &ds[..i_len_alt], &mut mul_scratch);\n    }\n    if do_extra_cleanup {\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(i_len_alt);\n        q_too_large |=\n            limbs_sub_greater_in_place_left(&mut ns_shifted[..r_len], &scratch_hi[..q_len]);\n        let (rs_lo, rs_hi) = rs.split_at_mut(i_len_alt);\n        let rs_hi_len = rs_hi.len();\n        rs_hi.copy_from_slice(&ns_shifted[..rs_hi_len]);\n        q_too_large |= limbs_sub_same_length_to_out(rs_lo, &ns[..i_len_alt], scratch_lo)\n            && limbs_sub_limb_in_place(&mut rs_hi[..min(rs_hi_len, r_len)], 1);\n    }\n    if q_too_large {\n        assert!(!limbs_sub_limb_in_place(qs, 1));\n        limbs_slice_add_same_length_in_place_left(rs, ds);\n    }\n}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, returning the quotient and remainder. The quotient has `ns.len() -\n// ds.len() + 1` limbs and the remainder `ds.len()` limbs.\n//\n// `ns` must be at least as long as `ds` and `ds` must have length at least 2 and its most\n// significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` has length less than 2, or the most-significant limb of\n// `ds` is zero.\n//\n// This is equivalent to `mpn_tdiv_qr` from `mpn/generic/tdiv_qr.c`, GMP 6.2.1, where `dn > 1` and\n// `qp` and `rp` are returned.\npub_test! {limbs_div_mod(ns: &[Limb], ds: &[Limb]) -> (Vec<Limb>, Vec<Limb>) {\n    let d_len = ds.len();\n    let mut qs = vec![0; ns.len() - d_len + 1];\n    let mut rs = vec![0; d_len];\n    limbs_div_mod_to_out(&mut qs, &mut rs, ns, ds);\n    (qs, rs)\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ns.len() - ds.len() + 1` limbs of the quotient to `qs` and\n// the `ds.len()` limbs of the remainder to `rs`.\n//\n// `ns` must be at least as long as `ds`, `qs` must have length at least `ns.len() - ds.len() + 1`,\n// `rs` must be at least as long as `ds`, and `ds` must have length at least 2 and its most\n// significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `qs` or `rs` are too short, `ns` is shorter than `ds`, `ds` has length less than 2, or\n// the most-significant limb of `ds` is zero.\n//\n// This is equivalent to `mpn_tdiv_qr` from `mpn/generic/tdiv_qr.c`, GMP 6.2.1, where `dn > 1`.\npub_crate_test! {limbs_div_mod_to_out(qs: &mut [Limb], rs: &mut [Limb], ns: &[Limb], ds: &[Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len > 1);\n    assert!(n_len >= d_len);\n    assert!(qs.len() > n_len - d_len);\n    let rs = &mut rs[..d_len];\n    let ds_last = *ds.last().unwrap();\n    assert!(ds_last != 0);\n    if d_len == 2 {\n        limbs_div_mod_by_two_limb(qs, rs, ns, ds);\n    } else {\n        // conservative tests for quotient size\n        let adjust = ns[n_len - 1] >= ds_last;\n        let adjusted_n_len = if adjust { n_len + 1 } else { n_len };\n        if adjusted_n_len < d_len << 1 {\n            limbs_div_mod_balanced(qs, rs, ns, ds, adjust);\n        } else {\n            limbs_div_mod_unbalanced(qs, rs, ns, ds, adjusted_n_len);\n        }\n    }\n}}\n\n// TODO improve!\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub_crate_test! {limbs_div_mod_qs_to_out_rs_to_ns(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb]) {\n    let ns_copy = ns.to_vec();\n    limbs_div_mod_to_out(qs, ns, &ns_copy, ds);\n}}\n\nimpl Natural {\n    fn div_mod_limb_ref(&self, other: Limb) -> (Self, Limb) {\n        match (self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (n, 1) => (n.clone(), 0),\n            (Self(Small(small)), other) => {\n                let (q, r) = small.div_rem(other);\n                (Self(Small(q)), r)\n            }\n            (Self(Large(limbs)), other) => {\n                let (qs, r) = limbs_div_limb_mod(limbs, other);\n                (Self::from_owned_limbs_asc(qs), r)\n            }\n        }\n    }\n\n    pub_test! {div_assign_mod_limb(&mut self, other: Limb) -> Limb {\n        match (&mut *self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (_, 1) => 0,\n            (Natural(Small(small)), other) => small.div_assign_rem(other),\n            (Natural(Large(limbs)), other) => {\n                let r = limbs_div_limb_in_place_mod(limbs, other);\n                self.trim();\n                r\n            }\n        }\n    }}\n}\n\nimpl DivMod<Self> for Natural {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value and returning the\n    /// quotient and remainder. The quotient is rounded towards negative infinity.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .div_mod(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .div_mod(Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_mod(mut self, other: Self) -> (Self, Self) {\n        let r = self.div_assign_mod(other);\n        (self, r)\n    }\n}\n\nimpl<'a> DivMod<&'a Self> for Natural {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and returning the quotient and remainder. The quotient is rounded towards negative\n    /// infinity.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .div_mod(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .div_mod(&Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_mod(mut self, other: &'a Self) -> (Self, Self) {\n        let r = self.div_assign_mod(other);\n        (self, r)\n    }\n}\n\nimpl DivMod<Natural> for &Natural {\n    type DivOutput = Natural;\n    type ModOutput = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and returning the quotient and remainder. The quotient is rounded towards negative\n    /// infinity.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .div_mod(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .div_mod(Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    fn div_mod(self, mut other: Natural) -> (Natural, Natural) {\n        if *self == other {\n            return (Natural::ONE, Natural::ZERO);\n        }\n        match (self, &mut other) {\n            (_, &mut Natural::ZERO) => panic!(\"division by zero\"),\n            (n, &mut Natural::ONE) => (n.clone(), Natural::ZERO),\n            (n, &mut Natural(Small(d))) => {\n                let (q, r) = n.div_mod_limb_ref(d);\n                (q, Natural(Small(r)))\n            }\n            (Natural(Small(_)), _) => (Natural::ZERO, self.clone()),\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                if ns.len() < ds.len() {\n                    (Natural::ZERO, self.clone())\n                } else {\n                    let (qs, mut rs) = limbs_div_mod(ns, ds);\n                    swap(&mut rs, ds);\n                    other.trim();\n                    (Natural::from_owned_limbs_asc(qs), other)\n                }\n            }\n        }\n    }\n}\n\nimpl DivMod<&Natural> for &Natural {\n    type DivOutput = Natural;\n    type ModOutput = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference and returning the\n    /// quotient and remainder. The quotient is rounded towards negative infinity.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .div_mod(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .div_mod(&Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    fn div_mod(self, other: &Natural) -> (Natural, Natural) {\n        if self == other {\n            return (Natural::ONE, Natural::ZERO);\n        }\n        match (self, other) {\n            (_, &Natural::ZERO) => panic!(\"division by zero\"),\n            (n, &Natural::ONE) => (n.clone(), Natural::ZERO),\n            (n, Natural(Small(d))) => {\n                let (q, r) = n.div_mod_limb_ref(*d);\n                (q, Natural(Small(r)))\n            }\n            (Natural(Small(_)), _) => (Natural::ZERO, self.clone()),\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                if ns.len() < ds.len() {\n                    (Natural::ZERO, self.clone())\n                } else {\n                    let (qs, rs) = limbs_div_mod(ns, ds);\n                    (\n                        Natural::from_owned_limbs_asc(qs),\n                        Natural::from_owned_limbs_asc(rs),\n                    )\n                }\n            }\n        }\n    }\n}\n\nimpl DivAssignMod<Self> for Natural {\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value and returning the remainder. The quotient is rounded towards\n    /// negative infinity.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivAssignMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// assert_eq!(x.div_assign_mod(Natural::from(10u32)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// assert_eq!(\n    ///     x.div_assign_mod(Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// assert_eq!(x, 810000006723u64);\n    /// ```\n    fn div_assign_mod(&mut self, mut other: Self) -> Self {\n        if *self == other {\n            *self = Self::ONE;\n            return Self::ZERO;\n        }\n        match (&mut *self, &mut other) {\n            (_, &mut Self::ZERO) => panic!(\"division by zero\"),\n            (_, &mut Self::ONE) => Self::ZERO,\n            (n, &mut Self(Small(d))) => Self(Small(n.div_assign_mod_limb(d))),\n            (Self(Small(_)), _) => {\n                let mut r = Self::ZERO;\n                swap(self, &mut r);\n                r\n            }\n            (Self(Large(ns)), Self(Large(ds))) => {\n                if ns.len() < ds.len() {\n                    let mut r = Self::ZERO;\n                    swap(self, &mut r);\n                    r\n                } else {\n                    let (mut qs, mut rs) = limbs_div_mod(ns, ds);\n                    swap(&mut qs, ns);\n                    swap(&mut rs, ds);\n                    self.trim();\n                    other.trim();\n                    other\n                }\n            }\n        }\n    }\n}\n\nimpl<'a> DivAssignMod<&'a Self> for Natural {\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value and returning the remainder. The quotient is rounded towards\n    /// negative infinity.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivAssignMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// assert_eq!(x.div_assign_mod(&Natural::from(10u32)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// assert_eq!(\n    ///     x.div_assign_mod(&Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// assert_eq!(x, 810000006723u64);\n    /// ```\n    fn div_assign_mod(&mut self, other: &'a Self) -> Self {\n        if self == other {\n            *self = Self::ONE;\n            return Self::ZERO;\n        }\n        match (&mut *self, other) {\n            (_, &Self::ZERO) => panic!(\"division by zero\"),\n            (_, &Self::ONE) => Self::ZERO,\n            (_, Self(Small(d))) => Self(Small(self.div_assign_mod_limb(*d))),\n            (Self(Small(_)), _) => {\n                let mut r = Self::ZERO;\n                swap(self, &mut r);\n                r\n            }\n            (Self(Large(ns)), Self(Large(ds))) => {\n                if ns.len() < ds.len() {\n                    let mut r = Self::ZERO;\n                    swap(self, &mut r);\n                    r\n                } else {\n                    let (mut qs, rs) = limbs_div_mod(ns, ds);\n                    swap(&mut qs, ns);\n                    self.trim();\n                    Self::from_owned_limbs_asc(rs)\n                }\n            }\n        }\n    }\n}\n\nimpl DivRem<Self> for Natural {\n    type DivOutput = Self;\n    type RemOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value and returning the\n    /// quotient and remainder. The quotient is rounded towards zero.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// For [`Natural`]s, `div_rem` is equivalent to\n    /// [`div_mod`](malachite_base::num::arithmetic::traits::DivMod::div_mod).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .div_rem(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .div_rem(Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(self, other: Self) -> (Self, Self) {\n        self.div_mod(other)\n    }\n}\n\nimpl<'a> DivRem<&'a Self> for Natural {\n    type DivOutput = Self;\n    type RemOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and returning the quotient and remainder. The quotient is rounded towards zero.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// For [`Natural`]s, `div_rem` is equivalent to\n    /// [`div_mod`](malachite_base::num::arithmetic::traits::DivMod::div_mod).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .div_rem(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .div_rem(&Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(self, other: &'a Self) -> (Self, Self) {\n        self.div_mod(other)\n    }\n}\n\nimpl DivRem<Natural> for &Natural {\n    type DivOutput = Natural;\n    type RemOutput = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and returning the quotient and remainder. The quotient is rounded towards zero.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// For [`Natural`]s, `div_rem` is equivalent to\n    /// [`div_mod`](malachite_base::num::arithmetic::traits::DivMod::div_mod).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .div_rem(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .div_rem(Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(self, other: Natural) -> (Natural, Natural) {\n        self.div_mod(other)\n    }\n}\n\nimpl DivRem<&Natural> for &Natural {\n    type DivOutput = Natural;\n    type RemOutput = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference and returning the\n    /// quotient and remainder. The quotient is rounded towards zero.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lfloor \\frac{x}{y} \\right \\rfloor, \\space\n    /// x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor \\right ).\n    /// $$\n    ///\n    /// For [`Natural`]s, `div_rem` is equivalent to\n    /// [`div_mod`](malachite_base::num::arithmetic::traits::DivMod::div_mod).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .div_rem(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .div_rem(&Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006723, 530068894399)\"\n    /// );\n    /// ```\n    #[inline]\n    fn div_rem(self, other: &Natural) -> (Natural, Natural) {\n        self.div_mod(other)\n    }\n}\n\nimpl DivAssignRem<Self> for Natural {\n    type RemOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value and returning the remainder. The quotient is rounded towards zero.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `div_assign_rem` is equivalent to\n    /// [`div_assign_mod`](malachite_base::num::arithmetic::traits::DivAssignMod::div_assign_mod).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivAssignRem;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// assert_eq!(x.div_assign_rem(Natural::from(10u32)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// assert_eq!(\n    ///     x.div_assign_rem(Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// assert_eq!(x, 810000006723u64);\n    /// ```\n    #[inline]\n    fn div_assign_rem(&mut self, other: Self) -> Self {\n        self.div_assign_mod(other)\n    }\n}\n\nimpl<'a> DivAssignRem<&'a Self> for Natural {\n    type RemOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference and returning the remainder. The quotient is rounded towards\n    /// zero.\n    ///\n    /// The quotient and remainder satisfy $x = qy + r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `div_assign_rem` is equivalent to\n    /// [`div_assign_mod`](malachite_base::num::arithmetic::traits::DivAssignMod::div_assign_mod).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivAssignRem;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// assert_eq!(x.div_assign_rem(&Natural::from(10u32)), 3);\n    /// assert_eq!(x, 2);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// assert_eq!(\n    ///     x.div_assign_rem(&Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// assert_eq!(x, 810000006723u64);\n    /// ```\n    #[inline]\n    fn div_assign_rem(&mut self, other: &'a Self) -> Self {\n        self.div_assign_mod(other)\n    }\n}\n\nimpl CeilingDivNegMod<Self> for Natural {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value and returning the ceiling\n    /// of the quotient and the remainder of the negative of the first [`Natural`] divided by the\n    /// second.\n    ///\n    /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// y\\left \\lceil \\frac{x}{y} \\right \\rceil - x \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::CeilingDivNegMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .ceiling_div_neg_mod(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .ceiling_div_neg_mod(Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006724, 704498996588)\"\n    /// );\n    /// ```\n    #[inline]\n    fn ceiling_div_neg_mod(mut self, other: Self) -> (Self, Self) {\n        let r = self.ceiling_div_assign_neg_mod(other);\n        (self, r)\n    }\n}\n\nimpl<'a> CeilingDivNegMod<&'a Self> for Natural {\n    type DivOutput = Self;\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and returning the ceiling of the quotient and the remainder of the negative of the\n    /// first [`Natural`] divided by the second.\n    ///\n    /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// y\\left \\lceil \\frac{x}{y} \\right \\rceil - x \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::CeilingDivNegMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!(\n    ///     Natural::from(23u32)\n    ///         .ceiling_div_neg_mod(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .ceiling_div_neg_mod(&Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006724, 704498996588)\"\n    /// );\n    /// ```\n    #[inline]\n    fn ceiling_div_neg_mod(mut self, other: &'a Self) -> (Self, Self) {\n        let r = self.ceiling_div_assign_neg_mod(other);\n        (self, r)\n    }\n}\n\nimpl CeilingDivNegMod<Natural> for &Natural {\n    type DivOutput = Natural;\n    type ModOutput = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and returning the ceiling of the quotient and the remainder of the negative of the\n    /// first [`Natural`] divided by the second.\n    ///\n    /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// y\\left \\lceil \\frac{x}{y} \\right \\rceil - x \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::CeilingDivNegMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .ceiling_div_neg_mod(Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .ceiling_div_neg_mod(Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006724, 704498996588)\"\n    /// );\n    /// ```\n    fn ceiling_div_neg_mod(self, other: Natural) -> (Natural, Natural) {\n        let (q, r) = self.div_mod(&other);\n        if r == 0 {\n            (q, r)\n        } else {\n            (q.add_limb(1), other - r)\n        }\n    }\n}\n\nimpl CeilingDivNegMod<&Natural> for &Natural {\n    type DivOutput = Natural;\n    type ModOutput = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference and returning the\n    /// ceiling of the quotient and the remainder of the negative of the first [`Natural`] divided\n    /// by the second.\n    ///\n    /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\left \\lceil \\frac{x}{y} \\right \\rceil, \\space\n    /// y\\left \\lceil \\frac{x}{y} \\right \\rceil - x \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::CeilingDivNegMod;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!(\n    ///     (&Natural::from(23u32))\n    ///         .ceiling_div_neg_mod(&Natural::from(10u32))\n    ///         .to_debug_string(),\n    ///     \"(3, 7)\"\n    /// );\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .ceiling_div_neg_mod(&Natural::from_str(\"1234567890987\").unwrap())\n    ///         .to_debug_string(),\n    ///     \"(810000006724, 704498996588)\"\n    /// );\n    /// ```\n    fn ceiling_div_neg_mod(self, other: &Natural) -> (Natural, Natural) {\n        let (q, r) = self.div_mod(other);\n        if r == 0 {\n            (q, r)\n        } else {\n            (q.add_limb(1), other - r)\n        }\n    }\n}\n\nimpl CeilingDivAssignNegMod<Self> for Natural {\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value and returning the remainder of the negative of the first number\n    /// divided by the second.\n    ///\n    /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::CeilingDivAssignNegMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// let mut x = Natural::from(23u32);\n    /// assert_eq!(x.ceiling_div_assign_neg_mod(Natural::from(10u32)), 7);\n    /// assert_eq!(x, 3);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// assert_eq!(\n    ///     x.ceiling_div_assign_neg_mod(Natural::from_str(\"1234567890987\").unwrap()),\n    ///     704498996588u64,\n    /// );\n    /// assert_eq!(x, 810000006724u64);\n    /// ```\n    fn ceiling_div_assign_neg_mod(&mut self, other: Self) -> Self {\n        let r = self.div_assign_mod(&other);\n        if r == 0 {\n            Self::ZERO\n        } else {\n            *self += Self::ONE;\n            other - r\n        }\n    }\n}\n\nimpl<'a> CeilingDivAssignNegMod<&'a Self> for Natural {\n    type ModOutput = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference and returning the remainder of the negative of the first number\n    /// divided by the second.\n    ///\n    /// The quotient and remainder satisfy $x = qy - r$ and $0 \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x,\n    /// $$\n    /// $$\n    /// x \\gets \\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::CeilingDivAssignNegMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// let mut x = Natural::from(23u32);\n    /// assert_eq!(x.ceiling_div_assign_neg_mod(&Natural::from(10u32)), 7);\n    /// assert_eq!(x, 3);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// assert_eq!(\n    ///     x.ceiling_div_assign_neg_mod(&Natural::from_str(\"1234567890987\").unwrap()),\n    ///     704498996588u64,\n    /// );\n    /// assert_eq!(x, 810000006724u64);\n    /// ```\n    fn ceiling_div_assign_neg_mod(&mut self, other: &'a Self) -> Self {\n        let r = self.div_assign_mod(other);\n        if r == 0 {\n            Self::ZERO\n        } else {\n            *self += Self::ONE;\n            other - r\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    DivAssignMod, DivMod, DivRound, DivRoundAssign, Parity,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// quotient limbs of a `Limb` divided by the `Natural` and rounded according to a specified\n// `RoundingMode`. The limb slice must have at least two elements and cannot have any trailing\n// zeros. An `Ordering` is also returned, indicating whether the returned value is less than, equal\n// to, or greater than the exact value.\n//\n// This function returns a `None` iff the rounding mode is `Exact` but the remainder of the division\n// would be nonzero.\n//\n// Note that this function may only return `None`, `Some((0, Less))`, or `Some((1, Greater))`\n// because of the restrictions placed on the input slice.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {limbs_limb_div_round_limbs(n: Limb, ds: &[Limb], rm: RoundingMode)\n        -> Option<(Limb, Ordering)> {\n    if n == 0 {\n        Some((0, Equal))\n    } else {\n        match rm {\n            Down | Floor => Some((0, Less)),\n            Up | Ceiling => Some((1, Greater)),\n            Exact => None,\n            // 1 if 2 * n > Natural::from_limbs_asc(ds); otherwise, 0\n            Nearest => Some(\n                if ds.len() == 2 && ds[1] == 1 && n.get_highest_bit() && (n << 1) > ds[0] {\n                    (1, Greater)\n                } else {\n                    (0, Less)\n                },\n            ),\n        }\n    }\n}}\n\n// Compares 2x and y\npub(crate) fn double_cmp(x: &Natural, y: &Natural) -> Ordering {\n    (x.significant_bits() + 1)\n        .cmp(&y.significant_bits())\n        .then_with(|| x.cmp_normalized(y))\n}\n\n// assumes r != 0\nfn div_round_nearest(q: Natural, r: &Natural, d: &Natural) -> (Natural, Ordering) {\n    let compare = double_cmp(r, d);\n    if compare == Greater || compare == Equal && q.odd() {\n        (q.add_limb(1), Greater)\n    } else {\n        (q, Less)\n    }\n}\n\n// assumes r != 0\nfn div_round_assign_nearest(q: &mut Natural, r: &Natural, d: &Natural) -> Ordering {\n    let compare = double_cmp(r, d);\n    if compare == Greater || compare == Equal && q.odd() {\n        *q += Natural::ONE;\n        Greater\n    } else {\n        Less\n    }\n}\n\nimpl DivRound<Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value and rounding according to\n    /// a specified rounding mode. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & \\text{if} \\\\quad  q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad  q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(Natural::from(4u32), Down),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .div_round(Natural::from(3u32), Floor),\n    ///     (Natural::from(333333333333u64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(Natural::from(4u32), Up),\n    ///     (Natural::from(3u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .div_round(Natural::from(3u32), Ceiling),\n    ///     (Natural::from(333333333334u64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(Natural::from(5u32), Exact),\n    ///     (Natural::from(2u32), Equal)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(Natural::from(3u32), Nearest),\n    ///     (Natural::from(3u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(20u32).div_round(Natural::from(3u32), Nearest),\n    ///     (Natural::from(7u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(Natural::from(4u32), Nearest),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(14u32).div_round(Natural::from(4u32), Nearest),\n    ///     (Natural::from(4u32), Greater)\n    /// );\n    /// ```\n    #[inline]\n    fn div_round(mut self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.div_round_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl<'a> DivRound<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and rounding according to a specified rounding mode. An [`Ordering`] is also\n    /// returned, indicating whether the returned value is less than, equal to, or greater than the\n    /// exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & \\text{if} \\\\quad  q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad  q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(&Natural::from(4u32), Down),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .div_round(&Natural::from(3u32), Floor),\n    ///     (Natural::from(333333333333u64), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(&Natural::from(4u32), Up),\n    ///     (Natural::from(3u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .div_round(&Natural::from(3u32), Ceiling),\n    ///     (Natural::from(333333333334u64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(&Natural::from(5u32), Exact),\n    ///     (Natural::from(2u32), Equal)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(&Natural::from(3u32), Nearest),\n    ///     (Natural::from(3u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(20u32).div_round(&Natural::from(3u32), Nearest),\n    ///     (Natural::from(7u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).div_round(&Natural::from(4u32), Nearest),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(14u32).div_round(&Natural::from(4u32), Nearest),\n    ///     (Natural::from(4u32), Greater)\n    /// );\n    /// ```\n    #[inline]\n    fn div_round(mut self, other: &'a Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.div_round_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl DivRound<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and rounding according to a specified rounding mode. An [`Ordering`] is also\n    /// returned, indicating whether the returned value is less than, equal to, or greater than the\n    /// exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & \\text{if} \\\\quad  q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad  q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(Natural::from(4u32), Down),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12)).div_round(Natural::from(3u32), Floor),\n    ///     (Natural::from(333333333333u64), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(Natural::from(4u32), Up),\n    ///     (Natural::from(3u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12)).div_round(Natural::from(3u32), Ceiling),\n    ///     (Natural::from(333333333334u64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(Natural::from(5u32), Exact),\n    ///     (Natural::from(2u32), Equal)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(Natural::from(3u32), Nearest),\n    ///     (Natural::from(3u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(20u32)).div_round(Natural::from(3u32), Nearest),\n    ///     (Natural::from(7u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(Natural::from(4u32), Nearest),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(14u32)).div_round(Natural::from(4u32), Nearest),\n    ///     (Natural::from(4u32), Greater)\n    /// );\n    /// ```\n    fn div_round(self, other: Natural, rm: RoundingMode) -> (Natural, Ordering) {\n        let (q, r) = self.div_mod(&other);\n        if r == 0 {\n            (q, Equal)\n        } else {\n            match rm {\n                Floor | Down => (q, Less),\n                Ceiling | Up => (q.add_limb(1), Greater),\n                Exact => panic!(\"Division is not exact\"),\n                Nearest => div_round_nearest(q, &r, &other),\n            }\n        }\n    }\n}\n\nimpl DivRound<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference and rounding\n    /// according to a specified rounding mode. An [`Ordering`] is also returned, indicating whether\n    /// the returned value is less than, equal to, or greater than the exact value.\n    ///\n    /// Let $q = \\frac{x}{y}$, and let $g$ be the function that just returns the first element of\n    /// the pair, without the [`Ordering`]:\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.\n    /// $$\n    ///\n    /// $$\n    /// g(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n    ///     \\lceil q \\rceil & \\text{if} \\\\quad  q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n    ///     \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad  q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is even}, \\\\\\\\\n    ///     \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///     \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $g(x, y, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n    ///\n    /// Then $f(x, y, r) = (g(x, y, r), \\operatorname{cmp}(g(x, y, r), q))$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRound, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(&Natural::from(4u32), Down),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12)).div_round(&Natural::from(3u32), Floor),\n    ///     (Natural::from(333333333333u64), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(&Natural::from(4u32), Up),\n    ///     (Natural::from(3u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12)).div_round(&Natural::from(3u32), Ceiling),\n    ///     (Natural::from(333333333334u64), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(&Natural::from(5u32), Exact),\n    ///     (Natural::from(2u32), Equal)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(&Natural::from(3u32), Nearest),\n    ///     (Natural::from(3u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(20u32)).div_round(&Natural::from(3u32), Nearest),\n    ///     (Natural::from(7u32), Greater)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).div_round(&Natural::from(4u32), Nearest),\n    ///     (Natural::from(2u32), Less)\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(14u32)).div_round(&Natural::from(4u32), Nearest),\n    ///     (Natural::from(4u32), Greater)\n    /// );\n    /// ```\n    fn div_round(self, other: &Natural, rm: RoundingMode) -> (Natural, Ordering) {\n        let (q, r) = self.div_mod(other);\n        if r == 0 {\n            (q, Equal)\n        } else {\n            match rm {\n                Floor | Down => (q, Less),\n                Ceiling | Up => (q.add_limb(1), Greater),\n                Exact => panic!(\"Division is not exact: {self} / {other}\"),\n                Nearest => div_round_nearest(q, &r, other),\n            }\n        }\n    }\n}\n\nimpl DivRoundAssign<Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value and rounding according to a specified rounding mode. An\n    /// [`Ordering`] is returned, indicating whether the assigned value is less than, equal to, or\n    /// greater than the exact value.\n    ///\n    /// See the [`DivRound`] documentation for details.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRoundAssign, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(Natural::from(4u32), Down), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Natural::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(Natural::from(3u32), Floor), Less);\n    /// assert_eq!(n, 333333333333u64);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(Natural::from(4u32), Up), Greater);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Natural::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(&Natural::from(3u32), Ceiling), Greater);\n    /// assert_eq!(n, 333333333334u64);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(Natural::from(5u32), Exact), Equal);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(Natural::from(3u32), Nearest), Less);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Natural::from(20u32);\n    /// assert_eq!(n.div_round_assign(Natural::from(3u32), Nearest), Greater);\n    /// assert_eq!(n, 7);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(Natural::from(4u32), Nearest), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Natural::from(14u32);\n    /// assert_eq!(n.div_round_assign(Natural::from(4u32), Nearest), Greater);\n    /// assert_eq!(n, 4);\n    /// ```\n    fn div_round_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        let r = self.div_assign_mod(&other);\n        if r == 0 {\n            Equal\n        } else {\n            match rm {\n                Floor | Down => Less,\n                Ceiling | Up => {\n                    *self += Self::ONE;\n                    Greater\n                }\n                Exact => panic!(\"Division is not exact\"),\n                Nearest => div_round_assign_nearest(self, &r, &other),\n            }\n        }\n    }\n}\n\nimpl<'a> DivRoundAssign<&'a Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference and rounding according to a specified rounding mode. An\n    /// [`Ordering`] is returned, indicating whether the assigned value is less than, equal to, or\n    /// greater than the exact value.\n    ///\n    /// See the [`DivRound`] documentation for details.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero, or if `rm` is `Exact` but `self` is not divisible by `other`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::{DivRoundAssign, Pow};\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(&Natural::from(4u32), Down), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Natural::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(&Natural::from(3u32), Floor), Less);\n    /// assert_eq!(n, 333333333333u64);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(&Natural::from(4u32), Up), Greater);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Natural::from(10u32).pow(12);\n    /// assert_eq!(n.div_round_assign(&Natural::from(3u32), Ceiling), Greater);\n    /// assert_eq!(n, 333333333334u64);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(&Natural::from(5u32), Exact), Equal);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(&Natural::from(3u32), Nearest), Less);\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Natural::from(20u32);\n    /// assert_eq!(n.div_round_assign(&Natural::from(3u32), Nearest), Greater);\n    /// assert_eq!(n, 7);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.div_round_assign(&Natural::from(4u32), Nearest), Less);\n    /// assert_eq!(n, 2);\n    ///\n    /// let mut n = Natural::from(14u32);\n    /// assert_eq!(n.div_round_assign(&Natural::from(4u32), Nearest), Greater);\n    /// assert_eq!(n, 4);\n    /// ```\n    fn div_round_assign(&mut self, other: &'a Self, rm: RoundingMode) -> Ordering {\n        let r = self.div_assign_mod(other);\n        if r == 0 {\n            Equal\n        } else {\n            match rm {\n                Floor | Down => Less,\n                Ceiling | Up => {\n                    *self += Self::ONE;\n                    Greater\n                }\n                Exact => panic!(\"Division is not exact\"),\n                Nearest => div_round_assign_nearest(self, &r, other),\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2000–2002, 2005, 2009, 2014, 2017, 2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::div_exact::{\n    limbs_modular_div_mod_barrett, limbs_modular_div_mod_barrett_scratch_len,\n    limbs_modular_div_mod_divide_and_conquer, limbs_modular_div_mod_schoolbook,\n    limbs_modular_invert_limb,\n};\nuse crate::natural::arithmetic::eq_mod::limbs_mod_exact_odd_limb;\nuse crate::natural::arithmetic::mod_op::limbs_mod_limb;\nuse crate::natural::arithmetic::shr::{limbs_shr_to_out, limbs_slice_shr_in_place};\nuse crate::platform::{\n    BMOD_1_TO_MOD_1_THRESHOLD, DC_BDIV_QR_THRESHOLD, DoubleLimb, Limb, MU_BDIV_QR_THRESHOLD,\n};\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{DivisibleBy, DivisibleByPowerOf2, Parity};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::slices::{slice_leading_zeros, slice_test_zero};\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, determines\n// whether that `Natural` is divisible by a given limb.\n//\n// This function assumes that `ns` has at least two elements and that `d` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpz_divisible_ui_p` from `mpz/divis_ui.c`, GMP 6.2.1, where `a` is\n// non-negative and the `ABOVE_THRESHOLD` branch is excluded.\npub_crate_test! {limbs_divisible_by_limb(ns: &[Limb], d: Limb) -> bool {\n    assert!(ns.len() > 1);\n    if d.even() {\n        let twos = TrailingZeros::trailing_zeros(d);\n        ns[0].divisible_by_power_of_2(twos) && limbs_mod_exact_odd_limb(ns, d >> twos, 0) == 0\n    } else {\n        limbs_mod_exact_odd_limb(ns, d, 0) == 0\n    }\n}}\n\nfn limbs_mod_limb_helper(ns: &[Limb], d_low: Limb) -> Limb {\n    if ns.len() < BMOD_1_TO_MOD_1_THRESHOLD {\n        limbs_mod_exact_odd_limb(ns, d_low, 0)\n    } else {\n        limbs_mod_limb::<DoubleLimb, Limb>(ns, d_low)\n    }\n}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, determines whether the first `Natural` is divisible by the second. Both `Natural`s\n// are taken by value.\n//\n// `ns` must be at least as long as `ds`, both slices must be nonempty, and the last limb of both\n// must be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` is empty, or the last limbs of either slice are zero.\n//\n// This is equivalent to `mpn_divisible_p` from `mpn/generic/divis.c`, GMP 6.2.1, where `an >= dn`\n// and neither are zero.\npub_crate_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_divisible_by(ns: &mut [Limb], ds: &mut [Limb]) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(*ns.last().unwrap(), 0);\n    assert_ne!(*ds.last().unwrap(), 0);\n    // Strip low zero limbs from ds, requiring n == 0 on those.\n    let offset = slice_leading_zeros(ds);\n    let (ns_lo, ns) = ns.split_at_mut(offset);\n    if !slice_test_zero(ns_lo) {\n        // n has fewer low zero limbs than d, so not divisible\n        return false;\n    }\n    let n_len = ns.len();\n    let ds = &mut ds[offset..];\n    let d_len = ds.len();\n    let n_0 = ns[0];\n    let d_0 = ds[0];\n    // n must have at least as many low zero bits as d\n    let d_mask = (d_0 & d_0.wrapping_neg()).wrapping_sub(1);\n    if n_0 & d_mask != 0 {\n        return false;\n    }\n    if d_len == 1 {\n        return if n_len >= BMOD_1_TO_MOD_1_THRESHOLD {\n            limbs_mod_limb::<DoubleLimb, Limb>(ns, d_0) == 0\n        } else {\n            limbs_mod_exact_odd_limb(ns, d_0 >> d_0.trailing_zeros(), 0) == 0\n        };\n    }\n    let trailing_zeros = TrailingZeros::trailing_zeros(d_0);\n    if d_len == 2 {\n        let d_1 = ds[1];\n        if d_1 <= d_mask {\n            let d_low = (d_0 >> trailing_zeros) | (d_1 << (Limb::WIDTH - trailing_zeros));\n            return limbs_mod_limb_helper(ns, d_low) == 0;\n        }\n    }\n    let n_len_plus_1 = n_len + 1;\n    let mut qs = vec![0; n_len_plus_1 - d_len];\n    if trailing_zeros != 0 {\n        assert_eq!(limbs_slice_shr_in_place(ds, trailing_zeros), 0);\n        assert_eq!(limbs_slice_shr_in_place(ns, trailing_zeros), 0);\n    }\n    let mut rs_vec;\n    let rs = if ns[n_len - 1] >= ds[d_len - 1] {\n        rs_vec = Vec::with_capacity(n_len_plus_1);\n        rs_vec.extend_from_slice(ns);\n        rs_vec.push(0);\n        &mut rs_vec\n    } else if n_len == d_len {\n        return false;\n    } else {\n        ns\n    };\n    let r_len = rs.len();\n    let q_len = r_len - d_len;\n    let rs = if d_len < DC_BDIV_QR_THRESHOLD || q_len < DC_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_schoolbook(&mut qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else if d_len < MU_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_divide_and_conquer(&mut qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else {\n        let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(r_len, d_len)];\n        let ns = rs.to_vec();\n        limbs_modular_div_mod_barrett(&mut qs, rs, &ns, ds, &mut scratch);\n        &mut rs[..d_len]\n    };\n    slice_test_zero(rs)\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, determines whether the first `Natural` is divisible by the second. The first\n// `Natural` is taken by value, and the second by reference.\n//\n// `ns` must be at least as long as `ds`, both slices must be nonempty, and the last limb of both\n// must be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` is empty, or the last limbs of either slice are zero.\n//\n// This is equivalent to `mpn_divisible_p` from `mpn/generic/divis.c`, GMP 6.2.1, where `an >= dn`\n// and neither are zero.\npub_crate_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_divisible_by_val_ref(ns: &mut [Limb], ds: &[Limb]) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(*ns.last().unwrap(), 0);\n    assert_ne!(*ds.last().unwrap(), 0);\n    // Strip low zero limbs from ds, requiring n == 0 on those.\n    let offset = slice_leading_zeros(ds);\n    let (ns_lo, ns) = ns.split_at_mut(offset);\n    if !slice_test_zero(ns_lo) {\n        // n has fewer low zero limbs than d, so not divisible\n        return false;\n    }\n    let n_len = ns.len();\n    let mut scratch;\n    let mut ds = &ds[offset..];\n    let d_len = ds.len();\n    let n_0 = ns[0];\n    let d_0 = ds[0];\n    // n must have at least as many low zero bits as d\n    let d_mask = (d_0 & d_0.wrapping_neg()).wrapping_sub(1);\n    if n_0 & d_mask != 0 {\n        return false;\n    }\n    if d_len == 1 {\n        return if n_len >= BMOD_1_TO_MOD_1_THRESHOLD {\n            limbs_mod_limb::<DoubleLimb, Limb>(ns, d_0) == 0\n        } else {\n            limbs_mod_exact_odd_limb(ns, d_0 >> d_0.trailing_zeros(), 0) == 0\n        };\n    }\n    let trailing_zeros = TrailingZeros::trailing_zeros(d_0);\n    if d_len == 2 {\n        let d_1 = ds[1];\n        if d_1 <= d_mask {\n            let d_low = (d_0 >> trailing_zeros) | (d_1 << (Limb::WIDTH - trailing_zeros));\n            return limbs_mod_limb_helper(ns, d_low) == 0;\n        }\n    }\n    let n_len_plus_1 = n_len + 1;\n    let mut qs = vec![0; n_len_plus_1 - d_len];\n    if trailing_zeros != 0 {\n        scratch = vec![0; d_len];\n        assert_eq!(limbs_shr_to_out(&mut scratch, ds, trailing_zeros), 0);\n        ds = &scratch;\n        assert_eq!(limbs_slice_shr_in_place(ns, trailing_zeros), 0);\n    }\n    let mut rs_vec;\n    let rs = if ns[n_len - 1] >= ds[d_len - 1] {\n        rs_vec = Vec::with_capacity(n_len_plus_1);\n        rs_vec.extend_from_slice(ns);\n        rs_vec.push(0);\n        &mut rs_vec\n    } else if n_len == d_len {\n        return false;\n    } else {\n        ns\n    };\n    let r_len = rs.len();\n    let q_len = r_len - d_len;\n    let rs = if d_len < DC_BDIV_QR_THRESHOLD || q_len < DC_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_schoolbook(&mut qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else if d_len < MU_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_divide_and_conquer(&mut qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else {\n        let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(r_len, d_len)];\n        let ns = rs.to_vec();\n        limbs_modular_div_mod_barrett(&mut qs, rs, &ns, ds, &mut scratch);\n        &mut rs[..d_len]\n    };\n    slice_test_zero(rs)\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, determines whether the first `Natural` is divisible by the second. The first\n// `Natural` is taken by reference, and the second by value.\n//\n// `ns` must be at least as long as `ds`, both slices must be nonempty, and the last limb of both\n// must be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` is empty, or the last limbs of either slice are zero.\n//\n// This is equivalent to `mpn_divisible_p` from `mpn/generic/divis.c`, GMP 6.2.1, where `an >= dn`\n// and neither are zero.\npub_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_divisible_by_ref_val(ns: &[Limb], ds: &mut [Limb]) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(*ns.last().unwrap(), 0);\n    assert_ne!(*ds.last().unwrap(), 0);\n    // Strip low zero limbs from ds, requiring n == 0 on those.\n    let offset = slice_leading_zeros(ds);\n    let (ns_lo, ns) = ns.split_at(offset);\n    if !slice_test_zero(ns_lo) {\n        // n has fewer low zero limbs than d, so not divisible\n        return false;\n    }\n    let n_len = ns.len();\n    let ds = &mut ds[offset..];\n    let d_len = ds.len();\n    let n_0 = ns[0];\n    let d_0 = ds[0];\n    // n must have at least as many low zero bits as d\n    let d_mask = (d_0 & d_0.wrapping_neg()).wrapping_sub(1);\n    if n_0 & d_mask != 0 {\n        return false;\n    }\n    if d_len == 1 {\n        return if n_len >= BMOD_1_TO_MOD_1_THRESHOLD {\n            limbs_mod_limb::<DoubleLimb, Limb>(ns, d_0) == 0\n        } else {\n            limbs_mod_exact_odd_limb(ns, d_0 >> d_0.trailing_zeros(), 0) == 0\n        };\n    }\n    let trailing_zeros = TrailingZeros::trailing_zeros(d_0);\n    if d_len == 2 {\n        let d_1 = ds[1];\n        if d_1 <= d_mask {\n            let d_low = (d_0 >> trailing_zeros) | (d_1 << (Limb::WIDTH - trailing_zeros));\n            return limbs_mod_limb_helper(ns, d_low) == 0;\n        }\n    }\n    let n_len_plus_1 = n_len + 1;\n    let mut rs_qs = vec![0; (n_len_plus_1 << 1) - d_len];\n    let (rs, qs) = rs_qs.split_at_mut(n_len_plus_1);\n    if trailing_zeros != 0 {\n        assert_eq!(limbs_slice_shr_in_place(ds, trailing_zeros), 0);\n        assert_eq!(limbs_shr_to_out(rs, ns, trailing_zeros), 0);\n    } else {\n        rs[..n_len].copy_from_slice(ns);\n    }\n    let r_len = if rs[n_len - 1] >= ds[d_len - 1] {\n        n_len_plus_1\n    } else if n_len == d_len {\n        return false;\n    } else {\n        n_len\n    };\n    let rs = &mut rs[..r_len];\n    let q_len = r_len - d_len;\n    let rs = if d_len < DC_BDIV_QR_THRESHOLD || q_len < DC_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_schoolbook(qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else if d_len < MU_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_divide_and_conquer(qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else {\n        let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(r_len, d_len)];\n        let ns = rs.to_vec();\n        limbs_modular_div_mod_barrett(qs, rs, &ns, ds, &mut scratch);\n        &mut rs[..d_len]\n    };\n    slice_test_zero(rs)\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, determines whether the first `Natural` is divisible by the second. Both `Natural`s\n// are taken by reference.\n//\n// `ns` must be at least as long as `ds`, both slices must be nonempty, and the last limb of both\n// must be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` is empty, or the last limbs of either slice are zero.\n//\n// This is equivalent to `mpn_divisible_p` from `mpn/generic/divis.c`, GMP 6.2.1, where `an >= dn`\n// and neither are zero.\npub_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_divisible_by_ref_ref(ns: &[Limb], ds: &[Limb]) -> bool {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_ne!(d_len, 0);\n    assert!(n_len >= d_len);\n    assert_ne!(*ns.last().unwrap(), 0);\n    assert_ne!(*ds.last().unwrap(), 0);\n    // Strip low zero limbs from ds, requiring n == 0 on those.\n    let offset = slice_leading_zeros(ds);\n    let (ns_lo, ns) = ns.split_at(offset);\n    if !slice_test_zero(ns_lo) {\n        // n has fewer low zero limbs than d, so not divisible\n        return false;\n    }\n    let n_len = ns.len();\n    let mut scratch;\n    let mut ds = &ds[offset..];\n    let d_len = ds.len();\n    let d_0 = ds[0];\n    // n must have at least as many low zero bits as d\n    let d_mask = (d_0 & d_0.wrapping_neg()).wrapping_sub(1);\n    if ns[0] & d_mask != 0 {\n        return false;\n    }\n    if d_len == 1 {\n        return if n_len >= BMOD_1_TO_MOD_1_THRESHOLD {\n            limbs_mod_limb::<DoubleLimb, Limb>(ns, d_0) == 0\n        } else {\n            limbs_mod_exact_odd_limb(ns, d_0 >> d_0.trailing_zeros(), 0) == 0\n        };\n    }\n    let trailing_zeros = TrailingZeros::trailing_zeros(d_0);\n    if d_len == 2 {\n        let d_1 = ds[1];\n        if d_1 <= d_mask {\n            let d_low = (d_0 >> trailing_zeros) | (d_1 << (Limb::WIDTH - trailing_zeros));\n            return limbs_mod_limb_helper(ns, d_low) == 0;\n        }\n    }\n    let n_len_plus_1 = n_len + 1;\n    let mut rs_qs = vec![0; (n_len_plus_1 << 1) - d_len];\n    let (rs, qs) = rs_qs.split_at_mut(n_len_plus_1);\n    if trailing_zeros != 0 {\n        scratch = vec![0; d_len];\n        assert_eq!(limbs_shr_to_out(&mut scratch, ds, trailing_zeros), 0);\n        ds = &scratch;\n        assert_eq!(limbs_shr_to_out(rs, ns, trailing_zeros), 0);\n    } else {\n        rs[..n_len].copy_from_slice(ns);\n    }\n    let r_len = if rs[n_len - 1] >= ds[d_len - 1] {\n        n_len_plus_1\n    } else if n_len == d_len {\n        return false;\n    } else {\n        n_len\n    };\n    let rs = &mut rs[..r_len];\n    let q_len = r_len - d_len;\n    let rs = if d_len < DC_BDIV_QR_THRESHOLD || q_len < DC_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_schoolbook(qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else if d_len < MU_BDIV_QR_THRESHOLD {\n        let d_inv = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_mod_divide_and_conquer(qs, rs, ds, d_inv);\n        &mut rs[q_len..]\n    } else {\n        let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(r_len, d_len)];\n        let ns = rs.to_vec();\n        limbs_modular_div_mod_barrett(qs, rs, &ns, ds, &mut scratch);\n        &mut rs[..d_len]\n    };\n    slice_test_zero(rs)\n}}\n\nimpl Natural {\n    fn divisible_by_limb(&self, other: Limb) -> bool {\n        match (self, other) {\n            (&Self::ZERO, _) => true,\n            (_, 0) => false,\n            (&Self(Small(small)), y) => small.divisible_by(y),\n            (Self(Large(limbs)), y) => limbs_divisible_by_limb(limbs, y),\n        }\n    }\n\n    // Tests whether other is divisible by self\n    fn limb_divisible_by_natural(&self, other: Limb) -> bool {\n        match (other, self) {\n            (0, _) => true,\n            (_, &Self::ZERO | &Self(Large(_))) => false,\n            (x, &Self(Small(small))) => x.divisible_by(small),\n        }\n    }\n}\n\nimpl DivisibleBy<Self> for Natural {\n    /// Returns whether a [`Natural`] is divisible by another [`Natural`]; in other words, whether\n    /// the first is a multiple of the second. Both [`Natural`]s are taken by value.\n    ///\n    /// This means that zero is divisible by any [`Natural`], including zero; but a nonzero\n    /// [`Natural`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.divisible_by(Natural::ZERO), true);\n    /// assert_eq!(\n    ///     Natural::from(100u32).divisible_by(Natural::from(3u32)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(102u32).divisible_by(Natural::from(3u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .divisible_by(Natural::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(mut self, mut other: Self) -> bool {\n        match (&mut self, &mut other) {\n            (x, &mut Self(Small(y))) => x.divisible_by_limb(y),\n            (&mut Self(Small(x)), y) => y.limb_divisible_by_natural(x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                xs.len() >= ys.len() && limbs_divisible_by(xs, ys)\n            }\n        }\n    }\n}\n\nimpl<'a> DivisibleBy<&'a Self> for Natural {\n    /// Returns whether a [`Natural`] is divisible by another [`Natural`]; in other words, whether\n    /// the first is a multiple of the second. The first [`Natural`]s is taken by reference and the\n    /// second by value.\n    ///\n    /// This means that zero is divisible by any [`Natural`], including zero; but a nonzero\n    /// [`Natural`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.divisible_by(&Natural::ZERO), true);\n    /// assert_eq!(\n    ///     Natural::from(100u32).divisible_by(&Natural::from(3u32)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(102u32).divisible_by(&Natural::from(3u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .divisible_by(&Natural::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(mut self, other: &'a Self) -> bool {\n        match (&mut self, other) {\n            (x, &Self(Small(y))) => x.divisible_by_limb(y),\n            (&mut Self(Small(x)), y) => y.limb_divisible_by_natural(x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                xs.len() >= ys.len() && limbs_divisible_by_val_ref(xs, ys)\n            }\n        }\n    }\n}\n\nimpl DivisibleBy<Natural> for &Natural {\n    /// Returns whether a [`Natural`] is divisible by another [`Natural`]; in other words, whether\n    /// the first is a multiple of the second. The first [`Natural`]s are taken by reference and the\n    /// second by value.\n    ///\n    /// This means that zero is divisible by any [`Natural`], including zero; but a nonzero\n    /// [`Natural`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).divisible_by(Natural::ZERO), true);\n    /// assert_eq!(\n    ///     (&Natural::from(100u32)).divisible_by(Natural::from(3u32)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(102u32)).divisible_by(Natural::from(3u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .divisible_by(Natural::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(self, mut other: Natural) -> bool {\n        match (self, &mut other) {\n            (x, &mut Natural(Small(y))) => x.divisible_by_limb(y),\n            (&Natural(Small(x)), y) => y.limb_divisible_by_natural(x),\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                xs.len() >= ys.len() && limbs_divisible_by_ref_val(xs, ys)\n            }\n        }\n    }\n}\n\nimpl DivisibleBy<&Natural> for &Natural {\n    /// Returns whether a [`Natural`] is divisible by another [`Natural`]; in other words, whether\n    /// the first is a multiple of the second. Both [`Natural`]s are taken by reference.\n    ///\n    /// This means that zero is divisible by any [`Natural`], including zero; but a nonzero\n    /// [`Natural`] is never divisible by zero.\n    ///\n    /// It's more efficient to use this function than to compute the remainder and check whether\n    /// it's zero.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::DivisibleBy;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).divisible_by(&Natural::ZERO), true);\n    /// assert_eq!(\n    ///     (&Natural::from(100u32)).divisible_by(&Natural::from(3u32)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(102u32)).divisible_by(&Natural::from(3u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .divisible_by(&Natural::from_str(\"1000000000000\").unwrap()),\n    ///     true\n    /// );\n    /// ```\n    fn divisible_by(self, other: &Natural) -> bool {\n        match (self, other) {\n            (x, &Natural(Small(y))) => x.divisible_by_limb(y),\n            (&Natural(Small(x)), y) => y.limb_divisible_by_natural(x),\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                xs.len() >= ys.len() && limbs_divisible_by_ref_ref(xs, ys)\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2001, 2002 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::slice_test_zero;\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, determines\n// whether that `Natural` is divisible by 2 raised to a given power.\n//\n// This function assumes that `xs` is nonempty and does not only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(pow, xs.len())`.\n//\n// This is equivalent to `mpz_divisible_2exp_p` from `mpz/divis_2exp.c`, GMP 6.2.1, where `a` is\n// non-negative.\npub_crate_test! {limbs_divisible_by_power_of_2(xs: &[Limb], pow: u64) -> bool {\n    assert!(!xs.is_empty());\n    let zeros = bit_to_limb_count_floor(pow);\n    zeros < xs.len()\n        && slice_test_zero(&xs[..zeros])\n        && xs[zeros].divisible_by_power_of_2(pow & Limb::WIDTH_MASK)\n}}\n\nimpl DivisibleByPowerOf2 for &Natural {\n    /// Returns whether a [`Natural`] is divisible by $2^k$.\n    ///\n    /// $f(x, k) = (2^k|x)$.\n    ///\n    /// $f(x, k) = (\\exists n \\in \\N : \\ x = n2^k)$.\n    ///\n    /// If `self` is 0, the result is always true; otherwise, it is equivalent to\n    /// `self.trailing_zeros().unwrap() <= pow`, but more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(pow, self.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.divisible_by_power_of_2(100), true);\n    /// assert_eq!(Natural::from(100u32).divisible_by_power_of_2(2), true);\n    /// assert_eq!(Natural::from(100u32).divisible_by_power_of_2(3), false);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12).divisible_by_power_of_2(12),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12).divisible_by_power_of_2(13),\n    ///     false\n    /// );\n    /// ```\n    fn divisible_by_power_of_2(self, pow: u64) -> bool {\n        match (self, pow) {\n            (_, 0) => true,\n            (&Natural(Small(small)), pow) => small.divisible_by_power_of_2(pow),\n            (&Natural(Large(ref limbs)), pow) => limbs_divisible_by_power_of_2(limbs, pow),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::div_exact::limbs_modular_invert_limb;\nuse crate::natural::arithmetic::divisible_by::{\n    limbs_divisible_by, limbs_divisible_by_limb, limbs_divisible_by_val_ref,\n};\nuse crate::natural::arithmetic::mod_op::limbs_mod_limb;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_greater_to_out, limbs_sub_limb_in_place,\n    limbs_sub_limb_to_out, limbs_sub_same_length_in_place_left,\n    limbs_sub_same_length_in_place_right, limbs_sub_same_length_to_out,\n};\nuse crate::natural::comparison::cmp::limbs_cmp;\nuse crate::platform::{BMOD_1_TO_MOD_1_THRESHOLD, DoubleLimb, Limb};\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{\n    DivisibleBy, DivisibleByPowerOf2, EqMod, EqModPowerOf2, Parity, PowerOf2, WrappingAddAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::SplitInHalf;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::slices::slice_trailing_zeros;\n\n// See the description for `limbs_mod_exact_odd_limb`. divisor must be odd.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_modexact_1c_odd`, from `mpn/generic/mode1o.c`, GMP 6.2.1, where `size\n// == 1`. Pass `carry = 0` to get `mpn_modexact_1_odd` from `gmp-impl.c`, GMP 6.2.1, where `size ==\n// 1`.\npub_const_test! {limbs_limb_mod_exact_odd_limb(n: Limb, d: Limb, carry: Limb) -> Limb {\n    if n > carry {\n        let result = (n - carry) % d;\n        if result == 0 {\n            0\n        } else {\n            d - result\n        }\n    } else {\n        (carry - n) % d\n    }\n}}\n\n// Calculates an r satisfying\n//\n// r * B ^ k + n - c == q * d\n//\n// where B = `2 ^ Limb::WIDTH`, k is either `ns.len()` or `ns.len()` - 1 (the caller won't know\n// which), c is `carry`, and q is the quotient (discarded). `d` must be odd and `carry` can be any\n// limb value.\n//\n// If c < d then r will be in the range 0 <= r < d, or if c >= d then 0 <= r <= d.\n//\n// This slightly strange function suits the initial N x 1 reduction for GCDs or Jacobi symbols since\n// the factors of 2 in B ^ k can be ignored, leaving -r == a mod d (by passing c = 0). For a GCD the\n// factor of -1 on r can be ignored, or for the Jacobi symbol it can be accounted for. The function\n// also suits divisibility and congruence testing, since if r = 0 (or r = d) is obtained, then a ≡\n// c mod d.\n//\n// ns must be nonempty and divisor must be odd.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_modexact_1c_odd` from mpn/generic/mode1o.c, GMP 6.2.1. Pass `carry =\n// 0` to get `mpn_modexact_1_odd` from `gmp-impl.c`, GMP 6.2.1.\npub_crate_test! {limbs_mod_exact_odd_limb(ns: &[Limb], d: Limb, mut carry: Limb) -> Limb {\n    let len = ns.len();\n    if len == 1 {\n        return limbs_limb_mod_exact_odd_limb(ns[0], d, carry);\n    }\n    let d_inv = limbs_modular_invert_limb(d);\n    let d_double = DoubleLimb::from(d);\n    let (xs_last, xs_init) = ns.split_last().unwrap();\n    let xs_last = *xs_last;\n    for x in xs_init {\n        let (diff, small_carry) = x.overflowing_sub(carry);\n        carry = (DoubleLimb::from(diff.wrapping_mul(d_inv)) * d_double).upper_half();\n        if small_carry {\n            carry.wrapping_add_assign(1);\n        }\n    }\n    if xs_last <= d {\n        if carry >= xs_last {\n            carry - xs_last\n        } else {\n            carry.wrapping_add(d - xs_last)\n        }\n    } else {\n        let (diff, small_carry) = xs_last.overflowing_sub(carry);\n        carry = (DoubleLimb::from(diff.wrapping_mul(d_inv)) * d_double).upper_half();\n        if small_carry {\n            carry.wrapping_add_assign(1);\n        }\n        carry\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, determines\n// whether that `Natural` is equal to a limb mod a given `Limb` `m`.\n//\n// This function assumes that `m` is nonzero, `xs` has at least two elements, and the last element\n// of `xs` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `xs` is less than 2 or `m` is zero.\n//\n// This is equivalent to `mpz_congruent_ui_p` from `mpz/cong_ui.c`, GMP 6.2.1, where `a` is positive\n// and the `ABOVE_THRESHOLD` branch is excluded.\npub_crate_test! {limbs_eq_limb_mod_limb(xs: &[Limb], y: Limb, m: Limb) -> bool {\n    assert_ne!(m, 0);\n    assert!(xs.len() > 1);\n    let r = if m.even() {\n        let twos = TrailingZeros::trailing_zeros(m);\n        if !xs[0].wrapping_sub(y).divisible_by_power_of_2(twos) {\n            return false;\n        }\n        limbs_mod_exact_odd_limb(xs, m >> twos, y)\n    } else {\n        limbs_mod_exact_odd_limb(xs, m, y)\n    };\n    r == 0 || r == m\n}}\n\n#[allow(clippy::absurd_extreme_comparisons)]\nfn limbs_eq_limb_mod_helper(xs: &[Limb], y: Limb, ms: &[Limb]) -> Option<bool> {\n    let m_len = ms.len();\n    assert!(m_len > 1);\n    let x_len = xs.len();\n    assert!(x_len > 1);\n    assert_ne!(*xs.last().unwrap(), 0);\n    assert_ne!(y, 0);\n    assert_ne!(*ms.last().unwrap(), 0);\n    if m_len > x_len {\n        // x < m, y < m, and x != y, so x != y mod m\n        return Some(false);\n    }\n    let m_0 = ms[0];\n    // Check xs == ys mod low zero bits of m_0.\n    let m_0_trailing_zeros = TrailingZeros::trailing_zeros(m_0);\n    if !xs[0].eq_mod_power_of_2(y, m_0_trailing_zeros) {\n        return Some(false);\n    }\n    if m_len == 2 && m_0 != 0 {\n        let m_1 = ms[1];\n        if m_1 < Limb::power_of_2(m_0_trailing_zeros) {\n            let m_0 = (m_0 >> m_0_trailing_zeros) | (m_1 << (Limb::WIDTH - m_0_trailing_zeros));\n            return Some(if x_len >= BMOD_1_TO_MOD_1_THRESHOLD {\n                let r = limbs_mod_limb::<DoubleLimb, Limb>(xs, m_0);\n                if y < m_0 { r == y } else { r == y % m_0 }\n            } else {\n                let r = limbs_mod_exact_odd_limb(xs, m_0, y);\n                r == 0 || r == m_0\n            });\n        }\n    }\n    None\n}\n\n// Interpreting a slice of `Limb`s `xs`, a Limb `y`, and another slice of `Limb`s `ms` as three\n// numbers x, y, and m, determines whether x ≡ y mod m. Both input slices are immutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `y` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `xs` or `ms` is less than 2, if the last element of either of the slices\n// is zero, or if `y` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive, `a` and `d` are longer than one limb, and `c` is one limb long.\npub_test! {limbs_eq_limb_mod_ref_ref(xs: &[Limb], y: Limb, ms: &[Limb]) -> bool {\n    if let Some(equal) = limbs_eq_limb_mod_helper(xs, y, ms) {\n        return equal;\n    }\n    let mut scratch = vec![0; xs.len()];\n    // calculate |xs - y|\n    assert!(!limbs_sub_limb_to_out(&mut scratch, xs, y));\n    scratch.truncate(scratch.len() - slice_trailing_zeros(&scratch));\n    scratch.len() >= ms.len() && limbs_divisible_by_val_ref(&mut scratch, ms)\n}}\n\n// Interpreting a slice of `Limb`s `xs`, a Limb `y`, and another slice of `Limb`s `ms` as three\n// numbers x, y, and m, determines whether x ≡ y mod m. The first input slice is immutable and the\n// second is mutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `y` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `xs` or `ms` is less than 2, if the last element of either of the slices\n// is zero, or if `y` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive, `a` and `d` are longer than one limb, and `c` is one limb long.\npub_test! {limbs_eq_limb_mod_ref_val(xs: &[Limb], y: Limb, ms: &mut [Limb]) -> bool {\n    if let Some(equal) = limbs_eq_limb_mod_helper(xs, y, ms) {\n        return equal;\n    }\n    let mut scratch = vec![0; xs.len()];\n    // calculate |xs - y|\n    assert!(!limbs_sub_limb_to_out(&mut scratch, xs, y));\n    scratch.truncate(scratch.len() - slice_trailing_zeros(&scratch));\n    scratch.len() >= ms.len() && limbs_divisible_by(&mut scratch, ms)\n}}\n\n// Interpreting a slice of `Limb`s `xs`, a Limb `y`, and another slice of `Limb`s `ms` as three\n// numbers x, y, and m, determines whether x ≡ y mod m. The first input slice is mutable and the\n// second is immutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `y` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `xs` or `m` is less than 2, if the last element of either of the slices\n// is zero, or if `y` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive, `a` and `d` are longer than one limb, and `c` is one limb long.\npub_test! {limbs_eq_limb_mod_val_ref(xs: &mut [Limb], y: Limb, ms: &[Limb]) -> bool {\n    if let Some(equal) = limbs_eq_limb_mod_helper(xs, y, ms) {\n        return equal;\n    }\n    // calculate |xs - y|\n    assert!(!limbs_sub_limb_in_place(xs, y));\n    let new_len = xs.len() - slice_trailing_zeros(xs);\n    new_len >= ms.len() && limbs_divisible_by_val_ref(&mut xs[..new_len], ms)\n}}\n\n// Interpreting a slice of `Limb`s `xs`, a Limb `y`, and another slice of `Limb`s `ms` as three\n// numbers x, y, and m, determines whether x ≡ y mod m. Both input slices are mutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `y` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if the length of `xs` or `ms` is less than 2, if the last element of either of the slices\n// is zero, or if `y` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive, `a` and `d` are longer than one limb, and `c` is one limb long.\npub_test! {limbs_eq_limb_mod(xs: &mut [Limb], y: Limb, ms: &mut [Limb]) -> bool {\n    if let Some(equal) = limbs_eq_limb_mod_helper(xs, y, ms) {\n        return equal;\n    }\n    // calculate |xs - y|\n    assert!(!limbs_sub_limb_in_place(xs, y));\n    let new_len = xs.len() - slice_trailing_zeros(xs);\n    new_len >= ms.len() && limbs_divisible_by(&mut xs[..new_len], ms)\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_limb_helper(xs: &[Limb], ys: &[Limb], m: Limb) -> Option<bool> {\n    let x_len = xs.len();\n    let y_len = ys.len();\n    assert!(y_len > 1);\n    assert!(x_len >= y_len);\n    assert_ne!(*xs.last().unwrap(), 0);\n    assert_ne!(*ys.last().unwrap(), 0);\n    assert_ne!(m, 0);\n    if xs == ys {\n        Some(true)\n    } else if !xs[0].eq_mod_power_of_2(ys[0], u64::from(m.trailing_zeros())) {\n        // Check xs == ys mod low zero bits of m.\n        Some(false)\n    } else {\n        None\n    }\n}\n\n// Interpreting two slices of `Limb`s `xs` and `ys` and a Limb `m` as three numbers x, y, and m,\n// determines whether x ≡ y mod m. Both input slices are immutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `m` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs` or `ys` is less than 2, if the last element of either of the slices\n// is zero, or if `m` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive, `a` and `c` are longer than one limb, and `m` is one limb long.\npub_test! {limbs_eq_mod_limb_ref_ref(xs: &[Limb], ys: &[Limb], m: Limb) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_limb_ref_ref_greater(xs, ys, m)\n    } else {\n        limbs_eq_mod_limb_ref_ref_greater(ys, xs, m)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_limb_ref_ref_greater(xs: &[Limb], ys: &[Limb], m: Limb) -> bool {\n    if let Some(equal) = limbs_eq_mod_limb_helper(xs, ys, m) {\n        return equal;\n    }\n    let mut scratch = vec![0; xs.len()];\n    // calculate |xs - ys|\n    if limbs_cmp(xs, ys) >= Equal {\n        assert!(!limbs_sub_greater_to_out(&mut scratch, xs, ys));\n    } else {\n        assert!(!limbs_sub_same_length_to_out(&mut scratch, ys, xs));\n    }\n    scratch.truncate(scratch.len() - slice_trailing_zeros(&scratch));\n    // scratch is non-empty here because xs != ys\n    if scratch.len() == 1 {\n        scratch[0].divisible_by(m)\n    } else {\n        limbs_divisible_by_limb(&scratch, m)\n    }\n}\n\n// Interpreting two slices of `Limb`s `xs` and `ys` and a Limb `m` as three numbers x, y, and m,\n// determines whether x ≡ y mod m. The first input slice is immutable and the second is mutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `m` is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs` or `ys` is less than 2, if the last element of either of the slices\n// is zero, or if `m` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive, `a` and `c` are longer than one limb, and `m` is one limb long.\npub_test! {limbs_eq_mod_limb_ref_val(xs: &[Limb], ys: &mut [Limb], m: Limb) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_limb_ref_val_greater(xs, ys, m)\n    } else {\n        limbs_eq_mod_limb_val_ref_greater(ys, xs, m)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_limb_ref_val_greater(xs: &[Limb], ys: &mut [Limb], m: Limb) -> bool {\n    if let Some(equal) = limbs_eq_mod_limb_helper(xs, ys, m) {\n        return equal;\n    }\n    let mut scratch;\n    // calculate |xs - ys|\n    let scratch = if limbs_cmp(xs, ys) >= Equal {\n        scratch = vec![0; xs.len()];\n        assert!(!limbs_sub_greater_to_out(&mut scratch, xs, ys));\n        &mut scratch\n    } else {\n        assert!(!limbs_sub_same_length_in_place_left(ys, xs));\n        ys\n    };\n    let new_len = scratch.len() - slice_trailing_zeros(scratch);\n    // scratch is non-empty here because xs != ys\n    if new_len == 1 {\n        scratch[0].divisible_by(m)\n    } else {\n        limbs_divisible_by_limb(&scratch[..new_len], m)\n    }\n}\n\n// Interpreting two slices of `Limb`s `xs` and `ys` and a Limb `m` as three numbers x, y, and m,\n// determines whether x ≡ y mod m. The first input slice is mutable and the second is immutable.\n//\n// This function assumes that each of the two input slices have at least two elements, their last\n// elements are nonzero, and `m` is nonzero. Both input slices are immutable.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs` or `ys` is less than 2, if the last element of either of the slices\n// is zero, or if `m` is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive, `a` and `c` are longer than one limb, and `m` is one limb long.\npub_test! {limbs_eq_mod_limb_val_ref(xs: &mut [Limb], ys: &[Limb], m: Limb) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_limb_val_ref_greater(xs, ys, m)\n    } else {\n        limbs_eq_mod_limb_ref_val_greater(ys, xs, m)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_limb_val_ref_greater(xs: &mut [Limb], ys: &[Limb], m: Limb) -> bool {\n    if let Some(equal) = limbs_eq_mod_limb_helper(xs, ys, m) {\n        return equal;\n    }\n    // calculate |xs - ys|\n    if limbs_cmp(xs, ys) >= Equal {\n        assert!(!limbs_sub_greater_in_place_left(xs, ys));\n    } else {\n        assert!(!limbs_sub_same_length_in_place_right(ys, xs));\n    }\n    let new_len = xs.len() - slice_trailing_zeros(xs);\n    // xs is non-empty here because xs != ys\n    if new_len == 1 {\n        xs[0].divisible_by(m)\n    } else {\n        limbs_divisible_by_limb(&xs[..new_len], m)\n    }\n}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_helper(xs: &[Limb], ys: &[Limb], m: &[Limb]) -> Option<bool> {\n    let m_len = m.len();\n    assert!(m_len > 1);\n    let x_len = xs.len();\n    let y_len = ys.len();\n    assert!(y_len > 1);\n    assert!(x_len >= y_len);\n    assert_ne!(*xs.last().unwrap(), 0);\n    assert_ne!(*ys.last().unwrap(), 0);\n    assert_ne!(*m.last().unwrap(), 0);\n    if xs == ys {\n        Some(true)\n    } else if m_len > x_len || !xs[0].eq_mod_power_of_2(ys[0], TrailingZeros::trailing_zeros(m[0]))\n    {\n        // - Either: x < m, y < m, and x != y, so x != y mod m\n        // - Or: xs != ys mod low zero bits of m_0\n        Some(false)\n    } else {\n        None\n    }\n}\n\n// Interpreting three slice of `Limb`s as the limbs of three `Natural`s, determines whether the\n// first `Natural` is equal to the second `Natural` mod the third `Natural`. All input slices are\n// immutable.\n//\n// This function assumes that each of the three input slices have at least two elements, and their\n// last elements are nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs`, `ys`, or `ms` is less than 2, or if the last element of any of the\n// slices is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive and each is longer than one limb.\npub_test! {limbs_eq_mod_ref_ref_ref(xs: &[Limb], ys: &[Limb], ms: &[Limb]) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_greater_ref_ref_ref(xs, ys, ms)\n    } else {\n        limbs_eq_mod_greater_ref_ref_ref(ys, xs, ms)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_greater_ref_ref_ref(xs: &[Limb], ys: &[Limb], ms: &[Limb]) -> bool {\n    if let Some(equal) = limbs_eq_mod_helper(xs, ys, ms) {\n        return equal;\n    }\n    let mut scratch = vec![0; xs.len()];\n    // calculate |xs - ys|\n    if limbs_cmp(xs, ys) >= Equal {\n        assert!(!limbs_sub_greater_to_out(&mut scratch, xs, ys));\n    } else {\n        assert!(!limbs_sub_same_length_to_out(&mut scratch, ys, xs));\n    }\n    scratch.truncate(scratch.len() - slice_trailing_zeros(&scratch));\n    scratch.len() >= ms.len() && limbs_divisible_by_val_ref(&mut scratch, ms)\n}\n\n// Interpreting three slice of `Limb`s as the limbs of three `Natural`s, determines whether the\n// first `Natural` is equal to the second `Natural` mod the third `Natural`. The first two input\n// slices are immutable, and the third is mutable.\n//\n// This function assumes that each of the three input slices have at least two elements, and their\n// last elements are nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs`, `ys`, or `ms` is less than 2, or if the last element of any of the\n// slices is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive and each is longer than one limb.\npub_test! {limbs_eq_mod_ref_ref_val(xs: &[Limb], ys: &[Limb], ms: &mut [Limb]) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_greater_ref_ref_val(xs, ys, ms)\n    } else {\n        limbs_eq_mod_greater_ref_ref_val(ys, xs, ms)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_greater_ref_ref_val(xs: &[Limb], ys: &[Limb], ms: &mut [Limb]) -> bool {\n    if let Some(equal) = limbs_eq_mod_helper(xs, ys, ms) {\n        return equal;\n    }\n    let mut scratch = vec![0; xs.len()];\n    // calculate |xs - ys|\n    if limbs_cmp(xs, ys) >= Equal {\n        assert!(!limbs_sub_greater_to_out(&mut scratch, xs, ys));\n    } else {\n        assert!(!limbs_sub_same_length_to_out(&mut scratch, ys, xs));\n    }\n    scratch.truncate(scratch.len() - slice_trailing_zeros(&scratch));\n    scratch.len() >= ms.len() && limbs_divisible_by(&mut scratch, ms)\n}\n\n// Interpreting three slice of `Limb`s as the limbs of three `Natural`s, determines whether the\n// first `Natural` is equal to the second `Natural` mod the third `Natural`. The first and third\n// input slices are immutable, and the second is mutable.\n//\n// This function assumes that each of the three input slices have at least two elements, and their\n// last elements are nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs`, `ys`, or `ms` is less than 2, or if the last element of any of the\n// slices is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive and each is longer than one limb.\npub_test! {limbs_eq_mod_ref_val_ref(xs: &[Limb], ys: &mut [Limb], ms: &[Limb]) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_greater_ref_val_ref(xs, ys, ms)\n    } else {\n        limbs_eq_mod_greater_val_ref_ref(ys, xs, ms)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_greater_ref_val_ref(xs: &[Limb], ys: &mut [Limb], ms: &[Limb]) -> bool {\n    if let Some(equal) = limbs_eq_mod_helper(xs, ys, ms) {\n        return equal;\n    }\n    let mut scratch;\n    // calculate |xs - ys|\n    let scratch = if limbs_cmp(xs, ys) >= Equal {\n        scratch = vec![0; xs.len()];\n        assert!(!limbs_sub_greater_to_out(&mut scratch, xs, ys));\n        &mut scratch\n    } else {\n        assert!(!limbs_sub_same_length_in_place_left(ys, xs));\n        ys\n    };\n    let new_len = scratch.len() - slice_trailing_zeros(scratch);\n    new_len >= ms.len() && limbs_divisible_by_val_ref(&mut scratch[..new_len], ms)\n}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_greater_val_ref_ref(xs: &mut [Limb], ys: &[Limb], ms: &[Limb]) -> bool {\n    if let Some(equal) = limbs_eq_mod_helper(xs, ys, ms) {\n        return equal;\n    }\n    // calculate |xs - ys|\n    if limbs_cmp(xs, ys) >= Equal {\n        assert!(!limbs_sub_greater_in_place_left(xs, ys));\n    } else {\n        assert!(!limbs_sub_same_length_in_place_right(ys, xs));\n    }\n    let new_len = xs.len() - slice_trailing_zeros(xs);\n    new_len >= ms.len() && limbs_divisible_by_val_ref(&mut xs[..new_len], ms)\n}\n\n// Interpreting three slice of `Limb`s as the limbs of three `Natural`s, determines whether the\n// first `Natural` is equal to the second `Natural` mod the third `Natural`. The first input slice\n// is immutable, and the second and third are mutable.\n//\n// This function assumes that each of the three input slices have at least two elements, and their\n// last elements are nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log \\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the length of `xs`, `ys`, or `ms` is less than 2, or if the last element of any of the\n// slices is zero.\n//\n// This is equivalent to `mpz_congruent_p` from `mpz/cong.c`, GMP 6.2.1, where `a`, `c`, and `d` are\n// positive and each is longer than one limb.\npub_test! {limbs_eq_mod_ref_val_val(xs: &[Limb], ys: &mut [Limb], ms: &mut [Limb]) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_eq_mod_greater_ref_val_val(xs, ys, ms)\n    } else {\n        limbs_eq_mod_greater_val_ref_val(ys, xs, ms)\n    }\n}}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_greater_ref_val_val(xs: &[Limb], ys: &mut [Limb], ms: &mut [Limb]) -> bool {\n    if let Some(equal) = limbs_eq_mod_helper(xs, ys, ms) {\n        return equal;\n    }\n    let mut scratch;\n    // calculate |xs - ys|\n    let scratch = if limbs_cmp(xs, ys) >= Equal {\n        scratch = vec![0; xs.len()];\n        assert!(!limbs_sub_greater_to_out(&mut scratch, xs, ys));\n        &mut scratch\n    } else {\n        assert!(!limbs_sub_same_length_in_place_left(ys, xs));\n        ys\n    };\n    let new_len = scratch.len() - slice_trailing_zeros(scratch);\n    new_len >= ms.len() && limbs_divisible_by(&mut scratch[..new_len], ms)\n}\n\n// xs.len() >= ys.len()\nfn limbs_eq_mod_greater_val_ref_val(xs: &mut [Limb], ys: &[Limb], ms: &mut [Limb]) -> bool {\n    if let Some(equal) = limbs_eq_mod_helper(xs, ys, ms) {\n        return equal;\n    }\n    // calculate |xs - ys|\n    if limbs_cmp(xs, ys) >= Equal {\n        assert!(!limbs_sub_greater_in_place_left(xs, ys));\n    } else {\n        assert!(!limbs_sub_same_length_in_place_right(ys, xs));\n    }\n    let new_len = xs.len() - slice_trailing_zeros(xs);\n    new_len >= ms.len() && limbs_divisible_by(&mut xs[..new_len], ms)\n}\n\nimpl Natural {\n    fn eq_mod_limb(&self, other: Limb, m: Limb) -> bool {\n        match self {\n            Self(Small(small)) => small.eq_mod(other, m),\n            Self(Large(_)) if m == 0 => false,\n            Self(Large(limbs)) => limbs_eq_limb_mod_limb(limbs, other, m),\n        }\n    }\n}\n\nimpl EqMod<Self, Self> for Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. All three are taken\n    /// by value.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(123u32).eq_mod(Natural::from(223u32), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Natural::from_str(\"2000000987654\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Natural::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Self, m: Self) -> bool {\n        match (self, other, m) {\n            (x, y, Self::ZERO) => x == y,\n            (x, Self::ZERO, m) => x.divisible_by(m),\n            (Self::ZERO, y, m) => y.divisible_by(m),\n            (x, Self(Small(y)), Self(Small(m))) => x.eq_mod_limb(y, m),\n            (Self(Small(x)), y, Self(Small(m))) => y.eq_mod_limb(x, m),\n            (Self(Small(x)), Self(Small(y)), _) => x == y,\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Small(m))) => {\n                limbs_eq_mod_limb_val_ref(&mut xs, &ys, m)\n            }\n            (Self(Large(mut xs)), Self(Small(y)), Self(Large(mut m))) => {\n                limbs_eq_limb_mod(&mut xs, y, &mut m)\n            }\n            (Self(Small(x)), Self(Large(mut ys)), Self(Large(mut m))) => {\n                limbs_eq_limb_mod(&mut ys, x, &mut m)\n            }\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Large(mut m))) => {\n                limbs_eq_mod_ref_val_val(&ys, &mut xs, &mut m)\n            }\n        }\n    }\n}\n\nimpl<'a> EqMod<Self, &'a Self> for Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. The first two are\n    /// taken by value and the third by reference.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(123u32).eq_mod(Natural::from(223u32), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Natural::from_str(\"2000000987654\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         Natural::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Self, m: &'a Self) -> bool {\n        match (self, other, m) {\n            (x, y, &Self::ZERO) => x == y,\n            (x, Self::ZERO, m) => x.divisible_by(m),\n            (Self::ZERO, y, m) => y.divisible_by(m),\n            (x, Self(Small(y)), &Self(Small(m))) => x.eq_mod_limb(y, m),\n            (Self(Small(x)), y, &Self(Small(m))) => y.eq_mod_limb(x, m),\n            (Self(Small(x)), Self(Small(y)), _) => x == y,\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Small(m))) => {\n                limbs_eq_mod_limb_val_ref(&mut xs, &ys, *m)\n            }\n            (Self(Large(mut xs)), Self(Small(y)), Self(Large(m))) => {\n                limbs_eq_limb_mod_val_ref(&mut xs, y, m)\n            }\n            (Self(Small(x)), Self(Large(mut ys)), Self(Large(m))) => {\n                limbs_eq_limb_mod_val_ref(&mut ys, x, m)\n            }\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Large(m))) => {\n                limbs_eq_mod_ref_val_ref(&ys, &mut xs, m)\n            }\n        }\n    }\n}\n\nimpl<'a> EqMod<&'a Self, Self> for Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. The first and third\n    /// are taken by value and the second by reference.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(123u32).eq_mod(&Natural::from(223u32), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Natural::from_str(\"2000000987654\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Natural::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &'a Self, m: Self) -> bool {\n        match (self, other, m) {\n            (x, y, Self::ZERO) => x == *y,\n            (x, &Self::ZERO, m) => x.divisible_by(m),\n            (Self::ZERO, y, m) => y.divisible_by(m),\n            (x, &Self(Small(y)), Self(Small(m))) => x.eq_mod_limb(y, m),\n            (Self(Small(x)), y, Self(Small(m))) => y.eq_mod_limb(x, m),\n            (Self(Small(x)), &Self(Small(y)), _) => x == y,\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Small(m))) => {\n                limbs_eq_mod_limb_val_ref(&mut xs, ys, m)\n            }\n            (Self(Large(mut xs)), Self(Small(y)), Self(Large(mut m))) => {\n                limbs_eq_limb_mod(&mut xs, *y, &mut m)\n            }\n            (Self(Small(x)), Self(Large(ys)), Self(Large(mut m))) => {\n                limbs_eq_limb_mod_ref_val(ys, x, &mut m)\n            }\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Large(mut m))) => {\n                limbs_eq_mod_ref_val_val(ys, &mut xs, &mut m)\n            }\n        }\n    }\n}\n\nimpl<'a, 'b> EqMod<&'a Self, &'b Self> for Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. The first is taken\n    /// by value and the second and third by reference.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(123u32).eq_mod(&Natural::from(223u32), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Natural::from_str(\"2000000987654\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000987654\").unwrap().eq_mod(\n    ///         &Natural::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &'a Self, m: &'b Self) -> bool {\n        match (self, other, m) {\n            (x, y, &Self::ZERO) => x == *y,\n            (x, &Self::ZERO, m) => x.divisible_by(m),\n            (Self::ZERO, y, m) => y.divisible_by(m),\n            (x, &Self(Small(y)), &Self(Small(m))) => x.eq_mod_limb(y, m),\n            (Self(Small(x)), y, &Self(Small(m))) => y.eq_mod_limb(x, m),\n            (Self(Small(x)), &Self(Small(y)), _) => x == y,\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Small(m))) => {\n                limbs_eq_mod_limb_val_ref(&mut xs, ys, *m)\n            }\n            (Self(Large(mut xs)), Self(Small(y)), Self(Large(m))) => {\n                limbs_eq_limb_mod_val_ref(&mut xs, *y, m)\n            }\n            (Self(Small(x)), Self(Large(ys)), Self(Large(m))) => {\n                limbs_eq_limb_mod_ref_ref(ys, x, m)\n            }\n            (Self(Large(mut xs)), Self(Large(ys)), Self(Large(m))) => {\n                limbs_eq_mod_ref_val_ref(ys, &mut xs, m)\n            }\n        }\n    }\n}\n\nimpl EqMod<Natural, Natural> for &Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. The first is taken\n    /// by reference and the second and third by value.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(123u32)).eq_mod(Natural::from(223u32), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Natural::from_str(\"2000000987654\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Natural::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Natural, m: Natural) -> bool {\n        match (self, other, m) {\n            (x, y, Natural::ZERO) => *x == y,\n            (x, Natural::ZERO, m) => x.divisible_by(m),\n            (&Natural::ZERO, y, m) => y.divisible_by(m),\n            (x, Natural(Small(y)), Natural(Small(m))) => x.eq_mod_limb(y, m),\n            (&Natural(Small(x)), y, Natural(Small(m))) => y.eq_mod_limb(x, m),\n            (&Natural(Small(x)), Natural(Small(y)), _) => x == y,\n            (Natural(Large(xs)), Natural(Large(mut ys)), Natural(Small(m))) => {\n                limbs_eq_mod_limb_ref_val(xs, &mut ys, m)\n            }\n            (Natural(Large(xs)), Natural(Small(y)), Natural(Large(mut m))) => {\n                limbs_eq_limb_mod_ref_val(xs, y, &mut m)\n            }\n            (Natural(Small(x)), Natural(Large(mut ys)), Natural(Large(mut m))) => {\n                limbs_eq_limb_mod(&mut ys, *x, &mut m)\n            }\n            (Natural(Large(xs)), Natural(Large(mut ys)), Natural(Large(mut m))) => {\n                limbs_eq_mod_ref_val_val(xs, &mut ys, &mut m)\n            }\n        }\n    }\n}\n\nimpl EqMod<Natural, &Natural> for &Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. The first and third\n    /// are taken by reference and the second by value.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(123u32)).eq_mod(Natural::from(223u32), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Natural::from_str(\"2000000987654\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         Natural::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: Natural, m: &Natural) -> bool {\n        match (self, other, m) {\n            (x, y, &Natural::ZERO) => *x == y,\n            (x, Natural::ZERO, m) => x.divisible_by(m),\n            (&Natural::ZERO, y, m) => y.divisible_by(m),\n            (x, Natural(Small(y)), &Natural(Small(m))) => x.eq_mod_limb(y, m),\n            (&Natural(Small(x)), y, &Natural(Small(m))) => y.eq_mod_limb(x, m),\n            (&Natural(Small(x)), Natural(Small(y)), _) => x == y,\n            (Natural(Large(xs)), Natural(Large(mut ys)), Natural(Small(m))) => {\n                limbs_eq_mod_limb_ref_val(xs, &mut ys, *m)\n            }\n            (Natural(Large(xs)), Natural(Small(y)), Natural(Large(m))) => {\n                limbs_eq_limb_mod_ref_ref(xs, y, m)\n            }\n            (Natural(Small(x)), Natural(Large(mut ys)), Natural(Large(m))) => {\n                limbs_eq_limb_mod_val_ref(&mut ys, *x, m)\n            }\n            (Natural(Large(xs)), Natural(Large(mut ys)), Natural(Large(m))) => {\n                limbs_eq_mod_ref_val_ref(xs, &mut ys, m)\n            }\n        }\n    }\n}\n\nimpl EqMod<&Natural, Natural> for &Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. The first and\n    /// second are taken by reference and the third by value.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(123u32)).eq_mod(&Natural::from(223u32), Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Natural::from_str(\"2000000987654\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Natural::from_str(\"2000000987655\").unwrap(),\n    ///         Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &Natural, m: Natural) -> bool {\n        match (self, other, m) {\n            (x, y, Natural::ZERO) => x == y,\n            (x, &Natural::ZERO, m) => x.divisible_by(m),\n            (&Natural::ZERO, y, m) => y.divisible_by(m),\n            (x, &Natural(Small(y)), Natural(Small(m))) => x.eq_mod_limb(y, m),\n            (&Natural(Small(x)), y, Natural(Small(m))) => y.eq_mod_limb(x, m),\n            (&Natural(Small(x)), &Natural(Small(y)), _) => x == y,\n            (Natural(Large(xs)), Natural(Large(ys)), Natural(Small(m))) => {\n                limbs_eq_mod_limb_ref_ref(xs, ys, m)\n            }\n            (Natural(Large(xs)), Natural(Small(y)), Natural(Large(mut m))) => {\n                limbs_eq_limb_mod_ref_val(xs, *y, &mut m)\n            }\n            (Natural(Small(x)), Natural(Large(ys)), Natural(Large(mut m))) => {\n                limbs_eq_limb_mod_ref_val(ys, *x, &mut m)\n            }\n            (Natural(Large(xs)), Natural(Large(ys)), Natural(Large(mut m))) => {\n                limbs_eq_mod_ref_ref_val(xs, ys, &mut m)\n            }\n        }\n    }\n}\n\nimpl EqMod<&Natural, &Natural> for &Natural {\n    /// Returns whether a [`Natural`] is equivalent to another [`Natural`] modulo a third; that is,\n    /// whether the difference between the first two is a multiple of the third. All three are taken\n    /// by reference.\n    ///\n    /// Two [`Natural`]s are equal to each other modulo 0 iff they are equal.\n    ///\n    /// $f(x, y, m) = (x \\equiv y \\mod m)$.\n    ///\n    /// $f(x, y, m) = (\\exists k \\in \\Z : x - y = km)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log \\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::EqMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(123u32)).eq_mod(&Natural::from(223u32), &Natural::from(100u32)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Natural::from_str(\"2000000987654\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000987654\").unwrap()).eq_mod(\n    ///         &Natural::from_str(\"2000000987655\").unwrap(),\n    ///         &Natural::from_str(\"1000000000000\").unwrap()\n    ///     ),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod(self, other: &Natural, m: &Natural) -> bool {\n        match (self, other, m) {\n            (x, y, &Natural::ZERO) => x == y,\n            (x, &Natural::ZERO, m) => x.divisible_by(m),\n            (&Natural::ZERO, y, m) => y.divisible_by(m),\n            (x, &Natural(Small(y)), &Natural(Small(m))) => x.eq_mod_limb(y, m),\n            (&Natural(Small(x)), y, &Natural(Small(m))) => y.eq_mod_limb(x, m),\n            (&Natural(Small(x)), &Natural(Small(y)), _) => x == y,\n            (Natural(Large(xs)), Natural(Large(ys)), Natural(Small(m))) => {\n                limbs_eq_mod_limb_ref_ref(xs, ys, *m)\n            }\n            (Natural(Large(xs)), Natural(Small(y)), Natural(Large(m))) => {\n                limbs_eq_limb_mod_ref_ref(xs, *y, m)\n            }\n            (Natural(Small(x)), Natural(Large(ys)), Natural(Large(m))) => {\n                limbs_eq_limb_mod_ref_ref(ys, *x, m)\n            }\n            (Natural(Large(xs)), Natural(Large(ys)), Natural(Large(m))) => {\n                limbs_eq_mod_ref_ref_ref(xs, ys, m)\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2001, 2002, 2013 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::divisible_by_power_of_2::limbs_divisible_by_power_of_2;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::EqModPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::WrappingFrom;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns whether\n// the `Natural` is equivalent to a limb mod two to the power of `pow`; that is, whether the `pow`\n// least-significant bits of the `Natural` and the limb are equal.\n//\n// This function assumes that `xs` has length at least 2 and the last (most significant) limb is\n// nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_eq_limb_mod_power_of_2(xs: &[Limb], y: Limb, pow: u64) -> bool {\n    let i = bit_to_limb_count_floor(pow);\n    if i >= xs.len() {\n        false\n    } else if i == 0 {\n        xs[0].eq_mod_power_of_2(y, pow)\n    } else {\n        let (xs_head, xs_tail) = xs.split_first().unwrap();\n        *xs_head == y && limbs_divisible_by_power_of_2(xs_tail, pow - Limb::WIDTH)\n    }\n}}\n\n// xs.len() == ys.len()\nfn limbs_eq_mod_power_of_2_same_length(xs: &[Limb], ys: &[Limb], pow: u64) -> bool {\n    let i = bit_to_limb_count_floor(pow);\n    let len = xs.len();\n    if i >= len {\n        xs == ys\n    } else {\n        let (xs_last, xs_init) = xs[..=i].split_last().unwrap();\n        let (ys_last, ys_init) = ys[..=i].split_last().unwrap();\n        xs_init == ys_init && xs_last.eq_mod_power_of_2(*ys_last, pow & Limb::WIDTH_MASK)\n    }\n}\n\n// xs.len() > ys.len()\nfn limbs_eq_mod_power_of_2_greater(xs: &[Limb], ys: &[Limb], pow: u64) -> bool {\n    let i = bit_to_limb_count_floor(pow);\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if i >= xs_len {\n        false\n    } else if i >= ys_len {\n        let (xs_lo, xs_hi) = xs.split_at(ys_len);\n        xs_lo == ys\n            && limbs_divisible_by_power_of_2(xs_hi, pow - Limb::WIDTH * u64::wrapping_from(ys_len))\n    } else {\n        let (xs_last, xs_init) = xs[..=i].split_last().unwrap();\n        let (ys_last, ys_init) = ys[..=i].split_last().unwrap();\n        xs_init == ys_init && xs_last.eq_mod_power_of_2(*ys_last, pow & Limb::WIDTH_MASK)\n    }\n}\n\n/// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two [`Natural`]s,\n/// returns whether the [`Natural`]s are equivalent mod two to the power of `pow`; that is, whether\n/// their `pow` least-significant bits are equal.\n///\n/// This function assumes that neither slice is empty and their last elements are nonzero.\n///\n/// # Worst-case complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(1)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `min(pow, xs.len(), ys.len())`.\n///\n/// This is equivalent to `mpz_congruent_2exp_p` from `mpz/cong_2exp.c`, GMP 6.2.1, where `a` and\n/// `c` are non-negative.\n#[doc(hidden)]\npub fn limbs_eq_mod_power_of_2(xs: &[Limb], ys: &[Limb], pow: u64) -> bool {\n    match xs.len().cmp(&ys.len()) {\n        Equal => limbs_eq_mod_power_of_2_same_length(xs, ys, pow),\n        Less => limbs_eq_mod_power_of_2_greater(ys, xs, pow),\n        Greater => limbs_eq_mod_power_of_2_greater(xs, ys, pow),\n    }\n}\n\nimpl Natural {\n    fn eq_mod_power_of_2_limb(&self, other: Limb, pow: u64) -> bool {\n        match self {\n            Self(Small(small)) => small.eq_mod_power_of_2(other, pow),\n            Self(Large(limbs)) => limbs_eq_limb_mod_power_of_2(limbs, other, pow),\n        }\n    }\n}\n\nimpl EqModPowerOf2<&Natural> for &Natural {\n    /// Returns whether one [`Natural`] is equal to another modulo $2^k$; that is, whether their $k$\n    /// least-significant bits are equal.\n    ///\n    /// $f(x, y, k) = (x \\equiv y \\mod 2^k)$.\n    ///\n    /// $f(x, y, k) = (\\exists n \\in \\Z : x - y = n2^k)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(pow, self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::EqModPowerOf2;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO).eq_mod_power_of_2(&Natural::from(256u32), 8),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(0b1101u32)).eq_mod_power_of_2(&Natural::from(0b10101u32), 3),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(0b1101u32)).eq_mod_power_of_2(&Natural::from(0b10101u32), 4),\n    ///     false\n    /// );\n    /// ```\n    fn eq_mod_power_of_2(self, other: &Natural, pow: u64) -> bool {\n        match (self, other) {\n            (_, &Natural(Small(y))) => self.eq_mod_power_of_2_limb(y, pow),\n            (&Natural(Small(x)), _) => other.eq_mod_power_of_2_limb(x, pow),\n            (Natural(Large(xs)), Natural(Large(ys))) => limbs_eq_mod_power_of_2(xs, ys, pow),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `limb_apprsqrt`, `mpz_2multiswing_1`, `mpz_oddfac_1`, `mpz_fac_ui`, and `mpz_2fac_ui`\n//      contributed to the GNU project by Marco Bodrato.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::mul::product_of_limbs::limbs_product;\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::square::{limbs_square_to_out, limbs_square_to_out_scratch_len};\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::{\n    Limb, NTH_ROOT_NUMB_MASK_TABLE, ODD_DOUBLEFACTORIAL_TABLE_LIMIT, ODD_DOUBLEFACTORIAL_TABLE_MAX,\n    ODD_FACTORIAL_TABLE_LIMIT, ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE, ONE_LIMB_ODD_FACTORIAL_TABLE,\n    TABLE_2N_MINUS_POPC_2N, TABLE_LIMIT_2N_MINUS_POPC_2N,\n};\nuse alloc::vec::Vec;\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    DoubleFactorial, Factorial, Gcd, Multifactorial, Parity, Pow, PowerOf2, Square, Subfactorial,\n    XMulYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, WrappingFrom};\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::factorization::prime_sieve::limbs_prime_sieve_u32;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse malachite_base::num::factorization::prime_sieve::limbs_prime_sieve_u64;\nuse malachite_base::num::factorization::prime_sieve::{id_to_n, limbs_prime_sieve_size, n_to_bit};\nuse malachite_base::num::logic::traits::{BitAccess, CountOnes, NotAssign, SignificantBits};\n\npub_test! {subfactorial_naive(n: u64) -> Natural {\n    let mut f = Natural::ONE;\n    let mut b = true;\n    for i in 1..=n {\n        f *= Natural::from(i);\n        if b {\n            f -= Natural::ONE;\n        } else {\n            f += Natural::ONE;\n        }\n        b.not_assign();\n    }\n    f\n}}\n\n// Returns an approximation of the square root of x.\n//\n// It gives:\n// ```\n// limb_apprsqrt(x) ^ 2 <= x < (limb_apprsqrt(x) + 1) ^ 2\n// ```\n// or\n// ```\n// x <= limb_apprsqrt(x) ^ 2 <= x * 9 / 8\n// ```\n//\n// This is equivalent to `limb_apprsqrt` in `mpz/oddfac_1.c`, GMP 6.2.1.\nfn limbs_approx_sqrt(x: u64) -> u64 {\n    assert!(x > 2);\n    let s = x.significant_bits() >> 1;\n    (u64::power_of_2(s) + (x >> s)) >> 1\n}\n\npub(crate) const fn bit_to_n(bit: u64) -> u64 {\n    (bit * 3 + 4) | 1\n}\n\n// `limbs_2_multiswing_odd` computes the odd part of the 2-multiswing factorial of the parameter n.\n// The result x is an odd positive integer so that multiswing(n, 2) = x * 2 ^ a.\n//\n// The algorithm is described by Peter Luschny in \"Divide, Swing and Conquer the Factorial!\".\n//\n// The pointer sieve points to `limbs_prime_sieve_size(n)` limbs containing a bit array where primes\n// are marked as 0. Enough limbs must be pointed by `factors`.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpz_2multiswing_1` from `mpz/oddfac_1.c`, GMP 6.2.1, where `x_and_sieve`\n// is provided as a single slice, allowing the sieve to be overwritten.\n#[allow(clippy::useless_conversion)]\nfn limbs_2_multiswing_odd(\n    x_and_sieve: &mut [Limb],\n    x_len: usize,\n    mut n: Limb,\n    factors: &mut [Limb],\n) -> usize {\n    assert!(n > 25);\n    let mut prod = if n.odd() { n } else { 1 };\n    n.clear_bit(0);\n    let max_prod = Limb::MAX / (n - 1);\n    // Handle prime = 3 separately\n    let mut j = 0;\n    if prod > max_prod {\n        factors[j] = prod;\n        j += 1;\n        prod = 1;\n    }\n    let mut q = n;\n    while q >= 3 {\n        q /= 3;\n        if q.odd() {\n            prod *= 3;\n        }\n    }\n    let limb_n = n;\n    let n = u64::exact_from(n);\n    // Swing primes from 5 to n / 3\n    let mut s = limbs_approx_sqrt(n);\n    assert!(s >= 5);\n    s = n_to_bit(s);\n    assert!(bit_to_n(s + 1).square() > n);\n    assert!(s < n_to_bit(n / 3));\n    let start = const { n_to_bit(5) };\n    let mut index = bit_to_limb_count_floor(start);\n    let mut mask = Limb::power_of_2(start & Limb::WIDTH_MASK);\n    let sieve = &mut x_and_sieve[x_len..];\n    for i in start + 1..=s + 1 {\n        if sieve[index] & mask == 0 {\n            let prime = Limb::exact_from(id_to_n(i));\n            if prod > max_prod {\n                factors[j] = prod;\n                j += 1;\n                prod = 1;\n            }\n            let mut q = limb_n;\n            while q >= prime {\n                q /= prime;\n                if q.odd() {\n                    prod *= prime;\n                }\n            }\n        }\n        mask <<= 1;\n        if mask == 0 {\n            mask = 1;\n            index += 1;\n        }\n    }\n    assert!(max_prod <= const { Limb::MAX / 3 });\n    let l_max_prod = max_prod * 3;\n    for i in s + 2..=n_to_bit(n / 3) + 1 {\n        if sieve[index] & mask == 0 {\n            let prime = Limb::exact_from(id_to_n(i));\n            if (limb_n / prime).odd() {\n                if prod > l_max_prod {\n                    factors[j] = prod;\n                    j += 1;\n                    prod = prime;\n                } else {\n                    prod *= prime;\n                }\n            }\n        }\n        mask <<= 1;\n        if mask == 0 {\n            mask = 1;\n            index += 1;\n        }\n    }\n    // Store primes from (n + 1) / 2 to n\n    let start = n_to_bit(n >> 1) + 1;\n    let mut index = bit_to_limb_count_floor(start);\n    let mut mask = Limb::power_of_2(start & Limb::WIDTH_MASK);\n    for i in start + 1..=n_to_bit(n) + 1 {\n        if sieve[index] & mask == 0 {\n            let prime = Limb::exact_from(id_to_n(i));\n            if prod > max_prod {\n                factors[j] = prod;\n                j += 1;\n                prod = prime;\n            } else {\n                prod *= prime;\n            }\n        }\n        mask <<= 1;\n        if mask == 0 {\n            mask = 1;\n            index += 1;\n        }\n    }\n    if j != 0 {\n        factors[j] = prod;\n        j += 1;\n        match limbs_product(&mut x_and_sieve[..x_len], &mut factors[..j]) {\n            (size, None) => size,\n            (size, Some(new_x_and_sieve)) => {\n                x_and_sieve[..size].copy_from_slice(&new_x_and_sieve[..size]);\n                size\n            }\n        }\n    } else {\n        // not triggered by the first billion inputs\n        fail_on_untested_path(\"limbs_2_multiswing_odd, j == 0\");\n        x_and_sieve[0] = prod;\n        1\n    }\n}\n\npub(crate) const FAC_DSC_THRESHOLD: usize = 236;\n\nconst fn clb2(x: usize) -> usize {\n    let floor_log_base_2 = (usize::WIDTH as usize - x.leading_zeros() as usize) - 1;\n    if x.is_power_of_two() {\n        floor_log_base_2\n    } else {\n        floor_log_base_2 + 1\n    }\n}\n\nconst FACTORS_PER_LIMB: usize =\n    (Limb::WIDTH << 1) as usize / (clb2(FAC_DSC_THRESHOLD * FAC_DSC_THRESHOLD - 1) + 1) - 1;\n\n// n ^ log <= Limb::MAX: a limb can store log factors less than n.\n//\n// This is equivalent to log_n_max, `gmp-impl.h`, GMP 6.2.1.\npub(crate) fn log_n_max(n: Limb) -> u64 {\n    // NTH_ROOT_NUMB_MASK_TABLE[0] is Limb::MAX, so a match will always be found\n    u64::wrapping_from(\n        NTH_ROOT_NUMB_MASK_TABLE\n            .iter()\n            .rposition(|&x| n <= x)\n            .unwrap(),\n    ) + 1\n}\n\n// `limbs_odd_factorial` computes the odd part of the factorial of the parameter n, i.e. n! = x * 2\n// ^ a, where x is the returned value: an odd positive integer.\n//\n// If `double` is `true`, a square is skipped in the DSC part, e.g. if n is odd, n >\n// FAC_DSC_THRESHOLD and `double` is true, x is set to n!!.\n//\n// If n is too small, `double` is ignored, and an assert can be triggered.\n//\n// TODO: FAC_DSC_THRESHOLD is used here with two different roles:\n// - to decide when prime factorisation is needed,\n// - to stop the recursion, once sieving is done.\n// Maybe two thresholds can do a better job.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpz_oddfac_1` from `mpz/oddfac_1.c`, GMP 6.2.1.\n\npub_crate_test! {\n#[allow(clippy::redundant_comparisons)]\nlimbs_odd_factorial(n: usize, double: bool) -> Vec<Limb> {\n    assert!(Limb::convertible_from(n));\n    if double {\n        assert!(n > ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1 && n >= FAC_DSC_THRESHOLD);\n    }\n    if n <= ODD_FACTORIAL_TABLE_LIMIT {\n        vec![ONE_LIMB_ODD_FACTORIAL_TABLE[n]]\n    } else if n <= ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1 {\n        let (hi, lo) = Limb::x_mul_y_to_zz(\n            ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE[(n - 1) >> 1],\n            ONE_LIMB_ODD_FACTORIAL_TABLE[n >> 1],\n        );\n        vec![lo, hi]\n    } else {\n        // Compute the number of recursive steps for the DSC algorithm\n        let mut m = n;\n        let mut s = 0;\n        while m >= FAC_DSC_THRESHOLD {\n            m >>= 1;\n            s += 1;\n        }\n        let mut factors = vec![0; m / FACTORS_PER_LIMB + 1];\n        assert!(m >= FACTORS_PER_LIMB);\n        const LIMIT_P1: usize = ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1;\n        assert!(m > LIMIT_P1);\n        let mut j = 0;\n        let mut prod = 1;\n        let mut max_prod = const { Limb::MAX / (FAC_DSC_THRESHOLD * FAC_DSC_THRESHOLD) as Limb };\n        assert!(m > LIMIT_P1);\n        loop {\n            factors[j] = ODD_DOUBLEFACTORIAL_TABLE_MAX;\n            j += 1;\n            let mut diff = (m - ODD_DOUBLEFACTORIAL_TABLE_LIMIT) & const { 2usize.wrapping_neg() };\n            if diff & 2 != 0 {\n                let f = (ODD_DOUBLEFACTORIAL_TABLE_LIMIT + diff) as Limb;\n                if prod > max_prod {\n                    factors[j] = prod;\n                    j += 1;\n                    prod = f;\n                } else {\n                    prod *= f;\n                }\n                diff -= 2;\n            }\n            if diff != 0 {\n                let mut fac = (ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 2)\n                    * (ODD_DOUBLEFACTORIAL_TABLE_LIMIT + diff);\n                loop {\n                    let f = fac as Limb;\n                    if prod > max_prod {\n                        factors[j] = prod;\n                        j += 1;\n                        prod = f;\n                    } else {\n                        prod *= f;\n                    }\n                    diff -= 4;\n                    fac += diff << 1;\n                    if diff == 0 {\n                        break;\n                    }\n                }\n            }\n            max_prod <<= 2;\n            m >>= 1;\n            if m <= LIMIT_P1 {\n                break;\n            }\n        }\n        factors[j] = prod;\n        j += 1;\n        factors[j] = ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE[(m - 1) >> 1];\n        j += 1;\n        factors[j] = ONE_LIMB_ODD_FACTORIAL_TABLE[m >> 1];\n        j += 1;\n        let mut out = Vec::new();\n        let (out_size, new_out) = limbs_product(&mut out, &mut factors[..j]);\n        out = new_out.unwrap();\n        out.truncate(out_size);\n        if s != 0 {\n            // Use the algorithm described by Peter Luschny in \"Divide, Swing and Conquer the\n            // Factorial!\".\n            let mut size = (n >> Limb::LOG_WIDTH) + 4;\n            let n_m_1 = u64::exact_from(n - 1);\n            assert!(limbs_prime_sieve_size::<Limb>(n_m_1) < size - (size >> 1));\n            // 2-multiswing(n) < 2^(n - 1) * sqrt(n / pi) < 2 ^ (n + Limb::WIDTH); One more can be\n            // overwritten by mul, another for the sieve.\n            let mut swing_and_sieve = vec![0; size];\n            // Put the sieve on the second half; it will be overwritten by the last\n            // `limbs_2_multiswing_odd`.\n            let sieve_offset = (size >> 1) + 1;\n            let ss_len = swing_and_sieve.len() - 1;\n            #[cfg(feature = \"32_bit_limbs\")]\n            let count = limbs_prime_sieve_u32(&mut swing_and_sieve[sieve_offset..ss_len], n_m_1);\n            #[cfg(not(feature = \"32_bit_limbs\"))]\n            let count = limbs_prime_sieve_u64(&mut swing_and_sieve[sieve_offset..ss_len], n_m_1);\n            size = usize::exact_from((count + 1) / log_n_max(Limb::exact_from(n)) + 1);\n            let mut factors = vec![0; size];\n            let mut out_len = out.len();\n            for i in (0..s).rev() {\n                let ns = limbs_2_multiswing_odd(\n                    &mut swing_and_sieve,\n                    sieve_offset,\n                    Limb::exact_from(n >> i),\n                    &mut factors,\n                );\n                let mut square;\n                if double && i == 0 {\n                    size = out_len;\n                    square = vec![0; size];\n                    square[..out_len].copy_from_slice(&out[..out_len]);\n                } else {\n                    size = out_len << 1;\n                    square = vec![0; size];\n                    let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(out_len)];\n                    limbs_square_to_out(&mut square, &out[..out_len], &mut square_scratch);\n                    if square[size - 1] == 0 {\n                        size -= 1;\n                    }\n                }\n                out_len = size + ns;\n                out.resize(out_len, 0);\n                assert!(ns <= size);\n                // n != n$ * floor(n / 2)! ^ 2\n                let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(size, ns)];\n                if limbs_mul_greater_to_out(\n                    &mut out,\n                    &square[..size],\n                    &swing_and_sieve[..ns],\n                    &mut mul_scratch,\n                ) == 0\n                {\n                    out_len -= 1;\n                }\n            }\n        }\n        if *out.last().unwrap() == 0 {\n            out.pop();\n        }\n        out\n    }\n}}\n\nconst FAC_ODD_THRESHOLD: Limb = 24;\n\n#[cfg(feature = \"32_bit_limbs\")]\nconst SMALL_FACTORIAL_LIMIT: u64 = 13;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst SMALL_FACTORIAL_LIMIT: u64 = 21;\n\nimpl Factorial for Natural {\n    /// Computes the factorial of a number.\n    ///\n    /// $$\n    /// f(n) = n! = 1 \\times 2 \\times 3 \\times \\cdots \\times n.\n    /// $$\n    ///\n    /// $n! = O(\\sqrt{n}(n/e)^n)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Factorial;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::factorial(0), 1);\n    /// assert_eq!(Natural::factorial(1), 1);\n    /// assert_eq!(Natural::factorial(2), 2);\n    /// assert_eq!(Natural::factorial(3), 6);\n    /// assert_eq!(Natural::factorial(4), 24);\n    /// assert_eq!(Natural::factorial(5), 120);\n    /// assert_eq!(\n    ///     Natural::factorial(100).to_string(),\n    ///     \"9332621544394415268169923885626670049071596826438162146859296389521759999322991560894\\\n    ///     1463976156518286253697920827223758251185210916864000000000000000000000000\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `mpz_fac_ui` from `mpz/fac_ui.c`, GMP 6.2.1.\n    #[allow(clippy::useless_conversion)]\n    fn factorial(n: u64) -> Self {\n        assert!(Limb::convertible_from(n));\n        if n < SMALL_FACTORIAL_LIMIT {\n            Self::from(Limb::factorial(n))\n        } else if n < u64::from(FAC_ODD_THRESHOLD) {\n            let mut factors =\n                vec![0; usize::wrapping_from(n - SMALL_FACTORIAL_LIMIT) / FACTORS_PER_LIMB + 2];\n            factors[0] = Limb::factorial(SMALL_FACTORIAL_LIMIT - 1);\n            let mut j = 1;\n            let n = Limb::wrapping_from(n);\n            let mut prod = n;\n            const MAX_PROD: Limb = Limb::MAX / (FAC_ODD_THRESHOLD | 1);\n            const LIMB_SMALL_FACTORIAL_LIMIT: Limb = SMALL_FACTORIAL_LIMIT as Limb;\n            for i in (LIMB_SMALL_FACTORIAL_LIMIT..n).rev() {\n                if prod > MAX_PROD {\n                    factors[j] = prod;\n                    j += 1;\n                    prod = i;\n                } else {\n                    prod *= i;\n                }\n            }\n            factors[j] = prod;\n            j += 1;\n            let mut xs = Vec::new();\n            let new_xs = limbs_product(&mut xs, &mut factors[..j]).1;\n            xs = new_xs.unwrap();\n            Self::from_owned_limbs_asc(xs)\n        } else {\n            let count = if n <= TABLE_LIMIT_2N_MINUS_POPC_2N {\n                u64::from(TABLE_2N_MINUS_POPC_2N[usize::exact_from((n >> 1) - 1)])\n            } else {\n                n - CountOnes::count_ones(n)\n            };\n            Self::from_owned_limbs_asc(limbs_odd_factorial(usize::exact_from(n), false)) << count\n        }\n    }\n}\n\nconst FAC_2DSC_THRESHOLD: Limb = ((FAC_DSC_THRESHOLD << 1) | (FAC_DSC_THRESHOLD & 1)) as Limb;\n\nimpl DoubleFactorial for Natural {\n    /// Computes the double factorial of a number.\n    ///\n    /// $$\n    /// f(n) = n!! = n \\times (n - 2) \\times (n - 4) \\times \\cdots \\times i,\n    /// $$\n    /// where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.\n    ///\n    /// $n!! = O(\\sqrt{n}(n/e)^{n/2})$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::DoubleFactorial;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::double_factorial(0), 1);\n    /// assert_eq!(Natural::double_factorial(1), 1);\n    /// assert_eq!(Natural::double_factorial(2), 2);\n    /// assert_eq!(Natural::double_factorial(3), 3);\n    /// assert_eq!(Natural::double_factorial(4), 8);\n    /// assert_eq!(Natural::double_factorial(5), 15);\n    /// assert_eq!(Natural::double_factorial(6), 48);\n    /// assert_eq!(Natural::double_factorial(7), 105);\n    /// assert_eq!(\n    ///     Natural::double_factorial(99).to_string(),\n    ///     \"2725392139750729502980713245400918633290796330545803413734328823443106201171875\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::double_factorial(100).to_string(),\n    ///     \"34243224702511976248246432895208185975118675053719198827915654463488000000000000\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `mpz_2fac_ui` from `mpz/2fac_ui.c`, GMP 6.2.1.\n    fn double_factorial(n: u64) -> Self {\n        assert!(Limb::convertible_from(n));\n        if n.even() {\n            // n is even, n = 2k, (2k)!! = k! 2^k\n            let half_n = usize::wrapping_from(n >> 1);\n            let count = if n <= TABLE_LIMIT_2N_MINUS_POPC_2N && n != 0 {\n                u64::from(TABLE_2N_MINUS_POPC_2N[half_n - 1])\n            } else {\n                n - CountOnes::count_ones(n)\n            };\n            Self::from_owned_limbs_asc(limbs_odd_factorial(half_n, false)) << count\n        } else if n <= u64::wrapping_from(ODD_DOUBLEFACTORIAL_TABLE_LIMIT) {\n            Self::from(ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE[usize::wrapping_from(n >> 1)])\n        } else if n < u64::wrapping_from(FAC_2DSC_THRESHOLD) {\n            let mut factors = vec![0; usize::exact_from(n) / (FACTORS_PER_LIMB << 1) + 1];\n            factors[0] = ODD_DOUBLEFACTORIAL_TABLE_MAX;\n            let mut j = 1;\n            let mut n = Limb::wrapping_from(n);\n            let mut prod = n;\n            let max_prod = Limb::MAX / FAC_2DSC_THRESHOLD;\n            const LIMIT: Limb = ODD_DOUBLEFACTORIAL_TABLE_LIMIT as Limb + 2;\n            while n > LIMIT {\n                n -= 2;\n                if prod > max_prod {\n                    factors[j] = prod;\n                    j += 1;\n                    prod = n;\n                } else {\n                    prod *= n;\n                }\n            }\n            factors[j] = prod;\n            j += 1;\n            let mut xs = Vec::new();\n            let new_xs = limbs_product(&mut xs, &mut factors[..j]).1;\n            xs = new_xs.unwrap();\n            Self::from_owned_limbs_asc(xs)\n        } else {\n            Self::from_owned_limbs_asc(limbs_odd_factorial(usize::exact_from(n), true))\n        }\n    }\n}\n\nimpl Multifactorial for Natural {\n    /// Computes a multifactorial of a number.\n    ///\n    /// $$\n    /// f(n, m) = n!^{(m)} = n \\times (n - m) \\times (n - 2m) \\times \\cdots \\times i.\n    /// $$\n    /// If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when $n$ is\n    /// divided by $m$.\n    ///\n    /// $n!^{(m)} = O(\\sqrt{n}(n/e)^{n/m})$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n, m) = O(n \\log n)$\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Multifactorial;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::multifactorial(0, 1), 1);\n    /// assert_eq!(Natural::multifactorial(1, 1), 1);\n    /// assert_eq!(Natural::multifactorial(2, 1), 2);\n    /// assert_eq!(Natural::multifactorial(3, 1), 6);\n    /// assert_eq!(Natural::multifactorial(4, 1), 24);\n    /// assert_eq!(Natural::multifactorial(5, 1), 120);\n    ///\n    /// assert_eq!(Natural::multifactorial(0, 2), 1);\n    /// assert_eq!(Natural::multifactorial(1, 2), 1);\n    /// assert_eq!(Natural::multifactorial(2, 2), 2);\n    /// assert_eq!(Natural::multifactorial(3, 2), 3);\n    /// assert_eq!(Natural::multifactorial(4, 2), 8);\n    /// assert_eq!(Natural::multifactorial(5, 2), 15);\n    /// assert_eq!(Natural::multifactorial(6, 2), 48);\n    /// assert_eq!(Natural::multifactorial(7, 2), 105);\n    ///\n    /// assert_eq!(Natural::multifactorial(0, 3), 1);\n    /// assert_eq!(Natural::multifactorial(1, 3), 1);\n    /// assert_eq!(Natural::multifactorial(2, 3), 2);\n    /// assert_eq!(Natural::multifactorial(3, 3), 3);\n    /// assert_eq!(Natural::multifactorial(4, 3), 4);\n    /// assert_eq!(Natural::multifactorial(5, 3), 10);\n    /// assert_eq!(Natural::multifactorial(6, 3), 18);\n    /// assert_eq!(Natural::multifactorial(7, 3), 28);\n    /// assert_eq!(Natural::multifactorial(8, 3), 80);\n    /// assert_eq!(Natural::multifactorial(9, 3), 162);\n    ///\n    /// assert_eq!(\n    ///     Natural::multifactorial(100, 3).to_string(),\n    ///     \"174548867015437739741494347897360069928419328000000000\"\n    /// );\n    /// ```\n    fn multifactorial(mut n: u64, mut m: u64) -> Self {\n        assert_ne!(m, 0);\n        assert!(Limb::convertible_from(n));\n        assert!(Limb::convertible_from(m));\n        if n < 3 || n - 3 < m - 1 {\n            // n < 3 || n - 1 <= m\n            if n == 0 { Self::ONE } else { Self::from(n) }\n        } else {\n            // 0 < m < n - 1 < Limb::MAX\n            let gcd = n.gcd(m);\n            if gcd > 1 {\n                n /= gcd;\n                m /= gcd;\n            }\n            if m <= 2 {\n                // fac or 2fac\n                if m == 1 {\n                    match gcd {\n                        gcd if gcd > 2 => Self::from(gcd).pow(n) * Self::factorial(n),\n                        2 => Self::double_factorial(n << 1),\n                        _ => Self::factorial(n),\n                    }\n                } else if gcd > 1 {\n                    // m == 2\n                    Self::from(gcd).pow((n >> 1) + 1) * Self::double_factorial(n)\n                } else {\n                    Self::double_factorial(n)\n                }\n            } else {\n                // m >= 3, gcd(n,m) = 1\n                let reduced_n = n / m + 1;\n                let mut n = Limb::exact_from(n);\n                let m = Limb::exact_from(m);\n                let mut j = 0;\n                let mut prod = n;\n                n -= m;\n                let max_prod = Limb::MAX / n;\n                let mut factors = vec![0; usize::exact_from(reduced_n / log_n_max(n) + 2)];\n                while n > m {\n                    if prod > max_prod {\n                        factors[j] = prod;\n                        j += 1;\n                        prod = n;\n                    } else {\n                        prod *= n;\n                    }\n                    n -= m;\n                }\n                factors[j] = n;\n                j += 1;\n                factors[j] = prod;\n                j += 1;\n                let mut xs = Vec::new();\n                let new_xs = limbs_product(&mut xs, &mut factors[..j]).1;\n                xs = new_xs.unwrap();\n                let x = Self::from_owned_limbs_asc(xs);\n                if gcd == 1 {\n                    x\n                } else {\n                    Self::from(gcd).pow(reduced_n) * x\n                }\n            }\n        }\n    }\n}\n\nimpl Subfactorial for Natural {\n    /// Computes the subfactorial of a number.\n    ///\n    /// The subfactorial of $n$ counts the number of derangements of a set of size $n$; a\n    /// derangement is a permutation with no fixed points.\n    ///\n    /// $$\n    /// f(n) = \\\\ !n = \\lfloor n!/e \\rfloor.\n    /// $$\n    ///\n    /// $!n = O(n!) = O(\\sqrt{n}(n/e)^n)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Subfactorial;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::subfactorial(0), 1);\n    /// assert_eq!(Natural::subfactorial(1), 0);\n    /// assert_eq!(Natural::subfactorial(2), 1);\n    /// assert_eq!(Natural::subfactorial(3), 2);\n    /// assert_eq!(Natural::subfactorial(4), 9);\n    /// assert_eq!(Natural::subfactorial(5), 44);\n    /// assert_eq!(\n    ///     Natural::subfactorial(100).to_string(),\n    ///     \"3433279598416380476519597752677614203236578380537578498354340028268518079332763243279\\\n    ///     1396429850988990237345920155783984828001486412574060553756854137069878601\"\n    /// );\n    /// ```\n    #[inline]\n    fn subfactorial(n: u64) -> Self {\n        subfactorial_naive(n)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 2004-2022 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out, limbs_add_to_out_aliased_2,\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::float_add::RoundBit::*;\nuse crate::natural::arithmetic::is_power_of_2::limbs_is_power_of_2;\nuse crate::natural::arithmetic::shr::{limbs_shr_to_out, limbs_slice_shr_in_place};\nuse crate::natural::{\n    LIMB_HIGH_BIT, Natural, bit_to_limb_count_ceiling, bit_to_limb_count_floor, limb_to_bit_count,\n};\nuse crate::platform::Limb;\nuse core::cmp::Ordering::{self, *};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    NegModPowerOf2, OverflowingAddAssign, Parity, PowerOf2, SaturatingAddAssign, WrappingAddAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::slice_test_zero;\n\nconst TWICE_WIDTH: u64 = Limb::WIDTH * 2;\nconst THRICE_WIDTH: u64 = Limb::WIDTH * 3;\n\npub fn add_float_significands_in_place(\n    mut x: &mut Natural,\n    x_exp: &mut i32,\n    x_prec: u64,\n    mut y: &mut Natural,\n    y_exp: i32,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Ordering, bool) {\n    if x_prec == y_prec && out_prec == x_prec {\n        add_float_significands_in_place_same_prec(x, x_exp, y, y_exp, out_prec, rm)\n    } else if *x_exp >= y_exp {\n        match (&mut x, &mut y) {\n            (Natural(Small(small_x)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_x = out[0];\n                    *x_exp = out_exp;\n                    (o, false)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Large(out));\n                    *x_exp = out_exp;\n                    (o, false)\n                }\n            }\n            (Natural(Small(small_x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        ys,\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_x = out[0];\n                    *x_exp = out_exp;\n                    (o, false)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        ys,\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Large(out));\n                    *x_exp = out_exp;\n                    (o, false)\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    (o, false)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *xs = out;\n                    *x_exp = out_exp;\n                    (o, false)\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, xs, *x_exp, ys, y_exp, out_prec, rm,\n                    );\n                    *x = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    (o, false)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, xs, *x_exp, ys, y_exp, out_prec, rm,\n                    );\n                    *xs = out;\n                    *x_exp = out_exp;\n                    (o, false)\n                }\n            }\n        }\n    } else {\n        match (&mut x, &mut y) {\n            (Natural(Small(small_x)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_y = out[0];\n                    *x_exp = out_exp;\n                    (o, true)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *y = Natural(Large(out));\n                    *x_exp = out_exp;\n                    (o, true)\n                }\n            }\n            (Natural(Small(small_x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        ys,\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *y = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    (o, true)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        ys,\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *ys = out;\n                    *x_exp = out_exp;\n                    (o, true)\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        xs,\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_y = out[0];\n                    *x_exp = out_exp;\n                    (o, true)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        xs,\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *y = Natural(Large(out));\n                    *x_exp = out_exp;\n                    (o, true)\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, ys, y_exp, xs, *x_exp, out_prec, rm,\n                    );\n                    *y = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    (o, true)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, ys, y_exp, xs, *x_exp, out_prec, rm,\n                    );\n                    *ys = out;\n                    *x_exp = out_exp;\n                    (o, true)\n                }\n            }\n        }\n    }\n}\n\npub fn add_float_significands_in_place_ref(\n    mut x: &mut Natural,\n    x_exp: &mut i32,\n    x_prec: u64,\n    y: &Natural,\n    y_exp: i32,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> Ordering {\n    if x_prec == y_prec && out_prec == x_prec {\n        add_float_significands_in_place_same_prec_ref(x, x_exp, y, y_exp, out_prec, rm)\n    } else if *x_exp >= y_exp {\n        match (&mut x, y) {\n            (Natural(Small(small_x)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_x = out[0];\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Large(out));\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n            (Natural(Small(small_x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        ys,\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_x = out[0];\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        ys,\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Large(out));\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        &[*small_y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *xs = out;\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, xs, *x_exp, ys, y_exp, out_prec, rm,\n                    );\n                    *x = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, xs, *x_exp, ys, y_exp, out_prec, rm,\n                    );\n                    *xs = out;\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n        }\n    } else {\n        match (&mut x, y) {\n            (Natural(Small(small_x)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_x = out[0];\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Large(out));\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n            (Natural(Small(small_x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        ys,\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *small_x = out[0];\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        ys,\n                        y_exp,\n                        &[*small_x],\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Large(out));\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        xs,\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *x = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*small_y],\n                        y_exp,\n                        xs,\n                        *x_exp,\n                        out_prec,\n                        rm,\n                    );\n                    *xs = out;\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, ys, y_exp, xs, *x_exp, out_prec, rm,\n                    );\n                    *x = Natural(Small(out[0]));\n                    *x_exp = out_exp;\n                    o\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, ys, y_exp, xs, *x_exp, out_prec, rm,\n                    );\n                    *xs = out;\n                    *x_exp = out_exp;\n                    o\n                }\n            }\n        }\n    }\n}\n\npub fn add_float_significands_ref_ref<'a>(\n    mut x: &'a Natural,\n    mut x_exp: i32,\n    mut x_prec: u64,\n    mut y: &'a Natural,\n    mut y_exp: i32,\n    mut y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    if x_prec == y_prec && out_prec == x_prec {\n        add_float_significands_same_prec_ref_ref(x, x_exp, y, y_exp, out_prec, rm)\n    } else {\n        if x_exp < y_exp {\n            swap(&mut x, &mut y);\n            swap(&mut x_exp, &mut y_exp);\n            swap(&mut x_prec, &mut y_prec);\n        }\n        match (x, y) {\n            (Natural(Small(x)), Natural(Small(y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        &[*y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    (Natural(Small(out[0])), out_exp, o)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        &[*y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    (Natural(Large(out)), out_exp, o)\n                }\n            }\n            (Natural(Small(x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        ys,\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    (Natural(Small(out[0])), out_exp, o)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        ys,\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    (Natural(Large(out)), out_exp, o)\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        xs,\n                        x_exp,\n                        &[*y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    (Natural(Small(out[0])), out_exp, o)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out,\n                        xs,\n                        x_exp,\n                        &[*y],\n                        y_exp,\n                        out_prec,\n                        rm,\n                    );\n                    (Natural(Large(out)), out_exp, o)\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, xs, x_exp, ys, y_exp, out_prec, rm,\n                    );\n                    (Natural(Small(out[0])), out_exp, o)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o) = add_float_significands_general(\n                        &mut out, xs, x_exp, ys, y_exp, out_prec, rm,\n                    );\n                    (Natural(Large(out)), out_exp, o)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_add1sp from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_in_place_same_prec(\n    x: &mut Natural,\n    x_exp: &mut i32,\n    y: &mut Natural,\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Ordering, bool) {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (sum, sum_exp, o) = if prec == Limb::WIDTH {\n                add_float_significands_same_prec_w(*x, *x_exp, *y, y_exp, rm)\n            } else {\n                add_float_significands_same_prec_lt_w(*x, *x_exp, *y, y_exp, prec, rm)\n            };\n            *x = sum;\n            *x_exp = sum_exp;\n            (o, false)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_mut_slice()) {\n            ([x_0, x_1], [y_0, y_1]) => {\n                let (sum_0, sum_1, sum_exp, o) = if prec == TWICE_WIDTH {\n                    add_float_significands_same_prec_2w(*x_0, *x_1, *x_exp, *y_0, *y_1, y_exp, rm)\n                } else {\n                    add_float_significands_same_prec_gt_w_lt_2w(\n                        *x_0, *x_1, *x_exp, *y_0, *y_1, y_exp, prec, rm,\n                    )\n                };\n                *x_0 = sum_0;\n                *x_1 = sum_1;\n                *x_exp = sum_exp;\n                (o, false)\n            }\n            ([x_0, x_1, x_2], [y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (sum_0, sum_1, sum_2, sum_exp, o) =\n                    add_float_significands_same_prec_gt_2w_lt_3w(\n                        *x_0, *x_1, *x_2, *x_exp, *y_0, *y_1, *y_2, y_exp, prec, rm,\n                    );\n                *x_0 = sum_0;\n                *x_1 = sum_1;\n                *x_2 = sum_2;\n                *x_exp = sum_exp;\n                (o, false)\n            }\n            (xs_slice, ys_slice) => {\n                let (sum_exp, o, swapped) = add_float_significands_same_prec_ge_3w_val_val(\n                    xs_slice, *x_exp, ys_slice, y_exp, prec, rm,\n                );\n                *x_exp = sum_exp;\n                (o, swapped)\n            }\n        },\n        _ => unreachable!(),\n    }\n}\n\n// This is mpfr_add1sp from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_in_place_same_prec_ref(\n    x: &mut Natural,\n    x_exp: &mut i32,\n    y: &Natural,\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> Ordering {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (sum, sum_exp, o) = if prec == Limb::WIDTH {\n                add_float_significands_same_prec_w(*x, *x_exp, *y, y_exp, rm)\n            } else {\n                add_float_significands_same_prec_lt_w(*x, *x_exp, *y, y_exp, prec, rm)\n            };\n            *x = sum;\n            *x_exp = sum_exp;\n            o\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_slice()) {\n            ([x_0, x_1], &[y_0, y_1]) => {\n                let (sum_0, sum_1, sum_exp, o) = if prec == TWICE_WIDTH {\n                    add_float_significands_same_prec_2w(*x_0, *x_1, *x_exp, y_0, y_1, y_exp, rm)\n                } else {\n                    add_float_significands_same_prec_gt_w_lt_2w(\n                        *x_0, *x_1, *x_exp, y_0, y_1, y_exp, prec, rm,\n                    )\n                };\n                *x_0 = sum_0;\n                *x_1 = sum_1;\n                *x_exp = sum_exp;\n                o\n            }\n            ([x_0, x_1, x_2], &[y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (sum_0, sum_1, sum_2, sum_exp, o) =\n                    add_float_significands_same_prec_gt_2w_lt_3w(\n                        *x_0, *x_1, *x_2, *x_exp, y_0, y_1, y_2, y_exp, prec, rm,\n                    );\n                *x_0 = sum_0;\n                *x_1 = sum_1;\n                *x_2 = sum_2;\n                *x_exp = sum_exp;\n                o\n            }\n            (xs, ys) => {\n                if *x_exp >= y_exp {\n                    let (sum_exp, o) = add_float_significands_same_prec_ge_3w_val_ref(\n                        xs, *x_exp, ys, y_exp, prec, rm,\n                    );\n                    *x_exp = sum_exp;\n                    o\n                } else {\n                    let (sum_exp, o) = add_float_significands_same_prec_ge_3w_ref_val(\n                        ys, y_exp, xs, *x_exp, prec, rm,\n                    );\n                    *x_exp = sum_exp;\n                    o\n                }\n            }\n        },\n        _ => unreachable!(),\n    }\n}\n\n// This is mpfr_add1sp from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_same_prec_ref_ref(\n    x: &Natural,\n    x_exp: i32,\n    y: &Natural,\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (sum, sum_exp, o) = if prec == Limb::WIDTH {\n                add_float_significands_same_prec_w(*x, x_exp, *y, y_exp, rm)\n            } else {\n                add_float_significands_same_prec_lt_w(*x, x_exp, *y, y_exp, prec, rm)\n            };\n            (Natural(Small(sum)), sum_exp, o)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_slice(), ys.as_slice()) {\n            (&[x_0, x_1], &[y_0, y_1]) => {\n                let (sum_0, sum_1, sum_exp, o) = if prec == TWICE_WIDTH {\n                    add_float_significands_same_prec_2w(x_0, x_1, x_exp, y_0, y_1, y_exp, rm)\n                } else {\n                    add_float_significands_same_prec_gt_w_lt_2w(\n                        x_0, x_1, x_exp, y_0, y_1, y_exp, prec, rm,\n                    )\n                };\n                (Natural(Large(vec![sum_0, sum_1])), sum_exp, o)\n            }\n            (&[x_0, x_1, x_2], &[y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (sum_0, sum_1, sum_2, sum_exp, o) =\n                    add_float_significands_same_prec_gt_2w_lt_3w(\n                        x_0, x_1, x_2, x_exp, y_0, y_1, y_2, y_exp, prec, rm,\n                    );\n                (Natural(Large(vec![sum_0, sum_1, sum_2])), sum_exp, o)\n            }\n            (xs, ys) => {\n                let mut out = vec![0; xs.len()];\n                let (sum_exp, o) = add_float_significands_same_prec_ge_3w_ref_ref(\n                    &mut out, xs, x_exp, ys, y_exp, prec, rm,\n                );\n                (Natural(Large(out)), sum_exp, o)\n            }\n        },\n        _ => unreachable!(),\n    }\n}\n\nconst WIDTH_M1: u64 = Limb::WIDTH - 1;\n\n// This is mpfr_add1sp1 from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_same_prec_lt_w(\n    mut x: Limb,\n    mut x_exp: i32,\n    mut y: Limb,\n    mut y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, i32, Ordering) {\n    assert!(prec < Limb::WIDTH);\n    let shift = Limb::WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let (mut sum, sticky_bit, round_bit) = if x_exp == y_exp {\n        // The following line is probably better than\n        // ```\n        // sum = LIMB_HIGH_BIT | ((x + y) >> 1);\n        // ```\n        // as it has less dependency and doesn't need a long constant on some processors. On ARM, it\n        // can also probably benefit from shift-and-op in a better way. Timings cannot be\n        // conclusive.\n        let sum = (x >> 1) + (y >> 1);\n        x_exp.saturating_add_assign(1);\n        let round_bit = sum & (shift_bit >> 1);\n        // since x + y fits on prec + 1 bits, the sticky bit is zero\n        (sum ^ round_bit, 0, round_bit)\n    } else {\n        if x_exp < y_exp {\n            swap(&mut x_exp, &mut y_exp);\n            swap(&mut x, &mut y);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        let mask = shift_bit - 1;\n        if exp_diff < shift {\n            // we can shift y by exp_diff bits to the right without losing any bit. Moreover, we can\n            // shift one more if there is an exponent increase.\n            let (mut sum, overflow) = x.overflowing_add(y >> exp_diff);\n            if overflow {\n                // carry\n                assert!(sum.even());\n                sum = LIMB_HIGH_BIT | (sum >> 1);\n                x_exp.saturating_add_assign(1);\n            }\n            let round_bit = sum & (shift_bit >> 1);\n            (sum & !mask, (sum & mask) ^ round_bit, round_bit)\n        } else if exp_diff < Limb::WIDTH {\n            // shift <= exp_diff < Limb::WIDTH\n            let mut sticky_bit = y << (Limb::WIDTH - exp_diff); // bits from y[-1] after shift\n            let (mut sum, overflow) = x.overflowing_add(y >> exp_diff);\n            if overflow {\n                // carry\n                sticky_bit |= sum & 1;\n                sum = LIMB_HIGH_BIT | (sum >> 1);\n                x_exp.saturating_add_assign(1);\n            }\n            let round_bit = sum & (shift_bit >> 1);\n            (\n                sum & !mask,\n                sticky_bit | ((sum & mask) ^ round_bit),\n                round_bit,\n            )\n        } else {\n            // - exp_diff >= Limb::WIDTH\n            // - round_bit == 0 since prec < Limb::WIDTH\n            // - sticky_bit == 1 since y != 0\n            (x, 1, 0)\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (sum, x_exp, Equal)\n    } else {\n        match rm {\n            Exact => panic!(\"Inexact float addition\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (sum & shift_bit) == 0) {\n                    (sum, x_exp, Less)\n                } else if sum.overflowing_add_assign(shift_bit) {\n                    (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum, x_exp, Greater)\n                }\n            }\n            Floor | Down => (sum, x_exp, Less),\n            Ceiling | Up => {\n                if sum.overflowing_add_assign(shift_bit) {\n                    (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum, x_exp, Greater)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_add1sp1n from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_same_prec_w(\n    mut x: Limb,\n    mut x_exp: i32,\n    mut y: Limb,\n    mut y_exp: i32,\n    rm: RoundingMode,\n) -> (Limb, i32, Ordering) {\n    let (mut sum, sticky_bit, round_bit) = if x_exp == y_exp {\n        let sum = x.wrapping_add(y);\n        x_exp.saturating_add_assign(1);\n        // since x + y fits on Limb::WIDTH + 1 bits, the sticky bit is zero\n        (LIMB_HIGH_BIT | (sum >> 1), 0, sum & 1)\n    } else {\n        if x_exp < y_exp {\n            swap(&mut x, &mut y);\n            swap(&mut x_exp, &mut y_exp);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        if exp_diff < Limb::WIDTH {\n            // - 1 <= exp_diff < Limb::WIDTH\n            // - bits from y[-1] after shift\n            let sticky_bit = y << (Limb::WIDTH - exp_diff);\n            let (sum, overflow) = x.overflowing_add(y >> exp_diff);\n            if overflow {\n                // carry\n                x_exp.saturating_add_assign(1);\n                (LIMB_HIGH_BIT | (sum >> 1), sticky_bit, sum & 1)\n            } else {\n                // no carry\n                (sum, sticky_bit & !LIMB_HIGH_BIT, sticky_bit & LIMB_HIGH_BIT)\n            }\n        } else {\n            let round = exp_diff == Limb::WIDTH;\n            // exp_diff >= Limb::WIDTH\n            (\n                x,\n                Limb::from(!round || y != LIMB_HIGH_BIT),\n                Limb::from(round),\n            )\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (sum, x_exp, Equal)\n    } else {\n        match rm {\n            Exact => panic!(\"Inexact float addition\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (sum & 1) == 0) {\n                    (sum, x_exp, Less)\n                } else if sum.overflowing_add_assign(1) {\n                    (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum, x_exp, Greater)\n                }\n            }\n            Floor | Down => (sum, x_exp, Less),\n            Ceiling | Up => {\n                if sum.overflowing_add_assign(1) {\n                    (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum, x_exp, Greater)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_add1sp2 from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_same_prec_gt_w_lt_2w(\n    mut x_0: Limb,\n    mut x_1: Limb,\n    mut x_exp: i32,\n    mut y_0: Limb,\n    mut y_1: Limb,\n    mut y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, i32, Ordering) {\n    let shift = TWICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_m1_bit = shift_bit >> 1;\n    let (mut sum_0, mut sum_1, round_bit, sticky_bit) = if x_exp == y_exp {\n        // since x_1, y_1 >= LIMB_HIGH_BIT, a carry always occurs\n        let (mut a0, overflow) = x_0.overflowing_add(y_0);\n        let mut a1 = x_1.wrapping_add(y_1);\n        if overflow {\n            a1.wrapping_add_assign(1);\n        }\n        a0 = (a0 >> 1) | (a1 << WIDTH_M1);\n        x_exp.saturating_add_assign(1);\n        let round_bit = a0 & shift_m1_bit;\n        // Since x + y fits on prec + 1 bits, the sticky bit is zero.\n        (\n            a0 ^ round_bit,\n            LIMB_HIGH_BIT | (a1 >> 1),\n            a0 & shift_m1_bit,\n            0,\n        )\n    } else {\n        if x_exp < y_exp {\n            swap(&mut x_0, &mut y_0);\n            swap(&mut x_1, &mut y_1);\n            swap(&mut x_exp, &mut y_exp);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        let mask = shift_bit - 1;\n        if exp_diff < Limb::WIDTH {\n            let comp_diff = Limb::WIDTH - exp_diff;\n            // 0 < exp_diff < Limb::WIDTH\n            let mut sticky_bit = y_0 << comp_diff; // bits from y[-1] after shift\n            let (mut a0, overflow_1) = x_0.overflowing_add((y_1 << comp_diff) | (y_0 >> exp_diff));\n            let (mut a1, mut overflow_2) = x_1.overflowing_add(y_1 >> exp_diff);\n            if overflow_1 {\n                overflow_2 |= a1.overflowing_add_assign(1);\n            }\n            let sum_1 = if overflow_2 {\n                // carry in high word\n                sticky_bit |= a0 & 1;\n                // shift a by 1\n                a0 = (a1 << WIDTH_M1) | (a0 >> 1);\n                x_exp.saturating_add_assign(1);\n                LIMB_HIGH_BIT | (a1 >> 1)\n            } else {\n                a1\n            };\n            let round_bit = a0 & shift_m1_bit;\n            (\n                a0 & !mask,\n                sum_1,\n                round_bit,\n                sticky_bit | (a0 & mask) ^ round_bit,\n            )\n        } else if exp_diff < TWICE_WIDTH {\n            // Limb::WIDTH <= exp_diff < Limb::WIDTH * 2\n            let mut sticky_bit = if exp_diff == Limb::WIDTH {\n                y_0\n            } else {\n                y_0 | (y_1 << (TWICE_WIDTH - exp_diff))\n            };\n            let (mut a0, overflow_1) = x_0.overflowing_add(y_1 >> (exp_diff - Limb::WIDTH));\n            let (a1, overflow_2) = if overflow_1 {\n                x_1.overflowing_add(1)\n            } else {\n                (x_1, false)\n            };\n            if overflow_2 {\n                sticky_bit |= a0 & 1;\n                // shift a by 1\n                a0 = (a1 << WIDTH_M1) | (a0 >> 1);\n                x_exp.saturating_add_assign(1);\n                let round_bit = a0 & shift_m1_bit;\n                (\n                    a0 & !mask,\n                    LIMB_HIGH_BIT | (a1 >> 1),\n                    a0 & shift_m1_bit,\n                    sticky_bit | (a0 & mask) ^ round_bit,\n                )\n            } else {\n                let round_bit = a0 & shift_m1_bit;\n                (\n                    a0 & !mask,\n                    a1,\n                    round_bit,\n                    sticky_bit | (a0 & mask) ^ round_bit,\n                )\n            }\n        } else {\n            // - exp_diff >= TWICE_WIDTH\n            // - round_bit == 0 since prec < TWICE_WIDTH\n            // - sticky_bit == since y != 0\n            (x_0, x_1, 0, 1)\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (sum_0, sum_1, x_exp, Equal)\n    } else {\n        match rm {\n            Exact => panic!(\"Inexact float addition\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (sum_0 & shift_bit) == 0) {\n                    (sum_0, sum_1, x_exp, Less)\n                } else if sum_0.overflowing_add_assign(shift_bit) && sum_1.overflowing_add_assign(1)\n                {\n                    (sum_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum_0, sum_1, x_exp, Greater)\n                }\n            }\n            Floor | Down => (sum_0, sum_1, x_exp, Less),\n            Ceiling | Up => {\n                if sum_0.overflowing_add_assign(shift_bit) && sum_1.overflowing_add_assign(1) {\n                    (sum_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum_0, sum_1, x_exp, Greater)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_add1sp2n from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_same_prec_2w(\n    mut x_0: Limb,\n    mut x_1: Limb,\n    mut x_exp: i32,\n    mut y_0: Limb,\n    mut y_1: Limb,\n    mut y_exp: i32,\n    rm: RoundingMode,\n) -> (Limb, Limb, i32, Ordering) {\n    let (mut sum_0, mut sum_1, round_bit, sticky_bit) = if x_exp == y_exp {\n        // Since x_1, y_1 >= LIMB_HIGH_BIT, a carry always occurs.\n        let (a0, overflow) = x_0.overflowing_add(y_0);\n        let mut a1 = x_1.wrapping_add(y_1);\n        if overflow {\n            a1.wrapping_add_assign(1);\n        }\n        x_exp.saturating_add_assign(1);\n        // Since x + y fits on prec + 1 bits, the sticky bit is zero.\n        (\n            (a1 << WIDTH_M1) | (a0 >> 1),\n            LIMB_HIGH_BIT | (a1 >> 1),\n            a0 & 1,\n            0,\n        )\n    } else {\n        if x_exp < y_exp {\n            swap(&mut x_0, &mut y_0);\n            swap(&mut x_1, &mut y_1);\n            swap(&mut x_exp, &mut y_exp);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        if exp_diff >= TWICE_WIDTH {\n            if exp_diff == TWICE_WIDTH {\n                (x_0, x_1, 1, Limb::from(y_0 != 0 || y_1 > LIMB_HIGH_BIT))\n            } else {\n                (x_0, x_1, 0, 1)\n            }\n        } else {\n            // First, compute (a0, a1) = x + (y >> exp_diff), and determine the sticky bit from the\n            // bits shifted out such that (MSB, other bits) is regarded as (rounding bit, sticky\n            // bit), assuming no carry.\n            let (sum_0, sum_1, sticky_bit) = if exp_diff < Limb::WIDTH {\n                // 0 < exp_diff < Limb::WIDTH\n                let comp_diff = Limb::WIDTH - exp_diff;\n                let (sum_0, overflow) = x_0.overflowing_add((y_1 << comp_diff) | (y_0 >> exp_diff));\n                let mut sum_1 = x_1.wrapping_add(y_1 >> exp_diff);\n                if overflow {\n                    sum_1.wrapping_add_assign(1);\n                }\n                (sum_0, sum_1, y_0 << comp_diff)\n            } else {\n                // Limb::WIDTH <= exp_diff < Limb::WIDTH * 2 The most significant bit of sb should\n                // be the rounding bit, while the other bits represent the sticky bit:\n                // * If exp_diff = Limb::WIDTH, we get y_0;\n                // * If exp_diff > Limb::WIDTH: we get the least exp_diff - Limb::WIDTH bits of y_1,\n                //   and those from y_0 as the LSB of sticky_bit.\n                let sticky_bit = if exp_diff == Limb::WIDTH {\n                    y_0\n                } else {\n                    (y_1 << (TWICE_WIDTH - exp_diff)) | Limb::from(y_0 != 0)\n                };\n                let (sum_0, overflow) = x_0.overflowing_add(y_1 >> (exp_diff - Limb::WIDTH));\n                (\n                    sum_0,\n                    if overflow { x_1.wrapping_add(1) } else { x_1 },\n                    sticky_bit,\n                )\n            };\n            if sum_1 < x_1 {\n                // carry in high word\n                let round_bit = sum_0 << WIDTH_M1;\n                // Shift the result by 1 to the right.\n                x_exp.saturating_add_assign(1);\n                (\n                    (sum_1 << WIDTH_M1) | (sum_0 >> 1),\n                    LIMB_HIGH_BIT | (sum_1 >> 1),\n                    round_bit,\n                    sticky_bit,\n                )\n            } else {\n                (sum_0, sum_1, sticky_bit & LIMB_HIGH_BIT, sticky_bit << 1)\n            }\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (sum_0, sum_1, x_exp, Equal)\n    } else {\n        match rm {\n            Exact => panic!(\"Inexact float addition\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (sum_0 & 1) == 0) {\n                    (sum_0, sum_1, x_exp, Less)\n                } else if sum_0.overflowing_add_assign(1) && sum_1.overflowing_add_assign(1) {\n                    (sum_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum_0, sum_1, x_exp, Greater)\n                }\n            }\n            Floor | Down => (sum_0, sum_1, x_exp, Less),\n            Ceiling | Up => {\n                if sum_0.overflowing_add_assign(1) && sum_1.overflowing_add_assign(1) {\n                    (sum_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater)\n                } else {\n                    (sum_0, sum_1, x_exp, Greater)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_add1sp3 from add1sp.c, MPFR 4.2.0.\nfn add_float_significands_same_prec_gt_2w_lt_3w(\n    mut x_0: Limb,\n    mut x_1: Limb,\n    mut x_2: Limb,\n    mut x_exp: i32,\n    mut y_0: Limb,\n    mut y_1: Limb,\n    mut y_2: Limb,\n    mut y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, Limb, i32, Ordering) {\n    let shift = THRICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_m1_bit = shift_bit >> 1;\n    let (mut sum_0, mut sum_1, mut sum_2, round_bit, sticky_bit) = if x_exp == y_exp {\n        // Since x_2, y_2 >= LIMB_HIGH_BIT, a carry always occurs\n        let (mut a0, overflow_1) = x_0.overflowing_add(y_0);\n        let (mut a1, mut overflow_2) = x_1.overflowing_add(y_1);\n        if overflow_1 {\n            overflow_2 |= a1.overflowing_add_assign(1);\n        }\n        let mut a2 = x_2.wrapping_add(y_2);\n        if overflow_2 || (a1 == x_1 && overflow_1) {\n            a2.wrapping_add_assign(1);\n        }\n        // Since prec < 3 * Limb::WIDTH, we lose no bit in a0 >> 1.\n        a0 = (a1 << WIDTH_M1) | (a0 >> 1);\n        x_exp.saturating_add_assign(1);\n        let round_bit = a0 & shift_m1_bit;\n        // Since x + y fits on prec + 1 bits, the sticky bit is zero.\n        (\n            a0 ^ round_bit,\n            (a2 << WIDTH_M1) | (a1 >> 1),\n            LIMB_HIGH_BIT | (a2 >> 1),\n            round_bit,\n            0,\n        )\n    } else {\n        if x_exp < y_exp {\n            swap(&mut x_0, &mut y_0);\n            swap(&mut x_1, &mut y_1);\n            swap(&mut x_2, &mut y_2);\n            swap(&mut x_exp, &mut y_exp);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        let mask = shift_bit - 1;\n        if exp_diff < Limb::WIDTH {\n            // 0 < exp_diff < Limb::WIDTH\n            let comp_diff = Limb::WIDTH - exp_diff;\n            let mut sticky_bit = y_0 << comp_diff; // bits from y[-1] after shift\n            let (mut a0, overflow_1) = x_0.overflowing_add((y_1 << comp_diff) | (y_0 >> exp_diff));\n            let (mut a1, mut overflow_2) =\n                x_1.overflowing_add((y_2 << comp_diff) | (y_1 >> exp_diff));\n            if overflow_1 {\n                overflow_2 |= a1.overflowing_add_assign(1);\n            }\n            let (mut a2, mut overflow_3) = x_2.overflowing_add(y_2 >> exp_diff);\n            if overflow_2 {\n                overflow_3 |= a2.overflowing_add_assign(1);\n            }\n            let (sum_1, sum_2) = if overflow_3 || (a2 == x_2 && overflow_2) {\n                sticky_bit |= a0 & 1;\n                // shift a by 1\n                a0 = (a1 << WIDTH_M1) | (a0 >> 1);\n                x_exp.saturating_add_assign(1);\n                ((a2 << WIDTH_M1) | (a1 >> 1), LIMB_HIGH_BIT | (a2 >> 1))\n            } else {\n                (a1, a2)\n            };\n            let round_bit = a0 & shift_m1_bit;\n            sticky_bit |= (a0 & mask) ^ round_bit;\n            (a0 & !mask, sum_1, sum_2, round_bit, sticky_bit)\n        } else if exp_diff < TWICE_WIDTH {\n            // Limb::WIDTH <= exp_diff < Limb::WIDTH * 2\n            let comp_diff = exp_diff - Limb::WIDTH;\n            let comp_diff_2 = TWICE_WIDTH - exp_diff;\n            let mut sticky_bit = if exp_diff == Limb::WIDTH {\n                y_0\n            } else {\n                (y_1 << comp_diff_2) | y_0\n            };\n            let y0shifted = if exp_diff == Limb::WIDTH {\n                y_1\n            } else {\n                (y_2 << comp_diff_2) | (y_1 >> comp_diff)\n            };\n            let (mut a0, overflow_1) = x_0.overflowing_add(y0shifted);\n            let (mut a1, mut overflow_2) = x_1.overflowing_add(y_2 >> comp_diff);\n            if overflow_1 {\n                overflow_2 |= a1.overflowing_add_assign(1);\n            }\n            // If a1 < x_1, there was a carry in the above addition, or when a1 = x_1 and one of the\n            // added terms is nonzero (the sum of b_2 >> (exp_diff - Limb::WIDTH) and a0 < x_0 is at\n            // most 2 ^ Limb::WIDTH - exp_diff)\n            let (a2, overflow_3) = if overflow_2 || (a1 == x_1 && overflow_1) {\n                x_2.overflowing_add(1)\n            } else {\n                (x_2, false)\n            };\n            if overflow_3 {\n                sticky_bit |= a0 & 1;\n                // shift a by 1\n                a0 = (a1 << WIDTH_M1) | (a0 >> 1);\n                x_exp.saturating_add_assign(1);\n                let round_bit = a0 & shift_m1_bit;\n                sticky_bit |= (a0 & mask) ^ round_bit;\n                (\n                    a0 & !mask,\n                    (a2 << WIDTH_M1) | (a1 >> 1),\n                    LIMB_HIGH_BIT | (a2 >> 1),\n                    round_bit,\n                    sticky_bit,\n                )\n            } else {\n                let round_bit = a0 & shift_m1_bit;\n                sticky_bit |= (a0 & mask) ^ round_bit;\n                (a0 & !mask, a1, a2, round_bit, sticky_bit)\n            }\n        } else if exp_diff < THRICE_WIDTH {\n            // Limb::WIDTH * 2 <= exp_diff < Limb::WIDTH * 3\n            let mut sticky_bit = if exp_diff == TWICE_WIDTH {\n                y_1 | y_0\n            } else {\n                (y_2 << (THRICE_WIDTH - exp_diff)) | y_1 | y_0\n            };\n            let (mut a0, overflow_1) = x_0.overflowing_add(y_2 >> (exp_diff - TWICE_WIDTH));\n            let (a1, overflow_2) = if overflow_1 {\n                x_1.overflowing_add(1)\n            } else {\n                (x_1, false)\n            };\n            let a2 = if overflow_2 { x_2.wrapping_add(1) } else { x_2 };\n            if a2 == 0 {\n                sticky_bit |= a0 & 1;\n                // shift a by 1\n                a0 = (a1 << WIDTH_M1) | (a0 >> 1);\n                x_exp.saturating_add_assign(1);\n                let round_bit = a0 & shift_m1_bit;\n                sticky_bit |= (a0 & mask) ^ round_bit;\n                (\n                    a0 & !mask,\n                    (a2 << WIDTH_M1) | (a1 >> 1),\n                    LIMB_HIGH_BIT | (a2 >> 1),\n                    round_bit,\n                    sticky_bit,\n                )\n            } else {\n                let round_bit = a0 & shift_m1_bit;\n                sticky_bit |= (a0 & mask) ^ round_bit;\n                (a0 & !mask, a1, a2, round_bit, sticky_bit)\n            }\n        } else {\n            // - exp_diff >= Limb::WIDTH * 2\n            // - round_bit == 0 since prec < Limb::WIDTH * 3\n            // - sticky_bit == 1 since c != 0\n            (x_0, x_1, x_2, 0, 1)\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (sum_0, sum_1, sum_2, x_exp, Equal)\n    } else {\n        match rm {\n            Exact => panic!(\"Inexact float addition\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (sum_0 & shift_bit) == 0) {\n                    (sum_0, sum_1, sum_2, x_exp, Less)\n                } else {\n                    if sum_0.overflowing_add_assign(shift_bit) {\n                        sum_1.wrapping_add_assign(1);\n                    }\n                    if sum_1 == 0 && sum_0 == 0 {\n                        sum_2.wrapping_add_assign(1);\n                    }\n                    if sum_2 == 0 {\n                        (\n                            sum_0,\n                            sum_1,\n                            LIMB_HIGH_BIT,\n                            x_exp.saturating_add(1),\n                            Greater,\n                        )\n                    } else {\n                        (sum_0, sum_1, sum_2, x_exp, Greater)\n                    }\n                }\n            }\n            Floor | Down => (sum_0, sum_1, sum_2, x_exp, Less),\n            Ceiling | Up => {\n                if sum_0.overflowing_add_assign(shift_bit) {\n                    sum_1.wrapping_add_assign(1);\n                }\n                if sum_1 == 0 && sum_0 == 0 {\n                    sum_2.wrapping_add_assign(1);\n                }\n                if sum_2 == 0 {\n                    (\n                        sum_0,\n                        sum_1,\n                        LIMB_HIGH_BIT,\n                        x_exp.saturating_add(1),\n                        Greater,\n                    )\n                } else {\n                    (sum_0, sum_1, sum_2, x_exp, Greater)\n                }\n            }\n        }\n    }\n}\n\n// out <- x + y >> r where d = q * Limb::WIDTH + r. Return the carry at out[n + 1] (0 or 1) and\n// return low so that:\n// * the most significant bit of low would be that of out[-1] if we would compute one more limb of\n//   the (infinite) addition\n// * the Limb::WIDTH - 1 least significant bits of low are zero iff all bits of out[-1], out[-2],\n//   ... would be zero (except the most significant bit of out[-1]).\n//\n// Assume 0 < exp_diff < Limb::WIDTH * n.\n//\n// This is mpfr_addrsh from add1sp.c, MPFR 4.2.0, returning `low` before `carry`, where ap != bp and\n// ap != cp.\nfn add_significands_rsh_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    exp_diff: u64,\n) -> (Limb, bool) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    let out = &mut out[..n];\n    if exp_diff < Limb::WIDTH {\n        // out <- x + y >> d\n        assert_ne!(exp_diff, 0);\n        let comp_diff = Limb::WIDTH - exp_diff;\n        // Thus 0 < Limb::WIDTH - exp_diff < Limb::WIDTH\n        let low = ys[0] << comp_diff;\n        let mut carry = false;\n        let (out_last, out_init) = out.split_last_mut().unwrap();\n        let (xs_last, xs_init) = xs.split_last().unwrap();\n        for (i, (o, &x)) in out_init.iter_mut().zip(xs_init.iter()).enumerate() {\n            let mut carry_2;\n            (*o, carry_2) = x.overflowing_add((ys[i + 1] << comp_diff) | (ys[i] >> exp_diff));\n            if carry {\n                carry_2 |= o.overflowing_add_assign(1);\n            }\n            carry = carry_2;\n        }\n        // most significant limb is special\n        let mut carry_2;\n        (*out_last, carry_2) = xs_last.overflowing_add(ys[n - 1] >> exp_diff);\n        if carry {\n            carry_2 |= out_last.overflowing_add_assign(1);\n        }\n        (low, carry_2)\n    } else {\n        // exp_diff >= Limb::WIDTH\n        let q = bit_to_limb_count_floor(exp_diff);\n        let r = exp_diff & Limb::WIDTH_MASK;\n        if r == 0 {\n            assert_ne!(q, 0);\n            let (ys_lo, ys_hi) = ys.split_at(q);\n            let (ys_mid, ys_lo) = ys_lo.split_last().unwrap();\n            let mut low = *ys_mid;\n            if !slice_test_zero(ys_lo) {\n                low |= 1;\n            }\n            let nmq = n - q;\n            let (out_lo, out_hi) = out.split_at_mut(nmq);\n            let (xs_lo, xs_hi) = xs.split_at(nmq);\n            let carry = if limbs_add_same_length_to_out(out_lo, xs_lo, ys_hi) {\n                limbs_add_limb_to_out(out_hi, xs_hi, 1)\n            } else {\n                out_hi.copy_from_slice(xs_hi);\n                false\n            };\n            (low, carry)\n        } else {\n            // 0 < r < Limb::WIDTH\n            let comp_diff = Limb::WIDTH - r;\n            let (ys_lo, ys_hi) = ys.split_at(q);\n            let mut low = ys_hi[0] << comp_diff;\n            if !slice_test_zero(ys_lo) {\n                low |= 1;\n            }\n            let nmq = n - q;\n            let (out_lo, out_hi) = out.split_at_mut(nmq);\n            let (out_lo_last, out_lo_init) = out_lo.split_last_mut().unwrap();\n            let (xs_lo, xs_hi) = xs.split_at(nmq);\n            let (xs_lo_last, xs_lo_init) = xs_lo.split_last().unwrap();\n            let mut carry = false;\n            for (i, (o, &x)) in out_lo_init.iter_mut().zip(xs_lo_init).enumerate() {\n                let mut carry_2;\n                (*o, carry_2) = x.overflowing_add((ys_hi[i + 1] << comp_diff) | (ys_hi[i] >> r));\n                if carry {\n                    carry_2 |= o.overflowing_add_assign(1);\n                }\n                carry = carry_2;\n            }\n            // most significant limb of y is special\n            let mut carry_2;\n            (*out_lo_last, carry_2) = xs_lo_last.overflowing_add(ys[n - 1] >> r);\n            if carry {\n                carry_2 |= out_lo_last.overflowing_add_assign(1);\n            }\n            // upper limbs are copied\n            let carry = if carry_2 {\n                limbs_add_limb_to_out(out_hi, xs_hi, 1)\n            } else {\n                out_hi.copy_from_slice(xs_hi);\n                false\n            };\n            (low, carry)\n        }\n    }\n}\n\n// x <- x + y >> r where d = q * Limb::WIDTH + r. Return the carry at x[n + 1] (0 or 1) and return\n// low so that:\n// * the most significant bit of low would be that of x[-1] if we would compute one more limb of the\n//   (infinite) addition\n// * the Limb::WIDTH - 1 least significant bits of low are zero iff all bits of x[-1], x[-2], ...\n//   would be zero (except the most significant bit of x[-1]).\n//\n// Assume 0 < exp_diff < Limb::WIDTH * n.\n//\n// This is mpfr_addrsh from add1sp.c, MPFR 4.2.0, returning `low` before `carry`, where ap == bp.\nfn add_significands_rsh_mut_ref(xs: &mut [Limb], ys: &[Limb], exp_diff: u64) -> (Limb, bool) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    if exp_diff < Limb::WIDTH {\n        // x <- x + y >> d\n        assert_ne!(exp_diff, 0);\n        let comp_diff = Limb::WIDTH - exp_diff;\n        // Thus 0 < Limb::WIDTH - exp_diff < Limb::WIDTH\n        let low = ys[0] << comp_diff;\n        let mut carry = false;\n        let (xs_last, xs_init) = xs.split_last_mut().unwrap();\n        for (i, x) in xs_init.iter_mut().enumerate() {\n            let mut carry_2;\n            (*x, carry_2) = x.overflowing_add((ys[i + 1] << comp_diff) | (ys[i] >> exp_diff));\n            if carry {\n                carry_2 |= x.overflowing_add_assign(1);\n            }\n            carry = carry_2;\n        }\n        // most significant limb is special\n        let mut carry_2 = xs_last.overflowing_add_assign(ys[n - 1] >> exp_diff);\n        if carry {\n            carry_2 |= xs_last.overflowing_add_assign(1);\n        }\n        (low, carry_2)\n    } else {\n        // exp_diff >= Limb::WIDTH\n        let q = bit_to_limb_count_floor(exp_diff);\n        let r = exp_diff & Limb::WIDTH_MASK;\n        if r == 0 {\n            assert_ne!(q, 0);\n            let (ys_lo, ys_hi) = ys.split_at(q);\n            let (ys_mid, ys_lo) = ys_lo.split_last().unwrap();\n            let mut low = *ys_mid;\n            if !slice_test_zero(ys_lo) {\n                low |= 1;\n            }\n            let (xs_lo, xs_hi) = xs.split_at_mut(n - q);\n            let carry = limbs_slice_add_same_length_in_place_left(xs_lo, ys_hi)\n                && limbs_slice_add_limb_in_place(xs_hi, 1);\n            (low, carry)\n        } else {\n            // 0 < r < Limb::WIDTH\n            let comp_diff = Limb::WIDTH - r;\n            let (ys_lo, ys_hi) = ys.split_at(q);\n            let mut low = ys_hi[0] << comp_diff;\n            if !slice_test_zero(ys_lo) {\n                low |= 1;\n            }\n            let (xs_lo, xs_hi) = xs.split_at_mut(n - q);\n            let (xs_lo_last, xs_lo_init) = xs_lo.split_last_mut().unwrap();\n            let mut carry = false;\n            for (i, x) in xs_lo_init.iter_mut().enumerate() {\n                let mut carry_2;\n                (*x, carry_2) = x.overflowing_add((ys_hi[i + 1] << comp_diff) | (ys_hi[i] >> r));\n                if carry {\n                    carry_2 |= x.overflowing_add_assign(1);\n                }\n                carry = carry_2;\n            }\n            // most significant limb of y is special\n            let mut carry_2 = xs_lo_last.overflowing_add_assign(ys[n - 1] >> r);\n            if carry {\n                carry_2 |= xs_lo_last.overflowing_add_assign(1);\n            }\n            // upper limbs are copied\n            let carry = if carry_2 {\n                limbs_slice_add_limb_in_place(xs_hi, 1)\n            } else {\n                false\n            };\n            (low, carry)\n        }\n    }\n}\n\n// y <- x + y >> r where d = q * Limb::WIDTH + r. Return the carry at y[n + 1] (0 or 1) and return\n// low so that:\n// * the most significant bit of low would be that of y[-1] if we would compute one more limb of the\n//   (infinite) addition\n// * the Limb::WIDTH - 1 least significant bits of low are zero iff all bits of y[-1], y[-2], ...\n//   would be zero (except the most significant bit of y[-1]).\n//\n// Assume 0 < exp_diff < Limb::WIDTH * n.\n//\n// This is mpfr_addrsh from add1sp.c, MPFR 4.2.0, returning `low` before `carry`, where ap == cp.\nfn add_significands_rsh_ref_mut(xs: &[Limb], ys: &mut [Limb], exp_diff: u64) -> (Limb, bool) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    if exp_diff < Limb::WIDTH {\n        // y <- x + y >> d\n        assert_ne!(exp_diff, 0);\n        let comp_diff = Limb::WIDTH - exp_diff;\n        // Thus 0 < Limb::WIDTH - exp_diff < Limb::WIDTH\n        let low = ys[0] << comp_diff;\n        let mut carry = false;\n        let (xs_last, xs_init) = xs.split_last().unwrap();\n        for (i, x) in xs_init.iter().enumerate() {\n            let mut carry_2;\n            (ys[i], carry_2) = x.overflowing_add((ys[i + 1] << comp_diff) | (ys[i] >> exp_diff));\n            if carry {\n                carry_2 |= ys[i].overflowing_add_assign(1);\n            }\n            carry = carry_2;\n        }\n        // most significant limb is special\n        let ys_last = ys.last_mut().unwrap();\n        let mut carry_2;\n        (*ys_last, carry_2) = xs_last.overflowing_add(*ys_last >> exp_diff);\n        if carry {\n            carry_2 |= ys_last.overflowing_add_assign(1);\n        }\n        (low, carry_2)\n    } else {\n        // exp_diff >= Limb::WIDTH\n        let q = bit_to_limb_count_floor(exp_diff);\n        let r = exp_diff & Limb::WIDTH_MASK;\n        let nmq = n - q;\n        if r == 0 {\n            assert_ne!(q, 0);\n            let (ys_mid, ys_lo) = ys[..q].split_last_mut().unwrap();\n            let mut low = *ys_mid;\n            if !slice_test_zero(ys_lo) {\n                low |= 1;\n            }\n            let (xs_lo, xs_hi) = xs.split_at(nmq);\n            let carry = if limbs_add_to_out_aliased_2(ys, q, xs_lo) {\n                limbs_add_limb_to_out(&mut ys[nmq..], xs_hi, 1)\n            } else {\n                ys[nmq..].copy_from_slice(xs_hi);\n                false\n            };\n            (low, carry)\n        } else {\n            // 0 < r < Limb::WIDTH\n            let comp_diff = Limb::WIDTH - r;\n            let last_ys = ys[n - 1];\n            let (ys_lo, ys_hi) = ys.split_at(q);\n            let mut low = ys_hi[0] << comp_diff;\n            if !slice_test_zero(ys_lo) {\n                low |= 1;\n            }\n            let (xs_lo, xs_hi) = xs.split_at(nmq);\n            let (xs_lo_last, xs_lo_init) = xs_lo.split_last().unwrap();\n            let mut carry = false;\n            for (i, &x) in xs_lo_init.iter().enumerate() {\n                let qpi = q + i;\n                let mut carry_2;\n                (ys[i], carry_2) = x.overflowing_add((ys[qpi + 1] << comp_diff) | (ys[qpi] >> r));\n                if carry {\n                    carry_2 |= ys[i].overflowing_add_assign(1);\n                }\n                carry = carry_2;\n            }\n            // most significant limb of y is special\n            let (ys_lo, ys_hi) = ys.split_at_mut(nmq);\n            let ys_lo_last = ys_lo.last_mut().unwrap();\n            let mut carry_2;\n            (*ys_lo_last, carry_2) = xs_lo_last.overflowing_add(last_ys >> r);\n            if carry {\n                carry_2 |= ys_lo_last.overflowing_add_assign(1);\n            }\n            let carry = if carry_2 {\n                limbs_add_limb_to_out(ys_hi, xs_hi, 1)\n            } else {\n                ys_hi.copy_from_slice(xs_hi);\n                false\n            };\n            (low, carry)\n        }\n    }\n}\n\nfn add_float_significands_same_prec_ge_3w_ref_ref<'a>(\n    out: &mut [Limb],\n    mut xs: &'a [Limb],\n    mut x_exp: i32,\n    mut ys: &'a [Limb],\n    mut y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    if x_exp < y_exp {\n        swap(&mut xs, &mut ys);\n        swap(&mut x_exp, &mut y_exp);\n    }\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    let out = &mut out[..n];\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_m1_bit = shift_bit >> 1;\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    let mut round_bit;\n    let mut sticky_bit;\n    let last_index = n - 1;\n    if exp_diff == 0 {\n        x_exp.saturating_add_assign(1);\n        assert!(limbs_add_same_length_to_out(out, xs, ys));\n        round_bit = out[0] & shift_bit;\n        limbs_slice_shr_in_place(out, 1);\n        out[last_index] |= LIMB_HIGH_BIT;\n        out[0] &= !(shift_bit - 1);\n        if round_bit == 0 {\n            (x_exp, Equal)\n        } else {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest => {\n                    if out[0] & shift_bit == 0 {\n                        (x_exp, Less)\n                    } else {\n                        if limbs_slice_add_limb_in_place(out, shift_bit) {\n                            x_exp.saturating_add_assign(1);\n                            out[last_index] = LIMB_HIGH_BIT;\n                        }\n                        (x_exp, Greater)\n                    }\n                }\n                Floor | Down => (x_exp, Less),\n                Ceiling | Up => {\n                    if limbs_slice_add_limb_in_place(out, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        out[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        }\n    } else if exp_diff >= prec {\n        if exp_diff > prec {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest | Floor | Down => {\n                    out.copy_from_slice(xs);\n                    (x_exp, Less)\n                }\n                Ceiling | Up => {\n                    out.copy_from_slice(xs);\n                    if limbs_slice_add_limb_in_place(out, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        out[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        } else {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest => {\n                    // Check if y was a power of 2\n                    if limbs_is_power_of_2(ys) && xs[0] & shift_bit == 0 {\n                        out.copy_from_slice(xs);\n                        (x_exp, Less)\n                    } else {\n                        out.copy_from_slice(xs);\n                        if limbs_slice_add_limb_in_place(out, shift_bit) {\n                            x_exp.saturating_add_assign(1);\n                            out[last_index] = LIMB_HIGH_BIT;\n                        }\n                        (x_exp, Greater)\n                    }\n                }\n                Floor | Down => {\n                    out.copy_from_slice(xs);\n                    (x_exp, Less)\n                }\n                Ceiling | Up => {\n                    out.copy_from_slice(xs);\n                    if limbs_slice_add_limb_in_place(out, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        out[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        }\n    } else {\n        // - 0 < exp_diff < prec\n        // - General case: 1 <= exp_diff < prec\n        let mask = !(shift_bit - 1);\n        let carry;\n        (sticky_bit, carry) = add_significands_rsh_to_out(out, xs, ys, exp_diff);\n        // The most significant bit of sticky_bit contains what would be the most significant bit of\n        // out[-1], and the remaining bits of stick_bit are 0 iff the remaining bits of out[-1],\n        // out[-2], ... are all zero\n        if shift != 0 {\n            // The round bit and a part of the sticky bit are in out[0].\n            round_bit = out[0] & shift_m1_bit;\n            sticky_bit |= out[0] & (shift_m1_bit - 1);\n        } else {\n            // The round bit and possibly a part of the sticky bit are in sticky_bit\n            round_bit = sticky_bit & LIMB_HIGH_BIT;\n            sticky_bit &= !LIMB_HIGH_BIT;\n        }\n        out[0] &= mask;\n        // Check for carry out\n        if carry {\n            sticky_bit |= round_bit;\n            round_bit = out[0] & shift_bit;\n            limbs_slice_shr_in_place(out, 1);\n            x_exp.saturating_add_assign(1);\n            out[last_index] |= LIMB_HIGH_BIT;\n            out[0] &= mask;\n        }\n        match rm {\n            Nearest => {\n                if round_bit == 0 {\n                    (x_exp, if sticky_bit != 0 { Less } else { Equal })\n                } else if sticky_bit == 0 && out[0] & shift_bit == 0 {\n                    (x_exp, Less)\n                } else {\n                    if limbs_slice_add_limb_in_place(out, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        out[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n            Floor | Down | Exact => {\n                let inexact = round_bit != 0 || sticky_bit != 0;\n                if rm == Exact && inexact {\n                    panic!(\"Inexact float addition\");\n                } else {\n                    (x_exp, if inexact { Less } else { Equal })\n                }\n            }\n            Ceiling | Up => {\n                if round_bit != 0 || sticky_bit != 0 {\n                    if limbs_slice_add_limb_in_place(out, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        out[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                } else {\n                    (x_exp, Equal)\n                }\n            }\n        }\n    }\n}\n\nfn add_float_significands_same_prec_ge_3w_val_val<'a>(\n    xs: &'a mut [Limb],\n    x_exp: i32,\n    ys: &'a mut [Limb],\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering, bool) {\n    if x_exp >= y_exp {\n        let (exp, o) =\n            add_float_significands_same_prec_ge_3w_val_ref(xs, x_exp, ys, y_exp, prec, rm);\n        (exp, o, false)\n    } else {\n        let (exp, o) =\n            add_float_significands_same_prec_ge_3w_val_ref(ys, y_exp, xs, x_exp, prec, rm);\n        (exp, o, true)\n    }\n}\n\nfn add_float_significands_same_prec_ge_3w_val_ref(\n    xs: &mut [Limb],\n    mut x_exp: i32,\n    ys: &[Limb],\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_m1_bit = shift_bit >> 1;\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    let mut round_bit;\n    let mut sticky_bit;\n    let last_index = n - 1;\n    if exp_diff == 0 {\n        x_exp.saturating_add_assign(1);\n        assert!(limbs_slice_add_same_length_in_place_left(xs, ys));\n        round_bit = xs[0] & shift_bit;\n        limbs_slice_shr_in_place(xs, 1);\n        xs[last_index] |= LIMB_HIGH_BIT;\n        xs[0] &= !(shift_bit - 1);\n        if round_bit == 0 {\n            (x_exp, Equal)\n        } else {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest => {\n                    if xs[0] & shift_bit == 0 {\n                        (x_exp, Less)\n                    } else {\n                        if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                            x_exp.saturating_add_assign(1);\n                            xs[last_index] = LIMB_HIGH_BIT;\n                        }\n                        (x_exp, Greater)\n                    }\n                }\n                Floor | Down => (x_exp, Less),\n                Ceiling | Up => {\n                    if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        xs[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        }\n    } else if exp_diff >= prec {\n        if exp_diff > prec {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest | Floor | Down => (x_exp, Less),\n                Ceiling | Up => {\n                    if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        xs[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        } else {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest => {\n                    // Check if y was a power of 2\n                    if limbs_is_power_of_2(ys) && xs[0] & shift_bit == 0 {\n                        (x_exp, Less)\n                    } else {\n                        if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                            x_exp.saturating_add_assign(1);\n                            xs[last_index] = LIMB_HIGH_BIT;\n                        }\n                        (x_exp, Greater)\n                    }\n                }\n                Floor | Down => (x_exp, Less),\n                Ceiling | Up => {\n                    if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        xs[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        }\n    } else {\n        // - 0 < exp_diff < prec\n        // - General case: 1 <= exp_diff < prec\n        let mask = !(shift_bit - 1);\n        let carry;\n        (sticky_bit, carry) = add_significands_rsh_mut_ref(xs, ys, exp_diff);\n        // The most significant bit of sticky_bit contains what would be the most significant bit of\n        // out[-1], and the remaining bits of stick_bit are 0 iff the remaining bits of out[-1],\n        // out[-2], ... are all zero\n        if shift != 0 {\n            // The round bit and a part of the sticky bit are in out[0].\n            round_bit = xs[0] & shift_m1_bit;\n            sticky_bit |= xs[0] & (shift_m1_bit - 1);\n        } else {\n            // The round bit and possibly a part of the sticky bit are in sticky_bit\n            round_bit = sticky_bit & LIMB_HIGH_BIT;\n            sticky_bit &= !LIMB_HIGH_BIT;\n        }\n        xs[0] &= mask;\n        // Check for carry out\n        if carry {\n            sticky_bit |= round_bit;\n            round_bit = xs[0] & shift_bit;\n            limbs_slice_shr_in_place(xs, 1);\n            x_exp.saturating_add_assign(1);\n            xs[last_index] |= LIMB_HIGH_BIT;\n            xs[0] &= mask;\n        }\n        match rm {\n            Nearest => {\n                if round_bit == 0 {\n                    (x_exp, if sticky_bit != 0 { Less } else { Equal })\n                } else if sticky_bit == 0 && xs[0] & shift_bit == 0 {\n                    (x_exp, Less)\n                } else {\n                    if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        xs[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n            Floor | Down | Exact => {\n                let inexact = round_bit != 0 || sticky_bit != 0;\n                if rm == Exact && inexact {\n                    panic!(\"Inexact float addition\");\n                } else {\n                    (x_exp, if inexact { Less } else { Equal })\n                }\n            }\n            Ceiling | Up => {\n                if round_bit != 0 || sticky_bit != 0 {\n                    if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        xs[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                } else {\n                    (x_exp, Equal)\n                }\n            }\n        }\n    }\n}\n\nfn add_float_significands_same_prec_ge_3w_ref_val(\n    xs: &[Limb],\n    mut x_exp: i32,\n    ys: &mut [Limb],\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_m1_bit = shift_bit >> 1;\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    let mut round_bit;\n    let mut sticky_bit;\n    let last_index = n - 1;\n    if exp_diff == 0 {\n        x_exp.saturating_add_assign(1);\n        assert!(limbs_slice_add_same_length_in_place_left(ys, xs));\n        round_bit = ys[0] & shift_bit;\n        limbs_slice_shr_in_place(ys, 1);\n        ys[last_index] |= LIMB_HIGH_BIT;\n        ys[0] &= !(shift_bit - 1);\n        if round_bit == 0 {\n            (x_exp, Equal)\n        } else {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest => {\n                    if ys[0] & shift_bit == 0 {\n                        (x_exp, Less)\n                    } else {\n                        if limbs_slice_add_limb_in_place(ys, shift_bit) {\n                            x_exp.saturating_add_assign(1);\n                            ys[last_index] = LIMB_HIGH_BIT;\n                        }\n                        (x_exp, Greater)\n                    }\n                }\n                Floor | Down => (x_exp, Less),\n                Ceiling | Up => {\n                    if limbs_slice_add_limb_in_place(ys, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        ys[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        }\n    } else if exp_diff >= prec {\n        if exp_diff > prec {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest | Floor | Down => {\n                    ys.copy_from_slice(xs);\n                    (x_exp, Less)\n                }\n                Ceiling | Up => {\n                    ys.copy_from_slice(xs);\n                    if limbs_slice_add_limb_in_place(ys, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        ys[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        } else {\n            match rm {\n                Exact => panic!(\"Inexact float addition\"),\n                Nearest => {\n                    // Check if y was a power of 2\n                    if limbs_is_power_of_2(ys) && xs[0] & shift_bit == 0 {\n                        ys.copy_from_slice(xs);\n                        (x_exp, Less)\n                    } else {\n                        ys.copy_from_slice(xs);\n                        if limbs_slice_add_limb_in_place(ys, shift_bit) {\n                            x_exp.saturating_add_assign(1);\n                            ys[last_index] = LIMB_HIGH_BIT;\n                        }\n                        (x_exp, Greater)\n                    }\n                }\n                Floor | Down => {\n                    ys.copy_from_slice(xs);\n                    (x_exp, Less)\n                }\n                Ceiling | Up => {\n                    ys.copy_from_slice(xs);\n                    if limbs_slice_add_limb_in_place(ys, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        ys[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n        }\n    } else {\n        // - 0 < exp_diff < prec\n        // - General case: 1 <= exp_diff < prec\n        let mask = !(shift_bit - 1);\n        let carry;\n        (sticky_bit, carry) = add_significands_rsh_ref_mut(xs, ys, exp_diff);\n        // The most significant bit of sticky_bit contains what would be the most significant bit of\n        // y[-1], and the remaining bits of stick_bit are 0 iff the remaining bits of y[-1], y[-2],\n        // ... are all zero\n        if shift != 0 {\n            // The round bit and a part of the sticky bit are in y[0].\n            round_bit = ys[0] & shift_m1_bit;\n            sticky_bit |= ys[0] & (shift_m1_bit - 1);\n        } else {\n            // The round bit and possibly a part of the sticky bit are in sticky_bit\n            round_bit = sticky_bit & LIMB_HIGH_BIT;\n            sticky_bit &= !LIMB_HIGH_BIT;\n        }\n        ys[0] &= mask;\n        // Check for carry out\n        if carry {\n            sticky_bit |= round_bit;\n            round_bit = ys[0] & shift_bit;\n            limbs_slice_shr_in_place(ys, 1);\n            x_exp.saturating_add_assign(1);\n            ys[last_index] |= LIMB_HIGH_BIT;\n            ys[0] &= mask;\n        }\n        match rm {\n            Nearest => {\n                if round_bit == 0 {\n                    (x_exp, if sticky_bit != 0 { Less } else { Equal })\n                } else if sticky_bit == 0 && ys[0] & shift_bit == 0 {\n                    (x_exp, Less)\n                } else {\n                    if limbs_slice_add_limb_in_place(ys, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        ys[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                }\n            }\n            Floor | Down | Exact => {\n                let inexact = round_bit != 0 || sticky_bit != 0;\n                if rm == Exact && inexact {\n                    panic!(\"Inexact float addition\");\n                } else {\n                    (x_exp, if inexact { Less } else { Equal })\n                }\n            }\n            Ceiling | Up => {\n                if round_bit != 0 || sticky_bit != 0 {\n                    if limbs_slice_add_limb_in_place(ys, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        ys[last_index] = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                } else {\n                    (x_exp, Equal)\n                }\n            }\n        }\n    }\n}\n\n#[derive(Debug, Clone, Copy, Eq, PartialEq)]\nenum RoundBit {\n    Uninitialized,\n    False,\n    True,\n}\n\nimpl RoundBit {\n    #[inline]\n    const fn flip_assign(&mut self) {\n        match self {\n            False => *self = True,\n            True => *self = False,\n            _ => {}\n        }\n    }\n}\n\nimpl From<bool> for RoundBit {\n    #[inline]\n    fn from(b: bool) -> Self {\n        if b { True } else { False }\n    }\n}\n\nfn add_float_significands_general_round(\n    out: &mut [Limb],\n    mut x_exp: i32,\n    shift_bit: Limb,\n    round_bit: RoundBit,\n    following_bits: RoundBit,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    if following_bits == False && round_bit == False {\n        return (x_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float addition\"),\n        Nearest => {\n            if following_bits == False {\n                if out[0] & shift_bit != 0 {\n                    if limbs_slice_add_limb_in_place(out, shift_bit) {\n                        x_exp.saturating_add_assign(1);\n                        *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n                    }\n                    (x_exp, Greater)\n                } else {\n                    (x_exp, Less)\n                }\n            } else if round_bit == False {\n                (x_exp, Less)\n            } else {\n                if limbs_slice_add_limb_in_place(out, shift_bit) {\n                    x_exp.saturating_add_assign(1);\n                    *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n                }\n                (x_exp, Greater)\n            }\n        }\n        Floor | Down => (x_exp, Less),\n        Ceiling | Up => {\n            if limbs_slice_add_limb_in_place(out, shift_bit) {\n                x_exp.saturating_add_assign(1);\n                *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n            }\n            (x_exp, Greater)\n        }\n    }\n}\n\nfn add_float_significands_general(\n    out: &mut [Limb],\n    xs: &[Limb],\n    mut x_exp: i32,\n    ys: &[Limb],\n    y_exp: i32,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    assert!(x_exp >= y_exp);\n    let out_len = out.len();\n    let out_bits = limb_to_bit_count(out_len);\n    let shift = out_bits - out_prec; // non-significant bits in low limb\n    let shift_bit = Limb::power_of_2(shift);\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    let k = bit_to_limb_count_floor(exp_diff);\n    // Compute the significant part out', the non-significant bits of out are taken into account.\n    //\n    // Perform the rounding. At each iteration, we remember:\n    // - r = rounding bit\n    // - f = following bits (same value)\n    // where the result has the form: [number A]rfff...fff + a remaining value in the interval [0,2)\n    // ulp. We consider the most significant bits of the remaining value to update the result; a\n    // possible carry is immediately taken into account and out is updated accordingly. As soon as\n    // the bits f don't have the same value, out can be rounded. Variables:\n    //\n    // - round_bit = rounding bit (0 or 1).\n    // - following_bits = following bits (0 or 1), then sticky bit.\n    // - If following_bits == 0, the only thing that can change is the sticky bit.\n    // - means: not initialized\n    let mut round_bit = Uninitialized;\n    let mut following_bits = Uninitialized;\n    if out_bits <= exp_diff {\n        // y does not overlap with out'\n        if out_len > xs_len {\n            out[out_len - xs_len..].copy_from_slice(xs);\n        } else {\n            out.copy_from_slice(&xs[xs_len - out_len..]);\n        }\n    } else {\n        // - out_bits > exp_diff\n        // - y overlaps with out'\n        // - copy y (shifted) into out\n        // overlap is the number of limbs of y which overlap with out'\n        let mut overlap = bit_to_limb_count_ceiling(out_bits - exp_diff);\n        // only the highest overlap limbs from y have to be considered\n        if overlap > ys_len {\n            // y doesn't have enough limbs\n            assert!(overlap - ys_len <= out_len);\n            overlap = ys_len;\n        }\n        let ys_hi = &ys[ys_len - overlap..];\n        let omk = out_len - k;\n        let (out_lo, out_hi) = out.split_at_mut(omk - overlap);\n        let out_hi = &mut out_hi[..overlap];\n        let shift2 = u64::exact_from(exp_diff & Limb::WIDTH_MASK);\n        if shift2 != 0 {\n            assert!(omk >= overlap);\n            let y = limbs_shr_to_out(out_hi, ys_hi, shift2);\n            if omk > overlap {\n                *out_lo.last_mut().unwrap() = y;\n            }\n        } else {\n            out_hi.copy_from_slice(ys_hi);\n        }\n        // add x to out\n        let y = if out_len > xs_len {\n            limbs_slice_add_same_length_in_place_left(&mut out[out_len - xs_len..], xs)\n        } else {\n            limbs_slice_add_same_length_in_place_left(out, &xs[xs_len - out_len..])\n        };\n        if y {\n            x_exp.saturating_add_assign(1);\n            round_bit = RoundBit::from((out[0] >> shift).odd());\n            // LSB(out) --> rounding bit after the shift\n            if shift != 0 {\n                let mask = shift_bit - 1;\n                let x = out[0] & mask;\n                out[0] &= !mask << 1;\n                if x == 0 {\n                    following_bits = False;\n                } else if x == mask {\n                    following_bits = True;\n                }\n            }\n            limbs_slice_shr_in_place(out, 1);\n            out[out_len - 1] |= LIMB_HIGH_BIT;\n            if shift != 0 && following_bits == Uninitialized {\n                return add_float_significands_general_round(\n                    out,\n                    x_exp,\n                    shift_bit,\n                    round_bit,\n                    following_bits,\n                    rm,\n                );\n            }\n        }\n    }\n    if round_bit == Uninitialized && shift != 0 {\n        let mut mask = shift_bit - 1;\n        let mut x = out[0] & mask;\n        out[0] &= !mask;\n        round_bit = RoundBit::from(x >> (shift - 1) != 0);\n        if shift > 1 {\n            mask >>= 1;\n            x &= mask;\n            if x == 0 {\n                following_bits = False;\n            } else if x == mask {\n                following_bits = True;\n            } else {\n                return add_float_significands_general_round(\n                    out,\n                    x_exp,\n                    shift_bit,\n                    round_bit,\n                    following_bits,\n                    rm,\n                );\n            }\n        }\n    }\n    // Determine rounding and sticky bits (and possible carry). In faithful rounding, we may stop\n    // two bits after ulp(out): the approximation is regarded as the number formed by out, the\n    // rounding bit round_bit and an additional bit following_bits; and the corresponding error is <\n    // 1/2 ulp of the unrounded result.\n    if xs_len > out_len {\n        // there are still limbs from x that haven't been taken into account\n        if following_bits == False && out_len <= k {\n            // y hasn't been taken into account ==> sticky bit != 0\n            return add_float_significands_general_round(\n                out, x_exp, shift_bit, round_bit, True, rm,\n            );\n        }\n        // index of lowest considered limb from x, > 0\n        let mut xi = xs_len - out_len;\n        for _ in 0..k.saturating_sub(out_len) {\n            // ulp(next limb from x) > msb(y)\n            xi -= 1;\n            let mut x = xs[xi];\n            assert_ne!(following_bits, False);\n            if following_bits == True {\n                // Note: Here, we can round to nearest, but the loop may still be necessary to\n                // determine whether there is a carry from y, which will have an effect on the\n                // ternary value.\n                if x != Limb::MAX {\n                    return add_float_significands_general_round(\n                        out,\n                        x_exp,\n                        shift_bit,\n                        round_bit,\n                        following_bits,\n                        rm,\n                    );\n                }\n            } else {\n                if round_bit == Uninitialized {\n                    round_bit = RoundBit::from(x >> (Limb::WIDTH - 1) != 0);\n                    x |= LIMB_HIGH_BIT;\n                }\n                following_bits = True;\n                if x != Limb::MAX {\n                    return add_float_significands_general_round(\n                        out, x_exp, shift_bit, round_bit, True, rm,\n                    );\n                }\n            }\n            if xi == 0 {\n                // x has entirely been read y hasn't been taken into account, so sticky_bit != 0\n                return add_float_significands_general_round(\n                    out, x_exp, shift_bit, round_bit, True, rm,\n                );\n            }\n        }\n        let difw = out_len.saturating_sub(k);\n        assert!(xi != 0);\n        let mut goto_c_read = false;\n        if difw <= ys_len {\n            let mut yi = ys_len - difw + 1;\n            let exp_diff_rem = exp_diff & Limb::WIDTH_MASK;\n            if exp_diff_rem != 0 || yi != 1 {\n                let mut y_prev = if yi - 1 == ys_len { 0 } else { ys[yi - 1] };\n                if following_bits == Uninitialized {\n                    let mut y;\n                    if exp_diff_rem != 0 {\n                        y = y_prev << (Limb::WIDTH - exp_diff_rem);\n                        yi -= 1;\n                        if yi != 0 {\n                            y_prev = ys[yi - 1];\n                            y += y_prev >> exp_diff_rem;\n                        }\n                    } else {\n                        yi -= 1;\n                        y = ys[yi - 1];\n                    }\n                    xi -= 1;\n                    let mut x = xs[xi].wrapping_add(y);\n                    if x < y\n                        && (round_bit == Uninitialized || {\n                            round_bit.flip_assign();\n                            round_bit == False\n                        })\n                        && limbs_slice_add_limb_in_place(out, shift_bit)\n                    {\n                        x_exp.saturating_add_assign(1);\n                        out[out_len - 1] = LIMB_HIGH_BIT;\n                        round_bit = False;\n                    }\n                    if round_bit == Uninitialized {\n                        round_bit = RoundBit::from(x >> (Limb::WIDTH - 1) != 0);\n                        x <<= 1;\n                        x |= x >> (Limb::WIDTH - 1);\n                    }\n                    following_bits = RoundBit::from(x != 0);\n                    if x != 0 && x != Limb::MAX {\n                        return add_float_significands_general_round(\n                            out,\n                            x_exp,\n                            shift_bit,\n                            round_bit,\n                            following_bits,\n                            rm,\n                        );\n                    }\n                }\n                let mut y;\n                while xi != 0 {\n                    if exp_diff_rem != 0 {\n                        if yi == 0 {\n                            goto_c_read = true;\n                            break;\n                        }\n                        y = y_prev << (Limb::WIDTH - exp_diff_rem);\n                        yi -= 1;\n                        if yi != 0 {\n                            y_prev = ys[yi - 1];\n                            y += y_prev >> exp_diff_rem;\n                        }\n                    } else {\n                        if yi == 1 {\n                            goto_c_read = true;\n                            break;\n                        }\n                        yi -= 1;\n                        y = ys[yi - 1];\n                    }\n                    let x = xs[xi - 1].wrapping_add(y);\n                    if x < y {\n                        following_bits.flip_assign();\n                        if following_bits != False {\n                            return add_float_significands_general_round(\n                                out,\n                                x_exp,\n                                shift_bit,\n                                round_bit,\n                                following_bits,\n                                rm,\n                            );\n                        }\n                        round_bit.flip_assign();\n                        if round_bit == False && limbs_slice_add_limb_in_place(out, shift_bit) {\n                            x_exp.saturating_add_assign(1);\n                            out[out_len - 1] = LIMB_HIGH_BIT;\n                        }\n                    }\n                    if following_bits == False && x != 0 {\n                        return add_float_significands_general_round(\n                            out, x_exp, shift_bit, round_bit, True, rm,\n                        );\n                    }\n                    if following_bits != False && x != Limb::MAX {\n                        return add_float_significands_general_round(\n                            out,\n                            x_exp,\n                            shift_bit,\n                            round_bit,\n                            following_bits,\n                            rm,\n                        );\n                    }\n                    xi -= 1;\n                }\n                if !goto_c_read {\n                    if following_bits != False || yi == 0 {\n                        return add_float_significands_general_round(\n                            out,\n                            x_exp,\n                            shift_bit,\n                            round_bit,\n                            following_bits,\n                            rm,\n                        );\n                    }\n                    if exp_diff_rem != 0 && y_prev << (Limb::WIDTH - exp_diff_rem) != 0 {\n                        return add_float_significands_general_round(\n                            out, x_exp, shift_bit, round_bit, True, rm,\n                        );\n                    }\n                    yi -= 1;\n                    while yi != 0 {\n                        yi -= 1;\n                        if ys[yi] != 0 {\n                            return add_float_significands_general_round(\n                                out, x_exp, shift_bit, round_bit, True, rm,\n                            );\n                        }\n                    }\n                }\n            } else {\n                goto_c_read = true;\n            }\n        }\n        if difw > ys_len || goto_c_read {\n            // - y has entirely been read\n            // - label c_read:\n            if following_bits == Uninitialized {\n                assert_ne!(xi, 0);\n                xi -= 1;\n                let mut x = xs[xi];\n                if round_bit == Uninitialized {\n                    round_bit = RoundBit::from(x >> (Limb::WIDTH - 1) != 0);\n                    x &= !LIMB_HIGH_BIT;\n                }\n                following_bits = RoundBit::from(x != 0);\n            }\n            if following_bits == True {\n                return add_float_significands_general_round(\n                    out, x_exp, shift_bit, round_bit, True, rm,\n                );\n            }\n            while xi != 0 {\n                xi -= 1;\n                if xs[xi] != 0 {\n                    return add_float_significands_general_round(\n                        out, x_exp, shift_bit, round_bit, True, rm,\n                    );\n                }\n            }\n        }\n    } else if following_bits != True {\n        if out_len.saturating_sub(k) > ys_len {\n            if round_bit == Uninitialized {\n                round_bit = False;\n            }\n            following_bits = False;\n        } else if exp_diff > out_bits {\n            // x is followed by at least a zero bit, then by y\n            if round_bit == Uninitialized {\n                round_bit = False;\n            }\n            following_bits = True;\n        } else {\n            // difw is the number of limbs from x (regarded as having an infinite precision) that\n            // have already been combined with y; -n if the next n limbs from x won't be combined\n            // with y.\n            let difw = out_len - k;\n            assert!(ys_len >= difw);\n            let mut yi = ys_len - difw;\n            let exp_diff_rem = exp_diff & Limb::WIDTH_MASK;\n            if exp_diff_rem == 0 && yi == 0 {\n                // y has entirely been read\n                if round_bit == Uninitialized {\n                    round_bit = False;\n                }\n                following_bits = False;\n            } else {\n                let mut y = if exp_diff_rem != 0 {\n                    assert!(yi < ys_len);\n                    ys[yi] << (Limb::WIDTH - exp_diff_rem)\n                } else {\n                    yi -= 1;\n                    ys[yi]\n                };\n                if round_bit == Uninitialized {\n                    round_bit = RoundBit::from(y >> (Limb::WIDTH - 1) != 0);\n                    y &= !LIMB_HIGH_BIT;\n                }\n                while y == 0 {\n                    if yi == 0 {\n                        return add_float_significands_general_round(\n                            out, x_exp, shift_bit, round_bit, False, rm,\n                        );\n                    }\n                    yi -= 1;\n                    y = ys[yi];\n                }\n                following_bits = True;\n            }\n        }\n    }\n    add_float_significands_general_round(out, x_exp, shift_bit, round_bit, following_bits, rm)\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 1999-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::div::limbs_div_schoolbook_approx;\nuse crate::natural::arithmetic::div_mod::{\n    div_mod_by_preinversion, limbs_div_limb_in_place_mod, limbs_div_limb_to_out_mod,\n    limbs_div_mod_by_two_limb_normalized, limbs_div_mod_qs_to_out_rs_to_ns, limbs_invert_limb,\n    limbs_two_limb_inverse_helper,\n};\nuse crate::natural::arithmetic::float_extras::round_helper_2;\nuse crate::natural::arithmetic::float_mul::{\n    limbs_float_mul_high_same_length, limbs_float_mul_high_same_length_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{limbs_mul_to_out, limbs_mul_to_out_scratch_len};\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::shr::{limbs_shr_to_out, limbs_slice_shr_in_place};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::natural::{LIMB_HIGH_BIT, Natural, bit_to_limb_count_ceiling};\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, NegModPowerOf2, OverflowingAddAssign, OverflowingNegAssign, Parity, PowerOf2,\n    WrappingAddAssign, WrappingNegAssign, WrappingSubAssign, XMulYToZZ, XXSubYYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::slice_test_zero;\n\n// This is mpfr_div from div.c, MPFR 4.3.0.\npub fn div_float_significands_in_place(\n    x: &mut Natural,\n    x_prec: u64,\n    y: &mut Natural,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    if x_prec == y_prec\n        && out_prec == x_prec\n        && let Some((increment_exp, o)) =\n            div_float_significands_in_place_same_prec(x, y, out_prec, rm)\n    {\n        return (u64::from(increment_exp), o);\n    }\n    match (&mut *x, y) {\n        (Natural(Small(small_x)), Natural(Small(small_y))) => {\n            let mut xs = vec![*small_x];\n            let result =\n                div_float_significands_long_by_short_in_place(&mut xs, *small_y, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(xs);\n            result\n        }\n        (Natural(Large(xs)), Natural(Small(small_y))) => {\n            let result = div_float_significands_long_by_short_in_place(xs, *small_y, out_prec, rm);\n            x.demote_if_small();\n            result\n        }\n        (Natural(Small(small_x)), Natural(Large(ys))) => {\n            let (out, exp_offset, o) =\n                div_float_significands_general(&[*small_x], ys, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(out);\n            (exp_offset, o)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => {\n            let (out, exp_offset, o) = div_float_significands_general(xs, ys, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(out);\n            (exp_offset, o)\n        }\n    }\n}\n\n// This is mpfr_div from div.c, MPFR 4.3.0.\npub fn div_float_significands_in_place_ref(\n    x: &mut Natural,\n    x_prec: u64,\n    y: &Natural,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    if x_prec == y_prec\n        && out_prec == x_prec\n        && let Some((increment_exp, o)) =\n            div_float_significands_in_place_same_prec_ref(x, y, out_prec, rm)\n    {\n        return (u64::from(increment_exp), o);\n    }\n    match (&mut *x, y) {\n        (Natural(Small(small_x)), Natural(Small(small_y))) => {\n            let mut xs = vec![*small_x];\n            let result =\n                div_float_significands_long_by_short_in_place(&mut xs, *small_y, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(xs);\n            result\n        }\n        (Natural(Large(xs)), Natural(Small(small_y))) => {\n            let result = div_float_significands_long_by_short_in_place(xs, *small_y, out_prec, rm);\n            x.demote_if_small();\n            result\n        }\n        (Natural(Small(small_x)), y) => {\n            let mut ys = y.to_limbs_asc();\n            let (out, exp_offset, o) =\n                div_float_significands_general(&[*small_x], &mut ys, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(out);\n            (exp_offset, o)\n        }\n        (Natural(Large(xs)), y) => {\n            let mut ys = y.to_limbs_asc();\n            let (out, exp_offset, o) = div_float_significands_general(xs, &mut ys, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(out);\n            (exp_offset, o)\n        }\n    }\n}\n\n// This is mpfr_div from div.c, MPFR 4.3.0.\npub fn div_float_significands_ref_val(\n    x: &Natural,\n    x_prec: u64,\n    y: &mut Natural,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, u64, Ordering) {\n    if x_prec == y_prec\n        && out_prec == x_prec\n        && let Some((quotient, increment_exp, o)) =\n            div_float_significands_same_prec_ref_val(x, y, out_prec, rm)\n    {\n        return (quotient, u64::from(increment_exp), o);\n    }\n    match (x, y) {\n        (Natural(Small(small_x)), Natural(Small(small_y))) => {\n            let (qs, exp_offset, o) =\n                div_float_significands_long_by_short(&[*small_x], *small_y, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n        (Natural(Large(xs)), Natural(Small(small_y))) => {\n            let (qs, exp_offset, o) =\n                div_float_significands_long_by_short(xs, *small_y, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n        (Natural(Small(small_x)), Natural(Large(ys))) => {\n            let (qs, exp_offset, o) = div_float_significands_general(&[*small_x], ys, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => {\n            let (qs, exp_offset, o) = div_float_significands_general(xs, ys, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n    }\n}\n\n// This is mpfr_div from div.c, MPFR 4.3.0.\npub fn div_float_significands_ref_ref(\n    x: &Natural,\n    x_prec: u64,\n    y: &Natural,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, u64, Ordering) {\n    if x_prec == y_prec\n        && out_prec == x_prec\n        && let Some((quotient, increment_exp, o)) =\n            div_float_significands_same_prec_ref_ref(x, y, out_prec, rm)\n    {\n        return (quotient, u64::from(increment_exp), o);\n    }\n    match (x, y) {\n        (Natural(Small(small_x)), Natural(Small(small_y))) => {\n            let (qs, exp_offset, o) =\n                div_float_significands_long_by_short(&[*small_x], *small_y, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n        (Natural(Large(xs)), Natural(Small(small_y))) => {\n            let (qs, exp_offset, o) =\n                div_float_significands_long_by_short(xs, *small_y, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n        (Natural(Small(small_x)), y) => {\n            let mut ys = y.to_limbs_asc();\n            let (qs, exp_offset, o) =\n                div_float_significands_general(&[*small_x], &mut ys, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n        (Natural(Large(xs)), y) => {\n            let mut ys = y.to_limbs_asc();\n            let (qs, exp_offset, o) = div_float_significands_general(xs, &mut ys, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n    }\n}\n\nfn div_float_significands_in_place_same_prec(\n    x: &mut Natural,\n    y: &mut Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(bool, Ordering)> {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (quotient, increment_exp, o) = if prec == Limb::WIDTH {\n                div_float_significands_same_prec_w(*x, *y, rm)\n            } else {\n                div_float_significands_same_prec_lt_w(*x, *y, prec, rm)\n            };\n            *x = quotient;\n            Some((increment_exp, o))\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_mut_slice()) {\n            ([x_0, x_1], [y_0, y_1]) if prec != TWICE_WIDTH => {\n                let (quotient_0, quotient_1, increment_exp, o) =\n                    div_float_significands_same_prec_gt_w_lt_2w(*x_0, *x_1, *y_0, *y_1, prec, rm);\n                *x_0 = quotient_0;\n                *x_1 = quotient_1;\n                Some((increment_exp, o))\n            }\n            _ => None,\n        },\n        _ => None,\n    }\n}\n\nfn div_float_significands_in_place_same_prec_ref(\n    x: &mut Natural,\n    y: &Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(bool, Ordering)> {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (quotient, increment_exp, o) = if prec == Limb::WIDTH {\n                div_float_significands_same_prec_w(*x, *y, rm)\n            } else {\n                div_float_significands_same_prec_lt_w(*x, *y, prec, rm)\n            };\n            *x = quotient;\n            Some((increment_exp, o))\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_slice()) {\n            ([x_0, x_1], [y_0, y_1]) if prec != TWICE_WIDTH => {\n                let (quotient_0, quotient_1, increment_exp, o) =\n                    div_float_significands_same_prec_gt_w_lt_2w(*x_0, *x_1, *y_0, *y_1, prec, rm);\n                *x_0 = quotient_0;\n                *x_1 = quotient_1;\n                Some((increment_exp, o))\n            }\n            _ => None,\n        },\n        _ => None,\n    }\n}\n\nfn div_float_significands_same_prec_ref_val(\n    x: &Natural,\n    y: &mut Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(Natural, bool, Ordering)> {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (quotient, increment_exp, o) = if prec == Limb::WIDTH {\n                div_float_significands_same_prec_w(*x, *y, rm)\n            } else {\n                div_float_significands_same_prec_lt_w(*x, *y, prec, rm)\n            };\n            Some((Natural(Small(quotient)), increment_exp, o))\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_slice(), ys.as_slice()) {\n            ([x_0, x_1], [y_0, y_1]) if prec != TWICE_WIDTH => {\n                let (quotient_0, quotient_1, increment_exp, o) =\n                    div_float_significands_same_prec_gt_w_lt_2w(*x_0, *x_1, *y_0, *y_1, prec, rm);\n                Some((\n                    Natural(Large(vec![quotient_0, quotient_1])),\n                    increment_exp,\n                    o,\n                ))\n            }\n            _ => None,\n        },\n        _ => None,\n    }\n}\nfn div_float_significands_same_prec_ref_ref(\n    x: &Natural,\n    y: &Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(Natural, bool, Ordering)> {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (quotient, increment_exp, o) = if prec == Limb::WIDTH {\n                div_float_significands_same_prec_w(*x, *y, rm)\n            } else {\n                div_float_significands_same_prec_lt_w(*x, *y, prec, rm)\n            };\n            Some((Natural(Small(quotient)), increment_exp, o))\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_slice(), ys.as_slice()) {\n            ([x_0, x_1], [y_0, y_1]) if prec != TWICE_WIDTH => {\n                let (quotient_0, quotient_1, increment_exp, o) =\n                    div_float_significands_same_prec_gt_w_lt_2w(*x_0, *x_1, *y_0, *y_1, prec, rm);\n                Some((\n                    Natural(Large(vec![quotient_0, quotient_1])),\n                    increment_exp,\n                    o,\n                ))\n            }\n            _ => None,\n        },\n        _ => None,\n    }\n}\n\nconst WIDTH_M1: u64 = Limb::WIDTH - 1;\nconst TWICE_WIDTH: u64 = Limb::WIDTH << 1;\n\n// This is mpfr_div_1 from mul.c, MPFR 4.3.0.\nfn div_float_significands_same_prec_lt_w(\n    mut x: Limb,\n    y: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, bool, Ordering) {\n    let shift = Limb::WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let half_shift_bit = shift_bit >> 1;\n    let mask = shift_bit - 1;\n    let increment_exp = x >= y;\n    if increment_exp {\n        x -= y;\n    }\n    // First try with an approximate quotient.\n    let mut round_bit = Limb::wrapping_from(\n        (DoubleLimb::from(x) * DoubleLimb::from(limbs_invert_limb::<DoubleLimb, Limb>(y)))\n            >> Limb::WIDTH,\n    );\n    round_bit.wrapping_add_assign(x);\n    let mut q = if increment_exp {\n        round_bit >> 1\n    } else {\n        round_bit\n    };\n    // round_bit does not exceed the true quotient floor(x * 2 ^ WIDTH / y), with error at most 2,\n    // which means the rational quotient q satisfies round_bit <= q < round_bit + 3. We can round\n    // correctly except when the last shift - 1 bits of q0 are 000..000 or 111..111 or 111..110.\n    let sticky_bit = if (q + 2) & (mask >> 1) > 2 {\n        round_bit = q & half_shift_bit;\n        // result cannot be exact in this case\n        1\n    } else {\n        // The true quotient is round_bit, round_bit + 1, or round_bit + 2\n        q = round_bit;\n        let (mut hi, mut lo) = Limb::x_mul_y_to_zz(q, y);\n        assert!(hi < x || (hi == x && lo == 0));\n        // subtract {hi, lo} from {x, 0}\n        (hi, lo) = Limb::xx_sub_yy_to_zz(x, 0, hi, lo);\n        // the remainder {hi, lo} should be < y.\n        if hi != 0 || lo >= y {\n            q += 1;\n            if lo < y {\n                hi.wrapping_sub_assign(1);\n            }\n            lo.wrapping_sub_assign(y);\n        }\n        if hi != 0 || lo >= y {\n            q += 1;\n            if lo < y {\n                hi.wrapping_sub_assign(1);\n            }\n            lo.wrapping_sub_assign(y);\n        }\n        assert!(hi == 0 && lo < y);\n        let sticky_bit;\n        if increment_exp {\n            sticky_bit = lo | (q & 1);\n            q >>= 1;\n        } else {\n            sticky_bit = lo;\n        }\n        round_bit = q & half_shift_bit;\n        sticky_bit | (q & (mask >> 1))\n    };\n    let quotient = (LIMB_HIGH_BIT | q) & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (quotient, increment_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float division\"),\n        Nearest => {\n            if round_bit == 0 || sticky_bit == 0 && quotient & shift_bit == 0 {\n                (quotient, increment_exp, Less)\n            } else {\n                (quotient.wrapping_add(shift_bit), increment_exp, Greater)\n            }\n        }\n        Floor | Down => (quotient, increment_exp, Less),\n        Ceiling | Up => (quotient.wrapping_add(shift_bit), increment_exp, Greater),\n    }\n}\n\n// This is mpfr_div_1n from mul.c, MPFR 4.3.0.\nfn div_float_significands_same_prec_w(\n    mut x: Limb,\n    y: Limb,\n    rm: RoundingMode,\n) -> (Limb, bool, Ordering) {\n    let increment_exp = x >= y;\n    if increment_exp {\n        x -= y;\n    }\n    // First compute an approximate quotient.\n    let mut q = x.wrapping_add(Limb::wrapping_from(\n        (DoubleLimb::from(x) * DoubleLimb::from(limbs_invert_limb::<DoubleLimb, Limb>(y)))\n            >> Limb::WIDTH,\n    ));\n    // round_bit does not exceed the true quotient floor(x * 2 ^ WIDTH / y), with error at most 2,\n    // which means the rational quotient q satisfies round_bit <= q < round_bit + 3, thus the true\n    // quotient is round_bit, round_bit + 1 or round_bit + 2.\n    let (mut hi, mut lo) = Limb::x_mul_y_to_zz(q, y);\n    assert!(hi < x || (hi == x && lo == 0));\n    // subtract {hi, lo} from {x, 0}\n    (hi, lo) = Limb::xx_sub_yy_to_zz(x, 0, hi, lo);\n    // the remainder {hi, lo} should be < y.\n    if hi != 0 || lo >= y {\n        q += 1;\n        if lo < y {\n            hi.wrapping_sub_assign(1);\n        }\n        lo.wrapping_sub_assign(y);\n    }\n    if hi != 0 || lo >= y {\n        q += 1;\n        if lo < y {\n            hi.wrapping_sub_assign(1);\n        }\n        lo.wrapping_sub_assign(y);\n    }\n    assert!(hi == 0 && lo < y);\n    // now (x - extra * y) * 2 ^ WIDTH = q * y + lo with 0 <= lo < y\n    //\n    // If !increment_exp, the quotient is q0, the round bit is 1 if l >= y0 / 2, and sticky_bit are\n    // the remaining bits from l. If increment_exp, the quotient is HIGH_BIT + (q >> 1), the round\n    // bit is the least significant bit of q, and sticky_bit is lo.\n    let round_bit;\n    let (quotient, sticky_bit) = if increment_exp {\n        round_bit = q.odd();\n        (LIMB_HIGH_BIT | (q >> 1), lo)\n    } else {\n        // If \"lo + lo < lo\", then there is a carry in lo + lo, thus 2 * lo > y. Otherwise if there\n        // is no carry, we check whether 2 * lo >= v0.\n        let two_lo = lo << 1;\n        round_bit = (two_lo < lo) || (two_lo >= y);\n        (\n            q,\n            if round_bit {\n                two_lo.wrapping_sub(y)\n            } else {\n                lo\n            },\n        )\n    };\n    if !round_bit && sticky_bit == 0 {\n        return (quotient, increment_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float division\"),\n        Nearest => {\n            if !round_bit || sticky_bit == 0 && quotient.even() {\n                (quotient, increment_exp, Less)\n            } else {\n                (quotient.wrapping_add(1), increment_exp, Greater)\n            }\n        }\n        Floor | Down => (quotient, increment_exp, Less),\n        Ceiling | Up => (quotient.wrapping_add(1), increment_exp, Greater),\n    }\n}\n\n// Given x = x_1 * B + x_0 < y = y_1 * B + y_0 with y normalized (high bit of y_1 set), put in q =\n// Q1\n// * B + Q0 an approximation of floor(x * B ^ 2 / y), with: B = 2 ^ WIDTH and q <= floor(x * B ^ 2 /\n// y) <= q + 21.\n//\n// This is mpfr_div2_approx from div.c, MPFR 4.3.0, where Q0 and Q1 are returned.\nfn div_float_2_approx(x_1: Limb, x_0: Limb, y_1: Limb, y_0: Limb) -> (Limb, Limb) {\n    // First compute an approximation of q_1, using a lower approximation of B ^ 2 / (y_1 + 1) - B\n    let inv = if y_1 == Limb::MAX {\n        0\n    } else {\n        limbs_invert_limb::<DoubleLimb, Limb>(y_1 + 1)\n    };\n    // Now inv <= B ^ 2 / (y_1 + 1) - B.\n    let mut q_1 =\n        Limb::wrapping_from((DoubleLimb::from(x_1) * DoubleLimb::from(inv)) >> Limb::WIDTH);\n    q_1.wrapping_add_assign(x_1);\n    // Now q_1 <= x_1 * B / (y_1 + 1) < (x_1 * B + x_0) * B / (y_1 * B + y_0).\n    //\n    // Compute q_1 * (y_1 * B + y_0) into r_1 : r_0 : yy and subtract from u_1 : x_0 : 0.\n    let (mut r_1, mut r_0) = Limb::x_mul_y_to_zz(q_1, y_1);\n    let (xx, yy) = Limb::x_mul_y_to_zz(q_1, y_0);\n    if r_0.overflowing_add_assign(xx) {\n        r_1.wrapping_add_assign(1);\n    }\n    // We ignore yy below, but first increment r_0, to ensure we get a lower approximation of the\n    // remainder.\n    if yy != 0 {\n        r_0.wrapping_add_assign(1);\n    }\n    if r_0 == 0 && yy != 0 {\n        r_1.wrapping_add_assign(1);\n    }\n    r_1 = x_1.wrapping_sub(r_1);\n    let carry;\n    (r_0, carry) = x_0.overflowing_sub(r_0);\n    if carry {\n        r_1.wrapping_sub_assign(1);\n    }\n    // r_1 : r_0 should be non-negative.\n    assert!(!r_1.get_highest_bit());\n    // The second quotient limb is approximated by (r_1 * B ^ 2 + r_0 * B) / y_1, and since (B +\n    // inv) / B approximates B / y_1, this is in turn approximated by (r * B + r_0) * (B + inv) / B\n    // = r_1 * B * r_1 * inv + r_0 + (r0 * inv / B).\n    q_1.wrapping_add_assign(r_1);\n    // Add floor(r_0 * inv / B) to q_0.\n    if r_0.overflowing_add_assign(Limb::wrapping_from(\n        (DoubleLimb::from(r_0) * DoubleLimb::from(inv)) >> Limb::WIDTH,\n    )) {\n        q_1.wrapping_add_assign(1);\n    }\n    assert!(r_1 <= 4);\n    for _ in 0..r_1 {\n        if r_0.overflowing_add_assign(inv) {\n            q_1.wrapping_add_assign(1);\n        }\n    }\n    (q_1, r_0)\n}\n\n// This is mpfr_div_2 from div.c, MPFR 4.3.0, where Q1 and Q0 are returned.\nfn div_float_significands_same_prec_gt_w_lt_2w(\n    mut x_0: Limb,\n    mut x_1: Limb,\n    y_0: Limb,\n    y_1: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, bool, Ordering) {\n    let shift = TWICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    let increment_exp = x_1 > y_1 || (x_1 == y_1 && x_0 >= y_0);\n    if increment_exp {\n        (x_1, x_0) = Limb::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0);\n    }\n    assert!(x_1 < y_1 || (x_1 == y_1 && x_0 < y_0));\n    let (mut q_1, mut q_0) = div_float_2_approx(x_1, x_0, y_1, y_0);\n    // We know q1 * B + q0 is smaller or equal to the exact quotient, with difference at most 21.\n    let mut sticky_bit = if (q_0.wrapping_add(21)) & (mask >> 1) > 21 {\n        // The result is not exact when we can round with an approximation.\n        1\n    } else {\n        // We know q_1 : q_0 is a good-enough approximation, so use it!\n        //\n        // Since we know the difference should be at most 21 * (y_1 : y_0) after the subtraction\n        // below, thus at most 21 * 2 ^ 128, it suffices to compute the lower 3 limbs of (q_1 : q_0)\n        // * (y_1 : y_0).\n        let (mut s_1, mut s_0) = Limb::x_mul_y_to_zz(q_0, y_0);\n        let (mut s_2, mut lo) = Limb::x_mul_y_to_zz(q_0, y_1);\n        if s_1.overflowing_add_assign(lo) {\n            s_2.wrapping_add_assign(1);\n        }\n        let hi;\n        (hi, lo) = Limb::x_mul_y_to_zz(q_1, y_0);\n        s_2.wrapping_add_assign(hi);\n        if s_1.overflowing_add_assign(lo) {\n            s_2.wrapping_add_assign(1);\n        }\n        s_2.wrapping_add_assign(q_1.wrapping_mul(y_1));\n        // Subtract s_2 : s_1 : s_0 from x_0 : 0 : 0, with result in s_2 : s_1 : s_0.\n        s_2 = x_0.wrapping_sub(s_2);\n        // Now negate s_1 : s_0.\n        s_1.wrapping_neg_assign();\n        if s_0.overflowing_neg_assign() {\n            s_1.wrapping_sub_assign(1);\n        }\n        // There is a borrow in s_2 when s_0 and s_1 are not both zero.\n        if s_1 != 0 || s_0 != 0 {\n            s_2.wrapping_sub_assign(1);\n        }\n        while s_2 > 0 || s_1 > y_1 || (s_1 == y_1 && s_0 >= y_0) {\n            // Add 1 to q_1 : q_0.\n            if q_0.overflowing_add_assign(1) {\n                q_1.wrapping_add_assign(1);\n            }\n            // Subtract y_1 : y_0 to s_2 : s_1 : s_0\n            if (s_1 < y_1) || (s_1 == y_1 && s_0 < y_0) {\n                s_2.wrapping_sub_assign(1);\n            }\n            (s_1, s_0) = Limb::xx_sub_yy_to_zz(s_1, s_0, y_1, y_0);\n        }\n        s_1 | s_0\n    };\n    if increment_exp {\n        sticky_bit |= q_0 & 1;\n        q_0 = (q_1 << WIDTH_M1) | (q_0 >> 1);\n        q_1 = LIMB_HIGH_BIT | (q_1 >> 1);\n    }\n    let round_bit = q_0 & (shift_bit >> 1);\n    sticky_bit |= (q_0 & mask) ^ round_bit;\n    let mut z_1 = q_1;\n    let mut z_0 = q_0 & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z_0, z_1, increment_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float division\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && (z_0 & shift_bit) == 0) {\n                (z_0, z_1, increment_exp, Less)\n            } else if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, increment_exp, Greater)\n            }\n        }\n        Floor | Down => (z_0, z_1, increment_exp, Less),\n        Ceiling | Up => {\n            if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, increment_exp, Greater)\n            }\n        }\n    }\n}\n\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, assuming the\n// highest bit of `d` is set.\nfn limbs_div_limb_to_out_mod_with_fraction(\n    out: &mut [Limb],\n    fraction_len: usize,\n    ns: &[Limb],\n    d: Limb,\n) -> Limb {\n    assert_ne!(d, 0);\n    let len = ns.len().checked_add(fraction_len).unwrap();\n    assert_ne!(len, 0);\n    let out = &mut out[..len];\n    assert!(d.get_highest_bit());\n    // High quotient limb is 0 or 1, skip a divide step.\n    let (r, ns_init) = ns.split_last().unwrap();\n    let mut r = *r;\n    let (out_last, out_init) = out.split_last_mut().unwrap();\n    let adjust = r >= d;\n    if adjust {\n        r -= d;\n    }\n    *out_last = Limb::from(adjust);\n    // Multiply-by-inverse, divisor already normalized.\n    let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n    let (out_lo, out_hi) = out_init.split_at_mut(fraction_len);\n    for (out_q, &n) in out_hi.iter_mut().zip(ns_init.iter()).rev() {\n        (*out_q, r) = div_mod_by_preinversion(r, n, d, d_inv);\n    }\n    for out_q in out_lo.iter_mut().rev() {\n        (*out_q, r) = div_mod_by_preinversion(r, 0, d, d_inv);\n    }\n    r\n}\n\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, assuming the\n// highest bit of `d` is set.\nfn limbs_div_limb_in_place_mod_with_fraction(\n    ns: &mut [Limb],\n    ns_len: usize,\n    fraction_len: usize,\n    d: Limb,\n) -> Limb {\n    assert_ne!(d, 0);\n    let len = ns_len.checked_add(fraction_len).unwrap();\n    assert_ne!(len, 0);\n    let ns = &mut ns[..len];\n    assert!(d.get_highest_bit());\n    // High quotient limb is 0 or 1, skip a divide step.\n    let mut r = ns[ns_len - 1];\n    let adjust = r >= d;\n    if adjust {\n        r -= d;\n    }\n    ns.copy_within(..ns_len, fraction_len);\n    let (ns_high, ns_init) = ns.split_last_mut().unwrap();\n    *ns_high = Limb::from(adjust);\n    // Multiply-by-inverse, divisor already normalized.\n    let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n    let (ns_lo, ns_hi) = ns_init.split_at_mut(fraction_len);\n    for n in ns_hi.iter_mut().rev() {\n        (*n, r) = div_mod_by_preinversion(r, *n, d, d_inv);\n    }\n    for n in ns_lo.iter_mut().rev() {\n        (*n, r) = div_mod_by_preinversion(r, 0, d, d_inv);\n    }\n    r\n}\n\n// This is mpfr_div_ui from div_ui.c, MPFR 4.3.0.\nfn div_float_significands_long_by_short(\n    xs: &[Limb],\n    y: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Vec<Limb>, u64, Ordering) {\n    let out_len = bit_to_limb_count_ceiling(prec);\n    let mut out = vec![0; out_len + 1];\n    let (exp_offset, o) = div_float_significands_long_by_short_to_out(&mut out, xs, y, prec, rm);\n    out.truncate(out_len);\n    (out, exp_offset, o)\n}\n\n// y cannot be a power of 2.\n//\n// This is mpfr_div_ui from div_ui.c, MPFR 4.3.0.\nfn div_float_significands_long_by_short_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    y: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    let xs_len = xs.len();\n    let out_ge_xs = out.len() >= xs_len;\n    let diff = out.len().abs_diff(xs_len);\n    // We need to store out_len + 1 = xs_len + diff limbs of the quotient.\n    let (c, mut sticky_bit) = if out_ge_xs {\n        // used the entire dividend\n        //\n        // X = ({scratch, xs_len + diff} * y + c) * B ^ (-diff} = ({scratch, out_len + 1} * y + c) *\n        // B ^ (-dif)\n        (limbs_div_limb_to_out_mod_with_fraction(out, diff, xs, y), 0)\n    } else {\n        // dif < 0, i.e. xs_len > out_len + 1; ignore the (-diff) low limbs from x\n        //\n        // {xs - dif, out_len + 1} = {scratch, out_len + 1} * y + c, thus X = {xs, -dif} + {xs -\n        // diff, out_len + 1} * B ^ (-diff) = {xp, -diff} + ({scratch, out_len + 1} * y + c) * B ^\n        // (-dif)\n        let (xs_lo, xs_hi) = xs.split_at(diff);\n        (\n            limbs_div_limb_to_out_mod(out, xs_hi, y),\n            Limb::from(!slice_test_zero(xs_lo)),\n        )\n    };\n    // Let r = {xp, -diff} / B ^ (-diff) if diff < 0, r = 0 otherwise; 0 <= r < 1.\n    //\n    // Then X = ({scratch, out_len + 1} * y + c + r) * B ^ (-dif). x / y = (X / y) * B ^ (-xs_len) *\n    // 2 ^ exp = ({scratch, out_len + 1} + (c + r) / y) * B ^ (-(out_len + 1)) * 2 ^ exp where 0 <=\n    // (c + r) / y < 1.\n    //\n    // sticky_bit != 0 iff r != 0\n    //\n    // If the highest limb of the result is 0 (xs[xs_len - 1] < y), remove it. Otherwise, compute\n    // the left shift to be performed to normalize. In the latter case, we discard some low bits\n    // computed. They contain information useful for the rounding, hence the updating of middle and\n    // inexact.\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_mask = shift_bit - 1;\n    let out_head = out[0];\n    let out_last = *out.last().unwrap();\n    let round_bit;\n    let mut exp_offset = if out_last == 0 {\n        // round bit is 1 iff (c + r) / u >= 1/2\n        if shift == 0 {\n            // In this case scratch[out_len] = 0 and shift = 0, the round bit is not in {scratch,\n            // out_len + 1}. It is 1 iff 2 * (c + r) - y >= 0. This means that in some cases, we\n            // should look at the most significant bit of r.\n            if c >= y - c {\n                // i.e. 2 * c >= y: round bit is always 1\n                round_bit = 1;\n                // The sticky bit is 1 unless 2 * c - y = 0 and r = 0.\n                sticky_bit |= (c << 1).wrapping_sub(y);\n            } else {\n                // 2 * c < y\n                //\n                // The round bit is 1 iff r >= 1 / 2 and 2 * (c + 1 / 2) = y.\n                let xdm1 = if diff == 0 {\n                    0\n                } else {\n                    xs.get(diff - 1).copied().unwrap_or_default()\n                };\n                round_bit = Limb::from(c == y >> 1 && !out_ge_xs && xdm1.get_highest_bit());\n                // If round_bit is set, we need to recompute sticky_bit, since it might have taken\n                // into account the most-significant bit of xs[-diff - 1].\n                if round_bit != 0 {\n                    fail_on_untested_path(\"div_float_significands_long_by_short, round_bit != 0\");\n                    sticky_bit = xdm1 << 1; // discard the most significant bit\n                    if sticky_bit == 0 && !slice_test_zero(&xs[..diff]) {\n                        sticky_bit = 1;\n                    }\n                } else {\n                    sticky_bit |= c;\n                }\n            }\n        } else {\n            // round bit is in scratch[0]\n            round_bit = out_head & (shift_bit >> 1);\n            sticky_bit |= (out_head & (shift_mask >> 1)) | c;\n        }\n        0\n    } else {\n        // scratch[out_len] != 0\n        assert_ne!(out_last, 0);\n        let shift_2 = LeadingZeros::leading_zeros(out_last);\n        let comp_shift_2 = Limb::WIDTH - shift_2;\n        assert!(y >= 2); // see special cases at the beginning\n        assert_ne!(shift_2, 0); // since y >= 2, shift left to normalize\n        let old_head_1 = out_head >> comp_shift_2;\n        let old_head_2 = out_head << shift_2;\n        out.copy_within(1.., 0);\n        limbs_slice_shl_in_place(out, shift_2);\n        let out_head = out.first_mut().unwrap();\n        *out_head |= old_head_1;\n        // now Y is the approximate quotient, w is the next limb.\n        let w = old_head_2;\n        if shift == 0 {\n            // round bit is upper bit from w\n            round_bit = w & LIMB_HIGH_BIT;\n            sticky_bit |= (w - round_bit) | c;\n        } else {\n            round_bit = *out_head & (shift_bit >> 1);\n            sticky_bit |= (*out_head & (shift_mask >> 1)) | w | c;\n        }\n        comp_shift_2\n    };\n    // Clear the lowest `shift` bits\n    out[0] &= !shift_mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (exp_offset, Equal);\n    }\n    let (_, out) = out.split_last_mut().unwrap();\n    match rm {\n        Exact => panic!(\"Inexact float division\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && (out[0] & shift_bit) == 0) {\n                (exp_offset, Less)\n            } else {\n                if limbs_slice_add_limb_in_place(out, shift_bit) {\n                    exp_offset += 1;\n                    *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n                }\n                (exp_offset, Greater)\n            }\n        }\n        Floor | Down => (exp_offset, Less),\n        Ceiling | Up => {\n            if limbs_slice_add_limb_in_place(out, shift_bit) {\n                exp_offset += 1;\n                *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n            }\n            (exp_offset, Greater)\n        }\n    }\n}\n\n// y cannot be a power of 2. The returned offset is in [0, Limb::WIDTH + 1].\n//\n// This is mpfr_div_ui from div_ui.c, MPFR 4.3.0.\nfn div_float_significands_long_by_short_in_place(\n    xs: &mut Vec<Limb>,\n    y: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    let xs_len = xs.len();\n    let out_len = bit_to_limb_count_ceiling(prec);\n    let out_ge_xs = out_len + 1 >= xs_len;\n    let diff = (out_len + 1).abs_diff(xs_len);\n    let x_lo_nonzero = diff < xs_len && !slice_test_zero(&xs[..diff]);\n    let xdm1 = if diff == 0 {\n        0\n    } else {\n        xs.get(diff - 1).copied().unwrap_or_default()\n    };\n    // We need to store out_len + 1 = xs_len + diff limbs of the quotient.\n    let (c, mut sticky_bit) = if out_ge_xs {\n        // used the entire dividend\n        //\n        // X = ({scratch, xs_len + diff} * y + c) * B ^ (-diff} = ({scratch, out_len + 1} * y + c) *\n        // B ^ (-dif)\n        xs.resize(out_len + 1, 0);\n        (\n            limbs_div_limb_in_place_mod_with_fraction(xs, xs_len, diff, y),\n            0,\n        )\n    } else {\n        // dif < 0, i.e. xs_len > out_len + 1; ignore the (-diff) low limbs from x\n        //\n        // {xs - dif, out_len + 1} = {scratch, out_len + 1} * y + c, thus X = {xs, -dif} + {xs -\n        // diff, out_len + 1} * B ^ (-diff) = {xp, -diff} + ({scratch, out_len + 1} * y + c) * B ^\n        // (-dif)\n        let p = (\n            limbs_div_limb_in_place_mod(&mut xs[diff..], y),\n            Limb::from(x_lo_nonzero),\n        );\n        xs.drain(..diff);\n        p\n    };\n    // Let r = {xp, -diff} / B ^ (-diff) if diff < 0, r = 0 otherwise; 0 <= r < 1.\n    //\n    // Then X = ({scratch, out_len + 1} * y + c + r) * B ^ (-dif). x / y = (X / y) * B ^ (-xs_len) *\n    // 2 ^ exp = ({scratch, out_len + 1} + (c + r) / y) * B ^ (-(out_len + 1)) * 2 ^ exp where 0 <=\n    // (c + r) / y < 1.\n    //\n    // sticky_bit != 0 iff r != 0\n    //\n    // If the highest limb of the result is 0 (xs[xs_len - 1] < y), remove it. Otherwise, compute\n    // the left shift to be performed to normalize. In the latter case, we discard some low bits\n    // computed. They contain information useful for the rounding, hence the updating of middle and\n    // inexact.\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_mask = shift_bit - 1;\n    let xs_head = xs[0];\n    let xs_last = *xs.last().unwrap();\n    let round_bit;\n    let mut exp_offset = if xs_last == 0 {\n        // round bit is 1 iff (c + r) / u >= 1/2\n        if shift == 0 {\n            // In this case scratch[out_len] = 0 and shift = 0, the round bit is not in {scratch,\n            // out_len + 1}. It is 1 iff 2 * (c + r) - y >= 0. This means that in some cases, we\n            // should look at the most significant bit of r.\n            if c >= y - c {\n                // i.e. 2 * c >= y: round bit is always 1\n                round_bit = 1;\n                // The sticky bit is 1 unless 2 * c - y = 0 and r = 0.\n                sticky_bit |= (c << 1).wrapping_sub(y);\n            } else {\n                // 2 * c < y\n                //\n                // The round bit is 1 iff r >= 1 / 2 and 2 * (c + 1 / 2) = y.\n                round_bit = Limb::from(c == y >> 1 && !out_ge_xs && xdm1.get_highest_bit());\n                // If round_bit is set, we need to recompute sticky_bit, since it might have taken\n                // into account the most-significant bit of xs[-diff - 1].\n                if round_bit != 0 {\n                    fail_on_untested_path(\"div_float_significands_long_by_short, round_bit != 0\");\n                    sticky_bit = xdm1 << 1; // discard the most significant bit\n                    if sticky_bit == 0 && x_lo_nonzero {\n                        sticky_bit = 1;\n                    }\n                } else {\n                    sticky_bit |= c;\n                }\n            }\n        } else {\n            // round bit is in scratch[0]\n            round_bit = xs_head & (shift_bit >> 1);\n            sticky_bit |= (xs_head & (shift_mask >> 1)) | c;\n        }\n        0\n    } else {\n        // scratch[out_len] != 0\n        assert_ne!(xs_last, 0);\n        let shift_2 = LeadingZeros::leading_zeros(xs_last);\n        let comp_shift_2 = Limb::WIDTH - shift_2;\n        assert!(y >= 2); // see special cases at the beginning\n        assert_ne!(shift_2, 0); // since y >= 2, shift left to normalize\n        let old_head_1 = xs_head >> comp_shift_2;\n        let old_head_2 = xs_head << shift_2;\n        xs.copy_within(1.., 0);\n        limbs_slice_shl_in_place(xs, shift_2);\n        let xs_head = xs.first_mut().unwrap();\n        *xs_head |= old_head_1;\n        // now Y is the approximate quotient, w is the next limb.\n        let w = old_head_2;\n        if shift == 0 {\n            // round bit is upper bit from w\n            round_bit = w & LIMB_HIGH_BIT;\n            sticky_bit |= (w - round_bit) | c;\n        } else {\n            round_bit = *xs_head & (shift_bit >> 1);\n            sticky_bit |= (*xs_head & (shift_mask >> 1)) | w | c;\n        }\n        comp_shift_2\n    };\n    // Clear the lowest `shift` bits\n    xs[0] &= !shift_mask;\n    xs.truncate(out_len);\n    if round_bit == 0 && sticky_bit == 0 {\n        return (exp_offset, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float division\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && (xs[0] & shift_bit) == 0) {\n                (exp_offset, Less)\n            } else {\n                if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                    exp_offset += 1;\n                    *xs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                }\n                (exp_offset, Greater)\n            }\n        }\n        Floor | Down => (exp_offset, Less),\n        Ceiling | Up => {\n            if limbs_slice_add_limb_in_place(xs, shift_bit) {\n                exp_offset += 1;\n                *xs.last_mut().unwrap() = LIMB_HIGH_BIT;\n            }\n            (exp_offset, Greater)\n        }\n    }\n}\n\npub(crate) const MPFR_DIVHIGH_TAB: [i8; 17] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\n// This is `mpn_divrem` from `mpn/divrem.c`, GMP 6.2.1, where qxn is 0.\npub(crate) fn limbs_div_helper(qs: &mut [Limb], ns: &mut [Limb], ds: &[Limb]) -> bool {\n    let ns_len = ns.len();\n    let ds_len = ds.len();\n    assert!(ns_len >= ds_len);\n    assert_ne!(ds_len, 0);\n    assert!(ds[ds_len - 1].get_highest_bit());\n    if ds_len == 2 {\n        limbs_div_mod_by_two_limb_normalized(qs, ns, ds)\n    } else {\n        let qs_len = ns_len - ds_len + 1;\n        let mut scratch = vec![0; qs_len];\n        if ds_len == 1 {\n            ns[0] = limbs_div_limb_to_out_mod(&mut scratch, ns, ds[0]);\n        } else {\n            limbs_div_mod_qs_to_out_rs_to_ns(&mut scratch, ns, ds);\n        }\n        let (scratch_last, scratch_init) = scratch.split_last().unwrap();\n        qs[..qs_len - 1].copy_from_slice(scratch_init);\n        assert!(*scratch_last < 2);\n        *scratch_last != 0\n    }\n}\n\npub(crate) fn limbs_float_div_high_scratch_len(ds_len: usize) -> usize {\n    let k = if ds_len < MPFR_DIVHIGH_TAB.len() {\n        usize::exact_from(MPFR_DIVHIGH_TAB[ds_len])\n    } else {\n        (ds_len / 3) << 1\n    };\n    if k == 0 {\n        0\n    } else {\n        let l = ds_len - k;\n        (l << 1) + limbs_float_mul_high_same_length_scratch_len(l)\n    }\n}\n\n// Put in {qs, len} an approximation of N = {ns, 2 * len} divided by D = {ds, len},\n//\n// with the most significant limb of the quotient as return value (0 or 1). Assumes the most\n// significant bit of D is set. Clobbers N.\n//\n// This implements the ShortDiv algorithm from Short Division of Long Integers, David Harvey and\n// Paul Zimmermann, Proceedings of the 20th Symposium on Computer Arithmetic (ARITH-20), July 25-27,\n// 2011, pages 7-14.\n//\n// Assumes len >= 2 (which should be fulfilled also in the recursive calls).\n//\n// This is mpfr_divhigh_n from mulders.c, MPFR 4.2.0.\npub(crate) fn limbs_float_div_high(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) -> bool {\n    let len = ds.len();\n    const LENGTH_VALID: bool = MPFR_DIVHIGH_TAB.len() >= 15;\n    assert!(LENGTH_VALID); // so that 2*(n/3) >= (n+4)/2\n    assert!(len >= 2);\n    let k = if len < MPFR_DIVHIGH_TAB.len() {\n        usize::exact_from(MPFR_DIVHIGH_TAB[len])\n    } else {\n        (len / 3) << 1\n    };\n    let ns = &mut ns[..len << 1];\n    let qs = &mut qs[..len];\n    if k == 0 {\n        assert!(len > 2, \"must implement mpfr_divhigh_n_basecase\");\n        let inverse = limbs_two_limb_inverse_helper(ds[len - 1], ds[len - 2]);\n        return limbs_div_schoolbook_approx(qs, ns, ds, inverse);\n    }\n    // Check the bounds from. In addition, we forbid k = len - 1, which would give l = 1 in the\n    // recursive call. It follows len >= 5.\n    assert!((len + 4) >> 1 <= k && k < len - 1);\n    let l = len - k;\n    let two_l = l << 1;\n    let two_len_m_k = len + l;\n    // first divide the most significant 2 * k limbs from N by the most significant k limbs of D\n    // exact\n    let (ds_lo, ds_hi) = ds.split_at(l);\n    let mut q_high = limbs_div_helper(&mut qs[l..], &mut ns[two_l..], ds_hi);\n    // It remains {ns, 2 * l + k} = {ns, len + l} as remainder\n    //\n    // now we have to subtract high(Q1) * D0 where Q1 = q_high * B ^ k + {qs + l, k} and D0 = {ds,\n    // l}\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(two_l);\n    limbs_float_mul_high_same_length(scratch_lo, &qs[k..], ds_lo, scratch_hi);\n    // We are only interested in the upper l limbs from {scratch, 2 * l}\n    let ns_mid = &mut ns[len..two_len_m_k];\n    let mut carry = Limb::from(limbs_sub_same_length_in_place_left(\n        ns_mid,\n        &scratch_lo[l..],\n    ));\n    if q_high && limbs_sub_same_length_in_place_left(ns_mid, ds_lo) {\n        carry += 1;\n    }\n    while carry != 0 {\n        // Q1 was too large: subtract 1 from Q1 and add D to ns + l\n        if limbs_sub_limb_in_place(&mut qs[l..], 1) {\n            q_high = false;\n        }\n        if limbs_slice_add_same_length_in_place_left(&mut ns[l..two_len_m_k], ds) {\n            carry -= 1;\n        }\n    }\n    // Now it remains {ns, len + l} to divide by D\n    limbs_float_div_high(qs, &mut ns[k..], &ds[k..], scratch)\n        && limbs_slice_add_limb_in_place(&mut qs[l..], 1)\n        || q_high\n}\n\n// Compare {xs, xs_len} and {ys, ys_len} >> extra, aligned by the more significant limbs. Takes into\n// account ys[0] for extra = true.\n//\n// This is mpfr_mpn_cmp_aux from div.c, MPFR 4.2.0.\npub fn cmp_helper(xs: &[Limb], ys: &[Limb], extra: bool) -> Ordering {\n    let xs_len = xs.len();\n    let mut cmp = Equal;\n    if extra {\n        let ys_len = ys.len() - 1;\n        if xs_len >= ys_len {\n            let (xs_lo, xs_hi) = xs.split_at(xs_len - ys_len);\n            for (i, x) in xs_hi.iter().enumerate().rev() {\n                let y = (ys[i + 1] << WIDTH_M1) | (ys[i] >> 1);\n                cmp = x.cmp(&y);\n                if cmp != Equal {\n                    break;\n                }\n            }\n            let mut y = ys[0] << WIDTH_M1;\n            for x in xs_lo.iter().rev() {\n                if cmp != Equal {\n                    break;\n                }\n                cmp = x.cmp(&y);\n                y = 0; // ensure we consider ys[0] & 1 only once\n            }\n            if cmp == Equal && y != 0 {\n                cmp = Less;\n            }\n        } else {\n            let k = ys_len - xs_len;\n            let ys_hi = &ys[k..];\n            for (i, x) in xs.iter().enumerate().rev() {\n                let y = (ys_hi[i + 1] << WIDTH_M1) | (ys_hi[i] >> 1);\n                cmp = x.cmp(&y);\n                if cmp != Equal {\n                    break;\n                }\n            }\n            for i in (0..k).rev() {\n                if cmp != Equal {\n                    break;\n                }\n                let y = (ys[i + 1] << WIDTH_M1) | (ys[i] >> 1);\n                cmp = if y != 0 { Less } else { Equal };\n            }\n            if cmp == Equal && extra && ys[0].odd() {\n                cmp = Less;\n            }\n        }\n    } else {\n        let ys_len = ys.len();\n        if xs_len >= ys_len {\n            let (xs_lo, xs_hi) = xs.split_at(xs_len - ys_len);\n            cmp = limbs_cmp_same_length(xs_hi, ys);\n            if cmp == Equal && !slice_test_zero(xs_lo) {\n                cmp = Greater;\n            }\n        } else {\n            let (ys_lo, ys_hi) = ys.split_at(ys_len - xs_len);\n            cmp = limbs_cmp_same_length(xs, ys_hi);\n            if cmp == Equal && !slice_test_zero(ys_lo) {\n                cmp = Less;\n            }\n        }\n    }\n    cmp\n}\n\n// xs <- xs - ys >> extra - carry, with carry = 0 or 1. Return borrow out.\n//\n// This is mpfr_mpn_sub_aux from div.c, MPFR 4.2.0.\nfn sub_helper(xs: &mut [Limb], ys: &[Limb], mut carry: bool, extra: bool) -> bool {\n    if extra {\n        for (i, x) in xs.iter_mut().enumerate() {\n            let y = (ys[i + 1] << WIDTH_M1) | (ys[i] >> 1);\n            let mut diff = x.wrapping_sub(y);\n            if carry {\n                diff.wrapping_sub_assign(1);\n            }\n            carry = *x < y || carry && diff == Limb::MAX;\n            *x = diff;\n        }\n    } else {\n        for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n            let mut diff = x.wrapping_sub(y);\n            if carry {\n                diff.wrapping_sub_assign(1);\n            }\n            carry = *x < y || carry && diff == Limb::MAX;\n            *x = diff;\n        }\n    }\n    carry\n}\n\n#[inline]\nfn div_float_significands_general(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    prec: u64,\n    rm: RoundingMode,\n) -> (Vec<Limb>, u64, Ordering) {\n    let mut out = vec![0; bit_to_limb_count_ceiling(prec)];\n    let (exp_offset, o) = div_float_significands_general_to_out(&mut out, xs, ys, prec, rm);\n    (out, exp_offset, o)\n}\n\npub(crate) const MPFR_DIV_THRESHOLD: usize = 25;\n\n#[derive(Eq, PartialEq, Clone, Copy)]\npub(crate) enum Cleanup {\n    None,\n    TruncateCheckQHigh,\n    Sub1Ulp,\n    Sub2Ulp,\n}\n\n// TODO special case qs == ds\n//\n// This is mpfr_div from div.c, MPFR 4.2.0, skipping over various special cases\nfn div_float_significands_general_to_out(\n    qs: &mut [Limb],\n    ns: &[Limb],\n    ds: &mut [Limb],\n    prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    let ns_len = ns.len();\n    let ds_len = ds.len();\n    let qs_len = bit_to_limb_count_ceiling(prec);\n    let qs = &mut qs[..qs_len];\n    // Determine if an extra bit comes from the division, i.e. if the significand of X (as a\n    // fraction in [1/2, 1) ) is larger than that of Y\n    let ns_last = *ns.last().unwrap();\n    let ds_last = *ds.last().unwrap();\n    let extra_bit = if ns_last == ds_last {\n        // most significant limbs are equal, must look at further limbs\n        if let Some((n, d)) = ns.iter().rev().zip(ds.iter().rev()).find(|&(n, d)| n != d) {\n            n > d\n        } else if ns_len >= ds_len {\n            // no more divisor limb\n            true\n        } else {\n            // k = 0: no more dividend limb\n            slice_test_zero(&ds[..ds_len - ns_len])\n        }\n    } else {\n        ns_last > ds_last\n    };\n    let mut exp_offset = u64::from(extra_bit);\n    // shift is the number of zero bits in the low limb of the quotient\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let mut shift_bit = Limb::power_of_2(shift);\n    let shift_mask = shift_bit - 1;\n    let mut ys_vec;\n    let mut ys: &mut [Limb];\n    let mut inex;\n    // We first try Mulders' short division (for large operands)\n    if qs_len >= MPFR_DIV_THRESHOLD && ds_len >= MPFR_DIV_THRESHOLD {\n        // We will perform a short (2 * n) / n division\n        let n = qs_len + 1;\n        let two_n = n << 1;\n        // since Mulders' short division clobbers the dividend, we have to copy it\n        let mut xs = vec![0; two_n];\n        if ns_len >= two_n {\n            // truncate the dividend\n            xs[..two_n].copy_from_slice(&ns[ns_len - two_n..]);\n        } else {\n            // zero-pad the dividend\n            xs[two_n - ns_len..].copy_from_slice(ns);\n        }\n        if ds_len >= n {\n            // truncate the divisor\n            ys = &mut ds[ds_len - n..];\n        } else {\n            // zero-pad the divisor\n            ys_vec = vec![0; n];\n            ys = &mut ys_vec;\n            ys[n - ds_len..].copy_from_slice(ds);\n        }\n        // since n = qs_len + 1, we have n >= 2 here\n        let mut scratch = vec![0; n + limbs_float_div_high_scratch_len(n)];\n        let (qs_2, scratch) = scratch.split_at_mut(n);\n        let q_high = limbs_float_div_high(qs_2, &mut xs, &ys[..n], scratch);\n        // in all cases, the error is at most (2 * n + 2) ulps on q_high * B ^ n + {qs_2, n}.\n        let p = i32::exact_from(\n            i64::exact_from(n << Limb::LOG_WIDTH)\n                - i64::exact_from((two_n + 2).ceiling_log_base_2()),\n        );\n        // If rm == Nearest, we need to be able to round with a directed rounding and one more bit.\n        if q_high {\n            let qs_2_lo = &mut qs_2[..n];\n            limbs_slice_shr_in_place(qs_2_lo, 1);\n            *qs_2_lo.last_mut().unwrap() |= LIMB_HIGH_BIT;\n            if round_helper_2(qs_2_lo, p, prec + u64::from(rm == Nearest)) {\n                // We can round correctly whatever the rounding mode\n                qs.copy_from_slice(&qs_2[1..=qs_len]);\n                qs[0] &= !shift_mask; // put to zero low `shift` bits\n                return match rm {\n                    Exact => panic!(\"Inexact float division\"),\n                    Nearest => {\n                        // round to nearest\n                        //\n                        // We know we can round, thus we are never in the even rule case:\n                        // - if the round bit is 0, we truncate\n                        // - if the round bit is 1, we add 1\n                        let round_bit = if shift == 0 {\n                            qs_2[0].get_highest_bit()\n                        } else {\n                            (qs_2[1] >> (shift - 1)).odd()\n                        };\n                        if round_bit {\n                            if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                                exp_offset += 1;\n                                // else exponent is now incorrect, but one will still get an\n                                // overflow\n                                qs[qs_len - 1] = LIMB_HIGH_BIT;\n                            }\n                            (exp_offset, Greater)\n                        } else {\n                            (exp_offset, Less)\n                        }\n                    }\n                    Up | Ceiling => {\n                        if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                            exp_offset += 1;\n                            // else exponent is now incorrect, but one will still get an overflow\n                            *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                        }\n                        (exp_offset, Greater)\n                    }\n                    Down | Floor => (exp_offset, Less),\n                };\n            }\n        }\n    }\n    // Mulders' short division failed: we revert to integer division\n    let mut qs_2_vec = vec![];\n    let mut qs_2: &mut [Limb] = if rm == Nearest && shift == 0 {\n        // We compute the quotient with one more limb, in order to get the round bit in the\n        // quotient, and the remainder only contains sticky bits. Need to allocate memory for the\n        // quotient\n        qs_2_vec = vec![0; qs_len + 1];\n        &mut qs_2_vec\n    } else {\n        qs // directly put the quotient in the destination\n    };\n    let qs_2_len = qs_2.len();\n    let two_qs_2_len = qs_2_len << 1;\n    // prepare the dividend\n    let mut xs = vec![0; two_qs_2_len];\n    let mut sticky_x = false;\n    if two_qs_2_len > ns_len {\n        // use the full dividend\n        let (xs_lo, xs_hi) = xs.split_at_mut(two_qs_2_len - ns_len);\n        if extra_bit {\n            *xs_lo.last_mut().unwrap() = limbs_shr_to_out(xs_hi, ns, 1);\n        } else {\n            xs_hi.copy_from_slice(ns);\n        }\n    } else {\n        // truncate the dividend\n        let (ns_lo, ns_hi) = ns.split_at(ns_len - two_qs_2_len);\n        let ns_hi = &ns_hi[..two_qs_2_len];\n        if extra_bit {\n            sticky_x = limbs_shr_to_out(&mut xs, ns_hi, 1) != 0;\n        } else {\n            xs.copy_from_slice(ns_hi);\n        }\n        sticky_x = sticky_x || !slice_test_zero(ns_lo);\n    }\n    let mut low_x = sticky_x;\n    let mut k;\n    // Now sticky_x is non-zero iff the truncated part of x is non-zero\n    let mut sticky_y = false;\n    // Prepare the divisor\n    k = if ds_len >= qs_2_len {\n        k = ds_len - qs_2_len;\n        sticky_y = sticky_y || !slice_test_zero(&ds[..k]);\n        ys = &mut ds[k..]; // avoid copying the divisor\n        0\n    } else {\n        // ds_len < qs_2_len: small divisor case\n        ys = ds;\n        qs_2_len - ds_len\n    };\n    // Here we perform the real division of {xs + k, two_qs_2_len - k} by {ys, qs_2_len - k} In the\n    // general case (ns_len > 2 * qs_2_len and ds_len > qs_2_len), we have:\n    // ```\n    //   ______________________________________\n    //  |                          |           |   x1 has 2 * qs_2_len limbs\n    //  |             x1           |     x0    |   x0 has ns_len - 2 * qs_2_len limbs\n    //  |__________________________|___________|\n\n    //                  ____________________\n    //                 |           |        |      y1 has qs_2_len limbs\n    //                 |    y1     |    y0  |      y0 has ds_len - qs_2_len limbs\n    //                 |___________|________|\n    // ```\n    //\n    //  We divide x1 by y1, with quotient in q_high + {qs_2, qs_2_len} and remainder (denoted r\n    //  below) stored in place of the low qs_2_len limbs of x1.\n    //\n    // If Mulders' short division failed, we revert to division with remainder\n    let mut q_high = limbs_div_helper(qs_2, &mut xs[k..], &ys[..qs_2_len - k]);\n    // let x1 be the upper part of x, and y1 the upper part of y (with sticky_x and sticky_y\n    // representing the lower parts), then the quotient of x1 by y1 is now in {qs_2, qs_2_len}, with\n    // possible carry in q_high, and the remainder in {xs + k, qs_2_len - k}.\n    //\n    // Warning: q_high may be 1 if x1 == y1, but x < y.\n    k = qs_2_len;\n    sticky_x = sticky_x || !slice_test_zero(&xs[..k]);\n    let mut sticky_bit = Limb::from(sticky_x | sticky_y);\n    // now sticky_bit is non-zero iff one of the following holds:\n    // - the truncated part of u is non-zero\n    // - the truncated part of v is non-zero\n    // - the remainder from division is non-zero\n    let (mut sticky_3, shift_2) = if qs_2_len == qs_len {\n        // does nothing when shift = 0\n        (qs_2[0] & shift_mask, shift)\n    } else {\n        // qs_2_len = qs_len + 1: only happens when rm == Nearest and shift = 0\n        qs.copy_from_slice(&qs_2_vec[1..=qs_len]);\n        qs_2 = &mut qs_2_vec;\n        (qs_2[0], Limb::WIDTH)\n    };\n    qs_2[0] ^= sticky_3;\n    // sticky_3 contains the truncated bits from the quotient, including the round bit, and 1 <=\n    // shift_2 <= WIDTH is the number of bits in sticky_3\n    inex = if sticky_bit != 0 || sticky_3 != 0 {\n        Greater\n    } else {\n        Equal\n    };\n    // to round, we distinguish two cases:\n    // - ds_len <= qs_2_len: we used the full divisor\n    // - ds_len > qs_2_len: the divisor was truncated\n    let mut round_bit = 0;\n    let mut cleanup = Cleanup::None;\n    if ds_len <= qs_2_len {\n        // use the full divisor\n        sticky_bit = if rm == Nearest {\n            round_bit = sticky_3 & Limb::power_of_2(shift_2 - 1);\n            (sticky_3 ^ round_bit) | Limb::from(sticky_x)\n        } else if rm == Floor || rm == Down || inex == Equal {\n            Limb::from(inex != Equal)\n        } else if rm == Exact {\n            panic!(\"Inexact float division\");\n        } else {\n            1\n        };\n    } else {\n        // ds_len > qs_2_len: need to truncate the divisor\n        if inex == Equal {\n            return (exp_offset, Equal);\n        }\n        // We know the estimated quotient is an upper bound of the exact quotient (with rounding\n        // toward zero), with a difference of at most 2 in qs_2[0]. Thus we can round except when\n        // sticky_3 is 000...000 or 000...001 for directed rounding, and 100...000 or 100...001 for\n        // rounding to nearest. (For rounding to nearest, we cannot determine the inexact flag for\n        // 000...000 or 000...001.)\n        let sticky_3_orig = sticky_3;\n        if rm == Nearest {\n            round_bit = sticky_3 & Limb::power_of_2(shift_2 - 1);\n            sticky_3 ^= round_bit;\n        }\n        if sticky_3 > 1 {\n            sticky_bit = sticky_3;\n        } else {\n            // hard case: we have to compare q1 * v0 and r + u0, where q1 * v0 has qs_2_len +\n            // (ds_len-qs_2_len) = ds_len limbs, and r + u0 has qs_2_len + (usize-2*qs_2_len) =\n            // usize-qs_2_len limbs\n            let k = ds_len - qs_2_len;\n            // sp <- {qs_2, qs_2_len} * {ds, ds_len - qs_2_len}\n            let mut scratch = vec![0; ds_len + limbs_mul_to_out_scratch_len(qs_2_len, k)];\n            let (sp, scratch) = scratch.split_at_mut(ds_len);\n            qs_2[0] ^= sticky_3_orig; // restore original quotient\n            let ds_lo = &ds[..k];\n            limbs_mul_to_out(sp, qs_2, ds_lo, scratch);\n            let q_high_2 = if q_high {\n                limbs_slice_add_same_length_in_place_left(&mut sp[qs_2_len..], ds_lo)\n            } else {\n                false\n            };\n            qs_2[0] ^= sticky_3_orig;\n            // restore truncated quotient\n            //\n            // Compare q_high_2 + {sp, ds_len} to {xs, qs_2_len} + u0\n            let (sp_lo, sp_hi) = sp.split_at_mut(k);\n            let mut cmp_s_r = if q_high_2 {\n                Greater\n            } else {\n                limbs_cmp_same_length(sp_hi, &xs[..qs_2_len])\n            };\n            if cmp_s_r == Equal {\n                // compare {sp, k} and u0\n                cmp_s_r = if ns_len >= two_qs_2_len {\n                    cmp_helper(\n                        sp_lo,\n                        &ns[..ns_len - two_qs_2_len + usize::from(extra_bit)],\n                        extra_bit,\n                    )\n                } else if slice_test_zero(sp_lo) {\n                    Equal\n                } else {\n                    Greater\n                };\n            }\n            // now\n            // - cmp_s_r > 0 if {sp, ds_len} > {xs, qs_2_len} + u0\n            // - cmp_s_r = 0 if {sp, ds_len} = {xs, qs_2_len} + u0\n            // - cmp_s_r < 0 if {sp, ds_len} < {xs, qs_2_len} + u0\n            if cmp_s_r <= Equal {\n                // quotient is in [q1, q1+1)\n                sticky_bit = if cmp_s_r == Equal { sticky_3 } else { 1 };\n            } else {\n                // cmp_s_r > 0, quotient is < q1: to determine if it is in [q1 - 2, q1 - 1] or in\n                // [q1 - 1, q1], we need to subtract the low part u0 of the dividend from q*v0\n                let mut carry = false;\n                // subtract u0 >> extra_bit if non-zero\n                if q_high_2 {\n                    // whatever the value of {ns, m + k}, it will be smaller than q_high_2 + {sp, k}\n                    cmp_s_r = Greater;\n                } else {\n                    if low_x {\n                        let l = ns_len - two_qs_2_len; // number of limbs in u0\n                        let m = l.saturating_sub(k);\n                        carry = extra_bit && ns[m].odd();\n                        if l >= k {\n                            // u0 has at least as many limbs than s: first look if {ns, m} is not\n                            // zero, and compare {sp, k} and {ns + m, k}\n                            if !carry {\n                                carry = !slice_test_zero(&ns[..m]);\n                            }\n                            low_x = carry;\n                            carry = sub_helper(\n                                sp_lo,\n                                &ns[m..m + k + usize::from(extra_bit)],\n                                carry,\n                                extra_bit,\n                            );\n                        } else {\n                            // l < k: s has more limbs than u0\n                            low_x = false;\n                            let kml = k - l;\n                            if carry {\n                                carry = limbs_sub_limb_in_place(\n                                    &mut sp_lo[kml - 1..kml],\n                                    LIMB_HIGH_BIT,\n                                );\n                            }\n                            carry = sub_helper(\n                                &mut sp_lo[kml..],\n                                &ns[..l + usize::from(extra_bit)],\n                                carry,\n                                extra_bit,\n                            );\n                        }\n                    }\n                    if carry {\n                        limbs_sub_limb_in_place(sp_hi, 1);\n                    }\n                    // subtract r\n                    limbs_sub_same_length_in_place_left(sp_hi, &xs[..qs_2_len]);\n                    // now compare {sp, ds_len} to y\n                    cmp_s_r = limbs_cmp_same_length(sp, ds);\n                    if cmp_s_r == Equal && low_x {\n                        cmp_s_r = Greater;\n                        // since in fact we subtracted less than 1\n                    }\n                }\n                if cmp_s_r <= Equal {\n                    // q1 - 1 <= x / y < q1\n                    if sticky_3 == 1 {\n                        // q1 - 1 is either representable (directed rounding), or the middle of two\n                        // numbers (nearest)\n                        sticky_bit = Limb::from(cmp_s_r != Equal);\n                    } else if round_bit == 0 {\n                        // round_bit=0, sticky_3=0: q1 - 1 is exact only when sh=0\n                        inex = if cmp_s_r != Equal || shift != 0 {\n                            Less\n                        } else {\n                            Equal\n                        };\n                        cleanup = if rm == Nearest || ((rm == Ceiling || rm == Up) && inex != Equal)\n                        {\n                            inex = Greater;\n                            Cleanup::TruncateCheckQHigh\n                        } else if inex != Equal && rm == Exact {\n                            panic!(\"Inexact float division\");\n                        } else {\n                            Cleanup::Sub1Ulp\n                        };\n                    } else {\n                        // sticky_3 = 0, round_bit = 1 ==> rounding to nearest\n                        return (exp_offset, cmp_s_r);\n                    }\n                } else {\n                    // q1 - 2 < x / y < q1 - 1\n                    //\n                    // if rm == Nearest, the result is q1 when q1 - 2 >= q1 - 2 ^ (shift - 1), i.e.\n                    // shift >= 2, otherwise (shift = 1) it is q1 - 2\n                    (inex, cleanup) = match rm {\n                        Exact => {\n                            panic!(\"Inexact float division\");\n                        }\n                        Nearest => {\n                            // shift > 0\n                            //\n                            // Case shift = 1: sticky_bit = 0 always, and q1 - round_bit is exactly\n                            // representable, like q1 - round_bit - 2.\n                            // ```\n                            // round_bit action\n                            // 0         subtract two ulps, inex = Less\n                            // 1         truncate, inex = Greater\n                            // ```\n                            //\n                            // Case shift > 1: one ulp is 2 ^ (shift - 1) >= 2\n                            // ```\n                            // round_bit sticky_bit action\n                            // 0         0          truncate, inex = Greater\n                            // 0         1          truncate, inex = Greater\n                            // 1         x          truncate, inex = Less\n                            // ```\n                            if shift == 1 {\n                                if round_bit == 0 {\n                                    shift_bit = 1;\n                                    (Less, Cleanup::Sub2Ulp)\n                                } else {\n                                    (Greater, Cleanup::TruncateCheckQHigh)\n                                }\n                            } else {\n                                (\n                                    if round_bit == 0 { Greater } else { Less },\n                                    Cleanup::TruncateCheckQHigh,\n                                )\n                            }\n                        }\n                        Floor | Down => {\n                            // The result is down(q1 - 2), i.e. subtract one ulp if shift > 0, and\n                            // two ulps if shift = 0\n                            (\n                                Less,\n                                if shift == 0 {\n                                    Cleanup::Sub2Ulp\n                                } else {\n                                    Cleanup::Sub1Ulp\n                                },\n                            )\n                        }\n                        Ceiling | Up => (\n                            Greater,\n                            if shift == 0 {\n                                Cleanup::Sub1Ulp\n                            } else {\n                                Cleanup::TruncateCheckQHigh\n                            },\n                        ),\n                    };\n                }\n            }\n        }\n    }\n    match cleanup {\n        Cleanup::None => {\n            // quotient is in [q1, q1 + 1), round_bit is the round_bit (0 for directed rounding)\n            return if rm == Floor || rm == Down || round_bit == 0 && sticky_bit == 0 {\n                (\n                    exp_offset,\n                    if round_bit == 0 && sticky_bit == 0 {\n                        Equal\n                    } else {\n                        Less\n                    },\n                )\n            } else if rm == Exact {\n                panic!(\"Inexact float division\");\n            } else if rm == Nearest {\n                // sticky_bit != 0 or round != 0\n                if round_bit == 0 {\n                    // necessarily sticky_bit != 0\n                    (exp_offset, Less)\n                } else if sticky_bit != 0 {\n                    if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                        exp_offset += 1;\n                        // else qexp is now incorrect, but one will still get an overflow\n                        *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                    }\n                    (exp_offset, Greater)\n                } else {\n                    // round_bit = 1, sticky_bit = 0\n                    if qs[0] & shift_bit == 0 {\n                        (exp_offset, Less)\n                    } else {\n                        if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                            exp_offset += 1;\n                            // else qexp is now incorrect, but one will still get an overflow\n                            *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                        }\n                        (exp_offset, Greater)\n                    }\n                }\n            } else {\n                // round away from zero, sticky_bit != 0\n                if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                    exp_offset += 1;\n                    // else qexp is now incorrect, but one will still get an overflow\n                    *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                }\n                (exp_offset, Greater)\n            };\n        }\n        Cleanup::Sub1Ulp => {\n            // we cannot subtract 1 << (shift + 1), since this is undefined for shift = WIDTH\n            if limbs_sub_limb_in_place(qs, shift_bit) {\n                q_high = false;\n            }\n        }\n        Cleanup::Sub2Ulp => {\n            if limbs_sub_limb_in_place(qs, shift_bit) {\n                q_high = false;\n            }\n            if limbs_sub_limb_in_place(qs, shift_bit) {\n                q_high = false;\n            }\n        }\n        _ => {}\n    }\n    if q_high {\n        exp_offset += 1;\n        // else qexp is now incorrect, but one will still get an overflow\n        *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n    }\n    (exp_offset, inex)\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_extras.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 1999-2022 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{limbs_add_limb_to_out, limbs_slice_add_limb_in_place};\nuse crate::natural::{LIMB_HIGH_BIT, Natural, bit_to_limb_count_floor, limb_to_bit_count};\nuse crate::platform::Limb;\nuse core::cmp::min;\nuse malachite_base::num::arithmetic::traits::{NegModPowerOf2, PowerOf2, WrappingSubAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::slice_test_zero;\n\n// This is MPFR_CAN_ROUND from mpfr-impl.h, MPFR 4.2.0.\npub fn float_can_round(x: &Natural, err0: u64, prec: u64, rm: RoundingMode) -> bool {\n    match x {\n        Natural(Small(small)) => limb_float_can_round(*small, err0, prec, rm),\n        Natural(Large(xs)) => limbs_float_can_round(xs, err0, prec, rm),\n    }\n}\n\npub(crate) fn limb_float_can_round(x: Limb, err0: u64, mut prec: u64, rm: RoundingMode) -> bool {\n    if rm == Nearest {\n        prec += 1;\n    }\n    assert!(x.get_highest_bit());\n    let err = min(err0, u64::power_of_2(Limb::LOG_WIDTH));\n    if err <= prec {\n        return false;\n    }\n    let mut s = Limb::WIDTH - (prec & Limb::WIDTH_MASK);\n    let n = bit_to_limb_count_floor(err);\n    // Check first limb\n    let mask = Limb::low_mask(s);\n    let mut tmp = x & mask;\n    s = Limb::WIDTH - (err & Limb::WIDTH_MASK);\n    if n == 0 {\n        // prec and error are in the same limb\n        assert!(s < Limb::WIDTH);\n        tmp >>= s;\n        tmp != 0 && tmp != mask >> s\n    } else if tmp == 0 {\n        // Check if error limb is 0\n        s != Limb::WIDTH && x >> s != 0\n    } else if tmp == mask {\n        // Check if error limb is 0\n        s != Limb::WIDTH && x >> s != Limb::MAX >> s\n    } else {\n        // limb is different from 000000 or 1111111\n        true\n    }\n}\n\npub fn limbs_float_can_round(xs: &[Limb], err0: u64, mut prec: u64, rm: RoundingMode) -> bool {\n    if rm == Nearest {\n        prec += 1;\n    }\n    let len = xs.len();\n    assert!(xs[len - 1].get_highest_bit());\n    let err = min(err0, limb_to_bit_count(len));\n    if err <= prec {\n        return false;\n    }\n    let k = bit_to_limb_count_floor(prec);\n    let mut s = Limb::WIDTH - (prec & Limb::WIDTH_MASK);\n    let n = bit_to_limb_count_floor(err) - k;\n    assert!(len > k);\n    // Check first limb\n    let mut i = len - k - 1;\n    let mask = Limb::low_mask(s);\n    let mut tmp = xs[i] & mask;\n    i.wrapping_sub_assign(1);\n    if n == 0 {\n        // prec and error are in the same limb\n        s = Limb::WIDTH - (err & Limb::WIDTH_MASK);\n        assert!(s < Limb::WIDTH);\n        tmp >>= s;\n        tmp != 0 && tmp != mask >> s\n    } else if tmp == 0 {\n        // Check if all (n - 1) limbs are 0\n        let j = i.wrapping_add(2) - n;\n        if n > 1 && xs[j..=i].iter().any(|&x| x != 0) {\n            return true;\n        }\n        // Check if final error limb is 0\n        s = Limb::WIDTH - (err & Limb::WIDTH_MASK);\n        s != Limb::WIDTH && xs[j - 1] >> s != 0\n    } else if tmp == mask {\n        // Check if all (n - 1) limbs are 11111111111111111\n        let j = i.wrapping_add(2) - n;\n        if n > 1 && xs[j..=i].iter().any(|&x| x != Limb::MAX) {\n            return true;\n        }\n        // Check if final error limb is 0\n        s = Limb::WIDTH - (err & Limb::WIDTH_MASK);\n        s != Limb::WIDTH && xs[j - 1] >> s != Limb::MAX >> s\n    } else {\n        // First limb is different from 000000 or 1111111\n        true\n    }\n}\n\nconst WIDTH_M1_MASK: Limb = Limb::MAX >> 1;\npub(crate) const MPFR_EVEN_INEX: i8 = 2;\n\n// This is MPFR_RNDRAW_EVEN from mpfr-impl.h, MPFR 4.2.0, returning `inexact` and a `bool`\n// signifying whether the returned exponent should be incremented.\npub(crate) fn round_helper_even(\n    out: &mut [Limb],\n    out_prec: u64,\n    xs: &[Limb],\n    x_prec: u64,\n    rm: RoundingMode,\n) -> (i8, bool) {\n    round_helper(out, out_prec, xs, x_prec, rm, |out, xs_hi, ulp| {\n        let ulp_mask = !(ulp - 1);\n        if xs_hi[0] & ulp == 0 {\n            out.copy_from_slice(xs_hi);\n            out[0] &= ulp_mask;\n            (-MPFR_EVEN_INEX, false)\n        } else {\n            let increment = limbs_add_limb_to_out(out, xs_hi, ulp);\n            if increment {\n                *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n            }\n            out[0] &= ulp_mask;\n            (MPFR_EVEN_INEX, increment)\n        }\n    })\n}\n\n// This is MPFR_RNDRAW and mpfr_round_raw from mpfr-impl.h, MPFR 4.2.0, returning `inexact` and a\n// `bool` signifying whether the returned exponent should be incremented.\npub fn round_helper_raw(\n    out: &mut [Limb],\n    out_prec: u64,\n    xs: &[Limb],\n    x_prec: u64,\n    rm: RoundingMode,\n) -> (i8, bool) {\n    round_helper(out, out_prec, xs, x_prec, rm, |out, xs_hi, ulp| {\n        let ulp_mask = !(ulp - 1);\n        if xs_hi[0] & ulp == 0 {\n            out.copy_from_slice(xs_hi);\n            out[0] &= ulp_mask;\n            (-1, false)\n        } else {\n            let increment = limbs_add_limb_to_out(out, xs_hi, ulp);\n            if increment {\n                *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n            }\n            out[0] &= ulp_mask;\n            (1, increment)\n        }\n    })\n}\n\n// This is MPFR_RNDRAW_GEN from mpfr-impl.h, MPFR 4.2.0, returning `inexact` and a `bool` signifying\n// whether the returned exponent should be incremented.\nfn round_helper<F: Fn(&mut [Limb], &[Limb], Limb) -> (i8, bool)>(\n    out: &mut [Limb],\n    out_prec: u64,\n    xs: &[Limb],\n    x_prec: u64,\n    rm: RoundingMode,\n    middle_handler: F,\n) -> (i8, bool) {\n    let xs_len = xs.len();\n    let out_len = out.len();\n    // Check trivial case when out mantissa has more bits than source\n    if out_prec >= x_prec {\n        out[out_len - xs_len..].copy_from_slice(xs);\n        (0, false)\n    } else {\n        // - Nontrivial case: rounding needed\n        // - Compute position and shift\n        let shift = out_prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n        let i = xs_len.checked_sub(out_len).unwrap();\n        let mut sticky_bit;\n        let round_bit;\n        // General case when prec % Limb::WIDTH != 0\n        let ulp = if shift != 0 {\n            // Compute rounding bit and sticky bit\n            //\n            // Note: in directed rounding modes, if the rounding bit is 1, the behavior does not\n            // depend on the sticky bit; thus we will not try to compute it in this case (this can\n            // be much faster and avoids reading uninitialized data in the current mpfr_mul\n            // implementation). We just make sure that sticky_bit is initialized.\n            let mask = Limb::power_of_2(shift - 1);\n            let x = xs[i];\n            round_bit = x & mask;\n            sticky_bit = x & (mask - 1);\n            if rm == Nearest || round_bit == 0 {\n                let mut to = i;\n                let mut n = xs_len - out_len;\n                while n != 0 && sticky_bit == 0 {\n                    to -= 1;\n                    sticky_bit = xs[to];\n                    n -= 1;\n                }\n            }\n            mask << 1\n        } else {\n            assert!(out_len < xs_len);\n            // Compute rounding bit and sticky bit - see note above\n            let x = xs[i - 1];\n            round_bit = x & LIMB_HIGH_BIT;\n            sticky_bit = x & WIDTH_M1_MASK;\n            if rm == Nearest || round_bit == 0 {\n                let mut to = i - 1;\n                let mut n = xs_len - out_len - 1;\n                while n != 0 && sticky_bit == 0 {\n                    to -= 1;\n                    sticky_bit = xs[to];\n                    n -= 1;\n                }\n            }\n            1\n        };\n        let xs_hi = &xs[i..];\n        let ulp_mask = !(ulp - 1);\n        match rm {\n            Floor | Down | Exact => {\n                out.copy_from_slice(xs_hi);\n                out[0] &= ulp_mask;\n                (if sticky_bit | round_bit != 0 { -1 } else { 0 }, false)\n            }\n            Ceiling | Up => {\n                if sticky_bit | round_bit == 0 {\n                    out.copy_from_slice(xs_hi);\n                    out[0] &= ulp_mask;\n                    (0, false)\n                } else {\n                    let increment = limbs_add_limb_to_out(out, xs_hi, ulp);\n                    if increment {\n                        out[out_len - 1] = LIMB_HIGH_BIT;\n                    }\n                    out[0] &= ulp_mask;\n                    (1, increment)\n                }\n            }\n            Nearest => {\n                if round_bit == 0 {\n                    out.copy_from_slice(xs_hi);\n                    out[0] &= ulp_mask;\n                    (if (sticky_bit | round_bit) != 0 { -1 } else { 0 }, false)\n                } else if sticky_bit == 0 {\n                    middle_handler(out, xs_hi, ulp)\n                } else {\n                    let increment = limbs_add_limb_to_out(out, xs_hi, ulp);\n                    if increment {\n                        out[out_len - 1] = LIMB_HIGH_BIT;\n                    }\n                    out[0] &= ulp_mask;\n                    (1, increment)\n                }\n            }\n        }\n    }\n}\n\n// Assuming xs is an approximation of a non-singular number with error at most equal to 2 ^ (EXP(x)\n// - err0) (`err0` bits of x are known) of direction unknown, check if we can round x toward zero\n// with precision prec.\n//\n// This is mpfr_round_p from round_p.c, MPFR 4.2.0.\npub(crate) fn round_helper_2(xs: &[Limb], err0: i32, prec: u64) -> bool {\n    let len = xs.len();\n    assert!(xs.last().unwrap().get_highest_bit());\n    let mut err = limb_to_bit_count(len);\n    if err0 <= 0 {\n        return false;\n    }\n    let err0 = u64::from(err0.unsigned_abs());\n    if err0 <= prec || prec >= err {\n        return false;\n    }\n    err = min(err, err0);\n    let k = bit_to_limb_count_floor(prec);\n    let n = bit_to_limb_count_floor(err) - k;\n    assert!(len > k);\n    // Check first limb\n    let xs = &xs[len - k - n - 1..];\n    let (xs_last, xs_init) = xs[..=n].split_last().unwrap();\n    let mut tmp = *xs_last;\n    let mask = Limb::MAX >> (prec & Limb::WIDTH_MASK);\n    tmp &= mask;\n    if n == 0 {\n        // prec and error are in the same limb\n        let s = Limb::WIDTH - (err & Limb::WIDTH_MASK);\n        assert!(s < Limb::WIDTH);\n        tmp >>= s;\n        tmp != 0 && tmp != mask >> s\n    } else if tmp == 0 {\n        let (xs_head, xs_tail) = xs_init.split_first().unwrap();\n        // Check if all (n - 1) limbs are 0\n        if !slice_test_zero(xs_tail) {\n            return true;\n        }\n        // Check if final error limb is 0\n        let s = Limb::WIDTH - (err & Limb::WIDTH_MASK);\n        s != Limb::WIDTH && *xs_head >> s != 0\n    } else if tmp == mask {\n        let (xs_head, xs_tail) = xs_init.split_first().unwrap();\n        // Check if all (n - 1) limbs are 11111111111111111\n        if xs_tail.iter().any(|&x| x != Limb::MAX) {\n            return true;\n        }\n        // Check if final error limb is 0\n        let s = Limb::WIDTH - (err & Limb::WIDTH_MASK);\n        s != Limb::WIDTH && *xs_head >> s != Limb::MAX >> s\n    } else {\n        // First limb is different from 000000 or 1111111\n        true\n    }\n}\n\n#[inline]\npub fn limbs_significand_slice_add_limb_in_place(xs: &mut [Limb], y: Limb) -> bool {\n    limbs_slice_add_limb_in_place(xs, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 1999-2022 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::float_extras::{limbs_float_can_round, round_helper_raw};\nuse crate::natural::arithmetic::float_square::{\n    limbs_float_square_high, limbs_float_square_high_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out_basecase, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::{LIMB_HIGH_BIT, Natural, bit_to_limb_count_ceiling, limb_to_bit_count};\nuse crate::platform::{DoubleLimb, Limb, MUL_FFT_THRESHOLD};\nuse alloc::vec::Vec;\nuse core::cmp::{\n    Ordering::{self, *},\n    max, min,\n};\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, OverflowingAddAssign, Parity, PowerOf2, Sign, WrappingAddAssign, XMulYToZZ,\n    XXAddYYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{SplitInHalf, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::slice_leading_zeros;\n\n// This is mpfr_mul from mul.c, MPFR 4.2.0.\npub fn mul_float_significands_in_place(\n    x: &mut Natural,\n    x_prec: u64,\n    y: &mut Natural,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    if x_prec == y_prec\n        && out_prec == x_prec\n        && let Some((decrement_exp, o)) =\n            mul_float_significands_in_place_same_prec(x, y, out_prec, rm)\n    {\n        return (-i32::from(decrement_exp), o);\n    }\n    let (product, exp_offset, o) = if x_prec >= y_prec {\n        match (&mut *x, &mut *y) {\n            (Natural(Small(x)), Natural(Small(y))) => {\n                mul_float_significands_general(&[*x], x_prec, &[*y], y_prec, out_prec, rm)\n            }\n            (Natural(Large(xs)), Natural(Small(y))) => {\n                mul_float_significands_general(xs, x_prec, &[*y], y_prec, out_prec, rm)\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                mul_float_significands_general(xs, x_prec, ys, y_prec, out_prec, rm)\n            }\n            _ => unreachable!(),\n        }\n    } else {\n        match (&mut *x, &mut *y) {\n            (Natural(Small(x)), Natural(Small(y))) => {\n                mul_float_significands_general(&[*y], y_prec, &[*x], x_prec, out_prec, rm)\n            }\n            (Natural(Small(x)), Natural(Large(ys))) => {\n                mul_float_significands_general(ys, y_prec, &[*x], x_prec, out_prec, rm)\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                mul_float_significands_general(ys, y_prec, xs, x_prec, out_prec, rm)\n            }\n            _ => unreachable!(),\n        }\n    };\n    *x = product;\n    (exp_offset, o)\n}\n\n// This is mpfr_mul from mul.c, MPFR 4.2.0.\npub fn mul_float_significands_in_place_ref(\n    x: &mut Natural,\n    x_prec: u64,\n    y: &Natural,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    if x_prec == y_prec\n        && out_prec == x_prec\n        && let Some((decrement_exp, o)) =\n            mul_float_significands_in_place_same_prec_ref(x, y, out_prec, rm)\n    {\n        return (-i32::from(decrement_exp), o);\n    }\n    let (product, exp_offset, o) = if x_prec >= y_prec {\n        match (&mut *x, y) {\n            (Natural(Small(x)), Natural(Small(y))) => {\n                mul_float_significands_general(&[*x], x_prec, &[*y], y_prec, out_prec, rm)\n            }\n            (Natural(Large(xs)), Natural(Small(y))) => {\n                mul_float_significands_general(xs, x_prec, &[*y], y_prec, out_prec, rm)\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                mul_float_significands_general(xs, x_prec, ys, y_prec, out_prec, rm)\n            }\n            _ => unreachable!(),\n        }\n    } else {\n        match (&mut *x, y) {\n            (Natural(Small(x)), Natural(Small(y))) => {\n                mul_float_significands_general(&[*y], y_prec, &[*x], x_prec, out_prec, rm)\n            }\n            (Natural(Small(x)), Natural(Large(ys))) => {\n                mul_float_significands_general(ys, y_prec, &[*x], x_prec, out_prec, rm)\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                mul_float_significands_general(ys, y_prec, xs, x_prec, out_prec, rm)\n            }\n            _ => unreachable!(),\n        }\n    };\n    *x = product;\n    (exp_offset, o)\n}\n\n// This is mpfr_mul from mul.c, MPFR 4.2.0.\npub fn mul_float_significands_ref_ref(\n    x: &Natural,\n    x_prec: u64,\n    y: &Natural,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            mul_float_significands_ref_ref_helper(&[*x], x_prec, &[*y], y_prec, out_prec, rm)\n        }\n        (Natural(Large(xs)), Natural(Small(y))) => {\n            mul_float_significands_ref_ref_helper(xs, x_prec, &[*y], y_prec, out_prec, rm)\n        }\n        (Natural(Small(x)), Natural(Large(ys))) => {\n            mul_float_significands_ref_ref_helper(&[*x], x_prec, ys, y_prec, out_prec, rm)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => {\n            mul_float_significands_ref_ref_helper(xs, x_prec, ys, y_prec, out_prec, rm)\n        }\n    }\n}\n\npub(crate) fn mul_float_significands_ref_ref_helper(\n    xs: &[Limb],\n    x_prec: u64,\n    ys: &[Limb],\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    if x_prec == y_prec\n        && out_prec == x_prec\n        && let Some((product, decrement_exp, o)) =\n            mul_float_significands_same_prec_ref_ref(xs, ys, out_prec, rm)\n    {\n        return (product, -i32::from(decrement_exp), o);\n    }\n    if x_prec >= y_prec {\n        mul_float_significands_general(xs, x_prec, ys, y_prec, out_prec, rm)\n    } else {\n        mul_float_significands_general(ys, y_prec, xs, x_prec, out_prec, rm)\n    }\n}\n\nfn mul_float_significands_in_place_same_prec(\n    x: &mut Natural,\n    y: &mut Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(bool, Ordering)> {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (product, decrement_exp, o) = if prec == Limb::WIDTH {\n                mul_float_significands_same_prec_w(*x, *y, rm)\n            } else {\n                mul_float_significands_same_prec_lt_w(*x, *y, prec, rm)\n            };\n            *x = product;\n            Some((decrement_exp, o))\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_mut_slice()) {\n            ([x_0, x_1], [y_0, y_1]) if prec != TWICE_WIDTH => {\n                let (product_0, product_1, decrement_exp, o) =\n                    mul_float_significands_same_prec_gt_w_lt_2w(*x_0, *x_1, *y_0, *y_1, prec, rm);\n                *x_0 = product_0;\n                *x_1 = product_1;\n                Some((decrement_exp, o))\n            }\n            ([x_0, x_1, x_2], [y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (product_0, product_1, product_2, decrement_exp, o) =\n                    mul_float_significands_same_prec_gt_2w_lt_3w(\n                        *x_0, *x_1, *x_2, *y_0, *y_1, *y_2, prec, rm,\n                    );\n                *x_0 = product_0;\n                *x_1 = product_1;\n                *x_2 = product_2;\n                Some((decrement_exp, o))\n            }\n            _ => None,\n        },\n        _ => unreachable!(),\n    }\n}\n\nfn mul_float_significands_in_place_same_prec_ref(\n    x: &mut Natural,\n    y: &Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(bool, Ordering)> {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (product, decrement_exp, o) = if prec == Limb::WIDTH {\n                mul_float_significands_same_prec_w(*x, *y, rm)\n            } else {\n                mul_float_significands_same_prec_lt_w(*x, *y, prec, rm)\n            };\n            *x = product;\n            Some((decrement_exp, o))\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_slice()) {\n            ([x_0, x_1], [y_0, y_1]) if prec != TWICE_WIDTH => {\n                let (product_0, product_1, decrement_exp, o) =\n                    mul_float_significands_same_prec_gt_w_lt_2w(*x_0, *x_1, *y_0, *y_1, prec, rm);\n                *x_0 = product_0;\n                *x_1 = product_1;\n                Some((decrement_exp, o))\n            }\n            ([x_0, x_1, x_2], [y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (product_0, product_1, product_2, decrement_exp, o) =\n                    mul_float_significands_same_prec_gt_2w_lt_3w(\n                        *x_0, *x_1, *x_2, *y_0, *y_1, *y_2, prec, rm,\n                    );\n                *x_0 = product_0;\n                *x_1 = product_1;\n                *x_2 = product_2;\n                Some((decrement_exp, o))\n            }\n            _ => None,\n        },\n        _ => unreachable!(),\n    }\n}\n\nfn mul_float_significands_same_prec_ref_ref(\n    xs: &[Limb],\n    ys: &[Limb],\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(Natural, bool, Ordering)> {\n    match (xs, ys) {\n        ([x], [y]) => {\n            let (product, decrement_exp, o) = if prec == Limb::WIDTH {\n                mul_float_significands_same_prec_w(*x, *y, rm)\n            } else {\n                mul_float_significands_same_prec_lt_w(*x, *y, prec, rm)\n            };\n            Some((Natural(Small(product)), decrement_exp, o))\n        }\n        ([x_0, x_1], [y_0, y_1]) if prec != TWICE_WIDTH => {\n            let (product_0, product_1, decrement_exp, o) =\n                mul_float_significands_same_prec_gt_w_lt_2w(*x_0, *x_1, *y_0, *y_1, prec, rm);\n            Some((Natural(Large(vec![product_0, product_1])), decrement_exp, o))\n        }\n        ([x_0, x_1, x_2], [y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n            let (product_0, product_1, product_2, decrement_exp, o) =\n                mul_float_significands_same_prec_gt_2w_lt_3w(\n                    *x_0, *x_1, *x_2, *y_0, *y_1, *y_2, prec, rm,\n                );\n            Some((\n                Natural(Large(vec![product_0, product_1, product_2])),\n                decrement_exp,\n                o,\n            ))\n        }\n        _ => None,\n    }\n}\n\nconst WIDTH_M1: u64 = Limb::WIDTH - 1;\nconst COMP_HIGH_BIT: Limb = !LIMB_HIGH_BIT;\n\n// This is mpfr_mul_1 from mul.c, MPFR 4.2.0.\nfn mul_float_significands_same_prec_lt_w(\n    x: Limb,\n    y: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, bool, Ordering) {\n    let shift = Limb::WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    let (mut z, mut sticky_bit) = Limb::x_mul_y_to_zz(x, y);\n    let decrement_exp = !z.get_highest_bit();\n    if decrement_exp {\n        z <<= 1;\n        z |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n    }\n    let round_bit = z & (shift_bit >> 1);\n    sticky_bit |= (z & mask) ^ round_bit;\n    let mut product = z & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float multiplication\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && (product & shift_bit) == 0) {\n                (product, decrement_exp, Less)\n            } else if product.overflowing_add_assign(shift_bit) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (product, decrement_exp, Greater)\n            }\n        }\n        Floor | Down => (product, decrement_exp, Less),\n        Ceiling | Up => {\n            if product.overflowing_add_assign(shift_bit) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (product, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\n// This is mpfr_mul_1n from mul.c, MPFR 4.2.0.\nfn mul_float_significands_same_prec_w(\n    x: Limb,\n    y: Limb,\n    rm: RoundingMode,\n) -> (Limb, bool, Ordering) {\n    let (mut z, mut sticky_bit) = Limb::x_mul_y_to_zz(x, y);\n    let decrement_exp = !z.get_highest_bit();\n    if decrement_exp {\n        z <<= 1;\n        z |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n    }\n    let round_bit = sticky_bit & LIMB_HIGH_BIT;\n    sticky_bit &= COMP_HIGH_BIT;\n    let mut product = z;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float multiplication\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && product.even()) {\n                (product, decrement_exp, Less)\n            } else if product.overflowing_add_assign(1) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (product, decrement_exp, Greater)\n            }\n        }\n        Floor | Down => (product, decrement_exp, Less),\n        Ceiling | Up => {\n            if product.overflowing_add_assign(1) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (product, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\nconst TWICE_WIDTH: u64 = Limb::WIDTH * 2;\nconst THRICE_WIDTH: u64 = Limb::WIDTH * 3;\n\n// This is mpfr_mul_2 from mul.c, MPFR 4.2.0.\nfn mul_float_significands_same_prec_gt_w_lt_2w(\n    x_0: Limb,\n    x_1: Limb,\n    y_0: Limb,\n    y_1: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, bool, Ordering) {\n    let shift = TWICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    // we store the 4-limb product in h = z[1], l = z[0], sticky_bit = z[-1], sticky_bit_2 = z[-2]\n    let (mut hi, mut lo) = Limb::x_mul_y_to_zz(x_1, y_1);\n    let (u, v) = Limb::x_mul_y_to_zz(x_1, y_0);\n    if lo.overflowing_add_assign(u) {\n        hi += 1;\n    }\n    let (u, w) = Limb::x_mul_y_to_zz(x_0, y_1);\n    if lo.overflowing_add_assign(u) {\n        hi.wrapping_add_assign(1);\n    }\n    // now the full product is {hi, lo, v + w + high(x_0 * y_0), low(x_0 * y_0)}, where the lower\n    // part contributes to less than 3 ulps to {hi, lo}.\n    //\n    // If hi has its most significant bit set and the low shift - 1 bits of lo are not 000...000 nor\n    // 111...111 nor 111...110, then we can round correctly; if hi has zero as most significant bit,\n    // we have to shift left hi and lo, thus if the low sh-2 bits are not 000...000 nor 111...111\n    // nor 111...110, then we can round correctly. To avoid an extra test we consider the latter\n    // case (if we can round, we can also round in the former case). For shift <= 3, we have mask <=\n    // 7, thus (mask >> 2) <= 1, and the approximation cannot be enough.\n    let (mut sticky_bit, sticky_bit_2);\n    if lo.wrapping_add(2) & (mask >> 2) > 2 {\n        // result cannot be exact in that case\n        sticky_bit = 1;\n        sticky_bit_2 = 1;\n    } else {\n        (sticky_bit, sticky_bit_2) = Limb::x_mul_y_to_zz(x_0, y_0);\n        // The full product is {h, l, sticky_bit + v + w, sticky_bit_2}\n        if sticky_bit.overflowing_add_assign(v) && lo.overflowing_add_assign(1) {\n            hi.wrapping_add_assign(1);\n        }\n        if sticky_bit.overflowing_add_assign(w) && lo.overflowing_add_assign(1) {\n            hi.wrapping_add_assign(1);\n        }\n    }\n    let decrement_exp = !hi.get_highest_bit();\n    if decrement_exp {\n        hi <<= 1;\n        hi |= lo >> WIDTH_M1;\n        lo <<= 1;\n        lo |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n        // no need to shift sticky_bit_2 since we only want to know if it is zero or not\n    }\n    let mut z_1 = hi;\n    let round_bit = lo & (shift_bit >> 1);\n    sticky_bit |= ((lo & mask) ^ round_bit) | sticky_bit_2;\n    let mut z_0 = lo & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z_0, z_1, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float multiplication\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && (z_0 & shift_bit) == 0) {\n                (z_0, z_1, decrement_exp, Less)\n            } else if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, decrement_exp, Greater)\n            }\n        }\n        Floor | Down => (z_0, z_1, decrement_exp, Less),\n        Ceiling | Up => {\n            if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\nconst LIMB_MASK: DoubleLimb = (1 << Limb::WIDTH) - 1;\n\n// This is mpfr_mul_3 from mul.c, MPFR 4.2.0.\nfn mul_float_significands_same_prec_gt_2w_lt_3w(\n    x_0: Limb,\n    x_1: Limb,\n    x_2: Limb,\n    y_0: Limb,\n    y_1: Limb,\n    y_2: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, Limb, bool, Ordering) {\n    let shift = THRICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    // we store the upper 3-limb product in z2, z1, z0: x2 * y2, x2 * y1 + x1 * y2, x2 * y0 + x1 *\n    // y1 + x0 * y2\n    let x_0 = DoubleLimb::from(x_0);\n    let x_1 = DoubleLimb::from(x_1);\n    let x_2 = DoubleLimb::from(x_2);\n    let y_0 = DoubleLimb::from(y_0);\n    let y_1 = DoubleLimb::from(y_1);\n    let y_2 = DoubleLimb::from(y_2);\n    let x_2_y_2 = x_2 * y_2;\n    let x_2_y_1 = x_2 * y_1;\n    let x_1_y_2 = x_1 * y_2;\n    let x_2_y_0 = x_2 * y_0;\n    let x_1_y_1 = x_1 * y_1;\n    let x_0_y_2 = x_0 * y_2;\n    let (mut a2, mut a1) = x_2_y_2.split_in_half();\n    let (hi, mut a0) = x_2_y_1.split_in_half();\n    if a1.overflowing_add_assign(hi) {\n        a2 += 1;\n    }\n    let (hi, lo) = x_1_y_2.split_in_half();\n    if a1.overflowing_add_assign(hi) {\n        a2.wrapping_add_assign(1);\n    }\n    let mut carry = Limb::from(a0.overflowing_add_assign(lo));\n    if a0.overflowing_add_assign(Limb::wrapping_from(x_2_y_0 >> Limb::WIDTH)) {\n        carry += 1;\n    }\n    if a0.overflowing_add_assign(Limb::wrapping_from(x_1_y_1 >> Limb::WIDTH)) {\n        carry += 1;\n    }\n    if a0.overflowing_add_assign(Limb::wrapping_from(x_0_y_2 >> Limb::WIDTH)) {\n        carry += 1;\n    }\n    // now propagate carry\n    if a1.overflowing_add_assign(carry) {\n        a2.wrapping_add_assign(1);\n    }\n    // Now the approximate product {a2, a1, a0} has an error of less than 5 ulps (3 ulps for the\n    // ignored low limbs of x_2 * y_0 + x_1 * y_1 + x_0 * y2, plus 2 ulps for the ignored x_1 * y_0\n    // + x_0 * y_1 (plus x_0 * y_0)). Since we might shift by 1 bit, we make sure the low shift - 2\n    // bits of a0 are not 0, -1, -2, -3 or -4.\n    let (mut sticky_bit, sticky_bit_2) = if a0.wrapping_add(4) & (mask >> 2) > 4 {\n        // result cannot be exact in that case\n        (1, 1)\n    } else {\n        let out = x_0 * y_0;\n        let p_0 = out & LIMB_MASK;\n        let out = x_1 * y_0 + (out >> Limb::WIDTH);\n        let mut p_1 = out & LIMB_MASK;\n        let out = x_2_y_0 + (out >> Limb::WIDTH);\n        let mut p_2 = out & LIMB_MASK;\n        let mut p_3 = out >> Limb::WIDTH;\n        let out = p_1 + x_0 * y_1;\n        p_1 = out & LIMB_MASK;\n        let out = p_2 + x_1_y_1 + (out >> Limb::WIDTH);\n        p_2 = out & LIMB_MASK;\n        let out = p_3 + x_2_y_1 + (out >> Limb::WIDTH);\n        p_3 = out & LIMB_MASK;\n        let p_4 = out >> Limb::WIDTH;\n        let out = p_2 + x_0_y_2;\n        p_2 = out & LIMB_MASK;\n        let out = p_3 + x_1_y_2 + (out >> Limb::WIDTH);\n        p_3 = out & LIMB_MASK;\n        let out = p_4 + x_2_y_2 + (out >> Limb::WIDTH);\n        (a2, a1) = out.split_in_half();\n        a0 = Limb::wrapping_from(p_3);\n        (\n            Limb::wrapping_from(p_2),\n            Limb::wrapping_from(p_1) | Limb::wrapping_from(p_0),\n        )\n    };\n    let decrement_exp = !a2.get_highest_bit();\n    if decrement_exp {\n        a2 <<= 1;\n        a2 |= a1 >> WIDTH_M1;\n        a1 <<= 1;\n        a1 |= a0 >> WIDTH_M1;\n        a0 <<= 1;\n        a0 |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n        // no need to shift sticky_bit_2: we only need to know if it is zero or not\n    }\n    let mut z_2 = a2;\n    let mut z_1 = a1;\n    let round_bit = a0 & (shift_bit >> 1);\n    sticky_bit |= ((a0 & mask) ^ round_bit) | sticky_bit_2;\n    let mut z_0 = a0 & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z_0, z_1, z_2, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float multiplication\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && z_0 & shift_bit == 0) {\n                (z_0, z_1, z_2, decrement_exp, Less)\n            } else {\n                if z_0.overflowing_add_assign(shift_bit) {\n                    z_1.wrapping_add_assign(1);\n                }\n                if z_1 == 0 && z_0 == 0 {\n                    z_2.wrapping_add_assign(1);\n                }\n                if z_2 == 0 {\n                    (z_0, z_1, LIMB_HIGH_BIT, false, Greater)\n                } else {\n                    (z_0, z_1, z_2, decrement_exp, Greater)\n                }\n            }\n        }\n        Floor | Down => (z_0, z_1, z_2, decrement_exp, Less),\n        Ceiling | Up => {\n            if z_0.overflowing_add_assign(shift_bit) {\n                z_1.wrapping_add_assign(1);\n            }\n            if z_1 == 0 && z_0 == 0 {\n                z_2.wrapping_add_assign(1);\n            }\n            if z_2 == 0 {\n                (z_0, z_1, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, z_2, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\npub(crate) const MPFR_MULHIGH_TAB: [i8; 17] =\n    [-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\n// This is mpfr_mulhigh_n_basecase from mulders.c, MPFR 4.2.0.\nfn limbs_float_mul_high_same_length_basecase(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let len = xs.len();\n    assert_eq!(ys.len(), len);\n    // We neglect xs[0..len - 2] * ys[0], which is less than B ^ len\n    let out = &mut out[len - 1..];\n    (out[1], out[0]) = Limb::x_mul_y_to_zz(*xs.last().unwrap(), ys[0]);\n    for (i, y) in ys.iter().enumerate() {\n        let i = i + 1;\n        // Here, we neglect xs[0..len - i - 2] * ys[i], which is less than B ^ len too\n        let (out_lo, out_hi) = out.split_at_mut(i);\n        out_hi[0] = limbs_slice_add_mul_limb_same_length_in_place_left(out_lo, &xs[len - i..], *y);\n        // In total, we neglect less than n * B ^ len, i.e., n ulps of out[len].\n    }\n}\n\npub(crate) fn limbs_float_mul_high_same_length_scratch_len(len: usize) -> usize {\n    if len > MUL_FFT_THRESHOLD {\n        limbs_mul_same_length_to_out_scratch_len(len)\n    } else {\n        let k = MPFR_MULHIGH_TAB.get(len).map_or_else(\n            || 3 * (len >> 2),\n            |&m| if m == -1 { 0 } else { usize::wrapping_from(m) },\n        );\n        if k == 0 {\n            0\n        } else {\n            limbs_mul_same_length_to_out_scratch_len(max(len, len - k))\n        }\n    }\n}\n\n// Put in out[n..2 * len - 1] an approximation of the n high limbs of xs * ys. The error is less\n// than len ulps of out[len] (and the approximation is always less or equal to the truncated full\n// product).\n//\n// Implements Algorithm ShortMul from:\n//\n// [1] Short Division of Long Integers, David Harvey and Paul Zimmermann, Proceedings of the 20th\n// Symposium on Computer Arithmetic (ARITH-20), July 25-27, 2011, pages 7-14.\n//\n// This is mpfr_mulhigh_n from mulders.c, MPFR 4.2.0.\npub(crate) fn limbs_float_mul_high_same_length(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let len = xs.len();\n    assert_eq!(ys.len(), len);\n    const LENGTH_VALID: bool = MPFR_MULHIGH_TAB.len() >= 8;\n    assert!(LENGTH_VALID); // so that 3 * (len / 4) > len / 2\n    let k = MPFR_MULHIGH_TAB.get(len).map_or_else(\n        || Some(3 * (len >> 2)),\n        |&m| {\n            if m == -1 {\n                None\n            } else {\n                Some(usize::wrapping_from(m))\n            }\n        },\n    );\n    assert!(k.is_none() || k == Some(0) || (k.unwrap() >= (len + 4) >> 1 && k.unwrap() < len));\n    if let Some(k) = k {\n        if k == 0 {\n            // basecase error < len ulps\n            limbs_float_mul_high_same_length_basecase(out, xs, ys);\n        } else if len > MUL_FFT_THRESHOLD {\n            // result is exact, no error\n            limbs_mul_same_length_to_out(out, xs, ys, scratch);\n        } else {\n            let l = len - k;\n            let out = &mut out[..len << 1];\n            let (out_lo, out_hi) = out.split_at_mut(l << 1);\n            let (ys_lo, ys_hi) = ys.split_at(l);\n            limbs_mul_same_length_to_out(out_hi, &xs[l..], ys_hi, scratch);\n            limbs_float_mul_high_same_length(out_lo, &xs[k..], ys_lo, scratch);\n            let out_hi = &mut out_hi[k - l - 1..k];\n            let mut carry = Limb::from(limbs_slice_add_same_length_in_place_left(\n                out_hi,\n                &out_lo[l - 1..],\n            ));\n            limbs_float_mul_high_same_length(out_lo, &xs[..l], &ys[k..], scratch);\n            if limbs_slice_add_same_length_in_place_left(out_hi, &out_lo[l - 1..]) {\n                carry += 1;\n            }\n            limbs_slice_add_limb_in_place(&mut out[len + l..], carry);\n        }\n    } else {\n        // result is exact, no error\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    }\n}\n\nconst MPFR_MUL_THRESHOLD: usize = 20;\n\n// x.limb_count() >= y.limb_count()\nfn mul_float_significands_general(\n    xs: &[Limb],\n    x_prec: u64,\n    ys: &[Limb],\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let mut new_xs;\n    let mut new_ys;\n    let orig_xs = xs;\n    let orig_ys = ys;\n    let mut xs = xs;\n    let mut ys = ys;\n    let k = xs_len.checked_add(ys_len).unwrap();\n    let tmp_len = bit_to_limb_count_ceiling(x_prec.checked_add(y_prec).unwrap());\n    assert!(tmp_len <= k);\n    let mut tmp_vec: Vec<Limb>;\n    let mut tmp: &mut [Limb];\n    let mut b1 = false;\n    let mut goto_full_multiply = xs_len > 2 && ys_len <= MPFR_MUL_THRESHOLD;\n    let mut to = 0;\n    if xs_len <= 2 {\n        tmp_vec = vec![0; k];\n        tmp = &mut tmp_vec;\n        // The 3 cases perform the same first operation.\n        (tmp[1], tmp[0]) = Limb::x_mul_y_to_zz(xs[0], ys[0]);\n        b1 = if xs_len == 1 {\n            // 1 limb * 1 limb\n            tmp[1]\n        } else if ys_len == 1 {\n            // 2 limbs * 1 limb\n            let t;\n            (tmp[2], t) = Limb::x_mul_y_to_zz(xs[1], ys[0]);\n            (tmp[2], tmp[1]) = Limb::xx_add_yy_to_zz(tmp[2], tmp[1], 0, t);\n            tmp[2]\n        } else {\n            // 2 limbs * 2 limbs\n            //\n            // First 2 limbs * 1 limb\n            let mut t1;\n            (tmp[2], t1) = Limb::x_mul_y_to_zz(xs[1], ys[0]);\n            (tmp[2], tmp[1]) = Limb::xx_add_yy_to_zz(tmp[2], tmp[1], 0, t1);\n            let t2;\n            // Second, the other 2 limbs * 1 limb product\n            (t1, t2) = Limb::x_mul_y_to_zz(xs[0], ys[1]);\n            let t3;\n            (tmp[3], t3) = Limb::x_mul_y_to_zz(xs[1], ys[1]);\n            (tmp[3], t1) = Limb::xx_add_yy_to_zz(tmp[3], t1, 0, t3);\n            // Sum those two partial products\n            (tmp[2], tmp[1]) = Limb::xx_add_yy_to_zz(tmp[2], tmp[1], t1, t2);\n            let tmp_2 = tmp[2];\n            if tmp_2 < t1 {\n                tmp[3].wrapping_add_assign(1);\n            }\n            tmp[3]\n        }\n        .get_highest_bit();\n        to = k - tmp_len;\n        if !b1 {\n            limbs_slice_shl_in_place(&mut tmp[to..to + tmp_len], 1);\n        }\n    } else if ys_len > MPFR_MUL_THRESHOLD {\n        // xs_len >= ys_len and xs_len >= 3\n        //\n        // Mulders' mulhigh.\n        //\n        // First check if we can reduce the precision of x or y: exact values are a nightmare for\n        // the short product trick\n        if xs[0] == 0 && xs[1] == 0 || ys[0] == 0 && ys[1] == 0 {\n            let xs_leading_zeros = slice_leading_zeros(xs);\n            assert_ne!(xs_leading_zeros, xs_len);\n            let ys_leading_zeros = slice_leading_zeros(ys);\n            assert_ne!(ys_leading_zeros, ys_len);\n            return mul_float_significands_ref_ref_helper(\n                &xs[xs_leading_zeros..],\n                limb_to_bit_count(xs_len - xs_leading_zeros),\n                &ys[ys_leading_zeros..],\n                limb_to_bit_count(ys_len - ys_leading_zeros),\n                out_prec,\n                rm,\n            );\n        }\n        // Compute estimated precision of mulhigh.\n        let mut len = min(bit_to_limb_count_ceiling(out_prec) + 1, ys_len);\n        assert!(len >= 1 && len << 1 <= k && len <= ys_len && len <= xs_len);\n        let mut p = limb_to_bit_count(len) - (len + 2).ceiling_log_base_2();\n        // Check if MulHigh can produce a roundable result. We may lose 1 bit due to Nearest, 1 due\n        // to final shift.\n        let mut tmp_alloc = k;\n        if out_prec > p - 5 {\n            if out_prec > p - 5 + Limb::WIDTH || xs_len <= MPFR_MUL_THRESHOLD + 1 {\n                // MulHigh can't produce a roundable result.\n                goto_full_multiply = true;\n                xs = &xs[xs_len - len..];\n                ys = &ys[ys_len - len..];\n            } else {\n                // Add one extra limb to mantissa of x and y.\n                if xs_len > len {\n                    xs = &xs[xs_len - len - 1..];\n                } else {\n                    new_xs = vec![0; len + 1];\n                    new_xs[1..].copy_from_slice(&xs[xs_len - len..xs_len]);\n                    xs = &new_xs;\n                }\n                #[cfg(feature = \"32_bit_limbs\")]\n                {\n                    if ys_len > len {\n                        ys = &ys[ys_len - len - 1..];\n                        // This can only happen with 32-bit limbs, and is very unlikely to happen.\n                        // Indeed, since len = min(z_len + 1, ys_len), with z_len = prec /\n                        // Limb::WIDTH, we can have ys_len > len only when len = z_len + 1 < ys_len.\n                        // We are in the case prec > p - 5, p = len * Limb::WIDTH - ceil(log_2(len +\n                        // 2)), thus z_len * Limb::WIDTH - shift > len * Limb::WIDTH -\n                        // ceil(log_2(len + 2)) - 5. Thus len < z_len + (ceil(log_2(len + 2)) + 5 -\n                        // shift) / Limb::WIDTH. To get len = z_len + 1, we need ceil(log_2(len +\n                        // 2)) + 5 - shift > Limb::WIDTH, thus since shift >= 0 we need\n                        // ceil(log_2(len + 2)) + 5 > Limb::WIDTH. With Limb::WIDTH = 32 this can\n                        // only happen for len >= 2^27 - 1, thus for a precision of 2 ^ 32 - 64 for\n                        // z, and with Limb::WIDTH = 64 for n >= 2 ^ 59-1, which would give a\n                        // precision >= 2^64.\n                    } else {\n                        new_ys = vec![0; len + 1];\n                        new_ys[1..].copy_from_slice(&ys[ys_len - len..ys_len]);\n                        ys = &new_ys;\n                    }\n                }\n                #[cfg(not(feature = \"32_bit_limbs\"))]\n                {\n                    new_ys = vec![0; len + 1];\n                    new_ys[1..].copy_from_slice(&ys[ys_len - len..ys_len]);\n                    ys = &new_ys;\n                }\n                // We will compute with one extra limb.\n                len += 1;\n                // ceil(log_2(len + 2)) takes into account the lost bits due to Mulders' short\n                // product.\n                p = limb_to_bit_count(len) - (len + 2).ceiling_log_base_2();\n                // Due to some nasty reasons we can have only 4 bits\n                assert!(out_prec <= p - 4);\n                let twice_len = len << 1;\n                if k < twice_len {\n                    tmp_alloc = twice_len;\n                    to = twice_len - k;\n                } else {\n                    fail_on_untested_path(\"mul_float_significands_general, k >= len << 1 \");\n                }\n            }\n        } else {\n            xs = &xs[xs_len - len..];\n            ys = &ys[ys_len - len..];\n        }\n        if goto_full_multiply {\n            tmp_vec = vec![0; tmp_alloc];\n            tmp = &mut tmp_vec;\n        } else {\n            // Compute an approximation of the product of x and y\n            let square = core::ptr::eq(xs, ys) && x_prec == y_prec;\n            tmp_vec = vec![\n                0;\n                if square {\n                    limbs_float_square_high_scratch_len(len)\n                } else {\n                    limbs_float_mul_high_same_length_scratch_len(len)\n                } + tmp_alloc\n            ];\n            let scratch: &mut [Limb];\n            (tmp, scratch) = tmp_vec.split_at_mut(tmp_alloc);\n            if square {\n                limbs_float_square_high(&mut tmp[to + k - (len << 1)..], xs, scratch);\n            } else {\n                limbs_float_mul_high_same_length(&mut tmp[to + k - (len << 1)..], xs, ys, scratch);\n            }\n            // now tmp[k - len]..tmp[k - 1] contains an approximation of the `len` upper limbs of\n            // the product, with tmp[k - 1] >= 2 ^ (Limb::WIDTH - 2)\n            //\n            // msb from the product\n            //\n            // If the mantissas of x and y are uniformly distributed in (1/2, 1], then their product\n            // is in (1/4, 1/2] with probability 2 * ln(2) - 1 ~ 0.386 and in [1/2, 1] with\n            // probability 2 - 2 * ln(2) ~ 0.614\n            b1 = tmp[to + k - 1].get_highest_bit();\n            if !b1 {\n                limbs_slice_shl_in_place(&mut tmp[to + k - len - 1..to + k], 1);\n            }\n            // Now the approximation is in tmp[temp_len - len]...tmp[temp_len - 1]\n            assert!(tmp[to + k - 1].get_highest_bit());\n            // if the most significant bit b1 is zero, we have only p - 1 correct bits\n            if limbs_float_can_round(\n                &tmp[to + k - tmp_len..to + k],\n                p + u64::from(b1) - 1,\n                out_prec,\n                rm,\n            ) {\n                to += k - tmp_len;\n            } else {\n                goto_full_multiply = true;\n            }\n        }\n    } else {\n        tmp_vec = vec![0; k];\n        tmp = &mut tmp_vec;\n    }\n    tmp = &mut tmp[to..];\n    if goto_full_multiply {\n        let mut scratch = vec![0; limbs_mul_to_out_scratch_len(xs_len, ys_len)];\n        b1 = limbs_mul_to_out(tmp, orig_xs, orig_ys, &mut scratch).get_highest_bit();\n        // Now tmp[0]..tmp[k - 1] contains the product of both mantissas, with tmp[k - 1] >= 2 ^\n        // (Limb::WIDTH - 2).\n        //\n        // msb from the product\n        //\n        // If the mantissas of x and y are uniformly distributed in (1/2, 1], then their product is\n        // in (1/4, 1/2] with probability 2 * ln(2) - 1 ~ 0.386 and in [1/2, 1] with probability 2 -\n        // 2 * ln(2) ~ 0.614\n        tmp = &mut tmp[k - tmp_len..];\n        if !b1 {\n            limbs_slice_shl_in_place(&mut tmp[..tmp_len], 1);\n        }\n    }\n    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n    let (inexact, increment_exp) = round_helper_raw(\n        &mut out,\n        out_prec,\n        tmp,\n        x_prec.checked_add(y_prec).unwrap(),\n        rm,\n    );\n    assert!(inexact == 0 || rm != Exact, \"Inexact float multiplication\");\n    let mut exp_offset = -i32::from(!b1);\n    if increment_exp {\n        exp_offset += 1;\n    }\n    (\n        Natural::from_owned_limbs_asc(out),\n        exp_offset,\n        inexact.sign(),\n    )\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 1999-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::div_mod::{div_mod_by_preinversion, limbs_invert_limb};\nuse crate::natural::arithmetic::float_div::{\n    Cleanup, MPFR_DIV_THRESHOLD, limbs_div_helper, limbs_float_div_high,\n    limbs_float_div_high_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{limbs_mul_to_out, limbs_mul_to_out_scratch_len};\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::natural::{LIMB_HIGH_BIT, Natural, bit_to_limb_count_ceiling};\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    NegModPowerOf2, OverflowingAddAssign, OverflowingNegAssign, Parity, PowerOf2,\n    WrappingAddAssign, WrappingNegAssign, WrappingSubAssign, XMulYToZZ, XXSubYYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::slice_test_zero;\n\nconst TWICE_WIDTH: u64 = Limb::WIDTH * 2;\n\n// This is mpfr_div from div.c, MPFR 4.3.0, specialized for reciprocation.\npub fn reciprocal_float_significand_in_place(\n    x: &mut Natural,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    if out_prec == x_prec\n        && let Some((increment_exp, o)) =\n            reciprocal_float_significand_in_place_same_prec(x, out_prec, rm)\n    {\n        return (u64::from(increment_exp), o);\n    }\n    match &mut *x {\n        Natural(Small(small_x)) => {\n            let (qs, exp_offset, o) = reciprocal_float_significand_short(*small_x, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(qs);\n            (exp_offset, o)\n        }\n        Natural(Large(xs)) => {\n            let (out, exp_offset, o) = reciprocal_float_significand_general(xs, out_prec, rm);\n            *x = Natural::from_owned_limbs_asc(out);\n            (exp_offset, o)\n        }\n    }\n}\n\n// This is mpfr_div from div.c, MPFR 4.3.0, specialized for reciprocation.\npub fn reciprocal_float_significand_ref(\n    x: &Natural,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, u64, Ordering) {\n    if out_prec == x_prec\n        && let Some((reciprocal, increment_exp, o)) =\n            reciprocal_float_significand_same_prec_ref(x, out_prec, rm)\n    {\n        return (reciprocal, u64::from(increment_exp), o);\n    }\n    match x {\n        Natural(Small(small_x)) => {\n            let (qs, exp_offset, o) = reciprocal_float_significand_short(*small_x, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n        Natural(Large(xs)) => {\n            let mut xs = xs.clone();\n            let (qs, exp_offset, o) = reciprocal_float_significand_general(&mut xs, out_prec, rm);\n            (Natural::from_owned_limbs_asc(qs), exp_offset, o)\n        }\n    }\n}\n\nfn reciprocal_float_significand_in_place_same_prec(\n    x: &mut Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(bool, Ordering)> {\n    match x {\n        Natural(Small(x)) => {\n            let (reciprocal, increment_exp, o) = if prec == Limb::WIDTH {\n                reciprocal_float_significand_same_prec_w(*x, rm)\n            } else {\n                reciprocal_float_significand_same_prec_lt_w(*x, prec, rm)\n            };\n            *x = reciprocal;\n            Some((increment_exp, o))\n        }\n        Natural(Large(xs)) => match xs.as_mut_slice() {\n            [x_0, x_1] if prec != TWICE_WIDTH => {\n                let (reciprocal_0, reciprocal_1, increment_exp, o) =\n                    reciprocal_float_significand_same_prec_gt_w_lt_2w(*x_0, *x_1, prec, rm);\n                *x_0 = reciprocal_0;\n                *x_1 = reciprocal_1;\n                Some((increment_exp, o))\n            }\n            _ => None,\n        },\n    }\n}\n\nfn reciprocal_float_significand_same_prec_ref(\n    x: &Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(Natural, bool, Ordering)> {\n    match x {\n        Natural(Small(x)) => {\n            let (reciprocal, increment_exp, o) = if prec == Limb::WIDTH {\n                reciprocal_float_significand_same_prec_w(*x, rm)\n            } else {\n                reciprocal_float_significand_same_prec_lt_w(*x, prec, rm)\n            };\n            Some((Natural(Small(reciprocal)), increment_exp, o))\n        }\n        Natural(Large(xs)) => match xs.as_slice() {\n            [x_0, x_1] if prec != TWICE_WIDTH => {\n                let (reciprocal_0, reciprocal_1, increment_exp, o) =\n                    reciprocal_float_significand_same_prec_gt_w_lt_2w(*x_0, *x_1, prec, rm);\n                Some((\n                    Natural(Large(vec![reciprocal_0, reciprocal_1])),\n                    increment_exp,\n                    o,\n                ))\n            }\n            _ => None,\n        },\n    }\n}\n\n// x cannot be equal to `2 ^ (WIDTH - 1)`.\n//\n// This is mpfr_div_1 from mul.c, MPFR 4.3.0, specialized for reciprocation.\nfn reciprocal_float_significand_same_prec_lt_w(\n    x: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, bool, Ordering) {\n    let shift = Limb::WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let half_shift_bit = shift_bit >> 1;\n    let mask = shift_bit - 1;\n    // First try with an approximate reciprocal.\n    let q = LIMB_HIGH_BIT | (limbs_invert_limb::<DoubleLimb, Limb>(x) >> 1);\n    // round_bit does not exceed the true reciprocal floor(LIMB_HIGH_BIT * 2 ^ WIDTH / x), with\n    // error at most 2, which means the rational reciprocal q satisfies round_bit <= q < round_bit +\n    // 3. We can round correctly except when the last shift - 1 bits of q0 are 000..000 or 111..111\n    // or 111..110.\n    let (round_bit, sticky_bit) = if (q + 2) & (mask >> 1) > 2 {\n        // result cannot be exact in this case\n        (q & half_shift_bit, 1)\n    } else {\n        let (mut hi, mut lo) = Limb::x_mul_y_to_zz(q, x);\n        assert!(hi < LIMB_HIGH_BIT || (hi == LIMB_HIGH_BIT && lo == 0));\n        // subtract {hi, lo} from {LIMB_HIGH_BIT, 0}\n        (hi, lo) = Limb::xx_sub_yy_to_zz(LIMB_HIGH_BIT, 0, hi, lo);\n        assert!(hi == 0 && lo < x);\n        (q & half_shift_bit, lo | (q & (mask >> 1)))\n    };\n    let reciprocal = (LIMB_HIGH_BIT | q) & !mask;\n    match rm {\n        Exact => panic!(\"Inexact float reciprocation\"),\n        Nearest => {\n            if round_bit == 0 || sticky_bit == 0 && reciprocal & shift_bit == 0 {\n                (reciprocal, false, Less)\n            } else {\n                (reciprocal.wrapping_add(shift_bit), false, Greater)\n            }\n        }\n        Floor | Down => (reciprocal, false, Less),\n        Ceiling | Up => (reciprocal.wrapping_add(shift_bit), false, Greater),\n    }\n}\n\n// x cannot be equal to `2 ^ (WIDTH - 1)`.\nfn reciprocal_float_significand_same_prec_w(x: Limb, rm: RoundingMode) -> (Limb, bool, Ordering) {\n    // First compute an approximate reciprocal.\n    let q = LIMB_HIGH_BIT | (limbs_invert_limb::<DoubleLimb, Limb>(x) >> 1);\n    // round_bit does not exceed the true reciprocal floor(2 ^ WIDTH / x), with error at most 2,\n    // which means the rational reciprocal q satisfies round_bit <= q < round_bit + 3, thus the true\n    // reciprocal is round_bit, round_bit + 1 or round_bit + 2.\n    let (mut hi, mut lo) = Limb::x_mul_y_to_zz(q, x);\n    assert!(hi < LIMB_HIGH_BIT || (hi == LIMB_HIGH_BIT && lo == 0));\n    // subtract {hi, lo} from {LIMB_HIGH_BIT, 0}\n    (hi, lo) = Limb::xx_sub_yy_to_zz(LIMB_HIGH_BIT, 0, hi, lo);\n    assert!(hi == 0 && lo < x);\n    // now (LIMB_HIGH_BIT - extra * x) * 2 ^ WIDTH = q * x + lo with 0 <= lo < x\n    //\n    // If !increment_exp, the reciprocal is q0, the round bit is 1 if l >= x0 / 2, and sticky_bit\n    // are the remaining bits from l. If increment_exp, the reciprocal is LIMB_HIGH_BIT + (q >> 1),\n    // the round bit is the least significant bit of q, and sticky_bit is lo.\n    //\n    // If \"2 * lo < lo\", then there is a carry in 2 * lo, thus 2 * lo > x. Otherwise if there is no\n    // carry, we check whether 2 * lo >= y0.\n    let two_lo = lo << 1;\n    let round_bit = (two_lo < lo) || (two_lo >= x);\n    let mut reciprocal = q;\n    let sticky_bit = if round_bit {\n        two_lo.wrapping_sub(x)\n    } else {\n        lo\n    };\n    match rm {\n        Exact => panic!(\"Inexact float reciprocation\"),\n        Nearest => {\n            if !round_bit || sticky_bit == 0 && reciprocal.even() {\n                (reciprocal, false, Less)\n            } else {\n                reciprocal.wrapping_add_assign(1);\n                (reciprocal, false, Greater)\n            }\n        }\n        Floor | Down => (reciprocal, false, Less),\n        Ceiling | Up => {\n            reciprocal.wrapping_add_assign(1);\n            (reciprocal, false, Greater)\n        }\n    }\n}\n\n// Given (B << WIDTH) < x = x_1 * B + x_0 with x normalized (high bit of x_1 set), put in q = Q1\n// * B + Q0 an approximation of floor(B ^ 2 / x), with: B = 2 ^ WIDTH and q <= floor(B ^ 2 /\n// x) <= q + 21.\n//\n// This is mpfr_div2_approx from div.c, MPFR 4.3.0, where Q0 and Q1 are returned, specialized for\n// reciprocation.\nfn reciprocal_float_2_approx(x_1: Limb, x_0: Limb) -> (Limb, Limb) {\n    // First compute an approximation of q_1, using a lower approximation of B ^ 2 / (x_1 + 1) - B\n    let inv = if x_1 == Limb::MAX {\n        0\n    } else {\n        limbs_invert_limb::<DoubleLimb, Limb>(x_1 + 1)\n    };\n    // Now inv <= B ^ 2 / (x_1 + 1) - B.\n    let mut q_1 = LIMB_HIGH_BIT | (inv >> 1);\n    // Now q_1 <= x_1 * B / (x_1 + 1) < (x_1 * B + x_0) * B / (x_1 * B + x_0).\n    //\n    // Compute q_1 * (x_1 * B + x_0) into r_1 : r_0 : xx and subtract from u_1 : x_0 : 0.\n    let (mut r_1, mut r_0) = Limb::x_mul_y_to_zz(q_1, x_1);\n    let (xx, yy) = Limb::x_mul_y_to_zz(q_1, x_0);\n    if r_0.overflowing_add_assign(xx) {\n        r_1.wrapping_add_assign(1);\n    }\n    // We ignore yy below, but first increment r_0, to ensure we get a lower approximation of the\n    // remainder.\n    if yy != 0 {\n        r_0.wrapping_add_assign(1);\n    }\n    if r_0 == 0 && yy != 0 {\n        r_1.wrapping_add_assign(1);\n    }\n    r_1 = LIMB_HIGH_BIT.wrapping_sub(r_1);\n    let carry;\n    (r_0, carry) = r_0.overflowing_neg();\n    if carry {\n        r_1.wrapping_sub_assign(1);\n    }\n    // r_1 : r_0 should be non-negative.\n    assert!(!r_1.get_highest_bit());\n    // The second reciprocal limb is approximated by (r_1 * B ^ 2 + r_0 * B) / x_1, and since (B +\n    // inv) / B approximates B / x_1, this is in turn approximated by (r * B + r_0) * (B + inv) / B\n    // = r_1 * B * r_1 * inv + r_0 + (r0 * inv / B).\n    q_1.wrapping_add_assign(r_1);\n    // Add floor(r_0 * inv / B) to q_0.\n    if r_0.overflowing_add_assign(Limb::wrapping_from(\n        (DoubleLimb::from(r_0) * DoubleLimb::from(inv)) >> Limb::WIDTH,\n    )) {\n        q_1.wrapping_add_assign(1);\n    }\n    assert!(r_1 <= 4);\n    for _ in 0..r_1 {\n        if r_0.overflowing_add_assign(inv) {\n            q_1.wrapping_add_assign(1);\n        }\n    }\n    (q_1, r_0)\n}\n\n// [x_0, x_1] cannot be equal to `2 ^ (2 * WIDTH - 1)`.\n//\n// This is mpfr_div_2 from div.c, MPFR 4.3.0, where Q0 and Q1 are returned, specialized for\n// reciprocation.\nfn reciprocal_float_significand_same_prec_gt_w_lt_2w(\n    x_0: Limb,\n    x_1: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, bool, Ordering) {\n    let shift = TWICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    assert!(LIMB_HIGH_BIT < x_1 || (LIMB_HIGH_BIT == x_1 && x_0 != 0));\n    let (mut q_1, mut q_0) = reciprocal_float_2_approx(x_1, x_0);\n    // We know q1 * B + q0 is smaller or equal to the exact reciprocal, with difference at most 21.\n    let mut sticky_bit = if (q_0.wrapping_add(21)) & (mask >> 1) > 21 {\n        // The result is not exact when we can round with an approximation.\n        1\n    } else {\n        // We know q_1 : q_0 is a good-enough approximation, so use it!\n        //\n        // Since we know the difference should be at most 21 * (x_1 : x_0) after the subtraction\n        // below, thus at most 21 * 2 ^ 128, it suffices to compute the lower 3 limbs of (q_1 : q_0)\n        // * (x_1 : x_0).\n        let (mut s_1, mut s_0) = Limb::x_mul_y_to_zz(q_0, x_0);\n        let (mut s_2, mut lo) = Limb::x_mul_y_to_zz(q_0, x_1);\n        if s_1.overflowing_add_assign(lo) {\n            s_2.wrapping_add_assign(1);\n        }\n        let hi;\n        (hi, lo) = Limb::x_mul_y_to_zz(q_1, x_0);\n        s_2.wrapping_add_assign(hi);\n        if s_1.overflowing_add_assign(lo) {\n            s_2.wrapping_add_assign(1);\n        }\n        s_2.wrapping_add_assign(q_1.wrapping_mul(x_1));\n        // Subtract s_2 : s_1 : s_0 from 0 : 0 : 0, with result in s_2 : s_1 : s_0.\n        s_2.wrapping_neg_assign();\n        // Now negate s_1 : s_0.\n        s_1.wrapping_neg_assign();\n        if s_0.overflowing_neg_assign() {\n            s_1.wrapping_sub_assign(1);\n        }\n        // There is a borrow in s_2 when s_0 and s_1 are not both zero.\n        if s_1 != 0 || s_0 != 0 {\n            s_2.wrapping_sub_assign(1);\n        }\n        while s_2 > 0 || s_1 > x_1 || s_1 == x_1 && s_0 >= x_0 {\n            // Add 1 to q_1 : q_0.\n            if q_0.overflowing_add_assign(1) {\n                q_1.wrapping_add_assign(1);\n            }\n            // Subtract x_1 : x_0 to s_2 : s_1 : s_0\n            if s_1 < x_1 || s_1 == x_1 && s_0 < x_0 {\n                s_2.wrapping_sub_assign(1);\n            }\n            (s_1, s_0) = Limb::xx_sub_yy_to_zz(s_1, s_0, x_1, x_0);\n        }\n        s_1 | s_0\n    };\n    let round_bit = q_0 & (shift_bit >> 1);\n    sticky_bit |= (q_0 & mask) ^ round_bit;\n    let mut z_1 = q_1;\n    let mut z_0 = q_0 & !mask;\n    match rm {\n        Exact => panic!(\"Inexact float reciprocation\"),\n        Nearest => {\n            if round_bit == 0 || sticky_bit == 0 && z_0 & shift_bit == 0 {\n                (z_0, z_1, false, Less)\n            } else if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, false, Greater)\n            }\n        }\n        Floor | Down => (z_0, z_1, false, Less),\n        Ceiling | Up => {\n            if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, false, Greater)\n            }\n        }\n    }\n}\n\n// This is mpfr_div_ui from div_ui.c, MPFR 4.3.0, specialized for reciprocation.\nfn reciprocal_float_significand_short(\n    y: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Vec<Limb>, u64, Ordering) {\n    let out_len = bit_to_limb_count_ceiling(prec);\n    let mut out = vec![0; out_len + 1];\n    let (exp_offset, o) = reciprocal_float_significand_short_to_out(&mut out, y, prec, rm);\n    out.truncate(out_len);\n    (out, exp_offset, o)\n}\n\nfn limbs_reciprocal_limb_to_out_mod_with_fraction(\n    out: &mut [Limb],\n    fraction_len: usize,\n    d: Limb,\n) -> Limb {\n    assert_ne!(d, 0);\n    let len = fraction_len.checked_add(1).unwrap();\n    assert_ne!(len, 0);\n    let out = &mut out[..len];\n    assert!(d.get_highest_bit());\n    let (out_last, out_init) = out.split_last_mut().unwrap();\n    *out_last = 0;\n    // Multiply-by-inverse, divisor already normalized.\n    let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n    let mut r = LIMB_HIGH_BIT;\n    for out_q in out_init[..fraction_len].iter_mut().rev() {\n        (*out_q, r) = div_mod_by_preinversion(r, 0, d, d_inv);\n    }\n    r\n}\n\n// y cannot be a power of 2.\n//\n// This is mpfr_div_ui from div_ui.c, MPFR 4.3.0, specialized for reciprocation.\nfn reciprocal_float_significand_short_to_out(\n    out: &mut [Limb],\n    y: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    let diff = out.len().abs_diff(1);\n    // We need to store out_len + 1 = 1 + diff limbs of the reciprocal. used the entire dividend\n    //\n    // X = ({scratch, 1 + diff} * y + c) * B ^ (-diff} = ({scratch, out_len + 1} * y + c) * B ^\n    // (-dif)\n    let c = limbs_reciprocal_limb_to_out_mod_with_fraction(out, diff, y);\n    // Let r = {xp, -diff} / B ^ (-diff) if diff < 0, r = 0 otherwise; 0 <= r < 1.\n    //\n    // Then X = ({scratch, out_len + 1} * y + c + r) * B ^ (-dif). x / y = (X / y) * B ^ (-1) * 2 ^\n    // exp = ({scratch, out_len + 1} + (c + r) / y) * B ^ (-(out_len + 1)) * 2 ^ exp where 0 <= (c +\n    // r) / y < 1.\n    //\n    // sticky_bit != 0 iff r != 0\n    //\n    // If the highest limb of the result is 0 (xs[0] < y), remove it. Otherwise, compute the left\n    // shift to be performed to normalize. In the latter case, we discard some low bits computed.\n    // They contain information useful for the rounding, hence the updating of middle and inexact.\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_mask = shift_bit - 1;\n    let out_head = out[0];\n    // round bit is 1 iff (c + r) / u >= 1/2\n    let (mut exp_offset, round_bit, sticky_bit) = if shift == 0 {\n        // In this case scratch[out_len] = 0 and shift = 0, the round bit is not in {scratch,\n        // out_len + 1}. It is 1 iff 2 * (c + r) - y >= 0. This means that in some cases, we should\n        // look at the most significant bit of r.\n        if c >= y - c {\n            // i.e. 2 * c >= y: round bit is always 1\n            //\n            // The sticky bit is 1 unless 2 * c - y = 0 and r = 0.\n            (0, 1, (c << 1).wrapping_sub(y))\n        } else {\n            // 2 * c < y\n            //\n            // The round bit is 1 iff r >= 1 / 2 and 2 * (c + 1 / 2) = y.\n            //\n            // If round_bit is set, we need to recompute sticky_bit, since it might have taken into\n            // account the most-significant bit of xs[-diff - 1].\n            (0, 0, c)\n        }\n    } else {\n        // round bit is in scratch[0]\n        (\n            0,\n            out_head & (shift_bit >> 1),\n            (out_head & (shift_mask >> 1)) | c,\n        )\n    };\n    // Clear the lowest `shift` bits\n    out[0] &= !shift_mask;\n    let (_, out) = out.split_last_mut().unwrap();\n    match rm {\n        Exact => panic!(\"Inexact float reciprocation\"),\n        Nearest => {\n            if round_bit == 0 || sticky_bit == 0 && out[0] & shift_bit == 0 {\n                (exp_offset, Less)\n            } else {\n                if limbs_slice_add_limb_in_place(out, shift_bit) {\n                    exp_offset += 1;\n                    *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n                }\n                (exp_offset, Greater)\n            }\n        }\n        Floor | Down => (exp_offset, Less),\n        Ceiling | Up => {\n            if limbs_slice_add_limb_in_place(out, shift_bit) {\n                exp_offset += 1;\n                *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n            }\n            (exp_offset, Greater)\n        }\n    }\n}\n\n#[inline]\nfn reciprocal_float_significand_general(\n    ys: &mut [Limb],\n    prec: u64,\n    rm: RoundingMode,\n) -> (Vec<Limb>, u64, Ordering) {\n    let mut out = vec![0; bit_to_limb_count_ceiling(prec)];\n    let (exp_offset, o) = reciprocal_float_significand_general_to_out(&mut out, ys, prec, rm);\n    (out, exp_offset, o)\n}\n\n// TODO special case qs == ds\n//\n// This is mpfr_div from div.c, MPFR 4.2.0, skipping over various special cases, specialized for\n// reciprocation.\nfn reciprocal_float_significand_general_to_out(\n    qs: &mut [Limb],\n    ds: &mut [Limb],\n    prec: u64,\n    rm: RoundingMode,\n) -> (u64, Ordering) {\n    let ds_len = ds.len();\n    let qs_len = bit_to_limb_count_ceiling(prec);\n    let qs = &mut qs[..qs_len];\n    // Determine if an extra bit comes from the division, i.e. if the significand of X (as a\n    // fraction in [1/2, 1) ) is larger than that of Y\n    let ds_last = *ds.last().unwrap();\n    let extra_bit = if ds_last == LIMB_HIGH_BIT {\n        // k = 0: no more dividend limb\n        slice_test_zero(&ds[..ds_len - 1])\n    } else {\n        LIMB_HIGH_BIT > ds_last\n    };\n    let mut exp_offset = u64::from(extra_bit);\n    // shift is the number of zero bits in the low limb of the reciprocal\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let mut shift_bit = Limb::power_of_2(shift);\n    let shift_mask = shift_bit - 1;\n    let mut ys_vec;\n    let mut ys: &mut [Limb];\n    // We first try Mulders' short division (for large operands)\n    if qs_len >= MPFR_DIV_THRESHOLD && ds_len >= MPFR_DIV_THRESHOLD {\n        // We will perform a short (2 * n) / n division\n        let n = qs_len + 1;\n        let two_n = n << 1;\n        // since Mulders' short division clobbers the dividend, we have to copy it\n        let mut xs = vec![0; two_n];\n        // zero-pad the dividend\n        *xs.last_mut().unwrap() = LIMB_HIGH_BIT;\n        if ds_len >= n {\n            // truncate the divisor\n            ys = &mut ds[ds_len - n..];\n        } else {\n            // zero-pad the divisor\n            ys_vec = vec![0; n];\n            ys = &mut ys_vec;\n            ys[n - ds_len..].copy_from_slice(ds);\n        }\n        // Since n = qs_len + 1, we have n >= 2 here.\n        let mut scratch = vec![0; n + limbs_float_div_high_scratch_len(n)];\n        let (qs_2, scratch) = scratch.split_at_mut(n);\n        let q_high = limbs_float_div_high(qs_2, &mut xs, &ys[..n], scratch);\n        // In all cases, the error is at most (2 * n + 2) ulps on q_high * B ^ n + {qs_2, n}.\n        //\n        // If rm == Nearest, we need to be able to round with a directed rounding and one more bit.\n        if q_high {\n            let qs_2_lo = &mut qs_2[..n];\n            limbs_slice_shr_in_place(qs_2_lo, 1);\n            *qs_2_lo.last_mut().unwrap() |= LIMB_HIGH_BIT;\n            // round_helper_2 would always return false, so no need to call it\n        }\n    }\n    // Mulders' short division failed: we revert to integer division\n    let mut qs_2_vec = vec![];\n    let mut qs_2: &mut [Limb] = if rm == Nearest && shift == 0 {\n        // We compute the reciprocal with one more limb, in order to get the round bit in the\n        // reciprocal, and the remainder only contains sticky bits. Need to allocate memory for the\n        // reciprocal\n        qs_2_vec = vec![0; qs_len + 1];\n        &mut qs_2_vec\n    } else {\n        qs // directly put the reciprocal in the destination\n    };\n    let qs_2_len = qs_2.len();\n    let two_qs_2_len = qs_2_len << 1;\n    // prepare the dividend\n    let mut xs = vec![0; two_qs_2_len];\n    // use the full dividend\n    xs[two_qs_2_len - 1] = if extra_bit {\n        LIMB_HIGH_BIT >> 1\n    } else {\n        LIMB_HIGH_BIT\n    };\n    // Prepare the divisor\n    let (mut k, sticky_y) = if ds_len >= qs_2_len {\n        let k = ds_len - qs_2_len;\n        let sy = !slice_test_zero(&ds[..k]);\n        ys = &mut ds[k..]; // avoid copying the divisor\n        (0, sy)\n    } else {\n        // ds_len < qs_2_len: small divisor case\n        ys = ds;\n        (qs_2_len - ds_len, false)\n    };\n    // If Mulders' short division failed, we revert to division with remainder.\n    let mut q_high = limbs_div_helper(qs_2, &mut xs[k..], &ys[..qs_2_len - k]);\n    k = qs_2_len;\n    let sticky_x = !slice_test_zero(&xs[..k]);\n    let mut sticky_bit = Limb::from(sticky_x | sticky_y);\n    // now sticky_bit is non-zero iff one of the following holds:\n    // - the truncated part of u is non-zero\n    // - the truncated part of v is non-zero\n    // - the remainder from division is non-zero\n    let (mut sticky_3, shift_2) = if qs_2_len == qs_len {\n        // does nothing when shift = 0\n        (qs_2[0] & shift_mask, shift)\n    } else {\n        // qs_2_len = qs_len + 1: only happens when rm == Nearest and shift = 0\n        qs.copy_from_slice(&qs_2_vec[1..=qs_len]);\n        qs_2 = &mut qs_2_vec;\n        (qs_2[0], Limb::WIDTH)\n    };\n    qs_2[0] ^= sticky_3;\n    // sticky_3 contains the truncated bits from the reciprocal, including the round bit, and 1 <=\n    // shift_2 <= WIDTH is the number of bits in sticky_3 to round, we distinguish two cases:\n    // - ds_len <= qs_2_len: we used the full divisor\n    // - ds_len > qs_2_len: the divisor was truncated\n    let mut inex = Greater;\n    let mut round_bit = 0;\n    let mut cleanup = Cleanup::None;\n    if ds_len <= qs_2_len {\n        // use the full divisor\n        sticky_bit = if rm == Nearest {\n            round_bit = sticky_3 & Limb::power_of_2(shift_2 - 1);\n            (sticky_3 ^ round_bit) | Limb::from(sticky_x)\n        } else if rm == Exact {\n            panic!(\"Inexact float reciprocation\");\n        } else {\n            1\n        };\n    } else {\n        // ds_len > qs_2_len: need to truncate the divisor\n        //\n        // We know the estimated reciprocal is an upper bound of the exact reciprocal (with rounding\n        // toward zero), with a difference of at most 2 in qs_2[0]. Thus we can round except when\n        // sticky_3 is 000...000 or 000...001 for directed rounding, and 100...000 or 100...001 for\n        // rounding to nearest. (For rounding to nearest, we cannot determine the inexact flag for\n        // 000...000 or 000...001.)\n        let sticky_3_orig = sticky_3;\n        if rm == Nearest {\n            round_bit = sticky_3 & Limb::power_of_2(shift_2 - 1);\n            sticky_3 ^= round_bit;\n        }\n        if sticky_3 > 1 {\n            sticky_bit = sticky_3;\n        } else {\n            // hard case: we have to compare q1 * v0 and r + u0, where q1 * v0 has qs_2_len +\n            // (ds_len-qs_2_len) = ds_len limbs, and r + u0 has qs_2_len + (usize-2*qs_2_len) =\n            // usize-qs_2_len limbs\n            let k = ds_len - qs_2_len;\n            // sp <- {qs_2, qs_2_len} * {ds, ds_len - qs_2_len}\n            let mut scratch = vec![0; ds_len + limbs_mul_to_out_scratch_len(qs_2_len, k)];\n            let (sp, scratch) = scratch.split_at_mut(ds_len);\n            qs_2[0] ^= sticky_3_orig; // restore original reciprocal\n            let ds_lo = &ds[..k];\n            limbs_mul_to_out(sp, qs_2, ds_lo, scratch);\n            let q_high_2 = if q_high {\n                limbs_slice_add_same_length_in_place_left(&mut sp[qs_2_len..], ds_lo)\n            } else {\n                false\n            };\n            qs_2[0] ^= sticky_3_orig;\n            // restore truncated reciprocal\n            //\n            // Compare q_high_2 + {sp, ds_len} to {xs, qs_2_len} + u0\n            let (sp_lo, sp_hi) = sp.split_at_mut(k);\n            let mut cmp_s_r = if q_high_2 {\n                Greater\n            } else {\n                limbs_cmp_same_length(sp_hi, &xs[..qs_2_len])\n            };\n            if cmp_s_r == Equal {\n                // compare {sp, k} and u0\n                cmp_s_r = if slice_test_zero(sp_lo) {\n                    Equal\n                } else {\n                    Greater\n                };\n            }\n            // now\n            // - cmp_s_r > 0 if {sp, ds_len} > {xs, qs_2_len} + u0\n            // - cmp_s_r = 0 if {sp, ds_len} = {xs, qs_2_len} + u0\n            // - cmp_s_r < 0 if {sp, ds_len} < {xs, qs_2_len} + u0\n            if cmp_s_r <= Equal {\n                // reciprocal is in [q1, q1+1)\n                sticky_bit = if cmp_s_r == Equal { sticky_3 } else { 1 };\n            } else {\n                // cmp_s_r > 0, reciprocal is < q1: to determine if it is in [q1 - 2, q1 - 1] or in\n                // [q1 - 1, q1], we need to subtract the low part u0 of the dividend from q*v0\n                // subtract u0 >> extra_bit if non-zero\n                if q_high_2 {\n                    // whatever the value of {ns, m + k}, it will be smaller than q_high_2 + {sp, k}\n                    cmp_s_r = Greater;\n                } else {\n                    // subtract r\n                    limbs_sub_same_length_in_place_left(sp_hi, &xs[..qs_2_len]);\n                    // now compare {sp, ds_len} to y\n                    cmp_s_r = limbs_cmp_same_length(sp, ds);\n                }\n                if cmp_s_r <= Equal {\n                    // q1 - 1 <= x / y < q1\n                    if sticky_3 == 1 {\n                        // q1 - 1 is either representable (directed rounding), or the middle of two\n                        // numbers (nearest)\n                        sticky_bit = Limb::from(cmp_s_r != Equal);\n                    } else if round_bit == 0 {\n                        // round_bit=0, sticky_3=0: q1 - 1 is exact only when sh=0\n                        inex = if cmp_s_r != Equal || shift != 0 {\n                            Less\n                        } else {\n                            Equal\n                        };\n                        cleanup = if rm == Nearest || ((rm == Ceiling || rm == Up) && inex != Equal)\n                        {\n                            inex = Greater;\n                            Cleanup::TruncateCheckQHigh\n                        } else if inex != Equal && rm == Exact {\n                            panic!(\"Inexact float reciprocation\");\n                        } else {\n                            Cleanup::Sub1Ulp\n                        };\n                    } else {\n                        // sticky_3 = 0, round_bit = 1 ==> rounding to nearest\n                        return (exp_offset, cmp_s_r);\n                    }\n                } else {\n                    // q1 - 2 < x / y < q1 - 1\n                    //\n                    // if rm == Nearest, the result is q1 when q1 - 2 >= q1 - 2 ^ (shift - 1), i.e.\n                    // shift >= 2, otherwise (shift = 1) it is q1 - 2\n                    (inex, cleanup) = if rm == Exact {\n                        panic!(\"Inexact float reciprocation\");\n                    } else if rm == Nearest {\n                        // shift > 0\n                        //\n                        // Case shift = 1: sticky_bit = 0 always, and q1 - round_bit is exactly\n                        // representable, like q1 - round_bit - 2.\n                        // ```\n                        // round_bit action\n                        // 0         subtract two ulps, inex = Less\n                        // 1         truncate, inex = Greater\n                        // ```\n                        //\n                        // Case shift > 1: one ulp is 2 ^ (shift - 1) >= 2\n                        // ```\n                        // round_bit sticky_bit action\n                        // 0         0          truncate, inex = Greater\n                        // 0         1          truncate, inex = Greater\n                        // 1         x          truncate, inex = Less\n                        // ```\n                        if shift == 1 {\n                            if round_bit == 0 {\n                                shift_bit = 1;\n                                (Less, Cleanup::Sub2Ulp)\n                            } else {\n                                (Greater, Cleanup::TruncateCheckQHigh)\n                            }\n                        } else {\n                            (\n                                if round_bit == 0 { Greater } else { Less },\n                                Cleanup::TruncateCheckQHigh,\n                            )\n                        }\n                    } else if rm == Floor || rm == Down {\n                        // The result is down(q1 - 2), i.e. subtract one ulp if shift > 0, and two\n                        // ulps if shift = 0\n                        (\n                            Less,\n                            if shift == 0 {\n                                Cleanup::Sub2Ulp\n                            } else {\n                                Cleanup::Sub1Ulp\n                            },\n                        )\n                    } else {\n                        (\n                            Greater,\n                            if shift == 0 {\n                                Cleanup::Sub1Ulp\n                            } else {\n                                Cleanup::TruncateCheckQHigh\n                            },\n                        )\n                    };\n                }\n            }\n        }\n    }\n    match cleanup {\n        Cleanup::None => {\n            // reciprocal is in [q1, q1 + 1), round_bit is the round_bit (0 for directed rounding)\n            return if rm == Floor || rm == Down || round_bit == 0 && sticky_bit == 0 {\n                (\n                    exp_offset,\n                    if round_bit == 0 && sticky_bit == 0 {\n                        Equal\n                    } else {\n                        Less\n                    },\n                )\n            } else if rm == Exact {\n                panic!(\"Inexact float reciprocation\");\n            } else if rm == Nearest {\n                // sticky_bit != 0 or round != 0\n                if round_bit == 0 {\n                    // necessarily sticky_bit != 0\n                    (exp_offset, Less)\n                } else if sticky_bit != 0 {\n                    if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                        exp_offset += 1;\n                        // else qexp is now incorrect, but one will still get an overflow\n                        *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                    }\n                    (exp_offset, Greater)\n                } else {\n                    fail_on_untested_path(\n                        \"div_float_significands_long_by_short, round_bit != 0 && sticky_bit != 0\",\n                    );\n                    // round_bit = 1, sticky_bit = 0\n                    if qs[0] & shift_bit == 0 {\n                        (exp_offset, Less)\n                    } else {\n                        if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                            exp_offset += 1;\n                            // else qexp is now incorrect, but one will still get an overflow\n                            *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                        }\n                        (exp_offset, Greater)\n                    }\n                }\n            } else {\n                // round away from zero, sticky_bit != 0\n                if limbs_slice_add_limb_in_place(qs, shift_bit) {\n                    exp_offset += 1;\n                    // else qexp is now incorrect, but one will still get an overflow\n                    *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n                }\n                (exp_offset, Greater)\n            };\n        }\n        Cleanup::Sub1Ulp => {\n            // we cannot subtract 1 << (shift + 1), since this is undefined for shift = WIDTH\n            if limbs_sub_limb_in_place(qs, shift_bit) {\n                q_high = false;\n            }\n        }\n        Cleanup::Sub2Ulp => {\n            if limbs_sub_limb_in_place(qs, shift_bit) {\n                q_high = false;\n            }\n            if limbs_sub_limb_in_place(qs, shift_bit) {\n                q_high = false;\n            }\n        }\n        _ => {}\n    }\n    if q_high {\n        exp_offset += 1;\n        // else qexp is now incorrect, but one will still get an overflow\n        *qs.last_mut().unwrap() = LIMB_HIGH_BIT;\n    }\n    (exp_offset, inex)\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_reciprocal_sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright 2008-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_greater_in_place_left, limbs_slice_add_limb_in_place,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::square::{limbs_square_to_out, limbs_square_to_out_scratch_len};\nuse crate::natural::arithmetic::sub::{limbs_sub_greater_in_place_left, limbs_sub_limb_in_place};\nuse crate::natural::logic::not::{limbs_not_in_place, limbs_not_to_out};\nuse crate::natural::{\n    LIMB_HIGH_BIT, bit_to_limb_count_ceiling, bit_to_limb_count_floor, limb_to_bit_count,\n};\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{PowerOf2, Square, XMulYToZZ};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\n// the following T1 and T2 are bipartite tables giving initial approximation for the inverse square\n// root, with 13-bit input split in 5 + 4 + 4, and 11-bit output. More precisely, if 2048 <= i <\n// 8192, with i = a * 2 ^ 8 + b * 2 ^ 4 + c, we use for approximation of 2048 / sqrt(i / 2048) the\n// value x = T1[16 * (a - 8) + b] + T2[16 * (a - 8) + c]. The largest error is obtained for i =\n// 2054, where x = 2044, and 2048 / sqrt(i / 2048) = 2045.006576...\n//\n// This is T1 from rec_sqrt.c, MPFR 4.3.0.\nconst T1: [u16; 384] = [\n    2040, 2033, 2025, 2017, 2009, 2002, 1994, 1987, 1980, 1972, 1965, 1958, 1951, 1944, 1938, 1931,\n    1925, 1918, 1912, 1905, 1899, 1892, 1886, 1880, 1874, 1867, 1861, 1855, 1849, 1844, 1838, 1832,\n    1827, 1821, 1815, 1810, 1804, 1799, 1793, 1788, 1783, 1777, 1772, 1767, 1762, 1757, 1752, 1747,\n    1742, 1737, 1733, 1728, 1723, 1718, 1713, 1709, 1704, 1699, 1695, 1690, 1686, 1681, 1677, 1673,\n    1669, 1664, 1660, 1656, 1652, 1647, 1643, 1639, 1635, 1631, 1627, 1623, 1619, 1615, 1611, 1607,\n    1603, 1600, 1596, 1592, 1588, 1585, 1581, 1577, 1574, 1570, 1566, 1563, 1559, 1556, 1552, 1549,\n    1545, 1542, 1538, 1535, 1532, 1528, 1525, 1522, 1518, 1515, 1512, 1509, 1505, 1502, 1499, 1496,\n    1493, 1490, 1487, 1484, 1481, 1478, 1475, 1472, 1469, 1466, 1463, 1460, 1457, 1454, 1451, 1449,\n    1446, 1443, 1440, 1438, 1435, 1432, 1429, 1427, 1424, 1421, 1419, 1416, 1413, 1411, 1408, 1405,\n    1403, 1400, 1398, 1395, 1393, 1390, 1388, 1385, 1383, 1380, 1378, 1375, 1373, 1371, 1368, 1366,\n    1363, 1360, 1358, 1356, 1353, 1351, 1349, 1346, 1344, 1342, 1340, 1337, 1335, 1333, 1331, 1329,\n    1327, 1325, 1323, 1321, 1319, 1316, 1314, 1312, 1310, 1308, 1306, 1304, 1302, 1300, 1298, 1296,\n    1294, 1292, 1290, 1288, 1286, 1284, 1282, 1280, 1278, 1276, 1274, 1272, 1270, 1268, 1266, 1265,\n    1263, 1261, 1259, 1257, 1255, 1253, 1251, 1250, 1248, 1246, 1244, 1242, 1241, 1239, 1237, 1235,\n    1234, 1232, 1230, 1229, 1227, 1225, 1223, 1222, 1220, 1218, 1217, 1215, 1213, 1212, 1210, 1208,\n    1206, 1204, 1203, 1201, 1199, 1198, 1196, 1195, 1193, 1191, 1190, 1188, 1187, 1185, 1184, 1182,\n    1181, 1180, 1178, 1177, 1175, 1174, 1172, 1171, 1169, 1168, 1166, 1165, 1163, 1162, 1160, 1159,\n    1157, 1156, 1154, 1153, 1151, 1150, 1149, 1147, 1146, 1144, 1143, 1142, 1140, 1139, 1137, 1136,\n    1135, 1133, 1132, 1131, 1129, 1128, 1127, 1125, 1124, 1123, 1121, 1120, 1119, 1117, 1116, 1115,\n    1114, 1113, 1111, 1110, 1109, 1108, 1106, 1105, 1104, 1103, 1101, 1100, 1099, 1098, 1096, 1095,\n    1093, 1092, 1091, 1090, 1089, 1087, 1086, 1085, 1084, 1083, 1081, 1080, 1079, 1078, 1077, 1076,\n    1075, 1073, 1072, 1071, 1070, 1069, 1068, 1067, 1065, 1064, 1063, 1062, 1061, 1060, 1059, 1058,\n    1057, 1056, 1055, 1054, 1052, 1051, 1050, 1049, 1048, 1047, 1046, 1045, 1044, 1043, 1042, 1041,\n    1040, 1039, 1038, 1037, 1036, 1035, 1034, 1033, 1032, 1031, 1030, 1029, 1028, 1027, 1026, 1025,\n];\n\n// This is T2 from rec_sqrt.c, MPFR 4.3.0.\nconst T2: [u8; 384] = [\n    7, 7, 6, 6, 5, 5, 4, 4, 4, 3, 3, 2, 2, 1, 1, 0, 6, 5, 5, 5, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 0, 0,\n    5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 4, 4, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0,\n    3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0,\n    3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,\n    2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,\n    3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,\n    1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,\n    1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,\n    1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,\n    1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n];\n\n// Put in X a p-bit approximation of 1/sqrt(A), where X = {x, n} / B ^ n, n = ceil(p / Limb::WIDTH),\n// A = 2 ^ (1 + a_s) * {a, an} / B ^ an, a_s is 0 or 1, an = ceil(ap / Limb::WIDTH), where B = 2 ^\n// Limb::WIDTH.\n//\n// We have 1 <= A < 4 and 1/2 <= X < 1.\n//\n// The error in the approximate result with respect to the true value 1/sqrt(A) is bounded by 1\n// ulp(X), i.e., 2^{-p} since 1/2 <= X < 1.\n//\n// Note: x and a are left-aligned, i.e., the most significant bit of a[an-1] is set, and so is the\n// most significant bit of the output x[n-1].\n//\n// If p is not a multiple of Limb::WIDTH, the extra low bits of the input A are taken into account\n// to compute the approximation of 1/sqrt(A), but whether or not they are zero, the error between X\n// and 1/sqrt(A) is bounded by 1 ulp(X) [in precision p]. The extra low bits of the output X (if p\n// is not a multiple of Limb::WIDTH) are set to 0.\n//\n// Assumptions:\n// - A should be normalized, i.e., the most significant bit of a[an-1] should be 1. If a_s = 0, we\n//   have 1 <= A < 2; if a_s = 1, we have 2 <= A < 4.\n// - p >= 12\n// - {a, an} and {x, n} should not overlap\n// - Limb::WIDTH >= 12 and is even\n//\n// Note: this routine is much more efficient when ap is small compared to p, including the case\n// where ap <= Limb::WIDTH, thus it can be used to implement an efficient mpfr_rec_sqrt_ui function.\n//\n// References: [1] Modern Computer Algebra, Richard Brent and Paul Zimmermann,\n// https://members.loria.fr/PZimmermann/mca/pub226.html\n//\n// This is mpfr_mpn_rec_sqrt from rec_sqrt.c, MPFR 4.3.0.\npub fn limbs_reciprocal_sqrt(\n    out: &mut [Limb],\n    out_prec: u64,\n    mut xs: &[Limb],\n    x_prec: u64,\n    parity: bool,\n) {\n    let out_len = bit_to_limb_count_ceiling(out_prec);\n    let out = &mut out[..out_len];\n    let mut xs_len = bit_to_limb_count_ceiling(x_prec);\n    // A should be normalized\n    assert!(xs[xs_len - 1].get_highest_bit());\n    assert!(out_prec >= 11);\n    if xs_len > out_len {\n        // we can cut the input to n limbs\n        xs = &xs[xs_len - out_len..];\n        xs_len = out_len;\n    }\n    if out_prec == 11 {\n        // should happen only from recursive calls\n        //\n        // take the 12 + a_s most significant bits of A\n        let i =\n            usize::exact_from(xs[xs_len - 1] >> (const { Limb::WIDTH - 12 } - u64::from(parity)));\n        let ab = i >> 4;\n        let ac = (ab & 0x3f0) | (i & 0xf);\n        let t = T1[ab - 0x80] + u16::from(T2[ac - 0x80]); // fits on 16 bits\n        // x has only one limb\n        out[0] = Limb::from(t) << (Limb::WIDTH - out_prec);\n    } else {\n        // p >= 12\n        //\n        // compared to Algorithm 3.9 of [1], we have {a, an} = A / 2 if a_s = 0, and A / 4 if a_s =\n        // 1.\n        //\n        // h = max(11, ceil((p + 3) / 2)) is the bitsize of the recursive call\n        let h = if out_prec < 18 {\n            11\n        } else {\n            (out_prec >> 1) + 2\n        };\n        // limb size of the recursive Xh\n        let xs_rec_len = bit_to_limb_count_ceiling(h);\n        // a priori limb size of Xh^2\n        let rn = bit_to_limb_count_ceiling(h << 1);\n        let ln = out_len - xs_rec_len; // remaining limbs to be computed\n        // Since |Xh - A ^ {-1 / 2}| <= 2 ^ {-h}, then by multiplying by Xh + A ^ {-1 / 2} we get\n        // |Xh ^ 2 - 1 / A| <= 2 ^ {-h + 1}, thus |A * Xh ^ 2 - 1| <= 2 ^ {-h + 3}, thus the h-3\n        // most significant bits of t should be zero, which is in fact h + 1 + a_s - 3 because of\n        // the normalization of A. This corresponds to th=floor((h + 1 + a_s - 3) / Limb::WIDTH)\n        // limbs.\n        //\n        // More precisely we have |Xh ^ 2 - 1 / A| <= 2^{-h} * (Xh + A^{-1 / 2}) <= 2^{-h} * (2\n        // A^{-1 / 2} + 2^{-h}) <= 2.001 * 2^{-h} * A^{-1 / 2} since A < 4 and h >= 11, thus |A * Xh\n        // ^ 2 - 1| <= 2.001 * 2^{-h} * A^{1 / 2} <= 1.001 * 2 ^ {2 - h}. This is sufficient to\n        // prove that the upper limb of {t,tn} below is less that 0.501 * 2 ^ Limb::WIDTH, thus cu =\n        // 0 below.\n        let hp = h + 1 + u64::from(parity);\n        let th = bit_to_limb_count_floor(hp - 3);\n        let mut ts_len = bit_to_limb_count_ceiling(hp + h);\n        // we need h + 1 + a_s bits of a\n        //\n        // number of high limbs of A needed for the recursive call\n        let mut ahn = bit_to_limb_count_ceiling(hp);\n        if ahn > xs_len {\n            ahn = xs_len;\n        }\n        let (out_lo, out_hi) = out.split_at_mut(ln);\n        limbs_reciprocal_sqrt(\n            out_hi,\n            h,\n            &xs[xs_len - ahn..],\n            limb_to_bit_count(ahn),\n            parity,\n        );\n        // the most h significant bits of X are set, X has ceil(h / Limb::WIDTH) limbs, the low (-h)\n        // % Limb::WIDTH bits are zero\n        //\n        // compared to Algorithm 3.9 of [1], we have {x+ln,xn} = X_h\n        //\n        // first step: square X in r, result is exact\n        let mut us_len = xs_rec_len + (ts_len - th);\n        // We use the same temporary buffer to store r and u: r needs 2*xn limbs where u needs\n        // xn+(tn-th) limbs. Since tn can store at least 2h bits, and th at most h bits, then tn-th\n        // can store at least h bits, thus tn - th >= xn, and reserving the space for u is enough.\n        assert!(xs_rec_len << 1 <= us_len);\n        let sn = xs_len + rn;\n        let mut scratch = vec![0; (us_len << 1) + sn];\n        split_into_chunks_mut!(scratch, us_len, [us, rs], ss);\n        let mut rs = rs;\n        if h << 1 <= Limb::WIDTH {\n            // xn=rn=1, and since p <= 2h-3, n=1, thus ln = 0\n            assert_eq!(ln, 0);\n            let cy = out_hi[0] >> const { Limb::WIDTH >> 1 };\n            rs = &mut rs[1..];\n            rs[0] = cy.square();\n        } else if xs_rec_len == 1 {\n            // xn = 1, rn = 2\n            (rs[1], rs[0]) = Limb::x_mul_y_to_zz(out_hi[0], out_hi[0]);\n        } else {\n            let mut scratch = vec![0; limbs_square_to_out_scratch_len(xs_rec_len)];\n            limbs_square_to_out(rs, out_hi, &mut scratch);\n            // we have {r, 2 * xn} = X_h ^ 2\n            if rn < xs_rec_len << 1 {\n                rs = &mut rs[1..];\n            }\n        }\n        // now the 2h most significant bits of {r, rn} contains X ^ 2, r has rn limbs, and the low\n        // (-2h) % Limb::WIDTH bits are zero\n        //\n        // Second step: s <- A * (r ^ 2), and truncate the low ap bits, i.e., at weight 2 ^ {-2h} (s\n        // is aligned to the low significant bits)\n        if rn == 1 {\n            // rn=1 implies n=1, since rn*Limb::WIDTH >= 2h, and 2h >= p + 3\n            //\n            // necessarily p <= Limb::WIDTH-3: we can ignore the two low bits from A\n            //\n            // since n=1, and we ensured an <= n, we also have an=1\n            assert_eq!(xs_len, 1);\n            (ss[1], ss[0]) = Limb::x_mul_y_to_zz(rs[0], xs[0]);\n        } else {\n            // we have p <= n * Limb::WIDTH 2h <= rn * Limb::WIDTH with p+3 <= 2h <= p+4 thus n <=\n            // rn <= n + 1\n            assert!(rn <= out_len + 1);\n            // since we ensured an <= n, we have an <= rn\n            assert!(xs_len <= rn);\n            let mut scratch = vec![0; limbs_mul_greater_to_out_scratch_len(rn, xs_len)];\n            limbs_mul_greater_to_out(ss, &rs[..rn], xs, &mut scratch);\n            // s should be near B ^ sn / 2 ^ (1 + a_s), thus s[sn-1] is either\n            // - 100000... or 011111... if a_s = 0, or\n            // - 010000... or 001111... if a_s = 1.\n            // We ignore the bits of s after the first 2h + 1 + a_s ones. We have {s, rn+an} = A *\n            // X_h ^ 2 / 2 if a_s = 0, A * X_h ^ 2 / 4 if a_s = 1.\n        }\n        // We ignore the bits of s after the first 2h + 1 + a_s ones: s has rn + an limbs, where rn\n        // = LIMBS(2h), an = LIMBS(a), and tn = LIMBS(2h + 1 + a_s).\n        let ts = &mut ss[sn - ts_len..]; // pointer to low limb of the high part of t\n        // the upper h-3 bits of 1 - t should be zero, where 1 corresponds to the most significant\n        // bit of t[tn - 1] if a_s = 0, and to the 2nd most significant bit of t[tn - 1] if a_s = 1\n        //\n        // compute t <- 1 - t, which is B^tn - {t, tn + 1}, with rounding toward -Inf, i.e.,\n        // rounding the input t toward +Inf. We could only modify the low tn - th limbs from t, but\n        // it gives only a small speedup, and would make the code more complex.\n        let bit = if parity {\n            const { LIMB_HIGH_BIT >> 1 }\n        } else {\n            LIMB_HIGH_BIT\n        };\n        let ts_last = ts.last_mut().unwrap();\n        let neg = *ts_last & bit;\n        if neg == 0 {\n            // Ax ^ 2 < 1: we have t = th + eps, where 0 <= eps < ulp(th) is the part truncated\n            // above, thus 1 - t rounded to -Inf is 1 - th - ulp(th)\n            //\n            // since the 1 + a_s most significant bits of t are zero, set them to 1 before the\n            // one-complement\n            *ts_last |= LIMB_HIGH_BIT | bit;\n            limbs_not_in_place(ts);\n            // we should add 1 here to get 1-th complement, and subtract 1 for -ulp(th), thus we do\n            // nothing\n        } else {\n            // negative case: we want 1 - t rounded toward -Inf, i.e., th + eps rounded toward +Inf,\n            // which is th + ulp(th): we discard the bit corresponding to 1, and we add 1 to the\n            // least significant bit of t\n            *ts_last ^= neg;\n            limbs_slice_add_limb_in_place(ts, 1);\n        }\n        // we know at least th = floor((h + 1 + a_s - 3) / Limb::WIDTH) of the high limbs of {t, tn}\n        // are zero\n        ts_len -= th;\n        // tn = rn - th, where rn * Limb::WIDTH >= 2 * h and th * Limb::WIDTH <= h + 1 + a_s - 3,\n        // thus tn > 0\n        assert_ne!(ts_len, 0);\n        // u <- x * t, where {t, tn} contains at least h + 3 bits, and {x, xn} contains h bits, thus\n        // tn >= xn\n        assert!(ts_len >= xs_rec_len);\n        if ts_len == 1 {\n            // necessarily xn = 1\n            (us[1], us[0]) = Limb::x_mul_y_to_zz(ts[0], out_hi[0]);\n        } else {\n            let mut scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ts_len, xs_rec_len)];\n            limbs_mul_greater_to_out(us, &ts[..ts_len], out_hi, &mut scratch);\n        }\n        // we have {u, tn+xn} = T_l X_h / 2 if a_s = 0, T_l X_h / 4 if a_s = 1\n        //\n        // we have already discarded the upper th high limbs of t, thus we only have to consider the\n        // upper n - th limbs of u\n        us_len = out_len - th;\n        // un cannot be zero, since p <= n * Limb::WIDTH, h = ceil((p + 3) / 2) <= (p + 4) / 2, th *\n        // Limb::WIDTH <= h - 1 <= p / 2 + 1, thus (n - th) * Limb::WIDTH >= p / 2 - 1.\n        assert_ne!(us_len, 0);\n        let u_offset = ts_len + xs_rec_len - us_len;\n        // xn + tn - un = xn + (original_tn - th) - (n - th) = xn + original_tn - n = LIMBS(h) +\n        // LIMBS(2h + 1 + a_s) - LIMBS(p) > 0 since 2h >= p + 3\n        assert_ne!(u_offset, 0); // will allow to access u[-1] below\n        // In case a_s = 0, u contains |x * (1 - Ax ^ 2) / 2|, which is exactly what we need to add\n        // or subtract. In case a_s = 1, u contains |x * (1 - Ax ^ 2) / 4|, thus we need to multiply\n        // u by 2.\n        if parity {\n            // shift on un+1 limbs to get most significant bit of u[-1] into least significant bit\n            // of u[0]\n            limbs_slice_shl_in_place(&mut us[u_offset - 1..u_offset + us_len], 1);\n        }\n        // now {u,un} represents U / 2 from Algorithm 3.9\n        let shift_bit = Limb::power_of_2(limb_to_bit_count(out_len) - out_prec);\n        // We want that the low pl bits are zero after rounding to nearest, thus we round u to\n        // nearest at bit pl - 1 of u[0]\n        let (us_head, us_tail) = us[u_offset - 1..].split_first_mut().unwrap();\n        let us_tail = &mut us_tail[..us_len];\n        let cu = if shift_bit == 1 {\n            // round bit is in u[-1]\n            limbs_slice_add_limb_in_place(us_tail, *us_head >> const { Limb::WIDTH - 1 })\n        } else {\n            let uu = us_tail[0];\n            let cu = limbs_slice_add_limb_in_place(us_tail, uu & (shift_bit >> 1));\n            // mask bits 0..pl - 1 of u[0]\n            us_tail[0] &= !(shift_bit - 1);\n            cu\n        };\n        assert!(!cu);\n        // We already have filled {x + ln, xn = n - ln}, and we want to add or subtract {u, un} at\n        // position x.\n        // - un = n - th, where th contains <= h + 1 + a_s - 3 <= h - 1 bits\n        // - ln = n - xn, where xn contains >= h bits\n        // - thus un > ln.\n        // Warning: ln might be zero.\n        assert!(us_len > ln);\n        // we can have un = ln + 2, for example with Limb::WIDTH = 32 and p = 62, a_s = 0, then h =\n        // 33, n = 2, th = 0, xn = 2, thus un = 2 and ln = 0.\n        assert!(us_len == ln + 1 || us_len == ln + 2);\n        // the high un-ln limbs of u will overlap the low part of {x+ln,xn}, we need to add or\n        // subtract the overlapping part {u + ln, un - ln}\n        //\n        // Warning! th may be 0, in which case the mpn_add_1 and mpn_sub_1 below (with size = th)\n        // mustn't be used.\n        let mut carry;\n        let (us_lo, us_hi) = us_tail.split_at_mut(ln);\n        if neg == 0 {\n            if ln != 0 {\n                out_lo.copy_from_slice(us_lo);\n            }\n            carry = limbs_slice_add_greater_in_place_left(out_hi, us_hi);\n            // cy is the carry at x + (ln + xn) = x + n\n        } else {\n            // negative case\n            //\n            // subtract {u+ln, un-ln} from {x+ln,un}\n            carry = limbs_sub_greater_in_place_left(out_hi, us_hi);\n            // cy is the borrow at x + (ln + xn) = x + n\n            //\n            // cy cannot be non-zero, since the most significant bit of Xh is 1, and the correction\n            // is bounded by 2^{-h+3}\n            assert!(!carry);\n            if ln != 0 {\n                limbs_not_to_out(out, us_lo);\n                // we must add one for the 2-complement\n                carry = limbs_slice_add_limb_in_place(out, 1);\n                // ... and subtract 1 at x[ln], where n = ln + xn\n                if limbs_sub_limb_in_place(&mut out[ln..], 1) {\n                    assert!(carry);\n                    carry = false;\n                }\n            }\n        }\n        // cy can be 1 when A=1, i.e., {a, n} = B ^ n. In that case we should have X = B ^ n, and\n        // setting X to 1-2^{-p} satisfies the error bound of 1 ulp.\n        if carry {\n            assert!(limbs_sub_limb_in_place(out, shift_bit));\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 1999-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::shr::limbs_shr_to_out;\nuse crate::natural::arithmetic::sqrt::limbs_sqrt_to_out_return_inexact;\nuse crate::natural::{LIMB_HIGH_BIT, Natural, bit_to_limb_count_ceiling};\nuse crate::platform::Limb;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{NegModPowerOf2, Parity, PowerOf2};\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse malachite_base::num::arithmetic::traits::{\n    WrappingAddAssign, WrappingSubAssign, XMulYToZZ, XXAddYYToZZ, XXSubYYToZZ, XXXSubYYYToZZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\n// For 257 <= d10 <= 1024, T[d10-257] = floor(sqrt(2 ^ 30 / d10)).\n//\n// Sage code:\n//\n// T = [floor(sqrt(2 ^ 30 / d10)) for d10 in [257..1024]]\n//\n// This is T from invsqrt_limb.c, MPFR 4.3.0.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst T: [u16; 768] = [\n    2044, 2040, 2036, 2032, 2028, 2024, 2020, 2016, 2012, 2009, 2005, 2001, 1997, 1994, 1990, 1986,\n    1983, 1979, 1975, 1972, 1968, 1965, 1961, 1958, 1954, 1951, 1947, 1944, 1941, 1937, 1934, 1930,\n    1927, 1924, 1920, 1917, 1914, 1911, 1907, 1904, 1901, 1898, 1895, 1891, 1888, 1885, 1882, 1879,\n    1876, 1873, 1870, 1867, 1864, 1861, 1858, 1855, 1852, 1849, 1846, 1843, 1840, 1837, 1834, 1831,\n    1828, 1826, 1823, 1820, 1817, 1814, 1812, 1809, 1806, 1803, 1801, 1798, 1795, 1792, 1790, 1787,\n    1784, 1782, 1779, 1777, 1774, 1771, 1769, 1766, 1764, 1761, 1759, 1756, 1754, 1751, 1749, 1746,\n    1744, 1741, 1739, 1736, 1734, 1731, 1729, 1727, 1724, 1722, 1719, 1717, 1715, 1712, 1710, 1708,\n    1705, 1703, 1701, 1698, 1696, 1694, 1692, 1689, 1687, 1685, 1683, 1680, 1678, 1676, 1674, 1672,\n    1670, 1667, 1665, 1663, 1661, 1659, 1657, 1655, 1652, 1650, 1648, 1646, 1644, 1642, 1640, 1638,\n    1636, 1634, 1632, 1630, 1628, 1626, 1624, 1622, 1620, 1618, 1616, 1614, 1612, 1610, 1608, 1606,\n    1604, 1602, 1600, 1598, 1597, 1595, 1593, 1591, 1589, 1587, 1585, 1583, 1582, 1580, 1578, 1576,\n    1574, 1572, 1571, 1569, 1567, 1565, 1563, 1562, 1560, 1558, 1556, 1555, 1553, 1551, 1549, 1548,\n    1546, 1544, 1542, 1541, 1539, 1537, 1536, 1534, 1532, 1531, 1529, 1527, 1526, 1524, 1522, 1521,\n    1519, 1517, 1516, 1514, 1513, 1511, 1509, 1508, 1506, 1505, 1503, 1501, 1500, 1498, 1497, 1495,\n    1494, 1492, 1490, 1489, 1487, 1486, 1484, 1483, 1481, 1480, 1478, 1477, 1475, 1474, 1472, 1471,\n    1469, 1468, 1466, 1465, 1463, 1462, 1461, 1459, 1458, 1456, 1455, 1453, 1452, 1450, 1449, 1448,\n    1446, 1445, 1443, 1442, 1441, 1439, 1438, 1436, 1435, 1434, 1432, 1431, 1430, 1428, 1427, 1426,\n    1424, 1423, 1422, 1420, 1419, 1418, 1416, 1415, 1414, 1412, 1411, 1410, 1408, 1407, 1406, 1404,\n    1403, 1402, 1401, 1399, 1398, 1397, 1395, 1394, 1393, 1392, 1390, 1389, 1388, 1387, 1385, 1384,\n    1383, 1382, 1381, 1379, 1378, 1377, 1376, 1374, 1373, 1372, 1371, 1370, 1368, 1367, 1366, 1365,\n    1364, 1362, 1361, 1360, 1359, 1358, 1357, 1355, 1354, 1353, 1352, 1351, 1350, 1349, 1347, 1346,\n    1345, 1344, 1343, 1342, 1341, 1339, 1338, 1337, 1336, 1335, 1334, 1333, 1332, 1331, 1330, 1328,\n    1327, 1326, 1325, 1324, 1323, 1322, 1321, 1320, 1319, 1318, 1317, 1315, 1314, 1313, 1312, 1311,\n    1310, 1309, 1308, 1307, 1306, 1305, 1304, 1303, 1302, 1301, 1300, 1299, 1298, 1297, 1296, 1295,\n    1294, 1293, 1292, 1291, 1290, 1289, 1288, 1287, 1286, 1285, 1284, 1283, 1282, 1281, 1280, 1279,\n    1278, 1277, 1276, 1275, 1274, 1273, 1272, 1271, 1270, 1269, 1268, 1267, 1266, 1265, 1264, 1264,\n    1263, 1262, 1261, 1260, 1259, 1258, 1257, 1256, 1255, 1254, 1253, 1252, 1252, 1251, 1250, 1249,\n    1248, 1247, 1246, 1245, 1244, 1243, 1242, 1242, 1241, 1240, 1239, 1238, 1237, 1236, 1235, 1234,\n    1234, 1233, 1232, 1231, 1230, 1229, 1228, 1228, 1227, 1226, 1225, 1224, 1223, 1222, 1222, 1221,\n    1220, 1219, 1218, 1217, 1216, 1216, 1215, 1214, 1213, 1212, 1211, 1211, 1210, 1209, 1208, 1207,\n    1207, 1206, 1205, 1204, 1203, 1202, 1202, 1201, 1200, 1199, 1198, 1198, 1197, 1196, 1195, 1194,\n    1194, 1193, 1192, 1191, 1190, 1190, 1189, 1188, 1187, 1187, 1186, 1185, 1184, 1183, 1183, 1182,\n    1181, 1180, 1180, 1179, 1178, 1177, 1177, 1176, 1175, 1174, 1174, 1173, 1172, 1171, 1171, 1170,\n    1169, 1168, 1168, 1167, 1166, 1165, 1165, 1164, 1163, 1162, 1162, 1161, 1160, 1159, 1159, 1158,\n    1157, 1157, 1156, 1155, 1154, 1154, 1153, 1152, 1152, 1151, 1150, 1149, 1149, 1148, 1147, 1147,\n    1146, 1145, 1145, 1144, 1143, 1142, 1142, 1141, 1140, 1140, 1139, 1138, 1138, 1137, 1136, 1136,\n    1135, 1134, 1133, 1133, 1132, 1131, 1131, 1130, 1129, 1129, 1128, 1127, 1127, 1126, 1125, 1125,\n    1124, 1123, 1123, 1122, 1121, 1121, 1120, 1119, 1119, 1118, 1118, 1117, 1116, 1116, 1115, 1114,\n    1114, 1113, 1112, 1112, 1111, 1110, 1110, 1109, 1109, 1108, 1107, 1107, 1106, 1105, 1105, 1104,\n    1103, 1103, 1102, 1102, 1101, 1100, 1100, 1099, 1099, 1098, 1097, 1097, 1096, 1095, 1095, 1094,\n    1094, 1093, 1092, 1092, 1091, 1091, 1090, 1089, 1089, 1088, 1088, 1087, 1086, 1086, 1085, 1085,\n    1084, 1083, 1083, 1082, 1082, 1081, 1080, 1080, 1079, 1079, 1078, 1077, 1077, 1076, 1076, 1075,\n    1075, 1074, 1073, 1073, 1072, 1072, 1071, 1071, 1070, 1069, 1069, 1068, 1068, 1067, 1067, 1066,\n    1065, 1065, 1064, 1064, 1063, 1063, 1062, 1062, 1061, 1060, 1060, 1059, 1059, 1058, 1058, 1057,\n    1057, 1056, 1055, 1055, 1054, 1054, 1053, 1053, 1052, 1052, 1051, 1051, 1050, 1049, 1049, 1048,\n    1048, 1047, 1047, 1046, 1046, 1045, 1045, 1044, 1044, 1043, 1043, 1042, 1041, 1041, 1040, 1040,\n    1039, 1039, 1038, 1038, 1037, 1037, 1036, 1036, 1035, 1035, 1034, 1034, 1033, 1033, 1032, 1032,\n    1031, 1031, 1030, 1030, 1029, 1029, 1028, 1028, 1027, 1027, 1026, 1026, 1025, 1025, 1024, 1024,\n];\n\n// table of v0^3\n//\n// This is T from invsqrt_limb.c, MPFR 4.3.0.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst T3: [u64; 768] = [\n    8539701184, 8489664000, 8439822656, 8390176768, 8340725952, 8291469824, 8242408000, 8193540096,\n    8144865728, 8108486729, 8060150125, 8012006001, 7964053973, 7928215784, 7880599000, 7833173256,\n    7797729087, 7750636739, 7703734375, 7668682048, 7622111232, 7587307125, 7541066681, 7506509912,\n    7460598664, 7426288351, 7380705123, 7346640384, 7312680621, 7267563953, 7233848504, 7189057000,\n    7155584983, 7122217024, 7077888000, 7044762213, 7011739944, 6978821031, 6935089643, 6902411264,\n    6869835701, 6837362792, 6804992375, 6761990971, 6729859072, 6697829125, 6665900968, 6634074439,\n    6602349376, 6570725617, 6539203000, 6507781363, 6476460544, 6445240381, 6414120712, 6383101375,\n    6352182208, 6321363049, 6290643736, 6260024107, 6229504000, 6199083253, 6168761704, 6138539191,\n    6108415552, 6088387976, 6058428767, 6028568000, 5998805513, 5969141144, 5949419328, 5919918129,\n    5890514616, 5861208627, 5841725401, 5812581592, 5783534875, 5754585088, 5735339000, 5706550403,\n    5677858304, 5658783768, 5630252139, 5611284433, 5582912824, 5554637011, 5535839609, 5507723096,\n    5489031744, 5461074081, 5442488479, 5414689216, 5396209064, 5368567751, 5350192749, 5322708936,\n    5304438784, 5277112021, 5258946419, 5231776256, 5213714904, 5186700891, 5168743489, 5150827583,\n    5124031424, 5106219048, 5079577959, 5061868813, 5044200875, 5017776128, 5000211000, 4982686912,\n    4956477625, 4939055927, 4921675101, 4895680392, 4878401536, 4861163384, 4843965888, 4818245769,\n    4801149703, 4784094125, 4767078987, 4741632000, 4724717752, 4707843776, 4691010024, 4674216448,\n    4657463000, 4632407963, 4615754625, 4599141247, 4582567781, 4566034179, 4549540393, 4533086375,\n    4508479808, 4492125000, 4475809792, 4459534136, 4443297984, 4427101288, 4410944000, 4394826072,\n    4378747456, 4362708104, 4346707968, 4330747000, 4314825152, 4298942376, 4283098624, 4267293848,\n    4251528000, 4235801032, 4220112896, 4204463544, 4188852928, 4173281000, 4157747712, 4142253016,\n    4126796864, 4111379208, 4096000000, 4080659192, 4073003173, 4057719875, 4042474857, 4027268071,\n    4012099469, 3996969003, 3981876625, 3966822287, 3959309368, 3944312000, 3929352552, 3914430976,\n    3899547224, 3884701248, 3877292411, 3862503009, 3847751263, 3833037125, 3818360547, 3811036328,\n    3796416000, 3781833112, 3767287616, 3760028875, 3745539377, 3731087151, 3716672149, 3709478592,\n    3695119336, 3680797184, 3666512088, 3659383421, 3645153819, 3630961153, 3623878656, 3609741304,\n    3595640768, 3588604291, 3574558889, 3560550183, 3553559576, 3539605824, 3525688648, 3518743761,\n    3504881359, 3491055413, 3484156096, 3470384744, 3463512697, 3449795831, 3436115229, 3429288512,\n    3415662216, 3408862625, 3395290527, 3381754501, 3375000000, 3361517992, 3354790473, 3341362375,\n    3334661784, 3321287488, 3307949000, 3301293169, 3288008303, 3281379256, 3268147904, 3261545587,\n    3248367641, 3241792000, 3228667352, 3222118333, 3209046875, 3202524424, 3189506048, 3183010111,\n    3170044709, 3163575232, 3150662696, 3144219625, 3131359847, 3124943128, 3118535181, 3105745579,\n    3099363912, 3086626816, 3080271375, 3067586677, 3061257408, 3048625000, 3042321849, 3036027392,\n    3023464536, 3017196125, 3004685307, 2998442888, 2992209121, 2979767519, 2973559672, 2961169856,\n    2954987875, 2948814504, 2936493568, 2930345991, 2924207000, 2911954752, 2905841483, 2899736776,\n    2887553024, 2881473967, 2875403448, 2863288000, 2857243059, 2851206632, 2839159296, 2833148375,\n    2827145944, 2815166528, 2809189531, 2803221000, 2791309312, 2785366143, 2779431416, 2767587264,\n    2761677827, 2755776808, 2749884201, 2738124199, 2732256792, 2726397773, 2714704875, 2708870984,\n    2703045457, 2697228288, 2685619000, 2679826869, 2674043072, 2668267603, 2656741625, 2650991104,\n    2645248887, 2639514968, 2633789341, 2622362939, 2616662152, 2610969633, 2605285376, 2593941624,\n    2588282117, 2582630848, 2576987811, 2571353000, 2560108032, 2554497863, 2548895896, 2543302125,\n    2537716544, 2526569928, 2521008881, 2515456000, 2509911279, 2504374712, 2498846293, 2487813875,\n    2482309864, 2476813977, 2471326208, 2465846551, 2460375000, 2454911549, 2444008923, 2438569736,\n    2433138625, 2427715584, 2422300607, 2416893688, 2411494821, 2400721219, 2395346472, 2389979753,\n    2384621056, 2379270375, 2373927704, 2368593037, 2363266368, 2357947691, 2352637000, 2342039552,\n    2336752783, 2331473976, 2326203125, 2320940224, 2315685267, 2310438248, 2305199161, 2299968000,\n    2294744759, 2289529432, 2284322013, 2273930875, 2268747144, 2263571297, 2258403328, 2253243231,\n    2248091000, 2242946629, 2237810112, 2232681443, 2227560616, 2222447625, 2217342464, 2212245127,\n    2207155608, 2202073901, 2197000000, 2191933899, 2186875592, 2181825073, 2176782336, 2171747375,\n    2166720184, 2161700757, 2156689088, 2151685171, 2146689000, 2141700569, 2136719872, 2131746903,\n    2126781656, 2121824125, 2116874304, 2111932187, 2106997768, 2102071041, 2097152000, 2092240639,\n    2087336952, 2082440933, 2077552576, 2072671875, 2067798824, 2062933417, 2058075648, 2053225511,\n    2048383000, 2043548109, 2038720832, 2033901163, 2029089096, 2024284625, 2019487744, 2019487744,\n    2014698447, 2009916728, 2005142581, 2000376000, 1995616979, 1990865512, 1986121593, 1981385216,\n    1976656375, 1971935064, 1967221277, 1962515008, 1962515008, 1957816251, 1953125000, 1948441249,\n    1943764992, 1939096223, 1934434936, 1929781125, 1925134784, 1920495907, 1915864488, 1915864488,\n    1911240521, 1906624000, 1902014919, 1897413272, 1892819053, 1888232256, 1883652875, 1879080904,\n    1879080904, 1874516337, 1869959168, 1865409391, 1860867000, 1856331989, 1851804352, 1851804352,\n    1847284083, 1842771176, 1838265625, 1833767424, 1829276567, 1824793048, 1824793048, 1820316861,\n    1815848000, 1811386459, 1806932232, 1802485313, 1798045696, 1798045696, 1793613375, 1789188344,\n    1784770597, 1780360128, 1775956931, 1775956931, 1771561000, 1767172329, 1762790912, 1758416743,\n    1758416743, 1754049816, 1749690125, 1745337664, 1740992427, 1736654408, 1736654408, 1732323601,\n    1728000000, 1723683599, 1719374392, 1719374392, 1715072373, 1710777536, 1706489875, 1702209384,\n    1702209384, 1697936057, 1693669888, 1689410871, 1685159000, 1685159000, 1680914269, 1676676672,\n    1672446203, 1672446203, 1668222856, 1664006625, 1659797504, 1655595487, 1655595487, 1651400568,\n    1647212741, 1643032000, 1643032000, 1638858339, 1634691752, 1630532233, 1630532233, 1626379776,\n    1622234375, 1618096024, 1618096024, 1613964717, 1609840448, 1605723211, 1605723211, 1601613000,\n    1597509809, 1593413632, 1593413632, 1589324463, 1585242296, 1581167125, 1581167125, 1577098944,\n    1573037747, 1568983528, 1568983528, 1564936281, 1560896000, 1556862679, 1556862679, 1552836312,\n    1548816893, 1548816893, 1544804416, 1540798875, 1536800264, 1536800264, 1532808577, 1528823808,\n    1528823808, 1524845951, 1520875000, 1516910949, 1516910949, 1512953792, 1509003523, 1509003523,\n    1505060136, 1501123625, 1501123625, 1497193984, 1493271207, 1489355288, 1489355288, 1485446221,\n    1481544000, 1481544000, 1477648619, 1473760072, 1473760072, 1469878353, 1466003456, 1466003456,\n    1462135375, 1458274104, 1454419637, 1454419637, 1450571968, 1446731091, 1446731091, 1442897000,\n    1439069689, 1439069689, 1435249152, 1431435383, 1431435383, 1427628376, 1423828125, 1423828125,\n    1420034624, 1416247867, 1416247867, 1412467848, 1408694561, 1408694561, 1404928000, 1401168159,\n    1401168159, 1397415032, 1397415032, 1393668613, 1389928896, 1389928896, 1386195875, 1382469544,\n    1382469544, 1378749897, 1375036928, 1375036928, 1371330631, 1367631000, 1367631000, 1363938029,\n    1363938029, 1360251712, 1356572043, 1356572043, 1352899016, 1349232625, 1349232625, 1345572864,\n    1341919727, 1341919727, 1338273208, 1338273208, 1334633301, 1331000000, 1331000000, 1327373299,\n    1327373299, 1323753192, 1320139673, 1320139673, 1316532736, 1312932375, 1312932375, 1309338584,\n    1309338584, 1305751357, 1302170688, 1302170688, 1298596571, 1298596571, 1295029000, 1291467969,\n    1291467969, 1287913472, 1287913472, 1284365503, 1280824056, 1280824056, 1277289125, 1277289125,\n    1273760704, 1270238787, 1270238787, 1266723368, 1266723368, 1263214441, 1259712000, 1259712000,\n    1256216039, 1256216039, 1252726552, 1249243533, 1249243533, 1245766976, 1245766976, 1242296875,\n    1242296875, 1238833224, 1235376017, 1235376017, 1231925248, 1231925248, 1228480911, 1228480911,\n    1225043000, 1221611509, 1221611509, 1218186432, 1218186432, 1214767763, 1214767763, 1211355496,\n    1207949625, 1207949625, 1204550144, 1204550144, 1201157047, 1201157047, 1197770328, 1197770328,\n    1194389981, 1191016000, 1191016000, 1187648379, 1187648379, 1184287112, 1184287112, 1180932193,\n    1180932193, 1177583616, 1174241375, 1174241375, 1170905464, 1170905464, 1167575877, 1167575877,\n    1164252608, 1164252608, 1160935651, 1160935651, 1157625000, 1154320649, 1154320649, 1151022592,\n    1151022592, 1147730823, 1147730823, 1144445336, 1144445336, 1141166125, 1141166125, 1137893184,\n    1137893184, 1134626507, 1134626507, 1131366088, 1128111921, 1128111921, 1124864000, 1124864000,\n    1121622319, 1121622319, 1118386872, 1118386872, 1115157653, 1115157653, 1111934656, 1111934656,\n    1108717875, 1108717875, 1105507304, 1105507304, 1102302937, 1102302937, 1099104768, 1099104768,\n    1095912791, 1095912791, 1092727000, 1092727000, 1089547389, 1089547389, 1086373952, 1086373952,\n    1083206683, 1083206683, 1080045576, 1080045576, 1076890625, 1076890625, 1073741824, 1073741824,\n];\n\n// This is mpfr_sqrt from sqrt.c, MPFR 4.3.0.\n#[cfg(not(feature = \"32_bit_limbs\"))]\npub fn sqrt_float_significand_in_place(\n    x: &mut Natural,\n    x_exp: i32,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    if out_prec == x_prec\n        && let Some((exp, o)) = sqrt_float_significand_in_place_same_prec(x, x_exp, out_prec, rm)\n    {\n        return (exp, o);\n    }\n    let (sqrt, exp, o) = match &*x {\n        Natural(Small(x)) => sqrt_float_significand_ref_helper(&[*x], x_exp, x_prec, out_prec, rm),\n        Natural(Large(xs)) => sqrt_float_significand_ref_helper(xs, x_exp, x_prec, out_prec, rm),\n    };\n    *x = sqrt;\n    (exp, o)\n}\n\n// This is mpfr_sqrt from sqrt.c, MPFR 4.3.0.\n#[cfg(feature = \"32_bit_limbs\")]\npub fn sqrt_float_significand_in_place(\n    x: &mut Natural,\n    x_exp: i32,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    let (sqrt, exp, o) = match &*x {\n        Natural(Small(x)) => sqrt_float_significand_ref_helper(&[*x], x_exp, x_prec, out_prec, rm),\n        Natural(Large(xs)) => sqrt_float_significand_ref_helper(xs, x_exp, x_prec, out_prec, rm),\n    };\n    *x = sqrt;\n    (exp, o)\n}\n\n// This is mpfr_sqrt from sqrt.c, MPFR 4.3.0.\npub fn sqrt_float_significand_ref(\n    x: &Natural,\n    x_exp: i32,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    match x {\n        Natural(Small(x)) => sqrt_float_significand_ref_helper(&[*x], x_exp, x_prec, out_prec, rm),\n        Natural(Large(xs)) => sqrt_float_significand_ref_helper(xs, x_exp, x_prec, out_prec, rm),\n    }\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn sqrt_float_significand_ref_helper(\n    xs: &[Limb],\n    x_exp: i32,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    if out_prec == x_prec\n        && let Some(out) = sqrt_float_significand_same_prec_ref(xs, x_exp, x_prec, rm)\n    {\n        return out;\n    }\n    sqrt_float_significands_general(xs, x_exp, out_prec, rm)\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn sqrt_float_significand_in_place_same_prec(\n    x: &mut Natural,\n    x_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(i32, Ordering)> {\n    match x {\n        Natural(Small(x)) => {\n            let (sqrt, exp, o) = if prec == Limb::WIDTH {\n                sqrt_float_significand_same_prec_w(*x, x_exp, rm)\n            } else {\n                sqrt_float_significand_same_prec_lt_w(*x, x_exp, prec, rm)\n            };\n            *x = sqrt;\n            Some((exp, o))\n        }\n        Natural(Large(xs)) => match xs.as_mut_slice() {\n            [x_0, x_1] if prec != const { Limb::WIDTH << 1 } => {\n                let (sqrt_0, sqrt_1, exp, o) =\n                    sqrt_float_significand_same_prec_gt_w_lt_2w(*x_0, *x_1, x_exp, prec, rm);\n                *x_0 = sqrt_0;\n                *x_1 = sqrt_1;\n                Some((exp, o))\n            }\n            _ => None,\n        },\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[inline]\nfn sqrt_float_significand_ref_helper(\n    xs: &[Limb],\n    x_exp: i32,\n    _x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    sqrt_float_significands_general(xs, x_exp, out_prec, rm)\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn sqrt_float_significand_same_prec_ref(\n    xs: &[Limb],\n    x_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(Natural, i32, Ordering)> {\n    match xs {\n        [x] => {\n            let (sqrt, exp, o) = if prec == Limb::WIDTH {\n                sqrt_float_significand_same_prec_w(*x, x_exp, rm)\n            } else {\n                sqrt_float_significand_same_prec_lt_w(*x, x_exp, prec, rm)\n            };\n            Some((Natural::from(sqrt), exp, o))\n        }\n        [x_0, x_1] if prec != const { Limb::WIDTH << 1 } => {\n            let (sqrt_0, sqrt_1, exp, o) =\n                sqrt_float_significand_same_prec_gt_w_lt_2w(*x_0, *x_1, x_exp, prec, rm);\n            Some((Natural(Large(vec![sqrt_0, sqrt_1])), exp, o))\n        }\n        _ => None,\n    }\n}\n\n// given 2 ^ 62 <= d < 2 ^ 64, return a 32-bit approximation r of sqrt(2 ^ 126 / d)\n//\n// This is __gmpfr_invsqrt_halflimb_approx from invsqrt_limb.c, MPFR 4.3.0, returning r.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn half_limb_inverse_sqrt_approx(d: Limb) -> Limb {\n    let i = usize::wrapping_from((d >> 54) - 256);\n    // i = d10 - 256\n    let v0 = Limb::from(T[i]);\n    let d37 = 1 + (d >> 27);\n    let e0 = T3[i].wrapping_mul(d37);\n    // the value (v0 << 57) - e0 is less than 2 ^ 61\n    let v1 = (v0 << 11) + ((v0 << 57).wrapping_sub(e0) >> 47);\n    let e1 = v1.wrapping_neg().wrapping_mul(v1).wrapping_mul(d37);\n    let h = Limb::x_mul_y_to_zz(v1, e1).0;\n    // h = floor(e1 * v1 / 2 ^ 64)\n    (v1 << 10) + (h >> 6)\n}\n\n// given 2^62 <= n < 2^64, put in s an approximation of sqrt(2^64*n), with: s <= floor(sqrt(2^64*n))\n// <= s + 7\n//\n// This is __gmpfr_sqrt_limb_approx from invsqrt_limb.c, MPFR 4.3.0, returning s.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn limb_sqrt_approx(n: Limb) -> Limb {\n    let x = half_limb_inverse_sqrt_approx(n);\n    const LIMIT: u64 = 1 << 32;\n    assert!(x < LIMIT);\n    // x has 32 bits, and is near (by below) sqrt(2 ^ 126 / n)\n    let mut y = (x * (n >> 31)) >> 32;\n    assert!(y < LIMIT);\n    // y is near (by below) sqrt(n)\n    let mut z = n - y * y;\n    // reduce z so that z <= 2 * y\n    //\n    // the maximal value of z is 2 * (2 ^ 32 - 1)\n    while z > const { (LIMIT - 1) << 1 } {\n        z -= (y << 1) + 1;\n        y += 1;\n    }\n    // now z <= 2 * (2 ^ 32 - 1): one reduction is enough\n    let two_y = y << 1;\n    if z > two_y {\n        z -= two_y + 1;\n        y += 1;\n    }\n    // x * z should be < 2 ^ 64\n    (y << 32) + ((x * z) >> 32)\n}\n\n// Special code for prec(r) = prec(u) < Limb::WIDTH. We cannot have prec(u) = Limb::WIDTH here,\n// since when the exponent of u is odd, we need to shift u by one bit to the right without losing\n// any bit.\n//\n// This is mpfr_sqrt1 from sqrt.c, MPFR 4.3.0.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn sqrt_float_significand_same_prec_lt_w(\n    mut x: Limb,\n    mut x_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, i32, Ordering) {\n    let shift = Limb::WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    if x_exp.odd() {\n        x >>= 1;\n        x_exp += 1;\n    }\n    let mut exp_r = x_exp >> 1;\n    // then compute an approximation of the integer square root of x * 2 ^ Limb::WIDTH\n    let mut r0 = limb_sqrt_approx(x);\n    // when we can round correctly with the approximation, the sticky bit is non-zero\n    let mut sticky_bit = 1;\n    // the exact square root is in [r0, r0 + 7]\n    if r0.wrapping_add(7) & (mask >> 1) <= 7 {\n        // We should ensure r0 has its most significant bit set. Since r0 <= sqrt(2 ^ 64 * x) <= r0\n        // + 7, as soon as sqrt(2 ^ 64 * x) >= 2 ^ 63 + 7, which happens for x >= 2 ^ 62 + 8, then\n        // r0 >= 2 ^ 63. It thus remains to check that for 2 ^ 62 <= x <= 2 ^ 62 + 7,\n        // __gmpfr_sqrt_limb_approx (r0, x) gives r0 >= 2 ^ 63, which is indeed the case:\n        //\n        // ```\n        // x = 4611686018427387904 r0 = 9223372036854775808\n        // x = 4611686018427387905 r0 = 9223372036854775808\n        // x = 4611686018427387906 r0 = 9223372036854775809\n        // x = 4611686018427387907 r0 = 9223372036854775810\n        // x = 4611686018427387908 r0 = 9223372036854775811\n        // x = 4611686018427387909 r0 = 9223372036854775812\n        // x = 4611686018427387910 r0 = 9223372036854775813\n        // x = 4611686018427387911 r0 = 9223372036854775814\n        // ```\n        assert!(r0.get_highest_bit());\n        let mut round_bit;\n        (round_bit, sticky_bit) = Limb::x_mul_y_to_zz(r0, r0);\n        (round_bit, sticky_bit) = Limb::xx_sub_yy_to_zz(x, 0, round_bit, sticky_bit);\n        // for the exact square root, we should have 0 <= round_bit:sticky_bit <= 2*r0\n        while round_bit != 0 && (round_bit != 1 || sticky_bit > r0 << 1) {\n            // subtract 2 * r0 + 1 from round_bit:sticky_bit: subtract r0 before incrementing r0,\n            // then r0 after (which is r0 + 1)\n            if sticky_bit < r0 {\n                round_bit.wrapping_sub_assign(1);\n            }\n            sticky_bit.wrapping_sub_assign(r0);\n            r0 += 1;\n            if sticky_bit < r0 {\n                round_bit.wrapping_sub_assign(1);\n            }\n            sticky_bit.wrapping_sub_assign(r0);\n        }\n        // now we should have round_bit * 2 ^ 64 + sticky_bit <= 2 * r0\n        assert!(round_bit == 0 || (round_bit == 1 && sticky_bit <= r0 << 1));\n        sticky_bit |= round_bit;\n    }\n    let round_bit = r0 & (shift_bit >> 1);\n    sticky_bit |= (r0 & mask) ^ round_bit;\n    r0 &= !mask;\n    // rounding: sticky_bit = 0 implies round_bit = 0, since (round_bit, sticky_bit) = (1, 0) is not\n    // possible\n    if sticky_bit == 0 {\n        assert_eq!(round_bit, 0);\n        return (r0, exp_r, Equal);\n    }\n    match rm {\n        Floor | Down => (r0, exp_r, Less),\n        Ceiling | Up => {\n            r0.wrapping_add_assign(shift_bit);\n            if r0 == 0 {\n                r0 = LIMB_HIGH_BIT;\n                exp_r += 1;\n            }\n            (r0, exp_r, Greater)\n        }\n        Nearest => {\n            // since sticky_bit != 0, only round_bit is needed to decide how to round, and the exact\n            // middle is not possible\n            if round_bit == 0 {\n                (r0, exp_r, Less)\n            } else {\n                r0.wrapping_add_assign(shift_bit);\n                if r0 == 0 {\n                    r0 = LIMB_HIGH_BIT;\n                    exp_r += 1;\n                }\n                (r0, exp_r, Greater)\n            }\n        }\n        Exact => panic!(\"Inexact float square root\"),\n    }\n}\n\n// This is mpfr_sqrt1n from sqrt.c, MPFR 4.3.0.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn sqrt_float_significand_same_prec_w(\n    mut x: Limb,\n    mut x_exp: i32,\n    rm: RoundingMode,\n) -> (Limb, i32, Ordering) {\n    let low = if x_exp.odd() {\n        let low = x << (Limb::WIDTH - 1);\n        x >>= 1;\n        x_exp += 1;\n        low\n    } else {\n        0\n    };\n    let mut exp_r = x_exp >> 1;\n    // then compute an approximation of the integer square root of x*2 ^ Limb::WIDTH\n    let mut r0 = limb_sqrt_approx(x);\n    // the exact square root is in [r0, r0 + 7]\n    //\n    // As shown in sqrt_float_significand_same_prec_lt_w above, r0 has its most significant bit set\n    assert!(r0.get_highest_bit());\n    let (mut round_bit, mut sticky_bit) = Limb::x_mul_y_to_zz(r0, r0);\n    (round_bit, sticky_bit) = Limb::xx_sub_yy_to_zz(x, low, round_bit, sticky_bit);\n    // for the exact square root, we should have 0 <= round_bit:sticky_bit <= 2*r0\n    while round_bit != 0 && (round_bit != 1 || sticky_bit > r0 << 1) {\n        // subtract 2 * r0 + 1 from round_bit:sticky_bit: subtract r0 before incrementing r0, then\n        // r0 after (which is r0 + 1)\n        if sticky_bit < r0 {\n            round_bit -= 1;\n        }\n        sticky_bit.wrapping_sub_assign(r0);\n        r0 += 1;\n        if sticky_bit < r0 {\n            round_bit -= 1;\n        }\n        sticky_bit.wrapping_sub_assign(r0);\n    }\n    // now we have x * 2 ^ 64 + low = r0 ^ 2 + round_bit * 2 ^ 64 + sticky_bit, with round_bit * 2 ^\n    // 64 + sticky_bit <= 2 * r0\n    //\n    // We can't have the middle case x * 2 ^ 64 = (r0 + 1 / 2) ^ 2 since (r0 + 1 / 2) ^ 2 is not an\n    // integer. We thus round_bit = 1 whenever x * 2 ^ 64 > (r0 + 1 / 2) ^ 2, thus round_bit * 2 ^\n    // 64 + sticky_bit > r0 and the sticky bit is always 1, unless we had round_bit = sticky_bit =\n    // 0.\n    if sticky_bit > r0 {\n        round_bit |= 1;\n    }\n    sticky_bit |= round_bit;\n    // sticky_bit = 0 can only occur when the square root is exact, i.e., round_bit = 0\n    if sticky_bit == 0 {\n        assert_eq!(round_bit, 0);\n        return (r0, exp_r, Equal);\n    }\n    match rm {\n        Floor | Down => (r0, exp_r, Less),\n        Ceiling | Up => {\n            r0.wrapping_add_assign(1);\n            if r0 == 0 {\n                r0 = LIMB_HIGH_BIT;\n                exp_r += 1;\n            }\n            (r0, exp_r, Greater)\n        }\n        Nearest => {\n            // we can't have sticky_bit = 0, thus round_bit is enough\n            if round_bit == 0 {\n                (r0, exp_r, Less)\n            } else {\n                r0.wrapping_add_assign(1);\n                if r0 == 0 {\n                    r0 = LIMB_HIGH_BIT;\n                    exp_r += 1;\n                }\n                (r0, exp_r, Greater)\n            }\n        }\n        Exact => panic!(\"Inexact float square root\"),\n    }\n}\n\n// given 2^62 <= d < 2^64, return  an approximation of s = floor(2^96/sqrt(d)) - 2^64, with r <= s\n// <= r + 15\n//\n// This is __gmpfr_invsqrt_limb_approx from invsqrt_limb.c, MPFR 4.3.0, returning r.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn limb_inverse_sqrt_approx(d: Limb) -> Limb {\n    let i = ((d >> 54) - 256) as usize;\n    // i = d10 - 256\n    let v0 = Limb::from(T[i]);\n    let d37 = 1 + (d >> 27);\n    let e0 = T3[i].wrapping_mul(d37);\n    // the value (v0 << 57) - e0 is less than 2^61\n    let v1 = (v0 << 11) + ((v0 << 57).wrapping_sub(e0) >> 47);\n    let e1 = v1.wrapping_neg().wrapping_mul(v1).wrapping_mul(d37);\n    let mut h = Limb::x_mul_y_to_zz(v1, e1).0;\n    // h = floor(e_1 * v_1 /2 ^ 64)\n    let v2 = (v1 << 10) + (h >> 6);\n    h = Limb::x_mul_y_to_zz(v2 * v2, d).0;\n    // in h + 2, one +1 accounts for the lower neglected part of v2 ^ 2 * d. the other +1 is to\n    // compute ceil((h + 1) / 2)\n    let e2 = (1 << 61) - ((h + 2) >> 1);\n    h = v2 * e2;\n    (v2 << 33) + (h >> 29)\n}\n\n// given 2^62 <= u < 2^64, put in s the value floor(sqrt(2^64*u)), and in rh in rl the remainder:\n// 2^64*u - s^2 = 2^64*rh + rl, with 2^64*rh + rl <= 2*s, and in invs the approximation of\n// 2^96/sqrt(u)\n//\n// This is __gmpfr_sqrt_limb from invsqrt_limb.c, MPFR 4.3.0, returning s, rh, rl, and invs.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn limb_sqrt(u: Limb) -> (Limb, Limb, Limb, Limb) {\n    let invs = limb_inverse_sqrt_approx(u);\n    let mut h = Limb::x_mul_y_to_zz(invs, u).0;\n    let mut r = h + u;\n    // make sure r has its most significant bit set\n    if !r.get_highest_bit() {\n        r = LIMB_HIGH_BIT;\n    }\n    // we know r <= sqrt(2 ^ 64 * u) <= r + 16\n    let mut l;\n    (h, l) = Limb::x_mul_y_to_zz(r, r);\n    (h, l) = Limb::xx_sub_yy_to_zz(u, 0, h, l);\n    // now h:l <= 30 * r\n    assert!(h < 30);\n    if h >= 16 {\n        // subtract 16r + 64 to h:l, add 8 to r\n        (h, l) = Limb::xx_sub_yy_to_zz(h, l, r >> 60, r << 4);\n        (h, l) = Limb::xx_sub_yy_to_zz(h, l, 0, 64);\n        r += 8;\n    }\n    if h >= 8 {\n        // subtract 8r + 16 to h:l, add 4 to r\n        (h, l) = Limb::xx_sub_yy_to_zz(h, l, r >> 61, r << 3);\n        (h, l) = Limb::xx_sub_yy_to_zz(h, l, 0, 16);\n        r += 4;\n    }\n    if h >= 4 {\n        // subtract 4r + 4 to h:l, add 2 to _r\n        (h, l) = Limb::xx_sub_yy_to_zz(h, l, r >> 62, r << 2);\n        (h, l) = Limb::xx_sub_yy_to_zz(h, l, 0, 4);\n        r += 2;\n    }\n    while h > 1 || ((h == 1) && (l > r << 1)) {\n        // subtract 2r + 1 to h:l, add 1 to r\n        (h, l) = Limb::xx_sub_yy_to_zz(h, l, r >> 63, (r << 1) + 1);\n        r += 1;\n    }\n    (r, h, l, invs)\n}\n\n// Put in rp[1] * 2 ^ 64 + rp[0] an approximation of floor(sqrt(2^128*n)), with 2 ^ 126 <= n :=\n// np[1] * 2 ^ 64 + np[0] < 2 ^ 128. We have: {rp, 2} - 4 <= floor(sqrt(2 ^ 128 * n)) <= {rp, 2} +\n// 26.\n//\n// This is mpfr_sqrt2_approx from sqrt.c, MPFR 4.3.0.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn limbs_2_sqrt_approx(n0: Limb, n1: Limb) -> (Limb, Limb) {\n    let (mut r1, mut h, mut l, x) = limb_sqrt(n1);\n    // now r1 = floor(sqrt(2 ^ 64 * n1)) and h:l = 2 ^ 64 * n1 - r1 ^ 2 with h:l <= 2 * r1, thus h\n    // <= 1, and x is an approximation of 2 ^ 96 / sqrt(n1) - 2 ^ 64\n    l.wrapping_add_assign(n0);\n    if l < n0 {\n        h += 1;\n    }\n    // now 2 ^ 64 * n1 + n0 - r1 ^ 2 = 2 ^ 64 * h + l with h <= 2\n    //\n    // divide by 2\n    l = (h << 63) | (l >> 1);\n    h >>= 1;\n    // now h <= 1\n    //\n    // now add (2 ^ 64 + x) * (h * 2 ^ 64 + l) / 2 ^ 64 to [r1 * 2 ^ 64, 0]\n    let mut r0 = Limb::x_mul_y_to_zz(x, l).0; // x * l\n    r0.wrapping_add_assign(l);\n    r1 += h + Limb::from(r0 < l); // now we have added 2 ^ 64 * (h * 2 ^ 64 + l)\n    if h != 0 {\n        r0 += x;\n        if r0 < x {\n            r1 += 1;\n        }\n    }\n    assert!(r1.get_highest_bit());\n    (r0, r1)\n}\n\n// Doesn't compute highest limb, because caller doesn't need it\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn two_limbs_square(x_1: Limb, x_0: Limb) -> (Limb, Limb, Limb) {\n    let (x_00_1, x_00_0) = Limb::x_mul_y_to_zz(x_0, x_0);\n    let (mut x_01_1, mut x_01_0) = Limb::x_mul_y_to_zz(x_0, x_1);\n    x_01_1 = (x_01_1 << 1) | (x_01_0 >> const { Limb::WIDTH - 1 });\n    x_01_0 <<= 1;\n    (x_01_1, x_01_0) = Limb::xx_add_yy_to_zz(x_01_1, x_01_0, 0, x_00_1);\n    (x_1.wrapping_mul(x_1).wrapping_add(x_01_1), x_01_0, x_00_0)\n}\n\n// This is mpfr_sqrt2 from sqrt.c, MPFR 4.3.0.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn sqrt_float_significand_same_prec_gt_w_lt_2w(\n    x_0: Limb,\n    x_1: Limb,\n    mut x_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, i32, Ordering) {\n    let shift = const { Limb::WIDTH << 1 } - prec;\n    let (n3, n2, n1) = if x_exp.odd() {\n        const SHIFT: u64 = Limb::WIDTH - 1;\n        x_exp += 1;\n        (x_1 >> 1, (x_1 << SHIFT) | (x_0 >> 1), x_0 << SHIFT)\n    } else {\n        (x_1, x_0, 0)\n    };\n    let mut exp_r = x_exp >> 1;\n    let (mut r0, mut r1) = limbs_2_sqrt_approx(n2, n3);\n    // with n = np[3]*2^64+np[2], we have: {rp, 2} - 4 <= floor(sqrt(2^128*n)) <= {rp, 2} + 26, thus\n    // we can round correctly except when the number formed by the last shift-1 bits of rp[0] is in\n    // the range [-26, 4].\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    let mut sticky_bit = if r0.wrapping_add(26) & (mask >> 1) > 30 {\n        1\n    } else {\n        let (mut t2, mut t1, mut t0) = two_limbs_square(r1, r0);\n        // since we know s - 26 <= r <= s + 4 and 0 <= n^2 - s <= 2*s, we have -8*s-16 <= n - r^2 <=\n        // 54*s - 676, thus it suffices to compute n - r^2 modulo 2^192\n        (t2, t1, t0) = Limb::xxx_sub_yyy_to_zzz(n2, n1, 0, t2, t1, t0);\n        // invariant: h:l = 2 * {rp, 2}, with upper bit implicit\n        let mut h = (r1 << 1) | (r0 >> const { Limb::WIDTH - 1 });\n        let mut l = r0 << 1;\n        while t2.get_highest_bit() {\n            // approximation was too large\n            //\n            // subtract 1 to {rp, 2}, thus 2 to h:l\n            if l <= 1 {\n                h -= 1;\n            }\n            l -= 2;\n            // add (1:h:l)+1 to {tp,3}\n            t0.wrapping_add_assign(l + 1);\n            t1.wrapping_add_assign(h + Limb::from(t0 < l));\n            // necessarily r1 has its most significant bit set\n            t2.wrapping_add_assign(1 + Limb::from(t1 < h || (t1 == h && t0 < l)));\n        }\n        // now tp[2] >= 0\n        //\n        // now we want {tp, 4} <= 2 * {rp, 2}, which implies tp[2] <= 1\n        while t2 > 1 || (t2 == 1 && t1 > h) || (t2 == 1 && t1 == h && t0 > l) {\n            // subtract (1:h:l)+1 from {tp,3}\n            t2 -= 1 + Limb::from(t1 < h || (t1 == h && t0 <= l));\n            t1.wrapping_sub_assign(h + Limb::from(t0 <= l));\n            t0.wrapping_sub_assign(l + 1);\n            // add 2 to  h:l\n            l.wrapping_add_assign(2);\n            if l <= 1 {\n                h += 1;\n            }\n        }\n        // restore {rp, 2} from h:l\n        r1 = LIMB_HIGH_BIT | (h >> 1);\n        r0 = (h << const { Limb::WIDTH - 1 }) | (l >> 1);\n        t2 | t0 | t1\n    };\n    let round_bit = r0 & (shift_bit >> 1);\n    sticky_bit |= (r0 & mask) ^ round_bit;\n    r0 &= !mask;\n    if sticky_bit == 0 {\n        return (r0, r1, exp_r, Equal);\n    }\n    match rm {\n        Floor | Down => (r0, r1, exp_r, Less),\n        Ceiling | Up => {\n            r0.wrapping_add_assign(shift_bit);\n            if r0 == 0 {\n                r1.wrapping_add_assign(1);\n            }\n            if r1 == 0 {\n                r1 = LIMB_HIGH_BIT;\n                exp_r += 1;\n            }\n            (r0, r1, exp_r, Greater)\n        }\n        Nearest => {\n            // since sticky_bit != 0 now, only round_bit is needed\n            if round_bit == 0 {\n                (r0, r1, exp_r, Less)\n            } else {\n                r0.wrapping_add_assign(shift_bit);\n                if r0 == 0 {\n                    r1.wrapping_add_assign(1);\n                }\n                if r1 == 0 {\n                    r1 = LIMB_HIGH_BIT;\n                    exp_r += 1;\n                }\n                (r0, r1, exp_r, Greater)\n            }\n        }\n        Exact => panic!(\"Inexact float square root\"),\n    }\n}\n\nfn sqrt_float_significands_general(\n    xs: &[Limb],\n    x_exp: i32,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    let mut shift = out_prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    if shift == 0 && rm == Nearest {\n        // ugly case\n        shift = Limb::WIDTH;\n    }\n    let mut rsize = bit_to_limb_count_ceiling(out_prec);\n    if shift == Limb::WIDTH {\n        rsize += 1;\n    }\n    // rsize is the number of limbs of r + 1 if exact limb multiple and rounding to nearest, this is\n    // the number of wanted limbs for the square root\n    let rrsize = rsize << 1;\n    let xs_len = xs.len();\n    let mut out = vec![0; rsize];\n    let mut sticky0 = 0; // truncated part of input\n    let odd_exp = x_exp.odd();\n    let mut sp = vec![0; rrsize];\n    // copy the most significant limbs of u to {sp, rrsize}\n    if xs_len <= rrsize {\n        // in case r and u have the same precision, we have indeed rrsize = 2 * xs_len\n        let k = rrsize - xs_len;\n        if odd_exp {\n            if k == 0 {\n                sticky0 = limbs_shr_to_out(&mut sp, xs, 1);\n            } else {\n                sp[k - 1] = limbs_shr_to_out(&mut sp[k..], xs, 1);\n            }\n        } else {\n            sp[rrsize - xs_len..].copy_from_slice(xs);\n        }\n    } else {\n        // xs_len > rrsize: truncate the input\n        let k = xs_len - rrsize;\n        let (xs_lo, xs_hi) = xs.split_at(k);\n        if odd_exp {\n            sticky0 = limbs_shr_to_out(&mut sp, xs_hi, 1);\n        } else {\n            sp.copy_from_slice(xs_hi);\n        }\n        for &x in xs_lo.iter().rev() {\n            if sticky0 != 0 {\n                break;\n            }\n            sticky0 = x;\n        }\n    }\n    // sticky0 is non-zero iff the truncated part of the input is non-zero\n    let sqrt_inexact = limbs_sqrt_to_out_return_inexact(&mut out, &sp);\n    let mut sticky = sticky0 != 0 || sqrt_inexact;\n    // truncate low bits of rp[0]\n    let mut shift_bit = if shift == Limb::WIDTH {\n        0\n    } else {\n        Limb::power_of_2(shift)\n    };\n    let sticky1 = out[0] & shift_bit.wrapping_sub(1);\n    out[0] -= sticky1;\n    sticky |= sticky1 != 0;\n    let mut out_exp = (x_exp + i32::from(odd_exp)) >> 1; // exact\n    if !sticky {\n        if shift_bit == 0 {\n            out.remove(0);\n        }\n        return (Natural::from_owned_limbs_asc(out), out_exp, Equal);\n    }\n    let increment = match rm {\n        Floor | Down => false,\n        Ceiling | Up => true,\n        Nearest => {\n            // if shift < Limb::WIDTH: the round bit is bit (shift-1) of sticky1 and the sticky bit\n            // is formed by the low shift-1 bits from sticky1, together with the sqrtrem remainder\n            // and sticky0.\n            //\n            // if shift = Limb::WIDTH: the round bit is the most significant bit of rp[0], and the\n            // remaining Limb::WIDTH - 1 bits contribute to the sticky bit\n            let lower_bit = if shift_bit == 0 {\n                LIMB_HIGH_BIT\n            } else {\n                shift_bit >> 1\n            };\n            if sticky1 & lower_bit == 0 {\n                false\n            } else {\n                // round bit is set\n                if sticky1 == lower_bit && !sqrt_inexact && sticky0 == 0 {\n                    if shift_bit == 0 {\n                        out[1].odd()\n                    } else {\n                        out[0] & shift_bit != 0\n                    }\n                } else {\n                    true\n                }\n            }\n        }\n        Exact => panic!(\"Inexact float square root\"),\n    };\n    if shift_bit == 0 {\n        out.remove(0);\n        shift_bit = 1;\n    }\n    let o = if increment {\n        if limbs_slice_add_limb_in_place(&mut out, shift_bit) {\n            out_exp += 1;\n            *out.last_mut().unwrap() = LIMB_HIGH_BIT;\n        }\n        Greater\n    } else {\n        Less\n    };\n    (Natural::from_owned_limbs_asc(out), out_exp, o)\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 1999-2024 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::float_extras::round_helper_raw;\nuse crate::natural::arithmetic::float_mul::{\n    limbs_float_mul_high_same_length, limbs_float_mul_high_same_length_scratch_len,\n    mul_float_significands_ref_ref_helper,\n};\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::square::{limbs_square_to_out, limbs_square_to_out_scratch_len};\nuse crate::natural::{LIMB_HIGH_BIT, Natural, bit_to_limb_count_ceiling};\nuse crate::platform::{DoubleLimb, Limb};\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::max;\nuse malachite_base::num::arithmetic::traits::{\n    OverflowingAddAssign, Parity, PowerOf2, Sign, WrappingAddAssign, XMulYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, SplitInHalf, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\n// This is mpfr_sqr from sqr.c, MPFR 4.3.0.\npub fn square_float_significand_in_place(\n    x: &mut Natural,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    if out_prec == x_prec\n        && let Some((decrement_exp, o)) =\n            square_float_significand_in_place_same_prec(x, out_prec, rm)\n    {\n        return (-i32::from(decrement_exp), o);\n    }\n    let (square, exp_offset, o) = match &*x {\n        Natural(Small(x)) => square_float_significands_general(&[*x], x_prec, out_prec, rm),\n        Natural(Large(xs)) => square_float_significands_general(xs, x_prec, out_prec, rm),\n    };\n    *x = square;\n    (exp_offset, o)\n}\n\n// This is mpfr_sqr from sqr.c, MPFR 4.3.0.\npub fn square_float_significand_ref(\n    x: &Natural,\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    match x {\n        Natural(Small(x)) => square_float_significand_ref_helper(&[*x], x_prec, out_prec, rm),\n        Natural(Large(xs)) => square_float_significand_ref_helper(xs, x_prec, out_prec, rm),\n    }\n}\n\nfn square_float_significand_ref_helper(\n    xs: &[Limb],\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    if out_prec == x_prec\n        && let Some((square, decrement_exp, o)) =\n            square_float_significand_same_prec_ref(xs, out_prec, rm)\n    {\n        return (square, -i32::from(decrement_exp), o);\n    }\n    square_float_significands_general(xs, x_prec, out_prec, rm)\n}\n\nfn square_float_significand_in_place_same_prec(\n    x: &mut Natural,\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(bool, Ordering)> {\n    match x {\n        Natural(Small(x)) => {\n            let (square, decrement_exp, o) = if prec == Limb::WIDTH {\n                square_float_significand_same_prec_w(*x, rm)\n            } else {\n                square_float_significand_same_prec_lt_w(*x, prec, rm)\n            };\n            *x = square;\n            Some((decrement_exp, o))\n        }\n        Natural(Large(xs)) => match xs.as_mut_slice() {\n            [x_0, x_1] if prec != TWICE_WIDTH => {\n                let (square_0, square_1, decrement_exp, o) =\n                    square_float_significand_same_prec_gt_w_lt_2w(*x_0, *x_1, prec, rm);\n                *x_0 = square_0;\n                *x_1 = square_1;\n                Some((decrement_exp, o))\n            }\n            [x_0, x_1, x_2] if prec != THRICE_WIDTH => {\n                let (square_0, square_1, square_2, decrement_exp, o) =\n                    square_float_significand_same_prec_gt_2w_lt_3w(*x_0, *x_1, *x_2, prec, rm);\n                *x_0 = square_0;\n                *x_1 = square_1;\n                *x_2 = square_2;\n                Some((decrement_exp, o))\n            }\n            _ => None,\n        },\n    }\n}\n\nfn square_float_significand_same_prec_ref(\n    xs: &[Limb],\n    prec: u64,\n    rm: RoundingMode,\n) -> Option<(Natural, bool, Ordering)> {\n    match xs {\n        [x] => {\n            let (square, decrement_exp, o) = if prec == Limb::WIDTH {\n                square_float_significand_same_prec_w(*x, rm)\n            } else {\n                square_float_significand_same_prec_lt_w(*x, prec, rm)\n            };\n            Some((Natural(Small(square)), decrement_exp, o))\n        }\n        [x_0, x_1] if prec != TWICE_WIDTH => {\n            let (square_0, square_1, decrement_exp, o) =\n                square_float_significand_same_prec_gt_w_lt_2w(*x_0, *x_1, prec, rm);\n            Some((Natural(Large(vec![square_0, square_1])), decrement_exp, o))\n        }\n        [x_0, x_1, x_2] if prec != THRICE_WIDTH => {\n            let (square_0, square_1, square_2, decrement_exp, o) =\n                square_float_significand_same_prec_gt_2w_lt_3w(*x_0, *x_1, *x_2, prec, rm);\n            Some((\n                Natural(Large(vec![square_0, square_1, square_2])),\n                decrement_exp,\n                o,\n            ))\n        }\n        _ => None,\n    }\n}\n\nconst WIDTH_M1: u64 = Limb::WIDTH - 1;\nconst COMP_HIGH_BIT: Limb = !LIMB_HIGH_BIT;\n\n// This is mpfr_sqr_1 from sqr.c, MPFR 4.3.0.\nfn square_float_significand_same_prec_lt_w(\n    x: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, bool, Ordering) {\n    let shift = Limb::WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    let (mut z, mut sticky_bit) = Limb::x_mul_y_to_zz(x, x);\n    let decrement_exp = !z.get_highest_bit();\n    if decrement_exp {\n        z <<= 1;\n        z |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n    }\n    let round_bit = z & (shift_bit >> 1);\n    sticky_bit |= (z & mask) ^ round_bit;\n    let mut square = z & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float squaring\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && square & shift_bit == 0) {\n                (square, decrement_exp, Less)\n            } else if square.overflowing_add_assign(shift_bit) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (square, decrement_exp, Greater)\n            }\n        }\n        Floor | Down => (square, decrement_exp, Less),\n        Ceiling | Up => {\n            if square.overflowing_add_assign(shift_bit) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (square, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\n// This is mpfr_sqr_1n from sqr.c, MPFR 4.2.0.\nfn square_float_significand_same_prec_w(x: Limb, rm: RoundingMode) -> (Limb, bool, Ordering) {\n    let (mut z, mut sticky_bit) = Limb::x_mul_y_to_zz(x, x);\n    let decrement_exp = !z.get_highest_bit();\n    if decrement_exp {\n        z <<= 1;\n        z |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n    }\n    let round_bit = sticky_bit & LIMB_HIGH_BIT;\n    sticky_bit &= COMP_HIGH_BIT;\n    let mut square = z;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float squaring\"),\n        Nearest => {\n            if round_bit == 0 || (sticky_bit == 0 && square.even()) {\n                (square, decrement_exp, Less)\n            } else if square.overflowing_add_assign(1) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (square, decrement_exp, Greater)\n            }\n        }\n        Floor | Down => (square, decrement_exp, Less),\n        Ceiling | Up => {\n            if square.overflowing_add_assign(1) {\n                (LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (square, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\nconst TWICE_WIDTH: u64 = Limb::WIDTH * 2;\nconst THRICE_WIDTH: u64 = Limb::WIDTH * 3;\n\n// This is mpfr_sqr_2 from sqr.c, MPFR 4.2.0.\nfn square_float_significand_same_prec_gt_w_lt_2w(\n    x_0: Limb,\n    x_1: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, bool, Ordering) {\n    let shift = TWICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    // we store the 4-limb square in h = z[1], l = z[0], sticky_bit = z[-1], sticky_bit_2 = z[-2]\n    let (mut hi, mut lo) = Limb::x_mul_y_to_zz(x_1, x_1);\n    let (u, v) = Limb::x_mul_y_to_zz(x_0, x_1);\n    if lo.overflowing_add_assign(u) {\n        hi += 1;\n    }\n    if lo.overflowing_add_assign(u) {\n        hi.wrapping_add_assign(1);\n    }\n    // now the full square is {hi, lo, 2 * v + high(x_0 ^ 2), low(x_0 ^ 2)}, where the lower part\n    // contributes to less than 3 ulps to {hi, lo}.\n    //\n    // If hi has its most significant bit set and the low shift - 1 bits of lo are not 000...000 nor\n    // 111...111 nor 111...110, then we can round correctly; if hi has zero as most significant bit,\n    // we have to shift left hi and lo, thus if the low sh-2 bits are not 000...000 nor 111...111\n    // nor 111...110, then we can round correctly. To avoid an extra test we consider the latter\n    // case (if we can round, we can also round in the former case). For shift <= 3, we have mask <=\n    // 7, thus (mask >> 2) <= 1, and the approximation cannot be enough.\n    let (mut sticky_bit, sticky_bit_2);\n    if lo.wrapping_add(2) & (mask >> 2) > 2 {\n        // result cannot be exact in that case\n        sticky_bit = 1;\n        sticky_bit_2 = 1;\n    } else {\n        (sticky_bit, sticky_bit_2) = Limb::x_mul_y_to_zz(x_0, x_0);\n        // The full square is {h, l, sticky_bit + v + w, sticky_bit_2}\n        if sticky_bit.overflowing_add_assign(v) && lo.overflowing_add_assign(1) {\n            hi.wrapping_add_assign(1);\n        }\n        if sticky_bit.overflowing_add_assign(v) && lo.overflowing_add_assign(1) {\n            hi.wrapping_add_assign(1);\n        }\n    }\n    let decrement_exp = !hi.get_highest_bit();\n    if decrement_exp {\n        hi <<= 1;\n        hi |= lo >> WIDTH_M1;\n        lo <<= 1;\n        lo |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n        // no need to shift sticky_bit_2 since we only want to know if it is zero or not\n    }\n    let mut z_1 = hi;\n    let round_bit = lo & (shift_bit >> 1);\n    sticky_bit |= ((lo & mask) ^ round_bit) | sticky_bit_2;\n    let mut z_0 = lo & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z_0, z_1, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float squaring\"),\n        Nearest => {\n            if round_bit == 0 || sticky_bit == 0 && (z_0 & shift_bit) == 0 {\n                (z_0, z_1, decrement_exp, Less)\n            } else if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, decrement_exp, Greater)\n            }\n        }\n        Floor | Down => (z_0, z_1, decrement_exp, Less),\n        Ceiling | Up => {\n            if z_0.overflowing_add_assign(shift_bit) && z_1.overflowing_add_assign(1) {\n                (z_0, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\nconst LIMB_MASK: DoubleLimb = (1 << Limb::WIDTH) - 1;\n\n// This is mpfr_sqr_3 from sqr.c, MPFR 4.2.0.\nfn square_float_significand_same_prec_gt_2w_lt_3w(\n    x_0: Limb,\n    x_1: Limb,\n    x_2: Limb,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Limb, Limb, Limb, bool, Ordering) {\n    let shift = THRICE_WIDTH - prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let mask = shift_bit - 1;\n    // we store the upper 3-limb square in z2, z1, z0: x2 ^ 2, 2 * x1 * x2, 2 * x0 * x2 + x1 ^ 2\n    let x_0 = DoubleLimb::from(x_0);\n    let x_1 = DoubleLimb::from(x_1);\n    let x_2 = DoubleLimb::from(x_2);\n    let x_2_x_2 = x_2 * x_2;\n    let x_1_x_2 = x_1 * x_2;\n    let x_1_x_1 = x_1 * x_1;\n    let x_0_x_2 = x_0 * x_2;\n    let (mut a2, mut a1) = x_2_x_2.split_in_half();\n    let (hi, mut a0) = x_1_x_2.split_in_half();\n    if a1.overflowing_add_assign(hi) {\n        a2 += 1;\n    }\n    if a1.overflowing_add_assign(hi) {\n        a2.wrapping_add_assign(1);\n    }\n    let mut carry = Limb::from(a0.overflowing_add_assign(a0));\n    let x_0_x_2_hi = Limb::wrapping_from(x_0_x_2 >> Limb::WIDTH);\n    if a0.overflowing_add_assign(x_0_x_2_hi) {\n        carry += 1;\n    }\n    if a0.overflowing_add_assign(x_0_x_2_hi) {\n        carry += 1;\n    }\n    if a0.overflowing_add_assign(Limb::wrapping_from(x_1_x_1 >> Limb::WIDTH)) {\n        carry += 1;\n    }\n    // now propagate carry\n    if a1.overflowing_add_assign(carry) {\n        a2.wrapping_add_assign(1);\n    }\n    // Now the approximate square {a2, a1, a0} has an error of less than 5 ulps (3 ulps for the\n    // ignored low limbs of x_2 * y_0 + x_1 * y_1 + x_0 * y2, plus 2 ulps for the ignored x_1 * y_0\n    // + x_0 * y_1 (plus x_0 * y_0)). Since we might shift by 1 bit, we make sure the low shift - 2\n    // bits of a0 are not 0, -1, -2, -3 or -4.\n    let (mut sticky_bit, sticky_bit_2) = if a0.wrapping_add(4) & (mask >> 2) > 4 {\n        // result cannot be exact in that case\n        (1, 1)\n    } else {\n        let out = x_0 * x_0;\n        let p_0 = out & LIMB_MASK;\n        let x_0_x_1 = x_0 * x_1;\n        let out = x_0_x_1 + (out >> Limb::WIDTH);\n        let mut p_1 = out & LIMB_MASK;\n        let out = x_0_x_2 + (out >> Limb::WIDTH);\n        let mut p_2 = out & LIMB_MASK;\n        let mut p_3 = out >> Limb::WIDTH;\n        let out = p_1 + x_0_x_1;\n        p_1 = out & LIMB_MASK;\n        let out = p_2 + x_1_x_1 + (out >> Limb::WIDTH);\n        p_2 = out & LIMB_MASK;\n        let out = p_3 + x_1_x_2 + (out >> Limb::WIDTH);\n        p_3 = out & LIMB_MASK;\n        let p_4 = out >> Limb::WIDTH;\n        let out = p_2 + x_0_x_2;\n        p_2 = out & LIMB_MASK;\n        let out = p_3 + x_1_x_2 + (out >> Limb::WIDTH);\n        p_3 = out & LIMB_MASK;\n        let out = p_4 + x_2_x_2 + (out >> Limb::WIDTH);\n        (a2, a1) = out.split_in_half();\n        a0 = Limb::wrapping_from(p_3);\n        (\n            Limb::wrapping_from(p_2),\n            Limb::wrapping_from(p_1) | Limb::wrapping_from(p_0),\n        )\n    };\n    let decrement_exp = !a2.get_highest_bit();\n    if decrement_exp {\n        a2 <<= 1;\n        a2 |= a1 >> WIDTH_M1;\n        a1 <<= 1;\n        a1 |= a0 >> WIDTH_M1;\n        a0 <<= 1;\n        a0 |= sticky_bit >> WIDTH_M1;\n        sticky_bit <<= 1;\n        // no need to shift sticky_bit_2: we only need to know if it is zero or not\n    }\n    let mut z_2 = a2;\n    let mut z_1 = a1;\n    let round_bit = a0 & (shift_bit >> 1);\n    sticky_bit |= ((a0 & mask) ^ round_bit) | sticky_bit_2;\n    let mut z_0 = a0 & !mask;\n    if round_bit == 0 && sticky_bit == 0 {\n        return (z_0, z_1, z_2, decrement_exp, Equal);\n    }\n    match rm {\n        Exact => panic!(\"Inexact float squaring\"),\n        Nearest => {\n            if round_bit == 0 || sticky_bit == 0 && z_0 & shift_bit == 0 {\n                (z_0, z_1, z_2, decrement_exp, Less)\n            } else {\n                if z_0.overflowing_add_assign(shift_bit) {\n                    z_1.wrapping_add_assign(1);\n                }\n                if z_1 == 0 && z_0 == 0 {\n                    z_2.wrapping_add_assign(1);\n                }\n                if z_2 == 0 {\n                    (z_0, z_1, LIMB_HIGH_BIT, false, Greater)\n                } else {\n                    (z_0, z_1, z_2, decrement_exp, Greater)\n                }\n            }\n        }\n        Floor | Down => (z_0, z_1, z_2, decrement_exp, Less),\n        Ceiling | Up => {\n            if z_0.overflowing_add_assign(shift_bit) {\n                z_1.wrapping_add_assign(1);\n            }\n            if z_1 == 0 && z_0 == 0 {\n                z_2.wrapping_add_assign(1);\n            }\n            if z_2 == 0 {\n                (z_0, z_1, LIMB_HIGH_BIT, false, Greater)\n            } else {\n                (z_0, z_1, z_2, decrement_exp, Greater)\n            }\n        }\n    }\n}\n\npub(crate) fn limbs_float_square_high_scratch_len(n: usize) -> usize {\n    let k = MPFR_SQRHIGH_TAB\n        .get(n)\n        .map_or_else(|| isize::exact_from((n + 4) >> 1), |&x| isize::from(x));\n    if k < 0 {\n        limbs_square_to_out_scratch_len(n)\n    } else if k == 0 {\n        0\n    } else {\n        let k = usize::wrapping_from(k);\n        max(\n            limbs_square_to_out_scratch_len(k),\n            limbs_float_mul_high_same_length_scratch_len(n - k),\n        )\n    }\n}\n\npub(crate) const MPFR_SQRHIGH_TAB: [i8; 17] =\n    [-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\n// This is mpfr_mulhigh_n_basecase from mulders.c, MPFR 4.2.0, specialized for squaring.\nfn limbs_float_sqr_high_same_length_basecase(out: &mut [Limb], xs: &[Limb]) {\n    let len = xs.len();\n    // We neglect xs[0..len - 2] * xs[0], which is less than B ^ len\n    let out = &mut out[len - 1..];\n    (out[1], out[0]) = Limb::x_mul_y_to_zz(*xs.last().unwrap(), xs[0]);\n    for (i, x) in xs.iter().enumerate() {\n        let i = i + 1;\n        // Here, we neglect xs[0..len - i - 2] * xs[i], which is less than B ^ len too\n        let (out_lo, out_hi) = out.split_at_mut(i);\n        out_hi[0] = limbs_slice_add_mul_limb_same_length_in_place_left(out_lo, &xs[len - i..], *x);\n        // In total, we neglect less than n * B ^ len, i.e., n ulps of out[len].\n    }\n}\n\n// Put in out[n..2 * len - 1] an approximation of the n high limbs of xs ^ 2. The error is less than\n// len ulps of out[len] (and the approximation is always less or equal to the truncated full\n// square).\n//\n// Implements Algorithm ShortMul from:\n//\n// [1] Short Division of Long Integers, David Harvey and Paul Zimmermann, Proceedings of the 20th\n// Symposium on Computer Arithmetic (ARITH-20), July 25-27, 2011, pages 7-14.\n//\n// This is mpfr_sqrhigh_n from mulders.c, MPFR 4.2.0.\npub(crate) fn limbs_float_square_high(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    const LEN_ASSERT: bool = MPFR_SQRHIGH_TAB.len() > 2;\n    assert!(LEN_ASSERT);\n    let n = xs.len();\n    let k = MPFR_SQRHIGH_TAB\n        .get(n)\n        .map_or_else(|| isize::exact_from((n + 4) >> 1), |&x| isize::from(x));\n    assert!(\n        k == -1 || k == 0 || (k >= isize::exact_from((n + 4) >> 1) && k < isize::exact_from(n))\n    );\n    if k < 0 {\n        limbs_square_to_out(out, xs, scratch);\n    } else if k == 0 {\n        limbs_float_sqr_high_same_length_basecase(out, xs);\n    } else {\n        let k = usize::wrapping_from(k);\n        let l = n - k;\n        limbs_square_to_out(&mut out[l << 1..], &xs[l..], scratch);\n        let (xs_lo, xs_hi) = xs.split_at(k);\n        limbs_float_mul_high_same_length(out, &xs_lo[..l], xs_hi, scratch);\n        let (out_lo, out_hi) = out.split_at_mut(n - 1);\n        let out_lo = &mut out_lo[l - 1..l << 1];\n        let mut carry = limbs_slice_shl_in_place(out_lo, 1);\n        if limbs_slice_add_same_length_in_place_left(&mut out_hi[..=l], out_lo) {\n            carry += 1;\n        }\n        limbs_slice_add_limb_in_place(&mut out[n + l..n << 1], carry);\n    }\n}\n\nconst MPFR_SQR_THRESHOLD: usize = 20;\n\nfn square_float_significands_general(\n    xs: &[Limb],\n    x_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering) {\n    let xs_len = xs.len();\n    let tn = bit_to_limb_count_ceiling(x_prec << 1);\n    if xs_len > MPFR_SQR_THRESHOLD {\n        return mul_float_significands_ref_ref_helper(xs, x_prec, xs, x_prec, out_prec, rm);\n    }\n    let xs_len_2 = xs_len << 1;\n    let mut scratch = vec![0; xs_len_2 + limbs_square_to_out_scratch_len(xs.len())];\n    let (tmp, scratch) = scratch.split_at_mut(xs_len_2);\n    // Multiplies the mantissa in temporary allocated space\n    limbs_square_to_out(tmp, xs, scratch);\n    let mut b1 = tmp[xs_len_2 - 1];\n    // now tmp[0]..tmp[2 * xs_len - 1] contains the square of the mantissa, with tmp[2 * xs_len - 1]\n    // >= 2 ^ (Limb::WIDTH - 2)\n    b1 >>= const { Limb::WIDTH - 1 }; // msb from the product\n    // if the mantissas of b and c are uniformly distributed in (1/2, 1], then their product is in\n    // (1/4, 1/2] with probability 2 * ln(2) - 1 ~ 0.386 and in [1/2, 1] with probability 2 - 2 *\n    // ln(2) ~ 0.614\n    let tmp = &mut tmp[xs_len_2 - tn..];\n    if b1 == 0 {\n        limbs_slice_shl_in_place(&mut tmp[..tn], 1);\n    }\n    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n    let (inexact, increment_exp) = round_helper_raw(&mut out, out_prec, tmp, x_prec << 1, rm);\n    assert!(inexact == 0 || rm != Exact, \"Inexact float squaring\");\n    let mut exp_offset = -i32::from(b1 == 0);\n    if increment_exp {\n        exp_offset += 1;\n    }\n    (\n        Natural::from_owned_limbs_asc(out),\n        exp_offset,\n        inexact.sign(),\n    )\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/float_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 1999-2022 Free Software Foundation, Inc.\n//\n//      Contributed by the AriC and Caramba projects, INRIA.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::float_extras::{MPFR_EVEN_INEX, round_helper_even};\nuse crate::natural::arithmetic::is_power_of_2::limbs_is_power_of_2;\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::shr::limbs_shr_to_out;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_limb_in_place, limbs_sub_limb_to_out, limbs_sub_same_length_in_place_left,\n    limbs_sub_same_length_in_place_right, limbs_sub_same_length_to_out, sub_with_carry,\n};\nuse crate::natural::{\n    LIMB_HIGH_BIT, Natural, bit_to_limb_count_ceiling, bit_to_limb_count_floor, limb_to_bit_count,\n};\nuse crate::platform::Limb;\nuse core::cmp::{\n    Ordering::{self, *},\n    max,\n};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    IsPowerOf2, ModPowerOf2, ModPowerOf2Sub, NegAssign, NegModPowerOf2, OverflowingAddAssign,\n    OverflowingNegAssign, PowerOf2, SaturatingAddAssign, SaturatingSubAssign, Sign,\n    WrappingAddAssign, WrappingNegAssign, WrappingSubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ExactFrom, SaturatingFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::{slice_set_zero, slice_test_zero};\n\nconst WIDTH_M1: u64 = Limb::WIDTH - 1;\nconst IWIDTH_M1: isize = WIDTH_M1 as isize;\nconst WIDTH_M1_MASK: Limb = Limb::MAX >> 1;\nconst WIDTH_M2_MASK: Limb = Limb::MAX >> 2;\nconst HALF_LIMB_HIGH_BIT: Limb = LIMB_HIGH_BIT >> 1;\nconst IWIDTH: i32 = Limb::WIDTH as i32;\nconst NEG_ONE: Limb = Limb::MAX;\nconst NEG_TWO: Limb = Limb::MAX - 1;\nconst WIDTH_P1: u64 = Limb::WIDTH + 1;\nconst TWICE_WIDTH: u64 = Limb::WIDTH * 2;\nconst THRICE_WIDTH: u64 = Limb::WIDTH * 3;\nconst TWICE_WIDTH_P1: u64 = Limb::WIDTH * 2 + 1;\n\npub fn sub_float_significands_in_place(\n    mut x: &mut Natural,\n    x_exp: &mut i32,\n    x_prec: u64,\n    mut y: &mut Natural,\n    y_exp: i32,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Ordering, bool, bool) {\n    if x_prec == y_prec && out_prec == x_prec {\n        sub_float_significands_in_place_same_prec(x, x_exp, y, y_exp, out_prec, rm)\n    } else {\n        match (&mut x, &mut y) {\n            (Natural(Small(small_x)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *small_x = out[0];\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Large(out));\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                }\n            }\n            (Natural(Small(small_x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        ys,\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *small_x = out[0];\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        ys,\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Large(out));\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Small(out[0]));\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *xs = out;\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out, xs, *x_exp, x_prec, ys, y_exp, y_prec, out_prec, rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Small(out[0]));\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out, xs, *x_exp, x_prec, ys, y_exp, y_prec, out_prec, rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *xs = out;\n                        *x_exp = diff_exp;\n                    }\n                    (o, false, neg)\n                }\n            }\n        }\n    }\n}\n\npub fn sub_float_significands_in_place_ref(\n    mut x: &mut Natural,\n    x_exp: &mut i32,\n    x_prec: u64,\n    y: &Natural,\n    y_exp: i32,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Ordering, bool) {\n    if x_prec == y_prec && out_prec == x_prec {\n        sub_float_significands_in_place_same_prec_ref(x, x_exp, y, y_exp, out_prec, rm)\n    } else {\n        match (&mut x, y) {\n            (Natural(Small(small_x)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *small_x = out[0];\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Large(out));\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                }\n            }\n            (Natural(Small(small_x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        ys,\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *small_x = out[0];\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*small_x],\n                        *x_exp,\n                        x_prec,\n                        ys,\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Large(out));\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(small_y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Small(out[0]));\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        xs,\n                        *x_exp,\n                        x_prec,\n                        &[*small_y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *xs = out;\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out, xs, *x_exp, x_prec, ys, y_exp, y_prec, out_prec, rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *x = Natural(Small(out[0]));\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (diff_exp, o, neg) = sub_float_significands_general(\n                        &mut out, xs, *x_exp, x_prec, ys, y_exp, y_prec, out_prec, rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    if *out.last().unwrap() == 0 {\n                        *x = Natural::ZERO;\n                    } else {\n                        *xs = out;\n                        *x_exp = diff_exp;\n                    }\n                    (o, neg)\n                }\n            }\n        }\n    }\n}\n\npub fn sub_float_significands_ref_ref<'a>(\n    x: &'a Natural,\n    x_exp: i32,\n    x_prec: u64,\n    y: &'a Natural,\n    y_exp: i32,\n    y_prec: u64,\n    out_prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering, bool) {\n    if x_prec == y_prec && out_prec == x_prec {\n        sub_float_significands_same_prec_ref_ref(x, x_exp, y, y_exp, out_prec, rm)\n    } else {\n        match (x, y) {\n            (Natural(Small(x)), Natural(Small(y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        x_prec,\n                        &[*y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (Natural(Small(out[0])), out_exp, o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        x_prec,\n                        &[*y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (\n                        if *out.last().unwrap() == 0 {\n                            Natural::ZERO\n                        } else {\n                            Natural(Large(out))\n                        },\n                        out_exp,\n                        o,\n                        neg,\n                    )\n                }\n            }\n            (Natural(Small(x)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        x_prec,\n                        ys,\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (Natural(Small(out[0])), out_exp, o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        &[*x],\n                        x_exp,\n                        x_prec,\n                        ys,\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (\n                        if *out.last().unwrap() == 0 {\n                            Natural::ZERO\n                        } else {\n                            Natural(Large(out))\n                        },\n                        out_exp,\n                        o,\n                        neg,\n                    )\n                }\n            }\n            (Natural(Large(xs)), Natural(Small(y))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        xs,\n                        x_exp,\n                        x_prec,\n                        &[*y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (Natural(Small(out[0])), out_exp, o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out,\n                        xs,\n                        x_exp,\n                        x_prec,\n                        &[*y],\n                        y_exp,\n                        y_prec,\n                        out_prec,\n                        rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (\n                        if *out.last().unwrap() == 0 {\n                            Natural::ZERO\n                        } else {\n                            Natural(Large(out))\n                        },\n                        out_exp,\n                        o,\n                        neg,\n                    )\n                }\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                if out_prec <= Limb::WIDTH {\n                    let mut out = [0];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out, xs, x_exp, x_prec, ys, y_exp, y_prec, out_prec, rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (Natural(Small(out[0])), out_exp, o, neg)\n                } else {\n                    let mut out = vec![0; bit_to_limb_count_ceiling(out_prec)];\n                    let (out_exp, o, neg) = sub_float_significands_general(\n                        &mut out, xs, x_exp, x_prec, ys, y_exp, y_prec, out_prec, rm,\n                    );\n                    assert!(rm != Exact || o == Equal, \"Inexact float subtraction\");\n                    (\n                        if *out.last().unwrap() == 0 {\n                            Natural::ZERO\n                        } else {\n                            Natural(Large(out))\n                        },\n                        out_exp,\n                        o,\n                        neg,\n                    )\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_sub1sp from sub1sp.c, MPFR 4.2.0.\nfn sub_float_significands_in_place_same_prec(\n    x: &mut Natural,\n    x_exp: &mut i32,\n    y: &mut Natural,\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Ordering, bool, bool) {\n    match (&mut *x, &mut *y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (diff, diff_exp, o, neg) = if prec == Limb::WIDTH {\n                sub_float_significands_same_prec_w(*x, *x_exp, *y, y_exp, rm)\n            } else {\n                sub_float_significands_same_prec_lt_w(*x, *x_exp, *y, y_exp, prec, rm)\n            };\n            *x = diff;\n            *x_exp = diff_exp;\n            (o, false, neg)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_mut_slice()) {\n            ([x_0, x_1], [y_0, y_1]) => {\n                let (diff_0, diff_1, diff_exp, o, neg) = if prec == TWICE_WIDTH {\n                    sub_float_significands_same_prec_2w(*x_0, *x_1, *x_exp, *y_0, *y_1, y_exp, rm)\n                } else {\n                    sub_float_significands_same_prec_gt_w_lt_2w(\n                        *x_0, *x_1, *x_exp, *y_0, *y_1, y_exp, prec, rm,\n                    )\n                };\n                if diff_1 == 0 {\n                    *x = Natural::ZERO;\n                } else {\n                    *x_0 = diff_0;\n                    *x_1 = diff_1;\n                }\n                *x_exp = diff_exp;\n                (o, false, neg)\n            }\n            ([x_0, x_1, x_2], [y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (diff_0, diff_1, diff_2, diff_exp, o, neg) =\n                    sub_float_significands_same_prec_gt_2w_lt_3w(\n                        *x_0, *x_1, *x_2, *x_exp, *y_0, *y_1, *y_2, y_exp, prec, rm,\n                    );\n                if diff_2 == 0 {\n                    *x = Natural::ZERO;\n                } else {\n                    *x_0 = diff_0;\n                    *x_1 = diff_1;\n                    *x_2 = diff_2;\n                }\n                *x_exp = diff_exp;\n                (o, false, neg)\n            }\n            (xs, ys) => {\n                let (diff_exp, o, neg) =\n                    sub_float_significands_same_prec_ge_3w_val_val(xs, *x_exp, ys, y_exp, prec, rm);\n                if *xs.last().unwrap() == 0 {\n                    *x = Natural::ZERO;\n                } else {\n                    *x_exp = diff_exp;\n                }\n                (o, neg, neg)\n            }\n        },\n        _ => unreachable!(),\n    }\n}\n\n// This is mpfr_sub1sp from sub1sp.c, MPFR 4.2.0.\nfn sub_float_significands_in_place_same_prec_ref(\n    x: &mut Natural,\n    x_exp: &mut i32,\n    y: &Natural,\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Ordering, bool) {\n    match (&mut *x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (diff, diff_exp, o, neg) = if prec == Limb::WIDTH {\n                sub_float_significands_same_prec_w(*x, *x_exp, *y, y_exp, rm)\n            } else {\n                sub_float_significands_same_prec_lt_w(*x, *x_exp, *y, y_exp, prec, rm)\n            };\n            *x = diff;\n            *x_exp = diff_exp;\n            (o, neg)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_mut_slice(), ys.as_slice()) {\n            ([x_0, x_1], &[y_0, y_1]) => {\n                let (diff_0, diff_1, diff_exp, o, neg) = if prec == TWICE_WIDTH {\n                    sub_float_significands_same_prec_2w(*x_0, *x_1, *x_exp, y_0, y_1, y_exp, rm)\n                } else {\n                    sub_float_significands_same_prec_gt_w_lt_2w(\n                        *x_0, *x_1, *x_exp, y_0, y_1, y_exp, prec, rm,\n                    )\n                };\n                if diff_1 == 0 {\n                    *x = Natural::ZERO;\n                } else {\n                    *x_0 = diff_0;\n                    *x_1 = diff_1;\n                }\n                *x_exp = diff_exp;\n                (o, neg)\n            }\n            ([x_0, x_1, x_2], &[y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (diff_0, diff_1, diff_2, diff_exp, o, neg) =\n                    sub_float_significands_same_prec_gt_2w_lt_3w(\n                        *x_0, *x_1, *x_2, *x_exp, y_0, y_1, y_2, y_exp, prec, rm,\n                    );\n                if diff_2 == 0 {\n                    *x = Natural::ZERO;\n                } else {\n                    *x_0 = diff_0;\n                    *x_1 = diff_1;\n                    *x_2 = diff_2;\n                }\n                *x_exp = diff_exp;\n                (o, neg)\n            }\n            (xs, ys) => {\n                let (diff_exp, o, neg) =\n                    sub_float_significands_same_prec_ge_3w_val_ref(xs, *x_exp, ys, y_exp, prec, rm);\n                if *xs.last().unwrap() == 0 {\n                    *x = Natural::ZERO;\n                } else {\n                    *x_exp = diff_exp;\n                }\n                (o, neg)\n            }\n        },\n        _ => unreachable!(),\n    }\n}\n\n// This is mpfr_sub1sp from sub1sp.c, MPFR 4.2.0.\nfn sub_float_significands_same_prec_ref_ref(\n    x: &Natural,\n    x_exp: i32,\n    y: &Natural,\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (Natural, i32, Ordering, bool) {\n    match (x, y) {\n        (Natural(Small(x)), Natural(Small(y))) => {\n            let (diff, diff_exp, o, neg) = if prec == Limb::WIDTH {\n                sub_float_significands_same_prec_w(*x, x_exp, *y, y_exp, rm)\n            } else {\n                sub_float_significands_same_prec_lt_w(*x, x_exp, *y, y_exp, prec, rm)\n            };\n            (Natural(Small(diff)), diff_exp, o, neg)\n        }\n        (Natural(Large(xs)), Natural(Large(ys))) => match (xs.as_slice(), ys.as_slice()) {\n            (&[x_0, x_1], &[y_0, y_1]) => {\n                let (diff_0, diff_1, diff_exp, o, neg) = if prec == TWICE_WIDTH {\n                    sub_float_significands_same_prec_2w(x_0, x_1, x_exp, y_0, y_1, y_exp, rm)\n                } else {\n                    sub_float_significands_same_prec_gt_w_lt_2w(\n                        x_0, x_1, x_exp, y_0, y_1, y_exp, prec, rm,\n                    )\n                };\n                (\n                    if diff_1 == 0 {\n                        Natural::ZERO\n                    } else {\n                        Natural(Large(vec![diff_0, diff_1]))\n                    },\n                    diff_exp,\n                    o,\n                    neg,\n                )\n            }\n            (&[x_0, x_1, x_2], &[y_0, y_1, y_2]) if prec != THRICE_WIDTH => {\n                let (diff_0, diff_1, diff_2, diff_exp, o, neg) =\n                    sub_float_significands_same_prec_gt_2w_lt_3w(\n                        x_0, x_1, x_2, x_exp, y_0, y_1, y_2, y_exp, prec, rm,\n                    );\n                (\n                    if diff_2 == 0 {\n                        Natural::ZERO\n                    } else {\n                        Natural(Large(vec![diff_0, diff_1, diff_2]))\n                    },\n                    diff_exp,\n                    o,\n                    neg,\n                )\n            }\n            (xs, ys) => {\n                let mut out = vec![0; xs.len()];\n                let (diff_exp, o, neg) = sub_float_significands_same_prec_ge_3w_ref_ref(\n                    &mut out, xs, x_exp, ys, y_exp, prec, rm,\n                );\n                (\n                    if slice_test_zero(&out) {\n                        Natural::ZERO\n                    } else {\n                        Natural(Large(out))\n                    },\n                    diff_exp,\n                    o,\n                    neg,\n                )\n            }\n        },\n        _ => unreachable!(),\n    }\n}\n\n// This is mpfr_sub1sp1 from sub1sp.c, MPFR 4.2.0.\nfn sub_float_significands_same_prec_lt_w(\n    mut x: Limb,\n    mut x_exp: i32,\n    mut y: Limb,\n    mut y_exp: i32,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Limb, i32, Ordering, bool) {\n    {\n        let (mut diff, sticky_bit, round_bit, shift_bit, neg) = if x_exp == y_exp {\n            let (a0, neg) = match x.cmp(&y) {\n                Equal => return (0, 0, Equal, false),\n                Less => (y - x, true),\n                Greater => (x - y, false),\n            };\n            let leading_zeros = a0.leading_zeros();\n            x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n            (a0 << leading_zeros, 0, 0, 0, neg)\n        } else {\n            let neg = x_exp < y_exp;\n            if neg {\n                // swap x and y\n                swap(&mut x_exp, &mut y_exp);\n                swap(&mut x, &mut y);\n            }\n            let exp_diff = u64::exact_from(x_exp - y_exp);\n            let shift = Limb::WIDTH - prec;\n            let shift_bit = Limb::power_of_2(shift);\n            let mask = shift_bit - 1;\n            if exp_diff < Limb::WIDTH {\n                // neglected part of -y\n                let mut sticky_bit = (y << (Limb::WIDTH - exp_diff)).wrapping_neg();\n                let mut a0 = x - Limb::from(sticky_bit != 0) - (y >> exp_diff);\n                // a0 cannot be zero here since:\n                // - if exp_diff >= 2, then a0 >= 2^(w-1) - (2^(w-2)-1) with w = Limb::WIDTH, thus\n                //   a0 - 1 >= 2 ^ (w - 2),\n                // - if exp_diff = 1, then since prec < Limb::WIDTH we have sticky_bit = 0.\n                //\n                assert_ne!(a0, 0);\n                let leading_zeros = LeadingZeros::leading_zeros(a0);\n                if leading_zeros != 0 {\n                    a0 = (a0 << leading_zeros) | (sticky_bit >> (Limb::WIDTH - leading_zeros));\n                }\n                sticky_bit <<= leading_zeros;\n                x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                // shift > 0 since prec < Limb::WIDTH\n                assert_ne!(shift, 0);\n                let round_bit = a0 & (shift_bit >> 1);\n                (\n                    a0 & !mask,\n                    sticky_bit | (a0 & mask) ^ round_bit,\n                    round_bit,\n                    shift_bit,\n                    neg,\n                )\n            } else if x > LIMB_HIGH_BIT {\n                // We compute x - ulp(x), and the remainder ulp(x) - y satisfies: 1/2 ulp(x) <\n                // ulp(x) - y < ulp(x), thus round_bit = sticky_bit = 1.\n                (x - shift_bit, 1, 1, shift_bit, neg)\n            } else {\n                // - Warning: since we have an exponent decrease, when prec = Limb::WIDTH - 1 and d\n                //   = Limb::WIDTH, the round bit corresponds to the upper bit of -y. In that case\n                //   round_bit = 0 and sticky_bit = 1, except when y0 = LIMB_HIGH_BIT where\n                //   round_bit = 1 and sticky_bit = 0.\n                // - sticky_bit = 1 below is incorrect when prec = Limb::WIDTH - 1, exp_diff =\n                //   Limb::WIDTH and y0 = LIMB_HIGH_BIT, but in that case the even rule would round\n                //   up too.\n                // - Warning: if exp_diff = Limb::WIDTH and y0 = 1000...000, then x0 - y0 =\n                //   |0111...111|1000...000|, which after the shift becomes |111...111|000...000|\n                //   thus if prec = Limb::WIDTH - 1 we have round_bit = 1 but sticky_bit = 0.\n                //   However, in this case the round even rule will round up, which is what we get\n                //   with sticky_bit = 1: the final result will be correct, while sb is incorrect.\n                x_exp.saturating_sub_assign(1);\n                (\n                    !mask,\n                    1,\n                    Limb::from(shift > 1 || exp_diff > Limb::WIDTH || y == LIMB_HIGH_BIT),\n                    shift_bit,\n                    neg,\n                )\n            }\n        };\n        if round_bit == 0 && sticky_bit == 0 {\n            (diff, x_exp, Equal, neg)\n        } else {\n            if neg {\n                rm.neg_assign();\n            }\n            match rm {\n                Exact => panic!(\"Inexact float subtraction\"),\n                Nearest => {\n                    if round_bit == 0 || (sticky_bit == 0 && (diff & shift_bit) == 0) {\n                        (diff, x_exp, Less, neg)\n                    } else if diff.overflowing_add_assign(shift_bit) {\n                        (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                    } else {\n                        (diff, x_exp, Greater, neg)\n                    }\n                }\n                Floor | Down => (diff, x_exp, Less, neg),\n                Ceiling | Up => {\n                    if diff.overflowing_add_assign(shift_bit) {\n                        (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                    } else {\n                        (diff, x_exp, Greater, neg)\n                    }\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_sub1sp1n from sub1sp.c, MPFR 4.2.0.\nfn sub_float_significands_same_prec_w(\n    mut x: Limb,\n    mut x_exp: i32,\n    mut y: Limb,\n    mut y_exp: i32,\n    mut rm: RoundingMode,\n) -> (Limb, i32, Ordering, bool) {\n    let (mut diff, sticky_bit, round_bit, neg) = if x_exp == y_exp {\n        let (a0, neg) = match x.cmp(&y) {\n            Equal => return (0, 0, Equal, false),\n            Less => (y - x, true),\n            Greater => (x - y, false),\n        };\n        let leading_zeros = LeadingZeros::leading_zeros(a0);\n        x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n        (a0 << leading_zeros, 0, 0, neg)\n    } else {\n        let neg = x_exp < y_exp;\n        if neg {\n            // swap x and y\n            swap(&mut x_exp, &mut y_exp);\n            swap(&mut x, &mut y);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        if exp_diff < Limb::WIDTH {\n            let mut sticky_bit = (y << (Limb::WIDTH - exp_diff)).wrapping_neg();\n            let mut a0 = x.wrapping_sub(y >> exp_diff);\n            if sticky_bit != 0 {\n                a0.wrapping_sub_assign(1);\n            }\n            // a0 can only be zero when exp_diff = 1, x0 = B / 2, and y0 = B-1, where B = 2 ^\n            // Limb::WIDTH, thus x0 - y0 / 2 = 1/2\n            if a0 == 0 {\n                x_exp.saturating_sub_assign(IWIDTH);\n                (LIMB_HIGH_BIT, 0, 0, neg)\n            } else {\n                let leading_zeros = LeadingZeros::leading_zeros(a0);\n                if leading_zeros != 0 {\n                    a0 = (a0 << leading_zeros) | (sticky_bit >> (Limb::WIDTH - leading_zeros));\n                }\n                sticky_bit <<= leading_zeros;\n                x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                let round_bit = sticky_bit & LIMB_HIGH_BIT;\n                (a0, sticky_bit & !LIMB_HIGH_BIT, round_bit, neg)\n            }\n        } else {\n            // We compute x - ulp(x)\n            if x > LIMB_HIGH_BIT {\n                // If exp_diff = Limb::WIDTH, round_bit = 0 and sticky_bit = 1, unless c0 =\n                // LIMB_HIGH_BIT in which case round_bit = 1 and sticky_bit = 0. If exp_diff >\n                // Limb::WIDTH, round_bit = sticky_bit = 1.\n                let b = exp_diff > Limb::WIDTH;\n                (\n                    x - 1,\n                    Limb::from(b || y != LIMB_HIGH_BIT),\n                    Limb::from(b || y == LIMB_HIGH_BIT),\n                    neg,\n                )\n            } else {\n                // Warning: in this case a0 is shifted by one!\n                //\n                // If exp_diff = Limb::WIDTH\n                // - a) If y0 = LIMB_HIGH_BIT, a0 = 111...111, round_bit = sticky_bit = 0\n                // - b) Otherwise, a0 = 111...110, round_bit = -y0 >= 01000...000, sticky_bit =\n                //   (-y0) << 2\n                //\n                // If exp_diff = Limb::WIDTH + 1: a0 = 111...111\n                // - c) If y0 = LIMB_HIGH_BIT, round_bit = 1 and sticky_bit = 0\n                // - d) Otherwise round_bit = 0 and sticky_bit = 1\n                //\n                // If exp_diff > Limb::WIDTH + 1:\n                // - e) a0 = 111...111, round_bit = sticky_bit = 1\n                x_exp.saturating_sub_assign(1);\n                if exp_diff == Limb::WIDTH && y > LIMB_HIGH_BIT {\n                    // case (b)\n                    (\n                        NEG_TWO,\n                        y.wrapping_neg() << 2,\n                        Limb::from(y.wrapping_neg() >= (LIMB_HIGH_BIT >> 1)),\n                        neg,\n                    )\n                } else {\n                    // cases (a), (c), (d) and (e)\n                    // - round_bit = 1 in case (e) and case (c)\n                    // - sticky_bit = 1 in case (d) and (e)\n                    let b1 = exp_diff > WIDTH_P1;\n                    let b2 = exp_diff == WIDTH_P1;\n                    (\n                        NEG_ONE,\n                        Limb::from(b1 || (b2 && y > LIMB_HIGH_BIT)),\n                        Limb::from(b1 || (b2 && y == LIMB_HIGH_BIT)),\n                        neg,\n                    )\n                }\n            }\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (diff, x_exp, Equal, neg)\n    } else {\n        if neg {\n            rm.neg_assign();\n        }\n        match rm {\n            Exact => panic!(\"Inexact float subtraction\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (diff & 1) == 0) {\n                    (diff, x_exp, Less, neg)\n                } else if diff.overflowing_add_assign(1) {\n                    (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                } else {\n                    (diff, x_exp, Greater, neg)\n                }\n            }\n            Floor | Down => (diff, x_exp, Less, neg),\n            Ceiling | Up => {\n                if diff.overflowing_add_assign(1) {\n                    (LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                } else {\n                    (diff, x_exp, Greater, neg)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_sub1sp2 from sub1sp.c, MPFR 4.2.0.\nfn sub_float_significands_same_prec_gt_w_lt_2w(\n    mut x_0: Limb,\n    mut x_1: Limb,\n    mut x_exp: i32,\n    mut y_0: Limb,\n    mut y_1: Limb,\n    mut y_exp: i32,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Limb, Limb, i32, Ordering, bool) {\n    let (mut diff_0, mut diff_1, sticky_bit, round_bit, shift_bit, neg) = if x_exp == y_exp {\n        // subtraction is exact in this case\n        //\n        // first compute a0: if the compiler is smart enough, it will use the generated borrow to\n        // get for free the term (x_0 < y_0)\n        let (mut a0, overflow) = x_0.overflowing_sub(y_0);\n        let mut a1 = x_1.wrapping_sub(y_1);\n        if overflow {\n            a1.wrapping_sub_assign(1);\n        }\n        let neg = if a1 == 0 && a0 == 0 {\n            return (0, 0, 0, Equal, false);\n        } else if a1 >= x_1 {\n            // out = x - y mod 2 ^ (2 * Limb::WIDTH)\n            let overflow = a0.overflowing_neg_assign();\n            a1.wrapping_neg_assign();\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            true\n        } else {\n            false\n        };\n        if a1 == 0 {\n            a1 = a0;\n            a0 = 0;\n            x_exp.saturating_sub_assign(IWIDTH);\n        }\n        // now a1 != 0\n        let leading_zeros = LeadingZeros::leading_zeros(a1);\n        if leading_zeros != 0 {\n            x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n            (\n                a0 << leading_zeros,\n                (a1 << leading_zeros) | (a0 >> (Limb::WIDTH - leading_zeros)),\n                0,\n                0,\n                0,\n                neg,\n            )\n        } else {\n            (a0, a1, 0, 0, 0, neg)\n        }\n    } else {\n        let neg = x_exp < y_exp;\n        if neg {\n            swap(&mut x_exp, &mut y_exp);\n            swap(&mut x_0, &mut y_0);\n            swap(&mut x_1, &mut y_1);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        let shift = TWICE_WIDTH - prec;\n        let shift_bit = Limb::power_of_2(shift);\n        let mask = shift_bit - 1;\n        if exp_diff < Limb::WIDTH {\n            let comp_diff = Limb::WIDTH - exp_diff;\n            let t = (y_1 << comp_diff) | (y_0 >> exp_diff);\n            let (mut sticky_bit, overflow_1) = (y_0 << comp_diff).overflowing_neg();\n            let (mut a0, overflow_2) = x_0.overflowing_sub(t);\n            if overflow_1 {\n                a0.wrapping_sub_assign(1);\n            }\n            let mut a1 = x_1.wrapping_sub(y_1 >> exp_diff);\n            if overflow_2 || (x_0 == t && overflow_1) {\n                a1.wrapping_sub_assign(1);\n            }\n            if a1 == 0 {\n                // This implies exp_diff = 1, which in turn implies sticky_bit = 0\n                assert_eq!(sticky_bit, 0);\n                a1 = a0;\n                a0 = 0;\n                // Since sticky_bit = 0 already, no need to set it to 0\n                x_exp.saturating_sub_assign(IWIDTH);\n            }\n            // now a1 != 0\n            assert_ne!(a1, 0);\n            let leading_zeros = LeadingZeros::leading_zeros(a1);\n            let diff_1 = if leading_zeros != 0 {\n                let comp_zeros = Limb::WIDTH - leading_zeros;\n                let diff_1 = (a1 << leading_zeros) | (a0 >> comp_zeros);\n                a0 = (a0 << leading_zeros) | (sticky_bit >> comp_zeros);\n                sticky_bit <<= leading_zeros;\n                x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                diff_1\n            } else {\n                a1\n            };\n            // shift > 0 since prec < 2 * Limb::WIDTH\n            assert_ne!(shift, 0);\n            let round_bit = a0 & (shift_bit >> 1);\n            (\n                a0 & !mask,\n                diff_1,\n                sticky_bit | ((a0 & mask) ^ round_bit),\n                round_bit,\n                shift_bit,\n                neg,\n            )\n        } else if exp_diff < TWICE_WIDTH {\n            // Warning: the most significant bit of sticky_bit might become the least significant\n            // bit of a0 below\n            let mut sticky_bit = if exp_diff == Limb::WIDTH {\n                y_0\n            } else {\n                let mut sticky_bit = y_1 << (TWICE_WIDTH - exp_diff);\n                if y_0 != 0 {\n                    sticky_bit |= 1;\n                }\n                sticky_bit\n            };\n            let mut t = y_1 >> (exp_diff - Limb::WIDTH);\n            if sticky_bit != 0 {\n                t.wrapping_add_assign(1);\n            }\n            // Warning: t might overflow to 0 if exp_diff == Limb::WIDTH and sticky_bit != 0\n            let (mut a0, overflow) = x_0.overflowing_sub(t);\n            let mut a1 = x_1;\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            if t == 0 && sticky_bit != 0 {\n                a1.wrapping_sub_assign(1);\n            }\n            sticky_bit.wrapping_neg_assign();\n            // since x_1 has its most significant bit set, we can have an exponent decrease of at\n            // most one\n            let diff_1 = if a1 < LIMB_HIGH_BIT {\n                let diff_1 = (a1 << 1) | (a0 >> WIDTH_M1);\n                a0 = (a0 << 1) | (sticky_bit >> WIDTH_M1);\n                sticky_bit <<= 1;\n                x_exp.saturating_sub_assign(1);\n                diff_1\n            } else {\n                a1\n            };\n            let round_bit = a0 & (shift_bit >> 1);\n            (\n                a0 & !mask,\n                diff_1,\n                sticky_bit | ((a0 & mask) ^ round_bit),\n                round_bit,\n                shift_bit,\n                neg,\n            )\n        } else {\n            // We compute x - ulp(x), and the remainder ulp(x) - y satisfies: 1/2 ulp(x) < ulp(x) -\n            // y < ulp(x), thus round_bit = sticky_bit = 1, unless we had an exponent decrease.\n            let t = shift_bit;\n            let (a0, overflow) = x_0.overflowing_sub(t);\n            let mut a1 = x_1;\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            if a1 < LIMB_HIGH_BIT {\n                // Necessarily we had x = 1000...000\n                //\n                // Warning: since we have an exponent decrease, when prec = Limb::WIDTH * 2 - 1 and\n                // exp_diff = Limb::WIDTH * 2, the round bit corresponds to the upper bit of -y. In\n                // that case round_bit = 0 and sticky_bit = 1, except when y = 1000...000 where\n                // round_bit = 1 and sticky_bit = 0.\n                //\n                // sticky_bit = 1 below is incorrect when prec = Limb::WIDTH * 2 - 1, exp_diff =\n                // Limb::WIDTH * 2, and y = 1000...000, but in that case the even rule would round\n                // up too.\n                x_exp.saturating_sub_assign(1);\n                (\n                    !mask,\n                    Limb::MAX,\n                    1,\n                    Limb::from(\n                        shift > 1 || exp_diff > TWICE_WIDTH || (y_1 == LIMB_HIGH_BIT && y_0 == 0),\n                    ),\n                    shift_bit,\n                    neg,\n                )\n            } else {\n                (a0, a1, 1, 1, shift_bit, neg)\n            }\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (diff_0, diff_1, x_exp, Equal, neg)\n    } else {\n        if neg {\n            rm.neg_assign();\n        }\n        match rm {\n            Exact => panic!(\"Inexact float subtraction\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (diff_0 & shift_bit) == 0) {\n                    (diff_0, diff_1, x_exp, Less, neg)\n                } else if diff_0.overflowing_add_assign(shift_bit)\n                    && diff_1.overflowing_add_assign(1)\n                {\n                    (diff_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                } else {\n                    (diff_0, diff_1, x_exp, Greater, neg)\n                }\n            }\n            Floor | Down => (diff_0, diff_1, x_exp, Less, neg),\n            Ceiling | Up => {\n                if diff_0.overflowing_add_assign(shift_bit) && diff_1.overflowing_add_assign(1) {\n                    (diff_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                } else {\n                    (diff_0, diff_1, x_exp, Greater, neg)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_sub1sp2n from add1sp.c, MPFR 4.2.0.\nfn sub_float_significands_same_prec_2w(\n    mut x_0: Limb,\n    mut x_1: Limb,\n    mut x_exp: i32,\n    mut y_0: Limb,\n    mut y_1: Limb,\n    mut y_exp: i32,\n    mut rm: RoundingMode,\n) -> (Limb, Limb, i32, Ordering, bool) {\n    let (mut diff_0, mut diff_1, sticky_bit, round_bit, neg) = if x_exp == y_exp {\n        let (mut a0, overflow) = x_0.overflowing_sub(y_0);\n        let mut a1 = x_1.wrapping_sub(y_1);\n        if overflow {\n            a1.wrapping_sub_assign(1);\n        }\n        let neg = if a1 == 0 && a0 == 0 {\n            return (0, 0, 0, Equal, false);\n        } else if a1 >= x_1 {\n            // since B/2 <= x_1, y_1 < B with B = 2 ^ Limb::WIDTH, if no borrow we have 0 <= x_1 -\n            // y_1 - x < B / 2, where x = (x_0 < y_0) is 0 or 1, thus a1 < B / 2 <= x_1\n            //\n            // negate [a1,a0]\n            let overflow = a0.overflowing_neg_assign();\n            a1.wrapping_neg_assign();\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            true\n        } else {\n            false\n        };\n        // now [a1,a0] is the absolute value of x - y, maybe not normalized\n        if a1 == 0 {\n            a1 = a0;\n            a0 = 0;\n            x_exp.saturating_sub_assign(IWIDTH);\n        }\n        let leading_zeros = LeadingZeros::leading_zeros(a1);\n        if leading_zeros != 0 {\n            // shift [a1, a0] left by leading_zeros bits and store in result\n            x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n            (\n                a0 << leading_zeros,\n                (a1 << leading_zeros) | (a0 >> (Limb::WIDTH - leading_zeros)),\n                0,\n                0,\n                neg,\n            )\n        } else {\n            (a0, a1, 0, 0, neg)\n        }\n    } else {\n        let neg = x_exp < y_exp;\n        if neg {\n            swap(&mut x_exp, &mut y_exp);\n            swap(&mut x_0, &mut y_0);\n            swap(&mut x_1, &mut y_1);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        if exp_diff < Limb::WIDTH {\n            let comp_diff = Limb::WIDTH - exp_diff;\n            let t = (y_1 << comp_diff) | (y_0 >> exp_diff);\n            // t is the part that should be subtracted to x_0:\n            // ```\n            // |      a1       |      a0       |\n            // |     x_1       |     x_0       |\n            // |    y_1 >> d   |      t        |     sticky_bit     |\n            // ```\n            let (mut sticky_bit, overflow_1) = (y_0 << comp_diff).overflowing_neg();\n            let (mut a0, overflow_2) = x_0.overflowing_sub(t);\n            if overflow_1 {\n                a0.wrapping_sub_assign(1);\n            }\n            let mut a1 = x_1.wrapping_sub(y_1 >> exp_diff);\n            if overflow_2 || (x_0 == t && overflow_1) {\n                a1.wrapping_sub_assign(1);\n            }\n            // Now the result is formed of [a1,a0,sticky_bit], which might not be normalized\n            if a1 == 0 {\n                // this implies d = 1\n                assert_eq!(exp_diff, 1);\n                a1 = a0;\n                a0 = sticky_bit;\n                sticky_bit = 0;\n                x_exp.saturating_sub_assign(IWIDTH);\n            }\n            if a1 == 0 {\n                assert_eq!(a0, LIMB_HIGH_BIT);\n                x_exp.saturating_sub_assign(IWIDTH);\n                (sticky_bit, a0, 0, 0, neg)\n            } else {\n                let leading_zeros = LeadingZeros::leading_zeros(a1);\n                if leading_zeros != 0 {\n                    let comp_zeros = Limb::WIDTH - leading_zeros;\n                    // shift [a1, a0, sticky_bit] left by leading_zeros bits and adjust exponent\n                    a1 = (a1 << leading_zeros) | (a0 >> comp_zeros);\n                    a0 = (a0 << leading_zeros) | (sticky_bit >> comp_zeros);\n                    sticky_bit <<= leading_zeros;\n                    x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                }\n                (\n                    a0,\n                    a1,\n                    sticky_bit & !LIMB_HIGH_BIT,\n                    sticky_bit & LIMB_HIGH_BIT,\n                    neg,\n                )\n            }\n        } else if exp_diff < TWICE_WIDTH {\n            // Compute t, the part to be subtracted to x_0, and sticky_bit, the neglected part of y:\n            //\n            // ```\n            // |      a1       |      a0       |\n            // |     diff_1    |     diff_0    |\n            //                 |      t        |     sticky_bit     |\n            // ```\n            //\n            // Warning: we should not ignore the low bits from y_0 in case exp_diff > Limb::WIDTH\n            let comp_diff_1 = exp_diff - Limb::WIDTH;\n            let comp_diff_2 = TWICE_WIDTH - exp_diff;\n            let mut sticky_bit = if comp_diff_1 == 0 {\n                y_0\n            } else {\n                let mut sticky_bit = (y_1 << comp_diff_2) | (y_0 >> comp_diff_1);\n                if y_0 << comp_diff_2 != 0 {\n                    sticky_bit |= 1;\n                }\n                sticky_bit\n            };\n            let mut t = y_1 >> comp_diff_1;\n            if sticky_bit != 0 {\n                t.wrapping_add_assign(1);\n            }\n            // Warning: t might overflow to 0 if exp_diff = Limb::WIDTH, sticky_bit != 0, and y_1 =\n            // 111...111.\n            let (mut a0, overflow) = x_0.overflowing_sub(t);\n            let mut a1 = x_1;\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            if t == 0 && sticky_bit != 0 {\n                a1.wrapping_sub_assign(1);\n            }\n            sticky_bit.wrapping_neg_assign();\n            // Now the result is [a1, a0, sticky_bit]. Since x_1 has its most significant bit set,\n            // we can have an exponent decrease of at most one\n            if a1 < LIMB_HIGH_BIT {\n                // shift [a1, a0] left by 1 bit\n                a1 = (a1 << 1) | (a0 >> WIDTH_M1);\n                assert!(a1 >= LIMB_HIGH_BIT);\n                a0 = (a0 << 1) | (sticky_bit >> WIDTH_M1);\n                sticky_bit <<= 1;\n                x_exp.saturating_sub_assign(1);\n            }\n            (\n                a0,\n                a1,\n                sticky_bit & !LIMB_HIGH_BIT,\n                sticky_bit & LIMB_HIGH_BIT,\n                neg,\n            )\n        } else {\n            // ```\n            // |      a1       |      a0       |\n            // |      x_1      |      x_0      |\n            //                                 |   y_1   |   y_0   |\n            // ```\n            let tst = y_1 == LIMB_HIGH_BIT && y_0 == 0;\n            // if exp_diff = Limb::WIDTH * 2 and tst = 1, y = 1 / 2 * ulp(x)\n            if x_1 > LIMB_HIGH_BIT || x_0 > 0 {\n                let g = exp_diff > TWICE_WIDTH;\n                let mut diff_1 = x_1;\n                if x_0 == 0 {\n                    diff_1.wrapping_sub_assign(1);\n                }\n                // no borrow in x - ulp(x)\n                (\n                    x_0.wrapping_sub(1),\n                    diff_1,\n                    Limb::from(g || !tst),\n                    Limb::from(g || tst),\n                    neg,\n                )\n            } else {\n                // x = 1000...000, thus subtracting y yields an exponent shift\n                x_exp.saturating_sub_assign(1);\n                if exp_diff == TWICE_WIDTH && !tst {\n                    // y > 1 / 2 * ulp(x)\n                    let mut t = y_1.wrapping_neg();\n                    if y_0 != 0 {\n                        t.wrapping_sub_assign(1);\n                    }\n                    // The rounding bit is the 2nd most-significant bit of t (where the most\n                    // significant bit of t is necessarily 0), and the sticky bit is formed by the\n                    // remaining bits of t, and those from -y_0.\n                    (\n                        NEG_TWO,\n                        Limb::MAX,\n                        (t << 2) | y_0,\n                        Limb::from(t >= HALF_LIMB_HIGH_BIT),\n                        neg,\n                    )\n                } else {\n                    // y <= 1 / 2 * ulp(x)\n                    let g = exp_diff > TWICE_WIDTH_P1;\n                    (\n                        NEG_ONE,\n                        NEG_ONE,\n                        Limb::from(g || (exp_diff == TWICE_WIDTH_P1 && !tst)),\n                        Limb::from(g || (exp_diff == TWICE_WIDTH_P1 && tst)),\n                        neg,\n                    )\n                }\n            }\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (diff_0, diff_1, x_exp, Equal, neg)\n    } else {\n        if neg {\n            rm.neg_assign();\n        }\n        match rm {\n            Exact => panic!(\"Inexact float subtraction\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (diff_0 & 1) == 0) {\n                    (diff_0, diff_1, x_exp, Less, neg)\n                } else if diff_0.overflowing_add_assign(1) && diff_1.overflowing_add_assign(1) {\n                    (diff_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                } else {\n                    (diff_0, diff_1, x_exp, Greater, neg)\n                }\n            }\n            Floor | Down => (diff_0, diff_1, x_exp, Less, neg),\n            Ceiling | Up => {\n                if diff_0.overflowing_add_assign(1) && diff_1.overflowing_add_assign(1) {\n                    (diff_0, LIMB_HIGH_BIT, x_exp.saturating_add(1), Greater, neg)\n                } else {\n                    (diff_0, diff_1, x_exp, Greater, neg)\n                }\n            }\n        }\n    }\n}\n\n// This is mpfr_sub1sp3 from add1sp.c, MPFR 4.2.0.\nfn sub_float_significands_same_prec_gt_2w_lt_3w(\n    mut x_0: Limb,\n    mut x_1: Limb,\n    mut x_2: Limb,\n    mut x_exp: i32,\n    mut y_0: Limb,\n    mut y_1: Limb,\n    mut y_2: Limb,\n    mut y_exp: i32,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (Limb, Limb, Limb, i32, Ordering, bool) {\n    let (mut diff_0, mut diff_1, mut diff_2, sticky_bit, round_bit, shift_bit, neg) = if x_exp\n        == y_exp\n    {\n        let (mut a0, overflow_1) = x_0.overflowing_sub(y_0);\n        let (mut a1, overflow_2) = x_1.overflowing_sub(y_1);\n        if overflow_1 {\n            a1.wrapping_sub_assign(1);\n        }\n        // A borrow is generated for diff when either x_1 < y_1 or x_1 = y_1 and x_0 < y_0.\n        let mut a2 = x_2.wrapping_sub(y_2);\n        if overflow_2 || x_1 == y_1 && overflow_1 {\n            a2.wrapping_sub_assign(1);\n        }\n        let neg = if a2 == 0 && a1 == 0 && a0 == 0 {\n            return (0, 0, 0, 0, Equal, false);\n        } else if a2 >= x_2 {\n            // a = x - y mod 2 ^ (3 * Limb::WIDTH)\n            let overflow_1 = a0.overflowing_neg_assign();\n            a1.wrapping_neg_assign();\n            if overflow_1 {\n                a1.wrapping_sub_assign(1);\n            }\n            a2.wrapping_neg_assign();\n            if overflow_1 || a1 != 0 {\n                a2.wrapping_sub_assign(1);\n            }\n            true\n        } else {\n            false\n        };\n        if a2 == 0 {\n            a2 = a1;\n            a1 = a0;\n            a0 = 0;\n            x_exp.saturating_sub_assign(IWIDTH);\n            if a2 == 0 {\n                a2 = a1;\n                a1 = 0;\n                x_exp.saturating_sub_assign(IWIDTH);\n            }\n        }\n        assert_ne!(a2, 0);\n        let leading_zeros = LeadingZeros::leading_zeros(a2);\n        if leading_zeros != 0 {\n            x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n            let comp_zeros = Limb::WIDTH - leading_zeros;\n            (\n                a0 << leading_zeros,\n                (a1 << leading_zeros) | (a0 >> comp_zeros),\n                (a2 << leading_zeros) | (a1 >> comp_zeros),\n                0,\n                0,\n                0,\n                neg,\n            )\n        } else {\n            (a0, a1, a2, 0, 0, 0, neg)\n        }\n    } else {\n        let neg = x_exp < y_exp;\n        if neg {\n            swap(&mut x_exp, &mut y_exp);\n            swap(&mut x_0, &mut y_0);\n            swap(&mut x_1, &mut y_1);\n            swap(&mut x_2, &mut y_2);\n        }\n        let exp_diff = u64::exact_from(x_exp - y_exp);\n        let shift = THRICE_WIDTH - prec;\n        let shift_bit = Limb::power_of_2(shift);\n        let mask = shift_bit - 1;\n        if exp_diff < Limb::WIDTH {\n            // Warning: we must have the most significant bit of sticky_bit correct since it might\n            // become the round bit below\n            let comp_diff = Limb::WIDTH - exp_diff;\n            let mut sticky_bit = y_0 << comp_diff;\n            let (mut a0, overflow) = x_0.overflowing_sub((y_1 << comp_diff) | (y_0 >> exp_diff));\n            let mut a1 = x_1.wrapping_sub((y_2 << comp_diff) | (y_1 >> exp_diff));\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            let carry = a1 > x_1 || (a1 == x_1 && overflow);\n            let mut a2 = x_2.wrapping_sub(y_2 >> exp_diff);\n            if carry {\n                a2.wrapping_sub_assign(1);\n            }\n            // if sticky_bit is non-zero, subtract 1 from a2, a1, a0 since we want a non-negative\n            // neglected part\n            if sticky_bit != 0 {\n                if a1 == 0 && a0 == 0 {\n                    a2.wrapping_sub_assign(1);\n                }\n                if a0 == 0 {\n                    a1.wrapping_sub_assign(1);\n                }\n                a0.wrapping_sub_assign(1);\n                // a = a2, a1, a0 cannot become zero here, since:\n                // - if exp_diff >= 2, then a2 >= 2 ^ (w - 1) - (2 ^ (w - 2) - 1) with w =\n                //   Limb::WIDTH, thus a2 - 1 >= 2 ^ (w - 2),\n                // - if exp_diff = 1, then since prec < 3 * Limb::WIDTH we have sticky_bit = 0.\n                assert!(a2 > 0 || a1 > 0 || a0 > 0);\n                // 2 ^ Limb::WIDTH - sticky_bit\n                sticky_bit.wrapping_neg_assign();\n            }\n            if a2 == 0 {\n                // this implies exp_diff = 1, which in turn implies sticky_bit = 0\n                assert_eq!(sticky_bit, 0);\n                a2 = a1;\n                a1 = a0;\n                a0 = 0;\n                // since sticky_bit = 0 already, no need to set it to 0\n                x_exp.saturating_sub_assign(IWIDTH);\n                if a2 == 0 {\n                    a2 = a1;\n                    a1 = 0;\n                    x_exp.saturating_sub_assign(IWIDTH);\n                }\n            }\n            assert_ne!(a2, 0);\n            let leading_zeros = LeadingZeros::leading_zeros(a2);\n            let (diff_1, diff_2) = if leading_zeros != 0 {\n                let comp_zeros = Limb::WIDTH - leading_zeros;\n                let diff_1 = (a1 << leading_zeros) | (a0 >> comp_zeros);\n                a0 = (a0 << leading_zeros) | (sticky_bit >> comp_zeros);\n                sticky_bit <<= leading_zeros;\n                x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                (diff_1, (a2 << leading_zeros) | (a1 >> comp_zeros))\n            } else {\n                (a1, a2)\n            };\n            // shift > 0 since prec < 2 * Limb::WIDTH\n            assert_ne!(shift, 0);\n            let round_bit = a0 & (shift_bit >> 1);\n            (\n                a0 & !mask,\n                diff_1,\n                diff_2,\n                sticky_bit | (a0 & mask) ^ round_bit,\n                round_bit,\n                shift_bit,\n                neg,\n            )\n        } else if exp_diff < TWICE_WIDTH {\n            // Warning: we must have the most significant bit of sticky_bit correct since it might\n            // become the round bit below\n            let comp_diff = exp_diff - Limb::WIDTH;\n            let (mut sticky_bit, y0shifted) = if exp_diff == Limb::WIDTH {\n                (y_0, y_1)\n            } else {\n                let comp_diff_2 = TWICE_WIDTH - exp_diff;\n                let mut sticky_bit = y_1 << comp_diff_2;\n                if y_0 != 0 {\n                    sticky_bit |= 1;\n                }\n                (sticky_bit, (y_2 << comp_diff_2) | (y_1 >> comp_diff))\n            };\n            let (mut a0, overflow) = x_0.overflowing_sub(y0shifted);\n            let mut a1 = x_1.wrapping_sub(y_2 >> comp_diff);\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            let mut a2 = x_2;\n            if a1 > x_1 || (a1 == x_1 && overflow) {\n                a2.wrapping_sub_assign(1);\n            }\n            // if sticky_bit is non-zero, subtract 1 from a2, a1, a0 since we want a non-negative\n            // neglected part\n            if sticky_bit != 0 {\n                if a1 == 0 && a0 == 0 {\n                    a2.wrapping_sub_assign(1);\n                }\n                if a0 == 0 {\n                    a1.wrapping_sub_assign(1);\n                }\n                a0.wrapping_sub_assign(1);\n                // a = a2, a1, a0 cannot become zero here, since:\n                // - if exp_diff >= 2, then a2 >= 2 ^ (w - 1) - (2 ^ (w - 2) - 1) with w =\n                //   Limb::WIDTH, thus a2 - 1 >= 2 ^ (w - 2),\n                // - if exp_diff = 1, then since p < 3 * Limb::WIDTH we have sticky_bit = 0.\n                assert!(a2 > 0 || a1 > 0 || a0 > 0);\n                // 2 ^ Limb::WIDTH - sticky_bit\n                sticky_bit.wrapping_neg_assign();\n            }\n            // since x_2 has its most significant bit set, we can have an exponent decrease of at\n            // most one\n            let (diff_1, diff_2) = if a2 < LIMB_HIGH_BIT {\n                let diff_1 = (a1 << 1) | (a0 >> WIDTH_M1);\n                a0 = (a0 << 1) | (sticky_bit >> WIDTH_M1);\n                sticky_bit <<= 1;\n                x_exp.saturating_sub_assign(1);\n                (diff_1, (a2 << 1) | (a1 >> WIDTH_M1))\n            } else {\n                (a1, a2)\n            };\n            let round_bit = a0 & (shift_bit >> 1);\n            (\n                a0 & !mask,\n                diff_1,\n                diff_2,\n                sticky_bit | (a0 & mask) ^ round_bit,\n                round_bit,\n                shift_bit,\n                neg,\n            )\n        } else if exp_diff < THRICE_WIDTH {\n            // warning: we must have the most significant bit of sticky_bit correct since it might\n            // become the round bit below\n            let mut sticky_bit;\n            if exp_diff == TWICE_WIDTH {\n                sticky_bit = y_1;\n                if y_0 != 0 {\n                    sticky_bit |= 1;\n                }\n            } else {\n                sticky_bit = y_2 << (THRICE_WIDTH - exp_diff);\n                if y_1 != 0 || y_0 != 0 {\n                    sticky_bit |= 1;\n                }\n            };\n            let overflow = sticky_bit.overflowing_neg_assign();\n            let mut a0 = x_0.wrapping_sub(y_2 >> (exp_diff - TWICE_WIDTH));\n            if overflow {\n                a0.wrapping_sub_assign(1);\n            }\n            let mut a1 = x_1;\n            if a0 > x_0 || (a0 == x_0 && overflow) {\n                a1.wrapping_sub_assign(1);\n            }\n            let mut a2 = x_2;\n            if a1 > x_1 {\n                a2.wrapping_sub_assign(1);\n            }\n            let (diff_1, diff_2) = if a2 < LIMB_HIGH_BIT {\n                let diff_1 = (a1 << 1) | (a0 >> WIDTH_M1);\n                a0 = (a0 << 1) | (sticky_bit >> WIDTH_M1);\n                sticky_bit <<= 1;\n                x_exp.saturating_sub_assign(1);\n                (diff_1, (a2 << 1) | (a1 >> WIDTH_M1))\n            } else {\n                (a1, a2)\n            };\n            let round_bit = a0 & (shift_bit >> 1);\n            (\n                a0 & !mask,\n                diff_1,\n                diff_2,\n                sticky_bit | (a0 & mask) ^ round_bit,\n                round_bit,\n                shift_bit,\n                neg,\n            )\n        } else {\n            // We compute x - ulp(x), and the remainder ulp(x) - y satisfies: 1/2 ulp(x) < ulp(x) -\n            // y < ulp(x), thus round_bit = sticky_bit = 1.\n            let (a0, overflow) = x_0.overflowing_sub(shift_bit);\n            let mut a1 = x_1;\n            if overflow {\n                a1.wrapping_sub_assign(1);\n            }\n            let mut a2 = x_2;\n            if a1 > x_1 {\n                a2.wrapping_sub_assign(1);\n            }\n            if a2 < LIMB_HIGH_BIT {\n                // - necessarily we had b = 1000...000\n                // - Warning: since we have an exponent decrease, when prec = Limb::WIDTH * 3 - 1\n                //   and exp_diff = Limb::WIDTH * 3, the round bit corresponds to the upper bit of\n                //   -y. In that case round_bit = 0 and sticky_bit = 1, except when y = 1000...000\n                //   where round_bit = 1 and sticky_bit = 0.\n                // - sticky_bit = 1 below is incorrect when prec = Limb::WIDTH * 2 - 1, exp_diff =\n                //   Limb::WIDTH * 2 and y = 1000...000, but in that case the even rule wound round\n                //   up too.\n                x_exp.saturating_sub_assign(1);\n                (\n                    !mask,\n                    Limb::MAX,\n                    Limb::MAX,\n                    1,\n                    Limb::from(\n                        shift > 1\n                            || exp_diff > THRICE_WIDTH\n                            || (y_2 == LIMB_HIGH_BIT && y_1 == 0 && y_0 == 0),\n                    ),\n                    shift_bit,\n                    neg,\n                )\n            } else {\n                (a0, a1, a2, 1, 1, shift_bit, neg)\n            }\n        }\n    };\n    if round_bit == 0 && sticky_bit == 0 {\n        (diff_0, diff_1, diff_2, x_exp, Equal, neg)\n    } else {\n        if neg {\n            rm.neg_assign();\n        }\n        match rm {\n            Exact => panic!(\"Inexact float subtraction\"),\n            Nearest => {\n                if round_bit == 0 || (sticky_bit == 0 && (diff_0 & shift_bit) == 0) {\n                    (diff_0, diff_1, diff_2, x_exp, Less, neg)\n                } else {\n                    if diff_0.overflowing_add_assign(shift_bit) {\n                        diff_1.wrapping_add_assign(1);\n                    }\n                    if diff_1 == 0 && diff_0 == 0 {\n                        diff_2.wrapping_add_assign(1);\n                    }\n                    if diff_2 == 0 {\n                        (\n                            diff_0,\n                            diff_1,\n                            LIMB_HIGH_BIT,\n                            x_exp.saturating_add(1),\n                            Greater,\n                            neg,\n                        )\n                    } else {\n                        (diff_0, diff_1, diff_2, x_exp, Greater, neg)\n                    }\n                }\n            }\n            Floor | Down => (diff_0, diff_1, diff_2, x_exp, Less, neg),\n            Ceiling | Up => {\n                if diff_0.overflowing_add_assign(shift_bit) {\n                    diff_1.wrapping_add_assign(1);\n                }\n                if diff_1 == 0 && diff_0 == 0 {\n                    diff_2.wrapping_add_assign(1);\n                }\n                if diff_2 == 0 {\n                    (\n                        diff_0,\n                        diff_1,\n                        LIMB_HIGH_BIT,\n                        x_exp.saturating_add(1),\n                        Greater,\n                        neg,\n                    )\n                } else {\n                    (diff_0, diff_1, diff_2, x_exp, Greater, neg)\n                }\n            }\n        }\n    }\n}\n\n// Equivalent to shifting xs left by 1, then calling limbs_sub_same_length_to_out.\nfn limbs_sub_shl1_same_length_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(out.len() >= len);\n    let mut carry = 0;\n    let mut remaining_xs_bits = 0;\n    for (out, (&x, &y)) in out.iter_mut().zip(xs.iter().zip(ys.iter())) {\n        let shifted_x = (x << 1) | remaining_xs_bits;\n        remaining_xs_bits = x >> WIDTH_M1;\n        (*out, carry) = sub_with_carry(shifted_x, y, carry);\n    }\n}\n\n// Equivalent to shifting ys right by `bits`, anding the least-significant limb with `ys0_and`, and\n// then calling limbs_sub_same_length_to_out.\nfn limbs_sub_shr_same_length_to_out_and_ys0(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    bits: u64,\n    ys0_and: Limb,\n) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(bits < Limb::WIDTH);\n    assert!(out.len() >= len);\n    let mut carry = 0;\n    let comp_bits = Limb::WIDTH - bits;\n    for i in 0..len {\n        let mut shifted_y = (ys[i] >> bits) | (ys.get(i + 1).unwrap_or(&0) << comp_bits);\n        if i == 0 {\n            shifted_y &= ys0_and;\n        }\n        (out[i], carry) = sub_with_carry(xs[i], shifted_y, carry);\n    }\n}\n\n// Equivalent to shifting ys right by `bits`, anding the least-significant limb with `ys0_and`, and\n// then calling limbs_sub_same_length_to_out. Also allows ys to be shorter than xs, and pretends\n// that the missing ys limbs are zeros.\nfn limbs_sub_shr_greater_to_out_and_ys0(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    bits: u64,\n    ys0_and: Limb,\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    assert!(xs_len >= ys_len);\n    assert!(bits < Limb::WIDTH);\n    assert!(out.len() >= xs_len);\n    let comp_bits = Limb::WIDTH - bits;\n    let mut carry = 0;\n    for i in 0..xs_len {\n        let mut shifted_y = if let Some(y) = ys.get(i) {\n            (y >> bits) | (ys.get(i + 1).unwrap_or(&0) << comp_bits)\n        } else {\n            0\n        };\n        if i == 0 {\n            shifted_y &= ys0_and;\n        }\n        (out[i], carry) = sub_with_carry(xs[i], shifted_y, carry);\n    }\n}\n\n// Equivalent to replacing ys[0] with something else, then calling limbs_sub_same_length_to_out.\n// Also allows ys to be shorter than xs, and pretends that the missing ys limbs are zeros.\nfn limbs_sub_greater_to_out_different_ys0(out: &mut [Limb], xs: &[Limb], ys: &[Limb], ys0: Limb) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    assert!(xs_len >= ys_len);\n    assert!(out.len() >= xs_len);\n    let mut carry = 0;\n    let mut first = true;\n    for (out, (&x, &y)) in out.iter_mut().zip(xs.iter().zip(ys.iter())) {\n        (*out, carry) = if first {\n            first = false;\n            sub_with_carry(x, ys0, carry)\n        } else {\n            sub_with_carry(x, y, carry)\n        };\n    }\n    if carry != 0 {\n        limbs_sub_limb_to_out(&mut out[ys_len..], &xs[ys_len..], 1);\n    } else {\n        out[ys_len..xs_len].copy_from_slice(&xs[ys_len..]);\n    }\n}\n\nfn cmp_size_helper(\n    xs: &[Limb],\n    x_exp: i32,\n    ys: &[Limb],\n    y_exp: i32,\n    prec: u64,\n) -> (usize, usize, bool) {\n    let n = bit_to_limb_count_ceiling(prec);\n    let nm1 = n - 1;\n    let mut k = nm1;\n    let neg = match x_exp.cmp(&y_exp) {\n        Equal => {\n            // Check mantissa since exponents are equal\n            let mut x_y_equal = false;\n            while xs[k] == ys[k] {\n                if k == 0 {\n                    x_y_equal = true;\n                    break;\n                }\n                k -= 1;\n            }\n            // If !x_y_equal, k is the largest integer < n such that xs[k] != ys[k]\n            if x_y_equal {\n                return (0, 0, false);\n            }\n            xs[k] < ys[k]\n        }\n        Less => true,\n        Greater => false,\n    };\n    (n, k, neg)\n}\n\nfn sub_float_significands_same_prec_ge_3w_ref_ref<'a>(\n    out: &mut [Limb],\n    mut xs: &'a [Limb],\n    mut x_exp: i32,\n    mut ys: &'a [Limb],\n    mut y_exp: i32,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (i32, Ordering, bool) {\n    let (n, mut k, neg) = cmp_size_helper(xs, x_exp, ys, y_exp, prec);\n    if n == 0 {\n        // x == y. Return exact number 0. Setting the most-significant limb to 0 is a sufficient\n        // signal to the caller that the entire output is 0, since in every other case the precision\n        // of the output is the same as the precision of the inputs, and the most-significant limb\n        // is therefore nonzero.\n        *out.last_mut().unwrap() = 0;\n        return (0, Equal, false);\n    }\n    let nm1 = n - 1;\n    if neg {\n        swap(&mut x_exp, &mut y_exp);\n        swap(&mut xs, &mut ys);\n    }\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    let mut round_bit;\n    let mut sticky_bit;\n    // round_bit_2 is the next bit after the round bit, and sticky_bit_2 the corresponding sticky\n    // bit.\n    let mut round_bit_2;\n    let mut sticky_bit_2;\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let mut goto_exact_normalize = false;\n    let mut goto_sub_d1_no_lose = false;\n    let mut goto_sub_d1_lose = false;\n    let mut limb = 0;\n    loop {\n        // loop for ExactNormalize, SubD1NoLose, and SubD1Lose\n        if !goto_sub_d1_no_lose && !goto_sub_d1_lose && (exp_diff == 0 || goto_exact_normalize) {\n            // ```\n            // <-- x -->\n            // <-- y --> : exact sub\n            // ```\n            if !goto_exact_normalize {\n                limbs_sub_same_length_to_out(out, xs, ys);\n            }\n            // label ExactNormalize:\n            limb = out[nm1];\n            if limb != 0 {\n                // First limb is not zero.\n                let leading_zeros = LeadingZeros::leading_zeros(limb);\n                // Warning: leading_zeros can be 0 when we come from the case SubD1Lose with\n                // ExactNormalize\n                if leading_zeros != 0 {\n                    limbs_slice_shl_in_place(out, leading_zeros);\n                    x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                }\n                // Last limb should be OK\n                assert_eq!(out[0] & (shift_bit - 1), 0);\n            } else {\n                // - First limb is zero: this can only occur for n >= 2\n                // - Find the first limb not equal to zero. It necessarily exists since |x| > |y|.\n                //   We know that xs[k] > ys[k] and all upper limbs are equal.\n                while out[k] == 0 {\n                    k -= 1;\n                }\n                limb = out[k];\n                // out[k] is the non-zero limb of largest index, thus we have to consider the k + 1\n                // least-significant limbs\n                assert_ne!(limb, 0);\n                let leading_zeros = LeadingZeros::leading_zeros(limb);\n                k += 1;\n                let len = n - k; // Number of most significant zero limbs\n                assert_ne!(k, 0);\n                if leading_zeros != 0 {\n                    limbs_slice_shl_in_place(&mut out[..k], leading_zeros);\n                }\n                out.copy_within(0..k, len);\n                slice_set_zero(&mut out[..len]);\n                x_exp = i32::saturating_from(\n                    i128::from(x_exp)\n                        - (i128::from(leading_zeros)\n                            + (i128::wrapping_from(len) << Limb::LOG_WIDTH)),\n                );\n                // out[len] should have its low bits zero: it is x[0] - y[0].\n                assert_eq!(out[len] & Limb::wrapping_from(shift), 0);\n            }\n            // No rounding is necessary since the result is exact\n            assert!(out[nm1].get_highest_bit());\n            return (x_exp, Equal, neg);\n        } else if exp_diff == 1 || goto_sub_d1_no_lose || goto_sub_d1_lose {\n            // ```\n            // | <-- x -->\n            // |  <-- y -->\n            // ```\n            if !goto_sub_d1_no_lose && !goto_sub_d1_lose {\n                // If we lose at least one bit, compute 2 * x - y (exact), else compute x - y / 2\n                limb = xs[k] - (ys[k] >> 1);\n            }\n            // Let W = 2 ^ Limb::WIDTH: we have |x| - |y| >= limb * W ^ k - (2 * W ^ k - 1) / 2 >=\n            // limb\n            // * W ^ k - W ^ k + 1 / 2. Thus, if limb > W / 2, |x| - |y| >= 1 / 2 * W ^ n. Moreover,\n            //   if\n            // trunc(|y|) represents the first prec - 1 bits of |y|, minus the last significant bit\n            // called y0 below (in fact y0 is that bit shifted by `shift` bits), then we have\n            // |x|-trunc(|y|) >= 1 / 2 * W ^ n + 1, thus the two limbs_sub calls below necessarily\n            // yield out > 1 / 2 * W ^ n.\n            if !goto_sub_d1_lose && (limb > LIMB_HIGH_BIT || goto_sub_d1_no_lose) {\n                // - case limb > W / 2\n                // - The exponent cannot decrease: compute x - y / 2.\n                // - Shift y in the allocated temporary block\n                //\n                // label SubD1NoLose:\n                let y0 = ys[0] & shift_bit;\n                let mask = shift_bit - 1;\n                // Zero last bit of y if set\n                limbs_sub_shr_same_length_to_out_and_ys0(out, xs, ys, 1, !mask);\n                assert!(out[nm1].get_highest_bit());\n                if y0 == 0 {\n                    // Result is exact: no need of rounding!\n                    return (x_exp, Equal, neg);\n                }\n                // - y0 is non-zero, thus we have to subtract 1 / 2 * ulp(out).\n                // - However, we know (see analysis above) that this cannot make the exponent\n                //   decrease.\n                // - Check last bits\n                assert_eq!(out[0] & mask, 0);\n                // - No normalization is needed\n                // - Rounding is necessary since y0 is non-zero\n                // - We have to subtract 1 at the round bit position, and 0 for the lower bits\n                round_bit = 1;\n                round_bit_2 = 0;\n                sticky_bit_2 = 0;\n            } else if limb < LIMB_HIGH_BIT || goto_sub_d1_lose {\n                // - |x| - |y| <= (W / 2 - 1) * W ^ k + W ^ k - 1 = 1 / 2 * W ^ n - 1\n                // - The exponent decreases by one.\n                // - Compute 2 * x - y (Exact)\n                //\n                // label SubD1Lose:\n                goto_sub_d1_lose = false;\n                limbs_sub_shl1_same_length_to_out(out, xs, ys);\n                x_exp.saturating_sub_assign(1);\n                assert_eq!(k, nm1);\n                goto_exact_normalize = true;\n                continue;\n            } else {\n                // - Case: limb = 100000000000\n                // - Check while b[l] == y'[l] (Y' is Y shifted by 1)\n                // - If x[l] < y'[l] => We lose at least one bit\n                // - If x[l] > y'[l] => We don't lose any bit\n                // - If l == -1 => We don't lose any bit AND the result is 100000000000 0000000000\n                //   00000000000\n                let mut l = n;\n                let mut yl_shifted;\n                loop {\n                    // The first loop will compare x[n - 2] and y'[n - 2]\n                    yl_shifted = ys[l - 1] << WIDTH_M1;\n                    l -= 1;\n                    if l == 0 {\n                        break;\n                    }\n                    yl_shifted += ys[l - 1] >> 1;\n                    if xs[l - 1] != yl_shifted {\n                        break;\n                    }\n                }\n                if l == 0 {\n                    if yl_shifted != 0 {\n                        // Since yl_shifted is what should be subtracted from out[-1], if non-zero\n                        // then necessarily the precision is a multiple of Limb::WIDTH, and we lose\n                        // one bit, thus the (exact) result is a power of 2 minus 1.\n                        for o in out.iter_mut() {\n                            *o = Limb::MAX;\n                        }\n                        x_exp.saturating_sub_assign(1);\n                    } else {\n                        // yl_shifted = 0: result is a power of 2.\n                        let (out_last, out_init) = out.split_last_mut().unwrap();\n                        slice_set_zero(out_init);\n                        *out_last = LIMB_HIGH_BIT;\n                    }\n                    // No Normalize is needed, no Rounding is needed\n                    return (x_exp, Equal, neg);\n                } else if xs[l - 1] > yl_shifted {\n                    // - cl_shifted is the shifted value c'[l]\n                    // - |x| - |y| >= 1 / 2 * W ^ n\n                    //\n                    // goto SubD1NoLose;\n                    goto_sub_d1_no_lose = true;\n                } else {\n                    // We cannot have xs[l] = yl_shifted since the only way we can exit the while\n                    // loop above is when xs[l] != yl_shifted or l < 0, and the case l < 0 was\n                    // already treated above.\n                    assert!(xs[l - 1] < yl_shifted);\n                    // |x| - |y| <= 1 / 2 * W ^ n - 1 and is exact\n                    goto_sub_d1_lose = true;\n                }\n                continue;\n            }\n        } else if exp_diff >= prec {\n            // The difference of exponents is larger than the precision of all operands, thus the\n            // result is either x or x - 1 ulp, with a possible exact result when x = prec, x = 2 ^\n            // e and y = 1 / 2 * ulp(x)\n            //\n            // - We can't set OUT before since we use ys for rounding...\n            // - Perform rounding: check if out = b or out = x - ulp(x)\n            if exp_diff == prec {\n                // since y is normalized, we need to subtract 1 / 2 * ulp(x)\n                round_bit = 1;\n                // round_bit_2 is the bit of weight 1 / 4 * ulp(x) in y. We assume a limb has at\n                // least 2 bits. If the precision is 1, we read in the unused bits, which should be\n                // zero, and this is what we want.\n                round_bit_2 = ys[nm1] & HALF_LIMB_HIGH_BIT;\n                // We also need sticky_bit_2\n                sticky_bit_2 = ys[nm1] & WIDTH_M2_MASK;\n                let mut k = nm1;\n                while sticky_bit_2 == 0 && k > 0 {\n                    k -= 1;\n                    sticky_bit_2 = ys[k];\n                }\n            } else {\n                round_bit = 0;\n                if exp_diff == prec + 1 {\n                    round_bit_2 = 1;\n                    sticky_bit_2 = ys[nm1] & WIDTH_M1_MASK;\n                    let mut k = nm1;\n                    while sticky_bit_2 == 0 && k > 0 {\n                        k -= 1;\n                        sticky_bit_2 = ys[k];\n                    }\n                } else {\n                    round_bit_2 = 0;\n                    sticky_bit_2 = 1; // since C is non-zero\n                }\n            }\n            // Copy mantissa X in OUT\n            out.copy_from_slice(xs);\n        } else {\n            // case 2 <= exp_diff < prec\n            //\n            // Compute round_bit = Cp and sticky_bit = C'p + 1\n            //\n            // Compute round_bit and round_bit_2 from Y The round bit is bit prec - exp_diff in Y,\n            // assuming the most significant bit of Y is bit 0\n            let x = prec - exp_diff;\n            let mut kx = nm1 - bit_to_limb_count_floor(x);\n            let mut sx_bit = Limb::power_of_2(WIDTH_M1 - (x & Limb::WIDTH_MASK));\n            // the round bit is in ys[kx], at position sx\n            assert!(prec >= exp_diff);\n            round_bit = ys[kx] & sx_bit;\n            // Now compute rxx: since exp_diff >= 2 it always exists in Y\n            sx_bit = if sx_bit == 1 {\n                // rxx is in the next limb\n                kx = kx.checked_sub(1).unwrap();\n                LIMB_HIGH_BIT\n            } else {\n                // round_bit and round_bit_2 are in the same limb\n                sx_bit >> 1\n            };\n            round_bit_2 = ys[kx] & sx_bit;\n            // Now look at the remaining low bits of Y to determine sticky_bit_2\n            sticky_bit_2 = ys[kx] & (sx_bit - 1);\n            while sticky_bit_2 == 0 && kx > 0 {\n                kx -= 1;\n                sticky_bit_2 = ys[kx];\n            }\n            // Clean shifted Y'\n            let mask = shift_bit - 1;\n            let dm = exp_diff & Limb::WIDTH_MASK;\n            let m = bit_to_limb_count_floor(exp_diff);\n            if dm == 0 {\n                assert_ne!(m, 0);\n                // - dm = 0 and m > 0: Just copy\n                // - Subtract the mantissa y from x in out\n                limbs_sub_greater_to_out_different_ys0(out, xs, &ys[m..], ys[m] & !mask);\n            } else if m == 0 {\n                // dm >=2 and m == 0: just shift\n                assert!(dm >= 2);\n                // Subtract the mantissa y from x in out\n                limbs_sub_shr_same_length_to_out_and_ys0(out, xs, ys, dm, !mask);\n            } else {\n                // - dm > 0 and m > 0: shift and zero\n                // - Subtract the mantissa y from x in out\n                limbs_sub_shr_greater_to_out_and_ys0(out, xs, &ys[m..], dm, !mask);\n            }\n            // Normalize: we lose at most one bit\n            if !out[nm1].get_highest_bit() {\n                // - High bit is not set and we have to fix it.\n                // - OUT >= 010000xxx001\n                limbs_slice_shl_in_place(out, 1);\n                // OUT >= 100000xxx010\n                if round_bit != 0 {\n                    // - Check if Y = -1\n                    // - Since Y == -1, we have to subtract one more\n                    limbs_sub_limb_in_place(out, shift_bit);\n                    assert!(out[nm1].get_highest_bit());\n                }\n                // - OUT >= 10000xxx001\n                // - Final exponent -1 since we have shifted the mantissa\n                x_exp.saturating_sub_assign(1);\n                round_bit = round_bit_2;\n                round_bit_2 = sticky_bit_2;\n                // We don't have anymore a valid Yp + 1, but since Oyr >= 100000xxx001, the final\n                // sub can't unnormalize.\n            }\n            assert_eq!(out[0] & mask, 0);\n        }\n        // only loop when emulating gotos\n        break;\n    }\n    let mut out_power_of_2;\n    loop {\n        // At this point out contains x - high(y), normalized, and we have to subtract round_bit *\n        // 1/2 ulp(out), round_bit_2 * 1/4 ulp(out), and sticky_bit_2 * 1/8 ulp(out), interpreting\n        // round_bit/round_bit_2/sticky_bit_2 as 1 if non-zero.\n        sticky_bit = round_bit_2 | sticky_bit_2;\n        if round_bit == 0 && sticky_bit == 0 {\n            return (x_exp, Equal, neg);\n        }\n        out_power_of_2 = limbs_is_power_of_2(out);\n        if out_power_of_2 && round_bit != 0 {\n            limbs_sub_limb_in_place(out, shift_bit);\n            out[nm1] |= LIMB_HIGH_BIT;\n            x_exp.saturating_sub_assign(1);\n            round_bit = round_bit_2;\n            round_bit_2 = sticky_bit_2;\n            sticky_bit_2 = 0;\n        } else {\n            break;\n        }\n    }\n    // Now if out is a power of two, necessary round_bit = 0, which means the exact result is always\n    // in (pred(out), out), and the bounds cannot be attained\n    if neg {\n        rm.neg_assign();\n    }\n    match rm {\n        Exact => panic!(\"Inexact float subtraction\"),\n        Nearest => {\n            if out_power_of_2 {\n                assert_eq!(round_bit, 0);\n                // Since we are at the end of the binade, we have in fact round_bit = round_bit_2\n                // and sticky_bit = sticky_bit_2\n                round_bit = round_bit_2;\n                sticky_bit = sticky_bit_2;\n            }\n            if (prec == 1 || out[0] & shift_bit == 0 || round_bit == 0)\n                && (sticky_bit == 0 || round_bit == 0)\n            {\n                (x_exp, Greater, neg)\n            } else {\n                limbs_sub_limb_in_place(out, shift_bit);\n                if out_power_of_2 {\n                    // deal with cancellation\n                    out[nm1] |= LIMB_HIGH_BIT;\n                    x_exp.saturating_sub_assign(1);\n                }\n                (x_exp, Less, neg)\n            }\n        }\n        Floor | Down => {\n            limbs_sub_limb_in_place(out, shift_bit);\n            if out_power_of_2 {\n                // deal with cancellation\n                out[nm1] |= LIMB_HIGH_BIT;\n                x_exp.saturating_sub_assign(1);\n            }\n            (x_exp, Less, neg)\n        }\n        Ceiling | Up => (x_exp, Greater, neg),\n    }\n}\n\n// Equivalent to shifting xs left by 1, then calling limbs_sub_same_length_to_out.\nfn limbs_sub_shl1_same_length_in_place_left(xs: &mut [Limb], ys: &[Limb]) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    let mut carry = 0;\n    let mut remaining_xs_bits = 0;\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        let shifted_x = (*x << 1) | remaining_xs_bits;\n        remaining_xs_bits = *x >> WIDTH_M1;\n        (*x, carry) = sub_with_carry(shifted_x, y, carry);\n    }\n}\n\n// Equivalent to shifting ys right by `bits`, anding the least-significant limb with `ys0_and`, and\n// then calling limbs_sub_same_length_in_place_left.\nfn limbs_sub_shr_same_length_in_place_left_and_ys0(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    bits: u64,\n    ys0_and: Limb,\n) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(bits < Limb::WIDTH);\n    let mut carry = 0;\n    let comp_bits = Limb::WIDTH - bits;\n    for i in 0..len {\n        let mut shifted_y = (ys[i] >> bits) | (ys.get(i + 1).unwrap_or(&0) << comp_bits);\n        if i == 0 {\n            shifted_y &= ys0_and;\n        }\n        (xs[i], carry) = sub_with_carry(xs[i], shifted_y, carry);\n    }\n}\n\n// Equivalent to shifting ys right by `bits`, anding the least-significant limb with `ys0_and`, and\n// then calling limbs_sub_same_length_in_place_left. Also allows ys to be shorter than xs, and\n// pretends that the missing ys limbs are zeros.\nfn limbs_sub_shr_greater_in_place_left_and_ys0(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    bits: u64,\n    ys0_and: Limb,\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    assert!(xs_len >= ys_len);\n    assert!(bits < Limb::WIDTH);\n    let comp_bits = Limb::WIDTH - bits;\n    let mut carry = 0;\n    for (i, x) in xs.iter_mut().enumerate() {\n        let mut shifted_y = if let Some(y) = ys.get(i) {\n            (y >> bits) | (ys.get(i + 1).unwrap_or(&0) << comp_bits)\n        } else {\n            0\n        };\n        if i == 0 {\n            shifted_y &= ys0_and;\n        }\n        (*x, carry) = sub_with_carry(*x, shifted_y, carry);\n    }\n}\n\n// Equivalent to replacing ys[0] with something else, then calling\n// limbs_sub_same_length_in_place_left. Also allows ys to be shorter than xs, and pretends that the\n// missing ys limbs are zeros.\nfn limbs_sub_greater_in_place_left_different_ys0(xs: &mut [Limb], ys: &[Limb], ys0: Limb) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    assert!(xs_len >= ys_len);\n    let mut carry = 0;\n    let mut first = true;\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        (*x, carry) = if first {\n            first = false;\n            sub_with_carry(*x, ys0, carry)\n        } else {\n            sub_with_carry(*x, y, carry)\n        };\n    }\n    if carry != 0 {\n        limbs_sub_limb_in_place(&mut xs[ys_len..], 1);\n    }\n}\n\nfn sub_float_significands_same_prec_ge_3w_val_val<'a>(\n    mut xs: &'a mut [Limb],\n    mut x_exp: i32,\n    mut ys: &'a mut [Limb],\n    mut y_exp: i32,\n    prec: u64,\n    mut rm: RoundingMode,\n) -> (i32, Ordering, bool) {\n    let (n, _, neg) = cmp_size_helper(xs, x_exp, ys, y_exp, prec);\n    if n == 0 {\n        // x == y. Return exact number 0. Setting the most-significant limb to 0 is a sufficient\n        // signal to the caller that the entire output is 0, since in every other case the precision\n        // of the output is the same as the precision of the inputs, and the most-significant limb\n        // is therefore nonzero.\n        *xs.last_mut().unwrap() = 0;\n        return (0, Equal, false);\n    }\n    if neg {\n        rm.neg_assign();\n        swap(&mut x_exp, &mut y_exp);\n        swap(&mut xs, &mut ys);\n    }\n    let (exp, o) =\n        sub_float_significands_same_prec_ge_3w_val_ref_helper(xs, x_exp, ys, y_exp, prec, rm);\n    (exp, o, neg)\n}\n\nfn sub_float_significands_same_prec_ge_3w_val_ref(\n    xs: &mut [Limb],\n    x_exp: i32,\n    ys: &[Limb],\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering, bool) {\n    let (n, _, neg) = cmp_size_helper(xs, x_exp, ys, y_exp, prec);\n    if n == 0 {\n        // x == y. Return exact number 0. Setting the most-significant limb to 0 is a sufficient\n        // signal to the caller that the entire output is 0, since in every other case the precision\n        // of the output is the same as the precision of the inputs, and the most-significant limb\n        // is therefore nonzero.\n        *xs.last_mut().unwrap() = 0;\n        return (0, Equal, false);\n    }\n    if neg {\n        let (exp, o) =\n            sub_float_significands_same_prec_ge_3w_ref_val_helper(ys, y_exp, xs, x_exp, prec, -rm);\n        (exp, o, true)\n    } else {\n        let (exp, o) =\n            sub_float_significands_same_prec_ge_3w_val_ref_helper(xs, x_exp, ys, y_exp, prec, rm);\n        (exp, o, false)\n    }\n}\n\nfn sub_float_significands_same_prec_ge_3w_val_ref_helper(\n    xs: &mut [Limb],\n    mut x_exp: i32,\n    ys: &[Limb],\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    let n = bit_to_limb_count_ceiling(prec);\n    let nm1 = n - 1;\n    let mut k = nm1;\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    let mut round_bit;\n    let mut sticky_bit;\n    // round_bit_2 is the next bit after the round bit, and sticky_bit_2 the corresponding sticky\n    // bit.\n    let mut round_bit_2;\n    let mut sticky_bit_2;\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let mut goto_exact_normalize = false;\n    let mut goto_sub_d1_no_lose = false;\n    let mut goto_sub_d1_lose = false;\n    let mut limb = 0;\n    loop {\n        // loop for ExactNormalize, SubD1NoLose, and SubD1Lose\n        if !goto_sub_d1_no_lose && !goto_sub_d1_lose && (exp_diff == 0 || goto_exact_normalize) {\n            // ```\n            // <-- x -->\n            // <-- y --> : exact sub\n            // ```\n            if !goto_exact_normalize {\n                limbs_sub_same_length_in_place_left(xs, ys);\n            }\n            // label ExactNormalize:\n            limb = xs[nm1];\n            if limb != 0 {\n                // First limb is not zero.\n                let leading_zeros = LeadingZeros::leading_zeros(limb);\n                // Warning: leading_zeros can be 0 when we come from the case SubD1Lose with\n                // ExactNormalize\n                if leading_zeros != 0 {\n                    limbs_slice_shl_in_place(xs, leading_zeros);\n                    x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                }\n                // Last limb should be OK\n                assert_eq!(xs[0] & (shift_bit - 1), 0);\n            } else {\n                // - First limb is zero: this can only occur for n >= 2\n                // - Find the first limb not equal to zero. It necessarily exists since |x| > |y|.\n                //   We know that xs[k] > ys[k] and all upper limbs are equal.\n                while xs[k] == 0 {\n                    k -= 1;\n                }\n                limb = xs[k];\n                // out[k] is the non-zero limb of largest index, thus we have to consider the k + 1\n                // least-significant limbs\n                assert_ne!(limb, 0);\n                let leading_zeros = LeadingZeros::leading_zeros(limb);\n                k += 1;\n                let len = n - k; // Number of most significant zero limbs\n                assert_ne!(k, 0);\n                if leading_zeros != 0 {\n                    limbs_slice_shl_in_place(&mut xs[..k], leading_zeros);\n                }\n                xs.copy_within(0..k, len);\n                slice_set_zero(&mut xs[..len]);\n                x_exp = i32::saturating_from(\n                    i128::from(x_exp)\n                        - (i128::from(leading_zeros)\n                            + (i128::wrapping_from(len) << Limb::LOG_WIDTH)),\n                );\n                // out[len] should have its low bits zero: it is x[0] - y[0].\n                assert_eq!(xs[len] & Limb::wrapping_from(shift), 0);\n            }\n            // No rounding is necessary since the result is exact\n            assert!(xs[nm1].get_highest_bit());\n            return (x_exp, Equal);\n        } else if exp_diff == 1 || goto_sub_d1_no_lose || goto_sub_d1_lose {\n            // ```\n            // | <-- x -->\n            // |  <-- y -->\n            // ```\n            if !goto_sub_d1_no_lose && !goto_sub_d1_lose {\n                // If we lose at least one bit, compute 2 * x - y (exact), else compute x - y / 2\n                limb = xs[k] - (ys[k] >> 1);\n            }\n            // Let W = 2 ^ Limb::WIDTH: we have |x| - |y| >= limb * W ^ k - (2 * W ^ k - 1) / 2 >=\n            // limb\n            // * W ^ k - W ^ k + 1 / 2. Thus, if limb > W / 2, |x| - |y| >= 1 / 2 * W ^ n. Moreover,\n            //   if\n            // trunc(|y|) represents the first prec - 1 bits of |y|, minus the last significant bit\n            // called y0 below (in fact y0 is that bit shifted by `shift` bits), then we have\n            // |x|-trunc(|y|) >= 1 / 2 * W ^ n + 1, thus the two limbs_sub calls below necessarily\n            // yield out > 1 / 2 * W ^ n.\n            if !goto_sub_d1_lose && (limb > LIMB_HIGH_BIT || goto_sub_d1_no_lose) {\n                // - case limb > W / 2\n                // - The exponent cannot decrease: compute x - y / 2.\n                // - Shift y in the allocated temporary block\n                //\n                // label SubD1NoLose:\n                let y0 = ys[0] & shift_bit;\n                let mask = shift_bit - 1;\n                // Zero last bit of y if set\n                limbs_sub_shr_same_length_in_place_left_and_ys0(xs, ys, 1, !mask);\n                assert!(xs[nm1].get_highest_bit());\n                if y0 == 0 {\n                    // Result is exact: no need of rounding!\n                    return (x_exp, Equal);\n                }\n                // - y0 is non-zero, thus we have to subtract 1 / 2 * ulp(out).\n                // - However, we know (see analysis above) that this cannot make the exponent\n                //   decrease.\n                // - Check last bits\n                assert_eq!(xs[0] & mask, 0);\n                // - No normalization is needed\n                // - Rounding is necessary since y0 is non-zero\n                // - We have to subtract 1 at the round bit position, and 0 for the lower bits\n                round_bit = 1;\n                round_bit_2 = 0;\n                sticky_bit_2 = 0;\n            } else if limb < LIMB_HIGH_BIT || goto_sub_d1_lose {\n                // - |x| - |y| <= (W / 2 - 1) * W ^ k + W ^ k - 1 = 1 / 2 * W ^ n - 1\n                // - The exponent decreases by one.\n                // - Compute 2 * x - y (Exact)\n                //\n                // label SubD1Lose:\n                goto_sub_d1_lose = false;\n                limbs_sub_shl1_same_length_in_place_left(xs, ys);\n                x_exp.saturating_sub_assign(1);\n                assert_eq!(k, nm1);\n                goto_exact_normalize = true;\n                continue;\n            } else {\n                // - Case: limb = 100000000000\n                // - Check while b[l] == y'[l] (Y' is Y shifted by 1)\n                // - If x[l] < y'[l] => We lose at least one bit\n                // - If x[l] > y'[l] => We don't lose any bit\n                // - If l == -1 => We don't lose any bit AND the result is 100000000000 0000000000\n                //   00000000000\n                let mut l = n;\n                let mut yl_shifted;\n                loop {\n                    // The first loop will compare x[n - 2] and y'[n - 2]\n                    yl_shifted = ys[l - 1] << WIDTH_M1;\n                    l -= 1;\n                    if l == 0 {\n                        break;\n                    }\n                    yl_shifted += ys[l - 1] >> 1;\n                    if xs[l - 1] != yl_shifted {\n                        break;\n                    }\n                }\n                if l == 0 {\n                    if yl_shifted != 0 {\n                        // Since yl_shifted is what should be subtracted from out[-1], if non-zero\n                        // then necessarily the precision is a multiple of Limb::WIDTH, and we lose\n                        // one bit, thus the (exact) result is a power of 2 minus 1.\n                        for x in xs.iter_mut() {\n                            *x = Limb::MAX;\n                        }\n                        x_exp.saturating_sub_assign(1);\n                    } else {\n                        // yl_shifted = 0: result is a power of 2.\n                        let (xs_last, xs_init) = xs.split_last_mut().unwrap();\n                        slice_set_zero(xs_init);\n                        *xs_last = LIMB_HIGH_BIT;\n                    }\n                    // No Normalize is needed, no Rounding is needed\n                    return (x_exp, Equal);\n                } else if xs[l - 1] > yl_shifted {\n                    // - cl_shifted is the shifted value c'[l]\n                    // - |x| - |y| >= 1 / 2 * W ^ n\n                    //\n                    // goto SubD1NoLose;\n                    goto_sub_d1_no_lose = true;\n                } else {\n                    // We cannot have xs[l] = yl_shifted since the only way we can exit the while\n                    // loop above is when xs[l] != yl_shifted or l < 0, and the case l < 0 was\n                    // already treated above.\n                    assert!(xs[l - 1] < yl_shifted);\n                    // |x| - |y| <= 1 / 2 * W ^ n - 1 and is exact\n                    goto_sub_d1_lose = true;\n                }\n                continue;\n            }\n        } else if exp_diff >= prec {\n            // The difference of exponents is larger than the precision of all operands, thus the\n            // result is either x or x - 1 ulp, with a possible exact result when x = prec, x = 2 ^\n            // e and y = 1 / 2 * ulp(x)\n            //\n            // - We can't set OUT before since we use ys for rounding...\n            // - Perform rounding: check if out = b or out = x - ulp(x)\n            if exp_diff == prec {\n                // since y is normalized, we need to subtract 1 / 2 * ulp(x)\n                round_bit = 1;\n                // round_bit_2 is the bit of weight 1 / 4 * ulp(x) in y. We assume a limb has at\n                // least 2 bits. If the precision is 1, we read in the unused bits, which should be\n                // zero, and this is what we want.\n                round_bit_2 = ys[nm1] & HALF_LIMB_HIGH_BIT;\n                // We also need sticky_bit_2\n                sticky_bit_2 = ys[nm1] & WIDTH_M2_MASK;\n                let mut k = nm1;\n                while sticky_bit_2 == 0 && k > 0 {\n                    k -= 1;\n                    sticky_bit_2 = ys[k];\n                }\n            } else {\n                round_bit = 0;\n                if exp_diff == prec + 1 {\n                    round_bit_2 = 1;\n                    sticky_bit_2 = ys[nm1] & WIDTH_M1_MASK;\n                    let mut k = nm1;\n                    while sticky_bit_2 == 0 && k > 0 {\n                        k -= 1;\n                        sticky_bit_2 = ys[k];\n                    }\n                } else {\n                    round_bit_2 = 0;\n                    sticky_bit_2 = 1; // since C is non-zero\n                }\n            }\n        } else {\n            // case 2 <= exp_diff < prec\n            //\n            // Compute round_bit = Cp and sticky_bit = C'p + 1\n            //\n            // Compute round_bit and round_bit_2 from Y The round bit is bit prec - exp_diff in Y,\n            // assuming the most significant bit of Y is bit 0\n            let x = prec - exp_diff;\n            let mut kx = nm1 - bit_to_limb_count_floor(x);\n            let mut sx_bit = Limb::power_of_2(WIDTH_M1 - (x & Limb::WIDTH_MASK));\n            // the round bit is in ys[kx], at position sx\n            assert!(prec >= exp_diff);\n            round_bit = ys[kx] & sx_bit;\n            // Now compute rxx: since exp_diff >= 2 it always exists in Y\n            sx_bit = if sx_bit == 1 {\n                // rxx is in the next limb\n                kx = kx.checked_sub(1).unwrap();\n                LIMB_HIGH_BIT\n            } else {\n                // round_bit and round_bit_2 are in the same limb\n                sx_bit >> 1\n            };\n            round_bit_2 = ys[kx] & sx_bit;\n            // Now look at the remaining low bits of Y to determine sticky_bit_2\n            sticky_bit_2 = ys[kx] & (sx_bit - 1);\n            while sticky_bit_2 == 0 && kx > 0 {\n                kx -= 1;\n                sticky_bit_2 = ys[kx];\n            }\n            // Clean shifted Y'\n            let mask = shift_bit - 1;\n            let dm = exp_diff & Limb::WIDTH_MASK;\n            let m = bit_to_limb_count_floor(exp_diff);\n            if dm == 0 {\n                assert_ne!(m, 0);\n                // - dm = 0 and m > 0: Just copy\n                // - Subtract the mantissa y from x in out\n                limbs_sub_greater_in_place_left_different_ys0(xs, &ys[m..], ys[m] & !mask);\n            } else if m == 0 {\n                // dm >=2 and m == 0: just shift\n                assert!(dm >= 2);\n                // Subtract the mantissa y from x in out\n                limbs_sub_shr_same_length_in_place_left_and_ys0(xs, ys, dm, !mask);\n            } else {\n                // - dm > 0 and m > 0: shift and zero\n                // - Subtract the mantissa y from x in out\n                limbs_sub_shr_greater_in_place_left_and_ys0(xs, &ys[m..], dm, !mask);\n            }\n            // Normalize: we lose at most one bit\n            if !xs[nm1].get_highest_bit() {\n                // - High bit is not set and we have to fix it.\n                // - OUT >= 010000xxx001\n                limbs_slice_shl_in_place(xs, 1);\n                // OUT >= 100000xxx010\n                if round_bit != 0 {\n                    // - Check if Y = -1\n                    // - Since Y == -1, we have to subtract one more\n                    limbs_sub_limb_in_place(xs, shift_bit);\n                    assert!(xs[nm1].get_highest_bit());\n                }\n                // - OUT >= 10000xxx001\n                // - Final exponent -1 since we have shifted the mantissa\n                x_exp.saturating_sub_assign(1);\n                round_bit = round_bit_2;\n                round_bit_2 = sticky_bit_2;\n                // We don't have anymore a valid Yp + 1, but since Oyr >= 100000xxx001, the final\n                // sub can't unnormalize.\n            }\n            assert_eq!(xs[0] & mask, 0);\n        }\n        // only loop when emulating gotos\n        break;\n    }\n    let mut out_power_of_2;\n    loop {\n        // At this point out contains x - high(y), normalized, and we have to subtract round_bit *\n        // 1/2 ulp(out), round_bit_2 * 1/4 ulp(out), and sticky_bit_2 * 1/8 ulp(out), interpreting\n        // round_bit/round_bit_2/sticky_bit_2 as 1 if non-zero.\n        sticky_bit = round_bit_2 | sticky_bit_2;\n        if round_bit == 0 && sticky_bit == 0 {\n            return (x_exp, Equal);\n        }\n        out_power_of_2 = limbs_is_power_of_2(xs);\n        if out_power_of_2 && round_bit != 0 {\n            limbs_sub_limb_in_place(xs, shift_bit);\n            xs[nm1] |= LIMB_HIGH_BIT;\n            x_exp.saturating_sub_assign(1);\n            round_bit = round_bit_2;\n            round_bit_2 = sticky_bit_2;\n            sticky_bit_2 = 0;\n        } else {\n            break;\n        }\n    }\n    // Now if out is a power of two, necessary round_bit = 0, which means the exact result is always\n    // in (pred(xs), xs), and the bounds cannot be attained\n    match rm {\n        Exact => panic!(\"Inexact float subtraction\"),\n        Nearest => {\n            if out_power_of_2 {\n                assert_eq!(round_bit, 0);\n                // Since we are at the end of the binade, we have in fact round_bit = round_bit_2\n                // and sticky_bit = sticky_bit_2\n                round_bit = round_bit_2;\n                sticky_bit = sticky_bit_2;\n            }\n            if (prec == 1 || xs[0] & shift_bit == 0 || round_bit == 0)\n                && (sticky_bit == 0 || round_bit == 0)\n            {\n                (x_exp, Greater)\n            } else {\n                limbs_sub_limb_in_place(xs, shift_bit);\n                if out_power_of_2 {\n                    // deal with cancellation\n                    xs[nm1] |= LIMB_HIGH_BIT;\n                    x_exp.saturating_sub_assign(1);\n                }\n                (x_exp, Less)\n            }\n        }\n        Floor | Down => {\n            limbs_sub_limb_in_place(xs, shift_bit);\n            if out_power_of_2 {\n                // deal with cancellation\n                xs[nm1] |= LIMB_HIGH_BIT;\n                x_exp.saturating_sub_assign(1);\n            }\n            (x_exp, Less)\n        }\n        Ceiling | Up => (x_exp, Greater),\n    }\n}\n\n// Equivalent to shifting xs left by 1, then calling limbs_sub_same_length_in_place_right.\nfn limbs_sub_shl1_same_length_in_place_right(xs: &[Limb], ys: &mut [Limb]) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    let mut carry = 0;\n    let mut remaining_xs_bits = 0;\n    for (&x, y) in xs.iter().zip(ys.iter_mut()) {\n        let shifted_x = (x << 1) | remaining_xs_bits;\n        remaining_xs_bits = x >> WIDTH_M1;\n        (*y, carry) = sub_with_carry(shifted_x, *y, carry);\n    }\n}\n\n// Equivalent to shifting ys right by `bits`, anding the least-significant limb with `ys0_and`, and\n// then calling limbs_sub_same_length_in_place_right.\nfn limbs_sub_shr_same_length_in_place_right_and_ys0(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    bits: u64,\n    ys0_and: Limb,\n) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(bits < Limb::WIDTH);\n    let mut carry = 0;\n    let comp_bits = Limb::WIDTH - bits;\n    for i in 0..len {\n        let mut shifted_y = (ys[i] >> bits) | (ys.get(i + 1).unwrap_or(&0) << comp_bits);\n        if i == 0 {\n            shifted_y &= ys0_and;\n        }\n        (ys[i], carry) = sub_with_carry(xs[i], shifted_y, carry);\n    }\n}\n\nfn limbs_sub_shr_greater_in_place_right_and_ys0(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    bits: u64,\n    ys0_and: Limb,\n    m: usize,\n) {\n    let n = xs.len();\n    assert_ne!(n, 0);\n    assert!(bits < Limb::WIDTH);\n    let comp_bits = Limb::WIDTH - bits;\n    let mut carry = 0;\n    for i in 0..n {\n        let mut shifted_y = if let Some(y) = ys.get(i + m) {\n            (y >> bits) | (ys.get(i + m + 1).unwrap_or(&0) << comp_bits)\n        } else {\n            0\n        };\n        if i == 0 {\n            shifted_y &= ys0_and;\n        }\n        (ys[i], carry) = sub_with_carry(xs[i], shifted_y, carry);\n    }\n}\n\nfn limbs_sub_greater_in_place_right_different_ys0(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    ys0: Limb,\n    m: usize,\n) {\n    let mut carry = 0;\n    for i in 0..xs.len() {\n        (ys[i], carry) = sub_with_carry(\n            xs[i],\n            if i == 0 {\n                ys0\n            } else {\n                ys.get(i + m).copied().unwrap_or(0)\n            },\n            carry,\n        );\n    }\n}\n\nfn sub_float_significands_same_prec_ge_3w_ref_val_helper(\n    xs: &[Limb],\n    mut x_exp: i32,\n    ys: &mut [Limb],\n    y_exp: i32,\n    prec: u64,\n    rm: RoundingMode,\n) -> (i32, Ordering) {\n    let n = bit_to_limb_count_ceiling(prec);\n    let nm1 = n - 1;\n    let mut k = nm1;\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    let mut round_bit;\n    let mut sticky_bit;\n    // round_bit_2 is the next bit after the round bit, and sticky_bit_2 the corresponding sticky\n    // bit.\n    let mut round_bit_2;\n    let mut sticky_bit_2;\n    let shift = prec.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let shift_bit = Limb::power_of_2(shift);\n    let mut goto_exact_normalize = false;\n    let mut goto_sub_d1_no_lose = false;\n    let mut goto_sub_d1_lose = false;\n    let mut limb = 0;\n    loop {\n        // loop for ExactNormalize, SubD1NoLose, and SubD1Lose\n        if !goto_sub_d1_no_lose && !goto_sub_d1_lose && (exp_diff == 0 || goto_exact_normalize) {\n            // ```\n            // <-- x -->\n            // <-- y --> : exact sub\n            // ```\n            if !goto_exact_normalize {\n                limbs_sub_same_length_in_place_right(xs, ys);\n            }\n            // label ExactNormalize:\n            limb = ys[nm1];\n            if limb != 0 {\n                // First limb is not zero.\n                let leading_zeros = LeadingZeros::leading_zeros(limb);\n                // Warning: leading_zeros can be 0 when we come from the case SubD1Lose with\n                // ExactNormalize\n                if leading_zeros != 0 {\n                    limbs_slice_shl_in_place(ys, leading_zeros);\n                    x_exp.saturating_sub_assign(i32::wrapping_from(leading_zeros));\n                }\n                // Last limb should be OK\n                assert_eq!(ys[0] & (shift_bit - 1), 0);\n            } else {\n                // - First limb is zero: this can only occur for n >= 2\n                // - Find the first limb not equal to zero. It necessarily exists since |x| > |y|.\n                //   We know that xs[k] > ys[k] and all upper limbs are equal.\n                while ys[k] == 0 {\n                    k -= 1;\n                }\n                limb = ys[k];\n                // out[k] is the non-zero limb of largest index, thus we have to consider the k + 1\n                // least-significant limbs\n                assert_ne!(limb, 0);\n                let leading_zeros = LeadingZeros::leading_zeros(limb);\n                k += 1;\n                let len = n - k; // Number of most significant zero limbs\n                assert_ne!(k, 0);\n                if leading_zeros != 0 {\n                    limbs_slice_shl_in_place(&mut ys[..k], leading_zeros);\n                }\n                ys.copy_within(0..k, len);\n                slice_set_zero(&mut ys[..len]);\n                x_exp = i32::saturating_from(\n                    i128::from(x_exp)\n                        - (i128::from(leading_zeros)\n                            + (i128::wrapping_from(len) << Limb::LOG_WIDTH)),\n                );\n                // out[len] should have its low bits zero: it is x[0] - y[0].\n                assert_eq!(ys[len] & Limb::wrapping_from(shift), 0);\n            }\n            // No rounding is necessary since the result is exact\n            assert!(ys[nm1].get_highest_bit());\n            return (x_exp, Equal);\n        } else if exp_diff == 1 || goto_sub_d1_no_lose || goto_sub_d1_lose {\n            // ```\n            // | <-- x -->\n            // |  <-- y -->\n            // ```\n            if !goto_sub_d1_no_lose && !goto_sub_d1_lose {\n                // If we lose at least one bit, compute 2 * x - y (exact), else compute x - y / 2\n                limb = xs[k] - (ys[k] >> 1);\n            }\n            // Let W = 2 ^ Limb::WIDTH: we have |x| - |y| >= limb * W ^ k - (2 * W ^ k - 1) / 2 >=\n            // limb\n            // * W ^ k - W ^ k + 1 / 2. Thus, if limb > W / 2, |x| - |y| >= 1 / 2 * W ^ n. Moreover,\n            //   if\n            // trunc(|y|) represents the first prec - 1 bits of |y|, minus the last significant bit\n            // called y0 below (in fact y0 is that bit shifted by `shift` bits), then we have\n            // |x|-trunc(|y|) >= 1 / 2 * W ^ n + 1, thus the two limbs_sub calls below necessarily\n            // yield out > 1 / 2 * W ^ n.\n            if !goto_sub_d1_lose && (limb > LIMB_HIGH_BIT || goto_sub_d1_no_lose) {\n                // - case limb > W / 2\n                // - The exponent cannot decrease: compute x - y / 2.\n                // - Shift y in the allocated temporary block\n                //\n                // label SubD1NoLose:\n                let y0 = ys[0] & shift_bit;\n                let mask = shift_bit - 1;\n                // Zero last bit of y if set\n                limbs_sub_shr_same_length_in_place_right_and_ys0(xs, ys, 1, !mask);\n                assert!(ys[nm1].get_highest_bit());\n                if y0 == 0 {\n                    // Result is exact: no need of rounding!\n                    return (x_exp, Equal);\n                }\n                // - y0 is non-zero, thus we have to subtract 1 / 2 * ulp(out).\n                // - However, we know (see analysis above) that this cannot make the exponent\n                //   decrease.\n                // - Check last bits\n                assert_eq!(ys[0] & mask, 0);\n                // - No normalization is needed\n                // - Rounding is necessary since y0 is non-zero\n                // - We have to subtract 1 at the round bit position, and 0 for the lower bits\n                round_bit = 1;\n                round_bit_2 = 0;\n                sticky_bit_2 = 0;\n            } else if limb < LIMB_HIGH_BIT || goto_sub_d1_lose {\n                // - |x| - |y| <= (W / 2 - 1) * W ^ k + W ^ k - 1 = 1 / 2 * W ^ n - 1\n                // - The exponent decreases by one.\n                // - Compute 2 * x - y (Exact)\n                //\n                // label SubD1Lose:\n                goto_sub_d1_lose = false;\n                limbs_sub_shl1_same_length_in_place_right(xs, ys);\n                x_exp.saturating_sub_assign(1);\n                assert_eq!(k, nm1);\n                goto_exact_normalize = true;\n                continue;\n            } else {\n                // - Case: limb = 100000000000\n                // - Check while b[l] == y'[l] (Y' is Y shifted by 1)\n                // - If x[l] < y'[l] => We lose at least one bit\n                // - If x[l] > y'[l] => We don't lose any bit\n                // - If l == -1 => We don't lose any bit AND the result is 100000000000 0000000000\n                //   00000000000\n                let mut l = n;\n                let mut yl_shifted;\n                loop {\n                    // The first loop will compare x[n - 2] and y'[n - 2]\n                    yl_shifted = ys[l - 1] << WIDTH_M1;\n                    l -= 1;\n                    if l == 0 {\n                        break;\n                    }\n                    yl_shifted += ys[l - 1] >> 1;\n                    if xs[l - 1] != yl_shifted {\n                        break;\n                    }\n                }\n                if l == 0 {\n                    if yl_shifted != 0 {\n                        // Since yl_shifted is what should be subtracted from out[-1], if non-zero\n                        // then necessarily the precision is a multiple of Limb::WIDTH, and we lose\n                        // one bit, thus the (exact) result is a power of 2 minus 1.\n                        for o in ys.iter_mut() {\n                            *o = Limb::MAX;\n                        }\n                        x_exp.saturating_sub_assign(1);\n                    } else {\n                        // yl_shifted = 0: result is a power of 2.\n                        let (ys_last, ys_init) = ys.split_last_mut().unwrap();\n                        slice_set_zero(ys_init);\n                        *ys_last = LIMB_HIGH_BIT;\n                    }\n                    // No Normalize is needed, no Rounding is needed\n                    return (x_exp, Equal);\n                } else if xs[l - 1] > yl_shifted {\n                    // - cl_shifted is the shifted value c'[l]\n                    // - |x| - |y| >= 1 / 2 * W ^ n\n                    //\n                    // goto SubD1NoLose;\n                    goto_sub_d1_no_lose = true;\n                } else {\n                    // We cannot have xs[l] = yl_shifted since the only way we can exit the while\n                    // loop above is when xs[l] != yl_shifted or l < 0, and the case l < 0 was\n                    // already treated above.\n                    assert!(xs[l - 1] < yl_shifted);\n                    // |x| - |y| <= 1 / 2 * W ^ n - 1 and is exact\n                    goto_sub_d1_lose = true;\n                }\n                continue;\n            }\n        } else if exp_diff >= prec {\n            // The difference of exponents is larger than the precision of all operands, thus the\n            // result is either x or x - 1 ulp, with a possible exact result when x = prec, x = 2 ^\n            // e and y = 1 / 2 * ulp(x)\n            //\n            // - We can't set OUT before since we use ys for rounding...\n            // - Perform rounding: check if out = b or out = x - ulp(x)\n            if exp_diff == prec {\n                // since y is normalized, we need to subtract 1 / 2 * ulp(x)\n                round_bit = 1;\n                // round_bit_2 is the bit of weight 1 / 4 * ulp(x) in y. We assume a limb has at\n                // least 2 bits. If the precision is 1, we read in the unused bits, which should be\n                // zero, and this is what we want.\n                round_bit_2 = ys[nm1] & HALF_LIMB_HIGH_BIT;\n                // We also need sticky_bit_2\n                sticky_bit_2 = ys[nm1] & WIDTH_M2_MASK;\n                let mut k = nm1;\n                while sticky_bit_2 == 0 && k > 0 {\n                    k -= 1;\n                    sticky_bit_2 = ys[k];\n                }\n            } else {\n                round_bit = 0;\n                if exp_diff == prec + 1 {\n                    round_bit_2 = 1;\n                    sticky_bit_2 = ys[nm1] & WIDTH_M1_MASK;\n                    let mut k = nm1;\n                    while sticky_bit_2 == 0 && k > 0 {\n                        k -= 1;\n                        sticky_bit_2 = ys[k];\n                    }\n                } else {\n                    round_bit_2 = 0;\n                    sticky_bit_2 = 1; // since C is non-zero\n                }\n            }\n            // Copy mantissa X to Y\n            ys.copy_from_slice(xs);\n        } else {\n            // case 2 <= exp_diff < prec\n            //\n            // Compute round_bit = Cp and sticky_bit = C'p + 1\n            //\n            // Compute round_bit and round_bit_2 from Y The round bit is bit prec - exp_diff in Y,\n            // assuming the most significant bit of Y is bit 0\n            let x = prec - exp_diff;\n            let mut kx = nm1 - bit_to_limb_count_floor(x);\n            let mut sx_bit = Limb::power_of_2(WIDTH_M1 - (x & Limb::WIDTH_MASK));\n            // the round bit is in ys[kx], at position sx\n            assert!(prec >= exp_diff);\n            round_bit = ys[kx] & sx_bit;\n            // Now compute rxx: since exp_diff >= 2 it always exists in Y\n            sx_bit = if sx_bit == 1 {\n                // rxx is in the next limb\n                kx = kx.checked_sub(1).unwrap();\n                LIMB_HIGH_BIT\n            } else {\n                // round_bit and round_bit_2 are in the same limb\n                sx_bit >> 1\n            };\n            round_bit_2 = ys[kx] & sx_bit;\n            // Now look at the remaining low bits of Y to determine sticky_bit_2\n            sticky_bit_2 = ys[kx] & (sx_bit - 1);\n            while sticky_bit_2 == 0 && kx > 0 {\n                kx -= 1;\n                sticky_bit_2 = ys[kx];\n            }\n            // Clean shifted Y'\n            let mask = shift_bit - 1;\n            let dm = exp_diff & Limb::WIDTH_MASK;\n            let m = bit_to_limb_count_floor(exp_diff);\n            if dm == 0 {\n                assert_ne!(m, 0);\n                // - dm = 0 and m > 0: Just copy\n                // - Subtract the mantissa y from x in out\n                limbs_sub_greater_in_place_right_different_ys0(xs, ys, ys[m] & !mask, m);\n            } else if m == 0 {\n                // dm >=2 and m == 0: just shift\n                assert!(dm >= 2);\n                // Subtract the mantissa y from x in out\n                limbs_sub_shr_same_length_in_place_right_and_ys0(xs, ys, dm, !mask);\n            } else {\n                // - dm > 0 and m > 0: shift and zero\n                // - Subtract the mantissa y from x in out\n                limbs_sub_shr_greater_in_place_right_and_ys0(xs, ys, dm, !mask, m);\n            }\n            // Normalize: we lose at most one bit\n            if !ys[nm1].get_highest_bit() {\n                // - High bit is not set and we have to fix it.\n                // - OUT >= 010000xxx001\n                limbs_slice_shl_in_place(ys, 1);\n                // OUT >= 100000xxx010\n                if round_bit != 0 {\n                    // - Check if Y = -1\n                    // - Since Y == -1, we have to subtract one more\n                    limbs_sub_limb_in_place(ys, shift_bit);\n                    assert!(ys[nm1].get_highest_bit());\n                }\n                // - OUT >= 10000xxx001\n                // - Final exponent -1 since we have shifted the mantissa\n                x_exp.saturating_sub_assign(1);\n                round_bit = round_bit_2;\n                round_bit_2 = sticky_bit_2;\n                // We don't have anymore a valid Yp + 1, but since Oyr >= 100000xxx001, the final\n                // sub can't unnormalize.\n            }\n            assert_eq!(ys[0] & mask, 0);\n        }\n        // only loop when emulating gotos\n        break;\n    }\n    let mut ys_power_of_2;\n    loop {\n        // At this point out contains x - high(y), normalized, and we have to subtract round_bit *\n        // 1/2 ulp(out), round_bit_2 * 1/4 ulp(out), and sticky_bit_2 * 1/8 ulp(out), interpreting\n        // round_bit/round_bit_2/sticky_bit_2 as 1 if non-zero.\n        sticky_bit = round_bit_2 | sticky_bit_2;\n        if round_bit == 0 && sticky_bit == 0 {\n            return (x_exp, Equal);\n        }\n        ys_power_of_2 = limbs_is_power_of_2(ys);\n        if ys_power_of_2 && round_bit != 0 {\n            limbs_sub_limb_in_place(ys, shift_bit);\n            ys[nm1] |= LIMB_HIGH_BIT;\n            x_exp.saturating_sub_assign(1);\n            round_bit = round_bit_2;\n            round_bit_2 = sticky_bit_2;\n            sticky_bit_2 = 0;\n        } else {\n            break;\n        }\n    }\n    // Now if out is a power of two, necessary round_bit = 0, which means the exact result is always\n    // in (pred(ys), ys), and the bounds cannot be attained\n    match rm {\n        Exact => panic!(\"Inexact float subtraction\"),\n        Nearest => {\n            if ys_power_of_2 {\n                assert_eq!(round_bit, 0);\n                // Since we are at the end of the binade, we have in fact round_bit = round_bit_2\n                // and sticky_bit = sticky_bit_2\n                round_bit = round_bit_2;\n                sticky_bit = sticky_bit_2;\n            }\n            if (prec == 1 || ys[0] & shift_bit == 0 || round_bit == 0)\n                && (sticky_bit == 0 || round_bit == 0)\n            {\n                (x_exp, Greater)\n            } else {\n                limbs_sub_limb_in_place(ys, shift_bit);\n                if ys_power_of_2 {\n                    // deal with cancellation\n                    ys[nm1] |= LIMB_HIGH_BIT;\n                    x_exp.saturating_sub_assign(1);\n                }\n                (x_exp, Less)\n            }\n        }\n        Floor | Down => {\n            limbs_sub_limb_in_place(ys, shift_bit);\n            if ys_power_of_2 {\n                // deal with cancellation\n                ys[nm1] |= LIMB_HIGH_BIT;\n                x_exp.saturating_sub_assign(1);\n            }\n            (x_exp, Less)\n        }\n        Ceiling | Up => (x_exp, Greater),\n    }\n}\n\n// This is mpfr_cmp2 from cmp2.c, MPFR 4.2.0, returning `cancel` along with `sign`.\npub fn exponent_shift_compare<'a>(\n    mut xs: &'a [Limb],\n    mut x_exp: i64,\n    mut x_prec: u64,\n    mut ys: &'a [Limb],\n    mut y_exp: i64,\n    mut y_prec: u64,\n) -> (Ordering, u64) {\n    // x == y should not happen, since cmp2 is called only from agm (with different variables) and\n    // from sub1 (if b=c, then sub1sp would be called instead). So, no need for a particular\n    // optimization here.\n    //\n    // the cases b=0 or c=0 are also treated apart in agm and sub (which calls sub1)\n    let sdiff_exp = x_exp - y_exp;\n    let mut sign;\n    let mut diff_exp;\n    // index of the most significant limb of x and y\n    let mut xi = bit_to_limb_count_floor(x_prec - 1);\n    let mut yi = bit_to_limb_count_floor(y_prec - 1);\n    let mut xi_done = false;\n    let mut yi_done = false;\n    let mut res = 0;\n    if sdiff_exp >= 0 {\n        sign = Greater; // assumes |x| > |y|; will be changed if not.\n        diff_exp = u64::wrapping_from(sdiff_exp);\n        let mut cancel = 0;\n        // If diff_exp != 0, i.e. diff_exp > 0, then |x| > |y|. Otherwise...\n        if diff_exp == 0 {\n            // Skip the identical most significant limbs, adding Limb::WIDTH to the number of\n            // canceled bits at each iteration.\n            while !xi_done && !yi_done && xs[xi] == ys[yi] {\n                if xi == 0 {\n                    xi_done = true;\n                } else {\n                    xi -= 1;\n                }\n                if yi == 0 {\n                    yi_done = true;\n                } else {\n                    yi -= 1;\n                }\n                res += Limb::WIDTH;\n            }\n            if xi_done {\n                // |x| = |y|\n                if yi_done {\n                    return (Equal, cancel);\n                }\n                // x has been read entirely, but not y. Thus |x| <= |y|. Swap xs and ys, and take\n                // the opposite sign for the symmetric case below (simulating a swap). Note:\n                // \"yi_done = true;\" is necessary to enter the following \"if\" (probably less\n                // confusing than a \"goto\").\n                swap(&mut xs, &mut ys);\n                swap(&mut xi, &mut yi);\n                swap(&mut x_exp, &mut y_exp);\n                swap(&mut x_prec, &mut y_prec);\n                xi_done = yi_done;\n                yi_done = true;\n                sign = Less;\n            }\n            if yi_done {\n                // y discards exactly the upper part of x\n                assert!(!xi_done);\n                // Skip null limbs of x (= non-represented null limbs of y), adding Limb::WIDTH to\n                // the number of canceled bits at each iteration.\n                while xs[xi] == 0 {\n                    // |x| = |y|\n                    if xi == 0 {\n                        xi_done = true;\n                    } else {\n                        xi -= 1;\n                    }\n                    if xi_done {\n                        return (Equal, cancel);\n                    }\n                    res += Limb::WIDTH;\n                }\n                let z = LeadingZeros::leading_zeros(xs[xi]);\n                // xs[xn] != 0\n                cancel = res + z;\n                return (sign, cancel);\n            }\n            assert!(!xi_done);\n            assert!(!yi_done);\n            assert!(xs[xi] != ys[yi]);\n            // |x| != |y|. If |x| < |y|: swap xs and ys, and take the opposite sign.\n            if xs[xi] < ys[yi] {\n                swap(&mut xs, &mut ys);\n                swap(&mut xi, &mut yi);\n                swap(&mut xi_done, &mut yi_done);\n                swap(&mut x_exp, &mut y_exp);\n                swap(&mut x_prec, &mut y_prec);\n                sign = Less;\n            }\n        }\n    } else {\n        // We necessarily have |x| < |y|.\n        sign = Less;\n        diff_exp = u64::exact_from(-sdiff_exp);\n        swap(&mut xs, &mut ys);\n        swap(&mut xi, &mut yi);\n        swap(&mut x_exp, &mut y_exp);\n        swap(&mut x_prec, &mut y_prec);\n    }\n    // Now we have removed the identical upper limbs of x and y (when diff_exp = 0), and after the\n    // possible swap, we have |x| > |y|. The value diff_exp = EXP(x) - EXP(y) can be regarded as the\n    // number of leading zeros of y, when aligned with x.\n    //\n    // When a limb of y is read from memory, the part that is not taken into account for the\n    // operation with a limb xs[xn] of x will be put in lasty, shifted to the leftmost part (for\n    // alignment with x):\n    // ```\n    // [-------- xs[xn] --------][------- xs[xn-1] -------]\n    // [-- old_lasty --][-------- ys[yn] --------]\n    //                           [-- new_lastc --]\n    // ```\n    // Note: if diff_exp == 0, then lasty will always remain 0.\n    let mut lasty = 0;\n    // Compute the next limb difference, which cannot be 0 (dif >= 1).\n    let mut yy;\n    if diff_exp < Limb::WIDTH {\n        yy = ys[yi] >> diff_exp;\n        if diff_exp != 0 {\n            lasty = ys[yi] << (Limb::WIDTH - diff_exp);\n        }\n        if yi == 0 {\n            yi_done = true;\n        } else {\n            yi -= 1;\n        }\n    } else {\n        yy = 0;\n        // remove Limb::WIDTH leading zeros\n        diff_exp -= Limb::WIDTH;\n    }\n    // no borrow out in subtraction below\n    assert!(xs[xi] >= yy);\n    let mut dif = xs[xi] - yy;\n    if xi == 0 {\n        xi_done = true;\n    } else {\n        xi -= 1;\n    }\n    assert!(dif >= 1);\n    let mut high_dif = false;\n    // The current difference, here and later, is expressed under the form [high_dif][dif], where\n    // high_dif is 0 or 1, and dif is a limb. Here, since we have computed a difference of limbs\n    // (with x >= y), high_dif = 0.\n    //\n    // One needs to accumulate canceled bits for the remaining case where x and y are close to each\n    // other due to a long borrow propagation:\n    // ```\n    //   x = [common part]1000...000[low(x)]\n    //   y = [common part]0111...111[low(y)]\n    // ```\n    // After eliminating the common part above, we have computed a difference of the most\n    // significant parts, which has been stored in [high_dif][dif] with high_dif = 0. We will loop\n    // as long as the currently computed difference [high_dif][dif] = 1 (it is >= 1 by\n    // construction). The computation of the difference will be:\n    // ```\n    //    1xxx...xxx\n    //   - yyy...yyy\n    // ```\n    // where the leading 1 before xxx...xxx corresponds to [high_dif][dif] at the beginning of the\n    // loop. We will exit the loop also when y has entirely been taken into account as cancellation\n    // is no longer possible in this case (it is no longer possible to cancel the leading 1). Note:\n    // We can enter the loop only with diff_exp = 0 (with a non-empty common part, partly or\n    // entirely removed) or with diff_exp = 1 (with an empty common part). Indeed, if diff_exp > 1,\n    // then no limbs have been skipped, so that xs[xn] had its MSB equal to 1 and the most two\n    // significant bits of yy are 0, which implies that dif > 1.\n    while (!yi_done || lasty != 0) && !high_dif && dif == 1 {\n        // Since we consider the next limb, we assume a cancellation of Limb::WIDTH (the new\n        // exponent of the difference now being the one of the MSB of the next limb). But if the\n        // leading 1 remains 1 in the difference (i.e. high_dif = 1 at the end of the loop), then we\n        // will need to decrease res.\n        res += Limb::WIDTH;\n        // - See comment before the loop\n        // - Next limb of x or non-represented 0\n        assert!(diff_exp <= 1);\n        let xx = if xi_done {\n            0\n        } else {\n            let r = xs[xi];\n            if xi == 0 {\n                xi_done = true;\n            } else {\n                xi -= 1;\n            }\n            r\n        };\n        if yi_done {\n            yy = lasty;\n            lasty = 0;\n        } else if diff_exp == 0 {\n            yy = ys[yi];\n            if yi == 0 {\n                yi_done = true;\n            } else {\n                yi -= 1;\n            }\n        } else {\n            assert_eq!(diff_exp, 1);\n            assert!(lasty == 0 || lasty == LIMB_HIGH_BIT);\n            yy = lasty + (ys[yi] >> 1);\n            lasty = ys[yi] << (Limb::WIDTH - 1);\n            if yi == 0 {\n                yi_done = true;\n            } else {\n                yi -= 1;\n            }\n        }\n        dif = xx.wrapping_sub(yy);\n        high_dif = xx >= yy;\n    }\n    // Now, y has entirely been taken into account or [high_dif][dif] > 1. In any case,\n    // [high_dif][dif] >= 1 by construction. First, we determine the currently number of canceled\n    // bits, corresponding to the exponent of the current difference. The trailing bits of y, if\n    // any, can still decrease the exponent of the difference when [high_dif][dif] is a power of\n    // two, but since [high_dif][dif] > 1 in this case, by not more than 1.\n    if high_dif {\n        // high_dif == 1 See comment at the beginning of the above loop.\n        res = res.checked_sub(1).unwrap();\n        // Terminate if [high_dif][dif] is not a power of two.\n        if dif != 0 {\n            return (sign, res);\n        }\n    } else {\n        // high_dif == 0\n        assert!(dif >= 1); // [high_dif][dif] >= 1\n        res += LeadingZeros::leading_zeros(dif);\n        // Terminate if [high_dif][dif] is not a power of two.\n        if !dif.is_power_of_2() {\n            return (sign, res);\n        }\n    }\n    // Now, the result will be res + (low(x) < low(y)).\n    //\n    // If y has entirely been taken into account, it can no longer modify the current result.\n    if yi_done && lasty == 0 {\n        return (sign, res);\n    }\n    if !xi_done {\n        for &x in xs[..=xi].iter().rev() {\n            if diff_exp >= Limb::WIDTH {\n                diff_exp -= Limb::WIDTH;\n                assert_eq!(yy, 0);\n            } else if yi_done {\n                yy = lasty;\n                lasty = 0;\n            } else if diff_exp == 0 {\n                yy = ys[yi];\n                if yi == 0 {\n                    yi_done = true;\n                } else {\n                    yi -= 1;\n                }\n            } else {\n                assert!((1..Limb::WIDTH).contains(&diff_exp));\n                yy = lasty + (ys[yi] >> diff_exp);\n                lasty = ys[yi] << (Limb::WIDTH - diff_exp);\n                if yi == 0 {\n                    yi_done = true;\n                } else {\n                    yi -= 1;\n                }\n            }\n            if x != yy {\n                return (sign, if x < yy { res + 1 } else { res });\n            }\n        }\n    }\n    // x has entirely been read. Determine whether the trailing part of y is non-zero.\n    if lasty != 0 || !slice_test_zero(&ys[..=yi]) {\n        res += 1;\n    }\n    (sign, res)\n}\n\nfn sub_float_significands_general<'a>(\n    out: &mut [Limb],\n    mut xs: &'a [Limb],\n    mut x_exp: i32,\n    mut x_prec: u64,\n    mut ys: &'a [Limb],\n    mut y_exp: i32,\n    mut y_prec: u64,\n    out_prec: u64,\n    mut rm: RoundingMode,\n) -> (i32, Ordering, bool) {\n    let mut xs_len = xs.len();\n    let mut ys_len = ys.len();\n    let out_len = out.len();\n    let mut add_exp = false;\n    let (sign, cancel) =\n        exponent_shift_compare(xs, i64::from(x_exp), x_prec, ys, i64::from(y_exp), y_prec);\n    if sign == Equal {\n        // x == y. Return exact number 0. Setting the most-significant limb to 0 is a sufficient\n        // signal to the caller that the entire output is 0, since in every other case the precision\n        // of the output is the same as the precision of the inputs, and the most-significant limb\n        // is therefore nonzero.\n        *out.last_mut().unwrap() = 0;\n        return (0, Equal, false);\n    }\n    // sign != 0, so that cancel has a valid value.\n    //\n    // If subtraction: sign(out) = sign * sign(x) If addition: sign(out) = sign of the larger\n    // argument in absolute value.\n    //\n    // Both cases can be simplified in:\n    // ```\n    // if (sign>0)\n    //    if addition: sign(out) = sign * sign(x) = sign(x)\n    //    if subtraction, x is greater, so sign(out) = sign(x)\n    // else\n    //    if subtraction, sign(out) = -sign(x)\n    //    if addition, sign(out) = sign(y) (since y is greater)\n    //      But if it is an addition, sign(x) and sign(y) are opposed!\n    //      So sign(out) = -sign(x)\n    // ```\n    let neg = sign == Less;\n    if neg {\n        // swap x and y so that |x| > |y|\n        swap(&mut xs, &mut ys);\n        swap(&mut xs_len, &mut ys_len);\n        swap(&mut x_exp, &mut y_exp);\n        swap(&mut x_prec, &mut y_prec);\n        rm.neg_assign();\n    }\n    let exp_diff = u64::exact_from(x_exp - y_exp);\n    // Check if y is too small.\n    let mut inexact = 0;\n    if max(out_prec, x_prec) + 2 <= exp_diff {\n        // Remember, we can't have an exact result!\n        // ```\n        //   A.AAAAAAAAAAAAAAAAA\n        // = B.BBBBBBBBBBBBBBB\n        //  -                     C.CCCCCCCCCCCCC\n        // A = S*ABS(B) +/- ulp(a)\n        // ```\n        assert_ne!(rm, Exact, \"Inexact float subtraction\");\n        let mut exp_a = x_exp;\n        let increment_exp;\n        (inexact, increment_exp) = round_helper_even(out, out_prec, xs, x_prec, rm);\n        if increment_exp {\n            exp_a += 1;\n        }\n        if inexact == 0 && rm != Down && rm != Floor {\n            // out = x, but the exact value of x - y is a bit below. Then, except for directed\n            // rounding similar to toward zero and before overflow checking: a is the correctly\n            // rounded value and since |x| - |y| < |out|, the ternary value is given by the sign of\n            // out.\n            inexact = 1;\n        } else if inexact != 0 && inexact != MPFR_EVEN_INEX {\n            // ```\n            //   O.OOOOOOOOOOOOOO\n            // = X.XXXXXXXXXXXXXXX\n            //  -                   Y.YYYYYYYYYYYYY\n            // ```\n            //\n            // It isn't exact, so PREC(x) > PREC(out) and the last PREC(x)-PREC(out) bits of x are\n            // not all zeros. Subtracting y from x will not have an effect on the rounding except in\n            // case of a midpoint in the round-to-nearest mode, when the even rounding was done away\n            // from zero instead of toward zero.\n            //\n            // In case of even rounding:\n            // ```\n            //   1.BBBBBBBBBBBBBx10\n            // -                     1.CCCCCCCCCCCC\n            // = 1.BBBBBBBBBBBBBx01  Rounded to PREC(x)\n            // = 1.BBBBBBBBBBBBBx    Nearest / Rounded to PREC(out)\n            // ```\n            //\n            // Set gives:\n            // ```\n            //   1.BBBBBBBBBBBBB0   if inexact == EVEN_INEX  (x == 0)\n            //   1.BBBBBBBBBBBBB1+1 if inexact == -EVEN_INEX (x == 1)\n            // ````\n            // which means we get a wrong rounded result if x == 1, i.e. inexact == MPFR_EVEN_INEX\n            // (for positive numbers).\n            //\n            // Nothing to do.\n        } else {\n            // We need to take the value preceding |out|. We can't use mpfr_nexttozero due to a\n            // possible out-of-range exponent. But this will allow us to have more specific code.\n            limbs_sub_limb_in_place(out, Limb::power_of_2(limb_to_bit_count(out_len) - out_prec));\n            let last_out = out.last_mut().unwrap();\n            if !last_out.get_highest_bit() {\n                exp_a.saturating_sub_assign(1);\n                // The following is valid whether out_len = 1 or out_len > 1.\n                *last_out |= LIMB_HIGH_BIT;\n            }\n            inexact = -1;\n        }\n        return (exp_a, inexact.sign(), neg);\n    }\n    // Reserve a space to store x aligned with the result, i.e. shifted by (-cancel) % Limb::WIDTH\n    // to the right\n    let shift_x = cancel.neg_mod_power_of_2(Limb::LOG_WIDTH);\n    let cancel1 = bit_to_limb_count_floor(cancel + shift_x);\n    let mut shifted_x;\n    // the `high cancel1` limbs from x should not be taken into account\n    let xs = if shift_x == 0 {\n        // no need of an extra space\n        xs\n    } else {\n        shifted_x = vec![0; xs_len + 1];\n        let (shifted_head, shifted_tail) = shifted_x.split_first_mut().unwrap();\n        *shifted_head = limbs_shr_to_out(shifted_tail, xs, shift_x);\n        xs_len += 1;\n        &shifted_x\n    };\n    // Reserve a space to store y aligned with the result, i.e. shifted by (diff_exp - cancel) %\n    // Limb::WIDTH to the right\n    let shift_y = exp_diff\n        .mod_power_of_2(Limb::LOG_WIDTH)\n        .mod_power_of_2_sub(cancel.mod_power_of_2(Limb::LOG_WIDTH), Limb::LOG_WIDTH);\n    assert!(shift_y < Limb::WIDTH);\n    let mut shifted_y;\n    let ys = if shift_y == 0 {\n        ys\n    } else {\n        shifted_y = vec![0; ys_len + 1];\n        let (shifted_head, shifted_tail) = shifted_y.split_first_mut().unwrap();\n        *shifted_head = limbs_shr_to_out(shifted_tail, ys, shift_y);\n        ys_len += 1;\n        &shifted_y\n    };\n    // here we have shift_y = (diff_exp - cancel) % Limb::WIDTH, 0 <= shift_y < Limb::WIDTH, thus we\n    // want cancel2 = ceil((cancel - diff_exp) / Limb::WIDTH)\n    let cancel2 = if cancel >= exp_diff {\n        // Note that cancel is signed and will be converted to mpfr_uexp_t (type of diff_exp) in the\n        // expression below, so that this will work even if cancel is very large and diff_exp = 0.\n        (i128::from(cancel) - i128::from(exp_diff) + i128::wrapping_from(IWIDTH_M1))\n            >> Limb::LOG_WIDTH\n    } else {\n        -((i128::from(exp_diff) - i128::from(cancel)) >> Limb::LOG_WIDTH)\n    };\n    // The high cancel2 limbs from x should not be taken into account\n    //\n    // ```\n    //                 ap[an-1]        ap[0]\n    //             <----------------+-----------|---->\n    //             <----------PREC(a)----------><-sh->\n    // cancel1\n    // limbs        bp[bn-cancel1-1]\n    // <--...-----><----------------+-----------+----------->\n    //  cancel2\n    //  limbs       cp[cn-cancel2-1]                                    cancel2 >= 0\n    //    <--...--><----------------+----------------+---------------->\n    //                (-cancel2)                                        cancel2 < 0\n    //                   limbs      <----------------+---------------->\n    // ```\n    //\n    // First part: put in out[0..out_len - 1] the value of high(x) - high(y), where high(x) consists\n    // of the high out_len + cancel1 limbs of x, and high(y) consists of the high out_len + cancel2\n    // limbs of y.\n    //\n    // Copy high(x) into out\n    if out_len + cancel1 <= xs_len {\n        // ```\n        // out: <----------------+-----------|---->\n        // xs:  <----------------------------------------->\n        // ```\n        let xs_hi = &xs[xs_len - out_len - cancel1..];\n        out.copy_from_slice(&xs_hi[..out_len]);\n    } else {\n        // ```\n        // out: <----------------+-----------|---->\n        // xs:  <------------------------->\n        // ```\n        if cancel1 < xs_len {\n            let (out_lo, out_hi) = out.split_at_mut(out_len + cancel1 - xs_len);\n            slice_set_zero(out_lo);\n            out_hi.copy_from_slice(&xs[..xs_len - cancel1]);\n        }\n    }\n    // subtract high(y)\n    if i128::wrapping_from(out_len) + cancel2 > 0 {\n        if cancel2 >= 0 {\n            let cancel2 = usize::exact_from(cancel2);\n            if out_len + cancel2 <= ys_len {\n                // ```\n                // out: <----------------------------->\n                // ys:  <----------------------------------------->\n                // ```\n                let ys_hi = &ys[ys_len - out_len - cancel2..];\n                limbs_sub_same_length_in_place_left(out, &ys_hi[..out_len]);\n            } else {\n                // ```\n                // out: <---------------------------->\n                // ys:  <------------------------->\n                // ```\n                if ys_len > cancel2 {\n                    limbs_sub_same_length_in_place_left(\n                        &mut out[out_len + cancel2 - ys_len..],\n                        &ys[..ys_len - cancel2],\n                    );\n                }\n            }\n        } else {\n            // cancel2 < 0\n            let neg_cancel2 = usize::exact_from(-cancel2);\n            let (out_lo, out_hi) = out.split_at_mut(out_len - neg_cancel2);\n            let borrow = if out_len - neg_cancel2 <= ys_len {\n                // ```\n                // a: <----------------------------->\n                // c: <----------------------------->\n                // ```\n                limbs_sub_same_length_in_place_left(out_lo, &ys[ys_len - (out_len - neg_cancel2)..])\n            } else {\n                // ```\n                // a: <---------------------------->\n                // c: <---------------->\n                // ```\n                let len = out_lo.len();\n                limbs_sub_same_length_in_place_left(&mut out_lo[len - ys_len..], ys)\n            };\n            limbs_sub_limb_in_place(out_hi, Limb::from(borrow));\n        }\n    }\n    // Now perform rounding\n    let shift = limb_to_bit_count(out_len) - out_prec;\n    let shift_bit = Limb::power_of_2(shift);\n    let shift_mask = shift_bit - 1;\n    // Last unused bits from out\n    let out_head = out.first_mut().unwrap();\n    let carry = *out_head & shift_mask;\n    *out_head -= carry;\n    let mut cmp_low = 0;\n    let mut goto_truncate = false;\n    let mut goto_end_of_sub = false;\n    if rm == Nearest {\n        if shift != 0 {\n            let half_shift_bit = shift_bit >> 1;\n            // Can decide except when carry = 2 ^ (sh - 1) [middle] or carry = 0 [truncate, but\n            // cannot decide inexact flag]\n            if carry > half_shift_bit {\n                if limbs_slice_add_limb_in_place(out, shift_bit) {\n                    // result is a power of 2: 11111111111111 + 1 = 1000000000000000\n                    out[out_len - 1] = LIMB_HIGH_BIT;\n                    add_exp = true;\n                }\n                // result larger than exact value\n                inexact = 1;\n                goto_truncate = true;\n            } else if carry != 0 && carry < half_shift_bit {\n                inexact = -1; // result if smaller than exact value\n                goto_truncate = true;\n            } else {\n                // now carry = 2 ^ (sh - 1), in which case cmp_low = 2, or carry = 0, in which case\n                // cmp_low = 0\n                cmp_low = if carry == 0 { 0 } else { 2 };\n            }\n        }\n    } else if carry != 0 {\n        if rm == Floor || rm == Down || rm == Exact {\n            inexact = -1;\n        } else {\n            if limbs_slice_add_limb_in_place(out, shift_bit) {\n                // result is a power of 2: 11111111111111 + 1 = 1000000000000000\n                out[out_len - 1] = LIMB_HIGH_BIT;\n                add_exp = true;\n            }\n            // result larger than exact value\n            inexact = 1;\n        }\n        goto_truncate = true;\n    }\n    if !goto_truncate {\n        // We have to consider the low (xs_len - (out_len + cancel1)) limbs from x, and the (ys_len\n        // - (out_len + cancel2)) limbs from y.\n        xs_len.saturating_sub_assign(out_len + cancel1);\n        let ys_len0 = ys_len;\n        ys_len = usize::saturating_from(\n            i128::wrapping_from(ys_len) - (i128::wrapping_from(out_len) + cancel2),\n        );\n        // For rounding to nearest, we couldn't conclude up to here in the following cases:\n        // - shift = 0, then cmp_low = 0: we can either truncate, subtract one ulp or add one ulp:\n        //   -1 ulp < low(x) - low(y) < 1 ulp\n        // - shift > 0 but the low `shift` bits from high(x) - high(y) equal 2 ^ (shift - 1): -0.5\n        //   ulp <= -1 / 2 ^ shift < low(x) - low(y) - 0.5 < 1 / 2 ^ shift <= 0.5 ulp we can't\n        //   decide the rounding, in that case cmp_low = 2: either we truncate and flag = -1, or we\n        //   add one ulp and flag = 1\n        // - The low shift > 0 bits from high(x)-high(y) equal 0: we know we have to truncate but we\n        //   can't decide the ternary value, here cmp_low = 0: -0.5 ulp <= -1 / 2 ^ shift < low(x)\n        //   -low(y) < 1 / 2 ^ shift <= 0.5 ulp we always truncate and inexact can be any of -1, 0,\n        //   1\n        // - Note: here ys_len might exceed ys_len0, in which case we consider a zero limb\n        let mut k: i32 = 0;\n        while xs_len != 0 || ys_len != 0 {\n            // - If cmp_low < 0, we know low(x) - low(y) < 0\n            // - If cmp_low > 0, we know low(x) - low(y) > 0 (more precisely if cmp_low = 2, low(x)\n            //   - low(y) = 0.5 ulp so far)\n            // - If cmp_low = 0, so far low(x) - low(y) = 0\n            // - get next limbs\n            let mut xx = if xs_len != 0 {\n                xs_len -= 1;\n                xs[xs_len]\n            } else {\n                0\n            };\n            let mut yy = if ys_len != 0 && {\n                let c = ys_len <= ys_len0;\n                ys_len -= 1;\n                c\n            } {\n                ys[ys_len]\n            } else {\n                0\n            };\n            // cmp_low compares low(x) and low(y)\n            if cmp_low == 0 {\n                // case 1 or 3\n                cmp_low = match xx.cmp(&yy) {\n                    Greater => 1,\n                    Less => -2 + k,\n                    Equal => 0,\n                };\n            }\n            // Case 1 for k=0 splits into 7 subcases:\n            // - 1a: xx > yy + half\n            // - 1b: xx = yy + half\n            // - 1c: 0 < xx - yy < half\n            // - 1d: xx = yy\n            // - 1e: -half < xx - yy < 0\n            // - 1f: xx - yy = -half\n            // - 1g: xx - yy < -half\n            //\n            // Case 2 splits into 3 subcases:\n            // - 2a: xx > yy\n            // - 2b: xx = yy\n            // - 2c: xx < yy\n            //\n            // Case 3 splits into 3 subcases:\n            // - 3a: xx > yy\n            // - 3b: xx = yy\n            // - 3c: xx < yy\n            //\n            // The case rounding to nearest with sh=0 is special since one couldn't subtract above\n            // 1/2 ulp in the trailing limb of the result\n            if rm == Nearest && shift == 0 && k == 0 {\n                // case 1 for k = 0\n                // - add one ulp if xx > yy + half\n                // - truncate if yy - half < xx < yy + half\n                // - sub one ulp if xx < yy - half\n                if cmp_low < 0 {\n                    // - xx < yy: -1 ulp < low(b) - low(c) < 0,\n                    // - cases 1e, 1f and 1g\n                    if yy >= LIMB_HIGH_BIT {\n                        yy -= LIMB_HIGH_BIT;\n                    } else {\n                        // since xx < yy < half, xx + half < 2 * half\n                        xx += LIMB_HIGH_BIT;\n                    }\n                    // Now we have xx < yy + half: we have to subtract one ulp if xx < yy, and\n                    // truncate if xx > yy\n                } else {\n                    // xx >= yy, cases 1a to 1d\n                    if yy < LIMB_HIGH_BIT {\n                        yy += LIMB_HIGH_BIT;\n                    } else {\n                        // since xx >= yy >= half, xx - half >= 0\n                        xx -= LIMB_HIGH_BIT;\n                    }\n                    // Now we have xx > yy - half: we have to add one ulp if xx > yy, and truncate\n                    // if xx < yy\n                    if cmp_low > 0 {\n                        cmp_low = 2;\n                    }\n                }\n            }\n            match cmp_low.sign() {\n                Less => {\n                    // low(x) - low(y) < 0: either truncate or subtract one ulp\n                    match rm {\n                        Floor | Down => {\n                            limbs_sub_limb_in_place(out, shift_bit);\n                            inexact = -1;\n                            goto_end_of_sub = true;\n                        }\n                        Ceiling | Up | Exact => {\n                            inexact = 1;\n                            goto_truncate = true;\n                        }\n                        Nearest => {\n                            // - If cmp_low < 0 and xx > yy, then -0.5 ulp < low(x) - low(y) < 0,\n                            //   whatever the value of shift.\n                            // - If shift > 0, then cmp_low < 0 implies that the initial neglected\n                            //   shift bits were 0 (otherwise cmp_low = 2 initially), thus the\n                            //   weight of the new bits is less than 0.5 ulp too.\n                            // - If k > 0 (and shift = 0) this means that either the first neglected\n                            //   limbs xx and yy were equal (thus cmp_low was 0 for k = 0), or we\n                            //   had xx - yy = -0.5 ulp or 0.5 ulp.\n                            // - The last case is not possible here since we would have cmp_low > 0\n                            //   which is sticky.\n                            // - In the first case (where we have cmp_low = -1), we truncate,\n                            //   whereas in the 2nd case we have cmp_low = -2 and we subtract one\n                            //   ulp.\n                            if xx > yy || shift > 0 || cmp_low == -1 {\n                                // - -0.5 ulp < low(b)-low(c) < 0,\n                                // - xx > yy corresponds to cases 1e and 1f1\n                                // - shift > 0 corresponds to cases 3c and 3b3\n                                // - cmp_low = -1 corresponds to case 1d3 (also 3b3)\n                                inexact = 1;\n                                goto_truncate = true;\n                            } else if xx < yy {\n                                // Here shift = 0 and low(x) - low(y) < -0.5 ulp, this corresponds\n                                // to cases 1g and 1f3\n                                //\n                                limbs_sub_limb_in_place(out, shift_bit);\n                                inexact = -1;\n                                goto_end_of_sub = true;\n                            }\n                            // The only case where we can't conclude is shift = 0 and xx = yy, i.e.,\n                            // we have low(x)\n                            // - low(y) = -0.5 ulp (up to now), thus we don't know if we must\n                            //   truncate or\n                            // subtract one ulp. Note: for shift = 0 we can't have low(x) - low(y) =\n                            // -0.5 ulp up to now, since low(x) - low(y) > 1 / 2 ^ shift\n                        }\n                    }\n                }\n                Greater => {\n                    // 0 < low(x) - low(y): either truncate or add one ulp\n                    match rm {\n                        Floor | Down | Exact => {\n                            inexact = -1;\n                            goto_truncate = true;\n                        }\n                        Ceiling | Up => {\n                            if limbs_slice_add_limb_in_place(out, shift_bit) {\n                                // result is a power of 2: 11111111111111 + 1 = 1000000000000000\n                                out[out_len - 1] = LIMB_HIGH_BIT;\n                                add_exp = true;\n                            }\n                            // result larger than exact value\n                            inexact = 1;\n                            goto_truncate = true;\n                        }\n                        Nearest => {\n                            match xx.cmp(&yy) {\n                                Greater => {\n                                    // If sh = 0, then xx > yy means that low(x) - low(y) > 0.5 ulp,\n                                    // and similarly when cmp_low = 2.\n                                    if cmp_low == 2 {\n                                        // cases 1a, 1b1, 2a and 2b1\n                                        //\n                                        // shift > 0 and cmp_low > 0: this implies that the `shift`\n                                        // initial neglected bits were 0, and the remaining low(x) -\n                                        // low(y) > 0, but its weight is less than 0.5 ulp\n                                        if limbs_slice_add_limb_in_place(out, shift_bit) {\n                                            // result is a power of 2: 11111111111111 + 1 =\n                                            // 1000000000000000\n                                            out[out_len - 1] = LIMB_HIGH_BIT;\n                                            add_exp = true;\n                                        }\n                                        // result larger than exact value\n                                        inexact = 1;\n                                    } else {\n                                        // 0 < low(x) - low(y) < 0.5 ulp, this corresponds to cases\n                                        // 3a, 1d1 and 3b1\n                                        inexact = -1;\n                                    }\n                                    goto_truncate = true;\n                                }\n                                Less => {\n                                    // 0 < low(x) - low(y) < 0.5 ulp, cases 1c, 1b3, 2b3 and 2c\n                                    inexact = -1;\n                                    goto_truncate = true;\n                                }\n                                Equal => {\n                                    // The only case where we can't conclude is xx = yy, i.e.,\n                                    // low(x) - low(y) = 0.5 ulp (up to now), thus we don't know if\n                                    // we must truncate or add one ulp.\n                                }\n                            }\n                        }\n                    }\n                }\n                _ => {}\n            }\n            // After k = 0, we cannot conclude in the following cases, we split them according to\n            // the values of xx and yy for k = 1:\n            // ```\n            // 1b. shift = 0 and cmp_low = 1 and xx-yy = half [around 0.5 ulp]\n            //     1b1. xx > yy: add one ulp, inex = 1\n            //     1b2: xx = yy: cannot conclude\n            //     1b3: xx < yy: truncate, inex = -1\n            // 1d. shift = 0 and cmp_low = 0 and xx-yy = 0 [around 0]\n            //     1d1: xx > yy: truncate, inex = -1\n            //     1d2: xx = yy: cannot conclude\n            //     1d3: xx < yy: truncate, inex = +1\n            // 1f. shift = 0 and cmp_low = -1 and xx-yy = -half [around -0.5 ulp]\n            //     1f1: xx > yy: truncate, inex = +1\n            //     1f2: xx = yy: cannot conclude\n            //     1f3: xx < yy: sub one ulp, inex = -1\n            // 2b. shift > 0 and cmp_low = 2 and xx=yy [around 0.5 ulp]\n            //     2b1. xx > yy: add one ulp, inex = 1\n            //     2b2: xx = yy: cannot conclude\n            //     2b3: xx < yy: truncate, inex = -1\n            // 3b. shift > 0 and cmp_low = 0 [around 0]\n            //     3b1. xx > yy: truncate, inex = -1\n            //     3b2: xx = yy: cannot conclude\n            //     3b3: xx < yy: truncate, inex = +1\n            // ```\n            if goto_truncate || goto_end_of_sub {\n                break;\n            }\n            k = 1;\n        }\n        if !goto_truncate && !goto_end_of_sub {\n            inexact = if rm == Nearest && cmp_low != 0 {\n                // Even rounding rule\n                if (out[0] >> shift) & 1 != 0 {\n                    if cmp_low < 0 {\n                        limbs_sub_limb_in_place(out, shift_bit);\n                        goto_end_of_sub = true;\n                        -1\n                    } else {\n                        if limbs_slice_add_limb_in_place(out, shift_bit) {\n                            // result is a power of 2: 11111111111111 + 1 = 1000000000000000\n                            out[out_len - 1] = LIMB_HIGH_BIT;\n                            add_exp = true;\n                        }\n                        // result larger than exact value\n                        1\n                    }\n                } else if cmp_low > 0 {\n                    -1\n                } else {\n                    1\n                }\n            } else {\n                0\n            };\n        }\n    }\n    let last_out = &mut out[out_len - 1];\n    if !goto_end_of_sub && *last_out >> WIDTH_M1 == 0 {\n        // case 1 - varepsilon\n        *last_out = LIMB_HIGH_BIT;\n        add_exp = true;\n    }\n    // We have to set MPFR_EXP(out) to MPFR_EXP(x) - cancel + diff_exp, taking care of\n    // underflows/overflows in that computation, and of the allowed exponent range\n    let exp_a = if cancel != 0 {\n        x_exp = i32::saturating_from(i128::from(x_exp) - i128::from(cancel));\n        if add_exp {\n            x_exp.saturating_add_assign(1);\n        }\n        x_exp\n    } else {\n        // cancel = 0: MPFR_EXP(out) <- MPFR_EXP(x) + diff_exp\n        //\n        // In case cancel = 0, diff_exp can still be 1, in case x is just below a power of two, y is\n        // very small, prec(out) < prec(x), and rnd = away or nearest\n        if add_exp {\n            x_exp.saturating_add_assign(1);\n        }\n        x_exp\n    };\n    // check that result is msb-normalized\n    assert!(last_out.get_highest_bit());\n    (exp_a, inexact.sign(), neg)\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/gcd/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2009, 2016 William Hart\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::Small;\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_add_to_out_aliased, limbs_slice_add_greater_in_place_left,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::div_exact::limbs_div_exact_to_out;\nuse crate::natural::arithmetic::div_mod::{\n    limbs_div_limb_to_out_mod, limbs_div_mod_qs_to_out_rs_to_ns,\n};\nuse crate::natural::arithmetic::gcd::half_gcd::{\n    GcdSubdivideStepContext, HalfGcdMatrix, HalfGcdMatrix1, extract_number,\n    limbs_gcd_subdivide_step, limbs_half_gcd, limbs_half_gcd_2,\n    limbs_half_gcd_matrix_1_mul_inverse_vector, limbs_half_gcd_matrix_1_mul_vector,\n    limbs_half_gcd_matrix_adjust, limbs_half_gcd_matrix_init_scratch_len,\n    limbs_half_gcd_scratch_len,\n};\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::mul::{limbs_mul_to_out, limbs_mul_to_out_scratch_len};\nuse crate::natural::arithmetic::sub::limbs_sub_greater_in_place_left;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{DoubleLimb, Limb};\nuse core::cmp::{Ordering::*, max};\nuse core::mem::swap;\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    DivExact, ExtendedGcd, NegAssign, OverflowingAddAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::slices::{slice_set_zero, slice_test_zero, slice_trailing_zeros};\n\n// This is equivalent to `gcdext_ctx` from `gmp-impl.h`, GMP 6.2.1.\nstruct ExtendedGcdContext<'a> {\n    // Result parameters.\n    gs: &'a mut [Limb],\n    gs_len: usize,\n    ss: &'a mut [Limb],\n    ss_len: usize,\n    ss_sign: bool,\n\n    // Cofactors updated in each step.\n    us_len: usize,\n    us0: &'a mut [Limb],\n    us1: &'a mut [Limb],\n    scratch: &'a mut [Limb],\n}\n\nimpl<'a> ExtendedGcdContext<'a> {\n    const fn new(\n        gs: &'a mut [Limb],\n        ss: &'a mut [Limb],\n        us_len: usize,\n        us0: &'a mut [Limb],\n        us1: &'a mut [Limb],\n        scratch: &'a mut [Limb],\n    ) -> Self {\n        let gs_len = gs.len();\n        Self {\n            gs,\n            gs_len,\n            ss,\n            ss_len: 0,\n            ss_sign: false,\n            us_len,\n            us0,\n            us1,\n            scratch,\n        }\n    }\n}\n\nimpl GcdSubdivideStepContext for ExtendedGcdContext<'_> {\n    // This is equivalent to `mpn_gcdext_hook` from `mpn/gcdext_lehmer.c`, GMP 6.2.1.\n    fn gcd_subdiv_step_hook(\n        &mut self,\n        gs: Option<&[Limb]>,\n        qs: Option<&mut [Limb]>,\n        mut qs_len: usize,\n        mut d: i8,\n    ) {\n        let mut us_len = self.us_len;\n        if let Some(gs) = gs {\n            let gs_len = gs.len();\n            assert_ne!(gs_len, 0);\n            assert!(gs[gs_len - 1] > 0);\n            self.gs_len = gs_len;\n            self.gs[..gs_len].copy_from_slice(gs);\n            if d == -1 {\n                // Must return the smallest cofactor, +us1 or -us0\n                let c = limbs_cmp_same_length(&self.us0[..us_len], &self.us1[..us_len]);\n                assert!(c != Equal || us_len == 1 && self.us0[0] == 1 && self.us1[0] == 1);\n                d = i8::from(c == Less);\n            }\n            let ss = if d == 0 {\n                &mut *self.us1\n            } else {\n                &mut *self.us0\n            };\n            us_len -= slice_trailing_zeros(&ss[..us_len]);\n            self.ss[..us_len].copy_from_slice(&ss[..us_len]);\n            self.us_len = us_len;\n            self.ss_len = us_len;\n            self.ss_sign = d == 0;\n        } else {\n            let mut us0 = &mut *self.us0;\n            let mut us1 = &mut *self.us1;\n            if d != 0 {\n                swap(&mut us0, &mut us1);\n            }\n            let qs = qs.as_ref().unwrap();\n            if qs[qs_len - 1] == 0 {\n                qs_len -= 1;\n            }\n            // Update us0 += q * us1\n            let carry = if qs_len == 1 {\n                let q = qs[0];\n                let us0 = &mut us0[..us_len];\n                let us1 = &us1[..us_len];\n                if q == 1 {\n                    Limb::from(limbs_slice_add_same_length_in_place_left(us0, us1))\n                } else {\n                    limbs_slice_add_mul_limb_same_length_in_place_left(us0, us1, q)\n                }\n            } else {\n                let mut us1_len = us_len;\n                us1_len -= slice_trailing_zeros(&us1[..us1_len]);\n                if us1_len == 0 {\n                    return;\n                }\n                // Should always have us1_len == us_len here, and us1 >= us0. The reason is that we\n                // alternate adding us0 to us1 and us1 to us0 (corresponding to subtractions a - b\n                // and b - a), and we can get a large quotient only just after a swscratch_len,\n                // which means that we'll add (a multiple of) the larger u to the smaller.\n                let scratch = &mut *self.scratch;\n                let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(qs_len, us1_len)];\n                limbs_mul_to_out(scratch, &qs[..qs_len], &us1[..us1_len], &mut mul_scratch);\n                us1_len += qs_len;\n                if scratch[us1_len - 1] == 0 {\n                    us1_len -= 1;\n                }\n                let us0 = &mut us0[..us1_len];\n                let scratch = &scratch[..us1_len];\n                Limb::from(if us1_len >= us_len {\n                    let us_len_old = us_len;\n                    us_len = us1_len;\n                    limbs_add_to_out_aliased(us0, us_len_old, scratch)\n                } else {\n                    fail_on_untested_path(\"gcd_subdiv_step_hook, us1_len < us_len\");\n                    // Note: Unlikely case, maybe never happens?\n                    limbs_slice_add_greater_in_place_left(us0, scratch)\n                })\n            };\n            us0[us_len] = carry;\n            self.us_len = us_len;\n            if carry > 0 {\n                self.us_len += 1;\n            }\n        }\n    }\n}\n\n// This is equivalent to `mpn_gcdext_lehmer_n` from `mpn/generic/gcdext_lehmer.c`, GMP 6.2.1.\nfn limbs_extended_gcd_same_length_lehmer<'a>(\n    gs: &mut [Limb],\n    ss: &mut [Limb],\n    mut xs: &'a mut [Limb],\n    ys: &mut [Limb],\n    scratch: &'a mut [Limb],\n) -> (usize, usize, bool) {\n    // Keeps track of the second row of the reduction matrix\n    //\n    // M = (v0, v1 ; us0, us1)\n    //\n    // which correspond to the first column of the inverse\n    //\n    // M^{-1} = (us1, -v1; -us0, v0)\n    //\n    // This implies that\n    //\n    // ```\n    //   a =  us1 A (mod B)\n    //   b = -us0 A (mod B)\n    // ```\n    //\n    // where A, B denotes the input values.\n    let mut n = xs.len();\n    assert_eq!(ys.len(), n);\n    let scratch_len = n + 1;\n    let (us, mut scratch) = scratch.split_at_mut(3 * scratch_len);\n    slice_set_zero(us);\n    let (mut us0, remainder) = us.split_at_mut(scratch_len);\n    let (us1, mut u2) = remainder.split_at_mut(scratch_len);\n    us1[0] = 1;\n    let mut us_len = 1;\n    while n >= 2 {\n        let mut m = HalfGcdMatrix1::default();\n        let mask = xs[n - 1] | ys[n - 1];\n        assert_ne!(mask, 0);\n        let (ah, al, bh, bl) = if mask.get_highest_bit() {\n            (xs[n - 1], xs[n - 2], ys[n - 1], ys[n - 2])\n        } else if n == 2 {\n            // We use the full inputs without truncation, so we can safely shift left.\n            let shift = u64::from(mask.leading_zeros());\n            (\n                extract_number(shift, xs[1], xs[0]),\n                xs[0] << shift,\n                extract_number(shift, ys[1], ys[0]),\n                ys[0] << shift,\n            )\n        } else {\n            let shift = u64::from(mask.leading_zeros());\n            (\n                extract_number(shift, xs[n - 1], xs[n - 2]),\n                extract_number(shift, xs[n - 2], xs[n - 3]),\n                extract_number(shift, ys[n - 1], ys[n - 2]),\n                extract_number(shift, ys[n - 2], ys[n - 3]),\n            )\n        };\n        // Try a `limbs_half_gcd_2` step\n        if limbs_half_gcd_2(ah, al, bh, bl, &mut m) {\n            n = limbs_half_gcd_matrix_1_mul_inverse_vector(\n                &m,\n                &mut scratch[..n],\n                &xs[..n],\n                &mut ys[..n],\n            );\n            swap(&mut xs, &mut scratch);\n            us_len = limbs_half_gcd_matrix_1_mul_vector(&m, u2, &us0[..us_len], us1);\n            swap(&mut us0, &mut u2);\n        } else {\n            // `limbs_half_gcd_2` has failed. Then either one of a or b is very small, or the\n            // difference is very small. Perform one subtraction followed by one division.\n            let mut context = ExtendedGcdContext::new(gs, ss, us_len, us0, us1, u2);\n            // Temporary storage `n` for the quotient and `scratch_len` for the new cofactor.\n            n = limbs_gcd_subdivide_step(&mut xs[..n], &mut ys[..n], 0, &mut context, scratch);\n            if n == 0 {\n                return (context.gs_len, context.ss_len, context.ss_sign);\n            }\n            us_len = context.us_len;\n        }\n    }\n    assert_ne!(xs[0], 0);\n    assert_ne!(ys[0], 0);\n    let negate;\n    if xs[0] == ys[0] {\n        // Which cofactor to return now? Candidates are +us1 and -us0, depending on which of a and b\n        // was most recently reduced, which we don't keep track of. So compare and get the smallest\n        // one.\n        gs[0] = xs[0];\n        let c = limbs_cmp_same_length(&us0[..us_len], &us1[..us_len]);\n        assert!(c != Equal || us_len == 1 && us0[0] == 1 && us1[0] == 1);\n        let ss_sign = c != Less;\n        let u = if ss_sign { us1 } else { us0 };\n        us_len -= slice_trailing_zeros(&u[..us_len]);\n        ss[..us_len].copy_from_slice(&u[..us_len]);\n        (1, us_len, ss_sign)\n    } else {\n        let (g, mut u, mut v) = xs[0].extended_gcd(ys[0]);\n        gs[0] = g;\n        // Set ss = u us1 - v us0. Keep track of size, us_len grows by one or two limbs.\n        if u == 0 {\n            assert_eq!(v, 1);\n            us_len -= slice_trailing_zeros(&us0[..us_len]);\n            ss[..us_len].copy_from_slice(&us0[..us_len]);\n            return (1, us_len, false);\n        } else if v == 0 {\n            assert_eq!(u, 1);\n            us_len -= slice_trailing_zeros(&us1[..us_len]);\n            ss[..us_len].copy_from_slice(&us1[..us_len]);\n            return (1, us_len, true);\n        } else if u > 0 {\n            negate = false;\n            assert!(v < 0);\n            v.neg_assign();\n        } else {\n            negate = true;\n            assert!(v > 0);\n            u.neg_assign();\n        }\n        let mut u_high =\n            limbs_mul_limb_to_out::<DoubleLimb, Limb>(ss, &us1[..us_len], Limb::exact_from(u));\n        let v_high = limbs_slice_add_mul_limb_same_length_in_place_left(\n            &mut ss[..us_len],\n            &us0[..us_len],\n            Limb::exact_from(v),\n        );\n        if u_high != 0 || v_high != 0 {\n            let overflow = u_high.overflowing_add_assign(v_high);\n            ss[us_len] = u_high;\n            us_len += 1;\n            if overflow {\n                fail_on_untested_path(\"limbs_extended_gcd_same_length_lehmer, overflow\");\n                ss[us_len] = 1;\n                us_len += 1;\n            }\n        }\n        us_len -= slice_trailing_zeros(&ss[..us_len]);\n        assert_ne!(us_len, 0);\n        (1, us_len, !negate)\n    }\n}\n\n// Computes (r;b) = (a; b) M. Result is of size n + M->n +/- 1, and the size is returned (if inputs\n// are non-normalized, result may be non-normalized too). Temporary space needed is M->n + n.\n//\n// This is equivalent to `hgcd_mul_matrix_vector` from `mpn/generic/gcdext.c`, GMP 6.2.1.\nfn limbs_half_gcd_matrix_mul_vector(\n    m: &mut HalfGcdMatrix<'_>,\n    rp: &mut [Limb],\n    xs: &[Limb],\n    ys: &mut [Limb],\n    scratch: &mut [Limb],\n) -> usize {\n    // Compute (r,b) <-- (u00 a + u10 b, u01 a + u11 b) as\n    //\n    // ```\n    // t  = u00 * a\n    // r  = u10 * b\n    // r += t;\n    //\n    // t  = u11 * b\n    // b  = u01 * a\n    // b += t;\n    // ```\n    let n = xs.len();\n    let ys_lo = &ys[..n];\n    let m_n = m.n;\n    let mut big_n = n + m_n;\n    let scratch = &mut scratch[..big_n];\n    let (m00, m01, m10, m11) = m.get_four();\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(m_n, n)];\n    limbs_mul_to_out(scratch, &m00[..m_n], xs, &mut mul_scratch);\n    limbs_mul_to_out(&mut rp[..big_n], &m10[..m_n], ys_lo, &mut mul_scratch);\n    let a_high = limbs_slice_add_same_length_in_place_left(&mut rp[..big_n], scratch);\n    limbs_mul_to_out(scratch, &m11[..m_n], ys_lo, &mut mul_scratch);\n    limbs_mul_to_out(ys, &m01[..m_n], xs, &mut mul_scratch);\n    let b_high = limbs_slice_add_same_length_in_place_left(&mut ys[..big_n], scratch);\n    if a_high || b_high {\n        rp[big_n] = Limb::from(a_high);\n        ys[big_n] = Limb::from(b_high);\n        big_n += 1;\n    } else {\n        // Normalize\n        while rp[big_n - 1] == 0 && ys[big_n - 1] == 0 {\n            big_n -= 1;\n        }\n    }\n    big_n\n}\n\n// Computes |v| = |(g - u a)| / b, where u may be positive or negative, and v is of the opposite\n// sign. max(a, b) is of size n, u and v at most size n, and v must have space for n+1 limbs.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `compute_v` from `mpn/generic/gcdext.c`, GMP 6.2.1, except that `ys` is\n// consumed.\nfn limbs_extended_gcd_cofactor(\n    vs: &mut [Limb],\n    xs: &[Limb],\n    ys: &mut [Limb],\n    gs: &[Limb],\n    ss: &[Limb],\n    ss_len: usize,\n    ss_sign: bool,\n    scratch: &mut [Limb],\n) -> usize {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    let gs_len = gs.len();\n    assert_ne!(n, 0);\n    assert_ne!(gs_len, 0);\n    assert_ne!(ss_len, 0);\n    let mut size = ss_len;\n    assert!(size <= n);\n    assert_ne!(ss[size - 1], 0);\n    let xs_len = n - slice_trailing_zeros(xs);\n    assert!(gs_len <= xs_len);\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(xs_len, size)];\n    limbs_mul_to_out(scratch, &xs[..xs_len], &ss[..size], &mut mul_scratch);\n    size += xs_len;\n    let scratch = &mut scratch[..size];\n    if ss_len != 0 && ss_sign {\n        // |v| = -v = (u a - g) / b\n        assert!(!limbs_sub_greater_in_place_left(scratch, gs));\n        size -= slice_trailing_zeros(scratch);\n        if size == 0 {\n            return 0;\n        }\n    } else {\n        // |v| = v = (g - u a) / b = (g + |u| a) / b. Since g <= a, (g + |u| a) always fits in\n        // (|usize| + xs_len) limbs.\n        assert!(!limbs_slice_add_greater_in_place_left(scratch, gs));\n        if scratch[size - 1] == 0 {\n            size -= 1;\n        }\n    }\n    // Now divide t / b. There must be no remainder\n    let ys_len = n - slice_trailing_zeros(ys);\n    assert!(size >= ys_len);\n    let vs_len = size + 1 - ys_len;\n    assert!(vs_len <= n + 1);\n    limbs_div_exact_to_out(vs, &mut scratch[..size], &mut ys[..ys_len]);\n    if vs[vs_len - 1] == 0 {\n        vs_len - 1\n    } else {\n        vs_len\n    }\n}\n\n// This is equivalent to `CHOOSE_P_1` from `mpn/generic/gcdext.c`, GMP 6.2.1.\nconst fn choose_p_1(n: usize) -> usize {\n    n >> 1\n}\n\n// This is equivalent to `CHOOSE_P_2` from `mpn/generic/gcdext.c`, GMP 6.2.1.\nconst fn choose_p_2(n: usize) -> usize {\n    n / 3\n}\n\n// This is equivalent to `MPN_GCDEXT_LEHMER_N_ITCH` from `gmp-impl.h`, GMP 6.2.1.\nconst fn limbs_extended_gcd_same_length_lehmer_scratch_len(n: usize) -> usize {\n    (n << 2) + 3\n}\n\n// TODO tune\nconst GCDEXT_DC_THRESHOLD: usize = 242;\n\n// Temporary storage:\n//\n// Initial division: Quotient of at most xs_len - n + 1 <= xs_len limbs.\n//\n// Storage for us0 and us1: 2(n+1).\n//\n// Storage for hgcd matrix M, with input ceil(n/2): 5 * ceil(n/4)\n//\n// Storage for hgcd, input (n + 1)/2: 9 n/4 plus some.\n//\n// When hgcd succeeds: 1 + floor(3n/2) for adjusting a and b, and 2(n+1) for the cofactors.\n//\n// When hgcd fails: 2n + 1 for mpn_gcdext_subdiv_step, which is less.\n//\n// For the lehmer call after the loop, Let T denote GCDEXT_DC_THRESHOLD. For the gcdext_lehmer call,\n// we need T each for u, a and b, and 4T+3 scratch space. Next, for compute_v, we need T for u, T+1\n// for v and 2T scratch space. In all, 7T + 3 is sufficient for both operations.\n//\n// Optimal choice of p seems difficult. In each iteration the division of work between hgcd and the\n// updates of us0 and us1 depends on the current size of the u. It may be desirable to use a\n// different choice of p in each iteration. Also the input size seems to matter; choosing p = n / 3\n// in the first iteration seems to improve performance slightly for input size just above the\n// threshold, but degrade performance for larger inputs.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpn_gcdext` from `mpn/generic/gcdext.c`, GMP 6.2.1, where the sign of\n// `usizep` is returned, but its magnitude is not indicated anywhere; it can be inferred by taking\n// the length of the nonzero portion of `ss`.\npub fn limbs_extended_gcd(\n    gs: &mut [Limb],\n    ss: &mut [Limb],\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n) -> (usize, bool) {\n    let xs_len = xs.len();\n    let mut n = ys.len();\n    let scratch_len = n + 1;\n    assert!(xs_len >= n);\n    assert_ne!(n, 0);\n    assert_ne!(ys[n - 1], 0);\n    let scratch = xs_len - n + 1;\n    let mut scratch_2 = max(\n        scratch,\n        limbs_extended_gcd_same_length_lehmer_scratch_len(n),\n    );\n    let mut matrix_scratch = 0;\n    if n >= GCDEXT_DC_THRESHOLD {\n        // For hgcd loop. If the definitions of choose_p_1 and choose_p_2 change, the min and max\n        // might change too.\n        let max_p = choose_p_1(n);\n        let min_p = choose_p_2(n);\n        matrix_scratch = limbs_half_gcd_matrix_init_scratch_len(n - min_p);\n        let hgcd_scratch = limbs_half_gcd_scratch_len(n - min_p);\n        let update_scratch = max_p + n - 1;\n        let mut scratch = matrix_scratch + max(hgcd_scratch, update_scratch);\n        scratch_2 = max(scratch_2, scratch);\n        // Final `limbs_extended_gcd_same_length_lehmer` call. Need space for u and for copies of a\n        // and b.\n        scratch = limbs_extended_gcd_same_length_lehmer_scratch_len(GCDEXT_DC_THRESHOLD)\n            + 3 * GCDEXT_DC_THRESHOLD;\n        scratch_2 = max(scratch_2, scratch);\n        // Cofactors us0 and us1\n        scratch_2 += (n + 1) << 1;\n    }\n    let mut scratch = vec![0; scratch_2];\n    if xs_len > n {\n        if n == 1 {\n            xs[0] = limbs_div_limb_to_out_mod(&mut scratch, xs, ys[0]);\n        } else {\n            limbs_div_mod_qs_to_out_rs_to_ns(&mut scratch, xs, ys);\n        }\n        if slice_test_zero(&xs[..n]) {\n            gs[..n].copy_from_slice(ys);\n            return (n, true);\n        }\n    }\n    let xs_lo = &mut xs[..n];\n    if n < GCDEXT_DC_THRESHOLD {\n        let (gs_len, _, ss_sign) =\n            limbs_extended_gcd_same_length_lehmer(gs, ss, xs_lo, ys, &mut scratch);\n        return (gs_len, ss_sign);\n    }\n    slice_set_zero(&mut scratch[..scratch_len << 1]);\n    split_into_chunks_mut!(scratch, scratch_len, [us0, us1], scratch);\n    // For the first hgcd call, there are no u updates, and it makes some sense to use a different\n    // choice for p.\n    let p = choose_p_1(n);\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(matrix_scratch);\n    let mut m = HalfGcdMatrix::init(n - p, scratch_lo);\n    let nn = limbs_half_gcd(&mut xs_lo[p..], &mut ys[p..], &mut m, scratch_hi);\n    let mut ss_sign;\n    let mut us_len;\n    if nn != 0 {\n        assert!(m.n <= (n - p - 1) >> 1);\n        assert!(m.n + p <= (p + n - 1) >> 1);\n        // Temporary storage 2 (p + m.n) <= p + n - 1\n        n = limbs_half_gcd_matrix_adjust(&m, p + nn, xs, ys, p, scratch_hi);\n        us0[..m.n].copy_from_slice(&m.get(1, 0)[..m.n]);\n        us1[..m.n].copy_from_slice(&m.get(1, 1)[..m.n]);\n        us_len = m.n;\n        while us0[us_len - 1] == 0 && us1[us_len - 1] == 0 {\n            us_len -= 1;\n        }\n    } else {\n        // mpn_hgcd has failed. Then either one of a or b is very small, or the difference is very\n        // small. Perform one subtraction followed by one division.\n        us1[0] = 1;\n        let (scratch, scratch_hi) = scratch.split_at_mut(n);\n        let mut context = ExtendedGcdContext::new(gs, ss, 1, us0, us1, &mut scratch_hi[n..]);\n        // Temporary storage n\n        n = limbs_gcd_subdivide_step(&mut xs[..n], ys, 0, &mut context, scratch);\n        ss_sign = context.ss_sign;\n        if n == 0 {\n            return (context.gs_len, ss_sign);\n        }\n        us_len = context.us_len;\n        assert!(us_len < scratch_len);\n    }\n    while n >= GCDEXT_DC_THRESHOLD {\n        let p = choose_p_2(n);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(matrix_scratch);\n        let mut m = HalfGcdMatrix::init(n - p, scratch_lo);\n        let nn = limbs_half_gcd(&mut xs[p..n], &mut ys[p..n], &mut m, scratch_hi);\n        if nn != 0 {\n            let t0 = scratch_hi;\n            assert!(m.n <= (n - p - 1) >> 1);\n            assert!(m.n + p <= (p + n - 1) >> 1);\n            // Temporary storage 2 (p + M->n) <= p + n - 1\n            n = limbs_half_gcd_matrix_adjust(&m, p + nn, xs, ys, p, t0);\n            // By the same analysis as for mpn_hgcd_matrix_mul\n            assert!(m.n + us_len <= scratch_len);\n            t0[..us_len].copy_from_slice(&us0[..us_len]);\n            // Temporary storage scratch_len\n            let (t0_lo, t0_hi) = t0.split_at_mut(us_len);\n            us_len = limbs_half_gcd_matrix_mul_vector(&mut m, us0, t0_lo, us1, t0_hi);\n            assert!(us_len < scratch_len);\n            assert!(us0[us_len - 1] != 0 || us1[us_len - 1] != 0);\n        } else {\n            // mpn_hgcd has failed. Then either one of a or b is very small, or the difference is\n            // very small. Perform one subtraction followed by one division.\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(n);\n            let mut context = ExtendedGcdContext::new(gs, ss, us_len, us0, us1, scratch_hi);\n            // Temporary storage n\n            n = limbs_gcd_subdivide_step(&mut xs[..n], &mut ys[..n], 0, &mut context, scratch_lo);\n            ss_sign = context.ss_sign;\n            if n == 0 {\n                return (context.gs_len, ss_sign);\n            }\n            us_len = context.us_len;\n            assert!(us_len < scratch_len);\n        }\n    }\n    let n = n;\n    let xs = &mut xs[..n];\n    let ys = &mut ys[..n];\n    // We have\n    // ```\n    // A = ... a + ... b\n    // B =  us0 a +  us1 b\n    //\n    // a = us1  A + ... B\n    // b = -us0 A + ... B\n    // ```\n    //\n    // with bounds |us0|, |us1| <= B / min(a, b)\n    //\n    // We always have us1 > 0, and us0 == 0 is possible only if us1 == 1, in which case the only\n    // reduction done so far is a = A - k B for some k.\n    //\n    // Compute g = u a + v b = (u us1 - v us0) A + (...) B. Here, u, v are bounded by\n    // ```\n    // |u| <= b,\n    // |v| <= a\n    // ```\n    assert!(*xs.last().unwrap() != 0 || *ys.last().unwrap() != 0);\n    if limbs_cmp_same_length(xs, ys) == Equal {\n        // Must return the smallest cofactor, +us1 or -us0\n        gs[..n].copy_from_slice(xs);\n        let c = limbs_cmp_same_length(&us0[..us_len], &us1[..us_len]);\n        // c == 0 can happen only when A = (2k+1) G, B = 2 G. And in this case we choose the\n        // cofactor + 1, corresponding to G = A - k B, rather than -1, corresponding to G = - A +\n        // (k+1) B.\n        assert!(c != Equal || us_len == 1 && us0[0] == 1 && us1[0] == 1);\n        if c == Less {\n            us_len -= slice_trailing_zeros(&us0[..us_len]);\n            ss[..us_len].copy_from_slice(&us0[..us_len]);\n            ss_sign = false;\n        } else {\n            us_len -= slice_trailing_zeros(&us1[..us_len]);\n            assert_ne!(us_len, 0);\n            ss[..us_len].copy_from_slice(&us1[..us_len]);\n            ss_sign = true;\n        }\n        (n, ss_sign)\n    } else if us0[0] == 0 && us_len == 1 {\n        fail_on_untested_path(\n            \"limbs_extended_gcd, \\\n            limbs_cmp_same_length(..) != Equal && us0[0] == 0 && us_len == 1\",\n        );\n        assert_eq!(us1[0], 1);\n        // g = u a + v b = (u us1 - v us0) A + (...) B = u A + (...) B\n        let (gs_len, _, ss_sign) = limbs_extended_gcd_same_length_lehmer(gs, ss, xs, ys, scratch);\n        (gs_len, ss_sign)\n    } else {\n        let (lehmer_ss, scratch) = scratch.split_at_mut(n);\n        // Call limbs_extended_gcd_same_length_lehmer with copies of a and b.\n        split_into_chunks_mut!(scratch, n, [scratch_0, scratch_1], scratch_2);\n        scratch_0.copy_from_slice(xs);\n        scratch_1.copy_from_slice(ys);\n        let (gs_len, lehmer_us_len, lehmer_us_sign) =\n            limbs_extended_gcd_same_length_lehmer(gs, lehmer_ss, scratch_0, scratch_1, scratch_2);\n        let us0_len = us_len - slice_trailing_zeros(&us0[..us_len]);\n        let us0 = &us0[..us0_len];\n        assert_ne!(us0_len, 0);\n        if lehmer_us_len == 0 {\n            // u == 0 ==> v = g / b == 1 ==> g = - us0 A + (...) B\n            ss[..us0_len].copy_from_slice(us0);\n            return (gs_len, false);\n        }\n        let lehmer_ss = &lehmer_ss[..lehmer_us_len];\n        let (lehmer_vs, scratch_hi) = scratch.split_at_mut(n + 1);\n        // Compute v = (g - u a) / b\n        let lehmer_vs_len = limbs_extended_gcd_cofactor(\n            lehmer_vs,\n            xs,\n            ys,\n            &gs[..gs_len],\n            lehmer_ss,\n            lehmer_us_len,\n            lehmer_us_sign,\n            scratch_hi,\n        );\n        let mut us1_len = us_len - slice_trailing_zeros(&us1[..us_len]);\n        assert_ne!(us1_len, 0);\n        assert!(lehmer_vs_len + us0_len <= scratch_len);\n        // - We may still have v == 0\n        // - Compute u us0\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(us1_len, lehmer_ss.len())];\n        limbs_mul_to_out(ss, &us1[..us1_len], lehmer_ss, &mut mul_scratch);\n        us_len = us1_len + lehmer_us_len;\n        assert!(us_len <= scratch_len);\n        if ss[us_len - 1] == 0 {\n            us_len -= 1;\n        }\n        if lehmer_vs_len != 0 {\n            // Overwrites old us1 value\n            let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(us0.len(), lehmer_vs_len)];\n            limbs_mul_to_out(us1, us0, &lehmer_vs[..lehmer_vs_len], &mut mul_scratch);\n            us1_len = us0_len + lehmer_vs_len;\n            if us1[us1_len - 1] == 0 {\n                us1_len -= 1;\n            }\n            let us1 = &us1[..us1_len];\n            let carry = if us1_len <= us_len {\n                limbs_slice_add_greater_in_place_left(&mut ss[..us_len], us1)\n            } else {\n                let old_us_len = us_len;\n                us_len = us1_len;\n                limbs_add_to_out_aliased(&mut ss[..us1_len], old_us_len, us1)\n            };\n            ss[us_len] = Limb::from(carry);\n            if carry {\n                us_len += 1;\n            }\n            assert!(us_len < scratch_len);\n        }\n        (gs_len, lehmer_us_sign)\n    }\n}\n\nfn extended_gcd_helper(a: Natural, b: Natural) -> (Natural, Integer, Integer) {\n    let mut xs = a.to_limbs_asc();\n    let mut ys = b.to_limbs_asc();\n    let mut a = Integer::from(a);\n    let mut b = Integer::from(b);\n    let mut swapped = false;\n    if xs.len() < ys.len() {\n        swap(&mut xs, &mut ys);\n        swap(&mut a, &mut b);\n        swapped = true;\n    }\n    let mut gs = vec![0; ys.len()];\n    let mut ss = vec![0; ys.len() + 1];\n    let (g_len, ss_sign) = limbs_extended_gcd(&mut gs, &mut ss, &mut xs, &mut ys);\n    gs.truncate(g_len);\n    let gcd = Natural::from_owned_limbs_asc(gs);\n    let mut s = Integer::from_sign_and_abs(ss_sign, Natural::from_owned_limbs_asc(ss));\n    let mut t = (Integer::from(&gcd) - a * &s).div_exact(b);\n    if swapped {\n        swap(&mut s, &mut t);\n    }\n    (gcd, s, t)\n}\n\nimpl ExtendedGcd for Natural {\n    type Gcd = Self;\n    type Cofactor = Integer;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. Both [`Natural`]s are\n    /// taken by value.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(a, b)$, where\n    ///   $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq \\lfloor\n    ///   a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32)\n    ///         .extended_gcd(Natural::from(5u32))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(240u32)\n    ///         .extended_gcd(Natural::from(46u32))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: Self) -> (Self, Integer, Integer) {\n        match (self, other) {\n            (Self::ZERO, Self::ZERO) => (Self::ZERO, Integer::ZERO, Integer::ZERO),\n            (a, b) if a == b => (b, Integer::ZERO, Integer::ONE),\n            (Self::ZERO, b) => (b, Integer::ZERO, Integer::ONE),\n            (a, Self::ZERO) => (a, Integer::ONE, Integer::ZERO),\n            (Self(Small(x)), Self(Small(y))) => {\n                let (gcd, s, t) = x.extended_gcd(y);\n                (Self::from(gcd), Integer::from(s), Integer::from(t))\n            }\n            (a, b) => extended_gcd_helper(a, b),\n        }\n    }\n}\n\nimpl<'a> ExtendedGcd<&'a Self> for Natural {\n    type Gcd = Self;\n    type Cofactor = Integer;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. The first [`Natural`] is\n    /// taken by value and the second by reference.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(a, b)$, where\n    ///   $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq \\lfloor\n    ///   a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32)\n    ///         .extended_gcd(&Natural::from(5u32))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(240u32)\n    ///         .extended_gcd(&Natural::from(46u32))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: &'a Self) -> (Self, Integer, Integer) {\n        match (self, other) {\n            (Self::ZERO, &Self::ZERO) => (Self::ZERO, Integer::ZERO, Integer::ZERO),\n            (a, b) if a == *b => (b.clone(), Integer::ZERO, Integer::ONE),\n            (Self::ZERO, b) => (b.clone(), Integer::ZERO, Integer::ONE),\n            (a, &Self::ZERO) => (a, Integer::ONE, Integer::ZERO),\n            (Self(Small(x)), Self(Small(y))) => {\n                let (gcd, s, t) = x.extended_gcd(*y);\n                (Self::from(gcd), Integer::from(s), Integer::from(t))\n            }\n            (a, b) => extended_gcd_helper(a, b.clone()),\n        }\n    }\n}\n\nimpl ExtendedGcd<Natural> for &Natural {\n    type Gcd = Natural;\n    type Cofactor = Integer;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. The first [`Natural`] is\n    /// taken by reference and the second by value.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(a, b)$, where\n    ///   $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq \\lfloor\n    ///   a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32))\n    ///         .extended_gcd(Natural::from(5u32))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(240u32))\n    ///         .extended_gcd(Natural::from(46u32))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: Natural) -> (Natural, Integer, Integer) {\n        match (self, other) {\n            (&Natural::ZERO, Natural::ZERO) => (Natural::ZERO, Integer::ZERO, Integer::ZERO),\n            (a, b) if *a == b => (b, Integer::ZERO, Integer::ONE),\n            (&Natural::ZERO, b) => (b, Integer::ZERO, Integer::ONE),\n            (a, Natural::ZERO) => (a.clone(), Integer::ONE, Integer::ZERO),\n            (Natural(Small(x)), Natural(Small(y))) => {\n                let (gcd, s, t) = x.extended_gcd(y);\n                (Natural::from(gcd), Integer::from(s), Integer::from(t))\n            }\n            (a, b) => extended_gcd_helper(a.clone(), b),\n        }\n    }\n}\n\nimpl ExtendedGcd<&Natural> for &Natural {\n    type Gcd = Natural;\n    type Cofactor = Integer;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s $a$ and $b$, and also the\n    /// coefficients $x$ and $y$ in Bézout's identity $ax+by=\\gcd(a,b)$. Both [`Natural`]s are\n    /// taken by reference.\n    ///\n    /// The are infinitely many $x$, $y$ that satisfy the identity for any $a$, $b$, so the full\n    /// specification is more detailed:\n    ///\n    /// - $f(0, 0) = (0, 0, 0)$.\n    /// - $f(a, ak) = (a, 1, 0)$ if $a > 0$ and $k \\neq 1$.\n    /// - $f(bk, b) = (b, 0, 1)$ if $b > 0$.\n    /// - $f(a, b) = (g, x, y)$ if $a \\neq 0$ and $b \\neq 0$ and $\\gcd(a, b) \\neq \\min(a, b)$, where\n    ///   $g = \\gcd(a, b) \\geq 0$, $ax + by = g$, $x \\leq \\lfloor b/g \\rfloor$, and $y \\leq \\lfloor\n    ///   a/g \\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ExtendedGcd;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32))\n    ///         .extended_gcd(&Natural::from(5u32))\n    ///         .to_debug_string(),\n    ///     \"(1, 2, -1)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(240u32))\n    ///         .extended_gcd(&Natural::from(46u32))\n    ///         .to_debug_string(),\n    ///     \"(2, -9, 47)\"\n    /// );\n    /// ```\n    fn extended_gcd(self, other: &Natural) -> (Natural, Integer, Integer) {\n        match (self, other) {\n            (&Natural::ZERO, &Natural::ZERO) => (Natural::ZERO, Integer::ZERO, Integer::ZERO),\n            (a, b) if a == b => (b.clone(), Integer::ZERO, Integer::ONE),\n            (&Natural::ZERO, b) => (b.clone(), Integer::ZERO, Integer::ONE),\n            (a, &Natural::ZERO) => (a.clone(), Integer::ONE, Integer::ZERO),\n            (Natural(Small(x)), Natural(Small(y))) => {\n                let (gcd, s, t) = x.extended_gcd(*y);\n                (Natural::from(gcd), Integer::from(s), Integer::from(t))\n            }\n            (a, b) => extended_gcd_helper(a.clone(), b.clone()),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/gcd/half_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2019 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_add_to_out_aliased, limbs_slice_add_greater_in_place_left, limbs_slice_add_limb_in_place,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::div_mod::{\n    limbs_div_limb_to_out_mod, limbs_div_mod_qs_to_out_rs_to_ns,\n};\nuse crate::natural::arithmetic::gcd::matrix_2_2::limbs_matrix_2_2_mul;\nuse crate::natural::arithmetic::mul::limb::{limbs_mul_limb_to_out, limbs_slice_mul_limb_in_place};\nuse crate::natural::arithmetic::mul::mul_mod::{\n    limbs_mul_mod_base_pow_n_minus_1, limbs_mul_mod_base_pow_n_minus_1_next_size,\n    limbs_mul_mod_base_pow_n_minus_1_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len, limbs_mul_to_out,\n    limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::sub_mul::limbs_sub_mul_limb_same_length_in_place_left;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::natural::{bit_to_limb_count_floor, limb_to_bit_count};\nuse crate::platform::{DoubleLimb, Limb};\nuse core::cmp::{Ordering::*, max, min};\nuse core::mem::swap;\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    DivMod, Gcd, Parity, WrappingAddAssign, XMulYToZZ, XXDivModYToQR, XXSubYYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, JoinHalves, SplitInHalf, WrappingFrom};\nuse malachite_base::num::logic::traits::{LeadingZeros, NotAssign, TrailingZeros};\nuse malachite_base::slices::{slice_set_zero, slice_test_zero, slice_trailing_zeros};\n\npub(crate) trait GcdSubdivideStepContext {\n    fn gcd_subdiv_step_hook(\n        &mut self,\n        g: Option<&[Limb]>,\n        q: Option<&mut [Limb]>,\n        q_len: usize,\n        d: i8,\n    );\n\n    fn gcd_subdiv_step_hook_with_1(&mut self, d: i8) {\n        self.gcd_subdiv_step_hook(None, Some(&mut [1]), 1, d);\n    }\n}\n\n/// This is equivalent to `gcd_ctx` from `mpn/gcd.c`, GMP 6.2.1.\nstruct GcdContext<'a>(&'a mut [Limb]);\n\nimpl GcdSubdivideStepContext for GcdContext<'_> {\n    /// This is equivalent to `gcd_hook` from `mpn/gcd.c`, GMP 6.2.1.\n    fn gcd_subdiv_step_hook(\n        &mut self,\n        g: Option<&[Limb]>,\n        _q: Option<&mut [Limb]>,\n        _q_len: usize,\n        _d: i8,\n    ) {\n        if let Some(g) = g {\n            self.0[..g.len()].copy_from_slice(g);\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\npub struct HalfGcdMatrix<'a> {\n    pub(crate) data: &'a mut [Limb],\n    pub(crate) s: usize,\n    pub(crate) two_s: usize,\n    pub(crate) three_s: usize,\n    pub(crate) n: usize,\n}\n\n#[cfg(not(feature = \"test_build\"))]\npub(crate) struct HalfGcdMatrix<'a> {\n    data: &'a mut [Limb],\n    pub(crate) s: usize,\n    two_s: usize,\n    three_s: usize,\n    pub(crate) n: usize,\n}\n\nimpl HalfGcdMatrix<'_> {\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    pub_crate_test! {get(&self, row: u8, column: u8) -> &[Limb] {\n        match (row, column) {\n            (0, 0) => &self.data[..self.s],\n            (0, 1) => &self.data[self.s..self.two_s],\n            (1, 0) => &self.data[self.two_s..self.three_s],\n            (1, 1) => &self.data[self.three_s..],\n            _ => panic!(),\n        }\n    }}\n\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    pub_test! {get_mut(&mut self, row: u8, column: u8) -> &mut [Limb] {\n        match (row, column) {\n            (0, 0) => &mut self.data[..self.s],\n            (0, 1) => &mut self.data[self.s..self.two_s],\n            (1, 0) => &mut self.data[self.two_s..self.three_s],\n            (1, 1) => &mut self.data[self.three_s..],\n            _ => panic!(),\n        }\n    }}\n\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    #[inline]\n    fn get_two_mut(\n        &mut self,\n        row_1: u8,\n        column_1: u8,\n        row_2: u8,\n        column_2: u8,\n    ) -> (&mut [Limb], &mut [Limb]) {\n        match (row_1, column_1, row_2, column_2) {\n            (0, 0, 0, 1) => self.data[..self.two_s].split_at_mut(self.s),\n            (0, 1, 0, 0) => {\n                let (xs, ys) = self.data[..self.two_s].split_at_mut(self.s);\n                (ys, xs)\n            }\n            (1, 0, 1, 1) => self.data[self.two_s..].split_at_mut(self.s),\n            (1, 1, 1, 0) => {\n                let (xs, ys) = self.data[self.two_s..].split_at_mut(self.s);\n                (ys, xs)\n            }\n            _ => panic!(),\n        }\n    }\n\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    #[inline]\n    pub(crate) fn get_four(&mut self) -> (&[Limb], &[Limb], &[Limb], &[Limb]) {\n        split_into_chunks!(self.data, self.s, [x00, x01, x10], x11);\n        (x00, x01, x10, x11)\n    }\n\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    #[inline]\n    fn get_four_mut(&mut self) -> (&mut [Limb], &mut [Limb], &mut [Limb], &mut [Limb]) {\n        split_into_chunks_mut!(self.data, self.s, [x00, x01, x10], x11);\n        (x00, x01, x10, x11)\n    }\n\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    pub_const_test! {min_init_scratch(n: usize) -> usize {\n        (((n + 1) >> 1) + 1) << 2\n    }}\n\n    // For input of size n, matrix elements are of size at most ceil(n / 2) - 1, but we need two\n    // limbs extra.\n    //\n    // # Worst-case complexity\n    // $T(n) = O(n)$\n    //\n    // $M(n) = O(1)$\n    //\n    // where $T$ is time, $M$ is additional memory, and $n$ is `p.len()`.\n    //\n    // This is equivalent to `mpn_hgcd_matrix_init` from `mpn/generic/hgcd_matrix.c`, GMP 6.2.1,\n    // where the matrix is returned.\n    pub_crate_test! {init(n: usize, p: &mut [Limb]) -> HalfGcdMatrix<'_> {\n        let s = n.div_ceil(2) + 1;\n        let two_s = s << 1;\n        let three_s = two_s + s;\n        slice_set_zero(&mut p[..s << 2]);\n        let mut m = HalfGcdMatrix {\n            data: p,\n            s,\n            two_s,\n            three_s,\n            n: 1,\n        };\n        m.get_mut(0, 0)[0] = 1;\n        m.get_mut(1, 1)[0] = 1;\n        m\n    }}\n\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    pub_const_test! {update_q_scratch_len(&self, qs_len: usize) -> usize {\n        self.n + qs_len\n    }}\n\n    // # Worst-case complexity\n    // Constant time and additional memory.\n    fn all_elements_zero_at_index(&self, i: usize) -> bool {\n        self.get(0, 0)[i] == 0\n            && self.get(0, 1)[i] == 0\n            && self.get(1, 0)[i] == 0\n            && self.get(1, 1)[i] == 0\n    }\n}\n\n// Multiply M by M1 from the right. Needs 3*(M->n + M1->n) + 5 limbs of temporary storage (see\n// mpn_matrix22_mul_itch).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(a.n, b.n)`.\n//\n// This is equivalent to `mpn_hgcd_matrix_mul` from `mpn/generic/hgcd_matrix.c`, GMP 6.2.1.\npub_crate_test! {limbs_half_gcd_matrix_mul_matrix(\n    a: &mut HalfGcdMatrix,\n    b: &HalfGcdMatrix,\n    scratch: &mut [Limb]\n) {\n    // About the new size of M:s elements. Since M1's diagonal elements are > 0, no element can\n    // decrease. The new elements are of size M->n + M1->n, one limb more or less. The computation\n    // of the matrix product produces elements of size M->n + M1->n + 1. But the true size, after\n    // normalization, may be three limbs smaller.\n    //\n    // The reason that the product has normalized size >= M->n + M1->n - 2 is subtle. It depends on\n    // the fact that M and M1 can be factored as products of (1,1; 0,1) and (1,0; 1,1), and that we\n    // can't have M ending with a large power and M1 starting with a large power of the same matrix.\n    assert!(a.n + b.n < a.s);\n    assert!(!a.all_elements_zero_at_index(a.n - 1));\n    let b_n = b.n;\n    assert!(!b.all_elements_zero_at_index(b_n - 1));\n    let n = a.n;\n    let (x00, x01, x10, x11) = a.get_four_mut();\n    limbs_matrix_2_2_mul(\n        x00,\n        x01,\n        x10,\n        x11,\n        n,\n        &b.get(0, 0)[..b_n],\n        &b.get(0, 1)[..b_n],\n        &b.get(1, 0)[..b_n],\n        &b.get(1, 1)[..b_n],\n        scratch,\n    );\n    // Index of last potentially non-zero limb, size is one greater.\n    let mut n = a.n + b_n;\n    for _ in 0..3 {\n        if a.all_elements_zero_at_index(n) {\n            n -= 1;\n        }\n    }\n    assert!(!a.all_elements_zero_at_index(n));\n    a.n = n + 1;\n}}\n\n// Multiply M by M1 from the right. Since the M1 elements fit in Limb::WIDTH - 1 bits, M grows by at\n// most one limb. Needs temporary space M->n\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `a.n`.\n//\n// This is equivalent to `mpn_hgcd_matrix_mul_1` from `mpn/generic/hgcd_matrix.c`, GMP 6.2.1.\npub_crate_test! {limbs_half_gcd_matrix_mul_matrix_1(\n    a: &mut HalfGcdMatrix,\n    b: &HalfGcdMatrix1,\n    scratch: &mut [Limb],\n) {\n    let n = a.n;\n    let scratch = &mut scratch[..n];\n    scratch.copy_from_slice(&a.get(0, 0)[..n]);\n    let (a_0_0, a_0_1) = a.get_two_mut(0, 0, 0, 1);\n    let n0 = limbs_half_gcd_matrix_1_mul_vector(b, a_0_0, scratch, a_0_1);\n    scratch.copy_from_slice(&a.get(1, 0)[..n]);\n    let (a_1_0, a_1_1) = a.get_two_mut(1, 0, 1, 1);\n    let n1 = limbs_half_gcd_matrix_1_mul_vector(b, a_1_0, scratch, a_1_1);\n    a.n = max(n0, n1);\n    assert!(a.n <= a.s);\n}}\n\n// Update column `column`, adding in Q * column (1-`col`). Temporary storage: qn + n <= `self.s`,\n// where n is the size of the largest element in column 1 - `column`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `m.n`.\n//\n// This is equivalent to `mpn_hgcd_matrix_update_q` from `mpn/generic/hgcd_matrix.c`, GMP 6.2.1.\npub_crate_test! {limbs_half_gcd_matrix_update_q(\n    m: &mut HalfGcdMatrix,\n    qs: &[Limb],\n    column: u8,\n    scratch: &mut [Limb],\n) {\n    let qs_len = qs.len();\n    assert!(qs_len + m.n <= m.s);\n    assert!(column < 2);\n    if qs_len == 1 {\n        let q = qs[0];\n        let n = m.n;\n        let (m_0_a, m_0_b) = m.get_two_mut(0, column, 0, 1 - column);\n        let carry_0 =\n            limbs_slice_add_mul_limb_same_length_in_place_left(&mut m_0_a[..n], &m_0_b[..n], q);\n        let (m_1_a, m_1_b) = m.get_two_mut(1, column, 1, 1 - column);\n        let carry_1 =\n            limbs_slice_add_mul_limb_same_length_in_place_left(&mut m_1_a[..n], &m_1_b[..n], q);\n        m.get_mut(0, column)[n] = carry_0;\n        m.get_mut(1, column)[n] = carry_1;\n        if carry_0 != 0 || carry_1 != 0 {\n            m.n += 1;\n        }\n    } else {\n        // Carries for the unlikely case that we get both high words from the multiplication and\n        // carries from the addition.\n        let mut carries = [0; 2];\n        // The matrix will not necessarily grow in size by qn, so we need normalization in order not\n        // to overflow m.\n        let mut n = m.n;\n        while n + qs_len > m.n {\n            assert_ne!(n, 0);\n            if m.get(0, 1 - column)[n - 1] > 0 || m.get(1, 1 - column)[n - 1] > 0 {\n                break;\n            }\n            n -= 1;\n        }\n        assert!(qs_len + n <= m.s);\n        if n != 0 {\n            let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(n, qs_len)];\n            for row in 0..2 {\n                limbs_mul_to_out(\n                    scratch,\n                    &m.get(row, 1 - column)[..n],\n                    &qs[..qs_len],\n                    &mut mul_scratch,\n                );\n                assert!(n + qs_len >= m.n);\n                let m_n = m.n;\n                if limbs_add_to_out_aliased(m.get_mut(row, column), m_n, &scratch[..n + qs_len]) {\n                    carries[usize::wrapping_from(row)] = 1;\n                }\n            }\n        }\n        n += qs_len;\n        if carries[0] != 0 || carries[1] != 0 {\n            m.get_mut(0, column)[n] = carries[0];\n            m.get_mut(1, column)[n] = carries[1];\n            n += 1;\n        } else if m.get(0, column)[n - 1] == 0 && m.get(1, column)[n - 1] == 0 {\n            n -= 1;\n        }\n        m.n = n;\n    }\n    assert!(m.n <= m.s);\n}}\n\n// - Multiplies the least significant p limbs of (X;Y) by M^-1.\n// - Temporary space needed: 2 * (p + m.n)\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_hgcd_matrix_adjust` from `mpn/generic/hgcd_matrix.c`, GMP 6.2.1.\npub(crate) fn limbs_half_gcd_matrix_adjust(\n    m: &HalfGcdMatrix,\n    mut n: usize,\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n    p: usize,\n    scratch: &mut [Limb],\n) -> usize {\n    // M^-1 (X; Y) = (r11, -r01; -r10, r00) (a ; b) = (r11 x - r01 y; - r10 x + r00 y)\n    let xs_init = &mut xs[..n];\n    let ys_init = &mut ys[..n];\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(p + m.n);\n    assert!(p + m.n < n);\n    let (xs_lo, xs_hi) = xs_init.split_at_mut(p);\n    // First compute the two values depending on X, before overwriting X\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(m.n, p)];\n    limbs_mul_to_out(scratch_lo, &m.get(1, 1)[..m.n], xs_lo, &mut mul_scratch);\n    limbs_mul_to_out(scratch_hi, &m.get(1, 0)[..m.n], xs_lo, &mut mul_scratch);\n    // Update X\n    let (scratch_lo_lo, scratch_lo_hi) = scratch_lo.split_at(p);\n    xs_lo.copy_from_slice(scratch_lo_lo);\n    let mut x_high = limbs_slice_add_greater_in_place_left(xs_hi, scratch_lo_hi);\n    let (ys_lo, ys_hi) = ys_init.split_at_mut(p);\n    limbs_mul_to_out(scratch_lo, &m.get(0, 1)[..m.n], ys_lo, &mut mul_scratch);\n    if limbs_sub_greater_in_place_left(xs_init, scratch_lo) {\n        assert!(x_high);\n        x_high = false;\n    }\n    // Update Y\n    limbs_mul_to_out(scratch_lo, &m.get(0, 0)[..m.n], ys_lo, &mut mul_scratch);\n    let (scratch_lo_lo, scratch_lo_hi) = scratch_lo.split_at(p);\n    ys_lo.copy_from_slice(scratch_lo_lo);\n    let mut y_high = limbs_slice_add_greater_in_place_left(ys_hi, scratch_lo_hi);\n    if limbs_sub_greater_in_place_left(ys_init, &scratch_hi[..p + m.n]) {\n        assert!(y_high);\n        y_high = false;\n    }\n    if x_high || y_high {\n        xs[n] = Limb::from(x_high);\n        ys[n] = Limb::from(y_high);\n        n += 1;\n    } else {\n        // The subtraction can reduce the size by at most one limb.\n        if xs[n - 1] == 0 && ys[n - 1] == 0 {\n            n -= 1;\n        }\n    }\n    assert!(xs[n - 1] != 0 || ys[n - 1] != 0);\n    n\n}\n\n// Computes (x, y) <- M^(-1) (x; y)\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `m.len()`.\n//\n// This is equivalent to `mpn_hgcd_matrix_apply` from `mpn/generic/hgcd_reduce.c`, GMP 6.2.1.\nfn limbs_half_gcd_matrix_apply(m: &HalfGcdMatrix, xs: &mut [Limb], ys: &mut [Limb]) -> usize {\n    let mut n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert!(xs[n - 1] != 0 || ys[n - 1] != 0);\n    let xs_len = n - slice_trailing_zeros(&xs[..n]);\n    let ys_len = n - slice_trailing_zeros(&ys[..n]);\n    let xs_lo = &mut xs[..xs_len];\n    let ys_lo = &mut ys[..ys_len];\n    let mut m_lens = [[0usize; 2]; 2];\n    for (i, row) in m_lens.iter_mut().enumerate() {\n        for (j, len) in row.iter_mut().enumerate() {\n            *len = m.n - slice_trailing_zeros(&m.get(i as u8, j as u8)[..m.n]);\n        }\n    }\n    assert_ne!(m_lens[0][0], 0);\n    assert_ne!(m_lens[1][1], 0);\n    assert!(m_lens[0][1] != 0 || m_lens[1][0] != 0);\n    if m_lens[0][1] == 0 {\n        // X unchanged, M = (1, 0; q, 1)\n        assert_eq!(m_lens[0][0], 1);\n        assert_eq!(m.get(0, 0)[0], 1);\n        assert_eq!(m_lens[1][1], 1);\n        assert_eq!(m.get(1, 1)[0], 1);\n        // Put Y <- Y - q X\n        limbs_gcd_sub_mul(ys_lo, xs_lo, &m.get(1, 0)[..m_lens[1][0]])\n    } else if m_lens[1][0] == 0 {\n        fail_on_untested_path(\"limbs_half_gcd_matrix_apply, m_lens[1][0] == 0\");\n        // Y unchanged, M = (1, q; 0, 1)\n        assert_eq!(m_lens[0][0], 1);\n        assert_eq!(m.get(0, 0)[0], 1);\n        assert_eq!(m_lens[1][1], 1);\n        assert_eq!(m.get(1, 1)[0], 1);\n        // Put X <- X - q * Y\n        limbs_gcd_sub_mul(xs_lo, ys_lo, &m.get(0, 1)[..m_lens[0][1]])\n    } else {\n        // - X = m00 x + m01 y => x <= X / m00, y <= X / m01.\n        // - Y = m10 x + m11 y => x <= Y / m10, y <= Y / m11.\n        let mut new_n = max(\n            min(xs_len - m_lens[0][0], ys_len - m_lens[1][0]),\n            min(xs_len - m_lens[0][1], ys_len - m_lens[1][1]),\n        ) + 1;\n        // In the range of interest, mulmod_bnm1 should always beat mullo.\n        let mod_n = limbs_mul_mod_base_pow_n_minus_1_next_size(new_n + 1);\n        let mut big_scratch =\n            vec![0; (mod_n << 1) + limbs_mul_mod_base_pow_n_minus_1_scratch_len(mod_n, mod_n, m.n)];\n        split_into_chunks_mut!(big_scratch, mod_n, [scratch, scratch_lo], scratch_hi);\n        assert!(n <= mod_n << 1);\n        if n > mod_n {\n            let (xs_lo, xs_hi) = xs.split_at_mut(mod_n);\n            if limbs_slice_add_greater_in_place_left(xs_lo, xs_hi) {\n                assert!(!limbs_slice_add_limb_in_place(xs, 1));\n            }\n            let (ys_lo, ys_hi) = ys.split_at_mut(mod_n);\n            if limbs_slice_add_greater_in_place_left(ys_lo, ys_hi) {\n                assert!(!limbs_slice_add_limb_in_place(ys, 1));\n            }\n            n = mod_n;\n        }\n        let xs = &mut xs[..n];\n        let ys = &mut ys[..n];\n        limbs_mul_mod_base_pow_n_minus_1(\n            scratch,\n            mod_n,\n            xs,\n            &m.get(1, 1)[..m_lens[1][1]],\n            scratch_hi,\n        );\n        limbs_mul_mod_base_pow_n_minus_1(\n            scratch_lo,\n            mod_n,\n            ys,\n            &m.get(0, 1)[..m_lens[0][1]],\n            scratch_hi,\n        );\n        if n + m_lens[1][1] < mod_n {\n            slice_set_zero(&mut scratch[n + m_lens[1][1]..]);\n        }\n        if n + m_lens[0][1] < mod_n {\n            slice_set_zero(&mut scratch_lo[n + m_lens[0][1]..]);\n        }\n        if limbs_sub_same_length_in_place_left(scratch, scratch_lo) {\n            assert!(!limbs_sub_limb_in_place(scratch, 1));\n        }\n        let (scratch_0, scratch_1) = scratch.split_at(new_n);\n        assert!(slice_test_zero(scratch_1));\n        limbs_mul_mod_base_pow_n_minus_1(\n            scratch_lo,\n            mod_n,\n            xs,\n            &m.get(1, 0)[..m_lens[1][0]],\n            scratch_hi,\n        );\n        xs[..new_n].copy_from_slice(scratch_0);\n        limbs_mul_mod_base_pow_n_minus_1(\n            scratch,\n            mod_n,\n            ys,\n            &m.get(0, 0)[..m_lens[0][0]],\n            scratch_hi,\n        );\n        if n + m_lens[1][0] < mod_n {\n            slice_set_zero(&mut scratch_lo[n + m_lens[1][0]..]);\n        }\n        if n + m_lens[0][0] < mod_n {\n            slice_set_zero(&mut scratch[n + m_lens[0][0]..]);\n        }\n        if limbs_sub_same_length_in_place_left(scratch, scratch_lo) {\n            assert!(!limbs_sub_limb_in_place(scratch, 1));\n        }\n        let (scratch_0, scratch_1) = scratch.split_at(new_n);\n        assert!(slice_test_zero(scratch_1));\n        ys[..new_n].copy_from_slice(scratch_0);\n        while xs[new_n - 1] | ys[new_n - 1] == 0 {\n            new_n -= 1;\n            assert_ne!(new_n, 0);\n        }\n        new_n\n    }\n}\n\n/// This is equivalent to `mpn_hgcd_reduce` from `mpn/generic/hgcd_reduce.c`, GMP 6.2.1.\nfn limbs_half_gcd_matrix_reduce(\n    m: &mut HalfGcdMatrix,\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n    p: usize,\n    scratch: &mut [Limb],\n) -> usize {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    let com_p = n - p;\n    if n < HGCD_REDUCE_THRESHOLD {\n        let new_n = limbs_half_gcd(&mut xs[p..], &mut ys[p..], m, scratch);\n        if new_n == 0 {\n            0\n        } else {\n            // Needs 2 * (p + m.n) <= 2 * (floor(n / 2) + ceil(n / 2) - 1) = 2 (n - 1)\n            limbs_half_gcd_matrix_adjust(m, p + new_n, xs, ys, p, scratch)\n        }\n    } else {\n        split_into_chunks_mut!(scratch, com_p, [scratch_0, scratch_1], scratch_2);\n        scratch_0.copy_from_slice(&xs[p..]);\n        scratch_1.copy_from_slice(&ys[p..]);\n        if limbs_half_gcd_approx(scratch_0, scratch_1, m, scratch_2) {\n            limbs_half_gcd_matrix_apply(m, xs, ys)\n        } else {\n            0\n        }\n    }\n}\n\n// Computes R -= X * Y. Result must be non-negative. Normalized down to size xs_len, and resulting\n// size is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `submul` from `mpn/generic/hgcd_reduce.c`, GMP 6.2.1.\nfn limbs_gcd_sub_mul(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> usize {\n    let mut out_len = out.len();\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    assert!(xs_len >= ys_len);\n    assert!(out_len >= xs_len);\n    let sum_len = xs_len + ys_len;\n    assert!(sum_len <= out_len + 1);\n    let mut scratch = vec![0; sum_len];\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)];\n    limbs_mul_greater_to_out(&mut scratch, xs, ys, &mut mul_scratch);\n    assert!(sum_len <= out_len || scratch[out_len] == 0);\n    let mut scratch_len = sum_len;\n    if scratch_len > out_len {\n        scratch_len -= 1;\n    }\n    assert!(!limbs_sub_greater_in_place_left(\n        out,\n        &scratch[..scratch_len]\n    ));\n    while out_len > xs_len && out[out_len - 1] == 0 {\n        out_len -= 1;\n    }\n    out_len\n}\n\n#[cfg(feature = \"test_build\")]\n#[derive(Clone, Debug, Default)]\npub struct HalfGcdMatrix1 {\n    pub data: [[Limb; 2]; 2],\n}\n\n#[cfg(not(feature = \"test_build\"))]\n#[derive(Default)]\npub(crate) struct HalfGcdMatrix1 {\n    pub(crate) data: [[Limb; 2]; 2],\n}\n\n// Sets (r;b) = (a;b) M, with M = (u00, u01; u10, u11). Vector must have space for n + 1 limbs. Uses\n// three buffers to avoid a copy\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `m.n`.\n//\n// This is equivalent to `mpn_hgcd_mul_matrix1_vector` from `mpn/generic/hgcd2.c`, GMP 6.2.1.\npub_crate_test! {limbs_half_gcd_matrix_1_mul_vector(\n    m: &HalfGcdMatrix1,\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &mut [Limb],\n) -> usize {\n    let n = xs.len();\n    assert!(ys.len() > n);\n    assert!(out.len() > n);\n    let (out_lo, out_hi) = out.split_at_mut(n);\n    let (ys_lo, ys_hi) = ys.split_at_mut(n);\n    let mut x_high = limbs_mul_limb_to_out::<DoubleLimb, Limb>(out_lo, xs, m.data[0][0]);\n    x_high.wrapping_add_assign(\n        limbs_slice_add_mul_limb_same_length_in_place_left(out_lo, ys_lo, m.data[1][0])\n    );\n    let mut y_high = limbs_slice_mul_limb_in_place(ys_lo, m.data[1][1]);\n    y_high.wrapping_add_assign(\n        limbs_slice_add_mul_limb_same_length_in_place_left(ys_lo, xs, m.data[0][1])\n    );\n    out_hi[0] = x_high;\n    ys_hi[0] = y_high;\n    if x_high == 0 && y_high == 0 {\n        n\n    } else {\n        n + 1\n    }\n}}\n\n// Compute (r;y) <- (u11 x - u01 y; -u10 x + u00 y) xs\n// ```\n// r  = u11 * x\n// r -= u01 * y\n// y *= u00\n// y -= u10 * x\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `m.len()`.\n//\n// This is equivalent to `mpn_matrix22_mul1_inverse_vector` from\n// `mpn/generic/matrix22_mul1_inverse_vector.c`, GMP 6.2.1.\npub(crate) fn limbs_half_gcd_matrix_1_mul_inverse_vector(\n    m: &HalfGcdMatrix1,\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &mut [Limb],\n) -> usize {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert_eq!(out.len(), n);\n    let h0 = limbs_mul_limb_to_out::<DoubleLimb, Limb>(out, xs, m.data[1][1]);\n    let h1 = limbs_sub_mul_limb_same_length_in_place_left(out, ys, m.data[0][1]);\n    assert_eq!(h0, h1);\n    let h0 = limbs_slice_mul_limb_in_place(ys, m.data[0][0]);\n    let h1 = limbs_sub_mul_limb_same_length_in_place_left(ys, xs, m.data[1][0]);\n    assert_eq!(h0, h1);\n    if out[n - 1] == 0 && ys[n - 1] == 0 {\n        n - 1\n    } else {\n        n\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_gcd_subdiv_step` from `mpn/generic/gcd_subdiv_step.c`, GMP 6.2.1.\npub(crate) fn limbs_gcd_subdivide_step<'a, CTX: GcdSubdivideStepContext>(\n    mut xs: &'a mut [Limb],\n    mut ys: &'a mut [Limb],\n    s: usize,\n    context: &mut CTX,\n    scratch: &mut [Limb],\n) -> usize {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert_ne!(n, 0);\n    assert!(xs[n - 1] > 0 || ys[n - 1] > 0);\n    let mut xs_len = n - slice_trailing_zeros(xs);\n    let mut ys_len = n - slice_trailing_zeros(ys);\n    let mut xs_init = &mut xs[..xs_len];\n    let mut ys_init = &mut ys[..ys_len];\n    let mut swapped = false;\n    // Arrange so that x < y, subtract y -= x, and maintain normalization.\n    match xs_len.cmp(&ys_len) {\n        Equal => {\n            match limbs_cmp_same_length(xs_init, ys_init) {\n                Equal => {\n                    // For gcdext, return the smallest of the two cofactors.\n                    if s == 0 {\n                        context.gcd_subdiv_step_hook(Some(xs_init), None, 0, -1);\n                    }\n                    return 0;\n                }\n                Greater => {\n                    swap(&mut xs, &mut ys);\n                    xs_init = &mut xs[..xs_len];\n                    ys_init = &mut ys[..ys_len];\n                    swapped.not_assign();\n                }\n                _ => {}\n            }\n        }\n        Greater => {\n            swap(&mut xs, &mut ys);\n            swap(&mut xs_len, &mut ys_len);\n            xs_init = &mut xs[..xs_len];\n            ys_init = &mut ys[..ys_len];\n            swapped.not_assign();\n        }\n        Less => {}\n    }\n    if xs_len <= s {\n        if s == 0 {\n            context.gcd_subdiv_step_hook(Some(ys_init), None, 0, i8::from(!swapped));\n        }\n        return 0;\n    }\n    assert!(!limbs_sub_greater_in_place_left(ys_init, xs_init));\n    ys_len -= slice_trailing_zeros(ys_init);\n    ys_init = &mut ys_init[..ys_len];\n    assert_ne!(ys_len, 0);\n    if ys_len <= s {\n        // Undo subtraction\n        if limbs_add_to_out_aliased(ys, ys_len, xs_init) {\n            ys[xs_len] = 1;\n        }\n        return 0;\n    }\n    // Arrange so that x < y\n    match xs_len.cmp(&ys_len) {\n        Equal => {\n            match limbs_cmp_same_length(xs_init, ys_init) {\n                Equal => {\n                    fail_on_untested_path(\"limbs_gcd_subdivide_step, c == Equal\");\n                    if s != 0 {\n                        // Just record subtraction and return\n                        context.gcd_subdiv_step_hook_with_1(i8::from(swapped));\n                        context.gcd_subdiv_step_hook_with_1(i8::from(swapped));\n                    } else {\n                        // Found gcd.\n                        context.gcd_subdiv_step_hook(Some(ys_init), None, 0, i8::from(swapped));\n                        return 0;\n                    }\n                }\n                Greater => {\n                    context.gcd_subdiv_step_hook_with_1(i8::from(swapped));\n                    swap(&mut xs, &mut ys);\n                    xs_init = &mut xs[..xs_len];\n                    ys_init = &mut ys[..ys_len];\n                    swapped.not_assign();\n                }\n                Less => {\n                    context.gcd_subdiv_step_hook_with_1(i8::from(swapped));\n                }\n            }\n        }\n        Greater => {\n            context.gcd_subdiv_step_hook_with_1(i8::from(swapped));\n            swap(&mut xs, &mut ys);\n            swap(&mut xs_len, &mut ys_len);\n            xs_init = &mut xs[..xs_len];\n            ys_init = &mut ys[..ys_len];\n            swapped.not_assign();\n        }\n        Less => {\n            context.gcd_subdiv_step_hook_with_1(i8::from(swapped));\n        }\n    }\n    if xs_len == 1 {\n        if ys_init.len() == 1 {\n            (scratch[0], ys_init[0]) = ys_init[0].div_mod(xs_init[0]);\n        } else {\n            ys_init[0] = limbs_div_limb_to_out_mod(scratch, ys_init, xs_init[0]);\n        }\n    } else {\n        limbs_div_mod_qs_to_out_rs_to_ns(scratch, ys_init, xs_init);\n    }\n    let qn = ys_len - xs_len + 1;\n    let ys_len = xs_len - slice_trailing_zeros(&ys_init[..xs_len]);\n    if ys_len <= s {\n        if s == 0 {\n            context.gcd_subdiv_step_hook(Some(xs_init), Some(scratch), qn, i8::from(swapped));\n            return 0;\n        }\n        // Quotient is one too large, so decrement it and add back X.\n        if ys_len != 0 {\n            if limbs_add_to_out_aliased(ys, ys_len, xs_init) {\n                ys[xs_len] = 1;\n                xs_len += 1;\n            }\n        } else {\n            ys[..xs_len].copy_from_slice(xs_init);\n        }\n        assert!(!limbs_sub_limb_in_place(&mut scratch[..qn], 1));\n    }\n    context.gcd_subdiv_step_hook(None, Some(scratch), qn, i8::from(swapped));\n    xs_len\n}\n\nimpl GcdSubdivideStepContext for HalfGcdMatrix<'_> {\n    // # Worst-case complexity\n    // $T(n) = O(n)$\n    //\n    // $M(n) = O(1)$\n    //\n    // where $T$ is time, $M$ is additional memory, and $n$ is `q_len`.\n    //\n    // This is equivalent to `hgcd_hook` from `mpn/generic/hgcd_step.c`, GMP 6.2.1.\n    fn gcd_subdiv_step_hook(\n        &mut self,\n        g: Option<&[Limb]>,\n        q: Option<&mut [Limb]>,\n        mut q_len: usize,\n        d: i8,\n    ) {\n        assert!(g.is_none());\n        let q = q.unwrap();\n        q_len -= slice_trailing_zeros(&q[..q_len]);\n        if q_len != 0 {\n            let (q, scratch) = q.split_at_mut(q_len);\n            limbs_half_gcd_matrix_update_q(self, q, u8::exact_from(d), scratch);\n        }\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `MPN_EXTRACT_NUMB` from `gmp-impl.h`, GMP 6.2.1.\npub(crate) const fn extract_number(count: u64, x1: Limb, x0: Limb) -> Limb {\n    (x1 << count) | (x0 >> (Limb::WIDTH - count))\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `div2` from `mpn/generic/hgcd2.c`, GMP 6.2.1, where `HGCD2_DIV2_METHOD ==\n// 1`.\npub_crate_test! {limbs_gcd_div(\n    mut n1: Limb,\n    mut n0: Limb,\n    mut d1: Limb,\n    mut d0: Limb\n) -> (Limb, Limb, Limb) {\n    let (mut q, r) = n1.div_mod(d1);\n    if q > d1 {\n        // Normalize\n        let c = LeadingZeros::leading_zeros(d1);\n        let width_comp = Limb::WIDTH - c;\n        assert_ne!(c, 0);\n        let n2 = n1 >> width_comp;\n        n1 = (n1 << c) | (n0 >> width_comp);\n        n0 <<= c;\n        d1 = (d1 << c) | (d0 >> width_comp);\n        d0 <<= c;\n        (q, n1) = Limb::xx_div_mod_y_to_qr(n2, n1, d1);\n        let (mut t1, mut t0) = Limb::x_mul_y_to_zz(q, d0);\n        if t1 > n1 || t1 == n1 && t0 > n0 {\n            assert_ne!(q, 0);\n            q -= 1;\n            (t1, t0) = Limb::xx_sub_yy_to_zz(t1, t0, d1, d0);\n        }\n        (n1, n0) = Limb::xx_sub_yy_to_zz(n1, n0, t1, t0);\n        // Undo normalization\n        (q, n1 >> c, (n0 >> c) | (n1 << width_comp))\n    } else {\n        n1 = r;\n        let (mut t1, mut t0) = Limb::x_mul_y_to_zz(q, d0);\n        if t1 >= n1 && (t1 > n1 || t0 > n0) {\n            assert_ne!(q, 0);\n            q -= 1;\n            (t1, t0) = Limb::xx_sub_yy_to_zz(t1, t0, d1, d0);\n        }\n        let (r1, r0) = Limb::xx_sub_yy_to_zz(n1, n0, t1, t0);\n        (q, r1, r0)\n    }\n}}\n\n// Reduces a, b until |a - b| (almost) fits in one limb + 1 bit. Constructs matrix M. Returns 1 if\n// we make progress, i.e. can perform at least one subtraction. Otherwise returns zero.\n//\n// This is equivalent to `mpn_hgcd2` from `mpn/generic/hgcd2.c`, GMP 6.2.1.\npub(crate) fn limbs_half_gcd_2(\n    mut x_high: Limb,\n    mut a_low: Limb,\n    mut y_high: Limb,\n    mut b_low: Limb,\n    m: &mut HalfGcdMatrix1,\n) -> bool {\n    if x_high < 2 || y_high < 2 {\n        return false;\n    }\n    let mut m01;\n    let mut m10;\n    if x_high > y_high || x_high == y_high && a_low > b_low {\n        (x_high, a_low) = Limb::xx_sub_yy_to_zz(x_high, a_low, y_high, b_low);\n        if x_high < 2 {\n            return false;\n        }\n        m01 = 1;\n        m10 = 0;\n    } else {\n        (y_high, b_low) = Limb::xx_sub_yy_to_zz(y_high, b_low, x_high, a_low);\n        if y_high < 2 {\n            return false;\n        }\n        m01 = 0;\n        m10 = 1;\n    }\n    let mut m00 = 1;\n    let mut m11 = 1;\n    const HALF_WIDTH: u64 = Limb::WIDTH >> 1;\n    const HALF_LIMIT_1: Limb = 1 << HALF_WIDTH;\n    let mut subtract_a = x_high < y_high;\n    let mut subtract_a1 = false;\n    let mut done = false;\n    loop {\n        if subtract_a {\n            subtract_a = false;\n        } else {\n            assert!(x_high >= y_high);\n            if x_high == y_high {\n                done = true;\n                break;\n            }\n            if x_high < HALF_LIMIT_1 {\n                x_high = (x_high << HALF_WIDTH) + (a_low >> HALF_WIDTH);\n                y_high = (y_high << HALF_WIDTH) + (b_low >> HALF_WIDTH);\n                break;\n            }\n            // Subtract a -= q * b, and multiply M from the right by (1 q ; 0 1), affecting the\n            // second column of M.\n            assert!(x_high > y_high);\n            (x_high, a_low) = Limb::xx_sub_yy_to_zz(x_high, a_low, y_high, b_low);\n            if x_high < 2 {\n                done = true;\n                break;\n            }\n            if x_high <= y_high {\n                // Use q = 1.\n                m01 += m00;\n                m11 += m10;\n            } else {\n                let mut q;\n                (q, x_high, a_low) = limbs_gcd_div(x_high, a_low, y_high, b_low);\n                if x_high < 2 {\n                    // A is too small, but q is correct.\n                    m01 += q * m00;\n                    m11 += q * m10;\n                    done = true;\n                    break;\n                }\n                q += 1;\n                m01 += q * m00;\n                m11 += q * m10;\n            }\n        }\n        assert!(y_high >= x_high);\n        if x_high == y_high {\n            done = true;\n            break;\n        }\n        if y_high < HALF_LIMIT_1 {\n            x_high = (x_high << HALF_WIDTH) + (a_low >> HALF_WIDTH);\n            y_high = (y_high << HALF_WIDTH) + (b_low >> HALF_WIDTH);\n            subtract_a1 = true;\n            break;\n        }\n        // Subtract b -= q * a, and multiply M from the right by (1 0 ; q 1), affecting the first\n        // column of M.\n        (y_high, b_low) = Limb::xx_sub_yy_to_zz(y_high, b_low, x_high, a_low);\n        if y_high < 2 {\n            done = true;\n            break;\n        }\n        if x_high >= y_high {\n            // Use q = 1.\n            m00 += m01;\n            m10 += m11;\n        } else {\n            let mut q;\n            (q, y_high, b_low) = limbs_gcd_div(y_high, b_low, x_high, a_low);\n            if y_high < 2 {\n                // B is too small, but q is correct.\n                m00 += q * m01;\n                m10 += q * m11;\n                done = true;\n                break;\n            }\n            q += 1;\n            m00 += q * m01;\n            m10 += q * m11;\n        }\n    }\n    // Since we discard the least significant half limb, we don't get a truly maximal M\n    // corresponding to |a - b| < 2 ^ (W + 1)).\n    if !done {\n        const HALF_LIMIT_2: Limb = 1 << (HALF_WIDTH + 1);\n        loop {\n            if subtract_a1 {\n                subtract_a1 = false;\n            } else {\n                assert!(x_high >= y_high);\n                x_high -= y_high;\n                if x_high < HALF_LIMIT_2 {\n                    break;\n                }\n                if x_high <= y_high {\n                    // Use q = 1.\n                    m01 += m00;\n                    m11 += m10;\n                } else {\n                    let mut q;\n                    (q, x_high) = x_high.div_mod(y_high);\n                    if x_high < HALF_LIMIT_2 {\n                        // A is too small, but q is correct.\n                        m01 += q * m00;\n                        m11 += q * m10;\n                        break;\n                    }\n                    q += 1;\n                    m01 += q * m00;\n                    m11 += q * m10;\n                }\n            }\n            assert!(y_high >= x_high);\n            y_high -= x_high;\n            if y_high < HALF_LIMIT_2 {\n                break;\n            }\n            if x_high >= y_high {\n                // Use q = 1.\n                m00 += m01;\n                m10 += m11;\n            } else {\n                let mut q;\n                (q, y_high) = y_high.div_mod(x_high);\n                if y_high < HALF_LIMIT_2 {\n                    // B is too small, but q is correct.\n                    m00 += q * m01;\n                    m10 += q * m11;\n                    break;\n                }\n                q += 1;\n                m00 += q * m01;\n                m10 += q * m11;\n            }\n        }\n    }\n    m.data[0][0] = m00;\n    m.data[0][1] = m01;\n    m.data[1][0] = m10;\n    m.data[1][1] = m11;\n    true\n}\n\n/// This is equivalent to `mpn_hgcd_step` from `mpn/generic/hgcd_step.c`, GMP 6.2.1.\nfn limbs_half_gcd_step(\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n    s: usize,\n    a: &mut HalfGcdMatrix,\n    scratch: &mut [Limb],\n) -> usize {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert!(n > s);\n    let mask = xs[n - 1] | ys[n - 1];\n    assert_ne!(mask, 0);\n    let (x_high, a_low, y_high, b_low) = if n == s + 1 {\n        if mask < 4 {\n            return limbs_gcd_subdivide_step(xs, ys, s, a, scratch);\n        }\n        (xs[n - 1], xs[n - 2], ys[n - 1], ys[n - 2])\n    } else if mask.get_highest_bit() {\n        (xs[n - 1], xs[n - 2], ys[n - 1], ys[n - 2])\n    } else {\n        let shift = LeadingZeros::leading_zeros(mask);\n        (\n            extract_number(shift, xs[n - 1], xs[n - 2]),\n            extract_number(shift, xs[n - 2], xs[n - 3]),\n            extract_number(shift, ys[n - 1], ys[n - 2]),\n            extract_number(shift, ys[n - 2], ys[n - 3]),\n        )\n    };\n    // Try a limbs_half_gcd_2 step\n    let mut b = HalfGcdMatrix1::default();\n    if limbs_half_gcd_2(x_high, a_low, y_high, b_low, &mut b) {\n        // Multiply A <- A * B.\n        limbs_half_gcd_matrix_mul_matrix_1(a, &b, scratch);\n        let scratch = &mut scratch[..n];\n        // Can't swap inputs, so we need to copy.\n        scratch.copy_from_slice(xs);\n        // Multiply B^(-1) (x; y).\n        limbs_half_gcd_matrix_1_mul_inverse_vector(&b, xs, scratch, ys)\n    } else {\n        limbs_gcd_subdivide_step(xs, ys, s, a, scratch)\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `MPN_GCD_SUBDIV_STEP_ITCH` from `gmp-impl.h`, GMP 6.2.1.\npub(crate) const fn limbs_gcd_subdivide_step_scratch_len(n: usize) -> usize {\n    n\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `CHOOSE_P` from `mpn/generic/gcd.c`, GMP 6.2.1.\nconst fn limbs_gcd_choose_p(n: usize) -> usize {\n    (n << 1) / 3\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `MPN_HGCD_MATRIX_INIT_ITCH` from `gmp-impl.h`, GMP 6.2.1.\npub(crate) const fn limbs_half_gcd_matrix_init_scratch_len(n: usize) -> usize {\n    (((n + 1) >> 1) + 1) << 2\n}\n\n// TODO tune\npub(crate) const HGCD_THRESHOLD: usize = 101;\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_hgcd_itch` from `mpn/generic/hgcd.c`, GMP 6.2.1.\npub(crate) fn limbs_half_gcd_scratch_len(n: usize) -> usize {\n    if n < HGCD_THRESHOLD {\n        n\n    } else {\n        // Get the recursion depth.\n        let count = LeadingZeros::leading_zeros((n - 1) / (HGCD_THRESHOLD - 1));\n        20 * ((n + 3) >> 2) + 22 * usize::exact_from(usize::WIDTH - count) + HGCD_THRESHOLD\n    }\n}\n\n// TODO tune\nconst HGCD_REDUCE_THRESHOLD: usize = 1679;\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_hgcd_reduce_itch` from `mpn/generic/hgcd_reduce.c`, GMP 6.2.1.\npub_test! {limbs_half_gcd_reduce_scratch_len(n: usize, p: usize) -> usize {\n    assert!(n >= p);\n    let diff = n - p;\n    if n < HGCD_REDUCE_THRESHOLD {\n        let scratch_len = limbs_half_gcd_scratch_len(diff);\n        // - For arbitrary p, the storage for adjust is\n        // - 2 * (p + M.n) = 2 * (p + ceil((n - p) / 2) - 1 <= n + p - 1\n        let sum = n + p - 1;\n        if scratch_len < sum {\n            sum\n        } else {\n            scratch_len\n        }\n    } else {\n        (diff << 1) + limbs_half_gcd_scratch_len(diff)\n    }\n}}\n\n// TODO tune\nconst HGCD_APPR_THRESHOLD: usize = 104;\n\n/// Destroys inputs.\n///\n/// This is equivalent to `mpn_hgcd_appr` from `mpn/generic/hgcd_appr.c`, GMP 6.2.1.\nfn limbs_half_gcd_approx(\n    mut xs: &mut [Limb],\n    mut ys: &mut [Limb],\n    a: &mut HalfGcdMatrix,\n    scratch: &mut [Limb],\n) -> bool {\n    let mut n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert_ne!(n, 0);\n    assert!(xs[n - 1] != 0 || ys[n - 1] != 0);\n    if n <= 2 {\n        fail_on_untested_path(\"limbs_half_gcd_approx, n <= 2\");\n        // Implies s = n\n        return false;\n    }\n    assert!(((n + 1) >> 1) - 1 < a.s);\n    // We aim for reduction of to W * s bits. But each time we discard some of the least significant\n    // limbs, we must keep one additional bit to account for the truncation error. We maintain the W\n    // * s - extra_bits as the current target size.\n    let mut s = (n >> 1) + 1;\n    let mut offset = 0;\n    let mut success = false;\n    if n < HGCD_APPR_THRESHOLD {\n        let mut extra_bits = 0u64;\n        let mut xs_chunk = &mut *xs;\n        let mut ys_chunk = &mut *ys;\n        while n > 2 {\n            assert!(n > s);\n            assert!(n <= s << 1);\n            let new_n = limbs_half_gcd_step(xs_chunk, ys_chunk, s, a, scratch);\n            if new_n == 0 {\n                break;\n            }\n            n = new_n;\n            xs_chunk = &mut xs_chunk[..n];\n            ys_chunk = &mut ys_chunk[..n];\n            success = true;\n            // We can truncate and discard the lower p bits whenever n <= 2 * s - p. To account for\n            // the truncation error, we must adjust s <- s + 1 - p, rather than just sbits <- sbits\n            // - p. This adjustment makes the produced matrix slightly smaller than it could be.\n            if limb_to_bit_count(n + 1) + (extra_bits << 1) <= limb_to_bit_count(s << 1) {\n                let p =\n                    bit_to_limb_count_floor(limb_to_bit_count((s << 1) - n) - (extra_bits << 1));\n                if extra_bits == 0 {\n                    // We cross a limb boundary and bump s. We can't do that if the result is that\n                    // it makes makes min(X, Y) smaller than 2^W * s.\n                    if s + 1 == n\n                        || slice_test_zero(&xs_chunk[s + 1..])\n                        || slice_test_zero(&ys_chunk[s + 1..])\n                    {\n                        continue;\n                    }\n                    extra_bits = Limb::WIDTH - 1;\n                    s += 1;\n                } else {\n                    extra_bits -= 1;\n                }\n                // Drop the p least-significant limbs.\n                offset += p;\n                xs_chunk = &mut xs_chunk[p..];\n                ys_chunk = &mut ys_chunk[p..];\n                n -= p;\n                s -= p;\n            }\n        }\n        assert_ne!(s, 0);\n        if extra_bits != 0 {\n            // We can get here only of we have dropped at least one of the least-significant bits,\n            // so we can decrement xs and ys. We can then shift left extra bits using\n            // limbs_slice_shr_in_place.\n            assert_ne!(offset, 0);\n            let xs = &mut xs[offset - 1..];\n            let ys = &mut ys[offset - 1..];\n            let (xs_head, xs_tail) = xs[..=n].split_first_mut().unwrap();\n            let (ys_head, ys_tail) = ys[..=n].split_first_mut().unwrap();\n            let comp_bits = Limb::WIDTH - extra_bits;\n            *xs_head = limbs_slice_shr_in_place(xs_tail, comp_bits);\n            *ys_head = limbs_slice_shr_in_place(ys_tail, comp_bits);\n            if xs[n] != 0 || ys[n] != 0 {\n                n += 1;\n            }\n            assert!(success);\n            while n > 2 {\n                assert!(n > s);\n                assert!(n <= s << 1);\n                n = limbs_half_gcd_step(&mut xs[..n], &mut ys[..n], s, a, scratch);\n                if n == 0 {\n                    return true;\n                }\n            }\n        }\n        if n == 2 {\n            fail_on_untested_path(\"limbs_half_gcd_approx, n == 2\");\n            assert_eq!(s, 1);\n            let mut b = HalfGcdMatrix1::default();\n            if limbs_half_gcd_2(xs[1], xs[0], ys[1], ys[0], &mut b) {\n                // Multiply A <- A * B.\n                limbs_half_gcd_matrix_mul_matrix_1(a, &b, scratch);\n                success = true;\n            }\n        }\n        success\n    } else {\n        let limit = ((3 * n) >> 2) + 1;\n        let mut p = n >> 1;\n        let new_n = limbs_half_gcd_matrix_reduce(a, xs, ys, p, scratch);\n        if new_n != 0 {\n            n = new_n;\n            xs = &mut xs[..n];\n            ys = &mut ys[..n];\n            success = true;\n        }\n        while n > limit {\n            // Needs n + 1 storage\n            n = limbs_half_gcd_step(xs, ys, s, a, scratch);\n            if n == 0 {\n                return success;\n            }\n            xs = &mut xs[..n];\n            ys = &mut ys[..n];\n            success = true;\n        }\n        if n > s + 2 {\n            p = (s << 1) - n + 1;\n            let scratch_len = limbs_half_gcd_matrix_init_scratch_len(n - p);\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(scratch_len);\n            let mut b = HalfGcdMatrix::init(n - p, scratch_lo);\n            if limbs_half_gcd_approx(&mut xs[p..], &mut ys[p..], &mut b, scratch_hi) {\n                // We always have max(A) > 2 ^ (-(W + 1)) * max(B).\n                assert!(a.n + 2 >= b.n);\n                // Furthermore, assume A ends with a quotient (1, q; 0, 1); then either q or q + 1\n                // is a correct quotient, and B will start with either (1, 0; 1, 1) or (2, 1; 1, 1).\n                // This rules out the case that the size of A * B is much smaller than the expected\n                // A.n + B.n.\n                assert!(a.n + b.n < a.s);\n                // We need a bound for of A.n + B.n. Let n be the original input size. Then ceil(n /\n                // 2) - 1 >= size of product >= A.n + B.n - 2, and it follows that A.n + B.n <=\n                // ceil(n / 2) + 1. Then 3 * (A.n + B.n) + 5 <= 3 * ceil(n / 2) + 8 is the amount of\n                // needed scratch space.\n                limbs_half_gcd_matrix_mul_matrix(a, &b, scratch_hi);\n                return true;\n            }\n        }\n        loop {\n            assert!(n > s);\n            assert!(n <= s << 1);\n            let new_n = limbs_half_gcd_step(xs, ys, s, a, scratch);\n            if new_n == 0 {\n                return success;\n            }\n            n = new_n;\n            xs = &mut xs[..n];\n            ys = &mut ys[..n];\n            success = true;\n        }\n    }\n}\n\n// Reduces x, y until |x - y| fits in n / 2 + 1 limbs. Constructs matrix A with elements of size at\n// most (n + 1) / 2 - 1. Returns new size of a, b, or zero if no reduction is possible.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_hgcd` from `mpn/generic/hgcd.c`, GMP 6.2.1.\npub(crate) fn limbs_half_gcd(\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n    a: &mut HalfGcdMatrix,\n    scratch: &mut [Limb],\n) -> usize {\n    let mut n = xs.len();\n    assert_eq!(ys.len(), n);\n    let s = (n >> 1) + 1;\n    let mut success = false;\n    if n <= s {\n        fail_on_untested_path(\"limbs_half_gcd, n <= s\");\n        return 0;\n    }\n    assert!(xs[n - 1] != 0 || ys[n - 1] != 0);\n    assert!(((n + 1) >> 1) - 1 < a.s);\n    if n >= HGCD_THRESHOLD {\n        let limit = ((3 * n) >> 2) + 1;\n        let p = n >> 1;\n        let mut new_n = limbs_half_gcd_matrix_reduce(a, xs, ys, p, scratch);\n        if new_n != 0 {\n            n = new_n;\n            success = true;\n        }\n        while n > limit {\n            // Needs n + 1 storage\n            let new_n = limbs_half_gcd_step(&mut xs[..n], &mut ys[..n], s, a, scratch);\n            if new_n == 0 {\n                return if success { n } else { 0 };\n            }\n            n = new_n;\n            success = true;\n        }\n        if n > s + 2 {\n            let p = (s << 1) - n + 1;\n            let scratch_len = limbs_half_gcd_matrix_init_scratch_len(n - p);\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(scratch_len);\n            let mut b = HalfGcdMatrix::init(n - p, scratch_lo);\n            new_n = limbs_half_gcd(&mut xs[p..n], &mut ys[p..n], &mut b, scratch_hi);\n            if new_n != 0 {\n                // We always have max(A) > 2 ^ (-(W + 1)) * max(B).\n                assert!(a.n + 2 >= b.n);\n                // Furthermore, assume A ends with a quotient (1, q; 0, 1); then either q or q + 1\n                // is a correct quotient, and B will start with either (1, 0; 1, 1) or (2, 1; 1,\n                // 1).This rules out the case that the size of A * B is much smaller than the\n                // expected A.n + B.n.\n                assert!(a.n + b.n < a.s);\n                // Needs 2 * (p + A.n) <= 2 * (2 * s - limit + 1 + limit - s - 1) = 2 * s <= 2 *\n                // (floor(n / 2) + 1) <= n + 2.\n                n = limbs_half_gcd_matrix_adjust(&b, p + new_n, xs, ys, p, scratch_hi);\n                // We need a bound for of A.n + B.n. Let n be the original input size. Then ceil(n /\n                // 2) - 1 >= size of product >= A.n + B.n - 2 and it follows that A.n + B.n <=\n                // ceil(n / 2) + 1. Then 3 * (A.n + B.n) + 5 <= 3 * ceil(n / 2) + 8 is the amount of\n                // needed scratch space.\n                limbs_half_gcd_matrix_mul_matrix(a, &b, scratch_hi);\n                success = true;\n            }\n        }\n    }\n    loop {\n        // Needs s + 3 < n\n        let new_n = limbs_half_gcd_step(&mut xs[..n], &mut ys[..n], s, a, scratch);\n        if new_n == 0 {\n            return if success { n } else { 0 };\n        }\n        n = new_n;\n        success = true;\n    }\n}\n\n// TODO tune\npub(crate) const GCD_DC_THRESHOLD: usize = 330;\n\n// X >= Y, X and Y not both even.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_gcd` from `mpn/generic/gcd.c`, GMP 6.2.1.\npub_crate_test! {limbs_gcd_reduced(out: &mut [Limb], xs: &mut [Limb], ys: &mut [Limb]) -> usize {\n    let mut xs = &mut *xs;\n    let mut ys = &mut *ys;\n    let xs_len = xs.len();\n    let mut n = ys.len();\n    assert!(xs_len >= n);\n    assert_ne!(n, 0);\n    assert_ne!(ys[n - 1], 0);\n    let mut scratch_len = max(xs_len - n + 1, limbs_gcd_subdivide_step_scratch_len(n));\n    if n >= GCD_DC_THRESHOLD {\n        let p = limbs_gcd_choose_p(n);\n        let matrix_scratch_len = limbs_half_gcd_matrix_init_scratch_len(n - p);\n        let half_gcd_scratch_len = limbs_half_gcd_scratch_len(n - p);\n        let update_scratch_len = p + n - 1;\n        scratch_len = max(\n            scratch_len,\n            matrix_scratch_len + max(half_gcd_scratch_len, update_scratch_len),\n        );\n    }\n    let mut scratch = vec![0; scratch_len];\n    let mut scratch = &mut scratch[..];\n    if xs_len > n {\n        limbs_div_mod_qs_to_out_rs_to_ns(scratch, xs, ys);\n        if slice_test_zero(&xs[..n]) {\n            out[..n].copy_from_slice(ys);\n            return n;\n        }\n    }\n    while n >= GCD_DC_THRESHOLD {\n        let xs = &mut xs[..n];\n        let ys = &mut ys[..n];\n        let p = limbs_gcd_choose_p(n);\n        let comp_p = n - p;\n        let matrix_scratch_len = limbs_half_gcd_matrix_init_scratch_len(comp_p);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(matrix_scratch_len);\n        let mut m = HalfGcdMatrix::init(comp_p, scratch_lo);\n        let new_n = limbs_half_gcd(&mut xs[p..], &mut ys[p..], &mut m, scratch_hi);\n        if new_n != 0 {\n            assert!(m.n <= (comp_p - 1) >> 1);\n            assert!(m.n + p <= (p + n - 1) >> 1);\n            // Temporary storage 2 * (p + M.n) <= p + n - 1.\n            n = limbs_half_gcd_matrix_adjust(&m, p + new_n, xs, ys, p, scratch_hi);\n        } else {\n            // Temporary storage n.\n            let out_len = n;\n            n = limbs_gcd_subdivide_step(xs, ys, 0, &mut GcdContext(out), scratch);\n            if n == 0 {\n                return out_len;\n            }\n        }\n    }\n    while n > 2 {\n        let mask = xs[n - 1] | ys[n - 1];\n        assert_ne!(mask, 0);\n        let (x_hi, x_lo, y_hi, y_lo) = if mask.get_highest_bit() {\n            (xs[n - 1], xs[n - 2], ys[n - 1], ys[n - 2])\n        } else {\n            let shift = LeadingZeros::leading_zeros(mask);\n            (\n                extract_number(shift, xs[n - 1], xs[n - 2]),\n                extract_number(shift, xs[n - 2], xs[n - 3]),\n                extract_number(shift, ys[n - 1], ys[n - 2]),\n                extract_number(shift, ys[n - 2], ys[n - 3]),\n            )\n        };\n        let mut m = HalfGcdMatrix1::default();\n        // Try a limbs_half_gcd_2 step.\n        if limbs_half_gcd_2(x_hi, x_lo, y_hi, y_lo, &mut m) {\n            n = limbs_half_gcd_matrix_1_mul_inverse_vector(\n                &m,\n                &mut scratch[..n],\n                &xs[..n],\n                &mut ys[..n],\n            );\n            swap(&mut xs, &mut scratch);\n        } else {\n            // limbs_half_gcd_2 has failed. Then either one of x or y is very small, or the\n            // difference is very small. Perform one subtraction followed by one division.\n            let out_len = n;\n            n = limbs_gcd_subdivide_step(\n                &mut xs[..n],\n                &mut ys[..n],\n                0,\n                &mut GcdContext(out),\n                scratch,\n            );\n            if n == 0 {\n                return out_len;\n            }\n        }\n    }\n    assert!(xs[n - 1] != 0 || ys[n - 1] != 0);\n    // Due to the calling convention for limbs_gcd_reduced, at most one can be even.\n    if xs[0].even() {\n        swap(&mut xs, &mut ys);\n    }\n    assert!(xs[0].odd());\n    let x_0 = xs[0];\n    let mut y_0 = ys[0];\n    if n == 1 {\n        out[0] = x_0.gcd(y_0 >> y_0.trailing_zeros());\n        return 1;\n    }\n    let mut y_1 = ys[1];\n    if y_0 == 0 {\n        y_0 = y_1;\n        y_1 = 0;\n    }\n    if y_0.even() {\n        let zeros = TrailingZeros::trailing_zeros(y_0);\n        y_0 = (y_1 << (Limb::WIDTH - zeros)) | (y_0 >> zeros);\n        y_1 >>= zeros;\n    }\n    let x_1 = xs[1];\n    // TODO try mpn_gcd_22\n    (out[1], out[0]) = DoubleLimb::join_halves(x_1, x_0)\n        .gcd(DoubleLimb::join_halves(y_1, y_0))\n        .split_in_half();\n    if out[1] == 0 {\n        1\n    } else {\n        2\n    }\n}}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/gcd/matrix_2_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Contributed by Niels Möller and Marco Bodrato.\n//\n//      Copyright © 2003-2005, 2008, 2009 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_add_same_length_to_out, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_same_length_in_place_left, limbs_sub_same_length_in_place_right,\n    limbs_sub_same_length_to_out,\n};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{Limb, MATRIX22_STRASSEN_THRESHOLD};\nuse core::cmp::Ordering::*;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `abs_sub_n` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1, where `rp != ap`.\nfn limbs_sub_abs_same_length_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    if limbs_cmp_same_length(xs, ys) == Less {\n        limbs_sub_same_length_to_out(out, ys, xs);\n        true\n    } else {\n        limbs_sub_same_length_to_out(out, xs, ys);\n        false\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`. This is equivalent to\n// `abs_sub_n` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1, where `rp == ap`.\nfn limbs_sub_abs_same_length_in_place_left(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    if limbs_cmp_same_length(xs, ys) == Less {\n        limbs_sub_same_length_in_place_right(ys, xs);\n        true\n    } else {\n        limbs_sub_same_length_in_place_left(xs, ys);\n        false\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `abs_sub_n` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1, where `rp == bp`.\nfn limbs_sub_abs_same_length_in_place_right(xs: &[Limb], ys: &mut [Limb]) -> bool {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    if limbs_cmp_same_length(xs, ys) == Less {\n        limbs_sub_same_length_in_place_left(ys, xs);\n        true\n    } else {\n        limbs_sub_same_length_in_place_right(xs, ys);\n        false\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `add_signed_n` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1, where `rp !=\n// ap`.\nfn limbs_add_signed_same_length_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    x_sign: bool,\n    ys: &[Limb],\n    y_sign: bool,\n) -> bool {\n    if x_sign == y_sign {\n        assert!(!limbs_add_same_length_to_out(out, xs, ys));\n        x_sign\n    } else {\n        x_sign != limbs_sub_abs_same_length_to_out(out, xs, ys)\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `add_signed_n` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1, where `rp ==\n// ap`.\nfn limbs_add_signed_same_length_in_place_left(\n    xs: &mut [Limb],\n    x_sign: bool,\n    ys: &[Limb],\n    y_sign: bool,\n) -> bool {\n    if x_sign == y_sign {\n        assert!(!limbs_slice_add_same_length_in_place_left(xs, ys));\n        x_sign\n    } else {\n        x_sign != limbs_sub_abs_same_length_in_place_left(xs, ys)\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_matrix22_mul_itch` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1.\npub_const_test! {limbs_matrix_mul_2_2_scratch_len(xs_len: usize, ys_len: usize) -> usize {\n    if xs_len < MATRIX22_STRASSEN_THRESHOLD || ys_len < MATRIX22_STRASSEN_THRESHOLD {\n        3 * xs_len + 2 * ys_len\n    } else {\n        3 * (xs_len + ys_len) + 5\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs_len, ys00.len())`.\npub_test! {limbs_matrix_2_2_mul_small(\n    xs00: &mut [Limb],\n    xs01: &mut [Limb],\n    xs10: &mut [Limb],\n    xs11: &mut [Limb],\n    xs_len: usize,\n    ys00: &[Limb],\n    ys01: &[Limb],\n    ys10: &[Limb],\n    ys11: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let ys_len = ys00.len();\n    // The actual output length is one limb larger than this\n    let out_len = xs_len + ys_len;\n    let (scratch, remainder) = scratch.split_at_mut(xs_len);\n    split_into_chunks_mut!(remainder, out_len, [p0, p1], _unused);\n    let mut t0 = &mut *xs00;\n    let mut t1 = &mut *xs01;\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(xs_len, ys_len)];\n    for _ in 0..2 {\n        let t0_0 = &t0[..xs_len];\n        scratch.copy_from_slice(t0_0);\n        if xs_len >= ys_len {\n            limbs_mul_greater_to_out(p0, t0_0, ys00, &mut mul_scratch);\n            let t1_0 = &t1[..xs_len];\n            limbs_mul_greater_to_out(p1, t1_0, ys11, &mut mul_scratch);\n            limbs_mul_greater_to_out(t0, t1_0, ys10, &mut mul_scratch);\n            limbs_mul_greater_to_out(t1, scratch, ys01, &mut mul_scratch);\n        } else {\n            limbs_mul_greater_to_out(p0, ys00, t0_0, &mut mul_scratch);\n            let t1_0 = &t1[..xs_len];\n            limbs_mul_greater_to_out(p1, ys11, t1_0, &mut mul_scratch);\n            limbs_mul_greater_to_out(t0, ys10, t1_0, &mut mul_scratch);\n            limbs_mul_greater_to_out(t1, ys01, scratch, &mut mul_scratch);\n        }\n        let (t0_last, t0_init) = t0[..=out_len].split_last_mut().unwrap();\n        *t0_last = Limb::from(limbs_slice_add_same_length_in_place_left(t0_init, p0));\n        let (t1_last, t1_init) = t1[..=out_len].split_last_mut().unwrap();\n        *t1_last = Limb::from(limbs_slice_add_same_length_in_place_left(t1_init, p1));\n        t0 = &mut *xs10;\n        t1 = &mut *xs11;\n    }\n}}\n\n// Algorithm:\n//\n// ```\n// / s0 \\   /  1  0   0  0 \\ / xs00 \\\n// | s1 |   |  0  1   0  1 | | xs01 |\n// | s2 |   |  0  0  -1  1 | | xs10 |\n// | s3 | = |  0  1  -1  1 | \\ xs11 /\n// | s4 |   | -1  1  -1  1 |\n// | s5 |   |  0  1   0  0 |\n// \\ s6 /   \\  0  0   1  0 /\n//\n// / t0 \\   /  1  0   0  0 \\ / ys00 \\\n// | t1 |   |  0  1   0  1 | | ys01 |\n// | t2 |   |  0  0  -1  1 | | ys10 |\n// | t3 | = |  0  1  -1  1 | \\ ys11 /\n// | t4 |   | -1  1  -1  1 |\n// | t5 |   |  0  1   0  0 |\n// \\ t6 /   \\  0  0   1  0 /\n// ```\n//\n// Note: the two matrices above are the same, but s_i and t_i are used in the same product, only for\n// i < 4, see \"A Strassen-like Matrix Multiplication suited for squaring and higher power\n// computation\" by M. Bodrato, in Proceedings of ISSAC 2010.\n//\n// ```\n// / xs00 \\   / 1 0   0   0   0   1   0 \\ / s0 * t0 \\\n// | xs01 | = | 0 0  -1   1  -1   1   0 | | s1 * t1 |\n// | xs10 |   | 0 1   0  -1   0  -1  -1 | | s2 * t2 |\n// \\ xs11 /   \\ 0 1   1  -1   0  -1   0 / | s3 * t3 |\n//\t\t                                  | s4 * t5 |\n//\t\t                                  | s5 * t6 |\n//\t\t                                  \\ s6 * t4 /\n// ```\n//\n// The scheduling uses two temporaries U0 and U1 to store products, and two, S0 and T0, to store\n// combinations of entries of the two operands.\n//\n// Computes R = R * M. Elements are numbers R = (xs00, xs01; xs10, xs11).\n//\n// Resulting elements are of size up to xs_len + ys_len + 1.\n//\n// Temporary storage: 3 * xs_len + 3 * ys_len + 5.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs_len, ys00.len())`.\n//\n// This is equivalent to `mpn_matrix22_mul_strassen` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1.\npub_test! {limbs_matrix_2_2_mul_strassen(\n    xs00: &mut [Limb],\n    xs01: &mut [Limb],\n    xs10: &mut [Limb],\n    xs11: &mut [Limb],\n    xs_len: usize,\n    ys00: &[Limb],\n    ys01: &[Limb],\n    ys10: &[Limb],\n    ys11: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let ys_len = ys00.len();\n    let sum_len = xs_len + ys_len;\n    let (s0, remainder) = scratch.split_at_mut(xs_len + 1);\n    let (s0_last, s0_init) = s0.split_last_mut().unwrap();\n    let (t0, remainder) = remainder.split_at_mut(ys_len + 1);\n    let (t0_last, t0_init) = t0.split_last_mut().unwrap();\n    let (u0, u1) = remainder.split_at_mut(sum_len + 1);\n    let u1 = &mut u1[..sum_len + 2];\n    let xs00_lo = &xs00[..xs_len];\n    let xs01_lo = &mut xs01[..=xs_len];\n    let (xs01_lo_last, xs01_lo_init) = xs01_lo.split_last_mut().unwrap();\n    let xs10 = &mut xs10[..=sum_len];\n    let xs10_lo = &xs10[..xs_len];\n    let xs11 = &mut xs11[..=sum_len];\n    let xs11_lo = &mut xs11[..xs_len];\n    // u5 = s5 * t6\n    let mut mul_scratch = vec![\n        0;\n        max!(\n            limbs_mul_to_out_scratch_len(xs_len, ys_len),\n            limbs_mul_to_out_scratch_len(xs_len, ys_len + 1),\n            limbs_mul_to_out_scratch_len(xs_len + 1, ys_len),\n            limbs_mul_to_out_scratch_len(xs_len + 1, ys_len + 1)\n        )\n    ];\n    assert!(xs01_lo_init.len() <= sum_len + 1);\n    assert!(ys10.len() <= ys_len + 1);\n    // size: xs_len, ys_len\n    limbs_mul_to_out(u0, xs01_lo_init, ys10, &mut mul_scratch);\n    // xs11 - xs10\n    let mut x11_sign = limbs_sub_abs_same_length_in_place_left(xs11_lo, xs10_lo);\n    let x01_sign = if x11_sign {\n        *xs01_lo_last = 0;\n        limbs_sub_abs_same_length_in_place_left(xs01_lo_init, xs11_lo)\n    } else {\n        // xs01 - xs10 + xs11\n        *xs01_lo_last = Limb::from(limbs_slice_add_same_length_in_place_left(\n            xs01_lo_init,\n            xs11_lo,\n        ));\n        false\n    };\n    let s0_sign = if x01_sign {\n        *s0_last = Limb::from(limbs_add_same_length_to_out(s0_init, xs01_lo_init, xs00_lo));\n        false\n    } else if *xs01_lo_last != 0 {\n        *s0_last = *xs01_lo_last;\n        if limbs_sub_same_length_to_out(s0_init, xs01_lo_init, xs00_lo) {\n            s0[xs_len] -= 1;\n        }\n        // Reverse sign! s4 = -xs00 + xs01 - xs10 + xs11\n        true\n    } else {\n        *s0_last = 0;\n        limbs_sub_abs_same_length_to_out(s0_init, xs00_lo, xs01_lo_init)\n    };\n    // u0 = s0 * t0\n    //\n    // size: xs_len, ys_len\n    limbs_mul_to_out(u1, xs00_lo, ys00, &mut mul_scratch);\n    let (u0_last, u0_init) = u0.split_last_mut().unwrap();\n    xs00[sum_len] = Limb::from(limbs_add_same_length_to_out(xs00, u0_init, &u1[..sum_len]));\n    // u0 + u5\n    assert!(xs00[sum_len] < 2);\n    let mut t0_sign = limbs_sub_abs_same_length_to_out(t0_init, ys11, ys10);\n    // Reverse sign!\n    let u1_sign = x11_sign == t0_sign;\n    // u2 = s2 * t2\n    //\n    // size: xs_len, ys_len\n    limbs_mul_to_out(u1, xs11_lo, t0_init, &mut mul_scratch);\n    u1[sum_len] = 0;\n    *t0_last = if t0_sign {\n        t0_sign = limbs_sub_abs_same_length_in_place_right(ys01, t0_init);\n        0\n    } else {\n        Limb::from(limbs_slice_add_same_length_in_place_left(t0_init, ys01))\n    };\n    if *t0_last != 0 {\n        // u3 = s3 * t3\n        //\n        // size: xs_len, ys_len + 1\n        limbs_mul_to_out(xs11, xs01_lo_init, t0, &mut mul_scratch);\n        assert!(*xs01_lo_last < 2);\n        if *xs01_lo_last != 0 {\n            limbs_slice_add_same_length_in_place_left(&mut xs11[xs_len..], t0);\n        }\n    } else {\n        // size: xs_len + 1, ys_len\n        limbs_mul_to_out(xs11, xs01_lo, t0_init, &mut mul_scratch);\n    }\n    assert!(xs11[sum_len] < 4);\n    *u0_last = 0;\n    x11_sign = if x01_sign == t0_sign {\n        // u3 + u5\n        assert!(!limbs_slice_add_same_length_in_place_left(xs11, u0));\n        false\n    } else {\n        limbs_sub_abs_same_length_in_place_right(u0, xs11)\n    };\n    let (t0_last, t0_init) = t0.split_last_mut().unwrap();\n    if t0_sign {\n        *t0_last = Limb::from(limbs_slice_add_same_length_in_place_left(t0_init, ys00));\n    } else if *t0_last != 0 {\n        if limbs_sub_same_length_in_place_left(t0_init, ys00) {\n            *t0_last -= 1;\n        }\n    } else {\n        t0_sign = limbs_sub_abs_same_length_in_place_left(t0_init, ys00);\n    }\n    // u6 = s6 * t4\n    //\n    // size: xs_len, ys_len + 1\n    limbs_mul_to_out(u0, xs10_lo, t0, &mut mul_scratch);\n    assert!(u0[sum_len] < 2);\n    let (xs01_lo_last, xs01_lo_init) = xs01_lo.split_last_mut().unwrap();\n    if x01_sign {\n        assert!(!limbs_sub_same_length_in_place_right(xs10_lo, xs01_lo_init));\n    } else if limbs_slice_add_same_length_in_place_left(xs01_lo_init, xs10_lo) {\n        *xs01_lo_last += 1;\n    }\n    t0_sign = limbs_add_signed_same_length_to_out(xs10, xs11, x11_sign, u0, t0_sign);\n    // u3 + u5 + u6\n    assert!(xs10[sum_len] < 4);\n    x11_sign =\n        limbs_add_signed_same_length_in_place_left(xs11, x11_sign, &u1[..=sum_len], u1_sign);\n    // -u2 + u3 + u5\n    assert!(xs11[sum_len] < 3);\n    // u4 = s4 * t5\n    //\n    // size: xs_len + 1, ys_len\n    limbs_mul_to_out(u0, s0, ys01, &mut mul_scratch);\n    assert!(u0[sum_len] < 2);\n    t0[ys_len] = Limb::from(limbs_add_same_length_to_out(t0, ys11, ys01));\n    // u1 = s1 * t1\n    //\n    // size: xs_len + 1, ys_len + 1\n    limbs_mul_to_out(u1, xs01_lo, t0, &mut mul_scratch);\n    assert!(u1[sum_len] < 4);\n    let (u1_last, u1_init) = u1.split_last_mut().unwrap();\n    assert_eq!(*u1_last, 0);\n    limbs_add_signed_same_length_to_out(xs01, xs11, x11_sign, u0, s0_sign);\n    // -u2 + u3 - u4 + u5\n    assert!(xs01[sum_len] < 2);\n    if x11_sign {\n        assert!(!limbs_slice_add_same_length_in_place_left(xs11, u1_init));\n    } else {\n        // u1 + u2 - u3 - u5\n        assert!(!limbs_sub_same_length_in_place_right(u1_init, xs11));\n    }\n    assert!(xs11[sum_len] < 2);\n    if t0_sign {\n        assert!(!limbs_slice_add_same_length_in_place_left(xs10, u1_init));\n    } else {\n        // u1 - u3 - u5 - u6\n        assert!(!limbs_sub_same_length_in_place_right(u1_init, xs10));\n    }\n    assert!(xs10[sum_len] < 2);\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs_len, ys00.len())`.\n//\n// This is equivalent to `mpn_matrix22_mul` from `mpn/generic/matrix22_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_matrix_2_2_mul(\n    xs00: &mut [Limb],\n    xs01: &mut [Limb],\n    xs10: &mut [Limb],\n    xs11: &mut [Limb],\n    xs_len: usize,\n    ys00: &[Limb],\n    ys01: &[Limb],\n    ys10: &[Limb],\n    ys11: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let ys_len = ys00.len();\n    assert_eq!(ys01.len(), ys_len);\n    assert_eq!(ys10.len(), ys_len);\n    assert_eq!(ys11.len(), ys_len);\n    if xs_len < MATRIX22_STRASSEN_THRESHOLD || ys_len < MATRIX22_STRASSEN_THRESHOLD {\n        limbs_matrix_2_2_mul_small(\n            xs00, xs01, xs10, xs11, xs_len, ys00, ys01, ys10, ys11, scratch,\n        );\n    } else {\n        limbs_matrix_2_2_mul_strassen(\n            xs00, xs01, xs10, xs11, xs_len, ys00, ys01, ys10, ys11, scratch,\n        );\n    }\n}}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/gcd/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2019 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::eq_mod::limbs_mod_exact_odd_limb;\nuse crate::natural::arithmetic::gcd::half_gcd::limbs_gcd_reduced;\nuse crate::natural::arithmetic::mod_op::limbs_mod_limb_alt_2;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::comparison::cmp::limbs_cmp;\nuse crate::natural::{Natural, limb_to_bit_count};\nuse crate::platform::{BMOD_1_TO_MOD_1_THRESHOLD, DoubleLimb, Limb};\nuse core::cmp::{Ordering::*, min};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{Gcd, GcdAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::slices::slice_leading_zeros;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `MPN_MOD_OR_MODEXACT_1_ODD` from `gmp-impl.h`, GMP 6.2.1, where `size > 1`.\nfn limbs_mod_or_modexact(ns: &[Limb], d: Limb) -> Limb {\n    if ns.len() < BMOD_1_TO_MOD_1_THRESHOLD {\n        limbs_mod_exact_odd_limb(ns, d, 0)\n    } else {\n        limbs_mod_limb_alt_2::<DoubleLimb, Limb>(ns, d)\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_gcd_1` from `mpn/generic/gcd_1.c`, GMP 6.2.1.\npub_test! {limbs_gcd_limb(xs: &[Limb], mut y: Limb) -> Limb {\n    assert!(xs.len() > 1);\n    assert_ne!(y, 0);\n    let mut x = xs[0];\n    let mut zeros = y.trailing_zeros();\n    y >>= zeros;\n    if x != 0 {\n        zeros = min(zeros, x.trailing_zeros());\n    }\n    x = limbs_mod_or_modexact(xs, y);\n    if x != 0 {\n        y.gcd_assign(x >> x.trailing_zeros());\n    }\n    y << zeros\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn gcd_greater_helper(mut xs: &mut [Limb], mut ys: &mut [Limb]) -> Natural {\n    let xs_zero_limbs = slice_leading_zeros(xs);\n    let ys_zero_limbs = slice_leading_zeros(ys);\n    let common_zero_limbs = min(xs_zero_limbs, ys_zero_limbs);\n    xs = &mut xs[common_zero_limbs..];\n    ys = &mut ys[common_zero_limbs..];\n    let xs_zero_bits = TrailingZeros::trailing_zeros(xs[0]);\n    let ys_zero_bits = TrailingZeros::trailing_zeros(ys[0]);\n    let common_zero_bits = min(xs_zero_bits, ys_zero_bits);\n    if common_zero_bits != 0 {\n        limbs_slice_shr_in_place(xs, common_zero_bits);\n        limbs_slice_shr_in_place(ys, common_zero_bits);\n        if *xs.last().unwrap() == 0 {\n            let n = xs.len();\n            xs = &mut xs[..n - 1];\n        }\n        if *ys.last().unwrap() == 0 {\n            let n = ys.len();\n            ys = &mut ys[..n - 1];\n        }\n    }\n    let n = if ys.len() == 1 {\n        Natural::from(if xs.len() == 1 {\n            xs[0].gcd(ys[0])\n        } else {\n            limbs_gcd_limb(xs, ys[0])\n        })\n    } else {\n        let mut out = vec![0; xs.len()];\n        let out_len = limbs_gcd_reduced(&mut out, xs, ys);\n        out.resize(out_len, 0);\n        Natural::from_owned_limbs_asc(out)\n    };\n    n << (limb_to_bit_count(common_zero_limbs) + common_zero_bits)\n}\n\nimpl Gcd<Self> for Natural {\n    type Output = Self;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s, taking both by value.\n    ///\n    /// The GCD of 0 and $n$, for any $n$, is 0. In particular, $\\gcd(0, 0) = 0$, which makes sense\n    /// if we interpret \"greatest\" to mean \"greatest by the divisibility order\".\n    ///\n    /// $$\n    /// f(x, y) = \\gcd(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Gcd;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).gcd(Natural::from(5u32)), 1);\n    /// assert_eq!(Natural::from(12u32).gcd(Natural::from(90u32)), 6);\n    /// ```\n    fn gcd(mut self, other: Self) -> Self {\n        self.gcd_assign(other);\n        self\n    }\n}\n\nimpl<'a> Gcd<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s, taking the first by value\n    /// and the second by reference.\n    ///\n    /// The GCD of 0 and $n$, for any $n$, is 0. In particular, $\\gcd(0, 0) = 0$, which makes sense\n    /// if we interpret \"greatest\" to mean \"greatest by the divisibility order\".\n    ///\n    /// $$\n    /// f(x, y) = \\gcd(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Gcd;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).gcd(&Natural::from(5u32)), 1);\n    /// assert_eq!(Natural::from(12u32).gcd(&Natural::from(90u32)), 6);\n    /// ```\n    #[inline]\n    fn gcd(mut self, other: &'a Self) -> Self {\n        self.gcd_assign(other);\n        self\n    }\n}\n\nimpl Gcd<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s, taking the first by\n    /// reference and the second by value.\n    ///\n    /// The GCD of 0 and $n$, for any $n$, is 0. In particular, $\\gcd(0, 0) = 0$, which makes sense\n    /// if we interpret \"greatest\" to mean \"greatest by the divisibility order\".\n    ///\n    /// $$\n    /// f(x, y) = \\gcd(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Gcd;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(3u32)).gcd(Natural::from(5u32)), 1);\n    /// assert_eq!((&Natural::from(12u32)).gcd(Natural::from(90u32)), 6);\n    /// ```\n    #[inline]\n    fn gcd(self, mut other: Natural) -> Natural {\n        other.gcd_assign(self);\n        other\n    }\n}\n\nimpl Gcd<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the GCD (greatest common divisor) of two [`Natural`]s, taking both by reference.\n    ///\n    /// The GCD of 0 and $n$, for any $n$, is 0. In particular, $\\gcd(0, 0) = 0$, which makes sense\n    /// if we interpret \"greatest\" to mean \"greatest by the divisibility order\".\n    ///\n    /// $$\n    /// f(x, y) = \\gcd(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Gcd;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(3u32)).gcd(&Natural::from(5u32)), 1);\n    /// assert_eq!((&Natural::from(12u32)).gcd(&Natural::from(90u32)), 6);\n    /// ```\n    #[inline]\n    fn gcd(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (x, &Natural::ZERO) => x.clone(),\n            (&Natural::ZERO, y) => y.clone(),\n            (x, y) if core::ptr::eq(x, y) => x.clone(),\n            (Natural(Small(x)), Natural(Small(y))) => Natural::from(x.gcd(*y)),\n            (Natural(Large(xs)), Natural(Small(y))) => Natural::from(limbs_gcd_limb(xs, *y)),\n            (Natural(Small(x)), Natural(Large(ys))) => Natural::from(limbs_gcd_limb(ys, *x)),\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                let c = limbs_cmp(xs, ys);\n                if c == Equal {\n                    return self.clone();\n                }\n                let mut xs = xs.clone();\n                let mut xs: &mut [Limb] = &mut xs;\n                let mut ys = ys.clone();\n                let mut ys: &mut [Limb] = &mut ys;\n                if c == Less {\n                    swap(&mut xs, &mut ys);\n                }\n                gcd_greater_helper(xs, ys)\n            }\n        }\n    }\n}\n\nimpl GcdAssign<Self> for Natural {\n    /// Replaces a [`Natural`] by its GCD (greatest common divisor) with another [`Natural`], taking\n    /// the [`Natural`] on the right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets \\gcd(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::GcdAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.gcd_assign(Natural::from(5u32));\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Natural::from(12u32);\n    /// x.gcd_assign(Natural::from(90u32));\n    /// assert_eq!(x, 6);\n    /// ```\n    #[inline]\n    fn gcd_assign(&mut self, other: Self) {\n        match (&mut *self, other) {\n            (_, Self::ZERO) => {}\n            (&mut Self::ZERO, y) => *self = y,\n            (Self(Small(x)), Self(Small(y))) => x.gcd_assign(y),\n            (Self(Large(xs)), Self(Small(y))) => {\n                *self = Self::from(limbs_gcd_limb(xs, y));\n            }\n            (Self(Small(x)), Self(Large(ys))) => {\n                *self = Self::from(limbs_gcd_limb(&ys, *x));\n            }\n            (Self(Large(xs)), Self(Large(mut ys))) => {\n                let mut xs: &mut [Limb] = &mut *xs;\n                let mut ys: &mut [Limb] = &mut ys;\n                match limbs_cmp(xs, ys) {\n                    Equal => return,\n                    Less => {\n                        swap(&mut xs, &mut ys);\n                    }\n                    _ => {}\n                }\n                *self = gcd_greater_helper(xs, ys);\n            }\n        }\n    }\n}\n\nimpl<'a> GcdAssign<&'a Self> for Natural {\n    /// Replaces a [`Natural`] by its GCD (greatest common divisor) with another [`Natural`], taking\n    /// the [`Natural`] on the right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets \\gcd(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::GcdAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.gcd_assign(&Natural::from(5u32));\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Natural::from(12u32);\n    /// x.gcd_assign(&Natural::from(90u32));\n    /// assert_eq!(x, 6);\n    /// ```\n    #[inline]\n    fn gcd_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (_, &Self::ZERO) => {}\n            (&mut Self::ZERO, y) => self.clone_from(y),\n            (Self(Small(x)), Self(Small(y))) => x.gcd_assign(*y),\n            (Self(Large(xs)), Self(Small(y))) => {\n                *self = Self::from(limbs_gcd_limb(xs, *y));\n            }\n            (Self(Small(x)), Self(Large(ys))) => {\n                *self = Self::from(limbs_gcd_limb(ys, *x));\n            }\n            (Self(Large(xs)), Self(Large(ys))) => {\n                let c = limbs_cmp(xs, ys);\n                if c == Equal {\n                    return;\n                }\n                let mut xs: &mut [Limb] = &mut *xs;\n                let mut ys = ys.clone();\n                let mut ys: &mut [Limb] = &mut ys;\n                if c == Less {\n                    swap(&mut xs, &mut ys);\n                }\n                *self = gcd_greater_helper(xs, ys);\n            }\n        }\n    }\n}\n\n/// Implementations of [`ExtendedGcd`](malachite_base::num::arithmetic::traits::ExtendedGcd), a\n/// trait for computing the extended GCD of two numbers.\npub mod extended_gcd;\n/// Code for the half-GCD algorithm, described [here](https://gmplib.org/manual/Subquadratic-GCD).\npub mod half_gcd;\n/// Code for working with 2-by-2 matrices.\npub mod matrix_2_2;\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::slices::slice_test_zero;\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, determines\n// whether that `Natural` is an integer power of 2.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_crate_test! {limbs_is_power_of_2(xs: &[Limb]) -> bool {\n    let (xs_last, xs_init) = xs.split_last().unwrap();\n    slice_test_zero(xs_init) && xs_last.is_power_of_2()\n}}\n\nimpl IsPowerOf2 for Natural {\n    /// Determines whether a [`Natural`] is an integer power of 2.\n    ///\n    /// $f(x) = (\\exists n \\in \\Z : 2^n = x)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::{IsPowerOf2, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.is_power_of_2(), false);\n    /// assert_eq!(Natural::from(123u32).is_power_of_2(), false);\n    /// assert_eq!(Natural::from(0x80u32).is_power_of_2(), true);\n    /// assert_eq!(Natural::from(10u32).pow(12).is_power_of_2(), false);\n    /// assert_eq!(\n    ///     Natural::from_str(\"1099511627776\").unwrap().is_power_of_2(),\n    ///     true\n    /// );\n    /// ```\n    fn is_power_of_2(&self) -> bool {\n        match self {\n            Self(Small(small)) => small.is_power_of_2(),\n            Self(Large(limbs)) => limbs_is_power_of_2(limbs),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::arithmetic::kronecker_symbol::{\n    limbs_kronecker_symbol, limbs_kronecker_symbol_single,\n};\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::gcd::half_gcd::{\n    GCD_DC_THRESHOLD, GcdSubdivideStepContext, HGCD_THRESHOLD, HalfGcdMatrix, HalfGcdMatrix1,\n    extract_number, limbs_gcd_div, limbs_gcd_subdivide_step, limbs_gcd_subdivide_step_scratch_len,\n    limbs_half_gcd_matrix_1_mul_inverse_vector, limbs_half_gcd_matrix_adjust,\n    limbs_half_gcd_matrix_init_scratch_len, limbs_half_gcd_matrix_mul_matrix,\n    limbs_half_gcd_matrix_mul_matrix_1, limbs_half_gcd_matrix_update_q, limbs_half_gcd_scratch_len,\n};\nuse crate::platform::{DoubleLimb, Limb};\nuse core::cmp::max;\nuse core::mem::swap;\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    DivMod, JacobiSymbol, KroneckerSymbol, LegendreSymbol, ModPowerOf2, Parity, XXSubYYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{JoinHalves, WrappingFrom};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::slices::slice_trailing_zeros;\n\n// This is equivalent to `jacobi_table` from `mpn/jacobi.c`, GMP 6.2.1.\nconst JACOBI_TABLE: [u8; 208] = [\n    0, 0, 0, 0, 0, 12, 8, 4, 1, 1, 1, 1, 1, 13, 9, 5, 2, 2, 2, 2, 2, 6, 10, 14, 3, 3, 3, 3, 3, 7,\n    11, 15, 4, 16, 6, 18, 4, 0, 12, 8, 5, 17, 7, 19, 5, 1, 13, 9, 6, 18, 4, 16, 6, 10, 14, 2, 7,\n    19, 5, 17, 7, 11, 15, 3, 8, 10, 9, 11, 8, 4, 0, 12, 9, 11, 8, 10, 9, 5, 1, 13, 10, 9, 11, 8,\n    10, 14, 2, 6, 11, 8, 10, 9, 11, 15, 3, 7, 12, 22, 24, 20, 12, 8, 4, 0, 13, 23, 25, 21, 13, 9,\n    5, 1, 25, 21, 13, 23, 14, 2, 6, 10, 24, 20, 12, 22, 15, 3, 7, 11, 16, 6, 18, 4, 16, 16, 16, 16,\n    17, 7, 19, 5, 17, 17, 17, 17, 18, 4, 16, 6, 18, 22, 19, 23, 19, 5, 17, 7, 19, 23, 18, 22, 20,\n    12, 22, 24, 20, 20, 20, 20, 21, 13, 23, 25, 21, 21, 21, 21, 22, 24, 20, 12, 22, 19, 23, 18, 23,\n    25, 21, 13, 23, 18, 22, 19, 24, 20, 12, 22, 15, 3, 7, 11, 25, 21, 13, 23, 14, 2, 6, 10,\n];\n\n// This is equivalent to `mpn_jacobi_update` from `gmp-impl.h`, GMP 6.2.1.\nfn limbs_jacobi_update(bits: u8, denominator: u8, q: Limb) -> u8 {\n    assert!(bits < 26);\n    assert!(denominator < 2);\n    assert!(q < 4);\n    JACOBI_TABLE[usize::wrapping_from(((bits << 3) + (denominator << 2)) | u8::wrapping_from(q))]\n}\n\n// This is equivalent to `hgcd_jacobi_context` from `mpn/hgcd_jacobi.c`, GMP 6.2.1.\nstruct HalfGcdJacobiContext<'a, 'b, 'c> {\n    m: &'a mut HalfGcdMatrix<'b>,\n    bits_mut: &'c mut u8,\n}\n\nimpl GcdSubdivideStepContext for HalfGcdJacobiContext<'_, '_, '_> {\n    // This is equivalent to `hgcd_jacobi_hook` from `mpn/hgcd_jacobi.c`, GMP 6.2.1.\n    fn gcd_subdiv_step_hook(\n        &mut self,\n        gs: Option<&[Limb]>,\n        qs: Option<&mut [Limb]>,\n        mut qs_len: usize,\n        d: i8,\n    ) {\n        assert!(gs.is_none());\n        assert!(d >= 0);\n        let qs = qs.unwrap();\n        qs_len -= slice_trailing_zeros(&qs[..qs_len]);\n        if qs_len != 0 {\n            let (qs, scratch) = qs.split_at_mut(qs_len);\n            let d = u8::wrapping_from(d);\n            limbs_half_gcd_matrix_update_q(self.m, qs, d, scratch);\n            *self.bits_mut = limbs_jacobi_update(*self.bits_mut, d, qs[0].mod_power_of_2(2));\n        }\n    }\n}\n\nconst HALF_WIDTH: u64 = Limb::WIDTH >> 1;\nconst TWO_POW_HALF_WIDTH: Limb = 1 << HALF_WIDTH;\nconst TWICE_TWO_POW_HALF_WIDTH: Limb = TWO_POW_HALF_WIDTH << 1;\n\n// This is equivalent to `mpn_hgcd2_jacobi` from `mpn/hgcd2_jacobi.c`, GMP 6.2.1, returning `bitsp`\n// along with a bool.\nfn limbs_half_gcd_2_jacobi(\n    mut x_1: Limb,\n    mut x_0: Limb,\n    mut y_1: Limb,\n    mut y_0: Limb,\n    m: &mut HalfGcdMatrix1,\n    mut bits: u8,\n) -> (u8, bool) {\n    if x_1 < 2 || y_1 < 2 {\n        return (bits, false);\n    }\n    let mut u00 = 1;\n    let mut u01;\n    let mut u10;\n    let mut u11 = 1;\n    (u01, u10, bits) = if x_1 > y_1 || x_1 == y_1 && x_0 > y_0 {\n        (x_1, x_0) = Limb::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0);\n        if x_1 < 2 {\n            return (bits, false);\n        }\n        (1, 0, limbs_jacobi_update(bits, 1, 1))\n    } else {\n        (y_1, y_0) = Limb::xx_sub_yy_to_zz(y_1, y_0, x_1, x_0);\n        if y_1 < 2 {\n            return (bits, false);\n        }\n        (0, 1, limbs_jacobi_update(bits, 0, 1))\n    };\n    let mut subtract_a = x_1 < y_1;\n    let mut subtract_a_1 = false;\n    loop {\n        if !subtract_a {\n            assert!(x_1 >= y_1);\n            if x_1 == y_1 {\n                m.data[0][0] = u00;\n                m.data[0][1] = u01;\n                m.data[1][0] = u10;\n                m.data[1][1] = u11;\n                return (bits, true);\n            }\n            if x_1 < TWO_POW_HALF_WIDTH {\n                x_1 = (x_1 << HALF_WIDTH) + (x_0 >> HALF_WIDTH);\n                y_1 = (y_1 << HALF_WIDTH) + (y_0 >> HALF_WIDTH);\n                break;\n            }\n            // Subtract x -= q * y, and multiply m from the right by (1 q ; 0 1), affecting the\n            // second column of m.\n            assert!(x_1 > y_1);\n            (x_1, x_0) = Limb::xx_sub_yy_to_zz(x_1, x_0, y_1, y_0);\n            if x_1 < 2 {\n                m.data[0][0] = u00;\n                m.data[0][1] = u01;\n                m.data[1][0] = u10;\n                m.data[1][1] = u11;\n                return (bits, true);\n            }\n            let bits_copy = bits;\n            bits = limbs_jacobi_update(\n                bits_copy,\n                1,\n                if x_1 <= y_1 {\n                    // Use q = 1\n                    u01 += u00;\n                    u11 += u10;\n                    1\n                } else {\n                    let mut q;\n                    (q, x_1, x_0) = limbs_gcd_div(x_1, x_0, y_1, y_0);\n                    if x_1 < 2 {\n                        // X is too small, but q is correct.\n                        u01 += q * u00;\n                        u11 += q * u10;\n                        bits = limbs_jacobi_update(bits, 1, q.mod_power_of_2(2));\n                        m.data[0][0] = u00;\n                        m.data[0][1] = u01;\n                        m.data[1][0] = u10;\n                        m.data[1][1] = u11;\n                        return (bits, true);\n                    }\n                    q += 1;\n                    u01 += q * u00;\n                    u11 += q * u10;\n                    q.mod_power_of_2(2)\n                },\n            );\n        }\n        subtract_a = false;\n        assert!(y_1 >= x_1);\n        if x_1 == y_1 {\n            m.data[0][0] = u00;\n            m.data[0][1] = u01;\n            m.data[1][0] = u10;\n            m.data[1][1] = u11;\n            return (bits, true);\n        }\n        if y_1 < TWO_POW_HALF_WIDTH {\n            x_1 = (x_1 << HALF_WIDTH) + (x_0 >> HALF_WIDTH);\n            y_1 = (y_1 << HALF_WIDTH) + (y_0 >> HALF_WIDTH);\n            subtract_a_1 = true;\n            break;\n        }\n        // Subtract b -= q a, and multiply M from the right by (1 0 ; q 1), affecting the first\n        // column of M.\n        (y_1, y_0) = Limb::xx_sub_yy_to_zz(y_1, y_0, x_1, x_0);\n        if y_1 < 2 {\n            m.data[0][0] = u00;\n            m.data[0][1] = u01;\n            m.data[1][0] = u10;\n            m.data[1][1] = u11;\n            return (bits, true);\n        }\n        let bits_copy = bits;\n        bits = limbs_jacobi_update(\n            bits_copy,\n            0,\n            if y_1 <= x_1 {\n                // Use q = 1\n                u00 += u01;\n                u10 += u11;\n                1\n            } else {\n                let mut q;\n                (q, y_1, y_0) = limbs_gcd_div(y_1, y_0, x_1, x_0);\n                if y_1 < 2 {\n                    // Y is too small, but q is correct.\n                    u00 += q * u01;\n                    u10 += q * u11;\n                    bits = limbs_jacobi_update(bits, 0, q.mod_power_of_2(2));\n                    m.data[0][0] = u00;\n                    m.data[0][1] = u01;\n                    m.data[1][0] = u10;\n                    m.data[1][1] = u11;\n                    return (bits, true);\n                }\n                q += 1;\n                u00 += q * u01;\n                u10 += q * u11;\n                q.mod_power_of_2(2)\n            },\n        );\n    }\n    // Since we discard the least significant half limb, we don't　get a truly maximal m\n    // (corresponding to |x - y| < 2^(W+1)).\n    //\n    // Single precision loop\n    loop {\n        if !subtract_a_1 {\n            assert!(x_1 >= y_1);\n            if x_1 == y_1 {\n                break;\n            }\n            x_1 -= y_1;\n            if x_1 < TWICE_TWO_POW_HALF_WIDTH {\n                break;\n            }\n            let bits_copy = bits;\n            bits = limbs_jacobi_update(\n                bits_copy,\n                1,\n                if x_1 <= y_1 {\n                    // Use q = 1\n                    u01 += u00;\n                    u11 += u10;\n                    1\n                } else {\n                    let (mut q, r) = x_1.div_mod(y_1);\n                    x_1 = r;\n                    if x_1 < TWICE_TWO_POW_HALF_WIDTH {\n                        // X is too small, but q is correct.\n                        u01 += q * u00;\n                        u11 += q * u10;\n                        bits = limbs_jacobi_update(bits, 1, q.mod_power_of_2(2));\n                        break;\n                    }\n                    q += 1;\n                    u01 += q * u00;\n                    u11 += q * u10;\n                    q.mod_power_of_2(2)\n                },\n            );\n        }\n        subtract_a_1 = false;\n        assert!(y_1 >= x_1);\n        if x_1 == y_1 {\n            break;\n        }\n        y_1 -= x_1;\n        if y_1 < TWICE_TWO_POW_HALF_WIDTH {\n            break;\n        }\n        let bits_copy = bits;\n        bits = limbs_jacobi_update(\n            bits_copy,\n            0,\n            if y_1 <= x_1 {\n                // Use q = 1\n                u00 += u01;\n                u10 += u11;\n                1\n            } else {\n                let mut q;\n                (q, y_1) = y_1.div_mod(x_1);\n                if y_1 < TWICE_TWO_POW_HALF_WIDTH {\n                    // Y is too small, but q is correct.\n                    u00 += q * u01;\n                    u10 += q * u11;\n                    bits = limbs_jacobi_update(bits, 0, q.mod_power_of_2(2));\n                    break;\n                }\n                q += 1;\n                u00 += q * u01;\n                u10 += q * u11;\n                q.mod_power_of_2(2)\n            },\n        );\n    }\n    m.data[0][0] = u00;\n    m.data[0][1] = u01;\n    m.data[1][0] = u10;\n    m.data[1][1] = u11;\n    (bits, true)\n}\n\n// Perform a few steps, using some of `limbs_half_gcd_2_jacobi`, subtraction and division. Reduces\n// the size by almost one limb or more, but never below the given size s. Return new size for x and\n// y, or 0 if no more steps are possible.\n//\n// If `limbs_half_gcd_2_jacobi` succeeds, needs temporary space for\n// `limbs_half_gcd_matrix_mul_matrix_1`, m.n limbs, and\n// `limbs_half_gcd_matrix_1_mul_inverse_vector`, n limbs. If `limbs_half_gcd_2_jacobi` fails, needs\n// space for the quotient, qs_len <= n - s + 1 limbs, for and `update_q`, qs_len + (size of the\n// appropriate column of M) <= resulting size of m.\n//\n// If n is the input size to the calling hgcd, then s = floor(N / 2) + 1, m.n < N, qs_len + matrix\n// size <= n - s + 1 + n - s = 2 (n - s) + 1 < N, so N is sufficient.\n//\n// This is equivalent to `hgcd_jacobi_step` from `mpn/hgcd_jacobi.c`, GMP 6.2.1, where `bitsp` is\n// returned along with the `usize`.\nfn limbs_half_gcd_jacobi_step(\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n    s: usize,\n    m: &mut HalfGcdMatrix,\n    mut bits: u8,\n    scratch: &mut [Limb],\n) -> (u8, usize) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    let scratch = &mut scratch[..n];\n    assert!(n > s);\n    let mask = xs[n - 1] | ys[n - 1];\n    assert_ne!(mask, 0);\n    let (x_hi, x_lo, y_hi, y_lo) = if n == s + 1 {\n        if mask < 4 {\n            let u = limbs_gcd_subdivide_step(\n                xs,\n                ys,\n                s,\n                &mut HalfGcdJacobiContext {\n                    m,\n                    bits_mut: &mut bits,\n                },\n                scratch,\n            );\n            return (bits, u);\n        }\n        (xs[n - 1], xs[n - 2], ys[n - 1], ys[n - 2])\n    } else if mask.get_highest_bit() {\n        (xs[n - 1], xs[n - 2], ys[n - 1], ys[n - 2])\n    } else {\n        let shift = LeadingZeros::leading_zeros(mask);\n        (\n            extract_number(shift, xs[n - 1], xs[n - 2]),\n            extract_number(shift, xs[n - 2], xs[n - 3]),\n            extract_number(shift, ys[n - 1], ys[n - 2]),\n            extract_number(shift, ys[n - 2], ys[n - 3]),\n        )\n    };\n    // Try a `limbs_half_gcd_2_jacobi` step\n    let mut m1 = HalfGcdMatrix1::default();\n    let b;\n    (bits, b) = limbs_half_gcd_2_jacobi(x_hi, x_lo, y_hi, y_lo, &mut m1, bits);\n    if b {\n        // Multiply m <- m * m1\n        limbs_half_gcd_matrix_mul_matrix_1(m, &m1, scratch);\n        // Can't swap inputs, so we need to copy\n        scratch.copy_from_slice(xs);\n        // Multiply m1^(-1) (x;y)\n        (\n            bits,\n            limbs_half_gcd_matrix_1_mul_inverse_vector(&m1, xs, scratch, ys),\n        )\n    } else {\n        let u = limbs_gcd_subdivide_step(\n            xs,\n            ys,\n            s,\n            &mut HalfGcdJacobiContext {\n                m,\n                bits_mut: &mut bits,\n            },\n            scratch,\n        );\n        (bits, u)\n    }\n}\n\n// Reduces x, y until |x - y| fits in n / 2 + 1 limbs. Constructs matrix m with elements of size at\n// most (n + 1) / 2 - 1. Returns new size of x, y, or zero if no reduction is possible.\n//\n// Same scratch requirements as for `limbs_half_gcd`.\n//\n// This is equivalent to `mpn_hgcd_jacobi` from `mpn/hgcd_jacobi.c`, GMP 6.2.1, where `bitsp` is\n// also returned.\nfn limbs_half_gcd_jacobi(\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n    m: &mut HalfGcdMatrix<'_>,\n    mut bits: u8,\n    scratch: &mut [Limb],\n) -> (u8, usize) {\n    let mut n = xs.len();\n    assert_eq!(ys.len(), n);\n    let s = (n >> 1) + 1;\n    let mut success = false;\n    assert!(s < n);\n    assert!(xs[n - 1] != 0 || ys[n - 1] != 0);\n    assert!(((n + 1) >> 1) - 1 < s);\n    if n >= HGCD_THRESHOLD {\n        let n2 = ((3 * n) >> 2) + 1;\n        let p = n >> 1;\n        let mut nn;\n        (bits, nn) = limbs_half_gcd_jacobi(&mut xs[p..n], &mut ys[p..n], m, bits, scratch);\n        if nn != 0 {\n            // Needs 2 * (p + m.n) <= 2 * (floor(n / 2) + ceiling(n / 2) - 1) = 2 * (n - 1)\n            n = limbs_half_gcd_matrix_adjust(m, p + nn, xs, ys, p, scratch);\n            success = true;\n        }\n        while n > n2 {\n            // Needs n + 1 storage\n            (bits, nn) =\n                limbs_half_gcd_jacobi_step(&mut xs[..n], &mut ys[..n], s, m, bits, scratch);\n            if nn == 0 {\n                return (bits, if success { n } else { 0 });\n            }\n            n = nn;\n            success = true;\n        }\n        if n > s + 2 {\n            let p = 2 * s - n + 1;\n            let scratch_len = limbs_half_gcd_matrix_init_scratch_len(n - p);\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(scratch_len);\n            let mut m1 = HalfGcdMatrix::init(n - p, scratch_lo);\n            (bits, nn) =\n                limbs_half_gcd_jacobi(&mut xs[p..n], &mut ys[p..n], &mut m1, bits, scratch_hi);\n            if nn != 0 {\n                // We always have max(m) > 2^(-(W + 1)) * max(m1)\n                assert!(m.n + 2 >= m1.n);\n                // Furthermore, assume m ends with a quotient (1, q; 0, 1); then either q or q + 1\n                // is a correct quotient, and m1 will start with either (1, 0; 1, 1) or (2, 1; 1,\n                // 1). This rules out the case that the size of m * m1 is much smaller than the\n                // expected m.n + m1.n.\n                assert!(m.n + m1.n < m.s);\n                // Needs 2 * (p + m.n) <= 2 * (2 * s - nn + 1 + nn - s - 1) = 2 * s <= 2 * (floor(n\n                // / 2) + 1) <= n + 2.\n                n = limbs_half_gcd_matrix_adjust(&m1, p + nn, xs, ys, p, scratch_hi);\n                // We need a bound for of m.n + m1.n. Let n be the original input size. Then\n                //\n                // ceiling(n / 2) - 1 >= size of product >= m.n + m1.n - 2\n                //\n                // and it follows that\n                //\n                // m.n + m1.n <= ceiling(n / 2) + 1\n                //\n                // Then 3 * (m.n + m1.n) + 5 <= 3 * ceiling(n / 2) + 8 is the amount of needed\n                // scratch space.\n                limbs_half_gcd_matrix_mul_matrix(m, &m1, scratch_hi);\n                success = true;\n            }\n        }\n    }\n    loop {\n        // Needs s + 3 < n\n        let nn;\n        (bits, nn) = limbs_half_gcd_jacobi_step(&mut xs[..n], &mut ys[..n], s, m, bits, scratch);\n        if nn == 0 {\n            return (bits, if success { n } else { 0 });\n        }\n        n = nn;\n        success = true;\n    }\n}\n\n// This is equivalent to `CHOOSE_P` from `mpn/jacobi.c`, GMP 6.2.1.\nconst fn choose_p(n: usize) -> usize {\n    (n << 1) / 3\n}\n\nconst BITS_FAIL: u8 = 31;\n\n// This is equivalent to `mpn_jacobi_finish` from `gmp-impl.h`, GMP 6.2.1, which also handles the\n// `bits == BITS_FAIL` case.\nfn limbs_jacobi_finish(bits: u8) -> i8 {\n    // (a, b) = (1,0) or (0,1)\n    if bits == BITS_FAIL {\n        0\n    } else if bits.even() {\n        1\n    } else {\n        -1\n    }\n}\n\n// This is equivalent to `mpn_jacobi_init` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_jacobi_symbol_init(a: Limb, b: Limb, s: u8) -> u8 {\n    assert!(b.odd());\n    assert!(s <= 1);\n    u8::wrapping_from((a.mod_power_of_2(2) << 2) + (b & 2)) + s\n}}\n\nstruct JacobiContext<'a> {\n    bits_mut: &'a mut u8,\n}\n\nimpl GcdSubdivideStepContext for JacobiContext<'_> {\n    // This is equivalent to `jacobi_hook` from `mpn/jacobi.c`, GMP 6.2.1.\n    fn gcd_subdiv_step_hook(\n        &mut self,\n        gs: Option<&[Limb]>,\n        qs: Option<&mut [Limb]>,\n        qs_len: usize,\n        d: i8,\n    ) {\n        if let Some(gs) = gs {\n            let gs_len = gs.len();\n            assert_ne!(gs_len, 0);\n            if gs_len != 1 || gs[0] != 1 {\n                *self.bits_mut = BITS_FAIL;\n                return;\n            }\n        }\n        if let Some(qs) = qs {\n            assert_ne!(qs_len, 0);\n            assert!(d >= 0);\n            *self.bits_mut = limbs_jacobi_update(\n                *self.bits_mut,\n                u8::wrapping_from(d),\n                qs[0].mod_power_of_2(2),\n            );\n        } else {\n            fail_on_untested_path(\"JacobiContext::gcd_subdiv_step_hook, qs == None\");\n        }\n    }\n}\n\nconst JACOBI_DC_THRESHOLD: usize = GCD_DC_THRESHOLD;\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_jacobi_n` from `mpn/jacobi.c`, GMP 6.2.1.\npub_crate_test! {\n    limbs_jacobi_symbol_same_length(xs: &mut [Limb], ys: &mut [Limb], mut bits: u8) -> i8 {\n    let mut n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert_ne!(n, 0);\n    assert!(xs[n - 1] != 0 || ys[n - 1] != 0);\n    assert!((ys[0] | xs[0]).odd());\n    let mut scratch_len = limbs_gcd_subdivide_step_scratch_len(n);\n    if n >= JACOBI_DC_THRESHOLD {\n        let p = choose_p(n);\n        let matrix_scratch_len = limbs_half_gcd_matrix_init_scratch_len(n - p);\n        let hgcd_scratch_len = limbs_half_gcd_scratch_len(n - p);\n        let update_scratch_len = p + n - 1;\n        let dc_scratch_len = matrix_scratch_len + max(hgcd_scratch_len, update_scratch_len);\n        assert!(dc_scratch_len > scratch_len);\n        scratch_len = dc_scratch_len;\n    }\n    let mut scratch = vec![0; scratch_len];\n    let mut xs: &mut [Limb] = &mut xs[..];\n    let mut ys: &mut [Limb] = &mut ys[..];\n    let mut scratch: &mut [Limb] = &mut scratch;\n    while n >= JACOBI_DC_THRESHOLD {\n        let p = (n << 1) / 3;\n        let matrix_scratch_len = limbs_half_gcd_matrix_init_scratch_len(n - p);\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(matrix_scratch_len);\n        let mut m = HalfGcdMatrix::init(n - p, scratch_lo);\n        let nn;\n        (bits, nn) = limbs_half_gcd_jacobi(&mut xs[p..n], &mut ys[p..n], &mut m, bits, scratch_hi);\n        if nn != 0 {\n            assert!(m.n <= (n - p - 1) >> 1);\n            assert!(m.n + p <= (p + n - 1) >> 1);\n            // Temporary storage 2 (p + M->n) <= p + n - 1.\n            n = limbs_half_gcd_matrix_adjust(&m, p + nn, xs, ys, p, scratch_hi);\n        } else {\n            // Temporary storage n\n            n = limbs_gcd_subdivide_step(\n                &mut xs[..n],\n                &mut ys[..n],\n                0,\n                &mut JacobiContext {\n                    bits_mut: &mut bits,\n                },\n                scratch,\n            );\n            if n == 0 {\n                return limbs_jacobi_finish(bits);\n            }\n        }\n    }\n    while n > 2 {\n        let mask = xs[n - 1] | ys[n - 1];\n        assert_ne!(mask, 0);\n        let (xs_hi, xs_lo, ys_hi, ys_lo) = if mask.get_highest_bit() {\n            (xs[n - 1], xs[n - 2], ys[n - 1], ys[n - 2])\n        } else {\n            let shift = LeadingZeros::leading_zeros(mask);\n            (\n                extract_number(shift, xs[n - 1], xs[n - 2]),\n                extract_number(shift, xs[n - 2], xs[n - 3]),\n                extract_number(shift, ys[n - 1], ys[n - 2]),\n                extract_number(shift, ys[n - 2], ys[n - 3]),\n            )\n        };\n        let mut m = HalfGcdMatrix1::default();\n        // Try a `limbs_half_gcd_2_jacobi` step\n        let b;\n        (bits, b) = limbs_half_gcd_2_jacobi(xs_hi, xs_lo, ys_hi, ys_lo, &mut m, bits);\n        if b {\n            n = limbs_half_gcd_matrix_1_mul_inverse_vector(\n                &m,\n                &mut scratch[..n],\n                &xs[..n],\n                &mut ys[..n],\n            );\n            swap(&mut xs, &mut scratch);\n        } else {\n            // `limbs_half_gcd_2_jacobi` has failed. Then either one of x or y is very small, or the\n            // difference is very small. Perform one subtraction followed by one division.\n            n = limbs_gcd_subdivide_step(\n                &mut xs[..n],\n                &mut ys[..n],\n                0,\n                &mut JacobiContext {\n                    bits_mut: &mut bits,\n                },\n                scratch,\n            );\n            if n == 0 {\n                return limbs_jacobi_finish(bits);\n            }\n        }\n    }\n    if bits >= 16 {\n        swap(&mut xs, &mut ys);\n    }\n    assert!(ys[0].odd());\n    let j = if n == 1 {\n        let x_lo = xs[0];\n        let y_lo = ys[0];\n        if y_lo == 1 {\n            1\n        } else {\n            x_lo.jacobi_symbol(y_lo)\n        }\n    } else {\n        DoubleLimb::join_halves(xs[1], xs[0]).jacobi_symbol(DoubleLimb::join_halves(ys[1], ys[0]))\n    };\n    if bits.even() {\n        j\n    } else {\n        -j\n    }\n}}\n\nimpl LegendreSymbol<Self> for Natural {\n    /// Computes the Legendre symbol of two [`Natural`]s, taking both by value.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(10u32).legendre_symbol(Natural::from(5u32)), 0);\n    /// assert_eq!(Natural::from(7u32).legendre_symbol(Natural::from(5u32)), -1);\n    /// assert_eq!(Natural::from(11u32).legendre_symbol(Natural::from(5u32)), 1);\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: Self) -> i8 {\n        assert_ne!(other, 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(&other)\n    }\n}\n\nimpl<'a> LegendreSymbol<&'a Self> for Natural {\n    /// Computes the Legendre symbol of two [`Natural`]s, taking the first by value and the second\n    /// by reference.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).legendre_symbol(&Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).legendre_symbol(&Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).legendre_symbol(&Natural::from(5u32)),\n    ///     1\n    /// );\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: &'a Self) -> i8 {\n        assert_ne!(*other, 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(other)\n    }\n}\n\nimpl LegendreSymbol<Natural> for &Natural {\n    /// Computes the Legendre symbol of two [`Natural`]s, taking both the first by reference and the\n    /// second by value.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).legendre_symbol(Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).legendre_symbol(Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).legendre_symbol(Natural::from(5u32)),\n    ///     1\n    /// );\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: Natural) -> i8 {\n        assert_ne!(other, 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(&other)\n    }\n}\n\nimpl LegendreSymbol<&Natural> for &Natural {\n    /// Computes the Legendre symbol of two [`Natural`]s, taking both by reference.\n    ///\n    /// This implementation is identical to that of [`JacobiSymbol`], since there is no\n    /// computational benefit to requiring that the denominator be prime.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LegendreSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).legendre_symbol(&Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).legendre_symbol(&Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).legendre_symbol(&Natural::from(5u32)),\n    ///     1\n    /// );\n    /// ```\n    #[inline]\n    fn legendre_symbol(self, other: &Natural) -> i8 {\n        assert_ne!(*other, 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(other)\n    }\n}\n\nimpl JacobiSymbol<Self> for Natural {\n    /// Computes the Jacobi symbol of two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(10u32).jacobi_symbol(Natural::from(5u32)), 0);\n    /// assert_eq!(Natural::from(7u32).jacobi_symbol(Natural::from(5u32)), -1);\n    /// assert_eq!(Natural::from(11u32).jacobi_symbol(Natural::from(5u32)), 1);\n    /// assert_eq!(Natural::from(11u32).jacobi_symbol(Natural::from(9u32)), 1);\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: Self) -> i8 {\n        assert_ne!(other, 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(&other)\n    }\n}\n\nimpl<'a> JacobiSymbol<&'a Self> for Natural {\n    /// Computes the Jacobi symbol of two [`Natural`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(10u32).jacobi_symbol(&Natural::from(5u32)), 0);\n    /// assert_eq!(Natural::from(7u32).jacobi_symbol(&Natural::from(5u32)), -1);\n    /// assert_eq!(Natural::from(11u32).jacobi_symbol(&Natural::from(5u32)), 1);\n    /// assert_eq!(Natural::from(11u32).jacobi_symbol(&Natural::from(9u32)), 1);\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: &'a Self) -> i8 {\n        assert_ne!(*other, 0u32);\n        assert!(other.odd());\n        (&self).kronecker_symbol(other)\n    }\n}\n\nimpl JacobiSymbol<Natural> for &Natural {\n    /// Computes the Jacobi symbol of two [`Natural`]s, taking the first by reference and the second\n    /// by value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).jacobi_symbol(Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).jacobi_symbol(Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).jacobi_symbol(Natural::from(5u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).jacobi_symbol(Natural::from(9u32)),\n    ///     1\n    /// );\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: Natural) -> i8 {\n        assert_ne!(other, 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(&other)\n    }\n}\n\nimpl JacobiSymbol<&Natural> for &Natural {\n    /// Computes the Jacobi symbol of two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is even.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::JacobiSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).jacobi_symbol(&Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).jacobi_symbol(&Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).jacobi_symbol(&Natural::from(5u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).jacobi_symbol(&Natural::from(9u32)),\n    ///     1\n    /// );\n    /// ```\n    #[inline]\n    fn jacobi_symbol(self, other: &Natural) -> i8 {\n        assert_ne!(*other, 0u32);\n        assert!(other.odd());\n        self.kronecker_symbol(other)\n    }\n}\n\nimpl KroneckerSymbol<Self> for Natural {\n    /// Computes the Kronecker symbol of two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).kronecker_symbol(Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).kronecker_symbol(Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).kronecker_symbol(Natural::from(5u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).kronecker_symbol(Natural::from(9u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).kronecker_symbol(Natural::from(8u32)),\n    ///     -1\n    /// );\n    /// ```\n    #[inline]\n    fn kronecker_symbol(self, other: Self) -> i8 {\n        (&self).kronecker_symbol(&other)\n    }\n}\n\nimpl<'a> KroneckerSymbol<&'a Self> for Natural {\n    /// Computes the Kronecker symbol of two [`Natural`]s, taking the first by value and the second\n    /// by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32).kronecker_symbol(&Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).kronecker_symbol(&Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).kronecker_symbol(&Natural::from(5u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).kronecker_symbol(&Natural::from(9u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).kronecker_symbol(&Natural::from(8u32)),\n    ///     -1\n    /// );\n    /// ```\n    #[inline]\n    fn kronecker_symbol(self, other: &'a Self) -> i8 {\n        (&self).kronecker_symbol(other)\n    }\n}\n\nimpl KroneckerSymbol<Natural> for &Natural {\n    /// Computes the Kronecker symbol of two [`Natural`]s, taking the first by reference and the\n    /// second by value.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).kronecker_symbol(Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).kronecker_symbol(Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).kronecker_symbol(Natural::from(5u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).kronecker_symbol(Natural::from(9u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).kronecker_symbol(Natural::from(8u32)),\n    ///     -1\n    /// );\n    /// ```\n    #[inline]\n    fn kronecker_symbol(self, other: Natural) -> i8 {\n        self.kronecker_symbol(&other)\n    }\n}\n\nimpl KroneckerSymbol<&Natural> for &Natural {\n    /// Computes the Kronecker symbol of two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\left ( \\frac{x}{y} \\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::KroneckerSymbol;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).kronecker_symbol(Natural::from(5u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).kronecker_symbol(Natural::from(5u32)),\n    ///     -1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).kronecker_symbol(Natural::from(5u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).kronecker_symbol(Natural::from(9u32)),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).kronecker_symbol(Natural::from(8u32)),\n    ///     -1\n    /// );\n    /// ```\n    fn kronecker_symbol(self, other: &Natural) -> i8 {\n        match (self, other) {\n            (x, &Natural::ZERO) => i8::from(*x == 1u32),\n            (&Natural::ZERO, y) => i8::from(*y == 1u32),\n            (Natural(Small(x)), Natural(Small(y))) => {\n                limbs_kronecker_symbol_single(true, *x, true, *y)\n            }\n            (Natural(Small(x)), Natural(Large(ys))) => {\n                limbs_kronecker_symbol(true, &[*x], true, ys)\n            }\n            (Natural(Large(xs)), Natural(Small(y))) => {\n                limbs_kronecker_symbol(true, xs, true, &[*y])\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => limbs_kronecker_symbol(true, xs, true, ys),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/lcm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{DivExact, DivExactAssign, Gcd, Lcm, LcmAssign};\nuse malachite_base::num::basic::traits::Zero;\n\nimpl Lcm<Self> for Natural {\n    type Output = Self;\n\n    /// Computes the LCM (least common multiple) of two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{lcm}(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Lcm;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).lcm(Natural::from(5u32)), 15);\n    /// assert_eq!(Natural::from(12u32).lcm(Natural::from(90u32)), 180);\n    /// ```\n    fn lcm(mut self, other: Self) -> Self {\n        self.lcm_assign(other);\n        self\n    }\n}\n\nimpl<'a> Lcm<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Computes the LCM (least common multiple) of two [`Natural`]s, taking the first by value and\n    /// the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{lcm}(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Lcm;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).lcm(&Natural::from(5u32)), 15);\n    /// assert_eq!(Natural::from(12u32).lcm(&Natural::from(90u32)), 180);\n    /// ```\n    #[inline]\n    fn lcm(mut self, other: &'a Self) -> Self {\n        self.lcm_assign(other);\n        self\n    }\n}\n\nimpl Lcm<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the LCM (least common multiple) of two [`Natural`]s, taking the first by reference\n    /// and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{lcm}(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Lcm;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(3u32)).lcm(Natural::from(5u32)), 15);\n    /// assert_eq!((&Natural::from(12u32)).lcm(Natural::from(90u32)), 180);\n    /// ```\n    #[inline]\n    fn lcm(self, mut other: Natural) -> Natural {\n        other.lcm_assign(self);\n        other\n    }\n}\n\nimpl Lcm<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the LCM (least common multiple) of two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\operatorname{lcm}(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Lcm;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(3u32)).lcm(&Natural::from(5u32)), 15);\n    /// assert_eq!((&Natural::from(12u32)).lcm(&Natural::from(90u32)), 180);\n    /// ```\n    #[inline]\n    fn lcm(self, other: &Natural) -> Natural {\n        if *self == 0 || *other == 0 {\n            return Natural::ZERO;\n        }\n        let gcd = self.gcd(other);\n        // Division is slower than multiplication, so we choose the arguments to div_exact to be as\n        // small as possible. This also allows the special case of lcm(x, y) when x is a multiple of\n        // y to be quickly reduced to x.\n        if self >= other {\n            self * other.div_exact(gcd)\n        } else {\n            other * self.div_exact(gcd)\n        }\n    }\n}\n\nimpl LcmAssign<Self> for Natural {\n    /// Replaces a [`Natural`] by its LCM (least common multiple) with another [`Natural`], taking\n    /// the [`Natural`] on the right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets \\operatorname{lcm}(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LcmAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.lcm_assign(Natural::from(5u32));\n    /// assert_eq!(x, 15);\n    ///\n    /// let mut x = Natural::from(12u32);\n    /// x.lcm_assign(Natural::from(90u32));\n    /// assert_eq!(x, 180);\n    /// ```\n    #[inline]\n    fn lcm_assign(&mut self, mut other: Self) {\n        if *self == 0 {\n            return;\n        } else if other == 0 {\n            *self = Self::ZERO;\n            return;\n        }\n        let gcd = (&*self).gcd(&other);\n        if *self >= other {\n            other.div_exact_assign(gcd);\n        } else {\n            self.div_exact_assign(gcd);\n        }\n        *self *= other;\n    }\n}\n\nimpl<'a> LcmAssign<&'a Self> for Natural {\n    /// Replaces a [`Natural`] by its LCM (least common multiple) with another [`Natural`], taking\n    /// the [`Natural`] on the right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets \\operatorname{lcm}(x, y).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::LcmAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.lcm_assign(&Natural::from(5u32));\n    /// assert_eq!(x, 15);\n    ///\n    /// let mut x = Natural::from(12u32);\n    /// x.lcm_assign(&Natural::from(90u32));\n    /// assert_eq!(x, 180);\n    /// ```\n    #[inline]\n    fn lcm_assign(&mut self, other: &'a Self) {\n        if *self == 0 {\n            return;\n        } else if *other == 0 {\n            *self = Self::ZERO;\n            return;\n        }\n        self.div_exact_assign((&*self).gcd(other));\n        *self *= other;\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2011 Sebastian Pancratz\n//\n//      Copyright © 2011 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase, CeilingLogBasePowerOf2, CheckedLogBase, CheckedLogBase2,\n    CheckedLogBasePowerOf2, DivExactAssign, FloorLogBase, FloorLogBasePowerOf2, Pow,\n};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::num::conversion::traits::SciMantissaAndExponent;\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nimpl Natural {\n    /// Calculates the approximate natural logarithm of a nonzero [`Natural`].\n    ///\n    /// $f(x) = (1+\\varepsilon)(\\ln x)$, where $|\\varepsilon| < 2^{-52}.$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::float::NiceFloat;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     NiceFloat(Natural::from(10u32).approx_ln()),\n    ///     NiceFloat(2.3025850929940455)\n    /// );\n    /// assert_eq!(\n    ///     NiceFloat(Natural::from(10u32).pow(10000).approx_ln()),\n    ///     NiceFloat(23025.850929940454)\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `fmpz_dlog` from `fmpz/dlog.c`, FLINT 2.7.1.\n    pub fn approx_ln(&self) -> f64 {\n        assert_ne!(*self, 0);\n        let (mantissa, exponent): (f64, u64) = self.sci_mantissa_and_exponent();\n        libm::log(mantissa) + (exponent as f64) * core::f64::consts::LN_2\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\nfn log_base_helper(x: &Natural, base: &Natural) -> (u64, bool) {\n    assert_ne!(*x, 0);\n    assert!(*base > 1);\n    if *x == 1 {\n        return (0, true);\n    } else if x < base {\n        return (0, false);\n    }\n    let mut log = u64::rounding_from(x.approx_ln() / base.approx_ln(), Floor).0;\n    let mut power = base.pow(log);\n    match power.cmp(x) {\n        Equal => (log, true),\n        Less => loop {\n            power *= base;\n            match power.cmp(x) {\n                Equal => {\n                    return (log + 1, true);\n                }\n                Less => {\n                    log += 1;\n                }\n                Greater => {\n                    return (log, false);\n                }\n            }\n        },\n        Greater => loop {\n            power.div_exact_assign(base);\n            match power.cmp(x) {\n                Equal => {\n                    return (log - 1, true);\n                }\n                Less => {\n                    return (log - 1, false);\n                }\n                Greater => {\n                    log -= 1;\n                }\n            }\n        },\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n//\n// Also returns base^p and p, where base^p is close to x.\npub(crate) fn log_base_helper_with_pow(x: &Natural, base: &Natural) -> (u64, bool, Natural, u64) {\n    assert_ne!(*x, 0);\n    assert!(*base > 1);\n    if *x == 1 {\n        return (0, true, Natural::ONE, 0);\n    } else if x < base {\n        return (0, false, Natural::ONE, 0);\n    }\n    let mut log = (x.approx_ln() / base.approx_ln()) as u64;\n    let mut power = base.pow(log);\n    match power.cmp(x) {\n        Equal => (log, true, power, log),\n        Less => loop {\n            power *= base;\n            match power.cmp(x) {\n                Equal => {\n                    log += 1;\n                    return (log, true, power, log);\n                }\n                Less => {\n                    log += 1;\n                }\n                Greater => {\n                    return (log, false, power, log + 1);\n                }\n            }\n        },\n        Greater => loop {\n            power.div_exact_assign(base);\n            match power.cmp(x) {\n                Equal => {\n                    log -= 1;\n                    return (log, true, power, log);\n                }\n                Less => {\n                    log -= 1;\n                    return (log, false, power, log);\n                }\n                Greater => {\n                    log -= 1;\n                }\n            }\n        },\n    }\n}\n\nimpl FloorLogBase<&Natural> for &Natural {\n    type Output = u64;\n\n    /// Returns the floor of the base-$b$ logarithm of a positive [`Natural`].\n    ///\n    /// $f(x, b) = \\lfloor\\log_b x\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorLogBase;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(80u32).floor_log_base(&Natural::from(3u32)), 3);\n    /// assert_eq!(Natural::from(81u32).floor_log_base(&Natural::from(3u32)), 4);\n    /// assert_eq!(Natural::from(82u32).floor_log_base(&Natural::from(3u32)), 4);\n    /// assert_eq!(\n    ///     Natural::from(4294967296u64).floor_log_base(&Natural::from(10u32)),\n    ///     9\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `fmpz_flog` from `fmpz/flog.c`, FLINT 2.7.1.\n    fn floor_log_base(self, base: &Natural) -> u64 {\n        if let Some(log_base) = base.checked_log_base_2() {\n            return self.floor_log_base_power_of_2(log_base);\n        }\n        log_base_helper(self, base).0\n    }\n}\n\nimpl CeilingLogBase<&Natural> for &Natural {\n    type Output = u64;\n\n    /// Returns the ceiling of the base-$b$ logarithm of a positive [`Natural`].\n    ///\n    /// $f(x, b) = \\lceil\\log_b x\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingLogBase;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(80u32).ceiling_log_base(&Natural::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(81u32).ceiling_log_base(&Natural::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(82u32).ceiling_log_base(&Natural::from(3u32)),\n    ///     5\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(4294967296u64).ceiling_log_base(&Natural::from(10u32)),\n    ///     10\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `fmpz_clog` from `fmpz/clog.c`, FLINT 2.7.1.\n    fn ceiling_log_base(self, base: &Natural) -> u64 {\n        if let Some(log_base) = base.checked_log_base_2() {\n            return self.ceiling_log_base_power_of_2(log_base);\n        }\n        let (log, exact) = log_base_helper(self, base);\n        if exact { log } else { log + 1 }\n    }\n}\n\nimpl CheckedLogBase<&Natural> for &Natural {\n    type Output = u64;\n\n    /// Returns the base-$b$ logarithm of a positive [`Natural`]. If the [`Natural`] is not a power\n    /// of $b$, then `None` is returned.\n    ///\n    /// $$\n    /// f(x, b) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\log_b x) & \\text{if} \\\\quad \\log_b x \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedLogBase;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(80u32).checked_log_base(&Natural::from(3u32)),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(81u32).checked_log_base(&Natural::from(3u32)),\n    ///     Some(4)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(82u32).checked_log_base(&Natural::from(3u32)),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(4294967296u64).checked_log_base(&Natural::from(10u32)),\n    ///     None\n    /// );\n    /// ```\n    fn checked_log_base(self, base: &Natural) -> Option<u64> {\n        if let Some(log_base) = base.checked_log_base_2() {\n            return self.checked_log_base_power_of_2(log_base);\n        }\n        let (log, exact) = log_base_helper(self, base);\n        if exact { Some(log) } else { None }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::is_power_of_2::limbs_is_power_of_2;\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::natural::{Natural, limb_to_bit_count};\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase2, CheckedLogBase2, FloorLogBase2};\nuse malachite_base::slices::slice_test_zero;\n\n// Given the limbs of a `Natural`, returns the floor of its base-2 logarithm.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// $f((d_i)_ {i=0}^k) = \\lfloor\\log_2 x\\rfloor$, where $x = \\sum_{i=0}^kB^id_i$ and $B$ is one more\n// than `Limb::MAX`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_floor_log_base_2(xs: &[Limb]) -> u64 {\n    limbs_significant_bits(xs) - 1\n}}\n\n// Given the limbs of a `Natural`, returns the ceiling of its base-2 logarithm.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// $f((d_i)_ {i=0}^k) = \\lceil\\log_2 x\\rceil$, where $x = \\sum_{i=0}^kB^id_i$ and $B$ is one more\n// than `Limb::MAX`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_ceiling_log_base_2(xs: &[Limb]) -> u64 {\n    let floor_log_base_2 = limbs_floor_log_base_2(xs);\n    if limbs_is_power_of_2(xs) {\n        floor_log_base_2\n    } else {\n        floor_log_base_2 + 1\n    }\n}}\n\n// Given the limbs of a `Natural`, returns the its base-2 logarithm. If the `Natural` is not a power\n// of 2, returns `None`.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// $$\n// f((d_i)_ {i=0}^k) = \\\\begin{cases}\n//     \\operatorname{Some}(\\log_2 x) & \\text{if} \\\\quad \\log_2 x \\in \\Z, \\\\\\\\\n//     \\operatorname{None} & \\textrm{otherwise}.\n// \\\\end{cases}\n// $$\n// where $x = \\sum_{i=0}^kB^id_i$ and $B$ is one more than `Limb::MAX`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_checked_log_base_2(xs: &[Limb]) -> Option<u64> {\n    let (xs_last, xs_init) = xs.split_last().unwrap();\n    if slice_test_zero(xs_init) {\n        xs_last\n            .checked_log_base_2()\n            .map(|log| log + limb_to_bit_count(xs_init.len()))\n    } else {\n        None\n    }\n}}\n\nimpl FloorLogBase2 for &Natural {\n    type Output = u64;\n\n    /// Returns the floor of the base-2 logarithm of a positive [`Natural`].\n    ///\n    /// $f(x) = \\lfloor\\log_2 x\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorLogBase2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).floor_log_base_2(), 1);\n    /// assert_eq!(Natural::from(100u32).floor_log_base_2(), 6);\n    /// ```\n    fn floor_log_base_2(self) -> u64 {\n        match self {\n            Natural(Small(small)) => small.floor_log_base_2(),\n            Natural(Large(limbs)) => limbs_floor_log_base_2(limbs),\n        }\n    }\n}\n\nimpl CeilingLogBase2 for &Natural {\n    type Output = u64;\n\n    /// Returns the ceiling of the base-2 logarithm of a positive [`Natural`].\n    ///\n    /// $f(x) = \\lceil\\log_2 x\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingLogBase2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).ceiling_log_base_2(), 2);\n    /// assert_eq!(Natural::from(100u32).ceiling_log_base_2(), 7);\n    /// ```\n    fn ceiling_log_base_2(self) -> u64 {\n        match self {\n            Natural(Small(small)) => small.ceiling_log_base_2(),\n            Natural(Large(limbs)) => limbs_ceiling_log_base_2(limbs),\n        }\n    }\n}\n\nimpl CheckedLogBase2 for &Natural {\n    type Output = u64;\n\n    /// Returns the base-2 logarithm of a positive [`Natural`]. If the [`Natural`] is not a power of\n    /// 2, then `None` is returned.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\log_2 x) & \\text{if} \\\\quad \\log_2 x \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::CheckedLogBase2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(3u32).checked_log_base_2(), None);\n    /// assert_eq!(Natural::from(4u32).checked_log_base_2(), Some(2));\n    /// assert_eq!(\n    ///     Natural::from_str(\"1267650600228229401496703205376\")\n    ///         .unwrap()\n    ///         .checked_log_base_2(),\n    ///     Some(100)\n    /// );\n    /// ```\n    fn checked_log_base_2(self) -> Option<u64> {\n        match self {\n            Natural(Small(small)) => small.checked_log_base_2(),\n            Natural(Large(limbs)) => limbs_checked_log_base_2(limbs),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::is_power_of_2::limbs_is_power_of_2;\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBasePowerOf2, CheckedLogBasePowerOf2, DivMod, FloorLogBasePowerOf2,\n};\n\n// Given the limbs of a `Natural`, returns the floor of its base-$2^p$ logarithm.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// $f((d_i)_ {i=0}^k, p) = \\lfloor\\log_{2^p} x\\rfloor$, where $x = \\sum_{i=0}^kB^id_i$ and $B$ is\n// one more than `Limb::MAX`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty or `pow` is 0.\npub_test! {limbs_floor_log_base_power_of_2(xs: &[Limb], pow: u64) -> u64 {\n    assert_ne!(pow, 0);\n    (limbs_significant_bits(xs) - 1) / pow\n}}\n\n// Given the limbs of a `Natural`, returns the ceiling of its base-$2^p$ logarithm.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// $f((d_i)_ {i=0}^k, p) = \\lceil\\log_{2^p} x\\rceil$, where $x = \\sum_{i=0}^kB^id_i$ and $B$ is one\n// more than `Limb::MAX`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or `pow` is 0.\npub_test! {limbs_ceiling_log_base_power_of_2(xs: &[Limb], pow: u64) -> u64 {\n    assert_ne!(pow, 0);\n    let significant_bits_m_1 = limbs_significant_bits(xs) - 1;\n    let (floor_log, rem) = significant_bits_m_1.div_mod(pow);\n    if limbs_is_power_of_2(xs) && rem == 0 {\n        floor_log\n    } else {\n        floor_log + 1\n    }\n}}\n\n// Given the limbs of a `Natural`, returns the its base-$2^p$ logarithm. If the `Natural` is not a\n// power of $2^p$, returns `None`.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// $$\n// f((d_i)_ {i=0}^k, p) = \\\\begin{cases}\n//     \\operatorname{Some}(\\log_{2^p} x) & \\text{if} \\\\quad \\log_{2^p} x \\in \\Z, \\\\\\\\\n//     \\operatorname{None} & \\textrm{otherwise}.\n// \\\\end{cases}\n// $$\n// where $x = \\sum_{i=0}^kB^id_i$ and $B$ is one more than `Limb::MAX`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty or `pow` is 0.\npub_test! {limbs_checked_log_base_power_of_2(xs: &[Limb], pow: u64) -> Option<u64> {\n    assert_ne!(pow, 0);\n    let significant_bits_m_1 = limbs_significant_bits(xs) - 1;\n    let (floor_log, rem) = significant_bits_m_1.div_mod(pow);\n    if limbs_is_power_of_2(xs) && rem == 0 {\n        Some(floor_log)\n    } else {\n        None\n    }\n}}\n\nimpl FloorLogBasePowerOf2<u64> for &Natural {\n    type Output = u64;\n\n    /// Returns the floor of the base-$2^k$ logarithm of a positive [`Natural`].\n    ///\n    /// $f(x, k) = \\lfloor\\log_{2^k} x\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or `pow` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorLogBasePowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(100u32).floor_log_base_power_of_2(2), 3);\n    /// assert_eq!(Natural::from(4294967296u64).floor_log_base_power_of_2(8), 4);\n    /// ```\n    fn floor_log_base_power_of_2(self, pow: u64) -> u64 {\n        match self {\n            Natural(Small(small)) => small.floor_log_base_power_of_2(pow),\n            Natural(Large(limbs)) => limbs_floor_log_base_power_of_2(limbs, pow),\n        }\n    }\n}\n\nimpl CeilingLogBasePowerOf2<u64> for &Natural {\n    type Output = u64;\n\n    /// Returns the ceiling of the base-$2^k$ logarithm of a positive [`Natural`].\n    ///\n    /// $f(x, k) = \\lceil\\log_{2^k} x\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or `pow` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingLogBasePowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(100u32).ceiling_log_base_power_of_2(2), 4);\n    /// assert_eq!(\n    ///     Natural::from(4294967296u64).ceiling_log_base_power_of_2(8),\n    ///     4\n    /// );\n    /// ```\n    fn ceiling_log_base_power_of_2(self, pow: u64) -> u64 {\n        match self {\n            Natural(Small(small)) => small.ceiling_log_base_power_of_2(pow),\n            Natural(Large(limbs)) => limbs_ceiling_log_base_power_of_2(limbs, pow),\n        }\n    }\n}\n\nimpl CheckedLogBasePowerOf2<u64> for &Natural {\n    type Output = u64;\n\n    /// Returns the base-$2^k$ logarithm of a positive [`Natural`]. If the [`Natural`] is not a\n    /// power of $2^k$, then `None` is returned.\n    ///\n    /// $$\n    /// f(x, k) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\log_{2^k} x) & \\text{if} \\\\quad \\log_{2^k} x \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or `pow` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedLogBasePowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(100u32).checked_log_base_power_of_2(2), None);\n    /// assert_eq!(\n    ///     Natural::from(4294967296u64).checked_log_base_power_of_2(8),\n    ///     Some(4)\n    /// );\n    /// ```\n    fn checked_log_base_power_of_2(self, pow: u64) -> Option<u64> {\n        match self {\n            Natural(Small(small)) => small.checked_log_base_power_of_2(pow),\n            Natural(Large(limbs)) => limbs_checked_log_base_power_of_2(limbs, pow),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of [`AbsDiff`](malachite_base::num::arithmetic::traits::AbsDiff) and\n/// [`AbsDiffAssign`](malachite_base::num::arithmetic::traits::AbsDiffAssign), traits for getting\n/// the absolute value of the difference between two numbers.\npub mod abs_diff;\n/// Addition of [`Natural`](super::Natural)s.\npub mod add;\n/// Implementations of [`AddMul`](malachite_base::num::arithmetic::traits::AddMul) and\n/// [`AddMulAssign`](malachite_base::num::arithmetic::traits::AddMulAssign), traits for adding a\n/// number and the product of two other numbers.\npub mod add_mul;\n/// Implementations of\n/// [`BinomialCoefficient`](malachite_base::num::arithmetic::traits::BinomialCoefficient), a trait\n/// for computing the binomial coefficient of two numbers.\npub mod binomial_coefficient;\n/// Implementations of [`CheckedSub`](malachite_base::num::arithmetic::traits::CheckedSub), a trait\n/// for subtracting two numbers and checking whether the result is representable.\npub mod checked_sub;\n/// Implementations of [`CheckedSubMul`](malachite_base::num::arithmetic::traits::CheckedSubMul), a\n/// trait for subtracting the product of two numbers from another number, and checking whether the\n/// result is representable.\npub mod checked_sub_mul;\n/// Implementations of [`CoprimeWith`](malachite_base::num::arithmetic::traits::CoprimeWith), a\n/// trait for determining whether two numbers are coprime.\npub mod coprime_with;\n/// Division of [`Natural`](super::Natural)s.\npub mod div;\n/// Implementations of [`DivExact`](malachite_base::num::arithmetic::traits::DivExact) and\n/// [`DivExactAssign`](malachite_base::num::arithmetic::traits::DivExactAssign), traits for dividing\n/// two numbers when it's known that the division is exact.\npub mod div_exact;\n/// Implementations of raits for simultaneously finding the quotient and remainder of two numbers,\n/// subject to various rounding rules.\n///\n/// These are the traits:\n///\n/// | rounding     | by value or reference           | by mutable reference (assignment)      |\n/// |--------------|---------------------------------|----------------------------------------|\n/// | towards $-\\infty$ | [`DivMod`](malachite_base::num::arithmetic::traits::DivMod) | [`DivAssignMod`](malachite_base::num::arithmetic::traits::DivAssignMod) |\n/// | towards 0         | [`DivRem`](malachite_base::num::arithmetic::traits::DivRem) | [`DivAssignRem`](malachite_base::num::arithmetic::traits::DivAssignRem) |\n/// | towards $\\infty$  | [`CeilingDivNegMod`](malachite_base::num::arithmetic::traits::CeilingDivNegMod) | [`CeilingDivAssignNegMod`](malachite_base::num::arithmetic::traits::CeilingDivAssignNegMod) |\n///\n/// [`CeilingDivNegMod`](malachite_base::num::arithmetic::traits::CeilingDivNegMod) returns a\n/// remainder greater than or equal to zero. This allows the remainder to have an unsigned type, but\n/// modifies the usual relation $x = qy + r$ to $x = qy - r$.\npub mod div_mod;\n/// Implementations of [`DivRound`](malachite_base::num::arithmetic::traits::DivRound) and\n/// [`DivExactAssign`](malachite_base::num::arithmetic::traits::DivRoundAssign), traits for dividing\n/// two numbers according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode).\npub mod div_round;\n/// Implementations of [`DivisibleBy`](malachite_base::num::arithmetic::traits::DivisibleBy), a\n/// trait for determining whether one number is divisible by another.\npub mod divisible_by;\n/// Implementations of\n/// [`DivisibleByPowerOf2`](malachite_base::num::arithmetic::traits::DivisibleByPowerOf2), a trait\n/// for determining whether a number is divisible by $2^k$.\npub mod divisible_by_power_of_2;\n/// Implementations of [`EqMod`](malachite_base::num::arithmetic::traits::EqMod), a trait for\n/// determining whether one number is equal by another modulo a third.\npub mod eq_mod;\n/// Implementations of [`EqModPowerOf2`](malachite_base::num::arithmetic::traits::EqModPowerOf2), a\n/// trait for determining whether one number is equal to another modulo $2^k$.\npub mod eq_mod_power_of_2;\n/// Implementations of [`Factorial`](malachite_base::num::arithmetic::traits::Factorial),\n/// [`DoubleFactorial`](malachite_base::num::arithmetic::traits::DoubleFactorial),\n/// [`Multifactorial`](malachite_base::num::arithmetic::traits::Multifactorial), and\n/// [`Subfactorial`](malachite_base::num::arithmetic::traits::Subfactorial).\npub mod factorial;\n#[cfg(feature = \"float_helpers\")]\npub mod float_add;\n#[cfg(feature = \"float_helpers\")]\npub mod float_div;\n#[cfg(feature = \"float_helpers\")]\npub mod float_extras;\n#[cfg(feature = \"float_helpers\")]\npub mod float_mul;\n#[cfg(feature = \"float_helpers\")]\npub mod float_reciprocal;\n#[cfg(feature = \"float_helpers\")]\npub mod float_reciprocal_sqrt;\n#[cfg(feature = \"float_helpers\")]\npub mod float_sqrt;\n#[cfg(feature = \"float_helpers\")]\npub mod float_square;\n#[cfg(feature = \"float_helpers\")]\npub mod float_sub;\n/// Implementations of [`Gcd`](malachite_base::num::arithmetic::traits::Gcd) and\n/// [`GcdAssign`](malachite_base::num::arithmetic::traits::GcdAssign), traits for computing the GCD\n/// (greatest common divisor) of two numbers.\npub mod gcd;\n/// Implementations of [`IsPowerOf2`](malachite_base::num::arithmetic::traits::IsPowerOf2), a trait\n/// for determining whether a number is an integer power of 2.\npub mod is_power_of_2;\n/// Implementations of [`LegendreSymbol`](malachite_base::num::arithmetic::traits::LegendreSymbol),\n/// [`JacobiSymbol`](malachite_base::num::arithmetic::traits::JacobiSymbol), and\n/// [`KroneckerSymbol`](malachite_base::num::arithmetic::traits::KroneckerSymbol), traits for\n/// computing the Legendre, Jacobi, and Kronecker symbols of two numbers.\npub mod kronecker_symbol;\n/// Implementations of [`Lcm`](malachite_base::num::arithmetic::traits::Lcm),\n/// [`LcmAssign`](malachite_base::num::arithmetic::traits::LcmAssign), and\n/// [`CheckedLcm`](malachite_base::num::arithmetic::traits::CheckedLcm), traits for computing the\n/// LCM (least common multiple) of two numbers.\npub mod lcm;\n/// Implementations of traits for taking the base-$b$ logarithm of a number.\n///\n/// The traits are [`FloorLogBase`](malachite_base::num::arithmetic::traits::FloorLogBase),\n/// [`CeilingLogBase`](malachite_base::num::arithmetic::traits::CeilingLogBase), and\n/// [`CheckedLogBase`](malachite_base::num::arithmetic::traits::CheckedLogBase).\npub mod log_base;\n/// Implementations of traits for taking the base-2 logarithm of a number.\n///\n/// The traits are [`FloorLogBase2`](malachite_base::num::arithmetic::traits::FloorLogBase2),\n/// [`CeilingLogBase2`](malachite_base::num::arithmetic::traits::CeilingLogBase2), and\n/// [`CheckedLogBase2`](malachite_base::num::arithmetic::traits::CheckedLogBase2).\npub mod log_base_2;\n/// Implementations of traits for taking the base-$2^k$ logarithm of a number.\n///\n/// The traits are\n/// [`FloorLogBasePowerOf2`](malachite_base::num::arithmetic::traits::FloorLogBasePowerOf2),\n/// [`CeilingLogBasePowerOf2`](malachite_base::num::arithmetic::traits::CeilingLogBasePowerOf2), and\n/// [`CheckedLogBasePowerOf2`](malachite_base::num::arithmetic::traits::CheckedLogBasePowerOf2).\npub mod log_base_power_of_2;\n/// Implementations of [`ModAdd`](malachite_base::num::arithmetic::traits::ModAdd) and\n/// [`ModAddAssign`](malachite_base::num::arithmetic::traits::ModAddAssign), traits for adding two\n/// numbers modulo another number.\npub mod mod_add;\n/// Implementations of [`ModInverse`](malachite_base::num::arithmetic::traits::ModInverse), a trait\n/// for finding the multiplicative inverse of a number modulo another number.\npub mod mod_inverse;\n/// Implementations of [`ModIsReduced`](malachite_base::num::arithmetic::traits::ModIsReduced), a\n/// trait for checking whether a number is reduced modulo another number.\npub mod mod_is_reduced;\n/// Implementations of traits for multiplying two numbers modulo another number.\n///\n/// The traits are [`ModMul`](malachite_base::num::arithmetic::traits::ModMul),\n/// [`ModMulAssign`](malachite_base::num::arithmetic::traits::ModMulAssign),\n/// [`ModMulPrecomputed`](malachite_base::num::arithmetic::traits::ModMulPrecomputed), and\n/// [`ModMulPrecomputedAssign`](malachite_base::num::arithmetic::traits::ModMulPrecomputedAssign).\n/// [`ModMulPrecomputed`](malachite_base::num::arithmetic::traits::ModMulPrecomputed) and\n/// [`ModMulPrecomputedAssign`](malachite_base::num::arithmetic::traits::ModMulPrecomputedAssign)\n/// are useful when having to make several multiplications modulo the same modulus.\npub mod mod_mul;\n/// Implementations of [`ModNeg`](malachite_base::num::arithmetic::traits::ModNeg) and\n/// [`ModNegAssign`](malachite_base::num::arithmetic::traits::ModNegAssign), traits for negating a\n/// number modulo another number.\npub mod mod_neg;\n/// Implementations of traits for finding the remainder of two numbers, subject to various rounding\n/// rules.\n///\n/// These are the traits:\n///\n/// | rounding          | by value or reference      | by mutable reference (assignment)      |\n/// |-------------------|----------------------------|----------------------------------------|\n/// | towards $-\\infty$ | [`Mod`](malachite_base::num::arithmetic::traits::Mod)       | [`ModAssign`](malachite_base::num::arithmetic::traits::ModAssign)       |\n/// | towards $\\infty$  | [`NegMod`](malachite_base::num::arithmetic::traits::NegMod) | [`NegModAssign`](malachite_base::num::arithmetic::traits::NegModAssign) |\n///\n/// [`NegMod`](malachite_base::num::arithmetic::traits::NegMod) returns a remainder greater than or\n/// equal to zero. This allows the remainder to have an unsigned type, but modifies the usual\n/// relation $x = qy + r$ to $x = qy - r$.\n///\n/// The [`Rem`](core::ops::Rem) trait in the standard library rounds towards 0.\npub mod mod_op;\n/// Implementations of traits for raising a number to a power modulo another number.\n///\n/// The traits are [`ModPow`](malachite_base::num::arithmetic::traits::ModPow),\n/// [`ModPowAssign`](malachite_base::num::arithmetic::traits::ModPowAssign), and\n/// [`ModPowPrecomputed`](malachite_base::num::arithmetic::traits::ModPowPrecomputed).\n/// [`ModPowPrecomputed`](malachite_base::num::arithmetic::traits::ModPowPrecomputed) is useful when\n/// having to make several exponentiations modulo the same modulus.\npub mod mod_pow;\n/// Implementations of traits for finding the remainder of a number divided by $2^k$, subject to\n/// various rounding rules.\n///\n/// These are the traits:\n///\n/// | rounding | by value or reference | by mutable reference (assignment) |\n/// |----------|-----------------------|-----------------------------------|\n/// | towards $-\\infty$ | [`ModPowerOf2`](malachite_base::num::arithmetic::traits::ModPowerOf2) | [`ModPowerOf2Assign`](malachite_base::num::arithmetic::traits::ModPowerOf2Assign)       |\n/// | towards 0 | [`RemPowerOf2`](malachite_base::num::arithmetic::traits::RemPowerOf2) | [`RemPowerOf2Assign`](malachite_base::num::arithmetic::traits::RemPowerOf2Assign)       |\n/// | towards $\\infty$  | [`NegModPowerOf2`](malachite_base::num::arithmetic::traits::NegModPowerOf2) | [`NegModPowerOf2Assign`](malachite_base::num::arithmetic::traits::NegModPowerOf2Assign) |\n///\n/// [`NegModPowerOf2`](malachite_base::num::arithmetic::traits::NegModPowerOf2) returns a remainder\n/// greater than or equal to zero. This allows the remainder to have an unsigned type, but modifies\n/// the usual relation $x = q2^k + r$ to $x = q2^k - r$.\npub mod mod_power_of_2;\n/// Implementations of [`ModPowerOf2Add`](malachite_base::num::arithmetic::traits::ModPowerOf2Add)\n/// and [`ModPowerOf2AddAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2AddAssign),\n/// traits for adding two numbers modulo $2^k$.\npub mod mod_power_of_2_add;\n/// Implementations of\n/// [`ModPowerOf2Inverse`](malachite_base::num::arithmetic::traits::ModPowerOf2Inverse), a trait for\n/// finding the multiplicative inverse of a number modulo $2^k$.\npub mod mod_power_of_2_inverse;\n/// Implementations of\n/// [`ModPowerOf2IsReduced`](malachite_base::num::arithmetic::traits::ModPowerOf2IsReduced), a trait\n/// for checking whether a number is reduced modulo $2^k$.\npub mod mod_power_of_2_is_reduced;\n/// Implementations of [`ModPowerOf2Mul`](malachite_base::num::arithmetic::traits::ModPowerOf2Mul)\n/// and [`ModPowerOf2MulAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2MulAssign),\n/// traits for multiplying two numbers modulo $2^k$.\npub mod mod_power_of_2_mul;\n/// Implementations of [`ModPowerOf2Neg`](malachite_base::num::arithmetic::traits::ModPowerOf2Neg)\n/// and [`ModPowerOf2NegAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2NegAssign),\n/// traits for negating a number modulo $2^k$.\npub mod mod_power_of_2_neg;\n/// Implementations of [`ModPowerOf2Pow`](malachite_base::num::arithmetic::traits::ModPowerOf2Pow)\n/// and [`ModPowerOf2PowAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2PowAssign),\n/// traits for raising a number to a power modulo $2^k$.\npub mod mod_power_of_2_pow;\n/// Implementations of [`ModPowerOf2Shl`](malachite_base::num::arithmetic::traits::ModPowerOf2Shl)\n/// and [`ModPowerOf2ShlAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2ShlAssign),\n/// traits for left-shifting a number modulo $2^k$.\n///\n/// # mod_power_of_2_shl\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Shl;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shl(5u16, 8), 96);\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shl(100u64, 80), 0);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shl(5u16, 8), 96);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shl(100u64, 80), 0);\n///\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shl(5i16, 8), 96);\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shl(100i64, 80), 0);\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shl(-2i8, 8), 30);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shl(5i16, 8), 96);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shl(100i64, 80), 0);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shl(-2i8, 8), 30);\n/// ```\n///\n/// # mod_power_of_2_shl_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShlAssign;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shl_assign(5u16, 8);\n/// assert_eq!(n, 96);\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shl_assign(100u64, 80);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shl_assign(5i16, 8);\n/// assert_eq!(n, 96);\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shl_assign(100i64, 80);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shl_assign(-2i8, 8);\n/// assert_eq!(n, 30);\n/// ```\npub mod mod_power_of_2_shl;\n/// Implementations of [`ModPowerOf2Shr`](malachite_base::num::arithmetic::traits::ModPowerOf2Shr)\n/// and [`ModPowerOf2ShrAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2ShrAssign),\n/// traits for right-shifting a number modulo $2^k$.\n///\n/// # mod_power_of_2_shr\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2Shr;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shr(-5i16, 8), 96);\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shr(-100i64, 80), 0);\n/// assert_eq!(Natural::from(123u32).mod_power_of_2_shr(2i8, 8), 30);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shr(-5i16, 8), 96);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shr(-100i64, 80), 0);\n/// assert_eq!((&Natural::from(123u32)).mod_power_of_2_shr(2i8, 8), 30);\n/// ```\n///\n/// # mod_power_of_2_shr_assign\n/// ```\n/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShrAssign;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shr_assign(-5i16, 8);\n/// assert_eq!(n, 96);\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shr_assign(-100i64, 80);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(123u32);\n/// n.mod_power_of_2_shr_assign(2i8, 8);\n/// assert_eq!(n, 30);\n/// ```\npub mod mod_power_of_2_shr;\n/// Implementations of\n/// `ModPowerOf2Square`](malachite_base::num::arithmetic::traits::ModPowerOf2Square) and\n/// [`ModPowerOf2SquareAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2SquareAssign),\n/// traits for squaring a number modulo $2^k$.\npub mod mod_power_of_2_square;\n/// Implementations of [`ModPowerOf2Sub`](malachite_base::num::arithmetic::traits::ModPowerOf2Sub)\n/// and [`ModPowerOf2SubAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2SubAssign),\n/// traits for subtracting one number by another modulo $2^k$.\npub mod mod_power_of_2_sub;\n/// Implementations of [`ModShl`](malachite_base::num::arithmetic::traits::ModShl) and\n/// [`ModShlAssign`](malachite_base::num::arithmetic::traits::ModShlAssign), traits for\n/// left-shifting a number modulo another number.\n///\n/// # mod_shl\n/// ```\n/// use core::str::FromStr;\n/// use malachite_base::num::arithmetic::traits::ModShl;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::from(8u32).mod_shl(2u16, Natural::from(10u32)), 2);\n/// assert_eq!(\n///     Natural::from(123456u32).mod_shl(100u64, Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(Natural::from(8u32).mod_shl(2u16, &Natural::from(10u32)), 2);\n/// assert_eq!(\n///     Natural::from(123456u32).mod_shl(100u64, &Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(\n///     (&Natural::from(8u32)).mod_shl(2u16, Natural::from(10u32)),\n///     2\n/// );\n/// assert_eq!(\n///     (&Natural::from(123456u32))\n///         .mod_shl(100u64, Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(\n///     (&Natural::from(8u32)).mod_shl(2u16, &Natural::from(10u32)),\n///     2\n/// );\n/// assert_eq!(\n///     (&Natural::from(123456u32))\n///         .mod_shl(100u64, &Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n///\n/// assert_eq!(Natural::from(8u32).mod_shl(2i8, Natural::from(10u32)), 2);\n/// assert_eq!(\n///     Natural::from(5u32).mod_shl(-100i32, Natural::from(10u32)),\n///     0\n/// );\n/// assert_eq!(\n///     Natural::from(123456u32).mod_shl(100i64, Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(Natural::from(8u32).mod_shl(2i8, &Natural::from(10u32)), 2);\n/// assert_eq!(\n///     Natural::from(5u32).mod_shl(-100i32, &Natural::from(10u32)),\n///     0\n/// );\n/// assert_eq!(\n///     Natural::from(123456u32).mod_shl(100i64, &Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!((&Natural::from(8u32)).mod_shl(2i8, Natural::from(10u32)), 2);\n/// assert_eq!(\n///     (&Natural::from(5u32)).mod_shl(-100i32, Natural::from(10u32)),\n///     0\n/// );\n/// assert_eq!(\n///     (&Natural::from(123456u32))\n///         .mod_shl(100i64, Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(\n///     (&Natural::from(8u32)).mod_shl(2i8, &Natural::from(10u32)),\n///     2\n/// );\n/// assert_eq!(\n///     (&Natural::from(5u32)).mod_shl(-100i32, &Natural::from(10u32)),\n///     0\n/// );\n/// assert_eq!(\n///     (&Natural::from(123456u32))\n///         .mod_shl(100i64, &Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// ```\n///\n/// # mod_shl_assign\n/// ```\n/// use core::str::FromStr;\n/// use malachite_base::num::arithmetic::traits::ModShlAssign;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut x = Natural::from(8u32);\n/// x.mod_shl_assign(2u16, Natural::from(10u32));\n/// assert_eq!(x, 2);\n///\n/// let mut x = Natural::from(123456u32);\n/// x.mod_shl_assign(100u64, Natural::from_str(\"12345678987654321\").unwrap());\n/// assert_eq!(x, 7436663564915145u64);\n///\n/// let mut x = Natural::from(8u32);\n/// x.mod_shl_assign(2u16, &Natural::from(10u32));\n/// assert_eq!(x, 2);\n///\n/// let mut x = Natural::from(123456u32);\n/// x.mod_shl_assign(100u64, &Natural::from_str(\"12345678987654321\").unwrap());\n/// assert_eq!(x, 7436663564915145u64);\n///\n/// let mut x = Natural::from(8u32);\n/// x.mod_shl_assign(2i8, Natural::from(10u32));\n/// assert_eq!(x, 2);\n///\n/// let mut x = Natural::from(5u32);\n/// x.mod_shl_assign(-100i32, Natural::from(10u32));\n/// assert_eq!(x, 0);\n///\n/// let mut x = Natural::from(123456u32);\n/// x.mod_shl_assign(100i64, Natural::from_str(\"12345678987654321\").unwrap());\n/// assert_eq!(x, 7436663564915145u64);\n///\n/// let mut x = Natural::from(8u32);\n/// x.mod_shl_assign(2i8, &Natural::from(10u32));\n/// assert_eq!(x, 2);\n///\n/// let mut x = Natural::from(5u32);\n/// x.mod_shl_assign(-100i32, &Natural::from(10u32));\n/// assert_eq!(x, 0);\n///\n/// let mut x = Natural::from(123456u32);\n/// x.mod_shl_assign(100i64, &Natural::from_str(\"12345678987654321\").unwrap());\n/// assert_eq!(x, 7436663564915145u64);\n/// ```\npub mod mod_shl;\n/// Implementations of [`ModShr`](malachite_base::num::arithmetic::traits::ModShr) and\n/// [`ModShrAssign`](malachite_base::num::arithmetic::traits::ModShrAssign), traits for\n/// right-shifting a number modulo another number.\n///\n/// # mod_shr\n/// ```\n/// use core::str::FromStr;\n/// use malachite_base::num::arithmetic::traits::ModShr;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::from(8u32).mod_shr(-2i8, Natural::from(10u32)), 2);\n/// assert_eq!(Natural::from(5u32).mod_shr(100i32, Natural::from(10u32)), 0);\n/// assert_eq!(\n///     Natural::from(123456u32).mod_shr(-100i64, Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(Natural::from(8u32).mod_shr(-2i8, &Natural::from(10u32)), 2);\n/// assert_eq!(\n///     Natural::from(5u32).mod_shr(100i32, &Natural::from(10u32)),\n///     0\n/// );\n/// assert_eq!(\n///     Natural::from(123456u32).mod_shr(-100i64, &Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(\n///     (&Natural::from(8u32)).mod_shr(-2i8, Natural::from(10u32)),\n///     2\n/// );\n/// assert_eq!(\n///     (&Natural::from(5u32)).mod_shr(100i32, Natural::from(10u32)),\n///     0\n/// );\n/// assert_eq!(\n///     (&Natural::from(123456u32))\n///         .mod_shr(-100i64, Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// assert_eq!(\n///     (&Natural::from(8u32)).mod_shr(-2i8, &Natural::from(10u32)),\n///     2\n/// );\n/// assert_eq!(\n///     (&Natural::from(5u32)).mod_shr(100i32, &Natural::from(10u32)),\n///     0\n/// );\n/// assert_eq!(\n///     (&Natural::from(123456u32))\n///         .mod_shr(-100i64, &Natural::from_str(\"12345678987654321\").unwrap()),\n///     7436663564915145u64\n/// );\n/// ```\n///\n/// # mod_shr_assign\n/// ```\n/// use core::str::FromStr;\n/// use malachite_base::num::arithmetic::traits::ModShrAssign;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut x = Natural::from(8u32);\n/// x.mod_shr_assign(-2i8, Natural::from(10u32));\n/// assert_eq!(x, 2);\n///\n/// let mut x = Natural::from(5u32);\n/// x.mod_shr_assign(100i32, Natural::from(10u32));\n/// assert_eq!(x, 0);\n///\n/// let mut x = Natural::from(123456u32);\n/// x.mod_shr_assign(-100i64, Natural::from_str(\"12345678987654321\").unwrap());\n/// assert_eq!(x, 7436663564915145u64);\n///\n/// let mut x = Natural::from(8u32);\n/// x.mod_shr_assign(-2i8, &Natural::from(10u32));\n/// assert_eq!(x, 2);\n///\n/// let mut x = Natural::from(5u32);\n/// x.mod_shr_assign(100i32, &Natural::from(10u32));\n/// assert_eq!(x, 0);\n///\n/// let mut x = Natural::from(123456u32);\n/// x.mod_shr_assign(-100i64, &Natural::from_str(\"12345678987654321\").unwrap());\n/// assert_eq!(x, 7436663564915145u64);\n/// ```\npub mod mod_shr;\n/// Implementations of traits for squaring a number modulo another number.\n///\n/// The traits are [`ModSquare`](malachite_base::num::arithmetic::traits::ModSquare),\n/// [`ModSquareAssign`](malachite_base::num::arithmetic::traits::ModSquareAssign), and\n/// [`ModSquarePrecomputed`](malachite_base::num::arithmetic::traits::ModSquarePrecomputed).\n/// [`ModSquarePrecomputed`](malachite_base::num::arithmetic::traits::ModSquarePrecomputed) is\n/// useful when having to make several squarings modulo the same modulus.\npub mod mod_square;\n/// Implementations of [`ModSub`](malachite_base::num::arithmetic::traits::ModSub) and\n/// [`ModSubAssign`](malachite_base::num::arithmetic::traits::ModSubAssign), traits for subtracting\n/// two numbers modulo another number.\npub mod mod_sub;\n/// Multiplication of [`Natural`](super::Natural)s.\npub mod mul;\n/// Negation of a [`Natural`](super::Natural), returning an [`Integer`](crate::integer::Integer).\npub mod neg;\n/// Implementations of [`NextPowerOf2`](malachite_base::num::arithmetic::traits::NextPowerOf2) and\n/// [`NextPowerOf2Assign`](malachite_base::num::arithmetic::traits::NextPowerOf2Assign), traits for\n/// getting the next-highest power of 2.\npub mod next_power_of_2;\n/// Implementations of [`Parity`](malachite_base::num::arithmetic::traits::Parity), a trait for\n/// determining whether a number is even or odd.\npub mod parity;\n/// Implementations of [`Pow`](malachite_base::num::arithmetic::traits::Pow) and\n/// [`PowAssign`](malachite_base::num::arithmetic::traits::PowAssign), traits for raising a number\n/// to a power.\npub mod pow;\n/// Implementations of [`PowerOf2`](malachite_base::num::arithmetic::traits::PowerOf2), a trait for\n/// computing a power of 2.\npub mod power_of_2;\n/// An implementation of [`Primorial`](malachite_base::num::arithmetic::traits::Primorial), a trait\n/// for computing the primorial of a number.\npub mod primorial;\n/// Implementations of traits for taking the $n$th root of a number.\n///\n/// The traits are [`FloorRoot`](malachite_base::num::arithmetic::traits::FloorRoot),\n/// [`FloorRootAssign`](malachite_base::num::arithmetic::traits::FloorRootAssign),\n/// [`CeilingRoot`](malachite_base::num::arithmetic::traits::CeilingRoot),\n/// [`CeilingRootAssign`](malachite_base::num::arithmetic::traits::CeilingRootAssign),\n/// [`CheckedRoot`](malachite_base::num::arithmetic::traits::CheckedRoot),\n/// [`RootRem`](malachite_base::num::arithmetic::traits::RootRem), and\n/// [`RootAssignRem`](malachite_base::num::arithmetic::traits::RootAssignRem).\npub mod root;\n/// Implementations of [`RoundToMultiple`](malachite_base::num::arithmetic::traits::RoundToMultiple)\n/// and [`RoundToMultipleAssign`](malachite_base::num::arithmetic::traits::RoundToMultipleAssign),\n/// traits for rounding a number to a multiple of another number.\npub mod round_to_multiple;\n/// Implementations of\n/// [`RoundToMultipleOfPowerOf2`](malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2)\n/// and\n/// [`RoundToMultipleOfPowerOf2Assign`](malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign),\n/// traits for rounding a number to a multiple of a power of 2.\npub mod round_to_multiple_of_power_of_2;\n/// Implementations of [`SaturatingSub`](malachite_base::num::arithmetic::traits::SaturatingSub) and\n/// [`SaturatingSubAssign`](malachite_base::num::arithmetic::traits::SaturatingSubAssign), traits\n/// for subtracting two numbers and saturating at numeric bounds instead of overflowing.\npub mod saturating_sub;\n/// Implementations of\n/// [`SaturatingSubMul`](malachite_base::num::arithmetic::traits::SaturatingSubMul) and\n/// [`SaturatingSubMulAssign`](malachite_base::num::arithmetic::traits::SaturatingSubMulAssign),\n/// traits for subtracting a number by the product of two numbers and saturating at numeric bounds\n/// instead of overflowing.\npub mod saturating_sub_mul;\n/// Left-shifting a [`Natural`](super::Natural) (multiplying it by a power of 2).\n///\n/// # shl\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!((Natural::ZERO << 10u8), 0);\n/// assert_eq!((Natural::from(123u32) << 2u16), 492);\n/// assert_eq!(\n///     (Natural::from(123u32) << 100u64).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!((&Natural::ZERO << 10u8), 0);\n/// assert_eq!((&Natural::from(123u32) << 2u16), 492);\n/// assert_eq!(\n///     (&Natural::from(123u32) << 100u64).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n///\n/// assert_eq!((Natural::ZERO << 10i8), 0);\n/// assert_eq!((Natural::from(123u32) << 2i16), 492);\n/// assert_eq!(\n///     (Natural::from(123u32) << 100i32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!((Natural::ZERO << -10i64), 0);\n/// assert_eq!((Natural::from(10u32).pow(12) << -10i16), 976562500);\n/// assert_eq!((&Natural::ZERO << 10i8), 0);\n/// assert_eq!((&Natural::from(123u32) << 2i16), 492);\n/// assert_eq!(\n///     (&Natural::from(123u32) << 100i32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!((&Natural::ZERO << -10i64), 0);\n/// assert_eq!((&Natural::from(492u32) << -2i8), 123);\n/// assert_eq!((&Natural::from(10u32).pow(12) << -10i16), 976562500);\n/// ```\n///\n/// # shl_assign\n/// ```\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut x = Natural::ONE;\n/// x <<= 1u8;\n/// x <<= 2u16;\n/// x <<= 3u32;\n/// x <<= 4u64;\n/// assert_eq!(x, 1024);\n///\n/// let mut x = Natural::ONE;\n/// x <<= 1i8;\n/// x <<= 2i16;\n/// x <<= 3i32;\n/// x <<= 4i64;\n/// assert_eq!(x, 1024);\n///\n/// let mut x = Natural::from(1024u32);\n/// x <<= -1i8;\n/// x <<= -2i16;\n/// x <<= -3i32;\n/// x <<= -4i64;\n/// assert_eq!(x, 1);\n/// ```\npub mod shl;\n/// Implementations of [`ShlRound`](malachite_base::num::arithmetic::traits::ShlRound) and\n/// [`ShlRoundAssign`](malachite_base::num::arithmetic::traits::ShlRoundAssign), traits for\n/// multiplying a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode).\n///\n/// # shl_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShlRound;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shl_round(-8i8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shl_round(-8i16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shl_round(-9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shl_round(-9i64, Up)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shl_round(-9i8, Nearest)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0xffu32)\n///         .shl_round(-9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x100u32)\n///         .shl_round(-9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x100u32)\n///         .shl_round(-8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::ZERO.shl_round(10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::from(123u32)\n///         .shl_round(2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::from(123u32)\n///         .shl_round(100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shl_round(-8i8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shl_round(-8i16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shl_round(-9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shl_round(-9i64, Up)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shl_round(-9i8, Nearest)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0xffu32))\n///         .shl_round(-9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x100u32))\n///         .shl_round(-9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x100u32))\n///         .shl_round(-8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::ZERO).shl_round(10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(123u32))\n///         .shl_round(2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(123u32))\n///         .shl_round(100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n/// ```\n///\n/// # shl_round_assign\n/// ```\n/// use core::cmp::Ordering::*;\n/// use malachite_base::num::arithmetic::traits::ShlRoundAssign;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shl_round_assign(-8i8, Down), Less);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shl_round_assign(-8i16, Up), Greater);\n/// assert_eq!(n, 2);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shl_round_assign(-9i32, Down), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shl_round_assign(-9i64, Up), Greater);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shl_round_assign(-9i8, Nearest), Greater);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0xffu32);\n/// assert_eq!(n.shl_round_assign(-9i16, Nearest), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x100u32);\n/// assert_eq!(n.shl_round_assign(-9i32, Nearest), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x100u32);\n/// assert_eq!(n.shl_round_assign(-8i64, Exact), Equal);\n/// assert_eq!(n, 1);\n///\n/// let mut x = Natural::ONE;\n/// assert_eq!(x.shl_round_assign(1i8, Exact), Equal);\n/// assert_eq!(x.shl_round_assign(2i16, Exact), Equal);\n/// assert_eq!(x.shl_round_assign(3i32, Exact), Equal);\n/// assert_eq!(x.shl_round_assign(4i64, Exact), Equal);\n/// assert_eq!(x, 1024);\n/// ```\npub mod shl_round;\n/// Right-shifting a [`Natural`](super::Natural) (dividing it by a power of 2).\n///\n/// # shr\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!((Natural::ZERO >> 10u8), 0);\n/// assert_eq!((Natural::from(492u32) >> 2u32), 123);\n/// assert_eq!((Natural::from(10u32).pow(12) >> 10u64), 976562500);\n/// assert_eq!((&Natural::ZERO >> 10u8), 0);\n/// assert_eq!((&Natural::from(492u32) >> 2u32), 123);\n/// assert_eq!((&Natural::from(10u32).pow(12) >> 10u64), 976562500);\n///\n/// assert_eq!((Natural::ZERO >> 10i8), 0);\n/// assert_eq!((Natural::from(492u32) >> 2i16), 123);\n/// assert_eq!((Natural::from(10u32).pow(12) >> 10i32), 976562500);\n/// assert_eq!((Natural::ZERO >> -10i64), 0);\n/// assert_eq!((Natural::from(123u32) >> -2i8), 492);\n/// assert_eq!(\n///     (Natural::from(123u32) >> -100i16).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!((&Natural::ZERO >> -10i8), 0);\n/// assert_eq!((&Natural::from(123u32) >> -2i16), 492);\n/// assert_eq!(\n///     (&Natural::from(123u32) >> -100i32).to_string(),\n///     \"155921023828072216384094494261248\"\n/// );\n/// assert_eq!((&Natural::ZERO >> 10i64), 0);\n/// assert_eq!((&Natural::from(492u32) >> 2i8), 123);\n/// assert_eq!((&Natural::from(10u32).pow(12) >> 10i16), 976562500);\n/// ```\n///\n/// # shr_assign\n/// ```\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut x = Natural::from(1024u32);\n/// x >>= 1u8;\n/// x >>= 2u16;\n/// x >>= 3u32;\n/// x >>= 4u64;\n/// assert_eq!(x, 1);\n///\n/// let mut x = Natural::ONE;\n/// x >>= -1i8;\n/// x >>= -2i16;\n/// x >>= -3i32;\n/// x >>= -4i64;\n/// assert_eq!(x, 1024);\n///\n/// let mut x = Natural::from(1024u32);\n/// x >>= 1i8;\n/// x >>= 2i16;\n/// x >>= 3i32;\n/// x >>= 4i64;\n/// assert_eq!(x, 1);\n/// ```\npub mod shr;\n/// Implementations of [`ShrRound`](malachite_base::num::arithmetic::traits::ShrRound) and\n/// [`ShrRoundAssign`](malachite_base::num::arithmetic::traits::ShrRoundAssign), traits for dividing\n/// a number by a power of 2 and rounding according to a specified\n/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode).\n///\n/// # shr_round\n/// ```\n/// use malachite_base::num::arithmetic::traits::ShrRound;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(8u8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(8u16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(9u32, Down)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(9u64, Up)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(9u8, Nearest)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0xffu32)\n///         .shr_round(9u16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x100u32)\n///         .shr_round(9u32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x100u32)\n///         .shr_round(8u64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(8u8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(8u16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(9u32, Down)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(9u64, Up)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(9u8, Nearest)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0xffu32))\n///         .shr_round(9u16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x100u32))\n///         .shr_round(9u32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x100u32))\n///         .shr_round(8u64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n///\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(8i8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(8i16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(9i64, Up)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x101u32)\n///         .shr_round(9i8, Nearest)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0xffu32)\n///         .shr_round(9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x100u32)\n///         .shr_round(9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::from(0x100u32)\n///         .shr_round(8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::ZERO.shr_round(-10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::from(123u32)\n///         .shr_round(-2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::from(123u32)\n///         .shr_round(-100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(8i8, Down)\n///         .to_debug_string(),\n///     \"(1, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(8i16, Up)\n///         .to_debug_string(),\n///     \"(2, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(9i32, Down)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(9i64, Up)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x101u32))\n///         .shr_round(9i8, Nearest)\n///         .to_debug_string(),\n///     \"(1, Greater)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0xffu32))\n///         .shr_round(9i16, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x100u32))\n///         .shr_round(9i32, Nearest)\n///         .to_debug_string(),\n///     \"(0, Less)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(0x100u32))\n///         .shr_round(8i64, Exact)\n///         .to_debug_string(),\n///     \"(1, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::ZERO).shr_round(-10i8, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(123u32))\n///         .shr_round(-2i16, Exact)\n///         .to_debug_string(),\n///     \"(492, Equal)\"\n/// );\n/// assert_eq!(\n///     (&Natural::from(123u32))\n///         .shr_round(-100i32, Exact)\n///         .to_debug_string(),\n///     \"(155921023828072216384094494261248, Equal)\"\n/// );\n/// ```\n///\n/// # shr_round_assign\n/// ```\n/// use core::cmp::Ordering::*;\n/// use malachite_base::num::arithmetic::traits::ShrRoundAssign;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(8u8, Down), Less);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(8u16, Up), Greater);\n/// assert_eq!(n, 2);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(9u32, Down), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(9u64, Up), Greater);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(9u8, Nearest), Greater);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0xffu32);\n/// assert_eq!(n.shr_round_assign(9u16, Nearest), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x100u32);\n/// assert_eq!(n.shr_round_assign(9u32, Nearest), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x100u32);\n/// assert_eq!(n.shr_round_assign(8u64, Exact), Equal);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(8i8, Down), Less);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(8i16, Up), Greater);\n/// assert_eq!(n, 2);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(9i32, Down), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(9i64, Up), Greater);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0x101u32);\n/// assert_eq!(n.shr_round_assign(9i8, Nearest), Greater);\n/// assert_eq!(n, 1);\n///\n/// let mut n = Natural::from(0xffu32);\n/// assert_eq!(n.shr_round_assign(9i16, Nearest), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x100u32);\n/// assert_eq!(n.shr_round_assign(9i32, Nearest), Less);\n/// assert_eq!(n, 0);\n///\n/// let mut n = Natural::from(0x100u32);\n/// assert_eq!(n.shr_round_assign(8i64, Exact), Equal);\n/// assert_eq!(n, 1);\n///\n/// let mut x = Natural::ONE;\n/// assert_eq!(x.shr_round_assign(-1i8, Exact), Equal);\n/// assert_eq!(x.shr_round_assign(-2i16, Exact), Equal);\n/// assert_eq!(x.shr_round_assign(-3i32, Exact), Equal);\n/// assert_eq!(x.shr_round_assign(-4i64, Exact), Equal);\n/// assert_eq!(x, 1024);\n/// ```\npub mod shr_round;\n/// Implementations of [`Sign`](malachite_base::num::arithmetic::traits::Sign), a trait for\n/// determining the sign of a number.\npub mod sign;\n/// Implementations of traits for taking the square root of a number.\n///\n/// The traits are [`FloorSqrt`](malachite_base::num::arithmetic::traits::FloorSqrt),\n/// [`FloorSqrtAssign`](malachite_base::num::arithmetic::traits::FloorSqrtAssign),\n/// [`CeilingSqrt`](malachite_base::num::arithmetic::traits::CeilingSqrt),\n/// [`CeilingSqrtAssign`](malachite_base::num::arithmetic::traits::CeilingSqrtAssign),\n/// [`CheckedSqrt`](malachite_base::num::arithmetic::traits::CheckedSqrt),\n/// [`SqrtRem`](malachite_base::num::arithmetic::traits::SqrtRem), and\n/// [`SqrtAssignRem`](malachite_base::num::arithmetic::traits::SqrtAssignRem).\npub mod sqrt;\n/// Implementations of [`Square`](malachite_base::num::arithmetic::traits::Square) and\n/// [`SquareAssign`](malachite_base::num::arithmetic::traits::SquareAssign), traits for squaring a\n/// number.\npub mod square;\n/// Subtraction of [`Natural`](super::Natural)s.\npub mod sub;\n/// Implementations of [`SubMul`](malachite_base::num::arithmetic::traits::SubMul) and\n/// [`SubMulAssign`](malachite_base::num::arithmetic::traits::SubMulAssign), traits for subtracting\n/// the product of two numbers from a number.\npub mod sub_mul;\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2019 Daniel Schultz\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ModAdd, ModAddAssign};\n\nimpl ModAdd<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. All three [`Natural`]s are taken by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO.mod_add(Natural::from(3u32), Natural::from(5u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_add(Natural::from(5u32), Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value.\n    #[inline]\n    fn mod_add(mut self, other: Self, m: Self) -> Self {\n        self.mod_add_assign(other, m);\n        self\n    }\n}\n\nimpl<'a> ModAdd<Self, &'a Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. The first two [`Natural`]s are taken by value and the third by reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO.mod_add(Natural::from(3u32), &Natural::from(5u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_add(Natural::from(5u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value and `m` is taken by reference.\n    #[inline]\n    fn mod_add(mut self, other: Self, m: &'a Self) -> Self {\n        self.mod_add_assign(other, m);\n        self\n    }\n}\n\nimpl<'a> ModAdd<&'a Self, Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. The first and third [`Natural`]s are taken by value and the second by reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO.mod_add(&Natural::from(3u32), Natural::from(5u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_add(&Natural::from(5u32), Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value and `c` is taken by reference.\n    #[inline]\n    fn mod_add(mut self, other: &'a Self, m: Self) -> Self {\n        self.mod_add_assign(other, m);\n        self\n    }\n}\n\nimpl<'a, 'b> ModAdd<&'a Self, &'b Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. The first [`Natural`] is taken by value and the second and third by reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO.mod_add(&Natural::from(3u32), &Natural::from(5u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_add(&Natural::from(5u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` is\n    /// taken by value and `c` and `m` are taken by reference.\n    #[inline]\n    fn mod_add(mut self, other: &'a Self, m: &'b Self) -> Self {\n        self.mod_add_assign(other, m);\n        self\n    }\n}\n\nimpl ModAdd<Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. The first [`Natural`] is taken by reference and the second and third by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO)\n    ///         .mod_add(Natural::from(3u32), Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"3\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32))\n    ///         .mod_add(Natural::from(5u32), Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"2\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` is\n    /// taken by reference and `c` and `m` are taken by value.\n    #[inline]\n    fn mod_add(self, mut other: Natural, m: Natural) -> Natural {\n        other.mod_add_assign(self, m);\n        other\n    }\n}\n\nimpl ModAdd<Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. The first and third [`Natural`]s are taken by reference and the second by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO).mod_add(Natural::from(3u32), &Natural::from(5u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_add(Natural::from(5u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by reference and `c` is taken by value.\n    #[inline]\n    fn mod_add(self, mut other: Natural, m: &Natural) -> Natural {\n        other.mod_add_assign(self, m);\n        other\n    }\n}\n\nimpl ModAdd<&Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. The first two [`Natural`]s are taken by reference and the third by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO).mod_add(&Natural::from(3u32), Natural::from(5u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_add(&Natural::from(5u32), Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by reference and `m` is taken by value.\n    fn mod_add(self, other: &Natural, m: Natural) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            *other < m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        let sum = self + other;\n        if sum < m { sum } else { sum - m }\n    }\n}\n\nimpl ModAdd<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already reduced\n    /// modulo $m$. All three [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAdd;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO).mod_add(&Natural::from(3u32), &Natural::from(5u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_add(&Natural::from(5u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by reference.\n    fn mod_add(self, other: &Natural, m: &Natural) -> Natural {\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        let sum = self + other;\n        if sum < *m { sum } else { sum - m }\n    }\n}\n\nimpl ModAddAssign<Self, Self> for Natural {\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be already\n    /// reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAddAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.mod_add_assign(Natural::from(3u32), Natural::from(5u32));\n    /// assert_eq!(x, 3);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_add_assign(Natural::from(5u32), Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value and `a == b`.\n    fn mod_add_assign(&mut self, other: Self, m: Self) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        *self += other;\n        if *self >= m {\n            *self -= m;\n        }\n    }\n}\n\nimpl<'a> ModAddAssign<Self, &'a Self> for Natural {\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by value and the\n    /// second by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAddAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.mod_add_assign(Natural::from(3u32), &Natural::from(5u32));\n    /// assert_eq!(x, 3);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_add_assign(Natural::from(5u32), &Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value, `m` is taken by reference, and `a == b`.\n    fn mod_add_assign(&mut self, other: Self, m: &'a Self) {\n        assert!(*self < *m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            other < *m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        *self += other;\n        if *self >= *m {\n            *self -= m;\n        }\n    }\n}\n\nimpl<'a> ModAddAssign<&'a Self, Self> for Natural {\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by reference and\n    /// the second by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAddAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.mod_add_assign(&Natural::from(3u32), Natural::from(5u32));\n    /// assert_eq!(x, 3);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_add_assign(&Natural::from(5u32), Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value, `c` is taken by reference, and `a == b`.\n    fn mod_add_assign(&mut self, other: &'a Self, m: Self) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            *other < m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        *self += other;\n        if *self >= m {\n            *self -= m;\n        }\n    }\n}\n\nimpl<'a, 'b> ModAddAssign<&'a Self, &'b Self> for Natural {\n    /// Adds two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be already\n    /// reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x + y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAddAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.mod_add_assign(&Natural::from(3u32), &Natural::from(5u32));\n    /// assert_eq!(x, 3);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_add_assign(&Natural::from(5u32), &Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_addN` from `fmpz_mod/add.c`, FLINT 2.7.1, where `b` is\n    /// taken by value, `c` and `m` are taken by reference, and `a == b`.\n    fn mod_add_assign(&mut self, other: &'a Self, m: &'b Self) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        *self += other;\n        if *self >= *m {\n            *self -= m;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::Small;\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::gcd::extended_gcd::limbs_extended_gcd;\nuse crate::natural::arithmetic::sub::limbs_sub_same_length_in_place_right;\nuse malachite_base::num::arithmetic::traits::ModInverse;\nuse malachite_base::num::basic::traits::One;\n\nfn mod_inverse_helper(x: Natural, m: Natural) -> Option<Natural> {\n    let mut xs = x.into_limbs_asc();\n    let mut ys = m.to_limbs_asc();\n    let len = ys.len();\n    xs.resize(len, 0);\n    let mut gs = vec![0; len];\n    let mut ss = vec![0; len + 1];\n    let (g_len, ss_sign) = limbs_extended_gcd(&mut gs, &mut ss, &mut xs, &mut ys);\n    gs.truncate(g_len);\n    if Natural::from_owned_limbs_asc(gs) != 1u32 {\n        return None;\n    }\n    if !ss_sign {\n        assert_eq!(ss.pop(), Some(0));\n        limbs_sub_same_length_in_place_right(&m.into_limbs_asc(), &mut ss);\n    }\n    Some(Natural::from_owned_limbs_asc(ss))\n}\n\nimpl ModInverse for Natural {\n    type Output = Self;\n\n    /// Computes the multiplicative inverse of a [`Natural`] modulo another [`Natural`] $m$. The\n    /// input must be already reduced modulo $m$. Both [`Natural`]s are taken by value.\n    ///\n    /// Returns `None` if $x$ and $m$ are not coprime.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$, $\\gcd(x, y) = 1$, and $xy \\equiv 1 \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// m.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModInverse;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_inverse(Natural::from(10u32)),\n    ///     Some(Natural::from(7u32))\n    /// );\n    /// assert_eq!(Natural::from(4u32).mod_inverse(Natural::from(10u32)), None);\n    /// ```\n    fn mod_inverse(self, m: Self) -> Option<Self> {\n        assert_ne!(self, 0u32);\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, m) {\n            (x @ Self::ONE, _) => Some(x),\n            (Self(Small(x)), Self(Small(y))) => x.mod_inverse(y).map(Self::from),\n            (a, b) => mod_inverse_helper(a, b),\n        }\n    }\n}\n\nimpl<'a> ModInverse<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Computes the multiplicative inverse of a [`Natural`] modulo another [`Natural`] $m$. The\n    /// input must be already reduced modulo $m$. The first [`Natural`] is taken by value and the\n    /// second by reference.\n    ///\n    /// Returns `None` if $x$ and $m$ are not coprime.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$, $\\gcd(x, y) = 1$, and $xy \\equiv 1 \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// m.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModInverse;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_inverse(&Natural::from(10u32)),\n    ///     Some(Natural::from(7u32))\n    /// );\n    /// assert_eq!(Natural::from(4u32).mod_inverse(&Natural::from(10u32)), None);\n    /// ```\n    fn mod_inverse(self, m: &'a Self) -> Option<Self> {\n        assert_ne!(self, 0u32);\n        assert!(self < *m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, m) {\n            (x @ Self::ONE, _) => Some(x),\n            (Self(Small(x)), Self(Small(y))) => x.mod_inverse(*y).map(Self::from),\n            (a, b) => mod_inverse_helper(a, b.clone()),\n        }\n    }\n}\n\nimpl ModInverse<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the multiplicative inverse of a [`Natural`] modulo another [`Natural`] $m$. The\n    /// input must be already reduced modulo $m$. The first [`Natural`]s is taken by reference and\n    /// the second by value.\n    ///\n    /// Returns `None` if $x$ and $m$ are not coprime.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$, $\\gcd(x, y) = 1$, and $xy \\equiv 1 \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// m.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModInverse;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_inverse(Natural::from(10u32)),\n    ///     Some(Natural::from(7u32))\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(4u32)).mod_inverse(Natural::from(10u32)),\n    ///     None\n    /// );\n    /// ```\n    fn mod_inverse(self, m: Natural) -> Option<Natural> {\n        assert_ne!(*self, 0u32);\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, m) {\n            (&Natural::ONE, _) => Some(Natural::ONE),\n            (Natural(Small(x)), Natural(Small(y))) => x.mod_inverse(y).map(Natural::from),\n            (a, b) => mod_inverse_helper(a.clone(), b),\n        }\n    }\n}\n\nimpl ModInverse<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Computes the multiplicative inverse of a [`Natural`] modulo another [`Natural`] $m$. The\n    /// input must be already reduced modulo $m$. Both [`Natural`]s are taken by reference.\n    ///\n    /// Returns `None` if $x$ and $m$ are not coprime.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$, $\\gcd(x, y) = 1$, and $xy \\equiv 1 \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// m.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModInverse;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_inverse(&Natural::from(10u32)),\n    ///     Some(Natural::from(7u32))\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(4u32)).mod_inverse(&Natural::from(10u32)),\n    ///     None\n    /// );\n    /// ```\n    fn mod_inverse(self, m: &Natural) -> Option<Natural> {\n        assert_ne!(*self, 0u32);\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, m) {\n            (&Natural::ONE, _) => Some(Natural::ONE),\n            (Natural(Small(x)), Natural(Small(y))) => x.mod_inverse(*y).map(Natural::from),\n            (a, b) => mod_inverse_helper(a.clone(), b.clone()),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::ModIsReduced;\nuse malachite_base::num::basic::traits::Zero;\n\nimpl ModIsReduced for Natural {\n    /// Returns whether a [`Natural`] is reduced modulo another [`Natural`] $m$; in other words,\n    /// whether it is less than $m$.\n    ///\n    /// $m$ cannot be zero.\n    ///\n    /// $f(x, m) = (x < m)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `m` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModIsReduced, Pow};\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_is_reduced(&Natural::from(5u32)), true);\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .mod_is_reduced(&Natural::from(10u32).pow(12)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .mod_is_reduced(&(Natural::from(10u32).pow(12) + Natural::ONE)),\n    ///     true\n    /// );\n    /// ```\n    #[inline]\n    fn mod_is_reduced(&self, m: &Self) -> bool {\n        assert_ne!(*m, Self::ZERO);\n        self < m\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2019 Daniel Schultz\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::div_mod::limbs_div_mod_by_two_limb_normalized;\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::{\n    ModMul, ModMulAssign, ModMulPrecomputed, ModMulPrecomputedAssign, ModPowerOf2Mul,\n    ModPowerOf2MulAssign, PowerOf2, XMulYToZZ, XXXAddYYYToZZZ, XXXSubYYYToZZZ, XXXXAddYYYYToZZZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\n\n// m_1 cannot be zero, and we cannot have m_1 == 1 and m_0 == 0.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\npub_test! {limbs_precompute_mod_mul_two_limbs(m_1: Limb, m_0: Limb) -> (Limb, Limb, Limb) {\n    let xs = &mut [0; 5];\n    let out = &mut [0; 3];\n    let bits = LeadingZeros::leading_zeros(m_1);\n    if bits == 0 {\n        xs[4] = 1;\n        assert!(!limbs_div_mod_by_two_limb_normalized(out, xs, &[m_0, m_1]));\n    } else {\n        xs[4] = Limb::power_of_2(bits);\n        assert!(!limbs_div_mod_by_two_limb_normalized(\n            out,\n            xs,\n            &[m_0 << bits, (m_1 << bits) | (m_0 >> (Limb::WIDTH - bits))]\n        ));\n    }\n    assert_ne!(out[2], 0);\n    (out[2], out[1], out[0])\n}}\n\n// Standard Barrett reduction: (set r = `Limb::WIDTH`)\n//\n// We have m fits into 2 words and 2 ^ r < m < 2 ^ (2 * r). Therefore 2 ^ (3 * r) > 2 ^ (4 * r) / m\n// > 2 ^ (2 * r) and the precomputed number inv = floor(2 ^ (4 * r) / m) fits into 3 words. The\n// inputs x and y are < m and therefore fit into 2 words.\n//\n// The computation of a = x*y mod m is:\n// ```\n// w = x * y               x < m ^ 2 and therefore fits into 4 words\n// z = (w >> r) * inv      z <= m * 2 ^ (3 * r) and therefore fits into 5 words\n// q = (z >> (3 * r)) * n  q fits into 4 words\n// w = w - q               w fits into 3 words after the subtraction\n// ```\n//\n// at this point the canonical reduction in the range [0, m) is one of a = w, a = w - n, or a = w -\n// 2 * m\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `_fmpz_mod_mul2` from `fmpz_mod/mul.c`, FLINT 2.7.1.\npub_test! {limbs_mod_mul_two_limbs(\n    x_1: Limb,\n    x_0: Limb,\n    y_1: Limb,\n    y_0: Limb,\n    m_1: Limb,\n    m_0: Limb,\n    inv_2: Limb,\n    inv_1: Limb,\n    inv_0: Limb,\n) -> (Limb, Limb) {\n    // w[3:0] = x[1:0] * y[1:0]\n    let (w_3, w_2) = Limb::x_mul_y_to_zz(x_1, y_1);\n    let (w_1, w_0) = Limb::x_mul_y_to_zz(x_0, y_0);\n    let (t, carry) = (DoubleLimb::from(x_1) * DoubleLimb::from(y_0))\n        .overflowing_add(DoubleLimb::from(x_0) * DoubleLimb::from(y_1));\n    let (t_2, t_1) = t.split_in_half();\n    let (w_3, w_2, w_1) = Limb::xxx_add_yyy_to_zzz(w_3, w_2, w_1, Limb::from(carry), t_2, t_1);\n\n    // z[5:0] = w[3:1] * ninv[2:0], z[5] should end up zero\n    let (z_3, z_2) = Limb::x_mul_y_to_zz(w_2, inv_1);\n    let (t, carry) = (DoubleLimb::from(w_1) * DoubleLimb::from(inv_2))\n        .overflowing_add(DoubleLimb::from(w_3) * DoubleLimb::from(inv_0));\n    let (t_3, t_2) = t.split_in_half();\n    let (u_2, u_1) = Limb::x_mul_y_to_zz(w_2, inv_0);\n    let (u_4, u_3) = Limb::x_mul_y_to_zz(w_3, inv_1);\n    let (z_4, z_3, z_2) = Limb::xxx_add_yyy_to_zzz(\n        w_3.wrapping_mul(inv_2),\n        z_3,\n        z_2,\n        Limb::from(carry),\n        t_3,\n        t_2,\n    );\n    let (v_2, v_1) = Limb::x_mul_y_to_zz(w_1, inv_1);\n    let (v_4, v_3) = Limb::x_mul_y_to_zz(w_2, inv_2);\n    let (z_4, z_3, z_2, z_1) = Limb::xxxx_add_yyyy_to_zzzz(\n        z_4,\n        z_3,\n        z_2,\n        (DoubleLimb::from(w_1) * DoubleLimb::from(inv_0)).upper_half(),\n        u_4,\n        u_3,\n        u_2,\n        u_1,\n    );\n    let (z_4, z_3, _, _) = Limb::xxxx_add_yyyy_to_zzzz(z_4, z_3, z_2, z_1, v_4, v_3, v_2, v_1);\n\n    // - q[3:0] = z[4:3] * n[1:0], q[3] is not needed\n    // - x[3:0] -= q[3:0], w[3] should end up zero\n    let (q_1, q_0) = Limb::x_mul_y_to_zz(z_3, m_0);\n    let (w_2, w_1) = DoubleLimb::join_halves(w_2, w_1)\n        .wrapping_sub(DoubleLimb::from(z_4) * DoubleLimb::from(m_0))\n        .wrapping_sub(DoubleLimb::from(z_3) * DoubleLimb::from(m_1))\n        .split_in_half();\n    let (w_2, w_1, w_0) = Limb::xxx_sub_yyy_to_zzz(w_2, w_1, w_0, z_4.wrapping_mul(m_1), q_1, q_0);\n\n    // at most two subtractions of n, use q as temp space\n    let (q_2, q_1, q_0) = Limb::xxx_sub_yyy_to_zzz(w_2, w_1, w_0, 0, m_1, m_0);\n    if q_2.get_highest_bit() {\n        (w_1, w_0)\n    } else {\n        let (w_2, w_1, w_0) = Limb::xxx_sub_yyy_to_zzz(q_2, q_1, q_0, 0, m_1, m_0);\n        if w_2.get_highest_bit() {\n            (q_1, q_0)\n        } else {\n            (w_1, w_0)\n        }\n    }\n}}\n\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\n#[doc(hidden)]\npub enum ModMulData {\n    OneLimb(Limb),\n    MinTwoLimbs,\n    TwoLimbs(Limb, Limb, Limb),\n    MoreThanTwoLimbs,\n}\n\nfn precompute_mod_mul_data_helper(m: &Natural) -> ModMulData {\n    match *m {\n        Natural::ZERO => panic!(\"division by zero\"),\n        Natural(Small(ref x)) => ModMulData::OneLimb(Limb::precompute_mod_mul_data(x)),\n        Natural(Large(ref xs)) => match xs[..] {\n            [0, 1] => ModMulData::MinTwoLimbs,\n            [m_0, m_1] => {\n                let (inv_2, inv_1, inv_0) = limbs_precompute_mod_mul_two_limbs(m_1, m_0);\n                ModMulData::TwoLimbs(inv_2, inv_1, inv_0)\n            }\n            _ => ModMulData::MoreThanTwoLimbs,\n        },\n    }\n}\n\nimpl Natural {\n    fn mod_mul_precomputed_two_limbs(\n        &self,\n        y: &Self,\n        m: &Self,\n        inv_2: Limb,\n        inv_1: Limb,\n        inv_0: Limb,\n    ) -> Self {\n        let (r_1, r_0) = match (self, y, m) {\n            (&Self(Small(x)), &Self(Small(y)), &Self(Large(ref ms))) => {\n                limbs_mod_mul_two_limbs(0, x, 0, y, ms[1], ms[0], inv_2, inv_1, inv_0)\n            }\n            (&Self(Large(ref xs)), &Self(Small(y)), &Self(Large(ref ms)))\n            | (&Self(Small(y)), &Self(Large(ref xs)), &Self(Large(ref ms))) => {\n                limbs_mod_mul_two_limbs(xs[1], xs[0], 0, y, ms[1], ms[0], inv_2, inv_1, inv_0)\n            }\n            (&Self(Large(ref xs)), &Self(Large(ref ys)), &Self(Large(ref ms))) => {\n                limbs_mod_mul_two_limbs(\n                    xs[1], xs[0], ys[1], ys[0], ms[1], ms[0], inv_2, inv_1, inv_0,\n                )\n            }\n            _ => unreachable!(),\n        };\n        Self::from_owned_limbs_asc(vec![r_0, r_1])\n    }\n\n    fn mod_mul_precomputed_two_limbs_assign(\n        &mut self,\n        y: &Self,\n        m: &Self,\n        inv_2: Limb,\n        inv_1: Limb,\n        inv_0: Limb,\n    ) {\n        match (&mut *self, y, m) {\n            (&mut Self(Small(x)), &Self(Small(y)), &Self(Large(ref ms))) => {\n                let (r_1, r_0) =\n                    limbs_mod_mul_two_limbs(0, x, 0, y, ms[1], ms[0], inv_2, inv_1, inv_0);\n                *self = Self::from_owned_limbs_asc(vec![r_0, r_1]);\n            }\n            (&mut Self(Small(x)), &Self(Large(ref ys)), &Self(Large(ref ms))) => {\n                let (r_1, r_0) =\n                    limbs_mod_mul_two_limbs(0, x, ys[1], ys[0], ms[1], ms[0], inv_2, inv_1, inv_0);\n                *self = Self::from_owned_limbs_asc(vec![r_0, r_1]);\n            }\n            (&mut Self(Large(ref mut xs)), &Self(Small(y)), &Self(Large(ref ms))) => {\n                let (r_1, r_0) =\n                    limbs_mod_mul_two_limbs(xs[1], xs[0], 0, y, ms[1], ms[0], inv_2, inv_1, inv_0);\n                *xs = vec![r_0, r_1];\n                self.trim();\n            }\n            (&mut Self(Large(ref mut xs)), &Self(Large(ref ys)), &Self(Large(ref ms))) => {\n                let (r_1, r_0) = limbs_mod_mul_two_limbs(\n                    xs[1], xs[0], ys[1], ys[0], ms[1], ms[0], inv_2, inv_1, inv_0,\n                );\n                *xs = vec![r_0, r_1];\n                self.trim();\n            }\n            _ => unreachable!(),\n        }\n    }\n}\n\nimpl ModMulPrecomputed<Self, Self> for Natural {\n    type Output = Self;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &Self) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. All three [`Natural`]s are taken by value.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     Natural::from(6u8).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(9u8).mod_mul_precomputed(\n    ///         Natural::from(9u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(4u8).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value.\n    fn mod_mul_precomputed(mut self, other: Self, m: Self, data: &ModMulData) -> Self {\n        self.mod_mul_precomputed_assign(other, m, data);\n        self\n    }\n}\n\nimpl<'a> ModMulPrecomputed<Self, &'a Self> for Natural {\n    type Output = Self;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &&Self) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first two [`Natural`]s are taken by value and the third by\n    /// reference.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     Natural::from(6u8).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(9u8).mod_mul_precomputed(\n    ///         Natural::from(9u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(4u8).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value and `m` is taken by reference.\n    fn mod_mul_precomputed(mut self, other: Self, m: &'a Self, data: &ModMulData) -> Self {\n        self.mod_mul_precomputed_assign(other, m, data);\n        self\n    }\n}\n\nimpl<'a> ModMulPrecomputed<&'a Self, Self> for Natural {\n    type Output = Self;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &Self) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first and third [`Natural`]s are taken by value and the second by\n    /// reference.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     Natural::from(6u8).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(9u8).mod_mul_precomputed(\n    ///         &Natural::from(9u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(4u8).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value and `c` is taken by reference.\n    fn mod_mul_precomputed(mut self, other: &'a Self, m: Self, data: &ModMulData) -> Self {\n        self.mod_mul_precomputed_assign(other, m, data);\n        self\n    }\n}\n\nimpl<'a, 'b> ModMulPrecomputed<&'a Self, &'b Self> for Natural {\n    type Output = Self;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &&Self) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] is taken by value and the second and third by\n    /// reference.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     Natural::from(6u8).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(9u8).mod_mul_precomputed(\n    ///         &Natural::from(9u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(4u8).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` is\n    /// taken by value and `c` and `m` are taken by reference.\n    fn mod_mul_precomputed(mut self, other: &'a Self, m: &'b Self, data: &ModMulData) -> Self {\n        self.mod_mul_precomputed_assign(other, m, data);\n        self\n    }\n}\n\nimpl ModMulPrecomputed<Natural, Natural> for &Natural {\n    type Output = Natural;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &Natural) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] is taken by reference and the second and third by\n    /// value.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     (&Natural::from(6u8)).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(9u8)).mod_mul_precomputed(\n    ///         Natural::from(9u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(4u8)).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` is\n    /// taken by reference and `c` and `m` are taken by value.\n    fn mod_mul_precomputed(self, other: Natural, m: Natural, data: &ModMulData) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        match (self, other, m, data) {\n            (&Natural::ZERO, _, _, _) | (_, Natural::ZERO, _, _) => Natural::ZERO,\n            (x, Natural::ONE, _, _) => x.clone(),\n            (&Natural::ONE, y, _, _) => y,\n            (\n                &Natural(Small(x)),\n                Natural(Small(y)),\n                Natural(Small(m)),\n                &ModMulData::OneLimb(inv),\n            ) => Natural::from(x.mod_mul_precomputed(y, m, &inv)),\n            (x, y, _, &ModMulData::MinTwoLimbs) => x.mod_power_of_2_mul(y, Limb::WIDTH),\n            (x, y, m, &ModMulData::TwoLimbs(inv_2, inv_1, inv_0)) => {\n                x.mod_mul_precomputed_two_limbs(&y, &m, inv_2, inv_1, inv_0)\n            }\n            (x, y, m, _) => x * y % m,\n        }\n    }\n}\n\nimpl ModMulPrecomputed<Natural, &Natural> for &Natural {\n    type Output = Natural;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &&Natural) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first and third [`Natural`]s are taken by reference and the second\n    /// by value.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     (&Natural::from(6u8)).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(9u8)).mod_mul_precomputed(\n    ///         Natural::from(9u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(4u8)).mod_mul_precomputed(\n    ///         Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by reference and `c` is taken by value.\n    #[inline]\n    fn mod_mul_precomputed(self, other: Natural, m: &Natural, data: &ModMulData) -> Natural {\n        other.mod_mul_precomputed(self, m, data)\n    }\n}\n\nimpl ModMulPrecomputed<&Natural, Natural> for &Natural {\n    type Output = Natural;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &Natural) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first two [`Natural`]s are taken by reference and the third by\n    /// value.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     (&Natural::from(6u8)).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(9u8)).mod_mul_precomputed(\n    ///         &Natural::from(9u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(4u8)).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by reference and `m` is taken by value.\n    fn mod_mul_precomputed(self, other: &Natural, m: Natural, data: &ModMulData) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            *other < m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        match (self, other, m, data) {\n            (&Natural::ZERO, _, _, _) | (_, &Natural::ZERO, _, _) => Natural::ZERO,\n            (x, &Natural::ONE, _, _) => x.clone(),\n            (&Natural::ONE, y, _, _) => y.clone(),\n            (\n                &Natural(Small(x)),\n                &Natural(Small(y)),\n                Natural(Small(m)),\n                &ModMulData::OneLimb(inv),\n            ) => Natural::from(x.mod_mul_precomputed(y, m, &inv)),\n            (x, y, _, &ModMulData::MinTwoLimbs) => x.mod_power_of_2_mul(y, Limb::WIDTH),\n            (x, y, m, &ModMulData::TwoLimbs(inv_2, inv_1, inv_0)) => {\n                x.mod_mul_precomputed_two_limbs(y, &m, inv_2, inv_1, inv_0)\n            }\n            (x, y, m, _) => x * y % m,\n        }\n    }\n}\n\nimpl ModMulPrecomputed<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n    type Data = ModMulData;\n\n    /// Precomputes data for modular multiplication. See `mod_mul_precomputed` and\n    /// [`mod_mul_precomputed_assign`](ModMulPrecomputedAssign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// This is equivalent to part of `fmpz_mod_ctx_init` from `fmpz_mod/ctx_init.c`, FLINT 2.7.1.\n    #[inline]\n    fn precompute_mod_mul_data(m: &&Natural) -> ModMulData {\n        precompute_mod_mul_data_helper(m)\n    }\n\n    /// Multiplies two [`Natural`] modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. All three [`Natural`]s are taken by reference.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    /// assert_eq!(\n    ///     (&Natural::from(6u8)).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(9u8)).mod_mul_precomputed(\n    ///         &Natural::from(9u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     1\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(4u8)).mod_mul_precomputed(\n    ///         &Natural::from(7u32),\n    ///         &Natural::from(10u32),\n    ///         &data\n    ///     ),\n    ///     8\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from fmpz_mod/mul.c, FLINT 2.7.1, where `b`, `c`, and\n    /// `m` are taken by reference.\n    fn mod_mul_precomputed(self, other: &Natural, m: &Natural, data: &ModMulData) -> Natural {\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        match (self, other, m, data) {\n            (&Natural::ZERO, _, _, _) | (_, &Natural::ZERO, _, _) => Natural::ZERO,\n            (x, &Natural::ONE, _, _) => x.clone(),\n            (&Natural::ONE, y, _, _) => y.clone(),\n            (\n                &Natural(Small(x)),\n                &Natural(Small(y)),\n                &Natural(Small(m)),\n                &ModMulData::OneLimb(inv),\n            ) => Natural::from(x.mod_mul_precomputed(y, m, &inv)),\n            (x, y, _, &ModMulData::MinTwoLimbs) => x.mod_power_of_2_mul(y, Limb::WIDTH),\n            (x, y, m, &ModMulData::TwoLimbs(inv_2, inv_1, inv_0)) => {\n                x.mod_mul_precomputed_two_limbs(y, m, inv_2, inv_1, inv_0)\n            }\n            (x, y, m, _) => x * y % m,\n        }\n    }\n}\n\nimpl ModMulPrecomputedAssign<Self, Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by value.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModMulPrecomputed, ModMulPrecomputedAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    ///\n    /// let mut x = Natural::from(6u8);\n    /// x.mod_mul_precomputed_assign(Natural::from(7u32), Natural::from(10u32), &data);\n    /// assert_eq!(x, 2);\n    ///\n    /// let mut x = Natural::from(9u8);\n    /// x.mod_mul_precomputed_assign(Natural::from(9u32), Natural::from(10u32), &data);\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Natural::from(4u8);\n    /// x.mod_mul_precomputed_assign(Natural::from(7u32), Natural::from(10u32), &data);\n    /// assert_eq!(x, 8);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value and `a == b`.\n    fn mod_mul_precomputed_assign(&mut self, other: Self, m: Self, data: &ModMulData) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        match (&mut *self, other, m, data) {\n            (&mut Self::ZERO, _, _, _) | (_, Self::ONE, _, _) => {}\n            (x, Self::ZERO, _, _) => *x = Self::ZERO,\n            (&mut Self::ONE, y, _, _) => *self = y,\n            (&mut Self(Small(x)), Self(Small(y)), Self(Small(m)), &ModMulData::OneLimb(inv)) => {\n                *self = Self::from(x.mod_mul_precomputed(y, m, &inv));\n            }\n            (x, y, _, &ModMulData::MinTwoLimbs) => x.mod_power_of_2_mul_assign(y, Limb::WIDTH),\n            (x, y, m, &ModMulData::TwoLimbs(inv_2, inv_1, inv_0)) => {\n                x.mod_mul_precomputed_two_limbs_assign(&y, &m, inv_2, inv_1, inv_0);\n            }\n            (x, y, m, _) => {\n                *x *= y;\n                *x %= m;\n            }\n        }\n    }\n}\n\nimpl<'a> ModMulPrecomputedAssign<Self, &'a Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by value\n    /// and the second by reference.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModMulPrecomputed, ModMulPrecomputedAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    ///\n    /// let mut x = Natural::from(6u8);\n    /// x.mod_mul_precomputed_assign(Natural::from(7u32), &Natural::from(10u32), &data);\n    /// assert_eq!(x, 2);\n    ///\n    /// let mut x = Natural::from(9u8);\n    /// x.mod_mul_precomputed_assign(Natural::from(9u32), &Natural::from(10u32), &data);\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Natural::from(4u8);\n    /// x.mod_mul_precomputed_assign(Natural::from(7u32), &Natural::from(10u32), &data);\n    /// assert_eq!(x, 8);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value, `m` is taken by reference, and `a == b`.\n    fn mod_mul_precomputed_assign(&mut self, other: Self, m: &'a Self, data: &ModMulData) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            other < *m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        match (&mut *self, other, m, data) {\n            (&mut Self::ZERO, _, _, _) | (_, Self::ONE, _, _) => {}\n            (x, Self::ZERO, _, _) => *x = Self::ZERO,\n            (&mut Self::ONE, y, _, _) => *self = y,\n            (&mut Self(Small(x)), Self(Small(y)), &Self(Small(m)), &ModMulData::OneLimb(inv)) => {\n                *self = Self::from(x.mod_mul_precomputed(y, m, &inv));\n            }\n            (x, y, _, &ModMulData::MinTwoLimbs) => x.mod_power_of_2_mul_assign(y, Limb::WIDTH),\n            (x, y, m, &ModMulData::TwoLimbs(inv_2, inv_1, inv_0)) => {\n                x.mod_mul_precomputed_two_limbs_assign(&y, m, inv_2, inv_1, inv_0);\n            }\n            (x, y, m, _) => {\n                *x *= y;\n                *x %= m;\n            }\n        }\n    }\n}\n\nimpl<'a> ModMulPrecomputedAssign<&'a Self, Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by\n    /// reference and the second by value.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModMulPrecomputed, ModMulPrecomputedAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    ///\n    /// let mut x = Natural::from(6u8);\n    /// x.mod_mul_precomputed_assign(&Natural::from(7u32), Natural::from(10u32), &data);\n    /// assert_eq!(x, 2);\n    ///\n    /// let mut x = Natural::from(9u8);\n    /// x.mod_mul_precomputed_assign(&Natural::from(9u32), Natural::from(10u32), &data);\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Natural::from(4u8);\n    /// x.mod_mul_precomputed_assign(&Natural::from(7u32), Natural::from(10u32), &data);\n    /// assert_eq!(x, 8);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value, `c` is taken by reference, and `a == b`.\n    fn mod_mul_precomputed_assign(&mut self, other: &'a Self, m: Self, data: &ModMulData) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            *other < m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        match (&mut *self, other, m, data) {\n            (&mut Self::ZERO, _, _, _) | (_, &Self::ONE, _, _) => {}\n            (x, &Self::ZERO, _, _) => *x = Self::ZERO,\n            (&mut Self::ONE, y, _, _) => *self = y.clone(),\n            (&mut Self(Small(x)), &Self(Small(y)), Self(Small(m)), &ModMulData::OneLimb(inv)) => {\n                *self = Self::from(x.mod_mul_precomputed(y, m, &inv));\n            }\n            (x, y, _, &ModMulData::MinTwoLimbs) => x.mod_power_of_2_mul_assign(y, Limb::WIDTH),\n            (x, y, m, &ModMulData::TwoLimbs(inv_2, inv_1, inv_0)) => {\n                x.mod_mul_precomputed_two_limbs_assign(y, &m, inv_2, inv_1, inv_0);\n            }\n            (x, y, m, _) => {\n                *x *= y;\n                *x %= m;\n            }\n        }\n    }\n}\n\nimpl<'a, 'b> ModMulPrecomputedAssign<&'a Self, &'b Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by reference.\n    ///\n    /// Some precomputed data is provided; this speeds up computations involving several modular\n    /// multiplications with the same modulus. The precomputed data should be obtained using\n    /// [`precompute_mod_mul_data`](ModMulPrecomputed::precompute_mod_mul_data).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModMulPrecomputed, ModMulPrecomputedAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&Natural::from(10u32));\n    ///\n    /// let mut x = Natural::from(6u8);\n    /// x.mod_mul_precomputed_assign(&Natural::from(7u32), &Natural::from(10u32), &data);\n    /// assert_eq!(x, 2);\n    ///\n    /// let mut x = Natural::from(9u8);\n    /// x.mod_mul_precomputed_assign(&Natural::from(9u32), &Natural::from(10u32), &data);\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Natural::from(4u8);\n    /// x.mod_mul_precomputed_assign(&Natural::from(7u32), &Natural::from(10u32), &data);\n    /// assert_eq!(x, 8);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` is\n    /// taken by value, `c` and `m` are taken by reference, and `a == b`.\n    fn mod_mul_precomputed_assign(&mut self, other: &'a Self, m: &'b Self, data: &ModMulData) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        match (&mut *self, other, m, data) {\n            (&mut Self::ZERO, _, _, _) | (_, &Self::ONE, _, _) => {}\n            (x, &Self::ZERO, _, _) => *x = Self::ZERO,\n            (&mut Self::ONE, y, _, _) => *self = y.clone(),\n            (&mut Self(Small(x)), &Self(Small(y)), &Self(Small(m)), &ModMulData::OneLimb(inv)) => {\n                *self = Self::from(x.mod_mul_precomputed(y, m, &inv));\n            }\n            (x, y, _, &ModMulData::MinTwoLimbs) => x.mod_power_of_2_mul_assign(y, Limb::WIDTH),\n            (x, y, m, &ModMulData::TwoLimbs(inv_2, inv_1, inv_0)) => {\n                x.mod_mul_precomputed_two_limbs_assign(y, m, inv_2, inv_1, inv_0);\n            }\n            (x, y, m, _) => {\n                *x *= y;\n                *x %= m;\n            }\n        }\n    }\n}\n\nimpl ModMul<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. All three [`Natural`]s are taken by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_mul(Natural::from(4u32), Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_mul(Natural::from(6u32), Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value.\n    #[inline]\n    fn mod_mul(self, other: Self, m: Self) -> Self {\n        let data = precompute_mod_mul_data_helper(&m);\n        self.mod_mul_precomputed(other, m, &data)\n    }\n}\n\nimpl<'a> ModMul<Self, &'a Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first two [`Natural`]s are taken by value and the third by\n    /// reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_mul(Natural::from(4u32), &Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_mul(Natural::from(6u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value and `m` is taken by reference.\n    #[inline]\n    fn mod_mul(self, other: Self, m: &'a Self) -> Self {\n        self.mod_mul_precomputed(other, m, &precompute_mod_mul_data_helper(m))\n    }\n}\n\nimpl<'a> ModMul<&'a Self, Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first and third [`Natural`]s are taken by value and the second by\n    /// reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_mul(&Natural::from(4u32), Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_mul(&Natural::from(6u32), Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value and `c` is taken by reference.\n    #[inline]\n    fn mod_mul(self, other: &'a Self, m: Self) -> Self {\n        let data = precompute_mod_mul_data_helper(&m);\n        self.mod_mul_precomputed(other, m, &data)\n    }\n}\n\nimpl<'a, 'b> ModMul<&'a Self, &'b Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] is taken by value and the second and third by\n    /// reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_mul(&Natural::from(4u32), &Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_mul(&Natural::from(6u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` is\n    /// taken by value and `c` and `m` are taken by reference.\n    #[inline]\n    fn mod_mul(self, other: &'a Self, m: &'b Self) -> Self {\n        self.mod_mul_precomputed(other, m, &precompute_mod_mul_data_helper(m))\n    }\n}\n\nimpl ModMul<Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] is taken by reference and the second and third by\n    /// value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_mul(Natural::from(4u32), Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_mul(Natural::from(6u32), Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` is\n    /// taken by reference and `c` and `m` are taken by value.\n    #[inline]\n    fn mod_mul(self, other: Natural, m: Natural) -> Natural {\n        let data = precompute_mod_mul_data_helper(&m);\n        self.mod_mul_precomputed(other, m, &data)\n    }\n}\n\nimpl ModMul<Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first and third [`Natural`]s are taken by reference and the second\n    /// by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_mul(Natural::from(4u32), &Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_mul(Natural::from(6u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by reference and `c` is taken by value.\n    #[inline]\n    fn mod_mul(self, other: Natural, m: &Natural) -> Natural {\n        self.mod_mul_precomputed(other, m, &precompute_mod_mul_data_helper(m))\n    }\n}\n\nimpl ModMul<&Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first two [`Natural`]s are taken by reference and the third by\n    /// value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_mul(&Natural::from(4u32), Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_mul(&Natural::from(6u32), Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by reference and `m` is taken by value.\n    #[inline]\n    fn mod_mul(self, other: &Natural, m: Natural) -> Natural {\n        let data = precompute_mod_mul_data_helper(&m);\n        self.mod_mul_precomputed(other, m, &data)\n    }\n}\n\nimpl ModMul<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. All three [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_mul(&Natural::from(4u32), &Natural::from(15u32)),\n    ///     12\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_mul(&Natural::from(6u32), &Natural::from(10u32)),\n    ///     2\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by reference.\n    #[inline]\n    fn mod_mul(self, other: &Natural, m: &Natural) -> Natural {\n        self.mod_mul_precomputed(other, m, &precompute_mod_mul_data_helper(m))\n    }\n}\n\nimpl ModMulAssign<Self, Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_mul_assign(Natural::from(4u32), Natural::from(15u32));\n    /// assert_eq!(x, 12);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_mul_assign(Natural::from(6u32), Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value and `a == b`.\n    #[inline]\n    fn mod_mul_assign(&mut self, other: Self, m: Self) {\n        let data = precompute_mod_mul_data_helper(&m);\n        self.mod_mul_precomputed_assign(other, m, &data);\n    }\n}\n\nimpl<'a> ModMulAssign<Self, &'a Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by value\n    /// and the second by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_mul_assign(Natural::from(4u32), &Natural::from(15u32));\n    /// assert_eq!(x, 12);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_mul_assign(Natural::from(6u32), &Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value, `m` is taken by reference, and `a == b`.\n    #[inline]\n    fn mod_mul_assign(&mut self, other: Self, m: &'a Self) {\n        self.mod_mul_precomputed_assign(other, m, &precompute_mod_mul_data_helper(m));\n    }\n}\n\nimpl<'a> ModMulAssign<&'a Self, Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by\n    /// reference and the second by value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_mul_assign(&Natural::from(4u32), Natural::from(15u32));\n    /// assert_eq!(x, 12);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_mul_assign(&Natural::from(6u32), Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value, `c` is taken by reference, and `a == b`.\n    #[inline]\n    fn mod_mul_assign(&mut self, other: &'a Self, m: Self) {\n        let data = precompute_mod_mul_data_helper(&m);\n        self.mod_mul_precomputed_assign(other, m, &data);\n    }\n}\n\nimpl<'a, 'b> ModMulAssign<&'a Self, &'b Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $xy \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModMulAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_mul_assign(&Natural::from(4u32), &Natural::from(15u32));\n    /// assert_eq!(x, 12);\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_mul_assign(&Natural::from(6u32), &Natural::from(10u32));\n    /// assert_eq!(x, 2);\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_mulN` from `fmpz_mod/mul.c`, FLINT 2.7.1, where `b` is\n    /// taken by value, `c` and `m` are taken by reference, and `a == b`.\n    #[inline]\n    fn mod_mul_assign(&mut self, other: &'a Self, m: &'b Self) {\n        self.mod_mul_precomputed_assign(other, m, &precompute_mod_mul_data_helper(m));\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ModNeg, ModNegAssign};\nuse malachite_base::num::basic::traits::Zero;\n\nimpl ModNeg<Self> for Natural {\n    type Output = Self;\n\n    /// Negates a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. Both [`Natural`]s are taken by value.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$ and $-x \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModNeg, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_neg(Natural::from(5u32)), 0);\n    /// assert_eq!(Natural::from(7u32).mod_neg(Natural::from(10u32)), 3);\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_neg(Natural::from(10u32).pow(12)),\n    ///     999999999993u64\n    /// );\n    /// ```\n    #[inline]\n    fn mod_neg(mut self, m: Self) -> Self {\n        self.mod_neg_assign(&m);\n        self\n    }\n}\n\nimpl<'a> ModNeg<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Negates a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. The first [`Natural`] is taken by value and the second by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModNeg, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_neg(&Natural::from(5u32)), 0);\n    /// assert_eq!(Natural::from(7u32).mod_neg(&Natural::from(10u32)), 3);\n    /// assert_eq!(\n    ///     Natural::from(7u32).mod_neg(&Natural::from(10u32).pow(12)),\n    ///     999999999993u64\n    /// );\n    /// ```\n    #[inline]\n    fn mod_neg(mut self, m: &'a Self) -> Self {\n        self.mod_neg_assign(m);\n        self\n    }\n}\n\nimpl ModNeg<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Negates a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. The first [`Natural`] is taken by reference and the second by value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModNeg, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).mod_neg(Natural::from(5u32)), 0);\n    /// assert_eq!((&Natural::from(7u32)).mod_neg(Natural::from(10u32)), 3);\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_neg(Natural::from(10u32).pow(12)),\n    ///     999999999993u64\n    /// );\n    /// ```\n    fn mod_neg(self, m: Natural) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        if *self == 0 { Natural::ZERO } else { m - self }\n    }\n}\n\nimpl ModNeg<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Negates a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. Both [`Natural`]s are taken by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModNeg, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).mod_neg(&Natural::from(5u32)), 0);\n    /// assert_eq!((&Natural::from(7u32)).mod_neg(&Natural::from(10u32)), 3);\n    /// assert_eq!(\n    ///     (&Natural::from(7u32)).mod_neg(&Natural::from(10u32).pow(12)),\n    ///     999999999993u64\n    /// );\n    /// ```\n    fn mod_neg(self, m: &Natural) -> Natural {\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        if *self == 0 { Natural::ZERO } else { m - self }\n    }\n}\n\nimpl ModNegAssign<Self> for Natural {\n    /// Negates a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. The [`Natural`] on the right-hand side is taken by value.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $-x \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModNegAssign, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::ZERO;\n    /// n.mod_neg_assign(Natural::from(5u32));\n    /// assert_eq!(n, 0);\n    ///\n    /// let mut n = Natural::from(7u32);\n    /// n.mod_neg_assign(Natural::from(10u32));\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Natural::from(7u32);\n    /// n.mod_neg_assign(Natural::from(10u32).pow(12));\n    /// assert_eq!(n, 999999999993u64);\n    /// ```\n    #[inline]\n    fn mod_neg_assign(&mut self, m: Self) {\n        self.mod_neg_assign(&m);\n    }\n}\n\nimpl<'a> ModNegAssign<&'a Self> for Natural {\n    /// Negates a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. The [`Natural`] on the right-hand side is taken by reference.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $-x \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModNegAssign, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::ZERO;\n    /// n.mod_neg_assign(&Natural::from(5u32));\n    /// assert_eq!(n, 0);\n    ///\n    /// let mut n = Natural::from(7u32);\n    /// n.mod_neg_assign(&Natural::from(10u32));\n    /// assert_eq!(n, 3);\n    ///\n    /// let mut n = Natural::from(7u32);\n    /// n.mod_neg_assign(&Natural::from(10u32).pow(12));\n    /// assert_eq!(n, 999999999993u64);\n    /// ```\n    fn mod_neg_assign(&mut self, m: &'a Self) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        if *self != 0 {\n            assert!(!self.sub_right_assign_no_panic(m));\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_dcpi1_div_qr`, `mpn_dcpi1_div_qr_n`, `mpn_mu_div_qr`, `mpn_mu_div_qr2`,\n//      `mpn_preinv_mu_div_qr`, and `mpn_sbpi1_div_qr` contributed to the GNU project by Torbjörn\n//      Granlund.\n//\n//      `mpn_mod_1s_2p_cps`, `mpn_mod_1s_2p`, `mpn_mod_1s_4p_cps`, and `mpn_mod_1s_4p` contributed\n//      to the GNU project by Torbjörn Granlund. Based on a suggestion by Peter L. Montgomery.\n//\n//      `mpn_div_qr_1` contributed to the GNU project by Niels Möller and Torbjörn Granlund.\n//\n//      `mpn_div_qr_1n_pi1` contributed to the GNU project by Niels Möller.\n//\n//      Copyright © 1991, 1993-1996, 1997, 1998-2002, 2003, 2005-2010, 2012, 2013, 2015 Free\n//      Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::div_mod::{\n    MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD, MUPI_DIV_QR_THRESHOLD, limbs_div_barrett_large_product,\n    limbs_div_mod_balanced, limbs_div_mod_barrett_helper, limbs_div_mod_barrett_is_len,\n    limbs_div_mod_barrett_scratch_len, limbs_div_mod_by_two_limb_normalized,\n    limbs_div_mod_divide_and_conquer_helper, limbs_div_mod_schoolbook,\n    limbs_div_mod_three_limb_by_two_limb, limbs_invert_approx, limbs_invert_limb,\n    limbs_two_limb_inverse_helper,\n};\nuse crate::natural::arithmetic::mul::mul_mod::limbs_mul_mod_base_pow_n_minus_1_next_size;\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::limbs_shl_to_out;\nuse crate::natural::arithmetic::shr::{limbs_shr_to_out, limbs_slice_shr_in_place};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n    limbs_sub_same_length_in_place_right, limbs_sub_same_length_to_out,\n    limbs_sub_same_length_with_borrow_in_in_place_left,\n    limbs_sub_same_length_with_borrow_in_in_place_right,\n};\nuse crate::natural::arithmetic::sub_mul::limbs_sub_mul_limb_same_length_in_place_left;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{\n    DC_DIV_QR_THRESHOLD, DoubleLimb, Limb, MOD_1_1_TO_MOD_1_2_THRESHOLD, MOD_1_1P_METHOD,\n    MOD_1_2_TO_MOD_1_4_THRESHOLD, MOD_1_NORM_THRESHOLD, MOD_1_UNNORM_THRESHOLD,\n    MOD_1N_TO_MOD_1_1_THRESHOLD, MOD_1U_TO_MOD_1_1_THRESHOLD, MU_DIV_QR_SKEW_THRESHOLD,\n    MU_DIV_QR_THRESHOLD,\n};\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse core::mem::swap;\nuse core::ops::{Rem, RemAssign};\nuse malachite_base::num::arithmetic::traits::{\n    Mod, ModAssign, ModPowerOf2, NegMod, NegModAssign, Parity, WrappingAddAssign, WrappingSubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{HasHalf, JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::slices::{slice_move_left, slice_set_zero};\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `udiv_qrnnd_preinv` from `gmp-impl.h`, GMP 6.2.1, but not computing the\n// quotient.\npub_test! {mod_by_preinversion<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half=T>,\n    T: PrimitiveUnsigned,\n>(\n    n_high: T,\n    n_low: T,\n    d: T,\n    d_inv: T,\n) -> T {\n    let (q_high, q_low) = (DT::from(n_high) * DT::from(d_inv))\n        .wrapping_add(DT::join_halves(n_high.wrapping_add(T::ONE), n_low))\n        .split_in_half();\n    let mut r = n_low.wrapping_sub(q_high.wrapping_mul(d));\n    if r > q_low {\n        r.wrapping_add_assign(d);\n    }\n    if r >= d {\n        r -= d;\n    }\n    r\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// remainder when the `Natural` is divided by a `Limb`.\n//\n// The divisor limb cannot be zero and the input limb slice must have at least two elements.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if the length of `ns` is less than 2 or if `d` is zero.\n#[cfg(feature = \"32_bit_limbs\")]\n#[cfg(feature = \"test_build\")]\n#[inline]\npub fn limbs_mod_limb<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half = T>,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    limbs_mod_limb_alt_2::<DT, T>(ns, d)\n}\n#[cfg(feature = \"32_bit_limbs\")]\n#[cfg(not(feature = \"test_build\"))]\n#[inline]\npub(crate) fn limbs_mod_limb<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half = T>,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    limbs_mod_limb_alt_2::<DT, T>(ns, d)\n}\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[cfg(feature = \"test_build\")]\n#[inline]\npub fn limbs_mod_limb<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half = T>,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[Limb],\n    d: Limb,\n) -> Limb {\n    limbs_mod_limb_alt_1::<DoubleLimb, Limb>(ns, d)\n}\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[cfg(not(feature = \"test_build\"))]\npub(crate) fn limbs_mod_limb<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half = T>,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    limbs_mod_limb_alt_1::<DT, T>(ns, d)\n}\n\n// Computes the remainder of `[n_2, n_1, n_0]` / `[d_1, d_0]`. Requires the highest bit of `d_1` to\n// be set, and `[n_2, n_1]` < `[d_1, d_0]`. `d_inv` is the inverse of `[d_1, d_0]` computed by\n// `limbs_two_limb_inverse_helper`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `udiv_qr_3by2` from `gmp-impl.h`, GMP 6.2.1, returning only the remainder.\npub_test! {limbs_mod_three_limb_by_two_limb(\n    n_2: Limb,\n    n_1: Limb,\n    n_0: Limb,\n    d_1: Limb,\n    d_0: Limb,\n    d_inv: Limb,\n) -> DoubleLimb {\n    let (q, q_lo) = (DoubleLimb::from(n_2) * DoubleLimb::from(d_inv))\n        .wrapping_add(DoubleLimb::join_halves(n_2, n_1))\n        .split_in_half();\n    let d = DoubleLimb::join_halves(d_1, d_0);\n    // Compute the two most significant limbs of n - q * d\n    let r = DoubleLimb::join_halves(n_1.wrapping_sub(d_1.wrapping_mul(q)), n_0)\n        .wrapping_sub(d)\n        .wrapping_sub(DoubleLimb::from(d_0) * DoubleLimb::from(q));\n    // Conditionally adjust the remainder\n    if r.upper_half() >= q_lo {\n        let (r_plus_d, overflow) = r.overflowing_add(d);\n        if overflow {\n            return r_plus_d;\n        }\n    } else if r >= d {\n        return r.wrapping_sub(d);\n    }\n    r\n}}\n\n// Divides `ns` by `ds`, returning the limbs of the remainder. `ds` must have length 2, `ns` must\n// have length at least 2, and the most significant bit of `ds[1]` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` does not have length 2, `ns` has length less than 2, `qs` has length less than\n// `ns.len() - 2`, or `ds[1]` does not have its highest bit set.\n//\n// This is equivalent to `mpn_divrem_2` from `mpn/generic/divrem_2.c`, GMP 6.2.1, returning the two\n// limbs of the remainder.\npub_test! {limbs_mod_by_two_limb_normalized(ns: &[Limb], ds: &[Limb]) -> (Limb, Limb) {\n    assert_eq!(ds.len(), 2);\n    let n_len = ns.len();\n    assert!(n_len >= 2);\n    let n_limit = n_len - 2;\n    assert!(ds[1].get_highest_bit());\n    let d_1 = ds[1];\n    let d_0 = ds[0];\n    let d = DoubleLimb::join_halves(d_1, d_0);\n    let mut r = DoubleLimb::join_halves(ns[n_limit + 1], ns[n_limit]);\n    if r >= d {\n        r.wrapping_sub_assign(d);\n    }\n    let (mut r_1, mut r_0) = r.split_in_half();\n    let d_inv = limbs_two_limb_inverse_helper(d_1, d_0);\n    for &n in ns[..n_limit].iter().rev() {\n        (r_1, r_0) = limbs_mod_three_limb_by_two_limb(r_1, r_0, n, d_1, d_0, d_inv).split_in_half();\n    }\n    (r_0, r_1)\n}}\n\n// Divides `ns` by `ds` and writes the `ds.len()` limbs of the remainder to `ns`. `ds` must have\n// length greater than 2, `ns` must be at least as long as `ds`, and the most significant bit of\n// `ds` must be set. `d_inv` should be the result of `limbs_two_limb_inverse_helper` applied to the\n// two highest limbs of the denominator.\n//\n// # Worst-case complexity\n// $T(n, d) = O(d(n - d + 1)) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ns.len()`, and $d$ is `ds.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 3, `ns` is shorter than `ds`, or the last limb of `ds`\n// does not have its highest bit set.\n//\n// This is equivalent to `mpn_sbpi1_div_qr` from `mpn/generic/sbpi1_div_qr.c`, GMP 6.2.1, where only\n// the remainder is calculated.\npub_test! {limbs_mod_schoolbook(ns: &mut [Limb], ds: &[Limb], d_inv: Limb) {\n    let d_len = ds.len();\n    assert!(d_len > 2);\n    let n_len = ns.len();\n    assert!(n_len >= d_len);\n    let (d_1, ds_init) = ds.split_last().unwrap();\n    let d_1 = *d_1;\n    assert!(d_1.get_highest_bit());\n    let (d_0, ds_init_init) = ds_init.split_last().unwrap();\n    let d_0 = *d_0;\n    let ns_hi = &mut ns[n_len - d_len..];\n    if limbs_cmp_same_length(ns_hi, ds) >= Equal {\n        limbs_sub_same_length_in_place_left(ns_hi, ds);\n    }\n    let mut n_1 = ns[n_len - 1];\n    for i in (d_len..n_len).rev() {\n        let j = i - d_len;\n        if n_1 == d_1 && ns[i - 1] == d_0 {\n            limbs_sub_mul_limb_same_length_in_place_left(&mut ns[j..i], ds, Limb::MAX);\n            n_1 = ns[i - 1]; // update n_1, last loop's value will now be invalid\n        } else {\n            let (ns_lo, ns_hi) = ns.split_at_mut(i - 2);\n            let (q, n) =\n                limbs_div_mod_three_limb_by_two_limb(n_1, ns_hi[1], ns_hi[0], d_1, d_0, d_inv);\n            let mut n_0;\n            (n_1, n_0) = n.split_in_half();\n            let local_carry_1 =\n                limbs_sub_mul_limb_same_length_in_place_left(&mut ns_lo[j..], ds_init_init, q);\n            let local_carry_2 = n_0 < local_carry_1;\n            n_0.wrapping_sub_assign(local_carry_1);\n            let carry = local_carry_2 && n_1 == 0;\n            if local_carry_2 {\n                n_1.wrapping_sub_assign(1);\n            }\n            ns_hi[0] = n_0;\n            if carry {\n                n_1.wrapping_add_assign(d_1);\n                if limbs_slice_add_same_length_in_place_left(&mut ns[j..i - 1], ds_init) {\n                    n_1.wrapping_add_assign(1);\n                }\n            }\n        }\n    }\n    ns[d_len - 1] = n_1;\n}}\n\n// `qs` is just used as scratch space.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n(\\log n)^2)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// This is equivalent to `mpn_dcpi1_div_qr_n` from `mpn/generic/dcpi1_div_qr.c`, GMP 6.2.1, where\n// only the remainder is calculated.\nfn limbs_mod_divide_and_conquer_helper(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb,\n    scratch: &mut [Limb],\n) {\n    let n = ds.len();\n    let lo = n >> 1; // floor(n / 2)\n    let hi = n - lo; // ceil(n / 2)\n    let qs_hi = &mut qs[lo..];\n    let (ds_lo, ds_hi) = ds.split_at(lo);\n    let highest_q = if hi < DC_DIV_QR_THRESHOLD {\n        limbs_div_mod_schoolbook(qs_hi, &mut ns[lo << 1..n << 1], ds_hi, d_inv)\n    } else {\n        limbs_div_mod_divide_and_conquer_helper(qs_hi, &mut ns[lo << 1..], ds_hi, d_inv, scratch)\n    };\n    let qs_hi = &mut qs_hi[..hi];\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(qs_hi.len(), ds_lo.len())];\n    limbs_mul_greater_to_out(scratch, qs_hi, ds_lo, &mut mul_scratch);\n    let ns_lo = &mut ns[..n + lo];\n    let mut carry = Limb::from(limbs_sub_same_length_in_place_left(\n        &mut ns_lo[lo..],\n        &scratch[..n],\n    ));\n    if highest_q && limbs_sub_same_length_in_place_left(&mut ns_lo[n..], ds_lo) {\n        carry += 1;\n    }\n    while carry != 0 {\n        limbs_sub_limb_in_place(qs_hi, 1);\n        if limbs_slice_add_same_length_in_place_left(&mut ns_lo[lo..], ds) {\n            carry -= 1;\n        }\n    }\n    let (ds_lo, ds_hi) = ds.split_at(hi);\n    let q_lo = if lo < DC_DIV_QR_THRESHOLD {\n        limbs_div_mod_schoolbook(qs, &mut ns[hi..n + lo], ds_hi, d_inv)\n    } else {\n        limbs_div_mod_divide_and_conquer_helper(qs, &mut ns[hi..], ds_hi, d_inv, scratch)\n    };\n    let qs_lo = &mut qs[..lo];\n    let ns_lo = &mut ns[..n];\n    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds_lo.len(), lo)];\n    limbs_mul_greater_to_out(scratch, ds_lo, qs_lo, &mut mul_scratch);\n    let mut carry = Limb::from(limbs_sub_same_length_in_place_left(ns_lo, &scratch[..n]));\n    if q_lo && limbs_sub_same_length_in_place_left(&mut ns_lo[lo..], ds_lo) {\n        carry += 1;\n    }\n    while carry != 0 {\n        if limbs_slice_add_same_length_in_place_left(ns_lo, ds) {\n            carry -= 1;\n        }\n    }\n}\n\n// `qs` is just used as scratch space.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n(\\log n)^2)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ds.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 6, `ns.len()` is less than `ds.len()` + 3, `qs` has length\n// less than `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_dcpi1_div_qr` from `mpn/generic/dcpi1_div_qr.c`, GMP 6.2.1, where only\n// the remainder is calculated.\npub_test! {limbs_mod_divide_and_conquer(\n    qs: &mut [Limb],\n    ns: &mut [Limb],\n    ds: &[Limb],\n    d_inv: Limb\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len >= 6); // to adhere to limbs_div_mod_schoolbook's limits\n    assert!(n_len >= d_len + 3); // to adhere to limbs_div_mod_schoolbook's limits\n    let a = d_len - 1;\n    let d_1 = ds[a];\n    let b = d_len - 2;\n    assert!(d_1.get_highest_bit());\n    let mut scratch = vec![0; d_len];\n    let q_len = n_len - d_len;\n    if q_len > d_len {\n        let q_len_mod_d_len = {\n            let mut m = q_len % d_len;\n            if m == 0 {\n                m = d_len;\n            }\n            m\n        };\n        // Perform the typically smaller block first. point at low limb of next quotient block\n        let qs_block = &mut qs[q_len - q_len_mod_d_len..q_len];\n        if q_len_mod_d_len == 1 {\n            // Handle highest_q up front, for simplicity.\n            let ns = &mut ns[q_len - 1..];\n            let ns_tail = &mut ns[1..];\n            if limbs_cmp_same_length(ns_tail, ds) >= Equal {\n                assert!(!limbs_sub_same_length_in_place_left(ns_tail, ds));\n            }\n            // A single iteration of schoolbook: One 3/2 division, followed by the bignum update and\n            // adjustment.\n            let (last_n, ns) = ns.split_last_mut().unwrap();\n            let n_2 = *last_n;\n            let mut n_1 = ns[a];\n            let mut n_0 = ns[b];\n            let d_0 = ds[b];\n            assert!(n_2 < d_1 || n_2 == d_1 && n_1 <= d_0);\n            let mut q;\n            if n_2 == d_1 && n_1 == d_0 {\n                q = Limb::MAX;\n                assert_eq!(limbs_sub_mul_limb_same_length_in_place_left(ns, ds, q), n_2);\n            } else {\n                let n;\n                (q, n) = limbs_div_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, d_inv);\n                (n_1, n_0) = n.split_in_half();\n                // d_len > 2 because of precondition. No need to check\n                let local_carry_1 =\n                    limbs_sub_mul_limb_same_length_in_place_left(&mut ns[..b], &ds[..b], q);\n                let local_carry_2 = n_0 < local_carry_1;\n                n_0.wrapping_sub_assign(local_carry_1);\n                let carry = local_carry_2 && n_1 == 0;\n                if local_carry_2 {\n                    n_1.wrapping_sub_assign(1);\n                }\n                ns[b] = n_0;\n                let (ns_last, ns_init) = ns.split_last_mut().unwrap();\n                if carry {\n                    n_1.wrapping_add_assign(d_1);\n                    if limbs_slice_add_same_length_in_place_left(ns_init, &ds[..a]) {\n                        n_1.wrapping_add_assign(1);\n                    }\n                    q.wrapping_sub_assign(1);\n                }\n                *ns_last = n_1;\n            }\n            qs_block[0] = q;\n        } else {\n            // Do a 2 * q_len_mod_d_len / q_len_mod_d_len division\n            let (ds_lo, ds_hi) = ds.split_at(d_len - q_len_mod_d_len);\n            let highest_q = {\n                let ns = &mut ns[n_len - (q_len_mod_d_len << 1)..];\n                if q_len_mod_d_len == 2 {\n                    limbs_div_mod_by_two_limb_normalized(qs_block, ns, ds_hi)\n                } else if q_len_mod_d_len < DC_DIV_QR_THRESHOLD {\n                    limbs_div_mod_schoolbook(qs_block, ns, ds_hi, d_inv)\n                } else {\n                    limbs_div_mod_divide_and_conquer_helper(\n                        qs_block,\n                        ns,\n                        ds_hi,\n                        d_inv,\n                        &mut scratch,\n                    )\n                }\n            };\n            if q_len_mod_d_len != d_len {\n                let mut mul_scratch =\n                    vec![0; limbs_mul_to_out_scratch_len(qs_block.len(), ds_lo.len())];\n                limbs_mul_to_out(&mut scratch, qs_block, ds_lo, &mut mul_scratch);\n                let ns = &mut ns[q_len - q_len_mod_d_len..n_len - q_len_mod_d_len];\n                let mut carry = Limb::from(limbs_sub_same_length_in_place_left(ns, &scratch));\n                if highest_q\n                    && limbs_sub_same_length_in_place_left(&mut ns[q_len_mod_d_len..], ds_lo)\n                {\n                    carry += 1;\n                }\n                while carry != 0 {\n                    limbs_sub_limb_in_place(qs_block, 1);\n                    if limbs_slice_add_same_length_in_place_left(ns, ds) {\n                        carry -= 1;\n                    }\n                }\n            }\n        }\n        // offset is a multiple of d_len\n        let mut offset = n_len.checked_sub(d_len + q_len_mod_d_len).unwrap();\n        while offset != 0 {\n            offset -= d_len;\n            limbs_mod_divide_and_conquer_helper(\n                &mut qs[offset..],\n                &mut ns[offset..],\n                ds,\n                d_inv,\n                &mut scratch,\n            );\n        }\n    } else {\n        let m = d_len - q_len;\n        let (ds_lo, ds_hi) = ds.split_at(m);\n        let highest_q = if q_len < DC_DIV_QR_THRESHOLD {\n            limbs_div_mod_schoolbook(qs, &mut ns[m..], ds_hi, d_inv)\n        } else {\n            limbs_div_mod_divide_and_conquer_helper(qs, &mut ns[m..], ds_hi, d_inv, &mut scratch)\n        };\n        if m != 0 {\n            let qs = &mut qs[..q_len];\n            let ns = &mut ns[..d_len];\n            let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(q_len, ds_lo.len())];\n            limbs_mul_to_out(&mut scratch, qs, ds_lo, &mut mul_scratch);\n            let mut carry = Limb::from(limbs_sub_same_length_in_place_left(ns, &scratch));\n            if highest_q && limbs_sub_same_length_in_place_left(&mut ns[q_len..], ds_lo) {\n                carry += 1;\n            }\n            while carry != 0 {\n                if limbs_slice_add_same_length_in_place_left(ns, ds) {\n                    carry -= 1;\n                }\n            }\n        }\n    }\n}}\n\n// `qs` is just used as scratch space.\n//\n// # Worst-case complexity\n// $T(n, d) = O(n \\log d \\log\\log d)$\n//\n// $M(n) = O(d(\\log d)^2)$\n//\n// where $T$ is time, $M$ is additional memory, n$ is `ns.len()`, and $d$ is `ds.len()`.\n//\n// This is equivalent to `mpn_preinv_mu_div_qr` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1, where\n// only the remainder is calculated.\nfn limbs_mod_barrett_preinverted(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    mut is: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_eq!(rs.len(), d_len);\n    let mut i_len = is.len();\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    let (ns_lo, ns_hi) = ns.split_at(q_len);\n    if limbs_cmp_same_length(ns_hi, ds) >= Equal {\n        limbs_sub_same_length_to_out(rs, ns_hi, ds);\n    } else {\n        rs.copy_from_slice(ns_hi);\n    }\n    let scratch_len = if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n        0\n    } else {\n        limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1)\n    };\n    let mut n = d_len - i_len;\n    for (ns, qs) in ns_lo.rchunks(i_len).zip(qs.rchunks_mut(i_len)) {\n        let chunk_len = ns.len();\n        if i_len != chunk_len {\n            // last iteration\n            is = &is[i_len - chunk_len..];\n            i_len = chunk_len;\n            n = d_len - i_len;\n        }\n        let (rs_lo, rs_hi) = rs.split_at_mut(n);\n        // Compute the next block of quotient limbs by multiplying the inverse by the upper part of\n        // the partial remainder.\n        let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(is.len())];\n        limbs_mul_same_length_to_out(scratch, rs_hi, is, &mut mul_scratch);\n        // The inverse's most significant bit is implicit.\n        assert!(!limbs_add_same_length_to_out(\n            qs,\n            &scratch[i_len..i_len << 1],\n            rs_hi,\n        ));\n        // Compute the product of the quotient block and the divisor, to be subtracted from the\n        // partial remainder combined with new limbs from the dividend. We only really need the low\n        // d_len + 1 limbs.\n        if i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD {\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ds.len(), qs.len())];\n            limbs_mul_greater_to_out(scratch, ds, qs, &mut mul_scratch);\n        } else {\n            limbs_div_barrett_large_product(scratch, ds, qs, rs_hi, scratch_len, i_len);\n        }\n        let mut r = rs_hi[0].wrapping_sub(scratch[d_len]);\n        // Subtract the product from the partial remainder combined with new limbs from the\n        // dividend, generating a new partial remainder.\n        let scratch = &mut scratch[..d_len];\n        let carry = if n == 0 {\n            // Get next i_len limbs from n.\n            limbs_sub_same_length_to_out(rs, ns, scratch)\n        } else {\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(i_len);\n            // Get next i_len limbs from n.\n            let carry = limbs_sub_same_length_with_borrow_in_in_place_right(\n                rs_lo,\n                scratch_hi,\n                limbs_sub_same_length_in_place_right(ns, scratch_lo),\n            );\n            rs.copy_from_slice(scratch);\n            carry\n        };\n        // Check the remainder.\n        if carry {\n            r.wrapping_sub_assign(1);\n        }\n        while r != 0 {\n            // We loop 0 times with about 69% probability, 1 time with about 31% probability, and 2\n            // times with about 0.6% probability, if the inverse is computed as recommended.\n            if limbs_sub_same_length_in_place_left(rs, ds) {\n                r -= 1;\n            }\n        }\n        if limbs_cmp_same_length(rs, ds) >= Equal {\n            // This is executed with about 76% probability.\n            limbs_sub_same_length_in_place_left(rs, ds);\n        }\n    }\n}\n\n// `qs` is just used as scratch space.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mu_div_qr2` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1, where only the\n// remainder is calculated.\npub_test! {limbs_mod_barrett_helper(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert_eq!(rs.len(), d_len);\n    assert!(d_len > 1);\n    assert!(n_len > d_len);\n    let q_len = n_len - d_len;\n    // Compute the inverse size.\n    let i_len = limbs_div_mod_barrett_is_len(q_len, d_len);\n    assert!(i_len <= d_len);\n    let i_len_plus_1 = i_len + 1;\n    let (is, scratch_hi) = scratch.split_at_mut(i_len_plus_1);\n    // compute an approximate inverse on i_len + 1 limbs\n    if d_len == i_len {\n        let (scratch_lo, scratch_hi) = scratch_hi.split_at_mut(i_len_plus_1);\n        let (scratch_first, scratch_lo_tail) = scratch_lo.split_first_mut().unwrap();\n        scratch_lo_tail.copy_from_slice(&ds[..i_len]);\n        *scratch_first = 1;\n        limbs_invert_approx(is, scratch_lo, scratch_hi);\n        slice_move_left(is, 1);\n    } else if limbs_add_limb_to_out(scratch_hi, &ds[d_len - i_len_plus_1..], 1) {\n        slice_set_zero(&mut is[..i_len]);\n    } else {\n        let (scratch_lo, scratch_hi) = scratch_hi.split_at_mut(i_len_plus_1);\n        limbs_invert_approx(is, scratch_lo, scratch_hi);\n        slice_move_left(is, 1);\n    }\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(i_len);\n    limbs_mod_barrett_preinverted(qs, rs, ns, ds, scratch_lo, scratch_hi);\n}}\n\n// `qs` is just used as scratch space.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and n$ is `ns.len()`.\nfn limbs_mod_barrett_large_helper(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = qs.len();\n    let q_len_plus_one = q_len + 1;\n    let n = n_len - q_len - q_len_plus_one; // 2 * d_len - n_len - 1\n    let (ns_lo, ns_hi) = ns.split_at(n);\n    let (ds_lo, ds_hi) = ds.split_at(d_len - q_len_plus_one);\n    let (rs_lo, rs_hi) = rs.split_at_mut(n);\n    let rs_hi = &mut rs_hi[..q_len_plus_one];\n    let highest_q = limbs_div_mod_barrett_helper(qs, rs_hi, ns_hi, ds_hi, scratch);\n    // Multiply the quotient by the divisor limbs ignored above. The product is d_len - 1 limbs\n    // long.\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(ds_lo.len(), qs.len())];\n    limbs_mul_to_out(scratch, ds_lo, qs, &mut mul_scratch);\n    let (scratch_last, scratch_init) = scratch[..d_len].split_last_mut().unwrap();\n    *scratch_last = Limb::from(\n        highest_q && limbs_slice_add_same_length_in_place_left(&mut scratch_init[q_len..], ds_lo),\n    );\n    let (scratch_lo, scratch_hi) = scratch.split_at(n);\n    let scratch_hi = &scratch_hi[..q_len_plus_one];\n    if limbs_sub_same_length_with_borrow_in_in_place_left(\n        rs_hi,\n        scratch_hi,\n        limbs_sub_same_length_to_out(rs_lo, ns_lo, scratch_lo),\n    ) {\n        limbs_slice_add_same_length_in_place_left(&mut rs[..d_len], ds);\n    }\n}\n\n// `qs` is just used as scratch space.\n//\n// `ns` must have length at least 3, `ds` must have length at least 2 and be no longer than `ns`,\n// and the most significant bit of `ds` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ds` has length smaller than 2, `ns.len()` is less than `ds.len()`, `qs` has length\n// less than `ns.len()` - `ds.len()`, or the last limb of `ds` does not have its highest bit set.\n//\n// This is equivalent to `mpn_mu_div_qr` from `mpn/generic/mu_div_qr.c`, GMP 6.2.1.\npub_test! {limbs_mod_barrett(\n    qs: &mut [Limb],\n    rs: &mut [Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = n_len - d_len;\n    let qs = &mut qs[..q_len];\n    // Test whether 2 * d_len - n_len > MU_DIV_QR_SKEW_THRESHOLD\n    if d_len <= q_len + MU_DIV_QR_SKEW_THRESHOLD {\n        limbs_mod_barrett_helper(qs, &mut rs[..d_len], ns, ds, scratch);\n    } else {\n        limbs_mod_barrett_large_helper(qs, rs, ns, ds, scratch);\n    }\n}}\n\n/// `ds` must have length 2, `ns` must have length at least 2, and the most-significant limb of `ds`\n/// must be nonzero.\n///\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and n$ is `ns.len()`.\nfn limbs_mod_by_two_limb(ns: &[Limb], ds: &[Limb]) -> (Limb, Limb) {\n    let n_len = ns.len();\n    let ds_1 = ds[1];\n    let bits = LeadingZeros::leading_zeros(ds_1);\n    if bits == 0 {\n        limbs_mod_by_two_limb_normalized(ns, ds)\n    } else {\n        let ds_0 = ds[0];\n        let cobits = Limb::WIDTH - bits;\n        let mut ns_shifted = vec![0; n_len + 1];\n        let ns_shifted = &mut ns_shifted;\n        let carry = limbs_shl_to_out(ns_shifted, ns, bits);\n        let ds_shifted = &mut [ds_0 << bits, (ds_1 << bits) | (ds_0 >> cobits)];\n        let (r_0, r_1) = if carry == 0 {\n            limbs_mod_by_two_limb_normalized(&ns_shifted[..n_len], ds_shifted)\n        } else {\n            ns_shifted[n_len] = carry;\n            limbs_mod_by_two_limb_normalized(ns_shifted, ds_shifted)\n        };\n        ((r_0 >> bits) | (r_1 << cobits), r_1 >> bits)\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\nfn limbs_mod_dc_condition(n_len: usize, d_len: usize) -> bool {\n    let n_64 = n_len as f64;\n    let d_64 = d_len as f64;\n    d_len < MUPI_DIV_QR_THRESHOLD\n        || n_len < MU_DIV_QR_THRESHOLD << 1\n        || fma!(\n            ((MU_DIV_QR_THRESHOLD - MUPI_DIV_QR_THRESHOLD) << 1) as f64,\n            d_64,\n            MUPI_DIV_QR_THRESHOLD as f64 * n_64\n        ) > d_64 * n_64\n}\n\n// This function is optimized for the case when the numerator has at least twice the length of the\n// denominator.\n//\n// `ds` must have length at least 3, `ns` must be at least as long as `ds`, `rs` must have the same\n// length as `ds`, and the most-significant limb of `ds` must be nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and n$ is `ns.len()`.\nfn limbs_mod_unbalanced(rs: &mut [Limb], ns: &[Limb], ds: &[Limb], adjusted_n_len: usize) {\n    let mut n_len = ns.len();\n    let d_len = ds.len();\n    let mut ds_shifted_vec;\n    let ds_shifted: &[Limb];\n    let mut ns_shifted_vec = vec![0; n_len + 1];\n    let ns_shifted = &mut ns_shifted_vec;\n    let bits = LeadingZeros::leading_zeros(*ds.last().unwrap());\n    if bits == 0 {\n        ds_shifted = ds;\n        ns_shifted[..n_len].copy_from_slice(ns);\n    } else {\n        // normalize divisor\n        ds_shifted_vec = vec![0; d_len];\n        limbs_shl_to_out(&mut ds_shifted_vec, ds, bits);\n        ds_shifted = &ds_shifted_vec;\n        let (ns_shifted_last, ns_shifted_init) = ns_shifted.split_last_mut().unwrap();\n        *ns_shifted_last = limbs_shl_to_out(ns_shifted_init, ns, bits);\n    }\n    n_len = adjusted_n_len;\n    let d_inv = limbs_two_limb_inverse_helper(ds_shifted[d_len - 1], ds_shifted[d_len - 2]);\n    let ns_shifted = &mut ns_shifted[..n_len];\n    if d_len < DC_DIV_QR_THRESHOLD {\n        limbs_mod_schoolbook(ns_shifted, ds_shifted, d_inv);\n        let ns_shifted = &ns_shifted[..d_len];\n        if bits == 0 {\n            rs.copy_from_slice(ns_shifted);\n        } else {\n            limbs_shr_to_out(rs, ns_shifted, bits);\n        }\n    } else if limbs_mod_dc_condition(n_len, d_len) {\n        let mut qs = vec![0; n_len - d_len];\n        limbs_mod_divide_and_conquer(&mut qs, ns_shifted, ds_shifted, d_inv);\n        let ns_shifted = &ns_shifted[..d_len];\n        if bits == 0 {\n            rs.copy_from_slice(ns_shifted);\n        } else {\n            limbs_shr_to_out(rs, ns_shifted, bits);\n        }\n    } else {\n        let scratch_len = limbs_div_mod_barrett_scratch_len(n_len, d_len);\n        let mut qs = vec![0; n_len - d_len];\n        let mut scratch = vec![0; scratch_len];\n        limbs_mod_barrett(&mut qs, rs, ns_shifted, ds_shifted, &mut scratch);\n        if bits != 0 {\n            limbs_slice_shr_in_place(rs, bits);\n        }\n    }\n}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, returning the remainder. The remainder has `ds.len()` limbs.\n//\n// `ns` must be at least as long as `ds` and `ds` must have length at least 2 and its most\n// significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `ns` is shorter than `ds`, `ds` has length less than 2, or the most-significant limb of\n// `ds` is zero.\n//\n// This is equivalent to `mpn_tdiv_qr` from `mpn/generic/tdiv_qr.c`, GMP 6.2.1, where `qp` is not\n// calculated and `rp` is returned.\npub_test! {limbs_mod(ns: &[Limb], ds: &[Limb]) -> Vec<Limb> {\n    let mut rs = vec![0; ds.len()];\n    limbs_mod_to_out(&mut rs, ns, ds);\n    rs\n}}\n\n// Interpreting two slices of `Limb`s, `ns` and `ds`, as the limbs (in ascending order) of two\n// `Natural`s, divides them, writing the `ds.len()` limbs of the remainder to `rs`.\n//\n// `ns` must be at least as long as `ds`, `rs` must be at least as long as `ds`, and `ds` must have\n// length at least 2 and its most significant limb must be greater than zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and n$ is `ns.len()`.\n//\n// # Panics\n// Panics if `rs` is too short, `ns` is shorter than `ds`, `ds` has length less than 2, or the\n// most-significant limb of `ds` is zero.\n//\n// This is equivalent to `mpn_tdiv_qr` from `mpn/generic/tdiv_qr.c`, GMP 6.2.1, where `qp` is not\n// calculated.\npub_crate_test! {limbs_mod_to_out(rs: &mut [Limb], ns: &[Limb], ds: &[Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(n_len >= d_len);\n    let rs = &mut rs[..d_len];\n    let ds_last = *ds.last().unwrap();\n    assert!(d_len > 1 && ds_last != 0);\n    if d_len == 2 {\n        (rs[0], rs[1]) = limbs_mod_by_two_limb(ns, ds);\n    } else {\n        // conservative tests for quotient size\n        let adjust = ns[n_len - 1] >= ds_last;\n        let adjusted_n_len = if adjust { n_len + 1 } else { n_len };\n        if adjusted_n_len < d_len << 1 {\n            let mut qs = vec![0; n_len - d_len + 1];\n            limbs_div_mod_balanced(&mut qs, rs, ns, ds, adjust);\n        } else {\n            limbs_mod_unbalanced(rs, ns, ds, adjusted_n_len);\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n#[cfg(feature = \"test_build\")]\nfn limbs_rem_naive(ns: &[Limb], d: Limb) -> Limb {\n    let d = DoubleLimb::from(d);\n    let mut r = 0;\n    for &n in ns.iter().rev() {\n        r = (DoubleLimb::join_halves(r, n) % d).lower_half();\n    }\n    r\n}\n\n// The high bit of `d` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_div_qr_1n_pi1` from `mpn/generic/div_qr_1n_pi1.c`, GMP 6.2.1, with\n// `DIV_QR_1N_METHOD == 2`, but not computing the quotient.\npub fn limbs_mod_limb_normalized<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half = T>,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    ns_high: T,\n    d: T,\n    d_inv: T,\n) -> T {\n    let len = ns.len();\n    if len == 1 {\n        return mod_by_preinversion::<DT, T>(ns_high, ns[0], d, d_inv);\n    }\n    let power_of_2 = d.wrapping_neg().wrapping_mul(d_inv);\n    let (sum, mut big_carry) = DT::join_halves(ns[len - 1], ns[len - 2])\n        .overflowing_add(DT::from(power_of_2) * DT::from(ns_high));\n    let (mut sum_high, mut sum_low) = sum.split_in_half();\n    for &n in ns[..len - 2].iter().rev() {\n        if big_carry && sum_low.overflowing_add_assign(power_of_2) {\n            sum_low.wrapping_sub_assign(d);\n        }\n        let sum;\n        (sum, big_carry) =\n            DT::join_halves(sum_low, n).overflowing_add(DT::from(sum_high) * DT::from(power_of_2));\n        sum_high = sum.upper_half();\n        sum_low = sum.lower_half();\n    }\n    if big_carry {\n        sum_high.wrapping_sub_assign(d);\n    }\n    if sum_high >= d {\n        sum_high.wrapping_sub_assign(d);\n    }\n    mod_by_preinversion::<DT, T>(sum_high, sum_low, d, d_inv)\n}\n\n// The high bit of `d` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_div_qr_1n_pi1` from `mpn/generic/div_qr_1n_pi1.c`, GMP 6.2.1, with\n// `DIV_QR_1N_METHOD == 2`, but not computing the quotient, and where the input is left-shifted by\n// `bits`.\npub_test! {limbs_mod_limb_normalized_shl<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half = T>,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    ns_high: T,\n    d: T,\n    d_inv: T,\n    bits: u64,\n) -> T {\n    let len = ns.len();\n    if len == 1 {\n        return mod_by_preinversion::<DT, T>(ns_high, ns[0] << bits, d, d_inv);\n    }\n    let power_of_2 = d.wrapping_neg().wrapping_mul(d_inv);\n    let cobits = T::WIDTH - bits;\n    let second_highest = ns[len - 2];\n    let highest_after_shl = (ns[len - 1] << bits) | (second_highest >> cobits);\n    let mut second_highest_after_shl = second_highest << bits;\n    if len > 2 {\n        second_highest_after_shl |= ns[len - 3] >> cobits;\n    }\n    let (sum, mut big_carry) = DT::join_halves(highest_after_shl, second_highest_after_shl)\n        .overflowing_add(DT::from(power_of_2) * DT::from(ns_high));\n    let (mut sum_high, mut sum_low) = sum.split_in_half();\n    for j in (0..len - 2).rev() {\n        if big_carry && sum_low.overflowing_add_assign(power_of_2) {\n            sum_low.wrapping_sub_assign(d);\n        }\n        let mut n = ns[j] << bits;\n        if j != 0 {\n            n |= ns[j - 1] >> cobits;\n        }\n        let sum;\n        (sum, big_carry) =\n            DT::join_halves(sum_low, n).overflowing_add(DT::from(sum_high) * DT::from(power_of_2));\n        sum_high = sum.upper_half();\n        sum_low = sum.lower_half();\n    }\n    if big_carry {\n        sum_high.wrapping_sub_assign(d);\n    }\n    if sum_high >= d {\n        sum_high.wrapping_sub_assign(d);\n    }\n    mod_by_preinversion::<DT, T>(sum_high, sum_low, d, d_inv)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_div_qr_1` from `mpn/generic/div_qr_1.c`, GMP 6.2.1, where the quotient\n// is not computed and the remainder is returned. Experiments show that this is always slower than\n// `limbs_mod_limb`.\npub_test! {limbs_mod_limb_alt_1<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf + JoinHalves<Half = T>,\n    T: PrimitiveUnsigned,\n>(ns: &[T], d: T) -> T {\n    assert_ne!(d, T::ZERO);\n    let len = ns.len();\n    assert!(len > 1);\n    let len_minus_1 = len - 1;\n    let mut ns_high = ns[len_minus_1];\n    let bits = LeadingZeros::leading_zeros(d);\n    if bits == 0 {\n        if ns_high >= d {\n            ns_high -= d;\n        }\n        let d_inv = limbs_invert_limb::<DT, T>(d);\n        limbs_mod_limb_normalized::<DT, T>(&ns[..len_minus_1], ns_high, d, d_inv)\n    } else {\n        let d = d << bits;\n        let cobits = T::WIDTH - bits;\n        let d_inv = limbs_invert_limb::<DT, T>(d);\n        let r = mod_by_preinversion::<DT, T>(\n            ns_high >> cobits,\n            (ns_high << bits) | (ns[len - 2] >> cobits),\n            d,\n            d_inv,\n        );\n        limbs_mod_limb_normalized_shl::<DT, T>(&ns[..len_minus_1], r, d, d_inv, bits) >> bits\n    }\n}}\n\n// Dividing (`n_high`, `n_low`) by `d`, returning the remainder only. Unlike `mod_by_preinversion`,\n// works also for the case `n_high` == `d`, where the quotient doesn't quite fit in a single limb.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `udiv_rnnd_preinv` from `gmp-impl.h`, GMP 6.2.1.\nfn mod_by_preinversion_special<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    n_high: T,\n    n_low: T,\n    d: T,\n    d_inv: T,\n) -> T {\n    let (q_high, q_low) = ((DT::from(n_high) * DT::from(d_inv))\n        .wrapping_add(DT::join_halves(n_high.wrapping_add(T::ONE), n_low)))\n    .split_in_half();\n    let mut r = n_low.wrapping_sub(q_high.wrapping_mul(d));\n    // both > and >= are OK\n    if r > q_low {\n        r.wrapping_add_assign(d);\n    }\n    if r >= d {\n        r.wrapping_sub_assign(d);\n    }\n    r\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub_test! {limbs_mod_limb_small_small<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(ns: &[T], d: T, mut r: T) -> T {\n    let d = DT::from(d);\n    for &n in ns.iter().rev() {\n        r = (DT::join_halves(r, n) % d).lower_half();\n    }\n    r\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub_test! {limbs_mod_limb_small_normalized_large<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves<Half = T> + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n    mut r: T,\n) -> T {\n    let d_inv = limbs_invert_limb::<DT, T>(d);\n    for &n in ns.iter().rev() {\n        r = mod_by_preinversion_special::<DT, T>(r, n, d, d_inv);\n    }\n    r\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mod_1_norm` from `mpn/generic/mod_1.c`, GMP 6.2.1.\npub_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_mod_limb_small_normalized<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves<Half = T> + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    let mut len = ns.len();\n    assert_ne!(len, 0);\n    assert!(d.get_highest_bit());\n    // High limb is initial remainder, possibly with one subtraction of d to get r < d.\n    let mut r = ns[len - 1];\n    if r >= d {\n        r -= d;\n    }\n    len -= 1;\n    if len == 0 {\n        r\n    } else {\n        let ns = &ns[..len];\n        if len < MOD_1_NORM_THRESHOLD {\n            limbs_mod_limb_small_small::<DT, T>(ns, d, r)\n        } else {\n            limbs_mod_limb_small_normalized_large::<DT, T>(ns, d, r)\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub_test! {limbs_mod_limb_small_unnormalized_large<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    mut d: T,\n    mut r: T,\n) -> T {\n    let shift = LeadingZeros::leading_zeros(d);\n    d <<= shift;\n    let (ns_last, ns_init) = ns.split_last().unwrap();\n    let mut previous_n = *ns_last;\n    let co_shift = T::WIDTH - shift;\n    r = (r << shift) | (previous_n >> co_shift);\n    let d_inv = limbs_invert_limb::<DT, T>(d);\n    for &n in ns_init.iter().rev() {\n        let shifted_n = (previous_n << shift) | (n >> co_shift);\n        r = mod_by_preinversion_special::<DT, T>(r, shifted_n, d, d_inv);\n        previous_n = n;\n    }\n    mod_by_preinversion_special::<DT, T>(r, previous_n << shift, d, d_inv) >> shift\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mod_1_unnorm` from `mpn/generic/mod_1.c`, GMP 6.2.1, where\n// `UDIV_NEEDS_NORMALIZATION` is `false`.\npub_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_mod_limb_small_unnormalized<\nDT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\nT: PrimitiveUnsigned,\n>(ns: &[T], d: T) -> T {\n    let mut len = ns.len();\n    assert_ne!(len, 0);\n    assert_ne!(d, T::ZERO);\n    assert!(!d.get_highest_bit());\n    // Skip a division if high < divisor. Having the test here before normalizing will still skip as\n    // often as possible.\n    let mut r = ns[len - 1];\n    if r < d {\n        len -= 1;\n        if len == 0 {\n            return r;\n        }\n    } else {\n        r = T::ZERO;\n    }\n    let ns = &ns[..len];\n    if len < MOD_1_UNNORM_THRESHOLD {\n        limbs_mod_limb_small_small::<DT, T>(ns, d, r)\n    } else {\n        limbs_mod_limb_small_unnormalized_large::<DT, T>(ns, d, r)\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\npub_test! {limbs_mod_limb_any_leading_zeros<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    if MOD_1_1P_METHOD {\n        limbs_mod_limb_any_leading_zeros_1::<DT, T>(ns, d)\n    } else {\n        limbs_mod_limb_any_leading_zeros_2::<DT, T>(ns, d)\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mod_1_1p_cps_1` combined with `mpn_mod_1_1p_1` from\n// `mpn/generic/mod_1.c`, GMP 6.2.1.\npub_test! {limbs_mod_limb_any_leading_zeros_1<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    let len = ns.len();\n    assert!(len >= 2);\n    let shift = d.leading_zeros();\n    let d = d << shift;\n    let d_inv = limbs_invert_limb::<DT, T>(d);\n    let mut base_mod_d = d.wrapping_neg();\n    if shift != 0 {\n        base_mod_d.wrapping_mul_assign((d_inv >> (T::WIDTH - shift)) | T::power_of_2(shift));\n    }\n    assert!(base_mod_d <= d); // not fully reduced mod divisor\n    let base_pow_2_mod_d =\n        DT::from(mod_by_preinversion_special::<DT, T>(base_mod_d, T::ZERO, d, d_inv) >> shift);\n    let base_mod_d = DT::from(base_mod_d >> shift);\n    let (mut r_hi, mut r_lo) = (DT::from(ns[len - 1]) * base_mod_d)\n        .wrapping_add(DT::from(ns[len - 2]))\n        .split_in_half();\n    for &n in ns[..len - 2].iter().rev() {\n        (r_hi, r_lo) = (DT::from(r_hi) * base_pow_2_mod_d)\n            .wrapping_add(DT::from(r_lo) * base_mod_d)\n            .wrapping_add(DT::from(n))\n            .split_in_half();\n    }\n    if shift != 0 {\n        r_hi = (r_hi << shift) | (r_lo >> (T::WIDTH - shift));\n    }\n    if r_hi >= d {\n        r_hi.wrapping_sub_assign(d);\n    }\n    mod_by_preinversion_special::<DT, T>(r_hi, r_lo << shift, d, d_inv) >> shift\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mod_1_1p_cps_2` combined with `mpn_mod_1_1p_2` from\n// `mpn/generic/mod_1.c`, GMP 6.2.1.\npub_test! {limbs_mod_limb_any_leading_zeros_2<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    let len = ns.len();\n    assert!(len >= 2);\n    let shift = LeadingZeros::leading_zeros(d);\n    let d = d << shift;\n    let d_inv = limbs_invert_limb::<DT, T>(d);\n    let base_mod_d = if shift == 0 {\n        DT::ZERO\n    } else {\n        let base_mod_d = d\n            .wrapping_neg()\n            .wrapping_mul((d_inv >> (T::WIDTH - shift)) | T::power_of_2(shift));\n        assert!(base_mod_d <= d); // not fully reduced mod divisor\n        DT::from(base_mod_d >> shift)\n    };\n    let small_base_pow_2_mod_d = d.wrapping_neg().wrapping_mul(d_inv);\n    // equality iff divisor = 2 ^ (Limb::WIDTH - 1)\n    assert!(small_base_pow_2_mod_d <= d);\n    let base_pow_2_mod_d = DT::from(small_base_pow_2_mod_d);\n    let mut r_lo = ns[len - 2];\n    let mut r_hi = ns[len - 1];\n    if len > 2 {\n        let (r, mut carry) =\n            DT::join_halves(r_lo, ns[len - 3]).overflowing_add(DT::from(r_hi) * base_pow_2_mod_d);\n        (r_hi, r_lo) = r.split_in_half();\n        for &n in ns[..len - 3].iter().rev() {\n            if carry && r_lo.overflowing_add_assign(small_base_pow_2_mod_d) {\n                r_lo.wrapping_sub_assign(d);\n            }\n            let r;\n            (r, carry) =\n                DT::join_halves(r_lo, n).overflowing_add(DT::from(r_hi) * base_pow_2_mod_d);\n            (r_hi, r_lo) = r.split_in_half();\n        }\n        if carry {\n            r_hi.wrapping_sub_assign(d);\n        }\n    }\n    if shift != 0 {\n        let (new_r_hi, t) = (DT::from(r_hi) * base_mod_d).split_in_half();\n        (r_hi, r_lo) =\n            (DT::join_halves(new_r_hi, r_lo).wrapping_add(DT::from(t)) << shift).split_in_half();\n    } else if r_hi >= d {\n        // might get r_hi == divisor here, but `mod_by_preinversion_special` allows that.\n        r_hi.wrapping_sub_assign(d);\n    }\n    mod_by_preinversion_special::<DT, T>(r_hi, r_lo, d, d_inv) >> shift\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mod_1s_2p_cps` combined with `mpn_mod_1s_2p` from\n// `mpn/generic/mod_1_2.c`, GMP 6.2.1.\npub_test! {limbs_mod_limb_at_least_1_leading_zero<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    let mut len = ns.len();\n    assert_ne!(len, 0);\n    let shift = LeadingZeros::leading_zeros(d);\n    assert_ne!(shift, 0);\n    let co_shift = T::WIDTH - shift;\n    let d = d << shift;\n    let d_inv = limbs_invert_limb::<DT, T>(d);\n    let base_mod_d = d\n        .wrapping_neg()\n        .wrapping_mul((d_inv >> co_shift) | T::power_of_2(shift));\n    assert!(base_mod_d <= d); // not fully reduced mod divisor\n    let base_pow_2_mod_d = mod_by_preinversion_special::<DT, T>(base_mod_d, T::ZERO, d, d_inv);\n    let base_mod_d = DT::from(base_mod_d >> shift);\n    let base_pow_3_mod_d = DT::from(\n        mod_by_preinversion_special::<DT, T>(base_pow_2_mod_d, T::ZERO, d, d_inv) >> shift,\n    );\n    let base_pow_2_mod_d = DT::from(base_pow_2_mod_d >> shift);\n    let (mut r_hi, mut r_lo) = if len.odd() {\n        len -= 1;\n        if len == 0 {\n            let rl = ns[len];\n            return mod_by_preinversion_special::<DT, T>(rl >> co_shift, rl << shift, d, d_inv)\n                >> shift;\n        }\n        (DT::from(ns[len]) * base_pow_2_mod_d)\n            .wrapping_add(DT::from(ns[len - 1]) * base_mod_d)\n            .wrapping_add(DT::from(ns[len - 2]))\n            .split_in_half()\n    } else {\n        (ns[len - 1], ns[len - 2])\n    };\n    for chunk in ns[..len - 2].rchunks_exact(2) {\n        (r_hi, r_lo) = (DT::from(r_hi) * base_pow_3_mod_d)\n            .wrapping_add(DT::from(r_lo) * base_pow_2_mod_d)\n            .wrapping_add(DT::from(chunk[1]) * base_mod_d)\n            .wrapping_add(DT::from(chunk[0]))\n            .split_in_half();\n    }\n    let (r_hi, r_lo) = (DT::from(r_hi) * base_mod_d)\n        .wrapping_add(DT::from(r_lo))\n        .split_in_half();\n    mod_by_preinversion_special::<DT, T>(\n        (r_hi << shift) | (r_lo >> co_shift),\n        r_lo << shift,\n        d,\n        d_inv,\n    ) >> shift\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mod_1s_4p_cps` combined with `mpn_mod_1s_4p` from\n// `mpn/generic/mod_1_4.c`, GMP 6.2.1.\npub_test! {limbs_mod_limb_at_least_2_leading_zeros<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    let mut len = ns.len();\n    assert_ne!(len, 0);\n    let shift = LeadingZeros::leading_zeros(d);\n    assert!(shift >= 2);\n    let co_shift = T::WIDTH - shift;\n    let d = d << shift;\n    let d_inv = limbs_invert_limb::<DT, T>(d);\n    let base_mod_d = d\n        .wrapping_neg()\n        .wrapping_mul((d_inv >> co_shift) | T::power_of_2(shift));\n    assert!(base_mod_d <= d); // not fully reduced mod divisor\n    let base_pow_2_mod_d = mod_by_preinversion_special::<DT, T>(base_mod_d, T::ZERO, d, d_inv);\n    let base_mod_d = DT::from(base_mod_d >> shift);\n    let base_pow_3_mod_d =\n        mod_by_preinversion_special::<DT, T>(base_pow_2_mod_d, T::ZERO, d, d_inv);\n    let base_pow_2_mod_d = DT::from(base_pow_2_mod_d >> shift);\n    let base_pow_4_mod_d =\n        mod_by_preinversion_special::<DT, T>(base_pow_3_mod_d, T::ZERO, d, d_inv);\n    let base_pow_3_mod_d = DT::from(base_pow_3_mod_d >> shift);\n    let base_pow_5_mod_d = DT::from(\n        mod_by_preinversion_special::<DT, T>(base_pow_4_mod_d, T::ZERO, d, d_inv) >> shift,\n    );\n    let base_pow_4_mod_d = DT::from(base_pow_4_mod_d >> shift);\n    let (mut r_hi, mut r_lo) = match len.mod_power_of_2(2) {\n        0 => {\n            len -= 4;\n            (DT::from(ns[len + 3]) * base_pow_3_mod_d)\n                .wrapping_add(DT::from(ns[len + 2]) * base_pow_2_mod_d)\n                .wrapping_add(DT::from(ns[len + 1]) * base_mod_d)\n                .wrapping_add(DT::from(ns[len]))\n                .split_in_half()\n        }\n        1 => {\n            len -= 1;\n            (T::ZERO, ns[len])\n        }\n        2 => {\n            len -= 2;\n            (ns[len + 1], ns[len])\n        }\n        3 => {\n            len -= 3;\n            (DT::from(ns[len + 2]) * base_pow_2_mod_d)\n                .wrapping_add(DT::from(ns[len + 1]) * base_mod_d)\n                .wrapping_add(DT::from(ns[len]))\n                .split_in_half()\n        }\n        _ => unreachable!(),\n    };\n    for chunk in ns[..len].rchunks_exact(4) {\n        (r_hi, r_lo) = (DT::from(r_hi) * base_pow_5_mod_d)\n            .wrapping_add(DT::from(r_lo) * base_pow_4_mod_d)\n            .wrapping_add(DT::from(chunk[3]) * base_pow_3_mod_d)\n            .wrapping_add(DT::from(chunk[2]) * base_pow_2_mod_d)\n            .wrapping_add(DT::from(chunk[1]) * base_mod_d)\n            .wrapping_add(DT::from(chunk[0]))\n            .split_in_half();\n    }\n    let (r_hi, r_lo) = (DT::from(r_hi) * base_mod_d)\n        .wrapping_add(DT::from(r_lo))\n        .split_in_half();\n    mod_by_preinversion_special::<DT, T>(\n        (r_hi << shift) | (r_lo >> co_shift),\n        r_lo << shift,\n        d,\n        d_inv,\n    ) >> shift\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_mod_1` from `mpn/generic/mod_1.c`, GMP 6.2.1, where `n > 1`.\npub_crate_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_mod_limb_alt_2<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + JoinHalves + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    ns: &[T],\n    d: T,\n) -> T {\n    let len = ns.len();\n    assert!(len > 1);\n    assert_ne!(d, T::ZERO);\n    if d.get_highest_bit() {\n        if len < MOD_1N_TO_MOD_1_1_THRESHOLD {\n            limbs_mod_limb_small_normalized::<DT, T>(ns, d)\n        } else {\n            limbs_mod_limb_any_leading_zeros::<DT, T>(ns, d)\n        }\n    } else if len < MOD_1U_TO_MOD_1_1_THRESHOLD {\n        limbs_mod_limb_small_unnormalized::<DT, T>(ns, d)\n    } else if len < MOD_1_1_TO_MOD_1_2_THRESHOLD {\n        limbs_mod_limb_any_leading_zeros::<DT, T>(ns, d)\n    } else if len < MOD_1_2_TO_MOD_1_4_THRESHOLD || d & !(T::MAX >> 2u32) != T::ZERO {\n        limbs_mod_limb_at_least_1_leading_zero::<DT, T>(ns, d)\n    } else {\n        limbs_mod_limb_at_least_2_leading_zeros::<DT, T>(ns, d)\n    }\n}}\n\nimpl Natural {\n    #[cfg(feature = \"test_build\")]\n    pub fn mod_limb_naive(&self, other: Limb) -> Limb {\n        match (self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (Self(Small(small)), other) => small % other,\n            (Self(Large(limbs)), other) => limbs_rem_naive(limbs, other),\n        }\n    }\n\n    fn rem_limb_ref(&self, other: Limb) -> Limb {\n        match (self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (Self(Small(small)), other) => small % other,\n            (Self(Large(limbs)), other) => limbs_mod_limb::<DoubleLimb, Limb>(limbs, other),\n        }\n    }\n\n    fn rem_assign_limb(&mut self, other: Limb) {\n        match (&mut *self, other) {\n            (_, 0) => panic!(\"division by zero\"),\n            (Self(Small(small)), other) => *small %= other,\n            (Self(Large(limbs)), other) => {\n                *self = Self(Small(limbs_mod_limb::<DoubleLimb, Limb>(limbs, other)));\n            }\n        }\n    }\n}\n\nimpl Mod<Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value and returning just the\n    /// remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Natural::from(23u32).mod_op(Natural::from(10u32)), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .mod_op(Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// ```\n    #[inline]\n    fn mod_op(self, other: Self) -> Self {\n        self % other\n    }\n}\n\nimpl<'a> Mod<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Natural::from(23u32).mod_op(&Natural::from(10u32)), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .mod_op(&Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// ```\n    #[inline]\n    fn mod_op(self, other: &'a Self) -> Self {\n        self % other\n    }\n}\n\nimpl Mod<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!((&Natural::from(23u32)).mod_op(Natural::from(10u32)), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .mod_op(Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// ```\n    #[inline]\n    fn mod_op(self, other: Natural) -> Natural {\n        self % other\n    }\n}\n\nimpl Mod<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference and returning just\n    /// the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!((&Natural::from(23u32)).mod_op(&Natural::from(10u32)), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .mod_op(&Natural::from_str(\"1234567890987\").unwrap()),\n    ///     530068894399u64\n    /// );\n    /// ```\n    #[inline]\n    fn mod_op(self, other: &Natural) -> Natural {\n        self % other\n    }\n}\n\nimpl ModAssign<Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`], taking the second [`Natural`] by value and\n    /// replacing the first by the remainder.\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::ModAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x.mod_assign(Natural::from(10u32));\n    /// assert_eq!(x, 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x.mod_assign(Natural::from_str(\"1234567890987\").unwrap());\n    /// assert_eq!(x, 530068894399u64);\n    /// ```\n    #[inline]\n    fn mod_assign(&mut self, other: Self) {\n        *self %= other;\n    }\n}\n\nimpl<'a> ModAssign<&'a Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`], taking the second [`Natural`] by reference and\n    /// replacing the first by the remainder.\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::ModAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x.mod_assign(&Natural::from(10u32));\n    /// assert_eq!(x, 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x.mod_assign(&Natural::from_str(\"1234567890987\").unwrap());\n    /// assert_eq!(x, 530068894399u64);\n    /// ```\n    fn mod_assign(&mut self, other: &'a Self) {\n        *self %= other;\n    }\n}\n\nimpl Rem<Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by value and returning just the\n    /// remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem` is equivalent to [`mod_op`](Mod::mod_op).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Natural::from(23u32) % Natural::from(10u32), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         % Natural::from_str(\"1234567890987\").unwrap(),\n    ///     530068894399u64\n    /// );\n    /// ```\n    #[inline]\n    fn rem(mut self, other: Self) -> Self {\n        self %= other;\n        self\n    }\n}\n\nimpl<'a> Rem<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem` is equivalent to [`mod_op`](Mod::mod_op).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(Natural::from(23u32) % &Natural::from(10u32), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         % &Natural::from_str(\"1234567890987\").unwrap(),\n    ///     530068894399u64\n    /// );\n    /// ```\n    #[inline]\n    fn rem(mut self, other: &'a Self) -> Self {\n        self %= other;\n        self\n    }\n}\n\nimpl Rem<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem` is equivalent to [`mod_op`](Mod::mod_op).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Natural::from(23u32) % Natural::from(10u32), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     &Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         % Natural::from_str(\"1234567890987\").unwrap(),\n    ///     530068894399u64\n    /// );\n    /// ```\n    fn rem(self, other: Natural) -> Natural {\n        match (self, other) {\n            (_, Natural::ZERO) => panic!(\"division by zero\"),\n            (_, Natural::ONE) => Natural::ZERO,\n            (n, Natural(Small(d))) => Natural(Small(n.rem_limb_ref(d))),\n            (Natural(Small(_)), _) => self.clone(),\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                if ns.len() >= ds.len() {\n                    Natural::from_owned_limbs_asc(limbs_mod(ns, &ds))\n                } else {\n                    self.clone()\n                }\n            }\n        }\n    }\n}\n\nimpl Rem<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by another [`Natural`], taking both by reference and returning just\n    /// the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem` is equivalent to [`mod_op`](Mod::mod_op).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// assert_eq!(&Natural::from(23u32) % &Natural::from(10u32), 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     &Natural::from_str(\"1000000000000000000000000\").unwrap()\n    ///         % &Natural::from_str(\"1234567890987\").unwrap(),\n    ///     530068894399u64\n    /// );\n    /// ```\n    fn rem(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (_, &Natural::ZERO) => panic!(\"division by zero\"),\n            (_, &Natural::ONE) => Natural::ZERO,\n            (n, d) if core::ptr::eq(n, d) => Natural::ZERO,\n            (n, Natural(Small(d))) => Natural(Small(n.rem_limb_ref(*d))),\n            (Natural(Small(_)), _) => self.clone(),\n            (Natural(Large(ns)), Natural(Large(ds))) => {\n                if ns.len() >= ds.len() {\n                    Natural::from_owned_limbs_asc(limbs_mod(ns, ds))\n                } else {\n                    self.clone()\n                }\n            }\n        }\n    }\n}\n\nimpl RemAssign<Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`], taking the second [`Natural`] by value and\n    /// replacing the first by the remainder.\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem_assign` is equivalent to [`mod_assign`](ModAssign::mod_assign).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x %= Natural::from(10u32);\n    /// assert_eq!(x, 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x %= Natural::from_str(\"1234567890987\").unwrap();\n    /// assert_eq!(x, 530068894399u64);\n    /// ```\n    #[inline]\n    fn rem_assign(&mut self, other: Self) {\n        *self %= &other;\n    }\n}\n\nimpl<'a> RemAssign<&'a Self> for Natural {\n    /// Divides a [`Natural`] by another [`Natural`], taking the second [`Natural`] by reference and\n    /// replacing the first by the remainder.\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem_assign` is equivalent to [`mod_assign`](ModAssign::mod_assign).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 10 + 3 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x %= &Natural::from(10u32);\n    /// assert_eq!(x, 3);\n    ///\n    /// // 810000006723 * 1234567890987 + 530068894399 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x %= &Natural::from_str(\"1234567890987\").unwrap();\n    /// assert_eq!(x, 530068894399u64);\n    /// ```\n    fn rem_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (_, &Self::ZERO) => panic!(\"division by zero\"),\n            (_, &Self::ONE) => *self = Self::ZERO,\n            (_, Self(Small(d))) => self.rem_assign_limb(*d),\n            (Self(Small(_)), _) => {}\n            (Self(Large(ns)), Self(Large(ds))) => {\n                if ns.len() >= ds.len() {\n                    let mut rs = vec![0; ds.len()];\n                    limbs_mod_to_out(&mut rs, ns, ds);\n                    swap(&mut rs, ns);\n                    self.trim();\n                }\n            }\n        }\n    }\n}\n\nimpl NegMod<Self> for Natural {\n    type Output = Self;\n\n    /// Divides the negative of a [`Natural`] by another [`Natural`], taking both by value and\n    /// returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::NegMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!(Natural::from(23u32).neg_mod(Natural::from(10u32)), 7);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .neg_mod(Natural::from_str(\"1234567890987\").unwrap()),\n    ///     704498996588u64\n    /// );\n    /// ```\n    #[inline]\n    fn neg_mod(mut self, other: Self) -> Self {\n        self.neg_mod_assign(other);\n        self\n    }\n}\n\nimpl<'a> NegMod<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Divides the negative of a [`Natural`] by another [`Natural`], taking the first by value and\n    /// the second by reference and returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::NegMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!(Natural::from(23u32).neg_mod(&Natural::from(10u32)), 7);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000000000000000\")\n    ///         .unwrap()\n    ///         .neg_mod(&Natural::from_str(\"1234567890987\").unwrap()),\n    ///     704498996588u64\n    /// );\n    /// ```\n    #[inline]\n    fn neg_mod(mut self, other: &'a Self) -> Self {\n        self.neg_mod_assign(other);\n        self\n    }\n}\n\nimpl NegMod<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides the negative of a [`Natural`] by another [`Natural`], taking the first by reference\n    /// and the second by value and returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::NegMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!((&Natural::from(23u32)).neg_mod(Natural::from(10u32)), 7);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .neg_mod(Natural::from_str(\"1234567890987\").unwrap()),\n    ///     704498996588u64\n    /// );\n    /// ```\n    fn neg_mod(self, other: Natural) -> Natural {\n        let r = self % &other;\n        if r == 0 { r } else { other - r }\n    }\n}\n\nimpl NegMod<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Divides the negative of a [`Natural`] by another [`Natural`], taking both by reference and\n    /// returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// f(x, y) = y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::NegMod;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// assert_eq!((&Natural::from(23u32)).neg_mod(&Natural::from(10u32)), 7);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"1000000000000000000000000\").unwrap())\n    ///         .neg_mod(&Natural::from_str(\"1234567890987\").unwrap()),\n    ///     704498996588u64\n    /// );\n    /// ```\n    fn neg_mod(self, other: &Natural) -> Natural {\n        let r = self % other;\n        if r == 0 { r } else { other - r }\n    }\n}\n\nimpl NegModAssign<Self> for Natural {\n    /// Divides the negative of a [`Natural`] by another [`Natural`], taking the second [`Natural`]s\n    /// by value and replacing the first by the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// x \\gets y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::NegModAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x.neg_mod_assign(Natural::from(10u32));\n    /// assert_eq!(x, 7);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x.neg_mod_assign(Natural::from_str(\"1234567890987\").unwrap());\n    /// assert_eq!(x, 704498996588u64);\n    /// ```\n    fn neg_mod_assign(&mut self, other: Self) {\n        *self %= &other;\n        if *self != 0 {\n            self.sub_right_assign_no_panic(&other);\n        }\n    }\n}\n\nimpl<'a> NegModAssign<&'a Self> for Natural {\n    /// Divides the negative of a [`Natural`] by another [`Natural`], taking the second [`Natural`]s\n    /// by reference and replacing the first by the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy - r$ and $0\n    /// \\leq r < y$.\n    ///\n    /// $$\n    /// x \\gets y\\left \\lceil \\frac{x}{y} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::NegModAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 3 * 10 - 7 = 23\n    /// let mut x = Natural::from(23u32);\n    /// x.neg_mod_assign(&Natural::from(10u32));\n    /// assert_eq!(x, 7);\n    ///\n    /// // 810000006724 * 1234567890987 - 704498996588 = 1000000000000000000000000\n    /// let mut x = Natural::from_str(\"1000000000000000000000000\").unwrap();\n    /// x.neg_mod_assign(&Natural::from_str(\"1234567890987\").unwrap());\n    /// assert_eq!(x, 704498996588u64);\n    /// ```\n    fn neg_mod_assign(&mut self, other: &'a Self) {\n        *self %= other;\n        if *self != 0 {\n            self.sub_right_assign_no_panic(other);\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `getbits`, `MPN_REDC_1`, `win_size`, `redcify`, `mpn_powm`, and `mpz_powm` contributed to\n//      the GNU project by Torbjörn Granlund.\n//\n//      Copyright (C) 2000-2002, 2004, 2007–2012 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::Small;\nuse crate::natural::arithmetic::add::{\n    limbs_add_same_length_to_out, limbs_add_to_out_aliased,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::div_exact::{\n    limbs_modular_invert, limbs_modular_invert_limb, limbs_modular_invert_scratch_len,\n};\nuse crate::natural::arithmetic::div_mod::limbs_div_limb_to_out_mod;\nuse crate::natural::arithmetic::mod_op::limbs_mod_to_out;\nuse crate::natural::arithmetic::mod_power_of_2_pow::limbs_pow_low;\nuse crate::natural::arithmetic::mul::mul_low::limbs_mul_low_same_length;\nuse crate::natural::arithmetic::mul::mul_mod::{\n    limbs_mul_mod_base_pow_n_minus_1, limbs_mul_mod_base_pow_n_minus_1_next_size,\n    limbs_mul_mod_base_pow_n_minus_1_scratch_len,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out_basecase, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shr::limbs_shr_to_out;\nuse crate::natural::arithmetic::square::{\n    limbs_square_to_out, limbs_square_to_out_basecase, limbs_square_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n    limbs_sub_same_length_to_out,\n};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::natural::logic::bit_access::limbs_get_bit;\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::natural::{Natural, bit_to_limb_count_floor, limb_to_bit_count};\nuse crate::platform::{Limb, MUL_TOOM22_THRESHOLD, SQR_BASECASE_THRESHOLD, SQR_TOOM2_THRESHOLD};\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, max, min};\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    ModPow, ModPowAssign, ModPowerOf2, ModPowerOf2Assign, Parity, PowerOf2, WrappingNegAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::slices::{slice_leading_zeros, slice_set_zero};\n\n// Equivalent to limbs_slice_get_bits(xs, end.saturating_sub(len), end)[0]\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `getbits` from `mpn/generic/powm.c` and `mpn/generic/powlo.c`, GMP 6.2.1.\n// Investigate changes from 6.1.2?\npub(crate) fn get_bits(xs: &[Limb], mut end: u64, len: u64) -> usize {\n    usize::exact_from(if end < len {\n        xs[0].mod_power_of_2(end)\n    } else {\n        end -= len;\n        let i = bit_to_limb_count_floor(end);\n        end &= Limb::WIDTH_MASK;\n        let mut bits = xs[i] >> end;\n        let coend = Limb::WIDTH - end;\n        if coend < len {\n            bits += xs[i + 1] << coend;\n        }\n        bits.mod_power_of_2(len)\n    })\n}\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ms.len()`.\n//\n// This is equivalent to `mpn_redc_1` from `mpn/generic/redc_1.c`, GMP 6.2.1.\n#[allow(clippy::redundant_slicing)]\nfn limbs_redc_limb_raw(out: &mut [Limb], xs: &mut [Limb], ms: &[Limb], m_inv: Limb) -> bool {\n    let len = ms.len();\n    assert_ne!(len, 0);\n    let xs = &mut xs[..len << 1];\n    let mut xs_tail = &mut xs[..]; // force borrow rather than move\n    for _ in 0..len {\n        let product = xs_tail[0].wrapping_mul(m_inv);\n        let carry =\n            limbs_slice_add_mul_limb_same_length_in_place_left(&mut xs_tail[..len], ms, product);\n        assert_eq!(xs_tail[0], 0);\n        xs_tail[0] = carry;\n        xs_tail = &mut xs_tail[1..];\n    }\n    let (xs_lo, xs_hi) = xs.split_at(len);\n    limbs_add_same_length_to_out(out, xs_hi, xs_lo)\n}\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ms.len()`.\n//\n// This is equivalent to `MPN_REDC_1` from `mpn/generic/powm.c`, GMP 6.2.1. Investigate changes from\n// 6.1.2?\nfn limbs_redc_limb(out: &mut [Limb], xs: &mut [Limb], ms: &[Limb], m_inv: Limb) {\n    if limbs_redc_limb_raw(out, xs, ms, m_inv) {\n        limbs_sub_same_length_in_place_left(&mut out[..ms.len()], ms);\n    }\n}\n\nconst WIDTH_LIMITS: [u64; 10] = [7, 25, 81, 241, 673, 1793, 4609, 11521, 28161, u64::MAX];\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `win_size` from `mpn/generic/powm.c`, 6.2.1. Investigate changes from\n// 6.1.2?\npub(crate) fn get_window_size(width: u64) -> u64 {\n    u64::wrapping_from(\n        WIDTH_LIMITS\n            .iter()\n            .position(|&limit| width <= limit)\n            .unwrap()\n            + 1,\n    )\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ms.len()`.\n//\n// This is equivalent to `mpn_redc_n` from `mpn/generic/redc_n.c`, GMP 6.2.1.\nfn limbs_redc(out: &mut [Limb], xs: &[Limb], ms: &[Limb], is: &[Limb]) {\n    let ms_len = ms.len();\n    assert!(ms_len > 8);\n    let n = limbs_mul_mod_base_pow_n_minus_1_next_size(ms_len);\n    let mut scratch =\n        vec![0; limbs_mul_mod_base_pow_n_minus_1_scratch_len(n, ms_len, ms_len) + ms_len + n];\n    let (scratch_0, scratch) = scratch.split_at_mut(ms_len);\n    limbs_mul_low_same_length(scratch_0, &xs[..ms_len], &is[..ms_len]);\n    let (scratch_1, scratch_2) = scratch.split_at_mut(n);\n    limbs_mul_mod_base_pow_n_minus_1(scratch_1, n, scratch_0, ms, scratch_2);\n    let two_ms_len = ms_len << 1;\n    assert!(two_ms_len > n);\n    let m = two_ms_len - n;\n    let carry = limbs_sub_same_length_to_out(scratch_2, &scratch_1[..m], &xs[..m]);\n    let scratch = &mut scratch[..two_ms_len];\n    if carry {\n        assert!(!limbs_sub_limb_in_place(&mut scratch[m..], 1));\n    }\n    if limbs_sub_same_length_to_out(out, &xs[ms_len..two_ms_len], &scratch[ms_len..]) {\n        limbs_slice_add_same_length_in_place_left(&mut out[..ms_len], ms);\n    }\n}\n\n// Convert U to REDC form, U_r = B^n * U mod M\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ms.len()`.\n//\n// This is equivalent to `redcify` from `mpn/generic/powm.c`, 6.2.1. Investigate changes from 6.1.2?\nfn to_redc(out: &mut [Limb], xs: &[Limb], ms: &[Limb]) {\n    let xs_len = xs.len();\n    let ms_len = ms.len();\n    if ms_len == 1 {\n        let mut scratch = vec![0; (xs_len << 1) + ms_len + 1];\n        let (scratch, qs) = scratch.split_at_mut(xs_len + ms_len);\n        scratch[ms_len..].copy_from_slice(xs);\n        out[0] = limbs_div_limb_to_out_mod(qs, scratch, ms[0]);\n    } else {\n        let mut scratch = vec![0; xs_len + ms_len];\n        scratch[ms_len..].copy_from_slice(xs);\n        limbs_mod_to_out(out, &scratch, ms);\n    }\n}\n\n// TODO tune\nconst REDC_1_TO_REDC_N_THRESHOLD: usize = 100;\n\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {limbs_mod_pow_odd_scratch_len(n: usize) -> usize {\n    max(limbs_modular_invert_scratch_len(n), n << 1)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn square_using_basecase_mul(out: &mut [Limb], xs: &[Limb]) {\n    limbs_mul_greater_to_out_basecase(out, xs, xs);\n}\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ms.len()`.\nfn limbs_redc_limb_helper(out: &mut [Limb], xs: &mut [Limb], ms: &[Limb], is: &[Limb]) {\n    limbs_redc_limb(out, xs, ms, is[0]);\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ms.len()`.\nfn limbs_redc_helper(out: &mut [Limb], xs: &mut [Limb], ms: &[Limb], is: &[Limb]) {\n    limbs_redc(out, xs, ms, is);\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n#[allow(clippy::absurd_extreme_comparisons, clippy::type_complexity)]\nfn select_fns(\n    ms_len: usize,\n) -> (\n    &'static dyn Fn(&mut [Limb], &[Limb], &[Limb]),\n    &'static dyn Fn(&mut [Limb], &[Limb]),\n    &'static dyn Fn(&mut [Limb], &mut [Limb], &[Limb], &[Limb]),\n) {\n    if REDC_1_TO_REDC_N_THRESHOLD < MUL_TOOM22_THRESHOLD {\n        if ms_len < REDC_1_TO_REDC_N_THRESHOLD {\n            (\n                &limbs_mul_greater_to_out_basecase,\n                if REDC_1_TO_REDC_N_THRESHOLD < SQR_BASECASE_THRESHOLD\n                    || !(SQR_BASECASE_THRESHOLD..=SQR_TOOM2_THRESHOLD).contains(&ms_len)\n                {\n                    &square_using_basecase_mul\n                } else {\n                    &limbs_square_to_out_basecase\n                },\n                &limbs_redc_limb_helper,\n            )\n        } else if ms_len < MUL_TOOM22_THRESHOLD {\n            (\n                &limbs_mul_greater_to_out_basecase,\n                if MUL_TOOM22_THRESHOLD < SQR_BASECASE_THRESHOLD\n                    || !(SQR_BASECASE_THRESHOLD..=SQR_TOOM2_THRESHOLD).contains(&ms_len)\n                {\n                    &square_using_basecase_mul\n                } else {\n                    &limbs_square_to_out_basecase\n                },\n                &limbs_redc_helper,\n            )\n        } else {\n            (\n                &|out, xs, ys| {\n                    let mut mul_scratch =\n                        vec![0; limbs_mul_same_length_to_out_scratch_len(xs.len())];\n                    limbs_mul_same_length_to_out(out, xs, ys, &mut mul_scratch);\n                },\n                &|out, xs| {\n                    let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(xs.len())];\n                    limbs_square_to_out(out, xs, &mut square_scratch);\n                },\n                &limbs_redc_helper,\n            )\n        }\n    } else if ms_len < MUL_TOOM22_THRESHOLD {\n        (\n            &limbs_mul_greater_to_out_basecase,\n            if MUL_TOOM22_THRESHOLD < SQR_BASECASE_THRESHOLD\n                || !(SQR_BASECASE_THRESHOLD..=SQR_TOOM2_THRESHOLD).contains(&ms_len)\n            {\n                &square_using_basecase_mul\n            } else {\n                &limbs_square_to_out_basecase\n            },\n            &limbs_redc_limb_helper,\n        )\n    } else {\n        (\n            &|out, xs, ys| {\n                let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(xs.len())];\n                limbs_mul_same_length_to_out(out, xs, ys, &mut mul_scratch);\n            },\n            &|out, xs| {\n                let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(xs.len())];\n                limbs_square_to_out(out, xs, &mut square_scratch);\n            },\n            if ms_len < REDC_1_TO_REDC_N_THRESHOLD {\n                &limbs_redc_limb_helper\n            } else {\n                &limbs_redc_helper\n            },\n        )\n    }\n}\n\n// Given the limbs of $x$, $E$, and odd $m$, writes the limbs of $x^E \\mod m$ to an output slice.\n//\n// `xs`, `es`, and `ms` must be nonempty and their last elements must be nonzero. $m$ must be odd,\n// $E$ must be greater than 1, and `out` must be at least as long as `ms`. It is not required than\n// `xs` be less than `ms`.\n//\n// # Worst-case complexity\n// $T(n, m) = O(mn \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ms.len()`, and $m$ is `es.len()`.\n//\n// # Panics\n// Panics if `xs`, `es`, or `ms` are empty, if `xs` is longer than `ms`, if the first element of\n// `ms` is even, or if $E$ less than 2.\n//\n// This is equivalent to `mpn_powm` from `mpn/generic/powm.c`, GMP 6.2.1.\npub_test! {limbs_mod_pow_odd(\n    out: &mut [Limb],\n    xs: &[Limb],\n    es: &[Limb],\n    ms: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let es_len = es.len();\n    let ms_len = ms.len();\n    assert_ne!(xs_len, 0);\n    assert_ne!(es_len, 0);\n    if es_len == 1 {\n        assert!(es[0] > 1);\n    }\n    assert!(ms[0].odd());\n    let out = &mut out[..ms_len];\n    let width = limbs_significant_bits(es);\n    let window_size = get_window_size(width);\n    let mut small_is = [0; 2];\n    let mut is_vec;\n    let is: &mut [Limb];\n    let redc_fn: &dyn Fn(&mut [Limb], &mut [Limb], &[Limb], &[Limb]);\n    if ms_len < REDC_1_TO_REDC_N_THRESHOLD {\n        is = &mut small_is;\n        is[0] = limbs_modular_invert_limb(ms[0]);\n        is[0].wrapping_neg_assign();\n        redc_fn = &limbs_redc_limb_helper;\n    } else {\n        is_vec = vec![0; ms_len];\n        is = &mut is_vec;\n        limbs_modular_invert(is, ms, scratch);\n        redc_fn = &limbs_redc_helper;\n    }\n    let mut powers = vec![0; ms_len << (window_size - 1)];\n    let mut powers: Vec<&mut [Limb]> = powers.chunks_mut(ms_len).collect();\n    to_redc(powers[0], xs, ms);\n    // Store x ^ 2 at `out`.\n    let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(powers[0].len())];\n    limbs_square_to_out(scratch, powers[0], &mut square_scratch);\n    redc_fn(out, scratch, ms, is);\n    // Precompute odd powers of x and put them in `powers`.\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(out.len())];\n    for i in 1..usize::power_of_2(window_size - 1) {\n        let (powers_lo, powers_hi) = powers.split_at_mut(i);\n        limbs_mul_same_length_to_out(scratch, powers_lo[i - 1], out, &mut mul_scratch);\n        redc_fn(powers_hi[0], scratch, ms, is);\n    }\n    let exp_bits = get_bits(es, width, window_size);\n    let mut bit_index = if width < window_size {\n        fail_on_untested_path(\"limbs_mod_pow_odd, width < window_size\");\n        0\n    } else {\n        width - window_size\n    };\n    let trailing_zeros = TrailingZeros::trailing_zeros(Limb::exact_from(exp_bits));\n    bit_index += trailing_zeros;\n    out.copy_from_slice(powers[exp_bits >> trailing_zeros >> 1]);\n    let (mul_fn, square_fn, reduce_fn) = select_fns(ms_len);\n    'outer: while bit_index != 0 {\n        while !limbs_get_bit(es, bit_index - 1) {\n            square_fn(scratch, out);\n            reduce_fn(out, scratch, ms, is);\n            bit_index -= 1;\n            if bit_index == 0 {\n                break 'outer;\n            }\n        }\n        // The next bit of the exponent is 1. Now extract the largest block of bits <= window_size,\n        // and such that the least significant bit is 1.\n        let exp_bits = get_bits(es, bit_index, window_size);\n        let mut this_window_size = window_size;\n        if bit_index < window_size {\n            this_window_size -= window_size - bit_index;\n            bit_index = 0;\n        } else {\n            bit_index -= window_size;\n        }\n        let trailing_zeros = TrailingZeros::trailing_zeros(Limb::exact_from(exp_bits));\n        bit_index += trailing_zeros;\n        for _ in 0..this_window_size - trailing_zeros {\n            square_fn(scratch, out);\n            reduce_fn(out, scratch, ms, is);\n        }\n        mul_fn(scratch, out, powers[exp_bits >> trailing_zeros >> 1]);\n        reduce_fn(out, scratch, ms, is);\n    }\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(ms_len);\n    scratch_lo.copy_from_slice(out);\n    slice_set_zero(&mut scratch_hi[..ms_len]);\n    redc_fn(out, scratch, ms, is);\n    if limbs_cmp_same_length(out, ms) != Less {\n        limbs_sub_same_length_in_place_left(out, ms);\n    }\n}}\n\n// Interpreting a `Vec<Limb>` and two `&[Limb]` as the limbs (in ascending order) of three\n// `Natural`s, `x`, `exp`, and `m`, writes the limbs of `x ^ exp` mod `2 ^ m` to an output slice.\n// Assumes the input is already reduced mod `m`. No input may be empty or have trailing zeros, the\n// exponent must be greater than 1, and the output slice must be at least as long as `ms`.\n//\n// # Worst-case complexity\n// $T(n, m) = O(mn \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `ms.len()`, and $m$ is `es.len()`.\n//\n// # Panics\n// Panics if the exponent has trailing zeros or is 1.\n//\n// This is equivalent to `mpz_powm` from `mpn/generic/powm.c`, GMP 6.2.1, where `b`, `e`, and `m`\n// are non-negative. Investigate changes from 6.1.2?\npub_test! {limbs_mod_pow(out: &mut [Limb], xs: &[Limb], es: &[Limb], ms: &[Limb]) {\n    let ms_len = ms.len();\n    let es_len = es.len();\n    let xs_len = xs.len();\n    let mut ms_zero_len = slice_leading_zeros(ms);\n    let mut ms = &ms[ms_zero_len..];\n    let mut ms_nonzero_len = ms_len - ms_zero_len;\n    let mut ms_vec;\n    let mut ms_twos = 0;\n    if ms[0].even() {\n        ms_vec = vec![0; ms_nonzero_len];\n        ms_twos = TrailingZeros::trailing_zeros(ms[0]);\n        limbs_shr_to_out(&mut ms_vec, &ms[..ms_nonzero_len], ms_twos);\n        if ms_vec[ms_nonzero_len - 1] == 0 {\n            ms_nonzero_len -= 1;\n        }\n        ms = &ms_vec;\n        ms_zero_len += 1;\n    }\n    let scratch_len = if ms_zero_len != 0 {\n        // We will call both `limbs_mod_pow_odd` and `limbs_pow_low`.\n        let max_invert_len = max(ms_zero_len, ms_nonzero_len);\n        let invert_scratch_len = limbs_modular_invert_scratch_len(max_invert_len);\n        (ms_len << 1) + max(invert_scratch_len, ms_len << 1)\n    } else {\n        // We will call just `limbs_mod_pow_odd`.\n        let invert_scratch_len = limbs_modular_invert_scratch_len(ms_nonzero_len);\n        max(invert_scratch_len, ms_len << 1)\n    };\n    let mut scratch = vec![0; scratch_len];\n    limbs_mod_pow_odd(out, xs, es, &ms[..ms_nonzero_len], &mut scratch);\n    let mut xs_vec;\n    let mut xs = xs;\n    if ms_zero_len != 0 {\n        if xs_len < ms_zero_len {\n            xs_vec = vec![0; ms_zero_len];\n            xs_vec[..xs_len].copy_from_slice(xs);\n            xs = &xs_vec;\n        }\n        let mut do_pow_low = true;\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(ms_zero_len);\n        if xs[0].even() {\n            if es_len > 1 {\n                slice_set_zero(scratch_lo);\n                do_pow_low = false;\n            } else {\n                assert_eq!(es_len, 1);\n                let t = if ms_twos == 0 {\n                    limb_to_bit_count(ms_zero_len)\n                } else {\n                    limb_to_bit_count(ms_zero_len - 1) + ms_twos\n                };\n                // Count number of low zero bits in `xs`, up to 3.\n                let bits =\n                    (Limb::exact_from(0x1213) >> (xs[0].mod_power_of_2(3) << 1)).mod_power_of_2(2);\n                // Note that es[0] * bits might overflow, but that just results in a missed\n                // optimization.\n                #[cfg(feature = \"32_bit_limbs\")]\n                if let Ok(t) = Limb::try_from(t)\n                    && es[0].wrapping_mul(bits) >= t\n                {\n                    slice_set_zero(scratch_lo);\n                    do_pow_low = false;\n                }\n                #[cfg(not(feature = \"32_bit_limbs\"))]\n                if es[0].wrapping_mul(bits) >= t {\n                    slice_set_zero(scratch_lo);\n                    do_pow_low = false;\n                }\n            }\n        }\n        if do_pow_low {\n            scratch_lo.copy_from_slice(&xs[..ms_zero_len]);\n            limbs_pow_low(scratch_lo, &es[..es_len], scratch_hi);\n        }\n        let mut ms_vec;\n        if ms_nonzero_len < ms_zero_len {\n            ms_vec = vec![0; ms_zero_len];\n            ms_vec[..ms_nonzero_len].copy_from_slice(&ms[..ms_nonzero_len]);\n            ms = &ms_vec;\n        }\n        let (scratch_0_1, scratch_2) = scratch.split_at_mut(ms_len << 1);\n        let (scratch_0, scratch_1) = scratch_0_1.split_at_mut(ms_len);\n        let scratch_0 = &mut scratch_0[..ms_zero_len];\n        limbs_modular_invert(scratch_1, &ms[..ms_zero_len], scratch_2);\n        limbs_sub_greater_in_place_left(scratch_0, &out[..min(ms_zero_len, ms_nonzero_len)]);\n        limbs_mul_low_same_length(scratch_2, &scratch_1[..ms_zero_len], scratch_0);\n        if ms_twos != 0 {\n            scratch_2[ms_zero_len - 1].mod_power_of_2_assign(ms_twos);\n        }\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(ms_zero_len, ms_nonzero_len)];\n        limbs_mul_to_out(\n            scratch_0_1,\n            &scratch_2[..ms_zero_len],\n            &ms[..ms_nonzero_len],\n            &mut mul_scratch,\n        );\n        limbs_add_to_out_aliased(out, ms_nonzero_len, &scratch_0_1[..ms_len]);\n    }\n}}\n\nimpl ModPow<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$. The base must be\n    /// already reduced modulo $m$. All three [`Natural`]s are taken by value.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32).mod_pow(Natural::from(13u32), Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_pow(Natural::from(1000u32), Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[inline]\n    fn mod_pow(mut self, exp: Self, m: Self) -> Self {\n        self.mod_pow_assign(exp, m);\n        self\n    }\n}\n\nimpl<'a> ModPow<Self, &'a Self> for Natural {\n    type Output = Self;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$. The base must be\n    /// already reduced modulo $m$. The first two [`Natural`]s are taken by value and the third by\n    /// reference.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32).mod_pow(Natural::from(13u32), &Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_pow(Natural::from(1000u32), &Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[inline]\n    fn mod_pow(mut self, exp: Self, m: &'a Self) -> Self {\n        self.mod_pow_assign(exp, m);\n        self\n    }\n}\n\nimpl<'a> ModPow<&'a Self, Self> for Natural {\n    type Output = Self;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$. The base must be\n    /// already reduced modulo $m$. The first and third [`Natural`]s are taken by value and the\n    /// second by reference.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32).mod_pow(&Natural::from(13u32), Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_pow(&Natural::from(1000u32), Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[inline]\n    fn mod_pow(mut self, exp: &'a Self, m: Self) -> Self {\n        self.mod_pow_assign(exp, m);\n        self\n    }\n}\n\nimpl<'a, 'b> ModPow<&'a Self, &'b Self> for Natural {\n    type Output = Self;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$. The base must be\n    /// already reduced modulo $m$. The first [`Natural`] is taken by value and the second and third\n    /// by reference.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32).mod_pow(&Natural::from(13u32), &Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_pow(&Natural::from(1000u32), &Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[inline]\n    fn mod_pow(mut self, exp: &'a Self, m: &'b Self) -> Self {\n        self.mod_pow_assign(exp, m);\n        self\n    }\n}\n\nimpl ModPow<Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`]$m$. The base must be\n    /// already reduced modulo $m$. The first [`Natural`] is taken by reference and the second and\n    /// third by value.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32)).mod_pow(Natural::from(13u32), Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_pow(Natural::from(1000u32), Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow(self, mut exp: Natural, mut m: Natural) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, &exp, &m) {\n            (_, _, &Natural::ONE) => Natural::ZERO,\n            (_, &Natural::ZERO, _) => Natural::ONE,\n            (&Natural::ZERO, _, _) => Natural::ZERO,\n            (x, &Natural::ONE, _) => x.clone(),\n            (&Natural::ONE, _, _) => Natural::ONE,\n            (Natural(Small(x)), Natural(Small(e)), Natural(Small(m)))\n                if u64::convertible_from(*e) =>\n            {\n                Natural::from(x.mod_pow(u64::wrapping_from(*e), *m))\n            }\n            _ => {\n                let ms = m.promote_in_place();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(&mut out, self.as_limbs_asc(), exp.promote_in_place(), ms);\n                Natural::from_owned_limbs_asc(out)\n            }\n        }\n    }\n}\n\nimpl ModPow<Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$. The base must be\n    /// already reduced modulo $m$. The first and third [`Natural`]s are taken by reference and the\n    /// second by value.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32)).mod_pow(Natural::from(13u32), &Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_pow(Natural::from(1000u32), &Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow(self, mut exp: Natural, m: &Natural) -> Natural {\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, &exp, m) {\n            (_, _, &Natural::ONE) => Natural::ZERO,\n            (_, &Natural::ZERO, _) => Natural::ONE,\n            (&Natural::ZERO, _, _) => Natural::ZERO,\n            (x, &Natural::ONE, _) => x.clone(),\n            (&Natural::ONE, _, _) => Natural::ONE,\n            (Natural(Small(x)), Natural(Small(e)), Natural(Small(m)))\n                if u64::convertible_from(*e) =>\n            {\n                Natural::from(x.mod_pow(u64::wrapping_from(*e), *m))\n            }\n            _ => {\n                let ms = m.as_limbs_asc();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(&mut out, self.as_limbs_asc(), exp.promote_in_place(), ms);\n                Natural::from_owned_limbs_asc(out)\n            }\n        }\n    }\n}\n\nimpl ModPow<&Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$. The base must be\n    /// already reduced modulo $m$. The first two [`Natural`]s are taken by reference and the third\n    /// by value.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32)).mod_pow(&Natural::from(13u32), Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_pow(&Natural::from(1000u32), Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow(self, exp: &Natural, mut m: Natural) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, exp, &m) {\n            (_, _, &Natural::ONE) => Natural::ZERO,\n            (_, &Natural::ZERO, _) => Natural::ONE,\n            (&Natural::ZERO, _, _) => Natural::ZERO,\n            (x, &Natural::ONE, _) => x.clone(),\n            (&Natural::ONE, _, _) => Natural::ONE,\n            (Natural(Small(x)), Natural(Small(e)), Natural(Small(m)))\n                if u64::convertible_from(*e) =>\n            {\n                Natural::from(x.mod_pow(u64::wrapping_from(*e), *m))\n            }\n            _ => {\n                let ms = m.promote_in_place();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(&mut out, self.as_limbs_asc(), exp.as_limbs_asc(), ms);\n                Natural::from_owned_limbs_asc(out)\n            }\n        }\n    }\n}\n\nimpl ModPow<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$. The base must be\n    /// already reduced modulo $m$. All three [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, n, m) = y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32)).mod_pow(&Natural::from(13u32), &Natural::from(497u32)),\n    ///     445\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_pow(&Natural::from(1000u32), &Natural::from(30u32)),\n    ///     10\n    /// );\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow(self, exp: &Natural, m: &Natural) -> Natural {\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (self, exp, m) {\n            (_, _, &Natural::ONE) => Natural::ZERO,\n            (_, &Natural::ZERO, _) => Natural::ONE,\n            (&Natural::ZERO, _, _) => Natural::ZERO,\n            (x, &Natural::ONE, _) => x.clone(),\n            (&Natural::ONE, _, _) => Natural::ONE,\n            (Natural(Small(x)), Natural(Small(e)), Natural(Small(m)))\n                if u64::convertible_from(*e) =>\n            {\n                Natural::from(x.mod_pow(u64::wrapping_from(*e), *m))\n            }\n            _ => {\n                let ms = m.as_limbs_asc();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(&mut out, self.as_limbs_asc(), exp.as_limbs_asc(), ms);\n                Natural::from_owned_limbs_asc(out)\n            }\n        }\n    }\n}\n\nimpl ModPowAssign<Self, Self> for Natural {\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$, in place. The\n    /// base must be already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken\n    /// by value.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_pow_assign(Natural::from(13u32), Natural::from(497u32));\n    /// assert_eq!(x, 445);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_pow_assign(Natural::from(1000u32), Natural::from(30u32));\n    /// assert_eq!(x, 10);\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow_assign(&mut self, mut exp: Self, mut m: Self) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (&mut *self, &exp, &m) {\n            (_, _, &Self::ONE) => *self = Self::ZERO,\n            (_, &Self::ZERO, _) => *self = Self::ONE,\n            (&mut (Self::ZERO | Self::ONE), _, _) | (_, &Self::ONE, _) => {}\n            (Self(Small(x)), Self(Small(e)), Self(Small(m))) if u64::convertible_from(*e) => {\n                x.mod_pow_assign(u64::wrapping_from(*e), *m);\n            }\n            _ => {\n                let ms = m.promote_in_place();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(\n                    &mut out,\n                    self.promote_in_place(),\n                    exp.promote_in_place(),\n                    ms,\n                );\n                *self = Self::from_owned_limbs_asc(out);\n            }\n        }\n    }\n}\n\nimpl<'a> ModPowAssign<Self, &'a Self> for Natural {\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$, in place. The\n    /// base must be already reduced modulo $m$. The first [`Natural`] on the right-hand side is\n    /// taken by value and the second by reference.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_pow_assign(Natural::from(13u32), &Natural::from(497u32));\n    /// assert_eq!(x, 445);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_pow_assign(Natural::from(1000u32), &Natural::from(30u32));\n    /// assert_eq!(x, 10);\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow_assign(&mut self, mut exp: Self, m: &'a Self) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (&mut *self, &exp, m) {\n            (_, _, &Self::ONE) => *self = Self::ZERO,\n            (_, &Self::ZERO, _) => *self = Self::ONE,\n            (&mut (Self::ZERO | Self::ONE), _, _) | (_, &Self::ONE, _) => {}\n            (Self(Small(x)), Self(Small(e)), Self(Small(m))) if u64::convertible_from(*e) => {\n                x.mod_pow_assign(u64::wrapping_from(*e), *m);\n            }\n            _ => {\n                let ms = m.as_limbs_asc();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(\n                    &mut out,\n                    self.promote_in_place(),\n                    exp.promote_in_place(),\n                    ms,\n                );\n                *self = Self::from_owned_limbs_asc(out);\n            }\n        }\n    }\n}\n\nimpl<'a> ModPowAssign<&'a Self, Self> for Natural {\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$, in place. The\n    /// base must be already reduced modulo $m$. The first [`Natural`] on the right-hand side is\n    /// taken by reference and the second by value.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_pow_assign(&Natural::from(13u32), Natural::from(497u32));\n    /// assert_eq!(x, 445);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_pow_assign(&Natural::from(1000u32), Natural::from(30u32));\n    /// assert_eq!(x, 10);\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow_assign(&mut self, exp: &'a Self, mut m: Self) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (&mut *self, exp, &m) {\n            (_, _, &Self::ONE) => *self = Self::ZERO,\n            (_, &Self::ZERO, _) => *self = Self::ONE,\n            (&mut (Self::ZERO | Self::ONE), _, _) | (_, &Self::ONE, _) => {}\n            (Self(Small(x)), Self(Small(e)), Self(Small(m))) if u64::convertible_from(*e) => {\n                x.mod_pow_assign(u64::wrapping_from(*e), *m);\n            }\n            _ => {\n                let ms = m.promote_in_place();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(&mut out, self.promote_in_place(), exp.as_limbs_asc(), ms);\n                *self = Self::from_owned_limbs_asc(out);\n            }\n        }\n    }\n}\n\nimpl<'a, 'b> ModPowAssign<&'a Self, &'b Self> for Natural {\n    /// Raises a [`Natural`] to a [`Natural`] power modulo a third [`Natural`] $m$, in place. The\n    /// base must be already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken\n    /// by reference.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $x^n \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_pow_assign(&Natural::from(13u32), &Natural::from(497u32));\n    /// assert_eq!(x, 445);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_pow_assign(&Natural::from(1000u32), &Natural::from(30u32));\n    /// assert_eq!(x, 10);\n    /// ```\n    #[allow(clippy::match_same_arms)] // matches are order-dependent\n    fn mod_pow_assign(&mut self, exp: &'a Self, m: &'b Self) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        match (&mut *self, exp, m) {\n            (_, _, &Self::ONE) => *self = Self::ZERO,\n            (_, &Self::ZERO, _) => *self = Self::ONE,\n            (&mut (Self::ZERO | Self::ONE), _, _) | (_, &Self::ONE, _) => {}\n            (Self(Small(x)), Self(Small(e)), Self(Small(m))) if u64::convertible_from(*e) => {\n                x.mod_pow_assign(u64::wrapping_from(*e), *m);\n            }\n            _ => {\n                let ms = m.as_limbs_asc();\n                let mut out = vec![0; ms.len()];\n                limbs_mod_pow(&mut out, self.promote_in_place(), exp.as_limbs_asc(), ms);\n                *self = Self::from_owned_limbs_asc(out);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1995, 2001, 2002, 2012 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::conversion::to_twos_complement_limbs::limbs_twos_complement_in_place;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_ceiling, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Assign, NegModPowerOf2, NegModPowerOf2Assign, RemPowerOf2,\n    RemPowerOf2Assign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::slices::slice_set_zero;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` mod two raised to `pow`. Equivalently, retains only the least-significant\n// `pow` bits.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// This is equivalent to `mpz_tdiv_r_2exp` from `mpz/tdiv_r_2exp.c`, GMP 6.2.1, where in is\n// non-negative and the result is returned.\npub_test! {limbs_mod_power_of_2(xs: &[Limb], pow: u64) -> Vec<Limb> {\n    if pow == 0 {\n        return Vec::new();\n    }\n    let leftover_bits = pow & Limb::WIDTH_MASK;\n    let result_size = bit_to_limb_count_floor(pow);\n    if result_size >= xs.len() {\n        return xs.to_vec();\n    }\n    let mut result = xs[..result_size].to_vec();\n    if leftover_bits != 0 {\n        result.push(xs[result_size].mod_power_of_2(leftover_bits));\n    }\n    result\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` mod two raised to `pow` to the input slice. Equivalently, retains only the\n// least-significant `pow` bits. If the upper limbs of the input slice are no longer needed, they\n// are set to zero.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpz_tdiv_r_2exp` from `mpz/tdiv_r_2exp.c`, GMP 6.2.1, where `in` is\n// non-negative, `res == in`, and instead of possibly being truncated, the high limbs of `res` are\n// possibly filled with zeros.\npub_crate_test! {limbs_slice_mod_power_of_2_in_place(xs: &mut [Limb], pow: u64) {\n    if pow == 0 {\n        slice_set_zero(xs);\n        return;\n    }\n    let new_size = bit_to_limb_count_ceiling(pow);\n    if new_size > xs.len() {\n        return;\n    }\n    slice_set_zero(&mut xs[new_size..]);\n    let leftover_bits = pow & Limb::WIDTH_MASK;\n    if leftover_bits != 0 {\n        xs[new_size - 1].mod_power_of_2_assign(leftover_bits);\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` mod two raised to `pow` to the input `Vec`. Equivalently, retains only the\n// least-significant `pow` bits.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpz_tdiv_r_2exp` from `mpz/tdiv_r_2exp.c`, GMP 6.2.1, where `in` is\n// non-negative and `res == in`.\npub_crate_test! {limbs_vec_mod_power_of_2_in_place(xs: &mut Vec<Limb>, pow: u64) {\n    if pow == 0 {\n        xs.clear();\n        return;\n    }\n    let new_size = bit_to_limb_count_ceiling(pow);\n    if new_size > xs.len() {\n        return;\n    }\n    xs.truncate(new_size);\n    let leftover_bits = pow & Limb::WIDTH_MASK;\n    if leftover_bits != 0 {\n        xs[new_size - 1].mod_power_of_2_assign(leftover_bits);\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the negative of the `Natural` mod two raised to `pow`. Equivalently, takes the two's\n// complement and retains only the least-significant `pow` bits.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// This is equivalent to `mpz_tdiv_r_2exp` from `mpz/tdiv_r_2exp.c`, GMP 6.2.1, where `in` is\n// negative and the result is returned. `xs` is the limbs of `-in`.\npub_crate_test! {limbs_neg_mod_power_of_2(xs: &[Limb], pow: u64) -> Vec<Limb> {\n    let mut result = xs.to_vec();\n    limbs_neg_mod_power_of_2_in_place(&mut result, pow);\n    result\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the negative of the `Natural` mod two raised to `pow` to the input `Vec`. Equivalently,\n// takes the two's complement and retains only the least-significant `pow` bits.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// This is equivalent to `mpz_tdiv_r_2exp` from `mpz/tdiv_r_2exp.c`, GMP 6.2.1, where `in` is\n// negative and `res == in`. `xs` is the limbs of `-in`.\npub_crate_test! {limbs_neg_mod_power_of_2_in_place(xs: &mut Vec<Limb>, pow: u64) {\n    let new_size = bit_to_limb_count_ceiling(pow);\n    xs.resize(new_size, 0);\n    limbs_twos_complement_in_place(xs);\n    let leftover_bits = pow & Limb::WIDTH_MASK;\n    if leftover_bits != 0 {\n        xs[new_size - 1].mod_power_of_2_assign(leftover_bits);\n    }\n}}\n\nimpl ModPowerOf2 for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by $2^k$, returning just the remainder. The [`Natural`] is taken by\n    /// value.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!(Natural::from(260u32).mod_power_of_2(8), 4);\n    ///\n    /// // 100 * 2^4 + 11 = 1611\n    /// assert_eq!(Natural::from(1611u32).mod_power_of_2(4), 11);\n    /// ```\n    #[inline]\n    fn mod_power_of_2(mut self, pow: u64) -> Self {\n        self.mod_power_of_2_assign(pow);\n        self\n    }\n}\n\nimpl ModPowerOf2 for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by $2^k$, returning just the remainder. The [`Natural`] is taken by\n    /// reference.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!((&Natural::from(260u32)).mod_power_of_2(8), 4);\n    /// // 100 * 2^4 + 11 = 1611\n    /// assert_eq!((&Natural::from(1611u32)).mod_power_of_2(4), 11);\n    /// ```\n    fn mod_power_of_2(self, pow: u64) -> Natural {\n        match self {\n            Natural(Small(small)) => Natural(Small(small.mod_power_of_2(pow))),\n            Natural(Large(limbs)) => {\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2(limbs, pow))\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2Assign for Natural {\n    /// Divides a [`Natural`]by $2^k$, replacing the [`Natural`] by the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Assign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// let mut x = Natural::from(260u32);\n    /// x.mod_power_of_2_assign(8);\n    /// assert_eq!(x, 4);\n    ///\n    /// // 100 * 2^4 + 11 = 1611\n    /// let mut x = Natural::from(1611u32);\n    /// x.mod_power_of_2_assign(4);\n    /// assert_eq!(x, 11);\n    /// ```\n    fn mod_power_of_2_assign(&mut self, pow: u64) {\n        match &mut *self {\n            Self(Small(small)) => small.mod_power_of_2_assign(pow),\n            Self(Large(limbs)) => {\n                limbs_vec_mod_power_of_2_in_place(limbs, pow);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl RemPowerOf2 for Natural {\n    type Output = Self;\n\n    /// Divides a [`Natural`] by $2^k$, returning just the remainder. The [`Natural`] is taken by\n    /// value.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem_power_of_2` is equivalent to\n    /// [`mod_power_of_2`](ModPowerOf2::mod_power_of_2).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RemPowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!(Natural::from(260u32).rem_power_of_2(8), 4);\n    ///\n    /// // 100 * 2^4 + 11 = 1611\n    /// assert_eq!(Natural::from(1611u32).rem_power_of_2(4), 11);\n    /// ```\n    #[inline]\n    fn rem_power_of_2(self, pow: u64) -> Self {\n        self.mod_power_of_2(pow)\n    }\n}\n\nimpl RemPowerOf2 for &Natural {\n    type Output = Natural;\n\n    /// Divides a [`Natural`] by $2^k$, returning just the remainder. The [`Natural`] is taken by\n    /// reference.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem_power_of_2` is equivalent to\n    /// [`mod_power_of_2`](ModPowerOf2::mod_power_of_2).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RemPowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// assert_eq!((&Natural::from(260u32)).rem_power_of_2(8), 4);\n    /// // 100 * 2^4 + 11 = 1611\n    /// assert_eq!((&Natural::from(1611u32)).rem_power_of_2(4), 11);\n    /// ```\n    #[inline]\n    fn rem_power_of_2(self, pow: u64) -> Natural {\n        self.mod_power_of_2(pow)\n    }\n}\n\nimpl RemPowerOf2Assign for Natural {\n    /// Divides a [`Natural`] by $2^k$, replacing the first [`Natural`] by the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// x \\gets x - 2^k\\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n    /// $$\n    ///\n    /// For [`Natural`]s, `rem_power_of_2_assign` is equivalent to\n    /// [`mod_power_of_2_assign`](ModPowerOf2Assign::mod_power_of_2_assign).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RemPowerOf2Assign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 1 * 2^8 + 4 = 260\n    /// let mut x = Natural::from(260u32);\n    /// x.rem_power_of_2_assign(8);\n    /// assert_eq!(x, 4);\n    ///\n    /// // 100 * 2^4 + 11 = 1611\n    /// let mut x = Natural::from(1611u32);\n    /// x.rem_power_of_2_assign(4);\n    /// assert_eq!(x, 11);\n    /// ```\n    #[inline]\n    fn rem_power_of_2_assign(&mut self, pow: u64) {\n        self.mod_power_of_2_assign(pow);\n    }\n}\n\nimpl NegModPowerOf2 for Natural {\n    type Output = Self;\n\n    /// Divides the negative of a [`Natural`] by a $2^k$, returning just the remainder. The\n    /// [`Natural`] is taken by value.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NegModPowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 2^8 - 252 = 260\n    /// assert_eq!(Natural::from(260u32).neg_mod_power_of_2(8), 252);\n    ///\n    /// // 101 * 2^4 - 5 = 1611\n    /// assert_eq!(Natural::from(1611u32).neg_mod_power_of_2(4), 5);\n    /// ```\n    #[inline]\n    fn neg_mod_power_of_2(mut self, pow: u64) -> Self {\n        self.neg_mod_power_of_2_assign(pow);\n        self\n    }\n}\n\nimpl NegModPowerOf2 for &Natural {\n    type Output = Natural;\n\n    /// Divides the negative of a [`Natural`] by a $2^k$, returning just the remainder. The\n    /// [`Natural`] is taken by reference.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// f(x, k) = 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NegModPowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 2^8 - 252 = 260\n    /// assert_eq!((&Natural::from(260u32)).neg_mod_power_of_2(8), 252);\n    /// // 101 * 2^4 - 5 = 1611\n    /// assert_eq!((&Natural::from(1611u32)).neg_mod_power_of_2(4), 5);\n    /// ```\n    fn neg_mod_power_of_2(self, pow: u64) -> Natural {\n        match (self, pow) {\n            (&Natural::ZERO, _) => Natural::ZERO,\n            (_, pow) if pow <= Limb::WIDTH => {\n                Natural::from(Limb::wrapping_from(self).neg_mod_power_of_2(pow))\n            }\n            (Natural(Small(small)), pow) => {\n                Natural::from_owned_limbs_asc(limbs_neg_mod_power_of_2(&[*small], pow))\n            }\n            (Natural(Large(limbs)), pow) => {\n                Natural::from_owned_limbs_asc(limbs_neg_mod_power_of_2(limbs, pow))\n            }\n        }\n    }\n}\n\nimpl NegModPowerOf2Assign for Natural {\n    /// Divides the negative of a [`Natural`] by $2^k$, returning just the remainder.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and\n    /// $0 \\leq r < 2^k$.\n    ///\n    /// $$\n    /// x \\gets 2^k\\left \\lceil \\frac{x}{2^k} \\right \\rceil - x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NegModPowerOf2Assign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 2 * 2^8 - 252 = 260\n    /// let mut x = Natural::from(260u32);\n    /// x.neg_mod_power_of_2_assign(8);\n    /// assert_eq!(x, 252);\n    ///\n    /// // 101 * 2^4 - 5 = 1611\n    /// let mut x = Natural::from(1611u32);\n    /// x.neg_mod_power_of_2_assign(4);\n    /// assert_eq!(x, 5);\n    /// ```\n    fn neg_mod_power_of_2_assign(&mut self, pow: u64) {\n        if *self == 0 {\n        } else if pow <= Limb::WIDTH {\n            *self = Self::from(Limb::wrapping_from(&*self).neg_mod_power_of_2(pow));\n        } else {\n            let limbs = self.promote_in_place();\n            limbs_neg_mod_power_of_2_in_place(limbs, pow);\n            self.trim();\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb, limbs_slice_add_greater_in_place_left, limbs_slice_add_limb_in_place,\n    limbs_slice_add_same_length_in_place_left, limbs_vec_add_in_place_left,\n};\nuse crate::natural::logic::bit_access::limbs_clear_bit;\nuse crate::natural::{Natural, bit_to_limb_count_ceiling};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2Add, ModPowerOf2AddAssign, ModPowerOf2Shl, ModPowerOf2ShlAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::SignificantBits;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the sum of the `Natural` and a `Limb`, mod `2 ^ pow`. Assumes the input is already\n// reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_mod_power_of_2_add_limb(xs: &[Limb], y: Limb, pow: u64) -> Vec<Limb> {\n    if xs.len() < bit_to_limb_count_ceiling(pow) {\n        limbs_add_limb(xs, y)\n    } else {\n        let mut out = xs.to_vec();\n        if !limbs_slice_add_limb_in_place(&mut out, y) {\n            limbs_clear_bit(&mut out, pow);\n        }\n        out\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the sum of the `Natural` and a `Limb`, mod `2 ^ pow`, to the input slice. Returns\n// whether there is a carry. Assumes the input is already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_slice_mod_power_of_2_add_limb_in_place(\n    xs: &mut [Limb],\n    y: Limb,\n    pow: u64\n) -> bool {\n    if xs.len() < bit_to_limb_count_ceiling(pow) {\n        limbs_slice_add_limb_in_place(xs, y)\n    } else {\n        if !limbs_slice_add_limb_in_place(xs, y) {\n            limbs_clear_bit(xs, pow);\n        }\n        false\n    }\n}}\n\n// Interpreting a nonempty `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes\n// the limbs of the sum of the `Natural` and a `Limb`, mod `2 ^ pow`, to the input `Vec`. Assumes\n// the input is already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_crate_test! {limbs_vec_mod_power_of_2_add_limb_in_place(xs: &mut Vec<Limb>, y: Limb, pow: u64) {\n    assert!(!xs.is_empty());\n    if limbs_slice_mod_power_of_2_add_limb_in_place(xs, y, pow) {\n        xs.push(1);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, where the\n// first slice is at least as long as the second, returns a `Vec` of the limbs of the sum of the\n// `Natural`s mod `2 ^ pow`. Assumes the inputs are already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\npub_test! {limbs_mod_power_of_2_add_greater(xs: &[Limb], ys: &[Limb], pow: u64) -> Vec<Limb> {\n    let mut out = xs.to_vec();\n    if limbs_slice_mod_power_of_2_add_greater_in_place_left(&mut out, ys, pow) {\n        out.push(1);\n    }\n    out\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns a\n// `Vec` of the limbs of the sum of the `Natural`s mod `2 ^ pow`. Assumes the inputs are already\n// reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\npub_test! {limbs_mod_power_of_2_add(xs: &[Limb], ys: &[Limb], pow: u64) -> Vec<Limb> {\n    if xs.len() >= ys.len() {\n        limbs_mod_power_of_2_add_greater(xs, ys, pow)\n    } else {\n        limbs_mod_power_of_2_add_greater(ys, xs, pow)\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, where the\n// length of the first slice is greater than or equal to the length of the second, writes the\n// `xs.len()` least-significant limbs of the sum of the `Natural`s, mod `2 ^ pow`, to the first\n// (left) slice. Returns whether there is a carry. Assumes the inputs are already reduced mod `2 ^\n// pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\npub_test! {limbs_slice_mod_power_of_2_add_greater_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    pow: u64,\n) -> bool {\n    if xs.len() < bit_to_limb_count_ceiling(pow) {\n        limbs_slice_add_greater_in_place_left(xs, ys)\n    } else {\n        if !limbs_slice_add_greater_in_place_left(xs, ys) {\n            limbs_clear_bit(xs, pow);\n        }\n        false\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s and a slice of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the sum of the `Natural`s, mod `2 ^ pow`, to the first (left)\n// slice. Assumes the inputs are already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(xs.len(), ys.len())`, and $m$ is `max(1,\n// ys.len() - xs.len())`.\npub_test! {limbs_vec_mod_power_of_2_add_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb], pow: u64) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let max_len =bit_to_limb_count_ceiling(pow);\n    if xs_len < max_len && ys_len < max_len {\n        limbs_vec_add_in_place_left(xs, ys);\n    } else {\n        let carry = if xs_len >= ys_len {\n            limbs_slice_mod_power_of_2_add_greater_in_place_left(xs, ys, pow)\n        } else {\n            let (ys_lo, ys_hi) = ys.split_at(xs_len);\n            let mut carry = limbs_slice_add_same_length_in_place_left(xs, ys_lo);\n            xs.extend_from_slice(ys_hi);\n            if carry {\n                carry = limbs_slice_add_limb_in_place(&mut xs[xs_len..], 1);\n            }\n            carry\n        };\n        if !carry {\n            limbs_clear_bit(xs, pow);\n        }\n    }\n}}\n\n// Interpreting two `Vec`s of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the sum of the `Natural`s, mod `2 ^ pow`, to the longer slice (or the first one, if\n// they are equally long). Returns a `bool` which is `false` when the output is to the first `Vec`\n// and `true` when it's to the second `Vec`. Assumes the inputs are already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\npub_test! {limbs_mod_power_of_2_add_in_place_either(\n    xs: &mut Vec<Limb>,\n    ys: &mut Vec<Limb>,\n    pow: u64,\n) -> bool {\n    if xs.len() >= ys.len() {\n        if limbs_slice_mod_power_of_2_add_greater_in_place_left(xs, ys, pow) {\n            xs.push(1);\n        }\n        false\n    } else {\n        if limbs_slice_mod_power_of_2_add_greater_in_place_left(ys, xs, pow) {\n            ys.push(1);\n        }\n        true\n    }\n}}\n\nimpl Natural {\n    fn mod_power_of_2_add_limb_ref(&self, y: Limb, pow: u64) -> Self {\n        match (self, y, pow) {\n            (_, 0, _) => self.clone(),\n            (&Self::ZERO, _, _) => Self(Small(y)),\n            (&Self(Small(small)), other, pow) if pow <= Limb::WIDTH => {\n                Self(Small(small.mod_power_of_2_add(other, pow)))\n            }\n            (&Self(Small(small)), other, _) => {\n                let (sum, overflow) = small.overflowing_add(other);\n                if overflow {\n                    Self(Large(vec![sum, 1]))\n                } else {\n                    Self(Small(sum))\n                }\n            }\n            (&Self(Large(ref limbs)), other, pow) => {\n                Self::from_owned_limbs_asc(limbs_mod_power_of_2_add_limb(limbs, other, pow))\n            }\n        }\n    }\n\n    fn mod_power_of_2_add_assign_limb(&mut self, y: Limb, pow: u64) {\n        match (&mut *self, y, pow) {\n            (_, 0, _) => {}\n            (&mut Self::ZERO, _, _) => *self = Self(Small(y)),\n            (&mut Self(Small(ref mut small)), other, pow) if pow <= Limb::WIDTH => {\n                small.mod_power_of_2_add_assign(other, pow);\n            }\n            (&mut Self(Small(ref mut small)), other, _) => {\n                let (sum, overflow) = small.overflowing_add(other);\n                if overflow {\n                    *self = Self(Large(vec![sum, 1]));\n                } else {\n                    *small = sum;\n                }\n            }\n            (&mut Self(Large(ref mut limbs)), y, pow) => {\n                limbs_vec_mod_power_of_2_add_limb_in_place(limbs, y, pow);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2Add<Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$. Both\n    /// [`Natural`]s are taken by value.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Add;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_power_of_2_add(Natural::from(2u32), 5), 2);\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_power_of_2_add(Natural::from(14u32), 4),\n    ///     8\n    /// );\n    /// ```\n    fn mod_power_of_2_add(mut self, other: Self, pow: u64) -> Self {\n        self.mod_power_of_2_add_assign(other, pow);\n        self\n    }\n}\n\nimpl<'a> ModPowerOf2Add<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Adds two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$. The\n    /// first [`Natural`] is taken by value and the second by reference.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Add;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_power_of_2_add(&Natural::from(2u32), 5), 2);\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_power_of_2_add(&Natural::from(14u32), 4),\n    ///     8\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_add(mut self, other: &'a Self, pow: u64) -> Self {\n        self.mod_power_of_2_add_assign(other, pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Add<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$. The\n    /// first [`Natural`] is taken by reference and the second by value.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Add;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO).mod_power_of_2_add(Natural::from(2u32), 5),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_power_of_2_add(Natural::from(14u32), 4),\n    ///     8\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_add(self, mut other: Natural, pow: u64) -> Natural {\n        other.mod_power_of_2_add_assign(self, pow);\n        other\n    }\n}\n\nimpl ModPowerOf2Add<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Adds two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$. Both\n    /// [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Add;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::ZERO).mod_power_of_2_add(&Natural::from(2u32), 5),\n    ///     2\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_power_of_2_add(&Natural::from(14u32), 4),\n    ///     8\n    /// );\n    /// ```\n    fn mod_power_of_2_add(self, other: &Natural, pow: u64) -> Natural {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (self, other) {\n            (x, y) if core::ptr::eq(x, y) => self.mod_power_of_2_shl(1, pow),\n            (x, &Natural(Small(y))) => x.mod_power_of_2_add_limb_ref(y, pow),\n            (&Natural(Small(x)), y) => y.mod_power_of_2_add_limb_ref(x, pow),\n            (&Natural(Large(ref xs)), &Natural(Large(ref ys))) => {\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_add(xs, ys, pow))\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2AddAssign<Self> for Natural {\n    /// Adds two [`Natural`]s modulo $2^k$, in place. The inputs must be already reduced modulo\n    /// $2^k$. The [`Natural`] on the right-hand side is taken by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2AddAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.mod_power_of_2_add_assign(Natural::from(2u32), 5);\n    /// assert_eq!(x, 2);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_power_of_2_add_assign(Natural::from(14u32), 4);\n    /// assert_eq!(x, 8);\n    /// ```\n    fn mod_power_of_2_add_assign(&mut self, mut other: Self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (&mut *self, &mut other) {\n            (x, &mut Self(Small(y))) => x.mod_power_of_2_add_assign_limb(y, pow),\n            (&mut Self(Small(x)), y) => *self = y.mod_power_of_2_add_limb_ref(x, pow),\n            (&mut Self(Large(ref mut xs)), _) => {\n                if let Self(Large(mut ys)) = other {\n                    if limbs_mod_power_of_2_add_in_place_either(xs, &mut ys, pow) {\n                        *xs = ys;\n                    }\n                    self.trim();\n                }\n            }\n        }\n    }\n}\n\nimpl<'a> ModPowerOf2AddAssign<&'a Self> for Natural {\n    /// Adds two [`Natural`]s modulo $2^k$, in place. The inputs must be already reduced modulo\n    /// $2^k$. The [`Natural`] on the right-hand side is taken by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2AddAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.mod_power_of_2_add_assign(&Natural::from(2u32), 5);\n    /// assert_eq!(x, 2);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_power_of_2_add_assign(&Natural::from(14u32), 4);\n    /// assert_eq!(x, 8);\n    /// ```\n    fn mod_power_of_2_add_assign(&mut self, other: &'a Self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (&mut *self, other) {\n            (x, y) if core::ptr::eq(x, y) => {\n                self.mod_power_of_2_shl_assign(pow, 1);\n            }\n            (x, &Self(Small(y))) => x.mod_power_of_2_add_assign_limb(y, pow),\n            (&mut Self(Small(x)), y) => *self = y.mod_power_of_2_add_limb_ref(x, pow),\n            (&mut Self(Large(ref mut xs)), &Self(Large(ref ys))) => {\n                limbs_vec_mod_power_of_2_add_in_place_left(xs, ys, pow);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::conversion::to_twos_complement_limbs::limbs_twos_complement_in_place;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::mod_power_of_2::limbs_slice_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::mul::mul_low::limbs_mul_low_same_length;\nuse crate::natural::{Natural, bit_to_limb_count_ceiling};\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2Inverse, Parity};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::logic::traits::SignificantBits;\n\n// - out should be just long enough for `pow` bits.\n// - xs should have the same length as out.\n// - scratch should be at least twice as long as out.\n// - out should be filled with zeros.\nfn limbs_mod_power_of_2_inverse(out: &mut [Limb], xs: &[Limb], pow: u64, scratch: &mut [Limb]) {\n    let len = out.len();\n    split_into_chunks_mut!(scratch, len, [scratch_0, scratch_1], _unused);\n    let mut limb_pow = 1;\n    out[0] = xs[0].mod_power_of_2_inverse(Limb::WIDTH).unwrap();\n    while limb_pow < len {\n        limb_pow <<= 1;\n        if limb_pow > len {\n            limb_pow = len;\n        }\n        let out_lo = &mut out[..limb_pow];\n        let scratch_0_lo = &mut scratch_0[..limb_pow];\n        let scratch_1_lo = &mut scratch_1[..limb_pow];\n        limbs_mul_low_same_length(scratch_0_lo, out_lo, &xs[..limb_pow]);\n        limbs_twos_complement_in_place(scratch_0_lo);\n        limbs_slice_add_limb_in_place(scratch_0_lo, 2);\n        limbs_mul_low_same_length(scratch_1_lo, scratch_0_lo, out_lo);\n        out_lo.copy_from_slice(scratch_1_lo);\n    }\n    limbs_slice_mod_power_of_2_in_place(out, pow);\n}\n\n#[allow(clippy::unnecessary_wraps)]\nfn mod_power_of_2_inverse_helper(xs: &[Limb], pow: u64) -> Option<Natural> {\n    let len = xs.len();\n    let mut big_scratch = vec![0; len * 3];\n    let (out, scratch) = big_scratch.split_at_mut(len);\n    limbs_mod_power_of_2_inverse(out, xs, pow, scratch);\n    big_scratch.truncate(len);\n    Some(Natural::from_owned_limbs_asc(big_scratch))\n}\n\nimpl ModPowerOf2Inverse for Natural {\n    type Output = Self;\n\n    /// Computes the multiplicative inverse of a [`Natural`] modulo $2^k$. The input must be already\n    /// reduced modulo $2^k$. The [`Natural`] is taken by value.\n    ///\n    /// Returns `None` if $x$ is even.\n    ///\n    /// $f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \\equiv 1 \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Inverse;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_power_of_2_inverse(8),\n    ///     Some(Natural::from(171u32))\n    /// );\n    /// assert_eq!(Natural::from(4u32).mod_power_of_2_inverse(8), None);\n    /// ```\n    fn mod_power_of_2_inverse(self, pow: u64) -> Option<Self> {\n        assert_ne!(self, 0u32);\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        match (self, pow) {\n            (Self::ONE, _) => Some(Self::ONE),\n            (x, _) if x.even() => None,\n            (Self(Small(x)), pow) if pow <= Limb::WIDTH => {\n                x.mod_power_of_2_inverse(pow).map(Self::from)\n            }\n            (Self(Small(x)), pow) => {\n                let len = bit_to_limb_count_ceiling(pow);\n                let mut xs = vec![0; len];\n                xs[0] = x;\n                mod_power_of_2_inverse_helper(&xs, pow)\n            }\n            (Self(Large(mut xs)), pow) => {\n                let len = bit_to_limb_count_ceiling(pow);\n                xs.resize(len, 0);\n                mod_power_of_2_inverse_helper(&xs, pow)\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2Inverse for &Natural {\n    type Output = Natural;\n\n    /// Computes the multiplicative inverse of a [`Natural`] modulo $2^k$. The input must be already\n    /// reduced modulo $2^k$. The [`Natural`] is taken by reference.\n    ///\n    /// Returns `None` if $x$ is even.\n    ///\n    /// $f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \\equiv 1 \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Inverse;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_power_of_2_inverse(8),\n    ///     Some(Natural::from(171u32))\n    /// );\n    /// assert_eq!((&Natural::from(4u32)).mod_power_of_2_inverse(8), None);\n    /// ```\n    fn mod_power_of_2_inverse(self, pow: u64) -> Option<Natural> {\n        assert_ne!(*self, 0u32);\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        match (self, pow) {\n            (&Natural::ONE, _) => Some(Natural::ONE),\n            (x, _) if x.even() => None,\n            (Natural(Small(x)), pow) if pow <= Limb::WIDTH => {\n                x.mod_power_of_2_inverse(pow).map(Natural::from)\n            }\n            (Natural(Small(x)), pow) => {\n                let mut xs = vec![0; bit_to_limb_count_ceiling(pow)];\n                xs[0] = *x;\n                mod_power_of_2_inverse_helper(&xs, pow)\n            }\n            (Natural(Large(xs)), pow) => {\n                let mut xs = xs.clone();\n                xs.resize(bit_to_limb_count_ceiling(pow), 0);\n                mod_power_of_2_inverse_helper(&xs, pow)\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::ModPowerOf2IsReduced;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nimpl ModPowerOf2IsReduced for Natural {\n    /// Returns whether a [`Natural`] is reduced modulo 2^k$; in other words, whether it has no more\n    /// than $k$ significant bits.\n    ///\n    /// $f(x, k) = (x < 2^k)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{ModPowerOf2IsReduced, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_power_of_2_is_reduced(5), true);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12).mod_power_of_2_is_reduced(39),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12).mod_power_of_2_is_reduced(40),\n    ///     true\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_is_reduced(&self, pow: u64) -> bool {\n        self.significant_bits() <= pow\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::mod_power_of_2::limbs_vec_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::mod_power_of_2_square::{\n    limbs_mod_power_of_2_square, limbs_mod_power_of_2_square_ref,\n};\nuse crate::natural::arithmetic::mul::limbs_mul;\nuse crate::natural::arithmetic::mul::mul_low::limbs_mul_low_same_length;\nuse crate::natural::{Natural, bit_to_limb_count_ceiling};\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Assign, ModPowerOf2Mul, ModPowerOf2MulAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::SignificantBits;\n\n// Interpreting two `Vec<Limb>`s as the limbs (in ascending order) of two `Natural`s, returns a\n// `Vec` of the limbs of the product of the `Natural`s mod `2 ^ pow`. Assumes the inputs are already\n// reduced mod `2 ^ pow`. The input `Vec`s may be mutated. Neither input may be empty or have\n// trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// # Panics\n// Panics if either input is empty. May panic if either input has trailing zeros.\npub_test! {limbs_mod_power_of_2_mul(xs: &mut Vec<Limb>, ys: &mut Vec<Limb>, pow: u64) -> Vec<Limb> {\n    if core::ptr::eq(xs.as_slice(), ys.as_slice()) {\n        return limbs_mod_power_of_2_square(xs, pow);\n    }\n    let xs_len = xs.len();\n    assert_ne!(xs_len, 0);\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    let max_len = bit_to_limb_count_ceiling(pow);\n    if max_len > xs_len + ys_len + 1 {\n        return limbs_mul(xs, ys);\n    }\n    // Should really be max_len / sqrt(2); 0.75 * max_len is close enough\n    let limit = max_len.checked_mul(3).unwrap() >> 2;\n    let mut product = if xs_len >= limit && ys_len >= limit {\n        if xs_len != max_len {\n            xs.resize(max_len, 0);\n        }\n        if ys_len != max_len {\n            ys.resize(max_len, 0);\n        }\n        let mut product_limbs = vec![0; max_len];\n        limbs_mul_low_same_length(&mut product_limbs, xs, ys);\n        product_limbs\n    } else {\n        limbs_mul(xs, ys)\n    };\n    limbs_vec_mod_power_of_2_in_place(&mut product, pow);\n    product\n}}\n\n// Interpreting a slice of `Limb` and a `Vec<Limb>` as the limbs (in ascending order) of two\n// `Natural`s, returns a `Vec` of the limbs of the product of the `Natural`s mod `2 ^ pow`. Assumes\n// the inputs are already reduced mod `2 ^ pow`. The input `Vec` may be mutated. Neither input may\n// be empty or have trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// # Panics\n// Panics if either input is empty. May panic if either input has trailing zeros.\npub_test! {limbs_mod_power_of_2_mul_val_ref(\n    xs: &mut Vec<Limb>,\n    ys: &[Limb],\n    pow: u64\n) -> Vec<Limb> {\n    if core::ptr::eq(xs.as_slice(), ys) {\n        return limbs_mod_power_of_2_square(xs, pow);\n    }\n    let xs_len = xs.len();\n    assert_ne!(xs_len, 0);\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    let max_len = bit_to_limb_count_ceiling(pow);\n    if max_len > xs_len + ys_len + 1 {\n        return limbs_mul(xs, ys);\n    }\n    // Should really be max_len / sqrt(2); 0.75 * max_len is close enough\n    let limit = max_len.checked_mul(3).unwrap() >> 2;\n    let mut product = if xs_len >= limit && ys_len >= limit {\n        if xs_len != max_len {\n            xs.resize(max_len, 0);\n        }\n        let mut ys_adjusted_vec;\n        let ys_adjusted = if ys_len == max_len {\n            ys\n        } else {\n            ys_adjusted_vec = vec![0; max_len];\n            ys_adjusted_vec[..ys_len].copy_from_slice(ys);\n            &ys_adjusted_vec\n        };\n        let mut product = vec![0; max_len];\n        limbs_mul_low_same_length(&mut product, xs, ys_adjusted);\n        product\n    } else {\n        limbs_mul(xs, ys)\n    };\n    limbs_vec_mod_power_of_2_in_place(&mut product, pow);\n    product\n}}\n\n// Interpreting two slices of `Limb` as the limbs (in ascending order) of two `Natural`s, returns a\n// `Vec` of the limbs of the product of the `Natural`s mod `2 ^ pow`. Assumes the inputs are already\n// reduced mod `2 ^ pow`. Neither input may be empty or have trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// # Panics\n// Panics if either input is empty. May panic if either input has trailing zeros.\npub_test! {limbs_mod_power_of_2_mul_ref_ref(xs: &[Limb], ys: &[Limb], pow: u64) -> Vec<Limb> {\n    if core::ptr::eq(xs, ys) {\n        return limbs_mod_power_of_2_square_ref(xs, pow);\n    }\n    let xs_len = xs.len();\n    assert_ne!(xs_len, 0);\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    let max_len = bit_to_limb_count_ceiling(pow);\n    if max_len > xs_len + ys_len + 1 {\n        return limbs_mul(xs, ys);\n    }\n    // Should really be max_len / sqrt(2); 0.75 * max_len is close enough\n    let limit = max_len.checked_mul(3).unwrap() >> 2;\n    let mut product = if xs_len >= limit && ys_len >= limit {\n        let mut xs_adjusted_vec;\n        let mut ys_adjusted_vec;\n        let xs_adjusted = if xs_len == max_len {\n            xs\n        } else {\n            xs_adjusted_vec = vec![0; max_len];\n            xs_adjusted_vec[..xs_len].copy_from_slice(xs);\n            &xs_adjusted_vec\n        };\n        let ys_adjusted = if ys_len == max_len {\n            ys\n        } else {\n            ys_adjusted_vec = vec![0; max_len];\n            ys_adjusted_vec[..ys_len].copy_from_slice(ys);\n            &ys_adjusted_vec\n        };\n        let mut product = vec![0; max_len];\n        limbs_mul_low_same_length(&mut product, xs_adjusted, ys_adjusted);\n        product\n    } else {\n        limbs_mul(xs, ys)\n    };\n    limbs_vec_mod_power_of_2_in_place(&mut product, pow);\n    product\n}}\n\nimpl Natural {\n    fn mod_power_of_2_mul_limb_ref(&self, y: Limb, pow: u64) -> Self {\n        match (self, y, pow) {\n            (_, 0, _) | (&Self::ZERO, _, _) => Self::ZERO,\n            (_, 1, _) => self.clone(),\n            (&Self::ONE, _, _) => Self(Small(y)),\n            (&Self(Small(small)), other, pow) if pow <= Limb::WIDTH => {\n                Self(Small(small.mod_power_of_2_mul(other, pow)))\n            }\n            (&Self(Small(small)), other, pow) => {\n                Self::from((DoubleLimb::from(small) * DoubleLimb::from(other)).mod_power_of_2(pow))\n            }\n            (x, other, pow) => (x * Self::from(other)).mod_power_of_2(pow),\n        }\n    }\n\n    fn mod_power_of_2_mul_limb_assign(&mut self, y: Limb, pow: u64) {\n        match (&mut *self, y, pow) {\n            (_, 1, _) | (&mut Self::ZERO, _, _) => {}\n            (_, 0, _) => *self = Self::ZERO,\n            (&mut Self::ONE, _, _) => *self = Self(Small(y)),\n            (&mut Self(Small(ref mut small)), other, pow) if pow <= Limb::WIDTH => {\n                small.mod_power_of_2_mul_assign(other, pow);\n            }\n            (&mut Self(Small(small)), other, pow) => {\n                *self = Self::from(\n                    (DoubleLimb::from(small) * DoubleLimb::from(other)).mod_power_of_2(pow),\n                );\n            }\n            (x, other, pow) => {\n                *x *= Self::from(other);\n                x.mod_power_of_2_assign(pow);\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2Mul<Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// Both [`Natural`]s are taken by value.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $xy \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Mul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_power_of_2_mul(Natural::from(2u32), 5),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_power_of_2_mul(Natural::from(14u32), 4),\n    ///     12\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_mul(mut self, other: Self, pow: u64) -> Self {\n        self.mod_power_of_2_mul_assign(other, pow);\n        self\n    }\n}\n\nimpl<'a> ModPowerOf2Mul<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// The first [`Natural`] is taken by value and the second by reference.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $xy \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Mul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_power_of_2_mul(&Natural::from(2u32), 5),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).mod_power_of_2_mul(&Natural::from(14u32), 4),\n    ///     12\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_mul(mut self, other: &'a Self, pow: u64) -> Self {\n        self.mod_power_of_2_mul_assign(other, pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Mul<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// The first [`Natural`] is taken by reference and the second by value.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $xy \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Mul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_power_of_2_mul(Natural::from(2u32), 5),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_power_of_2_mul(Natural::from(14u32), 4),\n    ///     12\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_mul(self, mut other: Natural, pow: u64) -> Natural {\n        other.mod_power_of_2_mul_assign(self, pow);\n        other\n    }\n}\n\nimpl ModPowerOf2Mul<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// Both [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $xy \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Mul;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_power_of_2_mul(&Natural::from(2u32), 5),\n    ///     6\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_power_of_2_mul(&Natural::from(14u32), 4),\n    ///     12\n    /// );\n    /// ```\n    fn mod_power_of_2_mul(self, other: &Natural, pow: u64) -> Natural {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (self, other) {\n            (x, &Natural(Small(y))) => x.mod_power_of_2_mul_limb_ref(y, pow),\n            (&Natural(Small(x)), y) => y.mod_power_of_2_mul_limb_ref(x, pow),\n            (&Natural(Large(ref xs)), &Natural(Large(ref ys))) => {\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_mul_ref_ref(xs, ys, pow))\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2MulAssign<Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo $2^k$, in place. The inputs must be already reduced\n    /// modulo $2^k$. The [`Natural`] on the right-hand side is taken by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2MulAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_power_of_2_mul_assign(Natural::from(2u32), 5);\n    /// assert_eq!(x, 6);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_power_of_2_mul_assign(Natural::from(14u32), 4);\n    /// assert_eq!(x, 12);\n    /// ```\n    fn mod_power_of_2_mul_assign(&mut self, mut other: Self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (&mut *self, &mut other) {\n            (x, &mut Self(Small(y))) => x.mod_power_of_2_mul_limb_assign(y, pow),\n            (&mut Self(Small(x)), y) => {\n                y.mod_power_of_2_mul_limb_assign(x, pow);\n                *self = other;\n            }\n            (&mut Self(Large(ref mut xs)), &mut Self(Large(ref mut ys))) => {\n                *xs = limbs_mod_power_of_2_mul(xs, ys, pow);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl<'a> ModPowerOf2MulAssign<&'a Self> for Natural {\n    /// Multiplies two [`Natural`]s modulo $2^k$, in place. The inputs must be already reduced\n    /// modulo $2^k$. The [`Natural`] on the right-hand side is taken by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < 2^k$ and $x + y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2MulAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_power_of_2_mul_assign(&Natural::from(2u32), 5);\n    /// assert_eq!(x, 6);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_power_of_2_mul_assign(&Natural::from(14u32), 4);\n    /// assert_eq!(x, 12);\n    /// ```\n    fn mod_power_of_2_mul_assign(&mut self, other: &'a Self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (&mut *self, other) {\n            (x, &Self(Small(y))) => x.mod_power_of_2_mul_limb_assign(y, pow),\n            (&mut Self(Small(x)), y) => {\n                *self = y.mod_power_of_2_mul_limb_ref(x, pow);\n            }\n            (&mut Self(Large(ref mut xs)), &Self(Large(ref ys))) => {\n                *xs = limbs_mod_power_of_2_mul_val_ref(xs, ys, pow);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2Neg, ModPowerOf2NegAssign, NegModPowerOf2, NegModPowerOf2Assign,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\n\nimpl ModPowerOf2Neg for Natural {\n    type Output = Self;\n\n    /// Negates a [`Natural`] modulo $2^k$. The input must be already reduced modulo $2^k$. The\n    /// [`Natural`] is taken by value.\n    ///\n    /// $f(x, k) = y$, where $x, y < 2^k$ and $-x \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Neg;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_power_of_2_neg(5), 0);\n    /// assert_eq!(Natural::ZERO.mod_power_of_2_neg(100), 0);\n    /// assert_eq!(Natural::from(100u32).mod_power_of_2_neg(8), 156);\n    /// assert_eq!(\n    ///     Natural::from(100u32).mod_power_of_2_neg(100).to_string(),\n    ///     \"1267650600228229401496703205276\"\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_neg(mut self, pow: u64) -> Self {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        self.neg_mod_power_of_2_assign(pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Neg for &Natural {\n    type Output = Natural;\n\n    /// Negates a [`Natural`] modulo $2^k$. The input must be already reduced modulo $2^k$. The\n    /// [`Natural`] is taken by reference.\n    ///\n    /// $f(x, k) = y$, where $x, y < 2^k$ and $-x \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Neg;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).mod_power_of_2_neg(5), 0);\n    /// assert_eq!((&Natural::ZERO).mod_power_of_2_neg(100), 0);\n    /// assert_eq!((&Natural::from(100u32)).mod_power_of_2_neg(8), 156);\n    /// assert_eq!(\n    ///     (&Natural::from(100u32)).mod_power_of_2_neg(100).to_string(),\n    ///     \"1267650600228229401496703205276\"\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_neg(self, pow: u64) -> Natural {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        self.neg_mod_power_of_2(pow)\n    }\n}\n\nimpl ModPowerOf2NegAssign for Natural {\n    /// Negates a [`Natural`] modulo $2^k$, in place. The input must be already reduced modulo\n    /// $2^k$.\n    ///\n    /// $x \\gets y$, where $x, y < 2^p$ and $-x \\equiv y \\mod 2^p$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2NegAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::ZERO;\n    /// n.mod_power_of_2_neg_assign(5);\n    /// assert_eq!(n, 0);\n    ///\n    /// let mut n = Natural::ZERO;\n    /// n.mod_power_of_2_neg_assign(100);\n    /// assert_eq!(n, 0);\n    ///\n    /// let mut n = Natural::from(100u32);\n    /// n.mod_power_of_2_neg_assign(8);\n    /// assert_eq!(n, 156);\n    ///\n    /// let mut n = Natural::from(100u32);\n    /// n.mod_power_of_2_neg_assign(100);\n    /// assert_eq!(n.to_string(), \"1267650600228229401496703205276\");\n    /// ```\n    #[inline]\n    fn mod_power_of_2_neg_assign(&mut self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        self.neg_mod_power_of_2_assign(pow);\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2007-2009, 2012, 2015, 2016, 2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::mod_pow::{get_bits, get_window_size};\nuse crate::natural::arithmetic::mod_power_of_2::limbs_vec_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::mod_power_of_2_square::limbs_square_low;\nuse crate::natural::arithmetic::mul::mul_low::limbs_mul_low_same_length;\nuse crate::natural::logic::bit_access::limbs_get_bit;\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::natural::{Natural, bit_to_limb_count_ceiling};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2Pow, ModPowerOf2PowAssign, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::{SignificantBits, TrailingZeros};\n\n// Raise an n-limb number to a power and return the lowest n limbs of the result.\n//\n// # Worst-case complexity\n// $T(n, m) = O(mn \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `es.len()`.\n//\n// This is equivalent to `mpn_powlo` from `mpn/generic/powlo.c`, GMP 6.2.1, where `rp == bp`.\n// Investigate changes from 6.1.2?\npub_crate_test! {limbs_pow_low(xs: &mut [Limb], es: &[Limb], scratch: &mut [Limb]) {\n    let xs_len = xs.len();\n    assert_ne!(xs_len, 0);\n    let scratch = &mut scratch[..xs_len];\n    let es_len = es.len();\n    assert_ne!(es_len, 0);\n    assert_ne!(es[es_len - 1], 0);\n    assert!(es_len > 1 || es_len == 1 && es[0] > 1);\n    let mut bit_index = limbs_significant_bits(es);\n    let window_size = get_window_size(bit_index);\n    assert!(window_size < bit_index);\n    let mut powers = vec![0; xs_len << (window_size - 1)];\n    let mut powers: Vec<&mut [Limb]> = powers.chunks_mut(xs_len).collect();\n    powers[0].copy_from_slice(xs);\n    // Store x ^ 2 in scratch.\n    limbs_square_low(scratch, xs);\n    // Precompute odd powers of x and put them in `powers`.\n    for i in 1..usize::power_of_2(window_size - 1) {\n        let (powers_lo, powers_hi) = powers.split_at_mut(i);\n        limbs_mul_low_same_length(powers_hi[0], powers_lo[i - 1], scratch);\n    }\n    let mut exp_bits = get_bits(es, bit_index, window_size);\n    let trailing_zeros = TrailingZeros::trailing_zeros(Limb::exact_from(exp_bits));\n    bit_index += trailing_zeros;\n    bit_index -= window_size;\n    xs.copy_from_slice(powers[exp_bits >> trailing_zeros >> 1]);\n    while bit_index != 0 {\n        while bit_index != 0 && !limbs_get_bit(es, bit_index - 1) {\n            limbs_square_low(scratch, xs);\n            xs.copy_from_slice(scratch);\n            bit_index -= 1;\n        }\n        if bit_index == 0 {\n            break;\n        }\n        // The next bit of the exponent is 1. Now extract the largest block of bits <= window_size,\n        // and such that the least significant bit is 1.\n        exp_bits = get_bits(es, bit_index, window_size);\n        let mut this_windowsize = window_size;\n        if bit_index < window_size {\n            this_windowsize -= window_size - bit_index;\n            bit_index = 0;\n        } else {\n            bit_index -= window_size;\n        }\n        let trailing_zeros = TrailingZeros::trailing_zeros(Limb::exact_from(exp_bits));\n        this_windowsize -= trailing_zeros;\n        bit_index += trailing_zeros;\n        while this_windowsize > 1 {\n            limbs_square_low(scratch, xs);\n            limbs_square_low(xs, scratch);\n            this_windowsize -= 2;\n        }\n        if this_windowsize == 1 {\n            limbs_square_low(scratch, xs);\n        } else {\n            scratch.copy_from_slice(xs);\n        }\n        limbs_mul_low_same_length(xs, scratch, powers[exp_bits >> trailing_zeros >> 1]);\n    }\n}}\n\n// Interpreting a `Vec<Limb>` and a `&[Limb]` as the limbs (in ascending order) of two `Natural`s,\n// writes the limbs of the first `Natural` raised to the second, mod $2^k$, to the input `Vec`.\n// Assumes the input is already reduced mod $2^k$. Neither input may be empty or have trailing\n// zeros, and the exponent must be greater than 1.\n//\n// # Worst-case complexity\n// $T(n, m) = O(mn \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `es.len()`.\n//\n// # Panics\n// Panics if the exponent has trailing zeros or is 1.\npub_test! {limbs_mod_power_of_2_pow(xs: &mut Vec<Limb>, es: &[Limb], pow: u64) {\n    let out_len = bit_to_limb_count_ceiling(pow);\n    xs.resize(out_len, 0);\n    let mut scratch = vec![0; out_len];\n    limbs_pow_low(xs, es, &mut scratch);\n    limbs_vec_mod_power_of_2_in_place(xs, pow);\n}}\n\nimpl ModPowerOf2Pow<Self> for Natural {\n    type Output = Self;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo $2^k$. The base must be already reduced\n    /// modulo $2^k$. Both [`Natural`]s are taken by value.\n    ///\n    /// $f(x, n, k) = y$, where $x, y < 2^k$ and $x^n \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `pow`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_power_of_2_pow(Natural::from(10u32), 8),\n    ///     169\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).mod_power_of_2_pow(Natural::from(1000u32), 30),\n    ///     289109473\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_pow(mut self, exp: Self, pow: u64) -> Self {\n        self.mod_power_of_2_pow_assign(exp, pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Pow<&Self> for Natural {\n    type Output = Self;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo $2^k$. The base must be already reduced\n    /// modulo $2^k$. The first [`Natural`] is taken by value and the second by reference.\n    ///\n    /// $f(x, n, k) = y$, where $x, y < 2^k$ and $x^n \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `pow`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).mod_power_of_2_pow(&Natural::from(10u32), 8),\n    ///     169\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(11u32).mod_power_of_2_pow(&Natural::from(1000u32), 30),\n    ///     289109473\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_pow(mut self, exp: &Self, pow: u64) -> Self {\n        self.mod_power_of_2_pow_assign(exp, pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Pow<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo $2^k$. The base must be already reduced\n    /// modulo $2^k$. The first [`Natural`] is taken by reference and the second by value.\n    ///\n    /// $f(x, n, k) = y$, where $x, y < 2^k$ and $x^n \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `pow`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_power_of_2_pow(Natural::from(10u32), 8),\n    ///     169\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).mod_power_of_2_pow(Natural::from(1000u32), 30),\n    ///     289109473\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_pow(self, exp: Natural, pow: u64) -> Natural {\n        self.mod_power_of_2_pow(&exp, pow)\n    }\n}\n\nimpl ModPowerOf2Pow<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Raises a [`Natural`] to a [`Natural`] power modulo $2^k$. The base must be already reduced\n    /// modulo $2^k$. Both [`Natural`]s are taken by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `pow`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).mod_power_of_2_pow(&Natural::from(10u32), 8),\n    ///     169\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(11u32)).mod_power_of_2_pow(&Natural::from(1000u32), 30),\n    ///     289109473\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_pow(self, exp: &Natural, pow: u64) -> Natural {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        match (self, exp) {\n            _ if pow == 0 => Natural::ZERO,\n            (_, &Natural::ZERO) => Natural::ONE,\n            (&Natural::ZERO | &Natural::ONE, _) | (_, &Natural::ONE) => self.clone(),\n            (Natural(Small(x)), Natural(Small(e)))\n                if pow <= Limb::WIDTH && u64::convertible_from(*e) =>\n            {\n                Natural(Small(x.mod_power_of_2_pow(u64::wrapping_from(*e), pow)))\n            }\n            (_, Natural(Small(e))) => {\n                let mut xs = self.to_limbs_asc();\n                limbs_mod_power_of_2_pow(&mut xs, &[*e], pow);\n                Natural::from_owned_limbs_asc(xs)\n            }\n            (_, Natural(Large(es))) => {\n                let mut xs = self.to_limbs_asc();\n                limbs_mod_power_of_2_pow(&mut xs, es, pow);\n                Natural::from_owned_limbs_asc(xs)\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2PowAssign<Self> for Natural {\n    /// Raises a [`Natural`] to a [`Natural`] power modulo $2^k$, in place. The base must be already\n    /// reduced modulo $2^k$. The [`Natural`] on the right-hand side is taken by value.\n    ///\n    /// $x \\gets y$, where $x, y < 2^k$ and $x^n \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `pow`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2PowAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_power_of_2_pow_assign(Natural::from(10u32), 8);\n    /// assert_eq!(x, 169);\n    ///\n    /// let mut x = Natural::from(11u32);\n    /// x.mod_power_of_2_pow_assign(Natural::from(1000u32), 30);\n    /// assert_eq!(x, 289109473);\n    /// ```\n    #[inline]\n    fn mod_power_of_2_pow_assign(&mut self, exp: Self, pow: u64) {\n        self.mod_power_of_2_pow_assign(&exp, pow);\n    }\n}\n\nimpl ModPowerOf2PowAssign<&Self> for Natural {\n    /// Raises a [`Natural`] to a [`Natural`] power modulo $2^k$, in place. The base must be already\n    /// reduced modulo $2^k$. The [`Natural`] on the right-hand side is taken by reference.\n    ///\n    /// $x \\gets y$, where $x, y < 2^k$ and $x^n \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(mn \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `pow`, and $m$ is\n    /// `exp.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2PowAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.mod_power_of_2_pow_assign(&Natural::from(10u32), 8);\n    /// assert_eq!(x, 169);\n    ///\n    /// let mut x = Natural::from(11u32);\n    /// x.mod_power_of_2_pow_assign(&Natural::from(1000u32), 30);\n    /// assert_eq!(x, 289109473);\n    /// ```\n    fn mod_power_of_2_pow_assign(&mut self, exp: &Self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        match (&mut *self, exp) {\n            _ if pow == 0 => *self = Self::ZERO,\n            (_, &Self::ZERO) => *self = Self::ONE,\n            (&mut (Self::ZERO | Self::ONE), _) | (_, &Self::ONE) => {}\n            (Self(Small(x)), Self(Small(e))) if pow <= Limb::WIDTH && u64::convertible_from(*e) => {\n                x.mod_power_of_2_pow_assign(u64::wrapping_from(*e), pow);\n            }\n            (_, Self(Small(e))) => {\n                let xs = self.promote_in_place();\n                limbs_mod_power_of_2_pow(xs, &[*e], pow);\n                self.trim();\n            }\n            (_, Self(Large(es))) => {\n                let xs = self.promote_in_place();\n                limbs_mod_power_of_2_pow(xs, es, pow);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::ops::{Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Assign, ModPowerOf2Shl, ModPowerOf2ShlAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nfn mod_power_of_2_shl_unsigned_nz<T: PrimitiveUnsigned>(x: &Natural, bits: T, pow: u64) -> Natural\nwhere\n    u64: ExactFrom<T>,\n{\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    let bits = u64::exact_from(bits);\n    if bits >= pow {\n        Natural::ZERO\n    } else {\n        x.mod_power_of_2(pow - bits) << bits\n    }\n}\n\nfn mod_power_of_2_shl_assign_unsigned_nz<T: PrimitiveUnsigned>(x: &mut Natural, bits: T, pow: u64)\nwhere\n    u64: ExactFrom<T>,\n{\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    let bits = u64::exact_from(bits);\n    if bits >= pow {\n        *x = Natural::ZERO;\n    } else {\n        x.mod_power_of_2_assign(pow - bits);\n        *x <<= bits;\n    }\n}\n\nmacro_rules! impl_mod_power_of_2_shl_unsigned {\n    ($t:ident) => {\n        impl ModPowerOf2Shl<$t> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo $2^k$. The\n            /// [`Natural`] must be already reduced modulo $2^k$. The [`Natural`] is taken by value.\n            ///\n            /// $f(x, n, k) = y$, where $x, y < 2^k$ and $2^nx \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl).\n            #[inline]\n            fn mod_power_of_2_shl(mut self, bits: $t, pow: u64) -> Natural {\n                self.mod_power_of_2_shl_assign(bits, pow);\n                self\n            }\n        }\n\n        impl ModPowerOf2Shl<$t> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo $2^k$. The\n            /// [`Natural`] must be already reduced modulo $2^k$. The [`Natural`] is taken by\n            /// reference.\n            ///\n            /// $f(x, n, k) = y$, where $x, y < 2^k$ and $2^nx \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl).\n            #[inline]\n            fn mod_power_of_2_shl(self, bits: $t, pow: u64) -> Natural {\n                mod_power_of_2_shl_unsigned_nz(self, bits, pow)\n            }\n        }\n\n        impl ModPowerOf2ShlAssign<$t> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo $2^k$, in place.\n            /// The [`Natural`] must be already reduced modulo $2^k$.\n            ///\n            /// $x \\gets y$, where $x, y < 2^k$ and $2^nx \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl_assign).\n            #[inline]\n            fn mod_power_of_2_shl_assign(&mut self, bits: $t, pow: u64) {\n                mod_power_of_2_shl_assign_unsigned_nz(self, bits, pow);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_power_of_2_shl_unsigned);\n\nfn mod_power_of_2_shl_signed_nz<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    pow: u64,\n) -> Natural\nwhere\n    &'a Natural: ModPowerOf2Shl<U, Output = Natural> + Shr<U, Output = Natural>,\n{\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    if bits >= S::ZERO {\n        x.mod_power_of_2_shl(bits.unsigned_abs(), pow)\n    } else {\n        x >> bits.unsigned_abs()\n    }\n}\n\nfn mod_power_of_2_shl_assign_signed_nz<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    pow: u64,\n) where\n    Natural: ModPowerOf2ShlAssign<U> + ShrAssign<U>,\n{\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    if bits >= S::ZERO {\n        x.mod_power_of_2_shl_assign(bits.unsigned_abs(), pow);\n    } else {\n        *x >>= bits.unsigned_abs();\n    }\n}\n\nmacro_rules! impl_mod_power_of_2_shl_signed {\n    ($t:ident) => {\n        impl ModPowerOf2Shl<$t> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo $2^k$. The\n            /// [`Natural`] must be already reduced modulo $2^k$. The [`Natural`] is taken by value.\n            ///\n            /// $f(x, n, k) = y$, where $x, y < 2^k$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl).\n            #[inline]\n            fn mod_power_of_2_shl(mut self, bits: $t, pow: u64) -> Natural {\n                self.mod_power_of_2_shl_assign(bits, pow);\n                self\n            }\n        }\n\n        impl ModPowerOf2Shl<$t> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo $2^k$. The\n            /// [`Natural`] must be already reduced modulo $2^k$. The [`Natural`] is taken by\n            /// reference.\n            ///\n            /// $f(x, n, k) = y$, where $x, y < 2^k$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl).\n            #[inline]\n            fn mod_power_of_2_shl(self, bits: $t, pow: u64) -> Natural {\n                mod_power_of_2_shl_signed_nz(self, bits, pow)\n            }\n        }\n\n        impl ModPowerOf2ShlAssign<$t> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo $2^k$, in place.\n            /// The [`Natural`] must be already reduced modulo $2^k$.\n            ///\n            /// $x \\gets y$, where $x, y < 2^k$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shl#mod_power_of_2_shl_assign).\n            #[inline]\n            fn mod_power_of_2_shl_assign(&mut self, bits: $t, pow: u64) {\n                mod_power_of_2_shl_assign_signed_nz(self, bits, pow)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_mod_power_of_2_shl_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::ops::{Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2Shl, ModPowerOf2ShlAssign, ModPowerOf2Shr, ModPowerOf2ShrAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nfn mod_power_of_2_shr_ref<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    pow: u64,\n) -> Natural\nwhere\n    &'a Natural: ModPowerOf2Shl<U, Output = Natural> + Shr<U, Output = Natural>,\n{\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    if bits >= S::ZERO {\n        x >> bits.unsigned_abs()\n    } else {\n        x.mod_power_of_2_shl(bits.unsigned_abs(), pow)\n    }\n}\n\nfn mod_power_of_2_shr_assign<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    pow: u64,\n) where\n    Natural: ModPowerOf2ShlAssign<U> + ShrAssign<U>,\n{\n    assert!(\n        x.significant_bits() <= pow,\n        \"x must be reduced mod 2^pow, but {x} >= 2^{pow}\"\n    );\n    if bits >= S::ZERO {\n        *x >>= bits.unsigned_abs();\n    } else {\n        x.mod_power_of_2_shl_assign(bits.unsigned_abs(), pow);\n    }\n}\n\nmacro_rules! impl_mod_power_of_2_shr_signed {\n    ($t:ident) => {\n        impl ModPowerOf2Shr<$t> for Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo $2^k$. The\n            /// [`Natural`] must be already reduced modulo $2^k$. The [`Natural`] is taken by value.\n            ///\n            /// $f(x, n, k) = y$, where $x, y < 2^k$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod\n            /// 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shr#mod_power_of_2_shr).\n            #[inline]\n            fn mod_power_of_2_shr(mut self, bits: $t, pow: u64) -> Natural {\n                self.mod_power_of_2_shr_assign(bits, pow);\n                self\n            }\n        }\n\n        impl ModPowerOf2Shr<$t> for &Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo $2^k$. The\n            /// [`Natural`] must be already reduced modulo $2^k$. The [`Natural`] is taken by\n            /// reference.\n            ///\n            /// $f(x, n, k) = y$, where $x, y < 2^k$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod\n            /// 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shr#mod_power_of_2_shr).\n            #[inline]\n            fn mod_power_of_2_shr(self, bits: $t, pow: u64) -> Natural {\n                mod_power_of_2_shr_ref(self, bits, pow)\n            }\n        }\n\n        impl ModPowerOf2ShrAssign<$t> for Natural {\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo $2^k$, in place. The\n            /// [`Natural`] must be already reduced modulo $2^k$.\n            ///\n            /// $x \\gets y$, where $x, y < 2^k$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod 2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::mod_power_of_2_shr#mod_power_of_2_shr_assign).\n            #[inline]\n            fn mod_power_of_2_shr_assign(&mut self, bits: $t, pow: u64) {\n                mod_power_of_2_shr_assign(self, bits, pow);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_mod_power_of_2_shr_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-1994, 1996, 1997, 2000-2005, 2008, 2009, 2010, 2011, 2012, 2015 Free\n//      Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_slice_add_same_length_in_place_left;\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::mod_power_of_2::limbs_vec_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::mul::limbs_mul_greater_to_out_basecase;\nuse crate::natural::arithmetic::mul::mul_low::{\n    limbs_mul_low_same_length, limbs_mul_low_same_length_basecase,\n};\nuse crate::natural::arithmetic::mul::toom::{TUNE_PROGRAM_BUILD, WANT_FAT_BINARY};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::natural::arithmetic::square::{\n    limbs_square, limbs_square_diagonal, limbs_square_to_out, limbs_square_to_out_basecase,\n    limbs_square_to_out_scratch_len,\n};\nuse crate::natural::{Natural, bit_to_limb_count_ceiling};\nuse crate::platform::{\n    DoubleLimb, Limb, MULLO_BASECASE_THRESHOLD, MULLO_DC_THRESHOLD, SQR_TOOM2_THRESHOLD,\n    SQR_TOOM3_THRESHOLD, SQR_TOOM4_THRESHOLD, SQR_TOOM8_THRESHOLD, SQRLO_DC_THRESHOLD,\n};\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2Square, ModPowerOf2SquareAssign, Parity, Square, WrappingSquare,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::SplitInHalf;\nuse malachite_base::num::logic::traits::SignificantBits;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `MPN_SQRLO_DIAGONAL` from `mpn/generic/sqrlo_basecase.c`, GMP 6.2.1.\nfn limbs_square_low_diagonal(out: &mut [Limb], xs: &[Limb]) {\n    let n = xs.len();\n    let half_n = n >> 1;\n    limbs_square_diagonal(out, &xs[..half_n]);\n    if n.odd() {\n        out[n - 1] = xs[half_n].wrapping_square();\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `MPN_SQRLO_DIAG_ADDLSH1` from `mpn/generic/sqrlo_basecase.c`, GMP 6.2.1.\npub_test! {limbs_square_diagonal_shl_add(out: &mut [Limb], scratch: &mut [Limb], xs: &[Limb]) {\n    let n = xs.len();\n    assert_eq!(scratch.len(), n - 1);\n    assert_eq!(out.len(), n);\n    limbs_square_low_diagonal(out, xs);\n    limbs_slice_shl_in_place(scratch, 1);\n    limbs_slice_add_same_length_in_place_left(&mut out[1..], scratch);\n}}\n\n// TODO tune\n#[cfg(feature = \"test_build\")]\npub const SQRLO_DC_THRESHOLD_LIMIT: usize = 500;\n\n#[cfg(not(feature = \"test_build\"))]\nconst SQRLO_DC_THRESHOLD_LIMIT: usize = 500;\n\n// TODO tune\nconst SQRLO_BASECASE_ALLOC: usize = if SQRLO_DC_THRESHOLD_LIMIT < 2 {\n    1\n} else {\n    SQRLO_DC_THRESHOLD_LIMIT - 1\n};\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_sqrlo_basecase` from `mpn/generic/sqrlo_basecase.c`, GMP 6.2.1.\npub_test! {limbs_square_low_basecase(out: &mut [Limb], xs: &[Limb]) {\n    let n = xs.len();\n    let out = &mut out[..n];\n    assert_ne!(n, 0);\n    let xs_0 = xs[0];\n    match n {\n        1 => out[0] = xs_0.wrapping_square(),\n        2 => {\n            let p_hi;\n            (p_hi, out[0]) = DoubleLimb::from(xs_0).square().split_in_half();\n            out[1] = (xs_0.wrapping_mul(xs[1]) << 1).wrapping_add(p_hi);\n        }\n        _ => {\n            let scratch = &mut [0; SQRLO_BASECASE_ALLOC];\n            // must fit n - 1 limbs in scratch\n            assert!(n <= SQRLO_DC_THRESHOLD_LIMIT);\n            let scratch = &mut scratch[..n - 1];\n            limbs_mul_limb_to_out::<DoubleLimb, Limb>(scratch, &xs[1..], xs_0);\n            for i in 1.. {\n                let two_i = i << 1;\n                if two_i >= n - 1 {\n                    break;\n                }\n                limbs_slice_add_mul_limb_same_length_in_place_left(\n                    &mut scratch[two_i..],\n                    &xs[i + 1..n - i],\n                    xs[i],\n                );\n            }\n            limbs_square_diagonal_shl_add(out, scratch, xs);\n        }\n    }\n}}\n\n// TODO tune\nconst SQRLO_BASECASE_THRESHOLD: usize = 8;\n\n// TODO tune\n/// This is equivalent to `MAYBE_range_basecase` from `mpn/generic/sqrlo.c`, GMP 6.2.1. Investigate\n/// changes from 6.1.2?\nconst MAYBE_RANGE_BASECASE_MOD_SQUARE: bool = TUNE_PROGRAM_BUILD\n    || WANT_FAT_BINARY\n    || (if SQRLO_DC_THRESHOLD == 0 {\n        SQRLO_BASECASE_THRESHOLD\n    } else {\n        SQRLO_DC_THRESHOLD\n    }) < SQR_TOOM2_THRESHOLD * 36 / (36 - 11);\n\n// TODO tune\n/// This is equivalent to `MAYBE_range_toom22` from `mpn/generic/sqrlo.c`, GMP 6.2.1. Investigate\n/// changes from 6.1.2?\nconst MAYBE_RANGE_TOOM22_MOD_SQUARE: bool = TUNE_PROGRAM_BUILD\n    || WANT_FAT_BINARY\n    || (if SQRLO_DC_THRESHOLD == 0 {\n        SQRLO_BASECASE_THRESHOLD\n    } else {\n        SQRLO_DC_THRESHOLD\n    }) < SQR_TOOM3_THRESHOLD * 36 / (36 - 11);\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_sqrlo_itch` from `mpn/generic/sqrlo.c`, GMP 6.2.1. Investigate changes\n// from 6.1.2?\npub_const_test! {limbs_square_low_scratch_len(len: usize) -> usize {\n    len << 1\n}}\n\n// Requires a scratch space of 2 * `xs.len()` limbs at `scratch`.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_dc_sqrlo` from `mpn/generic/sqrlo.c`, GMP 6.2.1. Investigate changes\n// from 6.1.2?\npub_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_square_low_divide_and_conquer(\n    out: &mut [Limb],\n    xs: &[Limb],\n    scratch: &mut [Limb]\n) {\n    let len = xs.len();\n    let out = &mut out[..len];\n    assert!(len > 1);\n    // We need a fractional approximation of the value 0 < a <= 1/2, giving the minimum in the\n    // function k = (1 - a) ^ e / (1 - 2 * a ^ e).\n    let len_small = if MAYBE_RANGE_BASECASE_MOD_SQUARE && len < SQR_TOOM2_THRESHOLD * 36 / (36 - 11)\n    {\n        len >> 1\n    } else if MAYBE_RANGE_TOOM22_MOD_SQUARE && len < SQR_TOOM3_THRESHOLD * 36 / (36 - 11) {\n        len * 11 / 36 // n1 ~= n*(1-.694...)\n    } else if len < SQR_TOOM4_THRESHOLD * 40 / (40 - 9) {\n        len * 9 / 40 // n1 ~= n*(1-.775...)\n    } else if len < SQR_TOOM8_THRESHOLD * 10 / 9 {\n        len * 7 / 39 // n1 ~= n*(1-.821...)\n    } else {\n        len / 10 // n1 ~= n*(1-.899...) [TOOM88]\n    };\n    let len_big = len - len_small;\n    // x0 ^ 2\n    let (xs_lo, xs_hi) = xs.split_at(len_big);\n    let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(xs_lo.len())];\n    limbs_square_to_out(scratch, xs_lo, &mut square_scratch);\n    let xs_lo = &xs_lo[..len_small];\n    let (out_lo, out_hi) = out.split_at_mut(len_big);\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(len);\n    out_lo.copy_from_slice(&scratch_lo[..len_big]);\n    // x1 * x0 * 2^(n2 Limb::WIDTH)\n    if len_small < MULLO_BASECASE_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(scratch_hi, xs_hi, xs_lo);\n    } else if len_small < MULLO_DC_THRESHOLD {\n        limbs_mul_low_same_length_basecase(scratch_hi, xs_hi, xs_lo);\n    } else {\n        limbs_mul_low_same_length(scratch_hi, xs_hi, xs_lo);\n    }\n    limbs_shl_to_out(out_hi, &scratch_hi[..len_small], 1);\n    limbs_slice_add_same_length_in_place_left(out_hi, &scratch_lo[len_big..]);\n}}\n\n// TODO tune\n\n// must be at least SQRLO_BASECASE_THRESHOLD\nconst SQRLO_BASECASE_THRESHOLD_LIMIT: usize = 8;\n\n// TODO tune\nconst SQRLO_SQR_THRESHOLD: usize = 6440;\n\n// TODO tune\nconst SQR_BASECASE_ALLOC: usize = if SQRLO_BASECASE_THRESHOLD_LIMIT == 0 {\n    1\n} else {\n    SQRLO_BASECASE_THRESHOLD_LIMIT << 1\n};\n\n// Square an n-limb number and return the lowest n limbs of the result.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_sqrlo` from `mpn/generic/sqrlo.c`, GMP 6.2.1. Investigate changes from\n// 6.1.2?\npub_crate_test! {limbs_square_low(out: &mut [Limb], xs: &[Limb]) {\n    assert!(SQRLO_BASECASE_THRESHOLD_LIMIT >= SQRLO_BASECASE_THRESHOLD);\n    let len = xs.len();\n    assert_ne!(len, 0);\n    let out = &mut out[..len];\n    if len < SQRLO_BASECASE_THRESHOLD {\n        // Allocate workspace of fixed size on stack: fast!\n        let scratch = &mut [0; SQR_BASECASE_ALLOC];\n        limbs_square_to_out_basecase(scratch, xs);\n        out.copy_from_slice(&scratch[..len]);\n    } else if len < SQRLO_DC_THRESHOLD {\n        limbs_square_low_basecase(out, xs);\n    } else {\n        let mut scratch = vec![0; limbs_square_low_scratch_len(len)];\n        if len < SQRLO_SQR_THRESHOLD {\n            limbs_square_low_divide_and_conquer(out, xs, &mut scratch);\n        } else {\n            // For really large operands, use plain mpn_mul_n but throw away upper n limbs of the\n            // result.\n            let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(xs.len())];\n            limbs_square_to_out(&mut scratch, xs, &mut square_scratch);\n            out.copy_from_slice(&scratch[..len]);\n        }\n    }\n}}\n\n// Interpreting a `Vec<Limb>` as the limbs (in ascending order) of a `Natural`, returns a `Vec` of\n// the limbs of the square of the `Natural` mod `2 ^ pow`. Assumes the input is already reduced mod\n// `2 ^ pow`. The input `Vec` may be mutated. The input may not be empty or have trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// # Panics\n// Panics if the input is empty. May panic if the input has trailing zeros.\npub_crate_test! {limbs_mod_power_of_2_square(xs: &mut Vec<Limb>, pow: u64) -> Vec<Limb> {\n    let len = xs.len();\n    assert_ne!(len, 0);\n    let max_len = bit_to_limb_count_ceiling(pow);\n    if max_len > len << 1 {\n        return limbs_square(xs);\n    }\n    // Should really be max_len / sqrt(2); 0.75 * max_len is close enough\n    let limit = max_len.checked_mul(3).unwrap() >> 2;\n    let mut square = if len >= limit {\n        if len != max_len {\n            xs.resize(max_len, 0);\n        }\n        let mut square_limbs = vec![0; max_len];\n        limbs_square_low(&mut square_limbs, xs);\n        square_limbs\n    } else {\n        limbs_square(xs)\n    };\n    limbs_vec_mod_power_of_2_in_place(&mut square, pow);\n    square\n}}\n\n// Interpreting a slice of `Limb` as the limbs (in ascending order) of a `Natural`, returns a `Vec`\n// of the limbs of the square of the `Natural` mod `2 ^ pow`. Assumes the input is already reduced\n// mod `2 ^ pow`. The input may not be empty or have trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// # Panics\n// Panics if the input is empty. May panic if the input has trailing zeros.\npub_crate_test! {limbs_mod_power_of_2_square_ref(xs: &[Limb], pow: u64) -> Vec<Limb> {\n    let len = xs.len();\n    assert_ne!(len, 0);\n    let max_len = bit_to_limb_count_ceiling(pow);\n    if max_len > len << 1 {\n        return limbs_square(xs);\n    }\n    // Should really be max_len / sqrt(2); 0.75 * max_len is close enough\n    let limit = max_len.checked_mul(3).unwrap() >> 2;\n    let mut square = if len >= limit {\n        let mut xs_adjusted_vec;\n        let xs_adjusted = if len == max_len {\n            xs\n        } else {\n            xs_adjusted_vec = vec![0; max_len];\n            xs_adjusted_vec[..len].copy_from_slice(xs);\n            &xs_adjusted_vec\n        };\n        let mut square = vec![0; max_len];\n        limbs_square_low(&mut square, xs_adjusted);\n        square\n    } else {\n        limbs_square(xs)\n    };\n    limbs_vec_mod_power_of_2_in_place(&mut square, pow);\n    square\n}}\n\nimpl ModPowerOf2Square for Natural {\n    type Output = Self;\n\n    /// Squares a [`Natural`] modulo $2^k$. The input must be already reduced modulo $2^k$. The\n    /// [`Natural`] is taken by value.\n    ///\n    /// $f(x, k) = y$, where $x, y < 2^k$ and $x^2 \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.mod_power_of_2_square(2), 0);\n    /// assert_eq!(Natural::from(5u32).mod_power_of_2_square(3), 1);\n    /// assert_eq!(\n    ///     Natural::from_str(\"12345678987654321\")\n    ///         .unwrap()\n    ///         .mod_power_of_2_square(64)\n    ///         .to_string(),\n    ///     \"16556040056090124897\"\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_square(mut self, pow: u64) -> Self {\n        self.mod_power_of_2_square_assign(pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Square for &Natural {\n    type Output = Natural;\n\n    /// Squares a [`Natural`] modulo $2^k$. The input must be already reduced modulo $2^k$. The\n    /// [`Natural`] is taken by reference.\n    ///\n    /// $f(x, k) = y$, where $x, y < 2^k$ and $x^2 \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).mod_power_of_2_square(2), 0);\n    /// assert_eq!((&Natural::from(5u32)).mod_power_of_2_square(3), 1);\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"12345678987654321\").unwrap())\n    ///         .mod_power_of_2_square(64)\n    ///         .to_string(),\n    ///     \"16556040056090124897\"\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_square(self, pow: u64) -> Natural {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        match self {\n            &Natural::ZERO => Natural::ZERO,\n            Natural(Small(x)) if pow <= Limb::WIDTH => Natural(Small(x.mod_power_of_2_square(pow))),\n            Natural(Small(x)) => {\n                let x_double = DoubleLimb::from(*x);\n                Natural::from(if pow <= Limb::WIDTH << 1 {\n                    x_double.mod_power_of_2_square(pow)\n                } else {\n                    x_double.square()\n                })\n            }\n            Natural(Large(xs)) => {\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_square_ref(xs, pow))\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2SquareAssign for Natural {\n    /// Squares a [`Natural`] modulo $2^k$, in place. The input must be already reduced modulo\n    /// $2^k$.\n    ///\n    /// $x \\gets y$, where $x, y < 2^k$ and $x^2 \\equiv y \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2SquareAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::ZERO;\n    /// n.mod_power_of_2_square_assign(2);\n    /// assert_eq!(n, 0);\n    ///\n    /// let mut n = Natural::from(5u32);\n    /// n.mod_power_of_2_square_assign(3);\n    /// assert_eq!(n, 1);\n    ///\n    /// let mut n = Natural::from_str(\"12345678987654321\").unwrap();\n    /// n.mod_power_of_2_square_assign(64);\n    /// assert_eq!(n.to_string(), \"16556040056090124897\");\n    /// ```\n    #[inline]\n    fn mod_power_of_2_square_assign(&mut self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        match self {\n            &mut Self::ZERO => {}\n            Self(Small(x)) if pow <= Limb::WIDTH => x.mod_power_of_2_square_assign(pow),\n            Self(Small(x)) => {\n                let x_double = DoubleLimb::from(*x);\n                *self = Self::from(if pow <= Limb::WIDTH << 1 {\n                    x_double.mod_power_of_2_square(pow)\n                } else {\n                    x_double.square()\n                });\n            }\n            Self(Large(xs)) => {\n                *xs = limbs_mod_power_of_2_square(xs, pow);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_power_of_2_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::conversion::to_twos_complement_limbs::limbs_twos_complement_in_place;\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::mod_power_of_2::{\n    limbs_neg_mod_power_of_2, limbs_neg_mod_power_of_2_in_place,\n    limbs_slice_mod_power_of_2_in_place,\n};\nuse crate::natural::arithmetic::mod_power_of_2_add::limbs_vec_mod_power_of_2_add_limb_in_place;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_limb, limbs_sub_limb_in_place,\n    limbs_sub_same_length_in_place_right, limbs_vec_sub_in_place_right,\n};\nuse crate::natural::logic::low_mask::limbs_low_mask;\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::natural::{Natural, bit_to_limb_count_ceiling};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2Neg, ModPowerOf2NegAssign, ModPowerOf2Sub, ModPowerOf2SubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::SignificantBits;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\nfn extend_with_ones(xs: &mut Vec<Limb>, pow: u64) {\n    xs.resize(bit_to_limb_count_ceiling(pow), Limb::MAX);\n}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, subtracts the\n// `Natural` from a `Limb`, mod `2 ^ pow`. Assumes the input is already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// # Panics\n// Panics if `pow` is zero.\npub_test! {limbs_mod_power_of_2_limb_sub_limbs(x: Limb, ys: &[Limb], pow: u64) -> Vec<Limb> {\n    let mut diff = limbs_neg_mod_power_of_2(ys, pow);\n    limbs_vec_mod_power_of_2_add_limb_in_place(&mut diff, x, pow);\n    diff\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, subtracts the\n// `Natural` from a `Limb`, mod `2 ^ pow`, and writes the limbs of the difference to the input\n// slice. Assumes the input is already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n//\n// # Panics\n// Panics if `pow` is zero.\npub_test! {limbs_mod_power_of_2_limb_sub_limbs_in_place(x: Limb, ys: &mut Vec<Limb>, pow: u64) {\n    limbs_neg_mod_power_of_2_in_place(ys, pow);\n    limbs_vec_mod_power_of_2_add_limb_in_place(ys, x, pow);\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, subtracts\n// the second `Natural` from the first, mod `2 ^ pow`, and returns a `Vec` of the limbs of the\n// difference. Assumes the inputs are already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\npub_test! {limbs_mod_power_of_2_sub(xs: &[Limb], ys: &[Limb], pow: u64) -> Vec<Limb> {\n    let ys_len = ys.len();\n    let mut out_limbs = xs.to_vec();\n    if ys_len > xs.len() {\n        out_limbs.resize(ys_len, 0);\n    }\n    if limbs_sub_greater_in_place_left(&mut out_limbs, ys) {\n        extend_with_ones(&mut out_limbs, pow);\n        limbs_slice_mod_power_of_2_in_place(&mut out_limbs, pow);\n    }\n    out_limbs\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, subtracts\n// the second `Natural` from the first, mod `2 ^ pow`, and writes the limbs of the difference to the\n// first (left) slice. Assumes the inputs are already reduced mod `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\npub_test! {limbs_mod_power_of_2_sub_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb], pow: u64) {\n    let ys_len = ys.len();\n    if ys_len > xs.len() {\n        xs.resize(ys_len, 0);\n    }\n    if limbs_sub_greater_in_place_left(xs, ys) {\n        extend_with_ones(xs, pow);\n        limbs_slice_mod_power_of_2_in_place(xs, pow);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, subtracts\n// the second `Natural` from the first, mod `2 ^ pow`, and writes the limbs of the difference to the\n// second (right) slice. Assumes the inputs are already reduced mod `2 ^ pow`.\n//\n// Neither input slice may have trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\npub_test! {limbs_mod_power_of_2_sub_in_place_right(xs: &[Limb], ys: &mut Vec<Limb>, pow: u64) {\n    let xs_len = xs.len();\n    if xs_len >= ys.len() {\n        if limbs_vec_sub_in_place_right(xs, ys) {\n            extend_with_ones(ys, pow);\n            limbs_slice_mod_power_of_2_in_place(ys, pow);\n        }\n    } else {\n        let (ys_lo, ys_hi) = ys.split_at_mut(xs_len);\n        if limbs_sub_same_length_in_place_right(xs, ys_lo) {\n            limbs_not_in_place(ys_hi);\n        } else {\n            limbs_twos_complement_in_place(ys_hi);\n        }\n        extend_with_ones(ys, pow);\n        limbs_slice_mod_power_of_2_in_place(ys, pow);\n    }\n}}\n\n// Interpreting two `Vec`s of `Limb`s as the limbs (in ascending order) of two `Natural`s, subtracts\n// the second `Natural` from the first, mod `2 ^ pow`, and writes the limbs of the difference to to\n// the longer slice (or the first one, if they are equally long). Returns a `bool` which is `false`\n// when the output is to the first `Vec` and `true` when it's to the second `Vec`. Assumes the\n// inputs are already reduced mod `2 ^ pow`.\n//\n// Neither input slice may have trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\npub_test! {limbs_mod_power_of_2_sub_in_place_either(\n    xs: &mut Vec<Limb>,\n    ys: &mut Vec<Limb>,\n    pow: u64,\n) -> bool {\n    if xs.len() >= ys.len() {\n        limbs_mod_power_of_2_sub_in_place_left(xs, ys, pow);\n        false\n    } else {\n        limbs_mod_power_of_2_sub_in_place_right(xs, ys, pow);\n        true\n    }\n}}\n\nimpl Natural {\n    fn mod_power_of_2_sub_limb_ref(&self, y: Limb, pow: u64) -> Self {\n        match (self, y, pow) {\n            (x, 0, _) => x.clone(),\n            (&Self::ZERO, _, _) => Self(Small(y)).mod_power_of_2_neg(pow),\n            (&Self(Small(small)), other, pow) if pow <= Limb::WIDTH => {\n                Self(Small(small.mod_power_of_2_sub(other, pow)))\n            }\n            (&Self(Small(small)), other, _) => {\n                let (diff, overflow) = small.overflowing_sub(other);\n                if overflow {\n                    let mut out = limbs_low_mask(pow);\n                    out[0] = diff;\n                    Self(Large(out))\n                } else {\n                    Self(Small(diff))\n                }\n            }\n            (Self(Large(limbs)), other, _) => {\n                Self::from_owned_limbs_asc(limbs_sub_limb(limbs, other).0)\n            }\n        }\n    }\n\n    // other - self\n    fn mod_power_of_2_right_sub_limb_ref(&self, y: Limb, pow: u64) -> Self {\n        match (self, y, pow) {\n            (_, 0, _) => self.mod_power_of_2_neg(pow),\n            (&Self::ZERO, _, _) => Self(Small(y)),\n            (&Self(Small(small)), other, pow) if pow <= Limb::WIDTH => {\n                Self(Small(other.mod_power_of_2_sub(small, pow)))\n            }\n            (&Self(Small(small)), other, _) => {\n                let (diff, overflow) = other.overflowing_sub(small);\n                if overflow {\n                    let mut out = limbs_low_mask(pow);\n                    out[0] = diff;\n                    Self(Large(out))\n                } else {\n                    Self(Small(diff))\n                }\n            }\n            (Self(Large(limbs)), other, _) => {\n                Self::from_owned_limbs_asc(limbs_mod_power_of_2_limb_sub_limbs(other, limbs, pow))\n            }\n        }\n    }\n\n    fn mod_power_of_2_sub_assign_limb(&mut self, y: Limb, pow: u64) {\n        match (&mut *self, y, pow) {\n            (_, 0, _) => {}\n            (&mut Self::ZERO, _, _) => *self = Self(Small(y)).mod_power_of_2_neg(pow),\n            (Self(Small(small)), other, pow) if pow <= Limb::WIDTH => {\n                small.mod_power_of_2_sub_assign(other, pow);\n            }\n            (Self(Small(small)), other, _) => {\n                let (diff, overflow) = small.overflowing_sub(other);\n                if overflow {\n                    let mut out = limbs_low_mask(pow);\n                    out[0] = diff;\n                    *self = Self(Large(out));\n                } else {\n                    *small = diff;\n                }\n            }\n            (Self(Large(limbs)), other, _) => {\n                limbs_sub_limb_in_place(limbs, other);\n                self.trim();\n            }\n        }\n    }\n\n    // other -= self\n    fn mod_power_of_2_right_sub_assign_limb(&mut self, other: Limb, pow: u64) {\n        match (&mut *self, other, pow) {\n            (_, 0, _) => self.mod_power_of_2_neg_assign(pow),\n            (&mut Self::ZERO, _, _) => *self = Self(Small(other)),\n            (Self(Small(small)), other, pow) if pow <= Limb::WIDTH => {\n                *small = other.mod_power_of_2_sub(*small, pow);\n            }\n            (Self(Small(small)), other, _) => {\n                let (diff, overflow) = other.overflowing_sub(*small);\n                if overflow {\n                    let mut out = limbs_low_mask(pow);\n                    out[0] = diff;\n                    *self = Self(Large(out));\n                } else {\n                    *small = diff;\n                }\n            }\n            (Self(Large(limbs)), other, _) => {\n                limbs_mod_power_of_2_limb_sub_limbs_in_place(other, limbs, pow);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2Sub<Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// Both [`Natural`]s are taken by value.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Sub;\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(10u32).mod_power_of_2_sub(Natural::TWO, 4), 8);\n    /// assert_eq!(\n    ///     Natural::from(56u32).mod_power_of_2_sub(Natural::from(123u32), 9),\n    ///     445\n    /// );\n    /// ```\n    fn mod_power_of_2_sub(mut self, other: Self, pow: u64) -> Self {\n        self.mod_power_of_2_sub_assign(other, pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Sub<&Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// The first [`Natural`] is taken by value and the second by reference.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Sub;\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(10u32).mod_power_of_2_sub(&Natural::TWO, 4), 8);\n    /// assert_eq!(\n    ///     Natural::from(56u32).mod_power_of_2_sub(&Natural::from(123u32), 9),\n    ///     445\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_sub(mut self, other: &Self, pow: u64) -> Self {\n        self.mod_power_of_2_sub_assign(other, pow);\n        self\n    }\n}\n\nimpl ModPowerOf2Sub<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts two [`Natural`]s modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// The first [`Natural`] is taken by reference and the second by value.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Sub;\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_power_of_2_sub(Natural::TWO, 4),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(56u32)).mod_power_of_2_sub(Natural::from(123u32), 9),\n    ///     445\n    /// );\n    /// ```\n    #[inline]\n    fn mod_power_of_2_sub(self, mut other: Natural, pow: u64) -> Natural {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (self, &mut other) {\n            (x, Natural(Small(y))) => x.mod_power_of_2_sub_limb_ref(*y, pow),\n            (&Natural(Small(x)), y) => {\n                y.mod_power_of_2_right_sub_assign_limb(x, pow);\n                other\n            }\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                limbs_mod_power_of_2_sub_in_place_right(xs, ys, pow);\n                other.trim();\n                other\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2Sub<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts two [`Natural`] modulo $2^k$. The inputs must be already reduced modulo $2^k$.\n    /// Both [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2Sub;\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).mod_power_of_2_sub(&Natural::TWO, 4),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(56u32)).mod_power_of_2_sub(&Natural::from(123u32), 9),\n    ///     445\n    /// );\n    /// ```\n    fn mod_power_of_2_sub(self, other: &Natural, pow: u64) -> Natural {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (self, other) {\n            (x, y) if core::ptr::eq(x, y) => Natural::ZERO,\n            (x, &Natural(Small(y))) => x.mod_power_of_2_sub_limb_ref(y, pow),\n            (&Natural(Small(x)), y) => y.mod_power_of_2_right_sub_limb_ref(x, pow),\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_sub(xs, ys, pow))\n            }\n        }\n    }\n}\n\nimpl ModPowerOf2SubAssign<Self> for Natural {\n    /// Subtracts two [`Natural`] modulo $2^k$, in place. The inputs must be already reduced modulo\n    /// $2^k$. The [`Natural`] on the right-hand side is taken by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2SubAssign;\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_power_of_2_sub_assign(Natural::TWO, 4);\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(56u32);\n    /// x.mod_power_of_2_sub_assign(Natural::from(123u32), 9);\n    /// assert_eq!(x, 445);\n    /// ```\n    fn mod_power_of_2_sub_assign(&mut self, mut other: Self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (&mut *self, &mut other) {\n            (x, &mut Self(Small(y))) => x.mod_power_of_2_sub_assign_limb(y, pow),\n            (&mut Self(Small(x)), y) => {\n                y.mod_power_of_2_right_sub_assign_limb(x, pow);\n                *self = other;\n            }\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_mod_power_of_2_sub_in_place_either(xs, ys, pow) {\n                    swap(xs, ys);\n                }\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl<'a> ModPowerOf2SubAssign<&'a Self> for Natural {\n    /// Subtracts two [`Natural`] modulo $2^k$, in place. The inputs must be already reduced modulo\n    /// $2^k$. The [`Natural`] on the right-hand side is taken by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < 2^k$ and $x - y \\equiv z \\mod 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to $2^k$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModPowerOf2SubAssign;\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.mod_power_of_2_sub_assign(&Natural::TWO, 4);\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(56u32);\n    /// x.mod_power_of_2_sub_assign(&Natural::from(123u32), 9);\n    /// assert_eq!(x, 445);\n    /// ```\n    fn mod_power_of_2_sub_assign(&mut self, other: &'a Self, pow: u64) {\n        assert!(\n            self.significant_bits() <= pow,\n            \"self must be reduced mod 2^pow, but {self} >= 2^{pow}\"\n        );\n        assert!(\n            other.significant_bits() <= pow,\n            \"other must be reduced mod 2^pow, but {other} >= 2^{pow}\"\n        );\n        match (&mut *self, other) {\n            (x, y) if core::ptr::eq(x, y) => *self = Self::ZERO,\n            (x, &Self(Small(y))) => x.mod_power_of_2_sub_assign_limb(y, pow),\n            (&mut Self(Small(x)), y) => *self = y.mod_power_of_2_right_sub_limb_ref(x, pow),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_mod_power_of_2_sub_in_place_left(xs, ys, pow);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::*;\nuse core::ops::{Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::{\n    ModMul, ModMulAssign, ModPow, ModShl, ModShlAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\n\nfn mod_shl_ref_val_unsigned<T: PrimitiveUnsigned>(x: &Natural, bits: T, m: Natural) -> Natural\nwhere\n    Natural: From<T>,\n{\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if bits == T::ZERO {\n        x.clone()\n    } else {\n        match m {\n            Natural::ONE | Natural::TWO => Natural::ZERO,\n            _ => x.mod_mul(Natural::TWO.mod_pow(Natural::from(bits), &m), m),\n        }\n    }\n}\n\nfn mod_shl_ref_ref_unsigned<T: PrimitiveUnsigned>(x: &Natural, bits: T, m: &Natural) -> Natural\nwhere\n    Natural: From<T>,\n{\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if bits == T::ZERO {\n        x.clone()\n    } else {\n        match m {\n            &Natural::ONE | &Natural::TWO => Natural::ZERO,\n            _ => x.mod_mul(Natural::TWO.mod_pow(Natural::from(bits), m), m),\n        }\n    }\n}\n\nfn mod_shl_assign_unsigned_nz<T: PrimitiveUnsigned>(x: &mut Natural, bits: T, m: Natural)\nwhere\n    Natural: From<T>,\n{\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    if bits != T::ZERO {\n        match m {\n            Natural::ONE | Natural::TWO => *x = Natural::ZERO,\n            _ => x.mod_mul_assign(Natural::TWO.mod_pow(Natural::from(bits), &m), m),\n        }\n    }\n}\n\nfn mod_shl_assign_ref_unsigned<T: PrimitiveUnsigned>(x: &mut Natural, bits: T, m: &Natural)\nwhere\n    Natural: From<T>,\n{\n    assert!(*x < *m, \"x must be reduced mod m, but {x} >= {m}\");\n    if bits != T::ZERO {\n        match m {\n            &Natural::ONE | &Natural::TWO => *x = Natural::ZERO,\n            _ => x.mod_mul_assign(Natural::TWO.mod_pow(Natural::from(bits), m), m),\n        }\n    }\n}\n\nmacro_rules! impl_mod_shl_unsigned {\n    ($t:ident) => {\n        impl ModShl<$t, Natural> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. Both [`Natural`]s are\n            /// taken by value.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(mut self, bits: $t, m: Natural) -> Natural {\n                self.mod_shl_assign(bits, m);\n                self\n            }\n        }\n\n        impl<'a> ModShl<$t, &'a Natural> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. The first [`Natural`]\n            /// is taken by value and the second by reference.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(mut self, bits: $t, m: &'a Natural) -> Natural {\n                self.mod_shl_assign(bits, m);\n                self\n            }\n        }\n\n        impl ModShl<$t, Natural> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. The first [`Natural`]\n            /// is taken by reference and the second by value.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(self, bits: $t, m: Natural) -> Natural {\n                mod_shl_ref_val_unsigned(self, bits, m)\n            }\n        }\n\n        impl ModShl<$t, &Natural> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. Both [`Natural`]s are\n            /// taken by reference.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(self, bits: $t, m: &Natural) -> Natural {\n                mod_shl_ref_ref_unsigned(self, bits, m)\n            }\n        }\n\n        impl ModShlAssign<$t, Natural> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$, in place. The first [`Natural`] must be already reduced modulo $m$. The\n            /// [`Natural`] on the right-hand side is taken by value.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl_assign).\n            #[inline]\n            fn mod_shl_assign(&mut self, bits: $t, m: Natural) {\n                mod_shl_assign_unsigned_nz(self, bits, m);\n            }\n        }\n\n        impl ModShlAssign<$t, &Natural> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$, in place. The first [`Natural`] must be already reduced modulo $m$. The\n            /// [`Natural`] on the right-hand side is taken by reference.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $2^nx \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl_assign).\n            #[inline]\n            fn mod_shl_assign(&mut self, bits: $t, m: &Natural) {\n                mod_shl_assign_ref_unsigned(self, bits, m);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_mod_shl_unsigned);\n\nfn mod_shl_ref_val_signed<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    m: Natural,\n) -> Natural\nwhere\n    Natural: From<U>,\n    &'a Natural: Shr<U, Output = Natural>,\n{\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => x.clone(),\n        Less => x >> bits_abs,\n        Greater => match m {\n            Natural::ONE | Natural::TWO => Natural::ZERO,\n            _ => x.mod_mul(Natural::TWO.mod_pow(Natural::from(bits_abs), &m), m),\n        },\n    }\n}\n\nfn mod_shl_ref_ref_signed<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    m: &Natural,\n) -> Natural\nwhere\n    Natural: From<U>,\n    &'a Natural: Shr<U, Output = Natural>,\n{\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => x.clone(),\n        Less => x >> bits_abs,\n        Greater => match m {\n            &Natural::ONE | &Natural::TWO => Natural::ZERO,\n            _ => x.mod_mul(Natural::TWO.mod_pow(Natural::from(bits_abs), m), m),\n        },\n    }\n}\n\nfn mod_shl_assign_signed_nz<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    m: Natural,\n) where\n    Natural: From<U> + ShrAssign<U>,\n{\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => {}\n        Less => *x >>= bits_abs,\n        Greater => match m {\n            Natural::ONE | Natural::TWO => *x = Natural::ZERO,\n            _ => x.mod_mul_assign(Natural::TWO.mod_pow(Natural::from(bits_abs), &m), m),\n        },\n    }\n}\n\nfn mod_shl_assign_ref_signed<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    m: &Natural,\n) where\n    Natural: From<U> + ShrAssign<U>,\n{\n    assert!(*x < *m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => {}\n        Less => *x >>= bits_abs,\n        Greater => match m {\n            &Natural::ONE | &Natural::TWO => *x = Natural::ZERO,\n            _ => x.mod_mul_assign(Natural::TWO.mod_pow(Natural::from(bits_abs), m), m),\n        },\n    }\n}\n\nmacro_rules! impl_mod_shl_signed {\n    ($t:ident) => {\n        impl ModShl<$t, Natural> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. Both [`Natural`]s are\n            /// taken by value.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(mut self, bits: $t, m: Natural) -> Natural {\n                self.mod_shl_assign(bits, m);\n                self\n            }\n        }\n\n        impl ModShl<$t, &Natural> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. The first [`Natural`]\n            /// is taken by value and the second by reference.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(mut self, bits: $t, m: &Natural) -> Natural {\n                self.mod_shl_assign(bits, m);\n                self\n            }\n        }\n\n        impl ModShl<$t, Natural> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. The first [`Natural`]\n            /// is taken by reference and the second by value.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(self, bits: $t, m: Natural) -> Natural {\n                mod_shl_ref_val_signed(self, bits, m)\n            }\n        }\n\n        impl ModShl<$t, &Natural> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. Both [`Natural`]s are\n            /// taken by reference.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl).\n            #[inline]\n            fn mod_shl(self, bits: $t, m: &Natural) -> Natural {\n                mod_shl_ref_ref_signed(self, bits, m)\n            }\n        }\n\n        impl ModShlAssign<$t, Natural> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$, in place. The first [`Natural`] must be already reduced modulo $m$. The\n            /// [`Natural`] on the right-hand side is taken by value.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl_assign).\n            #[inline]\n            fn mod_shl_assign(&mut self, bits: $t, m: Natural) {\n                mod_shl_assign_signed_nz(self, bits, m);\n            }\n        }\n\n        impl ModShlAssign<$t, &Natural> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2) modulo another [`Natural`]\n            /// $m$, in place. The first [`Natural`] must be already reduced modulo $m$. The\n            /// [`Natural`] on the right-hand side is taken by reference.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $\\lfloor 2^nx \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shl#mod_shl_assign).\n            #[inline]\n            fn mod_shl_assign(&mut self, bits: $t, m: &Natural) {\n                mod_shl_assign_ref_signed(self, bits, m);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_mod_shl_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::*;\nuse core::ops::{Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::{\n    ModMul, ModMulAssign, ModPow, ModShr, ModShrAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\n\nfn mod_shr_ref_val<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    m: Natural,\n) -> Natural\nwhere\n    Natural: From<U>,\n    &'a Natural: Shr<U, Output = Natural>,\n{\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => x.clone(),\n        Greater => x >> bits_abs,\n        Less => match m {\n            Natural::ONE | Natural::TWO => Natural::ZERO,\n            _ => x.mod_mul(Natural::TWO.mod_pow(Natural::from(bits_abs), &m), m),\n        },\n    }\n}\n\nfn mod_shr_ref_ref<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    m: &Natural,\n) -> Natural\nwhere\n    Natural: From<U>,\n    &'a Natural: Shr<U, Output = Natural>,\n{\n    assert!(x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => x.clone(),\n        Greater => x >> bits_abs,\n        Less => match m {\n            &Natural::ONE | &Natural::TWO => Natural::ZERO,\n            _ => x.mod_mul(Natural::TWO.mod_pow(Natural::from(bits_abs), m), m),\n        },\n    }\n}\n\nfn mod_shr_assign<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    m: Natural,\n) where\n    Natural: From<U> + ShrAssign<U>,\n{\n    assert!(*x < m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => {}\n        Greater => *x >>= bits_abs,\n        Less => match m {\n            Natural::ONE | Natural::TWO => *x = Natural::ZERO,\n            _ => x.mod_mul_assign(Natural::TWO.mod_pow(Natural::from(bits_abs), &m), m),\n        },\n    }\n}\n\nfn mod_shr_assign_ref<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    m: &Natural,\n) where\n    Natural: From<U> + ShrAssign<U>,\n{\n    assert!(*x < *m, \"x must be reduced mod m, but {x} >= {m}\");\n    let bits_abs = bits.unsigned_abs();\n    match bits.cmp(&S::ZERO) {\n        Equal => {}\n        Greater => *x >>= bits_abs,\n        Less => match m {\n            &Natural::ONE | &Natural::TWO => *x = Natural::ZERO,\n            _ => x.mod_mul_assign(Natural::TWO.mod_pow(Natural::from(bits_abs), m), m),\n        },\n    }\n}\n\nmacro_rules! impl_mod_shr {\n    ($t:ident) => {\n        impl ModShr<$t, Natural> for Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. Both [`Natural`]s are\n            /// taken by value.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shr#mod_shr).\n            #[inline]\n            fn mod_shr(mut self, bits: $t, m: Natural) -> Natural {\n                self.mod_shr_assign(bits, m);\n                self\n            }\n        }\n\n        impl<'a> ModShr<$t, &'a Natural> for Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. The first [`Natural`]\n            /// is taken by value and the second by reference.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shr#mod_shr).\n            #[inline]\n            fn mod_shr(mut self, bits: $t, m: &'a Natural) -> Natural {\n                self.mod_shr_assign(bits, m);\n                self\n            }\n        }\n\n        impl ModShr<$t, Natural> for &Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. The first [`Natural`]\n            /// is taken by reference and the second by value.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shr#mod_shr).\n            #[inline]\n            fn mod_shr(self, bits: $t, m: Natural) -> Natural {\n                mod_shr_ref_val(self, bits, m)\n            }\n        }\n\n        impl ModShr<$t, &Natural> for &Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo another [`Natural`]\n            /// $m$. The first [`Natural`] must be already reduced modulo $m$. Both [`Natural`]s are\n            /// taken by reference.\n            ///\n            /// $f(x, n, m) = y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shr#mod_shr).\n            #[inline]\n            fn mod_shr(self, bits: $t, m: &Natural) -> Natural {\n                mod_shr_ref_ref(self, bits, m)\n            }\n        }\n\n        impl ModShrAssign<$t, Natural> for Natural {\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo another [`Natural`]\n            /// $m$, in place. The first [`Natural`] must be already reduced modulo $m$. The\n            /// [`Natural`] on the right-hand side is taken by value.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shr#mod_shr_assign).\n            #[inline]\n            fn mod_shr_assign(&mut self, bits: $t, m: Natural) {\n                mod_shr_assign(self, bits, m);\n            }\n        }\n\n        impl<'a> ModShrAssign<$t, &'a Natural> for Natural {\n            /// Right-shifts a [`Natural`] (divides it by a power of 2) modulo another [`Natural`]\n            /// $m$, in place. The first [`Natural`] must be already reduced modulo $m$. The\n            /// [`Natural`] on the right-hand side is taken by reference.\n            ///\n            /// $x \\gets y$, where $x, y < m$ and $\\lfloor 2^{-n}x \\rfloor \\equiv y \\mod m$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(mn \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `m.significant_bits()`, and $m$\n            /// is `bits`.\n            ///\n            /// # Panics\n            /// Panics if `self` is greater than or equal to `m`.\n            ///\n            /// # Examples\n            /// See [here](super::mod_shr#mod_shr_assign).\n            #[inline]\n            fn mod_shr_assign(&mut self, bits: $t, m: &'a Natural) {\n                mod_shr_assign_ref(self, bits, m);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_mod_shr);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ModPow, ModPowAssign, ModSquare, ModSquareAssign};\nuse malachite_base::num::basic::traits::Two;\n\nimpl ModSquare<Self> for Natural {\n    type Output = Self;\n\n    /// Squares a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. Both [`Natural`]s are taken by value.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSquare;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(2u32).mod_square(Natural::from(10u32)), 4);\n    /// assert_eq!(Natural::from(100u32).mod_square(Natural::from(497u32)), 60);\n    /// ```\n    fn mod_square(self, m: Self) -> Self {\n        (&self).mod_pow(&Self::TWO, &m)\n    }\n}\n\nimpl ModSquare<&Self> for Natural {\n    type Output = Self;\n\n    /// Squares a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. The first [`Natural`] is taken by value and the second by reference.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSquare;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(2u32).mod_square(&Natural::from(10u32)), 4);\n    /// assert_eq!(Natural::from(100u32).mod_square(&Natural::from(497u32)), 60);\n    /// ```\n    fn mod_square(self, m: &Self) -> Self {\n        (&self).mod_pow(&Self::TWO, m)\n    }\n}\n\nimpl ModSquare<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Squares a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. The first [`Natural`] is taken by reference and the second by value.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSquare;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(2u32)).mod_square(Natural::from(10u32)), 4);\n    /// assert_eq!(\n    ///     (&Natural::from(100u32)).mod_square(Natural::from(497u32)),\n    ///     60\n    /// );\n    /// ```\n    fn mod_square(self, m: Natural) -> Natural {\n        self.mod_pow(&Natural::TWO, &m)\n    }\n}\n\nimpl ModSquare<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Squares a [`Natural`] modulo another [`Natural`] $m$. The input must be already reduced\n    /// modulo $m$. Both [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, m) = y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSquare;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(2u32)).mod_square(&Natural::from(10u32)), 4);\n    /// assert_eq!(\n    ///     (&Natural::from(100u32)).mod_square(&Natural::from(497u32)),\n    ///     60\n    /// );\n    /// ```\n    fn mod_square(self, m: &Natural) -> Natural {\n        self.mod_pow(&Natural::TWO, m)\n    }\n}\n\nimpl ModSquareAssign<Self> for Natural {\n    /// Squares a [`Natural`] modulo another [`Natural`] $m$, in place. The input must be already\n    /// reduced modulo $m$. The [`Natural`] on the right-hand side is taken by value.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSquareAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(2u32);\n    /// x.mod_square_assign(Natural::from(10u32));\n    /// assert_eq!(x, 4);\n    ///\n    /// let mut x = Natural::from(100u32);\n    /// x.mod_square_assign(Natural::from(497u32));\n    /// assert_eq!(x, 60);\n    /// ```\n    #[inline]\n    fn mod_square_assign(&mut self, m: Self) {\n        self.mod_pow_assign(&Self::TWO, &m);\n    }\n}\n\nimpl ModSquareAssign<&Self> for Natural {\n    /// Squares a [`Natural`] modulo another [`Natural`] $m$, in place. The input must be already\n    /// reduced modulo $m$. The [`Natural`] on the right-hand side is taken by reference.\n    ///\n    /// $x \\gets y$, where $x, y < m$ and $x^2 \\equiv y \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSquareAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(2u32);\n    /// x.mod_square_assign(&Natural::from(10u32));\n    /// assert_eq!(x, 4);\n    ///\n    /// let mut x = Natural::from(100u32);\n    /// x.mod_square_assign(&Natural::from(497u32));\n    /// assert_eq!(x, 60);\n    /// ```\n    #[inline]\n    fn mod_square_assign(&mut self, m: &Self) {\n        self.mod_pow_assign(&Self::TWO, m);\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mod_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ModSub, ModSubAssign};\n\nimpl ModSub<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. All three [`Natural`]s are taken by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32)\n    ///         .mod_sub(Natural::from(3u32), Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32)\n    ///         .mod_sub(Natural::from(9u32), Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value.\n    #[inline]\n    fn mod_sub(mut self, other: Self, m: Self) -> Self {\n        self.mod_sub_assign(other, m);\n        self\n    }\n}\n\nimpl ModSub<Self, &Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first two [`Natural`]s are taken by value and the third by\n    /// reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32)\n    ///         .mod_sub(Natural::from(3u32), &Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32)\n    ///         .mod_sub(Natural::from(9u32), &Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value and `m` is taken by reference.\n    #[inline]\n    fn mod_sub(mut self, other: Self, m: &Self) -> Self {\n        self.mod_sub_assign(other, m);\n        self\n    }\n}\n\nimpl ModSub<&Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first and third [`Natural`]s are taken by value and the second by\n    /// reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32)\n    ///         .mod_sub(&Natural::from(3u32), Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32)\n    ///         .mod_sub(&Natural::from(9u32), Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This isequivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value and `c` is taken by reference.\n    #[inline]\n    fn mod_sub(mut self, other: &Self, m: Self) -> Self {\n        self.mod_sub_assign(other, m);\n        self\n    }\n}\n\nimpl ModSub<&Self, &Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] is taken by value and the second and third by\n    /// reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(4u32)\n    ///         .mod_sub(&Natural::from(3u32), &Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(7u32)\n    ///         .mod_sub(&Natural::from(9u32), &Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` is\n    /// taken by value and `c` and `m` are taken by reference.\n    #[inline]\n    fn mod_sub(mut self, other: &Self, m: &Self) -> Self {\n        self.mod_sub_assign(other, m);\n        self\n    }\n}\n\nimpl ModSub<Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first [`Natural`] is taken by reference and the second and third by\n    /// value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32))\n    ///         .mod_sub(Natural::from(3u32), Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32))\n    ///         .mod_sub(Natural::from(9u32), Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` is\n    /// taken by reference and `c` and `m` are taken by value.\n    fn mod_sub(self, other: Natural, m: Natural) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        if *self >= other {\n            self - other\n        } else {\n            m - other + self\n        }\n    }\n}\n\nimpl ModSub<Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first and third [`Natural`]s are taken by reference and the second\n    /// by value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32))\n    ///         .mod_sub(Natural::from(3u32), &Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32))\n    ///         .mod_sub(Natural::from(9u32), &Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by reference and `c` is taken by value.\n    fn mod_sub(self, other: Natural, m: &Natural) -> Natural {\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            other < *m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        if *self >= other {\n            self - other\n        } else {\n            m - other + self\n        }\n    }\n}\n\nimpl ModSub<&Natural, Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. The first two [`Natural`]s are taken by reference and the third by\n    /// value.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32))\n    ///         .mod_sub(&Natural::from(3u32), Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32))\n    ///         .mod_sub(&Natural::from(9u32), Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by reference and `m` is taken by value.\n    fn mod_sub(self, other: &Natural, m: Natural) -> Natural {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            *other < m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        if self >= other {\n            self - other\n        } else {\n            m - other + self\n        }\n    }\n}\n\nimpl ModSub<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$. The inputs must be already\n    /// reduced modulo $m$. All three [`Natural`]s are taken by reference.\n    ///\n    /// $f(x, y, m) = z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSub;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(4u32))\n    ///         .mod_sub(&Natural::from(3u32), &Natural::from(5u32))\n    ///         .to_string(),\n    ///     \"1\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(7u32))\n    ///         .mod_sub(&Natural::from(9u32), &Natural::from(10u32))\n    ///         .to_string(),\n    ///     \"8\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by reference.\n    fn mod_sub(self, other: &Natural, m: &Natural) -> Natural {\n        assert!(self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        if self >= other {\n            self - other\n        } else {\n            m - other + self\n        }\n    }\n}\n\nimpl ModSubAssign<Self, Self> for Natural {\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSubAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_sub_assign(Natural::from(3u32), Natural::from(5u32));\n    /// assert_eq!(x.to_string(), \"1\");\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_sub_assign(Natural::from(9u32), Natural::from(10u32));\n    /// assert_eq!(x.to_string(), \"8\");\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b`, `c`,\n    /// and `m` are taken by value and `a == b`.\n    fn mod_sub_assign(&mut self, other: Self, m: Self) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        if *self >= other {\n            *self -= other;\n        } else {\n            *self += m - other;\n        }\n    }\n}\n\nimpl ModSubAssign<Self, &Self> for Natural {\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by value\n    /// and the second by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSubAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_sub_assign(Natural::from(3u32), &Natural::from(5u32));\n    /// assert_eq!(x.to_string(), \"1\");\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_sub_assign(Natural::from(9u32), &Natural::from(10u32));\n    /// assert_eq!(x.to_string(), \"8\");\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` and `c`\n    /// are taken by value, `m` is taken by reference, and `a == b`.\n    fn mod_sub_assign(&mut self, other: Self, m: &Self) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            other < *m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        if *self >= other {\n            *self -= other;\n        } else {\n            *self += m - other;\n        }\n    }\n}\n\nimpl ModSubAssign<&Self, Self> for Natural {\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. The first [`Natural`] on the right-hand side is taken by\n    /// reference and the second by value.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSubAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_sub_assign(&Natural::from(3u32), Natural::from(5u32));\n    /// assert_eq!(x.to_string(), \"1\");\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_sub_assign(&Natural::from(9u32), Natural::from(10u32));\n    /// assert_eq!(x.to_string(), \"8\");\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` and `m`\n    /// are taken by value, `c` is taken by reference, and `a == b`.\n    fn mod_sub_assign(&mut self, other: &Self, m: Self) {\n        assert!(*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(\n            *other < m,\n            \"other must be reduced mod m, but {other} >= {m}\"\n        );\n        if *self >= *other {\n            *self -= other;\n        } else {\n            *self += m - other;\n        }\n    }\n}\n\nimpl ModSubAssign<&Self, &Self> for Natural {\n    /// Subtracts two [`Natural`]s modulo a third [`Natural`] $m$, in place. The inputs must be\n    /// already reduced modulo $m$. Both [`Natural`]s on the right-hand side are taken by reference.\n    ///\n    /// $x \\gets z$, where $x, y, z < m$ and $x - y \\equiv z \\mod m$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `m.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` or `other` are greater than or equal to `m`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModSubAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(4u32);\n    /// x.mod_sub_assign(&Natural::from(3u32), &Natural::from(5u32));\n    /// assert_eq!(x.to_string(), \"1\");\n    ///\n    /// let mut x = Natural::from(7u32);\n    /// x.mod_sub_assign(&Natural::from(9u32), &Natural::from(10u32));\n    /// assert_eq!(x.to_string(), \"8\");\n    /// ```\n    ///\n    /// This is equivalent to `_fmpz_mod_subN` from `fmpz_mod/sub.c`, FLINT 2.7.1, where `b` is\n    /// taken by value, `c` and `m` are taken by reference, and `a == b`.\n    fn mod_sub_assign(&mut self, other: &Self, m: &Self) {\n        assert!(&*self < m, \"self must be reduced mod m, but {self} >= {m}\");\n        assert!(other < m, \"other must be reduced mod m, but {other} >= {m}\");\n        if *self >= *other {\n            *self -= other;\n        } else {\n            *self += m - other;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/context.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::mul::fft::{\n    MPNToFFTFunc, ModData, ProfileEntry, SerializedCRTData, SerializedContext, SerializedFFTContext,\n};\n\npub_const_crate_test_const! {CONTEXT: SerializedContext = SerializedContext {\n    ffts: [\n        SerializedFFTContext {\n            p: 4832221662680186888,\n            pinv: 4382073923139863564,\n            mod_data: ModData {\n                n: 1108307720798209,\n                ninv: 292805461487436291,\n                norm: 14,\n            },\n            primitive_root: 11,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                14046483040696548224,\n                14041266564791292416,\n                14046654607898308576,\n                14048474171345687056,\n                4825280988129212736,\n                4823070262100768512,\n                4825145705455639920,\n                14048719511357028512,\n                4813041419429792512,\n                14047460680378998560,\n                4823932171918830848,\n                14048012741190537504,\n                14049414971616717552,\n                14040214421382992192,\n                14050594040212820512,\n                14048118403069104272,\n                14051037750155633584,\n                4826427714660192064,\n                14042408583631808640,\n                4815500119549053952,\n                14048055777734951184,\n                14044695660409383360,\n                4819649398905565088,\n                14045427149334620256,\n                4823381304004007728,\n                4815599231986874624,\n                14049509440854704336,\n                14047614079244213184,\n                14042020442567623936,\n                4823837246712104864,\n                14047202918495667568,\n                4824606943046356768,\n                14046144365724386304,\n                4826338243139809296,\n                4825776016666020752,\n                14041974982291700928,\n                4821075954353764384,\n                4818934199985439168,\n                4826844709835937088,\n                14045053681550184064,\n                4825846602928402784,\n                14048339714062651280,\n                14048236519775616432,\n                4813167748879223040,\n                4814427186749045568,\n                4801993905695418880,\n                14047921481845181584,\n                4800715846833548288,\n                14050051937776320720,\n                14047329130950929136,\n                4825192028434603936,\n                14033557391598349440,\n                4811583918684201600,\n                4826394491523750912,\n                4827607900400231040,\n                4815035465331248256,\n                14050309097969302944,\n                4826895466358131152,\n                4822554631046226720,\n                14036931337007205248,\n                4825205012118472032,\n                4825308579084571232,\n                14045241352176863040,\n                4810918236012237824,\n                4797249783404725248,\n                4827236163907204256,\n                14047069118495169488,\n                14049026285404870560,\n                4818738903444956800,\n                14045230990509550592,\n                14031635412619855616,\n                4827474457339444832,\n                4824129028022177616,\n                4823340064380744192,\n                14044739687417710432,\n                14045128433022754176,\n                14047993490571051712,\n                14045870974207516800,\n                4813634929117924736,\n                4825324746932035648,\n                14039469803807068096,\n                4820611054736759936,\n                4822256754287614912,\n                14021738051791665152,\n                4825010562180111408,\n                14048190222917392928,\n                4819182008851661728,\n                4826030548176723616,\n                14046692545027997760,\n                4819198852482536064,\n                4815055146123290688,\n                4820857779201672672,\n                4826571770796088800,\n                4824763373960046432,\n                4826207330779558000,\n                4815138139495074624,\n                4824204430389702192,\n                14049556824142364176,\n                4824454081787068800,\n                14049189919930928896,\n                14044179955986812000,\n                14046271736812641696,\n                4824060318425401312,\n                14050747509266926912,\n                4825142450362155552,\n                4816533874169214976,\n                4827160896341891104,\n                4820570784529409856,\n                4821137938370792928,\n                14049846250466738816,\n                4826774199463379360,\n                14030945197938521856,\n                14049603588453280640,\n                14043351094687337600,\n                4824626990036934288,\n                14031802698386156288,\n                4822255187199184928,\n                14048726292367537312,\n                4823397034388116864,\n                4826762790423412384,\n                14049636050427273072,\n                4819718048613067424,\n                4825536657712000208,\n                14048626728823809376,\n                4819184994000744512,\n                14045446525187476192,\n                4827104583110771904,\n                4818006370840631488,\n                4818680646777312000,\n                4827071932865285376,\n                4827445384756072704,\n                4817780525507956992,\n                4817161839406250816,\n                4824195591743519120,\n                14043192498422708128,\n                14051017367425719104,\n                14048200105821986928,\n                4825004025033499872,\n                4819844802597583264,\n                14047050195186803632,\n                4824163142215258384,\n                4824248279185254512,\n                4820199679800643328,\n                4823002747338444320,\n                4824075640393983264,\n                14038926028439106752,\n                4808013985434214144,\n                14049668227092583920,\n                4819620504808480992,\n                4824559823719753504,\n                4825286829547784608,\n                4810092177519262464,\n                4825087873481068240,\n                4823714322660276192,\n                14038645532674298624,\n                14040020995286578688,\n                4825599849329234928,\n                4813819847671611520,\n                14048896310852447216,\n                14045384088795470912,\n                4805668865339335424,\n                14048576381293985696,\n                4824781826700605200,\n                4822357966667501056,\n                4824073675312833952,\n                4824461384396031488,\n                14041618821648592640,\n                4820424204835760288,\n                14049446565963314096,\n                4825914703018903344,\n                4824320050456920240,\n                14047216851637180048,\n                4826845605120967488,\n                14046990281984208896,\n                4803301096677755392,\n                14048087048487187312,\n                14048267125598031568,\n                14049219203991515232,\n                4823791154502875456,\n                4824813478518749264,\n                4826761756073767856,\n                14045890088146478048,\n                14047127224416405504,\n                4825308406718036624,\n                4826524740619734384,\n                14039473079911134080,\n                14051006953175174096,\n                4822044751034231200,\n                14045192674302691168,\n                4821202192697375744,\n                4819313830282205792,\n                4824199172058020496,\n                4824128930307876912,\n                4815704995150873728,\n                4824923227130951120,\n                4822596689055455808,\n                4823049360411012608,\n                4819306590744902016,\n                4826591080181301456,\n                14049635164099591392,\n                14030468778628478464,\n                4827052116848378224,\n                4819206832265809568,\n                4825055614504367120,\n                4823918165860660496,\n                14042633715279387808,\n                14049596467118077264,\n                4825263238083522368,\n                14031413503257703936,\n                4815679279413013824,\n                14038672289249759872,\n                14038909836703556160,\n                14038242927481553280,\n                14047635090853167248,\n                14051018802502624176,\n                14042983528167630848,\n                4805682748104838912,\n                14039978362163436608,\n                14048792868698251440,\n                14034098702346825344,\n                4820243268433542592,\n                4819910547530873024,\n                4824173475856074032,\n                14048139949516686880,\n                14037002837738441856,\n                14035085540317849216,\n                4820329208711005184,\n                4818481772245505984,\n                14046160799527187488,\n                14037689673424876800,\n                4823583889208340128,\n                4826155876156847680,\n                14050588077073411760,\n                14043231202974999008,\n                14044835822719360000,\n                14050162147253726352,\n                4825994224944672832,\n                14036443957070478976,\n                14049322393135056224,\n                4827593390471561312,\n                4810251343749604352,\n                4825452261412231632,\n                4826216935547207120,\n                14045481310938361856,\n                14047172324274992944,\n                14049403413423105552,\n                14042745788132748640,\n                4822179390531901216,\n                4817091570614064960,\n                4817032356022110656,\n                14050750681875133904,\n                14044068818421252416,\n                4825073596177150656,\n                4821524366611283232,\n                4825245299496273760,\n                14048522608956380368,\n                14047269914571844320,\n                14026979281596195328,\n                14048637741933060032,\n                4812924759510915456,\n                4823791571623482416,\n                4819364326935767520,\n                14048615469363975744,\n                14048223789395992496,\n                4822067875914460928,\n                4812844665382721408,\n                14047185591090111504,\n                14048278565984707120,\n                14042266618224066208,\n                14046140076805973664,\n                4822011185608477568,\n                4821375973811010784,\n                14045850264554840448,\n                4825253119507244880,\n                14050856228650986592,\n                14039727714170773888,\n                14041667864897455872,\n                14050661261201644784,\n                14041751979740895808,\n                14046874492511972464,\n                14043800344359399840,\n                14048457429015702784,\n                14048917430359400128,\n                14042764907603421984,\n                14042382814754304160,\n                14029268887713520384,\n                14050944396847437904,\n                4815176157982052608,\n                4826823196257196448,\n                14045365898906697056,\n                4819172934441799744,\n                14045936955907546368,\n                4823566126366426288,\n                14050209728573336256,\n                14046986837514138704,\n                4814904289452726912,\n                4820746400431198912,\n                4820784338626452896,\n                14047590789083965024,\n                14050165047405310016,\n                4818140992688887424,\n                4815407965458868736,\n                14042371101755937088,\n                4820627440088072544,\n                14043470953967812096,\n                14049107355544595424,\n                4819505155127182240,\n                14046183897776881952,\n                4822936423049905632,\n                4823971831127090240,\n                14043135196912923744,\n                14049182014391677296,\n                14034046123976283136,\n                14046811435933691632,\n                14022498559883549696,\n                4824763649716131600,\n                14048257837414730656,\n                14034119430308336384,\n                4823856510552235008,\n                14043255227566739200,\n                4826998889025437824,\n                14046546893774345312,\n                14044554777814164864,\n                4820417871504712192,\n                4824097658741020752,\n                14048265955335196560,\n                14048723582937471984,\n                4811351800357217664,\n                14049621229982541584,\n                14048269579186701840,\n                4822731413398345664,\n                14048568447829647504,\n                14047272161047292352,\n                4825958042234336112,\n                4824953413136992880,\n                14049793694230404512,\n                4824858220134808816,\n                4825694514610506336,\n                14051076155048251232,\n                14047583081180249024,\n                4821226398019722720,\n                4815936484729315584,\n                4806342673533014016,\n                14035013194025497600,\n                14047809908198516608,\n                14040392727468692096,\n                4827411667643419792,\n                4814282660731462656,\n                14050087885837953632,\n                14044912089655399392,\n                14049311980611036608,\n                4816333361033769856,\n                14049386058612116992,\n                14042232823497699424,\n                14041619273212419200,\n                14047287722435667584,\n                14050118733590641840,\n                4823849828665473648,\n                14046824244044652064,\n                14047657990103172176,\n                14045276687864563680,\n                14047370000355839712,\n                14047308608616217264,\n                4827682614884533744,\n                14047319421821095872,\n                4815919970748835904,\n                4825492136127470800,\n                14047530779696310976,\n                14040786623432398784,\n                4825522590368690448,\n                4810010342263356032,\n                14049378355821000400,\n                14043790937380510144,\n                14042591317386920288,\n                14042693356712405856,\n                4826427066641869376,\n                4823486517647396592,\n                4816793397773071168,\n                14047837490033714352,\n                14049709592061729072,\n                14050022679623089984,\n                14050152793643129040,\n                14049847128285324384,\n                4819442534710903776,\n                14038772444489239552,\n                4821821467032183200,\n                14042798754962017344,\n                14041244107263114880,\n                4827512962414264224,\n                14047472473965405456,\n                4825329610943058128,\n                14049900603450083040,\n                14049934082860131360,\n                4814455544346235200,\n                14047142381153297520,\n                4826644084028141856,\n                14047085174347850784,\n                14034063809682956416,\n                4823099380073302400,\n                14012223001864626176,\n                4825074551368201440,\n                4824858100641346352,\n                14049041245033723072,\n                4822373292844632416,\n                14050204891093079520,\n                4815076031447749504,\n                14047584520893664336,\n                14040320315309779264,\n                14046337944112227456,\n                14047877078142909248,\n                14035466038416465536,\n                14050478143558961360,\n                14049260042868949536,\n                14037672082656803968,\n                4824963523432087232,\n                14049340336395875664,\n                14046910530902793104,\n                14045444748947415648,\n                14047177271606125312,\n                4821990434795555200,\n                14044419518738293344,\n                4819945184119759648,\n                14041032232841913728,\n                14048763430668217488,\n                4823619084349412576,\n                14042801532148048256,\n                14042347407205647616,\n                4825621341096362400,\n                14048040123758626192,\n                4824682598948631008,\n                14038564188098452480,\n                14050638994166165504,\n                14035505984064535808,\n                4823533888126971008,\n                4806675099723725056,\n                4817865399384972352,\n                14049297014298640768,\n                4824259560240576528,\n                14049611781423650688,\n                14029959399145138688,\n                14037242542246288896,\n                4825751297384132848,\n                14046850998927723312,\n                4826211820473417808,\n                14030498426865137152,\n                4814705398582830784,\n                14034450775430002176,\n                4823706404100106736,\n                4822157538441493216,\n                4823426478537610624,\n                14049146411892380512,\n                14044219782276401984,\n                14050670223392374624,\n                14051028838390376768,\n                14045915779506876064,\n                4823558930160020128,\n                4825244377568960640,\n                4807591992296692480,\n                4823758301839896160,\n                4826142634230447840,\n                4819088486472748480,\n                14042685438782441216,\n                4824822936255775984,\n                14031749427877780736,\n                4823324524495060576,\n                14049289602396136640,\n                4827146294076208352,\n                4816847446884583616,\n                4824446731668680448,\n                14043542548998325984,\n                14047173703129147072,\n                4824118336375205616,\n                14050641862556008704,\n                14047751130241162976,\n                4806693690923252992,\n                4827586275371484976,\n                4822678311433221440,\n                4826573937920286992,\n                14048153007760356912,\n                14049004955509556128,\n                4824778240945409696,\n                14036529543114140416,\n                4824945237162002112,\n                14050310219556371632,\n                4818989118935674304,\n                14049132194814866272,\n                14043852533528500864,\n                14046127599306224672,\n                14046755170205931376,\n                14038084636413186432,\n                14045762785437682496,\n                14046731548459908768,\n                4822132427385229408,\n                4822456890616758080,\n                4810418936055242368,\n                4822718343374728704,\n                4827637059920517616,\n                4819427585591130880,\n                14043691531324087648,\n                14037383153404967552,\n                4820563762056005280,\n                14050819228458052688,\n                4827095853942521792,\n                14045971781255204352,\n                14043014250328850784,\n                14039548785370054656,\n                14049753755436084336,\n                14044911373014465248,\n                14035462916292590848,\n                4822053619758865600,\n                14038080494600610560,\n                14048389317093962048,\n                14035193936213624704,\n                14050250939632282608,\n                4819008650820837120,\n                14036592514031676160,\n                4816931626055282816,\n                4813566330015433088,\n                14044351404457903264,\n                4825322526433315104,\n                4824771951280955344,\n                14038805418786009984,\n                14048890978650719680,\n                14050468113100330848,\n                4821828605537414112,\n                14047174553190971664,\n                14049425161611228672,\n                4823837449135753024,\n                14048056088373853408,\n                14045038441127697920,\n                4822734584214799744,\n                4825994138165977392,\n                14039327426371662208,\n                14047363506710856576,\n                4818444698442537664,\n                14031089761854012672,\n                14049871459928539312,\n                4824321216613372160,\n                4825649307690949872,\n                4796988492555425792,\n                14041251693586588288,\n                4821024448229029184,\n                4826919181845170944,\n                14048341116163477984,\n                14045399563606076608,\n                4817900579996075136,\n                14049030473429325072,\n                4825276324930707024,\n                4824572232687531584,\n                14050576318790848720,\n                14048973466044014944,\n                4821922910084220320,\n                4821750207397119200,\n                4825603708836400080,\n                14043133702734724288,\n                14035176049538710144,\n                14046895249368355328,\n                14043003277378234752,\n                4823947386255577152,\n                4824896708370961632,\n                14047205499523794016,\n                4821717118544614656,\n                14044833001674968960,\n                14038717957195825216,\n                14049164410395341536,\n                14048782641585623056,\n                4792448378576891904,\n                14050208830239565808,\n                14030361909789717760,\n                14048055817760640912,\n                14046243174679042816,\n                14050008850696821200,\n                14049931393597862912,\n                14048134459644229184,\n                4823601079135387488,\n                4820591677239373888,\n                4827081636870501520,\n                14050995059743268320,\n                14043784197742915776,\n                4825812946351759632,\n                4826970763627606240,\n                14030044983182958848,\n                14044139643617881632,\n                4824726842733191920,\n                14049740409859275952,\n                4827680076108604192,\n                14044917199660457984,\n                14034940658526484608,\n                4808463339559038208,\n                14045422847133900608,\n                4825854603158192128,\n                4818081818263350784,\n                4821344529459973952,\n                4813619312253060736,\n                14043652839812545248,\n                4827437810137513424,\n                4821669099732525696,\n                14039369361079539456,\n                14049156464208464256,\n                14048195764173334656,\n                14050522863552142784,\n                4824938742031900752,\n                4824928488290445872,\n                4814871612147637696,\n                14015311739133556736,\n                14041908890339829760,\n                4824144497432211968,\n                4818382806586852096,\n                14040099449000027712,\n                14042951673715602912,\n                14040778137255815104,\n                4825062764527490384,\n                4817303522963686912,\n                14050085523192606944,\n                14049518587648221616,\n                4827670732149058192,\n                4823145697700376000,\n                14044260934986973664,\n                14049696201554602640,\n                14048108127626746032,\n                4826179626828927232,\n                14025411070459712512,\n                14043126295386998272,\n                14042215012924440576,\n                4817138123172843072,\n                14039659159559786624,\n                4827465257896231840,\n                14048700151011937152,\n                14044145462090976832,\n                14044240267743751168,\n                14051014947497155792,\n                4825792464940578096,\n                14045429016722256896,\n                4820419454094284960,\n                4816881735781510912,\n                14040636933071128448,\n                14042687405981482496,\n                14031602415484818432,\n                14043159942599446208,\n                4823680538966477888,\n                4826944835012779808,\n                4826603141001502816,\n                4826478223155301520,\n                14048128849987772736,\n                4822322466570815616,\n                14049218559407890512,\n                14047304711675162112,\n                14042094920924952256,\n                4817824202519944000,\n                4825189996172164608,\n                4818421383587950080,\n                4823833599386250000,\n                4816562725450519104,\n                14034691421119442432,\n                4824993328069840064,\n                14043245000696696352,\n                4797625995430700032,\n                14048526673318310592,\n                4824286505259134480,\n                14042053994169972480,\n                4812300173882833152,\n                4827082155612445760,\n                14049381679719453920,\n                14049274138105394912,\n                14044913171158146112,\n                14050373527917723984,\n                14048316983198268272,\n                4817876332410355840,\n                14049032695401610784,\n                14050097281675712128,\n                4821460861520460672,\n                4823737627459473552,\n                4823982265570123936,\n                4820056428764819712,\n                14049353536247509456,\n                14050472218798172352,\n                4826755432408624016,\n                4824803968710798544,\n                4820031489267798592,\n                4821967137830257824,\n                4825015224569409792,\n                4824838961161096688,\n                4825800065348432656,\n                14049952585096929616,\n                4827104314850334688,\n                14042705266240876928,\n                4819926754454714560,\n                4824018972128983168,\n                14050795241954013984,\n                4805014905477674496,\n                14050038971813359200,\n                4822044814930407040,\n                4820411605327367744,\n                14049688902799295104,\n                4819142804284420768,\n                4825886917665679248,\n                14048747937899510416,\n                14042037124403658304,\n                14049176071280358352,\n                14044055017356814816,\n                4825469840564567632,\n                4824905342407590544,\n                4818504074420354816,\n                4815458176558902464,\n                4815188453051336448,\n                14036807263994892160,\n                4827498343826201664,\n                14049119379953410128,\n                4823302775604405376,\n                14043016715203301664,\n                4827495641790033104,\n                4823363857277762688,\n                14038033438167736064,\n                4814847157876722496,\n                4814251124741317248,\n                4819195415170804448,\n                14050528980015152576,\n                4825411202855366608,\n                14047125621080780672,\n                14047959588196616240,\n                4825051940528699280,\n                14050521634850489216,\n                14050017475456693200,\n                4820379686704611264,\n                14035910600422123136,\n                14047326493300457424,\n                14050571215156938256,\n                4823652418888649696,\n                14050417988381761264,\n                4820387977337772736,\n                4818314072083754240,\n                14051017487741226912,\n                14037050973462570112,\n                4823704255755433136,\n                14049427498142413264,\n                14040878793519066496,\n                4824929473640154320,\n                14047664547066175872,\n                4818037308111769600,\n                4826743500546108048,\n                14044957773744784448,\n                4810005278012207744,\n                4823919620547018928,\n                4820321268535672416,\n                4818908408295628128,\n                14043313622182274368,\n                14044813162330105760,\n                4813160655793087872,\n                4823385822014157392,\n                14046760915264564288,\n                4823786982390816112,\n                4827296165539996304,\n                4823642076546874576,\n                14042724646872466528,\n                14048553575357552560,\n                14047780490992593744,\n                14046445349514871488,\n                14047521390871206144,\n                4820418130056209440,\n                4826057571897478464,\n                14038613586342552960,\n                4818400212677276096,\n                4826763177360602672,\n                14047467554376226640,\n                14048174401070517808,\n                14044467821834138496,\n                14042917213813070048,\n                4823973937344713312,\n                4824802598723866432,\n                4810374765008782848,\n                4823313025639697728,\n                14047663970055997744,\n                14042087037471012800,\n                4820438914229217856,\n                14049376909377142672,\n                14033903211948548224,\n                4825987015351910048,\n                14041826251995452288,\n                14034672944557374464,\n                4806721659360261632,\n                4823504542259255104,\n                14049386929894760304,\n                14042167594739367872,\n                4819735892051179072,\n                4826234150372706352,\n                4825635028466205696,\n                4825682256751671408,\n                4826055702446774672,\n                4821388320759786848,\n                4821631503468549312,\n                4821239842242658848,\n                14044068914730140320,\n                14048039872714796704,\n                14047720135151209552,\n                14043322227654425504,\n                4825120915116238928,\n                4824561218852411520,\n                4799089433073063936,\n                14041671799794458944,\n                14045470044109872608,\n                4819833243804254816,\n                14050818584461557184,\n                14011000164004884480,\n                4821574614677297728,\n                4818409231908242944,\n                14047772101476957008,\n                14028656681432691712,\n                4826369189318387600,\n                4826047476251163104,\n                4826626888858870256,\n                4827179954026736880,\n                14044775829680114976,\n                14044398407826933440,\n                4814560448369338496,\n                4819574707907834176,\n                14050221278744849424,\n                14050489287540949120,\n                14047444516093491344,\n                14050910635606165344,\n                14047856588118826768,\n                14050830839860001552,\n                4821056253933807904,\n                4822526238105877088,\n                4823136705466425216,\n                4824598052275447584,\n                14046721130553494464,\n                14030105928680120064,\n                14050129392130375760,\n                14048399179017431104,\n                4822062910989996128,\n                14045832027205446304,\n                4827426182310374864,\n                4826803922508817136,\n                4824725648271379040,\n                14034047469209378176,\n                14031946455468987136,\n                14040993140600164736,\n                14043883714586794240,\n                14049753207724580032,\n                14040274828053123904,\n                14038075165461151488,\n                14048394431476414240,\n                4819914078759153664,\n                14048700303594925936,\n                14048319457910827600,\n                14031159189659777792,\n                4810951811591987584,\n                14047736580788544352,\n                14050220993756874384,\n                14047994611929683824,\n                4812993739683130880,\n                14050612673831094928,\n                4823077962950726880,\n                14049324931122414224,\n                4807056624159824128,\n                4822181562188094144,\n                14049500243183956304,\n                4825066038008814960,\n                4821520350432733632,\n                4826360018397011440,\n                14033543939808361344,\n                4826441453874137008,\n                14049470627390374496,\n                4823491673007346512,\n                14049306039481578160,\n                14049318778861924688,\n                14049433456593114432,\n                4815193853112816128,\n                4824208031904870272,\n                4822978959369136000,\n                14050129686200503776,\n                14048301535758838144,\n                4824038246796583168,\n                14019990247193713664,\n                14047173327800554336,\n                4827005370443939232,\n                4819059803056283136,\n                14050985684827130912,\n                14049692948841202048,\n                14038741239917574400,\n                4823981374889807680,\n                14042558626126699168,\n                14040184482525000000,\n                4824731944975032352,\n                14047108356132470864,\n                14049050995698017840,\n                4822353234150518592,\n                4826298778478247248,\n                4827074656938274112,\n                14040027358764133888,\n                4809399905530755072,\n                14048245229180783072,\n                4824278461063835232,\n                4818264080879098624,\n                14042573514164921184,\n                14046780630583738992,\n                14048342525722425392,\n                4817603500973679680,\n                4819355347407624384,\n                14032021090460038400,\n                4824782255042232384,\n                14045389521665389504,\n                14024409243401035776,\n                4823739530006398416,\n                4827190975852845184,\n                14050460958769218208,\n                14047972934133372160,\n                14043237056584784160,\n                14045246492667673408,\n                14048248890478175024,\n                4824033266785191440,\n                14041306932511527680,\n                4824201948414407648,\n                14035746306137014784,\n                4826608797457487136,\n                4825804477667002240,\n                14043458486220994944,\n                14039931440313117440,\n                4825680090629775552,\n                14038874845851296512,\n                4827633008316686240,\n                14049708630484377120,\n                4825969499993660960,\n                4827670181244286672,\n                14046073782105463360,\n                14032244290825528576,\n                4820333566335309088,\n                14001185667743121408,\n                4826877747219171088,\n                4810503667078950528,\n                4815969264516539712,\n                14046872477003629472,\n                14050474979328471360,\n                4823938516431877552,\n                4822696416038111904,\n                4825330112667078304,\n                4817726654421807424,\n                14049534591293289408,\n                4819622695209296288,\n                14036484605168766336,\n                14040477302657828672,\n                4827238155886872208,\n                14047555417981665392,\n                4823724132021569344,\n                14050451441238069248,\n                14043073339329737536,\n                14043085447748119520,\n                4822810482732216384,\n                4811736601657569920,\n                14040312215997210816,\n                14043598447053454176,\n                14045110381196836064,\n                14046819728878511344,\n                4823802266536485248,\n                4823865206430002048,\n                14049996697967239248,\n                14044341517830000928,\n                14049724357239109920,\n                4820791278730805472,\n                4825197387206310000,\n                4825827918262292960,\n                14044132766436536544,\n                14041268228672924032,\n                14047201944379888240,\n                14032735196274474752,\n                4809112834775911936,\n                4818003131852559040,\n                4802243099366344704,\n                14050182649627319328,\n                14047909231480107088,\n                4812137897655606784,\n                14049705564967831168,\n                14033976512708240896,\n                14027931435200795648,\n                4824337775157688944,\n                4821357004530333184,\n                14048717017850817536,\n                14048728071702574160,\n                4827670279212212256,\n                4824166125754012000,\n                4822765038570455968,\n                14037244243850448384,\n                4803066520386499072,\n                14042263836442361600,\n                4796999112019733504,\n                14046089892588727136,\n                4825179684649838944,\n                4823500156715498032,\n                14048848520911285376,\n                4818161119440225728,\n                4822495930307914208,\n                4826439904916876544,\n                4827100542241410544,\n                14050741909833905152,\n                14050347714602958160,\n                4822430311858673856,\n                14025262676021335552,\n                4824211547973375648,\n                14050974329678990624,\n                14042676524287139040,\n                4817472113258527424,\n                14047610723732217488,\n                14049946287408552704,\n                4803674739935610368,\n                4826087269076794352,\n                4823267877903293472,\n                4824223373330637536,\n                4801118048153637888,\n                4816149158066276800,\n                14049850220279978576,\n                14047638012785179888,\n                4827670034037597360,\n                4808599677359184384,\n                4825199449878897232,\n                14050497912851002416,\n                14041591445852857088,\n                4820637808789058688,\n                4811178381842720640,\n                14044426604533850592,\n                14048055342465439344,\n                4827641084103665792,\n                4823634593854848704,\n                4827135429311388656,\n                4811421929041603072,\n                4824264860205137088,\n                14049235855245066656,\n                4809994195048449792,\n                4812398687601299200,\n                4799737892864008192,\n                4812639104270494336,\n                4821783757551691904,\n                4823762185457199696,\n                14049391731391316272,\n                14043795866412463072,\n                4819163028129517024,\n                4826311011295981904,\n                14048864487497926672,\n                4814216756732007168,\n                14045091618957046176,\n                4820679856320506528,\n                14042133889935211136,\n                4804794786083888640,\n                14049247742810533296,\n                14033200741560652288,\n                14045367357496828544,\n                14043088686934028256,\n                14043594812964895840,\n                14041441548351936128,\n                4823459811836453168,\n                14042586208531821408,\n                4826111767986921904,\n                14047777047226615312,\n                4818990093768923616,\n                14040054768560402240,\n                14046476804754734560,\n                14043510144205915616,\n                4819940633648600928,\n                4823753316141818048,\n                14050881073941911744,\n                4824885911148528304,\n                14046698637174888160,\n                14047458767313100800,\n                4806398597017638656,\n                4813942231709614592,\n                4824232339651744880,\n                14048730126332423680,\n                4818714442459357824,\n                14049366445346794016,\n                4826312939247337696,\n                14048006279033415440,\n                14042782612048154592,\n                14048740776264692208,\n                14042881147351247296,\n                14042065059306533760,\n                4824096451484427520,\n                14050610853646856784,\n                14048397085743005952,\n                4813789006044855296,\n                4821801979214705824,\n                14043520699521108992,\n                4802840056561442304,\n                4823864102796060576,\n                4823525999223474000,\n                4824706085613404320,\n                4820295627894130080,\n                4823544168582647904,\n                4804994324847129600,\n                14043494716301654336,\n                4821997976030029024,\n                14047881418499838864,\n                14049388816561862624,\n                4825922794789602800,\n                14046012998850089856,\n                14038799663733567232,\n                14048053782188155056,\n                14050968423657705712,\n                14047423957593545168,\n                4820943035580785376,\n                4826980164489391808,\n                14045044462552138496,\n                4812702268248144512,\n                4821826116850782496,\n                14042649674563675360,\n                14047887038785699920,\n                4825847111692139040,\n                4825083159516926544,\n                14050282990916501840,\n                14047371306406156496,\n                4813624770547960448,\n                14041107897071280064,\n                4818179172666332032,\n                4806607923258368256,\n                14047972280383725456,\n                14047710483752884880,\n                4825566470899741280,\n                4827633472773783312,\n                14048895436467717776,\n                4826526829160628560,\n                14047821533715008400,\n                4826356385626289264,\n                4818623174480530944,\n                4820126229807775296,\n                4816559678143028352,\n                4826763985400077600,\n                14048591364024177664,\n                4824736719850303744,\n                14048281471776530400,\n                4815193594621049408,\n                14029521606013841408,\n                14046942316399706224,\n                14049141353658527552,\n                14048790086622898752,\n                14043365918462265920,\n                14035295414311566848,\n                4825513921554817664,\n                4825769449850664080,\n                14035287333485237632,\n                14039068086671078272,\n                4823804547424765136,\n                4823648732167960784,\n                14031442911559868928,\n                4796686174254595072,\n                4814678091057292928,\n                14048307304165791136,\n                4818885944091279936,\n                4827404505191560288,\n                4811071555081036032,\n                4821483615965647360,\n                4824590594527788928,\n                4823492577593275104,\n                4824474008253487152,\n                4821850323476073984,\n                4817773315630970752,\n                14048305156564457984,\n                14050699803713024544,\n                14045885427511678752,\n                14042798892269549728,\n                4822115307729688448,\n                14045145185572353024,\n                14047929644166078320,\n                14050114217549470640,\n                4823389360071748304,\n                4825285574720321392,\n                4824059602368387536,\n                14048566002654176976,\n                14048142872528450400,\n                4826379947123452064,\n                14047550402831225648,\n                4826313022610942096,\n                14038574554613437248,\n                14017387027466635264,\n                14045938320822787712,\n                14046924477127197904,\n                4820543124300843328,\n                4826984292151300880,\n                4820780794260132832,\n                4820311018256293600,\n                4821088497043329920,\n                14031285923684652288,\n                14050208023762320720,\n                4823154468781830496,\n                14024221014024868864,\n                4827545810710818544,\n                4803770425606217728,\n                4815833483577915328,\n                14047948581737379344,\n                14035830390547190784,\n                4826536315839360752,\n                4820373725338630752,\n                4823793970031509152,\n                4820612029768570976,\n                4807861656405345536,\n                4825785990719501568,\n                4823931299084811600,\n                4826487899239145904,\n                4824929895976138192,\n                4823687050699006352,\n                14035270889360028416,\n                4817085968707752192,\n                14047221565498090064,\n                4827608698755319856,\n                14022965825106377728,\n                4826023156446274000,\n                4822774230966204640,\n                4826662755377551888,\n                14045246278306345504,\n                14045210904717919680,\n                14050255574983527728,\n                4819753640331101632,\n                4817379519334513152,\n                14044090049767361344,\n                14048182622205039440,\n                4823988193033827344,\n                4826097815083829792,\n                14042726040813921536,\n                14049672100162419040,\n                14034763801898471552,\n                4812792188198274048,\n                4826961330126910000,\n                4822540034503062848,\n                4820897453194200320,\n                14048772375141864976,\n                14049181354669862912,\n                14050759248192090848,\n                14042834203342692544,\n                4819669466011728768,\n                4816083940476311808,\n                14048499021916310880,\n                4808405822684878080,\n                4824984268712939808,\n                4824118205980250352,\n                14050668975253147040,\n                14048707224589576464,\n                4827183255647135648,\n                4826151874233119008,\n                14046983094248641696,\n                14049301561251323280,\n                4818115213590563584,\n                14044673444400616992,\n                14047443406712906304,\n                14031027101722540800,\n                4824097134306830640,\n                14031316359760125184,\n                14046891485875874064,\n                14047220734626503520,\n                4821102982322572000,\n                14041247686193285440,\n                14047011331989882624,\n                4822142354097115840,\n                4826338805104120080,\n                4825404623007600288,\n                4822459353770083424,\n                4808020038486670080,\n                14050974077795101984,\n                14046790294847422416,\n                14049249972180910768,\n                14047241068169001024,\n                14050543760247434784,\n                4816902829497605504,\n                4805751018085177088,\n                4823948647611760176,\n                4827394871616739472,\n                14049674043206788736,\n                4825810122965890496,\n                4819911126381611136,\n                4815925995176838720,\n                4823371458677150352,\n                14042717089041157536,\n                14032455400918530048,\n                4827411287266581296,\n                4820652585886907232,\n                4825077981930103536,\n                4819555259465834080,\n                14040875238305174784,\n                4817766492375635072,\n                4822669011838381696,\n                4827466219917713328,\n                4827048618674559392,\n                4824897529043500592,\n                4824874891956432880,\n                4824200863393844464,\n                14040308079211922304,\n                4818370054817360832,\n                14042519095379283264,\n                4816653920016617472,\n                14043663008969520032,\n                4823511258765714320,\n                14039392752081414208,\n                4826036898486457840,\n                4825402200590193440,\n                14027938839169893888,\n                4823728344907461936,\n                14045664793858061920,\n                14038107196253930048,\n                4815301754434298688,\n                4825258778408648688,\n                14045857112140246080,\n                14043390724342676544,\n                4815849137218845696,\n                4826649084435575456,\n                4805958791929560832,\n                14048537968184792592,\n                14049091228753016912,\n                14036186466028463744,\n                14039261025174243904,\n                4826319658239455152,\n                4820065375866440416,\n                14047371851533913408,\n                4826106825619478128,\n                14048013833904203760,\n                4826035994409429280,\n                14015058383664095232,\n                14043838777961254528,\n                4824202454094419232,\n                14048351032218719888,\n                14046198107125211232,\n                4816121044939971328,\n                14049226478982094880,\n                4814848534768442688,\n                14038520142436121472,\n                14038246757609779968,\n                4826476906199083168,\n                4809462203309062656,\n                14047161664700644032,\n                4823376409147757712,\n                14046607631393091904,\n                4823242148841808416,\n                14044824267096326048,\n                4822786214030842400,\n                4827418661768953936,\n                14049422066138325600,\n                4814964056013024448,\n                14043383934020347520,\n                14047864846296047472,\n                14043513789210561856,\n                4820026682781140288,\n                14030960717774562816,\n                4811873976512967936,\n                14045044059703654624,\n                4823527423684777584,\n                14047528149116157872,\n                4823835791738285472,\n                4823896730670086000,\n                14049469981769096080,\n                14047832717898471024,\n                4825369438676787488,\n                4827191782322799008,\n                4825057605352803264,\n                4820756585569507040,\n                4808084823852582144,\n                14045051186973999008,\n                14047145195118349104,\n                14036643925099944448,\n                4814941830252912000,\n                14050973286917179088,\n                14042685647050006304,\n                14039065486163422464,\n                4821855905304276000,\n                14049924940458569888,\n                4825952151283509504,\n                14042961181224440448,\n                4804605176609667072,\n                14049913132331992832,\n                4824827504858597456,\n                4822773597922257984,\n                14040026980928625216,\n                4826779941577806976,\n                4815960767651894720,\n                14036631522244737920,\n                14039093758150116096,\n                14050549914943705984,\n                14051001522018262064,\n                14040313834729597184,\n                14048640518487531040,\n                4824010406447783472,\n                14048797096208923088,\n                4827168991544262768,\n                4821583906004469760,\n                14030744967826738176,\n                14049394615343466864,\n                14045782442650237664,\n                4825099293470491120,\n                4818957323014426752,\n                14038630476874445568,\n                4826603945834925680,\n                4826131358529539744,\n                14048236112110473024,\n                14051035493720566448,\n                4814630088838820224,\n                4820989018267810976,\n                14048246886449846912,\n                4826471765553943744,\n                14040209684948417984,\n                14048587924311158400,\n                4811772396496130816,\n                14038200391603697024,\n                14046633568261573248,\n                4822092685938815168,\n                4824621315641089520,\n                14047214195608651968,\n                4819010212900246592,\n                4809127000458138368,\n                4816728096965108352,\n                4821412288747976320,\n                14043488377933560448,\n                4823733951057920928,\n                14050089753909609680,\n                4822838457933772896,\n                4822803359764372448,\n                4819941737103643904,\n                4823747831448535184,\n                4827504327015385024,\n                14051051056718676672,\n                4824658099726637744,\n                4825411260933834960,\n                4823043002615955616,\n                14048910447521457632,\n                4811059987606457984,\n                14049685749077831520,\n                14048603028352395952,\n                4824144463675470288,\n                4827642918647245552,\n                14041182725316451008,\n                14043226584804013856,\n                4824376221296616048,\n                4824143174738645744,\n                4819544534746024288,\n                4819357397217110432,\n                4821475286766059200,\n                14051082127157782208,\n                4822856974009252576,\n                4817648785063775488,\n                14043881878702764224,\n                14041782930361304256,\n                4823512157551936768,\n                14022263306753145856,\n                4826711052921488784,\n                4819230706615873056,\n                14047975792163191008,\n                4811307173663393664,\n                14048415312568857584,\n                14031965883123745792,\n                4826855737456213168,\n                4808721559732013568,\n                4824860569998859408,\n                14045602767638314912,\n                4822539963520467360,\n                4823281430241485248,\n                4814075181149041408,\n                14027415616102775808,\n                4816630093244011520,\n                4817327204481828224,\n                14042632846383276736,\n                4827298496948764736,\n                4824216370439993664,\n                4824875883070530864,\n                14051056959248631920,\n                4827708255740512400,\n                14047390629272803008,\n                4824106277282720656,\n                14041731834229461056,\n                14046868792931710064,\n                4820199782790721888,\n                14039141845818192064,\n                4821697901999706528,\n                4826323686207068864,\n                4820217808752684736,\n                14038098233776185664,\n                4827630130636869408,\n                4827448787185918544,\n                4821686207487274208,\n                14039533057964429120,\n                4822772496609909696,\n                14045588520227685824,\n                4815382937617482304,\n                4827658186492441664,\n                14033455317055026432,\n                14043062359825904736,\n                14050602729445589840,\n                14046576125365225728,\n                14050140227265044048,\n                4821762868503691136,\n                14038055881211665664,\n                14045374949720539104,\n                14048805945577493936,\n                14046602041622258912,\n                14049220179107149040,\n                4825794462053744032,\n                4822937066223620096,\n                4826103508198147392,\n                4816628568434180864,\n                14040012361554649600,\n                4823389924688200752,\n                4822799382082689600,\n                4820433380855794592,\n                4823428114210331216,\n                14044965541929404992,\n                4826445539118309840,\n                4819727460073753632,\n                14017380542168121344,\n                14050542271589125024,\n                14035631237608591488,\n                4818306784191398016,\n                14048677121080367984,\n                4826633669332172336,\n                14042358042698410624,\n                14038281643458277952,\n                4801883021905472512,\n                4825729462398887408,\n                14047742637522574944,\n                4825684679274142608,\n                4825326523302221568,\n                4821931566862920928,\n                14046925427475931968,\n                4822622403057852256,\n                4824008119366823968,\n                4825412246870318496,\n                4814443743652895872,\n                14045570833795369760,\n                14036531238324141952,\n                4827540081414505600,\n                14047571202954087312,\n                14045816147737524672,\n                14046020380372169312,\n                4826644568044572352,\n                14035501766537650688,\n                14050162292280528352,\n                4823549234826249264,\n                14049116307292674608,\n                4817908452864409216,\n                4819538173329123424,\n                4807334874615023104,\n                14047278227632520080,\n                14050289513387397808,\n                4813757782267819520,\n                4820740961289909312,\n                14047555562635806992,\n                14049350418844801744,\n                14048109124623256864,\n                4825353928764013744,\n                14045323485318942208,\n                4823124540316155968,\n                4826945668128171280,\n                4812600737105759616,\n                14048087404177149440,\n                4821835838770093824,\n                14046833059605891984,\n                14044258118020022624,\n                14049870430866339824,\n                4816128397606519168,\n                4817398809169279296,\n                14044470459828437824,\n                4823295078466394912,\n                14038953643923701120,\n                14045511321756949312,\n                4822636253160679488,\n                14048945516375699504,\n                4820845912369012160,\n                4820253679365997824,\n                14040939353509877248,\n                14048884198746175328,\n                4818949865824361920,\n                14041209950309868672,\n                14044719304210324480,\n                4826777336089560928,\n                14043481839483825152,\n                4823821105684543344,\n                4822783255043803904,\n                14049281732649294112,\n                4825248220119865344,\n                4821333000366636672,\n                4823881024519973504,\n                4824913348784392592,\n                4818259024263396800,\n                14032450027187251712,\n                14046898721463804624,\n                4824299014303891648,\n                4821675762816370944,\n                14040144928351822784,\n                14044073059975003744,\n                4826456315736606336,\n                4814765110873584960,\n                14042341214254781856,\n                4825119399469174640,\n                4819306516110165728,\n                4823816956272018240,\n                14047804251838868112,\n                4825986531739597584,\n                4817786160319507008,\n                4824867828566145408,\n                14050880528513780384,\n                14043917704907488192,\n                14036130547913246080,\n                4822752087190713664,\n                4827700593398496192,\n                4819395347940782528,\n                4816389306831085696,\n                14046779516268288656,\n                4819237370757801248,\n                4800804938021174272,\n                14021563430131771392,\n                4825427096657175504,\n                4823502588867530832,\n                4818609538104890112,\n                4825769672844657456,\n                4826256650008051200,\n                4810852091300554496,\n                14050610256335269904,\n                4826795460142347152,\n                14041247008925071872,\n                14036220111299612928,\n                14048303144863796144,\n                4813598234548998144,\n                4819963595741132640,\n                14048295403856279360,\n                4827451367021476512,\n                14048783298885132032,\n                14047454131434375184,\n                14043315376803241088,\n                4823618581136908352,\n                14049607457175579696,\n                4819406522244055520,\n                4826742818956699152,\n                4826698289508748352,\n                4814501787864231488,\n                14043573233526010656,\n                14039917697807371136,\n                4824135265879415936,\n                14049660427355387152,\n                4794445503981279232,\n                14050723597514702832,\n                4815768972598708608,\n                14047732750054641952,\n                4820415654805654176,\n                4817206566278107904,\n                14045272609101309248,\n                4823715358250807328,\n                4825536955963543408,\n                14044509227807849568,\n                14047569418033310480,\n                14047787329280058480,\n                4824985852951599376,\n                4825562841097208784,\n                14050916608157128528,\n                4818400025255088256,\n                4823456282262852688,\n                4811105345790366720,\n                4811584187347914368,\n                14031811081013298432,\n                4818769723044596992,\n                4820460926610461664,\n                4815848166012674944,\n                4820275576080913664,\n                14050873393436755600,\n                4824425879580314144,\n                4824372893567186256,\n                14047251161746509632,\n                14044115041160724768,\n                4823373125817114352,\n                14049020671407397968,\n                4793387164187516928,\n                4824700864388409568,\n                4819469392294336320,\n                4813861749344003712,\n                14049355181746156016,\n                14038671019862213184,\n                4799453382307109888,\n                14047473053284071376,\n                14035074230730264704,\n                4789441156622323712,\n                14049750095640513424,\n                14028766377577940736,\n                14044362760215333120,\n                14048811573425986848,\n                4825496545540172768,\n                4818576125127002816,\n                14002317238196781056,\n                14038691195772444864,\n                14048069196267150368,\n                4822082814895215904,\n                4815803962309064064,\n                14027339280850575360,\n                4827135305534509968,\n                4814818124101868032,\n                4813345373256541824,\n                4817638647746724096,\n                4824373030474564128,\n                4825648653439495664,\n                14049345770806273232,\n                14049243472281443264,\n                4827145263229278576,\n                14049415116506242736,\n                4825623018156637312,\n                14049952156943357792,\n                4825949819055276464,\n                14039942214431684672,\n                14047552189685927520,\n                14049084433484129536,\n                14033341594490121216,\n                4827010506476908640,\n                4818630732592711360,\n                14049121257479556192,\n                14047006154293683296,\n                14048042991193559920,\n                4826073845437503248,\n                4826685808269654720,\n                4818829496363635264,\n                14050114020472834128,\n                4826462260087830016,\n                14049535119760430368,\n                4825546559926265488,\n                4824746670337213968,\n                4817523703688575104,\n                4827259814437917248,\n                14042747410057185984,\n                4826245894705949328,\n                4819833622760730432,\n                14048506405753240544,\n                14045152059638856576,\n                4826503398883375040,\n                14049807727116798496,\n                14050402678886026240,\n                4818933267441513760,\n                14042201592086615808,\n                14046054339890160224,\n                14047596103326278896,\n                4826476310251226704,\n                14045015639041745504,\n                4805512153501563136,\n                4818944150914046240,\n                14047536185839953536,\n                4814018051555214720,\n                14045569331692669888,\n                14031923946096272896,\n                4822744718018811264,\n                4813041749200906624,\n                4823739002983875712,\n                14050416099789506240,\n                4812532390170866048,\n                14044018607668059616,\n                4812594222363244416,\n                4824533827419506512,\n                14047945508894542128,\n                4825160357465678816,\n                14044850966048374560,\n                4821732301126715584,\n                14048781142659208512,\n                14045295458759605472,\n                14045747937482891776,\n                14049875747390274144,\n                4826263784714438848,\n                14045419806793099168,\n                4816847734945561984,\n                14050471988211152064,\n                14034027783913372544,\n                4811039969273479424,\n                4826061620360441520,\n                4826020893728525728,\n                14050695307263748944,\n                14040210327260752384,\n                14046066411706034592,\n                14048986597260644608,\n                14048680064231740496,\n                14034068088366424448,\n                4815880263468846592,\n                14050380068302458048,\n                14050712827672616992,\n                14041514622421967872,\n                4811808016357075328,\n                4821053480822345824,\n                4822084757716810176,\n                14034595235122872576,\n                4823335848888561216,\n                14046309064205824608,\n                4827192738319963904,\n                4815965535827510656,\n                14047161583949895072,\n                4825152738562587808,\n                14049524903595168592,\n                4807520680282924544,\n                14014952280814137344,\n                4819937128696271040,\n                4819690794432981504,\n                14044951262803899648,\n                14050536497208329328,\n                14050726497683702000,\n                14047157075416915568,\n                14050344951798916752,\n                4821294569716946336,\n                4826498010776526784,\n                4810410287348127872,\n                14050360672171799008,\n                14050276586573855856,\n                14049070813262950160,\n                4822104404044246720,\n                14041285704916763968,\n                4814510634132239616,\n                14048840496894155136,\n                4817115272425660672,\n                4826029144080926624,\n                14050516695415704000,\n                4813788770163077120,\n                4811712358643152384,\n                4822003623490960224,\n                4826349453877262400,\n                14020896018135100416,\n                14050264276156357936,\n                14042442432518723392,\n                4821177593899727392,\n                14048235998661582960,\n                4823046834486961216,\n                4802090634954478080,\n                4823234803757015456,\n                4823359912584577248,\n                4798138492814368768,\n                14037705807159493632,\n                14040634568070943360,\n                14048793475402835872,\n                14047495603926305968,\n                4825973246811017728,\n                14029372530558797312,\n                4827538921072190544,\n                4815697206367026560,\n                4825816215435880448,\n                14042516384431609856,\n                14048458169513524240,\n                4826538547916483168,\n                14045759692194711200,\n                4823356392169040144,\n                4826154477102249440,\n                4814700885952551552,\n                4826252183308865776,\n                4824974757520155360,\n                14048190175174438496,\n                14046780224363057888,\n                4824752379951631632,\n                4824273186611894928,\n                14048331081068352368,\n                4811220580560222848,\n                14042272568235610752,\n                14042424494305154848,\n                14032608611505335296,\n                4824025893487889680,\n                4824027966548269088,\n                4823590363937651008,\n                4814356610060848512,\n                4826838467660879440,\n                14044721877138426976,\n                14043470233755728832,\n                14049774152821533648,\n                14040265088001192320,\n                14047879387366574048,\n                14050614733786296464,\n                14050212279612829968,\n                4826312285210207712,\n                4823700262216313488,\n                14033586002042470272,\n                4802541170718196224,\n                4813907315216517376,\n                14035910052010553728,\n                4825800464099422112,\n                4820969367225557760,\n                14049038840578138752,\n                14049900830371037584,\n                4823901587034998032,\n                14048293997006090656,\n                4824182657273064800,\n                4823741987730466064,\n                14044992982005551872,\n                4823971155694406496,\n                4824012131354625936,\n                4810419183559103104,\n                14039232665577073920,\n                4823503002216754320,\n                14048479922122598464,\n                14045821635095769824,\n                14032619406190974976,\n                4826263072035324768,\n                4825908837174979584,\n                4824730955112305728,\n                4823300671091514016,\n                14049749821391910448,\n                4827419749602629664,\n                14043579820283284480,\n                4820173794904810752,\n                4824746101078912880,\n                14048347833062625456,\n                4823630418979936752,\n                14032149438537020672,\n                4816490517680249152,\n                4823710088697930928,\n                14037226153989010048,\n                4802851431372572160,\n                14050295528836265168,\n                14026534686342483968,\n                4823972278471873904,\n                14048831944521334912,\n                4823417418211768608,\n                14038631889625598080,\n                4824264453434680192,\n                4827657067963844064,\n                14049789466880124192,\n                14050953137808377712,\n                14038701017207764224,\n                14044652475405505088,\n                14050203842233181472,\n                14025668692392048640,\n                14047917883741893120,\n                4825378123742632256,\n                4819760767486964480,\n                4819637858563459552,\n                14042289796141181152,\n                4822726670269952192,\n                14047800645053939056,\n                14045752520235844864,\n                14031493106082523648,\n                4825502782200421728,\n                14046858860010065872,\n                4818326939641915200,\n                14050180241097002688,\n                4823528937802000000,\n                14047884438794068640,\n                4820556805226138560,\n                14042920202783121440,\n                4809119854597300992,\n                14043107100923736992,\n                14050197377518432128,\n                4813144646356519680,\n                14039157615251800640,\n                4820739080255024224,\n                14038530291968152704,\n                4817109036695824832,\n                4810269873700408192,\n                4826374684931792224,\n                4817981061335538688,\n                4825609053903741808,\n                14037951083207326784,\n                4821246643305950592,\n                4823998090620773872,\n                4825628602898931552,\n                4814358593247632768,\n                14047233835690411136,\n                14042671400751724288,\n                4824984488789790192,\n                4827641642617006720,\n                4814595523582769856,\n                14041621114572618240,\n                4822715435316322784,\n                4821281605523032800,\n                4824981848572901328,\n                14049628629421054448,\n                4825117417531266176,\n                4826828645496426080,\n                4810521467321621888,\n                4801772399391783424,\n                14046195818203651680,\n                14048173351184043680,\n                14040075043384437952,\n                14034535372035786240,\n                14037913214565410048,\n                14050613723821736016,\n                14047938634625013504,\n                14043623817771747616,\n                4811112362530416896,\n                4817290454357732864,\n                14047083115582902832,\n                14048271140227889840,\n                4808090717497775104,\n                4827387335383872992,\n                14045501921018674656,\n                14045825954815159392,\n                14047154605124648896,\n                4823410539906505200,\n                4826164532708620224,\n                4823734664880947200,\n                4826171033707836768,\n                4824788422668330048,\n                14047514839978030048,\n                14049417132519270272,\n                4826140779517619504,\n                14049855918019013904,\n                4819371684235387584,\n                4826219031919154640,\n                14045783381604152896,\n                4811333879680225792,\n                4825623414536728736,\n                4825032680706994608,\n                14048998262597218640,\n                14041631406053670848,\n                4814866568511247872,\n                14035959184549976832,\n                14051075047855447584,\n                4826457870499446768,\n                14049415331188041424,\n                4814151555245021952,\n                14043745520358470976,\n                4823986348588245488,\n                14043305856018952960,\n                14040454147282728448,\n                14035536714113912064,\n                14027874297207997952,\n                14047733285989575024,\n                14038152840867900864,\n                4825529851820564160,\n                14028413230963145216,\n                4812190226581242112,\n                4816268091817225664,\n                14030328950209231616,\n                4822172364975014240,\n                4826081343803695520,\n                14050972247282182032,\n                4821498934439557248,\n                14044636428436912448,\n                14042626498947446112,\n                14047352162255241760,\n                14047706225166302256,\n                14049234248672795568,\n                14048036411601144960,\n                4822851661565697440,\n                14048222720729285440,\n                14045547016399182688,\n                4824012405606903120,\n                14049548482211983232,\n                4806786551763581440,\n                4820100274329244288,\n                14048887797359332288,\n                4826869046890293072,\n                4826035734992846032,\n                4825550577096920848,\n                4819552821142361440,\n                14050264143699670816,\n                14050299240317652864,\n                14032787871273484288,\n                14029310519282707968,\n                14029772401589264640,\n                14036857108884439808,\n                14042685422861408384,\n                4826671868544077408,\n                4824393569072236048,\n                4827433708726031328,\n                14047445532620181328,\n                4824617460995290000,\n                14048421672400906032,\n                4824275415644965984,\n                4818106584495411584,\n                4811038908479089024,\n                14046976420087815072,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n        SerializedFFTContext {\n            p: 4828632856727126024,\n            pinv: 4385184981168167747,\n            mod_data: ModData {\n                n: 659706976665601,\n                ninv: 13035699145421368753,\n                norm: 14,\n            },\n            primitive_root: 11,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                14022680714634054656,\n                4820712691211757408,\n                4819249779558219328,\n                4814848747229190976,\n                14022729685023594496,\n                4819165647952025408,\n                14042771579763669792,\n                14042347485588792416,\n                4810322147605490176,\n                4819746801432125088,\n                14045876426525876800,\n                14045422124162931744,\n                4822911455828147456,\n                14040501214504649280,\n                4818246507580775360,\n                14038295065953428160,\n                4821876636497526944,\n                14046070764013118464,\n                14035753502278090368,\n                14038717782756693184,\n                4815949059311277952,\n                4822672929233018816,\n                4820769715554402368,\n                14040796714214300352,\n                4823374512110701792,\n                14040765101311988096,\n                14037964577281404480,\n                14043374672138121056,\n                14029609600473224192,\n                4820470819738241184,\n                4817534789551762112,\n                14041395260030327168,\n                4823329126402176672,\n                4821463746447382432,\n                14033287482559375872,\n                14043057443239284960,\n                14047337337290524352,\n                4823271721378525536,\n                4823103375123745344,\n                14034740446563932928,\n                14040343733629255616,\n                14037159334362785792,\n                4815131337730935872,\n                4819499553550657824,\n                14040361778298498304,\n                4816889594662260544,\n                14045507617035855776,\n                14036692362406926848,\n                4822010001847494400,\n                4821374737789289472,\n                14045139395684334368,\n                14043715882869823872,\n                14037049689699825024,\n                4802708576056335360,\n                4824028972484406336,\n                14047303564099489504,\n                14047434029246607456,\n                14038094888762036160,\n                4821847493476766848,\n                14044077935175739104,\n                4814535035013448960,\n                14032569346990249984,\n                14039102684246736256,\n                4822516397464357760,\n                4822393846196709536,\n                4819968889018665632,\n                4802111971169878016,\n                14041330249657258752,\n                14045847829584049344,\n                4820038440796376416,\n                4820040481785133088,\n                14046920661922258320,\n                14040268282486967936,\n                14046522987992208384,\n                4823683088334476528,\n                14046746121206313248,\n                14044940456568775744,\n                4810734461243463168,\n                4816744108380203904,\n                4823527173842664176,\n                14046857810758224752,\n                4821062067491491936,\n                4803443929230962176,\n                4819717550856432384,\n                4824084669763567392,\n                14043025870045175936,\n                4818747919521542848,\n                14038502710830179136,\n                4823386796571280784,\n                14042327815495895840,\n                4822111759078927008,\n                4814977299231950912,\n                4817588110536056832,\n                14042279251053151712,\n                4821840109955956096,\n                14040653630420899264,\n                4817930989932559296,\n                14042622665069547872,\n                14034721616857048064,\n                4820074523136886144,\n                4823707295292562272,\n                4804482854961802752,\n                14043161980881380672,\n                14044718689173440288,\n                14039631036301203904,\n                4819820497643926656,\n                14039994898299412160,\n                14046909480325279984,\n                4806584974209728512,\n                4819109486192351232,\n                4824112834507130432,\n                14044689868337704224,\n                14039765492989067840,\n                14043041832818968352,\n                14043727011455858880,\n                14039034406029932352,\n                4820811091750771168,\n                4811003096932815488,\n                14047111264276690432,\n                4821175079436430912,\n                4817287546362851264,\n                14029505646696510720,\n                4823484453479471888,\n                14043740279272244128,\n                4817944497882481792,\n                4821050694690922208,\n                14044521596829420544,\n                14044790036724851904,\n                4821982659053236288,\n                4814547529164107712,\n                4818740620071045760,\n                14043968098221152352,\n                14047287577677973056,\n                4823601395070219872,\n                14020765748402148352,\n                14026516655440028672,\n                14045047884142750080,\n                14044993358829835040,\n                4809209870993103360,\n                4811412376222931456,\n                4811886058664630272,\n                14019215786600765440,\n                4823462958103153136,\n                4823290887582221664,\n                4815895052336918592,\n                4806919841636668672,\n                14044463654034514112,\n                14042255812751477280,\n                14044086488879062528,\n                14028218328931315712,\n                14043039730882272640,\n                14046925510749453168,\n                4823577691849640512,\n                14046643057261962208,\n                14038438719733707008,\n                4817916262237805760,\n                14040252588598165760,\n                14043202199643897120,\n                14042361669199462304,\n                14042613428712936960,\n                14032438839976769792,\n                4815469530610619904,\n                4819138093917083328,\n                14040352515635012544,\n                4823883037538166208,\n                4812470229139847680,\n                14040507027709688192,\n                14038639940949316224,\n                4817983541071607168,\n                4805509274672941568,\n                14035408214278025216,\n                14035036614773646464,\n                14035739355815424512,\n                4809312053682963456,\n                14038282086058492608,\n                14044014777021488256,\n                4817945462026109248,\n                4815657952001174016,\n                14044470231760413280,\n                4822556559184983776,\n                4819731033665559360,\n                14047059349763525248,\n                14029206869563360768,\n                14046309220833051808,\n                4817602434335160896,\n                14047114861219612880,\n                4814650343617271936,\n                4816193752358088896,\n                14042464035020253472,\n                4821849412880885248,\n                14035428022684829568,\n                14040069398432507520,\n                4805383728751683840,\n                4809882104865608192,\n                4823341438746873568,\n                14047103598397220528,\n                4820262523631462304,\n                14047008368067779072,\n                14043092783527359840,\n                4823704730762207056,\n                4823686600044731456,\n                4820535842771284928,\n                14047289388162766768,\n                4821441019148283232,\n                14044132007970833120,\n                4823592241207882784,\n                4809097044155193600,\n                14036553207955736064,\n                4809170343200448768,\n                4823690651786384848,\n                14045568788876540032,\n                14039839023848964928,\n                4815495658276152384,\n                14043142510096238880,\n                14044667661348971520,\n                4804377184246858240,\n                14036559547074397056,\n                14028947537588717056,\n                4819939632983572832,\n                4817123622609749632,\n                4819758823408731680,\n                4822922983748985248,\n                14038763342059353984,\n                4814548196696302656,\n                4814595859187778304,\n                4814293307734695552,\n                14031451914127218176,\n                14047454277665020400,\n                14044547338072658336,\n                14042676013325982400,\n                4823950722660703104,\n                14035859784584876160,\n                4821711633490773088,\n                14039137336233276864,\n                14022833524913299456,\n                4822874552451964928,\n                4823007173792612640,\n                14038119426893418560,\n                4824117245655304768,\n                4816205206434565952,\n                14037070723215900800,\n                4818368252873733312,\n                14045919480036429120,\n                14044749570872477728,\n                14043364308773138592,\n                4821660391531334880,\n                4820256454065847104,\n                4820231442658191552,\n                14043934164815453120,\n                4811819433064607232,\n                14042356227007051488,\n                14029094423779336192,\n                14037660794830753024,\n                14036996017993602816,\n                14041046522910001024,\n                14047116219678424336,\n                14026177626017395712,\n                4819050027016169728,\n                4823781462658225664,\n                14047129250563115648,\n                14031851399433750784,\n                14042146160743595648,\n                14039974409580301248,\n                4815403280020890240,\n                4822328580842176960,\n                4818040911621798208,\n                14041710250584451968,\n                14046315908512876320,\n                4815464798232036800,\n                14040808794125169408,\n                4822016293584513120,\n                14043308576447945120,\n                14046693652007237440,\n                14045577994213000000,\n                14047380616614746368,\n                4808718582135990272,\n                14044982733111443008,\n                14038238938183694336,\n                4823738603176979456,\n                4799411612127715328,\n                4821047899071022816,\n                14047490865833513408,\n                14044035091755091712,\n                14042410880368495520,\n                4814756149736951360,\n                14047007315568217152,\n                14022376323223775232,\n                14041707679464380864,\n                14041186908778767232,\n                4823078632967598208,\n                4823447984648066288,\n                14044699007395880416,\n                4820524093171390432,\n                14039322323836094208,\n                4816303409342446080,\n                4811196517421352064,\n                4812607645670833152,\n                4824118109127387280,\n                4822486706433366048,\n                14010746719618039808,\n                4812813077972245376,\n                4819912942786780384,\n                14039393147862990208,\n                4809261358601790464,\n                4802578457651204096,\n                4819055953343625216,\n                14047306806092835520,\n                14045653526069814496,\n                14044582021905637600,\n                14039755126784276352,\n                4823389216414505968,\n                4811203070307879296,\n                14046226136989021888,\n                4814472113709883520,\n                4810905083817094144,\n                14043393148676703840,\n                14039797527143377088,\n                14044995974956452096,\n                14040477317544600576,\n                14046269344125844416,\n                4808030733178213888,\n                14042348121230718816,\n                14033346594218093696,\n                14042637836856688512,\n                14038943331040251200,\n                14037114248785428992,\n                14046807794943784000,\n                14036201226957750912,\n                4823895618915669072,\n                14038556340029466368,\n                4822956377903820992,\n                4824069573376912528,\n                14043135066660958176,\n                14026604451271281152,\n                14038363321840365120,\n                14043693197255255296,\n                14046883884765863664,\n                4814912756393204480,\n                4814069497504095360,\n                14034051250771085824,\n                4822820909601806144,\n                14042100848433460608,\n                14036500234451803904,\n                4816568041285323008,\n                14045721196433563840,\n                14047090746736507552,\n                14047215162764973408,\n                4822789089314390496,\n                4822083451364898016,\n                4819881468059480192,\n                4808515797837834752,\n                4821483981221378048,\n                4816320040953219072,\n                4817573936067886592,\n                4818410623036340224,\n                4815636977908845312,\n                4811763508050834176,\n                4803173088059140608,\n                4813852541820428032,\n                4818165827782973696,\n                4819013970154393984,\n                14037813247431430720,\n                4813242321747934592,\n                14040296650756964736,\n                4822457889284067840,\n                4814142798008455168,\n                14044750594843946528,\n                14047161291673777728,\n                4810329483713191552,\n                14036074716735492736,\n                14038171602412163456,\n                14039941072745809216,\n                14042477070087347168,\n                14043210864203278592,\n                4815105309413393024,\n                14007481333521776640,\n                4818975111574063968,\n                4813357892706549248,\n                14047116615475173248,\n                14036506338757299200,\n                4818008438152944960,\n                4818421194522831808,\n                4813408541245848064,\n                4810675467103056000,\n                4823711764081777168,\n                14045282608274164736,\n                14046437406945342208,\n                4789675703982116864,\n                4814226727953549184,\n                14045480468658618560,\n                14046643121006720032,\n                14043316343048022944,\n                4819582568191330304,\n                4820697580024568768,\n                14026400404284275712,\n                14038884436626239488,\n                14039793353905564416,\n                4821882382221644416,\n                14046989453609375872,\n                14028608346519543296,\n                4813856374925788928,\n                14046933272341906976,\n                14041733291849840640,\n                14046193338964718272,\n                14029749416615012608,\n                14008667499160313856,\n                4821031463613096032,\n                4821094240267533440,\n                14043028777688811840,\n                14045910274105611648,\n                14023955125171160064,\n                4822418739057433088,\n                14046787177892432176,\n                4818187363512031104,\n                4817743609349753600,\n                4820055930851207104,\n                4819847234491765824,\n                14044863838920091040,\n                4823670922938214496,\n                4822764973916805024,\n                4808832116202588160,\n                4811684220456504064,\n                14046293438160036288,\n                4820537689466184768,\n                4821733830774473824,\n                14046612066301586720,\n                4817532712770942848,\n                4822685744375756608,\n                4818759157899174016,\n                14028724347357063168,\n                14041830198129768448,\n                14036344666610436608,\n                14040323179555480128,\n                4823746133896211824,\n                4823221511981163520,\n                14046699740007808928,\n                4822957187907335168,\n                4819405699738379264,\n                4819438318464273952,\n                14044810232557298176,\n                14046849905972347296,\n                14042248634109431904,\n                14044532864438065120,\n                14035136877280465024,\n                14046393352858336352,\n                14039701827418801472,\n                4822716368445853280,\n                14039536497402850560,\n                14039334523410160576,\n                14039797141231677696,\n                4823113715985570976,\n                4817747628290547008,\n                14042812082446271136,\n                4813729698985979520,\n                4820356605140550432,\n                4809252862094656256,\n                14046568441523315360,\n                14046310566391754208,\n                14039624299785957056,\n                14031889117283188224,\n                4819205760061489344,\n                4821266245190442176,\n                4823573256897809472,\n                4818230664775002432,\n                4761382017729822720,\n                14046321782092180224,\n                4823991330419029856,\n                4816981208511728640,\n                14046280676724399520,\n                14043911203190585728,\n                4821722909307034688,\n                14042336350419369344,\n                14043081597176352192,\n                4822238989999752640,\n                4813323622230135040,\n                4819479969178453920,\n                14046673775195096576,\n                4822746454817367328,\n                14037940523917228480,\n                4808218210793240576,\n                14044911857947482528,\n                4822632405562891840,\n                14047024327850261760,\n                4824080957566290800,\n                4823552086410294080,\n                14044777830772381344,\n                4819702949337907136,\n                4816086063520677824,\n                4820519969818823072,\n                14022872577629170688,\n                4818383745947697728,\n                14046166513966093184,\n                4820058378580902080,\n                4817916270469662336,\n                14042617394985060544,\n                14044596089363140672,\n                4818985421984799520,\n                14046732240460260720,\n                14043462475813731616,\n                14037355457397961216,\n                14044794232562871456,\n                14028293322124921344,\n                14045636679319878208,\n                14042481863718810368,\n                14047247491105393792,\n                4822458750819063168,\n                14030659778785043968,\n                14043833472166895904,\n                4822313669184477824,\n                4817899473009487232,\n                4803788293057803776,\n                14043941681394536320,\n                14042373463191821120,\n                4823404759023487808,\n                14044780914684384704,\n                14039268276222143488,\n                4816042300707062784,\n                4815446149316687744,\n                4815491395841920000,\n                4820973370017418144,\n                4822119801271255520,\n                14021589681635712000,\n                4809446134923886080,\n                14042718051431356544,\n                14044063165685195392,\n                14047485897162058976,\n                14037879433503924800,\n                4823914357040724688,\n                4824033705821649728,\n                4814823466447710592,\n                14041904958291630208,\n                4822608577643321216,\n                4800910610103177728,\n                4810947297500713728,\n                14030233436446985216,\n                4816694488678761472,\n                14047137913047852144,\n                14045343311827569088,\n                14046848596280512176,\n                14040462067435045888,\n                4823066754800109952,\n                14034421534334573696,\n                4813235632454499200,\n                14032885324730906880,\n                4822273038293927936,\n                4822254081173935840,\n                4820958755975331808,\n                4824032060406757024,\n                4823094704385835072,\n                4824060563548864720,\n                4819420339598795552,\n                14015805132095299584,\n                14046079983205059744,\n                14036559663417226112,\n                4822080860488830752,\n                4810201547902970112,\n                14038866180848913920,\n                4820677051769647456,\n                4814235200910405504,\n                14046824661375750416,\n                4813588912007940992,\n                4823694568251371264,\n                4814207448614980096,\n                14031704389383817216,\n                14033853494219613824,\n                4817390739517288000,\n                4816645688451000704,\n                4817749826578561664,\n                14038517610490541952,\n                14046205303469157856,\n                4822230337757929376,\n                4806957836876844288,\n                14047498789056107680,\n                14047189667303467552,\n                14039785431304624192,\n                14044124348115237120,\n                14041724116931741184,\n                4824121870661311472,\n                14035079847618938112,\n                4821999107498541792,\n                4822773613800314112,\n                14041787110701319616,\n                4813997316342108032,\n                4819537219386131840,\n                14036982043067753344,\n                14046655010716349792,\n                4822540567279174240,\n                14047098073610125088,\n                14040232473459531648,\n                14038233256023442496,\n                14039302519583481600,\n                4820546647750909184,\n                14047226175328405440,\n                14035852088016843520,\n                4823376094355464192,\n                4823037186739420256,\n                4819382521750075488,\n                14046976765202420592,\n                4815425452451253248,\n                14043886071298983872,\n                4821625471008554560,\n                4816844333957271296,\n                4822125858149512608,\n                4820834062174058272,\n                4823949622974739104,\n                4823631853929970560,\n                14046756020457365712,\n                4824072775279631360,\n                4823157691523098624,\n                4819412561842715712,\n                4821711787860576128,\n                14044205723979976352,\n                14042848964047274016,\n                4815595288338732672,\n                4811290605164790016,\n                14041295940152597184,\n                14044152556144923200,\n                4823481078326404688,\n                4819796360145091808,\n                14040232337328770752,\n                4819096611732257536,\n                14042271352187171392,\n                14046341208751328192,\n                14043259704623333984,\n                14039416569433984704,\n                14035259146595790848,\n                14043597587962598752,\n                4823794061722747824,\n                14045394402041258688,\n                14041664318255492992,\n                4824011715294152144,\n                14047182850784171200,\n                4818379432968531200,\n                14040056253711039936,\n                14024755683593077248,\n                4815982009750323136,\n                14043165812760657152,\n                4799166218741269504,\n                14046085610239732096,\n                14039424292079066624,\n                4822274694427205568,\n                4794358408973070336,\n                14046958810460073616,\n                4807447807406093056,\n                14018394255620046848,\n                14038476758997304448,\n                14045724555017076864,\n                14037302522624510464,\n                14046928604667483840,\n                4822554717644761920,\n                4822878774813976544,\n                4820705277458645824,\n                4816107349473405248,\n                14043642712354907264,\n                4823245056493711328,\n                14045373716489657888,\n                4819180148419784064,\n                14045163509224132768,\n                14043817140837482112,\n                14025791069688133632,\n                14044488205247893152,\n                14044017675137152064,\n                14042732588460381504,\n                14046304029965461376,\n                14045089470708041568,\n                4823369668689471696,\n                4821220610727702432,\n                14046911270526342864,\n                4817579335270385280,\n                14044691267028319104,\n                4821227064853461600,\n                14042344892263778112,\n                4820720974439910368,\n                14022766134604633088,\n                4823269281011446624,\n                14043432316949895392,\n                4818894263721311456,\n                14040377717009404864,\n                4822647346481329696,\n                4821699515430018496,\n                14028077026423474688,\n                4817557932702790912,\n                14044383800484257120,\n                4823665637029237792,\n                14043820798354006304,\n                14033076679602080000,\n                14042327622374391840,\n                14047260405945129072,\n                4820636860018443168,\n                4812191441784315904,\n                14037917772226225664,\n                4823899439311424624,\n                4822033578944059360,\n                4805966167502031616,\n                4823466961012864272,\n                4821054860756024096,\n                4822527541706653088,\n                14043838404532236544,\n                14044446149810642400,\n                14044031800027279456,\n                14038711459048334080,\n                14040041961306825536,\n                14026336402234876928,\n                14046883837249453168,\n                4821909097932492480,\n                14044544088370095456,\n                14043760552704173152,\n                4819649833376765216,\n                14036524335305462400,\n                14044235953127967136,\n                4819888308368959456,\n                14042513543893949920,\n                14046255556696021664,\n                4821017447808372864,\n                4808391523058194688,\n                4821246106167148672,\n                4823794142716503680,\n                14045609308200076128,\n                4814322361633144576,\n                4824082437111424176,\n                4815242360691093952,\n                4823489924531879488,\n                4821793360149654752,\n                14039529196834787968,\n                14042931495374359168,\n                4822207043214631296,\n                14045889141034063712,\n                14046934810695187264,\n                4819233873517202176,\n                14042572688586014080,\n                4819524480379887360,\n                14042373285444997952,\n                14046166930287668128,\n                14044038401318121632,\n                14046242716416552608,\n                4822019036249625728,\n                14046128892999401376,\n                14045659384835308640,\n                4821618996238505920,\n                14033321836878275200,\n                4817105381495746048,\n                4819421212509030368,\n                4815511896646205888,\n                4819291732207164864,\n                4814623623362994688,\n                14039791898298758336,\n                4822656176961099104,\n                14045058409198700064,\n                14043439769165685216,\n                4821786513163802912,\n                4800070130247992320,\n                14044480442594057536,\n                4815023689511117760,\n                14046856298904896416,\n                4824060463334351920,\n                14047011728189053376,\n                14047449392218806304,\n                14043072636762376224,\n                4822795979625324576,\n                4820848953200563904,\n                4819556404437545088,\n                14033614011256829824,\n                4814374893833611840,\n                4793139648904071168,\n                14035335573727593984,\n                14045461480156290176,\n                4821206998364986848,\n                14036922699826802304,\n                4815554604340740096,\n                4821636644830473504,\n                14041650945068569664,\n                4820939767798377632,\n                4797656916403511296,\n                14044697667089888544,\n                14041246024578569472,\n                14036993870463762688,\n                4820897320492639168,\n                14041481775051314560,\n                4818531097727857024,\n                4802588126438515712,\n                4820182915473146272,\n                4823074603746320864,\n                4809145847237585920,\n                4798783142015828992,\n                14034719666053115008,\n                4821703675051402336,\n                14044849592187605344,\n                14044941850175584480,\n                14046561159826992032,\n                4819677494563634112,\n                4810867687044574848,\n                14033511170465564416,\n                14040107576756789888,\n                4820288758912491072,\n                14034222784986415488,\n                4823515507520839376,\n                4813366639822757248,\n                4816487660728711040,\n                14042487217769909152,\n                4819606658237363200,\n                14045967413130617856,\n                4818970528373539296,\n                14046867761976906928,\n                14047241861057974000,\n                4792806782283632640,\n                4823923121266641920,\n                14038122342859874176,\n                4813931524406361344,\n                14040955554324451136,\n                14033046759452960256,\n                14045025153353754464,\n                14041824314132611456,\n                4813410108420516864,\n                4817493423868752000,\n                4818945471047610784,\n                4811916798496423808,\n                14038170097712571712,\n                4807210308010360832,\n                4818999971588965056,\n                14044720083864563904,\n                14046063409632212640,\n                4820593621986151840,\n                14042121142850950464,\n                14047444358045394192,\n                4821242933447912640,\n                14045701450705743264,\n                4822608652257225504,\n                4816121186125800320,\n                14022641400520940544,\n                4822235577594344576,\n                4820818878147718112,\n                4821813656728771584,\n                4823393811335520032,\n                4812662589977544448,\n                14043120786420024320,\n                14044571178147012032,\n                14045933182683827680,\n                4822521203257907872,\n                14047014566700721312,\n                4820797329466096288,\n                4821192265000701216,\n                14041102899453264256,\n                14037126305492183168,\n                14047022188183292544,\n                14045829041139578336,\n                4820004151318876032,\n                14039676569325289472,\n                4821354969070576544,\n                4822900322234764608,\n                4820924227351107360,\n                14032570190573244416,\n                14044144349825143648,\n                4817350408279433280,\n                14038746639715655168,\n                14035537784849444480,\n                4814744030119768320,\n                4819523815871146112,\n                14045502353302404576,\n                14045699119794785376,\n                14043000798510653248,\n                14046968012069164464,\n                4819622361926939712,\n                4820074837716972864,\n                14047341243289429632,\n                14025309665505894912,\n                14024701743558333440,\n                14040181442697290752,\n                14028808678629110784,\n                4797292785021455360,\n                14042095035215234944,\n                4816550808046938944,\n                4823356199020518400,\n                14035869243089819008,\n                14036210028218821888,\n                4807279985289316096,\n                4823069624276870016,\n                14044943822533434848,\n                14042776510329650464,\n                14042499180403934784,\n                4821373270265770016,\n                14045786588700925568,\n                4811914484471932928,\n                4806613225654606336,\n                4823768609204563072,\n                14043897965989753728,\n                4818293755620989760,\n                4819859700468330784,\n                14004801607202897920,\n                4824017513547630112,\n                4823978802077757072,\n                4811506598032761984,\n                14037299078074427648,\n                14033235220325517184,\n                4815739045043193920,\n                14047277174567657712,\n                4823748268781303168,\n                14028718654629710848,\n                14044316463565045632,\n                14046765516897655056,\n                14042310880665501024,\n                4823791661560914960,\n                4822387308009871968,\n                14044780598653110336,\n                14044400072611719232,\n                4820740915992458016,\n                14040494265726269376,\n                14047205254244982176,\n                4818225526970177216,\n                14037900575915157184,\n                4822219160874755488,\n                4812692093784145664,\n                4821715452497307008,\n                14041166205603164096,\n                14044565547953054624,\n                4814617644740894528,\n                4822939032789664928,\n                14034608707708412800,\n                4822866853207902368,\n                14047127967245985040,\n                14046106961386103328,\n                14045582860543927680,\n                4820173024944134688,\n                4804784091795986432,\n                4807935949926320896,\n                4809085326616123648,\n                4820758306097450560,\n                14047037595707218688,\n                14046994894871673984,\n                4814773844798992000,\n                14043250224867192320,\n                14039116892766709312,\n                4814623480008647296,\n                4823349351674771072,\n                4821853865904467168,\n                14043257453802491904,\n                14043384698312157248,\n                4808004162349238528,\n                4815741349821026624,\n                14043176519562033824,\n                4821952685361690304,\n                14042628498912668672,\n                14044188011937121472,\n                14046093904052350176,\n                14041501491335280768,\n                14042469499688583136,\n                4810436757785617408,\n                4818662393499736768,\n                14046723329011646720,\n                4823443837227239104,\n                14045366633413788192,\n                14046968887098845280,\n                4814911163004364544,\n                14042447825700077568,\n                4798283492030341120,\n                14027072700842153984,\n                4820194441192439616,\n                14041711858580995264,\n                14038069383084359296,\n                14026590278867922432,\n                14046896907735844352,\n                4823803140673402448,\n                4815776664945193024,\n                4820261429951379776,\n                4823226737069167872,\n                14040117196345040320,\n                4819609571130025696,\n                4823557386918859584,\n                14044691078301435360,\n                14039872306803966656,\n                4820136525520219488,\n                4820440095280437696,\n                4807428604124868352,\n                4818200200854840384,\n                14043078065489555040,\n                14046851247370771712,\n                14042615905046766656,\n                4819419559074095648,\n                4819112756380643456,\n                4808948302827880960,\n                4820130107936008704,\n                14036698063470440960,\n                14046903312288905408,\n                14026588781053335040,\n                4816269192506426624,\n                14045850795683210432,\n                14039252365685061440,\n                4810020597805412864,\n                14045356094921604160,\n                14043097288932800896,\n                14044665434266344256,\n                14044562962925736768,\n                14044516530214969920,\n                4823414511899322128,\n                4820204739225923008,\n                14042542236139031776,\n                14047100595192298144,\n                14046729058137353536,\n                14044796766035074912,\n                4819966076551926592,\n                14031825281874523392,\n                14041096210268183360,\n                14039544134449878528,\n                4823383796766809392,\n                14047492982535475648,\n                14046301091467990368,\n                4823862562924047296,\n                14047249839214803536,\n                4821006253017118080,\n                14040428187817643456,\n                4824005993688368320,\n                14045138135432056544,\n                14046446365037435488,\n                14038935721085282368,\n                14047471169940503792,\n                14033495835719313536,\n                14042798896398731776,\n                4813157751014127488,\n                14044474447533584000,\n                4819567554994267392,\n                14040431189854779520,\n                14043090970797978144,\n                4820463635250632032,\n                14040961570653283520,\n                4785209584446308352,\n                4821073353742914272,\n                4809100580981404928,\n                4808607489358899200,\n                14042846816211251424,\n                14030700313171563776,\n                14046720907453635680,\n                14042920768275761344,\n                4816644796496144640,\n                14042497014721546976,\n                14028145922326999040,\n                14042465958683418368,\n                14044255534365527392,\n                4822617211641397280,\n                14043122364769447616,\n                4805631511629792256,\n                4810205474183461376,\n                4819606117760729376,\n                4819049237311854400,\n                4819638313986968992,\n                14043789396857654336,\n                4804022758989834752,\n                14040964261201084992,\n                14036392944012153984,\n                14038391049626679488,\n                14030847539825835264,\n                4822839210649299776,\n                4819499685647439136,\n                14040253761405135168,\n                14032606430339451648,\n                14045174730775718624,\n                14029735463763564800,\n                4823038293124335712,\n                14033238609233370624,\n                4821316923062445408,\n                4823074215882770208,\n                14045908717898737824,\n                4802781908572011520,\n                4817384894172195072,\n                4818144007497931136,\n                4816665432062572160,\n                14033354940862010880,\n                4823914536535917280,\n                14044295144949067360,\n                14035870561435002496,\n                4814539839156746432,\n                14043215015797880384,\n                14047315189023095792,\n                14035369152291028480,\n                4808681504791904768,\n                4822493077036618048,\n                14033266594244150272,\n                14043932721849060672,\n                14042948378965998240,\n                4822978822084341600,\n                14032741532056719104,\n                4819249622307109536,\n                14044748600480618240,\n                4817576212678360192,\n                14046405478477518496,\n                14046847117436838192,\n                4820149646918266304,\n                4823553674312880880,\n                4815301385385155520,\n                4822312140696970912,\n                4824032081417544704,\n                14044992801371797696,\n                4819349535848911936,\n                4823584106532590608,\n                14031880114206224640,\n                14047329892044412320,\n                4813463750358693248,\n                14043127682725156128,\n                14042550868905487392,\n                4819526262316173056,\n                4823492042802582928,\n                4813747665811519744,\n                14038408769714612864,\n                14025515924506802176,\n                14040206776833417408,\n                4822275175649790528,\n                14041651661965319808,\n                14045853943419993056,\n                14043505194734274752,\n                14039929575754856768,\n                14029446928943123968,\n                4819471829690483680,\n                4822358238606616160,\n                4815952782782718016,\n                4816579803919977088,\n                4803172268559085568,\n                14037574520474544896,\n                14041023293749826496,\n                4819669316338293184,\n                4822381886685121664,\n                4814949541608513024,\n                14046518209777144768,\n                14044962088148458176,\n                14043712021470579552,\n                14045462025555960128,\n                4823290296369894272,\n                14042875242047187712,\n                4811227996257409152,\n                4820094657302172000,\n                14047268026412358496,\n                14044261627055153888,\n                4816676027372550080,\n                4818988112406057056,\n                14047168323392133104,\n                14036812146916278144,\n                4822647148745983232,\n                4806416580925257984,\n                4822687338421398592,\n                14040659473392140992,\n                4807617116341448448,\n                4823754125084250656,\n                14041898383959664640,\n                4823928215263594528,\n                4823590608007128736,\n                14046984033857514832,\n                4810656040128120320,\n                4819166525645750080,\n                14034041966182391040,\n                4822822987161371488,\n                14045127101047551840,\n                4820068862666826144,\n                14043434095527401760,\n                14040921218767197376,\n                14047495591310846416,\n                14046903687920233824,\n                14042797441888326400,\n                4822894497633561792,\n                4818982771651696608,\n                14043137429542590112,\n                14042750052873796832,\n                14038252924793468416,\n                14040282646075979520,\n                14033895360297905152,\n                4818821017394163840,\n                14042916399651292128,\n                4814798536125483904,\n                14046806191966722304,\n                4823139113113045504,\n                14015297166206785536,\n                14046827572606184720,\n                14047080180235629808,\n                14041618148976860928,\n                4817363782277768384,\n                14037345265549837824,\n                4816921621327639168,\n                14046700883851729792,\n                4812798785083198720,\n                4819777826789112832,\n                4824093621144554736,\n                4821050479025166432,\n                4821499796823920384,\n                4810080753381523200,\n                14035266888196645504,\n                14046152857191322464,\n                14045147555265602880,\n                4819720101365537216,\n                14035884162226495104,\n                4814557221934779584,\n                14028975157409673472,\n                4823557713114728720,\n                4823011986069562560,\n                4814353235093053888,\n                14046113294532890976,\n                4824039762260425360,\n                4819140546758649024,\n                4815737341935295680,\n                4815435286943200512,\n                14043610898880614688,\n                14042238454686872704,\n                4822589053593557440,\n                4811562170768949888,\n                4798285318942627840,\n                4821598444014079232,\n                4816137313013105280,\n                4810772711755612544,\n                4821153687260206944,\n                4809418545373824256,\n                4823363559742400304,\n                14045337467805364608,\n                14046314655885555520,\n                4819478119637254400,\n                4820824064880936960,\n                14042617384550599648,\n                14046529274567364192,\n                14044756763057829536,\n                14030372190572887552,\n                4824074930273949312,\n                14043260157563907072,\n                14041404044477393216,\n                4821675538426049472,\n                14042047253238559104,\n                4822573073662088960,\n                14024232844721237504,\n                4801746691493966336,\n                14042024041810355328,\n                4817468615484937728,\n                4820419564910000672,\n                4820037981555363520,\n                14035413828192259328,\n                14029374584420809216,\n                4820125659001981920,\n                4822231509270238976,\n                4820084760969442624,\n                4807221227979781632,\n                14024955392120029696,\n                4815923338424602496,\n                4822666603030589888,\n                4817857794247714880,\n                4815815094706722880,\n                14039111549850603520,\n                14046810693373296288,\n                4816792165915616128,\n                14042480920902775904,\n                14043147966907082912,\n                14046633061170736640,\n                4803887935008955904,\n                14047447627957748080,\n                14025361448608221184,\n                14042481898715989632,\n                4822695462269299520,\n                14031561667074544896,\n                4823926475793359232,\n                14045111035514535456,\n                14033792475926343552,\n                14037740230693659072,\n                14032282177726076928,\n                4808147722149140224,\n                4821904534654980992,\n                14046352571106276384,\n                14038572443947110336,\n                4819841449235128064,\n                4820639502405138368,\n                14040803203057666880,\n                4820325840742393280,\n                14046838066772351792,\n                4788234228701003776,\n                4819746011374314432,\n                14040290217118963584,\n                4801568121055811072,\n                4821642371227288992,\n                4823859126348224128,\n                4822472635232691392,\n                4817395005835428160,\n                4815561947371879232,\n                14045612890817049376,\n                14041556355980214656,\n                4821271401332285600,\n                4820785860094018304,\n                4821807788617917888,\n                14037922882662542976,\n                4818149007691290816,\n                14042374597710097760,\n                4810322861417925504,\n                14045073620949091104,\n                4813468108857660928,\n                14041187569759368192,\n                14047192491651720240,\n                4821234452466636992,\n                4818342463455319424,\n                4822782853860455840,\n                14038532268403006656,\n                14038776597179011520,\n                4816140734456347456,\n                14036383282552424192,\n                14043860887023185824,\n                14039366923205984128,\n                14042853905491540096,\n                4823867769016818448,\n                14042038332447023936,\n                4814029249873877120,\n                14024977505123907072,\n                4822596351476697152,\n                14036603772330247680,\n                4821667776901388352,\n                14047173462717938672,\n                4820019591090057632,\n                4823640503739676496,\n                4820298114112882688,\n                14043783508696328032,\n                14028726705776916992,\n                4819628803029101696,\n                4823318710764586240,\n                4818970967084412864,\n                4814388435310996032,\n                4821298175323663744,\n                4819443772850088160,\n                14042759174029573536,\n                14046851936453335328,\n                4821852725460364672,\n                14038131602748077120,\n                14037083922071075840,\n                4819163326499610912,\n                4820948724870138720,\n                14044040439348105472,\n                4823784312647558816,\n                14040969568888977536,\n                4820908349952007200,\n                14042755081944579840,\n                4816556754237347136,\n                4820193859696014240,\n                14045762037814251072,\n                14043224991715790112,\n                4823873628123189328,\n                14046419856357617280,\n                4821573046117805824,\n                14035737978225647872,\n                14045940787308872320,\n                4822957791173172128,\n                14046835227131674544,\n                14036756773597010304,\n                4821015227653029472,\n                14039382347475567616,\n                4814385784409341120,\n                14033447077064123136,\n                4810745352876379776,\n                4823831421451721440,\n                4817115890056272704,\n                4819464457500141728,\n                4813724091834970752,\n                4818029070339465920,\n                4823358951554819424,\n                14044001591236914144,\n                4823607839163985056,\n                4811772911301224704,\n                14043056632030466464,\n                4806416960801803520,\n                14042996277296042272,\n                14039648365580371200,\n                4820152409711828192,\n                4820642108352588928,\n                14029090544416495104,\n                14041179479721601536,\n                14038340485397973632,\n                14046472002264079520,\n                4810726478000431488,\n                4812009031527654400,\n                4819315764315930944,\n                4817317575146479808,\n                14045868707891930848,\n                4821658017381554144,\n                14040757173430545088,\n                4814447920884705472,\n                14030005929563398144,\n                4802073332771989504,\n                4822128050040569376,\n                4822359116259091168,\n                14046325319246567328,\n                4798595665430469632,\n                14034379409710560000,\n                4821891553341924320,\n                4797501343319888896,\n                14044255277761127040,\n                14043973271698199456,\n                14046689262494093248,\n                14045764001054923488,\n                14034054619097519488,\n                4819601995670726176,\n                14046954568177349824,\n                14044406139628367264,\n                4823401493582609232,\n                4822416999492889344,\n                4820050606249603456,\n                14041729305763569152,\n                14039655485946678592,\n                14045766340286793728,\n                14040271984167585984,\n                14040068671774277632,\n                4800418279539573760,\n                14044601480897545664,\n                14032304512413818624,\n                4819238340117434304,\n                14045303005801748608,\n                14042052206746599936,\n                4818709615573168256,\n                14047238791822630944,\n                4820616519029229856,\n                14040734105350532224,\n                14043536928763529824,\n                4821182466082456960,\n                14047132411445369904,\n                14045526532385780256,\n                14039398073026549824,\n                14039320474256265216,\n                14032575787568917248,\n                4819224304095574112,\n                4820798639573090464,\n                4816803522852885632,\n                4816690685012090176,\n                14044419713595851520,\n                4815882743657667968,\n                4815627252727524736,\n                4821439474473379424,\n                4820457307381208864,\n                4822114080786367552,\n                4821072314498901696,\n                4822960767583985696,\n                4822119231875931200,\n                4820234832863064800,\n                4815964594203463168,\n                4822125426508014368,\n                14046439196670498432,\n                4806951098695948288,\n                14046157477473920768,\n                4822634881928081888,\n                14038034950202540608,\n                4820677684055701728,\n                14045369508204984320,\n                14044122534704717888,\n                4823063123614395520,\n                14038968612466453440,\n                4823482431263559264,\n                4824086635725295776,\n                4818021184677034048,\n                14034115880897733632,\n                4819966612056855296,\n                14028856255443871744,\n                4800970581927577600,\n                4811537776786762112,\n                4822273483660427136,\n                4822261797596690656,\n                4810073792655816448,\n                4820682091626689152,\n                4822520554778299040,\n                4809573375960721664,\n                14033507278063002752,\n                4819985856232579392,\n                14041838307938890368,\n                4820345444333655744,\n                4820045267160635008,\n                4823412697257961792,\n                4818000365087560128,\n                14041737325021053504,\n                14047420526262344784,\n                4823910521414846000,\n                14045717418532570176,\n                4823490868950751600,\n                4822367534293583520,\n                4819676090810798944,\n                4811349907640715776,\n                4823629015488249504,\n                4820422126990451136,\n                14042952444763607680,\n                4819470720981846400,\n                14042642332972833376,\n                14042879472544650400,\n                4821689528655304224,\n                4820456291005022720,\n                14045670581054078720,\n                14043533367729650176,\n                4801290734701679616,\n                4815957326919023552,\n                14042269834789089376,\n                14044890606275740736,\n                4805823458217711104,\n                14044227724496891904,\n                4823402092703335760,\n                4822608778533371456,\n                14045645732149140416,\n                4818546952019434304,\n                14046986317644262624,\n                14047017506194726832,\n                4810372028260206720,\n                14038123799911812608,\n                14039190125026145984,\n                14033897456602033408,\n                4822522716631995136,\n                14047277130431192832,\n                4823048297695750368,\n                14047160333283775552,\n                14045884679782399968,\n                4819005120583910944,\n                14045210385634400384,\n                14024182039035762688,\n                4821503792210971840,\n                4821239335458938688,\n                14029227748219801600,\n                4806053637299426816,\n                14046959868323274320,\n                4817859294125530368,\n                4824023714355564032,\n                14041619919901260416,\n                14046344807772762880,\n                14045728851633937376,\n                4823996386441260224,\n                4823231065333489344,\n                4815340192858770880,\n                14024570343524751360,\n                4819074915229193536,\n                4817140994373176192,\n                4806987178036726528,\n                4821323123908480320,\n                14039472839561286016,\n                14043310271355162464,\n                14033691387627211008,\n                4823370929661135536,\n                4815816211742494080,\n                14040717840444771840,\n                14037221380182369024,\n                14035238055346100736,\n                14045517733303433152,\n                14046736322858406528,\n                14046834828517165536,\n                4821757995531734848,\n                4816864785469041408,\n                14040887163328182144,\n                4815875329662489280,\n                14045265484758465344,\n                14041282294720095360,\n                4819505244894497728,\n                14041105549822131264,\n                14046973493111895504,\n                4819206136788759200,\n                14038365770000307584,\n                4823427509993365872,\n                14033010494170406400,\n                4820446292889421568,\n                14046794481251997888,\n                14044648872133409376,\n                4819249534589534720,\n                14035527248940838656,\n                14034261935081950720,\n                4821114772958933984,\n                4821449709258136256,\n                14044634765029429536,\n                4822502883067568896,\n                4823750421928062432,\n                14044475807416224640,\n                14047395748166022000,\n                14038624747672163584,\n                4821953175416184288,\n                4819337235590158304,\n                4816176896428906624,\n                14043552516085828512,\n                4823659750748469504,\n                4823683180204692768,\n                4819997721808574464,\n                4815874811355983424,\n                14044557403550214848,\n                14025471573734111744,\n                4820066535420159168,\n                14032070845741869312,\n                4814013559997335936,\n                14044613861689086528,\n                14044770624394437824,\n                4821753792832931872,\n                4820674071879711584,\n                4815143732755754496,\n                4823696691243399216,\n                14040690485748854464,\n                14046372584328571552,\n                4810316635939921280,\n                4820058528214213472,\n                4814589008542662720,\n                4823019936059684544,\n                14043745495751175296,\n                4809960520597146240,\n                4817891850758788928,\n                4819871283148638688,\n                14045981412032529152,\n                14024263113188784640,\n                14042363120210719520,\n                14035929970487290496,\n                4821586563237456672,\n                14047213692821423168,\n                14045648439711035456,\n                4812069453271974272,\n                14046489394534793600,\n                4818862190486623072,\n                4808013714969195008,\n                14041167052405707200,\n                14046821750574420768,\n                14036010153277055488,\n                4819386390564190656,\n                4823781272583221984,\n                14023960969868794880,\n                14044126354803288000,\n                14047070891540887984,\n                14042892667241457120,\n                14042790486042985952,\n                14043417583987223840,\n                14046822480908767856,\n                4822443996441927104,\n                14041182822950817152,\n                14042470704843533632,\n                4817810673950360832,\n                14028254104561745920,\n                4822853609835256000,\n                4822687333974972192,\n                4823105465648033632,\n                14047168012439471328,\n                4816515961740858432,\n                4823655675590455088,\n                14043630635174836448,\n                4817238579574709504,\n                4818887415767244032,\n                14042948046481616512,\n                4819499091780365920,\n                4814537184253533248,\n                14041117198205066560,\n                14042269925194334528,\n                14038993805610214336,\n                14047085432758954080,\n                14046004408873853344,\n                14035307190491619456,\n                14035750526682482048,\n                4812935339925737600,\n                14047392809644506672,\n                4822050445836341952,\n                4822276249439436576,\n                14025776736980483072,\n                14046451362205787168,\n                14037794483080965056,\n                14039099824723814016,\n                14037187434997084800,\n                14042520867569309088,\n                14030876598110204416,\n                4806439727629671424,\n                14045370440314431648,\n                14028462420745052672,\n                4819831674947039776,\n                14043180639921156608,\n                4817196335626270208,\n                4810518035491653504,\n                14044514992861280736,\n                14034100268864493824,\n                14043428755539938400,\n                4819292575565933408,\n                4823404944481193360,\n                14046532532064297216,\n                14047472477624072768,\n                14043796311434510752,\n                14045823429637120544,\n                4817094531227128768,\n                4820273109354296864,\n                14044187814073736352,\n                4820681851865697440,\n                4809819994148775168,\n                14031928359088231424,\n                14043303660277451360,\n                4823682648839184192,\n                14046785722576646656,\n                14040611234845209984,\n                14047323800234668544,\n                14031218062741227008,\n                14045293700618496064,\n                4814655726080799488,\n                14043819821868333152,\n                14044990505834243872,\n                14042901196048561920,\n                14046538964966124160,\n                14040995813292683136,\n                4816648289674201152,\n                14038059195782628480,\n                14043330863112450048,\n                4823301218443024832,\n                14041088300757269440,\n                4819176144373985312,\n                14042796397761668384,\n                14045435018910573312,\n                4823404304185780400,\n                14039555351035942336,\n                4820920303791018880,\n                14040854872510018176,\n                14046743312847922464,\n                4822881867229273152,\n                4822870278549681056,\n                4811103157650820608,\n                14037406497670069248,\n                14028703409747387392,\n                14043621620318579776,\n                4820726158279935840,\n                14022755949943558144,\n                4817424135002080896,\n                14034183528196808192,\n                14046743189766499744,\n                4818145017427955456,\n                14047098241361704912,\n                4822031672980739488,\n                14047486743546703440,\n                4822720214560048832,\n                14046866291759700288,\n                4810690458462979840,\n                4823357412844257952,\n                14042744863780213952,\n                14042483051657633024,\n                4818970366540676512,\n                4823721411484328720,\n                14040676837878843968,\n                4810095970686856192,\n                14043516463327118080,\n                14047208816258402480,\n                14044244102809007840,\n                4817728788172846912,\n                14046683228058724000,\n                4823387798116752080,\n                14047210412729299680,\n                14040925792872235008,\n                4798877000723968000,\n                14045414675307446080,\n                14043875385242020992,\n                4797879142046307328,\n                4817921002095611840,\n                4823743980582138848,\n                14018857531252613120,\n                4811018041032142848,\n                4822554275062634784,\n                4819271512461310144,\n                14047353681180690992,\n                14043478909672306272,\n                4823505019154075792,\n                4814124833699803136,\n                4821114957311013824,\n                4810032675234218880,\n                4822825136326632480,\n                14040903881332537280,\n                14046618424900302272,\n                4815706534555082560,\n                4816557647165239360,\n                4822282997572038240,\n                4821300566469104608,\n                14044452451623232832,\n                14042249790520235232,\n                4816643808720172736,\n                14042345021733912352,\n                4824030406189854080,\n                4819463084060812512,\n                14043765414262537152,\n                4810206240462452352,\n                14043923729116800032,\n                4814299821805958272,\n                4809031675552807936,\n                14040575704732681152,\n                14045961286555755744,\n                14047092257262150464,\n                4821127030371987712,\n                4815680639666405504,\n                14043989989130508640,\n                4814495686803074240,\n                14041013770551388800,\n                14046804052561675792,\n                4824083484623816768,\n                4805959629248404736,\n                4819254724173426144,\n                4815498382544308672,\n                14045240350390341664,\n                14043434896227629888,\n                14046242209451825504,\n                4822075008167544800,\n                4818900657748672256,\n                4824017930179475040,\n                4819035268997084256,\n                4821198595678204736,\n                4823866870401895760,\n                4821687226397580768,\n                4823457498141729136,\n                14032766839416975872,\n                14034180913410412928,\n                4823270494794457024,\n                4814228505680265088,\n                14046502457513541216,\n                4819843442159029728,\n                14031221433860364800,\n                4823218008825225536,\n                4820770492673680768,\n                4820907245418401568,\n                4821799766882749120,\n                4823551620227722784,\n                14036396276658314112,\n                4822683185419534592,\n                4821021667082329696,\n                4810658381506673280,\n                4818326933037005824,\n                14040019254838181504,\n                14047141118489096048,\n                14046851990945858032,\n                4817899070559940224,\n                14043664375618992576,\n                4823358103274378544,\n                4814633522209839168,\n                14044434554669951840,\n                14042464678335108928,\n                4803947108354246144,\n                14043729159908509120,\n                4806752781581983488,\n                14039512807242246912,\n                4814182576743198592,\n                14013310543475191808,\n                4819572507635344928,\n                14032217613873326848,\n                14046877226571895632,\n                14031883947433794816,\n                14041134052009196864,\n                4820262456286575040,\n                4823102712585947296,\n                4820812845360118048,\n                14047364617322776352,\n                14043184012347870112,\n                4816685999375297152,\n                14047322654131286768,\n                14044134362835530048,\n                14044413255469116608,\n                14034164336633090304,\n                4787698460410433536,\n                14033456942139026048,\n                4820438074479234272,\n                14043663622764917952,\n                4820347709485749536,\n                14047041855185071472,\n                4814837930561079040,\n                4814896320994780800,\n                14040951312912705792,\n                14047145540870023360,\n                14041513833326171008,\n                4822244114432649024,\n                4824099341068386240,\n                4820877528574901952,\n                4814397176188211136,\n                4816095989087295040,\n                4814398741154217920,\n                4812869438225019008,\n                14045327725506778368,\n                14038823124142416256,\n                4818118098727541440,\n                14045050372325388480,\n                14045736641499755680,\n                14037389938219797632,\n                14044296384704244800,\n                4819493595272932384,\n                4811047750359747328,\n                14046225899084480832,\n                14046895973279952272,\n                14044402994596927040,\n                14036576705465070592,\n                14046253512832852800,\n                4820117361875512288,\n                14045011063567676320,\n                14025432054961825792,\n                14047021960672323840,\n                14045151997080962720,\n                14042613099088985024,\n                14022039240238833664,\n                4809878213988696448,\n                14047009627734491744,\n                14033820054263929984,\n                4821319698923306496,\n                4822955497384013216,\n                14047276388020295184,\n                14047096184241382528,\n                4823611135109299216,\n                4818857901030648448,\n                4819991900036441696,\n                14045019654580228288,\n                14033462813119154176,\n                14043566788775828800,\n                4818171916692428864,\n                14042436133615592096,\n                4822339466750503456,\n                4817660958014563456,\n                14046114236509905632,\n                4820567137475811360,\n                14042977698243467072,\n                14047202509523767072,\n                4810023793922915200,\n                4823672534259544192,\n                14046903960203434752,\n                4802629115109755392,\n                4819462104396276512,\n                4812742613521022464,\n                14041319921609080128,\n                4822777110685846336,\n                4820803370591781472,\n                4818564115490740480,\n                4823922322425850448,\n                4812402951175645440,\n                14033518230887070720,\n                4816160224236722368,\n                14040547656584289536,\n                4815258088449519808,\n                4816665446776801856,\n                4821749414027722432,\n                4821658077509654272,\n                4820598676166545120,\n                4822901554356922336,\n                4822811876720564416,\n                4821861187996165664,\n                14039426922870091520,\n                14044082577254496960,\n                14046939850957662064,\n                4823775979979532832,\n                4823203846411833408,\n                14046639349080753536,\n                4817248548485416384,\n                14041112161043629824,\n                14047125616403237680,\n                4820156295970459808,\n                4815062623491864896,\n                4815287171972422848,\n                14044392931892569856,\n                4823123590979828672,\n                4821026966198218816,\n                14028092806058881024,\n                4805459034923118592,\n                4821426196700519872,\n                14040566195010002688,\n                14040567022575945856,\n                14039209106098959936,\n                14035976994464630272,\n                14039341238410081792,\n                14045948473375729344,\n                4819525811375133600,\n                4822234098134713472,\n                14041126459144131392,\n                4822877398980337824,\n                14047382703435330128,\n                14046964242539972928,\n                4804761455703464448,\n                4823252973748797280,\n                4821781334453699232,\n                14047102543725413584,\n                14047230505615006960,\n                4798404689703901184,\n                4821770082167910976,\n                14046833103580599744,\n                14033590219261963776,\n                4814285438091985280,\n                4819188577589261792,\n                4807581900448057088,\n                4788229220792360960,\n                4817586859723202880,\n                4813483577183812352,\n                4815855429285315264,\n                4814915057301381376,\n                14038845522429040832,\n                14038536283360610560,\n                4815989346122288320,\n                14042298156668553120,\n                4812764814252530048,\n                14039025463701560768,\n                14041740394287555392,\n                14034363885515192448,\n                14044435557273584096,\n                4813182912998061184,\n                14045320263552488192,\n                4817176567279651264,\n                14030865552733326592,\n                4819176655909761920,\n                4817626217967129664,\n                4819170569235376544,\n                4822620760926410656,\n                14042656347952278304,\n                4807587715613936640,\n                4816095088198837376,\n                4821563891152559680,\n                4822935863857873120,\n                14045307167176802464,\n                14043388248859445600,\n                14034150862208892800,\n                4821319654284821056,\n                4820771116049600832,\n                4822686954182576992,\n                14042531582392307008,\n                14037205680375455616,\n                14039345402214513600,\n                14036936694793475968,\n                14029535206724152064,\n                4820767578646556384,\n                14039724192881549120,\n                14039236788833008256,\n                14040012737763614528,\n                4811115643675009152,\n                4819935651310128128,\n                14044181276260289152,\n                4814890797881035712,\n                14039456412996557824,\n                14045428678483319520,\n                4822933752871245312,\n                4822384383068537152,\n                4823574143491257328,\n                14034676801947316864,\n                4822132900080793120,\n                4822892826528701568,\n                4822616577678764192,\n                14034164286534441088,\n                4811101677600318592,\n                14045849806927348320,\n                4823808520393398512,\n                14042747041188638528,\n                4820937431326125856,\n                4816222786347003968,\n                4812588908975165696,\n                14045672835051327776,\n                4811796911361400832,\n                14044616555411920960,\n                4821712305243947392,\n                14047024814661021184,\n                14040296648016037952,\n                4821976839110633344,\n                4823834746414167616,\n                14037766440292819136,\n                14041585671469505856,\n                14047382033960289152,\n                4818914562640192224,\n                14044810836460242080,\n                14040318143590506304,\n                4813172150722496768,\n                4814567200328487872,\n                14045973751089579232,\n                14039974436792780352,\n                4814017694229352704,\n                4823374971972368896,\n                4811705943173248128,\n                4823387947946393888,\n                14045704697300347840,\n                14035606548230141440,\n                14047135251221734544,\n                4819271609366685024,\n                4821711502139901440,\n                4823307836216475520,\n                4820124345830491968,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n        SerializedFFTContext {\n            p: 4832045740819742728,\n            pinv: 4382166536203340112,\n            mod_data: ModData {\n                n: 1086317488242689,\n                ninv: 672148569487374969,\n                norm: 14,\n            },\n            primitive_root: 3,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                4823669075673047008,\n                4821074455055476960,\n                4824464537976271760,\n                14048002495736585952,\n                4827439284260349632,\n                14045174112482972512,\n                14039465322840855680,\n                14047583530830462000,\n                4798363000744307712,\n                14048239708373958992,\n                14050731133834628688,\n                14045823572033926208,\n                14036443235440844672,\n                4809811901440654080,\n                14043401806652668352,\n                4808386844270543616,\n                14046190428065778400,\n                4817669223458730688,\n                14043371806395188608,\n                4822976686508107008,\n                4824081006318536176,\n                14038968715275889792,\n                4820995090977744864,\n                4815514108829272640,\n                4824223029550427296,\n                14048023909235321328,\n                4825184773604796608,\n                14048926648418871232,\n                14045264925715693408,\n                14049487039993555776,\n                4807139543325878784,\n                4824694269976575168,\n                14047745396193975056,\n                4807414549950819584,\n                14050283736512803712,\n                14047380340439613968,\n                4822245813524250784,\n                4815121391312415552,\n                4817319226064926656,\n                14046026847444144288,\n                4818542464428741952,\n                4825474976241824960,\n                4825883541323858144,\n                14043630627172369888,\n                14038210136376732416,\n                14048095265420288624,\n                14050146014957033344,\n                14036703814359031424,\n                4821179515390904960,\n                4825254774599650096,\n                4818943853169667136,\n                4825344953747088864,\n                14049223642061362160,\n                14038104667124981504,\n                4814642515765468160,\n                14046875111226459936,\n                4825274776540997216,\n                4824758610727820256,\n                4822047654827000032,\n                14043071888295319616,\n                14048272450443581408,\n                4822809755460662048,\n                14048371011079552256,\n                4817890523762114880,\n                14050078310196389712,\n                4811518488726426368,\n                14050309357289728432,\n                14032911088151142400,\n                4827439317977199872,\n                4823676834199080496,\n                14042791722262758368,\n                4816645695503448768,\n                14043772842778193216,\n                14049284017012965184,\n                14048601325101869536,\n                14047718930951295616,\n                4819267058212090560,\n                4824099035806433072,\n                14033006406012555776,\n                14043499847196152128,\n                4821391322272425856,\n                14047502591584659744,\n                14041594654704280192,\n                14048388332327342688,\n                4826788402113082880,\n                14027957855955036672,\n                14044349817504397984,\n                4822785975466479072,\n                4825021337472606464,\n                14042117320824563456,\n                14050045834334406448,\n                14045479945677456640,\n                4823934452865734304,\n                4824021508034647504,\n                14046523383579655392,\n                14050613509346282560,\n                14039688745224568576,\n                4823777794160657616,\n                4827411646543862736,\n                14033469933313939200,\n                4824561909263682464,\n                14040881506509483968,\n                14050009786714029680,\n                4821737654230683584,\n                14037826153710720960,\n                4825211351128951216,\n                4823947906853884240,\n                4824929118128215600,\n                14046566347705385824,\n                14039400665966879424,\n                14049833831990796528,\n                4803965375031389696,\n                4804033221111239680,\n                14048609834703906304,\n                14048876309803297680,\n                4825058732463787200,\n                14046281325866019808,\n                14042656181443171392,\n                14048468389490078752,\n                14046629866667473824,\n                4815648663079374016,\n                4824636691110615776,\n                14046292328489376224,\n                14047234639821289872,\n                14050560215382968176,\n                14049631567673748032,\n                4823148432576698336,\n                4802943429249333248,\n                14049396806737399680,\n                14044576390503023744,\n                4819402246238207200,\n                4809004640979239424,\n                4803348419635223040,\n                4811984509382260992,\n                4822383556949577344,\n                4819119172704411488,\n                4819442373740876576,\n                14047358631759256576,\n                4827527633223030416,\n                4823581603372731232,\n                4826333822449531472,\n                4824434491347899040,\n                14046231939514884256,\n                14047839749561180624,\n                4823302281790578688,\n                4827332296145373568,\n                4821004722894627968,\n                14043428318609857440,\n                14046464745538966784,\n                14044430118382302240,\n                14046962868751032240,\n                4819749396157453728,\n                14047720029535616496,\n                4815689013086704576,\n                4825117483528982000,\n                4809049348110900736,\n                4822250853185248992,\n                4826784585253298160,\n                14050013836007357360,\n                14038247436067576896,\n                4816623911501482112,\n                4809721466716274944,\n                14032104006738276096,\n                14050453813473198416,\n                14044827212156913216,\n                4825814047818603664,\n                14047696222193534336,\n                4819935698048810304,\n                4820272253567008224,\n                14050394096636982688,\n                4820961846915642400,\n                14050214420523755280,\n                14039463322110126272,\n                14046654697802883296,\n                14049135136049004992,\n                4815835742090743808,\n                4827103202308012656,\n                14046442482662991392,\n                14032980059939564032,\n                4818178058703800256,\n                14031953734386717696,\n                14049782453639499536,\n                4818455757661749376,\n                4825920593060035744,\n                4820501258139105088,\n                14043400192667825760,\n                14049304658124207632,\n                4826568395635961696,\n                14048703594788780624,\n                4820152776394181024,\n                14048537087304784576,\n                4823344774229103744,\n                4816707756803048832,\n                14047618536844999760,\n                14049775357525453664,\n                4814772330083138368,\n                4827420245671905808,\n                14037924894210417088,\n                4809897730877532160,\n                4821184383292930400,\n                14047543661664225760,\n                14048638760050180800,\n                14047369323019232352,\n                14047849344985776672,\n                14046936203645396896,\n                4814891176592263424,\n                4825387344334058000,\n                4826743556251727808,\n                14044078116837800704,\n                4803341727680464384,\n                4827414730611485440,\n                14042747480909186304,\n                4818124830547924096,\n                14048714295026209504,\n                4825930031181648880,\n                14050487440567268672,\n                14046266506787087584,\n                4811767368486241536,\n                4826682832693370352,\n                14035679294129261952,\n                4825775857735184160,\n                4825030095907060368,\n                14022195793590770688,\n                14044300021171104960,\n                4814518461424370432,\n                14049487139996102720,\n                14046070997212271840,\n                4826268793383341984,\n                14040023801552677888,\n                14029954758406551040,\n                4824383474699739888,\n                14044527367765150592,\n                4826539774740602896,\n                4811936105639091584,\n                14046897708320262816,\n                14027441443096358400,\n                4825937439798110320,\n                4824750672857837968,\n                14043111181614510752,\n                4796984850429614080,\n                4824438361337115008,\n                4822121441594657312,\n                14046875487308859712,\n                4825565678444384448,\n                14040433727900966208,\n                14050835357100859312,\n                14049088240414533680,\n                4824539341897979664,\n                4824390763060039760,\n                14046739705553552720,\n                14050542238461109536,\n                4822375761204541408,\n                14047627358704858976,\n                14041209662298350784,\n                14049975128274292416,\n                14047218219103102384,\n                14047533272021738320,\n                14036558530282903040,\n                14050314400576337584,\n                14047688371808784528,\n                14047400949758842288,\n                4824878335747892736,\n                14044198019162131104,\n                4827413344841394544,\n                4825502070144544048,\n                4813124933629621120,\n                14046538532219547392,\n                14048464581086399472,\n                14048853380031323520,\n                4825899505590411456,\n                4824227957268193168,\n                4813485207076762880,\n                4824938087296934864,\n                4825466350429488000,\n                4822877910404392896,\n                4822033347796440736,\n                14047520654944302096,\n                4812974512988636672,\n                4817513278571148928,\n                14039105229129261440,\n                4824143723196474688,\n                4826438126922600992,\n                14046090930232306496,\n                14047440142812144432,\n                4825821199555780000,\n                4825242251935149152,\n                4825344557574263296,\n                14029362673351473408,\n                4824553695908829728,\n                4827200774914309184,\n                14032779564718697728,\n                14047378468772007936,\n                4804346442806902272,\n                14043539288856989056,\n                4816548937806409408,\n                14046636351351898912,\n                4822567550447625728,\n                14048145064544052272,\n                4825954776696536608,\n                4825275041514837600,\n                4825171923706505408,\n                14043433243494698880,\n                4822057195094010432,\n                4827442164502080064,\n                14043575592671461728,\n                4824512812840564672,\n                4820367435398346848,\n                4826646780773983472,\n                4817971560207341184,\n                14035138585708664960,\n                4824708695056569184,\n                14044840415547853248,\n                4794942435704320000,\n                4813614598824218624,\n                14046864234405290544,\n                4825872643584083520,\n                4825124448481593632,\n                4826732744772695504,\n                14047893795576817808,\n                14042705121682420576,\n                4825368735764351472,\n                14045403131278602336,\n                14047308711687675504,\n                14046962429182494064,\n                14049282401120782240,\n                4824304440995204800,\n                4817506698370480448,\n                14046248643692129248,\n                4815594164916306752,\n                14036920489128619904,\n                4822096166890467200,\n                4815780323351711616,\n                4822621976458002048,\n                4818936132427483840,\n                14034441510654750848,\n                14033409571470493696,\n                4826346738386027072,\n                14047563968588042128,\n                4814699469008606656,\n                4823815188190957040,\n                14039606925036258112,\n                4819847602078066400,\n                4821544525797217248,\n                4824669260376545424,\n                4823927018555261024,\n                4812819383269788416,\n                14046833901108044256,\n                4819283554150873952,\n                4826116757227458672,\n                14038431583242843712,\n                14038390930967815232,\n                4820412992442146176,\n                14049220816671762176,\n                4824956053214170320,\n                4820252989827651584,\n                14049010785158733680,\n                4826039612838542352,\n                4815327208107521664,\n                14048512799808813488,\n                14037068283532484352,\n                14044295226939709184,\n                14049413994963762752,\n                4823925675993854896,\n                14046309163702963968,\n                14047880879843850816,\n                4824707508981109872,\n                14045726704666720992,\n                4827282687894680848,\n                14049460838775650144,\n                4826377726238276640,\n                4812003281287413888,\n                14043601869758682368,\n                4823289351738063072,\n                4821974746981674656,\n                14045243755266945120,\n                14046791047058545040,\n                14036920018457088000,\n                14047797079560177840,\n                4824627395782606864,\n                4824148908627448928,\n                4823488120076808000,\n                14048650841191402624,\n                4825505594331450560,\n                4826573194393033152,\n                4822568027987764768,\n                14049807963597616384,\n                14034175756783419136,\n                14041901302763657408,\n                14037079691831737088,\n                4813686074082473216,\n                14030064716923749888,\n                14045887661478971488,\n                4826118309940170928,\n                4827027249126472368,\n                14050158947176759920,\n                14049354830472744064,\n                4815616631111631360,\n                4819992598618900832,\n                14044194233282059584,\n                4823712699055877264,\n                4825018352088548800,\n                14046897227593925504,\n                14041604000149550976,\n                14040560266786768896,\n                14048967780734609792,\n                14047840323819025216,\n                14044325931583514176,\n                14045547485985099808,\n                14046631565103956704,\n                14048551069591981312,\n                4824794158486501792,\n                4811422361474846848,\n                4824950247308644176,\n                4825111990250182560,\n                14043101314036845216,\n                4827052454849733232,\n                14038017500267018944,\n                14040305083250122880,\n                4826042980419585104,\n                4825342870991037216,\n                4824345918573050960,\n                14044268591040691904,\n                4824232359648627792,\n                4819095538717736512,\n                4825592566920967504,\n                4824155977869705632,\n                14032901262052418048,\n                4827166364929704576,\n                14044702639346002720,\n                14027394674715025920,\n                14047938656523355600,\n                4825724886335524496,\n                4823653336949540496,\n                4825858236687455376,\n                14040328641177979328,\n                14046324230905685600,\n                14048449633302727024,\n                4822633743438984128,\n                14041275186719642688,\n                14049620416879981296,\n                4823596465737975904,\n                14046605937688023040,\n                4816312569683389120,\n                14039205226164440000,\n                4823385745818104432,\n                4819648477556025856,\n                4825755172146410496,\n                4825622765449648928,\n                4815361583976938944,\n                4824713188744657744,\n                14049028327055436160,\n                4827305698993413904,\n                14029661602861399552,\n                4817686341641616704,\n                14041395471567971200,\n                4823997409702007600,\n                14046099648078241280,\n                14049511999725689808,\n                14049142078802085744,\n                14043696076429037088,\n                4823833498319832064,\n                14037873040031993536,\n                14036108229920586624,\n                14048746745203428048,\n                4825437259130218288,\n                4823317370725625952,\n                14050820871013216032,\n                14050256815821251744,\n                4802232718919720448,\n                14040619075253068416,\n                14050296154584916928,\n                4826499751522105376,\n                4826833756388793040,\n                4820342546705239584,\n                14049809462564536928,\n                4827332662364497568,\n                14046990049847494016,\n                4827426402078713232,\n                4823913864879564000,\n                4817588255977783296,\n                14047400696779163312,\n                4824324443623408960,\n                4810325341099306752,\n                14048806887871202704,\n                14043790796546123680,\n                4822761639474895072,\n                4816575825813205440,\n                4810149439538732672,\n                14046549005160757920,\n                14047120466166117120,\n                4825035325271754192,\n                4823843293609031664,\n                14050361129275027344,\n                14030109335402705408,\n                14048576876456287712,\n                14048999259784570784,\n                4790925337410015232,\n                14049980284560711872,\n                4826213771281123840,\n                14038175791516320192,\n                14047381052028298816,\n                4825250805728601344,\n                14039469659193018624,\n                4813118754624969728,\n                14042345909057223456,\n                4825207612711029568,\n                14046821627311010048,\n                14049701615942508384,\n                4813818125305525760,\n                14047325910355584624,\n                4825907182981559904,\n                14049096289898746624,\n                14037167020144745856,\n                4824736967870173520,\n                4816789162740948288,\n                14041582344218197120,\n                14047971026127931344,\n                14045344112028650656,\n                14047662222744629136,\n                4822314102716085952,\n                4816853376218690944,\n                14050052232207516416,\n                14045591215317552768,\n                14050280918360536480,\n                4824732898298706032,\n                4827106723794861248,\n                4827106688684748928,\n                4826431103400572112,\n                14037403549302600832,\n                14049080723883127296,\n                4804363289251495424,\n                14030185571426728960,\n                14038397699034456064,\n                14045714778166485408,\n                14048600410042614656,\n                4820046394897588800,\n                14050087337343283808,\n                4811207210550991488,\n                4823459273999405872,\n                14048204491775548864,\n                14047877046328385536,\n                4826189115062196864,\n                14046942449006734160,\n                14035292849025363328,\n                4824368563833866912,\n                14029830211734635008,\n                14042360205479957376,\n                14040748725018832384,\n                4827417388923238144,\n                4824214415418328080,\n                4794572512130633728,\n                14040704638232068096,\n                4826023450780372880,\n                4822057102906710240,\n                14048575305002802496,\n                14049453498414305040,\n                14040672410733960768,\n                4806661874397268736,\n                14048064619753234416,\n                14042485457419007200,\n                4818454219423700864,\n                14050812107621478640,\n                4824053940518913152,\n                14047032699674498272,\n                14040893024799306432,\n                4821972793164645472,\n                14046447913518408608,\n                4814733385354665984,\n                4803005377339220480,\n                4820997982661777472,\n                4813812449711378048,\n                14038224756913255552,\n                4826217103919067648,\n                4807414013853091584,\n                4814500654973011840,\n                14023677137426848768,\n                14049193694176265584,\n                14047284826100604016,\n                14047244433643270448,\n                4826509870751570768,\n                14048449038250270096,\n                14048445421564885312,\n                4812895393896041472,\n                4820277622734007936,\n                14043465674397110176,\n                14035734551323447296,\n                4819539715644416128,\n                4827016561723629280,\n                4820879077951299296,\n                14047782665357449456,\n                14048229597543700528,\n                4823587264191490560,\n                4825923755597799504,\n                4826905897660217968,\n                4810744060330181760,\n                14047628793872262544,\n                4820301758343638528,\n                4810504686841833472,\n                4820169556005786688,\n                14045916074324387616,\n                14049014381670234416,\n                14043266343409649984,\n                4825544080529000128,\n                14049195231911444336,\n                4816305309518378752,\n                4825892666215854096,\n                4820228635692091424,\n                14039460297863506368,\n                14047457486192875952,\n                14027478790385997824,\n                4827375209142228272,\n                4827475596075372240,\n                14048942690042111136,\n                4816435754268609600,\n                14034411773510640768,\n                4825032276685385440,\n                4818359447447602752,\n                14050104396649896688,\n                4817671314828727616,\n                4816447939916698048,\n                4825021181004138400,\n                4816605047621449600,\n                14048486843705778416,\n                4826505842000732128,\n                4825500461705777360,\n                14042472703736636256,\n                4817734717229416768,\n                4809291162203853568,\n                14044404169266544352,\n                4815914602910284800,\n                14048858698130966224,\n                14036101460776935552,\n                4824869906749882560,\n                14038073056611875712,\n                4821055069919318240,\n                4823726146217129904,\n                4824644346638022096,\n                4821488729281420128,\n                4823232972595818240,\n                4815861306409708352,\n                4825923761784874416,\n                4822145926880519424,\n                14043912345987186368,\n                4825698727528483552,\n                4827496799336028672,\n                4827388878526922032,\n                14047342903851918848,\n                14043618080006794176,\n                14025656170871706624,\n                4818375882812654784,\n                4825192101448469120,\n                14048290697117854992,\n                4827152212331464288,\n                14036861650235655680,\n                4827234691243587584,\n                4824342384021011520,\n                14043981782818117216,\n                4826118500189347856,\n                14048471797006108048,\n                14048861362986108736,\n                14046759496182247024,\n                4819399305753481440,\n                14049043476823649440,\n                14046823839356329904,\n                4816176769121146496,\n                4825786095999036160,\n                4826241788276223088,\n                4818986940494195776,\n                14043162540286299168,\n                4822722492022500704,\n                14050880285328092464,\n                4823751698888846336,\n                14048300498998944208,\n                4817656981259625344,\n                4818536874967188160,\n                14045195514416569120,\n                14047992542429093088,\n                14048809850657987056,\n                14016791382348544000,\n                4824527203528682176,\n                4822702137615992672,\n                4819969141731513280,\n                14035896674846163712,\n                4821407164580298464,\n                4810656810818985600,\n                14045505777984169472,\n                14045739340100364480,\n                14047566683676771408,\n                4752053734082609152,\n                14049958816077011232,\n                4817174979660770176,\n                14035497289759830016,\n                4821984623625848256,\n                4820332707657795168,\n                14050264520749145664,\n                14047303025466811488,\n                4827524633316930864,\n                4824609681466904704,\n                14049962564799521728,\n                14048309409744718784,\n                4797189451316329472,\n                14049391175624572864,\n                14048037928382118368,\n                4808463840777550848,\n                4823655610175715008,\n                14046890486795299776,\n                4827139455543994224,\n                4824062291165692144,\n                14048138520258705344,\n                14050291427696716896,\n                14047562554493802480,\n                4822978777890482304,\n                14048103010413563072,\n                14042417322581688640,\n                14050700820548139456,\n                4825783824557932624,\n                4818927202554383616,\n                4808164301425248512,\n                14044462280281847008,\n                4820008554015526816,\n                14046704173389119424,\n                14046583594210522848,\n                14048108219532375232,\n                4824901683177351968,\n                14034600529698837888,\n                14050873228138384256,\n                4825970650938056160,\n                4819337656592692480,\n                14043378739545879616,\n                4825545752452926704,\n                4820199722098596896,\n                14044880618866974112,\n                4823426618700293552,\n                14048119187221489792,\n                4821469617978702304,\n                4823924085889139328,\n                4824898702371513600,\n                14042556653214304256,\n                14042895511619905376,\n                14049927365129203936,\n                14025903512464595968,\n                4825989434132668688,\n                14042638914587954880,\n                14047248376159271936,\n                4825163128923226416,\n                14041707578127073728,\n                14050836205556948736,\n                4811433388398753920,\n                14038868351932557568,\n                4823470498895325024,\n                14050244933080351696,\n                14049293595355266560,\n                4825546240672869056,\n                4826141924215864208,\n                14028289912637442560,\n                4827331827729561072,\n                14047298610156851440,\n                14050467202633790160,\n                4825326846767646944,\n                14044014249753023744,\n                4816080187705344832,\n                4818560413173935424,\n                4820850650591711072,\n                14048387854682275488,\n                14045320099582269504,\n                4825872951407024512,\n                14050240230394505152,\n                4802732933867449856,\n                4824654101838303104,\n                4814857720289123456,\n                4823915462642254512,\n                14042986165354480992,\n                14039261896837337344,\n                14039830524213336384,\n                14048461303041803536,\n                14018697476565278720,\n                4821699702366270336,\n                14037812504947253184,\n                4821262929071637440,\n                14049822765899686912,\n                4824796203103431600,\n                4806740995057848320,\n                14034053820166908544,\n                14048448581552980336,\n                14050299546710641584,\n                4826614252035880768,\n                14049770777747138592,\n                14049789067993336320,\n                4800811229952730112,\n                14048674540297025472,\n                4826156229654389232,\n                14032335315118612480,\n                4790364003619381248,\n                4826125868533998336,\n                14044038920330800352,\n                14047391396420267744,\n                4814452009523781312,\n                14043674053754524928,\n                14050735290451595744,\n                14034175436955393664,\n                4824023548064048592,\n                4814944850516883776,\n                14049646918486097728,\n                4810418144167598976,\n                4827320259443302928,\n                14042738094118667232,\n                14047726635959205248,\n                4827391603372602400,\n                4815213772740262848,\n                14032927041490024448,\n                14036010962913791744,\n                4811648836022465152,\n                14038660053253260032,\n                4823320696941159392,\n                14047788010599234592,\n                14040664049174184448,\n                4817346080097335744,\n                4822696317625127808,\n                14042955765420976544,\n                4822749736868095456,\n                4807440476460350464,\n                14047107902801890400,\n                14048531638141195952,\n                4817570981414272832,\n                4813629601315548672,\n                4824569750345782640,\n                4821633959043983648,\n                4825469606876584800,\n                14050675032572867344,\n                14038938372769741312,\n                4816684898491130496,\n                4824349953305523664,\n                14045873936439766848,\n                14048099006358527632,\n                4824774608527428368,\n                4826106306343912944,\n                4813515605280634624,\n                4810542851617532288,\n                4802979431790181888,\n                14047910718875129408,\n                4825885865135236144,\n                4822599683782904320,\n                4816442549103467456,\n                4827520882371575552,\n                4805409822583963904,\n                4822394640436706368,\n                14043112041065373472,\n                14043920380321423968,\n                14046222368244592512,\n                14041105383378377984,\n                4825589209030717584,\n                14041005813848277952,\n                4823525612521249568,\n                4822505980892172224,\n                14046698847473091584,\n                14046198652065521824,\n                14050216727789838400,\n                4808889700304526336,\n                4824187863070011680,\n                4820982992489883360,\n                14046443535205793472,\n                4818985967885981152,\n                4824590689752775728,\n                14049755323165779440,\n                4797117954635166720,\n                14047234474970918544,\n                14047967707960953376,\n                14040584620609446016,\n                4827134377446770864,\n                14043399782642098656,\n                14049086943138672832,\n                14036286968742574592,\n                4825428831539644032,\n                14050351703285447264,\n                4820618771246673504,\n                4821753888671166304,\n                14049749698514023344,\n                14047565878872144656,\n                4812281368355519616,\n                4821545735149027488,\n                4814360522434904384,\n                14047269841809463536,\n                4826818880800809248,\n                14048767300672146352,\n                4817089660786771200,\n                4824328699688647344,\n                4826330049959783088,\n                4825474219405237552,\n                14042529898353777664,\n                14045911615046701344,\n                14040779063915970176,\n                14048354308363775648,\n                4813222816533646080,\n                14044282134997088416,\n                14050090031980771952,\n                4827271456927878544,\n                14047543190389293424,\n                14050069041780897984,\n                4817205539946377088,\n                14047551075085999328,\n                4818154749411420160,\n                4811851224349411200,\n                4822867542037627328,\n                4816652535647179520,\n                14046447335895992800,\n                14037700084876808192,\n                14047251554064535888,\n                14046499755852653600,\n                14049968091456070032,\n                4819682568827203232,\n                4820916056718771456,\n                14042499295391146432,\n                14042159031019988800,\n                4819525742772475328,\n                14044307436851058304,\n                14037814893308110720,\n                4822300462032130464,\n                14050291413508816592,\n                14047474084194200128,\n                14030693945142926080,\n                4811865913107018368,\n                4822739796415177632,\n                14046029358772332768,\n                4815637940745949120,\n                4820582764103204672,\n                14039731535567729152,\n                14037544277190028160,\n                14033929324348290176,\n                4812694965287397632,\n                14049328209367101920,\n                4825594854553298736,\n                14043239976808655488,\n                14049153053754529120,\n                4815354172699059456,\n                4815817954694293696,\n                14042362261548803232,\n                14045206833773344384,\n                14034816333524678784,\n                4826910615981259616,\n                4825846050844994032,\n                14035476247042449280,\n                14047632965272013104,\n                4826897261774151552,\n                14046476870082609280,\n                14036143952589557504,\n                4815195417778694464,\n                14044026400811556160,\n                14045420358992383968,\n                4821718503690183808,\n                14031795509465220096,\n                4825309571374527808,\n                4827389448398884432,\n                14046775619633908512,\n                14046806371983507248,\n                14049447486936208960,\n                14049440506105992256,\n                14043677160848197312,\n                14050172918142501200,\n                14043762569795054208,\n                14049934524037237872,\n                4826867870261576128,\n                4827286835851558576,\n                4806143666869979392,\n                14048922574192087664,\n                4827214449426121120,\n                14039999205344759616,\n                4826073020979652880,\n                4816990759827235328,\n                14045615613507186720,\n                4823657355241872848,\n                14044788239382283072,\n                4820811915670830016,\n                4820117965313582432,\n                4824184546227654032,\n                4805372051231269376,\n                14034439078448139008,\n                4817539105828261184,\n                14044307641696930592,\n                14046271979856627072,\n                14047951184380695712,\n                14039693765695234624,\n                14047557315560712256,\n                4825969509629932272,\n                4827538221666079984,\n                4820219396764646912,\n                4820991796866674272,\n                4817541247142691776,\n                14044225817051180224,\n                14037439556916622336,\n                4824457733099428880,\n                4823679759637159488,\n                14038556262951558784,\n                4827438241020549152,\n                4819687211860892160,\n                14049451345734005504,\n                4826284605323864816,\n                4825152961927119152,\n                14049572812692583968,\n                4821040761572401280,\n                4819818093690164832,\n                4827117322194468704,\n                14050679583135120528,\n                4821648425909622176,\n                14038096139607875200,\n                4808674625776397568,\n                4819809164432985312,\n                4811409762472002304,\n                14038883530020770880,\n                4817368785957615296,\n                4825570609990811008,\n                4825392391898120176,\n                14042699532495128736,\n                14050583730812302896,\n                4826659672355578304,\n                14045773069910965824,\n                4811900109399415552,\n                4826384868179719456,\n                4826137677250241008,\n                4822598014691342016,\n                14047549635022054304,\n                14042803236689179680,\n                4820917015969801920,\n                14048220794093985760,\n                4825490342405589456,\n                14050779192957904288,\n                4825430427542135296,\n                14038700658918012800,\n                4826058423629640752,\n                14041540798002694336,\n                14043277527130728192,\n                4824628043828371376,\n                14040916580488203200,\n                14050077324647863024,\n                4826380063284196272,\n                14046589991038668896,\n                14050499877900179040,\n                4823973675530891920,\n                4825693329167187184,\n                4826072800579081200,\n                14045486880605870880,\n                14048373661487016304,\n                4826907023128104496,\n                14049480417396667328,\n                4817725360848926080,\n                4818540360628950016,\n                14049833783619408960,\n                4789738689436200960,\n                4818889026841473248,\n                14048699032871017392,\n                14035626354097818112,\n                14040993989110635584,\n                14030844108281171200,\n                14042981850819225984,\n                4824885858604141648,\n                14049506138838128768,\n                14042570485376980896,\n                4824097918057795136,\n                4821253448194608512,\n                14048100209479694960,\n                4821135898288099616,\n                14049081478406706000,\n                14044517733238218752,\n                14046668366931898176,\n                14047546260800595648,\n                4807588188995015424,\n                14050529442169741152,\n                4822567646897763424,\n                4824052387832233968,\n                14049532792484758016,\n                14043372367620093792,\n                4821782306490755520,\n                14042943356258703200,\n                4818038684068530112,\n                14040559390870544832,\n                4827512512636644896,\n                14049663201837070992,\n                4815967538710357120,\n                4809965276574625024,\n                14049151600144544144,\n                4827524526732729872,\n                4821288915894488640,\n                4796750543907596288,\n                14049685422934961872,\n                4825358836984044592,\n                4824311776782263760,\n                4799820440580381696,\n                14037988452810018048,\n                4826145508676277952,\n                14047095223977211984,\n                4826014728301725088,\n                14034626616776958464,\n                14038708410135778048,\n                4820586549683437760,\n                4825479486824845072,\n                4817855097183345024,\n                4815930523981551168,\n                14045655197291088448,\n                14050309170853145552,\n                14047650296299121984,\n                4820013468421902432,\n                14041297358760458176,\n                14042699574526062720,\n                4821833443125081472,\n                14050108093538474304,\n                14030375229338249728,\n                14044984721761994208,\n                4827070815129472384,\n                4826396407918438992,\n                4822760694962129568,\n                4814440197576533376,\n                14047943658896591632,\n                4815653495464315072,\n                14044463156639709824,\n                4820060408129761024,\n                4817765066312719744,\n                4826710444907733728,\n                14046511125764393888,\n                14050709392201865520,\n                14039897241069626688,\n                4821000919479208640,\n                14044219509765568928,\n                4805027040659365376,\n                14050438489462040096,\n                4813035256688970752,\n                4823851084331092320,\n                14012455677553266688,\n                4809923512089517696,\n                14049960963113202064,\n                14030802230154784256,\n                4813329603483211904,\n                14046152649105750688,\n                14042217226154760256,\n                4823687529311181472,\n                4825023163695672624,\n                4825023378770437456,\n                14049237787250617952,\n                4822947758432855232,\n                14049600103051778096,\n                4824926332635571760,\n                4819524260103066432,\n                4826044227063143152,\n                14033244570576339712,\n                14050687531630496224,\n                4823745694549864192,\n                4822761204795245600,\n                4826379907695171584,\n                4827489510798892432,\n                14048012016273213744,\n                14038694339874021568,\n                14036748857082834304,\n                14048833197502169824,\n                14048217926710073536,\n                14045689587086360992,\n                14037787259748863104,\n                14043097026653372256,\n                14044635381777187392,\n                14048225041862610320,\n                14048770609316029216,\n                4804977741722480128,\n                4825321224700966320,\n                4800220111277785088,\n                14043442521272979968,\n                4825909089225981312,\n                4824513766379962976,\n                4823870501696420864,\n                4816650998669627648,\n                14040121625067562688,\n                14044523904667088608,\n                4825807870433166736,\n                14047057535301194544,\n                4823814500642216688,\n                14043365899367635232,\n                4816406064445231040,\n                4826263352627281424,\n                14047013970916072896,\n                4821117458664213696,\n                14044507400270140992,\n                4825975153264440368,\n                4823120098842564960,\n                14034543949629549056,\n                4814689783561743808,\n                14050029546606905472,\n                14041276856331759232,\n                4820442159264978624,\n                14047799844189071312,\n                4826453477726942464,\n                14046134594232840576,\n                4814890551115058240,\n                14046248988448574656,\n                14050002085753334256,\n                4825866515410765904,\n                14044453177905086784,\n                4827170700347221392,\n                4820931836573598208,\n                14049605138965574912,\n                14043210774064383328,\n                4826597074495445568,\n                4814213929796513664,\n                14042121901078362816,\n                4824713729118017104,\n                4823029722794282496,\n                14047294620577788448,\n                4823328725385913920,\n                4821742935851688864,\n                14048079577359533088,\n                4827369676205252320,\n                14049902212472525296,\n                4811932235002354048,\n                4826518470198570576,\n                4822108316021943392,\n                4820381392089958016,\n                4823746493360387360,\n                4818867677990904288,\n                4820017553903449312,\n                4820957215413289856,\n                14040100557547119872,\n                4803408029714062336,\n                4822217410659601792,\n                14038073424807886848,\n                4818544598829997824,\n                4814019917385576960,\n                14049873819441567088,\n                4827472511627503136,\n                4804697258652760576,\n                4822363670461187168,\n                4826223681760378960,\n                4818371615432063936,\n                4825410909472836592,\n                14050566737821298640,\n                14044970817227698880,\n                4820390392873326176,\n                4821936539900920032,\n                4823385137912684496,\n                14045633760725393248,\n                14044658673874254144,\n                4825856308246054544,\n                4803558198063867904,\n                14049801508680345264,\n                4818015224341775040,\n                4825063065994072800,\n                14030205757538919424,\n                4808802554133322240,\n                14036060224228209408,\n                14050655370894546480,\n                14045256328143746656,\n                4813746999852420224,\n                4818347686664185344,\n                4822523515865525408,\n                4822181937430099488,\n                14048203193318009600,\n                4825641198872371072,\n                4818125169991300544,\n                4827126309964315952,\n                4822324608988395040,\n                4811154868835276544,\n                14049251929630659376,\n                4826790543908816144,\n                14048346496416447296,\n                14044997500025140160,\n                4820997880011417152,\n                4826694297030078496,\n                4826523585620066672,\n                4820987166198646752,\n                14028654173445591552,\n                14036949535500764672,\n                14047472727436919744,\n                4825028262747784176,\n                4826276512785204464,\n                14049002064478769584,\n                14045792827528888928,\n                4822907025802413248,\n                4819093965991109536,\n                14050719614483158096,\n                14049911185973797136,\n                14038255833428036608,\n                14045702740511516352,\n                14046343786939408992,\n                4824803736570329472,\n                4820749615190259776,\n                14033789142699563136,\n                4824664740731543664,\n                4810596563945365120,\n                4826985991060703360,\n                14047104887939171344,\n                4822593358103381024,\n                14041768820159614528,\n                14050179831944910656,\n                4822975744517806080,\n                4820809442889686464,\n                4821657249105344128,\n                14049494804715260224,\n                4823463545667200112,\n                4825091619570902608,\n                4816659595849054528,\n                14047642041402662432,\n                4822617244831186144,\n                14048265285144342480,\n                14043413586657170784,\n                14050544478340453824,\n                4818974290900593088,\n                14050291639403017264,\n                4823188246754458144,\n                14049225262847383856,\n                14050474355542890080,\n                4827506822629080832,\n                14040931360994469184,\n                14019942073152442368,\n                14047451438871506256,\n                4810603835864989568,\n                14022513656549353472,\n                14045788808727580128,\n                4824334810630821728,\n                14018682891098083328,\n                14039957450564285376,\n                4822879880281669888,\n                14036940283619224192,\n                14029354777665927424,\n                14048454513306374192,\n                4819982392044529632,\n                14042767370707103136,\n                4822736432620661120,\n                14048404593452857024,\n                14049283530646971232,\n                14045808374076604832,\n                14047223903156728752,\n                14047180825357952896,\n                14048624410072117776,\n                14049336048107771520,\n                4819554192596037632,\n                4827092978433806208,\n                4810118552391494400,\n                4826692659736847328,\n                14046089543596634400,\n                4823977352043713200,\n                4816203662778689152,\n                14049634833079222096,\n                4826101002856109760,\n                4825429156831265632,\n                4827421331538066352,\n                4823821455165611104,\n                14027597363570988032,\n                14050112678498391472,\n                14022873427945430016,\n                14050471526360541632,\n                14048180999441940128,\n                14047069482431905936,\n                14046182363014307040,\n                4794196803435882496,\n                4815391253384178624,\n                14050180295339060256,\n                4824887629352012992,\n                14045268277999328096,\n                14050307536562943232,\n                14047940319558644160,\n                14045751264001221984,\n                4815876874570541696,\n                4825445029765670768,\n                14050729575798393632,\n                4825801663153120096,\n                4817748590413628352,\n                14031355845451897088,\n                14048852067629400432,\n                4823036813032966944,\n                14049533748394722000,\n                14046772638929125392,\n                14048523132918560672,\n                14045372429393576032,\n                14049214494669939824,\n                14047082836134608240,\n                4811266020377325952,\n                4814774508194516736,\n                4809915077152572928,\n                4826665247702822224,\n                4820143764721380512,\n                14046670199595657632,\n                4802431421646786560,\n                4822641704561109600,\n                4824930993783765088,\n                4802144404521020928,\n                14034780170709607936,\n                4821751474473472320,\n                14049298800854277264,\n                14045421448637922528,\n                4814768763870693696,\n                4824367268709780944,\n                4823884230130873312,\n                4815452285659675136,\n                14047716253881801456,\n                14049013520174956112,\n                14050261248405261104,\n                4825076658505055008,\n                14043594259851181760,\n                14038932597036082944,\n                4824733526815516928,\n                14042570109117421728,\n                4822314610181687584,\n                4826943684329973168,\n                14042508323346198848,\n                14035695575419164160,\n                14044195475706875008,\n                4822256929819681344,\n                4824776955382945728,\n                4820736289951554400,\n                4824587143688499664,\n                4824979744300740624,\n                4819969571161827552,\n                4823147499402255712,\n                14043124829693532608,\n                4824715988204073472,\n                4809412333651321344,\n                4817618821739681984,\n                4822587804868824096,\n                4799921925377231872,\n                4822826724302940224,\n                4825123135569557824,\n                4827471205971946336,\n                14047378112159624736,\n                4826573071239109872,\n                14050398375395817808,\n                4826223012403801712,\n                14047554599342413712,\n                14046204387464520160,\n                4824614093765751280,\n                14048070963445095424,\n                4824920686352845728,\n                14048836956503377488,\n                14042033653767829568,\n                14045220400231792032,\n                4824629501893930400,\n                4819734906215831680,\n                4825443236016069616,\n                4826711979761802880,\n                4821146484393830368,\n                4826777864702804688,\n                14047221764860915792,\n                14042026417581312832,\n                4820285560699197280,\n                14047226999559571760,\n                4787602508735610880,\n                4823936981115367216,\n                4823591495175996864,\n                14033741879784349696,\n                14048361774471680016,\n                14050822882427221280,\n                14049567207357729616,\n                14050567733116709344,\n                14044298050788024672,\n                4821948804293039776,\n                14047944342994330464,\n                4824490210950416224,\n                4823697657900140080,\n                14043900304960523360,\n                4824226103093316784,\n                14033728005607968128,\n                14050398296653486032,\n                4815002566237056128,\n                4824972401781073568,\n                4823399058762957904,\n                4821647344827854912,\n                14043506142490625440,\n                14046900087792493920,\n                14026937414561577984,\n                4804363751547990016,\n                4822396623250197312,\n                4819919500543536864,\n                14047578144727888400,\n                14048505909572123088,\n                4824995475208691360,\n                14048399882332694944,\n                4819662007181144576,\n                14045817039662018272,\n                4825359733401114512,\n                4782900175721742336,\n                14048595915477955632,\n                14024671839365934592,\n                14033702678381508096,\n                14034082286008763264,\n                14032193188209399296,\n                14043823712926008928,\n                4815904838782364992,\n                4825474027556688528,\n                14048453841421097056,\n                14048711897358954128,\n                4817264954216958336,\n                14045790320795312224,\n                4825977759322491088,\n                4811108932895345408,\n                14050619395026507456,\n                14047546194496197552,\n                4821281558749465536,\n                4826323819509116848,\n                4825069327449529760,\n                14046472657775065536,\n                4826943144128455792,\n                14041016364621278720,\n                14047031318265985072,\n                4826657357752326336,\n                14050903483722911424,\n                4825862329558265952,\n                14041830234763096192,\n                4821002482792071968,\n                14045141090235591168,\n                14034120605084120064,\n                14041746674067750720,\n                14048961147925078576,\n                4824506967465471072,\n                4810218555031910656,\n                4817334227632935104,\n                4819673687848678080,\n                14047035987480697776,\n                4823707647925674800,\n                14050753368027079232,\n                14050751128734157568,\n                4826312425000941664,\n                14049998191138379392,\n                14044687554861509728,\n                14043736602194200768,\n                4827197903823811568,\n                4827127297527704256,\n                4823750329270282224,\n                4815125194873689728,\n                4827022189289690896,\n                14044938720144388608,\n                4824680263300379440,\n                14049456147030673328,\n                14049754162131054608,\n                14038077139704340544,\n                14048205603808229152,\n                14047403131663614976,\n                4813495894821509504,\n                4825978479301031840,\n                4826179911661365728,\n                4820574390857220928,\n                4823632496301265808,\n                14049957197783526208,\n                4825427331190650400,\n                4825592472852119008,\n                14035332547723591424,\n                14049499533359377424,\n                14049522382471897520,\n                4822573083094077632,\n                4822226755648871136,\n                4826074696507201584,\n                14045770062522718528,\n                4826439870924835984,\n                4821541377173092128,\n                14050827733559938432,\n                4823910365809511952,\n                4820611184836479744,\n                4823591249804754624,\n                14034788110938435328,\n                4810433476642056960,\n                14042792414334466048,\n                4827329776650402304,\n                14049733642563550352,\n                14029839347643400704,\n                14042240822891272960,\n                4815197401178689856,\n                14048934715739207104,\n                4826327471363181968,\n                14026532946730756608,\n                4824238593354989232,\n                4827534234690181840,\n                14050257916270278208,\n                14047735853276302704,\n                14039907775963307136,\n                14050428504992850192,\n                14049114833708133008,\n                14049449998125502720,\n                14040991952554807488,\n                14047483726311056992,\n                14046432757916023680,\n                14048033604615045600,\n                4818716246421539392,\n                4822517009167618912,\n                14034952150285154944,\n                14049943432368571504,\n                4815949131064252672,\n                14044675735970686656,\n                14047343592979287392,\n                14048640225518876960,\n                4826811033709229856,\n                4819288071959575168,\n                4822927236896679424,\n                4823099178847253280,\n                4821709943674780864,\n                4814678903250604032,\n                14050090007387814384,\n                14046919834140492352,\n                4811583017113625088,\n                4821441865138998848,\n                14029066363982651648,\n                14037031379643669120,\n                4823367907325536656,\n                14031935670364565504,\n                4826031729053701456,\n                14030592987771446528,\n                14042320154001939968,\n                14038163677117582720,\n                14049705917369389744,\n                14023166337212724224,\n                14034028223875524992,\n                14049229907346033120,\n                4825975422726138560,\n                14048824751234473376,\n                4820314256783915840,\n                14045984979326855008,\n                4827144204312868192,\n                4823964591121316160,\n                4817985657136715328,\n                4821500380213644384,\n                14044721794582030016,\n                4822476391350697856,\n                4815605548300137728,\n                4813304855034136576,\n                4820821160961760800,\n                4824830586517209392,\n                14050092328835294400,\n                4827270122667852176,\n                14038816622389051136,\n                14037722797843146240,\n                4817285703013165376,\n                14047855397411323008,\n                14048534949378627104,\n                4826322119666881056,\n                14047594419604411520,\n                4818245841206746816,\n                14033871995781988352,\n                4825203060820458544,\n                14044923631564411584,\n                14042722353808932832,\n                4825303756678937888,\n                14038209922191202048,\n                14046932769278311648,\n                4822034464997039936,\n                4807265624864805632,\n                14046125009671282048,\n                4823673755687687248,\n                14047553077547373424,\n                14050289850285319920,\n                4823402464296434864,\n                4813514856479012480,\n                4823973674097274880,\n                4826697050359314960,\n                14047931556667538432,\n                14026032745708298752,\n                4819254213422082464,\n                14050410949763823440,\n                14043253312615272224,\n                14050286302552970464,\n                14047471872370744864,\n                14043808468669004192,\n                4826165539587482624,\n                4820760110085622720,\n                14049458073641455488,\n                14035821210798496768,\n                14046894523026764736,\n                4825584863612294000,\n                4824635487878757200,\n                14047926159819913104,\n                4806077858399183360,\n                14042978102166706592,\n                14040743173511341632,\n                4815912675432628096,\n                14047950993586569936,\n                4819825749892560288,\n                4817106096189092736,\n                4815477945362809472,\n                4824027672990393888,\n                4823136474217280160,\n                4816765255167841984,\n                4826426447667747392,\n                4825697785836847312,\n                4826148514549848672,\n                14018139189444648960,\n                14048824640855377536,\n                4826087354719701344,\n                14045337436546218208,\n                4824827062987726160,\n                4824303789194450832,\n                14033930753729546752,\n                14041534810055173312,\n                14049572454444343680,\n                4826668033060512512,\n                4821593613436720352,\n                14047908856414982784,\n                14040754983644121280,\n                14043650093291714592,\n                14043971627959739776,\n                14048345285746207584,\n                4827470481687982512,\n                14034972829643104256,\n                4825876074492582080,\n                4824156051457566080,\n                14050241455177549856,\n                4824547522687808368,\n                4825690118020054944,\n                14042449363575596896,\n                4826536632009297040,\n                14047114662869147520,\n                4811474144798917888,\n                14048199364761032256,\n                14050312744345024432,\n                4819427969999402048,\n                4823580393309598400,\n                14033264272005404928,\n                4813017592658180864,\n                4818345531655184448,\n                4821813430172926976,\n                4815949157081662016,\n                4825646060944816640,\n                4821133920102791392,\n                4826755056978629552,\n                14048861007595561872,\n                4821906485362212000,\n                14049526204527277776,\n                14049705701990684352,\n                14039638815157811200,\n                14049572982917386896,\n                14047273650490327792,\n                4825277340358538432,\n                14047367318477927872,\n                4824706573041473664,\n                4822647582773721312,\n                14047804777454083792,\n                4827372578751824736,\n                4825079779431517888,\n                4827160403100192320,\n                4824103390694118000,\n                14034886834366445696,\n                4801829262160078848,\n                14039762585011989504,\n                4815294276729558528,\n                4826894437963996912,\n                14042229328219276672,\n                4811086186472434176,\n                14013526282223071232,\n                4809287210836285440,\n                14049778182087927344,\n                14044732544344534400,\n                14028937117232335872,\n                4822993231573216096,\n                14050613592851272992,\n                4827324457778488912,\n                4820037198918391968,\n                14041102401015397824,\n                4825401255649667040,\n                4820520102616682144,\n                14032065290285577728,\n                4819988161791230176,\n                4825074429088906928,\n                14028093281216314368,\n                4825902395936467728,\n                14050006555322218912,\n                14046737675514665616,\n                4808796036947104512,\n                4825200938220528048,\n                4823969928474717840,\n                4825039799455237616,\n                14045844224917100448,\n                14042067174906836416,\n                14050278727575344896,\n                4825751062043614256,\n                4823706312059070352,\n                4825012483574840672,\n                4822847443248041376,\n                4814659527826940608,\n                14050017934257601392,\n                14038450298828449344,\n                4827245570764288352,\n                14048862037354472064,\n                4826418814259171360,\n                4823913297148910704,\n                4816104279061863808,\n                14034017109329083008,\n                4813095091177205760,\n                14048219376269528000,\n                14044747138651652608,\n                14048904809164598816,\n                14047675737241597584,\n                14048389781924186112,\n                14049688445689735792,\n                14049561007035039232,\n                4816715160504330752,\n                14048289741721088912,\n                14045790956092582688,\n                14033758530111134592,\n                14045903142651934208,\n                4819054037742504864,\n                14038833284531211840,\n                14047432247490239920,\n                14037937180325997056,\n                4815468126803496704,\n                14049489987750221456,\n                14048736606123453888,\n                14048410273649090272,\n                4825205747388996048,\n                4818382142166444480,\n                4823442846389619040,\n                14046852454240607104,\n                14047381251339453920,\n                4825431114848987200,\n                4816210102156059648,\n                14048546464514646080,\n                4825211768181471536,\n                4826410336425282768,\n                14049529815677378320,\n                14046772419246927440,\n                4814906014225211136,\n                4812028328282472064,\n                14049355839577694272,\n                14045307973039600128,\n                14043015181550925888,\n                14043184442480630240,\n                14044695593169561856,\n                14047700506902293184,\n                14047524065584890544,\n                14047207783201930928,\n                4827368092493634704,\n                14025687234495816192,\n                4818213448122143552,\n                4824135894511944560,\n                4826188062098920912,\n                4824087500061719296,\n                4824860403265937504,\n                14049078248388160864,\n                4824263586222235344,\n                4814372308045610816,\n                14049401025871879872,\n                4826513770040956064,\n                4826926321838507952,\n                14049241687990881936,\n                14048206632566548080,\n                4825522080418198912,\n                14049305165946982208,\n                14047149351841519200,\n                14046203123113878112,\n                14040930842304126784,\n                14040007461961851456,\n                4814556857962670080,\n                4824221088434885712,\n                14047420720794598592,\n                4801917292426891776,\n                4823725261690029744,\n                4808429160253275136,\n                14044115518076677376,\n                4827060715213216224,\n                14045820660171675136,\n                4815990217718815936,\n                14044128444329909376,\n                14034025466636798976,\n                4826968336662012464,\n                4827457089673258512,\n                14037713619515486976,\n                4820687048034723072,\n                14047399391908959088,\n                4824843002582742304,\n                4824616997766990512,\n                4827364691500590352,\n                4822706623510900768,\n                14044036417534410976,\n                4820314385196276832,\n                14050578607574502768,\n                14047593507232460240,\n                14050719269215028288,\n                14033437509402462336,\n                14047717883930505520,\n                4823690402705489760,\n                14049101757737550064,\n                14046958557282545600,\n                4823659171409903760,\n                14024758379697304576,\n                4801132068328516608,\n                4825381563035240192,\n                14049621005844140672,\n                14049100130676469952,\n                14050435179636612784,\n                14040930408184823296,\n                14048996112254772064,\n                4824218254522013936,\n                14043401774999325440,\n                14030361860190806272,\n                4823406631495159632,\n                4827399112849435152,\n                14041692300575804544,\n                4814072169833773312,\n                14049266232522196736,\n                14049448467368422544,\n                14047717269449736960,\n                14048917952352454784,\n                14044794656751510272,\n                4802950731667485184,\n                4823743900915225216,\n                14048182339037749168,\n                4793842383082405888,\n                14034211709575233664,\n                14048781755939040992,\n                4823621822123394256,\n                14049552480197563600,\n                14047666760619420464,\n                4820223605471142848,\n                14048228442525089568,\n                4822676681465611040,\n                4812662680993679488,\n                4824752815960458800,\n                14026896154810910720,\n                4825259576539552560,\n                14048498286076379600,\n                4824151478002402304,\n                4801136464720155648,\n                4824889430092670352,\n                4826415277196794608,\n                4810928722964551168,\n                14042286429905445728,\n                14048392744814175920,\n                14050151719985668320,\n                4826992050373487248,\n                4816291980325788864,\n                14039545878587970304,\n                14043631370147431616,\n                4819092225593443456,\n                14040347530954600384,\n                14046783632004125376,\n                4823589933606790944,\n                14048688399459479232,\n                14046207497733367776,\n                4810803205586402944,\n                14026188340085927936,\n                14046618758614173408,\n                4815550900307929856,\n                4819787244044644288,\n                4810642813400592128,\n                4817446151690797440,\n                14041172904004259136,\n                14050034382488672032,\n                14048557700185702112,\n                4825328991444815120,\n                4820215203916191456,\n                4815610250177554176,\n                4815577598021148800,\n                4816242307723599936,\n                14048531150030771296,\n                4824749835675082912,\n                4825918944139598480,\n                4821906665940949056,\n                4821126800484833088,\n                14046407663870124512,\n                4814631182226612352,\n                14035308017630417024,\n                4806955943362115328,\n                4825949302261867808,\n                14042654450308971552,\n                4819002226610695616,\n                4816920352321078720,\n                4823104680385367104,\n                14046083325877690592,\n                14047264774843374576,\n                14045936558956279392,\n                14038987754355189056,\n                14046727273650193504,\n                14032393852681471232,\n                14044501927911542336,\n                4819112070292472288,\n                14046422359134930336,\n                4806436395944237824,\n                4826144895517751072,\n                4825996881753209344,\n                14046765211523567440,\n                14050769606019933456,\n                4815848057591745280,\n                4824413486326639360,\n                4810715011400012032,\n                4827283648904997392,\n                14045200247545704832,\n                4821272495297799488,\n                4818070754547789504,\n                14039722428426476864,\n                4825410079729698048,\n                14000285193140699136,\n                14040974942146253760,\n                14047730788081596896,\n                4826354336072926896,\n                4825532282265360128,\n                14044679958358097184,\n                4805876032793872896,\n                14047495126766447248,\n                14049248750835755424,\n                4819155539256106944,\n                14038840155410299968,\n                4824435005034634464,\n                4814569590254206336,\n                14047765783031600448,\n                4813871772627196544,\n                4821481839601562336,\n                4826641754344493760,\n                4824526777896244096,\n                4819061296163744160,\n                14039944886244769408,\n                14039915038434647680,\n                4827443872741467776,\n                14045585699229411584,\n                14032378653259896064,\n                4821189559285876096,\n                4826370528286312320,\n                4824677925515610768,\n                14045060943439282080,\n                14049901342413930496,\n                4813371528538449920,\n                14044684542653168992,\n                14049568489926521600,\n                14036656762722131200,\n                14037125842619706112,\n                14039738301263239744,\n                4823359585567389760,\n                14037389131326764416,\n                4824088163260013648,\n                4820998053844144800,\n                4827072556256991424,\n                4823551499735679872,\n                4825617025705500368,\n                4826398773626268944,\n                4827079271409614304,\n                14040163236363352704,\n                4825740876669531024,\n                4827053366299701920,\n                4823923043686703488,\n                4813641184365473536,\n                14041923015940546368,\n                4826755357356721856,\n                14048682357901566352,\n                14050182151085603520,\n                4820026226778570240,\n                4824120137725686144,\n                14047927810959947072,\n                4821612800595171904,\n                14049360691055243600,\n                4823430008624704112,\n                4808836303728278016,\n                14047738652259099360,\n                14050365317738478864,\n                4823709498600428000,\n                4826248400919049088,\n                4815770902191781376,\n                4821516438339962592,\n                4809300794441592320,\n                4817901470915381760,\n                14045531788116694656,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n        SerializedFFTContext {\n            p: 4830638365936189448,\n            pinv: 4383068506908503009,\n            mod_data: ModData {\n                n: 910395627798529,\n                ninv: 4366620577834603101,\n                norm: 14,\n            },\n            primitive_root: 7,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                4823953248388537392,\n                4825083993720127840,\n                14049275608845979040,\n                4824558626898942528,\n                4803703128081250816,\n                14047217599387735920,\n                14045860596578195104,\n                4823704989170698784,\n                4812117899404575232,\n                14029321031068354304,\n                4817683911404602752,\n                14049274581278795600,\n                14041025923768159808,\n                14048591530656053200,\n                4823224929182377440,\n                14044807356283555680,\n                14048565011689080224,\n                14048449022444332320,\n                4824619472446582144,\n                4823545490913121568,\n                14048194762364833840,\n                14043725730480177248,\n                4820997252961902688,\n                14046969896560937456,\n                14047944254408845424,\n                4814509113908708992,\n                4820477893383007712,\n                4822886236437798624,\n                14030159836736439296,\n                4822273251020797280,\n                4824537938186787216,\n                4825647061013664432,\n                4823728502996949664,\n                4821165689330117568,\n                4818024201873709568,\n                14039361062917015616,\n                4821924234251739584,\n                4825479218392732880,\n                4821220156209760192,\n                14023539604117214208,\n                14046701094988933632,\n                14038513230084538304,\n                4825632302374308352,\n                4814590346725569280,\n                14046991709532908576,\n                4800002922553151488,\n                4816494586703843520,\n                14048611296086688256,\n                14048428041204873072,\n                4824178991170477632,\n                14048490301387049200,\n                14042705275438139840,\n                4821684822767825376,\n                4813424424977668736,\n                4803161907772867584,\n                14042394905524651136,\n                14040982099804935552,\n                4806735342721739008,\n                4820924352012881504,\n                14046277953908248512,\n                4818426322503451072,\n                4819296472033449440,\n                14048201536697058832,\n                14045292507001908416,\n                4823509433060748064,\n                14038811872899390208,\n                4823749491126068816,\n                14045633668192059904,\n                4814957669901982016,\n                4820728484829706720,\n                4810826174971240960,\n                14047010399146799952,\n                14047627826635961456,\n                4824503278026854640,\n                4810778845404246784,\n                14018769033322659840,\n                4823718911246657056,\n                14034213468509213312,\n                14048318162641566272,\n                14045922188606898912,\n                4808715529640919296,\n                14042831698965526592,\n                4825980062247441920,\n                4819934294852330240,\n                4824873661851166528,\n                4788410949623271424,\n                4822667211326123904,\n                4819447364204318624,\n                4810347438158859136,\n                4808913645787965952,\n                4821158218039483552,\n                4823547875455008192,\n                14043959405600712992,\n                4810762224885885312,\n                4796071786087073792,\n                4821113327210515232,\n                4823092688685074208,\n                4820596459587901088,\n                14045872098857687488,\n                4825734698328484176,\n                4819652954745367136,\n                14049375417232557296,\n                4822957853727417856,\n                4823376422399993536,\n                4818342611857321664,\n                4812217687694509824,\n                4824601140231727040,\n                14039279975802662144,\n                14040584312719823872,\n                4825871844980382656,\n                4823533362441899216,\n                4823460032919144944,\n                14048528666393331472,\n                14048620582578066320,\n                14047253482568712976,\n                4818386184811889536,\n                4804993988781171712,\n                14048718481021689536,\n                14049275508725685552,\n                14023555239694610432,\n                4812180889514960896,\n                4823456411053849280,\n                4825959825926376512,\n                4821664253171391936,\n                4825223272740620416,\n                4825599422265346592,\n                4825459023037646448,\n                4816433534926346304,\n                4805921150676023296,\n                4822650003309728768,\n                14044855148220296224,\n                14044851843919453024,\n                4822712319063919968,\n                14041858962814587584,\n                4824084971789193328,\n                4823683832102123808,\n                4826094734836133216,\n                4821042713112845536,\n                4810552068489937536,\n                14009150108824190976,\n                4821288213246124416,\n                4815774814643972736,\n                14047134923109627056,\n                4820656392250524320,\n                14047562180646757936,\n                14049422473494486512,\n                14049504298399032288,\n                14044624869283200608,\n                14047105636895727040,\n                4811057924139905920,\n                14046547085047285056,\n                4823529845578198544,\n                14042634533201991072,\n                14047920321929641248,\n                4816379969293490560,\n                14048766282100756928,\n                14046327830295601408,\n                4820461407562753952,\n                14043906922314265216,\n                4804374488389633536,\n                4821307016383498112,\n                4824810200504819488,\n                14048444257415607520,\n                4826026480753740864,\n                4824466787276303808,\n                4806523135315836672,\n                4822279514727872640,\n                4823036130075245600,\n                14043069692977278880,\n                14035967625060981760,\n                4822948649596260544,\n                14048596972578474224,\n                4821970848247535200,\n                4811842985463049216,\n                4824260309925335376,\n                4821990808009911168,\n                14049120049240933312,\n                4823408644246315584,\n                4819668409327055680,\n                14047298351547703296,\n                4820109343585729216,\n                4825223498588132640,\n                14043550967936567456,\n                4815364838631025600,\n                4797209284497325056,\n                4814174389837234944,\n                14040591645354942528,\n                14049072477378298592,\n                14042760207936687776,\n                14048872208147027248,\n                14048018172151038176,\n                4819409765338495616,\n                14038704454474944576,\n                14046134763060242144,\n                14048963994710033056,\n                4818948776086721088,\n                4820589624317163168,\n                4808445475087085824,\n                4823397744013543488,\n                14048792545867666096,\n                14046568923146552352,\n                4817033876557824256,\n                4824492821322020448,\n                14046849022540854560,\n                14034105467648868736,\n                14045261550903268192,\n                14043410693888634848,\n                14046826761071100480,\n                4816755163740240320,\n                14044755616210738528,\n                14049291586897935216,\n                4825858830293189168,\n                14048239312138930720,\n                4783651790069874688,\n                14047013225808426384,\n                14043506562133739360,\n                4822057256751904032,\n                4815320473529030976,\n                14047620675719663936,\n                14048354017908925520,\n                4825883180799872272,\n                4824372690969326928,\n                14046832549511142016,\n                4818630927824896640,\n                4824484475076486672,\n                4824078425153333680,\n                14043468921944181440,\n                14047066873492539072,\n                14039792182053281728,\n                14047073419824636976,\n                4822188982574306912,\n                14046270787629103904,\n                4825874270076618944,\n                14048815527454091600,\n                14048711876016877152,\n                14042389048580125600,\n                14045841002915635328,\n                4824537658458520208,\n                4824113124921987520,\n                14048823020259652448,\n                14046529088258217632,\n                14048401133198012784,\n                14049455056945456624,\n                4821795723484087776,\n                14047054645656454096,\n                4820149308939004000,\n                14025018424296692224,\n                4817996996499996288,\n                4813706085482655488,\n                14049308552360670624,\n                4820405028202317312,\n                14027587350854545408,\n                4818109941484212352,\n                14042405548863531840,\n                14041703772267821504,\n                14047224471701078480,\n                4824726043440232320,\n                4807526909313088256,\n                4821293380873255040,\n                14042405776601684352,\n                4823468121353609648,\n                4821456035857869664,\n                14048656217488111008,\n                4825102598476292384,\n                4810961974498593408,\n                4825467610202686352,\n                14043694176453104768,\n                4821820863778876768,\n                4825391895584308464,\n                14039154425849546240,\n                4808138383129685760,\n                4825188621388997888,\n                14047648612396323760,\n                4820363324486896416,\n                14034719057045182720,\n                4823645272290631904,\n                14049335325575376928,\n                4824599323870394016,\n                4811024792146314112,\n                14042724664691536896,\n                4826025145299946688,\n                14033715910156323072,\n                4819443651062763104,\n                4815984832222008704,\n                4824229659689360768,\n                14045463557354927584,\n                4825376651425853440,\n                4819438192701056032,\n                4817116815552996224,\n                4821308831284607136,\n                4822633234101551648,\n                4812743346687088384,\n                14048240421667925056,\n                14037641820484748672,\n                4816137993421516096,\n                4803501548758763008,\n                4825525825748241248,\n                4815122249009667456,\n                4824477335476147408,\n                14017203941536200704,\n                4824038273196424432,\n                14029281820040242432,\n                14044126003483769056,\n                14047878397914920240,\n                14048034874375319648,\n                4814986718331060224,\n                4819306150039353632,\n                14038154729728284864,\n                4823482525960242736,\n                14045901837959338336,\n                14038541098886310720,\n                14047338117915928560,\n                4823566307707468816,\n                14047039770878715472,\n                14044569679087154592,\n                4825365567720527840,\n                4825584344455624160,\n                14049442328935842192,\n                4823250404931640224,\n                4824148534724784672,\n                4817980249632793088,\n                14044216122860790752,\n                14046830544426702064,\n                4826128759605670704,\n                4812014905373941504,\n                14048105824940779504,\n                14045417170434438464,\n                14048863639040829728,\n                14037530276010274816,\n                4817922093356476736,\n                14035279143420302208,\n                14044186296602954912,\n                4822342874949691424,\n                14038416957021400256,\n                4817414357615335552,\n                4822844826938921792,\n                4824258832129913648,\n                14045521092932721248,\n                4804206449353889280,\n                14047796647945882240,\n                4816747602877404096,\n                4823903987944072864,\n                14032799037965747200,\n                4814330751977444736,\n                14045968555905400000,\n                14048157126397274960,\n                14041407820743605440,\n                4825174991528644720,\n                4810352550957093888,\n                4825830854087414848,\n                4823018937621715232,\n                14043179403893050752,\n                4826087643510056208,\n                14040404768956755712,\n                14045769913846005664,\n                4823836853493768688,\n                14047675630400060096,\n                4825591976428686000,\n                4820160704103389696,\n                4825977261315662448,\n                4820011116443432064,\n                4814151471421857024,\n                4803280076769162752,\n                4819521148737191040,\n                14049022167673547760,\n                4819679658566226784,\n                14047068513268930560,\n                14047072616017833792,\n                4819378615714481536,\n                14046650759539548800,\n                14035364453431222144,\n                14030053348789753600,\n                4825700719359063984,\n                14044526584110923520,\n                14043957901269283968,\n                14049313297550170672,\n                14048939875429568128,\n                4791216540694831104,\n                4822961721116407296,\n                4822406362512763776,\n                14049082284145589168,\n                4820217992215437024,\n                14044480275792773312,\n                14040788003404518976,\n                4822380564178811776,\n                4817034878203484032,\n                14049313872328390080,\n                4818960524102592256,\n                14043628023005129440,\n                4825269036803627168,\n                4823157895937672704,\n                14043288357667439712,\n                14028276451788894208,\n                4805512658545223936,\n                14048735525210923056,\n                14043744743516957344,\n                14041544352493287744,\n                14049364012766889232,\n                14033296220318315392,\n                4816901082524599680,\n                4818264975119238976,\n                14039628942079135872,\n                14048314832662593152,\n                14041835736408685312,\n                14047337492884856176,\n                4820478272354778400,\n                14048000513096537760,\n                4825065748009982944,\n                4822048610394722784,\n                14046871100847718624,\n                4815811072385848960,\n                4824331831052059744,\n                14047943547581407712,\n                4809151315902813696,\n                14046241942888731296,\n                4822146993129050560,\n                4822096017086327648,\n                14044327745697293696,\n                4820350550652206752,\n                14024521197801320448,\n                4823889543663640720,\n                4824008856115605200,\n                14046140174888396960,\n                14048623052416985888,\n                4819399009524512864,\n                4815024815889547648,\n                14044839606423821280,\n                14047892606675986032,\n                14043455633135033376,\n                14046124297122335808,\n                4824950207011665936,\n                14039856917326082432,\n                4822119435580499744,\n                4822573960278262528,\n                14044640620977698048,\n                4821439571202711264,\n                4786678533351006208,\n                14042177753641602624,\n                4821095366244187552,\n                14031215686492833024,\n                4809909582778345728,\n                14036087898714888448,\n                4824114371515345824,\n                14044583842528841632,\n                14049017165550411344,\n                14024424309353656832,\n                4821193836839761696,\n                4824893979607517136,\n                4825288280109719856,\n                4824156359951471232,\n                4824492980103616192,\n                14049368081538950592,\n                4817993961340249152,\n                14048383596497315648,\n                14043114754878088992,\n                14047293100659476704,\n                4797946862342383616,\n                4825307821932793168,\n                14031166591573483264,\n                4815090634218279872,\n                4813615659856295552,\n                4808247220082154240,\n                4817654756707757248,\n                4825189900209521056,\n                4819285444664320160,\n                14040983986961982912,\n                4821194793193993504,\n                14047192053775109824,\n                4815201361173582208,\n                14049245296529701728,\n                4810994209390792448,\n                4826020194031829184,\n                4810173151544425344,\n                4820522164401433056,\n                4806065339722821632,\n                4812429038963743104,\n                14037730777429739456,\n                4823382627940347184,\n                4804763631472912896,\n                4824062613331113536,\n                4820103988356859904,\n                4822151469707373952,\n                4825752120103231280,\n                14048126007571492656,\n                14044141848136231360,\n                14045426663779173856,\n                4821386596066810848,\n                14043580103710371776,\n                14049286625576349328,\n                4817518229588646912,\n                4823425813215830224,\n                4813031980038996736,\n                4809649605305686272,\n                14036888054973053184,\n                4819701922567040768,\n                14037214991419952384,\n                4823547303553466080,\n                14046123571309766784,\n                4800343520334873600,\n                14038709976900367296,\n                14037866488732471168,\n                4818966594847896832,\n                4817460729130668288,\n                14049056114215253184,\n                14043730197059700416,\n                4824570229506735008,\n                4821237415053814432,\n                4817144072762029184,\n                4824591333785347776,\n                14042584898417558656,\n                4788947292574593024,\n                14047790630409759696,\n                14047550726237428608,\n                4822238171356125760,\n                4809612428219089408,\n                14016609240414943232,\n                4824295347346960064,\n                4824055408006797232,\n                14039796386350428672,\n                14047063945169299104,\n                14043984014069088512,\n                14036685261505493760,\n                14040895782250957824,\n                4823918355798592832,\n                14049312825137551808,\n                14045273802766847360,\n                14047407748782060224,\n                14048183745300366800,\n                14045642687482105024,\n                14048753373521557040,\n                14037835168048565696,\n                14046458220779203936,\n                14039677876305374080,\n                4821227751631967840,\n                14040713637218013440,\n                14043786070643033504,\n                14044335093639923392,\n                14048306763172282432,\n                4820744701446598272,\n                4798425194468366336,\n                14034842320022247424,\n                4819694546609863136,\n                4824575687450819808,\n                4823878248212043856,\n                4823978141389907552,\n                4825570065782731376,\n                14037716658545033088,\n                4820305726901694816,\n                14045699945363178848,\n                4825013278618348480,\n                4789062431559569408,\n                4814784471433347072,\n                14048111086211267168,\n                14020619167057711104,\n                14047369775899941392,\n                4815600764618304064,\n                14049103172804421984,\n                4825873890332338944,\n                4823593289310521344,\n                4819666153957478848,\n                4823237514960742272,\n                14027744525602444288,\n                4825584569701882864,\n                14043665139329496672,\n                4823405538168842576,\n                14049395684821107136,\n                4825668465713925808,\n                4820658444380342144,\n                4819820867580648160,\n                14047295166845210656,\n                14044625836677581792,\n                4824306993923413824,\n                14043277352294806208,\n                14017104583530530816,\n                14041408743768704192,\n                4825337046133245888,\n                14043459424015837152,\n                4818791005747982464,\n                14043484365494872832,\n                4814492915334685440,\n                14048850156880681760,\n                4823474313372550144,\n                14049478105414574064,\n                4801752853527157760,\n                4824412154244619280,\n                14048347277736416752,\n                4824984710439790800,\n                4822677850292147872,\n                14048583931900137376,\n                14044797665892990368,\n                14048733968986519872,\n                4824128807849208928,\n                4821678795456354368,\n                4823730962631421824,\n                4806759091449108992,\n                4807846115789023488,\n                4824499778241538656,\n                14044061864598245056,\n                4817520835622736128,\n                4823593575572307792,\n                14034016916414466048,\n                14036382201833365632,\n                14043567033351683104,\n                14028777689424467456,\n                14041130407231636032,\n                14039161108259370240,\n                14042753570276657472,\n                14043515335673833920,\n                14042764250335561280,\n                14045674049059466816,\n                4822083705534830048,\n                14039932944491941952,\n                14046812451228188128,\n                4825508675374609936,\n                4821856665246076992,\n                4822451886731514432,\n                4824505200319042496,\n                14033938158495151488,\n                14043282851803953728,\n                4823469851512349408,\n                4823627755471563616,\n                14047731341168771776,\n                14048654130466885248,\n                4820895642519157024,\n                14036320232891451776,\n                14043483891116644544,\n                4821966039262706944,\n                14047759090244674656,\n                14048283538237087696,\n                4817325311904711616,\n                14047681406781325600,\n                4806821252655495936,\n                14036988929254572160,\n                4824053983005699200,\n                4823837402328387824,\n                14041921342841544832,\n                14044139196087001824,\n                14036606647725917184,\n                4824282786237130096,\n                4816645144209495808,\n                4825799925434165232,\n                14047788571233848544,\n                14045484886748963328,\n                14028524439307377664,\n                4824434132537116000,\n                4813386901685951616,\n                14042350400140175136,\n                4825772706005453408,\n                14047582611626698912,\n                4820203911544131744,\n                14047681484591723424,\n                14048140874029456864,\n                4819792003275038528,\n                14044795721922856768,\n                4817800535066705536,\n                14049464148580589792,\n                4824402420292726608,\n                14044791699938753216,\n                14041037612342588032,\n                14041863687808391040,\n                4824217249110654640,\n                4826001519285196192,\n                14038296375136873920,\n                14045504147248822432,\n                4823910714973418928,\n                14044658950155976672,\n                14034624867941200000,\n                4821395930520335712,\n                14041084919486166720,\n                4824713508867757472,\n                14044145840700107008,\n                14035463543032299776,\n                14045772754813139008,\n                4823934497472800752,\n                4821887790389361952,\n                14045693729910927712,\n                4821011501311774016,\n                14046651368575184064,\n                4819273244675296448,\n                4818937185678030816,\n                4815006552904790976,\n                14046837901756820160,\n                4824894121203218144,\n                14029417748654791680,\n                14043852708649155808,\n                4817388874652616576,\n                14042420722934610848,\n                14047316871774709344,\n                4821441426874899424,\n                4814488714718053888,\n                4823970978275452688,\n                14048532072002852144,\n                4822797158083407488,\n                4818672100457414144,\n                14048890263534194800,\n                4823706211534315872,\n                14049222297326893392,\n                4820502980005779552,\n                14047822342166140208,\n                4803375436592053248,\n                14034388047058697728,\n                14044718981433919904,\n                4820567863148559520,\n                14048359635938309648,\n                14048692051816816624,\n                4812575163169714816,\n                14045787787949337408,\n                14043431647812779968,\n                14039365734592012608,\n                4806765885879651584,\n                4826078626326100832,\n                4824947731783341072,\n                14048991121840381152,\n                14047181734527671760,\n                14039127034250110208,\n                14048579771075486288,\n                4812404479463878400,\n                14046834645793195248,\n                14035985937727458944,\n                14049325749853941536,\n                4821548085463008640,\n                4823666538394645136,\n                4809514371974909952,\n                4825757322419148240,\n                4822869662775097440,\n                4825511594891152192,\n                4819754070485701696,\n                14049159941061074000,\n                4819970646820991264,\n                4824277650513278864,\n                14047516265122351424,\n                4822572389353899040,\n                4825350190125892544,\n                14046614883698788768,\n                4823654199878109296,\n                14035138305084036992,\n                4811990183293041920,\n                4826035914029913616,\n                4825698265038752576,\n                4823279320258954080,\n                14045043386872232096,\n                14032313217007383040,\n                14044716117862326208,\n                14039912072061881984,\n                4818702736289266560,\n                4819280411070815040,\n                14042535436479928640,\n                14041359070074589056,\n                4821741215284991072,\n                4821200099087147584,\n                14043952106648267616,\n                4820642937196403328,\n                14043577356478246272,\n                14035334688054819072,\n                4820435266939396192,\n                14048260440663814736,\n                4811261387761558784,\n                4815488970708472512,\n                14027137219464487424,\n                4823440788349503728,\n                14043882337908217376,\n                14046627618549570944,\n                14047650697836113344,\n                14048874955758520800,\n                4820531222934491968,\n                14045207416096249088,\n                4824768247361016048,\n                14039494650865925568,\n                14046955488514550048,\n                14029753947182124288,\n                4823491728644163072,\n                4819132326111815104,\n                14046113486044344256,\n                4823212333688003616,\n                14047867124922568240,\n                4823390081715787728,\n                4811210057896234880,\n                4825672659316091600,\n                4800837885380390912,\n                14044424782998466272,\n                14046230913752192224,\n                14048539060472864464,\n                4814841269326680192,\n                4818569149948283776,\n                14017499162106810368,\n                4819798846932783104,\n                14048256146398728496,\n                14049246514430649648,\n                14042747735810799904,\n                14043899415607785440,\n                14042838619177541600,\n                4824699167035684176,\n                14043366427858079232,\n                4821987329132626720,\n                14024981376105126912,\n                4823819010093279792,\n                4819508395545464640,\n                14039112515896504192,\n                4824960560275669040,\n                14044730414669784672,\n                14045641623050641312,\n                4807890101022833152,\n                4820481868470320928,\n                14040582983228397696,\n                14045551746283425984,\n                4824638423022658640,\n                14047656300588076992,\n                4825969301827138976,\n                14045312358402798592,\n                4823577108282775520,\n                14033616809426549632,\n                4817491117598835008,\n                14047711946463647920,\n                14017138652370186240,\n                4814293604152200576,\n                4824102080247326992,\n                4825433674921535344,\n                4798417727273772032,\n                4814324715392750592,\n                4812067189281820672,\n                14048395574014847296,\n                14048049620421384416,\n                14043816034495334592,\n                4825168853606119680,\n                14048077812649100640,\n                14031278426934983168,\n                4822664076090005728,\n                14046283724158469280,\n                14046397305112937344,\n                14044078079401517856,\n                14046696762035599520,\n                14044740860603369152,\n                14047660498738846960,\n                4823406115891044256,\n                4819069147344075712,\n                4820791313144706144,\n                14049342494831757536,\n                14042125833078413184,\n                14046610092037569408,\n                14043206480554774176,\n                14047225107883394880,\n                4808267773743216128,\n                4825259889410030112,\n                14048511323990994576,\n                4821439076136109792,\n                14046728194360194384,\n                4819779687808646368,\n                4821793955451956480,\n                14039616051002245568,\n                4825279428809623056,\n                4812321188306878848,\n                14044417556593216832,\n                4802055490669989376,\n                4825569268326390960,\n                4813353961982797312,\n                4821421246022231872,\n                4812712769663062400,\n                14047912393825697392,\n                14029879764366103552,\n                14044602560736059968,\n                4819389678868075936,\n                4819469864864033568,\n                14049030020002894256,\n                4825809929265716736,\n                4823466089207036480,\n                14048058366392993776,\n                4816327221950730304,\n                14044401464447192320,\n                14046192040418349760,\n                4825800845017736224,\n                14043247397321882368,\n                14047435935261124928,\n                14026278802031792640,\n                4818595201097564160,\n                14039768967160682752,\n                4814951722629826880,\n                4820950228631234336,\n                4825755955743165232,\n                14037600389560718336,\n                4816047617698501248,\n                4824951705205037088,\n                4825155018005046032,\n                4814848860227197376,\n                14048026684245231328,\n                14049313033631808624,\n                14043219760842215904,\n                14047803494729399424,\n                4823453214814382048,\n                14046514954384740960,\n                14047860897014330336,\n                14047450644731600016,\n                4822455909461261632,\n                14036485032092318080,\n                14046976674331557728,\n                4819986508671765664,\n                4818002125417966592,\n                14032538563042080256,\n                4825048953203652272,\n                14029580896322983168,\n                14049174892412748320,\n                14044230671416116128,\n                4823658494405287456,\n                14041956290103877760,\n                14043370539869093920,\n                14045932750545528928,\n                4820745277503115488,\n                14042652751282579680,\n                4819006166548595104,\n                14048886013270025760,\n                14044450198352722880,\n                14045987899762385312,\n                4821132896166465888,\n                4820989999654882208,\n                14043817331432645312,\n                14043702900469742848,\n                4823893719766536400,\n                4819150065671148896,\n                14048997539790314816,\n                4824223298867460272,\n                4811488256658291200,\n                14040895757855661824,\n                4814940521819383232,\n                14045037166395535072,\n                4820979872845301536,\n                14042017155350596672,\n                14047799170698495552,\n                14048843603260619280,\n                14046989267163272384,\n                14045058189431876160,\n                14031860262367677184,\n                14044474133754137664,\n                4812035333352927872,\n                14049037963410711680,\n                4825433836344307216,\n                14043926239572147232,\n                4825513164329647872,\n                14047311588323725424,\n                4820470992176524128,\n                14020386550114670592,\n                14046318549084136768,\n                4820182586433668128,\n                4822980553650086624,\n                14036203821106896128,\n                4823614865262100592,\n                14044926533851591360,\n                14046851331722533280,\n                14043055454296643456,\n                14049412885736566592,\n                14037962133299571648,\n                14046726545222149696,\n                14047233090964272336,\n                4820243825114128352,\n                14048122226215720944,\n                14047785455716015824,\n                14034545164818383744,\n                4823995569577665360,\n                4823327236798981824,\n                14038367756990910528,\n                4816831357013840000,\n                14048180586227254880,\n                14038685789818344064,\n                14044039710535779744,\n                14047089040127758112,\n                14037731580207534592,\n                4826072655394979712,\n                14048772946211184912,\n                4825081764317694704,\n                4821037360437271392,\n                14048712226592224128,\n                14032276393761443840,\n                14046590115601460224,\n                4812202559676208768,\n                14048707391287436672,\n                14035196666207079808,\n                14005118577718411264,\n                14042244056269009216,\n                14035607602456641920,\n                4814352533958761216,\n                4816543099905685824,\n                14048874608064266832,\n                4820994560502018848,\n                4810358340105771520,\n                14046610122499428928,\n                14046528530208643648,\n                4825461544937897216,\n                4823898034442875648,\n                4814367885492178816,\n                4822197692549141792,\n                14047305180238238080,\n                4816145561671869760,\n                4824669847616201728,\n                14048054343846250944,\n                4815756824126371328,\n                14041544450269063744,\n                4824677648755486144,\n                14046840423158103856,\n                4817043518068634944,\n                14040250979245767104,\n                14043758755912371840,\n                4821268600956909888,\n                14046008919841912128,\n                4825392626389228560,\n                14042580446738220384,\n                14039922328993447168,\n                4825630664115612160,\n                14041155724508215040,\n                4792643680791646208,\n                4821483983637609632,\n                4826027883545339136,\n                4823380272997187520,\n                14045598350099886304,\n                4822211037250860736,\n                14048586166521851536,\n                14047316714340847648,\n                14046108997129038496,\n                4825973181750430080,\n                4822731795905911744,\n                4820243279775614144,\n                14049477753663947104,\n                14041400369918972672,\n                4826016429988591504,\n                14048784505175397872,\n                14043559231572284608,\n                4825801116114137184,\n                4813792139219027328,\n                4817120541254506240,\n                14048605693470775040,\n                4814514237594887168,\n                14045871682631817472,\n                14038037860458179520,\n                14049144366911703168,\n                14047078364978124240,\n                4821578850101173632,\n                14042503800921864736,\n                14047585718518784768,\n                4823898561283142976,\n                4820195917385416192,\n                14048131952484830384,\n                14048815666915868544,\n                14033069274113456640,\n                4791109880713076736,\n                4816923386739969344,\n                14047158716388820192,\n                4824938869558284784,\n                4825773172994281440,\n                14040892554145098240,\n                4816392176988898816,\n                14047481057265452016,\n                4824995365003637168,\n                4817178940449582400,\n                14041333023725420416,\n                4825902518291647696,\n                4824224703019913424,\n                4818359081892465472,\n                14042019507024938432,\n                4820115281765526208,\n                4825422854567360944,\n                14048311046053536112,\n                14040554322491422592,\n                14047201761315155200,\n                4823938414170343088,\n                4824131217405710928,\n                4818602537712200256,\n                14036507693119973760,\n                14040174584276268800,\n                4824511641089796192,\n                4816768193009903872,\n                14049417503782867632,\n                14045802698487560544,\n                14036415098945234944,\n                4825806809042773792,\n                4821803859698855840,\n                4821706560609429248,\n                14043950492062286496,\n                4806348157045050624,\n                4824205771810647584,\n                14046840541695864656,\n                4820093121819765504,\n                14042221118025045952,\n                14039033129001135552,\n                14024834083471730688,\n                14046053268531866496,\n                4825747432888281536,\n                14034735252829027200,\n                4819407444096563008,\n                4825776961600077552,\n                4825622611514804208,\n                14048922431405344784,\n                4823575863063018272,\n                4826097939875141968,\n                4824104640104825488,\n                4825229295947606032,\n                14048614793357476960,\n                14047185989290037600,\n                14047918960664482256,\n                14048931590782925104,\n                4823581891259939136,\n                4815904832697979904,\n                14047783094569982160,\n                14041133873969093376,\n                14042764293975414464,\n                4824529762334589328,\n                14028889369648239104,\n                4823571553164030624,\n                4824108213141242928,\n                4822701387282037248,\n                4819210585340427584,\n                4825073816309822080,\n                4801181965573444096,\n                4825273702021404576,\n                4822362538534677056,\n                4824673292872169056,\n                14042715161676276000,\n                14035556319780078336,\n                14047075390563732576,\n                14038193007681453504,\n                14049035568577790400,\n                4825957900710263088,\n                4825075603521313088,\n                4824920044992839104,\n                14047283042243859408,\n                4819866246981433920,\n                4819520142077709568,\n                4796219354047746048,\n                14025696480474423296,\n                4808070510798359040,\n                14048724072351326272,\n                4813791367816548096,\n                4824136296419628240,\n                14047290770581145216,\n                4811613783782124032,\n                4824716458215033264,\n                14049193684361639824,\n                4824887242313707520,\n                4823553167882904192,\n                14046758600947613232,\n                14049472643415484816,\n                14048428575969953568,\n                14048287845359904560,\n                4817278761485318976,\n                14036002867647282816,\n                4821209578793184064,\n                14045674501377842336,\n                4824243647453932736,\n                4824282339143702992,\n                14047145559857134048,\n                14025476409726808064,\n                4818896932169975968,\n                14040906064674985088,\n                14048168451095962224,\n                14049089748406725632,\n                14048704023497263152,\n                14048150783587470480,\n                4822512835324467456,\n                4823994949317633232,\n                4815664991151044096,\n                14037835844266088448,\n                4818544623252718400,\n                4823559265504350080,\n                14049014372719636112,\n                14048726995513878304,\n                14038446133556496448,\n                4820453953457846240,\n                14048728709258864160,\n                14049391623685815664,\n                4815919554030401280,\n                14049436839238695632,\n                4807654763886386432,\n                14042340011054494816,\n                14046143334093746304,\n                14046395121339726240,\n                14042709817675441376,\n                4823218290686018944,\n                14039524482455525696,\n                4821643517508801664,\n                4821344155552875264,\n                4815057852126473728,\n                4819050196005058560,\n                4824769265987336688,\n                4780195458809905152,\n                14049400165700265760,\n                14048264862205766816,\n                14044717835737217056,\n                4819363063391618176,\n                14045211094051997056,\n                4824535084576824096,\n                14047351529205034496,\n                14047316924839105392,\n                4823457650360081952,\n                14047799523690450976,\n                4790675648332267520,\n                14042685120438631584,\n                4820628442932832064,\n                14045168614168261856,\n                4815881384862278528,\n                4820941785371617856,\n                14044037031280312448,\n                4819951329614367808,\n                4815601513799558720,\n                14047524630295599328,\n                4806848435573614592,\n                4805082018605693952,\n                4812165917170155392,\n                4825634985135820528,\n                14035377770703175296,\n                14043620814667969440,\n                14037289847389732096,\n                4810173282423828224,\n                14045091722065906720,\n                14047736985873469712,\n                14047159734014983584,\n                4796843728240861184,\n                4822842023823075776,\n                14047645847783393184,\n                4825262280288905472,\n                14046926577037285296,\n                4825708274313418464,\n                4816375971527638784,\n                4816079575756826880,\n                4802315244269506048,\n                14031407977182087936,\n                14042859032938692736,\n                4824651513548786752,\n                14042403972358535264,\n                4815513811610422976,\n                4824031751120927280,\n                4820368773111658848,\n                14047327578405552832,\n                14048139784817839216,\n                14048903780190245120,\n                4824679601556008672,\n                4821525365964237152,\n                14047980094937954912,\n                14046914586551752992,\n                4815522155359847232,\n                14048766649811889360,\n                4825339377984455584,\n                14040849116159867968,\n                4825380102605593408,\n                14028936561556855040,\n                4824066714949823904,\n                4823685275335365888,\n                14048546344076282768,\n                14024249881007655424,\n                4825441330886989392,\n                14042336718477837824,\n                14047588027390388672,\n                4810559102577410688,\n                14049469961464651488,\n                14044375115535440608,\n                14036526016648102272,\n                14037172609928812032,\n                14034784115223076992,\n                14005883356502654976,\n                4821930011170387744,\n                14038596110466247872,\n                4819832764693149440,\n                14047940677392518848,\n                14039209994486083328,\n                14044608821966055552,\n                14041527405263008192,\n                4813347701156180992,\n                14048738693952185392,\n                14047704419943755504,\n                4825499083079993728,\n                4823793258039762560,\n                4825974426075657632,\n                4823776888165760800,\n                4825076614479252816,\n                4824828268633283520,\n                4821520245219284736,\n                14045103040895871136,\n                14040105978725592000,\n                14044455540809411744,\n                4821255116484757664,\n                4820572155642001216,\n                4815906244300186688,\n                4818301484052122240,\n                4822025372794514880,\n                4813226163572852096,\n                14016126667663247360,\n                4825212005243271760,\n                4810940255103567104,\n                4818038529194043456,\n                4808159400565080064,\n                4816282564000707648,\n                14048007772477561696,\n                14047427371050800176,\n                14042306618792801920,\n                14042378149257190816,\n                14049187310313806896,\n                4824073156392015184,\n                14043790606248614336,\n                4821858753777262112,\n                4818547565089876736,\n                4816342130135081216,\n                4823422266196108064,\n                4824393098916643296,\n                4811688966856403200,\n                4822637684602825120,\n                14047071538622103088,\n                4820556898691694528,\n                14039391832509022528,\n                14046932837057954704,\n                4804323275571257344,\n                14042807049188526464,\n                14040076212099371776,\n                4825319052928248240,\n                14040719425333898688,\n                4825973161023122752,\n                4823424284211613408,\n                4823861060942531392,\n                14046003355238590336,\n                14034118309842195968,\n                14049463893476095680,\n                4819414672164774080,\n                14038950728213323008,\n                4820624590894352000,\n                4818856612532597792,\n                14049292297362220960,\n                4824908737594090512,\n                14043641611839267584,\n                4819515721171865056,\n                14047505470388100256,\n                14040229780935253120,\n                14036385049973158144,\n                4824262771965927536,\n                14043730052512700000,\n                4815552318541366976,\n                14031915238178992640,\n                4825679069718080144,\n                4825650127575950160,\n                4822473210592656384,\n                4822716798786426080,\n                4824280892040739440,\n                14029031520201799424,\n                14047128722833269424,\n                4824517242373028416,\n                4824240066839333824,\n                14045531873696035200,\n                14019910079452430336,\n                4820686741244024416,\n                4819218099392045760,\n                4821061996366075936,\n                14048558065279703392,\n                4824498885699672624,\n                4820014654224262720,\n                14047031567580460944,\n                4823585548683642160,\n                14047419844159976048,\n                4820645762754922496,\n                4821767849614181600,\n                14044019317817631808,\n                4824041970730964000,\n                14040372688366445760,\n                4819023751049888320,\n                4796783719874294784,\n                4822394878317892960,\n                4811255662829104512,\n                14046255989154242720,\n                14018691780982368256,\n                4823906857116502048,\n                4824947099868674528,\n                4815077993369358016,\n                4824676904222281872,\n                14049461670953825216,\n                4824380393482377648,\n                4823092832404079008,\n                14047221037352793040,\n                4818142618789344256,\n                14046053765980814688,\n                14034378720987832832,\n                4822641344974928224,\n                14042740407405435584,\n                4824850015132325744,\n                14049316634820538352,\n                4821006028404887104,\n                14034226857388254080,\n                4813097240535685760,\n                4803528448741088768,\n                4825657536779356592,\n                4825731288649859584,\n                4819872991112554176,\n                14047634600807230592,\n                14045306340314436640,\n                4820772029082735648,\n                4821920239224421952,\n                4825546438441354480,\n                14033205191326861824,\n                14047579848110928720,\n                4825370371105331456,\n                14045662227878121824,\n                14044051806111074016,\n                14048306009450001888,\n                14048758655792713072,\n                14044473951699608032,\n                4821898022998453248,\n                14048433348254323072,\n                14047746151592458560,\n                4814876098472972416,\n                14043734318701961696,\n                14049302738815623616,\n                14047187847308799728,\n                4819219583649028128,\n                4823110807455759456,\n                4823467586745394640,\n                14048951010778301920,\n                4817278396609124352,\n                4824566251280759040,\n                4825218202205848576,\n                14042859581684650528,\n                4825062579313568304,\n                14038947275537904192,\n                4823914837506054240,\n                4819161919869362720,\n                14045357549603490592,\n                14049026223845267120,\n                14049438853404335424,\n                14049308253820962752,\n                14030159217023705600,\n                4818203778939214784,\n                4816425904442885824,\n                4821854826531764224,\n                14040845777828796160,\n                14037951351055134656,\n                4814804962303242880,\n                14048536593531299552,\n                4824570330373403440,\n                14047908527096471200,\n                14048076993120677216,\n                14042792447079171424,\n                14047358164534244768,\n                4825576172781743216,\n                14042995724935741344,\n                14047477028768425984,\n                14039756904882394304,\n                4825390044167561040,\n                4820667773681926400,\n                14039717477028927744,\n                4824648373540873376,\n                4825967444870362144,\n                14044939894450495264,\n                4825456092001724288,\n                14043106475575138464,\n                4826031093638521888,\n                4817979695198177280,\n                4822841723383758752,\n                4824838658898018240,\n                14046841277763714752,\n                4814239301420616192,\n                4825570989749270432,\n                14045386014346263936,\n                14038056849774306560,\n                4824703473195605056,\n                4825584703537205872,\n                14043218471419296224,\n                4824709831590088752,\n                4803862519866614784,\n                14032551272601084416,\n                14044182426497724608,\n                4818620508808124928,\n                4823207887549416736,\n                4823681047231857616,\n                14040481433244148160,\n                14034244083461213824,\n                14044970558620028160,\n                14049033070035396880,\n                4814587343372635712,\n                4824734172206688480,\n                4823780917462373504,\n                14045764904282614272,\n                4824371193007716096,\n                14049365917718006688,\n                14047075079977112240,\n                14042705639472853120,\n                14040412562659582976,\n                14045091432669031360,\n                4821333853854633440,\n                4825375510360198752,\n                4819082499160857984,\n                14045714299176656448,\n                14049081224274257904,\n                14041956490390223424,\n                4822321001281496000,\n                4825742476353279552,\n                14049065088377326016,\n                14029315677724130048,\n                4819190960769378912,\n                14042907443872146912,\n                4803425732686631424,\n                4826072834069822480,\n                4815540272732431424,\n                14043361673160659520,\n                14049248718876758320,\n                4825998874078804112,\n                14048729476439267664,\n                4825809443478487840,\n                14048120198493568880,\n                14044738514824770176,\n                14048873644732655072,\n                14047590477313707776,\n                14049054856840135872,\n                14043451856793396928,\n                14022405299356661760,\n                4820490648150391552,\n                14043256753375672992,\n                4824391533925071056,\n                4823097374685449568,\n                14024508975674640384,\n                14045630244377295712,\n                14028806457685102080,\n                14042650859930931136,\n                14047111125117091056,\n                14041185644203448256,\n                14048985448923763248,\n                14043619921060370112,\n                14047326906115662960,\n                14048657177649624720,\n                14048497124548970080,\n                14044676923680603392,\n                4813171192760564992,\n                14043307650283889792,\n                4823889382630955920,\n                4806692602052838656,\n                14048244790539753104,\n                14046021874097741728,\n                14048023067084921824,\n                14042490741265074400,\n                14035990249621202816,\n                4825824781419750176,\n                14044554385485625568,\n                14048851215330664864,\n                14046943539867223456,\n                14029078460959363072,\n                14036004473463703936,\n                14045606893672060544,\n                14046409678468354592,\n                14048033822599107408,\n                14047971611914430640,\n                14046792584439944752,\n                14041868153127954816,\n                4822659215769591680,\n                4825755282921193840,\n                4816671974918267840,\n                4821115976688527040,\n                14042702122733295136,\n                4815091505599602624,\n                4815605164961396672,\n                4810005875329161600,\n                4817205759075486016,\n                4807657564097075200,\n                4825294836739854080,\n                14047430437156370704,\n                4814383337109266176,\n                4823752340651761920,\n                14037976023854481408,\n                4822235389010100576,\n                14043050587987948128,\n                13996682174067703808,\n                4818033039420465152,\n                4825250219623421824,\n                14048929583122700144,\n                14045052191284055264,\n                14035435174872359040,\n                4824954400487123472,\n                4810887326570066816,\n                4772013213576265728,\n                14046892975615256272,\n                14044222308976202048,\n                14049044829453335312,\n                4807648011826990080,\n                4823158702993336672,\n                4824597888008003344,\n                4824896899180464128,\n                4825714446188229744,\n                14045545769439664576,\n                4825887631338930096,\n                14047101974651363728,\n                4818352816021585536,\n                14042647971660574560,\n                4824116624676444480,\n                14036322822408096768,\n                4819005108630444896,\n                4821308921147918656,\n                4820699808843720512,\n                14046867958948479968,\n                4815665711649760384,\n                4820738583016020288,\n                4797057068646591488,\n                4818522619710394688,\n                14043463664252902656,\n                14040782616925617344,\n                14027069236061724160,\n                14043013569888157792,\n                4811236931491163648,\n                14037732504159876160,\n                14044454238352781792,\n                4808240641602471680,\n                4814261254421637888,\n                4824615592094282048,\n                4825625882797936304,\n                4826107716041171104,\n                14049169937769497776,\n                14041733767654775424,\n                14049386921283965904,\n                4817701954404875776,\n                14033831974902502144,\n                4815017250778785472,\n                4819958851594276800,\n                14046935395852688176,\n                14027703185633212416,\n                4821367711502553920,\n                14048168060275756112,\n                4824981591216558624,\n                14037181756105496192,\n                14041071860705387136,\n                4806131581256441344,\n                4824164830901797392,\n                14031008769674067200,\n                14042638303367250144,\n                14048995480723402768,\n                4825481810707194928,\n                4820843121741740800,\n                4824607341824331152,\n                4819656791844545344,\n                4810538957876212736,\n                14045126081814421920,\n                4824022596455340576,\n                14043776037038854656,\n                4825432054744660400,\n                14048198840929610432,\n                14048295951799414848,\n                14011745542449807360,\n                14043397204078868768,\n                14045984386075468544,\n                4821102207098806752,\n                14030805302206060288,\n                4809929375606476672,\n                4822819582539387360,\n                4818743293603630464,\n                14042480325243741504,\n                4822577150516546720,\n                14048792005909866800,\n                4812226271062418304,\n                14048267016365053680,\n                14045053738879417888,\n                14043403185992236736,\n                14038848117672041920,\n                14042495632758302944,\n                4825203403940055104,\n                4823155601414092352,\n                14042292929242555936,\n                14043295705729395520,\n                4824390256797995088,\n                4824788576253410176,\n                14039117549342101440,\n                14046929448794273792,\n                14045938525766895168,\n                14047180560100179024,\n                4825636041992423952,\n                14043010637192762368,\n                14047184546528746640,\n                14036249651858988800,\n                14040192401804557376,\n                14048692200692341200,\n                14042836114031696544,\n                14031744324563649792,\n                4824591506722032912,\n                4818153786178878464,\n                4820558019365270624,\n                4824797307342564736,\n                4822260355243384544,\n                14043594517210427136,\n                4820590286483827808,\n                4818951146682830528,\n                14045407653358760832,\n                4816400647425864320,\n                14048869907398063056,\n                4825185492861331312,\n                14049151211878298592,\n                14034801237514465152,\n                4796992939868878848,\n                14038392605521538816,\n                4810724391398766976,\n                4823181724992309056,\n                4817100580799474880,\n                4819699672687728800,\n                14043901784075455680,\n                14048977913582474784,\n                4824636694958947728,\n                14047408189128739904,\n                4823811888465729744,\n                4814473862462062912,\n                4816366796509624128,\n                14049139232926434144,\n                4818730331126065728,\n                4815298740199792640,\n                4800661970276634624,\n                4797534822088979456,\n                4822244154465125440,\n                14048447337676907104,\n                14041057052061026752,\n                14040773298390113152,\n                4820612934798466784,\n                4823318431755368448,\n                14029556916406815232,\n                14045944328776929056,\n                4824845315896753296,\n                14042583567146315488,\n                14047737192188980240,\n                4821462247596004288,\n                4813595094717716992,\n                4823616883218023072,\n                14045212025504628480,\n                4813108904091509632,\n                4818469734389131968,\n                14044757486455116320,\n                4816972518788146816,\n                4819683002147815808,\n                4824173819060184320,\n                14039450015401213376,\n                4820424705743848000,\n                4820839725594160224,\n                14034551967967741184,\n                4825080499778044544,\n                14044041589466984160,\n                14049039333486054336,\n                4806602919535342848,\n                4818700011736314112,\n                4822538523765737280,\n                4824382965078694896,\n                14041902772234098304,\n                4824237288610453360,\n                14046831556157034720,\n                4814845785237918720,\n                14046897622289712064,\n                4824620131882342784,\n                14042532972881543040,\n                4815119674515879424,\n                14047947513181789952,\n                14040451477640662784,\n                4821208121540503744,\n                4814053300957567488,\n                4821819844351069728,\n                14047629914344027488,\n                4817958729685370240,\n                14031770142241237504,\n                14044352450847890016,\n                14028092292329113088,\n                14049173855662117136,\n                4821489147587003520,\n                4825393231510414816,\n                4816587896926043584,\n                14038669045262392000,\n                4826112081390253296,\n                14048244149719511040,\n                14044978304958092704,\n                14042879469581325280,\n                14047990989255782816,\n                4825409723702621872,\n                4818884777805559648,\n                4816419155821253824,\n                14034919406712995712,\n                4823133687202126016,\n                14038607720124004800,\n                4822286561576807616,\n                4822260931419015872,\n                4813012055893198336,\n                4820578923075325088,\n                14038140370196862144,\n                4824382268923450448,\n                14043567278679383616,\n                4823552579815315664,\n                4821790270410893792,\n                14048132096760867472,\n                4821978643873519488,\n                14048188087888229328,\n                4825499609220579008,\n                14047984753749767312,\n                14042466327433861376,\n                14029893333343486976,\n                14047535968311779152,\n                14047557452438877056,\n                4822627378513280768,\n                14036818453481021568,\n                4824912654509633600,\n                14041726746972559552,\n                4824106279155864304,\n                14043418095994417952,\n                4803116275213315584,\n                4823566597828160992,\n                14041761321219023168,\n                4810379818947513344,\n                14045510424921823168,\n                4811754761000817664,\n                4821906632488989728,\n                4815096383337692096,\n                14047542845157394032,\n                4822848993038502880,\n                4819456631258319904,\n                4822727259725573408,\n                4823986910134373760,\n                14047170596937602672,\n                14046897254727875200,\n                14040077344334118528,\n                14040899048908620992,\n                4823375846897111936,\n                14041781426061703360,\n                4824641192445356064,\n                14022268178799889408,\n                4814129730951775744,\n                14048796573012468000,\n                14042399171867924480,\n                14045954719682565472,\n                14046545194540246208,\n                14045244851398842912,\n                4820272687960210880,\n                14047390047434165312,\n                14046278831698285024,\n                14037436958055175040,\n                4821776659163575360,\n                4824543825542467440,\n                4811482767314956800,\n                14040288803249597184,\n                14035253240151331072,\n                4821715884245035680,\n                4819051953633670048,\n                14048840184787734080,\n                14048461930705752720,\n                4826104299469651376,\n                14046954350179926560,\n                14048799971822595072,\n                4825956652400283616,\n                4814585895407026368,\n                4816118928550544320,\n                4825693321851677632,\n                4824306772860527616,\n                14046145695133705248,\n                4824670895886044224,\n                4824984420502205040,\n                14046757309880988608,\n                14037850422373253248,\n                14040490362389863872,\n                14048655952136170432,\n                14040361922788276096,\n                14044513833750573472,\n                4822074760257551456,\n                4819897032723333120,\n                4821879424832142688,\n                14041645708105249728,\n                4822698100372988832,\n                4769382678855090176,\n                4824416239948476480,\n                4824184770882028192,\n                14033286647956071808,\n                4824277990100371312,\n                14042677436634696640,\n                4825796985200076944,\n                4811934966415820672,\n                4824956497349613936,\n                14049080114768413008,\n                4821302276642317472,\n                4816185732763096704,\n                14041003154558285184,\n                14041849722295935872,\n                14042095665098442048,\n                14046765349444140096,\n                4823417160342708560,\n                14049055943231807040,\n                4824356156037244096,\n                14048712769202459344,\n                14049022432231894896,\n                4810481548198206976,\n                4820793766834305920,\n                14049404426116073056,\n                14026584218614313472,\n                14046377525596372096,\n                14037160552242612480,\n                4825438237651103216,\n                4824565539385965472,\n                14047353912631895904,\n                4823743228092602720,\n                14044255753598116768,\n                4818043524384019648,\n                14049428144266440144,\n                14049369226999554080,\n                14048685168941676432,\n                4824652422686914944,\n                14049419684778306848,\n                14047127409917783088,\n                14034528702478299648,\n                14043533643187181824,\n                14047132377292058128,\n                14043460673816996512,\n                4783359583883214848,\n                4822006319237000224,\n                4822194500623665824,\n                4794675492266926080,\n                4823265792846555648,\n                4814027937094236416,\n                4824101655379145152,\n                14042950922221528320,\n                14038325207794778880,\n                14048750879072725104,\n                14030844322825829888,\n                14037622250831881344,\n                14043920401321528448,\n                14044784105639808896,\n                4815462022231653888,\n                4816124197111810496,\n                14038723667232665408,\n                14048595349410294032,\n                4825974137205583712,\n                14044105223831518688,\n                14043938311348614304,\n                4825069442163264800,\n                4819112179562838976,\n                14040654754187275840,\n                14048751193535242240,\n                4815308145543523328,\n                14015422292051261440,\n                4825351676772921680,\n                14044350090446031008,\n                4823682496192554288,\n                14043174864867054560,\n                14037309698334639360,\n                4801028987059078144,\n                14048472544522176304,\n                14048164459519026144,\n                14029598524037666048,\n                4823225613997541408,\n                14046185289839958784,\n                14044193389445317440,\n                14049255195022175248,\n                14048842451255185088,\n                4823391854863890256,\n                14046618366497075616,\n                14044850773938128928,\n                4810830775688146432,\n                14015786448413880320,\n                4810501707121132288,\n                4812642632825899648,\n                14042998384337562816,\n                14044274816819490304,\n                4824861648590340496,\n                4824286565732335904,\n                4806941321644365312,\n                14030487126634521344,\n                4805598864205244672,\n                4824392085685162880,\n                14043011847145156224,\n                4798442266469725184,\n                14046134534072593664,\n                14042268165205901152,\n                14047295748668881856,\n                4823266060931175840,\n                14043605609315993760,\n                4824097695465351360,\n                14047846618118058976,\n                14048031471485058032,\n                14047275204363369904,\n                4807462349740220416,\n                4819511344131059328,\n                4823729613383934592,\n                4823811170184019904,\n                14036097919948041088,\n                4821699566704247104,\n                14048032517521740160,\n                4822614747095277088,\n                14044354243816428992,\n                14043805724068549792,\n                14042374067959400640,\n                4812518790674045056,\n                4823884912164455056,\n                14042236504579985536,\n                14049406471192098288,\n                4825030496684047040,\n                4825186483886753392,\n                4823783518265645696,\n                14045271666221143328,\n                14037005880688230144,\n                14037060398469251968,\n                14047550698584150128,\n                14038042917576651840,\n                14048356879725605344,\n                4824802777396462672,\n                4820084697453743680,\n                14046059821839046080,\n                14041621992269793600,\n                4820953398134286720,\n                4824272495401843664,\n                4823672112317320864,\n                4807244252795201024,\n                14039447917070851008,\n                4820221792489145312,\n                14046263992910333824,\n                4820378214053610048,\n                14049305241114861840,\n                14035582490745490432,\n                14046940638736251888,\n                4812361753545414272,\n                14044355165553484512,\n                4824471852330480032,\n                4823832628572480688,\n                4816229459415984000,\n                14036360707813798784,\n                4822332225055689216,\n                14045966870913586560,\n                14045537307402781376,\n                4821633100838645376,\n                14045828351767763296,\n                4824388769982014544,\n                14047059316928551392,\n                14049202112606955200,\n                4811395280921612032,\n                14049478264043877760,\n                14043068542761814656,\n                4821928761914013632,\n                14043654340270384864,\n                4821063345988320000,\n                4820497088082072864,\n                4821630392490327360,\n                14043904291594592064,\n                14044468838323855584,\n                14046506042023143904,\n                14028389909469078016,\n                14048686219154726624,\n                14045528671236498912,\n                4821146503347831040,\n                14040778038683541248,\n                4815926276788897152,\n                14046626749148089344,\n                14047026658313383680,\n                14048969457063630448,\n                4821462222995653792,\n                4822300136827196864,\n                4811826401062109824,\n                14042960056612821888,\n                14039967300100255744,\n                14049466609464251024,\n                14037796681763199168,\n                14043885509709874080,\n                4819851305991772928,\n                14037974093083905024,\n                4814429736733341120,\n                4814576073597498112,\n                4824958556196312864,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n        SerializedFFTContext {\n            p: 4828949516075925512,\n            pinv: 4384749916449448183,\n            mod_data: ModData {\n                n: 699289395265537,\n                ninv: 11253674057546036186,\n                norm: 14,\n            },\n            primitive_root: 5,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                14043622169812404576,\n                4820260646800627072,\n                4822573843679186272,\n                14038877097332927808,\n                14046789977532042656,\n                14040713522786628864,\n                4820318765268317568,\n                4816131317178144384,\n                14038210499179756032,\n                14034957500497820672,\n                14046779774437867536,\n                14046128589799704960,\n                4820756715955919520,\n                4824138563762302192,\n                14041563707511352064,\n                14032199640911435520,\n                4820094505759813760,\n                14043445196645936320,\n                4799321977349047296,\n                4822760672783583840,\n                14044080953280510016,\n                4822523068557746592,\n                14026336481545697280,\n                4818294762781998720,\n                14046537768768901696,\n                4814149164508726912,\n                14044679199084454432,\n                4814454491016390016,\n                4812371157287901440,\n                14030047316150949632,\n                4814010356613300352,\n                4822158243140402464,\n                4818887362516281024,\n                14044694573841889888,\n                4820981925724966464,\n                4811888475589693824,\n                14034062459116458112,\n                14047005782346875232,\n                4822729425437265248,\n                4823655726712856848,\n                14043037793104442784,\n                4820917078078769824,\n                14039972651024706688,\n                4821888537163889760,\n                4812395179851828224,\n                4824016768529508592,\n                14042680746024769984,\n                4822441165244596544,\n                14044515236017049568,\n                4819206254053179168,\n                4822883195612228256,\n                14046379120446889120,\n                4811091376783488512,\n                14043437165170076608,\n                14039185161466973888,\n                14045508837599775648,\n                14039892832563519680,\n                4820074524887993920,\n                4824101005073826768,\n                4817518632395394176,\n                14046934402978041536,\n                4810925620462777856,\n                14042667939352407456,\n                4821996414453731744,\n                4824050690961512688,\n                14045054452615266784,\n                4811410312514628608,\n                14020667972812045312,\n                4817607100219359232,\n                4814368951648908736,\n                4817564953312376000,\n                14043752184207923712,\n                4823907058541388384,\n                4817340186786187840,\n                4801444388224095744,\n                4817743510261775232,\n                14041537792859798080,\n                4812242691984983296,\n                14043873430346643200,\n                14046720773401538080,\n                4814253760473245056,\n                14043187474037793632,\n                4820601772358799648,\n                14045432882452764256,\n                4820900973366881312,\n                4823671623248192832,\n                14042375358230552064,\n                4822961560921908832,\n                14046341684750854528,\n                14034872908559974400,\n                14045673850935154208,\n                14029268316669150208,\n                4821975219248184416,\n                14037881574677811072,\n                4823647178519455504,\n                4821648941924734464,\n                4824171319922972672,\n                4823438770983749680,\n                4824247795801318816,\n                4815867839057086912,\n                14037724999193881920,\n                4817548391051320384,\n                4806258190725730304,\n                4816520467902283456,\n                14043313577414176320,\n                14038527723907451456,\n                14044074853032869344,\n                14034096991020673152,\n                14043968160581506752,\n                4818777410307253056,\n                4814642181812998400,\n                14044350324362495744,\n                14043368496364589760,\n                4819821581630061760,\n                14041349104641567616,\n                14047163315950227552,\n                14043554826534533856,\n                14047189380119438624,\n                14044858954455262176,\n                4820128832851998816,\n                14047428064220476624,\n                14044274040160876864,\n                4820829726595801184,\n                14042039755839511232,\n                4822419882713052896,\n                14037225492272940416,\n                14046963845062170688,\n                4820099090541598848,\n                4823852019483065600,\n                14034248747490327552,\n                14044643570980827488,\n                4821556909575146880,\n                4818430834453135680,\n                4821928841695917504,\n                4823156828571927104,\n                4810889972902040448,\n                14046509955294258784,\n                4824093576705813840,\n                14041590503602655488,\n                14040098001600446528,\n                4820280809288724000,\n                4813907434516782592,\n                14042429183096496160,\n                14043674829125885440,\n                4816282725486917504,\n                14039992787601905600,\n                4814216617720513280,\n                14047535996141040896,\n                14034239836294137984,\n                14041030856545134144,\n                4810871949714195456,\n                4819451437098533920,\n                4823901371604669360,\n                14039765802660186176,\n                14030019569933987328,\n                14041675386841725952,\n                14047633612471047648,\n                14043614323179790624,\n                14033790638749349504,\n                14033888789444894976,\n                14037349057875565824,\n                4806766194143211776,\n                4823799573121956848,\n                4823402433425703664,\n                14040937207348252800,\n                4820360742863475776,\n                14034832389925438848,\n                14034493482725009920,\n                4820354681490794912,\n                4818482190339795136,\n                14033530162271277440,\n                14045119797399565792,\n                14043340740026992864,\n                4820667382640596384,\n                14047694009375627424,\n                14047024917097743232,\n                4809923789654065024,\n                14047591276808957888,\n                4821532897338383008,\n                4810432822819576192,\n                14037419401854811264,\n                14039134448345630912,\n                4819941097337078528,\n                14041365389354265728,\n                14045781663357997760,\n                14042237466566778272,\n                14045509568781967264,\n                4818103450094096256,\n                4823932290543593264,\n                14046215671105456032,\n                14047246413984495360,\n                14044429366592736448,\n                4819953078662576448,\n                14044459359221533248,\n                4819464507767685952,\n                14043353343820478368,\n                4816611966817897472,\n                14045655143175751808,\n                4814681875637925184,\n                4811093334935509760,\n                4820033184784169280,\n                14047281546861695424,\n                4814961490307933312,\n                14045404447320625792,\n                14047676172173846944,\n                14038633807406693440,\n                14043407695779075424,\n                4823044641922566528,\n                14047407281020006304,\n                14033912883990579072,\n                4815601122006018176,\n                14043047140831385152,\n                14037856019262704192,\n                14047038263980883312,\n                14042047826908587456,\n                4820380867193468096,\n                4817816531671256704,\n                4816212912883396544,\n                14043501535211092224,\n                4823429979313086192,\n                4820042440627305376,\n                14046793868041777232,\n                4818885770280867840,\n                4819034605394032992,\n                4819571796108807616,\n                14023453306044328960,\n                14045650647085269760,\n                14043801547175169280,\n                14046186570240108192,\n                14047483681688135760,\n                4821290887276774240,\n                14033217278498342656,\n                4819911857498680384,\n                4808340188163989504,\n                4815333207238273152,\n                14034832845719066112,\n                4822135365517782624,\n                14039789843977418432,\n                4803668765432732160,\n                14047583816746123984,\n                14046640226131609408,\n                14045008295670867552,\n                14045933732607524544,\n                14043978625119140128,\n                4824058248590978832,\n                14038404182674419008,\n                14044118930343270304,\n                14039883046456645312,\n                4821081913489825184,\n                4814398025824142208,\n                4824058901242842592,\n                14025075400061671936,\n                4822122106120202304,\n                4819808804479115104,\n                4823466419039476496,\n                14015804925431586816,\n                14046689924603614592,\n                4821092173317015936,\n                4811433636320527104,\n                4820701025712794304,\n                14038668452057523456,\n                4819142796082036640,\n                14030291785226319104,\n                4822534139109102592,\n                4819974328558699392,\n                14047111197194485808,\n                4823522585981342080,\n                14043326400199287328,\n                14041158113909547776,\n                4820066968442715744,\n                14038284821883315456,\n                14046454559332973696,\n                4816863152391875264,\n                4801844642556047360,\n                14030838457869437184,\n                14044245485609018624,\n                4824002761257276320,\n                14047201605907862880,\n                14047470344364679248,\n                4823442205683944784,\n                14039136091797708288,\n                14042829870255358208,\n                14042453736200543296,\n                14046510112333758656,\n                4810111882680845312,\n                14035030130417796224,\n                4823962173626402464,\n                14042029922203515200,\n                4824036221686191328,\n                4819518786094181344,\n                14043580622539006880,\n                14045400293764423872,\n                4820862570444941568,\n                4809348836144409600,\n                4820028051821109856,\n                4815527810206517120,\n                14045228816188525568,\n                4819164213445513280,\n                4809646368961016064,\n                14046452663811927744,\n                14025694194603387904,\n                4823117543791448768,\n                4821122636779388160,\n                4823108859459870112,\n                14032294317663131392,\n                14047756100522196192,\n                4823676480650987600,\n                14043736326378521216,\n                14041549032997534400,\n                14031469241185101312,\n                4812466407924748288,\n                14047509160669308224,\n                14047414333192198960,\n                4824002467170509904,\n                4821858009671189952,\n                14040091836428805376,\n                4822217370431250304,\n                14047425005988311072,\n                4814830103186837568,\n                14047702057678751104,\n                4807940491001978368,\n                14039263309563137600,\n                14046872156462453536,\n                14034447162012730624,\n                14042465887387803200,\n                14036592982926213376,\n                14044786340166289376,\n                4824386400086355680,\n                14043005857572139968,\n                4820781543195351520,\n                14038020901410037952,\n                14042573320898817184,\n                14045202238081672352,\n                14040836508132771712,\n                4815950739044206144,\n                14046604953799357504,\n                14043569712193431392,\n                4817652991098281152,\n                14047679835368999936,\n                4819860404236049408,\n                4816338417212381952,\n                14030471744253419520,\n                14012962421188407296,\n                14043206600420825472,\n                4822510664899144160,\n                4818457576664356096,\n                14041697943456771712,\n                14046058705042125280,\n                14039167911876574080,\n                14035851575353102080,\n                14013054850496634880,\n                14046044976447218976,\n                4823751821983431264,\n                4822984316768337696,\n                4815844127523398080,\n                4814375942658755072,\n                4814695690189876032,\n                4823454173919204272,\n                14047452212117662672,\n                14042812125404062624,\n                4819865431687444928,\n                14045802026688278112,\n                4821003521003799040,\n                4808364794116682240,\n                4817807316505935936,\n                14037581177733054976,\n                14042043248586366656,\n                4820046458460908800,\n                4812164612270672640,\n                14046654129173130560,\n                14047028683554418048,\n                14045526640024013536,\n                14045713671736887648,\n                14046738285767606768,\n                4819325252867581280,\n                14037301465152720256,\n                14021796180965095424,\n                14043033520629742176,\n                14045715766151803456,\n                14045134234030252544,\n                4821090419031665888,\n                14043632688864235552,\n                4814443574702891264,\n                14032540235963274496,\n                4818856530772798976,\n                14042688069984519072,\n                4817056524521545024,\n                14033846136224726912,\n                14046877321506387296,\n                4823540057395483472,\n                4819961233825566976,\n                4824084153442196256,\n                4813323162036251648,\n                14047054658779337024,\n                14039636265290296832,\n                14046370224734734176,\n                14011988691951890432,\n                14045068111392108160,\n                4808841565679293952,\n                4824175760497460256,\n                4823879744258072640,\n                4823616708974570176,\n                4816122353194917696,\n                4819608760767729760,\n                14043333733207115680,\n                14041581415907576832,\n                14045553617792299392,\n                14032720118534142720,\n                4818669332546279616,\n                14026377232137765888,\n                4820410821450748864,\n                4816202042025028480,\n                14039750124826510656,\n                14046402519547720960,\n                14046982624331150976,\n                14039216802048463360,\n                14035620496669053824,\n                14043994442163451136,\n                14044603530843385440,\n                14047197749305031792,\n                14047202301398791712,\n                14045478327086566240,\n                4812835584192394880,\n                4809948737117772416,\n                4821199302567040352,\n                14033665550503202560,\n                14038156641033573888,\n                14047225690915886032,\n                14047136181268232688,\n                14046071615915710912,\n                4811781641904160768,\n                4821898166512144480,\n                4814572013159245056,\n                14037225920096226560,\n                4823594233837227200,\n                14046196277058815424,\n                4823884165551758928,\n                14043315232960542176,\n                4821175535986151328,\n                14042616457197594496,\n                14044319524801472672,\n                4810593049454641664,\n                14046956031271516480,\n                14041306620889620160,\n                4821493126648458816,\n                4817591451093321152,\n                4800838502195677696,\n                14045807721087566304,\n                14044828202376958656,\n                14043037583512972480,\n                14033463612184828544,\n                14041327813539761024,\n                4817384796826576512,\n                4810658033262625152,\n                4821734735177489536,\n                4821667046011553728,\n                4814614355515668864,\n                4818695820502350912,\n                4804051854443058688,\n                4823673616019886528,\n                4823004514785253600,\n                4824285018759717328,\n                4819434538446183168,\n                14046870845312110960,\n                4794221853083949056,\n                4823036053742170656,\n                4820491386959525184,\n                14036553047416682112,\n                4820904373366483360,\n                4823966639664836464,\n                14047143128583705520,\n                14041888647535081792,\n                14038351455690147264,\n                14041402637267737088,\n                14046563369396852544,\n                14044405222571455168,\n                4821733245809106656,\n                14041296320886141504,\n                14029182595785412096,\n                4810613454136512384,\n                4824155311598023840,\n                14036554454700787200,\n                14046783552962743856,\n                14045739126607319712,\n                4823717255777627008,\n                4822117072162131584,\n                4821325161344766624,\n                14041339293954118720,\n                14032983494146037248,\n                14043727192940695808,\n                14045730233505128256,\n                14035457906643770112,\n                4821444944054979456,\n                14044211377564050880,\n                4818964265012595456,\n                14039140048919979328,\n                14043954114552936320,\n                4824258882281306800,\n                14024314903945856512,\n                4816051272643639488,\n                14033098932633552640,\n                4812856766119812992,\n                14030655565170129408,\n                4822232571614508224,\n                14046864565567694288,\n                4817030799777859392,\n                14038747192528326912,\n                4824330384189775440,\n                4822504753350063712,\n                14031812946410993664,\n                4793487639464667136,\n                4820840318078287136,\n                14042963498816043264,\n                14047403077778826064,\n                14045770482712163456,\n                4823971822618995008,\n                14041709635758112448,\n                14045422595035857024,\n                4819934385958348768,\n                14046966949366733968,\n                4823788193090275552,\n                4818574439711966464,\n                14042366643440688096,\n                14040679777762224256,\n                14036475782379602304,\n                4823090045290943968,\n                14045193000021854336,\n                14047210510611244496,\n                4823370883855062656,\n                14044192438102974400,\n                4823172849935395680,\n                14044225369908184288,\n                14034435656948726144,\n                14044595568539341696,\n                4819843238134021376,\n                14039236751501446080,\n                4815999922638303552,\n                14046506960797797920,\n                4824202189178808784,\n                14045840884842992256,\n                4823496428407902272,\n                14037259741467357056,\n                14043622418241040704,\n                14043059494606156928,\n                14038156977094539968,\n                4783978436742053888,\n                4818132683076678656,\n                4813426806276434560,\n                14046746601476066048,\n                4818996469832819360,\n                4821908214814757312,\n                14045129393805524000,\n                14043555536151410144,\n                4818359763290334144,\n                4816531298906286208,\n                4809050785284685312,\n                4820687565394306912,\n                4814962452183171968,\n                4816748216926943616,\n                4823363748359853632,\n                4824154252412549984,\n                4820166780470940416,\n                14047237557269939792,\n                4809009933805922560,\n                4813083720545387136,\n                4817310522289793216,\n                4808193529407754752,\n                14035993606406228352,\n                4822839965905744352,\n                4816286824866341632,\n                4824398709287367408,\n                4817951279683016000,\n                14035220148909657344,\n                4809375484956807168,\n                14041757651118764928,\n                14027307665113732608,\n                14047205508875497056,\n                14042499981999691424,\n                14032227273470490880,\n                4822126230674729568,\n                14043123241540916608,\n                4807652468853835776,\n                14031133270441010688,\n                14042360401905887168,\n                4820914221227115200,\n                14037435489212567168,\n                14044084425749825696,\n                4802179898236015616,\n                4823551942955099344,\n                14046918219052111920,\n                14026823325253606400,\n                4796095687483103232,\n                14026789765757129216,\n                4821147753823584864,\n                14041818953012312448,\n                4823163643539026048,\n                4766042926904115200,\n                14042311063187861824,\n                14043677731116685632,\n                14023518806729462784,\n                4817883846808087040,\n                4820457992998218944,\n                4819872476039679008,\n                14041368555148452672,\n                14044912701208465792,\n                4815929607722593920,\n                4819988750094976960,\n                4816627786067625728,\n                14047223259176871584,\n                4822490460766517888,\n                4823483232183730720,\n                14040846908839080896,\n                14038974442322030656,\n                14045074022424090048,\n                4798963152046280704,\n                14037957902305924928,\n                4821690006425703744,\n                4823411257956384368,\n                4823992799853228208,\n                14043786027421583232,\n                4820750559898109568,\n                14047741898484199712,\n                4814488575167785664,\n                14040587549682378048,\n                14044471466730240064,\n                14044552144996588288,\n                4822454133142842432,\n                4818888246343293056,\n                14043307761330580064,\n                4815511458374083264,\n                14047145333009124400,\n                4811563159049379456,\n                14040580528924771840,\n                4821425709764831104,\n                14044856613195920896,\n                4819417043021988832,\n                14045954889587736864,\n                4819944663728237632,\n                14043310348455819008,\n                4815975069841904192,\n                14040175661232084096,\n                4824107697156858960,\n                4824353630469378864,\n                14046018757555336416,\n                4806990858200654080,\n                14041993464964108032,\n                4823684758329874976,\n                14038563780437312768,\n                4819175075508282336,\n                4823874181292764112,\n                14043144080914987648,\n                14040042897433577280,\n                4821895222841946560,\n                4823132903861166112,\n                4824079204884126304,\n                14046946443043562384,\n                14047720022943653216,\n                4819540031306070208,\n                4819357409200788384,\n                4817468216411049472,\n                14047173831390564256,\n                14047123920917366928,\n                4818178365637546304,\n                4820530769269769056,\n                14047157357336623872,\n                4823347699934185600,\n                14033043259111935232,\n                4821818413153605696,\n                4817198502996766336,\n                4824187978197310864,\n                14045100641827239392,\n                14047038361393043072,\n                14046605285666345312,\n                14039305344636488448,\n                4810523087717874688,\n                14026524969219397632,\n                4803872913560872448,\n                14044844408500523744,\n                4817526612956464896,\n                14027674970290599936,\n                14029179487705461760,\n                4819949486005550016,\n                14046854149593771168,\n                14044201139038381440,\n                4823209412318806464,\n                4820970325931014336,\n                4814250609519187328,\n                4820326288038460128,\n                14039766727968974272,\n                14045348013855690336,\n                14035707004503463936,\n                14043687304030906528,\n                4805380190266265088,\n                14043226173178851840,\n                14043324881835903936,\n                4824294074677586704,\n                14044663791410196576,\n                4810117436090050176,\n                14043238005528761440,\n                4822936899357343296,\n                4815454000118893184,\n                14040897901983854528,\n                4819306997691563616,\n                14037162276539896448,\n                4819609759356024064,\n                4823489891231088656,\n                14044646305517983360,\n                14046879365114303888,\n                4823943150623105024,\n                14045771174191091232,\n                4821346449465260352,\n                4819581426122145280,\n                14039526531889766592,\n                4819506159990865440,\n                14043119839825452480,\n                4814848318451207488,\n                4817774253451244160,\n                14033118546134105088,\n                4822616679730318560,\n                4820679990685140640,\n                14043768648330125728,\n                4823367146092250992,\n                14039519310753470144,\n                4823237822014886016,\n                14046686107588891968,\n                14046865775558950576,\n                4809103308284029440,\n                14034866622232945408,\n                14043985310248309440,\n                14024452337409473024,\n                4821663172441960352,\n                4823546136580278448,\n                14047136659300635936,\n                4802285799709803520,\n                4823425069428663136,\n                4822126090050887744,\n                14047119497713103984,\n                14037071496746457472,\n                14042510845646411136,\n                4810744590775204736,\n                4821373128345012192,\n                14042399760732162464,\n                14032786096245446912,\n                4816613113329098944,\n                14012605496929517568,\n                4824061245623153328,\n                14043502198842249600,\n                14046813127770734352,\n                4819734390975394112,\n                4818369390807601600,\n                4795893271938328576,\n                14047442016166096496,\n                4822786277664820096,\n                14043915354124806752,\n                4820157834971302816,\n                14043270839095819584,\n                14044245160504810240,\n                4823926365893410032,\n                14045855751513110752,\n                4819915969166955968,\n                4819034108168235264,\n                14033412400007804160,\n                14043984856887490560,\n                14047342318824105024,\n                4817475156129353856,\n                14041466827699587712,\n                14040675632413207808,\n                4824181990246711056,\n                4815970480796887296,\n                4822047264229300448,\n                14040144833860637696,\n                4811279055512741504,\n                14040371541105193920,\n                14046282590089387072,\n                14039280122820808576,\n                14040688022735639744,\n                4804760781293358080,\n                14021313057689651200,\n                14046788451590536784,\n                4821417974426725408,\n                4805270108595715584,\n                4819861924579995712,\n                4823789505175069472,\n                4823498502611394912,\n                4822730964651350080,\n                14047805676004729376,\n                14039661977931821440,\n                4817944660572179264,\n                4824291948519746768,\n                14044298070743509856,\n                14045484585407742784,\n                4822551436983163552,\n                4815543611252325248,\n                4824138358834474608,\n                14039224806601896192,\n                14044539381100877184,\n                14041648675405619264,\n                4796778203629168640,\n                14039200678751936064,\n                4824214494743993168,\n                14040485861987321600,\n                4822852223001953024,\n                4822076728507849152,\n                4815983234994135936,\n                4808366224312305920,\n                4815099879688953792,\n                14042247284177313344,\n                14042437404126597952,\n                14047812873348838304,\n                4823069288735457056,\n                14041347010159477248,\n                14043894429400383776,\n                4819635122802553248,\n                4814201408701105664,\n                14044639037278289824,\n                14039409820255928640,\n                14046838717014631424,\n                14035993071963813376,\n                4821277331901735008,\n                4816909351676540032,\n                14047251431830400176,\n                4823386327318295584,\n                14043720908594367616,\n                4824386002378177184,\n                4812679633421980800,\n                4817421229549538048,\n                14033452516393702528,\n                14044800509343097920,\n                14033229931787345280,\n                4817889888602242048,\n                4821390566307734656,\n                4819892278784002592,\n                14042457067283930016,\n                4816362956143920192,\n                14047202244297569216,\n                14045012888550132256,\n                4805521806100503040,\n                4822854508495359168,\n                14036777155852232832,\n                4821621989105673184,\n                4822787163933571616,\n                4811881962806754688,\n                4818733485796270912,\n                14026740726560588800,\n                4823316387193691776,\n                4813063882923683200,\n                14045289969087003616,\n                14037999651314512192,\n                14043375513149635872,\n                4814923814646151552,\n                4821041720292596576,\n                14043620217465391136,\n                4823648192736489456,\n                4818973826825290240,\n                4813652998116532480,\n                14043232546410813152,\n                4819027547726639136,\n                14045478387193786208,\n                14039157476229041152,\n                14025614513382237696,\n                14044429658342186304,\n                14047203122135595456,\n                4824105151430563488,\n                4800457286325762048,\n                14043750156781419776,\n                4811278816331313664,\n                4816175674365221952,\n                14046782384356416304,\n                4823728238871735584,\n                4819393609505329312,\n                4822142690440658240,\n                4820939274248517984,\n                4817969547440828672,\n                14033371660031957888,\n                4821694922204432160,\n                4823895697141775440,\n                4816615263466927744,\n                14042639520078681824,\n                14044849793104973440,\n                14037351968203753856,\n                14032879055835801856,\n                14047747907821636544,\n                14019625697997414400,\n                14044667941025892576,\n                4821162679917262656,\n                4814481077713604480,\n                14046415865069205760,\n                14031671723543405824,\n                4807864248816519936,\n                4821950446119995296,\n                14045530015871105120,\n                14042326353034790176,\n                14044507126665772128,\n                4824325313948793920,\n                4822274309197656352,\n                4811040600690807680,\n                14047323673568081264,\n                4822183065425030272,\n                4815867489894007296,\n                14046350567857243904,\n                14040193659206467008,\n                14045347602934944512,\n                4823223568518759808,\n                14036067751827837056,\n                4818132043388972544,\n                14047468777877987584,\n                4820343031604131200,\n                4812399488116299392,\n                4816008373029099200,\n                4821481485189605248,\n                4819337461674651168,\n                14046679949678637504,\n                14047815089873968336,\n                14042947909259589376,\n                14037261240246042112,\n                4818058723696343552,\n                14042726144028443136,\n                14043368531914356448,\n                4822972953928057024,\n                4819273939932173856,\n                4824020200243955040,\n                4823455050795745984,\n                4821624143044066976,\n                4813831970443995648,\n                14042766079320147968,\n                4823963453842999952,\n                4823942240464260240,\n                4815103213467292736,\n                14037984822979324800,\n                4819456754642742304,\n                4824004654800969568,\n                14035054418122695040,\n                4800861817045789696,\n                14044257814735385664,\n                4823839124462615664,\n                14046074964494274880,\n                14043526065680249728,\n                14043690562130644736,\n                4819849880524195616,\n                4813705100284043520,\n                14043017636332461920,\n                4823277396894680480,\n                14046771103108435904,\n                4811701252214606080,\n                14044074701934453472,\n                14046691510459560512,\n                14035590490954711808,\n                4821582773325890272,\n                4821026842438069344,\n                4824348100021438192,\n                14027294365644390400,\n                14037373555536799232,\n                4816353349070511104,\n                4824093909524020016,\n                14033525834677674752,\n                4796550316280591360,\n                14046799848272269824,\n                14043288919595671680,\n                4823875330713175664,\n                14044828494615906560,\n                14039135898914167616,\n                14040087203332719616,\n                4820694628967938816,\n                14043203501399302560,\n                14043214455983603840,\n                4811846308115197696,\n                14044466400820524992,\n                4820418802992555872,\n                14044095171702292224,\n                14047196262663958496,\n                14037253022752426880,\n                14043311279324989696,\n                4821993449993954208,\n                4824167910211928096,\n                4820504733221238912,\n                4823328096244781280,\n                14042459008937992544,\n                4818521394997896064,\n                4822132793564605728,\n                4819808722954947072,\n                4817063439390191296,\n                4822866384427722112,\n                4818995693736758688,\n                14045805217667766400,\n                4824085392327121968,\n                14043456638406588544,\n                14043910448931916736,\n                4816646781953200704,\n                4823426723838847424,\n                14039362996229706496,\n                4802112402200382976,\n                4813690592250630784,\n                14036681282497341184,\n                14046486183015637952,\n                14038651310703014464,\n                14046772694437265104,\n                14046366383968819168,\n                4815079338717749696,\n                4823285429037740320,\n                14047487969137554992,\n                14046727326390886624,\n                14045374426879913056,\n                4805425183921085440,\n                14043469041260087904,\n                14044567288922222848,\n                14037120031637651712,\n                4819761250553177280,\n                4824234216913190768,\n                4806692794488079616,\n                4810127876327453184,\n                14038081110549116672,\n                4814567855690719872,\n                4813083631402520960,\n                4822861541160848064,\n                14046273295588046912,\n                4817838498090627584,\n                14042599055953016288,\n                4819004256292943712,\n                4822178453996379168,\n                4822667289824115072,\n                14046712362839916512,\n                4823993970596108832,\n                4820510323589020192,\n                14044462363846754144,\n                14036637511010782976,\n                14046321934247365792,\n                4823265277364256800,\n                14037305606934383488,\n                4823504002887360736,\n                14043928817053838688,\n                14047678883796565920,\n                4806703235479384320,\n                14043423715690290784,\n                14047086673479039744,\n                4806925163618326528,\n                14042377459093944704,\n                14047734693509710528,\n                4823429713392018864,\n                14039394641841434240,\n                14036661003382078464,\n                4810056547256150912,\n                4809190772735646976,\n                14038964654704901312,\n                4810292617849562880,\n                4821900892222560768,\n                4813603724124372736,\n                4819280735755495296,\n                4822610566489478880,\n                4816006883859259392,\n                14042634560297810816,\n                4816898174306484416,\n                14041415729104604928,\n                14043204774323879424,\n                14032263812185247744,\n                4824251022306511168,\n                4815714708448250176,\n                4824352099176760064,\n                4822771627786350400,\n                14045456005608666432,\n                4818150845709286592,\n                14046492672684653568,\n                4816196911150624896,\n                14024289203754354688,\n                4816132990815136512,\n                4820722995010682368,\n                14045548618391181152,\n                14047335087038948656,\n                14047483236205469840,\n                4815287811986221376,\n                4819392621112817312,\n                14046788616729130368,\n                14040185748553312832,\n                4822521488495523104,\n                4819037459709960256,\n                4821857412005156160,\n                14031289661305577472,\n                14043592793576397216,\n                14038079824613482048,\n                4819796039201375072,\n                14044855003696071424,\n                14047348241374504656,\n                14042668096284843232,\n                4823787437636000992,\n                14047143116912036928,\n                14043405734570576224,\n                4809161337669878272,\n                4823652707003485152,\n                14016115953265508352,\n                14042493814881047136,\n                14040564740421615232,\n                14043693961272589024,\n                14043558905470939840,\n                4819128362036283232,\n                14045160005047581824,\n                4820459876836838368,\n                4820740460149114272,\n                14037838192801226240,\n                4821324465880169984,\n                14047713368799961760,\n                14046136698295636576,\n                4818957119718662848,\n                14043087881275217504,\n                14045321649620690080,\n                14047751558931847168,\n                4814481604469777728,\n                4809688636361510912,\n                14032747037574260736,\n                14045950286585398176,\n                14045468384871546688,\n                4821035325058280736,\n                4823893253549734672,\n                4824235338383295664,\n                14039822301124175936,\n                4813737672817582208,\n                14039059043318756288,\n                14047355953993082944,\n                4814448375291251136,\n                4815373750324788224,\n                4804740873396689408,\n                4821050269607314400,\n                14040139703997154880,\n                4800843072695213568,\n                14039950304279988800,\n                14046483720400632864,\n                4816236974661058304,\n                14044510976345469568,\n                4820845278245663840,\n                4823921198926354352,\n                4820982581941428384,\n                14045302150871070848,\n                4818976014650297344,\n                14037399115891802880,\n                4819452753883066976,\n                4809857189520310400,\n                14030285707320278784,\n                14042171374130253312,\n                14043546346655092192,\n                14044504015016730048,\n                14046750616062742272,\n                14040128030505077760,\n                4821975792296201056,\n                14047735014810467472,\n                14047590122618461920,\n                14029594415300371456,\n                14047281100856681888,\n                4816831069296658624,\n                14045486262967254848,\n                4816209115508185152,\n                14045870558914631808,\n                14046952042967399840,\n                14042892920375540864,\n                14034595799128908928,\n                4819129793108769632,\n                4820688790156186304,\n                14042322096102552448,\n                4821428817846958144,\n                4819289188876866976,\n                4820802049049149472,\n                4821885868268199424,\n                14028583769458949632,\n                14038065367203005568,\n                4820964596614892768,\n                14044587721461000768,\n                4823273201925636832,\n                4821577155318449536,\n                14046068461590181568,\n                4819177116451387296,\n                4815199045803863808,\n                4812986310863715712,\n                14042320457874115968,\n                4821728869175179328,\n                4817118290021593728,\n                14044465515386736704,\n                14043013489679421888,\n                4795212145455230976,\n                4806010771812087808,\n                14037825921087217088,\n                14025382076973410304,\n                14046340635113923968,\n                14032305161331090432,\n                4814754911905610240,\n                14043531567504032640,\n                4812425179533299456,\n                14038261719361869696,\n                4819873550969124032,\n                14047109864937727872,\n                14046395427080352640,\n                14036812773169494528,\n                4812480689164345600,\n                4819100447569198080,\n                4807237462296128512,\n                14043731760297209248,\n                14043723129297686816,\n                14042645333447402144,\n                14037835835822670400,\n                14029110348785317632,\n                14047006297395373120,\n                4821913063741499040,\n                14044936016405150112,\n                4822717712052554784,\n                14045122524653940768,\n                4821591284936040768,\n                14040457461073027392,\n                14016146425523748864,\n                14047012642170281520,\n                14042544041986816384,\n                4809028432532429568,\n                14038156633758640448,\n                4807954720591889920,\n                14045947572926379328,\n                14047159803845178544,\n                4815611164880093120,\n                14044686521039847744,\n                14045495830219821600,\n                4820319362502675936,\n                4809294525693260544,\n                14026738281151544832,\n                14044109710240746336,\n                4813233988649725952,\n                4809210244393566464,\n                14046096384653893120,\n                4820502585899403200,\n                14039073281870312384,\n                4819381377692448544,\n                4811759195293818496,\n                4824252495791743248,\n                4819209359266834624,\n                4818434242659458688,\n                4796651384639742976,\n                14047304526397579088,\n                4819057072899896704,\n                14043886702060342112,\n                14035702716919901312,\n                14040144809997392576,\n                4816691232206152896,\n                4803928499375954944,\n                4780354733611663360,\n                14045782709149081248,\n                4822204646955057312,\n                4805702824993946112,\n                14043870095802326976,\n                4821653791802953248,\n                14036088984019447680,\n                4821693308789346496,\n                4819780132599639616,\n                14043391129296452352,\n                14019928981721321472,\n                4821046524681233216,\n                4806594942043273728,\n                14038297889287020032,\n                4806870243188259072,\n                14039290441169335424,\n                4811819949339144960,\n                4823651863586002976,\n                14041377308417522752,\n                14047065904518268464,\n                4823984547277953344,\n                14039579719176256832,\n                4816809430984693824,\n                14047330352750505536,\n                14047267481834992016,\n                14046145811618960896,\n                14038887624297920320,\n                14044618032489246976,\n                4820233682049965248,\n                14042452114862676192,\n                14042458847591791616,\n                14023180132084197376,\n                14038444346622941120,\n                4824299395723656016,\n                4818272672822072832,\n                14041604791378313792,\n                4822579585108401376,\n                4814511963403040768,\n                14040815467222898240,\n                14047225347427368896,\n                14040018757898264832,\n                14015889855587938304,\n                4823517098469829184,\n                4798166518074552320,\n                14042240202746069856,\n                4817631435430149440,\n                4820248451816436352,\n                4819095661418445280,\n                4817153832058025792,\n                14046924599444585104,\n                14043006637709542784,\n                4821207532900752928,\n                4822614504780526464,\n                4822005759589214752,\n                4819224138882024512,\n                14044557171411834368,\n                14033963449974099584,\n                4815613233092124992,\n                4811504947924010368,\n                14043191541465349024,\n                4823597637253280480,\n                4818528872451487680,\n                14044792103934095424,\n                14037985647362476352,\n                14043504252721566208,\n                14027294662693879808,\n                4819925851587257184,\n                4806433837706846720,\n                4815540747419930176,\n                14046849628928559136,\n                4820726315660429312,\n                4824030503091524288,\n                4822969168663340224,\n                14047146896339617040,\n                4821737278308029504,\n                14046209731321115488,\n                14044771878530547424,\n                4823761369698104336,\n                4822423121304083072,\n                14046875776775005424,\n                4816365006486358016,\n                4824122976934244912,\n                4810358632108605056,\n                14039862300397851072,\n                14040819618519188672,\n                14047311647881819536,\n                14044181267499570144,\n                14044941080029631264,\n                4823209471822802432,\n                14033305008224706432,\n                14044453522730380704,\n                14043563134412925472,\n                14047391853295458368,\n                14032052360908685568,\n                14047107929229772432,\n                4816477744177171200,\n                4819553124043671264,\n                4823003935814415040,\n                14046743297769601776,\n                4817713036143886720,\n                14033661123323239552,\n                4816430168316126144,\n                4817288844680599360,\n                4823785270842236416,\n                4819943196091629184,\n                14047704534451122336,\n                4814975870930787520,\n                4823170433987067456,\n                4818949894631688832,\n                4818213648479335744,\n                4823533175616710144,\n                14044434197586028384,\n                14037386034400436608,\n                4816598624796006720,\n                14047688961801601536,\n                4823976763447732832,\n                4818592093900749184,\n                14034360070733327360,\n                14046314264033446592,\n                4811856828549281536,\n                4823838852269394576,\n                14047442732139253408,\n                4819316904174790752,\n                4823822818513649056,\n                4797176268169957376,\n                4821076299014588288,\n                14043004763967198304,\n                14047394444087282528,\n                14038558150485732352,\n                14039208544327764864,\n                4805995204463727616,\n                14043415203445288544,\n                4818938431963797568,\n                14041147250445818752,\n                14035902534539939200,\n                14035572161475482112,\n                14041859923234640000,\n                14046278991373593824,\n                14045561005429541824,\n                14047698248554093440,\n                4819767166932819936,\n                14046302624715167456,\n                14038586048938875520,\n                14037400739175106304,\n                14042122143525630208,\n                4822779434321705440,\n                4819396562793443552,\n                14047484202957279728,\n                14047276338225352096,\n                14046973764803038160,\n                14041324231951552768,\n                4817913118120430464,\n                14044321112560685696,\n                4808302502776418304,\n                14047484695052835088,\n                14042458043994762368,\n                14042282896502234048,\n                14047700643038000928,\n                14043567711430682976,\n                4821471676990267168,\n                4823551122999922816,\n                14043287067297406784,\n                14045580200133713120,\n                4822068449999930976,\n                14044728823497951168,\n                4822152951607183392,\n                14047452110552317120,\n                14040074895901297472,\n                14042584425914731712,\n                14032488491824062464,\n                4798059679430110208,\n                4823717022874466288,\n                14046144831806163040,\n                14046210206509672576,\n                14033479115400395648,\n                4824359822644662784,\n                14045855510849158016,\n                4818409429647746240,\n                4806216260485526528,\n                4814820692188803904,\n                4823591340736127120,\n                4823568540118250928,\n                4821120247392047456,\n                4817611644243472832,\n                14047173753915574480,\n                4822781831765644448,\n                4819987300824400768,\n                14042910370310382432,\n                4823751810699436240,\n                4814559528094715840,\n                4820311686548119360,\n                4816097610281400832,\n                4824240795786472928,\n                14047429247787647920,\n                4814691235347679040,\n                4823193839528439936,\n                14045426810151784704,\n                4822228182782064832,\n                4821164008598388992,\n                4824205683657917648,\n                14030327408881482240,\n                14047210223843661888,\n                4784967496909733888,\n                14047254377239966096,\n                4808675887359889408,\n                14045131801245577856,\n                14046693708346473728,\n                14047363469138028048,\n                4820458432932222176,\n                14042165364655198144,\n                4812125949821001984,\n                4816626998785899968,\n                14044865070543061504,\n                4821676881830030400,\n                4813504641694460288,\n                14046899868673928176,\n                4819975639416213920,\n                4817062688781018944,\n                4805183220337536000,\n                14047339600066537600,\n                4814737995099640512,\n                14046081227197250464,\n                4823205884508119072,\n                14044375238697131264,\n                4815355389786951872,\n                14046777796006780480,\n                4819711576898985952,\n                14045844984252640256,\n                4819098066893399872,\n                4821524325555791104,\n                14042360239091200224,\n                4824356953009671552,\n                14047585420050962560,\n                4820897390846449632,\n                14042923926948395296,\n                4820923135385604224,\n                14031883854365357824,\n                14025977562247279616,\n                14047701158989305616,\n                4822882602605464352,\n                14035521514946993152,\n                14038459521056192832,\n                14046824278319491744,\n                14039302645939582016,\n                14046234379387811296,\n                14046706673405358944,\n                14031836686169992192,\n                14032916828081384960,\n                14034478277204661248,\n                14043483872421376288,\n                4807027326922350080,\n                14045457851614463616,\n                14039712657470712704,\n                14043535995640645152,\n                4781190069002698752,\n                4822493394911715360,\n                4820913865558426880,\n                14042848467254687360,\n                14044218300540241024,\n                14042416492279749376,\n                14047112192154268496,\n                4809062849980522752,\n                4822869183616651264,\n                14034196479917200640,\n                14043512056511054624,\n                14038046419294490624,\n                4805428344831387648,\n                4822272129022904992,\n                14035821435293192064,\n                4824403183863076128,\n                4815312947740003584,\n                14046751268344853824,\n                14046368717321639808,\n                14043888645459893280,\n                4822979728090420576,\n                14044764797717959360,\n                14042860928432459328,\n                14028520610043415552,\n                14034495580753253888,\n                4823242528857728960,\n                4816074563009374336,\n                14043237273945100832,\n                14045006107865117824,\n                14042980733972470176,\n                4818953101523468608,\n                14043755405108586464,\n                14041952680977708928,\n                4820862160181132448,\n                4819111188669601664,\n                4824376700572963520,\n                14036515688631302016,\n                4819259890832796672,\n                14042796629121605088,\n                14047229467203266640,\n                4820352897094299744,\n                4814512119779175872,\n                14040697385971595072,\n                14042836612688433376,\n                4823312526753240768,\n                14044430062932059744,\n                14047177198079744240,\n                4824193127097398400,\n                14047247811573483984,\n                14042643370545074912,\n                4821238751087753248,\n                14046285498965468096,\n                4801252367047785472,\n                14045214017015720896,\n                4800387493571614720,\n                14044971559762065760,\n                4820916656771517664,\n                14043134737591819424,\n                14047250594244384368,\n                14027618577795354624,\n                4803390966439840256,\n                14044580793709814848,\n                4820795576566887072,\n                14044121145263671296,\n                4823639300082839904,\n                14046242893781764896,\n                4824169055156469472,\n                4820622911656633376,\n                4818407494553344064,\n                4823132595943840544,\n                14047788261233029264,\n                14047812518264244624,\n                14047132692478265440,\n                4823797766372715584,\n                14012799994927599616,\n                4816616543693390976,\n                14039837999880766272,\n                4819897048216118752,\n                14040656393087780224,\n                14047797001760125664,\n                14037145585324746880,\n                4823492515381645184,\n                4824222078569410384,\n                4805843460972864768,\n                4814952543945210752,\n                14033031904786615040,\n                14047660965375379888,\n                14044048253245572512,\n                4822321577190644864,\n                4810128316400017024,\n                4821861530746518560,\n                14028718968555846912,\n                14044975852117647840,\n                14047400130017730912,\n                14042225248557556256,\n                14039811888342550080,\n                14044384438147288832,\n                14042040219040749632,\n                14042955093508832352,\n                14047213254448203392,\n                14047779678765732496,\n                14040060911340891008,\n                4823572615632682688,\n                14038863884918282688,\n                14043910394752092192,\n                4798083768317329408,\n                14029674447043756544,\n                14043902370111713408,\n                14030235128450219264,\n                14045986978923457280,\n                4802412758610304512,\n                4807843497383963392,\n                14047309969602672256,\n                14047113491932135728,\n                14038824108967523968,\n                4818986369390365152,\n                4812029209816684544,\n                14046934480698203808,\n                4823200712926546592,\n                14046889795365757136,\n                4822380915785931328,\n                4824077442888265840,\n                4814659809643589824,\n                14045319376819342976,\n                4816101734923469696,\n                14044439244143813344,\n                14042896548077394528,\n                4822172772786270048,\n                14036867072506479488,\n                14047695942324142944,\n                4816733372420111424,\n                4820083093962932384,\n                14047491085798036576,\n                4819764610424076928,\n                4819819130727716448,\n                14043710494891363360,\n                14044466825481203008,\n                4823695981929359216,\n                4815959408186151680,\n                4821903456732700224,\n                4817141770277991104,\n                4812857953904731904,\n                4821801557214778784,\n                14047040383521345888,\n                4823661919184471920,\n                4822587644078091392,\n                4817450020359373824,\n                14034882454485799040,\n                14045375642432151616,\n                14046504918605976096,\n                14046776485600802704,\n                14046705019211443328,\n                4819623183750355936,\n                4819865638067829984,\n                14038322995019137920,\n                14046783798459969808,\n                4813560665203641728,\n                14025122310054795264,\n                4823063871266427456,\n                14033981220724207360,\n                14046721154144792864,\n                14042822518445384128,\n                4822034619507504512,\n                4823106131960710048,\n                4823940965030420240,\n                14043786577559703008,\n                14044097391667306656,\n                14030050004434320384,\n                4822512125000163040,\n                14033594303258450304,\n                4819475898398384928,\n                4818045198789927040,\n                4817389518368260672,\n                14047771640547672128,\n                14043730397633921856,\n                4809559532635950336,\n                14044726126453256480,\n                4821309576545680192,\n                4816759391062564544,\n                14046853696255503424,\n                4819100830260411616,\n                4824419424788298064,\n                14046723202305094656,\n                4814544556670724224,\n                14039271499722070656,\n                14026696599710756352,\n                4823474363640589328,\n                14047028948189274400,\n                4819682008796086912,\n                14039470959076852928,\n                14044389816826803392,\n                4819741696910764608,\n                14041095107925719296,\n                4824420569627771520,\n                4824390506741089664,\n                14041672947656198656,\n                4821408791372344288,\n                4819540375374127776,\n                4819248293728082816,\n                4806936962710708736,\n                4819895515521051488,\n                4823884919635526832,\n                4820504163864409824,\n                14043698716671279296,\n                4823766888655161760,\n                14047151464206465696,\n                4817790191762082048,\n                4819349715404774496,\n                14031104874573218816,\n                14047790445837353520,\n                14045301380157162240,\n                4815580632890572672,\n                4820684797750426112,\n                14037983152210994112,\n                4797907297199373312,\n                14045146575882641568,\n                14044799477421043968,\n                14040169095956681408,\n                14038803861642804544,\n                14044097748261439712,\n                4818698150820339520,\n                4823012883833596288,\n                14047701964549510448,\n                4818370161758307072,\n                4820576457891488928,\n                4820459963548459360,\n                14047214712514987344,\n                14040442517581042368,\n                14025077579885121024,\n                14044805968493898656,\n                14045941706387944512,\n                14043686832438064960,\n                4809849891935518720,\n                4816705191054570560,\n                14046786392345949920,\n                4820380062344707744,\n                4818950219923920704,\n                4822272170511120736,\n                4812710800443716992,\n                4824276746619615120,\n                4819029035601163872,\n                14033293684377528960,\n                14041159640329023552,\n                4812483688115637632,\n                14031904573127046144,\n                14042457741636850016,\n                14039091781613372480,\n                4820927318019567680,\n                14043242319895159200,\n                14046475949894047616,\n                4822394121775350016,\n                4822636981833431680,\n                14047740530364838784,\n                4818694985451997312,\n                14033660649117541248,\n                4816018022615028928,\n                14040709576279109568,\n                14044703221840300608,\n                14029143281194108160,\n                4811085600218215040,\n                14041872488248484096,\n                4816440343283382144,\n                14038148684625784512,\n                4818039173569096192,\n                14044409957248009184,\n                14047717140772428896,\n                4822233654567273792,\n                14045014413904331232,\n                14038262630384989120,\n                4801034892246536704,\n                4820593581912697504,\n                14047431067404474736,\n                14042106118517394112,\n                14045679394771324480,\n                14045803964235293568,\n                4819571530039989280,\n                4817992542385581120,\n                14040716220003257088,\n                4821116160787218560,\n                4818960771374593696,\n                4819982081755677888,\n                14047031616543895616,\n                14046914178948953168,\n                4823801245206784688,\n                4815421408875968064,\n                14045722841755548928,\n                14046403992055730688,\n                4822265548039847392,\n                4820146594545107808,\n                14041354286291536832,\n                14045331692075098848,\n                4824104892957147216,\n                14037279099111422976,\n                14011505073551974400,\n                4797650488381337600,\n                4819930329719833536,\n                14034802315388413824,\n                4808582432654663424,\n                14043446955206387936,\n                4816701342642924800,\n                4819646896307486304,\n                14046959463050292832,\n                4822035124047226208,\n                14047804957498600304,\n                14040768612265496000,\n                4824082909256640608,\n                4821180563040851936,\n                4820737570396308992,\n                14028017667358446080,\n                4816220679882033344,\n                4820346820568523584,\n                14046695006976102016,\n                14032358063715759872,\n                4823272221586211200,\n                4819497935761788032,\n                4821879668523470112,\n                4823163038679642976,\n                4807558364765489664,\n                14047298086389419056,\n                4824423895118097824,\n                14040807996560257088,\n                14035815559751593856,\n                14042532594863171072,\n                4820173317409088960,\n                14046802420907552768,\n                4819648386414263200,\n                14043487188473131296,\n                4824407500215816656,\n                14032104065896952320,\n                4823913852248665712,\n                4810786061275712256,\n                14038120040170306560,\n                4824395745741625648,\n                4820550564083913792,\n                4804983809098205696,\n                4810160583923365760,\n                4800920352084143104,\n                14038304061985251200,\n                14034224554573983104,\n                4823773871870311920,\n                14036993344616877056,\n                4814477525440594944,\n                14046339579442061056,\n                4814590255428767424,\n                14045634308801758272,\n                14042953266319071936,\n                14047556597275717568,\n                14044390333021886336,\n                4819334215623260128,\n                14043485036108604576,\n                14046931377355619744,\n                14047693987350213808,\n                14047153494676446288,\n                4820582167050542080,\n                4820521939630448192,\n                14042651207160465216,\n                14019164222742009856,\n                14040032540273711936,\n                14046984778975810496,\n                14044137808748154240,\n                14047309611699410048,\n                4808449249573603328,\n                14041668472275926144,\n                4822575134359994080,\n                14044530254705037696,\n                4820416867876643040,\n                14041120892287766784,\n                4824241054272468896,\n                4823878293680742848,\n                14046865154093029600,\n                4821103105562856736,\n                14047465985844151024,\n                4819533786135150144,\n                14035024961257298304,\n                4818147753074575296,\n                4815964475886735296,\n                14043995115057475360,\n                4819937301192730592,\n                4815634586181721536,\n                14038766028606549696,\n                4814052806435341440,\n                4822096862987138816,\n                14047000522048339328,\n                14043127205223093376,\n                14039377820943484416,\n                4816608043046676864,\n                4823383351250016032,\n                14043049200640220704,\n                14032474406907333120,\n                4819801521307356416,\n                14043838539212011488,\n                4817809623341709760,\n                14043998079897956768,\n                4820880415016955072,\n                14033806712317000192,\n                14043050433861409312,\n                4823275798491550112,\n                14016682380955770880,\n                14034654062998027392,\n                4802446900394471424,\n                14032910497553583616,\n                14036377827472265600,\n                14047268673396894576,\n                4815581361225974912,\n                4808680875431067136,\n                4823954636654102624,\n                4821012926300724640,\n                14026070393259743744,\n                4818333383944114816,\n                14047586860192220144,\n                4822182193071175680,\n                14001873419040800768,\n                14044876342317314912,\n                4824287414674145264,\n                14046754953470993936,\n                4803093063968686080,\n                14043762683810490016,\n                4817587022019678656,\n                4816890792834352768,\n                4824041454783903696,\n                4822712377862611424,\n                14040386227273706944,\n                14046870618327012976,\n                14040653515509152320,\n                14036381356472305024,\n                14044406049077472160,\n                14038169909068977216,\n                14044114754412481600,\n                14042473098198077856,\n                14043202667742072032,\n                4811089924723728384,\n                4814708407105828032,\n                14032588426475405824,\n                4811822749608269568,\n                14046080434926323744,\n                14047147017273093456,\n                4814798375379535168,\n                14040202090153608064,\n                4824250093547825520,\n                4790709949686468608,\n                14044306778958041888,\n                4821293350483223392,\n                4824199321065388992,\n                4820676055722140896,\n                4819710845777098496,\n                4810420442862988544,\n                4815772297745774336,\n                4822247186631767584,\n                4812128131286420736,\n                4807319470975566336,\n                14043478617439591968,\n                14046839708255231408,\n                14046936415890011328,\n                4817970800367820928,\n                4823922460348815696,\n                14040139312965802752,\n                4820578199785300480,\n                14042744759733613088,\n                14045692182572326880,\n                14047800216092907008,\n                14043327008426986656,\n                14044235718400261536,\n                14045379468488903968,\n                14016357975001667584,\n                14040780393514288640,\n                14033997341388145792,\n                4823577954063905840,\n                14046861150808723024,\n                14047023416068008752,\n                4820298006957654496,\n                4807272254180607488,\n                4822220961123556736,\n                14037977470476288064,\n                4811234236807556096,\n                14036155846884299904,\n                4819330245586116544,\n                14045492250189204800,\n                4806774316409191936,\n                4813911127496019200,\n                14044258906467680960,\n                14035352415961263232,\n                4815492584012832448,\n                4823609875070311296,\n                4822894388576332448,\n                4819704637700896064,\n                4793116888844077056,\n                4823253146680873824,\n                4821048659881089920,\n                14030085037827512576,\n                14042722297151539872,\n                4791912151281739776,\n                14039205817442027136,\n                14037391109510543104,\n                14045098705965703584,\n                14035482324306170368,\n                14032226153664657152,\n                14046126367165035840,\n                14046920457521751568,\n                4822133760502083168,\n                4798067730175451136,\n                4818312350801927936,\n                14025910390769230848,\n                4821145361315738112,\n                14043463146632464384,\n                14035299930156616320,\n                14040285292402275200,\n                14046877045717181488,\n                14046664442283222208,\n                14047049341459729920,\n                14040261755018405120,\n                14029336578645687552,\n                4824013524059117920,\n                4821290860306103680,\n                14041683553610992576,\n                4813162394110489088,\n                4816020308622307712,\n                14046992609389370608,\n                14040658539594748928,\n                14041993908508617728,\n                4823545052902757264,\n                14040570851463978240,\n                4822324835731300896,\n                4822746580944419936,\n                14046767543716330912,\n                4822287850681802432,\n                14044769004683313600,\n                14047514460164226112,\n                4815405545693814784,\n                14046842051945763568,\n                4823758680262007104,\n                14036989946088182784,\n                4823767499620493120,\n                4806629308959177472,\n                14041081555847939328,\n                14047332956358413136,\n                4822329096416309440,\n                14045311011202963616,\n                4817493622147959552,\n                4820852129889496192,\n                4823910067768544096,\n                4816022299331604480,\n                14044604703129190944,\n                4815653675378373504,\n                4824039697430039296,\n                4810814449147564800,\n                4817492533314167872,\n                4819097795669798432,\n                4817726280046190272,\n                14041705101123566912,\n                14045969773679644960,\n                4813751384276521984,\n                14042605939098632160,\n                14020928961658515456,\n                14046287249357044736,\n                4822820247812969408,\n                14045758115066664640,\n                4824073289404049136,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n        SerializedFFTContext {\n            p: 4831535567424454664,\n            pinv: 4382457639974474137,\n            mod_data: ModData {\n                n: 1022545813831681,\n                ninv: 1864509616052343418,\n                norm: 14,\n            },\n            primitive_root: 11,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                4825439846457185120,\n                4821496375955681152,\n                14049432074167511120,\n                14048478640921129008,\n                14046841195274624976,\n                4825650894409250288,\n                14046178618945972768,\n                14047385253808960784,\n                4825851319364483808,\n                14046707542787468928,\n                14035437132771416064,\n                14049249919714584256,\n                14048315649665522912,\n                4819544071387224864,\n                14047809862777334032,\n                4804231751593389056,\n                4823540658199560512,\n                14035096759338017024,\n                14047985492045227712,\n                14047232511187730096,\n                14045558067334366240,\n                4818401787736819520,\n                4823971754795709104,\n                4824274440945422448,\n                4813373805408107648,\n                14046847133865445168,\n                4824874467674102608,\n                14047057175127032928,\n                14047337512356251696,\n                4824688535832160864,\n                14039642814059537600,\n                4825431061631096736,\n                4823857135317523216,\n                14047651134929528208,\n                4819853611199351008,\n                4824891664215266576,\n                14049196726504201936,\n                14048838363086239424,\n                14048788033313157344,\n                4821837116763697312,\n                4824165132311920512,\n                14042851180804928544,\n                4806543476166756352,\n                4821188583758948480,\n                4806058251952569088,\n                14047071222383024288,\n                14048983310422191728,\n                4817331328054397120,\n                4819257789212167040,\n                4822319399608984352,\n                14046288430572866432,\n                4826308677866686368,\n                4826710067006638368,\n                14049100323906066576,\n                4824669008026338704,\n                4823647945755946512,\n                4824144516159091040,\n                4802106136673379328,\n                14040754280317357760,\n                14042788466786814368,\n                4821615795891559008,\n                14044834037282175840,\n                14039478854006833984,\n                14040607596865999552,\n                4821946028368516800,\n                14049516732419034976,\n                14049206857969660736,\n                14049984964483129792,\n                4822786634136944320,\n                14048645380840578640,\n                4796586952420560896,\n                14048299641909678272,\n                14050223579179019984,\n                4821639862341614496,\n                4826083448808429712,\n                4818925895533524288,\n                14046140310705855360,\n                4824447739708704416,\n                14040583634108787136,\n                4817697548870899712,\n                14038495319671992576,\n                14049539081702425216,\n                4823973861279393648,\n                14043953473761831872,\n                14040821937507886080,\n                14042972836596274880,\n                4824241469782134688,\n                4826614002054715008,\n                14048661006473149200,\n                4826158942876350080,\n                4820498697288848960,\n                14042943144166162848,\n                4825476814041280064,\n                14046209373554872448,\n                14050369711676841760,\n                4826625113375115072,\n                14048775627815185280,\n                14047794119296666112,\n                4809037424436230912,\n                4819886308662117120,\n                14046702230224517120,\n                4806171070467751680,\n                4823663048961988048,\n                4823609660477321120,\n                14049121204679784768,\n                14043455999063375008,\n                4826221803976297536,\n                14044128325784850656,\n                14033765383685192832,\n                14049295679214985392,\n                14045637752390369472,\n                4824726587349038368,\n                4822910890163108864,\n                4824418996765631024,\n                4824746760597292320,\n                14046919827427072720,\n                14042940658021060192,\n                14035795643607627648,\n                14048353366022992208,\n                14043457251233012064,\n                14049341231454216304,\n                14036079412522896384,\n                4824023015558510672,\n                14047234394853446736,\n                14042165854941764096,\n                14035059051908634624,\n                4826395138883607632,\n                4825757721551474000,\n                14040808625615315456,\n                14047834766764041376,\n                4824255872273792688,\n                4822487547942965568,\n                4825798908091777600,\n                14030536133004097024,\n                14041347918954649600,\n                14049429496376697168,\n                4815425678752495744,\n                14043007954767362368,\n                14032926333973469696,\n                4825736866983086112,\n                14045816627924422912,\n                14043732880686297984,\n                4814842852911510720,\n                14047357888419900320,\n                4825907827293800144,\n                14047966526424251616,\n                14002559716742758400,\n                4810073521747832960,\n                14049973814603675072,\n                4821674598945080928,\n                4825295768309609568,\n                14048887066852165264,\n                4810619265463375616,\n                14048624081486644272,\n                4824421793077052992,\n                4823991882571222832,\n                14048256545945987456,\n                4820291280021689888,\n                4820266633957734976,\n                4819009480151447744,\n                4821204518766480448,\n                4823875594070730128,\n                14049259478421229360,\n                14050321028404402480,\n                4818877658333212640,\n                14047554331660805296,\n                14041219495619620928,\n                4824537814371695376,\n                14025713186051705344,\n                14048847933772515792,\n                14048859218688977104,\n                14049476186512291040,\n                4824383929827360064,\n                4826518874873005312,\n                4815726028918689536,\n                14030692357902129408,\n                4823625139044720240,\n                4818013809370647232,\n                14047648467880875952,\n                4819479411981134208,\n                14048094514946480224,\n                14049621633589141200,\n                4823094328091085056,\n                4809945138134605824,\n                4822896877449584544,\n                14033399590924075392,\n                4817875473122529984,\n                4820898691632714112,\n                4817176120574170560,\n                14049483272303519520,\n                4824857280230884176,\n                4810265091033998592,\n                14042291333033269344,\n                14042240775611339872,\n                4819290206020753504,\n                14049992373047944896,\n                4826794530549922064,\n                14049407313043269264,\n                4822222138002923616,\n                4816715619420569088,\n                14049419955940566608,\n                14041725160979721536,\n                14047329107528684720,\n                4821888646645182112,\n                4819584455773980768,\n                4815684254437081728,\n                4825751281298205024,\n                14046551727574677632,\n                4824465785789955200,\n                14044243325953149408,\n                14035621024797297152,\n                14045156568874581088,\n                4824530800850812304,\n                14046314914821141760,\n                4826092114703573360,\n                4826784285577746032,\n                14048559484278655232,\n                14047217799016411136,\n                14049371450465537136,\n                14045902624781340736,\n                14047837948620381584,\n                14036397915340799616,\n                4825556903921301504,\n                14046744415782606864,\n                14037076939308192256,\n                14050116905265819696,\n                14048477057662066992,\n                4814018216343754368,\n                4797599443515247616,\n                14050155978648458432,\n                4815898157752423296,\n                14047892865499719536,\n                14048282980144324816,\n                14042207184694697088,\n                14048226518381435872,\n                4821603726844806304,\n                14046234806401221952,\n                4826001184804767344,\n                14047819008011546704,\n                4825566132635704752,\n                14047250970282086272,\n                14050176659091494576,\n                4825734802991863312,\n                14040170659585065088,\n                14036681382702296576,\n                4821824713381115200,\n                4818152594735670016,\n                14035406496419305344,\n                14049243037275575216,\n                4825017005959015552,\n                4826635783914605664,\n                4822346645713292704,\n                4826637544877222064,\n                4825294442525891200,\n                4825830785175699776,\n                14040697121801716672,\n                14045012117981227424,\n                4824168735652351216,\n                4826447266245115904,\n                14046516602256015040,\n                4817202642448776768,\n                14046855072105445872,\n                4825260965865601232,\n                14049762559979192336,\n                14038359549076815424,\n                4824880816583420592,\n                4825969418483895200,\n                4824674280745916160,\n                4825318513062859184,\n                14048787506801188032,\n                4826769947669656320,\n                14048133072431917552,\n                4825983939612366240,\n                14049386051819287024,\n                4820228311272340480,\n                14045269817483728608,\n                14048530851330290112,\n                4824382435936497936,\n                14048802284956680592,\n                14036396827522221568,\n                4822532016225992416,\n                4817702104052781376,\n                4823847534414169648,\n                4816715516567467456,\n                4825092875893318368,\n                4826482831842853136,\n                4825021622063929360,\n                14048795651545758320,\n                14040963313355219712,\n                14045204371684147424,\n                4824312270644756224,\n                4810581102974092672,\n                4826430318245484096,\n                4822295706121617952,\n                4820411158551192608,\n                14042277403359517824,\n                4819068179216221920,\n                4820878151923922016,\n                14048372605695284080,\n                4817182474358183616,\n                14040395635930603584,\n                14049168165703315216,\n                14036987055459178880,\n                4819201072549382112,\n                4824082106520130544,\n                4823756490292596112,\n                4821452835792602080,\n                4820771256439777472,\n                14049410599165310288,\n                14045277100298570528,\n                14046213307027472864,\n                4825242206270109456,\n                4811532625785862016,\n                14040688091704011904,\n                4822619394684522816,\n                4816333038347396416,\n                14026674975446486016,\n                4815862890758514624,\n                4826645760117212544,\n                4825272946715171968,\n                4823604178010629040,\n                14049904196728932320,\n                14050067685668342848,\n                4825171982775794432,\n                4815388921128173312,\n                4826119520486388272,\n                4823788409425996112,\n                4824765239299562864,\n                4826779432598009200,\n                4811440425768318720,\n                14049505734665451152,\n                14042391975464536320,\n                14049381343011974656,\n                14044540453754271008,\n                14020587942509486080,\n                14043647104960028576,\n                4823849829521596512,\n                4825885184058158208,\n                4825902361501455152,\n                14040184349038736832,\n                14023730280822118400,\n                4819637203821021024,\n                4814864937783417536,\n                14045140967046545856,\n                4801549417825792512,\n                4814424904006263232,\n                4815169646328046464,\n                4819500496277027232,\n                14049552317581345632,\n                14045889270549134048,\n                4821832716006128320,\n                14041965506656694592,\n                4825498982319318720,\n                4825619054106821248,\n                14047141004118321648,\n                4814936855401470336,\n                14043783962626559936,\n                4826727388778005168,\n                14048006119331581104,\n                14042731692928365120,\n                4822013985983097728,\n                4824232106235068720,\n                14049409117379024480,\n                14044085783029509056,\n                4820200493272226336,\n                4822479442500902368,\n                14039364370094074368,\n                14047325203924138560,\n                4819684284883995424,\n                4819070679250932864,\n                4821267478059587904,\n                14040885711575448960,\n                4826764026048432480,\n                4826802182038415312,\n                4822162150327408512,\n                4811662723463885056,\n                4822740194952644512,\n                4824408842656977472,\n                14047552556339420432,\n                4823955575677817328,\n                14049845523229576432,\n                14049767743838189616,\n                14045318914905471712,\n                4825328220400156112,\n                4823638354597169440,\n                14042363969061733312,\n                4824140736343351344,\n                14041904554047165312,\n                4825190543136406064,\n                4815783965092671680,\n                14023972928314634240,\n                14040597923386037056,\n                4823131374472999840,\n                14049919093648136768,\n                4825356348717539792,\n                4816951159099933120,\n                4819453906571232064,\n                14040716287590795584,\n                14049013900291608288,\n                14040234476364309888,\n                4825970269891838448,\n                4820752838051846368,\n                4823498853947566016,\n                14048380975301037776,\n                4821452588103068352,\n                4823783301985832816,\n                14021403150307355648,\n                14040721939593446144,\n                14049535717764115056,\n                14048461964356772480,\n                14048496183702034480,\n                4824409224561906000,\n                14042603297674050528,\n                4823922282601109504,\n                4825466993846379920,\n                4826995751540017216,\n                4823281069958606464,\n                14045646770566069088,\n                4824575750684921408,\n                14043208150546584640,\n                4826996588836298656,\n                4824736778634036528,\n                14042286746572494432,\n                4822504839104164672,\n                14048691040060141952,\n                14047355978975364080,\n                4823750966892361088,\n                14028188694380263936,\n                4821011994680771936,\n                14041983186979442624,\n                4822254982781049984,\n                14034940666250038656,\n                14046682469371083456,\n                14049926134188778384,\n                4816280370878262144,\n                4826343908792766976,\n                4820894682002475104,\n                14047904237205727536,\n                4821237398477175776,\n                14045658287882346240,\n                4818359231666234496,\n                4825236691698971904,\n                14039499859206479104,\n                4824019573488824800,\n                14050285875103353168,\n                4824391398762946432,\n                4816119493188454144,\n                14047889610306379936,\n                14046864442446616384,\n                14048353843027293696,\n                4826910037252760192,\n                14049942324334851408,\n                4824231023076788032,\n                4819510038671787040,\n                14043876694452371232,\n                14039741973866638400,\n                14041073622438834048,\n                4824934762448348416,\n                4824433818469612496,\n                4819733937074020672,\n                14045521682297220576,\n                14049299785189010448,\n                14045877844421124160,\n                4824639572617382464,\n                4823677039543959424,\n                14048558464022900544,\n                14031024396471978240,\n                4816337874438634048,\n                14048955707982341856,\n                4807748437136682752,\n                14036607901753294336,\n                4822933451224082656,\n                4818489078521299776,\n                14045939638836249152,\n                14030084009143558400,\n                14049987984258383040,\n                4826686622448442816,\n                4819803611899043200,\n                4825797068268621248,\n                14037683166895959936,\n                4824414103396857488,\n                14039846689628315264,\n                4826558905340836752,\n                4821283912522613184,\n                4823749785067243552,\n                4825089353421362096,\n                14036844074703361024,\n                14048759031375612400,\n                4824736654607524592,\n                4824837390459668688,\n                14017030017284132864,\n                14048549363791237888,\n                14048268963466243728,\n                14049843957187662208,\n                4824958833567658384,\n                4815364328462287552,\n                4807307617245065472,\n                4826500897732746976,\n                4824337483163992400,\n                4817062577208958464,\n                14042407853197218208,\n                4824690927746163664,\n                14049468599377236944,\n                4826648924684605888,\n                14039071815433929856,\n                14038148806069372672,\n                14042775386823149952,\n                14047156478776688304,\n                14048872969713169920,\n                4811547568881958784,\n                14037113358034368256,\n                14039662166213802240,\n                14036822908249530368,\n                4825075158881459616,\n                4795119593266028544,\n                14038906582407862336,\n                14024313017620431360,\n                4823960575994067824,\n                4799472508850048000,\n                4825650290575776624,\n                14043324890206042848,\n                4818979306384984544,\n                4822071500741073088,\n                14036128351785239808,\n                4817226027045636416,\n                4826554358365942144,\n                4825661727902174672,\n                14049039392648512656,\n                14046641398275848672,\n                4813515345678205824,\n                4825898830368634704,\n                14044312294333542464,\n                4821549216934020128,\n                4822016692002862816,\n                14046493545003971936,\n                4825162770744742384,\n                4823516311344336816,\n                4823706597452143360,\n                4824666357692637984,\n                4823584262980329520,\n                14033601008849362816,\n                4824234970790291648,\n                4823060903647197888,\n                4814849777588118208,\n                14045520557179463424,\n                14048744670606424576,\n                4826270678208114976,\n                4820865186154251296,\n                4825568802975275728,\n                14049542671919275456,\n                14039931685086816576,\n                4824237336375659472,\n                14050045806336407600,\n                14047271232968161536,\n                4816723896056407936,\n                4821525035261909440,\n                14045864470024110560,\n                14049602534072716656,\n                4824688150974602448,\n                14036798330832329728,\n                4812286073985733760,\n                14047145630953159328,\n                4826455677854903968,\n                14047344046922410432,\n                14037127073201500928,\n                14043542973236493600,\n                14033912162969075968,\n                14043462748018882752,\n                14049425767573745872,\n                4820568386167520096,\n                14046080505180103552,\n                14046053370511627456,\n                4818828357635448640,\n                4826331097166840720,\n                4810638366685441664,\n                14033340269387483264,\n                14042709212052946880,\n                14045052978390783936,\n                14048142430406778768,\n                14048440192607175008,\n                14038481930555397056,\n                14048898918960950736,\n                14022631639189305344,\n                14044545110440436864,\n                4824569540153180560,\n                14048979119157150160,\n                4817506697255589888,\n                14045871076192335648,\n                14042730057149022304,\n                4818175592273592128,\n                4823431183585260864,\n                4820617230021939968,\n                14042474368019836736,\n                14046372771584161120,\n                14043422801323945280,\n                14036572240553991040,\n                14034662342192216576,\n                4825320004088378192,\n                4807800418904261376,\n                4817045316579373888,\n                14042747936623150944,\n                4824176106466215408,\n                4822594936836978976,\n                4816017344086285312,\n                4813664948448407040,\n                4820244204869737280,\n                4819148758840189280,\n                4817949881454028032,\n                14032814218523377920,\n                4817641178576458880,\n                14045849068800341888,\n                14049940644631331408,\n                4824856006764364368,\n                4821147618192466304,\n                14048652779938710752,\n                4803826622211950080,\n                14043336844994776640,\n                4824763929097326560,\n                14047410002213487888,\n                4824757238532195120,\n                14045303433252424320,\n                14046079823483535680,\n                14042394042499877408,\n                14048154907769951792,\n                14048711639123229024,\n                14049131229502242896,\n                4824871085925037328,\n                4817531397551552256,\n                14049810863594677696,\n                14047899945136881504,\n                14046755647165919936,\n                14048677382877737856,\n                4821295906805741312,\n                4820367788584550400,\n                14049528022891518848,\n                14049179816082274736,\n                4824403309474203616,\n                4826130448927041328,\n                14038761107343131904,\n                4810852209145262720,\n                14049973225576423312,\n                4800308232723200000,\n                14049995619627505456,\n                4807717568771531520,\n                4812823248937967616,\n                14047573210008597280,\n                4825124177681552320,\n                4823880704686516480,\n                14049169339115445472,\n                14047664367957566576,\n                4824080487495534656,\n                4822110916558156832,\n                4822474728988646976,\n                4815547369838738880,\n                4813759360908208384,\n                4826393960327734496,\n                14045403110379662624,\n                14048138448148485488,\n                4824412996159721328,\n                4826449173214665440,\n                4812119531866916480,\n                14039064264952847040,\n                4810038100637919872,\n                4822061851829804160,\n                4819607045127841696,\n                4824971342012011152,\n                14043235008871433312,\n                14038603410745437248,\n                14045115613112012192,\n                4820378306860499520,\n                14048292795468980528,\n                4820485536164221152,\n                14048592981206063104,\n                4825634304340203024,\n                4826361706128051776,\n                4823923018594407984,\n                4821067687723533920,\n                14034718645823337600,\n                4824876054991360080,\n                4796846518314719232,\n                4824720487400231264,\n                14047062858483509152,\n                4812604756067401856,\n                4822539066659357664,\n                4827000063820702464,\n                4824178633920672992,\n                4815274196970367872,\n                4825338915440250384,\n                4826152124684246416,\n                14042542906148414752,\n                14042525956216601504,\n                14043099611161991840,\n                14033459074969784064,\n                14049866209312737680,\n                14041437704515657408,\n                4820663341206715872,\n                4819599997341311584,\n                4825659499550340080,\n                14047400607394115056,\n                14042389168941073760,\n                14043454830622202304,\n                14048039578958039504,\n                14046836207905883184,\n                4826454662676513088,\n                14039045173613872256,\n                14046128589203081152,\n                4826030772614305824,\n                4811518011268153728,\n                14036217924826495872,\n                4805744518735155968,\n                4820658237813497440,\n                14047951338530823264,\n                14050149103677225536,\n                4823251641267295616,\n                14035891587959352960,\n                14043771124136676768,\n                14047484707462289248,\n                14033870594489282432,\n                14035382387270127744,\n                14049413597009271872,\n                4826495797908445728,\n                14044302384756198208,\n                4808798022799624960,\n                4816266262628546880,\n                14015765324118446080,\n                14029583277355657216,\n                14027425222137940992,\n                4825548741658910240,\n                4820486782811366880,\n                14049627269157569264,\n                4820869070258316704,\n                14047897776056204224,\n                14046709688696975808,\n                4797351224611823616,\n                14044306594147305216,\n                14048759603106942224,\n                4824921994972638576,\n                4819093160934810880,\n                4819777150824746400,\n                4825469984026456576,\n                4821855056544062752,\n                14041484337592020352,\n                14047162457818414288,\n                4825579489031771392,\n                14045409921482667776,\n                14049502986651713216,\n                14044089508238178592,\n                4805584847020056064,\n                14049642162491457408,\n                14047392605268107136,\n                14038191608691707712,\n                14045926630779467008,\n                4826961446116550480,\n                4809423666134189568,\n                4824685277725351312,\n                4815855588104679680,\n                14048091258367868496,\n                4819217259501132800,\n                14047777463802578288,\n                14047246937568362048,\n                4825755712070607680,\n                14049268546762237712,\n                4814576355710964800,\n                4821694409038310496,\n                4823244017262304928,\n                14042371362774673792,\n                4826785512340213488,\n                4818902671001911904,\n                14023406777958383616,\n                14046259886234207488,\n                4823926147925104976,\n                14033455468399341696,\n                14035239372554111104,\n                4826453350357865728,\n                4824400787144292592,\n                14040639694771469440,\n                14032511588392805376,\n                14042278402574395232,\n                4821443001047528800,\n                14047510164774242608,\n                14046127177886709856,\n                14049387924701320544,\n                14043463601800607616,\n                4822875730173340832,\n                4820354706127420448,\n                4826623659534784112,\n                14033968932604615680,\n                4814905870122492800,\n                4825735847869654800,\n                4799689029665595392,\n                4824079747914595696,\n                4826371673164429840,\n                14049950732580699312,\n                4820367999390297472,\n                4824322495376996208,\n                4820090362278880064,\n                14045929780988237152,\n                4826192249397381312,\n                14049836059559425216,\n                4826633796876354400,\n                4826075003648160720,\n                14049512940147944032,\n                4815195885277015680,\n                4826979736650115232,\n                4809986930076721536,\n                4820213035302990176,\n                4824741945156946816,\n                4815890841606257984,\n                14029183012973093120,\n                14046130537650035744,\n                4819315693364971840,\n                14042917069162641728,\n                14046669144130864608,\n                4818859157581594752,\n                14030328471082210304,\n                14039443063793102016,\n                4823418770397502672,\n                4823818180144152976,\n                4826904007596055936,\n                14043744198151351840,\n                14037374062775425408,\n                14047927914571752736,\n                4825564456034688016,\n                4824533421499704352,\n                4823939785236395632,\n                14044229703397373568,\n                4820601716647929536,\n                4819487496734492640,\n                4826526329396875328,\n                14043231179398194304,\n                14045545737844476352,\n                14046002242483695232,\n                14047763197586319872,\n                4826987405878869296,\n                4818542575417747072,\n                14042858460978928384,\n                4823877262103057472,\n                4824258821813163520,\n                14042651024878868800,\n                4814930319937262784,\n                4816798607497173760,\n                4815823823167915264,\n                14050353905051478832,\n                14042885595953849248,\n                4812575329450717184,\n                4825231872087973152,\n                4825282376062237888,\n                14037676278814186368,\n                14050302740000229488,\n                14049894648032058400,\n                14049206713474606080,\n                14044838246628745984,\n                14049095836655535552,\n                14049968214001048720,\n                14044227582927963840,\n                14048641082553657024,\n                14048372273111292080,\n                14046654014624341216,\n                14047033100361827488,\n                4810301788389754624,\n                4819652107322060800,\n                14047938053517573664,\n                4822499302560775072,\n                14048095407390508864,\n                4819789371325841152,\n                14042888958448864768,\n                14048969430698072048,\n                4818031726029999040,\n                14045642808305735936,\n                4825968564518465424,\n                4820557431700935392,\n                14040743629522074304,\n                4815000782626714240,\n                4822477092099813184,\n                4819378807116125952,\n                14043143846145778880,\n                4810173887417183104,\n                14047046126653069616,\n                14046235874810864352,\n                4821956453653179552,\n                4822019943690503392,\n                14045969616696886304,\n                14047182795170331712,\n                4822770793588756544,\n                4821429285262282240,\n                14043454524442908992,\n                4821515647695305184,\n                4823600111391195872,\n                4823769809983629952,\n                4826201393072381712,\n                4824733559659976928,\n                14048338761246973504,\n                14039278764680940096,\n                4819203263347387328,\n                4826823705040708560,\n                4820141583604387872,\n                14047246367360338608,\n                14048863302639523280,\n                14048017404046559984,\n                4822765405561003424,\n                4824942651098081520,\n                4812718003030252416,\n                4820468236814268768,\n                4825066985069040096,\n                4825569512721551296,\n                4819671786241032416,\n                14034625309146908032,\n                4820839568389181696,\n                4820946277405463424,\n                14049844745794832672,\n                14049215085359949776,\n                4818334344290953472,\n                14046127869628347680,\n                14022220936127863808,\n                4826516177736531936,\n                4821366808516176352,\n                14041435382413692480,\n                14049375929547494288,\n                4812796398722643072,\n                4813289227877067008,\n                14037312721648543616,\n                14049005237534088528,\n                4826829034573383392,\n                4826488458664625472,\n                4825524396028412144,\n                14046636513540159136,\n                14048825164605475824,\n                4813356299740130048,\n                14032842616344302592,\n                4811065878872511616,\n                4823991091686203536,\n                14048705018704599376,\n                14044971868279260320,\n                14046018082164159200,\n                4821797347583687968,\n                14043987263225202752,\n                4815038065148411200,\n                14042345223280430080,\n                14048620122827002736,\n                14044118514012857152,\n                14043744435022921536,\n                14046519768891554176,\n                4826051844271858176,\n                14045014223420747008,\n                14035373638332441856,\n                14049682757039302432,\n                4823270303523298624,\n                4822064180558385920,\n                14041694855809086400,\n                14032837796621953792,\n                4816438443657809024,\n                4826788103791773728,\n                4826520238854468256,\n                14047636733556707136,\n                4824418530271369424,\n                4823410202322094352,\n                4817599598034374592,\n                4824685115979946816,\n                14029764788408598528,\n                14047307215220347104,\n                14046504293845433952,\n                14047589664575596832,\n                14042387774984080256,\n                14046670580002995936,\n                14040923813559830912,\n                4826790217518370672,\n                14049261678863331216,\n                4816375768647296896,\n                14049629842661921056,\n                14042967395677096960,\n                14047270587850405472,\n                4824741100189444192,\n                14034231755276104064,\n                14047674892218507360,\n                4823547538853694384,\n                4826656806385249680,\n                4825956739762067568,\n                14048530764307271344,\n                14042343636662625280,\n                14047958383424955792,\n                4819550859965958208,\n                4815211313426282112,\n                14042965360708413728,\n                14049705793243530208,\n                14047434928515237408,\n                4820554446173328736,\n                14015506114511925248,\n                4822929228433297792,\n                4825784103807786064,\n                14043284597103888192,\n                14049561312226384544,\n                4817127930150870208,\n                4819987335537630112,\n                14047126856689396352,\n                14043008935335511456,\n                4826948320477658480,\n                14039613373101957440,\n                4816065657029506880,\n                4821127159174599904,\n                14042962080275296832,\n                14049718837132357280,\n                4819079995865709152,\n                14034848005353102976,\n                4825044032733391648,\n                4819984866554399808,\n                14047000303049511808,\n                4819989828606245024,\n                4823954289410169840,\n                4823915094795780000,\n                4820079626384799488,\n                4813226839480610944,\n                4826628316346224960,\n                14034502223421584896,\n                14044143276650279584,\n                14033488023314340992,\n                4816300966530191872,\n                4822369313988188896,\n                4818179196508826944,\n                4821668373061070112,\n                14040802742465851264,\n                4823162495545218240,\n                4825024222162203008,\n                4825316907755618096,\n                14044333239230684544,\n                4826437049633839248,\n                4819954104206541056,\n                4823696242301690800,\n                14048628076877786176,\n                14044073929032496960,\n                4819785834658580928,\n                4826274314036046864,\n                14049129466280858640,\n                4822305249037436608,\n                4824676915362923760,\n                14030626858710564608,\n                14047548513061270800,\n                4826299696939748048,\n                14047677687271339952,\n                4819703657166055296,\n                4826123106258670656,\n                4814494561027482496,\n                14047595719191995952,\n                4820290370792754336,\n                14048588448461892176,\n                4825489440091287104,\n                14038430452169271744,\n                4821943257095109056,\n                4810570234222318464,\n                4814441036464969472,\n                4826432144159867488,\n                14038876040000856320,\n                14049846460802877824,\n                4797446831860947968,\n                4800452802573444096,\n                14046806877626272304,\n                14029788929538882560,\n                4818909271150376640,\n                14043585412179423072,\n                4823962447889166624,\n                4819223493994120800,\n                14047818317681896848,\n                4826689597366998160,\n                4823313439603733984,\n                4792767879105748992,\n                4822492540107020128,\n                4817325418698451328,\n                4819374804666530144,\n                4810906165122853248,\n                14046973755419059312,\n                14049143398304481392,\n                4823915832138753360,\n                14047456354968544192,\n                14048030057206810080,\n                14049080069005429664,\n                4825329629560243824,\n                14050203466536735376,\n                14047259869801015264,\n                4824549576136668736,\n                4825422072700504176,\n                4821047988790626240,\n                4823171540843029376,\n                14040605886499666944,\n                14047588690533763920,\n                14039861601899159488,\n                14048919388030028032,\n                4791879807981289472,\n                4822619776376717504,\n                4820136989492235136,\n                14039787137695227712,\n                14047777870197080944,\n                4821778475313640544,\n                4824603659490274960,\n                4823121015640963456,\n                14047272632378851264,\n                14046902723877733024,\n                4823914248522111904,\n                4825432797714302368,\n                14049283862014817024,\n                4820147655076425536,\n                4821438503795564000,\n                14044249101722111936,\n                4820679207125281248,\n                4824030319502576704,\n                14047412760310556736,\n                14040491766856776448,\n                14048433310975025184,\n                14045138227902389472,\n                14038246844811241280,\n                14013182530125299712,\n                14044337679270986784,\n                14048141994381478032,\n                4803044374332002304,\n                14044242565610171424,\n                14046307199516274432,\n                14049756400785096416,\n                4807131973487489792,\n                4820852463101817696,\n                4818359712902447616,\n                4811919784360547968,\n                14048755303230566480,\n                14050269981455532288,\n                14037870852578746112,\n                4825520135781005072,\n                4820354070894826464,\n                4823794715321659936,\n                4826053468822012288,\n                14036991397143189376,\n                14037431300751563776,\n                4811530836259894528,\n                4810926535090671872,\n                4825592620633234592,\n                4824097521296087616,\n                14044175780359309856,\n                4819847400102978464,\n                4822744404688184192,\n                14031160185260761856,\n                14048607097045334736,\n                14046939316674684512,\n                4817330339518588544,\n                4812759831043427200,\n                14044108570754980960,\n                4826009000771851584,\n                14037848495792716544,\n                4808929004254640896,\n                14037065678234222336,\n                14020857437520893952,\n                4823183312704643264,\n                14046950564152196320,\n                4815747721095218432,\n                14050314493195724672,\n                4826225363998048992,\n                4804148171821246464,\n                4825752542128104880,\n                14049709949051090320,\n                14048130094101239232,\n                4826337035164226016,\n                14043381932350579328,\n                14049353777096587344,\n                4822471464151734112,\n                4826245182002943600,\n                14048909659817754336,\n                14047909261643443568,\n                4821221176591159136,\n                4826711140177431440,\n                4825458692263520400,\n                14044860238871633888,\n                4824306477632930864,\n                4815951350281205440,\n                4819253086299931456,\n                4796543367766173696,\n                4825101563299500896,\n                4819999581443394560,\n                4824482264609853632,\n                4826811345746284752,\n                4820922701782187168,\n                14047948790565785904,\n                4825541011185013104,\n                4823196259360788480,\n                4816319632084924800,\n                14036471294960703104,\n                4823035655924240736,\n                14046938119666594320,\n                14050176578974035424,\n                4824509524606850720,\n                4816123365714627456,\n                14038742311889040320,\n                14040494386843939392,\n                4825718956116088128,\n                4806889039969765376,\n                4814575420765909248,\n                14042412615453765280,\n                4817771483819901376,\n                4814495640955967104,\n                4822153577161486336,\n                14037554026376755456,\n                4824727050046397712,\n                14039172958646028096,\n                4824236915291075472,\n                4820762957900082368,\n                14032479336683529472,\n                14046641404795147008,\n                14032056089182161664,\n                14032197948507593216,\n                14043745007938122784,\n                4823584857958768352,\n                4820323913366312576,\n                14046185783913124096,\n                14047429041491562448,\n                14047965095846403456,\n                4824788802286565696,\n                14049654991143129808,\n                4825885452662721184,\n                14045476205272549504,\n                4825868815597100208,\n                4819420769586381760,\n                4819822403642163808,\n                4825592746953216032,\n                4813605056777581184,\n                4825552316431883088,\n                14047765912609298496,\n                4824138522888393536,\n                14049587860241542400,\n                14048173277158064800,\n                4813439619653685376,\n                4826089665418992304,\n                4826196899562722496,\n                4825081416070216240,\n                14048276227124763248,\n                14034284957261792896,\n                14046170815933109184,\n                4816086607136520064,\n                4822809563083392288,\n                4824829074996751072,\n                4816836911373258240,\n                4826046162427789520,\n                4824797222859209648,\n                14048446240795550400,\n                4824143743560886000,\n                14046985642333586352,\n                14048909038628702448,\n                4814301446758108160,\n                14048464017215606000,\n                4823888234356872880,\n                4819423383845975136,\n                14048421304194497808,\n                4813339900290152960,\n                4826728691086466832,\n                14046015903365080224,\n                4824236855735842112,\n                4813915471922892032,\n                14039463645589175680,\n                14048796532573511456,\n                14044598060993028992,\n                14042942765800923520,\n                4823406627730367792,\n                4814163796892690560,\n                4820536026366912064,\n                14038169298413220224,\n                14047611918471099792,\n                4826741809243464448,\n                14048070145981044512,\n                14047871351779314624,\n                4826219963917336112,\n                14048111882735954848,\n                14041990737815684544,\n                14039471523651096960,\n                4824258170952457072,\n                4826255987486838784,\n                4811852247995185152,\n                4826403842148221728,\n                14048178215624261616,\n                4820747532149644672,\n                14019751516481141760,\n                4825537450867081456,\n                4806894111534958080,\n                4815892556662859392,\n                14048042338679889920,\n                14044939536066528608,\n                4821582547498918976,\n                14040933604370686272,\n                14043943305402206560,\n                14048476690997752864,\n                4808318502219236352,\n                14043164964543085440,\n                4825485388567324352,\n                4822552672395115712,\n                4818789949735707136,\n                14047053024070127328,\n                4819654097025476480,\n                4826804190407413760,\n                4824133763811074336,\n                4816648722922354560,\n                4817393400097349440,\n                4820293062245492736,\n                14043953091056011168,\n                14049711376046639744,\n                4824917227063910096,\n                14047134730213249296,\n                14031038240764570368,\n                14044434224538882496,\n                4821748476715239456,\n                4823504041115816768,\n                14048797153992188864,\n                14049938008208514528,\n                14047149066117257024,\n                4806351249621259520,\n                14048120193485889952,\n                4809840470600779776,\n                4816026615325588672,\n                4804948647360359424,\n                14048963088481197328,\n                14045240901348843712,\n                4809394648214140672,\n                14048185385951011568,\n                14044836711974848896,\n                14033785658298971776,\n                14047641065199970416,\n                14047583799743240976,\n                14050181407417338816,\n                4820737802524540896,\n                14041891759427852032,\n                14044457651661143168,\n                14046944166956308032,\n                14035567746451128832,\n                4823013155896423264,\n                4824285675630475616,\n                4825084525051707024,\n                14050269478797102064,\n                14050359236633670192,\n                14047607623552658144,\n                4825652509333356176,\n                4822255951798439744,\n                4819772822830510464,\n                14046978867928959424,\n                14046917968702578544,\n                4824456049594556144,\n                4819625950844985440,\n                4816387432303887232,\n                4812083553806669312,\n                14043985391311278336,\n                14044480740720573472,\n                4823211887556564096,\n                14016583140060821504,\n                4819906212071993536,\n                14041483172895711616,\n                4824949774559324464,\n                4817542567014155712,\n                4826728159076317840,\n                4821520786034099808,\n                14049863634959999008,\n                14038741117966392192,\n                14049368136722705808,\n                14048186632629201536,\n                4821102470974378752,\n                14048244569498905552,\n                14044953601067135968,\n                4815230950245974336,\n                14040974555162249472,\n                14043347516161419936,\n                14029617310758649600,\n                14039860776417689856,\n                4820583943804101024,\n                14046254775406378272,\n                4808329137798987520,\n                4825986483115752928,\n                14048899265200552800,\n                4824739304425436480,\n                14035739421423227392,\n                14042787038294124992,\n                4825817632497591232,\n                14047375320605378368,\n                4803952415216879616,\n                14046234405827477696,\n                14032419552812955392,\n                4816145077642689280,\n                4826889270591175808,\n                4825060462423522144,\n                4826592297688266352,\n                4823356264334252880,\n                4824288247621825760,\n                14047511999047995296,\n                14045946291583477984,\n                4824903689575812384,\n                4824798081038212240,\n                4821186856290193856,\n                14049981337315338560,\n                4827000395756173584,\n                14043124773056072032,\n                14046037551195392000,\n                4813111672367320576,\n                14045120941965299232,\n                14048604636422214576,\n                14042648769702025984,\n                14046716642684931328,\n                14046095853466408064,\n                4822941483311167904,\n                4824259468642938848,\n                4823504475960459856,\n                14045849879349392864,\n                4825771480509140128,\n                14044990403509249792,\n                14049556253943900592,\n                14037445488276187904,\n                14044578198019793216,\n                14044387310190291936,\n                14046298048276456480,\n                14042569721787555168,\n                14050380414401739792,\n                4820817181633632192,\n                4821654779093982656,\n                14050022148261812144,\n                4824553590009302496,\n                4824513668487248208,\n                14045922401824014816,\n                4825145125914348832,\n                4826955639517804704,\n                14050088439872854224,\n                4826342717404428928,\n                4823504375151870944,\n                14046905484156924320,\n                14038246643554791232,\n                4825640588322413216,\n                4817440889399166080,\n                4826619704933710928,\n                4819828544130119360,\n                14047911018518934480,\n                4823476427886154576,\n                4826741533517054528,\n                4823819962658517024,\n                4823017985615223680,\n                14007972156868919296,\n                4817915087741585024,\n                14038019531852635264,\n                14049971652863745680,\n                4826732531823049632,\n                4806702662171230208,\n                4800280155724620800,\n                14048582412558968976,\n                14050176775204780512,\n                14038841642857498240,\n                4821522603856178848,\n                4812159375519389056,\n                4817483175532139840,\n                4826757774988687920,\n                14046042218686540704,\n                4811907985366866048,\n                14048710865644571664,\n                14045554630980844512,\n                14033776592126946176,\n                14042478820511500608,\n                4819032866156458016,\n                4816951991993230912,\n                14049836654866279920,\n                4825002966912610992,\n                4824350437780540432,\n                14042658649619208064,\n                4816387912109924288,\n                4822249872411261728,\n                14048749082715245136,\n                14048910350591238768,\n                4821075825689468704,\n                4814156455305786112,\n                4820352753242367296,\n                4824817474869839648,\n                4823766221737785424,\n                4821413945503262336,\n                4824018909257097568,\n                14044327407090908000,\n                4824092044126163104,\n                14047932041556017456,\n                4823955314026203472,\n                4821899966424712256,\n                4824560176261311760,\n                4819556483839416992,\n                4823582584189814944,\n                14048396706455320944,\n                14042462281834194880,\n                4821415590976539072,\n                4818875693049439744,\n                14048022164592874640,\n                4816359248765248960,\n                14048553219247178768,\n                4824993443519122608,\n                14047470201004715360,\n                4814725086017628800,\n                14048362820662586752,\n                4824201274119435136,\n                4817525552815527040,\n                4826816321960095920,\n                4822495284665335648,\n                4823495312536349984,\n                4823423546369904976,\n                14049804948284949120,\n                14045794597291580128,\n                4825363654137113088,\n                4824304627970683680,\n                14045307964267453984,\n                14042616500024715200,\n                14048545974147001024,\n                4826701935269041600,\n                4816097250299011072,\n                4825040314247223536,\n                14042546208692535264,\n                4820181521171473504,\n                14046979231743893376,\n                4824757982060070368,\n                4823510128064686176,\n                14043456597105802400,\n                14048145368947174560,\n                14047831280027726976,\n                4826306259893735392,\n                14037392716565903872,\n                4820227960395513600,\n                4822837955691074560,\n                4823682107330982832,\n                14048021331878239312,\n                4822613793903993248,\n                4824468923427139856,\n                14046763139382734080,\n                14046570501544411040,\n                14043831027226196576,\n                14041488578648610560,\n                14046438164875921312,\n                14046807851315383712,\n                14037131730701250176,\n                4826859771957013680,\n                14041861951313989248,\n                14048969939287891072,\n                14044464260514826944,\n                4815747147179601600,\n                4807228720428141824,\n                4825335964692005440,\n                14038579359248175808,\n                4824296091476457520,\n                4823371145629464512,\n                4811974800141394176,\n                4824954027672691616,\n                14049017521573291776,\n                14033804773590299648,\n                14049900982598159968,\n                14047900234773537568,\n                14048053924107199824,\n                4807025578591968512,\n                14044049452599187040,\n                4822675330746200832,\n                4817849261617340352,\n                4825166319042070832,\n                4818034409673005952,\n                14049230956802255232,\n                4820342335007337504,\n                4815288980825441728,\n                14050202921602986352,\n                14044226444113633344,\n                14046710569192130400,\n                4822403151516937632,\n                14047111266617014688,\n                14045311161844417696,\n                4824437209140276208,\n                4824294536233436048,\n                4826583464122238128,\n                14048343277757924144,\n                4812534467063176960,\n                4811070970808184448,\n                4820676808825991520,\n                4815520262510235072,\n                14041953380187747200,\n                4824659542538461296,\n                4825924445854376832,\n                4821369459846907488,\n                14049788119375923168,\n                14043389625569876832,\n                4816097146744870912,\n                4817819963198776448,\n                14038935813634969088,\n                14050314137765697152,\n                4810630835809058304,\n                14044439962977664832,\n                4822692796627273056,\n                14037916695401171776,\n                4821948988798858880,\n                14047530027596012448,\n                4821148769758957888,\n                4812741877952696704,\n                4826121857522812784,\n                14042955203190647488,\n                14043838241508323168,\n                4826455829917334000,\n                14044506214913952544,\n                4817242318425768448,\n                14046962336677935776,\n                14049646546102863056,\n                14038373574308968192,\n                14049638247713734416,\n                4806787291405901824,\n                4823593115746579872,\n                4819093118386918592,\n                4822994777755530688,\n                4809961387020574848,\n                4823085436466622880,\n                4812713748662732800,\n                14049334583722684176,\n                4822929660385233088,\n                4815025488364019264,\n                4825057688321364368,\n                4821779996738790208,\n                14045221209337665344,\n                4825587530221902864,\n                4818024601764440448,\n                4824400704834961504,\n                14048429024546680736,\n                14037590158187846784,\n                14048308392828760432,\n                4816861049524085632,\n                4816208878815724864,\n                4803995892228722688,\n                4825194003812114880,\n                4823661329109171312,\n                14049740215485385808,\n                4824223353761470816,\n                4819437827420016320,\n                14034491112708651776,\n                4820503272556359488,\n                4825896176477528608,\n                4814739028080879104,\n                4823916997167553776,\n                4826486557849964880,\n                14028417292665296896,\n                14041312909684077952,\n                4820599057763908032,\n                4819070306181481504,\n                4823509856779361776,\n                4823612348510249152,\n                14044557735548507104,\n                4825357238952569728,\n                14049782571897932992,\n                14048448058465315408,\n                4817196628885106816,\n                4826706291810242016,\n                14034389231462510208,\n                4823972713464442240,\n                14049548100495544176,\n                14043928937181569344,\n                4820947218881948864,\n                4824682919731118800,\n                4823960403920997568,\n                4821872811296834048,\n                14047081796615753200,\n                14047203450685982704,\n                14038660813630139648,\n                4826883210122778064,\n                14048734369853168240,\n                4821246693342109888,\n                4824113443298676208,\n                14049327646808716464,\n                4827008645489881552,\n                14050130863787317440,\n                4819894905687163648,\n                4818824874114218688,\n                4826126527355560960,\n                4817814506978647104,\n                4822235975726277856,\n                4825387855685014848,\n                4825404711346732368,\n                14047662240244513168,\n                4820583721379047552,\n                14044202145464581888,\n                14028086285990765568,\n                14043445865816615936,\n                14045417496689893440,\n                14032225424463567104,\n                14047795867073309328,\n                14048239301865053136,\n                4809511958832710912,\n                4821639854725086880,\n                14048210935271976672,\n                4826207876711999248,\n                4823932418190385200,\n                14045322633841252448,\n                14048744025555198304,\n                14004519280049324032,\n                14047006101882084560,\n                14048309591520782144,\n                4826370485642349904,\n                4823464484389071584,\n                4825633686374016880,\n                4819818250586263232,\n                14029662975750372608,\n                4823645398383868448,\n                14044140273208182848,\n                14050346319433422224,\n                4823780705985484768,\n                4824448774291990656,\n                4826387294426337008,\n                4824904733477846800,\n                4826257345629324144,\n                4823568242425851808,\n                14047494598402896576,\n                14049556025970338160,\n                14045346765518864064,\n                4816882271685640128,\n                4812928322042141952,\n                4822202457637178464,\n                4822743282355661280,\n                14048446989852183648,\n                4824136861647769232,\n                14034110703522126464,\n                14037890672735795264,\n                14049229296017695104,\n                4825494913203540496,\n                4822287670857857344,\n                4817896458487387200,\n                4825984135807891488,\n                14044795731299322368,\n                4826869491530128944,\n                14047557388804465792,\n                14045273610727535008,\n                14044622858232728928,\n                4817795697797931776,\n                4813807398642846848,\n                14049836151809199248,\n                4824575904371739184,\n                14045484026610000512,\n                4808120005931792640,\n                4825049572854158608,\n                4807416235454870272,\n                14039181824665880192,\n                14042122446237690304,\n                4826825440926239904,\n                4819386461792489376,\n                4825454054599997536,\n                4824175878193000432,\n                14049041100006051040,\n                14046256726845991712,\n                4826228254255950912,\n                14043589627205975744,\n                14032719653987641600,\n                4825055616313143648,\n                14042462378922748416,\n                4825679120283502160,\n                14048327036877893648,\n                4824380379149475152,\n                4825324485563110224,\n                14047991840588314464,\n                14049340628751140944,\n                14050386581483220384,\n                14049022429583085872,\n                14033312282245391360,\n                14046732985129364944,\n                4812652715911210240,\n                4816213878965598720,\n                14040038480545065472,\n                14025160878632648704,\n                4826963780137039648,\n                14047522265028865632,\n                4820349660205531136,\n                14036883772189656960,\n                14044152749069925696,\n                4825552828696468320,\n                14048563823690479024,\n                14030455256348985600,\n                4825985257305659520,\n                14049119559190809664,\n                4824407092655869120,\n                4826876864970481472,\n                4819589842567840480,\n                14043844513007503360,\n                14047701361816516112,\n                14038673881964376448,\n                4818578847743258624,\n                4825009922789398752,\n                4794647900895479808,\n                4826584262023826784,\n                4825475835751686336,\n                4818935633117503968,\n                14046311634240345824,\n                4816243175557617408,\n                14047316128610743712,\n                14050124867208011776,\n                4808382482357242368,\n                4824642767332485792,\n                14046690852699346880,\n                14042258888921612928,\n                14042913818238120992,\n                4823601825046207232,\n                4819795939960280384,\n                14043305642111563680,\n                4825428231513926416,\n                4820120878080386592,\n                14047037798896737696,\n                4823516157604645888,\n                4815747829737092992,\n                4826252426656470000,\n                4819926446552226976,\n                14040010428707993920,\n                14043435723798294848,\n                14043233969202285504,\n                4824445073012859360,\n                14045006988632565856,\n                4820560834806834240,\n                4815294002732771072,\n                14042501223771940000,\n                4821592541054222560,\n                14045554554677133472,\n                4826372287928391536,\n                14048744121856970672,\n                14043538274880890784,\n                14045509255011748448,\n                4812244562852267520,\n                14049968039044416848,\n                4826915182655836496,\n                4819351863690680736,\n                14046443947125096064,\n                4823646985388566560,\n                4825102256140644624,\n                14048823737051732032,\n                14049714216147792000,\n                14048500942435690432,\n                14046967218525159712,\n                14034345696757952640,\n                14040537946971417472,\n                4825102698915087280,\n                4825010718277323440,\n                14040220089583963840,\n                14038953125165337472,\n                14050052470812233552,\n                14033724626394242432,\n                14040529519055901376,\n                4807618178158558464,\n                14048034691616895360,\n                4824206041696383136,\n                14045748618996727968,\n                14048176028304207888,\n                4817774454980068352,\n                4819022413307113536,\n                14048038073258886528,\n                4824255453644224464,\n                4819334078957093184,\n                4822953738851166784,\n                4819777161106546016,\n                4824371788628917008,\n                4821180978528803232,\n                4818210681043392704,\n                14050220024392281264,\n                4814460917429043584,\n                14048782837587198768,\n                14044897144280841088,\n                14034285676187728000,\n                4822114357786113792,\n                14047222359279277696,\n                4803356161066532352,\n                14047390369256095616,\n                4824669783340554528,\n                4823807521836723872,\n                4821428959640002464,\n                14024500817583929344,\n                14041572821642777536,\n                4820334721759161184,\n                4815093687146802176,\n                14049192922549600848,\n                4826107246492551200,\n                14038255593217494720,\n                14048070915991946496,\n                14037017753525203072,\n                14049162615217054880,\n                14040261855872021120,\n                4819358922875158464,\n                4803459961727256064,\n                4819041052901324384,\n                14049829626863457904,\n                14048302278328593088,\n                14036184300521872512,\n                4810111472734145536,\n                4815629102568766976,\n                14049725704914389040,\n                14048698355980350736,\n                14046907874083368928,\n                14044219613299633120,\n                4826843843341551344,\n                4825814879252869680,\n                14050387031982471616,\n                14046611041701457568,\n                4825304392467587744,\n                4825482345109604528,\n                14050360798251040944,\n                14046781266396278960,\n                14039512020855226752,\n                14050166359293773648,\n                14033601036272941440,\n                14045892173451118368,\n                4810107325648705280,\n                4819596456235106848,\n                14034676051888983040,\n                4825538221735414288,\n                4820736741307720384,\n                4816406278538255232,\n                4825098644895795552,\n                4815890859717271168,\n                14047493601964200880,\n                14047612289691821872,\n                4823232864194843616,\n                14040337312209482048,\n                14047094853312119584,\n                14047603550125293728,\n                14047395006479348256,\n                14049004644282541696,\n                4819829006639404512,\n                4826127954952750512,\n                4820053235145574784,\n                4821752284220280800,\n                4822190597677158880,\n                4825318946518790880,\n                14047594724273745616,\n                14050009994324352304,\n                4820650890674854240,\n                14039451415979393216,\n                14047260395530473568,\n                14047652180770077440,\n                4824098156969192480,\n                4823382309099936000,\n                14035860561104472064,\n                14039390791156409280,\n                4796408937667940352,\n                4810481476953535616,\n                14047990478854565408,\n                4826515146318441680,\n                4805488446506747136,\n                14043705800095967296,\n                14046172787990548864,\n                14037755041527788160,\n                14021610300325761024,\n                14043147634800268928,\n                14041663058837872704,\n                14041544739256108480,\n                14047161686811858560,\n                4825906789220059360,\n                4824196507355004752,\n                14048415935474726752,\n                14042348734584953472,\n                14049548813523729184,\n                4819393917570848512,\n                4825765607257631520,\n                14045723735397976896,\n                4812499529122388608,\n                14047746179937980096,\n                4824643863796155792,\n                14048372722326881152,\n                14033904761883055488,\n                14049729029885848944,\n                4819540472962949664,\n                4826951853175949824,\n                4825769893550953648,\n                14049775327798027744,\n                4824672908039304864,\n                14042159892508817920,\n                14049038105367161232,\n                14048055525241910688,\n                4821612229112130048,\n                4818789576123961280,\n                14048422127579856528,\n                4822296188468900832,\n                4819087040934395136,\n                14042220494334781632,\n                4825411306427650624,\n                14042923719704688832,\n                14044761843608653856,\n                14040944860831471936,\n                14048964086407954528,\n                4824104588097178208,\n                14035923090899508096,\n                14030524012802870784,\n                14047422351335699472,\n                4823015253974865408,\n                14040383510463157888,\n                14047275360713146336,\n                14047391090409943232,\n                14047850381142283008,\n                14039516883028265152,\n                14006415774645075968,\n                14048499678039701200,\n                14036545505289196672,\n                14048847478039742336,\n                4826623829027218368,\n                14046837267005826096,\n                4818915438175823680,\n                14037399254739363712,\n                4816033507981116864,\n                4820385877433056832,\n                14047615650387250288,\n                4807038628806562304,\n                14044422482325045664,\n                14047812237176520288,\n                14048509833824251840,\n                14042212732525123008,\n                4825198427790427104,\n                4825624362522840928,\n                4815008762717817984,\n                14047036551828177136,\n                14050222615451067152,\n                14040214265193336640,\n                14032230174190772480,\n                14044050054574931136,\n                14039995569462228480,\n                14042357303480415328,\n                14032273916463947776,\n                14044167584954213920,\n                4823621736779969056,\n                14049200019094823072,\n                4826076196071654448,\n                4802918797468423680,\n                14045735987758439104,\n                14047247353592620288,\n                4824778785395283888,\n                14049983280216469728,\n                4822128190067187072,\n                14049367367560314064,\n                14037517315011367936,\n                14041349824715694720,\n                14047878350251701536,\n                4823891494123471168,\n                14040075337064462848,\n                14046868729889458672,\n                14041731896359393856,\n                4820078566836918560,\n                4820902115747632640,\n                14048826124561595408,\n                4824227353872573392,\n                4800915695091262976,\n                4826636136481301248,\n                4814982297116827136,\n                4821828722561273344,\n                4820498837584286336,\n                14042939358816585056,\n                14045418282475930496,\n                4819640142905624704,\n                14033731889993414016,\n                4821479698086380768,\n                4819397642454309344,\n                14041335567837243648,\n                14036140589121085312,\n                4816870774372371968,\n                14044494726856080512,\n                4824703986083544784,\n                4826965952713317280,\n                14047924308892749968,\n                4824118392422061456,\n                4823746317588446384,\n                14049046926733949296,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n        SerializedFFTContext {\n            p: 4831465198680277000,\n            pinv: 4382500666457514068,\n            mod_data: ModData {\n                n: 1013749720809473,\n                ninv: 2040746090583899817,\n                norm: 14,\n            },\n            primitive_root: 3,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                4817247727980125568,\n                4825321074127147056,\n                14045897366133639168,\n                4799076302293404672,\n                4815096634960094144,\n                14032413498573211392,\n                14048131086875926720,\n                4824961258136783936,\n                14048647426631102048,\n                14033844839309557120,\n                4812376598533030016,\n                14040476274729997696,\n                14049317458526386944,\n                14047091506787708368,\n                4820111890967091360,\n                14045519652690835840,\n                4825423312945966352,\n                14050221761703734416,\n                14049879988542651136,\n                14045653392598027936,\n                4809658051387331072,\n                4823047852989701184,\n                14043897352608058944,\n                14048856151523561904,\n                4815848502957585856,\n                4826892684983434640,\n                14042869236451698656,\n                14049880623794938528,\n                4819578146339783840,\n                14044812389203359168,\n                14049149527341699872,\n                4817426255157415616,\n                4810616878939192704,\n                14040675184820247616,\n                14043338056002125888,\n                4825988602241020304,\n                14043675625404483392,\n                14046484360952658048,\n                4823071036591053984,\n                4823785102892147392,\n                4815640938452832064,\n                14040906557683203392,\n                14049442167416609552,\n                14050082520665835008,\n                4825529645800553248,\n                14045697111833594848,\n                4809701732190784000,\n                14046740669301075680,\n                4818491503596189184,\n                4819271739338795968,\n                4814994381110367936,\n                4814287932015059328,\n                4826893216458965200,\n                14049374347974003856,\n                14049690523986300064,\n                14046993172634227424,\n                14049922908470693056,\n                14038060216251590720,\n                4818989473290089376,\n                14047074031023484528,\n                14046432866756713568,\n                14035276392248976000,\n                4817754412243740800,\n                14037883319745406720,\n                4802212562804460544,\n                4821270173053818208,\n                14039683621379689216,\n                4825703143847413680,\n                14046988017117655168,\n                14048612349944228592,\n                14030193643659148800,\n                14048133864531518976,\n                4816534743448840960,\n                14032202866638982912,\n                14044953737445956608,\n                4826590184334372560,\n                14046844280201201664,\n                4820640033542428512,\n                4816841558156658560,\n                4800610735082861568,\n                14041087126981829504,\n                14049013824293805328,\n                4820326027993933472,\n                14046814625996616816,\n                14048695259430989968,\n                14043991882890555584,\n                4825301109404366816,\n                4811252942205037440,\n                4825607720404157760,\n                14047707233972303376,\n                4818518089915074432,\n                14038543403062469888,\n                14049111493964486560,\n                4822421055549660992,\n                4825303102579638048,\n                4820051247094122240,\n                4815452854279961728,\n                14044032486787756480,\n                14043357989756589312,\n                4822365832989823456,\n                14027286583426888704,\n                4812051851201686400,\n                4821556755010824928,\n                14040830369786274240,\n                14046607602693685888,\n                14041542586621442816,\n                4817363364845815424,\n                4824077197219980240,\n                14035164600336721024,\n                14049117324932605856,\n                4805496587839898112,\n                14043070558021474592,\n                14042393142787556800,\n                14047267672452546016,\n                14050203426318129744,\n                14050205212826655856,\n                14042011226601735872,\n                4820790042538903392,\n                4821450440634288032,\n                4798803893457392640,\n                14047500319381373104,\n                14031666317021128192,\n                14044037260676175872,\n                14047435325672699520,\n                4824401055608835136,\n                14047229578779307424,\n                14047290655869536768,\n                4817775182462038080,\n                4817839968247378880,\n                4826727467825576032,\n                4825705393107090640,\n                4819245725442869728,\n                4816732980152952768,\n                4821480803481381536,\n                14046033895611066784,\n                14047517011185894016,\n                4821776036603368256,\n                14047933236563027712,\n                4826435711911637664,\n                4820501196403473088,\n                14042855259192733728,\n                4825294802508505696,\n                4811783740398346112,\n                14043393108172016608,\n                4812227194344915968,\n                14048478971209265328,\n                4819052380929893888,\n                14048267554488027248,\n                4823831305139698784,\n                14048560878999062144,\n                14048888262160795248,\n                4813401423847082496,\n                4822321984566678432,\n                4825411103948254160,\n                14049956069210542544,\n                4822373800028262240,\n                4820785044898098240,\n                14042436161317528416,\n                14050022381485030240,\n                4824885920824324416,\n                4826172787133621248,\n                4820012297158944896,\n                14036247539392002688,\n                4825378076858837040,\n                14043132369698897088,\n                14044103387171144960,\n                14024863020143131136,\n                4825118156218632576,\n                4810485575720084864,\n                14033248211791048960,\n                14049396061044568080,\n                4810490341997276672,\n                14047827549995917376,\n                4825153696758014448,\n                14048783455109537632,\n                4799927289216800768,\n                14045711037293712192,\n                4824825183013633920,\n                14041375434691079424,\n                14041984292342412864,\n                4820252426055550848,\n                4826067712725732960,\n                14048296872887875408,\n                14041865134026575104,\n                14044281813490105088,\n                14037713456342445312,\n                14049614924845659728,\n                14048019028511673904,\n                4821983803495383872,\n                4823335156631948352,\n                14036381263410124160,\n                4817445037286628352,\n                4824728085145249360,\n                4812457641990374400,\n                4825867696990924448,\n                14050313017841934816,\n                14050075819775351616,\n                4816908024084271744,\n                14047918857752990416,\n                4825073243497182864,\n                4821468600371419488,\n                4825669557015477856,\n                4825895375065998720,\n                4826543597171310096,\n                4814685298716716416,\n                14047254363350515392,\n                4819059368480581600,\n                14043156558178590848,\n                14049586759268805728,\n                14047820557986704576,\n                4820007423222845440,\n                4826784660194864688,\n                14039838824737512512,\n                4809922061111647616,\n                4820717299139551520,\n                4816346758052272064,\n                14030193050466259712,\n                4807027060315917824,\n                4797114810679913472,\n                14049272329023560496,\n                4823737395222962384,\n                14043780618518719968,\n                4826169169264256672,\n                14049051289844378496,\n                4824688892948045152,\n                4819002335038054432,\n                14046913438012915344,\n                4825618611410595584,\n                14038807439231778624,\n                4821166297978331968,\n                14044189910563672480,\n                14045689696735212672,\n                4810926285687961216,\n                4826046957226221808,\n                14046299921412173152,\n                14043932173396777856,\n                4819358751019051776,\n                14033774489891646848,\n                14045459624458070784,\n                14049340655944428272,\n                4819933974381387840,\n                14041514089948438272,\n                14048879830235182480,\n                14043357388614516960,\n                14046139160351580096,\n                14043257177500582912,\n                4814571168449543360,\n                14038054265897331072,\n                14050162231718555440,\n                14043855283120998880,\n                4816605869219511936,\n                4821692244655636832,\n                14045908279964528896,\n                4824161211664133248,\n                14044623744673721792,\n                4818625522523472512,\n                14049803851566399776,\n                14048702450340064400,\n                4824709352340310160,\n                14048042223671935040,\n                4822146589031120512,\n                4817227680101645440,\n                4826484027378866800,\n                4815383370009139648,\n                4824430616525852928,\n                4816297551031623232,\n                4826293191961438432,\n                4826121693898336832,\n                14040272768988886336,\n                4822794872035475392,\n                4819178925861825216,\n                14040930387960073408,\n                14043845036815974816,\n                14048858663024925776,\n                4824219575099298224,\n                4812708167864436224,\n                4824781804083932400,\n                4823386089894994848,\n                14046476056355188672,\n                4816710127987636928,\n                4825052195407440784,\n                14046789934236262240,\n                14045283020417087904,\n                4818339673445823872,\n                14046931085037218848,\n                4814570516628108096,\n                4821597740470276128,\n                14045715297449567456,\n                14046799343966158592,\n                14044526979886664096,\n                4822590163478787456,\n                14048944124198852624,\n                14048037612365859680,\n                4825374552605309616,\n                4825883494317744400,\n                14043651043260695072,\n                4825783811623427840,\n                14002529360831528960,\n                4820998670401813920,\n                4824011924454919584,\n                4825940018090815264,\n                14018822878973458432,\n                14049672696347445328,\n                14034702410133325952,\n                4821354039653970848,\n                4824919630999725216,\n                14048260826578930672,\n                14049322901801867808,\n                14025396975639941120,\n                4820421926977429472,\n                4824952101725667344,\n                4826069920802110816,\n                4826400069372329104,\n                4810293334654057984,\n                4824339524613870944,\n                4825557554763124432,\n                14037987054156467520,\n                14046015563539831232,\n                14047519151376571600,\n                4821542814897532352,\n                14025023093008722432,\n                4824573049926996496,\n                14047889467680928480,\n                4826447026563549616,\n                4810243419264615808,\n                4826676334017085168,\n                14049138981758873424,\n                14045309689852550368,\n                4826257931627573744,\n                4815882363200098880,\n                4815766465308388480,\n                4809996137606160512,\n                4819536572687478112,\n                14045095257580854912,\n                14046899717161879360,\n                4816660067459389248,\n                14048423701644560960,\n                14034053766605905536,\n                4824840291761964848,\n                4826893092015778512,\n                14047033290823828240,\n                14044854007769184640,\n                4824595704843934688,\n                4824739528485642208,\n                14048090265605705024,\n                14046972269284891488,\n                4822287088818254016,\n                14036292660791469568,\n                14047479066706692960,\n                4826059055465154688,\n                4805217788935621120,\n                14039929529930651712,\n                14045579995840724736,\n                4821028449249191264,\n                14048633041888341040,\n                14048700923782786224,\n                4817082879672406464,\n                14049705608751836720,\n                4821150750313838112,\n                14047206191228607392,\n                14042506440118707200,\n                14047361221958137088,\n                4819863867688203744,\n                4811068521210525312,\n                4824873851817057552,\n                4822760170925511296,\n                4801420263170261504,\n                4823434161378211280,\n                4797541161619253248,\n                4823831900861184672,\n                4793531812516716544,\n                14050238926341491824,\n                14040930320701782336,\n                14047933410996576016,\n                4819683150271984544,\n                14045730136551340704,\n                4810504454175822208,\n                14047009818833638752,\n                14047812851283968912,\n                4825514204256313680,\n                4819815371168489216,\n                14028149300567108608,\n                14048821856356385328,\n                4821709813957582912,\n                4826925035543150864,\n                4824385933560766112,\n                14042551645153713152,\n                14046872573205029424,\n                4806908526872391168,\n                14040632295050160640,\n                4826201876143785680,\n                4824573620087514544,\n                14049336286930974160,\n                4806435030947848448,\n                14050262510935517536,\n                14047994999201748720,\n                4810549870652156672,\n                14044225502951681280,\n                4823826953806031424,\n                4824563562880265056,\n                14037408746295225216,\n                14048793781541068768,\n                14047919632595832688,\n                4821063592540214048,\n                4819464693928865344,\n                4823851066292438960,\n                14038077009473914624,\n                4815870078126786944,\n                4820413949281085856,\n                14048381398248761168,\n                14047781361523048256,\n                14048190403104487280,\n                14035827290296305024,\n                4825722656047968256,\n                4825583003686548592,\n                4822593431742379648,\n                4823839111780243408,\n                14026908170648473088,\n                4807646277057426432,\n                14047352483697346400,\n                14048773854632410080,\n                4825821991769392912,\n                4824531381501430688,\n                14044876376391119968,\n                4810786286085069056,\n                4823404794866865632,\n                4818768938731229760,\n                14049154589141956912,\n                14046397336735781824,\n                14038617669938231616,\n                4824914636947133632,\n                4826290250455565344,\n                4817664509448726144,\n                4826261276281810416,\n                14038877300792047744,\n                14045113414164871296,\n                14049639085809418528,\n                14042971026722054240,\n                14032740906178474496,\n                4821185458492525344,\n                14036705879821549440,\n                14035044639995235584,\n                14049022278692248592,\n                14046483307483724096,\n                14043661628638383328,\n                4818093367173774656,\n                14040476733919508224,\n                14049163111699653744,\n                14045437876906763712,\n                14045758151386091168,\n                4821480813655307392,\n                4825952211794413888,\n                4793951600858667008,\n                14035129932671057792,\n                14049333757598101280,\n                14048205968065322928,\n                14039245339415826880,\n                4826204962667300560,\n                4815414079499956864,\n                14042490622445243904,\n                14045769223322912288,\n                14048586673093989264,\n                14047014276973146000,\n                4823580973391122832,\n                14037466350456584576,\n                14049359445535476096,\n                14047297078540720224,\n                4811787419445252352,\n                14028900113309792768,\n                4824240337277109472,\n                4816547074395133824,\n                14037397287508535296,\n                14045110014875789248,\n                4826123424112271440,\n                4797350601556633600,\n                14041518906197837696,\n                4820529605923954368,\n                4825190814279963824,\n                4815321990733636032,\n                4826582632475960368,\n                14043393699986467616,\n                4823916116940856544,\n                14050195792884740016,\n                14031645050948277760,\n                4826077430167600016,\n                4815711447509679744,\n                4826901187515376976,\n                14047568802398895456,\n                4818884524874976288,\n                14040187179418917504,\n                14041510136669915840,\n                4822851777368962080,\n                14049179291689597776,\n                4809054163488595712,\n                14049511936722004368,\n                14049443848248981968,\n                4821883686839722848,\n                4822317592557665024,\n                4820933286182567648,\n                14042539615341990432,\n                14049565438113034208,\n                4826254480637490656,\n                14043008279789330592,\n                4820030287370943456,\n                4818802015336235136,\n                14049840906431819424,\n                4826038665313220208,\n                4824662433783319904,\n                14044142809064929056,\n                14046752340706113632,\n                14049876585425099744,\n                4826229668489658816,\n                14043255517149582144,\n                4819107838797533856,\n                4819694943498257568,\n                14049909971315187712,\n                14043187220776154112,\n                4820311334255641088,\n                4825258002643439184,\n                14050128850472564560,\n                14041209073460566848,\n                4810976488444294784,\n                4823618207383722784,\n                14048630895509271424,\n                4823539148065537776,\n                14050135555417231456,\n                14040655362754024704,\n                14033616761445810176,\n                14041691844414895104,\n                14050320916628430080,\n                14049124774173115328,\n                14035319571415079040,\n                14048699395981034384,\n                14049095948128942752,\n                14048926419471587696,\n                14050058752937606432,\n                14046831644390647920,\n                4821470706560000544,\n                4818363553368584448,\n                14026630451652196864,\n                14049834904153395200,\n                4824860412181453760,\n                14045689841766635040,\n                4825182705554027904,\n                14047798498244471328,\n                4824012117900795600,\n                4822478178905397024,\n                4826096103588816336,\n                14047580743331772720,\n                4825430160754486112,\n                4823127884763617472,\n                14033694608093543680,\n                14035586030643123328,\n                14047842109729376384,\n                14048167281019064144,\n                14050154990887546592,\n                4824138704351804944,\n                4817143288096894272,\n                14048061818425130736,\n                4817706371691658624,\n                14046746823486324464,\n                14044375444772357376,\n                4824309274559565072,\n                4824320249358117344,\n                14042689886707067424,\n                14043454515401690496,\n                14039087968893311552,\n                4825935819913731360,\n                4824383397909951616,\n                4814484324684005952,\n                4819577087919466080,\n                14048101058097173760,\n                4824927411552890048,\n                4805959722732647424,\n                4826271371045042400,\n                4818626670550594816,\n                14043408062671562592,\n                4814560135319369472,\n                14048920724651993280,\n                14050024079913756720,\n                4816655759203087936,\n                4825471561409238096,\n                4826915875022509872,\n                14050231928991914832,\n                4823638122275032832,\n                14038554271987794368,\n                4819084626709039296,\n                4820472390486184320,\n                14044838543423845792,\n                14047719534458722944,\n                4816085638089357568,\n                14045723399422283968,\n                4824395432876887040,\n                4817922828175261504,\n                4824684725355074528,\n                4809975698137597952,\n                4825779005969581360,\n                4824652933432589568,\n                14043666893341873600,\n                4825612640208968912,\n                14047975420344355920,\n                4786978507628683264,\n                14040769739506090752,\n                14048409043299729488,\n                14044744986252845696,\n                14047344966096101408,\n                4811165537628197760,\n                4822941956264106304,\n                4816057076874422976,\n                14033242976542914048,\n                14049829326051514384,\n                14048051758011764304,\n                14034260906215013376,\n                14050152093276452384,\n                14045160038234589600,\n                14048266368775294928,\n                4816206936817654592,\n                4815101186579795904,\n                4825968563325836848,\n                4824364409306105104,\n                4825636546095512576,\n                14046769672401285904,\n                14031918399171531264,\n                4825550189494056336,\n                4814541607317456960,\n                14033491541048930816,\n                14045690057850890656,\n                4802767042748937216,\n                14048371390733981824,\n                14046825329767057184,\n                4824818656724774976,\n                14033443567766374016,\n                14049598424820232416,\n                14049030248131398944,\n                14046979659025601136,\n                4812934853586468224,\n                14037745419383400000,\n                14047798955405701712,\n                14048412153231304256,\n                4826678622688850352,\n                14049679056020007984,\n                4826803449031923648,\n                14048484583406910928,\n                4814511303219655040,\n                4815222835682892672,\n                14047061295177712032,\n                4823995697094804432,\n                14042463937266084608,\n                14047067789412636224,\n                14044508290484253920,\n                14050203866494847296,\n                14048621081002088288,\n                4821689750421510496,\n                4825366472969600496,\n                14049786833126483360,\n                14021432429700867072,\n                14047400305681501312,\n                14047157483025862688,\n                14035891889080145792,\n                14048451975820597408,\n                4823003925825723840,\n                4822941707106765632,\n                4822066021741098784,\n                14044738465294511136,\n                4816756103666551424,\n                4819850210025292480,\n                14047095445248234768,\n                14049241641059216144,\n                14048398067929671136,\n                14048767550551961056,\n                14047496300270598944,\n                4811909507216142848,\n                4799024801365312512,\n                4826595031267162320,\n                4824390859054002656,\n                14048132904256476288,\n                4818233267543254016,\n                14049006817536756064,\n                14049372407728530272,\n                4815425732848367680,\n                4825892109393936400,\n                4821747396259684096,\n                4819118424667024608,\n                4796462607974899712,\n                14037123605610355072,\n                14048727823331434608,\n                14044917453734940288,\n                14030191905886627840,\n                4809432075117755136,\n                4825131942972153488,\n                4825949344106449872,\n                4806619522554018560,\n                4823615112182119344,\n                14043569243837980064,\n                14038669094821695424,\n                4825237033959089440,\n                14045908771484399584,\n                4823892701164094496,\n                14044134670781049056,\n                14040025907226767552,\n                4805328444848555008,\n                4825933992639767168,\n                14047650787185673904,\n                4818839670387821120,\n                14044121155032277152,\n                14049234577508221456,\n                4816425340173759872,\n                14049865421537271520,\n                4822530421945224160,\n                14042275633722909216,\n                4815269864310197760,\n                4815507000795249536,\n                4819318177621888704,\n                4826366625421524512,\n                4824341714701900800,\n                14049786711066844432,\n                14038838971763903872,\n                14050208519389623696,\n                4825987249978294288,\n                14046310523685566720,\n                14050166585083853856,\n                14044236536628223456,\n                14041566084122202112,\n                14044601176253674752,\n                14045746114518815776,\n                14047825871604318384,\n                14045748509616889600,\n                4824896069042970960,\n                4815681103907160832,\n                14039019360194180608,\n                14043136526094787008,\n                14049522165432313280,\n                14044824767302418464,\n                4820259762042386464,\n                14034391132653060864,\n                4819806861728229056,\n                4815177723391939200,\n                4824821687299382752,\n                14034167427550307712,\n                14027994832328501760,\n                4819742118653682368,\n                4826284060157550496,\n                14049797621315469216,\n                14045514310149370976,\n                4820778765529905504,\n                14049494127544297824,\n                4813861410196148480,\n                4826104822685119136,\n                4817066621055353152,\n                14034373091663632768,\n                4811287658855612544,\n                14049008343322368784,\n                14048243208946989824,\n                14049597113988013040,\n                14043502262025973440,\n                4823878020634670256,\n                4820679423514715584,\n                4823018892214500128,\n                4816831146529527104,\n                14041620601628831104,\n                14042294240788787200,\n                14039695798833516928,\n                14048889493018925584,\n                14044502654623655904,\n                4814334260551099264,\n                14048654833481089376,\n                4815694363615094848,\n                14047421979063561392,\n                4819199469837470880,\n                14044845553357749568,\n                4815758790417902592,\n                4815462067064319040,\n                14045518664255117120,\n                14048522976973641936,\n                4817175035022535680,\n                4810338678673849856,\n                14046542040971371616,\n                4824240308981853584,\n                4816471078617809728,\n                4823724605489689216,\n                14045694238483946144,\n                14046520713912716192,\n                4823500299169456160,\n                4812083763592010496,\n                4823985822057411856,\n                4816634651574984576,\n                4823740590247787808,\n                4824282134247508400,\n                4816062785382170752,\n                4825619746344117184,\n                4823912139976035344,\n                14048675424662902672,\n                14042939885674523424,\n                4821624402847589344,\n                14049007550489459664,\n                14046331685242379104,\n                4822554852884839008,\n                14049747681362846944,\n                4813184206679021312,\n                14047066134311707472,\n                4820820259085746016,\n                4815662347878129920,\n                4820551052513217824,\n                14043124730426127648,\n                4815101220031491264,\n                4819455526624935936,\n                14049898863557837104,\n                4807289677020162816,\n                4805829356415959808,\n                14047965674250709040,\n                14040136117962901824,\n                4815507543518433856,\n                4825623386341106672,\n                4815856688992445120,\n                14038510960212613632,\n                14043680886784916320,\n                14049441336926428016,\n                14042561819160995616,\n                14033765482838049152,\n                14048213742507053664,\n                14042047508359348544,\n                14047645253136802272,\n                4818581100918459136,\n                4822934330491954144,\n                4825598065719643936,\n                14038482410683762944,\n                14048316668686995968,\n                14043947716148251968,\n                4824311298492920976,\n                14048369931211422016,\n                14042847951216838336,\n                4826917181362397344,\n                4821522437948429088,\n                14021150816372140032,\n                4821316945228902368,\n                14049800850834786800,\n                4818877886408567968,\n                4804036933624215552,\n                4813660962439297024,\n                14039061955985228736,\n                14042481528347465728,\n                4815343921417232640,\n                4813033908711305088,\n                4823190010914186592,\n                4813501654668972544,\n                14049764259323347632,\n                4825686801023153440,\n                4824749651623456288,\n                4826366151590533200,\n                14042863130472813952,\n                4817721990984510976,\n                4824173051796002288,\n                14028800575884833280,\n                14024609263881438208,\n                14037220253630006912,\n                14048412866819204320,\n                14042581745818108992,\n                4822689549024319456,\n                4820419339235596160,\n                4824421530321601024,\n                4825859610368592688,\n                14039572945181449536,\n                4820987246690320576,\n                4825344265006339776,\n                4819546325047122432,\n                4825291774233448832,\n                14047242210352665808,\n                14046828194192830960,\n                4820792259458170752,\n                14019627585624745984,\n                14049431601287193440,\n                14035491022620441600,\n                14020769037385361408,\n                14048543181998637088,\n                4813475114576069888,\n                14048550552911199440,\n                14039821272519929792,\n                14047100360468475840,\n                14024219802742226944,\n                4821782981289337792,\n                14045308445804968032,\n                14044906799280268192,\n                14043295173858398688,\n                14031885951784964352,\n                14045478486265331968,\n                4825468511369567984,\n                14046006499878247968,\n                4824878292398498576,\n                4825382953520901808,\n                14039814746421640512,\n                14035990051551264896,\n                4824216047668151856,\n                4821021150233557952,\n                4815175965809316992,\n                4824711755678594208,\n                14042131662160587904,\n                14046790590764246464,\n                14048569552876582624,\n                4821624953849427712,\n                4814043525519353600,\n                14050203280581311344,\n                4823731604342113312,\n                4824911616728419408,\n                4820196491582223680,\n                4810429532919018880,\n                4822190182100799584,\n                4826772259511108048,\n                4803763847718480896,\n                4817631166608410944,\n                4826590278193928272,\n                14043580606556829056,\n                14048824762071397424,\n                14044912323819590688,\n                4825868292679894592,\n                4825154300159856256,\n                14050110175022115824,\n                14047859417880894304,\n                4820026358652404704,\n                4817237118153420160,\n                4819146540813001088,\n                14040394777020196416,\n                4826111566665222832,\n                4817920400597215744,\n                14049512809596988368,\n                4822477386213783456,\n                4822645937828777792,\n                14050064663568410512,\n                4822210632246529472,\n                4824324264052326640,\n                14038518332673861632,\n                14049598044163080432,\n                14035673663585692288,\n                14047689305557722992,\n                14033388469789937792,\n                14039809171386309120,\n                14043949727104152128,\n                4822972836137302304,\n                4810855576822244096,\n                4826539129364821808,\n                4824603841237380032,\n                4821864584250289568,\n                14048632679247674976,\n                14036793094333882624,\n                14047925592039309328,\n                4824653457492522864,\n                4825871936971540048,\n                14048576465561437424,\n                14024610100978245120,\n                4810540742116280320,\n                4823956380359175584,\n                4822707087601131808,\n                4802620402126849536,\n                14046334207775196224,\n                4821174982928947264,\n                4802846403564153344,\n                14049266538475637568,\n                4808850643825442048,\n                14050301257407021936,\n                14040586408748265472,\n                14049830648169289968,\n                4826379937068506960,\n                4818957934909462400,\n                4814622985871031040,\n                4820613361651953344,\n                14046256360993203648,\n                4826805614007695728,\n                14041151319512331072,\n                4823681476165661888,\n                14049859238794401376,\n                14048648296448771008,\n                4821879794722405472,\n                4820719939125484928,\n                14041881127082587008,\n                14042945285866221792,\n                14039500415128635328,\n                4817090972240461760,\n                14044696434556812704,\n                14046422206168833792,\n                4826323303096491440,\n                4825375922828193376,\n                4818840990549136704,\n                4823964574461564896,\n                4814890768699297280,\n                14036611279488544768,\n                4826083103752923728,\n                14042812927173664352,\n                14047413986230291600,\n                4805564067941945088,\n                4817514956410754560,\n                4824975970523952800,\n                14050231891602647232,\n                14049961206181387168,\n                14050212595411043296,\n                14048346110030177360,\n                4824614032947703488,\n                14036986207363709440,\n                14041157670583370560,\n                14049778515500089904,\n                14047105661380568240,\n                14038444686944273216,\n                14047824257011488592,\n                14046777986997232848,\n                14049569146145233312,\n                4822011828346373824,\n                14046419121918514592,\n                14047299613483835792,\n                14048261979949853904,\n                4822114390072989248,\n                14043007440337998400,\n                4820385573103708352,\n                4802755167629208576,\n                14048029743312987840,\n                4824804698925307216,\n                4824517644622516896,\n                4804312500609511936,\n                14044804324760050816,\n                14050299319780785728,\n                4818812611163396160,\n                4818914735497844896,\n                14037923899594549952,\n                4806914803854025728,\n                4823855671493782080,\n                4824938766814820240,\n                14045047802481543776,\n                4823710904618536656,\n                4801151897131472896,\n                4810471032896192640,\n                14042919441463922272,\n                4824645279463541616,\n                14048545031687348672,\n                4821442781824600160,\n                14039726724744515904,\n                4820640678625198560,\n                14042575444748416480,\n                4823878546802610352,\n                14044068862098677088,\n                14034354528286481792,\n                14047476926720607920,\n                14032178582844491008,\n                14047930339899884480,\n                14047509864096854752,\n                4826678430448873088,\n                4822516940025661856,\n                14049453956792296128,\n                14049838119601362976,\n                4826481272856355680,\n                4826318640303867536,\n                4825506368441949616,\n                4825022007861316832,\n                4820921832299512672,\n                14045818337179549152,\n                4818098033005847040,\n                14036432480280821376,\n                14050171878416033632,\n                14050125404423452240,\n                4811625315005181056,\n                4824386137318990272,\n                14045173072756503840,\n                14031906694195139584,\n                4825700730707832592,\n                4814924687069149568,\n                4816802454571175488,\n                4821160121534093280,\n                4822511029048724928,\n                4825409474142888656,\n                4825473252844903200,\n                14047292370171146368,\n                14037665394332372992,\n                14043948280129620896,\n                4819258095941803392,\n                14045074045605102752,\n                4816794549039724288,\n                14043829607258225216,\n                14048471408774628816,\n                4826652500105106112,\n                4826354426784644208,\n                14040110278804448960,\n                4824639931259022176,\n                14037315726303117952,\n                14050048266696721680,\n                4819851025585314816,\n                14046009066308168608,\n                4823434993616185376,\n                4825753558535047104,\n                4822327051868229792,\n                4802970576429953536,\n                14047026830261247296,\n                14049189304802691520,\n                14049093584275153904,\n                4819902555315921824,\n                4826456219583485024,\n                14049409329959976112,\n                14046086467962991872,\n                4797803988727835648,\n                14047427519949842544,\n                14048639211188112624,\n                14045266517437051616,\n                14042731419909285728,\n                4816663150541298816,\n                4822777613850569344,\n                4826698796270417712,\n                14048133399859796896,\n                4816414454972982144,\n                14031211772545969920,\n                14036930816947345920,\n                14048850140412403200,\n                14042547861214274400,\n                4815720106637119872,\n                4824280276900405488,\n                14050145557281474448,\n                4824367741353982032,\n                4818762423935229696,\n                4806825133483597824,\n                14038868528432410240,\n                4817906767256899520,\n                14046328665710018912,\n                14035459749581470976,\n                4826466041866350480,\n                4822385112634071040,\n                14030560733044676864,\n                4823871054553724064,\n                4816085873843739200,\n                14037983327044601856,\n                14048177183659682464,\n                14048614095689390784,\n                4825442662302350640,\n                14040483019737266944,\n                4822963667763986144,\n                14034731786143349248,\n                4824912513434329856,\n                14042254108134298976,\n                14048311090745317472,\n                4813240083022987264,\n                4826575419615642368,\n                14049446992884145280,\n                14050101263253739568,\n                14044393036622020864,\n                14038583217634284864,\n                14048213535983753808,\n                4823729731080926256,\n                4814400493933272000,\n                14047660495382054880,\n                14035377540454069504,\n                4809650856007455488,\n                4817123923399032640,\n                4821535002754424736,\n                4826690193755012320,\n                4814507285350845888,\n                14050331062732985824,\n                4826546141758795952,\n                4826793168025620320,\n                14049897789369177344,\n                4824986586630702592,\n                14039826350773989696,\n                14041597744631778496,\n                4820687216782492704,\n                4826174412867434064,\n                4822124395090062432,\n                14039110365246141504,\n                4826809959601279312,\n                4824398176685925536,\n                4824180217737185504,\n                14036616628866637440,\n                14044234317904744960,\n                4819022025410504640,\n                4820390089579366720,\n                4818759743132623552,\n                14047881189077442368,\n                14047324877210731840,\n                4815665847331630528,\n                4824071446394561808,\n                4823931062690657200,\n                14047779299900247696,\n                14043538470067181056,\n                14046658134796199136,\n                4826505722051825136,\n                14043893067006883552,\n                14047168985010279008,\n                4823266219662441824,\n                4824964677937329472,\n                4816413032973682496,\n                14042801962553008192,\n                4812909484450620416,\n                14030721988088970496,\n                4806186986602184448,\n                14047427347158047056,\n                4819331045524401792,\n                4826948408941322176,\n                4824100628303842912,\n                4826937203088584752,\n                14041859089079198336,\n                14043403242206972320,\n                4822499151623263680,\n                14045278435963308480,\n                14042743180850591136,\n                4817457096824119296,\n                14031655228992721920,\n                14039065715210283136,\n                14045263630049835520,\n                4815316882086869760,\n                4822325555224290016,\n                4819292073990938592,\n                14046012602259221856,\n                14040348696823431168,\n                4812703759350432384,\n                14047284798945988720,\n                4813318780878870144,\n                4819927281196159360,\n                14045166110170720864,\n                4807315067395886336,\n                4824415473787439376,\n                4821477474301857600,\n                14046062684528029600,\n                14045792485273857984,\n                4824820070469760400,\n                14050008418968197360,\n                4814431323810466816,\n                14037242051725248640,\n                14039792178429578368,\n                14046534595444825344,\n                14050327269550633424,\n                14038710286172470976,\n                4816689841131331584,\n                14045582315906886464,\n                4805689689836821504,\n                14039895835775547328,\n                4825430874036856624,\n                4811105933231247232,\n                4810304558110137984,\n                4824219036519864976,\n                14042871459590589792,\n                4812295649960950272,\n                14046398301748287072,\n                14046729200965126752,\n                14045086009291187264,\n                4814592710686625984,\n                4826499199371484496,\n                14042456195845784192,\n                14043782362564128320,\n                14046538000328054592,\n                14044957119342174400,\n                14038747155968993536,\n                14038089157257823552,\n                4822192525314914560,\n                14038173977685434048,\n                4825908726109267280,\n                4818955311322269248,\n                14049177326111980144,\n                4811641936083464576,\n                4820403222966988960,\n                4823429509854849936,\n                14046506076265233408,\n                4809647396425148160,\n                14047396951276662496,\n                4825721596193774000,\n                4825271106397595824,\n                14045185689561125536,\n                14032131274278046464,\n                14034259451901156864,\n                14049410332045906096,\n                4815458437517500800,\n                4826216665503370176,\n                4826057797324400272,\n                14044742488404534240,\n                14045881049265113120,\n                14046714628993528544,\n                4820739042443125248,\n                14031124069933872896,\n                4819091616929653408,\n                14045802672477544640,\n                14042565149325177248,\n                4815853371272416768,\n                14036472405094239232,\n                14047595727699691520,\n                4815583161355561024,\n                4824668870202229280,\n                14049576532217676288,\n                4819584553504868288,\n                14049832133891394048,\n                14046744458085234832,\n                4826959249228020144,\n                4826419644405293504,\n                4824790826334228048,\n                4826741738923454336,\n                14047770551390614992,\n                4817928088000460544,\n                4820417684139858464,\n                4826779216732479488,\n                14048610546891668128,\n                4826658347749369424,\n                14045703293186572448,\n                4823800417434260752,\n                14038359543956871296,\n                14049399791614362000,\n                14045161464364385600,\n                14044283900328685440,\n                4821098404986123488,\n                4821591689417088256,\n                14049310532663755584,\n                4826550543477429872,\n                14039268201603397056,\n                14046035221918146784,\n                14047109469419852432,\n                14039921568895164608,\n                14043114517720362016,\n                14048104634279366112,\n                4826721395303155680,\n                4815748957255838272,\n                14045561875698613280,\n                14039865165698559104,\n                14040499865021454016,\n                4823540176588596608,\n                14042958006809962304,\n                14043784542557953248,\n                14033626412027598720,\n                14049083773360983952,\n                4823925773472677552,\n                14047599591385616288,\n                4819818191127520032,\n                4821005279758539104,\n                4821729544138992672,\n                4826806165639067136,\n                4824191090524116368,\n                4809889998738795008,\n                14044903948787625440,\n                14032314074474503936,\n                14045082214915465344,\n                14046874855807370336,\n                4819130127576333696,\n                4815314312382352576,\n                4824827397931913968,\n                4820006662479595776,\n                14043343613480873024,\n                4813709130292190592,\n                14041186794177400448,\n                14047225905084627488,\n                14040160034003550848,\n                4819345984403310016,\n                14046940334722481072,\n                14037147952713442048,\n                14049248859633135584,\n                14049592861044562176,\n                14046948466181513808,\n                14034485791480281600,\n                14043828365458618240,\n                4823653520617894016,\n                4815977720741612288,\n                14049472440275706752,\n                14016927522388590592,\n                14048143890579627312,\n                14043531116254385280,\n                14036741312203048320,\n                14049340686131019440,\n                14048298100268450752,\n                4822524323174652768,\n                14049623756928336576,\n                4825353722969032112,\n                4826238407930097936,\n                4810134574992762496,\n                14025008228204036608,\n                14045344398672473952,\n                4801239008936496128,\n                14039424172869117888,\n                4823050422979333056,\n                4809333033203437312,\n                4825977946368591760,\n                4817647886340551872,\n                14042526567082607136,\n                14044071085684323584,\n                4819942239172214784,\n                14047988716290887280,\n                4813665758315836928,\n                4822473289705901856,\n                14036590519625924096,\n                4821475674926317056,\n                4812275257145741952,\n                14046940670853183936,\n                14041056289975149888,\n                4820979076768268320,\n                4821277445435551072,\n                14038212966596109696,\n                14043670554936683712,\n                4824843372559980432,\n                14047851622576791600,\n                14042554910194468224,\n                4826426587794629072,\n                14045471588977557632,\n                4819809082358957824,\n                4823537787401180944,\n                14048787871363009440,\n                14043485195716361440,\n                14050169507038767408,\n                14015563508529203200,\n                4810907430930699904,\n                4817690189083001984,\n                14043731529721203040,\n                4813740448502300288,\n                14045504917971409184,\n                4823724864256285120,\n                4819702667795472064,\n                4819113474981210208,\n                14041470889409578624,\n                14046061472608016320,\n                4826180033562468080,\n                4808695882335891712,\n                14045607038789187136,\n                4820833771722894880,\n                4824624489003467392,\n                14047464721468051072,\n                4825756304856139184,\n                14035361360545765888,\n                4820320048909808224,\n                4814903707711663744,\n                14043641807356974400,\n                14047596103714766608,\n                14048308796984851952,\n                4823599795472242000,\n                4825802073788910032,\n                14047912793425508880,\n                14040285522013028864,\n                14041830881993127040,\n                4824183292120291152,\n                4823573551243175008,\n                4826205950630512080,\n                4826110827002683824,\n                4821242033139421856,\n                14046595489967649024,\n                14046739193208183968,\n                14047643596190989248,\n                14044291972541684064,\n                4825907996605884912,\n                4824142005641012096,\n                4823946050461684416,\n                14043158685662281984,\n                14047774044448959104,\n                14049388812257621824,\n                4819419990613361440,\n                4822764514783642912,\n                4819657173591701696,\n                4819217837594722176,\n                14040460477505672000,\n                4823973258504315664,\n                14043374741689165664,\n                4821282242964747776,\n                4823799306074397616,\n                14046936828426049680,\n                4821870868572990208,\n                14050181882516785232,\n                14047714736943783520,\n                4801189891334238720,\n                4823669923153445056,\n                14038779706521375552,\n                14011724012760666112,\n                14043133033429311456,\n                4825448895436383520,\n                14030681777952812032,\n                14046303604562837696,\n                4823674596948371952,\n                4818477128188028288,\n                14043554174717082496,\n                4826719173625740080,\n                14048868851668976752,\n                14046067626884145056,\n                4815744371828726720,\n                14039482495414675968,\n                14043611891754084672,\n                4825280466981079408,\n                4825325697870563424,\n                4797889082578248704,\n                14029968121472800768,\n                14037877367918907968,\n                4826344598558717008,\n                4826287233065469232,\n                4821517119455963744,\n                14042700711639103328,\n                14043224446664263936,\n                14040023591716085952,\n                4819638586368484736,\n                14046773166104972912,\n                14036557916447469184,\n                14048580532509234256,\n                14048782163996708864,\n                4825866189477949680,\n                4806479525456668928,\n                4824639020910807056,\n                4824727552510192064,\n                14037090994808603904,\n                14046193470301857504,\n                4825362055723210880,\n                4813839296816154112,\n                4810757570570752256,\n                14045944309298065344,\n                14050123291995155120,\n                14048087995480347632,\n                14039194283985143616,\n                14036456245704149248,\n                14049568704188914112,\n                4826890451140417472,\n                14049137183358473552,\n                4824009969348381936,\n                4824658336934616096,\n                4825014840655641232,\n                14038446790400409024,\n                14048292818172862864,\n                14049483891062560016,\n                14048881951936602816,\n                4825439233560778032,\n                14045741073164180032,\n                4823508094722707584,\n                4818939132062635904,\n                4801839018533815808,\n                14050158950402119872,\n                14037852181763395328,\n                14044975830208267744,\n                4799562953612472320,\n                14032198474991196416,\n                14048769762474074432,\n                4825925540746191152,\n                14043826615226574240,\n                14037788219577848192,\n                4821679672579468960,\n                4823412204567093584,\n                14042844801014694144,\n                4824908230413536080,\n                4821237909489727040,\n                4823741029165099792,\n                4820451874095959040,\n                14046994755965290032,\n                14042882028746882912,\n                14048599596335834800,\n                4820848393900347296,\n                14033683658742444544,\n                14048119267795480960,\n                4825626937940377104,\n                14033247092982311808,\n                14045094672442789024,\n                4825424570497252272,\n                4822625571632936096,\n                14049846876382433872,\n                4819756326969954368,\n                14048589339926688272,\n                4824733792226706368,\n                4817435680015633216,\n                14034068072994805120,\n                4813425517930099200,\n                4825467456567002672,\n                14029417442193019648,\n                14036127128759831424,\n                14038222524000804608,\n                14037954555900257536,\n                4824678865942379808,\n                14038162264942015552,\n                14047059466415571344,\n                4808507988300786176,\n                14047379236945366720,\n                4824811852524353984,\n                4825962833071723072,\n                14043780554457397696,\n                4822089103969874656,\n                4825553895462155408,\n                14047847253606307264,\n                4813198280742542976,\n                4806281969197665024,\n                14050047802891852176,\n                14050044672452234528,\n                14048685310196268192,\n                14041845629847243648,\n                14042909401919375040,\n                14047009485653365264,\n                4811930836955190656,\n                14036232868650257024,\n                4820312497040000256,\n                14046845953074549168,\n                14039037345199055488,\n                4826948064122195376,\n                4819352333468647040,\n                4825532842426705056,\n                4814740447995174912,\n                4823135385403874304,\n                14048861480097149504,\n                14037685768899205760,\n                14046792983934469728,\n                4825251501912806304,\n                14049949959941555008,\n                14047015735900433344,\n                14047775801851290240,\n                4823769351458372208,\n                4821734858053597312,\n                4824112191616721760,\n                14049644203490906256,\n                14044659766388767808,\n                14040285202816623936,\n                14039555910774034496,\n                4795269880864606208,\n                14047782673931289248,\n                14034299402360590080,\n                14040734064196177856,\n                4818127639049477568,\n                14029571732868275456,\n                14043957490970947680,\n                4814268799672511360,\n                14039802785517223360,\n                4811316200358008704,\n                4804697987078153728,\n                14048574842010763216,\n                14038428763584605760,\n                14048410284206602032,\n                4803652145280393216,\n                4812070588564075520,\n                4826819746102603808,\n                4824782154337212160,\n                14046915438265674896,\n                14050110971093036128,\n                14047977440341485056,\n                4826007721019444528,\n                4821288512102514944,\n                4824966357532074928,\n                4799554366440880128,\n                4817087393414771968,\n                4825910302229906000,\n                14047364116365411488,\n                4825931848481007712,\n                4820196379780346592,\n                14040837484181335104,\n                14045249196849348896,\n                14031550817935136768,\n                14033830564203800960,\n                4821581662032552512,\n                14046522807449830432,\n                14041071366655870976,\n                4824494867117277312,\n                4825964145785616336,\n                14040627439725476864,\n                4825150616996436560,\n                14036811163683064576,\n                4819742155660645216,\n                14049560784928292000,\n                14046142716521787392,\n                14049165830367134864,\n                4804268100711416320,\n                14049029777049091744,\n                14048061304451135600,\n                14045977088088006208,\n                14049354119559599840,\n                14048700462223856352,\n                4819328453895107232,\n                4810016650773992448,\n                14042076993880854528,\n                4822666318759786848,\n                4824157062810021920,\n                4818074328918507328,\n                14044136367018160864,\n                14048102642163619664,\n                14049364593594341632,\n                4824384636622035248,\n                4825525204670665920,\n                14048571388829208160,\n                4825630694036067680,\n                4781602868934770688,\n                4816705570011381120,\n                14039487888907608000,\n                4823824959782903616,\n                14046378137120881248,\n                4826287749556244864,\n                14020249323286068224,\n                4825343030790815568,\n                4812977226661632128,\n                14048313768339534192,\n                4825763233476029456,\n                4798567689904268288,\n                4825926956838313264,\n                4825557832701644064,\n                14034486574935069952,\n                4825875637790215840,\n                4802967726807395840,\n                14044236065860212832,\n                14049296903521964912,\n                4819661500929950912,\n                14047034740043047664,\n                14033582588293634688,\n                14049279682039536096,\n                14035314929688738176,\n                4808924784577974016,\n                4824127989476453872,\n                4821108251331829280,\n                4824086529359302560,\n                4823874788038901968,\n                4815779500299794432,\n                14047859315038723088,\n                4826694264288990512,\n                4826508450846926400,\n                14050081463863713744,\n                4819596585376210912,\n                4826588269179974256,\n                14042134436867156224,\n                14028721364846511104,\n                4822494940425982336,\n                4819016011950519008,\n                4808065936599183360,\n                4821088347734886016,\n                14046837107321043024,\n                14049488663081340112,\n                14049770814093768800,\n                14043856530070793376,\n                14047418558191558000,\n                4825731355264696368,\n                14037330966336571264,\n                14047339261970925648,\n                14044508102413389408,\n                14047377461334258336,\n                14048866529485113552,\n                4822735036807800832,\n                14047825754760376384,\n                4825100869502078240,\n                14021632233654950912,\n                4811711937731716992,\n                4823519138679137088,\n                14050260469037443536,\n                14048050032868952064,\n                14038453007250838016,\n                14049969897280517680,\n                14045028052625692000,\n                4826925310446028640,\n                4820593196368871488,\n                14038400997552674496,\n                4816834426523102400,\n                4821101677950620352,\n                4817380245898972544,\n                14043719992269401632,\n                4819613368858676992,\n                4825739745506537440,\n                14047034600635341008,\n                4791185688169639936,\n                4823567157551617472,\n                4825405059998762496,\n                4808683623717294336,\n                4826819031055544832,\n                14044400931839100512,\n                4812269819130522496,\n                14049619972031732336,\n                14046060365758934880,\n                14048829357910777488,\n                14039942286399539712,\n                14049217736751488032,\n                4825019749012772960,\n                14046481301877367712,\n                4809755820681807360,\n                14034931753381590144,\n                4820623931121564736,\n                4824977818136784320,\n                14043903134420377632,\n                4814610827820452160,\n                4812024989837711360,\n                14044842678283248480,\n                14049710692705613904,\n                4811623510677114240,\n                4820858475068412800,\n                4818652668250115008,\n                4825467603666672128,\n                14049296665541506048,\n                14040843436138507136,\n                14039794059207799936,\n                14049447146463822816,\n                4820382369956742112,\n                4820629838718541120,\n                14046206083871117696,\n                4821310291094453600,\n                4820392991419503392,\n                14048942569461123408,\n                14016876797060233216,\n                14048651390415477456,\n                14039274293743808384,\n                14011226921604186112,\n                4805022918510459904,\n                14049444451553260256,\n                4826271924849156928,\n                4819558993038724384,\n                4825612176276985296,\n                4817172745039958976,\n                14031710083534521088,\n                4825215892169349760,\n                14048589175132542160,\n                14045609652487719808,\n                4820294449069408544,\n                14043945640553982848,\n                4815814847435082240,\n                4821053469099567648,\n                14041209371022388480,\n                4822246834760564256,\n                14049131127272228128,\n                4806580903063107328,\n                4823675747324566080,\n                4825754762546058944,\n                14041389070809651456,\n                4814151173954179584,\n                14046311006627619872,\n                4824742871550435952,\n                14043403762418688032,\n                4817442215958204608,\n                14048452020987022256,\n                14048083251126236112,\n                14047789106465549472,\n                4825118519925331968,\n                14045985869796732480,\n                4806338785680196096,\n                14049860396272606448,\n                4824992526356272960,\n                4810300319471518976,\n                4811846211442415872,\n                4824922953257709200,\n                14045493501841980864,\n                14039844980945745344,\n                14041996272697490816,\n                4821801317070200352,\n                14049371652385225328,\n                4819481722947731232,\n                4825913950314967024,\n                4804157024224937472,\n                14037166276036356480,\n                14036290982871222400,\n                4825743400327333440,\n                14048852253472926112,\n                4821440144854897984,\n                14033754280946242944,\n                4816627956302891328,\n                14038608876587441152,\n                14049934931933749632,\n                4826332914797029792,\n                4820454979232198528,\n                14040391891247570880,\n                14045036698586386720,\n                14045981682928912640,\n                14049732951170840832,\n                4825341256578527808,\n                14047079871842308080,\n                4820372931725386720,\n                4819996848224670176,\n                4824878349717131328,\n                14042907893200628448,\n                14042325612592508256,\n                14049780534290595072,\n                4825569995644470336,\n                14028251182685343232,\n                4820739364643074400,\n                14030008662815248896,\n                4802921735795429888,\n                14042695433088040928,\n                14047336377220835936,\n                14047344489686119776,\n                4822589092573212128,\n                4818857219782288960,\n                14047754867792374656,\n                14047050134487578768,\n                4825780315750226624,\n                4817413901576596864,\n                14047256223096132576,\n                14048539161216325744,\n                14039105851251281408,\n                4826762629996954736,\n                14049214055512534144,\n                4821732831230411680,\n                14047912734441563248,\n                14047729054116542864,\n                14029575474804608512,\n                14046160937765504096,\n                4813033628318880384,\n                14049205924693891648,\n                14049054588582980672,\n                14039702812641552256,\n                14038881886775874752,\n                14047122305293384496,\n                4824307385378216704,\n                14036971194039520384,\n                14041166166604219584,\n                4821294545064671200,\n                4821235713695939968,\n                4821584140063203712,\n                14050041792424639904,\n                14046726149986308928,\n                14049650439069122176,\n                14040926824655945984,\n                14049670756987411152,\n                14049094159229408368,\n                14045991127544591680,\n                14050072842447325440,\n                4823303132068986880,\n                4814824043338737664,\n                14047706742967928160,\n                4819712948692548960,\n                4824068427540981664,\n                14045927148042741312,\n                14037638282930654592,\n                4819290210038685312,\n                14047515600221722704,\n                14048498828390954448,\n                4818865422356400352,\n                14021816576989010944,\n                4825236157255052880,\n                14036407210164043776,\n                4824163677193185648,\n                4822605170417242080,\n                4805944635898422016,\n                14045438646090817408,\n                4826259382309007680,\n                14048998173569764288,\n                4825989353064943248,\n                4826403958670544784,\n                4822452853008918688,\n                14037337428208347136,\n                14044013034419674592,\n                14043136324289841792,\n                4821540350940488224,\n                14031918041872049664,\n                4816168519761424320,\n                4814404645281789312,\n                14048635715316806784,\n                4826702309336811328,\n                4822333786360623776,\n                14040833841760326528,\n                4820541293564453696,\n                14047530675431387280,\n                4814272839122453120,\n                4822624134567601536,\n                4803362015905946112,\n                14041787737373813376,\n                4826533385285333104,\n                4825524782678921120,\n                4815620834722150144,\n                4825199305415704128,\n                14049012846271227504,\n                4817164476807641920,\n                14044957405400082784,\n                14047309613699346336,\n                14044054326412418144,\n                4817570512876238720,\n                14044253700519634048,\n                4824381525990644704,\n                4798086108912438272,\n                4819867128032419680,\n                14042250538756632608,\n                4824901122443871072,\n                4814490478832659136,\n                14049540765266276032,\n                14041179593912429184,\n                14042313229836733472,\n                14047211594023816256,\n                14050213186065067504,\n                14044286070512332096,\n                14035691182974036480,\n                4825284505319701104,\n                14044085722086261408,\n                14043597567539006560,\n                4817403911024083904,\n                4820284432111798336,\n                14043329331356165024,\n                4816644506959309120,\n                14038349973868458880,\n                14038109515839231680,\n                14029706865694825472,\n                4816142263581370048,\n                4823461323901894624,\n                4817851841953979328,\n                14045302135694605824,\n                14034541951408060544,\n                4822868116947773120,\n                14046932086423087984,\n                14044042994029073728,\n                14050232477255837520,\n                4824132224690131760,\n                4810307163224214400,\n                4825991895482074992,\n                4810613745463803264,\n                14042372932696761120,\n                14046754476403833216,\n                14041544320346888768,\n                14049954068094901760,\n                14034920533801847808,\n                4822730554387418848,\n                14046005213975127584,\n                14041988650538038720,\n                4820754630688166656,\n                4822078668495877440,\n                14046813384168253808,\n                14027568759679188992,\n                4815292706762136448,\n                14039472939035111232,\n                4824873505574911952,\n                4825851644463274000,\n                14050183574814181344,\n                4821450232022766048,\n                14047763178436700624,\n                4823406727004291728,\n                14035947178632160384,\n                4825060952979661792,\n                4818172395009685760,\n                14044890897904312960,\n                14039828885739508288,\n                4801625667033952768,\n                4809707871339315200,\n                14047037091871758576,\n                14049724886169234352,\n                14045857263744979264,\n                14046568553060396160,\n                14047482683942887824,\n                4823533464616027008,\n                14048608119480333440,\n                14039688484120061760,\n                14044675344318986592,\n                4825834429329575264,\n                4824686440876648272,\n                14025076799742054400,\n                4822753550810898176,\n                4821810185452530240,\n                4823615469977353872,\n                4824409015872223216,\n                14043936778888232512,\n                14043444080472609728,\n                14041108678828827712,\n                14048197215196928432,\n                14047205196063837360,\n                14047021970143933168,\n                4821920784109661600,\n                14049281981729604256,\n                14038437896084173824,\n                4825822516895912000,\n                14048774195667936544,\n                4821856141862019360,\n                4820114299063921792,\n                4824003949400487408,\n                14048825701361332496,\n                4818996249356312800,\n                4807468211705052672,\n                4822969887678456480,\n                14049004818151757120,\n                4825243034325856896,\n                4806110113346621184,\n                14046847826494862720,\n                14050259454522843088,\n                4821492900901991840,\n                4818587239210906496,\n                4818477893547100352,\n                14043421070573427616,\n                4826813199526290160,\n                4819536773944629312,\n                14043172806022311648,\n                4823546528938830160,\n                4812513254292338304,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n        SerializedFFTContext {\n            p: 4830304114401345544,\n            pinv: 4383336415042637786,\n            mod_data: ModData {\n                n: 868614185943041,\n                ninv: 5463972295250649786,\n                norm: 14,\n            },\n            primitive_root: 3,\n            w2tab_depth: 12,\n            w2tab_backing: [\n                4607182418800017408,\n                14043228097021372032,\n                14042817191572437888,\n                4819605159994420960,\n                14047581432524294064,\n                14039677153516493120,\n                14021517279837736960,\n                4825573147916255904,\n                14046786866629089872,\n                4816556504985579904,\n                14045007839975801248,\n                4823493081183302560,\n                4823374360624130144,\n                14049115856735280752,\n                4814783368078661824,\n                14045776367532642240,\n                4813211216664688640,\n                14046748403814652160,\n                14048094306135921008,\n                4816074495325307968,\n                14025445256807130112,\n                4822275123098533952,\n                4822868403043080448,\n                4825057915767726816,\n                4824538351066130512,\n                14043575823342944992,\n                4819890865056798624,\n                4809740873623140352,\n                4824063588250253728,\n                4825643869443244592,\n                14032476193136987136,\n                4819041622153057952,\n                4823616243278662176,\n                4816789000370097408,\n                14045168516972838368,\n                4824936663882930448,\n                4804025334237775872,\n                4824592636802917712,\n                4821173042409316736,\n                14042455943764399904,\n                4824842605659959680,\n                14044205851848637536,\n                4823238844129275008,\n                14040622713825906048,\n                14045683995220758720,\n                14047016110888916192,\n                4820629377494216416,\n                14029496107202945536,\n                4818946574080300160,\n                4825164588638135296,\n                4807959773326895616,\n                4806684889484666880,\n                14044015744520577696,\n                14045043195219040512,\n                14037661998141788800,\n                14048280430169695664,\n                4818794394705152512,\n                4823710638713947296,\n                4815006634046066688,\n                4823556240445652400,\n                4801268250072522752,\n                4821934618660915520,\n                14040665625652734784,\n                14045782609231479744,\n                14048153043798963424,\n                14043913606556118208,\n                14045467300185766208,\n                14043491892675332384,\n                4815197558347393920,\n                4823846501176797312,\n                4814629072152215872,\n                14042741063698376800,\n                4817701856292165952,\n                14044266561572250784,\n                14039905706471689984,\n                4818416290211374592,\n                14046433847459287552,\n                4811752856996228480,\n                14043016220096694912,\n                14048030876028483648,\n                4822271558355174080,\n                4824998052596069552,\n                14046734170965334592,\n                4825204217636478800,\n                14020170227317134336,\n                14048158682205633344,\n                14048851174006661152,\n                14047486398249945088,\n                4823541227391590320,\n                4819293698107807648,\n                4819813913348754496,\n                4822633609117653856,\n                14046334987985762496,\n                14031010408771188992,\n                14030348505737732352,\n                4823056625361965216,\n                4823852187578458432,\n                14047649528334422384,\n                14039795666187369920,\n                4825317899076089200,\n                4824648989411968688,\n                4812366575593819392,\n                14039306853856624448,\n                14049038433022781488,\n                4820117641493807648,\n                4824724090423447680,\n                14047953256333565552,\n                14045813264857351904,\n                4825770006041219312,\n                4825716442757008160,\n                14041182826615153216,\n                4818543307551362176,\n                4812153361844840448,\n                14048304395677791632,\n                4823389970041179648,\n                14044605781322472896,\n                4824311899833575120,\n                14045021054794832480,\n                14048485350653332448,\n                4824248837739626208,\n                4823956668219443744,\n                4806453406743994112,\n                14042561300008624960,\n                4807478167973515264,\n                14039233389488045632,\n                4824023082963240960,\n                4824356469014786384,\n                14040455366948864064,\n                4811146009991142400,\n                14048492574812532144,\n                14044248268865570272,\n                4818762803725290496,\n                14047578387515440864,\n                14046743480560656320,\n                14048937241972521648,\n                4809601641300267520,\n                14039857620376310208,\n                4810889622697800448,\n                4823032225851786848,\n                4807771494236538880,\n                4817151130329423360,\n                14039494299158070912,\n                4821014657694789088,\n                4819372361948962240,\n                14034567216733372416,\n                4823696913086053200,\n                14044751232279002848,\n                14023125857922617344,\n                14048595210380632080,\n                4808325146790618880,\n                14045819608409311680,\n                4816873565206425216,\n                14043977785984785440,\n                14047532055007916272,\n                14048573190700393872,\n                4819831787784499520,\n                4821336011224334592,\n                14047400630617533888,\n                14048140469986330928,\n                4823887202767065424,\n                14046789542532691216,\n                4821211000139485632,\n                14042511090656306400,\n                14044463033323023872,\n                14035697884481155328,\n                4815537213924490368,\n                4817883194768016640,\n                4817291324728961600,\n                14045375626186159904,\n                14039322302281897216,\n                14042597358834456224,\n                14048581247628822832,\n                14042468013007756192,\n                14047530682838137584,\n                4822749486898855136,\n                14036942136986220928,\n                4818872741954901568,\n                14039558937777904448,\n                14047246767204121344,\n                14048353810966509456,\n                14044278130680061952,\n                14047082403861123088,\n                4823879166754666080,\n                14048830676703197936,\n                4824467442917944976,\n                4818252656652572672,\n                14047490588578878576,\n                4825397574725751152,\n                4801587996619713024,\n                14040301569897250688,\n                14045464350015452192,\n                4822493008984130720,\n                14048257471581994576,\n                14043386344636854048,\n                4819684406345089440,\n                4825421962233155376,\n                14044853963976721792,\n                14048418775057315296,\n                4796356120043623424,\n                4818928717414739136,\n                14041846000285873664,\n                4825443561341982240,\n                14048125546774998560,\n                4823399690524872896,\n                14048423220730846976,\n                14044449649622759392,\n                14048815104229701616,\n                14039817011373274944,\n                14046136611741309600,\n                14048456080134091872,\n                14044902860034504352,\n                4825657928293665296,\n                4811544117288883456,\n                14042002652392637184,\n                4820184220383988032,\n                14037488626801430784,\n                14040692634491958592,\n                4824966814558508048,\n                14017294735675809792,\n                4817025807106292352,\n                4822350897607845696,\n                4821416249275903584,\n                4816988467499206144,\n                4816591084442674112,\n                4824915733173046192,\n                4824345130832153824,\n                14039472746644277824,\n                14047703966491578752,\n                4808735245956530176,\n                14048048521386073408,\n                4822616820716423328,\n                4823711842643187824,\n                4823680176880773600,\n                4823969249593708336,\n                4785975436417843200,\n                4822052261069128544,\n                14044032827683610912,\n                4821123266422297152,\n                4819573562239676992,\n                14045300722060315936,\n                14037932071484928000,\n                14047150856875119600,\n                14017796322560208896,\n                14048886515267072768,\n                4823937141761900880,\n                4816525263002487232,\n                4821560040537881312,\n                14043049127940811008,\n                14045109143434532224,\n                4823254216694120000,\n                14039481553174771968,\n                14040290700967531712,\n                4822566376907020800,\n                4822695861706298912,\n                14046952990065715280,\n                4824513378017517168,\n                4824823435977420960,\n                4818951160076784256,\n                14042295278648503968,\n                4825190818327628432,\n                14042287724691899456,\n                4825496108321101056,\n                14047102573233849856,\n                14047868361374624688,\n                14045170022524073504,\n                14047837248355976288,\n                14043496329717280160,\n                4820043614202620544,\n                14044277656781778240,\n                4825274243410493920,\n                14048717589150544544,\n                14038410788865076736,\n                14035816807981539968,\n                14046795909796069280,\n                14018170533872201728,\n                14045544571148311296,\n                14048362076129690528,\n                14042230008467320448,\n                4824254051598430384,\n                4824749629501762048,\n                14043224935777164192,\n                4821818949915751424,\n                14036157627346449152,\n                14047502583610411760,\n                4818694112881786752,\n                14048710150381433600,\n                4824556054338182736,\n                14047056328729011936,\n                14028224915517056512,\n                4824798578828433680,\n                14045824593035869376,\n                14038485642051598784,\n                4803438157391490048,\n                14047521899047352176,\n                4809565254022689536,\n                4809462367543568384,\n                14047083115694135440,\n                4812469832573374720,\n                14047835160068902704,\n                4818774500081596992,\n                14045373419636137728,\n                14046823325959267088,\n                4825440105679591968,\n                4821405120788440096,\n                14048912332811238736,\n                14040587886319056128,\n                4821951430529851808,\n                4820723733550290944,\n                14048955995979799152,\n                4819410070494934848,\n                4817705066446278720,\n                4823932032405782320,\n                14047336587541093152,\n                14044323616133786432,\n                14040655733887880128,\n                4823412699245564992,\n                14042443200543240192,\n                14046635720139267328,\n                4809345389930984192,\n                4816936625687693440,\n                4815644120315787136,\n                14040009288647017088,\n                4823331664349444224,\n                14042906320792794656,\n                14038407256768144896,\n                14044605720100835264,\n                14046068016489800192,\n                14041957149422180992,\n                14047924659096534528,\n                14044262261262093440,\n                14012689275923214336,\n                4815948114216399424,\n                14035209197836205568,\n                14044737985059552224,\n                4824128229217487888,\n                4823374042255367008,\n                4821548916339568544,\n                14035688220421668864,\n                4821590559915433184,\n                4818567241480520512,\n                4819805682681621600,\n                4818345885301512384,\n                4824341147448967168,\n                4823405898452287600,\n                14029487420349151488,\n                14040093542562044992,\n                14047015892723834144,\n                4814686549252682880,\n                14047362048569403008,\n                4815317326327131968,\n                4824165113650089680,\n                4824434014823559808,\n                4811194322361416448,\n                4824980264473546320,\n                14048344334685303808,\n                14020802325539778560,\n                14042152634613383680,\n                4825758940138348240,\n                4817526706204524544,\n                4821186510476286976,\n                14038404272613930368,\n                14038004583880895424,\n                14048454621355116064,\n                14047367841231139680,\n                14046806755773781024,\n                14048138183264354176,\n                14048589155742149376,\n                14047429612013606432,\n                14029157834045246208,\n                14048766466314769104,\n                4823631879534589840,\n                4815999987879628992,\n                4820163772323651776,\n                14048563721887823792,\n                4815139124790407296,\n                4817619384968446656,\n                4824314914129774240,\n                4822014268429311008,\n                4824295806396779296,\n                14048710604396895984,\n                14047365797250896416,\n                4816833727037317056,\n                14038887232791438592,\n                14041247402057501440,\n                4818292974470206976,\n                4825253778847974128,\n                4821983807267931392,\n                4823878213511816368,\n                14037546185492343936,\n                4820030849238970624,\n                4804459468026718720,\n                14041750227165653440,\n                14039576697340134016,\n                4819161529531549600,\n                4824745178681213248,\n                4819701239283249344,\n                14047754633764038336,\n                4814327162678704896,\n                14048530731728601728,\n                4821912622719414624,\n                4808167531754461696,\n                14045728385546240832,\n                14044053520441863808,\n                14047434719592489840,\n                14037401128502595584,\n                14046861241151263424,\n                14022208777514068992,\n                14041959922282851584,\n                14037758751625253440,\n                14043450847621283552,\n                4818393804998841344,\n                4820085613654887744,\n                4814364981542683776,\n                4819656246768450944,\n                14048747044915088944,\n                14027608620531751424,\n                14046430507935750656,\n                14043933511036770048,\n                4816267946201320512,\n                4819011455589756704,\n                14044654194769966720,\n                14042556849826320576,\n                14047410235151134928,\n                4810541084821220864,\n                4783378357999992832,\n                4824169676573682016,\n                4825194992135601584,\n                4820829692712282048,\n                14045234815888724672,\n                4824536951587011872,\n                14038634379291224128,\n                14047920816213613024,\n                4824240546755815216,\n                14048810525711174528,\n                4818887892976219008,\n                14047981706810162336,\n                14042817254998608480,\n                14039650495529741888,\n                14026431103085966848,\n                4821086022437241152,\n                14044908123376528672,\n                4821942098105353696,\n                14047990977267455776,\n                14045822226120079200,\n                4820750006881336576,\n                14048224679307755232,\n                14048239171818288000,\n                14048825942491131360,\n                14042410946871682240,\n                4823859872194970512,\n                4821500405583493376,\n                4824968047514252832,\n                4818497623928069312,\n                14045756123989134656,\n                4825245620074935792,\n                4820436738597915264,\n                4811304233764865280,\n                14037844308624685248,\n                4823914143377133408,\n                14048316925372661840,\n                4814087281058600320,\n                14041513559587289152,\n                4819347685468512544,\n                4819237760509496896,\n                14044622635128790912,\n                4823873503725295664,\n                14047614194401523776,\n                14048413934677668160,\n                4823607109400202288,\n                14046849912092914176,\n                4824154642579472176,\n                4821361500887907648,\n                4823942390615114112,\n                4825229832920725904,\n                4824179731758597440,\n                4825006815771701264,\n                4822608534557168800,\n                14032885571326626560,\n                4820143275860926176,\n                4811594963418491648,\n                4824881501322501552,\n                4807134495379920384,\n                14047604891892185840,\n                14047332957012664528,\n                14048078456623843904,\n                14038662957961723264,\n                4815626585925600640,\n                14047868938395736560,\n                14043710698861738016,\n                4824611750219152784,\n                14043993046101387136,\n                4825242014597327392,\n                4818116102667389696,\n                14047728342120029392,\n                14022219049402516480,\n                14038048719047372288,\n                4823968979684594624,\n                14046887907478004464,\n                14045288438306444192,\n                4818283008160113728,\n                4823451558568972592,\n                14046287008020350944,\n                4824832758625711200,\n                4819652812670393184,\n                14046825290634125120,\n                4814456286971480576,\n                14042302887881969056,\n                14044836835438148960,\n                14047838534528495824,\n                4816702947033893120,\n                14019678658256308224,\n                4825636301326055520,\n                14030861431732603392,\n                14042743351495309696,\n                14035937802676778496,\n                14048022267163631152,\n                4822848956880109920,\n                14042364094287160544,\n                14040143720674356800,\n                14044637126181639776,\n                4792716801032855552,\n                4821773211317746112,\n                4824019668689826096,\n                4812424785661291136,\n                14045885847204700320,\n                14048356180248350208,\n                14046966570176105520,\n                4811494437115600256,\n                14048689693908169552,\n                4818506356145420480,\n                14047472041030630800,\n                14045127798519704192,\n                4815681458997155840,\n                14038550225824590784,\n                14040270621590114880,\n                4821360487145246944,\n                14045457175217474208,\n                4818534578906627584,\n                4825252099883082544,\n                4823540340658053488,\n                14046785363053377040,\n                4816945205242537472,\n                4824221625712923904,\n                4819111678335613632,\n                4823494238427749936,\n                4813566095802117632,\n                14044686251276656192,\n                14039016618663065856,\n                14035591542985836672,\n                14048110990063373024,\n                4825010637444282832,\n                14047716180911378432,\n                14047022329380671840,\n                4824232742807896592,\n                4822509014179726592,\n                4823298498913008864,\n                4821496670768081952,\n                14046321931468516576,\n                4820428733251579744,\n                4817218941935424000,\n                4812933224489377920,\n                4802797542327358464,\n                4824496402866146848,\n                14048218916817746896,\n                14034546284361348608,\n                14038355548285699520,\n                14044702691585707168,\n                14049024625112457184,\n                4823202762755908288,\n                14043609575577517184,\n                4811154369008552192,\n                14042795875821682368,\n                14040182360109089984,\n                14034013046950897280,\n                4823072652860753824,\n                14046972952640013536,\n                14039343913731150336,\n                14044319793744245568,\n                4812650534253177088,\n                14046371812627101504,\n                4821063192203342624,\n                4816924948346064512,\n                4822872909638449856,\n                14046185065798809632,\n                4823075209095194016,\n                4824812749989680208,\n                14032131995952173056,\n                14046598159936915488,\n                4824338718474497744,\n                14040417984111794496,\n                14047434972759928240,\n                14047713965230483408,\n                4811805958561124352,\n                4823661434788375392,\n                4819371101476383872,\n                4820368836068829024,\n                4822601097759280320,\n                14035601872838437632,\n                14042585095347772224,\n                4820211343488097856,\n                4785100483842703360,\n                14046485788724875328,\n                4823620521064961808,\n                4823958279807517936,\n                14048946927087735920,\n                4825067580189147632,\n                14041610004630052800,\n                4824171629500849904,\n                14046682938938099328,\n                14045817550738463456,\n                14043905289703031456,\n                14043207014105289920,\n                14026280079566404096,\n                14042851025125833120,\n                4825056853645007456,\n                4823178747794311520,\n                4820867314915536160,\n                14045758619376659712,\n                4821772027815496480,\n                4823469709834069136,\n                14048745474488465952,\n                14044708671883746048,\n                14047462456265114192,\n                4814515730598206144,\n                14042620790796421600,\n                4823522554720315824,\n                4818230251858751616,\n                14042796273302997088,\n                4818105121608829824,\n                14043261364282836928,\n                4823692751597217328,\n                4814807973994157888,\n                14047455597442272880,\n                4818460671558840896,\n                14045112515845387840,\n                14047637957357090320,\n                14043788692012826400,\n                14037733980508571392,\n                4811056429270741888,\n                14033974608165490304,\n                4817892642233619648,\n                4825444696005299840,\n                14044148709143213760,\n                4824898509546609296,\n                4823783601325098704,\n                4816917189341124928,\n                4823670859580445312,\n                4816105355467003840,\n                4818438040889401408,\n                14043492641661840064,\n                14048989600483952144,\n                4824270426581410848,\n                4825285819311812560,\n                4809003322107628288,\n                4821778204908211296,\n                4822777819699761696,\n                4815409247251764992,\n                14046896183798847984,\n                4824682763596078304,\n                4817008793446921792,\n                4812958265950076928,\n                4821088619569523104,\n                4820593058516318912,\n                14043975487509986944,\n                14047621300427075520,\n                4811744799544471040,\n                4816791978625591616,\n                4824802506771449008,\n                4819604751910446944,\n                14045784959723410656,\n                4825552964609381216,\n                4825600846414555664,\n                14046429139785310304,\n                4825664339865192544,\n                4817402314147039040,\n                14046674036541752416,\n                4823659676638521888,\n                14043094088489140640,\n                14045460970277451488,\n                4820706698326074112,\n                4819592168162455680,\n                4820339872951433344,\n                14038585544076013760,\n                14044363882277070016,\n                4823132024209448672,\n                4810720209485323136,\n                14048126467681110144,\n                14036130612338681472,\n                14037641435922013440,\n                4825290837153705648,\n                4821682231586133472,\n                14048508866230148560,\n                14043055749983035840,\n                14047912405750249056,\n                4823080210441220608,\n                4823777842033183696,\n                4823820002656487936,\n                4825799721898478864,\n                14046636435075699648,\n                4825480010489585520,\n                4823581677442506688,\n                4822250372574087200,\n                14033302697861504640,\n                14045693919176894912,\n                4823358046825654224,\n                14048272816343027904,\n                4823413803268144096,\n                4825463800618642384,\n                14046026414240434176,\n                4816033709328416768,\n                14040908040559709056,\n                4824480404421529872,\n                14047779831783860704,\n                4809530260274340096,\n                4821829968700340672,\n                14039105607067115648,\n                14042242818078999424,\n                4824280037184775648,\n                14047422510889145904,\n                4811354492706416512,\n                14038703788439499328,\n                4824314904346435840,\n                4823721605852964928,\n                4825390660868555616,\n                4824393569512251664,\n                4822969447700513408,\n                14047013774182033344,\n                4822458840987607872,\n                14046834031563964480,\n                4823972782196108480,\n                4825720711634082448,\n                4824447418339265472,\n                14047469975413542928,\n                14047625963598415952,\n                4799468734284798976,\n                4825408554609456528,\n                4824410355098476240,\n                14038597314327841536,\n                4824493909051150592,\n                14047444315067137952,\n                14037918024033555520,\n                14046262630488680320,\n                14037324877806814464,\n                4824023445801633760,\n                14046887947282102000,\n                14044940070320078944,\n                4823641899469778080,\n                4824123234429243392,\n                4823860495067764112,\n                4803433872244803584,\n                14048616725384401872,\n                4824408377942691040,\n                4824514206593680928,\n                4824350346873041088,\n                14042388346432008352,\n                14048439262684646528,\n                14048991124704661936,\n                4815892311406985664,\n                4824134086696805360,\n                14044132095110882816,\n                4815158786482322816,\n                14048650388135545088,\n                14044921312257901536,\n                14047142758640897136,\n                14045293876766700032,\n                4815499533728784512,\n                4819668747697122912,\n                4820025237521622112,\n                4822940764057731072,\n                4823019288024570176,\n                4820365750874427744,\n                4820730122761988064,\n                14048875947967487136,\n                4821016435912748704,\n                14044140892818081664,\n                14048113318515215456,\n                4818867018662177504,\n                4825615440028521632,\n                4813565970332964096,\n                4821379434016807648,\n                14048984548531799216,\n                4824737372497321440,\n                4824537491254704192,\n                14043661628615990592,\n                14047581081479198544,\n                14048524243159034704,\n                4824342523339760768,\n                14049063797956166208,\n                14046320395644539840,\n                4820327652416853088,\n                14041210068769242432,\n                4825222744942625312,\n                4820783551179446016,\n                14042929054388566304,\n                4825185980008379888,\n                4819774187262191552,\n                4824688749300207616,\n                4824163308595914000,\n                4813900956304566016,\n                14048722398222204528,\n                4822549480334712544,\n                14035255403370842624,\n                14042986249689417280,\n                14042818161816751872,\n                4805077075890746368,\n                4824173084024554960,\n                14046765958292228480,\n                4820339171570542688,\n                4825711291054058304,\n                4807092377174223616,\n                4810822891367042944,\n                4819103894964737376,\n                14048963089960440368,\n                4823547061017868944,\n                4822093383424033664,\n                4818886068543277408,\n                14047131226867724496,\n                14045352715678334752,\n                4818627784578037312,\n                4814504138869771456,\n                14047561869935177072,\n                4823699041501809472,\n                14030085388505836288,\n                4821984907811720672,\n                4819263651972265856,\n                14049036633608379920,\n                4824857816255758960,\n                4816705633918291264,\n                4825515089957303776,\n                14030441610146929152,\n                14047152086431763568,\n                14045934717468309888,\n                14046239514229562656,\n                4816664242405193920,\n                14040488042159794176,\n                4801246988415622656,\n                4821179326921310592,\n                14046000518988881600,\n                4812140807020007296,\n                14044961783589598912,\n                4823639809789632496,\n                14040745514798170496,\n                14047726171579062528,\n                14048415161159316592,\n                14044732776655038144,\n                4821739117710811392,\n                14049165323498981024,\n                14028373760152723968,\n                4814979032221229440,\n                4813717948683407872,\n                4820759981033289984,\n                14048007857030982320,\n                14047680862765500608,\n                14042681424022127072,\n                4821808387038366752,\n                14048399085692705840,\n                4821865710990341184,\n                14041279171555902144,\n                4822390394090191360,\n                4824618662500613104,\n                14043490887518243584,\n                4813629834794785792,\n                4824484195353297744,\n                4821558475914252896,\n                4823118423615618848,\n                4818595084526150016,\n                4816568009332876736,\n                14039102753865354048,\n                14048242540863132912,\n                14045884521152186272,\n                14047757444607404160,\n                14044652017933776736,\n                14032793007844305664,\n                14049027279532698192,\n                14046892829488229968,\n                14026797022747316736,\n                4825163595661451920,\n                14044455581861546976,\n                14042727201393173792,\n                14048685766115795312,\n                14046025959264294272,\n                4820511945091319840,\n                4823743909907030624,\n                14042949939972600256,\n                14039580159555560064,\n                4819015937985659712,\n                4824362982326659216,\n                4824552111129251792,\n                4823457638671805424,\n                4823921140191502080,\n                14040345307052881216,\n                4823533418350332032,\n                4825338171039361216,\n                4822612552487225120,\n                14038700238698098688,\n                14043715555620946880,\n                4819904199248797376,\n                14039743487162291648,\n                4825070690262801600,\n                14038985231958932352,\n                14042815702035420160,\n                14047505889168939776,\n                4824086563950945248,\n                14036804189463831680,\n                4813414579830468224,\n                4816539955452386432,\n                14043599782684410272,\n                4821145681434145120,\n                4815103961915534336,\n                14045934264249440512,\n                4814959335414219392,\n                14041846622307731520,\n                4825155188489548992,\n                14040131482669972224,\n                4820739432987995872,\n                14037981962948801600,\n                4825299708248529184,\n                4823510448253360048,\n                14046833288683250624,\n                4824607805015615744,\n                14044315509699201728,\n                14048393865545262640,\n                4824244048683455248,\n                4810670042511891840,\n                4824691539254249968,\n                14046296444243381344,\n                14045557391572858880,\n                14046261225365569760,\n                14035749892700217472,\n                4806369623280819968,\n                4822332825577109760,\n                4819555559649771360,\n                14030060638786317312,\n                14047941426888210016,\n                4821728909065972096,\n                4819665495462708064,\n                4803717209641332736,\n                4825197891685549568,\n                4820659740520598496,\n                4825493605265544336,\n                14049022842860213632,\n                14046087634811030624,\n                4823436116850100976,\n                14033145032014503424,\n                14046767118481846688,\n                4816500336190882304,\n                14046242707297517568,\n                14046776031495662816,\n                4815703354135552320,\n                14043360699546394784,\n                4825051797675560016,\n                14046724073075621312,\n                14046614971263859424,\n                4825138949304023168,\n                4816214500039761408,\n                14045119227321720544,\n                14043811896782311488,\n                4815202472834941376,\n                4824902240377816288,\n                4817916989179734272,\n                14038744235187764864,\n                14048130188551567312,\n                14040422021022565568,\n                14047572286945449088,\n                4819493806941414080,\n                4824757416212172544,\n                4823142472158525664,\n                4816810368623767936,\n                14046764252318726768,\n                14046840463438634624,\n                14045433209606397824,\n                4819834990348396448,\n                4824913541516905952,\n                4818428436337149760,\n                14041081194394334016,\n                14043197886526868416,\n                14049002736020079632,\n                4822008707556525120,\n                14032669599490028288,\n                4824846972709498688,\n                14048389408623910080,\n                4820581640170525440,\n                14044299140972670176,\n                4825205011168604096,\n                4825522397425522000,\n                14040506994769310656,\n                4819704023598634752,\n                4806084138736763648,\n                4824595862144404208,\n                14048767342883926880,\n                14045420265757879552,\n                14041096228393989376,\n                4820967791712436000,\n                4812267997001086720,\n                14047859097364719184,\n                14042623333028794272,\n                4815019804759284416,\n                4825483745771451824,\n                14043713502251792224,\n                14048100419397610224,\n                4817956529314049344,\n                4825099698095493680,\n                14047603064479999376,\n                4821677781523566720,\n                4824675647976840240,\n                14041044320136109312,\n                14048357716882199312,\n                4820832261441515840,\n                4818307872204423616,\n                4824900621368785328,\n                4819228265911136512,\n                14046291018795745760,\n                14038138648593437504,\n                14044533727359865344,\n                14047529370610032800,\n                4814749962329873600,\n                14048876665590507952,\n                14047261473896587296,\n                14048265991775029968,\n                4818982682813134784,\n                14030627681786138368,\n                14041004067595664448,\n                4824633852670295840,\n                14048578467832803648,\n                14048969123484945664,\n                14048613237520856832,\n                14044920039306676352,\n                14048079665556436256,\n                4825635219583812128,\n                14044224953991823040,\n                4810080860085029888,\n                4823516978872418752,\n                14048985187750213584,\n                14042926472270744768,\n                4818098313978017600,\n                4822987407276604448,\n                4825268175142055680,\n                4808063063380076800,\n                4784705798763724800,\n                4822191680941913632,\n                14043989991150913728,\n                4814565868856249152,\n                4824908724883329552,\n                4825491385159090256,\n                14046867539259995504,\n                14033661380005742336,\n                14047331556102338720,\n                4823316224765885632,\n                4825303165855541696,\n                4819599262551974592,\n                14045174835131343712,\n                4797811320920848384,\n                4825399016814281648,\n                14048769460534934608,\n                4823550245189390816,\n                4822556106598021440,\n                4821330865977190144,\n                4823634967448699472,\n                4825770823169695536,\n                14042508098622725504,\n                4825765859659562640,\n                14042311761928053216,\n                4823939054384931984,\n                4815799315823292672,\n                14045870005443132480,\n                14048819568468780400,\n                4823810729965960224,\n                14028743388748786944,\n                14048139468978053232,\n                14048515423817757280,\n                14047863303690080336,\n                4818039579239938816,\n                4817677313551843584,\n                4820854682816799328,\n                14048973544294974368,\n                14014616574546919424,\n                14048564014456705424,\n                14043667026177980256,\n                4820913313671891392,\n                4824838162898347088,\n                14045466989798356736,\n                14040620994713362176,\n                14042020059809823616,\n                4810151737271640064,\n                14034922773766791808,\n                14041167727637456384,\n                14048921480856579088,\n                14047505225963272688,\n                4823884869399481472,\n                4813303195463768832,\n                14043732960720243424,\n                4821704450958995968,\n                14048726718832678736,\n                14030664253432975616,\n                14029442077796864768,\n                14046857880889520304,\n                4811411208422272512,\n                4824691826138273024,\n                4810929180882090624,\n                4825713654706116016,\n                14043277707007597472,\n                4823814842162294848,\n                4825061298287918544,\n                4811395359900589952,\n                14040093784478105920,\n                14010846819932356608,\n                14047609996612463824,\n                4820589049093050784,\n                14046043014746844032,\n                14035347817301138944,\n                14047165054493622784,\n                14043001489257504096,\n                4824796042815448800,\n                4823940060130537152,\n                4812053543038616960,\n                4810504410389741312,\n                4815675717771747904,\n                4817343667700242368,\n                14047867209982106576,\n                14042553564915148448,\n                14041674310627193856,\n                4824626747854791472,\n                4809469662999577600,\n                4816853196745531328,\n                14039415523564640576,\n                14047366217729915568,\n                4804512050904220672,\n                14044061893743300512,\n                14040877084533261824,\n                4825149794512835168,\n                14043369298173682080,\n                14032920822853072640,\n                4815451004354370048,\n                4820031712543295456,\n                4824864106082153728,\n                14048745447546426768,\n                14042979561052101792,\n                4821363200561319680,\n                4822188232926783040,\n                4823731095105076720,\n                14024330928877349376,\n                4822124569350486144,\n                14046181020766844096,\n                4816008032659257600,\n                4823505532255655232,\n                14048608926876817744,\n                14043086816360609152,\n                14043431218222617024,\n                4823742227279148896,\n                14033434271271102848,\n                14043254654206696352,\n                4820799526351658208,\n                4810042652985639168,\n                4818464096024626048,\n                4820810156746239552,\n                4821861130857032736,\n                4817824308536477184,\n                14047859633748925680,\n                4819153922482361760,\n                4824647649089435648,\n                14046758314719623072,\n                14029987412182777856,\n                14046822443461942432,\n                14039953205051747328,\n                4825718202891572000,\n                4811552120232699392,\n                14047432855865009888,\n                14048929586987963552,\n                14042662844130310208,\n                14033607778619611392,\n                4819441198173008800,\n                4818917877881869824,\n                14049085323745459216,\n                4823860559748031344,\n                4807365921367104256,\n                4824861016138671968,\n                14031654614643143680,\n                4817914381448875776,\n                4825198479846029904,\n                14047939231914667456,\n                4819277230271576256,\n                14047371905361045008,\n                4822149782054294400,\n                14039237228312403328,\n                14047050714534011008,\n                4824316363071183616,\n                4806274560160168192,\n                4820570106516500704,\n                4824191688082688400,\n                4812114795851291008,\n                4823590921617211760,\n                14039375058746366720,\n                4823822080073498736,\n                14031968529294401536,\n                4823638948432959920,\n                14035302807104554112,\n                14048814407632134160,\n                4814120764064260992,\n                4819008980077095968,\n                14037959542815727808,\n                4820454790779644032,\n                14008603624705097728,\n                4811994176005042816,\n                14030279414180350976,\n                14042582547940812512,\n                14047104138168244432,\n                14046010004457038048,\n                14048513193303984672,\n                4806572390951808000,\n                14049020594390580960,\n                4821598109261442784,\n                14035158615887344768,\n                4817734477992260160,\n                4824699225026522000,\n                14041047372336474176,\n                14042919785460425792,\n                14045990127414022048,\n                4796735231262048256,\n                4824997937700429040,\n                4824968653599102176,\n                4825417884620012464,\n                4813592728514745344,\n                14046786361181204368,\n                14047632926479269440,\n                4822646764126377696,\n                14043336938170193248,\n                4822392379978847936,\n                4825446974385574320,\n                4824474636133764528,\n                14041518929823639552,\n                4824039833716783600,\n                14040235325891868800,\n                4824746124298134272,\n                14047634769619181984,\n                14045313348135125376,\n                14041436195472132224,\n                4824664257085369088,\n                14044357955201268992,\n                4821441676178600160,\n                14032154578807784704,\n                14047432270807972608,\n                14041150570552848640,\n                4802039259094374400,\n                14046547865216255840,\n                14034665588260917120,\n                4822198523984619360,\n                14024155782596941824,\n                4822550622765951488,\n                14039723891016340160,\n                14034531657195725568,\n                14046402720168212160,\n                14048815450179842816,\n                14047068368869358448,\n                14041082432262534720,\n                4824471937691770512,\n                14035399376366849536,\n                14041787027145811264,\n                14033307753871640704,\n                14049130446858848736,\n                4824880548850009248,\n                4815164664896434624,\n                14038337419048270720,\n                14044589637814572928,\n                14036308343873620736,\n                4811765600305797248,\n                4821093404696239488,\n                4824499179044062416,\n                14044796935843991552,\n                4825044229752982976,\n                14047016579479895648,\n                14023645206820292608,\n                4823835181733434800,\n                4807508680976417792,\n                14041429724337838912,\n                14047946070668179568,\n                14043533962612662528,\n                14043033764563326048,\n                14034149244040961664,\n                14047781173396705728,\n                14042978827476653952,\n                14048316289435030752,\n                4821422836857409664,\n                14048182187160617440,\n                14040211650041108288,\n                4824637274054143536,\n                4822076319777330752,\n                4824498758037584416,\n                14047423287414214288,\n                14047990392117113696,\n                4811259113780879104,\n                14048886565567525616,\n                4824094482538051680,\n                14047618874943624544,\n                14027399186241871360,\n                4820902637664070176,\n                4821122205470090976,\n                4825308486408796000,\n                14036214974157370496,\n                4820396805880857184,\n                4823766232033999008,\n                4825514506451478160,\n                4802033423964268032,\n                14045883021204027744,\n                14031276819043171072,\n                14047924286335157552,\n                4825172419180734480,\n                4823970631424233440,\n                4821779064645009952,\n                4812773864779906560,\n                4803271333529530880,\n                4825492139971995424,\n                14036413216541245312,\n                14044356743822607840,\n                4816682525860259968,\n                4818463722202679232,\n                4818808340069366784,\n                4824850732171055776,\n                14041264449465872640,\n                14048183324220056400,\n                14047291514935738304,\n                4817334145361688640,\n                14040263704621852928,\n                4814897156578506816,\n                4820103469433420576,\n                14049098392876593520,\n                14046874669210997440,\n                14037204041975831936,\n                4821142109959339200,\n                14033357282232927232,\n                4795366749952940032,\n                4825073699214020976,\n                14048643664617618288,\n                4823975143141394608,\n                14042259665693915872,\n                4817288477211253504,\n                14039804331806362816,\n                14039597521658132032,\n                4822245547121096000,\n                14044364854982553280,\n                4823163843499253280,\n                14042434601051075968,\n                4825771636441478256,\n                4825696122035969024,\n                4819057330289958240,\n                4824451369999172128,\n                4825660860991803968,\n                14046095891170898368,\n                14047815988034435024,\n                4822222424956392288,\n                14040454923402367680,\n                4818759848294333440,\n                4814869787699289088,\n                14048168241346501888,\n                14034492491026147712,\n                14037781350341329408,\n                4818046862503595200,\n                14048674650136630112,\n                4809043926402394368,\n                4822130643009194144,\n                4825584322019064032,\n                14043463764490388928,\n                14047711734126476496,\n                14042028771981653632,\n                4821213783731303008,\n                4824097787867862848,\n                4824552947270173088,\n                4825510007112537888,\n                4824914528218860432,\n                14038334858020807168,\n                14030665390759691776,\n                4823020534669674528,\n                4810083679642412928,\n                4824384252572698528,\n                14047566306679343776,\n                14038912295696402560,\n                4823717782054597264,\n                4808200379836104192,\n                4824394076386796656,\n                4820330319581919776,\n                14045325426999314656,\n                14046365120501436832,\n                14044149789380628704,\n                4819039223841385856,\n                14039235563336614848,\n                14045969129271658624,\n                14041817754655880128,\n                4825131551847934256,\n                4811254555456829568,\n                14043670928709967232,\n                4825332575611757680,\n                4821088497814710496,\n                14048048589564974960,\n                14044612644721478880,\n                4823905787144242640,\n                14043759638687472608,\n                4825689559050848240,\n                4820920774517506016,\n                4821109658015699552,\n                4809168362666924288,\n                14032159081907142144,\n                4823941424989302368,\n                4824422034810973536,\n                4824329055777266784,\n                14046990117354139552,\n                14048781017505987008,\n                14049165448903487424,\n                4823396333782532592,\n                4808897556958704128,\n                14043869462381141568,\n                4823625411153540944,\n                14045044730168242816,\n                14048512604526218176,\n                4806320010870609920,\n                4780960499617218560,\n                14048305794661702272,\n                4825502815947091904,\n                14035111104035609472,\n                14046494058493286272,\n                14038098854484362688,\n                4822281089241756736,\n                4819478842187358240,\n                14043342756211376992,\n                4825118434462241936,\n                4822680930955796352,\n                4823486188302607248,\n                4824708561328341456,\n                4820411491316775584,\n                14047652395226744976,\n                14043556844085627648,\n                4795329193623121920,\n                14045229224944328608,\n                14045505766908476224,\n                14043410007211580544,\n                14046431309206230560,\n                14044352395881500096,\n                14047091179732440912,\n                14040660958297720896,\n                4821817055165850944,\n                4819199782566382816,\n                4820552519312091552,\n                14044038080378180224,\n                4823626586759988288,\n                14049029660881844256,\n                4823432679904451936,\n                4816937081132080384,\n                14044918008458111424,\n                14020902098382045184,\n                4825319351585650272,\n                4815961531267460672,\n                14048587033792391584,\n                4815021075536897536,\n                14036479029193372544,\n                4819185431676456448,\n                14048663720639524448,\n                14038583725798463104,\n                4813159270269736448,\n                4825780158746887536,\n                14048645304410417152,\n                14042715766195774336,\n                14011700343665528832,\n                14048351210226755120,\n                14034421464178087808,\n                4824683488419712752,\n                14046799120506050944,\n                4823325141407800960,\n                4824828138576424432,\n                14021094136442047488,\n                4823638235325125392,\n                14034017471368043264,\n                14042288828097558816,\n                14043156075144106336,\n                4806837410053747968,\n                14039925246703034816,\n                14042136769992976192,\n                4825294132408825440,\n                4824795331719690688,\n                14043192984385229536,\n                4820394933017762400,\n                4820158500518951232,\n                4820563390870483168,\n                4824587126480364048,\n                14048921609774002400,\n                14047415578198840048,\n                4822498766602738752,\n                14042318320626030880,\n                4812727538142044032,\n                14044952908571129728,\n                14049006924595280848,\n                14036687082704309760,\n                14038118743210154304,\n                4816879028373490944,\n                14047830244698481744,\n                4824775736211304000,\n                4814172527318878464,\n                4824523525066340544,\n                4815098745828375040,\n                4815101512388185856,\n                14015215148728569856,\n                4824554621870243872,\n                14047131527335992640,\n                14037040587996897664,\n                14046826979045978352,\n                4823810932579291328,\n                4820479286536100096,\n                4824025064337768448,\n                14031625757285242880,\n                4809664499448005376,\n                4824003556673392016,\n                4814462241983823744,\n                14047183313265195856,\n                4819427535743887392,\n                4824864172787250080,\n                4825599773713811008,\n                4823430056784091840,\n                14036617675265517824,\n                14044697207842096768,\n                14028793082616640256,\n                14047767428554719104,\n                14046228029542860736,\n                14048357082089106688,\n                14039046738265045696,\n                14036966647204158976,\n                4823901096678996656,\n                4825265566354568736,\n                4823313053677949760,\n                14046729053382192432,\n                4803677510675791872,\n                4822072021462983520,\n                14047882657639345600,\n                4815989131287157888,\n                4824648798597445312,\n                4823596800095263776,\n                4825452425024528880,\n                4817059429024057088,\n                4822849296170395872,\n                14044635622196772896,\n                4819361904919562496,\n                14049068364825738960,\n                4810501446803364224,\n                4824485945741776448,\n                4823259803769131136,\n                14044747587695985472,\n                4820908189929728608,\n                4818794376220434816,\n                4816108343408973760,\n                4825403958920374368,\n                4823793936674110640,\n                14043807775905800256,\n                14036431093034641280,\n                4823428374613190160,\n                4823456223292231312,\n                4815422236714533824,\n                14042335396392254432,\n                4822552706222506912,\n                14044868192340871520,\n                4822247264741971456,\n                14045261901037167712,\n                4814120624571797632,\n                14038417954804688000,\n                14035810273727324800,\n                4824668946196266800,\n                4822946311429356928,\n                4824865598517886784,\n                14047989092002799952,\n                14047189150594752928,\n                4824529248758541888,\n                4822959577716853792,\n                14043967904406082336,\n                14044025182676338144,\n                4823055223635684160,\n                4820258622215998240,\n                4823708037201768336,\n                14048686191809961712,\n                14040526815067820864,\n                4814321300577441280,\n                4821662091867274560,\n                4825696541231398816,\n                4824536689847720384,\n                14040069041008209344,\n                14048116803683574192,\n                14044339303715978080,\n                4820922439718925184,\n                4821347579251020256,\n                14046205369346919328,\n                4814820021000367360,\n                14048010483661446336,\n                4824246456163389840,\n                14043862768895973312,\n                14041578814391084480,\n                4821828337744762016,\n                4817625345557820160,\n                4819625978766232672,\n                4822261489834261664,\n                4824797767744218112,\n                4825467190193831088,\n                14044944519505486080,\n                4825257099096686752,\n                4822844067889225472,\n                14049062794721039088,\n                14048419495768346192,\n                14048358845022615392,\n                4821940456313966208,\n                4825781222648606272,\n                14044770118777752960,\n                4822477589161561344,\n                14045903838232765248,\n                14042525171771461760,\n                14047894001338874944,\n                4822117288483348576,\n                14047103947997857184,\n                4814703670485199808,\n                4822716150688547040,\n                4818747066279927808,\n                14042317720043200384,\n                4822782618761166080,\n                14046221411775730336,\n                14042180291607736896,\n                4823198288935028608,\n                14045640872416596896,\n                14049069445492502832,\n                14048407156054820144,\n                4816408571398304448,\n                4824886878132944752,\n                14042901405467415424,\n                14048983891005575440,\n                4811277492240575104,\n                14039592740227219968,\n                14037720094846931968,\n                4824103161134812208,\n                14041228168804467392,\n                14049084259695085552,\n                4823028054587460672,\n                14034617407306666752,\n                14027205404510754304,\n                14045596794367193952,\n                14049109822368874736,\n                4814700155417299392,\n                14038205574719259200,\n                4821133414948934240,\n                4807658014437523712,\n                14046818250910660240,\n                14043500660972239680,\n                14048927820078980528,\n                14042223465469575296,\n                14044466448556423008,\n                4818839803760532672,\n                14042554233179444000,\n                4824652631904467808,\n                14042150581838090944,\n                14047104815928853792,\n                4824849657250712416,\n                14048255013656985072,\n                4825612138913241424,\n                4822638137927943936,\n                14048572819666547536,\n                4825233263122045456,\n                4819910553766348384,\n                4821715471609333568,\n                4814875770870063808,\n                4819786472723278688,\n                4818402455693673984,\n                14046186192283658272,\n                14048260117997113040,\n                14038419085957396544,\n                4823725894356626624,\n                4819446055545337792,\n                14040300318702617728,\n                4822360928336805824,\n                4823373043301644432,\n                14035351792974377728,\n                14045293124139190464,\n                14044525947970532160,\n                4825748900760840688,\n                14020353453775311872,\n                14042235348754988992,\n                14048959636038672560,\n                14041420114076209920,\n                4824580918715324960,\n                4810129767972218240,\n                14048518287661526624,\n                14048965794690965088,\n                4823501006594178784,\n                14040998374858042432,\n                14042327360407432992,\n                14045160048934373312,\n                14024832427335436800,\n                14042999912589697376,\n                4821342494564902848,\n                14045602366058426688,\n                14042556540900780960,\n                4805581525172769536,\n                4815753853996979392,\n                14048234469037794032,\n                14029812006270044160,\n                14042500138902327872,\n                4822172984996334336,\n                4819838152469835072,\n                4819399941274559712,\n                4819347064913619872,\n                14041326363585569856,\n                4823139506591837568,\n                14047979518243091328,\n                14041606606399951680,\n                4824297525055589696,\n                14036333397661454336,\n                14044505619532453280,\n                4816831158832552384,\n                4821666117537948960,\n                14042478164651294208,\n                4817589718173583680,\n                14048191343534622448,\n                14048645125773154608,\n                4814233095401211392,\n                14047483709747098320,\n                4818680658625789248,\n                14040636169532221632,\n                14040803336369050944,\n                14044593280942246944,\n                14047129120235775072,\n                14038823200748777152,\n                14046763680973508656,\n                14046608882492330432,\n                14047481293264791312,\n                4825589446653083744,\n                4824920886445615776,\n                4824531828603699616,\n                4818988687019059488,\n                14045414187235242880,\n                14036111466687911168,\n                4819160184232783808,\n                14048805170158592512,\n                4824035378279041872,\n                4824237923961393072,\n                4825132171646934880,\n                14048257841820499040,\n                4819528509169402688,\n                14043657591186423872,\n                14046387890913359424,\n                4824134418209535264,\n                14048743834403249888,\n                14042294856302848352,\n                14047148995976767104,\n                4825031720907314480,\n                14042052453229739136,\n                14046676121336856224,\n                14049054967715551472,\n                14038599511694023424,\n                4825162663832051264,\n                14047442025147249216,\n                14037723993555736512,\n                4821940087027561280,\n                14024900525013959680,\n                4817253328084959296,\n                4819461413846577344,\n                14044882395932832128,\n                4824528870231913088,\n                14037070311974496640,\n                14046342472613602112,\n                4824951359190630624,\n                4825546747119167232,\n                14044781802203471584,\n                4816600845839623488,\n                4825778936880648768,\n                14048620634226905392,\n                4821974040045795584,\n                4822259517303351968,\n                4823831795524903504,\n                4799950832228170752,\n                14048979205247875120,\n                4812537347165889792,\n                4824337283629199376,\n                14045670381235236992,\n                14045244379693435200,\n                14036459055618907648,\n                4822888550680909920,\n                4823635667656511824,\n                14049134823592440912,\n                4824069872689553152,\n                4816595357216173824,\n                4808710766082249216,\n                14042418790464045632,\n                14046477506892596800,\n                14043398260487037152,\n                14047020603191320272,\n                4823794606714205136,\n                4825208919820651920,\n                4810255898296833280,\n                14048174993702557472,\n                14031218065677010688,\n                4815370418413929344,\n                4824486838814085024,\n                4822739708391689568,\n                4822586152193057248,\n                14045954091572279264,\n                4802778812519639552,\n                14042773259051778624,\n                4823700719930457424,\n                14044502550048991872,\n                14030560325937258496,\n                4812722163493309568,\n                14042869278648109312,\n                4823954717183032640,\n                4808510638068955392,\n                14044754168329762240,\n                4824952843856497776,\n                14043625850189021792,\n                4825018626037774912,\n                4816537793204529408,\n                4815421908627850432,\n                14047954475478614496,\n                14037690995066713728,\n                4822356440614009856,\n                4825547180506781600,\n                4814430861172927616,\n                14048326267377747344,\n                14047980604595262016,\n                14046556665036832224,\n                14044802675006348800,\n                4815077004599362368,\n                14037523503206304640,\n                4822411895407200480,\n                14042969473449009984,\n                14045443781189650112,\n                14044508042724035136,\n                4823079439063141504,\n                4825601113859181872,\n                4810021666733410176,\n                4824277006514015152,\n                4823987077946328576,\n                4818233613479956864,\n                4825438135440397184,\n                4814524885019299136,\n                14024573821519523328,\n                4815307854132227072,\n                14047459192522621856,\n                4825115332910152704,\n                14045060474407595840,\n                14045251198651260096,\n                4821903354082042496,\n                4824656606233529056,\n                4812983876140134912,\n                14039958129181022272,\n                4823437081122836688,\n                14039773269233049344,\n                14047100644790258960,\n                4820120081736677344,\n                14042081864130170624,\n                4824891684722971296,\n                14043200110983080416,\n                14046198772202153312,\n                14039743336140037504,\n                14047164062653083696,\n                4823776775075343536,\n                4819020122735314048,\n                4825241065497721072,\n                14041883400219110144,\n                14048491980588049008,\n                14034733642170184064,\n                4816623046341058368,\n                4819448054750859776,\n                4821959319467467104,\n                4816595589642135744,\n                14031406190985562880,\n                14046723341210022880,\n                4822121187834219680,\n                4819409601088840192,\n                4825555928031439568,\n                14043166967486658880,\n                4824518984465831024,\n                14042639801898105344,\n                14040080437567239872,\n                14044159693466196736,\n                4814683868293188608,\n                14046251883788447776,\n                4812865744470700672,\n                4821028470729843968,\n                4823993597005770000,\n                14043813122652458400,\n                4819786778529327168,\n                4823580361172319984,\n                4823992542478761104,\n                4823907011920804240,\n                14037775829442203328,\n                4796402677603721216,\n                4815028467032232384,\n                14047961248981739168,\n                14041153369005993280,\n                14046881044539894448,\n                14046922994809413696,\n                14039906385651157312,\n                4825227028615957616,\n                4823770328847239184,\n                14047449421980167376,\n                4824287127141871648,\n                4819027602398519616,\n                4819914689616567584,\n                14043404391358018688,\n                4822837655710840128,\n                14046791501974347424,\n                14048942270802509472,\n                14045452733107151840,\n                14039554327645985536,\n                14045827934158284032,\n                14047239433789808256,\n                14037130380023548160,\n                14034867204809081472,\n                14035241676013645824,\n                14048207166401850240,\n                14047991323392969440,\n                4824246953235221056,\n                14043851835145181760,\n                4818367307904894464,\n                4824652778964147552,\n                14048730476311653600,\n                14040418399699816704,\n                14047456050418096416,\n                4824430752514720832,\n                4819492142642010592,\n                4825227620005671216,\n                4820263067040228352,\n                4819284821463994560,\n                4821934641184135872,\n                14039829019717110208,\n                14047082653720845536,\n                4811937098022243328,\n                14048203816622421248,\n                4818121595931286784,\n                4824371128853501840,\n                4824500741613638064,\n                14033485559620271744,\n                14040671843562067584,\n                14044378526694689952,\n                14046860384716577184,\n                14048728206259739136,\n                14041876662741834048,\n                14047149212732573824,\n                14039936263056435584,\n                4817745944332642560,\n                14047853251317322544,\n                4824052561202876528,\n                14046032242323604608,\n                14048949668235440368,\n                4801409254327659008,\n                4820801340618463968,\n                4813837026340930304,\n                14042746947779002752,\n                14043737286503750112,\n                14048572057235414832,\n                14044021129288586496,\n                4825411860536978096,\n                4816253493935780288,\n                14039587257297321600,\n                4816802878535489216,\n                4825254207903054640,\n                4817108214976570432,\n                4825522844708905248,\n                14046236965204166528,\n                14048428679290519712,\n                14041403454063425920,\n                4824920652007546144,\n                4822076402978010432,\n                14040782966056027968,\n                14045469910120356224,\n                14040817268304582592,\n                4823537046448287360,\n                4825542199994661728,\n                4816795274138577408,\n                4803516639061754880,\n                14048031366099736640,\n                4822170201496685792,\n                4823917485742546144,\n                4824650573257132432,\n                4824520928744856064,\n                14042850428874976544,\n                14042551426705223744,\n                4823073668841395072,\n                14043677174658654688,\n                4819885514414555648,\n                4820567441476092768,\n                14037822649441574656,\n                4815507352615158272,\n                14048069958799448320,\n                14035956905390485632,\n                4824006387258217312,\n                14047825084095033664,\n                4825497617704600336,\n                4823710251822915952,\n                4818564662891733760,\n                4802540568370867200,\n                4817783542940734784,\n                4819097907965471552,\n                4815770203467603456,\n                4823503628351117552,\n                4825575873764536032,\n                4819964201468093600,\n                14047110080179873952,\n                14037976031954335616,\n                14047206272173840192,\n                4819555700974924192,\n                4819682760681990048,\n                4814575666592819712,\n                4824593570341773600,\n                14045731131286984032,\n                4820453382547030080,\n                14035579719987047552,\n                4823394873587251984,\n                14038409257607009152,\n                14008802837672419328,\n                4823119450280492928,\n                4823697101508112944,\n                14045803432805343744,\n                4825235470573760592,\n                4824362808272949840,\n                4823141118950601248,\n                4818402729592626048,\n                14047965960600300160,\n                4820480098771281920,\n                4825075385656996960,\n                14045375639208778912,\n                4818870980556533568,\n                14045744963691315328,\n                4825743495166271600,\n                14024465663582709760,\n                4825218767317859104,\n                4825456778648256128,\n                4819959260922282048,\n                14023603196420501504,\n                14025329975515606528,\n                4795643535283232768,\n                4824039028940734384,\n                4824328230144321984,\n                4817359991911098176,\n                4813965683063214592,\n                14044153524067540608,\n                14041007745824524544,\n                4820060462529641216,\n                14048272011270279664,\n                4822516552777929056,\n                14042790287495060736,\n                14049030264483091920,\n                4814897236898586944,\n                14041714513845410368,\n                14045645552131582752,\n                4824902083693964608,\n                14045635924064324800,\n                4821197816935667328,\n                4824493519784159488,\n                14045059031499263712,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            w2tab_offsets: [\n                0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        },\n    ],\n    crts: [\n        SerializedCRTData {\n            prime: 1108307720798209,\n            coeff_len: 1,\n            nprimes: 1,\n        },\n        SerializedCRTData {\n            prime: 659706976665601,\n            coeff_len: 2,\n            nprimes: 2,\n        },\n        SerializedCRTData {\n            prime: 1086317488242689,\n            coeff_len: 3,\n            nprimes: 3,\n        },\n        SerializedCRTData {\n            prime: 910395627798529,\n            coeff_len: 4,\n            nprimes: 4,\n        },\n        SerializedCRTData {\n            prime: 699289395265537,\n            coeff_len: 4,\n            nprimes: 5,\n        },\n        SerializedCRTData {\n            prime: 1022545813831681,\n            coeff_len: 5,\n            nprimes: 6,\n        },\n        SerializedCRTData {\n            prime: 1013749720809473,\n            coeff_len: 6,\n            nprimes: 7,\n        },\n        SerializedCRTData {\n            prime: 868614185943041,\n            coeff_len: 7,\n            nprimes: 8,\n        },\n    ],\n    crts_data_0: [1, 1108307720798209, 1],\n    crts_data_1: [\n        659706976665601,\n        0,\n        1108307720798209,\n        0,\n        1768014697463809,\n        39636172800,\n        659706976665601,\n        448600744132608,\n    ],\n    crts_data_2: [\n        1746024464908289,\n        38849740800,\n        0,\n        2194625209040897,\n        65267564544,\n        0,\n        1768014697463809,\n        39636172800,\n        0,\n        2854332185706497,\n        143753478144,\n        2334150,\n        571641331050399,\n        264058712526685,\n        369275654225854,\n    ],\n    crts_data_3: [\n        2656420092706817,\n        9223372161875443712,\n        1917337,\n        0,\n        3105020836839425,\n        173578125312,\n        3221127,\n        0,\n        2678410325262337,\n        126892376064,\n        1956150,\n        0,\n        2854332185706497,\n        143753478144,\n        2334150,\n        0,\n        3764727813505025,\n        9223372321477099520,\n        3624386149345124124,\n        115,\n        458320576515567,\n        97569782239540,\n        1036168050845794,\n        811521334526211,\n    ],\n    crts_data_4: [\n        3355709487972353,\n        4611686244149100544,\n        12608207587853570738,\n        72,\n        3804310232104961,\n        13835058346567139328,\n        1997174910934683142,\n        122,\n        3377699720527873,\n        9223372265281814528,\n        2855889094178193272,\n        74,\n        3553621580972033,\n        9223372288811859968,\n        8932863472618095828,\n        88,\n        3764727813505025,\n        9223372321477099520,\n        3624386149345124124,\n        115,\n        4464017208770561,\n        4611686445765099520,\n        11571777141199897105,\n        80555675693875672,\n        50394861723794,\n        258028603731868,\n        773781365962580,\n        227761278779927,\n        298113091205252,\n    ],\n    crts_data_5: [\n        4378255301804033,\n        6917529439377555456,\n        12530393500700933832,\n        74322200788992441,\n        0,\n        4826856045936641,\n        11529215548235186176,\n        7614436330990988976,\n        124861297325507225,\n        0,\n        4400245534359553,\n        2305843424874463232,\n        4338630002270041433,\n        75826698780672449,\n        0,\n        4576167394803713,\n        2305843458156265472,\n        17511087166284620218,\n        90479200960512519,\n        0,\n        4787273627336705,\n        2305843502523613184,\n        15767648752728317208,\n        117793676722176637,\n        0,\n        4464017208770561,\n        4611686445765099520,\n        11571777141199897105,\n        80555675693875672,\n        0,\n        5486563022602241,\n        16140901739284398080,\n        6996870336501118609,\n        14398896805553899065,\n        4465387963968,\n        465694486061214,\n        121967058613713,\n        753509900459637,\n        334781288330872,\n        601064818874366,\n        857013090336611,\n    ],\n    crts_data_6: [\n        5392005022613505,\n        17293823221448310784,\n        2198478172704326192,\n        14933593249072088535,\n        4084412403550,\n        0,\n        5840605766746113,\n        14987980327317929984,\n        7157356428090476222,\n        6564030839720445995,\n        6861812837965,\n        0,\n        5413995255169025,\n        4611686675905773568,\n        17498989514742629167,\n        2837081764142908908,\n        4167092816578,\n        0,\n        5589917115613185,\n        13835058755710222336,\n        4466506778020173865,\n        2923420645518345907,\n        4972328143453,\n        0,\n        5801023348146177,\n        13835058811679014912,\n        1196502022415599580,\n        3070261776836331495,\n        6473408337703,\n        0,\n        5477766929580033,\n        6917529700301012992,\n        13621513655758281367,\n        14394739531794089519,\n        4426976024493,\n        0,\n        5486563022602241,\n        16140901739284398080,\n        6996870336501118609,\n        14398896805553899065,\n        4465387963968,\n        0,\n        6500312743411713,\n        12682137526980575232,\n        5414242920244170579,\n        1602665819603013542,\n        613989000473298913,\n        245397550,\n        369585359167388,\n        139053507976977,\n        197670239731636,\n        810816405262515,\n        464183612954890,\n        207483271871031,\n        455632918774715,\n    ],\n    crts_data_7: [\n        6260619208556545,\n        2882304667759673344,\n        3730551556212422699,\n        6864787753339620743,\n        15487482481366708770,\n        192325460,\n        0,\n        6709219952689153,\n        576461794752856064,\n        12548400340138486966,\n        16018745093780771332,\n        3882874023334036815,\n        323106774,\n        0,\n        6282609441112065,\n        1729383169321074688,\n        7686718500326172996,\n        13089866517368245683,\n        14606063416176826766,\n        196218688,\n        0,\n        6458531301556225,\n        10952755257409273856,\n        2741863966014413374,\n        15654288961721831229,\n        11636034492611489364,\n        234135343,\n        0,\n        6669637534089217,\n        10952755323318566912,\n        9393959891602620577,\n        11456823266980106630,\n        9579969358296738720,\n        304817711,\n        0,\n        6346381115523073,\n        14987980490484219904,\n        11211844038443280667,\n        14041014936563027513,\n        6670475906452161904,\n        208455983,\n        0,\n        6355177208545281,\n        10376294474599628800,\n        15564451032506485917,\n        16359389422381633100,\n        1246349985313081608,\n        210264712,\n        0,\n        6500312743411713,\n        12682137526980575232,\n        5414242920244170579,\n        1602665819603013542,\n        613989000473298913,\n        245397550,\n        0,\n        7368926929354753,\n        16717363099189116928,\n        17073008061340272950,\n        7820777766012624523,\n        8382868381485621416,\n        3665382864143079344,\n        11555,\n        880374631983717,\n        648658714639505,\n        567379657715946,\n        136167427417685,\n        657261478444690,\n        163175436259942,\n        815098541074103,\n        656711192629307,\n    ],\n    vec_two_pow_tab_backing: [\n        [4607182418800017408, 4607182418800017408, 4607182418800017408, 4607182418800017408],\n        [4611686018427387904, 4611686018427387904, 4611686018427387904, 4611686018427387904],\n        [4616189618054758400, 4616189618054758400, 4616189618054758400, 4616189618054758400],\n        [4620693217682128896, 4620693217682128896, 4620693217682128896, 4620693217682128896],\n        [4625196817309499392, 4625196817309499392, 4625196817309499392, 4625196817309499392],\n        [4629700416936869888, 4629700416936869888, 4629700416936869888, 4629700416936869888],\n        [4634204016564240384, 4634204016564240384, 4634204016564240384, 4634204016564240384],\n        [4638707616191610880, 4638707616191610880, 4638707616191610880, 4638707616191610880],\n        [4643211215818981376, 4643211215818981376, 4643211215818981376, 4643211215818981376],\n        [4647714815446351872, 4647714815446351872, 4647714815446351872, 4647714815446351872],\n        [4652218415073722368, 4652218415073722368, 4652218415073722368, 4652218415073722368],\n        [4656722014701092864, 4656722014701092864, 4656722014701092864, 4656722014701092864],\n        [4661225614328463360, 4661225614328463360, 4661225614328463360, 4661225614328463360],\n        [4665729213955833856, 4665729213955833856, 4665729213955833856, 4665729213955833856],\n        [4670232813583204352, 4670232813583204352, 4670232813583204352, 4670232813583204352],\n        [4674736413210574848, 4674736413210574848, 4674736413210574848, 4674736413210574848],\n        [4679240012837945344, 4679240012837945344, 4679240012837945344, 4679240012837945344],\n        [4683743612465315840, 4683743612465315840, 4683743612465315840, 4683743612465315840],\n        [4688247212092686336, 4688247212092686336, 4688247212092686336, 4688247212092686336],\n        [4692750811720056832, 4692750811720056832, 4692750811720056832, 4692750811720056832],\n        [4697254411347427328, 4697254411347427328, 4697254411347427328, 4697254411347427328],\n        [4701758010974797824, 4701758010974797824, 4701758010974797824, 4701758010974797824],\n        [4706261610602168320, 4706261610602168320, 4706261610602168320, 4706261610602168320],\n        [4710765210229538816, 4710765210229538816, 4710765210229538816, 4710765210229538816],\n        [4715268809856909312, 4715268809856909312, 4715268809856909312, 4715268809856909312],\n        [4719772409484279808, 4719772409484279808, 4719772409484279808, 4719772409484279808],\n        [4724276009111650304, 4724276009111650304, 4724276009111650304, 4724276009111650304],\n        [4728779608739020800, 4728779608739020800, 4728779608739020800, 4728779608739020800],\n        [4733283208366391296, 4733283208366391296, 4733283208366391296, 4733283208366391296],\n        [4737786807993761792, 4737786807993761792, 4737786807993761792, 4737786807993761792],\n        [4742290407621132288, 4742290407621132288, 4742290407621132288, 4742290407621132288],\n        [4746794007248502784, 4746794007248502784, 4746794007248502784, 4746794007248502784],\n        [4751297606875873280, 4751297606875873280, 4751297606875873280, 4751297606875873280],\n        [4755801206503243776, 4755801206503243776, 4755801206503243776, 4755801206503243776],\n        [4760304806130614272, 4760304806130614272, 4760304806130614272, 4760304806130614272],\n        [4764808405757984768, 4764808405757984768, 4764808405757984768, 4764808405757984768],\n        [4769312005385355264, 4769312005385355264, 4769312005385355264, 4769312005385355264],\n        [4773815605012725760, 4773815605012725760, 4773815605012725760, 4773815605012725760],\n        [4778319204640096256, 4778319204640096256, 4778319204640096256, 4778319204640096256],\n        [4782822804267466752, 4782822804267466752, 4782822804267466752, 4782822804267466752],\n        [4787326403894837248, 4787326403894837248, 4787326403894837248, 4787326403894837248],\n        [4791830003522207744, 4791830003522207744, 4791830003522207744, 4791830003522207744],\n        [4796333603149578240, 4796333603149578240, 4796333603149578240, 4796333603149578240],\n        [4800837202776948736, 4800837202776948736, 4800837202776948736, 4800837202776948736],\n        [4805340802404319232, 4805340802404319232, 4805340802404319232, 4805340802404319232],\n        [4809844402031689728, 4809844402031689728, 4809844402031689728, 4809844402031689728],\n        [4814348001659060224, 4814348001659060224, 4814348001659060224, 4814348001659060224],\n        [4818851601286430720, 4818851601286430720, 4818851601286430720, 4818851601286430720],\n        [4823355200913801216, 4823355200913801216, 4823355200913801216, 4823355200913801216],\n        [14050949362419236880, 14039408888374100032, 14050597518698348560, 14047782768931242000],\n        [4805340802404318720, 14043912488001470528, 4810407351985110912, 4821244138588471264],\n        [4809844402031689216, 4823073725937090464, 4814910951612481408, 4825747738215841760],\n        [4814348001659059712, 14040534788280943040, 4819414551239851904, 14034905288746730112],\n        [4818851601286430208, 14045038387908313536, 4823918150867222400, 14039408888374100608],\n        [4823355200913800704, 4820821926123404448, 14049471618791506192, 14043912488001471104],\n        [14050949362419237392, 14045882812838446816, 4820118238681627616, 14048416087628841600],\n        [4805340802404285952, 4819133076263137888, 4824621838308998112, 4818570126309715008],\n        [4809844402031656448, 4823636675890508384, 14048064243907954768, 4823073725937085504],\n        [4814348001659026944, 14036594138607049344, 4824551469564817264, 14048064243907957712],\n        [4818851601286397440, 14041097738234419840, 14048204981396316464, 4820118238681608416],\n        [4823355200913767936, 14045601337861790336, 4824269994588093872, 4824621838308978912],\n        [14050949362419270160, 4819696026216450848, 14048767931349763248, 14043771750513196192],\n        [4805340802402188800, 14047430925210465520, 4822932988448599392, 14048275350140566688],\n        [4809844402029559296, 4800837202762632192, 4827436588075969888, 4819273813751172512],\n        [4814348001656929792, 4805340802390002688, 14026461039454104064, 4823777413378543008],\n        [4818851601284300288, 4809844402017373184, 14030964639081474560, 14046938344001758416],\n        [4823355200911670784, 4814348001644743680, 14035468238708845056, 4823988519610103408],\n        [14050949362421367312, 4818851601272114176, 14039971838336215552, 14046305025308698208],\n        [4805340802267971072, 4823355200899484672, 14044475437963586048, 4824832944536345008],\n        [4809844401895341568, 14039408888431366208, 14048979037590956544, 14042927325603731808],\n        [4814348001522712064, 14043912488058736704, 4822088563483826208, 14047430925231102304],\n        [4818851601150082560, 4823073725822558112, 4826592163111196704, 4822651513389030048],\n        [4823355200777453056, 14040534788739072448, 14040816263535869760, 14048486456456013168],\n        [14050949362555585040, 14045038388366442944, 14045319863163240256, 4818007175692342464],\n        [4805340793678036480, 4820821925207145632, 14049823462790610752, 4822510775319712960],\n        [4809844393305406976, 14045882814670964448, 4818570124083988032, 14048627194525330256],\n        [4814347992932777472, 4819133072598102624, 4823073723711358528, 4816881271137805760],\n        [4818851592560147968, 4823636672225473120, 14050878995900791248, 4821384870765176256],\n        [4823355192187518464, 14036594197247613568, 4796333033362176000, 4825888470392546752],\n        [14050949371145519632, 14041097796874984064, 4800836632989546496, 14032090708952434944],\n        [4805340243922222592, 14045601396502354560, 4805340232616916992, 14036594308579805440],\n        [4809843843549593088, 4819695908935322400, 4809843832244287488, 14041097908207175936],\n        [4814347443176963584, 14047431042491593968, 4814347431871657984, 14045601507834546432],\n        [4818851042804334080, 4800822190778190848, 4818851031499028480, 4825536462010496784],\n        [4823354642431704576, 4805325790405561344, 4823354631126398976, 14038002873273042880],\n        [14050949920901333520, 4809829390032931840, 14050598088485750800, 14042506472900413376],\n        [4805305059550133760, 4814332989660302336, 4810398235386675072, 14047010072527783872],\n        [4809808659177504256, 4818836589287672832, 4814901835014045568, 4823845062558052496],\n        [4814312258804874752, 4823340188915043328, 4819405434641416064, 14046803045642739440],\n        [4818815858432245248, 14039468936369131584, 4823909034268786560, 4824259116328141360],\n        [4823319458059615744, 14043972535996502080, 14049489851988377872, 14045222638436546400],\n        [14050985105273422352, 4822953629947027360, 4820045305894140896, 4825915331408496816],\n        [4803053259736448512, 14041015172241195456, 4824548905521511392, 14031231156442032896],\n        [4807556859363819008, 14045518771868565952, 14048210109482928208, 14035734756069403392],\n        [4812060458991189504, 4819861158202899616, 4824259738414870384, 14040238355696773888],\n        [4816564058618560000, 14047265793224016752, 14048788443696210224, 14044741955324144384],\n        [4821067658245930496, 4808373226153415424, 4822850939062811488, 14049245554951514880],\n        [4825571257873300992, 4812876825780785920, 4827354538690181984, 4809197145563504896],\n        [14046307259231897632, 4817380425408156416, 14030212519701812480, 4813700745190875392],\n        [14050810858859268128, 4821884025035526912, 14034716119329182976, 4818204344818245888],\n        [4809772916323319040, 14043758615014201888, 14039219718956553472, 4822707944445616384],\n        [4814276515950689536, 4823368336412714480, 14043723318583923968, 14048430025399426832],\n        [4818780115578060032, 14039303804382793920, 14048226918211294464, 4818458624145033152],\n        [4823283715205430528, 14043807404010164416, 4824226120958137872, 4822962223772403648],\n        [14051020848127607568, 4823283893919702688, 14048855678609675248, 14048175746072639568],\n        [4800694231360240640, 14039694116350494144, 4822581999408951392, 4819672230022880992],\n        [4805197830987611136, 14044197715977864640, 4827085599036321888, 4824175829650251488],\n        [4809701430614981632, 4822503269984302240, 14036017513755900544, 14045555785148105888],\n        [4814205030242352128, 14042520125116651232, 14040521113383271040, 4825582184696937328],\n        [4818708629869722624, 14047023724744021728, 14045024713010641536, 14037554145049201024],\n        [4823212229497093120, 4812981909772472960, 14049528312638012032, 14042057744676571520],\n        [4827715829124463616, 4817485509399843456, 4819891463295604256, 14046561344303942016],\n        [14001762727133986816, 4821989109027213952, 4824395062922974752, 4824576625541101200],\n        [14006266326761357312, 14043548447030827808, 14048517794680001488, 14043952601584707040],\n        [14010769926388727808, 4823578504396088560, 4823644368020723824, 14048456201212077536],\n        [14015273526016098304, 14037524882517766528, 14050019184484503344, 4818249217643827520],\n        [14019777125643468800, 14042028482145137024, 4817004350532847296, 4822752817271198016],\n        [14024280725270839296, 14046532081772507520, 4821507950160217792, 14048385152573845200],\n        [14028784324898209792, 4816817475503602240, 4826011549787588288, 4818817606749686208],\n        [14033287924525580288, 4821321075130972736, 14043842404132971808, 4823321206377056704],\n        [14037791524152950784, 14044884514823310240, 14048346003760342304, 14047816763467986512],\n        [14042295123780321280, 4821129672293411040, 4823987949860042192, 4821108160441493216],\n        [14046798723407691776, 14045267320498433632, 14049332020805866608, 4825611760068863712],\n        [4827434354286231568, 4820364060943164256, 4820676630624185952, 14037080939098378880],\n        [14033252179524452224, 14046762890483752112, 4825180230251556448, 14041584538725749376],\n        [14037755779151822720, 4815751629797923520, 14046947460022838096, 14046088138353119872],\n        [14042259378779193216, 4820255229425294016, 4826785037335050608, 4825049831491923344],\n        [14046762978406563712, 14046871722001622352, 14039273269745038528, 14041895917421630400],\n        [4827505844288487696, 4814880977654961600, 14043776869372409024, 14046399517049000896],\n        [14031000240090242816, 4819384577282332096, 14048280468999779520, 4824738452796042320],\n        [14035503839717613312, 4823888176909702592, 4824119019381167760, 14043305292564942560],\n        [14040007439344983808, 14031923805713418496, 14049069881763615472, 14047808892192313056],\n        [14044511038972354304, 14036427405340788992, 4821725186793190496, 4821139645544187040],\n        [14049014638599724800, 14040931004968159488, 4826228786420560992, 4825643245171557536],\n        [4822649846890529824, 14045434604595529984, 14042973457601080992, 14036577177455277696],\n        [4827153446517900320, 4820029492748971552, 14047477057228451488, 14041080777082648192],\n        [14037733371165794112, 14047097458677944816, 4825725842923823824, 14045584376710018688],\n        [14042236970793164608, 4811802166829703552, 14044985231588029664, 4825553593135024528],\n        [14046740570420535104, 4816305766457074048, 14049488831215400160, 14037865824276820928],\n        [4827550660260544912, 4820809366084444544, 4820049388986051744, 14042369423904191424],\n        [14029566128984411904, 14045907932916366624, 4824552988613422240, 14046873023531561920],\n        [14034069728611782400, 4819082836107298272, 14048201943299106512, 4824119160550496400],\n        [14038573328239152896, 4823586435734668768, 4824276070782513776, 14045782461547126240],\n        [14043076927866523392, 14037397981100483200, 14048755778960923440, 4825355508297916976],\n        [14047580527493893888, 14041901580727853696, 4822981598003958624, 14039450502973681344],\n        [4825870746113827344, 14046405180355224192, 4827485197631329120, 14043954102601051840],\n        [14045109306269792224, 4817325081172735552, 14022490816190501888, 14048457702228422336],\n        [14049612905897162720, 4821828680800106048, 14026994415817872384, 4818237209513069120],\n        [4820256777700778144, 14043869303485043616, 14031498015445242880, 4822740809140439616],\n        [4824760377328148640, 4823160094969944288, 14036001615072613376, 14048397160704603600],\n        [14048139009590542032, 14040189312149527744, 14040505214699983872, 4818721541703619008],\n        [4824753781920531056, 14044692911776898240, 14045008814327354368, 4823225141330989504],\n        [14048152200405777200, 4821512878386235040, 14049512413954724864, 14047912828514053712],\n        [4824727400290060720, 14044500908312785632, 4819955058028752928, 4820723900257224416],\n        [14048204963666717872, 4821896885314460256, 4824458657656123424, 4825227499884594912],\n        [4824621873768179376, 14043732894456335200, 14048390605213704144, 14040474570280257856],\n        [14048416016710480560, 4823394056970581168, 4823898746953318512, 14044978169907628352],\n        [4824199767680654000, 14039098039919860416, 14049510426619313968, 14049481769534998848],\n        [14049260228885531312, 14043601639547230912, 4819963007370396512, 4793735012815390720],\n        [4821667485747303776, 4823525311879685456, 4824466606997767008, 4798238612442761216],\n        [4826171085374674272, 14038048000647026112, 14048374706530416976, 4802742212070131712],\n        [14043907949226404512, 14042551600274396608, 4823930544319892848, 4807245811697502208],\n        [14048411548853775008, 14047055199901767104, 14049446831886165296, 4811749411324872704],\n        [4824208703394065104, 4812478307248546944, 4820217386302991200, 4816253010952243200],\n        [14049242357458709104, 4816981906875917440, 4824720985930361696, 4820756610579613696],\n        [4821738971454592608, 4821485506503287936, 14047865948665227600, 4825260210206984192],\n        [4826242571081963104, 14044555652078679840, 4824948060050271600, 14040212887701143616],\n        [14043622006397249184, 4821787397782671840, 14047411800425407792, 14044716487328514112],\n        [14048125606024619680, 14043951869519912032, 4825856356529911216, 14049220086955884608],\n        [4824780589052375760, 4822994962900207456, 14044463177163680096, 4809928261727681664],\n        [14048098586142087792, 14040849840428475072, 14048966776791050592, 4814431861355052160],\n        [4824834628817439536, 14045353440055845568, 4822137606683450016, 4818935460982422656],\n        [14047990506611960240, 4820191821828340384, 4826641206310820512, 4823439060609793152],\n        [4825050787877694640, 14046935129598575984, 14040423917938879296, 14047615049539258128],\n        [14047558188491450032, 4814373716879332544, 14044927517566249792, 4821915016156406752],\n        [4825915424118715056, 4818877316506703040, 14049431117193620288, 14049222953688636464],\n        [14044930594250241376, 4823380916134073536, 4820280245073171232, 4809882394003651968],\n        [14049434193877611872, 14039203166611921472, 4824783844700541728, 4814385993631022464],\n        [4820971625778981536, 14043706766239291968, 14047740231124867536, 4818889593258392960],\n        [4825475225406352032, 4823420185187624400, 4825199495130991728, 4823393192885763456],\n        [14046691389099693472, 14038889014183514560, 14046908930263967536, 14047706784987317520],\n        [4827613174233344624, 14043392613810885056, 4826862096852791728, 4821548074364169184],\n        [14026418524450547200, 4823734337616031312, 14038656793603109568, 4826051673991539680],\n        [14030922124077917696, 14035031550998682496, 14043160393230480064, 14025023548310227456],\n        [14035425723705288192, 14039535150626052992, 14047663992857850560, 14029527147937597952],\n        [14039929323332658688, 14044038750253423488, 4825351971665025680, 14034030747564968448],\n        [14044432922960029184, 4822821201433184544, 14046480716623222240, 14038534347192338944],\n        [14048936522587399680, 14041544886296566720, 4827472002988927536, 14043037946819709440],\n        [4822962310939830304, 14046048485923937216, 14024179730417904640, 14047541546447079936],\n        [4827465910567200800, 4818751858897883456, 14028683330045275136, 4822209028525119520],\n        [14032278119171423488, 4823255458525253952, 14033186929672645632, 14048928941319923696],\n        [14036781718798793984, 14039807857928289088, 14037690529300016128, 4814467296781058240],\n        [14041285318426164480, 14044311457555659584, 14042194128927386624, 4818970896408428736],\n        [14045788918053534976, 4822275786828712352, 14046697728554757120, 4823474496035799232],\n        [14050292517680905472, 14042975091427831008, 4827254991057392656, 14047544178687245968],\n        [4816225059845183552, 14047478691055201504, 14033307241418768256, 4822198499564455392],\n        [4820728659472554048, 4793112746123274240, 14037810841046138752, 14048939470280587824],\n        [4825232259099924544, 4797616345750644736, 14042314440673509248, 4814383065095745216],\n        [14047195246046990224, 4802119945378015232, 14046818040300879744, 4818886664723115712],\n        [4826641309007634672, 4806623545005385728, 4827043876778967312, 4823390264350486208],\n        [14041830471247919296, 4811127144632756224, 14036685069873573760, 14047712642057872016],\n        [14046334070875289792, 4815630744260126720, 14041188669500944256, 4821524646081951200],\n        [14050837670502660288, 4820134343887497216, 14045692269128314752, 4826028245709321696],\n        [4808914943734769920, 14046992607539419152, 14050195868755685248, 14026522958372178432],\n        [4813418543362140416, 4813479785046114176, 4815590876363392064, 14031026557999548928],\n        [4817922142989510912, 4817983384673484672, 4820094475990762560, 14035530157626919424],\n        [4822425742616881408, 4822486984300855168, 4824598075618133056, 14040033757254289920],\n        [4826929342244251904, 14042552696483545376, 14048111769289684880, 14044537356881660416],\n        [14039526205354981440, 14047056296110915872, 4824456418801357040, 14049040956509030912],\n        [14044029804982351936, 4812460767902166656, 14048395082923236912, 4812794348877340800],\n        [14048533404609722432, 4816964367529537152, 4823889791534252976, 4817297948504711296],\n        [4823964991882170256, 4821467967156907648, 14049528337457445040, 4821801548132081792],\n        [14049729780482498800, 14044590730771440416, 4819891364017872224, 14049336421712961424],\n        [4819789279359433824, 4821717240397150688, 4824394963645242720, 4806289409197215488],\n        [4824292878986804320, 14044092184290954336, 14048517993235465552, 4810793008824585984],\n        [14049074006273230672, 4822714333358122848, 4823643970909795696, 4815296608451956480],\n        [4822412376196506336, 14041972358596813504, 14050019978706359600, 4819800208079326976],\n        [4826915975823876832, 14046475958224184000, 4816997996757997248, 4824303807706697472],\n        [14039633136717982016, 4817041969696896320, 4821501596385367744, 14045043872922321952],\n        [14044136736345352512, 4821545569324266816, 4826005196012738240, 4826094096922721264],\n        [14048640335972723008, 14044435526436722080, 14043867819232372000, 14020407721797487616],\n        [4823751129156169104, 4822027649066587360, 14048371418859742496, 14024911321424858112],\n        [14050157505934501104, 14043471366952080992, 4823937119661241808, 14029414921052228608],\n        [4817305153816418496, 4823655584474835376, 14049433681203467376, 14033918520679599104],\n        [4821808753443788992, 14036291601257817472, 4820269989033782880, 14038422120306969600],\n        [4826312353071159488, 14040795200885187968, 4824773588661153376, 14042925719934340096],\n        [14043342878440463648, 14045298800512558464, 14047760743203644240, 14047429319561710592],\n        [14047846478067834144, 4820301100914914592, 4825158470973438320, 4822657936066596896],\n        [4825338844965946832, 14046825850512001776, 14046990978579074352, 14048480033778446320],\n        [14046982074314945648, 4815247949571926208, 4826698000222578096, 4818058557112877248],\n        [4827067652471723824, 4819751549199296704, 14039969566644818624, 4822562156740247744],\n        [14038419723535206080, 14047375402227619664, 14044473166272189120, 14048575813104795472],\n        [14042923323162576576, 4804390673671925248, 14048976765899559616, 4817292322502084032],\n        [14047426922789947072, 4808894273299295744, 4822097650249413920, 4821795922129454528],\n        [4826177955521720976, 4813397872926666240, 4826601249876784416, 14049342047715588688],\n        [14043880468638217696, 4817901472554036736, 14040743569411168064, 4806109377113143040],\n        [14048384068265588192, 4822405072181407232, 14045247169038538560, 4810612976740513536],\n        [4824263664570438736, 14042716520722441248, 14049750768665909056, 4815116576367884032],\n        [14049132435105961840, 14047220120349811744, 4819001639184016160, 4819620175995254528],\n        [4822178660865581664, 4809834758127975680, 4823505238811386656, 4824123775622625024],\n        [4826682260492952160, 4814338357755346176, 14050297442903177680, 14045764001258611744],\n        [14041502859365379392, 4818841957382716672, 4814778283183452608, 4825373968586431472],\n        [14046006458992749888, 4823345557010087168, 4819281882810823104, 14039302820665565376],\n        [14050510058620120384, 14039447463988956224, 4823785482438193600, 14043806420292935872],\n        [4814484732331464256, 14043951063616326720, 14049736955649563792, 14048310019920306368],\n        [4818988331958834752, 4822996574707378080, 4819056891249397216, 4819135134632213792],\n        [4823491931586205248, 14040843393199792576, 4823560490876767712, 4823638734259584288],\n        [14050675901074428816, 14045346992827163072, 14050186938772415568, 14047215702239675856],\n        [4811967983734933376, 4820204716285705376, 4815662316229549504, 4823433803134268528],\n        [4816471583362303872, 14046922235141210992, 4820165915856920000, 14047625564490307376],\n        [4820975182989674368, 4814476872538252480, 4824669515484290496, 4821872956352209760],\n        [4825478782617044864, 4818980472165622976, 14047968889557370000, 14049265013492833456],\n        [14046677160256922144, 4823484071792993472, 4824742178265986800, 4808574472241310464],\n        [4827627403076115952, 14038377921340561984, 14047823563993977392, 4813078071868680960],\n        [14025507878513182208, 14042881520967932480, 4825032829392772016, 4817581671496051456],\n        [14030011478140552704, 14047385120595302976, 14047242261740406960, 4822085271123421952],\n        [4607182418800017408, 4607182418800017408, 4607182418800017408, 4607182418800017408],\n        [4607182418800017408, 4607182418800017408, 4607182418800017408, 4607182418800017408],\n        [4611686018427387904, 4611686018427387904, 4611686018427387904, 4611686018427387904],\n        [4611686018427387904, 4611686018427387904, 4611686018427387904, 4611686018427387904],\n        [4616189618054758400, 4616189618054758400, 4616189618054758400, 4616189618054758400],\n        [4616189618054758400, 4616189618054758400, 4616189618054758400, 4616189618054758400],\n        [4620693217682128896, 4620693217682128896, 4620693217682128896, 4620693217682128896],\n        [4620693217682128896, 4620693217682128896, 4620693217682128896, 4620693217682128896],\n        [4625196817309499392, 4625196817309499392, 4625196817309499392, 4625196817309499392],\n        [4625196817309499392, 4625196817309499392, 4625196817309499392, 4625196817309499392],\n        [4629700416936869888, 4629700416936869888, 4629700416936869888, 4629700416936869888],\n        [4629700416936869888, 4629700416936869888, 4629700416936869888, 4629700416936869888],\n        [4634204016564240384, 4634204016564240384, 4634204016564240384, 4634204016564240384],\n        [4634204016564240384, 4634204016564240384, 4634204016564240384, 4634204016564240384],\n        [4638707616191610880, 4638707616191610880, 4638707616191610880, 4638707616191610880],\n        [4638707616191610880, 4638707616191610880, 4638707616191610880, 4638707616191610880],\n        [4643211215818981376, 4643211215818981376, 4643211215818981376, 4643211215818981376],\n        [4643211215818981376, 4643211215818981376, 4643211215818981376, 4643211215818981376],\n        [4647714815446351872, 4647714815446351872, 4647714815446351872, 4647714815446351872],\n        [4647714815446351872, 4647714815446351872, 4647714815446351872, 4647714815446351872],\n        [4652218415073722368, 4652218415073722368, 4652218415073722368, 4652218415073722368],\n        [4652218415073722368, 4652218415073722368, 4652218415073722368, 4652218415073722368],\n        [4656722014701092864, 4656722014701092864, 4656722014701092864, 4656722014701092864],\n        [4656722014701092864, 4656722014701092864, 4656722014701092864, 4656722014701092864],\n        [4661225614328463360, 4661225614328463360, 4661225614328463360, 4661225614328463360],\n        [4661225614328463360, 4661225614328463360, 4661225614328463360, 4661225614328463360],\n        [4665729213955833856, 4665729213955833856, 4665729213955833856, 4665729213955833856],\n        [4665729213955833856, 4665729213955833856, 4665729213955833856, 4665729213955833856],\n        [4670232813583204352, 4670232813583204352, 4670232813583204352, 4670232813583204352],\n        [4670232813583204352, 4670232813583204352, 4670232813583204352, 4670232813583204352],\n        [4674736413210574848, 4674736413210574848, 4674736413210574848, 4674736413210574848],\n        [4674736413210574848, 4674736413210574848, 4674736413210574848, 4674736413210574848],\n        [4679240012837945344, 4679240012837945344, 4679240012837945344, 4679240012837945344],\n        [4679240012837945344, 4679240012837945344, 4679240012837945344, 4679240012837945344],\n        [4683743612465315840, 4683743612465315840, 4683743612465315840, 4683743612465315840],\n        [4683743612465315840, 4683743612465315840, 4683743612465315840, 4683743612465315840],\n        [4688247212092686336, 4688247212092686336, 4688247212092686336, 4688247212092686336],\n        [4688247212092686336, 4688247212092686336, 4688247212092686336, 4688247212092686336],\n        [4692750811720056832, 4692750811720056832, 4692750811720056832, 4692750811720056832],\n        [4692750811720056832, 4692750811720056832, 4692750811720056832, 4692750811720056832],\n        [4697254411347427328, 4697254411347427328, 4697254411347427328, 4697254411347427328],\n        [4697254411347427328, 4697254411347427328, 4697254411347427328, 4697254411347427328],\n        [4701758010974797824, 4701758010974797824, 4701758010974797824, 4701758010974797824],\n        [4701758010974797824, 4701758010974797824, 4701758010974797824, 4701758010974797824],\n        [4706261610602168320, 4706261610602168320, 4706261610602168320, 4706261610602168320],\n        [4706261610602168320, 4706261610602168320, 4706261610602168320, 4706261610602168320],\n        [4710765210229538816, 4710765210229538816, 4710765210229538816, 4710765210229538816],\n        [4710765210229538816, 4710765210229538816, 4710765210229538816, 4710765210229538816],\n        [4715268809856909312, 4715268809856909312, 4715268809856909312, 4715268809856909312],\n        [4715268809856909312, 4715268809856909312, 4715268809856909312, 4715268809856909312],\n        [4719772409484279808, 4719772409484279808, 4719772409484279808, 4719772409484279808],\n        [4719772409484279808, 4719772409484279808, 4719772409484279808, 4719772409484279808],\n        [4724276009111650304, 4724276009111650304, 4724276009111650304, 4724276009111650304],\n        [4724276009111650304, 4724276009111650304, 4724276009111650304, 4724276009111650304],\n        [4728779608739020800, 4728779608739020800, 4728779608739020800, 4728779608739020800],\n        [4728779608739020800, 4728779608739020800, 4728779608739020800, 4728779608739020800],\n        [4733283208366391296, 4733283208366391296, 4733283208366391296, 4733283208366391296],\n        [4733283208366391296, 4733283208366391296, 4733283208366391296, 4733283208366391296],\n        [4737786807993761792, 4737786807993761792, 4737786807993761792, 4737786807993761792],\n        [4737786807993761792, 4737786807993761792, 4737786807993761792, 4737786807993761792],\n        [4742290407621132288, 4742290407621132288, 4742290407621132288, 4742290407621132288],\n        [4742290407621132288, 4742290407621132288, 4742290407621132288, 4742290407621132288],\n        [4746794007248502784, 4746794007248502784, 4746794007248502784, 4746794007248502784],\n        [4746794007248502784, 4746794007248502784, 4746794007248502784, 4746794007248502784],\n        [4751297606875873280, 4751297606875873280, 4751297606875873280, 4751297606875873280],\n        [4751297606875873280, 4751297606875873280, 4751297606875873280, 4751297606875873280],\n        [4755801206503243776, 4755801206503243776, 4755801206503243776, 4755801206503243776],\n        [4755801206503243776, 4755801206503243776, 4755801206503243776, 4755801206503243776],\n        [4760304806130614272, 4760304806130614272, 4760304806130614272, 4760304806130614272],\n        [4760304806130614272, 4760304806130614272, 4760304806130614272, 4760304806130614272],\n        [4764808405757984768, 4764808405757984768, 4764808405757984768, 4764808405757984768],\n        [4764808405757984768, 4764808405757984768, 4764808405757984768, 4764808405757984768],\n        [4769312005385355264, 4769312005385355264, 4769312005385355264, 4769312005385355264],\n        [4769312005385355264, 4769312005385355264, 4769312005385355264, 4769312005385355264],\n        [4773815605012725760, 4773815605012725760, 4773815605012725760, 4773815605012725760],\n        [4773815605012725760, 4773815605012725760, 4773815605012725760, 4773815605012725760],\n        [4778319204640096256, 4778319204640096256, 4778319204640096256, 4778319204640096256],\n        [4778319204640096256, 4778319204640096256, 4778319204640096256, 4778319204640096256],\n        [4782822804267466752, 4782822804267466752, 4782822804267466752, 4782822804267466752],\n        [4782822804267466752, 4782822804267466752, 4782822804267466752, 4782822804267466752],\n        [4787326403894837248, 4787326403894837248, 4787326403894837248, 4787326403894837248],\n        [4787326403894837248, 4787326403894837248, 4787326403894837248, 4787326403894837248],\n        [4791830003522207744, 4791830003522207744, 4791830003522207744, 4791830003522207744],\n        [4791830003522207744, 4791830003522207744, 4791830003522207744, 4791830003522207744],\n        [4796333603149578240, 4796333603149578240, 4796333603149578240, 4796333603149578240],\n        [4796333603149578240, 4796333603149578240, 4796333603149578240, 4796333603149578240],\n        [4800837202776948736, 4800837202776948736, 4800837202776948736, 4800837202776948736],\n        [4800837202776948736, 4800837202776948736, 4800837202776948736, 4800837202776948736],\n        [4805340802404319232, 4805340802404319232, 4805340802404319232, 4805340802404319232],\n        [4805340802404319232, 4805340802404319232, 4805340802404319232, 4805340802404319232],\n        [4809844402031689728, 4809844402031689728, 4809844402031689728, 4809844402031689728],\n        [4809844402031689728, 4809844402031689728, 4809844402031689728, 4809844402031689728],\n        [4814348001659060224, 4814348001659060224, 4814348001659060224, 4814348001659060224],\n        [4814348001659060224, 4814348001659060224, 4814348001659060224, 4814348001659060224],\n        [4818851601286430720, 4818851601286430720, 4818851601286430720, 4818851601286430720],\n        [4818851601286430720, 4818851601286430720, 4818851601286430720, 4818851601286430720],\n        [4823355200913801216, 4823355200913801216, 4823355200913801216, 4823355200913801216],\n        [4823355200913801216, 4823355200913801216, 4823355200913801216, 4823355200913801216],\n        [14050949362419236880, 14039408888374100032, 14050597518698348560, 14047782768931242000],\n        [14041942163164495936, 14049577171907772432, 14049436434419417104, 14047114265861554192],\n        [4805340802404318720, 14043912488001470528, 4810407351985110912, 4821244138588471264],\n        [14046445762791866432, 4816459063984390080, 4817022013937811392, 4822581144727846880],\n        [4809844402031689216, 4823073725937090464, 4814910951612481408, 4825747738215841760],\n        [4819273813751496608, 4820962663611760576, 4821525613565181888, 14047888322047508528],\n        [4814348001659059712, 14040534788280943040, 4819414551239851904, 14034905288746730112],\n        [4823777413378867104, 4825466263239131072, 4826029213192552384, 4819484919984029536],\n        [4818851601286430208, 14045038387908313536, 4823918150867222400, 14039408888374100608],\n        [14038564463443968832, 14043982856745648416, 14040675525769298496, 4823988519611400032],\n        [4823355200913800704, 4820821926123404448, 14049471618791506192, 14043912488001471104],\n        [14043068063071339328, 14048486456373018912, 14045179125396668992, 14044968019164136096],\n        [14050949362419237392, 14045882812838446816, 4820118238681627616, 14048416087628841600],\n        [14047571662698709824, 4822018194774424480, 14049682725024039488, 4825501447611219312],\n        [4805340802404285952, 4819133076263137888, 4824621838308998112, 4818570126309715008],\n        [4808718502124820736, 4826521794401794976, 4815051689100832320, 14033497913863186816],\n        [4809844402031656448, 4823636675890508384, 14048064243907954768, 4823073725937085504],\n        [4813222101752191232, 14036875613583722112, 4819555288728202816, 14038001513490557312],\n        [4814348001659026944, 14036594138607049344, 4824551469564817264, 14048064243907957712],\n        [4817725701379561728, 14041379213211092608, 4824058888355573312, 14042505113117927808],\n        [4818851601286397440, 14041097738234419840, 14048204981396316464, 4820118238681608416],\n        [4822229301006932224, 14045882812838463104, 14048029059535872912, 14047008712745298304],\n        [4823355200913767936, 14045601337861790336, 4824269994588093872, 4824621838308978912],\n        [14044334700466589216, 14050386412465833600, 4823460754030049520, 4823003357192870432],\n        [14050949362419270160, 4819696026216450848, 14048767931349763248, 14043771750513196192],\n        [4823425569657926128, 4791830003512971264, 14049225328186920496, 14047466109582484976],\n        [4805340802402188800, 14047430925210465520, 4822932988448599392, 14048275350140566688],\n        [14041379213211496640, 4796333603140341760, 4818710863797784256, 4821173769844123744],\n        [4809844402029559296, 4800837202762632192, 4827436588075969888, 4819273813751172512],\n        [14045882812838867136, 4800837202767712256, 4823214463425154752, 4825677369471494240],\n        [4814348001656929792, 4805340802390002688, 14026461039454104064, 4823777413378543008],\n        [4820399713657495200, 4805340802395082752, 14049577171908063568, 14027586939363125760],\n        [4818851601284300288, 4809844402017373184, 14030964639081474560, 14046938344001758416],\n        [14047360556467020144, 4809844402022453248, 4815896114028639680, 14032090538990496256],\n        [4823355200911670784, 4814348001644743680, 14035468238708845056, 4823988519610103408],\n        [4812659151785290112, 4814348001649823744, 4820399713656010176, 14036594138617866752],\n        [14050949362421367312, 4818851601272114176, 14039971838336215552, 14046305025308698208],\n        [4817162751412660608, 4818851601277194240, 4824903313283380672, 14041097738245237248],\n        [4805340802267971072, 4823355200899484672, 14044475437963586048, 4824832944536345008],\n        [4821666351040031104, 4823355200904564736, 14045953181591939360, 14045601337872607744],\n        [4809844401895341568, 14039408888431366208, 14048979037590956544, 14042927325603731808],\n        [14045460600400391456, 14049577171917008912, 4826838453741278960, 4824868128902747664],\n        [4814348001522712064, 14043912488058736704, 4822088563483826208, 14047430925231102304],\n        [4821244138534446560, 4816459063910498240, 14027586939948516864, 14040675525856284608],\n        [4818851601150082560, 4823073725822558112, 4826592163111196704, 4822651513389030048],\n        [14046305025411560544, 4820962663537868736, 14032090539575887360, 14045179125483655104],\n        [4823355200777453056, 14040534788739072448, 14040816263535869760, 14048486456456013168],\n        [4819555288512108384, 4825466263165239232, 14036594139203257856, 4825290341291700304],\n        [14050949362555585040, 14045038388366442944, 14045319863163240256, 4818007175692342464],\n        [4824058888139478880, 14043982857041215776, 14041097738830628352, 14036875614975490944],\n        [4805340793678036480, 4820821925207145632, 14049823462790610752, 4822510775319712960],\n        [14034905292204313216, 14048486456668586272, 14045601338457998848, 14041379214602861440],\n        [4809844393305406976, 14045882814670964448, 4818570124083988032, 14048627194525330256],\n        [14039408891831683712, 4822018193592155040, 14050104938085369344, 14045882814230231936],\n        [4814347992932777472, 4819133072598102624, 4823073723711358528, 4816881271137805760],\n        [14043912491459054208, 4826521793219525536, 4808155533090963712, 4824586652545123472],\n        [4818851592560147968, 4823636672225473120, 14050878995900791248, 4821384870765176256],\n        [4823847778665461136, 14036875632500033152, 4812659132718334208, 14042575487429242336],\n        [4823355192187518464, 14036594197247613568, 4796333033362176000, 4825888470392546752],\n        [14038001541151216576, 14041379232127403648, 4817162732345704704, 14047079087056612832],\n        [14050949371145519632, 14041097796874984064, 4800836632989546496, 14032090708952434944],\n        [14042505140778587072, 14045882831754774144, 4821666331973075200, 4822721859947612320],\n        [4805340243922222592, 14045601396502354560, 4805340232616916992, 14036594308579805440],\n        [14047008740405957568, 14050386431382144640, 4826169931600445696, 14047747606827743088],\n        [4809843843549593088, 4819695908935322400, 4809843832244287488, 14041097908207175936],\n        [4816318105210675776, 4791820318361718784, 14039549778506152000, 4820047780863091296],\n        [4814347443176963584, 14047431042491593968, 4814347431871657984, 14045601507834546432],\n        [4820821704838046272, 4796323917989089280, 14044053378133522496, 4824551380490461792],\n        [4818851042804334080, 4800822190778190848, 4818851031499028480, 4825536462010496784],\n        [14046938565286469072, 4800827517616459776, 14048556977760892992, 14042716575647889056],\n        [4823354642431704576, 4805325790405561344, 4823354631126398976, 14038002873273042880],\n        [4816879506166583744, 4805331117243830272, 4821454634246217504, 14047220175275259552],\n        [14050949920901333520, 4809829390032931840, 14050598088485750800, 14042506472900413376],\n        [4821383105793954240, 4809834716871200768, 4825958233873588000, 4822157507073025440],\n        [4805305059550133760, 4814332989660302336, 4810398235386675072, 14047010072527783872],\n        [14046027090892545184, 4814338316498571264, 14041243360321013568, 14048311959702329968],\n        [4809808659177504256, 4818836589287672832, 4814901835014045568, 4823845062558052496],\n        [4820111157550139104, 4818841916125941760, 14045746959948384064, 4816729137443056832],\n        [4814312258804874752, 4823340188915043328, 4819405434641416064, 14046803045642739440],\n        [14047649112574376240, 4823345515753312256, 14050250559575754560, 4821232737070427328],\n        [4818815858432245248, 14039468936369131584, 4823909034268786560, 4824259116328141360],\n        [4806240106103495424, 14049586857068261392, 4801650488392954368, 4825736336697797824],\n        [4823319458059615744, 14043972535996502080, 14049489851988377872, 14045222638436546400],\n        [4810743705730865920, 4816381582700478400, 4806154088020324864, 14023416834127668224],\n        [14050985105273422352, 4822953629947027360, 4820045305894140896, 4825915331408496816],\n        [4815247305358236416, 4820885182327848896, 4810657687647695360, 14027920433755038720],\n        [4803053259736448512, 14041015172241195456, 4824548905521511392, 14031231156442032896],\n        [4819750904985606912, 4825388781955219392, 4815161287275065856, 14032424033382409216],\n        [4807556859363819008, 14045518771868565952, 14048210109482928208, 14035734756069403392],\n        [4824254504612977408, 14044292781881295136, 4819664886902436352, 14036927633009779712],\n        [4812060458991189504, 4819861158202899616, 4824259738414870384, 14040238355696773888],\n        [14030334418370208000, 14048796381508665632, 4824168486529806848, 14041431232637150208],\n        [4816564058618560000, 14047265793224016752, 14048788443696210224, 14044741955324144384],\n        [14034838017997578496, 4820778494231837600, 14047809863187405840, 14045934832264520704],\n        [4821067658245930496, 4808373226153415424, 4822850939062811488, 14049245554951514880],\n        [14039341617624948992, 4825282093859208096, 4823899146726983664, 4824534634510834704],\n        [4825571257873300992, 4812876825780785920, 4827354538690181984, 4809197145563504896],\n        [14043845217252319488, 14044719534265340320, 14048348542793052208, 14042783559566397408],\n        [14046307259231897632, 4817380425408156416, 14030212519701812480, 4813700745190875392],\n        [4823915052872195856, 14049223133892710816, 4822288374117580640, 14047287159193767904],\n        [14050810858859268128, 4821884025035526912, 14034716119329182976, 4818204344818245888],\n        [14037206656480841600, 4819071484695656864, 4826791973744951136, 4821889571398992032],\n        [4809772916323319040, 14043758615014201888, 14039219718956553472, 4822707944445616384],\n        [14041710256108212096, 4823575084323027360, 14029637249486296320, 14048579895376363376],\n        [4814276515950689536, 4823368336412714480, 14043723318583923968, 14048430025399426832],\n        [14046213855735582592, 14049137405089320144, 14034140849113666816, 4814585652050789568],\n        [4818780115578060032, 14039303804382793920, 14048226918211294464, 4818458624145033152],\n        [4819737627864064288, 4819414399909219552, 14038644448741037312, 4819089251678160064],\n        [4823283715205430528, 14043807404010164416, 4824226120958137872, 4822962223772403648],\n        [4824241227491434784, 4823917999536590048, 14043148048368407808, 4823592851305530560],\n        [14051020848127607568, 4823283893919702688, 14048855678609675248, 14048175746072639568],\n        [14030759286259571968, 14048451574662194768, 14047651647995778304, 14046550692387613984],\n        [4800694231360240640, 14039694116350494144, 4822581999408951392, 4819672230022880992],\n        [14035262885886942464, 4822157721617721056, 4824215577110238736, 4823918774387741424],\n        [4805197830987611136, 14044197715977864640, 4827085599036321888, 4824175829650251488],\n        [14039766485514312960, 4826661321245091552, 14047715682026542064, 14045247000058770528],\n        [4809701430614981632, 4822503269984302240, 14036017513755900544, 14045555785148105888],\n        [14044270085141683456, 14034643184090976896, 4824087509048711216, 4825222466716584880],\n        [4814205030242352128, 14042520125116651232, 14040521113383271040, 4825582184696937328],\n        [4823490184982831888, 14039146783718347392, 14047971818149597104, 14037840823345586880],\n        [4818708629869722624, 14047023724744021728, 14045024713010641536, 14037554145049201024],\n        [14040862290612250560, 14043650383345717888, 4823575236802601136, 14042344422972957376],\n        [4823212229497093120, 4812981909772472960, 14049528312638012032, 14042057744676571520],\n        [14045365890239621056, 14048153982973088384, 14048996362641817264, 14046848022600327872],\n        [4827715829124463616, 4817485509399843456, 4819891463295604256, 14046561344303942016],\n        [4821433558855987360, 4823348088374146592, 4819697094722520416, 4823500659343276688],\n        [14001762727133986816, 4821989109027213952, 4824395062922974752, 4824576625541101200],\n        [14045926184768478944, 14049584284447427056, 4824200694349890912, 14046823349002603248],\n        [14006266326761357312, 14043548447030827808, 14048517794680001488, 14043952601584707040],\n        [4820312969798271584, 4816402163667153088, 14047745447547237712, 4823550006538725936],\n        [14010769926388727808, 4823578504396088560, 4823644368020723824, 14048456201212077536],\n        [14047447300326243760, 4820905763294523584, 4824027978007319920, 14046722071454832480],\n        [14015273526016098304, 14037524882517766528, 14050019184484503344, 4818249217643827520],\n        [4811271250037712256, 4825409362921894080, 14048090880232379696, 4823747395320522928],\n        [14019777125643468800, 14042028482145137024, 4817004350532847296, 4822752817271198016],\n        [4815774849665082752, 14044210458014596384, 4823319024360270688, 14045932516327644512],\n        [14024280725270839296, 14046532081772507520, 4821507950160217792, 14048385152573845200],\n        [4820278449292453248, 14048714057641966880, 14049472610972947632, 4824536950447710896],\n        [14028784324898209792, 4816817475503602240, 4826011549787588288, 4818817606749686208],\n        [14047481820832062096, 4821107789698632608, 4816732601509567168, 14042774295818892640],\n        [14033287924525580288, 4821321075130972736, 14043842404132971808, 4823321206377056704],\n        [4810718921944618880, 4825611389326003104, 4821236201136937664, 14047277895446263136],\n        [14037791524152950784, 14044884514823310240, 14048346003760342304, 14047816763467986512],\n        [4815222521571989376, 14043402352398160288, 4825739800764308160, 4821926626389011104],\n        [14042295123780321280, 4821129672293411040, 4823987949860042192, 4821108160441493216],\n        [4819726121199359872, 14047905952025530784, 14042607231668229408, 14048542840386344304],\n        [14046798723407691776, 14045267320498433632, 14049332020805866608, 4825611760068863712],\n        [4824229720826730368, 4823847706539089104, 14047110831295599904, 4814882091970942144],\n        [4827434354286231568, 4820364060943164256, 4820676630624185952, 14037080939098378880],\n        [14031127499530113280, 14048592160657196656, 4825297210510595536, 4819385691598312640],\n        [14033252179524452224, 14046762890483752112, 4825180230251556448, 14041584538725749376],\n        [14035631099157483776, 4821595377637713504, 14044377592683079904, 4823889291225683136],\n        [14037755779151822720, 4815751629797923520, 14046947460022838096, 14046088138353119872],\n        [14040134698784854272, 4826098977265084000, 14048881192310450400, 14045364932707003680],\n        [14042259378779193216, 4820255229425294016, 4826785037335050608, 4825049831491923344],\n        [14044638298412224768, 14040680363142466880, 4820157776047987872, 4825104534068351728],\n        [14046762978406563712, 14046871722001622352, 14039273269745038528, 14041895917421630400],\n        [4822888742510779936, 14045183962769837376, 4824661375675358368, 14038784284531452096],\n        [4827505844288487696, 4814880977654961600, 14043776869372409024, 14046399517049000896],\n        [14043015817458893792, 14049687562397207872, 14046824084896302800, 14043287884158822592],\n        [14031000240090242816, 4819384577282332096, 14048280468999779520, 4824738452796042320],\n        [14047519417086264288, 4815575940068906560, 4825870703309189744, 14047791483786193088],\n        [14035503839717613312, 4823888176909702592, 4824119019381167760, 14043305292564942560],\n        [4810117381877383808, 4820079539696277056, 14041943604836199616, 4819872273029291296],\n        [14040007439344983808, 14031923805713418496, 14049069881763615472, 14047808892192313056],\n        [4814620981504754304, 4824583139323647552, 14046447204463570112, 4824375872656661792],\n        [14044511038972354304, 14036427405340788992, 4821725186793190496, 4821139645544187040],\n        [4819124581132124800, 14047121295088079760, 4826344430869648208, 14043418606983089056],\n        [14049014638599724800, 14040931004968159488, 4826228786420560992, 4825643245171557536],\n        [4823628180759495296, 4825417020413991152, 14038153784352531904, 14047922206610459552],\n        [4822649846890529824, 14045434604595529984, 14042973457601080992, 14036577177455277696],\n        [14039758324398943296, 14044179828046208096, 14042657383979902400, 4819349381732225440],\n        [4827153446517900320, 4820029492748971552, 14047477057228451488, 14041080777082648192],\n        [14044261924026313792, 14048683427673578592, 14047160983607272896, 4823852981359595936],\n        [14037733371165794112, 14047097458677944816, 4825725842923823824, 14045584376710018688],\n        [4823498346098201552, 4821230309572185760, 4825196905887249552, 14045510172171352480],\n        [14042236970793164608, 4811802166829703552, 14044985231588029664, 4825553593135024528],\n        [14040797001689293248, 4825733909199556256, 14044778811176463840, 4824959294604002928],\n        [14046740570420535104, 4816305766457074048, 14049488831215400160, 14037865824276820928],\n        [14045300601316663744, 14042912272903947680, 14049282410803834336, 14039946200246242496],\n        [4827550660260544912, 4820809366084444544, 4820049388986051744, 14042369423904191424],\n        [4821564136701901984, 14047415872531318176, 4818254202862473536, 14044449799873612992],\n        [14029566128984411904, 14045907932916366624, 4824552988613422240, 14046873023531561920],\n        [14045665029076649696, 4824827865527514320, 4822757802489844032, 14048953399500983488],\n        [14034069728611782400, 4819082836107298272, 14048201943299106512, 4824119160550496400],\n        [4820835281181930080, 14046536447592115424, 14050033832843374288, 4807850070865504512],\n        [14038573328239152896, 4823586435734668768, 4824276070782513776, 14045782461547126240],\n        [14046924988942585264, 4826395925229458224, 4810137651433247616, 4812353670492875008],\n        [14043076927866523392, 14037397981100483200, 14048755778960923440, 4825355508297916976],\n        [4816988116917654208, 14038304779427473088, 4814641251060618112, 4816857270120245504],\n        [14047580527493893888, 14041901580727853696, 4822981598003958624, 14039450502973681344],\n        [4821491716545024704, 14042808379054843584, 4819144850687988608, 4821360869747616000],\n        [4825870746113827344, 14046405180355224192, 4827485197631329120, 14043954102601051840],\n        [14045809869390404256, 14047311978682214080, 4823648450315359104, 14049108597027739408],\n        [14045109306269792224, 4817325081172735552, 14022490816190501888, 14048457702228422336],\n        [4820545600554420960, 4825035653225722512, 14048849935616301328, 4800016192451673088],\n        [14049612905897162720, 4821828680800106048, 14026994415817872384, 4818237209513069120],\n        [14047214669570094384, 14045705296799282656, 4820282802824584160, 4804519792079043584],\n        [4820256777700778144, 14043869303485043616, 14031498015445242880, 4822740809140439616],\n        [4814670671897581248, 14050208896426653152, 4824786402451954656, 4809023391706414080],\n        [4824760377328148640, 4823160094969944288, 14036001615072613376, 14048397160704603600],\n        [4819174271524951744, 4807080665983567104, 14046420824917643424, 4813526991333784576],\n        [14048139009590542032, 14040189312149527744, 14040505214699983872, 4818721541703619008],\n        [4823677871152322240, 4811584265610937600, 4826370810415574896, 4818030590961155072],\n        [4824753781920531056, 14044692911776898240, 14045008814327354368, 4823225141330989504],\n        [14039360801256327744, 4816087865238308096, 14037942747985118400, 4822534190588525568],\n        [14048152200405777200, 4821512878386235040, 14049512413954724864, 14047912828514053712],\n        [14043864400883698240, 4820591464865678592, 14042446347612488896, 14047935276186829840],\n        [4824727400290060720, 14044500908312785632, 4819955058028752928, 4820723900257224416],\n        [4823895869240817104, 4825095064493049088, 14046949947239859392, 4819297103426744288],\n        [14048204963666717872, 4821896885314460256, 4824458657656123424, 4825227499884594912],\n        [14037513594582901632, 14045467651729976352, 4825618978622076560, 4823800703054114784],\n        [4824621873768179376, 14043732894456335200, 14048390605213704144, 14040474570280257856],\n        [14042017194210272128, 14049971251357346848, 14043090520237155808, 14045719285393277088],\n        [14048416016710480560, 4823394056970581168, 4823898746953318512, 14044978169907628352],\n        [14046520793837642624, 4812264855116529280, 14047594119864526304, 4824750181382078320],\n        [4824199767680654000, 14039098039919860416, 14049510426619313968, 14049481769534998848],\n        [4819123751659944224, 4816768454743899776, 4824330633372742736, 14041619106021639360],\n        [14049260228885531312, 14043601639547230912, 4819963007370396512, 4793735012815390720],\n        [4823627351287314720, 4821272054371270272, 14047485569501534064, 14046122705649009856],\n        [4821667485747303776, 4823525311879685456, 4824466606997767008, 4798238612442761216],\n        [14039764960176387904, 4825775653998640768, 4824547734098727216, 4824346761126345552],\n        [4826171085374674272, 14038048000647026112, 14048374706530416976, 4802742212070131712],\n        [14044268559803758400, 14042745293707609632, 14047051368049565104, 14043535053104354016],\n        [14043907949226404512, 14042551600274396608, 4823930544319892848, 4807245811697502208],\n        [4823491710320756944, 14047248893334980128, 4825416137002665136, 14048038652731724512],\n        [14048411548853775008, 14047055199901767104, 14049446831886165296, 4811749411324872704],\n        [14040850087908850112, 4825161823920190416, 14043901886714801504, 4818883597247165600],\n        [4824208703394065104, 4812478307248546944, 4820217386302991200, 4816253010952243200],\n        [14045353687536220608, 14045200614021411040, 14048405486342172000, 4823387196874536096],\n        [14049242357458709104, 4816981906875917440, 4824720985930361696, 4820756610579613696],\n        [4821457964262788256, 14049704213648781536, 4822060599921101472, 14047050273940084432],\n        [4821738971454592608, 4821485506503287936, 14047865948665227600, 4825260210206984192],\n        [14045877373954877152, 4815442730056317248, 4826564199548471968, 4822837112413725920],\n        [4826242571081963104, 14044555652078679840, 4824948060050271600, 14040212887701143616],\n        [4820410591425475168, 4819946329683687744, 14035071231330047616, 14047632354361629488],\n        [14043622006397249184, 4821787397782671840, 14047411800425407792, 14044716487328514112],\n        [14047349678699040176, 4824449929311058240, 14039574830957418112, 4820508790727545696],\n        [14048125606024619680, 14043951869519912032, 4825856356529911216, 14049220086955884608],\n        [4812833196072969600, 14047387715113258384, 14044078430584788608, 4825012390354916192],\n        [4824780589052375760, 4822994962900207456, 14044463177163680096, 4809928261727681664],\n        [4817336795700340096, 4824884180363633904, 14048582030212159104, 14039521434238936384],\n        [14048098586142087792, 14040849840428475072, 14048966776791050592, 4814431861355052160],\n        [4821840395327710592, 14046311188247637088, 4821354424441153056, 14044025033866306880],\n        [4824834628817439536, 14045353440055845568, 4822137606683450016, 4818935460982422656],\n        [14045112511825032480, 4826621184573936560, 4825858024068523552, 14048528633493677376],\n        [14047990506611960240, 4820191821828340384, 4826641206310820512, 4823439060609793152],\n        [4821940315685164512, 14035285370829456768, 14042045038761529152, 4814995747112277568],\n        [4825050787877694640, 14046935129598575984, 14040423917938879296, 14047615049539258128],\n        [14044912671110124640, 14039788970456827264, 14046548638388899648, 4819499346739648064],\n        [14047558188491450032, 4814373716879332544, 14044927517566249792, 4821915016156406752],\n        [4822339997114980192, 14044292570084197760, 4826242996944318672, 4824002946367018560],\n        [4825915424118715056, 4818877316506703040, 14049431117193620288, 14049222953688636464],\n        [14044113308250493280, 14048796169711568256, 14038965255755168192, 14044910312141661984],\n        [14044930594250241376, 4823380916134073536, 4820280245073171232, 4809882394003651968],\n        [4823646961874022064, 4820779341420227104, 14043468855382538688, 4825559154633693424],\n        [14049434193877611872, 14039203166611921472, 4824783844700541728, 4814385993631022464],\n        [14039608075482729152, 4825282941047597600, 14047972455009909184, 14031932764120736512],\n        [4820971625778981536, 14043706766239291968, 14047740231124867536, 4818889593258392960],\n        [14044111675110099648, 14044716145511782304, 4823573963081976976, 14036436363748107008],\n        [4825475225406352032, 4823420185187624400, 4825199495130991728, 4823393192885763456],\n        [4823648595014415696, 14049219745139152800, 14048998910083065584, 14040939963375477504],\n        [14046691389099693472, 14038889014183514560, 14046908930263967536, 14047706784987317520],\n        [14039595010359580096, 4819085039709888928, 4819686904957527136, 14045443563002848000],\n        [4827613174233344624, 14043392613810885056, 4826862096852791728, 4821548074364169184],\n        [14044098609986950592, 4823588639337259424, 4824190504584897632, 4825025903772507408],\n        [14026418524450547200, 4823734337616031312, 14038656793603109568, 4826051673991539680],\n        [4823661660137564752, 14049110295060856016, 14047765827077224272, 14039413326898206656],\n        [14030922124077917696, 14035031550998682496, 14043160393230480064, 14025023548310227456],\n        [14039490489374387648, 4819522840023076064, 4823987218947346800, 14043916926525577152],\n        [14035425723705288192, 14039535150626052992, 14047663992857850560, 14029527147937597952],\n        [14043994089001758144, 4824026439650446560, 14048172398352325936, 14048420526152947648],\n        [14039929323332658688, 14044038750253423488, 4825351971665025680, 14034030747564968448],\n        [4823766181122757200, 14048234694434481744, 4822992951880485728, 4815860605838115392],\n        [14044432922960029184, 4822821201433184544, 14046480716623222240, 14038534347192338944],\n        [14038654321492848064, 4823025242528573152, 14049798683452732592, 4820364205465485888],\n        [14048936522587399680, 14041544886296566720, 4827472002988927536, 14043037946819709440],\n        [14043157921120218560, 14049907130293000496, 4813900041683514752, 4824867805092856384],\n        [4822962310939830304, 14046048485923937216, 14024179730417904640, 14047541546447079936],\n        [14047661520747589056, 4813290792146070912, 4818403641310885248, 14040678116335414848],\n        [4827465910567200800, 4818751858897883456, 14028683330045275136, 4822209028525119520],\n        [4805843044560685312, 4817794391773441408, 4822907240938255744, 14045181715962785344],\n        [14032278119171423488, 4823255458525253952, 14033186929672645632, 14048928941319923696],\n        [4810346644188055808, 4822297991400811904, 14049884394394962576, 4825287750812570064],\n        [14036781718798793984, 14039807857928289088, 14037690529300016128, 4814467296781058240],\n        [4814850243815426304, 4826801591028182400, 4812528666607835008, 14036917062641574784],\n        [14041285318426164480, 14044311457555659584, 14042194128927386624, 4818970896408428736],\n        [4819353843442796800, 14031581296236581120, 4817032266235205504, 14041420662268945280],\n        [14045788918053534976, 4822275786828712352, 14046697728554757120, 4823474496035799232],\n        [4823857443070167296, 14036084895863951616, 4821535865862576000, 14045924261896315776],\n        [14050292517680905472, 14042975091427831008, 4827254991057392656, 14047544178687245968],\n        [14037924225913567296, 14040588495491322112, 4826039465489946496, 4824545204879039632],\n        [4816225059845183552, 14047478691055201504, 14033307241418768256, 4822198499564455392],\n        [14042427825540937792, 14045092095118692608, 14040593507390145600, 14042741278093577696],\n        [4820728659472554048, 4793112746123274240, 14037810841046138752, 14048939470280587824],\n        [14046931425168308288, 14049595694746063104, 14045097107017516096, 14047244877720948192],\n        [4825232259099924544, 4797616345750644736, 14042314440673509248, 4814383065095745216],\n        [4816936627111870016, 4816310881278064704, 14049600706644886592, 4822058697290270880],\n        [14047195246046990224, 4802119945378015232, 14046818040300879744, 4818886664723115712],\n        [4821440226739240512, 4820814480905435200, 4815707836134055488, 14048410769485084528],\n        [4826641309007634672, 4806623545005385728, 4827043876778967312, 4823390264350486208],\n        [14045912849001972640, 4825318080532805696, 4820211435761425984, 4815938659181020352],\n        [14041830471247919296, 4811127144632756224, 14036685069873573760, 14047712642057872016],\n        [4820339641331284192, 14044575587570949920, 4824715035388796480, 4820442258808390848],\n        [14046334070875289792, 4815630744260126720, 14041188669500944256, 4821524646081951200],\n        [14047420628793231152, 14049079187198320416, 14046706293170276128, 4824945858435761344],\n        [14050837670502660288, 4820134343887497216, 14045692269128314752, 4826028245709321696],\n        [4811697994565913984, 4819647271473218464, 4826085342162942192, 14040053689592175168],\n        [4808914943734769920, 14046992607539419152, 14050195868755685248, 14026522958372178432],\n        [4816201594193284480, 4824150871100588960, 14040226494006180032, 14044557289219545664],\n        [4813418543362140416, 4813479785046114176, 4815590876363392064, 14031026557999548928],\n        [4820705193820654976, 14047985831534196944, 14044730093633550528, 14049060888846916160],\n        [4817922142989510912, 4817983384673484672, 4820094475990762560, 14035530157626919424],\n        [14047055076303860368, 4823687947521756784, 14049233693260921024, 4803480021186998784],\n        [4822425742616881408, 4822486984300855168, 4824598075618133056, 14040033757254289920],\n        [4815947418027453376, 14048911678691861296, 4818643943205780032, 4807983620814369280],\n        [4826929342244251904, 14042552696483545376, 14048111769289684880, 14044537356881660416],\n        [4820451017654823872, 4820317305499054944, 4823147542833150528, 4812487220441739776],\n        [14039526205354981440, 14047056296110915872, 4824456418801357040, 14049040956509030912],\n        [14047309252469691472, 4824820905126425440, 14049644092500067792, 4816990820069110272],\n        [14044029804982351936, 4812460767902166656, 14048395082923236912, 4812794348877340800],\n        [4813480015742548864, 14046564289196470944, 4815360749292605888, 4821494419696480768],\n        [14048533404609722432, 4816964367529537152, 4823889791534252976, 4817297948504711296],\n        [4817983615369919360, 4826368083625102704, 4819864348919976384, 14048975047078874640],\n        [4823964991882170256, 4821467967156907648, 14049528337457445040, 4821801548132081792],\n        [4822487214997289856, 14038527512262317248, 4824367948547346880, 4807157348372987648],\n        [14049729780482498800, 14044590730771440416, 4819891364017872224, 14049336421712961424],\n        [14043818872485873952, 14043031111889687744, 14047410939152325776, 4811660948000358144],\n        [4819789279359433824, 4821717240397150688, 4824394963645242720, 4806289409197215488],\n        [4823941397638641392, 14047534711517058240, 4824696994797143792, 4816164547627728640],\n        [4824292878986804320, 14044092184290954336, 14048517993235465552, 4810793008824585984],\n        [14036785140217713024, 4824590187556034192, 14046752846652731952, 4820668147255099136],\n        [14049074006273230672, 4822714333358122848, 4823643970909795696, 4815296608451956480],\n        [14041288739845083520, 14047107198623306480, 4826013179796331440, 4825171746882469632],\n        [4822412376196506336, 14041972358596813504, 14050019978706359600, 4819800208079326976],\n        [14045792339472454016, 4825445213343537712, 14040803792939066048, 14038246582018508864],\n        [4826915975823876832, 14046475958224184000, 4816997996757997248, 4824303807706697472],\n        [4820580660390321440, 14044067056328021856, 14045307392566436544, 14042750181645879360],\n        [14039633136717982016, 4817041969696896320, 4821501596385367744, 14045043872922321952],\n        [14047179609734193904, 14048570655955392352, 14049810992193807040, 14047253781273249856],\n        [14044136736345352512, 4821545569324266816, 4826005196012738240, 4826094096922721264],\n        [4814951150584785088, 4821681396444930720, 4813703101826323584, 4822023083081064224],\n        [14048640335972723008, 14044435526436722080, 14043867819232372000, 14020407721797487616],\n        [4819454750212155584, 4826184996072301216, 4818206701453694080, 14048446383694291184],\n        [4823751129156169104, 4822027649066587360, 14048371418859742496, 14024911321424858112],\n        [4823958349839526080, 14039992212684729152, 4822710301081064576, 4815653745507367104],\n        [14050157505934501104, 14043471366952080992, 4823937119661241808, 14029414921052228608],\n        [14036513905003558016, 14044495812312099648, 14050081334252153744, 4820157345134737600],\n        [4817305153816418496, 4823655584474835376, 14049433681203467376, 14033918520679599104],\n        [14041017504630928512, 14048999411939470144, 4808910855753862912, 4824660944762108096],\n        [4821808753443788992, 14036291601257817472, 4820269989033782880, 14038422120306969600],\n        [14045521104258299008, 4819966372508619552, 4813414455381233408, 14042278318561303840],\n        [4826312353071159488, 14040795200885187968, 4824773588661153376, 14042925719934340096],\n        [4821123130818631456, 4824469972135990048, 4817918055008603904, 14046781918188674336],\n        [14043342878440463648, 14045298800512558464, 14047760743203644240, 14047429319561710592],\n        [14046547040843190752, 14047347629463394768, 4822421654635974400, 4823632868166583760],\n        [14047846478067834144, 4820301100914914592, 4825158470973438320, 4822657936066596896],\n        [4819071257648847968, 4824964351663361136, 4826925254263344896, 14046390624943401184],\n        [4825338844965946832, 14046825850512001776, 14046990978579074352, 14048480033778446320],\n        [4823574857276218464, 14045990503048728160, 14019854173440869376, 4824078841831954224],\n        [14046982074314945648, 4815247949571926208, 4826698000222578096, 4818058557112877248],\n        [14040184912265157952, 4826941869772845488, 14024357773068239872, 14044606730281919328],\n        [4827067652471723824, 4819751549199296704, 14039969566644818624, 4822562156740247744],\n        [14044688511892528448, 14025471913555629568, 14028861372695610368, 14049110329909289824],\n        [14038419723535206080, 14047375402227619664, 14044473166272189120, 14048575813104795472],\n        [4822788315550172576, 14029975513183000064, 14033364972322980864, 4799794383613219840],\n        [14042923323162576576, 4804390673671925248, 14048976765899559616, 4817292322502084032],\n        [14043216671380108512, 14034479112810370560, 14037868571950351360, 4804297983240590336],\n        [14047426922789947072, 4808894273299295744, 4822097650249413920, 4821795922129454528],\n        [14047720271007479008, 14038982712437741056, 14042372171577721856, 4808801582867960832],\n        [4826177955521720976, 4813397872926666240, 4826601249876784416, 14049342047715588688],\n        [4802585270084094464, 14043486312065111552, 14046875771205092352, 4813305182495331328],\n        [14043880468638217696, 4817901472554036736, 14040743569411168064, 4806109377113143040],\n        [4807088869711464960, 14047989911692482048, 4825767330691610640, 4817808782122701824],\n        [14048384068265588192, 4822405072181407232, 14045247169038538560, 4810612976740513536],\n        [4811592469338835456, 4823679787205186576, 14042497111959019488, 4822312381750072320],\n        [4824263664570438736, 14042716520722441248, 14049750768665909056, 4815116576367884032],\n        [4816096068966205952, 14048927999325001712, 14047000711586389984, 14048157085025283088],\n        [14049132435105961840, 14047220120349811744, 4819001639184016160, 4819620175995254528],\n        [4820599668593576448, 4820252022966493280, 4825517449929015376, 4817968134859431872],\n        [4822178660865581664, 4809834758127975680, 4823505238811386656, 4824123775622625024],\n        [14047160601530938896, 4824755622593863776, 14043496635009400544, 4822471734486802368],\n        [4826682260492952160, 4814338357755346176, 14050297442903177680, 14045764001258611744],\n        [4815103216210825152, 14046776328547647312, 14048000234636771040, 14047997732288553040],\n        [14041502859365379392, 4818841957382716672, 4814778283183452608, 4825373968586431472],\n        [4819606815838195648, 4826106953494856048, 4823518403828253264, 4819047279019851488],\n        [14046006458992749888, 4823345557010087168, 4819281882810823104, 14039302820665565376],\n        [4824110415465566144, 14040616553304290496, 14049110028590513008, 4823550878647221984],\n        [14050510058620120384, 14039447463988956224, 4823785482438193600, 14043806420292935872],\n        [14034080854986916992, 14045120152931660992, 4819242430927737440, 14046718583020848288],\n        [4814484732331464256, 14043951063616326720, 14049736955649563792, 14048310019920306368],\n        [14038584454614287488, 14049623752559031488, 4823746030555107936, 4823750883754507120],\n        [4818988331958834752, 4822996574707378080, 4819056891249397216, 4819135134632213792],\n        [14043088054241657984, 4816086418774317632, 14048654775136803664, 14045918562591707744],\n        [4823491931586205248, 14040843393199792576, 4823560490876767712, 4823638734259584288],\n        [14047591653869028480, 4820590018401688128, 4821063444742574816, 4824550904183647664],\n        [14050675901074428816, 14045346992827163072, 14050186938772415568, 14047215702239675856],\n        [4808078784674623744, 4825093618029058624, 4825567044369945312, 14042718480875145568],\n        [4811967983734933376, 4820204716285705376, 4815662316229549504, 4823433803134268528],\n        [4812582384301994240, 14045473437585938208, 14043298257245680800, 14047222080502516064],\n        [4816471583362303872, 14046922235141210992, 4820165915856920000, 14047625564490307376],\n        [4817085983929364736, 14049977037213308704, 14047801856873051296, 4822149886163999392],\n        [4820975182989674368, 4814476872538252480, 4824669515484290496, 4821872956352209760],\n        [4821589583556735232, 4812172281421139584, 4823915159355692752, 14048319580611356016],\n        [4825478782617044864, 4818980472165622976, 14047968889557370000, 14049265013492833456],\n        [14045614135366983200, 4816675881048510080, 14048316517535634032, 4816668170170848448],\n        [14046677160256922144, 4823484071792993472, 4824742178265986800, 4808574472241310464],\n        [4820937068601263072, 4821179480675880576, 4822416475147253344, 4821171769798218944],\n        [4827627403076115952, 14038377921340561984, 14047823563993977392, 4813078071868680960],\n        [14046823201523252272, 4825683080303251072, 4826920074774623840, 4825675369425589440],\n        [14025507878513182208, 14042881520967932480, 4825032829392772016, 4817581671496051456],\n        [4817802416272318144, 14043115588489168416, 14020517147997164544, 14027714942301032960],\n        [14030011478140552704, 14047385120595302976, 14047242261740406960, 4822085271123421952],\n        [4822306015899688640, 14047619188116538912, 14025020747624535040, 14032218541928403456],\n    ],\n    vec_two_pow_tab_offsets: [0, 256],\n    slow_two_pow_backing: [\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14050949362419236880,\n        4805340802404318720,\n        4809844402031689216,\n        4814348001659059712,\n        4818851601286430208,\n        4823355200913800704,\n        14050949362419237392,\n        4805340802404285952,\n        4809844402031656448,\n        4814348001659026944,\n        4818851601286397440,\n        4823355200913767936,\n        14050949362419270160,\n        4805340802402188800,\n        4809844402029559296,\n        4814348001656929792,\n        4818851601284300288,\n        4823355200911670784,\n        14050949362421367312,\n        4805340802267971072,\n        4809844401895341568,\n        4814348001522712064,\n        4818851601150082560,\n        4823355200777453056,\n        14050949362555585040,\n        4805340793678036480,\n        4809844393305406976,\n        4814347992932777472,\n        4818851592560147968,\n        4823355192187518464,\n        14050949371145519632,\n        4805340243922222592,\n        4809843843549593088,\n        4814347443176963584,\n        4818851042804334080,\n        4823354642431704576,\n        14050949920901333520,\n        4805305059550133760,\n        4809808659177504256,\n        4814312258804874752,\n        4818815858432245248,\n        4823319458059615744,\n        14050985105273422352,\n        4803053259736448512,\n        4807556859363819008,\n        4812060458991189504,\n        4816564058618560000,\n        4821067658245930496,\n        4825571257873300992,\n        14046307259231897632,\n        14050810858859268128,\n        4809772916323319040,\n        4814276515950689536,\n        4818780115578060032,\n        4823283715205430528,\n        14051020848127607568,\n        4800694231360240640,\n        4805197830987611136,\n        4809701430614981632,\n        4814205030242352128,\n        4818708629869722624,\n        4823212229497093120,\n        4827715829124463616,\n        14001762727133986816,\n        14006266326761357312,\n        14010769926388727808,\n        14015273526016098304,\n        14019777125643468800,\n        14024280725270839296,\n        14028784324898209792,\n        14033287924525580288,\n        14037791524152950784,\n        14042295123780321280,\n        14046798723407691776,\n        4827434354286231568,\n        14033252179524452224,\n        14037755779151822720,\n        14042259378779193216,\n        14046762978406563712,\n        4827505844288487696,\n        14031000240090242816,\n        14035503839717613312,\n        14040007439344983808,\n        14044511038972354304,\n        14049014638599724800,\n        4822649846890529824,\n        4827153446517900320,\n        14037733371165794112,\n        14042236970793164608,\n        14046740570420535104,\n        4827550660260544912,\n        14029566128984411904,\n        14034069728611782400,\n        14038573328239152896,\n        14043076927866523392,\n        14047580527493893888,\n        4825870746113827344,\n        14045109306269792224,\n        14049612905897162720,\n        4820256777700778144,\n        4824760377328148640,\n        14048139009590542032,\n        4824753781920531056,\n        14048152200405777200,\n        4824727400290060720,\n        14048204963666717872,\n        4824621873768179376,\n        14048416016710480560,\n        4824199767680654000,\n        14049260228885531312,\n        4821667485747303776,\n        4826171085374674272,\n        14043907949226404512,\n        14048411548853775008,\n        4824208703394065104,\n        14049242357458709104,\n        4821738971454592608,\n        4826242571081963104,\n        14043622006397249184,\n        14048125606024619680,\n        4824780589052375760,\n        14048098586142087792,\n        4824834628817439536,\n        14047990506611960240,\n        4825050787877694640,\n        14047558188491450032,\n        4825915424118715056,\n        14044930594250241376,\n        14049434193877611872,\n        4820971625778981536,\n        4825475225406352032,\n        14046691389099693472,\n        4827613174233344624,\n        14026418524450547200,\n        14030922124077917696,\n        14035425723705288192,\n        14039929323332658688,\n        14044432922960029184,\n        14048936522587399680,\n        4822962310939830304,\n        4827465910567200800,\n        14032278119171423488,\n        14036781718798793984,\n        14041285318426164480,\n        14045788918053534976,\n        14050292517680905472,\n        4816225059845183552,\n        4820728659472554048,\n        4825232259099924544,\n        14047195246046990224,\n        4826641309007634672,\n        14041830471247919296,\n        14046334070875289792,\n        14050837670502660288,\n        4808914943734769920,\n        4813418543362140416,\n        4817922142989510912,\n        4822425742616881408,\n        4826929342244251904,\n        14039526205354981440,\n        14044029804982351936,\n        14048533404609722432,\n        4823964991882170256,\n        14049729780482498800,\n        4819789279359433824,\n        4824292878986804320,\n        14049074006273230672,\n        4822412376196506336,\n        4826915975823876832,\n        14039633136717982016,\n        14044136736345352512,\n        14048640335972723008,\n        4823751129156169104,\n        14050157505934501104,\n        4817305153816418496,\n        4821808753443788992,\n        4826312353071159488,\n        14043342878440463648,\n        14047846478067834144,\n        4825338844965946832,\n        14046982074314945648,\n        4827067652471723824,\n        14038419723535206080,\n        14042923323162576576,\n        14047426922789947072,\n        4826177955521720976,\n        14043880468638217696,\n        14048384068265588192,\n        4824263664570438736,\n        14049132435105961840,\n        4822178660865581664,\n        4826682260492952160,\n        14041502859365379392,\n        14046006458992749888,\n        14050510058620120384,\n        4814484732331464256,\n        4818988331958834752,\n        4823491931586205248,\n        14050675901074428816,\n        4811967983734933376,\n        4816471583362303872,\n        4820975182989674368,\n        4825478782617044864,\n        14046677160256922144,\n        4827627403076115952,\n        14025507878513182208,\n        14030011478140552704,\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14039408888374100032,\n        14043912488001470528,\n        4823073725937090464,\n        14040534788280943040,\n        14045038387908313536,\n        4820821926123404448,\n        14045882812838446816,\n        4819133076263137888,\n        4823636675890508384,\n        14036594138607049344,\n        14041097738234419840,\n        14045601337861790336,\n        4819696026216450848,\n        14047430925210465520,\n        4800837202762632192,\n        4805340802390002688,\n        4809844402017373184,\n        4814348001644743680,\n        4818851601272114176,\n        4823355200899484672,\n        14039408888431366208,\n        14043912488058736704,\n        4823073725822558112,\n        14040534788739072448,\n        14045038388366442944,\n        4820821925207145632,\n        14045882814670964448,\n        4819133072598102624,\n        4823636672225473120,\n        14036594197247613568,\n        14041097796874984064,\n        14045601396502354560,\n        4819695908935322400,\n        14047431042491593968,\n        4800822190778190848,\n        4805325790405561344,\n        4809829390032931840,\n        4814332989660302336,\n        4818836589287672832,\n        4823340188915043328,\n        14039468936369131584,\n        14043972535996502080,\n        4822953629947027360,\n        14041015172241195456,\n        14045518771868565952,\n        4819861158202899616,\n        14047265793224016752,\n        4808373226153415424,\n        4812876825780785920,\n        4817380425408156416,\n        4821884025035526912,\n        14043758615014201888,\n        4823368336412714480,\n        14039303804382793920,\n        14043807404010164416,\n        4823283893919702688,\n        14039694116350494144,\n        14044197715977864640,\n        4822503269984302240,\n        14042520125116651232,\n        14047023724744021728,\n        4812981909772472960,\n        4817485509399843456,\n        4821989109027213952,\n        14043548447030827808,\n        4823578504396088560,\n        14037524882517766528,\n        14042028482145137024,\n        14046532081772507520,\n        4816817475503602240,\n        4821321075130972736,\n        14044884514823310240,\n        4821129672293411040,\n        14045267320498433632,\n        4820364060943164256,\n        14046762890483752112,\n        4815751629797923520,\n        4820255229425294016,\n        14046871722001622352,\n        4814880977654961600,\n        4819384577282332096,\n        4823888176909702592,\n        14031923805713418496,\n        14036427405340788992,\n        14040931004968159488,\n        14045434604595529984,\n        4820029492748971552,\n        14047097458677944816,\n        4811802166829703552,\n        4816305766457074048,\n        4820809366084444544,\n        14045907932916366624,\n        4819082836107298272,\n        4823586435734668768,\n        14037397981100483200,\n        14041901580727853696,\n        14046405180355224192,\n        4817325081172735552,\n        4821828680800106048,\n        14043869303485043616,\n        4823160094969944288,\n        14040189312149527744,\n        14044692911776898240,\n        4821512878386235040,\n        14044500908312785632,\n        4821896885314460256,\n        14043732894456335200,\n        4823394056970581168,\n        14039098039919860416,\n        14043601639547230912,\n        4823525311879685456,\n        14038048000647026112,\n        14042551600274396608,\n        14047055199901767104,\n        4812478307248546944,\n        4816981906875917440,\n        4821485506503287936,\n        14044555652078679840,\n        4821787397782671840,\n        14043951869519912032,\n        4822994962900207456,\n        14040849840428475072,\n        14045353440055845568,\n        4820191821828340384,\n        14046935129598575984,\n        4814373716879332544,\n        4818877316506703040,\n        4823380916134073536,\n        14039203166611921472,\n        14043706766239291968,\n        4823420185187624400,\n        14038889014183514560,\n        14043392613810885056,\n        4823734337616031312,\n        14035031550998682496,\n        14039535150626052992,\n        14044038750253423488,\n        4822821201433184544,\n        14041544886296566720,\n        14046048485923937216,\n        4818751858897883456,\n        4823255458525253952,\n        14039807857928289088,\n        14044311457555659584,\n        4822275786828712352,\n        14042975091427831008,\n        14047478691055201504,\n        4793112746123274240,\n        4797616345750644736,\n        4802119945378015232,\n        4806623545005385728,\n        4811127144632756224,\n        4815630744260126720,\n        4820134343887497216,\n        14046992607539419152,\n        4813479785046114176,\n        4817983384673484672,\n        4822486984300855168,\n        14042552696483545376,\n        14047056296110915872,\n        4812460767902166656,\n        4816964367529537152,\n        4821467967156907648,\n        14044590730771440416,\n        4821717240397150688,\n        14044092184290954336,\n        4822714333358122848,\n        14041972358596813504,\n        14046475958224184000,\n        4817041969696896320,\n        4821545569324266816,\n        14044435526436722080,\n        4822027649066587360,\n        14043471366952080992,\n        4823655584474835376,\n        14036291601257817472,\n        14040795200885187968,\n        14045298800512558464,\n        4820301100914914592,\n        14046825850512001776,\n        4815247949571926208,\n        4819751549199296704,\n        14047375402227619664,\n        4804390673671925248,\n        4808894273299295744,\n        4813397872926666240,\n        4817901472554036736,\n        4822405072181407232,\n        14042716520722441248,\n        14047220120349811744,\n        4809834758127975680,\n        4814338357755346176,\n        4818841957382716672,\n        4823345557010087168,\n        14039447463988956224,\n        14043951063616326720,\n        4822996574707378080,\n        14040843393199792576,\n        14045346992827163072,\n        4820204716285705376,\n        14046922235141210992,\n        4814476872538252480,\n        4818980472165622976,\n        4823484071792993472,\n        14038377921340561984,\n        14042881520967932480,\n        14047385120595302976,\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14050597518698348560,\n        4810407351985110912,\n        4814910951612481408,\n        4819414551239851904,\n        4823918150867222400,\n        14049471618791506192,\n        4820118238681627616,\n        4824621838308998112,\n        14048064243907954768,\n        4824551469564817264,\n        14048204981396316464,\n        4824269994588093872,\n        14048767931349763248,\n        4822932988448599392,\n        4827436588075969888,\n        14026461039454104064,\n        14030964639081474560,\n        14035468238708845056,\n        14039971838336215552,\n        14044475437963586048,\n        14048979037590956544,\n        4822088563483826208,\n        4826592163111196704,\n        14040816263535869760,\n        14045319863163240256,\n        14049823462790610752,\n        4818570124083988032,\n        4823073723711358528,\n        14050878995900791248,\n        4796333033362176000,\n        4800836632989546496,\n        4805340232616916992,\n        4809843832244287488,\n        4814347431871657984,\n        4818851031499028480,\n        4823354631126398976,\n        14050598088485750800,\n        4810398235386675072,\n        4814901835014045568,\n        4819405434641416064,\n        4823909034268786560,\n        14049489851988377872,\n        4820045305894140896,\n        4824548905521511392,\n        14048210109482928208,\n        4824259738414870384,\n        14048788443696210224,\n        4822850939062811488,\n        4827354538690181984,\n        14030212519701812480,\n        14034716119329182976,\n        14039219718956553472,\n        14043723318583923968,\n        14048226918211294464,\n        4824226120958137872,\n        14048855678609675248,\n        4822581999408951392,\n        4827085599036321888,\n        14036017513755900544,\n        14040521113383271040,\n        14045024713010641536,\n        14049528312638012032,\n        4819891463295604256,\n        4824395062922974752,\n        14048517794680001488,\n        4823644368020723824,\n        14050019184484503344,\n        4817004350532847296,\n        4821507950160217792,\n        4826011549787588288,\n        14043842404132971808,\n        14048346003760342304,\n        4823987949860042192,\n        14049332020805866608,\n        4820676630624185952,\n        4825180230251556448,\n        14046947460022838096,\n        4826785037335050608,\n        14039273269745038528,\n        14043776869372409024,\n        14048280468999779520,\n        4824119019381167760,\n        14049069881763615472,\n        4821725186793190496,\n        4826228786420560992,\n        14042973457601080992,\n        14047477057228451488,\n        4825725842923823824,\n        14044985231588029664,\n        14049488831215400160,\n        4820049388986051744,\n        4824552988613422240,\n        14048201943299106512,\n        4824276070782513776,\n        14048755778960923440,\n        4822981598003958624,\n        4827485197631329120,\n        14022490816190501888,\n        14026994415817872384,\n        14031498015445242880,\n        14036001615072613376,\n        14040505214699983872,\n        14045008814327354368,\n        14049512413954724864,\n        4819955058028752928,\n        4824458657656123424,\n        14048390605213704144,\n        4823898746953318512,\n        14049510426619313968,\n        4819963007370396512,\n        4824466606997767008,\n        14048374706530416976,\n        4823930544319892848,\n        14049446831886165296,\n        4820217386302991200,\n        4824720985930361696,\n        14047865948665227600,\n        4824948060050271600,\n        14047411800425407792,\n        4825856356529911216,\n        14044463177163680096,\n        14048966776791050592,\n        4822137606683450016,\n        4826641206310820512,\n        14040423917938879296,\n        14044927517566249792,\n        14049431117193620288,\n        4820280245073171232,\n        4824783844700541728,\n        14047740231124867536,\n        4825199495130991728,\n        14046908930263967536,\n        4826862096852791728,\n        14038656793603109568,\n        14043160393230480064,\n        14047663992857850560,\n        4825351971665025680,\n        14046480716623222240,\n        4827472002988927536,\n        14024179730417904640,\n        14028683330045275136,\n        14033186929672645632,\n        14037690529300016128,\n        14042194128927386624,\n        14046697728554757120,\n        4827254991057392656,\n        14033307241418768256,\n        14037810841046138752,\n        14042314440673509248,\n        14046818040300879744,\n        4827043876778967312,\n        14036685069873573760,\n        14041188669500944256,\n        14045692269128314752,\n        14050195868755685248,\n        4815590876363392064,\n        4820094475990762560,\n        4824598075618133056,\n        14048111769289684880,\n        4824456418801357040,\n        14048395082923236912,\n        4823889791534252976,\n        14049528337457445040,\n        4819891364017872224,\n        4824394963645242720,\n        14048517993235465552,\n        4823643970909795696,\n        14050019978706359600,\n        4816997996757997248,\n        4821501596385367744,\n        4826005196012738240,\n        14043867819232372000,\n        14048371418859742496,\n        4823937119661241808,\n        14049433681203467376,\n        4820269989033782880,\n        4824773588661153376,\n        14047760743203644240,\n        4825158470973438320,\n        14046990978579074352,\n        4826698000222578096,\n        14039969566644818624,\n        14044473166272189120,\n        14048976765899559616,\n        4822097650249413920,\n        4826601249876784416,\n        14040743569411168064,\n        14045247169038538560,\n        14049750768665909056,\n        4819001639184016160,\n        4823505238811386656,\n        14050297442903177680,\n        4814778283183452608,\n        4819281882810823104,\n        4823785482438193600,\n        14049736955649563792,\n        4819056891249397216,\n        4823560490876767712,\n        14050186938772415568,\n        4815662316229549504,\n        4820165915856920000,\n        4824669515484290496,\n        14047968889557370000,\n        4824742178265986800,\n        14047823563993977392,\n        4825032829392772016,\n        14047242261740406960,\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14047782768931242000,\n        4821244138588471264,\n        4825747738215841760,\n        14034905288746730112,\n        14039408888374100608,\n        14043912488001471104,\n        14048416087628841600,\n        4818570126309715008,\n        4823073725937085504,\n        14048064243907957712,\n        4820118238681608416,\n        4824621838308978912,\n        14043771750513196192,\n        14048275350140566688,\n        4819273813751172512,\n        4823777413378543008,\n        14046938344001758416,\n        4823988519610103408,\n        14046305025308698208,\n        4824832944536345008,\n        14042927325603731808,\n        14047430925231102304,\n        4822651513389030048,\n        14048486456456013168,\n        4818007175692342464,\n        4822510775319712960,\n        14048627194525330256,\n        4816881271137805760,\n        4821384870765176256,\n        4825888470392546752,\n        14032090708952434944,\n        14036594308579805440,\n        14041097908207175936,\n        14045601507834546432,\n        4825536462010496784,\n        14038002873273042880,\n        14042506472900413376,\n        14047010072527783872,\n        4823845062558052496,\n        14046803045642739440,\n        4824259116328141360,\n        14045222638436546400,\n        4825915331408496816,\n        14031231156442032896,\n        14035734756069403392,\n        14040238355696773888,\n        14044741955324144384,\n        14049245554951514880,\n        4809197145563504896,\n        4813700745190875392,\n        4818204344818245888,\n        4822707944445616384,\n        14048430025399426832,\n        4818458624145033152,\n        4822962223772403648,\n        14048175746072639568,\n        4819672230022880992,\n        4824175829650251488,\n        14045555785148105888,\n        4825582184696937328,\n        14037554145049201024,\n        14042057744676571520,\n        14046561344303942016,\n        4824576625541101200,\n        14043952601584707040,\n        14048456201212077536,\n        4818249217643827520,\n        4822752817271198016,\n        14048385152573845200,\n        4818817606749686208,\n        4823321206377056704,\n        14047816763467986512,\n        4821108160441493216,\n        4825611760068863712,\n        14037080939098378880,\n        14041584538725749376,\n        14046088138353119872,\n        4825049831491923344,\n        14041895917421630400,\n        14046399517049000896,\n        4824738452796042320,\n        14043305292564942560,\n        14047808892192313056,\n        4821139645544187040,\n        4825643245171557536,\n        14036577177455277696,\n        14041080777082648192,\n        14045584376710018688,\n        4825553593135024528,\n        14037865824276820928,\n        14042369423904191424,\n        14046873023531561920,\n        4824119160550496400,\n        14045782461547126240,\n        4825355508297916976,\n        14039450502973681344,\n        14043954102601051840,\n        14048457702228422336,\n        4818237209513069120,\n        4822740809140439616,\n        14048397160704603600,\n        4818721541703619008,\n        4823225141330989504,\n        14047912828514053712,\n        4820723900257224416,\n        4825227499884594912,\n        14040474570280257856,\n        14044978169907628352,\n        14049481769534998848,\n        4793735012815390720,\n        4798238612442761216,\n        4802742212070131712,\n        4807245811697502208,\n        4811749411324872704,\n        4816253010952243200,\n        4820756610579613696,\n        4825260210206984192,\n        14040212887701143616,\n        14044716487328514112,\n        14049220086955884608,\n        4809928261727681664,\n        4814431861355052160,\n        4818935460982422656,\n        4823439060609793152,\n        14047615049539258128,\n        4821915016156406752,\n        14049222953688636464,\n        4809882394003651968,\n        4814385993631022464,\n        4818889593258392960,\n        4823393192885763456,\n        14047706784987317520,\n        4821548074364169184,\n        4826051673991539680,\n        14025023548310227456,\n        14029527147937597952,\n        14034030747564968448,\n        14038534347192338944,\n        14043037946819709440,\n        14047541546447079936,\n        4822209028525119520,\n        14048928941319923696,\n        4814467296781058240,\n        4818970896408428736,\n        4823474496035799232,\n        14047544178687245968,\n        4822198499564455392,\n        14048939470280587824,\n        4814383065095745216,\n        4818886664723115712,\n        4823390264350486208,\n        14047712642057872016,\n        4821524646081951200,\n        4826028245709321696,\n        14026522958372178432,\n        14031026557999548928,\n        14035530157626919424,\n        14040033757254289920,\n        14044537356881660416,\n        14049040956509030912,\n        4812794348877340800,\n        4817297948504711296,\n        4821801548132081792,\n        14049336421712961424,\n        4806289409197215488,\n        4810793008824585984,\n        4815296608451956480,\n        4819800208079326976,\n        4824303807706697472,\n        14045043872922321952,\n        4826094096922721264,\n        14020407721797487616,\n        14024911321424858112,\n        14029414921052228608,\n        14033918520679599104,\n        14038422120306969600,\n        14042925719934340096,\n        14047429319561710592,\n        4822657936066596896,\n        14048480033778446320,\n        4818058557112877248,\n        4822562156740247744,\n        14048575813104795472,\n        4817292322502084032,\n        4821795922129454528,\n        14049342047715588688,\n        4806109377113143040,\n        4810612976740513536,\n        4815116576367884032,\n        4819620175995254528,\n        4824123775622625024,\n        14045764001258611744,\n        4825373968586431472,\n        14039302820665565376,\n        14043806420292935872,\n        14048310019920306368,\n        4819135134632213792,\n        4823638734259584288,\n        14047215702239675856,\n        4823433803134268528,\n        14047625564490307376,\n        4821872956352209760,\n        14049265013492833456,\n        4808574472241310464,\n        4813078071868680960,\n        4817581671496051456,\n        4822085271123421952,\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14041942163164495936,\n        14046445762791866432,\n        4819273813751496608,\n        4823777413378867104,\n        14038564463443968832,\n        14043068063071339328,\n        14047571662698709824,\n        4808718502124820736,\n        4813222101752191232,\n        4817725701379561728,\n        4822229301006932224,\n        14044334700466589216,\n        4823425569657926128,\n        14041379213211496640,\n        14045882812838867136,\n        4820399713657495200,\n        14047360556467020144,\n        4812659151785290112,\n        4817162751412660608,\n        4821666351040031104,\n        14045460600400391456,\n        4821244138534446560,\n        14046305025411560544,\n        4819555288512108384,\n        4824058888139478880,\n        14034905292204313216,\n        14039408891831683712,\n        14043912491459054208,\n        4823847778665461136,\n        14038001541151216576,\n        14042505140778587072,\n        14047008740405957568,\n        4816318105210675776,\n        4820821704838046272,\n        14046938565286469072,\n        4816879506166583744,\n        4821383105793954240,\n        14046027090892545184,\n        4820111157550139104,\n        14047649112574376240,\n        4806240106103495424,\n        4810743705730865920,\n        4815247305358236416,\n        4819750904985606912,\n        4824254504612977408,\n        14030334418370208000,\n        14034838017997578496,\n        14039341617624948992,\n        14043845217252319488,\n        4823915052872195856,\n        14037206656480841600,\n        14041710256108212096,\n        14046213855735582592,\n        4819737627864064288,\n        4824241227491434784,\n        14030759286259571968,\n        14035262885886942464,\n        14039766485514312960,\n        14044270085141683456,\n        4823490184982831888,\n        14040862290612250560,\n        14045365890239621056,\n        4821433558855987360,\n        14045926184768478944,\n        4820312969798271584,\n        14047447300326243760,\n        4811271250037712256,\n        4815774849665082752,\n        4820278449292453248,\n        14047481820832062096,\n        4810718921944618880,\n        4815222521571989376,\n        4819726121199359872,\n        4824229720826730368,\n        14031127499530113280,\n        14035631099157483776,\n        14040134698784854272,\n        14044638298412224768,\n        4822888742510779936,\n        14043015817458893792,\n        14047519417086264288,\n        4810117381877383808,\n        4814620981504754304,\n        4819124581132124800,\n        4823628180759495296,\n        14039758324398943296,\n        14044261924026313792,\n        4823498346098201552,\n        14040797001689293248,\n        14045300601316663744,\n        4821564136701901984,\n        14045665029076649696,\n        4820835281181930080,\n        14046924988942585264,\n        4816988116917654208,\n        4821491716545024704,\n        14045809869390404256,\n        4820545600554420960,\n        14047214669570094384,\n        4814670671897581248,\n        4819174271524951744,\n        4823677871152322240,\n        14039360801256327744,\n        14043864400883698240,\n        4823895869240817104,\n        14037513594582901632,\n        14042017194210272128,\n        14046520793837642624,\n        4819123751659944224,\n        4823627351287314720,\n        14039764960176387904,\n        14044268559803758400,\n        4823491710320756944,\n        14040850087908850112,\n        14045353687536220608,\n        4821457964262788256,\n        14045877373954877152,\n        4820410591425475168,\n        14047349678699040176,\n        4812833196072969600,\n        4817336795700340096,\n        4821840395327710592,\n        14045112511825032480,\n        4821940315685164512,\n        14044912671110124640,\n        4822339997114980192,\n        14044113308250493280,\n        4823646961874022064,\n        14039608075482729152,\n        14044111675110099648,\n        4823648595014415696,\n        14039595010359580096,\n        14044098609986950592,\n        4823661660137564752,\n        14039490489374387648,\n        14043994089001758144,\n        4823766181122757200,\n        14038654321492848064,\n        14043157921120218560,\n        14047661520747589056,\n        4805843044560685312,\n        4810346644188055808,\n        4814850243815426304,\n        4819353843442796800,\n        4823857443070167296,\n        14037924225913567296,\n        14042427825540937792,\n        14046931425168308288,\n        4816936627111870016,\n        4821440226739240512,\n        14045912849001972640,\n        4820339641331284192,\n        14047420628793231152,\n        4811697994565913984,\n        4816201594193284480,\n        4820705193820654976,\n        14047055076303860368,\n        4815947418027453376,\n        4820451017654823872,\n        14047309252469691472,\n        4813480015742548864,\n        4817983615369919360,\n        4822487214997289856,\n        14043818872485873952,\n        4823941397638641392,\n        14036785140217713024,\n        14041288739845083520,\n        14045792339472454016,\n        4820580660390321440,\n        14047179609734193904,\n        4814951150584785088,\n        4819454750212155584,\n        4823958349839526080,\n        14036513905003558016,\n        14041017504630928512,\n        14045521104258299008,\n        4821123130818631456,\n        14046547040843190752,\n        4819071257648847968,\n        4823574857276218464,\n        14040184912265157952,\n        14044688511892528448,\n        4822788315550172576,\n        14043216671380108512,\n        14047720271007479008,\n        4802585270084094464,\n        4807088869711464960,\n        4811592469338835456,\n        4816096068966205952,\n        4820599668593576448,\n        14047160601530938896,\n        4815103216210825152,\n        4819606815838195648,\n        4824110415465566144,\n        14034080854986916992,\n        14038584454614287488,\n        14043088054241657984,\n        14047591653869028480,\n        4808078784674623744,\n        4812582384301994240,\n        4817085983929364736,\n        4821589583556735232,\n        14045614135366983200,\n        4820937068601263072,\n        14046823201523252272,\n        4817802416272318144,\n        4822306015899688640,\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14049577171907772432,\n        4816459063984390080,\n        4820962663611760576,\n        4825466263239131072,\n        14043982856745648416,\n        14048486456373018912,\n        4822018194774424480,\n        4826521794401794976,\n        14036875613583722112,\n        14041379213211092608,\n        14045882812838463104,\n        14050386412465833600,\n        4791830003512971264,\n        4796333603140341760,\n        4800837202767712256,\n        4805340802395082752,\n        4809844402022453248,\n        4814348001649823744,\n        4818851601277194240,\n        4823355200904564736,\n        14049577171917008912,\n        4816459063910498240,\n        4820962663537868736,\n        4825466263165239232,\n        14043982857041215776,\n        14048486456668586272,\n        4822018193592155040,\n        4826521793219525536,\n        14036875632500033152,\n        14041379232127403648,\n        14045882831754774144,\n        14050386431382144640,\n        4791820318361718784,\n        4796323917989089280,\n        4800827517616459776,\n        4805331117243830272,\n        4809834716871200768,\n        4814338316498571264,\n        4818841916125941760,\n        4823345515753312256,\n        14049586857068261392,\n        4816381582700478400,\n        4820885182327848896,\n        4825388781955219392,\n        14044292781881295136,\n        14048796381508665632,\n        4820778494231837600,\n        4825282093859208096,\n        14044719534265340320,\n        14049223133892710816,\n        4819071484695656864,\n        4823575084323027360,\n        14049137405089320144,\n        4819414399909219552,\n        4823917999536590048,\n        14048451574662194768,\n        4822157721617721056,\n        4826661321245091552,\n        14034643184090976896,\n        14039146783718347392,\n        14043650383345717888,\n        14048153982973088384,\n        4823348088374146592,\n        14049584284447427056,\n        4816402163667153088,\n        4820905763294523584,\n        4825409362921894080,\n        14044210458014596384,\n        14048714057641966880,\n        4821107789698632608,\n        4825611389326003104,\n        14043402352398160288,\n        14047905952025530784,\n        4823847706539089104,\n        14048592160657196656,\n        4821595377637713504,\n        4826098977265084000,\n        14040680363142466880,\n        14045183962769837376,\n        14049687562397207872,\n        4815575940068906560,\n        4820079539696277056,\n        4824583139323647552,\n        14047121295088079760,\n        4825417020413991152,\n        14044179828046208096,\n        14048683427673578592,\n        4821230309572185760,\n        4825733909199556256,\n        14042912272903947680,\n        14047415872531318176,\n        4824827865527514320,\n        14046536447592115424,\n        4826395925229458224,\n        14038304779427473088,\n        14042808379054843584,\n        14047311978682214080,\n        4825035653225722512,\n        14045705296799282656,\n        14050208896426653152,\n        4807080665983567104,\n        4811584265610937600,\n        4816087865238308096,\n        4820591464865678592,\n        4825095064493049088,\n        14045467651729976352,\n        14049971251357346848,\n        4812264855116529280,\n        4816768454743899776,\n        4821272054371270272,\n        4825775653998640768,\n        14042745293707609632,\n        14047248893334980128,\n        4825161823920190416,\n        14045200614021411040,\n        14049704213648781536,\n        4815442730056317248,\n        4819946329683687744,\n        4824449929311058240,\n        14047387715113258384,\n        4824884180363633904,\n        14046311188247637088,\n        4826621184573936560,\n        14035285370829456768,\n        14039788970456827264,\n        14044292570084197760,\n        14048796169711568256,\n        4820779341420227104,\n        4825282941047597600,\n        14044716145511782304,\n        14049219745139152800,\n        4819085039709888928,\n        4823588639337259424,\n        14049110295060856016,\n        4819522840023076064,\n        4824026439650446560,\n        14048234694434481744,\n        4823025242528573152,\n        14049907130293000496,\n        4813290792146070912,\n        4817794391773441408,\n        4822297991400811904,\n        4826801591028182400,\n        14031581296236581120,\n        14036084895863951616,\n        14040588495491322112,\n        14045092095118692608,\n        14049595694746063104,\n        4816310881278064704,\n        4820814480905435200,\n        4825318080532805696,\n        14044575587570949920,\n        14049079187198320416,\n        4819647271473218464,\n        4824150871100588960,\n        14047985831534196944,\n        4823687947521756784,\n        14048911678691861296,\n        4820317305499054944,\n        4824820905126425440,\n        14046564289196470944,\n        4826368083625102704,\n        14038527512262317248,\n        14043031111889687744,\n        14047534711517058240,\n        4824590187556034192,\n        14047107198623306480,\n        4825445213343537712,\n        14044067056328021856,\n        14048570655955392352,\n        4821681396444930720,\n        4826184996072301216,\n        14039992212684729152,\n        14044495812312099648,\n        14048999411939470144,\n        4819966372508619552,\n        4824469972135990048,\n        14047347629463394768,\n        4824964351663361136,\n        14045990503048728160,\n        4826941869772845488,\n        14025471913555629568,\n        14029975513183000064,\n        14034479112810370560,\n        14038982712437741056,\n        14043486312065111552,\n        14047989911692482048,\n        4823679787205186576,\n        14048927999325001712,\n        4820252022966493280,\n        4824755622593863776,\n        14046776328547647312,\n        4826106953494856048,\n        14040616553304290496,\n        14045120152931660992,\n        14049623752559031488,\n        4816086418774317632,\n        4820590018401688128,\n        4825093618029058624,\n        14045473437585938208,\n        14049977037213308704,\n        4812172281421139584,\n        4816675881048510080,\n        4821179480675880576,\n        4825683080303251072,\n        14043115588489168416,\n        14047619188116538912,\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14049436434419417104,\n        4817022013937811392,\n        4821525613565181888,\n        4826029213192552384,\n        14040675525769298496,\n        14045179125396668992,\n        14049682725024039488,\n        4815051689100832320,\n        4819555288728202816,\n        4824058888355573312,\n        14048029059535872912,\n        4823460754030049520,\n        14049225328186920496,\n        4818710863797784256,\n        4823214463425154752,\n        14049577171908063568,\n        4815896114028639680,\n        4820399713656010176,\n        4824903313283380672,\n        14045953181591939360,\n        4826838453741278960,\n        14027586939948516864,\n        14032090539575887360,\n        14036594139203257856,\n        14041097738830628352,\n        14045601338457998848,\n        14050104938085369344,\n        4808155533090963712,\n        4812659132718334208,\n        4817162732345704704,\n        4821666331973075200,\n        4826169931600445696,\n        14039549778506152000,\n        14044053378133522496,\n        14048556977760892992,\n        4821454634246217504,\n        4825958233873588000,\n        14041243360321013568,\n        14045746959948384064,\n        14050250559575754560,\n        4801650488392954368,\n        4806154088020324864,\n        4810657687647695360,\n        4815161287275065856,\n        4819664886902436352,\n        4824168486529806848,\n        14047809863187405840,\n        4823899146726983664,\n        14048348542793052208,\n        4822288374117580640,\n        4826791973744951136,\n        14029637249486296320,\n        14034140849113666816,\n        14038644448741037312,\n        14043148048368407808,\n        14047651647995778304,\n        4824215577110238736,\n        14047715682026542064,\n        4824087509048711216,\n        14047971818149597104,\n        4823575236802601136,\n        14048996362641817264,\n        4819697094722520416,\n        4824200694349890912,\n        14047745447547237712,\n        4824027978007319920,\n        14048090880232379696,\n        4823319024360270688,\n        14049472610972947632,\n        4816732601509567168,\n        4821236201136937664,\n        4825739800764308160,\n        14042607231668229408,\n        14047110831295599904,\n        4825297210510595536,\n        14044377592683079904,\n        14048881192310450400,\n        4820157776047987872,\n        4824661375675358368,\n        14046824084896302800,\n        4825870703309189744,\n        14041943604836199616,\n        14046447204463570112,\n        4826344430869648208,\n        14038153784352531904,\n        14042657383979902400,\n        14047160983607272896,\n        4825196905887249552,\n        14044778811176463840,\n        14049282410803834336,\n        4818254202862473536,\n        4822757802489844032,\n        14050033832843374288,\n        4810137651433247616,\n        4814641251060618112,\n        4819144850687988608,\n        4823648450315359104,\n        14048849935616301328,\n        4820282802824584160,\n        4824786402451954656,\n        14046420824917643424,\n        4826370810415574896,\n        14037942747985118400,\n        14042446347612488896,\n        14046949947239859392,\n        4825618978622076560,\n        14043090520237155808,\n        14047594119864526304,\n        4824330633372742736,\n        14047485569501534064,\n        4824547734098727216,\n        14047051368049565104,\n        4825416137002665136,\n        14043901886714801504,\n        14048405486342172000,\n        4822060599921101472,\n        4826564199548471968,\n        14035071231330047616,\n        14039574830957418112,\n        14044078430584788608,\n        14048582030212159104,\n        4821354424441153056,\n        4825858024068523552,\n        14042045038761529152,\n        14046548638388899648,\n        4826242996944318672,\n        14038965255755168192,\n        14043468855382538688,\n        14047972455009909184,\n        4823573963081976976,\n        14048998910083065584,\n        4819686904957527136,\n        4824190504584897632,\n        14047765827077224272,\n        4823987218947346800,\n        14048172398352325936,\n        4822992951880485728,\n        14049798683452732592,\n        4813900041683514752,\n        4818403641310885248,\n        4822907240938255744,\n        14049884394394962576,\n        4812528666607835008,\n        4817032266235205504,\n        4821535865862576000,\n        4826039465489946496,\n        14040593507390145600,\n        14045097107017516096,\n        14049600706644886592,\n        4815707836134055488,\n        4820211435761425984,\n        4824715035388796480,\n        14046706293170276128,\n        4826085342162942192,\n        14040226494006180032,\n        14044730093633550528,\n        14049233693260921024,\n        4818643943205780032,\n        4823147542833150528,\n        14049644092500067792,\n        4815360749292605888,\n        4819864348919976384,\n        4824367948547346880,\n        14047410939152325776,\n        4824696994797143792,\n        14046752846652731952,\n        4826013179796331440,\n        14040803792939066048,\n        14045307392566436544,\n        14049810992193807040,\n        4813703101826323584,\n        4818206701453694080,\n        4822710301081064576,\n        14050081334252153744,\n        4808910855753862912,\n        4813414455381233408,\n        4817918055008603904,\n        4822421654635974400,\n        4826925254263344896,\n        14019854173440869376,\n        14024357773068239872,\n        14028861372695610368,\n        14033364972322980864,\n        14037868571950351360,\n        14042372171577721856,\n        14046875771205092352,\n        4825767330691610640,\n        14042497111959019488,\n        14047000711586389984,\n        4825517449929015376,\n        14043496635009400544,\n        14048000234636771040,\n        4823518403828253264,\n        14049110028590513008,\n        4819242430927737440,\n        4823746030555107936,\n        14048654775136803664,\n        4821063444742574816,\n        4825567044369945312,\n        14043298257245680800,\n        14047801856873051296,\n        4823915159355692752,\n        14048316517535634032,\n        4822416475147253344,\n        4826920074774623840,\n        14020517147997164544,\n        14025020747624535040,\n        4607182418800017408,\n        4611686018427387904,\n        4616189618054758400,\n        4620693217682128896,\n        4625196817309499392,\n        4629700416936869888,\n        4634204016564240384,\n        4638707616191610880,\n        4643211215818981376,\n        4647714815446351872,\n        4652218415073722368,\n        4656722014701092864,\n        4661225614328463360,\n        4665729213955833856,\n        4670232813583204352,\n        4674736413210574848,\n        4679240012837945344,\n        4683743612465315840,\n        4688247212092686336,\n        4692750811720056832,\n        4697254411347427328,\n        4701758010974797824,\n        4706261610602168320,\n        4710765210229538816,\n        4715268809856909312,\n        4719772409484279808,\n        4724276009111650304,\n        4728779608739020800,\n        4733283208366391296,\n        4737786807993761792,\n        4742290407621132288,\n        4746794007248502784,\n        4751297606875873280,\n        4755801206503243776,\n        4760304806130614272,\n        4764808405757984768,\n        4769312005385355264,\n        4773815605012725760,\n        4778319204640096256,\n        4782822804267466752,\n        4787326403894837248,\n        4791830003522207744,\n        4796333603149578240,\n        4800837202776948736,\n        4805340802404319232,\n        4809844402031689728,\n        4814348001659060224,\n        4818851601286430720,\n        4823355200913801216,\n        14047114265861554192,\n        4822581144727846880,\n        14047888322047508528,\n        4819484919984029536,\n        4823988519611400032,\n        14044968019164136096,\n        4825501447611219312,\n        14033497913863186816,\n        14038001513490557312,\n        14042505113117927808,\n        14047008712745298304,\n        4823003357192870432,\n        14047466109582484976,\n        4821173769844123744,\n        4825677369471494240,\n        14027586939363125760,\n        14032090538990496256,\n        14036594138617866752,\n        14041097738245237248,\n        14045601337872607744,\n        4824868128902747664,\n        14040675525856284608,\n        14045179125483655104,\n        4825290341291700304,\n        14036875614975490944,\n        14041379214602861440,\n        14045882814230231936,\n        4824586652545123472,\n        14042575487429242336,\n        14047079087056612832,\n        4822721859947612320,\n        14047747606827743088,\n        4820047780863091296,\n        4824551380490461792,\n        14042716575647889056,\n        14047220175275259552,\n        4822157507073025440,\n        14048311959702329968,\n        4816729137443056832,\n        4821232737070427328,\n        4825736336697797824,\n        14023416834127668224,\n        14027920433755038720,\n        14032424033382409216,\n        14036927633009779712,\n        14041431232637150208,\n        14045934832264520704,\n        4824534634510834704,\n        14042783559566397408,\n        14047287159193767904,\n        4821889571398992032,\n        14048579895376363376,\n        4814585652050789568,\n        4819089251678160064,\n        4823592851305530560,\n        14046550692387613984,\n        4823918774387741424,\n        14045247000058770528,\n        4825222466716584880,\n        14037840823345586880,\n        14042344422972957376,\n        14046848022600327872,\n        4823500659343276688,\n        14046823349002603248,\n        4823550006538725936,\n        14046722071454832480,\n        4823747395320522928,\n        14045932516327644512,\n        4824536950447710896,\n        14042774295818892640,\n        14047277895446263136,\n        4821926626389011104,\n        14048542840386344304,\n        4814882091970942144,\n        4819385691598312640,\n        4823889291225683136,\n        14045364932707003680,\n        4825104534068351728,\n        14038784284531452096,\n        14043287884158822592,\n        14047791483786193088,\n        4819872273029291296,\n        4824375872656661792,\n        14043418606983089056,\n        14047922206610459552,\n        4819349381732225440,\n        4823852981359595936,\n        14045510172171352480,\n        4824959294604002928,\n        14039946200246242496,\n        14044449799873612992,\n        14048953399500983488,\n        4807850070865504512,\n        4812353670492875008,\n        4816857270120245504,\n        4821360869747616000,\n        14049108597027739408,\n        4800016192451673088,\n        4804519792079043584,\n        4809023391706414080,\n        4813526991333784576,\n        4818030590961155072,\n        4822534190588525568,\n        14047935276186829840,\n        4819297103426744288,\n        4823800703054114784,\n        14045719285393277088,\n        4824750181382078320,\n        14041619106021639360,\n        14046122705649009856,\n        4824346761126345552,\n        14043535053104354016,\n        14048038652731724512,\n        4818883597247165600,\n        4823387196874536096,\n        14047050273940084432,\n        4822837112413725920,\n        14047632354361629488,\n        4820508790727545696,\n        4825012390354916192,\n        14039521434238936384,\n        14044025033866306880,\n        14048528633493677376,\n        4814995747112277568,\n        4819499346739648064,\n        4824002946367018560,\n        14044910312141661984,\n        4825559154633693424,\n        14031932764120736512,\n        14036436363748107008,\n        14040939963375477504,\n        14045443563002848000,\n        4825025903772507408,\n        14039413326898206656,\n        14043916926525577152,\n        14048420526152947648,\n        4815860605838115392,\n        4820364205465485888,\n        4824867805092856384,\n        14040678116335414848,\n        14045181715962785344,\n        4825287750812570064,\n        14036917062641574784,\n        14041420662268945280,\n        14045924261896315776,\n        4824545204879039632,\n        14042741278093577696,\n        14047244877720948192,\n        4822058697290270880,\n        14048410769485084528,\n        4815938659181020352,\n        4820442258808390848,\n        4824945858435761344,\n        14040053689592175168,\n        14044557289219545664,\n        14049060888846916160,\n        4803480021186998784,\n        4807983620814369280,\n        4812487220441739776,\n        4816990820069110272,\n        4821494419696480768,\n        14048975047078874640,\n        4807157348372987648,\n        4811660948000358144,\n        4816164547627728640,\n        4820668147255099136,\n        4825171746882469632,\n        14038246582018508864,\n        14042750181645879360,\n        14047253781273249856,\n        4822023083081064224,\n        14048446383694291184,\n        4815653745507367104,\n        4820157345134737600,\n        4824660944762108096,\n        14042278318561303840,\n        14046781918188674336,\n        4823632868166583760,\n        14046390624943401184,\n        4824078841831954224,\n        14044606730281919328,\n        14049110329909289824,\n        4799794383613219840,\n        4804297983240590336,\n        4808801582867960832,\n        4813305182495331328,\n        4817808782122701824,\n        4822312381750072320,\n        14048157085025283088,\n        4817968134859431872,\n        4822471734486802368,\n        14047997732288553040,\n        4819047279019851488,\n        4823550878647221984,\n        14046718583020848288,\n        4823750883754507120,\n        14045918562591707744,\n        4824550904183647664,\n        14042718480875145568,\n        14047222080502516064,\n        4822149886163999392,\n        14048319580611356016,\n        4816668170170848448,\n        4821171769798218944,\n        4825675369425589440,\n        14027714942301032960,\n        14032218541928403456,\n    ],\n    slow_two_pow_offsets: [0, 256, 512, 768, 1024, 1280, 1536, 1792],\n    profiles: [\n        ProfileEntry {\n            np: 4,\n            bits: 84,\n            bn_bound: 2536637511,\n            to_ffts: Some(MPNToFFTFunc { np: 4, bits: 84 }),\n        },\n        ProfileEntry {\n            np: 4,\n            bits: 88,\n            bn_bound: 10380583,\n            to_ffts: Some(MPNToFFTFunc { np: 4, bits: 88 }),\n        },\n        ProfileEntry {\n            np: 4,\n            bits: 92,\n            bn_bound: 42390,\n            to_ffts: Some(MPNToFFTFunc { np: 4, bits: 92 }),\n        },\n        ProfileEntry {\n            np: 5,\n            bits: 112,\n            bn_bound: 32822700,\n            to_ffts: Some(MPNToFFTFunc { np: 5, bits: 112 }),\n        },\n        ProfileEntry {\n            np: 5,\n            bits: 116,\n            bn_bound: 132790,\n            to_ffts: Some(MPNToFFTFunc { np: 5, bits: 116 }),\n        },\n        ProfileEntry {\n            np: 5,\n            bits: 120,\n            bn_bound: 534,\n            to_ffts: Some(MPNToFFTFunc { np: 5, bits: 120 }),\n        },\n        ProfileEntry {\n            np: 6,\n            bits: 136,\n            bn_bound: 144789875,\n            to_ffts: Some(MPNToFFTFunc { np: 6, bits: 136 }),\n        },\n        ProfileEntry {\n            np: 6,\n            bits: 140,\n            bn_bound: 582218,\n            to_ffts: Some(MPNToFFTFunc { np: 6, bits: 140 }),\n        },\n        ProfileEntry {\n            np: 6,\n            bits: 144,\n            bn_bound: 2337,\n            to_ffts: Some(MPNToFFTFunc { np: 6, bits: 144 }),\n        },\n        ProfileEntry {\n            np: 7,\n            bits: 160,\n            bn_bound: 613493872,\n            to_ffts: Some(MPNToFFTFunc { np: 7, bits: 160 }),\n        },\n        ProfileEntry {\n            np: 7,\n            bits: 164,\n            bn_bound: 2456369,\n            to_ffts: Some(MPNToFFTFunc { np: 7, bits: 164 }),\n        },\n        ProfileEntry {\n            np: 7,\n            bits: 168,\n            bn_bound: 9826,\n            to_ffts: Some(MPNToFFTFunc { np: 7, bits: 168 }),\n        },\n        ProfileEntry {\n            np: 8,\n            bits: 184,\n            bn_bound: 2177184315,\n            to_ffts: Some(MPNToFFTFunc { np: 8, bits: 184 }),\n        },\n        ProfileEntry {\n            np: 8,\n            bits: 188,\n            bn_bound: 8689506,\n            to_ffts: Some(MPNToFFTFunc { np: 8, bits: 188 }),\n        },\n        ProfileEntry {\n            np: 8,\n            bits: 192,\n            bn_bound: 34662,\n            to_ffts: Some(MPNToFFTFunc { np: 8, bits: 192 }),\n        },\n        ProfileEntry {\n            np: 0,\n            bits: 0,\n            bn_bound: 0,\n            to_ffts: None,\n        },\n        ProfileEntry {\n            np: 0,\n            bits: 0,\n            bn_bound: 0,\n            to_ffts: None,\n        },\n        ProfileEntry {\n            np: 0,\n            bits: 0,\n            bn_bound: 0,\n            to_ffts: None,\n        },\n        ProfileEntry {\n            np: 0,\n            bits: 0,\n            bn_bound: 0,\n            to_ffts: None,\n        },\n        ProfileEntry {\n            np: 0,\n            bits: 0,\n            bn_bound: 0,\n            to_ffts: None,\n        },\n    ],\n    profiles_size: 15,\n    buffer_alloc: 0,\n};}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/fft.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright © 2022 Daniel Schultz\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(feature = \"32_bit_limbs\")]\nuse crate::natural::arithmetic::add::add_with_carry_limb;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse crate::natural::arithmetic::add::limbs_slice_add_same_length_in_place_left;\nuse crate::natural::arithmetic::mul::context::CONTEXT;\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::arithmetic::sub::limbs_sub_limb_in_place;\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::{self, *};\nuse core::cmp::{max, min};\nuse core::fmt::Debug;\nuse malachite_base::fail_on_untested_path;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::arithmetic::traits::ShrRound;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, DivRound, ModInverse, ModPow, OverflowingAddAssign, OverflowingSubAssign,\n    Parity, PowerOf2, RoundToMultiple, RoundToMultipleOfPowerOf2, WrappingAddAssign,\n    WrappingSubAssign, XMulYToZZ, XXAddYYToZZ, XXXAddYYYToZZZ, XXXXAddYYYYToZZZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::{ExactFrom, SplitInHalf};\nuse malachite_base::num::logic::traits::{LeadingZeros, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse wide::{f64x4, f64x8, u64x4};\n\n// This is nmod_t from flint.h, FLINT 3.3.0-dev.\n#[derive(Debug, Default, Clone, Eq, PartialEq)]\npub(crate) struct ModData {\n    pub(crate) n: u64,\n    pub(crate) ninv: u64,\n    pub(crate) norm: u64,\n}\n\nconst SD_FFT_CTX_W2TAB_SIZE: usize = 40;\npub(crate) const SD_FFT_CTX_W2TAB_INIT: u64 = 12;\n\n#[derive(Debug, Eq, PartialEq)]\npub(crate) struct SerializedFFTContext {\n    pub(crate) p: u64,\n    pub(crate) pinv: u64,\n    pub(crate) mod_data: ModData,\n    pub(crate) primitive_root: u64,\n    pub(crate) w2tab_depth: u64,\n    pub(crate) w2tab_backing: [u64; 4096],\n    pub(crate) w2tab_offsets: [usize; SD_FFT_CTX_W2TAB_SIZE],\n}\n\nimpl SerializedFFTContext {\n    fn deserialize(self) -> FFTContext {\n        FFTContext {\n            p: f64::from_bits(self.p),\n            pinv: f64::from_bits(self.pinv),\n            mod_data: self.mod_data,\n            primitive_root: self.primitive_root,\n            w2tab_depth: self.w2tab_depth,\n            w2tab_backing: self.w2tab_backing.into_iter().map(f64::from_bits).collect(),\n            w2tab_offsets: self.w2tab_offsets,\n        }\n    }\n}\n\n// This is sd_fft_ctx_struct from fft_small.h, FLINT 3.3.0-dev.\n#[derive(Clone, Debug, PartialEq)]\npub(crate) struct FFTContext {\n    pub(crate) p: f64,\n    pub(crate) pinv: f64,\n    pub(crate) mod_data: ModData,\n    pub(crate) primitive_root: u64,\n    pub(crate) w2tab_depth: u64,\n    pub(crate) w2tab_backing: Vec<f64>,\n    pub(crate) w2tab_offsets: [usize; SD_FFT_CTX_W2TAB_SIZE],\n}\n\nimpl Default for FFTContext {\n    fn default() -> Self {\n        Self {\n            p: 0.0,\n            pinv: 0.0,\n            mod_data: ModData::default(),\n            primitive_root: 0,\n            w2tab_depth: 0,\n            w2tab_backing: Vec::new(),\n            w2tab_offsets: [0; SD_FFT_CTX_W2TAB_SIZE],\n        }\n    }\n}\n\nmacro_rules! w2tab {\n    ($q: expr, $i: expr, $j: expr) => {\n        $q.w2tab_backing[$q.w2tab_offsets[$i] + $j]\n    };\n}\n\n#[derive(Debug, Eq, PartialEq)]\npub(crate) struct SerializedCRTData {\n    pub(crate) prime: u64,\n    pub(crate) coeff_len: usize,\n    pub(crate) nprimes: usize,\n}\n\nimpl SerializedCRTData {\n    fn deserialize(self, data: &[u64]) -> CRTData {\n        CRTData {\n            prime: self.prime,\n            coeff_len: self.coeff_len,\n            nprimes: self.nprimes,\n            data: data.to_vec(),\n        }\n    }\n}\n\n// This is crt_data_struct from fft_small.h, FLINT 3.3.0-dev.\n#[derive(Debug, Default, Clone, Eq, PartialEq)]\npub(crate) struct CRTData {\n    pub(crate) prime: u64,\n    pub(crate) coeff_len: usize,\n    pub(crate) nprimes: usize,\n    pub(crate) data: Vec<u64>,\n}\n\nimpl CRTData {\n    // This is crt_data_co_prime_red from fft_small.h, FLINT 3.3.0-dev, read-only.\n    #[inline]\n    fn co_prime_red(&self, i: usize) -> u64 {\n        assert!(i < self.nprimes);\n        self.data[self.nprimes * self.coeff_len + self.coeff_len + i]\n    }\n\n    // return mpn of length C->coeff_len\n    //\n    // This is crt_data_co_prime from fft_small.h, FLINT 3.3.0-dev, read-only.\n    #[inline]\n    pub(crate) fn co_prime(&mut self, i: usize) -> &mut [u64] {\n        assert!(i < self.nprimes);\n        &mut self.data[i * self.coeff_len..]\n    }\n\n    #[inline]\n    fn prod_primes_ref(&self) -> &[u64] {\n        &self.data[self.nprimes * self.coeff_len..]\n    }\n}\n\n// This is profile_entry_struct from fft_small.h, FLINT 3.3.0-dev.\n#[derive(Debug, Default, Clone, Eq, PartialEq)]\npub(crate) struct ProfileEntry {\n    pub(crate) np: usize,\n    pub(crate) bits: u64,\n    pub(crate) bn_bound: usize,\n    pub(crate) to_ffts: Option<MPNToFFTFunc>,\n}\n\npub(crate) const MPN_CTX_NCRTS: usize = 8;\npub(crate) const VEC_SZ: usize = 4;\npub(crate) const MAX_NPROFILES: usize = 20;\n\npub_test_struct! {\n    #[derive(Debug, Eq, PartialEq)]\n    SerializedContext {\n    pub(crate) ffts: [SerializedFFTContext; MPN_CTX_NCRTS],\n    pub(crate) crts: [SerializedCRTData; MPN_CTX_NCRTS],\n    pub(crate) crts_data_0: [u64; 3],\n    pub(crate) crts_data_1: [u64; 8],\n    pub(crate) crts_data_2: [u64; 15],\n    pub(crate) crts_data_3: [u64; 24],\n    pub(crate) crts_data_4: [u64; 29],\n    pub(crate) crts_data_5: [u64; 41],\n    pub(crate) crts_data_6: [u64; 55],\n    pub(crate) crts_data_7: [u64; 71],\n    pub(crate) vec_two_pow_tab_backing: [[u64; 4]; 768],\n    pub(crate) vec_two_pow_tab_offsets: [usize; MPN_CTX_NCRTS.div_ceil(VEC_SZ)],\n    pub(crate) slow_two_pow_backing: [u64; 1 << 11],\n    pub(crate) slow_two_pow_offsets: [usize; MPN_CTX_NCRTS],\n    pub(crate) profiles: [ProfileEntry; MAX_NPROFILES],\n    pub(crate) profiles_size: usize,\n    pub(crate) buffer_alloc: usize,\n}}\n\nimpl SerializedContext {\n    pub_test! {deserialize(self) -> Context {\n        let [f0, f1, f2, f3, f4, f5, f6, f7] = self.ffts;\n        let [c0, c1, c2, c3, c4, c5, c6, c7] = self.crts;\n        Context {\n            ffts: [\n                f0.deserialize(),\n                f1.deserialize(),\n                f2.deserialize(),\n                f3.deserialize(),\n                f4.deserialize(),\n                f5.deserialize(),\n                f6.deserialize(),\n                f7.deserialize(),\n            ],\n            crts: [\n                c0.deserialize(&self.crts_data_0),\n                c1.deserialize(&self.crts_data_1),\n                c2.deserialize(&self.crts_data_2),\n                c3.deserialize(&self.crts_data_3),\n                c4.deserialize(&self.crts_data_4),\n                c5.deserialize(&self.crts_data_5),\n                c6.deserialize(&self.crts_data_6),\n                c7.deserialize(&self.crts_data_7),\n            ],\n            vec_two_pow_tab_backing: self\n                .vec_two_pow_tab_backing\n                .into_iter()\n                .map(|[u0, u1, u2, u3]| {\n                    f64x4::from([\n                        f64::from_bits(u0),\n                        f64::from_bits(u1),\n                        f64::from_bits(u2),\n                        f64::from_bits(u3),\n                    ])\n                })\n                .collect(),\n            vec_two_pow_tab_offsets: self.vec_two_pow_tab_offsets,\n            slow_two_pow_backing: self\n                .slow_two_pow_backing\n                .into_iter()\n                .map(f64::from_bits)\n                .collect(),\n            slow_two_pow_offsets: self.slow_two_pow_offsets,\n            profiles: self.profiles,\n            profiles_size: self.profiles_size,\n            buffer: Vec::new(),\n            buffer_alloc: self.buffer_alloc,\n        }\n    }}\n}\n\n// This is mpn_ctx_struct from fft_small.h, FLINT 3.3.0-dev.\npub_test_struct! {\n    #[derive(Debug, Default, Clone, PartialEq)]\nContext {\n    pub(crate) ffts: [FFTContext; MPN_CTX_NCRTS],\n    pub(crate) crts: [CRTData; MPN_CTX_NCRTS],\n    pub(crate) vec_two_pow_tab_backing: Vec<f64x4>,\n    pub(crate) vec_two_pow_tab_offsets: [usize; MPN_CTX_NCRTS.div_ceil(VEC_SZ)],\n    pub(crate) slow_two_pow_backing: Vec<f64>,\n    pub(crate) slow_two_pow_offsets: [usize; MPN_CTX_NCRTS],\n    pub(crate) profiles: [ProfileEntry; MAX_NPROFILES],\n    pub(crate) profiles_size: usize,\n    pub(crate) buffer: Vec<f64>,\n    pub(crate) buffer_alloc: usize,\n}}\n\n// This is vec1d_reduce_pm1n_to_pmhn from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64_reduce_pm1n_to_pmhn {\n    ($a: expr, $n: expr) => {{\n        let a = $a;\n        let n = $n;\n        let halfn = 0.5 * n;\n        if a > halfn {\n            a - n\n        } else {\n            let t = a + n;\n            if t < halfn { t } else { a }\n        }\n    }};\n}\n#[cfg(feature = \"test_build\")]\npub(crate) use f64_reduce_pm1n_to_pmhn;\n\n// This is vec4d_reduce_pm1n_to_pmhn from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_reduce_pm1n_to_pmhn {\n    ($a: expr, $n: expr) => {{\n        let [a0, a1, a2, a3] = $a.to_array();\n        let [n0, n1, n2, n3] = $n.to_array();\n        f64x4::from([\n            f64_reduce_pm1n_to_pmhn!(a0, n0),\n            f64_reduce_pm1n_to_pmhn!(a1, n1),\n            f64_reduce_pm1n_to_pmhn!(a2, n2),\n            f64_reduce_pm1n_to_pmhn!(a3, n3),\n        ])\n    }};\n}\n\n// This is vec8d_reduce_pm1n_to_pmhn from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x8_reduce_pm1n_to_pmhn {\n    ($a: expr, $n: expr) => {{\n        let [a0, a1, a2, a3, a4, a5, a6, a7] = $a.to_array();\n        let [n0, n1, n2, n3, n4, n5, n6, n7] = $n.to_array();\n        f64x8::from([\n            f64_reduce_pm1n_to_pmhn!(a0, n0),\n            f64_reduce_pm1n_to_pmhn!(a1, n1),\n            f64_reduce_pm1n_to_pmhn!(a2, n2),\n            f64_reduce_pm1n_to_pmhn!(a3, n3),\n            f64_reduce_pm1n_to_pmhn!(a4, n4),\n            f64_reduce_pm1n_to_pmhn!(a5, n5),\n            f64_reduce_pm1n_to_pmhn!(a6, n6),\n            f64_reduce_pm1n_to_pmhn!(a7, n7),\n        ])\n    }};\n}\n\n// [0,n] -> [-n/2, n/2]\n//\n// This is f64_reduce_0n_to_pmhn from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64_reduce_0n_to_pmhn {\n    ($a: expr, $n: expr) => {{\n        let a = $a;\n        let n = $n;\n        if a > 0.5 * n { a - n } else { a }\n    }};\n}\n#[cfg(feature = \"test_build\")]\npub(crate) use f64_reduce_0n_to_pmhn;\n\n// return a mod n in [0,n) assuming a in (-n,n)\n//\n// This is vec1d_reduce_pm1no_to_0n from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64_reduce_pm1no_to_0n {\n    ($a: expr, $n: expr) => {{\n        let a = $a;\n        if a >= 0.0 { a } else { a + $n }\n    }};\n}\n\n// return a mod n in [0,n) assuming a in (-n,n)\n//\n// This is vec4d_reduce_pm1no_to_0n from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_reduce_pm1no_to_0n {\n    ($a: expr, $n: expr) => {{\n        let [a0, a1, a2, a3] = $a.to_array();\n        let [n0, n1, n2, n3] = $n.to_array();\n        f64x4::from([\n            f64_reduce_pm1no_to_0n!(a0, n0),\n            f64_reduce_pm1no_to_0n!(a1, n1),\n            f64_reduce_pm1no_to_0n!(a2, n2),\n            f64_reduce_pm1no_to_0n!(a3, n3),\n        ])\n    }};\n}\n\nmacro_rules! f64x4_round {\n    ($x: expr) => {{\n        let [x0, x1, x2, x3] = $x.to_array();\n        f64x4::from([round_even!(x0), round_even!(x1), round_even!(x2), round_even!(x3)])\n    }};\n}\n\nmacro_rules! f64x8_round {\n    ($x: expr) => {{\n        let [x0, x1, x2, x3, x4, x5, x6, x7] = $x.to_array();\n        f64x8::from([\n            round_even!(x0),\n            round_even!(x1),\n            round_even!(x2),\n            round_even!(x3),\n            round_even!(x4),\n            round_even!(x5),\n            round_even!(x6),\n            round_even!(x7),\n        ])\n    }};\n}\n\n// In this case f64x4::mul_add is not perfectly accurate, so we must fall back to a slower, more\n// accurate implementation\n#[cfg(not(any(\n    all(\n        target_feature = \"fma\",\n        any(target_arch = \"x86\", target_arch = \"x86_64\")\n    ),\n    all(target_feature = \"neon\", target_arch = \"aarch64\")\n)))]\nmacro_rules! f64x4_mul_add {\n    ($a: expr, $b: expr, $c: expr) => {{\n        let [a0, a1, a2, a3] = $a.to_array();\n        let [b0, b1, b2, b3] = $b.to_array();\n        let [c0, c1, c2, c3] = $c.to_array();\n        f64x4::from([fma!(a0, b0, c0), fma!(a1, b1, c1), fma!(a2, b2, c2), fma!(a3, b3, c3)])\n    }};\n}\n\n#[cfg(any(\n    all(\n        target_feature = \"fma\",\n        any(target_arch = \"x86\", target_arch = \"x86_64\")\n    ),\n    all(target_feature = \"neon\", target_arch = \"aarch64\")\n))]\nmacro_rules! f64x4_mul_add {\n    ($a: expr, $b: expr, $c: expr) => {{ $a.mul_add($b, $c) }};\n}\n#[cfg(feature = \"test_build\")]\npub(crate) use f64x4_mul_add;\n\n// In this case f64x8::mul_add is not perfectly accurate, so we must fall back to a slower, more\n// accurate implementation\n#[cfg(not(any(\n    all(\n        target_feature = \"fma\",\n        any(target_arch = \"x86\", target_arch = \"x86_64\")\n    ),\n    all(target_feature = \"neon\", target_arch = \"aarch64\")\n)))]\nmacro_rules! f64x8_mul_add {\n    ($a: expr, $b: expr, $c: expr) => {{\n        let [a0, a1, a2, a3, a4, a5, a6, a7] = $a.to_array();\n        let [b0, b1, b2, b3, b4, b5, b6, b7] = $b.to_array();\n        let [c0, c1, c2, c3, c4, c5, c6, c7] = $c.to_array();\n        f64x8::from([\n            fma!(a0, b0, c0),\n            fma!(a1, b1, c1),\n            fma!(a2, b2, c2),\n            fma!(a3, b3, c3),\n            fma!(a4, b4, c4),\n            fma!(a5, b5, c5),\n            fma!(a6, b6, c6),\n            fma!(a7, b7, c7),\n        ])\n    }};\n}\n\n#[cfg(any(\n    all(\n        target_feature = \"fma\",\n        any(target_arch = \"x86\", target_arch = \"x86_64\")\n    ),\n    all(target_feature = \"neon\", target_arch = \"aarch64\")\n))]\nmacro_rules! f64x8_mul_add {\n    ($a: expr, $b: expr, $c: expr) => {{ $a.mul_add($b, $c) }};\n}\n\n// return a mod n in (-n,n)\n//\n// This is vec4d_reduce_to_pm1no from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_reduce_to_pm1no {\n    ($a: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        f64x4_mul_add!(-f64x4_round!(a * $ninv), $n, a)\n    }};\n}\n\n// return a mod n in (-n,n)\n//\n// This is vec1d_reduce_to_pm1no from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64_reduce_to_pm1no {\n    ($a: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        fma!(-round_even!(a * $ninv), $n, a)\n    }};\n}\n\n// return a mod n in [0,n)\n//\n// This is vec4d_reduce_to_0n from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_reduce_to_0n {\n    ($a: expr, $n: expr, $ninv: expr) => {{\n        let n = $n;\n        f64x4_reduce_pm1no_to_0n!(f64x4_reduce_to_pm1no!($a, n, $ninv), n)\n    }};\n}\n\n// return a mod n in [0,n)\n//\n// This is vec1d_reduce_to_0n from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64_reduce_to_0n {\n    ($a: expr, $n: expr, $ninv: expr) => {{\n        let n = $n;\n        f64_reduce_pm1no_to_0n!(f64_reduce_to_pm1no!($a, n, $ninv), n)\n    }};\n}\n\n// This is vec1d_mulmod from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64_mulmod {\n    ($a: expr, $b: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        let b = $b;\n        let h = a * b;\n        fma!(-round_even!(h * $ninv), $n, h) - fma!(-a, b, h)\n    }};\n}\n#[cfg(feature = \"test_build\")]\npub(crate) use f64_mulmod;\n\n// This is vec4d_mulmod from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_mulmod {\n    ($a: expr, $b: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        let b = $b;\n        let h = a * b;\n        f64x4_mul_add!(-f64x4_round!(h * $ninv), $n, h) - f64x4_mul_add!(-a, b, h)\n    }};\n}\n\n// This is vec8d_mulmod from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x8_mulmod {\n    ($a: expr, $b: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        let b = $b;\n        let h = a * b;\n        f64x8_mul_add!(-f64x8_round!(h * $ninv), $n, h) - f64x8_mul_add!(-a, b, h)\n    }};\n}\n\n// This is vec4d_nmulmod from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_nmulmod {\n    ($a: expr, $b: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        let b = $b;\n        let h = a * b;\n        f64x4_mul_add!(-a, b, h) - f64x4_mul_add!(-f64x4_round!(h * $ninv), $n, h)\n    }};\n}\n\n// This is vec4d_nmulmod from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x8_nmulmod {\n    ($a: expr, $b: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        let b = $b;\n        let h = a * b;\n        f64x8_mul_add!(-a, b, h) - f64x8_mul_add!(-f64x8_round!(h * $ninv), $n, h)\n    }};\n}\n\n// This is vec1d_reduce_to_pm1n from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64_reduce_to_pm1n {\n    ($a: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        fma!(-round_even!(a * $ninv), $n, a)\n    }};\n}\n\n// This is vec4d_reduce_to_pm1n from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_reduce_to_pm1n {\n    ($a: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        f64x4_mul_add!(-f64x4_round!(a * $ninv), $n, a)\n    }};\n}\n\n// This is vec8d_reduce_to_pm1n from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x8_reduce_to_pm1n {\n    ($a: expr, $n: expr, $ninv: expr) => {{\n        let a = $a;\n        f64x8_mul_add!(-f64x8_round!(a * $ninv), $n, a)\n    }};\n}\n\n// need  ceil(64 * bn / bits) <= prod_primes / 2 ^ (2 * bits) i.e. (64 * bn + bits - 1) / bits <=\n// prod_primes / 2 ^ (2 * bits) 64 * bn <= bits * prod_primes / 2 ^ (2 * bits) - (bits - 1)\n//\n// This is crt_data_find_bn_bound from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\npub(crate) fn crt_data_find_bn_bound(c: &CRTData, bits: u64) -> usize {\n    let two_bits = bits << 1;\n    let q = usize::exact_from(two_bits >> u64::LOG_WIDTH);\n    let r = two_bits & u64::WIDTH_MASK;\n    let n = c.coeff_len;\n    let n_p1 = n + 1;\n    let mut xs = [0; 8];\n    let xs = &mut xs[..n_p1];\n    xs[n] = limbs_mul_limb_to_out::<u128, u64>(xs, &c.prod_primes_ref()[..n], bits);\n    let mut bound = 0;\n    if q < n_p1 {\n        let xs_hi = &mut xs[q..];\n        if r != 0 {\n            limbs_slice_shr_in_place::<u64>(xs_hi, r);\n        }\n        if !limbs_sub_limb_in_place::<u64>(xs_hi, bits - 1) {\n            limbs_slice_shr_in_place::<u64>(xs_hi, 6);\n            bound = usize::exact_from(xs_hi[0]);\n            if xs_hi[1..].iter().any(|&x| x != 0) {\n                return usize::ONE.wrapping_neg();\n            }\n        }\n    }\n    bound\n}\n\n// need ceil(64*bn/bits) <= prod_primes/2^(2*bits). first try bits = (nbits(prod_primes) -\n// nbits(bn))/2 then adjust. also require bits > 64 for some applications below\n//\n// This is crt_data_find_bits from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn crt_data_find_bits(c: &CRTData, bn: usize) -> u64 {\n    let p_nbits = limbs_significant_bits(&c.prod_primes_ref()[..c.coeff_len]);\n    let mut bits = max(66, (p_nbits - bn.significant_bits()) >> 1);\n    if bn > crt_data_find_bn_bound(c, bits) {\n        bits -= 1;\n        while bits > 65 && bn > crt_data_find_bn_bound(c, bits) {\n            bits -= 1;\n        }\n    } else {\n        while bn <= crt_data_find_bn_bound(c, bits + 1) {\n            bits += 1;\n        }\n    }\n    bits\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\nmacro_rules! get {\n    ($a: ident, $i: expr) => {\n        $a[$i]\n    };\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nmacro_rules! get {\n    ($a: ident, $i: expr) => {{\n        let i = $i;\n        let x = $a[i >> 1];\n        if i & 1 == 0 {\n            x.lower_half()\n        } else {\n            x.upper_half()\n        }\n    }};\n}\n\n// This is CODE from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nmacro_rules! code {\n    (\n        $ir: expr,\n        $nvs: expr,\n        $np: expr,\n        $ds: ident,\n        $dstride: ident,\n        $xs: ident,\n        $ps: ident,\n        $pinvs: ident,\n        $two_pow: ident,\n        $a: ident,\n        $i: ident,\n        $bits: expr\n    ) => {\n        let mut k = (($i + $ir) * $bits) / 32;\n        let mut j = const { ($ir * $bits) % 32 };\n        $xs[..$nvs].fill(f64x4::splat(f64::from(get!($a, k) >> j)));\n        k += 1;\n        j = const { 32 - ($ir * $bits) % 32 };\n        let mut m = const { (32 - ($ir * $bits) % 32) * $nvs };\n        while j <= const { $bits - 32 } {\n            let ak = f64x4::splat(f64::from(get!($a, k)));\n            let two_pow_hi = &$two_pow[m..];\n            for l in 0..$nvs {\n                $xs[l] += f64x4_mulmod!(ak, two_pow_hi[l], $ps[l], $pinvs[l]);\n            }\n            k += 1;\n            j += 32;\n            m += const { $nvs << 5 };\n        }\n        let bmj = $bits - j;\n        if bmj != 0 {\n            let ak = f64x4::splat(f64::from(get!($a, k) << (32 - bmj)));\n            let two_pow_hi = &$two_pow[const { ($bits - 32) * $nvs }..];\n            for l in 0..$nvs {\n                $xs[l] += f64x4_mulmod!(ak, two_pow_hi[l], $ps[l], $pinvs[l]);\n            }\n        }\n        for l in 0..$nvs {\n            $xs[l] = f64x4_reduce_to_pm1n!($xs[l], $ps[l], $pinvs[l]);\n        }\n        let ds_hi = &mut $ds[$i + $ir..];\n        let mut m = 0;\n        for l in 0..$np {\n            ds_hi[m] = $xs[l >> 2].to_array()[l & 3];\n            m += $dstride;\n        }\n    };\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\nmacro_rules! get_or_default {\n    ($a: ident, $i: expr) => {\n        $a.get($i).copied().unwrap_or_default()\n    };\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nmacro_rules! get_or_default {\n    ($a: ident, $i: expr) => {{\n        let i = $i;\n        let j = i >> 1;\n        if j < $a.len() {\n            let x = $a[j];\n            if i & 1 == 0 {\n                x.lower_half()\n            } else {\n                x.upper_half()\n            }\n        } else {\n            0\n        }\n    }};\n}\n\n// This is mpn_to_ffts_hard from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nmacro_rules! mpn_to_ffts_hard {\n    (\n        $np: expr,\n        $nvs: expr,\n        $rffts: ident,\n        $ds: ident,\n        $dstride: ident,\n        $a: ident,\n        $atrunc: ident,\n        $two_pow: ident,\n        $start_hard: ident,\n        $stop_hard: ident,\n        $bits: expr\n    ) => {{\n        let mut xs = [f64x4::default(); $nvs];\n        let mut ps = [f64x4::default(); $nvs];\n        let mut pinvs = [f64x4::default(); $nvs];\n        for (i, r) in $rffts.chunks(4).enumerate() {\n            ps[i] = f64x4::new([r[0].p, r[1].p, r[2].p, r[3].p]);\n            pinvs[i] = f64x4::new([r[0].pinv, r[1].pinv, r[2].pinv, r[3].pinv]);\n        }\n        for i in $start_hard..$stop_hard {\n            let ib = i * $bits;\n            let mut k = ib >> 5;\n            let mut j = ib & 31;\n            xs[..$nvs].fill(f64x4::splat(f64::from(get_or_default!($a, k) >> j)));\n            k += 1;\n            j = 32 - j;\n            let bm32 = $bits - 32;\n            while j <= bm32 {\n                let ak = f64x4::splat(f64::from(get_or_default!($a, k)));\n                let two_pow_hi = &$two_pow[j * $nvs..];\n                for l in 0..$nvs {\n                    xs[l] += f64x4_mulmod!(ak, two_pow_hi[l], ps[l], pinvs[l]);\n                }\n                k += 1;\n                j += 32;\n            }\n            let bmj = $bits - j;\n            if bmj != 0 {\n                let ak = f64x4::splat(f64::from(get_or_default!($a, k) << (32 - bmj)));\n                let two_pow_hi = &$two_pow[bm32 * $nvs..];\n                for l in 0..$nvs {\n                    xs[l] += f64x4_mulmod!(ak, two_pow_hi[l], ps[l], pinvs[l]);\n                }\n            }\n            for l in 0..$nvs {\n                xs[l] = f64x4_reduce_to_pm1n!(xs[l], ps[l], pinvs[l]);\n            }\n            let ds_hi = &mut $ds[i..];\n            let mut m = 0;\n            for l in 0..$np {\n                ds_hi[m] = xs[l / VEC_SZ].to_array()[l % VEC_SZ];\n                m += $dstride;\n            }\n        }\n        for l in 0..$np {\n            $ds[l * $dstride..][$stop_hard..$atrunc].fill(0.0);\n        }\n    }};\n}\n\n// The tables for powers of two each have this fixed length. This has to go up linearly with the max\n// number of primes MPN_CTX_NCRTS involved in chinese remaindering. This length is checked with\n// asserts in the code.\npub(crate) const MPN_CTX_TWO_POWER_TAB_SIZE: usize = 256;\n\n#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]\npub(crate) struct MPNToFFTFunc {\n    pub(crate) np: usize,\n    pub(crate) bits: u64,\n}\n\n// The the l^th fft ctx Rffts[l] is expected to have data at d + l*dstride\n//\n// This is mpn_to_ffts from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nmacro_rules! apply_mpn_to_fft_func {\n    ($f: ident, $np: expr, $bits: expr, $nvs: expr) => {\n        fn $f(\n            rffts: &[FFTContext],\n            ds: &mut [f64],\n            dstride: usize,\n            a: &[Limb],\n            atrunc: usize,\n            two_pow: &[f64x4],\n            stop_easy: usize,\n            start_hard: usize,\n            stop_hard: usize,\n        ) {\n            let mut xs = [f64x4::default(); $nvs];\n            let mut ps = [f64x4::default(); $nvs];\n            let mut pinvs = [f64x4::default(); $nvs];\n            for (i, r) in rffts.chunks(4).enumerate() {\n                ps[i] = f64x4::from([r[0].p, r[1].p, r[2].p, r[3].p]);\n                pinvs[i] = f64x4::from([r[0].pinv, r[1].pinv, r[2].pinv, r[3].pinv]);\n            }\n            if const { $bits & 7 == 0 } {\n                assert_eq!(stop_easy & 3, 0);\n                for i in (0..stop_easy).step_by(4) {\n                    code!(\n                        0, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        1, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        2, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        3, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                }\n            } else {\n                assert_eq!(stop_easy & 7, 0);\n                for i in (0..stop_easy).step_by(8) {\n                    code!(\n                        0, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        1, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        2, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        3, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        4, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        5, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        6, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                    code!(\n                        7, $nvs, $np, ds, dstride, xs, ps, pinvs, two_pow, a, i, $bits\n                    );\n                }\n            }\n            mpn_to_ffts_hard!(\n                $np, $nvs, rffts, ds, dstride, a, atrunc, two_pow, start_hard, stop_hard, $bits\n            );\n        }\n    };\n}\n\n// nvs == np.div_ceil(4)\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_4_84, 4, 84, 1);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_4_88, 4, 88, 1);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_4_92, 4, 92, 1);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_5_112, 5, 112, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_5_116, 5, 116, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_5_120, 5, 120, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_6_136, 6, 136, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_6_140, 6, 140, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_6_144, 6, 144, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_7_160, 7, 160, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_7_164, 7, 164, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_7_168, 7, 168, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_8_184, 8, 184, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_8_188, 8, 188, 2);\napply_mpn_to_fft_func!(apply_mpn_to_fft_func_8_192, 8, 192, 2);\n\nconst LG_BLK_SZ: u64 = 8;\nconst BLK_SZ: usize = 256;\n\n// This is mpn_ctx_best_profile from fft_small/mpn_mul.c, FLINT 3.3.0-dev, returning the context.\nfn mpn_ctx_best_profile(r: &Context, p: &mut ProfileEntry, an: usize, bn: usize) {\n    // The first profile is supposed to have the biggest bn_bound. If the given bn is too large, we\n    // must fill in p.to_ffts = None because we don't have a fast mod function.\n    //\n    // We can also fill in p.to_ffts = None any time to not use the fast mod function and use the\n    // slow generic one instead.\n    const BIGGEST_BOUND: usize = CONTEXT.profiles[0].bn_bound;\n    const PROFILES_SIZE: usize = CONTEXT.profiles_size;\n    if bn > BIGGEST_BOUND {\n        p.np = 4;\n        p.bits = crt_data_find_bits(&r.crts[p.np - 1], bn);\n        p.to_ffts = None;\n        return;\n    }\n    let mut i = 0;\n    let mut best_i = 0;\n    let mut best_score = 100000000.0 * (an.checked_add(bn).unwrap() as f64);\n    loop {\n        // maximize r.profiles[i].bits\n        assert!(i < PROFILES_SIZE);\n        assert!(bn <= r.profiles[i].bn_bound);\n        while i + 1 < PROFILES_SIZE\n            && bn <= r.profiles[i + 1].bn_bound\n            && r.profiles[i + 1].np == r.profiles[i].np\n        {\n            i += 1;\n        }\n        let np = r.profiles[i].np;\n        let bits = r.profiles[i].bits as usize;\n        let alen = (an << 6).div_round(bits, Ceiling).0;\n        let blen = (bn << 6).div_round(bits, Ceiling).0;\n        let zlen = alen + blen - 1;\n        let ztrunc = zlen.round_to_multiple(BLK_SZ, Ceiling).0;\n        let depth = max(LG_BLK_SZ, ztrunc.ceiling_log_base_2());\n        let ratio = (ztrunc as f64) / (f64::power_of_2(depth));\n        let mut score = (1.0 - 0.25 * ratio) * const { 1.0 / 1000000.0 };\n        score *= (np * usize::exact_from(depth)) as f64;\n        score *= ztrunc as f64;\n        if score < best_score {\n            best_i = i;\n            best_score = score;\n        }\n        loop {\n            i += 1;\n            if i >= PROFILES_SIZE {\n                p.np = r.profiles[best_i].np;\n                p.bits = r.profiles[best_i].bits;\n                p.to_ffts = r.profiles[best_i].to_ffts;\n                return;\n            }\n            if bn <= r.profiles[i].bn_bound {\n                break;\n            }\n        }\n    }\n}\n\n// This is mpn_ctx_fit_buffer from fft_small/mpn_mul.c, FLINT 3.3.0-dev, not returning the buffer.\nfn mpn_ctx_fit_buffer(r: &mut Context, n: usize) {\n    if n > r.buffer_alloc {\n        let n = max(n, (r.buffer_alloc * 17) >> 4)\n            .round_to_multiple_of_power_of_2(12, Ceiling)\n            .0;\n        r.buffer.resize(n >> 3, 0.0);\n        r.buffer_alloc = n;\n    }\n}\n\n// This is slow_mpn_to_fft_easy from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn slow_mpn_to_fft_easy(\n    q: &FFTContext,\n    zs: &mut [f64],\n    a: &[Limb],\n    iq_stop_easy: usize,\n    bits: usize,\n    two_pow: &[f64],\n) {\n    let p = f64x8::splat(q.p);\n    let pinv = f64x8::splat(q.pinv);\n    let b2 = bits << 1;\n    let b3 = b2 + bits;\n    let b4 = b3 + bits;\n    let b5 = b4 + bits;\n    let b6 = b5 + bits;\n    let b7 = b6 + bits;\n    for iq in 0..iq_stop_easy {\n        let zi = &mut zs[iq << LG_BLK_SZ..];\n        let mut m = 0;\n        for ir in 0..const { BLK_SZ >> 3 } {\n            let mut k = iq * const { BLK_SZ >> 5 } * bits + (m >> 5);\n            let mut j = m & 31;\n            let mut ak = f64x8::from([\n                f64::from(get!(a, k) >> j),\n                f64::from(get!(a, k + bits) >> j),\n                f64::from(get!(a, k + b2) >> j),\n                f64::from(get!(a, k + b3) >> j),\n                f64::from(get!(a, k + b4) >> j),\n                f64::from(get!(a, k + b5) >> j),\n                f64::from(get!(a, k + b6) >> j),\n                f64::from(get!(a, k + b7) >> j),\n            ]);\n            let mut x = ak;\n            k += 1;\n            j = 32 - j;\n            let bm32 = bits - 32;\n            while j <= bm32 {\n                ak = f64x8::from([\n                    f64::from(get!(a, k)),\n                    f64::from(get!(a, k + bits)),\n                    f64::from(get!(a, k + b2)),\n                    f64::from(get!(a, k + b3)),\n                    f64::from(get!(a, k + b4)),\n                    f64::from(get!(a, k + b5)),\n                    f64::from(get!(a, k + b6)),\n                    f64::from(get!(a, k + b7)),\n                ]);\n                x += f64x8_mulmod!(ak, f64x8::splat(two_pow[j]), p, pinv);\n                k += 1;\n                j += 32;\n            }\n            let bmj = bits - j;\n            if bmj != 0 {\n                let shift = 32 - bmj;\n                ak = f64x8::from([\n                    f64::from(get!(a, k) << shift),\n                    f64::from(get!(a, k + bits) << shift),\n                    f64::from(get!(a, k + b2) << shift),\n                    f64::from(get!(a, k + b3) << shift),\n                    f64::from(get!(a, k + b4) << shift),\n                    f64::from(get!(a, k + b5) << shift),\n                    f64::from(get!(a, k + b6) << shift),\n                    f64::from(get!(a, k + b7) << shift),\n                ]);\n                x += f64x8_mulmod!(ak, f64x8::splat(two_pow[bm32]), p, pinv);\n            }\n            x = f64x8_reduce_to_pm1n!(x, p, pinv);\n            let [x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7] = x.to_array();\n            let zi_hi = &mut zi[ir..];\n            const B: usize = BLK_SZ >> 3;\n            zi_hi[0] = x_0;\n            zi_hi[B] = x_1;\n            zi_hi[const { 2 * B }] = x_2;\n            zi_hi[const { 3 * B }] = x_3;\n            zi_hi[const { 4 * B }] = x_4;\n            zi_hi[const { 5 * B }] = x_5;\n            zi_hi[const { 6 * B }] = x_6;\n            zi_hi[const { 7 * B }] = x_7;\n            m += bits;\n        }\n    }\n}\n\n// This is slow_mpn_to_fft from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn slow_mpn_to_fft(\n    q: &FFTContext,\n    zs: &mut [f64],\n    ztrunc: usize,\n    a: &[Limb],\n    bits: usize,\n    two_pow: &[f64],\n) {\n    let an = a.len();\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    let an = an << 1;\n    let bm32 = bits - 32;\n    // the highest index read from two_pow is bits - 32\n    assert!(bm32 < MPN_CTX_TWO_POWER_TAB_SIZE);\n    // if i*bits + 32 < 32*an, then the index into a is always in bounds\n    let i_stop_easy = min(ztrunc, ((an << 5) - 33) / bits);\n    let iq_stop_easy = i_stop_easy >> LG_BLK_SZ;\n    slow_mpn_to_fft_easy(q, zs, a, iq_stop_easy, bits, two_pow);\n    // now the hard ones\n    let p = q.p;\n    let pinv = q.pinv;\n    for iq in iq_stop_easy..ztrunc >> LG_BLK_SZ {\n        let big_i = iq << LG_BLK_SZ;\n        for (i, z) in zs[big_i..].iter_mut().enumerate().take(BLK_SZ) {\n            let n = (big_i + i) * bits;\n            let mut k = n >> 5;\n            let mut j = n & 31;\n            let mut x = f64::from(get_or_default!(a, k) >> j);\n            k += 1;\n            j = 32 - j;\n            while j <= bm32 {\n                x += f64_mulmod!(f64::from(get_or_default!(a, k)), two_pow[j], p, pinv);\n                k += 1;\n                j += 32;\n            }\n            let bmj = bits - j;\n            if bmj != 0 {\n                x += f64_mulmod!(\n                    f64::from(get_or_default!(a, k) << (32 - bmj)),\n                    two_pow[bm32],\n                    p,\n                    pinv\n                );\n            }\n            *z = f64_reduce_to_pm1n!(x, p, pinv);\n        }\n    }\n}\n\n// This is n_nbits_nz from fft_small.h, FLINT 3.3.0-dev.\nmacro_rules! n_nbits_nz {\n    ($x: expr) => {{ (LeadingZeros::leading_zeros($x) ^ const { usize::WIDTH - 1 }) + 1 }};\n}\n\n// for the fft look up of powers of w\n//\n// This is SET_J_BITS_AND_J_R from fft_small.h, FLINT 3.3.0-dev, returning j_bits and j_r.\nmacro_rules! set_j_bits_and_j_r {\n    ($j: ident, $j_bits: ident, $j_r: ident) => {\n        let ($j_bits, $j_r) = if $j == 0 {\n            (0, 0)\n        } else {\n            let j_bits = n_nbits_nz!($j);\n            (j_bits, $j - usize::power_of_2(j_bits - 1))\n        };\n    };\n}\n\n// This is  RADIX_4_FORWARD_PARAM_J_IS_Z from fft_small/sd_fft.c, FLINT 3.3.0-dev, returning iw, n,\n// and ninv.\nmacro_rules! radix_4_forward_param_j_is_z {\n    ($q: ident, $iw: ident, $n: ident, $ninv: ident) => {\n        let $iw = f64x8::splat(w2tab!($q, 1, 0));\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_4_FORWARD_MOTH_J_IS_Z from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_4_forward_moth_j_is_z {\n    (\n    $x0: ident,\n    $x1: ident,\n    $x2: ident,\n    $x3: ident,\n    $iw: ident,\n    $n: ident,\n    $ninv: ident\n) => {\n        $x0 = f64x8_reduce_to_pm1n!($x0, $n, $ninv);\n        $x2 = f64x8_reduce_to_pm1n!($x2, $n, $ninv);\n        $x3 = f64x8_reduce_to_pm1n!($x3, $n, $ninv);\n        let y0 = $x0 + $x2;\n        let y1 = f64x8_reduce_to_pm1n!($x1 + $x3, $n, $ninv);\n        let y2 = $x0 - $x2;\n        let y3 = f64x8_mulmod!($x1 - $x3, $iw, $n, $ninv);\n        $x0 = y0 + y1;\n        $x1 = y0 - y1;\n        $x2 = y2 + y3;\n        $x3 = y2 - y3;\n    };\n}\n\n// This is RADIX_4_FORWARD_PARAM_J_IS_NZ from fft_small/sd_fft.c, FLINT 3.3.0-dev, returning w, w2,\n// iw, n, and ninv.\nmacro_rules! radix_4_forward_param_j_is_nz {\n    (\n    $q: ident,\n    $j_r: ident,\n    $j_bits: ident,\n    $w: ident,\n    $w2: ident,\n    $iw: ident,\n    $n: ident,\n    $ninv: ident\n) => {\n        assert_ne!($j_bits, 0);\n        let j_bits = usize::exact_from($j_bits);\n        let j_bits_p_1 = j_bits + 1;\n        let j_2 = $j_r << 1;\n        let $w = f64x8::splat(w2tab!($q, j_bits_p_1, j_2));\n        let $w2 = f64x8::splat(w2tab!($q, j_bits, $j_r));\n        let $iw = f64x8::splat(w2tab!($q, j_bits_p_1, j_2 + 1));\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_4_FORWARD_MOTH_J_IS_NZ from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_4_forward_moth_j_is_nz {\n    (\n    $x0: ident,\n    $x1: ident,\n    $x2: ident,\n    $x3: ident,\n    $w: ident,\n    $w2: ident,\n    $iw: ident,\n    $n: ident,\n    $ninv: ident\n) => {\n        $x0 = f64x8_reduce_to_pm1n!($x0, $n, $ninv);\n        $x2 = f64x8_mulmod!($x2, $w2, $n, $ninv);\n        $x3 = f64x8_mulmod!($x3, $w2, $n, $ninv);\n        let y0 = $x0 + $x2;\n        let y1 = f64x8_mulmod!($x1 + $x3, $w, $n, $ninv);\n        let y2 = $x0 - $x2;\n        let y3 = f64x8_mulmod!($x1 - $x3, $iw, $n, $ninv);\n        $x0 = y0 + y1;\n        $x1 = y0 - y1;\n        $x2 = y2 + y3;\n        $x3 = y2 - y3;\n    };\n}\n\n// This is RADIX_2_FORWARD_PARAM_J_IS_Z from fft_small/sd_fft.c, FLINT 3.3.0-dev, returning n and\n// ninv.\nmacro_rules! radix_2_forward_param_j_is_z {\n    ($q: ident, $n: ident, $ninv: ident) => {\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_2_FORWARD_MOTH_J_IS_Z from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_2_forward_moth_j_is_z {\n    ($x0: ident, $x1: ident, $n: ident, $ninv: ident) => {\n        $x0 = f64x8_reduce_to_pm1n!($x0, $n, $ninv);\n        $x1 = f64x8_reduce_to_pm1n!($x1, $n, $ninv);\n        ($x0, $x1) = ($x0 + $x1, $x0 - $x1);\n    };\n}\n\n// This is RADIX_2_FORWARD_PARAM_J_IS_NZ from fft_small/sd_fft.c, FLINT 3.3.0-dev, returning w, n,\n// and ninv.\nmacro_rules! radix_2_forward_param_j_is_nz {\n    ($q: ident, $j_r: ident, $j_bits: ident, $w: ident, $n: ident, $ninv: ident) => {\n        let $w = f64x8::splat(w2tab!($q, usize::exact_from($j_bits), $j_r));\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_2_FORWARD_MOTH_J_IS_NZ from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_2_forward_moth_j_is_nz {\n    ($x0: ident, $x1: ident, $w: ident, $n: ident, $ninv: ident) => {\n        $x0 = f64x8_reduce_to_pm1n!($x0, $n, $ninv);\n        $x1 = f64x8_mulmod!($x1, $w, $n, $ninv);\n        ($x0, $x1) = ($x0 + $x1, $x0 - $x1);\n    };\n}\n\nconst BIG_N: usize = 8;\n\nmacro_rules! read_f64x4 {\n    ($xs: expr, $i: expr) => {{\n        let i = $i;\n        f64x4::from(&$xs[i..i + 4])\n    }};\n}\n\nmacro_rules! read_f64x8 {\n    ($xs: expr, $i: expr) => {{\n        let i = $i;\n        f64x8::from(&$xs[i..i + 8])\n    }};\n}\n\nmacro_rules! read_f64x4_w2tab {\n    ($q: expr, $i: expr, $j: expr) => {\n        read_f64x4!($q.w2tab_backing, $q.w2tab_offsets[$i] + $j)\n    };\n}\n\nmacro_rules! read_f64x8_w2tab {\n    ($q: expr, $i: expr, $j: expr) => {\n        read_f64x8!($q.w2tab_backing, $q.w2tab_offsets[$i] + $j)\n    };\n}\n\nmacro_rules! write_f64x4 {\n    ($xs: ident, $i: expr, $f: expr) => {{\n        let i = $i;\n        $xs[i..i + 4].copy_from_slice(&$f.to_array())\n    }};\n}\n\nmacro_rules! write_f64x8 {\n    ($xs: ident, $i: expr, $f: expr) => {{\n        let i = $i;\n        $xs[i..i + 8].copy_from_slice(&$f.to_array())\n    }};\n}\n\nmacro_rules! write_f64x8_w2tab {\n    ($q: expr, $i: expr, $j: expr, $f: expr) => {\n        let start = $q.w2tab_offsets[$i] + $j;\n        $q.w2tab_backing[start..start + 8].copy_from_slice(&$f.to_array());\n    };\n}\n\nmacro_rules! process_2_2 {\n    ($f: ident, $limit: expr, $x0: ident, $x1: ident, $p0: ident, $p1: ident) => {\n        for i in (0..$limit).step_by(BIG_N) {\n            let mut f0 = read_f64x8!($x0, i);\n            let mut f1 = read_f64x8!($x1, i);\n            $f!(f0, f1, $p0, $p1);\n            write_f64x8!($x0, i, f0);\n            write_f64x8!($x1, i, f1);\n        }\n    };\n}\n\nmacro_rules! process_2_3 {\n    ($f: ident, $limit: expr, $x0: ident, $x1: ident, $p0: ident, $p1: ident, $p2: ident) => {\n        for i in (0..$limit).step_by(BIG_N) {\n            let mut f0 = read_f64x8!($x0, i);\n            let mut f1 = read_f64x8!($x1, i);\n            $f!(f0, f1, $p0, $p1, $p2);\n            write_f64x8!($x0, i, f0);\n            write_f64x8!($x1, i, f1);\n        }\n    };\n}\n\nmacro_rules! process_4_3 {\n    (\n        $f: ident,\n        $limit: expr,\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $p0: ident,\n        $p1: ident,\n        $p2: ident\n    ) => {\n        for i in (0..$limit).step_by(BIG_N) {\n            let mut f0 = read_f64x8!($x0, i);\n            let mut f1 = read_f64x8!($x1, i);\n            let mut f2 = read_f64x8!($x2, i);\n            let mut f3 = read_f64x8!($x3, i);\n            $f!(f0, f1, f2, f3, $p0, $p1, $p2);\n            write_f64x8!($x0, i, f0);\n            write_f64x8!($x1, i, f1);\n            write_f64x8!($x2, i, f2);\n            write_f64x8!($x3, i, f3);\n        }\n    };\n}\n\nmacro_rules! process_4_5 {\n    (\n        $f: ident,\n        $limit: expr,\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $p0: ident,\n        $p1: ident,\n        $p2: ident,\n        $p3: ident,\n        $p4: ident\n    ) => {\n        for i in (0..$limit).step_by(BIG_N) {\n            let mut f0 = read_f64x8!($x0, i);\n            let mut f1 = read_f64x8!($x1, i);\n            let mut f2 = read_f64x8!($x2, i);\n            let mut f3 = read_f64x8!($x3, i);\n            $f!(f0, f1, f2, f3, $p0, $p1, $p2, $p3, $p4);\n            write_f64x8!($x0, i, f0);\n            write_f64x8!($x1, i, f1);\n            write_f64x8!($x2, i, f2);\n            write_f64x8!($x3, i, f3);\n        }\n    };\n}\n\n// S is stride; BLK_SZ transforms each of length 2^k\n//\n// This is sd_fft_no_trunc_block from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_no_trunc_block(q: &FFTContext, xs: &mut [f64], s: usize, k: u64, j: usize) {\n    let big_s = s << LG_BLK_SZ;\n    if k > 4 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        let shifted = s << k2;\n        let mut m = 0;\n        for _ in 0..usize::power_of_2(k2) {\n            sd_fft_no_trunc_block(q, &mut xs[m..], shifted, k1, j);\n            m += big_s;\n        }\n        // row ffts\n        let big_s = s << (k2 + LG_BLK_SZ);\n        let shifted = j << k1;\n        let mut m = 0;\n        for b in 0..usize::power_of_2(k1) {\n            sd_fft_no_trunc_block(q, &mut xs[m..], s, k2, shifted + b);\n            m += big_s;\n        }\n        return;\n    }\n    set_j_bits_and_j_r!(j, j_bits, j_r);\n    if k >= 2 {\n        let k1 = 2;\n        let k2 = k - k1;\n        let l2 = usize::power_of_2(k2);\n        let big_s_2 = s << (k2 + LG_BLK_SZ);\n        // column ffts\n        if j_bits == 0 {\n            radix_4_forward_param_j_is_z!(q, iw, n, ninv);\n            for a in 0..l2 {\n                split_into_chunks_mut!(&mut xs[a * big_s..], big_s_2, [x0, x1, x2], x3);\n                process_4_3!(\n                    radix_4_forward_moth_j_is_z,\n                    BLK_SZ,\n                    x0,\n                    x1,\n                    x2,\n                    x3,\n                    iw,\n                    n,\n                    ninv\n                );\n            }\n        } else {\n            radix_4_forward_param_j_is_nz!(q, j_r, j_bits, w, w2, iw, n, ninv);\n            for a in 0..l2 {\n                split_into_chunks_mut!(&mut xs[a * big_s..], big_s_2, [x0, x1, x2], x3);\n                process_4_5!(\n                    radix_4_forward_moth_j_is_nz,\n                    BLK_SZ,\n                    x0,\n                    x1,\n                    x2,\n                    x3,\n                    w,\n                    w2,\n                    iw,\n                    n,\n                    ninv\n                );\n            }\n        }\n        if l2 == 1 {\n            return;\n        }\n        // row ffts\n        let shifted = j << k1;\n        let mut m = 0;\n        for b in 0..usize::power_of_2(k1) {\n            sd_fft_no_trunc_block(q, &mut xs[m..], s, k2, shifted + b);\n            m += big_s_2;\n        }\n    } else if k == 1 {\n        let (x0, x1) = xs.split_at_mut(big_s);\n        if j_bits == 0 {\n            radix_2_forward_param_j_is_z!(q, n, ninv);\n            process_2_2!(radix_2_forward_moth_j_is_z, BLK_SZ, x0, x1, n, ninv);\n        } else {\n            radix_2_forward_param_j_is_nz!(q, j_r, j_bits, w, n, ninv);\n            process_2_3!(radix_2_forward_moth_j_is_nz, BLK_SZ, x0, x1, w, n, ninv);\n        }\n    }\n}\n\n// This is LENGTH4_ZERO_J from fft_small/sd_fft.c, FLINT 3.3.0-dev, for vec1d.\nmacro_rules! f64_length4_zero_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $n: expr,\n        $ninv: expr,\n        $e14: expr\n    ) => {\n        let n = $n;\n        let ninv = $ninv;\n        *$x0 = f64_reduce_to_pm1n!(*$x0, n, ninv);\n        *$x2 = f64_reduce_to_pm1n!(*$x2, n, ninv);\n        *$x3 = f64_reduce_to_pm1n!(*$x3, n, ninv);\n        let y0 = *$x0 + *$x2;\n        let y1 = f64_reduce_to_pm1n!(*$x1 + *$x3, n, ninv);\n        let y2 = *$x0 - *$x2;\n        let y3 = f64_mulmod!(*$x1 - *$x3, $e14, n, ninv);\n        *$x0 = y0 + y1;\n        *$x1 = y0 - y1;\n        *$x2 = y2 + y3;\n        *$x3 = y2 - y3;\n    };\n}\n\n// This is LENGTH4_ZERO_J from fft_small/sd_fft.c, FLINT 3.3.0-dev, for vec4d.\nmacro_rules! f64x4_length4_zero_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $n: ident,\n        $ninv: ident,\n        $e14: ident\n    ) => {\n        $x0 = f64x4_reduce_to_pm1n!($x0, $n, $ninv);\n        $x2 = f64x4_reduce_to_pm1n!($x2, $n, $ninv);\n        $x3 = f64x4_reduce_to_pm1n!($x3, $n, $ninv);\n        let y0 = $x0 + $x2;\n        let y1 = f64x4_reduce_to_pm1n!($x1 + $x3, $n, $ninv);\n        let y2 = $x0 - $x2;\n        let y3 = f64x4_mulmod!($x1 - $x3, $e14, $n, $ninv);\n        $x0 = y0 + y1;\n        $x1 = y0 - y1;\n        $x2 = y2 + y3;\n        $x3 = y2 - y3;\n    };\n}\n\n// This is LENGTH4_ANY_J from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! length4_any_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $n: ident,\n        $ninv: ident,\n        $w2: ident,\n        $w: ident,\n        $iw: ident\n    ) => {\n        $x0 = f64x4_reduce_to_pm1n!($x0, $n, $ninv);\n        $x2 = f64x4_mulmod!($x2, $w2, $n, $ninv);\n        $x3 = f64x4_mulmod!($x3, $w2, $n, $ninv);\n        let y0 = $x0 + $x2;\n        let y1 = f64x4_mulmod!($x1 + $x3, $w, $n, $ninv);\n        let y2 = $x0 - $x2;\n        let y3 = f64x4_mulmod!($x1 - $x3, $iw, $n, $ninv);\n        $x0 = y0 + y1;\n        $x1 = y0 - y1;\n        $x2 = y2 + y3;\n        $x3 = y2 - y3;\n    };\n}\n\n// This is LENGTH8_ZERO_J from fft_small/sd_fft.c, FLINT 3.3.0-dev, for vec1d.\nmacro_rules! f64_length8_zero_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $x4: ident,\n        $x5: ident,\n        $x6: ident,\n        $x7: ident,\n        $n: expr,\n        $ninv: expr,\n        $e14: expr,\n        $e18: expr,\n        $e38: expr\n    ) => {\n        let n = $n;\n        let ninv = $ninv;\n        let e14 = $e14;\n        let y0 = f64_reduce_to_pm1n!(*$x0 + *$x4, n, ninv);\n        let y1 = f64_reduce_to_pm1n!(*$x1 + *$x5, n, ninv);\n        let y2 = f64_reduce_to_pm1n!(*$x2 + *$x6, n, ninv);\n        let y3 = f64_reduce_to_pm1n!(*$x3 + *$x7, n, ninv);\n        let y4 = f64_reduce_to_pm1n!(*$x0 - *$x4, n, ninv);\n        let y5 = f64_reduce_to_pm1n!(*$x1 - *$x5, n, ninv);\n        let y6 = f64_mulmod!(e14, f64_reduce_to_pm1n!(*$x2 - *$x6, n, ninv), n, ninv);\n        let y7 = f64_mulmod!(e14, f64_reduce_to_pm1n!(*$x3 - *$x7, n, ninv), n, ninv);\n        let z0 = y0 + y2;\n        let z1 = y1 + y3;\n        let z2 = y0 - y2;\n        let z3 = f64_mulmod!(e14, y1 - y3, n, ninv);\n        let z4 = y4 + y6;\n        let z5 = f64_mulmod!($e18, y5 + y7, n, ninv);\n        let z6 = y4 - y6;\n        let z7 = f64_mulmod!($e38, y5 - y7, n, ninv);\n        *$x0 = z0 + z1;\n        *$x1 = z0 - z1;\n        *$x2 = z2 + z3;\n        *$x3 = z2 - z3;\n        *$x4 = z4 + z5;\n        *$x5 = z4 - z5;\n        *$x6 = z6 + z7;\n        *$x7 = z6 - z7;\n    };\n}\n\n// This is LENGTH8_ZERO_J from fft_small/sd_fft.c, FLINT 3.3.0-dev, for vec4d.\nmacro_rules! f64x4_length8_zero_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $x4: ident,\n        $x5: ident,\n        $x6: ident,\n        $x7: ident,\n        $n: ident,\n        $ninv: ident,\n        $e14: ident,\n        $e18: ident,\n        $e38: ident\n    ) => {\n        let y0 = f64x4_reduce_to_pm1n!($x0 + $x4, $n, $ninv);\n        let y1 = f64x4_reduce_to_pm1n!($x1 + $x5, $n, $ninv);\n        let y2 = f64x4_reduce_to_pm1n!($x2 + $x6, $n, $ninv);\n        let y3 = f64x4_reduce_to_pm1n!($x3 + $x7, $n, $ninv);\n        let y4 = f64x4_reduce_to_pm1n!($x0 - $x4, $n, $ninv);\n        let y5 = f64x4_reduce_to_pm1n!($x1 - $x5, $n, $ninv);\n        let y6 = f64x4_mulmod!($e14, f64x4_reduce_to_pm1n!($x2 - $x6, $n, $ninv), $n, $ninv);\n        let y7 = f64x4_mulmod!($e14, f64x4_reduce_to_pm1n!($x3 - $x7, $n, $ninv), $n, $ninv);\n        let z0 = y0 + y2;\n        let z1 = y1 + y3;\n        let z2 = y0 - y2;\n        let z3 = f64x4_mulmod!($e14, y1 - y3, $n, $ninv);\n        let z4 = y4 + y6;\n        let z5 = f64x4_mulmod!($e18, y5 + y7, $n, $ninv);\n        let z6 = y4 - y6;\n        let z7 = f64x4_mulmod!($e38, y5 - y7, $n, $ninv);\n        $x0 = z0 + z1;\n        $x1 = z0 - z1;\n        $x2 = z2 + z3;\n        $x3 = z2 - z3;\n        $x4 = z4 + z5;\n        $x5 = z4 - z5;\n        $x6 = z6 + z7;\n        $x7 = z6 - z7;\n    };\n}\n\n// This is LENGTH8_ANY_J from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! length8_any_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $x4: ident,\n        $x5: ident,\n        $x6: ident,\n        $x7: ident,\n        $n: ident,\n        $ninv: ident,\n        $w2: ident,\n        $w: ident,\n        $iw: ident,\n        $ww0: ident,\n        $ww1: ident,\n        $ww2: ident,\n        $ww3: ident\n    ) => {\n        $x0 = f64x4_reduce_to_pm1n!($x0, $n, $ninv);\n        $x1 = f64x4_reduce_to_pm1n!($x1, $n, $ninv);\n        $x4 = f64x4_mulmod!($x4, $w2, $n, $ninv);\n        $x5 = f64x4_mulmod!($x5, $w2, $n, $ninv);\n        $x6 = f64x4_mulmod!($x6, $w2, $n, $ninv);\n        $x7 = f64x4_mulmod!($x7, $w2, $n, $ninv);\n        let y0 = $x0 + $x4;\n        let y1 = $x1 + $x5;\n        let y2 = f64x4_mulmod!($x2 + $x6, $w, $n, $ninv);\n        let y3 = f64x4_mulmod!($x3 + $x7, $w, $n, $ninv);\n        let y4 = $x0 - $x4;\n        let y5 = $x1 - $x5;\n        let y6 = f64x4_mulmod!($x2 - $x6, $iw, $n, $ninv);\n        let y7 = f64x4_mulmod!($x3 - $x7, $iw, $n, $ninv);\n        let z0 = f64x4_reduce_to_pm1n!(y0 + y2, $n, $ninv);\n        let z1 = f64x4_mulmod!(y1 + y3, $ww0, $n, $ninv);\n        let z2 = f64x4_reduce_to_pm1n!(y0 - y2, $n, $ninv);\n        let z3 = f64x4_mulmod!(y1 - y3, $ww1, $n, $ninv);\n        let z4 = f64x4_reduce_to_pm1n!(y4 + y6, $n, $ninv);\n        let z5 = f64x4_mulmod!(y5 + y7, $ww2, $n, $ninv);\n        let z6 = f64x4_reduce_to_pm1n!(y4 - y6, $n, $ninv);\n        let z7 = f64x4_mulmod!(y5 - y7, $ww3, $n, $ninv);\n        $x0 = z0 + z1;\n        $x1 = z0 - z1;\n        $x2 = z2 + z3;\n        $x3 = z2 - z3;\n        $x4 = z4 + z5;\n        $x5 = z4 - z5;\n        $x6 = z6 + z7;\n        $x7 = z6 - z7;\n    };\n}\n\n// This is vec4d_unpack_lo_permute_0_2_1_3 from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_unpack_lo_permute_0_2_1_3 {\n    ($u: ident, $v: ident) => {{\n        let [u0, _, u2, _] = $u.to_array();\n        let [v0, _, v2, _] = $v.to_array();\n        f64x4::from([u0, u2, v0, v2])\n    }};\n}\n\n// This is vec4d_unpack_hi_permute_0_2_1_3 from machine_vectors.h, FLINT 3.3.0-dev.\nmacro_rules! f64x4_unpack_hi_permute_0_2_1_3 {\n    ($u: ident, $v: ident) => {{\n        let [_, u1, _, u3] = $u.to_array();\n        let [_, v1, _, v3] = $v.to_array();\n        f64x4::from([u1, u3, v1, v3])\n    }};\n}\n\n// view the 4 vectors as the rows of a 4x4 matrix\n//\n// This is VEC4D_TRANSPOSE from machine_vectors.h, FLINT 3.3.0-dev, modifying the vectors in place.\nmacro_rules! f64x4_transpose {\n    ($a0: ident, $a1: ident, $a2: ident, $a3: ident) => {{\n        let [a00, a01, a02, a03] = $a0.to_array();\n        let [a10, a11, a12, a13] = $a1.to_array();\n        let [a20, a21, a22, a23] = $a2.to_array();\n        let [a30, a31, a32, a33] = $a3.to_array();\n        $a0 = f64x4::from([a00, a10, a20, a30]);\n        $a1 = f64x4::from([a01, a11, a21, a31]);\n        $a2 = f64x4::from([a02, a12, a22, a32]);\n        $a3 = f64x4::from([a03, a13, a23, a33]);\n    }};\n}\n\n// This is sd_fft_basecase_0_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nconst fn sd_fft_basecase_0_1(_q: &FFTContext, _xs: &mut [f64]) {}\n\n// This is sd_fft_basecase_1_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_basecase_1_1(q: &FFTContext, xs: &mut [f64]) {\n    let n = q.p;\n    let ninv = q.pinv;\n    let x0 = f64_reduce_to_pm1n!(xs[0], n, ninv);\n    let x1 = f64_reduce_to_pm1n!(xs[1], n, ninv);\n    xs[0] = x0 + x1;\n    xs[1] = x0 - x1;\n}\n\n// This is sd_fft_basecase_2_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_basecase_2_1(q: &FFTContext, xs: &mut [f64]) {\n    if let &mut [ref mut x0, ref mut x1, ref mut x2, ref mut x3, ..] = xs {\n        f64_length4_zero_j!(x0, x1, x2, x3, q.p, q.pinv, w2tab!(q, 1, 0));\n    }\n}\n\n// This is sd_fft_basecase_3_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_basecase_3_1(q: &FFTContext, xs: &mut [f64]) {\n    if let &mut [\n        ref mut x0,\n        ref mut x1,\n        ref mut x2,\n        ref mut x3,\n        ref mut x4,\n        ref mut x5,\n        ref mut x6,\n        ref mut x7,\n        ..,\n    ] = xs\n    {\n        f64_length8_zero_j!(\n            x0,\n            x1,\n            x2,\n            x3,\n            x4,\n            x5,\n            x6,\n            x7,\n            q.p,\n            q.pinv,\n            w2tab!(q, 1, 0),\n            w2tab!(q, 2, 0),\n            w2tab!(q, 2, 1)\n        );\n    }\n}\n\n// This is sd_fft_basecase_4_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_basecase_4_1(q: &FFTContext, xs: &mut [f64]) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    // q.w2tab[0] points to consecutive entries\n    const _: () = assert!(SD_FFT_CTX_W2TAB_INIT >= 4);\n    let iw = f64x4::splat(w2tab!(q, 0, 1));\n    f64x4_length4_zero_j!(x0, x1, x2, x3, n, ninv, iw);\n    let u = read_f64x4_w2tab!(q, 0, 0);\n    let v = read_f64x4_w2tab!(q, 0, 4);\n    let w = f64x4_unpack_lo_permute_0_2_1_3!(u, v);\n    let iw = f64x4_unpack_hi_permute_0_2_1_3!(u, v);\n    f64x4_transpose!(x0, x1, x2, x3);\n    length4_any_j!(x0, x1, x2, x3, n, ninv, u, w, iw);\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n}\n\n// This is sd_fft_basecase_4_0 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_basecase_4_0(q: &FFTContext, xs: &mut [f64], j_r: usize, j_bits: u64) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    let j_bits = usize::exact_from(j_bits);\n    let w2 = f64x4::splat(w2tab!(q, j_bits, j_r));\n    let jp1 = j_bits + 1;\n    let j_2 = j_r << 1;\n    let w = f64x4::splat(w2tab!(q, jp1, j_2));\n    let iw = f64x4::splat(w2tab!(q, jp1, j_2 + 1));\n    length4_any_j!(x0, x1, x2, x3, n, ninv, w2, w, iw);\n    let jp3 = j_bits + 3;\n    let j_8 = j_r << 3;\n    let u = read_f64x4_w2tab!(q, jp3, j_8);\n    let v = read_f64x4_w2tab!(q, jp3, j_8 + 4);\n    let w2 = read_f64x4_w2tab!(q, j_bits + 2, j_r << 2);\n    let w = f64x4_unpack_lo_permute_0_2_1_3!(u, v);\n    let iw = f64x4_unpack_hi_permute_0_2_1_3!(u, v);\n    f64x4_transpose!(x0, x1, x2, x3);\n    length4_any_j!(x0, x1, x2, x3, n, ninv, w2, w, iw);\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n}\n\n// The length 32 transform can be broken up as\n// - 8 transforms of length 4 within columns, followed by 4 transforms of length 8 in the rows, or\n// - 4 transforms of length 8 within columns, followed by 8 transforms of length 4 in the rows\n// Since the length 16 basecase is missing the final 4x4 transpose, so the output is worse than\n// bit-reversed. If the length 32 transform used a order different from 16's, then we will have a\n// problem at a higher level since it would be difficult to keep track of what basecase happened to\n// have be used. Therefore, the length 16 and 32 basecases should produce the same order, and this\n// is easier with (b).\n//\n// This is sd_fft_basecase_5_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_basecase_5_1(q: &FFTContext, xs: &mut [f64]) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    let mut x4 = read_f64x4!(xs, 16);\n    let mut x5 = read_f64x4!(xs, 20);\n    let mut x6 = read_f64x4!(xs, 24);\n    let mut x7 = read_f64x4!(xs, 28);\n    let q00 = w2tab!(q, 0, 0);\n    let q10 = w2tab!(q, 1, 0);\n    let q20 = w2tab!(q, 2, 0);\n    let q21 = w2tab!(q, 2, 1);\n    let ww1 = f64x4::splat(q10);\n    let www2 = f64x4::splat(q20);\n    let www3 = f64x4::splat(q21);\n    f64x4_length8_zero_j!(x0, x1, x2, x3, x4, x5, x6, x7, n, ninv, ww1, www2, www3);\n    f64x4_transpose!(x0, x1, x2, x3);\n    f64x4_transpose!(x4, x5, x6, x7);\n    // j = 0, 1, 2, 3\n    let mut w0 = f64x4::from([q00, q10, q20, q21]);\n    let mut ww0 = f64x4::from([q00, q20, w2tab!(q, 3, 0), w2tab!(q, 3, 2)]);\n    let mut ww1 = f64x4::from([q10, q21, w2tab!(q, 3, 1), w2tab!(q, 3, 3)]);\n    length4_any_j!(x0, x1, x2, x3, n, ninv, w0, ww0, ww1);\n    // j = 4, 5, 6, 7\n    w0 = f64x4::from([w2tab!(q, 3, 0), w2tab!(q, 3, 1), w2tab!(q, 3, 2), w2tab!(q, 3, 3)]);\n    let u = read_f64x4_w2tab!(q, 4, 0);\n    let v = read_f64x4_w2tab!(q, 4, 4);\n    ww0 = f64x4_unpack_lo_permute_0_2_1_3!(u, v);\n    ww1 = f64x4_unpack_hi_permute_0_2_1_3!(u, v);\n    length4_any_j!(x4, x5, x6, x7, n, ninv, w0, ww0, ww1);\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n    write_f64x4!(xs, 16, x4);\n    write_f64x4!(xs, 20, x5);\n    write_f64x4!(xs, 24, x6);\n    write_f64x4!(xs, 28, x7);\n}\n\n// This is sd_fft_basecase_5_0 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_basecase_5_0(q: &FFTContext, xs: &mut [f64], j_r: usize, j_bits: u64) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    let mut x4 = read_f64x4!(xs, 16);\n    let mut x5 = read_f64x4!(xs, 20);\n    let mut x6 = read_f64x4!(xs, 24);\n    let mut x7 = read_f64x4!(xs, 28);\n    let j_bits = usize::exact_from(j_bits);\n    let w0 = f64x4::splat(w2tab!(q, j_bits, j_r));\n    let jp1 = j_bits + 1;\n    let j_2 = j_r << 1;\n    let ww0 = f64x4::splat(w2tab!(q, jp1, j_2));\n    let ww1 = f64x4::splat(w2tab!(q, jp1, j_2 + 1));\n    let jp2 = j_bits + 2;\n    let j_4 = j_r << 2;\n    let www0 = f64x4::splat(w2tab!(q, jp2, j_4));\n    let www1 = f64x4::splat(w2tab!(q, jp2, j_4 + 1));\n    let www2 = f64x4::splat(w2tab!(q, jp2, j_4 + 2));\n    let www3 = f64x4::splat(w2tab!(q, jp2, j_4 + 3));\n    length8_any_j!(\n        x0, x1, x2, x3, x4, x5, x6, x7, n, ninv, w0, ww0, ww1, www0, www1, www2, www3\n    );\n    f64x4_transpose!(x0, x1, x2, x3);\n    f64x4_transpose!(x4, x5, x6, x7);\n    // j = 8*j+0, 8*j+1, 8*j+2, 8*j+3\n    let jp3 = j_bits + 3;\n    let jp4 = j_bits + 4;\n    let j_8 = j_r << 3;\n    let w0 = read_f64x4_w2tab!(q, jp3, j_8);\n    let sixteen_j = j_r << 4;\n    let u = read_f64x4_w2tab!(q, jp4, sixteen_j);\n    let v = read_f64x4_w2tab!(q, jp4, sixteen_j + 4);\n    let ww0 = f64x4_unpack_lo_permute_0_2_1_3!(u, v);\n    let ww1 = f64x4_unpack_hi_permute_0_2_1_3!(u, v);\n    length4_any_j!(x0, x1, x2, x3, n, ninv, w0, ww0, ww1);\n    // j = 8*j+4, 8*j+5, 8*j+6, 8*j+7\n    let w0 = read_f64x4_w2tab!(q, jp3, j_8 + 4);\n    let u = read_f64x4_w2tab!(q, jp4, sixteen_j + 8);\n    let v = read_f64x4_w2tab!(q, jp4, sixteen_j + 12);\n    let ww0 = f64x4_unpack_lo_permute_0_2_1_3!(u, v);\n    let ww1 = f64x4_unpack_hi_permute_0_2_1_3!(u, v);\n    length4_any_j!(x4, x5, x6, x7, n, ninv, w0, ww0, ww1);\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n    write_f64x4!(xs, 16, x4);\n    write_f64x4!(xs, 20, x5);\n    write_f64x4!(xs, 24, x6);\n    write_f64x4!(xs, 28, x7);\n}\n\nmacro_rules! sd_fft_basecase {\n    ($n: expr, $f0: ident, $f1: ident, $fs0: ident, $fs1: ident) => {\n        // This is sd_fft_basecase_n_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\n        fn $f1(q: &FFTContext, xs: &mut [f64]) {\n            const LIMIT: usize = 1 << ($n - 2);\n            radix_4_forward_param_j_is_z!(q, iw, n, ninv);\n            split_into_chunks_mut!(xs, LIMIT, [xs0, xs1, xs2], xs3);\n            process_4_3!(\n                radix_4_forward_moth_j_is_z,\n                LIMIT,\n                xs0,\n                xs1,\n                xs2,\n                xs3,\n                iw,\n                n,\n                ninv\n            );\n            $fs1(q, xs0);\n            $fs0(q, xs1, 0, 1);\n            $fs0(q, xs2, 0, 2);\n            $fs0(q, xs3, 1, 2);\n        }\n\n        // This is sd_fft_basecase_n_0 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\n        fn $f0(q: &FFTContext, xs: &mut [f64], j_r: usize, j_bits: u64) {\n            const LIMIT: usize = 1 << ($n - 2);\n            radix_4_forward_param_j_is_nz!(q, j_r, j_bits, w, w2, iw, n, ninv);\n            split_into_chunks_mut!(xs, LIMIT, [xs0, xs1, xs2], xs3);\n            process_4_5!(\n                radix_4_forward_moth_j_is_nz,\n                LIMIT,\n                xs0,\n                xs1,\n                xs2,\n                xs3,\n                w,\n                w2,\n                iw,\n                n,\n                ninv\n            );\n            let j_r_4 = j_r << 2;\n            let j_bits_p_2 = j_bits + 2;\n            $fs0(q, xs0, j_r_4, j_bits_p_2);\n            $fs0(q, xs1, j_r_4 + 1, j_bits_p_2);\n            $fs0(q, xs2, j_r_4 + 2, j_bits_p_2);\n            $fs0(q, xs3, j_r_4 + 3, j_bits_p_2);\n        }\n    };\n}\n\nsd_fft_basecase!(\n    6,\n    sd_fft_basecase_6_0,\n    sd_fft_basecase_6_1,\n    sd_fft_basecase_4_0,\n    sd_fft_basecase_4_1\n);\nsd_fft_basecase!(\n    7,\n    sd_fft_basecase_7_0,\n    sd_fft_basecase_7_1,\n    sd_fft_basecase_5_0,\n    sd_fft_basecase_5_1\n);\nsd_fft_basecase!(\n    8,\n    sd_fft_basecase_8_0,\n    sd_fft_basecase_8_1,\n    sd_fft_basecase_6_0,\n    sd_fft_basecase_6_1\n);\nsd_fft_basecase!(\n    9,\n    sd_fft_basecase_9_0,\n    sd_fft_basecase_9_1,\n    sd_fft_basecase_7_0,\n    sd_fft_basecase_7_1\n);\n\n// parameter 1: j can be zero\n//\n// This is sd_fft_base_8_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_base_8_1(q: &FFTContext, xs: &mut [f64], j: usize) {\n    set_j_bits_and_j_r!(j, j_bits, j_r);\n    if j == 0 {\n        sd_fft_basecase_8_1(q, xs);\n    } else {\n        sd_fft_basecase_8_0(q, xs, j_r, j_bits);\n    }\n}\n\n// parameter 0: j cannot be zero\n//\n// This is sd_fft_base_8_0 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_base_8_0(q: &FFTContext, xs: &mut [f64], j: usize) {\n    assert_ne!(j, 0);\n    set_j_bits_and_j_r!(j, j_bits, j_r);\n    sd_fft_basecase_8_0(q, xs, j_r, j_bits);\n}\n\n// This is sd_fft_base_9_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_base_9_1(q: &FFTContext, xs: &mut [f64], j: usize) {\n    set_j_bits_and_j_r!(j, j_bits, j_r);\n    if j == 0 {\n        sd_fft_basecase_9_1(q, xs);\n    } else {\n        sd_fft_basecase_9_0(q, xs, j_r, j_bits);\n    }\n}\n\n// This is sd_fft_no_trunc_internal from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_no_trunc_internal(\n    q: &FFTContext,\n    xs: &mut [f64],\n    // stride\n    s: usize,\n    // 1 transform of length BLK_SZ*2^k\n    k: u64,\n    // twist param\n    j: usize,\n) {\n    if k > 2 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        // column ffts\n        let shift = s << k2;\n        let big_s = s << LG_BLK_SZ;\n        let mut m = 0;\n        for _ in 0..usize::power_of_2(k2) {\n            sd_fft_no_trunc_block(q, &mut xs[m..], shift, k1, j);\n            m += big_s;\n        }\n        // row ffts\n        let shift = k2 + LG_BLK_SZ;\n        let shifted = j << k1;\n        let big_s = s << shift;\n        let mut m = 0;\n        for b in 0..usize::power_of_2(k1) {\n            sd_fft_no_trunc_internal(q, &mut xs[m..], s, k2, shifted + b);\n            m += big_s;\n        }\n        return;\n    }\n    if k == 2 {\n        // k1 = 2; k2 = 0\n        sd_fft_no_trunc_block(q, xs, s, 2, j);\n        split_into_chunks_mut!(xs, s << LG_BLK_SZ, [xs0, xs1, xs2], xs3);\n        let j_4 = j << 2;\n        sd_fft_base_8_1(q, xs0, j_4);\n        sd_fft_base_8_0(q, xs1, j_4 + 1);\n        sd_fft_base_8_0(q, xs2, j_4 + 2);\n        sd_fft_base_8_0(q, xs3, j_4 + 3);\n    } else if k == 1 {\n        sd_fft_base_9_1(q, xs, j);\n    } else {\n        // currently unreachable because all ffts are called with k > 0\n        sd_fft_base_8_1(q, xs, j);\n    }\n}\n\n// This is sd_fft_moth_trunc_block_i_j_1 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_moth_trunc_block_1<const ITRUNC: usize, const OTRUNC: usize>(\n    q: &FFTContext,\n    _j_r: usize,\n    _j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    radix_4_forward_param_j_is_z!(q, iw, n, ninv);\n    let gap_2 = gap << 1;\n    let gap_3 = gap_2 + gap;\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let mut x0 = f64x8::default();\n        let mut x1 = f64x8::default();\n        let mut x2 = f64x8::default();\n        let mut x3 = f64x8::default();\n        if 0 < ITRUNC {\n            x0 = read_f64x8!(xs, i);\n        }\n        if 0 < ITRUNC {\n            x0 = f64x8_reduce_to_pm1n!(x0, n, ninv);\n        }\n        if 1 < ITRUNC {\n            x1 = read_f64x8!(xs, gap + i);\n        }\n        if 2 < ITRUNC {\n            x2 = read_f64x8!(xs, gap_2 + i);\n        }\n        if 2 < ITRUNC {\n            x2 = f64x8_reduce_to_pm1n!(x2, n, ninv);\n        }\n        if 3 < ITRUNC {\n            x3 = read_f64x8!(xs, gap_3 + i);\n        }\n        if 3 < ITRUNC {\n            x3 = f64x8_reduce_to_pm1n!(x3, n, ninv);\n        }\n        let y0 = if 2 < ITRUNC { x0 + x2 } else { x0 };\n        let mut y1 = if 3 < ITRUNC { x1 + x3 } else { x1 };\n        let y2 = if 2 < ITRUNC { x0 - x2 } else { x0 };\n        let mut y3 = if 3 < ITRUNC { x1 - x3 } else { x1 };\n        y1 = f64x8_reduce_to_pm1n!(y1, n, ninv);\n        y3 = f64x8_mulmod!(y3, iw, n, ninv);\n        x0 = y0 + y1;\n        x1 = y0 - y1;\n        x2 = y2 + y3;\n        x3 = y2 - y3;\n        if 0 < OTRUNC {\n            write_f64x8!(xs, i, x0);\n        }\n        if 1 < OTRUNC {\n            write_f64x8!(xs, gap + i, x1);\n        }\n        if 2 < OTRUNC {\n            write_f64x8!(xs, gap_2 + i, x2);\n        }\n        if 3 < OTRUNC {\n            write_f64x8!(xs, gap_3 + i, x3);\n        }\n    }\n}\n\n// This is sd_fft_moth_trunc_block_i_j_0 from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_moth_trunc_block_0<const ITRUNC: usize, const OTRUNC: usize>(\n    q: &FFTContext,\n    j_r: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    radix_4_forward_param_j_is_nz!(q, j_r, j_bits, w, w2, iw, n, ninv);\n    let gap_2 = gap << 1;\n    let gap_3 = gap_2 + gap;\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let mut x0 = f64x8::default();\n        let mut x1 = f64x8::default();\n        let mut x2 = f64x8::default();\n        let mut x3 = f64x8::default();\n        if 0 < ITRUNC {\n            x0 = read_f64x8!(xs, i);\n        }\n        if 0 < ITRUNC {\n            x0 = f64x8_reduce_to_pm1n!(x0, n, ninv);\n        }\n        if 1 < ITRUNC {\n            x1 = read_f64x8!(xs, gap + i);\n        }\n        if 2 < ITRUNC {\n            x2 = read_f64x8!(xs, gap_2 + i);\n        }\n        if 2 < ITRUNC {\n            x2 = f64x8_mulmod!(x2, w2, n, ninv);\n        }\n        if 3 < ITRUNC {\n            x3 = read_f64x8!(xs, gap_3 + i);\n        }\n        if 3 < ITRUNC {\n            x3 = f64x8_mulmod!(x3, w2, n, ninv);\n        }\n        let y0 = if 2 < ITRUNC { x0 + x2 } else { x0 };\n        let mut y1 = if 3 < ITRUNC { x1 + x3 } else { x1 };\n        let y2 = if 2 < ITRUNC { x0 - x2 } else { x0 };\n        let mut y3 = if 3 < ITRUNC { x1 - x3 } else { x1 };\n        y1 = f64x8_mulmod!(y1, w, n, ninv);\n        y3 = f64x8_mulmod!(y3, iw, n, ninv);\n        x0 = y0 + y1;\n        x1 = y0 - y1;\n        x2 = y2 + y3;\n        x3 = y2 - y3;\n        if 0 < OTRUNC {\n            write_f64x8!(xs, i, x0);\n        }\n        if 1 < OTRUNC {\n            write_f64x8!(xs, gap + i, x1);\n        }\n        if 2 < OTRUNC {\n            write_f64x8!(xs, gap_2 + i, x2);\n        }\n        if 3 < OTRUNC {\n            write_f64x8!(xs, gap_3 + i, x3);\n        }\n    }\n}\n\ntype Sd2MothTruncBlockFn =\n    for<'a, 'b, 'c, 'd> fn(&'a FFTContext, usize, &'b mut [f64], &'c mut [f64]);\n\ntype Sd4MothTruncBlockFn = for<'a, 'b, 'c> fn(&'a FFTContext, usize, u64, &'b mut [f64], usize);\n\nconst SD_FFT_4_MOTH_TRUNC_BLOCK_TABLE: [Sd4MothTruncBlockFn; 24] = [\n    sd_fft_moth_trunc_block_0::<2, 1>,\n    sd_fft_moth_trunc_block_1::<2, 1>,\n    sd_fft_moth_trunc_block_0::<2, 2>,\n    sd_fft_moth_trunc_block_1::<2, 2>,\n    sd_fft_moth_trunc_block_0::<2, 3>,\n    sd_fft_moth_trunc_block_1::<2, 3>,\n    sd_fft_moth_trunc_block_0::<2, 4>,\n    sd_fft_moth_trunc_block_1::<2, 4>,\n    sd_fft_moth_trunc_block_0::<3, 1>,\n    sd_fft_moth_trunc_block_1::<3, 1>,\n    sd_fft_moth_trunc_block_0::<3, 2>,\n    sd_fft_moth_trunc_block_1::<3, 2>,\n    sd_fft_moth_trunc_block_0::<3, 3>,\n    sd_fft_moth_trunc_block_1::<3, 3>,\n    sd_fft_moth_trunc_block_0::<3, 4>,\n    sd_fft_moth_trunc_block_1::<3, 4>,\n    sd_fft_moth_trunc_block_0::<4, 1>,\n    sd_fft_moth_trunc_block_1::<4, 1>,\n    sd_fft_moth_trunc_block_0::<4, 2>,\n    sd_fft_moth_trunc_block_1::<4, 2>,\n    sd_fft_moth_trunc_block_0::<4, 3>,\n    sd_fft_moth_trunc_block_1::<4, 3>,\n    sd_fft_moth_trunc_block_0::<4, 4>,\n    sd_fft_moth_trunc_block_1::<4, 4>,\n];\n\n// This is RADIX_2_FORWARD_MOTH_TRUNC_2_1_J_IS_Z from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_2_forward_moth_trunc_2_1_j_is_z {\n    ($x0: ident, $x1: ident, $n: ident, $ninv: ident) => {\n        $x0 = f64x8_reduce_to_pm1n!($x0, $n, $ninv);\n        $x1 = f64x8_reduce_to_pm1n!($x1, $n, $ninv);\n        $x0 += $x1;\n    };\n}\n\n// This is RADIX_2_FORWARD_MOTH_TRUNC_2_1_J_IS_NZ from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_2_forward_moth_trunc_2_1_j_is_nz {\n    ($x0: ident, $x1: ident, $w: ident, $n: ident, $ninv: ident) => {\n        $x0 = f64x8_reduce_to_pm1n!($x0, $n, $ninv);\n        $x1 = f64x8_mulmod!($x1, $w, $n, $ninv);\n        $x0 += $x1;\n    };\n}\n\n// This is sd_fft_trunc_block from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_trunc_block(\n    q: &FFTContext,\n    xs: &mut [f64],\n    s: usize,\n    // transform length 2^k\n    k: u64,\n    j: usize,\n    itrunc: usize,\n    otrunc: usize,\n) {\n    let pow = usize::power_of_2(k);\n    assert!(itrunc <= pow);\n    assert!(otrunc <= pow);\n    if otrunc < 1 {\n        fail_on_untested_path(\"sd_fft_trunc_block, otrunc < 1\");\n        return;\n    }\n    if itrunc <= 1 {\n        let big_s = s << LG_BLK_SZ;\n        if itrunc < 1 {\n            fail_on_untested_path(\"sd_fft_trunc_block, itrunc < 1\");\n            for c in xs[..big_s * otrunc].chunks_mut(big_s) {\n                c[..BLK_SZ].fill(0.0);\n            }\n        } else {\n            let mut m = big_s;\n            for _ in 1..otrunc {\n                let (xs_lo, xs_hi) = xs.split_at_mut(m);\n                xs_hi[..BLK_SZ].copy_from_slice(&xs_lo[..BLK_SZ]);\n                m += big_s;\n            }\n        }\n        return;\n    }\n    if itrunc == otrunc && otrunc == pow {\n        sd_fft_no_trunc_block(q, xs, s, k, j);\n        return;\n    }\n    let big_s = s << LG_BLK_SZ;\n    if k > 2 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        let l2 = usize::power_of_2(k2);\n        let n1 = otrunc >> k2;\n        let mask = l2 - 1;\n        let n2 = otrunc & mask;\n        let z1 = itrunc >> k2;\n        let z2 = itrunc & mask;\n        let n1p = n1 + usize::from(n2 != 0);\n        let z2p = min(l2, itrunc);\n        // columns\n        let shifted = s << k2;\n        let mut m = 0;\n        for a in 0..z2p {\n            sd_fft_trunc_block(\n                q,\n                &mut xs[m..],\n                shifted,\n                k1,\n                j,\n                z1 + usize::from(a < z2),\n                n1p,\n            );\n            m += big_s;\n        }\n        // full rows\n        let big_s_2 = s << (k2 + LG_BLK_SZ);\n        let shifted = j << k1;\n        let mut m = 0;\n        for b in 0..n1 {\n            sd_fft_trunc_block(q, &mut xs[m..], s, k2, shifted + b, z2p, l2);\n            m += big_s_2;\n        }\n        // last partial row\n        if n2 != 0 {\n            sd_fft_trunc_block(q, &mut xs[n1 * big_s_2..], s, k2, shifted + n1, z2p, n2);\n        }\n        return;\n    }\n    set_j_bits_and_j_r!(j, j_bits, j_r);\n    if k == 2 {\n        let index = usize::from(j == 0) + ((otrunc - 1 + ((itrunc - 2) << 2)) << 1);\n        SD_FFT_4_MOTH_TRUNC_BLOCK_TABLE[index](q, j_r, j_bits, xs, big_s);\n    } else if k == 1 {\n        let (xs0, xs1) = xs.split_at_mut(big_s);\n        assert_eq!(itrunc, 2);\n        assert_eq!(otrunc, 1);\n        if j_bits == 0 {\n            fail_on_untested_path(\"sd_fft_trunc_block, j_bits == 0\");\n            radix_2_forward_param_j_is_z!(q, n, ninv);\n            process_2_2!(\n                radix_2_forward_moth_trunc_2_1_j_is_z,\n                BLK_SZ,\n                xs0,\n                xs1,\n                n,\n                ninv\n            );\n        } else {\n            radix_2_forward_param_j_is_nz!(q, j_r, j_bits, w, n, ninv);\n            process_2_3!(\n                radix_2_forward_moth_trunc_2_1_j_is_nz,\n                BLK_SZ,\n                xs0,\n                xs1,\n                w,\n                n,\n                ninv\n            );\n        }\n    }\n}\n\n// This is sd_fft_trunc_internal from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_trunc_internal(\n    q: &FFTContext,\n    // x = data + BLK_SZ*I  where I = starting index\n    xs: &mut [f64],\n    // stride\n    s: usize,\n    // transform length BLK_SZ*2^k\n    k: u64,\n    j: usize,\n    // actual trunc is BLK_SZ*itrunc\n    itrunc: usize,\n    // actual trunc is BLK_SZ*otrunc\n    otrunc: usize,\n) {\n    if otrunc < 1 {\n        fail_on_untested_path(\"sd_fft_trunc_internal, otrunc < 1\");\n        return;\n    }\n    if itrunc < 1 {\n        fail_on_untested_path(\"sd_fft_trunc_internal, itrunc < 1\");\n        let big_s = s << LG_BLK_SZ;\n        for c in xs[..big_s * otrunc].chunks_mut(big_s) {\n            c[..BLK_SZ].fill(0.0);\n        }\n        return;\n    }\n    if itrunc == otrunc && otrunc == usize::power_of_2(k) {\n        sd_fft_no_trunc_internal(q, xs, s, k, j);\n        return;\n    }\n    let big_s = s << LG_BLK_SZ;\n    if k > 2 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        let l2 = usize::power_of_2(k2);\n        let n1 = otrunc >> k2;\n        let mask = l2 - 1;\n        let n2 = otrunc & mask;\n        let z1 = itrunc >> k2;\n        let z2 = itrunc & mask;\n        let n1p = n1 + usize::from(n2 != 0);\n        let z2p = min(l2, itrunc);\n        // columns\n        let shifted = s << k2;\n        let mut m = 0;\n        for a in 0..z2p {\n            sd_fft_trunc_block(\n                q,\n                &mut xs[m..],\n                shifted,\n                k1,\n                j,\n                z1 + usize::from(a < z2),\n                n1p,\n            );\n            m += big_s;\n        }\n        // full rows\n        let big_s_2 = s << (k2 + LG_BLK_SZ);\n        let shifted = j << k1;\n        let mut m = 0;\n        for b in 0..n1 {\n            sd_fft_trunc_internal(q, &mut xs[m..], s, k2, shifted + b, z2p, l2);\n            m += big_s_2;\n        }\n        // last partial row\n        if n2 > 0 {\n            sd_fft_trunc_internal(q, &mut xs[n1 * big_s_2..], s, k2, shifted + n1, z2p, n2);\n        }\n        return;\n    }\n    if k == 2 {\n        sd_fft_trunc_block(q, xs, s, 2, j, itrunc, otrunc);\n        let j_4 = j << 2;\n        sd_fft_base_8_1(q, xs, j_4);\n        if otrunc > 1 {\n            sd_fft_base_8_0(q, &mut xs[big_s..], j_4 + 1);\n        }\n        if otrunc > 2 {\n            sd_fft_base_8_0(q, &mut xs[big_s << 1..], j_4 + 2);\n        }\n        if otrunc > 3 {\n            sd_fft_base_8_0(q, &mut xs[big_s * 3..], j_4 + 3);\n        }\n    } else if k == 1 {\n        sd_fft_trunc_block(q, xs, s, 1, j, itrunc, otrunc);\n        let j_2 = j << 1;\n        sd_fft_base_8_1(q, xs, j_2);\n        if otrunc > 1 {\n            sd_fft_base_8_0(q, &mut xs[big_s..], j_2 + 1);\n        }\n    } else {\n        // currently unreachable\n        sd_fft_base_8_1(q, xs, j);\n    }\n}\n\n// This is sd_fft_ctx_fit_depth_with_lock from fft_small/sd_fft_ctx.c, FLINT 3.3.0-dev.\nfn sd_fft_ctx_fit_depth_with_lock(q: &mut FFTContext, depth: u64) {\n    for k in q.w2tab_depth..depth {\n        let ww = q\n            .primitive_root\n            .mod_pow((q.mod_data.n - 1) >> (k + 1), q.mod_data.n);\n        let w = f64x8::splat(f64_reduce_0n_to_pmhn!(ww as f64, q.p));\n        let n = f64x8::splat(q.p);\n        let ninv = f64x8::splat(q.pinv);\n        let big_n = usize::power_of_2(k - 1);\n        let old_len = q.w2tab_backing.len();\n        q.w2tab_backing.resize(\n            old_len + big_n.round_to_multiple_of_power_of_2(12, Ceiling).0,\n            0.0,\n        );\n        let ku = k as usize;\n        q.w2tab_offsets[ku] = old_len;\n        // The first few tables are stored consecutively, so vec16 is ok.\n        let mut off = 0;\n        let mut l = const { 1 << (SD_FFT_CTX_W2TAB_INIT - 1) };\n        let mut kk = 0;\n        for j in SD_FFT_CTX_W2TAB_INIT - 1..k {\n            for i in (0..l).step_by(16) {\n                let x0 = read_f64x8_w2tab!(q, kk, i);\n                let x1 = read_f64x8_w2tab!(q, kk, i + 8);\n                let y0 = f64x8_reduce_pm1n_to_pmhn!(f64x8_mulmod!(x0, w, n, ninv), n);\n                let y1 = f64x8_reduce_pm1n_to_pmhn!(f64x8_mulmod!(x1, w, n, ninv), n);\n                write_f64x8_w2tab!(q, ku, off + i, y0);\n                write_f64x8_w2tab!(q, ku, off + i + 8, y1);\n            }\n            kk = j as usize + 1;\n            l += off;\n            off = l;\n        }\n        q.w2tab_depth = k;\n    }\n}\n\n// This is sd_fft_ctx_fit_depth from fft_small.h, FLINT 3.3.0-dev.\nfn sd_fft_ctx_fit_depth(q: &mut FFTContext, depth: u64) {\n    if q.w2tab_depth < depth {\n        sd_fft_ctx_fit_depth_with_lock(q, depth);\n    }\n}\n\n// This is sd_fft_trunc from fft_small/sd_fft.c, FLINT 3.3.0-dev.\nfn sd_fft_trunc(\n    q: &mut FFTContext,\n    ds: &mut [f64],\n    // convolution length 2^L\n    l: u64,\n    itrunc: usize,\n    otrunc: usize,\n) {\n    let pow = usize::power_of_2(l);\n    assert!(itrunc <= pow);\n    assert!(otrunc <= pow);\n    if l > LG_BLK_SZ {\n        sd_fft_ctx_fit_depth(q, l);\n        let new_itrunc = itrunc.div_round(BLK_SZ, Ceiling).0;\n        let new_otrunc = otrunc.div_round(BLK_SZ, Ceiling).0;\n        ds[itrunc..][..itrunc.wrapping_neg() & const { BLK_SZ - 1 }].fill(0.0);\n        sd_fft_trunc_internal(q, ds, 1, l - LG_BLK_SZ, 0, new_itrunc, new_otrunc);\n        return;\n    }\n    fail_on_untested_path(\"sd_fft_trunc, l <= LG_BLK_SZ\");\n    ds[itrunc..][..usize::power_of_2(l)].fill(0.0);\n    // L=8 reads from w2tab[7]\n    const _: () = assert!(LG_BLK_SZ <= SD_FFT_CTX_W2TAB_INIT);\n    match l {\n        0 => sd_fft_basecase_0_1(q, ds),\n        1 => sd_fft_basecase_1_1(q, ds),\n        2 => sd_fft_basecase_2_1(q, ds),\n        3 => sd_fft_basecase_3_1(q, ds),\n        4 => sd_fft_basecase_4_1(q, ds),\n        5 => sd_fft_basecase_5_1(q, ds),\n        6 => sd_fft_basecase_6_1(q, ds),\n        7 => sd_fft_basecase_7_1(q, ds),\n        8 => sd_fft_basecase_8_1(q, ds),\n        _ => unreachable!(),\n    }\n}\n\n// for the ifft look up of powers of w^-1: the remainder has to be flipped\n//\n// This is SET_J_BITS_AND_J_MR from fft_small.h, FLINT 3.3.0-dev, returning j_bits and j_mr.\nmacro_rules! set_j_bits_and_j_mr {\n    ($j: ident, $j_bits: ident, $j_mr: ident) => {\n        let ($j_bits, $j_mr) = if $j == 0 {\n            (0, 0)\n        } else {\n            let j_bits = n_nbits_nz!($j);\n            (j_bits, usize::power_of_2(j_bits) - 1 - $j)\n        };\n    };\n}\n\n// This is RADIX_4_REVERSE_PARAM_J_IS_Z from fft_small/sd_ifft.c, FLINT 3.3.0-dev, returning iw, n,\n// and ninv.\nmacro_rules! radix_4_reverse_param_j_is_z {\n    ($q: ident, $iw: ident, $n: ident, $ninv: ident) => {\n        let $iw = f64x8::splat(w2tab!($q, 0, 1));\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_4_REVERSE_PARAM_J_IS_NZ from fft_small/sd_ifft.c, FLINT 3.3.0-dev, returning w, w2,\n// iw, n, and ninv.\nmacro_rules! radix_4_reverse_param_j_is_nz {\n    (\n        $q: ident,\n        $j_mr: ident,\n        $j_bits: ident,\n        $w: ident,\n        $w2: ident,\n        $iw: ident,\n        $n: ident,\n        $ninv: ident\n    ) => {\n        let j_bits = usize::exact_from($j_bits);\n        let jp1 = j_bits + 1;\n        let j_2 = $j_mr << 1;\n        let $w = f64x8::splat(w2tab!($q, jp1, j_2 + 1));\n        let $w2 = f64x8::splat(w2tab!($q, j_bits, $j_mr));\n        let $iw = f64x8::splat(w2tab!($q, jp1, j_2));\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_4_REVERSE_MOTH_J_IS_Z from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_4_reverse_moth_j_is_z {\n    ($x0: ident,\n     $x1: ident,\n     $x2: ident,\n     $x3: ident,\n     $iw: ident,\n     $n: ident,\n     $ninv: ident\n) => {\n        let mut y0 = $x0 + $x1;\n        let mut y1 = $x2 + $x3;\n        let mut y2 = $x0 - $x1;\n        let mut y3 = $x2 - $x3;\n        y0 = f64x8_reduce_to_pm1n!(y0, $n, $ninv);\n        y1 = f64x8_reduce_to_pm1n!(y1, $n, $ninv);\n        y2 = f64x8_reduce_to_pm1n!(y2, $n, $ninv);\n        y3 = f64x8_mulmod!(y3, $iw, $n, $ninv);\n        $x0 = y0 + y1;\n        $x2 = y0 - y1;\n        $x1 = y2 - y3;\n        $x3 = y2 + y3;\n    };\n}\n\n// This is RADIX_4_REVERSE_MOTH_J_IS_NZ from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_4_reverse_moth_j_is_nz {\n    (\n    $x0: ident,\n    $x1: ident,\n    $x2: ident,\n    $x3: ident,\n    $w: ident,\n    $w2: ident,\n    $iw: ident,\n    $n: ident,\n    $ninv: ident\n) => {\n        let y0 = $x0 + $x1;\n        let y1 = $x2 + $x3;\n        let y2 = f64x8_mulmod!($x0 - $x1, $w, $n, $ninv);\n        let y3 = f64x8_mulmod!($x3 - $x2, $iw, $n, $ninv);\n        $x0 = y0 + y1;\n        $x1 = y3 - y2;\n        $x2 = y1 - y0;\n        $x3 = y3 + y2;\n        $x0 = f64x8_reduce_to_pm1n!($x0, $n, $ninv);\n        $x2 = f64x8_mulmod!($x2, $w2, $n, $ninv);\n        $x3 = f64x8_mulmod!($x3, $w2, $n, $ninv);\n    };\n}\n\n// This is RADIX_2_REVERSE_PARAM_J_IS_Z from fft_small/sd_ifft.c, FLINT 3.3.0-dev, returning n and\n// ninv.\nmacro_rules! radix_2_reverse_param_j_is_z {\n    ($q: ident, $n: ident, $ninv: ident) => {\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_2_REVERSE_PARAM_J_IS_NZ from fft_small/sd_ifft.c, FLINT 3.3.0-dev, returning w, n,\n// and ninv.\nmacro_rules! radix_2_reverse_param_j_is_nz {\n    (\n        $q: ident,\n        $j_mr: ident,\n        $j_bits: ident,\n        $w: ident,\n        $n: ident,\n        $ninv: ident\n    ) => {\n        let $w = f64x8::splat(w2tab!($q, usize::exact_from($j_bits), $j_mr));\n        let $n = f64x8::splat($q.p);\n        let $ninv = f64x8::splat($q.pinv);\n    };\n}\n\n// This is RADIX_2_REVERSE_MOTH_J_IS_Z from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_2_reverse_moth_j_is_z {\n    ($x0: ident, $x1: ident, $n: ident, $ninv: ident) => {\n        let y0 = f64x8_reduce_to_pm1n!($x0 + $x1, $n, $ninv);\n        let y1 = f64x8_reduce_to_pm1n!($x0 - $x1, $n, $ninv);\n        $x0 = y0;\n        $x1 = y1;\n    };\n}\n\n// This is RADIX_2_REVERSE_MOTH_J_IS_NZ from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! radix_2_reverse_moth_j_is_nz {\n    ($x0: ident, $x1: ident, $w: ident, $n: ident, $ninv: ident) => {\n        let y0 = f64x8_reduce_to_pm1n!($x0 + $x1, $n, $ninv);\n        let y1 = f64x8_mulmod!($x1 - $x0, $w, $n, $ninv);\n        $x0 = y0;\n        $x1 = y1;\n    };\n}\n\n// This is sd_ifft_no_trunc_block from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_no_trunc_block(\n    q: &FFTContext,\n    xs: &mut [f64],\n    // stride\n    s: usize,\n    // BLK_SZ transforms each of length 2^k\n    k: u64,\n    j: usize,\n) {\n    let big_s = s << LG_BLK_SZ;\n    if k > 2 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        // row ffts\n        let big_s_2 = s << (k2 + LG_BLK_SZ);\n        let shifted = j << k1;\n        let mut m = 0;\n        for b in 0..usize::power_of_2(k1) {\n            sd_ifft_no_trunc_block(q, &mut xs[m..], s, k2, shifted + b);\n            m += big_s_2;\n        }\n        // column ffts\n        let shifted = s << k2;\n        let mut m = 0;\n        for _ in 0..usize::power_of_2(k2) {\n            sd_ifft_no_trunc_block(q, &mut xs[m..], shifted, k1, j);\n            m += big_s;\n        }\n        return;\n    }\n    set_j_bits_and_j_mr!(j, j_bits, j_mr);\n    if k == 2 {\n        split_into_chunks_mut!(xs, big_s, [xs0, xs1, xs2], xs3);\n        if j_bits == 0 {\n            radix_4_reverse_param_j_is_z!(q, iw, n, ninv);\n            process_4_3!(\n                radix_4_reverse_moth_j_is_z,\n                BLK_SZ,\n                xs0,\n                xs1,\n                xs2,\n                xs3,\n                iw,\n                n,\n                ninv\n            );\n        } else {\n            radix_4_reverse_param_j_is_nz!(q, j_mr, j_bits, w, w2, iw, n, ninv);\n            process_4_5!(\n                radix_4_reverse_moth_j_is_nz,\n                BLK_SZ,\n                xs0,\n                xs1,\n                xs2,\n                xs3,\n                w,\n                w2,\n                iw,\n                n,\n                ninv\n            );\n        }\n    } else if k == 1 {\n        let (xs0, xs1) = xs.split_at_mut(big_s);\n        if j_bits == 0 {\n            radix_2_reverse_param_j_is_z!(q, n, ninv);\n            process_2_2!(radix_2_reverse_moth_j_is_z, BLK_SZ, xs0, xs1, n, ninv);\n        } else {\n            radix_2_reverse_param_j_is_nz!(q, j_mr, j_bits, w, n, ninv);\n            process_2_3!(radix_2_reverse_moth_j_is_nz, BLK_SZ, xs0, xs1, w, n, ninv);\n        }\n    }\n}\n\n// This is LENGTH2INV_ZERO_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64_length2inv_zero_j_mut {\n    ($x0: ident, $x1: ident, $n: expr, $ninv: expr) => {\n        (*$x0, *$x1) = (\n            f64_reduce_to_pm1n!(*$x0 + *$x1, $n, $ninv),\n            f64_reduce_to_pm1n!(*$x0 - *$x1, $n, $ninv),\n        );\n    };\n}\n\n// This is LENGTH2INV_ZERO_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64x4_length2inv_zero_j {\n    ($x0: ident, $x1: ident, $n: ident, $ninv: ident) => {\n        ($x0, $x1) = (\n            f64x4_reduce_to_pm1n!($x0 + $x1, $n, $ninv),\n            f64x4_reduce_to_pm1n!($x0 - $x1, $n, $ninv),\n        );\n    };\n}\n\n// This is LENGTH2INV_ANY_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64_length2inv_any_j_mut {\n    ($x0: ident, $x1: ident, $n: ident, $ninv: ident, $w0: expr) => {\n        (*$x0, *$x1) = (\n            f64_reduce_to_pm1n!(*$x0 + *$x1, $n, $ninv),\n            f64_mulmod!(*$x1 - *$x0, $w0, $n, $ninv),\n        );\n    };\n}\n\n// This is LENGTH2INV_ANY_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64x4_length2inv_any_j {\n    ($x0: ident, $x1: ident, $n: ident, $ninv: ident, $w0: ident) => {\n        ($x0, $x1) = (\n            f64x4_reduce_to_pm1n!($x0 + $x1, $n, $ninv),\n            f64x4_mulmod!($x1 - $x0, $w0, $n, $ninv),\n        );\n    };\n}\n\n// This is LENGTH4INV_ZERO_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64_length4inv_zero_j_mut {\n    ($x0: ident, $x1: ident, $x2: ident, $x3: ident, $n: expr, $ninv: expr, $ww1: expr) => {\n        let n = $n;\n        let ninv = $ninv;\n        let y0 = f64_reduce_to_pm1n!(*$x0 + *$x1, n, ninv);\n        let y1 = f64_reduce_to_pm1n!(*$x2 + *$x3, n, ninv);\n        let y2 = f64_reduce_to_pm1n!(*$x0 - *$x1, n, ninv);\n        let y3 = f64_mulmod!(*$x2 - *$x3, $ww1, n, ninv);\n        *$x0 = y0 + y1;\n        *$x2 = y0 - y1;\n        *$x1 = y2 - y3;\n        *$x3 = y2 + y3;\n    };\n}\n\n// This is LENGTH4INV_ZERO_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64x4_length4inv_zero_j {\n    ($x0: ident, $x1: ident, $x2: ident, $x3: ident, $n: ident, $ninv: ident, $ww1: ident) => {\n        let y0 = f64x4_reduce_to_pm1n!($x0 + $x1, $n, $ninv);\n        let y1 = f64x4_reduce_to_pm1n!($x2 + $x3, $n, $ninv);\n        let y2 = f64x4_reduce_to_pm1n!($x0 - $x1, $n, $ninv);\n        let y3 = f64x4_mulmod!($x2 - $x3, $ww1, $n, $ninv);\n        $x0 = y0 + y1;\n        $x2 = y0 - y1;\n        $x1 = y2 - y3;\n        $x3 = y2 + y3;\n    };\n}\n\n// This is LENGTH4INV_ZERO_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64x4_length4inv_any_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $n: expr,\n        $ninv: ident,\n        $w0: ident,\n        $ww0: ident,\n        $ww1: ident\n    ) => {\n        let y0 = $x0 + $x1;\n        let y1 = $x2 + $x3;\n        let y2 = f64x4_mulmod!($x0 - $x1, $ww0, $n, $ninv);\n        let y3 = f64x4_mulmod!($x3 - $x2, $ww1, $n, $ninv);\n        $x0 = f64x4_reduce_to_pm1n!(y0 + y1, $n, $ninv);\n        $x1 = y3 - y2;\n        $x2 = f64x4_mulmod!(y1 - y0, $w0, $n, $ninv);\n        $x3 = f64x4_mulmod!(y3 + y2, $w0, $n, $ninv);\n    };\n}\n\n// This is LENGTH8INV_ZERO_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64_length8inv_zero_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $x4: ident,\n        $x5: ident,\n        $x6: ident,\n        $x7: ident,\n        $n: expr,\n        $ninv: expr,\n        $ww1: expr,\n        $www2: expr,\n        $www3: expr\n    ) => {\n        let n = $n;\n        let ninv = $ninv;\n        let ww1 = $ww1;\n        f64_length2inv_zero_j_mut!($x0, $x1, n, ninv);\n        f64_length2inv_any_j_mut!($x2, $x3, n, ninv, ww1);\n        f64_length2inv_any_j_mut!($x4, $x5, n, ninv, $www2);\n        f64_length2inv_any_j_mut!($x6, $x7, n, ninv, $www3);\n        f64_length4inv_zero_j_mut!($x0, $x2, $x4, $x6, n, ninv, ww1);\n        f64_length4inv_zero_j_mut!($x1, $x3, $x5, $x7, n, ninv, ww1);\n    };\n}\n\n// This is LENGTH8INV_ZERO_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64x4_length8inv_zero_j {\n    (\n    $x0: ident,\n    $x1: ident,\n    $x2: ident,\n    $x3: ident,\n    $x4: ident,\n    $x5: ident,\n    $x6: ident,\n    $x7: ident,\n    $n: ident,\n    $ninv: ident,\n    $ww1: ident,\n    $www2: ident,\n    $www3: ident\n) => {\n        f64x4_length2inv_zero_j!($x0, $x1, $n, $ninv);\n        f64x4_length2inv_any_j!($x2, $x3, $n, $ninv, $ww1);\n        f64x4_length2inv_any_j!($x4, $x5, $n, $ninv, $www2);\n        f64x4_length2inv_any_j!($x6, $x7, $n, $ninv, $www3);\n        f64x4_length4inv_zero_j!($x0, $x2, $x4, $x6, $n, $ninv, $ww1);\n        f64x4_length4inv_zero_j!($x1, $x3, $x5, $x7, $n, $ninv, $ww1);\n    };\n}\n\n// This is LENGTH8INV_ANY_J from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nmacro_rules! f64x4_length8inv_any_j {\n    (\n        $x0: ident,\n        $x1: ident,\n        $x2: ident,\n        $x3: ident,\n        $x4: ident,\n        $x5: ident,\n        $x6: ident,\n        $x7: ident,\n        $n: ident,\n        $ninv: ident,\n        $w0: ident,\n        $ww0: ident,\n        $ww1: ident,\n        $www0: ident,\n        $www1: ident,\n        $www2: ident,\n        $www3: ident\n    ) => {\n        f64x4_length2inv_any_j!($x0, $x1, $n, $ninv, $www0);\n        f64x4_length2inv_any_j!($x2, $x3, $n, $ninv, $www1);\n        f64x4_length2inv_any_j!($x4, $x5, $n, $ninv, $www2);\n        f64x4_length2inv_any_j!($x6, $x7, $n, $ninv, $www3);\n        f64x4_length4inv_any_j!($x0, $x2, $x4, $x6, $n, $ninv, $w0, $ww0, $ww1);\n        f64x4_length4inv_any_j!($x1, $x3, $x5, $x7, $n, $ninv, $w0, $ww0, $ww1);\n    };\n}\n\n// This is sd_ifft_basecase_0_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nconst fn sd_ifft_basecase_0_1(_q: &FFTContext, _xs: &mut [f64]) {}\n\n// This is sd_ifft_basecase_1_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_basecase_1_1(q: &FFTContext, xs: &mut [f64]) {\n    if let &mut [ref mut x0, ref mut x1, ..] = xs {\n        f64_length2inv_zero_j_mut!(x0, x1, q.p, q.pinv);\n    }\n}\n\n// This is sd_ifft_basecase_2_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_basecase_2_1(q: &FFTContext, xs: &mut [f64]) {\n    if let &mut [ref mut x0, ref mut x1, ref mut x2, ref mut x3, ..] = xs {\n        f64_length4inv_zero_j_mut!(x0, x1, x2, x3, q.p, q.pinv, w2tab!(q, 1, 0));\n    }\n}\n\n// This is sd_ifft_basecase_3_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_basecase_3_1(q: &FFTContext, xs: &mut [f64]) {\n    if let &mut [\n        ref mut x0,\n        ref mut x1,\n        ref mut x2,\n        ref mut x3,\n        ref mut x4,\n        ref mut x5,\n        ref mut x6,\n        ref mut x7,\n        ..,\n    ] = xs\n    {\n        f64_length8inv_zero_j!(\n            x0,\n            x1,\n            x2,\n            x3,\n            x4,\n            x5,\n            x6,\n            x7,\n            q.p,\n            q.pinv,\n            w2tab!(q, 1, 0),\n            w2tab!(q, 2, 1),\n            w2tab!(q, 2, 0)\n        );\n    }\n}\n\n// This is sd_ifft_basecase_4_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_basecase_4_1(q: &FFTContext, xs: &mut [f64]) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    let q00 = w2tab!(q, 0, 0);\n    let q01 = w2tab!(q, 0, 1);\n    let q02 = w2tab!(q, 0, 2);\n    let q03 = w2tab!(q, 0, 3);\n    let w = f64x4::from([-q00, q03, w2tab!(q, 0, 7), w2tab!(q, 0, 5)]);\n    let iw = f64x4::from([q01, q02, w2tab!(q, 0, 6), w2tab!(q, 0, 4)]);\n    let w2 = f64x4::from([-q00, q01, q03, q02]);\n    f64x4_length4inv_any_j!(x0, x1, x2, x3, n, ninv, w2, w, iw);\n    f64x4_transpose!(x0, x1, x2, x3);\n    let iw = f64x4::splat(q01);\n    f64x4_length4inv_zero_j!(x0, x1, x2, x3, n, ninv, iw);\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n}\n\n// This is sd_ifft_basecase_4_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_basecase_4_0(q: &FFTContext, xs: &mut [f64], j_mr: usize, j_bits: u64) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    let j_bits = usize::exact_from(j_bits);\n    let w2 = read_f64x4_w2tab!(q, j_bits + 2, j_mr << 2);\n    let [w20, w21, w22, w23] = w2.to_array();\n    let w2 = f64x4::from([w23, w22, w21, w20]);\n    let jp3 = j_bits + 3;\n    let j_8 = j_mr << 3;\n    let [u0, u1, u2, u3] = read_f64x4_w2tab!(q, jp3, j_8).to_array();\n    let [v0, v1, v2, v3] = read_f64x4_w2tab!(q, jp3, j_8 + 4).to_array();\n    let mut w = f64x4::from([v3, v1, u3, u1]);\n    let mut iw = f64x4::from([v2, v0, u2, u0]);\n    f64x4_length4inv_any_j!(x0, x1, x2, x3, n, ninv, w2, w, iw);\n    f64x4_transpose!(x0, x1, x2, x3);\n    let jp1 = j_bits + 1;\n    let j_2 = j_mr << 1;\n    w = f64x4::splat(w2tab!(q, jp1, j_2 + 1));\n    iw = f64x4::splat(w2tab!(q, jp1, j_2));\n    let w2 = f64x4::splat(w2tab!(q, j_bits, j_mr));\n    f64x4_length4inv_any_j!(x0, x1, x2, x3, n, ninv, w2, w, iw);\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n}\n\n// This is sd_ifft_basecase_5_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_basecase_5_1(q: &FFTContext, xs: &mut [f64]) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    let mut x4 = read_f64x4!(xs, 16);\n    let mut x5 = read_f64x4!(xs, 20);\n    let mut x6 = read_f64x4!(xs, 24);\n    let mut x7 = read_f64x4!(xs, 28);\n    let q00 = w2tab!(q, 0, 0);\n    let q10 = w2tab!(q, 1, 0);\n    let q20 = w2tab!(q, 2, 0);\n    let q21 = w2tab!(q, 2, 1);\n    let q30 = w2tab!(q, 3, 0);\n    let q31 = w2tab!(q, 3, 1);\n    let q32 = w2tab!(q, 3, 2);\n    let q33 = w2tab!(q, 3, 3);\n    // j = 0, 1, 2, 3  then {j,2j+0,2j+1}^-1 in each column\n    let mut w0 = f64x4::from([-q00, q10, q21, q20]);\n    let mut ww0 = f64x4::from([-q00, q21, q33, q31]);\n    let mut ww1 = f64x4::from([q10, q20, q32, q30]);\n    f64x4_length4inv_any_j!(x0, x1, x2, x3, n, ninv, w0, ww0, ww1);\n    // j = 4, 5, 6, 7  then {j,2j+0,2j+1}^-1 in each column\n    w0 = f64x4::from([q33, q32, q31, q30]);\n    ww0 = f64x4::from([w2tab!(q, 4, 7), w2tab!(q, 4, 5), w2tab!(q, 4, 3), w2tab!(q, 4, 1)]);\n    ww1 = f64x4::from([w2tab!(q, 4, 6), w2tab!(q, 4, 4), w2tab!(q, 4, 2), w2tab!(q, 4, 0)]);\n    f64x4_length4inv_any_j!(x4, x5, x6, x7, n, ninv, w0, ww0, ww1);\n    f64x4_transpose!(x0, x1, x2, x3);\n    f64x4_transpose!(x4, x5, x6, x7);\n    ww1 = f64x4::splat(q10);\n    let www2 = f64x4::splat(q21);\n    let www3 = f64x4::splat(q20);\n    f64x4_length8inv_zero_j!(x0, x1, x2, x3, x4, x5, x6, x7, n, ninv, ww1, www2, www3);\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n    write_f64x4!(xs, 16, x4);\n    write_f64x4!(xs, 20, x5);\n    write_f64x4!(xs, 24, x6);\n    write_f64x4!(xs, 28, x7);\n}\n\n// This is sd_ifft_basecase_5_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_basecase_5_0(q: &FFTContext, xs: &mut [f64], j_mr: usize, j_bits: u64) {\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let mut x0 = read_f64x4!(xs, 0);\n    let mut x1 = read_f64x4!(xs, 4);\n    let mut x2 = read_f64x4!(xs, 8);\n    let mut x3 = read_f64x4!(xs, 12);\n    let mut x4 = read_f64x4!(xs, 16);\n    let mut x5 = read_f64x4!(xs, 20);\n    let mut x6 = read_f64x4!(xs, 24);\n    let mut x7 = read_f64x4!(xs, 28);\n    let j_bits = usize::exact_from(j_bits);\n    let j_8 = j_mr << 3;\n    let jp3 = j_bits + 3;\n    let [w00, w01, w02, w03] = read_f64x4_w2tab!(q, jp3, j_8 + 4).to_array();\n    let w0 = f64x4::from([w03, w02, w01, w00]);\n    let jp4 = j_bits + 4;\n    let j_16 = j_mr << 4;\n    let [u0, u1, u2, u3] = read_f64x4_w2tab!(q, jp4, j_16 + 8).to_array();\n    let [v0, v1, v2, v3] = read_f64x4_w2tab!(q, jp4, j_16 + 12).to_array();\n    let mut ww0 = f64x4::from([v3, v1, u3, u1]);\n    let mut ww1 = f64x4::from([v2, v0, u2, u0]);\n    f64x4_length4inv_any_j!(x0, x1, x2, x3, n, ninv, w0, ww0, ww1);\n    let [w00, w01, w02, w03] = read_f64x4_w2tab!(q, jp3, j_8).to_array();\n    let w0 = f64x4::from([w03, w02, w01, w00]);\n    let [u0, u1, u2, u3] = read_f64x4_w2tab!(q, jp4, j_16).to_array();\n    let [v0, v1, v2, v3] = read_f64x4_w2tab!(q, jp4, j_16 + 4).to_array();\n    ww0 = f64x4::from([v3, v1, u3, u1]);\n    ww1 = f64x4::from([v2, v0, u2, u0]);\n    f64x4_length4inv_any_j!(x4, x5, x6, x7, n, ninv, w0, ww0, ww1);\n    f64x4_transpose!(x0, x1, x2, x3);\n    f64x4_transpose!(x4, x5, x6, x7);\n    let w0 = f64x4::splat(w2tab!(q, j_bits, j_mr));\n    let jp1 = j_bits + 1;\n    let j_2 = j_mr << 1;\n    ww0 = f64x4::splat(w2tab!(q, jp1, j_2 + 1));\n    ww1 = f64x4::splat(w2tab!(q, jp1, j_2));\n    let jp2 = j_bits + 2;\n    let j_4 = j_mr << 2;\n    let www0 = f64x4::splat(w2tab!(q, jp2, j_4 + 3));\n    let www1 = f64x4::splat(w2tab!(q, jp2, j_4 + 2));\n    let www2 = f64x4::splat(w2tab!(q, jp2, j_4 + 1));\n    let www3 = f64x4::splat(w2tab!(q, jp2, j_4));\n    f64x4_length8inv_any_j!(\n        x0, x1, x2, x3, x4, x5, x6, x7, n, ninv, w0, ww0, ww1, www0, www1, www2, www3\n    );\n    write_f64x4!(xs, 0, x0);\n    write_f64x4!(xs, 4, x1);\n    write_f64x4!(xs, 8, x2);\n    write_f64x4!(xs, 12, x3);\n    write_f64x4!(xs, 16, x4);\n    write_f64x4!(xs, 20, x5);\n    write_f64x4!(xs, 24, x6);\n    write_f64x4!(xs, 28, x7);\n}\n\nmacro_rules! sd_ifft_basecase {\n    ($n: expr, $f0: ident, $f1: ident, $fs0: ident, $fs1: ident) => {\n        // This is sd_ifft_basecase_n_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\n        fn $f1(q: &FFTContext, xs: &mut [f64]) {\n            const LIMIT: usize = 1 << ($n - 2);\n            split_into_chunks_mut!(xs, LIMIT, [xs0, xs1, xs2], xs3);\n            $fs1(q, xs0);\n            $fs0(q, xs1, 0, 1);\n            $fs0(q, xs2, 1, 2);\n            $fs0(q, xs3, 0, 2);\n            radix_4_reverse_param_j_is_z!(q, iw, n, ninv);\n            process_4_3!(\n                radix_4_reverse_moth_j_is_z,\n                LIMIT,\n                xs0,\n                xs1,\n                xs2,\n                xs3,\n                iw,\n                n,\n                ninv\n            );\n        }\n\n        // This is sd_ifft_basecase_n_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\n        fn $f0(q: &FFTContext, xs: &mut [f64], j_mr: usize, j_bits: u64) {\n            const LIMIT: usize = 1 << ($n - 2);\n            assert_ne!(j_bits, 0);\n            split_into_chunks_mut!(xs, LIMIT, [xs0, xs1, xs2], xs3);\n            let j_mr_4 = j_mr << 2;\n            let j_bits_p_2 = j_bits + 2;\n            $fs0(q, xs0, j_mr_4 + 3, j_bits_p_2);\n            $fs0(q, xs1, j_mr_4 + 2, j_bits_p_2);\n            $fs0(q, xs2, j_mr_4 + 1, j_bits_p_2);\n            $fs0(q, xs3, j_mr_4, j_bits_p_2);\n            radix_4_reverse_param_j_is_nz!(q, j_mr, j_bits, w, w2, iw, n, ninv);\n            process_4_5!(\n                radix_4_reverse_moth_j_is_nz,\n                LIMIT,\n                xs0,\n                xs1,\n                xs2,\n                xs3,\n                w,\n                w2,\n                iw,\n                n,\n                ninv\n            );\n        }\n    };\n}\nsd_ifft_basecase!(\n    6,\n    sd_ifft_basecase_6_0,\n    sd_ifft_basecase_6_1,\n    sd_ifft_basecase_4_0,\n    sd_ifft_basecase_4_1\n);\nsd_ifft_basecase!(\n    7,\n    sd_ifft_basecase_7_0,\n    sd_ifft_basecase_7_1,\n    sd_ifft_basecase_5_0,\n    sd_ifft_basecase_5_1\n);\nsd_ifft_basecase!(\n    8,\n    sd_ifft_basecase_8_0,\n    sd_ifft_basecase_8_1,\n    sd_ifft_basecase_6_0,\n    sd_ifft_basecase_6_1\n);\nsd_ifft_basecase!(\n    9,\n    sd_ifft_basecase_9_0,\n    sd_ifft_basecase_9_1,\n    sd_ifft_basecase_7_0,\n    sd_ifft_basecase_7_1\n);\n\n// parameter 1: j can be zero\n//\n// This is sd_ifft_base_8_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_base_8_1(q: &FFTContext, x: &mut [f64], j: usize) {\n    set_j_bits_and_j_mr!(j, j_bits, j_mr);\n    if j == 0 {\n        sd_ifft_basecase_8_1(q, x);\n    } else {\n        sd_ifft_basecase_8_0(q, x, j_mr, j_bits);\n    }\n}\n\n// parameter 1: j cannot be zero\n//\n// This is sd_ifft_base_8_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_base_8_0(q: &FFTContext, x: &mut [f64], j: usize) {\n    set_j_bits_and_j_mr!(j, j_bits, j_mr);\n    sd_ifft_basecase_8_0(q, x, j_mr, j_bits);\n}\n\n// parameter 1: j can be zero\n//\n// This is sd_ifft_base_9_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_base_9_1(q: &FFTContext, x: &mut [f64], j: usize) {\n    set_j_bits_and_j_mr!(j, j_bits, j_mr);\n    if j == 0 {\n        sd_ifft_basecase_9_1(q, x);\n    } else {\n        sd_ifft_basecase_9_0(q, x, j_mr, j_bits);\n    }\n}\n\n// This is sd_ifft_no_trunc_internal from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_no_trunc_internal(\n    q: &FFTContext,\n    xs: &mut [f64],\n    // stride\n    s: usize,\n    // transform length BLK_SZ*2^k\n    k: u64,\n    j: usize,\n) {\n    if k > 2 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        let big_s_2 = s << (k2 + LG_BLK_SZ);\n        let shifted = j << k1;\n        let mut m = 0;\n        for b in 0..usize::power_of_2(k1) {\n            sd_ifft_no_trunc_internal(q, &mut xs[m..], s, k2, shifted + b);\n            m += big_s_2;\n        }\n        let big_s = s << LG_BLK_SZ;\n        let shifted = s << k2;\n        let mut m = 0;\n        for _ in 0..usize::power_of_2(k2) {\n            sd_ifft_no_trunc_block(q, &mut xs[m..], shifted, k1, j);\n            m += big_s;\n        }\n        return;\n    }\n    if k == 2 {\n        let big_s = s << LG_BLK_SZ;\n        // k1 = 2; k2 = 0\n        split_into_chunks_mut!(xs, big_s, [xs0, xs1, xs2], xs3);\n        let j_4 = j << 2;\n        sd_ifft_base_8_1(q, xs0, j_4);\n        sd_ifft_base_8_0(q, xs1, j_4 + 1);\n        sd_ifft_base_8_0(q, xs2, j_4 + 2);\n        sd_ifft_base_8_0(q, xs3, j_4 + 3);\n        sd_ifft_no_trunc_block(q, xs, s, 2, j);\n    } else if k == 1 {\n        sd_ifft_base_9_1(q, xs, j);\n    } else {\n        sd_ifft_base_8_1(q, xs, j);\n    }\n}\n\nconst BIG_M: usize = 4;\n\n// ```\n// k = 2, n = 3, z = 4, f = true\n// [      -r + 1           r + 1         2   r*w^3]\n// [        2//w           -2//w         0    -w^2]\n// [(r + 1)//w^2   (-r + 1)//w^2   -2//w^2    -r*w]\n// [          -r               r         1   r*w^3]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_3_4_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_3_4_1(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let pow = usize::power_of_2(j_bits);\n    let j_mr = pow - 1 - j;\n    let j_r = j & ((pow >> 1) - 1);\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let w = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, 1 + j_bits, (j_mr << 1) + 1)\n    };\n    let w2 = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, j_bits, j_mr)\n    };\n    let two_w = f64_reduce_pm1n_to_pmhn!(-2.0 * w, q.p);\n    let f0 = f64x4::splat(w2tab!(q, 0, 1)); // r\n    let f1 = f64x4::splat(two_w); // 2*w^-1\n    let f2 = f64x4::splat(2.0);\n    let f3 = f64x4::splat(w2); // -w^-2\n    let rw = if j == 0 {\n        w2tab!(q, 0, 1)\n    } else {\n        w2tab!(q, 1 + j_bits, (j_r << 1) + 1)\n    };\n    let fr = f64x4::splat(rw); // r*w\n    let fq = f64x4::splat(w2tab!(q, j_bits, j_r)); // w^2\n    let fp_alt = f64x4_mulmod!(fr, fq, n, ninv);\n    let fp = f64x4_reduce_pm1n_to_pmhn!(fp_alt, n); // r*w^3\n    for i in (0..BLK_SZ).step_by(BIG_M) {\n        let a = read_f64x4!(xs0, i);\n        let mut b = read_f64x4!(xs1, i);\n        let mut c = read_f64x4!(xs2, i);\n        let mut d = read_f64x4!(xs3, i);\n        let mut v = a - b;\n        let p = f64x4_mulmod!(d, fp, n, ninv);\n        let q = f64x4_mulmod!(d, fq, n, ninv);\n        let r = f64x4_mulmod!(d, fr, n, ninv);\n        c = f64x4_reduce_to_pm1n!(c, n, ninv);\n        let u = f64x4_reduce_to_pm1n!(a + b, n, ninv);\n        b = f64x4_mulmod!(v, f1, n, ninv);\n        v = f64x4_mulmod!(v, f0, n, ninv);\n        d = c - v;\n        c = f64x4_mul_add!(f2, c, -v);\n        write_f64x4!(xs0, i, c + u + p);\n        write_f64x4!(xs1, i, b - q);\n        write_f64x4!(xs2, i, f64x4_mulmod!(c - u, f3, n, ninv) - r);\n        write_f64x4!(xs3, i, d + p);\n    }\n}\n\n// ```\n// k = 2, n = 3, z = 4, f = false\n// [      -r + 1           r + 1         2   r*w^3]\n// [        2//w           -2//w         0    -w^2]\n// [(r + 1)//w^2   (-r + 1)//w^2   -2//w^2    -r*w]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_3_4_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_3_4_0(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let pow = usize::power_of_2(j_bits);\n    let j_mr = pow - 1 - j;\n    let j_r = j & ((pow >> 1) - 1);\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let jp1 = j_bits + 1;\n    let w = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, jp1, (j_mr << 1) + 1)\n    };\n    let w2 = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, j_bits, j_mr)\n    };\n    let two_w = f64_reduce_pm1n_to_pmhn!(-2.0 * w, q.p);\n    let f0 = f64x4::splat(w2tab!(q, 0, 1)); // r\n    let f1 = f64x4::splat(two_w); // 2*w^-1\n    let f2 = f64x4::splat(2.0);\n    let f3 = f64x4::splat(w2); // -w^-2\n    let rw = if j == 0 {\n        w2tab!(q, 0, 1)\n    } else {\n        w2tab!(q, jp1, (j_r << 1) + 1)\n    };\n    let fr = f64x4::splat(rw); // r*w\n    let fq = f64x4::splat(w2tab!(q, j_bits, j_r)); // w^2\n    let fp_alt = f64x4_mulmod!(fr, fq, n, ninv);\n    let fp = f64x4_reduce_pm1n_to_pmhn!(fp_alt, n); // r*w^3\n    for i in (0..BLK_SZ).step_by(BIG_M) {\n        let a = read_f64x4!(xs0, i);\n        let b = read_f64x4!(xs1, i);\n        let mut c = read_f64x4!(xs2, i);\n        let d = read_f64x4!(xs3, i);\n        let u = f64x4_reduce_to_pm1n!(a + b, n, ninv);\n        let v = a - b;\n        c = f64x4_mul_add!(\n            f2,\n            f64x4_reduce_to_pm1n!(c, n, ninv),\n            -f64x4_mulmod!(v, f0, n, ninv)\n        );\n        write_f64x4!(xs0, i, c + u + f64x4_mulmod!(d, fp, n, ninv));\n        write_f64x4!(\n            xs1,\n            i,\n            f64x4_mulmod!(v, f1, n, ninv) - f64x4_mulmod!(d, fq, n, ninv)\n        );\n        write_f64x4!(\n            xs2,\n            i,\n            f64x4_mulmod!(c - u, f3, n, ninv) - f64x4_mulmod!(d, fr, n, ninv)\n        );\n    }\n}\n\n// ```\n// k = 2, n = 3, z = 3, f = true\n// [      -r + 1           r + 1         2]\n// [        2//w           -2//w         0]\n// [(r + 1)//w^2   (-r + 1)//w^2   -2//w^2]\n// [          -r               r         1]\n//\n//     {x0, x1, x3, x4} = {        -r*(x0 - x1) + (x0 + x1) + 2*x2,\n//                         2*w^-1*    (x0 - x1),\n//                          -w^-2*(-r*(x0 - x1) - (x0 + x1) + 2*x2),\n//                                 -r*(x0 - x1)             +   x2  }\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_3_3_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_3_3_1(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let j_mr = usize::power_of_2(j_bits) - 1 - j;\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let w = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, 1 + j_bits, (j_mr << 1) + 1)\n    };\n    let w2 = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, j_bits, j_mr)\n    };\n    let two_w = f64_reduce_pm1n_to_pmhn!(-2.0 * w, q.p);\n    let f0 = f64x8::splat(w2tab!(q, 0, 1)); // r\n    let f1 = f64x8::splat(two_w); // 2*w^-1\n    let f2 = f64x8::splat(2.0);\n    let f3 = f64x8::splat(w2); // -w^-2\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let b = read_f64x8!(xs1, i);\n        let mut c = read_f64x8!(xs2, i);\n        let mut v = a - b;\n        write_f64x8!(xs1, i, f64x8_mulmod!(v, f1, n, ninv));\n        c = f64x8_reduce_to_pm1n!(c, n, ninv);\n        v = f64x8_mulmod!(v, f0, n, ninv);\n        write_f64x8!(xs3, i, c - v);\n        let u = f64x8_reduce_to_pm1n!(a + b, n, ninv);\n        c = f64x8_mul_add!(-f2, c, v);\n        write_f64x8!(xs0, i, u - c);\n        write_f64x8!(xs2, i, f64x8_nmulmod!(u + c, f3, n, ninv));\n    }\n}\n\n// ```\n// k = 2, n = 3, z = 3, f = false\n// [      -r + 1           r + 1         2]\n// [        2//w           -2//w         0]\n// [(r + 1)//w^2   (-r + 1)//w^2   -2//w^2]\n//\n//     {x0, x1, x3} = {        -r*(x0 - x1) + (x0 + x1) + 2*x2,\n//                     2*w^-1*(x0 - x1),\n//                      -w^-2*(-r*(x0 - x1) - (x0 + x1) + 2*x2)}\n//\n//                  = {        2*x2 - r*v + u,\n//                     2*w^-1*v,\n//                      -w^-2*(2*x2 - r*v - u)}\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_3_3_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_3_3_0(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1], xs2);\n    let j_mr = usize::power_of_2(j_bits) - 1 - j;\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let w = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, 1 + j_bits, (j_mr << 1) + 1)\n    };\n    let w2 = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, j_bits, j_mr)\n    };\n    let two_w = f64_reduce_pm1n_to_pmhn!(-2.0 * w, q.p);\n    let f0 = f64x8::splat(w2tab!(q, 0, 1)); // r\n    let f1 = f64x8::splat(two_w); // 2*w^-1\n    let f2 = f64x8::splat(2.0);\n    let f3 = f64x8::splat(w2); // -w^-2\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let b = read_f64x8!(xs1, i);\n        let mut c = read_f64x8!(xs2, i);\n        let v = a - b;\n        write_f64x8!(xs1, i, f64x8_mulmod!(v, f1, n, ninv));\n        c = f64x8_reduce_to_pm1n!(c, n, ninv);\n        let mut u = a + b;\n        u = f64x8_reduce_to_pm1n!(u, n, ninv);\n        c = f64x8_mul_add!(-f2, c, f64x8_mulmod!(v, f0, n, ninv));\n        write_f64x8!(xs0, i, u - c);\n        write_f64x8!(xs2, i, f64x8_nmulmod!(u + c, f3, n, ninv));\n    }\n}\n\n// ```\n// k = 2, n = 2, z = 4, f = true\n// [            2                2        -w^2             0]\n// [         2//w            -2//w           0          -w^2]\n// [1//2*r + 1//2   -1//2*r + 1//2   -1//2*w^2   -1//2*r*w^3]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_2_4_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_2_4_1(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let pow = usize::power_of_2(j_bits);\n    let j_mr = pow - 1 - j;\n    let j_r = j & ((pow >> 1) - 1);\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let jp1 = j_bits + 1;\n    let big_w = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, jp1, (j_mr << 1) + 1)\n    };\n    let rw = if j == 0 {\n        w2tab!(q, 0, 1)\n    } else {\n        w2tab!(q, jp1, (j_r << 1) + 1)\n    };\n    let w = w2tab!(q, j_bits, j_r);\n    let two_w = f64_reduce_pm1n_to_pmhn!(-2.0 * big_w, q.p);\n    let rw3 = f64_mulmod!(w, rw, q.p, q.pinv);\n    let f0 = f64x4::splat(2.0);\n    let f1 = f64x4::splat(two_w); // 2*w^-1\n    let f2 = f64x4::splat(fma!(-0.5f64, q.p, 0.5)); // 1/2\n    let f3 = f64x4::splat(w2tab!(q, 0, 1)); // r\n    let f4 = f64x4::splat(w); // w^2\n    let f5 = f64x4::splat(f64_reduce_pm1n_to_pmhn!(rw3, q.p)); // r*w^3\n    for i in (0..BLK_SZ).step_by(BIG_M) {\n        let u = read_f64x4!(xs0, i);\n        let v = read_f64x4!(xs1, i);\n        let a = read_f64x4!(xs2, i);\n        let b = read_f64x4!(xs3, i);\n        let p = f64x4_mulmod!(a, f4, n, ninv);\n        let q = f64x4_mulmod!(b, f4, n, ninv);\n        let r = f64x4_mulmod!(b, f5, n, ninv);\n        let s = f64x4_reduce_to_pm1n!(u + v, n, ninv);\n        let t = u - v;\n        write_f64x4!(xs0, i, f64x4_mulmod!(s, f0, n, ninv) - p);\n        write_f64x4!(xs1, i, f64x4_mulmod!(t, f1, n, ninv) - q);\n        write_f64x4!(\n            xs2,\n            i,\n            f64x4_mulmod!((s + f64x4_mulmod!(t, f3, n, ninv)) - (p + r), f2, n, ninv)\n        );\n    }\n}\n\n// ```\n// k = 2, n = 2, z = 4, f = false\n// [   2       2   -w^2      0]\n// [2//w   -2//w      0   -w^2]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_2_4_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_2_4_0(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let pow = usize::power_of_2(j_bits);\n    let j_mr = pow - 1 - j;\n    let j_r = j & ((pow >> 1) - 1);\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let wi = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, 1 + j_bits, (j_mr << 1) + 1)\n    };\n    let w2 = f64x8::splat(w2tab!(q, j_bits, j_r));\n    let twowi = f64x8::splat(f64_reduce_pm1n_to_pmhn!(-2.0 * wi, q.p));\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let b = read_f64x8!(xs1, i);\n        let c = read_f64x8!(xs2, i);\n        let d = read_f64x8!(xs3, i);\n        let mut u = a + b;\n        u += u;\n        write_f64x8!(\n            xs0,\n            i,\n            f64x8_reduce_to_pm1n!(u, n, ninv) - f64x8_mulmod!(c, w2, n, ninv)\n        );\n        write_f64x8!(\n            xs1,\n            i,\n            f64x8_mulmod!(a - b, twowi, n, ninv) - f64x8_mulmod!(d, w2, n, ninv)\n        );\n    }\n}\n\n// ```\n// k = 2, n = 2, z = 2, f = true\n// [            2                2]\n// [         2//w            -2//w]\n// [1//2*r + 1//2   -1//2*r + 1//2]\n//\n// {x0, x1, x2} = {2*(x0 + x1), 2*w^-1*(x0 - x1), (x0+x1)/2 + (x0-x1)*i/2}\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_2_2_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_2_2_1(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1], xs2);\n    let j_mr = usize::power_of_2(j_bits) - 1 - j;\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let w = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, 1 + j_bits, (j_mr << 1) + 1)\n    };\n    let c1 = f64x8::splat(f64_reduce_pm1n_to_pmhn!(-2.0 * w, q.p)); // 2/w\n    let c2 = f64x8::splat(fma!(-0.5f64, q.p, 0.5)); // 1/2\n    let c3 = f64x8::splat(w2tab!(q, 1, 0)); // r\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let mut u = read_f64x8!(xs0, i);\n        let v = read_f64x8!(xs1, i);\n        let s = u + v;\n        let t = u - v;\n        u = s + s;\n        write_f64x8!(xs0, i, f64x8_reduce_to_pm1n!(u, n, ninv));\n        write_f64x8!(xs1, i, f64x8_mulmod!(t, c1, n, ninv));\n        write_f64x8!(\n            xs2,\n            i,\n            f64x8_mulmod!(s + f64x8_mulmod!(t, c3, n, ninv), c2, n, ninv)\n        );\n    }\n}\n\n// ```\n// k = 2, n = 2, z = 2, f = 0\n//\n// {x0, x1} = {2*(x0 + x1), 2*w^-1*(x0 - x1)}\n//\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_2_2_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_2_2_0(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    fail_on_untested_path(\"radix_4_moth_inv_trunc_block_2_2_0\");\n    let (xs0, xs1) = xs.split_at_mut(gap);\n    let j_mr = usize::power_of_2(j_bits) - 1 - j;\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let j_bits = usize::exact_from(j_bits);\n    let w = if j == 0 {\n        -1.0\n    } else {\n        w2tab!(q, 1 + j_bits, (j_mr << 1) + 1)\n    };\n    let c0 = f64x8::splat(2.0);\n    let c1 = f64x8::splat(f64_reduce_pm1n_to_pmhn!(-2.0 * w, q.p));\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let u = read_f64x8!(xs0, i);\n        let v = read_f64x8!(xs1, i);\n        write_f64x8!(xs0, i, f64x8_mulmod!(u + v, c0, n, ninv));\n        write_f64x8!(xs1, i, f64x8_mulmod!(u - v, c1, n, ninv));\n    }\n}\n\n// ```\n// k = 2, n = 1, z = 4, f = true\n// [4        -w   -w^2        -w^3]\n// [1   -1//2*w      0   -1//2*w^3]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_1_4_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_1_4_1(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let j_r = j & ((usize::power_of_2(j_bits) >> 1) - 1);\n    let j_bits = usize::exact_from(j_bits);\n    let big_w2 = w2tab!(q, j_bits, j_r);\n    let w = if j == 0 {\n        1.0\n    } else {\n        w2tab!(q, 1 + j_bits, (j_r << 1))\n    };\n    let n = f64x4::splat(q.p);\n    let ninv = f64x4::splat(q.pinv);\n    let f2 = f64x4::splat(2.0);\n    let w2 = f64x4::splat(big_w2);\n    let ha = fma!(-0.5f64, q.p, 0.5);\n    let ha_w = f64_mulmod!(w, ha, q.p, q.pinv);\n    let wo2 = f64x4::splat(f64_reduce_pm1n_to_pmhn!(ha_w, q.p));\n    for i in (0..BLK_SZ).step_by(BIG_M) {\n        let mut a = read_f64x4!(xs0, i);\n        a = f64x4_reduce_to_pm1n!(a, n, ninv);\n        let mut b = read_f64x4!(xs1, i);\n        let mut c = read_f64x4!(xs2, i);\n        let mut d = read_f64x4!(xs3, i);\n        c = f64x4_nmulmod!(c, w2, n, ninv);\n        d = f64x4_mulmod!(d, w2, n, ninv);\n        b = f64x4_mulmod!(b + d, wo2, n, ninv);\n        let u = f64x4_mul_add!(-f2, a, b);\n        write_f64x4!(xs0, i, c - f64x4_reduce_to_pm1n!(u + u, n, ninv));\n        write_f64x4!(xs1, i, a - b);\n    }\n}\n\n// ```\n// k = 2, n = 1, z = 4, f = false\n// [4   -w   -w^2   -w^3]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_1_4_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_1_4_0(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let j_r = j & ((usize::power_of_2(j_bits) >> 1) - 1);\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let f1 = f64x8::splat(4.0);\n    let j_bits = usize::exact_from(j_bits);\n    let w2 = f64x8::splat(w2tab!(q, j_bits, j_r));\n    let w = f64x8::splat(if j == 0 {\n        1.0\n    } else {\n        w2tab!(q, 1 + j_bits, j_r << 1)\n    });\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let b = read_f64x8!(xs1, i);\n        let c = read_f64x8!(xs2, i);\n        let d = read_f64x8!(xs3, i);\n        write_f64x8!(\n            xs0,\n            i,\n            f64x8_reduce_to_pm1n!(a * f1, n, ninv)\n                - f64x8_mulmod!(b, w, n, ninv)\n                - f64x8_mulmod!(c + f64x8_mulmod!(d, w, n, ninv), w2, n, ninv)\n        );\n    }\n}\n\n// ```\n// k = 2, n = 1, z = 1, f = true\n// [4]\n// [1]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_1_1_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_1_1_1(\n    q: &FFTContext,\n    _j: usize,\n    _j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    fail_on_untested_path(\"radix_4_moth_inv_trunc_block_1_1_1\");\n    let (xs0, xs1) = xs.split_at_mut(gap);\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let f = f64x8::splat(4.0);\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        write_f64x8!(xs0, i, f64x8_reduce_to_pm1n!(f * a, n, ninv));\n        write_f64x8!(xs1, i, f64x8_reduce_to_pm1n!(a, n, ninv));\n    }\n}\n\n// ```\n// k = 2, n = 1, z = 1, f = false\n// [4]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_1_1_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_1_1_0(\n    q: &FFTContext,\n    _j: usize,\n    _j_bits: u64,\n    xs: &mut [f64],\n    _gap: usize,\n) {\n    fail_on_untested_path(\"radix_4_moth_inv_trunc_block_1_1_0\");\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let f = f64x8::splat(4.0);\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs, i);\n        write_f64x8!(xs, i, f64x8_reduce_to_pm1n!(f * a, n, ninv));\n    }\n}\n\n// ```\n// k = 2, n = 0, z = 4, f = true\n// [1//4   1//4*w   1//4*w^2   1//4*w^3]\n// ```\n//\n// This is radix_4_moth_inv_trunc_block_0_4_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_4_moth_inv_trunc_block_0_4_1(\n    q: &FFTContext,\n    j: usize,\n    j_bits: u64,\n    xs: &mut [f64],\n    gap: usize,\n) {\n    split_into_chunks_mut!(xs, gap, [xs0, xs1, xs2], xs3);\n    let j_r = j & ((usize::power_of_2(j_bits) >> 1) - 1);\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let one4th = f64x8::splat(fma!(-0.25f64, q.p, 0.25));\n    let j_bits = usize::exact_from(j_bits);\n    let w2 = f64x8::splat(w2tab!(q, j_bits, j_r));\n    let w = f64x8::splat(if j == 0 {\n        1.0\n    } else {\n        w2tab!(q, 1 + j_bits, j_r << 1)\n    });\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let b = read_f64x8!(xs1, i);\n        let c = read_f64x8!(xs2, i);\n        let d = read_f64x8!(xs3, i);\n        write_f64x8!(\n            xs0,\n            i,\n            f64x8_mulmod!(\n                a + f64x8_mulmod!(b, w, n, ninv)\n                    + f64x8_mulmod!(c + f64x8_mulmod!(d, w, n, ninv), w2, n, ninv),\n                one4th,\n                n,\n                ninv\n            )\n        );\n    }\n}\n\n// This is sd_fft_ctx_w2 from fft_small.h, FLINT 3.3.0-dev.\nfn sd_fft_ctx_w2(q: &FFTContext, j: usize) -> f64 {\n    set_j_bits_and_j_r!(j, j_bits, j_r);\n    w2tab!(q, usize::exact_from(j_bits), j_r)\n}\n\n// {x0, x1} = {2*x0 - w*x1, x0 - w*x1}\n//\n// This is radix_2_moth_inv_trunc_block_1_2_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_2_moth_inv_trunc_block_1_2_1(q: &FFTContext, j: usize, xs0: &mut [f64], xs1: &mut [f64]) {\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let w = f64x8::splat(sd_fft_ctx_w2(q, j));\n    let c = f64x8::splat(2.0);\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let mut b = read_f64x8!(xs1, i);\n        b = f64x8_nmulmod!(b, w, n, ninv);\n        write_f64x8!(\n            xs0,\n            i,\n            f64x8_reduce_to_pm1n!(f64x8_mul_add!(c, a, b), n, ninv)\n        );\n        write_f64x8!(xs1, i, f64x8_reduce_to_pm1n!(a + b, n, ninv));\n    }\n}\n\n// {x0} = {2*x0 - w*x1}\n//\n// This is radix_2_moth_inv_trunc_block_1_2_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_2_moth_inv_trunc_block_1_2_0(q: &FFTContext, j: usize, xs0: &mut [f64], xs1: &mut [f64]) {\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let w = f64x8::splat(sd_fft_ctx_w2(q, j));\n    let c = f64x8::splat(2.0);\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let b = read_f64x8!(xs1, i);\n        write_f64x8!(\n            xs0,\n            i,\n            f64x8_reduce_to_pm1n!(f64x8_mul_add!(c, a, -f64x8_mulmod!(b, w, n, ninv)), n, ninv)\n        );\n    }\n}\n\n// {x0, x1} = {2*x0, x0}\n//\n// This is radix_2_moth_inv_trunc_block_1_1_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_2_moth_inv_trunc_block_1_1_1(q: &FFTContext, _j: usize, xs0: &mut [f64], xs1: &mut [f64]) {\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let u = a + a;\n        write_f64x8!(xs0, i, f64x8_reduce_to_pm1n!(u, n, ninv));\n        write_f64x8!(xs1, i, a);\n    }\n}\n\n// {x0} = {2*x0}\n//\n// This is radix_2_moth_inv_trunc_block_1_1_0 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_2_moth_inv_trunc_block_1_1_0(\n    q: &FFTContext,\n    _j: usize,\n    xs0: &mut [f64],\n    _xs1: &mut [f64],\n) {\n    fail_on_untested_path(\"radix_2_moth_inv_trunc_block_1_1_0\");\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let mut a = read_f64x8!(xs0, i);\n        a = a + a;\n        write_f64x8!(xs0, i, f64x8_reduce_to_pm1n!(a, n, ninv));\n    }\n}\n\n// {x0} = {(x0 + w*x1)/2}\n//\n// This is radix_2_moth_inv_trunc_block_0_2_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_2_moth_inv_trunc_block_0_2_1(q: &FFTContext, j: usize, xs0: &mut [f64], xs1: &mut [f64]) {\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let w = f64x8::splat(sd_fft_ctx_w2(q, j));\n    let c = f64x8::splat(fma!(-0.5f64, q.p, 0.5));\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        let b = read_f64x8!(xs1, i);\n        write_f64x8!(\n            xs0,\n            i,\n            f64x8_mulmod!(a + f64x8_mulmod!(b, w, n, ninv), c, n, ninv)\n        );\n    }\n}\n\n// {x0} = {(x0)/2}\n//\n// This is radix_2_moth_inv_trunc_block_0_1_1 from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn radix_2_moth_inv_trunc_block_0_1_1(\n    q: &FFTContext,\n    _j: usize,\n    xs0: &mut [f64],\n    _xs1: &mut [f64],\n) {\n    fail_on_untested_path(\"radix_2_moth_inv_trunc_block_0_1_1\");\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    let c = f64x8::splat(fma!(-0.5f64, q.p, 0.5));\n    for i in (0..BLK_SZ).step_by(BIG_N) {\n        let a = read_f64x8!(xs0, i);\n        write_f64x8!(xs0, i, f64x8_mulmod!(a, c, n, ninv));\n    }\n}\n\nconst SD_IFFT_4_MOTH_TRUNC_BLOCK_TABLE: [Option<Sd4MothTruncBlockFn>; 40] = [\n    None,\n    None,\n    None,\n    None,\n    None,\n    None,\n    None,\n    Some(radix_4_moth_inv_trunc_block_0_4_1),\n    Some(radix_4_moth_inv_trunc_block_1_1_0),\n    Some(radix_4_moth_inv_trunc_block_1_1_1),\n    None,\n    None,\n    None,\n    None,\n    Some(radix_4_moth_inv_trunc_block_1_4_0),\n    Some(radix_4_moth_inv_trunc_block_1_4_1),\n    None,\n    None,\n    Some(radix_4_moth_inv_trunc_block_2_2_0),\n    Some(radix_4_moth_inv_trunc_block_2_2_1),\n    None,\n    None,\n    Some(radix_4_moth_inv_trunc_block_2_4_0),\n    Some(radix_4_moth_inv_trunc_block_2_4_1),\n    None,\n    None,\n    None,\n    None,\n    Some(radix_4_moth_inv_trunc_block_3_3_0),\n    Some(radix_4_moth_inv_trunc_block_3_3_1),\n    Some(radix_4_moth_inv_trunc_block_3_4_0),\n    Some(radix_4_moth_inv_trunc_block_3_4_1),\n    None,\n    None,\n    None,\n    None,\n    None,\n    None,\n    None,\n    None,\n];\n\nconst SD_IFFT_2_MOTH_TRUNC_BLOCK_TABLE: [Option<Sd2MothTruncBlockFn>; 12] = [\n    None,\n    Some(radix_2_moth_inv_trunc_block_0_1_1),\n    None,\n    Some(radix_2_moth_inv_trunc_block_0_2_1),\n    Some(radix_2_moth_inv_trunc_block_1_1_0),\n    Some(radix_2_moth_inv_trunc_block_1_1_1),\n    Some(radix_2_moth_inv_trunc_block_1_2_0),\n    Some(radix_2_moth_inv_trunc_block_1_2_1),\n    None,\n    None,\n    None,\n    None,\n];\n\n// This is sd_ifft_trunc_block from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_trunc_block(\n    q: &FFTContext,\n    // data + BLK_SZ*I\n    xs: &mut [f64],\n    // stride\n    s: usize,\n    // BLK_SZ transforms each of length 2^k\n    k: u64,\n    j: usize,\n    // actual trunc is z\n    z: usize,\n    // actual trunc is n\n    n: usize,\n    f: bool,\n) {\n    assert!(n <= z);\n    let pow = usize::power_of_2(k);\n    assert!(1 <= z && z <= pow);\n    let sum = n + usize::from(f);\n    assert!(1 <= sum && sum <= pow);\n    if !f && z == n && n == pow {\n        sd_ifft_no_trunc_block(q, xs, s, k, j);\n        return;\n    }\n    let big_s = s << LG_BLK_SZ;\n    if k == 2\n        && let Some(fxn) =\n            SD_IFFT_4_MOTH_TRUNC_BLOCK_TABLE[usize::from(f) + ((z - 1 + (n << 2)) << 1)]\n    {\n        fxn(q, j, j.significant_bits(), xs, big_s);\n        return;\n    }\n    if k > 1 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        let l2 = usize::power_of_2(k2);\n        let n1 = n >> k2;\n        let mask = l2 - 1;\n        let n2 = n & mask;\n        let z1 = z >> k2;\n        let z2 = z & mask;\n        let fp = f || n2 != 0;\n        let z2p = min(l2, z);\n        let m = min(n2, z2);\n        let mp = max(n2, z2);\n        // complete rows\n        let big_s_2 = s << (k2 + LG_BLK_SZ);\n        let shifted = j << k1;\n        let mut p = 0;\n        for b in 0..n1 {\n            sd_ifft_no_trunc_block(q, &mut xs[p..], s, k2, shifted + b);\n            p += big_s_2;\n        }\n        // rightmost columns\n        let shifted2 = s << k2;\n        let mut p = n2 * big_s;\n        for a in n2..z2p {\n            sd_ifft_trunc_block(\n                q,\n                &mut xs[p..],\n                shifted2,\n                k1,\n                j,\n                z1 + usize::from(a < mp),\n                n1,\n                fp,\n            );\n            p += big_s;\n        }\n        // last partial row\n        if fp {\n            sd_ifft_trunc_block(q, &mut xs[n1 * big_s_2..], s, k2, shifted + n1, z2p, n2, f);\n        }\n        let sum = n1 + 1;\n        let mut p = 0;\n        // leftmost columns\n        for a in 0..n2 {\n            sd_ifft_trunc_block(\n                q,\n                &mut xs[p..],\n                shifted2,\n                k1,\n                j,\n                z1 + usize::from(a < m),\n                sum,\n                false,\n            );\n            p += big_s;\n        }\n        return;\n    }\n    if k == 1\n        && let Some(fxn) =\n            SD_IFFT_2_MOTH_TRUNC_BLOCK_TABLE[usize::from(f) + ((z - 1 + (n << 1)) << 1)]\n    {\n        let (xs0, xs1) = xs.split_at_mut(big_s);\n        fxn(q, j, xs0, xs1);\n    }\n}\n\n// This is sd_ifft_trunc_internal from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_trunc_internal(\n    q: &FFTContext,\n    // x = data + BLK_SZ*I  where I = starting index\n    xs: &mut [f64],\n    // stride\n    s: usize,\n    // transform length 2^(k + LG_BLK_SZ)\n    k: u64,\n    j: usize,\n    // actual trunc is z*BLK_SZ\n    z: usize,\n    // actual trunc is n*BLK_SZ\n    n: usize,\n    f: bool,\n) {\n    assert!(n <= z);\n    let big_z = z << LG_BLK_SZ;\n    let pow = usize::power_of_2(k + LG_BLK_SZ);\n    assert!(1 <= big_z && big_z <= pow);\n    let uf = usize::from(f);\n    let big_n = n << LG_BLK_SZ;\n    assert!(1 <= big_n + uf && big_n + uf <= pow);\n    if !f && z == n && n == usize::power_of_2(k) {\n        sd_ifft_no_trunc_internal(q, xs, s, k, j);\n        return;\n    }\n    let big_s = s << LG_BLK_SZ;\n    if k > 2 {\n        let k1 = k >> 1;\n        let k2 = k - k1;\n        let l2 = usize::power_of_2(k2);\n        let n1 = n >> k2;\n        let mask = l2 - 1;\n        let n2 = n & mask;\n        let z1 = z >> k2;\n        let z2 = z & mask;\n        let fp = f || n2 != 0;\n        let z2p = min(l2, z);\n        let m = min(n2, z2);\n        let mp = max(n2, z2);\n        // complete rows\n        let shifted = j << k1;\n        let big_s_2 = s << (k2 + LG_BLK_SZ);\n        let mut p = 0;\n        for b in 0..n1 {\n            sd_ifft_no_trunc_internal(q, &mut xs[p..], s, k2, shifted + b);\n            p += big_s_2;\n        }\n        // rightmost columns\n        let shifted_2 = s << k2;\n        let mut p = n2 * big_s;\n        for a in n2..z2p {\n            sd_ifft_trunc_block(\n                q,\n                &mut xs[p..],\n                shifted_2,\n                k1,\n                j,\n                z1 + usize::from(a < mp),\n                n1,\n                fp,\n            );\n            p += big_s;\n        }\n        // last partial row\n        if fp {\n            sd_ifft_trunc_internal(q, &mut xs[n1 * big_s_2..], s, k2, shifted + n1, z2p, n2, f);\n        }\n        // leftmost columns\n        let sum = n1 + 1;\n        let mut p = 0;\n        for a in 0..n2 {\n            sd_ifft_trunc_block(\n                q,\n                &mut xs[p..],\n                shifted_2,\n                k1,\n                j,\n                z1 + usize::from(a < m),\n                sum,\n                false,\n            );\n            p += big_s;\n        }\n        return;\n    }\n    if k == 2 {\n        let four_j = j << 2;\n        sd_ifft_base_8_1(q, xs, four_j);\n        if n > 1 {\n            sd_ifft_base_8_0(q, &mut xs[big_s..], four_j + 1);\n        }\n        if n > 2 {\n            sd_ifft_base_8_0(q, &mut xs[big_s << 1..], four_j + 2);\n        }\n        if n > 3 {\n            sd_ifft_base_8_0(q, &mut xs[big_s * 3..], four_j + 3);\n        }\n        sd_ifft_trunc_block(q, xs, s, 2, j, z, n, f);\n        if f {\n            sd_ifft_trunc_internal(q, &mut xs[big_s * n..], s, 0, four_j + n, 1, 0, f);\n        }\n    } else if k == 1 {\n        fail_on_untested_path(\"sd_ifft_trunc_internal, k == 1\");\n        let two_j = j << 1;\n        sd_ifft_base_8_1(q, xs, two_j);\n        if n > 1 {\n            sd_ifft_base_8_0(q, &mut xs[big_s..], two_j + 1);\n        }\n        sd_ifft_trunc_block(q, xs, s, 1, j, z, n, f);\n        if f {\n            sd_ifft_trunc_internal(q, &mut xs[big_s * n..], s, 0, two_j + n, 1, 0, f);\n        }\n    } else {\n        assert!(!f);\n        sd_ifft_base_8_1(q, xs, j);\n    }\n}\n\n// This is sd_ifft_trunc from fft_small/sd_ifft.c, FLINT 3.3.0-dev.\nfn sd_ifft_trunc(\n    q: &mut FFTContext,\n    d: &mut [f64],\n    // convolution length 2^L\n    l: u64,\n    trunc: usize,\n) {\n    assert!(trunc <= usize::power_of_2(l));\n    if l > LG_BLK_SZ {\n        let new_trunc = trunc.div_round(BLK_SZ, Ceiling).0;\n        sd_fft_ctx_fit_depth(q, l);\n        sd_ifft_trunc_internal(q, d, 1, l - LG_BLK_SZ, 0, new_trunc, new_trunc, false);\n        return;\n    }\n    fail_on_untested_path(\"sd_ifft_trunc, l <= LG_BLK_SZ\");\n    match l {\n        0 => sd_ifft_basecase_0_1(q, d),\n        1 => sd_ifft_basecase_1_1(q, d),\n        2 => sd_ifft_basecase_2_1(q, d),\n        3 => sd_ifft_basecase_3_1(q, d),\n        4 => sd_ifft_basecase_4_1(q, d),\n        5 => sd_ifft_basecase_5_1(q, d),\n        6 => sd_ifft_basecase_6_1(q, d),\n        7 => sd_ifft_basecase_7_1(q, d),\n        8 => sd_ifft_basecase_8_1(q, d),\n        _ => unreachable!(),\n    }\n}\n\n// pointwise mul of a with b and m\n//\n// This is sd_fft_ctx_point_mul from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn sd_fft_ctx_point_mul(q: &FFTContext, a: &mut [f64], b: &[f64], m_orig: u64, depth: u64) {\n    let m = f64x8::splat(f64_reduce_0n_to_pmhn!(m_orig as f64, q.p));\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    assert!(depth >= LG_BLK_SZ);\n    let mut k = 0;\n    for _ in 0..usize::power_of_2(depth - LG_BLK_SZ) {\n        let ax = &mut a[k..];\n        let bx = &b[k..];\n        for j in (0..BLK_SZ).step_by(16) {\n            let mut x0 = read_f64x8!(ax, j);\n            let mut x1 = read_f64x8!(ax, j + 8);\n            let b0 = read_f64x8!(bx, j);\n            let b1 = read_f64x8!(bx, j + 8);\n            x0 = f64x8_mulmod!(x0, m, n, ninv);\n            x1 = f64x8_mulmod!(x1, m, n, ninv);\n            x0 = f64x8_mulmod!(x0, b0, n, ninv);\n            x1 = f64x8_mulmod!(x1, b1, n, ninv);\n            write_f64x8!(ax, j, x0);\n            write_f64x8!(ax, j + 8, x1);\n        }\n        k += BLK_SZ;\n    }\n}\n\n// This is sd_fft_ctx_point_sqr from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn sd_fft_ctx_point_sqr(q: &FFTContext, a: &mut [f64], m_orig: u64, depth: u64) {\n    let m = f64x8::splat(f64_reduce_0n_to_pmhn!(m_orig as f64, q.p));\n    let n = f64x8::splat(q.p);\n    let ninv = f64x8::splat(q.pinv);\n    assert!(depth >= LG_BLK_SZ);\n    let mut k = 0;\n    for _ in 0..usize::power_of_2(depth - LG_BLK_SZ) {\n        let ax = &mut a[k..];\n        for j in (0..BLK_SZ).step_by(16) {\n            let mut x0 = read_f64x8!(ax, j);\n            let mut x1 = read_f64x8!(ax, j + 8);\n            x0 = f64x8_mulmod!(x0, x0, n, ninv);\n            x1 = f64x8_mulmod!(x1, x1, n, ninv);\n            x0 = f64x8_mulmod!(x0, m, n, ninv);\n            x1 = f64x8_mulmod!(x1, m, n, ninv);\n            write_f64x8!(ax, j, x0);\n            write_f64x8!(ax, j + 8, x1);\n        }\n        k += BLK_SZ;\n    }\n}\n\n// cmp(a, b*2^e), a does not have to be normalized\n//\n// This is flint_mpn_cmp_ui_2exp from fft_small/mul_helpers.c, FLINT 3.3.0-dev.\nfn flint_mpn_cmp_ui_2exp(a: &[u64], b: u64, e: u64) -> Ordering {\n    let mut an = a.len();\n    let mut q = usize::exact_from(e >> u64::LOG_WIDTH);\n    let r = e & u64::WIDTH_MASK;\n    while an != 0 && a[an - 1] == 0 {\n        an -= 1;\n    }\n    if an == 0 {\n        return if b == 0 { Equal } else { Greater };\n    }\n    // ```\n    // b*2^e = (b*2^r       )*2^(64*q)\n    //       = (b0 + b1*2^64)*2^(64*q)\n    // ```\n    let (b0, b1) = if r == 0 {\n        (b, 0)\n    } else {\n        (b << r, b >> (u64::WIDTH - r))\n    };\n    // ```\n    //      check words [q+2,infty)\n    // then check words [q+1, 64*q+128) against b1\n    // then check words [q, q+1) against b0\n    // then check words [0, q)\n    // ```\n    if an > q + 2 {\n        return Greater;\n    }\n    let mut x = if q + 1 < an { a[q + 1] } else { 0 };\n    if x != b1 {\n        return x.cmp(&b1);\n    }\n    x = if q < an { a[q] } else { 0 };\n    if x != b0 {\n        return x.cmp(&b0);\n    }\n    q = min(q, an);\n    if a[..q].iter().any(|&x| x != 0) {\n        return Greater;\n    }\n    Less\n}\n\n// This is mod_worker_func from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn process_mod(\n    to_ffts: MPNToFFTFunc,\n    ffts: &[FFTContext],\n    stride: usize,\n    two_pow_tab: &[f64x4],\n    abuf: &mut [f64],\n    a: &[Limb],\n    atrunc: usize,\n    a_stop_easy: usize,\n    a_start_hard: usize,\n    a_stop_hard: usize,\n    bbuf: &mut [f64],\n    b: &[Limb],\n    btrunc: usize,\n    b_stop_easy: usize,\n    b_start_hard: usize,\n    b_stop_hard: usize,\n    squaring: bool,\n) {\n    let f = match to_ffts {\n        MPNToFFTFunc { np: 4, bits: 84 } => apply_mpn_to_fft_func_4_84,\n        MPNToFFTFunc { np: 4, bits: 88 } => apply_mpn_to_fft_func_4_88,\n        MPNToFFTFunc { np: 4, bits: 92 } => apply_mpn_to_fft_func_4_92,\n        MPNToFFTFunc { np: 5, bits: 112 } => apply_mpn_to_fft_func_5_112,\n        MPNToFFTFunc { np: 5, bits: 116 } => apply_mpn_to_fft_func_5_116,\n        MPNToFFTFunc { np: 5, bits: 120 } => apply_mpn_to_fft_func_5_120,\n        MPNToFFTFunc { np: 6, bits: 136 } => apply_mpn_to_fft_func_6_136,\n        MPNToFFTFunc { np: 6, bits: 140 } => apply_mpn_to_fft_func_6_140,\n        MPNToFFTFunc { np: 6, bits: 144 } => apply_mpn_to_fft_func_6_144,\n        MPNToFFTFunc { np: 7, bits: 160 } => apply_mpn_to_fft_func_7_160,\n        MPNToFFTFunc { np: 7, bits: 164 } => apply_mpn_to_fft_func_7_164,\n        MPNToFFTFunc { np: 7, bits: 168 } => apply_mpn_to_fft_func_7_168,\n        MPNToFFTFunc { np: 8, bits: 184 } => apply_mpn_to_fft_func_8_184,\n        MPNToFFTFunc { np: 8, bits: 188 } => apply_mpn_to_fft_func_8_188,\n        MPNToFFTFunc { np: 8, bits: 192 } => apply_mpn_to_fft_func_8_192,\n        _ => unreachable!(),\n    };\n    f(\n        ffts,\n        abuf,\n        stride,\n        a,\n        atrunc,\n        two_pow_tab,\n        a_stop_easy,\n        a_start_hard,\n        a_stop_hard,\n    );\n    if !squaring {\n        f(\n            ffts,\n            bbuf,\n            stride,\n            b,\n            btrunc,\n            two_pow_tab,\n            b_stop_easy,\n            b_start_hard,\n            b_stop_hard,\n        );\n    }\n}\n\n// This is NMOD_RED2 from nmod.h, FLINT 3.3.0-dev.\nmacro_rules! nmod_red2 {\n    ($a_hi: expr, $a_lo: expr, $mod_data: expr) => {{\n        let a_lo = $a_lo;\n        let mod_data = $mod_data;\n        let u1xx = ($a_hi << mod_data.norm)\n            + (if mod_data.norm == 0 {\n                0\n            } else {\n                a_lo >> (u64::WIDTH - mod_data.norm)\n            });\n        let u0xx = a_lo << mod_data.norm;\n        let nxx = mod_data.n << mod_data.norm;\n        let (mut q1xx, mut q0xx) = u64::x_mul_y_to_zz(mod_data.ninv, u1xx);\n        (q1xx, q0xx) = u64::xx_add_yy_to_zz(q1xx, q0xx, u1xx, u0xx);\n        let mut r1xx = u0xx.wrapping_sub((q1xx + 1).wrapping_mul(nxx));\n        if r1xx > q0xx {\n            r1xx.wrapping_add_assign(nxx);\n        }\n        if r1xx < nxx {\n            r1xx >> mod_data.norm\n        } else {\n            (r1xx - nxx) >> mod_data.norm\n        }\n    }};\n}\n\n// This is fft_worker_func from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn process_fft(\n    fctx: &mut FFTContext,\n    cop: u64,\n    depth: u64,\n    ztrunc: usize,\n    abuf: &mut [f64],\n    atrunc: usize,\n    bbuf: &mut [f64],\n    btrunc: usize,\n    squaring: bool,\n) {\n    let q = &mut *fctx;\n    if !squaring {\n        sd_fft_trunc(q, bbuf, depth, btrunc, ztrunc);\n    }\n    sd_fft_trunc(q, abuf, depth, atrunc, ztrunc);\n    let m = nmod_red2!(cop >> (u64::WIDTH - depth), cop << depth, &q.mod_data)\n        .mod_inverse(q.mod_data.n)\n        .unwrap();\n    if squaring {\n        sd_fft_ctx_point_sqr(q, abuf, m, depth);\n    } else {\n        sd_fft_ctx_point_mul(q, abuf, bbuf, m, depth);\n    }\n    sd_ifft_trunc(q, abuf, depth, ztrunc);\n}\n\n// This is mod_fft_worker_func from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn process_mod_fft(\n    bits: usize,\n    fctx: &mut FFTContext,\n    two_pow_tab: &[f64],\n    cop: u64,\n    depth: u64,\n    ztrunc: usize,\n    a: &[Limb],\n    abuf: &mut [f64],\n    atrunc: usize,\n    b: &[Limb],\n    bbuf: &mut [f64],\n    btrunc: usize,\n    squaring: bool,\n) {\n    let q = fctx;\n    if !squaring {\n        slow_mpn_to_fft(q, bbuf, btrunc, b, bits, two_pow_tab);\n        sd_fft_trunc(q, bbuf, depth, btrunc, ztrunc);\n    }\n    slow_mpn_to_fft(q, abuf, atrunc, a, bits, two_pow_tab);\n    sd_fft_trunc(q, abuf, depth, atrunc, ztrunc);\n    let m = nmod_red2!(cop >> (u64::WIDTH - depth), cop << depth, &q.mod_data)\n        .mod_inverse(q.mod_data.n)\n        .unwrap();\n    if squaring {\n        sd_fft_ctx_point_sqr(q, abuf, m, depth);\n    } else {\n        sd_fft_ctx_point_mul(q, abuf, bbuf, m, depth);\n    }\n    sd_ifft_trunc(q, abuf, depth, ztrunc);\n}\n\n// This is _madd from crt_helpers.h, FLINT 3.3.0-dev, modifying hi and lo.\nmacro_rules! madd {\n    ($hi: expr, $lo: expr, $y: expr, $x: expr) => {\n        let (r1, r0) = u64::x_mul_y_to_zz($x, $y);\n        ($hi, $lo) = u64::xx_add_yy_to_zz(r1, r0, $hi, $lo);\n    };\n}\n\n// This is big_mul from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! big_mul {\n    ($n: expr, $m: expr, $r: ident, $t: ident, $c: expr, $y: expr) => {\n        let y = $y;\n        let c = $c;\n        for k in (0..$n).step_by(2) {\n            if k < const { $n - 1 } {\n                assert!(k < $m);\n                ($r[k + 1], $r[k]) = u64::x_mul_y_to_zz(c[k], y);\n            } else {\n                assert_eq!(k, const { $n - 1 });\n                $r[k] = if k < $m { c[k] * y } else { 0 };\n            }\n            if k < const { $n - 2 } {\n                assert!(k < const { $m - 1 });\n                let kp1 = k + 1;\n                ($t[k + 2], $t[kp1]) = u64::x_mul_y_to_zz(c[kp1], y);\n            } else if k < const { $n - 1 } {\n                let kp1 = k + 1;\n                $t[kp1] = if k < const { $m - 1 } { c[kp1] * y } else { 0 }\n            }\n        }\n    };\n}\n\n// This is big_addmul from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! big_add_mul {\n    ($n: expr, $m: expr, $r: ident, $t: ident, $c: expr, $y: expr) => {\n        let y = $y;\n        let c = $c;\n        for k in (0..$n).step_by(2) {\n            if k < const { $n - 1 } {\n                assert!(k < $m);\n                madd!($r[k + 1], $r[k], c[k], y);\n            } else {\n                assert_eq!(k, const { $n - 1 });\n                if k < $m {\n                    $r[k] += c[k] * y;\n                }\n            }\n            #[allow(clippy::redundant_comparisons)]\n            if k < const { $n - 2 } {\n                assert!(k < const { $m - 1 });\n                let kp1 = k + 1;\n                madd!($t[k + 2], $t[kp1], c[kp1], y);\n            } else if k < const { $n - 1 } && k < const { $m - 1 } {\n                let kp1 = k + 1;\n                $t[kp1] += c[kp1] * y;\n            }\n        }\n    };\n}\n\n// This is multi_add_3 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_add_3{($z: expr, $a: expr) => {{\n    let z = $z;\n    let a = $a;\n    (z[2], z[1], z[0]) = u64::xxx_add_yyy_to_zzz(z[2], z[1], z[0], a[2], a[1], a[0]);\n}}}\n\n// This is multi_add_4 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_add_4{($z: expr, $a: expr) => {{\n    let z = $z;\n    let a = $a;\n    (z[3], z[2], z[1], z[0]) =\n        u64::xxxx_add_yyyy_to_zzzz(z[3], z[2], z[1], z[0], a[3], a[2], a[1], a[0]);\n}}}\n\n// This is multi_add_5 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_add_5 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let carry_1 = z[0].overflowing_add_assign(a[0]);\n        let mut carry_2 = z[1].overflowing_add_assign(a[1]);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a[2]);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a[3]);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        z[4].wrapping_add_assign(a[4]);\n        if carry_4 {\n            z[4].wrapping_add_assign(1);\n        }\n    }};\n}\n\n// This is multi_add_6 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_add_6 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let carry_1 = z[0].overflowing_add_assign(a[0]);\n        let mut carry_2 = z[1].overflowing_add_assign(a[1]);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a[2]);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a[3]);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a[4]);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        z[5].wrapping_add_assign(a[5]);\n        if carry_5 {\n            z[5].wrapping_add_assign(1);\n        }\n    }};\n}\n\n// This is multi_add_7 from crt_helpers.h, FLINT 3.3.0-dev.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nmacro_rules! multi_add_7 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let carry_1 = z[0].overflowing_add_assign(a[0]);\n        let mut carry_2 = z[1].overflowing_add_assign(a[1]);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a[2]);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a[3]);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a[4]);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        let mut carry_6 = z[5].overflowing_add_assign(a[5]);\n        if carry_5 {\n            carry_6 |= z[5].overflowing_add_assign(1);\n        }\n        z[6].wrapping_add_assign(a[6]);\n        if carry_6 {\n            z[6].wrapping_add_assign(1);\n        }\n    }};\n}\n\n// This is multi_add_8 from crt_helpers.h, FLINT 3.3.0-dev.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nmacro_rules! multi_add_8 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let carry_1 = z[0].overflowing_add_assign(a[0]);\n        let mut carry_2 = z[1].overflowing_add_assign(a[1]);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a[2]);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a[3]);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a[4]);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        let mut carry_6 = z[5].overflowing_add_assign(a[5]);\n        if carry_5 {\n            carry_6 |= z[5].overflowing_add_assign(1);\n        }\n        let mut carry_7 = z[6].overflowing_add_assign(a[6]);\n        if carry_6 {\n            carry_7 |= z[6].overflowing_add_assign(1);\n        }\n        z[7].wrapping_add_assign(a[7]);\n        if carry_7 {\n            z[7].wrapping_add_assign(1);\n        }\n    }};\n}\n\n// This is multi_add_4 from crt_helpers.h, FLINT 3.3.0-dev.\n#[cfg(feature = \"32_bit_limbs\")]\nmacro_rules! multi_add_4_alt {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let (a_1, a_0) = a[0].split_in_half();\n        let (a_3, a_2) = a[1].split_in_half();\n        let (a_5, a_4) = a[2].split_in_half();\n        let (a_7, a_6) = a[3].split_in_half();\n        let carry_1 = z[0].overflowing_add_assign(a_0);\n        let mut carry_2 = z[1].overflowing_add_assign(a_1);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a_2);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a_3);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a_4);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        let mut carry_6 = z[5].overflowing_add_assign(a_5);\n        if carry_5 {\n            carry_6 |= z[5].overflowing_add_assign(1);\n        }\n        let mut carry_7 = z[6].overflowing_add_assign(a_6);\n        if carry_6 {\n            carry_7 |= z[6].overflowing_add_assign(1);\n        }\n        if 7 < z.len() {\n            z[7].wrapping_add_assign(a_7);\n            if carry_7 {\n                z[7].wrapping_add_assign(1);\n            }\n        }\n    }};\n}\n\n// This is multi_add_5 from crt_helpers.h, FLINT 3.3.0-dev.\n#[cfg(feature = \"32_bit_limbs\")]\nmacro_rules! multi_add_5_alt {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let (a_1, a_0) = a[0].split_in_half();\n        let (a_3, a_2) = a[1].split_in_half();\n        let (a_5, a_4) = a[2].split_in_half();\n        let (a_7, a_6) = a[3].split_in_half();\n        let (a_9, a_8) = a[4].split_in_half();\n        let carry_1 = z[0].overflowing_add_assign(a_0);\n        let mut carry_2 = z[1].overflowing_add_assign(a_1);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a_2);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a_3);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a_4);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        let mut carry_6 = z[5].overflowing_add_assign(a_5);\n        if carry_5 {\n            carry_6 |= z[5].overflowing_add_assign(1);\n        }\n        let mut carry_7 = z[6].overflowing_add_assign(a_6);\n        if carry_6 {\n            carry_7 |= z[6].overflowing_add_assign(1);\n        }\n        let mut carry_8 = z[7].overflowing_add_assign(a_7);\n        if carry_7 {\n            carry_8 |= z[7].overflowing_add_assign(1);\n        }\n        let mut carry_9 = z[8].overflowing_add_assign(a_8);\n        if carry_8 {\n            carry_9 |= z[8].overflowing_add_assign(1);\n        }\n        if 9 < z.len() {\n            z[9].wrapping_add_assign(a_9);\n            if carry_9 {\n                z[9].wrapping_add_assign(1);\n            }\n        }\n    }};\n}\n\n// This is multi_add_6 from crt_helpers.h, FLINT 3.3.0-dev.\n#[cfg(feature = \"32_bit_limbs\")]\nmacro_rules! multi_add_6_alt {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let (a_1, a_0) = a[0].split_in_half();\n        let (a_3, a_2) = a[1].split_in_half();\n        let (a_5, a_4) = a[2].split_in_half();\n        let (a_7, a_6) = a[3].split_in_half();\n        let (a_9, a_8) = a[4].split_in_half();\n        let (a_11, a_10) = a[5].split_in_half();\n        let carry_1 = z[0].overflowing_add_assign(a_0);\n        let mut carry_2 = z[1].overflowing_add_assign(a_1);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a_2);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a_3);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a_4);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        let mut carry_6 = z[5].overflowing_add_assign(a_5);\n        if carry_5 {\n            carry_6 |= z[5].overflowing_add_assign(1);\n        }\n        let mut carry_7 = z[6].overflowing_add_assign(a_6);\n        if carry_6 {\n            carry_7 |= z[6].overflowing_add_assign(1);\n        }\n        let mut carry_8 = z[7].overflowing_add_assign(a_7);\n        if carry_7 {\n            carry_8 |= z[7].overflowing_add_assign(1);\n        }\n        let mut carry_9 = z[8].overflowing_add_assign(a_8);\n        if carry_8 {\n            carry_9 |= z[8].overflowing_add_assign(1);\n        }\n        let mut carry_10 = z[9].overflowing_add_assign(a_9);\n        if carry_9 {\n            carry_10 |= z[9].overflowing_add_assign(1);\n        }\n        let mut carry_11 = z[10].overflowing_add_assign(a_10);\n        if carry_10 {\n            carry_11 |= z[10].overflowing_add_assign(1);\n        }\n        if 11 < z.len() {\n            z[11].wrapping_add_assign(a_11);\n            if carry_11 {\n                z[11].wrapping_add_assign(1);\n            }\n        }\n    }};\n}\n\n// This is multi_add_7 from crt_helpers.h, FLINT 3.3.0-dev.\n#[cfg(feature = \"32_bit_limbs\")]\nmacro_rules! multi_add_7_alt {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let (a_1, a_0) = a[0].split_in_half();\n        let (a_3, a_2) = a[1].split_in_half();\n        let (a_5, a_4) = a[2].split_in_half();\n        let (a_7, a_6) = a[3].split_in_half();\n        let (a_9, a_8) = a[4].split_in_half();\n        let (a_11, a_10) = a[5].split_in_half();\n        let (a_13, a_12) = a[6].split_in_half();\n        let carry_1 = z[0].overflowing_add_assign(a_0);\n        let mut carry_2 = z[1].overflowing_add_assign(a_1);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a_2);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a_3);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a_4);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        let mut carry_6 = z[5].overflowing_add_assign(a_5);\n        if carry_5 {\n            carry_6 |= z[5].overflowing_add_assign(1);\n        }\n        let mut carry_7 = z[6].overflowing_add_assign(a_6);\n        if carry_6 {\n            carry_7 |= z[6].overflowing_add_assign(1);\n        }\n        let mut carry_8 = z[7].overflowing_add_assign(a_7);\n        if carry_7 {\n            carry_8 |= z[7].overflowing_add_assign(1);\n        }\n        let mut carry_9 = z[8].overflowing_add_assign(a_8);\n        if carry_8 {\n            carry_9 |= z[8].overflowing_add_assign(1);\n        }\n        let mut carry_10 = z[9].overflowing_add_assign(a_9);\n        if carry_9 {\n            carry_10 |= z[9].overflowing_add_assign(1);\n        }\n        let mut carry_11 = z[10].overflowing_add_assign(a_10);\n        if carry_10 {\n            carry_11 |= z[10].overflowing_add_assign(1);\n        }\n        let mut carry_12 = z[11].overflowing_add_assign(a_11);\n        if carry_11 {\n            carry_12 |= z[11].overflowing_add_assign(1);\n        }\n        let mut carry_13 = z[12].overflowing_add_assign(a_12);\n        if carry_12 {\n            carry_13 |= z[12].overflowing_add_assign(1);\n        }\n        if 13 < z.len() {\n            z[13].wrapping_add_assign(a_13);\n            if carry_13 {\n                z[13].wrapping_add_assign(1);\n            }\n        }\n    }};\n}\n\n// This is multi_add_8 from crt_helpers.h, FLINT 3.3.0-dev.\n#[cfg(feature = \"32_bit_limbs\")]\nmacro_rules! multi_add_8_alt {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let (a_1, a_0) = a[0].split_in_half();\n        let (a_3, a_2) = a[1].split_in_half();\n        let (a_5, a_4) = a[2].split_in_half();\n        let (a_7, a_6) = a[3].split_in_half();\n        let (a_9, a_8) = a[4].split_in_half();\n        let (a_11, a_10) = a[5].split_in_half();\n        let (a_13, a_12) = a[6].split_in_half();\n        let (a_15, a_14) = a[7].split_in_half();\n        let carry_1 = z[0].overflowing_add_assign(a_0);\n        let mut carry_2 = z[1].overflowing_add_assign(a_1);\n        if carry_1 {\n            carry_2 |= z[1].overflowing_add_assign(1);\n        }\n        let mut carry_3 = z[2].overflowing_add_assign(a_2);\n        if carry_2 {\n            carry_3 |= z[2].overflowing_add_assign(1);\n        }\n        let mut carry_4 = z[3].overflowing_add_assign(a_3);\n        if carry_3 {\n            carry_4 |= z[3].overflowing_add_assign(1);\n        }\n        let mut carry_5 = z[4].overflowing_add_assign(a_4);\n        if carry_4 {\n            carry_5 |= z[4].overflowing_add_assign(1);\n        }\n        let mut carry_6 = z[5].overflowing_add_assign(a_5);\n        if carry_5 {\n            carry_6 |= z[5].overflowing_add_assign(1);\n        }\n        let mut carry_7 = z[6].overflowing_add_assign(a_6);\n        if carry_6 {\n            carry_7 |= z[6].overflowing_add_assign(1);\n        }\n        let mut carry_8 = z[7].overflowing_add_assign(a_7);\n        if carry_7 {\n            carry_8 |= z[7].overflowing_add_assign(1);\n        }\n        let mut carry_9 = z[8].overflowing_add_assign(a_8);\n        if carry_8 {\n            carry_9 |= z[8].overflowing_add_assign(1);\n        }\n        let mut carry_10 = z[9].overflowing_add_assign(a_9);\n        if carry_9 {\n            carry_10 |= z[9].overflowing_add_assign(1);\n        }\n        let mut carry_11 = z[10].overflowing_add_assign(a_10);\n        if carry_10 {\n            carry_11 |= z[10].overflowing_add_assign(1);\n        }\n        let mut carry_12 = z[11].overflowing_add_assign(a_11);\n        if carry_11 {\n            carry_12 |= z[11].overflowing_add_assign(1);\n        }\n        let mut carry_13 = z[12].overflowing_add_assign(a_12);\n        if carry_12 {\n            carry_13 |= z[12].overflowing_add_assign(1);\n        }\n        let mut carry_14 = z[13].overflowing_add_assign(a_13);\n        if carry_13 {\n            carry_14 |= z[13].overflowing_add_assign(1);\n        }\n        let mut carry_15 = z[14].overflowing_add_assign(a_14);\n        if carry_14 {\n            carry_15 |= z[14].overflowing_add_assign(1);\n        }\n        if 15 < z.len() {\n            z[15].wrapping_add_assign(a_15);\n            if carry_15 {\n                z[15].wrapping_add_assign(1);\n            }\n        }\n    }};\n}\n\n// This is multi_sub_4 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_sub_4 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let borrow_1 = z[0].overflowing_sub_assign(a[0]);\n        let mut borrow_2 = z[1].overflowing_sub_assign(a[1]);\n        if borrow_1 {\n            borrow_2 |= z[1].overflowing_sub_assign(1);\n        }\n        let mut borrow_3 = z[2].overflowing_sub_assign(a[2]);\n        if borrow_2 {\n            borrow_3 |= z[2].overflowing_sub_assign(1);\n        }\n        z[3].wrapping_sub_assign(a[3]);\n        if borrow_3 {\n            z[3].wrapping_sub_assign(1);\n        }\n    }};\n}\n\n// This is multi_sub_5 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_sub_5 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let borrow_1 = z[0].overflowing_sub_assign(a[0]);\n        let mut borrow_2 = z[1].overflowing_sub_assign(a[1]);\n        if borrow_1 {\n            borrow_2 |= z[1].overflowing_sub_assign(1);\n        }\n        let mut borrow_3 = z[2].overflowing_sub_assign(a[2]);\n        if borrow_2 {\n            borrow_3 |= z[2].overflowing_sub_assign(1);\n        }\n        let mut borrow_4 = z[3].overflowing_sub_assign(a[3]);\n        if borrow_3 {\n            borrow_4 |= z[3].overflowing_sub_assign(1);\n        }\n        z[4].wrapping_sub_assign(a[4]);\n        if borrow_4 {\n            z[4].wrapping_sub_assign(1);\n        }\n    }};\n}\n\n// This is multi_sub_6 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_sub_6 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let borrow_1 = z[0].overflowing_sub_assign(a[0]);\n        let mut borrow_2 = z[1].overflowing_sub_assign(a[1]);\n        if borrow_1 {\n            borrow_2 |= z[1].overflowing_sub_assign(1);\n        }\n        let mut borrow_3 = z[2].overflowing_sub_assign(a[2]);\n        if borrow_2 {\n            borrow_3 |= z[2].overflowing_sub_assign(1);\n        }\n        let mut borrow_4 = z[3].overflowing_sub_assign(a[3]);\n        if borrow_3 {\n            borrow_4 |= z[3].overflowing_sub_assign(1);\n        }\n        let mut borrow_5 = z[4].overflowing_sub_assign(a[4]);\n        if borrow_4 {\n            borrow_5 |= z[4].overflowing_sub_assign(1);\n        }\n        z[5].wrapping_sub_assign(a[5]);\n        if borrow_5 {\n            z[5].wrapping_sub_assign(1);\n        }\n    }};\n}\n\n// This is multi_sub_7 from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! multi_sub_7 {\n    ($z: expr, $a: expr) => {{\n        let z = $z;\n        let a = $a;\n        let borrow_1 = z[0].overflowing_sub_assign(a[0]);\n        let mut borrow_2 = z[1].overflowing_sub_assign(a[1]);\n        if borrow_1 {\n            borrow_2 |= z[1].overflowing_sub_assign(1);\n        }\n        let mut borrow_3 = z[2].overflowing_sub_assign(a[2]);\n        if borrow_2 {\n            borrow_3 |= z[2].overflowing_sub_assign(1);\n        }\n        let mut borrow_4 = z[3].overflowing_sub_assign(a[3]);\n        if borrow_3 {\n            borrow_4 |= z[3].overflowing_sub_assign(1);\n        }\n        let mut borrow_5 = z[4].overflowing_sub_assign(a[4]);\n        if borrow_4 {\n            borrow_5 |= z[4].overflowing_sub_assign(1);\n        }\n        let mut borrow_6 = z[5].overflowing_sub_assign(a[5]);\n        if borrow_5 {\n            borrow_6 |= z[5].overflowing_sub_assign(1);\n        }\n        z[6].wrapping_sub_assign(a[6]);\n        if borrow_6 {\n            z[6].wrapping_sub_assign(1);\n        }\n    }};\n}\n\n// This is _reduce_big_sum from crt_helpers.h, FLINT 3.3.0-dev.\nmacro_rules! reduce_big_sum {\n    ($n: expr, $faddm1: ident, $fsub: ident, $r: ident, $t: ident, $limit: expr) => {\n        let limit = $limit;\n        $faddm1!(&mut $r[1..], &$t[1..]);\n        'outer: loop {\n            let mut goto_sub = false;\n            for k in (2..=$n).rev() {\n                let km1 = k - 1;\n                if $r[km1] > limit[km1] {\n                    goto_sub = true;\n                    break;\n                }\n                if $r[km1] < limit[km1] {\n                    break 'outer;\n                }\n            }\n            if !goto_sub && $r[0] < limit[0] {\n                break 'outer;\n            }\n            $fsub!(&mut $r, limit);\n        }\n    };\n}\n\n// This is _add_to_answer_easy from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nmacro_rules! add_to_answer_easy {\n    (\n        $n: expr,\n        $fadd: ident,\n        $fadd_alt: ident,\n        $faddp1: ident,\n        $fadd_altp1: ident,\n        $z: ident,\n        $r: ident,\n        $toff: ident,\n        $tshift: ident\n    ) => {{\n        #[cfg(feature = \"32_bit_limbs\")]\n        let z_len = $z.len().shr_round(1, Ceiling).0;\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        let z_len = $z.len();\n        assert!(z_len > $toff);\n        if $tshift == 0 {\n            #[cfg(feature = \"32_bit_limbs\")]\n            $fadd_alt!(&mut $z[$toff << 1..], $r);\n            #[cfg(not(feature = \"32_bit_limbs\"))]\n            $fadd!(&mut $z[$toff..], $r);\n        } else {\n            let comp_shift = 64 - $tshift;\n            $r[$n] = $r[$n - 1] >> comp_shift;\n            for k in (2..=$n).rev() {\n                $r[k - 1] = ($r[k - 1] << $tshift) | ($r[k - 2] >> comp_shift);\n            }\n            $r[0] <<= $tshift;\n            #[cfg(feature = \"32_bit_limbs\")]\n            $fadd_altp1!(&mut $z[$toff << 1..], $r);\n            #[cfg(not(feature = \"32_bit_limbs\"))]\n            $faddp1!(&mut $z[$toff..], $r);\n        }\n    }};\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\nfn limbs_slice_add_same_length_in_place_left_alt(xs: &mut [u32], ys: &[u64]) -> bool {\n    let mut carry = 0;\n    let mut xi = xs.iter_mut();\n    for &y in ys {\n        let (y_hi, y_lo) = y.split_in_half();\n        let x = xi.next().unwrap();\n        (*x, carry) = add_with_carry_limb(*x, y_lo, carry);\n        if let Some(x) = xi.next() {\n            (*x, carry) = add_with_carry_limb(*x, y_hi, carry);\n        }\n    }\n    carry != 0\n}\n\n// This is _add_to_answer_hard from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nmacro_rules! add_to_answer_hard {\n    (\n        $n: expr,\n        $fadd: ident,\n        $fadd_alt: ident,\n        $faddp1: ident,\n        $fadd_altp1: ident,\n        $z: ident,\n        $r: ident,\n        $toff: ident,\n        $tshift: ident\n    ) => {{\n        #[cfg(feature = \"32_bit_limbs\")]\n        let z_len = $z.len().shr_round(1, Ceiling).0;\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        let z_len = $z.len();\n        assert!(z_len > $toff);\n        let mut do_add = true;\n        if $tshift == 0 {\n            if z_len - $toff >= const { $n as usize } {\n                #[cfg(feature = \"32_bit_limbs\")]\n                $fadd_alt!(&mut $z[$toff << 1..], $r);\n                #[cfg(not(feature = \"32_bit_limbs\"))]\n                $fadd!(&mut $z[$toff..], $r);\n                do_add = false;\n            }\n        } else {\n            let comp_shift = 64 - $tshift;\n            $r[$n] = $r[const { $n - 1 }] >> comp_shift;\n            for k in (2..=$n).rev() {\n                $r[k - 1] = ($r[k - 1] << $tshift) | ($r[k - 2] >> comp_shift);\n            }\n            $r[0] <<= $tshift;\n            if z_len - $toff > const { $n as usize } {\n                #[cfg(feature = \"32_bit_limbs\")]\n                $fadd_altp1!(&mut $z[$toff << 1..], $r);\n                #[cfg(not(feature = \"32_bit_limbs\"))]\n                $faddp1!(&mut $z[$toff..], $r);\n                do_add = false;\n            }\n        }\n        if do_add {\n            let diff = z_len - $toff;\n            assert!(diff <= const { $n as usize });\n            #[cfg(feature = \"32_bit_limbs\")]\n            limbs_slice_add_same_length_in_place_left_alt(&mut $z[$toff << 1..], &$r[..diff]);\n            #[cfg(not(feature = \"32_bit_limbs\"))]\n            limbs_slice_add_same_length_in_place_left(&mut $z[$toff..], &$r[..diff]);\n        }\n    }};\n}\n\nmacro_rules! f64x4_to_u64x4 {\n    ($x: ident) => {{\n        let [a, b, c, d] = $x.to_array();\n        u64x4::from([\n            round_even!(a) as u64,\n            round_even!(b) as u64,\n            round_even!(c) as u64,\n            round_even!(d) as u64,\n        ])\n    }};\n}\n\n// transpose a block\n//\n// This is _convert_block from fft_small/mpn_helpers.c, FLINT 3.3.0-dev.\nmacro_rules! convert_block {\n    (\n    $xs: ident,\n    $rffts: ident,\n    $d: ident,\n    $dstride: ident,\n    $np: expr,\n    $i: expr\n) => {\n        let d_hi = &$d[$i << LG_BLK_SZ..];\n        let mut m = 0;\n        for l in 0..$np {\n            let xs_hi = &mut $xs[l << LG_BLK_SZ..];\n            let ds = &d_hi[m..];\n            let p = f64x4::splat($rffts[l].p);\n            let pinv = f64x4::splat($rffts[l].pinv);\n            for j in (0..BLK_SZ).step_by(VEC_SZ << 2) {\n                let mut x0 = read_f64x4!(ds, j);\n                let mut x1 = read_f64x4!(ds, j + VEC_SZ);\n                let mut x2 = read_f64x4!(ds, j + const { 2 * VEC_SZ });\n                let mut x3 = read_f64x4!(ds, j + const { 3 * VEC_SZ });\n                x0 = f64x4_reduce_to_0n!(x0, p, pinv);\n                x1 = f64x4_reduce_to_0n!(x1, p, pinv);\n                x2 = f64x4_reduce_to_0n!(x2, p, pinv);\n                x3 = f64x4_reduce_to_0n!(x3, p, pinv);\n                let y0 = f64x4_to_u64x4!(x0);\n                let y1 = f64x4_to_u64x4!(x1);\n                let y2 = f64x4_to_u64x4!(x2);\n                let y3 = f64x4_to_u64x4!(x3);\n                write_f64x4!(xs_hi, j, y0);\n                write_f64x4!(xs_hi, j + VEC_SZ, y1);\n                write_f64x4!(xs_hi, j + const { 2 * VEC_SZ }, y2);\n                write_f64x4!(xs_hi, j + const { 3 * VEC_SZ }, y3);\n            }\n            m += $dstride;\n        }\n    };\n}\n\n//  The \"n\" here is the limb count Rcrts[np-1].coeff_len, which is big enough to hold (product of\n//  primes)*(number of primes), so it can hold the intermediate dot products f[0]*x[0] + ... +\n//  f[np-1]*x[np-1]. The x[i] are single limb and the f[i] are of length \"m\". The number of primes\n//  is \"np\".\n//\n//  The coefficient of X^i, 0 <= i < zlen needs to be reconstructed and added to the answer mpn (z,\n//  zn). This involves the limbs\n//\n//  z[floor(i*bits/64)] ... z[floor(i*bits/64)+n]\n//\n//  so is easy if floor(i*bits/64)+n < zn.\n//\n//  The the l^th fft ctx Rffts[l] is expected to have data at d + l*dstride\n//\n//  handle output coefficients from [start_easy, zlen) end_easy is still expected to be valid\n//\n// This is _mpn_from_ffts and crt_worker_func from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nmacro_rules! process_crt {\n    (\n        $f: ident,\n        $np: expr,\n        $n: expr,\n        $m: expr,\n        $faddm1: ident,\n        $fadd: ident,\n        $faddp1: ident,\n        $fadd_alt: ident,\n        $faddp1_alt: ident,\n        $fsub: ident\n    ) => {\n        fn $f(\n            zs: &mut [Limb],\n            zlen: usize,\n            rffts: &[FFTContext],\n            ds: &[f64],\n            dstride: usize,\n            rcrts: &mut [CRTData],\n            bits: usize,\n            stop_easy: usize,\n        ) {\n            #[cfg(feature = \"32_bit_limbs\")]\n            let zn_stop = zs.len().shr_round(1, Ceiling).0;\n            #[cfg(not(feature = \"32_bit_limbs\"))]\n            let zn_stop = zs.len();\n            let rcrt = &mut rcrts[const {$np - 1}];\n            assert_eq!($n, rcrt.coeff_len);\n            if const{$n != $m} {\n                for l in 0..$np {\n                    assert_eq!(rcrt.co_prime(l)[$m], 0);\n                }\n            }\n            zs.fill(0);\n            let mut xs = [0; $np << LG_BLK_SZ];\n            let mut r = [0; $n + 1];\n            let mut t = [0; $n + 1];\n            let mut k = 0;\n            for i in (0..stop_easy).step_by(BLK_SZ) {\n                convert_block!(xs, rffts, ds, dstride, $np, i >> LG_BLK_SZ);\n                for j in 0..BLK_SZ {\n                    big_mul!($n, $m, r, t, rcrt.co_prime(0), xs[j]);\n                    let xs_hi = &xs[j..];\n                    let mut m = BLK_SZ;\n                    for l in 1..$np {\n                        big_add_mul!($n, $m, r, t, rcrt.co_prime(l), xs_hi[m]);\n                        m += BLK_SZ;\n                    }\n                    reduce_big_sum!($n, $faddm1, $fsub, r, t, rcrt.prod_primes_ref());\n                    let toff = k >> u64::LOG_WIDTH;\n                    let tshift = k & const {u64::WIDTH_MASK as usize};\n                    assert!(zn_stop > $n + toff);\n                    add_to_answer_easy!(\n                        $n,\n                        $fadd,\n                        $fadd_alt,\n                        $faddp1,\n                        $faddp1_alt,\n                        zs,\n                        r,\n                        toff,\n                        tshift\n                    );\n                    k += bits;\n                }\n            }\n            let mut j = stop_easy * bits;\n            for i in stop_easy..zlen {\n                let ds_hi = &ds[i..];\n                let mut xx = ds_hi[0];\n                let rfft = &rffts[0];\n                let mut x = f64_reduce_to_0n!(xx, rfft.p, rfft.pinv) as u64;\n                big_mul!($n, $m, r, t, rcrt.co_prime(0), x);\n                let mut m = dstride;\n                for l in 1..$np {\n                    xx = ds_hi[m];\n                    let rfft = &rffts[l];\n                    x = f64_reduce_to_0n!(xx, rfft.p, rfft.pinv) as u64;\n                    big_add_mul!($n, $m, r, t, rcrt.co_prime(l), x);\n                    m += dstride;\n                }\n                reduce_big_sum!($n, $faddm1, $fsub, r, t, rcrt.prod_primes_ref());\n                let toff = j >> u64::LOG_WIDTH;\n                let tshift = j & const {u64::WIDTH_MASK as usize};\n                if toff >= zn_stop {\n                    break;\n                }\n                add_to_answer_hard!(\n                    $n,\n                    $fadd,\n                    $fadd_alt,\n                    $faddp1,\n                    $faddp1_alt,\n                    zs,\n                    r,\n                    toff,\n                    tshift\n                );\n                j += bits;\n            }\n        }\n    }\n}\nprocess_crt!(\n    process_crt_4_4_3,\n    4,\n    4,\n    3,\n    multi_add_3,\n    multi_add_4,\n    multi_add_5,\n    multi_add_4_alt,\n    multi_add_5_alt,\n    multi_sub_4\n);\nprocess_crt!(\n    process_crt_5_4_4,\n    5,\n    4,\n    4,\n    multi_add_3,\n    multi_add_4,\n    multi_add_5,\n    multi_add_4_alt,\n    multi_add_5_alt,\n    multi_sub_4\n);\nprocess_crt!(\n    process_crt_6_5_4,\n    6,\n    5,\n    4,\n    multi_add_4,\n    multi_add_5,\n    multi_add_6,\n    multi_add_5_alt,\n    multi_add_6_alt,\n    multi_sub_5\n);\nprocess_crt!(\n    process_crt_7_6_5,\n    7,\n    6,\n    5,\n    multi_add_5,\n    multi_add_6,\n    multi_add_7,\n    multi_add_6_alt,\n    multi_add_7_alt,\n    multi_sub_6\n);\nprocess_crt!(\n    process_crt_8_7_6,\n    8,\n    7,\n    6,\n    multi_add_6,\n    multi_add_7,\n    multi_add_8,\n    multi_add_7_alt,\n    multi_add_8_alt,\n    multi_sub_7\n);\n\n// This is mpn_ctx_mpn_mul from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn mpn_ctx_mpn_mul(r: &mut Context, z: &mut [Limb], a: &[Limb], b: &[Limb], test_slow: bool) {\n    let squaring = core::ptr::addr_eq(a as *const [Limb], b as *const [Limb]) && a.len() == b.len();\n    let an = a.len();\n    let bn = b.len();\n    #[cfg(feature = \"32_bit_limbs\")]\n    let an = an.shr_round(1, Ceiling).0;\n    #[cfg(feature = \"32_bit_limbs\")]\n    let bn = bn.shr_round(1, Ceiling).0;\n    let mut p = ProfileEntry::default();\n    mpn_ctx_best_profile(r, &mut p, an, bn);\n    let zn = an + bn;\n    let alen = usize::exact_from(\n        u64::exact_from(an << u64::LOG_WIDTH)\n            .div_round(p.bits, Ceiling)\n            .0,\n    );\n    let blen = usize::exact_from(\n        u64::exact_from(bn << u64::LOG_WIDTH)\n            .div_round(p.bits, Ceiling)\n            .0,\n    );\n    let zlen = alen + blen - 1;\n    let atrunc = alen.round_to_multiple(BLK_SZ, Ceiling).0;\n    let btrunc = blen.round_to_multiple(BLK_SZ, Ceiling).0;\n    let ztrunc = zlen.round_to_multiple(BLK_SZ, Ceiling).0;\n    let depth = max(LG_BLK_SZ, ztrunc.ceiling_log_base_2());\n    let stride = usize::power_of_2(depth)\n        .round_to_multiple_of_power_of_2(7, Ceiling)\n        .0;\n    assert_ne!(an, 0);\n    assert_ne!(bn, 0);\n    let coeff_len = CONTEXT.crts[p.np - 1].coeff_len;\n    assert_ne!(\n        flint_mpn_cmp_ui_2exp(\n            &r.crts[p.np - 1].prod_primes_ref()[..coeff_len],\n            blen as u64,\n            p.bits << 1,\n        ),\n        Less\n    );\n    let abuf;\n    // Normally, p.to_ffts is None only for extremely large arguments, which are impractical to\n    // test, so we set a test_slow flag instead\n    if !test_slow && let Some(to_ffts) = p.to_ffts {\n        let bits = p.bits as usize;\n        let an_64 = an << 6;\n        let bn_64 = bn << 6;\n        // if i*bits + 32 < 64*an, then the index into a is always in bounds\n        let mut a_stop_easy = min(atrunc, (an_64 - 33) / bits);\n        // if i*bits >= 64*an, then the index into a is always out of bounds\n        let a_stop_hard = min(atrunc, an_64.div_ceil(bits));\n        // ditto\n        let mut b_stop_easy = min(btrunc, (bn_64 - 33) / bits);\n        let b_stop_hard = min(btrunc, bn_64.div_ceil(bits));\n        let rounding: usize = if bits & 7 == 0 {\n            4\n        } else if bits & 3 == 0 {\n            8\n        } else {\n            16\n        };\n        let prod = p.np * stride;\n        mpn_ctx_fit_buffer(r, prod << 4);\n        let bbuf;\n        (abuf, bbuf) = r.buffer.split_at_mut(prod);\n        // some fixups for loop unrollings: round down the easy stops\n        assert!(bits.even());\n        a_stop_easy &= rounding.wrapping_neg();\n        b_stop_easy &= rounding.wrapping_neg();\n        process_mod(\n            to_ffts,\n            &r.ffts,\n            stride,\n            &r.vec_two_pow_tab_backing\n                [r.vec_two_pow_tab_offsets[p.np.div_round(VEC_SZ, Ceiling).0 - 1]..],\n            abuf,\n            a,\n            atrunc,\n            a_stop_easy.round_to_multiple(rounding, Ceiling).0,\n            a_stop_easy,\n            a_stop_hard,\n            bbuf,\n            b,\n            btrunc,\n            b_stop_easy.round_to_multiple(rounding, Ceiling).0,\n            b_stop_easy,\n            b_stop_hard,\n            squaring,\n        );\n        let crt = &r.crts[p.np - 1];\n        let mut m = 0;\n        for l in 0..p.np {\n            process_fft(\n                &mut r.ffts[l],\n                crt.co_prime_red(l),\n                depth,\n                ztrunc,\n                &mut abuf[m..],\n                atrunc,\n                &mut bbuf[m..],\n                btrunc,\n                squaring,\n            );\n            m += stride;\n        }\n    } else {\n        mpn_ctx_fit_buffer(r, ((p.np + 1) * stride) << 3);\n        let crt = &r.crts[p.np - 1];\n        let bbuf;\n        (abuf, bbuf) = r.buffer.split_at_mut(p.np * stride);\n        let mut m = 0;\n        for l in 0..p.np {\n            process_mod_fft(\n                p.bits as usize,\n                &mut r.ffts[l],\n                &r.slow_two_pow_backing[r.slow_two_pow_offsets[l]..],\n                crt.co_prime_red(l),\n                depth,\n                ztrunc,\n                a,\n                &mut abuf[m..],\n                atrunc,\n                b,\n                bbuf,\n                btrunc,\n                squaring,\n            );\n            m += stride;\n        }\n    }\n    let n = r.crts[p.np - 1].coeff_len;\n    let mut end_easy = ((if zn > n { zn - (n + 1) } else { 0 }) << 6) / (p.bits as usize);\n    // this is how much space was statically allocated in each struct\n    assert!(n <= MPN_CTX_NCRTS);\n    end_easy &= BLK_SZ.wrapping_neg();\n    assert!(4 <= p.np && p.np <= 8);\n    let process_crt = match p.np {\n        4 => process_crt_4_4_3,\n        5 => process_crt_5_4_4,\n        6 => process_crt_6_5_4,\n        7 => process_crt_7_6_5,\n        8 => process_crt_8_7_6,\n        _ => unreachable!(),\n    };\n    process_crt(\n        z,\n        zlen,\n        &r.ffts,\n        abuf,\n        stride,\n        &mut r.crts,\n        p.bits as usize,\n        end_easy.round_to_multiple(BLK_SZ, Ceiling).0,\n    );\n}\n\n// This is mpn_mul_default_mpn_ctx from fft_small/default_ctx.c, FLINT 3.3.0-dev.\npub(crate) fn mpn_mul_default_mpn_ctx(r1: &mut [Limb], i1: &[Limb], i2: &[Limb], test_slow: bool) {\n    let mut context = CONTEXT.deserialize();\n    mpn_ctx_mpn_mul(&mut context, r1, i1, i2, test_slow);\n}\n\npub(crate) fn mpn_square_default_mpn_ctx(r1: &mut [Limb], i1: &[Limb]) {\n    let mut context = CONTEXT.deserialize();\n    mpn_ctx_mpn_mul(&mut context, r1, i1, i1, false);\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/limb.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::XMulYToZZ;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{HasHalf, SplitInHalf};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the product of the `Natural` and a `Limb`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_mul_1` from `mpn/generic/mul_1.c`, GMP 6.2.1, where the result is\n// returned.\npub_test! {limbs_mul_limb(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    let mut carry = 0;\n    let y = DoubleLimb::from(y);\n    let mut out = Vec::with_capacity(xs.len());\n    for &x in xs {\n        let product = DoubleLimb::from(x) * y + DoubleLimb::from(carry);\n        out.push(product.lower_half());\n        carry = product.upper_half();\n    }\n    if carry != 0 {\n        out.push(carry);\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the product of the `Natural` and a `Limb`, plus a carry, to an output slice. The output\n// slice must be at least as long as the input slice. Returns the carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs`.\n//\n// This is equivalent to `mul_1c` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_limb_with_carry_to_out<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    out: &mut [T],\n    xs: &[T],\n    y: T,\n    mut carry: T,\n) -> T {\n    let y = DT::from(y);\n    for (out, x) in out[..xs.len()].iter_mut().zip(xs.iter()) {\n        let product = DT::from(*x) * y + DT::from(carry);\n        (carry, *out) = product.split_in_half();\n    }\n    carry\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the product of the `Natural` and a `Limb` to an output slice. The output slice must be\n// at least as long as the input slice. Returns the carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs`.\n//\n// This is equivalent to `mpn_mul_1` from `mpn/generic/mul_1.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_limb_to_out<\n    DT: From<T> + HasHalf<Half = T> + PrimitiveUnsigned + SplitInHalf,\n    T: PrimitiveUnsigned,\n>(\n    out: &mut [T],\n    xs: &[T],\n    y: T,\n) -> T {\n    limbs_mul_limb_with_carry_to_out::<DT, T>(out, xs, y, T::ZERO)\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the product of the `Natural` and a `Limb`, plus a carry, to the input slice. Returns the\n// carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mul_1c` from `gmp-impl.h`, GMP 6.2.1, where the output is the same as the\n// input.\npub_crate_test! {limbs_slice_mul_limb_with_carry_in_place(\n    xs: &mut [Limb],\n    y: Limb,\n    mut carry: Limb\n) -> Limb {\n    let y = DoubleLimb::from(y);\n    for x in &mut *xs {\n        let product = DoubleLimb::from(*x) * y + DoubleLimb::from(carry);\n        *x = product.lower_half();\n        carry = product.upper_half();\n    }\n    carry\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the product of the `Natural` and a `Limb` to the input slice. Returns the carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_mul_1` from `mpn/generic/mul_1.c`, GMP 6.2.1, where `rp == up`.\npub_crate_test! {limbs_slice_mul_limb_in_place(xs: &mut [Limb], y: Limb) -> Limb {\n    limbs_slice_mul_limb_with_carry_in_place(xs, y, 0)\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the product of the `Natural` and a `Limb` to the input `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_mul_1` from `mpn/generic/mul_1.c`, GMP 6.2.1, where the `rp == up` and\n// instead of returning the carry, it is appended to `rp`.\npub_test! {limbs_vec_mul_limb_in_place(xs: &mut Vec<Limb>, y: Limb) {\n    let carry = limbs_slice_mul_limb_in_place(xs, y);\n    if carry != 0 {\n        xs.push(carry);\n    }\n}}\n\nimpl Natural {\n    pub(crate) fn mul_assign_limb(&mut self, other: Limb) {\n        match (&mut *self, other) {\n            (_, 0) => *self = Self::ZERO,\n            (_, 1) | (&mut Self::ZERO, _) => {}\n            (&mut Self::ONE, _) => *self = Self::from(other),\n            (Self(Small(small)), other) => {\n                let (upper, lower) = Limb::x_mul_y_to_zz(*small, other);\n                if upper == 0 {\n                    *small = lower;\n                } else {\n                    *self = Self(Large(vec![lower, upper]));\n                }\n            }\n            (Self(Large(limbs)), other) => {\n                limbs_vec_mul_limb_in_place(limbs, other);\n            }\n        }\n    }\n\n    pub(crate) fn mul_limb_ref(&self, other: Limb) -> Self {\n        match (self, other) {\n            (_, 0) => Self::ZERO,\n            (_, 1) | (&Self::ZERO, _) => self.clone(),\n            (&Self::ONE, _) => Self::from(other),\n            (Self(Small(small)), other) => Self({\n                let (upper, lower) = Limb::x_mul_y_to_zz(*small, other);\n                if upper == 0 {\n                    Small(lower)\n                } else {\n                    Large(vec![lower, upper])\n                }\n            }),\n            (Self(Large(limbs)), other) => Self(Large(limbs_mul_limb(limbs, other))),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Some optimizations contributed by florian1345.\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_mul` and `TOOM44_OK` contributed to the GNU project by Torbjörn Granlund.\n//\n//      Copyright © 1991—1994, 1996, 1996-2003, 2005-2007, 2008, 2009, 2010, 2012, 2014, 2019\n//      Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::limbs_slice_add_greater_in_place_left;\nuse crate::natural::arithmetic::add_mul::{\n    limbs_slice_add_mul_limb_same_length_in_place_left,\n    limbs_slice_add_mul_two_limbs_matching_length_in_place_left,\n};\nuse crate::natural::arithmetic::mul::fft::mpn_mul_default_mpn_ctx;\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::mul::toom::MUL_TOOM33_THRESHOLD_LIMIT;\nuse crate::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_6h, limbs_mul_greater_to_out_toom_6h_scratch_len,\n    limbs_mul_greater_to_out_toom_8h, limbs_mul_greater_to_out_toom_8h_scratch_len,\n    limbs_mul_greater_to_out_toom_22, limbs_mul_greater_to_out_toom_22_scratch_len,\n    limbs_mul_greater_to_out_toom_32, limbs_mul_greater_to_out_toom_32_scratch_len,\n    limbs_mul_greater_to_out_toom_33, limbs_mul_greater_to_out_toom_33_scratch_len,\n    limbs_mul_greater_to_out_toom_42, limbs_mul_greater_to_out_toom_42_scratch_len,\n    limbs_mul_greater_to_out_toom_43, limbs_mul_greater_to_out_toom_43_scratch_len,\n    limbs_mul_greater_to_out_toom_44, limbs_mul_greater_to_out_toom_44_scratch_len,\n    limbs_mul_greater_to_out_toom_53, limbs_mul_greater_to_out_toom_53_scratch_len,\n    limbs_mul_greater_to_out_toom_63, limbs_mul_greater_to_out_toom_63_scratch_len,\n};\nuse crate::platform::{\n    DoubleLimb, Limb, MUL_FFT_THRESHOLD, MUL_TOOM6H_THRESHOLD, MUL_TOOM8H_THRESHOLD,\n    MUL_TOOM22_THRESHOLD, MUL_TOOM32_TO_TOOM43_THRESHOLD, MUL_TOOM32_TO_TOOM53_THRESHOLD,\n    MUL_TOOM33_THRESHOLD, MUL_TOOM42_TO_TOOM53_THRESHOLD, MUL_TOOM42_TO_TOOM63_THRESHOLD,\n    MUL_TOOM44_THRESHOLD,\n};\nuse alloc::vec::Vec;\nuse core::cmp::max;\nuse core::iter::Product;\nuse core::ops::{Mul, MulAssign};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::basic::traits::Zero;\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns\n// the limbs of the product of the `Natural`s. `xs` must be as least as long as `ys` and `ys` cannot\n// be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys` or `ys` is empty.\n//\n// This is equivalent to `mpn_mul` from `mpn/generic/mul.c`, GMP 6.2.1, where `prodp` is returned.\npub_test! {limbs_mul_greater(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let out_len = xs_len + ys_len;\n    let mut scratch = vec![0; out_len + limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)];\n    let (out, mul_scratch) = scratch.split_at_mut(out_len);\n    limbs_mul_greater_to_out(out, xs, ys, mul_scratch);\n    scratch.truncate(out_len);\n    scratch.shrink_to_fit();\n    scratch\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns\n// the limbs of the product of the `Natural`s. Neither slice can be empty. The length of the\n// resulting slice is always the sum of the lengths of the input slices, so it may have trailing\n// zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if either slice is empty.\n//\n// This is equivalent to `mpn_mul` from mpn/generic/mul.c, GMP 6.2.1, where `un` may be less than\n// `vn` and `prodp` is returned.\npub_crate_test! {limbs_mul(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    if xs.len() >= ys.len() {\n        limbs_mul_greater(xs, ys)\n    } else {\n        limbs_mul_greater(ys, xs)\n    }\n}}\n\npub_crate_test! { limbs_mul_same_length_to_out_scratch_len(len: usize) -> usize {\n    if len < MUL_TOOM22_THRESHOLD {\n        0\n    } else if len < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22_scratch_len(\n            MUL_TOOM33_THRESHOLD_LIMIT - 1,\n            MUL_TOOM33_THRESHOLD_LIMIT - 1,\n        )\n    } else if len < MUL_TOOM44_THRESHOLD {\n        limbs_mul_greater_to_out_toom_33_scratch_len(len, len)\n    } else if len < MUL_TOOM6H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_44_scratch_len(len, len)\n    } else if len < MUL_TOOM8H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_6h_scratch_len(len, len)\n    } else if len < FFT_MUL_THRESHOLD {\n        limbs_mul_greater_to_out_toom_8h_scratch_len(len, len)\n    } else {\n        0\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the `2 * xs.len()` least-significant limbs of the product of the `Natural`s to\n// an output slice. The output must be at least as long as `2 * xs.len()`, `xs` must be as long as\n// `ys`, and neither slice can be empty. Returns the result limb at index `2 * xs.len() - 1` (which\n// may be zero).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is too short, `xs` and `ys` have different lengths, or either slice is empty.\n//\n// This is equivalent to `mpn_mul_n` from `mpn/generic/mul_n.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_same_length_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb]\n) {\n    let len = xs.len();\n    assert_eq!(ys.len(), len);\n    assert_ne!(len, 0);\n    let out = &mut out[..len << 1];\n    if len < MUL_TOOM22_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if len < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n    } else if len < MUL_TOOM44_THRESHOLD {\n        limbs_mul_greater_to_out_toom_33(out, xs, ys, scratch);\n    } else if len < MUL_TOOM6H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_44(out, xs, ys, scratch);\n    } else if len < MUL_TOOM8H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_6h(out, xs, ys, scratch);\n    } else if len < FFT_MUL_THRESHOLD {\n        limbs_mul_greater_to_out_toom_8h(out, xs, ys, scratch);\n    } else {\n        mpn_mul_default_mpn_ctx(out, xs, ys, false);\n    }\n}}\n\n// This is equivalent to `TOOM44_OK` from `mpn/generic/mul.c`, GMP 6.2.1.\npub_const_crate_test! {toom44_ok(xs_len: usize, ys_len: usize) -> bool {\n    12 + 3 * xs_len < ys_len << 2\n}}\n\npub_crate_test! { limbs_mul_greater_to_out_scratch_len(xs_len: usize, ys_len: usize) -> usize {\n    assert!(xs_len >= ys_len);\n    assert_ne!(ys_len, 0);\n    if xs_len == ys_len {\n        limbs_mul_same_length_to_out_scratch_len(xs_len)\n    } else if ys_len < MUL_TOOM22_THRESHOLD {\n        0\n    } else if ys_len < MUL_TOOM33_THRESHOLD {\n        if xs_len >= 3 * ys_len {\n            let two_ys_len = ys_len << 1;\n            let three_ys_len = two_ys_len + ys_len;\n            let four_ys_len = two_ys_len << 1;\n            let mut xs_len = xs_len - two_ys_len;\n            while xs_len >= three_ys_len {\n                xs_len -= two_ys_len;\n            }\n            let four_xs_len = xs_len << 2;\n            let first_mul_scratch_len =\n                limbs_mul_greater_to_out_toom_42_scratch_len(two_ys_len, ys_len);\n            let second_mul_scratch_len = if four_xs_len < 5 * ys_len {\n                limbs_mul_greater_to_out_toom_22_scratch_len(xs_len, ys_len)\n            } else if four_xs_len < 7 * ys_len {\n                limbs_mul_greater_to_out_toom_32_scratch_len(xs_len, ys_len)\n            } else {\n                limbs_mul_greater_to_out_toom_42_scratch_len(xs_len, ys_len)\n            };\n            max(first_mul_scratch_len, second_mul_scratch_len) + four_ys_len\n        } else if 4 * xs_len < 5 * ys_len {\n            limbs_mul_greater_to_out_toom_22_scratch_len(xs_len, ys_len)\n        } else if 4 * xs_len < 7 * ys_len {\n            limbs_mul_greater_to_out_toom_32_scratch_len(xs_len, ys_len)\n        } else {\n            limbs_mul_greater_to_out_toom_42_scratch_len(xs_len, ys_len)\n        }\n    } else if (xs_len + ys_len) >> 1 < MUL_FFT_THRESHOLD || 3 * ys_len < MUL_FFT_THRESHOLD {\n        if ys_len < MUL_TOOM44_THRESHOLD || !toom44_ok(xs_len, ys_len) {\n            // Use ToomX3 variants\n            if xs_len << 1 >= 5 * ys_len {\n                let two_ys_len = ys_len << 1;\n                let four_ys_len = two_ys_len << 1;\n                let first_mul_scratch_len = if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_42_scratch_len(two_ys_len, ys_len)\n                } else {\n                    limbs_mul_greater_to_out_toom_63_scratch_len(two_ys_len, ys_len)\n                };\n                let mut xs_len = xs_len - two_ys_len;\n                while xs_len << 1 >= 5 * ys_len {\n                    xs_len -= two_ys_len;\n                }\n                let second_mul_scratch_len = limbs_mul_to_out_scratch_len(xs_len, ys_len);\n                max(first_mul_scratch_len, second_mul_scratch_len) + four_ys_len\n            } else if 6 * xs_len < 7 * ys_len {\n                limbs_mul_greater_to_out_toom_33_scratch_len(xs_len, ys_len)\n            } else if xs_len << 1 < 3 * ys_len {\n                if ys_len < MUL_TOOM32_TO_TOOM43_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_32_scratch_len(xs_len, ys_len)\n                } else {\n                    limbs_mul_greater_to_out_toom_43_scratch_len(xs_len, ys_len)\n                }\n            } else if 6 * xs_len < 11 * ys_len {\n                if xs_len << 2 < 7 * ys_len {\n                    if ys_len < MUL_TOOM32_TO_TOOM53_THRESHOLD {\n                        limbs_mul_greater_to_out_toom_32_scratch_len(xs_len, ys_len)\n                    } else {\n                        limbs_mul_greater_to_out_toom_53_scratch_len(xs_len, ys_len)\n                    }\n                } else if ys_len < MUL_TOOM42_TO_TOOM53_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_42_scratch_len(xs_len, ys_len)\n                } else {\n                    limbs_mul_greater_to_out_toom_53_scratch_len(xs_len, ys_len)\n                }\n            } else if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                limbs_mul_greater_to_out_toom_42_scratch_len(xs_len, ys_len)\n            } else {\n                limbs_mul_greater_to_out_toom_63_scratch_len(xs_len, ys_len)\n            }\n        } else if ys_len < MUL_TOOM6H_THRESHOLD {\n            limbs_mul_greater_to_out_toom_44_scratch_len(xs_len, ys_len)\n        } else if ys_len < MUL_TOOM8H_THRESHOLD {\n            limbs_mul_greater_to_out_toom_6h_scratch_len(xs_len, ys_len)\n        } else {\n            limbs_mul_greater_to_out_toom_8h_scratch_len(xs_len, ys_len)\n        }\n    } else {\n        0\n    }\n}}\n\npub_const_crate_test_const! {FFT_MUL_THRESHOLD: usize = 1000;}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. The output must be at least as long as `xs.len() + ys.len()`, `xs` must be as least as\n// long as `ys`, and `ys` cannot be empty. Returns the result limb at index `xs.len() + ys.len() -\n// 1` (which may be zero).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is too short, `xs` is shorter than `ys`, or `ys` is empty.\n//\n// This is _flint_mpn_mul from mpn_extras/mul.c, FLINT 3.3.0-dev.\npub_crate_test! {limbs_mul_greater_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) -> Limb {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let out_len = xs_len + ys_len;\n    assert!(out.len() >= out_len);\n    if xs_len == ys_len {\n        limbs_mul_same_length_to_out(out, xs, ys, scratch);\n    } else if ys_len < FFT_MUL_THRESHOLD {\n        let mut scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)];\n        limbs_mul_greater_to_out_old(out, xs, ys, &mut scratch);\n    } else {\n        mpn_mul_default_mpn_ctx(out, xs, ys, false);\n    }\n    out[xs_len + ys_len - 1]\n}}\n\npub_crate_test! {limbs_mul_greater_to_out_old(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb]\n) -> Limb {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    assert_ne!(ys_len, 0);\n    assert!(out.len() >= xs_len + ys_len);\n    if ys_len < MUL_TOOM22_THRESHOLD {\n        // Plain schoolbook multiplication. Unless xs_len is very large, or else if\n        // `limbs_mul_same_length_to_out` applies, perform basecase multiply directly.\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if ys_len < MUL_TOOM33_THRESHOLD {\n        if xs_len >= 3 * ys_len {\n            let two_ys_len = ys_len << 1;\n            let three_ys_len = two_ys_len + ys_len;\n            let four_ys_len = two_ys_len << 1;\n            let (scratch, mul_scratch) = scratch.split_at_mut(four_ys_len);\n            limbs_mul_greater_to_out_toom_42(out, &xs[..two_ys_len], ys, mul_scratch);\n            let mut xs = &xs[two_ys_len..];\n            let mut out_offset = two_ys_len;\n            while xs.len() >= three_ys_len {\n                let out = &mut out[out_offset..];\n                let (xs_lo, xs_hi) = xs.split_at(two_ys_len);\n                limbs_mul_greater_to_out_toom_42(scratch, xs_lo, ys, mul_scratch);\n                let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n                out[ys_len..three_ys_len].copy_from_slice(&scratch_hi[..two_ys_len]);\n                assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n                xs = xs_hi;\n                out_offset += two_ys_len;\n            }\n            let xs_len = xs.len();\n            let out = &mut out[out_offset..];\n            // ys_len <= xs_len < 3 * ys_len\n            let four_xs_len = xs_len << 2;\n            if four_xs_len < 5 * ys_len {\n                limbs_mul_greater_to_out_toom_22(scratch, xs, ys, mul_scratch);\n            } else if four_xs_len < 7 * ys_len {\n                limbs_mul_greater_to_out_toom_32(scratch, xs, ys, mul_scratch);\n            } else {\n                limbs_mul_greater_to_out_toom_42(scratch, xs, ys, mul_scratch);\n            }\n            let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n            out[ys_len..ys_len + xs_len].copy_from_slice(&scratch_hi[..xs_len]);\n            assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n        } else if 4 * xs_len < 5 * ys_len {\n            limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n        } else if 4 * xs_len < 7 * ys_len {\n            limbs_mul_greater_to_out_toom_32(out, xs, ys, scratch);\n        } else {\n            limbs_mul_greater_to_out_toom_42(out, xs, ys, scratch);\n        }\n    } else if (xs_len + ys_len) >> 1 < MUL_FFT_THRESHOLD || 3 * ys_len < MUL_FFT_THRESHOLD {\n        // Handle the largest operands that are not in the FFT range. The 2nd condition makes very\n        // unbalanced operands avoid the FFT code (except perhaps as coefficient products of the\n        // Toom code).\n        if ys_len < MUL_TOOM44_THRESHOLD || !toom44_ok(xs_len, ys_len) {\n            // Use ToomX3 variants\n            if xs_len << 1 >= 5 * ys_len {\n                let two_ys_len = ys_len << 1;\n                let four_ys_len = two_ys_len << 1;\n                let (scratch, mul_scratch) = scratch.split_at_mut(four_ys_len);\n                let (xs_lo, mut xs) = xs.split_at(two_ys_len);\n                if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_42(out, xs_lo, ys, mul_scratch);\n                } else {\n                    limbs_mul_greater_to_out_toom_63(out, xs_lo, ys, mul_scratch);\n                }\n                let mut out_offset = two_ys_len;\n                // xs_len >= 2.5 * ys_len\n                while xs.len() << 1 >= 5 * ys_len {\n                    let out = &mut out[out_offset..];\n                    let (xs_lo, xs_hi) = xs.split_at(two_ys_len);\n                    if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                        limbs_mul_greater_to_out_toom_42(scratch, xs_lo, ys, mul_scratch);\n                    } else {\n                        limbs_mul_greater_to_out_toom_63(scratch, xs_lo, ys, mul_scratch);\n                    }\n                    let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n                    out[ys_len..ys_len + two_ys_len].copy_from_slice(&scratch_hi[..two_ys_len]);\n                    assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n                    xs = xs_hi;\n                    out_offset += two_ys_len;\n                }\n                let xs_len = xs.len();\n                let out = &mut out[out_offset..];\n                // ys_len / 2 <= xs_len < 2.5 * ys_len\n                limbs_mul_to_out(scratch, xs, ys, mul_scratch);\n                let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n                out[ys_len..xs_len + ys_len].copy_from_slice(&scratch_hi[..xs_len]);\n                assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n            } else if 6 * xs_len < 7 * ys_len {\n                limbs_mul_greater_to_out_toom_33(out, xs, ys, scratch);\n            } else if xs_len << 1 < 3 * ys_len {\n                if ys_len < MUL_TOOM32_TO_TOOM43_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_32(out, xs, ys, scratch);\n                } else {\n                    limbs_mul_greater_to_out_toom_43(out, xs, ys, scratch);\n                }\n            } else if 6 * xs_len < 11 * ys_len {\n                if xs_len << 2 < 7 * ys_len {\n                    if ys_len < MUL_TOOM32_TO_TOOM53_THRESHOLD {\n                        limbs_mul_greater_to_out_toom_32(out, xs, ys, scratch);\n                    } else {\n                        limbs_mul_greater_to_out_toom_53(out, xs, ys, scratch);\n                    }\n                } else if ys_len < MUL_TOOM42_TO_TOOM53_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_42(out, xs, ys, scratch);\n                } else {\n                    limbs_mul_greater_to_out_toom_53(out, xs, ys, scratch);\n                }\n            } else if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                limbs_mul_greater_to_out_toom_42(out, xs, ys, scratch);\n            } else {\n                limbs_mul_greater_to_out_toom_63(out, xs, ys, scratch);\n            }\n        } else if ys_len < MUL_TOOM6H_THRESHOLD {\n            limbs_mul_greater_to_out_toom_44(out, xs, ys, scratch);\n        } else if ys_len < MUL_TOOM8H_THRESHOLD {\n            limbs_mul_greater_to_out_toom_6h(out, xs, ys, scratch);\n        } else {\n            limbs_mul_greater_to_out_toom_8h(out, xs, ys, scratch);\n        }\n    } else {\n        mpn_mul_default_mpn_ctx(out, xs, ys, false);\n    }\n    out[xs_len + ys_len - 1]\n}}\n\npub_crate_test! {limbs_mul_to_out_scratch_len(xs_len: usize, ys_len: usize) -> usize {\n    if xs_len >= ys_len {\n        limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)\n    } else {\n        limbs_mul_greater_to_out_scratch_len(ys_len, xs_len)\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. The output must be at least as long as `xs.len() + ys.len()`, and neither slice can be\n// empty. Returns the result limb at index `xs.len() + ys.len() - 1` (which may be zero).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `out` is too short or either slice is empty.\n//\n// This is equivalent to `mpn_mul` from `mpn/generic/mul.c`, GMP 6.2.1, where `un` may be less than\n// `vn`.\npub_crate_test! {limbs_mul_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb]\n) -> Limb {\n    if xs.len() >= ys.len() {\n        limbs_mul_greater_to_out(out, xs, ys, scratch)\n    } else {\n        limbs_mul_greater_to_out(out, ys, xs, scratch)\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. The output must be at least as long as `xs.len() + ys.len()`, `xs` must be as least as\n// long as `ys`, and `ys` cannot be empty. Returns the result limb at index `xs.len() + ys.len() -\n// 1` (which may be zero).\n//\n// This uses the basecase, quadratic, schoolbook algorithm, and it is most critical code for\n// multiplication. All multiplies rely on this, both small and huge. Small ones arrive here\n// immediately, and huge ones arrive here as this is the base case for Karatsuba's recursive\n// algorithm.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `out` is too short, `xs` is shorter than `ys`, or `ys` is empty.\n//\n// This is equivalent to `mpn_mul_basecase` from `mpn/generic/mul_basecase.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_basecase(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    assert!(xs_len >= ys_len);\n    assert!(out.len() >= xs_len + ys_len);\n    let out = &mut out[..(xs_len + ys_len)];\n    // We first multiply by the low order limb. This result can be stored, not added, to out.\n    out[xs_len] = limbs_mul_limb_to_out::<DoubleLimb, Limb>(out, xs, ys[0]);\n    // Now accumulate the product of xs and the next higher limb from ys.\n    let window_size = xs_len + 1;\n    let mut i = 1;\n    let max = ys_len - 1;\n    while i < max {\n        let (out_last, out_init) = out[i..=i + window_size].split_last_mut().unwrap();\n        *out_last = limbs_slice_add_mul_two_limbs_matching_length_in_place_left(\n            out_init,\n            xs,\n            [ys[i], ys[i + 1]],\n        );\n        i += 2;\n    }\n    if i <= max {\n        let (out_last, out_init) = out[i..i + window_size].split_last_mut().unwrap();\n        *out_last = limbs_slice_add_mul_limb_same_length_in_place_left(out_init, xs, ys[i]);\n    }\n}}\n\nimpl Mul<Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ONE * Natural::from(123u32), 123);\n    /// assert_eq!(Natural::from(123u32) * Natural::ZERO, 0);\n    /// assert_eq!(Natural::from(123u32) * Natural::from(456u32), 56088);\n    /// assert_eq!(\n    ///     (Natural::from_str(\"123456789000\").unwrap()\n    ///         * Natural::from_str(\"987654321000\").unwrap())\n    ///     .to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    #[inline]\n    fn mul(mut self, other: Self) -> Self {\n        self *= other;\n        self\n    }\n}\n\nimpl<'a> Mul<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Multiplies two [`Natural`]s, taking the first by value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ONE * &Natural::from(123u32), 123);\n    /// assert_eq!(Natural::from(123u32) * &Natural::ZERO, 0);\n    /// assert_eq!(Natural::from(123u32) * &Natural::from(456u32), 56088);\n    /// assert_eq!(\n    ///     (Natural::from_str(\"123456789000\").unwrap()\n    ///         * &Natural::from_str(\"987654321000\").unwrap())\n    ///         .to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    #[inline]\n    fn mul(mut self, other: &'a Self) -> Self {\n        self *= other;\n        self\n    }\n}\n\nimpl Mul<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s, taking the first by reference and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::ONE * Natural::from(123u32), 123);\n    /// assert_eq!(&Natural::from(123u32) * Natural::ZERO, 0);\n    /// assert_eq!(&Natural::from(123u32) * Natural::from(456u32), 56088);\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"123456789000\").unwrap()\n    ///         * Natural::from_str(\"987654321000\").unwrap())\n    ///     .to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    #[inline]\n    fn mul(self, mut other: Natural) -> Natural {\n        other *= self;\n        other\n    }\n}\n\nimpl Mul<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Multiplies two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::ONE * &Natural::from(123u32), 123);\n    /// assert_eq!(&Natural::from(123u32) * &Natural::ZERO, 0);\n    /// assert_eq!(&Natural::from(123u32) * &Natural::from(456u32), 56088);\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"123456789000\").unwrap()\n    ///         * &Natural::from_str(\"987654321000\").unwrap())\n    ///         .to_string(),\n    ///     \"121932631112635269000000\"\n    /// );\n    /// ```\n    fn mul(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (Natural(Small(x)), y) => y.mul_limb_ref(*x),\n            (x, Natural(Small(y))) => x.mul_limb_ref(*y),\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                Natural::from_owned_limbs_asc(limbs_mul(xs, ys))\n            }\n        }\n    }\n}\n\nimpl MulAssign<Self> for Natural {\n    /// Multiplies a [`Natural`] by a [`Natural`] in place, taking the [`Natural`] on the right-hand\n    /// side by value.\n    ///\n    /// $$\n    /// x \\gets = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ONE;\n    /// x *= Natural::from_str(\"1000\").unwrap();\n    /// x *= Natural::from_str(\"2000\").unwrap();\n    /// x *= Natural::from_str(\"3000\").unwrap();\n    /// x *= Natural::from_str(\"4000\").unwrap();\n    /// assert_eq!(x.to_string(), \"24000000000000\");\n    /// ```\n    fn mul_assign(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (Self(Small(x)), _) => {\n                other.mul_assign_limb(*x);\n                *self = other;\n            }\n            (_, Self(Small(y))) => self.mul_assign_limb(*y),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                *xs = limbs_mul(xs, ys);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl<'a> MulAssign<&'a Self> for Natural {\n    /// Multiplies a [`Natural`] by a [`Natural`] in place, taking the [`Natural`] on the right-hand\n    /// side by reference.\n    ///\n    /// $$\n    /// x \\gets = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ONE;\n    /// x *= &Natural::from_str(\"1000\").unwrap();\n    /// x *= &Natural::from_str(\"2000\").unwrap();\n    /// x *= &Natural::from_str(\"3000\").unwrap();\n    /// x *= &Natural::from_str(\"4000\").unwrap();\n    /// assert_eq!(x.to_string(), \"24000000000000\");\n    /// ```\n    fn mul_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (Self(Small(x)), _) => *self = other.mul_limb_ref(*x),\n            (_, Self(Small(y))) => self.mul_assign_limb(*y),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                *xs = limbs_mul(xs, ys);\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl Product for Natural {\n    /// Multiplies together all the [`Natural`]s in an iterator.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\prod_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Natural::sum(xs.map(Natural::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Product;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::product(vec_from_str::<Natural>(\"[2, 3, 5, 7]\").unwrap().into_iter()),\n    ///     210\n    /// );\n    /// ```\n    fn product<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate().map(|(i, x)| (i + 1, x)) {\n            if x == 0 {\n                return Self::ZERO;\n            }\n            let mut p = x;\n            for _ in 0..i.trailing_zeros() {\n                p *= stack.pop().unwrap();\n            }\n            stack.push(p);\n        }\n        let mut p = Self::ONE;\n        for x in stack.into_iter().rev() {\n            p *= x;\n        }\n        p\n    }\n}\n\nimpl<'a> Product<&'a Self> for Natural {\n    /// Multiplies together all the [`Natural`]s in an iterator of [`Natural`] references.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\prod_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Natural::sum(xs.map(Natural::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::Product;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::product(vec_from_str::<Natural>(\"[2, 3, 5, 7]\").unwrap().iter()),\n    ///     210\n    /// );\n    /// ```\n    fn product<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = &'a Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate().map(|(i, x)| (i + 1, x)) {\n            if *x == 0 {\n                return Self::ZERO;\n            }\n            let mut p = x.clone();\n            for _ in 0..i.trailing_zeros() {\n                p *= stack.pop().unwrap();\n            }\n            stack.push(p);\n        }\n        let mut p = Self::ONE;\n        for x in stack.into_iter().rev() {\n            p *= x;\n        }\n        p\n    }\n}\n\n/// A precomputed object used by FFT code.\npub mod context;\n/// Code for multiplying large integers. Derived from Daniel Schultz's small-prime FFT\n/// implementation for FLINT.\npub mod fft;\n/// Code for multiplying a many-limbed [`Natural`] by a single [limb](crate#limbs).\npub mod limb;\n/// Code for computing only the lowest [limbs](crate#limbs) of the product of two [`Natural`]s.\npub mod mul_low;\n/// Code for multiplying two [`Natural`]s modulo one less than a large power of 2; used by the\n/// Schönhage-Strassen algorithm.\npub mod mul_mod;\n/// Code for evaluating polynomials at various points; used in Toom-Cook multiplication.\npub mod poly_eval;\n/// Code for reconstructing polynomials from their values at various points; used in Toom-Cook\n/// multiplication.\npub mod poly_interpolate;\n#[cfg(feature = \"test_build\")]\n/// Code for multiplying several limbs together.\npub mod product_of_limbs;\n#[cfg(not(feature = \"test_build\"))]\n/// Code for multiplying several limbs together.\npub(crate) mod product_of_limbs;\n/// Code for Toom-Cook multiplication.\npub mod toom;\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/mul_low.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_mullo_n`, `mpn_mullo_n_itch`, and `mpn_dc_mullo_n` contributed to the GNU project by\n//      Torbjörn Granlund and Marco Bodrato.\n//\n//      Copyright © 2000, 2002, 2004, 2005, 2009, 2010, 2012, 2015 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_add_same_length_to_out, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::mul::toom::{TUNE_PROGRAM_BUILD, WANT_FAT_BINARY};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out_basecase, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len,\n};\nuse crate::platform::{\n    DoubleLimb, Limb, MUL_TOOM8H_THRESHOLD, MUL_TOOM22_THRESHOLD, MUL_TOOM33_THRESHOLD,\n    MUL_TOOM44_THRESHOLD, MULLO_BASECASE_THRESHOLD, MULLO_DC_THRESHOLD, MULLO_MUL_N_THRESHOLD,\n};\nuse malachite_base::num::arithmetic::traits::WrappingAddAssign;\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_mullo_basecase` from `mpn/generic/mullo_basecase.c`, GMP 6.2.1,\n// `MULLO_VARIANT == 2`.\npub_crate_test! {limbs_mul_low_same_length_basecase(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let n = xs.len();\n    assert_ne!(n, 0);\n    assert_eq!(ys.len(), n);\n    let (ys_last, ys_init) = ys.split_last().unwrap();\n    let (out_last, out_init) = out[..n].split_last_mut().unwrap();\n    let mut p = xs[0].wrapping_mul(*ys_last);\n    if n != 1 {\n        let y = ys_init[0];\n        let (xs_last, xs_init) = xs.split_last().unwrap();\n        let product = xs_last\n            .wrapping_mul(y)\n            .wrapping_add(limbs_mul_limb_to_out::<DoubleLimb, Limb>(out_init, xs_init, y));\n        p.wrapping_add_assign(product);\n        let m = n - 1;\n        for i in 1..m {\n            let y = ys_init[i];\n            let (xs_lo, xs_hi) = xs_init.split_at(m - i);\n            let limb_p = xs_hi[0].wrapping_mul(y).wrapping_add(\n                limbs_slice_add_mul_limb_same_length_in_place_left(&mut out_init[i..], xs_lo, y),\n            );\n            p.wrapping_add_assign(limb_p);\n        }\n    }\n    *out_last = p;\n}}\n\n// TODO tune\nconst SCALED_MUL_TOOM22_THRESHOLD: usize = MUL_TOOM22_THRESHOLD * 36 / (36 - 11);\n// TODO tune\nconst SCALED_MUL_TOOM33_THRESHOLD: usize = MUL_TOOM33_THRESHOLD * 36 / (36 - 11);\n// TODO tune\nconst SCALED_MUL_TOOM44_THRESHOLD: usize = MUL_TOOM44_THRESHOLD.saturating_mul(40) / (40 - 9);\n// TODO tune\nconst SCALED_MUL_TOOM8H_THRESHOLD: usize = MUL_TOOM8H_THRESHOLD * 10 / 9;\n\n// TODO tune\nconst MAYBE_RANGE_BASECASE_MUL_LOW: bool = TUNE_PROGRAM_BUILD\n    || WANT_FAT_BINARY\n    || (MULLO_DC_THRESHOLD == 0 && MULLO_BASECASE_THRESHOLD < SCALED_MUL_TOOM22_THRESHOLD\n        || MULLO_DC_THRESHOLD != 0 && MULLO_DC_THRESHOLD < SCALED_MUL_TOOM22_THRESHOLD);\n\n// TODO tune\nconst MAYBE_RANGE_TOOM22_MUL_LOW: bool = TUNE_PROGRAM_BUILD\n    || WANT_FAT_BINARY\n    || (MULLO_DC_THRESHOLD == 0 && MULLO_BASECASE_THRESHOLD < SCALED_MUL_TOOM33_THRESHOLD\n        || MULLO_DC_THRESHOLD != 0 && MULLO_DC_THRESHOLD < SCALED_MUL_TOOM33_THRESHOLD);\n\n// We need fractional approximation of the value 0 < a <= 1/2 giving the minimum in the function k =\n// (1 - a) ^ e / (1 - 2 * a ^ e).\nconst fn get_n_lo(n: usize) -> usize {\n    if MAYBE_RANGE_BASECASE_MUL_LOW && n < SCALED_MUL_TOOM22_THRESHOLD {\n        n >> 1\n    } else if MAYBE_RANGE_TOOM22_MUL_LOW && n < SCALED_MUL_TOOM33_THRESHOLD {\n        n * 11 / 36 // n_lo ~= n * (1 - .694...)\n    } else if n < SCALED_MUL_TOOM44_THRESHOLD {\n        n * 9 / 40 // n_lo ~= n * (1 - .775...)\n    } else if n < SCALED_MUL_TOOM8H_THRESHOLD {\n        n * 7 / 39 // n_lo ~= n * (1 - .821...)\n    } else {\n        n / 10 // n_lo ~= n * (1 - .899...) [TOOM88]\n    }\n}\n\n// See `limbs_mul_low_same_length_divide_and_conquer` documentation for more details.\n//\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_8 15}) \\approx O(n^{1.302})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_dc_mullo_n` from `mpn/generic/mullo_n.c`, GMP 6.2.1, where `rp == tp`.\npub_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_mul_low_same_length_divide_and_conquer_shared_scratch(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert!(n >= 2);\n    let n_lo = get_n_lo(n);\n    let n_hi = n - n_lo;\n    // Split as x = x_1 *  2 ^ (n_hi * Limb::WIDTH) + x_0, y = y_1 * 2 ^ (n_hi * Limb::WIDTH) + y_0\n    let (xs_lo, xs_hi) = xs.split_at(n_hi);\n    // x_0 * y_0\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(n_hi)];\n    limbs_mul_same_length_to_out(out, xs_lo, &ys[..n_hi], &mut mul_scratch);\n    let ys_lo = &ys[..n_lo];\n    let (out_lo, out_hi) = out.split_at_mut(n);\n    // x_1 * y_0 * 2 ^ (n_hi * Limb::WIDTH)\n    if n_lo < MULLO_BASECASE_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out_hi, xs_hi, ys_lo);\n    } else if n_lo < MULLO_DC_THRESHOLD {\n        limbs_mul_low_same_length_basecase(out_hi, xs_hi, ys_lo);\n    } else {\n        limbs_mul_low_same_length_divide_and_conquer_shared_scratch(out_hi, xs_hi, ys_lo);\n    }\n    limbs_slice_add_same_length_in_place_left(&mut out_lo[n_hi..], &out_hi[..n_lo]);\n    let xs_lo = &xs[..n_lo];\n    let ys_hi = &ys[n_hi..];\n    // x_0 * y_1 * 2 ^ (n_hi * Limb::WIDTH)\n    if n_lo < MULLO_BASECASE_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out_hi, xs_lo, ys_hi);\n    } else if n_lo < MULLO_DC_THRESHOLD {\n        limbs_mul_low_same_length_basecase(out_hi, xs_lo, ys_hi);\n    } else {\n        limbs_mul_low_same_length_divide_and_conquer_shared_scratch(out_hi, xs_lo, ys_hi);\n    }\n    limbs_slice_add_same_length_in_place_left(&mut out_lo[n_hi..], &out_hi[..n_lo]);\n}}\n\n// Compute the least significant half of the product {xs, n} * {ys, n}, or formally {rp, n} = {xs,\n// n} * {ys, n} mod (2 ^ `Limb::WIDTH * n`).\n//\n// Above the given threshold, the Divide and Conquer strategy is used. The operands are split in\n// two, and a full product plus two mul_low are used to obtain the final result. The more natural\n// strategy is to split in two halves, but this is far from optimal when a sub-quadratic\n// multiplication is used.\n//\n// Mulders suggests an unbalanced split in favour of the full product, split n = n_lo + n_hi, where\n// a * n = n_lo <= n_hi = (1 - a) * n; i.e. 0 < a <= 1/2.\n//\n// To compute the value of a, we assume that the cost of mul_lo for a given size ML(n) is a fraction\n// of the cost of a full product with same size M(n), and the cost M(n) = n ^ e for some exponent 1\n// < e <= 2. Then we can write:\n//\n// ML(n) = 2 * ML(a * n) + M((1 - a) * n) => k * M(n) = 2 * k * M(n) * a ^ e + M(n) * (1 - a) ^ e\n//\n// Given a value for e, want to minimise the value of k, i.e. the function k = (1 - a) ^ e / (1 - 2\n// * a ^ e).\n//\n// With e = 2, the exponent for schoolbook multiplication, the minimum is given by the values a = 1\n// - a = 1/2.\n//\n// With e = log(3) / log(2), the exponent for Karatsuba (aka toom22), Mulders computes (1 - a) =\n// 0.694... and we approximate a with 11 / 36.\n//\n// Other possible approximations follow:\n// - e = log(5) / log(3) [Toom-3] -> a ~= 9/40\n// - e = log(7) / log(4) [Toom-4] -> a ~= 7/39\n// - e = log(11) / log(6) [Toom-6] -> a ~= 1/8\n// - e = log(15) / log(8) [Toom-8] -> a ~= 1/10\n//\n// The values above where obtained with the following trivial commands in the gp-pari shell:\n//\n// - fun(e,a)=(1-a)^e/(1-2*a^e)\n// - mul(a,b,c)={local(m,x,p);if(b-c<1/10000,(b+c)/2,m=1;x=b;\n// - forstep(p=c,b,(b-c)/8,if(fun(a,p)<m,m=fun(a,p);x=p));mul(a,(b+x)/2,(c+x)/2))}\n//\n// - contfracpnqn(contfrac(mul(log(2*2-1)/log(2),1/2,0),5))\n// - contfracpnqn(contfrac(mul(log(3*2-1)/log(3),1/2,0),5))\n// - contfracpnqn(contfrac(mul(log(4*2-1)/log(4),1/2,0),5))\n// - contfracpnqn(contfrac(mul(log(6*2-1)/log(6),1/2,0),3))\n// - contfracpnqn(contfrac(mul(log(8*2-1)/log(8),1/2,0),3))\n//\n// ```\n// ,\n// |\\\n// | \\\n// +----,\n// |    |\n// |    |\n// |    |\\\n// |    | \\\n// +----+--`\n// ^n_hi^__^ <- n_low\n// ```\n//\n// For an actual implementation, the assumption that M(n) = n ^ e is incorrect, and, as a\n// consequence, the assumption that ML(n) = k * M(n) with a constant k is wrong.\n//\n// But theory suggests us two things:\n// - the faster multiplication is (the lower e is), the more k approaches 1 and a approaches 0.\n//\n// - A smaller-than-optimal value for a is probably less bad than a bigger one: e.g. let e = log(3)\n//   / log(2), a = 0.3058... (the optimal value), and k(a) = 0.808...,  the mul / mul_low speed\n//   ratio. We get k * (a + 1 / 6) = 0.929..., but k(a - 1/6) = 0.865....\n//\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_8 15}) \\approx O(n^{1.302})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_dc_mullo_n` from `mpn/generic/mullo_n.c`, GMP 6.2.1, where `rp != tp`.\npub_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_mul_low_same_length_divide_and_conquer(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert!(n >= 2);\n    let n_lo = get_n_lo(n);\n    let n_hi = n - n_lo;\n    let (out_lo, out_hi) = out[..n].split_at_mut(n_hi);\n    // Split as x = x_1 *  2 ^ (n_hi * Limb::WIDTH) + x_0, y = y_1 * 2 ^ (n_hi * Limb::WIDTH) + y_0\n    let (xs_lo, xs_hi) = xs.split_at(n_hi);\n    // x_0 * y_0\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(n_hi)];\n    limbs_mul_same_length_to_out(scratch, xs_lo, &ys[..n_hi], &mut mul_scratch);\n    out_lo.copy_from_slice(&scratch[..n_hi]);\n    let ys_lo = &ys[..n_lo];\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(n);\n    // x_1 * y_0 * 2 ^ (n_hi * Limb::WIDTH)\n    if n_lo < MULLO_BASECASE_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(scratch_hi, xs_hi, ys_lo);\n    } else if n_lo < MULLO_DC_THRESHOLD {\n        limbs_mul_low_same_length_basecase(scratch_hi, xs_hi, ys_lo);\n    } else {\n        limbs_mul_low_same_length_divide_and_conquer_shared_scratch(scratch_hi, xs_hi, ys_lo);\n    }\n    limbs_add_same_length_to_out(out_hi, &scratch_lo[n_hi..], &scratch_hi[..n_lo]);\n    let xs_lo = &xs[..n_lo];\n    let ys_hi = &ys[n_hi..];\n    // x_0 * y_1 * 2 ^ (n_hi * Limb::WIDTH)\n    if n_lo < MULLO_BASECASE_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(scratch_hi, xs_lo, ys_hi);\n    } else if n_lo < MULLO_DC_THRESHOLD {\n        limbs_mul_low_same_length_basecase(scratch_hi, xs_lo, ys_hi);\n    } else {\n        limbs_mul_low_same_length_divide_and_conquer_shared_scratch(scratch_hi, xs_lo, ys_hi);\n    }\n    limbs_slice_add_same_length_in_place_left(out_hi, &scratch_hi[..n_lo]);\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_mullo_n_itch` from `mpn/generic/mullo_n.c`, GMP 6.2.1.\npub_const_test! {limbs_mul_low_same_length_divide_and_conquer_scratch_len(n: usize) -> usize {\n    n << 1\n}}\n\n// TODO tune\nconst MULLO_BASECASE_THRESHOLD_LIMIT: usize = MULLO_BASECASE_THRESHOLD;\n\npub_test! {limbs_mul_low_same_length_large(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n = xs.len();\n    // For really large operands, use plain limbs_mul_same_length_to_out but throw away the upper n\n    // limbs of the result.\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(n)];\n    limbs_mul_same_length_to_out(scratch, xs, ys, &mut mul_scratch);\n    out.copy_from_slice(&scratch[..n]);\n}}\n\n// Multiply two n-limb numbers and return the lowest n limbs of their products.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$, assuming $k = O(\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_mullo_n` from `mpn/generic/mullo_n.c`, GMP 6.2.1.\npub_crate_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_mul_low_same_length(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    assert!(n >= 1);\n    let out = &mut out[..n];\n    if n < MULLO_BASECASE_THRESHOLD {\n        // Allocate workspace of fixed size on stack: fast!\n        let scratch = &mut [0; MULLO_BASECASE_THRESHOLD_LIMIT];\n        limbs_mul_greater_to_out_basecase(scratch, xs, ys);\n        out.copy_from_slice(&scratch[..n]);\n    } else if n < MULLO_DC_THRESHOLD {\n        limbs_mul_low_same_length_basecase(out, xs, ys);\n    } else {\n        let mut scratch = vec![0; limbs_mul_low_same_length_divide_and_conquer_scratch_len(n)];\n        if n < MULLO_MUL_N_THRESHOLD {\n            limbs_mul_low_same_length_divide_and_conquer(out, xs, ys, &mut scratch);\n        } else {\n            limbs_mul_low_same_length_large(out, xs, ys, &mut scratch);\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_mullo_basecase` from `mpn/generic/mullo_basecase.c`, GMP 6.2.1,\n// `MULLO_VARIANT == 1`.\npub_crate_test! {limbs_mul_low_same_length_basecase_alt(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb]\n) {\n    let n = xs.len();\n    assert_ne!(n, 0);\n    assert_eq!(ys.len(), n);\n    let out = &mut out[..n];\n    limbs_mul_limb_to_out::<DoubleLimb, Limb>(out, xs, ys[0]);\n    for i in 1..n {\n        limbs_slice_add_mul_limb_same_length_in_place_left(&mut out[i..], &xs[..n - i], ys[i]);\n    }\n}}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/mul_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_bc_mulmod_bnm1`, `mpn_bc_mulmod_bnp1`, `mpn_mulmod_bnm1`, and\n//      `mpn_mulmod_bnm1_next_size` contributed to the GNU project by Niels Möller, Torbjörn\n//      Granlund and Marco Bodrato.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_add_same_length_to_out, limbs_add_to_out, limbs_slice_add_limb_in_place,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_greater_to_out, limbs_sub_limb_in_place,\n    limbs_sub_same_length_in_place_left, limbs_sub_same_length_to_out,\n    limbs_sub_same_length_with_borrow_in_in_place_right,\n};\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{Parity, RoundToMultipleOfPowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::slice_test_zero;\n\n// TODO tune\npub(crate) const MULMOD_BNM1_THRESHOLD: usize = 13;\n\n// # Worst-case complexity\n// Constant time and additional memory.\npub(crate) fn limbs_mul_mod_base_pow_n_minus_1_next_size_helper(\n    n: usize,\n    low_threshold: usize,\n) -> usize {\n    if n < low_threshold {\n        n\n    } else if n <= (low_threshold - 1) << 2 {\n        n.round_to_multiple_of_power_of_2(1, Ceiling).0\n    } else if n <= (low_threshold - 1) << 3 {\n        n.round_to_multiple_of_power_of_2(2, Ceiling).0\n    } else {\n        n.round_to_multiple_of_power_of_2(3, Ceiling).0\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// The result is $O(n)$.\n//\n// This is equivalent to `mpn_mulmod_bnm1_next_size` from `mpn/generic/mulmod_bnm1.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_mod_base_pow_n_minus_1_next_size(n: usize) -> usize {\n    limbs_mul_mod_base_pow_n_minus_1_next_size_helper(\n        n,\n        MULMOD_BNM1_THRESHOLD,\n    )\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// The result is $O(n)$.\n//\n// This is equivalent to `mpn_mulmod_bnm1_itch` from `gmp-impl.h`, GMP 6.2.1.\npub(crate) const fn limbs_mul_mod_base_pow_n_minus_1_scratch_len(\n    n: usize,\n    xs_len: usize,\n    ys_len: usize,\n) -> usize {\n    let half_n = n >> 1;\n    if xs_len > half_n {\n        if ys_len > half_n {\n            (n + 2) << 1\n        } else {\n            n + 4 + half_n\n        }\n    } else {\n        n + 4\n    }\n}\n\n// Interpreting two equal-length, nonempty slices of `Limb`s as the limbs (in ascending order) of\n// two `Natural`s, multiplies the `Natural`s mod `2 ^ (Limb::WIDTH * n) - 1`, where n is the length\n// of either slice. The result is semi-normalized: zero is represented as either 0 or `Limb::WIDTH ^\n// n - 1`. The limbs of the result are written to `out`. `out` should have length at least n, and\n// `scratch` at least 2 * n. This is the basecase algorithm.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths, if `out` or `scratch` are too short, or if the\n// input slices are empty.\n//\n// This is equivalent to `mpn_bc_mulmod_bnm1` from `mpn/generic/mulmod_bnm1.c`, GMP 6.2.1.\nfn limbs_mul_mod_base_pow_n_minus_1_basecase(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n = xs.len();\n    assert_ne!(n, 0);\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(n)];\n    limbs_mul_same_length_to_out(scratch, xs, ys, &mut mul_scratch);\n    split_into_chunks_mut!(scratch, n, [scratch_lo, scratch_hi], _unused);\n    if limbs_add_same_length_to_out(out, scratch_lo, scratch_hi) {\n        // If carry == 1, then the value of out is at most B ^ n - 2, so there can be no overflow\n        // when adding in the carry.\n        limbs_slice_add_limb_in_place(&mut out[..n], 1);\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\npub(crate) fn limbs_mul_mod_base_pow_n_plus_1_basecase_helper(out: &mut [Limb], n: usize) {\n    split_into_chunks_mut!(out, n, [out_0, out_1], out_2);\n    assert_eq!(out_2[1], 0);\n    let mut carry = out_2[0];\n    assert_ne!(carry, Limb::MAX);\n    if limbs_sub_same_length_in_place_left(out_0, out_1) {\n        carry += 1;\n    }\n    out_1[0] = 0;\n    assert!(!limbs_slice_add_limb_in_place(&mut out[..=n], carry));\n}\n\n// Interpreting the first n + 1 limbs of two slices of `Limb`s as the limbs (in ascending order) of\n// two `Natural`s, multiplies the `Natural`s mod `2 ^ (Limb::WIDTH * n) + 1`. The limbs of the\n// result are written to `out`, which should have length at least 2 * n + 2.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// # Panics\n// Panics if `xs`, `ys`, or `out` are too short, or if n is zero.\n//\n// This is equivalent to `mpn_bc_mulmod_bnp1` from `mpn/generic/mulmod_bnm1.c`, GMP 6.2.1, where `rp\n// == tp`.\nfn limbs_mul_mod_base_pow_n_plus_1_basecase(out: &mut [Limb], xs: &[Limb], ys: &[Limb], n: usize) {\n    assert_ne!(0, n);\n    let m = n + 1;\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(m)];\n    limbs_mul_same_length_to_out(out, &xs[..m], &ys[..m], &mut mul_scratch);\n    limbs_mul_mod_base_pow_n_plus_1_basecase_helper(out, n);\n}\n\n// Interpreting two nonempty slices of `Limb`s as the limbs (in ascending order) of two `Natural`s,\n// multiplies the `Natural`s mod `2 ^ (Limb::WIDTH * n) - 1`. The limbs of the result are written to\n// `out`.\n//\n// The result is expected to be 0 if and only if one of the operands already is. Otherwise the class\n// 0 mod `(Limb::WIDTH ^ n - 1)` is represented by `2 ^ (n * Limb::WIDTH) - 1`. This should not be a\n// problem if `limbs_mul_mod_base_pow_n_minus_1` is used to combine results and obtain a natural\n// number when one knows in advance that the final value is less than `2 ^ (n * Limb::WIDTH) - 1`.\n// Moreover it should not be a problem if `limbs_mul_mod_base_pow_n_minus_1` is used to compute the\n// full product with `xs.len() + ys.len() <= n`, because this condition implies `(2 ^ (Limb::WIDTH *\n// xs.len()) - 1)(2 ^ (Limb::WIDTH * ys.len()) - 1) < 2 ^ (Limb::WIDTH * n) - 1`.\n//\n// Requires 0 < `ys.len()` <= `xs.len()` <= n and an + `ys.len()` > n / 2. Scratch need: n + (need\n// for recursive call OR n + 4). This gives S(n) <= n + MAX (n + 4, S(n / 2)) <= 2 * n + 4\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`, if `ys` is empty, is `xs` is longer than n, or if `out` or\n// `scratch` are too short.\n//\n// This is equivalent to `mpn_mulmod_bnm1` from `mpn/generic/mulmod_bnm1.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_mod_base_pow_n_minus_1(\n    out: &mut [Limb],\n    n: usize,\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert_ne!(0, ys_len);\n    assert!(xs_len >= ys_len);\n    assert!(xs_len <= n);\n    let sum = xs_len + ys_len;\n    if n < MULMOD_BNM1_THRESHOLD || n.odd() {\n        if ys_len < n {\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)];\n            if sum <= n {\n                limbs_mul_greater_to_out(out, xs, ys, &mut mul_scratch);\n            } else {\n                limbs_mul_greater_to_out(scratch, xs, ys, &mut mul_scratch);\n                if limbs_add_to_out(out, &scratch[..n], &scratch[n..sum]) {\n                    assert!(!limbs_slice_add_limb_in_place(&mut out[..n], 1));\n                }\n            }\n        } else {\n            limbs_mul_mod_base_pow_n_minus_1_basecase(out, &xs[..n], ys, scratch);\n        }\n    } else {\n        let half_n = n >> 1;\n        // We need at least xs_len + ys_len >= half_n, to be able to fit one of the recursive\n        // products at out. Requiring strict inequality makes the code slightly simpler. If desired,\n        // we could avoid this restriction by initially halving n as long as n is even and xs_len +\n        // ys_len <= n / 2.\n        assert!(sum > half_n);\n        // Compute xm = a * b mod (2 ^ (Limb::WIDTH * half_n) - 1), xp = a * b mod (2 ^ (Limb::WIDTH\n        // * half_n) + 1), and Chinese-Remainder-Theorem together as x = -xp * 2 ^ (Limb::WIDTH *\n        // half_n) + (2 ^ (Limb::WIDTH * half_n) + 1) * ((xp + xm) / 2 mod (2 ^ (Limb::WIDTH *\n        // half_n) - 1))\n        let m = half_n + 1;\n        if xs_len <= half_n {\n            limbs_mul_mod_base_pow_n_minus_1(out, half_n, xs, ys, scratch);\n                assert!(sum <= (half_n << 1) | 1);\n                let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)];\n                limbs_mul_greater_to_out(scratch, xs, ys, &mut mul_scratch);\n                let mut limit = sum - half_n;\n                assert!(limit <= half_n || scratch[half_n << 1] == 0);\n                if limit > half_n {\n                    limit -= 1;\n                }\n                let carry = {\n                    let (scratch_lo, scratch_hi) = scratch.split_at_mut(half_n);\n                    limbs_sub_greater_in_place_left(scratch_lo, &scratch_hi[..limit])\n                };\n                scratch[half_n] = 0;\n                if carry {\n                    assert!(!limbs_slice_add_limb_in_place(&mut scratch[..m], 1));\n                }\n        } else {\n            let (xs_0, xs_1) = xs.split_at(half_n);\n            let carry = limbs_add_to_out(scratch, xs_0, xs_1);\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(half_n);\n            if carry {\n                assert!(!limbs_slice_add_limb_in_place(scratch_lo, 1));\n            }\n            if ys_len <= half_n {\n                limbs_mul_mod_base_pow_n_minus_1(out, half_n, scratch_lo, ys, scratch_hi);\n                let scratch_2 = &mut scratch[m << 1..3 * m];\n                let carry = limbs_sub_greater_to_out(scratch_2, xs_0, xs_1);\n                *scratch_2.last_mut().unwrap() = 0;\n                if carry {\n                    assert!(!limbs_slice_add_limb_in_place(scratch_2, 1));\n                }\n                let a = half_n + usize::exact_from(*scratch_2.last_mut().unwrap());\n                    let sum_2 = a + ys_len;\n                    assert!(sum_2 <= (half_n << 1) + 1);\n                    assert!(sum_2 > half_n);\n                    assert!(a >= ys_len);\n                    let (scratch_lo, scratch_hi) = scratch.split_at_mut(m << 1);\n                    let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(a, ys_len)];\n                    limbs_mul_greater_to_out(scratch_lo, &scratch_hi[..a], ys, &mut mul_scratch);\n                    let mut a = sum_2 - half_n;\n                    assert!(a <= half_n || scratch[half_n << 1] == 0);\n                    if a > half_n {\n                        a -= 1;\n                    }\n                    let carry = {\n                        let (scratch_lo, scratch_hi) = scratch.split_at_mut(half_n);\n                        limbs_sub_greater_in_place_left(scratch_lo, &scratch_hi[..a])\n                    };\n                    scratch[half_n] = 0;\n                    if carry {\n                        assert!(!limbs_slice_add_limb_in_place(&mut scratch[..m], 1));\n                    }\n            } else {\n                let (ys_0, ys_1) = ys.split_at(half_n);\n                let carry = limbs_add_to_out(scratch_hi, ys_0, ys_1);\n                let (scratch_1, scratch_2) = scratch_hi.split_at_mut(half_n);\n                if carry {\n                    assert!(!limbs_slice_add_limb_in_place(scratch_1, 1));\n                }\n                limbs_mul_mod_base_pow_n_minus_1(out, half_n, scratch_lo, scratch_1, scratch_2);\n                let (scratch_2, scratch_3) = scratch[m << 1..].split_at_mut(m);\n                let carry = limbs_sub_greater_to_out(scratch_2, xs_0, xs_1);\n                *scratch_2.last_mut().unwrap() = 0;\n                if carry {\n                    assert!(!limbs_slice_add_limb_in_place(scratch_2, 1));\n                }\n                let scratch_3 = &mut scratch_3[..m];\n                let (ys_0, ys_1) = ys.split_at(half_n);\n                let carry = limbs_sub_greater_to_out(scratch_3, ys_0, ys_1);\n                *scratch_3.last_mut().unwrap() = 0;\n                if carry {\n                    assert!(!limbs_slice_add_limb_in_place(scratch_3, 1));\n                }\n                let (scratch_lo, scratch_hi) = scratch.split_at_mut(m << 1);\n                    limbs_mul_mod_base_pow_n_plus_1_basecase(\n                        scratch_lo,\n                        scratch_hi,\n                        &scratch_hi[m..],\n                        half_n,\n                    );\n            }\n        }\n        // Here the Chinese Remainder Theorem recomposition begins.\n        //\n        // let xm = (scratch + xm) / 2 = (scratch + xm) * 2 ^ (Limb::WIDTH * half_n) / 2 mod (2 ^\n        // (Limb::WIDTH * half_n) - 1). Division by 2 is a bitwise rotation.\n        //\n        // Assumes scratch normalised mod (2 ^ (Limb::WIDTH * half_n) + 1).\n        //\n        // The residue class 0 is represented by [2 ^ (Limb::WIDTH * half_n) - 1]; except when both\n        // inputs are zero.\n        //\n        // scratch[half_n] == 1 implies slice_test_zero(scratch[..half_n]).\n        let mut carry = scratch[half_n];\n        let (out_lo, out_hi) = out.split_at_mut(half_n);\n        if limbs_slice_add_same_length_in_place_left(out_lo, &scratch[..half_n]) {\n            carry += 1;\n        }\n        if out_lo[0].odd() {\n            carry += 1;\n        }\n        limbs_slice_shr_in_place(out_lo, 1);\n        let out_lo_last = out_lo.last_mut().unwrap();\n        assert!(!out_lo_last.get_highest_bit());\n        match carry {\n            1 => out_lo_last.set_bit(Limb::WIDTH - 1),\n            2 => {\n                assert!(!out_lo_last.get_highest_bit());\n                assert!(!limbs_slice_add_limb_in_place(out_lo, 1));\n            }\n            _ => assert_eq!(carry, 0),\n        }\n        // Compute the highest half: ([(scratch + xm) / 2 mod (2 ^ (Limb::WIDTH * half_n) - 1)] -\n        // scratch) * 2 ^ (Limb::WIDTH * half_n)\n        if sum < n {\n            let a = sum - half_n;\n            // Note that in this case, the only way the result can equal zero mod 2 ^ (Limb::WIDTH\n            // * n) - 1 is if one of the inputs is zero, and then the output of both the recursive\n            // calls and this CRT reconstruction is zero, not 2 ^ (Limb::WIDTH * n) - 1. Which is\n            // good, since the latter representation doesn't fit in the output area.\n            let borrow = limbs_sub_same_length_to_out(out_hi, &out_lo[..a], &scratch[..a]);\n            let mut carry = scratch[half_n];\n            let scratch = &mut scratch[..n - half_n];\n            if limbs_sub_same_length_with_borrow_in_in_place_right(\n                &out[a..n - half_n],\n                &mut scratch[a..],\n                borrow,\n            ) {\n                carry += 1;\n            }\n            assert!(sum == n - 1 || slice_test_zero(&scratch[a + 1..]));\n            assert_eq!(\n                scratch[a],\n                Limb::from(limbs_sub_limb_in_place(&mut out[..sum], carry))\n            );\n        } else {\n            let mut carry = scratch[half_n];\n            if limbs_sub_same_length_to_out(out_hi, out_lo, &scratch[..half_n]) {\n                carry += 1;\n            }\n            // carry == 1 only if &scratch[..half_n + 1] is not zero, i.e. out[..half_n] is not\n            // zero. The decrement will affect _at most_ the lowest half_n limbs.\n            assert!(!limbs_sub_limb_in_place(&mut out[..half_n << 1], carry));\n        }\n    }\n}}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/poly_eval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_toom_eval_dgr3_pm2`, `mpn_toom_eval_dgr3_pm1`, `mpn_toom_eval_pm1`, and\n//      `mpn_toom_eval_pm2exp` contributed to the GNU project by Niels Möller.\n//\n//      `DO_addlsh2` and `mpn_toom_eval_pm2` contributed to the GNU project by Niels Möller and\n//      Marco Bodrato.\n//\n//      `DO_mpn_addlsh_n` and `mpn_toom_eval_pm2rexp` contributed to the GNU project by Marco\n//      Bodrato.\n//\n//      Copyright © 2009 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out, limbs_add_to_out,\n    limbs_add_to_out_aliased, limbs_slice_add_greater_in_place_left,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::natural::arithmetic::sub::limbs_sub_same_length_to_out;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::Limb;\nuse core::cmp::Ordering::*;\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::{Parity, WrappingAddAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::NotAssign;\n\n// Evaluate a degree-3 polynomial in +1 and -1, where each coefficient has width `n` limbs, except\n// the last, which has width `n_high` limbs.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_toom_eval_dgr3_pm1` in `mpn/generic/toom_eval_dgr3_pm1.c`, GMP 6.2.1,\n// where `s` is omitted from the inputs because it can be determined from `ap` and `n`.\npub(crate) fn limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(\n    v_1: &mut [Limb],\n    v_neg_1: &mut [Limb],\n    poly: &[Limb],\n    n: usize,\n    scratch: &mut [Limb],\n) -> bool {\n    assert_eq!(v_1.len(), n + 1);\n    assert_eq!(scratch.len(), n + 1);\n    split_into_chunks!(poly, n, [poly_0, poly_1, poly_2], poly_3);\n    assert!(poly_3.len() <= n);\n    v_1[n] = Limb::from(limbs_add_same_length_to_out(v_1, poly_0, poly_2));\n    scratch[n] = Limb::from(limbs_add_to_out(scratch, poly_1, poly_3));\n    let v_neg_1_neg = limbs_cmp_same_length(v_1, scratch) == Less;\n    if v_neg_1_neg {\n        limbs_sub_same_length_to_out(v_neg_1, scratch, v_1);\n    } else {\n        limbs_sub_same_length_to_out(v_neg_1, v_1, scratch);\n    }\n    limbs_slice_add_same_length_in_place_left(v_1, scratch);\n    assert!(v_1[n] <= 3);\n    assert!(v_neg_1[n] <= 1);\n    v_neg_1_neg\n}\n\n// Evaluate a degree-3 polynomial in +2 and -2, where each coefficient has width `n` limbs, except\n// the last, which has width `n_high` limbs.\n//\n// Needs n + 1 limbs of temporary storage.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_toom_eval_dgr3_pm2` from `mpn/generic/toom_eval_dg3_pm2.c`, GMP 6.2.1,\n// where `s` is omitted from the inputs because it can be determined from `ap` and `n`.\npub(crate) fn limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2(\n    v_2: &mut [Limb],\n    v_neg_2: &mut [Limb],\n    poly: &[Limb],\n    n: usize,\n    scratch: &mut [Limb],\n) -> bool {\n    split_into_chunks!(poly, n, [poly_0, poly_1, poly_2], poly_3);\n    let n_high = poly_3.len();\n    assert!(n_high <= n);\n    assert_eq!(v_2.len(), n + 1);\n    let (scratch_last, scratch_init) = scratch.split_last_mut().unwrap();\n    assert_eq!(scratch_init.len(), n);\n    // scratch <- (poly_0 + 4 * poly_2) +/- (2 * poly_1 + 8 * poly_3)\n    v_2[n] = limbs_shl_to_out(scratch_init, poly_2, 2);\n    if limbs_add_same_length_to_out(v_2, scratch_init, poly_0) {\n        v_2[n] += 1;\n    }\n    if n_high < n {\n        scratch_init[n_high] = limbs_shl_to_out(scratch_init, poly_3, 2);\n        *scratch_last = Limb::from(limbs_add_to_out_aliased(scratch_init, n_high + 1, poly_1));\n    } else {\n        *scratch_last = limbs_shl_to_out(scratch_init, poly_3, 2);\n        if limbs_slice_add_same_length_in_place_left(scratch_init, poly_1) {\n            *scratch_last += 1;\n        }\n    }\n    limbs_slice_shl_in_place(scratch, 1);\n    let v_neg_2_neg = limbs_cmp_same_length(v_2, scratch) == Less;\n    if v_neg_2_neg {\n        limbs_sub_same_length_to_out(v_neg_2, scratch, v_2);\n    } else {\n        limbs_sub_same_length_to_out(v_neg_2, v_2, scratch);\n    }\n    limbs_slice_add_same_length_in_place_left(v_2, scratch);\n    assert!(v_2[n] < 15);\n    assert!(v_neg_2[n] < 10);\n    v_neg_2_neg\n}\n\n// Evaluates a polynomial of degree 3 < `degree` < `Limb::WIDTH`, in the points +1 and -1, where\n// each coefficient has width `n` limbs, except the last, which has width `n_high` limbs.\n//\n// # Worst-case complexity\n// $T(m) = O(m)$\n//\n// $M(m) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $m$ is `n * degree`.\n//\n// This is equivalent to `mpn_toom_eval_pm1` from `mpn/generic/toom_eval_pm1.c`, GMP 6.2.1, where\n// `hn` is omitted from the inputs because it can be determined from `xp` and `n`.\npub(crate) fn limbs_mul_toom_evaluate_poly_in_1_and_neg_1(\n    v_1: &mut [Limb],\n    v_neg_1: &mut [Limb],\n    degree: usize,\n    poly: &[Limb],\n    n: usize,\n    scratch: &mut [Limb],\n) -> bool {\n    assert!(degree > 3);\n    assert_eq!(v_1.len(), n + 1);\n    assert_eq!(scratch.len(), n + 1);\n\n    // The degree `degree` is also the number of full-size coefficients, so that the last\n    // coefficient, of size `n_high`, starts at `poly[degree * n..]`.\n    let coefficients = poly.chunks(n).collect_vec();\n    assert_eq!(coefficients.len(), degree + 1);\n\n    // The degree `degree` is also the number of full-size coefficients, so that the last\n    // coefficient, of size `n_high`, starts at poly + degree * n.\n    v_1[n] = Limb::from(limbs_add_same_length_to_out(\n        v_1,\n        coefficients[0],\n        coefficients[2],\n    ));\n    let mut i = 4;\n    while i < degree {\n        assert!(!limbs_slice_add_greater_in_place_left(v_1, coefficients[i]));\n        i += 2;\n    }\n    scratch[n] = Limb::from(limbs_add_same_length_to_out(\n        scratch,\n        coefficients[1],\n        coefficients[3],\n    ));\n    let mut i = 5;\n    while i < degree {\n        assert!(!limbs_slice_add_greater_in_place_left(\n            scratch,\n            coefficients[i],\n        ));\n        i += 2;\n    }\n    assert!(!limbs_slice_add_greater_in_place_left(\n        if degree.even() { v_1 } else { scratch },\n        coefficients[degree],\n    ));\n    let v_neg_1_neg = limbs_cmp_same_length(v_1, scratch) == Less;\n    if v_neg_1_neg {\n        limbs_sub_same_length_to_out(v_neg_1, scratch, v_1);\n    } else {\n        limbs_sub_same_length_to_out(v_neg_1, v_1, scratch);\n    }\n    limbs_slice_add_same_length_in_place_left(v_1, scratch);\n    let degree = Limb::exact_from(degree);\n    assert!(v_1[n] <= degree);\n    assert!(v_neg_1[n] <= (degree >> 1) + 1);\n    v_neg_1_neg\n}\n\n// Given a `Natural` whose highest limb is `carry` and remaining limbs are `xs`, multiplies the\n// `Natural` by 4 and adds the `Natural` whose limbs are `ys`. The highest limb of the result is\n// written back to `carry` and the remaining limbs are written to `out`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `DO_addlsh2` from `mpn/generic/toom_eval_pm2.c`, GMP 6.2.1, with `d ==\n// out`, `a == xs`, and `b == ys`.\nfn shl_2_and_add_with_carry_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb], carry: &mut Limb) {\n    *carry <<= 2;\n    *carry += limbs_shl_to_out(out, xs, 2);\n    if limbs_slice_add_same_length_in_place_left(&mut out[..ys.len()], ys) {\n        *carry += 1;\n    }\n}\n\n// Given a `Natural` whose highest limb is `carry` and remaining limbs are `xs`, multiplies the\n// `Natural` by 4 and adds the `Natural` whose limbs are `ys`. The highest limb of the result is\n// written back to `carry` and the remaining limbs are written to `xs`. `xs` and `ys` must have the\n// same length.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ys.len()`.\n//\n// This is equivalent to `DO_addlsh2` from `mpn/generic/toom_eval_pm2.c`, GMP 6.2.1, with `d == b ==\n// ys` and `a == xs`.\nfn shl_2_and_add_with_carry_in_place_left(xs: &mut [Limb], ys: &[Limb], carry: &mut Limb) {\n    *carry <<= 2;\n    *carry += limbs_slice_shl_in_place(xs, 2);\n    if limbs_slice_add_same_length_in_place_left(xs, ys) {\n        *carry += 1;\n    }\n}\n\n// Evaluates a polynomial of degree 3 < `degree` < `Limb::WIDTH`, in the points +2 and -2, where\n// each coefficient has width `n` limbs, except the last, which has width `n_high` limbs.\n//\n// # Worst-case complexity\n// $T(m) = O(m)$\n//\n// $M(m) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $m$ is `n * degree`.\n//\n// This is equivalent to `mpn_toom_eval_pm2` from `mpn/generic/toom_eval_pm2.c`, GMP 6.2.1, where\n// `hn` is omitted from the inputs because it can be determined from `xp` and `n`.\npub(crate) fn limbs_mul_toom_evaluate_poly_in_2_and_neg_2(\n    v_2: &mut [Limb],\n    v_neg_2: &mut [Limb],\n    degree: usize,\n    poly: &[Limb],\n    n: usize,\n    scratch: &mut [Limb],\n) -> bool {\n    assert!(degree >= 3);\n    assert!(degree < usize::wrapping_from(Limb::WIDTH));\n    assert_eq!(v_2.len(), n + 1);\n    assert_eq!(scratch.len(), n + 1);\n    // The degree `degree` is also the number of full-size coefficients, so that the last\n    // coefficient, of size `n_high`, starts at `poly[degree * n..]`.\n    let coefficients = poly.chunks(n).collect_vec();\n    assert_eq!(coefficients.len(), degree + 1);\n    let n_high = coefficients[degree].len();\n    let (v_2_last, v_2_init) = v_2.split_last_mut().unwrap();\n    let mut carry = 0;\n    shl_2_and_add_with_carry_to_out(\n        v_2_init,\n        coefficients[degree],\n        &coefficients[degree - 2][..n_high],\n        &mut carry,\n    );\n    if n_high != n {\n        carry = Limb::from(limbs_add_limb_to_out(\n            &mut v_2_init[n_high..],\n            &coefficients[degree - 2][n_high..],\n            carry,\n        ));\n    }\n    if degree >= 4 {\n        let mut i = degree - 4;\n        loop {\n            shl_2_and_add_with_carry_in_place_left(v_2_init, coefficients[i], &mut carry);\n            if i < 2 {\n                break;\n            }\n            i -= 2;\n        }\n    }\n    *v_2_last = carry;\n    let (scratch_last, scratch_init) = scratch.split_last_mut().unwrap();\n    let mut carry = 0;\n    shl_2_and_add_with_carry_to_out(\n        scratch_init,\n        coefficients[degree - 1],\n        coefficients[degree - 3],\n        &mut carry,\n    );\n    if degree >= 5 {\n        let mut i = degree - 5;\n        loop {\n            shl_2_and_add_with_carry_in_place_left(scratch_init, coefficients[i], &mut carry);\n            if i < 2 {\n                break;\n            }\n            i -= 2;\n        }\n    }\n    *scratch_last = carry;\n    assert_eq!(\n        limbs_slice_shl_in_place(if degree.even() { scratch } else { v_2 }, 1),\n        0\n    );\n    let mut v_neg_2_neg = limbs_cmp_same_length(v_2, scratch) == Less;\n    if v_neg_2_neg {\n        limbs_sub_same_length_to_out(v_neg_2, scratch, v_2);\n    } else {\n        limbs_sub_same_length_to_out(v_neg_2, v_2, scratch);\n    }\n    if degree.odd() {\n        v_neg_2_neg.not_assign();\n    }\n    limbs_slice_add_same_length_in_place_left(v_2, scratch);\n    let mut shift = 1 << (degree + 1);\n    if shift != 0 {\n        assert!(v_2[n] < shift - 1);\n    }\n    shift <<= 1;\n    if shift != 0 {\n        assert!(v_neg_2[n] < shift / 3);\n    }\n    v_neg_2_neg\n}\n\n// Evaluates a polynomial of degree `degree` > 2, in the points 2 ^ `shift` and -2 ^ `shift`, where\n// each coefficient has width `n` limbs, except the last, which has width `n_high` limbs.\n//\n// # Worst-case complexity\n// $T(m) = O(m)$\n//\n// $M(m) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $m$ is `n * degree`.\n//\n// This is equivalent to `mpn_toom_eval_pm2exp` from `mpn/generic/toom_eval_pm2exp.c`, GMP 6.2.1,\n// where `hn` is omitted from the inputs because it can be determined from `xp` and `n`.\npub(crate) fn limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(\n    v_2_pow: &mut [Limb],\n    v_neg_2_pow: &mut [Limb],\n    degree: usize,\n    poly: &[Limb],\n    n: usize,\n    shift: u64,\n    scratch: &mut [Limb],\n) -> bool {\n    assert!(degree >= 3);\n    let degree_u64 = u64::exact_from(degree);\n    assert!(shift * degree_u64 < Limb::WIDTH);\n    assert_eq!(v_2_pow.len(), n + 1);\n    assert_eq!(scratch.len(), n + 1);\n    let coefficients = poly.chunks(n).collect_vec();\n    assert_eq!(coefficients.len(), degree + 1);\n    let n_high = coefficients[degree].len();\n    let (scratch_last, scratch_init) = scratch.split_last_mut().unwrap();\n    let (v_2_pow_last, v_2_pow_init) = v_2_pow.split_last_mut().unwrap();\n    // The degree `degree` is also the number of full-size coefficients, so that the last\n    // coefficient, of size `n_high`, starts at `poly + degree * n`.\n    *v_2_pow_last = limbs_shl_to_out(scratch_init, coefficients[2], shift << 1);\n    if limbs_add_same_length_to_out(v_2_pow_init, coefficients[0], scratch_init) {\n        v_2_pow_last.wrapping_add_assign(1);\n    }\n    let mut i = 4;\n    let mut local_shift = shift << 2;\n    while i < degree {\n        v_2_pow_last.wrapping_add_assign(limbs_shl_to_out(\n            scratch_init,\n            coefficients[i],\n            local_shift,\n        ));\n        if limbs_slice_add_same_length_in_place_left(v_2_pow_init, scratch_init) {\n            v_2_pow_last.wrapping_add_assign(1);\n        }\n        i += 2;\n        local_shift += shift << 1;\n    }\n\n    *scratch_last = limbs_shl_to_out(scratch_init, coefficients[1], shift);\n    let mut i = 3;\n    let mut local_shift = shift * 3;\n    while i < degree {\n        *scratch_last += limbs_shl_to_out(v_neg_2_pow, coefficients[i], local_shift);\n        if limbs_slice_add_same_length_in_place_left(scratch_init, &v_neg_2_pow[..n]) {\n            scratch_last.wrapping_add_assign(1);\n        }\n        i += 2;\n        local_shift += shift << 1;\n    }\n\n    v_neg_2_pow[n_high] = limbs_shl_to_out(v_neg_2_pow, coefficients[degree], degree_u64 * shift);\n    limbs_slice_add_greater_in_place_left(\n        if degree.even() { v_2_pow } else { scratch },\n        &v_neg_2_pow[..=n_high],\n    );\n    let v_neg_2_pow_neg = limbs_cmp_same_length(v_2_pow, scratch) == Less;\n    if v_neg_2_pow_neg {\n        limbs_sub_same_length_to_out(v_neg_2_pow, scratch, v_2_pow);\n    } else {\n        limbs_sub_same_length_to_out(v_neg_2_pow, v_2_pow, scratch);\n    }\n    limbs_slice_add_same_length_in_place_left(v_2_pow, scratch);\n    v_neg_2_pow_neg\n}\n\n// Given a `Natural` whose limbs are `ys`, multiplies the `Natural` by `2 ^ shift` and adds the\n// `Natural` whose limbs are the lowest `ys.len()` limbs of `xs`, writing the lowest `ys.len()`\n// limbs of the result to those limbs, and returning the highest limb as a carry.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ys.len()`.\n//\n// This is equivalent to `DO_mpn_addlsh_n` from `mpn/generic/toom_eval_pm2rexp.c`, GMP 6.2.1.\npub(crate) fn limbs_shl_and_add_same_length_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    shift: u64,\n    scratch: &mut [Limb],\n) -> Limb {\n    let n = ys.len();\n    let scratch = &mut scratch[..n];\n    let mut carry = limbs_shl_to_out(scratch, ys, shift);\n    if limbs_slice_add_same_length_in_place_left(&mut xs[..n], scratch) {\n        carry.wrapping_add_assign(1);\n    }\n    carry\n}\n\n// Evaluates a polynomial of degree `degree` > 2, in the points 2 ^ -`shift` and -2 ^ -`shift`,\n// where each coefficient has width `n` limbs, except the last, which has width `n_high` limbs.\n//\n// # Worst-case complexity\n// $T(m) = O(m)$\n//\n// $M(m) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $m$ is `n * degree`.\n//\n// This is equivalent to `mpn_toom_eval_pm2rexp` from `mpn/generic/toom_eval_pm2rexp.c`, GMP 6.2.1,\n// where `t` is omitted from the inputs because it can be determined from `ap` and `n`.\npub(crate) fn limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n    v_2_pow_neg: &mut [Limb],\n    v_neg_2_pow_neg: &mut [Limb],\n    degree: usize,\n    poly: &[Limb],\n    n: usize,\n    shift: u64,\n    scratch: &mut [Limb],\n) -> bool {\n    assert_ne!(shift, 0); // or `limbs_mul_toom_evaluate_poly_in_1_and_neg_1` should be used\n    assert!(degree > 1);\n    let degree_u64 = u64::exact_from(degree);\n    assert_eq!(v_2_pow_neg.len(), n + 1);\n    assert_eq!(scratch.len(), n + 1);\n    let coefficients = poly.chunks(n).collect_vec();\n    assert_eq!(coefficients.len(), degree + 1);\n    v_2_pow_neg[n] = limbs_shl_to_out(v_2_pow_neg, coefficients[0], shift * degree_u64);\n    scratch[n] = limbs_shl_to_out(scratch, coefficients[1], shift * (degree_u64 - 1));\n    if degree.even() {\n        assert!(!limbs_slice_add_greater_in_place_left(\n            v_2_pow_neg,\n            coefficients[degree],\n        ));\n    } else {\n        assert!(!limbs_slice_add_greater_in_place_left(\n            scratch,\n            coefficients[degree],\n        ));\n        let carry = limbs_shl_and_add_same_length_in_place_left(\n            v_2_pow_neg,\n            coefficients[degree - 1],\n            shift,\n            v_neg_2_pow_neg,\n        );\n        v_2_pow_neg[n].wrapping_add_assign(carry);\n    }\n    let mut i = 2;\n    let mut local_shift = shift * (degree_u64 - 2);\n    while i < degree - 1 {\n        let carry = limbs_shl_and_add_same_length_in_place_left(\n            v_2_pow_neg,\n            coefficients[i],\n            local_shift,\n            v_neg_2_pow_neg,\n        );\n        v_2_pow_neg[n].wrapping_add_assign(carry);\n        i += 1;\n        local_shift -= shift;\n        let carry = limbs_shl_and_add_same_length_in_place_left(\n            scratch,\n            coefficients[i],\n            local_shift,\n            v_neg_2_pow_neg,\n        );\n        scratch[n].wrapping_add_assign(carry);\n        i += 1;\n        local_shift -= shift;\n    }\n    let v_2_pow_neg_neg = limbs_cmp_same_length(v_2_pow_neg, scratch) == Less;\n    if v_2_pow_neg_neg {\n        limbs_sub_same_length_to_out(v_neg_2_pow_neg, scratch, v_2_pow_neg);\n    } else {\n        limbs_sub_same_length_to_out(v_neg_2_pow_neg, v_2_pow_neg, scratch);\n    }\n    assert!(!limbs_slice_add_same_length_in_place_left(\n        v_2_pow_neg,\n        scratch,\n    ));\n    v_2_pow_neg_neg\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/poly_interpolate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `DO_mpn_sublsh_n`, `DO_mpn_subrsh`, `mpn_toom_interpolate_6pts`,\n//      `mpn_toom_interpolate_8pts`, `mpn_toom_interpolate_12pts`, and `mpn_toom_interpolate_16pts`\n//      contributed to the GNU project by Marco Bodrato.\n//\n//      `mpn_toom_interpolate_5pts` and `mpn_toom_interpolate_7pts` contributed to the GNU project\n//      by Robert Harley, with improvements by Paul Zimmermann and Marco Bodrato.\n//\n//      Copyright © 2000-2003, 2005-2007, 2009, 2010, 2011, 2012, 2015, 2020 Free Software\n//      Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out, limbs_slice_add_greater_in_place_left,\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::div::limbs_div_divisor_of_limb_max_with_carry_in_place;\nuse crate::natural::arithmetic::div_exact::{\n    limbs_div_exact_3_in_place, limbs_div_exact_limb_in_place,\n};\nuse crate::natural::arithmetic::mul::poly_eval::limbs_shl_and_add_same_length_in_place_left;\nuse crate::natural::arithmetic::mul::toom::BIT_CORRECTION;\nuse crate::natural::arithmetic::shl::limbs_shl_to_out;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n    limbs_sub_same_length_in_place_right, limbs_sub_same_length_in_place_with_overlap,\n    limbs_sub_same_length_to_out,\n};\nuse crate::natural::arithmetic::sub_mul::limbs_sub_mul_limb_same_length_in_place_left;\nuse crate::platform::{\n    AORSMUL_FASTER_2AORSLSH, AORSMUL_FASTER_3AORSLSH, AORSMUL_FASTER_AORS_2AORSLSH,\n    AORSMUL_FASTER_AORS_AORSLSH, Limb,\n};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    DivisibleByPowerOf2, Parity, WrappingAddAssign, WrappingSubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::slice_test_zero;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `k`.\n//\n// This is equivalent to `mpn_toom_interpolate_5pts` in `mpn/generic/toom_interpolate_5pts.c`, GMP\n// 6.2.1.\npub(crate) fn limbs_mul_toom_interpolate_5_points(\n    c: &mut [Limb],\n    v_2: &mut [Limb],\n    v_neg_1: &mut [Limb],\n    k: usize,\n    two_r: usize,\n    v_neg_1_neg: bool,\n    mut v_inf_0: Limb,\n) {\n    let two_k = k << 1;\n    let two_k_plus_1 = two_k + 1;\n    let four_k_plus_1 = two_k_plus_1 + two_k;\n    assert_eq!(v_neg_1.len(), two_k_plus_1);\n    assert!(two_r <= two_k);\n    let v_1 = &c[two_k..four_k_plus_1]; // v_1 length: 2 * k + 1\n    let v_2 = &mut v_2[..two_k_plus_1];\n    // ```\n    // (1) v_2 <- v_2 - v_neg_1 < v_2 + |v_neg_1|,            (16 8 4 2 1) - (1 -1 1 -1  1) =\n    // thus 0 <= v_2 < 50 * B ^ (2 * k) < 2 ^ 6 * B ^ (2 * k) (15 9 3  3  0)\n    // ```\n    if v_neg_1_neg {\n        assert!(!limbs_slice_add_same_length_in_place_left(v_2, v_neg_1));\n    } else {\n        assert!(!limbs_sub_same_length_in_place_left(v_2, v_neg_1));\n    }\n    // ```\n    // {c,2k} {c + 2k,2k + 1} {c + 4k + 1,2r - 1} {t,2k + 1} {t + 2k + 1,2k + 1} {t + 4k + 2,2r}\n    //   v0        v_1             hi(v_inf)      |v_neg_1|     v_2-v_neg_1          EMPTY\n    // v_2 <- v_2 / 3\n    // (5 3 1 1 0)\n    // {c,2k} {c + 2k,2k + 1} {c + 4k + 1,2r - 1} {t,2k + 1} {t + 2k + 1,2k + 1} {t + 4k + 2,2r}\n    //   v0       v_1             hi(v_inf)        |v_neg_1|    (v_2-v_neg_1)/3       EMPTY\n    //\n    // (2) v_neg_1 <- tm1 := (v_1 - v_neg_1) / 2  [(1 1 1 1 1) - (1 -1 1 -1 1)] / 2 =\n    // tm1 >= 0                                    (0  1 0  1 0)\n    // ```\n    // No carry comes out from {v_1, two_k_plus_1} +/- {v_neg_1, two_k_plus_1}, and the division by\n    // two is exact. If v_neg_1_neg the sign of v_neg_1 is negative\n    limbs_div_exact_3_in_place(v_2);\n    if v_neg_1_neg {\n        assert!(!limbs_slice_add_same_length_in_place_left(v_neg_1, v_1));\n    } else {\n        assert!(!limbs_sub_same_length_in_place_right(v_1, v_neg_1));\n    }\n    assert_eq!(limbs_slice_shr_in_place(v_neg_1, 1), 0);\n    // ```\n    // {c,2k} {c + 2k,2k + 1} {c + 4k + 1,2r - 1} {t,2k + 1} {t + 2k + 1,2k + 1} {t + 4k + 2,2r}\n    //   v0       v_1             hi(v_inf)          tm1       (v_2-v_neg_1)/3        EMPTY\n    //\n    // (3) v_1 <- t1 := v_1 - v0  (1 1 1 1 1) - (0 0 0 0 1) = (1 1 1 1 0)\n    // t1 >= 0\n    // ```\n    let (c_lo, v_1) = c.split_at_mut(two_k);\n    if limbs_sub_same_length_in_place_left(&mut v_1[..two_k], c_lo) {\n        v_1[two_k].wrapping_sub_assign(1);\n    }\n    let v_1 = &mut v_1[..two_k_plus_1];\n    // ```\n    // {c,2k} {c + 2k,2k + 1} {c + 4k + 1,2r - 1} {t,2k + 1} {t + 2k + 1,2k + 1} {t + 4k + 2,2r}\n    //   v0       v_1-v0           hi(v_inf)          tm1      (v_2-v_neg_1)/3        EMPTY\n    //\n    // (4) v_2 <- t2 := ((v_2 - v_neg_1) / 3 - t1) / 2 = (v_2 - v_neg_1 - 3 * t1) / 6\n    // t2 >= 0                  [(5 3 1 1 0) - (1 1 1 1 0)]/2 = (2 1 0 0 0)\n    // ```\n    assert!(!limbs_sub_same_length_in_place_left(v_2, v_1));\n    assert_eq!(limbs_slice_shr_in_place(v_2, 1), 0);\n    // ```\n    // {c,2k} {c + 2k,2k + 1} {c + 4k + 1,2r - 1} {t,2k + 1} {t + 2k + 1,2k + 1} {t + 4k + 2,2r}\n    //   v0      v_1 - v0        hi(v_inf)          tm1    (v_2 - v_neg_1 - 3t1) / 6    EMPTY\n    //\n    // (5) v_1 <- t1 - tm1           (1 1 1 1 0) - (0 1 0 1 0) = (1 0 1 0 0)\n    // result is v_1 >= 0\n    // ```\n    assert!(!limbs_sub_same_length_in_place_left(v_1, v_neg_1));\n    // We do not need to read the value in v_neg_1, so we add it in {c + k, ..}\n    let (c_lo, c_hi) = c.split_at_mut(3 * k + 1);\n    if limbs_slice_add_same_length_in_place_left(&mut c_lo[k..], v_neg_1) {\n        // ```\n        // 2 * n - (3 * k + 1) = 2 * r + k - 1\n        // ```\n        //\n        // Memory allocated for v_neg_1 is now free, it can be recycled\n        assert!(!limbs_slice_add_limb_in_place(\n            &mut c_hi[..two_r + k - 1],\n            1,\n        ));\n    }\n    let v_inf = &mut c_hi[k - 1..two_r + k - 1];\n    // ```\n    // (6) v_2 <- v_2 - 2 * v_inf, (2 1 0 0 0) - 2 * (1 0 0 0 0) = (0 1 0 0 0)\n    // ```\n    //\n    // result is v_2 >= 0\n    let saved = v_inf[0]; // Remember v1's highest byte (will be overwritten).\n    v_inf[0] = v_inf_0; // Set the right value for v_inf_0\n    // Overwrite unused v_neg_1\n    let mut carry = limbs_shl_to_out(v_neg_1, &v_inf[..two_r], 1);\n    if limbs_sub_same_length_in_place_left(&mut v_2[..two_r], &v_neg_1[..two_r]) {\n        carry += 1;\n    }\n    assert!(!limbs_sub_limb_in_place(&mut v_2[two_r..], carry));\n    // Current matrix is\n    // ```\n    // [1 0 0 0 0; v_inf\n    //  0 1 0 0 0; v_2\n    //  1 0 1 0 0; v1\n    //  0 1 0 1 0; v_neg_1\n    //  0 0 0 0 1] v0\n    // ```\n    // Some values already are in-place (we added v_neg_1 in the correct position)\n    // ```\n    // | v_inf|  v1 |  v0 |\n    // | v_neg_1 |\n    // ```\n    // One still is in a separated area\n    // ```\n    // | +v_2 |\n    // ```\n    // We have to compute v1-=v_inf; v_neg_1 -= v_2,\n    // ```\n    // | -v_inf|\n    // | -v_2 |\n    // ```\n    // Carefully reordering operations we can avoid to compute twice the sum of the high half of v_2\n    // plus the low half of v_inf.\n    //\n    // Add the high half of t2 in {v_inf}\n    if two_r > k + 1 {\n        // This is the expected flow\n        let (c_lo, c_hi) = c[k << 2..].split_at_mut(k + 1);\n        if limbs_slice_add_same_length_in_place_left(c_lo, &v_2[k..]) {\n            // 2n-(5k+1) = 2r-k-1\n            assert!(!limbs_slice_add_limb_in_place(\n                &mut c_hi[..two_r - k - 1],\n                1,\n            ));\n        }\n    } else {\n        // - triggered only by very unbalanced cases like (k+k+(k-2))x(k+k+1), should be handled by\n        //   toom32\n        // - two_r < k + 1 so k + two_r < two_k, the size of v_2\n        assert!(!limbs_slice_add_same_length_in_place_left(\n            &mut c[k << 2..(k << 2) + two_r],\n            &v_2[k..k + two_r],\n        ));\n    }\n    split_into_chunks_mut!(c, k << 1, [_unused, v_1], v_inf);\n    // - (7) v_1 <- v_1 - v_inf,       (1 0 1 0 0) - (1 0 0 0 0) = (0 0 1 0 0)\n    // - result is >= 0\n    // - Side effect: we also subtracted (high half) v_neg_1 -= v_2\n    // - v_inf is at most two_r long.\n    let carry = limbs_sub_same_length_in_place_left(&mut v_1[..two_r], &v_inf[..two_r]);\n    v_inf_0 = v_inf[0]; // Save again the right value for v_inf_0\n    v_inf[0] = saved;\n    split_into_chunks_mut!(c, k, [_unused, c1], v1);\n    let v1 = &mut v1[..two_k_plus_1];\n    if carry {\n        assert!(!limbs_sub_limb_in_place(&mut v1[two_r..], 1)); // Treat the last bytes.\n    }\n    // - (8) v_neg_1 <- v_neg_1 - v_2 (0 1 0 1 0) - (0 1 0 0 0) = (0 0 0 1 0)\n    // - Operate only on the low half.\n    if limbs_sub_same_length_in_place_left(c1, &v_2[..k]) {\n        assert!(!limbs_sub_limb_in_place(v1, 1));\n    }\n    let (c3, v_inf) = c[3 * k..].split_at_mut(k);\n    // - Beginning the final phase\n    // - Most of the recomposition was done\n    // - add t2 in {c + 3 * k, ...}, but only the low half\n    if limbs_slice_add_same_length_in_place_left(c3, &v_2[..k]) {\n        v_inf[0].wrapping_add_assign(1);\n        assert!(v_inf[0] >= 1); // No carry\n    }\n    // Add v_inf_0, propagate carry.\n    assert!(!limbs_slice_add_limb_in_place(&mut v_inf[..two_r], v_inf_0));\n}\n\n// Interpolation for Toom-3.5, using the evaluation points infinity, 1, -1, 2, -2. More precisely,\n// we want to compute f(2 ^ (`Limb::WIDTH` * n)) for a polynomial f of degree 5, given the six\n// values\n//\n// ```\n// w5 = f(0),\n// w4 = f(-1),\n// w3 = f(1)\n// w2 = f(-2),\n// w1 = f(2),\n// w0 = limit at infinity of f(x) / x^5,\n// ```\n//\n// The result is stored in {out, 5 * n + n_high}. At entry, w5 is stored at {out, 2 * n}, w3 is\n// stored at {out + 2 * n, 2 * n + 1}, and w0 is stored at {out + 5 * n, n_high}. The other values\n// are 2 * n + 1 limbs each (with most significant limbs small). f(-1) and f(-2) may be negative;\n// signs are passed in. All intermediate results are positive. Inputs are destroyed.\n//\n// Interpolation sequence was taken from the paper: \"Integer and Polynomial Multiplication: Towards\n// Optimal Toom-Cook Matrices\". Some slight variations were introduced: adaptation to \"gmp\n// instruction set\", and a final saving of an operation by interlacing interpolation and\n// recomposition phases.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_toom_interpolate_6pts` from `mpn/generic/toom_interpolate_6pts.c`, GMP\n// 6.2.1, but the argument `w0n == n_high` is moved to immediately after `n`.\npub(crate) fn limbs_mul_toom_interpolate_6_points(\n    out: &mut [Limb],\n    n: usize,\n    n_high: usize,\n    w4_neg: bool,\n    w4: &mut [Limb],\n    w2_neg: bool,\n    w2: &mut [Limb],\n    w1: &mut [Limb],\n) {\n    assert_ne!(n, 0);\n    let m = 2 * n + 1;\n    assert_ne!(n_high, 0);\n    assert!(n_high < m);\n    assert_eq!(w1.len(), m);\n    assert_eq!(w2.len(), m);\n    assert_eq!(w4.len(), m);\n    // w5 length: 2 * n\n    //\n    // Interpolate with sequence:\n    // - w2 = (w1 - w2) >> 2\n    // - w1 = (w1 - w5) >> 1\n    // - w1 = (w1 - w2) >> 1\n    // - w4 = (w3 - w4) >> 1\n    // - w2 = (w2 - w4) / 3\n    // - w3 =  w3 - w4 - w5\n    // - w1 = (w1 - w3) / 3\n    //\n    // Last steps are mixed with recomposition:\n    // - w2 = w2 - w0 << 2\n    // - w4 = w4 - w2\n    // - w3 = w3 - w1\n    // - w2 = w2 - w0\n    //\n    // w2 = (w1 - w2) >> 2\n    let (w5, w3) = out[..=n << 2].split_at_mut(n << 1);\n    if w2_neg {\n        limbs_slice_add_same_length_in_place_left(w2, w1);\n    } else {\n        limbs_sub_same_length_in_place_right(w1, w2);\n    }\n    limbs_slice_shr_in_place(w2, 2);\n    // w1 = (w1 - w5) >> 1\n    let (w1_last, w1_init) = w1.split_last_mut().unwrap();\n    if limbs_sub_same_length_in_place_left(w1_init, w5) {\n        w1_last.wrapping_sub_assign(1);\n    }\n    limbs_slice_shr_in_place(w1, 1);\n    // w1 = (w1 - w2) >> 1\n    limbs_sub_same_length_in_place_left(w1, w2);\n    limbs_slice_shr_in_place(w1, 1);\n    // w4 = (w3 - w4) >> 1\n    if w4_neg {\n        limbs_slice_add_same_length_in_place_left(w4, w3);\n    } else {\n        limbs_sub_same_length_in_place_right(w3, w4);\n    }\n    limbs_slice_shr_in_place(w4, 1);\n    // w2 = (w2 - w4) / 3\n    limbs_sub_same_length_in_place_left(w2, w4);\n    limbs_div_exact_3_in_place(w2);\n    // w3 = w3 - w4 - w5\n    limbs_sub_same_length_in_place_left(w3, w4);\n    let (w3_last, w3_init) = w3.split_last_mut().unwrap();\n    if limbs_sub_same_length_in_place_left(w3_init, w5) {\n        w3_last.wrapping_sub_assign(1);\n    }\n    // w1 = (w1 - w3) / 3\n    limbs_sub_same_length_in_place_left(w1, w3);\n    limbs_div_exact_3_in_place(w1);\n    // ```\n    // [1 0 0 0 0 0;\n    //  0 1 0 0 0 0;\n    //  1 0 1 0 0 0;\n    //  0 1 0 1 0 0;\n    //  1 0 1 0 1 0;\n    //  0 0 0 0 0 1]\n    // ```\n    //\n    // out[] prior to operations:\n    // ```\n    // |_H w0__|_L w0__|______||_H w3__|_L w3__|_H w5__|_L w5__|\n    // ```\n    //\n    // summation scheme for remaining operations:\n    // ```\n    // |______________5|n_____4|n_____3|n_____2|n______|n______| out\n    // |_H w0__|_L w0__|______||_H w3__|_L w3__|_H w5__|_L w5__|\n    //                || H w4  | L w4  |\n    //        || H w2  | L w2  |\n    //    || H w1  | L w1  |\n    //            ||-H w1  |-L w1  |\n    //         |-H w0  |-L w0 ||-H w2  |-L w2  |\n    // ```\n    let out = &mut out[n..];\n    let (out_lo, out_hi) = out.split_at_mut(m);\n    if limbs_slice_add_same_length_in_place_left(out_lo, w4) {\n        assert!(!limbs_slice_add_limb_in_place(&mut out_hi[..n], 1));\n    }\n    // ```\n    // w2 -= w0 << 2\n    // ```\n    //\n    // {w4, 2 * n + 1} is now free and can be overwritten.\n    let out_hi = &out[n << 2..];\n    let mut carry = limbs_shl_to_out(w4, &out_hi[..n_high], 2);\n    let (w2_lo, w2_hi) = w2.split_at_mut(n_high);\n    if limbs_sub_same_length_in_place_left(w2_lo, &w4[..n_high]) {\n        carry += 1;\n    }\n    assert!(!limbs_sub_limb_in_place(w2_hi, carry));\n    // w4L = w4L - w2L\n    let (w2_lo, w2_hi) = w2.split_at(n);\n    let (out_lo, out) = out.split_at_mut(n);\n    if limbs_sub_same_length_in_place_left(out_lo, w2_lo) {\n        assert!(!limbs_sub_limb_in_place(&mut out[..m], 1));\n    }\n    let (out_lo, out_hi) = out.split_at_mut(n << 1);\n    let carry = Limb::from(limbs_slice_add_same_length_in_place_left(\n        &mut out_lo[n..],\n        w2_lo,\n    ));\n    // w3H = w3H + w2L\n    let carry_1 = out_hi[0] + carry;\n    // w1L + w2H\n    let (w2_hi_last, w2_hi_init) = w2_hi.split_last().unwrap();\n    let mut carry = *w2_hi_last;\n    let (w1_lo, w1_hi) = w1.split_at_mut(n);\n    if limbs_add_same_length_to_out(out_hi, w1_lo, w2_hi_init) {\n        carry += 1;\n    }\n    assert!(!limbs_slice_add_limb_in_place(w1_hi, carry));\n    // w0 = w0 + w1H\n    let mut carry_2 = 0;\n    let (w1_last, w1_init) = w1.split_last().unwrap();\n    let w1_init = &w1_init[n..];\n    let out_hi = &mut out[3 * n..];\n    if n_high > n {\n        carry_2 = *w1_last;\n        if limbs_slice_add_same_length_in_place_left(&mut out_hi[..n], w1_init) {\n            carry_2.wrapping_add_assign(1);\n        }\n    } else if limbs_slice_add_same_length_in_place_left(&mut out_hi[..n_high], &w1_init[..n_high]) {\n        carry_2 = 1;\n    }\n    // summation scheme for the next operation:\n    // ```\n    // |...____5|n_____4|n_____3|n_____2|n______|n______| out\n    // |...w0___|_w1_w2_|_H w3__|_L w3__|_H w5__|_L w5__|\n    //         ...-w0___|-w1_w2 |\n    // ```\n    //\n    // if (LIKELY(n_high > n)) the two operands below DO overlap!\n    let out = &mut out[..3 * n + n_high];\n    let carry = limbs_sub_same_length_in_place_with_overlap(out, n << 1);\n    let out_high = out.last_mut().unwrap();\n    let embankment = out_high.wrapping_sub(1);\n    *out_high = 1;\n    let out = &mut out[n..];\n    if n_high > n {\n        if carry_1 > carry_2 {\n            assert!(!limbs_slice_add_limb_in_place(\n                &mut out[n..],\n                carry_1 - carry_2,\n            ));\n        } else {\n            assert!(!limbs_sub_limb_in_place(&mut out[n..], carry_2 - carry_1));\n        }\n        if carry {\n            assert!(!limbs_sub_limb_in_place(&mut out[n_high..], 1));\n        }\n        assert!(!limbs_slice_add_limb_in_place(&mut out[3 * n..], carry_2));\n    } else {\n        assert!(!limbs_slice_add_limb_in_place(&mut out[n..], carry_1));\n        if carry {\n            carry_2.wrapping_add_assign(1);\n        }\n        assert!(!limbs_sub_limb_in_place(&mut out[n_high..], carry_2));\n    }\n    out.last_mut().unwrap().wrapping_add_assign(embankment);\n}\n\nconst WANT_ASSERT: bool = true;\n\n// Interpolation for toom4, using the evaluation points 0, infinity, 1, -1, 2, -2, 1 / 2. More\n// precisely, we want to compute f(2 ^ (Limb::WIDTH * n)) for a polynomial f of degree 6, given the\n// seven values\n// - w0 = f(0),\n// - w1 = f(-2),\n// - w2 = f(1),\n// - w3 = f(-1),\n// - w4 = f(2)\n// - w5 = 64 * f(1/2)\n// - w6 = limit at infinity of f(x) / x ^ 6,\n//\n// The result is 6 * n + n_high limbs. At entry, w0 is stored at {out, 2 * n}, w2 is stored at {out\n// + 2 * n, 2 * n + 1}, and w6 is stored at {out + 6 * n, n_high}. The other values are 2 * n + 1\n// limbs each (with most significant limbs small). f(-1) and f(-1/2) may be negative, signs\n// determined by the flag bits. Inputs are destroyed.\n//\n// Needs 2 * n + 1 limbs of temporary storage.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_toom_interpolate_7pts` from `mpn/generic/toom_interpolate_7pts.c`, GMP\n// 6.2.1, but the argument `w6n == n_high` is moved to immediately after `n`.\npub(crate) fn limbs_mul_toom_interpolate_7_points(\n    out: &mut [Limb],\n    n: usize,\n    n_high: usize,\n    w1_neg: bool,\n    w1: &mut [Limb],\n    w3_neg: bool,\n    w3: &mut [Limb],\n    w4: &mut [Limb],\n    w5: &mut [Limb],\n    scratch: &mut [Limb],\n) {\n    let m = 2 * n + 1;\n    assert_ne!(n_high, 0);\n    assert!(n_high < m);\n    assert_eq!(w1.len(), m);\n    assert_eq!(w3.len(), m);\n    assert_eq!(w4.len(), m);\n    assert_eq!(w5.len(), m);\n    let (w0, remainder) = out.split_at_mut(n << 1);\n    let (w2, w6) = remainder.split_at_mut(n << 2);\n    let w2 = &mut w2[..m];\n    let w6 = &mut w6[..n_high];\n    // Using formulas similar to Marco Bodrato's\n    //\n    // - w5 =  w5 + w4\n    // - w1 = (w4 - w1) / 2\n    // - w4 =  w4 - w0\n    // - w4 = (w4 - w1) / 4 - w6 * 16\n    // - w3 = (w2 - w3) / 2\n    // - w2 =  w2 - w3\n    //\n    // - w5 =  w5 - w2 * 65 May be negative.\n    // - w2 =  w2 - w6 - w0\n    // - w5 = (w5 + w2 * 45) / 2 Now >= 0 again.\n    // - w4 = (w4 - w2) / 3\n    // - w2 =  w2 - w4\n    //\n    // - w1 =  w5 - w1 May be negative.\n    // - w5 = (w5 - w3 * 8) / 9\n    // - w3 =  w3 - w5\n    // - w1 = (w1 / 15 + w5) / 2 Now >= 0 again.\n    // - w5 =  w5 - w1\n    //\n    // where w0 = f(0), w1 = f(-2), w2 = f(1), w3 = f(-1), w4 = f(2), w5 = f(1/2), w6 = f(infinity).\n    //\n    // Note that most intermediate results are positive; the ones that may be negative are\n    // represented in two's complement. We must never shift right a value that may be negative,\n    // since that would invalidate the sign bit. On the other hand, divexact by odd numbers works\n    // fine with two's complement.\n    limbs_slice_add_same_length_in_place_left(w5, w4);\n    if w1_neg {\n        limbs_slice_add_same_length_in_place_left(w1, w4);\n    } else {\n        limbs_sub_same_length_in_place_right(w4, w1);\n    }\n    assert!(w1[0].even());\n    limbs_slice_shr_in_place(w1, 1);\n    limbs_sub_greater_in_place_left(w4, w0);\n    limbs_sub_same_length_in_place_left(w4, w1);\n    assert!(w4[0].divisible_by_power_of_2(2));\n    limbs_slice_shr_in_place(w4, 2); // w4 >= 0\n    scratch[n_high] = limbs_shl_to_out(scratch, w6, 4);\n    limbs_sub_greater_in_place_left(w4, &scratch[..=n_high]);\n    if w3_neg {\n        limbs_slice_add_same_length_in_place_left(w3, w2);\n    } else {\n        limbs_sub_same_length_in_place_right(w2, w3);\n    }\n    assert!(w3[0].even());\n    limbs_slice_shr_in_place(w3, 1);\n    limbs_sub_same_length_in_place_left(w2, w3);\n    limbs_sub_mul_limb_same_length_in_place_left(w5, w2, 65);\n    limbs_sub_greater_in_place_left(w2, w6);\n    limbs_sub_greater_in_place_left(w2, w0);\n    limbs_slice_add_mul_limb_same_length_in_place_left(w5, w2, 45);\n    assert!(w5[0].even());\n    limbs_slice_shr_in_place(w5, 1);\n    limbs_sub_same_length_in_place_left(w4, w2);\n    limbs_div_exact_3_in_place(w4);\n    limbs_sub_same_length_in_place_left(w2, w4);\n    limbs_sub_same_length_in_place_right(w5, w1);\n    limbs_shl_to_out(scratch, w3, 3);\n    limbs_sub_same_length_in_place_left(w5, &scratch[..m]);\n    limbs_div_exact_limb_in_place(w5, 9);\n    limbs_sub_same_length_in_place_left(w3, w5);\n    limbs_div_exact_limb_in_place(w1, 15);\n    limbs_slice_add_same_length_in_place_left(w1, w5);\n    assert!(w1[0].even());\n    limbs_slice_shr_in_place(w1, 1); // w1 >= 0 now\n    limbs_sub_same_length_in_place_left(w5, w1);\n    // These bounds are valid for the 4x4 polynomial product of toom44, and they are conservative\n    // for toom53 and toom62.\n    let two_n = n << 1;\n    assert!(w1[two_n] < 2);\n    assert!(w2[two_n] < 3);\n    assert!(w3[two_n] < 4);\n    assert!(w4[two_n] < 3);\n    assert!(w5[two_n] < 2);\n    // Addition chain. Note carries and the 2n'th limbs that need to be added in.\n    //\n    // Special care is needed for w2[2 * n] and the corresponding carry, since the \"simple\" way of\n    // adding it all together would overwrite the limb at wp[2 * n] and out[4 * n] (same location)\n    // with the sum of the high half of w3 and the low half of w4.\n    // ```\n    //\n    //         7    6    5    4    3    2    1    0\n    //    |    |    |    |    |    |    |    |    |\n    //                  ||w3 (2n+1)|\n    //             ||w4 (2n+1)|\n    //        ||w5 (2n+1)|        ||w1 (2n+1)|\n    //  +     |w6(n_high)|        ||w2 (2n+1)| w0 (2n) |  (share storage with r)\n    //  -----------------------------------------------\n    //  r |    |    |    |    |    |    |    |    |\n    //        c7   c6   c5   c4   c3                 Carries to propagate\n    // ```\n    let (out_lo, out_hi) = out[n..].split_at_mut(m);\n    if limbs_slice_add_same_length_in_place_left(out_lo, w1) {\n        assert!(!limbs_slice_add_limb_in_place(&mut out_hi[..n], 1));\n    }\n    split_into_chunks_mut!(&mut out[3 * n..], n, [out_3, out_4, out_5], remainder);\n    let mut addend = out_4[0];\n    let (w3_lo, w3_hi) = w3.split_at_mut(n);\n    if limbs_slice_add_same_length_in_place_left(out_3, w3_lo) {\n        addend.wrapping_add_assign(1);\n    }\n    assert!(!limbs_slice_add_limb_in_place(w3_hi, addend));\n    let (w3_hi_last, w3_hi_init) = w3_hi.split_last_mut().unwrap();\n    let mut addend = *w3_hi_last;\n    let (w4_lo, w4_hi) = w4.split_at_mut(n);\n    if limbs_add_same_length_to_out(out_4, w3_hi_init, w4_lo) {\n        addend += 1;\n    }\n    assert!(!limbs_slice_add_limb_in_place(w4_hi, addend));\n    let (w4_last, w4_init) = w4_hi.split_last_mut().unwrap();\n    let mut addend = *w4_last;\n    let (w5_lo, w5_hi) = w5.split_at_mut(n);\n    if limbs_add_same_length_to_out(out_5, w4_init, w5_lo) {\n        addend += 1;\n    }\n    assert!(!limbs_slice_add_limb_in_place(w5_hi, addend));\n    if n_high > n + 1 {\n        assert!(!limbs_slice_add_greater_in_place_left(remainder, w5_hi));\n    } else {\n        let (w5_hi_lo, w5_hi_hi) = w5_hi.split_at_mut(n_high);\n        assert!(!limbs_slice_add_same_length_in_place_left(\n            &mut remainder[..n_high],\n            w5_hi_lo,\n        ));\n        if WANT_ASSERT && n + n_high < m {\n            slice_test_zero(w5_hi_hi);\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ys.len()`.\n//\n// This is equivalent to `DO_mpn_sublsh_n` from `mpn/generic/toom_interpolate_8pts.c`, GMP 6.2.1.\npub_test! {limbs_shl_and_sub_same_length(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    shift: u64,\n    scratch: &mut [Limb],\n) -> Limb {\n    let n = ys.len();\n    let mut carry = limbs_shl_to_out(scratch, ys, shift);\n    if limbs_sub_same_length_in_place_left(&mut xs[..n], &scratch[..n]) {\n        carry.wrapping_add_assign(1);\n    }\n    carry\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `DO_mpn_subrsh` from `mpn/generic/toom_interpolate_8pts.c`, GMP 6.2.1.\nfn limbs_shl_and_sub(xs: &mut [Limb], ys: &[Limb], shift: u64, scratch: &mut [Limb]) {\n    let (ys_head, ys_tail) = ys.split_first().unwrap();\n    assert!(!limbs_sub_limb_in_place(xs, *ys_head >> shift));\n    let carry = limbs_shl_and_sub_same_length(xs, ys_tail, Limb::WIDTH - shift, scratch);\n    assert!(!limbs_sub_limb_in_place(&mut xs[ys.len() - 1..], carry));\n}\n\nfn limbs_shl_and_sub_special(\n    xs_init: &mut [Limb],\n    xs_last: &mut Limb,\n    ys: &[Limb],\n    shift: u64,\n    scratch: &mut [Limb],\n) {\n    let (ys_head, ys_tail) = ys.split_first().unwrap();\n    if limbs_sub_limb_in_place(xs_init, *ys_head >> shift) {\n        *xs_last = xs_last.checked_sub(1).unwrap();\n    }\n    let carry = limbs_shl_and_sub_same_length(xs_init, ys_tail, Limb::WIDTH - shift, scratch);\n    if limbs_sub_limb_in_place(&mut xs_init[ys_tail.len()..], carry) {\n        *xs_last = xs_last.checked_sub(1).unwrap();\n    }\n}\n\n// Interpolation for Toom-4.5 (or Toom-4), using the evaluation points: infinity(4.5 only), 4, -4,\n// 2, -2, 1, -1, 0. More precisely, we want to compute f(2 ^ (`Limb::WIDTH` * n)) for a polynomial f\n// of degree 7 (or 6), given the 8 (rsp. 7) values:\n//\n// - r1 = limit at infinity of f(x) / x ^ 7,\n// - r2 = f(4),\n// - r3 = f(-4),\n// - r4 = f(2),\n// - r5 = f(-2),\n// - r6 = f(1),\n// - r7 = f(-1),\n// - r8 = f(0).\n//\n// All couples of the form f(n),f(-n) must be already mixed with\n// `limbs_toom_couple_handling`(f(n),..., f(-n), ...)\n//\n// The result is stored in {`out`, `s_plus_t` + 7 * n (or 6 * n)}. At entry, `r8` is stored at\n// {`out`, 2 * `n`}, and r5 is stored at {`out` + 3 * `n`, 3 * `n` + 1}.\n//\n// The other values are 2 * `n` + ... limbs each (with most significant limbs small).\n//\n// All intermediate results are positive. Inputs are destroyed.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_toom_interpolate_8pts` from `mpn/generic/toom_interpolate_8pts.c`, GMP\n// 6.2.1, but the argument spt == `s_plus_t` is moved to immediately after `n`.\npub(crate) fn limbs_mul_toom_interpolate_8_points(\n    out: &mut [Limb],\n    n: usize,\n    s_plus_t: usize,\n    r3: &mut [Limb],\n    r7: &mut [Limb],\n    scratch: &mut [Limb],\n) {\n    assert!(s_plus_t >= n);\n    let m = 3 * n + 1;\n    assert_eq!(r3.len(), m);\n    assert_eq!(r7.len(), m);\n    let (out, remainder) = out.split_at_mut(n << 1);\n    let (out_2, remainder) = remainder.split_at_mut(n);\n    let (r5, r1) = remainder.split_at_mut(n << 2);\n    let r1 = &mut r1[..s_plus_t];\n    let r5_lo = &mut r5[..m];\n    // Interpolation\n    limbs_shl_and_sub(&mut r3[n..], out, 4, scratch);\n    let carry = limbs_shl_and_sub_same_length(r3, r1, 12, scratch);\n    assert!(!limbs_sub_limb_in_place(&mut r3[s_plus_t..], carry));\n    limbs_shl_and_sub(&mut r5_lo[n..], out, 2, scratch);\n    let carry = limbs_shl_and_sub_same_length(r5_lo, r1, 6, scratch);\n    assert!(!limbs_sub_limb_in_place(&mut r5_lo[s_plus_t..], carry));\n    let (r7_last, r7_init) = r7.split_last_mut().unwrap();\n    if limbs_sub_same_length_in_place_left(&mut r7_init[n..], out) {\n        r7_last.wrapping_sub_assign(1);\n    }\n    let (r7_lo, r7_hi) = r7.split_at_mut(s_plus_t);\n    if limbs_sub_same_length_in_place_left(r7_lo, r1) {\n        assert!(!limbs_sub_limb_in_place(r7_hi, 1));\n    }\n    assert!(!limbs_sub_same_length_in_place_left(r3, r5_lo));\n    assert_eq!(limbs_slice_shr_in_place(r3, 2), 0);\n    assert!(!limbs_sub_same_length_in_place_left(r5_lo, r7));\n    assert!(!limbs_sub_same_length_in_place_left(r3, r5_lo));\n    limbs_div_exact_limb_in_place(r3, 45);\n    limbs_div_exact_3_in_place(r5_lo);\n    assert_eq!(limbs_shl_and_sub_same_length(r5_lo, r3, 2, scratch), 0);\n    // Last interpolation steps are mixed with recomposition.\n    //\n    // out[] prior to operations:\n    // ```\n    // |_H r1|_L r1|____||_H r5|_M_r5|_L r5|_____|_H r8|_L r8|out\n    // ```\n    //\n    // summation scheme for remaining operations:\n    // ```\n    // |____8|n___7|n___6|n___5|n___4|n___3|n___2|n____|n____|out\n    // |_H r1|_L r1|____||_H*r5|_M r5|_L r5|_____|_H_r8|_L r8|out\n    //  ||_H r3|_M r3|_L*r3|\n    //              ||_H_r7|_M_r7|_L_r7|\n    //          ||-H r3|-M r3|-L*r3|\n    //              ||-H*r5|-M_r5|-L_r5|\n    // Hr8+Lr7-Lr5\n    // ```\n    split_into_chunks_mut!(r5_lo, n, [r5_lo_0, r5_lo_1, r5_lo_2], r5_lo_3);\n    let (r7_lo, r7) = r7.split_at_mut(n);\n    let out = &mut out[n..];\n    let carry_1 = limbs_slice_add_same_length_in_place_left(out, r7_lo);\n    let carry_2 = limbs_sub_same_length_in_place_left(out, r5_lo_0);\n    if carry_1 && !carry_2 {\n        assert!(!limbs_slice_add_limb_in_place(r7, 1));\n    } else if !carry_1 && carry_2 {\n        assert!(!limbs_sub_limb_in_place(r7, 1));\n    }\n    let (r7_lo, r7_hi) = r7.split_at_mut(n);\n    // Mr7-Mr5\n    if limbs_sub_same_length_to_out(out_2, r7_lo, r5_lo_1) {\n        assert!(!limbs_sub_limb_in_place(r7_hi, 1));\n    }\n    // Hr5+Lr3\n    let (r3_lo, r3) = r3.split_at_mut(n);\n    if limbs_slice_add_same_length_in_place_left(r5_lo_2, r3_lo) {\n        r5_lo_3[0].wrapping_add_assign(1);\n    }\n    // Hr7+Lr5\n    let carry_1 = limbs_slice_add_same_length_in_place_left(&mut r5_lo[..=n], r7_hi);\n    // Hr7-Hr5+Lr5-Lr3\n    let (r5_lo_lo, r5_lo_hi) = r5_lo.split_at_mut(n << 1);\n    let carry_2 = limbs_sub_same_length_in_place_left(&mut r5_lo_lo[..=n], r5_lo_hi);\n    if carry_1 && !carry_2 {\n        assert!(!limbs_slice_add_limb_in_place(&mut r5_lo[n + 1..], 1));\n    } else if !carry_1 && carry_2 {\n        assert!(!limbs_sub_limb_in_place(&mut r5_lo[n + 1..], 1));\n    }\n    // Mr5-Mr3,Hr5-Hr3\n    assert!(!limbs_sub_same_length_in_place_left(&mut r5_lo[n..], r3));\n    let r5_3n = r5[3 * n];\n    let (r3_lo, r3) = r3.split_at_mut(n);\n    if limbs_add_limb_to_out(&mut r5[3 * n..], r3_lo, r5_3n) {\n        assert!(!limbs_slice_add_limb_in_place(r3, 1));\n    }\n    let mut r3_n = r3[n];\n    let (r1_lo, r1_hi) = r1.split_at_mut(n);\n    if limbs_slice_add_same_length_in_place_left(r1_lo, &r3[..n]) {\n        r3_n.wrapping_add_assign(1);\n    }\n    if s_plus_t == n {\n        assert_eq!(r3_n, 0);\n    } else {\n        assert!(!limbs_slice_add_limb_in_place(r1_hi, r3_n));\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn limbs_div_255_in_place(xs: &mut [Limb]) {\n    limbs_div_divisor_of_limb_max_with_carry_in_place(xs, Limb::MAX / 255, 0);\n}\n\nfn limbs_aors_mul_or_two_sh_aors_helper(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    s: Limb,\n    sign: bool,\n    s1: u64,\n    sign1: bool,\n    s2: u64,\n    sign2: bool,\n    scratch: &mut [Limb],\n) {\n    if AORSMUL_FASTER_2AORSLSH {\n        if sign {\n            limbs_slice_add_mul_limb_same_length_in_place_left(xs, ys, s);\n        } else {\n            limbs_sub_mul_limb_same_length_in_place_left(xs, ys, s);\n        }\n    } else {\n        if sign1 {\n            limbs_shl_and_add_same_length_in_place_left(xs, ys, s1, scratch);\n        } else {\n            limbs_shl_and_sub_same_length(xs, ys, s1, scratch);\n        }\n        if sign2 {\n            limbs_shl_and_add_same_length_in_place_left(xs, ys, s2, scratch);\n        } else {\n            limbs_shl_and_sub_same_length(xs, ys, s2, scratch);\n        }\n    }\n}\n\nfn limbs_aors_mul_or_three_sh_aors_helper(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    s: Limb,\n    s1: u64,\n    s2: u64,\n    s3: u64,\n    no_carry: bool,\n    scratch: &mut [Limb],\n) {\n    if AORSMUL_FASTER_3AORSLSH {\n        let c = limbs_sub_mul_limb_same_length_in_place_left(xs, ys, s);\n        if no_carry {\n            assert_eq!(c, 0);\n        }\n    } else {\n        let c = limbs_shl_and_sub_same_length(xs, ys, s1, scratch);\n        if no_carry {\n            assert_eq!(c, 0);\n        }\n        let c = limbs_shl_and_sub_same_length(xs, ys, s2, scratch);\n        if no_carry {\n            assert_eq!(c, 0);\n        }\n        let c = limbs_shl_and_sub_same_length(xs, ys, s3, scratch);\n        if no_carry {\n            assert_eq!(c, 0);\n        }\n    }\n}\n\nfn limbs_aors_mul_or_aors_and_two_sh_aors_helper(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    s: Limb,\n    s1: u64,\n    s2: u64,\n    scratch: &mut [Limb],\n) {\n    if AORSMUL_FASTER_AORS_2AORSLSH {\n        assert_eq!(limbs_sub_mul_limb_same_length_in_place_left(xs, ys, s), 0);\n    } else {\n        assert!(!limbs_sub_same_length_in_place_left(xs, ys));\n        assert_eq!(\n            limbs_shl_and_add_same_length_in_place_left(xs, ys, s1, scratch),\n            0\n        );\n        assert_eq!(limbs_shl_and_sub_same_length(xs, ys, s2, scratch), 0);\n    }\n}\n\nfn limbs_aors_mul_or_aors_and_sh_aors_helper(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    s: Limb,\n    sign1: bool,\n    s2: u64,\n    scratch: &mut [Limb],\n) {\n    if AORSMUL_FASTER_AORS_AORSLSH {\n        limbs_sub_mul_limb_same_length_in_place_left(xs, ys, s);\n    } else {\n        if sign1 {\n            limbs_slice_add_same_length_in_place_left(xs, ys);\n        } else {\n            limbs_sub_same_length_in_place_left(xs, ys);\n        }\n        limbs_shl_and_sub_same_length(xs, ys, s2, scratch);\n    }\n}\n\n// Interpolation for Toom-6.5 (or Toom-6), using the evaluation points:\n// - Infinity(6.5 only), +-4, +-2, +-1, +-1/4, +-1/2, 0.\n//\n// More precisely, we want to compute f(2 ^ (`Limb::WIDTH` * n)) for a polynomial f of degree 11 (or\n// 10), given the 12 (resp. 11) values:\n//\n// - r0 = limit at infinity of f(x) / x ^ 7,\n// - r1 = f(4),f(-4),\n// - r2 = f(2),f(-2),\n// - r3 = f(1),f(-1),\n// - r4 = f(1 / 4), f(-1 / 4),\n// - r5 = f(1 / 2), f(-1 / 2),\n// - r6 = f(0).\n//\n// All couples of the form f(n),f(-n) must be already mixed with `limbs_toom_couple_handling`(f(n),\n// ..., f(-n),...)\n//\n// - The result is stored in {out, s_plus_t + 7 * n (or 6 * n)}.\n// - At entry, r6 is stored at {out, 2 * n},\n// - r4 is stored at {out +  3 * n, 3 * n + 1}.\n// - r2 is stored at {out +  7 * n, 3 * n + 1}.\n// - r0 is stored at {out + 11 * n, s_plus_t}.\n//\n// The other values are 3 * n + 1 limbs each (with most significant limbs small).\n//\n// Negative intermediate results are stored two-complemented. Inputs are destroyed.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_toom_interpolate_12pts` from `mpn/generic/toom_interpolate_12pts.c`,\n// GMP 6.2.1.\npub_crate_test! {limbs_mul_toom_interpolate_12_points<'a>(\n    out: &mut [Limb],\n    mut r1: &'a mut [Limb],\n    r3: &mut [Limb],\n    mut r5: &'a mut [Limb],\n    n: usize,\n    s_plus_t: usize,\n    half: bool,\n    mut scratch: &'a mut [Limb],\n) {\n    let m = 3 * n + 1;\n    assert_eq!(r1.len(), m);\n    assert_eq!(r3.len(), m);\n    assert_eq!(r5.len(), m);\n    let (out_lo, remainder) = out.split_at_mut(3 * n);\n    let out_lo = &mut out_lo[..n << 1];\n    let (r4, r2) = remainder.split_at_mut(n << 2);\n    let r4 = &mut r4[..m];\n    // Interpolation\n    if half {\n        let (r2, r0) = r2.split_at_mut(4 * n);\n        let r0 = &mut r0[..s_plus_t];\n        let (r3_lo, r3_hi) = r3.split_at_mut(s_plus_t);\n        if limbs_sub_same_length_in_place_left(r3_lo, r0) {\n            assert!(!limbs_sub_limb_in_place(r3_hi, 1));\n        }\n        let carry = limbs_shl_and_sub_same_length(r2, r0, 10, scratch);\n        assert!(!limbs_sub_limb_in_place(&mut r2[s_plus_t..m], carry));\n        limbs_shl_and_sub(r5, r0, 2, scratch);\n        let carry = limbs_shl_and_sub_same_length(r1, r0, 20, scratch);\n        assert!(!limbs_sub_limb_in_place(&mut r1[s_plus_t..], carry));\n        limbs_shl_and_sub(r4, r0, 4, scratch);\n    };\n    let r2 = &mut r2[..m];\n    let carry = limbs_shl_and_sub_same_length(&mut r4[n..], out_lo, 20, scratch);\n    r4.last_mut().unwrap().wrapping_sub_assign(carry);\n    limbs_shl_and_sub(&mut r1[n..], out_lo, 4, scratch);\n    assert!(!limbs_add_same_length_to_out(scratch, r1, r4));\n    limbs_sub_same_length_in_place_left(r4, r1); // can be negative\n    swap(&mut r1, &mut scratch);\n    let r1 = &mut r1[..m];\n    let carry = limbs_shl_and_sub_same_length(&mut r5[n..], out_lo, 10, scratch);\n    r5.last_mut().unwrap().wrapping_sub_assign(carry);\n    limbs_shl_and_sub(&mut r2[n..], out_lo, 2, scratch);\n    limbs_sub_same_length_to_out(scratch, r5, r2); // can be negative\n    assert!(!limbs_slice_add_same_length_in_place_left(r2, r5));\n    swap(&mut r5, &mut scratch);\n    let (r3_last, r3_init) = r3.split_last_mut().unwrap();\n    if limbs_sub_same_length_in_place_left(&mut r3_init[n..], out_lo) {\n        r3_last.wrapping_sub_assign(1);\n    }\n    limbs_aors_mul_or_aors_and_sh_aors_helper(r4, r5, 257, false, 8, scratch);\n    // A division by 2835 * 4 follows. Warning: the operand can be negative!\n    limbs_div_exact_limb_in_place(r4, 2835 << 2);\n    let r4_last = r4.last_mut().unwrap();\n    if r4_last.leading_zeros() < 3 {\n        *r4_last |= Limb::MAX << (Limb::WIDTH - 2);\n    }\n    limbs_aors_mul_or_two_sh_aors_helper(r5, r4, 60, true, 2, false, 6, true, scratch);\n    limbs_div_255_in_place(r5);\n    assert_eq!(limbs_shl_and_sub_same_length(r2, r3, 5, scratch), 0);\n    limbs_aors_mul_or_three_sh_aors_helper(r1, r2, 100, 6, 5, 2, true, scratch);\n    assert_eq!(limbs_shl_and_sub_same_length(r1, r3, 9, scratch), 0);\n    limbs_div_exact_limb_in_place(r1, 42525);\n    limbs_aors_mul_or_aors_and_two_sh_aors_helper(r2, r1, 225, 5, 8, scratch);\n    limbs_div_exact_limb_in_place(r2, 9 << 2);\n    assert!(!limbs_sub_same_length_in_place_left(r3, r2));\n    limbs_sub_same_length_in_place_right(r2, r4);\n    assert_eq!(limbs_slice_shr_in_place(r4, 1), 0);\n    assert!(!limbs_sub_same_length_in_place_left(r2, r4));\n    let r1 = &mut r1[..m];\n    limbs_slice_add_same_length_in_place_left(r5, r1);\n    assert_eq!(limbs_slice_shr_in_place(r5, 1), 0);\n    // Last interpolation steps...\n    assert!(!limbs_sub_same_length_in_place_left(r3, r1));\n    assert!(!limbs_sub_same_length_in_place_left(r1, r5));\n    // ...could be mixed with recomposition\n    // ```\n    // ||H-r5|M-r5|L-r5|   ||H-r1|M-r1|L-r1|\n    // ```\n    //\n    // Recomposition\n    //\n    // out[] prior to operations:\n    // ```\n    // |M r0|L r0|___||H r2|M r2|L r2|___||H r4|M r4|L r4|____|H_r6|L r6|out\n    // ```\n    //\n    // Summation scheme for remaining operations:\n    // ```\n    // |__12|n_11|n_10|n__9|n__8|n__7|n__6|n__5|n__4|n__3|n__2|n___|n___|out\n    // |M r0|L r0|___||H r2|M r2|L r2|___||H r4|M r4|L r4|____|H_r6|L r6|out\n    // ||H r1|M r1|L r1|   ||H r3|M r3|L r3|   ||H_r5|M_r5|L_r5|\n    // ```\n    split_into_chunks_mut!(out, n, [_unused, out_1, out_2, out_3], out_4);\n    split_into_chunks_mut!(r5, n, [r5_0, r5_1], r5_2);\n    if limbs_slice_add_same_length_in_place_left(out_1, r5_0) {\n        if limbs_add_limb_to_out(out_2, r5_1, 1) {\n            assert!(!limbs_slice_add_limb_in_place(r5_2, 1));\n        }\n    } else {\n        out_2.copy_from_slice(r5_1);\n    }\n    let (r5_last, r5_2) = r5_2.split_last_mut().unwrap();\n    let mut carry = *r5_last;\n    if limbs_slice_add_same_length_in_place_left(out_3, r5_2) {\n        carry.wrapping_add_assign(1);\n    }\n    assert!(!limbs_slice_add_limb_in_place(\n        &mut out_4[..=n<<1],\n        carry,\n    ));\n    split_into_chunks_mut!(out_4, n, [_unused, out_5, out_6, out_7], out_8);\n    split_into_chunks_mut!(r3, n, [r3_0, r3_1], r3_2);\n    if limbs_slice_add_same_length_in_place_left(out_5, r3_0) {\n        out_6[0].wrapping_add_assign(1);\n    }\n    let out_6_first = out_6[0];\n    if limbs_add_limb_to_out(out_6, r3_1, out_6_first) {\n        assert!(!limbs_slice_add_limb_in_place(r3_2, 1));\n    }\n    let (r3_last, r3_2) = r3_2.split_last_mut().unwrap();\n    let mut carry = *r3_last;\n    if limbs_slice_add_same_length_in_place_left(out_7, r3_2) {\n        carry.wrapping_add_assign(1);\n    }\n    assert!(!limbs_slice_add_limb_in_place(\n        &mut out_8[..=n<<1],\n        carry,\n    ));\n    split_into_chunks_mut!(out_8, n, [_unused, out_9], out_10);\n    let (r1_0, r1_1) = r1.split_at_mut(n);\n    if limbs_slice_add_same_length_in_place_left(out_9, r1_0) {\n        out_10[0].wrapping_add_assign(1);\n    }\n    let out_10_first = out_10[0];\n    if half {\n        let (out_10, out_11) = out_10.split_at_mut(n);\n        let (r1_1, r1_2) = r1_1.split_at_mut(n);\n        if limbs_add_limb_to_out(out_10, r1_1, out_10_first) {\n            assert!(!limbs_slice_add_limb_in_place(r1_2, 1));\n        }\n        if s_plus_t > n {\n            let (out_11, out_12) = out_11.split_at_mut(n);\n            let (r1_last, r1_2) = r1_2.split_last_mut().unwrap();\n            let mut carry = *r1_last;\n            if limbs_slice_add_same_length_in_place_left(out_11, r1_2) {\n                carry.wrapping_add_assign(1);\n            }\n            assert!(!limbs_slice_add_limb_in_place(\n                &mut out_12[..s_plus_t - n],\n                carry,\n            ));\n        } else {\n            assert!(!limbs_slice_add_same_length_in_place_left(\n                &mut out_11[..s_plus_t],\n                &r1_2[..s_plus_t],\n            ));\n        }\n    } else {\n        assert!(!limbs_add_limb_to_out(\n            out_10,\n            &r1_1[..s_plus_t],\n            out_10_first,\n        ));\n    }\n}}\n\n#[cfg(feature = \"32_bit_limbs\")]\nconst CORRECTED_WIDTH: u64 = 42 - Limb::WIDTH;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst CORRECTED_WIDTH: u64 = 42;\n\n// Interpolation for Toom-8.5 (or Toom-8), using the evaluation points: Infinity(8.5 only), +-8,\n// +-4, +-2, +-1, +-1/4, +-1/2, +-1/8, 0.\n//\n// More precisely, we want to compute f(2 ^ (`Limb::WIDTH` * n)) for a polynomial f of degree 15 (or\n// 14), given the 16 (rsp. 15) values:\n//\n// - r0 = limit at infinity of f(x) / x ^ 7,\n// - r1 = f(8), f(-8),\n// - r2 = f(4), f(-4),\n// - r3 = f(2), f(-2),\n// - r4 = f(1), f(-1),\n// - r5 = f(1/4), f(-1/4),\n// - r6 = f(1/2), f(-1/2),\n// - r7 = f(1/8), f(-1/8),\n// - r8 = f(0).\n//\n// All couples of the form f(n),f(-n) must be already mixed with\n// toom_couple_handling(f(n),...,f(-n),...)\n//\n// - The result is stored in {out, s_plus_t + 7 * n (or 8 * n)}.\n// - At entry, r8 is stored at {out, 2 * n},\n// - r6 is stored at {out + 3 * n, 3 * n + 1}.\n// - r4 is stored at {out + 7 * n, 3 * n + 1}.\n// - r2 is stored at {out + 11 * n, 3 * n + 1}.\n// - r0 is stored at {out + 15 * n, s_plus_t}.\n//\n// The other values are 3 * n + 1 limbs each (with most significant limbs small).\n//\n// Negative intermediate results are stored two-complemented. Inputs are destroyed.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `n`.\n//\n// This is equivalent to `mpn_toom_interpolate_16pts` from `mpn/generic/toom_interpolate_16pts.c`,\n// GMP 6.2.1.\npub_crate_test! {limbs_mul_toom_interpolate_16_points<'a>(\n    out: &mut [Limb],\n    r1: &mut [Limb],\n    mut r3: &'a mut [Limb],\n    mut r5: &'a mut [Limb],\n    mut r7: &'a mut [Limb],\n    n: usize,\n    s_plus_t: usize,\n    half: bool,\n    mut scratch: &'a mut [Limb],\n) {\n    let m = 3 * n + 1;\n    assert!(s_plus_t <= n << 1);\n    assert_eq!(r1.len(), m);\n    assert_eq!(r3.len(), m);\n    assert_eq!(r5.len(), m);\n    assert_eq!(r7.len(), m);\n    let (pp_lo, remainder) = out.split_at_mut(3 * n);\n    let pp_lo = &mut pp_lo[..n << 1];\n    split_into_chunks_mut!(remainder, n << 2, [r6, r4], r2);\n    let r4 = &mut r4[..m];\n    let r6 = &mut r6[..m];\n    // Interpolation\n    if half {\n        let (r2, r0) = r2.split_at_mut(n << 2);\n        let r0 = &mut r0[..s_plus_t];\n        let r2 = &mut r2[..m];\n        let (r4_lo, r4_hi) = r4.split_at_mut(s_plus_t);\n        if limbs_sub_same_length_in_place_left(r4_lo, r0) {\n            assert!(!limbs_sub_limb_in_place(r4_hi, 1));\n        }\n        let carry = limbs_shl_and_sub_same_length(r3, r0, 14, scratch);\n        assert!(!limbs_sub_limb_in_place(&mut r3[s_plus_t..], carry));\n        limbs_shl_and_sub(r6, r0, 2, scratch);\n        let carry = limbs_shl_and_sub_same_length(r2, r0, 28, scratch);\n        assert!(!limbs_sub_limb_in_place(&mut r2[s_plus_t..], carry));\n        limbs_shl_and_sub(r5, r0, 4, scratch);\n        if BIT_CORRECTION {\n            let carry = limbs_shl_and_sub_same_length(&mut r1[1..], r0, CORRECTED_WIDTH, scratch);\n            limbs_sub_limb_in_place(&mut r1[s_plus_t + 1..], carry);\n            let r5_first = r5.first_mut().unwrap();\n            let carry = *r5_first;\n            *r5_first = 0x80;\n            limbs_shl_and_sub_special(r7, r5_first, r0, 6, scratch);\n            *r5_first = carry;\n        } else {\n            let carry = limbs_shl_and_sub_same_length(r1, r0, CORRECTED_WIDTH, scratch);\n            assert!(!limbs_sub_limb_in_place(&mut r1[s_plus_t..], carry));\n            limbs_shl_and_sub(r7, r0, 6, scratch);\n        }\n    }\n    let r2 = &mut r2[..m];\n    let (r5_last, r5_init) = r5[n..].split_last_mut().unwrap();\n    r5_last.wrapping_sub_assign(limbs_shl_and_sub_same_length(r5_init, pp_lo, 28, scratch));\n    limbs_shl_and_sub(&mut r2[n..], pp_lo, 4, scratch);\n    limbs_sub_same_length_to_out(scratch, r5, r2); // can be negative\n    assert!(!limbs_slice_add_same_length_in_place_left(r2, r5));\n    swap(&mut r5, &mut scratch);\n    let (r6_last, r6_init) = r6[n..].split_last_mut().unwrap();\n    r6_last.wrapping_sub_assign(limbs_shl_and_sub_same_length(r6_init, pp_lo, 14, scratch));\n    limbs_shl_and_sub(&mut r3[n..], pp_lo, 2, scratch);\n    assert!(!limbs_add_same_length_to_out(scratch, r3, r6));\n    limbs_sub_same_length_in_place_left(r6, r3); // can be negative\n    swap(&mut r3, &mut scratch);\n    let r1_hi = &mut r1[n..];\n    if BIT_CORRECTION {\n        limbs_shl_and_sub_same_length(&mut r7[n + 1..], pp_lo, CORRECTED_WIDTH, scratch);\n        let (pp_lo_first, pp_lo_tail) = pp_lo.split_first().unwrap();\n        assert!(!limbs_sub_limb_in_place(r1_hi, pp_lo_first >> 6));\n        let carry = limbs_shl_and_sub_same_length(r1_hi, pp_lo_tail, Limb::WIDTH - 6, scratch);\n        limbs_sub_limb_in_place(&mut r1_hi[2 * n - 1..], carry);\n    } else {\n        let carry = limbs_shl_and_sub_same_length(&mut r7[n..], pp_lo, CORRECTED_WIDTH, scratch);\n        r7.last_mut().unwrap().wrapping_sub_assign(carry);\n        limbs_shl_and_sub(r1_hi, pp_lo, 6, scratch);\n    }\n    // can be negative\n    limbs_sub_same_length_to_out(scratch, r7, r1);\n    // if BIT_CORRECTION, can give a carry.\n    limbs_slice_add_same_length_in_place_left(r1, r7);\n    swap(&mut r7, &mut scratch);\n    let (r4_last, r4_init) = r4[n..].split_last_mut().unwrap();\n    if limbs_sub_same_length_in_place_left(r4_init, pp_lo) {\n        r4_last.wrapping_sub_assign(1);\n    }\n    limbs_aors_mul_or_two_sh_aors_helper(r5, r6, 1028, false, 2, false, 10, false, scratch);\n    limbs_sub_mul_limb_same_length_in_place_left(r7, r5, 1300); // can be negative\n    limbs_aors_mul_or_three_sh_aors_helper(r7, r6, 1052688, 4, 12, 20, false, scratch);\n    limbs_div_exact_limb_in_place(r7, 188513325);\n    limbs_div_255_in_place(r7);\n    // can be negative\n    limbs_sub_mul_limb_same_length_in_place_left(r5, r7, 12567555);\n    // A division by 2835x64 follows. Warning: the operand can be negative!\n    limbs_div_exact_limb_in_place(r5, 2835 << 6);\n    let r5_last = r5.last_mut().unwrap();\n    if r5_last.leading_zeros() < 7 {\n        *r5_last |= Limb::MAX << (Limb::WIDTH - 6);\n    }\n    limbs_aors_mul_or_aors_and_sh_aors_helper(r6, r7, 4095, true, 12, scratch);\n    limbs_aors_mul_or_two_sh_aors_helper(r6, r5, 240, true, 8, true, 4, false, scratch);\n    // A division by 255x4 follows. Warning: the operand can be negative!\n    limbs_div_exact_limb_in_place(r6, 255 << 2);\n    let r6_last = r6.last_mut().unwrap();\n    if r6_last.leading_zeros() < 3 {\n        *r6_last |= Limb::MAX << (Limb::WIDTH - 2);\n    }\n    assert_eq!(limbs_shl_and_sub_same_length(r3, r4, 7, scratch), 0);\n    assert_eq!(limbs_shl_and_sub_same_length(r2, r4, 13, scratch), 0);\n    assert_eq!(limbs_sub_mul_limb_same_length_in_place_left(r2, r3, 400), 0);\n    // If `Limb::WIDTH` < 42 next operations on r1 can give a carry!\n    limbs_shl_and_sub_same_length(r1, r4, 19, scratch);\n    limbs_sub_mul_limb_same_length_in_place_left(r1, r2, 1428);\n    limbs_sub_mul_limb_same_length_in_place_left(r1, r3, 112896);\n    limbs_div_exact_limb_in_place(r1, 182712915);\n    limbs_div_255_in_place(r1);\n    assert_eq!(\n        limbs_sub_mul_limb_same_length_in_place_left(r2, r1, 15181425),\n        0\n    );\n    limbs_div_exact_limb_in_place(r2, 42525 << 4);\n    limbs_aors_mul_or_aors_and_two_sh_aors_helper(r3, r1, 3969, 7, 12, scratch);\n    assert_eq!(limbs_sub_mul_limb_same_length_in_place_left(r3, r2, 900), 0);\n    limbs_div_exact_limb_in_place(r3, 9 << 4);\n    assert!(!limbs_sub_same_length_in_place_left(r4, r1));\n    assert!(!limbs_sub_same_length_in_place_left(r4, r3));\n    assert!(!limbs_sub_same_length_in_place_left(r4, r2));\n    limbs_slice_add_same_length_in_place_left(r6, r2);\n    assert_eq!(limbs_slice_shr_in_place(r6, 1), 0);\n    assert!(!limbs_sub_greater_in_place_left(r2, r6));\n    limbs_sub_same_length_in_place_right(r3, r5);\n    assert_eq!(limbs_slice_shr_in_place(r5, 1), 0);\n    assert!(!limbs_sub_same_length_in_place_left(r3, r5));\n    limbs_slice_add_same_length_in_place_left(r7, r1);\n    assert_eq!(limbs_slice_shr_in_place(r7, 1), 0);\n    assert!(!limbs_sub_same_length_in_place_left(r1, r7));\n    // Last interpolation steps could be mixed with recomposition.\n    // ```\n    // ||H-r7|M-r7|L-r7|   ||H-r5|M-r5|L-r5|\n    // ```\n    //\n    // Recomposition\n    //\n    // out[] prior to operations:\n    // ```\n    // |M r0|L r0|___||H r2|M r2|L r2|___||H r4|M r4|L r4|___||H r6|M r6|L r6|____|H_r8|L r8|out\n    // ```\n    //\n    // summation scheme for remaining operations:\n    // ```\n    // |__16|n_15|n_14|n_13|n_12|n_11|n_10|n__9|n__8|n__7|n__6|n__5|n__4|n__3|n__2|n___|n___|out\n    // |M r0|L r0|___||H r2|M r2|L r2|___||H r4|M r4|L r4|___||H r6|M r6|L r6|____|H_r8|L r8|out\n    // ||H r1|M r1|L r1|   ||H r3|M r3|L r3|   ||H_r5|M_r5|L_r5|   ||H r7|M r7|L r7|\n    // ```\n    split_into_chunks_mut!(out, n, [_unused, out_1, out_2, out_3], out_4);\n    split_into_chunks_mut!(r7, n, [r7_0, r7_1], r7_2);\n    if limbs_slice_add_same_length_in_place_left(out_1, r7_0) {\n        if limbs_add_limb_to_out(out_2, r7_1, 1) {\n            assert!(!limbs_slice_add_limb_in_place(r7_2, 1));\n        }\n    } else {\n        out_2.copy_from_slice(r7_1);\n    }\n    let (r7_last, r7_2) = r7_2.split_last_mut().unwrap();\n    let mut carry = *r7_last;\n    if limbs_slice_add_same_length_in_place_left(out_3, r7_2) {\n        carry.wrapping_add_assign(1);\n    }\n    assert!(!limbs_slice_add_limb_in_place(out_4, carry));\n    split_into_chunks_mut!(out_4, n, [_unused, out_5, out_6, out_7], out_8);\n    split_into_chunks_mut!(r5, n, [r5_0, r5_1], r5_2);\n    if limbs_slice_add_same_length_in_place_left(out_5, r5_0) {\n        out_6[0].wrapping_add_assign(1);\n    }\n    let out_6_first = out_6[0];\n    if limbs_add_limb_to_out(out_6, r5_1, out_6_first) {\n        assert!(!limbs_slice_add_limb_in_place(r5_2, 1));\n    }\n    let (r5_last, r5_2) = r5_2.split_last_mut().unwrap();\n    let mut carry = *r5_last;\n    if limbs_slice_add_same_length_in_place_left(out_7, r5_2) {\n        carry.wrapping_add_assign(1);\n    }\n    assert!(!limbs_slice_add_limb_in_place(out_8, carry));\n    split_into_chunks_mut!(out_8, n, [_unused, out_9, out_10, out_11], out_12);\n    split_into_chunks_mut!(r3, n, [r3_0, r3_1], r3_2);\n    if limbs_slice_add_same_length_in_place_left(out_9, r3_0) {\n        out_10[0].wrapping_add_assign(1);\n    }\n    let out_10_first = out_10[0];\n    if limbs_add_limb_to_out(out_10, r3_1, out_10_first) {\n        assert!(!limbs_slice_add_limb_in_place(r3_2, 1));\n    }\n    let (r3_last, r3_2) = r3_2.split_last_mut().unwrap();\n    let mut carry = *r3_last;\n    if limbs_slice_add_same_length_in_place_left(out_11, r3_2) {\n        carry.wrapping_add_assign(1);\n    }\n    assert!(!limbs_slice_add_limb_in_place(out_12, carry));\n    split_into_chunks_mut!(out_12, n, [_unused, out_13], out_14);\n    let (r1_0, r1_1) = r1.split_at_mut(n);\n    if limbs_slice_add_same_length_in_place_left(out_13, r1_0) {\n        out_14[0].wrapping_add_assign(1);\n    }\n    let out_14_first = out_14[0];\n    if half {\n        let (out_14, out_15) = out_14.split_at_mut(n);\n        let (r1_1, r1_2) = r1_1.split_at_mut(n);\n        if limbs_add_limb_to_out(out_14, r1_1, out_14_first) {\n            assert!(!limbs_slice_add_limb_in_place(r1_2, 1));\n        }\n        if s_plus_t > n {\n            let (out_15, out_16) = out_15.split_at_mut(n);\n            let (r1_last, r1_2) = r1_2.split_last_mut().unwrap();\n            let mut carry = *r1_last;\n            if limbs_slice_add_same_length_in_place_left(out_15, r1_2) {\n                carry.wrapping_add_assign(1);\n            }\n            assert!(!limbs_slice_add_limb_in_place(\n                &mut out_16[..s_plus_t - n],\n                carry,\n            ));\n        } else {\n            assert!(!limbs_slice_add_same_length_in_place_left(\n                &mut out_15[..s_plus_t],\n                &r1_2[..s_plus_t],\n            ));\n        }\n    } else {\n        assert!(!limbs_add_limb_to_out(\n            &mut out_14[..s_plus_t],\n            &r1_1[..s_plus_t],\n            out_14_first,\n        ));\n    }\n}}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/product_of_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Contributed to the GNU project by Marco Bodrato.\n//\n//      Copyright © 2010-2012 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::mul::limb::limbs_slice_mul_limb_in_place;\nuse crate::natural::arithmetic::mul::{\n    MUL_TOOM22_THRESHOLD, limbs_mul_limb_to_out, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\n\nconst RECURSIVE_PROD_THRESHOLD: usize = MUL_TOOM22_THRESHOLD;\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `factors.len()`.\n//\n// This is equivalent to `mpz_prodlimbs` from `mpz/prodlimbs.c`, GMP 6.3.0. If x is too small to\n// contain the output, a newly-allocated vector containing the output is returned.\npub fn limbs_product(xs: &mut [Limb], factors: &mut [Limb]) -> (usize, Option<Vec<Limb>>) {\n    let xs_len = xs.len();\n    let factors_len = factors.len();\n    assert_ne!(factors_len, 0);\n    assert!(const { RECURSIVE_PROD_THRESHOLD > 3 });\n    if factors_len < RECURSIVE_PROD_THRESHOLD {\n        let j = factors_len - 1;\n        let mut size = 1;\n        for i in 1..j {\n            let factor = factors[i];\n            let carry = limbs_slice_mul_limb_in_place(&mut factors[..size], factor);\n            factors[size] = carry;\n            if carry != 0 {\n                size += 1;\n            }\n        }\n        let fj = factors[j];\n        let factors = &factors[..size];\n        let sp1 = size + 1;\n        if sp1 > xs_len {\n            let mut prod = vec![0; sp1];\n            prod[..xs_len].copy_from_slice(xs);\n            let carry = limbs_mul_limb_to_out::<DoubleLimb, Limb>(&mut prod, factors, fj);\n            prod[size] = carry;\n            (size + usize::from(carry != 0), Some(prod))\n        } else {\n            let carry = limbs_mul_limb_to_out::<DoubleLimb, Limb>(xs, factors, fj);\n            xs[size] = carry;\n            (size + usize::from(carry != 0), None)\n        }\n    } else {\n        let mut i = factors_len >> 1;\n        let mut j = factors_len - i;\n        let mut x2 = vec![0; j];\n        let (factors_lo, x1) = factors.split_at_mut(i);\n        let ox2;\n        (j, ox2) = limbs_product(&mut x2, x1);\n        if let Some(new_x2) = ox2 {\n            x2 = new_x2;\n        }\n        let x2 = &x2[..j];\n        let new_x1;\n        let ox1;\n        (i, ox1) = limbs_product(x1, factors_lo);\n        let x1 = if let Some(new_x1_temp) = ox1 {\n            new_x1 = new_x1_temp;\n            &new_x1[..i]\n        } else {\n            &x1[..i]\n        };\n        let size = i + j;\n        let mut scratch = vec![0; limbs_mul_to_out_scratch_len(i, j)];\n        if size > xs_len {\n            let mut prod = vec![0; size];\n            prod[..xs_len].copy_from_slice(xs);\n            let carry = limbs_mul_to_out(&mut prod, x1, x2, &mut scratch);\n            (size - usize::from(carry == 0), Some(prod))\n        } else {\n            let carry = limbs_mul_to_out(xs, x1, x2, &mut scratch);\n            (size - usize::from(carry == 0), None)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/mul/toom.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `TOOM22_MUL_REC`, `TOOM22_MUL_N_REC`, and `mpn_toom22_mul` contributed to the GNU project by\n//      Torbjörn Granlund.\n//\n//      `mpn_toom32_mul` contributed to the GNU project by Torbjörn Granlund, with improvements by\n//      Marco Bodrato and Niels Möller.\n//\n//      `TOOM33_MUL_N_REC`, `mpn_toom33_mul`, and `mpn_toom42_mul` contributed to the GNU project by\n//      Torbjörn Granlund, with additional improvements by Marco Bodrato.\n//\n//      `mpn_toom43_mul`, `mpn_toom52_mul`, `mpn_toom54_mul`, `abs_sub_n`, `abs_sub_add_n`,\n//      `mpn_toom63_mul`, `TOOM6H_MUL_N_REC`, `mpn_toom6h_mul`, `TOOM8H_MUL_N_REC`,\n//      `mpn_toom8h_mul`, and `mpn_toom_couple_handling` contributed to the GNU project by Marco\n//      Bodrato.\n//\n//      `mpn_toom44_mul`, `mpn_toom53_mul`, and `mpn_toom62_mul` contributed to the GNU project by\n//      Torbjörn Granlund and Marco Bodrato.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out,\n    limbs_add_same_length_with_carry_in_in_place_left, limbs_add_to_out, limbs_add_to_out_aliased,\n    limbs_slice_add_greater_in_place_left, limbs_slice_add_limb_in_place,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::mul::poly_eval::{\n    limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1,\n    limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2, limbs_mul_toom_evaluate_poly_in_1_and_neg_1,\n    limbs_mul_toom_evaluate_poly_in_2_and_neg_2,\n    limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow,\n    limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg,\n};\nuse crate::natural::arithmetic::mul::poly_interpolate::{\n    limbs_mul_toom_interpolate_5_points, limbs_mul_toom_interpolate_6_points,\n    limbs_mul_toom_interpolate_7_points, limbs_mul_toom_interpolate_8_points,\n    limbs_mul_toom_interpolate_12_points, limbs_mul_toom_interpolate_16_points,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_basecase,\n    limbs_mul_greater_to_out_scratch_len, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::arithmetic::square::{\n    limbs_square_to_out_toom_6_scratch_len, limbs_square_to_out_toom_8_scratch_len,\n};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_greater_to_out, limbs_sub_limb_in_place,\n    limbs_sub_same_length_in_place_left, limbs_sub_same_length_in_place_right,\n    limbs_sub_same_length_to_out, limbs_sub_same_length_with_borrow_in_in_place_left,\n    limbs_sub_same_length_with_borrow_in_to_out,\n};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{\n    Limb, MUL_FFT_THRESHOLD, MUL_TOOM6H_THRESHOLD, MUL_TOOM8H_THRESHOLD, MUL_TOOM22_THRESHOLD,\n    MUL_TOOM33_THRESHOLD, MUL_TOOM44_THRESHOLD,\n};\nuse core::cmp::{Ordering::*, max};\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, DivRound, EqModPowerOf2, ShrRound, WrappingAddAssign, WrappingSubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::NotAssign;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::{slice_set_zero, slice_test_zero};\n\n// TODO tune\npub(crate) const MUL_TOOM33_THRESHOLD_LIMIT: usize = MUL_TOOM33_THRESHOLD;\n\n// Helper function for high degree Toom-Cook algorithms.\n//\n// Gets {`xs`, `n`} and (`y_sign` ? -1 : 1) * {`ys`, `n`}. Computes at once:\n// ```\n// {`xs`, `n`} <- ({`xs`, `n`} + {`ys`, `n`}) / 2 ^ {`x_shift` + 1}\n// {`ys`, `n`} <- ({`xs`, `n`} - {`ys`, `n`}) / 2 ^ {`y_shift` + 1}\n// ```\n//\n// Finally recompose them obtaining:\n// ```\n// {`xs`, `n` + `offset`} <- {`xs`, `n`} + {`ys`, `n`} * 2 ^ {`offset` * `Limb::WIDTH`}\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpn_toom_couple_handling` from `mpn/generic/toom_couple_handling.c`, GMP\n// 6.2.1. The argument `n` is excluded as it is just the length of `ys`.\npub(crate) fn limbs_toom_couple_handling(\n    xs: &mut [Limb],\n    ys: &mut [Limb],\n    y_sign: bool,\n    offset: usize,\n    x_shift: u64,\n    y_shift: u64,\n) {\n    let n = ys.len();\n    assert!(xs.len() >= n + offset);\n    let (xs_lo, xs_hi) = xs.split_at_mut(n);\n    if y_sign {\n        limbs_sub_same_length_in_place_right(xs_lo, ys);\n    } else {\n        limbs_slice_add_same_length_in_place_left(ys, xs_lo);\n    }\n    limbs_slice_shr_in_place(ys, 1);\n    limbs_sub_same_length_in_place_left(xs_lo, ys);\n    if x_shift != 0 {\n        limbs_slice_shr_in_place(xs_lo, x_shift);\n    }\n    if y_shift != 0 {\n        limbs_slice_shr_in_place(ys, y_shift);\n    }\n    let (ys_lo, ys_hi) = ys.split_at(n - offset);\n    if limbs_slice_add_same_length_in_place_left(&mut xs_lo[offset..], ys_lo) {\n        assert!(!limbs_add_limb_to_out(xs_hi, ys_hi, 1));\n    } else {\n        xs_hi[..offset].copy_from_slice(ys_hi);\n    }\n}\n\n// TODO make these compiler flags?\n\n// TODO tune\n#[cfg(feature = \"test_build\")]\npub const TUNE_PROGRAM_BUILD: bool = false;\n#[cfg(not(feature = \"test_build\"))]\npub(crate) const TUNE_PROGRAM_BUILD: bool = false;\n// TODO tune\n#[cfg(feature = \"test_build\")]\npub const WANT_FAT_BINARY: bool = true;\n#[cfg(not(feature = \"test_build\"))]\npub(crate) const WANT_FAT_BINARY: bool = true;\n\n// TODO tune\n#[cfg(feature = \"test_build\")]\npub const TOOM22_MAYBE_MUL_TOOM22: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || MUL_TOOM33_THRESHOLD >= 2 * MUL_TOOM22_THRESHOLD;\n#[cfg(not(feature = \"test_build\"))]\nconst TOOM22_MAYBE_MUL_TOOM22: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || MUL_TOOM33_THRESHOLD >= 2 * MUL_TOOM22_THRESHOLD;\n\nfn limbs_mul_same_length_to_out_toom_22_recursive_scratch_len(xs_len: usize) -> usize {\n    if !TOOM22_MAYBE_MUL_TOOM22 || xs_len < MUL_TOOM22_THRESHOLD {\n        0\n    } else {\n        limbs_mul_greater_to_out_toom_22_scratch_len(xs_len, xs_len)\n    }\n}\n\n// A helper function for `limbs_mul_greater_to_out_toom_22`.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM22_MUL_N_REC` from `mpn/generic/toom22_mul.c`, GMP 6.2.1.\nfn limbs_mul_same_length_to_out_toom_22_recursive(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    assert_eq!(xs.len(), ys.len());\n    if !TOOM22_MAYBE_MUL_TOOM22 || xs.len() < MUL_TOOM22_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else {\n        limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n    }\n}\n\nfn limbs_mul_greater_to_out_toom_22_recursive_scratch_len(xs_len: usize, ys_len: usize) -> usize {\n    if !TOOM22_MAYBE_MUL_TOOM22 || ys_len < MUL_TOOM22_THRESHOLD {\n        0\n    } else if xs_len << 2 < 5 * ys_len {\n        limbs_mul_greater_to_out_toom_22_scratch_len(xs_len, ys_len)\n    } else if limbs_mul_greater_to_out_toom_32_input_sizes_valid(xs_len, ys_len) {\n        limbs_mul_greater_to_out_toom_32_scratch_len(xs_len, ys_len)\n    } else {\n        limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)\n    }\n}\n\n// A helper function for `limbs_mul_greater_to_out_toom_22`.\n//\n// Normally, this calls `limbs_mul_greater_to_out_basecase` or `limbs_mul_greater_to_out_toom_22`.\n// But when the fraction MUL_TOOM33_THRESHOLD / MUL_TOOM22_THRESHOLD is large, an initially small\n// relative unbalance will become a larger and larger relative unbalance with each recursion (the\n// difference s - t will be invariant over recursive calls). Therefore, we need to call\n// `limbs_mul_greater_to_out_toom_32`.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM22_MUL_REC` from `mpn/generic/toom22_mul.c`, GMP 6.2.1.\nfn limbs_mul_greater_to_out_toom_22_recursive(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if !TOOM22_MAYBE_MUL_TOOM22 || ys_len < MUL_TOOM22_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if xs_len << 2 < 5 * ys_len {\n        limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n    } else if limbs_mul_greater_to_out_toom_32_input_sizes_valid(xs_len, ys_len) {\n        limbs_mul_greater_to_out_toom_32(out, xs, ys, scratch);\n    } else {\n        limbs_mul_greater_to_out(out, xs, ys, scratch);\n    }\n}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_22` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_mul_greater_to_out_toom_22_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize,\n) -> bool {\n    xs_len >= ys_len && xs_len + 1 < ys_len << 1\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_22`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom22_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_22_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let s = xs_len >> 1;\n    let n = xs_len - s;\n    let t = ys_len - n;\n    let len = n << 1;\n    let mut mul_len = limbs_mul_same_length_to_out_toom_22_recursive_scratch_len(n);\n    let n = if s > t {\n        limbs_mul_greater_to_out_toom_22_recursive_scratch_len(s, t)\n    } else {\n        limbs_mul_same_length_to_out_toom_22_recursive_scratch_len(s)\n    };\n    if n > mul_len {\n        mul_len = n;\n    }\n    len + mul_len\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_22_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - `xs`.len() + 1 < 2 * `ys`.len()\n//\n// Approximately, `ys`.len() < `xs`.len() < 2 * `ys`.len().\n//\n// The smallest allowable `xs` length is 2. The smallest allowable `ys` length is also 2.\n//\n// This uses the Toom-22, aka Toom-2, aka Karatsuba algorithm.\n//\n// Evaluate in: -1, 0, Infinity.\n// ```\n// <--s--><--n--->\n//  ______________\n// |_xs1_|__xs0__|\n//  |ys1_|__ys0__|\n//  <-t--><--n--->\n//\n// v_0     = xs0         * ys0         # X(0)   * Y(0)\n// v_neg_1 = (xs0 - xs1) * (ys0 - ys1) # X(-1)  * Y(-1)\n// v_inf   = xs1         * ys1         # X(inf) * Y(inf)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_2 3}) \\approx O(n^{1.585}), but\n// `limbs_mul_same_length_to_out_toom_22_recursive` calls `limbs_mul_greater_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom22_mul` from `mpn/generic/toom22_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_22(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    assert!(xs_len > 1);\n    let ys_len = ys.len();\n    assert_ne!(ys_len, 0);\n    assert!(xs_len >= ys_len);\n    let out = &mut out[..xs_len + ys_len];\n    let s = xs_len >> 1;\n    let n = xs_len - s;\n    assert!(ys_len >= n);\n    let t = ys_len - n;\n    let (xs_0, xs_1) = xs.split_at(n); // xs_0: length n, xs_1: length s\n    let (ys_0, ys_1) = ys.split_at(n); // ys_0: length n, ys_1: length t\n    let mut v_neg_1_neg = false;\n    split_into_chunks_mut!(out, n, [asm1, bsm1], _unused);\n    // Compute bsm1.\n    if s == n {\n        if limbs_cmp_same_length(xs_0, xs_1) == Less {\n            limbs_sub_same_length_to_out(asm1, xs_1, xs_0);\n            v_neg_1_neg = true;\n        } else {\n            limbs_sub_same_length_to_out(asm1, xs_0, xs_1);\n        }\n    } else {\n        // n - s == 1\n        let (xs_0_last, xs_0_init) = xs_0.split_last().unwrap();\n        let (asm1_last, asm1_init) = asm1.split_last_mut().unwrap();\n        if *xs_0_last == 0 && limbs_cmp_same_length(xs_0_init, xs_1) == Less {\n            limbs_sub_same_length_to_out(asm1_init, xs_1, xs_0_init);\n            *asm1_last = 0;\n            v_neg_1_neg = true;\n        } else {\n            *asm1_last = *xs_0_last;\n            if limbs_sub_same_length_to_out(asm1_init, xs_0_init, xs_1) {\n                asm1_last.wrapping_sub_assign(1);\n            }\n        }\n    }\n    // Compute bsm1.\n    if t == n {\n        if limbs_cmp_same_length(ys_0, ys_1) == Less {\n            limbs_sub_same_length_to_out(bsm1, ys_1, ys_0);\n            v_neg_1_neg.not_assign();\n        } else {\n            limbs_sub_same_length_to_out(bsm1, ys_0, ys_1);\n        }\n    } else {\n        let (ys_0_lo, ys_0_hi) = ys_0.split_at(t);\n        if slice_test_zero(ys_0_hi) && limbs_cmp_same_length(ys_0_lo, ys_1) == Less {\n            limbs_sub_same_length_to_out(bsm1, ys_1, ys_0_lo);\n            slice_set_zero(&mut bsm1[t..]);\n            v_neg_1_neg.not_assign();\n        } else {\n            limbs_sub_greater_to_out(bsm1, ys_0, ys_1);\n        }\n    }\n    let (v_neg_1, scratch_out) = scratch.split_at_mut(n << 1);\n    // size: n\n    limbs_mul_same_length_to_out_toom_22_recursive(v_neg_1, asm1, bsm1, scratch_out);\n    let (v_0, v_pos_inf) = out.split_at_mut(n << 1); // v_0: length 2 * n\n    if s > t {\n        // size: s, t\n        limbs_mul_greater_to_out_toom_22_recursive(v_pos_inf, xs_1, ys_1, scratch_out);\n    } else {\n        // size: s\n        limbs_mul_same_length_to_out_toom_22_recursive(v_pos_inf, xs_1, &ys_1[..s], scratch_out);\n    }\n    // size: n\n    limbs_mul_same_length_to_out_toom_22_recursive(v_0, xs_0, ys_0, scratch_out);\n    // L(v_pos_inf) + H(v_pos_inf)\n    let (v_pos_inf_lo, v_pos_inf_hi) = v_pos_inf.split_at_mut(n); // v_pos_inf_lo: length n\n    let (v_0_lo, v_0_hi) = v_0.split_at_mut(n); // v_0_lo: length n, vo_hi: length n\n                                                // H(v_0) + L(v_pos_inf)\n    let mut carry = Limb::from(limbs_slice_add_same_length_in_place_left(\n        v_pos_inf_lo,\n        v_0_hi,\n    ));\n    // L(v_0) + H(v_0)\n    let mut carry2 = carry;\n    if limbs_add_same_length_to_out(v_0_hi, v_pos_inf_lo, v_0_lo) {\n        carry2 += 1;\n    }\n    // - s + t - n == either ys_len - (xs_len >> 1) or ys_len - (xs_len >> 1) - 2.\n    // - n == xs_len - (xs_len >> 1) and xs_len >= ys_len.\n    // - So n >= s + t - n.\n    if limbs_slice_add_greater_in_place_left(v_pos_inf_lo, &v_pos_inf_hi[..s + t - n]) {\n        carry += 1;\n    }\n    let out_lo = &mut out[n..3 * n];\n    if v_neg_1_neg {\n        if limbs_slice_add_same_length_in_place_left(out_lo, v_neg_1) {\n            carry += 1;\n        }\n    } else if limbs_sub_same_length_in_place_left(out_lo, v_neg_1) {\n        carry.wrapping_sub_assign(1);\n    }\n    assert!(!limbs_slice_add_limb_in_place(&mut out[n << 1..], carry2));\n    let out_hi = &mut out[3 * n..];\n    if carry <= 2 {\n        assert!(!limbs_slice_add_limb_in_place(out_hi, carry));\n    } else {\n        assert!(!limbs_sub_limb_in_place(out_hi, 1));\n    }\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_32`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom32_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_32_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = 1 + if xs_len << 1 >= 3 * ys_len {\n        (xs_len - 1) / 3\n    } else {\n        (ys_len - 1) >> 1\n    };\n    let s = xs_len - (n << 1);\n    let t = ys_len - n;\n    2 * n\n        + 1\n        + max(\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_to_out_scratch_len(s, t),\n        )\n}}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_32` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_mul_greater_to_out_toom_32_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize,\n) -> bool {\n    xs_len > ys_len + 1 && (xs_len == 6 || ys_len > 4) && xs_len << 1 < 3 * (ys_len + 1)\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_32_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() > `ys`.len() + 1\n// - 2 * `xs`.len() < 3 * (`ys`.len() + 1)\n// - `xs`.len() == 6 or `ys`.len() > 4\n//\n// Approximately, `ys`.len() < `xs`.len() < 3 / 2 * `ys`.len().\n//\n// The smallest allowable `xs` length is 6. The smallest allowable `ys` length is 4.\n//\n// This uses the Toom-32 aka Toom-2.5 algorithm.\n//\n// Evaluate in: -1, 0, 1, Infinity.\n// ```\n// <-s-><--n--><--n-->\n//  ___________________\n// |xs2_|__xs1_|__xs0_|\n//        |ys1_|__ys0_|\n//        <-t--><--n-->\n//\n// v0   =  xs0              * ys0         # X(0)   * Y(0)\n// v1   = (xs0 + xs1 + xs2) * (ys0 + ys1) # X(1)   * Y(1)    xh  <= 2  yh <= 1\n// vm1  = (xs0 - xs1 + xs2) * (ys0 - ys1) # X(-1)  * Y(-1)  |xh| <= 1  yh = 0\n// vinf =               xs2 * ys1         # X(inf) * Y(inf)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_3 4}) \\approx O(n^{1.262}), but `limbs_mul_same_length_to_out` is\n// called.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom32_mul` from `mpn/generic/toom32_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_32(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let n = 1 + if xs_len << 1 >= 3 * ys_len {\n        (xs_len - 1) / 3\n    } else {\n        (ys_len - 1) >> 1\n    };\n    // Required, to ensure that s + t >= n.\n    assert!(ys_len + 2 <= xs_len && xs_len + 6 <= 3 * ys_len);\n    split_into_chunks!(xs, n, [xs_0, xs_1], xs_2);\n    let s = xs_2.len();\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    split_into_chunks!(ys, n, [ys_0], ys_1);\n    let t = ys_1.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    assert!(s + t >= n);\n    // Product area of size xs_len + ys_len = 3 * n + s + t >= 4 * n + 2.\n    split_into_chunks_mut!(out, n << 1, [out_lo, out_hi], _unused);\n    let (ap1, bp1) = out_lo.split_at_mut(n);\n    let (am1, bm1) = out_hi.split_at_mut(n);\n    // Compute ap1 = xs0 + xs1 + a3, am1 = xs0 - xs1 + a3\n    let mut hi = limbs_add_to_out(ap1, xs_0, xs_2);\n    let mut ap1_hi = Limb::from(hi);\n    let mut v_neg_1_neg = ap1_hi == 0 && limbs_cmp_same_length(ap1, xs_1) == Less;\n    if v_neg_1_neg {\n        assert!(!limbs_sub_same_length_to_out(am1, xs_1, ap1));\n    } else if limbs_sub_same_length_to_out(am1, ap1, xs_1) {\n        hi.not_assign();\n    }\n    if limbs_slice_add_same_length_in_place_left(ap1, xs_1) {\n        ap1_hi += 1;\n    }\n    let bp1_hi;\n    // Compute bp1 = ys0 + ys1 and bm1 = ys0 - ys1.\n    if t == n {\n        bp1_hi = limbs_add_same_length_to_out(bp1, ys_0, ys_1);\n        if limbs_cmp_same_length(ys_0, ys_1) == Less {\n            assert!(!limbs_sub_same_length_to_out(bm1, ys_1, ys_0));\n            v_neg_1_neg.not_assign();\n        } else {\n            assert!(!limbs_sub_same_length_to_out(bm1, ys_0, ys_1));\n        }\n    } else {\n        bp1_hi = limbs_add_to_out(bp1, ys_0, ys_1);\n        let (ys_0_lo, ys_0_hi) = ys_0.split_at(t);\n        if slice_test_zero(ys_0_hi) && limbs_cmp_same_length(ys_0_lo, ys_1) == Less {\n            let (bm1_lo, bm1_hi) = bm1.split_at_mut(t);\n            assert!(!limbs_sub_same_length_to_out(bm1_lo, ys_1, ys_0_lo));\n            slice_set_zero(bm1_hi);\n            v_neg_1_neg.not_assign();\n        } else {\n            assert!(!limbs_sub_greater_to_out(bm1, ys_0, ys_1));\n        }\n    }\n    let m = (n << 1) + 1;\n    let (scratch, mul_scratch) = scratch.split_at_mut(m);\n    // size: n\n    limbs_mul_same_length_to_out(scratch, ap1, bp1, mul_scratch);\n    split_into_chunks_mut!(scratch, n, [_unused, scratch_lo], scratch_hi);\n    let mut carry = 0;\n    match ap1_hi {\n        1 => {\n            if limbs_slice_add_same_length_in_place_left(scratch_lo, bp1) {\n                carry = 1;\n            }\n            if bp1_hi {\n                carry += 1;\n            }\n        }\n        2 => {\n            carry = limbs_slice_add_mul_limb_same_length_in_place_left(scratch_lo, bp1, 2);\n            if bp1_hi {\n                carry += 2;\n            }\n        }\n        _ => {}\n    }\n    if bp1_hi && limbs_slice_add_same_length_in_place_left(scratch_lo, ap1) {\n        carry += 1;\n    }\n    scratch_hi[0] = carry;\n    // size: n\n    limbs_mul_same_length_to_out(out_lo, am1, bm1, mul_scratch);\n    out_hi[0] =\n        Limb::from(hi && limbs_slice_add_same_length_in_place_left(&mut out_lo[n..], bm1));\n    // v1 <-- (v1 + vm1) / 2 = x0 + x2\n    let out_b = &out[..m];\n    if v_neg_1_neg {\n        limbs_sub_same_length_in_place_left(scratch, out_b);\n    } else {\n        limbs_slice_add_same_length_in_place_left(scratch, out_b);\n    }\n    assert_eq!(limbs_slice_shr_in_place(scratch, 1), 0);\n    split_into_chunks_mut!(out, n, [out_0, out_1, out_2], _unused);\n    // We get x1 + x3 = (x0 + x2) - (x0 - x1 + x2 - x3), and hence\n    // ```\n    // y = x1 + x3 + (x0 + x2) * B\n    //   = (x0 + x2) * B + (x0 + x2) - vm1.\n    // ```\n    //\n    // y is 3 * n + 1 limbs, y = y0 + y1 B + y2 B^2. We store them as follows: y0 at scratch, y1 at\n    // out + 2 * n, and y2 at scratch + n (already in place, except for carry propagation).\n    //\n    // We thus add\n    // ```\n    //    B^3  B^2   B    1\n    //     |    |    |    |\n    //    +-----+----+\n    //  + |  x0 + x2 |\n    //    +----+-----+----+\n    //  +      |  x0 + x2 |\n    //         +----------+\n    //  -      |  vm1     |\n    //  --+----++----+----+-\n    //    | y2  | y1 | y0 |\n    //    +-----+----+----+\n    // ```\n    //\n    // Since we store y0 at the same location as the low half of x0 + x2, we need to do the middle\n    // sum first.\n    let mut hi = out_2[0];\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(n);\n    let scratch_hi = &mut scratch_hi[..=n];\n    let (scratch_hi_last, scratch_hi_init) = scratch_hi.split_last().unwrap();\n    let mut x = *scratch_hi_last;\n    if limbs_add_same_length_to_out(out_2, scratch_lo, scratch_hi_init) {\n        x += 1;\n    }\n    assert!(!limbs_slice_add_limb_in_place(scratch_hi, x));\n    if v_neg_1_neg {\n        let carry = limbs_slice_add_same_length_in_place_left(scratch_lo, out_0);\n        // out_lo: length 2 * n\n        if limbs_add_same_length_with_carry_in_in_place_left(out_2, out_1, carry) {\n            hi.wrapping_add_assign(1);\n        }\n        assert!(!limbs_slice_add_limb_in_place(scratch_hi, hi));\n    } else {\n        let carry = limbs_sub_same_length_in_place_left(scratch_lo, out_0);\n        // out_lo: length 2 * n\n        if limbs_sub_same_length_with_borrow_in_in_place_left(out_2, out_1, carry) {\n            hi.wrapping_add_assign(1);\n        }\n        assert!(!limbs_sub_limb_in_place(scratch_hi, hi));\n    }\n    // size: n\n    limbs_mul_same_length_to_out(out, xs_0, ys_0, mul_scratch);\n    // size: s, t\n    limbs_mul_to_out(&mut out[3 * n..], xs_2, ys_1, mul_scratch);\n    // Remaining interpolation.\n    //\n    // ```\n    //    y * B + x0 + x3 B^3 - x0 B^2 - x3 B\n    //    = (x1 + x3) B + (x0 + x2) B^2 + x0 + x3 B^3 - x0 B^2 - x3 B\n    //    = y0 B + y1 B^2 + y3 B^3 + Lx0 + H x0 B\n    //      + L x3 B^3 + H x3 B^4 - Lx0 B^2 - H x0 B^3 - L x3 B - H x3 B^2\n    //    = L x0 + (y0 + H x0 - L x3) B + (y1 - L x0 - H x3) B^2\n    //      + (y2 - (H x0 - L x3)) B^3 + H x3 B^4\n    //\n    //     B^4       B^3       B^2        B         1\n    //  |         |         |         |         |         |\n    //  +-------+                   +---------+---------+\n    //  |  Hx3  |                   | Hx0-Lx3 |    Lx0  |\n    //  +------+----------+---------+---------+---------+\n    //     |    y2    |  y1     |   y0    |\n    //     ++---------+---------+---------+\n    //     -| Hx0-Lx3 | - Lx0   |\n    //      +---------+---------+\n    //             | - Hx3  |\n    //             +--------+\n    // ```\n    // We must take into account the carry from Hx0 - Lx3.\n    split_into_chunks_mut!(out, n, [out_0, out_1, out_2], out_3);\n    let carry = limbs_sub_same_length_in_place_left(out_1, &out_3[..n]);\n    let (scratch_hi_last, scratch_hi_init) = scratch_hi.split_last().unwrap();\n    let mut hi = *scratch_hi_last;\n    if carry {\n        hi.wrapping_add_assign(1);\n    }\n    let borrow = limbs_sub_same_length_with_borrow_in_in_place_left(out_2, out_0, carry);\n    if limbs_sub_same_length_with_borrow_in_to_out(out_3, scratch_hi_init, out_1, borrow) {\n        hi.wrapping_sub_assign(1);\n    }\n    if limbs_slice_add_greater_in_place_left(&mut out[n..n << 2], scratch_lo) {\n        hi.wrapping_add_assign(1);\n    }\n    if s + t > n {\n        split_into_chunks_mut!(out, n << 1, [_unused, out_lo], out_hi);\n        let out_hi = &mut out_hi[..s + t - n];\n        if limbs_sub_greater_in_place_left(out_lo, out_hi) {\n            hi.wrapping_sub_assign(1);\n        }\n        if hi.get_highest_bit() {\n            fail_on_untested_path(\"limbs_mul_greater_to_out_toom_32, hi.get_highest_bit()\");\n            assert!(!limbs_sub_limb_in_place(out_hi, hi.wrapping_neg()));\n        } else {\n            assert!(!limbs_slice_add_limb_in_place(out_hi, hi));\n        }\n    } else {\n        assert_eq!(hi, 0);\n    }\n}}\n\n// TODO tune\n#[cfg(feature = \"test_build\")]\npub const TOOM33_MAYBE_MUL_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || MUL_TOOM33_THRESHOLD < 3 * MUL_TOOM22_THRESHOLD;\n#[cfg(not(feature = \"test_build\"))]\nconst TOOM33_MAYBE_MUL_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || MUL_TOOM33_THRESHOLD < 3 * MUL_TOOM22_THRESHOLD;\n// TODO tune\n#[cfg(feature = \"test_build\")]\n#[allow(clippy::absurd_extreme_comparisons)]\npub const TOOM33_MAYBE_MUL_TOOM33: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || MUL_TOOM44_THRESHOLD >= 3 * MUL_TOOM33_THRESHOLD;\n#[cfg(not(feature = \"test_build\"))]\n#[allow(clippy::absurd_extreme_comparisons)]\nconst TOOM33_MAYBE_MUL_TOOM33: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || MUL_TOOM44_THRESHOLD >= 3 * MUL_TOOM33_THRESHOLD;\n\nfn limbs_mul_same_length_to_out_toom_33_recursive_scratch_len(xs_len: usize) -> usize {\n    if TOOM33_MAYBE_MUL_BASECASE && xs_len < MUL_TOOM22_THRESHOLD {\n        0\n    } else if !TOOM33_MAYBE_MUL_TOOM33 || xs_len < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22_scratch_len(xs_len, xs_len)\n    } else {\n        limbs_mul_greater_to_out_toom_33_scratch_len(xs_len, xs_len)\n    }\n}\n\n// A helper function for `limbs_mul_greater_to_out_toom_33`.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM33_MUL_N_REC` from `mpn/generic/toom33_mul.c`, GMP 6.2.1.\npub_test! {limbs_mul_same_length_to_out_toom_33_recursive(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n = xs.len();\n    assert_eq!(xs.len(), n);\n    if TOOM33_MAYBE_MUL_BASECASE && n < MUL_TOOM22_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if !TOOM33_MAYBE_MUL_TOOM33 || n < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n    } else {\n        limbs_mul_greater_to_out_toom_33(out, xs, ys, scratch);\n    }\n}}\n\n// TODO tune\nconst SMALLER_RECURSION_TOOM_33_AND_53: bool = true;\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_33` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {limbs_mul_greater_to_out_toom_33_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize\n) -> bool {\n    xs_len >= ys_len && xs_len.div_round(3, Ceiling).0 << 1 < ys_len\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_33`.\n//\n// Scratch need is 5 * xs_len / 2 + 10 * k, where k is the recursion depth. We use 3 * xs_len + C,\n// so that we can use a smaller constant.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom33_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_33_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = xs_len.div_round(3, Ceiling).0;\n    let m = n + 1;\n    assert!(m < xs_len);\n    let s = xs_len - (n << 1);\n    let t = ys_len - (n << 1);\n    let st_mul_scratch_len = if s > t {\n        limbs_mul_greater_to_out_scratch_len(s, t)\n    } else {\n        limbs_mul_same_length_to_out_toom_33_recursive_scratch_len(s)\n    };\n    5 * m\n        + max!(\n            limbs_mul_same_length_to_out_toom_33_recursive_scratch_len(m),\n            limbs_mul_same_length_to_out_toom_33_recursive_scratch_len(n),\n            st_mul_scratch_len\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_33_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - 2 * ceiling(`xs`.len() / 3) < `ys`.len()\n//\n// Approximately, `ys`.len() < `xs`.len() < 3 / 2 * `ys`.len().\n//\n// The smallest allowable `xs` length is 3. The smallest allowable `ys` length is also 3.\n//\n// This uses the Toom-33 aka Toom-3 algorithm.\n//\n// Evaluate in: -1, 0, 1, 2, Infinity.\n// ```\n// <--s--><--n--><--n-->\n//  ____________________\n// |_xs2_|__xs1_|__xs0_|\n//  |ys2_|__ys1_|__ys0_|\n//  <-t--><--n--><--n-->\n//\n// v0   =  xs0           *  b0                                 # X(0)   * Y(0)\n// v1   = (xs0 +   * xs1 +  a2)    * (ys0 +  ys1+ ys2)         # X(1)   * Y(1)    xh  <= 2, yh <= 2\n// vm1  = (xs0 -   * xs1 +  a2)    * (ys0 -  ys1+ ys2)         # X(-1)  * Y(-1)  |xh| <= 1, yh <= 1\n// v2   = (xs0 + 2 * xs1 + 4 * a2) * (ys0 + 2 * ys1 + 4 * ys2) # X(2)   * Y(2)    xh  <= 6, yh <= 6\n// vinf =            xs2           *  ys2                      # X(inf) * Y(inf)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_3 5}) \\approx O(n^{1.465}), but\n// `limbs_mul_same_length_to_out_toom_33_recursive` ultimately calls `limbs_mul_greater_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom33_mul` from `mpn/generic/toom33_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_33(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let n = xs_len.div_round(3, Ceiling).0;\n    let m = n + 1;\n    split_into_chunks!(xs, n, [xs_0, xs_1], xs_2);\n    let s = xs_2.len();\n    split_into_chunks!(ys, n, [ys_0, ys_1], ys_2);\n    let t = ys_2.len();\n    assert_ne!(t, 0);\n    split_into_chunks_mut!(out, m, [bs1, as2, bs2], _unused);\n    // we need 4 * n + 4 <= 4 * n + s + t\n    let (v_neg_1, remainder) = scratch.split_at_mut(m << 1);\n    split_into_chunks_mut!(remainder, m, [asm1, bsm1, as1], mul_scratch);\n    let gp = &mut v_neg_1[..n];\n    // Compute as1 and asm1.\n    let mut carry = Limb::from(limbs_add_to_out(gp, xs_0, xs_2));\n    let (as1_last, as1_init) = as1.split_last_mut().unwrap();\n    *as1_last = carry;\n    if limbs_add_same_length_to_out(as1_init, gp, xs_1) {\n        as1_last.wrapping_add_assign(1);\n    }\n    let mut v_neg_1_neg = carry == 0 && limbs_cmp_same_length(gp, xs_1) == Less;\n    let (asm1_last, asm1_init) = asm1.split_last_mut().unwrap();\n    if v_neg_1_neg {\n        limbs_sub_same_length_to_out(asm1_init, xs_1, gp);\n        *asm1_last = 0;\n    } else {\n        if limbs_sub_same_length_to_out(asm1_init, gp, xs_1) {\n            carry.wrapping_sub_assign(1);\n        }\n        *asm1_last = carry;\n    }\n    // Compute as2.\n    let (as2_last, as2_init) = as2.split_last_mut().unwrap();\n    let carry = if s == n {\n        limbs_add_same_length_to_out(as2_init, xs_2, &as1_init[..s])\n    } else if limbs_add_same_length_to_out(as2_init, xs_2, &as1_init[..s]) {\n        limbs_add_limb_to_out(&mut as2_init[s..], &as1_init[s..], 1)\n    } else {\n        as2_init[s..].copy_from_slice(&as1_init[s..]);\n        false\n    };\n    let mut carry = Limb::from(carry)\n        .wrapping_add(*as1_last)\n        .arithmetic_checked_shl(1u64)\n        .unwrap()\n        .wrapping_add(limbs_slice_shl_in_place(as2_init, 1));\n    if limbs_sub_same_length_in_place_left(as2_init, xs_0) {\n        carry.wrapping_sub_assign(1);\n    }\n    *as2_last = carry;\n    // Compute bs1 and bsm1.\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    let mut carry = Limb::from(limbs_add_to_out(gp, ys_0, ys_2));\n    *bs1_last = carry;\n    if limbs_add_same_length_to_out(bs1_init, gp, ys_1) {\n        *bs1_last += 1;\n    }\n    let (bsm1_last, bsm1_init) = bsm1.split_last_mut().unwrap();\n    if carry == 0 && limbs_cmp_same_length(gp, ys_1) == Less {\n        limbs_sub_same_length_to_out(bsm1_init, ys_1, gp);\n        *bsm1_last = 0;\n        v_neg_1_neg.not_assign();\n    } else {\n        if limbs_sub_same_length_to_out(bsm1_init, gp, ys_1) {\n            carry.wrapping_sub_assign(1);\n        }\n        *bsm1_last = carry;\n    }\n    // Compute bs2.\n    let (bs2_last, bs2_init) = bs2.split_last_mut().unwrap();\n    let carry = if t == n {\n        limbs_add_same_length_to_out(bs2_init, &bs1_init[..t], ys_2)\n    } else if limbs_add_same_length_to_out(bs2_init, &bs1_init[..t], ys_2) {\n        limbs_add_limb_to_out(&mut bs2_init[t..], &bs1_init[t..], 1)\n    } else {\n        bs2_init[t..].copy_from_slice(&bs1_init[t..]);\n        false\n    };\n    let mut carry = Limb::from(carry)\n        .wrapping_add(*bs1_last)\n        .arithmetic_checked_shl(1u64)\n        .unwrap()\n        .wrapping_add(limbs_slice_shl_in_place(bs2_init, 1));\n    if limbs_sub_same_length_in_place_left(bs2_init, ys_0) {\n        carry.wrapping_sub_assign(1);\n    }\n    *bs2_last = carry;\n    assert!(*as1_last <= 2);\n    assert!(*bs1_last <= 2);\n    assert!(*asm1_last <= 1);\n    assert!(*bsm1_last <= 1);\n    assert!(*as2_last <= 6);\n    assert!(*bs2_last <= 6);\n    if SMALLER_RECURSION_TOOM_33_AND_53 {\n        // size: n\n        limbs_mul_same_length_to_out_toom_33_recursive(v_neg_1, asm1_init, bsm1_init, mul_scratch);\n        let (v_neg_1_last, v_neg_1_init) = v_neg_1[n..=n<<1].split_last_mut().unwrap();\n        let mut carry = 0;\n        if *asm1_last != 0 {\n            carry = *bsm1_last;\n            if limbs_slice_add_same_length_in_place_left(v_neg_1_init, bsm1_init) {\n                carry.wrapping_add_assign(1);\n            }\n        }\n        if *bsm1_last != 0 && limbs_slice_add_same_length_in_place_left(v_neg_1_init, asm1_init) {\n            carry.wrapping_add_assign(1);\n        }\n        *v_neg_1_last = carry;\n    } else {\n        fail_on_untested_path(\"limbs_mul_greater_to_out_toom_33, !SMALLER_RECURSION\");\n        // size: m\n        limbs_mul_same_length_to_out_toom_33_recursive(v_neg_1, asm1, bsm1, mul_scratch);\n    }\n    let (v_2, mul_scratch) = scratch[2 * n + 1..].split_at_mut(3 * n + 4);\n    // size: m\n    limbs_mul_same_length_to_out_toom_33_recursive(v_2, as2, bs2, mul_scratch);\n    let v_inf = &mut out[n << 2..];\n    // v_inf, s + t limbs\n    if s > t {\n        // size: s, t\n        limbs_mul_greater_to_out(v_inf, xs_2, ys_2, mul_scratch);\n    } else {\n        // size: s\n        limbs_mul_same_length_to_out_toom_33_recursive(v_inf, xs_2, &ys_2[..s], mul_scratch);\n    }\n    let v_inf0 = v_inf[0]; // v1 overlaps with this\n    let (as1, mul_scratch) = scratch[m << 2..].split_at_mut(m);\n    let (bs1, v_1) = out.split_at_mut(n << 1);\n    let bs1 = &bs1[..m];\n    if SMALLER_RECURSION_TOOM_33_AND_53 {\n        let (as1_last, as1_init) = as1.split_last().unwrap();\n        let (bs1_last, bs1_init) = bs1.split_last().unwrap();\n        // size: n\n        limbs_mul_same_length_to_out_toom_33_recursive(v_1, as1_init, bs1_init, mul_scratch);\n        let (v_1_lo, v_1_hi) = v_1[n..].split_at_mut(n);\n        let mut carry = 0;\n        if *as1_last == 1 {\n            carry = *bs1_last;\n            if limbs_slice_add_same_length_in_place_left(v_1_lo, bs1_init) {\n                carry += 1;\n            }\n        } else if *as1_last != 0 {\n            carry = bs1_last.arithmetic_checked_shl(1).unwrap();\n            carry.wrapping_add_assign(limbs_slice_add_mul_limb_same_length_in_place_left(\n                v_1_lo, bs1_init, 2,\n            ));\n        }\n        if *bs1_last == 1 {\n            if limbs_slice_add_same_length_in_place_left(v_1_lo, as1_init) {\n                carry += 1;\n            }\n        } else if *bs1_last != 0 {\n            carry += limbs_slice_add_mul_limb_same_length_in_place_left(v_1_lo, as1_init, 2);\n        }\n        v_1_hi[0] = carry;\n    } else {\n        let carry = v_1[2 * n + 1];\n        // size: m\n        limbs_mul_same_length_to_out_toom_33_recursive(v_1, as1, bs1, mul_scratch);\n        v_1[2 * n + 1] = carry;\n    }\n    // size: n\n    limbs_mul_same_length_to_out_toom_33_recursive(out, &xs[..n], &ys[..n], mul_scratch);\n    let (v_neg_1, v_2) = scratch.split_at_mut(2 * n + 1);\n    limbs_mul_toom_interpolate_5_points(out, v_2, v_neg_1, n, s + t, v_neg_1_neg, v_inf0);\n}}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_42` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {\n    limbs_mul_greater_to_out_toom_42_input_sizes_valid(xs_len: usize, ys_len: usize) -> bool {\n    !(xs_len == 9 && ys_len == 4)\n        && xs_len + 3 < ys_len << 2\n        && xs_len.div_round(3, Ceiling).0\n            > ys_len.shr_round(1, Ceiling).0\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_42`.\n//\n// This is equivalent to `mpn_toom42_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_crate_test! {limbs_mul_greater_to_out_toom_42_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = if xs_len >= ys_len << 1 {\n        xs_len.shr_round(2, Ceiling).0\n    } else {\n        ys_len.shr_round(1, Ceiling).0\n    };\n    let s = xs_len - 3 * n;\n    let t = ys_len - n;\n    assert!(n + 1 < xs_len);\n    10 * n\n        + 8\n        + max!(\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_same_length_to_out_scratch_len(n + 1),\n            limbs_mul_to_out_scratch_len(s, t)\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_42_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - ceiling(`xs`.len() / 3) > ceiling(`ys`.len() / 2)\n// - `xs`.len() + 3 < 4 * `ys`.len()\n// - (`xs`.len(), `ys`.len()) != (9, 4)\n//\n// Approximately, 3 / 2 * `ys`.len() < `xs`.len() < 4 * `ys`.len().\n//\n// The smallest allowable `xs` length is 4. The smallest allowable `ys` length is 2.\n//\n// This uses the Toom-42 algorithm.\n//\n// Evaluate in: -1, 0, 1, 2, Infinity.\n// ```\n// <-s--><--n---><--n---><--n--->\n//  _____________________________\n// |xs3_|__xs2__|__xs1__|__xs0__|\n//               |_ys1__|__ys0__|\n//               <--t--><---n--->\n//\n// v_0     =  xs0                          *  ys0          # X(0)  * Y(0)\n// v_1     = (xs0 +   xs1 +   xs2 +   xs3) * (ys0 + ys1)   # X(1)  * Y(1)   xh  <= 3  yh <= 1\n// v_neg_1 = (xs0 -   xs1 +   xs2 -   xs3) * (ys0 - ys1)   # X(-1) * Y(-1) |xh| <= 1  yh  = 0\n// v_2     = (xs0 + 2*xs1 + 4*xs2 + 8*xs3) * (ys0 + 2*ys1) # X(2)  * Y(2)   xh  <= 14 yh <= 2\n// v_inf   =  xs3 *     b1  # A(inf)*B(inf)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_4 5}) \\approx O(n^{1.161}), but `limbs_mul_same_length_to_out` is\n// called.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom42_mul` from `mpn/generic/toom42_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_42(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let n = if xs_len >= ys_len << 1 {\n        xs_len.shr_round(2, Ceiling).0\n    } else {\n        ys_len.shr_round(1, Ceiling).0\n    };\n    split_into_chunks!(xs, n, [xs_0, xs_1, xs_2], xs_3);\n    let s = xs_3.len();\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    split_into_chunks!(ys, n, [ys_0], ys_1);\n    let t = ys_1.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    let (scratch, mul_scratch) = scratch.split_at_mut(10 * n + 8);\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(6 * n + 5);\n    split_into_chunks_mut!(scratch_lo, n + 1, [as1, asm1, as2, bs1], remainder);\n    let (bsm1, bs2) = remainder.split_at_mut(n);\n    // Compute as1 and asm1.\n    let mut v_neg_1_neg =\n        limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(as1, asm1, xs, n, &mut out[..=n]);\n    // Compute as2.\n    let (as2_last, as2_init) = as2.split_last_mut().unwrap();\n    let mut carry = limbs_shl_to_out(as2_init, xs_3, 1);\n    if limbs_slice_add_same_length_in_place_left(&mut as2_init[..s], &xs_2[..s]) {\n        carry += 1;\n    }\n    if s != n {\n        carry = Limb::from(limbs_add_limb_to_out(&mut as2_init[s..], &xs_2[s..], carry));\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(as2_init, 1));\n    if limbs_slice_add_same_length_in_place_left(as2_init, xs_1) {\n        carry += 1;\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(as2_init, 1));\n    if limbs_slice_add_same_length_in_place_left(as2_init, xs_0) {\n        carry += 1;\n    }\n    *as2_last = carry;\n    // Compute bs1 and bsm1.\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    if t == n {\n        *bs1_last = Limb::from(limbs_add_same_length_to_out(bs1_init, ys_0, ys_1));\n        if limbs_cmp_same_length(ys_0, ys_1) == Less {\n            limbs_sub_same_length_to_out(bsm1, ys_1, ys_0);\n            v_neg_1_neg.not_assign();\n        } else {\n            limbs_sub_same_length_to_out(bsm1, ys_0, ys_1);\n        }\n    } else {\n        *bs1_last = Limb::from(limbs_add_to_out(bs1_init, ys_0, ys_1));\n        if slice_test_zero(&ys_0[t..]) && limbs_cmp_same_length(&ys_0[..t], ys_1) == Less\n        {\n            limbs_sub_same_length_to_out(bsm1, ys_1, &ys_0[..t]);\n            slice_set_zero(&mut bsm1[t..]);\n            v_neg_1_neg.not_assign();\n        } else {\n            limbs_sub_greater_to_out(bsm1, ys_0, ys_1);\n        }\n    }\n    // Compute bs2, recycling bs1. bs2 = bs1 + ys_1\n    limbs_add_to_out(bs2, bs1, ys_1);\n    let (as1_last, as1_init) = as1.split_last().unwrap();\n    let (bs1_last, bs1_init) = bs1.split_last().unwrap();\n    let (asm1_last, asm1_init) = asm1.split_last().unwrap();\n    assert!(*as1_last <= 3);\n    assert!(*bs1_last <= 1);\n    assert!(*asm1_last <= 1);\n    assert!(*as2_last <= 14);\n    assert!(bs2[n] <= 2);\n    let (v_neg_1, v_2) = scratch_hi.split_at_mut(2 * n + 1);\n    split_into_chunks_mut!(out, n << 1, [v_0, v_1], v_inf);\n    // size: n\n    limbs_mul_same_length_to_out(v_neg_1, asm1_init, bsm1, mul_scratch);\n    let (v_neg_1_last, v_neg_1_init) = v_neg_1.split_last_mut().unwrap();\n    *v_neg_1_last = Limb::from(\n        *asm1_last != 0 && limbs_slice_add_same_length_in_place_left(&mut v_neg_1_init[n..], bsm1),\n    );\n    // size: n + 1\n    limbs_mul_same_length_to_out(v_2, as2, bs2, mul_scratch);\n    // size: s, t\n    limbs_mul_to_out(v_inf, xs_3, ys_1, mul_scratch);\n    // size: n\n    limbs_mul_same_length_to_out(v_1, as1_init, bs1_init, mul_scratch);\n    let v_1 = &mut v_1[n..];\n    let mut carry = match *as1_last {\n        1 => {\n            let mut carry = *bs1_last;\n            if limbs_slice_add_same_length_in_place_left(v_1, bs1_init) {\n                carry += 1;\n            }\n            carry\n        }\n        2 => (*bs1_last << 1).wrapping_add(limbs_slice_add_mul_limb_same_length_in_place_left(\n            v_1, bs1_init, 2,\n        )),\n        3 => bs1_last.wrapping_mul(3).wrapping_add(\n            limbs_slice_add_mul_limb_same_length_in_place_left(v_1, bs1_init, 3),\n        ),\n        _ => *v_neg_1_last,\n    };\n    if *bs1_last != 0 && limbs_slice_add_same_length_in_place_left(v_1, as1_init) {\n        carry += 1;\n    }\n    let v_inf_0 = v_inf[0]; // v_1 overlaps with this\n    v_inf[0] = carry;\n    // size: n\n    limbs_mul_same_length_to_out(v_0, xs_0, ys_0, mul_scratch);\n    limbs_mul_toom_interpolate_5_points(out, v_2, v_neg_1, n, s + t, v_neg_1_neg, v_inf_0);\n}}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_43` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {\n    limbs_mul_greater_to_out_toom_43_input_sizes_valid(xs_len: usize, ys_len: usize) -> bool {\n    !(xs_len == 16 && ys_len == 13)\n        && xs_len.div_round(3, Ceiling).0\n            > ys_len.div_round(3, Ceiling).0\n        && {\n            let xs_len_div_4: usize = xs_len.shr_round(2, Ceiling).0;\n            xs_len_div_4 < ys_len.shr_round(1, Ceiling).0\n                && xs_len + ys_len >= 5 * (xs_len_div_4 + 1)\n        }\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_43`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom43_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_43_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = 1 + if 3 * xs_len >= ys_len << 2 {\n        (xs_len - 1) >> 2\n    } else {\n        (ys_len - 1) / 3\n    };\n    let s = xs_len - 3 * n;\n    let t = ys_len - (n << 1);\n    assert!(n + 1 < xs_len);\n    6 * n\n        + 4\n        + max!(\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_same_length_to_out_scratch_len(n + 1),\n            limbs_mul_to_out_scratch_len(s, t)\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_43_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - ceiling(`xs`.len() / 3) > ceiling(`ys`.len() / 3)\n// - ceiling(`xs`.len() / 4) < ceiling(`ys`.len() / 2)\n// - (`xs`.len(), `ys`.len()) != (16, 13)\n// - `xs`.len() + `ys`.len() >= 5 * (ceiling(`xs`.len() / 4) + 1)\n//\n// Approximately, `ys`.len() < `xs`.len() < 2 * `ys`.len().\n//\n// The smallest allowable `xs` length is 11. The smallest allowable `ys` length is 8.\n//\n// This uses the Toom-43 algorithm.\n// ```\n// <-s--><--n--><--n--><--n-->\n//  __________________________\n// |xs3_|__xs2_|__xs1_|__xs0_|\n//       |_ys2_|__ys1_|__ys0_|\n//       <-t--><--n--><--n-->\n//\n// v_0     =  xs0                          * ys0                   # X(0) *Y(0)\n// v_1     = (xs0 +   xs1 +   xs2 +   xs3) * (ys0 +   ys1 +   ys2) # X(1) *Y(1)   xh  <= 3  yh <= 2\n// v_neg_1 = (xs0 -   xs1 +   xs2 -   xs3) * (ys0 -   ys1 +   ys2) # X(-1)*Y(-1) |xh| <= 1 |yh|<= 1\n// v_2     = (xs0 + 2*xs1 + 4*xs2 + 8*xs3) * (ys0 + 2*ys1 + 4*ys2) # X(2) *Y(2)   xh  <= 14 yh <= 6\n// v_neg_2 = (xs0 - 2*xs1 + 4*xs2 - 8*xs3) * (ys0 - 2*ys1 + 4*ys2) # X(-2)*Y(-2) |xh| <= 9 |yh|<= 4\n// v_inf   =                          xs3 *                   ys2  # X(inf)*Y(inf)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_4 6}) \\approx O(n^{1.292}), but this function calls\n// `limbs_mul_same_length_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom43_mul` from `mpn/generic/toom43_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_43(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let n = 1 + if 3 * xs_len >= ys_len << 2 {\n        (xs_len - 1) >> 2\n    } else {\n        (ys_len - 1) / 3\n    };\n    let xs_3 = &xs[3 * n..];\n    let s = xs_3.len();\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    split_into_chunks!(ys, n, [ys_0, ys_1], ys_2);\n    let t = ys_2.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    // This is probably true whenever `xs_len` >= 25 or `ys_len` >= 19. It guarantees that we can\n    // fit 5 values of size n + 1 in the product area.\n    assert!(s + t >= 5);\n    let m = n + 1;\n    let mut v_neg_1_neg = false;\n    let mut v_neg_2_neg = false;\n    split_into_chunks_mut!(out, m, [bs1, bsm2, bs2, as2, as1], _unused);\n    let (scratch, mul_scratch) = scratch.split_at_mut(6 * n + 4);\n    split_into_chunks_mut!(scratch, m, [small_scratch, _unused, bsm1, asm1], asm2);\n    // Compute as2 and asm2.\n    if limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2(as2, asm2, xs, n, asm1) {\n        v_neg_2_neg = true;\n    }\n    // Compute bs2 and bsm2.\n    bsm1[n] = limbs_shl_to_out(bsm1, ys_1, 1); // 2 * ys_1\n    let mut carry = limbs_shl_to_out(small_scratch, ys_2, 2); // 4 * ys_2\n    if limbs_slice_add_same_length_in_place_left(&mut small_scratch[..t], &ys_0[..t]) {\n        carry += 1;\n    }\n    // 4 * ys_2 + ys_0\n    if t != n {\n        carry = Limb::from(limbs_add_limb_to_out(\n            &mut small_scratch[t..],\n            &ys_0[t..],\n            carry,\n        ));\n    }\n    small_scratch[n] = carry;\n    limbs_add_same_length_to_out(bs2, small_scratch, bsm1);\n    if limbs_cmp_same_length(small_scratch, bsm1) == Less {\n        limbs_sub_same_length_to_out(bsm2, bsm1, small_scratch);\n        v_neg_2_neg.not_assign();\n    } else {\n        limbs_sub_same_length_to_out(bsm2, small_scratch, bsm1);\n    }\n    // Compute as1 and asm1.\n    if limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(as1, asm1, xs, n, small_scratch) {\n        v_neg_1_neg = true;\n    }\n    let (bsm1_last, bsm1_init) = bsm1.split_last_mut().unwrap();\n    // Compute bs1 and bsm1.\n    *bsm1_last = Limb::from(limbs_add_to_out(bsm1_init, ys_0, ys_2));\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    *bs1_last = *bsm1_last;\n    if limbs_add_same_length_to_out(bs1_init, bsm1_init, ys_1) {\n        *bs1_last += 1;\n    }\n    if *bsm1_last == 0 && limbs_cmp_same_length(bsm1_init, ys_1) == Less {\n        limbs_sub_same_length_in_place_right(ys_1, bsm1_init);\n        v_neg_1_neg.not_assign();\n    } else if limbs_sub_same_length_in_place_left(bsm1_init, ys_1) {\n        bsm1_last.wrapping_sub_assign(1);\n    }\n    assert!(as1[n] <= 3);\n    assert!(*bs1_last <= 2);\n    assert!(asm1[n] <= 1);\n    assert!(*bsm1_last <= 1);\n    assert!(as2[n] <= 14);\n    assert!(bs2[n] <= 6);\n    assert!(asm2[n] <= 9);\n    assert!(bsm2[n] <= 4);\n    let (v_neg_1, remainder) = scratch.split_at_mut(m << 1);\n    split_into_chunks_mut!(remainder, m, [bsm1, asm1], _unused);\n    // size: m\n    limbs_mul_same_length_to_out(v_neg_1, asm1, bsm1, mul_scratch); // W4\n    let two_n = n << 1;\n    let (v_neg_2, asm2) = scratch[two_n + 1..].split_at_mut(two_n + 3);\n    split_into_chunks_mut!(out, m, [_unused, out_lo, bs2, as2], _unused);\n    // size: m\n    limbs_mul_same_length_to_out(v_neg_2, &asm2[..m], out_lo, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out(&mut scratch[(n << 2) + 2..], as2, bs2, mul_scratch);\n    let (bs1, remainder) = out.split_at_mut(two_n);\n    let (v_1, as1) = remainder.split_at_mut(two_n + 4);\n    // size: m\n    limbs_mul_same_length_to_out(v_1, &as1[..m], &bs1[..m], mul_scratch);\n    // size: s, t\n    limbs_mul_to_out(&mut out[5 * n..], xs_3, ys_2, mul_scratch);\n    // size: n\n    limbs_mul_same_length_to_out(&mut out[..two_n], &xs[..n], ys_0, mul_scratch);\n    split_into_chunks_mut!(scratch, two_n + 1, [v_neg_1, v_neg_2, v_2], _unused);\n    limbs_mul_toom_interpolate_6_points(\n        out,\n        n,\n        t + s,\n        v_neg_1_neg,\n        v_neg_1,\n        v_neg_2_neg,\n        v_neg_2,\n        v_2,\n    );\n}}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_44` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {limbs_mul_greater_to_out_toom_44_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize\n) -> bool {\n    xs_len >= ys_len && 3usize * xs_len.shr_round(2, Ceiling).0 < ys_len\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_44`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom44_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_44_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = xs_len.shr_round(2, Ceiling).0;\n    let s = xs_len - 3 * n;\n    let t = ys_len - 3 * n;\n    assert!(n + 1 < xs_len);\n    let alt_mul_scratch_len = if s > t {\n        limbs_mul_greater_to_out_scratch_len(s, t)\n    } else {\n        limbs_mul_same_length_to_out_scratch_len(s)\n    };\n    max(\n        9 * n\n            + 6\n            + max!(\n                limbs_mul_same_length_to_out_scratch_len(n),\n                limbs_mul_same_length_to_out_scratch_len(n + 1),\n                alt_mul_scratch_len\n            ),\n        (n << 3) + 6usize + max(n << 1, s + t),\n    )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_44_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - 3 * ceiling(`xs`.len() / 4) < `ys`.len()\n//\n// Approximately, `ys`.len() < `xs`.len() < 4 / 3 * `ys`.len().\n//\n// The smallest allowable `xs` length is 4. The smallest allowable `ys` length is also 4.\n//\n// This uses the Toom-44 algorithm.\n//\n// Evaluate in: 0, 1, -1, 2, -2, 1 / 2, Infinity.\n// ```\n// <-s--><--n--><--n--><--n-->\n//  __________________________\n// |_xs3|__xs2_|__xs1_|__xs0_|\n//  |ys3|__ys2_|__ys1_|__ys0_|\n//  <-t-><--n--><--n--><--n-->\n//\n// v_0     =   x0             *  y0              #   X(0)*Y(0)\n// v_1     = ( x0+ x1+ x2+ x3)*( y0+ y1+ y2+ y3) #   X(1)*Y(1)    xh  <= 3   yh  <= 3\n// v_neg_1 = ( x0- x1+ x2- x3)*( y0- y1+ y2- y3) #  X(-1)*Y(-1)  |xh| <= 1  |yh| <= 1\n// v_2     = ( x0+2x1+4x2+8x3)*( y0+2y1+4y2+8y3) #   X(2)*Y(2)    xh  <= 14  yh  <= 14\n// v_neg_2 = ( x0-2x1+4x2-8x3)*( y0-2y1+4y2-8y3) #   X(2)*Y(2)    xh  <= 9  |yh| <= 9\n// v_half  = (8x0+4x1+2x2+ x3)*(8y0+4y1+2y2+ y3) # X(1/2)*Y(1/2)  xh  <= 14  yh  <= 14\n// v_inf   =               x3 *          y2      # X(inf)*Y(inf)\n// ```\n//\n// Use of scratch space: In the product area, we store\n// ```\n//    _______________________\n//   |v_inf|____|_v_1_|_v_0_|\n//    s+t   2n-1  2n+1  2n\n// ```\n//\n// The other recursive products, v_neg_1, v_2, v_neg_2, and v_half, are stored in the scratch area.\n// When computing them, we use the product area for intermediate values.\n//\n// Next, we compute v_1. We can store the intermediate factors at v_0 and at v_half + 2 * n + 2.\n//\n// Finally, for v_0 and v_inf, factors are parts of the input operands, and we need scratch space\n// only for the recursive multiplication.\n//\n// In all, if S(xs_len) is the scratch need, the needed space is bounded by\n//\n// S(xs_len) <= 4 (2 * ceil(xs_len / 4) + 1) + 1 + S(ceil(xs_len / 4) + 1)\n//\n// which should give S(n) = 8 * n / 3 + c * log(n) for some constant c.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_4 7}) \\approx O(n^{1.404}), but\n// `limbs_mul_same_length_to_out_toom_44_recursive` calls `limbs_mul_same_length_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom44_mul` from `mpn/generic/toom44_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_44(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let n = xs_len.shr_round(2, Ceiling).0;\n    let m = 2 * n + 1;\n    split_into_chunks!(xs, n, [xs_0, xs_1, xs_2], xs_3);\n    let s = xs_3.len();\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    split_into_chunks!(ys, n, [ys_0, ys_1, ys_2], ys_3);\n    let t = ys_3.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    let k = n + 1;\n    // NOTE: The multiplications to v_2, v_neg_2, v_half, and v_neg_1 overwrite the following limb,\n    // so these must be computed in order, and we need a one limb gap to scratch2. apx and bpx must\n    // not overlap with v1\n    split_into_chunks_mut!(out, k, [apx, amx], remainder);\n    let (bmx, bpx) = remainder.split_at_mut(n << 1);\n    let bmx = &mut bmx[..k];\n    let bpx = &mut bpx[..k];\n    // Total scratch need: 8 * n + 5 + scratch for recursive calls. This gives roughly 32 * n / 3 +\n    // log term.\n    let (scratch_lo, mul_scratch) = scratch.split_at_mut(9 * n + 6);\n    let (v_2, scratch_hi) = scratch_lo.split_at_mut((n << 3) + 5);\n    let scratch_hi = &mut scratch_hi[..k];\n    // Compute apx = xs_0 + 2 * xs_1 + 4 * xs_2 + 8 xs_3 and amx = xs_0 - 2 * xs_1 + 4 * xs_2 - 8 *\n    // xs_3.\n    let mut w1_neg =\n        limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2(&mut apx[..k], amx, xs, n, scratch_hi);\n    // Compute bpx = ys_0 + 2 * ys_1 + 4 * ys_2 + 8 * ys_3 and bmx = ys_0 - 2 * ys_1 + 4 * ys_2 - 8\n    // * ys_3.\n    if limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2(bpx, bmx, ys, n, scratch_hi) {\n        w1_neg.not_assign();\n    }\n    // size: n + 1\n    limbs_mul_same_length_to_out(v_2, apx, bpx, mul_scratch);\n    // size: n + 1\n    limbs_mul_same_length_to_out(&mut scratch_lo[m..], amx, bmx, mul_scratch);\n    // Compute apx = 8 * xs_0 + 4 * xs_1 + 2 * xs_2 + xs_3 = (((2 * xs_0 + xs_1) * 2 + xs_2) * 2 +\n    // xs_3\n    let (apx_last, apx_init) = apx.split_last_mut().unwrap();\n    let mut carry = limbs_shl_to_out(apx_init, xs_0, 1);\n    if limbs_slice_add_same_length_in_place_left(apx_init, xs_1) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(apx_init, 1));\n    if limbs_slice_add_same_length_in_place_left(apx_init, xs_2) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    *apx_last = carry.wrapping_add(limbs_slice_shl_in_place(apx_init, 1));\n    if limbs_slice_add_greater_in_place_left(apx_init, xs_3) {\n        apx_last.wrapping_add_assign(1);\n    }\n    // Compute bpx = 8 ys_0 + 4 ys_1 + 2 ys_2 + ys_3 = (((2*ys_0 + ys_1) * 2 + ys_2) * 2 + ys_3\n    let (bpx_last, bpx_init) = bpx.split_last_mut().unwrap();\n    let mut carry = limbs_shl_to_out(bpx_init, ys_0, 1);\n    if limbs_slice_add_same_length_in_place_left(bpx_init, ys_1) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(bpx_init, 1));\n    if limbs_slice_add_same_length_in_place_left(bpx_init, ys_2) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    *bpx_last = carry.wrapping_add(limbs_slice_shl_in_place(bpx_init, 1));\n    if limbs_slice_add_greater_in_place_left(bpx_init, ys_3) {\n        bpx_last.wrapping_add_assign(1);\n    }\n    assert!(*apx_last < 15);\n    assert!(*bpx_last < 15);\n    let (v_half, scratch_hi) = scratch_lo[m << 1..].split_at_mut((n << 2) + 3);\n    let scratch_hi = &mut scratch_hi[..k];\n    // size: n + 1\n    limbs_mul_same_length_to_out(v_half, apx, bpx, mul_scratch);\n    // Compute apx = xs_0 + xs_1 + xs_2 + xs_3 and amx = xs_0 - xs_1 + xs_2 - xs_3.\n    let mut w3_neg = limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(apx, amx, xs, n, scratch_hi);\n    // Compute bpx = ys_0 + ys_1 + ys_2 + ys_3 and bmx = ys_0 - ys_1 + ys_2 - ys_3.\n    if limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(bpx, bmx, ys, n, scratch_hi) {\n        w3_neg.not_assign();\n    }\n    // size: n + 1\n    limbs_mul_same_length_to_out(&mut scratch_lo[3 * m..], amx, bmx, mul_scratch);\n    let (apx, remainder) = out.split_at_mut(n << 1);\n    let (v_1, bpx) = remainder.split_at_mut(m + 1);\n    // - Clobbers amx, bmx.\n    // - size: n + 1\n    limbs_mul_same_length_to_out(v_1, &apx[..k], &bpx[..k], mul_scratch);\n    let (v_0, v_inf) = out.split_at_mut(n << 1); // v_0 length: 2 * n\n    let v_inf = &mut v_inf[n << 2..];\n    // size: n\n    limbs_mul_same_length_to_out(v_0, xs_0, ys_0, mul_scratch);\n    if s > t {\n        // size: s, t\n        limbs_mul_greater_to_out(v_inf, xs_3, ys_3, mul_scratch);\n    } else {\n        // size: s, s\n        limbs_mul_same_length_to_out(v_inf, xs_3, ys_3, mul_scratch);\n    }\n    split_into_chunks_mut!(scratch, m, [v_2, v_neg_2, v_half], remainder);\n    let (v_neg_1, scratch_hi) = remainder.split_at_mut(m + 1);\n    limbs_mul_toom_interpolate_7_points(\n        out,\n        n,\n        s + t,\n        w1_neg,\n        v_neg_2,\n        w3_neg,\n        &mut v_neg_1[..m],\n        v_2,\n        v_half,\n        scratch_hi,\n    );\n}}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_52` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {\n    limbs_mul_greater_to_out_toom_52_input_sizes_valid(xs_len: usize, ys_len: usize) -> bool {\n    xs_len + 4 < 5 * ys_len\n        && xs_len.shr_round(2, Ceiling).0\n            > ys_len.shr_round(1, Ceiling).0\n        && xs_len + ys_len >= 5 * (xs_len.div_round(5, Ceiling).0 + 1)\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_52`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom52_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_test! {limbs_mul_greater_to_out_toom_52_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = 1 + if xs_len << 1 >= 5 * ys_len {\n        (xs_len - 1) / 5\n    } else {\n        (ys_len - 1) >> 1\n    };\n    let s = xs_len - (n << 2);\n    let t = ys_len - n;\n    let m = n + 1;\n    assert!(m < xs_len);\n    6 * n\n        + 4\n        + max!(\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_same_length_to_out_scratch_len(m),\n            limbs_mul_greater_to_out_scratch_len(m, n),\n            limbs_mul_to_out_scratch_len(s, t)\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_52_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - ceiling(`xs`.len() / 4) > ceiling(`ys`.len() / 2)\n// - `xs`.len() + 4 < 5 * `ys`.len()\n// - `xs`.len() + `ys`.len() >= 5 * (ceiling(`xs`.len() / 5) + 1)\n//\n// Approximately, 2 * `ys`.len() < `xs`.len() < 5 * `ys`.len().\n//\n// The smallest allowable `xs` length is 14. The smallest allowable `ys` length is 5.\n//\n// This uses the Toom-52 algorithm.\n//\n// Evaluate in: -2, -1, 0, 1, 2, Infinity.\n// ```\n// <-s--><--n--><--n--><--n--><--n-->\n//  _________________________________\n// |xs4_|__xs3_|__xs2_|__xs1_|__xs0_|\n//                       |ys1|__ys0_|\n//                       <-t-><--n-->\n//\n// v_0     =  xs0                               * ys0          # X(0)   * Y(0)\n// v_1     = (xs0 +  xs1 +  xs2 +  xs3 +   xs4) * (ys0 +  ys1) # X(1)   * Y(1)   xh  <= 4   yh <= 1\n// v_neg_1 = (xs0 -  xs1 +  xs2 -  xs3 +   xs4) * (ys0 -  ys1) # X(-1)  * Y(-1) |xh| <= 2   yh  = 0\n// v_2     = (xs0 + 2xs1 + 4xs2 + 8xs3 + 16xs4) * (ys0 + 2ys1) # X(2)   * Y(2)   xh  <= 30  yh <= 2\n// v_neg_2 = (xs0 - 2xs1 + 4xs2 - 8xs3 + 16xs4) * (ys0 - 2ys1) # X(-2)  * Y(-2) |xh| <= 20 |yh|<= 1\n// v_inf   =                               xs4  *         ys1  # X(inf) * Y(inf)\n// ```\n//\n// Some slight optimization in evaluation are taken from the paper: \"Towards Optimal Toom-Cook\n// Multiplication for Univariate and Multivariate Polynomials in Characteristic 2 and 0.\"\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_5 6}) \\approx O(n^{1.113}), but this function calls\n// `limbs_mul_same_length_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom52_mul` from `mpn/generic/toom52_mul.c`, GMP 6.2.1.\npub_test! {limbs_mul_greater_to_out_toom_52(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let n = 1 + if xs_len << 1 >= 5 * ys_len {\n        (xs_len - 1) / 5\n    } else {\n        (ys_len - 1) >> 1\n    };\n    let (ys_0, ys_1) = ys.split_at(n);\n    let t = ys_1.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    let s = xs_len - (n << 2);\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    // Ensures that 5 values of n + 1 limbs each fits in the product area. Borderline cases are\n    // xs_len = 32, ys_len = 8, n = 7, and xs_len = 36, ys_len = 9, n = 8.\n    assert!(s + t >= 5);\n    // - Scratch need is 6 * n + 4. We need one extra limb, because products will overwrite 2 * n +\n    //   2 limbs.\n    // - Compute as2 and asm2.\n    let mut v_neg_1_neg = false;\n    let m = n + 1;\n    let (scratch, mul_scratch) = scratch.split_at_mut(6 * n + 4);\n    split_into_chunks_mut!(out, m, [bs1, bsm2, bs2, as2, as1], _unused);\n    let (v_neg_1, scratch_hi) = scratch.split_at_mut(m << 1);\n    split_into_chunks_mut!(scratch_hi, m, [bsm1, asm1, asm2], _unused);\n    let bsm1 = &mut bsm1[..n];\n    let mut v_neg_2_neg = limbs_mul_toom_evaluate_poly_in_2_and_neg_2(as2, asm2, 4, xs, n, asm1);\n    // Compute bs1 and bsm1.\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    *bs1_last = 0;\n    if t == n {\n        if limbs_add_same_length_to_out(bs1_init, ys_0, ys_1) {\n            *bs1_last = 1;\n        }\n        if limbs_cmp_same_length(ys_0, ys_1) == Less {\n            limbs_sub_same_length_to_out(bsm1, ys_1, ys_0);\n            v_neg_1_neg = true;\n        } else {\n            limbs_sub_same_length_to_out(bsm1, ys_0, ys_1);\n        }\n    } else {\n        if limbs_add_to_out(bs1_init, ys_0, ys_1) {\n            *bs1_last = 1;\n        }\n        let (ys_0_lo, ys_0_hi) = ys_0.split_at(t);\n        if slice_test_zero(ys_0_hi) && limbs_cmp_same_length(ys_0_lo, ys_1) == Less {\n            let (bsm1_lo, bsm1_hi) = bsm1.split_at_mut(t);\n            limbs_sub_same_length_to_out(bsm1_lo, ys_1, ys_0_lo);\n            slice_set_zero(bsm1_hi);\n            v_neg_1_neg.not_assign();\n        } else {\n            limbs_sub_greater_to_out(bsm1, ys_0, ys_1);\n        }\n    }\n    // Compute bs2 and bsm2, recycling bs1 and bsm1. bs2 = bs1 + ys_1; bsm2 = bsm1 - ys_1\n    limbs_add_to_out(bs2, bs1, ys_1);\n    let (bsm2_last, bsm2_init) = bsm2.split_last_mut().unwrap();\n    *bsm2_last = 0;\n    if v_neg_1_neg {\n        if limbs_add_to_out(bsm2_init, bsm1, ys_1) {\n            *bsm2_last = 1;\n        }\n        v_neg_2_neg.not_assign();\n    } else if t == n {\n        if limbs_cmp_same_length(bsm1, ys_1) == Less {\n            limbs_sub_same_length_to_out(bsm2_init, ys_1, bsm1);\n            v_neg_2_neg.not_assign();\n        } else {\n            limbs_sub_same_length_to_out(bsm2_init, bsm1, ys_1);\n        }\n    } else {\n        let (bsm1_lo, bsm1_hi) = bsm1.split_at(t);\n        if slice_test_zero(bsm1_hi) && limbs_cmp_same_length(bsm1_lo, ys_1) == Less {\n            limbs_sub_same_length_to_out(bsm2_init, ys_1, bsm1_lo);\n            slice_set_zero(&mut bsm2_init[t..]);\n            v_neg_2_neg.not_assign();\n        } else {\n            limbs_sub_greater_to_out(bsm2_init, bsm1, ys_1);\n        }\n    }\n    // Compute as1 and asm1.\n    if limbs_mul_toom_evaluate_poly_in_1_and_neg_1(as1, asm1, 4, xs, n, &mut v_neg_1[..m]) {\n        v_neg_1_neg.not_assign();\n    }\n    assert!(as1[n] <= 4);\n    assert!(bs1[n] <= 1);\n    assert!(asm1[n] <= 2);\n    assert!(as2[n] <= 30);\n    assert!(bs2[n] <= 2);\n    assert!(asm2[n] <= 20);\n    assert!(*bsm2_last <= 1);\n    // size: m, n\n    limbs_mul_greater_to_out(v_neg_1, asm1, bsm1, mul_scratch); // W4\n    let k = (n << 1) + 1;\n    let (v_neg_2, asm2) = scratch[k..].split_at_mut(k + 2);\n    // size: m\n    limbs_mul_same_length_to_out(v_neg_2, &asm2[..m], bsm2, mul_scratch); // W2\n                                                                          // size: m\n    limbs_mul_same_length_to_out(&mut scratch[k << 1..], as2, bs2, mul_scratch); // W1\n    let (bs1, remainder) = out.split_at_mut(n << 1);\n    let (v_1, as1) = remainder.split_at_mut(k + 3);\n    // size: m\n    limbs_mul_same_length_to_out(v_1, &as1[..m], &bs1[..m], mul_scratch); // W3\n    let (v_0, v_inf) = out.split_at_mut(5 * n);\n    // size: s, t\n    limbs_mul_to_out(v_inf, &xs[n << 2..], ys_1, mul_scratch); // W0\n                                                               // size: n\n    limbs_mul_same_length_to_out(v_0, &xs[..n], ys_0, mul_scratch); // W5\n    split_into_chunks_mut!(scratch, k, [v_neg_1, v_neg_2, v_2], _unused);\n    limbs_mul_toom_interpolate_6_points(\n        out,\n        n,\n        s + t,\n        v_neg_1_neg,\n        v_neg_1,\n        v_neg_2_neg,\n        v_neg_2,\n        v_2,\n    );\n}}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_53` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {\n    limbs_mul_greater_to_out_toom_53_input_sizes_valid(xs_len: usize, ys_len: usize) -> bool {\n    !(xs_len == 16 && ys_len == 9)\n        && xs_len.shr_round(2, Ceiling).0\n            > ys_len.div_round(3, Ceiling).0\n        && xs_len.div_round(5, Ceiling).0\n            < ys_len.shr_round(1, Ceiling).0\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_53`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom53_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_53_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = 1 + if 3 * xs_len >= 5 * ys_len {\n        (xs_len - 1) / 5\n    } else {\n        (ys_len - 1) / 3\n    };\n    let s = xs_len - (n << 2);\n    let t = ys_len - (n << 1);\n    let m = n + 1;\n    assert!(m < xs_len);\n    18 * n\n        + 15\n        + max!(\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_same_length_to_out_scratch_len(m),\n            limbs_mul_to_out_scratch_len(s, t)\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_53_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - ceiling(`xs`.len() / 4) > ceiling(`xs`.len() / 3)\n// - ceiling(`xs`.len() / 5) < ceiling(`ys`.len() / 2)\n// - (`xs`.len(), `ys`.len()) != (16, 9)\n//\n// Approximately, 4 / 3 * `ys`.len() < `xs`.len() < 5 / 2 * `ys`.len().\n//\n// The smallest allowable `xs` length is 5. The smallest allowable `ys` length is 3.\n//\n// This uses the Toom-53 algorithm.\n//\n// Evaluate in: 0, 1, -1, 2, -2, 1 / 2, Infinity.\n// ```\n// <-s-><--n--><--n--><--n--><--n-->\n//  _________________________________\n// |xs4_|__xs3_|__xs2_|__xs1_|__xs0_|\n//               |ys2_|__ys1_|__ys0_|\n//               <-t--><--n--><--n-->\n//\n// v_0  =       x0                   *   y0          #    X(0) * Y(0)\n// v_1  =    (  x0+ x1+ x2+ x3+  x4) * ( y0+ y1+ y2) #    X(1) * Y(1)      xh  <= 4      yh <= 2\n// v_neg_1 = (  x0- x1+ x2- x3+  x4) * ( y0- y1+ y2) #   X(-1) * Y(-1)    |xh| <= 2      yh <= 1\n// v_2  =    (  x0+2x1+4x2+8x3+16x4) * ( y0+2y1+4y2) #    X(2) * Y(2)      xh  <= 30     yh <= 6\n// v_neg_2 = (  x0-2x1+4x2-8x3+16x4) * ( y0-2y1+4y2) #    X(2) * Y(2)    -9<=xh<=20  -1<=yh <= 4\n// v_half  = (16x0+8x1+4x2+2x3+  x4) * (4y0+2y1+ y2) #  X(1/2) * Y(1/2)    xh  <= 30     yh <= 6\n// v_inf=                        x4  *           y2  #  X(inf) * Y(inf)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_5 7}) \\approx O(n^{1.209}), but this function calls\n// `limbs_mul_same_length_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom53_mul` from `mpn/generic/toom53_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_53(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let n = 1 + if 3 * xs_len >= 5 * ys_len {\n        (xs_len - 1) / 5\n    } else {\n        (ys_len - 1) / 3\n    };\n    split_into_chunks!(xs, n, [xs_0, xs_1, xs_2, xs_3], xs_4);\n    let s = xs_4.len();\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    split_into_chunks!(ys, n, [ys_0, ys_1], ys_2);\n    let t = ys_2.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    let (scratch, mul_scratch) = scratch.split_at_mut(18 * n + 15);\n    let (scratch2, scratch) = scratch.split_at_mut(10 * (n + 1));\n    split_into_chunks_mut!(\n        scratch2,\n        n + 1,\n        [as1, asm1, as2, asm2, ash, bs1, bsm1, bs2, bsm2, bsh],\n        _unused\n    );\n    let out_lo = &mut out[..=n];\n    // Compute as1 and asm1.\n    let mut v_neg_1_neg = limbs_mul_toom_evaluate_poly_in_1_and_neg_1(as1, asm1, 4, xs, n, out_lo);\n    // Compute as2 and asm2.\n    let mut v_neg_2_neg = limbs_mul_toom_evaluate_poly_in_2_and_neg_2(as2, asm2, 4, xs, n, out_lo);\n    // Compute ash = 16 * xs_0 + 8 * xs_1 + 4 * xs_2 + 2 * xs_3 + xs_4 = 2 * (2 * (2 * (2 * xs_0 +\n    // xs_1) + xs_2) + xs_3) + xs_4\n    let (ash_last, ash_init) = ash.split_last_mut().unwrap();\n    let mut carry = limbs_shl_to_out(ash_init, xs_0, 1);\n    if limbs_slice_add_same_length_in_place_left(ash_init, xs_1) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(ash_init, 1));\n    if limbs_slice_add_same_length_in_place_left(ash_init, xs_2) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(ash_init, 1));\n    if limbs_slice_add_same_length_in_place_left(ash_init, xs_3) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(ash_init, 1));\n    if limbs_slice_add_greater_in_place_left(ash_init, xs_4) {\n        carry.wrapping_add_assign(1);\n    }\n    *ash_last = carry;\n    // Compute bs1 and bsm1.\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    // ys_0 + ys_2\n    *bs1_last = Limb::from(limbs_add_to_out(bs1_init, ys_0, ys_2));\n    let (bsm1_last, bsm1_init) = bsm1.split_last_mut().unwrap();\n    if *bs1_last == 0 && limbs_cmp_same_length(bs1_init, ys_1) == Less {\n        limbs_sub_same_length_to_out(bsm1_init, ys_1, bs1_init);\n        *bsm1_last = 0;\n        v_neg_1_neg.not_assign();\n    } else {\n        *bsm1_last = *bs1_last;\n        if limbs_sub_same_length_to_out(bsm1_init, bs1_init, ys_1) {\n            bsm1_last.wrapping_sub_assign(1);\n        }\n    }\n    // ys_0 + ys_1 + ys_2\n    if limbs_slice_add_same_length_in_place_left(bs1_init, ys_1) {\n        bs1_last.wrapping_add_assign(1);\n    }\n    // Compute bs2 and bsm2.\n    let (out_lo_last, out_lo_init) = out_lo.split_last_mut().unwrap();\n    let carry = limbs_shl_to_out(out_lo_init, ys_2, 2);\n    let (bs2_last, bs2_init) = bs2.split_last_mut().unwrap();\n    *bs2_last = Limb::from(limbs_add_to_out(bs2_init, ys_0, &out_lo_init[..t]));\n    assert!(!limbs_slice_add_limb_in_place(&mut bs2[t..], carry));\n    *out_lo_last = limbs_shl_to_out(out_lo_init, ys_1, 1);\n    if limbs_cmp_same_length(bs2, out_lo) == Less {\n        assert!(!limbs_sub_same_length_to_out(bsm2, out_lo, bs2));\n        v_neg_2_neg.not_assign();\n    } else {\n        assert!(!limbs_sub_same_length_to_out(bsm2, bs2, out_lo));\n    }\n    limbs_slice_add_same_length_in_place_left(bs2, out_lo);\n    // Compute bsh = 4 * ys_0 + 2 * ys_1 + ys_2 = 2 * (2 * ys_0 + ys_1) + ys_2.\n    let (bsh_last, bsh_init) = bsh.split_last_mut().unwrap();\n    let mut carry = limbs_shl_to_out(bsh_init, ys_0, 1);\n    if limbs_slice_add_same_length_in_place_left(bsh_init, ys_1) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(bsh_init, 1));\n    if limbs_slice_add_greater_in_place_left(bsh_init, ys_2) {\n        carry.wrapping_add_assign(1);\n    }\n    *bsh_last = carry;\n    let (as1_last, as1_init) = as1.split_last().unwrap();\n    let (asm1_last, asm1_init) = asm1.split_last().unwrap();\n    assert!(*as1_last <= 4);\n    assert!(*bs1_last <= 2);\n    assert!(*asm1_last <= 2);\n    assert!(*bsm1_last <= 1);\n    assert!(as2[n] <= 30);\n    assert!(bs2[n] <= 6);\n    assert!(asm2[n] <= 20);\n    assert!(bsm2[n] <= 4);\n    assert!(*ash_last <= 30);\n    assert!(*bsh_last <= 6);\n    let (v_0, remainder) = out.split_at_mut(n << 1);\n    let (v_1, v_inf) = remainder.split_at_mut(n << 2);\n    // size: n + 1\n    limbs_mul_same_length_to_out(scratch, as2, bs2, mul_scratch);\n    let m = 2 * n + 1;\n    // size: n + 1\n    limbs_mul_same_length_to_out(&mut scratch[m..], asm2, bsm2, mul_scratch);\n    // size: n + 1\n    limbs_mul_same_length_to_out(&mut scratch[m << 1..], ash, bsh, mul_scratch);\n    let v_neg_1 = &mut scratch[3 * m..m << 2];\n    let (v_neg_1_last, v_neg_1_init) = v_neg_1.split_last_mut().unwrap();\n    if SMALLER_RECURSION_TOOM_33_AND_53 {\n        // size: n\n        limbs_mul_same_length_to_out(v_neg_1_init, asm1_init, bsm1_init, mul_scratch);\n        let v_neg_1_init = &mut v_neg_1_init[n..];\n        let mut carry = match *asm1_last {\n            1 => {\n                let mut carry = *bsm1_last;\n                if limbs_slice_add_same_length_in_place_left(v_neg_1_init, bsm1_init) {\n                    carry.wrapping_add_assign(1);\n                }\n                carry\n            }\n            2 => (*bsm1_last << 1).wrapping_add(\n                limbs_slice_add_mul_limb_same_length_in_place_left(v_neg_1_init, bsm1_init, 2),\n            ),\n            _ => 0,\n        };\n        if *bsm1_last != 0 && limbs_slice_add_same_length_in_place_left(v_neg_1_init, asm1_init) {\n            carry.wrapping_add_assign(1);\n        }\n        *v_neg_1_last = carry;\n        // size: n\n        limbs_mul_same_length_to_out(v_1, as1_init, bs1_init, mul_scratch);\n        split_into_chunks_mut!(v_1, n, [_unused, v_1_lo], v_1_hi);\n        let mut carry = match *as1_last {\n            1 => {\n                let mut carry = *bs1_last;\n                if limbs_slice_add_same_length_in_place_left(v_1_lo, bs1_init) {\n                    carry.wrapping_add_assign(1);\n                }\n                carry\n            }\n            2 => (*bs1_last << 1).wrapping_add(limbs_slice_add_mul_limb_same_length_in_place_left(\n                v_1_lo, bs1_init, 2,\n            )),\n            0 => 0,\n            _ => {\n                as1_last.wrapping_mul(*bs1_last)\n                    + limbs_slice_add_mul_limb_same_length_in_place_left(\n                        v_1_lo, bs1_init, *as1_last,\n                    )\n            }\n        };\n        if *bs1_last == 1 && limbs_slice_add_same_length_in_place_left(v_1_lo, as1_init) {\n            carry.wrapping_add_assign(1);\n        } else if *bs1_last == 2 {\n            carry.wrapping_add_assign(limbs_slice_add_mul_limb_same_length_in_place_left(\n                v_1_lo, as1_init, 2,\n            ));\n        }\n        v_1_hi[0] = carry;\n    } else {\n        fail_on_untested_path(\"limbs_mul_greater_to_out_toom_53, !SMALLER_RECURSION\");\n        *v_neg_1_last = 0;\n        if (*asm1_last | *bsm1_last) == 0 {\n            // size: n\n            limbs_mul_same_length_to_out(v_neg_1_init, asm1_init, bsm1_init, mul_scratch);\n        } else {\n            // size: n + 1\n            limbs_mul_same_length_to_out(&mut scratch[3 * m..8 * n + 5], asm1, bsm1, mul_scratch);\n        }\n        v_1[n << 1] = 0;\n        if (*as1_last | *bs1_last) == 0 {\n            // size: n\n            limbs_mul_same_length_to_out(v_1, as1_init, bs1_init, mul_scratch);\n        } else {\n            // size: n + 1\n            limbs_mul_same_length_to_out(v_1, as1, bs1, mul_scratch);\n        }\n    }\n    // size: n\n    limbs_mul_same_length_to_out(v_0, xs_0, ys_0, mul_scratch); // v_0, 2 * n limbs\n    // size: s, t\n    limbs_mul_to_out(v_inf, xs_4, ys_2, mul_scratch); // v_inf, s + t limbs\n    split_into_chunks_mut!(\n        scratch,\n        m,\n        [v_2, v_neg_2, v_half, v_neg_1],\n        _unused\n    );\n    limbs_mul_toom_interpolate_7_points(\n        out,\n        n,\n        s + t,\n        v_neg_2_neg,\n        v_neg_2,\n        v_neg_1_neg,\n        v_neg_1,\n        v_2,\n        v_half,\n        scratch2,\n    );\n}}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_54` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_mul_greater_to_out_toom_54_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize,\n) -> bool {\n    xs_len != 0 && xs_len >= ys_len && {\n        let sum = xs_len + ys_len;\n        let n = 1 + if xs_len << 2 >= 5 * ys_len {\n            (xs_len - 1) / 5\n        } else {\n            (ys_len - 1) >> 2\n        };\n        n > 2\n            && xs_len > n << 2\n            && xs_len <= 5 * n\n            && ys_len > 3 * n\n            && ys_len <= n << 2\n            && sum >= n << 3\n            && sum > 7 * n + 4\n    }\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_54`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom54_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_test! {limbs_mul_greater_to_out_toom_54_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = 1\n        + (if xs_len << 2 >= 5 * ys_len {\n            (xs_len - 1) / 5\n        } else {\n            (ys_len - 1) >> 2\n        });\n    let m = n + 1;\n    assert!(m < xs_len);\n    let s = xs_len - (n << 2);\n    let t = ys_len - 3 * n;\n    6 * n\n        + 2\n        + max!(\n            3 * n + 1,\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_same_length_to_out_scratch_len(m),\n            limbs_mul_to_out_scratch_len(s, t)\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_54_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - Others; see `limbs_mul_greater_to_out_toom_54_input_sizes_valid`. The gist is that 3 times\n//   `xs.len()` must be less than 5 times `ys.len()`.\n//\n// This uses the Toom-54 algorithm (the splitting unbalanced version).\n//\n// Evaluate in: Infinity, 4, -4, 2, -2, 1, -1, 0.\n// ```\n// <--s-><--n--><--n--><--n--><--n-->\n//  _________________________________\n// |xs4_|_xs3__|_xs2__|_xs1__|_xs0__|\n//        |ys3_|_ys2__|_ys1__|_ys0__|\n//         <-t-><--n--><--n--><--n-->\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_5 8}) \\approx O(n^{1.292}), but `limbs_mul_same_length_to_out` is\n// called.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom54_mul` from `mpn/generic/toom54_mul.c`, GMP 6.2.1.\n#[cfg(feature = \"test_build\")]\npub fn limbs_mul_greater_to_out_toom_54(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    // Decomposition\n    let n = 1 + if xs_len << 2 >= 5 * ys_len {\n        (xs_len - 1) / 5\n    } else {\n        (ys_len - 1) >> 2\n    };\n    assert!(n > 2);\n    let m = n + 1;\n    let a4 = &xs[n << 2..];\n    let b3 = &ys[3 * n..];\n    let s = a4.len();\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    let t = b3.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    let sum = s + t;\n    assert!(sum >= n);\n    assert!(sum > 4);\n    // Also allocate 3 * `n` + 1 limbs for `scratch_hi`. `limbs_mul_toom_interpolate_8_points` may\n    // need all of them, when `shl_and_sub_same_length` uses a scratch.\n    let (scratch, mul_scratch) = scratch.split_at_mut(6 * n + 2);\n    let (r7, r3) = scratch.split_at_mut(3 * n + 1);\n    let (out_lo, out_hi) = out.split_at_mut(3 * n);\n    split_into_chunks_mut!(out_hi, m, [v0, v1, v2, v3], _unused);\n    // - Evaluation and recursive calls\n    // - 4, -4\n    let out_lo_lo = &mut out_lo[..m];\n    let neg_2_pow_sign =\n        limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, 4, xs, n, 2, out_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v3, v1, 3, ys, n, 2, out_lo_lo);\n    // - X(-4) * Y(-4)\n    // - size: m\n    limbs_mul_same_length_to_out(out_lo, v0, v1, mul_scratch);\n    // - X(+4) * Y(+4)\n    // - size: m\n    limbs_mul_same_length_to_out(r3, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r3, &mut out_lo[..=n << 1], neg_2_pow_sign, n, 2, 4);\n    // 1, -1\n    let out_lo_lo = &mut out_lo[..m];\n    let neg_1_sign = limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v2, v0, 4, xs, n, out_lo_lo)\n        != limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(v3, v1, ys, n, out_lo_lo);\n    // - X(-1) * Y(-1)\n    // - size: m\n    limbs_mul_same_length_to_out(out_lo, v0, v1, mul_scratch);\n    // - X(1) * Y(1)\n    // - size: m\n    limbs_mul_same_length_to_out(r7, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r7, &mut out_lo[..=n << 1], neg_1_sign, n, 0, 0);\n    // 2, -2\n    let out_lo_lo = &mut out_lo[..m];\n    let neg_2_sign = limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v2, v0, 4, xs, n, out_lo_lo)\n        != limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2(v3, v1, ys, n, out_lo_lo);\n    // - X(-2) * Y(-2)\n    // - size: m\n    limbs_mul_same_length_to_out(out_lo, v0, v1, mul_scratch);\n    let (r5, remainder) = out[3 * n..].split_at_mut(m << 1);\n    split_into_chunks_mut!(remainder, m, [v2, v3], _unused);\n    // - X(2) * Y(2)\n    // - size: m\n    limbs_mul_same_length_to_out(r5, v2, v3, mul_scratch);\n    let (out_lo, r5) = out.split_at_mut(3 * n);\n    limbs_toom_couple_handling(r5, &mut out_lo[..=n << 1], neg_2_sign, n, 1, 2);\n    // - X(0) * Y(0)\n    // - size: n\n    limbs_mul_same_length_to_out(out, &xs[..n], &ys[..n], mul_scratch);\n    // - Infinity\n    // - size: s, t\n    limbs_mul_to_out(&mut out[7 * n..], a4, b3, mul_scratch);\n    limbs_mul_toom_interpolate_8_points(out, n, sum, r3, r7, mul_scratch);\n}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_62` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_mul_greater_to_out_toom_62_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize,\n) -> bool {\n    xs_len != 0 && xs_len >= ys_len && {\n        let n = 1 + if xs_len >= 3 * ys_len {\n            (xs_len - 1) / 6\n        } else {\n            (ys_len - 1) >> 1\n        };\n        xs_len > 5 * n && xs_len <= 6 * n && ys_len > n && ys_len <= n << 1\n    }\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_62`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom62_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_test! {limbs_mul_greater_to_out_toom_62_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = 1 + if xs_len >= 3 * ys_len {\n        (xs_len - 1) / 6\n    } else {\n        (ys_len - 1) >> 1\n    };\n    let s = xs_len - 5 * n;\n    let t = ys_len - n;\n    let m = n + 1;\n    assert!(m < xs_len);\n    20 * n\n        + 14\n        + max!(\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_same_length_to_out_scratch_len(m),\n            limbs_mul_to_out_scratch_len(s, t)\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_62_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - See `limbs_mul_greater_to_out_toom_62_input_sizes_valid`. The gist is that `xs.len()` must be\n//   less than 6 times `ys.len()`.\n//\n// This uses the Toom-62 algorithm.\n//\n// Evaluate in: 0, 1, -1, 2, -2, 1 / 2, Infinity.\n// ```\n// <-s-><--n--><--n--><--n--><--n--><--n-->\n//  ________________________________________\n// |xs5_|__xs4_|__xs3_|__xs2_|__xs1_|__xs0_|\n//                             |ys1_|__ys0_|\n//                             <-t--><--n-->\n//\n// v_0     =    x0                         *    y0     #   X(0) * Y(0)\n// v_1     = (  x0+  x1+ x2+ x3+  x4+  x5) * ( y0+ y1) #   X(1) * Y(1)        xh <= 5      yh <= 1\n// v_neg_1 = (  x0-  x1+ x2- x3+  x4-  x5) * ( y0- y1) #  X(-1) * Y(-1)      |xh|<= 2      yh =  0\n// v_2     = (  x0+ 2x1+4x2+8x3+16x4+32x5) * ( y0+2y1) #   X(2) * Y(2)        xh <= 62     yh <= 2\n// v_neg_2 = (  x0- 2x1+4x2-8x3+16x4-32x5) * ( y0-2y1) #  X(-2) * Y(-2)  -41<=xh <= 20 -1<=yh <= 0\n// v_half  = (32x0+16x1+8x2+4x3+ 2x4+  x5) * (2y0+ y1) # X(1/2) * Y(1/2)      xh <= 62     yh <= 2\n// v_inf   =                           x5  *       y1  # X(inf) * Y(inf)\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_6 7}) \\approx O(n^{1.086}), but this function calls\n// `limbs_mul_same_length_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom62_mul` from `mpn/generic/toom62_mul.c`, GMP 6.2.1.\npub_test! {limbs_mul_greater_to_out_toom_62(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let n = 1 + if xs_len >= 3 * ys_len {\n        (xs_len - 1) / 6\n    } else {\n        (ys_len - 1) >> 1\n    };\n    split_into_chunks!(xs, n, [xs_0, xs_1, xs_2, xs_3, xs_4], xs_5);\n    let s = xs_5.len();\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    split_into_chunks!(ys, n, [ys_0], ys_1);\n    let t = ys_1.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    let m = n + 1;\n    let (scratch, mul_scratch) = scratch.split_at_mut(20 * n + 14);\n    let (scratch2, scratch) = scratch.split_at_mut(10 * n + 9);\n    split_into_chunks_mut!(\n        scratch2,\n        m,\n        [as1, asm1, as2, asm2, ash, bs1, bs2, bsm2, bsh],\n        bsm1\n    );\n    // Compute as1 and asm1.\n    let out_lo = &mut out[..m];\n    let v_neg_1_neg_a = limbs_mul_toom_evaluate_poly_in_1_and_neg_1(as1, asm1, 5, xs, n, out_lo);\n    // Compute as2 and asm2.\n    let v_neg_2_neg_a = limbs_mul_toom_evaluate_poly_in_2_and_neg_2(as2, asm2, 5, xs, n, out_lo);\n    let (ash_last, ash_init) = ash.split_last_mut().unwrap();\n    // Compute ash = 32 * xs_0 + 16 * xs_1 + 8 * xs_2 + 4 * xs_3 + 2 * xs_4 + xs_5 = 2 * (2 * (2 *\n    // (2 * (2 * xs_0 + xs_1) + xs_2) + xs_3) + xs_4) + xs_5\n    let mut carry = limbs_shl_to_out(ash_init, xs_0, 1);\n    for xs_i in &[xs_1, xs_2, xs_3, xs_4] {\n        if limbs_slice_add_same_length_in_place_left(ash_init, xs_i) {\n            carry += 1;\n        }\n        carry <<= 1;\n        carry |= limbs_slice_shl_in_place(ash_init, 1);\n    }\n    *ash_last = carry;\n    if limbs_slice_add_greater_in_place_left(ash_init, xs_5) {\n        *ash_last += 1;\n    }\n    // Compute bs1 and bsm1.\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    let v_neg_1_neg_b = if t == n {\n        *bs1_last = Limb::from(limbs_add_same_length_to_out(bs1_init, ys_0, ys_1));\n        if limbs_cmp_same_length(ys_0, ys_1) == Less {\n            limbs_sub_same_length_to_out(bsm1, ys_1, ys_0);\n            true\n        } else {\n            limbs_sub_same_length_to_out(bsm1, ys_0, ys_1);\n            false\n        }\n    } else {\n        *bs1_last = Limb::from(limbs_add_to_out(bs1_init, ys_0, ys_1));\n        let (ys_0_lo, ys_0_hi) = ys_0.split_at(t);\n        if slice_test_zero(ys_0_hi) && limbs_cmp_same_length(ys_0_lo, ys_1) == Less {\n            let (bsm1_lo, bsm1_hi) = bsm1.split_at_mut(t);\n            limbs_sub_same_length_to_out(bsm1_lo, ys_1, ys_0_lo);\n            slice_set_zero(bsm1_hi);\n            true\n        } else {\n            limbs_sub_greater_to_out(bsm1, ys_0, ys_1);\n            false\n        }\n    };\n    // Compute bs2 and bsm2. Recycling bs1 and bsm1: bs2 = bs1 + ys_1, bsm2 = bsm1 - ys_1\n    limbs_add_to_out(bs2, bs1, ys_1);\n    let v_neg_2_neg_b = if v_neg_1_neg_b {\n        bsm2[n] = Limb::from(limbs_add_to_out(bsm2, bsm1, ys_1));\n        true\n    } else if t < n {\n        let (bsm1_lo, bsm1_hi) = bsm1.split_at(t);\n        if slice_test_zero(bsm1_hi) && limbs_cmp_same_length(bsm1_lo, ys_1) == Less {\n            let (bsm2_lo, bsm2_hi) = bsm2.split_at_mut(t);\n            assert!(!limbs_sub_same_length_to_out(bsm2_lo, ys_1, bsm1_lo));\n            slice_set_zero(bsm2_hi);\n            true\n        } else {\n            assert!(!limbs_sub_greater_to_out(bsm2, bsm1, ys_1));\n            bsm2[n] = 0;\n            false\n        }\n    } else {\n        bsm2[n] = 0;\n        if limbs_cmp_same_length(bsm1, ys_1) == Less {\n            assert!(!limbs_sub_same_length_to_out(bsm2, ys_1, bsm1));\n            true\n        } else {\n            assert!(!limbs_sub_same_length_to_out(bsm2, bsm1, ys_1));\n            false\n        }\n    };\n    // Compute bsh, recycling bs1. bsh = bs1 + ys_0\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    let (bsh_last, bsh_init) = bsh.split_last_mut().unwrap();\n    *bsh_last = *bs1_last;\n    if limbs_add_same_length_to_out(bsh_init, bs1_init, ys_0) {\n        bsh_last.wrapping_add_assign(1);\n    }\n    assert!(as1[n] <= 5);\n    assert!(*bs1_last <= 1);\n    assert!(asm1[n] <= 2);\n    assert!(as2[n] <= 62);\n    assert!(bs2[n] <= 2);\n    assert!(asm2[n] <= 41);\n    assert!(bsm2[n] <= 1);\n    assert!(*ash_last <= 62);\n    assert!(*bsh_last <= 2);\n    let (as1_last, as1_init) = as1.split_last_mut().unwrap();\n    let (asm1_last, asm1_init) = asm1.split_last_mut().unwrap();\n    let (bs1_last, bs1_init) = bs1.split_last_mut().unwrap();\n    let p = 2 * n + 1;\n    // size: m\n    limbs_mul_same_length_to_out(scratch, as2, bs2, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out(&mut scratch[p..], asm2, bsm2, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out(&mut scratch[p << 1..], ash, bsh, mul_scratch);\n    split_into_chunks_mut!(\n        scratch,\n        p,\n        [v_2, v_neg_2, v_half, v_neg_1, scratch_out],\n        _unused\n    );\n    // size: n\n    limbs_mul_same_length_to_out(v_neg_1, asm1_init, bsm1, mul_scratch);\n    let (v_neg_1_last, v_neg_1_hi) = v_neg_1[n..p].split_last_mut().unwrap();\n    *v_neg_1_last = if *asm1_last == 2 {\n        limbs_slice_add_mul_limb_same_length_in_place_left(v_neg_1_hi, bsm1, 2)\n    } else {\n        Limb::from(\n            *asm1_last == 1 && limbs_slice_add_same_length_in_place_left(v_neg_1_hi, bsm1),\n        )\n    };\n    let (v_0, remainder) = out.split_at_mut(n << 1);\n    let (v_1, v_inf) = remainder.split_at_mut(n << 2);\n    // size: n\n    limbs_mul_same_length_to_out(v_1, as1_init, bs1_init, mul_scratch);\n    let (v_1_last, v_1_hi) = v_1[n..p].split_last_mut().unwrap();\n    *v_1_last = match *as1_last {\n        1 => {\n            let mut carry = *bs1_last;\n            if limbs_slice_add_same_length_in_place_left(v_1_hi, bs1_init) {\n                carry.wrapping_add_assign(1);\n            }\n            carry\n        }\n        2 => bs1_last.arithmetic_checked_shl(1u64).unwrap().wrapping_add(\n            limbs_slice_add_mul_limb_same_length_in_place_left(v_1_hi, bs1_init, 2),\n        ),\n        0 => 0,\n        _ => as1_last.wrapping_mul(*bs1_last).wrapping_add(\n            limbs_slice_add_mul_limb_same_length_in_place_left(v_1_hi, bs1_init, *as1_last),\n        ),\n    };\n    if *bs1_last != 0 && limbs_slice_add_same_length_in_place_left(v_1_hi, as1_init) {\n        v_1_last.wrapping_add_assign(1);\n    }\n    // size: n\n    limbs_mul_same_length_to_out(v_0, xs_0, ys_0, mul_scratch);\n    // size: s, t\n    limbs_mul_to_out(v_inf, xs_5, ys_1, mul_scratch);\n    limbs_mul_toom_interpolate_7_points(\n        out,\n        n,\n        s + t,\n        v_neg_2_neg_a != v_neg_2_neg_b,\n        v_neg_2,\n        v_neg_1_neg_a != v_neg_1_neg_b,\n        v_neg_1,\n        v_2,\n        v_half,\n        scratch_out,\n    );\n}}\n\n// Stores |{xs,n}-{ys,n}| in {out,n}, returns the sign.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `abs_sub_n` from `mpn/generic/toom63_mul.c`, GMP 6.2.1.\nfn limbs_abs_sub_same_length(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    for i in (0..n).rev() {\n        let x = xs[i];\n        let y = ys[i];\n        if x != y {\n            let n = i + 1;\n            return if x > y {\n                limbs_sub_same_length_to_out(out, &xs[..n], &ys[..n]);\n                false\n            } else {\n                limbs_sub_same_length_to_out(out, &ys[..n], &xs[..n]);\n                true\n            };\n        }\n        out[i] = 0;\n    }\n    false\n}\n\n// Given the limbs `xs` and `ys` of two integers, writes the limbs of the absolute difference to\n// `out_diff` and the limbs of the sum to `xs`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `abs_sub_add_n` from `mpn/generic/toom63_mul.c`, GMP 6.2.1.\nfn limbs_abs_sub_add_same_length(out_diff: &mut [Limb], xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let result = limbs_abs_sub_same_length(out_diff, xs, ys);\n    assert!(!limbs_slice_add_same_length_in_place_left(xs, ys));\n    result\n}\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_63` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_mul_greater_to_out_toom_63_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize,\n) -> bool {\n    xs_len != 0 && xs_len >= ys_len && {\n        let sum = xs_len + ys_len;\n        let n = 1 + if xs_len >= ys_len << 1 {\n            (xs_len - 1) / 6\n        } else {\n            (ys_len - 1) / 3\n        };\n        n > 2\n            && xs_len > 5 * n\n            && xs_len <= 6 * n\n            && ys_len > n << 1\n            && ys_len <= 3 * n\n            && sum >= n << 3\n            && sum > 7 * n + 4\n    }\n}}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_63`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom63_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_63_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n = 1 + if xs_len >= ys_len << 1 {\n        (xs_len - 1) / 6\n    } else {\n        (ys_len - 1) / 3\n    };\n    let m = n + 1;\n    assert!(m < xs_len);\n    let s = xs_len - 5 * n;\n    let t = ys_len - (n << 1);\n    9 * n\n        + 3\n        + max!(\n            limbs_mul_same_length_to_out_scratch_len(n),\n            limbs_mul_same_length_to_out_scratch_len(m),\n            limbs_mul_to_out_scratch_len(s, t)\n        )\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_63_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - Others; see `limbs_mul_greater_to_out_toom_63_input_sizes_valid`. The gist is that\n// `xs.len()` must be less than 3 times `ys.len()`.\n//\n// This uses the Toom-63 algorithm (aka Toom-4.5, the splitting 6x3 unbalanced version).\n//\n// Evaluate in: Infinity, 4, -4, 2, -2, 1, -1, 0.\n// ```\n// <--s-><--n--><--n--><--n--><--n--><--n-->\n//  ________________________________________\n// |xs5_|_xs4__|_xs3__|_xs2__|_xs1__|_xs0__|\n//                      |ys2_|_ys1__|_ys0__|\n//                      <--t-><--n--><--n-->\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_6 8}) \\approx O(n^{1.161}), but\n// `limbs_mul_same_length_to_out_toom_63_recursive` calls `limbs_mul_same_length_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom63_mul` from `mpn/generic/toom63_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_63(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let n = 1 + if xs_len >= ys_len << 1 {\n        (xs_len - 1) / 6\n    } else {\n        (ys_len - 1) / 3\n    };\n    assert!(n > 2);\n    let m = n + 1;\n    // Decomposition\n    split_into_chunks!(ys, n, [ys_0, ys_1], ys_2);\n    let t = ys_2.len();\n    assert_ne!(t, 0);\n    assert!(t <= n);\n    let s = xs_len - 5 * n;\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    assert!(s + t >= n);\n    assert!(s + t > 4);\n    // - Also allocate 3 * n + 1 limbs for `scratch2`. `limbs_mul_toom_interpolate_8_points` may\n    //   need all of them, when `shl_and_sub_same_length` uses a scratch.\n    // - Evaluation and recursive calls\n    // - 4, -4\n    let (scratch, mul_scratch) = scratch.split_at_mut(9 * n + 3);\n    split_into_chunks_mut!(scratch, 3 * n + 1, [r7, r3], scratch2);\n    let (r8, remainder) = out.split_at_mut(3 * n);\n    split_into_chunks_mut!(remainder, m, [v0, v1, v2, v3], _unused);\n    let r8_lo = &mut r8[..m];\n    let mut v_neg_2_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, 5, xs, n, 2, r8_lo);\n    let (r8_lo_last, r8_lo_init) = r8_lo.split_last_mut().unwrap();\n    *r8_lo_last = limbs_shl_to_out(r8_lo_init, ys_1, 2); // 4 * ys_1\n    v3[t] = limbs_shl_to_out(v3, ys_2, 4); // 16 * ys_2\n    let (v3_last, v3_init) = v3.split_last_mut().unwrap();\n    if n != t {\n        // 16 * ys_2 + ys_0\n        *v3_last = Limb::from(limbs_add_to_out_aliased(v3_init, t + 1, ys_0));\n    } else if limbs_slice_add_same_length_in_place_left(v3_init, ys_0) {\n        // 16 * ys_2 + ys_0\n        *v3_last += 1;\n    }\n    if limbs_abs_sub_add_same_length(v1, v3, r8_lo) {\n        v_neg_2_neg.not_assign();\n    }\n    // - A(-4) * B(-4)\n    // - size: m\n    limbs_mul_same_length_to_out(r8, v0, v1, mul_scratch);\n    // - A(+4) * B(+4)\n    // - size: m\n    limbs_mul_same_length_to_out(r3, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r3, &mut r8[..=n<<1], v_neg_2_neg, n, 2, 4);\n    // $pm1$\n    v_neg_2_neg = limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v2, v0, 5, xs, n, &mut r8[..m]);\n    // Compute bs1 and bsm1. Code taken from toom33\n    let scratch2_lo = &mut scratch2[..n];\n    let (v3_last, v3_init) = v3.split_last_mut().unwrap();\n    *v3_last = 0;\n    let carry = limbs_add_to_out(scratch2_lo, ys_0, ys_2);\n    *v3_last = Limb::from(carry);\n    if limbs_add_same_length_to_out(v3_init, scratch2_lo, ys_1) {\n        *v3_last += 1;\n    }\n    let (v1_last, v1_init) = v1.split_last_mut().unwrap();\n    if !carry && limbs_cmp_same_length(scratch2_lo, ys_1) == Less {\n        limbs_sub_same_length_to_out(v1_init, ys_1, scratch2_lo);\n        *v1_last = 0;\n        v_neg_2_neg.not_assign();\n    } else {\n        *v1_last = Limb::from(carry);\n        if limbs_sub_same_length_to_out(v1_init, scratch2_lo, ys_1) {\n            v1_last.wrapping_sub_assign(1);\n        }\n    }\n    // - A(-1) * B(-1)\n    // - size: m\n    limbs_mul_same_length_to_out(r8, v0, v1, mul_scratch);\n    // - A(1) * B(1)\n    // - size: m\n    limbs_mul_same_length_to_out(r7, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r7, &mut r8[..=n<<1], v_neg_2_neg, n, 0, 0);\n    // 2, -2\n    let r8_lo = &mut r8[..m];\n    v_neg_2_neg = limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v2, v0, 5, xs, n, r8_lo);\n    let (r8_lo_last, r8_lo_init) = r8_lo.split_last_mut().unwrap();\n    *r8_lo_last = limbs_shl_to_out(r8_lo_init, ys_1, 1); // 2 * ys_1\n    v3[t] = limbs_shl_to_out(v3, ys_2, 2); // 4 * ys_2\n    if n == t {\n        // 4 * ys_2 + ys_0\n        let (v3_last, v3_init) = v3.split_last_mut().unwrap();\n        if limbs_slice_add_same_length_in_place_left(v3_init, ys_0) {\n            v3_last.wrapping_add_assign(1);\n        }\n    } else {\n        // 4 * ys_2 + ys_0\n        v3[n] = Limb::from(limbs_add_to_out_aliased(v3, t + 1, ys_0));\n    }\n    if limbs_abs_sub_add_same_length(v1, v3, &r8[..m]) {\n        v_neg_2_neg.not_assign();\n    }\n    // - A(-2) * B(-2)\n    // - size: m\n    limbs_mul_same_length_to_out(r8, v0, v1, mul_scratch);\n    let (r8, r5) = out.split_at_mut(3 * n);\n    let (r5_lo, remainder) = r5.split_at_mut(m << 1);\n    split_into_chunks_mut!(remainder, m, [v2, v3], _unused);\n    // - A(2) * B(2)\n    // - size: m\n    limbs_mul_same_length_to_out(r5_lo, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r5, &mut r8[..=n<<1], v_neg_2_neg, n, 1, 2);\n    // - A(0) * B(0)\n    // - size: n\n    limbs_mul_same_length_to_out(r8, &xs[..n], &ys[..n], mul_scratch);\n    // Infinity\n    let xs_5 = &xs[5 * n..];\n    let r1 = &mut out[7 * n..];\n    // size: s, t\n    limbs_mul_to_out(r1, xs_5, ys_2, mul_scratch);\n    limbs_mul_toom_interpolate_8_points(out, n, s + t, r3, r7, scratch2);\n}}\n\n// - The limit is a rational number between (12 / 11) ^ (log(4) / log(2 * 4 - 1)) and\n// - (12 / 11) ^ (log(6) / log(2 * 6 - 1))\nconst TOOM_6H_LIMIT_NUMERATOR: usize = 18;\nconst TOOM_6H_LIMIT_DENOMINATOR: usize = 17;\n\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_6h` are valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_test! {limbs_mul_greater_to_out_toom_6h_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize\n) -> bool {\n    if xs_len == 0\n        || xs_len < ys_len\n        || ys_len < 42\n        || xs_len * 3 >= ys_len << 3 && (ys_len < 46 || xs_len * 6 >= ys_len * 17)\n    {\n        return false;\n    }\n    let n;\n    let mut half = false;\n    let mut xl = xs_len;\n    let mut yl = ys_len;\n    let (xr, yr) = if xs_len * TOOM_6H_LIMIT_DENOMINATOR < TOOM_6H_LIMIT_NUMERATOR * ys_len {\n        // xs.len() < 18 / 17 * ys.len()\n        n = 1 + (xs_len - 1) / 6;\n        let n5 = 5 * n;\n        (n5, n5)\n    } else {\n        let (p, q) = if xs_len * 5 * TOOM_6H_LIMIT_NUMERATOR\n            < TOOM_6H_LIMIT_DENOMINATOR * 7 * ys_len\n        {\n            (7, 6) // xs.len() < 119 / 90 * ys.len()\n        } else if xs_len * 5 * TOOM_6H_LIMIT_DENOMINATOR < TOOM_6H_LIMIT_NUMERATOR * 7 * ys_len {\n            (7, 5) // xs.len() < 126 / 85 * ys.len()\n        } else if xs_len * TOOM_6H_LIMIT_NUMERATOR < (TOOM_6H_LIMIT_DENOMINATOR * ys_len) << 1 {\n            (8, 5) // xs.len() < 17 / 9 * ys.len()\n        } else if xs_len * TOOM_6H_LIMIT_DENOMINATOR < (TOOM_6H_LIMIT_NUMERATOR * ys_len) << 1 {\n            (8, 4) // xs.len() < 36 / 17 * ys.len()\n        } else {\n            (9, 4) // xs.len() >= 36 / 17 * ys.len()\n        };\n        // With LIMIT = 16 / 15, the following recovery is needed only if `ys_len` <= 73.\n        n = 1 + if q * xs_len >= p * ys_len {\n            (xs_len - 1) / p\n        } else {\n            (ys_len - 1) / q\n        };\n        let pn = (p - 1) * n;\n        let qn = (q - 1) * n;\n        if !p.eq_mod_power_of_2(q, 1) {\n            // Recover from-badly chosen splitting\n            if xs_len <= pn {\n                xl += n;\n            } else if ys_len <= qn {\n                yl += n;\n            } else {\n                half = true;\n            }\n        }\n        (pn, qn)\n    };\n    xl > xr && yl > yr && {\n        let (s, t) = (xl - xr, yl - yr);\n        let limit = 12 * n + 6;\n        s <= n\n            && t <= n\n            && (half || s + t > 3)\n            && n > 2\n            && limit <= limbs_mul_greater_to_out_toom_6h_scratch_len(xs_len, ys_len)\n            && limit <= limbs_square_to_out_toom_6_scratch_len(n * 6)\n    }\n}}\n\n// TODO tune\nconst TOOM_6H_MAYBE_MUL_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || MUL_TOOM6H_THRESHOLD < 6 * MUL_TOOM22_THRESHOLD;\n// TODO tune\nconst TOOM_6H_MAYBE_MUL_TOOM22: bool =\n    TUNE_PROGRAM_BUILD || MUL_TOOM6H_THRESHOLD < 6 * MUL_TOOM33_THRESHOLD;\nconst TOOM_6H_MAYBE_MUL_TOOM33: bool =\n    TUNE_PROGRAM_BUILD || MUL_TOOM6H_THRESHOLD < 6usize.saturating_mul(MUL_TOOM44_THRESHOLD);\nconst TOOM_6H_MAYBE_MUL_TOOM6H: bool =\n    TUNE_PROGRAM_BUILD || MUL_FFT_THRESHOLD >= 6 * MUL_TOOM6H_THRESHOLD;\n\nfn limbs_mul_same_length_to_out_toom_6h_recursive_scratch_len(n: usize) -> usize {\n    if TOOM_6H_MAYBE_MUL_BASECASE && n < MUL_TOOM22_THRESHOLD {\n        0\n    } else if TOOM_6H_MAYBE_MUL_TOOM22 && n < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22_scratch_len(n, n)\n    } else if TOOM_6H_MAYBE_MUL_TOOM33 && n < MUL_TOOM44_THRESHOLD {\n        limbs_mul_greater_to_out_toom_33_scratch_len(n, n)\n    } else if !TOOM_6H_MAYBE_MUL_TOOM6H || n < MUL_TOOM6H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_44_scratch_len(n, n)\n    } else {\n        limbs_mul_greater_to_out_toom_6h_scratch_len(n, n)\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM6H_MUL_N_REC` from `mpn/generic/toom6h_mul.c`, GMP 6.2.1, when `f` is\n// false.\nfn limbs_mul_same_length_to_out_toom_6h_recursive(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    if TOOM_6H_MAYBE_MUL_BASECASE && n < MUL_TOOM22_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if TOOM_6H_MAYBE_MUL_TOOM22 && n < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n    } else if TOOM_6H_MAYBE_MUL_TOOM33 && n < MUL_TOOM44_THRESHOLD {\n        limbs_mul_greater_to_out_toom_33(out, xs, ys, scratch);\n    } else if !TOOM_6H_MAYBE_MUL_TOOM6H || n < MUL_TOOM6H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_44(out, xs, ys, scratch);\n    } else {\n        limbs_mul_greater_to_out_toom_6h(out, xs, ys, scratch);\n    }\n}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_6h`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom6h_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_6h_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n;\n    let mut half = false;\n    let (pn, qn) = if xs_len * TOOM_6H_LIMIT_DENOMINATOR < TOOM_6H_LIMIT_NUMERATOR * ys_len {\n        // - xs.len() < 18 / 17 * ys.len()\n        // - This is the slowest variation\n        n = 1 + (xs_len - 1) / 6;\n        let n5 = 5 * n;\n        (n5, n5)\n    } else {\n        let (mut p, mut q) = if xs_len * 5 * TOOM_6H_LIMIT_NUMERATOR\n            < TOOM_6H_LIMIT_DENOMINATOR * 7 * ys_len\n        {\n            // xs.len() < 119 / 90 * ys.len(), half\n            (7, 6)\n        } else if xs_len * 5 * TOOM_6H_LIMIT_DENOMINATOR < TOOM_6H_LIMIT_NUMERATOR * 7 * ys_len {\n            // xs.len() < 126 / 85 * ys.len(), !half\n            (7, 5)\n        } else if xs_len * TOOM_6H_LIMIT_NUMERATOR < (TOOM_6H_LIMIT_DENOMINATOR * ys_len) << 1 {\n            // xs.len() < 17 / 9 * ys.len(), half\n            (8, 5)\n        } else if xs_len * TOOM_6H_LIMIT_DENOMINATOR < (TOOM_6H_LIMIT_NUMERATOR * ys_len) << 1 {\n            // xs.len() < 36 / 17 * ys.len(), !half\n            (8, 4)\n        } else {\n            // xs.len() >= 36 / 17 * ys.len(), half\n            (9, 4)\n        };\n        n = 1 + if q * xs_len >= p * ys_len {\n            (xs_len - 1) / p\n        } else {\n            (ys_len - 1) / q\n        };\n        p -= 1;\n        q -= 1;\n        let mut pn = p * n;\n        let mut qn = q * n;\n        // With LIMIT = 16 / 15, the following recovery is needed only if `ys_len` <= 73.\n        if !p.eq_mod_power_of_2(q, 1) {\n            // Recover from badly-chosen splitting\n            if xs_len <= pn {\n                pn -= n;\n            } else if ys_len <= qn {\n                qn -= n;\n            } else {\n                half = true;\n            }\n        }\n        (pn, qn)\n    };\n    let m = n + 1;\n    assert!(m < xs_len);\n    let s = xs_len - pn;\n    let t = ys_len - qn;\n    let mut mul_scratch_len = max!(\n        3 * n - 1,\n        limbs_mul_same_length_to_out_toom_6h_recursive_scratch_len(n),\n        limbs_mul_same_length_to_out_toom_6h_recursive_scratch_len(m)\n    );\n    if half {\n        mul_scratch_len = max(mul_scratch_len, limbs_mul_to_out_scratch_len(s, t));\n    }\n    10 * n + 4 + mul_scratch_len\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_6h_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - Others; see `limbs_mul_greater_to_out_toom_6h_input_sizes_valid`.\n//\n// This uses the Toom-6h algorithm (Toom-6.5).\n//\n// Evaluate in: Infinity, 4, -4, 2, -2, 1, -1, 1 / 2, -1 / 2, 1 / 4, -1 / 4, 0.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_5 11}) \\approx O(n^{1.490}) (assuming worst-possible splitting), but\n// `limbs_mul_same_length_to_out_toom_6h_recursive` ultimately calls `limbs_mul_greater_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom6h_mul` from `mpn/generic/toom6h_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_6h(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    // - Decomposition\n    // - Can not handle too much unbalance\n    assert!(ys_len >= 42);\n    assert!(xs_len * 3 < ys_len << 3 || ys_len >= 46 && xs_len * 6 < ys_len * 17);\n    let n;\n    let mut half = false;\n    let (p, q, pn, qn) = if xs_len * TOOM_6H_LIMIT_DENOMINATOR < TOOM_6H_LIMIT_NUMERATOR * ys_len {\n        // - xs.len() < 18 / 17 * ys.len()\n        // - This is the slowest variation\n        n = 1 + (xs_len - 1) / 6;\n        let n5 = 5 * n;\n        (5, 5, n5, n5)\n    } else {\n        let (mut p, mut q) = if xs_len * 5 * TOOM_6H_LIMIT_NUMERATOR\n            < TOOM_6H_LIMIT_DENOMINATOR * 7 * ys_len\n        {\n            // xs.len() < 119 / 90 * ys.len(), half\n            (7, 6)\n        } else if xs_len * 5 * TOOM_6H_LIMIT_DENOMINATOR < TOOM_6H_LIMIT_NUMERATOR * 7 * ys_len {\n            // xs.len() < 126 / 85 * ys.len(), !half\n            (7, 5)\n        } else if xs_len * TOOM_6H_LIMIT_NUMERATOR < (TOOM_6H_LIMIT_DENOMINATOR * ys_len) << 1 {\n            // xs.len() < 17 / 9 * ys.len(), half\n            (8, 5)\n        } else if xs_len * TOOM_6H_LIMIT_DENOMINATOR < (TOOM_6H_LIMIT_NUMERATOR * ys_len) << 1 {\n            // xs.len() < 36 / 17 * ys.len(), !half\n            (8, 4)\n        } else {\n            // xs.len() >= 36 / 17 * ys.len(), half\n            (9, 4)\n        };\n        n = 1 + if q * xs_len >= p * ys_len {\n            (xs_len - 1) / p\n        } else {\n            (ys_len - 1) / q\n        };\n        p -= 1;\n        q -= 1;\n        let mut pn = p * n;\n        let mut qn = q * n;\n        // With LIMIT = 16 / 15, the following recovery is needed only if `ys_len` <= 73.\n        if !p.eq_mod_power_of_2(q, 1) {\n            // Recover from badly-chosen splitting\n            if xs_len <= pn {\n                p -= 1;\n                pn -= n;\n            } else if ys_len <= qn {\n                q -= 1;\n                qn -= n;\n            } else {\n                half = true;\n            }\n        }\n        (p, q, pn, qn)\n    };\n    assert!(n > 2);\n    assert!(xs_len > pn);\n    let s = xs_len - pn;\n    assert!(s <= n);\n    assert!(ys_len > qn);\n    let t = ys_len - qn;\n    assert!(t <= n);\n    assert!(half || s + t > 3);\n    let m = n + 1;\n    // r == 2 * n + 1\n    let r = m + n;\n    split_into_chunks_mut!(scratch, 3 * n + 1, [r5, r3, r1], scratch2);\n    let (out_lo, remainder) = out.split_at_mut(3 * n);\n    let (r4, remainder) = remainder.split_at_mut(n << 2);\n    split_into_chunks_mut!(remainder, m, [v0, v1, v2], _unused);\n    let (v3, mul_scratch) = scratch2.split_at_mut(m);\n    // - Evaluation and recursive calls\n    // - 1/2, -1/2\n    let out_lo_lo = &mut out_lo[..m];\n    let v_neg_half_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(v2, v0, p, xs, n, 1, out_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n                v3, v1, q, ys, n, 1, out_lo_lo,\n            );\n    // - X(-1/2) * Y(-1/2) * 2^\n    // - X(1/2) * Y(1/2) * 2^\n    // - size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(out_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(r5, v2, v3, mul_scratch);\n    if half {\n        limbs_toom_couple_handling(r5, &mut out_lo[..r], v_neg_half_neg, n, 2, 1);\n    } else {\n        limbs_toom_couple_handling(r5, &mut out_lo[..r], v_neg_half_neg, n, 1, 0);\n    }\n    // 1, -1\n    let out_lo_lo = &mut out_lo[..m];\n    let mut v_neg_1_neg = limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v2, v0, p, xs, n, out_lo_lo);\n    let flip = if q == 3 {\n        limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(v3, v1, ys, n, out_lo_lo)\n    } else {\n        limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v3, v1, q, ys, n, out_lo_lo)\n    };\n    if flip {\n        v_neg_1_neg.not_assign();\n    }\n    // - X(-1) * Y(-1)\n    // - X(1) * Y(1)\n    // - size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(out_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(r3, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r3, &mut out_lo[..r], v_neg_1_neg, n, 0, 0);\n    // 4, -4\n    let out_lo_lo = &mut out_lo[..m];\n    let v_neg_4_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, p, xs, n, 2, out_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v3, v1, q, ys, n, 2, out_lo_lo);\n    // - X(-4) * Y(-4)\n    // - size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(out_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(r1, v2, v3, mul_scratch);\n    // X(4) * B(4)\n    limbs_toom_couple_handling(r1, &mut out_lo[..r], v_neg_4_neg, n, 2, 4);\n    // 1/4, -1/4\n    let out_lo_lo = &mut out_lo[..m];\n    let v_neg_quarter_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(v2, v0, p, xs, n, 2, out_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n                v3, v1, q, ys, n, 2, out_lo_lo,\n            );\n    // - X(-1/4) * Y(-1/4) * 4^\n    // - X(1/4) * Y(1/4) * 4^\n    // - size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(out_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(r4, v2, v3, mul_scratch);\n    if half {\n        limbs_toom_couple_handling(r4, &mut out_lo[..r], v_neg_quarter_neg, n, 4, 2);\n    } else {\n        limbs_toom_couple_handling(r4, &mut out_lo[..r], v_neg_quarter_neg, n, 2, 0);\n    }\n    let out_lo = &mut out_lo[..m];\n    // 2, -2\n    let v_neg_2_neg = limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v2, v0, p, xs, n, out_lo)\n        != limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v3, v1, q, ys, n, out_lo);\n    // - X(-2) * Y(-2)\n    // - X(2) * Y(2)\n    let (out_lo, r2) = out.split_at_mut(7 * n);\n    let (r2_v1, v2) = r2.split_at_mut(m << 1);\n    let v2 = &mut v2[..m];\n    {\n        let (r2, v1) = r2_v1.split_at_mut(m);\n        // size: m\n        limbs_mul_same_length_to_out_toom_6h_recursive(out_lo, r2, v1, mul_scratch);\n    }\n    // size: m\n    limbs_mul_same_length_to_out_toom_6h_recursive(r2_v1, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r2, &mut out_lo[..r], v_neg_2_neg, n, 1, 2);\n    // - X(0) * Y(0)\n    // - size: n\n    limbs_mul_same_length_to_out_toom_6h_recursive(out, &xs[..n], &ys[..n], mul_scratch);\n    // Infinity\n    if half {\n        // size: s, t\n        limbs_mul_to_out(&mut out[11 * n..], &xs[pn..], &ys[qn..], mul_scratch);\n    }\n    limbs_mul_toom_interpolate_12_points(out, r1, r3, r5, n, s + t, half, scratch2);\n}}\n\n// Limit num/den is a rational number between (16 / 15) ^ (log(6) / log(2 * 6 - 1)) and (16 / 15) ^\n// (log(8) / log(2 * 8 - 1))\nconst TOOM_8H_LIMIT_NUMERATOR: usize = 21;\nconst TOOM_8H_LIMIT_DENOMINATOR: usize = 20;\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This function can be used to determine whether the sizes of the input slices to\n// `limbs_mul_greater_to_out_toom_8h` are valid.\npub_test! {limbs_mul_greater_to_out_toom_8h_input_sizes_valid(\n    xs_len: usize,\n    ys_len: usize\n) -> bool {\n    if xs_len == 0\n        || ys_len < 86\n        || xs_len < ys_len\n        || xs_len > ys_len << 2\n        || Limb::WIDTH <= 11 * 3 && xs_len << 2 > ys_len * 11\n        || Limb::WIDTH <= 10 * 3 && xs_len > ys_len << 1\n        || Limb::WIDTH <= 9 * 3 && xs_len << 1 > ys_len * 3\n    {\n        return false;\n    }\n    let n;\n    let mut half = false;\n    let mut xl = xs_len;\n    let mut yl = ys_len;\n    let (xr, yr) = if xs_len == ys_len\n        || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1) < TOOM_8H_LIMIT_NUMERATOR * (ys_len >> 1)\n    {\n        // - xs_len == ys_len || xs_len < 21 / 20 * ys_len, !half\n        // - This is the slowest variation\n        n = 1 + ((xs_len - 1) >> 3);\n        let n7 = 7 * n;\n        (n7, n7)\n    } else {\n        let (p, q) = if xs_len * 13 < ys_len << 4 {\n            // xs_len < 16 / 13 * ys_len, half\n            (9, 8)\n        } else if Limb::WIDTH <= 9 * 3\n            || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1)\n                < (TOOM_8H_LIMIT_NUMERATOR / 7 * 9) * (ys_len >> 1)\n        {\n            // Limb::WIDTH <= 27 || xs_len < 27 / 20 * ys_len, !half\n            (9, 7)\n        } else if xs_len * 10 < 33 * (ys_len >> 1) {\n            // xs_len < 33 / 20 * ys_len, half\n            (10, 7)\n        } else if Limb::WIDTH <= 10 * 3\n            || xs_len * (TOOM_8H_LIMIT_DENOMINATOR / 5) < (TOOM_8H_LIMIT_NUMERATOR / 3) * ys_len\n        {\n            // Limb::WIDTH <= 30 || xs_len < 7 / 4 * ys_len, !half\n            (10, 6)\n        } else if xs_len * 6 < 13 * ys_len {\n            // xs_len < 13 / 6 * ys_len, half\n            (11, 6)\n        } else if Limb::WIDTH <= 11 * 3 || xs_len << 2 < 9 * ys_len {\n            // Limb::WIDTH <= 33 || xs_len < 9 / 4 * ys_len, !half\n            (11, 5)\n        } else if xs_len * (TOOM_8H_LIMIT_NUMERATOR / 3) < TOOM_8H_LIMIT_DENOMINATOR * ys_len {\n            // xs_len < 20 / 7 * ys_len, half\n            (12, 5)\n        } else if Limb::WIDTH <= 12 * 3 || xs_len * 9 < 28 * ys_len {\n            // Limb::WIDTH <= 36 || xs_len < 28 / 9 * ys_len, !half\n            (12, 4)\n        } else {\n            // half\n            (13, 4)\n        };\n        n = 1 + if q * xs_len >= p * ys_len {\n            (xs_len - 1) / p\n        } else {\n            (ys_len - 1) / q\n        };\n        let pn = (p - 1) * n;\n        let qn = (q - 1) * n;\n        if !p.eq_mod_power_of_2(q, 1) {\n            // Recover from badly chosen splitting\n            if xs_len <= pn {\n                xl += n;\n            } else if ys_len <= qn {\n                yl += n;\n            } else {\n                half = true;\n            }\n        }\n        (pn, qn)\n    };\n    xl > xr && yl > yr && {\n        let (s, t) = (xl - xr, yl - yr);\n        let limit = 15 * n + 6;\n        s <= n\n            && t <= n\n            && (half || s + t > 3)\n            && n > 2\n            && limit <= limbs_mul_greater_to_out_toom_8h_scratch_len(xs_len, ys_len)\n            && limit <= limbs_square_to_out_toom_8_scratch_len(n << 3)\n    }\n}}\n\n#[cfg(feature = \"32_bit_limbs\")]\npub(crate) const BIT_CORRECTION: bool = true;\n#[cfg(not(feature = \"32_bit_limbs\"))]\npub(crate) const BIT_CORRECTION: bool = false;\n\n// TODO tune\nconst TOOM_8H_MAYBE_MUL_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || MUL_TOOM8H_THRESHOLD < MUL_TOOM22_THRESHOLD << 3;\n// TODO tune\nconst TOOM_8H_MAYBE_MUL_TOOM22: bool =\n    TUNE_PROGRAM_BUILD || MUL_TOOM8H_THRESHOLD < MUL_TOOM33_THRESHOLD << 3;\n// TODO tune\nconst TOOM_8H_MAYBE_MUL_TOOM33: bool =\n    TUNE_PROGRAM_BUILD || MUL_TOOM8H_THRESHOLD < MUL_TOOM44_THRESHOLD << 3;\n// TODO tune\nconst TOOM_8H_MAYBE_MUL_TOOM44: bool =\n    TUNE_PROGRAM_BUILD || MUL_TOOM8H_THRESHOLD < MUL_TOOM6H_THRESHOLD << 3;\n// TODO tune\nconst TOOM_8H_MAYBE_MUL_TOOM8H: bool =\n    TUNE_PROGRAM_BUILD || MUL_FFT_THRESHOLD >= MUL_TOOM8H_THRESHOLD << 3;\n\nfn limbs_mul_same_length_to_out_toom_8h_recursive_scratch_len(n: usize) -> usize {\n    if TOOM_8H_MAYBE_MUL_BASECASE && n < MUL_TOOM22_THRESHOLD {\n        0\n    } else if TOOM_8H_MAYBE_MUL_TOOM22 && n < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22_scratch_len(n, n)\n    } else if TOOM_8H_MAYBE_MUL_TOOM33 && n < MUL_TOOM44_THRESHOLD {\n        limbs_mul_greater_to_out_toom_33_scratch_len(n, n)\n    } else if TOOM_8H_MAYBE_MUL_TOOM44 && n < MUL_TOOM6H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_44_scratch_len(n, n)\n    } else if !TOOM_8H_MAYBE_MUL_TOOM8H || n < MUL_TOOM8H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_6h_scratch_len(n, n)\n    } else {\n        limbs_mul_greater_to_out_toom_8h_scratch_len(n, n)\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_7 15}) \\approx O(n^{1.392}), but\n// `limbs_mul_same_length_to_out_toom_22` ultimately calls `limbs_mul_greater_to_out`.\n//\n// This is equivalent to `TOOM8H_MUL_N_REC` from `mpn/generic/toom8h_mul.c`, GMP 6.2.1, when `f` is\n// false.\nfn limbs_mul_same_length_to_out_toom_8h_recursive(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let n = xs.len();\n    assert_eq!(ys.len(), n);\n    if TOOM_8H_MAYBE_MUL_BASECASE && n < MUL_TOOM22_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if TOOM_8H_MAYBE_MUL_TOOM22 && n < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n    } else if TOOM_8H_MAYBE_MUL_TOOM33 && n < MUL_TOOM44_THRESHOLD {\n        limbs_mul_greater_to_out_toom_33(out, xs, ys, scratch);\n    } else if TOOM_8H_MAYBE_MUL_TOOM44 && n < MUL_TOOM6H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_44(out, xs, ys, scratch);\n    } else if !TOOM_8H_MAYBE_MUL_TOOM8H || n < MUL_TOOM8H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_6h(out, xs, ys, scratch);\n    } else {\n        limbs_mul_greater_to_out_toom_8h(out, xs, ys, scratch);\n    }\n}\n\n// This function can be used to determine the length of the input `scratch` slice in\n// `limbs_mul_greater_to_out_toom_8h`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom8h_mul_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_8h_scratch_len(\n    xs_len: usize,\n    ys_len: usize\n) -> usize {\n    let n;\n    let mut half = false;\n    let (pn, qn) = if xs_len == ys_len\n        || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1) < TOOM_8H_LIMIT_NUMERATOR * (ys_len >> 1)\n    {\n        // - xs_len == ys_len || xs_len < 21 / 20 * ys_len, !half\n        // - This is the slowest variation\n        n = 1 + ((xs_len - 1) >> 3);\n        let n7 = 7 * n;\n        (n7, n7)\n    } else {\n        let (mut p, mut q) = if xs_len * 13 < ys_len << 4 {\n            // xs_len < 16 / 13 * ys_len, half\n            (9, 8)\n        } else if Limb::WIDTH <= 9 * 3\n            || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1)\n                < (TOOM_8H_LIMIT_NUMERATOR / 7 * 9) * (ys_len >> 1)\n        {\n            // Limb::WIDTH <= 27 || xs_len < 27 / 20 * ys_len, !half\n            (9, 7)\n        } else if xs_len * 10 < 33 * (ys_len >> 1) {\n            // xs_len < 33 / 20 * ys_len, half\n            (10, 7)\n        } else if Limb::WIDTH <= 10 * 3\n            || xs_len * (TOOM_8H_LIMIT_DENOMINATOR / 5) < (TOOM_8H_LIMIT_NUMERATOR / 3) * ys_len\n        {\n            // Limb::WIDTH <= 30 || xs_len < 7 / 4 * ys_len, !half\n            (10, 6)\n        } else if xs_len * 6 < 13 * ys_len {\n            // xs_len < 13 / 6 * ys_len, half\n            (11, 6)\n        } else if Limb::WIDTH <= 11 * 3 || xs_len << 2 < 9 * ys_len {\n            // Limb::WIDTH <= 33 || xs_len < 9 / 4 * ys_len, !half\n            (11, 5)\n        } else if xs_len * (TOOM_8H_LIMIT_NUMERATOR / 3) < TOOM_8H_LIMIT_DENOMINATOR * ys_len {\n            // xs_len < 20 / 7 * ys_len, half\n            (12, 5)\n        } else if Limb::WIDTH <= 12 * 3 || xs_len * 9 < 28 * ys_len {\n            // Limb::WIDTH <= 36 || xs_len < 28 / 9 * ys_len, !half\n            (12, 4)\n        } else {\n            // half\n            (13, 4)\n        };\n        n = 1 + if q * xs_len >= p * ys_len {\n            (xs_len - 1) / p\n        } else {\n            (ys_len - 1) / q\n        };\n        p -= 1;\n        q -= 1;\n        let mut pn = p * n;\n        let mut qn = q * n;\n        if !p.eq_mod_power_of_2(q, 1) {\n            // Recover from badly chosen splitting\n            if xs_len <= pn {\n                pn -= n;\n            } else if ys_len <= qn {\n                qn -= n;\n            } else {\n                half = true;\n            }\n        }\n        (pn, qn)\n    };\n    let s = xs_len - pn;\n    let t = ys_len - qn;\n    let m = n + 1;\n    assert!(m < xs_len);\n    let mut mul_scratch_len = max!(\n        3 * n + 1,\n        limbs_mul_same_length_to_out_toom_8h_recursive_scratch_len(n),\n        limbs_mul_same_length_to_out_toom_8h_recursive_scratch_len(m)\n    );\n    if half {\n        mul_scratch_len = max(mul_scratch_len, limbs_mul_to_out_scratch_len(s, t));\n    }\n    13 * n + 5 + mul_scratch_len\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the `xs.len() + ys.len()` least-significant limbs of the product of the `Natural`s to an output\n// slice. A scratch slice is provided for the algorithm to use. An upper bound for the number of\n// scratch limbs needed is provided by `limbs_mul_greater_to_out_toom_8h_scratch_len`. The following\n// restrictions on the input slices must be met:\n// - `out`.len() >= `xs`.len() + `ys`.len()\n// - `xs`.len() >= `ys`.len()\n// - Others; see `limbs_mul_greater_to_out_toom_8h_input_sizes_valid`.\n//\n// This uses the Toom-8h algorithm (Toom-8.5).\n//\n// Evaluate in: Infinity, 8, -8, 4, -4, 2, -2, 1, -1, 1 / 2, -1 / 2, 1 / 4, -1 / 4, 1 / 8, -1 / 8,\n// 0.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// The time would be O(n^{\\log_7 15}) \\approx O(n^{1.392}), but\n// `limbs_mul_same_length_to_out_toom_8h_recursive` ultimately calls `limbs_mul_greater_to_out`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom8h_mul` from `mpn/generic/toom8h_mul.c`, GMP 6.2.1.\npub_crate_test! {limbs_mul_greater_to_out_toom_8h(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    // - Decomposition\n    // - Can not handle too small operands\n    assert!(ys_len >= 86);\n    // Can not handle too much unbalance\n    assert!(xs_len <= ys_len << 2);\n    assert!(Limb::WIDTH > 11 * 3 || xs_len << 2 <= ys_len * 11);\n    assert!(Limb::WIDTH > 10 * 3 || xs_len <= ys_len << 1);\n    assert!(Limb::WIDTH > 9 * 3 || xs_len << 1 <= ys_len * 3);\n    let n;\n    let mut half = false;\n    let (p, q, pn, qn) = if xs_len == ys_len\n        || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1) < TOOM_8H_LIMIT_NUMERATOR * (ys_len >> 1)\n    {\n        // - xs_len == ys_len || xs_len < 21 / 20 * ys_len, !half\n        // - This is the slowest variation\n        n = 1 + ((xs_len - 1) >> 3);\n        let n7 = 7 * n;\n        (7, 7, n7, n7)\n    } else {\n        let (mut p, mut q) = if xs_len * 13 < ys_len << 4 {\n            // xs_len < 16 / 13 * ys_len, half\n            (9, 8)\n        } else if Limb::WIDTH <= 9 * 3\n            || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1)\n                < (TOOM_8H_LIMIT_NUMERATOR / 7 * 9) * (ys_len >> 1)\n        {\n            // Limb::WIDTH <= 27 || xs_len < 27 / 20 * ys_len, !half\n            (9, 7)\n        } else if xs_len * 10 < 33 * (ys_len >> 1) {\n            // xs_len < 33 / 20 * ys_len, half\n            (10, 7)\n        } else if Limb::WIDTH <= 10 * 3\n            || xs_len * (TOOM_8H_LIMIT_DENOMINATOR / 5) < (TOOM_8H_LIMIT_NUMERATOR / 3) * ys_len\n        {\n            // Limb::WIDTH <= 30 || xs_len < 7 / 4 * ys_len, !half\n            (10, 6)\n        } else if xs_len * 6 < 13 * ys_len {\n            // xs_len < 13 / 6 * ys_len, half\n            (11, 6)\n        } else if Limb::WIDTH <= 11 * 3 || xs_len << 2 < 9 * ys_len {\n            // Limb::WIDTH <= 33 || xs_len < 9 / 4 * ys_len, !half\n            (11, 5)\n        } else if xs_len * (TOOM_8H_LIMIT_NUMERATOR / 3) < TOOM_8H_LIMIT_DENOMINATOR * ys_len {\n            // xs_len < 20 / 7 * ys_len, half\n            (12, 5)\n        } else if Limb::WIDTH <= 12 * 3 || xs_len * 9 < 28 * ys_len {\n            // Limb::WIDTH <= 36 || xs_len < 28 / 9 * ys_len, !half\n            (12, 4)\n        } else {\n            // half\n            (13, 4)\n        };\n        n = 1 + if q * xs_len >= p * ys_len {\n            (xs_len - 1) / p\n        } else {\n            (ys_len - 1) / q\n        };\n        p -= 1;\n        q -= 1;\n        let mut pn = p * n;\n        let mut qn = q * n;\n        if !p.eq_mod_power_of_2(q, 1) {\n            // Recover from badly chosen splitting\n            if xs_len <= pn {\n                p -= 1;\n                pn -= n;\n            } else if ys_len <= qn {\n                q -= 1;\n                qn -= n;\n            } else {\n                half = true;\n            }\n        }\n        (p, q, pn, qn)\n    };\n    assert!(n > 2);\n    assert!(xs_len > pn);\n    let s = xs_len - pn;\n    assert!(s <= n);\n    assert!(ys_len > qn);\n    let t = ys_len - qn;\n    assert!(t <= n);\n    assert!(half || s + t > 3);\n    let m = n + 1;\n    let u = m + n; // 2 * n + 1\n    let r = 3 * n + 1;\n    // Evaluation and recursive calls\n    let (pp_lo, remainder) = out.split_at_mut(3 * n);\n    split_into_chunks_mut!(remainder, n << 2, [r6, r4], remainder);\n    split_into_chunks_mut!(remainder, m, [v0, v1, v2], _unused);\n    let (r7, remainder) = scratch.split_at_mut(r);\n    let (v3, mul_scratch) = remainder[3 * r..].split_at_mut(m);\n    // 1/8, -1/8\n    let pp_lo_lo = &mut pp_lo[..m];\n    let v_neg_8th_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(v2, v0, p, xs, n, 3, pp_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n                v3, v1, q, ys, n, 3, pp_lo_lo,\n            );\n    // - X(-1/8) * Y(-1/8) * 8^\n    // - X(1/8) * Y(1/8) * 8^\n    // - size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(pp_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(r7, v2, v3, mul_scratch);\n    let limit = if BIT_CORRECTION { m << 1 } else { u };\n    let pp_lo_lo = &mut pp_lo[..limit];\n    if half {\n        limbs_toom_couple_handling(scratch, pp_lo_lo, v_neg_8th_neg, n, 6, 3);\n    } else {\n        limbs_toom_couple_handling(scratch, pp_lo_lo, v_neg_8th_neg, n, 3, 0);\n    }\n    split_into_chunks_mut!(scratch, r, [_unused, r5, r3, r1], remainder);\n    let (v3, mul_scratch) = remainder.split_at_mut(m);\n    // 1/4, -1/4\n    let pp_lo_lo = &mut pp_lo[..m];\n    let v_neg_quarter_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(v2, v0, p, xs, n, 2, pp_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n                v3, v1, q, ys, n, 2, pp_lo_lo,\n            );\n    // - X(-1/4) * Y(-1/4) * 4^\n    // - X(1/4) * Y(1/4) * 4^\n    // - size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(pp_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(r5, v2, v3, mul_scratch);\n    let pp_lo_lo = &mut pp_lo[..u];\n    if half {\n        limbs_toom_couple_handling(r5, pp_lo_lo, v_neg_quarter_neg, n, 4, 2);\n    } else {\n        limbs_toom_couple_handling(r5, pp_lo_lo, v_neg_quarter_neg, n, 2, 0);\n    }\n    // 2, -2\n    let pp_lo_lo = &mut pp_lo[..m];\n    let v_neg_2_neg = limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v2, v0, p, xs, n, pp_lo_lo)\n        != limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v3, v1, q, ys, n, pp_lo_lo);\n    // - X(-2) * Y(-2)\n    // - X(2) * Y(2)\n    // - size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(pp_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(r3, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r3, &mut pp_lo[..u], v_neg_2_neg, n, 1, 2);\n    // 8, -8\n    let pp_lo_lo = &mut pp_lo[..m];\n    let v_neg_8_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, p, xs, n, 3, pp_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v3, v1, q, ys, n, 3, pp_lo_lo);\n    // - X(-8) * Y(-8)\n    // - X(8) * Y(8)\n    // - size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(pp_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(r1, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(\n        &mut scratch[3 * r..],\n        &mut pp_lo[..limit],\n        v_neg_8_neg,\n        n,\n        3,\n        6,\n    );\n    let (v3, mul_scratch) = scratch[r << 2..].split_at_mut(m);\n    // 1/2, -1/2\n    let pp_lo_lo = &mut pp_lo[..m];\n    let v_neg_half_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(v2, v0, p, xs, n, 1, pp_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n                v3, v1, q, ys, n, 1, pp_lo_lo,\n            );\n    // - X(-1/2) * Y(-1/2) * 2^\n    // - X(1/2) * Y(1/2) * 2^\n    // - size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(pp_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(r6, v2, v3, mul_scratch);\n    let pp_lo_lo = &mut pp_lo[..u];\n    if half {\n        limbs_toom_couple_handling(r6, pp_lo_lo, v_neg_half_neg, n, 2, 1);\n    } else {\n        limbs_toom_couple_handling(r6, pp_lo_lo, v_neg_half_neg, n, 1, 0);\n    }\n    // 1, -1\n    let pp_lo_lo = &mut pp_lo[..m];\n    let mut v_neg_1_neg = limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v2, v0, p, xs, n, pp_lo_lo);\n    if if Limb::WIDTH > 36 && q == 3 {\n        limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(v3, v1, ys, n, pp_lo_lo)\n    } else {\n        limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v3, v1, q, ys, n, pp_lo_lo)\n    } {\n        v_neg_1_neg.not_assign();\n    }\n    // - X(-1) * Y(-1)\n    // - X(1) * Y(1)\n    // - size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(pp_lo, v0, v1, mul_scratch);\n    // size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(r4, v2, v3, mul_scratch);\n    limbs_toom_couple_handling(r4, &mut pp_lo[..u], v_neg_1_neg, n, 0, 0);\n    // 4, -4\n    let pp_lo_lo = &mut pp_lo[..m];\n    let v_neg_4_neg =\n        limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, p, xs, n, 2, pp_lo_lo)\n            != limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v3, v1, q, ys, n, 2, pp_lo_lo);\n    // - X(-4) * Y(-4)\n    // - X(4) * Y(4)\n    // - size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(pp_lo, v0, v1, mul_scratch);\n    split_into_chunks_mut!(scratch, r, [r7, r5, r3, r1], mul_scratch);\n    let (v3, mul_scratch) = mul_scratch.split_at_mut(m);\n    let (r2, v2) = out[11 * n..].split_at_mut(m << 1);\n    // size: m\n    limbs_mul_same_length_to_out_toom_8h_recursive(r2, &v2[..m], v3, mul_scratch);\n    let (pp_lo, r2) = out.split_at_mut(11 * n);\n    limbs_toom_couple_handling(r2, &mut pp_lo[..u], v_neg_4_neg, n, 2, 4);\n    // - X(0) * Y(0)\n    // - size: n\n    limbs_mul_same_length_to_out_toom_8h_recursive(out, &xs[..n], &ys[..n], mul_scratch);\n    // Infinity\n    if half {\n        // size: s, t\n        limbs_mul_to_out(&mut out[15 * n..], &xs[pn..], &ys[qn..], mul_scratch);\n    }\n    limbs_mul_toom_interpolate_16_points(\n        out,\n        r1,\n        r3,\n        r5,\n        r7,\n        n,\n        s + t,\n        half,\n        &mut mul_scratch[..r],\n    );\n}}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1997, 1999-2016, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::platform::Limb;\nuse core::ops::Neg;\nuse malachite_base::num::arithmetic::traits::WrappingNegAssign;\nuse malachite_base::slices::slice_leading_zeros;\n\n// This is equivalent to `mpn_neg` from `gmp.h`, GMP 6.2.1, where rp == up.\npub(crate) fn limbs_neg_in_place(xs: &mut [Limb]) -> bool {\n    let n = xs.len();\n    let zeros = slice_leading_zeros(xs);\n    if zeros == n {\n        return false;\n    }\n    xs[zeros].wrapping_neg_assign();\n    let offset = zeros + 1;\n    if offset != n {\n        limbs_not_in_place(&mut xs[offset..]);\n    }\n    true\n}\n\nimpl Neg for Natural {\n    type Output = Integer;\n\n    /// Negates a [`Natural`], taking it by value and returning an [`Integer`].\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(-Natural::ZERO, 0);\n    /// assert_eq!(-Natural::from(123u32), -123);\n    /// ```\n    fn neg(self) -> Integer {\n        Integer::from_sign_and_abs(self == 0, self)\n    }\n}\n\nimpl Neg for &Natural {\n    type Output = Integer;\n\n    /// Negates a [`Natural`], taking it by reference and returning an [`Integer`].\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(-&Natural::ZERO, 0);\n    /// assert_eq!(-&Natural::from(123u32), -123);\n    /// ```\n    fn neg(self) -> Integer {\n        Integer::from_sign_and_abs_ref(*self == 0, self)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, NextPowerOf2, NextPowerOf2Assign,\n};\nuse malachite_base::slices::{slice_set_zero, slice_test_zero};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the smallest integer power of 2 greater than or equal to the `Natural`.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_next_power_of_2(xs: &[Limb]) -> Vec<Limb> {\n    let (xs_last, xs_init) = xs.split_last().unwrap();\n    let mut out;\n    if let Some(x) = xs_last.checked_next_power_of_two() {\n        out = vec![0; xs_init.len()];\n        if x == *xs_last && !slice_test_zero(xs_init) {\n            if let Some(x) = x.arithmetic_checked_shl(1) {\n                out.push(x);\n            } else {\n                out.push(0);\n                out.push(1);\n            }\n        } else {\n            out.push(x);\n        }\n    } else {\n        out = vec![0; xs.len()];\n        out.push(1);\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the smallest integer power of 2 greater than or equal to the `Natural` to the input\n// slice. If the input slice is too small to hold the result, the limbs are all set to zero and the\n// carry bit, `true`, is returned. Otherwise, `false` is returned.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_slice_next_power_of_2_in_place(xs: &mut [Limb]) -> bool {\n    let (xs_last, xs_init) = xs.split_last_mut().unwrap();\n    if let Some(x) = xs_last.checked_next_power_of_two() {\n        if x == *xs_last && !slice_test_zero(xs_init) {\n            slice_set_zero(xs_init);\n            if let Some(x) = x.arithmetic_checked_shl(1) {\n                *xs_last = x;\n                false\n            } else {\n                *xs_last = 0;\n                true\n            }\n        } else {\n            slice_set_zero(xs_init);\n            *xs_last = x;\n            false\n        }\n    } else {\n        slice_set_zero(xs_init);\n        *xs_last = 0;\n        true\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the smallest integer power of 2 greater than or equal to the `Natural` to the input\n// `Vec`.\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_vec_next_power_of_2_in_place(xs: &mut Vec<Limb>) {\n    if limbs_slice_next_power_of_2_in_place(xs) {\n        xs.push(1);\n    }\n}}\n\nimpl NextPowerOf2 for Natural {\n    type Output = Self;\n\n    /// Finds the smallest power of 2 greater than or equal to a [`Natural`]. The [`Natural`] is\n    /// taken by value.\n    ///\n    /// $f(x) = 2^{\\lceil \\log_2 x \\rceil}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{NextPowerOf2, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.next_power_of_2(), 1);\n    /// assert_eq!(Natural::from(123u32).next_power_of_2(), 128);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12).next_power_of_2(),\n    ///     1099511627776u64\n    /// );\n    /// ```\n    #[inline]\n    fn next_power_of_2(mut self) -> Self {\n        self.next_power_of_2_assign();\n        self\n    }\n}\n\nimpl NextPowerOf2 for &Natural {\n    type Output = Natural;\n\n    /// Finds the smallest power of 2 greater than or equal to a [`Natural`]. The [`Natural`] is\n    /// taken by reference.\n    ///\n    /// $f(x) = 2^{\\lceil \\log_2 x \\rceil}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{NextPowerOf2, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).next_power_of_2(), 1);\n    /// assert_eq!((&Natural::from(123u32)).next_power_of_2(), 128);\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12)).next_power_of_2(),\n    ///     1099511627776u64\n    /// );\n    /// ```\n    fn next_power_of_2(self) -> Natural {\n        Natural(match self {\n            Natural(Small(small)) => {\n                if let Some(result) = small.checked_next_power_of_two() {\n                    Small(result)\n                } else {\n                    Large(vec![0, 1])\n                }\n            }\n            Natural(Large(limbs)) => Large(limbs_next_power_of_2(limbs)),\n        })\n    }\n}\n\nimpl NextPowerOf2Assign for Natural {\n    /// Replaces a [`Natural`] with the smallest power of 2 greater than or equal to it.\n    ///\n    /// $x \\gets 2^{\\lceil \\log_2 x \\rceil}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$ (only if the underlying [`Vec`] needs to reallocate)\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{NextPowerOf2Assign, Pow};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.next_power_of_2_assign();\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.next_power_of_2_assign();\n    /// assert_eq!(x, 128);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.next_power_of_2_assign();\n    /// assert_eq!(x, 1099511627776u64);\n    /// ```\n    fn next_power_of_2_assign(&mut self) {\n        match self {\n            Self(Small(small)) => {\n                if let Some(pow) = small.checked_next_power_of_two() {\n                    *small = pow;\n                } else {\n                    *self = Self(Large(vec![0, 1]));\n                }\n            }\n            Self(Large(limbs)) => {\n                limbs_vec_next_power_of_2_in_place(limbs);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::Parity;\n\nimpl Parity for &Natural {\n    /// Tests whether a [`Natural`] is even.\n    ///\n    /// $f(x) = (2|x)$.\n    ///\n    /// $f(x) = (\\exists k \\in \\N : x = 2k)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Parity, Pow};\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.even(), true);\n    /// assert_eq!(Natural::from(123u32).even(), false);\n    /// assert_eq!(Natural::from(0x80u32).even(), true);\n    /// assert_eq!(Natural::from(10u32).pow(12).even(), true);\n    /// assert_eq!((Natural::from(10u32).pow(12) + Natural::ONE).even(), false);\n    /// ```\n    fn even(self) -> bool {\n        match self {\n            Natural(Small(small)) => small.even(),\n            Natural(Large(limbs)) => limbs[0].even(),\n        }\n    }\n\n    /// Tests whether a [`Natural`] is odd.\n    ///\n    /// $f(x) = (2\\nmid x)$.\n    ///\n    /// $f(x) = (\\exists k \\in \\N : x = 2k+1)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Parity, Pow};\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.odd(), false);\n    /// assert_eq!(Natural::from(123u32).odd(), true);\n    /// assert_eq!(Natural::from(0x80u32).odd(), false);\n    /// assert_eq!(Natural::from(10u32).pow(12).odd(), false);\n    /// assert_eq!((Natural::from(10u32).pow(12) + Natural::ONE).odd(), true);\n    /// ```\n    fn odd(self) -> bool {\n        match self {\n            Natural(Small(small)) => small.odd(),\n            Natural(Large(limbs)) => limbs[0].odd(),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1997, 1999-2016, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::mul::limb::limbs_slice_mul_limb_in_place;\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::shr::limbs_shr_to_out;\nuse crate::natural::arithmetic::square::{limbs_square_to_out, limbs_square_to_out_scratch_len};\n#[cfg(feature = \"test_build\")]\nuse crate::natural::bit_to_limb_count_ceiling;\n#[cfg(feature = \"test_build\")]\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::natural::{Natural, bit_to_limb_count_floor, limb_to_bit_count};\n#[cfg(feature = \"test_build\")]\nuse crate::platform::DoubleLimb;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    EqModPowerOf2, Parity, Pow, PowAssign, Square, SquareAssign,\n};\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::conversion::traits::SplitInHalf;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::num::logic::traits::{\n    BitIterable, CountOnes, LeadingZeros, SignificantBits, TrailingZeros,\n};\nuse malachite_base::slices::slice_leading_zeros;\n\n/// This is equivalent to `GMP_NUMB_HALFMAX` from `mpz/n_pow_ui.c`, GMP 6.2.1.\nconst HALF_MAX: Limb = (1 << (Limb::WIDTH >> 1)) - 1;\n\n// # Worst-case complexity\n// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `exp`.\npub_crate_test! {limbs_pow(xs: &[Limb], exp: u64) -> Vec<Limb> {\n    let mut out = Vec::new();\n    let out_len = limbs_pow_to_out(&mut out, xs, exp);\n    out.truncate(out_len);\n    out\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `exp`.\nfn len_1_helper(x_0: &mut Limb, out_0: &mut Limb, trailing_zero_bits_out: &mut u64, exp: &mut u64) {\n    // Power up as far as possible within `x_0`. We start here with `exp` != 0, but if `exp` is\n    // small then we might reach `exp` == 0 and the whole `x` ^ `exp` in `out_0`.\n    while *x_0 <= HALF_MAX {\n        assert_ne!(*exp, 0);\n        if exp.odd() {\n            *out_0 *= *x_0;\n        }\n        *exp >>= 1;\n        if *exp == 0 {\n            break;\n        }\n        x_0.square_assign();\n    }\n    // Combine leftover `trailing_zero_bits_out` into `out_0` to be handled by the final\n    // `limbs_slice_mul_limb_in_place` rather than a separate `limbs_slice_shl_in_place`.\n    // - `out_0` mustn't be 1 (since then there's no final mul)\n    // - `out_0` mustn't overflow\n    if *trailing_zero_bits_out != 0\n        && *out_0 != 1\n        && *out_0 >> (Limb::WIDTH - *trailing_zero_bits_out) == 0\n    {\n        *out_0 <<= *trailing_zero_bits_out;\n        *trailing_zero_bits_out = 0;\n    }\n}\n\n// # Worst-case complexity\n// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `exp`.\n//\n// This is equivalent to `mpz_n_pow_ui` from `mpz/n_pow_ui.c`, GMP 6.2.1, where `e > 1` and\n// `bp.len() != 0`. Returns `rsize`.\nfn limbs_pow_to_out(out: &mut Vec<Limb>, xs: &[Limb], mut exp: u64) -> usize {\n    assert!(exp > 1);\n    let leading_zeros_in = slice_leading_zeros(xs);\n    let mut leading_zeros_out = leading_zeros_in * usize::exact_from(exp);\n    let mut xs = &xs[leading_zeros_in..];\n    let mut x = xs[0];\n    // Strip low zero bits from b.\n    let trailing_zero_bits_in = TrailingZeros::trailing_zeros(x);\n    x >>= trailing_zero_bits_in;\n    let mut trailing_zero_bits_out = exp * trailing_zero_bits_in;\n    leading_zeros_out += bit_to_limb_count_floor(trailing_zero_bits_out);\n    trailing_zero_bits_out &= Limb::WIDTH_MASK;\n    let mut out_0 = 1;\n    let mut scratch;\n    let mut x_0_x_1 = [0; 2];\n    match xs.len() {\n        1 => len_1_helper(&mut x, &mut out_0, &mut trailing_zero_bits_out, &mut exp),\n        2 => {\n            let mut x_1 = xs[1];\n            if trailing_zero_bits_in != 0 {\n                x |= x_1 << (Limb::WIDTH - trailing_zero_bits_in);\n            }\n            x_1 >>= trailing_zero_bits_in;\n            if x_1 == 0 {\n                // Two limbs became one after rshift.\n                xs = &xs[..1];\n                len_1_helper(&mut x, &mut out_0, &mut trailing_zero_bits_out, &mut exp);\n            } else {\n                x_0_x_1[0] = x;\n                x_0_x_1[1] = x_1;\n                xs = &x_0_x_1;\n                x = x_1;\n            }\n        }\n        len => {\n            if trailing_zero_bits_in != 0 {\n                scratch = vec![0; len];\n                limbs_shr_to_out(&mut scratch, xs, trailing_zero_bits_in);\n                if *scratch.last().unwrap() == 0 {\n                    scratch.pop();\n                }\n                xs = &scratch;\n            }\n            x = *xs.last().unwrap();\n        }\n    }\n    let len = xs.len();\n    // At this point `x` is the most significant limb of the base to use.\n    //\n    // Each factor of `xs` takes (len * 2 ^ `Limb::WIDTH` - `bits`) bits and there's `exp` of them;\n    // +1 limb to round up the division; +1 for multiplies all using an extra limb over the true\n    // size; +2 for `out_0` at the end; +1 for `limbs_slice_shl_in_place` at the end.\n    //\n    // The size calculation here is reasonably accurate. The base is at least half a limb, so in 32\n    // bits the worst case is 2 ^ 16 + 1 treated as 17 bits when it will power up as just over 16,\n    // an overestimate of 17/16 = 6.25%. For a 64-bit limb it's half that.\n    assert_ne!(x, 0);\n    let mut out_alloc =\n        bit_to_limb_count_floor((limb_to_bit_count(len) - LeadingZeros::leading_zeros(x)) * exp)\n            + 5;\n    out.resize(out_alloc + leading_zeros_out, 0);\n    // Low zero limbs resulting from powers of 2.\n    let out_original = out;\n    let mut out = &mut out_original[leading_zeros_out..];\n    let mut out_len;\n    let mut scratch;\n    if exp == 0 {\n        out[0] = out_0;\n        out_len = 1;\n        assert_ne!(out[0], 0);\n    } else {\n        // In the `limbs_slice_mul_limb_in_place` loop or in the `limbs_mul_greater_to_out` loop\n        // when the low bit of `exp` is zero, `scratch` only has to hold the second last power step,\n        // which is half the size of the final result. There's no need to round up the divide by 2,\n        // since `out_alloc` includes a +2 for `out_0` which is not needed by `scratch`. In the\n        // `limbs_mul_greater_to_out` loop when the low bit of `exp` is 1, `scratch` must hold\n        // nearly the full result, so just size it the same as `out`.\n        let mut scratch_len = out_alloc;\n        if len == 1 || exp.even() {\n            scratch_len >>= 1;\n        }\n        scratch = vec![0; scratch_len];\n        let mut scratch: &mut [Limb] = &mut scratch;\n        let bits = LeadingZeros::leading_zeros(exp);\n        if len == 1 {\n            // Arrange the final result ends up in `out`, not in `scratch`\n            if bits.even() {\n                swap(&mut out, &mut scratch);\n                swap(&mut out_alloc, &mut scratch_len);\n            }\n            out[0] = x;\n            out_len = 1;\n            for bit in exp.bits().rev().skip(1) {\n                assert!(out_len << 1 <= scratch_len);\n                let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(out_len)];\n                limbs_square_to_out(scratch, &out[..out_len], &mut square_scratch);\n                out_len <<= 1;\n                if scratch[out_len - 1] == 0 {\n                    out_len -= 1;\n                }\n                swap(&mut out, &mut scratch);\n                swap(&mut out_alloc, &mut scratch_len);\n                if bit {\n                    assert!(out_len < out_alloc);\n                    let carry = limbs_slice_mul_limb_in_place(&mut out[..out_len], x);\n                    out[out_len] = carry;\n                    if carry != 0 {\n                        out_len += 1;\n                    }\n                }\n            }\n            if out_0 != 1 {\n                assert!(out_len < out_alloc);\n                let carry = limbs_slice_mul_limb_in_place(&mut out[..out_len], out_0);\n                out[out_len] = carry;\n                if carry != 0 {\n                    out_len += 1;\n                }\n            }\n        } else {\n            // Arrange the final result ends up in `out`, not in `scratch`\n            if !CountOnes::count_ones(exp).eq_mod_power_of_2(bits, 1) {\n                swap(&mut out, &mut scratch);\n                swap(&mut out_alloc, &mut scratch_len);\n            }\n            out[..len].copy_from_slice(xs);\n            out_len = len;\n            for bit in exp.bits().rev().skip(1) {\n                assert!(out_len << 1 <= scratch_len);\n                let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(out_len)];\n                limbs_square_to_out(scratch, &out[..out_len], &mut square_scratch);\n                out_len <<= 1;\n                if scratch[out_len - 1] == 0 {\n                    out_len -= 1;\n                }\n                swap(&mut out, &mut scratch);\n                swap(&mut out_alloc, &mut scratch_len);\n                if bit {\n                    assert!(out_len + len <= scratch_len);\n                    let mut mul_scratch =\n                        vec![0; limbs_mul_greater_to_out_scratch_len(out_len, len)];\n                    let carry =\n                        limbs_mul_greater_to_out(scratch, &out[..out_len], xs, &mut mul_scratch);\n                    out_len += len;\n                    if carry == 0 {\n                        out_len -= 1;\n                    }\n                    swap(&mut out, &mut scratch);\n                    swap(&mut out_alloc, &mut scratch_len);\n                }\n            }\n        }\n    }\n    // Apply any partial limb factors of 2.\n    if trailing_zero_bits_out != 0 {\n        assert!(out_len < out_alloc);\n        let carry = limbs_slice_shl_in_place(&mut out[..out_len], trailing_zero_bits_out);\n        out[out_len] = carry;\n        if carry != 0 {\n            out_len += 1;\n        }\n    }\n    assert_eq!(\n        out as *const [Limb],\n        &out_original[leading_zeros_out..] as *const [Limb]\n    );\n    out_len + leading_zeros_out\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n#[cfg(feature = \"test_build\")]\nfn exp_predecessor(exp: u64) -> u64 {\n    if exp.even() { exp >> 1 } else { exp - 1 }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n#[cfg(feature = \"test_build\")]\nfn estimated_limb_len_helper(x: Limb, exp: u64) -> usize {\n    bit_to_limb_count_ceiling(x.significant_bits() * exp)\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// Never an underestimate.\n#[cfg(feature = \"test_build\")]\nfn limb_pow_alt_estimated_out_len(x: Limb, exp: u64) -> usize {\n    if exp.even() {\n        estimated_limb_len_helper(x, exp >> 1) << 1\n    } else {\n        estimated_limb_len_helper(x, exp - 1) + 1\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// Never an underestimate.\n#[cfg(feature = \"test_build\")]\n#[inline]\nfn limb_pow_alt_estimated_scratch_len(x: Limb, exp: u64) -> usize {\n    limb_pow_alt_estimated_out_len(x, exp_predecessor(exp))\n}\n\n// TODO figure out how to find scratch len using mp_bases. x > 1.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `exp`.\n//\n// This is equivalent to `mpn_pow_1` from `mpn/generic/pow_1.c`, GMP 6.2.1, where `exp > 1` and `bn\n// == 1`.\n#[cfg(feature = \"test_build\")]\nfn limb_pow_to_out_alt<'a>(\n    mut out: &'a mut [Limb],\n    x: Limb,\n    exp: u64,\n    mut scratch: &'a mut [Limb],\n) -> usize {\n    assert!(x > 1);\n    assert!(exp > 1);\n    // Count number of bits in exp, and compute where to put initial square in order to magically\n    // get results in the entry out.\n    let bits = exp.significant_bits();\n    if bits.odd() {\n        swap(&mut out, &mut scratch);\n    }\n    (out[1], out[0]) = DoubleLimb::from(x).square().split_in_half();\n    let mut out_len = if out[1] == 0 { 1 } else { 2 };\n    for i in (0..bits - 1).rev() {\n        if exp.get_bit(i) {\n            let (out_last, out_init) = out[..=out_len].split_last_mut().unwrap();\n            *out_last = limbs_slice_mul_limb_in_place(out_init, x);\n            if *out_last != 0 {\n                out_len += 1;\n            }\n        }\n        if i == 0 {\n            break;\n        }\n        let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(out_len)];\n        limbs_square_to_out(scratch, &out[..out_len], &mut square_scratch);\n        out_len <<= 1;\n        if scratch[out_len - 1] == 0 {\n            out_len -= 1;\n        }\n        swap(&mut out, &mut scratch);\n    }\n    out_len\n}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `exp`.\n#[cfg(feature = \"test_build\")]\nfn limb_pow_alt(x: Limb, exp: u64) -> Vec<Limb> {\n    let mut out = vec![0; limb_pow_alt_estimated_out_len(x, exp)];\n    let mut scratch = vec![0; limb_pow_alt_estimated_scratch_len(x, exp)];\n    let out_len = limb_pow_to_out_alt(&mut out, x, exp, &mut scratch);\n    assert!(out_len <= out.len());\n    out.truncate(out_len);\n    out\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n#[cfg(feature = \"test_build\")]\nfn estimated_limbs_len_helper(xs: &[Limb], exp: u64) -> usize {\n    bit_to_limb_count_ceiling(limbs_significant_bits(xs) * exp)\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// Never an underestimate.\n#[cfg(feature = \"test_build\")]\nfn limbs_pow_alt_estimated_out_len(xs: &[Limb], exp: u64) -> usize {\n    if exp.even() {\n        estimated_limbs_len_helper(xs, exp >> 1) << 1\n    } else {\n        estimated_limbs_len_helper(xs, exp - 1) + xs.len()\n    }\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// Never an underestimate.\n#[cfg(feature = \"test_build\")]\n#[inline]\nfn limbs_pow_alt_estimated_scratch_len(xs: &[Limb], exp: u64) -> usize {\n    limbs_pow_alt_estimated_out_len(xs, exp_predecessor(exp))\n}\n\n// TODO figure out how to find scratch len using mp_bases.\n//\n// # Worst-case complexity\n// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `exp`.\n//\n// This is equivalent to `mpn_pow_1` from `mpn/generic/pow_1.c`, GMP 6.2.1, where `exp > 1`, `bn >\n// 1`, and the last element of `xs` is nonzero.\n#[cfg(feature = \"test_build\")]\nfn limbs_pow_to_out_alt<'a>(\n    mut out: &'a mut [Limb],\n    xs: &[Limb],\n    exp: u64,\n    mut scratch: &'a mut [Limb],\n) -> usize {\n    let len = xs.len();\n    assert!(len > 1);\n    assert!(exp > 1);\n    // Count number of bits in exp, and compute where to put initial square in order to magically\n    // get results in the entry out.\n    let bits = exp.significant_bits();\n    if bits.eq_mod_power_of_2(CountOnes::count_ones(exp), 1) {\n        swap(&mut out, &mut scratch);\n    }\n    let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(xs.len())];\n    limbs_square_to_out(out, xs, &mut square_scratch);\n    let mut out_len = len << 1;\n    if out[out_len - 1] == 0 {\n        out_len -= 1;\n    }\n    for i in (0..bits - 1).rev() {\n        if exp.get_bit(i) {\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(out_len, len)];\n            if limbs_mul_greater_to_out(scratch, &out[..out_len], xs, &mut mul_scratch) == 0 {\n                out_len -= 1;\n            }\n            out_len += len;\n            swap(&mut out, &mut scratch);\n        }\n        if i == 0 {\n            break;\n        }\n        let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(out_len)];\n        limbs_square_to_out(scratch, &out[..out_len], &mut square_scratch);\n        out_len <<= 1;\n        if scratch[out_len - 1] == 0 {\n            out_len -= 1;\n        }\n        swap(&mut out, &mut scratch);\n    }\n    out_len\n}\n\n// # Worst-case complexity\n// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `exp`.\n#[cfg(feature = \"test_build\")]\nfn limbs_pow_alt(xs: &[Limb], exp: u64) -> Vec<Limb> {\n    let mut out = vec![0; limbs_pow_alt_estimated_out_len(xs, exp)];\n    let mut scratch = vec![0; limbs_pow_alt_estimated_scratch_len(xs, exp)];\n    let out_len = limbs_pow_to_out_alt(&mut out, xs, exp, &mut scratch);\n    assert!(out_len <= out.len());\n    out.truncate(out_len);\n    out\n}\n\n#[cfg(feature = \"test_build\")]\nimpl Natural {\n    pub fn pow_ref_alt(&self, exp: u64) -> Self {\n        match (self, exp) {\n            (_, 0) | (&Self::ONE, _) => Self::ONE,\n            (&Self::ZERO, _) => Self::ZERO,\n            (x, 1) => x.clone(),\n            (x, 2) => x.square(),\n            (x, exp) if x.is_power_of_2() => Self::power_of_2((x.significant_bits() - 1) * exp),\n            (Self(Small(small)), exp) => {\n                if small.significant_bits() * exp <= Limb::WIDTH {\n                    Self(Small(small.checked_pow(u32::wrapping_from(exp)).unwrap()))\n                } else {\n                    Self::from_owned_limbs_asc(limb_pow_alt(*small, exp))\n                }\n            }\n            (Self(Large(limbs)), exp) => Self::from_owned_limbs_asc(limbs_pow_alt(limbs, exp)),\n        }\n    }\n\n    pub fn pow_assign_alt(&mut self, exp: u64) {\n        match (&mut *self, exp) {\n            (x, 0) => *x = Self::ONE,\n            (_, 1) | (&mut (Self::ZERO | Self::ONE), _) => {}\n            (x, 2) => x.square_assign(),\n            (x, exp) if x.is_power_of_2() => {\n                *x = Self::power_of_2((x.significant_bits() - 1) * exp);\n            }\n            (Self(Small(small)), exp) => {\n                if small.significant_bits() * exp <= Limb::WIDTH {\n                    *small = small.checked_pow(u32::wrapping_from(exp)).unwrap();\n                } else {\n                    *self = Self::from_owned_limbs_asc(limb_pow_alt(*small, exp));\n                }\n            }\n            (Self(Large(limbs)), exp) => {\n                *self = Self::from_owned_limbs_asc(limbs_pow_alt(limbs, exp));\n            }\n        }\n    }\n}\n\nimpl Pow<u64> for Natural {\n    type Output = Self;\n\n    /// Raises a [`Natural`] to a power, taking the [`Natural`] by value.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).pow(100).to_string(),\n    ///     \"515377520732011331036461129765621272702107522001\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_str(\"12345678987654321\")\n    ///         .unwrap()\n    ///         .pow(3)\n    ///         .to_string(),\n    ///     \"1881676411868862234942354805142998028003108518161\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(mut self, exp: u64) -> Self {\n        self.pow_assign(exp);\n        self\n    }\n}\n\nimpl Pow<u64> for &Natural {\n    type Output = Natural;\n\n    /// Raises a [`Natural`] to a power, taking the [`Natural`] by reference.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(3u32)).pow(100).to_string(),\n    ///     \"515377520732011331036461129765621272702107522001\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from_str(\"12345678987654321\").unwrap())\n    ///         .pow(3)\n    ///         .to_string(),\n    ///     \"1881676411868862234942354805142998028003108518161\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(self, exp: u64) -> Natural {\n        match (self, exp) {\n            (_, 0) | (&Natural::ONE, _) => Natural::ONE,\n            (&Natural::ZERO, _) => Natural::ZERO,\n            (x, 1) => x.clone(),\n            (x, 2) => x.square(),\n            (Natural(Small(small)), exp) => {\n                if small.significant_bits() * exp <= Limb::WIDTH {\n                    Natural(Small(small.checked_pow(u32::wrapping_from(exp)).unwrap()))\n                } else {\n                    let mut out = Natural(Large(limbs_pow(&[*small], exp)));\n                    out.demote_if_small();\n                    out\n                }\n            }\n            (Natural(Large(limbs)), exp) => {\n                let mut out = Natural(Large(limbs_pow(limbs, exp)));\n                out.demote_if_small();\n                out\n            }\n        }\n    }\n}\n\nimpl PowAssign<u64> for Natural {\n    /// Raises a [`Natural`] to a power in place.\n    ///\n    /// $x \\gets x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::arithmetic::traits::PowAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(3u32);\n    /// x.pow_assign(100);\n    /// assert_eq!(\n    ///     x.to_string(),\n    ///     \"515377520732011331036461129765621272702107522001\"\n    /// );\n    ///\n    /// let mut x = Natural::from_str(\"12345678987654321\").unwrap();\n    /// x.pow_assign(3);\n    /// assert_eq!(\n    ///     x.to_string(),\n    ///     \"1881676411868862234942354805142998028003108518161\"\n    /// );\n    /// ```\n    fn pow_assign(&mut self, exp: u64) {\n        match (&mut *self, exp) {\n            (x, 0) => *x = Self::ONE,\n            (_, 1) | (&mut (Self::ZERO | Self::ONE), _) => {}\n            (x, 2) => x.square_assign(),\n            (Self(Small(small)), exp) => {\n                if small.significant_bits() * exp <= Limb::WIDTH {\n                    *small = small.checked_pow(u32::wrapping_from(exp)).unwrap();\n                } else {\n                    *self = Self(Large(limbs_pow(&[*small], exp)));\n                    self.demote_if_small();\n                }\n            }\n            (Self(Large(limbs)), exp) => {\n                *self = Self(Large(limbs_pow(limbs, exp)));\n                self.demote_if_small();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::One;\n\nimpl PowerOf2<u64> for Natural {\n    /// Raises 2 to an integer power.\n    ///\n    /// $f(k) = 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::power_of_2(0), 1);\n    /// assert_eq!(Natural::power_of_2(3), 8);\n    /// assert_eq!(\n    ///     Natural::power_of_2(100).to_string(),\n    ///     \"1267650600228229401496703205376\"\n    /// );\n    /// ```\n    #[inline]\n    fn power_of_2(pow: u64) -> Self {\n        Self::ONE << pow\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Contributed to the GNU project by Marco Bodrato.\n//\n//      Copyright © 2012, 2015, 2016 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::factorial::log_n_max;\nuse crate::natural::arithmetic::mul::product_of_limbs::limbs_product;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{PowerOf2, Primorial, RotateLeftAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, WrappingFrom};\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::factorization::prime_sieve::limbs_prime_sieve_u32;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse malachite_base::num::factorization::prime_sieve::limbs_prime_sieve_u64;\nuse malachite_base::num::factorization::prime_sieve::{id_to_n, limbs_prime_sieve_size, n_to_bit};\nuse malachite_base::num::factorization::traits::Primes;\n\n#[cfg(feature = \"32_bit_limbs\")]\nconst SMALL_PRIMORIAL_LIMIT: u64 = 29;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst SMALL_PRIMORIAL_LIMIT: u64 = 53;\n\n// This is equivalent to `mpz_primorial_ui` from `mpz/primorial_ui.c`, GMP 6.2.1, where n is too\n// large for the primorial of n to fit in a single limb.\n#[allow(clippy::useless_conversion)]\nfn limbs_primorial(n: Limb) -> Vec<Limb> {\n    let n_u64 = u64::from(n);\n    let size = usize::exact_from(n >> Limb::LOG_WIDTH);\n    let size = size + (size >> 1) + 1;\n    assert!(size >= limbs_prime_sieve_size::<Limb>(n_u64));\n    let mut sieve = vec![0; size];\n    #[cfg(feature = \"32_bit_limbs\")]\n    let count = limbs_prime_sieve_u32(&mut sieve, n_u64);\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    let count = limbs_prime_sieve_u64(&mut sieve, n);\n    let size = usize::exact_from((count + 1) / log_n_max(n) + 1);\n    let mut factors = vec![0; size];\n    let mut j = 0;\n    let mut prod = 6;\n    // Store primes from 5 to n\n    let max_prod = Limb::MAX / n;\n    let i = n_to_bit(5);\n    let mut index = bit_to_limb_count_floor(i);\n    let mut mask = Limb::power_of_2(i & Limb::WIDTH_MASK);\n    for i in i + 1..=n_to_bit(n_u64) + 1 {\n        if sieve[index] & mask == 0 {\n            let prime = Limb::wrapping_from(id_to_n(i));\n            if prod > max_prod {\n                factors[j] = prod;\n                j += 1;\n                prod = prime;\n            } else {\n                prod *= prime;\n            }\n        }\n        mask.rotate_left_assign(1);\n        if mask == 1 {\n            index += 1;\n        }\n    }\n    // j != 0\n    factors[j] = prod;\n    j += 1;\n    sieve.resize(j, 0);\n    let (out_len, new_sieve) = limbs_product(&mut sieve, &mut factors[..j]);\n    assert!(new_sieve.is_none());\n    sieve.truncate(out_len);\n    sieve\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\nconst SMALL_PRODUCT_OF_FIRST_N_PRIMES_LIMIT: u64 = 10;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst SMALL_PRODUCT_OF_FIRST_N_PRIMES_LIMIT: u64 = 16;\n\nfn limbs_product_of_first_n_primes(n: usize) -> Vec<Limb> {\n    let mut prod: Limb = 1;\n    let mut factors = Vec::new();\n    for prime in Limb::primes().take(n) {\n        if let Some(p) = prod.checked_mul(prime) {\n            prod = p;\n        } else {\n            factors.push(prod);\n            prod = prime;\n        }\n    }\n    factors.push(prod);\n    let mut out = Vec::new();\n    let (out_len, new_out) = limbs_product(&mut out, &mut factors);\n    out = new_out.unwrap();\n    out.truncate(out_len);\n    out\n}\n\nimpl Primorial for Natural {\n    /// Computes the primorial of a [`Natural`]: the product of all primes less than or equal to it.\n    ///\n    /// The [`product_of_first_n_primes`](Natural::product_of_first_n_primes) function is similar;\n    /// it computes the primorial of the $n$th prime.\n    ///\n    /// $$\n    /// f(n) = n\\\\# =prod_{pleq natop p\\\\text {prime}} p.\n    /// $$\n    ///\n    /// $n\\\\# = O(e^{(1+o(1))n})$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Primorial;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::primorial(0), 1);\n    /// assert_eq!(Natural::primorial(1), 1);\n    /// assert_eq!(Natural::primorial(2), 2);\n    /// assert_eq!(Natural::primorial(3), 6);\n    /// assert_eq!(Natural::primorial(4), 6);\n    /// assert_eq!(Natural::primorial(5), 30);\n    /// assert_eq!(\n    ///     Natural::primorial(100).to_string(),\n    ///     \"2305567963945518424753102147331756070\"\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `mpz_primorial_ui` from `mpz/primorial_ui.c`, GMP 6.2.1.\n    #[inline]\n    fn primorial(n: u64) -> Self {\n        assert!(Limb::convertible_from(n));\n        if n < SMALL_PRIMORIAL_LIMIT {\n            Self::from(Limb::primorial(n))\n        } else {\n            Self::from_owned_limbs_asc(limbs_primorial(Limb::wrapping_from(n)))\n        }\n    }\n\n    /// Computes the product of the first $n$ primes.\n    ///\n    /// The [`primorial`](Natural::primorial) function is similar; it computes the product of all\n    /// primes less than or equal to $n$.\n    ///\n    /// $$\n    /// f(n) = p_n\\\\# = \\prod_{k=1}^n p_n,\n    /// $$\n    /// where $p_n$ is the $n$th prime number.\n    ///\n    /// $p_n\\\\# = O\\left (\\left (\\frac{1}{e}k\\log k\\left (\\frac{\\log k}{e^2}k \\right )^{1/\\log\n    /// k}\\right )^k\\omega(1)\\right )$.\n    ///\n    /// This asymptotic approximation is due to [Bart\n    /// Michels](https://math.stackexchange.com/a/1594930).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Primorial;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::product_of_first_n_primes(0), 1);\n    /// assert_eq!(Natural::product_of_first_n_primes(1), 2);\n    /// assert_eq!(Natural::product_of_first_n_primes(2), 6);\n    /// assert_eq!(Natural::product_of_first_n_primes(3), 30);\n    /// assert_eq!(Natural::product_of_first_n_primes(4), 210);\n    /// assert_eq!(Natural::product_of_first_n_primes(5), 2310);\n    /// assert_eq!(\n    ///     Natural::product_of_first_n_primes(100).to_string(),\n    ///     \"4711930799906184953162487834760260422020574773409675520188634839616415335845034221205\\\n    ///     28925670554468197243910409777715799180438028421831503871944494399049257903072063599053\\\n    ///     8452312528339864352999310398481791730017201031090\"\n    /// );\n    /// ```\n    #[inline]\n    fn product_of_first_n_primes(n: u64) -> Self {\n        assert!(Limb::convertible_from(n));\n        if n < SMALL_PRODUCT_OF_FIRST_N_PRIMES_LIMIT {\n            Self::from(Limb::product_of_first_n_primes(n))\n        } else {\n            Self::from_owned_limbs_asc(limbs_product_of_first_n_primes(usize::exact_from(n)))\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Contributed by Paul Zimmermann (algorithm) and Paul Zimmermann and Torbjörn Granlund\n//      (implementation). Marco Bodrato wrote `logbased_root` to seed the loop.\n//\n//      Copyright © 2002, 2005, 2009-2012, 2015 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::div::{limbs_div_limb_to_out, limbs_div_to_out};\nuse crate::natural::arithmetic::mul::limb::limbs_slice_mul_limb_in_place;\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::pow::limbs_pow;\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::shr::limbs_shr_to_out;\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_greater_in_place_left, limbs_sub_greater_to_out, limbs_sub_limb_in_place,\n    limbs_sub_limb_to_out,\n};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::natural::{Natural, bit_to_limb_count_floor, limb_to_bit_count};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingRootAssign, CeilingSqrt, CheckedRoot, CheckedSqrt, DivMod, DivRound,\n    FloorRoot, FloorRootAssign, FloorSqrt, ModPowerOf2Assign, PowerOf2, RootAssignRem, RootRem,\n    SqrtRem,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::{LeadingZeros, LowMask, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::{slice_set_zero, slice_trailing_zeros};\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn limbs_shl_helper(xs: &mut [Limb], len: usize, out_start_index: usize, bits: u64) -> Limb {\n    assert!(bits < Limb::WIDTH);\n    if len == 0 {\n        0\n    } else {\n        xs.copy_within(0..len, out_start_index);\n        if bits == 0 {\n            0\n        } else {\n            limbs_slice_shl_in_place(&mut xs[out_start_index..out_start_index + len], bits)\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn shr_helper(out: &mut [Limb], xs: &[Limb], shift: u64) {\n    if shift == 0 {\n        out[..xs.len()].copy_from_slice(xs);\n    } else {\n        limbs_shr_to_out(out, xs, shift);\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn div_helper(qs: &mut [Limb], ns: &mut [Limb], ds: &mut [Limb]) {\n    assert!(*ns.last().unwrap() != 0);\n    assert!(*ds.last().unwrap() != 0);\n    if ns.len() == 1 {\n        if ds.len() == 1 {\n            qs[0] = ns[0] / ds[0];\n        } else {\n            qs[0] = 0;\n        }\n    } else if ds.len() == 1 {\n        limbs_div_limb_to_out(qs, ns, ds[0]);\n    } else {\n        limbs_div_to_out(qs, ns, ds);\n    }\n}\n\n// vlog=vector(256,i,floor((log(256+i)/log(2)-8)*256)-(i>255))\nconst V_LOG: [u8; 256] = [\n    1, 2, 4, 5, 7, 8, 9, 11, 12, 14, 15, 16, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34,\n    35, 37, 38, 39, 40, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 61, 62, 63, 64,\n    65, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92,\n    93, 94, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 108, 109, 110, 111, 112, 113, 114,\n    115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134,\n    135, 136, 137, 138, 139, 140, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,\n    153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 162, 163, 164, 165, 166, 167, 168, 169, 170,\n    171, 172, 173, 173, 174, 175, 176, 177, 178, 179, 180, 181, 181, 182, 183, 184, 185, 186, 187,\n    188, 188, 189, 190, 191, 192, 193, 194, 194, 195, 196, 197, 198, 199, 200, 200, 201, 202, 203,\n    204, 205, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 218, 218,\n    219, 220, 221, 222, 222, 223, 224, 225, 225, 226, 227, 228, 229, 229, 230, 231, 232, 232, 233,\n    234, 235, 235, 236, 237, 238, 239, 239, 240, 241, 242, 242, 243, 244, 245, 245, 246, 247, 247,\n    248, 249, 250, 250, 251, 252, 253, 253, 254, 255, 255,\n];\n\n// vexp=vector(256,i,floor(2^(8+i/256)-256)-(i>255))\nconst V_EXP: [u8; 256] = [\n    0, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 14, 15, 16, 17, 17, 18, 19,\n    20, 20, 21, 22, 23, 23, 24, 25, 26, 26, 27, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35, 36, 37, 37,\n    38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 50, 51, 52, 53, 54, 55, 55, 56, 57,\n    58, 59, 60, 61, 61, 62, 63, 64, 65, 66, 67, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78,\n    79, 80, 81, 82, 83, 84, 85, 86, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,\n    101, 102, 103, 104, 105, 106, 107, 108, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 119,\n    120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,\n    139, 140, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 157, 158, 159,\n    160, 161, 163, 164, 165, 166, 167, 168, 169, 171, 172, 173, 174, 175, 176, 178, 179, 180, 181,\n    182, 183, 185, 186, 187, 188, 189, 191, 192, 193, 194, 196, 197, 198, 199, 200, 202, 203, 204,\n    205, 207, 208, 209, 210, 212, 213, 214, 216, 217, 218, 219, 221, 222, 223, 225, 226, 227, 229,\n    230, 231, 232, 234, 235, 236, 238, 239, 240, 242, 243, 245, 246, 247, 249, 250, 251, 253, 254,\n    255,\n];\n\nconst LOGROOT_USED_BITS: u64 = 8;\nconst LOGROOT_NEEDS_TWO_CORRECTIONS: bool = true;\nconst NEEDED_CORRECTIONS: u64 = if LOGROOT_NEEDS_TWO_CORRECTIONS { 2 } else { 1 };\nconst LOGROOT_RETURNED_BITS: u64 = if LOGROOT_NEEDS_TWO_CORRECTIONS {\n    LOGROOT_USED_BITS + 1\n} else {\n    LOGROOT_USED_BITS\n};\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `logbased_root` from `mpn/generic/rootrem.c`, GMP 6.2.1.\nfn log_based_root(out: &mut Limb, x: Limb, mut bit_count: u64, exp: u64) -> u64 {\n    const LOGROOT_USED_BITS_COMP: u64 = Limb::WIDTH - LOGROOT_USED_BITS;\n    let len;\n    let b = u64::from(V_LOG[usize::exact_from(x >> LOGROOT_USED_BITS_COMP)]);\n    if bit_count.significant_bits() > LOGROOT_USED_BITS_COMP {\n        // In this branch, the input is unreasonably large. In the unlikely case, we use two\n        // divisions and a modulo.\n        fail_on_untested_path(\"bit_count.significant_bits() > LOGROOT_USED_BITS_COMP\");\n        let r;\n        (len, r) = bit_count.div_mod(exp);\n        bit_count = ((r << LOGROOT_USED_BITS) | b) / exp;\n    } else {\n        bit_count = ((bit_count << LOGROOT_USED_BITS) | b) / exp;\n        len = bit_count >> LOGROOT_USED_BITS;\n        bit_count.mod_power_of_2_assign(LOGROOT_USED_BITS);\n    }\n    assert!(bit_count.significant_bits() <= LOGROOT_USED_BITS);\n    *out = Limb::power_of_2(LOGROOT_USED_BITS) | Limb::from(V_EXP[usize::exact_from(bit_count)]);\n    if !LOGROOT_NEEDS_TWO_CORRECTIONS {\n        *out >>= 1;\n    }\n    len\n}\n\n// If approx is non-zero, does not compute the final remainder.\n//\n/// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_rootrem_internal` from `mpn/generic/rootrem.c`, GMP 6.2.1.\nfn limbs_root_to_out_internal(\n    out_root: &mut [Limb],\n    out_rem: Option<&mut [Limb]>,\n    xs: &[Limb],\n    exp: u64,\n    approx: bool,\n) -> usize {\n    let mut xs_len = xs.len();\n    let mut xs_hi = xs[xs_len - 1];\n    let leading_zeros = LeadingZeros::leading_zeros(xs_hi) + 1;\n    let bit_count = limb_to_bit_count(xs_len) - leading_zeros;\n    let out_rem_is_some = out_rem.is_some();\n    if bit_count < exp {\n        // root is 1\n        out_root[0] = 1;\n        if out_rem_is_some {\n            let out_rem = out_rem.unwrap();\n            limbs_sub_limb_to_out(out_rem, xs, 1);\n            // There should be at most one zero limb, if we demand x to be normalized\n            if out_rem[xs_len - 1] == 0 {\n                xs_len -= 1;\n            }\n        } else if xs[0] == 1 {\n            xs_len -= 1;\n        }\n        return xs_len;\n    }\n    xs_hi = if leading_zeros == Limb::WIDTH {\n        xs[xs_len - 2]\n    } else {\n        let mut i = xs_len - 1;\n        if xs_len != 1 {\n            i -= 1;\n        }\n        (xs_hi << leading_zeros) | (xs[i] >> (Limb::WIDTH - leading_zeros))\n    };\n    assert!(xs_len != 1 || xs[xs_len - 1] >> (Limb::WIDTH - leading_zeros) == 1);\n    // - root_bits + 1 is the number of bits of the root R\n    // - APPROX_BITS + 1 is the number of bits of the current approximation S\n    let mut root_bits = log_based_root(&mut out_root[0], xs_hi, bit_count, exp);\n    const APPROX_BITS: u64 = LOGROOT_RETURNED_BITS - 1;\n    let mut input_bits = exp * root_bits; // number of truncated bits in the input\n    xs_hi = (Limb::exact_from(exp) - 1) >> 1;\n    let mut log_exp = 3;\n    loop {\n        xs_hi >>= 1;\n        if xs_hi == 0 {\n            break;\n        }\n        log_exp += 1;\n    }\n    // log_exp = ceil(log_2(exp)) + 1\n    let mut i = 0;\n    let mut sizes = [0u64; (Limb::WIDTH + 1) as usize];\n    loop {\n        // Invariant: here we want root_bits + 1 total bits for the kth root. If c is the new value\n        // of root_bits, this means that we'll go from a root of c + 1 bits (say s') to a root of\n        // root_bits + 1 bits. It is proved in the book \"Modern Computer Arithmetic\" by Brent and\n        // Zimmermann, Chapter 1, that if s' >= exp * beta, then at most one correction is\n        // necessary. Here beta = 2 ^ (root_bits - c), and s' >= 2 ^ c, thus it suffices that c >=\n        // ceil((root_bits + log_2(exp)) / 2).\n        sizes[i] = root_bits;\n        if root_bits <= APPROX_BITS {\n            break;\n        }\n        if root_bits > log_exp {\n            root_bits = (root_bits + log_exp) >> 1;\n        } else {\n            // add just one bit at a time\n            root_bits -= 1;\n        }\n        i += 1;\n    }\n    out_root[0] >>= APPROX_BITS - root_bits;\n    input_bits -= root_bits;\n    assert!(i < usize::wrapping_from(Limb::WIDTH + 1));\n    // We have sizes[0] = next_bits > sizes[1] > ... > sizes[ni] = 0, with sizes[i] <= 2 * sizes[i +\n    // 1]. Newton iteration will first compute sizes[i - 1] extra bits, then sizes[i - 2], ..., then\n    // sizes[0] = next_bits. qs and ws need enough space to store S' ^ exp, where S' is an\n    // approximate root. Since S' can be as large as S + 2, the worst case is when S = 2 and S' = 4.\n    // But then since we know the number of bits of S in advance, S' can only be 3 at most.\n    // Similarly for S = 4, then S' can be 6 at most. So the worst case is S' / S = 3 / 2, thus S' ^\n    // exp <= (3 / 2) ^ exp * S ^ exp. Since S ^ exp fits in xs_len limbs, the number of extra limbs\n    // needed is bounded by ceil(exp * log_2(3 / 2) / B), where B is `Limb::WIDTH`.\n    let extra = (((0.585 * (exp as f64)) / (Limb::WIDTH as f64)) as usize) + 2;\n    let mut big_scratch = vec![0; 3 * xs_len + 2 * extra + 1];\n    let (scratch, remainder) = big_scratch.split_at_mut(xs_len + 1);\n    // - qs will contain quotient and remainder of R / (exp * S ^ (exp - 1)).\n    // - ws will contain S ^ (k-1) and exp *S^(k-1).\n    let (qs, ws) = remainder.split_at_mut(xs_len + extra);\n    let rs = if out_rem_is_some {\n        out_rem.unwrap()\n    } else {\n        scratch\n    };\n    let ss = out_root;\n    // Initial approximation has one limb\n    let mut ss_len = 1;\n    let mut next_bits = root_bits;\n    let mut rs_len = 0;\n    let mut save_1;\n    let mut save_2 = 0;\n    let mut qs_len;\n    let mut pow_cmp;\n    while i != 0 {\n        // Loop invariant:\n        // - &ss[..ss_len] is the current approximation of the root, which has exactly 1 + sizes[i]\n        //   bits.\n        // - &rs[..rs_len] is the current remainder.\n        // - &ws[..ws_len] = ss[..ss_len] ^ (exp - 1)\n        // - input_bits = number of truncated bits of the input\n        //\n        // Since each iteration treats next_bits bits from the root and thus exp * next_bits bits\n        // from the input, and we already considered next_bits bits from the input, we now have to\n        // take another (exp - 1) * next_bits bits from the input.\n        input_bits -= (exp - 1) * next_bits;\n        // &rs[..rs_len] = floor(&xs[..xs_len] / 2 ^ input_bits)\n        let input_len = bit_to_limb_count_floor(input_bits);\n        let input_bits_rem = input_bits & Limb::WIDTH_MASK;\n        shr_helper(rs, &xs[input_len..xs_len], input_bits_rem);\n        rs_len = xs_len - input_len;\n        if rs[rs_len - 1] == 0 {\n            rs_len -= 1;\n        }\n        // Current buffers: &ss[..ss_len], &ss[..ss_len]\n        let mut correction = 0;\n        let mut ws_len;\n        loop {\n            // - Compute S ^ exp in &qs[..qs_len]\n            // - W <- S ^ (exp - 1) for the next iteration, and S ^ k = W * S.\n            let ss_trimmed = &mut ss[..ss_len];\n            let pow_xs = limbs_pow(ss_trimmed, exp - 1);\n            ws[..pow_xs.len()].copy_from_slice(&pow_xs);\n            ws_len = pow_xs.len();\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(ws_len, ss_len)];\n            limbs_mul_greater_to_out(qs, &ws[..ws_len], ss_trimmed, &mut mul_scratch);\n            qs_len = ws_len + ss_len;\n            if qs[qs_len - 1] == 0 {\n                qs_len -= 1;\n            }\n            pow_cmp = Greater;\n            // if S^k > floor(U/2^input_bits), the root approximation was too large\n            let mut need_adjust = qs_len > rs_len;\n            if !need_adjust && qs_len == rs_len {\n                pow_cmp = limbs_cmp_same_length(&qs[..rs_len], &rs[..rs_len]);\n                need_adjust = pow_cmp == Greater;\n            }\n            if need_adjust {\n                assert!(!limbs_sub_limb_in_place(ss_trimmed, 1));\n            } else {\n                break;\n            }\n            correction += 1;\n        }\n        // - Current buffers: &ss[..ss_len], &rs[..rs_len], &qs[..qs_len], &ws[..ws_len]\n        // - Sometimes two corrections are needed with logbased_root.\n        assert!(correction <= NEEDED_CORRECTIONS);\n        assert!(rs_len >= qs_len);\n        // next_bits is the number of bits to compute in the next iteration.\n        next_bits = sizes[i - 1] - sizes[i];\n        // next_len is the lowest limb from the high part of rs, after shift.\n        let next_len = bit_to_limb_count_floor(next_bits);\n        let next_bits_rem = next_bits & Limb::WIDTH_MASK;\n        input_bits -= next_bits;\n        let input_len = bit_to_limb_count_floor(input_bits);\n        let input_bits_rem = input_bits & Limb::WIDTH_MASK;\n        // - n_len is the number of limbs in x which contain bits\n        // - [input_bits, input_bits + next_bits - 1]\n        //\n        // n_len = 1 + floor((input_bits + next_bits - 1) / B) - floor(input_bits / B) <= 1 +\n        // (input_bits + next_bits - 1) / B - (input_bits - B + 1) / B = 2 + (next_bits - 2) / B,\n        // where B is `Limb::WIDTH`.\n        //\n        // Thus, since n_len is an integer: n_len <= 2 + floor(next_bits / B) <= 2 + next_len.\n        let n_len = bit_to_limb_count_floor(input_bits + next_bits - 1) + 1 - input_len;\n        // - Current buffers: &ss[..ss_len], &rs[..rs_len], &ws[..ws_len]\n        // - R = R - Q = floor(X / 2 ^ input_bits) - S ^ exp\n        if pow_cmp == Equal {\n            rs_len = next_len;\n            save_2 = 0;\n            save_1 = 0;\n        } else {\n            let rs_trimmed = &mut rs[..rs_len];\n            limbs_sub_greater_in_place_left(rs_trimmed, &qs[..qs_len]);\n            rs_len -= slice_trailing_zeros(rs_trimmed);\n            // first multiply the remainder by 2^next_bits\n            let carry = limbs_shl_helper(rs, rs_len, next_len, next_bits_rem);\n            rs_len += next_len;\n            if carry != 0 {\n                rs[rs_len] = carry;\n                rs_len += 1;\n            }\n            save_1 = rs[next_len];\n            // we have to save rs[next_len] up to rs[n_len - 1], i.e. 1 or 2 limbs\n            if n_len - 1 > next_len {\n                save_2 = rs[next_len + 1];\n            }\n        }\n        // - Current buffers: &ss[..ss_len], &rs[..rs_len], &ws[..ws_len]\n        // - Now insert bits [input_bits, input_bits + next_bits - 1] from the input X\n        shr_helper(rs, &xs[input_len..input_len + n_len], input_bits_rem);\n        // Set to zero high bits of rs[next_len]\n        rs[next_len].mod_power_of_2_assign(next_bits_rem);\n        // Restore corresponding bits\n        rs[next_len] |= save_1;\n        if n_len - 1 > next_len {\n            // The low next_bits bits go in rs[0..next_len] only, since they start by bit 0 in\n            // rs[0], so they use at most ceil(next_bits / B) limbs\n            rs[next_len + 1] = save_2;\n        }\n        // - Current buffers: &ss[..ss_len], &rs[..rs_len], &ws[..ws_len]\n        // - Compute &ws[..ws_len] = exp * &ss[..ss_len] ^ (exp-1).\n        let carry = limbs_slice_mul_limb_in_place(&mut ws[..ws_len], Limb::exact_from(exp));\n        ws[ws_len] = carry;\n        if carry != 0 {\n            ws_len += 1;\n        }\n        // - Current buffers: &ss[..ss_len], &qs[..qs_len]\n        // - Multiply the root approximation by 2 ^ next_bits\n        let carry = limbs_shl_helper(ss, ss_len, next_len, next_bits_rem);\n        ss_len += next_len;\n        if carry != 0 {\n            ss[ss_len] = carry;\n            ss_len += 1;\n        }\n        save_1 = ss[next_len];\n        // Number of limbs used by next_bits bits, when least significant bit is aligned to least\n        // limb\n        let b_rem = bit_to_limb_count_floor(next_bits - 1) + 1;\n        // - Current buffers: &ss[..ss_len], &rs[..rs_len], &ws[..ws_len]\n        // - Now divide &rs[..rs_len] by &ws[..ws_len] to get the low part of the root\n        if rs_len < ws_len {\n            slice_set_zero(&mut ss[..b_rem]);\n        } else {\n            let mut qs_len = rs_len - ws_len; // Expected quotient size\n            if qs_len <= b_rem {\n                // Divide only if result is not too big.\n                div_helper(qs, &mut rs[..rs_len], &mut ws[..ws_len]);\n                if qs[qs_len] != 0 {\n                    qs_len += 1;\n                }\n            } else {\n                fail_on_untested_path(\"limbs_root_to_out_internal, qs_len > b_rem\");\n            }\n            // - Current buffers: &ss[..ss_len], &qs[..qs_len]\n            // - Note: &rs[..rs_len]is not needed any more since we'll compute it from scratch at\n            //   the end of the loop.\n            //\n            // The quotient should be smaller than 2 ^ next_bits, since the previous approximation\n            // was correctly rounded toward zero.\n            if qs_len > b_rem\n                || (qs_len == b_rem\n                    && (next_bits_rem != 0)\n                    && qs[qs_len - 1].significant_bits() > next_bits_rem)\n            {\n                qs_len = 1;\n                while qs_len < b_rem {\n                    ss[qs_len - 1] = Limb::MAX;\n                    qs_len += 1;\n                }\n                ss[qs_len - 1] = Limb::low_mask(((next_bits - 1) & Limb::WIDTH_MASK) + 1);\n            } else {\n                // - Current buffers: &ss[..ss_len], &qs[..qs_len]\n                // - Combine sB and q to form sB + q.\n                let (ss_lo, ss_hi) = ss.split_at_mut(qs_len);\n                ss_lo.copy_from_slice(&qs[..qs_len]);\n                slice_set_zero(&mut ss_hi[..b_rem - qs_len]);\n            }\n        }\n        ss[next_len] |= save_1;\n        // 8: current buffer: &ss[..ss_len]\n        i -= 1;\n    }\n    // otherwise we have rn > 0, thus the return value is ok\n    if !approx || ss[0] <= 1 {\n        let mut c = 0;\n        loop {\n            // - Compute S ^ exp in &qs[..qs_len].\n            // - Last iteration: we don't need W anymore.\n            let pow_xs = limbs_pow(&ss[..ss_len], exp);\n            qs[..pow_xs.len()].copy_from_slice(&pow_xs);\n            qs_len = pow_xs.len();\n            pow_cmp = Greater;\n            let mut need_adjust = qs_len > xs_len;\n            if !need_adjust && qs_len == xs_len {\n                pow_cmp = limbs_cmp_same_length(&qs[..xs_len], &xs[..xs_len]);\n                need_adjust = pow_cmp == Greater;\n            }\n            if need_adjust {\n                assert!(!limbs_sub_limb_in_place(&mut ss[..ss_len], 1));\n            } else {\n                break;\n            }\n            c += 1;\n        }\n        // Sometimes two corrections are needed with log_based_root.\n        assert!(c <= NEEDED_CORRECTIONS);\n        rs_len = usize::from(pow_cmp != Equal);\n        if rs_len != 0 && out_rem_is_some {\n            limbs_sub_greater_to_out(rs, &xs[..xs_len], &qs[..qs_len]);\n            rs_len = xs_len;\n            rs_len -= slice_trailing_zeros(rs);\n        }\n    }\n    rs_len\n}\n\n// Returns the size (in limbs) of the remainder.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_rootrem` from `mpn/generic/rootrem.c`, GMP 6.2.1, where `k != 2` and\n// `remp` is not `NULL`.\npub_test! {limbs_root_rem_to_out(\n    out_root: &mut [Limb],\n    out_rem: &mut [Limb],\n    xs: &[Limb],\n    exp: u64,\n) -> usize {\n    let xs_len = xs.len();\n    assert_ne!(xs_len, 0);\n    assert_ne!(xs[xs_len - 1], 0);\n    assert!(exp > 2);\n    // (xs_len - 1) / exp > 2 <=> xs_len > 3 * exp <=> (xs_len + 2) / 3 > exp\n    limbs_root_to_out_internal(out_root, Some(out_rem), xs, exp, false)\n}}\n\n// Returns a non-zero value iff the remainder is non-zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_rootrem` from `mpn/generic/rootrem.c`, GMP 6.2.1, where `remp` is\n// `NULL`.\npub_test! {limbs_floor_root_to_out(out_root: &mut [Limb], xs: &[Limb], exp: u64) -> bool {\n    let xs_len = xs.len();\n    assert_ne!(xs_len, 0);\n    assert_ne!(xs[xs_len - 1], 0);\n    assert!(exp > 2);\n    // (xs_len - 1) / exp > 2 <=> xs_len > 3 * exp <=> (xs_len + 2) / 3 > exp\n    let u_exp = usize::exact_from(exp);\n    if xs_len.div_ceil(3) > u_exp {\n        // Pad xs with exp zero limbs. This will produce an approximate root with one more limb,\n        // allowing us to compute the exact integral result.\n        let ws_len = xs_len + u_exp;\n        let ss_len = (xs_len - 1) / u_exp + 2; // ceil(xs_len / exp) + 1\n        let mut scratch = vec![0; ws_len + ss_len];\n        // - ws will contain the padded input.\n        // - ss is the approximate root of padded input.\n        let (ws, ss) = scratch.split_at_mut(ws_len);\n        ws[u_exp..].copy_from_slice(xs);\n        let rs_len = limbs_root_to_out_internal(ss, None, ws, exp, true);\n        // The approximate root S = ss is either the correct root of ss, or 1 too large. Thus,\n        // unless the least significant limb of S is 0 or 1, we can deduce the root of xs is S\n        // truncated by one limb. (In case xs[0] = 1, we can deduce the root, but not decide whether\n        // it is exact or not.)\n        out_root[..ss_len - 1].copy_from_slice(&ss[1..]);\n        rs_len != 0\n    } else {\n        limbs_root_to_out_internal(out_root, None, xs, exp, false) != 0\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_floor_root(xs: &[Limb], exp: u64) -> (Vec<Limb>, bool) {\n    let mut out = vec![\n        0;\n        xs.len()\n            .div_round(usize::exact_from(exp), Ceiling).0\n    ];\n    let inexact = limbs_floor_root_to_out(&mut out, xs, exp);\n    (out, inexact)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_root_rem(xs: &[Limb], exp: u64) -> (Vec<Limb>, Vec<Limb>) {\n    let mut root_out = vec![\n        0;\n        xs.len()\n            .div_round(usize::exact_from(exp), Ceiling).0\n    ];\n    let mut rem_out = vec![0; xs.len()];\n    let rem_len = limbs_root_rem_to_out(&mut root_out, &mut rem_out, xs, exp);\n    rem_out.truncate(rem_len);\n    (root_out, rem_out)\n}}\n\nimpl FloorRoot<u64> for Natural {\n    type Output = Self;\n\n    /// Returns the floor of the $n$th root of a [`Natural`], taking the [`Natural`] by value.\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorRoot;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(999u16).floor_root(3), 9);\n    /// assert_eq!(Natural::from(1000u16).floor_root(3), 10);\n    /// assert_eq!(Natural::from(1001u16).floor_root(3), 10);\n    /// assert_eq!(Natural::from(100000000000u64).floor_root(5), 158);\n    /// ```\n    fn floor_root(self, exp: u64) -> Self {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => self,\n            2 => self.floor_sqrt(),\n            exp => match self {\n                Self(Small(x)) => Self(Small(x.floor_root(exp))),\n                Self(Large(xs)) => Self::from_owned_limbs_asc(limbs_floor_root(&xs, exp).0),\n            },\n        }\n    }\n}\n\nimpl FloorRoot<u64> for &Natural {\n    type Output = Natural;\n\n    /// Returns the floor of the $n$th root of a [`Natural`], taking the [`Natural`] by reference.\n    ///\n    /// $f(x, n) = \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorRoot;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(999u16)).floor_root(3), 9);\n    /// assert_eq!((&Natural::from(1000u16)).floor_root(3), 10);\n    /// assert_eq!((&Natural::from(1001u16)).floor_root(3), 10);\n    /// assert_eq!((&Natural::from(100000000000u64)).floor_root(5), 158);\n    /// ```\n    fn floor_root(self, exp: u64) -> Natural {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => self.clone(),\n            2 => self.floor_sqrt(),\n            exp => match self {\n                Natural(Small(x)) => Natural(Small(x.floor_root(exp))),\n                Natural(Large(xs)) => Natural::from_owned_limbs_asc(limbs_floor_root(xs, exp).0),\n            },\n        }\n    }\n}\n\nimpl FloorRootAssign<u64> for Natural {\n    /// Replaces a [`Natural`] with the floor of its $n$th root.\n    ///\n    /// $x \\gets \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorRootAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(999u16);\n    /// x.floor_root_assign(3);\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Natural::from(1000u16);\n    /// x.floor_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(1001u16);\n    /// x.floor_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(100000000000u64);\n    /// x.floor_root_assign(5);\n    /// assert_eq!(x, 158);\n    /// ```\n    #[inline]\n    fn floor_root_assign(&mut self, exp: u64) {\n        *self = (&*self).floor_root(exp);\n    }\n}\n\nimpl CeilingRoot<u64> for Natural {\n    type Output = Self;\n\n    /// Returns the ceiling of the $n$th root of a [`Natural`], taking the [`Natural`] by value.\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingRoot;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(999u16).ceiling_root(3), 10);\n    /// assert_eq!(Natural::from(1000u16).ceiling_root(3), 10);\n    /// assert_eq!(Natural::from(1001u16).ceiling_root(3), 11);\n    /// assert_eq!(Natural::from(100000000000u64).ceiling_root(5), 159);\n    /// ```\n    fn ceiling_root(self, exp: u64) -> Self {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => self,\n            2 => self.ceiling_sqrt(),\n            exp => match self {\n                Self(Small(x)) => Self(Small(x.ceiling_root(exp))),\n                Self(Large(xs)) => {\n                    let (floor_root_limbs, inexact) = limbs_floor_root(&xs, exp);\n                    let floor_root = Self::from_owned_limbs_asc(floor_root_limbs);\n                    if inexact {\n                        floor_root + Self::ONE\n                    } else {\n                        floor_root\n                    }\n                }\n            },\n        }\n    }\n}\n\nimpl CeilingRoot<u64> for &Natural {\n    type Output = Natural;\n\n    /// Returns the ceiling of the $n$th root of a [`Natural`], taking the [`Natural`] by reference.\n    ///\n    /// $f(x, n) = \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingRoot;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(999u16).ceiling_root(3), 10);\n    /// assert_eq!(Natural::from(1000u16).ceiling_root(3), 10);\n    /// assert_eq!(Natural::from(1001u16).ceiling_root(3), 11);\n    /// assert_eq!(Natural::from(100000000000u64).ceiling_root(5), 159);\n    /// ```\n    fn ceiling_root(self, exp: u64) -> Natural {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => self.clone(),\n            2 => self.ceiling_sqrt(),\n            exp => match self {\n                Natural(Small(x)) => Natural(Small(x.ceiling_root(exp))),\n                Natural(Large(xs)) => {\n                    let (floor_root_limbs, inexact) = limbs_floor_root(xs, exp);\n                    let floor_root = Natural::from_owned_limbs_asc(floor_root_limbs);\n                    if inexact {\n                        floor_root + Natural::ONE\n                    } else {\n                        floor_root\n                    }\n                }\n            },\n        }\n    }\n}\n\nimpl CeilingRootAssign<u64> for Natural {\n    /// Replaces a [`Natural`] with the ceiling of its $n$th root.\n    ///\n    /// $x \\gets \\lceil\\sqrt\\[n\\]{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingRootAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(999u16);\n    /// x.ceiling_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(1000u16);\n    /// x.ceiling_root_assign(3);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(1001u16);\n    /// x.ceiling_root_assign(3);\n    /// assert_eq!(x, 11);\n    ///\n    /// let mut x = Natural::from(100000000000u64);\n    /// x.ceiling_root_assign(5);\n    /// assert_eq!(x, 159);\n    /// ```\n    #[inline]\n    fn ceiling_root_assign(&mut self, exp: u64) {\n        *self = (&*self).ceiling_root(exp);\n    }\n}\n\nimpl CheckedRoot<u64> for Natural {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`Natural`], or `None` if the [`Natural`] is not a perfect\n    /// $n$th power. The [`Natural`] is taken by value.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(999u16).checked_root(3).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(1000u16).checked_root(3).to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(1001u16).checked_root(3).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(100000000000u64)\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10000000000u64)\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"Some(100)\"\n    /// );\n    /// ```\n    fn checked_root(self, exp: u64) -> Option<Self> {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => Some(self),\n            2 => self.checked_sqrt(),\n            exp => match self {\n                Self(Small(x)) => x.checked_root(exp).map(|x| Self(Small(x))),\n                Self(Large(xs)) => {\n                    let (floor_root_limbs, inexact) = limbs_floor_root(&xs, exp);\n                    let floor_root = Self::from_owned_limbs_asc(floor_root_limbs);\n                    if inexact { None } else { Some(floor_root) }\n                }\n            },\n        }\n    }\n}\n\nimpl CheckedRoot<u64> for &Natural {\n    type Output = Natural;\n\n    /// Returns the the $n$th root of a [`Natural`], or `None` if the [`Natural`] is not a perfect\n    /// $n$th power. The [`Natural`] is taken by reference.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(999u16)).checked_root(3).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(1000u16)).checked_root(3).to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(1001u16)).checked_root(3).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(100000000000u64))\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10000000000u64))\n    ///         .checked_root(5)\n    ///         .to_debug_string(),\n    ///     \"Some(100)\"\n    /// );\n    /// ```\n    fn checked_root(self, exp: u64) -> Option<Natural> {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => Some(self.clone()),\n            2 => self.checked_sqrt(),\n            exp => match self {\n                Natural(Small(x)) => x.checked_root(exp).map(|x| Natural(Small(x))),\n                Natural(Large(xs)) => {\n                    let (floor_root_limbs, inexact) = limbs_floor_root(xs, exp);\n                    let floor_root = Natural::from_owned_limbs_asc(floor_root_limbs);\n                    if inexact { None } else { Some(floor_root) }\n                }\n            },\n        }\n    }\n}\n\nimpl RootRem<u64> for Natural {\n    type RootOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the $n$th root of a [`Natural`], and the remainder (the difference\n    /// between the [`Natural`] and the $n$th power of the floor). The [`Natural`] is taken by\n    /// value.\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^n)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RootRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(999u16).root_rem(3).to_debug_string(),\n    ///     \"(9, 270)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(1000u16).root_rem(3).to_debug_string(),\n    ///     \"(10, 0)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(1001u16).root_rem(3).to_debug_string(),\n    ///     \"(10, 1)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(100000000000u64).root_rem(5).to_debug_string(),\n    ///     \"(158, 1534195232)\"\n    /// );\n    /// ```\n    fn root_rem(self, exp: u64) -> (Self, Self) {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => (self, Self::ZERO),\n            2 => self.sqrt_rem(),\n            exp => match self {\n                Self(Small(x)) => {\n                    let (root, rem) = x.root_rem(exp);\n                    (Self(Small(root)), Self(Small(rem)))\n                }\n                Self(Large(xs)) => {\n                    let (root_limbs, rem_limbs) = limbs_root_rem(&xs, exp);\n                    (\n                        Self::from_owned_limbs_asc(root_limbs),\n                        Self::from_owned_limbs_asc(rem_limbs),\n                    )\n                }\n            },\n        }\n    }\n}\n\nimpl RootRem<u64> for &Natural {\n    type RootOutput = Natural;\n    type RemOutput = Natural;\n\n    /// Returns the floor of the $n$th root of a [`Natural`], and the remainder (the difference\n    /// between the [`Natural`] and the $n$th power of the floor). The [`Natural`] is taken by\n    /// reference.\n    ///\n    /// $f(x, n) = (\\lfloor\\sqrt\\[n\\]{x}\\rfloor, x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^n)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RootRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(999u16)).root_rem(3).to_debug_string(),\n    ///     \"(9, 270)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(1000u16)).root_rem(3).to_debug_string(),\n    ///     \"(10, 0)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(1001u16)).root_rem(3).to_debug_string(),\n    ///     \"(10, 1)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(100000000000u64))\n    ///         .root_rem(5)\n    ///         .to_debug_string(),\n    ///     \"(158, 1534195232)\"\n    /// );\n    /// ```\n    fn root_rem(self, exp: u64) -> (Natural, Natural) {\n        match exp {\n            0 => panic!(\"Cannot take 0th root\"),\n            1 => (self.clone(), Natural::ZERO),\n            2 => self.sqrt_rem(),\n            exp => match self {\n                Natural(Small(x)) => {\n                    let (root, rem) = x.root_rem(exp);\n                    (Natural(Small(root)), Natural(Small(rem)))\n                }\n                Natural(Large(xs)) => {\n                    let (root_limbs, rem_limbs) = limbs_root_rem(xs, exp);\n                    (\n                        Natural::from_owned_limbs_asc(root_limbs),\n                        Natural::from_owned_limbs_asc(rem_limbs),\n                    )\n                }\n            },\n        }\n    }\n}\n\nimpl RootAssignRem<u64> for Natural {\n    type RemOutput = Self;\n\n    /// Replaces a [`Natural`] with the floor of its $n$th root, and returns the remainder (the\n    /// difference between the original [`Natural`] and the $n$th power of the floor).\n    ///\n    /// $f(x, n) = x - \\lfloor\\sqrt\\[n\\]{x}\\rfloor^n$,\n    ///\n    /// $x \\gets \\lfloor\\sqrt\\[n\\]{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RootAssignRem;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(999u16);\n    /// assert_eq!(x.root_assign_rem(3), 270);\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Natural::from(1000u16);\n    /// assert_eq!(x.root_assign_rem(3), 0);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(1001u16);\n    /// assert_eq!(x.root_assign_rem(3), 1);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(100000000000u64);\n    /// assert_eq!(x.root_assign_rem(5), 1534195232);\n    /// assert_eq!(x, 158);\n    /// ```\n    #[inline]\n    fn root_assign_rem(&mut self, exp: u64) -> Self {\n        let rem;\n        (*self, rem) = (&*self).root_rem(exp);\n        rem\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{RoundToMultiple, RoundToMultipleAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl RoundToMultiple<Self> for Natural {\n    type Output = Self;\n\n    /// Rounds a [`Natural`] to a multiple of another [`Natural`], according to a specified rounding\n    /// mode. Both [`Natural`]s are taken by value. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\N$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(5u32)\n    ///         .round_to_multiple(Natural::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(Natural::from(4u32), Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(Natural::from(4u32), Up)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(Natural::from(5u32), Exact)\n    ///         .to_debug_string(),\n    ///     \"(10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(9, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(20u32)\n    ///         .round_to_multiple(Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(21, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(14u32)\n    ///         .round_to_multiple(Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(16, Greater)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple(mut self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultiple<&Self> for Natural {\n    type Output = Self;\n\n    /// Rounds a [`Natural`] to a multiple of another [`Natural`], according to a specified rounding\n    /// mode. The first [`Natural`] is taken by value and the second by reference. An [`Ordering`]\n    /// is also returned, indicating whether the returned value is less than, equal to, or greater\n    /// than the original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\N$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(5u32)\n    ///         .round_to_multiple(&Natural::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(&Natural::from(4u32), Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(&Natural::from(4u32), Up)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(&Natural::from(5u32), Exact)\n    ///         .to_debug_string(),\n    ///     \"(10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(&Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(9, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(20u32)\n    ///         .round_to_multiple(&Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(21, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple(&Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(14u32)\n    ///         .round_to_multiple(&Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(16, Greater)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple(mut self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultiple<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Rounds a [`Natural`] to a multiple of another [`Natural`], according to a specified rounding\n    /// mode. The first [`Natural`] is taken by reference and the second by value. An [`Ordering`]\n    /// is also returned, indicating whether the returned value is less than, equal to, or greater\n    /// than the original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\N$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(5u32))\n    ///         .round_to_multiple(Natural::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(Natural::from(4u32), Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(Natural::from(4u32), Up)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(Natural::from(5u32), Exact)\n    ///         .to_debug_string(),\n    ///     \"(10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(9, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(20u32))\n    ///         .round_to_multiple(Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(21, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(14u32))\n    ///         .round_to_multiple(Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(16, Greater)\"\n    /// );\n    /// ```\n    fn round_to_multiple(self, other: Natural, rm: RoundingMode) -> (Natural, Ordering) {\n        match (self, other) {\n            (x, y) if *x == y => (y, Equal),\n            (x, Natural::ZERO) => match rm {\n                Down | Floor | Nearest => (Natural::ZERO, Less),\n                _ => panic!(\"Cannot round {x} to zero using RoundingMode {rm}\"),\n            },\n            (x, y) => {\n                let r = x % &y;\n                if r == 0 {\n                    (x.clone(), Equal)\n                } else {\n                    let floor = x - &r;\n                    match rm {\n                        Down | Floor => (floor, Less),\n                        Up | Ceiling => (floor + y, Greater),\n                        Nearest => {\n                            match (r << 1u64).cmp(&y) {\n                                Less => (floor, Less),\n                                Greater => (floor + y, Greater),\n                                Equal => {\n                                    // The even multiple of y will have more trailing zeros.\n                                    if floor == 0 {\n                                        (floor, Less)\n                                    } else {\n                                        let ceiling = &floor + y;\n                                        if floor.trailing_zeros() > ceiling.trailing_zeros() {\n                                            (floor, Less)\n                                        } else {\n                                            (ceiling, Greater)\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                        Exact => {\n                            panic!(\"Cannot round {x} to {y} using RoundingMode {rm}\")\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n\nimpl RoundToMultiple<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Rounds a [`Natural`] to a multiple of another [`Natural`], according to a specified rounding\n    /// mode. Both [`Natural`]s are taken by reference. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\N$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple(other, Exact)`\n    /// - `{ assert!(x.divisible_by(other)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(5u32))\n    ///         .round_to_multiple(&Natural::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(&Natural::from(4u32), Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(&Natural::from(4u32), Up)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(&Natural::from(5u32), Exact)\n    ///         .to_debug_string(),\n    ///     \"(10, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(&Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(9, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(20u32))\n    ///         .round_to_multiple(&Natural::from(3u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(21, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple(&Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(14u32))\n    ///         .round_to_multiple(&Natural::from(4u32), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(16, Greater)\"\n    /// );\n    /// ```\n    fn round_to_multiple(self, other: &Natural, rm: RoundingMode) -> (Natural, Ordering) {\n        match (self, other) {\n            (x, y) if x == y => (x.clone(), Equal),\n            (x, &Natural::ZERO) => match rm {\n                Down | Floor | Nearest => (Natural::ZERO, Less),\n                _ => panic!(\"Cannot round {x} to zero using RoundingMode {rm}\"),\n            },\n            (x, y) => {\n                let r = x % y;\n                if r == 0 {\n                    (x.clone(), Equal)\n                } else {\n                    let floor = x - &r;\n                    match rm {\n                        Down | Floor => (floor, Less),\n                        Up | Ceiling => (floor + y, Greater),\n                        Nearest => {\n                            match (r << 1u64).cmp(y) {\n                                Less => (floor, Less),\n                                Greater => (floor + y, Greater),\n                                Equal => {\n                                    // The even multiple of y will have more trailing zeros.\n                                    if floor == 0 {\n                                        (floor, Less)\n                                    } else {\n                                        let ceiling = &floor + y;\n                                        if floor.trailing_zeros() > ceiling.trailing_zeros() {\n                                            (floor, Less)\n                                        } else {\n                                            (ceiling, Greater)\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                        Exact => {\n                            panic!(\"Cannot round {x} to {y} using RoundingMode {rm}\")\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n\nimpl RoundToMultipleAssign<Self> for Natural {\n    /// Rounds a [`Natural`] to a multiple of another [`Natural`] in place, according to a specified\n    /// rounding mode. The [`Natural`] on the right-hand side is taken by value. An [`Ordering`] is\n    /// returned, indicating whether the returned value is less than, equal to, or greater than the\n    /// original value.\n    ///\n    /// See the [`RoundToMultiple`] documentation for details.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_assign(other, Exact);`\n    /// - `assert!(x.divisible_by(other));`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(5u32);\n    /// assert_eq!(x.round_to_multiple_assign(Natural::ZERO, Down), Less);\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(x.round_to_multiple_assign(Natural::from(4u32), Down), Less);\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(x.round_to_multiple_assign(Natural::from(4u32), Up), Greater);\n    /// assert_eq!(x, 12);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Natural::from(5u32), Exact),\n    ///     Equal\n    /// );\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Natural::from(3u32), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Natural::from(3u32), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, 21);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Natural::from(4u32), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(14u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(Natural::from(4u32), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, 16);\n    /// ```\n    fn round_to_multiple_assign(&mut self, other: Self, rm: RoundingMode) -> Ordering {\n        match (&mut *self, other) {\n            (x, y) if *x == y => Equal,\n            (x, Self::ZERO) => match rm {\n                Down | Floor | Nearest => {\n                    *self = Self::ZERO;\n                    Less\n                }\n                _ => panic!(\"Cannot round {x} to zero using RoundingMode {rm}\"),\n            },\n            (x, y) => {\n                let r = &*x % &y;\n                if r == 0 {\n                    Equal\n                } else {\n                    *x -= &r;\n                    match rm {\n                        Down | Floor => Less,\n                        Up | Ceiling => {\n                            *x += y;\n                            Greater\n                        }\n                        Nearest => {\n                            match (r << 1u64).cmp(&y) {\n                                Less => Less,\n                                Greater => {\n                                    *x += y;\n                                    Greater\n                                }\n                                Equal => {\n                                    // The even multiple of y will have more trailing zeros.\n                                    if *x == 0 {\n                                        Less\n                                    } else {\n                                        let ceiling = &*x + y;\n                                        if x.trailing_zeros() < ceiling.trailing_zeros() {\n                                            *x = ceiling;\n                                            Greater\n                                        } else {\n                                            Less\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                        Exact => {\n                            panic!(\"Cannot round {x} to {y} using RoundingMode {rm}\")\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n\nimpl RoundToMultipleAssign<&Self> for Natural {\n    /// Rounds a [`Natural`] to a multiple of another [`Natural`] in place, according to a specified\n    /// rounding mode. The [`Natural`] on the right-hand side is taken by reference. An [`Ordering`]\n    /// is also returned, indicating whether the returned value is less than, equal to, or greater\n    /// than the original value.\n    ///\n    /// See the [`RoundToMultiple`] documentation for details.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_assign(other, Exact);`\n    /// - `assert!(x.divisible_by(other));`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(5u32);\n    /// assert_eq!(x.round_to_multiple_assign(&Natural::ZERO, Down), Less);\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(x.round_to_multiple_assign(&Natural::from(4u32), Down), Less);\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Natural::from(4u32), Up),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, 12);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Natural::from(5u32), Exact),\n    ///     Equal\n    /// );\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Natural::from(3u32), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Natural::from(3u32), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, 21);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Natural::from(4u32), Nearest),\n    ///     Less\n    /// );\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(14u32);\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(&Natural::from(4u32), Nearest),\n    ///     Greater\n    /// );\n    /// assert_eq!(x, 16);\n    /// ```\n    fn round_to_multiple_assign(&mut self, other: &Self, rm: RoundingMode) -> Ordering {\n        match (&mut *self, other) {\n            (x, y) if *x == *y => Equal,\n            (x, &Self::ZERO) => match rm {\n                Down | Floor | Nearest => {\n                    *self = Self::ZERO;\n                    Less\n                }\n                _ => panic!(\"Cannot round {x} to zero using RoundingMode {rm}\"),\n            },\n            (x, y) => {\n                let r = &*x % y;\n                if r == 0 {\n                    Equal\n                } else {\n                    *x -= &r;\n                    match rm {\n                        Down | Floor => Less,\n                        Up | Ceiling => {\n                            *x += y;\n                            Greater\n                        }\n                        Nearest => {\n                            match (r << 1u64).cmp(y) {\n                                Less => Less,\n                                Greater => {\n                                    *x += y;\n                                    Greater\n                                }\n                                Equal => {\n                                    // The even multiple of y will have more trailing zeros.\n                                    if *x == 0 {\n                                        Less\n                                    } else {\n                                        let ceiling = &*x + y;\n                                        if x.trailing_zeros() < ceiling.trailing_zeros() {\n                                            *x = ceiling;\n                                            Greater\n                                        } else {\n                                            Less\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                        Exact => {\n                            panic!(\"Cannot round {x} to {y} using RoundingMode {rm}\")\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::divisible_by_power_of_2::limbs_divisible_by_power_of_2;\nuse crate::natural::logic::bit_access::limbs_get_bit;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, PowerOf2, RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign, ShrRound,\n    ShrRoundAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::{BitAccess, LowMask};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::{slice_set_zero, slice_test_zero};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` rounded down to a multiple of `2 ^ pow`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {\n    limbs_round_to_multiple_of_power_of_2_down(xs: &[Limb], pow: u64) -> (Vec<Limb>, Ordering) {\n    let clear_count = bit_to_limb_count_floor(pow);\n    let xs_len = xs.len();\n    if clear_count >= xs_len {\n        (Vec::new(), if slice_test_zero(xs) {Equal} else {Less})\n    } else {\n        let mut out = vec![0; xs_len];\n        let (xs_lo, xs_hi) = xs.split_at(clear_count);\n        let mut exact = slice_test_zero(xs_lo);\n        out[clear_count..].copy_from_slice(xs_hi);\n        let small_pow = pow & Limb::WIDTH_MASK;\n        if small_pow != 0 {\n            let out_cc = &mut out[clear_count];\n            let old = *out_cc;\n            *out_cc &= !Limb::low_mask(small_pow);\n            exact &= *out_cc == old;\n        }\n        (out, if exact {Equal} else {Less})\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` rounded up to a multiple of `2 ^ pow`. The limbs should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.\npub_test! {\n    limbs_round_to_multiple_of_power_of_2_up(xs: &[Limb], pow: u64) -> (Vec<Limb>, Ordering) {\n    let clear_count = bit_to_limb_count_floor(pow);\n    let xs_len = xs.len();\n    let mut out;\n    let small_pow = pow & Limb::WIDTH_MASK;\n    let mut exact;\n    if clear_count >= xs_len {\n        out = vec![0; clear_count + 1];\n        out[clear_count] = Limb::power_of_2(small_pow);\n        exact = false;\n    } else {\n        let (xs_lo, xs_hi) = xs.split_at(clear_count);\n        exact = slice_test_zero(xs_lo);\n        out = vec![0; xs_len];\n        let out_hi = &mut out[clear_count..];\n        out_hi.copy_from_slice(xs_hi);\n        if small_pow != 0 {\n            let remainder = out_hi[0].mod_power_of_2(small_pow);\n            if remainder != 0 {\n                out_hi[0] -= remainder;\n                exact = false;\n            }\n        }\n        if !exact && limbs_slice_add_limb_in_place(out_hi, Limb::power_of_2(small_pow)) {\n            out.push(1);\n        }\n    }\n    (out, if exact {Equal} else {Greater})\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.s\nfn limbs_round_to_multiple_of_power_of_2_half_integer_to_even(\n    xs: &[Limb],\n    pow: u64,\n) -> (Vec<Limb>, Ordering) {\n    let clear_count = bit_to_limb_count_floor(pow);\n    let xs_len = xs.len();\n    if clear_count >= xs_len {\n        (Vec::new(), if slice_test_zero(xs) { Equal } else { Less })\n    } else {\n        let (xs_lo, xs_hi) = xs.split_at(clear_count);\n        let mut exact = slice_test_zero(xs_lo);\n        let mut out = vec![0; xs_len];\n        let out_hi = &mut out[clear_count..];\n        out_hi.copy_from_slice(xs_hi);\n        let small_pow = pow & Limb::WIDTH_MASK;\n        if small_pow != 0 {\n            out_hi[0] &= !Limb::low_mask(small_pow);\n            exact = false;\n        }\n        if xs_hi[0].get_bit(small_pow) {\n            if limbs_slice_add_limb_in_place(out_hi, Limb::power_of_2(small_pow)) {\n                out.push(1);\n            }\n            (out, Greater)\n        } else {\n            (out, if exact { Equal } else { Less })\n        }\n    }\n}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` rounded to the nearest multiple of `2 ^ pow`. If the original value is\n// exactly between two multiples, it is rounded to the one whose `pow`th bit is zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.\npub_test! {\n    limbs_round_to_multiple_of_power_of_2_nearest(xs: &[Limb], pow: u64) -> (Vec<Limb>, Ordering) {\n    if pow == 0 {\n        (xs.to_vec(), Equal)\n    } else if !limbs_get_bit(xs, pow - 1) {\n        limbs_round_to_multiple_of_power_of_2_down(xs, pow)\n    } else if !limbs_divisible_by_power_of_2(xs, pow - 1) {\n        limbs_round_to_multiple_of_power_of_2_up(xs, pow)\n    } else {\n        limbs_round_to_multiple_of_power_of_2_half_integer_to_even(xs, pow)\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` rounded to a multiple of `2 ^ pow`, using a specified rounding format. If\n// the original value is not already a multiple of the power of 2, and the `RoundingMode` is\n// `Exact`, `None` is returned. The limbs should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.\npub_test! {limbs_round_to_multiple_of_power_of_2(\n    xs: &[Limb],\n    pow: u64,\n    rm: RoundingMode,\n) -> Option<(Vec<Limb>, Ordering)> {\n    match rm {\n        Down | Floor => {\n            Some(limbs_round_to_multiple_of_power_of_2_down(xs, pow))\n        }\n        Up | Ceiling => {\n            Some(limbs_round_to_multiple_of_power_of_2_up(xs, pow))\n        }\n        Nearest => Some(limbs_round_to_multiple_of_power_of_2_nearest(xs, pow)),\n        Exact => {\n            if limbs_divisible_by_power_of_2(xs, pow) {\n                Some((xs.to_vec(), Equal))\n            } else {\n                None\n            }\n        }\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural`, rounded down to a multiple of `2 ^ pow`, to the input `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {\n    limbs_round_to_multiple_of_power_of_2_down_in_place(xs: &mut Vec<Limb>, pow: u64) -> Ordering {\n    let clear_count = bit_to_limb_count_floor(pow);\n    let xs_len = xs.len();\n    let mut exact;\n    if clear_count >= xs_len {\n        exact = slice_test_zero(xs);\n        xs.clear();\n    } else {\n        let (xs_lo, xs_hi) = xs.split_at_mut(clear_count);\n        exact = slice_test_zero(xs_lo);\n        slice_set_zero(xs_lo);\n        let small_pow = pow & Limb::WIDTH_MASK;\n        if small_pow != 0 {\n            let x0 = &mut xs_hi[0];\n            let old = *x0;\n            *x0 &= !Limb::low_mask(small_pow);\n            exact &= *x0 == old;\n        }\n    }\n    if exact {Equal} else {Less}\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural`, rounded up to a multiple of `2 ^ pow`, to the input `Vec`. The limbs\n// should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.\npub_test! {\n    limbs_round_to_multiple_of_power_of_2_up_in_place(xs: &mut Vec<Limb>, pow: u64) -> Ordering {\n    let clear_count = bit_to_limb_count_floor(pow);\n    let xs_len = xs.len();\n    let small_pow = pow & Limb::WIDTH_MASK;\n    if clear_count >= xs_len {\n        *xs = vec![0; clear_count + 1];\n        xs[clear_count] = Limb::power_of_2(small_pow);\n        Greater\n    } else {\n        let (xs_lo, xs_hi) = xs.split_at_mut(clear_count);\n        let mut exact = slice_test_zero(xs_lo);\n        slice_set_zero(xs_lo);\n        if small_pow != 0 {\n            let remainder = xs_hi[0].mod_power_of_2(small_pow);\n            if remainder != 0 {\n                xs_hi[0] -= remainder;\n                exact = false;\n            }\n        }\n        if !exact && limbs_slice_add_limb_in_place(xs_hi, Limb::power_of_2(small_pow)) {\n            xs.push(1);\n        }\n        if exact {Equal} else {Greater}\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.\nfn limbs_round_to_multiple_of_power_of_2_half_integer_to_even_in_place(\n    xs: &mut Vec<Limb>,\n    pow: u64,\n) -> Ordering {\n    let clear_count = bit_to_limb_count_floor(pow);\n    let xs_len = xs.len();\n    if clear_count >= xs_len {\n        let exact = slice_test_zero(xs);\n        xs.clear();\n        if exact { Equal } else { Less }\n    } else {\n        let (xs_lo, xs_hi) = xs.split_at_mut(clear_count);\n        let mut exact = true;\n        if let Some(last) = xs_lo.last_mut() {\n            if *last != 0 {\n                exact = false;\n            }\n            *last = 0;\n        }\n        let small_pow = pow & Limb::WIDTH_MASK;\n        if small_pow != 0 {\n            xs_hi[0] &= !Limb::low_mask(small_pow);\n            exact = false;\n        }\n        if xs_hi[0].get_bit(small_pow) {\n            if limbs_slice_add_limb_in_place(xs_hi, Limb::power_of_2(small_pow)) {\n                xs.push(1);\n            }\n            Greater\n        } else if exact {\n            Equal\n        } else {\n            Less\n        }\n    }\n}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural`, rounded to the nearest multiple of `2 ^ pow`, to the input `Vec`. If the\n// original value is exactly between two multiples, it is rounded to the one whose `pow`th bit is\n// zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.\npub_test! {limbs_round_to_multiple_of_power_of_2_nearest_in_place(\n    xs: &mut Vec<Limb>,\n    pow: u64\n) -> Ordering {\n    if pow == 0 {\n        Equal\n    } else if !limbs_get_bit(xs, pow - 1) {\n        limbs_round_to_multiple_of_power_of_2_down_in_place(xs, pow)\n    } else if !limbs_divisible_by_power_of_2(xs, pow - 1) {\n        limbs_round_to_multiple_of_power_of_2_up_in_place(xs, pow)\n    } else {\n        limbs_round_to_multiple_of_power_of_2_half_integer_to_even_in_place(xs, pow)\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` rounded to the nearest multiple of `2 ^ pow` to the input `Vec`, using a\n// specified rounding format. If the original value is not already a multiple of the power of two,\n// and the `RoundingMode` is `Exact`, the value of `xs` becomes unspecified and `None` is returned.\n// Otherwise, an `Ordering` is returned. The limbs should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), pow / Limb::WIDTH)`.\npub_test! {limbs_round_to_multiple_of_power_of_2_in_place(\n    xs: &mut Vec<Limb>,\n    pow: u64,\n    rm: RoundingMode,\n) -> Option<Ordering> {\n    match rm {\n        Down | Floor => {\n            Some(limbs_round_to_multiple_of_power_of_2_down_in_place(xs, pow))\n        }\n        Up | Ceiling => {\n            Some(limbs_round_to_multiple_of_power_of_2_up_in_place(xs, pow))\n        }\n        Nearest => Some(limbs_round_to_multiple_of_power_of_2_nearest_in_place(\n            xs, pow,\n        )),\n        Exact => {\n            if limbs_divisible_by_power_of_2(xs, pow) {\n                Some(Equal)\n            } else {\n                None\n            }\n        }\n    }\n}}\n\nimpl RoundToMultipleOfPowerOf2<u64> for Natural {\n    type Output = Self;\n\n    /// Rounds a [`Natural`] to a multiple of $2^k$ according to a specified rounding mode. The\n    /// [`Natural`] is taken by value. An [`Ordering`] is also returned, indicating whether the\n    /// returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{2^k}$:\n    ///\n    /// $f(x, k, \\mathrm{Down}) = f(x, k, \\mathrm{Floor}) = 2^k \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Up}) = f(x, k, \\mathrm{Ceiling}) = 2^k \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n    ///     2^k \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///     q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     2^k \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, k, \\mathrm{Exact}) = 2^k q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_of_power_of_2(pow, Exact)`\n    /// - `{ assert!(x.divisible_by_power_of_2(pow)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple_of_power_of_2(2, Floor)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple_of_power_of_2(2, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple_of_power_of_2(2, Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple_of_power_of_2(2, Up)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .round_to_multiple_of_power_of_2(2, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(12u32)\n    ///         .round_to_multiple_of_power_of_2(2, Exact)\n    ///         .to_debug_string(),\n    ///     \"(12, Equal)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple_of_power_of_2(mut self, pow: u64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_of_power_of_2_assign(pow, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultipleOfPowerOf2<u64> for &Natural {\n    type Output = Natural;\n\n    /// Rounds a [`Natural`] to a multiple of $2^k$ according to a specified rounding mode. The\n    /// [`Natural`] is taken by reference. An [`Ordering`] is also returned, indicating whether the\n    /// returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{2^k}$:\n    ///\n    /// $f(x, k, \\mathrm{Down}) = f(x, k, \\mathrm{Floor}) = 2^k \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Up}) = f(x, k, \\mathrm{Ceiling}) = 2^k \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n    ///     2^k \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///     q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     2^k \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, k, \\mathrm{Exact}) = 2^k q$, but panics if $q \\notin \\Z$.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_of_power_of_2(pow, Exact)`\n    /// - `{ assert!(x.divisible_by_power_of_2(pow)); x }`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple_of_power_of_2(2, Floor)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple_of_power_of_2(2, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple_of_power_of_2(2, Down)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple_of_power_of_2(2, Up)\n    ///         .to_debug_string(),\n    ///     \"(12, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32))\n    ///         .round_to_multiple_of_power_of_2(2, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(12u32))\n    ///         .round_to_multiple_of_power_of_2(2, Exact)\n    ///         .to_debug_string(),\n    ///     \"(12, Equal)\"\n    /// );\n    /// ```\n    fn round_to_multiple_of_power_of_2(self, pow: u64, rm: RoundingMode) -> (Natural, Ordering) {\n        match (self, pow) {\n            (_, 0) | (&Natural::ZERO, _) => (self.clone(), Equal),\n            (Natural(Small(small)), pow) => {\n                let (s, o) = small.shr_round(pow, rm);\n                (Natural::from(s) << pow, o)\n            }\n            (Natural(Large(limbs)), pow) => {\n                if let Some((result_limbs, o)) =\n                    limbs_round_to_multiple_of_power_of_2(limbs, pow, rm)\n                {\n                    (Natural::from_owned_limbs_asc(result_limbs), o)\n                } else {\n                    panic!(\"Rounding {self} to multiple of 2^{pow} is not exact\");\n                }\n            }\n        }\n    }\n}\n\nimpl RoundToMultipleOfPowerOf2Assign<u64> for Natural {\n    /// Rounds a [`Natural`] to a multiple of $2^k$ in place, according to a specified rounding\n    /// mode. An [`Ordering`] is returned, indicating whether the returned value is less than, equal\n    /// to, or greater than the original value.\n    ///\n    /// See the [`RoundToMultipleOfPowerOf2`] documentation for details.\n    ///\n    /// The following two expressions are equivalent:\n    /// - `x.round_to_multiple_of_power_of_2_assign(pow, Exact);`\n    /// - `assert!(x.divisible_by_power_of_2(pow));`\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Floor), Less);\n    /// assert_eq!(n, 8);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(\n    ///     n.round_to_multiple_of_power_of_2_assign(2, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(n, 12);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Down), Less);\n    /// assert_eq!(n, 8);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Up), Greater);\n    /// assert_eq!(n, 12);\n    ///\n    /// let mut n = Natural::from(10u32);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Nearest), Less);\n    /// assert_eq!(n, 8);\n    ///\n    /// let mut n = Natural::from(12u32);\n    /// assert_eq!(n.round_to_multiple_of_power_of_2_assign(2, Exact), Equal);\n    /// assert_eq!(n, 12);\n    /// ```\n    fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode) -> Ordering {\n        match (&mut *self, pow) {\n            (_, 0) | (&mut Self::ZERO, _) => Equal,\n            (Self(Small(small)), pow) => {\n                let o = small.shr_round_assign(pow, rm);\n                *self <<= pow;\n                o\n            }\n            (Self(Large(limbs)), pow) => {\n                if let Some(o) = limbs_round_to_multiple_of_power_of_2_in_place(limbs, pow, rm) {\n                    self.trim();\n                    o\n                } else {\n                    panic!(\"Rounding is not exact\");\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/saturating_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{CheckedSub, SaturatingSub, SaturatingSubAssign};\nuse malachite_base::num::basic::traits::Zero;\n\nimpl SaturatingSub<Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking both by value and returning 0 if the\n    /// result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\max(x - y, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSub};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.saturating_sub(Natural::from(123u32)), 0);\n    /// assert_eq!(Natural::from(123u32).saturating_sub(Natural::ZERO), 123);\n    /// assert_eq!(\n    ///     Natural::from(456u32).saturating_sub(Natural::from(123u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (Natural::from(10u32).pow(12) * Natural::from(3u32))\n    ///         .saturating_sub(Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub(self, other: Self) -> Self {\n        CheckedSub::checked_sub(self, other).unwrap_or(Self::ZERO)\n    }\n}\n\nimpl<'a> SaturatingSub<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference and returning 0 if the result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\max(x - y, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSub};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.saturating_sub(&Natural::from(123u32)), 0);\n    /// assert_eq!(Natural::from(123u32).saturating_sub(&Natural::ZERO), 123);\n    /// assert_eq!(\n    ///     Natural::from(456u32).saturating_sub(&Natural::from(123u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (Natural::from(10u32).pow(12) * Natural::from(3u32))\n    ///         .saturating_sub(&Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub(self, other: &'a Self) -> Self {\n        CheckedSub::checked_sub(self, other).unwrap_or(Self::ZERO)\n    }\n}\n\nimpl SaturatingSub<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value and returning 0 if the result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\max(x - y, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSub};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).saturating_sub(Natural::from(123u32)), 0);\n    /// assert_eq!((&Natural::from(123u32)).saturating_sub(Natural::ZERO), 123);\n    /// assert_eq!(\n    ///     (&Natural::from(456u32)).saturating_sub(Natural::from(123u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (&(Natural::from(10u32).pow(12) * Natural::from(3u32)))\n    ///         .saturating_sub(Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub(self, other: Natural) -> Natural {\n        CheckedSub::checked_sub(self, other).unwrap_or(Natural::ZERO)\n    }\n}\n\nimpl SaturatingSub<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking both by reference and returning 0 if\n    /// the result is negative.\n    ///\n    /// $$\n    /// f(x, y) = \\max(x - y, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSub};\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).saturating_sub(&Natural::from(123u32)), 0);\n    /// assert_eq!((&Natural::from(123u32)).saturating_sub(&Natural::ZERO), 123);\n    /// assert_eq!(\n    ///     (&Natural::from(456u32)).saturating_sub(&Natural::from(123u32)),\n    ///     333\n    /// );\n    /// assert_eq!(\n    ///     (&(Natural::from(10u32).pow(12) * Natural::from(3u32)))\n    ///         .saturating_sub(&Natural::from(10u32).pow(12)),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub(self, other: &Natural) -> Natural {\n        CheckedSub::checked_sub(self, other).unwrap_or(Natural::ZERO)\n    }\n}\n\nimpl SaturatingSubAssign<Self> for Natural {\n    /// Subtracts a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value and setting the left-hand side to 0 if the result is negative.\n    ///\n    /// $$\n    /// x \\gets \\max(x - y, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SaturatingSubAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.saturating_sub_assign(Natural::from(123u32));\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.saturating_sub_assign(Natural::ZERO);\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Natural::from(456u32);\n    /// x.saturating_sub_assign(Natural::from(123u32));\n    /// assert_eq!(x, 333);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.saturating_sub_assign(Natural::from(456u32));\n    /// assert_eq!(x, 0);\n    /// ```\n    #[inline]\n    fn saturating_sub_assign(&mut self, other: Self) {\n        if self.sub_assign_ref_no_panic(&other) {\n            *self = Self::ZERO;\n        }\n    }\n}\n\nimpl<'a> SaturatingSubAssign<&'a Self> for Natural {\n    /// Subtracts a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference and setting the left-hand side to 0 if the result is negative.\n    ///\n    /// $$\n    /// x \\gets \\max(x - y, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SaturatingSubAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.saturating_sub_assign(&Natural::from(123u32));\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.saturating_sub_assign(&Natural::ZERO);\n    /// assert_eq!(x, 123);\n    ///\n    /// let mut x = Natural::from(456u32);\n    /// x.saturating_sub_assign(&Natural::from(123u32));\n    /// assert_eq!(x, 333);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.saturating_sub_assign(&Natural::from(456u32));\n    /// assert_eq!(x, 0);\n    /// ```\n    #[inline]\n    fn saturating_sub_assign(&mut self, other: &'a Self) {\n        if self.sub_assign_ref_no_panic(other) {\n            *self = Self::ZERO;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/saturating_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{\n    CheckedSubMul, SaturatingSubMul, SaturatingSubMulAssign,\n};\nuse malachite_base::num::basic::traits::Zero;\n\nimpl SaturatingSubMul<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking all three by value\n    /// and returning 0 if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).saturating_sub_mul(Natural::from(3u32), Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).saturating_sub_mul(Natural::from(3u32), Natural::from(4u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .saturating_sub_mul(Natural::from(0x10000u32), Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub_mul(self, y: Self, z: Self) -> Self {\n        self.checked_sub_mul(y, z).unwrap_or(Self::ZERO)\n    }\n}\n\nimpl SaturatingSubMul<Self, &Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first two by\n    /// value and the third by reference and returning 0 if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).saturating_sub_mul(Natural::from(3u32), &Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).saturating_sub_mul(Natural::from(3u32), &Natural::from(4u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .saturating_sub_mul(Natural::from(0x10000u32), &Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub_mul(self, y: Self, z: &Self) -> Self {\n        self.checked_sub_mul(y, z).unwrap_or(Self::ZERO)\n    }\n}\n\nimpl SaturatingSubMul<&Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first and third\n    /// by value and the second by reference and returning 0 if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).saturating_sub_mul(&Natural::from(3u32), Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).saturating_sub_mul(&Natural::from(3u32), Natural::from(4u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .saturating_sub_mul(&Natural::from(0x10000u32), Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub_mul(self, y: &Self, z: Self) -> Self {\n        self.checked_sub_mul(y, z).unwrap_or(Self::ZERO)\n    }\n}\n\nimpl SaturatingSubMul<&Self, &Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first by value\n    /// and the second and third by reference and returning 0 if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).saturating_sub_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32).saturating_sub_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .saturating_sub_mul(&Natural::from(0x10000u32), &Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub_mul(self, y: &Self, z: &Self) -> Self {\n        self.checked_sub_mul(y, z).unwrap_or(Self::ZERO)\n    }\n}\n\nimpl SaturatingSubMul<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking all three by\n    /// reference and returning 0 if the result is negative.\n    ///\n    /// $$\n    /// f(x, y, z) = \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(20u32)).saturating_sub_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32)).saturating_sub_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12))\n    ///         .saturating_sub_mul(&Natural::from(0x10000u32), &Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    #[inline]\n    fn saturating_sub_mul(self, y: &Natural, z: &Natural) -> Natural {\n        self.checked_sub_mul(y, z).unwrap_or(Natural::ZERO)\n    }\n}\n\nimpl SaturatingSubMulAssign<Self, Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking both\n    /// [`Natural`]s on the right-hand side by value and replacing the left-hand side [`Natural`]\n    /// with 0 if the result is negative.\n    ///\n    /// $$\n    /// x \\gets \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.saturating_sub_mul_assign(Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.saturating_sub_mul_assign(Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.saturating_sub_mul_assign(Natural::from(0x10000u32), Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    #[inline]\n    fn saturating_sub_mul_assign(&mut self, y: Self, z: Self) {\n        if self.sub_mul_assign_no_panic(y, z) {\n            *self = Self::ZERO;\n        }\n    }\n}\n\nimpl SaturatingSubMulAssign<Self, &Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking the first\n    /// [`Natural`] on the right-hand side by value and the second by reference and replacing the\n    /// left-hand side [`Natural`] with 0 if the result is negative.\n    ///\n    /// $$\n    /// x \\gets \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.saturating_sub_mul_assign(Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.saturating_sub_mul_assign(Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.saturating_sub_mul_assign(Natural::from(0x10000u32), &Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    #[inline]\n    fn saturating_sub_mul_assign(&mut self, y: Self, z: &Self) {\n        if self.sub_mul_assign_val_ref_no_panic(y, z) {\n            *self = Self::ZERO;\n        }\n    }\n}\n\nimpl SaturatingSubMulAssign<&Self, Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking the first\n    /// [`Natural`] on the right-hand side by reference and the second by value and replacing the\n    /// left-hand side [`Natural`] with 0 if the result is negative.\n    ///\n    /// $$\n    /// x \\gets \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.saturating_sub_mul_assign(&Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.saturating_sub_mul_assign(&Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.saturating_sub_mul_assign(&Natural::from(0x10000u32), Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    #[inline]\n    fn saturating_sub_mul_assign(&mut self, y: &Self, z: Self) {\n        if self.sub_mul_assign_ref_val_no_panic(y, z) {\n            *self = Self::ZERO;\n        }\n    }\n}\n\nimpl SaturatingSubMulAssign<&Self, &Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking both\n    /// [`Natural`]s on the right-hand side by reference and replacing the left-hand side\n    /// [`Natural`] with 0 if the result is negative.\n    ///\n    /// $$\n    /// x \\gets \\max(x - yz, 0).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SaturatingSubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.saturating_sub_mul_assign(&Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32);\n    /// x.saturating_sub_mul_assign(&Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.saturating_sub_mul_assign(&Natural::from(0x10000u32), &Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    #[inline]\n    fn saturating_sub_mul_assign(&mut self, y: &Self, z: &Self) {\n        if self.sub_mul_assign_ref_ref_no_panic(y, z) {\n            *self = Self::ZERO;\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 2000-2002 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShl, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::vecs::vec_pad_left;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` left-shifted by a `Limb`.\n//\n// # Worst-case complexity\n// $T(n, m) = O(n + m)$\n//\n// $M(n, m) = O(n + m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `bits / Limb::WIDTH`.\n//\n// This is equivalent to `mpn_lshift` from `mpn/generic/lshift.c`, GMP 6.2.1, where the result is\n// returned.\npub_crate_test! {limbs_shl(xs: &[Limb], bits: u64) -> Vec<Limb> {\n    let small_bits = bits & Limb::WIDTH_MASK;\n    let mut out = vec![0; bit_to_limb_count_floor(bits)];\n    if small_bits == 0 {\n        out.extend_from_slice(xs);\n    } else {\n        let cobits = Limb::WIDTH - small_bits;\n        let mut remaining_bits = 0;\n        for x in xs {\n            out.push((x << small_bits) | remaining_bits);\n            remaining_bits = x >> cobits;\n        }\n        if remaining_bits != 0 {\n            out.push(remaining_bits);\n        }\n    }\n    out\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` left-shifted by a `Limb` to an output slice. The output slice must be at\n// least as long as the input slice. The `Limb` must be between 1 and `Limb::WIDTH` - 1, inclusive.\n// The carry, or the bits that are shifted past the width of the input slice, is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs`, `bits` is 0, or `bits` is greater than or equal to\n// `Limb::WIDTH`.\n//\n// This is equivalent to `mpn_lshift` from `mpn/generic/lshift.c`, GMP 6.2.1.\npub_crate_test! {limbs_shl_to_out(out: &mut [Limb], xs: &[Limb], bits: u64) -> Limb {\n    assert_ne!(bits, 0);\n    assert!(bits < Limb::WIDTH);\n    let cobits = Limb::WIDTH - bits;\n    let mut remaining_bits = 0;\n    for (out, x) in out[..xs.len()].iter_mut().zip(xs.iter()) {\n        *out = (x << bits) | remaining_bits;\n        remaining_bits = x >> cobits;\n    }\n    remaining_bits\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` left-shifted by a `Limb` to the input slice. The `Limb` must be between 1\n// and `Limb::WIDTH` - 1, inclusive. The carry, or the bits that are shifted past the width of the\n// input slice, is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_lshift` from `mpn/generic/lshift.c`, GMP 6.2.1, where `rp == up`.\npub_crate_test! {limbs_slice_shl_in_place(xs: &mut [Limb], bits: u64) -> Limb {\n    assert_ne!(bits, 0);\n    assert!(bits < Limb::WIDTH);\n    let cobits = Limb::WIDTH - bits;\n    let mut remaining_bits = 0;\n    for x in &mut *xs {\n        let previous_x = *x;\n        *x = (previous_x << bits) | remaining_bits;\n        remaining_bits = previous_x >> cobits;\n    }\n    remaining_bits\n}}\n\n// Interpreting a nonempty `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes\n// the limbs of the `Natural` left-shifted by a `Limb` to the input `Vec`.\n//\n// # Worst-case complexity\n// $T(n, m) = O(n + m)$\n//\n// $M(n, m) = O(n + m)$\n//\n// # Panics\n// Panics if `xs` is empty.\n//\n// This is equivalent to `mpn_lshift` from `mpn/generic/lshift.c`, GMP 6.2.1, where `rp == up` and\n// the carry is appended to `rp`.\npub_crate_test! {limbs_vec_shl_in_place(xs: &mut Vec<Limb>, bits: u64) {\n    let small_bits = bits & Limb::WIDTH_MASK;\n    let remaining_bits = if small_bits == 0 {\n        0\n    } else {\n        limbs_slice_shl_in_place(xs, small_bits)\n    };\n    vec_pad_left(xs, bit_to_limb_count_floor(bits), 0);\n    if remaining_bits != 0 {\n        xs.push(remaining_bits);\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` left-shifted by a `Limb`, and complemented, to an output slice. The output\n// slice must be at least as long as the input slice. The `Limb` must be between 1 and `Limb::WIDTH`\n// - 1, inclusive. The carry, or the bits that are shifted past the width of the input slice, is\n// returned. The carry is not complemented.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs`, `xs` is empty, `bits` is 0, or `bits` is greater than or\n// equal to `Limb::WIDTH`.\n//\n// This is equivalent to `mpn_lshiftc` from `mpn/generic/lshift.c`, GMP 6.2.1.\npub_crate_test! {limbs_shl_with_complement_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    bits: u64\n) -> Limb {\n    let n = xs.len();\n    assert_ne!(n, 0);\n    assert_ne!(bits, 0);\n    assert!(bits < Limb::WIDTH);\n    let cobits = Limb::WIDTH - bits;\n    let (xs_last, xs_init) = xs.split_last().unwrap();\n    let remaining_bits = xs_last >> cobits;\n    let mut previous_x = xs_last << bits;\n    let (out_head, out_tail) = out[..n].split_first_mut().unwrap();\n    for (out, x) in out_tail.iter_mut().rev().zip(xs_init.iter().rev()) {\n        *out = !(previous_x | (x >> cobits));\n        previous_x = x << bits;\n    }\n    *out_head = !previous_x;\n    remaining_bits\n}}\n\nfn shl_ref_unsigned<T: PrimitiveUnsigned>(x: &Natural, bits: T) -> Natural\nwhere\n    u64: ExactFrom<T>,\n    Limb: ArithmeticCheckedShl<T, Output = Limb>,\n{\n    match (x, bits) {\n        (&Natural::ZERO, _) => x.clone(),\n        (_, bits) if bits == T::ZERO => x.clone(),\n        (Natural(Small(small)), bits) => {\n            Natural(if let Some(shifted) = small.arithmetic_checked_shl(bits) {\n                Small(shifted)\n            } else {\n                Large(limbs_shl(&[*small], u64::exact_from(bits)))\n            })\n        }\n        (Natural(Large(limbs)), bits) => Natural(Large(limbs_shl(limbs, u64::exact_from(bits)))),\n    }\n}\n\nfn shl_assign<T: PrimitiveUnsigned>(x: &mut Natural, bits: T)\nwhere\n    u64: ExactFrom<T>,\n    Limb: ArithmeticCheckedShl<T, Output = Limb>,\n{\n    match (&mut *x, bits) {\n        (&mut Natural::ZERO, _) => {}\n        (_, bits) if bits == T::ZERO => {}\n        (Natural(Small(small)), bits) => {\n            if let Some(shifted) = small.arithmetic_checked_shl(bits) {\n                *small = shifted;\n            } else {\n                *x = Natural(Large(limbs_shl(&[*small], u64::exact_from(bits))));\n            }\n        }\n        (Natural(Large(limbs)), bits) => {\n            limbs_vec_shl_in_place(limbs, u64::exact_from(bits));\n        }\n    }\n}\n\nmacro_rules! impl_natural_shl_unsigned {\n    ($t:ident) => {\n        impl Shl<$t> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// $f(x, k) = x2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(mut self, bits: $t) -> Natural {\n                self <<= bits;\n                self\n            }\n        }\n\n        impl Shl<$t> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2), taking it by reference.\n            ///\n            /// $f(x, k) = x2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Natural {\n                shl_ref_unsigned(self, bits)\n            }\n        }\n\n        impl ShlAssign<$t> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2), in place.\n            ///\n            /// $x \\gets x2^k$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.s\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl_assign).\n            #[inline]\n            fn shl_assign(&mut self, bits: $t) {\n                shl_assign(self, bits);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_natural_shl_unsigned);\n\nfn shl_ref_signed<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n) -> Natural\nwhere\n    &'a Natural: Shl<U, Output = Natural> + Shr<U, Output = Natural>,\n{\n    if bits >= S::ZERO {\n        x << bits.unsigned_abs()\n    } else {\n        x >> bits.unsigned_abs()\n    }\n}\n\nfn shl_assign_signed<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(x: &mut Natural, bits: S)\nwhere\n    Natural: ShlAssign<U> + ShrAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x <<= bits.unsigned_abs();\n    } else {\n        *x >>= bits.unsigned_abs();\n    }\n}\n\nmacro_rules! impl_natural_shl_signed {\n    ($t:ident) => {\n        impl Shl<$t> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2 or divides it by a power of\n            /// 2 and takes the floor), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\lfloor x2^k \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(mut self, bits: $t) -> Natural {\n                self <<= bits;\n                self\n            }\n        }\n\n        impl<'a> Shl<$t> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2 or divides it by a power of\n            /// 2 and takes the floor), taking it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\lfloor x2^k \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Natural {\n                shl_ref_signed(self, bits)\n            }\n        }\n\n        impl ShlAssign<$t> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies it by a power of 2 or divides it by a power of\n            /// 2 and takes the floor), in place.\n            ///\n            /// $$\n            /// x \\gets \\lfloor x2^k \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shl#shl_assign).\n            #[inline]\n            fn shl_assign(&mut self, bits: $t) {\n                shl_assign_signed(self, bits);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_natural_shl_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse core::ops::{Shl, ShlAssign};\nuse malachite_base::num::arithmetic::traits::{\n    ShlRound, ShlRoundAssign, ShrRound, ShrRoundAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::rounding_modes::RoundingMode;\n\nfn shl_round_ref<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    rm: RoundingMode,\n) -> (Natural, Ordering)\nwhere\n    &'a Natural: Shl<U, Output = Natural> + ShrRound<U, Output = Natural>,\n{\n    if bits >= S::ZERO {\n        (x << bits.unsigned_abs(), Equal)\n    } else {\n        x.shr_round(bits.unsigned_abs(), rm)\n    }\n}\n\nfn shl_round_assign_n<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    rm: RoundingMode,\n) -> Ordering\nwhere\n    Natural: ShlAssign<U> + ShrRoundAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x <<= bits.unsigned_abs();\n        Equal\n    } else {\n        x.shr_round_assign(bits.unsigned_abs(), rm)\n    }\n}\n\nmacro_rules! impl_natural_shl_round_signed {\n    ($t:ident) => {\n        impl ShlRound<$t> for Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies or divides it by a power of 2), taking it by\n            /// value, and rounds according to the specified rounding mode. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the exact value. If `bits` is non-negative, then the returned [`Ordering`] is\n            /// always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `bits > 0 || self.divisible_by_power_of_2(bits)`. Rounding might only\n            /// be necessary if `bits` is negative.\n            ///\n            /// Let $q = x2^k$, and let $g$ be the function that just returns the first element of\n            /// the pair, without the [`Ordering`]:\n            ///\n            /// $g(x, k, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $g(x, k, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is negative and `rm` is `Exact` but `self` is not\n            /// divisible by $2^{-k}$.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round).\n            #[inline]\n            fn shl_round(mut self, bits: $t, rm: RoundingMode) -> (Natural, Ordering) {\n                let o = self.shl_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl ShlRound<$t> for &Natural {\n            type Output = Natural;\n\n            /// Left-shifts a [`Natural`] (multiplies or divides it by a power of 2), taking it by\n            /// reference, and rounds according to the specified rounding mode. An [`Ordering`] is\n            /// also returned, indicating whether the returned value is less than, equal to, or\n            /// greater than the exact value. If `bits` is non-negative, then the returned\n            /// [`Ordering`] is always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `bits > 0 || self.divisible_by_power_of_2(bits)`. Rounding might only\n            /// be necessary if `bits` is negative.\n            ///\n            /// Let $q = x2^k$, and let $g$ be the function that just returns the first element of\n            /// the pair, without the [`Ordering`]:\n            ///\n            /// $g(x, k, \\mathrm{Down}) = g(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $g(x, k, \\mathrm{Up}) = g(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// g(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $g(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is negative and `rm` is `Exact` but `self` is not\n            /// divisible by $2^{-k}$.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round).\n            #[inline]\n            fn shl_round(self, bits: $t, rm: RoundingMode) -> (Natural, Ordering) {\n                shl_round_ref(self, bits, rm)\n            }\n        }\n\n        impl ShlRoundAssign<$t> for Natural {\n            /// Left-shifts a [`Natural`] (multiplies or divides it by a power of 2) and rounds\n            /// according to the specified rounding mode, in place. An [`Ordering`] is returned,\n            /// indicating whether the assigned value is less than, equal to, or greater than the\n            /// exact value.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `bits > 0 || self.divisible_by_power_of_2(bits)`. Rounding might only\n            /// be necessary if `bits` is negative.\n            ///\n            /// See the [`ShlRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is negative and `rm` is `Exact` but `self` is not\n            /// divisible by $2^{-k}$.\n            ///\n            /// # Examples\n            /// See [here](super::shl_round#shl_round_assign).\n            #[inline]\n            fn shl_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shl_round_assign_n(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_natural_shl_round_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 2000-2002 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::vecs::vec_delete_left;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` right-shifted by a `Limb`, rounding down.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(1, xs.len() - bits / Limb::WIDTH)`.\n//\n// This is equivalent to `mpn_rshift` from `mpn/generic/rshift.c`, GMP 6.2.1, where the result is\n// returned.\npub_crate_test! {limbs_shr(xs: &[Limb], bits: u64) -> Vec<Limb> {\n    let delete_count = bit_to_limb_count_floor(bits);\n    if delete_count >= xs.len() {\n        Vec::new()\n    } else {\n        let mut out = xs[delete_count..].to_vec();\n        let small_bits = bits & Limb::WIDTH_MASK;\n        if small_bits != 0 {\n            limbs_slice_shr_in_place(&mut out, small_bits);\n        }\n        out\n    }\n}}\n\n// Interpreting a nonempty slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes\n// the limbs of the `Natural` right-shifted by a `Limb` to an output slice. The output slice must be\n// at least as long as the input slice. The `Limb` must be between 1 and `Limb::WIDTH` - 1,\n// inclusive. The carry, or the bits that are shifted past the width of the input slice, is\n// returned. The input slice should not only contain zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty, `out` is shorter than `xs`, `bits` is 0, or `bits` is greater than or\n// equal to `Limb::WIDTH`.\n//\n// This is equivalent to `mpn_rshift` from `mpn/generic/rshift.c`, GMP 6.2.1.\npub_crate_test! {limbs_shr_to_out(out: &mut [Limb], xs: &[Limb], bits: u64) -> Limb {\n    let len = xs.len();\n    assert_ne!(len, 0);\n    assert_ne!(bits, 0);\n    assert!(bits < Limb::WIDTH);\n    assert!(out.len() >= len);\n    let cobits = Limb::WIDTH - bits;\n    let (xs_head, xs_tail) = xs.split_first().unwrap();\n    let remaining_bits = xs_head << cobits;\n    let mut previous_x = xs_head >> bits;\n    let (out_last, out_init) = out[..len].split_last_mut().unwrap();\n    for (out, x) in out_init.iter_mut().zip(xs_tail.iter()) {\n        *out = previous_x | (x << cobits);\n        previous_x = x >> bits;\n    }\n    *out_last = previous_x;\n    remaining_bits\n}}\n\n// Interpreting a nonempty slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes\n// the limbs of the `Natural` right-shifted by a `Limb` to the input slice. The `Limb` must be\n// between 1 and `Limb::WIDTH` - 1, inclusive. The carry, or the bits that are shifted past the\n// width of the input slice, is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty, `bits` is 0, or `bits` is greater than or equal to `Limb::WIDTH`.\n//\n// This is equivalent to `mpn_rshift` from `mpn/generic/rshift.c`, GMP 6.2.1, where `rp == up`.\npub_crate_test! {limbs_slice_shr_in_place<T: PrimitiveUnsigned>(xs: &mut [T], bits: u64) -> T {\n    assert_ne!(bits, 0);\n    assert!(bits < T::WIDTH);\n    let len = xs.len();\n    assert_ne!(len, 0);\n    let cobits = T::WIDTH - bits;\n    let mut x = xs[0];\n    let remaining_bits = x << cobits;\n    let mut previous_x = x >> bits;\n    for i in 1..len {\n        x = xs[i];\n        xs[i - 1] = previous_x | (x << cobits);\n        previous_x = x >> bits;\n    }\n    *xs.last_mut().unwrap() = previous_x;\n    remaining_bits\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` right-shifted by a `Limb` to the input `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(1, xs.len() - bits / Limb::WIDTH)`.\n//\n// This is equivalent to `mpn_rshift` from `mpn/generic/rshift.c`, GMP 6.2.1, where `rp == up` and\n// if `cnt` is sufficiently large, limbs are removed from `rp`.\npub_crate_test! {limbs_vec_shr_in_place(xs: &mut Vec<Limb>, bits: u64) {\n    let delete_count = bit_to_limb_count_floor(bits);\n    if delete_count >= xs.len() {\n        xs.clear();\n    } else {\n        let small_shift = bits & Limb::WIDTH_MASK;\n        vec_delete_left(xs, delete_count);\n        if small_shift != 0 {\n            limbs_slice_shr_in_place(xs, small_shift);\n        }\n    }\n}}\n\nfn shr_unsigned_ref<T: Copy + Eq + Ord + WrappingFrom<u64> + Zero>(x: &Natural, bits: T) -> Natural\nwhere\n    u64: ExactFrom<T>,\n    Limb: Shr<T, Output = Limb>,\n{\n    match (x, bits) {\n        (&Natural::ZERO, _) => x.clone(),\n        (_, bits) if bits == T::ZERO => x.clone(),\n        (Natural(Small(_)), bits) if bits >= T::wrapping_from(Limb::WIDTH) => Natural::ZERO,\n        (Natural(Small(small)), bits) => Natural(Small(*small >> bits)),\n        (Natural(Large(limbs)), bits) => {\n            Natural::from_owned_limbs_asc(limbs_shr(limbs, u64::exact_from(bits)))\n        }\n    }\n}\n\nfn shr_assign_unsigned<T: PrimitiveUnsigned>(x: &mut Natural, bits: T)\nwhere\n    u64: ExactFrom<T>,\n    Limb: ShrAssign<T>,\n{\n    match (&mut *x, bits) {\n        (&mut Natural::ZERO, _) => {}\n        (_, bits) if bits == T::ZERO => {}\n        (Natural(Small(small)), bits) if bits >= T::wrapping_from(Limb::WIDTH) => {\n            *small = 0;\n        }\n        (Natural(Small(small)), bits) => {\n            *small >>= bits;\n        }\n        (Natural(Large(limbs)), bits) => {\n            limbs_vec_shr_in_place(limbs, u64::exact_from(bits));\n            x.trim();\n        }\n    }\n}\n\nmacro_rules! impl_natural_shr_unsigned {\n    ($t:ident) => {\n        impl Shr<$t> for Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2 and takes the floor), taking\n            /// it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(mut self, bits: $t) -> Natural {\n                self >>= bits;\n                self\n            }\n        }\n\n        impl<'a> Shr<$t> for &Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2 and takes the floor), taking\n            /// it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Natural {\n                shr_unsigned_ref(self, bits)\n            }\n        }\n\n        impl ShrAssign<$t> for Natural {\n            /// Right-shifts a [`Natural`] (divides it by a power of 2 and takes the floor), in\n            /// place.\n            ///\n            /// $$\n            /// x \\gets \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr_assign).\n            #[inline]\n            fn shr_assign(&mut self, bits: $t) {\n                shr_assign_unsigned(self, bits);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_natural_shr_unsigned);\n\nfn shr_signed_ref<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n) -> Natural\nwhere\n    &'a Natural: Shl<U, Output = Natural> + Shr<U, Output = Natural>,\n{\n    if bits >= S::ZERO {\n        x >> bits.unsigned_abs()\n    } else {\n        x << bits.unsigned_abs()\n    }\n}\n\nfn shr_assign_signed<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(x: &mut Natural, bits: S)\nwhere\n    Natural: ShlAssign<U> + ShrAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x >>= bits.unsigned_abs();\n    } else {\n        *x <<= bits.unsigned_abs();\n    }\n}\n\nmacro_rules! impl_natural_shr_signed {\n    ($t:ident) => {\n        impl Shr<$t> for Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2 and takes the floor or\n            /// multiplies it by a power of 2), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(mut self, bits: $t) -> Natural {\n                self >>= bits;\n                self\n            }\n        }\n\n        impl<'a> Shr<$t> for &Natural {\n            type Output = Natural;\n\n            /// Right-shifts a [`Natural`] (divides it by a power of 2 and takes the floor or\n            /// multiplies it by a power of 2), taking it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Natural {\n                shr_signed_ref(self, bits)\n            }\n        }\n\n        impl ShrAssign<$t> for Natural {\n            /// Right-shifts a [`Natural`] (divides it by a power of 2 and takes the floor or\n            /// multiplies it by a power of 2), in place.\n            ///\n            /// $$\n            /// x \\gets \\left \\lfloor \\frac{x}{2^k} \\right \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `max(1,\n            /// self.significant_bits() - bits)`.\n            ///\n            /// # Examples\n            /// See [here](super::shr#shr_assign).\n            #[inline]\n            fn shr_assign(&mut self, bits: $t) {\n                shr_assign_signed(self, bits);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_natural_shr_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 1998, 1999, 2001, 2002, 2004, 2012, 2015 Free Software\n//      Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::limbs_vec_add_limb_in_place;\nuse crate::natural::arithmetic::divisible_by_power_of_2::limbs_divisible_by_power_of_2;\nuse crate::natural::arithmetic::shr::{\n    limbs_shr, limbs_slice_shr_in_place, limbs_vec_shr_in_place,\n};\nuse crate::natural::logic::bit_access::limbs_get_bit;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::{self, *};\nuse core::ops::{Shl, ShlAssign};\nuse malachite_base::num::arithmetic::traits::{Parity, ShrRound, ShrRoundAssign, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::slice_test_zero;\nuse malachite_base::vecs::vec_delete_left;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` right-shifted by a `Limb`, rounding up. The limbs should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(1, xs.len() - bits / Limb::WIDTH)`.\n//\n// This is equivalent to `cfdiv_q_2exp` from `mpz/cfdiv_q_2exp.c`, GMP 6.2.1, where `u` is\n// non-negative, `dir == 1`, and the result is returned.\npub_test! {limbs_shr_round_up(xs: &[Limb], bits: u64) -> (Vec<Limb>, Ordering) {\n    let delete_count = bit_to_limb_count_floor(bits);\n    if delete_count >= xs.len() {\n        (vec![1], Greater)\n    } else {\n        let (xs_lo, xs_hi) = xs.split_at(delete_count);\n        let mut exact = slice_test_zero(xs_lo);\n        let mut out = xs_hi.to_vec();\n        let small_bits = bits & Limb::WIDTH_MASK;\n        if small_bits != 0 {\n            exact &= limbs_slice_shr_in_place(&mut out, small_bits) == 0;\n        }\n        if !exact {\n            limbs_vec_add_limb_in_place(&mut out, 1);\n        }\n        (\n            out,\n            if exact {\n                Equal\n            } else {\n                Greater\n            },\n        )\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(1, xs.len() - bits / Limb::WIDTH)`.\nfn limbs_shr_round_half_integer_to_even(xs: &[Limb], bits: u64) -> (Vec<Limb>, Ordering) {\n    let delete_count = bit_to_limb_count_floor(bits);\n    if delete_count >= xs.len() {\n        (Vec::new(), if slice_test_zero(xs) { Equal } else { Less })\n    } else {\n        let small_bits = bits & Limb::WIDTH_MASK;\n        let (xs_lo, xs_hi) = xs.split_at(delete_count);\n        let mut exact = slice_test_zero(xs_lo);\n        let mut out = xs_hi.to_vec();\n        if small_bits != 0 {\n            exact &= limbs_slice_shr_in_place(&mut out, small_bits) == 0;\n        }\n        if !out.is_empty() && out[0].odd() {\n            limbs_vec_add_limb_in_place(&mut out, 1);\n            (out, Greater)\n        } else {\n            (out, if exact { Equal } else { Less })\n        }\n    }\n}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` right-shifted by a `Limb`, rounding to the `Natural` nearest to the actual\n// value of `self` divided by `2 ^ bits`. If the actual value is exactly between two integers, it is\n// rounded to the even one.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `max(1, xs.len() -\n// bits / Limb::WIDTH)`.\npub_test! {limbs_shr_round_nearest(xs: &[Limb], bits: u64) -> (Vec<Limb>, Ordering) {\n    if bits == 0 {\n        (xs.to_vec(), Equal)\n    } else {\n        let d = slice_test_zero(xs) || limbs_divisible_by_power_of_2(xs, bits - 1);\n        if !limbs_get_bit(xs, bits - 1) {\n            (\n                limbs_shr(xs, bits),\n                if d { Equal } else { Less },\n            )\n        } else if d {\n            limbs_shr_round_half_integer_to_even(xs, bits)\n        } else {\n            limbs_shr_round_up(xs, bits)\n        }\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` right-shifted by a `Limb`, if the shift is exact (doesn't remove any\n// `true` bits). If the shift is inexact, `None` is returned. The limbs should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `max(1, xs.len() -\n// bits / Limb::WIDTH)`.\npub_test! {limbs_shr_exact(xs: &[Limb], bits: u64) -> Option<Vec<Limb>> {\n    if limbs_divisible_by_power_of_2(xs, bits) {\n        Some(limbs_shr(xs, bits))\n    } else {\n        None\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the `Natural` right-shifted by a `Limb`, rounded using a specified rounding format. The\n// limbs should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `max(1, xs.len() -\n// bits / Limb::WIDTH)`.\npub_test! {\n    limbs_shr_round(xs: &[Limb], bits: u64, rm: RoundingMode) -> Option<(Vec<Limb>, Ordering)> {\n    match rm {\n        Down | Floor => Some((\n            limbs_shr(xs, bits),\n            if limbs_divisible_by_power_of_2(xs, bits) {\n                Equal\n            } else {\n                Less\n            },\n        )),\n        Up | Ceiling => Some(limbs_shr_round_up(xs, bits)),\n        Nearest => Some(limbs_shr_round_nearest(xs, bits)),\n        Exact => limbs_shr_exact(xs, bits).map(|ss| (ss, Equal)),\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` right-shifted by a `Limb`, rounding up, to the input `Vec`. The limbs\n// should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(1, xs.len() - bits / Limb::WIDTH)`.\n//\n// This is equivalent to `cfdiv_q_2exp` from `mpz/cfdiv_q_2exp.c`, GMP 6.2.1, where `u` is\n// non-negative, `dir == 1`, and `w == u`.\npub_test! {limbs_vec_shr_round_up_in_place(xs: &mut Vec<Limb>, bits: u64) -> Ordering {\n    let delete_count = bit_to_limb_count_floor(bits);\n    if delete_count >= xs.len() {\n        xs.truncate(1);\n        xs[0] = 1;\n        Greater\n    } else {\n        let mut exact = slice_test_zero(&xs[..delete_count]);\n        let small_bits = bits & Limb::WIDTH_MASK;\n        vec_delete_left(xs, delete_count);\n        if small_bits != 0 {\n            exact &= limbs_slice_shr_in_place(xs, small_bits) == 0;\n        }\n        if !exact {\n            limbs_vec_add_limb_in_place(xs, 1);\n        }\n        if exact {\n            Equal\n        } else {\n            Greater\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `max(1, xs.len() - bits / Limb::WIDTH)`.\nfn limbs_vec_shr_round_half_integer_to_even_in_place(xs: &mut Vec<Limb>, bits: u64) -> Ordering {\n    let delete_count = bit_to_limb_count_floor(bits);\n    if delete_count >= xs.len() {\n        let o = if slice_test_zero(xs) { Equal } else { Less };\n        xs.clear();\n        o\n    } else {\n        let small_bits = bits & Limb::WIDTH_MASK;\n        let mut exact = slice_test_zero(&xs[..delete_count]);\n        vec_delete_left(xs, delete_count);\n        if small_bits != 0 {\n            exact &= limbs_slice_shr_in_place(xs, small_bits) == 0;\n        }\n        if !xs.is_empty() && xs[0].odd() {\n            limbs_vec_add_limb_in_place(xs, 1);\n            Greater\n        } else if exact {\n            Equal\n        } else {\n            Less\n        }\n    }\n}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` right-shifted by a `Limb` to the input `Vec`, rounding to the `Natural`\n// nearest to the actual value of `self` divided by `2 ^ bits`. If the actual value is exactly\n// between two integers, it is rounded to the even one.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `xs.len()`.\npub_test! {limbs_vec_shr_round_nearest_in_place(xs: &mut Vec<Limb>, bits: u64) -> Ordering {\n    if bits == 0 {\n        Equal\n    } else {\n        let d = slice_test_zero(xs) || limbs_divisible_by_power_of_2(xs, bits - 1);\n        if !limbs_get_bit(xs, bits - 1) {\n            limbs_vec_shr_in_place(xs, bits);\n            if d {\n                Equal\n            } else {\n                Less\n            }\n        } else if d {\n            limbs_vec_shr_round_half_integer_to_even_in_place(xs, bits)\n        } else {\n            limbs_vec_shr_round_up_in_place(xs, bits)\n        }\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` right-shifted by a `Limb` to the input `Vec`, if the shift is exact\n// (doesn't remove any `true` bits). Returns whether the shift was exact. The limbs should not all\n// be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `xs.len()`.\npub_test! {limbs_vec_shr_exact_in_place(xs: &mut Vec<Limb>, bits: u64) -> bool {\n    if limbs_divisible_by_power_of_2(xs, bits) {\n        limbs_vec_shr_in_place(xs, bits);\n        true\n    } else {\n        false\n    }\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the `Natural` right-shifted by a `Limb` to the input `Vec`, rounded using a specified\n// rounding format. If the shift is inexact (removes some `true` bits) and the `RoundingMode` is\n// `Exact`, the value of `xs` becomes unspecified and `false` is returned. Otherwise, `true` is\n// returned. The limbs should not all be zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory and $n$ is `xs.len()`.\npub_test! {limbs_vec_shr_round_in_place(\n    xs: &mut Vec<Limb>,\n    bits: u64,\n    rm: RoundingMode,\n) -> (bool, Ordering) {\n    match rm {\n        Down | Floor => {\n            let exact = limbs_divisible_by_power_of_2(xs, bits);\n            limbs_vec_shr_in_place(xs, bits);\n            (\n                true,\n                if exact {\n                    Equal\n                } else {\n                    Less\n                },\n            )\n        }\n        Up | Ceiling => {\n            (true, limbs_vec_shr_round_up_in_place(xs, bits))\n        }\n        Nearest => (true, limbs_vec_shr_round_nearest_in_place(xs, bits)),\n        Exact => (limbs_vec_shr_exact_in_place(xs, bits), Equal),\n    }\n}}\n\nfn shr_round_unsigned_ref_n<T: PrimitiveUnsigned>(\n    x: &Natural,\n    bits: T,\n    rm: RoundingMode,\n) -> (Natural, Ordering)\nwhere\n    u64: ExactFrom<T>,\n    Limb: ShrRound<T, Output = Limb>,\n{\n    match (x, bits) {\n        (&Natural::ZERO, _) => (x.clone(), Equal),\n        (_, bits) if bits == T::ZERO => (x.clone(), Equal),\n        (Natural(Small(small)), bits) => {\n            let (s, o) = small.shr_round(bits, rm);\n            (Natural(Small(s)), o)\n        }\n        (Natural(Large(limbs)), bits) => {\n            if let Some((out, o)) = limbs_shr_round(limbs, u64::exact_from(bits), rm) {\n                (Natural::from_owned_limbs_asc(out), o)\n            } else {\n                panic!(\"Right shift is not exact: {x} >> {bits}\");\n            }\n        }\n    }\n}\n\nfn shr_round_assign_unsigned_n<T: PrimitiveUnsigned>(\n    x: &mut Natural,\n    bits: T,\n    rm: RoundingMode,\n) -> Ordering\nwhere\n    u64: ExactFrom<T>,\n    Limb: ShrRoundAssign<T>,\n{\n    match (&mut *x, bits) {\n        (&mut Natural::ZERO, _) => Equal,\n        (_, bits) if bits == T::ZERO => Equal,\n        (Natural(Small(small)), bits) => small.shr_round_assign(bits, rm),\n        (Natural(Large(limbs)), bits) => {\n            let (b, o) = limbs_vec_shr_round_in_place(limbs, u64::exact_from(bits), rm);\n            assert!(b, \"Right shift is not exact.\");\n            x.trim();\n            o\n        }\n    }\n}\n\nmacro_rules! impl_natural_shr_round_unsigned {\n    ($t:ident) => {\n        impl ShrRound<$t> for Natural {\n            type Output = Natural;\n\n            /// Shifts a [`Natural`] right (divides it by a power of 2), taking it by value, and\n            /// rounds according to the specified rounding mode. An [`Ordering`] is also returned,\n            /// indicating whether the returned value is less than, equal to, or greater than the\n            /// exact value.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if `rm` is `Exact` but `self` is not divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(mut self, bits: $t, rm: RoundingMode) -> (Natural, Ordering) {\n                let o = self.shr_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl<'a> ShrRound<$t> for &Natural {\n            type Output = Natural;\n\n            /// Shifts a [`Natural`] right (divides it by a power of 2), taking it by reference, and\n            /// rounds according to the specified rounding mode. An [`Ordering`] is also returned,\n            /// indicating whether the returned value is less than, equal to, or greater than the\n            /// exact value.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(m) = O(m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(1, self.significant_bits() - bits)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if `rm` is `Exact` but `self` is not divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(self, bits: $t, rm: RoundingMode) -> (Natural, Ordering) {\n                shr_round_unsigned_ref_n(self, bits, rm)\n            }\n        }\n\n        impl ShrRoundAssign<$t> for Natural {\n            /// Shifts a [`Natural`] right (divides it by a power of 2) and rounds according to the\n            /// specified rounding mode, in place. An [`Ordering`] is returned, indicating whether\n            /// the assigned value is less than, equal to, or greater than the exact value.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>=`. To test whether `Exact` can\n            /// be passed, use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// See the [`ShrRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if `rm` is `Exact` but `self` is not divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round_assign).\n            #[inline]\n            fn shr_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shr_round_assign_unsigned_n(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_natural_shr_round_unsigned);\n\nfn shr_round_signed_ref_n<'a, U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &'a Natural,\n    bits: S,\n    rm: RoundingMode,\n) -> (Natural, Ordering)\nwhere\n    &'a Natural: Shl<U, Output = Natural> + ShrRound<U, Output = Natural>,\n{\n    if bits >= S::ZERO {\n        x.shr_round(bits.unsigned_abs(), rm)\n    } else {\n        (x << bits.unsigned_abs(), Equal)\n    }\n}\n\nfn shr_round_assign_signed_n<U, S: PrimitiveSigned + UnsignedAbs<Output = U>>(\n    x: &mut Natural,\n    bits: S,\n    rm: RoundingMode,\n) -> Ordering\nwhere\n    Natural: ShlAssign<U> + ShrRoundAssign<U>,\n{\n    if bits >= S::ZERO {\n        x.shr_round_assign(bits.unsigned_abs(), rm)\n    } else {\n        *x <<= bits.unsigned_abs();\n        Equal\n    }\n}\n\nmacro_rules! impl_natural_shr_round_signed {\n    ($t:ident) => {\n        impl ShrRound<$t> for Natural {\n            type Output = Natural;\n\n            /// Shifts a [`Natural`] right (divides or multiplies it by a power of 2), taking it by\n            /// value, and rounds according to the specified rounding mode. An [`Ordering`] is also\n            /// returned, indicating whether the returned value is less than, equal to, or greater\n            /// than the exact value. If `bits` is negative, then the returned [`Ordering`] is\n            /// always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(-bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is positive and `rm` is `Exact` but `self` is not\n            /// divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(mut self, bits: $t, rm: RoundingMode) -> (Natural, Ordering) {\n                let o = self.shr_round_assign(bits, rm);\n                (self, o)\n            }\n        }\n\n        impl<'a> ShrRound<$t> for &Natural {\n            type Output = Natural;\n\n            /// Shifts a [`Natural`] right (divides or multiplies it by a power of 2), taking it by\n            /// reference, and rounds according to the specified rounding mode. An [`Ordering`] is\n            /// also returned, indicating whether the returned value is less than, equal to, or\n            /// greater than the exact value. If `bits` is negative, then the returned [`Ordering`]\n            /// is always `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// Let $q = \\frac{x}{2^k}$, and let $g$ be the function that just returns the first\n            /// element of the pair, without the [`Ordering`]:\n            ///\n            /// $f(x, k, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = \\lfloor q \\rfloor.$\n            ///\n            /// $f(x, k, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = \\lceil q \\rceil.$\n            ///\n            /// $$\n            /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n            ///     \\lfloor q \\rfloor & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor < \\frac{1}{2}, \\\\\\\\\n            ///     \\lceil q \\rceil & \\text{if}\n            ///         \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2}, \\\\\\\\\n            ///     \\lfloor q \\rfloor & \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n            ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n            ///     \\\\ \\text{is even}, \\\\\\\\\n            ///     \\lceil q \\rceil &\n            ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and}\n            ///         \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd}.\n            /// \\end{cases}\n            /// $$\n            ///\n            /// $f(x, k, \\mathrm{Exact}) = q$, but panics if $q \\notin \\N$.\n            ///\n            /// Then\n            ///\n            /// $f(x, k, r) = (g(x, k, r), \\operatorname{cmp}(g(x, k, r), q))$.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(-bits, 0)`.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(-bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is positive and `rm` is `Exact` but `self` is not\n            /// divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round).\n            #[inline]\n            fn shr_round(self, bits: $t, rm: RoundingMode) -> (Natural, Ordering) {\n                shr_round_signed_ref_n(self, bits, rm)\n            }\n        }\n\n        impl ShrRoundAssign<$t> for Natural {\n            /// Shifts a [`Natural`] right (divides or multiplies it by a power of 2) and rounds\n            /// according to the specified rounding mode, in place. An [`Ordering`] is returned,\n            /// indicating whether the assigned value is less than, equal to, or greater than the\n            /// exact value. If `bits` is negative, then the returned [`Ordering`] is always\n            /// `Equal`, even if the higher bits of the result are lost.\n            ///\n            /// Passing `Floor` or `Down` is equivalent to using `>>`. To test whether `Exact` can\n            /// be passed, use `self.divisible_by_power_of_2(bits)`.\n            ///\n            /// See the [`ShrRound`] documentation for details.\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(-bits, 0)`.\n            ///\n            /// # Panics\n            /// Let $k$ be `bits`. Panics if $k$ is positive and `rm` is `Exact` but `self` is not\n            /// divisible by $2^k$.\n            ///\n            /// # Examples\n            /// See [here](super::shr_round#shr_round_assign).\n            #[inline]\n            fn shr_round_assign(&mut self, bits: $t, rm: RoundingMode) -> Ordering {\n                shr_round_assign_signed_n(self, bits, rm)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_natural_shr_round_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\n\nimpl Sign for Natural {\n    /// Compares a [`Natural`] to zero.\n    ///\n    /// Returns `Greater` or `Equal` depending on whether the [`Natural`] is positive or zero,\n    /// respectively.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_base::num::arithmetic::traits::Sign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.sign(), Equal);\n    /// assert_eq!(Natural::from(123u32).sign(), Greater);\n    /// ```\n    fn sign(&self) -> Ordering {\n        if *self == 0 { Equal } else { Greater }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Contributed to the GNU project by Paul Zimmermann (most code), Torbjörn Granlund\n//      (`mpn_sqrtrem1`) and Marco Bodrato (`mpn_dc_sqrt`).\n//\n//      Copyright © 1999-2002, 2004, 2005, 2008, 2010, 2012, 2015, 2017 Free Software Foundation,\n//      Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n    limbs_vec_add_limb_in_place,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::div::{\n    limbs_div_barrett_approx, limbs_div_barrett_approx_scratch_len,\n    limbs_div_divide_and_conquer_approx, limbs_div_schoolbook_approx,\n};\nuse crate::natural::arithmetic::div_mod::{\n    limbs_div_limb_to_out_mod, limbs_div_mod_qs_to_out_rs_to_ns, limbs_two_limb_inverse_helper,\n};\nuse crate::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out, limbs_mul_greater_to_out_scratch_len,\n};\nuse crate::natural::arithmetic::shl::limbs_shl_to_out;\nuse crate::natural::arithmetic::shr::{limbs_shr_to_out, limbs_slice_shr_in_place};\nuse crate::natural::arithmetic::square::{limbs_square_to_out, limbs_square_to_out_scratch_len};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::sub_mul::limbs_sub_mul_limb_same_length_in_place_left;\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{DC_DIVAPPR_Q_THRESHOLD, Limb, MU_DIVAPPR_Q_THRESHOLD, SignedLimb};\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::sqrt::sqrt_rem_2_newton;\nuse malachite_base::num::arithmetic::sqrt::sqrt_rem_newton;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingSqrt, CeilingSqrtAssign, CheckedSqrt, FloorSqrt, FloorSqrtAssign, ModPowerOf2, Parity,\n    ShrRound, SqrtAssignRem, SqrtRem, Square, WrappingSquare, WrappingSubAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, LeadingZeros, LowMask};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::slice_test_zero;\n\npub_const_test! {limbs_sqrt_rem_helper_scratch_len(n: usize) -> usize {\n    (n >> 1) + 1\n}}\n\n// - Let n be out.len().\n// - Let x be xs[..2 * n] before execution.\n// - Let s be out after execution.\n// - Let r be xs[..n] after execution.\n//\n// xs[2 * n - 1].leading_zeros() must be less than 2.\n//\n// If approx = 0, then s = floor(sqrt(x)) and r = x - s ^ 2.\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_dc_sqrtrem` from `mpn/generic/sqrtrem.c`, GMP 6.2.1.\npub_test! {limbs_sqrt_rem_helper(\n    out: &mut [Limb],\n    xs: &mut [Limb],\n    approx: Limb,\n    scratch: &mut [Limb],\n) -> bool {\n    let n = out.len();\n    assert!(n > 1);\n    let xs = &mut xs[..n << 1];\n    assert!(xs.last().unwrap().leading_zeros() < 2);\n    let h1 = n >> 1;\n    let h2 = n - h1;\n    let two_h1 = h1 << 1;\n    let xs_hi = &mut xs[two_h1..];\n    let out_hi = &mut out[h1..];\n    let q = if h2 == 1 {\n        let r_hi;\n        (out_hi[0], r_hi, xs_hi[0]) = sqrt_rem_2_newton::<Limb, SignedLimb>(xs_hi[1], xs_hi[0]);\n        r_hi\n    } else {\n        limbs_sqrt_rem_helper(out_hi, xs_hi, 0, scratch)\n    };\n    if q {\n        assert!(limbs_sub_same_length_in_place_left(\n            &mut xs_hi[..h2],\n            out_hi\n        ));\n    }\n    let xs_hi = &mut xs[h1..];\n    if h2 == 1 {\n        xs_hi[0] = limbs_div_limb_to_out_mod(scratch, &xs_hi[..n], out_hi[0]);\n    } else {\n        limbs_div_mod_qs_to_out_rs_to_ns(scratch, &mut xs_hi[..n], out_hi);\n    }\n    let mut q = Limb::from(q);\n    q += scratch[h1];\n    let mut r_hi = scratch[0].odd();\n    limbs_shr_to_out(out, &scratch[..h1], 1);\n    out[h1 - 1] |= q << (Limb::WIDTH - 1);\n    if (out[0] & approx) != 0 {\n        return true;\n    }\n    q >>= 1;\n    let (out_lo, out_hi) = out.split_at_mut(h1);\n    if r_hi {\n        r_hi = limbs_slice_add_same_length_in_place_left(&mut xs_hi[..h2], out_hi);\n    }\n    let (xs, xs_hi_hi) = xs.split_at_mut(n);\n    let (xs_lo, xs_hi) = xs.split_at_mut(two_h1);\n    let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(h1)];\n    limbs_square_to_out(xs_hi_hi, out_lo, &mut square_scratch);\n    let mut b = q;\n    if limbs_sub_same_length_in_place_left(xs_lo, &xs_hi_hi[..two_h1]) {\n        b += 1;\n    }\n    let mut r_hi = SignedLimb::from(r_hi);\n    r_hi -= if h1 == h2 {\n        SignedLimb::exact_from(b)\n    } else {\n        SignedLimb::from(limbs_sub_limb_in_place(xs_hi, b))\n    };\n    if r_hi < 0 {\n        q = Limb::from(limbs_slice_add_limb_in_place(out_hi, q));\n        r_hi += SignedLimb::exact_from(\n            limbs_slice_add_mul_limb_same_length_in_place_left(xs, out, 2) + (q << 1),\n        );\n        if limbs_sub_limb_in_place(xs, 1) {\n            r_hi -= 1;\n        }\n        limbs_sub_limb_in_place(out, 1);\n    }\n    assert!(r_hi >= 0);\n    assert!(r_hi < 2);\n    r_hi == 1\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_divappr_q` from `mpn/generic/sqrtrem.c`, GMP 6.2.1.\nfn limbs_sqrt_div_approx_helper(qs: &mut [Limb], ns: &[Limb], ds: &[Limb], scratch: &mut [Limb]) {\n    let n_len = ns.len();\n    let d_len = ds.len();\n    assert!(d_len > 2);\n    assert!(n_len >= d_len);\n    assert!(ds.last().unwrap().get_highest_bit());\n    let scratch = &mut scratch[..n_len];\n    scratch.copy_from_slice(ns);\n    let inv = limbs_two_limb_inverse_helper(ds[d_len - 1], ds[d_len - 2]);\n    qs[n_len - d_len] = Limb::from(if d_len < DC_DIVAPPR_Q_THRESHOLD {\n        limbs_div_schoolbook_approx(qs, scratch, ds, inv)\n    } else if d_len < MU_DIVAPPR_Q_THRESHOLD {\n        limbs_div_divide_and_conquer_approx(qs, scratch, ds, inv)\n    } else {\n        let mut new_scratch = vec![0; limbs_div_barrett_approx_scratch_len(n_len, d_len)];\n        limbs_div_barrett_approx(qs, ns, ds, &mut new_scratch)\n    });\n}\n\n// - Let n be out.len().\n// - Let m be xs.len().\n// - n must be ceiling(m / 2).\n// - odd must be m.odd().\n// - shift must be floor(xs[m - 1].leading_zeros() / 2).\n// - Let x be xs before execution.\n// - Let s be out after execution.\n// - Then s = floor(sqrt(x)).\n// - The return value is true iff there is a remainder (that is, x is not a perfect square).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_dc_sqrt` from `mpn/generic/sqrtrem.c`, GMP 6.2.1.\npub_test! { limbs_sqrt_helper(out: &mut [Limb], xs: &[Limb], shift: u64, odd: bool) -> bool {\n    let n = out.len();\n    let odd = usize::from(odd);\n    assert_eq!(xs.len(), (n << 1) - odd);\n    assert_ne!(*xs.last().unwrap(), 0);\n    assert!(n > 4);\n    assert!(shift < Limb::WIDTH >> 1);\n    let h1 = (n - 1) >> 1;\n    let h2 = n - h1;\n    let (out_lo, out_hi) = out.split_at_mut(h1);\n    let mut scratch = vec![0; (n << 1) + h1 + 4];\n    let scratch_hi = &mut scratch[n..]; // length is n + h1 + 4\n    if shift != 0 {\n        // o is used to exactly set the lowest bits of the dividend.\n        let o = usize::from(h1 > (1 + odd));\n        assert_eq!(\n            limbs_shl_to_out(\n                &mut scratch_hi[1 - o..],\n                &xs[h1 - 1 - o - odd..(n << 1) - odd],\n                shift << 1\n            ),\n            0\n        );\n    } else {\n        scratch_hi[1..n + h2 + 2].copy_from_slice(&xs[h1 - 1 - odd..(n << 1) - odd]);\n    }\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut(n + 1); // scratch_hi len is n + h1 + 3\n    let r_hi = limbs_sqrt_rem_helper(out_hi, &mut scratch_hi[h1 + 1..=n + h2], 0, scratch_lo);\n    if r_hi {\n        assert!(limbs_sub_same_length_in_place_left(\n            &mut scratch_hi[h1 + 1..=n],\n            out_hi\n        ));\n    }\n    // qs len is h1 + 2\n    let (scratch_hi_lo, qs) = scratch_hi.split_at_mut(n + 1);\n    limbs_sqrt_div_approx_helper(qs, scratch_hi_lo, out_hi, scratch_lo);\n    // qs_tail len is h1 + 1\n    let (qs_head, qs_tail) = qs.split_first_mut().unwrap();\n    let mut qs_last = Limb::from(r_hi);\n    qs_last += qs_tail[h1];\n    let mut nonzero_remainder = true;\n    if qs_last > 1 {\n        for x in out_lo {\n            *x = Limb::MAX;\n        }\n    } else {\n        limbs_shr_to_out(out_lo, &qs_tail[..h1], 1);\n        if qs_last != 0 {\n            out_lo.last_mut().unwrap().set_bit(Limb::WIDTH - 1);\n        }\n        let s = (Limb::WIDTH >> odd) - shift - 1;\n        if (*qs_head >> 3) | qs_tail[0].mod_power_of_2(Limb::WIDTH - s) == 0 {\n            // Approximation is not good enough, the extra limb(+ shift bits) is smaller than needed\n            // to absorb the possible error. {qs + 1, h1 + 1} equals 2*{out, h1}\n            let mut mul_scratch =\n                vec![0; limbs_mul_greater_to_out_scratch_len(out_hi.len(), qs_tail.len())];\n            assert_eq!(\n                limbs_mul_greater_to_out(scratch_lo, out_hi, qs_tail, &mut mul_scratch),\n                0\n            );\n            // scratch_hi_1 len is n + h1 + 2\n            let scratch_hi_1 = &mut scratch_hi[1..];\n            // scratch_lo_hi len is h1 + 1\n            let (scratch_lo_lo, scratch_lo_hi) = scratch_lo.split_at_mut(h2);\n            // scratch_hi_1_hi len is 2 * h1 + 2\n            let (scratch_hi_1_lo, scratch_hi_1_hi) = scratch_hi_1.split_at_mut(h2);\n            // Compute the remainder of the previous mpn_div(appr)_q.\n            if limbs_sub_same_length_in_place_left(scratch_hi_1_lo, scratch_lo_lo) {\n                assert!(!limbs_sub_limb_in_place(&mut scratch_hi_1_hi[..h1], 1));\n            }\n            let cmp = limbs_cmp_same_length(&scratch_hi_1_hi[..h1], &scratch_lo_hi[..h1]);\n            assert_ne!(cmp, Greater);\n            if cmp == Less {\n                // May happen only if div result was not exact.\n                let carry =\n                    limbs_slice_add_mul_limb_same_length_in_place_left(scratch_hi_1_lo, out_hi, 2);\n                assert!(!limbs_slice_add_limb_in_place(\n                    &mut scratch_hi_1_hi[..h1],\n                    carry\n                ));\n                assert!(!limbs_sub_limb_in_place(out_lo, 1));\n            }\n            // scratch_hi_1_hi len is 2 * h1 + 2\n            let (scratch_hi_1_lo, scratch_hi_1_hi) = scratch_hi_1.split_at_mut(h1);\n            if slice_test_zero(&scratch_hi_1_hi[..h2 - h1]) {\n                let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(out_lo.len())];\n                limbs_square_to_out(scratch_lo, out_lo, &mut square_scratch);\n                // scratch_lo_hi len is h2 + 1\n                let (scratch_lo_lo, scratch_lo_hi) = scratch_lo.split_at(h1);\n                let mut cmp = limbs_cmp_same_length(scratch_hi_1_lo, &scratch_lo_hi[..h1]);\n                if cmp == Equal {\n                    let scratch = &scratch_lo_lo[odd..];\n                    cmp = if shift != 0 {\n                        limbs_shl_to_out(scratch_hi, &xs[..h1], shift << 1);\n                        limbs_cmp_same_length(&scratch_hi[..h1 - odd], scratch)\n                    } else {\n                        limbs_cmp_same_length(&xs[..h1 - odd], scratch)\n                    };\n                }\n                if cmp == Less {\n                    assert!(!limbs_sub_limb_in_place(out_lo, 1));\n                }\n                nonzero_remainder = cmp != Equal;\n            }\n        }\n    }\n    if odd == 1 || shift != 0 {\n        let mut shift = shift;\n        if odd == 1 {\n            shift.set_bit(Limb::LOG_WIDTH - 1);\n        }\n        limbs_slice_shr_in_place(out, shift);\n    }\n    nonzero_remainder\n}}\n\n// Computes the floor of the square root of a `Natural`.\n//\n// - Let $n$ be `xs.len()` and $x$ be the `Natural` whose limbs are `xs`.\n// - Let $s$ be the `Natural` whose limbs are the first $\\lceil n/2 \\rceil$ limbs of `out`.\n// - Then $s = \\lfloor \\sqrt x \\rfloor$.\n//\n// All limbs are in ascending order (least-significant first).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_sqrtrem` from `mpn/generic/sqrtrem.c`, GMP 6.2.1, where `rp` is\n// `NULL`.\npub_test! {limbs_sqrt_to_out(out: &mut [Limb], xs: &[Limb]) {\n    let xs_len = xs.len();\n    let high = xs[xs_len - 1];\n    assert_ne!(high, 0);\n    let mut shift = LeadingZeros::leading_zeros(high) >> 1;\n    let two_shift = shift << 1;\n    match xs_len {\n        1 => {\n            out[0] = sqrt_rem_newton::<Limb, SignedLimb>(high << two_shift).0 >> shift;\n        }\n        2 => {\n            out[0] = if shift == 0 {\n                sqrt_rem_2_newton::<Limb, SignedLimb>(xs[1], xs[0]).0\n            } else {\n                let lo = xs[0];\n                sqrt_rem_2_newton::<Limb, SignedLimb>(\n                    (high << two_shift) | (lo >> (Limb::WIDTH - two_shift)),\n                    lo << two_shift,\n                )\n                .0 >> shift\n            };\n        }\n        _ if xs_len > 8 => {\n            let out_len = xs_len.shr_round(1, Ceiling).0;\n            limbs_sqrt_helper(&mut out[..out_len], xs, shift, xs_len.odd());\n        }\n        _ => {\n            let out_len = xs_len.shr_round(1, Ceiling).0;\n            let out = &mut out[..out_len];\n            if xs_len.odd() || shift != 0 {\n                let scratch_1_len = out_len << 1;\n                let mut scratch = vec![0; scratch_1_len + (out_len >> 1) + 1];\n                let (scratch_1, scratch_2) = scratch.split_at_mut(scratch_1_len);\n                // needed only when 2 * out_len > xs_len, but saves a test\n                let shifted_scratch_1 = if xs_len.odd() {\n                    &mut scratch_1[1..]\n                } else {\n                    scratch_1[0] = 0;\n                    &mut *scratch_1\n                };\n                if shift == 0 {\n                    shifted_scratch_1.copy_from_slice(xs);\n                } else {\n                    limbs_shl_to_out(shifted_scratch_1, xs, two_shift);\n                }\n                if xs_len.odd() {\n                    shift += Limb::WIDTH >> 1;\n                }\n                limbs_sqrt_rem_helper(out, scratch_1, Limb::low_mask(shift) - 1, scratch_2);\n                limbs_slice_shr_in_place(out, shift);\n            } else {\n                let mut rem = xs.to_vec();\n                let mut scratch = vec![0; (out_len >> 1) + 1];\n                limbs_sqrt_rem_helper(out, &mut rem, 0, &mut scratch);\n            }\n        }\n    }\n}}\n\n// Computes the square root and remainder of a `Natural`.\n//\n// Let $n$ be `xs.len()` and $x$ be the `Natural` whose limbs are `xs`. Let $s$ be the `Natural`\n// whose limbs are the first $\\lceil n/2 \\rceil$ limbs of `out_sqrt`, $m$ the return value, and $r$\n// be the `Natural` whose limbs are the first $m$ limbs of `out_rem`. Then $s = \\lfloor \\sqrt x\n// \\rfloor$ and $s^2 + r = x$. This implies that $r \\leq 2x$.\n//\n// All limbs are in ascending order (least-significant first).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_sqrtrem` from `mpn/generic/sqrtrem.c`, GMP 6.2.1, where `rp` is not\n// `NULL`.\npub_test! {limbs_sqrt_rem_to_out(\n    out_sqrt: &mut [Limb],\n    out_rem: &mut [Limb],\n    xs: &[Limb]\n) -> usize {\n    let xs_len = xs.len();\n    let high = xs[xs_len - 1];\n    assert_ne!(high, 0);\n    let mut shift = LeadingZeros::leading_zeros(high) >> 1;\n    let two_shift = shift << 1;\n    match xs_len {\n        1 => {\n            let r_lo = if shift == 0 {\n                let r;\n                (out_sqrt[0], r) = sqrt_rem_newton::<Limb, SignedLimb>(high);\n                r\n            } else {\n                let sqrt = sqrt_rem_newton::<Limb, SignedLimb>(high << two_shift).0 >> shift;\n                out_sqrt[0] = sqrt;\n                high - sqrt.square()\n            };\n            out_rem[0] = r_lo;\n            usize::from(r_lo != 0)\n        }\n        2 => {\n            if shift == 0 {\n                let r_hi;\n                (out_sqrt[0], r_hi, out_rem[0]) =\n                    sqrt_rem_2_newton::<Limb, SignedLimb>(xs[1], xs[0]);\n                if r_hi {\n                    out_rem[1] = 1;\n                    2\n                } else {\n                    usize::from(out_rem[0] != 0)\n                }\n            } else {\n                let mut lo = xs[0];\n                let hi = (high << two_shift) | (lo >> (Limb::WIDTH - two_shift));\n                out_sqrt[0] = sqrt_rem_2_newton::<Limb, SignedLimb>(hi, lo << two_shift).0 >> shift;\n                lo.wrapping_sub_assign(out_sqrt[0].wrapping_square());\n                out_rem[0] = lo;\n                usize::from(lo != 0)\n            }\n        }\n        _ => {\n            let mut out_len = xs_len.shr_round(1, Ceiling).0;\n            let out_sqrt = &mut out_sqrt[..out_len];\n            if xs_len.odd() || shift != 0 {\n                let scratch_1_len = out_len << 1;\n                let mut scratch = vec![0; scratch_1_len + (out_len >> 1) + 1];\n                let (mut scratch_1, scratch_2) = scratch.split_at_mut(scratch_1_len);\n                // needed only when 2 * out_len > xs_len, but saves a test\n                let shifted_scratch_1 = if xs_len.odd() {\n                    &mut scratch_1[1..]\n                } else {\n                    scratch_1[0] = 0;\n                    &mut *scratch_1\n                };\n                if shift == 0 {\n                    shifted_scratch_1.copy_from_slice(xs);\n                } else {\n                    limbs_shl_to_out(shifted_scratch_1, xs, two_shift);\n                }\n                if xs_len.odd() {\n                    shift += Limb::WIDTH >> 1;\n                }\n                let r_hi = limbs_sqrt_rem_helper(out_sqrt, scratch_1, 0, scratch_2);\n                let s = out_sqrt[0] & Limb::low_mask(shift);\n                let scratch_1_lo = &mut scratch_1[..out_len];\n                let mut r_lo = limbs_slice_add_mul_limb_same_length_in_place_left(\n                    scratch_1_lo,\n                    out_sqrt,\n                    s << 1,\n                );\n                if r_hi {\n                    r_lo += 1;\n                }\n                let (scratch_1_lo_lo, scratch_1_lo_hi) = scratch_1_lo.split_at_mut(1);\n                let carry = limbs_sub_mul_limb_same_length_in_place_left(scratch_1_lo_lo, &[s], s);\n                if limbs_sub_limb_in_place(scratch_1_lo_hi, carry) {\n                    r_lo -= 1;\n                }\n                limbs_slice_shr_in_place(out_sqrt, shift);\n                scratch_1[out_len] = r_lo;\n                shift <<= 1;\n                if shift < Limb::WIDTH {\n                    out_len += 1;\n                } else {\n                    scratch_1 = &mut scratch_1[1..];\n                    shift -= Limb::WIDTH;\n                }\n                let scratch_1 = &mut scratch_1[..out_len];\n                if shift == 0 {\n                    out_rem[..out_len].copy_from_slice(scratch_1);\n                } else {\n                    limbs_shr_to_out(out_rem, scratch_1, shift);\n                }\n            } else {\n                out_rem[..xs_len].copy_from_slice(xs);\n                let mut scratch = vec![0; (out_len >> 1) + 1];\n                if limbs_sqrt_rem_helper(out_sqrt, out_rem, 0, &mut scratch) {\n                    out_rem[out_len] = 1;\n                    out_len += 1;\n                }\n            }\n            out_len\n        }\n    }\n}}\n\n// This is equivalent to `mpn_sqrtrem` from `mpn/generic/sqrtrem.c`, GMP 6.2.1, where `rp` is not\n// `NULL`, only returning whether the remainder is nonzero, rather than computing it in full.\npub(crate) fn limbs_sqrt_to_out_return_inexact(out_sqrt: &mut [Limb], xs: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let high = xs[xs_len - 1];\n    assert_ne!(high, 0);\n    let mut shift = LeadingZeros::leading_zeros(high) >> 1;\n    let two_shift = shift << 1;\n    match xs_len {\n        1 => {\n            let r_lo = if shift == 0 {\n                let r;\n                (out_sqrt[0], r) = sqrt_rem_newton::<Limb, SignedLimb>(high);\n                r\n            } else {\n                let sqrt = sqrt_rem_newton::<Limb, SignedLimb>(high << two_shift).0 >> shift;\n                out_sqrt[0] = sqrt;\n                high - sqrt.square()\n            };\n            r_lo != 0\n        }\n        2 => {\n            if shift == 0 {\n                let r_hi;\n                let r_0;\n                (out_sqrt[0], r_hi, r_0) = sqrt_rem_2_newton::<Limb, SignedLimb>(xs[1], xs[0]);\n                r_hi || r_0 != 0\n            } else {\n                let mut lo = xs[0];\n                let hi = (high << two_shift) | (lo >> (Limb::WIDTH - two_shift));\n                out_sqrt[0] = sqrt_rem_2_newton::<Limb, SignedLimb>(hi, lo << two_shift).0 >> shift;\n                lo.wrapping_sub_assign(out_sqrt[0].wrapping_square());\n                lo != 0\n            }\n        }\n        _ => {\n            let mut out_len = xs_len.shr_round(1, Ceiling).0;\n            let out_sqrt = &mut out_sqrt[..out_len];\n            let mut out_rem;\n            let mut scratch;\n            let out = if xs_len.odd() || shift != 0 {\n                let scratch_1_len = out_len << 1;\n                scratch = vec![0; scratch_1_len + (out_len >> 1) + 1];\n                let (mut scratch_1, scratch_2) = scratch.split_at_mut(scratch_1_len);\n                // needed only when 2 * out_len > xs_len, but saves a test\n                let shifted_scratch_1 = if xs_len.odd() {\n                    &mut scratch_1[1..]\n                } else {\n                    scratch_1[0] = 0;\n                    &mut *scratch_1\n                };\n                if shift == 0 {\n                    shifted_scratch_1.copy_from_slice(xs);\n                } else {\n                    limbs_shl_to_out(shifted_scratch_1, xs, two_shift);\n                }\n                if xs_len.odd() {\n                    shift += Limb::WIDTH >> 1;\n                }\n                let r_hi = limbs_sqrt_rem_helper(out_sqrt, scratch_1, 0, scratch_2);\n                let s = out_sqrt[0] & Limb::low_mask(shift);\n                let scratch_1_lo = &mut scratch_1[..out_len];\n                let mut r_lo = limbs_slice_add_mul_limb_same_length_in_place_left(\n                    scratch_1_lo,\n                    out_sqrt,\n                    s << 1,\n                );\n                if r_hi {\n                    r_lo += 1;\n                }\n                let (scratch_1_lo_lo, scratch_1_lo_hi) = scratch_1_lo.split_at_mut(1);\n                let carry = limbs_sub_mul_limb_same_length_in_place_left(scratch_1_lo_lo, &[s], s);\n                if limbs_sub_limb_in_place(scratch_1_lo_hi, carry) {\n                    r_lo -= 1;\n                }\n                limbs_slice_shr_in_place(out_sqrt, shift);\n                scratch_1[out_len] = r_lo;\n                shift <<= 1;\n                if shift < Limb::WIDTH {\n                    out_len += 1;\n                } else {\n                    scratch_1 = &mut scratch_1[1..];\n                }\n                scratch_1\n            } else {\n                let mut scratch = vec![0; (out_len >> 1) + 1];\n                out_rem = xs.to_vec();\n                if limbs_sqrt_rem_helper(out_sqrt, &mut out_rem, 0, &mut scratch) {\n                    out_rem[out_len] = 1;\n                    out_len += 1;\n                }\n                &out_rem[..]\n            };\n            out[..out_len].iter().any(|&x| x != 0)\n        }\n    }\n}\n\n// Computes the floor of the square root of a `Natural`.\n//\n// Let $x$ be the `Natural` whose limbs are `xs` and $s$ be the `Natural` whose limbs are returned.\n// Then $s = \\lfloor \\sqrt x \\rfloor$.\n//\n// All limbs are in ascending order (least-significant first).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_floor_sqrt(xs: &[Limb]) -> Vec<Limb> {\n    let mut out = vec![0; xs.len().shr_round(1, Ceiling).0];\n    limbs_sqrt_to_out(&mut out, xs);\n    out\n}}\n\n// Computes the ceiling of the square root of a `Natural`.\n//\n// Let $x$ be the `Natural` whose limbs are `xs` and $s$ be the `Natural` whose limbs are returned.\n// Then $s = \\lceil \\sqrt x \\rceil$.\n//\n// All limbs are in ascending order (least-significant first).\n//\n// # Worst-case complexity\n// TODO\npub_test! {limbs_ceiling_sqrt(xs: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let mut out_sqrt = vec![0; xs_len.shr_round(1, Ceiling).0];\n    let mut out_rem = vec![0; xs_len];\n    let rem_len = limbs_sqrt_rem_to_out(&mut out_sqrt, &mut out_rem, xs);\n    if !slice_test_zero(&out_rem[..rem_len]) {\n        limbs_vec_add_limb_in_place(&mut out_sqrt, 1);\n    }\n    out_sqrt\n}}\n\n// Computes the square root of a `Natural`, returning `None` if the `Natural` is not a perfect\n// square.\n//\n// Let $x$ be the `Natural` whose limbs are `xs` and $s$ be the `Natural` whose limbs are returned.\n//\n// $$\n// s = \\\\begin{cases}\n//     \\operatorname{Some}(\\sqrt{x}) & \\sqrt{x} \\in \\Z \\\\\\\\\n//     \\operatorname{None} & \\textrm{otherwise}.\n// \\\\end{cases}\n// $$\n//\n// All limbs are in ascending order (least-significant first).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_crate_test! {limbs_checked_sqrt(xs: &[Limb]) -> Option<Vec<Limb>> {\n    let xs_len = xs.len();\n    let mut out_sqrt = vec![0; xs_len.shr_round(1, Ceiling).0];\n    if limbs_sqrt_to_out_return_inexact(&mut out_sqrt, xs) {\n        None\n    } else {\n        Some(out_sqrt)\n    }\n}}\n\n// Computes the square root and remainder of a `Natural`.\n//\n// Let `out_sqrt` and `out_rem` be the two returned `Limb` `Vec`s. Let $n$ be `xs.len()` and $x$ be\n// the `Natural` whose limbs are `xs`. Let $s$ be the `Natural` whose limbs are the first $\\lceil\n// n/2 \\rceil$ limbs of `out_sqrt` and $r$ be the `Natural` whose limbs are the first $n$ limbs of\n// `out_rem`.  Then $s = \\lfloor \\sqrt x \\rfloor$ and $s^2 + r = x$. This implies that $r \\leq 2x$.\n//\n// All limbs are in ascending order (least-significant first).\n//\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {limbs_sqrt_rem(xs: &[Limb]) -> (Vec<Limb>, Vec<Limb>) {\n    let xs_len = xs.len();\n    let mut out_sqrt = vec![0; xs_len.shr_round(1, Ceiling).0];\n    let mut out_rem = vec![0; xs_len];\n    let rem_len = limbs_sqrt_rem_to_out(&mut out_sqrt, &mut out_rem, xs);\n    out_rem.truncate(rem_len);\n    (out_sqrt, out_rem)\n}}\n\nimpl FloorSqrt for Natural {\n    type Output = Self;\n\n    /// Returns the floor of the square root of a [`Natural`], taking it by value.\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorSqrt;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(99u8).floor_sqrt(), 9);\n    /// assert_eq!(Natural::from(100u8).floor_sqrt(), 10);\n    /// assert_eq!(Natural::from(101u8).floor_sqrt(), 10);\n    /// assert_eq!(Natural::from(1000000000u32).floor_sqrt(), 31622);\n    /// assert_eq!(Natural::from(10000000000u64).floor_sqrt(), 100000);\n    /// ```\n    #[inline]\n    fn floor_sqrt(self) -> Self {\n        (&self).floor_sqrt()\n    }\n}\n\nimpl FloorSqrt for &Natural {\n    type Output = Natural;\n\n    /// Returns the floor of the square root of a [`Natural`], taking it by value.\n    ///\n    /// $f(x) = \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorSqrt;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::from(99u8)).floor_sqrt(), 9);\n    /// assert_eq!((&Natural::from(100u8)).floor_sqrt(), 10);\n    /// assert_eq!((&Natural::from(101u8)).floor_sqrt(), 10);\n    /// assert_eq!((&Natural::from(1000000000u32)).floor_sqrt(), 31622);\n    /// assert_eq!((&Natural::from(10000000000u64)).floor_sqrt(), 100000);\n    /// ```\n    fn floor_sqrt(self) -> Natural {\n        match self {\n            Natural(Small(small)) => Natural::from(small.floor_sqrt()),\n            Natural(Large(limbs)) => Natural::from_owned_limbs_asc(limbs_floor_sqrt(limbs)),\n        }\n    }\n}\n\nimpl FloorSqrtAssign for Natural {\n    /// Replaces a [`Natural`] with the floor of its square root.\n    ///\n    /// $x \\gets \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorSqrtAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(99u8);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Natural::from(100u8);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(101u8);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(1000000000u32);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 31622);\n    ///\n    /// let mut x = Natural::from(10000000000u64);\n    /// x.floor_sqrt_assign();\n    /// assert_eq!(x, 100000);\n    /// ```\n    #[inline]\n    fn floor_sqrt_assign(&mut self) {\n        *self = (&*self).floor_sqrt();\n    }\n}\n\nimpl CeilingSqrt for Natural {\n    type Output = Self;\n\n    /// Returns the ceiling of the square root of a [`Natural`], taking it by value.\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingSqrt;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(99u8).ceiling_sqrt(), 10);\n    /// assert_eq!(Natural::from(100u8).ceiling_sqrt(), 10);\n    /// assert_eq!(Natural::from(101u8).ceiling_sqrt(), 11);\n    /// assert_eq!(Natural::from(1000000000u32).ceiling_sqrt(), 31623);\n    /// assert_eq!(Natural::from(10000000000u64).ceiling_sqrt(), 100000);\n    /// ```\n    #[inline]\n    fn ceiling_sqrt(self) -> Self {\n        (&self).ceiling_sqrt()\n    }\n}\n\nimpl CeilingSqrt for &Natural {\n    type Output = Natural;\n\n    /// Returns the ceiling of the square root of a [`Natural`], taking it by value.\n    ///\n    /// $f(x) = \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingSqrt;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(99u8).ceiling_sqrt(), 10);\n    /// assert_eq!(Natural::from(100u8).ceiling_sqrt(), 10);\n    /// assert_eq!(Natural::from(101u8).ceiling_sqrt(), 11);\n    /// assert_eq!(Natural::from(1000000000u32).ceiling_sqrt(), 31623);\n    /// assert_eq!(Natural::from(10000000000u64).ceiling_sqrt(), 100000);\n    /// ```\n    fn ceiling_sqrt(self) -> Natural {\n        match self {\n            Natural(Small(small)) => Natural::from(small.ceiling_sqrt()),\n            Natural(Large(limbs)) => Natural::from_owned_limbs_asc(limbs_ceiling_sqrt(limbs)),\n        }\n    }\n}\n\nimpl CeilingSqrtAssign for Natural {\n    /// Replaces a [`Natural`] with the ceiling of its square root.\n    ///\n    /// $x \\gets \\lceil\\sqrt{x}\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingSqrtAssign;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(99u8);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(100u8);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(101u8);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 11);\n    ///\n    /// let mut x = Natural::from(1000000000u32);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 31623);\n    ///\n    /// let mut x = Natural::from(10000000000u64);\n    /// x.ceiling_sqrt_assign();\n    /// assert_eq!(x, 100000);\n    /// ```\n    #[inline]\n    fn ceiling_sqrt_assign(&mut self) {\n        *self = (&*self).ceiling_sqrt();\n    }\n}\n\nimpl CheckedSqrt for Natural {\n    type Output = Self;\n\n    /// Returns the the square root of a [`Natural`], or `None` if it is not a perfect square. The\n    /// [`Natural`] is taken by value.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedSqrt;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(99u8).checked_sqrt().to_debug_string(), \"None\");\n    /// assert_eq!(\n    ///     Natural::from(100u8).checked_sqrt().to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(101u8).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(1000000000u32)\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10000000000u64)\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"Some(100000)\"\n    /// );\n    /// ```\n    #[inline]\n    fn checked_sqrt(self) -> Option<Self> {\n        (&self).checked_sqrt()\n    }\n}\n\nimpl CheckedSqrt for &Natural {\n    type Output = Natural;\n\n    /// Returns the the square root of a [`Natural`], or `None` if it is not a perfect square. The\n    /// [`Natural`] is taken by value.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedSqrt;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(99u8)).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(100u8)).checked_sqrt().to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(101u8)).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(1000000000u32))\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10000000000u64))\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"Some(100000)\"\n    /// );\n    /// ```\n    fn checked_sqrt(self) -> Option<Natural> {\n        match self {\n            Natural(Small(small)) => small.checked_sqrt().map(Natural::from),\n            Natural(Large(limbs)) => limbs_checked_sqrt(limbs).map(Natural::from_owned_limbs_asc),\n        }\n    }\n}\n\nimpl SqrtRem for Natural {\n    type SqrtOutput = Self;\n    type RemOutput = Self;\n\n    /// Returns the floor of the square root of a [`Natural`] and the remainder (the difference\n    /// between the [`Natural`] and the square of the floor). The [`Natural`] is taken by value.\n    ///\n    /// $f(x) = (\\lfloor\\sqrt{x}\\rfloor, x - \\lfloor\\sqrt{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SqrtRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(99u8).sqrt_rem().to_debug_string(), \"(9, 18)\");\n    /// assert_eq!(Natural::from(100u8).sqrt_rem().to_debug_string(), \"(10, 0)\");\n    /// assert_eq!(Natural::from(101u8).sqrt_rem().to_debug_string(), \"(10, 1)\");\n    /// assert_eq!(\n    ///     Natural::from(1000000000u32).sqrt_rem().to_debug_string(),\n    ///     \"(31622, 49116)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10000000000u64).sqrt_rem().to_debug_string(),\n    ///     \"(100000, 0)\"\n    /// );\n    /// ```\n    #[inline]\n    fn sqrt_rem(self) -> (Self, Self) {\n        (&self).sqrt_rem()\n    }\n}\n\nimpl SqrtRem for &Natural {\n    type SqrtOutput = Natural;\n    type RemOutput = Natural;\n\n    /// Returns the floor of the square root of a [`Natural`] and the remainder (the difference\n    /// between the [`Natural`] and the square of the floor). The [`Natural`] is taken by reference.\n    ///\n    /// $f(x) = (\\lfloor\\sqrt{x}\\rfloor, x - \\lfloor\\sqrt{x}\\rfloor^2)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SqrtRem;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(99u8)).sqrt_rem().to_debug_string(),\n    ///     \"(9, 18)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(100u8)).sqrt_rem().to_debug_string(),\n    ///     \"(10, 0)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(101u8)).sqrt_rem().to_debug_string(),\n    ///     \"(10, 1)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(1000000000u32)).sqrt_rem().to_debug_string(),\n    ///     \"(31622, 49116)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10000000000u64))\n    ///         .sqrt_rem()\n    ///         .to_debug_string(),\n    ///     \"(100000, 0)\"\n    /// );\n    /// ```\n    fn sqrt_rem(self) -> (Natural, Natural) {\n        match self {\n            Natural(Small(small)) => {\n                let (sqrt, rem) = small.sqrt_rem();\n                (Natural::from(sqrt), Natural::from(rem))\n            }\n            Natural(Large(limbs)) => {\n                let (sqrt_limbs, rem_limbs) = limbs_sqrt_rem(limbs);\n                (\n                    Natural::from_owned_limbs_asc(sqrt_limbs),\n                    Natural::from_owned_limbs_asc(rem_limbs),\n                )\n            }\n        }\n    }\n}\n\nimpl SqrtAssignRem for Natural {\n    type RemOutput = Self;\n\n    /// Replaces a [`Natural`] with the floor of its square root and returns the remainder (the\n    /// difference between the original [`Natural`] and the square of the floor).\n    ///\n    /// $f(x) = x - \\lfloor\\sqrt{x}\\rfloor^2$,\n    ///\n    /// $x \\gets \\lfloor\\sqrt{x}\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SqrtAssignRem;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(99u8);\n    /// assert_eq!(x.sqrt_assign_rem(), 18);\n    /// assert_eq!(x, 9);\n    ///\n    /// let mut x = Natural::from(100u8);\n    /// assert_eq!(x.sqrt_assign_rem(), 0);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(101u8);\n    /// assert_eq!(x.sqrt_assign_rem(), 1);\n    /// assert_eq!(x, 10);\n    ///\n    /// let mut x = Natural::from(1000000000u32);\n    /// assert_eq!(x.sqrt_assign_rem(), 49116);\n    /// assert_eq!(x, 31622);\n    ///\n    /// let mut x = Natural::from(10000000000u64);\n    /// assert_eq!(x.sqrt_assign_rem(), 0);\n    /// assert_eq!(x, 100000);\n    /// ```\n    #[inline]\n    fn sqrt_assign_rem(&mut self) -> Self {\n        let rem;\n        (*self, rem) = (&*self).sqrt_rem();\n        rem\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `MAYBE_sqr_toom2`, `TOOM2_SQR_REC`, and `mpn_toom2_sqr` contributed to the GNU project by\n//      Torbjörn Granlund.\n//\n//      `SQR_TOOM6_MAX`, `MAYBE_sqr_basecase`, `MAYBE_sqr_toom2`, `MAYBE_sqr_above_toom2`,\n//      `MAYBE_sqr_toom3`, `MAYBE_sqr_above_toom3`, `MAYBE_sqr_above_toom4`, `TOOM6_SQR_REC`,\n//      `mpn_toom6_sqr`, `SQR_TOOM8_MAX`, `MAYBE_sqr_basecase`, `MAYBE_sqr_above_basecase`,\n//      `MAYBE_sqr_toom2`, `MAYBE_sqr_above_toom2`, `MAYBE_sqr_toom3`, `MAYBE_sqr_above_toom3`,\n//      `MAYBE_sqr_toom4`, `MAYBE_sqr_above_toom4`, `MAYBE_sqr_above_toom6`, `TOOM8_SQR_REC`, and\n//      `mpn_toom8_sqr` contributed to the GNU project by Marco Bodrato.\n//\n//      `MAYBE_sqr_toom3`, `MAYBE_sqr_basecase`, `TOOM3_SQR_REC`, and `mpn_toom3_sqr` contributed to\n//      the GNU project by Torbjörn Granlund, with additional improvements by Marco Bodrato.\n//\n//      `MAYBE_sqr_toom2`, `MAYBE_sqr_toom4`, `TOOM4_SQR_REC`, and `mpn_toom4_sqr` contributed to\n//      the GNU project by Torbjörn Granlund and Marco Bodrato.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{\n    limbs_add_limb_to_out, limbs_add_same_length_to_out, limbs_add_to_out,\n    limbs_slice_add_greater_in_place_left, limbs_slice_add_limb_in_place,\n    limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::mul::fft::mpn_square_default_mpn_ctx;\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::mul::limbs_mul_greater_to_out_basecase;\nuse crate::natural::arithmetic::mul::poly_eval::{\n    limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1,\n    limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2, limbs_mul_toom_evaluate_poly_in_1_and_neg_1,\n    limbs_mul_toom_evaluate_poly_in_2_and_neg_2,\n    limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow,\n    limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg,\n};\nuse crate::natural::arithmetic::mul::poly_interpolate::{\n    limbs_mul_toom_interpolate_5_points, limbs_mul_toom_interpolate_7_points,\n    limbs_mul_toom_interpolate_12_points, limbs_mul_toom_interpolate_16_points,\n};\nuse crate::natural::arithmetic::mul::toom::{\n    BIT_CORRECTION, TUNE_PROGRAM_BUILD, WANT_FAT_BINARY, limbs_toom_couple_handling,\n};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::natural::arithmetic::sub::{\n    limbs_sub_limb_in_place, limbs_sub_same_length_in_place_left, limbs_sub_same_length_to_out,\n};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::{\n    DoubleLimb, Limb, SQR_BASECASE_THRESHOLD, SQR_TOOM2_THRESHOLD, SQR_TOOM3_THRESHOLD,\n    SQR_TOOM4_THRESHOLD, SQR_TOOM6_THRESHOLD, SQR_TOOM8_THRESHOLD,\n};\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, max};\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, DivRound, ShrRound, Square, SquareAssign, WrappingAddAssign,\n    WrappingSubAssign, XMulYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{SplitInHalf, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nconst SQR_FFT_MODF_THRESHOLD: usize = SQR_TOOM3_THRESHOLD * 3;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `MPN_SQR_DIAGONAL` from `mpn/generic/sqr_basecase.c`, GMP 6.2.1.\n#[inline]\npub(crate) fn limbs_square_diagonal(out: &mut [Limb], xs: &[Limb]) {\n    for (i, &x) in xs.iter().enumerate() {\n        let i_2 = i << 1;\n        (out[i_2 | 1], out[i_2]) = DoubleLimb::from(x).square().split_in_half();\n    }\n}\n\n// scratch must have length 2 * xs.len() - 2 and out must have length 2 * xs.len().\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `MPN_SQR_DIAG_ADDLSH1` from `mpn/generic/sqr_basecase.c`, GMP 6.2.1.\npub_test! {limbs_square_diagonal_add_shl_1(out: &mut [Limb], scratch: &mut [Limb], xs: &[Limb]) {\n    limbs_square_diagonal(out, xs);\n    let (out_last, out_init) = out.split_last_mut().unwrap();\n    *out_last += limbs_slice_shl_in_place(scratch, 1);\n    if limbs_slice_add_same_length_in_place_left(&mut out_init[1..], scratch) {\n        *out_last += 1;\n    }\n}}\n\n// Interpreting a slices of `Limb`s as the limbs (in ascending order) of a `Natural`s, writes the `2\n// * xs.len()` least-significant limbs of the square of the `Natural`s to an output slice. The\n// output must be at least twice as long as `xs.len()`, `xs.len()` must be less than\n// `SQR_TOOM2_THRESHOLD`, and `xs` cannot be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is less than twice the length of `xs`, `xs.len()` > SQR_TOOM2_THRESHOLD, or if\n// `xs` is empty.\n//\n// This is equivalent to `mpn_sqr_basecase` from `mpn/generic/sqr_basecase.c`, GMP 6.2.1.\npub_crate_test! {limbs_square_to_out_basecase(out: &mut [Limb], xs: &[Limb]) {\n    let n = xs.len();\n    let (xs_head, xs_tail) = xs.split_first().unwrap();\n    (out[1], out[0]) = DoubleLimb::from(*xs_head).square().split_in_half();\n    if n > 1 {\n        assert!(n <= SQR_TOOM2_THRESHOLD);\n        let scratch = &mut [0; SQR_TOOM2_THRESHOLD << 1];\n        let two_n = n << 1;\n        let scratch = &mut scratch[..two_n - 2];\n        let (scratch_last, scratch_init) = scratch[..n].split_last_mut().unwrap();\n        *scratch_last = limbs_mul_limb_to_out::<DoubleLimb, Limb>(scratch_init, xs_tail, *xs_head);\n        for i in 1..n - 1 {\n            let (scratch_last, scratch_init) = scratch[i..][i..n].split_last_mut().unwrap();\n            let (xs_head, xs_tail) = xs[i..].split_first().unwrap();\n            *scratch_last =\n                limbs_slice_add_mul_limb_same_length_in_place_left(scratch_init, xs_tail, *xs_head);\n        }\n        limbs_square_diagonal_add_shl_1(&mut out[..two_n], scratch, xs);\n    }\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom2_sqr_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_const_test! {limbs_square_to_out_toom_2_scratch_len(xs_len: usize) -> usize {\n    (xs_len + Limb::WIDTH as usize) << 1\n}}\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_toom2` from `mpn/generic/toom2_sqr.c`, GMP 6.2.1.\nconst TOOM2_MAYBE_SQR_TOOM2: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || SQR_TOOM3_THRESHOLD >= 2 * SQR_TOOM2_THRESHOLD;\n\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_2 3}) \\approx O(n^{1.585})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM2_SQR_REC` from `mpn/generic/toom2_sqr.c`, GMP 6.2.1.\nfn limbs_square_to_out_toom_2_recursive(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    if !TOOM2_MAYBE_SQR_TOOM2 || xs.len() < SQR_TOOM2_THRESHOLD {\n        limbs_square_to_out_basecase(out, xs);\n    } else {\n        limbs_square_to_out_toom_2(out, xs, scratch);\n    }\n}\n\n// Interpreting a slices of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the `2\n// * xs.len()` least-significant limbs of the square of the `Natural` to an output slice. A scratch\n// slice is provided for the algorithm to use. An upper bound for the number of scratch limbs needed\n// is provided by `limbs_square_to_out_toom_2_scratch_len`. The following restrictions on the input\n// slices must be met:\n// - `out`.len() >= 2 * `xs`.len()\n// - `xs`.len() > 1\n//\n// The smallest allowable `xs` length is 2.\n//\n// Evaluate in: -1, 0, infinity.\n// ```\n// <-s--><--n-->\n//  ____ ______\n// |xs1_|__xs0_|\n//\n// v_0     = xs_0 ^ 2          # X(0) ^ 2\n// v_neg_1 = (xs_0 - xs_1) ^ 2 # X(-1) ^ 2\n// v_inf   = xs_1 ^ 2          # X(inf) ^ 2\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_2 3}) \\approx O(n^{1.585})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom2_sqr` from `mpn/generic/toom2_sqr.c`, GMP 6.2.1.\npub_test! {limbs_square_to_out_toom_2(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let xs_len = xs.len();\n    assert!(xs_len > 1);\n    let out = &mut out[..xs_len << 1];\n    let s = xs_len >> 1;\n    let n = xs_len - s;\n    let (xs_0, xs_1) = xs.split_at(n);\n    if s == n {\n        if limbs_cmp_same_length(xs_0, xs_1) == Less {\n            limbs_sub_same_length_to_out(out, xs_1, xs_0);\n        } else {\n            limbs_sub_same_length_to_out(out, xs_0, xs_1);\n        }\n    } else {\n        // n - s == 1\n        let (xs_0_last, xs_0_init) = xs_0.split_last().unwrap();\n        let (out_last, out_init) = out[..n].split_last_mut().unwrap();\n        if *xs_0_last == 0 && limbs_cmp_same_length(xs_0_init, xs_1) == Less {\n            limbs_sub_same_length_to_out(out_init, xs_1, xs_0_init);\n            *out_last = 0;\n        } else {\n            *out_last = *xs_0_last;\n            if limbs_sub_same_length_to_out(out_init, xs_0_init, xs_1) {\n                out_last.wrapping_sub_assign(1);\n            }\n        }\n    }\n    let (v_0, v_inf) = out.split_at_mut(n << 1);\n    let (v_neg_1, scratch_out) = scratch.split_at_mut(n << 1);\n    limbs_square_to_out_toom_2_recursive(v_neg_1, &v_0[..n], scratch_out);\n    limbs_square_to_out_toom_2_recursive(v_inf, xs_1, scratch_out);\n    limbs_square_to_out_toom_2_recursive(v_0, xs_0, scratch_out);\n    let (v_0_lo, v_0_hi) = v_0.split_at_mut(n);\n    let (v_inf_lo, v_inf_hi) = v_inf.split_at_mut(n);\n    let mut carry = Limb::from(limbs_slice_add_same_length_in_place_left(v_inf_lo, v_0_hi));\n    let mut carry2 = carry;\n    if limbs_add_same_length_to_out(v_0_hi, v_inf_lo, v_0_lo) {\n        carry2 += 1;\n    }\n    if limbs_slice_add_greater_in_place_left(v_inf_lo, &v_inf_hi[..s + s - n]) {\n        carry += 1;\n    }\n    if limbs_sub_same_length_in_place_left(&mut out[n..3 * n], v_neg_1) {\n        carry.wrapping_sub_assign(1);\n    }\n    assert!(carry.wrapping_add(1) <= 3);\n    assert!(carry2 <= 2);\n    let carry3 = limbs_slice_add_limb_in_place(&mut out[n << 1..], carry2);\n    let out_hi = &mut out[3 * n..];\n    if carry <= 2 {\n        assert!(!limbs_slice_add_limb_in_place(out_hi, carry));\n    } else if limbs_sub_limb_in_place(out_hi, 1) {\n        assert!(carry3);\n    }\n}}\n\n// This function can be used to determine whether the size of the input slice to\n// `limbs_square_to_out_toom_3` is valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_square_to_out_toom_3_input_size_valid(xs_len: usize) -> bool {\n    xs_len == 3 || xs_len > 4\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom3_sqr_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_const_test! {limbs_square_to_out_toom_3_scratch_len(xs_len: usize) -> usize {\n    3 * xs_len + Limb::WIDTH as usize\n}}\n\n// TODO tune\n\nconst SMALLER_RECURSION_TOOM_3: bool = true;\n\n// TODO tune\n\n// This is equivalent to `MAYBE_sqr_toom3` from `mpn/generic/toom3_sqr.c`, GMP 6.2.1.\n#[cfg(feature = \"test_build\")]\npub const TOOM3_MAYBE_SQR_TOOM3: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || SQR_TOOM4_THRESHOLD >= 3 * SQR_TOOM3_THRESHOLD;\n#[cfg(not(feature = \"test_build\"))]\nconst TOOM3_MAYBE_SQR_TOOM3: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || SQR_TOOM4_THRESHOLD >= 3 * SQR_TOOM3_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_basecase` from `mpn/generic/toom3_sqr.c`, GMP 6.2.1.\n#[cfg(feature = \"test_build\")]\npub const TOOM3_MAYBE_SQR_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || SQR_TOOM3_THRESHOLD < 3 * SQR_TOOM2_THRESHOLD;\n#[cfg(not(feature = \"test_build\"))]\nconst TOOM3_MAYBE_SQR_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || WANT_FAT_BINARY || SQR_TOOM3_THRESHOLD < 3 * SQR_TOOM2_THRESHOLD;\n\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_3 5}) \\approx O(n^{1.465})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM3_SQR_REC` from `mpn/generic/toom3_sqr.c`, GMP 6.2.1.\nfn limbs_square_to_out_toom_3_recursive(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let n = xs.len();\n    if TOOM3_MAYBE_SQR_BASECASE && n < SQR_TOOM2_THRESHOLD {\n        limbs_square_to_out_basecase(out, xs);\n    } else if !TOOM3_MAYBE_SQR_TOOM3 || n < SQR_TOOM3_THRESHOLD {\n        limbs_square_to_out_toom_2(out, xs, scratch);\n    } else {\n        limbs_square_to_out_toom_3(out, xs, scratch);\n    }\n}\n\n// Interpreting a slices of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the `2\n// * xs.len()` least-significant limbs of the square of the `Natural` to an output slice. A scratch\n// slice is provided for the algorithm to use. An upper bound for the number of scratch limbs needed\n// is provided by `limbs_square_to_out_toom_3_scratch_len`. The following restrictions on the input\n// slices must be met:\n// - `out`.len() >= 2 * `xs`.len()\n// - `xs`.len() == 3 or `xs`.len() > 4\n//\n// The smallest allowable `xs` length is 3.\n//\n// Evaluate in: -1, 0, +1, +2, +inf\n// ```\n// <-s--><--n--><--n-->\n//  ____ ______ ______\n// |xs_2|_xs_1_|_xs_0_|\n//\n// v_0     = xs_0 ^ 2                         # X(0)^2\n// v_1     = (xs_0 + xs_1 + xs_2) ^ 2         # X(1)^2    xh  <= 2\n// v_neg_1 = (xs_0 - xs_1 + xs_2) ^ 2         # X(-1)^2  |xh| <= 1\n// v_2     = (xs_0 + 2 * xs_1 + 4 * xs_2) ^ 2 # X(2)^2    xh  <= 6\n// v_inf   = xs_2 ^ 2                         # X(inf)^2\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_3 5}) \\approx O(n^{1.465})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom3_sqr` from `mpn/generic/toom3_sqr.c`, GMP 6.2.1.\npub_test! {limbs_square_to_out_toom_3(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let xs_len = xs.len();\n    let n = xs_len.div_round(3, Ceiling).0;\n    let m = n + 1;\n    let k = m + n;\n    let s = xs_len - (n << 1);\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    split_into_chunks!(xs, n, [xs_0, xs_1], xs_2);\n    split_into_chunks_mut!(scratch, m << 1, [scratch_lo, asm1], as1);\n    let (asm1_last, asm1_init) = asm1[..m].split_last_mut().unwrap();\n    let (as1_last, as1_init) = as1[..m].split_last_mut().unwrap();\n    let scratch_lo = &mut scratch_lo[..n];\n    let mut carry = Limb::from(limbs_add_to_out(scratch_lo, xs_0, xs_2));\n    *as1_last = carry;\n    if limbs_add_same_length_to_out(as1_init, scratch_lo, xs_1) {\n        *as1_last += 1;\n    }\n    if carry == 0 && limbs_cmp_same_length(scratch_lo, xs_1) == Less {\n        limbs_sub_same_length_to_out(asm1_init, xs_1, scratch_lo);\n    } else if limbs_sub_same_length_to_out(asm1_init, scratch_lo, xs_1) {\n        carry.wrapping_sub_assign(1);\n    }\n    *asm1_last = carry;\n    let as2 = &mut out[m..m << 1];\n    let (as2_last, as2_init) = as2.split_last_mut().unwrap();\n    let (as1_lo, as1_hi) = as1_init.split_at_mut(s);\n    let mut carry = Limb::from(limbs_add_same_length_to_out(as2_init, xs_2, as1_lo));\n    if s != n {\n        carry = Limb::from(limbs_add_limb_to_out(&mut as2_init[s..], as1_hi, carry));\n    }\n    carry.wrapping_add_assign(*as1_last);\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(as2_init, 1));\n    if limbs_sub_same_length_in_place_left(as2_init, xs_0) {\n        carry.wrapping_sub_assign(1);\n    }\n    *as2_last = carry;\n    assert!(*as1_last <= 2);\n    assert!(*asm1_last <= 1);\n    let (scratch_lo, scratch_out) = scratch.split_at_mut(5 * m);\n    if SMALLER_RECURSION_TOOM_3 {\n        let (v_neg_1, asm1) = scratch_lo.split_at_mut(k);\n        let (v_neg_1_last, v_neg_1_init) = v_neg_1.split_last_mut().unwrap();\n        let (asm1_last, asm1_init) = asm1[1..n + 2].split_last().unwrap();\n        limbs_square_to_out_toom_3_recursive(v_neg_1_init, asm1_init, scratch_out);\n        *v_neg_1_last = if *asm1_last != 0 {\n            asm1_last.wrapping_add(limbs_slice_add_mul_limb_same_length_in_place_left(\n                &mut v_neg_1_init[n..],\n                asm1_init,\n                2,\n            ))\n        } else {\n            0\n        };\n    } else {\n        fail_on_untested_path(\"limbs_square_to_out_toom_3, !SMALLER_RECURSION\");\n        let (v_neg_1, asm1) = scratch_lo.split_at_mut(m << 1);\n        limbs_square_to_out_toom_3_recursive(v_neg_1, &asm1[..m], scratch_out);\n    }\n    limbs_square_to_out_toom_3_recursive(&mut scratch_lo[k..], as2, scratch_out);\n    let v_inf = &mut out[n << 2..];\n    limbs_square_to_out_toom_3_recursive(v_inf, xs_2, scratch_out);\n    let v_inf_0 = v_inf[0];\n    let (as1, scratch_out) = &mut scratch[m << 2..].split_at_mut(m);\n    let out_hi = &mut out[n << 1..];\n    if SMALLER_RECURSION_TOOM_3 {\n        let (v_1_last, v_1_init) = out_hi[..k].split_last_mut().unwrap();\n        let (as1_last, as1_init) = as1.split_last_mut().unwrap();\n        limbs_square_to_out_toom_3_recursive(v_1_init, as1_init, scratch_out);\n        let v_1_init = &mut v_1_init[n..];\n        *v_1_last = if *as1_last == 1 {\n            limbs_slice_add_mul_limb_same_length_in_place_left(v_1_init, as1_init, 2)\n                .wrapping_add(1)\n        } else if *as1_last != 0 {\n            as1_last.arithmetic_checked_shl(1u64).unwrap().wrapping_add(\n                limbs_slice_add_mul_limb_same_length_in_place_left(v_1_init, as1_init, 4),\n            )\n        } else {\n            0\n        };\n    } else {\n        let carry = out_hi[k];\n        limbs_square_to_out_toom_3_recursive(out_hi, as1, scratch_out);\n        out_hi[k] = carry;\n    }\n    let (v_neg_1, remainder) = scratch.split_at_mut(k);\n    let (v_2, scratch_out) = remainder.split_at_mut(3 * n + 4);\n    limbs_square_to_out_toom_3_recursive(out, xs_0, scratch_out);\n    limbs_mul_toom_interpolate_5_points(out, v_2, v_neg_1, n, s << 1, false, v_inf_0);\n}}\n\n// This function can be used to determine whether the size of the input slice to\n// `limbs_square_to_out_toom_4` is valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_square_to_out_toom_4_input_size_valid(xs_len: usize) -> bool {\n    xs_len == 4 || xs_len == 7 || xs_len == 8 || xs_len > 9\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom4_sqr_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_const_test! {limbs_square_to_out_toom_4_scratch_len(xs_len: usize) -> usize {\n    3 * xs_len + Limb::WIDTH as usize\n}}\n\n// TODO tune\n\n// This is equivalent to `MAYBE_sqr_toom2` from `mpn/generic/toom4_sqr.c`, GMP 6.2.1.\nconst TOOM4_MAYBE_SQR_TOOM2: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM4_THRESHOLD < 4 * SQR_TOOM3_THRESHOLD;\n\n// TODO tune\n\n// This is equivalent to `MAYBE_sqr_toom4` from `mpn/generic/toom4_sqr.c`, GMP 6.2.1.\nconst TOOM4_MAYBE_SQR_TOOM4: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM6_THRESHOLD >= 4 * SQR_TOOM4_THRESHOLD;\n\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_4 7}) \\approx O(n^{1.404})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM4_SQR_REC` from `mpn/generic/toom4_sqr.c`, GMP 6.2.1.\nfn limbs_square_to_out_toom_4_recursive(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let n = xs.len();\n    if n < SQR_TOOM2_THRESHOLD {\n        // We don't check TOOM4_MAYBE_SQR_BASECASE because we never want the Toom functions to\n        // handle very small inputs.\n        limbs_square_to_out_basecase(out, xs);\n    } else if TOOM4_MAYBE_SQR_TOOM2 && n < SQR_TOOM3_THRESHOLD {\n        limbs_square_to_out_toom_2(out, xs, scratch);\n    } else if !TOOM4_MAYBE_SQR_TOOM4 || n < SQR_TOOM4_THRESHOLD {\n        limbs_square_to_out_toom_3(out, xs, scratch);\n    } else {\n        limbs_square_to_out_toom_4(out, xs, scratch);\n    }\n}\n\n// Interpreting a slices of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the `2\n// * xs.len()` least-significant limbs of the square of the `Natural` to an output slice. A scratch\n// slice is provided for the algorithm to use. An upper bound for the number of scratch limbs needed\n// is provided by `limbs_square_to_out_toom_4_scratch_len`. The following restrictions on the input\n// slices must be met:\n// - `out`.len() >= 2 * `xs`.len()\n// - `xs`.len() is 4, 7, or 8, or `xs`.len() > 9.\n//\n// The smallest allowable `xs` length is 4.\n//\n// Evaluate in: -1, -1/2, 0, +1/2, +1, +2, +inf\n// ```\n// <-s--><--n--><--n--><--n-->\n//  ____ ______ ______ ______\n// |xs_3|_xs_2_|_xs_1_|_xs_0_|\n//\n// v_0     = xs_0 ^ 2                                    # X(0) ^ 2\n// v_1     = (xs_0 + xs_1 + xs_2 + xs_3) ^ 2             # X(1) ^ 2     xh <= 3\n// v_neg_1 = (xs_0 - xs_1 + xs_2 - xs_3) ^ 2             # X(-1) ^ 2    |xh| <= 1\n// v_2     = (xs_0 + 2 * xs_1 + 4 * xs_2 + 8 * xs_3) ^ 2 # X(2) ^ 2     xh <= 14\n// vh      = (8 * xs_0 + 4 * xs_1 + 2 * xs_2 + xs_3) ^ 2 # X(1/2) ^ 2   xh <= 14\n// vmh     = (8 * xs_0 - 4 * xs_1 + 2 * xs_2 - xs_3) ^ 2 # X(-1/2) ^ 2  -4 <= xh <= 9\n// v_inf   = xs_3 ^ 2                                    # X(inf) ^ 2\n// ```\n//\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_4 7}) \\approx O(n^{1.404})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom4_sqr` from `mpn/generic/toom4_sqr.c`, GMP 6.2.1.\npub_test! {limbs_square_to_out_toom_4(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let xs_len = xs.len();\n    let n = (xs_len + 3) >> 2;\n    let s = xs_len - 3 * n;\n    assert_ne!(s, 0);\n    assert!(s <= n);\n    let m = n + 1;\n    let k = m + n;\n    split_into_chunks!(xs, n, [xs_0, xs_1, xs_2], xs_3);\n    // Total scratch need: 8 * n + 5 + scratch for recursive calls. This gives roughly 32 * n / 3 +\n    // log term. Compute apx = xs_0 + 2 * xs_1 + 4 * xs_2 + 8 * xs_3 and amx = xs_0 - 2 * xs_1 + 4\n    // * xs_2 - 8 * xs_3.\n    let (apx, remainder) = out.split_at_mut(n << 1);\n    let apx = &mut apx[..m];\n    let (v1, amx) = remainder.split_at_mut(m << 1);\n    let amx = &mut amx[..m];\n    let (scratch_lo, scratch_hi) = scratch.split_at_mut((k << 2) + 1);\n    limbs_mul_toom_evaluate_deg_3_poly_in_2_and_neg_2(apx, amx, xs, n, &mut scratch_hi[..m]);\n    limbs_square_to_out_toom_4_recursive(scratch_lo, apx, scratch_hi);\n    let scratch_lo = &mut scratch_lo[k..];\n    limbs_square_to_out_toom_4_recursive(scratch_lo, amx, scratch_hi);\n    // Compute apx = 8 xs_0 + 4 xs_1 + 2 xs_2 + xs_3 = (((2 xs_0 + xs_1) * 2 + xs_2) * 2 + xs_3\n    let (apx_last, apx_init) = apx.split_last_mut().unwrap();\n    let mut carry = limbs_shl_to_out(apx_init, xs_0, 1);\n    if limbs_slice_add_same_length_in_place_left(apx_init, xs_1) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(apx_init, 1));\n    if limbs_slice_add_same_length_in_place_left(apx_init, xs_2) {\n        carry.wrapping_add_assign(1);\n    }\n    carry = carry.arithmetic_checked_shl(1).unwrap();\n    carry.wrapping_add_assign(limbs_slice_shl_in_place(apx_init, 1));\n    if limbs_slice_add_greater_in_place_left(apx_init, xs_3) {\n        carry.wrapping_add_assign(1);\n    }\n    *apx_last = carry;\n    assert!(*apx_last < 15);\n    let scratch_lo = &mut scratch_lo[k..];\n    limbs_square_to_out_toom_4_recursive(scratch_lo, apx, scratch_hi);\n    // Compute apx = xs_0 + xs_1 + xs_2 + xs_3 and amx = xs_0 - xs_1 + xs_2 - xs_3.\n    limbs_mul_toom_evaluate_deg_3_poly_in_1_and_neg_1(apx, amx, xs, n, &mut scratch_hi[..m]);\n    limbs_square_to_out_toom_4_recursive(v1, apx, scratch_hi);\n    let scratch_lo = &mut scratch_lo[k..];\n    limbs_square_to_out_toom_4_recursive(scratch_lo, amx, scratch_hi);\n    let (v0, vinf) = out.split_at_mut(n << 1);\n    let vinf = &mut vinf[n << 2..];\n    limbs_square_to_out_toom_4_recursive(v0, xs_0, scratch_hi);\n    limbs_square_to_out_toom_4_recursive(vinf, xs_3, scratch_hi);\n    split_into_chunks_mut!(scratch, k, [v2, vm2, vh, vm1], scratch_hi);\n    limbs_mul_toom_interpolate_7_points(out, n, s << 1, false, vm2, false, vm1, v2, vh, scratch_hi);\n}}\n\n// This function can be used to determine whether the size of the input slice to\n// `limbs_square_to_out_toom_6` is valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_square_to_out_toom_6_input_size_valid(xs_len: usize) -> bool {\n    xs_len == 18 || xs_len > 21 && xs_len != 25 && xs_len != 26 && xs_len != 31\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom6_sqr_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_square_to_out_toom_6_scratch_len(n: usize) -> usize {\n    (n << 1)\n        + max(\n            (SQR_TOOM6_THRESHOLD << 1) + usize::wrapping_from(Limb::WIDTH) * 6,\n            limbs_square_to_out_toom_4_scratch_len(SQR_TOOM6_THRESHOLD),\n        )\n        - (SQR_TOOM6_THRESHOLD << 1)\n}}\n\n// TODO tune\n\n/// This is equivalent to `SQR_TOOM6_MAX` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nconst SQR_TOOM6_MAX: usize = (SQR_TOOM8_THRESHOLD + 6 * 2 - 1).div_ceil(6);\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_basecase` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nconst TOOM6_MAYBE_SQR_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM6_THRESHOLD < 6 * SQR_TOOM2_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_toom2` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nconst TOOM6_MAYBE_SQR_TOOM2: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM6_THRESHOLD < 6 * SQR_TOOM3_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_toom2` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nconst TOOM6_MAYBE_SQR_ABOVE_TOOM2: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM6_MAX >= SQR_TOOM3_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_toom3` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nconst TOOM6_MAYBE_SQR_TOOM3: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM6_THRESHOLD < 6 * SQR_TOOM4_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_toom3` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nconst TOOM6_MAYBE_SQR_ABOVE_TOOM3: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM6_MAX >= SQR_TOOM4_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_toom4` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nconst TOOM6_MAYBE_SQR_ABOVE_TOOM4: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM6_MAX >= SQR_TOOM6_THRESHOLD;\n\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_6 11}) \\approx O(n^{1.338})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM6_SQR_REC` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\nfn limbs_square_to_out_toom_6_recursive(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let n = xs.len();\n    if TOOM6_MAYBE_SQR_BASECASE && n < SQR_TOOM2_THRESHOLD {\n        limbs_square_to_out_basecase(out, xs);\n    } else if TOOM6_MAYBE_SQR_TOOM2 && (!TOOM6_MAYBE_SQR_ABOVE_TOOM2 || n < SQR_TOOM3_THRESHOLD) {\n        limbs_square_to_out_toom_2(out, xs, scratch);\n    } else if TOOM6_MAYBE_SQR_TOOM3 && (!TOOM6_MAYBE_SQR_ABOVE_TOOM3 || n < SQR_TOOM4_THRESHOLD) {\n        limbs_square_to_out_toom_3(out, xs, scratch);\n    } else if !TOOM6_MAYBE_SQR_ABOVE_TOOM4 || n < SQR_TOOM6_THRESHOLD {\n        limbs_square_to_out_toom_4(out, xs, scratch);\n    } else {\n        limbs_square_to_out_toom_6(out, xs, scratch);\n    }\n}\n\n// Interpreting a slices of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the `2\n// * xs.len()` least-significant limbs of the square of the `Natural` to an output slice. A scratch\n// slice is provided for the algorithm to use. An upper bound for the number of scratch limbs needed\n// is provided by `limbs_square_to_out_toom_6_scratch_len`. The following restrictions on the input\n// slices must be met:\n// - `out`.len() >= 2 * `xs`.len()\n// - `xs`.len() is 18, or `xs.len()` > 21 but `xs`.len() is not 25, 26, or 31.\n//\n// The smallest allowable `xs` length is 18.\n//\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_6 11}) \\approx O(n^{1.338})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom6_sqr` from `mpn/generic/toom6_sqr.c`, GMP 6.2.1.\npub_test! {limbs_square_to_out_toom_6(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let xs_len = xs.len();\n    assert!(xs_len >= 18);\n    let n = 1 + (xs_len - 1) / 6;\n    assert!(xs_len > 5 * n);\n    let s = xs_len - 5 * n;\n    assert!(s <= n);\n    assert!(10 * n + 3 <= xs_len << 1);\n    let m = n + 1;\n    let k = m + n;\n    let (out_lo, remainder) = out.split_at_mut(3 * n);\n    let (r4, r2) = remainder.split_at_mut(n << 2);\n    let (v0, v2) = r2.split_at_mut(m << 1);\n    let v0 = &mut v0[..m];\n    let v2 = &mut v2[..m];\n    // +/- 1/2\n    limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n        v2,\n        v0,\n        5,\n        xs,\n        n,\n        1,\n        &mut out_lo[..m],\n    );\n    split_into_chunks_mut!(scratch, 3 * n + 1, [r5, r3, r1], wse);\n    limbs_square_to_out_toom_6_recursive(out_lo, v0, wse); // X(-1/2) ^ 2 * 2 ^\n    limbs_square_to_out_toom_6_recursive(r5, v2, wse); // X(1/2) ^ 2 * 2 ^\n    limbs_toom_couple_handling(r5, &mut out_lo[..k], false, n, 1, 0);\n    // +/- 1\n    limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v2, v0, 5, xs, n, &mut out_lo[..m]);\n    limbs_square_to_out_toom_6_recursive(out_lo, v0, wse); // X(-1) ^ 2\n    limbs_square_to_out_toom_6_recursive(r3, v2, wse); // X(1) ^ 2\n    limbs_toom_couple_handling(r3, &mut out_lo[..k], false, n, 0, 0);\n    // +/- 4\n    limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, 5, xs, n, 2, &mut out_lo[..m]);\n    limbs_square_to_out_toom_6_recursive(out_lo, v0, wse); // X(-4) ^ 2\n    limbs_square_to_out_toom_6_recursive(r1, v2, wse); // X(4) ^ 2\n    limbs_toom_couple_handling(r1, &mut out_lo[..k], false, n, 2, 4);\n    // +/- 1/4\n    limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n        v2,\n        v0,\n        5,\n        xs,\n        n,\n        2,\n        &mut out_lo[..m],\n    );\n    limbs_square_to_out_toom_6_recursive(out_lo, v0, wse); // X(-1/4) ^ 2 * 4 ^\n    limbs_square_to_out_toom_6_recursive(r4, v2, wse); // X(1/4) ^ 2 * 4 ^\n    limbs_toom_couple_handling(r4, &mut out_lo[..k], false, n, 2, 0);\n    // +/- 2\n    limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v2, v0, 5, xs, n, &mut out_lo[..m]);\n    limbs_square_to_out_toom_6_recursive(out_lo, v0, wse); // X(-2) ^ 2\n    let (v0, v2) = r2.split_at_mut(m << 1);\n    limbs_square_to_out_toom_6_recursive(v0, &v2[..m], wse); // X(2) ^ 2\n    limbs_toom_couple_handling(r2, &mut out_lo[..k], false, n, 1, 2);\n    limbs_square_to_out_toom_6_recursive(out_lo, &xs[..n], wse); // X(0) ^ 2\n    limbs_mul_toom_interpolate_12_points(out, r1, r3, r5, n, s << 1, false, wse);\n}}\n\n// TODO tune\npub(crate) const SQR_FFT_THRESHOLD: usize = SQR_FFT_MODF_THRESHOLD * 10;\n\n// This function can be used to determine whether the size of the input slice to\n// `limbs_square_to_out_toom_8` is valid.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {limbs_square_to_out_toom_8_input_size_valid(xs_len: usize) -> bool {\n    xs_len == 40 || xs_len > 43 && xs_len != 49 && xs_len != 50 && xs_len != 57\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_toom8_sqr_itch` from `gmp-impl.h`, GMP 6.2.1.\npub_crate_test! {limbs_square_to_out_toom_8_scratch_len(n: usize) -> usize {\n    ((n * 15) >> 3)\n        + max(\n            ((SQR_TOOM8_THRESHOLD * 15) >> 3) + usize::wrapping_from(Limb::WIDTH) * 6,\n            limbs_square_to_out_toom_6_scratch_len(SQR_TOOM8_THRESHOLD),\n        )\n        - ((SQR_TOOM8_THRESHOLD * 15) >> 3)\n}}\n\n// TODO tune\n\n/// This is equivalent to `SQR_TOOM8_MAX` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst SQR_TOOM8_MAX: usize = if SQR_FFT_THRESHOLD <= usize::MAX - (8 * 2 - 1 + 7) {\n    (SQR_FFT_THRESHOLD + 8 * 2 - 1).div_ceil(8)\n} else {\n    usize::MAX\n};\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_basecase` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_THRESHOLD < 8 * SQR_TOOM2_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_basecase` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_ABOVE_BASECASE: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_MAX >= SQR_TOOM2_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_toom2` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_TOOM2: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_THRESHOLD < 8 * SQR_TOOM3_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_toom2` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_ABOVE_TOOM2: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_MAX >= SQR_TOOM3_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_toom3` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_TOOM3: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_THRESHOLD < 8 * SQR_TOOM4_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_toom3` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_ABOVE_TOOM3: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_MAX >= SQR_TOOM4_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_toom4` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_TOOM4: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_THRESHOLD < 8 * SQR_TOOM6_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_toom4` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_ABOVE_TOOM4: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_MAX >= SQR_TOOM6_THRESHOLD;\n\n// TODO tune\n\n/// This is equivalent to `MAYBE_sqr_above_toom6` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\nconst TOOM8_MAYBE_SQR_ABOVE_TOOM6: bool =\n    TUNE_PROGRAM_BUILD || SQR_TOOM8_MAX >= SQR_TOOM8_THRESHOLD;\n\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_6 11}) \\approx O(n^{1.302})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `TOOM8_SQR_REC` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1, when `f` is\n// `false`.\nfn limbs_square_to_out_toom_8_recursive(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let n = xs.len();\n    if TOOM8_MAYBE_SQR_BASECASE && (!TOOM8_MAYBE_SQR_ABOVE_BASECASE || n < SQR_TOOM2_THRESHOLD) {\n        limbs_square_to_out_basecase(out, xs);\n    } else if TOOM8_MAYBE_SQR_TOOM2 && (!TOOM8_MAYBE_SQR_ABOVE_TOOM2 || n < SQR_TOOM3_THRESHOLD) {\n        limbs_square_to_out_toom_2(out, xs, scratch);\n    } else if TOOM8_MAYBE_SQR_TOOM3 && (!TOOM8_MAYBE_SQR_ABOVE_TOOM3 || n < SQR_TOOM4_THRESHOLD) {\n        limbs_square_to_out_toom_3(out, xs, scratch);\n    } else if TOOM8_MAYBE_SQR_TOOM4 && (!TOOM8_MAYBE_SQR_ABOVE_TOOM4 || n < SQR_TOOM6_THRESHOLD) {\n        limbs_square_to_out_toom_4(out, xs, scratch);\n    } else if !TOOM8_MAYBE_SQR_ABOVE_TOOM6 || n < SQR_TOOM8_THRESHOLD {\n        limbs_square_to_out_toom_6(out, xs, scratch);\n    } else {\n        limbs_square_to_out_toom_8(out, xs, scratch);\n    }\n}\n\n// Interpreting a slices of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the `2\n// * xs.len()` least-significant limbs of the square of the `Natural` to an output slice. A scratch\n// slice is provided for the algorithm to use. An upper bound for the number of scratch limbs needed\n// is provided by `limbs_square_to_out_toom_8_scratch_len`. The following restrictions on the input\n// slices must be met:\n// - `out`.len() >= 2 * `xs`.len()\n// - `xs`.len() is 40, or `xs.len()` > 43 but `xs`.len() is not 49, 50, or 57.\n//\n// The smallest allowable `xs` length is 40.\n//\n// # Worst-case complexity\n// $T(n) = O(n^{\\log_6 11}) \\approx O(n^{1.302})$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// May panic if the input slice conditions are not met.\n//\n// This is equivalent to `mpn_toom8_sqr` from `mpn/generic/toom8_sqr.c`, GMP 6.2.1.\npub_test! {limbs_square_to_out_toom_8(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let xs_len = xs.len();\n    assert!(xs_len >= 40);\n    let n: usize = xs_len.shr_round(3, Ceiling).0;\n    let m = n + 1;\n    let k = m + n;\n    let p = k + n;\n    assert!(xs_len > 7 * n);\n    let s = xs_len - 7 * n;\n    assert!(s <= n);\n    assert!(s << 1 > 3);\n    let (pp_lo, remainder) = out.split_at_mut(3 * n);\n    split_into_chunks_mut!(remainder, n << 2, [r6, r4], pp_hi);\n    split_into_chunks_mut!(pp_hi, m, [v0, _unused, v2], _unused);\n    // +/- 1/8\n    limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n        v2,\n        v0,\n        7,\n        xs,\n        n,\n        3,\n        &mut pp_lo[..m],\n    );\n    let (r7_r5, remainder) = scratch.split_at_mut(p << 1);\n    let (r3, r1_wse) = remainder.split_at_mut(p);\n    let (r1, wse) = r1_wse.split_at_mut(p);\n    // A(-1/8) * B(-1/8) * 8 ^, A(1/8) * B(1/8) * 8 ^\n    limbs_square_to_out_toom_8_recursive(pp_lo, v0, wse);\n    limbs_square_to_out_toom_8_recursive(r7_r5, v2, wse);\n    let limit = if BIT_CORRECTION { m << 1 } else { k };\n    limbs_toom_couple_handling(r7_r5, &mut pp_lo[..limit], false, n, 3, 0);\n    // +/- 1/4\n    limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n        v2,\n        v0,\n        7,\n        xs,\n        n,\n        2,\n        &mut pp_lo[..m],\n    );\n    // A(-1/4) * B(-1/4) * 4 ^, A(1/4) * B(1/4) * 4^\n    limbs_square_to_out_toom_8_recursive(pp_lo, v0, wse);\n    let (r7, r5) = r7_r5.split_at_mut(p);\n    limbs_square_to_out_toom_8_recursive(r5, v2, wse);\n    limbs_toom_couple_handling(r5, &mut pp_lo[..k], false, n, 2, 0);\n    // +/- 2\n    limbs_mul_toom_evaluate_poly_in_2_and_neg_2(v2, v0, 7, xs, n, &mut pp_lo[..m]);\n    // A(-2)*B(-2), A(+2)*B(+2)\n    limbs_square_to_out_toom_8_recursive(pp_lo, v0, wse);\n    limbs_square_to_out_toom_8_recursive(r3, v2, wse);\n    limbs_toom_couple_handling(r3, &mut pp_lo[..k], false, n, 1, 2);\n    // +/- 8\n    limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, 7, xs, n, 3, &mut pp_lo[..m]);\n    // A(-8) * B(-8), A(8) * B(8)\n    limbs_square_to_out_toom_8_recursive(pp_lo, v0, wse);\n    limbs_square_to_out_toom_8_recursive(r1, v2, wse);\n    limbs_toom_couple_handling(r1_wse, &mut pp_lo[..limit], false, n, 3, 6);\n    // +/- 1/2\n    limbs_mul_toom_evaluate_poly_in_2_pow_neg_and_neg_2_pow_neg(\n        v2,\n        v0,\n        7,\n        xs,\n        n,\n        1,\n        &mut pp_lo[..m],\n    );\n    // A(-1/2) * B(-1/2) * 2 ^, A(1/2) * B(1/2) * 2 ^\n    let (r1, wse) = r1_wse.split_at_mut(p);\n    limbs_square_to_out_toom_8_recursive(pp_lo, v0, wse);\n    limbs_square_to_out_toom_8_recursive(r6, v2, wse);\n    limbs_toom_couple_handling(r6, &mut pp_lo[..k], false, n, 1, 0);\n    // +/- 1\n    limbs_mul_toom_evaluate_poly_in_1_and_neg_1(v2, v0, 7, xs, n, &mut pp_lo[..m]);\n    // A(-1) * B(-1), A(1) * B(1)\n    limbs_square_to_out_toom_8_recursive(pp_lo, v0, wse);\n    limbs_square_to_out_toom_8_recursive(r4, v2, wse);\n    limbs_toom_couple_handling(r4, &mut pp_lo[..k], false, n, 0, 0);\n    // +/- 4\n    limbs_mul_toom_evaluate_poly_in_2_pow_and_neg_2_pow(v2, v0, 7, xs, n, 2, &mut pp_lo[..m]);\n    // A(-4) * B(-4), A(4) * B(4)\n    limbs_square_to_out_toom_8_recursive(pp_lo, v0, wse);\n    let (r2, v2) = pp_hi.split_at_mut(m << 1);\n    limbs_square_to_out_toom_8_recursive(r2, &v2[..m], wse);\n    limbs_toom_couple_handling(pp_hi, &mut pp_lo[..k], false, n, 2, 4);\n    // A(0) * B(0)\n    limbs_square_to_out_toom_8_recursive(pp_lo, &xs[..n], wse);\n    limbs_mul_toom_interpolate_16_points(out, r1, r3, r5, r7, n, s << 1, false, &mut wse[..p]);\n}}\n\npub_crate_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_square_to_out_scratch_len(n: usize) -> usize {\n    if n < SQR_BASECASE_THRESHOLD || n < SQR_TOOM2_THRESHOLD {\n        0\n    } else if n < SQR_TOOM3_THRESHOLD {\n        limbs_square_to_out_toom_2_scratch_len(n)\n    } else if n < SQR_TOOM4_THRESHOLD {\n        limbs_square_to_out_toom_3_scratch_len(n)\n    } else if n < SQR_TOOM6_THRESHOLD {\n        limbs_square_to_out_toom_4_scratch_len(n)\n    } else if n < SQR_TOOM8_THRESHOLD {\n        limbs_square_to_out_toom_6_scratch_len(n)\n    } else if n < SQR_FFT_THRESHOLD {\n        limbs_square_to_out_toom_8_scratch_len(n)\n    } else {\n        0\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_sqr` from `mpn/generic/sqr.c`, GMP 6.2.1.\npub_crate_test! {\n#[allow(clippy::absurd_extreme_comparisons)]\nlimbs_square_to_out(out: &mut [Limb], xs: &[Limb], scratch: &mut [Limb]) {\n    let n = xs.len();\n    assert!(n >= 1);\n    if n < SQR_BASECASE_THRESHOLD {\n        // limbs_mul_greater_to_out_basecase is faster than limbs_square_to_out_basecase on small\n        // sizes sometimes\n        limbs_mul_greater_to_out_basecase(out, xs, xs);\n    } else if n < SQR_TOOM2_THRESHOLD {\n        limbs_square_to_out_basecase(out, xs);\n    } else if n < SQR_TOOM3_THRESHOLD {\n        limbs_square_to_out_toom_2(out, xs, scratch);\n    } else if n < SQR_TOOM4_THRESHOLD {\n        limbs_square_to_out_toom_3(out, xs, scratch);\n    } else if n < SQR_TOOM6_THRESHOLD {\n        limbs_square_to_out_toom_4(out, xs, scratch);\n    } else if n < SQR_TOOM8_THRESHOLD {\n        limbs_square_to_out_toom_6(out, xs, scratch);\n    } else if n < SQR_FFT_THRESHOLD {\n        limbs_square_to_out_toom_8(out, xs, scratch);\n    } else {\n        mpn_square_default_mpn_ctx(out, xs);\n    }\n}}\n\npub_crate_test! {limbs_square(xs: &[Limb]) -> Vec<Limb> {\n    let mut out = vec![0; xs.len() << 1];\n    let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(xs.len())];\n    limbs_square_to_out(&mut out, xs, &mut square_scratch);\n    out\n}}\n\nimpl Square for Natural {\n    type Output = Self;\n\n    /// Squares a [`Natural`], taking it by value.\n    ///\n    /// $$\n    /// f(x) = x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.square(), 0);\n    /// assert_eq!(Natural::from(123u32).square(), 15129);\n    /// ```\n    #[inline]\n    fn square(mut self) -> Self {\n        self.square_assign();\n        self\n    }\n}\n\nimpl Square for &Natural {\n    type Output = Natural;\n\n    /// Squares a [`Natural`], taking it by reference.\n    ///\n    /// $$\n    /// f(x) = x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!((&Natural::ZERO).square(), 0);\n    /// assert_eq!((&Natural::from(123u32)).square(), 15129);\n    /// ```\n    #[inline]\n    fn square(self) -> Natural {\n        match self {\n            &Natural::ZERO | &Natural::ONE => self.clone(),\n            Natural(Small(x)) => Natural({\n                let (upper, lower) = Limb::x_mul_y_to_zz(*x, *x);\n                if upper == 0 {\n                    Small(lower)\n                } else {\n                    Large(vec![lower, upper])\n                }\n            }),\n            Natural(Large(xs)) => Natural::from_owned_limbs_asc(limbs_square(xs)),\n        }\n    }\n}\n\nimpl SquareAssign for Natural {\n    /// Squares a [`Natural`] in place.\n    ///\n    /// $$\n    /// x \\gets x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SquareAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.square_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Natural::from(123u32);\n    /// x.square_assign();\n    /// assert_eq!(x, 15129);\n    /// ```\n    fn square_assign(&mut self) {\n        match self {\n            &mut (Self::ZERO | Self::ONE) => {}\n            Self(Small(x)) => {\n                let (upper, lower) = Limb::x_mul_y_to_zz(*x, *x);\n                if upper == 0 {\n                    *x = lower;\n                } else {\n                    *self = Self(Large(vec![lower, upper]));\n                }\n            }\n            Self(Large(xs)) => {\n                *xs = limbs_square(xs);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Some optimizations contributed by florian1345.\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::fmt::Display;\nuse core::ops::{Sub, SubAssign};\nuse malachite_base::num::arithmetic::traits::CheckedSub;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, subtracts the\n// `Limb` from the `Natural`. Returns a pair consisting of the limbs of the result, and whether\n// there was a borrow left over; that is, whether the `Limb` was greater than the `Natural`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_sub_1` from `gmp.h`, GMP 6.2.1, where the result is returned.\npub_crate_test! {limbs_sub_limb(xs: &[Limb], mut y: Limb) -> (Vec<Limb>, bool) {\n    let len = xs.len();\n    let mut out = Vec::with_capacity(len);\n    for i in 0..len {\n        let (diff, overflow) = xs[i].overflowing_sub(y);\n        out.push(diff);\n        if overflow {\n            y = 1;\n        } else {\n            y = 0;\n            out.extend_from_slice(&xs[i + 1..]);\n            break;\n        }\n    }\n    (out, y != 0)\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, subtracts the\n// `Limb` from the `Natural`, writing the `xs.len()` limbs of the result to an output slice. Returns\n// whether there was a borrow left over; that is, whether the `Limb` was greater than the `Natural`.\n// The output slice must be at least as long as the input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs`.\n//\n// This is equivalent to `mpn_sub_1` from `gmp.h`, GMP 6.2.1.\npub_crate_test! {limbs_sub_limb_to_out(out: &mut [Limb], xs: &[Limb], mut y: Limb) -> bool {\n    let len = xs.len();\n    assert!(out.len() >= len);\n    for i in 0..len {\n        let overflow;\n        (out[i], overflow) = xs[i].overflowing_sub(y);\n        if overflow {\n            y = 1;\n        } else {\n            y = 0;\n            let copy_index = i + 1;\n            out[copy_index..len].copy_from_slice(&xs[copy_index..]);\n            break;\n        }\n    }\n    y != 0\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, subtracts the\n// `Limb` from the `Natural` and writes the limbs of the result to the input slice. Returns whether\n// there was a borrow left over; that is, whether the `Limb` was greater than the `Natural`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_add_1` from `gmp.h`, GMP 6.2.1, where the result is written to the\n// input slice.\npub_crate_test! {limbs_sub_limb_in_place<T: PrimitiveUnsigned>(xs: &mut [T], mut y: T) -> bool {\n    for x in &mut *xs {\n        if x.overflowing_sub_assign(y) {\n            y = T::ONE;\n        } else {\n            return false;\n        }\n    }\n    y != T::ZERO\n}}\n\n#[inline]\npub(crate) fn sub_with_carry(x: Limb, y: Limb, carry: Limb) -> (Limb, Limb) {\n    let result_no_carry = x.wrapping_sub(y);\n    let result = result_no_carry.wrapping_sub(carry);\n    let carry = Limb::from((result_no_carry > x) || (result > result_no_carry));\n    (result, carry)\n}\n\n// Interpreting a two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s,\n// subtracts the second from the first. Returns a pair consisting of the limbs of the result, and\n// whether there was a borrow left over; that is, whether the second `Natural` was greater than the\n// first `Natural`. The first slice must be at least as long as the second.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpn_sub` from `gmp.h`, GMP 6.2.1, where the output is returned.\npub_crate_test! {limbs_sub(xs: &[Limb], ys: &[Limb]) -> (Vec<Limb>, bool) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let mut out = Vec::with_capacity(xs_len);\n    let mut carry = 0;\n    for (&x, &y) in xs.iter().zip(ys.iter()) {\n        let o;\n        (o, carry) = sub_with_carry(x, y, carry);\n        out.push(o);\n    }\n    let mut borrow = carry != 0;\n    if xs_len != ys_len {\n        out.extend_from_slice(&xs[ys_len..]);\n        if borrow {\n            borrow = limbs_sub_limb_in_place(&mut out[ys_len..], 1);\n        }\n    }\n    (out, borrow)\n}}\n\n// Interpreting a two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, subtracts the second from the first, writing the `xs.len()` limbs of the result to an\n// output slice. Returns whether there was a borrow left over; that is, whether the second `Natural`\n// was greater than the first `Natural`. The output slice must be at least as long as either input\n// slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs` or if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_sub_n` from `gmp.h`, GMP 6.2.1.\npub_crate_test! {limbs_sub_same_length_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(out.len() >= len);\n    let mut carry = 0;\n\n    for (out, (&x, &y)) in out.iter_mut().zip(xs.iter().zip(ys.iter())) {\n        (*out, carry) = sub_with_carry(x, y, carry);\n    }\n\n    carry > 0\n}}\n\n// Interpreting a two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s,\n// subtracts the second from the first, writing the `xs.len()` limbs of the result to an output\n// slice. Returns whether there was a borrow left over; that is, whether the second `Natural` was\n// greater than the first `Natural`. The output slice must be at least as long as the first input\n// slice and the first input slice must be at least as long as the second.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs` or if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpn_sub` from `gmp.h`, GMP 6.2.1.\npub_crate_test! {limbs_sub_greater_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(out.len() >= xs_len);\n    let (xs_lo, xs_hi) = xs.split_at(ys_len);\n    let borrow = limbs_sub_same_length_to_out(out, xs_lo, ys);\n    if xs_len == ys_len {\n        borrow\n    } else if borrow {\n        limbs_sub_limb_to_out(&mut out[ys_len..], xs_hi, 1)\n    } else {\n        out[ys_len..xs_len].copy_from_slice(xs_hi);\n        false\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, subtracts the second from the first, writing the `xs.len()` limbs of the result to\n// the first (left) slice. Returns whether there was a borrow left over; that is, whether the second\n// `Natural` was greater than the first `Natural`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_sub_n` from `gmp.h`, GMP 6.2.1, where the output is written to the\n// first input.\npub_crate_test! {limbs_sub_same_length_in_place_left(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    assert_eq!(xs.len(), ys.len());\n    let mut carry = 0;\n\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        (*x, carry) = sub_with_carry(*x, y, carry);\n    }\n\n    carry > 0\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, subtracts\n// the second from the first, writing the `xs.len()` limbs of the result to the first (left) slice.\n// Returns whether there was a borrow left over; that is, whether the second `Natural` was greater\n// than the first `Natural`. The first slice must be at least as long as the second.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpn_sub` from `gmp.h`, GMP 6.2.1, where the output is written to the first\n// input.\npub_crate_test! {limbs_sub_greater_in_place_left(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let (xs_lo, xs_hi) = xs.split_at_mut(ys_len);\n    let borrow = limbs_sub_same_length_in_place_left(xs_lo, ys);\n    if xs_len == ys_len {\n        borrow\n    } else if borrow {\n        limbs_sub_limb_in_place(xs_hi, 1)\n    } else {\n        false\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, subtracts the second from the first, writing the `xs.len()` limbs of the result to\n// the second (right) slice. Returns whether there was a borrow left over; that is, whether the\n// second `Natural` was greater than the first `Natural`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_sub_n` from `gmp.h`, GMP 6.2.1, where the output is written to the\n// second input.\npub_crate_test! {limbs_sub_same_length_in_place_right(xs: &[Limb], ys: &mut [Limb]) -> bool {\n    assert_eq!(xs.len(), ys.len());\n    let mut carry = 0;\n\n    for (&x, y) in xs.iter().zip(ys.iter_mut()) {\n        (*y, carry) = sub_with_carry(x, *y, carry);\n    }\n\n    carry > 0\n}}\n\n// Given two equal-length slices `xs` and `ys`, computes the difference between the `Natural`s whose\n// limbs are `xs` and `&ys[..len]`, and writes the limbs of the result to `ys`. Returns whether\n// there was a borrow left over; that is, whether the second `Natural` was greater than the first\n// `Natural`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths or if `len` is greater than `xs.len()`.\n//\n// This is equivalent to `mpn_sub_n` from `gmp.h`, GMP 6.2.1, where the output is written to the\n// second input (which has `len` limbs) and the second input has enough space past `len` to\n// accomodate the output.\npub_crate_test! {limbs_slice_sub_in_place_right(xs: &[Limb], ys: &mut [Limb], len: usize) -> bool {\n    let xs_len = xs.len();\n    assert_eq!(xs_len, ys.len());\n    let (xs_lo, xs_hi) = xs.split_at(len);\n    let (ys_lo, ys_hi) = ys.split_at_mut(len);\n    let borrow = limbs_sub_same_length_in_place_right(xs_lo, ys_lo);\n    if xs_len == len {\n        borrow\n    } else if borrow {\n        limbs_sub_limb_to_out(ys_hi, xs_hi, 1)\n    } else {\n        ys_hi.copy_from_slice(xs_hi);\n        false\n    }\n}}\n\n// Interpreting a of `Limb`s and a `Vec` of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, subtracts the second from the first, writing the `xs.len()` limbs of the result to\n// the `Vec`, possibly extending the `Vec`'s length. Returns whether there was a borrow left over;\n// that is, whether the second `Natural` was greater than the first `Natural`. The first slice must\n// be at least as long as the second.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `xs.len()` -\n// `ys.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\npub_crate_test! {limbs_vec_sub_in_place_right(xs: &[Limb], ys: &mut Vec<Limb>) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let (xs_lo, xs_hi) = xs.split_at(ys_len);\n    let borrow = limbs_sub_same_length_in_place_right(xs_lo, ys);\n    if xs_len == ys_len {\n        borrow\n    } else {\n        ys.extend_from_slice(xs_hi);\n        if borrow {\n            limbs_sub_limb_in_place(&mut ys[ys_len..], 1)\n        } else {\n            false\n        }\n    }\n}}\n\n// Given a slice `xs`, computes the difference between the `Natural`s whose limbs are\n// `&xs[..xs.len() - right_start]` and `&xs[right_start..]`, and writes the limbs of the result to\n// `&xs[..xs.len() - right_start]`. Returns whether there was a borrow left over; that is, whether\n// the second `Natural` was greater than the first `Natural`. As implied by the name, the input\n// slices may overlap.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len() - right_start`.\n//\n// # Panics\n// Panics if `right_start` is greater than `xs.len()`.\n//\n// This is equivalent to `mpn_sub_n` from `gmp.h`, GMP 6.2.1, where the output is written to the\n// first input, and the two inputs are possibly-overlapping subslices of a single slice.\npub_crate_test! {limbs_sub_same_length_in_place_with_overlap(\n    xs: &mut [Limb],\n    right_start: usize\n) -> bool {\n    let len = xs.len() - right_start;\n    let mut carry = 0;\n    for i in 0..len {\n        (xs[i], carry) = sub_with_carry(xs[i], xs[i + right_start], carry);\n    }\n    carry != 0\n}}\n\n// Given two slices `xs` and `ys`, computes the difference between the `Natural`s whose limbs are\n// `&xs[xs.len() - ys.len()..]` and `&ys`, and writes the limbs of the result to `&xs[..ys.len()]`.\n// Returns whether there was a borrow left over; that is, whether the second `Natural` was greater\n// than the first `Natural`. As implied by the name, the input and output ranges may overlap. `xs`\n// must be at least as long as `ys`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ys.len()`.\n//\n// # Panics\n// Panics if `xs.len()` is shorter than `ys.len()`.\n//\n// This is equivalent to `mpn_sub_n` from `gmp.h`, GMP 6.2.1, where the output is a prefix of a\n// slice and the left operand of the subtraction is a suffix of the same slice, and the prefix and\n// suffix may overlap.\npub_crate_test! {limbs_sub_same_length_to_out_with_overlap(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    let right_start = xs_len - ys_len;\n    let mut carry = 0;\n    for i in 0..ys_len {\n        (xs[i], carry) = sub_with_carry(xs[i + right_start], ys[i], carry);\n    }\n    carry != 0\n}}\n\n// Interpreting a two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, subtracts the second from the first, and then subtracts a borrow (`false` is 0,\n// `true` is 1), writing the `xs.len()` limbs of the result to an output slice. Returns whether\n// there was a borrow left over. The output slice must be at least as long as either input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs` or if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_sub_nc` from `gmp-impl.h`, GMP 6.2.1, where `rp`, `up`, and `vp` are\n// disjoint.\npub_crate_test! {limbs_sub_same_length_with_borrow_in_to_out(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    borrow_in: bool,\n) -> bool {\n    let mut borrow = limbs_sub_same_length_to_out(out, xs, ys);\n    if borrow_in {\n        borrow |= limbs_sub_limb_in_place(&mut out[..xs.len()], 1);\n    }\n    borrow\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, subtracts the second from the first, and then subtracts a borrow (`false` is 0,\n// `true` is 1), writing the `xs.len()` limbs of the result to the first (left) slice. Return\n// whether there was a borrow left over.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_sub_nc` from `gmp-impl.h`, GMP 6.2.1, where `rp` is the same as `up`.\npub_crate_test! {limbs_sub_same_length_with_borrow_in_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    borrow_in: bool,\n) -> bool {\n    let mut borrow = limbs_sub_same_length_in_place_left(xs, ys);\n    if borrow_in {\n        borrow |= limbs_sub_limb_in_place(xs, 1);\n    }\n    borrow\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, subtracts the second from the first, and then subtracts a borrow (`false` is 0,\n// `true` is 1), writing the `xs.len()` limbs of the result to the second (right) slice. Returns\n// whether there was a borrow left over.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_sub_nc` from `gmp-impl.h`, GMP 6.2.1, where `rp` is the same as `vp`.\npub_crate_test! {limbs_sub_same_length_with_borrow_in_in_place_right(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    borrow_in: bool,\n) -> bool {\n    let mut borrow = limbs_sub_same_length_in_place_right(xs, ys);\n    if borrow_in {\n        borrow |= limbs_sub_limb_in_place(ys, 1);\n    }\n    borrow\n}}\n\nfn sub_panic<S: Display, T: Display>(x: S, y: T) -> ! {\n    panic!(\"Cannot subtract a number from a smaller number. self: {x}, other: {y}\");\n}\n\nimpl Natural {\n    pub(crate) fn sub_limb(self, other: Limb) -> Self {\n        self.checked_sub_limb(other)\n            .expect(\"Cannot subtract a Limb from a smaller Natural\")\n    }\n\n    pub(crate) fn sub_limb_ref(&self, other: Limb) -> Self {\n        self.checked_sub_limb_ref(other).unwrap_or_else(|| {\n            sub_panic(self, other);\n        })\n    }\n\n    #[cfg(feature = \"float_helpers\")]\n    pub fn sub_assign_at_limb(&mut self, i: usize, y: Limb) {\n        if i == 0 {\n            *self -= Self::from(y);\n            return;\n        }\n        let xs = self.promote_in_place();\n        if xs.len() <= i {\n            xs.resize(i + 1, 0);\n        }\n        assert!(!limbs_sub_limb_in_place(&mut xs[i..], y));\n        self.trim();\n    }\n}\n\nimpl Sub<Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) - Natural::ZERO, 123);\n    /// assert_eq!(Natural::from(456u32) - Natural::from(123u32), 333);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) * Natural::from(3u32) - Natural::from(10u32).pow(12),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn sub(self, other: Self) -> Self {\n        self.checked_sub(other)\n            .expect(\"Cannot subtract a Natural from a smaller Natural\")\n    }\n}\n\nimpl Sub<&Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) - &Natural::ZERO, 123);\n    /// assert_eq!(Natural::from(456u32) - &Natural::from(123u32), 333);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) * Natural::from(3u32) - &Natural::from(10u32).pow(12),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn sub(self, other: &Self) -> Self {\n        self.checked_sub(other)\n            .expect(\"Cannot subtract a Natural from a smaller Natural\")\n    }\n}\n\nimpl Sub<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking the first by reference and the second\n    /// by value.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) - Natural::ZERO, 123);\n    /// assert_eq!(&Natural::from(456u32) - Natural::from(123u32), 333);\n    /// assert_eq!(\n    ///     &(Natural::from(10u32).pow(12) * Natural::from(3u32)) - Natural::from(10u32).pow(12),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn sub(self, other: Natural) -> Natural {\n        self.checked_sub(other)\n            .expect(\"Cannot subtract a Natural from a smaller Natural\")\n    }\n}\n\nimpl Sub<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by another [`Natural`], taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) - &Natural::ZERO, 123);\n    /// assert_eq!(&Natural::from(456u32) - &Natural::from(123u32), 333);\n    /// assert_eq!(\n    ///     &(Natural::from(10u32).pow(12) * Natural::from(3u32)) - &Natural::from(10u32).pow(12),\n    ///     2000000000000u64\n    /// );\n    /// ```\n    fn sub(self, other: &Natural) -> Natural {\n        self.checked_sub(other).unwrap_or_else(|| {\n            sub_panic(self, other);\n        })\n    }\n}\n\nimpl SubAssign<Self> for Natural {\n    /// Subtracts a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32).pow(12) * Natural::from(10u32);\n    /// x -= Natural::from(10u32).pow(12);\n    /// x -= Natural::from(10u32).pow(12) * Natural::from(2u32);\n    /// x -= Natural::from(10u32).pow(12) * Natural::from(3u32);\n    /// x -= Natural::from(10u32).pow(12) * Natural::from(4u32);\n    /// assert_eq!(x, 0);\n    /// ```\n    fn sub_assign(&mut self, other: Self) {\n        assert!(\n            !self.sub_assign_no_panic(other),\n            \"Cannot subtract a Natural from a smaller Natural\"\n        );\n    }\n}\n\nimpl SubAssign<&Self> for Natural {\n    /// Subtracts a [`Natural`] by another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(10u32).pow(12) * Natural::from(10u32);\n    /// x -= &Natural::from(10u32).pow(12);\n    /// x -= &(Natural::from(10u32).pow(12) * Natural::from(2u32));\n    /// x -= &(Natural::from(10u32).pow(12) * Natural::from(3u32));\n    /// x -= &(Natural::from(10u32).pow(12) * Natural::from(4u32));\n    /// assert_eq!(x, 0);\n    /// ```\n    fn sub_assign(&mut self, other: &Self) {\n        assert!(\n            !self.sub_assign_ref_no_panic(other),\n            \"Cannot subtract a Natural from a smaller Natural\"\n        );\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1992-1994, 1996, 2000, 2001, 2002, 2004, 2005, 2012 Free Software Foundation,\n//      Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::mul::limbs_mul;\nuse crate::natural::arithmetic::sub::{limbs_sub_greater_in_place_left, limbs_sub_limb_in_place};\nuse crate::natural::comparison::cmp::limbs_cmp;\nuse crate::platform::{DoubleLimb, Limb};\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse core::fmt::Display;\nuse malachite_base::num::arithmetic::traits::{\n    CheckedSubMul, SubMul, SubMulAssign, WrappingAddAssign,\n};\nuse malachite_base::num::conversion::traits::SplitInHalf;\n\n// Given the limbs of two `Natural`s x and y, and a limb z, returns the limbs of x - y * z. If y * z\n// > x, `None` is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is negative, and `w` is returned instead of overwriting the first input.\npub_crate_test! {limbs_sub_mul_limb_greater(\n    xs: &[Limb],\n    ys: &[Limb],\n    z: Limb\n) -> Option<Vec<Limb>> {\n    let ys_len = ys.len();\n    let mut result = xs.to_vec();\n    let borrow = limbs_sub_mul_limb_same_length_in_place_left(&mut result[..ys_len], ys, z);\n    if borrow == 0 {\n        Some(result)\n    } else if xs.len() == ys_len || limbs_sub_limb_in_place(&mut result[ys_len..], borrow) {\n        None\n    } else {\n        Some(result)\n    }\n}}\n\n// Given the equal-length limbs of two `Natural`s x and y, and a limb z, calculates x - y * z and\n// writes the limbs of the result to the first (left) input slice. If y * z > x, a nonzero borrow is\n// returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_submul_1` from `mpn/generic/submul_1.c`, GMP 6.2.1.\npub_crate_test! {limbs_sub_mul_limb_same_length_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    z: Limb\n) -> Limb {\n    assert_eq!(xs.len(), ys.len());\n    let mut borrow = 0;\n    let z = DoubleLimb::from(z);\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        let (upper, mut lower) = (DoubleLimb::from(y) * z).split_in_half();\n        lower.wrapping_add_assign(borrow);\n        if lower < borrow {\n            borrow = upper.wrapping_add(1);\n        } else {\n            borrow = upper;\n        }\n        lower = x.wrapping_sub(lower);\n        if lower > *x {\n            borrow.wrapping_add_assign(1);\n        }\n        *x = lower;\n    }\n    borrow\n}}\n\n// Given the limbs of two `Natural`s x and y, and a limb z, calculates x - y * z and writes the\n// limbs of the result to the first (left) input slice. If y * z > x, a nonzero borrow is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpn_submul_1` from `mpn/generic/submul_1.c`, GMP 6.2.1, but where the\n// first input may be longer than the second.\npub_crate_test! {limbs_sub_mul_limb_greater_in_place_left(\n    xs: &mut [Limb],\n    ys: &[Limb],\n    limb: Limb\n) -> Limb {\n    let (xs_lo, xs_hi) = xs.split_at_mut(ys.len());\n    let borrow = limbs_sub_mul_limb_same_length_in_place_left(xs_lo, ys, limb);\n    if borrow == 0 || xs_hi.is_empty() {\n        borrow\n    } else {\n        Limb::from(limbs_sub_limb_in_place(xs_hi, borrow))\n    }\n}}\n\n// Given the equal-length limbs of two `Natural`s x and y, and a limb z, calculates x - y * z and\n// writes the limbs of the result to the second (right) input slice. If y * z > x, a nonzero borrow\n// is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive and have the same lengths, sub is negative, and the lowest limbs of the result are\n// written to the second input rather than the first.\npub_crate_test! {limbs_sub_mul_limb_same_length_in_place_right(\n    xs: &[Limb],\n    ys: &mut [Limb],\n    z: Limb,\n) -> Limb {\n    assert_eq!(xs.len(), ys.len());\n    let mut borrow = 0;\n    let z = DoubleLimb::from(z);\n    for (&x, y) in xs.iter().zip(ys.iter_mut()) {\n        let (upper, mut lower) = (DoubleLimb::from(*y) * z).split_in_half();\n        lower.wrapping_add_assign(borrow);\n        if lower < borrow {\n            borrow = upper.wrapping_add(1);\n        } else {\n            borrow = upper;\n        }\n        lower = x.wrapping_sub(lower);\n        if lower > x {\n            borrow.wrapping_add_assign(1);\n        }\n        *y = lower;\n    }\n    borrow\n}}\n\n// Given the limbs of two `Natural`s x and y, and a limb z, calculates x - y * z and writes the\n// limbs of the result to the second (right) input `Vec`. If y * z > x, a nonzero borrow is\n// returned.\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(m) = O(m)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is `xs.len() - ys.len()`.\n//\n// # Panics\n// Panics if `xs` is shorter than `ys`.\n//\n// This is equivalent to `mpz_aorsmul_1` from `mpz/aorsmul_i.c`, GMP 6.2.1, where `w` and `x` are\n// positive, `sub` is negative, and the result is written to the second input rather than the first.\npub_test! {limbs_sub_mul_limb_greater_in_place_right(\n    xs: &[Limb],\n    ys: &mut Vec<Limb>,\n    z: Limb\n) -> Limb {\n    let ys_len = ys.len();\n    let (xs_lo, xs_hi) = xs.split_at(ys_len);\n    let borrow = limbs_sub_mul_limb_same_length_in_place_right(xs_lo, ys, z);\n    if xs_hi.is_empty() {\n        borrow\n    } else {\n        ys.extend(&xs[ys_len..]);\n        if borrow == 0 {\n            0\n        } else {\n            Limb::from(limbs_sub_limb_in_place(&mut ys[ys_len..], borrow))\n        }\n    }\n}}\n\n// Given the limbs `xs`, `ys` and `zs` of three `Natural`s x, y, and z, returns the limbs of x - y\n// * z. If x < y * z, `None` is returned. `ys` and `zs` should have length at least 2, and the\n// length of `xs` should be at least `ys.len()` + `zs.len()` - 1 (if the latter condition is false,\n// the result would be `None` and there's no point in calling this function). None of the slices\n// should have any trailing zeros. The result, if it exists, will have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n, m) = O(m + n \\log n \\log\\log n)$\n//\n// $M(n, m) = O(m + n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(ys.len(), zs.len())`, and $m$ is\n// `xs.len()`.\n//\n// # Panics\n// Panics if `ys` or `zs` have fewer than two elements each, or if `xs.len()` < `ys.len()` +\n// `zs.len()` - 1.\n//\n// This is equivalent to `mpz_aorsmul` from `mpz/aorsmul.c`, GMP 6.2.1, where `w`, `x`, and `y` are\n// positive, `sub` is negative, negative results are converted to `None`, and `w` is returned\n// instead of overwriting the first input.\npub_crate_test! {limbs_sub_mul(xs: &[Limb], ys: &[Limb], zs: &[Limb]) -> Option<Vec<Limb>> {\n    let mut xs = xs.to_vec();\n    if limbs_sub_mul_in_place_left(&mut xs, ys, zs) {\n        None\n    } else {\n        Some(xs)\n    }\n}}\n\n// Given the limbs `xs`, `ys` and `zs` of three `Natural`s x, y, and z, computes x - y * z. The\n// limbs of the result are written to `xs`. Returns whether a borrow (overflow) occurred: if x < y\n// * z, `true` is returned and the value of `xs` should be ignored. `ys` and `zs` should have\n// length at least 2, and the length of `xs` should be at least `ys.len()` + `zs.len()` - 1 (if the\n// latter condition is false, the result would be negative and there would be no point in calling\n// this function). None of the slices should have any trailing zeros. The result, if it exists, will\n// have no trailing zeros.\n//\n// # Worst-case complexity\n// $T(n, m) = O(m + n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `max(ys.len(), zs.len())`, and $m$ is\n// `xs.len()`.\n//\n// # Panics\n// Panics if `ys` or `zs` have fewer than two elements each, or if `xs.len() < ys.len() + zs.len()\n// - 1`.\n//\n// This is equivalent to `mpz_aorsmul` from `mpz/aorsmul.c`, GMP 6.2.1, where `w`, `x`, and `y` are\n// positive, `sub` is negative and negative results are discarded.\npub_crate_test! {limbs_sub_mul_in_place_left(xs: &mut [Limb], ys: &[Limb], zs: &[Limb]) -> bool {\n    assert!(ys.len() > 1);\n    assert!(zs.len() > 1);\n    let mut scratch = limbs_mul(ys, zs);\n    assert!(xs.len() >= scratch.len() - 1);\n    if *scratch.last().unwrap() == 0 {\n        scratch.pop();\n    }\n    let borrow = limbs_cmp(xs, &scratch) == Less;\n    if !borrow {\n        assert!(!limbs_sub_greater_in_place_left(xs, &scratch));\n    }\n    borrow\n}}\n\nfn sub_mul_panic<S: Display, T: Display, U: Display>(a: S, b: T, c: U) -> ! {\n    panic!(\"Cannot perform sub_mul. a: {a}, b: {b}, c: {c}\");\n}\n\nimpl SubMul<Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking all three by value.\n    ///\n    /// $$\n    /// f(x, y, z) = x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).sub_mul(Natural::from(3u32), Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .sub_mul(Natural::from(0x10000u32), Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    fn sub_mul(self, y: Self, z: Self) -> Self {\n        self.checked_sub_mul(y, z)\n            .expect(\"Natural sub_mul_assign cannot have a negative result\")\n    }\n}\n\nimpl<'a> SubMul<Self, &'a Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first two by\n    /// value and the third by reference.\n    ///\n    /// $$\n    /// f(x, y, z) = x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).sub_mul(Natural::from(3u32), &Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .sub_mul(Natural::from(0x10000u32), &Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    fn sub_mul(self, y: Self, z: &'a Self) -> Self {\n        self.checked_sub_mul(y, z)\n            .expect(\"Natural sub_mul_assign cannot have a negative result\")\n    }\n}\n\nimpl<'a> SubMul<&'a Self, Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first and third\n    /// by value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y, z) = x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).sub_mul(&Natural::from(3u32), Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .sub_mul(&Natural::from(0x10000u32), Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    fn sub_mul(self, y: &'a Self, z: Self) -> Self {\n        self.checked_sub_mul(y, z)\n            .expect(\"Natural sub_mul_assign cannot have a negative result\")\n    }\n}\n\nimpl<'a, 'b> SubMul<&'a Self, &'b Self> for Natural {\n    type Output = Self;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking the first by value\n    /// and the second and third by reference.\n    ///\n    /// $$\n    /// f(x, y, z) = x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(20u32).sub_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(10u32)\n    ///         .pow(12)\n    ///         .sub_mul(&Natural::from(0x10000u32), &Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    fn sub_mul(self, y: &'a Self, z: &'b Self) -> Self {\n        self.checked_sub_mul(y, z)\n            .expect(\"Natural sub_mul_assign cannot have a negative result\")\n    }\n}\n\nimpl SubMul<&Natural, &Natural> for &Natural {\n    type Output = Natural;\n\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s, taking all three by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y, z) = x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n, m) = O(m + n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMul};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     (&Natural::from(20u32)).sub_mul(&Natural::from(3u32), &Natural::from(4u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     (&Natural::from(10u32).pow(12))\n    ///         .sub_mul(&Natural::from(0x10000u32), &Natural::from(0x10000u32)),\n    ///     995705032704u64\n    /// );\n    /// ```\n    fn sub_mul(self, y: &Natural, z: &Natural) -> Natural {\n        self.checked_sub_mul(y, z).unwrap_or_else(|| {\n            sub_mul_panic(self, y, z);\n        })\n    }\n}\n\nimpl SubMulAssign<Self, Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking both\n    /// [`Natural`]s on the right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.sub_mul_assign(Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.sub_mul_assign(Natural::from(0x10000u32), Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: Self, z: Self) {\n        assert!(\n            !self.sub_mul_assign_no_panic(y, z),\n            \"Natural sub_mul_assign cannot have a negative result\"\n        );\n    }\n}\n\nimpl<'a> SubMulAssign<Self, &'a Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking the first\n    /// [`Natural`] on the right-hand side by value and the second by reference.\n    ///\n    /// $$\n    /// x \\gets x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.sub_mul_assign(Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.sub_mul_assign(Natural::from(0x10000u32), &Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: Self, z: &'a Self) {\n        assert!(\n            !self.sub_mul_assign_val_ref_no_panic(y, z),\n            \"Natural sub_mul_assign cannot have a negative result\"\n        );\n    }\n}\n\nimpl<'a> SubMulAssign<&'a Self, Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking the first\n    /// [`Natural`] on the right-hand side by reference and the second by value.\n    ///\n    /// $$\n    /// x \\gets x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.sub_mul_assign(&Natural::from(3u32), Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.sub_mul_assign(&Natural::from(0x10000u32), Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: &'a Self, z: Self) {\n        assert!(\n            !self.sub_mul_assign_ref_val_no_panic(y, z),\n            \"Natural sub_mul_assign cannot have a negative result\"\n        );\n    }\n}\n\nimpl<'a, 'b> SubMulAssign<&'a Self, &'b Self> for Natural {\n    /// Subtracts a [`Natural`] by the product of two other [`Natural`]s in place, taking both\n    /// [`Natural`]s on the right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x - yz.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m + n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(y.significant_bits(),\n    /// z.significant_bits())`, and $m$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `y * z` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, SubMulAssign};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(20u32);\n    /// x.sub_mul_assign(&Natural::from(3u32), &Natural::from(4u32));\n    /// assert_eq!(x, 8);\n    ///\n    /// let mut x = Natural::from(10u32).pow(12);\n    /// x.sub_mul_assign(&Natural::from(0x10000u32), &Natural::from(0x10000u32));\n    /// assert_eq!(x, 995705032704u64);\n    /// ```\n    fn sub_mul_assign(&mut self, y: &'a Self, z: &'b Self) {\n        assert!(\n            !self.sub_mul_assign_ref_ref_no_panic(y, z),\n            \"Natural sub_mul_assign cannot have a negative result\"\n        );\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1997, 1999-2016, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse core::cmp::Ordering::{self, *};\nuse core::mem::swap;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::slices::{slice_leading_zeros, slice_test_zero};\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, compares the two `Natural`s.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_cmp` from `gmp.h`, GMP 6.2.1.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\npub_crate_test! {limbs_cmp_same_length(xs: &[Limb], ys: &[Limb]) -> Ordering {\n    assert_eq!(xs.len(), ys.len());\n    xs.iter().rev().cmp(ys.iter().rev())\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, compares\n// the two `Natural`s. Neither limb slice can contain trailing zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if the last element of `xs` or `ys` is zero.\npub_crate_test! {limbs_cmp(xs: &[Limb], ys: &[Limb]) -> Ordering {\n    assert_ne!(xs.last(), Some(&0));\n    assert_ne!(ys.last(), Some(&0));\n    xs.len()\n        .cmp(&ys.len())\n        .then_with(|| limbs_cmp_same_length(xs, ys))\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns\n// their normalized comparison. See `Natural::cmp_normalized` for details.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if either `xs` or `ys` is empty, or if the last element of `xs` or `ys` is zero.\npub_test! {limbs_cmp_normalized(xs: &[Limb], ys: &[Limb]) -> Ordering {\n    let mut xs = &xs[slice_leading_zeros(xs)..];\n    let mut ys = &ys[slice_leading_zeros(ys)..];\n    let mut xs_leading = LeadingZeros::leading_zeros(*xs.last().unwrap());\n    assert_ne!(xs_leading, Limb::WIDTH);\n    let mut ys_leading = LeadingZeros::leading_zeros(*ys.last().unwrap());\n    assert_ne!(ys_leading, Limb::WIDTH);\n    let mut xs_len = xs.len();\n    let mut ys_len = ys.len();\n    let mut swapped = false;\n    match xs_leading.cmp(&ys_leading) {\n        Equal => {\n            return match xs_len.cmp(&ys_len) {\n                Equal => limbs_cmp_same_length(xs, ys),\n                Less => {\n                    let leading_cmp = limbs_cmp_same_length(xs, &ys[ys_len - xs_len..]);\n                    if leading_cmp == Greater {\n                        Greater\n                    } else {\n                        Less\n                    }\n                }\n                Greater => {\n                    let leading_cmp = limbs_cmp_same_length(&xs[xs_len - ys_len..], ys);\n                    if leading_cmp == Less {\n                        Less\n                    } else {\n                        Greater\n                    }\n                }\n            };\n        }\n        Less => {\n            swap(&mut xs, &mut ys);\n            swap(&mut xs_leading, &mut ys_leading);\n            swap(&mut xs_len, &mut ys_len);\n            swapped = true;\n        }\n        _ => {}\n    }\n    let xs_shift = xs_leading - ys_leading;\n    let comp_xs_shift = Limb::WIDTH - xs_shift;\n    let mut xs_i = xs_len - 1;\n    let mut ys_i = ys_len - 1;\n    loop {\n        let y = ys[ys_i];\n        let xs_hi = xs[xs_i];\n        let xs_lo = if xs_i == 0 { 0 } else { xs[xs_i - 1] };\n        let x = (xs_hi << xs_shift) | (xs_lo >> comp_xs_shift);\n        let cmp = x.cmp(&y);\n        if cmp != Equal {\n            return if swapped { cmp.reverse() } else { cmp };\n        }\n        if xs_i == 0 {\n            return if ys_i == 0 {\n                Equal\n            } else if swapped {\n                Greater\n            } else {\n                Less\n            };\n        } else if ys_i == 0 {\n            return if xs_lo << xs_shift == 0 && slice_test_zero(&xs[..xs_i - 1]) {\n                Equal\n            } else if swapped {\n                Less\n            } else {\n                Greater\n            };\n        }\n        xs_i -= 1;\n        ys_i -= 1;\n    }\n}}\n\nimpl PartialOrd for Natural {\n    /// Compares two [`Natural`]s.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp(other))\n    }\n}\n\nimpl Ord for Natural {\n    /// Compares two [`Natural`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::from(123u32) > Natural::from(122u32));\n    /// assert!(Natural::from(123u32) >= Natural::from(122u32));\n    /// assert!(Natural::from(123u32) < Natural::from(124u32));\n    /// assert!(Natural::from(123u32) <= Natural::from(124u32));\n    /// ```\n    fn cmp(&self, other: &Self) -> Ordering {\n        if core::ptr::eq(self, other) {\n            return Equal;\n        }\n        match (self, other) {\n            (&Self(Small(ref x)), &Self(Small(ref y))) => x.cmp(y),\n            (&Self(Small(_)), &Self(Large(_))) => Less,\n            (&Self(Large(_)), &Self(Small(_))) => Greater,\n            (&Self(Large(ref xs)), &Self(Large(ref ys))) => limbs_cmp(xs, ys),\n        }\n    }\n}\n\nimpl Natural {\n    /// Returns a result of a comparison between two [`Natural`]s as if each had been multiplied by\n    /// some power of 2 to bring it into the interval $[1, 2)$.\n    ///\n    /// That is, the comparison is equivalent to a comparison between $f(x)$ and $f(y)$, where\n    /// $$\n    /// f(n) = n2^{\\lfloor\\log_2 n \\rfloor}.\n    /// $$\n    ///\n    /// The multiplication is not actually performed.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if either argument is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// // 1 == 1.0 * 2^0, 4 == 1.0 * 2^2\n    /// // 1.0 == 1.0\n    /// assert_eq!(\n    ///     Natural::from(1u32).cmp_normalized(&Natural::from(4u32)),\n    ///     Equal\n    /// );\n    ///\n    /// // 5 == 1.25 * 2^2, 6 == 1.5 * 2^2\n    /// // 1.25 < 1.5\n    /// assert_eq!(\n    ///     Natural::from(5u32).cmp_normalized(&Natural::from(6u32)),\n    ///     Less\n    /// );\n    ///\n    /// // 3 == 1.5 * 2^1, 17 == 1.0625 * 2^4\n    /// // 1.5 > 1.0625\n    /// assert_eq!(\n    ///     Natural::from(3u32).cmp_normalized(&Natural::from(17u32)),\n    ///     Greater\n    /// );\n    ///\n    /// // 9 == 1.125 * 2^3, 36 == 1.125 * 2^5\n    /// // 1.125 == 1.125\n    /// assert_eq!(\n    ///     Natural::from(9u32).cmp_normalized(&Natural::from(36u32)),\n    ///     Equal\n    /// );\n    /// ```\n    pub fn cmp_normalized(&self, other: &Self) -> Ordering {\n        assert_ne!(*self, 0);\n        assert_ne!(*other, 0);\n        if core::ptr::eq(self, other) {\n            return Equal;\n        }\n        match (self, other) {\n            (&Self(Small(x)), &Self(Small(y))) => {\n                let leading_x = x.leading_zeros();\n                let leading_y = y.leading_zeros();\n                match leading_x.cmp(&leading_y) {\n                    Equal => x.cmp(&y),\n                    Less => x.cmp(&(y << (leading_y - leading_x))),\n                    Greater => (x << (leading_x - leading_y)).cmp(&y),\n                }\n            }\n            (&Self(Small(x)), &Self(Large(ref ys))) => limbs_cmp_normalized(&[x], ys),\n            (&Self(Large(ref xs)), &Self(Small(y))) => limbs_cmp_normalized(xs, &[y]),\n            (&Self(Large(ref xs)), &Self(Large(ref ys))) => limbs_cmp_normalized(xs, ys),\n        }\n    }\n\n    #[cfg(feature = \"float_helpers\")]\n    pub fn cmp_normalized_no_shift(&self, other: &Self) -> Ordering {\n        assert_ne!(*self, 0);\n        assert_ne!(*other, 0);\n        if core::ptr::eq(self, other) {\n            return Equal;\n        }\n        match (self, other) {\n            (&Self(Small(x)), &Self(Small(y))) => x.cmp(&y),\n            (Self(Small(x)), &Self(Large(ref ys))) => {\n                let (ys_last, ys_init) = ys.split_last().unwrap();\n                let c = x.cmp(ys_last);\n                if c != Equal {\n                    c\n                } else if slice_test_zero(ys_init) {\n                    Equal\n                } else {\n                    Less\n                }\n            }\n            (&Self(Large(ref xs)), Self(Small(y))) => {\n                let (xs_last, xs_init) = xs.split_last().unwrap();\n                let c = xs_last.cmp(y);\n                if c != Equal {\n                    c\n                } else if slice_test_zero(xs_init) {\n                    Equal\n                } else {\n                    Greater\n                }\n            }\n            (&Self(Large(ref xs)), &Self(Large(ref ys))) => {\n                let xs_len = xs.len();\n                let ys_len = ys.len();\n                match xs_len.cmp(&ys_len) {\n                    Equal => xs.iter().rev().cmp(ys.iter().rev()),\n                    Less => {\n                        let (ys_lo, ys_hi) = ys.split_at(ys_len - xs_len);\n                        let c = xs.iter().rev().cmp(ys_hi.iter().rev());\n                        if c != Equal {\n                            c\n                        } else if slice_test_zero(ys_lo) {\n                            Equal\n                        } else {\n                            Less\n                        }\n                    }\n                    Greater => {\n                        let (xs_lo, xs_hi) = xs.split_at(xs_len - ys_len);\n                        let c = xs_hi.iter().rev().cmp(ys.iter().rev());\n                        if c != Equal {\n                            c\n                        } else if slice_test_zero(xs_lo) {\n                            Equal\n                        } else {\n                            Greater\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nmacro_rules! impl_eq_abs {\n    ($t: ident) => {\n        impl EqAbs<$t> for Natural {\n            /// Determines whether the absolute values of a [`Natural`] and a primitive float are\n            /// equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                *self == other.abs()\n            }\n        }\n\n        impl EqAbs<Natural> for $t {\n            /// Determines whether the absolute values of a primitive float and a [`Natural`] are\n            /// equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Natural) -> bool {\n                self.abs() == *other\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_eq_abs);\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl EqAbs<$t> for Natural {\n            /// Determines whether the absolute values of a [`Natural`] and a primitive unsigned\n            /// integer are equal.\n            ///\n            /// Since both values are non-negative, this is the same as ordinary equality.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                self == other\n            }\n        }\n\n        impl EqAbs<Natural> for $t {\n            /// Determines whether the absolute values of a primitive unsigned integer and a\n            /// [`Natural`] are equal.\n            ///\n            /// Since both values are non-negative, this is the same as ordinary equality.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Natural) -> bool {\n                self == other\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl EqAbs<$t> for Natural {\n            /// Determines whether the absolute values of a [`Natural`] and a primitive signed\n            /// integer are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                *self == other.unsigned_abs()\n            }\n        }\n\n        impl EqAbs<Natural> for $t {\n            /// Determines whether the absolute values of a primitive signed integer and a\n            /// [`Natural`] are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Natural) -> bool {\n                self.unsigned_abs() == *other\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Comparison of [`Natural`](crate::natural::Natural)s.\npub mod cmp;\n/// Equality of the absolute values of a [`Natural`](crate::natural::Natural) and a primitive float.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::basic::traits::{NegativeInfinity, Zero};\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::from(123u32).eq_abs(&123.0), true);\n/// assert_eq!(Natural::from(123u32).eq_abs(&5.0), false);\n/// assert_eq!(Natural::from(123u32).eq_abs(&-123.0), true);\n/// assert_eq!(Natural::from(123u32).eq_abs(&-5.0), false);\n/// assert_eq!(Natural::ZERO.eq_abs(&0.0), true);\n/// assert_eq!(Natural::ZERO.eq_abs(&-0.0), true);\n/// assert_eq!(Natural::ZERO.eq_abs(&f64::NAN), false);\n/// assert_eq!(Natural::ZERO.eq_abs(&f64::INFINITY), false);\n/// assert_eq!(Natural::ZERO.eq_abs(&f64::NEGATIVE_INFINITY), false);\n///\n/// assert_eq!(123.0.eq_abs(&Natural::from(123u32)), true);\n/// assert_eq!(5.0.eq_abs(&Natural::from(123u32)), false);\n/// assert_eq!((-123.0).eq_abs(&Natural::from(123u32)), true);\n/// assert_eq!((-5.0).eq_abs(&Natural::from(123u32)), false);\n/// assert_eq!(0.0.eq_abs(&Natural::ZERO), true);\n/// assert_eq!((-0.0).eq_abs(&Natural::ZERO), true);\n/// assert_eq!(f64::NAN.eq_abs(&Natural::ZERO), false);\n/// assert_eq!(f64::INFINITY.eq_abs(&Natural::ZERO), false);\n/// assert_eq!(f64::NEGATIVE_INFINITY.eq_abs(&Natural::ZERO), false);\n/// ```\npub mod eq_abs_primitive_float;\n/// Equality of the absolute values of a [`Natural`](crate::natural::Natural) and a primitive\n/// integer.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::from(123u32).eq_abs(&123u32), true);\n/// assert_eq!(Natural::from(123u32).eq_abs(&5u32), false);\n///\n/// assert_eq!(Natural::from(123u32).eq_abs(&123u64), true);\n/// assert_eq!(Natural::from(123u32).eq_abs(&5u64), false);\n///\n/// assert_eq!(Natural::from(123u32).eq_abs(&123i64), true);\n/// assert_eq!(Natural::from(123u32).eq_abs(&-123i64), true);\n///\n/// assert_eq!(123u8.eq_abs(&Natural::from(123u32)), true);\n/// assert_eq!(5u8.eq_abs(&Natural::from(123u32)), false);\n///\n/// assert_eq!(123u64.eq_abs(&Natural::from(123u32)), true);\n/// assert_eq!(5u64.eq_abs(&Natural::from(123u32)), false);\n///\n/// assert_eq!(123i64.eq_abs(&Natural::from(123u32)), true);\n/// assert_eq!((-123i64).eq_abs(&Natural::from(123u32)), true);\n/// ```\npub mod eq_abs_primitive_int;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Natural`](crate::natural::Natural)s and primitive floats.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::from(123u32).gt_abs(&-122.5f32));\n/// assert!(Natural::from(123u32).lt_abs(&f32::NEGATIVE_INFINITY));\n/// assert!((-122.5f32).lt_abs(&Natural::from(123u32)));\n/// assert!(f32::NEGATIVE_INFINITY.gt_abs(&Natural::from(123u32)));\n/// ```\npub mod partial_cmp_abs_primitive_float;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Natural`](crate::natural::Natural)s and primitive integers.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::from(122u32).lt_abs(&123u64));\n/// assert!(Natural::from(122u32).le_abs(&123u64));\n/// assert!(Natural::from(123u32).lt_abs(&124u64));\n/// assert!(Natural::from(123u32).le_abs(&124u64));\n/// assert!(Natural::from(10u32).pow(12).gt_abs(&123u64));\n/// assert!(Natural::from(10u32).pow(12).ge_abs(&123u64));\n///\n/// assert!(Natural::from(122u32).lt_abs(&-123i64));\n/// assert!(Natural::from(122u32).le_abs(&-123i64));\n/// assert!(Natural::from(124u32).gt_abs(&-123i64));\n/// assert!(Natural::from(124u32).ge_abs(&-123i64));\n/// assert!(Natural::from(10u32).pow(12).gt_abs(&123i64));\n/// assert!(Natural::from(10u32).pow(12).ge_abs(&123i64));\n///\n/// assert!(123u64.gt_abs(&Natural::from(122u32)));\n/// assert!(123u64.ge_abs(&Natural::from(122u32)));\n/// assert!(124u64.gt_abs(&Natural::from(123u32)));\n/// assert!(124u64.ge_abs(&Natural::from(123u32)));\n/// assert!(123u64.lt_abs(&Natural::from(10u32).pow(12)));\n/// assert!(123u64.le_abs(&Natural::from(10u32).pow(12)));\n///\n/// assert!((-123i64).gt_abs(&Natural::from(122u32)));\n/// assert!((-123i64).ge_abs(&Natural::from(122u32)));\n/// assert!((-123i64).lt_abs(&Natural::from(124u32)));\n/// assert!((-123i64).le_abs(&Natural::from(124u32)));\n/// assert!(123i64.lt_abs(&Natural::from(10u32).pow(12)));\n/// assert!(123i64.le_abs(&Natural::from(10u32).pow(12)));\n/// ```\npub mod partial_cmp_abs_primitive_int;\n/// Comparison of [`Natural`](crate::natural::Natural)s and primitive floats.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::from(123u32) > 122.5f32);\n/// assert!(Natural::from(123u32) < f32::INFINITY);\n/// assert!(122.5f32 < Natural::from(123u32));\n/// assert!(f32::INFINITY > Natural::from(123u32));\n/// ```\npub mod partial_cmp_primitive_float;\n/// Comparison of [`Natural`](crate::natural::Natural)s and primitive integers.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::from(123u32) > 122u32);\n/// assert!(Natural::from(123u32) >= 122u32);\n/// assert!(Natural::from(123u32) < 124u32);\n/// assert!(Natural::from(123u32) <= 124u32);\n/// assert!(Natural::from(10u32).pow(12) > 123u32);\n/// assert!(Natural::from(10u32).pow(12) >= 123u32);\n///\n/// assert!(Natural::from(123u32) > 122u8);\n/// assert!(Natural::from(123u32) >= 122u8);\n/// assert!(Natural::from(123u32) < 124u8);\n/// assert!(Natural::from(123u32) <= 124u8);\n/// assert!(Natural::from(10u32).pow(12) > 123u8);\n/// assert!(Natural::from(10u32).pow(12) >= 123u8);\n///\n/// assert!(Natural::from(123u32) > 122u64);\n/// assert!(Natural::from(123u32) >= 122u64);\n/// assert!(Natural::from(123u32) < 124u64);\n/// assert!(Natural::from(123u32) <= 124u64);\n/// assert!(Natural::from(10u32).pow(12) > 123u64);\n/// assert!(Natural::from(10u32).pow(12) >= 123u64);\n///\n/// assert!(Natural::from(123u32) > 122i64);\n/// assert!(Natural::from(123u32) >= 122i64);\n/// assert!(Natural::from(123u32) < 124i64);\n/// assert!(Natural::from(123u32) <= 124i64);\n/// assert!(Natural::from(123u32) > -124i64);\n/// assert!(Natural::from(123u32) >= -124i64);\n/// assert!(Natural::from(10u32).pow(12) > 123i64);\n/// assert!(Natural::from(10u32).pow(12) >= 123i64);\n///\n/// assert!(122u32 < Natural::from(123u32));\n/// assert!(122u32 <= Natural::from(123u32));\n/// assert!(124u32 > Natural::from(123u32));\n/// assert!(124u32 >= Natural::from(123u32));\n/// assert!(123u32 < Natural::from(10u32).pow(12));\n/// assert!(123u32 <= Natural::from(10u32).pow(12));\n///\n/// assert!(122u8 < Natural::from(123u32));\n/// assert!(122u8 <= Natural::from(123u32));\n/// assert!(124u8 > Natural::from(123u32));\n/// assert!(124u8 >= Natural::from(123u32));\n/// assert!(123u8 < Natural::from(10u32).pow(12));\n/// assert!(123u8 <= Natural::from(10u32).pow(12));\n///\n/// assert!(122u64 < Natural::from(123u32));\n/// assert!(122u64 <= Natural::from(123u32));\n/// assert!(124u64 > Natural::from(123u32));\n/// assert!(124u64 >= Natural::from(123u32));\n/// assert!(123u64 < Natural::from(10u32).pow(12));\n/// assert!(123u64 <= Natural::from(10u32).pow(12));\n///\n/// assert!(122i64 < Natural::from(123u32));\n/// assert!(122i64 <= Natural::from(123u32));\n/// assert!(124i64 > Natural::from(123u32));\n/// assert!(124i64 >= Natural::from(123u32));\n/// assert!(-124i64 < Natural::from(123u32));\n/// assert!(-124i64 <= Natural::from(123u32));\n/// assert!(123i64 < Natural::from(10u32).pow(12));\n/// assert!(123i64 <= Natural::from(10u32).pow(12));\n/// ```\npub mod partial_cmp_primitive_int;\n/// Equality of [`Natural`](crate::natural::Natural)s and primitive floats.\n///\n/// # partial_eq\n/// ```\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::from(123u32) == 123.0f32);\n/// assert!(Natural::from(123u32) != -5.0f32);\n///\n/// assert!(123.0f32 == Natural::from(123u32));\n/// assert!(-5.0f32 != Natural::from(123u32));\n/// ```\npub mod partial_eq_primitive_float;\n/// Equality of [`Natural`](crate::natural::Natural)s and primitive integers.\n///\n/// # partial_eq\n/// ```\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::from(123u32) == 123u32);\n/// assert!(Natural::from(123u32) != 5u32);\n///\n/// assert!(Natural::from(123u32) == 123u64);\n/// assert!(Natural::from(123u32) != 5u64);\n///\n/// assert!(Natural::from(123u32) == 123i64);\n/// assert!(Natural::from(123u32) != -123i64);\n///\n/// assert!(123u8 == Natural::from(123u32));\n/// assert!(5u8 != Natural::from(123u32));\n///\n/// assert!(123u64 == Natural::from(123u32));\n/// assert!(5u64 != Natural::from(123u32));\n///\n/// assert!(123i64 == Natural::from(123u32));\n/// assert!(-123i64 != Natural::from(123u32));\n/// ```\npub mod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, IntegerMantissaAndExponent};\nuse malachite_base::num::logic::traits::SignificantBits;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Natural {\n            /// Compares a [`Natural`] to the absolute value of a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_abs_primitive_float#partial_cmp_abs).\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                if other.is_nan() {\n                    None\n                } else if !other.is_finite() {\n                    Some(Less)\n                } else if *other == 0.0 {\n                    self.partial_cmp_abs(&0u32)\n                } else if *self == 0u32 {\n                    Some(Less)\n                } else {\n                    let (m, e) = other.integer_mantissa_and_exponent();\n                    let log_cmp = i64::exact_from(self.significant_bits())\n                        .cmp(&(i64::exact_from(m.significant_bits()) + e));\n                    Some(if log_cmp != Equal {\n                        log_cmp\n                    } else {\n                        self.cmp_normalized(&Natural::from(m))\n                    })\n                }\n            }\n        }\n\n        impl PartialOrdAbs<Natural> for $t {\n            /// Compares the absolute value of a primitive float to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_float#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Natural {\n            /// Compares a [`Natural`] to an unsigned primitive integer.\n            ///\n            /// Since both values are non-negative, this is the same as ordinary\n            /// [`partial_cmp`](PartialOrd::partial_cmp).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                self.partial_cmp(other)\n            }\n        }\n\n        impl PartialOrdAbs<Natural> for $t {\n            /// Compares a value of unsigned primitive integer type to a [`Natural`].\n            ///\n            /// Since both values are non-negative, this is the same as ordinary\n            /// [`partial_cmp`](PartialOrd::partial_cmp).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {\n                self.partial_cmp(other)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Natural {\n            /// Compares a [`Natural`] to the absolute value of a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                self.partial_cmp(&other.unsigned_abs())\n            }\n        }\n\n        impl PartialOrdAbs<Natural> for $t {\n            /// Compares the absolute value of a signed primitive integer to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::conversion::traits::{ExactFrom, IntegerMantissaAndExponent};\nuse malachite_base::num::logic::traits::SignificantBits;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Natural {\n            /// Compares a [`Natural`] to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                if other.is_nan() {\n                    None\n                } else if *other < 0.0 {\n                    Some(Greater)\n                } else if !other.is_finite() {\n                    Some(Less)\n                } else if *other == 0.0 {\n                    self.partial_cmp(&0u32)\n                } else if *self == 0u32 {\n                    Some(Less)\n                } else {\n                    let (m, e) = other.integer_mantissa_and_exponent();\n                    let log_cmp = i64::exact_from(self.significant_bits())\n                        .cmp(&(i64::exact_from(m.significant_bits()) + e));\n                    Some(if log_cmp != Equal {\n                        log_cmp\n                    } else {\n                        self.cmp_normalized(&Natural::from(m))\n                    })\n                }\n            }\n        }\n\n        impl PartialOrd<Natural> for $t {\n            /// Compares a primitive float to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_ceiling, limb_to_bit_count};\nuse crate::platform::Limb;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nmacro_rules! impl_partial_ord_limb {\n    ($u: ident) => {\n        impl PartialOrd<$u> for Natural {\n            /// Compares a [`Natural`] to a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            fn partial_cmp(&self, other: &$u) -> Option<Ordering> {\n                match self {\n                    Natural(Small(small)) => small.partial_cmp(other),\n                    Natural(Large(_)) => Some(Greater),\n                }\n            }\n        }\n\n        impl PartialOrd<Natural> for $u {\n            /// Compares a [`Limb`](crate#limbs) to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_partial_ord_smaller_than_limb {\n    ($u: ident) => {\n        impl PartialOrd<$u> for Natural {\n            /// Compares a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// smaller than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$u) -> Option<Ordering> {\n                self.partial_cmp(&Limb::from(*other))\n            }\n        }\n\n        impl PartialOrd<Natural> for $u {\n            /// Compares a value of an unsigned primitive integer type that's smaller than a\n            /// [`Limb`](crate#limbs) to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_partial_ord_larger_than_limb_or_usize {\n    ($u: ident) => {\n        impl PartialOrd<Natural> for $u {\n            /// Compares a value of an unsigned primitive integer type that's larger than a\n            /// [`Limb`](crate#limbs) to a [`Natural`]. This implementation is general enough to\n            /// also work for [`usize`], regardless of whether it is equal in width to\n            /// [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_partial_ord_larger_than_limb {\n    ($u: ident) => {\n        impl_partial_ord_larger_than_limb_or_usize!($u);\n\n        impl PartialOrd<$u> for Natural {\n            /// Compares a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// larger than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$u) -> Option<Ordering> {\n                let limb_count = bit_to_limb_count_ceiling(other.significant_bits());\n                let limb_count_cmp = usize::wrapping_from(self.limb_count()).cmp(&limb_count);\n                if limb_count_cmp != Equal || limb_count == 0 {\n                    return Some(limb_count_cmp);\n                }\n                let width = Limb::WIDTH;\n                let mut i = limb_to_bit_count(limb_count);\n                let mut mask = $u::from(Limb::MAX) << (i - width);\n                for limb in self.limbs().rev() {\n                    i -= width;\n                    let limb_cmp = limb.cmp(&Limb::wrapping_from((other & mask) >> i));\n                    if limb_cmp != Equal {\n                        return Some(limb_cmp);\n                    }\n                    mask >>= width;\n                }\n                Some(Equal)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Natural {\n            /// Compares a [`Natural`] to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                if *other < 0 {\n                    Some(Greater)\n                } else {\n                    self.partial_cmp(&other.unsigned_abs())\n                }\n            }\n        }\n\n        impl PartialOrd<Natural> for $t {\n            /// Compares a signed primitive integer to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\n\nimpl_partial_ord_smaller_than_limb!(u8);\nimpl_partial_ord_smaller_than_limb!(u16);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_partial_ord_limb!(u32);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_partial_ord_smaller_than_limb!(u32);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_partial_ord_larger_than_limb!(u64);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_partial_ord_limb!(u64);\nimpl_partial_ord_larger_than_limb!(u128);\nimpl_partial_ord_larger_than_limb_or_usize!(usize);\n\napply_to_signeds!(impl_signed);\n\nimpl PartialOrd<usize> for Natural {\n    /// Compares a [`Natural`] to a [`usize`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n    #[inline]\n    fn partial_cmp(&self, other: &usize) -> Option<Ordering> {\n        if USIZE_IS_U32 {\n            self.partial_cmp(&u32::wrapping_from(*other))\n        } else {\n            assert_eq!(usize::WIDTH, u64::WIDTH);\n            self.partial_cmp(&u64::wrapping_from(*other))\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialEq<$t> for Natural {\n            /// Determines whether a [`Natural`] is equal to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            fn eq(&self, other: &$t) -> bool {\n                if !other.is_finite() {\n                    false\n                } else if *other == 0.0 {\n                    *self == 0u32\n                } else if *other < 1.0 || *self == 0u32 {\n                    false\n                } else {\n                    let (m, e) = other.integer_mantissa_and_exponent();\n                    if let Ok(e) = u64::try_from(e) {\n                        self.significant_bits() == m.significant_bits() + e\n                            && self.cmp_normalized(&Natural::from(m)) == Equal\n                    } else {\n                        false\n                    }\n                }\n            }\n        }\n\n        impl PartialEq<Natural> for $t {\n            /// Determines whether a primitive float is equal to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Natural) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-nz/src/natural/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse malachite_base::num::conversion::traits::WrappingFrom;\n\nmacro_rules! impl_partial_eq_limb {\n    ($u: ident) => {\n        impl PartialEq<$u> for Natural {\n            /// Determines whether a [`Natural`] is equal to a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            fn eq(&self, other: &$u) -> bool {\n                match self {\n                    Natural(Small(x)) => *x == *other,\n                    Natural(Large(_)) => false,\n                }\n            }\n        }\n\n        impl PartialEq<Natural> for $u {\n            /// Determines whether a [`Limb`](crate#limbs) is equal to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Natural) -> bool {\n                other == self\n            }\n        }\n    };\n}\n\nmacro_rules! impl_partial_eq_smaller_than_limb {\n    ($u: ident) => {\n        impl PartialEq<$u> for Natural {\n            /// Determines whether a [`Natural`] is equal to a value of an unsigned primitive\n            /// integer type that's smaller than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[allow(clippy::cmp_owned)]\n            #[inline]\n            fn eq(&self, other: &$u) -> bool {\n                *self == Limb::from(*other)\n            }\n        }\n\n        impl PartialEq<Natural> for $u {\n            /// Determines whether a value of an unsigned primitive integer type that's smaller than\n            /// a [`Limb`](crate#limbs) is equal to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[allow(clippy::cmp_owned)]\n            #[inline]\n            fn eq(&self, other: &Natural) -> bool {\n                Limb::from(*self) == *other\n            }\n        }\n    };\n}\n\nmacro_rules! impl_partial_eq_larger_than_limb_or_usize {\n    ($u: ident) => {\n        impl PartialEq<Natural> for $u {\n            /// Determines whether a value of an unsigned primitive integer type that's larger than\n            /// a [`Limb`](crate#limbs) is equal to a [`Natural`].\n            ///\n            /// This implementation is general enough to also work for [`usize`], regardless of\n            /// whether it is equal in width to [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Natural) -> bool {\n                other == self\n            }\n        }\n    };\n}\n\nmacro_rules! impl_partial_eq_larger_than_limb {\n    ($u: ident) => {\n        impl_partial_eq_larger_than_limb_or_usize!($u);\n\n        impl PartialEq<$u> for Natural {\n            /// Determines whether a [`Natural`] is equal to a value of an unsigned primitive\n            /// integer type that's larger than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &$u) -> bool {\n                let mut other = *other;\n                for limb in self.limbs() {\n                    if other == 0 || limb != Limb::wrapping_from(other) {\n                        return false;\n                    }\n                    other >>= Limb::WIDTH;\n                }\n                other == 0\n            }\n        }\n    };\n}\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialEq<$t> for Natural {\n            /// Determines whether a [`Natural`] is equal to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            fn eq(&self, other: &$t) -> bool {\n                *other >= 0 && *self == other.unsigned_abs()\n            }\n        }\n\n        impl PartialEq<Natural> for $t {\n            /// Determines whether a signed primitive integer is equal to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Natural) -> bool {\n                other == self\n            }\n        }\n    };\n}\n\nimpl_partial_eq_smaller_than_limb!(u8);\nimpl_partial_eq_smaller_than_limb!(u16);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_partial_eq_limb!(u32);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_partial_eq_smaller_than_limb!(u32);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_partial_eq_larger_than_limb!(u64);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_partial_eq_limb!(u64);\nimpl_partial_eq_larger_than_limb!(u128);\nimpl_partial_eq_larger_than_limb_or_usize!(usize);\n\napply_to_signeds!(impl_signed);\n\nimpl PartialEq<usize> for Natural {\n    /// Determines whether a [`Natural`] is equal to a [`usize`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// See [here](super::partial_eq_primitive_int#partial_eq).\n    #[inline]\n    fn eq(&self, other: &usize) -> bool {\n        if USIZE_IS_U32 {\n            *self == u32::wrapping_from(*other)\n        } else {\n            assert_eq!(usize::WIDTH, u64::WIDTH);\n            *self == u64::wrapping_from(*other)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/digits/general_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_bc_get_str`, `mpn_dc_get_str`, `mpn_get_str`, `mpn_bc_set_str`, `mpn_dc_set_str`,\n//      `mpn_set_str`, `powtab_decide`, `mpn_compute_powtab_mul`, `mpn_compute_powtab_div`, and\n//      `mpn_compute_powtab` contributed to the GNU project by Torbjörn Granlund.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::add::{\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n};\nuse crate::natural::arithmetic::div_exact::limbs_div_exact_limb_in_place;\nuse crate::natural::arithmetic::div_mod::{\n    limbs_div_limb_in_place_mod, limbs_div_mod_extra_in_place, limbs_div_mod_qs_to_out_rs_to_ns,\n};\nuse crate::natural::arithmetic::mul::limb::{limbs_mul_limb_to_out, limbs_slice_mul_limb_in_place};\nuse crate::natural::arithmetic::mul::toom::TUNE_PROGRAM_BUILD;\nuse crate::natural::arithmetic::mul::{limbs_mul_to_out, limbs_mul_to_out_scratch_len};\nuse crate::natural::arithmetic::square::{limbs_square_to_out, limbs_square_to_out_scratch_len};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::natural::{Natural, limb_to_bit_count};\nuse crate::platform::{\n    BASES, DoubleLimb, FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD, Limb, MP_BASES_BIG_BASE_10,\n    MP_BASES_BIG_BASE_INVERTED_10, MP_BASES_CHARS_PER_LIMB_10, MP_BASES_NORMALIZATION_STEPS_10,\n};\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse itertools::Itertools;\nuse malachite_base::fail_on_untested_path;\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, CheckedMul, DivAssignMod, DivMod, DivisibleByPowerOf2, ModPowerOf2Assign,\n    Parity, PowerOf2, ShrRound, ShrRoundAssign, SquareAssign, XMulYToZZ,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, ExactInto, PowerOf2Digits, WrappingFrom, WrappingInto,\n};\nuse malachite_base::num::logic::traits::{LeadingZeros, SignificantBits, TrailingZeros};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::{slice_set_zero, slice_test_zero, slice_trailing_zeros};\n\n// TODO tune\nconst GET_STR_THRESHOLD_LIMIT: usize = 150;\n\n// TODO tune\n#[cfg(feature = \"test_build\")]\npub const GET_STR_PRECOMPUTE_THRESHOLD: usize = 29;\n\n#[cfg(not(feature = \"test_build\"))]\nconst GET_STR_PRECOMPUTE_THRESHOLD: usize = 29;\n\n// # Worst-case complexity\n// Constant time and additional memory.\npub_const_test! {get_chars_per_limb(base: u64) -> usize {\n    BASES[base as usize].0\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\nconst fn get_log_base_of_2(base: u64) -> Limb {\n    BASES[base as usize].1\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\nconst fn get_log_2_of_base(base: u64) -> Limb {\n    BASES[base as usize].2\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\nconst fn get_big_base(base: u64) -> Limb {\n    BASES[base as usize].3\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\nconst fn get_big_base_inverted(base: u64) -> Limb {\n    BASES[base as usize].4\n}\n\n// Compute the number of base-`base` digits corresponding to `limb_count` limbs, rounding down.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `DIGITS_IN_BASE_PER_LIMB` from `gmp-impl.h`, where `res` is returned.\nfn digits_in_base_per_limb(limb_count: usize, base: u64) -> u64 {\n    u64::exact_from(\n        Limb::x_mul_y_to_zz(\n            get_log_base_of_2(base),\n            Limb::exact_from(limb_count) << Limb::LOG_WIDTH,\n        )\n        .0,\n    )\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `DIGITS_IN_BASEGT2_FROM_BITS` from `gmp-impl.h`, GMP 6.2.1, where `res` is\n// returned and `base` is not a power of 2.\nfn limbs_digit_count_helper(bit_count: u64, base: u64) -> u64 {\n    u64::exact_from(Limb::x_mul_y_to_zz(get_log_base_of_2(base) + 1, Limb::exact_from(bit_count)).0)\n        .checked_add(1)\n        .unwrap()\n}\n\n// The result is either exact or one too big.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `MPN_SIZEINBASE` from `gmp-impl.h`, GMP 6.2.1, where result is returned and\n// base is not a power of 2.\npub_crate_test! {limbs_digit_count(xs: &[Limb], base: u64) -> u64 {\n    assert!(base > 2);\n    assert!(base < u64::wrapping_from(BASES.len()));\n    assert!(!base.is_power_of_two());\n    let size = xs.len();\n    if size == 0 {\n        1\n    } else {\n        limbs_digit_count_helper(\n            limb_to_bit_count(size)\n                - LeadingZeros::leading_zeros(*xs.last().unwrap()),\n            base,\n        )\n    }\n}}\n\nmacro_rules! base_10_normalization_step {\n    ($j: expr, $buffer: ident, $i: ident, $frac: ident) => {\n        if MP_BASES_NORMALIZATION_STEPS_10 <= $j {\n            let digit;\n            (digit, $frac) = Limb::x_mul_y_to_zz($frac, 10);\n            $buffer[$i] = T::wrapping_from(digit);\n            $i += 1;\n        }\n    };\n}\n\n// TODO tune\nconst RP_LEN: usize = if TUNE_PROGRAM_BUILD {\n    GET_STR_THRESHOLD_LIMIT\n} else {\n    GET_STR_PRECOMPUTE_THRESHOLD\n};\n\n// Convert `xs` to digits in base `base`, and put the result in `out`. Generate `len` digits,\n// possibly padding with zeros to the left. If `len` is zero, generate as many characters as\n// required. Return the number of significant digits. Complexity is quadratic; intended for small\n// conversions.\n//\n// - `base` must not be a power of 2, and 2 < `base` < 256.\n// - `xs.len()` < `GET_STR_PRECOMPUTE_THRESHOLD`.\n// - `len` must be at least as large as the actual number of digits.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_bc_get_str` from `mpn/generic/get_str.c`, GMP 6.2.1.\npub_crate_test! {limbs_to_digits_small_base_basecase<T: PrimitiveUnsigned>(\n    out: &mut [T],\n    len: usize,\n    xs: &[Limb],\n    base: u64,\n) -> usize {\n    assert!(base > 2);\n    assert!(base < 256);\n    assert!(out.len() >= len);\n    let mut xs_len = xs.len();\n    assert!(xs_len < GET_STR_PRECOMPUTE_THRESHOLD);\n    // Allocate memory for largest possible string, given that we only get here for operands with\n    // `xs_len` < GET_STR_PRECOMPUTE_THRESHOLD and that the smallest base is 3. 7 / 11 is an\n    // approximation to 1 / log_2(3).\n    const BUFFER_LEN: usize = (RP_LEN << Limb::LOG_WIDTH) * 7 / 11;\n    let mut buffer = [T::ZERO; BUFFER_LEN];\n    let mut rs = [0; RP_LEN];\n    let mut i = BUFFER_LEN;\n    if base == 10 {\n        // Special case code for base 10 so that the compiler has a chance to optimize things.\n        const DIGIT_SHIFT: u64 = Limb::WIDTH - 4;\n        const LIMIT: usize = MP_BASES_CHARS_PER_LIMB_10\n            - 4usize.wrapping_sub(MP_BASES_NORMALIZATION_STEPS_10 as usize);\n        rs[1..=xs_len].copy_from_slice(xs);\n        while xs_len > 1 {\n            limbs_div_mod_extra_in_place(\n                &mut rs[..=xs_len],\n                1,\n                MP_BASES_BIG_BASE_10,\n                MP_BASES_BIG_BASE_INVERTED_10,\n                MP_BASES_NORMALIZATION_STEPS_10,\n            );\n            if rs[xs_len] == 0 {\n                xs_len -= 1;\n            }\n            let mut frac = rs[0].wrapping_add(1);\n            i -= MP_BASES_CHARS_PER_LIMB_10;\n            // Use the fact that 10 in binary is 1010, with the lowest bit 0. After a few\n            // `x_mul_y_to_zz`s, we will have accumulated enough low zeros to use a plain multiply.\n            base_10_normalization_step!(0, buffer, i, frac);\n            base_10_normalization_step!(1, buffer, i, frac);\n            base_10_normalization_step!(2, buffer, i, frac);\n            base_10_normalization_step!(3, buffer, i, frac);\n            frac.shr_round_assign(4, Ceiling);\n            for _ in 0..LIMIT {\n                frac *= 10;\n                let digit = frac >> DIGIT_SHIFT;\n                buffer[i] = T::wrapping_from(digit);\n                i += 1;\n                frac.mod_power_of_2_assign(DIGIT_SHIFT);\n            }\n            i -= MP_BASES_CHARS_PER_LIMB_10;\n        }\n        let mut r = rs[1];\n        while r != 0 {\n            let d = r.div_assign_mod(10);\n            i -= 1;\n            buffer[i] = T::wrapping_from(d);\n        }\n    } else {\n        // not base 10\n        let digits_per_limb = get_chars_per_limb(base);\n        let big_base = get_big_base(base);\n        let big_base_inverted = get_big_base_inverted(base);\n        let normalization_steps = LeadingZeros::leading_zeros(big_base);\n        let limb_base = Limb::wrapping_from(base);\n        rs[1..=xs_len].copy_from_slice(&xs[..xs_len]);\n        while xs_len > 1 {\n            limbs_div_mod_extra_in_place(\n                &mut rs[..=xs_len],\n                1,\n                big_base,\n                big_base_inverted,\n                normalization_steps,\n            );\n            if rs[xs_len] == 0 {\n                xs_len -= 1;\n            }\n            let mut frac = rs[0].wrapping_add(1);\n            let old_i = i;\n            i -= digits_per_limb;\n            for d in &mut buffer[i..old_i] {\n                let digit;\n                (digit, frac) = Limb::x_mul_y_to_zz(frac, limb_base);\n                *d = T::wrapping_from(digit);\n            }\n        }\n        let mut r = rs[1];\n        while r != 0 {\n            let digit = r.div_assign_mod(limb_base);\n            i -= 1;\n            buffer[i] = T::wrapping_from(digit);\n        }\n    }\n    let nonzero_len = BUFFER_LEN - i;\n    let zero_len = len.saturating_sub(nonzero_len); // Accounts for len == 0 case\n    let (out_zero, out_nonzero) = out.split_at_mut(zero_len);\n    slice_set_zero(out_zero);\n    out_nonzero[..nonzero_len].copy_from_slice(&buffer[i..]);\n    zero_len + nonzero_len\n}}\n\n// This is equivalent to `powers` from `gmp-impl.h`, GMP 6.2.1.\nstruct PowerTableIndicesRow {\n    start: usize, // actual power value\n    len: usize,\n    shift: usize,          // weight of lowest limb, in limb base B\n    digits_in_base: usize, // number of corresponding digits\n}\n\n#[cfg(feature = \"test_build\")]\npub struct PowerTableRow<'a> {\n    power: &'a [Limb],\n    shift: usize,          // weight of lowest limb, in limb base B\n    digits_in_base: usize, // number of corresponding digits\n}\n\n#[cfg(not(feature = \"test_build\"))]\nstruct PowerTableRow<'a> {\n    power: &'a [Limb],\n    shift: usize,          // weight of lowest limb, in limb base B\n    digits_in_base: usize, // number of corresponding digits\n}\n\n// TODO tune\nconst DIV_1_VS_MUL_1_PERCENT: usize = 150;\n\n// TODO tune\nconst HAVE_MPN_COMPUTE_POWTAB_MUL: bool = DIV_1_VS_MUL_1_PERCENT > 120;\n\n// TODO tune\nconst HAVE_MPN_COMPUTE_POWTAB_DIV: bool = DIV_1_VS_MUL_1_PERCENT < 275;\n\n#[cfg(feature = \"test_build\")]\npub enum PowerTableAlgorithm {\n    Mul,\n    Div,\n}\n\n#[cfg(not(feature = \"test_build\"))]\nenum PowerTableAlgorithm {\n    Mul,\n    Div,\n}\n\n// # Worst-case complexity\n// $T(n) = O(\\log n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs_len`.\n//\n// This is equivalent to `powtab_decide` from `mpn/compute_powtab.c`, GMP 6.2.1.\npub_test! {limbs_choose_power_table_algorithm(\n    exptab: &mut [usize],\n    xs_len: usize,\n    base: u64,\n) -> (usize, PowerTableAlgorithm) {\n    let digits_per_limb = get_chars_per_limb(base);\n    let mut number_of_powers = 0;\n    let mut power: usize = xs_len.shr_round(1, Ceiling).0;\n    while power != 1 {\n        exptab[number_of_powers] = power * digits_per_limb;\n        number_of_powers += 1;\n        power = (power + 1) >> 1;\n    }\n    exptab[number_of_powers] = digits_per_limb;\n    if HAVE_MPN_COMPUTE_POWTAB_MUL && HAVE_MPN_COMPUTE_POWTAB_DIV {\n        let power = xs_len - 1;\n        let n = xs_len.shr_round(1, Ceiling).0;\n        let mut mul_cost = 1;\n        let mut div_cost = 1;\n        for i in (1..number_of_powers).rev() {\n            let pow = (power >> i) + 1;\n            if n != pow << (i - 1) {\n                if pow.odd() {\n                    div_cost += pow;\n                }\n                mul_cost += if pow > 2 && pow.even() { pow << 1 } else { pow };\n            } else if pow.odd() {\n                mul_cost += pow;\n                div_cost += pow;\n            }\n        }\n        div_cost = div_cost * DIV_1_VS_MUL_1_PERCENT / 100;\n        (\n            number_of_powers,\n            if mul_cost <= div_cost {\n                PowerTableAlgorithm::Mul\n            } else {\n                PowerTableAlgorithm::Div\n            },\n        )\n    } else if HAVE_MPN_COMPUTE_POWTAB_MUL {\n        (number_of_powers, PowerTableAlgorithm::Mul)\n    } else if HAVE_MPN_COMPUTE_POWTAB_DIV {\n        (number_of_powers, PowerTableAlgorithm::Div)\n    } else {\n        panic!(\"no powtab function available\");\n    }\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_str_powtab_alloc` from `gmp-impl.h`, GMP 6.2.1.\nconst fn limbs_digits_power_table_scratch_len(xs_len: usize) -> usize {\n    xs_len + ((Limb::WIDTH as usize) << 1)\n}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_dc_get_str_itch` from `gmp-impl.h`, GMP 6.2.1.\nconst fn limbs_to_digits_small_base_divide_and_conquer_scratch_len(xs_len: usize) -> usize {\n    xs_len + (Limb::WIDTH as usize)\n}\n\n// # Worst-case complexity\n// $T(n) = O(2^n n \\log n)$\n//\n// $M(n) = O(2^n n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `power_len`.\n//\n// This is equivalent to `mpn_compute_powtab_mul` from `mpn/compute_powtab.c`, GMP 6.2.1.\npub_test! {limbs_compute_power_table_using_mul<'a>(\n    power_table_memory: &'a mut [Limb],\n    base: u64,\n    exponents: &[usize],\n    power_len: usize,\n) -> Vec<PowerTableRow<'a>> {\n    let mut power_indices = Vec::new();\n    let big_base = get_big_base(base);\n    let digits_per_limb = get_chars_per_limb(base);\n    let mut digits_in_base = digits_per_limb;\n    let (head, mut remainder) = power_table_memory.split_first_mut().unwrap();\n    *head = big_base;\n    (remainder[1], remainder[0]) = Limb::x_mul_y_to_zz(big_base, big_base);\n    power_indices.push(PowerTableIndicesRow {\n        start: 0,\n        len: 1,\n        digits_in_base,\n        shift: 0,\n    });\n    // `a` and `n` are the start index and length of a power subslice.\n    let (mut start, mut len, mut shift) = if remainder[0] == 0 {\n        (2, 1, 1)\n    } else {\n        (1, 2, 0)\n    };\n    digits_in_base <<= 1;\n    power_indices.push(PowerTableIndicesRow {\n        start,\n        len,\n        shift,\n        digits_in_base,\n    });\n    let start_index = if exponents[0] == digits_per_limb << power_len {\n        let power;\n        (power, remainder) = remainder[shift..].split_at_mut(len);\n        let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(len)];\n        limbs_square_to_out(remainder, power, &mut square_scratch);\n        start = 3;\n        isize::exact_from(power_len) - 2\n    } else {\n        if (digits_in_base + digits_per_limb) << (power_len - 2) <= exponents[0] {\n            // a = 3, sometimes adjusted to 4.\n            let power;\n            (power, remainder) = remainder[shift..].split_at_mut(len);\n            let carry = limbs_mul_limb_to_out::<DoubleLimb, Limb>(remainder, power, big_base);\n            remainder[len] = carry;\n            if carry != 0 {\n                len += 1;\n            }\n            start = 3;\n            digits_in_base += digits_per_limb;\n            if remainder[1] == 0 {\n                start = 4;\n                len -= 1;\n                shift += 1;\n            }\n            power_indices.push(PowerTableIndicesRow {\n                start,\n                len,\n                shift,\n                digits_in_base,\n            });\n            let power;\n            (power, remainder) = remainder[start - 3..].split_at_mut(7 - start);\n            let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(len)];\n            limbs_square_to_out(remainder, &power[..len], &mut square_scratch);\n            start = 7;\n        } else {\n            remainder[2] = remainder[start - 1];\n            remainder[3] = remainder[start];\n            remainder = &mut remainder[2..];\n            power_indices.push(PowerTableIndicesRow {\n                start: 3,\n                len,\n                digits_in_base,\n                shift,\n            });\n            let power;\n            (power, remainder) = remainder.split_at_mut(3);\n            let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(len)];\n            limbs_square_to_out(remainder, &power[..len], &mut square_scratch);\n            start = 6;\n        }\n        isize::exact_from(power_len) - 3\n    };\n    if start_index >= 0 {\n        for i in (0..=start_index).rev() {\n            let increment = (len + 1) << 1;\n            digits_in_base <<= 1;\n            len <<= 1;\n            if remainder[len - 1] == 0 {\n                len -= 1;\n            }\n            shift <<= 1;\n            let mut adjust = 0;\n            if remainder[0] == 0 {\n                len -= 1;\n                shift += 1;\n                remainder = &mut remainder[1..];\n                adjust += 1;\n            }\n            // Adjust new value if it is too small as input to the next squaring.\n            if (digits_in_base + digits_per_limb) << i <= exponents[0] {\n                let carry = limbs_slice_mul_limb_in_place(&mut remainder[..len], big_base);\n                remainder[len] = carry;\n                if carry != 0 {\n                    len += 1;\n                }\n                digits_in_base += digits_per_limb;\n                if remainder[0] == 0 {\n                    len -= 1;\n                    shift += 1;\n                    adjust += 1;\n                    remainder = &mut remainder[1..];\n                }\n            }\n            power_indices.push(PowerTableIndicesRow {\n                start: start + adjust,\n                len,\n                digits_in_base,\n                shift,\n            });\n            start += increment;\n            let power;\n            (power, remainder) = remainder.split_at_mut(increment - adjust);\n            if i != 0 {\n                let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(len)];\n                limbs_square_to_out(remainder, &power[..len], &mut square_scratch);\n            }\n        }\n        for (&exponent, row) in exponents[1..usize::exact_from(start_index + 2)]\n            .iter()\n            .rev()\n            .zip(power_indices[power_len - usize::exact_from(start_index + 1)..].iter_mut())\n        {\n            if row.digits_in_base < exponent {\n                let start = row.start;\n                let end = start + row.len;\n                let carry =\n                    limbs_slice_mul_limb_in_place(&mut power_table_memory[start..end], big_base);\n                power_table_memory[end] = carry;\n                if carry != 0 {\n                    row.len += 1;\n                }\n                assert!(row.digits_in_base + digits_per_limb == exponent);\n                row.digits_in_base = exponent;\n                if power_table_memory[start] == 0 {\n                    row.start += 1;\n                    row.len -= 1;\n                    row.shift += 1;\n                }\n            }\n        }\n    }\n    let mut powers = Vec::with_capacity(power_indices.len());\n    let mut remainder: &mut [Limb] = power_table_memory;\n    let mut consumed_len = 0;\n    for row in power_indices {\n        remainder = &mut remainder[row.start - consumed_len..];\n        let power;\n        (power, remainder) = remainder.split_at_mut(row.len);\n        consumed_len = row.start + power.len();\n        powers.push(PowerTableRow {\n            power,\n            digits_in_base: row.digits_in_base,\n            shift: row.shift,\n        });\n    }\n    powers\n}}\n\n// # Worst-case complexity\n// $T(n) = O(2^n n \\log n)$\n//\n// $M(n) = O(2^n n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `power_len`.\n//\n// This is equivalent to `mpn_compute_powtab_div` from `mpn/compute_powtab.c`, GMP 6.2.1.\npub_test! {limbs_compute_power_table_using_div<'a>(\n    power_table_memory: &'a mut [Limb],\n    base: u64,\n    exponents: &[usize],\n    power_len: usize,\n) -> Vec<PowerTableRow<'a>> {\n    let big_base = get_big_base(base);\n    let digits_per_limb = get_chars_per_limb(base);\n    let big_base_trailing_zeros = TrailingZeros::trailing_zeros(big_base);\n    power_table_memory[0] = big_base;\n    let mut powers = Vec::with_capacity(power_len + 1);\n    let (mut power, mut remainder) = power_table_memory.split_at_mut(1);\n    powers.push(PowerTableRow {\n        power: &*power,\n        digits_in_base: digits_per_limb,\n        shift: 0,\n    });\n    let mut digits_in_base = digits_per_limb;\n    let mut len = 1;\n    let mut shift = 0;\n    for &exp in exponents[..power_len].iter().rev() {\n        let two_n = len << 1;\n        let mut square_scratch = vec![0; limbs_square_to_out_scratch_len(power.len())];\n        limbs_square_to_out(remainder, power, &mut square_scratch);\n        len = two_n - 1;\n        if remainder[len] != 0 {\n            len += 1;\n        }\n        digits_in_base <<= 1;\n        if digits_in_base != exp {\n            limbs_div_exact_limb_in_place(&mut remainder[..len], big_base);\n            if remainder[len - 1] == 0 {\n                len -= 1;\n            }\n            digits_in_base -= digits_per_limb;\n        }\n        shift <<= 1;\n        // Strip low zero limbs, but be careful to keep the result divisible by big_base.\n        let mut adjust = 0;\n        while remainder[adjust] == 0\n            && remainder[adjust + 1].divisible_by_power_of_2(big_base_trailing_zeros)\n        {\n            adjust += 1;\n        }\n        len -= adjust;\n        shift += adjust;\n        remainder = &mut remainder[adjust..];\n        let next_power;\n        (next_power, remainder) = remainder.split_at_mut(two_n);\n        power = &mut next_power[..len];\n        powers.push(if power[0] == 0 {\n            PowerTableRow {\n                power: &power[1..],\n                digits_in_base,\n                shift: shift + 1,\n            }\n        } else {\n            PowerTableRow {\n                power,\n                shift,\n                digits_in_base,\n            }\n        });\n    }\n    powers\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs_len`.\n//\n// This is equivalent to `mpn_compute_powtab` from `mpn/compute_powtab.c`, GMP 6.2.1.\npub_test! {limbs_compute_power_table(\n    power_table_memory: &mut [Limb],\n    xs_len: usize,\n    base: u64,\n    forced_algorithm: Option<PowerTableAlgorithm>,\n) -> (usize, Vec<PowerTableRow<'_>>) {\n    let mut exponents = [0; Limb::WIDTH as usize];\n    let (power_len, auto_algorithm) =\n        limbs_choose_power_table_algorithm(&mut exponents, xs_len, base);\n    let algorithm = forced_algorithm.unwrap_or(auto_algorithm);\n    let powers = match algorithm {\n        PowerTableAlgorithm::Mul => {\n            limbs_compute_power_table_using_mul(power_table_memory, base, &exponents, power_len)\n        }\n        PowerTableAlgorithm::Div => {\n            limbs_compute_power_table_using_div(power_table_memory, base, &exponents, power_len)\n        }\n    };\n    (power_len, powers)\n}}\n\n// TODO tune\nconst GET_STR_DC_THRESHOLD: usize = 15;\n\n// Convert `xs` to a string with a base as represented in `powers`, and put the string in `out`.\n// Generate `len` characters, possibly padding with zeros to the left. If `len` is zero, generate as\n// many characters as required. Return a pointer immediately after the last digit of the result\n// string. This uses divide-and-conquer and is intended for large conversions.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_dc_get_str` from `mpn/generic/get_str.c`, GMP 6.2.1.\nfn limbs_to_digits_small_base_divide_and_conquer<T: PrimitiveUnsigned>(\n    out: &mut [T],\n    mut len: usize,\n    xs: &mut [Limb],\n    base: u64,\n    powers: &[PowerTableRow],\n    i: usize,\n    scratch: &mut [Limb],\n) -> usize {\n    let xs_len = xs.len();\n    if xs_len < GET_STR_DC_THRESHOLD {\n        if xs_len != 0 {\n            limbs_to_digits_small_base_basecase(out, len, xs, base)\n        } else {\n            fail_on_untested_path(\"limbs_to_digits_small_base_divide_and_conquer, xs_len == 0\");\n            slice_set_zero(&mut out[..len]);\n            len\n        }\n    } else {\n        let power = &powers[i];\n        let power_len = power.power.len();\n        let shift = power.shift;\n        let total_len = power_len + shift;\n        if xs_len < total_len\n            || xs_len == total_len && limbs_cmp_same_length(&xs[shift..], power.power) == Less\n        {\n            fail_on_untested_path(\n                \"limbs_to_digits_small_base_divide_and_conquer, \\\n                xs_len < total_len || \\\n                xs_len == total_len && \\\n                limbs_cmp_same_length(&xs[shift..], power.power) == Less\",\n            );\n            limbs_to_digits_small_base_divide_and_conquer(\n                out,\n                len,\n                xs,\n                base,\n                powers,\n                i - 1,\n                scratch,\n            )\n        } else {\n            let power = &powers[i];\n            limbs_div_mod_qs_to_out_rs_to_ns(scratch, &mut xs[shift..], power.power);\n            let mut q_len = xs_len - total_len;\n            if scratch[q_len] != 0 {\n                q_len += 1;\n            }\n            assert!(\n                q_len < total_len\n                    || q_len == total_len\n                        && limbs_cmp_same_length(&scratch[shift..total_len], power.power) == Less\n            );\n            if len != 0 {\n                len -= powers[i].digits_in_base;\n            }\n            let (scratch_lo, scratch_hi) = scratch.split_at_mut(q_len);\n            let next_index = limbs_to_digits_small_base_divide_and_conquer(\n                out,\n                len,\n                scratch_lo,\n                base,\n                powers,\n                i - 1,\n                scratch_hi,\n            );\n            limbs_to_digits_small_base_divide_and_conquer(\n                &mut out[next_index..],\n                power.digits_in_base,\n                &mut xs[..total_len],\n                base,\n                powers,\n                i - 1,\n                scratch,\n            ) + next_index\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_crate_test! {limbs_to_digits_small_base_no_alg_specified<T: PrimitiveUnsigned>(\n    out: &mut [T],\n    base: u64,\n    xs: &mut [Limb],\n) -> usize {\n    limbs_to_digits_small_base(out, base, xs, None)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_get_str` from `mpn/generic/get_str.c`, GMP 6.2.1, where `un != 0` and\n// base is not a power of 2.\npub_test! {limbs_to_digits_small_base<T: PrimitiveUnsigned>(\n    out: &mut [T],\n    base: u64,\n    xs: &mut [Limb],\n    forced_algorithm: Option<PowerTableAlgorithm>,\n) -> usize {\n    let xs_len = xs.len();\n    if xs_len == 0 {\n        0\n    } else if xs_len < GET_STR_PRECOMPUTE_THRESHOLD {\n        limbs_to_digits_small_base_basecase(out, 0, xs, base)\n    } else {\n        // Allocate one large block for the powers of big_base.\n        let mut power_table_memory = vec![0; limbs_digits_power_table_scratch_len(xs_len)];\n        // Compute a table of powers, were the largest power is >= sqrt(U).\n        let digits_len = digits_in_base_per_limb(xs_len, base);\n        let len = 1 + usize::exact_from(digits_len) / get_chars_per_limb(base);\n        let (power_len, powers) =\n            limbs_compute_power_table(&mut power_table_memory, len, base, forced_algorithm);\n        // Using our precomputed powers, convert our number.\n        let mut scratch =\n            vec![0; limbs_to_digits_small_base_divide_and_conquer_scratch_len(xs_len)];\n        limbs_to_digits_small_base_divide_and_conquer(\n            out,\n            0,\n            xs,\n            base,\n            &powers,\n            power_len,\n            &mut scratch,\n        )\n    }\n}}\n\n// Returns digits in ascending order.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `digits.len()`.\npub_test! {limbs_to_digits_basecase<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n    digits: &mut Vec<T>,\n    xs: &mut [Limb],\n    base: Limb,\n) {\n    assert!(base >= 2);\n    assert!(xs.len() > 1);\n    assert!(T::convertible_from(base));\n    let mut digits_per_limb = 0;\n    let mut big_base = 1;\n    while let Some(next) = big_base.checked_mul(base) {\n        big_base = next;\n        digits_per_limb += 1;\n    }\n    while !slice_test_zero(xs) {\n        let mut big_digit = limbs_div_limb_in_place_mod(xs, big_base);\n        for _ in 0..digits_per_limb - 1 {\n            digits.push(T::wrapping_from(big_digit.div_assign_mod(base)));\n        }\n        digits.push(T::wrapping_from(big_digit));\n    }\n    let trailing_zeros = slice_trailing_zeros(digits);\n    digits.truncate(digits.len() - trailing_zeros);\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `digits.len()`.\npub_test! {to_digits_asc_naive_primitive<T: for<'a> ExactFrom<&'a Natural> + PrimitiveUnsigned>(\n    digits: &mut Vec<T>,\n    x: &Natural,\n    base: T,\n) where\n    Natural: From<T>,\n{\n    assert!(base > T::ONE);\n    let mut remainder = x.clone();\n    let nat_base = Natural::from(base);\n    while remainder != 0 {\n        digits.push(T::exact_from(&remainder.div_assign_mod(&nat_base)));\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O((n^2/m) \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `x.significant_bits()`, and $m$ is\n// `base.significant_bits()`.\npub_test! {to_digits_asc_naive(digits: &mut Vec<Natural>, x: &Natural, base: &Natural) {\n    assert!(*base > 1);\n    let mut remainder = x.clone();\n    while remainder != 0 {\n        digits.push(remainder.div_assign_mod(base));\n    }\n}}\n\n// TODO tune\nconst TO_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD: u64 = 50;\nconst SQRT_MAX_LIMB: Limb = (1 << (Limb::WIDTH >> 1)) - 1;\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bits`.\nfn compute_powers_for_to_digits(base: &Natural, bits: u64) -> Vec<Natural> {\n    if bits / base.significant_bits() < TO_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD {\n        return Vec::new();\n    }\n    let limit = (bits + 3).shr_round(1, Ceiling).0;\n    let mut powers = Vec::new();\n    let mut power = base.clone();\n    loop {\n        powers.push(power.clone());\n        power.square_assign();\n        if power.significant_bits() >= limit {\n            break;\n        }\n    }\n    powers.push(power);\n    powers\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\nfn to_digits_asc_divide_and_conquer_limb<\n    T: ConvertibleFrom<Limb> + for<'a> ExactFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    digits: &mut Vec<T>,\n    mut x: Natural,\n    base: Limb,\n    powers: &[Natural],\n    power_index: usize,\n) where\n    Limb: Digits<T>,\n    Natural: From<T>,\n{\n    let bits = x.significant_bits();\n    if bits / base.significant_bits() < TO_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD {\n        if base <= SQRT_MAX_LIMB {\n            match x {\n                Natural(Small(x)) => {\n                    digits.extend_from_slice(&x.to_digits_asc(&T::wrapping_from(base)));\n                }\n                Natural(Large(ref mut xs)) => limbs_to_digits_basecase(digits, xs, base),\n            }\n        } else {\n            to_digits_asc_naive_primitive(digits, &x, T::exact_from(base));\n        }\n    } else {\n        let (q, r) = x.div_mod(&powers[power_index]);\n        let start_len = digits.len();\n        to_digits_asc_divide_and_conquer_limb(digits, r, base, powers, power_index - 1);\n        if q != 0 {\n            for _ in digits.len() - start_len..1 << power_index {\n                digits.push(T::ZERO);\n            }\n            to_digits_asc_divide_and_conquer_limb(digits, q, base, powers, power_index - 1);\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\nfn to_digits_asc_divide_and_conquer(\n    digits: &mut Vec<Natural>,\n    x: &Natural,\n    base: &Natural,\n    powers: &[Natural],\n    power_index: usize,\n) {\n    let bits = x.significant_bits();\n    if bits / base.significant_bits() < TO_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD {\n        to_digits_asc_naive(digits, x, base);\n    } else {\n        let (q, r) = x.div_mod(&powers[power_index]);\n        let start_len = digits.len();\n        to_digits_asc_divide_and_conquer(digits, &r, base, powers, power_index - 1);\n        if q != 0 {\n            for _ in digits.len() - start_len..1 << power_index {\n                digits.push(Natural::ZERO);\n            }\n            to_digits_asc_divide_and_conquer(digits, &q, base, powers, power_index - 1);\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\npub_test! {to_digits_asc_limb<\n    T: ConvertibleFrom<Limb> + for<'a> ExactFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    x: &Natural,\n    base: Limb,\n) -> Vec<T>\nwhere\n    Limb: Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert!(base >= 2);\n    if let Some(log_base) = base.checked_log_base_2() {\n        x.to_power_of_2_digits_asc(log_base)\n    } else {\n        let t_base = T::exact_from(base);\n        match x {\n            Natural(Small(x)) => x.to_digits_asc(&t_base),\n            Natural(Large(xs)) => {\n                if base < 256 {\n                    let mut digits =\n                        vec![\n                            T::ZERO;\n                            usize::exact_from(limbs_digit_count(xs, u64::wrapping_from(base)))\n                        ];\n                    let mut xs = xs.clone();\n                    let len = limbs_to_digits_small_base(\n                        &mut digits,\n                        u64::wrapping_from(base),\n                        &mut xs,\n                        None,\n                    );\n                    digits.truncate(len);\n                    digits.reverse();\n                    digits\n                } else {\n                    let powers = compute_powers_for_to_digits(\n                        &From::<Limb>::from(base),\n                        x.significant_bits(),\n                    );\n                    let mut digits = Vec::new();\n                    to_digits_asc_divide_and_conquer_limb(\n                        &mut digits,\n                        x.clone(),\n                        base,\n                        &powers,\n                        powers.len().saturating_sub(1),\n                    );\n                    digits\n                }\n            }\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\npub_test! {to_digits_desc_limb<\n    T: ConvertibleFrom<Limb> + for<'a> ExactFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    x: &Natural,\n    base: Limb,\n) -> Vec<T>\nwhere\n    Limb: Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert!(base >= 2);\n    if let Some(log_base) = base.checked_log_base_2() {\n        x.to_power_of_2_digits_desc(log_base)\n    } else {\n        let t_base = T::exact_from(base);\n        match x {\n            Natural(Small(x)) => x.to_digits_desc(&t_base),\n            Natural(Large(xs)) => {\n                if base < 256 {\n                    let mut digits =\n                        vec![\n                            T::ZERO;\n                            usize::exact_from(limbs_digit_count(xs, u64::wrapping_from(base)))\n                        ];\n                    let mut xs = xs.clone();\n                    let len = limbs_to_digits_small_base(\n                        &mut digits,\n                        u64::wrapping_from(base),\n                        &mut xs,\n                        None,\n                    );\n                    digits.truncate(len);\n                    digits\n                } else {\n                    let powers = compute_powers_for_to_digits(\n                        &From::<Limb>::from(base),\n                        x.significant_bits(),\n                    );\n                    let mut digits = Vec::new();\n                    to_digits_asc_divide_and_conquer_limb(\n                        &mut digits,\n                        x.clone(),\n                        base,\n                        &powers,\n                        powers.len().saturating_sub(1),\n                    );\n                    digits.reverse();\n                    digits\n                }\n            }\n        }\n    }\n}}\n\n// optimized for large base\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\npub_test! {to_digits_asc_large(x: &Natural, base: &Natural) -> Vec<Natural> {\n    if *x == 0 {\n        Vec::new()\n    } else if x < base {\n        vec![x.clone()]\n    } else if let Some(log_base) = base.checked_log_base_2() {\n        x.to_power_of_2_digits_asc(log_base)\n    } else {\n        match x {\n            Natural(Large(_)) => {\n                let powers = compute_powers_for_to_digits(base, x.significant_bits());\n                let mut digits = Vec::new();\n                to_digits_asc_divide_and_conquer(\n                    &mut digits,\n                    x,\n                    base,\n                    &powers,\n                    powers.len().saturating_sub(1),\n                );\n                digits\n            }\n            _ => panic!(\"x must be large\"),\n        }\n    }\n}}\n\n// optimized for large base\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\npub_test! {to_digits_desc_large(x: &Natural, base: &Natural) -> Vec<Natural> {\n    if *x == 0 {\n        Vec::new()\n    } else if x < base {\n        vec![x.clone()]\n    } else if let Some(log_base) = base.checked_log_base_2() {\n        x.to_power_of_2_digits_desc(log_base)\n    } else {\n        match x {\n            Natural(Large(_)) => {\n                let powers = compute_powers_for_to_digits(base, x.significant_bits());\n                let mut digits = Vec::new();\n                to_digits_asc_divide_and_conquer(\n                    &mut digits,\n                    x,\n                    base,\n                    &powers,\n                    powers.len().saturating_sub(1),\n                );\n                digits.reverse();\n                digits\n            }\n            _ => panic!(\"x must be large\"),\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {from_digits_desc_naive_primitive<T: PrimitiveUnsigned>(\n    xs: &[T],\n    base: T\n) -> Option<Natural>\nwhere\n    Natural: From<T>,\n{\n    assert!(base > T::ONE);\n    let mut n = Natural::ZERO;\n    let n_base = Natural::from(base);\n    for &x in xs {\n        if x >= base {\n            return None;\n        }\n        n *= &n_base;\n        n += Natural::from(x);\n    }\n    Some(n)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(m^2 n \\log (m n) \\log\\log (m n))$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `base.significant_bits()`, and $m$ is\n// `xs.len()`.\npub_test! {from_digits_desc_naive(xs: &[Natural], base: &Natural) -> Option<Natural> {\n    assert!(*base > 1);\n    let mut n = Natural::ZERO;\n    for x in xs {\n        if x >= base {\n            return None;\n        }\n        n *= base;\n        n += x;\n    }\n    Some(n)\n}}\n\n// Compute the number of limbs corresponding to `digit_count` base-`base` digits, rounding up.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `LIMBS_PER_DIGIT_IN_BASE` from `gmp-impl.h`, where `res` is returned and\n// `base` is not a power of 2.\npub_test! {limbs_per_digit_in_base(digit_count: usize, base: u64) -> u64 {\n    (u64::exact_from(Limb::x_mul_y_to_zz(get_log_2_of_base(base), Limb::exact_from(digit_count)).0)\n        >> (Limb::LOG_WIDTH - 3))\n        + 2\n}}\n\n// The input digits are in descending order.\n//\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_bc_set_str` from `mpn/generic/set_str.c`, GMP 6.2.1, where `base` is\n// not a power of 2.\npub_test! {limbs_from_digits_small_base_basecase<T: PrimitiveUnsigned>(\n    out: &mut [Limb],\n    xs: &[T],\n    base: u64,\n) -> Option<usize>\nwhere\n    Limb: WrappingFrom<T>,\n{\n    let xs_len = xs.len();\n    assert!(base > 2);\n    assert!(base < 256);\n    assert_ne!(xs_len, 0);\n    let big_base = get_big_base(base);\n    let digits_per_limb = get_chars_per_limb(base);\n    let limb_base: Limb = base.wrapping_into();\n    let t_base = T::wrapping_from(base);\n    let mut size = 0;\n    let mut i = 0;\n    for chunk in xs[..xs_len - 1].chunks_exact(digits_per_limb) {\n        let (&chunk_head, chunk_tail) = chunk.split_first().unwrap();\n        if chunk_head >= t_base {\n            return None;\n        }\n        let mut y = Limb::wrapping_from(chunk_head);\n        if limb_base == 10 {\n            // This is a common case. Help the compiler avoid multiplication.\n            for &x in chunk_tail {\n                if x >= t_base {\n                    return None;\n                }\n                let x = Limb::wrapping_from(x);\n                assert!(x < 10);\n                y = y * 10 + x;\n            }\n        } else {\n            for &x in chunk_tail {\n                if x >= t_base {\n                    return None;\n                }\n                let x = Limb::wrapping_from(x);\n                assert!(x < limb_base);\n                y = y * limb_base + x;\n            }\n        }\n        if size == 0 {\n            if y != 0 {\n                out[0] = y;\n                size = 1;\n            }\n        } else {\n            let (out_last, out_init) = out[..=size].split_last_mut().unwrap();\n            let mut carry = limbs_slice_mul_limb_in_place(out_init, big_base);\n            if limbs_slice_add_limb_in_place(out_init, y) {\n                carry += 1;\n            }\n            if carry != 0 {\n                *out_last = carry;\n                size += 1;\n            }\n        }\n        i += digits_per_limb;\n    }\n    let mut big_base = limb_base;\n    let (&remainder_head, remainder_tail) = xs[i..].split_first().unwrap();\n    if remainder_head >= t_base {\n        return None;\n    }\n    let mut y = Limb::wrapping_from(remainder_head);\n    if limb_base == 10 {\n        // This is a common case. Help the compiler avoid multiplication.\n        for &x in remainder_tail {\n            if x >= t_base {\n                return None;\n            }\n            let x = Limb::wrapping_from(x);\n            assert!(x < 10);\n            y = y * 10 + x;\n            big_base *= 10;\n        }\n    } else {\n        for &x in remainder_tail {\n            if x >= t_base {\n                return None;\n            }\n            let x = Limb::wrapping_from(x);\n            assert!(x < limb_base);\n            y = y * limb_base + x;\n            big_base *= limb_base;\n        }\n    }\n    if size == 0 {\n        if y != 0 {\n            out[0] = y;\n            size = 1;\n        }\n    } else {\n        let (out_last, out_init) = out[..=size].split_last_mut().unwrap();\n        let mut carry = limbs_slice_mul_limb_in_place(out_init, big_base);\n        if limbs_slice_add_limb_in_place(out_init, y) {\n            carry += 1;\n        }\n        if carry != 0 {\n            *out_last = carry;\n            size += 1;\n        }\n    }\n    Some(size)\n}}\n\n// TODO tune\n\n// must be greater than get_chars_per_limb(3), which is 40 for 64-bit build\nconst SET_STR_DC_THRESHOLD: usize = 7100;\n\n// The input digits are in descending order.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_dc_set_str` from `mpn/generic/set_str.c`, GMP 6.2.1, where `base` is\n// not a power of 2.\npub_test! {limbs_from_digits_small_base_divide_and_conquer<T: PrimitiveUnsigned>(\n    out: &mut [Limb],\n    xs: &[T],\n    base: u64,\n    powers: &[PowerTableRow],\n    i: usize,\n    scratch: &mut [Limb],\n) -> Option<usize>\nwhere\n    Limb: WrappingFrom<T>,\n{\n    if i == 0 {\n        return limbs_from_digits_small_base_basecase(out, xs, base);\n    }\n    let xs_len = xs.len();\n    let power = &powers[i];\n    let len_lo = power.digits_in_base;\n    if xs_len <= len_lo {\n        return if xs_len < SET_STR_DC_THRESHOLD {\n            fail_on_untested_path(\n                \"limbs_from_digits_small_base_divide_and_conquer, xs_len < SET_STR_DC_THRESHOLD\",\n            );\n            limbs_from_digits_small_base_basecase(out, xs, base)\n        } else {\n            limbs_from_digits_small_base_divide_and_conquer(out, xs, base, powers, i - 1, scratch)\n        };\n    }\n    let len_hi = xs_len - len_lo;\n    let (xs_lo, xs_hi) = xs.split_at(len_hi);\n    assert!(len_lo >= len_hi);\n    let out_len_hi = if len_hi < SET_STR_DC_THRESHOLD {\n        limbs_from_digits_small_base_basecase(scratch, xs_lo, base)\n    } else {\n        limbs_from_digits_small_base_divide_and_conquer(scratch, xs_lo, base, powers, i - 1, out)\n    }?;\n    let shift = power.shift;\n    let adjusted_power_len = power.power.len() + shift;\n    if out_len_hi == 0 {\n        // Zero +1 limb here, to avoid reading an allocated but uninitialized limb in\n        // limbs_slice_add_limb_in_place below.\n        slice_set_zero(&mut out[..=adjusted_power_len]);\n    } else {\n        let (out_lo, out_hi) = out.split_at_mut(shift);\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(power.power.len(), out_len_hi)];\n        limbs_mul_to_out(out_hi, power.power, &scratch[..out_len_hi], &mut mul_scratch);\n        slice_set_zero(out_lo);\n    }\n    let out_len_lo = if len_lo < SET_STR_DC_THRESHOLD {\n        limbs_from_digits_small_base_basecase(scratch, xs_hi, base)\n    } else {\n        let (scratch_lo, scratch_hi) = scratch.split_at_mut(adjusted_power_len + 1);\n        limbs_from_digits_small_base_divide_and_conquer(\n            scratch_lo,\n            xs_hi,\n            base,\n            powers,\n            i - 1,\n            scratch_hi,\n        )\n    }?;\n    if out_len_lo != 0 {\n        let (out_lo, out_hi) = out.split_at_mut(out_len_lo);\n        if limbs_slice_add_same_length_in_place_left(out_lo, &scratch[..out_len_lo]) {\n            assert!(!limbs_slice_add_limb_in_place(out_hi, 1));\n        }\n    }\n    let mut n = out_len_hi + adjusted_power_len;\n    if out[n - 1] == 0 {\n        n -= 1;\n    }\n    Some(n)\n}}\n\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpn_dc_set_str_itch` from `gmp-impl.h`, GMP 6.2.1.\nconst fn limbs_from_digits_small_base_divide_and_conquer_scratch_len(xs_len: usize) -> usize {\n    xs_len + (Limb::WIDTH as usize)\n}\n\n// must be greater than get_chars_per_limb(3), which is 40 for 64-bit build\nconst SET_STR_PRECOMPUTE_THRESHOLD: usize = 7100;\n\n// The input digits are in descending order.\n//\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_set_str` from `mpn/generic/set_str.c`, GMP 6.2.1, where `base` is not\n// a power of 2.\npub_test! {limbs_from_digits_small_base<T: PrimitiveUnsigned>(\n    out: &mut [Limb],\n    xs: &[T],\n    base: u64,\n) -> Option<usize>\nwhere\n    Limb: WrappingFrom<T>,\n{\n    let xs_len = xs.len();\n    if xs_len < SET_STR_PRECOMPUTE_THRESHOLD {\n        limbs_from_digits_small_base_basecase(out, xs, base)\n    } else {\n        let chars_per_limb = get_chars_per_limb(base);\n        let len = xs_len / chars_per_limb + 1;\n        // Allocate one large block for the powers of big_base.\n        let mut power_table_memory = vec![0; limbs_digits_power_table_scratch_len(len)];\n        let (power_len, powers) =\n            limbs_compute_power_table(&mut power_table_memory, len, base, None);\n        let mut scratch = vec![0; limbs_from_digits_small_base_divide_and_conquer_scratch_len(len)];\n        limbs_from_digits_small_base_divide_and_conquer(\n            out,\n            xs,\n            base,\n            &powers,\n            power_len,\n            &mut scratch,\n        )\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n^2)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {from_digits_desc_basecase<T: PrimitiveUnsigned>(xs: &[T], base: Limb) -> Option<Natural>\nwhere\n    Limb: WrappingFrom<T>,\n{\n    assert!(base >= 2);\n    let t_base = T::try_from(base).ok()?;\n    let mut digits_per_limb = 0;\n    let mut big_base = 1;\n    while let Some(next) = big_base.checked_mul(base) {\n        big_base = next;\n        digits_per_limb += 1;\n    }\n    let big_big_base = Natural::from(big_base);\n    let mut x = Natural::ZERO;\n    for chunk in xs.rchunks(digits_per_limb).rev() {\n        for &y in chunk {\n            if y >= t_base {\n                return None;\n            }\n        }\n        let big_digit =\n            Limb::from_digits_desc(&base, chunk.iter().map(|&x| Limb::wrapping_from(x)))?;\n        x *= &big_big_base;\n        x += Natural::from(big_digit);\n    }\n    Some(x)\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n \\log n \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `digits`.\nfn compute_powers_for_from_digits(base: &Natural, digits: usize) -> Vec<Natural> {\n    if u64::exact_from(digits) * base.significant_bits() < FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    {\n        return Vec::new();\n    }\n    let limit = digits.shr_round(1u64, Ceiling).0;\n    let mut powers = Vec::new();\n    let mut power = base.clone();\n    let mut p = 1;\n    loop {\n        powers.push(power.clone());\n        if p >= limit {\n            break;\n        }\n        power.square_assign();\n        p <<= 1;\n    }\n    powers\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn from_digits_desc_divide_and_conquer_limb<T: PrimitiveUnsigned>(\n    xs: &[T],\n    base: Limb,\n    powers: &[Natural],\n    power_index: usize,\n) -> Option<Natural>\nwhere\n    Limb: WrappingFrom<T>,\n    Natural: From<T>,\n{\n    let xs_len = xs.len();\n    let b = u64::exact_from(xs_len) * base.significant_bits();\n    if power_index == 0 || b < FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD {\n        if base <= SQRT_MAX_LIMB {\n            from_digits_desc_basecase(xs, base)\n        } else {\n            from_digits_desc_naive_primitive(xs, T::exact_from(base))\n        }\n    } else {\n        let p = usize::power_of_2(power_index.exact_into());\n        if xs_len <= p {\n            from_digits_desc_divide_and_conquer_limb(xs, base, powers, power_index - 1)\n        } else {\n            let (xs_hi, xs_lo) = xs.split_at(xs_len - p);\n            let out_hi =\n                from_digits_desc_divide_and_conquer_limb(xs_hi, base, powers, power_index - 1)?;\n            let out_lo =\n                from_digits_desc_divide_and_conquer_limb(xs_lo, base, powers, power_index - 1)?;\n            Some(out_hi * &powers[power_index] + out_lo)\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n, m) = O(nm (\\log (nm))^2 \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.len()`, and $m$ is\n// `base.significant_bits()`.\npub_test! {from_digits_desc_divide_and_conquer(\n    xs: &[Natural],\n    base: &Natural,\n    powers: &[Natural],\n    power_index: usize,\n) -> Option<Natural> {\n    let xs_len = xs.len();\n    if power_index == 0\n        || u64::exact_from(xs_len) * base.significant_bits()\n            < FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    {\n        from_digits_desc_naive(xs, base)\n    } else {\n        let p = usize::power_of_2(u64::exact_from(power_index));\n        if xs_len <= p {\n            from_digits_desc_divide_and_conquer(xs, base, powers, power_index - 1)\n        } else {\n            let (xs_hi, xs_lo) = xs.split_at(xs_len - p);\n            let out_hi = from_digits_desc_divide_and_conquer(xs_hi, base, powers, power_index - 1)?;\n            let out_lo = from_digits_desc_divide_and_conquer(xs_lo, base, powers, power_index - 1)?;\n            Some(out_hi * &powers[power_index] + out_lo)\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_test! {from_digits_asc_limb<I: Iterator<Item = T>, T: TryFrom<Limb> + PrimitiveUnsigned>(\n    xs: I,\n    base: Limb,\n) -> Option<Natural>\nwhere\n    Limb: ExactFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert!(base >= 2);\n    if let Some(log_base) = base.checked_log_base_2() {\n        Natural::from_power_of_2_digits_asc(log_base, xs)\n    } else {\n        let mut xs = xs.collect_vec();\n        T::try_from(base).ok()?;\n        if xs.is_empty() {\n            return Some(Natural::ZERO);\n        }\n        xs.reverse();\n        if base < 256 {\n            let u64_base = base.exact_into();\n            let mut out = vec![0; usize::exact_from(limbs_per_digit_in_base(xs.len(), u64_base))];\n            let len = limbs_from_digits_small_base(&mut out, &xs, u64_base)?;\n            out.truncate(len);\n            Some(Natural::from_owned_limbs_asc(out))\n        } else {\n            let t_base = T::wrapping_from(base);\n            let powers = compute_powers_for_from_digits(&Natural::from(t_base), xs.len());\n            from_digits_desc_divide_and_conquer_limb(\n                &xs,\n                base,\n                &powers,\n                powers.len().saturating_sub(1),\n            )\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.count()`.\n#[allow(clippy::trait_duplication_in_bounds)]\nfn from_digits_asc_limb_from_natural<\n    I: Iterator<Item = Natural>,\n    T: TryFrom<Limb> + for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    xs: I,\n    base: Limb,\n) -> Option<Natural>\nwhere\n    Limb: WrappingFrom<T>,\n    Natural: From<T>,\n{\n    assert!(base >= 2);\n    if let Some(log_base) = base.checked_log_base_2() {\n        Natural::from_power_of_2_digits_asc(log_base, xs)\n    } else {\n        let large_xs = xs;\n        let mut xs = Vec::new();\n        T::try_from(base).ok()?;\n        for x in large_xs {\n            xs.push(T::try_from(&x).ok()?);\n        }\n        if xs.is_empty() {\n            return Some(Natural::ZERO);\n        }\n        xs.reverse();\n        if base < 256 {\n            let u64_base = base.exact_into();\n            let mut out = vec![0; usize::exact_from(limbs_per_digit_in_base(xs.len(), u64_base))];\n            let len = limbs_from_digits_small_base(&mut out, &xs, u64_base)?;\n            out.truncate(len);\n            Some(Natural::from_owned_limbs_asc(out))\n        } else {\n            let t_base = T::wrapping_from(base);\n            let powers = compute_powers_for_from_digits(&Natural::from(t_base), xs.len());\n            from_digits_desc_divide_and_conquer_limb(\n                &xs,\n                base,\n                &powers,\n                powers.len().saturating_sub(1),\n            )\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.count()`.\npub_test! {from_digits_desc_limb<I: Iterator<Item = T>, T: PrimitiveUnsigned>(\n    xs: I,\n    base: Limb,\n) -> Option<Natural>\nwhere\n    Limb: WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert!(base >= 2);\n    if let Some(log_base) = base.checked_log_base_2() {\n        Natural::from_power_of_2_digits_desc(log_base, xs)\n    } else {\n        let xs = xs.collect_vec();\n        T::try_from(base).ok()?;\n        if xs.is_empty() {\n            return Some(Natural::ZERO);\n        }\n        if base < 256 {\n            let u64_base = base.exact_into();\n            let mut out = vec![0; usize::exact_from(limbs_per_digit_in_base(xs.len(), u64_base))];\n            let len = limbs_from_digits_small_base(&mut out, &xs, u64_base)?;\n            out.truncate(len);\n            Some(Natural::from_owned_limbs_asc(out))\n        } else {\n            let t_base = T::wrapping_from(base);\n            let powers = compute_powers_for_from_digits(&Natural::from(t_base), xs.len());\n            from_digits_desc_divide_and_conquer_limb(\n                &xs,\n                base,\n                &powers,\n                powers.len().saturating_sub(1),\n            )\n        }\n    }\n}}\n\n// # Worst-case complexity\n// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n//\n// $M(n) = O(n \\log n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.count()`.\n#[allow(clippy::trait_duplication_in_bounds)]\nfn from_digits_desc_limb_from_natural<\n    I: Iterator<Item = Natural>,\n    T: TryFrom<Limb> + for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    xs: I,\n    base: Limb,\n) -> Option<Natural>\nwhere\n    Limb: WrappingFrom<T>,\n    Natural: From<T>,\n{\n    assert!(base >= 2);\n    if let Some(log_base) = base.checked_log_base_2() {\n        Natural::from_power_of_2_digits_desc(log_base, xs)\n    } else {\n        let large_xs = xs;\n        let mut xs = Vec::new();\n        T::try_from(base).ok()?;\n        for x in large_xs {\n            xs.push(T::try_from(&x).ok()?);\n        }\n        if xs.is_empty() {\n            return Some(Natural::ZERO);\n        }\n        if base < 256 {\n            let u64_base = base.exact_into();\n            let mut out = vec![0; usize::exact_from(limbs_per_digit_in_base(xs.len(), u64_base))];\n            let len = limbs_from_digits_small_base(&mut out, &xs, u64_base)?;\n            out.truncate(len);\n            Some(Natural::from_owned_limbs_asc(out))\n        } else {\n            let t_base = T::wrapping_from(base);\n            let powers = compute_powers_for_from_digits(&Natural::from(t_base), xs.len());\n            from_digits_desc_divide_and_conquer_limb(\n                &xs,\n                base,\n                &powers,\n                powers.len().saturating_sub(1),\n            )\n        }\n    }\n}\n\n// # Worst-case complexity\n// $T(n, m) = O(nm (\\log (nm))^2 \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.count()`, and $m$ is\n// `base.significant_bits()`.\n//\n// optimized for large base\npub_test! {from_digits_asc_large<I: Iterator<Item = Natural>>(\n    xs: I,\n    base: &Natural,\n) -> Option<Natural> {\n    if let Some(log_base) = base.checked_log_base_2() {\n        Natural::from_power_of_2_digits_asc(log_base, xs)\n    } else {\n        let mut xs = xs.collect_vec();\n        xs.reverse();\n        let powers = compute_powers_for_from_digits(base, xs.len());\n        from_digits_desc_divide_and_conquer(&xs, base, &powers, powers.len().saturating_sub(1))\n    }\n}}\n\n// # Worst-case complexity\n// $T(n, m) = O(nm (\\log (nm))^2 \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `xs.count()`, and $m$ is\n// `base.significant_bits()`.\n//\n// optimized for large base\npub_test! {from_digits_desc_large<I: Iterator<Item = Natural>>(\n    xs: I,\n    base: &Natural,\n) -> Option<Natural> {\n    if let Some(log_base) = base.checked_log_base_2() {\n        Natural::from_power_of_2_digits_desc(log_base, xs)\n    } else {\n        let xs = xs.collect_vec();\n        let powers = compute_powers_for_from_digits(base, xs.len());\n        from_digits_desc_divide_and_conquer(&xs, base, &powers, powers.len().saturating_sub(1))\n    }\n}}\n\nimpl Digits<u8> for Natural {\n    /// Returns a [`Vec`] containing the digits of a [`Natural`] in ascending order (least- to\n    /// most-significant).\n    ///\n    /// If the [`Natural`] is 0, the [`Vec`] is empty; otherwise, it ends with a nonzero digit.\n    ///\n    /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \\neq\n    /// 0$, and\n    ///\n    /// $$\n    /// \\sum_{i=0}^{k-1}b^i d_i = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// See [here](super::general_digits#to_digits_asc).\n    #[inline]\n    fn to_digits_asc(&self, base: &u8) -> Vec<u8> {\n        match self {\n            Self(Small(x)) => x.to_digits_asc(base),\n            Self(Large(xs)) => {\n                if let Some(log_base) = base.checked_log_base_2() {\n                    self.to_power_of_2_digits_asc(log_base)\n                } else {\n                    let mut digits =\n                        vec![0; usize::exact_from(limbs_digit_count(xs, u64::from(*base)))];\n                    let mut xs = xs.clone();\n                    let len =\n                        limbs_to_digits_small_base(&mut digits, u64::from(*base), &mut xs, None);\n                    digits.truncate(len);\n                    digits.reverse();\n                    digits\n                }\n            }\n        }\n    }\n\n    /// Returns a [`Vec`] containing the digits of a [`Natural`] in descending order (most- to\n    /// least-significant).\n    ///\n    /// If the [`Natural`] is 0, the [`Vec`] is empty; otherwise, it begins with a nonzero digit.\n    ///\n    /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \\neq\n    /// 0$, and\n    ///\n    /// $$\n    /// \\sum_{i=0}^{k-1}b^i d_{k-i-1} = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// See [here](super::general_digits#to_digits_desc).\n    #[inline]\n    fn to_digits_desc(&self, base: &u8) -> Vec<u8> {\n        match self {\n            Self(Small(x)) => x.to_digits_desc(base),\n            Self(Large(xs)) => {\n                if let Some(log_base) = base.checked_log_base_2() {\n                    self.to_power_of_2_digits_desc(log_base)\n                } else {\n                    let mut digits =\n                        vec![0; usize::exact_from(limbs_digit_count(xs, u64::from(*base)))];\n                    let mut xs = xs.clone();\n                    let len =\n                        limbs_to_digits_small_base(&mut digits, u64::from(*base), &mut xs, None);\n                    digits.truncate(len);\n                    digits\n                }\n            }\n        }\n    }\n\n    /// Converts an iterator of digits into a [`Natural`].\n    ///\n    /// The input digits are in ascending order (least- to most-significant). The function returns\n    /// `None` if any of the digits are greater than or equal to the base.\n    ///\n    /// $$\n    /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^id_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// See [here](super::general_digits#from_digits_asc).\n    #[inline]\n    fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<Self> {\n        if let Some(log_base) = base.checked_log_base_2() {\n            Self::from_power_of_2_digits_asc(log_base, digits)\n        } else {\n            let base = u64::from(*base);\n            let mut xs = digits.collect_vec();\n            if xs.is_empty() {\n                return Some(Self::ZERO);\n            }\n            xs.reverse();\n            let mut out = vec![0; usize::exact_from(limbs_per_digit_in_base(xs.len(), base))];\n            let _ = limbs_from_digits_small_base(&mut out, &xs, base)?;\n            Some(Self::from_owned_limbs_asc(out))\n        }\n    }\n\n    /// Converts an iterator of digits into a [`Natural`].\n    ///\n    /// The input digits are in descending order (most- to least-significant). The function returns\n    /// `None` if any of the digits are greater than or equal to the base.\n    ///\n    /// $$\n    /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^{k-i-1}d_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// See [here](super::general_digits#from_digits_desc).\n    #[inline]\n    fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<Self> {\n        if let Some(log_base) = base.checked_log_base_2() {\n            Self::from_power_of_2_digits_desc(log_base, digits)\n        } else {\n            let base = u64::from(*base);\n            let xs = digits.collect_vec();\n            if xs.is_empty() {\n                return Some(Self::ZERO);\n            }\n            let mut out = vec![0; usize::exact_from(limbs_per_digit_in_base(xs.len(), base))];\n            let _ = limbs_from_digits_small_base(&mut out, &xs, base)?;\n            Some(Self::from_owned_limbs_asc(out))\n        }\n    }\n}\n\nfn to_digits_asc_unsigned<\n    T: for<'a> TryFrom<&'a Natural>\n        + ConvertibleFrom<Limb>\n        + PrimitiveUnsigned\n        + for<'a> WrappingFrom<&'a Natural>,\n>(\n    x: &Natural,\n    base: &T,\n) -> Vec<T>\nwhere\n    Limb: TryFrom<T> + Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    if let Ok(base) = Limb::try_from(*base) {\n        to_digits_asc_limb(x, base)\n    } else {\n        to_digits_asc_large(x, &Natural::from(*base))\n            .into_iter()\n            .map(|n| T::wrapping_from(&n))\n            .collect()\n    }\n}\n\nfn to_digits_desc_unsigned<\n    T: for<'a> TryFrom<&'a Natural>\n        + ConvertibleFrom<Limb>\n        + PrimitiveUnsigned\n        + for<'a> WrappingFrom<&'a Natural>,\n>(\n    x: &Natural,\n    base: &T,\n) -> Vec<T>\nwhere\n    Limb: TryFrom<T> + Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    if let Ok(base) = Limb::try_from(*base) {\n        to_digits_desc_limb(x, base)\n    } else {\n        to_digits_desc_large(x, &Natural::from(*base))\n            .into_iter()\n            .map(|n| T::wrapping_from(&n))\n            .collect()\n    }\n}\n\nfn from_digits_asc_unsigned<T: ConvertibleFrom<Limb> + PrimitiveUnsigned, I: Iterator<Item = T>>(\n    base: &T,\n    digits: I,\n) -> Option<Natural>\nwhere\n    Limb: TryFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    if let Ok(base) = Limb::try_from(*base) {\n        from_digits_asc_limb(digits, base)\n    } else {\n        from_digits_asc_large(digits.map(Natural::from), &Natural::from(*base))\n    }\n}\n\nfn from_digits_desc_unsigned<T: ConvertibleFrom<Limb> + PrimitiveUnsigned, I: Iterator<Item = T>>(\n    base: &T,\n    digits: I,\n) -> Option<Natural>\nwhere\n    Limb: TryFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    if let Ok(base) = Limb::try_from(*base) {\n        from_digits_desc_limb(digits, base)\n    } else {\n        from_digits_desc_large(digits.map(Natural::from), &Natural::from(*base))\n    }\n}\n\nmacro_rules! digits_unsigned {\n    ($d: ident) => {\n        impl Digits<$d> for Natural {\n            /// Returns a [`Vec`] containing the digits of a [`Natural`] in ascending order (least-\n            /// to most-significant).\n            ///\n            /// If the [`Natural`] is 0, the [`Vec`] is empty; otherwise, it ends with a nonzero\n            /// digit.\n            ///\n            /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or\n            /// $d_{k-1} \\neq 0$, and\n            ///\n            /// $$\n            /// \\sum_{i=0}^{k-1}b^i d_i = x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2.\n            ///\n            /// # Examples\n            /// See [here](super::general_digits#to_digits_asc).\n            #[inline]\n            fn to_digits_asc(&self, base: &$d) -> Vec<$d> {\n                to_digits_asc_unsigned(self, base)\n            }\n\n            /// Returns a [`Vec`] containing the digits of a [`Natural`] in descending order (most-\n            /// to least-significant).\n            ///\n            /// If the [`Natural`] is 0, the [`Vec`] is empty; otherwise, it begins with a nonzero\n            /// digit.\n            ///\n            /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or\n            /// $d_{k-1} \\neq 0$, and\n            ///\n            /// $$\n            /// \\sum_{i=0}^{k-1}b^i d_{k-i-1} = x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2.\n            ///\n            /// # Examples\n            /// See [here](super::general_digits#to_digits_desc).\n            #[inline]\n            fn to_digits_desc(&self, base: &$d) -> Vec<$d> {\n                to_digits_desc_unsigned(self, base)\n            }\n\n            /// Converts an iterator of digits into a [`Natural`].\n            ///\n            /// The input digits are in ascending order (least- to most-significant). The function\n            /// returns `None` if any of the digits are greater than or equal to the base.\n            ///\n            /// $$\n            /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^id_i.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2.\n            ///\n            /// # Examples\n            /// See [here](super::general_digits#from_digits_asc).\n            #[inline]\n            fn from_digits_asc<I: Iterator<Item = $d>>(base: &$d, digits: I) -> Option<Natural> {\n                from_digits_asc_unsigned(base, digits)\n            }\n\n            /// Converts an iterator of digits into a [`Natural`].\n            ///\n            /// The input digits are in descending order (most- to least-significant). The function\n            /// returns `None` if any of the digits are greater than or equal to the base.\n            ///\n            /// $$\n            /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^{k-i-1}d_i.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n            ///\n            /// # Panics\n            /// Panics if `base` is less than 2.\n            ///\n            /// # Examples\n            /// See [here](super::general_digits#to_digits_desc).\n            #[inline]\n            fn from_digits_desc<I: Iterator<Item = $d>>(base: &$d, digits: I) -> Option<Natural> {\n                from_digits_desc_unsigned(base, digits)\n            }\n        }\n    };\n}\ndigits_unsigned!(u16);\ndigits_unsigned!(u32);\ndigits_unsigned!(u64);\ndigits_unsigned!(u128);\ndigits_unsigned!(usize);\n\nimpl Digits<Self> for Natural {\n    /// Returns a [`Vec`] containing the digits of a [`Natural`] in ascending order (least- to\n    /// most-significant).\n    ///\n    /// If the [`Natural`] is 0, the [`Vec`] is empty; otherwise, it ends with a nonzero digit.\n    ///\n    /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \\neq\n    /// 0$, and\n    ///\n    /// $$\n    /// \\sum_{i=0}^{k-1}b^i d_i = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_base::num::conversion::traits::Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO\n    ///         .to_digits_asc(&Natural::from(6u32))\n    ///         .to_debug_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::TWO\n    ///         .to_digits_asc(&Natural::from(6u32))\n    ///         .to_debug_string(),\n    ///     \"[2]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(123456u32)\n    ///         .to_digits_asc(&Natural::from(3u32))\n    ///         .to_debug_string(),\n    ///     \"[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2]\"\n    /// );\n    /// ```\n    fn to_digits_asc(&self, base: &Self) -> Vec<Self> {\n        match base {\n            Self(Small(b)) => self.to_digits_asc(b).into_iter().map(Self::from).collect(),\n            _ => to_digits_asc_large(self, base),\n        }\n    }\n\n    /// Returns a [`Vec`] containing the digits of a [`Natural`] in descending order (most- to\n    /// least-significant).\n    ///\n    /// If the [`Natural`] is 0, the [`Vec`] is empty; otherwise, it begins with a nonzero digit.\n    ///\n    /// $f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \\leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \\neq\n    /// 0$, and\n    ///\n    /// $$\n    /// \\sum_{i=0}^{k-1}b^i d_{k-i-1} = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_base::num::conversion::traits::Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::ZERO\n    ///         .to_digits_desc(&Natural::from(6u32))\n    ///         .to_debug_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::TWO\n    ///         .to_digits_desc(&Natural::from(6u32))\n    ///         .to_debug_string(),\n    ///     \"[2]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(123456u32)\n    ///         .to_digits_desc(&Natural::from(3u32))\n    ///         .to_debug_string(),\n    ///     \"[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0]\"\n    /// );\n    /// ```\n    fn to_digits_desc(&self, base: &Self) -> Vec<Self> {\n        match base {\n            Self(Small(b)) => self.to_digits_desc(b).into_iter().map(Self::from).collect(),\n            _ => to_digits_desc_large(self, base),\n        }\n    }\n\n    /// Converts an iterator of digits into a [`Natural`].\n    ///\n    /// The input digits are in ascending order (least- to most-significant). The function returns\n    /// `None` if any of the digits are greater than or equal to the base.\n    ///\n    /// $$\n    /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^id_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm (\\log (nm))^2 \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `digits.count()`, and $m$ is\n    /// `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from_digits_asc(\n    ///         &Natural::from(64u32),\n    ///         vec_from_str::<Natural>(\"[0, 0, 0]\").unwrap().into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"Some(0)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_digits_asc(\n    ///         &Natural::from(3u32),\n    ///         vec_from_str::<Natural>(\"[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2]\")\n    ///             .unwrap()\n    ///             .into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"Some(123456)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_digits_asc(\n    ///         &Natural::from(8u32),\n    ///         vec_from_str::<Natural>(\"[3, 7, 1]\").unwrap().into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_digits_asc(\n    ///         &Natural::from(8u32),\n    ///         vec_from_str::<Natural>(\"[1, 10, 3]\").unwrap().into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// ```\n    #[inline]\n    fn from_digits_asc<I: Iterator<Item = Self>>(base: &Self, digits: I) -> Option<Self> {\n        match base {\n            Self(Small(b)) => from_digits_asc_limb_from_natural::<_, Limb>(digits, *b),\n            _ => from_digits_asc_large(digits, base),\n        }\n    }\n\n    /// Converts an iterator of digits into a [`Natural`].\n    ///\n    /// The input digits are in descending order (most- to least-significant). The function returns\n    /// `None` if any of the digits are greater than or equal to the base.\n    ///\n    /// $$\n    /// f((d_i)_ {i=0}^{k-1}, b) = \\sum_{i=0}^{k-1}b^{k-i-1}d_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm (\\log (nm))^2 \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `digits.count()`, and $m$ is\n    /// `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from_digits_desc(\n    ///         &Natural::from(64u32),\n    ///         vec_from_str::<Natural>(\"[0, 0, 0]\").unwrap().into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"Some(0)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_digits_desc(\n    ///         &Natural::from(3u32),\n    ///         vec_from_str::<Natural>(\"[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0]\")\n    ///             .unwrap()\n    ///             .into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"Some(123456)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_digits_desc(\n    ///         &Natural::from(8u32),\n    ///         vec_from_str::<Natural>(\"[1, 7, 3]\").unwrap().into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_digits_desc(\n    ///         &Natural::from(8u32),\n    ///         vec_from_str::<Natural>(\"[3, 10, 1]\").unwrap().into_iter()\n    ///     )\n    ///     .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// ```\n    #[inline]\n    fn from_digits_desc<I: Iterator<Item = Self>>(base: &Self, digits: I) -> Option<Self> {\n        match base {\n            Self(Small(b)) => from_digits_desc_limb_from_natural::<_, Limb>(digits, *b),\n            _ => from_digits_desc_large(digits, base),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of [`Digits`](malachite_base::num::conversion::traits::Digits), a trait for\n/// extracting digits from [`Natural`](crate::natural::Natural)s and constructing\n/// [`Natural`](crate::natural::Natural)s from digits.\n///\n/// # to_digits_asc\n/// ```\n/// use malachite_base::num::basic::traits::{Two, Zero};\n/// use malachite_base::num::conversion::traits::Digits;\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::ZERO.to_digits_asc(&6u64).is_empty());\n/// assert_eq!(Natural::TWO.to_digits_asc(&6u32), &[2]);\n/// assert_eq!(\n///     Natural::from(123456u32).to_digits_asc(&3u16),\n///     &[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2]\n/// );\n/// ```\n///\n/// # to_digits_desc\n/// ```\n/// use malachite_base::num::basic::traits::{Two, Zero};\n/// use malachite_base::num::conversion::traits::Digits;\n/// use malachite_nz::natural::Natural;\n///\n/// assert!(Natural::ZERO.to_digits_desc(&6u64).is_empty());\n/// assert_eq!(Natural::TWO.to_digits_desc(&6u32), &[2]);\n/// assert_eq!(\n///     Natural::from(123456u32).to_digits_desc(&3u16),\n///     &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0]\n/// );\n/// ```\n///\n/// # from_digits_asc\n/// ```\n/// use malachite_base::num::conversion::traits::Digits;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::from_digits_asc(&64u64, [0, 0, 0].iter().cloned()).to_debug_string(),\n///     \"Some(0)\"\n/// );\n/// assert_eq!(\n///     Natural::from_digits_asc(&3u64, [0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2].iter().cloned())\n///         .to_debug_string(),\n///     \"Some(123456)\"\n/// );\n/// assert_eq!(\n///     Natural::from_digits_asc(&8u16, [3, 7, 1].iter().cloned()).to_debug_string(),\n///     \"Some(123)\"\n/// );\n/// assert_eq!(\n///     Natural::from_digits_asc(&8u16, [3, 10, 1].iter().cloned()).to_debug_string(),\n///     \"None\"\n/// );\n/// ```\n///\n/// # from_digits_desc\n/// ```\n/// use malachite_base::num::conversion::traits::Digits;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::from_digits_desc(&64u64, [0, 0, 0].iter().cloned()).to_debug_string(),\n///     \"Some(0)\"\n/// );\n/// assert_eq!(\n///     Natural::from_digits_desc(&3u64, [2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0].iter().cloned())\n///         .to_debug_string(),\n///     \"Some(123456)\"\n/// );\n/// assert_eq!(\n///     Natural::from_digits_desc(&8u16, [1, 7, 3].iter().cloned()).to_debug_string(),\n///     \"Some(123)\"\n/// );\n/// assert_eq!(\n///     Natural::from_digits_desc(&8u16, [3, 10, 1].iter().cloned()).to_debug_string(),\n///     \"None\"\n/// );\n/// ```\npub mod general_digits;\n/// An implementation of\n/// [`PowerOf2DigitIterable`](malachite_base::num::conversion::traits::PowerOf2DigitIterable), a\n/// trait for iterating over a [`Natural`](crate::natural::Natural)'s base-$2^k$ digits.\n///\n/// # power_of_2_digits\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::num::conversion::traits::PowerOf2DigitIterable;\n/// use malachite_nz::natural::Natural;\n///\n/// let n = Natural::ZERO;\n/// assert!(PowerOf2DigitIterable::<u8>::power_of_2_digits(&n, 2)\n///     .next()\n///     .is_none());\n///\n/// // 107 = 1223_4\n/// let n = Natural::from(107u32);\n/// assert_eq!(\n///     PowerOf2DigitIterable::<u32>::power_of_2_digits(&n, 2).collect_vec(),\n///     vec![3, 2, 2, 1]\n/// );\n///\n/// let n = Natural::ZERO;\n/// assert!(PowerOf2DigitIterable::<u8>::power_of_2_digits(&n, 2)\n///     .next_back()\n///     .is_none());\n///\n/// // 107 = 1223_4\n/// let n = Natural::from(107u32);\n/// assert_eq!(\n///     PowerOf2DigitIterable::<u32>::power_of_2_digits(&n, 2)\n///         .rev()\n///         .collect_vec(),\n///     vec![1, 2, 2, 3]\n/// );\n/// ```\npub mod power_of_2_digit_iterable;\n/// Implementations of [`PowerOf2Digits`](malachite_base::num::conversion::traits::PowerOf2Digits),\n/// a trait for extracting base-$2^k$ digits from [`Natural`](crate::natural::Natural)s and\n/// constructing [`Natural`](crate::natural::Natural)s from such digits.\n///\n/// # to_power_of_2_digits_asc\n/// ```\n/// use malachite_base::num::basic::traits::{Two, Zero};\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&Natural::ZERO, 6),\n///     Vec::<u64>::new()\n/// );\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&Natural::TWO, 6),\n///     vec![2]\n/// );\n///\n/// // 123_10 = 173_8\n/// assert_eq!(\n///     PowerOf2Digits::<u16>::to_power_of_2_digits_asc(&Natural::from(123u32), 3),\n///     vec![3, 7, 1]\n/// );\n/// ```\n///\n/// # to_power_of_2_digits_desc\n/// ```\n/// use malachite_base::num::basic::traits::{Two, Zero};\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_desc(&Natural::ZERO, 6),\n///     Vec::<u64>::new()\n/// );\n/// assert_eq!(\n///     PowerOf2Digits::<u64>::to_power_of_2_digits_desc(&Natural::TWO, 6),\n///     vec![2]\n/// );\n///\n/// // 123_10 = 173_8\n/// assert_eq!(\n///     PowerOf2Digits::<u16>::to_power_of_2_digits_desc(&Natural::from(123u32), 3),\n///     vec![1, 7, 3]\n/// );\n/// ```\n///\n/// # from_power_of_2_digits_asc\n/// ```\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_asc(6, [0u64, 0, 0].iter().cloned()).to_debug_string(),\n///     \"Some(0)\"\n/// );\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_asc(6, [2u64, 0].iter().cloned()).to_debug_string(),\n///     \"Some(2)\"\n/// );\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_asc(3, [3u16, 7, 1].iter().cloned()).to_debug_string(),\n///     \"Some(123)\"\n/// );\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_asc(3, [100u8].iter().cloned()).to_debug_string(),\n///     \"None\"\n/// );\n/// ```\n///\n/// # from_power_of_2_digits_desc\n/// ```\n/// use malachite_base::num::conversion::traits::PowerOf2Digits;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_desc(6, [0u64, 0, 0].iter().cloned()).to_debug_string(),\n///     \"Some(0)\"\n/// );\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_desc(6, [0u64, 2].iter().cloned()).to_debug_string(),\n///     \"Some(2)\"\n/// );\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_desc(3, [1u16, 7, 3].iter().cloned()).to_debug_string(),\n///     \"Some(123)\"\n/// );\n/// assert_eq!(\n///     Natural::from_power_of_2_digits_desc(3, [100u8].iter().cloned()).to_debug_string(),\n///     \"None\"\n/// );\n/// ```\npub mod power_of_2_digits;\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/digits/power_of_2_digit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::logic::bit_block_access::limbs_slice_get_bits;\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse core::cmp::{Ordering::*, min};\nuse core::marker::PhantomData;\nuse core::slice::Chunks;\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, DivRound, FloorLogBase2, ModPowerOf2, PowerOf2, SaturatingSubAssign, ShrRound,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::digits::power_of_2_digit_iterable::*;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, PowerOf2DigitIterable, PowerOf2DigitIterator,\n};\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rounding_modes::RoundingMode::*;\n\n#[doc(hidden)]\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct FitsInLimbIterator<'a, T>(FILIterator<'a, T>);\n\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\nstruct FILIterator<'a, T> {\n    limbs: &'a [Limb],\n    log_base: u64,\n    remaining: usize,\n    limb_i: usize,\n    limb_j: usize,\n    // This index initially points to the least-significant digit, and is incremented by next().\n    i: u64,\n    // This index initially points to the most-significant nonzero digit, and is decremented by\n    // next_back().\n    j: u64,\n    mask: Limb,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for FILIterator<'_, T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.remaining != 0 {\n            let digit = T::wrapping_from((self.limbs[self.limb_i] >> self.i) & self.mask);\n            self.i += self.log_base;\n            if self.i == Limb::WIDTH {\n                self.i = 0;\n                self.limb_i += 1;\n            }\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl<T: PrimitiveUnsigned> DoubleEndedIterator for FILIterator<'_, T> {\n    fn next_back(&mut self) -> Option<T> {\n        if self.remaining != 0 {\n            let digit = T::wrapping_from((self.limbs[self.limb_j] >> self.j) & self.mask);\n            if self.j == 0 {\n                self.j = Limb::WIDTH - self.log_base;\n                self.limb_j.saturating_sub_assign(1);\n            } else {\n                self.j -= self.log_base;\n            }\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> ExactSizeIterator for FILIterator<'_, T> {}\n\nimpl<T: PrimitiveUnsigned> PowerOf2DigitIterator<T> for FILIterator<'_, T> {\n    fn get_digit(&self, index: u64) -> T {\n        let log_log_base = self.log_base.floor_log_base_2();\n        let log_ratio = Limb::LOG_WIDTH - log_log_base;\n        let limb_index = usize::exact_from(index >> log_ratio);\n        let digit_index = index.mod_power_of_2(log_ratio);\n        if limb_index < self.limbs.len() {\n            T::wrapping_from((self.limbs[limb_index] >> (digit_index << log_log_base)) & self.mask)\n        } else {\n            T::ZERO\n        }\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct SizeOfLimbIterator<'a, T>(SOLIterator<'a, T>);\n\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\nstruct SOLIterator<'a, T> {\n    limbs: &'a [Limb],\n    remaining: usize,\n    // This index initially points to the least-significant digit, and is incremented by next().\n    i: usize,\n    // This index initially points to the most-significant nonzero digit, and is decremented by\n    // next_back().\n    j: usize,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for SOLIterator<'_, T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.remaining != 0 {\n            let digit = T::wrapping_from(self.limbs[self.i]);\n            self.i += 1;\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl<T: PrimitiveUnsigned> DoubleEndedIterator for SOLIterator<'_, T> {\n    fn next_back(&mut self) -> Option<T> {\n        if self.remaining != 0 {\n            let digit = T::wrapping_from(self.limbs[self.j]);\n            self.j.saturating_sub_assign(1);\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> ExactSizeIterator for SOLIterator<'_, T> {}\n\nimpl<T: PrimitiveUnsigned> SOLIterator<'_, T> {\n    fn get_digit(&self, index: u64) -> T {\n        let index = usize::exact_from(index);\n        if index < self.limbs.len() {\n            T::wrapping_from(self.limbs[index])\n        } else {\n            T::ZERO\n        }\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct MultipleOfLimbIterator<'a, T>(MOLIterator<'a, T>);\n\n#[derive(Clone, Debug)]\nstruct MOLIterator<'a, T> {\n    log_ratio: u64,\n    limbs: &'a [Limb],\n    chunks: Chunks<'a, Limb>,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for MOLIterator<'_, T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        self.chunks.next().map(T::from_other_type_slice)\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        self.chunks.size_hint()\n    }\n}\n\nimpl<T: PrimitiveUnsigned> DoubleEndedIterator for MOLIterator<'_, T> {\n    fn next_back(&mut self) -> Option<T> {\n        self.chunks.next_back().map(T::from_other_type_slice)\n    }\n}\n\nimpl<T: PrimitiveUnsigned> ExactSizeIterator for MOLIterator<'_, T> {}\n\nimpl<T: PrimitiveUnsigned> PowerOf2DigitIterator<T> for MOLIterator<'_, T> {\n    fn get_digit(&self, index: u64) -> T {\n        let start_index = usize::exact_from(index << self.log_ratio);\n        if start_index >= self.limbs.len() {\n            T::ZERO\n        } else {\n            let end_index = min(\n                self.limbs.len(),\n                start_index + usize::power_of_2(self.log_ratio),\n            );\n            T::from_other_type_slice(&self.limbs[start_index..end_index])\n        }\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct IrregularIterator<'a, T>(IIterator<'a, T>);\n\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\nstruct IIterator<'a, T> {\n    limbs: &'a [Limb],\n    log_base: u64,\n    remaining: usize,\n    // This index initially points to the least-significant digit, and is incremented by next().\n    i: u64,\n    // This index initially points to the most-significant nonzero digit, and is decremented by\n    // next_back().\n    j: u64,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for IIterator<'_, T> {\n    type Item = T;\n\n    fn next(&mut self) -> Option<T> {\n        if self.remaining != 0 {\n            let digit = self.get_digit(self.i);\n            self.i += 1;\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl<T: PrimitiveUnsigned> DoubleEndedIterator for IIterator<'_, T> {\n    fn next_back(&mut self) -> Option<T> {\n        if self.remaining != 0 {\n            let digit = self.get_digit(self.j);\n            self.j.saturating_sub_assign(1);\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> ExactSizeIterator for IIterator<'_, T> {}\n\nimpl<T: PrimitiveUnsigned> IIterator<'_, T> {\n    fn get_digit(&self, index: u64) -> T {\n        let start = index * self.log_base;\n        let limb_start = bit_to_limb_count_floor(start);\n        let len = self.limbs.len();\n        let mut result = T::ZERO;\n        if limb_start >= len {\n            return result;\n        }\n        let mut result_index = 0;\n        let mut limb_index = start & Limb::WIDTH_MASK;\n        for &limb in &self.limbs[limb_start..] {\n            let remaining_result_bits = self.log_base - result_index;\n            let remaining_limb_bits = Limb::WIDTH - limb_index;\n            if remaining_limb_bits <= remaining_result_bits {\n                result |= T::wrapping_from(limb >> limb_index) << result_index;\n                result_index += remaining_limb_bits;\n                limb_index = 0;\n            } else {\n                result |=\n                    T::wrapping_from((limb >> limb_index).mod_power_of_2(remaining_result_bits))\n                        << result_index;\n                break;\n            }\n        }\n        result\n    }\n}\n\n/// A double-ended iterator over the base-$2^k$ $digits of a [`Natural`].\n///\n/// The base-2 logarithm of the base is specified. Each digit has primitive integer type, and\n/// `log_base` must be no larger than the width of that type. The forward order is ascending\n/// (least-significant first). The iterator does not iterate over the implicit leading zero digits.\n///\n/// This struct also supports retrieving digits by index. This functionality is completely\n/// independent of the iterator's state. Indexing the implicit leading zero digits is allowed.\n#[derive(Clone, Debug)]\npub enum NaturalPowerOf2DigitPrimitiveIterator<'a, T: PrimitiveUnsigned> {\n    Small(PrimitivePowerOf2DigitIterator<Limb, T>),\n    FitsInLimb(FitsInLimbIterator<'a, T>),\n    SizeOfLimb(SizeOfLimbIterator<'a, T>),\n    MultipleOfLimb(MultipleOfLimbIterator<'a, T>),\n    Irregular(IrregularIterator<'a, T>),\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for NaturalPowerOf2DigitPrimitiveIterator<'_, T> {\n    type Item = T;\n\n    /// Iterates through the base-$2^k$ digits of a [`Natural`] in ascending order\n    /// (least-significant first).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    fn next(&mut self) -> Option<T> {\n        match self {\n            Self::Small(xs) => xs.next(),\n            Self::FitsInLimb(xs) => xs.0.next(),\n            Self::SizeOfLimb(xs) => xs.0.next(),\n            Self::MultipleOfLimb(xs) => xs.0.next(),\n            Self::Irregular(xs) => xs.0.next(),\n        }\n    }\n\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        match self {\n            Self::Small(xs) => xs.size_hint(),\n            Self::FitsInLimb(xs) => xs.0.size_hint(),\n            Self::SizeOfLimb(xs) => xs.0.size_hint(),\n            Self::MultipleOfLimb(xs) => xs.0.size_hint(),\n            Self::Irregular(xs) => xs.0.size_hint(),\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> DoubleEndedIterator for NaturalPowerOf2DigitPrimitiveIterator<'_, T> {\n    /// Iterates through the base-$2^k$ digits of a [`Natural`] in descending order\n    /// (most-significant first).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    fn next_back(&mut self) -> Option<T> {\n        match self {\n            Self::Small(xs) => xs.next_back(),\n            Self::FitsInLimb(xs) => xs.0.next_back(),\n            Self::SizeOfLimb(xs) => xs.0.next_back(),\n            Self::MultipleOfLimb(xs) => xs.0.next_back(),\n            Self::Irregular(xs) => xs.0.next_back(),\n        }\n    }\n}\n\nimpl<T: PrimitiveUnsigned> ExactSizeIterator for NaturalPowerOf2DigitPrimitiveIterator<'_, T> {}\n\nimpl<T: PrimitiveUnsigned> PowerOf2DigitIterator<T>\n    for NaturalPowerOf2DigitPrimitiveIterator<'_, T>\n{\n    /// Retrieves the base-$2^k$ digits of a [`Natural`] by index.\n    ///\n    /// $f(x, k, i) = d_i$, where $0 \\leq d_i < 2^k$ for all $i$ and\n    /// $$\n    /// \\sum_{i=0}^\\infty2^{ki}d_i = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::{\n    ///     PowerOf2DigitIterable, PowerOf2DigitIterator,\n    /// };\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n = Natural::ZERO;\n    /// assert_eq!(\n    ///     PowerOf2DigitIterable::<u8>::power_of_2_digits(&n, 2).get_digit(0),\n    ///     0\n    /// );\n    ///\n    /// // 107 = 1223_4\n    /// let n = Natural::from(107u32);\n    /// let digits = PowerOf2DigitIterable::<u32>::power_of_2_digits(&n, 2);\n    /// assert_eq!(digits.get_digit(0), 3);\n    /// assert_eq!(digits.get_digit(1), 2);\n    /// assert_eq!(digits.get_digit(2), 2);\n    /// assert_eq!(digits.get_digit(3), 1);\n    /// assert_eq!(digits.get_digit(4), 0);\n    /// assert_eq!(digits.get_digit(100), 0);\n    /// ```\n    fn get_digit(&self, index: u64) -> T {\n        match self {\n            Self::Small(xs) => xs.get_digit(index),\n            Self::FitsInLimb(xs) => xs.0.get_digit(index),\n            Self::SizeOfLimb(xs) => xs.0.get_digit(index),\n            Self::MultipleOfLimb(xs) => xs.0.get_digit(index),\n            Self::Irregular(xs) => xs.0.get_digit(index),\n        }\n    }\n}\n\nfn fits_in_limb_iterator<T: PrimitiveUnsigned>(\n    xs: &[Limb],\n    log_base: u64,\n) -> FitsInLimbIterator<'_, T> {\n    let significant_bits = limbs_significant_bits(xs);\n    let log_log_base = log_base.floor_log_base_2();\n    let significant_digits = significant_bits.shr_round(log_log_base, Ceiling).0;\n    FitsInLimbIterator(FILIterator {\n        limbs: xs,\n        log_base,\n        remaining: usize::exact_from(significant_digits),\n        limb_i: 0,\n        limb_j: xs.len() - 1,\n        i: 0,\n        j: (significant_digits - 1).mod_power_of_2(Limb::LOG_WIDTH - log_log_base) << log_log_base,\n        mask: Limb::low_mask(log_base),\n        phantom: PhantomData,\n    })\n}\n\nconst fn size_of_limb_iterator<T: PrimitiveUnsigned>(xs: &[Limb]) -> SizeOfLimbIterator<'_, T> {\n    SizeOfLimbIterator(SOLIterator {\n        limbs: xs,\n        remaining: xs.len(),\n        i: 0,\n        j: xs.len() - 1,\n        phantom: PhantomData,\n    })\n}\n\nfn multiple_of_limb_iterator<T: PrimitiveUnsigned>(\n    xs: &[Limb],\n    log_base: u64,\n) -> MultipleOfLimbIterator<'_, T> {\n    let log_log_base = log_base.floor_log_base_2();\n    let log_ratio = log_log_base - Limb::LOG_WIDTH;\n    MultipleOfLimbIterator(MOLIterator {\n        log_ratio,\n        limbs: xs,\n        chunks: xs.chunks(usize::power_of_2(log_ratio)),\n        phantom: PhantomData,\n    })\n}\n\nfn irregular_iterator<T: PrimitiveUnsigned>(\n    xs: &[Limb],\n    log_base: u64,\n) -> IrregularIterator<'_, T> {\n    let significant_digits = limbs_significant_bits(xs).div_round(log_base, Ceiling).0;\n    IrregularIterator(IIterator {\n        limbs: xs,\n        log_base,\n        remaining: usize::exact_from(significant_digits),\n        i: 0,\n        j: significant_digits - 1,\n        phantom: PhantomData,\n    })\n}\n\nfn power_of_2_digits<T: PrimitiveUnsigned>(\n    x: &Natural,\n    log_base: u64,\n) -> NaturalPowerOf2DigitPrimitiveIterator<'_, T>\nwhere\n    Limb: PowerOf2DigitIterable<T, PowerOf2DigitIterator = PrimitivePowerOf2DigitIterator<Limb, T>>,\n{\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= T::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        T::NAME,\n        log_base\n    );\n    match x {\n        Natural(Small(small)) => NaturalPowerOf2DigitPrimitiveIterator::Small(\n            PowerOf2DigitIterable::<T>::power_of_2_digits(*small, log_base),\n        ),\n        Natural(Large(limbs)) => {\n            if let Some(log_log_base) = log_base.checked_log_base_2() {\n                match log_log_base.cmp(&Limb::LOG_WIDTH) {\n                    Equal => NaturalPowerOf2DigitPrimitiveIterator::SizeOfLimb(\n                        size_of_limb_iterator(limbs),\n                    ),\n                    Less => NaturalPowerOf2DigitPrimitiveIterator::FitsInLimb(\n                        fits_in_limb_iterator(limbs, log_base),\n                    ),\n                    Greater => NaturalPowerOf2DigitPrimitiveIterator::MultipleOfLimb(\n                        multiple_of_limb_iterator(limbs, log_base),\n                    ),\n                }\n            } else {\n                NaturalPowerOf2DigitPrimitiveIterator::Irregular(irregular_iterator(\n                    limbs, log_base,\n                ))\n            }\n        }\n    }\n}\n\nmacro_rules! iterables {\n    (\n        $t: ident\n    ) => {\n        impl<'a> PowerOf2DigitIterable<$t> for &'a Natural {\n            type PowerOf2DigitIterator = NaturalPowerOf2DigitPrimitiveIterator<'a, $t>;\n\n            /// Returns a double-ended iterator over the base-$2^k$ digits of a [`Natural`].\n            ///\n            /// The base-2 logarithm of the base is specified. Each digit has primitive integer\n            /// type, and `log_base` must be no larger than the width of that type. The forward\n            /// order is ascending, so that less significant digits appear first. There are no\n            /// trailing zero digits going forward, or leading zero digits going backward.\n            ///\n            /// If it's necessary to get a [`Vec`] of all the digits, consider using\n            /// [`to_power_of_2_digits_asc`](malachite_base::num::conversion::traits::PowerOf2Digits::to_power_of_2_digits_asc)\n            /// or\n            /// [`to_power_of_2_digits_desc`](malachite_base::num::conversion::traits::PowerOf2Digits::to_power_of_2_digits_desc)\n            /// instead.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2_digit_iterable#power_of_2_digits).\n            #[inline]\n            fn power_of_2_digits(\n                self,\n                log_base: u64,\n            ) -> NaturalPowerOf2DigitPrimitiveIterator<'a, $t> {\n                power_of_2_digits(self, log_base)\n            }\n        }\n    };\n}\napply_to_unsigneds!(iterables);\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct NaturalMultipleOfLimbIterator<'a>(NMOLIterator<'a>);\n\n#[derive(Clone, Debug)]\nstruct NMOLIterator<'a> {\n    log_ratio: u64,\n    limbs: &'a [Limb],\n    chunks: Chunks<'a, Limb>,\n}\n\nimpl Iterator for NMOLIterator<'_> {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        self.chunks.next().map(Natural::from_limbs_asc)\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        self.chunks.size_hint()\n    }\n}\n\nimpl DoubleEndedIterator for NMOLIterator<'_> {\n    fn next_back(&mut self) -> Option<Natural> {\n        self.chunks.next_back().map(Natural::from_limbs_asc)\n    }\n}\n\nimpl ExactSizeIterator for NMOLIterator<'_> {}\n\nimpl PowerOf2DigitIterator<Natural> for NMOLIterator<'_> {\n    fn get_digit(&self, index: u64) -> Natural {\n        let start_index = usize::exact_from(index << self.log_ratio);\n        if start_index >= self.limbs.len() {\n            Natural::ZERO\n        } else {\n            let end_index = min(\n                self.limbs.len(),\n                start_index + usize::power_of_2(self.log_ratio),\n            );\n            Natural::from_limbs_asc(&self.limbs[start_index..end_index])\n        }\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct NaturalIrregularIterator<'a>(NIIterator<'a>);\n\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\nstruct NIIterator<'a> {\n    limbs: &'a [Limb],\n    log_base: u64,\n    remaining: usize,\n    // This index initially points to the least-significant digit, and is incremented by next().\n    i: u64,\n    // This index initially points to the most-significant nonzero digit, and is decremented by\n    // next_back().\n    j: u64,\n}\n\nimpl Iterator for NIIterator<'_> {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.remaining != 0 {\n            let digit = self.get_digit(self.i);\n            self.i += 1;\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl DoubleEndedIterator for NIIterator<'_> {\n    fn next_back(&mut self) -> Option<Natural> {\n        if self.remaining != 0 {\n            let digit = self.get_digit(self.j);\n            self.j.saturating_sub_assign(1);\n            self.remaining -= 1;\n            Some(digit)\n        } else {\n            None\n        }\n    }\n}\n\nimpl ExactSizeIterator for NIIterator<'_> {}\n\nimpl NIIterator<'_> {\n    fn get_digit(&self, index: u64) -> Natural {\n        let start_index = index.checked_mul(self.log_base).unwrap();\n        Natural::from_owned_limbs_asc(limbs_slice_get_bits(\n            self.limbs,\n            start_index,\n            start_index + self.log_base,\n        ))\n    }\n}\n\n/// A double-ended iterator over the base-$2^k$ digits of a [`Natural`].\n///\n/// The base-2 logarithm of the base is specified. The type of each digit is [`Natural`]. The\n/// forward order is ascending (least-significant first). The iterator does not iterate over the\n/// implicit leading zero digits.\n///\n/// This struct also supports retrieving digits by index. This functionality is completely\n/// independent of the iterator's state. Indexing the implicit leading zero digits is allowed.\n#[derive(Clone, Debug)]\npub enum NaturalPowerOf2DigitIterator<'a> {\n    Small(PrimitivePowerOf2DigitIterator<Limb, Limb>),\n    SmallerThanLimb(NaturalPowerOf2DigitPrimitiveIterator<'a, Limb>),\n    MultipleOfLimb(NaturalMultipleOfLimbIterator<'a>),\n    Irregular(NaturalIrregularIterator<'a>),\n}\n\nimpl Iterator for NaturalPowerOf2DigitIterator<'_> {\n    type Item = Natural;\n\n    /// Iterates through the base-$2^k$ digits of a [`Natural`] in ascending order\n    /// (least-significant first).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `log_base`.\n    fn next(&mut self) -> Option<Natural> {\n        match self {\n            Self::Small(xs) => xs.next().map(Natural::from),\n            Self::SmallerThanLimb(xs) => xs.next().map(Natural::from),\n            Self::MultipleOfLimb(xs) => xs.0.next(),\n            Self::Irregular(xs) => xs.0.next(),\n        }\n    }\n\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        match self {\n            Self::Small(xs) => xs.size_hint(),\n            Self::SmallerThanLimb(xs) => xs.size_hint(),\n            Self::MultipleOfLimb(xs) => xs.0.size_hint(),\n            Self::Irregular(xs) => xs.0.size_hint(),\n        }\n    }\n}\n\nimpl DoubleEndedIterator for NaturalPowerOf2DigitIterator<'_> {\n    /// Iterate through the base-$2^k$ digits of a [`Natural`] in descending order (most-significant\n    /// first).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `log_base`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::PowerOf2DigitIterable;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n = Natural::ZERO;\n    /// assert_eq!(\n    ///     PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2).next(),\n    ///     None\n    /// );\n    ///\n    /// // 107 = 1223_4\n    /// let n = Natural::from(107u32);\n    /// let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2);\n    /// assert_eq!(digits.next_back(), Some(Natural::from(1u32)));\n    /// assert_eq!(digits.next_back(), Some(Natural::from(2u32)));\n    /// assert_eq!(digits.next_back(), Some(Natural::from(2u32)));\n    /// assert_eq!(digits.next_back(), Some(Natural::from(3u32)));\n    /// assert_eq!(digits.next_back(), None);\n    /// ```\n    fn next_back(&mut self) -> Option<Natural> {\n        match self {\n            Self::Small(xs) => xs.next_back().map(Natural::from),\n            Self::SmallerThanLimb(xs) => xs.next_back().map(Natural::from),\n            Self::MultipleOfLimb(xs) => xs.0.next_back(),\n            Self::Irregular(xs) => xs.0.next_back(),\n        }\n    }\n}\n\nimpl ExactSizeIterator for NaturalPowerOf2DigitIterator<'_> {}\n\nimpl PowerOf2DigitIterator<Natural> for NaturalPowerOf2DigitIterator<'_> {\n    /// Retrieves the base-$2^k$ digits of a [`Natural`] by index.\n    ///\n    /// $f(x, k, i) = d_i$, where $0 \\leq d_i < 2^k$ for all $i$ and\n    /// $$\n    /// \\sum_{i=0}^\\infty2^{ki}d_i = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `log_base`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::{\n    ///     PowerOf2DigitIterable, PowerOf2DigitIterator,\n    /// };\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n = Natural::ZERO;\n    /// assert_eq!(\n    ///     PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2).get_digit(0),\n    ///     0\n    /// );\n    ///\n    /// // 107 = 1223_4\n    /// let n = Natural::from(107u32);\n    /// let digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2);\n    /// assert_eq!(digits.get_digit(0), 3);\n    /// assert_eq!(digits.get_digit(1), 2);\n    /// assert_eq!(digits.get_digit(2), 2);\n    /// assert_eq!(digits.get_digit(3), 1);\n    /// assert_eq!(digits.get_digit(4), 0);\n    /// assert_eq!(digits.get_digit(100), 0);\n    /// ```\n    fn get_digit(&self, index: u64) -> Natural {\n        match self {\n            Self::Small(xs) => Natural::from(xs.get_digit(index)),\n            Self::SmallerThanLimb(xs) => Natural::from(xs.get_digit(index)),\n            Self::MultipleOfLimb(xs) => xs.0.get_digit(index),\n            Self::Irregular(xs) => xs.0.get_digit(index),\n        }\n    }\n}\n\nfn multiple_of_limb_fn(xs: &[Limb], log_base: u64) -> NaturalMultipleOfLimbIterator<'_> {\n    let log_ratio = log_base.floor_log_base_2() - Limb::LOG_WIDTH;\n    NaturalMultipleOfLimbIterator(NMOLIterator {\n        log_ratio,\n        limbs: xs,\n        chunks: xs.chunks(usize::power_of_2(log_ratio)),\n    })\n}\n\nfn irregular_fn(xs: &[Limb], log_base: u64) -> NaturalIrregularIterator<'_> {\n    let significant_digits = limbs_significant_bits(xs).div_round(log_base, Ceiling).0;\n    NaturalIrregularIterator(NIIterator {\n        limbs: xs,\n        log_base,\n        remaining: usize::exact_from(significant_digits),\n        i: 0,\n        j: significant_digits - 1,\n    })\n}\n\nimpl<'a> PowerOf2DigitIterable<Natural> for &'a Natural {\n    type PowerOf2DigitIterator = NaturalPowerOf2DigitIterator<'a>;\n\n    /// Returns a double-ended iterator over the base-$2^k$ digits of a [`Natural`].\n    ///\n    /// The base-2 logarithm of the base is specified. The type of each digit is [`Natural`]. The\n    /// forward order is ascending, so that less significant digits appear first. There are no\n    /// trailing zero digits going forward, or leading zero digits going backward.\n    ///\n    /// If it's necessary to get a [`Vec`] of all the digits, consider using\n    /// [`to_power_of_2_digits_asc`](malachite_base::num::conversion::traits::PowerOf2Digits::to_power_of_2_digits_asc)\n    /// or\n    /// [`to_power_of_2_digits_desc`](malachite_base::num::conversion::traits::PowerOf2Digits::to_power_of_2_digits_desc)\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::PowerOf2DigitIterable;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n = Natural::ZERO;\n    /// assert!(PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2)\n    ///     .next()\n    ///     .is_none());\n    ///\n    /// // 107 = 1223_4\n    /// let n = Natural::from(107u32);\n    /// assert_eq!(\n    ///     PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2).collect_vec(),\n    ///     vec![\n    ///         Natural::from(3u32),\n    ///         Natural::from(2u32),\n    ///         Natural::from(2u32),\n    ///         Natural::from(1u32)\n    ///     ]\n    /// );\n    ///\n    /// let n = Natural::ZERO;\n    /// assert!(PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2)\n    ///     .next_back()\n    ///     .is_none());\n    ///\n    /// // 107 = 1223_4\n    /// let n = Natural::from(107u32);\n    /// assert_eq!(\n    ///     PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2)\n    ///         .rev()\n    ///         .collect_vec(),\n    ///     vec![\n    ///         Natural::from(1u32),\n    ///         Natural::from(2u32),\n    ///         Natural::from(2u32),\n    ///         Natural::from(3u32)\n    ///     ]\n    /// );\n    /// ```\n    fn power_of_2_digits(self, log_base: u64) -> NaturalPowerOf2DigitIterator<'a> {\n        assert_ne!(log_base, 0);\n        match self {\n            Natural(Small(small)) => NaturalPowerOf2DigitIterator::Small(PowerOf2DigitIterable::<\n                Limb,\n            >::power_of_2_digits(\n                *small,\n                min(log_base, Limb::WIDTH),\n            )),\n            Natural(Large(limbs)) => {\n                if let Some(log_log_base) = log_base.checked_log_base_2() {\n                    if log_log_base <= Limb::LOG_WIDTH {\n                        NaturalPowerOf2DigitIterator::SmallerThanLimb(\n                            PowerOf2DigitIterable::<Limb>::power_of_2_digits(self, log_base),\n                        )\n                    } else {\n                        NaturalPowerOf2DigitIterator::MultipleOfLimb(multiple_of_limb_fn(\n                            limbs, log_base,\n                        ))\n                    }\n                } else {\n                    NaturalPowerOf2DigitIterator::Irregular(irregular_fn(limbs, log_base))\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/digits/power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::{Ordering::*, min};\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::{CheckedLogBase2, DivRound, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, PowerOf2Digits, WrappingFrom};\nuse malachite_base::num::iterators::iterator_to_bit_chunks;\nuse malachite_base::num::logic::traits::{BitBlockAccess, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::slice_trailing_zeros;\n\nimpl Natural {\n    pub_test! {to_power_of_2_digits_asc_naive<\n        T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n    >(\n        &self,\n        log_base: u64,\n    ) -> Vec<T> {\n        assert_ne!(log_base, 0);\n            assert!(log_base <= T::WIDTH,\n                \"type {:?} is too small for a digit of width {}\",\n                T::NAME,\n                log_base\n            );\n        let digit_len = self\n            .significant_bits()\n            .div_round(log_base, Ceiling).0;\n        let mut digits = Vec::with_capacity(usize::exact_from(digit_len));\n        let mut previous_index = 0;\n        for _ in 0..digit_len {\n            let index = previous_index + log_base;\n            digits.push(T::exact_from(&self.get_bits(previous_index, index)));\n            previous_index = index;\n        }\n        digits\n    }}\n\n    pub_test! {from_power_of_2_digits_asc_naive<T: PrimitiveUnsigned, I: Iterator<Item = T>>(\n        log_base: u64,\n        digits: I,\n    ) -> Option<Natural>\n    where\n        Natural: From<T>,\n    {\n        assert_ne!(log_base, 0);\n            assert!(log_base <= T::WIDTH,\n                \"type {:?} is too small for a digit of width {}\",\n                T::NAME,\n                log_base\n            );\n        let mut n = Natural::ZERO;\n        let mut previous_index = 0;\n        for digit in digits {\n            if digit.significant_bits() > log_base {\n                return None;\n            }\n            let index = previous_index + log_base;\n            n.assign_bits(previous_index, index, &Natural::from(digit));\n            previous_index = index;\n        }\n        Some(n)\n    }}\n}\n\nfn to_power_of_2_digits_asc_nz<T: PrimitiveUnsigned>(x: &Natural, log_base: u64) -> Vec<T>\nwhere\n    Limb: PowerOf2Digits<T>,\n{\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= T::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        T::NAME,\n        log_base\n    );\n    let limbs = match x {\n        Natural(Small(small)) => {\n            return PowerOf2Digits::<T>::to_power_of_2_digits_asc(\n                small,\n                min(log_base, Limb::WIDTH),\n            );\n        }\n        Natural(Large(limbs)) => limbs,\n    };\n    let mut digits = iterator_to_bit_chunks(limbs.iter().copied(), Limb::WIDTH, log_base)\n        .map(Option::unwrap)\n        .collect_vec();\n    digits.truncate(digits.len() - slice_trailing_zeros(&digits));\n    digits\n}\n\nfn to_power_of_2_digits_desc_nz<T>(x: &Natural, log_base: u64) -> Vec<T>\nwhere\n    Natural: PowerOf2Digits<T>,\n{\n    let mut digits = x.to_power_of_2_digits_asc(log_base);\n    digits.reverse();\n    digits\n}\n\nfn from_power_of_2_digits_asc_nz<T: PrimitiveUnsigned, I: Iterator<Item = T>>(\n    log_base: u64,\n    digits: I,\n) -> Option<Natural>\nwhere\n    Limb: WrappingFrom<T>,\n{\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= T::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        T::NAME,\n        log_base\n    );\n    let mut limbs = Vec::new();\n    for digit in iterator_to_bit_chunks(digits, log_base, Limb::WIDTH) {\n        limbs.push(digit?);\n    }\n    Some(Natural::from_owned_limbs_asc(limbs))\n}\n\nfn from_power_of_2_digits_desc_nz<T: PrimitiveUnsigned, I: Iterator<Item = T>>(\n    log_base: u64,\n    digits: I,\n) -> Option<Natural>\nwhere\n    Limb: WrappingFrom<T>,\n{\n    assert_ne!(log_base, 0);\n    assert!(\n        log_base <= T::WIDTH,\n        \"type {:?} is too small for a digit of width {}\",\n        T::NAME,\n        log_base\n    );\n    let digits = digits.collect_vec();\n    let mut limbs = Vec::new();\n    for digit in iterator_to_bit_chunks(digits.iter().copied().rev(), log_base, Limb::WIDTH) {\n        limbs.push(digit?);\n    }\n    Some(Natural::from_owned_limbs_asc(limbs))\n}\n\nmacro_rules! power_of_2_digits_unsigned {\n    (\n        $t: ident\n    ) => {\n        impl PowerOf2Digits<$t> for Natural {\n            /// Returns a [`Vec`] containing the base-$2^k$ digits of a [`Natural`] in ascending\n            /// order: least- to most-significant.\n            ///\n            /// The base-2 logarithm of the base is specified. Each digit has primitive integer\n            /// type, and `log_base` must be no larger than the width of that type. If the\n            /// [`Natural`] is 0, the [`Vec`] is empty; otherwise, it ends with a nonzero digit.\n            ///\n            /// $f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \\leq d_i < 2^k$ for all $i$, $n=0$ or\n            /// $d_{n-1} \\neq 0$, and\n            ///\n            /// $$\n            /// \\sum_{i=0}^{n-1}2^{ki}d_i = x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `log_base` is greater than the width of the digit type, or if `log_base`\n            /// is zero.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2_digits#to_power_of_2_digits_asc).\n            #[inline]\n            fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<$t> {\n                to_power_of_2_digits_asc_nz(self, log_base)\n            }\n\n            /// Returns a [`Vec`] containing the base-$2^k$ digits of a [`Natural`] in descending\n            /// order: most- to least-significant.\n            ///\n            /// The base-2 logarithm of the base is specified. Each digit has primitive integer\n            /// type, and `log_base` must be no larger than the width of that type. If the\n            /// [`Natural`] is 0, the [`Vec`] is empty; otherwise, it begins with a nonzero digit.\n            ///\n            /// $f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \\leq d_i < 2^k$ for all $i$, $n=0$ or $d_0\n            /// \\neq 0$, and\n            ///\n            /// $$\n            /// \\sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if `log_base` is greater than the width of the digit type, or if `log_base`\n            /// is zero.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2_digits#to_power_of_2_digits_desc).\n            #[inline]\n            fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<$t> {\n                to_power_of_2_digits_desc_nz(self, log_base)\n            }\n\n            /// Converts an iterator of base-$2^k$ digits into a [`Natural`].\n            ///\n            /// The base-2 logarithm of the base is specified. The input digits are in ascending\n            /// order: least- to most-significant. Each digit has primitive integer type, and\n            /// `log_base` must be no larger than the width of that type.\n            ///\n            /// If some digit is greater than $2^k$, `None` is returned.\n            ///\n            /// $$\n            /// f((d_i)_ {i=0}^{n-1}, k) = \\sum_{i=0}^{n-1}2^{ki}d_i.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n            ///\n            /// # Panics\n            /// Panics if `log_base` is zero or greater than the width of the digit type.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2_digits#from_power_of_2_digits_asc).\n            #[inline]\n            fn from_power_of_2_digits_asc<I: Iterator<Item = $t>>(\n                log_base: u64,\n                digits: I,\n            ) -> Option<Natural> {\n                from_power_of_2_digits_asc_nz(log_base, digits)\n            }\n\n            /// Converts an iterator of base-$2^k$ digits into a [`Natural`].\n            ///\n            /// The base-2 logarithm of the base is specified. The input digits are in descending\n            /// order: most- to least-significant. Each digit has primitive integer type, and\n            /// `log_base` must be no larger than the width of that type.\n            ///\n            /// If some digit is greater than $2^k$, `None` is returned.\n            ///\n            /// $$\n            /// f((d_i)_ {i=0}^{n-1}, k) = \\sum_{i=0}^{n-1}2^{k (n-i-1)}d_i.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `digits.count()`.\n            ///\n            /// # Panics\n            /// Panics if `log_base` is zero or greater than the width of the digit type.\n            ///\n            /// # Examples\n            /// See [here](super::power_of_2_digits#from_power_of_2_digits_desc).\n            #[inline]\n            fn from_power_of_2_digits_desc<I: Iterator<Item = $t>>(\n                log_base: u64,\n                digits: I,\n            ) -> Option<Natural> {\n                from_power_of_2_digits_desc_nz(log_base, digits)\n            }\n        }\n    };\n}\napply_to_unsigneds!(power_of_2_digits_unsigned);\n\nimpl PowerOf2Digits<Self> for Natural {\n    /// Returns a [`Vec`] containing the base-$2^k$ digits of a [`Natural`] in ascending order:\n    /// least- to most-significant.\n    ///\n    /// The base-2 logarithm of the base is specified. The type of each digit is [`Natural`]. If the\n    /// [`Natural`] is 0, the [`Vec`] is empty; otherwise, it ends with a nonzero digit.\n    ///\n    /// $f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \\leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \\neq\n    /// 0$, and\n    ///\n    /// $$\n    /// \\sum_{i=0}^{n-1}2^{ki}d_i = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_base::num::conversion::traits::PowerOf2Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&Natural::ZERO, 6)\n    ///         .to_debug_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&Natural::TWO, 6).to_debug_string(),\n    ///     \"[2]\"\n    /// );\n    ///\n    /// // 123_10 = 173_8\n    /// assert_eq!(\n    ///     PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&Natural::from(123u32), 3)\n    ///         .to_debug_string(),\n    ///     \"[3, 7, 1]\"\n    /// );\n    /// ```\n    fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<Self> {\n        assert_ne!(log_base, 0);\n        if log_base <= Limb::WIDTH || self.limb_count() < 2 {\n            return PowerOf2Digits::<Limb>::to_power_of_2_digits_asc(\n                self,\n                min(log_base, Limb::WIDTH),\n            )\n            .iter()\n            .copied()\n            .map(Self::from)\n            .collect();\n        }\n        let limbs = match self {\n            Self(Large(limbs)) => limbs,\n            _ => unreachable!(),\n        };\n        let mut digits = Vec::new();\n        if let Some(log_log_base) = log_base.checked_log_base_2() {\n            assert!(log_log_base > Limb::LOG_WIDTH);\n            digits.extend(\n                limbs\n                    .chunks(usize::power_of_2(log_log_base - Limb::LOG_WIDTH))\n                    .map(Self::from_limbs_asc),\n            );\n        } else {\n            let mut digit = Self::ZERO;\n            let mut remaining_digit_bits = log_base;\n            for &limb in limbs {\n                let mut limb = limb;\n                let mut remaining_limb_bits = Limb::WIDTH;\n                while remaining_limb_bits != 0 {\n                    let digit_index = log_base - remaining_digit_bits;\n                    if remaining_limb_bits <= remaining_digit_bits {\n                        digit.assign_bits(\n                            digit_index,\n                            digit_index + remaining_limb_bits,\n                            &Self::from(limb),\n                        );\n                        remaining_digit_bits -= remaining_limb_bits;\n                        remaining_limb_bits = 0;\n                    } else {\n                        digit.assign_bits(digit_index, log_base, &Self::from(limb));\n                        limb >>= remaining_digit_bits;\n                        remaining_limb_bits -= remaining_digit_bits;\n                        remaining_digit_bits = 0;\n                    }\n                    if remaining_digit_bits == 0 {\n                        digits.push(digit);\n                        digit = Self::ZERO;\n                        remaining_digit_bits = log_base;\n                    }\n                }\n            }\n            if digit != 0 {\n                digits.push(digit);\n            }\n        }\n        digits.truncate(digits.len() - slice_trailing_zeros(&digits));\n        digits\n    }\n\n    /// Returns a [`Vec`] containing the base-$2^k$ digits of a [`Natural`] in descending order:\n    /// most- to least-significant.\n    ///\n    /// The base-2 logarithm of the base is specified. The type of each digit is [`Natural`]. If the\n    /// [`Natural`] is 0, the [`Vec`] is empty; otherwise, it begins with a nonzero digit.\n    ///\n    /// $f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \\leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \\neq 0$,\n    /// and\n    ///\n    /// $$\n    /// \\sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_base::num::conversion::traits::PowerOf2Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&Natural::ZERO, 6)\n    ///         .to_debug_string(),\n    ///     \"[]\"\n    /// );\n    /// assert_eq!(\n    ///     PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&Natural::TWO, 6)\n    ///         .to_debug_string(),\n    ///     \"[2]\"\n    /// );\n    ///\n    /// // 123_10 = 173_8\n    /// assert_eq!(\n    ///     PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&Natural::from(123u32), 3)\n    ///         .to_debug_string(),\n    ///     \"[1, 7, 3]\"\n    /// );\n    /// ```\n    fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<Self> {\n        let mut digits = self.to_power_of_2_digits_asc(log_base);\n        digits.reverse();\n        digits\n    }\n\n    /// Converts an iterator of base-$2^k$ digits into a [`Natural`].\n    ///\n    /// The base-2 logarithm of the base is specified. The input digits are in ascending order:\n    /// least- to most-significant. The type of each digit is [`Natural`].\n    ///\n    /// If some digit is greater than $2^k$, `None` is returned.\n    ///\n    /// $$\n    /// f((d_i)_ {i=0}^{n-1}, k) = \\sum_{i=0}^{n-1}2^{ki}d_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm)$\n    ///\n    /// $M(n, m) = O(nm)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `digits.count()`, and $m$ is `log_base`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Two, Zero};\n    /// use malachite_base::num::conversion::traits::PowerOf2Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let digits = &[Natural::ZERO, Natural::ZERO, Natural::ZERO];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_asc(6, digits.iter().cloned()).to_debug_string(),\n    ///     \"Some(0)\"\n    /// );\n    ///\n    /// let digits = &[Natural::TWO, Natural::ZERO];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_asc(6, digits.iter().cloned()).to_debug_string(),\n    ///     \"Some(2)\"\n    /// );\n    ///\n    /// let digits = &[Natural::from(3u32), Natural::from(7u32), Natural::ONE];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_asc(3, digits.iter().cloned()).to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    ///\n    /// let digits = &[Natural::from(100u32)];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_asc(3, digits.iter().cloned()).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// ```\n    fn from_power_of_2_digits_asc<I: Iterator<Item = Self>>(\n        log_base: u64,\n        digits: I,\n    ) -> Option<Self> {\n        assert_ne!(log_base, 0);\n        if let Some(log_log_base) = log_base.checked_log_base_2() {\n            let mut limbs = Vec::new();\n            match log_log_base.cmp(&Limb::LOG_WIDTH) {\n                Equal => {\n                    for digit in digits {\n                        if digit.significant_bits() > log_base {\n                            return None;\n                        }\n                        limbs.push(Limb::wrapping_from(&digit));\n                    }\n                }\n                Less => {\n                    for chunk in &digits.chunks(usize::wrapping_from(Limb::WIDTH >> log_log_base)) {\n                        let mut limb = 0;\n                        let mut offset = 0;\n                        for digit in chunk {\n                            if digit.significant_bits() > log_base {\n                                return None;\n                            }\n                            limb |= Limb::wrapping_from(&digit) << offset;\n                            offset += log_base;\n                        }\n                        limbs.push(limb);\n                    }\n                }\n                Greater => {\n                    let mut offset = 0;\n                    let chunk_size = bit_to_limb_count_floor(log_base);\n                    for digit in digits {\n                        if digit.significant_bits() > log_base {\n                            return None;\n                        }\n                        offset += chunk_size;\n                        limbs.extend(digit.limbs());\n                        limbs.resize(offset, 0);\n                    }\n                }\n            }\n            Some(Self::from_owned_limbs_asc(limbs))\n        } else {\n            let mut n = Self::ZERO;\n            let mut previous_index = 0;\n            for digit in digits {\n                if digit.significant_bits() > log_base {\n                    return None;\n                }\n                let index = previous_index + log_base;\n                n.assign_bits(previous_index, index, &digit);\n                previous_index = index;\n            }\n            Some(n)\n        }\n    }\n\n    /// Converts an iterator of base-$2^k$ digits into a [`Natural`].\n    ///\n    /// The base-2 logarithm of the base is specified. The input digits are in descending order:\n    /// most- to least-significant. The type of each digit is [`Natural`].\n    ///\n    /// If some digit is greater than $2^k$, `None` is returned.\n    ///\n    /// $$\n    /// f((d_i)_ {i=0}^{n-1}, k) = \\sum_{i=0}^{n-1}2^{k (n-i-1)}d_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm)$\n    ///\n    /// $M(n, m) = O(nm)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `digits.count()`, and $m$ is `log_base`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Two, Zero};\n    /// use malachite_base::num::conversion::traits::PowerOf2Digits;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let digits = &[Natural::ZERO, Natural::ZERO, Natural::ZERO];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_desc(6, digits.iter().cloned()).to_debug_string(),\n    ///     \"Some(0)\"\n    /// );\n    ///\n    /// let digits = &[Natural::ZERO, Natural::TWO];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_desc(6, digits.iter().cloned()).to_debug_string(),\n    ///     \"Some(2)\"\n    /// );\n    ///\n    /// let digits = &[Natural::ONE, Natural::from(7u32), Natural::from(3u32)];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_desc(3, digits.iter().cloned()).to_debug_string(),\n    ///     \"Some(123)\"\n    /// );\n    ///\n    /// let digits = &[Natural::from(100u32)];\n    /// assert_eq!(\n    ///     Natural::from_power_of_2_digits_desc(3, digits.iter().cloned()).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// ```\n    fn from_power_of_2_digits_desc<I: Iterator<Item = Self>>(\n        log_base: u64,\n        digits: I,\n    ) -> Option<Self> {\n        assert_ne!(log_base, 0);\n        if let Some(log_log_base) = log_base.checked_log_base_2() {\n            let mut limbs = Vec::new();\n            match log_log_base.cmp(&Limb::LOG_WIDTH) {\n                Equal => {\n                    for digit in digits {\n                        if digit.significant_bits() > log_base {\n                            return None;\n                        }\n                        limbs.push(Limb::wrapping_from(&digit));\n                    }\n                    limbs.reverse();\n                }\n                Less => {\n                    let digits = digits.collect_vec();\n                    for chunk in digits.rchunks(usize::wrapping_from(Limb::WIDTH >> log_log_base)) {\n                        let mut limb = 0;\n                        let mut offset = 0;\n                        for digit in chunk.iter().rev() {\n                            if digit.significant_bits() > log_base {\n                                return None;\n                            }\n                            limb |= Limb::wrapping_from(digit) << offset;\n                            offset += log_base;\n                        }\n                        limbs.push(limb);\n                    }\n                }\n                Greater => {\n                    let digits = digits.collect_vec();\n                    let mut offset = 0;\n                    let chunk_size = bit_to_limb_count_floor(log_base);\n                    for digit in digits.iter().rev() {\n                        if digit.significant_bits() > log_base {\n                            return None;\n                        }\n                        offset += chunk_size;\n                        limbs.extend(digit.limbs());\n                        limbs.resize(offset, 0);\n                    }\n                }\n            }\n            Some(Self::from_owned_limbs_asc(limbs))\n        } else {\n            let digits = digits.collect_vec();\n            let mut n = Self::ZERO;\n            let mut previous_index = 0;\n            for digit in digits.iter().rev() {\n                if digit.significant_bits() > log_base {\n                    return None;\n                }\n                let index = previous_index + log_base;\n                n.assign_bits(previous_index, index, digit);\n                previous_index = index;\n            }\n            Some(n)\n        }\n    }\n}\n\nimpl Natural {\n    pub_test! {to_power_of_2_digits_asc_natural_naive(&self, log_base: u64) -> Vec<Natural> {\n        assert_ne!(log_base, 0);\n        let digit_len = self\n            .significant_bits()\n            .div_round(log_base, Ceiling).0;\n        let mut digits = Vec::with_capacity(usize::exact_from(digit_len));\n        let mut previous_index = 0;\n        for _ in 0..digit_len {\n            let index = previous_index + log_base;\n            digits.push(self.get_bits(previous_index, index));\n            previous_index = index;\n        }\n        digits\n    }}\n\n    pub_test! {from_power_of_2_digits_asc_natural_naive<I: Iterator<Item = Natural>>(\n        log_base: u64,\n        digits: I,\n    ) -> Option<Natural> {\n        assert_ne!(log_base, 0);\n        let mut n = Natural::ZERO;\n        let mut previous_index = 0;\n        for digit in digits {\n            if digit.significant_bits() > log_base {\n                return None;\n            }\n            let index = previous_index + log_base;\n            n.assign_bits(previous_index, index, &digit);\n            previous_index = index;\n        }\n        Some(n)\n    }}\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::basic::traits::{One, Zero};\n\nimpl From<bool> for Natural {\n    /// Converts a [`bool`] to 0 or 1.\n    ///\n    /// This function is known as the [Iverson\n    /// bracket](https://en.wikipedia.org/wiki/Iverson_bracket).\n    ///\n    /// $$\n    /// f(P) = \\[P\\] = \\\\begin{cases}\n    ///     1 & \\text{if} \\\\quad P, \\\\\\\\\n    ///     0 & \\\\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(false), 0);\n    /// assert_eq!(Natural::from(true), 1);\n    /// ```\n    #[inline]\n    fn from(b: bool) -> Self {\n        if b { Self::ONE } else { Self::ZERO }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/from_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::basic::traits::Zero;\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// Returns the length of `xs`, excluding trailing zeros.\nfn limbs_significant_length(xs: &[Limb]) -> usize {\n    xs.iter()\n        .enumerate()\n        .rev()\n        .find(|&(_, &x)| x != 0)\n        .map_or(0, |(i, _)| i + 1)\n}\n\nimpl Natural {\n    /// Converts a slice of [limbs](crate#limbs) to a [`Natural`].\n    ///\n    /// The limbs are in ascending order, so that less-significant limbs have lower indices in the\n    /// input slice.\n    ///\n    /// This function borrows the limbs. If taking ownership of limbs is possible,\n    /// [`from_owned_limbs_asc`](Self::from_owned_limbs_asc) is more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// This function is more efficient than [`from_limbs_desc`](Self::from_limbs_desc).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::from_limbs_asc(&[]), 0);\n    ///     assert_eq!(Natural::from_limbs_asc(&[123]), 123);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from_limbs_asc(&[3567587328, 232]),\n    ///         1000000000000u64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_limbs_asc(xs: &[Limb]) -> Self {\n        let significant_length = limbs_significant_length(xs);\n        match significant_length {\n            0 => Self::ZERO,\n            1 => Self(Small(xs[0])),\n            _ => Self(Large(xs[..significant_length].to_vec())),\n        }\n    }\n\n    /// Converts a slice of [limbs](crate#limbs) to a [`Natural`].\n    ///\n    /// The limbs in descending order, so that less-significant limbs have higher indices in the\n    /// input slice.\n    ///\n    /// This function borrows the limbs. If taking ownership of the limbs is possible,\n    /// [`from_owned_limbs_desc`](Self::from_owned_limbs_desc) is more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// This function is less efficient than [`from_limbs_asc`](Self::from_limbs_asc).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::from_limbs_desc(&[]), 0);\n    ///     assert_eq!(Natural::from_limbs_desc(&[123]), 123);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from_limbs_desc(&[232, 3567587328]),\n    ///         1000000000000u64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_limbs_desc(xs: &[Limb]) -> Self {\n        Self::from_owned_limbs_asc(xs.iter().copied().rev().collect())\n    }\n\n    /// Converts a [`Vec`] of [limbs](crate#limbs) to a [`Natural`].\n    ///\n    /// The limbs are in ascending order, so that less-significant limbs have lower indices in the\n    /// input [`Vec`].\n    ///\n    /// This function takes ownership of the limbs. If it's necessary to borrow the limbs instead,\n    /// use [`from_limbs_asc`](Self::from_limbs_asc).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// This function is more efficient than [`from_limbs_desc`](Self::from_limbs_desc).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::from_owned_limbs_asc(vec![]), 0);\n    ///     assert_eq!(Natural::from_owned_limbs_asc(vec![123]), 123);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from_owned_limbs_asc(vec![3567587328, 232]),\n    ///         1000000000000u64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_owned_limbs_asc(mut xs: Vec<Limb>) -> Self {\n        let significant_length = limbs_significant_length(&xs);\n        match significant_length {\n            0 => Self::ZERO,\n            1 => Self(Small(xs[0])),\n            _ => {\n                xs.truncate(significant_length);\n                Self(Large(xs))\n            }\n        }\n    }\n\n    /// Converts a [`Vec`] of [limbs](crate#limbs) to a [`Natural`].\n    ///\n    /// The limbs are in descending order, so that less-significant limbs have higher indices in the\n    /// input [`Vec`].\n    ///\n    /// This function takes ownership of the limbs. If it's necessary to borrow the limbs instead,\n    /// use [`from_limbs_desc`](Self::from_limbs_desc).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n    ///\n    /// This function is less efficient than [`from_limbs_asc`](Self::from_limbs_asc).\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::from_owned_limbs_desc(vec![]), 0);\n    ///     assert_eq!(Natural::from_owned_limbs_desc(vec![123]), 123);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from_owned_limbs_desc(vec![232, 3567587328]),\n    ///         1000000000000u64\n    ///     );\n    /// }\n    /// ```\n    pub fn from_owned_limbs_desc(mut xs: Vec<Limb>) -> Self {\n        xs.reverse();\n        Self::from_owned_limbs_asc(xs)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::ShlRound;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, IntegerMantissaAndExponent, IsInteger, RoundingFrom,\n};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nmacro_rules! float_impls {\n    ($f: ident) => {\n        impl RoundingFrom<$f> for Natural {\n            /// Converts a floating-point value to a [`Natural`], using the specified rounding mode.\n            /// An [`Ordering`] is also returned, indicating whether the returned value is less\n            /// than, equal to, or greater than the original value.\n            ///\n            /// The floating-point value cannot be NaN or infinite, and it cannot round to a\n            /// negative integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.sci_exponent()`.\n            ///\n            /// # Panics\n            /// Panics if `value` is NaN or infinite, if it would round to a negative integer, or if\n            /// the rounding mode is `Exact` and `value` is not an integer.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#rounding_from).\n            fn rounding_from(value: $f, rm: RoundingMode) -> (Self, Ordering) {\n                if value.is_nan() || value == $f::INFINITY {\n                    panic!(\"Cannot convert {} to Natural\", value);\n                } else if value == 0.0 {\n                    (Natural::ZERO, Equal)\n                } else if value < 0.0 {\n                    if rm == Down || rm == Ceiling || rm == Nearest {\n                        (Natural::ZERO, Greater)\n                    } else {\n                        panic!(\"Result is negative and cannot be converted to a Natural\");\n                    }\n                } else {\n                    let (mantissa, exponent) = value.integer_mantissa_and_exponent();\n                    Natural::from(mantissa).shl_round(exponent, rm)\n                }\n            }\n        }\n\n        impl TryFrom<$f> for Natural {\n            type Error = UnsignedFromFloatError;\n\n            /// Converts a floating-point value to a [`Natural`].\n            ///\n            /// If the input isn't exactly equal to some [`Natural`], an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.sci_exponent()`.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#try_from).\n            fn try_from(value: $f) -> Result<Natural, Self::Error> {\n                if value.is_nan() || value.is_infinite() {\n                    Err(UnsignedFromFloatError::FloatInfiniteOrNan)\n                } else if value < 0.0 {\n                    Err(UnsignedFromFloatError::FloatNegative)\n                } else if value == 0.0 {\n                    Ok(Natural::ZERO)\n                } else {\n                    let (mantissa, exponent) = value.integer_mantissa_and_exponent();\n                    if exponent >= 0 {\n                        Ok(Natural::from(mantissa) << exponent)\n                    } else {\n                        Err(UnsignedFromFloatError::FloatNonIntegerOrOutOfRange)\n                    }\n                }\n            }\n        }\n\n        impl ConvertibleFrom<$f> for Natural {\n            /// Determines whether a floating-point value can be exactly converted to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#convertible_from).\n            #[inline]\n            fn convertible_from(value: $f) -> bool {\n                value >= 0.0 && value.is_integer()\n            }\n        }\n    };\n}\napply_to_primitive_floats!(float_impls);\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::Small;\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, SaturatingFrom, VecFromOtherType};\n\nimpl Natural {\n    /// Converts a [`Limb`](crate#limbs) to a [`Natural`].\n    ///\n    /// This function is const, so it may be used to define constants.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// const TEN: Natural = Natural::const_from(10);\n    /// assert_eq!(TEN, 10);\n    /// ```\n    pub const fn const_from(x: Limb) -> Self {\n        Self(Small(x))\n    }\n}\n\nmacro_rules! impl_from_limb {\n    ($t: ident) => {\n        impl From<$t> for Natural {\n            /// Converts a [`Limb`](crate#limbs) to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(u: $t) -> Natural {\n                Natural(Small(u))\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_smaller_than_limb {\n    ($t: ident) => {\n        impl From<$t> for Natural {\n            /// Converts an unsigned primitive integer to a [`Natural`], where the integer's width\n            /// is smaller than a [`Limb`](crate#limbs)'s.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(u: $t) -> Natural {\n                Natural(Small(Limb::from(u)))\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_larger_than_limb_or_usize {\n    ($t: ident) => {\n        impl From<$t> for Natural {\n            /// Converts an unsigned primitive integer to a [`Natural`], where the integer's width\n            /// is larger than a [`Limb`](crate#limbs)'s.\n            ///\n            /// This implementation is general enough to also work for [`usize`], regardless of\n            /// whether it is equal in width to [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(u: $t) -> Natural {\n                Natural::from_owned_limbs_asc(Limb::vec_from_other_type(u))\n            }\n        }\n    };\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct NaturalFromSignedError;\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl TryFrom<$t> for Natural {\n            type Error = NaturalFromSignedError;\n\n            /// Converts a signed primitive integer to a [`Natural`]. If the integer is negative, an\n            /// error is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#try_from).\n            #[inline]\n            fn try_from(i: $t) -> Result<Natural, Self::Error> {\n                if i >= 0 {\n                    Ok(Natural::from(i.unsigned_abs()))\n                } else {\n                    Err(NaturalFromSignedError)\n                }\n            }\n        }\n\n        impl ConvertibleFrom<$t> for Natural {\n            /// Determines whether a signed primitive integer can be converted to a [`Natural`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#convertible_from).\n            #[inline]\n            fn convertible_from(i: $t) -> bool {\n                i >= 0\n            }\n        }\n\n        impl SaturatingFrom<$t> for Natural {\n            /// Converts a signed primitive primitive integer to a [`Natural`]. If the integer is\n            /// negative, 0 is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#saturating_from).\n            #[inline]\n            fn saturating_from(i: $t) -> Natural {\n                if i >= 0 {\n                    Natural::from(i.unsigned_abs())\n                } else {\n                    Natural::ZERO\n                }\n            }\n        }\n    };\n}\n\nimpl_from_smaller_than_limb!(u8);\nimpl_from_smaller_than_limb!(u16);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_from_limb!(u32);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_from_smaller_than_limb!(u32);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_from_larger_than_limb_or_usize!(u64);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_from_limb!(u64);\nimpl_from_larger_than_limb_or_usize!(u128);\nimpl_from_larger_than_limb_or_usize!(usize);\n\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::IsInteger;\n\nimpl IsInteger for &Natural {\n    /// Determines whether a [`Natural`] is an integer. It always returns `true`.\n    ///\n    /// $f(x) = \\textrm{true}$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::num::conversion::traits::IsInteger;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.is_integer(), true);\n    /// assert_eq!(Natural::ONE.is_integer(), true);\n    /// assert_eq!(Natural::from(100u32).is_integer(), true);\n    /// ```\n    #[inline]\n    fn is_integer(self) -> bool {\n        true\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/limb_count.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::WrappingFrom;\n\nimpl Natural {\n    /// Returns the number of limbs of a [`Natural`].\n    ///\n    /// Zero has 0 limbs.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::ZERO.limb_count(), 0);\n    ///     assert_eq!(Natural::from(123u32).limb_count(), 1);\n    ///     assert_eq!(Natural::from(10u32).pow(12).limb_count(), 2);\n    /// }\n    /// ```\n    pub fn limb_count(&self) -> u64 {\n        match self {\n            &Self::ZERO => 0,\n            Self(Small(_)) => 1,\n            Self(Large(limbs)) => u64::wrapping_from(limbs.len()),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::logic::bit_access::limbs_get_bit;\nuse crate::natural::logic::bit_scan::limbs_index_of_next_true_bit;\nuse crate::natural::{LIMB_HIGH_BIT, Natural};\nuse crate::natural::{bit_to_limb_count_floor, limb_to_bit_count};\nuse crate::platform::Limb;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Assign, Parity, ShrRound, Sign,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, FromOtherTypeSlice, IntegerMantissaAndExponent, SciMantissaAndExponent, WrappingFrom,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::slices::{slice_set_zero, slice_test_zero};\n\nconst TWICE_WIDTH: u64 = Limb::WIDTH << 1;\n\nimpl Natural {\n    /// Returns a [`Natural`]'s scientific mantissa and exponent, rounding according to the\n    /// specified rounding mode. An [`Ordering`] is also returned, indicating whether the mantissa\n    /// and exponent represent a value that is less than, equal to, or greater than the original\n    /// value.\n    ///\n    /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is\n    /// a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa as a float. The\n    /// conversion might not be exact, so we round to the nearest float using the provided rounding\n    /// mode. If the rounding mode is `Exact` but the conversion is not exact, `None` is returned.\n    /// $$\n    /// f(x, r) \\approx \\left (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}},\n    ///     \\lfloor \\log_2 x \\rfloor\\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::{self, *};\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::float::NiceFloat;\n    /// use malachite_base::rounding_modes::RoundingMode::{self, *};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let test = |n: Natural, rm: RoundingMode, out: Option<(f32, u64, Ordering)>| {\n    ///     assert_eq!(\n    ///         n.sci_mantissa_and_exponent_round(rm)\n    ///             .map(|(m, e, o)| (NiceFloat(m), e, o)),\n    ///         out.map(|(m, e, o)| (NiceFloat(m), e, o))\n    ///     );\n    /// };\n    /// test(Natural::from(3u32), Floor, Some((1.5, 1, Equal)));\n    /// test(Natural::from(3u32), Down, Some((1.5, 1, Equal)));\n    /// test(Natural::from(3u32), Ceiling, Some((1.5, 1, Equal)));\n    /// test(Natural::from(3u32), Up, Some((1.5, 1, Equal)));\n    /// test(Natural::from(3u32), Nearest, Some((1.5, 1, Equal)));\n    /// test(Natural::from(3u32), Exact, Some((1.5, 1, Equal)));\n    ///\n    /// test(Natural::from(123u32), Floor, Some((1.921875, 6, Equal)));\n    /// test(Natural::from(123u32), Down, Some((1.921875, 6, Equal)));\n    /// test(Natural::from(123u32), Ceiling, Some((1.921875, 6, Equal)));\n    /// test(Natural::from(123u32), Up, Some((1.921875, 6, Equal)));\n    /// test(Natural::from(123u32), Nearest, Some((1.921875, 6, Equal)));\n    /// test(Natural::from(123u32), Exact, Some((1.921875, 6, Equal)));\n    ///\n    /// test(\n    ///     Natural::from(1000000000u32),\n    ///     Nearest,\n    ///     Some((1.8626451, 29, Equal)),\n    /// );\n    /// test(\n    ///     Natural::from(10u32).pow(52),\n    ///     Nearest,\n    ///     Some((1.670478, 172, Greater)),\n    /// );\n    ///\n    /// test(Natural::from(10u32).pow(52), Exact, None);\n    /// ```\n    pub fn sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n        &self,\n        rm: RoundingMode,\n    ) -> Option<(T, u64, Ordering)> {\n        assert_ne!(*self, 0);\n        // Worst case: 32-bit limbs, 64-bit float output, most-significant limb is 1. In this case,\n        // the 3 most-significant limbs are needed.\n        let mut most_significant_limbs = [0; 3];\n        let mut exponent = T::MANTISSA_WIDTH;\n        let significant_bits;\n        let mut exact = true;\n        let mut half_compare = Less; // (mantissa - floor(mantissa)).cmp(&0.5)\n        let mut highest_discarded_limb = 0;\n        match self {\n            Self(Small(x)) => {\n                most_significant_limbs[0] = *x;\n                significant_bits = x.significant_bits();\n            }\n            Self(Large(xs)) => {\n                let len = xs.len();\n                if len == 2 {\n                    most_significant_limbs[0] = xs[0];\n                    most_significant_limbs[1] = xs[1];\n                    significant_bits = xs[1].significant_bits() + Limb::WIDTH;\n                } else {\n                    most_significant_limbs[2] = xs[len - 1];\n                    most_significant_limbs[1] = xs[len - 2];\n                    most_significant_limbs[0] = xs[len - 3];\n                    exponent += limb_to_bit_count(len - 3);\n                    if !slice_test_zero(&xs[..len - 3]) {\n                        if rm == Exact {\n                            return None;\n                        }\n                        exact = false;\n                        highest_discarded_limb = xs[len - 4];\n                    }\n                    significant_bits = most_significant_limbs[2].significant_bits() + TWICE_WIDTH;\n                }\n            }\n        }\n        let shift =\n            i128::wrapping_from(T::MANTISSA_WIDTH + 1) - i128::wrapping_from(significant_bits);\n        match shift.sign() {\n            Greater => {\n                let mut shift = u64::exact_from(shift);\n                exponent -= shift;\n                let limbs_to_shift = bit_to_limb_count_floor(shift);\n                if limbs_to_shift != 0 {\n                    shift.mod_power_of_2_assign(Limb::LOG_WIDTH);\n                    most_significant_limbs.copy_within(..3 - limbs_to_shift, limbs_to_shift);\n                    slice_set_zero(&mut most_significant_limbs[..limbs_to_shift]);\n                }\n                if shift != 0 {\n                    limbs_slice_shl_in_place(&mut most_significant_limbs, shift);\n                }\n            }\n            Less => {\n                let mut shift = u64::exact_from(-shift);\n                let one_index = limbs_index_of_next_true_bit(&most_significant_limbs, 0).unwrap();\n                if one_index < shift {\n                    if rm == Exact {\n                        return None;\n                    }\n                    if rm == Nearest {\n                        // If `exact` is true here, that means all lower limbs are 0\n                        half_compare = if exact && one_index == shift - 1 {\n                            Equal\n                        } else if limbs_get_bit(&most_significant_limbs, shift - 1) {\n                            Greater\n                        } else {\n                            Less\n                        };\n                    }\n                    exact = false;\n                }\n                exponent += shift;\n                let limbs_to_shift = bit_to_limb_count_floor(shift);\n                if limbs_to_shift != 0 {\n                    shift.mod_power_of_2_assign(Limb::LOG_WIDTH);\n                    most_significant_limbs.copy_within(limbs_to_shift.., 0);\n                }\n                if shift != 0 {\n                    limbs_slice_shr_in_place(&mut most_significant_limbs, shift);\n                }\n            }\n            Equal => {\n                if !exact && rm == Nearest {\n                    // len is at least 4, since the only way `exact` is false at this point is if\n                    // xs[..len - 3] is nonzero\n                    half_compare = highest_discarded_limb.cmp(&LIMB_HIGH_BIT);\n                }\n            }\n        }\n        let raw_mantissa =\n            u64::from_other_type_slice(&most_significant_limbs).mod_power_of_2(T::MANTISSA_WIDTH);\n        let mantissa =\n            T::from_raw_mantissa_and_exponent(raw_mantissa, u64::wrapping_from(T::MAX_EXPONENT));\n        let increment = !exact\n            && (rm == Up\n                || rm == Ceiling\n                || rm == Nearest\n                    && (half_compare == Greater || half_compare == Equal && raw_mantissa.odd()));\n        Some(if increment {\n            let next_mantissa = mantissa.next_higher();\n            if next_mantissa == T::TWO {\n                (T::ONE, exponent + 1, Greater)\n            } else {\n                (next_mantissa, exponent, Greater)\n            }\n        } else {\n            (mantissa, exponent, if exact { Equal } else { Less })\n        })\n    }\n\n    /// Constructs a [`Natural`] from its scientific mantissa and exponent, rounding according to\n    /// the specified rounding mode. An [`Ordering`] is also returned, indicating whether the\n    /// returned value is less than, equal to, or greater than the exact value represented by the\n    /// mantissa and exponent.\n    ///\n    /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is\n    /// a rational number with $1 \\leq m_s < 2$. Here, the rational mantissa is provided as a float.\n    /// If the mantissa is outside the range $[1, 2)$, `None` is returned.\n    ///\n    /// Some combinations of mantissas and exponents do not specify a [`Natural`], in which case the\n    /// resulting value is rounded to a [`Natural`] using the specified rounding mode. If the\n    /// rounding mode is `Exact` but the input does not exactly specify a [`Natural`], `None` is\n    /// returned.\n    ///\n    /// $$\n    /// f(x, r) \\approx 2^{e_s}m_s.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `sci_exponent`.\n    ///\n    /// # Panics\n    /// Panics if `sci_mantissa` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::cmp::Ordering::{self, *};\n    /// use core::str::FromStr;\n    /// use malachite_base::rounding_modes::RoundingMode::{self, *};\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let test =\n    ///     |mantissa: f32, exponent: u64, rm: RoundingMode, out: Option<(Natural, Ordering)>| {\n    ///         assert_eq!(\n    ///             Natural::from_sci_mantissa_and_exponent_round(mantissa, exponent, rm),\n    ///             out\n    ///         );\n    ///     };\n    /// test(1.5, 1, Floor, Some((Natural::from(3u32), Equal)));\n    /// test(1.5, 1, Down, Some((Natural::from(3u32), Equal)));\n    /// test(1.5, 1, Ceiling, Some((Natural::from(3u32), Equal)));\n    /// test(1.5, 1, Up, Some((Natural::from(3u32), Equal)));\n    /// test(1.5, 1, Nearest, Some((Natural::from(3u32), Equal)));\n    /// test(1.5, 1, Exact, Some((Natural::from(3u32), Equal)));\n    ///\n    /// test(1.51, 1, Floor, Some((Natural::from(3u32), Less)));\n    /// test(1.51, 1, Down, Some((Natural::from(3u32), Less)));\n    /// test(1.51, 1, Ceiling, Some((Natural::from(4u32), Greater)));\n    /// test(1.51, 1, Up, Some((Natural::from(4u32), Greater)));\n    /// test(1.51, 1, Nearest, Some((Natural::from(3u32), Less)));\n    /// test(1.51, 1, Exact, None);\n    ///\n    /// test(\n    ///     1.670478,\n    ///     172,\n    ///     Nearest,\n    ///     Some((\n    ///         Natural::from_str(\"10000000254586612611935772707803116801852191350456320\").unwrap(),\n    ///         Equal,\n    ///     )),\n    /// );\n    ///\n    /// test(2.0, 1, Floor, None);\n    /// test(10.0, 1, Floor, None);\n    /// test(0.5, 1, Floor, None);\n    /// ```\n    #[inline]\n    pub fn from_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n        sci_mantissa: T,\n        sci_exponent: u64,\n        rm: RoundingMode,\n    ) -> Option<(Self, Ordering)> {\n        assert_ne!(sci_mantissa, T::ZERO);\n        if sci_mantissa < T::ONE || sci_mantissa >= T::TWO {\n            return None;\n        }\n        let (integer_mantissa, integer_exponent) = sci_mantissa.integer_mantissa_and_exponent();\n        if integer_exponent > 0 {\n            Some((\n                Self::from(integer_mantissa) << (sci_exponent + u64::exact_from(integer_exponent)),\n                Equal,\n            ))\n        } else {\n            let integer_exponent = u64::exact_from(-integer_exponent);\n            if integer_exponent <= sci_exponent {\n                Some((\n                    Self::from(integer_mantissa) << (sci_exponent - integer_exponent),\n                    Equal,\n                ))\n            } else if rm == Exact {\n                None\n            } else {\n                Some(Self::from(integer_mantissa).shr_round(integer_exponent - sci_exponent, rm))\n            }\n        }\n    }\n}\n\nimpl IntegerMantissaAndExponent<Natural, u64, Natural> for &Natural {\n    /// Returns a [`Natural`]'s integer mantissa and exponent.\n    ///\n    /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is\n    /// an odd integer.\n    /// $$\n    /// f(x) = (\\frac{|x|}{2^{e_i}}, e_i),\n    /// $$\n    /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n    ///\n    /// The inverse operation is\n    /// [`from_integer_mantissa_and_exponent`](IntegerMantissaAndExponent::from_integer_mantissa_and_exponent).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(123u32).integer_mantissa_and_exponent(),\n    ///     (Natural::from(123u32), 0)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(100u32).integer_mantissa_and_exponent(),\n    ///     (Natural::from(25u32), 2)\n    /// );\n    /// ```\n    #[inline]\n    fn integer_mantissa_and_exponent(self) -> (Natural, u64) {\n        let trailing_zeros = self.trailing_zeros().unwrap();\n        (self >> trailing_zeros, trailing_zeros)\n    }\n\n    /// Returns a [`Natural`]'s integer mantissa.\n    ///\n    /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is\n    /// an odd integer.\n    /// $$\n    /// f(x) = \\frac{|x|}{2^{e_i}},\n    /// $$\n    /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32).integer_mantissa(), 123);\n    /// assert_eq!(Natural::from(100u32).integer_mantissa(), 25);\n    /// ```\n    #[inline]\n    fn integer_mantissa(self) -> Natural {\n        self >> self.trailing_zeros().unwrap()\n    }\n\n    /// Returns a [`Natural`]'s integer exponent.\n    ///\n    /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is\n    /// an odd integer.\n    /// $$\n    /// f(x) = e_i,\n    /// $$\n    /// where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32).integer_exponent(), 0);\n    /// assert_eq!(Natural::from(100u32).integer_exponent(), 2);\n    /// ```\n    #[inline]\n    fn integer_exponent(self) -> u64 {\n        self.trailing_zeros().unwrap()\n    }\n\n    /// Constructs a [`Natural`] from its integer mantissa and exponent.\n    ///\n    /// When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is\n    /// an odd integer.\n    ///\n    /// $$\n    /// f(x) = 2^{e_i}m_i.\n    /// $$\n    ///\n    /// The input does not have to be reduced; that is, the mantissa does not have to be odd.\n    ///\n    /// The result is an [`Option`], but for this trait implementation the result is always `Some`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `integer_mantissa.significant_bits()\n    /// + integer_exponent`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n =\n    ///     <&Natural as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n    ///         Natural::from(123u32),\n    ///         0,\n    ///     )\n    ///     .unwrap();\n    /// assert_eq!(n, 123);\n    /// let n =\n    ///     <&Natural as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n    ///         Natural::from(25u32),\n    ///         2,\n    ///     )\n    ///     .unwrap();\n    /// assert_eq!(n, 100);\n    /// ```\n    #[inline]\n    fn from_integer_mantissa_and_exponent(\n        integer_mantissa: Natural,\n        integer_exponent: u64,\n    ) -> Option<Natural> {\n        Some(integer_mantissa << integer_exponent)\n    }\n}\n\nmacro_rules! impl_mantissa_and_exponent {\n    ($t:ident) => {\n        impl SciMantissaAndExponent<$t, u64, Natural> for &Natural {\n            /// Returns a [`Natural`]'s scientific mantissa and exponent.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa\n            /// as a float. The conversion might not be exact, so we round to the nearest float\n            /// using the `Nearest` rounding mode. To use other rounding modes, use\n            /// [`sci_mantissa_and_exponent_round`](Natural::sci_mantissa_and_exponent_round).\n            /// $$\n            /// f(x) \\approx (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}, \\lfloor \\log_2 x \\rfloor).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_mantissa_and_exponent).\n            #[inline]\n            fn sci_mantissa_and_exponent(self) -> ($t, u64) {\n                let (m, e, _) = self.sci_mantissa_and_exponent_round(Nearest).unwrap();\n                (m, e)\n            }\n\n            /// Constructs a [`Natural`] from its scientific mantissa and exponent.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. Here, the rational mantissa is\n            /// provided as a float. If the mantissa is outside the range $[1, 2)$, `None` is\n            /// returned.\n            ///\n            /// Some combinations of mantissas and exponents do not specify a [`Natural`], in which\n            /// case the resulting value is rounded to a [`Natural`] using the `Nearest` rounding\n            /// mode. To specify other rounding modes, use\n            /// [`from_sci_mantissa_and_exponent_round`](Natural::from_sci_mantissa_and_exponent_round).\n            ///\n            /// $$\n            /// f(x) \\approx 2^{e_s}m_s.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `sci_exponent`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#from_sci_mantissa_and_exponent).\n            #[inline]\n            fn from_sci_mantissa_and_exponent(\n                sci_mantissa: $t,\n                sci_exponent: u64,\n            ) -> Option<Natural> {\n                Natural::from_sci_mantissa_and_exponent_round(sci_mantissa, sci_exponent, Nearest)\n                    .map(|p| p.0)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_mantissa_and_exponent);\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of traits for working with the digits of [`Natural`](crate::natural::Natural)s.\npub mod digits;\n/// An implementation of the [`From`] trait for converting a [`bool`] to a\n/// [`Natural`](crate::natural::Natural).\npub mod from_bool;\n/// Functions for constructing a [`Natural`](crate::natural::Natural) from [`Limb`](crate#limbs)s.\npub mod from_limbs;\n/// Implementations of traits for converting a primitive float to a\n/// [`Natural`](crate::natural::Natural).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # rounding_from\n/// ```\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::rounding_from(0.0, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(-0.0, Exact).to_debug_string(),\n///     \"(0, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.0, Exact).to_debug_string(),\n///     \"(123, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(1.0e9, Exact).to_debug_string(),\n///     \"(1000000000, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(1.0e9, Exact).to_debug_string(),\n///     \"(1000000000, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(4294967295.0, Exact).to_debug_string(),\n///     \"(4294967295, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(4294967296.0, Exact).to_debug_string(),\n///     \"(4294967296, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(1.0e100, Exact).to_debug_string(),\n///     \"(1000000000000000015902891109759918046836080856394528138978132755774783877217038106081346\\\n///     9985856815104, Equal)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.1, Floor).to_debug_string(),\n///     \"(123, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.1, Ceiling).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.1, Nearest).to_debug_string(),\n///     \"(123, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.9, Floor).to_debug_string(),\n///     \"(123, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.9, Ceiling).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.9, Nearest).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(123.5, Nearest).to_debug_string(),\n///     \"(124, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(124.5, Nearest).to_debug_string(),\n///     \"(124, Less)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(-0.99, Ceiling).to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(-0.499, Nearest).to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// assert_eq!(\n///     Natural::rounding_from(-0.5, Nearest).to_debug_string(),\n///     \"(0, Greater)\"\n/// );\n/// ```\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     Natural::try_from(f64::NAN).to_debug_string(),\n///     \"Err(FloatInfiniteOrNan)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(f64::INFINITY).to_debug_string(),\n///     \"Err(FloatInfiniteOrNan)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(f64::NEGATIVE_INFINITY).to_debug_string(),\n///     \"Err(FloatInfiniteOrNan)\"\n/// );\n/// assert_eq!(Natural::try_from(0.0).to_debug_string(), \"Ok(0)\");\n/// assert_eq!(Natural::try_from(-0.0).to_debug_string(), \"Ok(0)\");\n/// assert_eq!(Natural::try_from(123.0).to_debug_string(), \"Ok(123)\");\n/// assert_eq!(Natural::try_from(1.0e9).to_debug_string(), \"Ok(1000000000)\");\n/// assert_eq!(\n///     Natural::try_from(4294967295.0).to_debug_string(),\n///     \"Ok(4294967295)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(4294967296.0).to_debug_string(),\n///     \"Ok(4294967296)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(1.0e100).to_debug_string(),\n///     \"Ok(10000000000000000159028911097599180468360808563945281389781327557747838772170381060813\\\n///     469985856815104)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(123.1).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(123.9).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(123.5).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(124.5).to_debug_string(),\n///     \"Err(FloatNonIntegerOrOutOfRange)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(-0.499).to_debug_string(),\n///     \"Err(FloatNegative)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(-0.5).to_debug_string(),\n///     \"Err(FloatNegative)\"\n/// );\n/// assert_eq!(\n///     Natural::try_from(-123.0).to_debug_string(),\n///     \"Err(FloatNegative)\"\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::basic::traits::NegativeInfinity;\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::convertible_from(f64::NAN), false);\n/// assert_eq!(Natural::convertible_from(f64::INFINITY), false);\n/// assert_eq!(Natural::convertible_from(f64::NEGATIVE_INFINITY), false);\n/// assert_eq!(Natural::convertible_from(0.0), true);\n/// assert_eq!(Natural::convertible_from(-0.0), true);\n/// assert_eq!(Natural::convertible_from(123.0), true);\n/// assert_eq!(Natural::convertible_from(1.0e9), true);\n/// assert_eq!(Natural::convertible_from(4294967295.0), true);\n/// assert_eq!(Natural::convertible_from(4294967296.0), true);\n/// assert_eq!(Natural::convertible_from(1.0e100), true);\n/// assert_eq!(Natural::convertible_from(123.1), false);\n/// assert_eq!(Natural::convertible_from(123.9), false);\n/// assert_eq!(Natural::convertible_from(123.5), false);\n/// assert_eq!(Natural::convertible_from(124.5), false);\n/// assert_eq!(Natural::convertible_from(-0.499), false);\n/// assert_eq!(Natural::convertible_from(-0.5), false);\n/// assert_eq!(Natural::convertible_from(-123.0), false);\n/// ```\npub mod from_primitive_float;\n/// Implementations of traits for converting a primitive integer to a\n/// [`Natural`](crate::natural::Natural).\n///\n/// The traits are [`From`], [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`SaturatingFrom`](malachite_base::num::conversion::traits::SaturatingFrom).\n///\n/// # from\n/// ```\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::from(123u64), 123);\n/// assert_eq!(Natural::from(123u8), 123);\n/// assert_eq!(Natural::from(123u128), 123);\n/// ```\n///\n/// # try_from\n/// ```\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::try_from(123i32).to_debug_string(), \"Ok(123)\");\n/// assert_eq!(\n///     Natural::try_from(-123i32).to_debug_string(),\n///     \"Err(NaturalFromSignedError)\"\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::convertible_from(123i32), true);\n/// assert_eq!(Natural::convertible_from(-123i32), false);\n/// ```\n///\n/// # saturating_from\n/// ```\n/// use malachite_base::num::conversion::traits::SaturatingFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(Natural::saturating_from(123i32), 123);\n/// assert_eq!(Natural::saturating_from(-123i32), 0);\n/// ```\npub mod from_primitive_int;\n/// An implementation of [`IsInteger`](malachite_base::num::conversion::traits::IsInteger), a trait\n/// for determining whether a number is an integer.\n///\n/// A [`Natural`](crate::natural::Natural) is always an integer.\npub mod is_integer;\n/// A function for counting a [`Natural`](crate::natural::Natural)'s [`Limb`](crate#limbs)s.\npub mod limb_count;\n/// Implementations of traits for converting numbers to and from mantissa-and-exponent\n/// representations.\n///\n/// See [`PrimitiveFloat`](malachite_base::num::basic::floats::PrimitiveFloat) for a description of\n/// the different types of mantissas and exponents. The traits are\n/// [`IntegerMantissaAndExponent`](malachite_base::num::conversion::traits::IntegerMantissaAndExponent)\n/// and [`SciMantissaAndExponent`](malachite_base::num::conversion::traits::SciMantissaAndExponent).\n///\n/// Here are some examples of the macro-generated functions:\n///\n/// # sci_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_nz::natural::Natural;\n///\n/// let test = |n: Natural, mantissa: f32, exponent: u64| {\n///     let (m, e) = n.sci_mantissa_and_exponent();\n///     assert_eq!(NiceFloat(m), NiceFloat(mantissa));\n///     assert_eq!(e, exponent);\n/// };\n/// test(Natural::from(3u32), 1.5, 1);\n/// test(Natural::from(123u32), 1.921875, 6);\n/// test(Natural::from(1000000000u32), 1.8626451, 29);\n/// test(Natural::from(10u32).pow(52), 1.670478, 172);\n/// ```\n///\n/// # from_sci_mantissa_and_exponent\n/// ```\n/// use core::str::FromStr;\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_nz::natural::Natural;\n///\n/// let test = |mantissa: f32, exponent: u64, out: Option<Natural>| {\n///     assert_eq!(\n///         <&Natural as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n///             mantissa, exponent\n///         ),\n///         out\n///     );\n/// };\n/// test(1.5, 1, Some(Natural::from(3u32)));\n/// test(1.51, 1, Some(Natural::from(3u32)));\n/// test(1.921875, 6, Some(Natural::from(123u32)));\n/// test(\n///     1.670478,\n///     172,\n///     Some(Natural::from_str(\"10000000254586612611935772707803116801852191350456320\").unwrap()),\n/// );\n///\n/// test(2.0, 1, None);\n/// test(10.0, 1, None);\n/// test(0.5, 1, None);\n/// ```\npub mod mantissa_and_exponent;\n/// Implementations of traits for converting a [`Natural`](crate::natural::Natural) to a primitive\n/// float.\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # rounding_from\n/// ```\n/// use core::cmp::Ordering::*;\n/// use core::str::FromStr;\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     f32::rounding_from(&Natural::from_str(\"123\").unwrap(), Exact),\n///     (123.0, Equal)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(&Natural::from_str(\"1000000001\").unwrap(), Floor),\n///     (1.0e9, Less)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(&Natural::from_str(\"1000000001\").unwrap(), Ceiling),\n///     (1.00000006e9, Greater)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(\n///         &Natural::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n///         Nearest\n///     ),\n///     (f32::INFINITY, Greater)\n/// );\n/// ```\n///\n/// # try_from\n/// ```\n/// use core::str::FromStr;\n/// use malachite_nz::natural::conversion::primitive_float_from_natural::*;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(f32::try_from(&Natural::from_str(\"123\").unwrap()), Ok(123.0));\n/// assert_eq!(\n///     f32::try_from(&Natural::from_str(\"1000000000\").unwrap()),\n///     Ok(1.0e9)\n/// );\n/// assert_eq!(\n///     f32::try_from(&Natural::from_str(\"1000000001\").unwrap()),\n///     Err(PrimitiveFloatFromNaturalError)\n/// );\n/// assert_eq!(\n///     f32::try_from(\n///         &Natural::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap()\n///     ),\n///     Err(PrimitiveFloatFromNaturalError)\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use core::str::FromStr;\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     f32::convertible_from(&Natural::from_str(\"123\").unwrap()),\n///     true\n/// );\n/// assert_eq!(\n///     f32::convertible_from(&Natural::from_str(\"1000000000\").unwrap()),\n///     true\n/// );\n/// assert_eq!(\n///     f32::convertible_from(&Natural::from_str(\"1000000001\").unwrap()),\n///     false\n/// );\n/// assert_eq!(\n///     f32::convertible_from(\n///         &Natural::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap()\n///     ),\n///     false\n/// );\n/// ```\npub mod primitive_float_from_natural;\n/// Implementations of traits for converting a [`Natural`](crate::natural::Natural) to a primitive\n/// integer.\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom),\n/// [`OverflowingFrom`](malachite_base::num::conversion::traits::OverflowingFrom),\n/// [`SaturatingFrom`](malachite_base::num::conversion::traits::SaturatingFrom), and\n/// [`WrappingFrom`](malachite_base::num::conversion::traits::WrappingFrom).\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_nz::natural::conversion::primitive_int_from_natural::{\n///     SignedFromNaturalError, UnsignedFromNaturalError,\n/// };\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(u32::try_from(&Natural::from(123u32)), Ok(123));\n/// assert_eq!(\n///     u32::try_from(&Natural::from(10u32).pow(12)),\n///     Err(UnsignedFromNaturalError)\n/// );\n/// assert_eq!(u8::try_from(&Natural::from(123u32)), Ok(123));\n/// assert_eq!(\n///     u8::try_from(&Natural::from(10u32).pow(12)),\n///     Err(UnsignedFromNaturalError)\n/// );\n/// assert_eq!(u64::try_from(&Natural::from(123u32)), Ok(123));\n/// assert_eq!(\n///     u64::try_from(&(Natural::ONE << 100)),\n///     Err(UnsignedFromNaturalError)\n/// );\n///\n/// assert_eq!(i32::try_from(&Natural::from(123u32)), Ok(123));\n/// assert_eq!(\n///     i32::try_from(&Natural::from(10u32).pow(12)),\n///     Err(SignedFromNaturalError)\n/// );\n/// assert_eq!(i8::try_from(&Natural::from(123u32)), Ok(123));\n/// assert_eq!(\n///     i8::try_from(&Natural::from(10u32).pow(12)),\n///     Err(SignedFromNaturalError)\n/// );\n/// assert_eq!(i64::try_from(&Natural::from(123u32)), Ok(123));\n/// assert_eq!(\n///     i64::try_from(&(Natural::ONE << 100)),\n///     Err(SignedFromNaturalError)\n/// );\n/// ```\n///\n/// # wrapping_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::num::conversion::traits::WrappingFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(u32::wrapping_from(&Natural::from(123u32)), 123);\n/// assert_eq!(\n///     u32::wrapping_from(&Natural::from(10u32).pow(12)),\n///     3567587328\n/// );\n/// assert_eq!(u8::wrapping_from(&Natural::from(123u32)), 123);\n/// assert_eq!(u8::wrapping_from(&Natural::from(10u32).pow(12)), 0);\n/// assert_eq!(u64::wrapping_from(&Natural::from(123u32)), 123);\n/// assert_eq!(u64::wrapping_from(&(Natural::ONE << 100)), 0);\n///\n/// assert_eq!(i32::wrapping_from(&Natural::from(123u32)), 123);\n/// assert_eq!(\n///     i32::wrapping_from(&Natural::from(10u32).pow(12)),\n///     -727379968\n/// );\n/// assert_eq!(i8::wrapping_from(&Natural::from(123u32)), 123);\n/// assert_eq!(i8::wrapping_from(&Natural::from(10u32).pow(12)), 0);\n/// assert_eq!(i64::wrapping_from(&Natural::from(123u32)), 123);\n/// assert_eq!(i64::wrapping_from(&(Natural::ONE << 100)), 0);\n/// ```\n///\n/// # saturating_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::num::conversion::traits::SaturatingFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(u32::saturating_from(&Natural::from(123u32)), 123);\n/// assert_eq!(\n///     u32::saturating_from(&Natural::from(10u32).pow(12)),\n///     u32::MAX\n/// );\n/// assert_eq!(u8::saturating_from(&Natural::from(123u32)), 123);\n/// assert_eq!(u8::saturating_from(&Natural::from(10u32).pow(12)), 255);\n/// assert_eq!(u64::saturating_from(&Natural::from(123u32)), 123);\n/// assert_eq!(\n///     u64::saturating_from(&(Natural::ONE << 100)),\n///     18446744073709551615\n/// );\n///\n/// assert_eq!(i32::saturating_from(&Natural::from(123u32)), 123);\n/// assert_eq!(\n///     i32::saturating_from(&Natural::from(10u32).pow(12)),\n///     2147483647\n/// );\n/// assert_eq!(i8::saturating_from(&Natural::from(123u32)), 123);\n/// assert_eq!(i8::saturating_from(&Natural::from(10u32).pow(12)), 127);\n/// assert_eq!(i64::saturating_from(&Natural::from(123u32)), 123);\n/// assert_eq!(\n///     i64::saturating_from(&(Natural::ONE << 100)),\n///     9223372036854775807\n/// );\n/// ```\n///\n/// # overflowing_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::num::conversion::traits::OverflowingFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(u32::overflowing_from(&Natural::from(123u32)), (123, false));\n/// assert_eq!(\n///     u32::overflowing_from(&Natural::from(10u32).pow(12)),\n///     (3567587328, true)\n/// );\n/// assert_eq!(u8::overflowing_from(&Natural::from(123u32)), (123, false));\n/// assert_eq!(\n///     u8::overflowing_from(&Natural::from(10u32).pow(12)),\n///     (0, true)\n/// );\n/// assert_eq!(u64::overflowing_from(&Natural::from(123u32)), (123, false));\n/// assert_eq!(u64::overflowing_from(&(Natural::ONE << 100)), (0, true));\n///\n/// assert_eq!(i32::overflowing_from(&Natural::from(123u32)), (123, false));\n/// assert_eq!(\n///     i32::overflowing_from(&Natural::from(10u32).pow(12)),\n///     (-727379968, true)\n/// );\n/// assert_eq!(i8::overflowing_from(&Natural::from(123u32)), (123, false));\n/// assert_eq!(\n///     i8::overflowing_from(&Natural::from(10u32).pow(12)),\n///     (0, true)\n/// );\n/// assert_eq!(i64::overflowing_from(&Natural::from(123u32)), (123, false));\n/// assert_eq!(i64::overflowing_from(&(Natural::ONE << 100)), (0, true));\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(u32::convertible_from(&Natural::from(123u32)), true);\n/// assert_eq!(u32::convertible_from(&Natural::from(10u32).pow(12)), false);\n/// assert_eq!(u8::convertible_from(&Natural::from(123u32)), true);\n/// assert_eq!(u8::convertible_from(&Natural::from(10u32).pow(12)), false);\n/// assert_eq!(u64::convertible_from(&Natural::from(123u32)), true);\n/// assert_eq!(u64::convertible_from(&(Natural::ONE << 100)), false);\n///\n/// assert_eq!(i32::convertible_from(&Natural::from(123u32)), true);\n/// assert_eq!(i32::convertible_from(&Natural::from(10u32).pow(12)), false);\n/// assert_eq!(i8::convertible_from(&Natural::from(123u32)), true);\n/// assert_eq!(i8::convertible_from(&Natural::from(10u32).pow(12)), false);\n/// assert_eq!(i64::convertible_from(&Natural::from(123u32)), true);\n/// assert_eq!(i64::convertible_from(&(Natural::ONE << 100)), false);\n/// ```\npub mod primitive_int_from_natural;\n/// Implementations of traits for conversions between Python integers and\n/// [`Natural`](crate::natural::Natural)s using [pyo3](https://pyo3.rs/).\npub mod pyo3;\n/// Implementations of traits for serialization and deserialization using\n/// [serde](https://serde.rs/).\npub mod serde;\n/// Implementations of traits for converting [`Natural`](crate::natural::Natural)s to and from\n/// [`String`]s.\npub mod string;\n/// Functions for extracting [`Limb`](crate#limbs)s from a [`Natural`](crate::natural::Natural).\npub mod to_limbs;\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/primitive_float_from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::named::Named;\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, RawMantissaAndExponent, RoundingFrom, SciMantissaAndExponent,\n    WrappingFrom,\n};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct PrimitiveFloatFromNaturalError;\n\nmacro_rules! float_impls {\n    ($f: ident) => {\n        impl<'a> RoundingFrom<&'a Natural> for $f {\n            /// Converts a [`Natural`] to a primitive float according to a specified\n            /// [`RoundingMode`]. An [`Ordering`] is also returned, indicating whether the returned\n            /// value is less than, equal to, or greater than the original value.\n            ///\n            /// - If the rounding mode is `Floor` or `Down`, the largest float less than or equal to\n            ///   the [`Natural`] is returned. If the [`Natural`] is greater than the maximum finite\n            ///   float, then the maximum finite float is returned.\n            /// - If the rounding mode is `Ceiling` or `Up`, the smallest float greater than or\n            ///   equal to the [`Natural`] is returned. If the [`Natural`] is greater than the\n            ///   maximum finite float, then $\\infty$ is returned.\n            /// - If the rounding mode is `Nearest`, then the nearest float is returned. If the\n            ///   [`Natural`] is exactly between two floats, the float with the zero\n            ///   least-significant bit in its representation is selected. If the [`Natural`] is\n            ///   greater than the maximum finite float, then $\\infty$ is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the rounding mode is `Exact` and `value` cannot be represented exactly.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_natural#rounding_from).\n            fn rounding_from(value: &'a Natural, rm: RoundingMode) -> ($f, Ordering) {\n                if *value == 0 {\n                    (0.0, Equal)\n                } else {\n                    let (mantissa, exponent, o) = value\n                        .sci_mantissa_and_exponent_round(rm)\n                        .expect(\"Value cannot be represented exactly as a float\");\n                    if let Some(f) =\n                        $f::from_sci_mantissa_and_exponent(mantissa, i64::exact_from(exponent))\n                    {\n                        (f, o)\n                    } else {\n                        match rm {\n                            Exact => {\n                                panic!(\"Value cannot be represented exactly as an {}\", $f::NAME)\n                            }\n                            Floor | Down => ($f::MAX_FINITE, Less),\n                            _ => ($f::INFINITY, Greater),\n                        }\n                    }\n                }\n            }\n        }\n\n        impl<'a> TryFrom<&'a Natural> for $f {\n            type Error = PrimitiveFloatFromNaturalError;\n\n            /// Converts a [`Natural`] to a primitive float.\n            ///\n            /// If the input isn't exactly equal to some float, an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_natural#try_from).\n            fn try_from(value: &'a Natural) -> Result<$f, Self::Error> {\n                if *value == 0 {\n                    Ok(0.0)\n                } else {\n                    let (mantissa, exponent, _) = value\n                        .sci_mantissa_and_exponent_round(Exact)\n                        .ok_or(PrimitiveFloatFromNaturalError)?;\n                    $f::from_sci_mantissa_and_exponent(mantissa, i64::exact_from(exponent))\n                        .ok_or(PrimitiveFloatFromNaturalError)\n                }\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Natural> for $f {\n            /// Determines whether a [`Natural`] can be exactly converted to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_natural#convertible_from).\n            fn convertible_from(value: &'a Natural) -> bool {\n                if *value == 0 {\n                    true\n                } else {\n                    if let Some((mantissa, exponent, _)) =\n                        value.sci_mantissa_and_exponent_round::<$f>(Exact)\n                    {\n                        let exponent = i64::exact_from(exponent);\n                        if !($f::MIN_EXPONENT..=$f::MAX_EXPONENT).contains(&exponent) {\n                            return false;\n                        }\n                        let (orig_mantissa, orig_exponent) = mantissa.raw_mantissa_and_exponent();\n                        orig_exponent == u64::wrapping_from($f::MAX_EXPONENT)\n                            && exponent >= $f::MIN_NORMAL_EXPONENT\n                            || orig_mantissa.divisible_by_power_of_2(u64::wrapping_from(\n                                $f::MIN_NORMAL_EXPONENT - exponent,\n                            ))\n                    } else {\n                        false\n                    }\n                }\n            }\n        }\n    };\n}\napply_to_primitive_floats!(float_impls);\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/primitive_int_from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::basic::integers::{PrimitiveInt, USIZE_IS_U32};\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, FromOtherTypeSlice, OverflowingFrom, SaturatingFrom, WrappingFrom,\n};\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct UnsignedFromNaturalError;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct SignedFromNaturalError;\n\nmacro_rules! impl_from_limb {\n    ($u: ident, $s: ident) => {\n        impl<'a> TryFrom<&'a Natural> for $u {\n            type Error = UnsignedFromNaturalError;\n\n            /// Converts a [`Natural`] to a [`Limb`](crate#limbs), returning an error if the\n            /// [`Natural`] is too large.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#try_from).\n            fn try_from(value: &Natural) -> Result<$u, Self::Error> {\n                match *value {\n                    Natural(Small(small)) => Ok(small),\n                    Natural(Large(_)) => Err(UnsignedFromNaturalError),\n                }\n            }\n        }\n\n        impl<'a> WrappingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$\n            /// is the width of a limb.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#wrapping_from).\n            fn wrapping_from(value: &Natural) -> $u {\n                match *value {\n                    Natural(Small(small)) => small,\n                    Natural(Large(ref limbs)) => limbs[0],\n                }\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a [`Limb`](crate#limbs).\n            ///\n            /// If the [`Natural`] is too large to fit in a [`Limb`](crate#limbs), the maximum\n            /// representable value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#saturating_from).\n            fn saturating_from(value: &Natural) -> $u {\n                match *value {\n                    Natural(Small(small)) => small,\n                    Natural(Large(_)) => $u::MAX,\n                }\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$\n            /// is the width of a limb.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#overflowing_from).\n            fn overflowing_from(value: &Natural) -> ($u, bool) {\n                match *value {\n                    Natural(Small(small)) => (small, false),\n                    Natural(Large(ref limbs)) => (limbs[0], true),\n                }\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Natural> for $u {\n            /// Determines whether a [`Natural`] can be converted to a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#convertible_from).\n            fn convertible_from(value: &Natural) -> bool {\n                match *value {\n                    Natural(Small(_)) => true,\n                    Natural(Large(_)) => false,\n                }\n            }\n        }\n\n        impl<'a> TryFrom<&'a Natural> for $s {\n            type Error = SignedFromNaturalError;\n\n            /// Converts a [`Natural`] to a `SignedLimb` (the signed type whose width is the same as\n            /// a [limb](crate#limbs)'s), returning an error if the [`Natural`] is too large.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#try_from).\n            fn try_from(value: &Natural) -> Result<$s, Self::Error> {\n                match *value {\n                    Natural(Small(small)) => {\n                        $s::try_from(small).map_err(|_| SignedFromNaturalError)\n                    }\n                    Natural(Large(_)) => Err(SignedFromNaturalError),\n                }\n            }\n        }\n\n        impl<'a> WrappingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to a `SignedLimb` (the signed type whose width is the same as\n            /// a [limb](crate#limbs)'s), wrapping modulo $2^W$, where $W$ is the width of a limb.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: &Natural) -> $s {\n                $s::wrapping_from($u::wrapping_from(value))\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to a `SignedLimb` (the signed type whose width is the same as\n            /// a [limb](crate#limbs)'s).\n            ///\n            /// If the [`Natural`] is too large to fit in a `SignedLimb`, the largest representable\n            /// value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#saturating_from).\n            #[inline]\n            fn saturating_from(value: &Natural) -> $s {\n                $s::saturating_from($u::saturating_from(value))\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to a `SignedLimb` (the signed type whose width is the same as\n            /// a [limb](crate#limbs)'s), wrapping modulo $2^W$, where $W$ is the width of a limb.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#overflowing_from).\n            fn overflowing_from(value: &Natural) -> ($s, bool) {\n                let (result, overflow_1) = $u::overflowing_from(value);\n                let (result, overflow_2) = $s::overflowing_from(result);\n                (result, overflow_1 || overflow_2)\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Natural> for $s {\n            /// Determines whether a [`Natural`] can be converted to a `SignedLimb` (the signed type\n            /// whose width is the same as a [limb](crate#limbs)'s).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#convertible_from).\n            fn convertible_from(value: &Natural) -> bool {\n                match *value {\n                    Natural(Small(small)) => $s::convertible_from(small),\n                    Natural(Large(_)) => false,\n                }\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_smaller_than_limb {\n    ($u: ident, $s: ident) => {\n        impl<'a> TryFrom<&'a Natural> for $u {\n            type Error = UnsignedFromNaturalError;\n\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// smaller than a [`Limb`](crate#limbs), returning an error if the [`Natural`] is too\n            /// large.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#try_from).\n            #[inline]\n            fn try_from(value: &Natural) -> Result<$u, Self::Error> {\n                Limb::try_from(value)\n                    .map_err(|_| UnsignedFromNaturalError)\n                    .and_then(|x| $u::try_from(x).map_err(|_| UnsignedFromNaturalError))\n            }\n        }\n\n        impl<'a> WrappingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// smaller than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is the width\n            /// of a limb.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: &Natural) -> $u {\n                $u::wrapping_from(Limb::wrapping_from(value))\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// smaller than a [`Limb`](crate#limbs). If the [`Natural`] is too large to fit in the\n            /// output type, the largest representable value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#saturating_from).\n            #[inline]\n            fn saturating_from(value: &Natural) -> $u {\n                $u::saturating_from(Limb::saturating_from(value))\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// smaller than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is the width\n            /// of a limb.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#overflowing_from).\n            #[inline]\n            fn overflowing_from(value: &Natural) -> ($u, bool) {\n                let (result, overflow_1) = Limb::overflowing_from(value);\n                let (result, overflow_2) = $u::overflowing_from(result);\n                (result, overflow_1 || overflow_2)\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Natural> for $u {\n            /// Determines whether a [`Natural`] can be converted to a value of a primitive unsigned\n            /// integer type that's smaller than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#convertible_from).\n            fn convertible_from(value: &Natural) -> bool {\n                match *value {\n                    Natural(Small(small)) => $u::convertible_from(small),\n                    Natural(Large(_)) => false,\n                }\n            }\n        }\n\n        impl<'a> TryFrom<&'a Natural> for $s {\n            type Error = SignedFromNaturalError;\n\n            /// Converts a [`Natural`] to a value of a signed primitive integer type that's smaller\n            /// than a [`Limb`](crate#limbs), returning an error if the [`Natural`] is too large.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#try_from).\n            #[inline]\n            fn try_from(value: &Natural) -> Result<$s, Self::Error> {\n                Limb::try_from(value)\n                    .map_err(|_| SignedFromNaturalError)\n                    .and_then(|x| $s::try_from(x).map_err(|_| SignedFromNaturalError))\n            }\n        }\n\n        impl<'a> WrappingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to a value of a signed primitive integer type that's smaller\n            /// than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is the width of a\n            /// limb.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: &Natural) -> $s {\n                $s::wrapping_from(Limb::wrapping_from(value))\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// smaller than a [`Limb`](crate#limbs). If the [`Natural`] is too large to fit in the\n            /// output type, the largest representable value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#saturating_from).\n            #[inline]\n            fn saturating_from(value: &Natural) -> $s {\n                $s::saturating_from(Limb::saturating_from(value))\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to a value of a signed primitive integer type that's smaller\n            /// than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is the width of a\n            /// limb.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#overflowing_from).\n            #[inline]\n            fn overflowing_from(value: &Natural) -> ($s, bool) {\n                let (result, overflow_1) = Limb::overflowing_from(value);\n                let (result, overflow_2) = $s::overflowing_from(result);\n                (result, overflow_1 || overflow_2)\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Natural> for $s {\n            /// Determines whether a [`Natural`] can be converted to a value of a signed primitive\n            /// integer type that's smaller than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#convertible_from).\n            fn convertible_from(value: &Natural) -> bool {\n                match *value {\n                    Natural(Small(small)) => $s::convertible_from(small),\n                    Natural(Large(_)) => false,\n                }\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_larger_than_limb_or_xsize {\n    ($u: ident, $s: ident) => {\n        impl<'a> WrappingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a [`usize`] or a value of an unsigned primitive integer\n            /// type that's larger than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is\n            /// the width of a limb.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#wrapping_from).\n            fn wrapping_from(value: &Natural) -> $u {\n                match *value {\n                    Natural(Small(small)) => $u::wrapping_from(small),\n                    Natural(Large(ref limbs)) => $u::from_other_type_slice(limbs),\n                }\n            }\n        }\n\n        impl<'a> TryFrom<&'a Natural> for $s {\n            type Error = SignedFromNaturalError;\n\n            /// Converts a [`Natural`] to an [`isize`] or value of a signed primitive integer type\n            /// that's larger than a [`Limb`](crate#limbs), returning an error if the [`Natural`] is\n            /// too large.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#try_from).\n            #[inline]\n            fn try_from(value: &Natural) -> Result<$s, Self::Error> {\n                $u::try_from(value)\n                    .map_err(|_| SignedFromNaturalError)\n                    .and_then(|x| $s::try_from(x).map_err(|_| SignedFromNaturalError))\n            }\n        }\n\n        impl<'a> WrappingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to an [`isize`] or a value of a signed primitive integer type\n            /// that's larger than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is the\n            /// width of a limb.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#wrapping_from).\n            #[inline]\n            fn wrapping_from(value: &Natural) -> $s {\n                $s::wrapping_from($u::wrapping_from(value))\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to an [`isize`] or a value of a signed primitive integer type\n            /// that's larger than a [`Limb`](crate#limbs), If the [`Natural`] is too large to fit\n            /// in the output type, the largest representable value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#saturating_from).\n            #[inline]\n            fn saturating_from(value: &Natural) -> $s {\n                $s::saturating_from($u::saturating_from(value))\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Natural> for $s {\n            /// Converts a [`Natural`] to an [`isize`] or a value of a signed primitive integer type\n            /// that's larger than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is the\n            /// width of a limb.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#overflowing_from).\n            fn overflowing_from(value: &Natural) -> ($s, bool) {\n                let (result, overflow_1) = $u::overflowing_from(value);\n                let (result, overflow_2) = $s::overflowing_from(result);\n                (result, overflow_1 || overflow_2)\n            }\n        }\n    };\n}\n\nmacro_rules! impl_from_larger_than_limb {\n    ($u: ident, $s: ident) => {\n        impl_from_larger_than_limb_or_xsize!($u, $s);\n\n        impl<'a> TryFrom<&'a Natural> for $u {\n            type Error = UnsignedFromNaturalError;\n\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// larger than a [`Limb`](crate#limbs), returning an error if the [`Natural`] is too\n            /// large.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#try_from).\n            fn try_from(value: &Natural) -> Result<$u, Self::Error> {\n                const SIZE_RATIO: usize = 1 << ($u::LOG_WIDTH - Limb::LOG_WIDTH);\n                match *value {\n                    Natural(Small(small)) => Ok($u::from(small)),\n                    Natural(Large(ref limbs)) if limbs.len() <= SIZE_RATIO => {\n                        Ok($u::from_other_type_slice(limbs))\n                    }\n                    Natural(Large(_)) => Err(UnsignedFromNaturalError),\n                }\n            }\n        }\n\n        impl<'a> SaturatingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// larger than a [`Limb`](crate#limbs). If the [`Natural`] is too large to fit in the\n            /// output type, the largest representable value is returned.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#saturating_from).\n            fn saturating_from(value: &Natural) -> $u {\n                const SIZE_RATIO: usize = 1 << ($u::LOG_WIDTH - Limb::LOG_WIDTH);\n                match *value {\n                    Natural(Small(small)) => $u::from(small),\n                    Natural(Large(ref limbs)) if limbs.len() <= SIZE_RATIO => {\n                        $u::from_other_type_slice(limbs)\n                    }\n                    Natural(Large(_)) => $u::MAX,\n                }\n            }\n        }\n\n        impl<'a> OverflowingFrom<&'a Natural> for $u {\n            /// Converts a [`Natural`] to a value of an unsigned primitive integer type that's\n            /// larger than a [`Limb`](crate#limbs), wrapping modulo $2^W$, where $W$ is the width\n            /// of a limb.\n            ///\n            /// The returned boolean value indicates whether wrapping occurred.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#overflowing_from).\n            fn overflowing_from(value: &Natural) -> ($u, bool) {\n                const SIZE_RATIO: usize = 1 << ($u::LOG_WIDTH - Limb::LOG_WIDTH);\n                match *value {\n                    Natural(Small(small)) => ($u::from(small), false),\n                    Natural(Large(ref limbs)) => {\n                        ($u::from_other_type_slice(limbs), limbs.len() > SIZE_RATIO)\n                    }\n                }\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Natural> for $u {\n            /// Determines whether a [`Natural`] can be converted to a value of a primitive unsigned\n            /// integer type that's larger than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#convertible_from).\n            fn convertible_from(value: &Natural) -> bool {\n                const SIZE_RATIO: usize = 1 << ($u::LOG_WIDTH - Limb::LOG_WIDTH);\n                match *value {\n                    Natural(Small(_)) => true,\n                    Natural(Large(ref limbs)) => limbs.len() <= SIZE_RATIO,\n                }\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Natural> for $s {\n            /// Determines whether a [`Natural`] can be converted to a value of a signed primitive\n            /// integer type that's larger than a [`Limb`](crate#limbs).\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_natural#convertible_from).\n            fn convertible_from(value: &Natural) -> bool {\n                const SIZE_RATIO: usize = 1 << ($u::LOG_WIDTH - Limb::LOG_WIDTH);\n                match *value {\n                    Natural(Small(_)) => true,\n                    Natural(Large(ref limbs)) => {\n                        limbs.len() < SIZE_RATIO\n                            || limbs.len() == SIZE_RATIO && !limbs[SIZE_RATIO - 1].get_highest_bit()\n                    }\n                }\n            }\n        }\n    };\n}\n\nimpl TryFrom<&Natural> for usize {\n    type Error = UnsignedFromNaturalError;\n\n    /// Converts a [`Natural`] to a [`usize`], returning an error if the [`Natural`] is too large.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::primitive_int_from_natural#try_from).\n    fn try_from(value: &Natural) -> Result<Self, Self::Error> {\n        if USIZE_IS_U32 {\n            u32::try_from(value).map(Self::wrapping_from)\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            u64::try_from(value).map(Self::wrapping_from)\n        }\n    }\n}\n\nimpl SaturatingFrom<&Natural> for usize {\n    /// Converts a [`Natural`] to a [`usize`]. If the [`Natural`] is too large to fit in a\n    /// [`usize`], the largest representable value is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::primitive_int_from_natural#saturating_from).\n    fn saturating_from(value: &Natural) -> Self {\n        if USIZE_IS_U32 {\n            Self::wrapping_from(u32::saturating_from(value))\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            Self::wrapping_from(u64::saturating_from(value))\n        }\n    }\n}\n\nimpl OverflowingFrom<&Natural> for usize {\n    /// Converts a [`Natural`] to a [`usize`], wrapping modulo $2^W$, where $W$ is the width of a\n    /// limb.\n    ///\n    /// The returned boolean value indicates whether wrapping occurred.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::primitive_int_from_natural#overflowing_from).\n    fn overflowing_from(value: &Natural) -> (Self, bool) {\n        if USIZE_IS_U32 {\n            let (result, overflow) = u32::overflowing_from(value);\n            (Self::wrapping_from(result), overflow)\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            let (result, overflow) = u64::overflowing_from(value);\n            (Self::wrapping_from(result), overflow)\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Natural> for usize {\n    /// Determines whether a [`Natural`] can be converted to a [`usize`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::primitive_int_from_natural#convertible_from).\n    fn convertible_from(value: &Natural) -> bool {\n        if USIZE_IS_U32 {\n            u32::convertible_from(value)\n        } else {\n            assert_eq!(Self::WIDTH, u64::WIDTH);\n            u64::convertible_from(value)\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Natural> for isize {\n    /// Determines whether a [`Natural`] can be converted to an [`isize`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// See [here](super::primitive_int_from_natural#convertible_from).\n    fn convertible_from(value: &Natural) -> bool {\n        if USIZE_IS_U32 {\n            i32::convertible_from(value)\n        } else {\n            assert_eq!(usize::WIDTH, u64::WIDTH);\n            i64::convertible_from(value)\n        }\n    }\n}\n\nimpl_from_smaller_than_limb!(u8, i8);\nimpl_from_smaller_than_limb!(u16, i16);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_from_limb!(u32, i32);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_from_smaller_than_limb!(u32, i32);\n#[cfg(feature = \"32_bit_limbs\")]\nimpl_from_larger_than_limb!(u64, i64);\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl_from_limb!(u64, i64);\nimpl_from_larger_than_limb!(u128, i128);\nimpl_from_larger_than_limb_or_xsize!(usize, isize);\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/pyo3.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// PyO3 integration contributed by Antonio Mamić.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![cfg(feature = \"enable_pyo3\")]\n\n//!\n//! This is useful for converting Python integers when they may not fit in Rust's built-in integer\n//! types.\n//!\n//! To use this enable the `enable_pyo3` feature.\n//!\n//! ## Examples\n//!\n//! Using [`Natural`](crate::natural::Natural) to correctly increment an arbitrary precision\n//! integer. This is not possible with Rust's native integers if the Python integer is too large,\n//! in which case it will fail its conversion and raise `OverflowError`.\n//! ```rust\n//! use malachite::Natural;\n//! use malachite::num::basic::traits::One;\n//! use pyo3::prelude::*;\n//!\n//! #[pyfunction]\n//! fn add_one(n: Natural) -> Natural {\n//!     // negative n would raise ValueError here\n//!     n + Natural::ONE\n//! }\n//!\n//! #[pymodule]\n//! fn my_module(_py: Python<'_>, m: &PyModule) -> PyResult<()> {\n//!     m.add_function(wrap_pyfunction!(add_one, m)?)?;\n//!     Ok(())\n//! }\n//! ```\n//!\n//! Python code:\n//! ```python\n//! from my_module import add_one\n//!\n//! n = 1 << 1337\n//! value = add_one(n)\n//!\n//! assert n + 1 == value\n//! ```\n\nuse crate::natural::Natural;\nuse alloc::vec::Vec;\nuse core::convert::Infallible;\nuse malachite_base::num::basic::traits::Zero;\n#[cfg(Py_LIMITED_API)]\nuse pyo3::intern;\n#[allow(unused_imports)]\nuse pyo3::{\n    Bound, FromPyObject, IntoPyObject, IntoPyObjectExt, Py, PyErr, PyObject, PyResult, Python,\n    exceptions::PyValueError, ffi, types::*,\n};\n\n#[cfg_attr(docsrs, doc(cfg(feature = \"enable_pyo3\")))]\nimpl<'source> FromPyObject<'source> for Natural {\n    fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult<Natural> {\n        // get the Python interpreter\n        let py = ob.py();\n\n        // get PyInt object\n        let num_owned: Py<PyInt>;\n        let num = if let Ok(long) = ob.downcast::<PyInt>() {\n            long\n        } else {\n            num_owned = unsafe { Py::from_owned_ptr_or_err(py, ffi::PyNumber_Index(ob.as_ptr()))? };\n            num_owned.bind(py)\n        };\n\n        // check if number is negative, and if so, raise TypeError\n        if num.lt(0)? {\n            return Err(PyErr::new::<PyValueError, _>(\n                \"expected non-negative integer\",\n            ));\n        }\n\n        // check if number is zero, and if so, return zero\n        let n_bits = int_n_bits(num)?;\n        if n_bits == 0 {\n            return Ok(Natural::ZERO);\n        }\n\n        // the number of bytes needed to store the integer\n        let mut n_bytes = (n_bits + 7) >> 3;\n\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            // convert the number of bytes to a multiple of 4, because of 32-bit limbs\n            n_bytes = ((n_bytes + 7) >> 2) << 2;\n        }\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            // convert the number of bytes to a multiple of 8, because of 64-bit limbs\n            n_bytes = ((n_bytes + 7) >> 3) << 3;\n        }\n\n        #[cfg(not(Py_LIMITED_API))]\n        {\n            let limbs = int_to_limbs(num, n_bytes, false)?;\n            Ok(Natural::from_owned_limbs_asc(limbs))\n        }\n        #[cfg(all(Py_LIMITED_API, feature = \"32_bit_limbs\"))]\n        {\n            let py_bytes = int_to_py_bytes(num, n_bytes, false)?;\n            let bytes = py_bytes.as_bytes();\n            let n_limbs_32 = n_bytes >> 2; // the number of 32-bit limbs needed to store the integer\n            let mut limbs_32 = Vec::with_capacity(n_limbs_32);\n            for i in (0..n_bytes).step_by(4) {\n                limbs_32.push(u32::from_le_bytes(bytes[i..(i + 4)].try_into().unwrap()));\n            }\n            Ok(Natural::from_owned_limbs_asc(limbs_32))\n        }\n        #[cfg(all(Py_LIMITED_API, not(feature = \"32_bit_limbs\")))]\n        {\n            let bytes = int_to_py_bytes(num, n_bytes, false)?.as_bytes();\n            let n_limbs_64 = n_bytes >> 3; // the number of 64-bit limbs needed to store the integer\n            let mut limbs_64 = Vec::with_capacity(n_limbs_64);\n            for i in (0..n_bytes).step_by(8) {\n                limbs_64.push(u64::from_le_bytes(bytes[i..(i + 8)].try_into().unwrap()));\n            }\n            Ok(Natural::from_owned_limbs_asc(limbs_64))\n        }\n    }\n}\n\n#[cfg_attr(docsrs, doc(cfg(feature = \"enable_pyo3\")))]\nimpl<'py> IntoPyObject<'py> for Natural {\n    type Target = PyInt;\n    type Output = Bound<'py, Self::Target>;\n    type Error = Infallible;\n\n    fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {\n        (&self).into_pyobject(py)\n    }\n}\n\n#[cfg_attr(docsrs, doc(cfg(feature = \"enable_pyo3\")))]\nimpl<'py> IntoPyObject<'py> for &Natural {\n    type Target = PyInt;\n    type Output = Bound<'py, Self::Target>;\n    type Error = Infallible;\n\n    fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {\n        if self == &Natural::ZERO {\n            return 0i32.into_pyobject(py);\n        }\n\n        let bytes = limbs_to_bytes(self.limbs(), self.limb_count());\n\n        #[cfg(not(Py_LIMITED_API))]\n        unsafe {\n            let obj = ffi::_PyLong_FromByteArray(\n                bytes.as_ptr().cast(),\n                bytes.len(),\n                1,            // little endian\n                false.into(), // unsigned\n            );\n            Ok(Bound::from_owned_ptr(py, obj).downcast_into_unchecked())\n        }\n\n        #[cfg(Py_LIMITED_API)]\n        {\n            let bytes_obj = PyBytes::new(py, &bytes);\n            let kwargs = None;\n            let result: Bound<'py, PyAny> = py\n                .get_type::<PyInt>()\n                .call_method(\"from_bytes\", (bytes_obj, \"little\"), kwargs)\n                .expect(\"int.from_bytes() failed during into_pyobject()\");\n            Ok(result)\n        }\n    }\n}\n\n/// Convert 32-bit limbs (little endian) used by malachite to bytes (little endian)\n#[cfg(feature = \"32_bit_limbs\")]\n#[inline]\nfn limbs_to_bytes(limbs: impl Iterator<Item = u32>, limb_count: u64) -> Vec<u8> {\n    let mut bytes = Vec::with_capacity((limb_count << 3) as usize);\n\n    for limb in limbs {\n        for byte in limb.to_le_bytes() {\n            bytes.push(byte);\n        }\n    }\n\n    bytes\n}\n\n/// Convert 64-bit limbs (little endian) used by malachite to bytes (little endian)\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[inline]\nfn limbs_to_bytes(limbs: impl Iterator<Item = u64>, limb_count: u64) -> Vec<u8> {\n    let mut bytes = Vec::with_capacity((limb_count << 3) as usize);\n\n    for limb in limbs {\n        for byte in limb.to_le_bytes() {\n            bytes.push(byte);\n        }\n    }\n\n    bytes\n}\n\n/// Converts a Python integer to a vector of 32-bit limbs (little endian). Takes number of bytes to\n/// convert to. Multiple of 4. If `is_signed` is true, the integer is treated as signed, and two's\n/// complement is returned.\n#[cfg(all(not(Py_LIMITED_API), feature = \"32_bit_limbs\"))]\n#[inline]\nfn int_to_limbs(long: &Bound<PyInt>, n_bytes: usize, is_signed: bool) -> PyResult<Vec<u32>> {\n    let mut buffer = Vec::with_capacity(n_bytes);\n    unsafe {\n        let error_code = ffi::_PyLong_AsByteArray(\n            long.as_ptr().cast(),           // ptr to PyInt object\n            buffer.as_mut_ptr() as *mut u8, // ptr to first byte of buffer\n            n_bytes << 2,                   // 4 bytes per u32\n            1,                              // little endian\n            is_signed.into(),               // signed flag\n        );\n        if error_code == -1 {\n            return Err(PyErr::fetch(long.py()));\n        }\n        buffer.set_len(n_bytes); // set buffer length to the number of bytes\n    };\n    buffer\n        .iter_mut()\n        .for_each(|chunk| *chunk = u32::from_le(*chunk));\n\n    Ok(buffer)\n}\n\n/// Converts a Python integer to a vector of 64-bit limbs (little endian). Takes number of bytes to\n/// convert to. Multiple of 8. If `is_signed` is true, the integer is treated as signed, and two's\n/// complement is returned.\n#[cfg(all(not(Py_LIMITED_API), not(feature = \"32_bit_limbs\")))]\n#[inline]\nfn int_to_limbs(long: &Bound<PyInt>, n_bytes: usize, is_signed: bool) -> PyResult<Vec<u64>> {\n    let mut buffer = Vec::with_capacity(n_bytes);\n    unsafe {\n        let error_code = ffi::_PyLong_AsByteArray(\n            long.as_ptr().cast(),           // ptr to PyLong object\n            buffer.as_mut_ptr() as *mut u8, // ptr to first byte of buffer\n            n_bytes << 3,                   // 8 bytes per u64\n            1,                              // little endian\n            is_signed.into(),               // signed flag\n        );\n        if error_code == -1 {\n            return Err(PyErr::fetch(long.py()));\n        }\n        buffer.set_len(n_bytes); // set buffer length to the number of bytes\n    };\n    buffer\n        .iter_mut()\n        .for_each(|chunk| *chunk = u64::from_le(*chunk));\n\n    Ok(buffer)\n}\n\n/// Converts a Python integer to a Python bytes object. Bytes are in little endian order. Takes\n/// number of bytes to convert to (can be calculated from the number of bits in the integer). If\n/// `is_signed` is true, the integer is treated as signed, and two's complement is returned.\n#[cfg(Py_LIMITED_API)]\n#[inline]\nfn int_to_py_bytes<'py>(\n    long: &Bound<'py, PyInt>,\n    n_bytes: usize,\n    is_signed: bool,\n) -> PyResult<Bound<'py, PyBytes>> {\n    // get the Python interpreter\n    let py = long.py();\n\n    // setup kwargs for to_bytes (only if signed)\n    let kwargs_dict = PyDict::new(py);\n    let kwargs = if is_signed {\n        kwargs_dict.set_item(intern!(py, \"signed\"), true)?;\n        Some(&kwargs_dict)\n    } else {\n        None\n    };\n\n    // call to_bytes\n    let bytes = long.call_method(\n        intern!(py, \"to_bytes\"),\n        (n_bytes, intern!(py, \"little\")),\n        kwargs,\n    )?;\n\n    // downcast to PyBytes\n    Ok(bytes.downcast_into()?)\n}\n\n/// Returns the number of bits in the absolute value of the given integer. The number of bits\n/// returned is the smallest number of bits that can represent the integer, not the multiple of 8\n/// (bytes) that it would take up in memory.\n#[inline]\nfn int_n_bits(long: &Bound<PyInt>) -> PyResult<usize> {\n    let py = long.py();\n\n    #[cfg(not(Py_LIMITED_API))]\n    {\n        // fast path\n        let n_bits = unsafe { ffi::_PyLong_NumBits(long.as_ptr()) };\n        if n_bits == (-1isize as usize) {\n            return Err(PyErr::fetch(py));\n        }\n        Ok(n_bits)\n    }\n\n    #[cfg(Py_LIMITED_API)]\n    {\n        // slow path\n        long.call_method0(intern!(py, \"bit_length\"))\n            .and_then(|l| l.extract::<usize>())\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    /// Prepare Python\n    fn prepare_python() {\n        pyo3::prepare_freethreaded_python();\n    }\n\n    /// Fibonacci sequence iterator (Rust)\n    fn rust_fib<T>() -> impl Iterator<Item = T>\n    where\n        T: From<u8>,\n        for<'a> &'a T: std::ops::Add<Output = T>,\n    {\n        let mut f0: T = T::from(1);\n        let mut f1: T = T::from(1);\n        std::iter::from_fn(move || {\n            let f2 = &f0 + &f1;\n            Some(std::mem::replace(&mut f0, std::mem::replace(&mut f1, f2)))\n        })\n    }\n\n    /// Fibonacci sequence iterator (Python)\n    fn python_fib(py: Python<'_>) -> impl Iterator<Item = Py<PyInt>> {\n        let mut f0 = 1u32.into_pyobject(py).unwrap();\n        let mut f1 = 1u32.into_pyobject(py).unwrap();\n        std::iter::from_fn(move || {\n            let f2 = f0\n                .call_method1(\"__add__\", (&f1,))\n                .unwrap()\n                .downcast_into::<PyInt>()\n                .unwrap();\n            Some(std::mem::replace(&mut f0, std::mem::replace(&mut f1, f2)).unbind())\n        })\n    }\n\n    /// Generate test python class\n    fn python_index_class(py: Python<'_>) -> Bound<'_, PyModule> {\n        let index_code = c\"\n            class C:\n                def __init__(self, x):\n                    self.x = x\n                def __index__(self):\n                    return self.x\n            \";\n        let filename = c\"index.py\";\n        let modulename = c\"index\";\n        PyModule::from_code(py, index_code, filename, modulename).unwrap()\n    }\n\n    /// - Test conversion to and from Natural\n    /// - Tests the first 2000 numbers in the fibonacci sequence\n    #[test]\n    fn convert_natural() {\n        prepare_python();\n        Python::with_gil(|py| {\n            // check the first 2000 numbers in the fibonacci sequence\n            for (py_result, rs_result) in python_fib(py).zip(rust_fib::<Natural>()).take(2000) {\n                // Python -> Rust\n                assert_eq!(py_result.extract::<Natural>(py).unwrap(), rs_result);\n                // Rust -> Python\n                assert!(\n                    py_result\n                        .bind(py)\n                        .as_any()\n                        .eq(rs_result.into_pyobject(py).unwrap())\n                        .unwrap()\n                );\n            }\n        });\n    }\n\n    /// Test Python class conversion\n    #[test]\n    fn convert_index_class() {\n        prepare_python();\n        Python::with_gil(|py| {\n            let index = python_index_class(py);\n            let locals = PyDict::new(py);\n            locals.set_item(\"index\", &index).unwrap();\n            let expr = c\"index.C(10)\";\n            let ob = py.eval(expr, None, Some(&locals)).unwrap();\n            let natural: Natural = <Natural as FromPyObject>::extract_bound(&ob).unwrap();\n\n            assert_eq!(natural, Natural::from(10_u8));\n        });\n    }\n\n    /// Test conversion to and from zero\n    #[test]\n    fn handle_zero() {\n        prepare_python();\n        Python::with_gil(|py| {\n            // Python -> Rust\n            let zero_natural: Natural = 0u32.into_pyobject(py).unwrap().extract().unwrap();\n            assert_eq!(zero_natural, Natural::from(0_u8));\n\n            // Rust -> Python\n            let zero_natural = zero_natural.into_pyobject(py).unwrap();\n            assert!(\n                zero_natural\n                    .as_any()\n                    .eq(0u8.into_py_any(py).unwrap())\n                    .unwrap()\n            );\n        });\n    }\n\n    /// Test for possible overflows\n    #[test]\n    fn check_overflow() {\n        prepare_python();\n        Python::with_gil(|py| {\n            macro_rules! test {\n                ($T:ty, $value:expr, $py:expr) => {\n                    let value = $value;\n                    println!(\"{}: {}\", stringify!($T), value);\n                    let python_value = value.clone().into_pyobject(py).unwrap();\n                    let roundtrip_value =\n                        <$T as FromPyObject>::extract_bound(&python_value).unwrap();\n                    assert_eq!(value, roundtrip_value);\n                };\n            }\n\n            for i in 0..=256usize {\n                // test a lot of values to help catch other bugs too\n                test!(Natural, Natural::from(i), py);\n                test!(Natural, Natural::from(1u32) << i, py);\n                test!(\n                    Natural,\n                    (Natural::from(1u32) << i) + Natural::from(1u32),\n                    py\n                );\n                test!(\n                    Natural,\n                    (Natural::from(1u32) << i) - Natural::from(1u32),\n                    py\n                );\n            }\n        });\n    }\n\n    /// Test error when converting negative integer to Natural\n    #[test]\n    fn negative_natural() {\n        prepare_python();\n        Python::with_gil(|py| {\n            let zero = 0u32.into_pyobject(py).unwrap();\n            let minus_one = (-1i32).into_pyobject(py).unwrap();\n            assert_eq!(zero.extract::<Natural>().unwrap(), Natural::ZERO);\n            assert!(\n                minus_one\n                    .extract::<Natural>()\n                    .unwrap_err()\n                    .get_type(py)\n                    .is(&PyType::new::<PyValueError>(py))\n            );\n        });\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::{Natural, SerdeNatural};\nuse alloc::string::String;\nuse core::convert::TryFrom;\nuse malachite_base::num::conversion::traits::FromStringBase;\n\nimpl From<Natural> for SerdeNatural {\n    #[inline]\n    fn from(x: Natural) -> Self {\n        Self(format!(\"{x:#x}\"))\n    }\n}\n\nimpl TryFrom<SerdeNatural> for Natural {\n    type Error = String;\n\n    #[inline]\n    fn try_from(s: SerdeNatural) -> Result<Self, String> {\n        if s.0.starts_with(\"0x\") {\n            Self::from_string_base(16, &s.0[2..])\n                .ok_or_else(|| format!(\"Unrecognized digits in {}\", s.0))\n        } else {\n            Err(format!(\"String '{}' does not start with '0x'\", s.0))\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse core::cmp::Ordering::*;\nuse core::ops::Mul;\nuse malachite_base::num::arithmetic::traits::{CheckedSub, Parity, Pow};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::string::from_sci_string::{\n    cmp_half_helper, is_zero_helper, preprocess_sci_string, validate_helper,\n};\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::num::conversion::traits::{FromSciString, FromStringBase};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\n#[doc(hidden)]\npub trait FromSciStringHelper: Sized {\n    fn parse_int(cs: &[u8], base: u8) -> Option<Self>;\n\n    fn up_1(self, neg: bool) -> Option<Self>;\n}\n\nimpl FromSciStringHelper for Natural {\n    fn parse_int(mut cs: &[u8], base: u8) -> Option<Self> {\n        // if T is unsigned, from_string_base won't handle -0\n        let mut test_neg_zero = false;\n        if let Some(&b'-') = cs.first() {\n            test_neg_zero = true;\n        }\n        if test_neg_zero {\n            if cs.len() == 1 {\n                return None;\n            }\n            for &c in &cs[1..] {\n                if c != b'0' {\n                    return None;\n                }\n            }\n            Some(Self::ZERO)\n        } else {\n            if let Some(b'+') = cs.first() {\n                cs = &cs[1..];\n                // If the string begins with a '+', the second character cannot be '+' or '-'\n                match cs {\n                    [] | [b'+' | b'-', ..] => return None,\n                    _ => {}\n                }\n            }\n            Self::from_string_base(base, core::str::from_utf8(cs).ok()?)\n        }\n    }\n\n    fn up_1(self, neg: bool) -> Option<Self> {\n        if neg {\n            self.checked_sub(Self::ONE)\n        } else {\n            Some(self + Self::ONE)\n        }\n    }\n}\n\npub(crate) fn from_sci_string_with_options_helper<\n    T: From<u8> + FromSciStringHelper + Mul<T, Output = T> + Pow<u64, Output = T> + Zero,\n>(\n    s: &str,\n    options: FromSciStringOptions,\n) -> Option<T>\nwhere\n    for<'a> &'a T: Parity,\n{\n    let (s, exponent) = preprocess_sci_string(s, options)?;\n    if exponent >= 0 {\n        let x = T::parse_int(&s, options.get_base())?;\n        Some(x * T::from(options.get_base()).pow(exponent.unsigned_abs()))\n    } else {\n        let neg_exponent = usize::try_from(exponent.unsigned_abs()).ok()?;\n        let len = s.len();\n        if len == 0 {\n            return None;\n        }\n        let first = s[0];\n        let neg = first == b'-';\n        let sign = neg || first == b'+';\n        let rm = if neg {\n            -options.get_rounding_mode()\n        } else {\n            options.get_rounding_mode()\n        };\n        let sig_len = if sign { len - 1 } else { len };\n        if sig_len == 0 {\n            return None;\n        }\n        if neg_exponent > sig_len {\n            let s = if sign { &s[1..] } else { &s[..] };\n            return match rm {\n                Down | Floor | Nearest => {\n                    validate_helper(s, options.get_base())?;\n                    Some(T::ZERO)\n                }\n                Up | Ceiling => {\n                    if is_zero_helper(s, options.get_base())? {\n                        Some(T::ZERO)\n                    } else {\n                        T::ZERO.up_1(neg)\n                    }\n                }\n                Exact => None,\n            };\n        }\n        let (before_e, after_e) = s.split_at(len - neg_exponent);\n        let x = match before_e {\n            &[] | &[b'-'] | &[b'+'] => T::ZERO,\n            before_e => T::parse_int(before_e, options.get_base())?,\n        };\n        if after_e.is_empty() {\n            return Some(x);\n        }\n        match rm {\n            Down | Floor => {\n                validate_helper(after_e, options.get_base())?;\n                Some(x)\n            }\n            Up | Ceiling => {\n                if is_zero_helper(after_e, options.get_base())? {\n                    Some(x)\n                } else {\n                    x.up_1(neg)\n                }\n            }\n            Exact => {\n                if is_zero_helper(after_e, options.get_base())? {\n                    Some(x)\n                } else {\n                    None\n                }\n            }\n            Nearest => match cmp_half_helper(after_e, options.get_base())? {\n                Less => Some(x),\n                Greater => x.up_1(neg),\n                Equal => {\n                    if x.even() {\n                        Some(x)\n                    } else {\n                        x.up_1(neg)\n                    }\n                }\n            },\n        }\n    }\n}\n\nimpl FromSciString for Natural {\n    /// Converts a string, possibly in scientfic notation, to a [`Natural`].\n    ///\n    /// Use [`FromSciStringOptions`] to specify the base (from 2 to 36, inclusive) and the rounding\n    /// mode, in case rounding is necessary because the string represents a non-integer.\n    ///\n    /// If the base is greater than 10, the higher digits are represented by the letters `'a'`\n    /// through `'z'` or `'A'` through `'Z'`; the case doesn't matter and doesn't need to be\n    /// consistent.\n    ///\n    /// Exponents are allowed, and are indicated using the character `'e'` or `'E'`. If the base is\n    /// 15 or greater, an ambiguity arises where it may not be clear whether `'e'` is a digit or an\n    /// exponent indicator. To resolve this ambiguity, always use a `'+'` or `'-'` sign after the\n    /// exponent indicator when the base is 15 or greater.\n    ///\n    /// The exponent itself is always parsed using base 10.\n    ///\n    /// Decimal (or other-base) points are allowed. These are most useful in conjunction with\n    /// exponents, but they may be used on their own. If the string represents a non-integer, the\n    /// rounding mode specified in `options` is used to round to an integer.\n    ///\n    /// If the string is unparseable, `None` is returned. `None` is also returned if the rounding\n    /// mode in options is `Exact`, but rounding is necessary.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m^n n \\log m (\\log n + \\log\\log m))$\n    ///\n    /// $M(n, m) = O(m^n n \\log m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `s.len()`, and $m$ is `options.base`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::FromSciStringOptions;\n    /// use malachite_base::num::conversion::traits::FromSciString;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from_sci_string(\"123\").unwrap(), 123);\n    /// assert_eq!(Natural::from_sci_string(\"123.5\").unwrap(), 124);\n    /// assert_eq!(Natural::from_sci_string(\"-123.5\"), None);\n    /// assert_eq!(Natural::from_sci_string(\"1.23e10\").unwrap(), 12300000000u64);\n    ///\n    /// let mut options = FromSciStringOptions::default();\n    /// assert_eq!(\n    ///     Natural::from_sci_string_with_options(\"123.5\", options).unwrap(),\n    ///     124\n    /// );\n    ///\n    /// options.set_rounding_mode(Floor);\n    /// assert_eq!(\n    ///     Natural::from_sci_string_with_options(\"123.5\", options).unwrap(),\n    ///     123\n    /// );\n    ///\n    /// options = FromSciStringOptions::default();\n    /// options.set_base(16);\n    /// assert_eq!(\n    ///     Natural::from_sci_string_with_options(\"ff\", options).unwrap(),\n    ///     255\n    /// );\n    ///\n    /// options = FromSciStringOptions::default();\n    /// options.set_base(36);\n    /// assert_eq!(\n    ///     Natural::from_sci_string_with_options(\"1e5\", options).unwrap(),\n    ///     1805\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_sci_string_with_options(\"1e+5\", options).unwrap(),\n    ///     60466176\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_sci_string_with_options(\"1e-5\", options).unwrap(),\n    ///     0\n    /// );\n    /// ```\n    #[inline]\n    fn from_sci_string_with_options(s: &str, options: FromSciStringOptions) -> Option<Self> {\n        from_sci_string_with_options_helper(s, options)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::Small;\nuse crate::natural::Natural;\nuse crate::platform::{Limb, MAX_DIGITS_PER_LIMB};\nuse core::str::FromStr;\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, ShrRound};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::string::from_string::digit_from_display_byte;\nuse malachite_base::num::conversion::traits::{Digits, ExactFrom, FromStringBase, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nimpl FromStr for Natural {\n    type Err = ();\n\n    /// Converts an string to a [`Natural`].\n    ///\n    /// If the string does not represent a valid [`Natural`], an `Err` is returned. To be valid, the\n    /// string must be nonempty and only contain the [`char`]s `'0'` through `'9'`. Leading zeros\n    /// are allowed.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from_str(\"123456\").unwrap(), 123456);\n    /// assert_eq!(Natural::from_str(\"00123456\").unwrap(), 123456);\n    /// assert_eq!(Natural::from_str(\"0\").unwrap(), 0);\n    ///\n    /// assert!(Natural::from_str(\"\").is_err());\n    /// assert!(Natural::from_str(\"a\").is_err());\n    /// assert!(Natural::from_str(\"-5\").is_err());\n    /// ```\n    #[inline]\n    fn from_str(s: &str) -> Result<Self, ()> {\n        Self::from_string_base(10, s).ok_or(())\n    }\n}\n\nfn from_binary_str(s: &str) -> Option<Natural> {\n    let len = s.len();\n    if len <= usize::wrapping_from(Limb::WIDTH) {\n        Limb::from_str_radix(s, 2).ok().map(Natural::from)\n    } else {\n        let mut xs = vec![0; len.shr_round(Limb::LOG_WIDTH, Ceiling).0];\n        let mut remaining = u64::wrapping_from(len & usize::wrapping_from(Limb::WIDTH_MASK));\n        let mut i = xs.len();\n        let mut x = xs.last_mut().unwrap();\n        if remaining != 0 {\n            i -= 1;\n        }\n        for b in s.bytes() {\n            if remaining == 0 {\n                i -= 1;\n                x = &mut xs[i];\n                remaining = Limb::WIDTH;\n            }\n            *x <<= 1;\n            match b {\n                b'1' => *x |= 1,\n                b'0' => {}\n                _ => return None,\n            }\n            remaining -= 1;\n        }\n        Some(Natural::from_owned_limbs_asc(xs))\n    }\n}\n\nfn from_oct_str(s: &str) -> Option<Natural> {\n    let len = s.len();\n    if len <= usize::wrapping_from(Limb::WIDTH / 3) {\n        Limb::from_str_radix(s, 8).ok().map(Natural::from)\n    } else {\n        let bit_len = len.checked_mul(3).unwrap();\n        let mut xs = vec![0; bit_len.shr_round(Limb::LOG_WIDTH, Ceiling).0];\n        let mut remaining = u64::exact_from(bit_len) & Limb::WIDTH_MASK;\n        let mut i = xs.len();\n        let mut x = xs.last_mut().unwrap();\n        if remaining != 0 {\n            i -= 1;\n        }\n        for b in s.bytes() {\n            let digit = digit_from_display_byte(b)?;\n            if digit >= 8 {\n                return None;\n            }\n            let digit = Limb::wrapping_from(digit);\n            match remaining {\n                0 => {\n                    i -= 1;\n                    x = &mut xs[i];\n                    *x = digit;\n                    remaining = Limb::WIDTH - 3;\n                }\n                1 => {\n                    *x <<= 1;\n                    *x |= digit >> 2;\n                    i -= 1;\n                    x = &mut xs[i];\n                    *x = digit & 3;\n                    remaining = Limb::WIDTH - 2;\n                }\n                2 => {\n                    *x <<= 2;\n                    *x |= digit >> 1;\n                    i -= 1;\n                    x = &mut xs[i];\n                    *x = digit & 1;\n                    remaining = Limb::WIDTH - 1;\n                }\n                _ => {\n                    *x <<= 3;\n                    *x |= digit;\n                    remaining -= 3;\n                }\n            }\n        }\n        Some(Natural::from_owned_limbs_asc(xs))\n    }\n}\n\nfn from_hex_str(s: &str) -> Option<Natural> {\n    let len = s.len();\n    if len <= usize::wrapping_from(Limb::WIDTH >> 2) {\n        Limb::from_str_radix(s, 16).ok().map(Natural::from)\n    } else {\n        let mut xs = vec![0; len.shr_round(Limb::LOG_WIDTH - 2, Ceiling).0];\n        let mut remaining = u64::wrapping_from(len.mod_power_of_2(Limb::LOG_WIDTH - 2)) << 2;\n        let mut i = xs.len();\n        let mut x = xs.last_mut().unwrap();\n        if remaining != 0 {\n            i -= 1;\n        }\n        for b in s.bytes() {\n            if remaining == 0 {\n                i -= 1;\n                x = &mut xs[i];\n                remaining = Limb::WIDTH;\n            }\n            *x <<= 4;\n            let digit = digit_from_display_byte(b)?;\n            if digit >= 16 {\n                return None;\n            }\n            *x |= Limb::wrapping_from(digit);\n            remaining -= 4;\n        }\n        Some(Natural::from_owned_limbs_asc(xs))\n    }\n}\n\nimpl FromStringBase for Natural {\n    /// Converts an string, in a specified base, to a [`Natural`].\n    ///\n    /// If the string does not represent a valid [`Natural`], an `Err` is returned. To be valid, the\n    /// string must be nonempty and only contain the [`char`]s `'0'` through `'9'`, `'a'` through\n    /// `'z'`, and `'A'` through `'Z'`, with an optional single leading `'+'`; and only characters\n    /// that represent digits smaller than the base are allowed. Leading zeros are always allowed.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::FromStringBase;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from_string_base(10, \"123456\").unwrap(), 123456);\n    /// assert_eq!(Natural::from_string_base(10, \"00123456\").unwrap(), 123456);\n    /// assert_eq!(Natural::from_string_base(16, \"0\").unwrap(), 0);\n    /// assert_eq!(\n    ///     Natural::from_string_base(16, \"deadbeef\").unwrap(),\n    ///     3735928559u32\n    /// );\n    /// assert_eq!(\n    ///     Natural::from_string_base(16, \"deAdBeEf\").unwrap(),\n    ///     3735928559u32\n    /// );\n    ///\n    /// assert!(Natural::from_string_base(10, \"\").is_none());\n    /// assert!(Natural::from_string_base(10, \"a\").is_none());\n    /// assert!(Natural::from_string_base(10, \"-5\").is_none());\n    /// assert!(Natural::from_string_base(2, \"2\").is_none());\n    /// ```\n    #[inline]\n    fn from_string_base(base: u8, mut s: &str) -> Option<Self> {\n        assert!((2..=36).contains(&base), \"base out of range\");\n        if s.is_empty() {\n            None\n        } else {\n            match base {\n                2 => from_binary_str(s),\n                8 => from_oct_str(s),\n                16 => from_hex_str(s),\n                10 => {\n                    if s.len() < MAX_DIGITS_PER_LIMB {\n                        Limb::from_str(s).ok().map(|x| Self(Small(x)))\n                    } else {\n                        if let Some(prefix_s) = s.strip_prefix('+') {\n                            s = prefix_s;\n                        }\n                        Self::from_digits_desc(\n                            &10,\n                            s.bytes()\n                                .map(|b| if b >= b'0' { b - b'0' } else { u8::MAX }),\n                        )\n                    }\n                }\n                _ => {\n                    for b in s.bytes() {\n                        let digit = digit_from_display_byte(b)?;\n                        if digit >= base {\n                            return None;\n                        }\n                    }\n                    Self::from_digits_desc(\n                        &u8::wrapping_from(base),\n                        s.bytes().map(|b| digit_from_display_byte(b).unwrap()),\n                    )\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of [`FromSciString`](malachite_base::num::conversion::traits::FromSciString).\n/// This is a trait for converting strings, possibly using scientific notation, to numbers.\npub mod from_sci_string;\n/// Implementations of [`FromStr`](core::str::FromStr) and of\n/// [`FromStringBase`](malachite_base::num::conversion::traits::FromStringBase), a trait for\n/// converting strings in a specified base to numbers.\npub mod from_string;\n/// Implementations of [`ToSci`](malachite_base::num::conversion::traits::ToSci), a trait for\n/// converting a number to string, possibly using scientific notation.\npub mod to_sci;\n/// The [`BaseFmtWrapper`](to_string::BaseFmtWrapper) struct and implementations of\n/// [`Display`](core::fmt::Display), [`Debug`], [`Binary`](core::fmt::Binary),\n/// [`Octal`](core::fmt::Octal), [`LowerHex`](core::fmt::LowerHex), and\n/// [`UpperHex`](core::fmt::UpperHex), and of the\n/// [`ToStringBase`](malachite_base::num::conversion::traits::ToStringBase) trait, used for\n/// converting numbers to strings.\npub mod to_string;\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::log_base::log_base_helper_with_pow;\nuse crate::natural::conversion::string::to_string::BaseFmtWrapper;\nuse crate::natural::slice_trailing_zeros;\nuse alloc::string::String;\nuse core::fmt::{Display, Formatter, Write};\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, DivExact, DivRound, DivisibleBy, DivisibleByPowerOf2, FloorLogBase,\n    FloorLogBasePowerOf2, Pow, ShrRound,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::string::options::{SciSizeOptions, ToSciOptions};\nuse malachite_base::num::conversion::string::to_sci::write_exponent;\nuse malachite_base::num::conversion::string::to_string::{\n    digit_to_display_byte_lower, digit_to_display_byte_upper,\n};\nuse malachite_base::num::conversion::traits::{Digits, ExactFrom, ToSci};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nfn write_helper<T>(x: &T, f: &mut Formatter, options: ToSciOptions) -> core::fmt::Result\nwhere\n    for<'a> BaseFmtWrapper<&'a T>: Display,\n{\n    let w = BaseFmtWrapper {\n        x,\n        base: options.get_base(),\n    };\n    if options.get_lowercase() {\n        Display::fmt(&w, f)\n    } else {\n        write!(f, \"{w:#}\")\n    }\n}\n\nimpl ToSci for Natural {\n    /// Determines whether a [`Natural`] can be converted to a string using\n    /// [`to_sci`](`Self::to_sci`) and a particular set of options.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::ToSciOptions;\n    /// use malachite_base::num::conversion::traits::ToSci;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut options = ToSciOptions::default();\n    /// assert!(Natural::from(123u8).fmt_sci_valid(options));\n    /// assert!(Natural::from(u128::MAX).fmt_sci_valid(options));\n    /// // u128::MAX has more than 16 significant digits\n    /// options.set_rounding_mode(Exact);\n    /// assert!(!Natural::from(u128::MAX).fmt_sci_valid(options));\n    /// options.set_precision(50);\n    /// assert!(Natural::from(u128::MAX).fmt_sci_valid(options));\n    /// ```\n    fn fmt_sci_valid(&self, options: ToSciOptions) -> bool {\n        if *self == 0u32 || options.get_rounding_mode() != Exact {\n            return true;\n        }\n        match options.get_size_options() {\n            SciSizeOptions::Complete | SciSizeOptions::Scale(_) => true,\n            SciSizeOptions::Precision(precision) => {\n                let n_base = Self::from(options.get_base());\n                let log = self.floor_log_base(&n_base);\n                if log < precision {\n                    return true;\n                }\n                let scale = log - precision + 1;\n                if let Some(base_log) = options.get_base().checked_log_base_2() {\n                    self.divisible_by_power_of_2(base_log * scale)\n                } else {\n                    self.divisible_by(n_base.pow(scale))\n                }\n            }\n        }\n    }\n\n    /// Converts a [`Natural`] to a string using a specified base, possibly formatting the number\n    /// using scientific notation.\n    ///\n    /// See [`ToSciOptions`] for details on the available options. Note that setting\n    /// `neg_exp_threshold` has no effect, since there is never a need to use negative exponents\n    /// when representing a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `options.rounding_mode` is `Exact`, but the size options are such that the input\n    /// must be rounded.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::ToSciOptions;\n    /// use malachite_base::num::conversion::traits::ToSci;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     format!(\"{}\", Natural::from(u128::MAX).to_sci()),\n    ///     \"3.402823669209385e38\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(u128::MAX).to_sci().to_string(),\n    ///     \"3.402823669209385e38\"\n    /// );\n    ///\n    /// let n = Natural::from(123456u32);\n    /// let mut options = ToSciOptions::default();\n    /// assert_eq!(format!(\"{}\", n.to_sci_with_options(options)), \"123456\");\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"123456\");\n    ///\n    /// options.set_precision(3);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.23e5\");\n    ///\n    /// options.set_rounding_mode(Ceiling);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.24e5\");\n    ///\n    /// options.set_e_uppercase();\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.24E5\");\n    ///\n    /// options.set_force_exponent_plus_sign(true);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.24E+5\");\n    ///\n    /// options = ToSciOptions::default();\n    /// options.set_base(36);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"2n9c\");\n    ///\n    /// options.set_uppercase();\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"2N9C\");\n    ///\n    /// options.set_base(2);\n    /// options.set_precision(10);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.1110001e16\");\n    ///\n    /// options.set_include_trailing_zeros(true);\n    /// assert_eq!(n.to_sci_with_options(options).to_string(), \"1.111000100e16\");\n    /// ```\n    fn fmt_sci(&self, f: &mut Formatter, options: ToSciOptions) -> core::fmt::Result {\n        match options.get_size_options() {\n            SciSizeOptions::Complete | SciSizeOptions::Scale(0) => write_helper(self, f, options),\n            SciSizeOptions::Scale(scale) => {\n                write_helper(self, f, options)?;\n                if options.get_include_trailing_zeros() {\n                    f.write_char('.')?;\n                    for _ in 0..scale {\n                        f.write_char('0')?;\n                    }\n                }\n                Ok(())\n            }\n            SciSizeOptions::Precision(precision) => {\n                let n_base = Self::from(options.get_base());\n                let (base_log, log, power, p) = if *self == 0u32 {\n                    // power and p unused\n                    (None, 0, Self::ZERO, 0)\n                } else if let Some(base_log) = options.get_base().checked_log_base_2() {\n                    // power and p unused\n                    (\n                        Some(base_log),\n                        self.floor_log_base_power_of_2(base_log),\n                        Self::ZERO,\n                        0,\n                    )\n                } else {\n                    // We save base^p so that we can save some computation later\n                    let (log, _, power, p) = log_base_helper_with_pow(self, &n_base);\n                    (None, log, power, p)\n                };\n                if log < precision {\n                    // no exponent\n                    write_helper(self, f, options)?;\n                    if options.get_include_trailing_zeros() {\n                        let extra_zeros = precision - log - 1;\n                        if extra_zeros != 0 {\n                            f.write_char('.')?;\n                            for _ in 0..extra_zeros {\n                                f.write_char('0')?;\n                            }\n                        }\n                    }\n                    Ok(())\n                } else {\n                    // exponent\n                    let mut e = log;\n                    let scale = log - precision + 1;\n                    let shifted = if let Some(base_log) = base_log {\n                        self.shr_round(base_log * scale, options.get_rounding_mode())\n                            .0\n                    } else {\n                        let n = if precision > log >> 1 {\n                            n_base.pow(scale)\n                        } else if p >= scale {\n                            power.div_exact(n_base.pow(p - scale))\n                        } else {\n                            // Not sure if this ever happens\n                            assert!(p == scale + 1);\n                            power * n_base\n                        };\n                        self.div_round(n, options.get_rounding_mode()).0\n                    };\n                    let mut chars = shifted.to_digits_desc(&options.get_base());\n                    let mut len = chars.len();\n                    let p = usize::exact_from(precision);\n                    if len > p {\n                        // rounded up to a power of the base, need to reduce precision\n                        assert_eq!(chars.pop().unwrap(), 0);\n                        len -= 1;\n                        e += 1;\n                    }\n                    assert_eq!(len, p);\n                    if !options.get_include_trailing_zeros() {\n                        chars.truncate(len - slice_trailing_zeros(&chars));\n                    }\n                    if options.get_lowercase() {\n                        for digit in &mut chars {\n                            *digit = digit_to_display_byte_lower(*digit).unwrap();\n                        }\n                    } else {\n                        for digit in &mut chars {\n                            *digit = digit_to_display_byte_upper(*digit).unwrap();\n                        }\n                    }\n                    len = chars.len();\n                    if len != 1 {\n                        chars.push(b'0');\n                        chars.copy_within(1..len, 2);\n                        chars[1] = b'.';\n                    }\n                    f.write_str(&String::from_utf8(chars).unwrap())?;\n                    write_exponent(f, options, e)\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::conversion::digits::general_digits::{\n    limbs_digit_count, limbs_to_digits_small_base_no_alg_specified,\n};\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::platform::Limb;\nuse alloc::string::String;\n#[cfg(feature = \"test_build\")]\nuse core::fmt::Write;\nuse core::fmt::{Binary, Debug, Display, Formatter, LowerHex, Octal, Result, UpperHex};\n#[cfg(feature = \"test_build\")]\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::{DivRound, Parity, ShrRound};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::string::to_string::{\n    BaseFmtWrapper as BaseBaseFmtWrapper, digit_to_display_byte_lower, digit_to_display_byte_upper,\n};\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::conversion::traits::PowerOf2DigitIterable;\nuse malachite_base::num::conversion::traits::{Digits, ExactFrom, ToStringBase, WrappingFrom};\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::logic::traits::{BitIterable, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\n/// A `struct` that allows for formatting a [`Natural`] or [`Integer`](crate::integer::Integer) and\n/// rendering its digits in a specified base.\n#[derive(Clone, Eq, Hash, PartialEq)]\npub struct BaseFmtWrapper<T> {\n    pub(crate) x: T,\n    pub(crate) base: u8,\n}\n\nimpl<T> BaseFmtWrapper<T> {\n    /// Creates a new `BaseFmtWrapper`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n = Natural::from(1000000000u32);\n    /// let x = BaseFmtWrapper::new(&n, 36);\n    /// assert_eq!(format!(\"{}\", x), \"gjdgxs\");\n    /// assert_eq!(format!(\"{:#}\", x), \"GJDGXS\");\n    ///\n    /// let n = Integer::from(-1000000000);\n    /// let x = BaseFmtWrapper::new(&n, 36);\n    /// assert_eq!(format!(\"{}\", x), \"-gjdgxs\");\n    /// assert_eq!(format!(\"{:#}\", x), \"-GJDGXS\");\n    /// ```\n    pub fn new(x: T, base: u8) -> Self {\n        assert!((2..=36).contains(&base), \"base out of range\");\n        Self { x, base }\n    }\n\n    /// Recovers the value from a `BaseFmtWrapper`.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     BaseFmtWrapper::new(Natural::from(1000000000u32), 36).unwrap(),\n    ///     1000000000\n    /// );\n    /// ```\n    #[allow(clippy::missing_const_for_fn)]\n    pub fn unwrap(self) -> T {\n        self.x\n    }\n}\n\nimpl Display for BaseFmtWrapper<&Natural> {\n    /// Writes a wrapped [`Natural`] to a string using a specified base.\n    ///\n    /// If the base is greater than 10, lowercase alphabetic letters are used by default. Using the\n    /// `#` flag switches to uppercase letters. Padding with zeros works as usual.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n = Natural::from(1000000000u32);\n    /// let x = BaseFmtWrapper::new(&n, 36);\n    /// assert_eq!(format!(\"{}\", x), \"gjdgxs\");\n    /// assert_eq!(format!(\"{:#}\", x), \"GJDGXS\");\n    /// assert_eq!(format!(\"{:010}\", x), \"0000gjdgxs\");\n    /// assert_eq!(format!(\"{:#010}\", x), \"0000GJDGXS\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        assert!((2..=36).contains(&self.base), \"base out of range\");\n        if let Natural(Small(x)) = self.x {\n            Display::fmt(&BaseBaseFmtWrapper::new(*x, self.base), f)\n        } else {\n            let mut digits = self.x.to_digits_desc(&u8::wrapping_from(self.base));\n            if f.alternate() {\n                for digit in &mut digits {\n                    *digit = digit_to_display_byte_upper(*digit).unwrap();\n                }\n            } else {\n                for digit in &mut digits {\n                    *digit = digit_to_display_byte_lower(*digit).unwrap();\n                }\n            }\n            f.pad_integral(true, \"\", core::str::from_utf8(&digits).unwrap())\n        }\n    }\n}\n\nimpl Debug for BaseFmtWrapper<&Natural> {\n    /// Writes a wrapped [`Natural`] to a string using a specified base.\n    ///\n    /// If the base is greater than 10, lowercase alphabetic letters are used by default. Using the\n    /// `#` flag switches to uppercase letters. Padding with zeros works as usual.\n    ///\n    /// This is the same as the [`Display::fmt`] implementation.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let n = Natural::from(1000000000u32);\n    /// let x = BaseFmtWrapper::new(&n, 36);\n    /// assert_eq!(format!(\"{:?}\", x), \"gjdgxs\");\n    /// assert_eq!(format!(\"{:#?}\", x), \"GJDGXS\");\n    /// assert_eq!(format!(\"{:010?}\", x), \"0000gjdgxs\");\n    /// assert_eq!(format!(\"{:#010?}\", x), \"0000GJDGXS\");\n    /// ```\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n\nimpl ToStringBase for Natural {\n    /// Converts a [`Natural`] to a [`String`] using a specified base.\n    ///\n    /// Digits from 0 to 9 become [`char`]s from `'0'` to `'9'`. Digits from 10 to 35 become the\n    /// lowercase [`char`]s `'a'` to `'z'`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ToStringBase;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(1000u32).to_string_base(2), \"1111101000\");\n    /// assert_eq!(Natural::from(1000u32).to_string_base(10), \"1000\");\n    /// assert_eq!(Natural::from(1000u32).to_string_base(36), \"rs\");\n    /// ```\n    fn to_string_base(&self, base: u8) -> String {\n        assert!((2..=36).contains(&base), \"base out of range\");\n        if let Self(Small(x)) = self {\n            x.to_string_base(base)\n        } else {\n            let mut digits = self.to_digits_desc(&base);\n            for digit in &mut digits {\n                *digit = digit_to_display_byte_lower(*digit).unwrap();\n            }\n            String::from_utf8(digits).unwrap()\n        }\n    }\n\n    /// Converts a [`Natural`] to a [`String`] using a specified base.\n    ///\n    /// Digits from 0 to 9 become [`char`]s from `'0'` to `'9'`. Digits from 10 to 35 become the\n    /// uppercase [`char`]s `'A'` to `'Z'`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ToStringBase;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(1000u32).to_string_base_upper(2), \"1111101000\");\n    /// assert_eq!(Natural::from(1000u32).to_string_base_upper(10), \"1000\");\n    /// assert_eq!(Natural::from(1000u32).to_string_base_upper(36), \"RS\");\n    /// ```\n    fn to_string_base_upper(&self, base: u8) -> String {\n        assert!((2..=36).contains(&base), \"base out of range\");\n        if let Self(Small(x)) = self {\n            x.to_string_base_upper(base)\n        } else {\n            let mut digits = self.to_digits_desc(&base);\n            for digit in &mut digits {\n                *digit = digit_to_display_byte_upper(*digit).unwrap();\n            }\n            String::from_utf8(digits).unwrap()\n        }\n    }\n}\n\nimpl Display for Natural {\n    /// Converts a [`Natural`] to a [`String`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.to_string(), \"0\");\n    /// assert_eq!(Natural::from(123u32).to_string(), \"123\");\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000\").unwrap().to_string(),\n    ///     \"1000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:05}\", Natural::from(123u32)), \"00123\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match self {\n            Self(Small(x)) => Display::fmt(x, f),\n            Self(Large(xs)) => {\n                let mut digits = vec![0; usize::exact_from(limbs_digit_count(xs, 10))];\n                let mut xs = xs.clone();\n                let len = limbs_to_digits_small_base_no_alg_specified(&mut digits, 10, &mut xs);\n                digits.truncate(len);\n                for digit in &mut digits {\n                    *digit = digit_to_display_byte_lower(*digit).unwrap();\n                }\n                f.pad_integral(true, \"\", core::str::from_utf8(&digits).unwrap())\n            }\n        }\n    }\n}\n\nimpl Debug for Natural {\n    /// Converts a [`Natural`] to a [`String`].\n    ///\n    /// This is the same as the [`Display::fmt`] implementation.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.to_debug_string(), \"0\");\n    /// assert_eq!(Natural::from(123u32).to_debug_string(), \"123\");\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_debug_string(),\n    ///     \"1000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:05?}\", Natural::from(123u32)), \"00123\");\n    /// ```\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n\n#[cfg(feature = \"test_build\")]\npub struct NaturalAlt(pub Natural);\n\n#[cfg(feature = \"test_build\")]\npub struct NaturalAlt2(pub Natural);\n\n#[cfg(feature = \"test_build\")]\nimpl Binary for NaturalAlt {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if let Natural(Small(x)) = self.0 {\n            Binary::fmt(&x, f)\n        } else {\n            if f.alternate() {\n                f.write_str(\"0b\")?;\n            }\n            if let Some(width) = f.width() {\n                let mut len = usize::exact_from(self.0.significant_bits());\n                if f.alternate() {\n                    len += 2;\n                }\n                for _ in 0..width.saturating_sub(len) {\n                    f.write_char('0')?;\n                }\n            }\n            for bit in self.0.bits().rev() {\n                f.write_char(if bit { '1' } else { '0' })?;\n            }\n            Ok(())\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\nimpl Binary for NaturalAlt2 {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match &self.0 {\n            Natural(Small(x)) => Binary::fmt(x, f),\n            Natural(Large(xs)) => {\n                let (xs_last, xs_init) = xs.split_last().unwrap();\n                let width = if let Some(width) = f.width() {\n                    width.saturating_sub(xs_init.len() << Limb::LOG_WIDTH)\n                } else {\n                    0\n                };\n                let mut result = if f.alternate() {\n                    write!(f, \"{xs_last:#0width$b}\")\n                } else {\n                    write!(f, \"{xs_last:0width$b}\")\n                };\n                for x in xs_init.iter().rev() {\n                    #[cfg(feature = \"32_bit_limbs\")]\n                    {\n                        result = write!(f, \"{x:032b}\");\n                    }\n                    #[cfg(not(feature = \"32_bit_limbs\"))]\n                    {\n                        result = write!(f, \"{x:064b}\");\n                    }\n                }\n                result\n            }\n        }\n    }\n}\n\nimpl Binary for Natural {\n    /// Converts a [`Natural`] to a binary [`String`].\n    ///\n    /// Using the `#` format flag prepends `\"0b\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToBinaryString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.to_binary_string(), \"0\");\n    /// assert_eq!(Natural::from(123u32).to_binary_string(), \"1111011\");\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_binary_string(),\n    ///     \"1110100011010100101001010001000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:011b}\", Natural::from(123u32)), \"00001111011\");\n    ///\n    /// assert_eq!(format!(\"{:#b}\", Natural::ZERO), \"0b0\");\n    /// assert_eq!(format!(\"{:#b}\", Natural::from(123u32)), \"0b1111011\");\n    /// assert_eq!(\n    ///     format!(\"{:#b}\", Natural::from_str(\"1000000000000\").unwrap()),\n    ///     \"0b1110100011010100101001010001000000000000\"\n    /// );\n    /// assert_eq!(format!(\"{:#011b}\", Natural::from(123u32)), \"0b001111011\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match self {\n            Self(Small(x)) => Binary::fmt(x, f),\n            Self(Large(xs)) => {\n                let mut bits = vec![0; usize::exact_from(limbs_significant_bits(xs))];\n                let mut limbs = xs.iter();\n                let mut limb = *limbs.next().unwrap();\n                let mut remaining_bits = Limb::WIDTH;\n                for bit in bits.iter_mut().rev() {\n                    if remaining_bits == 0 {\n                        remaining_bits = Limb::WIDTH;\n                        limb = *limbs.next().unwrap();\n                    }\n                    *bit = if limb.even() { b'0' } else { b'1' };\n                    limb >>= 1;\n                    remaining_bits -= 1;\n                }\n                f.pad_integral(true, \"0b\", core::str::from_utf8(&bits).unwrap())\n            }\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\nimpl Octal for NaturalAlt {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if let Natural(Small(x)) = self.0 {\n            Octal::fmt(&x, f)\n        } else {\n            if f.alternate() {\n                f.write_str(\"0o\")?;\n            }\n            if let Some(width) = f.width() {\n                let mut len = usize::exact_from(self.0.significant_bits().div_round(3, Ceiling).0);\n                if f.alternate() {\n                    len += 2;\n                }\n                for _ in 0..width.saturating_sub(len) {\n                    f.write_char('0')?;\n                }\n            }\n            for digit in PowerOf2DigitIterable::<u8>::power_of_2_digits(&self.0, 3).rev() {\n                f.write_char(char::from(digit_to_display_byte_lower(digit).unwrap()))?;\n            }\n            Ok(())\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\n#[cfg(feature = \"32_bit_limbs\")]\nfn oz_fmt(f: &mut Formatter, x: Limb) -> Result {\n    write!(f, \"{x:08o}\")\n}\n#[cfg(feature = \"test_build\")]\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn oz_fmt(f: &mut Formatter, x: Limb) -> Result {\n    write!(f, \"{x:016o}\")\n}\n\n#[cfg(feature = \"test_build\")]\nimpl Octal for NaturalAlt2 {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match &self.0 {\n            Natural(Small(x)) => Octal::fmt(x, f),\n            Natural(Large(xs)) => {\n                if f.alternate() {\n                    f.write_str(\"0o\")?;\n                }\n                if let Some(width) = f.width() {\n                    let mut len =\n                        usize::exact_from(limbs_significant_bits(xs).div_round(3, Ceiling).0);\n                    if f.alternate() {\n                        len += 2;\n                    }\n                    for _ in 0..width.saturating_sub(len) {\n                        f.write_char('0')?;\n                    }\n                }\n                let mut triple_r = xs.len() % 3;\n                if triple_r == 0 {\n                    triple_r = 3;\n                }\n                let mut result;\n                let last_i = xs.len() - 1;\n                const W_1_2: u64 = Limb::WIDTH >> 1;\n                const W_1_4: u64 = Limb::WIDTH >> 2;\n                const W_3_4: u64 = W_1_4 * 3;\n                const MASK: Limb = (1 << W_3_4) - 1;\n                match triple_r {\n                    1 => {\n                        let x_2 = xs[last_i];\n                        let y = x_2 >> W_3_4;\n                        if y == 0 {\n                            result = write!(f, \"{:o}\", x_2 & MASK);\n                        } else {\n                            write!(f, \"{y:o}\").unwrap();\n                            result = oz_fmt(f, x_2 & MASK);\n                        }\n                    }\n                    2 => {\n                        let x_1 = xs[last_i];\n                        let x_2 = xs[last_i - 1];\n                        let y = x_1 >> W_1_2;\n                        if y == 0 {\n                            write!(f, \"{:o}\", ((x_1 << W_1_4) & MASK) | (x_2 >> W_3_4)).unwrap();\n                        } else {\n                            write!(f, \"{y:o}\").unwrap();\n                            oz_fmt(f, ((x_1 << W_1_4) & MASK) | (x_2 >> W_3_4)).unwrap();\n                        }\n                        result = oz_fmt(f, x_2 & MASK);\n                    }\n                    _ => {\n                        let x_0 = xs[last_i];\n                        let x_1 = xs[last_i - 1];\n                        let x_2 = xs[last_i - 2];\n                        let y = x_0 >> W_1_4;\n                        if y == 0 {\n                            write!(f, \"{:o}\", ((x_0 << W_1_2) & MASK) | (x_1 >> W_1_2)).unwrap();\n                        } else {\n                            write!(f, \"{y:o}\").unwrap();\n                            oz_fmt(f, ((x_0 << W_1_2) & MASK) | (x_1 >> W_1_2)).unwrap();\n                        }\n                        oz_fmt(f, ((x_1 << W_1_4) & MASK) | (x_2 >> W_3_4)).unwrap();\n                        result = oz_fmt(f, x_2 & MASK);\n                    }\n                }\n                for mut chunk in &xs.iter().rev().skip(triple_r).chunks(3) {\n                    let x_0 = chunk.next().unwrap();\n                    let x_1 = chunk.next().unwrap();\n                    let x_2 = chunk.next().unwrap();\n                    oz_fmt(f, x_0 >> W_1_4).unwrap();\n                    oz_fmt(f, ((x_0 << W_1_2) & MASK) | (x_1 >> W_1_2)).unwrap();\n                    oz_fmt(f, ((x_1 << W_1_4) & MASK) | (x_2 >> W_3_4)).unwrap();\n                    result = oz_fmt(f, x_2 & MASK);\n                }\n                result\n            }\n        }\n    }\n}\n\nimpl Octal for Natural {\n    /// Converts a [`Natural`] to an octal [`String`].\n    ///\n    /// Using the `#` format flag prepends `\"0o\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToOctalString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.to_octal_string(), \"0\");\n    /// assert_eq!(Natural::from(123u32).to_octal_string(), \"173\");\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_octal_string(),\n    ///     \"16432451210000\"\n    /// );\n    /// assert_eq!(format!(\"{:07o}\", Natural::from(123u32)), \"0000173\");\n    ///\n    /// assert_eq!(format!(\"{:#o}\", Natural::ZERO), \"0o0\");\n    /// assert_eq!(format!(\"{:#o}\", Natural::from(123u32)), \"0o173\");\n    /// assert_eq!(\n    ///     format!(\"{:#o}\", Natural::from_str(\"1000000000000\").unwrap()),\n    ///     \"0o16432451210000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07o}\", Natural::from(123u32)), \"0o00173\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match self {\n            Self(Small(x)) => Octal::fmt(x, f),\n            Self(Large(xs)) => {\n                let mut digits =\n                    vec![0; usize::exact_from(limbs_significant_bits(xs).div_round(3, Ceiling).0)];\n                let mut limbs = xs.iter();\n                let mut remaining_bits = Limb::WIDTH;\n                let mut limb = *limbs.next().unwrap();\n                for digit in digits.iter_mut().rev() {\n                    if remaining_bits >= 3 {\n                        *digit = digit_to_display_byte_lower(u8::wrapping_from(limb & 7)).unwrap();\n                        remaining_bits -= 3;\n                        limb >>= 3;\n                    } else {\n                        match remaining_bits {\n                            0 => {\n                                limb = *limbs.next().unwrap();\n                                *digit = digit_to_display_byte_lower(u8::wrapping_from(limb & 7))\n                                    .unwrap();\n                                remaining_bits = Limb::WIDTH - 3;\n                                limb >>= 3;\n                            }\n                            1 => {\n                                let previous_limb = limb;\n                                limb = *limbs.next().unwrap_or(&0);\n                                *digit = digit_to_display_byte_lower(u8::wrapping_from(\n                                    ((limb & 3) << 1) | previous_limb,\n                                ))\n                                .unwrap();\n                                remaining_bits = Limb::WIDTH - 2;\n                                limb >>= 2;\n                            }\n                            _ => {\n                                let previous_limb = limb;\n                                limb = *limbs.next().unwrap_or(&0);\n                                *digit = digit_to_display_byte_lower(u8::wrapping_from(\n                                    ((limb & 1) << 2) | previous_limb,\n                                ))\n                                .unwrap();\n                                remaining_bits = Limb::WIDTH - 1;\n                                limb >>= 1;\n                            }\n                        }\n                    }\n                }\n                f.pad_integral(true, \"0o\", core::str::from_utf8(&digits).unwrap())\n            }\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\nimpl LowerHex for NaturalAlt {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if let Natural(Small(x)) = self.0 {\n            LowerHex::fmt(&x, f)\n        } else {\n            if f.alternate() {\n                f.write_str(\"0x\")?;\n            }\n            if let Some(width) = f.width() {\n                let mut len = usize::exact_from(self.0.significant_bits().shr_round(2, Ceiling).0);\n                if f.alternate() {\n                    len += 2;\n                }\n                for _ in 0..width.saturating_sub(len) {\n                    f.write_char('0')?;\n                }\n            }\n            for digit in PowerOf2DigitIterable::<u8>::power_of_2_digits(&self.0, 4).rev() {\n                f.write_char(char::from(digit_to_display_byte_lower(digit).unwrap()))?;\n            }\n            Ok(())\n        }\n    }\n}\n\n#[cfg(feature = \"test_build\")]\nimpl LowerHex for NaturalAlt2 {\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match &self.0 {\n            Natural(Small(x)) => LowerHex::fmt(x, f),\n            Natural(Large(xs)) => {\n                let (xs_last, xs_init) = xs.split_last().unwrap();\n                let width = if let Some(width) = f.width() {\n                    width.saturating_sub(xs_init.len() << Limb::LOG_WIDTH >> 2)\n                } else {\n                    0\n                };\n                let mut result = if f.alternate() {\n                    write!(f, \"{xs_last:#0width$x}\")\n                } else {\n                    write!(f, \"{xs_last:0width$x}\")\n                };\n                for x in xs_init.iter().rev() {\n                    #[cfg(feature = \"32_bit_limbs\")]\n                    {\n                        result = write!(f, \"{x:08x}\");\n                    }\n                    #[cfg(not(feature = \"32_bit_limbs\"))]\n                    {\n                        result = write!(f, \"{x:016x}\");\n                    }\n                }\n                result\n            }\n        }\n    }\n}\n\nimpl LowerHex for Natural {\n    /// Converts a [`Natural`] to a hexadecimal [`String`] using lowercase characters.\n    ///\n    /// Using the `#` format flag prepends `\"0x\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToLowerHexString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.to_lower_hex_string(), \"0\");\n    /// assert_eq!(Natural::from(123u32).to_lower_hex_string(), \"7b\");\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_lower_hex_string(),\n    ///     \"e8d4a51000\"\n    /// );\n    /// assert_eq!(format!(\"{:07x}\", Natural::from(123u32)), \"000007b\");\n    ///\n    /// assert_eq!(format!(\"{:#x}\", Natural::ZERO), \"0x0\");\n    /// assert_eq!(format!(\"{:#x}\", Natural::from(123u32)), \"0x7b\");\n    /// assert_eq!(\n    ///     format!(\"{:#x}\", Natural::from_str(\"1000000000000\").unwrap()),\n    ///     \"0xe8d4a51000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07x}\", Natural::from(123u32)), \"0x0007b\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match self {\n            Self(Small(x)) => LowerHex::fmt(x, f),\n            Self(Large(xs)) => {\n                const DIGITS_PER_LIMB: u64 = Limb::WIDTH >> 2;\n                let mut digits =\n                    vec![0; usize::exact_from(limbs_significant_bits(xs).shr_round(2, Ceiling).0)];\n                let mut limbs = xs.iter();\n                let mut limb = *limbs.next().unwrap();\n                let mut remaining_digits = DIGITS_PER_LIMB;\n                for digit in digits.iter_mut().rev() {\n                    if remaining_digits == 0 {\n                        remaining_digits = DIGITS_PER_LIMB;\n                        limb = *limbs.next().unwrap();\n                    }\n                    *digit = digit_to_display_byte_lower(u8::wrapping_from(limb & 15)).unwrap();\n                    limb >>= 4;\n                    remaining_digits -= 1;\n                }\n                f.pad_integral(true, \"0x\", core::str::from_utf8(&digits).unwrap())\n            }\n        }\n    }\n}\n\nimpl UpperHex for Natural {\n    /// Converts a [`Natural`] to a hexadecimal [`String`] using uppercase characters.\n    ///\n    /// Using the `#` format flag prepends `\"0x\"` to the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::str::FromStr;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToUpperHexString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.to_upper_hex_string(), \"0\");\n    /// assert_eq!(Natural::from(123u32).to_upper_hex_string(), \"7B\");\n    /// assert_eq!(\n    ///     Natural::from_str(\"1000000000000\")\n    ///         .unwrap()\n    ///         .to_upper_hex_string(),\n    ///     \"E8D4A51000\"\n    /// );\n    /// assert_eq!(format!(\"{:07X}\", Natural::from(123u32)), \"000007B\");\n    ///\n    /// assert_eq!(format!(\"{:#X}\", Natural::ZERO), \"0x0\");\n    /// assert_eq!(format!(\"{:#X}\", Natural::from(123u32)), \"0x7B\");\n    /// assert_eq!(\n    ///     format!(\"{:#X}\", Natural::from_str(\"1000000000000\").unwrap()),\n    ///     \"0xE8D4A51000\"\n    /// );\n    /// assert_eq!(format!(\"{:#07X}\", Natural::from(123u32)), \"0x0007B\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        match self {\n            Self(Small(x)) => UpperHex::fmt(x, f),\n            Self(Large(xs)) => {\n                const DIGITS_PER_LIMB: u64 = Limb::WIDTH >> 2;\n                let mut digits =\n                    vec![0; usize::exact_from(limbs_significant_bits(xs).shr_round(2, Ceiling).0)];\n                let mut limbs = xs.iter();\n                let mut limb = *limbs.next().unwrap();\n                let mut remaining_digits = DIGITS_PER_LIMB;\n                for digit in digits.iter_mut().rev() {\n                    if remaining_digits == 0 {\n                        remaining_digits = DIGITS_PER_LIMB;\n                        limb = *limbs.next().unwrap();\n                    }\n                    *digit = digit_to_display_byte_upper(u8::wrapping_from(limb & 15)).unwrap();\n                    limb >>= 4;\n                    remaining_digits -= 1;\n                }\n                f.pad_integral(true, \"0x\", core::str::from_utf8(&digits).unwrap())\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/conversion/to_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::ops::Index;\nuse core::slice;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\n/// A double-ended iterator over the [limbs](crate#limbs) of a [`Natural`].\n///\n/// The forward order is ascending (least-significant first). The iterator does not iterate over any\n/// implicit leading zero limbs.\n///\n/// This struct also supports retrieving limbs by index. This functionality is completely\n/// independent of the iterator's state. Indexing the implicit leading zero limbs is allowed.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct LimbIterator<'a> {\n    pub(crate) n: &'a Natural,\n    pub(crate) limb_count: usize,\n    pub(crate) remaining: usize,\n    // If `n` is nonzero, this index initially points to the least-significant limb, and is\n    // incremented by next().\n    pub(crate) i: u64,\n    // If `n` is nonzero, this index initially points to the most-significant limb, and is\n    // decremented by next_back().\n    pub(crate) j: u64,\n}\n\nimpl Iterator for LimbIterator<'_> {\n    type Item = Limb;\n\n    /// A function to iterate through the [limbs](crate#limbs) of a [`Natural`] in ascending order\n    /// (least-significant first).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::ZERO.limbs().next(), None);\n    ///\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     let trillion = Natural::from(10u32).pow(12);\n    ///     let mut limbs = trillion.limbs();\n    ///     assert_eq!(limbs.next(), Some(3567587328));\n    ///     assert_eq!(limbs.next(), Some(232));\n    ///     assert_eq!(limbs.next(), None);\n    /// }\n    /// ```\n    fn next(&mut self) -> Option<Limb> {\n        if self.remaining != 0 {\n            let limb = match self.n {\n                Natural(Small(small)) => *small,\n                Natural(Large(limbs)) => limbs[usize::exact_from(self.i)],\n            };\n            if self.i != self.j {\n                self.i += 1;\n            }\n            self.remaining -= 1;\n            Some(limb)\n        } else {\n            None\n        }\n    }\n\n    #[inline]\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl DoubleEndedIterator for LimbIterator<'_> {\n    /// A function to iterate through the [limbs](crate#limbs) of a [`Natural`] in descending order\n    /// (most-significant first).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::ZERO.limbs().next_back(), None);\n    ///\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     let trillion = Natural::from(10u32).pow(12);\n    ///     let mut limbs = trillion.limbs();\n    ///     assert_eq!(limbs.next_back(), Some(232));\n    ///     assert_eq!(limbs.next_back(), Some(3567587328));\n    ///     assert_eq!(limbs.next_back(), None);\n    /// }\n    /// ```\n    fn next_back(&mut self) -> Option<Limb> {\n        if self.remaining != 0 {\n            let limb = match self.n {\n                Natural(Small(small)) => *small,\n                Natural(Large(limbs)) => limbs[usize::exact_from(self.j)],\n            };\n            if self.j != self.i {\n                self.j -= 1;\n            }\n            self.remaining -= 1;\n            Some(limb)\n        } else {\n            None\n        }\n    }\n}\n\nimpl ExactSizeIterator for LimbIterator<'_> {}\n\nimpl Index<usize> for LimbIterator<'_> {\n    type Output = Limb;\n\n    /// A function to retrieve a [`Natural`]'s [limbs](crate#limbs) by index.\n    ///\n    /// The index is the power of $2^W$ of which the limbs is a coefficient, where $W$ is the width\n    /// of a limb. Indexing at or above the limb count returns zeros.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert_eq!(Natural::ZERO.limbs()[0], 0);\n    ///\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     let trillion = Natural::from(10u32).pow(12);\n    ///     let limbs = trillion.limbs();\n    ///     assert_eq!(limbs[0], 3567587328);\n    ///     assert_eq!(limbs[1], 232);\n    ///     assert_eq!(limbs[2], 0);\n    ///     assert_eq!(limbs[100], 0);\n    /// }\n    /// ```\n    fn index(&self, index: usize) -> &Limb {\n        if index >= self.limb_count {\n            &0\n        } else {\n            match self.n {\n                Natural(Small(small)) => small,\n                Natural(Large(limbs)) => limbs.index(index),\n            }\n        }\n    }\n}\n\nimpl LimbIterator<'_> {\n    // TODO document and test\n    #[allow(clippy::missing_const_for_fn)]\n    pub fn most_significant(&self) -> Option<Limb> {\n        match self.n {\n            Natural(Small(0)) => None,\n            Natural(Small(small)) => Some(*small),\n            Natural(Large(limbs)) => limbs.last().copied(),\n        }\n    }\n}\n\nimpl Natural {\n    /// Returns the [limbs](crate#limbs) of a [`Natural`], in ascending order, so that\n    /// less-significant limbs have lower indices in the output vector.\n    ///\n    /// There are no trailing zero limbs.\n    ///\n    /// This function borrows the [`Natural`]. If taking ownership is possible instead,\n    /// [`into_limbs_asc`](Self::into_limbs_asc) is more efficient.\n    ///\n    /// This function is more efficient than [`to_limbs_desc`](Self::to_limbs_desc).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Natural::ZERO.to_limbs_asc().is_empty());\n    ///     assert_eq!(Natural::from(123u32).to_limbs_asc(), &[123]);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from(10u32).pow(12).to_limbs_asc(),\n    ///         &[3567587328, 232]\n    ///     );\n    /// }\n    /// ```\n    pub fn to_limbs_asc(&self) -> Vec<Limb> {\n        match self {\n            &Self::ZERO => Vec::new(),\n            Self(Small(small)) => vec![*small],\n            Self(Large(limbs)) => limbs.clone(),\n        }\n    }\n\n    /// Returns the [limbs](crate#limbs) of a [`Natural`] in descending order, so that\n    /// less-significant limbs have higher indices in the output vector.\n    ///\n    /// There are no leading zero limbs.\n    ///\n    /// This function borrows the [`Natural`]. If taking ownership is possible instead,\n    /// [`into_limbs_desc`](Self::into_limbs_desc) is more efficient.\n    ///\n    /// This function is less efficient than [`to_limbs_asc`](Self::to_limbs_asc).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Natural::ZERO.to_limbs_desc().is_empty());\n    ///     assert_eq!(Natural::from(123u32).to_limbs_desc(), &[123]);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from(10u32).pow(12).to_limbs_desc(),\n    ///         &[232, 3567587328]\n    ///     );\n    /// }\n    /// ```\n    pub fn to_limbs_desc(&self) -> Vec<Limb> {\n        match self {\n            &Self::ZERO => Vec::new(),\n            Self(Small(small)) => vec![*small],\n            Self(Large(limbs)) => limbs.iter().copied().rev().collect(),\n        }\n    }\n\n    /// Returns the [limbs](crate#limbs) of a [`Natural`], in ascending order, so that\n    /// less-significant limbs have lower indices in the output vector.\n    ///\n    /// There are no trailing zero limbs.\n    ///\n    /// This function takes ownership of the [`Natural`]. If it's necessary to borrow instead, use\n    /// [`to_limbs_asc`](Self::to_limbs_asc).\n    ///\n    /// This function is more efficient than [`into_limbs_desc`](Self::into_limbs_desc).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Natural::ZERO.into_limbs_asc().is_empty());\n    ///     assert_eq!(Natural::from(123u32).into_limbs_asc(), &[123]);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from(10u32).pow(12).into_limbs_asc(),\n    ///         &[3567587328, 232]\n    ///     );\n    /// }\n    /// ```\n    pub fn into_limbs_asc(self) -> Vec<Limb> {\n        match self {\n            Self::ZERO => Vec::new(),\n            Self(Small(small)) => vec![small],\n            Self(Large(limbs)) => limbs,\n        }\n    }\n\n    /// Returns the [limbs](crate#limbs) of a [`Natural`], in descending order, so that\n    /// less-significant limbs have higher indices in the output vector.\n    ///\n    /// There are no leading zero limbs.\n    ///\n    /// This function takes ownership of the [`Natural`]. If it's necessary to borrow instead, use\n    /// [`to_limbs_desc`](Self::to_limbs_desc).\n    ///\n    /// This function is less efficient than [`into_limbs_asc`](Self::into_limbs_asc).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Natural::ZERO.into_limbs_desc().is_empty());\n    ///     assert_eq!(Natural::from(123u32).into_limbs_desc(), &[123]);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from(10u32).pow(12).into_limbs_desc(),\n    ///         &[232, 3567587328]\n    ///     );\n    /// }\n    /// ```\n    pub fn into_limbs_desc(self) -> Vec<Limb> {\n        match self {\n            Self::ZERO => Vec::new(),\n            Self(Small(small)) => vec![small],\n            Self(Large(mut limbs)) => {\n                limbs.reverse();\n                limbs\n            }\n        }\n    }\n\n    /// Returns the [limbs](crate#limbs) of a [`Natural`], in ascending order, so that\n    /// less-significant limbs have lower indices in the output slice.\n    ///\n    /// There are no trailing zero limbs.\n    ///\n    /// This function borrows the [`Natural`]. There is no descending order counterpoint, but\n    /// [`to_limbs_desc`](Self::to_limbs_desc) may be used instead.\n    ///\n    /// This function is more efficient than [`to_limbs_asc`](Self::to_limbs_asc) because it borrows\n    /// the underlying memory directly.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Natural::ZERO.as_limbs_asc().is_empty());\n    ///     assert_eq!(Natural::from(123u32).as_limbs_asc(), &[123]);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from(10u32).pow(12).as_limbs_asc(),\n    ///         &[3567587328, 232]\n    ///     );\n    /// }\n    /// ```\n    pub fn as_limbs_asc(&self) -> &[Limb] {\n        match self {\n            Self(Small(0)) => &[],\n            Self(Small(small)) => slice::from_ref(small),\n            Self(Large(limbs)) => limbs,\n        }\n    }\n\n    /// Returns a double-ended iterator over the [limbs](crate#limbs) of a [`Natural`].\n    ///\n    /// The forward order is ascending, so that less-significant limbs appear first. There are no\n    /// trailing zero limbs going forward, or leading zeros going backward.\n    ///\n    /// If it's necessary to get a [`Vec`] of all the limbs, consider using\n    /// [`to_limbs_asc`](Self::to_limbs_asc), [`to_limbs_desc`](Self::to_limbs_desc),\n    /// [`into_limbs_asc`](Self::into_limbs_asc), or [`into_limbs_desc`](Self::into_limbs_desc)\n    /// instead.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::integers::PrimitiveInt;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_nz::platform::Limb;\n    ///\n    /// if Limb::WIDTH == u32::WIDTH {\n    ///     assert!(Natural::ZERO.limbs().next().is_none());\n    ///     assert_eq!(Natural::from(123u32).limbs().collect_vec(), &[123]);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from(10u32).pow(12).limbs().collect_vec(),\n    ///         &[3567587328, 232]\n    ///     );\n    ///\n    ///     assert!(Natural::ZERO.limbs().next_back().is_none());\n    ///     assert_eq!(Natural::from(123u32).limbs().rev().collect_vec(), &[123]);\n    ///     // 10^12 = 232 * 2^32 + 3567587328\n    ///     assert_eq!(\n    ///         Natural::from(10u32).pow(12).limbs().rev().collect_vec(),\n    ///         &[232, 3567587328]\n    ///     );\n    /// }\n    /// ```\n    pub fn limbs(&self) -> LimbIterator<'_> {\n        let limb_count = self.limb_count();\n        let limb_count_usize = usize::exact_from(limb_count);\n        LimbIterator {\n            n: self,\n            limb_count: limb_count_usize,\n            remaining: limb_count_usize,\n            i: 0,\n            j: limb_count.saturating_sub(1),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::basic::traits::{One, Zero};\n\n/// Generates all [`Natural`]s in a finite interval.\n///\n/// This `struct` is created by [`exhaustive_natural_range`] and\n/// [`exhaustive_natural_inclusive_range`]; see their documentation for more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct ExhaustiveNaturalRange {\n    a: Natural,\n    b: Natural,\n}\n\nimpl Iterator for ExhaustiveNaturalRange {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.a == self.b {\n            None\n        } else {\n            let result = self.a.clone();\n            self.a += Natural::ONE;\n            Some(result)\n        }\n    }\n}\n\nimpl DoubleEndedIterator for ExhaustiveNaturalRange {\n    fn next_back(&mut self) -> Option<Natural> {\n        if self.a == self.b {\n            None\n        } else {\n            self.b -= Natural::ONE;\n            Some(self.b.clone())\n        }\n    }\n}\n\n/// Generates all [`Natural`]s greater than or equal to some [`Natural`], in ascending order.\n///\n/// This `struct` is created by [`exhaustive_natural_range_to_infinity`]; see its documentation for\n/// more.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct ExhaustiveNaturalRangeToInfinity {\n    a: Natural,\n}\n\nimpl Iterator for ExhaustiveNaturalRangeToInfinity {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        let result = self.a.clone();\n        self.a += Natural::ONE;\n        Some(result)\n    }\n}\n\n/// Generates all [`Natural`]s in ascending order.\n///\n/// The output is $(k)_{k=0}^{\\infty}$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the least-significant limb of the previously-generated value is\n/// `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::natural::exhaustive::exhaustive_naturals;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_naturals(), 10),\n///     \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]\"\n/// );\n/// ```\n#[inline]\npub const fn exhaustive_naturals() -> ExhaustiveNaturalRangeToInfinity {\n    exhaustive_natural_range_to_infinity(Natural::ZERO)\n}\n\n/// Generates all positive [`Natural`]s in ascending order.\n///\n/// The output is $(k)_{k=1}^{\\infty}$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the least-significant limb of the previously-generated value is\n/// `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::natural::exhaustive::exhaustive_positive_naturals;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_positive_naturals(), 10),\n///     \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn exhaustive_positive_naturals() -> ExhaustiveNaturalRangeToInfinity {\n    exhaustive_natural_range_to_infinity(Natural::ONE)\n}\n\n/// Generates all [`Natural`]s in the half-open interval $[a, b)$, in ascending order.\n///\n/// `a` must be less than or equal to `b`. If `a` and `b` are equal, the range is empty. To generate\n/// all [`Natural`]s in an infinite interval, use [`exhaustive_natural_range_to_infinity`].\n///\n/// The output is $(k)_{k=a}^{b-1}$.\n///\n/// The output length is $b - a$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the least-significant limb of the previously-generated value is\n/// `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::exhaustive::exhaustive_natural_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     exhaustive_natural_range(Natural::from(5u32), Natural::from(10u32))\n///         .collect_vec()\n///         .to_debug_string(),\n///     \"[5, 6, 7, 8, 9]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_natural_range(a: Natural, b: Natural) -> ExhaustiveNaturalRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    ExhaustiveNaturalRange { a, b }\n}\n\n/// Generates all [`Natural`]s in the closed interval $[a, b]$, in ascending order.\n///\n/// `a` must be less than or equal to `b`. If `a` and `b` are equal, the range contains a single\n/// element. To generate all [`Natural`]s in an infinite interval, use\n/// [`exhaustive_natural_range_to_infinity`].\n///\n/// The output is $(k)_{k=a}^{b}$.\n///\n/// The output length is $b - a + 1$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the least-significant limb of the previously-generated value is\n/// `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Panics\n/// Panics if $a>b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::exhaustive::exhaustive_natural_inclusive_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     exhaustive_natural_inclusive_range(Natural::from(5u32), Natural::from(10u32))\n///         .collect_vec()\n///         .to_debug_string(),\n///     \"[5, 6, 7, 8, 9, 10]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_natural_inclusive_range(a: Natural, b: Natural) -> ExhaustiveNaturalRange {\n    assert!(a <= b, \"a must be less than or equal to b. a: {a}, b: {b}\");\n    ExhaustiveNaturalRange {\n        a,\n        b: b + Natural::ONE,\n    }\n}\n\n/// Generates all [`Natural`]s greater than or equal to some number $a$, in ascending order.\n///\n/// The output is $(k)_{k=a}^{\\infty}$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(i)$\n///\n/// $M(i) = O(i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// Although the time and space complexities are worst-case linear, the worst case is very rare. If\n/// we exclude the cases where the least-significant limb of the previously-generated value is\n/// `Limb::MAX`, the worst case space and time complexities are constant.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::natural::exhaustive::exhaustive_natural_range_to_infinity;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_natural_range_to_infinity(Natural::from(5u32)),\n///         10\n///     ),\n///     \"[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn exhaustive_natural_range_to_infinity(a: Natural) -> ExhaustiveNaturalRangeToInfinity {\n    ExhaustiveNaturalRangeToInfinity { a }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/factorization/is_power.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// Uses code adopted from the FLINT Library.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{CheckedRoot, DivAssignMod, DivMod, GcdAssign};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::factorization::traits::{\n    ExpressAsPower, Factor, IsPower, IsPrime, Primes,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\n\nconst PRIMES: [u32; 168] = [\n    2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,\n    101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,\n    197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307,\n    311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421,\n    431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547,\n    557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659,\n    661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797,\n    809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929,\n    937, 941, 947, 953, 967, 971, 977, 983, 991, 997,\n];\n\n// Find ONE perfect power representation for a Natural (not necessarily the smallest base).\n//\n// This function does NOT recurse - it just checks if n can be expressed as some base^exp.\nfn get_perfect_power_natural(n: &Natural) -> Option<(Natural, u64)> {\n    // Find largest power of 2 dividing n\n    let mut pow_2 = n.trailing_zeros().unwrap();\n    // Two divides exactly once - not a perfect power\n    if pow_2 == 1 {\n        return None;\n    }\n    // If pow_2 is prime, just check if n is a perfect pow_2-th power\n    if pow_2.is_prime() {\n        return n.checked_root(pow_2).map(|root| (root, pow_2));\n    }\n    // Divide out 2^pow_2 to get the odd part\n    let mut q = n >> pow_2;\n    // Factor out powers of small primes\n    for &prime in PRIMES.iter().skip(1) {\n        let prime = Natural::from(prime);\n        let (new_q, r) = (&q).div_mod(&prime);\n        if r == 0u32 {\n            q = new_q;\n            if q.div_assign_mod(&prime) != 0u32 {\n                return None; // prime divides exactly once, reject\n            }\n            let mut pow_p = 2u64;\n            loop {\n                let (new_q, r) = (&q).div_mod(&prime);\n                if r == 0 {\n                    q = new_q;\n                    pow_p += 1;\n                } else {\n                    break;\n                }\n            }\n            pow_2.gcd_assign(pow_p);\n            if pow_2 == 1 {\n                return None; // we have multiplicity 1 of some factor\n            }\n            // As soon as pow_2 becomes prime, stop factoring\n            if q == 1u32 || pow_2.is_prime() {\n                return n.checked_root(pow_2).map(|root| (root, pow_2));\n            }\n        }\n    }\n    // After factoring, check remaining cases\n    if pow_2 == 0 {\n        // No factors found above; exhaustively check all prime exponents\n        let bits = n.significant_bits();\n        for nth in u64::primes() {\n            // Terminate if exponent exceeds bit length (n ^ (1 / nth) < 2 for nth > bits)\n            if nth > bits {\n                return None;\n            }\n            if let Some(root) = n.checked_root(nth) {\n                return Some((root, nth));\n            }\n        }\n    } else {\n        // Found some factors; only check prime divisors of pow_2\n        for (nth, _) in pow_2.factor() {\n            if let Some(root) = n.checked_root(nth) {\n                return Some((root, nth));\n            }\n        }\n    }\n    None\n}\n\n// Boolean check: is n a perfect power?\n//\n// Note: This function computes roots the same number of times as get_perfect_power_natural, but\n// discards the root values, only returning whether a perfect power representation exists.\n//\n// Left here in case we can find a way to optimize out root computations later.\nfn get_perfect_power_natural_bool(n: &Natural) -> bool {\n    // Find largest power of 2 dividing n\n    let mut pow_2 = n.trailing_zeros().unwrap();\n    // Two divides exactly once - not a perfect power\n    if pow_2 == 1 {\n        return false;\n    }\n    // If pow_2 is prime, check if n is a perfect pow_2-th power\n    if pow_2.is_prime() {\n        return n.checked_root(pow_2).is_some();\n    }\n    // Divide out 2^pow_2 to get the odd part\n    let mut q = n >> pow_2;\n    // Factor out powers of small primes\n    for &prime in PRIMES.iter().skip(1) {\n        let prime = Natural::from(prime);\n        let (new_q, r) = (&q).div_mod(&prime);\n        if r == 0 {\n            q = new_q;\n            if q.div_assign_mod(&prime) != 0u32 {\n                return false; // prime divides exactly once, reject\n            }\n            let mut pow_p = 2u64;\n            loop {\n                let (new_q, r) = (&q).div_mod(&prime);\n                if r == 0 {\n                    q = new_q;\n                    pow_p += 1;\n                } else {\n                    break;\n                }\n            }\n            pow_2.gcd_assign(pow_p);\n            if pow_2 == 1 {\n                return false; // we have multiplicity 1 of some factor\n            }\n            // As soon as pow_2 becomes prime, stop factoring\n            if q == Natural::ONE || pow_2.is_prime() {\n                return n.checked_root(pow_2).is_some();\n            }\n        }\n    }\n    // After factoring, check remaining cases\n    if pow_2 == 0 {\n        // No factors found above; exhaustively check all prime exponents\n        let bits = n.significant_bits();\n        for nth in u64::primes() {\n            // Terminate if exponent exceeds bit length (n ^ (1 / nth) < 2 for nth > bits)\n            if nth > bits {\n                return false;\n            }\n            if n.checked_root(nth).is_some() {\n                return true;\n            }\n        }\n    } else {\n        // Found some factors; only check prime divisors of pow_2\n        for (nth, _) in pow_2.factor() {\n            if n.checked_root(nth).is_some() {\n                return true;\n            }\n        }\n    }\n    false\n}\n\n// Express Natural as a power with the smallest possible base\n//\n// Note: This function is only called for multi-limb numbers (Large variant).\nfn express_as_power_natural(n: &Natural) -> Option<(Natural, u64)> {\n    // Get initial representation\n    let (mut base, mut exp) = get_perfect_power_natural(n)?;\n    // Continue until we have the smallest possible base\n    while base > 3u32 {\n        match get_perfect_power_natural(&base) {\n            Some((base2, exp2)) => {\n                base = base2;\n                exp *= exp2;\n            }\n            None => break,\n        }\n    }\n    Some((base, exp))\n}\n\n// Is Natural a perfect power?\n//\n// Note: This function is only called for multi-limb numbers\n#[inline]\nfn is_power_natural(n: &Natural) -> bool {\n    get_perfect_power_natural_bool(n)\n}\n\nimpl ExpressAsPower for Natural {\n    /// Expresses a [`Natural`] as a perfect power if possible.\n    ///\n    /// Returns `Some((root, exponent))` where `root ^ exponent = self` and `exponent > 1`, or\n    /// `None` if the number cannot be expressed as a perfect power.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::ExpressAsPower;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(8u32).express_as_power(),\n    ///     Some((Natural::from(2u32), 3))\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(16u32).express_as_power(),\n    ///     Some((Natural::from(2u32), 4))\n    /// );\n    /// assert_eq!(Natural::from(6u32).express_as_power(), None);\n    /// ```\n    fn express_as_power(&self) -> Option<(Self, u64)> {\n        match self {\n            // use the single-limb express_as_power impl for primitive integers\n            Self(Small(small)) => small\n                .express_as_power()\n                .map(|(root, exp)| (Self::from(root), exp)),\n            Self(Large(_)) => express_as_power_natural(self),\n        }\n    }\n}\n\nimpl IsPower for Natural {\n    /// Determines whether a [`Natural`] is a perfect power.\n    ///\n    /// A perfect power is any number of the form $a^x$ where $x > 1$, with $a$ and $x$ both\n    /// integers. In particular, 0 and 1 are considered perfect powers.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::IsPower;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(0u32).is_power(), true);\n    /// assert_eq!(Natural::from(1u32).is_power(), true);\n    /// assert_eq!(Natural::from(4u32).is_power(), true);\n    /// assert_eq!(Natural::from(6u32).is_power(), false);\n    /// assert_eq!(Natural::from(8u32).is_power(), true);\n    /// ```\n    fn is_power(&self) -> bool {\n        match self {\n            // use the single-limb is_power impl for primitive integers\n            Self(Small(small)) => small.is_power(),\n            Self(Large(_)) => is_power_natural(self),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/factorization/is_square.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// Uses code adopted from the GMP Library.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::sqrt::limbs_checked_sqrt;\nuse crate::platform::Limb;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::factorization::traits::IsSquare;\n\nconst MOD34_BITS: Limb = ((Limb::WIDTH as Limb) / 4) * 3;\nconst MOD34_MASK: Limb = (1 << MOD34_BITS) - 1;\n\n// This is PERFSQR_MOD_BITS from mpn/perfsqr.h, GMP 6.3.0. Either 49 on 64 bit limb or 25 on 32 bit\n// limb. 2^48-1 = 3^2 * 5 * 7 * 13 * 17 * 97 ... 2^24-1 = 3^2 * 5 * 7 * 13 * 17 ...\nconst SQR_MOD_BITS: Limb = MOD34_BITS + 1;\nconst SQR_MOD_MASK: Limb = (1 << SQR_MOD_BITS) - 1;\n\n// From mpn/generic/mod_34lsub1.c\nconst B1: Limb = (Limb::WIDTH as Limb) / 4;\nconst B2: Limb = B1 * 2;\nconst B3: Limb = B1 * 3;\n\nconst M1: Limb = (1 << B1) - 1;\nconst M2: Limb = (1 << B2) - 1;\nconst M3: Limb = (1 << B3) - 1;\n\nconst fn low0(n: Limb) -> Limb {\n    n & M3\n}\nconst fn high0(n: Limb) -> Limb {\n    n >> B3\n}\n\nconst fn low1(n: Limb) -> Limb {\n    (n & M2) << B1\n}\nconst fn high1(n: Limb) -> Limb {\n    n >> B2\n}\n\nconst fn low2(n: Limb) -> Limb {\n    (n & M1) << B2\n}\nconst fn high2(n: Limb) -> Limb {\n    n >> B1\n}\n\nconst fn parts0(n: Limb) -> Limb {\n    low0(n) + high0(n)\n}\nconst fn parts1(n: Limb) -> Limb {\n    low1(n) + high1(n)\n}\nconst fn parts2(n: Limb) -> Limb {\n    low2(n) + high2(n)\n}\n\n// This is mpn_mod_34lsub1 from mpn/generic/mod_34lsub1.c, GMP 6.3.0.\n//\n// Calculate a remainder from `limbs` divided by 2^(Limb::WIDTH*3/4)-1. The remainder is not fully\n// reduced, it's any limb value congruent to `limbs` modulo that divisor.\n//\n// Check gen-psqr.c. mpn_mod_34lsub1 preferred over mpn_mod_1 (plus a PERFSQR_PP modulus) with 32\n// and 64 bit limb.\npub(crate) fn mod_34lsub1(limbs: &[Limb]) -> Limb {\n    // Process in chunks of 3, chunks lets us cleanly handle remainder\n    let (sums, carries) = limbs.chunks(3).fold(\n        ([Limb::ZERO; 3], [Limb::ZERO; 3]),\n        |(mut sums, mut carries), chunk| {\n            for (i, &limb) in chunk.iter().enumerate() {\n                let (sum, overflow) = sums[i].overflowing_add(limb);\n                sums[i] = sum;\n                if overflow {\n                    carries[i] += 1;\n                }\n            }\n            (sums, carries)\n        },\n    );\n    parts0(sums[0])\n        + parts1(sums[1])\n        + parts2(sums[2])\n        + parts1(carries[0])\n        + parts2(carries[1])\n        + parts0(carries[2])\n}\n\n// reduce mod 2^(WIDTH*3/4) - 1 and ensure result is in [0, modulus)\nfn perfsqr_mod_34(limbs: &[Limb]) -> Limb {\n    let r = mod_34lsub1(limbs);\n    (r & MOD34_MASK) + (r >> MOD34_BITS)\n}\n\nconst fn perfsqr_mod_idx(r: Limb, d: Limb, inv: Limb) -> Limb {\n    assert!(r <= SQR_MOD_MASK);\n    assert!(inv.wrapping_mul(d) & SQR_MOD_MASK == 1);\n    assert!(Limb::MAX / d >= SQR_MOD_MASK);\n    let q = r.wrapping_mul(inv) & SQR_MOD_MASK;\n    assert!(r == (q.wrapping_mul(d) & SQR_MOD_MASK));\n    q.wrapping_mul(d) >> SQR_MOD_BITS\n}\n\n// Single limb. Check precomputed bitmasks to see if remainder is a quadratic residue\nfn perfsqr_mod_1(r: Limb, d: Limb, inv: Limb, mask: Limb) -> bool {\n    //   CNST_LIMB(0x202021202020213),\n    assert!(d <= Limb::WIDTH as Limb);\n    let idx = perfsqr_mod_idx(r, d, inv);\n    if (mask >> idx) & 1 == 0 {\n        // non-square\n        return false;\n    }\n    true\n}\n\n// Double limb. Check precomputed bitmasks to see if remainder is a quadratic residue\nfn perfsqr_mod_2(r: Limb, d: Limb, inv: Limb, mhi: Limb, mlo: Limb) -> bool {\n    assert!(d <= 2 * Limb::WIDTH as Limb);\n    let mut idx = perfsqr_mod_idx(r, d, inv);\n    let m = if idx < Limb::WIDTH as Limb { mlo } else { mhi };\n    idx %= Limb::WIDTH as Limb;\n    if (m >> idx) & 1 == 0 {\n        // non-square\n        return false;\n    }\n    true\n}\n\n// This test identifies 97.81% as non-squares. Grand total sq_res_0x100 and PERFSQR_MOD_TEST, 99.62%\n// non-squares.\n#[cfg(not(feature = \"32_bit_limbs\"))]\nfn perfsqr_mod_test(limbs: &[Limb]) -> bool {\n    let r = perfsqr_mod_34(limbs);\n\n    perfsqr_mod_2(r, 91, 0xfd2fd2fd2fd3, 0x2191240, 0x8850a206953820e1) // 69.23%\n        && perfsqr_mod_2(r, 85, 0xfcfcfcfcfcfd, 0x82158, 0x10b48c4b4206a105) // 68.24%\n        && perfsqr_mod_1(r, 9, 0xe38e38e38e39, 0x93)  // 55.56%\n        && perfsqr_mod_2(r, 97, 0xfd5c5f02a3a1, 0x1eb628b47, 0x6067981b8b451b5f) // 49.48%\n}\n\n// This test identifies 95.66% as non-squares. Grand total sq_res_0x100 and PERFSQR_MOD_TEST, 99.25%\n// non-squares.\n#[cfg(feature = \"32_bit_limbs\")]\nfn perfsqr_mod_test(limbs: &[Limb]) -> bool {\n    let r = perfsqr_mod_34(limbs);\n\n    perfsqr_mod_2(r, 45, 0xfa4fa5, 0x920, 0x1a442481) // 73.33%\n        && perfsqr_mod_1(r, 17, 0xf0f0f1, 0x1a317) // 47.06 %\n        && perfsqr_mod_1(r, 13, 0xec4ec5, 0x9e5) // 46.15 %\n        && perfsqr_mod_1(r, 7, 0xdb6db7, 0x69) // 42.86 %\n}\n\n// This is sq_res0x100 from mpn/perfsqr.h when generated for 64 bit limb, GMP 6.3.0. Non-zero bit\n// indicates a quadratic residue mod 0x100. This test identifies 82.81% as non-squares (212/256).\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst SQR_MOD256: [u64; 4] =\n    [0x202021202030213, 0x202021202020213, 0x202021202030212, 0x202021202020212];\n\n// This is sq_res0x100 from mpn/perfsqr.h when generated for 32 bit limb, GMP 6.3.0. Non-zero bit\n// indicates a quadratic residue mod 0x100. This test identifies 82.81% as non-squares (212/256).\n#[cfg(feature = \"32_bit_limbs\")]\nconst SQR_MOD256: [u32; 8] =\n    [0x2030213, 0x2020212, 0x2020213, 0x2020212, 0x2030212, 0x2020212, 0x2020212, 0x2020212];\n\nfn limbs_is_square(limbs: &[Limb]) -> bool {\n    assert!(!limbs.is_empty());\n    let idx = limbs[0] % 0x100; // mod 256\n\n    // The first test excludes 212/256 (82.8%) of the perfect square candidates in O(1) time.\n    //\n    // This just checks the particular bit in the bitmask SQR_MOD256_U64 encoding where the input\n    // can be a perfect square mod 256.\n    if (SQR_MOD256[usize::exact_from(idx >> Limb::LOG_WIDTH)]\n        >> (idx & const { Limb::WIDTH_MASK as Limb }))\n        & 1\n        == 0\n    {\n        return false;\n    }\n    // The second test uses mpn_mod_34lsub1 to detect non-squares according to their residues modulo\n    // small primes (or powers of primes). See mpn/perfsqr.h, GMP 6.3.0.\n    if !perfsqr_mod_test(limbs) {\n        return false;\n    }\n    // For the third and last test, we finally compute the square root, to make sure we've really\n    // got a perfect square.\n    limbs_checked_sqrt(limbs).is_some()\n}\n\nimpl IsSquare for Natural {\n    /// Determine whether a [`Natural`] is a perfect square. Rules out > 99% of non-squares in\n    /// $O(1)$ time using quadratic residue tests, then falls back to computing the square root. The\n    /// [`Natural`] is taken by reference.\n    ///\n    /// $f(x) = (\\exists b \\in \\Z : b^2 = x)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::factorization::traits::IsSquare;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let x = Natural::from(12345u64);\n    /// let mut y = &x * &x;\n    ///\n    /// assert!((&y).is_square());\n    ///\n    /// y += Natural::from(1u64);\n    /// assert!(!(&y).is_square());\n    /// ```\n    fn is_square(&self) -> bool {\n        match self {\n            // use the FLINT n_is_square impl for primitive integers TODO: is the FLINT n_is_square\n            // better than the GMP algorithm in this file for word size integers?\n            Self(Small(small)) => small.is_square(),\n            Self(Large(limbs)) => limbs_is_square(limbs),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/factorization/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of [`IsPower`](malachite_base::num::factorization::traits::IsPower) and\n/// [`ExpressAsPower`](malachite_base::num::factorization::traits::ExpressAsPower), traits for\n/// testing if a number is a perfect power and, if it is, expressing it as such.\npub mod is_power;\n/// An implementation of [`IsSquare`](malachite_base::num::factorization::traits::IsSquare), a trait\n/// for testing if a number if a perfect square.\npub mod is_square;\n/// An implementation of [`Primes`](malachite_base::num::factorization::traits::Primes), a trait for\n/// generating prime numbers.\npub mod primes;\n#[doc(hidden)]\npub mod remove_power;\n"
  },
  {
    "path": "malachite-nz/src/natural/factorization/primes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::SaturatingFrom;\nuse malachite_base::num::factorization::primes::{PrimesIterator, PrimesLessThanIterator};\nuse malachite_base::num::factorization::traits::Primes;\n\n/// An iterator over that generates all prime [`Natural`]s less than a given value.\n///\n/// This `struct` is created by [`Natural::primes_less_than`] and\n/// [`Natural::primes_less_than_or_equal_to`]; see their documentation for more.\n#[derive(Clone, Debug)]\npub struct NaturalPrimesLessThanIterator(PrimesLessThanIterator<u64>);\n\nimpl Iterator for NaturalPrimesLessThanIterator {\n    type Item = Natural;\n\n    #[inline]\n    fn next(&mut self) -> Option<Natural> {\n        self.0.next().map(Natural::from)\n    }\n}\n\n/// An iterator over that generates all prime [`Natural`]s.\n///\n/// This `struct` is created by [`Natural::primes`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct NaturalPrimesIterator(PrimesIterator<u64>);\n\nimpl Iterator for NaturalPrimesIterator {\n    type Item = Natural;\n\n    #[inline]\n    fn next(&mut self) -> Option<Natural> {\n        self.0.next().map(Natural::from)\n    }\n}\n\nimpl Primes for Natural {\n    type I = NaturalPrimesIterator;\n    type LI = NaturalPrimesLessThanIterator;\n\n    /// Returns an iterator that generates all primes less than a given value.\n    ///\n    /// The iterator produced by `primes_less_than(n)` generates the same primes as the iterator\n    /// produced by `primes().take_while(|&p| p < n)`, but the latter would be slower because it\n    /// doesn't know in advance how large its prime sieve should be, and might have to create larger\n    /// and larger prime sieves.\n    ///\n    /// # Worst-case complexity (amortized)\n    /// $T(i) = O(\\log \\log i)$\n    ///\n    /// $M(i) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::factorization::traits::Primes;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::primes_less_than(&Natural::from(10u32))\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[2, 3, 5, 7]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::primes_less_than(&Natural::from(11u32))\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[2, 3, 5, 7]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::primes_less_than(&Natural::from(100u32))\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, \\\n    ///     83, 89, 97]\"\n    /// );\n    /// ```\n    #[inline]\n    fn primes_less_than(n: &Self) -> NaturalPrimesLessThanIterator {\n        NaturalPrimesLessThanIterator(u64::primes_less_than(&u64::saturating_from(n)))\n    }\n\n    /// Returns an iterator that generates all primes less than or equal to a given value.\n    ///\n    /// The iterator produced by `primes_less_than_or_equal_to(n)` generates the same primes as the\n    /// iterator produced by `primes().take_while(|&p| p <= n)`, but the latter would be slower\n    /// because it doesn't know in advance how large its prime sieve should be, and might have to\n    /// create larger and larger prime sieves.\n    ///\n    /// # Worst-case complexity (amortized)\n    /// $T(i) = O(\\log \\log i)$\n    ///\n    /// $M(i) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::factorization::traits::Primes;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::primes_less_than_or_equal_to(&Natural::from(10u32))\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[2, 3, 5, 7]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::primes_less_than_or_equal_to(&Natural::from(11u32))\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[2, 3, 5, 7, 11]\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::primes_less_than_or_equal_to(&Natural::from(100u32))\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, \\\n    ///     83, 89, 97]\"\n    /// );\n    /// ```\n    #[inline]\n    fn primes_less_than_or_equal_to(n: &Self) -> NaturalPrimesLessThanIterator {\n        NaturalPrimesLessThanIterator(u64::primes_less_than_or_equal_to(&u64::saturating_from(n)))\n    }\n\n    /// Returns all [`Natural`] primes.\n    ///\n    /// # Worst-case complexity (amortized)\n    /// $T(i) = O(\\log \\log i)$\n    ///\n    /// $M(i) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_base::num::factorization::traits::Primes;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::primes()\n    ///         .take_while(|p| u8::convertible_from(p))\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, \\\n    ///     83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, \\\n    ///     173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251]\"\n    /// );\n    /// ```\n    #[inline]\n    fn primes() -> NaturalPrimesIterator {\n        NaturalPrimesIterator(u64::primes())\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/factorization/remove_power.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// Uses code adopted from the FLINT Library.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::div_exact::limbs_modular_div_mod_wrap;\nuse crate::natural::arithmetic::neg::limbs_neg_in_place;\nuse crate::natural::arithmetic::square::{limbs_square_to_out, limbs_square_to_out_scratch_len};\nuse crate::natural::comparison::cmp::limbs_cmp_same_length;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::Equal;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::slice_test_zero;\n\n// Remove the largest power of V from U that doesn't exceed the given cap\n//\n// This is `mpn_remove` from GMP 6.3.0.\n#[doc(hidden)]\npub fn limbs_remove(\n    wp: &mut Vec<Limb>, // Output: U / V^k\n    up: &[Limb],        // Input number U\n    vp: &[Limb],        // Divisor V (must be odd)\n    cap: usize,         // Maximum power to attempt\n) -> usize {\n    let un = up.len();\n    let vn = vp.len();\n\n    assert!(un > 0);\n    assert!(vn > 0);\n    assert!(vp[0].odd(), \"V must be odd for 2-adic division\");\n    assert!(vn > 1 || vp[0] > 1, \"V must be > 1 to avoid infinite loop\");\n\n    // Temporary work buffers\n    let mut qp = vec![0; un + 1];\n    let mut qp2 = vec![0; un + 1];\n    let mut tp = vec![0; (un + 1 + vn) / 2];\n\n    // Copy input into quotient buffer\n    qp[..un].copy_from_slice(up);\n    let mut qn = un;\n\n    // Store the powers of V\n    let mut pwpsn = Vec::with_capacity(Limb::WIDTH as usize);\n    let mut pwpsp_offsets = Vec::with_capacity(Limb::WIDTH as usize);\n\n    // All generated powers of V are stored here\n    let mut powers_storage = Vec::new();\n\n    let mut current_power_is_vp = true; // true if current power is vp, false if in powers_storage\n    let mut current_power_offset = 0; // offset in powers_storage if current_power_is_vp is false\n    let mut pn = vn;\n    let mut npowers = 0;\n\n    while qn >= pn {\n        qp[qn] = 0;\n\n        if current_power_is_vp {\n            // Use original vp directly\n            limbs_modular_div_mod_wrap(&mut qp2[..=qn - pn], &mut tp[..pn], &qp[..qn], &vp[..pn]);\n            if !slice_test_zero(&tp[..pn]) && limbs_cmp_same_length(&tp[..pn], &vp[..pn]) != Equal {\n                break; // cannot divide\n            }\n        } else {\n            // Access the power from storage without creating a conflicting borrow\n            let power_slice = &powers_storage[current_power_offset..current_power_offset + pn];\n            limbs_modular_div_mod_wrap(&mut qp2[..=qn - pn], &mut tp[..pn], &qp[..qn], power_slice);\n            if !slice_test_zero(&tp[..pn]) && limbs_cmp_same_length(&tp[..pn], power_slice) != Equal\n            {\n                break; // cannot divide\n            }\n        }\n        swap(&mut qp, &mut qp2);\n        qn -= pn;\n        limbs_neg_in_place(&mut qp[..=qn]);\n        if qp[qn] != 0 {\n            qn += 1;\n        }\n        // record power\n        pwpsp_offsets.push(if current_power_is_vp {\n            usize::MAX\n        } else {\n            current_power_offset\n        });\n        pwpsn.push(pn);\n        npowers += 1;\n\n        if ((2usize << npowers) - 1) > cap {\n            break;\n        }\n\n        let nn = 2 * pn - 1;\n        if nn > qn {\n            break;\n        }\n        // allocate powers_storage on first use\n        if npowers == 1 {\n            powers_storage = vec![0; qn + Limb::WIDTH as usize];\n        }\n        // compute square of current power into powers_storage\n        let np_offset = if npowers == 1 {\n            0\n        } else {\n            powers_storage.len()\n        };\n        let np_end = np_offset + 2 * pn;\n        powers_storage.resize(np_end, 0);\n        let mut scratch = vec![0; limbs_square_to_out_scratch_len(pn)];\n        if current_power_is_vp {\n            limbs_square_to_out(\n                &mut powers_storage[np_offset..np_end],\n                &vp[..pn],\n                &mut scratch,\n            );\n        } else {\n            // Square the current power from powers_storage into a new location\n            //\n            // need to be careful about overlapping borrows\n            //\n            // we can use split_at_mut to get non-overlapping mutable slices\n            let src_end = current_power_offset + pn;\n            if src_end <= np_offset {\n                // Source and destination don't overlap - safe to borrow both\n                let (src_part, dst_part) = powers_storage.split_at_mut(np_offset);\n                let src = &src_part[current_power_offset..src_end];\n                limbs_square_to_out(&mut dst_part[..2 * pn], src, &mut scratch);\n            } else {\n                // Fallback: copy source data to avoid overlapping borrows\n                //\n                // This should rarely happen with our offset calculation\n                let src_data: Vec<Limb> = powers_storage[current_power_offset..src_end].to_vec();\n                limbs_square_to_out(\n                    &mut powers_storage[np_offset..np_end],\n                    &src_data,\n                    &mut scratch,\n                );\n            }\n        }\n\n        pn = nn;\n        if powers_storage[np_offset + nn] != 0 {\n            pn += 1;\n        }\n\n        current_power_is_vp = false;\n        current_power_offset = np_offset;\n    }\n\n    let mut pwr = (1usize << npowers) - 1;\n\n    for i in (0..npowers).rev() {\n        let pn = pwpsn[i];\n        if qn < pn {\n            continue;\n        }\n        if pwr + (1usize << i) > cap {\n            continue;\n        }\n\n        let power_slice = if pwpsp_offsets[i] == usize::MAX {\n            &vp[..pn] // Use original vp\n        } else {\n            let offset = pwpsp_offsets[i];\n            &powers_storage[offset..offset + pn]\n        };\n\n        qp[qn] = 0;\n        limbs_modular_div_mod_wrap(\n            &mut qp2[..=(qn - pn)],\n            &mut tp[..pn],\n            &qp[..qn],\n            power_slice,\n        );\n\n        if !slice_test_zero(&tp[..pn]) && limbs_cmp_same_length(&tp[..pn], power_slice) != Equal {\n            continue;\n        }\n\n        swap(&mut qp, &mut qp2);\n        qn -= pn;\n        limbs_neg_in_place(&mut qp[..=qn]);\n        if qp[qn] != 0 {\n            qn += 1;\n        }\n\n        pwr += 1usize << i;\n    }\n\n    wp.clear();\n    wp.extend_from_slice(&qp[..qn]);\n\n    pwr\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::cmp::Ordering::*;\nuse core::mem::swap;\nuse core::ops::{BitAnd, BitAndAssign};\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::slices::slice_set_zero;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// bitwise and of the `Natural` and a `Limb`. The slice cannot be empty.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_const_test! {limbs_and_limb(xs: &[Limb], y: Limb) -> Limb {\n    xs[0] & y\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns a\n// `Vec` of the limbs of the bitwise and of the `Natural`s. The length of the result is the length\n// of the shorter input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res` is returned and both\n// inputs are non-negative.\npub_test! {limbs_and(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    xs.iter().zip(ys.iter()).map(|(x, y)| x & y).collect()\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise and of the `Natural`s to a specified slice. The\n// output slice must be at least as long as the length of one of the input slices.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths or if `out` is too short.\n//\n// This is equivalent to `mpn_and_n` from `gmp-impl.h`, GMP 6.2.1.\npub_test! {limbs_and_same_length_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(out.len() >= len);\n    for (out, (&x, &y)) in out.iter_mut().zip(xs.iter().zip(ys.iter())) {\n        *out = x & y;\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the bitwise and of the `Natural`s to a specified slice. The output slice must be at\n// least as long as the longer input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `out` is too short.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where both inputs are non-negative.\npub_test! {limbs_and_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len >= ys_len {\n        assert!(out.len() >= xs_len);\n        limbs_and_same_length_to_out(out, &xs[..ys_len], ys);\n        slice_set_zero(&mut out[ys_len..xs_len]);\n    } else {\n        assert!(out.len() >= ys_len);\n        limbs_and_same_length_to_out(out, xs, &ys[..xs_len]);\n        slice_set_zero(&mut out[xs_len..ys_len]);\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise and of the `Natural`s to the first (left) slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_and_n` from `gmp-impl.h`, GMP 6.2.1, where `rp == up`.\npub_test! {limbs_slice_and_same_length_in_place_left(xs: &mut [Limb], ys: &[Limb]) {\n    assert_eq!(xs.len(), ys.len());\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        *x &= y;\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the bitwise and of the `Natural`s to the first (left) slice. If the second slice is\n// shorter than the first, then some of the most-significant bits of the first slice should become\n// zero. Rather than setting them to zero, this function optionally returns the length of the\n// significant part of the slice. The caller can decide whether to zero the rest. If `None` is\n// returned, the entire slice remains significant.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res == op1` and both inputs\n// are non-negative.\npub_test! {limbs_slice_and_in_place_left(xs: &mut [Limb], ys: &[Limb]) -> Option<usize> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    match xs_len.cmp(&ys.len()) {\n        Equal => {\n            limbs_slice_and_same_length_in_place_left(xs, ys);\n            None\n        }\n        Greater => {\n            limbs_slice_and_same_length_in_place_left(&mut xs[..ys_len], ys);\n            Some(ys_len)\n        }\n        Less => {\n            limbs_slice_and_same_length_in_place_left(xs, &ys[..xs_len]);\n            None\n        }\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s and a slice of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise and of the `Natural`s to the `Vec`. If the slice is\n// shorter than the `Vec`, then some of the most-significant bits of the `Vec` should become zero.\n// Rather than setting them to zero, this function truncates the `Vec`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where `res == op1` and both inputs\n// are non-negative and have the same length, and `res` is truncated afterwards to remove the\n// `max(0, xs.len() - ys.len())` trailing zero limbs.\npub_test! {limbs_vec_and_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    if let Some(truncate_size) = limbs_slice_and_in_place_left(xs, ys) {\n        xs.truncate(truncate_size);\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, takes the\n// limbs of the bitwise and of the `Natural`s and writes them to the shorter slice (or the first\n// one, if they are equally long). If the function writes to the first slice, it returns `false`;\n// otherwise, it returns `true`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_and` from `mpz/and.c`, GMP 6.2.1, where both inputs are non-negative\n// and the result is written to the shorter input slice.\npub_test! {limbs_and_in_place_either(xs: &mut [Limb], ys: &mut [Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    match xs_len.cmp(&ys_len) {\n        Equal => {\n            limbs_slice_and_same_length_in_place_left(xs, ys);\n            false\n        }\n        Less => {\n            limbs_slice_and_same_length_in_place_left(xs, &ys[..xs_len]);\n            false\n        }\n        Greater => {\n            limbs_slice_and_same_length_in_place_left(ys, &xs[..ys_len]);\n            true\n        }\n    }\n}}\n\nimpl Natural {\n    fn and_limb(self, other: Limb) -> Limb {\n        Limb::wrapping_from(&self) & other\n    }\n\n    fn and_limb_ref(&self, other: Limb) -> Limb {\n        Limb::wrapping_from(self) & other\n    }\n\n    fn and_assign_limb(&mut self, other: Limb) {\n        *self = Self(Small(self.and_limb_ref(other)));\n    }\n}\n\nimpl BitAnd<Self> for Natural {\n    type Output = Self;\n\n    /// Takes the bitwise and of two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) & Natural::from(456u32), 72);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) & (Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     999999995904u64\n    /// );\n    /// ```\n    #[inline]\n    fn bitand(mut self, other: Self) -> Self {\n        self &= other;\n        self\n    }\n}\n\nimpl<'a> BitAnd<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Takes the bitwise and of two [`Natural`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) & &Natural::from(456u32), 72);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) & &(Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     999999995904u64\n    /// );\n    /// ```\n    #[inline]\n    fn bitand(mut self, other: &'a Self) -> Self {\n        self &= other;\n        self\n    }\n}\n\nimpl BitAnd<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Takes the bitwise and of two [`Natural`]s, taking the first by reference and the seocnd by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) & Natural::from(456u32), 72);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) & (Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     999999995904u64\n    /// );\n    /// ```\n    #[inline]\n    fn bitand(self, mut other: Natural) -> Natural {\n        other &= self;\n        other\n    }\n}\n\nimpl BitAnd<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Takes the bitwise and of two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) & &Natural::from(456u32), 72);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) & &(Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     999999995904u64\n    /// );\n    /// ```\n    fn bitand(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (x, &Natural(Small(y))) => Natural(Small(x.and_limb_ref(y))),\n            (&Natural(Small(x)), y) => Natural(Small(y.and_limb_ref(x))),\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                Natural::from_owned_limbs_asc(limbs_and(xs, ys))\n            }\n        }\n    }\n}\n\nimpl BitAndAssign<Self> for Natural {\n    /// Bitwise-ands a [`Natural`] with another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(u32::MAX);\n    /// x &= Natural::from(0xf0ffffffu32);\n    /// x &= Natural::from(0xfff0_ffffu32);\n    /// x &= Natural::from(0xfffff0ffu32);\n    /// x &= Natural::from(0xfffffff0u32);\n    /// assert_eq!(x, 0xf0f0_f0f0u32);\n    /// ```\n    fn bitand_assign(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (_, Self(Small(y))) => self.and_assign_limb(*y),\n            (Self(Small(x)), _) => *x = other.and_limb(*x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_and_in_place_either(xs, ys) {\n                    swap(xs, ys);\n                }\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl<'a> BitAndAssign<&'a Self> for Natural {\n    /// Bitwise-ands a [`Natural`] with another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x \\wedge y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(u32::MAX);\n    /// x &= &Natural::from(0xf0ffffffu32);\n    /// x &= &Natural::from(0xfff0_ffffu32);\n    /// x &= &Natural::from(0xfffff0ffu32);\n    /// x &= &Natural::from(0xfffffff0u32);\n    /// assert_eq!(x, 0xf0f0_f0f0u32);\n    /// ```\n    fn bitand_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (_, Self(Small(y))) => self.and_assign_limb(*y),\n            (Self(Small(x)), _) => *x = other.and_limb_ref(*x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_vec_and_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/bit_access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1995, 1997, 1999, 2000, 2001, 2002, 2012 Free Software Foundation,\n//      Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::BitAccess;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, gets a bit of\n// the `Natural` at a specified index. Sufficiently high indices will return `false`.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpz_tstbit` from `mpz/tstbit.c`, GMP 6.2.1, where the input is\n// non-negative.\npub_crate_test! {limbs_get_bit(xs: &[Limb], index: u64) -> bool {\n    xs.get(bit_to_limb_count_floor(index))\n        .is_some_and(|x| x.get_bit(index & Limb::WIDTH_MASK))\n}}\n\nfn limbs_set_bit_helper(xs: &mut [Limb], index: u64, limb_index: usize) {\n    xs[limb_index].set_bit(index & Limb::WIDTH_MASK);\n}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, sets a bit of\n// the `Natural` at a specified index to `true`. Indices that are outside the bounds of the slice\n// will cause a panic.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `index >= xs.len() * Limb::WIDTH`.\n//\n// This is equivalent to `mpz_setbit` from `mpz/setbit.c`, GMP 6.2.1, where `d` is non-negative and\n// `bit_idx` small enough that no additional memory needs to be given to `d`.\npub_crate_test! {limbs_slice_set_bit(xs: &mut [Limb], index: u64) {\n    limbs_set_bit_helper(xs, index, bit_to_limb_count_floor(index));\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, sets a bit of\n// the `Natural` at a specified index to `true`. Sufficiently high indices will increase the length\n// of the limbs vector.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n//\n// This is equivalent to `mpz_setbit` from `mpz/setbit.c`, GMP 6.2.1, where `d` is non-negative.\npub_test! {limbs_vec_set_bit(xs: &mut Vec<Limb>, index: u64) {\n    let small_index = bit_to_limb_count_floor(index);\n    if small_index >= xs.len() {\n        xs.resize(small_index + 1, 0);\n    }\n    limbs_set_bit_helper(xs, index, small_index);\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, sets a bit of\n// the `Natural` at a specified index to `false`. Indices that are outside the bounds of the slice\n// will result in no action being taken, since there are infinitely many leading zeros.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// This is equivalent to `mpz_clrbit` from `mpz/clrbit.c`, GMP 6.2.1, where `d` is non-negative.\npub_crate_test! {limbs_clear_bit(xs: &mut [Limb], index: u64) {\n    let small_index = bit_to_limb_count_floor(index);\n    if small_index < xs.len() {\n        xs[small_index].clear_bit(index & Limb::WIDTH_MASK);\n    }\n}}\n\n/// Provides functions for accessing and modifying the $i$th bit of a [`Natural`], or the\n/// coefficient of $2^i$ in its binary expansion.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_base::num::logic::traits::BitAccess;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut x = Natural::ZERO;\n/// x.assign_bit(2, true);\n/// x.assign_bit(5, true);\n/// x.assign_bit(6, true);\n/// assert_eq!(x, 100);\n/// x.assign_bit(2, false);\n/// x.assign_bit(5, false);\n/// x.assign_bit(6, false);\n/// assert_eq!(x, 0);\n///\n/// let mut x = Natural::ZERO;\n/// x.flip_bit(10);\n/// assert_eq!(x, 1024);\n/// x.flip_bit(10);\n/// assert_eq!(x, 0);\n/// ```\nimpl BitAccess for Natural {\n    /// Determines whether the $i$th bit of a [`Natural`], or the coefficient of $2^i$ in its binary\n    /// expansion, is 0 or 1.\n    ///\n    /// `false` means 0 and `true` means 1. Getting bits beyond the [`Natural`]'s width is allowed;\n    /// those bits are `false`.\n    ///\n    /// Let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the rest are\n    /// 0. Then $f(n, j) = (b_j = 1)$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::logic::traits::BitAccess;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32).get_bit(2), false);\n    /// assert_eq!(Natural::from(123u32).get_bit(3), true);\n    /// assert_eq!(Natural::from(123u32).get_bit(100), false);\n    /// assert_eq!(Natural::from(10u32).pow(12).get_bit(12), true);\n    /// assert_eq!(Natural::from(10u32).pow(12).get_bit(100), false);\n    /// ```\n    fn get_bit(&self, index: u64) -> bool {\n        match self {\n            Self(Small(small)) => small.get_bit(index),\n            Self(Large(limbs)) => limbs_get_bit(limbs, index),\n        }\n    }\n\n    /// Sets the $i$th bit of a [`Natural`], or the coefficient of $2^i$ in its binary expansion, to\n    /// 1.\n    ///\n    /// Let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the rest are\n    /// 0. Then\n    /// $$\n    /// n \\gets \\\\begin{cases}\n    ///     n + 2^j & \\text{if} \\\\quad b_j = 0, \\\\\\\\\n    ///     n & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitAccess;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x.set_bit(2);\n    /// x.set_bit(5);\n    /// x.set_bit(6);\n    /// assert_eq!(x, 100);\n    /// ```\n    fn set_bit(&mut self, index: u64) {\n        match self {\n            Self(Small(small)) => {\n                if index < Limb::WIDTH {\n                    let mut modified = *small;\n                    modified.set_bit(index);\n                    *small = modified;\n                } else {\n                    let mut limbs = vec![*small];\n                    limbs_vec_set_bit(&mut limbs, index);\n                    *self = Self(Large(limbs));\n                }\n            }\n            Self(Large(limbs)) => {\n                limbs_vec_set_bit(limbs, index);\n            }\n        }\n    }\n\n    /// Sets the $i$th bit of a [`Natural`], or the coefficient of $2^i$ in its binary expansion, to\n    /// 0.\n    ///\n    /// Clearing bits beyond the [`Natural`]'s width is allowed; since those bits are already\n    /// `false`, clearing them does nothing.\n    ///\n    /// Let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the rest are\n    /// 0. Then\n    /// $$\n    /// n \\gets \\\\begin{cases}\n    ///     n - 2^j & \\text{if} \\\\quad b_j = 1, \\\\\\\\\n    ///     n & \\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `index`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitAccess;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::from(0x7fu32);\n    /// x.clear_bit(0);\n    /// x.clear_bit(1);\n    /// x.clear_bit(3);\n    /// x.clear_bit(4);\n    /// assert_eq!(x, 100);\n    /// ```\n    fn clear_bit(&mut self, index: u64) {\n        match self {\n            Self(Small(small)) => small.clear_bit(index),\n            Self(Large(limbs)) => {\n                limbs_clear_bit(limbs, index);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/bit_block_access.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::arithmetic::mod_power_of_2::limbs_vec_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::shl::limbs_slice_shl_in_place;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::natural::{Natural, bit_to_limb_count_ceiling, bit_to_limb_count_floor};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::ModPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{BitBlockAccess, LeadingZeros};\nuse malachite_base::slices::slice_set_zero;\nuse malachite_base::vecs::vec_delete_left;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs obtained by taking a slice of bits beginning at index `start` of the input slice and ending\n// at index `end - 1`. `start` must be less than or equal to `end`, but apart from that there are no\n// restrictions on the index values. If they index beyond the physical size of the input limbs, the\n// function interprets them as pointing to `false` bits.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `start > end`.\npub_crate_test! {limbs_slice_get_bits(xs: &[Limb], start: u64, end: u64) -> Vec<Limb> {\n    assert!(start <= end);\n    let small_start = bit_to_limb_count_floor(start);\n    let len = xs.len();\n    if small_start >= len {\n        return Vec::new();\n    }\n    let small_end = bit_to_limb_count_floor(end) + 1;\n    let mut out = (if small_end >= len {\n        &xs[small_start..]\n    } else {\n        &xs[small_start..small_end]\n    })\n    .to_vec();\n    let offset = start & Limb::WIDTH_MASK;\n    if offset != 0 {\n        limbs_slice_shr_in_place(&mut out, offset);\n    }\n    limbs_vec_mod_power_of_2_in_place(&mut out, end - start);\n    out\n}}\n\n// Interpreting a `Vec` of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs obtained by taking a slice of bits beginning at index `start` of the input slice and ending\n// at index `end - 1`. `start` must be less than or equal to `end`, but apart from that there are no\n// restrictions on the index values. If they index beyond the physical size of the input limbs, the\n// function interprets them as pointing to `false` bits.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `start > end`.\npub_test! {limbs_vec_get_bits(mut xs: Vec<Limb>, start: u64, end: u64) -> Vec<Limb> {\n    assert!(start <= end);\n    let small_start = bit_to_limb_count_floor(start);\n    if small_start >= xs.len() {\n        return Vec::new();\n    }\n    limbs_vec_mod_power_of_2_in_place(&mut xs, end);\n    vec_delete_left(&mut xs, small_start);\n    let offset = start & Limb::WIDTH_MASK;\n    if offset != 0 {\n        limbs_slice_shr_in_place(&mut xs, offset);\n    }\n    xs\n}}\n\n// Copy values from `ys` into `xs`.\n//\n// - If `ys` has the same length as `xs`, the usual copy is performed.\n// - If `ys` is longer than `xs`, the first `xs.len()` limbs of `ys` are copied.\n// - If `ys` is shorter than `xs`, `ys` is copied and the remaining bits of `xs` are filled with\n//   zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\nfn copy_from_diff_len_slice(xs: &mut [Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len <= ys_len {\n        xs.copy_from_slice(&ys[..xs_len]);\n    } else {\n        let (xs_lo, xs_hi) = xs.split_at_mut(ys_len);\n        xs_lo.copy_from_slice(ys);\n        slice_set_zero(xs_hi);\n    }\n}\n\npub(crate) fn limbs_assign_bits_helper(\n    xs: &mut Vec<Limb>,\n    start: u64,\n    end: u64,\n    mut bits: &[Limb],\n    invert: bool,\n) {\n    let small_start = bit_to_limb_count_floor(start);\n    let small_end = bit_to_limb_count_floor(end - 1) + 1;\n    let width = bit_to_limb_count_ceiling(end - start);\n    if width < bits.len() {\n        bits = &bits[..width];\n    }\n    let start_remainder = start & Limb::WIDTH_MASK;\n    let end_remainder = end & Limb::WIDTH_MASK;\n    if small_end > xs.len() {\n        // Possible inefficiency here: we might write many zeros only to delete them later.\n        xs.resize(small_end, 0);\n    }\n    let out = &mut xs[small_start..small_end];\n    assert!(!out.is_empty());\n    let original_first = out[0];\n    let original_last = *out.last().unwrap();\n    copy_from_diff_len_slice(out, bits);\n    if invert {\n        limbs_not_in_place(out);\n    }\n    if start_remainder != 0 {\n        limbs_slice_shl_in_place(out, start_remainder);\n        out[0] |= original_first.mod_power_of_2(start_remainder);\n    }\n    if end_remainder != 0 {\n        out.last_mut().unwrap().assign_bits(\n            end_remainder,\n            Limb::WIDTH,\n            &(original_last >> end_remainder),\n        );\n    }\n}\n\n// Writes the limbs of `bits` into the limbs of `xs`, starting at bit `start` of `xs` (inclusive)\n// and ending at bit `end` of `xs` (exclusive). The bit indices do not need to be aligned with any\n// limb boundaries. If `bits` has more than `end` - `start` bits, only the first `end` - `start`\n// bits are written. If `bits` has fewer than `end` - `start` bits, the remaining written bits are\n// zero. `xs` may be extended to accommodate the new bits. `start` must be smaller than `end`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `end`.\n//\n// # Panics\n// Panics if `start >= end`.\npub_test! {limbs_assign_bits(xs: &mut Vec<Limb>, start: u64, end: u64, bits: &[Limb]) {\n    assert!(start < end);\n    limbs_assign_bits_helper(xs, start, end, bits, false);\n}}\n\nimpl BitBlockAccess for Natural {\n    type Bits = Self;\n\n    /// Extracts a block of adjacent bits from a [`Natural`], taking the [`Natural`] by reference.\n    ///\n    /// The first index is `start` and last index is `end - 1`.\n    ///\n    /// Let $n$ be `self`, and let $p$ and $q$ be `start` and `end`, respectively.\n    ///\n    /// Let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the rest are\n    /// 0. Then\n    /// $$\n    /// f(n, p, q) = \\sum_{i=p}^{q-1} 2^{b_{i-p}}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `start > end`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitBlockAccess;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(0xabcdef0112345678u64).get_bits(16, 48),\n    ///     0xef011234u32\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xabcdef0112345678u64).get_bits(4, 16),\n    ///     0x567u32\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xabcdef0112345678u64).get_bits(0, 100),\n    ///     0xabcdef0112345678u64\n    /// );\n    /// assert_eq!(Natural::from(0xabcdef0112345678u64).get_bits(10, 10), 0);\n    /// ```\n    fn get_bits(&self, start: u64, end: u64) -> Self {\n        match self {\n            Self(Small(small)) => Self(Small(small.get_bits(start, end))),\n            Self(Large(limbs)) => {\n                Self::from_owned_limbs_asc(limbs_slice_get_bits(limbs, start, end))\n            }\n        }\n    }\n\n    /// Extracts a block of adjacent bits from a [`Natural`], taking the [`Natural`] by value.\n    ///\n    /// The first index is `start` and last index is `end - 1`.\n    ///\n    /// Let $n$ be `self`, and let $p$ and $q$ be `start` and `end`, respectively.\n    ///\n    /// Let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the rest are\n    /// 0. Then\n    /// $$\n    /// f(n, p, q) = \\sum_{i=p}^{q-1} 2^{b_{i-p}}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `start > end`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitBlockAccess;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(0xabcdef0112345678u64).get_bits_owned(16, 48),\n    ///     0xef011234u32\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xabcdef0112345678u64).get_bits_owned(4, 16),\n    ///     0x567u32\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xabcdef0112345678u64).get_bits_owned(0, 100),\n    ///     0xabcdef0112345678u64\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xabcdef0112345678u64).get_bits_owned(10, 10),\n    ///     0\n    /// );\n    /// ```\n    fn get_bits_owned(self, start: u64, end: u64) -> Self {\n        match self {\n            Self(Small(small)) => Self(Small(small.get_bits(start, end))),\n            Self(Large(limbs)) => Self::from_owned_limbs_asc(limbs_vec_get_bits(limbs, start, end)),\n        }\n    }\n\n    /// Replaces a block of adjacent bits in a [`Natural`] with other bits.\n    ///\n    /// The least-significant `end - start` bits of `bits` are assigned to bits `start` through `end\n    /// - 1`, inclusive, of `self`.\n    ///\n    /// Let $n$ be `self` and let $m$ be `bits`, and let $p$ and $q$ be `start` and `end`,\n    /// respectively.\n    ///\n    /// If `bits` has fewer bits than `end - start`, the high bits are interpreted as 0. Let\n    /// $$\n    /// n = \\sum_{i=0}^\\infty 2^{b_i},\n    /// $$\n    /// where for all $i$, $b_i\\in \\\\{0, 1\\\\}$; so finitely many of the bits are 1, and the rest are\n    /// 0. Let\n    /// $$\n    /// m = \\sum_{i=0}^k 2^{d_i},\n    /// $$\n    /// where for all $i$, $d_i\\in \\\\{0, 1\\\\}$. Also, let $p, q \\in \\mathbb{N}$, and let $W$ be\n    /// `max(self.significant_bits(), end + 1)`.\n    ///\n    /// Then\n    /// $$\n    /// n \\gets \\sum_{i=0}^{W-1} 2^{c_i},\n    /// $$\n    /// where\n    /// $$\n    /// \\\\{c_0, c_1, c_2, \\ldots, c_ {W-1}\\\\} =\n    /// \\\\{b_0, b_1, b_2, \\ldots, b_{p-1}, d_0, d_1, \\ldots, d_{p-q-1}, b_q, \\ldots,\n    /// b_ {W-1}\\\\}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `end`.\n    ///\n    /// # Panics\n    /// Panics if `start > end`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitBlockAccess;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut n = Natural::from(123u32);\n    /// n.assign_bits(5, 7, &Natural::from(456u32));\n    /// assert_eq!(n, 27);\n    ///\n    /// let mut n = Natural::from(123u32);\n    /// n.assign_bits(64, 128, &Natural::from(456u32));\n    /// assert_eq!(n.to_string(), \"8411715297611555537019\");\n    ///\n    /// let mut n = Natural::from(123u32);\n    /// n.assign_bits(80, 100, &Natural::from(456u32));\n    /// assert_eq!(n.to_string(), \"551270173744270903666016379\");\n    /// ```\n    fn assign_bits(&mut self, start: u64, end: u64, bits: &Self) {\n        if start == end {\n            return;\n        }\n        if let Self(Small(small_self)) = self\n            && let Self(Small(small_bits)) = bits\n        {\n            let bits_width = end - start;\n            let small_bits = small_bits.mod_power_of_2(bits_width);\n            if small_bits == 0 || LeadingZeros::leading_zeros(small_bits) >= start {\n                small_self.assign_bits(start, end, &small_bits);\n                return;\n            }\n        }\n        let limbs = self.promote_in_place();\n        match bits {\n            Self(Small(small_bits)) => limbs_assign_bits(limbs, start, end, &[*small_bits]),\n            Self(Large(bits_limbs)) => limbs_assign_bits(limbs, start, end, bits_limbs),\n        }\n        self.trim();\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/bit_convertible.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::shr::limbs_slice_shr_in_place;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::{BitAccess, BitConvertible};\n\nimpl BitConvertible for Natural {\n    /// Returns a [`Vec`] containing the bits of a [`Natural`] in ascending order: least- to\n    /// most-significant.\n    ///\n    /// If the number is 0, the [`Vec`] is empty; otherwise, it ends with `true`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::ZERO.to_bits_asc().is_empty());\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Natural::from(105u32).to_bits_asc(),\n    ///     &[true, false, false, true, false, true, true]\n    /// );\n    /// ```\n    fn to_bits_asc(&self) -> Vec<bool> {\n        let mut bits = Vec::new();\n        if *self == 0 {\n            return bits;\n        }\n        let limbs = self.limbs();\n        let last_index = usize::exact_from(self.limb_count()) - 1;\n        let mut last = limbs[last_index];\n        for limb in limbs.take(last_index) {\n            for i in 0..Limb::WIDTH {\n                bits.push(limb.get_bit(i));\n            }\n        }\n        while last != 0 {\n            bits.push(last.odd());\n            last >>= 1;\n        }\n        bits\n    }\n\n    /// Returns a [`Vec`] containing the bits of a [`Natural`] in descending order: most- to\n    /// least-significant.\n    ///\n    /// If the number is 0, the [`Vec`] is empty; otherwise, it begins with `true`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::ZERO.to_bits_desc().is_empty());\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Natural::from(105u32).to_bits_desc(),\n    ///     &[true, true, false, true, false, false, true]\n    /// );\n    /// ```\n    fn to_bits_desc(&self) -> Vec<bool> {\n        let mut bits = self.to_bits_asc();\n        bits.reverse();\n        bits\n    }\n\n    /// Converts an iterator of bits into a [`Natural`]. The bits should be in ascending order\n    /// (least- to most-significant).\n    ///\n    /// $$\n    /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^i \\[b_i\\],\n    /// $$\n    /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.count()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::empty;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from_bits_asc(empty()), 0);\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Natural::from_bits_asc(\n    ///         [true, false, false, true, false, true, true]\n    ///             .iter()\n    ///             .cloned()\n    ///     ),\n    ///     105\n    /// );\n    /// ```\n    fn from_bits_asc<I: Iterator<Item = bool>>(xs: I) -> Self {\n        Self::from_owned_limbs_asc(\n            xs.chunks(usize::wrapping_from(Limb::WIDTH))\n                .into_iter()\n                .map(Limb::from_bits_asc)\n                .collect(),\n        )\n    }\n\n    /// Converts an iterator of bits into a [`Natural`]. The bits should be in descending order\n    /// (most- to least-significant).\n    ///\n    /// $$\n    /// f((b_i)_ {i=0}^{k-1}) = \\sum_{i=0}^{k-1}2^{k-i-1} \\[b_i\\],\n    /// $$\n    /// where braces denote the Iverson bracket, which converts a bit to 0 or 1.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `xs.count()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use core::iter::empty;\n    /// use malachite_base::num::logic::traits::BitConvertible;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from_bits_desc(empty()), 0);\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Natural::from_bits_desc(\n    ///         [true, true, false, true, false, false, true]\n    ///             .iter()\n    ///             .cloned()\n    ///     ),\n    ///     105\n    /// );\n    /// ```\n    fn from_bits_desc<I: Iterator<Item = bool>>(xs: I) -> Self {\n        let mut out = Vec::new();\n        let mut last_width = 0;\n        for chunk in &xs.chunks(usize::exact_from(Limb::WIDTH)) {\n            let mut x = 0;\n            let mut i = 0;\n            for bit in chunk {\n                x <<= 1;\n                if bit {\n                    x |= 1;\n                }\n                i += 1;\n            }\n            last_width = i;\n            out.push(x);\n        }\n        match out.len() {\n            0 => Self::ZERO,\n            1 => Self::from(out[0]),\n            _ => {\n                out.reverse();\n                if last_width != Limb::WIDTH {\n                    let out_0 = out[0];\n                    out[0] = 0;\n                    limbs_slice_shr_in_place(&mut out, Limb::WIDTH - last_width);\n                    out[0] |= out_0;\n                }\n                Self::from_owned_limbs_asc(out)\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/bit_iterable.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::natural::conversion::to_limbs::LimbIterator;\nuse crate::platform::Limb;\nuse core::ops::Index;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, BitIterable, SignificantBits};\n\n/// A double-ended iterator over the bits of a [`Natural`].\n///\n/// The forward order is ascending (least-significant first).\n///\n/// This `struct` is created by [`BitIterable::bits`]; see its documentation for more.\n#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]\npub struct NaturalBitIterator<'a> {\n    pub(crate) significant_bits: u64,\n    pub(crate) limbs: LimbIterator<'a>,\n    remaining: usize,\n    indices_are_in_same_limb: bool,\n    current_limb_forward: Limb,\n    current_limb_back: Limb,\n    // If `n` is nonzero, this mask initially points to the least-significant bit, and is left-\n    // shifted by next().\n    i_mask: Limb,\n    // If `n` is nonzero, this mask initially points to the most-significant nonzero bit, and is\n    // right-shifted by next_back().\n    j_mask: Limb,\n}\n\nimpl Iterator for NaturalBitIterator<'_> {\n    type Item = bool;\n\n    fn next(&mut self) -> Option<bool> {\n        if self.remaining != 0 {\n            let bit = self.current_limb_forward & self.i_mask != 0;\n            self.i_mask <<= 1;\n            if self.i_mask == 0 {\n                self.i_mask = 1;\n                if let Some(next) = self.limbs.next() {\n                    self.current_limb_forward = next;\n                } else {\n                    self.current_limb_forward = self.current_limb_back;\n                    self.indices_are_in_same_limb = true;\n                }\n            }\n            self.remaining -= 1;\n            Some(bit)\n        } else {\n            None\n        }\n    }\n\n    fn size_hint(&self) -> (usize, Option<usize>) {\n        (self.remaining, Some(self.remaining))\n    }\n}\n\nimpl DoubleEndedIterator for NaturalBitIterator<'_> {\n    fn next_back(&mut self) -> Option<bool> {\n        if self.remaining != 0 {\n            let bit = self.current_limb_back & self.j_mask != 0;\n            self.j_mask >>= 1;\n            if self.j_mask == 0 {\n                self.j_mask = Limb::power_of_2(Limb::WIDTH - 1);\n                if let Some(next_back) = self.limbs.next_back() {\n                    self.current_limb_back = next_back;\n                } else {\n                    self.current_limb_back = self.current_limb_forward;\n                    self.indices_are_in_same_limb = true;\n                }\n            }\n            self.remaining -= 1;\n            Some(bit)\n        } else {\n            None\n        }\n    }\n}\n\nimpl ExactSizeIterator for NaturalBitIterator<'_> {}\n\nimpl Index<u64> for NaturalBitIterator<'_> {\n    type Output = bool;\n\n    /// A function to retrieve a [`Natural`]'s bits by index.\n    ///\n    /// The index is the power of 2 of which the bit is a coefficient. Indexing at or above the\n    /// significant bit count returns `false` bits.\n    ///\n    /// This is equivalent to [`get_bit`](malachite_base::num::logic::traits::BitAccess::get_bit).\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitIterable;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.bits()[0], false);\n    ///\n    /// // 105 = 1101001b\n    /// let n = Natural::from(105u32);\n    /// let bits = n.bits();\n    /// assert_eq!(bits[0], true);\n    /// assert_eq!(bits[1], false);\n    /// assert_eq!(bits[2], false);\n    /// assert_eq!(bits[3], true);\n    /// assert_eq!(bits[4], false);\n    /// assert_eq!(bits[5], true);\n    /// assert_eq!(bits[6], true);\n    /// assert_eq!(bits[7], false);\n    /// assert_eq!(bits[100], false);\n    /// ```\n    fn index(&self, index: u64) -> &bool {\n        if self.limbs.n.get_bit(index) {\n            &true\n        } else {\n            &false\n        }\n    }\n}\n\nimpl<'a> BitIterable for &'a Natural {\n    type BitIterator = NaturalBitIterator<'a>;\n\n    /// Returns a double-ended iterator over the bits of a [`Natural`].\n    ///\n    /// The forward order is ascending, so that less significant bits appear first. There are no\n    /// trailing false bits going forward, or leading falses going backward.\n    ///\n    /// If it's necessary to get a [`Vec`] of all the bits, consider using\n    /// [`to_bits_asc`](malachite_base::num::logic::traits::BitConvertible::to_bits_asc) or\n    /// [`to_bits_desc`](malachite_base::num::logic::traits::BitConvertible::to_bits_desc) instead.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::BitIterable;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert!(Natural::ZERO.bits().next().is_none());\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Natural::from(105u32).bits().collect::<Vec<bool>>(),\n    ///     &[true, false, false, true, false, true, true]\n    /// );\n    ///\n    /// assert!(Natural::ZERO.bits().next_back().is_none());\n    /// // 105 = 1101001b\n    /// assert_eq!(\n    ///     Natural::from(105u32).bits().rev().collect::<Vec<bool>>(),\n    ///     &[true, true, false, true, false, false, true]\n    /// );\n    /// ```\n    fn bits(self) -> NaturalBitIterator<'a> {\n        let significant_bits = self.significant_bits();\n        let remainder = significant_bits & Limb::WIDTH_MASK;\n        let mut bits = NaturalBitIterator {\n            significant_bits,\n            limbs: self.limbs(),\n            remaining: usize::exact_from(significant_bits),\n            indices_are_in_same_limb: significant_bits <= Limb::WIDTH,\n            current_limb_forward: 0,\n            current_limb_back: 0,\n            i_mask: 1,\n            j_mask: if remainder != 0 {\n                Limb::power_of_2(remainder - 1)\n            } else {\n                Limb::power_of_2(Limb::WIDTH - 1)\n            },\n        };\n        if let Some(next) = bits.limbs.next() {\n            bits.current_limb_forward = next;\n        }\n        if let Some(next_back) = bits.limbs.next_back() {\n            bits.current_limb_back = next_back;\n        } else {\n            bits.current_limb_back = bits.current_limb_forward;\n        }\n        bits\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/bit_scan.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2000-2002, 2004, 2012, 2015 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_floor, limb_to_bit_count};\nuse crate::platform::Limb;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{BitScan, TrailingZeros};\nuse malachite_base::slices::slice_leading_zeros;\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, finds the\n// lowest index greater than or equal to `start` at which the `Natural` has a `false` bit.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_scan0` from `mpn/generic/scan0.c`, GMP 6.2.1.\npub_crate_test! {limbs_index_of_next_false_bit(xs: &[Limb], start: u64) -> u64 {\n    let starting_index = bit_to_limb_count_floor(start);\n    if starting_index >= xs.len() {\n        return start;\n    }\n    if let Some(result) = xs[starting_index].index_of_next_false_bit(start & Limb::WIDTH_MASK)\n        && result != Limb::WIDTH\n    {\n        return limb_to_bit_count(starting_index) + result;\n    }\n    if starting_index == xs.len() - 1 {\n        return limb_to_bit_count(xs.len());\n    }\n    let false_index = starting_index\n        + 1\n        + xs[starting_index + 1..]\n            .iter()\n            .take_while(|&&y| y == Limb::MAX)\n            .count();\n    let mut result_offset = limb_to_bit_count(false_index);\n    if false_index != xs.len() {\n        result_offset += TrailingZeros::trailing_zeros(!xs[false_index]);\n    }\n    result_offset\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, finds the\n// lowest index greater than or equal to `start` at which the `Natural` has a `true` bit. If the\n// starting index is too large and there are no more `true` bits above it, `None` is returned.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_scan1` from `mpn/generic/scan1.c`, GMP 6.2.1.\npub_crate_test! {limbs_index_of_next_true_bit(xs: &[Limb], start: u64) -> Option<u64> {\n    let starting_index = bit_to_limb_count_floor(start);\n    if starting_index >= xs.len() {\n        None\n    } else if let Some(result) = xs[starting_index].index_of_next_true_bit(start & Limb::WIDTH_MASK)\n    {\n        Some(limb_to_bit_count(starting_index) + result)\n    } else if starting_index == xs.len() - 1 {\n        None\n    } else {\n        let true_index = starting_index + 1 + slice_leading_zeros(&xs[starting_index + 1..]);\n        if true_index == xs.len() {\n            None\n        } else {\n            let result_offset = limb_to_bit_count(true_index);\n            Some(\n                result_offset\n                    .checked_add(TrailingZeros::trailing_zeros(xs[true_index]))\n                    .unwrap(),\n            )\n        }\n    }\n}}\n\nimpl BitScan for &Natural {\n    /// Given a [`Natural`] and a starting index, searches the [`Natural`] for the smallest index of\n    /// a `false` bit that is greater than or equal to the starting index.\n    ///\n    /// Since every [`Natural`] has an implicit prefix of infinitely-many zeros, this function\n    /// always returns a value.\n    ///\n    /// Starting beyond the [`Natural`]'s width is allowed; the result is the starting index.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitScan;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(0),\n    ///     Some(0)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(20),\n    ///     Some(20)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(31),\n    ///     Some(31)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(32),\n    ///     Some(34)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(33),\n    ///     Some(34)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(34),\n    ///     Some(34)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(35),\n    ///     Some(36)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_false_bit(100),\n    ///     Some(100)\n    /// );\n    /// ```\n    fn index_of_next_false_bit(self, start: u64) -> Option<u64> {\n        match self {\n            Natural(Small(small)) => small.index_of_next_false_bit(start),\n            Natural(Large(limbs)) => Some(limbs_index_of_next_false_bit(limbs, start)),\n        }\n    }\n\n    /// Given a [`Natural`] and a starting index, searches the [`Natural`] for the smallest index of\n    /// a `true` bit that is greater than or equal to the starting index.\n    ///\n    /// If the starting index is greater than or equal to the [`Natural`]'s width, the result is\n    /// `None` since there are no `true` bits past that point.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::BitScan;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(0),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(20),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(31),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(32),\n    ///     Some(32)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(33),\n    ///     Some(33)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(34),\n    ///     Some(35)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(35),\n    ///     Some(35)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(36),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(0xb00000000u64).index_of_next_true_bit(100),\n    ///     None\n    /// );\n    /// ```\n    fn index_of_next_true_bit(self, start: u64) -> Option<u64> {\n        match self {\n            Natural(Small(small)) => small.index_of_next_true_bit(start),\n            Natural(Large(limbs)) => limbs_index_of_next_true_bit(limbs, start),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::logic::traits::CountOnes;\n\n// Interpreting a slice of `Limb`s, as the limbs (in ascending order) of a `Natural`, counts the\n// number of ones in the binary expansion of the `Natural`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\npub_crate_test! {limbs_count_ones(xs: &[Limb]) -> u64 {\n    xs.iter().map(|&x| CountOnes::count_ones(x)).sum()\n}}\n\nimpl CountOnes for &Natural {\n    /// Counts the number of ones in the binary expansion of a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::CountOnes;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.count_ones(), 0);\n    /// // 105 = 1101001b\n    /// assert_eq!(Natural::from(105u32).count_ones(), 4);\n    /// // 10^12 = 1110100011010100101001010001000000000000b\n    /// assert_eq!(Natural::from(10u32).pow(12).count_ones(), 13);\n    /// ```\n    fn count_ones(self) -> u64 {\n        match self {\n            Natural(Small(small)) => CountOnes::count_ones(*small),\n            Natural(Large(limbs)) => limbs_count_ones(limbs),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1994, 1996, 2001, 2002, 2009-2011 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::logic::count_ones::limbs_count_ones;\nuse crate::platform::Limb;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::logic::traits::HammingDistance;\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, returns the\n// Hamming distance between that `Natural` and a `Limb`. Both have infinitely many implicit leading\n// zeros. `xs` cannot be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_hamming_distance_limb(xs: &[Limb], y: Limb) -> u64 {\n    xs[0].hamming_distance(y) + limbs_count_ones(&xs[1..])\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs of `Natural`s in ascending order,\n// returns the Hamming distance between them. Both have infinitely many implicit leading zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpz_hamdist` from `mpz/hamdist.c`, GMP 6.2.1, where both arguments are\n// non-negative and have the same length.\npub_crate_test! {limbs_hamming_distance_same_length(xs: &[Limb], ys: &[Limb]) -> u64 {\n    assert_eq!(xs.len(), ys.len());\n    xs.iter()\n        .zip(ys.iter())\n        .map(|(x, &y)| x.hamming_distance(y))\n        .sum()\n}}\n\n// Interpreting two slices of `Limb`s as the limbs of `Natural`s in ascending order, returns the\n// Hamming distance between them. Both have infinitely many implicit leading zeros.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_hamdist` from `mpz/hamdist.c`, GMP 6.2.1, where both arguments are\n// non-negative.\npub_test! {limbs_hamming_distance(xs: &[Limb], ys: &[Limb]) -> u64 {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    match xs_len.cmp(&ys_len) {\n        Equal => limbs_hamming_distance_same_length(xs, ys),\n        Less => {\n            limbs_hamming_distance_same_length(xs, &ys[..xs_len]) + limbs_count_ones(&ys[xs_len..])\n        }\n        Greater => {\n            limbs_hamming_distance_same_length(&xs[..ys_len], ys) + limbs_count_ones(&xs[ys_len..])\n        }\n    }\n}}\n\nimpl Natural {\n    fn hamming_distance_limb(&self, other: Limb) -> u64 {\n        match self {\n            Self(Small(small)) => small.hamming_distance(other),\n            Self(Large(limbs)) => limbs_hamming_distance_limb(limbs, other),\n        }\n    }\n}\n\nimpl HammingDistance<&Natural> for &Natural {\n    /// Determines the Hamming distance between two [`Natural]`s.\n    ///\n    /// Both [`Natural`]s have infinitely many implicit leading zeros.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_base::num::logic::traits::HammingDistance;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(123u32).hamming_distance(&Natural::from(123u32)),\n    ///     0\n    /// );\n    /// // 105 = 1101001b, 123 = 1111011\n    /// assert_eq!(\n    ///     Natural::from(105u32).hamming_distance(&Natural::from(123u32)),\n    ///     2\n    /// );\n    /// let n = Natural::ONE << 100u32;\n    /// assert_eq!(n.hamming_distance(&(&n - Natural::ONE)), 101);\n    /// ```\n    fn hamming_distance(self, other: &Natural) -> u64 {\n        match (self, other) {\n            (&Natural(Small(x)), _) => other.hamming_distance_limb(x),\n            (_, &Natural(Small(y))) => self.hamming_distance_limb(y),\n            (Natural(Large(xs)), Natural(Large(ys))) => limbs_hamming_distance(xs, ys),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, bit_to_limb_count_ceiling};\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::ModPowerOf2Assign;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::LowMask;\n\n// Returns the limbs of a `Natural`, where the lowest `bits` bits are set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `bits`.\npub_crate_test! {limbs_low_mask(bits: u64) -> Vec<Limb> {\n    let len = bit_to_limb_count_ceiling(bits);\n    let remaining_bits = bits & Limb::WIDTH_MASK;\n    let mut xs = vec![Limb::MAX; len];\n    if remaining_bits != 0 {\n        xs.last_mut().unwrap().mod_power_of_2_assign(remaining_bits);\n    }\n    xs\n}}\n\nimpl LowMask for Natural {\n    /// Returns a [`Natural`] whose least significant $b$ bits are `true` and whose other bits are\n    /// `false`.\n    ///\n    /// $f(b) = 2^b - 1$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `bits`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::logic::traits::LowMask;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::low_mask(0), 0);\n    /// assert_eq!(Natural::low_mask(3), 7);\n    /// assert_eq!(\n    ///     Natural::low_mask(100).to_string(),\n    ///     \"1267650600228229401496703205375\"\n    /// );\n    /// ```\n    fn low_mask(bits: u64) -> Self {\n        if bits <= Limb::WIDTH {\n            Self(Small(Limb::low_mask(bits)))\n        } else {\n            Self(Large(limbs_low_mask(bits)))\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Bitwise and of [`Natural`](super::Natural)s.\npub mod and;\n/// An implementation of [`BitAccess`](malachite_base::num::logic::traits::BitAccess), a trait for\n/// getting and setting individual bits of a number.\npub mod bit_access;\n/// An implementation of [`BitBlockAccess`](malachite_base::num::logic::traits::BitBlockAccess), a\n/// trait for getting and setting adjacent blocks of bits in a number.\npub mod bit_block_access;\n/// An implementation of [`BitConvertible`](malachite_base::num::logic::traits::BitConvertible), a\n/// trait for extracting all bits from a number or constructing a number from bits.\npub mod bit_convertible;\n/// An implementation of [`BitIterable`](malachite_base::num::logic::traits::BitIterable), a trait\n/// for producing a double-ended iterator over a number's bits.\npub mod bit_iterable;\n/// An implementation of [`BitScan`](malachite_base::num::logic::traits::BitScan), a trait for\n/// finding the next `true` or `false` bit in a number after a provided index.\npub mod bit_scan;\n/// An implementation of [`CountOnes`](malachite_base::num::logic::traits::CountOnes), a trait for\n/// counting the number of ones in the binary representation of a number.\npub mod count_ones;\n/// An implementation of [`HammingDistance`](malachite_base::num::logic::traits::HammingDistance), a\n/// trait for computing the Hamming distance between two numbers.\npub mod hamming_distance;\n/// An implementation of [`LowMask`](malachite_base::num::logic::traits::LowMask), a trait for\n/// generating a low bit mask (a number in which only the $k$ least-significant bits are 1).\npub mod low_mask;\n/// Bitwise negation of [`Natural`](super::Natural)s.\npub mod not;\n/// Bitwise or of [`Natural`](super::Natural)s.\npub mod or;\n/// An implementation of [`SignificantBits`](malachite_base::num::logic::traits::SignificantBits), a\n/// trait for determining how many significant bits a number has.\npub mod significant_bits;\n/// An implementation of [`TrailingZeros`](malachite_base::num::logic::traits::TrailingZeros), a\n/// trait for determining the number of zeros that a number ends with when written in binary.\npub mod trailing_zeros;\n/// Bitwise xor of [`Natural`](super::Natural)s.\npub mod xor;\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/not.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright 1991, 1993, 1994, 1996, 2001, 2003, 2012, 2015 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::ops::Not;\nuse malachite_base::num::logic::traits::NotAssign;\n\n// Returns the bitwise not of a slice of limbs.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_com` from `mpn/generic/com.c`, GMP 6.2.1, where `rp` is returned.\npub_test! {limbs_not(xs: &[Limb]) -> Vec<Limb> {\n    xs.iter().map(|x| !x).collect()\n}}\n\n// Writes the bitwise not of a slice of limbs to the lowest `x.len()` limbs of `out`. For this to\n// work, `out` must be at least as long as `xs`.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_com` from `mpn/generic/com.c`, GMP 6.2.1, where `rp != up`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs`.\npub_crate_test! {limbs_not_to_out(out: &mut [Limb], xs: &[Limb]) {\n    assert!(out.len() >= xs.len());\n    for (x, y) in out.iter_mut().zip(xs.iter()) {\n        *x = !y;\n    }\n}}\n\n// Takes the bitwise not of a slice of limbs in place.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_com` from `mpn/generic/com.c`, GMP 6.2.1, where `rp == up`.\npub_crate_test! {limbs_not_in_place(xs: &mut [Limb]) {\n    for x in &mut *xs {\n        x.not_assign();\n    }\n}}\n\nimpl Not for Natural {\n    type Output = Integer;\n\n    /// Returns the bitwise negation of a [`Natural`], taking it by value and returning an\n    /// [`Integer`].\n    ///\n    /// The [`Natural`] is bitwise-negated as if it were represented in two's complement.\n    ///\n    /// $$\n    /// f(n) = -n - 1.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(!Natural::ZERO, -1);\n    /// assert_eq!(!Natural::from(123u32), -124);\n    /// ```\n    fn not(self) -> Integer {\n        Integer {\n            sign: false,\n            abs: self.add_limb(1),\n        }\n    }\n}\n\nimpl Not for &Natural {\n    type Output = Integer;\n\n    /// Returns the bitwise negation of a [`Natural`], taking it by reference and returning an\n    /// [`Integer`].\n    ///\n    /// The [`Natural`] is bitwise-negated as if it were represented in two's complement.\n    ///\n    /// $$\n    /// f(n) = -n - 1.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(!&Natural::ZERO, -1);\n    /// assert_eq!(!&Natural::from(123u32), -124);\n    /// ```\n    fn not(self) -> Integer {\n        Integer {\n            sign: false,\n            abs: self.add_limb_ref(1),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::mem::swap;\nuse core::ops::{BitOr, BitOrAssign};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the bitwise or of the `Natural` and a `Limb`. `xs` cannot be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub fn limbs_or_limb(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    let mut result = xs.to_vec();\n    limbs_or_limb_in_place(&mut result, y);\n    result\n}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the bitwise or of the `Natural` and a `Limb` to an output slice. The output slice must\n// be at least as long as the input slice. `xs` cannot be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs` or if `xs` is empty.\npub_test! {limbs_or_limb_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) {\n    out[..xs.len()].copy_from_slice(xs);\n    limbs_or_limb_in_place(out, y);\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the bitwise or of the `Natural` and a `Limb` to the input slice. `xs` cannot be empty.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_or_limb_in_place(xs: &mut [Limb], y: Limb) {\n    xs[0] |= y;\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, returns a `Vec` of the limbs of the bitwise or of the `Natural`s. The length of the\n// result is the length of one of the input slices.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_ior_n` from `gmp-impl.h`, GMP 6.2.1, where `rp` is returned.\npub_test! {limbs_or_same_length(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    assert_eq!(xs.len(), ys.len());\n    xs.iter().zip(ys.iter()).map(|(x, y)| x | y).collect()\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns a\n// `Vec` of the limbs of the bitwise or of the `Natural`s. The length of the result is the length of\n// the longer input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res` is returned and both\n// inputs are non-negative.\npub_test! {limbs_or(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let mut result;\n    if xs_len >= ys_len {\n        result = limbs_or_same_length(&xs[..ys_len], ys);\n        result.extend_from_slice(&xs[ys_len..]);\n    } else {\n        result = limbs_or_same_length(xs, &ys[..xs_len]);\n        result.extend_from_slice(&ys[xs_len..]);\n    }\n    result\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise or of the `Natural`s to an output slice. The output\n// must be at least as long as one of the input slices.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths or if `out` is too short.\n//\n// This is equivalent to `mpn_ior_n` from `gmp-impl.h`, GMP 6.2.1.\npub_test! {limbs_or_same_length_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(out.len() >= len);\n    for (out_x, (x, y)) in out.iter_mut().zip(xs.iter().zip(ys.iter())) {\n        *out_x = x | y;\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the bitwise or of the `Natural`s to an output slice. The output must be at least as\n// long as the longer input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `out` is too short.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where both inputs are non-negative.\npub_test! {limbs_or_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len >= ys_len {\n        assert!(out.len() >= xs_len);\n        limbs_or_same_length_to_out(out, &xs[..ys_len], ys);\n        out[ys_len..xs_len].copy_from_slice(&xs[ys_len..]);\n    } else {\n        assert!(out.len() >= ys_len);\n        limbs_or_same_length_to_out(out, xs, &ys[..xs_len]);\n        out[xs_len..ys_len].copy_from_slice(&ys[xs_len..]);\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise or of the `Natural`s to the first (left) slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_ior_n` from `gmp-impl.h`, GMP 6.2.1, where `rp == up`.\npub_test! {limbs_or_same_length_in_place_left(xs: &mut [Limb], ys: &[Limb]) {\n    assert_eq!(xs.len(), ys.len());\n    for (x, &y) in xs.iter_mut().zip(ys.iter()) {\n        *x |= y;\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s and a slice of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise or of the `Natural`s to the `Vec`. If `ys` is longer\n// than `xs`, `xs` will be extended.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ys.len()`.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where `res == op1` and both inputs\n// are non-negative.\npub_test! {limbs_or_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len >= ys_len {\n        limbs_or_same_length_in_place_left(&mut xs[..ys_len], ys);\n    } else {\n        limbs_or_same_length_in_place_left(xs, &ys[..xs_len]);\n        xs.extend_from_slice(&ys[xs_len..]);\n    }\n}}\n\n// Interpreting two `Vec`s of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the bitwise or of the `Natural`s to the longer slice (or the first one, if they are\n// equally long). Returns a `bool` which is `false` when the output is to the first slice and `true`\n// when it's to the second slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_ior` from `mpz/ior.c`, GMP 6.2.1, where both inputs are non-negative\n// and the result is written to the longer input slice.\npub_test! {limbs_or_in_place_either(xs: &mut [Limb], ys: &mut [Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let right = xs_len < ys_len;\n    if right {\n        limbs_or_same_length_in_place_left(&mut ys[..xs_len], xs);\n    } else {\n        limbs_or_same_length_in_place_left(&mut xs[..ys_len], ys);\n    }\n    right\n}}\n\nimpl Natural {\n    #[inline]\n    fn or_limb(mut self, other: Limb) -> Self {\n        self.or_assign_limb(other);\n        self\n    }\n\n    fn or_limb_ref(&self, other: Limb) -> Self {\n        Self(match self {\n            Self(Small(small)) => Small(small | other),\n            Self(Large(limbs)) => Large(limbs_or_limb(limbs, other)),\n        })\n    }\n\n    fn or_assign_limb(&mut self, other: Limb) {\n        match self {\n            Self(Small(small)) => *small |= other,\n            Self(Large(limbs)) => limbs_or_limb_in_place(limbs, other),\n        }\n    }\n}\n\nimpl BitOr<Self> for Natural {\n    type Output = Self;\n\n    /// Takes the bitwise or of two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) | Natural::from(456u32), 507);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) | (Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     1000000004095u64\n    /// );\n    /// ```\n    #[inline]\n    fn bitor(mut self, other: Self) -> Self {\n        self |= other;\n        self\n    }\n}\n\nimpl<'a> BitOr<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Takes the bitwise or of two [`Natural`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) | &Natural::from(456u32), 507);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) | &(Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     1000000004095u64\n    /// );\n    /// ```\n    #[inline]\n    fn bitor(mut self, other: &'a Self) -> Self {\n        self |= other;\n        self\n    }\n}\n\nimpl BitOr<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Takes the bitwise or of two [`Natural`]s, taking the first by reference and the second by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) | Natural::from(456u32), 507);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) | (Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     1000000004095u64\n    /// );\n    /// ```\n    #[inline]\n    fn bitor(self, mut other: Natural) -> Natural {\n        other |= self;\n        other\n    }\n}\n\nimpl BitOr<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Takes the bitwise or of two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\vee y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) | &Natural::from(456u32), 507);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) | &(Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     1000000004095u64\n    /// );\n    /// ```\n    fn bitor(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (x, &Natural(Small(y))) => x.or_limb_ref(y),\n            (&Natural(Small(x)), y) => y.or_limb_ref(x),\n            (Natural(Large(xs)), Natural(Large(ys))) => Natural(Large(limbs_or(xs, ys))),\n        }\n    }\n}\n\nimpl BitOrAssign<Self> for Natural {\n    /// Bitwise-ors a [`Natural`] with another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x |= Natural::from(0x0000000fu32);\n    /// x |= Natural::from(0x00000f00u32);\n    /// x |= Natural::from(0x000f_0000u32);\n    /// x |= Natural::from(0x0f000000u32);\n    /// assert_eq!(x, 0x0f0f_0f0f);\n    /// ```\n    fn bitor_assign(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (_, Self(Small(y))) => self.or_assign_limb(*y),\n            (Self(Small(x)), _) => *self = other.or_limb(*x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_or_in_place_either(xs, ys) {\n                    swap(xs, ys);\n                }\n            }\n        }\n    }\n}\n\nimpl<'a> BitOrAssign<&'a Self> for Natural {\n    /// Bitwise-ors a [`Natural`] with another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x |= &Natural::from(0x0000000fu32);\n    /// x |= &Natural::from(0x00000f00u32);\n    /// x |= &Natural::from(0x000f_0000u32);\n    /// x |= &Natural::from(0x0f000000u32);\n    /// assert_eq!(x, 0x0f0f_0f0f);\n    /// ```\n    fn bitor_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (_, Self(Small(y))) => self.or_assign_limb(*y),\n            (Self(Small(x)), _) => *self = other.or_limb_ref(*x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_or_in_place_left(xs, ys);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993-1995, 2001, 2002 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, returns the\n// smallest number of bits necessary to represent that `Natural`. 0 has zero significant bits. When\n// the `Natural` is nonzero, this is equal to 1 + floor(log<sub>2</sub>(`self`)).\n//\n// This function assumes that `xs` is nonempty and the last (most significant) limb is nonzero.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\n//\n// This is equivalent to `mpz_sizeinbase` from `mpz/sizeinbase.c`, GMP 6.2.1, where `x` is\n// non-negative and `base` is 2.\npub_crate_test! {limbs_significant_bits<T: PrimitiveUnsigned>(xs: &[T]) -> u64 {\n    ((u64::wrapping_from(xs.len()) - 1) << T::LOG_WIDTH) + xs.last().unwrap().significant_bits()\n}}\n\nimpl SignificantBits for &Natural {\n    /// Returns the number of significant bits of a [`Natural`].\n    ///\n    /// $$\n    /// f(n) = \\\\begin{cases}\n    ///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n    ///     \\lfloor \\log_2 n \\rfloor + 1 & \\text{if} \\\\quad n > 0.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::SignificantBits;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.significant_bits(), 0);\n    /// assert_eq!(Natural::from(100u32).significant_bits(), 7);\n    /// ```\n    fn significant_bits(self) -> u64 {\n        match self {\n            Natural(Small(small)) => small.significant_bits(),\n            Natural(Large(limbs)) => limbs_significant_bits(limbs),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::{Natural, limb_to_bit_count};\nuse crate::platform::Limb;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::slices::slice_leading_zeros;\n\n// Interpreting a slice of `Limb`s as the limbs of a `Natural` in ascending order, returns the\n// number of trailing zeros in the binary expansion of a `Natural` (equivalently, the multiplicity\n// of 2 in its prime factorization). The limbs cannot be empty or all zero.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` only contains zeros.\npub_crate_test! {limbs_trailing_zeros(xs: &[Limb]) -> u64 {\n    let zeros = slice_leading_zeros(xs);\n    let remaining_zeros = TrailingZeros::trailing_zeros(xs[zeros]);\n    limb_to_bit_count(zeros)+ remaining_zeros\n}}\n\nimpl Natural {\n    /// Returns the number of trailing zeros in the binary expansion of a [`Natural`] (equivalently,\n    /// the multiplicity of 2 in its prime factorization), or `None` is the [`Natural`] is 0.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::ZERO.trailing_zeros(), None);\n    /// assert_eq!(Natural::from(3u32).trailing_zeros(), Some(0));\n    /// assert_eq!(Natural::from(72u32).trailing_zeros(), Some(3));\n    /// assert_eq!(Natural::from(100u32).trailing_zeros(), Some(2));\n    /// assert_eq!(Natural::from(10u32).pow(12).trailing_zeros(), Some(12));\n    /// ```\n    pub fn trailing_zeros(&self) -> Option<u64> {\n        match self {\n            &Self::ZERO => None,\n            Self(Small(small)) => Some(TrailingZeros::trailing_zeros(*small)),\n            Self(Large(limbs)) => Some(limbs_trailing_zeros(limbs)),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse alloc::vec::Vec;\nuse core::mem::swap;\nuse core::ops::{BitXor, BitXorAssign};\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, returns the\n// limbs of the bitwise xor of the `Natural` and a `Limb`. `xs` cannot be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_xor_limb(xs: &[Limb], y: Limb) -> Vec<Limb> {\n    let mut result = xs.to_vec();\n    limbs_xor_limb_in_place(&mut result, y);\n    result\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the bitwise xor of the `Natural` and a `Limb` to an output slice. The output slice must\n// be at least as long as the input slice. `xs` cannot be empty.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `out` is shorter than `xs` or if `xs` is empty.\npub_test! {limbs_xor_limb_to_out(out: &mut [Limb], xs: &[Limb], y: Limb) {\n    out[..xs.len()].copy_from_slice(xs);\n    limbs_xor_limb_in_place(out, y);\n}}\n\n// Interpreting a slice of `Limb`s as the limbs (in ascending order) of a `Natural`, writes the\n// limbs of the bitwise xor of the `Natural` and a `Limb` to the input slice. `xs` cannot be empty.\n//\n// # Worst-case complexity\n// Constant time and additional memory.\n//\n// # Panics\n// Panics if `xs` is empty.\npub_test! {limbs_xor_limb_in_place(xs: &mut [Limb], y: Limb) {\n    xs[0] ^= y;\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, returns a `Vec` of the limbs of the bitwise xor of the `Natural`s. The length of the\n// result is the length of one of the input slices.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// This is equivalent to `mpn_xor_n` from `gmp-impl.h`, GMP 6.2.1, where `rp` is returned.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\npub_test! {limbs_xor_same_length(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    assert_eq!(xs.len(), ys.len());\n    xs.iter().zip(ys.iter()).map(|(x, y)| x ^ y).collect()\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, returns a\n// `Vec` of the limbs of the bitwise xor of the `Natural`s. The length of the result is the length\n// of the longer input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where `res` is returned and both\n// inputs are non-negative.\npub_test! {limbs_xor(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let mut result;\n    if xs_len >= ys_len {\n        result = limbs_xor_same_length(&xs[..ys_len], ys);\n        result.extend_from_slice(&xs[ys_len..]);\n    } else {\n        result = limbs_xor_same_length(xs, &ys[..xs_len]);\n        result.extend_from_slice(&ys[xs_len..]);\n    }\n    result\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise xor of the `Natural`s to an output slice. The output\n// must be at least as long as one of the input slices.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths or if `out` is too short.\n//\n// This is equivalent to `mpn_xor_n` from `gmp-impl.h`, GMP 6.2.1.\npub_test! {limbs_xor_same_length_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let len = xs.len();\n    assert_eq!(len, ys.len());\n    assert!(out.len() >= len);\n    for (z, (x, y)) in out.iter_mut().zip(xs.iter().zip(ys.iter())) {\n        *z = x ^ y;\n    }\n}}\n\n// Interpreting two slices of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the bitwise xor of the `Natural`s to an output slice. The output must be at least as\n// long as the longer input slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `max(xs.len(), ys.len())`.\n//\n// # Panics\n// Panics if `out` is too short.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where both inputs are non-negative.\npub_test! {limbs_xor_to_out(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len >= ys_len {\n        assert!(out.len() >= xs_len);\n        limbs_xor_same_length_to_out(out, &xs[..ys_len], ys);\n        out[ys_len..xs_len].copy_from_slice(&xs[ys_len..]);\n    } else {\n        assert!(out.len() >= ys_len);\n        limbs_xor_same_length_to_out(out, xs, &ys[..xs_len]);\n        out[xs_len..ys_len].copy_from_slice(&ys[xs_len..]);\n    }\n}}\n\n// Interpreting two equal-length slices of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise xor of the `Natural`s to the first (left) slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `xs.len()`.\n//\n// # Panics\n// Panics if `xs` and `ys` have different lengths.\n//\n// This is equivalent to `mpn_xor_n` from `gmp-impl.h`, GMP 6.2.1, where `rp == up`.\npub_test! {limbs_xor_same_length_in_place_left(xs: &mut [Limb], ys: &[Limb]) {\n    assert_eq!(xs.len(), ys.len());\n    for (x, y) in xs.iter_mut().zip(ys.iter()) {\n        *x ^= y;\n    }\n}}\n\n// Interpreting a `Vec` of `Limb`s and a slice of `Limb`s as the limbs (in ascending order) of two\n// `Natural`s, writes the limbs of the bitwise xor of the `Natural`s to the `Vec`. If `ys` is longer\n// than `xs`, `xs` will be extended.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ys.len()`.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where `res == op1` and both inputs\n// are non-negative.\n#[doc(hidden)]\npub fn limbs_xor_in_place_left(xs: &mut Vec<Limb>, ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    if xs_len >= ys_len {\n        limbs_xor_same_length_in_place_left(&mut xs[..ys_len], ys);\n    } else {\n        limbs_xor_same_length_in_place_left(xs, &ys[..xs_len]);\n        xs.extend_from_slice(&ys[xs_len..]);\n    }\n}\n\n// Interpreting two `Vec`s of `Limb`s as the limbs (in ascending order) of two `Natural`s, writes\n// the limbs of the bitwise xor of the `Natural`s to the longer slice (or the first one, if they are\n// equally long). Returns a `bool` which is `false` when the output is to the first slice and `true`\n// when it's to the second slice.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `min(xs.len(), ys.len())`.\n//\n// This is equivalent to `mpz_xor` from `mpz/xor.c`, GMP 6.2.1, where both inputs are non-negative\n// and the result is written to the longer input slice.\n#[doc(hidden)]\npub fn limbs_xor_in_place_either(xs: &mut [Limb], ys: &mut [Limb]) -> bool {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let right = xs_len < ys_len;\n    if right {\n        limbs_xor_same_length_in_place_left(&mut ys[..xs_len], xs);\n    } else {\n        limbs_xor_same_length_in_place_left(&mut xs[..ys_len], ys);\n    }\n    right\n}\n\nimpl Natural {\n    #[inline]\n    fn xor_limb(mut self, other: Limb) -> Self {\n        self.xor_assign_limb(other);\n        self\n    }\n\n    fn xor_limb_ref(&self, other: Limb) -> Self {\n        Self(match self {\n            Self(Small(small)) => Small(small ^ other),\n            Self(Large(limbs)) => Large(limbs_xor_limb(limbs, other)),\n        })\n    }\n\n    fn xor_assign_limb(&mut self, other: Limb) {\n        match self {\n            Self(Small(small)) => *small ^= other,\n            Self(Large(limbs)) => limbs_xor_limb_in_place(limbs, other),\n        }\n    }\n}\n\nimpl BitXor<Self> for Natural {\n    type Output = Self;\n\n    /// Takes the bitwise xor of two [`Natural`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) ^ Natural::from(456u32), 435);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) ^ (Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     8191\n    /// );\n    /// ```\n    #[inline]\n    fn bitxor(mut self, other: Self) -> Self {\n        self ^= other;\n        self\n    }\n}\n\nimpl<'a> BitXor<&'a Self> for Natural {\n    type Output = Self;\n\n    /// Takes the bitwise xor of two [`Natural`]s, taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(Natural::from(123u32) ^ &Natural::from(456u32), 435);\n    /// assert_eq!(\n    ///     Natural::from(10u32).pow(12) ^ &(Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     8191\n    /// );\n    /// ```\n    #[inline]\n    fn bitxor(mut self, other: &'a Self) -> Self {\n        self ^= other;\n        self\n    }\n}\n\nimpl BitXor<Natural> for &Natural {\n    type Output = Natural;\n\n    /// Takes the bitwise xor of two [`Natural`]s, taking the first by reference and the second by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) ^ Natural::from(456u32), 435);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) ^ (Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     8191\n    /// );\n    /// ```\n    #[inline]\n    fn bitxor(self, mut other: Natural) -> Natural {\n        other ^= self;\n        other\n    }\n}\n\nimpl BitXor<&Natural> for &Natural {\n    type Output = Natural;\n\n    /// Takes the bitwise xor of two [`Natural`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// assert_eq!(&Natural::from(123u32) ^ &Natural::from(456u32), 435);\n    /// assert_eq!(\n    ///     &Natural::from(10u32).pow(12) ^ &(Natural::from(10u32).pow(12) - Natural::ONE),\n    ///     8191\n    /// );\n    /// ```\n    fn bitxor(self, other: &Natural) -> Natural {\n        match (self, other) {\n            (x, &Natural(Small(y))) => x.xor_limb_ref(y),\n            (&Natural(Small(x)), y) => y.xor_limb_ref(x),\n            (Natural(Large(xs)), Natural(Large(ys))) => {\n                Natural::from_owned_limbs_asc(limbs_xor(xs, ys))\n            }\n        }\n    }\n}\n\nimpl BitXorAssign<Self> for Natural {\n    /// Bitwise-xors a [`Natural`] with another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x ^= Natural::from(0x0000000fu32);\n    /// x ^= Natural::from(0x00000f00u32);\n    /// x ^= Natural::from(0x000f_0000u32);\n    /// x ^= Natural::from(0x0f000000u32);\n    /// assert_eq!(x, 0x0f0f_0f0f);\n    /// ```\n    fn bitxor_assign(&mut self, mut other: Self) {\n        match (&mut *self, &mut other) {\n            (_, Self(Small(y))) => self.xor_assign_limb(*y),\n            (Self(Small(x)), _) => *self = other.xor_limb(*x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                if limbs_xor_in_place_either(xs, ys) {\n                    swap(xs, ys);\n                }\n                self.trim();\n            }\n        }\n    }\n}\n\nimpl<'a> BitXorAssign<&'a Self> for Natural {\n    /// Bitwise-xors a [`Natural`] with another [`Natural`] in place, taking the [`Natural`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x \\oplus y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    ///\n    /// let mut x = Natural::ZERO;\n    /// x |= Natural::from(0x0000000fu32);\n    /// x |= Natural::from(0x00000f00u32);\n    /// x |= Natural::from(0x000f_0000u32);\n    /// x |= Natural::from(0x0f000000u32);\n    /// assert_eq!(x, 0x0f0f_0f0f);\n    /// ```\n    fn bitxor_assign(&mut self, other: &'a Self) {\n        match (&mut *self, other) {\n            (_, Self(Small(y))) => self.xor_assign_limb(*y),\n            (Self(Small(x)), _) => *self = other.xor_limb_ref(*x),\n            (Self(Large(xs)), Self(Large(ys))) => {\n                limbs_xor_in_place_left(xs, ys);\n                self.trim();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/natural/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::platform::Limb;\nuse alloc::string::String;\nuse alloc::vec::Vec;\n#[cfg(feature = \"doc-images\")]\nuse embed_doc_image::embed_doc_image;\nuse malachite_base::comparison::traits::Min;\nuse malachite_base::named::Named;\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShl, ShrRound};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::slices::slice_trailing_zeros;\n\n/// A natural (non-negative) integer.\n///\n/// Any `Natural` small enough to fit into a [`Limb`](crate#limbs) is represented inline. Only\n/// `Natural`s outside this range incur the costs of heap-allocation.\n#[cfg_attr(\n    feature = \"doc-images\",\n    embed_doc_image(\"natural-mem-layout\", \"images/natural-mem-layout.svg\")\n)]\n#[derive(Clone, Eq, Hash, PartialEq)]\n#[cfg_attr(feature = \"serde\", derive(Deserialize, Serialize))]\n#[cfg_attr(\n    feature = \"serde\",\n    serde(try_from = \"SerdeNatural\", into = \"SerdeNatural\")\n)]\npub struct Natural(pub(crate) InnerNatural);\n\n// We want to limit the visibility of the `Small` and `Large` constructors to within this crate. To\n// do this, we wrap the `InnerNatural` enum in a struct that gets compiled away.\n#[derive(Clone, Eq, Hash, PartialEq)]\npub(crate) enum InnerNatural {\n    Small(Limb),\n    Large(Vec<Limb>),\n}\n\n#[cfg_attr(feature = \"serde\", derive(Serialize, Deserialize))]\n#[cfg_attr(feature = \"serde\", serde(transparent))]\npub(crate) struct SerdeNatural(String);\n\nimpl Natural {\n    // If a `Natural` is `Large` but is small enough to be `Small`, make it `Small`.\n    fn demote_if_small(&mut self) {\n        if let Self(Large(limbs)) = self {\n            match limbs.len() {\n                0 => *self = Self::ZERO,\n                1 => *self = Self(Small(limbs[0])),\n                _ => {}\n            }\n        }\n    }\n\n    // If a `Natural` is `Small`, make it `Large`. Return a reference to the `Limb` vector.\n    pub(crate) fn promote_in_place(&mut self) -> &mut Vec<Limb> {\n        if let Self(Small(x)) = self {\n            *self = Self(Large(vec![*x]));\n        }\n        if let Self(Large(xs)) = self {\n            xs\n        } else {\n            unreachable!();\n        }\n    }\n\n    pub(crate) fn trim(&mut self) {\n        if let Self(Large(limbs)) = self {\n            let trailing_zero_count = slice_trailing_zeros(limbs);\n            if trailing_zero_count != 0 {\n                let len = limbs.len();\n                limbs.truncate(len - trailing_zero_count);\n            }\n        }\n        self.demote_if_small();\n    }\n\n    // Returns true iff `self` is valid. To be valid,\n    //\n    // `self` can only be `Large` when it is at least $2^W$, and cannot have leading zero limbs. All\n    // `Natural`s must be valid.\n    #[cfg(feature = \"test_build\")]\n    pub fn is_valid(&self) -> bool {\n        match self {\n            Self(Small(_)) => true,\n            Self(Large(xs)) => xs.len() > 1 && *xs.last().unwrap() != 0,\n        }\n    }\n}\n\n/// The constant 0.\nimpl Zero for Natural {\n    const ZERO: Self = Self(Small(0));\n}\n\n/// The constant 1.\nimpl One for Natural {\n    const ONE: Self = Self(Small(1));\n}\n\n/// The constant 2.\nimpl Two for Natural {\n    const TWO: Self = Self(Small(2));\n}\n\n/// The minimum value of a [`Natural`], 0.\nimpl Min for Natural {\n    const MIN: Self = Self::ZERO;\n}\n\n#[cfg(feature = \"float_helpers\")]\nimpl Natural {\n    pub const HIGH_BIT: Self = Self(Small(1 << (Limb::WIDTH - 1)));\n}\n\nimpl Default for Natural {\n    /// The default value of a [`Natural`], 0.\n    fn default() -> Self {\n        Self::ZERO\n    }\n}\n\n// Implements `Named` for `Natural`.\nimpl_named!(Natural);\n\n#[doc(hidden)]\n#[inline]\npub fn limb_to_bit_count(n: usize) -> u64 {\n    u64::wrapping_from(n)\n        .arithmetic_checked_shl(Limb::LOG_WIDTH)\n        .unwrap()\n}\n\n#[doc(hidden)]\n#[inline]\npub fn bit_to_limb_count_floor(n: u64) -> usize {\n    usize::exact_from(n >> Limb::LOG_WIDTH)\n}\n\n#[doc(hidden)]\n#[inline]\npub fn bit_to_limb_count_ceiling(n: u64) -> usize {\n    usize::exact_from(n.shr_round(Limb::LOG_WIDTH, Ceiling).0)\n}\n\n#[doc(hidden)]\npub const LIMB_HIGH_BIT: Limb = 1 << (Limb::WIDTH - 1);\n\n/// Traits for arithmetic.\npub mod arithmetic;\n/// Traits for comparing [`Natural`]s for equality or order.\npub mod comparison;\n/// Traits for converting to and from [`Natural`]s, converting to and from strings, and extracting\n/// digits.\npub mod conversion;\n/// Iterators that generate [`Natural`]s without repetition.\npub mod exhaustive;\n/// Traits for generating primes, primality testing, and factorization (TODO!)\npub mod factorization;\n/// Traits for logic and bit manipulation.\npub mod logic;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`Natural`]s randomly.\npub mod random;\n"
  },
  {
    "path": "malachite-nz/src/natural/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::mod_power_of_2::limbs_slice_mod_power_of_2_in_place;\nuse crate::natural::logic::bit_access::limbs_slice_set_bit;\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, PowerOf2, RoundToMultipleOfPowerOf2, ShrRound,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::iterators::iterator_to_bit_chunks;\nuse malachite_base::num::logic::traits::{BitAccess, LowMask, SignificantBits};\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, geometric_random_positive_unsigneds,\n    geometric_random_unsigned_inclusive_range, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::striped::{StripedBitSource, get_striped_unsigned_vec};\nuse malachite_base::num::random::{RandomPrimitiveInts, random_primitive_ints};\nuse malachite_base::random::Seed;\nuse malachite_base::rounding_modes::RoundingMode::*;\n\n/// Generates a random [`Natural`] with a given maximum bit length.\n///\n/// The [`Natural`] is chosen uniformly from $[0, 2^b)$; [`Natural`]s with bit lengths smaller than\n/// the maximum may also be generated.\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\frac{1}{2^b} & \\text{if} \\\\quad 0 \\\\leq n < 2^b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is `bits`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::get_random_natural_with_up_to_bits;\n///\n/// assert_eq!(\n///     get_random_natural_with_up_to_bits(&mut random_primitive_ints(EXAMPLE_SEED), 100)\n///         .to_string(),\n///     \"976558340558744279591984426865\"\n/// );\n/// ```\npub fn get_random_natural_with_up_to_bits(xs: &mut RandomPrimitiveInts<u64>, bits: u64) -> Natural {\n    if bits == 0 {\n        return Natural::ZERO;\n    }\n    #[cfg(feature = \"32_bit_limbs\")]\n    let mut xs = iterator_to_bit_chunks(\n        xs.take(usize::exact_from(bits.shr_round(u64::LOG_WIDTH, Ceiling).0)),\n        u64::WIDTH,\n        u32::WIDTH,\n    )\n    .map(Option::unwrap)\n    .collect_vec();\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    let mut xs = xs\n        .take(usize::exact_from(bits.shr_round(u64::LOG_WIDTH, Ceiling).0))\n        .collect_vec();\n    limbs_slice_mod_power_of_2_in_place(&mut xs, bits);\n    Natural::from_owned_limbs_asc(xs)\n}\n\n/// Generates a random [`Natural`] with a given bit length.\n///\n/// The [`Natural`] is 0 if $b$ is 0, or else chosen uniformly from $[2^{b-1}, 2^b)$.\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     1 & \\text{if} \\\\quad b = n = 0, \\\\\\\\\n///     \\frac{1}{2^{b-1}} & \\text{if} \\\\quad b \\neq 0 \\\\ \\text{and} \\\\ 2^{b-1} \\leq n < 2^b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is `bits`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::get_random_natural_with_bits;\n///\n/// assert_eq!(\n///     get_random_natural_with_bits(&mut random_primitive_ints(EXAMPLE_SEED), 100).to_string(),\n///     \"976558340558744279591984426865\"\n/// );\n/// ```\npub fn get_random_natural_with_bits(xs: &mut RandomPrimitiveInts<u64>, bits: u64) -> Natural {\n    if bits == 0 {\n        return Natural::ZERO;\n    }\n    #[cfg(feature = \"32_bit_limbs\")]\n    let mut xs = iterator_to_bit_chunks(\n        xs.take(usize::exact_from(bits.shr_round(u64::LOG_WIDTH, Ceiling).0)),\n        u64::WIDTH,\n        u32::WIDTH,\n    )\n    .map(Option::unwrap)\n    .collect_vec();\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    let mut xs = xs\n        .take(usize::exact_from(bits.shr_round(u64::LOG_WIDTH, Ceiling).0))\n        .collect_vec();\n    limbs_slice_mod_power_of_2_in_place(&mut xs, bits);\n    limbs_slice_set_bit(&mut xs, bits - 1);\n    Natural::from_owned_limbs_asc(xs)\n}\n\n/// Generates a striped random [`Natural`] with a given maximum bit length.\n///\n/// [`Natural`]s with bit lengths smaller than the maximum may also be generated.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is `bits`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::get_striped_random_natural_with_up_to_bits;\n///\n/// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 10, 1);\n/// // 0x3fffff80000ffc007ffe03ff8\n/// assert_eq!(\n///     get_striped_random_natural_with_up_to_bits(&mut bit_source, 100).to_string(),\n///     \"316912612278197474676665499640\"\n/// );\n/// ```\npub fn get_striped_random_natural_with_up_to_bits(xs: &mut StripedBitSource, bits: u64) -> Natural {\n    if bits == 0 {\n        Natural::ZERO\n    } else {\n        Natural::from_owned_limbs_asc(get_striped_unsigned_vec(xs, bits))\n    }\n}\n\n/// Generates a striped random [`Natural`] with a given bit length.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is `bits`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::get_striped_random_natural_with_bits;\n///\n/// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 10, 1);\n/// // 0xbfffff80000ffc007ffe03ff8\n/// assert_eq!(\n///     get_striped_random_natural_with_bits(&mut bit_source, 100).to_string(),\n///     \"950737912392312175425017102328\"\n/// );\n/// ```\npub fn get_striped_random_natural_with_bits(xs: &mut StripedBitSource, bits: u64) -> Natural {\n    if bits == 0 {\n        Natural::ZERO\n    } else {\n        let mut xs = get_striped_unsigned_vec(xs, bits);\n        limbs_slice_set_bit(&mut xs, bits - 1);\n        Natural::from_owned_limbs_asc(xs)\n    }\n}\n\n/// Generates random [`Natural`]s, given an iterator of random bit lengths.\n#[derive(Clone, Debug)]\npub struct RandomNaturals<I: Iterator<Item = u64>> {\n    bits: I,\n    limbs: RandomPrimitiveInts<u64>,\n}\n\nimpl<I: Iterator<Item = u64>> Iterator for RandomNaturals<I> {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        Some(get_random_natural_with_bits(\n            &mut self.limbs,\n            self.bits.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates random [`Natural`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 0. Then a [`Natural`] is\n/// chosen uniformly among all [`Natural`]s with that bit length. The resulting distribution\n/// resembles a Pareto distribution. It has no mean or higher-order statistics (unless $m < 1$,\n/// which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     \\\\frac{1}{m + 1} & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     \\\\frac{2}{m+1} \\\\left ( \\\\frac{m}{2(m+1)} \\\\right ) ^ {\\\\lfloor \\\\log_2 n \\\\rfloor + 1} &\n///         \\text{if} \\\\quad \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, or, if after being reduced\n/// to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::random_naturals;\n///\n/// assert_eq!(\n///     prefix_to_string(random_naturals(EXAMPLE_SEED, 32, 1), 10),\n///     \"[20431208470830262, 2777240, 114, 12184833305054, 1121025855008623490210, \\\n///     13478874522577592, 115311695, 7, 18, 54522366353, ...]\"\n/// )\n/// ```\npub fn random_naturals(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomNaturals<GeometricRandomNaturalValues<u64>> {\n    RandomNaturals {\n        bits: geometric_random_unsigneds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n    }\n}\n\n/// Generates random positive [`Natural`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. Then a [`Natural`] is\n/// chosen uniformly among all [`Natural`]s with that bit length. The resulting distribution\n/// resembles a Pareto distribution. It has no mean or higher-order statistics (unless $m < 2$,\n/// which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     0 & \\text{if} \\\\quad n = 0, \\\\\\\\\n///     \\frac{1}{m} \\left ( \\frac{m-1}{2m} \\right ) ^ {\\lfloor \\log_2 n \\rfloor} &\n///         \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::random_positive_naturals;\n///\n/// assert_eq!(\n///     prefix_to_string(random_positive_naturals(EXAMPLE_SEED, 32, 1), 10),\n///     \"[22, 4, 178, 55845661150, 93254818, 7577967529619388, 8, 11316951483471, 11, \\\n///     1005760138411689342464923704482, ...]\"\n/// )\n/// ```\npub fn random_positive_naturals(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomNaturals<GeometricRandomNaturalValues<u64>> {\n    RandomNaturals {\n        bits: geometric_random_positive_unsigneds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n    }\n}\n\n/// Generates striped random [`Natural`]s, given an iterator of random bit lengths.\n#[derive(Clone, Debug)]\npub struct StripedRandomNaturals<I: Iterator<Item = u64>> {\n    bits: I,\n    bit_source: StripedBitSource,\n}\n\nimpl<I: Iterator<Item = u64>> Iterator for StripedRandomNaturals<I> {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        Some(get_striped_random_natural_with_bits(\n            &mut self.bit_source,\n            self.bits.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates striped random [`Natural`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 0. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Natural`] is generated from the sequence.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or, if\n/// after being reduced to lowest terms, their sum is greater than or equal to $2^{64}$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::striped_random_naturals;\n///\n/// assert_eq!(\n///     prefix_to_string(striped_random_naturals(EXAMPLE_SEED, 16, 1, 32, 1), 10),\n///     \"[18014656207519744, 2228160, 64, 17592184995840, 1179440951012584587264, \\\n///     9007749010526207, 67108864, 5, 24, 34359738879, ...]\"\n/// )\n/// ```\npub fn striped_random_naturals(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomNaturals<GeometricRandomNaturalValues<u64>> {\n    StripedRandomNaturals {\n        bits: geometric_random_unsigneds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Generates striped random positive [`Natural`]s with a specified mean bit length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. A striped bit\n/// sequence with the given stripe parameter is generated and truncated at the bit length. The\n/// highest bit is forced to be 1, and the [`Natural`] is generated from the sequence.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::striped_random_positive_naturals;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_positive_naturals(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[16, 4, 128, 34391195648, 75493376, 9007199120523391, 8, 8796094070783, 8, \\\n///     950737950171027935941967741439, ...]\"\n/// )\n/// ```\npub fn striped_random_positive_naturals(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomNaturals<GeometricRandomNaturalValues<u64>> {\n    StripedRandomNaturals {\n        bits: geometric_random_positive_unsigneds(\n            seed.fork(\"bits\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n\n/// Uniformly generates random [`Natural`]s less than a positive limit.\n#[derive(Clone, Debug)]\npub struct RandomNaturalsLessThan {\n    bits: u64,\n    limit: Natural,\n    limbs: RandomPrimitiveInts<u64>,\n}\n\nimpl Iterator for RandomNaturalsLessThan {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        loop {\n            let x = get_random_natural_with_up_to_bits(&mut self.limbs, self.bits);\n            if x < self.limit {\n                return Some(x);\n            }\n        }\n    }\n}\n\n/// Uniformly generates random [`Natural`]s less than a positive `limit`.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{\\\\ell} & \\text{if} \\\\quad x < \\\\ell, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n/// where $\\ell$ is `limit`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `limit.significant_bits()`.\n///\n/// # Panics\n/// Panics if `limit` is 0.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::random_naturals_less_than;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_naturals_less_than(EXAMPLE_SEED, Natural::from(10u32)),\n///         10\n///     ),\n///     \"[1, 7, 5, 7, 9, 2, 8, 2, 4, 6, ...]\"\n/// )\n/// ```\npub fn random_naturals_less_than(seed: Seed, limit: Natural) -> RandomNaturalsLessThan {\n    assert_ne!(limit, 0);\n    RandomNaturalsLessThan {\n        bits: limit.ceiling_log_base_2(),\n        limit,\n        limbs: random_primitive_ints(seed),\n    }\n}\n\n/// Generates a random [`Natural`] less than a given limit.\n///\n/// The [`Natural`] is chosen uniformly from $[0, \\ell)$, where $\\ell$ is the provided limit.\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     1/\\ell & \\text{if} 0\\leq n<\\ell, \\\\\\\\\n///     0 & \\\\text{otherwise},\n/// \\\\end{cases}\n/// $$\n/// where $\\ell$ is `limit`.\n///\n/// # Expected complexity\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and `n` is `limit.significant_bits()`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::arithmetic::traits::Pow;\n/// use malachite_base::num::random::random_primitive_ints;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::get_random_natural_less_than;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     get_random_natural_less_than(\n///         &mut random_primitive_ints(EXAMPLE_SEED),\n///         &Natural::from(10u32).pow(20)\n///     )\n///     .to_string(),\n///     \"27702062732568241671\"\n/// );\n/// ```\npub fn get_random_natural_less_than(\n    limbs: &mut RandomPrimitiveInts<u64>,\n    limit: &Natural,\n) -> Natural {\n    assert_ne!(*limit, 0);\n    let bits = limit.ceiling_log_base_2();\n    loop {\n        let x = get_random_natural_with_up_to_bits(limbs, bits);\n        if x < *limit {\n            return x;\n        }\n    }\n}\n\n/// Uniformly generates random [`Natural`]s in an interval.\n#[derive(Clone, Debug)]\npub struct UniformRandomNaturalRange {\n    xs: RandomNaturalsLessThan,\n    a: Natural,\n}\n\nimpl Iterator for UniformRandomNaturalRange {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        self.xs.next().map(|x| &self.a + x)\n    }\n}\n\n/// Uniformly generates random [`Natural`]s in the half-open interval $[a, b)$.\n///\n/// $a$ must be less than $b$.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a} & \\text{if} \\\\quad a \\leq x < b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::uniform_random_natural_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         uniform_random_natural_range(EXAMPLE_SEED, Natural::from(10u32), Natural::from(100u32)),\n///         10\n///     ),\n///     \"[97, 17, 94, 37, 56, 32, 96, 11, 17, 39, ...]\"\n/// )\n/// ```\npub fn uniform_random_natural_range(\n    seed: Seed,\n    a: Natural,\n    b: Natural,\n) -> UniformRandomNaturalRange {\n    assert!(a < b);\n    UniformRandomNaturalRange {\n        xs: random_naturals_less_than(seed, b - &a),\n        a,\n    }\n}\n\n/// Uniformly generates random [`Natural`]s in the closed interval $[a, b]$.\n///\n/// $a$ must be less than or equal to $b$.\n///\n/// $$\n/// P(x) = \\\\begin{cases}\n///     \\frac{1}{b-a+1} & \\text{if} \\\\quad a \\leq x \\leq b, \\\\\\\\\n///     0 & \\\\text{otherwise}.\n/// \\\\end{cases}\n/// $$\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::uniform_random_natural_inclusive_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         uniform_random_natural_inclusive_range(\n///             EXAMPLE_SEED,\n///             Natural::from(10u32),\n///             Natural::from(99u32)\n///         ),\n///         10\n///     ),\n///     \"[97, 17, 94, 37, 56, 32, 96, 11, 17, 39, ...]\"\n/// )\n/// ```\n#[inline]\npub fn uniform_random_natural_inclusive_range(\n    seed: Seed,\n    a: Natural,\n    b: Natural,\n) -> UniformRandomNaturalRange {\n    assert!(a <= b);\n    uniform_random_natural_range(seed, a, b + Natural::ONE)\n}\n\n/// Generates random [`Natural`]s greater than or equal to a lower bound.\n#[derive(Clone, Debug)]\npub struct RandomNaturalRangeToInfinity {\n    min_bits: u64,\n    bits: GeometricRandomNaturalValues<u64>,\n    limbs: RandomPrimitiveInts<u64>,\n    min_bit_xs: UniformRandomNaturalRange,\n}\n\nimpl Iterator for RandomNaturalRangeToInfinity {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        let bits = self.bits.next().unwrap();\n        if bits == self.min_bits {\n            self.min_bit_xs.next()\n        } else {\n            Some(get_random_natural_with_bits(&mut self.limbs, bits))\n        }\n    }\n}\n\n/// Generates random [`Natural`]s greater than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the [`Natural`]s is specified; it must be greater than the bit length\n/// of $a$. $m$ is equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The actual bit length is chosen from a geometric distribution with lower bound $a$ and mean $m$.\n/// Then a [`Natural`] is chosen uniformly among all [`Natural`]s with that bit length that are\n/// greater than or equal to $a$. The resulting distribution has no mean or higher-order statistics\n/// (unless $a < m < a + 1$, which is not typical).\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     0 & \\text{if} \\\\quad n < a, \\\\\\\\\n///     \\frac{1}{m+1} & \\text{if} \\\\quad a = n = 0, \\\\\\\\\n///     \\frac{m}{(m+1)^2}\\left ( \\frac{m}{2(m+1)} \\right )^\\nu &\n///         \\text{if} \\\\quad 0 = a < n, \\\\\\\\\n///     \\frac{1}{(2^{\\nu + 1}-a)(m-\\alpha)} &\n///         \\text{if} \\\\quad 0 < a \\\\ \\text{and} \\\\ \\alpha = \\nu, \\\\\\\\\n///     \\frac{\\left ( 1 - \\frac{1}{\\alpha-m}\\right )^{\\nu-\\alpha}}{2^\\nu(m-\\alpha)} &\n///         \\text{if} \\\\quad 0 < a \\\\ \\text{and} \\\\ \\alpha < \\nu, \\\\\\\\\n/// \\\\end{cases}\n/// $$\n/// where $\\alpha = \\lfloor \\log_2 a \\rfloor$ and $\\nu = \\lfloor \\log_2 n \\rfloor$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if their ratio is less than\n/// or equal to $a$, or if they are too large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::random_natural_range_to_infinity;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_natural_range_to_infinity(EXAMPLE_SEED, Natural::from(1000u32), 20, 1),\n///         10\n///     ),\n///     \"[3254, 4248, 163506, 1189717027294, 5282, 12220, 60088, 1016911, 5772451, 5473099750562, \\\n///     ...]\"\n/// )\n/// ```\npub fn random_natural_range_to_infinity(\n    seed: Seed,\n    a: Natural,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomNaturalRangeToInfinity {\n    let min_bits = a.significant_bits();\n    RandomNaturalRangeToInfinity {\n        min_bits,\n        bits: geometric_random_unsigned_inclusive_range(\n            seed.fork(\"bits\"),\n            min_bits,\n            u64::MAX,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n        min_bit_xs: uniform_random_natural_range(\n            seed.fork(\"min_bit_xs\"),\n            a,\n            Natural::power_of_2(min_bits),\n        ),\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct RandomNaturalRangeMultipleOrders {\n    min_bits: u64,\n    max_bits: u64,\n    bits: GeometricRandomNaturalValues<u64>,\n    limbs: RandomPrimitiveInts<u64>,\n    min_bit_xs: UniformRandomNaturalRange,\n    max_bit_xs: UniformRandomNaturalRange,\n}\n\nimpl Iterator for RandomNaturalRangeMultipleOrders {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        let bits = self.bits.next().unwrap();\n        if bits == self.min_bits {\n            self.min_bit_xs.next()\n        } else if bits == self.max_bits {\n            self.max_bit_xs.next()\n        } else {\n            Some(get_random_natural_with_bits(&mut self.limbs, bits))\n        }\n    }\n}\n\n/// Generates random [`Natural`]s in an interval.\n#[derive(Clone, Debug)]\n#[allow(clippy::large_enum_variant)]\npub enum RandomNaturalRange {\n    SingleOrder(UniformRandomNaturalRange),\n    MultipleOrders(RandomNaturalRangeMultipleOrders),\n}\n\nimpl Iterator for RandomNaturalRange {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        match self {\n            Self::SingleOrder(xs) => xs.next(),\n            Self::MultipleOrders(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates random [`Natural`]s in the half-open interval $[a, b)$.\n///\n/// In general, the [`Natural`]s are not generated uniformly; for that, use\n/// [`uniform_random_natural_range`]. Instead, [`Natural`]s with smaller bit lengths are generated\n/// more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_bits_numerator / mean_bits_denominator`. It is not actually the mean bit length, though it\n/// approaches the mean bit length as $\\log (b/a)$ approaches infinity. $m$ must be greater than\n/// $a$, but it may be arbitrarily large. The smaller it is, the more quickly the probabilities\n/// decrease as bit length increases. The larger it is, the more closely the distribution approaches\n/// a uniform distribution over the bit lengths.\n///\n/// Once a bit length is selected, the [`Natural`] is chosen uniformly from all [`Natural`]s with\n/// that bit length that are in $[a, b)$.\n///\n/// To obtain the probability mass function, adjust $b$ and see [`random_natural_inclusive_range`].\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(m) = O(m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_bits_numerator +\n/// mean_bits_denominator`, and $m$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if $a \\geq b$, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if their\n/// ratio is less than or equal to $a$, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::random_natural_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_natural_range(\n///             EXAMPLE_SEED,\n///             Natural::from(1000u32),\n///             Natural::from(1000000000u32),\n///             20,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[3254, 4248, 163506, 600542, 5282, 12220, 60088, 1016911, 5772451, 2792610, ...]\"\n/// )\n/// ```\n#[inline]\npub fn random_natural_range(\n    seed: Seed,\n    a: Natural,\n    b: Natural,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomNaturalRange {\n    assert!(a < b);\n    random_natural_inclusive_range(\n        seed,\n        a,\n        b - Natural::ONE,\n        mean_bits_numerator,\n        mean_bits_denominator,\n    )\n}\n\n/// Generates random [`Natural`]s in the closed interval $[a, b]$.\n///\n/// In general, the [`Natural`]s are not generated uniformly; for that, use\n/// [`uniform_random_natural_inclusive_range`]. Instead, [`Natural`]s with smaller bit lengths are\n/// generated more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_bits_numerator / mean_bits_denominator`. It is not actually the mean bit length, though it\n/// approaches the mean bit length as $\\log (b/a)$ approaches infinity. $m$ must be greater than\n/// $a$, but it may be arbitrarily large. The smaller it is, the more quickly the probabilities\n/// decrease as bit length increases. The larger it is, the more closely the distribution approaches\n/// a uniform distribution over the bit lengths.\n///\n/// Once a bit length is selected, the [`Natural`] is chosen uniformly from all [`Natural`]s with\n/// that bit length that are in $[a, b]$.\n///\n/// $$\n/// P(n) = \\\\begin{cases}\n///     0 & \\text{if} \\\\quad n < a \\\\ \\text{or} \\\\ n > b,  \\\\\\\\\n///     1 & \\text{if} \\\\quad a = n = b = 0, \\\\\\\\\n///     \\frac{1}{b-a} & \\text{if} \\\\quad 0 < a \\\\ \\text{and} \\\\ \\alpha = \\beta, \\\\\\\\\n///     \\left \\[ (m+1)\\left ( 1-\\left (\\frac{m}{m+1}\\right )^{\\beta+2} \\right ) \\right \\]^{-1} &\n///         \\text{if} \\\\quad 0 = a = n < b \\\\\\\\\n///     (2^{\\alpha+1}-n)\\left \\[ (m-\\alpha)\\left ( 1+\\frac{1}{\\alpha-m}\\right )^{\\alpha-\\nu}-\n///         (m-\\alpha-1)\\left ( 1+\\frac{1}{\\alpha-m}\\right )^{\\beta-\\nu}\\right \\]^{-1} &\n///         \\text{if} \\\\quad 0 < a \\\\ \\text{and} \\\\ \\alpha = \\nu < \\beta, \\\\\\\\\n///     \\frac{m^{\\nu+1}(m+1)^{\\beta-\\nu}}{((m+1)^{\\beta+2}-m^{\\beta+2})(2^\\beta-n+1)} &\n///         \\text{if} \\\\quad 0 = a < n \\\\ \\text{and} \\\\ \\nu = \\beta, \\\\\\\\\n///     (n-2^\\beta+1)\\left \\[ (m-\\alpha)\\left ( 1+\\frac{1}{\\alpha-m}\\right )^{\\alpha-\\nu}-\n///         (m-\\alpha-1)\\left ( 1+\\frac{1}{\\alpha-m}\\right )^{\\beta-\\nu}\\right \\]^{-1} &\n///         \\text{if} \\\\quad 0 < a \\\\ \\text{and} \\\\ \\alpha < \\nu = \\beta, \\\\\\\\\n///     \\frac{m(m+1)^\\beta \\left ( \\frac{m}{2(m+1)}\\right )^\\nu}{(m+1)^{\\beta+2}-m^{\\beta+2}} &\n///         \\text{if} \\\\quad 0 = a < n \\\\ \\text{and} \\\\ \\nu < \\beta, \\\\\\\\\n///     2^{-\\nu}\\left \\[ (m-\\alpha)\\left ( 1+\\frac{1}{\\alpha-m}\\right )^{\\alpha-\\nu}-(m-\\alpha-1)\n///         \\left ( 1+\\frac{1}{\\alpha-m}\\right )^{\\beta-\\nu}\\right \\]^{-1} &\n///         \\text{if} \\\\quad 0 < a \\\\ \\text{and} \\\\ \\alpha < \\nu < \\beta,\n/// \\\\end{cases}\n/// $$\n/// where $\\alpha = \\lfloor \\log_2 a \\rfloor$, $\\beta = \\lfloor \\log_2 b \\rfloor$, and $\\nu =\n/// \\lfloor \\log_2 n \\rfloor$.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(m) = O(m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_bits_numerator +\n/// mean_bits_denominator`, and $m$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if $a > b$, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if their ratio\n/// is less than or equal to $a$, or if they are too large and manipulating them leads to arithmetic\n/// overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::random_natural_inclusive_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_natural_inclusive_range(\n///             EXAMPLE_SEED,\n///             Natural::from(1000u32),\n///             Natural::from(1000000000u32),\n///             20,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[3254, 4248, 163506, 600542, 5282, 12220, 60088, 1016911, 5772451, 2792610, ...]\"\n/// )\n/// ```\npub fn random_natural_inclusive_range(\n    seed: Seed,\n    a: Natural,\n    b: Natural,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomNaturalRange {\n    assert!(a <= b);\n    let min_bits = a.significant_bits();\n    let max_bits = b.significant_bits();\n    if min_bits == max_bits {\n        RandomNaturalRange::SingleOrder(uniform_random_natural_inclusive_range(seed, a, b))\n    } else {\n        RandomNaturalRange::MultipleOrders(RandomNaturalRangeMultipleOrders {\n            min_bits,\n            max_bits,\n            bits: geometric_random_unsigned_inclusive_range(\n                seed.fork(\"bits\"),\n                min_bits,\n                max_bits,\n                mean_bits_numerator,\n                mean_bits_denominator,\n            ),\n            limbs: random_primitive_ints(seed.fork(\"limbs\")),\n            min_bit_xs: uniform_random_natural_range(\n                seed.fork(\"min_bit_xs\"),\n                a,\n                Natural::power_of_2(min_bits),\n            ),\n            max_bit_xs: uniform_random_natural_inclusive_range(\n                seed.fork(\"max_bit_xs\"),\n                Natural::power_of_2(max_bits - 1),\n                b,\n            ),\n        })\n    }\n}\n\n#[inline]\nfn ranges_intersect<T: Ord>(lo_0: &T, hi_0: &T, lo: &T, hi: &T) -> bool {\n    lo <= hi_0 && lo_0 <= hi\n}\n\n/// Generates random striped [`Natural`]s from a range.\n#[derive(Clone, Debug)]\npub struct StripedRandomNaturalInclusiveRange {\n    a: Natural,\n    b: Natural,\n    lo_template: Natural,\n    hi_template: Natural,\n    next_bit: u64,\n    bit_source: StripedBitSource,\n}\n\nimpl Iterator for StripedRandomNaturalInclusiveRange {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.next_bit == 0 {\n            return Some(self.lo_template.clone());\n        }\n        let mut lo_template = self.lo_template.clone();\n        let mut hi_template = self.hi_template.clone();\n        let mut first = true;\n        let mut previous_forced = true;\n        let mut previous_bit = lo_template.get_bit(self.next_bit);\n        for next_bit in (0..self.next_bit).rev() {\n            let false_possible;\n            let true_possible;\n            if first {\n                false_possible = true;\n                true_possible = true;\n                lo_template.assign_bit(next_bit, true);\n                hi_template.assign_bit(next_bit, true);\n                first = false;\n            } else {\n                lo_template.assign_bit(next_bit, false);\n                hi_template.assign_bit(next_bit, false);\n                false_possible = ranges_intersect(&lo_template, &hi_template, &self.a, &self.b);\n                lo_template.assign_bit(next_bit, true);\n                hi_template.assign_bit(next_bit, true);\n                true_possible = ranges_intersect(&lo_template, &hi_template, &self.a, &self.b);\n            }\n            assert!(false_possible || true_possible);\n            let bit = if !false_possible {\n                previous_forced = true;\n                true\n            } else if !true_possible {\n                previous_forced = true;\n                false\n            } else {\n                if previous_forced {\n                    self.bit_source.end_block();\n                    self.bit_source.set_previous_bit(previous_bit);\n                    previous_forced = false;\n                }\n                self.bit_source.next().unwrap()\n            };\n            if !bit {\n                lo_template.assign_bit(next_bit, false);\n                hi_template.assign_bit(next_bit, false);\n            }\n            previous_bit = bit;\n        }\n        Some(lo_template)\n    }\n}\n\n/// Generates random striped [`Natural`]s in the range $[a, b)$.\n///\n/// The [`Natural`]s are generated using a striped bit sequence with mean run length $m$, which is\n/// `mean_stripe_numerator / mean_stripe_denominator`.\n///\n/// Because the [`Natural`]s are constrained to be within a certain range, the actual mean run\n/// length will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean\n/// run length.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a\\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n/// use malachite_nz::natural::random::striped_random_natural_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_natural_range(EXAMPLE_SEED, Natural::ONE, Natural::from(7u32), 4, 1)\n///             .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1, 1, 1, 110, 1, 110, 10, 11, 11, 100, ...]\"\n/// );\n/// ```\n#[inline]\npub fn striped_random_natural_range(\n    seed: Seed,\n    a: Natural,\n    b: Natural,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomNaturalInclusiveRange {\n    assert!(a < b);\n    striped_random_natural_inclusive_range(\n        seed,\n        a,\n        b - Natural::ONE,\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    )\n}\n\n/// Generates random striped [`Natural`]s in the range $[a, b]$.\n///\n/// The [`Natural`]s are generated using a striped bit sequence with mean run length $m$ =\n/// `mean_stripe_numerator / mean_stripe_denominator`.\n///\n/// Because the [`Natural`]s are constrained to be within a certain range, the actual mean run\n/// length will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean\n/// run length.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <=\n/// mean_stripe_denominator`, or if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::basic::traits::One;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n/// use malachite_nz::natural::random::striped_random_natural_inclusive_range;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_natural_inclusive_range(\n///             EXAMPLE_SEED,\n///             Natural::ONE,\n///             Natural::from(6u32),\n///             4,\n///             1\n///         )\n///         .map(|x| x.to_binary_string()),\n///         10\n///     ),\n///     \"[1, 1, 1, 110, 1, 110, 10, 11, 11, 100, ...]\"\n/// );\n/// ```\npub fn striped_random_natural_inclusive_range(\n    seed: Seed,\n    a: Natural,\n    b: Natural,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> StripedRandomNaturalInclusiveRange {\n    assert!(a <= b);\n    let diff_bits = (&a ^ &b).significant_bits();\n    let mask = Natural::low_mask(diff_bits);\n    let lo_template = (&a).round_to_multiple_of_power_of_2(diff_bits, Floor).0;\n    let hi_template = &lo_template | mask;\n    StripedRandomNaturalInclusiveRange {\n        a,\n        b,\n        lo_template,\n        hi_template,\n        next_bit: diff_bits,\n        bit_source: StripedBitSource::new(seed, mean_stripe_numerator, mean_stripe_denominator),\n    }\n}\n\n/// Generates a random striped [`Natural`] in the range $[a, b)$.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if $a\\geq b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n/// use malachite_nz::natural::random::get_striped_random_natural_from_range;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 10, 1);\n/// assert_eq!(\n///     get_striped_random_natural_from_range(\n///         &mut bit_source,\n///         Natural::from(10000u32),\n///         Natural::from(20000u32)\n///     )\n///     .to_binary_string(),\n///     \"10011100111111\"\n/// );\n/// ```\n#[inline]\npub fn get_striped_random_natural_from_range(\n    xs: &mut StripedBitSource,\n    a: Natural,\n    b: Natural,\n) -> Natural {\n    assert!(a < b);\n    get_striped_random_natural_from_inclusive_range(xs, a, b - Natural::ONE)\n}\n\n/// Generates a random striped [`Natural`] in the range $[a, b]$.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n)$\n///\n/// $M(n) = O(n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `b.significant_bits()`.\n///\n/// # Panics\n/// Panics if $a > b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::num::random::striped::StripedBitSource;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_base::strings::ToBinaryString;\n/// use malachite_nz::natural::random::get_striped_random_natural_from_inclusive_range;\n/// use malachite_nz::natural::Natural;\n///\n/// let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 10, 1);\n/// assert_eq!(\n///     get_striped_random_natural_from_inclusive_range(\n///         &mut bit_source,\n///         Natural::from(10000u32),\n///         Natural::from(19999u32)\n///     )\n///     .to_binary_string(),\n///     \"10011100111111\"\n/// );\n/// ```\n#[allow(clippy::needless_pass_by_value)]\npub fn get_striped_random_natural_from_inclusive_range(\n    xs: &mut StripedBitSource,\n    a: Natural,\n    b: Natural,\n) -> Natural {\n    assert!(a <= b);\n    let diff_bits = (&a ^ &b).significant_bits();\n    let mask = Natural::low_mask(diff_bits);\n    let lo_template = (&a).round_to_multiple_of_power_of_2(diff_bits, Floor).0;\n    let hi_template = &lo_template | mask;\n    if diff_bits == 0 {\n        return lo_template;\n    }\n    let mut lo_template = lo_template.clone();\n    let mut hi_template = hi_template.clone();\n    let mut first = true;\n    let mut previous_forced = true;\n    let mut previous_bit = lo_template.get_bit(diff_bits);\n    for next_bit in (0..diff_bits).rev() {\n        let false_possible;\n        let true_possible;\n        if first {\n            false_possible = true;\n            true_possible = true;\n            lo_template.assign_bit(next_bit, true);\n            hi_template.assign_bit(next_bit, true);\n            first = false;\n        } else {\n            lo_template.assign_bit(next_bit, false);\n            hi_template.assign_bit(next_bit, false);\n            false_possible = ranges_intersect(&lo_template, &hi_template, &a, &b);\n            lo_template.assign_bit(next_bit, true);\n            hi_template.assign_bit(next_bit, true);\n            true_possible = ranges_intersect(&lo_template, &hi_template, &a, &b);\n        }\n        assert!(false_possible || true_possible);\n        let bit = if !false_possible {\n            previous_forced = true;\n            true\n        } else if !true_possible {\n            previous_forced = true;\n            false\n        } else {\n            if previous_forced {\n                xs.end_block();\n                xs.set_previous_bit(previous_bit);\n                previous_forced = false;\n            }\n            xs.next().unwrap()\n        };\n        if !bit {\n            lo_template.assign_bit(next_bit, false);\n            hi_template.assign_bit(next_bit, false);\n        }\n        previous_bit = bit;\n    }\n    lo_template\n}\n\n/// Generates striped random [`Natural`]s greater than or equal to a lower bound.\n#[derive(Clone, Debug)]\npub struct StripedRandomNaturalRangeToInfinity {\n    min_bits: u64,\n    bits: GeometricRandomNaturalValues<u64>,\n    bit_source: StripedBitSource,\n    min_bit_xs: StripedRandomNaturalInclusiveRange,\n}\n\nimpl Iterator for StripedRandomNaturalRangeToInfinity {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        let bits = self.bits.next().unwrap();\n        if bits == self.min_bits {\n            self.min_bit_xs.next()\n        } else {\n            Some(get_striped_random_natural_with_bits(\n                &mut self.bit_source,\n                bits,\n            ))\n        }\n    }\n}\n\n/// Generates striped random [`Natural`]s greater than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the [`Natural`]s is specified; it must be greater than the bit length\n/// of $a$. $m$ is equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The actual bit length is chosen from a geometric distribution with lower bound $a$ and mean $m$.\n/// The resulting distribution has no mean or higher-order statistics (unless $a < m < a + 1$, which\n/// is not typical).\n///\n/// The [`Natural`]s are generated using a striped bit sequence with mean run length $m$ =\n/// `mean_stripe_numerator / mean_stripe_denominator`.\n///\n/// Because the [`Natural`]s are constrained to be within a certain range, the actual mean run\n/// length will usually not be $m$. Nonetheless, setting a higher $m$ will result in a higher mean\n/// run length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n, m) = O(n + m)$\n///\n/// $M(n, m) = O(n / m)$\n///\n/// where $T$ is time, $M$ is additional memory, $n$ is `mean_precision_numerator`, and $m$ is\n/// `mean_precision_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if their\n/// ratio is less than or equal to $a$, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::random::striped_random_natural_range_to_infinity;\n/// use malachite_nz::natural::Natural;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_natural_range_to_infinity(\n///             EXAMPLE_SEED,\n///             Natural::from(1000u32),\n///             20,\n///             1,\n///             14,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[8192, 14336, 16376, 1024, 1024, 1023, 2047, 245760, 8195, 131070, ...]\"\n/// )\n/// ```\npub fn striped_random_natural_range_to_infinity(\n    seed: Seed,\n    a: Natural,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomNaturalRangeToInfinity {\n    let min_bits = a.significant_bits();\n    StripedRandomNaturalRangeToInfinity {\n        min_bits,\n        bits: geometric_random_unsigned_inclusive_range(\n            seed.fork(\"bits\"),\n            min_bits,\n            u64::MAX,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        bit_source: StripedBitSource::new(\n            seed.fork(\"bit_source\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        min_bit_xs: striped_random_natural_range(\n            seed.fork(\"min_bit_xs\"),\n            a,\n            Natural::power_of_2(min_bits),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/platform_32.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `bin2kk`, `bin2kkinv`, and `fac2bin` contributed to the GNU project by Torbjörn Granlund\n//      and Marco Bodrato.\n//\n//      Copyright © 2002, 2010-2018 Free Software Foundation, Inc.\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 2005-2022 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub type Limb = u32;\npub type HalfLimb = u16;\npub type DoubleLimb = u64;\npub type SignedLimb = i32;\npub type SignedHalfLimb = i16;\npub type SignedDoubleLimb = i64;\npub type FloatWithLimbWidth = f32;\n\npub(crate) const MAX_DIGITS_PER_LIMB: usize = 10;\n\n// TODO tune\npub(crate) const AORSMUL_FASTER_2AORSLSH: bool = true;\n// TODO tune\npub(crate) const AORSMUL_FASTER_3AORSLSH: bool = true;\n// TODO tune\npub(crate) const AORSMUL_FASTER_AORS_AORSLSH: bool = true;\n// TODO tune\npub(crate) const AORSMUL_FASTER_AORS_2AORSLSH: bool = true;\n\n// TODO tune\npub(crate) const MUL_TOOM22_THRESHOLD: usize = 118;\n// TODO tune\npub(crate) const MUL_TOOM33_THRESHOLD: usize = 101;\n// TODO tune\npub(crate) const MUL_TOOM44_THRESHOLD: usize = 530;\n// TODO tune\npub(crate) const MUL_TOOM6H_THRESHOLD: usize = 738;\n// TODO tune\npub(crate) const MUL_TOOM8H_THRESHOLD: usize = 984;\n\n// TODO tune\npub(crate) const MUL_TOOM32_TO_TOOM43_THRESHOLD: usize = 315;\n// TODO tune\npub(crate) const MUL_TOOM32_TO_TOOM53_THRESHOLD: usize = 307;\n// TODO tune\npub(crate) const MUL_TOOM42_TO_TOOM53_THRESHOLD: usize = 328;\n// TODO tune\npub(crate) const MUL_TOOM42_TO_TOOM63_THRESHOLD: usize = 295;\n\n// TODO tune\npub(crate) const MUL_FFT_THRESHOLD: usize = 5608;\n\n// TODO tune\npub(crate) const DC_DIV_QR_THRESHOLD: usize = 7;\n// TODO tune\npub(crate) const DC_DIVAPPR_Q_THRESHOLD: usize = 151;\n// TODO tune\npub(crate) const MAYBE_DCP1_DIVAPPR: bool = true;\n// TODO tune\npub(crate) const INV_NEWTON_THRESHOLD: usize = 618;\n// TODO tune\npub(crate) const MU_DIV_QR_THRESHOLD: usize = 2243;\n// TODO tune\npub(crate) const INV_MULMOD_BNM1_THRESHOLD: usize = 68;\n// TODO tune\npub(crate) const MU_DIV_QR_SKEW_THRESHOLD: usize = 233;\n\n// TODO tune\npub(crate) const MU_DIVAPPR_Q_THRESHOLD: usize = 2297;\n// TODO tune\npub(crate) const FUDGE: usize = 261;\n\n// TODO tune\npub(crate) const MULLO_BASECASE_THRESHOLD: usize = 0;\n// TODO tune\npub(crate) const MULLO_DC_THRESHOLD: usize = 216;\n// TODO tune\npub(crate) const MULLO_MUL_N_THRESHOLD: usize = 100000;\n\n// TODO tune\npub(crate) const BINV_NEWTON_THRESHOLD: usize = 3264;\n// TODO tune\npub(crate) const DC_BDIV_QR_THRESHOLD: usize = 329;\n// TODO tune\npub(crate) const MU_BDIV_QR_THRESHOLD: usize = 50000;\n// TODO tune\npub(crate) const DC_BDIV_Q_THRESHOLD: usize = 373;\n// TODO tune\npub(crate) const MU_BDIV_Q_THRESHOLD: usize = 2390;\n\n// TODO tune\npub(crate) const MOD_1_NORM_THRESHOLD: usize = 0;\n// TODO tune\npub(crate) const MOD_1_UNNORM_THRESHOLD: usize = 0;\n// TODO tune\npub(crate) const MOD_1_1P_METHOD: bool = true;\n// TODO tune\npub(crate) const MOD_1N_TO_MOD_1_1_THRESHOLD: usize = 3;\n// TODO tune\npub(crate) const MOD_1U_TO_MOD_1_1_THRESHOLD: usize = 3;\n// TODO tune\npub(crate) const MOD_1_1_TO_MOD_1_2_THRESHOLD: usize = 15;\n// TODO tune\npub(crate) const MOD_1_2_TO_MOD_1_4_THRESHOLD: usize = 43;\n\n// TODO tune\npub(crate) const BMOD_1_TO_MOD_1_THRESHOLD: usize = 31;\n\n// TODO tune\npub(crate) const SQR_BASECASE_THRESHOLD: usize = 0;\n// TODO tune\n#[doc(hidden)]\npub const SQR_TOOM2_THRESHOLD: usize = 222;\n// TODO tune\npub(crate) const SQR_TOOM3_THRESHOLD: usize = 205;\n// TODO tune\npub(crate) const SQR_TOOM4_THRESHOLD: usize = 1170;\n// TODO tune\npub(crate) const SQR_TOOM6_THRESHOLD: usize = 512;\n// TODO tune\npub(crate) const SQR_TOOM8_THRESHOLD: usize = 644;\n\n// TODO tune\npub(crate) const SQRLO_DC_THRESHOLD: usize = 460;\n\n// TODO tune\npub(crate) const FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD: u64 = 12000;\n\n// TODO tune\npub(crate) const MATRIX22_STRASSEN_THRESHOLD: usize = 50;\n\n// This section is created by digits_data.rs.\n\n// mp_bases[10] data, as literal values\npub(crate) const MP_BASES_CHARS_PER_LIMB_10: usize = 9;\npub(crate) const MP_BASES_BIG_BASE_10: Limb = 0x3b9aca00;\npub(crate) const MP_BASES_BIG_BASE_INVERTED_10: Limb = 0x12e0be82;\npub(crate) const MP_BASES_NORMALIZATION_STEPS_10: u64 = 2;\n\n// Format is (chars_per_limb, logb2, log2b, big_base, big_base_inverted)\npub(crate) const BASES: [(usize, Limb, Limb, Limb, Limb); 257] = [\n    (0, 0, 0, 0, 0),                                      // 0\n    (0, 0, 0, 0, 0),                                      // 1\n    (32, 0xffffffff, 0x1fffffff, 0x1, 0x0),               // 2\n    (20, 0xa1849cc1, 0x32b80347, 0xcfd41b91, 0x3b563c24), // 3\n    (16, 0x7fffffff, 0x3fffffff, 0x2, 0x0),               // 4\n    (13, 0x6e40d1a4, 0x4a4d3c25, 0x48c27395, 0xc25c2684), // 5\n    (12, 0x6308c91b, 0x52b80347, 0x81bf1000, 0xf91bd1b6), // 6\n    (11, 0x5b3064eb, 0x59d5d9fd, 0x75db9c97, 0x1607a2cb), // 7\n    (10, 0x55555555, 0x5fffffff, 0x3, 0x0),               // 8\n    (10, 0x50c24e60, 0x6570068e, 0xcfd41b91, 0x3b563c24), // 9\n    (9, 0x4d104d42, 0x6a4d3c25, 0x3b9aca00, 0x12e0be82),  // 10\n    (9, 0x4a002707, 0x6eb3a9f0, 0x8c8b6d2b, 0xd24cde04),  // 11\n    (8, 0x4768ce0d, 0x72b80347, 0x19a10000, 0x3fa39ab5),  // 12\n    (8, 0x452e53e3, 0x766a008e, 0x309f1021, 0x50f8ac5f),  // 13\n    (8, 0x433cfffb, 0x79d5d9fd, 0x57f6c100, 0x74843b1e),  // 14\n    (8, 0x41867711, 0x7d053f6d, 0x98c29b81, 0xad0326c2),  // 15\n    (8, 0x3fffffff, 0x7fffffff, 0x4, 0x0),                // 16\n    (7, 0x3ea16afd, 0x82cc7edf, 0x18754571, 0x4ef0b6bd),  // 17\n    (7, 0x3d64598d, 0x8570068e, 0x247dbc80, 0xc0fc48a1),  // 18\n    (7, 0x3c43c230, 0x87ef05ae, 0x3547667b, 0x33838942),  // 19\n    (7, 0x3b3b9a42, 0x8a4d3c25, 0x4c4b4000, 0xad7f29ab),  // 20\n    (7, 0x3a4898f0, 0x8c8ddd44, 0x6b5a6e1d, 0x313c3d15),  // 21\n    (7, 0x39680b13, 0x8eb3a9f0, 0x94ace180, 0xb8cca9e0),  // 22\n    (7, 0x3897b2b7, 0x90c10500, 0xcaf18367, 0x42ed6de9),  // 23\n    (6, 0x37d5aed1, 0x92b80347, 0xb640000, 0x67980e0b),   // 24\n    (6, 0x372068d2, 0x949a784b, 0xe8d4a51, 0x19799812),   // 25\n    (6, 0x3676867e, 0x966a008e, 0x1269ae40, 0xbce85396),  // 26\n    (6, 0x35d6deeb, 0x982809d5, 0x17179149, 0x62c103a9),  // 27\n    (6, 0x354071d6, 0x99d5d9fd, 0x1cb91000, 0x1d353d43),  // 28\n    (6, 0x34b260c5, 0x9b74948f, 0x23744899, 0xce1decea),  // 29\n    (6, 0x342be986, 0x9d053f6d, 0x2b73a840, 0x790fc511),  // 30\n    (6, 0x33ac61b9, 0x9e88c6b3, 0x34e63b41, 0x35b865a0),  // 31\n    (6, 0x33333333, 0x9fffffff, 0x5, 0x0),                // 32\n    (6, 0x32bfd901, 0xa16bad37, 0x4cfa3cc1, 0xa9aed1b3),  // 33\n    (6, 0x3251dcf6, 0xa2cc7edf, 0x5c13d840, 0x63dfc229),  // 34\n    (6, 0x31e8d59f, 0xa4231623, 0x6d91b519, 0x2b0fee30),  // 35\n    (6, 0x3184648d, 0xa570068e, 0x81bf1000, 0xf91bd1b6),  // 36\n    (6, 0x312434e8, 0xa6b3d78b, 0x98ede0c9, 0xac89c3a9),  // 37\n    (6, 0x30c7fa34, 0xa7ef05ae, 0xb3773e40, 0x6d2c32fe),  // 38\n    (6, 0x306f6f4c, 0xa92203d5, 0xd1bbc4d1, 0x387907c9),  // 39\n    (6, 0x301a557f, 0xaa4d3c25, 0xf4240000, 0xc6f7a0b),   // 40\n    (5, 0x2fc873d1, 0xab7110e6, 0x6e7d349, 0x28928154),   // 41\n    (5, 0x2f799652, 0xac8ddd44, 0x7ca30a0, 0x6e8629d),    // 42\n    (5, 0x2f2d8d8f, 0xada3f5fb, 0x8c32bbb, 0xd373dca0),   // 43\n    (5, 0x2ee42e16, 0xaeb3a9f0, 0x9d46c00, 0xa0b17895),   // 44\n    (5, 0x2e9d5009, 0xafbd42b4, 0xaffacfd, 0x746811a5),   // 45\n    (5, 0x2e58cec0, 0xb0c10500, 0xc46bee0, 0x4da6500f),   // 46\n    (5, 0x2e168874, 0xb1bf311e, 0xdab86ef, 0x2ba23582),   // 47\n    (5, 0x2dd65df7, 0xb2b80347, 0xf300000, 0xdb20a88),    // 48\n    (5, 0x2d983275, 0xb3abb3fa, 0x10d63af1, 0xe68d5ce4),  // 49\n    (5, 0x2d5beb38, 0xb49a784b, 0x12a05f20, 0xb7cdfd9d),  // 50\n    (5, 0x2d216f79, 0xb5848226, 0x1490aae3, 0x8e583933),  // 51\n    (5, 0x2ce8a82e, 0xb66a008e, 0x16a97400, 0x697cc3ea),  // 52\n    (5, 0x2cb17fea, 0xb74b1fd6, 0x18ed2825, 0x48a5ca6c),  // 53\n    (5, 0x2c7be2b0, 0xb82809d5, 0x1b5e4d60, 0x2b52db16),  // 54\n    (5, 0x2c47bddb, 0xb900e615, 0x1dff8297, 0x111586a6),  // 55\n    (5, 0x2c14fffc, 0xb9d5d9fd, 0x20d38000, 0xf31d2b36),  // 56\n    (5, 0x2be398c3, 0xbaa708f5, 0x23dd1799, 0xc8d76d19),  // 57\n    (5, 0x2bb378e7, 0xbb74948f, 0x271f35a0, 0xa2cb1eb4),  // 58\n    (5, 0x2b849210, 0xbc3e9ca2, 0x2a9ce10b, 0x807c3ec3),  // 59\n    (5, 0x2b56d6c7, 0xbd053f6d, 0x2e593c00, 0x617ec8bf),  // 60\n    (5, 0x2b2a3a60, 0xbdc899ab, 0x3257844d, 0x45746cbe),  // 61\n    (5, 0x2afeb0f1, 0xbe88c6b3, 0x369b13e0, 0x2c0aa273),  // 62\n    (5, 0x2ad42f3c, 0xbf45e08b, 0x3b27613f, 0x14f90805),  // 63\n    (5, 0x2aaaaaaa, 0xbfffffff, 0x6, 0x0),                // 64\n    (5, 0x2a82193a, 0xc0b73cb4, 0x4528a141, 0xd9cf0829),  // 65\n    (5, 0x2a5a7176, 0xc16bad37, 0x4aa51420, 0xb6fc4841),  // 66\n    (5, 0x2a33aa6e, 0xc21d6713, 0x50794633, 0x973054cb),  // 67\n    (5, 0x2a0dbbaa, 0xc2cc7edf, 0x56a94400, 0x7a1dbe4b),  // 68\n    (5, 0x29e89d24, 0xc3790848, 0x5d393975, 0x5f7fcd7f),  // 69\n    (5, 0x29c44740, 0xc4231623, 0x642d7260, 0x47196c84),  // 70\n    (5, 0x29a0b2c7, 0xc4caba78, 0x6b8a5ae7, 0x30b43635),  // 71\n    (5, 0x297dd8db, 0xc570068e, 0x73548000, 0x1c1fa5f6),  // 72\n    (5, 0x295bb2f9, 0xc6130af4, 0x7b908fe9, 0x930634a),   // 73\n    (5, 0x293a3aeb, 0xc6b3d78b, 0x84435aa0, 0xef7f4a3c),  // 74\n    (5, 0x29196acc, 0xc7527b93, 0x8d71d25b, 0xcf5552d2),  // 75\n    (5, 0x28f93cfb, 0xc7ef05ae, 0x97210c00, 0xb1a47c8e),  // 76\n    (5, 0x28d9ac1b, 0xc88983ed, 0xa1563f9d, 0x9634b43e),  // 77\n    (5, 0x28bab310, 0xc92203d5, 0xac16c8e0, 0x7cd3817d),  // 78\n    (5, 0x289c4cf8, 0xc9b89267, 0xb768278f, 0x65536761),  // 79\n    (5, 0x287e7529, 0xca4d3c25, 0xc3500000, 0x4f8b588e),  // 80\n    (5, 0x28612730, 0xcae00d1c, 0xcfd41b91, 0x3b563c24),  // 81\n    (5, 0x28445ec9, 0xcb7110e6, 0xdcfa6920, 0x28928154),  // 82\n    (5, 0x282817e1, 0xcc0052b1, 0xeac8fd83, 0x1721bfb0),  // 83\n    (5, 0x280c4e90, 0xcc8ddd44, 0xf9461400, 0x6e8629d),   // 84\n    (4, 0x27f0ff1b, 0xcd19bb05, 0x31c84b1, 0x491cc17c),   // 85\n    (4, 0x27d625ec, 0xcda3f5fb, 0x342ab10, 0x3a11d83b),   // 86\n    (4, 0x27bbbf95, 0xce2c97d6, 0x36a2c21, 0x2be074cd),   // 87\n    (4, 0x27a1c8c8, 0xceb3a9f0, 0x3931000, 0x1e7a02e7),   // 88\n    (4, 0x27883e5e, 0xcf393550, 0x3bd5ee1, 0x11d10edd),   // 89\n    (4, 0x276f1d4c, 0xcfbd42b4, 0x3e92110, 0x5d92c68),    // 90\n    (4, 0x275662a8, 0xd03fda8b, 0x4165ef1, 0xf50dbfb2),   // 91\n    (4, 0x273e0ba3, 0xd0c10500, 0x4452100, 0xdf9f1316),   // 92\n    (4, 0x2726158c, 0xd140c9fa, 0x4756fd1, 0xcb52a684),   // 93\n    (4, 0x270e7dc9, 0xd1bf311e, 0x4a75410, 0xb8163e97),   // 94\n    (4, 0x26f741dd, 0xd23c41d4, 0x4dad681, 0xa5d8f269),   // 95\n    (4, 0x26e05f5f, 0xd2b80347, 0x5100000, 0x948b0fcd),   // 96\n    (4, 0x26c9d3fe, 0xd3327c6a, 0x546d981, 0x841e0215),   // 97\n    (4, 0x26b39d7f, 0xd3abb3fa, 0x57f6c10, 0x74843b1e),   // 98\n    (4, 0x269db9bc, 0xd423b07e, 0x5b9c0d1, 0x65b11e6e),   // 99\n    (4, 0x268826a1, 0xd49a784b, 0x5f5e100, 0x5798ee23),   // 100\n    (4, 0x2672e22d, 0xd5101187, 0x633d5f1, 0x4a30b99b),   // 101\n    (4, 0x265dea72, 0xd5848226, 0x673a910, 0x3d6e4d94),   // 102\n    (4, 0x26493d93, 0xd5f7cff4, 0x6b563e1, 0x314825b0),   // 103\n    (4, 0x2634d9c2, 0xd66a008e, 0x6f91000, 0x25b55f2e),   // 104\n    (4, 0x2620bd41, 0xd6db196a, 0x73eb721, 0x1aadaccb),   // 105\n    (4, 0x260ce662, 0xd74b1fd6, 0x7866310, 0x10294ba2),   // 106\n    (4, 0x25f95385, 0xd7ba18f9, 0x7d01db1, 0x620f8f6),    // 107\n    (4, 0x25e60316, 0xd82809d5, 0x81bf100, 0xf91bd1b6),   // 108\n    (4, 0x25d2f390, 0xd894f74b, 0x869e711, 0xe6d37b2a),   // 109\n    (4, 0x25c02379, 0xd900e615, 0x8ba0a10, 0xd55cff6e),   // 110\n    (4, 0x25ad9165, 0xd96bdad2, 0x90c6441, 0xc4ad2db2),   // 111\n    (4, 0x259b3bf3, 0xd9d5d9fd, 0x9610000, 0xb4b985cf),   // 112\n    (4, 0x258921cb, 0xda3ee7f3, 0x9b7e7c1, 0xa5782bef),   // 113\n    (4, 0x257741a2, 0xdaa708f5, 0xa112610, 0x96dfdd2a),   // 114\n    (4, 0x25659a37, 0xdb0e4126, 0xa6cc591, 0x88e7e509),   // 115\n    (4, 0x25542a50, 0xdb74948f, 0xacad100, 0x7b8813d3),   // 116\n    (4, 0x2542f0c2, 0xdbda071c, 0xb2b5331, 0x6eb8b595),   // 117\n    (4, 0x2531ec64, 0xdc3e9ca2, 0xb8e5710, 0x627289db),   // 118\n    (4, 0x25211c1c, 0xdca258dc, 0xbf3e7a1, 0x56aebc07),   // 119\n    (4, 0x25107ed5, 0xdd053f6d, 0xc5c1000, 0x4b66dc33),   // 120\n    (4, 0x25001383, 0xdd6753e0, 0xcc6db61, 0x4094d8a3),   // 121\n    (4, 0x24efd921, 0xddc899ab, 0xd345510, 0x3632f7a5),   // 122\n    (4, 0x24dfceb3, 0xde29142e, 0xda48871, 0x2c3bd1f0),   // 123\n    (4, 0x24cff343, 0xde88c6b3, 0xe178100, 0x22aa4d5f),   // 124\n    (4, 0x24c045e1, 0xdee7b471, 0xe8d4a51, 0x19799812),   // 125\n    (4, 0x24b0c5a6, 0xdf45e08b, 0xf05f010, 0x10a523e5),   // 126\n    (4, 0x24a171b0, 0xdfa34e11, 0xf817e01, 0x828a237),    // 127\n    (4, 0x24924924, 0xdfffffff, 0x7, 0x0),                // 128\n    (4, 0x24834b2c, 0xe05bf942, 0x10818201, 0xf04ec452),  // 129\n    (4, 0x247476f9, 0xe0b73cb4, 0x11061010, 0xe136444a),  // 130\n    (4, 0x2465cbc0, 0xe111cd1d, 0x118db651, 0xd2af9589),  // 131\n    (4, 0x245748bc, 0xe16bad37, 0x12188100, 0xc4b42a83),  // 132\n    (4, 0x2448ed2f, 0xe1c4dfab, 0x12a67c71, 0xb73dccf5),  // 133\n    (4, 0x243ab85d, 0xe21d6713, 0x1337b510, 0xaa4698c5),  // 134\n    (4, 0x242ca992, 0xe27545fb, 0x13cc3761, 0x9dc8f729),  // 135\n    (4, 0x241ec01b, 0xe2cc7edf, 0x14641000, 0x91bf9a30),  // 136\n    (4, 0x2410fb4d, 0xe323142d, 0x14ff4ba1, 0x86257887),  // 137\n    (4, 0x24035a80, 0xe3790848, 0x159df710, 0x7af5c98c),  // 138\n    (4, 0x23f5dd10, 0xe3ce5d82, 0x16401f31, 0x702c01a0),  // 139\n    (4, 0x23e8825d, 0xe4231623, 0x16e5d100, 0x65c3ceb1),  // 140\n    (4, 0x23db49cc, 0xe4773465, 0x178f1991, 0x5bb91502),  // 141\n    (4, 0x23ce32c4, 0xe4caba78, 0x183c0610, 0x5207ec23),  // 142\n    (4, 0x23c13cb3, 0xe51daa7e, 0x18eca3c1, 0x48ac9c19),  // 143\n    (4, 0x23b46706, 0xe570068e, 0x19a10000, 0x3fa39ab5),  // 144\n    (4, 0x23a7b132, 0xe5c1d0b5, 0x1a592841, 0x36e98912),  // 145\n    (4, 0x239b1aac, 0xe6130af4, 0x1b152a10, 0x2e7b3140),  // 146\n    (4, 0x238ea2ef, 0xe663b741, 0x1bd51311, 0x2655840b),  // 147\n    (4, 0x23824976, 0xe6b3d78b, 0x1c98f100, 0x1e7596ea),  // 148\n    (4, 0x23760dc3, 0xe7036db3, 0x1d60d1b1, 0x16d8a20d),  // 149\n    (4, 0x2369ef58, 0xe7527b93, 0x1e2cc310, 0xf7bfe87),   // 150\n    (4, 0x235dedbb, 0xe7a102f9, 0x1efcd321, 0x85d2492),   // 151\n    (4, 0x23520874, 0xe7ef05ae, 0x1fd11000, 0x179a9f4),   // 152\n    (4, 0x23463f10, 0xe83c856d, 0x20a987e1, 0xf59e80eb),  // 153\n    (4, 0x233a911b, 0xe88983ed, 0x21864910, 0xe8b768db),  // 154\n    (4, 0x232efe26, 0xe8d602d9, 0x226761f1, 0xdc39d6d5),  // 155\n    (4, 0x232385c6, 0xe92203d5, 0x234ce100, 0xd021c5d1),  // 156\n    (4, 0x2318278e, 0xe96d887e, 0x2436d4d1, 0xc46b5e37),  // 157\n    (4, 0x230ce318, 0xe9b89267, 0x25254c10, 0xb912f39c),  // 158\n    (4, 0x2301b7fd, 0xea03231d, 0x26185581, 0xae150294),  // 159\n    (4, 0x22f6a5d9, 0xea4d3c25, 0x27100000, 0xa36e2eb1),  // 160\n    (4, 0x22ebac4c, 0xea96defe, 0x280c5a81, 0x991b4094),  // 161\n    (4, 0x22e0caf6, 0xeae00d1c, 0x290d7410, 0x8f19241e),  // 162\n    (4, 0x22d60179, 0xeb28c7f2, 0x2a135bd1, 0x8564e6b7),  // 163\n    (4, 0x22cb4f7a, 0xeb7110e6, 0x2b1e2100, 0x7bfbb5b4),  // 164\n    (4, 0x22c0b4a1, 0xebb8e95d, 0x2c2dd2f1, 0x72dadcc8),  // 165\n    (4, 0x22b63095, 0xec0052b1, 0x2d428110, 0x69ffc498),  // 166\n    (4, 0x22abc300, 0xec474e39, 0x2e5c3ae1, 0x6167f154),  // 167\n    (4, 0x22a16b90, 0xec8ddd44, 0x2f7b1000, 0x5911016e),  // 168\n    (4, 0x229729f1, 0xecd4011c, 0x309f1021, 0x50f8ac5f),  // 169\n    (4, 0x228cfdd4, 0xed19bb05, 0x31c84b10, 0x491cc17c),  // 170\n    (4, 0x2282e6e9, 0xed5f0c3c, 0x32f6d0b1, 0x417b26d8),  // 171\n    (4, 0x2278e4e3, 0xeda3f5fb, 0x342ab100, 0x3a11d83b),  // 172\n    (4, 0x226ef777, 0xede87974, 0x3563fc11, 0x32dee622),  // 173\n    (4, 0x22651e5a, 0xee2c97d6, 0x36a2c210, 0x2be074cd),  // 174\n    (4, 0x225b5944, 0xee705249, 0x37e71341, 0x2514bb58),  // 175\n    (4, 0x2251a7ee, 0xeeb3a9f0, 0x39310000, 0x1e7a02e7),  // 176\n    (4, 0x22480a11, 0xeef69fea, 0x3a8098c1, 0x180ea5d0),  // 177\n    (4, 0x223e7f69, 0xef393550, 0x3bd5ee10, 0x11d10edd),  // 178\n    (4, 0x223507b4, 0xef7b6b39, 0x3d311091, 0xbbfb88e),   // 179\n    (4, 0x222ba2af, 0xefbd42b4, 0x3e921100, 0x5d92c68),   // 180\n    (4, 0x22225019, 0xeffebccd, 0x3ff90031, 0x1c024c),    // 181\n    (4, 0x22190fb4, 0xf03fda8b, 0x4165ef10, 0xf50dbfb2),  // 182\n    (4, 0x220fe141, 0xf0809cf2, 0x42d8eea1, 0xea30efa3),  // 183\n    (4, 0x2206c483, 0xf0c10500, 0x44521000, 0xdf9f1316),  // 184\n    (4, 0x21fdb93f, 0xf10113b1, 0x45d16461, 0xd555c0c9),  // 185\n    (4, 0x21f4bf3a, 0xf140c9fa, 0x4756fd10, 0xcb52a684),  // 186\n    (4, 0x21ebd639, 0xf18028cf, 0x48e2eb71, 0xc193881f),  // 187\n    (4, 0x21e2fe06, 0xf1bf311e, 0x4a754100, 0xb8163e97),  // 188\n    (4, 0x21da3667, 0xf1fde3d3, 0x4c0e0f51, 0xaed8b724),  // 189\n    (4, 0x21d17f28, 0xf23c41d4, 0x4dad6810, 0xa5d8f269),  // 190\n    (4, 0x21c8d811, 0xf27a4c05, 0x4f535d01, 0x9d15039d),  // 191\n    (4, 0x21c040ef, 0xf2b80347, 0x51000000, 0x948b0fcd),  // 192\n    (4, 0x21b7b98f, 0xf2f56875, 0x52b36301, 0x8c394d1d),  // 193\n    (4, 0x21af41bc, 0xf3327c6a, 0x546d9810, 0x841e0215),  // 194\n    (4, 0x21a6d947, 0xf36f3ffb, 0x562eb151, 0x7c3784f8),  // 195\n    (4, 0x219e7ffd, 0xf3abb3fa, 0x57f6c100, 0x74843b1e),  // 196\n    (4, 0x219635af, 0xf3e7d937, 0x59c5d971, 0x6d02985d),  // 197\n    (4, 0x218dfa2e, 0xf423b07e, 0x5b9c0d10, 0x65b11e6e),  // 198\n    (4, 0x2185cd4c, 0xf45f3a98, 0x5d796e61, 0x5e8e5c64),  // 199\n    (4, 0x217daeda, 0xf49a784b, 0x5f5e1000, 0x5798ee23),  // 200\n    (4, 0x21759eac, 0xf4d56a5b, 0x614a04a1, 0x50cf7bde),  // 201\n    (4, 0x216d9c96, 0xf5101187, 0x633d5f10, 0x4a30b99b),  // 202\n    (4, 0x2165a86e, 0xf54a6e8c, 0x65383231, 0x43bb66bd),  // 203\n    (4, 0x215dc207, 0xf5848226, 0x673a9100, 0x3d6e4d94),  // 204\n    (4, 0x2155e939, 0xf5be4d0c, 0x69448e91, 0x374842ee),  // 205\n    (4, 0x214e1ddb, 0xf5f7cff4, 0x6b563e10, 0x314825b0),  // 206\n    (4, 0x21465fc4, 0xf6310b8f, 0x6d6fb2c1, 0x2b6cde75),  // 207\n    (4, 0x213eaecd, 0xf66a008e, 0x6f910000, 0x25b55f2e),  // 208\n    (4, 0x21370ace, 0xf6a2af9e, 0x71ba3941, 0x2020a2c5),  // 209\n    (4, 0x212f73a0, 0xf6db196a, 0x73eb7210, 0x1aadaccb),  // 210\n    (4, 0x2127e920, 0xf7133e9b, 0x7624be11, 0x155b891f),  // 211\n    (4, 0x21206b26, 0xf74b1fd6, 0x78663100, 0x10294ba2),  // 212\n    (4, 0x2118f98f, 0xf782bdbf, 0x7aafdeb1, 0xb160fe9),   // 213\n    (4, 0x21119436, 0xf7ba18f9, 0x7d01db10, 0x620f8f6),   // 214\n    (4, 0x210a3af8, 0xf7f13221, 0x7f5c3a21, 0x14930ef),   // 215\n    (4, 0x2102edb3, 0xf82809d5, 0x81bf1000, 0xf91bd1b6),  // 216\n    (4, 0x20fbac44, 0xf85ea0b0, 0x842a70e1, 0xefdcb0c7),  // 217\n    (4, 0x20f4768a, 0xf894f74b, 0x869e7110, 0xe6d37b2a),  // 218\n    (4, 0x20ed4c62, 0xf8cb0e3b, 0x891b24f1, 0xddfeb94a),  // 219\n    (4, 0x20e62dae, 0xf900e615, 0x8ba0a100, 0xd55cff6e),  // 220\n    (4, 0x20df1a4b, 0xf9367f6d, 0x8e2ef9d1, 0xcceced50),  // 221\n    (4, 0x20d8121c, 0xf96bdad2, 0x90c64410, 0xc4ad2db2),  // 222\n    (4, 0x20d11500, 0xf9a0f8d3, 0x93669481, 0xbc9c75f9),  // 223\n    (4, 0x20ca22d9, 0xf9d5d9fd, 0x96100000, 0xb4b985cf),  // 224\n    (4, 0x20c33b88, 0xfa0a7eda, 0x98c29b81, 0xad0326c2),  // 225\n    (4, 0x20bc5ef1, 0xfa3ee7f3, 0x9b7e7c10, 0xa5782bef),  // 226\n    (4, 0x20b58cf5, 0xfa7315d0, 0x9e43b6d1, 0x9e1771a9),  // 227\n    (4, 0x20aec579, 0xfaa708f5, 0xa1126100, 0x96dfdd2a),  // 228\n    (4, 0x20a8085e, 0xfadac1e7, 0xa3ea8ff1, 0x8fd05c41),  // 229\n    (4, 0x20a1558b, 0xfb0e4126, 0xa6cc5910, 0x88e7e509),  // 230\n    (4, 0x209aace2, 0xfb418734, 0xa9b7d1e1, 0x8225759d),  // 231\n    (4, 0x20940e49, 0xfb74948f, 0xacad1000, 0x7b8813d3),  // 232\n    (4, 0x208d79a5, 0xfba769b3, 0xafac2921, 0x750eccf9),  // 233\n    (4, 0x2086eedb, 0xfbda071c, 0xb2b53310, 0x6eb8b595),  // 234\n    (4, 0x20806dd2, 0xfc0c6d44, 0xb5c843b1, 0x6884e923),  // 235\n    (4, 0x2079f671, 0xfc3e9ca2, 0xb8e57100, 0x627289db),  // 236\n    (4, 0x2073889d, 0xfc7095ae, 0xbc0cd111, 0x5c80c07b),  // 237\n    (4, 0x206d243e, 0xfca258dc, 0xbf3e7a10, 0x56aebc07),  // 238\n    (4, 0x2066c93c, 0xfcd3e6a0, 0xc27a8241, 0x50fbb19b),  // 239\n    (4, 0x2060777e, 0xfd053f6d, 0xc5c10000, 0x4b66dc33),  // 240\n    (4, 0x205a2eed, 0xfd3663b2, 0xc91209c1, 0x45ef7c7c),  // 241\n    (4, 0x2053ef71, 0xfd6753e0, 0xcc6db610, 0x4094d8a3),  // 242\n    (4, 0x204db8f3, 0xfd981064, 0xcfd41b91, 0x3b563c24),  // 243\n    (4, 0x20478b5c, 0xfdc899ab, 0xd3455100, 0x3632f7a5),  // 244\n    (4, 0x20416696, 0xfdf8f020, 0xd6c16d31, 0x312a60c3),  // 245\n    (4, 0x203b4a8b, 0xfe29142e, 0xda488710, 0x2c3bd1f0),  // 246\n    (4, 0x20353725, 0xfe59063c, 0xdddab5a1, 0x2766aa45),  // 247\n    (4, 0x202f2c4e, 0xfe88c6b3, 0xe1781000, 0x22aa4d5f),  // 248\n    (4, 0x202929f0, 0xfeb855f8, 0xe520ad61, 0x1e06233c),  // 249\n    (4, 0x20232ff8, 0xfee7b471, 0xe8d4a510, 0x19799812),  // 250\n    (4, 0x201d3e50, 0xff16e281, 0xec940e71, 0x15041c33),  // 251\n    (4, 0x201754e5, 0xff45e08b, 0xf05f0100, 0x10a523e5),  // 252\n    (4, 0x201173a1, 0xff74aef0, 0xf4359451, 0xc5c2749),   // 253\n    (4, 0x200b9a71, 0xffa34e11, 0xf817e010, 0x828a237),   // 254\n    (4, 0x2005c942, 0xffd1be4c, 0xfc05fc01, 0x40a1423),   // 255\n    (4, 0x1fffffff, 0xffffffff, 0x8, 0x0),                // 256\n];\n\n// This section is created by factorial_data.rs.\n\n// This is equivalent to `__gmp_oddfac_table` in `mpn/comb_tables.c`, GMP 6.2.1, which is the\n// combination of `ONE_LIMB_ODD_FACTORIAL_TABLE` and `ONE_LIMB_ODD_FACTORIAL_EXTTABLE` in\n// `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_FACTORIAL_TABLE: [Limb; 35] = [\n    0x1, 0x1, 0x1, 0x3, 0x3, 0xf, 0x2d, 0x13b, 0x13b, 0xb13, 0x375f, 0x26115, 0x7233f, 0x5cca33,\n    0x2898765, 0x260eeeeb, 0x260eeeeb, 0x86fddd9b, 0xbeecca73, 0x2b930689, 0xd9df20ad, 0xdf4dae31,\n    0x98567c1b, 0xafc5266d, 0xf4f7347, 0x7ec241ef, 0x6fdd5923, 0xcc5866b1, 0x966aced7, 0xa196e5b,\n    0x977d7755, 0x5831734b, 0x5831734b, 0x5e5fdcab, 0x445da75b,\n];\n// This is equivalent to `ODD_FACTORIAL_TABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_FACTORIAL_TABLE_LIMIT: usize = 16;\n// This is equivalent to `ODD_FACTORIAL_EXTTABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_FACTORIAL_EXTTABLE_LIMIT: usize = 34;\n// This is equivalent to `ODD_FACTORIAL_TABLE_MAX` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_FACTORIAL_TABLE_MAX: Limb = 0x260eeeeb;\n\n// This is equivalent to `__gmp_odd2fac_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\n// `ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE: [Limb; 10] =\n    [0x1, 0x3, 0xf, 0x69, 0x3b1, 0x289b, 0x20fdf, 0x1eee11, 0x20dcf21, 0x27065f73];\n// This is equivalent to `ODD_DOUBLEFACTORIAL_TABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_DOUBLEFACTORIAL_TABLE_LIMIT: usize = 19;\n// This is equivalent to `ODD_DOUBLEFACTORIAL_TABLE_MAX` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_DOUBLEFACTORIAL_TABLE_MAX: Limb = 0x27065f73;\n\n// This is equivalent to `__gmp_limbroots_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\n// `NTH_ROOT_NUMB_MASK_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const NTH_ROOT_NUMB_MASK_TABLE: [Limb; 8] =\n    [Limb::MAX, 0xffff, 0x659, 0xff, 0x54, 0x28, 0x17, 0xf];\n\n// This is equivalent to `ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE: [Limb; 31] = [\n    0x1, 0xaaaaaaab, 0xaaaaaaab, 0xeeeeeeef, 0xa4fa4fa5, 0xf2ff2ff3, 0xf2ff2ff3, 0x53e3771b,\n    0xdd93e49f, 0xfcdee63d, 0x544a4cbf, 0x7ca340fb, 0xa417526d, 0xd7bd49c3, 0xd7bd49c3, 0x85294093,\n    0xf259eabb, 0xd6dc4fb9, 0x915f4325, 0x131cead1, 0xea76fe13, 0x633cd365, 0x21144677, 0x200b0d0f,\n    0x8c4f9e8b, 0x21a42251, 0xe03c04e7, 0x600211d3, 0x4aaacdfd, 0x33f4fe63, 0x33f4fe63,\n];\n\npub(crate) const ODD_CENTRAL_BINOMIAL_OFFSET: usize = 8;\n\n// This table contains binomial(2k, k) / 2 ^ t.\n//\n// This is equivalent to `bin2kk` in `mpz/bin_uiui.c`, GMP 6.2.1, and\n// `ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE: [Limb; 11] = [\n    0x1923, 0x2f7b, 0xb46d, 0x15873, 0xa50c7, 0x13d66b, 0x4c842f, 0x93ee7d, 0x11e9e123, 0x22c60053,\n    0x873ae4d1,\n];\n\npub(crate) const ODD_CENTRAL_BINOMIAL_TABLE_LIMIT: usize = 18;\n\n// This table contains the inverses of elements in the previous table.\n//\n// This is equivalent to `bin2kkinv` in `mpz/bin_uiui.c`, GMP 6.2.1, and\n// `ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE: [Limb; 11] = [\n    0x16a2de8b, 0x847457b3, 0xfa6f7565, 0xf0e50cbb, 0xdca370f7, 0x9bb12643, 0xdc8342cf, 0x4ebf7ad5,\n    0x86ab568b, 0x265843db, 0x8633f431,\n];\n\n// This table contains the values t in the formula binomial(2k, k) / 2 ^ t.\n//\n// This is equivalent to `fac2bin` in `mpz/bin_uiui.c`, GMP 6.2.1, and `CENTRAL_BINOMIAL_2FAC_TABLE`\n// from `fac_table.h`, GMP 6.2.1.\npub(crate) const CENTRAL_BINOMIAL_2FAC_TABLE: [u64; 11] = [1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2];\n\n// https://oeis.org/A005187, skipping the initial 0\n//\n// This is equivalent to `__gmp_fac2cnt_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\n// `TABLE_2N_MINUS_POPC_2N` from `fac_table.h`, GMP 6.2.1.\npub(crate) const TABLE_2N_MINUS_POPC_2N: [u8; 24] =\n    [1, 3, 4, 7, 8, 10, 11, 15, 16, 18, 19, 22, 23, 25, 26, 31, 32, 34, 35, 38, 39, 41, 42, 46];\n\npub(crate) const TABLE_LIMIT_2N_MINUS_POPC_2N: u64 = 49;\n\n// end of auto-generated code\n"
  },
  {
    "path": "malachite-nz/src/platform_64.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `bin2kk`, `bin2kkinv`, and `fac2bin` contributed to the GNU project by Torbjörn Granlund\n//      and Marco Bodrato.\n//\n//      Copyright © 2002, 2010-2018 Free Software Foundation, Inc.\n//\n// Uses code adopted from the GNU MPFR Library.\n//\n//      Copyright © 2005-2022 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub type Limb = u64;\npub type HalfLimb = u32;\npub type DoubleLimb = u128;\npub type SignedLimb = i64;\npub type SignedHalfLimb = i32;\npub type SignedDoubleLimb = i128;\npub type FloatWithLimbWidth = f64;\n\npub(crate) const MAX_DIGITS_PER_LIMB: usize = 20;\n\npub(crate) const AORSMUL_FASTER_2AORSLSH: bool = true;\npub(crate) const AORSMUL_FASTER_3AORSLSH: bool = true;\npub(crate) const AORSMUL_FASTER_AORS_AORSLSH: bool = true;\npub(crate) const AORSMUL_FASTER_AORS_2AORSLSH: bool = true;\n\npub(crate) const MUL_TOOM22_THRESHOLD: usize = 20;\npub(crate) const MUL_TOOM33_THRESHOLD: usize = 39;\npub(crate) const MUL_TOOM44_THRESHOLD: usize = 340; // unclear when 44 is better than 33\npub(crate) const MUL_TOOM6H_THRESHOLD: usize = 345;\npub(crate) const MUL_TOOM8H_THRESHOLD: usize = 640;\n\npub(crate) const MUL_TOOM32_TO_TOOM43_THRESHOLD: usize = 60;\npub(crate) const MUL_TOOM32_TO_TOOM53_THRESHOLD: usize = 300;\npub(crate) const MUL_TOOM42_TO_TOOM53_THRESHOLD: usize = 600;\npub(crate) const MUL_TOOM42_TO_TOOM63_THRESHOLD: usize = 103;\n\npub(crate) const MUL_FFT_THRESHOLD: usize = 1500;\n\npub(crate) const DC_DIV_QR_THRESHOLD: usize = 85;\npub(crate) const DC_DIVAPPR_Q_THRESHOLD: usize = 211;\npub(crate) const MAYBE_DCP1_DIVAPPR: bool = true;\npub(crate) const INV_NEWTON_THRESHOLD: usize = 789;\npub(crate) const MU_DIV_QR_THRESHOLD: usize = 2094;\npub(crate) const INV_MULMOD_BNM1_THRESHOLD: usize = 62;\npub(crate) const MU_DIV_QR_SKEW_THRESHOLD: usize = 231;\n\npub(crate) const MU_DIVAPPR_Q_THRESHOLD: usize = 2965;\npub(crate) const FUDGE: usize = 311;\n\npub(crate) const MULLO_BASECASE_THRESHOLD: usize = 1;\npub(crate) const MULLO_DC_THRESHOLD: usize = 56;\npub(crate) const MULLO_MUL_N_THRESHOLD: usize = 10806;\n\npub(crate) const BINV_NEWTON_THRESHOLD: usize = 2211;\npub(crate) const DC_BDIV_QR_THRESHOLD: usize = 211;\npub(crate) const MU_BDIV_QR_THRESHOLD: usize = 7547;\npub(crate) const DC_BDIV_Q_THRESHOLD: usize = 211;\npub(crate) const MU_BDIV_Q_THRESHOLD: usize = 1998;\n\npub(crate) const MOD_1_NORM_THRESHOLD: usize = 0;\npub(crate) const MOD_1_UNNORM_THRESHOLD: usize = 0;\npub(crate) const MOD_1_1P_METHOD: bool = false;\npub(crate) const MOD_1N_TO_MOD_1_1_THRESHOLD: usize = 3;\npub(crate) const MOD_1U_TO_MOD_1_1_THRESHOLD: usize = 0;\npub(crate) const MOD_1_1_TO_MOD_1_2_THRESHOLD: usize = 6;\npub(crate) const MOD_1_2_TO_MOD_1_4_THRESHOLD: usize = 26;\n\npub(crate) const BMOD_1_TO_MOD_1_THRESHOLD: usize = 100000000;\n\npub(crate) const SQR_BASECASE_THRESHOLD: usize = 0;\npub(crate) const SQR_TOOM2_THRESHOLD: usize = 43;\npub(crate) const SQR_TOOM3_THRESHOLD: usize = 390;\npub(crate) const SQR_TOOM4_THRESHOLD: usize = 1090;\npub(crate) const SQR_TOOM6_THRESHOLD: usize = 336;\npub(crate) const SQR_TOOM8_THRESHOLD: usize = 837;\n\npub(crate) const SQRLO_DC_THRESHOLD: usize = 389;\n\npub(crate) const FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD: u64 = 6500;\n\npub(crate) const MATRIX22_STRASSEN_THRESHOLD: usize = 30;\n\n// This section is created by digits_data.rs.\n\n// mp_bases[10] data, as literal values\npub(crate) const MP_BASES_CHARS_PER_LIMB_10: usize = 19;\npub(crate) const MP_BASES_BIG_BASE_10: Limb = 0x8ac7230489e80000;\npub(crate) const MP_BASES_BIG_BASE_INVERTED_10: Limb = 0xd83c94fb6d2ac34a;\npub(crate) const MP_BASES_NORMALIZATION_STEPS_10: u64 = 0;\n\n// Format is (chars_per_limb, logb2, log2b, big_base, big_base_inverted)\npub(crate) const BASES: [(usize, Limb, Limb, Limb, Limb); 257] = [\n    (0, 0, 0, 0, 0),                                        // 0\n    (0, 0, 0, 0, 0),                                        // 1\n    (64, 0xffffffffffffffff, 0x1fffffffffffffff, 0x1, 0x0), // 2\n    (\n        40,\n        0xa1849cc1a9a9e94e,\n        0x32b803473f7ad0f3,\n        0xa8b8b452291fe821,\n        0x846d550e37b5063d,\n    ), // 3\n    (32, 0x7fffffffffffffff, 0x3fffffffffffffff, 0x2, 0x0), // 4\n    (\n        27,\n        0x6e40d1a4143dcb94,\n        0x4a4d3c25e68dc57f,\n        0x6765c793fa10079d,\n        0x3ce9a36f23c0fc90,\n    ), // 5\n    (\n        24,\n        0x6308c91b702a7cf4,\n        0x52b803473f7ad0f3,\n        0x41c21cb8e1000000,\n        0xf24f62335024a295,\n    ), // 6\n    (\n        22,\n        0x5b3064eb3aa6d388,\n        0x59d5d9fd5010b366,\n        0x3642798750226111,\n        0x2df495ccaa57147b,\n    ), // 7\n    (21, 0x5555555555555555, 0x5fffffffffffffff, 0x3, 0x0), // 8\n    (\n        20,\n        0x50c24e60d4d4f4a7,\n        0x6570068e7ef5a1e7,\n        0xa8b8b452291fe821,\n        0x846d550e37b5063d,\n    ), // 9\n    (\n        19,\n        0x4d104d427de7fbcc,\n        0x6a4d3c25e68dc57f,\n        0x8ac7230489e80000,\n        0xd83c94fb6d2ac34a,\n    ), // 10\n    (\n        18,\n        0x4a00270775914e88,\n        0x6eb3a9f01975077f,\n        0x4d28cb56c33fa539,\n        0xa8adf7ae45e7577b,\n    ), // 11\n    (\n        17,\n        0x4768ce0d05818e12,\n        0x72b803473f7ad0f3,\n        0x1eca170c00000000,\n        0xa10c2bec5da8f8f,\n    ), // 12\n    (\n        17,\n        0x452e53e365907bda,\n        0x766a008e4788cbcd,\n        0x780c7372621bd74d,\n        0x10f4becafe412ec3,\n    ), // 13\n    (\n        16,\n        0x433cfffb4b5aae55,\n        0x79d5d9fd5010b366,\n        0x1e39a5057d810000,\n        0xf08480f672b4e86,\n    ), // 14\n    (\n        16,\n        0x41867711b4f85355,\n        0x7d053f6d26089673,\n        0x5b27ac993df97701,\n        0x6779c7f90dc42f48,\n    ), // 15\n    (16, 0x3fffffffffffffff, 0x7fffffffffffffff, 0x4, 0x0), // 16\n    (\n        15,\n        0x3ea16afd58b10966,\n        0x82cc7edf592262cf,\n        0x27b95e997e21d9f1,\n        0x9c71e11bab279323,\n    ), // 17\n    (\n        15,\n        0x3d64598d154dc4de,\n        0x8570068e7ef5a1e7,\n        0x5da0e1e53c5c8000,\n        0x5dfaa697ec6f6a1c,\n    ), // 18\n    (\n        15,\n        0x3c43c23018bb5563,\n        0x87ef05ae409a0288,\n        0xd2ae3299c1c4aedb,\n        0x3711783f6be7e9ec,\n    ), // 19\n    (\n        14,\n        0x3b3b9a42873069c7,\n        0x8a4d3c25e68dc57f,\n        0x16bcc41e90000000,\n        0x6849b86a12b9b01e,\n    ), // 20\n    (\n        14,\n        0x3a4898f06cf41ac9,\n        0x8c8ddd448f8b845a,\n        0x2d04b7fdd9c0ef49,\n        0x6bf097ba5ca5e239,\n    ), // 21\n    (\n        14,\n        0x39680b13582e7c18,\n        0x8eb3a9f01975077f,\n        0x5658597bcaa24000,\n        0x7b8015c8d7af8f08,\n    ), // 22\n    (\n        14,\n        0x3897b2b751ae561a,\n        0x90c10500d63aa658,\n        0xa0e2073737609371,\n        0x975a24b3a3151b38,\n    ), // 23\n    (\n        13,\n        0x37d5aed131f19c98,\n        0x92b803473f7ad0f3,\n        0xc29e98000000000,\n        0x50bd367972689db1,\n    ), // 24\n    (\n        13,\n        0x372068d20a1ee5ca,\n        0x949a784bcd1b8afe,\n        0x14adf4b7320334b9,\n        0x8c240c4aecb13bb5,\n    ), // 25\n    (\n        13,\n        0x3676867e5d60de29,\n        0x966a008e4788cbcd,\n        0x226ed36478bfa000,\n        0xdbd2e56854e118c9,\n    ), // 26\n    (\n        13,\n        0x35d6deeb388df86f,\n        0x982809d5be7072db,\n        0x383d9170b85ff80b,\n        0x2351ffcaa9c7c4ae,\n    ), // 27\n    (\n        13,\n        0x354071d61c77fa2e,\n        0x99d5d9fd5010b366,\n        0x5a3c23e39c000000,\n        0x6b24188ca33b0636,\n    ), // 28\n    (\n        13,\n        0x34b260c5671b18ac,\n        0x9b74948f5532da4b,\n        0x8e65137388122bcd,\n        0xcc3dceaf2b8ba99d,\n    ), // 29\n    (\n        13,\n        0x342be986572b45cc,\n        0x9d053f6d26089673,\n        0xdd41bb36d259e000,\n        0x2832e835c6c7d6b6,\n    ), // 30\n    (\n        12,\n        0x33ac61b998fbbdf2,\n        0x9e88c6b3626a72aa,\n        0xaee5720ee830681,\n        0x76b6aa272e1873c5,\n    ), // 31\n    (12, 0x3333333333333333, 0x9fffffffffffffff, 0x5, 0x0), // 32\n    (\n        12,\n        0x32bfd90114c12861,\n        0xa16bad3758efd873,\n        0x172588ad4f5f0981,\n        0x61eaf5d402c7bf4f,\n    ), // 33\n    (\n        12,\n        0x3251dcf6169e45f2,\n        0xa2cc7edf592262cf,\n        0x211e44f7d02c1000,\n        0xeeb658123ffb27ec,\n    ), // 34\n    (\n        12,\n        0x31e8d59f180dc630,\n        0xa4231623369e78e5,\n        0x2ee56725f06e5c71,\n        0x5d5e3762e6fdf509,\n    ), // 35\n    (\n        12,\n        0x3184648db8153e7a,\n        0xa570068e7ef5a1e7,\n        0x41c21cb8e1000000,\n        0xf24f62335024a295,\n    ), // 36\n    (\n        12,\n        0x312434e89c35dacd,\n        0xa6b3d78b6d3b24fb,\n        0x5b5b57f8a98a5dd1,\n        0x66ae7831762efb6f,\n    ), // 37\n    (\n        12,\n        0x30c7fa349460a541,\n        0xa7ef05ae409a0288,\n        0x7dcff8986ea31000,\n        0x47388865a00f544,\n    ), // 38\n    (\n        12,\n        0x306f6f4c8432bc6d,\n        0xa92203d587039cc1,\n        0xabd4211662a6b2a1,\n        0x7d673c33a123b54c,\n    ), // 39\n    (\n        12,\n        0x301a557ffbfdd252,\n        0xaa4d3c25e68dc57f,\n        0xe8d4a51000000000,\n        0x19799812dea11197,\n    ), // 40\n    (\n        11,\n        0x2fc873d1fda55f3b,\n        0xab7110e6ce866f2b,\n        0x7a32956ad081b79,\n        0xc27e62e0686feae,\n    ), // 41\n    (\n        11,\n        0x2f799652a4e6dc49,\n        0xac8ddd448f8b845a,\n        0x9f49aaff0e86800,\n        0x9b6e7507064ce7c7,\n    ), // 42\n    (\n        11,\n        0x2f2d8d8f64460aad,\n        0xada3f5fb9c415052,\n        0xce583bb812d37b3,\n        0x3d9ac2bf66cfed94,\n    ), // 43\n    (\n        11,\n        0x2ee42e164e8f53a4,\n        0xaeb3a9f01975077f,\n        0x109b79a654c00000,\n        0xed46bc50ce59712a,\n    ), // 44\n    (\n        11,\n        0x2e9d500984041dbd,\n        0xafbd42b465836767,\n        0x1543beff214c8b95,\n        0x813d97e2c89b8d46,\n    ), // 45\n    (\n        11,\n        0x2e58cec05a6a8144,\n        0xb0c10500d63aa658,\n        0x1b149a79459a3800,\n        0x2e81751956af8083,\n    ), // 46\n    (\n        11,\n        0x2e1688743ef9104c,\n        0xb1bf311e95d00de3,\n        0x224edfb5434a830f,\n        0xdd8e0a95e30c0988,\n    ), // 47\n    (\n        11,\n        0x2dd65df7a583598f,\n        0xb2b803473f7ad0f3,\n        0x2b3fb00000000000,\n        0x7ad4dd48a0b5b167,\n    ), // 48\n    (\n        11,\n        0x2d9832759d5369c4,\n        0xb3abb3faa02166cc,\n        0x3642798750226111,\n        0x2df495ccaa57147b,\n    ), // 49\n    (\n        11,\n        0x2d5beb38dcd1394c,\n        0xb49a784bcd1b8afe,\n        0x43c33c1937564800,\n        0xe392010175ee5962,\n    ), // 50\n    (\n        11,\n        0x2d216f7943e2ba6a,\n        0xb5848226989d33c3,\n        0x54411b2441c3cd8b,\n        0x84eaf11b2fe7738e,\n    ), // 51\n    (\n        11,\n        0x2ce8a82efbb3ff2c,\n        0xb66a008e4788cbcd,\n        0x6851455acd400000,\n        0x3a1e3971e008995d,\n    ), // 52\n    (\n        11,\n        0x2cb17fea7ad7e332,\n        0xb74b1fd64e0753c6,\n        0x80a23b117c8feb6d,\n        0xfd7a462344ffce25,\n    ), // 53\n    (\n        11,\n        0x2c7be2b0cfa1ba50,\n        0xb82809d5be7072db,\n        0x9dff7d32d5dc1800,\n        0x9eca40b40ebcef8a,\n    ), // 54\n    (\n        11,\n        0x2c47bddba92d7463,\n        0xb900e6160002ccfe,\n        0xc155af6faeffe6a7,\n        0x52fa161a4a48e43d,\n    ), // 55\n    (\n        11,\n        0x2c14fffcaa8b131e,\n        0xb9d5d9fd5010b366,\n        0xebb7392e00000000,\n        0x1607a2cbacf930c1,\n    ), // 56\n    (\n        10,\n        0x2be398c3a38be053,\n        0xbaa708f58014d37c,\n        0x50633659656d971,\n        0x97a014f8e3be55f1,\n    ), // 57\n    (\n        10,\n        0x2bb378e758451068,\n        0xbb74948f5532da4b,\n        0x5fa8624c7fba400,\n        0x568df8b76cbf212c,\n    ), // 58\n    (\n        10,\n        0x2b8492108be5e5f7,\n        0xbc3e9ca2e1a05533,\n        0x717d9faa73c5679,\n        0x20ba7c4b4e6ef492,\n    ), // 59\n    (\n        10,\n        0x2b56d6c70d55481b,\n        0xbd053f6d26089673,\n        0x86430aac6100000,\n        0xe81ee46b9ef492f5,\n    ), // 60\n    (\n        10,\n        0x2b2a3a608c72ddd5,\n        0xbdc899ab3ff56c5e,\n        0x9e64d9944b57f29,\n        0x9dc0d10d51940416,\n    ), // 61\n    (\n        10,\n        0x2afeb0f1060c7e41,\n        0xbe88c6b3626a72aa,\n        0xba5ca5392cb0400,\n        0x5fa8ed2f450272a5,\n    ), // 62\n    (\n        10,\n        0x2ad42f3c9aca595c,\n        0xbf45e08bcf06554e,\n        0xdab2ce1d022cd81,\n        0x2ba9eb8c5e04e641,\n    ), // 63\n    (10, 0x2aaaaaaaaaaaaaaa, 0xbfffffffffffffff, 0x6, 0x0), // 64\n    (\n        10,\n        0x2a82193a13425883,\n        0xc0b73cb42e16914c,\n        0x12aeed5fd3e2d281,\n        0xb67759cc00287bf1,\n    ), // 65\n    (\n        10,\n        0x2a5a717672f66450,\n        0xc16bad3758efd873,\n        0x15c3da1572d50400,\n        0x78621feeb7f4ed33,\n    ), // 66\n    (\n        10,\n        0x2a33aa6e56d9c71c,\n        0xc21d6713f453f356,\n        0x194c05534f75ee29,\n        0x43d55b5f72943bc0,\n    ), // 67\n    (\n        10,\n        0x2a0dbbaa3bdfcea4,\n        0xc2cc7edf592262cf,\n        0x1d56299ada100000,\n        0x173decb64d1d4409,\n    ), // 68\n    (\n        10,\n        0x29e89d244eb4bfaf,\n        0xc379084815b5774c,\n        0x21f2a089a4ff4f79,\n        0xe29fb54fd6b6074f,\n    ), // 69\n    (\n        10,\n        0x29c44740d7db51e6,\n        0xc4231623369e78e5,\n        0x2733896c68d9a400,\n        0xa1f1f5c210d54e62,\n    ), // 70\n    (\n        10,\n        0x29a0b2c743b14d74,\n        0xc4caba789e2b8687,\n        0x2d2cf2c33b533c71,\n        0x6aac7f9bfafd57b2,\n    ), // 71\n    (\n        10,\n        0x297dd8dbb7c22a2d,\n        0xc570068e7ef5a1e7,\n        0x33f506e440000000,\n        0x3b563c2478b72ee2,\n    ), // 72\n    (\n        10,\n        0x295bb2f9285c8c1b,\n        0xc6130af40bc0ecbf,\n        0x3ba43bec1d062211,\n        0x12b536b574e92d1b,\n    ), // 73\n    (\n        10,\n        0x293a3aebe2be1c92,\n        0xc6b3d78b6d3b24fb,\n        0x4455872d8fd4e400,\n        0xdf86c03020404fa5,\n    ), // 74\n    (\n        10,\n        0x29196acc815ebd9f,\n        0xc7527b930c965bf2,\n        0x4e2694539f2f6c59,\n        0xa34adf02234eea8e,\n    ), // 75\n    (\n        10,\n        0x28f93cfb40f5c22a,\n        0xc7ef05ae409a0288,\n        0x5938006c18900000,\n        0x6f46eb8574eb59dd,\n    ), // 76\n    (\n        10,\n        0x28d9ac1badc64117,\n        0xc88983ed6985bae5,\n        0x65ad9912474aa649,\n        0x42459b481df47cec,\n    ), // 77\n    (\n        10,\n        0x28bab310a196b478,\n        0xc92203d587039cc1,\n        0x73ae9ff4241ec400,\n        0x1b424b95d80ca505,\n    ), // 78\n    (\n        10,\n        0x289c4cf88b774469,\n        0xc9b892675266f66c,\n        0x836612ee9c4ce1e1,\n        0xf2c1b982203a0dac,\n    ), // 79\n    (\n        10,\n        0x287e7529fb244e91,\n        0xca4d3c25e68dc57f,\n        0x9502f90000000000,\n        0xb7cdfd9d7bdbab7d,\n    ), // 80\n    (\n        10,\n        0x286127306a6a7a53,\n        0xcae00d1cfdeb43cf,\n        0xa8b8b452291fe821,\n        0x846d550e37b5063d,\n    ), // 81\n    (\n        10,\n        0x28445ec93f792b1e,\n        0xcb7110e6ce866f2b,\n        0xbebf59a07dab4400,\n        0x57931eeaf85cf64f,\n    ), // 82\n    (\n        10,\n        0x282817e1038950fa,\n        0xcc0052b18b0e2a19,\n        0xd7540d4093bc3109,\n        0x305a944507c82f47,\n    ), // 83\n    (\n        10,\n        0x280c4e90c9ab1f45,\n        0xcc8ddd448f8b845a,\n        0xf2b96616f1900000,\n        0xe007ccc9c22781a,\n    ), // 84\n    (\n        9,\n        0x27f0ff1bc1ee87cd,\n        0xcd19bb053fb0284e,\n        0x336de62af2bca35,\n        0x3e92c42e000eeed4,\n    ), // 85\n    (\n        9,\n        0x27d625ecf571c340,\n        0xcda3f5fb9c415052,\n        0x39235ec33d49600,\n        0x1ebe59130db2795e,\n    ), // 86\n    (\n        9,\n        0x27bbbf95282fcd45,\n        0xce2c97d694adab3f,\n        0x3f674e539585a17,\n        0x268859e90f51b89,\n    ), // 87\n    (\n        9,\n        0x27a1c8c8ddaf84da,\n        0xceb3a9f01975077f,\n        0x4645b6958000000,\n        0xd24cde0463108cfa,\n    ), // 88\n    (\n        9,\n        0x27883e5e7df3f518,\n        0xcf393550f3aa6906,\n        0x4dcb74afbc49c19,\n        0xa536009f37adc383,\n    ), // 89\n    (\n        9,\n        0x276f1d4c9847e90e,\n        0xcfbd42b465836767,\n        0x56064e1d18d9a00,\n        0x7cea06ce1c9ace10,\n    ), // 90\n    (\n        9,\n        0x275662a841b30191,\n        0xd03fda8b97997f33,\n        0x5f04fe2cd8a39fb,\n        0x58db032e72e8ba43,\n    ), // 91\n    (\n        9,\n        0x273e0ba38d15a47b,\n        0xd0c10500d63aa658,\n        0x68d74421f5c0000,\n        0x388cc17cae105447,\n    ), // 92\n    (\n        9,\n        0x2726158c1b13cf03,\n        0xd140c9faa1e5439e,\n        0x738df1f6ab4827d,\n        0x1b92672857620ce0,\n    ), // 93\n    (\n        9,\n        0x270e7dc9c01d8e9b,\n        0xd1bf311e95d00de3,\n        0x7f3afbc9cfb5e00,\n        0x18c6a9575c2ade4,\n    ), // 94\n    (\n        9,\n        0x26f741dd3f070d61,\n        0xd23c41d42727c808,\n        0x8bf187fba88f35f,\n        0xd44da7da8e44b24f,\n    ), // 95\n    (\n        9,\n        0x26e05f5f16c2159e,\n        0xd2b803473f7ad0f3,\n        0x99c600000000000,\n        0xaa2f78f1b4cc6794,\n    ), // 96\n    (\n        9,\n        0x26c9d3fe61e80598,\n        0xd3327c6ab49ca6c8,\n        0xa8ce21eb6531361,\n        0x843c067d091ee4cc,\n    ), // 97\n    (\n        9,\n        0x26b39d7fc6ddab08,\n        0xd3abb3faa02166cc,\n        0xb92112c1a0b6200,\n        0x62005e1e913356e3,\n    ), // 98\n    (\n        9,\n        0x269db9bc7772a5cc,\n        0xd423b07e986aa967,\n        0xcad7718b8747c43,\n        0x4316eed01dedd518,\n    ), // 99\n    (\n        9,\n        0x268826a13ef3fde6,\n        0xd49a784bcd1b8afe,\n        0xde0b6b3a7640000,\n        0x2725dd1d243aba0e,\n    ), // 100\n    (\n        9,\n        0x2672e22d9dbdbd9f,\n        0xd510118708a8f8dd,\n        0xf2d8cf5fe6d74c5,\n        0xddd9057c24cb54f,\n    ), // 101\n    (\n        9,\n        0x265dea72f169cc99,\n        0xd5848226989d33c3,\n        0x1095d25bfa712600,\n        0xedeee175a736d2a1,\n    ), // 102\n    (\n        9,\n        0x26493d93a8cb2514,\n        0xd5f7cff41e09aeb8,\n        0x121b7c4c3698faa7,\n        0xc4699f3df8b6b328,\n    ), // 103\n    (\n        9,\n        0x2634d9c282f3ef82,\n        0xd66a008e4788cbcd,\n        0x13c09e8d68000000,\n        0x9ebbe7d859cb5a7c,\n    ), // 104\n    (\n        9,\n        0x2620bd41d8933adc,\n        0xd6db196a761949d9,\n        0x15876ccb0b709ca9,\n        0x7c828b9887eb2179,\n    ), // 105\n    (\n        9,\n        0x260ce662ef04088a,\n        0xd74b1fd64e0753c6,\n        0x17723c2976da2a00,\n        0x5d652ab99001adcf,\n    ), // 106\n    (\n        9,\n        0x25f95385547353fd,\n        0xd7ba18f93502e409,\n        0x198384e9c259048b,\n        0x4114f1754e5d7b32,\n    ), // 107\n    (\n        9,\n        0x25e60316448db8e1,\n        0xd82809d5be7072db,\n        0x1bbde41dfeec0000,\n        0x274b7c902f7e0188,\n    ), // 108\n    (\n        9,\n        0x25d2f390152f74f5,\n        0xd894f74b06ef8b40,\n        0x1e241d6e3337910d,\n        0xfc9e0fbb32e210c,\n    ), // 109\n    (\n        9,\n        0x25c02379aa9ad043,\n        0xd900e6160002ccfe,\n        0x20b91cee9901ee00,\n        0xf4afa3e594f8ea1f,\n    ), // 110\n    (\n        9,\n        0x25ad9165f2c18907,\n        0xd96bdad2acb5f5ef,\n        0x237ff9079863dfef,\n        0xcd85c32e9e4437b0,\n    ), // 111\n    (\n        9,\n        0x259b3bf36735c90c,\n        0xd9d5d9fd5010b366,\n        0x267bf47000000000,\n        0xa9bbb147e0dd92a8,\n    ), // 112\n    (\n        9,\n        0x258921cb955e7693,\n        0xda3ee7f38e181ed0,\n        0x29b08039fbeda7f1,\n        0x8900447b70e8eb82,\n    ), // 113\n    (\n        9,\n        0x257741a2ac9170af,\n        0xdaa708f58014d37c,\n        0x2d213df34f65f200,\n        0x6b0a92adaad5848a,\n    ), // 114\n    (\n        9,\n        0x25659a3711bc827d,\n        0xdb0e4126bcc86bd7,\n        0x30d201d957a7c2d3,\n        0x4f990ad8740f0ee5,\n    ), // 115\n    (\n        9,\n        0x25542a50f84b9c39,\n        0xdb74948f5532da4b,\n        0x34c6d52160f40000,\n        0x3670a9663a8d3610,\n    ), // 116\n    (\n        9,\n        0x2542f0c20000377d,\n        0xdbda071cc67e6db5,\n        0x3903f855d8f4c755,\n        0x1f5c44188057be3c,\n    ), // 117\n    (\n        9,\n        0x2531ec64d772bd64,\n        0xdc3e9ca2e1a05533,\n        0x3d8de5c8ec59b600,\n        0xa2bea956c4e4977,\n    ), // 118\n    (\n        9,\n        0x25211c1ce2fb5a6e,\n        0xdca258dca9331635,\n        0x4269541d1ff01337,\n        0xed68b23033c3637e,\n    ), // 119\n    (\n        9,\n        0x25107ed5e7c3ec3b,\n        0xdd053f6d26089673,\n        0x479b38e478000000,\n        0xc99cf624e50549c5,\n    ), // 120\n    (\n        9,\n        0x25001383bac8a744,\n        0xdd6753e032ea0efe,\n        0x4d28cb56c33fa539,\n        0xa8adf7ae45e7577b,\n    ), // 121\n    (\n        9,\n        0x24efd921f390bce3,\n        0xddc899ab3ff56c5e,\n        0x5317871fa13aba00,\n        0x8a5bc740b1c113e5,\n    ), // 122\n    (\n        9,\n        0x24dfceb3a26bb203,\n        0xde29142e0e01401f,\n        0x596d2f44de9fa71b,\n        0x6e6c7efb81cfbb9b,\n    ), // 123\n    (\n        9,\n        0x24cff3430a0341a7,\n        0xde88c6b3626a72aa,\n        0x602fd125c47c0000,\n        0x54aba5c5cada5f10,\n    ), // 124\n    (\n        9,\n        0x24c045e15c149931,\n        0xdee7b471b3a9507d,\n        0x6765c793fa10079d,\n        0x3ce9a36f23c0fc90,\n    ), // 125\n    (\n        9,\n        0x24b0c5a679267ae2,\n        0xdf45e08bcf06554e,\n        0x6f15be069b847e00,\n        0x26fb43de2c8cd2a8,\n    ), // 126\n    (\n        9,\n        0x24a171b0b31461c8,\n        0xdfa34e1177c23362,\n        0x7746b3e82a77047f,\n        0x12b94793db8486a1,\n    ), // 127\n    (9, 0x2492492492492492, 0xdfffffffffffffff, 0x7, 0x0),  // 128\n    (\n        9,\n        0x24834b2c9d85cdfe,\n        0xe05bf942dbbc2145,\n        0x894953f7ea890481,\n        0xdd5deca404c0156d,\n    ), // 129\n    (\n        9,\n        0x247476f924137501,\n        0xe0b73cb42e16914c,\n        0x932abffea4848200,\n        0xbd51373330291de0,\n    ), // 130\n    (\n        9,\n        0x2465cbc00a40cec0,\n        0xe111cd1d5133412e,\n        0x9dacb687d3d6a163,\n        0x9fa4025d66f23085,\n    ), // 131\n    (\n        9,\n        0x245748bc980e0427,\n        0xe16bad3758efd873,\n        0xa8d8102a44840000,\n        0x842530ee2db4949d,\n    ), // 132\n    (\n        9,\n        0x2448ed2f49eb0633,\n        0xe1c4dfab90aab5ef,\n        0xb4b60f9d140541e5,\n        0x6aa7f2766b03dc25,\n    ), // 133\n    (\n        9,\n        0x243ab85da36e3167,\n        0xe21d6713f453f356,\n        0xc15065d4856e4600,\n        0x53035ba7ebf32e8d,\n    ), // 134\n    (\n        9,\n        0x242ca99203ea8c18,\n        0xe27545fba4fe385a,\n        0xceb1363f396d23c7,\n        0x3d12091fc9fb4914,\n    ), // 135\n    (\n        9,\n        0x241ec01b7cce4ea0,\n        0xe2cc7edf592262cf,\n        0xdce31b2488000000,\n        0x28b1cb81b1ef1849,\n    ), // 136\n    (\n        9,\n        0x2410fb4da9b3b0fc,\n        0xe323142dc8c66b55,\n        0xebf12a24bca135c9,\n        0x15c35be67ae3e2c9,\n    ), // 137\n    (\n        9,\n        0x24035a808a0f315e,\n        0xe379084815b5774c,\n        0xfbe6f8dbf88f4a00,\n        0x42a17bd09be1ff0,\n    ), // 138\n    (\n        8,\n        0x23f5dd105c67ab9d,\n        0xe3ce5d822ff4b643,\n        0x1ef156c084ce761,\n        0x8bf461f03cf0bbf,\n    ), // 139\n    (\n        8,\n        0x23e8825d7b05abb1,\n        0xe4231623369e78e5,\n        0x20c4e3b94a10000,\n        0xf3fbb43f68a32d05,\n    ), // 140\n    (\n        8,\n        0x23db49cc3a0866fe,\n        0xe4773465d54aded7,\n        0x22b0695a08ba421,\n        0xd84f44c48564dc19,\n    ), // 141\n    (\n        8,\n        0x23ce32c4c6cfb9f5,\n        0xe4caba789e2b8687,\n        0x24b4f35d7a4c100,\n        0xbe58ebcce7956abe,\n    ), // 142\n    (\n        8,\n        0x23c13cb308ab6ab7,\n        0xe51daa7e60fdd34c,\n        0x26d397284975781,\n        0xa5fac463c7c134b7,\n    ), // 143\n    (\n        8,\n        0x23b4670682c0c709,\n        0xe570068e7ef5a1e7,\n        0x290d74100000000,\n        0x8f19241e28c7d757,\n    ), // 144\n    (\n        8,\n        0x23a7b13237187c8b,\n        0xe5c1d0b53bc09fca,\n        0x2b63b3a37866081,\n        0x799a6d046c0ae1ae,\n    ), // 145\n    (\n        8,\n        0x239b1aac8ac74728,\n        0xe6130af40bc0ecbf,\n        0x2dd789f4d894100,\n        0x6566e37d746a9e40,\n    ), // 146\n    (\n        8,\n        0x238ea2ef2b24c379,\n        0xe663b741df9c37c0,\n        0x306a35e51b58721,\n        0x526887dbfb5f788f,\n    ), // 147\n    (\n        8,\n        0x23824976f4045a26,\n        0xe6b3d78b6d3b24fb,\n        0x331d01712e10000,\n        0x408af3382b8efd3d,\n    ), // 148\n    (\n        8,\n        0x23760dc3d6e4d729,\n        0xe7036db376537b90,\n        0x35f14200a827c61,\n        0x2fbb374806ec05f1,\n    ), // 149\n    (\n        8,\n        0x2369ef58c30bd43e,\n        0xe7527b930c965bf2,\n        0x38e858b62216100,\n        0x1fe7c0f0afce87fe,\n    ), // 150\n    (\n        8,\n        0x235dedbb8e82aa1c,\n        0xe7a102f9d39a9331,\n        0x3c03b2c13176a41,\n        0x11003d517540d32e,\n    ), // 151\n    (\n        8,\n        0x23520874dfeb1ffd,\n        0xe7ef05ae409a0288,\n        0x3f44c9b21000000,\n        0x2f5810f98eff0dc,\n    ), // 152\n    (\n        8,\n        0x23463f1019228dd7,\n        0xe83c856dd81804b7,\n        0x42ad23cef3113c1,\n        0xeb72e35e7840d910,\n    ), // 153\n    (\n        8,\n        0x233a911b42aa9b3c,\n        0xe88983ed6985bae5,\n        0x463e546b19a2100,\n        0xd27de19593dc3614,\n    ), // 154\n    (\n        8,\n        0x232efe26f7cf33f9,\n        0xe8d602d948f83829,\n        0x49f9fc3f96684e1,\n        0xbaf391fd3e5e6fc2,\n    ), // 155\n    (\n        8,\n        0x232385c65381b485,\n        0xe92203d587039cc1,\n        0x4de1c9c5dc10000,\n        0xa4bd38c55228c81d,\n    ), // 156\n    (\n        8,\n        0x2318278edde1b39b,\n        0xe96d887e26cd57b7,\n        0x51f77994116d2a1,\n        0x8fc5a8de8e1de782,\n    ), // 157\n    (\n        8,\n        0x230ce3187a6c2be9,\n        0xe9b892675266f66c,\n        0x563cd6bb3398100,\n        0x7bf9265bea9d3a3b,\n    ), // 158\n    (\n        8,\n        0x2301b7fd56ca21bb,\n        0xea03231d8d8224ba,\n        0x5ab3bb270beeb01,\n        0x69454b325983dccd,\n    ), // 159\n    (\n        8,\n        0x22f6a5d9da38341c,\n        0xea4d3c25e68dc57f,\n        0x5f5e10000000000,\n        0x5798ee2308c39df9,\n    ), // 160\n    (\n        8,\n        0x22ebac4c9580d89f,\n        0xea96defe264b59be,\n        0x643dce0ec16f501,\n        0x46e40ba0fa66a753,\n    ), // 161\n    (\n        8,\n        0x22e0caf633834beb,\n        0xeae00d1cfdeb43cf,\n        0x6954fe21e3e8100,\n        0x3717b0870b0db3a7,\n    ), // 162\n    (\n        8,\n        0x22d601796a418886,\n        0xeb28c7f233bdd372,\n        0x6ea5b9755f440a1,\n        0x2825e6775d11cdeb,\n    ), // 163\n    (\n        8,\n        0x22cb4f7aec6fd8b4,\n        0xeb7110e6ce866f2b,\n        0x74322a1c0410000,\n        0x1a01a1c09d1b4dac,\n    ), // 164\n    (\n        8,\n        0x22c0b4a15b80d83e,\n        0xebb8e95d3f7d9df2,\n        0x79fc8b6ae8a46e1,\n        0xc9eb0a8bebc8f3e,\n    ), // 165\n    (\n        8,\n        0x22b630953a28f77a,\n        0xec0052b18b0e2a19,\n        0x80072a66d512100,\n        0xffe357ff59e6a004,\n    ), // 166\n    (\n        8,\n        0x22abc300df54ca7c,\n        0xec474e39705912d2,\n        0x86546633b42b9c1,\n        0xe7dfd1be05fa61a8,\n    ), // 167\n    (\n        8,\n        0x22a16b90698da5d2,\n        0xec8ddd448f8b845a,\n        0x8ce6b0861000000,\n        0xd11ed6fc78f760e5,\n    ), // 168\n    (\n        8,\n        0x229729f1b2c83ded,\n        0xecd4011c8f11979a,\n        0x93c08e16a022441,\n        0xbb8db609dd29ebfe,\n    ), // 169\n    (\n        8,\n        0x228cfdd444992f78,\n        0xed19bb053fb0284e,\n        0x9ae49717f026100,\n        0xa71aec8d1813d532,\n    ), // 170\n    (\n        8,\n        0x2282e6e94ccb8588,\n        0xed5f0c3cbf8fa470,\n        0xa25577ae24c1a61,\n        0x93b612a9f20fbc02,\n    ), // 171\n    (\n        8,\n        0x2278e4e392557ecf,\n        0xeda3f5fb9c415052,\n        0xaa15f068e610000,\n        0x814fc7b19a67d317,\n    ), // 172\n    (\n        8,\n        0x226ef7776aa7fd29,\n        0xede87974f3c81855,\n        0xb228d6bf7577921,\n        0x6fd9a03f2e0a4b7c,\n    ), // 173\n    (\n        8,\n        0x22651e5aaf5532d0,\n        0xee2c97d694adab3f,\n        0xba91158ef5c4100,\n        0x5f4615a38d0d316e,\n    ), // 174\n    (\n        8,\n        0x225b5944b40b4694,\n        0xee7052491d2c3e64,\n        0xc351ad9aec0b681,\n        0x4f8876863479a286,\n    ), // 175\n    (\n        8,\n        0x2251a7ee3cdfcca5,\n        0xeeb3a9f01975077f,\n        0xcc6db6100000000,\n        0x4094d8a3041b60eb,\n    ), // 176\n    (\n        8,\n        0x22480a1174e913d9,\n        0xeef69fea211b2627,\n        0xd5e85d09025c181,\n        0x32600b8ed883a09b,\n    ), // 177\n    (\n        8,\n        0x223e7f69e522683c,\n        0xef393550f3aa6906,\n        0xdfc4e816401c100,\n        0x24df8c6eb4b6d1f1,\n    ), // 178\n    (\n        8,\n        0x223507b46b988abe,\n        0xef7b6b399471103e,\n        0xea06b4c72947221,\n        0x18097a8ee151acef,\n    ), // 179\n    (\n        8,\n        0x222ba2af32dbbb9e,\n        0xefbd42b465836767,\n        0xf4b139365210000,\n        0xbd48cc8ec1cd8e3,\n    ), // 180\n    (\n        8,\n        0x22225019a9b4d16c,\n        0xeffebccd41ffcd5c,\n        0xffc80497d520961,\n        0x3807a8d67485fb,\n    ), // 181\n    (\n        8,\n        0x22190fb47b1af172,\n        0xf03fda8b97997f33,\n        0x10b4ebfca1dee100,\n        0xea5768860b62e8d8,\n    ), // 182\n    (\n        8,\n        0x220fe14186679801,\n        0xf0809cf27f703d52,\n        0x117492de921fc141,\n        0xd54faf5b635c5005,\n    ), // 183\n    (\n        8,\n        0x2206c483d7c6b786,\n        0xf0c10500d63aa658,\n        0x123bb2ce41000000,\n        0xc14a56233a377926,\n    ), // 184\n    (\n        8,\n        0x21fdb93fa0e0ccc5,\n        0xf10113b153c8ea7b,\n        0x130a8b6157bdecc1,\n        0xae39a88db7cd329f,\n    ), // 185\n    (\n        8,\n        0x21f4bf3a31bcdcaa,\n        0xf140c9faa1e5439e,\n        0x13e15dede0e8a100,\n        0x9c10bde69efa7ab6,\n    ), // 186\n    (\n        8,\n        0x21ebd639f1d86584,\n        0xf18028cf72976a4e,\n        0x14c06d941c0ca7e1,\n        0x8ac36c42a2836497,\n    ), // 187\n    (\n        8,\n        0x21e2fe06597361a6,\n        0xf1bf311e95d00de3,\n        0x15a7ff487a810000,\n        0x7a463c8b84f5ef67,\n    ), // 188\n    (\n        8,\n        0x21da3667eb0e8ccb,\n        0xf1fde3d30e812642,\n        0x169859ddc5c697a1,\n        0x6a8e5f5ad090fd4b,\n    ), // 189\n    (\n        8,\n        0x21d17f282d1a300e,\n        0xf23c41d42727c808,\n        0x1791c60f6fed0100,\n        0x5b91a2943596fc56,\n    ), // 190\n    (\n        8,\n        0x21c8d811a3d3c9e1,\n        0xf27a4c0585cbf805,\n        0x18948e8c0e6fba01,\n        0x4d4667b1c468e8f0,\n    ), // 191\n    (\n        8,\n        0x21c040efcb50f858,\n        0xf2b803473f7ad0f3,\n        0x19a1000000000000,\n        0x3fa39ab547994daf,\n    ), // 192\n    (\n        8,\n        0x21b7b98f11b61c1a,\n        0xf2f56875eb3f2614,\n        0x1ab769203dafc601,\n        0x32a0a9b2faee1e2a,\n    ), // 193\n    (\n        8,\n        0x21af41bcd19739ba,\n        0xf3327c6ab49ca6c8,\n        0x1bd81ab557f30100,\n        0x26357ceac0e96962,\n    ), // 194\n    (\n        8,\n        0x21a6d9474c81adf0,\n        0xf36f3ffb6d916240,\n        0x1d0367a69fed1ba1,\n        0x1a5a6f65caa5859e,\n    ), // 195\n    (\n        8,\n        0x219e7ffda5ad572a,\n        0xf3abb3faa02166cc,\n        0x1e39a5057d810000,\n        0xf08480f672b4e86,\n    ), // 196\n    (\n        8,\n        0x219635afdcd3e46d,\n        0xf3e7d9379f70166a,\n        0x1f7b2a18f29ac3e1,\n        0x4383340615612ca,\n    ), // 197\n    (\n        8,\n        0x218dfa2ec92d0643,\n        0xf423b07e986aa967,\n        0x20c850694c2aa100,\n        0xf3c77969ee4be5a2,\n    ), // 198\n    (\n        8,\n        0x2185cd4c148e4ae2,\n        0xf45f3a98a20738a4,\n        0x222173cc014980c1,\n        0xe00993cc187c5ec9,\n    ), // 199\n    (\n        8,\n        0x217daeda36ad7a5c,\n        0xf49a784bcd1b8afe,\n        0x2386f26fc1000000,\n        0xcd2b297d889bc2b6,\n    ), // 200\n    (\n        8,\n        0x21759eac708452fe,\n        0xf4d56a5b33cec44a,\n        0x24f92ce8af296d41,\n        0xbb214d5064862b22,\n    ), // 201\n    (\n        8,\n        0x216d9c96c7d490d4,\n        0xf510118708a8f8dd,\n        0x2678863cd0ece100,\n        0xa9e1a7ca7ea10e20,\n    ), // 202\n    (\n        8,\n        0x2165a86e02cb358c,\n        0xf54a6e8ca5438db1,\n        0x280563f0a9472d61,\n        0x99626e72b39ea0cf,\n    ), // 203\n    (\n        8,\n        0x215dc207a3c20fdf,\n        0xf5848226989d33c3,\n        0x29a02e1406210000,\n        0x899a5ba9c13fafd9,\n    ), // 204\n    (\n        8,\n        0x2155e939e51e8b37,\n        0xf5be4d0cb51434aa,\n        0x2b494f4efe6d2e21,\n        0x7a80a705391e96ff,\n    ), // 205\n    (\n        8,\n        0x214e1ddbb54cd933,\n        0xf5f7cff41e09aeb8,\n        0x2d0134ef21cbc100,\n        0x6c0cfe23de23042a,\n    ), // 206\n    (\n        8,\n        0x21465fc4b2d68f98,\n        0xf6310b8f55304840,\n        0x2ec84ef4da2ef581,\n        0x5e377df359c944dd,\n    ), // 207\n    (\n        8,\n        0x213eaecd2893dd60,\n        0xf66a008e4788cbcd,\n        0x309f102100000000,\n        0x50f8ac5fc8f53985,\n    ), // 208\n    (\n        8,\n        0x21370ace09f681c6,\n        0xf6a2af9e5a0f0a08,\n        0x3285ee02a1420281,\n        0x44497266278e35b7,\n    ), // 209\n    (\n        8,\n        0x212f73a0ef6db7cb,\n        0xf6db196a761949d9,\n        0x347d6104fc324100,\n        0x382316831f7ee175,\n    ), // 210\n    (\n        8,\n        0x2127e92012e25004,\n        0xf7133e9b156c7be5,\n        0x3685e47dade53d21,\n        0x2c7f377833b8946e,\n    ), // 211\n    (\n        8,\n        0x21206b264c4a39a7,\n        0xf74b1fd64e0753c6,\n        0x389ff6bb15610000,\n        0x2157c761ab4163ef,\n    ), // 212\n    (\n        8,\n        0x2118f98f0e52c28f,\n        0xf782bdbfdda6577b,\n        0x3acc1912ebb57661,\n        0x16a7071803cc49a9,\n    ), // 213\n    (\n        8,\n        0x211194366320dc66,\n        0xf7ba18f93502e409,\n        0x3d0acff111946100,\n        0xc6781d80f8224fc,\n    ), // 214\n    (\n        8,\n        0x210a3af8e926bb78,\n        0xf7f1322182cf15d1,\n        0x3f5ca2e692eaf841,\n        0x294092d370a900b,\n    ), // 215\n    (\n        8,\n        0x2102edb3d00e29a6,\n        0xf82809d5be7072db,\n        0x41c21cb8e1000000,\n        0xf24f62335024a295,\n    ), // 216\n    (\n        8,\n        0x20fbac44d5b6edc2,\n        0xf85ea0b0b27b2610,\n        0x443bcb714399a5c1,\n        0xe03b98f103fad6d2,\n    ), // 217\n    (\n        8,\n        0x20f4768a4348ad08,\n        0xf894f74b06ef8b40,\n        0x46ca406c81af2100,\n        0xcee3d32cad2a9049,\n    ), // 218\n    (\n        8,\n        0x20ed4c62ea57b1f0,\n        0xf8cb0e3b4b3bbdb3,\n        0x496e106ac22aaae1,\n        0xbe3f9df9277fdada,\n    ), // 219\n    (\n        8,\n        0x20e62dae221c087a,\n        0xf900e6160002ccfe,\n        0x4c27d39fa5410000,\n        0xae46f0d94c05e933,\n    ), // 220\n    (\n        8,\n        0x20df1a4bc4ba6525,\n        0xf9367f6da0ab2e9c,\n        0x4ef825c296e43ca1,\n        0x9ef2280fb437a33d,\n    ), // 221\n    (\n        8,\n        0x20d8121c2c9e506e,\n        0xf96bdad2acb5f5ef,\n        0x51dfa61f5ad88100,\n        0x9039ff426d3f284b,\n    ), // 222\n    (\n        8,\n        0x20d1150031e51549,\n        0xf9a0f8d3b0e04fde,\n        0x54def7a6d2f16901,\n        0x82178c6d6b51f8f4,\n    ), // 223\n    (\n        8,\n        0x20ca22d927d8f54d,\n        0xf9d5d9fd5010b366,\n        0x57f6c10000000000,\n        0x74843b1ee4c1e053,\n    ), // 224\n    (\n        8,\n        0x20c33b88da7c29aa,\n        0xfa0a7eda4c112ce6,\n        0x5b27ac993df97701,\n        0x6779c7f90dc42f48,\n    ), // 225\n    (\n        8,\n        0x20bc5ef18c233bdf,\n        0xfa3ee7f38e181ed0,\n        0x5e7268b9bbdf8100,\n        0x5af23c74f9ad9fe9,\n    ), // 226\n    (\n        8,\n        0x20b58cf5f31e4526,\n        0xfa7315d02f20c7bd,\n        0x61d7a7932ff3d6a1,\n        0x4ee7eae2acdc617e,\n    ), // 227\n    (\n        8,\n        0x20aec5793770a74d,\n        0xfaa708f58014d37c,\n        0x65581f53c8c10000,\n        0x43556aa2ac262a0b,\n    ), // 228\n    (\n        8,\n        0x20a8085ef096d530,\n        0xfadac1e711c832d1,\n        0x68f48a385b8320e1,\n        0x3835949593b8ddd1,\n    ), // 229\n    (\n        8,\n        0x20a1558b2359c4b1,\n        0xfb0e4126bcc86bd7,\n        0x6cada69ed07c2100,\n        0x2d837fbe78458762,\n    ), // 230\n    (\n        8,\n        0x209aace23fafa72e,\n        0xfb418734a9008bd9,\n        0x70843718cdbf27c1,\n        0x233a7e150a54a555,\n    ), // 231\n    (\n        8,\n        0x20940e491ea988d7,\n        0xfb74948f5532da4b,\n        0x7479027ea1000000,\n        0x19561984a50ff8fe,\n    ), // 232\n    (\n        8,\n        0x208d79a5006d7a47,\n        0xfba769b39e49640e,\n        0x788cd40268f39641,\n        0xfd211159fe3490f,\n    ), // 233\n    (\n        8,\n        0x2086eedb8a3cead3,\n        0xfbda071cc67e6db5,\n        0x7cc07b437ecf6100,\n        0x6aa563e655033e3,\n    ), // 234\n    (\n        8,\n        0x20806dd2c486dcc6,\n        0xfc0c6d447c5dd362,\n        0x8114cc6220762061,\n        0xfbb614b3f2d3b14c,\n    ), // 235\n    (\n        8,\n        0x2079f67119059fae,\n        0xfc3e9ca2e1a05533,\n        0x858aa0135be10000,\n        0xeac0f8837fb05773,\n    ), // 236\n    (\n        8,\n        0x2073889d50e7bf63,\n        0xfc7095ae91e1c760,\n        0x8a22d3b53c54c321,\n        0xda6e4c10e8615ca5,\n    ), // 237\n    (\n        8,\n        0x206d243e9303d929,\n        0xfca258dca9331635,\n        0x8ede496339f34100,\n        0xcab755a8d01fa67f,\n    ), // 238\n    (\n        8,\n        0x2066c93c62170aa8,\n        0xfcd3e6a0ca8906c2,\n        0x93bde80aec3a1481,\n        0xbb95a9ae71aa3e0c,\n    ), // 239\n    (\n        8,\n        0x2060777e9b0db0f6,\n        0xfd053f6d26089673,\n        0x98c29b8100000000,\n        0xad0326c296b4f529,\n    ), // 240\n    (\n        8,\n        0x205a2eed73563032,\n        0xfd3663b27f31d529,\n        0x9ded549671832381,\n        0x9ef9f21eed31b7c1,\n    ), // 241\n    (\n        8,\n        0x2053ef71773d7e6a,\n        0xfd6753e032ea0efe,\n        0xa33f092e0b1ac100,\n        0x91747422be14b0b2,\n    ), // 242\n    (\n        8,\n        0x204db8f388552ea9,\n        0xfd9810643d6614c3,\n        0xa8b8b452291fe821,\n        0x846d550e37b5063d,\n    ), // 243\n    (\n        8,\n        0x20478b5cdbe2bb2f,\n        0xfdc899ab3ff56c5e,\n        0xae5b564ac3a10000,\n        0x77df79e9a96c06f6,\n    ), // 244\n    (\n        8,\n        0x20416696f957cfbf,\n        0xfdf8f02086af2c4b,\n        0xb427f4b3be74c361,\n        0x6bc6019636c7d0c2,\n    ), // 245\n    (\n        8,\n        0x203b4a8bb8d356e7,\n        0xfe29142e0e01401f,\n        0xba1f9a938041e100,\n        0x601c4205aebd9e47,\n    ), // 246\n    (\n        8,\n        0x2035372541ab0f0d,\n        0xfe59063c8822ce56,\n        0xc0435871d1110f41,\n        0x54ddc59756f05016,\n    ), // 247\n    (\n        8,\n        0x202f2c4e08fd6dcc,\n        0xfe88c6b3626a72aa,\n        0xc694446f01000000,\n        0x4a0648979c838c18,\n    ), // 248\n    (\n        8,\n        0x202929f0d04b99e9,\n        0xfeb855f8ca88fb0d,\n        0xcd137a5b57ac3ec1,\n        0x3f91b6e0bb3a053d,\n    ), // 249\n    (\n        8,\n        0x20232ff8a41b45eb,\n        0xfee7b471b3a9507d,\n        0xd3c21bcecceda100,\n        0x357c299a88ea76a5,\n    ), // 250\n    (\n        8,\n        0x201d3e50daa036db,\n        0xff16e281db76303b,\n        0xdaa150410b788de1,\n        0x2bc1e517aecc56e3,\n    ), // 251\n    (\n        8,\n        0x201754e5126d446d,\n        0xff45e08bcf06554e,\n        0xe1b24521be010000,\n        0x225f56ceb3da9f5d,\n    ), // 252\n    (\n        8,\n        0x201173a1312ca135,\n        0xff74aef0efafadd7,\n        0xe8f62df12777c1a1,\n        0x1951136d53ad63ac,\n    ), // 253\n    (\n        8,\n        0x200b9a71625f3b13,\n        0xffa34e1177c23362,\n        0xf06e445906fc0100,\n        0x1093d504b3cd7d93,\n    ), // 254\n    (\n        8,\n        0x2005c94216230568,\n        0xffd1be4c7f2af942,\n        0xf81bc845c81bf801,\n        0x824794d1ec1814f,\n    ), // 255\n    (8, 0x1fffffffffffffff, 0xffffffffffffffff, 0x8, 0x0),  // 256\n];\n\n// This section is created by factorial_data.rs.\n\n// This is equivalent to `__gmp_oddfac_table` in `mpn/comb_tables.c`, GMP 6.2.1, which is the\n// combination of `ONE_LIMB_ODD_FACTORIAL_TABLE` and `ONE_LIMB_ODD_FACTORIAL_EXTTABLE` in\n// `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_FACTORIAL_TABLE: [Limb; 68] = [\n    0x1,\n    0x1,\n    0x1,\n    0x3,\n    0x3,\n    0xf,\n    0x2d,\n    0x13b,\n    0x13b,\n    0xb13,\n    0x375f,\n    0x26115,\n    0x7233f,\n    0x5cca33,\n    0x2898765,\n    0x260eeeeb,\n    0x260eeeeb,\n    0x286fddd9b,\n    0x16beecca73,\n    0x1b02b930689,\n    0x870d9df20ad,\n    0xb141df4dae31,\n    0x79dd498567c1b,\n    0xaf2e19afc5266d,\n    0x20d8a4d0f4f7347,\n    0x335281867ec241ef,\n    0x9b3093d46fdd5923,\n    0x5e1f9767cc5866b1,\n    0x92dd23d6966aced7,\n    0xa30d0f4f0a196e5b,\n    0x8dc3e5a1977d7755,\n    0x2ab8ce915831734b,\n    0x2ab8ce915831734b,\n    0x81d2a0bc5e5fdcab,\n    0x9efcac82445da75b,\n    0xbc8b95cf58cde171,\n    0xa0e8444a1f3cecf9,\n    0x4191deb683ce3ffd,\n    0xddd3878bc84ebfc7,\n    0xcb39a64b83ff3751,\n    0xf8203f7993fc1495,\n    0xbd2a2a78b35f4bdd,\n    0x84757be6b6d13921,\n    0x3fbbcfc0b524988b,\n    0xbd11ed47c8928df9,\n    0x3c26b59e41c2f4c5,\n    0x677a5137e883fdb3,\n    0xff74e943b03b93dd,\n    0xfe5ebbcb10b2bb97,\n    0xb021f1de3235e7e7,\n    0x33509eb2e743a58f,\n    0x390f9da41279fb7d,\n    0xe5cb0154f031c559,\n    0x93074695ba4ddb6d,\n    0x81c471caa636247f,\n    0xe1347289b5a1d749,\n    0x286f21c3f76ce2ff,\n    0xbe84a2173e8ac7,\n    0x1595065ca215b88b,\n    0xf95877595b018809,\n    0x9c2efe3c5516f887,\n    0x373294604679382b,\n    0xaf1ff7a888adcd35,\n    0x18ddf279a2c5800b,\n    0x18ddf279a2c5800b,\n    0x505a90e2542582cb,\n    0x5bacad2cd8d5dc2b,\n    0xfe3152bcbff89f41,\n];\n// This is equivalent to `ODD_FACTORIAL_TABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_FACTORIAL_TABLE_LIMIT: usize = 25;\n// This is equivalent to `ODD_FACTORIAL_EXTTABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_FACTORIAL_EXTTABLE_LIMIT: usize = 67;\n// This is equivalent to `ODD_FACTORIAL_TABLE_MAX` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_FACTORIAL_TABLE_MAX: Limb = 0x335281867ec241ef;\n\n// This is equivalent to `__gmp_odd2fac_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\n// `ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE: [Limb; 17] = [\n    0x1,\n    0x3,\n    0xf,\n    0x69,\n    0x3b1,\n    0x289b,\n    0x20fdf,\n    0x1eee11,\n    0x20dcf21,\n    0x27065f73,\n    0x33385d46f,\n    0x49a10615f9,\n    0x730b9982551,\n    0xc223930bef8b,\n    0x15fe07a85a22bf,\n    0x2a9c2ed62ea3521,\n    0x57e22099c030d941,\n];\n// This is equivalent to `ODD_DOUBLEFACTORIAL_TABLE_LIMIT` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_DOUBLEFACTORIAL_TABLE_LIMIT: usize = 33;\n// This is equivalent to `ODD_DOUBLEFACTORIAL_TABLE_MAX` in `fac_table.h`, GMP 6.2.1.\npub(crate) const ODD_DOUBLEFACTORIAL_TABLE_MAX: Limb = 0x57e22099c030d941;\n\n// This is equivalent to `__gmp_limbroots_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\n// `NTH_ROOT_NUMB_MASK_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const NTH_ROOT_NUMB_MASK_TABLE: [Limb; 8] =\n    [Limb::MAX, 0xffffffff, 0x285145, 0xffff, 0x1bdb, 0x659, 0x235, 0xff];\n\n// This is equivalent to `ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE: [Limb; 64] = [\n    0x1,\n    0xaaaaaaaaaaaaaaab,\n    0xaaaaaaaaaaaaaaab,\n    0xeeeeeeeeeeeeeeef,\n    0x4fa4fa4fa4fa4fa5,\n    0x2ff2ff2ff2ff2ff3,\n    0x2ff2ff2ff2ff2ff3,\n    0x938cc70553e3771b,\n    0xb71c27cddd93e49f,\n    0xb38e3229fcdee63d,\n    0xe684bb63544a4cbf,\n    0xc2f684917ca340fb,\n    0xf747c9cba417526d,\n    0xbb26eb51d7bd49c3,\n    0xbb26eb51d7bd49c3,\n    0xb0a7efb985294093,\n    0xbe4b8c69f259eabb,\n    0x6854d17ed6dc4fb9,\n    0xe1aa904c915f4325,\n    0x3b8206df131cead1,\n    0x79c6009fea76fe13,\n    0xd8c5d381633cd365,\n    0x4841f12b21144677,\n    0x4a91ff68200b0d0f,\n    0x8f9513a58c4f9e8b,\n    0x2b3e690621a42251,\n    0x4f520f00e03c04e7,\n    0x2edf84ee600211d3,\n    0xadcaa2764aaacdfd,\n    0x161f4f9033f4fe63,\n    0x161f4f9033f4fe63,\n    0xbada2932ea4d3e03,\n    0xcec189f3efaa30d3,\n    0xf7475bb68330bf91,\n    0x37eb7bf7d5b01549,\n    0x46b35660a4e91555,\n    0xa567c12d81f151f7,\n    0x4c724007bb2071b1,\n    0xf4a0cce58a016bd,\n    0xfa21068e66106475,\n    0x244ab72b5a318ae1,\n    0x366ce67e080d0f23,\n    0xd666fdae5dd2a449,\n    0xd740ddd0acc06a0d,\n    0xb050bbbb28e6f97b,\n    0x70b003fe890a5c75,\n    0xd03aabff83037427,\n    0x13ec4ca72c783bd7,\n    0x90282c06afdbd96f,\n    0x4414ddb9db4a95d5,\n    0xa2c68735ae6832e9,\n    0xbf72d71455676665,\n    0xa8469fab6b759b7f,\n    0xc1e55b56e606caf9,\n    0x40455630fc4a1cff,\n    0x120a7b0046d16f7,\n    0xa7c3553b08faef23,\n    0x9f0bfd1b08d48639,\n    0xa433ffce9a304d37,\n    0xa22ad1d53915c683,\n    0xcb6cbc723ba5dd1d,\n    0x547fb1b8ab9d0ba3,\n    0x547fb1b8ab9d0ba3,\n    0x8f15a826498852e3,\n];\n\npub(crate) const ODD_CENTRAL_BINOMIAL_OFFSET: usize = 13;\n\n// This table contains binomial(2k, k) / 2 ^ t.\n//\n// This is equivalent to `bin2kk` in `mpz/bin_uiui.c`, GMP 6.2.1, and\n// `ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE: [Limb; 23] = [\n    0x13d66b,\n    0x4c842f,\n    0x93ee7d,\n    0x11e9e123,\n    0x22c60053,\n    0x873ae4d1,\n    0x10757bd97,\n    0x80612c6cd,\n    0xfaa556bc1,\n    0x3d3cc24821,\n    0x77cfeb6bbb,\n    0x7550ebd97c7,\n    0xe5f08695caf,\n    0x386120ffce11,\n    0x6eabb28dd6df,\n    0x3658e31c82a8f,\n    0x6ad2050312783,\n    0x1a42902a5af0bf,\n    0x33ac44f881661d,\n    0xcb764f927d82123,\n    0x190c23fa46b93983,\n    0x62b7609e25caf1b9,\n    0xc29cb72925ef2cff,\n];\n\npub(crate) const ODD_CENTRAL_BINOMIAL_TABLE_LIMIT: usize = 35;\n\n// This table contains the inverses of elements in the previous table.\n//\n// This is equivalent to `bin2kkinv` in `mpz/bin_uiui.c`, GMP 6.2.1, and\n// `ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE` from `fac_table.h`, GMP 6.2.1.\npub(crate) const ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE: [Limb; 23] = [\n    0x61e5bd199bb12643,\n    0x78321494dc8342cf,\n    0x4fd348704ebf7ad5,\n    0x7e722ba086ab568b,\n    0xa5fcc124265843db,\n    0x89c4a6b18633f431,\n    0x4daa2c15f8ce9227,\n    0x801c618ca9be9605,\n    0x32dc192f948a441,\n    0xd02b90c2bf3be1,\n    0xd897e8c1749aa173,\n    0x54a234fc01fef9f7,\n    0x83ff2ab4d1ff7a4f,\n    0xa427f1c9b304e2f1,\n    0x9c14595d1793651f,\n    0x883a71c607a7b46f,\n    0xd089863c54bc9f2b,\n    0x9022f6bce5d07f3f,\n    0xbec207e218768c35,\n    0x9d70cb4cbb4f168b,\n    0x3c3d3403828a9d2b,\n    0x7672df58c56bc489,\n    0x1e66ca55d727d2ff,\n];\n\n// This table contains the values t in the formula binomial(2k, k) / 2 ^ t.\n//\n// This is equivalent to `fac2bin` in `mpz/bin_uiui.c`, GMP 6.2.1, and `CENTRAL_BINOMIAL_2FAC_TABLE`\n// from `fac_table.h`, GMP 6.2.1.\npub(crate) const CENTRAL_BINOMIAL_2FAC_TABLE: [u64; 23] =\n    [3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3];\n\n// https://oeis.org/A005187, skipping the initial 0\n//\n// This is equivalent to `__gmp_fac2cnt_table` in `mpn/comb_tables.c`, GMP 6.2.1, and\n// `TABLE_2N_MINUS_POPC_2N` from `fac_table.h`, GMP 6.2.1.\npub(crate) const TABLE_2N_MINUS_POPC_2N: [u8; 40] = [\n    1, 3, 4, 7, 8, 10, 11, 15, 16, 18, 19, 22, 23, 25, 26, 31, 32, 34, 35, 38, 39, 41, 42, 46, 47,\n    49, 50, 53, 54, 56, 57, 63, 64, 66, 67, 70, 71, 73, 74, 78,\n];\n\npub(crate) const TABLE_LIMIT_2N_MINUS_POPC_2N: u64 = 81;\n\n// Use these tables to match FLINT for debugging\n// ```\n// pub(crate) const FFT_TAB: [[u8; 2]; 5] = [[3, 3], [3, 2], [2, 1], [2, 1], [0, 0]];\n// pub(crate) const MULMOD_TAB: [u8; 15] = [4, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1];\n// ```\n"
  },
  {
    "path": "malachite-nz/src/test_util/bench/bucketers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::platform::Limb;\nuse crate::test_util::natural::arithmetic::gcd::OwnedHalfGcdMatrix;\nuse malachite_base::max;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::test_util::bench::bucketers::Bucketer;\nuse std::cmp::{max, min};\n\npub fn natural_bucketer(var_name: &str) -> Bucketer<'_, Natural> {\n    Bucketer {\n        bucketing_function: &|x| usize::exact_from(x),\n        bucketing_label: var_name.to_string(),\n    }\n}\n\npub fn natural_bit_bucketer(var_name: &str) -> Bucketer<'_, Natural> {\n    Bucketer {\n        bucketing_function: &|x| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_natural_max_bit_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Natural, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_natural_min_bit_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Natural, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(min(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"min({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_natural_max_bit_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Natural, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_natural_min_bit_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Natural, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(min(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"min({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_natural_bit_u64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Natural, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn pair_natural_bit_i64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Natural, i64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.unsigned_abs()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.unsigned_abs())\"),\n    }\n}\n\npub fn triple_natural_bit_i64_u64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Natural, i64, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn quadruple_1_2_3_natural_bit_i64_u64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Natural, i64, u64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z, _)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn pair_integer_bit_i64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Integer, i64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.unsigned_abs()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.unsigned_abs())\"),\n    }\n}\n\npub fn pair_integer_bit_u64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Integer, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn pair_2_pair_integer_bit_u64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Integer, u64))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn triple_integer_bit_i64_u64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Integer, i64, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn quadruple_1_2_3_integer_bit_i64_u64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Integer, i64, u64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z, _)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn triple_3_pair_natural_max_bit_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, (Natural, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn triple_3_pair_natural_min_bit_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, (Natural, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (x, y))| {\n            usize::exact_from(min(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"min({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_1_natural_bit_bucketer<T>(var_name: &str) -> Bucketer<'_, (Natural, T)> {\n    Bucketer {\n        bucketing_function: &|(x, _)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_2_natural_bit_bucketer<T>(var_name: &str) -> Bucketer<'_, (T, Natural)> {\n    Bucketer {\n        bucketing_function: &|(_, x)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_1_natural_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (Natural, T, U)> {\n    Bucketer {\n        bucketing_function: &|(x, _, _)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_natural_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (T, U, Natural)> {\n    Bucketer {\n        bucketing_function: &|(_, _, x)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_pair_1_natural_bit_bucketer<T, U, V>(\n    var_name: &str,\n) -> Bucketer<'_, (T, U, (Natural, V))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (x, _))| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_2_pair_1_natural_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (T, (Natural, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, _))| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_natural_max_bit_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Natural, Natural, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits())\"\n        ),\n    }\n}\n\npub fn integer_bit_bucketer(var_name: &str) -> Bucketer<'_, Integer> {\n    Bucketer {\n        bucketing_function: &|x| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_1_integer_bit_bucketer<T>(var_name: &str) -> Bucketer<'_, (Integer, T)> {\n    Bucketer {\n        bucketing_function: &|(x, _)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_2_integer_bit_bucketer<T>(var_name: &str) -> Bucketer<'_, (T, Integer)> {\n    Bucketer {\n        bucketing_function: &|(_, x)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_integer_max_bit_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Integer, Integer)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn triple_integer_max_bit_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Integer, Integer, Integer)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits())\"\n        ),\n    }\n}\n\npub fn triple_1_2_natural_max_bit_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Natural, Natural, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_triple_1_2_natural_max_bit_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Natural, Natural, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, _))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn triple_1_2_integer_max_bit_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Integer, Integer, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_triple_1_2_integer_max_bit_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Integer, Integer, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y, _))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_integer_max_bit_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Integer, Integer))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn integer_natural_max_bit_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Integer, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_1_integer_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (T, (Integer, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, _))| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_2_integer_natural_max_bit_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, (Integer, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn triple_1_integer_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (Integer, T, U)> {\n    Bucketer {\n        bucketing_function: &|(x, _, _)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_integer_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (T, U, Integer)> {\n    Bucketer {\n        bucketing_function: &|(_, _, x)| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_pair_1_integer_bit_bucketer<T, U, V>(\n    var_name: &str,\n) -> Bucketer<'_, (T, U, (Integer, V))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (x, _))| usize::exact_from(x.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_pair_integer_max_bit_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, (Integer, Integer))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn natural_bit_ratio_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Natural, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(x.significant_bits() / y.significant_bits())\n        },\n        bucketing_label: format!(\"{x_name}.significant_bits() / {y_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_1_vec_len_times_pair_2_natural_bits_bucketer<'a, T>(\n    xs_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Vec<T>, Natural)> {\n    Bucketer {\n        bucketing_function: &|(xs, y)| {\n            xs.len()\n                .checked_mul(usize::exact_from(y.significant_bits()))\n                .unwrap()\n        },\n        bucketing_label: format!(\"{xs_name}.len() * {y_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_1_vec_len_times_pair_2_bucketer<'a, T, U: Copy>(\n    xs_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Vec<T>, U)>\nwhere\n    usize: ExactFrom<U>,\n{\n    Bucketer {\n        bucketing_function: &|&(ref xs, y)| xs.len().checked_mul(usize::exact_from(y)).unwrap(),\n        bucketing_label: format!(\"{xs_name}.len() * {y_name}\"),\n    }\n}\n\npub fn natural_deserialize_bucketer<'a>() -> Bucketer<'a, (String, String, String)> {\n    Bucketer {\n        bucketing_function: &|(_, _, s)| {\n            let n: Natural = serde_json::from_str(s).unwrap();\n            usize::exact_from(n.significant_bits())\n        },\n        bucketing_label: \"n.significant_bits()\".to_string(),\n    }\n}\n\npub fn integer_deserialize_bucketer<'a>() -> Bucketer<'a, (String, String, String)> {\n    Bucketer {\n        bucketing_function: &|(_, _, s)| {\n            let n: Integer = serde_json::from_str(s).unwrap();\n            usize::exact_from(n.significant_bits())\n        },\n        bucketing_label: \"n.significant_bits()\".to_string(),\n    }\n}\n\npub fn triple_1_3_prod_natural_bits_bucketer<'a, T>(\n    xs_name: &'a str,\n    zs_name: &'a str,\n) -> Bucketer<'a, (Natural, T, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, _, z)| {\n            usize::exact_from(x.significant_bits())\n                .checked_mul(usize::exact_from(z.significant_bits()))\n                .unwrap()\n        },\n        bucketing_label: format!(\"{xs_name}.significant_bits() * {zs_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_triple_1_3_prod_natural_bits_bucketer<'a, T, U, V>(\n    xs_name: &'a str,\n    zs_name: &'a str,\n) -> Bucketer<'a, (T, U, (Natural, V, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (x, _, z))| {\n            usize::exact_from(x.significant_bits())\n                .checked_mul(usize::exact_from(z.significant_bits()))\n                .unwrap()\n        },\n        bucketing_label: format!(\"{xs_name}.significant_bits() * {zs_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_1_half_gcd_matrix_bucketer<T>(m_name: &str) -> Bucketer<'_, (OwnedHalfGcdMatrix, T)> {\n    Bucketer {\n        bucketing_function: &|(m, _)| m.s,\n        bucketing_label: m_name.to_string(),\n    }\n}\n\npub fn triple_1_half_gcd_matrix_bucketer<T, U>(\n    m_name: &str,\n) -> Bucketer<'_, (OwnedHalfGcdMatrix, T, U)> {\n    Bucketer {\n        bucketing_function: &|(m, _, _)| m.s,\n        bucketing_label: m_name.to_string(),\n    }\n}\n\n#[allow(clippy::type_complexity)]\npub fn limbs_matrix_2_2_mul_bucketer<'a>() -> Bucketer<\n    'a,\n    (\n        Vec<Limb>,\n        Vec<Limb>,\n        Vec<Limb>,\n        Vec<Limb>,\n        usize,\n        Vec<Limb>,\n        Vec<Limb>,\n        Vec<Limb>,\n        Vec<Limb>,\n    ),\n> {\n    Bucketer {\n        bucketing_function: &|(_, _, _, _, xs_len, ys00, _, _, _)| max(*xs_len, ys00.len()),\n        bucketing_label: \"max(xs_len, ys_len)\".to_string(),\n    }\n}\n\npub fn triple_3_pair_1_integer_bits_times_pair_2_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, (Integer, u64))> {\n    Bucketer {\n        bucketing_function: &|&(_, _, (ref x, y))| usize::exact_from(x.significant_bits() * y),\n        bucketing_label: format!(\"{x_name}.significant_bits() * {y_name}\"),\n    }\n}\n\npub fn triple_1_2_natural_bit_u64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Natural, u64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn triple_1_2_integer_bit_u64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Integer, u64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn limbs_div_to_out_balancing_bucketer<'a>() -> Bucketer<'a, (Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Bucketer {\n        bucketing_function: &|(_, ns, ds)| max(2, (ds.len() << 1).saturating_sub(ns.len())),\n        bucketing_label: \"max(2, 2 * ds.len() - ns.len())\".to_string(),\n    }\n}\n\n#[allow(clippy::type_complexity)]\npub fn limbs_div_mod_extra_bucketer<'a>()\n-> Bucketer<'a, (Vec<Limb>, usize, Vec<Limb>, Limb, Limb, u64)> {\n    Bucketer {\n        bucketing_function: &|(_, fraction_len, ns, _, _, _)| ns.len() + fraction_len,\n        bucketing_label: \"ns.len() + fraction_len\".to_string(),\n    }\n}\n\n#[allow(clippy::type_complexity)]\npub fn limbs_div_mod_barrett_product_bucketer<'a>()\n-> Bucketer<'a, (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>, usize, usize)> {\n    Bucketer {\n        bucketing_function: &|(_, _, _, _, _, i_len)| i_len << 1,\n        bucketing_label: \"2 * i_len\".to_string(),\n    }\n}\n\n#[allow(clippy::type_complexity)]\npub fn limbs_div_mod_barrett_helper_bucketer<'a>()\n-> Bucketer<'a, (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Bucketer {\n        bucketing_function: &|(_, _, ns, ds)| (ds.len() << 1).saturating_sub(ns.len()),\n        bucketing_label: \"max(0, 2 * ds.len() - ns.len())\".to_string(),\n    }\n}\n\npub fn limb_pair_significant_bits_bucketer(var_name: &str) -> Bucketer<'_, (Limb, Limb)> {\n    Bucketer {\n        bucketing_function: &|&(hi, lo)| usize::exact_from(limbs_significant_bits(&[lo, hi])),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\n#[allow(clippy::type_complexity)]\npub fn limbs_mod_mul_two_limbs_bucketer<'a>()\n-> Bucketer<'a, (Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Bucketer {\n        bucketing_function: &|&(x_1, x_0, y_1, y_0, _, _, _, _, _)| {\n            usize::exact_from(max(\n                limbs_significant_bits(&[x_0, x_1]),\n                limbs_significant_bits(&[y_0, y_1]),\n            ))\n        },\n        bucketing_label: \"m.significant_bits()\".to_string(),\n    }\n}\n\npub fn limbs_mod_limb_small_unnormalized_bucketer<'a>() -> Bucketer<'a, (Vec<Limb>, Limb)> {\n    Bucketer {\n        bucketing_function: &|(ns, d)| {\n            if *ns.last().unwrap() < *d {\n                ns.len() - 1\n            } else {\n                ns.len()\n            }\n        },\n        bucketing_label: \"adjusted ns.len()\".to_string(),\n    }\n}\n\npub fn rational_from_power_of_2_digits_bucketer<'a>()\n-> Bucketer<'a, (u64, Vec<Natural>, RationalSequence<Natural>)> {\n    Bucketer {\n        bucketing_function: &|(log_base, xs, ys)| {\n            usize::exact_from(*log_base) * max(xs.len(), ys.component_len())\n        },\n        bucketing_label: \"log_base * max(before_point.len(), after_point.component_len})\"\n            .to_string(),\n    }\n}\n\npub fn rational_from_digits_bucketer<'a>()\n-> Bucketer<'a, (Natural, Vec<Natural>, RationalSequence<Natural>)> {\n    Bucketer {\n        bucketing_function: &|(base, xs, ys)| {\n            usize::exact_from(base.significant_bits()) * max(xs.len(), ys.component_len())\n        },\n        bucketing_label:\n            \"base.significant_bits() * max(before_point.len(), after_point.component_len})\"\n                .to_string(),\n    }\n}\n\npub fn vec_integer_sum_bits_bucketer<'a>() -> Bucketer<'a, Vec<Integer>> {\n    Bucketer {\n        bucketing_function: &|xs| {\n            usize::exact_from(\n                xs.iter()\n                    .map(SignificantBits::significant_bits)\n                    .sum::<u64>(),\n            )\n        },\n        bucketing_label: \"xs.map(|x| x.significant_bits()).sum()\".to_string(),\n    }\n}\n\npub fn vec_natural_sum_bits_bucketer<'a>() -> Bucketer<'a, Vec<Natural>> {\n    Bucketer {\n        bucketing_function: &|xs| {\n            usize::exact_from(\n                xs.iter()\n                    .map(SignificantBits::significant_bits)\n                    .sum::<u64>(),\n            )\n        },\n        bucketing_label: \"xs.map(|x| x.significant_bits()).sum()\".to_string(),\n    }\n}\n\npub fn pair_1_vec_natural_sum_bits_bucketer<'a, T>() -> Bucketer<'a, (Vec<Natural>, T)> {\n    Bucketer {\n        bucketing_function: &|(xs, _)| {\n            usize::exact_from(\n                xs.iter()\n                    .map(SignificantBits::significant_bits)\n                    .sum::<u64>(),\n            )\n        },\n        bucketing_label: \"xs.map(|x| x.significant_bits()).sum()\".to_string(),\n    }\n}\n\npub fn triple_3_vec_integer_sum_bits_bucketer<'a, T, U>() -> Bucketer<'a, (T, U, Vec<Integer>)> {\n    Bucketer {\n        bucketing_function: &|(_, _, xs)| {\n            usize::exact_from(\n                xs.iter()\n                    .map(SignificantBits::significant_bits)\n                    .sum::<u64>(),\n            )\n        },\n        bucketing_label: \"xs.map(|x| x.significant_bits()).sum()\".to_string(),\n    }\n}\n\npub fn triple_3_vec_natural_sum_bits_bucketer<'a, T, U>() -> Bucketer<'a, (T, U, Vec<Natural>)> {\n    Bucketer {\n        bucketing_function: &|(_, _, xs)| {\n            usize::exact_from(\n                xs.iter()\n                    .map(SignificantBits::significant_bits)\n                    .sum::<u64>(),\n            )\n        },\n        bucketing_label: \"xs.map(|x| x.significant_bits()).sum()\".to_string(),\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod bucketers;\n"
  },
  {
    "path": "malachite-nz/src/test_util/common/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::Sign as SignTrait;\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse malachite_base::num::conversion::traits::VecFromOtherTypeSlice;\nuse num::bigint::Sign;\nuse num::{BigInt, BigUint};\nuse rug::integer::Order;\nuse std::cmp::Ordering::*;\n\n#[cfg(feature = \"32_bit_limbs\")]\nimpl From<&BigUint> for Natural {\n    #[inline]\n    fn from(n: &BigUint) -> Self {\n        Self::from_owned_limbs_asc(n.to_u32_digits())\n    }\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl From<&BigUint> for Natural {\n    #[inline]\n    fn from(n: &BigUint) -> Self {\n        Self::from_owned_limbs_asc(Limb::vec_from_other_type_slice(&n.to_u32_digits()))\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\nimpl From<&Natural> for BigUint {\n    #[inline]\n    fn from(n: &Natural) -> Self {\n        Self::new(n.to_limbs_asc())\n    }\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl From<&Natural> for BigUint {\n    #[inline]\n    fn from(n: &Natural) -> Self {\n        Self::new(u32::vec_from_other_type_slice(n.as_limbs_asc()))\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\nimpl From<&Natural> for BigInt {\n    #[inline]\n    fn from(n: &Natural) -> Self {\n        Self::from_biguint(\n            if *n == 0 { Sign::NoSign } else { Sign::Plus },\n            BigUint::new(n.to_limbs_asc()),\n        )\n    }\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nimpl From<&Natural> for BigInt {\n    #[inline]\n    fn from(n: &Natural) -> Self {\n        Self::from_biguint(\n            if *n == 0 { Sign::NoSign } else { Sign::Plus },\n            BigUint::new(u32::vec_from_other_type_slice(n.as_limbs_asc())),\n        )\n    }\n}\n\nimpl TryFrom<&rug::Integer> for Natural {\n    type Error = ();\n\n    #[inline]\n    fn try_from(n: &rug::Integer) -> Result<Self, ()> {\n        if *n >= 0 {\n            Ok(Self::from_owned_limbs_asc(n.to_digits(Order::Lsf)))\n        } else {\n            Err(())\n        }\n    }\n}\n\nimpl From<&Natural> for rug::Integer {\n    #[inline]\n    fn from(n: &Natural) -> Self {\n        Self::from_digits(n.as_limbs_asc(), Order::Lsf)\n    }\n}\n\nimpl From<&BigInt> for Integer {\n    #[inline]\n    fn from(n: &BigInt) -> Self {\n        Self::from_sign_and_abs(n.sign() != Sign::Minus, Natural::from(n.magnitude()))\n    }\n}\n\nimpl From<&Integer> for BigInt {\n    #[inline]\n    fn from(n: &Integer) -> Self {\n        let sign = match n.sign() {\n            Less => Sign::Minus,\n            Equal => Sign::NoSign,\n            Greater => Sign::Plus,\n        };\n        Self::from_biguint(sign, BigUint::from(n.unsigned_abs_ref()))\n    }\n}\n\nimpl From<&rug::Integer> for Integer {\n    #[inline]\n    fn from(n: &rug::Integer) -> Self {\n        Self::from_sign_and_abs(\n            *n >= 0,\n            Natural::from_owned_limbs_asc(n.to_digits(Order::Lsf)),\n        )\n    }\n}\n\nimpl From<&Integer> for rug::Integer {\n    #[inline]\n    fn from(n: &Integer) -> Self {\n        let out = Self::from(n.unsigned_abs_ref());\n        if *n >= 0 { out } else { -out }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/extra_variadic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse malachite_base::iterators::iterator_cache::IteratorCache;\nuse malachite_base::num::arithmetic::traits::CheckedPow;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::random::Seed;\nuse malachite_base::tuples::random::next_helper;\nuse malachite_base::{\n    custom_tuples, exhaustive_tuples_1_input, random_custom_tuples, random_tuples,\n};\nuse std::cmp::max;\nuse std::marker::PhantomData;\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n    (a.unwrap(), b.unwrap(), c.unwrap())\n}\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_quadruple<X, Y, Z, W>(\n    (a, b, c, d): (Option<X>, Option<Y>, Option<Z>, Option<W>),\n) -> (X, Y, Z, W) {\n    (a.unwrap(), b.unwrap(), c.unwrap(), d.unwrap())\n}\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_quintuple<X, Y, Z, W, V>(\n    (a, b, c, d, e): (Option<X>, Option<Y>, Option<Z>, Option<W>, Option<V>),\n) -> (X, Y, Z, W, V) {\n    (a.unwrap(), b.unwrap(), c.unwrap(), d.unwrap(), e.unwrap())\n}\n\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveTriples1Input,\n    exhaustive_triples_1_input,\n    exhaustive_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveQuadruples1Input,\n    exhaustive_quadruples_1_input,\n    exhaustive_quadruples_from_single,\n    (I::Item, I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w]\n);\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveSextuples1Input,\n    exhaustive_sextuples_1_input,\n    exhaustive_sextuples_from_single,\n    (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z],\n    [3, output_type_w],\n    [4, output_type_v],\n    [5, output_type_u]\n);\n\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveTriplesXXY,\n    (X, X, Y),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xxy,\n    exhaustive_triples_xxy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]]\n);\ncustom_tuples!(\n     (pub(crate)),\n     ExhaustiveTriplesXYX,\n     (X, Y, X),\n     (None, None, None),\n     unwrap_triple,\n     exhaustive_triples_xyx,\n    exhaustive_triples_xyx_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_ys_1]],\n    [Y, J, ys, ys_done, [1, output_type_xs_2]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXXXY,\n    (X, X, X, Y),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xxxy,\n    exhaustive_quadruples_xxxy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1], [2, output_type_xs_2]],\n    [Y, J, ys, ys_done, [3, output_type_ys_3]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXYXZ,\n    (X, Y, X, Z),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xyxz,\n    exhaustive_quadruples_xyxz_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [2, output_type_xs_2]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1]],\n    [Z, K, zs, zs_done, [3, output_type_zs_3]]\n);\ncustom_tuples!(\n     (pub(crate)),\n     ExhaustiveQuadruplesXYYX,\n     (X, Y, Y, X),\n     (None, None, None, None),\n     unwrap_quadruple,\n     exhaustive_quadruples_xyyx,\n     exhaustive_quadruples_xyyx_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [3, output_type_xs_3]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXYYZ,\n    (X, Y, Y, Z),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xyyz,\n    exhaustive_quadruples_xyyz_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2]],\n    [Z, K, zs, zs_done, [3, output_type_zs_3]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuintuplesXYYYZ,\n    (X, Y, Y, Y, Z),\n    (None, None, None, None, None),\n    unwrap_quintuple,\n    exhaustive_quintuples_xyyyz,\n    exhaustive_quintuples_xyyyz_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0]],\n    [Y, J, ys, ys_done, [1, output_type_ys_1], [2, output_type_ys_2], [3, output_type_ys_3]],\n    [Z, K, zs, zs_done, [4, output_type_zs_4]]\n);\n\nrandom_tuples!(\n    (pub(crate)),\n    RandomTriples,\n    RandomTriplesFromSingle,\n    random_triples,\n    random_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen]\n);\nrandom_tuples!(\n    (pub(crate)),\n    RandomQuadruples,\n    RandomQuadruplesFromSingle,\n    random_quadruples,\n    random_quadruples_from_single,\n    (I::Item, I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen],\n    [3, W, L, ws, ws_gen]\n);\nrandom_tuples!(\n    (pub(crate)),\n    RandomSextuples,\n    RandomSextuplesFromSingle,\n    random_sextuples,\n    random_sextuples_from_single,\n    (I::Item, I::Item, I::Item, I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen],\n    [3, W, L, ws, ws_gen],\n    [4, V, M, vs, vs_gen],\n    [5, U, N, us, us_gen]\n);\n\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXXY,\n    (X, X, Y),\n    random_triples_xxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n    [Y, J, ys, ys_gen, [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXYX,\n    (X, Y, X),\n    random_triples_xyx,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n    [Y, J, ys, ys_gen, [y_1, x_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXYY,\n    (X, Y, Y),\n    random_triples_xyy,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXXXY,\n    (X, X, X, Y),\n    random_quadruples_xxxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1], [x_2, x_2]],\n    [Y, J, ys, ys_gen, [y_3, y_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXYXZ,\n    (X, Y, X, Z),\n    random_quadruples_xyxz,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_2, y_1]],\n    [Y, J, ys, ys_gen, [y_1, x_2]],\n    [Z, K, zs, zs_gen, [z_3, z_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXYYX,\n    (X, Y, Y, X),\n    random_quadruples_xyyx,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_3, y_1]],\n    [Y, J, ys, ys_gen, [y_1, y_2], [y_2, x_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXYYZ,\n    (X, Y, Y, Z),\n    random_quadruples_xyyz,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]],\n    [Z, K, zs, zs_gen, [z_3, z_3]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuintuplesXYYYZ,\n    (X, Y, Y, Y, Z),\n    random_quintuples_xyyyz,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2], [y_3, y_3]],\n    [Z, K, zs, zs_gen, [z_4, z_4]]\n);\n"
  },
  {
    "path": "malachite-nz/src/test_util/generators/common.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::test_util::generators::common::It;\nuse num::{BigInt, BigUint};\n\npub fn natural_nrm(xs: It<Natural>) -> It<(BigUint, rug::Integer, Natural)> {\n    Box::new(xs.map(|x| (BigUint::from(&x), rug::Integer::from(&x), x)))\n}\n\npub fn natural_rm(xs: It<Natural>) -> It<(rug::Integer, Natural)> {\n    Box::new(xs.map(|x| (rug::Integer::from(&x), x)))\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_pair_nrm(\n    ps: It<(Natural, Natural)>,\n) -> It<(\n    (BigUint, BigUint),\n    (rug::Integer, rug::Integer),\n    (Natural, Natural),\n)> {\n    Box::new(ps.map(|(x, y)| {\n        (\n            (BigUint::from(&x), BigUint::from(&y)),\n            (rug::Integer::from(&x), rug::Integer::from(&y)),\n            (x, y),\n        )\n    }))\n}\n\npub fn natural_pair_rm(\n    ps: It<(Natural, Natural)>,\n) -> It<((rug::Integer, rug::Integer), (Natural, Natural))> {\n    Box::new(ps.map(|(x, y)| ((rug::Integer::from(&x), rug::Integer::from(&y)), (x, y))))\n}\n\npub fn natural_pair_nm(ps: It<(Natural, Natural)>) -> It<((BigUint, BigUint), (Natural, Natural))> {\n    Box::new(ps.map(|(x, y)| ((BigUint::from(&x), BigUint::from(&y)), (x, y))))\n}\n\npub fn natural_pair_1_rm<T: 'static + Clone>(\n    ps: It<(Natural, T)>,\n) -> It<((rug::Integer, T), (Natural, T))> {\n    Box::new(ps.map(|(x, y)| ((rug::Integer::from(&x), y.clone()), (x, y))))\n}\n\npub fn natural_pair_1_nm<T: 'static + Clone>(\n    ps: It<(Natural, T)>,\n) -> It<((BigUint, T), (Natural, T))> {\n    Box::new(ps.map(|(x, y)| ((BigUint::from(&x), y.clone()), (x, y))))\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_pair_1_nrm<T: 'static + Clone>(\n    ps: It<(Natural, T)>,\n) -> It<((BigUint, T), (rug::Integer, T), (Natural, T))> {\n    Box::new(ps.map(|(x, y)| {\n        (\n            (BigUint::from(&x), y.clone()),\n            (rug::Integer::from(&x), y.clone()),\n            (x, y),\n        )\n    }))\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_triple_nrm(\n    ts: It<(Natural, Natural, Natural)>,\n) -> It<(\n    (BigUint, BigUint, BigUint),\n    (rug::Integer, rug::Integer, rug::Integer),\n    (Natural, Natural, Natural),\n)> {\n    Box::new(ts.map(|(x, y, z)| {\n        (\n            (BigUint::from(&x), BigUint::from(&y), BigUint::from(&z)),\n            (\n                rug::Integer::from(&x),\n                rug::Integer::from(&y),\n                rug::Integer::from(&z),\n            ),\n            (x, y, z),\n        )\n    }))\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_triple_rm(\n    ts: It<(Natural, Natural, Natural)>,\n) -> It<(\n    (rug::Integer, rug::Integer, rug::Integer),\n    (Natural, Natural, Natural),\n)> {\n    Box::new(ts.map(|(x, y, z)| {\n        (\n            (\n                rug::Integer::from(&x),\n                rug::Integer::from(&y),\n                rug::Integer::from(&z),\n            ),\n            (x, y, z),\n        )\n    }))\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_triple_1_rm<T: 'static + Clone, U: 'static + Clone>(\n    ts: It<(Natural, T, U)>,\n) -> It<((rug::Integer, T, U), (Natural, T, U))> {\n    Box::new(ts.map(|(x, y, z)| ((rug::Integer::from(&x), y.clone(), z.clone()), (x, y, z))))\n}\n\npub fn integer_rm(xs: It<Integer>) -> It<(rug::Integer, Integer)> {\n    Box::new(xs.map(|x| (rug::Integer::from(&x), x)))\n}\n\npub fn integer_nrm(xs: It<Integer>) -> It<(BigInt, rug::Integer, Integer)> {\n    Box::new(xs.map(|x| (BigInt::from(&x), rug::Integer::from(&x), x)))\n}\n\npub fn integer_pair_rm(\n    ps: It<(Integer, Integer)>,\n) -> It<((rug::Integer, rug::Integer), (Integer, Integer))> {\n    Box::new(ps.map(|(x, y)| ((rug::Integer::from(&x), rug::Integer::from(&y)), (x, y))))\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_pair_nrm(\n    ps: It<(Integer, Integer)>,\n) -> It<(\n    (BigInt, BigInt),\n    (rug::Integer, rug::Integer),\n    (Integer, Integer),\n)> {\n    Box::new(ps.map(|(x, y)| {\n        (\n            (BigInt::from(&x), BigInt::from(&y)),\n            (rug::Integer::from(&x), rug::Integer::from(&y)),\n            (x, y),\n        )\n    }))\n}\n\npub fn integer_pair_nm(ps: It<(Integer, Integer)>) -> It<((BigInt, BigInt), (Integer, Integer))> {\n    Box::new(ps.map(|(x, y)| ((BigInt::from(&x), BigInt::from(&y)), (x, y))))\n}\n\npub fn integer_pair_1_rm<T: 'static + Clone>(\n    ps: It<(Integer, T)>,\n) -> It<((rug::Integer, T), (Integer, T))> {\n    Box::new(ps.map(|(x, y)| ((rug::Integer::from(&x), y.clone()), (x, y))))\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_pair_1_nrm<T: 'static + Clone>(\n    ps: It<(Integer, T)>,\n) -> It<((BigInt, T), (rug::Integer, T), (Integer, T))> {\n    Box::new(ps.map(|(x, y)| {\n        (\n            (BigInt::from(&x), y.clone()),\n            (rug::Integer::from(&x), y.clone()),\n            (x, y),\n        )\n    }))\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_triple_1_rm<T: 'static + Clone, U: 'static + Clone>(\n    ts: It<(Integer, T, U)>,\n) -> It<((rug::Integer, T, U), (Integer, T, U))> {\n    Box::new(ts.map(|(x, y, z)| ((rug::Integer::from(&x), y.clone(), z.clone()), (x, y, z))))\n}\n\npub fn integer_natural_pair_rm(\n    ps: It<(Integer, Natural)>,\n) -> It<((rug::Integer, rug::Integer), (Integer, Natural))> {\n    Box::new(ps.map(|(x, y)| ((rug::Integer::from(&x), rug::Integer::from(&y)), (x, y))))\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_integer_natural_triple_rm(\n    ts: It<(Integer, Integer, Natural)>,\n) -> It<(\n    (rug::Integer, rug::Integer, rug::Integer),\n    (Integer, Integer, Natural),\n)> {\n    Box::new(ts.map(|(x, y, z)| {\n        (\n            (\n                rug::Integer::from(&x),\n                rug::Integer::from(&y),\n                rug::Integer::from(&z),\n            ),\n            (x, y, z),\n        )\n    }))\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_natural_triple_1_2_rm<T: 'static + Clone>(\n    ts: It<(Natural, Natural, T)>,\n) -> It<((rug::Integer, rug::Integer, T), (Natural, Natural, T))> {\n    Box::new(ts.map(|(x, y, z)| {\n        (\n            (rug::Integer::from(&x), rug::Integer::from(&y), z.clone()),\n            (x, y, z),\n        )\n    }))\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_integer_triple_1_2_rm<T: 'static + Clone>(\n    ts: It<(Integer, Integer, T)>,\n) -> It<((rug::Integer, rug::Integer, T), (Integer, Integer, T))> {\n    Box::new(ts.map(|(x, y, z)| {\n        (\n            (rug::Integer::from(&x), rug::Integer::from(&y), z.clone()),\n            (x, y, z),\n        )\n    }))\n}\n\npub fn integer_vec_nrm(\n    xss: It<Vec<Integer>>,\n) -> It<(Vec<BigInt>, Vec<rug::Integer>, Vec<Integer>)> {\n    Box::new(xss.map(|xs| {\n        (\n            xs.iter().map(BigInt::from).collect(),\n            xs.iter().map(rug::Integer::from).collect(),\n            xs,\n        )\n    }))\n}\n\npub fn natural_vec_nrm(\n    xss: It<Vec<Natural>>,\n) -> It<(Vec<BigUint>, Vec<rug::Integer>, Vec<Natural>)> {\n    Box::new(xss.map(|xs| {\n        (\n            xs.iter().map(BigUint::from).collect(),\n            xs.iter().map(rug::Integer::from).collect(),\n            xs,\n        )\n    }))\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/generators/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::exhaustive::{\n    exhaustive_integers, exhaustive_natural_integers, exhaustive_negative_integers,\n    exhaustive_nonzero_integers,\n};\nuse crate::integer::logic::bit_access::limbs_vec_clear_bit_neg;\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::{limbs_vec_add_in_place_left, limbs_vec_add_limb_in_place};\nuse crate::natural::arithmetic::binomial_coefficient::{\n    BIN_GOETGHELUCK_THRESHOLD, BIN_UIUI_RECURSIVE_SMALLDC,\n};\nuse crate::natural::arithmetic::div_exact::{\n    limbs_modular_invert_limb, limbs_modular_invert_scratch_len,\n};\nuse crate::natural::arithmetic::div_mod::{\n    limbs_div_mod_barrett_is_len, limbs_div_mod_barrett_scratch_len, limbs_invert_limb,\n    limbs_two_limb_inverse_helper,\n};\nuse crate::natural::arithmetic::eq_mod::{\n    limbs_eq_limb_mod_limb, limbs_eq_limb_mod_ref_ref, limbs_eq_mod_limb_ref_ref,\n    limbs_eq_mod_ref_ref_ref,\n};\nuse crate::natural::arithmetic::gcd::half_gcd::HalfGcdMatrix1;\nuse crate::natural::arithmetic::mod_mul::limbs_precompute_mod_mul_two_limbs;\nuse crate::natural::arithmetic::mod_power_of_2::limbs_slice_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::mod_power_of_2_square::SQRLO_DC_THRESHOLD_LIMIT;\nuse crate::natural::arithmetic::mul::limb::{\n    limbs_slice_mul_limb_in_place, limbs_vec_mul_limb_in_place,\n};\nuse crate::natural::arithmetic::mul::limbs_mul;\nuse crate::natural::arithmetic::mul::mul_mod::limbs_mul_mod_base_pow_n_minus_1_next_size;\nuse crate::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_22_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_32_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_42_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_43_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_44_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_52_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_53_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_54_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_62_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_63_input_sizes_valid,\n};\nuse crate::natural::arithmetic::square::{\n    limbs_square_to_out_toom_3_input_size_valid, limbs_square_to_out_toom_4_input_size_valid,\n    limbs_square_to_out_toom_6_input_size_valid, limbs_square_to_out_toom_8_input_size_valid,\n};\nuse crate::natural::arithmetic::sub::{limbs_sub_greater_in_place_left, limbs_sub_limb_in_place};\nuse crate::natural::comparison::cmp::limbs_cmp;\nuse crate::natural::conversion::digits::general_digits::{\n    GET_STR_PRECOMPUTE_THRESHOLD, limbs_digit_count, limbs_per_digit_in_base,\n};\nuse crate::natural::exhaustive::{\n    ExhaustiveNaturalRange, exhaustive_natural_range, exhaustive_natural_range_to_infinity,\n    exhaustive_naturals, exhaustive_positive_naturals,\n};\nuse crate::natural::logic::significant_bits::limbs_significant_bits;\nuse crate::platform::{\n    DoubleLimb, Limb, ODD_CENTRAL_BINOMIAL_OFFSET, ODD_CENTRAL_BINOMIAL_TABLE_LIMIT,\n    ODD_FACTORIAL_EXTTABLE_LIMIT, ODD_FACTORIAL_TABLE_LIMIT, SQR_TOOM2_THRESHOLD,\n};\nuse crate::test_util::extra_variadic::{\n    exhaustive_quadruples_from_single, exhaustive_quadruples_xxxy,\n    exhaustive_quadruples_xxxy_custom_output, exhaustive_quadruples_xyxz,\n    exhaustive_quadruples_xyyx, exhaustive_quadruples_xyyz, exhaustive_quintuples_xyyyz,\n    exhaustive_sextuples_from_single, exhaustive_triples_from_single, exhaustive_triples_xxy,\n    exhaustive_triples_xxy_custom_output, exhaustive_triples_xyx,\n};\nuse crate::test_util::generators::{factors_of_limb_max, limbs_odd_factorial_valid};\nuse crate::test_util::natural::arithmetic::gcd::{OwnedHalfGcdMatrix, half_gcd_matrix_create};\nuse itertools::Itertools;\nuse malachite_base::bools::exhaustive::{ExhaustiveBools, exhaustive_bools};\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\nuse malachite_base::iterators::iter_windows;\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, CoprimeWith, DivRound, DivisibleBy, DivisibleByPowerOf2, EqMod,\n    EqModPowerOf2, Parity, PowerOf2,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::string::options::exhaustive::exhaustive_to_sci_options;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, SaturatingFrom, ToSci, WrappingFrom,\n};\nuse malachite_base::num::exhaustive::{\n    PrimitiveIntIncreasingRange, exhaustive_natural_signeds, exhaustive_positive_primitive_ints,\n    exhaustive_primitive_floats, exhaustive_signeds, exhaustive_unsigneds,\n    primitive_int_increasing_inclusive_range, primitive_int_increasing_range,\n};\nuse malachite_base::num::factorization::prime_sieve::n_to_bit;\nuse malachite_base::num::iterators::{bit_distributor_sequence, ruler_sequence};\nuse malachite_base::num::logic::traits::{\n    BitAccess, BitConvertible, LeadingZeros, SignificantBits,\n};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::rational_sequences::exhaustive::exhaustive_rational_sequences;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::slices::slice_trailing_zeros;\nuse malachite_base::test_util::generators::common::{\n    It, permute_1_3_2, permute_2_1, reshape_1_2_to_3, reshape_1_3_to_4, reshape_2_1_to_3,\n    reshape_2_2_to_4,\n};\nuse malachite_base::test_util::generators::exhaustive::{\n    UnsignedVecPairLenGenerator1, UnsignedVecPairLenGenerator2, UnsignedVecQuadrupleLenGenerator1,\n    UnsignedVecTripleLenGenerator1, UnsignedVecTripleXYYLenGenerator,\n    exhaustive_unsigned_pair_gen_var_20, exhaustive_unsigned_pair_gen_var_24,\n    exhaustive_unsigned_vec_unsigned_pair_gen_var_17,\n};\nuse malachite_base::test_util::generators::{\n    exhaustive_pairs_big_small, exhaustive_pairs_big_tiny,\n};\nuse malachite_base::tuples::exhaustive::{\n    ExhaustiveDependentPairsYsGenerator, exhaustive_dependent_pairs,\n    exhaustive_ordered_unique_pairs, exhaustive_pairs, exhaustive_pairs_from_single,\n    exhaustive_triples, exhaustive_triples_custom_output, exhaustive_triples_xyy,\n    exhaustive_triples_xyy_custom_output, lex_pairs,\n};\nuse malachite_base::vecs::exhaustive::{\n    ExhaustiveVecs, LexFixedLengthVecsFromSingle, exhaustive_vecs,\n    exhaustive_vecs_fixed_length_from_single, exhaustive_vecs_length_range,\n    exhaustive_vecs_min_length, lex_vecs_fixed_length_from_single,\n};\nuse num::{BigInt, BigUint};\nuse std::cmp::{Ordering::*, max};\nuse std::iter::once;\nuse std::marker::PhantomData;\nuse std::ops::{Shl, Shr};\n\n// -- Integer --\n\npub fn exhaustive_integer_gen() -> It<Integer> {\n    Box::new(exhaustive_integers())\n}\n\npub fn exhaustive_integer_gen_var_1<T: PrimitiveFloat>() -> It<Integer>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Box::new(\n        once(Integer::ZERO).chain(\n            lex_pairs(\n                exhaustive_positive_float_naturals::<T>(0),\n                exhaustive_bools(),\n            )\n            .map(|(n, b)| Integer::from_sign_and_abs(b, n)),\n        ),\n    )\n}\n\npub fn exhaustive_integer_gen_var_2<T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat>()\n-> It<Integer> {\n    Box::new(\n        lex_pairs(exhaustive_natural_gen_var_4::<T>(), exhaustive_bools())\n            .map(|(n, b)| Integer::from_sign_and_abs(b, n)),\n    )\n}\n\npub fn exhaustive_integer_gen_var_3<T: PrimitiveFloat>() -> It<Integer>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Box::new(\n        lex_pairs(exhaustive_natural_gen_var_5::<T>(), exhaustive_bools())\n            .map(|(n, b)| Integer::from_sign_and_abs(b, n)),\n    )\n}\n\npub fn exhaustive_integer_gen_var_4() -> It<Integer> {\n    Box::new(exhaustive_natural_integers())\n}\n\npub fn exhaustive_integer_gen_var_5<T: PrimitiveUnsigned>() -> It<Integer>\nwhere\n    Integer: From<T>,\n{\n    Box::new(exhaustive_unsigneds::<T>().map(Integer::from))\n}\n\npub fn exhaustive_integer_gen_var_6<T: PrimitiveSigned>() -> It<Integer>\nwhere\n    Integer: From<T>,\n{\n    Box::new(exhaustive_natural_signeds::<T>().map(Integer::from))\n}\n\npub fn exhaustive_integer_gen_var_7() -> It<Integer> {\n    Box::new(exhaustive_negative_integers())\n}\n\npub fn exhaustive_integer_gen_var_8() -> It<Integer> {\n    Box::new(exhaustive_nonzero_integers())\n}\n\npub fn exhaustive_integer_gen_var_9() -> It<Integer> {\n    Box::new(exhaustive_natural_integers().map(|n| (n << 1u32) | Integer::ONE))\n}\n\n// -- (Integer, Integer) --\n\npub fn exhaustive_integer_pair_gen() -> It<(Integer, Integer)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_integers()))\n}\n\npub fn exhaustive_integer_pair_gen_var_1() -> It<(Integer, Integer)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_integers(),\n        exhaustive_nonzero_integers(),\n    ))\n}\n\npub fn exhaustive_integer_pair_gen_var_2() -> It<(Integer, Integer)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_integers(), exhaustive_nonzero_integers())\n            .map(|(x, y)| (x * &y, y)),\n    )\n}\n\npub fn exhaustive_integer_pair_gen_var_3() -> It<(Integer, Integer)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_integers(), exhaustive_nonzero_integers())\n            .filter(|(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn exhaustive_integer_pair_gen_var_4() -> It<(Integer, Integer)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_integers(), exhaustive_natural_integers())\n            .map(|(a, n)| (a, (n << 1u32) | Integer::ONE)),\n    )\n}\n\npub fn exhaustive_integer_pair_gen_var_5() -> It<(Integer, Integer)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_integers())\n            .filter(|(x, y)| x.unsigned_abs_ref().coprime_with(y.unsigned_abs_ref())),\n    )\n}\n\npub fn exhaustive_integer_pair_gen_var_6() -> It<(Integer, Integer)> {\n    Box::new(\n        exhaustive_pairs_from_single(\n            exhaustive_natural_integers().map(|n| (n << 1u32) | Integer::ONE),\n        )\n        .filter(|(x, y)| x.unsigned_abs_ref().coprime_with(y.unsigned_abs_ref())),\n    )\n}\n\npub fn exhaustive_integer_pair_gen_var_7() -> It<(Integer, Integer)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_integers(),\n        exhaustive_unsigneds::<Limb>().map(Integer::from),\n    ))\n}\n\n// -- (Integer, Integer, Integer) --\n\npub fn exhaustive_integer_triple_gen() -> It<(Integer, Integer, Integer)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_integers()))\n}\n\npub fn exhaustive_integer_triple_gen_var_1() -> It<(Integer, Integer, Integer)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_natural_integers()))\n}\n\npub fn exhaustive_integer_triple_gen_var_2() -> It<(Integer, Integer, Integer)> {\n    Box::new(\n        exhaustive_triples_xxy(exhaustive_integers(), exhaustive_natural_integers())\n            .map(|(a, b, n)| (a, b, (n << 1u32) | Integer::ONE)),\n    )\n}\n\npub fn exhaustive_integer_triple_gen_var_3() -> It<(Integer, Integer, Integer)> {\n    Box::new(\n        exhaustive_triples_xyy(exhaustive_integers(), exhaustive_natural_integers())\n            .map(|(a, m, n)| (a, (m << 1u32) | Integer::ONE, (n << 1u32) | Integer::ONE)),\n    )\n}\n\n// -- (Integer, Integer, Integer, PrimitiveUnsigned) --\n\npub fn exhaustive_integer_integer_integer_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Integer, Integer, Integer, T)> {\n    Box::new(exhaustive_quadruples_xxxy_custom_output(\n        exhaustive_integers(),\n        exhaustive_unsigneds::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Integer, Integer, Natural) --\n\npub fn exhaustive_integer_integer_natural_triple_gen() -> It<(Integer, Integer, Natural)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_integers(),\n        exhaustive_naturals(),\n    ))\n}\n\npub fn exhaustive_integer_integer_natural_triple_gen_var_1() -> It<(Integer, Integer, Natural)> {\n    Box::new(\n        exhaustive_triples_xxy(exhaustive_integers(), exhaustive_naturals())\n            .map(|(x, y, m)| (x * Integer::from(&m) + &y, y, m)),\n    )\n}\n\npub fn exhaustive_integer_integer_natural_triple_gen_var_2() -> It<(Integer, Integer, Natural)> {\n    Box::new(\n        exhaustive_triples_xxy(exhaustive_integers(), exhaustive_naturals())\n            .filter(|(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\n// -- (Integer, Integer, PrimitiveFloat) --\n\npub fn exhaustive_integer_integer_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Integer, Integer, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_integers(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Integer, Integer, PrimitiveSigned) --\n\npub fn exhaustive_integer_integer_signed_triple_gen<T: PrimitiveSigned>()\n-> It<(Integer, Integer, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_integers(),\n        exhaustive_signeds::<T>(),\n    ))\n}\n\n// -- (Integer, Integer, PrimitiveUnsigned) --\n\npub fn exhaustive_integer_integer_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> It<(Integer, Integer, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_integers(),\n        exhaustive_unsigneds::<T>(),\n    ))\n}\n\npub fn exhaustive_integer_integer_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Integer, Integer, T)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_integers(),\n        exhaustive_unsigneds::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_integer_integer_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Integer, Integer, T)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_integers(),\n            exhaustive_unsigneds::<T>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(x, y, pow)| ((x << pow) + &y, y, pow)),\n    )\n}\n\npub fn exhaustive_integer_integer_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> It<(Integer, Integer, T)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_integers(),\n            exhaustive_unsigneds::<T>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter(|&(ref x, ref y, pow)| !x.eq_mod_power_of_2(y, pow.exact_into())),\n    )\n}\n\n// -- (Integer, Integer, RoundingMode) --\n\npub fn exhaustive_integer_integer_rounding_mode_triple_gen_var_1()\n-> It<(Integer, Integer, RoundingMode)> {\n    Box::new(\n        exhaustive_triples(\n            exhaustive_integers(),\n            exhaustive_nonzero_integers(),\n            exhaustive_rounding_modes(),\n        )\n        .map(|(x, y, rm)| {\n            if rm == Exact {\n                (x * &y, y, rm)\n            } else {\n                (x, y, rm)\n            }\n        }),\n    )\n}\n\npub(crate) fn round_to_multiple_integer_filter_map(\n    x: Integer,\n    y: Integer,\n    rm: RoundingMode,\n) -> Option<(Integer, Integer, RoundingMode)> {\n    if x == y {\n        Some((x, y, rm))\n    } else if y == 0 {\n        if rm == Down || rm == if x >= 0 { Floor } else { Ceiling } || rm == Nearest {\n            Some((x, y, rm))\n        } else {\n            None\n        }\n    } else if rm == Exact {\n        Some((x * &y, y, rm))\n    } else {\n        Some((x, y, rm))\n    }\n}\n\npub fn exhaustive_integer_integer_rounding_mode_triple_gen_var_2()\n-> It<(Integer, Integer, RoundingMode)> {\n    Box::new(\n        exhaustive_triples(\n            exhaustive_integers(),\n            exhaustive_nonzero_integers(),\n            exhaustive_rounding_modes(),\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_integer_filter_map(x, y, rm)),\n    )\n}\n\n// -- (Integer, Natural) --\n\npub fn exhaustive_integer_natural_pair_gen() -> It<(Integer, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_integers(),\n        exhaustive_naturals(),\n    ))\n}\n\n// -- (Integer, Natural, Natural) --\n\npub fn exhaustive_integer_natural_natural_triple_gen() -> It<(Integer, Natural, Natural)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_integers(),\n        exhaustive_naturals(),\n    ))\n}\n\n// -- (Integer, PrimitiveFloat) --\n\npub fn exhaustive_integer_primitive_float_pair_gen<T: PrimitiveFloat>() -> It<(Integer, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_integers(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Integer, PrimitiveFloat, PrimitiveFloat) --\n\npub fn exhaustive_integer_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Integer, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_integers(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Integer, PrimitiveSigned) --\n\npub fn exhaustive_integer_signed_pair_gen<T: PrimitiveSigned>() -> It<(Integer, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_integers(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_integer_signed_pair_gen_var_1<T: PrimitiveSigned>() -> It<(Integer, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_integers(),\n        exhaustive_signeds(),\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, PrimitiveSigned) --\n\npub fn exhaustive_integer_signed_signed_triple_gen<T: PrimitiveSigned>() -> It<(Integer, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_integers(),\n        exhaustive_signeds::<T>(),\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn exhaustive_integer_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Integer, T, U)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_integers(),\n        exhaustive_signeds::<T>(),\n        exhaustive_positive_primitive_ints::<U>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, RoundingMode) --\n\npub fn exhaustive_integer_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shr<T, Output = Integer>,\n{\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_integers(), exhaustive_signeds::<T>()),\n            exhaustive_rounding_modes(),\n        )\n        .map(|((n, i), rm)| {\n            (\n                if i < T::ZERO && rm == Exact {\n                    n >> i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\npub fn exhaustive_integer_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>()\n-> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_integers(), exhaustive_signeds::<T>()),\n            exhaustive_rounding_modes(),\n        )\n        .map(|((n, i), rm)| {\n            (\n                if i > T::ZERO && rm == Exact {\n                    n << i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned) --\n\npub fn exhaustive_integer_unsigned_pair_gen<T: PrimitiveUnsigned>() -> It<(Integer, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_integers(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_integer_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> It<(Integer, T)> {\n    Box::new(lex_pairs(\n        exhaustive_integers(),\n        primitive_int_increasing_inclusive_range(T::TWO, T::from(36u8)),\n    ))\n}\n\npub fn exhaustive_integer_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> It<(Integer, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_integers(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_integer_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> It<(Integer, T)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_natural_integers(),\n            exhaustive_positive_primitive_ints(),\n        )\n        .interleave(exhaustive_pairs_big_tiny(\n            exhaustive_negative_integers(),\n            exhaustive_unsigneds::<T>()\n                .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE)),\n        )),\n    )\n}\n\nstruct IntegerDivisibleByP2PairsGenerator;\n\nimpl ExhaustiveDependentPairsYsGenerator<u64, Integer, It<Integer>>\n    for IntegerDivisibleByP2PairsGenerator\n{\n    #[inline]\n    fn get_ys(&self, pow: &u64) -> It<Integer> {\n        let pow = *pow;\n        if pow == 0 {\n            Box::new(exhaustive_integers())\n        } else {\n            Box::new(exhaustive_integers().map(move |k| k << pow))\n        }\n    }\n}\n\npub fn exhaustive_integer_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>() -> It<(Integer, T)> {\n    permute_2_1(Box::new(\n        exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_unsigneds(),\n            IntegerDivisibleByP2PairsGenerator,\n        )\n        .map(|(x, y)| (T::exact_from(x), y)),\n    ))\n}\n\npub fn exhaustive_integer_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>() -> It<(Integer, T)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_integers(), exhaustive_unsigneds::<T>())\n            .filter(|(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn exhaustive_integer_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> It<(Integer, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_integers(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, bool) --\n\npub fn exhaustive_integer_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Integer, T, bool)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_integers(),\n        exhaustive_unsigneds(),\n        exhaustive_bools(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, Natural) --\n\npub fn exhaustive_integer_unsigned_natural_triple_gen<T: PrimitiveUnsigned>()\n-> It<(Integer, T, Natural)> {\n    Box::new(exhaustive_triples(\n        exhaustive_integers(),\n        exhaustive_unsigneds(),\n        exhaustive_naturals(),\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned) --\n\ntype T1<T> = It<(Integer, T, T)>;\npub fn exhaustive_integer_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> T1<T> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_integers(),\n        exhaustive_unsigneds::<T>(),\n    ))\n}\n\npub fn exhaustive_integer_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Integer, T, U)> {\n    permute_1_3_2(reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_integers(), exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(T::TWO, T::from(36u8)),\n    ))))\n}\n\npub fn exhaustive_integer_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Integer, T, T)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_integers(),\n            exhaustive_unsigneds::<T>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter_map(|(x, y, z)| y.checked_add(z).map(|new_z| (x, y, new_z))),\n    )\n}\n\npub fn exhaustive_integer_unsigned_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> It<(Integer, T, T)> {\n    Box::new(exhaustive_triples_xyy_custom_output(\n        exhaustive_integers(),\n        exhaustive_unsigneds::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\npub fn exhaustive_integer_unsigned_unsigned_natural_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Integer, T, T, Natural)> {\n    Box::new(\n        exhaustive_quadruples_xyyz(\n            exhaustive_integers(),\n            exhaustive_unsigneds::<T>(),\n            exhaustive_naturals(),\n        )\n        .filter(|(_, y, z, _)| y < z),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_integer_unsigned_rounding_mode_triple_gen_var_1()\n-> It<(Integer, u64, RoundingMode)> {\n    Box::new(\n        exhaustive_triples_custom_output(\n            exhaustive_integers(),\n            exhaustive_unsigneds::<u64>(),\n            exhaustive_rounding_modes(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(n, u, rm)| {\n            if rm == Exact {\n                (n << u, u, rm)\n            } else {\n                (n, u, rm)\n            }\n        }),\n    )\n}\n\npub fn exhaustive_integer_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_integers(), exhaustive_unsigneds::<T>()),\n            exhaustive_rounding_modes(),\n        )\n        .map(|((n, u), rm)| (if rm == Exact { n << u } else { n }, u, rm)),\n    )\n}\n\n// vars 3 and 4 are in malachite-float.\n\npub fn exhaustive_integer_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> It<(Integer, T, RoundingMode)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_integers(),\n        exhaustive_unsigneds::<T>(),\n        exhaustive_rounding_modes(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Integer, RoundingMode) --\n\npub fn exhaustive_integer_rounding_mode_pair_gen() -> It<(Integer, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_integers(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_integer_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat,\n>() -> It<(Integer, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_integers(), exhaustive_rounding_modes())\n            .filter(|&(ref n, rm)| rm != Exact || T::convertible_from(n)),\n    )\n}\n\npub fn exhaustive_integer_rounding_mode_pair_gen_var_2() -> It<(Integer, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_nonzero_integers(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\n// -- (Integer, ToSciOptions) --\n\npub fn exhaustive_integer_to_sci_options_pair_gen() -> It<(Integer, ToSciOptions)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_integers(),\n        exhaustive_to_sci_options(),\n    ))\n}\n\npub fn exhaustive_integer_to_sci_options_pair_gen_var_1() -> It<(Integer, ToSciOptions)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_integers(), exhaustive_to_sci_options())\n            .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- (Integer, Vec<bool>) --\n\nstruct IntegerBoolVecPairGenerator1;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Integer,\n        Vec<bool>,\n        LexFixedLengthVecsFromSingle<ExhaustiveBools>,\n    > for IntegerBoolVecPairGenerator1\n{\n    #[inline]\n    fn get_ys(&self, x: &Integer) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(\n            u64::exact_from(x.to_twos_complement_limbs_asc().len()),\n            exhaustive_bools(),\n        )\n    }\n}\n\npub fn exhaustive_integer_bool_vec_pair_gen_var_1() -> It<(Integer, Vec<bool>)> {\n    Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_integers(),\n        IntegerBoolVecPairGenerator1,\n    ))\n}\n\nstruct IntegerBoolVecPairGenerator2;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Integer,\n        Vec<bool>,\n        LexFixedLengthVecsFromSingle<ExhaustiveBools>,\n    > for IntegerBoolVecPairGenerator2\n{\n    #[inline]\n    fn get_ys(&self, x: &Integer) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(\n            u64::exact_from(x.to_bits_asc().len()),\n            exhaustive_bools(),\n        )\n    }\n}\n\npub fn exhaustive_integer_bool_vec_pair_gen_var_2() -> It<(Integer, Vec<bool>)> {\n    Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_integers(),\n        IntegerBoolVecPairGenerator2,\n    ))\n}\n\n// -- Natural --\n\npub fn exhaustive_natural_gen() -> It<Natural> {\n    Box::new(exhaustive_naturals())\n}\n\npub fn exhaustive_natural_gen_var_1() -> It<Natural> {\n    Box::new(exhaustive_natural_range_to_infinity(Natural::TWO))\n}\n\npub fn exhaustive_natural_gen_var_2() -> It<Natural> {\n    Box::new(exhaustive_positive_naturals())\n}\n\nstruct ExhaustivePositiveFloatNaturals<T: PrimitiveFloat> {\n    phantom: PhantomData<*const T>,\n    done: bool,\n    exponent: i64,\n    limit: u64,\n    mantissa: u64,\n    max_finite: Natural,\n}\n\nimpl<T: PrimitiveFloat> Iterator for ExhaustivePositiveFloatNaturals<T>\nwhere\n    Natural: TryFrom<T>,\n{\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.done {\n            None\n        } else {\n            let n: Natural = ExactFrom::exact_from(self.mantissa);\n            let n = n << self.exponent;\n            if n == self.max_finite {\n                self.done = true;\n            } else {\n                self.mantissa += 1;\n                if self.mantissa == self.limit {\n                    self.mantissa >>= 1;\n                    self.exponent += 1;\n                    self.limit = u64::power_of_2(T::MANTISSA_WIDTH + 1);\n                }\n            }\n            Some(n)\n        }\n    }\n}\n\nfn exhaustive_positive_float_naturals<T: PrimitiveFloat>(\n    start_exponent: i64,\n) -> ExhaustivePositiveFloatNaturals<T>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    ExhaustivePositiveFloatNaturals {\n        phantom: PhantomData,\n        done: false,\n        exponent: start_exponent,\n        limit: u64::power_of_2(T::MANTISSA_WIDTH + 1),\n        mantissa: if start_exponent == 0 {\n            1\n        } else {\n            u64::power_of_2(T::MANTISSA_WIDTH)\n        },\n        max_finite: Natural::exact_from(T::MAX_FINITE),\n    }\n}\n\npub fn exhaustive_natural_gen_var_3<T: PrimitiveFloat>() -> It<Natural>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Box::new(once(Natural::ZERO).chain(exhaustive_positive_float_naturals::<T>(0)))\n}\n\npub fn exhaustive_natural_gen_var_4<T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat>()\n-> It<Natural> {\n    Box::new(\n        exhaustive_natural_range_to_infinity(\n            Natural::power_of_2(T::MANTISSA_WIDTH + 1) | Natural::ONE,\n        )\n        .filter(|n| !T::convertible_from(n)),\n    )\n}\n\npub fn exhaustive_natural_gen_var_5<T: PrimitiveFloat>() -> It<Natural>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Box::new(\n        iter_windows(2, exhaustive_positive_float_naturals::<T>(1)).filter_map(|xs| {\n            let mut xs = xs.into_iter();\n            let a = xs.next().unwrap();\n            let diff = xs.next().unwrap() - &a;\n            if diff.even() {\n                // This happens almost always\n                Some(a + (diff >> 1))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn exhaustive_natural_gen_var_6<T: PrimitiveUnsigned>() -> It<Natural>\nwhere\n    Natural: From<T>,\n{\n    Box::new(exhaustive_unsigneds::<T>().map(Natural::from))\n}\n\npub fn exhaustive_natural_gen_var_7<T: PrimitiveSigned>() -> It<Natural>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Box::new(exhaustive_natural_signeds::<T>().map(Natural::exact_from))\n}\n\npub fn exhaustive_natural_gen_var_8() -> It<Natural> {\n    Box::new(exhaustive_naturals().map(|n| (n << 1u32) | Natural::ONE))\n}\n\n// -- (Natural, bool) --\n\npub fn exhaustive_natural_bool_pair_gen() -> It<(Natural, bool)> {\n    Box::new(lex_pairs(exhaustive_naturals(), exhaustive_bools()))\n}\n\n// -- (Natural, Integer, Natural) --\n\npub fn exhaustive_natural_integer_natural_triple_gen() -> It<(Natural, Integer, Natural)> {\n    Box::new(exhaustive_triples_xyx(\n        exhaustive_naturals(),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Natural, Natural) --\n\npub fn exhaustive_natural_pair_gen() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_naturals()))\n}\n\npub fn exhaustive_natural_pair_gen_var_1() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_natural_range_to_infinity(Natural::power_of_2(Limb::WIDTH)),\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n    ))\n}\n\npub fn exhaustive_natural_pair_gen_var_2() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_naturals(),\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n    ))\n}\n\npub fn exhaustive_natural_pair_gen_var_3() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_positive_naturals(),\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n    ))\n}\n\npub fn exhaustive_natural_pair_gen_var_4() -> It<(Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals())\n            .map(|(x, y, z)| (x * &y, y * z))\n            .unique(),\n    )\n}\n\npub fn exhaustive_natural_pair_gen_var_5() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_naturals(),\n        exhaustive_positive_naturals(),\n    ))\n}\n\npub fn exhaustive_natural_pair_gen_var_6() -> It<(Natural, Natural)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_naturals(), exhaustive_positive_naturals())\n            .map(|(x, y)| (x * &y, y)),\n    )\n}\n\npub fn exhaustive_natural_pair_gen_var_7() -> It<(Natural, Natural)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_naturals(), exhaustive_positive_naturals())\n            .filter(|(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn exhaustive_natural_pair_gen_var_8() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_ordered_unique_pairs(exhaustive_naturals()))\n}\n\npub fn exhaustive_natural_pair_gen_var_9() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_positive_naturals()))\n}\n\npub fn exhaustive_natural_pair_gen_var_10() -> It<(Natural, Natural)> {\n    // TODO\n    Box::new(exhaustive_pairs_from_single(exhaustive_naturals()).filter(|(x, y)| x >= y))\n}\n\npub fn exhaustive_natural_pair_gen_var_11() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_ordered_unique_pairs(\n        exhaustive_positive_naturals(),\n    ))\n}\n\npub fn exhaustive_natural_pair_gen_var_12() -> It<(Natural, Natural)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_naturals())\n            .map(|(a, n)| (a, (n << 1u32) | Natural::ONE)),\n    )\n}\n\npub fn exhaustive_natural_pair_gen_var_13() -> It<(Natural, Natural)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_naturals().map(|n| (n << 1u32) | Natural::ONE))\n            .filter(|(x, y)| x.coprime_with(y)),\n    )\n}\n\npub fn exhaustive_natural_pair_gen_var_14() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_naturals()).filter(|(x, y)| x.coprime_with(y)))\n}\n\npub fn exhaustive_natural_pair_gen_var_15() -> It<(Natural, Natural)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_naturals(),\n        exhaustive_unsigneds::<Limb>().map(Natural::from),\n    ))\n}\n\n// -- (Natural, Natural, bool) --\n\npub fn exhaustive_natural_natural_bool_triple_gen_var_1() -> It<(Natural, Natural, bool)> {\n    reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs(exhaustive_naturals(), exhaustive_positive_naturals()),\n        exhaustive_bools(),\n    )))\n}\n\n// -- (Natural, Natural, Natural) --\n\npub fn exhaustive_natural_triple_gen() -> It<(Natural, Natural, Natural)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_naturals()))\n}\n\npub fn exhaustive_natural_triple_gen_var_1() -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals()).map(|(x, y, m)| (x * &m + &y, y, m)),\n    )\n}\n\npub fn exhaustive_natural_triple_gen_var_2() -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals()).filter(|(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\npub fn exhaustive_natural_triple_gen_var_3() -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals()).map(|(x, y, z)| {\n            let z = max(&x, &y) + z + Natural::ONE;\n            (x, y, z)\n        }),\n    )\n}\n\npub fn exhaustive_natural_triple_gen_var_4() -> It<(Natural, Natural, Natural)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_naturals(),\n        exhaustive_positive_naturals(),\n    ))\n}\n\npub fn exhaustive_natural_triple_gen_var_5() -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals()).map(|(x, y, mut z)| {\n            z += &x;\n            z += Natural::ONE;\n            (x, y, z)\n        }),\n    )\n}\n\npub fn exhaustive_natural_triple_gen_var_6() -> It<(Natural, Natural, Natural)> {\n    Box::new(exhaustive_triples_from_single(\n        exhaustive_positive_naturals(),\n    ))\n}\n\npub fn exhaustive_natural_triple_gen_var_7() -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals()).map(|(x, y, z)| (x + &y * &z, y, z)),\n    )\n}\n\npub fn exhaustive_natural_triple_gen_var_8() -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals())\n            .map(|(a, b, n)| (a, b, (n << 1u32) | Natural::ONE)),\n    )\n}\n\npub fn exhaustive_natural_triple_gen_var_9() -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_naturals())\n            .map(|(a, m, n)| (a, (m << 1u32) | Natural::ONE, (n << 1u32) | Natural::ONE)),\n    )\n}\n\n// -- (Natural, Natural, Natural, Natural) --\n\npub fn exhaustive_natural_quadruple_gen_var_1() -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_quadruples_from_single(exhaustive_naturals()).map(|(x, y, z, w)| {\n            let w = max!(&x, &y, &z) + w + Natural::ONE;\n            (x, y, z, w)\n        }),\n    )\n}\n\npub fn exhaustive_natural_quadruple_gen_var_2() -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_quadruples_from_single(exhaustive_naturals()).map(|(x, y, z, mut w)| {\n            w += max!(&x, &y);\n            w += Natural::ONE;\n            (x, y, z, w)\n        }),\n    )\n}\n\npub fn exhaustive_natural_quadruple_gen_var_3() -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        exhaustive_quadruples_from_single(exhaustive_naturals()).map(|(x, y, z, mut w)| {\n            w += &x;\n            w += Natural::ONE;\n            (x, y, z, w)\n        }),\n    )\n}\n\n// -- (Natural, Natural, Natural, PrimitiveUnsigned) --\n\npub fn exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Natural, Natural, Natural, T)> {\n    Box::new(exhaustive_quadruples_xxxy_custom_output(\n        exhaustive_naturals(),\n        exhaustive_unsigneds::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_2()\n-> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        exhaustive_quadruples_xxxy(exhaustive_naturals(), exhaustive_unsigneds::<u64>()).map(\n            |(x, y, z, mut m)| {\n                m += max!(\n                    x.significant_bits(),\n                    y.significant_bits(),\n                    z.significant_bits()\n                );\n                (x, y, z, m)\n            },\n        ),\n    )\n}\n\npub fn exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_3()\n-> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        exhaustive_quadruples_xxxy(exhaustive_naturals(), exhaustive_unsigneds::<u64>()).map(\n            |(x, y, z, mut m)| {\n                m += max(x.significant_bits(), y.significant_bits());\n                (x, y, z, m)\n            },\n        ),\n    )\n}\n\npub fn exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_4()\n-> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        exhaustive_quadruples_xxxy(exhaustive_naturals(), exhaustive_unsigneds::<u64>()).map(\n            |(x, y, z, mut m)| {\n                m += x.significant_bits();\n                (x, y, z, m)\n            },\n        ),\n    )\n}\n\n// -- (Natural, Natural, PrimitiveFloat) --\n\npub fn exhaustive_natural_natural_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Natural, Natural, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_naturals(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Natural, Natural, PrimitiveSigned) --\n\npub fn exhaustive_natural_natural_signed_triple_gen<T: PrimitiveSigned>()\n-> It<(Natural, Natural, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_naturals(),\n        exhaustive_signeds::<T>(),\n    ))\n}\n\npub fn exhaustive_natural_natural_signed_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Natural, Natural, T)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs_big_small(\n        exhaustive_ordered_unique_pairs(exhaustive_naturals()),\n        exhaustive_signeds(),\n    )))\n}\n\n// -- (Natural, Natural, PrimitiveUnsigned) --\n\npub fn exhaustive_natural_natural_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> It<(Natural, Natural, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_naturals(),\n        exhaustive_unsigneds::<T>(),\n    ))\n}\n\npub fn exhaustive_natural_natural_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Natural, Natural, T)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_naturals(),\n        exhaustive_unsigneds::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_natural_natural_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> It<(Natural, Natural, T)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_naturals(),\n            exhaustive_unsigneds::<T>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(x, y, pow)| ((x << pow) + &y, y, pow)),\n    )\n}\n\npub fn exhaustive_natural_natural_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> It<(Natural, Natural, T)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_naturals(),\n            exhaustive_unsigneds::<T>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter(|&(ref x, ref y, pow)| !x.eq_mod_power_of_2(y, pow.exact_into())),\n    )\n}\n\npub fn exhaustive_natural_natural_unsigned_triple_gen_var_4() -> It<(Natural, Natural, u64)> {\n    Box::new(\n        exhaustive_triples_xxy(exhaustive_naturals(), exhaustive_unsigneds::<u64>()).map(\n            |(x, y, mut m)| {\n                m += max(x.significant_bits(), y.significant_bits());\n                (x, y, m)\n            },\n        ),\n    )\n}\n\npub fn exhaustive_natural_natural_unsigned_triple_gen_var_5() -> It<(Natural, Natural, u64)> {\n    Box::new(\n        exhaustive_triples_xxy(exhaustive_naturals(), exhaustive_unsigneds::<u64>()).map(\n            |(x, y, mut m)| {\n                m += x.significant_bits();\n                (x, y, m)\n            },\n        ),\n    )\n}\n\npub fn exhaustive_natural_natural_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> It<(Natural, Natural, T)> {\n    reshape_2_1_to_3(Box::new(exhaustive_pairs_big_small(\n        exhaustive_ordered_unique_pairs(exhaustive_naturals()),\n        exhaustive_unsigneds(),\n    )))\n}\n\n// -- (Natural, Natural, RoundingMode) --\n\npub fn exhaustive_natural_natural_rounding_mode_triple_gen_var_1()\n-> It<(Natural, Natural, RoundingMode)> {\n    Box::new(\n        exhaustive_triples(\n            exhaustive_naturals(),\n            exhaustive_positive_naturals(),\n            exhaustive_rounding_modes(),\n        )\n        .map(|(x, y, rm)| {\n            if rm == Exact {\n                (x * &y, y, rm)\n            } else {\n                (x, y, rm)\n            }\n        }),\n    )\n}\n\npub(crate) fn round_to_multiple_natural_filter_map(\n    x: Natural,\n    y: Natural,\n    rm: RoundingMode,\n) -> Option<(Natural, Natural, RoundingMode)> {\n    if x == y {\n        Some((x, y, rm))\n    } else if y == 0 {\n        if rm == Down || rm == Floor || rm == Nearest {\n            Some((x, y, rm))\n        } else {\n            None\n        }\n    } else if rm == Exact {\n        Some((x * &y, y, rm))\n    } else {\n        Some((x, y, rm))\n    }\n}\n\npub fn exhaustive_natural_natural_rounding_mode_triple_gen_var_2()\n-> It<(Natural, Natural, RoundingMode)> {\n    Box::new(\n        exhaustive_triples(\n            exhaustive_naturals(),\n            exhaustive_positive_naturals(),\n            exhaustive_rounding_modes(),\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_natural_filter_map(x, y, rm)),\n    )\n}\n\n// -- (Natural, PrimitiveFloat) --\n\npub fn exhaustive_natural_primitive_float_pair_gen<T: PrimitiveFloat>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_naturals(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Natural, PrimitiveFloat, PrimitiveFloat) --\n\npub fn exhaustive_natural_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Natural, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_naturals(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Natural, PrimitiveInt) --\n\npub fn exhaustive_natural_primitive_int_pair_gen_var_1<\n    T: PrimitiveInt + SaturatingFrom<U>,\n    U: PrimitiveInt,\n>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_naturals(),\n        primitive_int_increasing_inclusive_range(T::TWO, T::saturating_from(U::MAX)),\n    ))\n}\n\npub fn exhaustive_natural_primitive_int_pair_gen_var_2<T: PrimitiveInt>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_naturals(),\n        primitive_int_increasing_inclusive_range(T::TWO, T::MAX),\n    ))\n}\n\npub fn exhaustive_natural_primitive_int_pair_gen_var_3<T: PrimitiveInt>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_naturals(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_natural_primitive_int_pair_gen_var_4<T: PrimitiveInt>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_naturals(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (Natural, PrimitiveInt, PrimitiveUnsigned) --\n\npub fn exhaustive_natural_primitive_int_unsigned_triple_gen_var_3<\n    T: PrimitiveInt,\n    U: PrimitiveUnsigned,\n>() -> It<(Natural, T, U)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_naturals(),\n        exhaustive_positive_primitive_ints(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Natural, PrimitiveSigned) --\n\npub fn exhaustive_natural_signed_pair_gen<T: PrimitiveSigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_naturals(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_natural_signed_pair_gen_var_1<T: PrimitiveSigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_naturals(),\n        exhaustive_natural_signeds(),\n    ))\n}\n\npub fn exhaustive_natural_signed_pair_gen_var_2<T: PrimitiveSigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_naturals(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_natural_signed_pair_gen_var_3<T: PrimitiveSigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_positive_naturals(),\n        exhaustive_signeds(),\n    ))\n}\n\nstruct NaturalBitsMultipleOfLimbBitsGenerator;\n\nimpl ExhaustiveDependentPairsYsGenerator<u64, Natural, It<Natural>>\n    for NaturalBitsMultipleOfLimbBitsGenerator\n{\n    #[inline]\n    fn get_ys(&self, pow: &u64) -> It<Natural> {\n        let p = Natural::power_of_2(pow << Limb::LOG_WIDTH);\n        Box::new(exhaustive_natural_range(&p >> 1u32, p))\n    }\n}\n\npub fn exhaustive_natural_signed_pair_gen_var_4<T: PrimitiveSigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_positive_primitive_ints(),\n            NaturalBitsMultipleOfLimbBitsGenerator,\n        )\n        .map(|p| p.1),\n        exhaustive_signeds(),\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, PrimitiveSigned) --\n\npub fn exhaustive_natural_signed_signed_triple_gen<T: PrimitiveSigned>() -> It<(Natural, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_naturals(),\n        exhaustive_signeds::<T>(),\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn exhaustive_natural_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Natural, T, u64)> {\n    Box::new(\n        exhaustive_triples_custom_output(\n            exhaustive_naturals(),\n            exhaustive_signeds::<T>(),\n            exhaustive_unsigneds::<u64>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\npub fn exhaustive_natural_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Natural, T, U)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_naturals(),\n        exhaustive_signeds::<T>(),\n        exhaustive_positive_primitive_ints::<U>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, RoundingMode) --\n\npub fn exhaustive_natural_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shr<T, Output = Natural>,\n{\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_naturals(), exhaustive_signeds::<T>()),\n            exhaustive_rounding_modes(),\n        )\n        .map(|((n, i), rm)| {\n            (\n                if i < T::ZERO && rm == Exact {\n                    n >> i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\npub fn exhaustive_natural_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>()\n-> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_naturals(), exhaustive_signeds::<T>()),\n            exhaustive_rounding_modes(),\n        )\n        .map(|((n, i), rm)| {\n            (\n                if i > T::ZERO && rm == Exact {\n                    n << i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned) --\n\npub fn exhaustive_natural_unsigned_pair_gen<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_naturals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    Box::new(lex_pairs(\n        exhaustive_naturals(),\n        primitive_int_increasing_inclusive_range(T::TWO, T::from(36u8)),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_naturals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_4<T: PrimitiveInt>() -> It<(Natural, u64)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_naturals(),\n        primitive_int_increasing_inclusive_range(1, T::WIDTH),\n    ))\n}\n\nstruct NaturalDivisibleByP2PairsGenerator;\n\nimpl ExhaustiveDependentPairsYsGenerator<u64, Natural, It<Natural>>\n    for NaturalDivisibleByP2PairsGenerator\n{\n    #[inline]\n    fn get_ys(&self, pow: &u64) -> It<Natural> {\n        let pow = *pow;\n        if pow == 0 {\n            Box::new(exhaustive_naturals())\n        } else {\n            Box::new(exhaustive_naturals().map(move |k| k << pow))\n        }\n    }\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    permute_2_1(Box::new(\n        exhaustive_dependent_pairs(\n            ruler_sequence(),\n            exhaustive_unsigneds(),\n            NaturalDivisibleByP2PairsGenerator,\n        )\n        .map(|(x, y)| (T::exact_from(x), y)),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_naturals(), exhaustive_unsigneds::<T>())\n            .filter(|(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_7() -> It<(Natural, u64)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_naturals(), exhaustive_unsigneds::<u64>()).map(|(x, mut m)| {\n            m += x.significant_bits();\n            (x, m)\n        }),\n    )\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_positive_naturals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_9<T: PrimitiveUnsigned>() -> It<(Natural, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_naturals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_pair_gen_var_10() -> It<(Natural, u64)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_positive_naturals(),\n            exhaustive_unsigneds::<u64>(),\n        )\n        .map(|(x, mut m)| {\n            m += x.significant_bits();\n            (x, m)\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, bool) --\n\npub fn exhaustive_natural_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Natural, T, bool)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_naturals(),\n        exhaustive_unsigneds(),\n        exhaustive_bools(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::normal(1),\n    ))\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned) --\n\ntype T2<T> = It<(Natural, T, T)>;\npub fn exhaustive_natural_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> T2<T> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_naturals(),\n        exhaustive_unsigneds::<T>(),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Natural, T, U)> {\n    permute_1_3_2(reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_naturals(), exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(T::TWO, T::from(36u8)),\n    ))))\n}\n\npub fn exhaustive_natural_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>() -> It<(Natural, u64, T)> {\n    permute_1_3_2(reshape_2_1_to_3(Box::new(lex_pairs(\n        exhaustive_pairs_big_tiny(exhaustive_naturals(), exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(1, U::WIDTH),\n    ))))\n}\n\npub fn exhaustive_natural_unsigned_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> It<(Natural, T, T)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_naturals(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter_map(|(x, y, z): (Natural, T, T)| y.checked_add(z).map(|new_z| (x, y, new_z))),\n    )\n}\n\npub fn exhaustive_natural_unsigned_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>()\n-> It<(Natural, T, T)> {\n    Box::new(exhaustive_triples_xyy_custom_output(\n        exhaustive_naturals(),\n        exhaustive_unsigneds(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\npub fn exhaustive_natural_unsigned_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> It<(Natural, T, u64)> {\n    Box::new(\n        exhaustive_triples_custom_output(\n            exhaustive_naturals(),\n            exhaustive_unsigneds::<T>(),\n            exhaustive_unsigneds::<u64>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\npub fn exhaustive_natural_unsigned_unsigned_natural_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Natural, T, T, Natural)> {\n    Box::new(\n        exhaustive_quadruples_xyyx(exhaustive_naturals(), exhaustive_unsigneds())\n            .filter(|(_, y, z, _)| y < z),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\npub fn exhaustive_natural_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        lex_pairs(\n            exhaustive_pairs_big_small(exhaustive_naturals(), exhaustive_unsigneds()),\n            exhaustive_rounding_modes(),\n        )\n        .map(|((n, u), rm)| {\n            if rm == Exact {\n                (n << u, u, rm)\n            } else {\n                (n, u, rm)\n            }\n        }),\n    )\n}\n\n// var 2 is in malachite-float\n\n// -- (Natural, PrimitiveUnsigned, Vec<bool>) --\n\nstruct NaturalUnsignedBoolVecPairGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        (Natural, u64),\n        Vec<bool>,\n        LexFixedLengthVecsFromSingle<ExhaustiveBools>,\n    > for NaturalUnsignedBoolVecPairGenerator\n{\n    #[inline]\n    fn get_ys(&self, p: &(Natural, u64)) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(\n            p.0.significant_bits().div_round(p.1, Up).0,\n            exhaustive_bools(),\n        )\n    }\n}\n\npub fn exhaustive_natural_unsigned_bool_vec_triple_gen_var_1() -> It<(Natural, u64, Vec<bool>)> {\n    reshape_2_1_to_3(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_pairs_big_tiny(exhaustive_naturals(), exhaustive_positive_primitive_ints()),\n        NaturalUnsignedBoolVecPairGenerator,\n    )))\n}\n\npub fn exhaustive_natural_unsigned_bool_vec_triple_gen_var_2<T: PrimitiveInt>()\n-> It<(Natural, u64, Vec<bool>)> {\n    reshape_2_1_to_3(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        lex_pairs(\n            exhaustive_naturals(),\n            primitive_int_increasing_inclusive_range(1, T::WIDTH),\n        ),\n        NaturalUnsignedBoolVecPairGenerator,\n    )))\n}\n\n// -- (Natural, RoundingMode) --\n\npub fn exhaustive_natural_rounding_mode_pair_gen() -> It<(Natural, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_naturals(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_natural_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat,\n>() -> It<(Natural, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_naturals(), exhaustive_rounding_modes())\n            .filter(|&(ref n, rm)| rm != Exact || T::convertible_from(n)),\n    )\n}\n\npub fn exhaustive_natural_rounding_mode_pair_gen_var_2() -> It<(Natural, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_positive_naturals(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\n// -- (Natural, ToSciOptions) --\n\npub fn exhaustive_natural_to_sci_options_pair_gen() -> It<(Natural, ToSciOptions)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_naturals(),\n        exhaustive_to_sci_options(),\n    ))\n}\n\npub fn exhaustive_natural_to_sci_options_pair_gen_var_1() -> It<(Natural, ToSciOptions)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_naturals(), exhaustive_to_sci_options())\n            .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- (Natural, Vec<bool>) --\n\nstruct NaturalBoolVecPairGenerator1;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Natural,\n        Vec<bool>,\n        LexFixedLengthVecsFromSingle<ExhaustiveBools>,\n    > for NaturalBoolVecPairGenerator1\n{\n    #[inline]\n    fn get_ys(&self, x: &Natural) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(x.limb_count(), exhaustive_bools())\n    }\n}\n\npub fn exhaustive_natural_bool_vec_pair_gen_var_1() -> It<(Natural, Vec<bool>)> {\n    Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_naturals(),\n        NaturalBoolVecPairGenerator1,\n    ))\n}\n\nstruct NaturalBoolVecPairGenerator2;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Natural,\n        Vec<bool>,\n        LexFixedLengthVecsFromSingle<ExhaustiveBools>,\n    > for NaturalBoolVecPairGenerator2\n{\n    #[inline]\n    fn get_ys(&self, x: &Natural) -> LexFixedLengthVecsFromSingle<ExhaustiveBools> {\n        lex_vecs_fixed_length_from_single(x.significant_bits(), exhaustive_bools())\n    }\n}\n\npub fn exhaustive_natural_bool_vec_pair_gen_var_2() -> It<(Natural, Vec<bool>)> {\n    Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_naturals(),\n        NaturalBoolVecPairGenerator2,\n    ))\n}\n\n// -- (PrimitiveUnsigned, bool)\n\npub fn exhaustive_unsigned_bool_pair_gen_var_1() -> It<(usize, bool)> {\n    Box::new(\n        lex_pairs(exhaustive_unsigneds(), exhaustive_bools())\n            .filter(|&(n, b)| limbs_odd_factorial_valid(n, b)),\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// vars 1 through 31 are in malachite-base.\n\npub fn exhaustive_unsigned_pair_gen_var_32<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    // TODO\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_unsigneds(),\n            primitive_int_increasing_inclusive_range(\n                T::exact_from(ODD_FACTORIAL_TABLE_LIMIT + 1),\n                T::MAX,\n            ),\n        )\n        .filter(|&(n, k)| n >= k),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_33<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    // TODO\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_unsigneds(),\n            primitive_int_increasing_inclusive_range(\n                T::TWO,\n                T::wrapping_from(ODD_FACTORIAL_TABLE_LIMIT),\n            ),\n        )\n        .filter(|&(n, k)| n >= k),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_34<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs(\n            primitive_int_increasing_inclusive_range(\n                T::from(4u8),\n                T::wrapping_from(ODD_FACTORIAL_EXTTABLE_LIMIT),\n            ),\n            primitive_int_increasing_inclusive_range(\n                T::TWO,\n                T::wrapping_from(ODD_FACTORIAL_EXTTABLE_LIMIT - 2),\n            ),\n        )\n        .filter(|&(n, k)| n >= k + T::TWO),\n    )\n}\n\npub fn exhaustive_unsigned_pair_gen_var_35<T: PrimitiveUnsigned>() -> It<(T, T)> {\n    Box::new(\n        exhaustive_pairs(\n            primitive_int_increasing_inclusive_range(\n                T::wrapping_from((ODD_CENTRAL_BINOMIAL_OFFSET << 1) + 1),\n                T::MAX,\n            ),\n            primitive_int_increasing_inclusive_range(\n                T::wrapping_from((ODD_CENTRAL_BINOMIAL_OFFSET << 1) - 1),\n                T::wrapping_from(\n                    (if BIN_UIUI_RECURSIVE_SMALLDC {\n                        ODD_CENTRAL_BINOMIAL_TABLE_LIMIT\n                    } else {\n                        ODD_FACTORIAL_TABLE_LIMIT\n                    }) << 1,\n                ),\n            ),\n        )\n        .filter(|&(n, k)| n >= k + T::TWO),\n    )\n}\n\n#[allow(clippy::useless_conversion)]\npub fn exhaustive_unsigned_pair_gen_var_36() -> It<(Limb, Limb)> {\n    Box::new(\n        exhaustive_pairs(\n            primitive_int_increasing_inclusive_range(\n                Limb::wrapping_from(BIN_GOETGHELUCK_THRESHOLD) << 1,\n                Limb::MAX,\n            ),\n            primitive_int_increasing_inclusive_range(\n                Limb::wrapping_from(BIN_GOETGHELUCK_THRESHOLD),\n                Limb::MAX,\n            ),\n        )\n        .filter(|&(n, k)| {\n            n >= k + 5\n                && k > (n >> 4)\n                && n_to_bit(u64::from(n - k)) < n_to_bit(u64::from(n))\n                && k <= n - k\n        }),\n    )\n}\n\n// -- (PrimitiveUnsigned * 6) --\n\n// var 1 is in malachite-base.\n\npub fn exhaustive_unsigned_sextuple_gen_var_2() -> It<(Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_pairs(\n                exhaustive_unsigned_pair_gen_var_20(),\n                exhaustive_unsigned_pair_gen_var_24(),\n            )\n            .filter(|&((n_2, n_1), (d_1, d_0))| n_2 < d_1 || n_2 == d_1 && n_1 < d_0),\n            exhaustive_unsigneds(),\n        )\n        .map(|(((n_2, n_1), (d_1, d_0)), n_0)| {\n            (\n                n_2,\n                n_1,\n                n_0,\n                d_1,\n                d_0,\n                limbs_two_limb_inverse_helper(d_1, d_0),\n            )\n        }),\n    )\n}\n\n// -- (String, String, String) --\n\npub fn exhaustive_string_triple_gen_var_1() -> It<(String, String, String)> {\n    Box::new(exhaustive_naturals().map(|x| {\n        (\n            serde_json::to_string(&BigUint::from(&x)).unwrap(),\n            serde_json::to_string(&rug::Integer::from(&x)).unwrap(),\n            serde_json::to_string(&x).unwrap(),\n        )\n    }))\n}\n\npub fn exhaustive_string_triple_gen_var_2() -> It<(String, String, String)> {\n    Box::new(exhaustive_integers().map(|x| {\n        (\n            serde_json::to_string(&BigInt::from(&x)).unwrap(),\n            serde_json::to_string(&rug::Integer::from(&x)).unwrap(),\n            serde_json::to_string(&x).unwrap(),\n        )\n    }))\n}\n\n// var 3 is in malachite-q.\n\n// -- Vec<Integer> --\n\npub fn exhaustive_integer_vec_gen() -> It<Vec<Integer>> {\n    Box::new(exhaustive_vecs(exhaustive_integers()))\n}\n\n// -- Vec<Natural> --\n\npub fn exhaustive_natural_vec_gen() -> It<Vec<Natural>> {\n    Box::new(exhaustive_vecs(exhaustive_naturals()))\n}\n\n// -- (Vec<Natural>, Integer)\n\npub fn exhaustive_natural_vec_integer_pair_gen_var_1() -> It<(Vec<Natural>, Integer)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_vecs(exhaustive_positive_naturals()),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Vec<Natural>, Natural)\n\nstruct ValidDigitsGenerator;\n\nimpl ExhaustiveDependentPairsYsGenerator<Natural, Vec<Natural>, It<Vec<Natural>>>\n    for ValidDigitsGenerator\n{\n    #[inline]\n    fn get_ys(&self, base: &Natural) -> It<Vec<Natural>> {\n        Box::new(exhaustive_vecs(exhaustive_natural_range(\n            Natural::ZERO,\n            base.clone(),\n        )))\n    }\n}\n\npub fn exhaustive_natural_vec_natural_pair_gen_var_1() -> It<(Vec<Natural>, Natural)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_natural_range_to_infinity(Natural::power_of_2(Limb::WIDTH)),\n        ValidDigitsGenerator,\n    )))\n}\n\npub fn exhaustive_natural_vec_natural_pair_gen_var_2() -> It<(Vec<Natural>, Natural)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n        ValidDigitsGenerator,\n    )))\n}\n\npub fn exhaustive_natural_vec_natural_pair_gen_var_3() -> It<(Vec<Natural>, Natural)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_vecs(exhaustive_naturals()),\n        exhaustive_natural_range_to_infinity(Natural::power_of_2(Limb::WIDTH)),\n    ))\n}\n\npub fn exhaustive_natural_vec_natural_pair_gen_var_4() -> It<(Vec<Natural>, Natural)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_vecs(exhaustive_naturals()),\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n    ))\n}\n\n// -- (Vec<Natural>, PrimitiveInt) --\n\npub fn exhaustive_natural_vec_primitive_int_pair_gen_var_1<T: PrimitiveInt>()\n-> It<(Vec<Natural>, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_vecs(exhaustive_naturals()),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (Vec<Natural>, u64) --\n\nstruct PowerOf2DigitsGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        Vec<Natural>,\n        ExhaustiveVecs<Natural, PrimitiveIntIncreasingRange<u64>, ExhaustiveNaturalRange>,\n    > for PowerOf2DigitsGenerator\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        &log_base: &u64,\n    ) -> ExhaustiveVecs<Natural, PrimitiveIntIncreasingRange<u64>, ExhaustiveNaturalRange> {\n        exhaustive_vecs(exhaustive_natural_range(\n            Natural::ZERO,\n            Natural::power_of_2(log_base),\n        ))\n    }\n}\n\npub fn exhaustive_natural_vec_unsigned_pair_gen_var_1() -> It<(Vec<Natural>, u64)> {\n    permute_2_1(Box::new(exhaustive_dependent_pairs(\n        bit_distributor_sequence(\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n        ),\n        primitive_int_increasing_inclusive_range(1, u64::MAX),\n        PowerOf2DigitsGenerator,\n    )))\n}\n\n// -- Vec<PrimitiveUnsigned>\n\n// vars 1 through 4 are in malachite-base.\n\npub fn exhaustive_unsigned_vec_gen_var_5() -> It<Vec<Limb>> {\n    Box::new(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds()).map(|mut xs| {\n            limbs_vec_mul_limb_in_place(&mut xs, 3);\n            xs\n        }),\n    )\n}\n\n// var 6 is in malachite-base\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned)\n\n// vars 1 through 3 are in malachite-base\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_4<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveInt,\n>() -> It<(Vec<T>, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_vecs_min_length(2, exhaustive_unsigneds()),\n        primitive_int_increasing_inclusive_range(T::TWO, T::saturating_from(U::MAX)),\n    ))\n}\n\n// vars 5 through 17 are in malachite-base\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_18() -> It<(Vec<Limb>, u64)> {\n    Box::new(\n        exhaustive_unsigned_vec_unsigned_pair_gen_var_17().filter(|(xs, index)| {\n            let mut mut_xs = xs.clone();\n            limbs_vec_clear_bit_neg(&mut mut_xs, *index);\n            mut_xs.len() == xs.len()\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_19() -> It<(Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_vecs_min_length(1, exhaustive_unsigneds()),\n            exhaustive_positive_primitive_ints(),\n        )\n        .map(|(mut xs, y)| {\n            limbs_vec_mul_limb_in_place(&mut xs, y);\n            (xs, y)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_pair_gen_var_20() -> It<(Vec<Limb>, u64)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_vecs_min_length(1, exhaustive_unsigneds::<Limb>()),\n            exhaustive_unsigneds(),\n        )\n        .filter_map(|(mut xs, mut pow)| {\n            let xs_last = xs.last_mut().unwrap();\n            *xs_last = xs_last.checked_add(1)?;\n            pow += limbs_significant_bits_helper(&xs);\n            Some((xs, pow))\n        }),\n    )\n}\n\n// var 21 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned)\n\n// vars 1 through 5 are in malachite-base\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_6() -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(\n        exhaustive_triples_xyy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter(|(m, x, y)| {\n            !Integer::from(Natural::from(*x)).eq_mod(-Natural::from(*y), Natural::from_limbs_asc(m))\n        }),\n    )\n}\n\n// vars 7 through 8 are in malachite-base.\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_9() -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(exhaustive_triples(\n        exhaustive_vecs(exhaustive_unsigneds()),\n        factors_of_limb_max().into_iter(),\n        exhaustive_unsigneds(),\n    ))\n}\n\n// var 10 is in malachite-base.\n\npub(crate) fn map_helper_3(t: (Vec<Limb>, Limb, Limb)) -> (Vec<Limb>, Limb, Limb) {\n    let (mut xs, y, m) = t;\n    let carry = limbs_slice_mul_limb_in_place(&mut xs, m);\n    if carry != 0 {\n        xs.push(carry);\n    } else if *xs.last().unwrap() == 0 {\n        xs.pop();\n    }\n    limbs_vec_add_limb_in_place(&mut xs, y);\n    (xs, y, m)\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_11() -> It<(Vec<Limb>, Limb, Limb)>\n{\n    Box::new(\n        exhaustive_triples(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_unsigneds(),\n            exhaustive_positive_primitive_ints(),\n        )\n        .map(map_helper_3),\n    )\n}\n\npub(crate) fn filter_helper_6(t: &(Vec<Limb>, Limb, Limb)) -> bool {\n    let (xs, y, m) = t;\n    !limbs_eq_limb_mod_limb(xs, *y, *m)\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_12() -> It<(Vec<Limb>, Limb, Limb)>\n{\n    Box::new(\n        exhaustive_triples(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_unsigneds(),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter(filter_helper_6),\n    )\n}\n\n// var 13 is in malachite-base.\n\npub(crate) fn limbs_significant_bits_helper(xs: &[Limb]) -> u64 {\n    let trailing_zeros = usize::exact_from(slice_trailing_zeros(xs));\n    if trailing_zeros == xs.len() {\n        0\n    } else {\n        limbs_significant_bits(&xs[..xs.len() - trailing_zeros])\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_14<T: PrimitiveUnsigned>()\n-> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        exhaustive_triples_custom_output(\n            exhaustive_vecs(exhaustive_unsigneds::<Limb>()),\n            exhaustive_unsigneds::<T>(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            (xs, y, pow)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_15<T: PrimitiveUnsigned>()\n-> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        exhaustive_triples_custom_output(\n            exhaustive_vecs_min_length(1, exhaustive_unsigneds::<Limb>()),\n            exhaustive_unsigneds::<T>(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            (xs, y, pow)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_16<T: PrimitiveUnsigned>()\n-> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        exhaustive_triples_custom_output(\n            exhaustive_vecs(exhaustive_unsigneds::<Limb>()),\n            exhaustive_unsigneds::<T>(),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            if pow == 0 {\n                pow = 1;\n            }\n            (xs, y, pow)\n        }),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>)\n\nstruct ValidLengthsGenerator;\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<(Vec<Limb>, u64), Vec<T>, It<Vec<T>>>\n    for ValidLengthsGenerator\n{\n    #[inline]\n    fn get_ys(&self, p: &(Vec<Limb>, u64)) -> It<Vec<T>> {\n        Box::new(exhaustive_vecs_min_length(\n            limbs_digit_count(&p.0, p.1),\n            exhaustive_unsigneds(),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, u64, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_big_tiny(\n                exhaustive_vecs(exhaustive_unsigneds()),\n                (3u64..256).filter(|&b| !b.is_power_of_two()),\n            ),\n            ValidLengthsGenerator,\n        )\n        .map(|((xs, base), out)| (out, base, xs)),\n    )\n}\n\npub(crate) fn filter_map_helper_1(\n    t: (Vec<Limb>, Limb, Vec<Limb>),\n) -> Option<(Vec<Limb>, Limb, Vec<Limb>)> {\n    let (xs, y, m) = t;\n    let mut product_limbs = if xs.is_empty() {\n        Vec::new()\n    } else {\n        limbs_mul(&xs, &m)\n    };\n    if product_limbs.last() == Some(&0) {\n        product_limbs.pop();\n    }\n    if limbs_sub_limb_in_place(&mut product_limbs, y) || *product_limbs.last().unwrap() == 0 {\n        None\n    } else {\n        Some((product_limbs, y, m))\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2()\n-> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )))\n        .filter_map(filter_map_helper_1),\n    )\n}\n\npub(crate) fn filter_helper_1(t: &(Vec<Limb>, Limb, Vec<Limb>)) -> bool {\n    let (xs, y, m) = t;\n    !Integer::from(Natural::from_limbs_asc(xs))\n        .eq_mod(-Natural::from(*y), Natural::from_limbs_asc(m))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3()\n-> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )))\n        .filter(filter_helper_1),\n    )\n}\n\npub(crate) fn map_helper_1(t: (Vec<Limb>, Limb, Vec<Limb>)) -> (Vec<Limb>, Limb, Vec<Limb>) {\n    let (xs, y, m) = t;\n    let mut product_limbs = if xs.is_empty() {\n        Vec::new()\n    } else {\n        limbs_mul(&xs, &m)\n    };\n    if product_limbs.last() == Some(&0) {\n        product_limbs.pop();\n    }\n    limbs_vec_add_limb_in_place(&mut product_limbs, y);\n    (product_limbs, y, m)\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4()\n-> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )))\n        .map(map_helper_1),\n    )\n}\n\npub(crate) fn filter_helper_4(t: &(Vec<Limb>, Limb, Vec<Limb>)) -> bool {\n    let (xs, y, m) = t;\n    !limbs_eq_limb_mod_ref_ref(xs, *y, m)\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5()\n-> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )))\n        .filter(filter_helper_4),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\nstruct ValidLengthsBasecaseGenerator {\n    min_out_len: usize,\n}\n\nimpl<T: PrimitiveUnsigned> ExhaustiveDependentPairsYsGenerator<usize, Vec<T>, It<Vec<T>>>\n    for ValidLengthsBasecaseGenerator\n{\n    #[inline]\n    fn get_ys(&self, &len: &usize) -> It<Vec<T>> {\n        Box::new(exhaustive_vecs_min_length(\n            u64::exact_from(if len == 0 { self.min_out_len } else { len }),\n            exhaustive_unsigneds(),\n        ))\n    }\n}\n\nstruct BasecaseDigitsInputGenerator;\n\nimpl<T: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<(Vec<Limb>, u64), (Vec<T>, usize), It<(Vec<T>, usize)>>\n    for BasecaseDigitsInputGenerator\n{\n    #[inline]\n    fn get_ys(&self, p: &(Vec<Limb>, u64)) -> It<(Vec<T>, usize)> {\n        let min_out_len = usize::exact_from(limbs_digit_count(&p.0, p.1));\n        permute_2_1(Box::new(exhaustive_dependent_pairs(\n            ruler_sequence(),\n            once(0).chain(primitive_int_increasing_inclusive_range(\n                min_out_len,\n                usize::MAX,\n            )),\n            ValidLengthsBasecaseGenerator { min_out_len },\n        )))\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n>() -> It<(Vec<T>, usize, Vec<Limb>, u64)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_big_tiny(\n                exhaustive_vecs_length_range(\n                    0,\n                    u64::wrapping_from(GET_STR_PRECOMPUTE_THRESHOLD),\n                    exhaustive_unsigneds(),\n                ),\n                (3u64..256).filter(|&b| !b.is_power_of_two()),\n            ),\n            BasecaseDigitsInputGenerator,\n        )\n        .map(|((xs, base), (out, len))| (out, len, xs, base)),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// vars 1 through 10 are in malachite-base.\n\npub(crate) fn gcd_input_filter(xs: &[Limb], ys: &[Limb]) -> bool {\n    *xs.last().unwrap() != 0\n        && *ys.last().unwrap() != 0\n        && limbs_cmp(xs, ys) != Less\n        && (xs[0].odd() || ys[0].odd())\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_11() -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator2,\n        )\n        .map(|p| p.1)\n        .filter(|(xs, ys)| gcd_input_filter(xs, ys)),\n    )\n}\n\n// vars 12 through 13 are in malachite-base.\n\npub fn exhaustive_unsigned_vec_pair_gen_var_14() -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .filter_map(|(_, (out, mut xs))| {\n            limbs_vec_mul_limb_in_place(&mut xs, 3);\n            if out.len() >= xs.len() {\n                Some((out, xs))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_15() -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_pairs_from_single(exhaustive_vecs_min_length(2, exhaustive_unsigneds()))\n            .filter_map(|(ns, ds)| {\n                if *ds.last().unwrap() == 0 {\n                    return None;\n                }\n                let mut new_ns = limbs_mul(&ns, &ds);\n                if *new_ns.last().unwrap() == 0 {\n                    new_ns.pop();\n                }\n                Some((new_ns, ds))\n            }),\n    )\n}\n\n// vars 16 through 17 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_pair_gen_var_18() -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_pairs_from_single(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds()).filter_map(|mut xs| {\n                let x_last = xs.last_mut().unwrap();\n                if *x_last == Limb::MAX {\n                    None\n                } else {\n                    *x_last += 1;\n                    Some(xs)\n                }\n            }),\n        )\n        .filter_map(|(ns, ds)| {\n            let mut ns = limbs_mul(&ns, &ds);\n            if *ns.last().unwrap() == 0 {\n                ns.pop();\n            }\n            if *ns.last().unwrap() == 0 {\n                None\n            } else {\n                Some((ns, ds))\n            }\n        }),\n    )\n}\n\n// vars 19 through 21 are in malachite-nz.\n\npub fn exhaustive_unsigned_vec_pair_gen_var_22<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs(\n                primitive_int_increasing_inclusive_range(1, u64::MAX),\n                primitive_int_increasing_inclusive_range(\n                    1,\n                    u64::exact_from(SQRLO_DC_THRESHOLD_LIMIT),\n                ),\n            )\n            .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\nfn exhaustive_square_helper<T: PrimitiveUnsigned, F: Fn(usize) -> bool>(\n    valid: &'static F,\n    min_x: u64,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                move |(o, x)| {\n                    let x = x.checked_add(min_x)?;\n                    let ux = usize::exact_from(x);\n                    if valid(ux) {\n                        let o = x.arithmetic_checked_shl(1u64)?.checked_add(o)?;\n                        Some((o, x))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_23<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    exhaustive_square_helper(&|x| x <= SQR_TOOM2_THRESHOLD, 1)\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_24<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    exhaustive_square_helper(&|_| true, 2)\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_25<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    exhaustive_square_helper(&limbs_square_to_out_toom_3_input_size_valid, 3)\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_26<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    exhaustive_square_helper(&limbs_square_to_out_toom_4_input_size_valid, 4)\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_27<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    exhaustive_square_helper(&|x| x == 7 || x == 8 || x > 9, 7)\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_28<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    exhaustive_square_helper(&limbs_square_to_out_toom_6_input_size_valid, 18)\n}\n\npub fn exhaustive_unsigned_vec_pair_gen_var_29<T: PrimitiveUnsigned>() -> It<(Vec<T>, Vec<T>)> {\n    exhaustive_square_helper(&limbs_square_to_out_toom_8_input_size_valid, 40)\n}\n\n// vars 32 to 33 are in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\nstruct ValidDigitsGenerator1<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<(u64, usize), (Vec<T>, Vec<U>), It<(Vec<T>, Vec<U>)>>\n    for ValidDigitsGenerator1<T, U>\n{\n    #[inline]\n    fn get_ys(&self, p: &(u64, usize)) -> It<(Vec<T>, Vec<U>)> {\n        Box::new(exhaustive_pairs(\n            exhaustive_vecs_fixed_length_from_single(\n                u64::wrapping_from(p.1),\n                primitive_int_increasing_range(T::ZERO, T::wrapping_from(p.0)),\n            ),\n            exhaustive_vecs_min_length(limbs_per_digit_in_base(p.1, p.0), exhaustive_unsigneds()),\n        ))\n    }\n}\n\n// var 1 is in malachite-base\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<U>, Vec<T>, u64)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_big_tiny(\n                (3u64..256).filter(|&b| !b.is_power_of_two()),\n                exhaustive_positive_primitive_ints(),\n            ),\n            ValidDigitsGenerator1 {\n                phantom: PhantomData,\n            },\n        )\n        .map(|((base, _), (xs, out))| (out, xs, base)),\n    )\n}\n\nstruct ValidDigitsGenerator2<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    phantom: PhantomData<(T, U)>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned>\n    ExhaustiveDependentPairsYsGenerator<(u64, usize), (Vec<T>, Vec<U>), It<(Vec<T>, Vec<U>)>>\n    for ValidDigitsGenerator2<T, U>\n{\n    #[inline]\n    fn get_ys(&self, p: &(u64, usize)) -> It<(Vec<T>, Vec<U>)> {\n        Box::new(exhaustive_pairs(\n            exhaustive_vecs_fixed_length_from_single(\n                u64::wrapping_from(p.1),\n                exhaustive_unsigneds(),\n            ),\n            exhaustive_vecs_min_length(limbs_per_digit_in_base(p.1, p.0), exhaustive_unsigneds()),\n        ))\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Vec<U>, Vec<T>, u64)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_big_tiny(\n                (3u64..256).filter(|&b| !b.is_power_of_two()),\n                exhaustive_positive_primitive_ints(),\n            ),\n            ValidDigitsGenerator2 {\n                phantom: PhantomData,\n            },\n        )\n        .map(|((base, _), (xs, out))| (out, xs, base)),\n    )\n}\n\n// vars 4 through 6 are in malachite-base.\n\npub(crate) fn filter_map_helper_2(\n    t: (Vec<Limb>, Vec<Limb>, Limb),\n) -> Option<(Vec<Limb>, Vec<Limb>, Limb)> {\n    let (xs, ys, m) = t;\n    let mut product_limbs = xs;\n    if !product_limbs.is_empty() {\n        limbs_vec_mul_limb_in_place(&mut product_limbs, m);\n    };\n    if product_limbs.last() == Some(&0) {\n        product_limbs.pop();\n    }\n    if product_limbs.len() < ys.len()\n        || limbs_sub_greater_in_place_left(&mut product_limbs, &ys)\n        || *product_limbs.last().unwrap() == 0\n    {\n        None\n    } else {\n        Some((product_limbs, ys, m))\n    }\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7()\n-> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter_map(filter_map_helper_2),\n    )\n}\n\npub(crate) fn filter_helper_2(t: &(Vec<Limb>, Vec<Limb>, Limb)) -> bool {\n    let (xs, ys, m) = t;\n    !Integer::from(Natural::from_limbs_asc(xs))\n        .eq_mod(-Natural::from_limbs_asc(ys), Natural::from(*m))\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_8()\n-> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter(filter_helper_2),\n    )\n}\n\n// vars 9 through 13 are in malachite-base.\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14()\n-> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                // TODO\n                exhaustive_pairs_from_single(primitive_int_increasing_inclusive_range(1, u64::MAX))\n                    .filter(|(x, y)| x >= y),\n                UnsignedVecPairLenGenerator1,\n            ),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter_map(|((_, (out, mut xs)), y)| {\n            limbs_vec_mul_limb_in_place(&mut xs, y);\n            if out.len() >= xs.len() {\n                Some((out, xs, y))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub(crate) fn map_helper_2(t: (Vec<Limb>, Vec<Limb>, Limb)) -> (Vec<Limb>, Vec<Limb>, Limb) {\n    let (mut xs, ys, m) = t;\n    limbs_vec_mul_limb_in_place(&mut xs, m);\n    if xs.last() == Some(&0) {\n        xs.pop();\n    }\n    limbs_vec_add_in_place_left(&mut xs, &ys);\n    (xs, ys, m)\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_15()\n-> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )\n        .map(map_helper_2),\n    )\n}\n\npub(crate) fn filter_helper_5(t: &(Vec<Limb>, Vec<Limb>, Limb)) -> bool {\n    let (xs, ys, m) = t;\n    !limbs_eq_mod_limb_ref_ref(xs, ys, *m)\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_16()\n-> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_triples_xxy(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter(filter_helper_5),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_17()\n-> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                    |(mut n_len, mut d_init_len)| {\n                        n_len = n_len.checked_add(3)?;\n                        d_init_len = d_init_len.checked_add(2)?;\n                        if n_len > d_init_len {\n                            Some((n_len, d_init_len))\n                        } else {\n                            None\n                        }\n                    },\n                ),\n                UnsignedVecPairLenGenerator1,\n            ),\n            primitive_int_increasing_inclusive_range(Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX),\n        )\n        .map(|((_, (n, mut d_init)), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (n, d_init, inverse)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18()\n-> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_vecs(exhaustive_unsigneds::<Limb>()),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(xs, ys, mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19()\n-> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                // TODO\n                exhaustive_pairs_from_single(exhaustive_unsigneds()).filter(|(x, y)| x >= y),\n                UnsignedVecPairLenGenerator1,\n            ),\n            exhaustive_unsigneds(),\n        )\n        .map(|((_, (xs, ys)), mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20()\n-> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_vecs_min_length(1, exhaustive_unsigneds::<Limb>()).filter_map(|mut xs| {\n                let last_x = xs.last_mut().unwrap();\n                *last_x = last_x.checked_add(1)?;\n                Some(xs)\n            }),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .map(|(xs, ys, mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21()\n-> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_vecs_min_length(1, exhaustive_unsigneds::<Limb>()),\n            exhaustive_unsigneds(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter_map(|(mut xs, mut es, pow)| {\n            let last_e = es.last_mut().unwrap();\n            *last_e = last_e.checked_add(1)?;\n            if es == [1] {\n                return None;\n            }\n            limbs_slice_mod_power_of_2_in_place(&mut xs, pow);\n            if *xs.last().unwrap() == 0 {\n                None\n            } else {\n                Some((xs, es, pow))\n            }\n        })\n        .unique(),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// vars 1 through 3 are in malachite-base\n\nfn exhaustive_mul_helper<T: PrimitiveUnsigned, F: Fn(usize, usize) -> bool>(\n    valid: &'static F,\n    min_x: u64,\n    min_y: u64,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                move |(o, x, y)| {\n                    let x = x.checked_add(min_x)?;\n                    let y = y.checked_add(min_y)?;\n                    if valid(usize::exact_from(x), usize::exact_from(y)) {\n                        let o = x.checked_add(y)?.checked_add(o)?;\n                        Some((o, x, y))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_4<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_22_input_sizes_valid, 2, 2)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_32_input_sizes_valid, 6, 4)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_33_input_sizes_valid, 3, 3)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_7<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_42_input_sizes_valid, 4, 2)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_8<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_43_input_sizes_valid, 11, 8)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_9<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_44_input_sizes_valid, 4, 4)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_10<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_52_input_sizes_valid, 14, 5)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_11<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_53_input_sizes_valid, 5, 3)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_12<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_54_input_sizes_valid, 14, 11)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_13<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_62_input_sizes_valid, 6, 2)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_14<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_63_input_sizes_valid, 17, 9)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_15<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_6h_input_sizes_valid, 42, 42)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_16<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(&limbs_mul_greater_to_out_toom_8h_input_sizes_valid, 86, 86)\n}\n\nfn exhaustive_mul_same_length_helper<T: PrimitiveUnsigned, F: Fn(usize, usize) -> bool>(\n    valid: &'static F,\n    min_x: u64,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                move |(o, x)| {\n                    let x = x.checked_add(min_x)?;\n                    let ux = usize::exact_from(x);\n                    if valid(ux, ux) {\n                        let o = x.arithmetic_checked_shl(1u64)?.checked_add(o)?;\n                        Some((o, x))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecTripleXYYLenGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_18<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_same_length_helper(&limbs_mul_greater_to_out_toom_33_input_sizes_valid, 5)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_19<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_same_length_helper(&limbs_mul_greater_to_out_toom_6h_input_sizes_valid, 42)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_20<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_same_length_helper(&limbs_mul_greater_to_out_toom_8h_input_sizes_valid, 86)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_22<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(\n        &|xs_len, ys_len| {\n            limbs_mul_greater_to_out_toom_32_input_sizes_valid(xs_len, ys_len)\n                && limbs_mul_greater_to_out_toom_43_input_sizes_valid(xs_len, ys_len)\n        },\n        11,\n        8,\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_23<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(\n        &|xs_len, ys_len| {\n            limbs_mul_greater_to_out_toom_42_input_sizes_valid(xs_len, ys_len)\n                && limbs_mul_greater_to_out_toom_53_input_sizes_valid(xs_len, ys_len)\n        },\n        5,\n        3,\n    )\n}\n\n// vars 24 through 36 are in malachite-base\n\npub(crate) fn filter_map_helper_3(\n    t: (Vec<Limb>, Vec<Limb>, Vec<Limb>),\n) -> Option<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    let (xs, ys, m) = t;\n    let mut product_limbs = if xs.is_empty() {\n        Vec::new()\n    } else {\n        limbs_mul(&xs, &m)\n    };\n    if product_limbs.last() == Some(&0) {\n        product_limbs.pop();\n    }\n    if product_limbs.len() < ys.len()\n        || limbs_sub_greater_in_place_left(&mut product_limbs, &ys)\n        || *product_limbs.last().unwrap() == 0\n    {\n        None\n    } else {\n        Some((product_limbs, ys, m))\n    }\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_37() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_triples_from_single(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter_map(filter_map_helper_3),\n    )\n}\n\npub(crate) fn filter_helper_3(t: &(Vec<Limb>, Vec<Limb>, Vec<Limb>)) -> bool {\n    let (xs, ys, m) = t;\n    !Integer::from(Natural::from_limbs_asc(xs))\n        .eq_mod(-Natural::from_limbs_asc(ys), Natural::from_limbs_asc(m))\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_38() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_triples_from_single(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter(filter_helper_3),\n    )\n}\n\n// vars 39 through 41 are in malachite-base.\n\npub fn exhaustive_unsigned_vec_triple_gen_var_42() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                    |(q_len, mut n_len, mut d_init_len)| {\n                        n_len = n_len.checked_add(2)?;\n                        d_init_len = d_init_len.checked_add(1)?;\n                        let d_len = d_init_len + 1;\n                        if n_len >= d_len && q_len >= n_len - d_len {\n                            Some((q_len, n_len, d_init_len))\n                        } else {\n                            None\n                        }\n                    },\n                ),\n                UnsignedVecTripleLenGenerator1,\n            )\n            .map(|p| p.1),\n            primitive_int_increasing_inclusive_range(Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX),\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            (q, n, d_init)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_43() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                    |(q_len, mut n_len, mut d_init_len)| {\n                        n_len = n_len.checked_add(3)?;\n                        d_init_len = d_init_len.checked_add(1)?;\n                        let d_len = d_init_len + 1;\n                        if n_len > d_len && q_len >= n_len - d_len {\n                            Some((q_len, n_len, d_init_len))\n                        } else {\n                            None\n                        }\n                    },\n                ),\n                UnsignedVecTripleLenGenerator1,\n            )\n            .map(|p| p.1),\n            primitive_int_increasing_inclusive_range(Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX),\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            (q, n, d_init)\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_44() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(mut q_len, mut n_len, mut d_len)| {\n                    q_len = q_len.checked_add(1)?;\n                    n_len = n_len.checked_add(2)?;\n                    d_len = d_len.checked_add(2)?;\n                    if n_len >= d_len && q_len > n_len - d_len {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d))| {\n            if *d.last().unwrap() != 0 {\n                Some((q, n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_45() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(mut q_len, mut n_len, mut d_len)| {\n                    q_len = q_len.checked_add(1)?;\n                    n_len = n_len.checked_add(2)?;\n                    d_len = d_len.checked_add(2)?;\n                    if n_len >= d_len && q_len > n_len - d_len && n_len < (d_len - 1) << 1 {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d))| {\n            if *d.last().unwrap() != 0 {\n                Some((q, n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_46() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter_map(|(q_len, n_len, d_len)| {\n                    if q_len >= n_len && n_len >= d_len {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                }),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(\n            |(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n                if d[0].odd() { Some((q, n, d)) } else { None }\n            },\n        ),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_47() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(primitive_int_increasing_inclusive_range(1, u64::MAX))\n                .filter_map(|(q_len, n_len, d_len)| {\n                    if q_len >= n_len && n_len >= d_len {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                }),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(\n            |(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n                if d[0].odd() { Some((q, n, d)) } else { None }\n            },\n        ),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_48() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(primitive_int_increasing_inclusive_range(1, u64::MAX))\n                .filter_map(|(q_len, n_len, d_len)| {\n                    if q_len + 1 >= n_len {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                }),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n            if *d.last().unwrap() == 0 {\n                return None;\n            }\n            let mut new_n = limbs_mul(&n, &d);\n            if *new_n.last().unwrap() == 0 {\n                new_n.pop();\n            }\n            if q.len() + d.len() >= new_n.len() + 1 {\n                Some((q, new_n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_49() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(primitive_int_increasing_inclusive_range(1, u64::MAX))\n                .filter_map(|(q_len, n_len, mut d_len)| {\n                    d_len = d_len.checked_add(1)?;\n                    if q_len + 1 >= n_len {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                }),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n            if *d.last().unwrap() == 0 {\n                return None;\n            }\n            let mut new_n = limbs_mul(&n, &d);\n            if *new_n.last().unwrap() == 0 {\n                new_n.pop();\n            }\n            if q.len() > new_n.len() - d.len() {\n                Some((q, n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n// vars 50 through 53 are in malachite-base.\n\npub(crate) fn limbs_eq_mod_map(\n    xs: &[Limb],\n    ys: Vec<Limb>,\n    m: Vec<Limb>,\n) -> (Vec<Limb>, Vec<Limb>, Vec<Limb>) {\n    let mut product_limbs = if xs.is_empty() {\n        Vec::new()\n    } else {\n        limbs_mul(xs, &m)\n    };\n    if product_limbs.last() == Some(&0) {\n        product_limbs.pop();\n    }\n    limbs_vec_add_in_place_left(&mut product_limbs, &ys);\n    (product_limbs, ys, m)\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_54() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_triples_from_single(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .map(|(xs, ys, m)| limbs_eq_mod_map(&xs, ys, m)),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_55() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_triples_from_single(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds())\n                .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter(|(xs, ys, m)| !limbs_eq_mod_ref_ref_ref(xs, ys, m)),\n    )\n}\n\npub fn exhaustive_unsigned_vec_triple_gen_var_56() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                exhaustive_pairs_from_single(exhaustive_unsigneds()).filter_map(\n                    |(q_len, n_len): (u64, u64)| {\n                        Some((q_len.checked_add(n_len)?, n_len.checked_add(2)?))\n                    },\n                ),\n                UnsignedVecPairLenGenerator1,\n            ),\n            exhaustive_pairs(\n                primitive_int_increasing_inclusive_range(\n                    Limb::power_of_2(Limb::WIDTH - 1),\n                    Limb::MAX,\n                ),\n                exhaustive_unsigneds(),\n            ),\n        )\n        .map(|((_, (q, n)), (d_1, d_0))| (q, n, vec![d_0, d_1])),\n    )\n}\n\n// var 57 is in malachite-base.\n\npub fn exhaustive_unsigned_vec_triple_gen_var_58<T: PrimitiveUnsigned>()\n-> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    exhaustive_mul_helper(\n        &|x, y| {\n            limbs_mul_greater_to_out_toom_44_input_sizes_valid(x, y)\n                && limbs_mul_greater_to_out_toom_44_input_sizes_valid(x, y)\n        },\n        7,\n        7,\n    )\n}\n\n// var 59 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned> * 4) --\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_vec_quadruple_gen_var_1()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_quadruples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                    q_len = q_len.checked_add(1)?;\n                    r_len = r_len.checked_add(2)?;\n                    n_len = n_len.checked_add(2)?;\n                    d_len = d_len.checked_add(2)?;\n                    if r_len >= d_len && n_len >= d_len && q_len > n_len - d_len {\n                        Some((q_len, r_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecQuadrupleLenGenerator1,\n        )\n        .filter_map(|(_, (q, r, n, d))| {\n            if *d.last().unwrap() != 0 {\n                Some((q, r, n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_vec_quadruple_gen_var_2()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_quadruples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                    q_len = q_len.checked_add(2)?;\n                    r_len = r_len.checked_add(2)?;\n                    n_len = n_len.checked_add(4)?;\n                    d_len = d_len.checked_add(2)?;\n                    if n_len >= d_len + 2 && q_len >= n_len - d_len && r_len >= d_len {\n                        Some((q_len, r_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecQuadrupleLenGenerator1,\n        )\n        .filter_map(\n            |(_, (q, r, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n                if d[0].odd() { Some((q, r, n, d)) } else { None }\n            },\n        ),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_vec_quadruple_gen_var_3()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_quadruples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                    q_len = q_len.checked_add(4)?;\n                    r_len = r_len.checked_add(2)?;\n                    n_len = n_len.checked_add(4)?;\n                    d_len = d_len.checked_add(2)?;\n                    if n_len >= d_len + 2 && q_len >= n_len - d_len && r_len >= d_len {\n                        Some((q_len, r_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecQuadrupleLenGenerator1,\n        )\n        .filter_map(\n            #[allow(clippy::type_complexity)]\n            |(_, (q, r, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n                if d[0].odd() { Some((q, r, n, d)) } else { None }\n            },\n        ),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_vec_quadruple_gen_var_4()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_quadruples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                    q_len = q_len.checked_add(1)?;\n                    r_len = r_len.checked_add(2)?;\n                    n_len = n_len.checked_add(2)?;\n                    d_len = d_len.checked_add(2)?;\n                    if r_len >= d_len\n                        && n_len >= d_len\n                        && q_len > n_len - d_len\n                        && (d_len << 1) > n_len + 1\n                    {\n                        Some((q_len, r_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecQuadrupleLenGenerator1,\n        )\n        .filter_map(|(_, (q, r, n, d))| {\n            if *d.last().unwrap() != 0 {\n                Some((q, r, n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_vec_quadruple_gen_var_5()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_quadruples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                    q_len = q_len.checked_add(1)?;\n                    r_len = r_len.checked_add(2)?;\n                    n_len = n_len.checked_add(3)?;\n                    d_len = d_len.checked_add(2)?;\n                    if r_len >= d_len && n_len > d_len && q_len + d_len >= n_len {\n                        Some((q_len, r_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecQuadrupleLenGenerator1,\n        )\n        .filter_map(\n            #[allow(clippy::type_complexity)]\n            |(_, (q, r, n, mut d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n                let d_last = d.last_mut().unwrap();\n                if d_last.get_highest_bit() {\n                    None\n                } else {\n                    d_last.set_bit(Limb::WIDTH - 1);\n                    Some((q, r, n, d))\n                }\n            },\n        ),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_vec_quadruple_gen_var_6()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_quadruples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(out_len, mut b_len, e_len, mut m_len)| {\n                    b_len = b_len.checked_add(1)?;\n                    m_len = m_len.checked_add(1)?;\n                    if out_len >= m_len {\n                        Some((out_len, b_len, e_len, m_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecQuadrupleLenGenerator1,\n        )\n        .filter_map(\n            #[allow(clippy::type_complexity)]\n            |(_, (out, bs, es, ms)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n                if (es.len() > 1 || es.len() == 1 && es[0] > 1)\n                    && *bs.last().unwrap() != 0\n                    && *es.last().unwrap() != 0\n                    && *ms.last().unwrap() != 0\n                {\n                    Some((out, bs, es, ms))\n                } else {\n                    None\n                }\n            },\n        ),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_unsigned_vec_quadruple_gen_var_7()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        exhaustive_unsigned_vec_quadruple_gen_var_6().filter_map(|(out, bs, es, mut ms)| {\n            let m = &mut ms[0];\n            *m = m.arithmetic_checked_shl(1)?;\n            *m |= 1;\n            Some((out, bs, es, ms))\n        }),\n    )\n}\n\n// -- large types --\n\n// vars 1 through 4 are in malachite-base\n\nfn exhaustive_half_gcd_matrices_with_size(s: usize, n: usize) -> It<OwnedHalfGcdMatrix> {\n    assert_ne!(n, 0);\n    assert!(n <= s);\n    Box::new(\n        exhaustive_quadruples_from_single(exhaustive_vecs_fixed_length_from_single(\n            u64::exact_from(n),\n            exhaustive_unsigneds(),\n        ))\n        .map(move |(mut m00, m01, m10, m11)| {\n            m00.resize(s << 2, 0);\n            m00[s..s + n].copy_from_slice(&m01);\n            m00[s << 1..(s << 1) + n].copy_from_slice(&m10);\n            m00[s * 3..s * 3 + n].copy_from_slice(&m11);\n            half_gcd_matrix_create(s, n, m00)\n        }),\n    )\n}\n\nstruct HalfGcdMatrixGenerator;\n\nimpl ExhaustiveDependentPairsYsGenerator<(usize, usize), OwnedHalfGcdMatrix, It<OwnedHalfGcdMatrix>>\n    for HalfGcdMatrixGenerator\n{\n    #[inline]\n    fn get_ys(&self, t: &(usize, usize)) -> It<OwnedHalfGcdMatrix> {\n        let &(n, s) = t;\n        exhaustive_half_gcd_matrices_with_size(s, n)\n    }\n}\n\nfn exhaustive_half_gcd_matrices() -> It<OwnedHalfGcdMatrix> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_ordered_unique_pairs(exhaustive_positive_primitive_ints()),\n            HalfGcdMatrixGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nstruct HalfGcdMatrixAndVecGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        (usize, usize, usize),\n        (OwnedHalfGcdMatrix, Vec<Limb>, u8),\n        It<(OwnedHalfGcdMatrix, Vec<Limb>, u8)>,\n    > for HalfGcdMatrixAndVecGenerator\n{\n    #[inline]\n    fn get_ys(&self, t: &(usize, usize, usize)) -> It<(OwnedHalfGcdMatrix, Vec<Limb>, u8)> {\n        let &(qs_len, m_n, m_s) = t;\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs(\n                exhaustive_half_gcd_matrices_with_size(m_s, m_n),\n                exhaustive_vecs_fixed_length_from_single(\n                    u64::exact_from(qs_len),\n                    exhaustive_unsigneds(),\n                ),\n            ),\n            0..=1,\n        )))\n    }\n}\n\npub fn exhaustive_large_type_gen_var_5() -> It<(OwnedHalfGcdMatrix, Vec<Limb>, u8)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<usize>()).filter_map(\n                |(x, y, z)| {\n                    let qs_len = x.checked_add(1)?;\n                    let m_n = qs_len.checked_add(y)?;\n                    let m_s_1 = m_n.checked_add(qs_len)?.checked_add(z)?;\n                    let m_s_2 = m_n.checked_add(2)?.checked_add(z)?;\n                    Some((qs_len, m_n, max(m_s_1, m_s_2)))\n                },\n            ),\n            HalfGcdMatrixAndVecGenerator,\n        )\n        .map(|p| p.1),\n    )\n}\n\nfn exhaustive_half_gcd_matrices_1() -> It<HalfGcdMatrix1> {\n    Box::new(\n        exhaustive_quadruples_from_single(exhaustive_unsigneds()).map(|(m00, m01, m10, m11)| {\n            HalfGcdMatrix1 {\n                data: [[m00, m01], [m10, m11]],\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_6() -> It<(HalfGcdMatrix1, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    reshape_1_3_to_4(Box::new(exhaustive_pairs(\n        exhaustive_half_gcd_matrices_1(),\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                |(x, y, z)| {\n                    let xs_len = x;\n                    let ys_len = x.checked_add(1)?.checked_add(y)?;\n                    let out_len = x.checked_add(1)?.checked_add(z)?;\n                    Some((out_len, xs_len, ys_len))\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .map(|p| p.1),\n    )))\n}\n\npub fn exhaustive_large_type_gen_var_7() -> It<(OwnedHalfGcdMatrix, HalfGcdMatrix1)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_half_gcd_matrices(),\n        exhaustive_quadruples_from_single(primitive_int_increasing_range(\n            0,\n            Limb::power_of_2(Limb::WIDTH - 1),\n        ))\n        .map(|(m00, m01, m10, m11)| HalfGcdMatrix1 {\n            data: [[m00, m01], [m10, m11]],\n        }),\n    ))\n}\n\nstruct MatrixMul22Generator;\npub(crate) type T8 = (\n    Vec<Limb>,\n    Vec<Limb>,\n    Vec<Limb>,\n    Vec<Limb>,\n    usize,\n    Vec<Limb>,\n    Vec<Limb>,\n    Vec<Limb>,\n    Vec<Limb>,\n);\n\nimpl ExhaustiveDependentPairsYsGenerator<(u64, u64), T8, It<T8>> for MatrixMul22Generator {\n    #[inline]\n    fn get_ys(&self, p: &(u64, u64)) -> It<T8> {\n        let &(ys_len, xs_len) = p;\n        Box::new(\n            exhaustive_pairs(\n                exhaustive_quadruples_from_single(exhaustive_vecs_fixed_length_from_single(\n                    ys_len + xs_len + 1,\n                    exhaustive_unsigneds(),\n                )),\n                exhaustive_quadruples_from_single(exhaustive_vecs_fixed_length_from_single(\n                    ys_len,\n                    exhaustive_unsigneds(),\n                )),\n            )\n            .map(\n                move |((xs00, xs01, xs10, xs11), (ys00, ys01, ys10, ys11))| {\n                    (\n                        xs00,\n                        xs01,\n                        xs10,\n                        xs11,\n                        usize::exact_from(xs_len),\n                        ys00,\n                        ys01,\n                        ys10,\n                        ys11,\n                    )\n                },\n            ),\n        )\n    }\n}\n\npub fn exhaustive_large_type_gen_var_8() -> It<T8> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::normal(1),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints()),\n            MatrixMul22Generator,\n        )\n        .map(|p| p.1),\n    )\n}\n\n// var 9 is in malachite-base.\n\npub fn exhaustive_large_type_gen_var_10() -> It<(Vec<Limb>, Vec<Limb>, Limb, Limb)> {\n    reshape_2_2_to_4(Box::new(exhaustive_pairs(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_pairs_from_single(exhaustive_positive_primitive_ints())\n                .filter(|(x, y)| x >= y),\n            UnsignedVecPairLenGenerator1,\n        )\n        .map(|p| p.1),\n        exhaustive_pairs(factors_of_limb_max().into_iter(), exhaustive_unsigneds()),\n    )))\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_11() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                    |(q_len, mut n_len, mut d_init_len)| {\n                        n_len = n_len.checked_add(3)?;\n                        d_init_len = d_init_len.checked_add(2)?;\n                        let d_len = d_init_len + 1;\n                        if n_len >= d_len && q_len >= n_len - d_len {\n                            Some((q_len, n_len, d_init_len))\n                        } else {\n                            None\n                        }\n                    },\n                ),\n                UnsignedVecTripleLenGenerator1,\n            )\n            .map(|p| p.1),\n            primitive_int_increasing_inclusive_range(Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX),\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (q, n, d_init, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_12() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_pairs(\n            exhaustive_dependent_pairs(\n                bit_distributor_sequence(\n                    BitDistributorOutputType::tiny(),\n                    BitDistributorOutputType::normal(1),\n                ),\n                exhaustive_triples_from_single(exhaustive_unsigneds::<u64>()).filter_map(\n                    |(mut q_len, mut n_len, mut d_init_len)| {\n                        q_len = q_len.checked_add(3)?;\n                        n_len = n_len.checked_add(9)?;\n                        d_init_len = d_init_len.checked_add(5)?;\n                        let d_len = d_init_len + 1;\n                        if n_len >= d_len + 3 && q_len >= n_len - d_len {\n                            Some((q_len, n_len, d_init_len))\n                        } else {\n                            None\n                        }\n                    },\n                ),\n                UnsignedVecTripleLenGenerator1,\n            )\n            .map(|p| p.1),\n            primitive_int_increasing_inclusive_range(Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX),\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (q, n, d_init, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_13() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_triples_from_single(exhaustive_positive_primitive_ints())\n                .filter(|&(q_len, n_len, d_len)| q_len >= n_len && n_len >= d_len),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n            if d[0].even() {\n                None\n            } else {\n                let inverse = limbs_modular_invert_limb(d[0]).wrapping_neg();\n                Some((q, n, d, inverse))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_14() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(exhaustive_positive_primitive_ints::<u64>()).filter_map(\n                |(mut q_len, mut n_len, d_len)| {\n                    q_len = q_len.checked_add(1)?;\n                    n_len = n_len.checked_add(1)?;\n                    if q_len >= n_len && n_len > d_len {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                },\n            ),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n            if d[0].even() {\n                None\n            } else {\n                let inverse = limbs_modular_invert_limb(d[0]).wrapping_neg();\n                Some((q, n, d, inverse))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_15() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            exhaustive_triples_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter_map(|(mut q_len, mut n_len, d_len)| {\n                    q_len = q_len.checked_add(1)?;\n                    n_len = n_len.checked_add(1)?;\n                    if q_len >= n_len && n_len > d_len {\n                        Some((q_len, n_len, d_len))\n                    } else {\n                        None\n                    }\n                }),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n            if d[0].even() {\n                None\n            } else {\n                let inverse = limbs_modular_invert_limb(d[0]).wrapping_neg();\n                Some((q, n, d, inverse))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_16() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_dependent_pairs(\n            bit_distributor_sequence(\n                BitDistributorOutputType::tiny(),\n                BitDistributorOutputType::normal(1),\n            ),\n            // TODO\n            exhaustive_triples_from_single(primitive_int_increasing_inclusive_range(2, u64::MAX))\n                .filter(|&(q_len, n_len, d_len)| q_len >= n_len && n_len >= d_len),\n            UnsignedVecTripleLenGenerator1,\n        )\n        .filter_map(|(_, (q, n, d)): (_, (Vec<Limb>, Vec<Limb>, Vec<Limb>))| {\n            if d[0].even() {\n                None\n            } else {\n                let inverse = limbs_modular_invert_limb(d[0]).wrapping_neg();\n                Some((q, n, d, inverse))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_17() -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        exhaustive_vecs_min_length(1, exhaustive_unsigneds::<Limb>()).filter_map(|d| {\n            if d[0].even() {\n                None\n            } else {\n                let inverse = limbs_modular_invert_limb(d[0]).wrapping_neg();\n                let is = vec![0; d.len()];\n                let scratch = vec![0; limbs_modular_invert_scratch_len(d.len())];\n                Some((is, scratch, d, inverse))\n            }\n        }),\n    )\n}\n\npub fn exhaustive_large_type_gen_var_18() -> It<(Vec<Limb>, usize, Limb, Limb, u64)> {\n    Box::new(\n        exhaustive_triples(\n            exhaustive_vecs(exhaustive_unsigneds()),\n            exhaustive_unsigneds(),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter_map(|(ns, fraction_len, d)| {\n            if ns.len() <= fraction_len {\n                None\n            } else {\n                let shift = LeadingZeros::leading_zeros(d);\n                let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n                Some((ns, fraction_len, d, d_inv, shift))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_19() -> It<(Vec<Limb>, usize, Vec<Limb>, Limb, Limb, u64)> {\n    Box::new(\n        exhaustive_quadruples_xyxz(\n            exhaustive_vecs(exhaustive_unsigneds()),\n            exhaustive_unsigneds(),\n            exhaustive_positive_primitive_ints(),\n        )\n        .filter_map(|(out, fraction_len, ns, d)| {\n            if ns.is_empty() || out.len() < ns.len() + fraction_len {\n                None\n            } else {\n                let shift = LeadingZeros::leading_zeros(d);\n                let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n                Some((out, fraction_len, ns, d, d_inv, shift))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_20()\n-> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>, usize, usize)> {\n    Box::new(\n        exhaustive_quintuples_xyyyz(\n            exhaustive_vecs_min_length(2, exhaustive_unsigneds()),\n            exhaustive_vecs(exhaustive_unsigneds()),\n            primitive_int_increasing_inclusive_range(3, u32::MAX),\n        )\n        .filter_map(|(ds, mut scratch, mut qs, mut rs_hi, n_len)| {\n            let n_len = usize::wrapping_from(n_len);\n            let d_len = ds.len();\n            if n_len < d_len {\n                return None;\n            }\n            let i_len = limbs_div_mod_barrett_is_len(n_len - d_len, d_len);\n            if i_len == 0 || qs.len() < i_len {\n                return None;\n            }\n            qs.truncate(i_len);\n            if rs_hi.len() < i_len {\n                return None;\n            }\n            rs_hi.truncate(i_len);\n            let scratch_len = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1);\n            let x = limbs_div_mod_barrett_scratch_len(n_len, d_len);\n            if x < i_len {\n                return None;\n            }\n            let actual_scratch_len = x - i_len;\n            if actual_scratch_len < d_len + i_len {\n                return None;\n            }\n            if scratch.len() < actual_scratch_len {\n                return None;\n            }\n            scratch.truncate(actual_scratch_len);\n            Some((scratch, ds, qs, rs_hi, scratch_len, i_len))\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub(crate) fn large_type_filter_map_1(\n    s: (Limb, Limb, Limb, Limb, Limb, Limb),\n) -> Option<(Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb)> {\n    let (x_1, x_0, y_1, y_0, m_1, m_0) = s;\n    if m_1 == 0\n        || m_1 == 1 && m_0 == 0\n        || x_1 > m_1\n        || y_1 > m_1\n        || x_1 == m_1 && x_0 > m_0\n        || y_1 == m_1 && y_0 > m_0\n    {\n        None\n    } else {\n        let (inv_2, inv_1, inv_0) = limbs_precompute_mod_mul_two_limbs(m_1, m_0);\n        Some((x_1, x_0, y_1, y_0, m_1, m_0, inv_2, inv_1, inv_0))\n    }\n}\n\n#[allow(clippy::type_complexity)]\npub fn exhaustive_large_type_gen_var_21()\n-> It<(Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Box::new(\n        exhaustive_sextuples_from_single(exhaustive_unsigneds())\n            .filter_map(large_type_filter_map_1),\n    )\n}\n\n// var 22 is in malachite-base.\n\nstruct RationalFromPowerOf2DigitsGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        u64,\n        (Vec<Natural>, RationalSequence<Natural>),\n        It<(Vec<Natural>, RationalSequence<Natural>)>,\n    > for RationalFromPowerOf2DigitsGenerator\n{\n    #[inline]\n    fn get_ys(&self, log_base: &u64) -> It<(Vec<Natural>, RationalSequence<Natural>)> {\n        Box::new(exhaustive_pairs(\n            exhaustive_vecs(exhaustive_natural_range(\n                Natural::ZERO,\n                Natural::power_of_2(*log_base),\n            )),\n            exhaustive_rational_sequences(exhaustive_natural_range(\n                Natural::ZERO,\n                Natural::power_of_2(*log_base),\n            )),\n        ))\n    }\n}\n\npub fn exhaustive_large_type_gen_var_23() -> It<(u64, Vec<Natural>, RationalSequence<Natural>)> {\n    reshape_1_2_to_3(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_positive_primitive_ints(),\n        RationalFromPowerOf2DigitsGenerator,\n    )))\n}\n\npub fn exhaustive_large_type_gen_var_24() -> It<(Vec<Natural>, RationalSequence<Natural>)> {\n    RationalFromPowerOf2DigitsGenerator.get_ys(&1)\n}\n\nstruct RationalFromDigitsGenerator;\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Natural,\n        (Vec<Natural>, RationalSequence<Natural>),\n        It<(Vec<Natural>, RationalSequence<Natural>)>,\n    > for RationalFromDigitsGenerator\n{\n    #[inline]\n    fn get_ys(&self, base: &Natural) -> It<(Vec<Natural>, RationalSequence<Natural>)> {\n        Box::new(exhaustive_pairs(\n            exhaustive_vecs(exhaustive_natural_range(Natural::ZERO, base.clone())),\n            exhaustive_rational_sequences(exhaustive_natural_range(Natural::ZERO, base.clone())),\n        ))\n    }\n}\n\npub fn exhaustive_large_type_gen_var_25() -> It<(Natural, Vec<Natural>, RationalSequence<Natural>)>\n{\n    reshape_1_2_to_3(Box::new(exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n        RationalFromDigitsGenerator,\n    )))\n}\n\npub fn exhaustive_large_type_gen_var_26() -> It<(Vec<Natural>, RationalSequence<Natural>)> {\n    RationalFromDigitsGenerator.get_ys(&Natural::from(10u32))\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/generators/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::factorial::FAC_DSC_THRESHOLD;\nuse crate::natural::arithmetic::gcd::half_gcd::HalfGcdMatrix1;\nuse crate::platform::{Limb, ODD_DOUBLEFACTORIAL_TABLE_LIMIT};\nuse crate::test_util::generators::common::{\n    integer_integer_natural_triple_rm, integer_integer_triple_1_2_rm, integer_natural_pair_rm,\n    integer_nrm, integer_pair_1_nrm, integer_pair_1_rm, integer_pair_nm, integer_pair_nrm,\n    integer_pair_rm, integer_rm, integer_triple_1_rm, integer_vec_nrm,\n    natural_natural_triple_1_2_rm, natural_nrm, natural_pair_1_nm, natural_pair_1_nrm,\n    natural_pair_1_rm, natural_pair_nm, natural_pair_nrm, natural_pair_rm, natural_rm,\n    natural_triple_1_rm, natural_triple_nrm, natural_triple_rm, natural_vec_nrm,\n};\nuse crate::test_util::generators::exhaustive::*;\nuse crate::test_util::generators::random::*;\nuse crate::test_util::generators::special_random::*;\nuse crate::test_util::natural::arithmetic::gcd::OwnedHalfGcdMatrix;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_base::test_util::generators::common::Generator;\nuse malachite_base::vecs::exhaustive::lex_ordered_unique_vecs;\nuse num::{BigInt, BigUint};\nuse std::ops::{Shl, Shr};\n\n// -- Integer --\n\npub fn integer_gen() -> Generator<Integer> {\n    Generator::new(\n        &exhaustive_integer_gen,\n        &random_integer_gen,\n        &special_random_integer_gen,\n    )\n}\n\npub fn integer_gen_rm() -> Generator<(rug::Integer, Integer)> {\n    Generator::new(\n        &|| integer_rm(exhaustive_integer_gen()),\n        &|config| integer_rm(random_integer_gen(config)),\n        &|config| integer_rm(special_random_integer_gen(config)),\n    )\n}\n\npub fn integer_gen_nrm() -> Generator<(BigInt, rug::Integer, Integer)> {\n    Generator::new(\n        &|| integer_nrm(exhaustive_integer_gen()),\n        &|config| integer_nrm(random_integer_gen(config)),\n        &|config| integer_nrm(special_random_integer_gen(config)),\n    )\n}\n\n// All `Integer`s that are exactly equal to a floating point value of type `T`.\npub fn integer_gen_var_1<T: PrimitiveFloat>() -> Generator<Integer>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Generator::new(\n        &exhaustive_integer_gen_var_1::<T>,\n        &random_integer_gen_var_1::<T>,\n        &special_random_integer_gen_var_1::<T>,\n    )\n}\n\n// All `Integer`s that are not equal to any floating point value of type `T`.\npub fn integer_gen_var_2<T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat>()\n-> Generator<Integer> {\n    Generator::new(\n        &exhaustive_integer_gen_var_2::<T>,\n        &random_integer_gen_var_2::<T>,\n        &special_random_integer_gen_var_8::<T>,\n    )\n}\n\n// All `Integer`s that are exactly between two adjacent floats of type `T`.\npub fn integer_gen_var_3<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>() -> Generator<Integer>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Generator::new(\n        &exhaustive_integer_gen_var_3::<T>,\n        &random_integer_gen_var_3::<T>,\n        &special_random_integer_gen_var_2::<T>,\n    )\n}\n\n// All `Integer`s that are natural (non-negative).\npub fn integer_gen_var_4() -> Generator<Integer> {\n    Generator::new(\n        &exhaustive_integer_gen_var_4,\n        &random_integer_gen_var_4,\n        &special_random_integer_gen_var_3,\n    )\n}\n\npub fn integer_gen_var_4_rm() -> Generator<(rug::Integer, Integer)> {\n    Generator::new(\n        &|| integer_rm(exhaustive_integer_gen_var_4()),\n        &|config| integer_rm(random_integer_gen_var_4(config)),\n        &|config| integer_rm(special_random_integer_gen_var_3(config)),\n    )\n}\n\npub fn integer_gen_var_4_nrm() -> Generator<(BigInt, rug::Integer, Integer)> {\n    Generator::new(\n        &|| integer_nrm(exhaustive_integer_gen_var_4()),\n        &|config| integer_nrm(random_integer_gen_var_4(config)),\n        &|config| integer_nrm(special_random_integer_gen_var_3(config)),\n    )\n}\n\n// All `Integer`s that are exactly equal to an unsigned value of type `T`.\npub fn integer_gen_var_5<T: PrimitiveUnsigned>() -> Generator<Integer>\nwhere\n    Integer: From<T>,\n{\n    Generator::new(\n        &exhaustive_integer_gen_var_5::<T>,\n        &random_integer_gen_var_5::<T>,\n        &special_random_integer_gen_var_4::<T>,\n    )\n}\n\n// All `Integer`s that are exactly equal to a signed value of type `T`.\npub fn integer_gen_var_6<T: PrimitiveSigned>() -> Generator<Integer>\nwhere\n    Integer: From<T>,\n{\n    Generator::new(\n        &exhaustive_integer_gen_var_6::<T>,\n        &random_integer_gen_var_5::<T>,\n        &special_random_integer_gen_var_5::<T>,\n    )\n}\n\n// All `Integer`s that are negative.\npub fn integer_gen_var_7() -> Generator<Integer> {\n    Generator::new(\n        &exhaustive_integer_gen_var_7,\n        &random_integer_gen_var_6,\n        &special_random_integer_gen_var_6,\n    )\n}\n\n// All `Integer`s that are nonzero.\npub fn integer_gen_var_8() -> Generator<Integer> {\n    Generator::new(\n        &exhaustive_integer_gen_var_8,\n        &random_integer_gen_var_7,\n        &special_random_integer_gen_var_7,\n    )\n}\n\n// All odd positive `Integer`s.\npub fn integer_gen_var_9() -> Generator<Integer> {\n    Generator::new(\n        &exhaustive_integer_gen_var_9,\n        &random_integer_gen_var_8,\n        &special_random_integer_gen_var_9,\n    )\n}\n\n// -- (Integer, Integer) --\n\npub fn integer_pair_gen() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen,\n        &random_integer_pair_gen,\n        &special_random_integer_pair_gen,\n    )\n}\n\npub fn integer_pair_gen_rm() -> Generator<((rug::Integer, rug::Integer), (Integer, Integer))> {\n    Generator::new(\n        &|| integer_pair_rm(exhaustive_integer_pair_gen()),\n        &|config| integer_pair_rm(random_integer_pair_gen(config)),\n        &|config| integer_pair_rm(special_random_integer_pair_gen(config)),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_pair_gen_nrm() -> Generator<(\n    (BigInt, BigInt),\n    (rug::Integer, rug::Integer),\n    (Integer, Integer),\n)> {\n    Generator::new(\n        &|| integer_pair_nrm(exhaustive_integer_pair_gen()),\n        &|config| integer_pair_nrm(random_integer_pair_gen(config)),\n        &|config| integer_pair_nrm(special_random_integer_pair_gen(config)),\n    )\n}\n\npub fn integer_pair_gen_nm() -> Generator<((BigInt, BigInt), (Integer, Integer))> {\n    Generator::new(\n        &|| integer_pair_nm(exhaustive_integer_pair_gen()),\n        &|config| integer_pair_nm(random_integer_pair_gen(config)),\n        &|config| integer_pair_nm(special_random_integer_pair_gen(config)),\n    )\n}\n\n// All pairs of `Integer`s where the second `Integer` is nonzero.\npub fn integer_pair_gen_var_1() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen_var_1,\n        &random_integer_pair_gen_var_1,\n        &special_random_integer_pair_gen_var_1,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_pair_gen_var_1_nrm() -> Generator<(\n    (BigInt, BigInt),\n    (rug::Integer, rug::Integer),\n    (Integer, Integer),\n)> {\n    Generator::new(\n        &|| integer_pair_nrm(exhaustive_integer_pair_gen_var_1()),\n        &|config| integer_pair_nrm(random_integer_pair_gen_var_1(config)),\n        &|config| integer_pair_nrm(special_random_integer_pair_gen_var_1(config)),\n    )\n}\n\npub fn integer_pair_gen_var_1_rm() -> Generator<((rug::Integer, rug::Integer), (Integer, Integer))>\n{\n    Generator::new(\n        &|| integer_pair_rm(exhaustive_integer_pair_gen_var_1()),\n        &|config| integer_pair_rm(random_integer_pair_gen_var_1(config)),\n        &|config| integer_pair_rm(special_random_integer_pair_gen_var_1(config)),\n    )\n}\n\n// All pairs of `Integer`s where the first `Integer` is divisible by the second, and the second is\n// nonzero.\npub fn integer_pair_gen_var_2() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen_var_2,\n        &random_integer_pair_gen_var_2,\n        &special_random_integer_pair_gen_var_2,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_pair_gen_var_2_nrm() -> Generator<(\n    (BigInt, BigInt),\n    (rug::Integer, rug::Integer),\n    (Integer, Integer),\n)> {\n    Generator::new(\n        &|| integer_pair_nrm(exhaustive_integer_pair_gen_var_2()),\n        &|config| integer_pair_nrm(random_integer_pair_gen_var_2(config)),\n        &|config| integer_pair_nrm(special_random_integer_pair_gen_var_2(config)),\n    )\n}\n\n// All pairs of `Integer`s where the first `Integer` is not divisible by the second, and the second\n// is nonzero.\npub fn integer_pair_gen_var_3() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen_var_3,\n        &random_integer_pair_gen_var_3,\n        &special_random_integer_pair_gen_var_3,\n    )\n}\n\n// All pairs of `Integer`s where the second `Integer` is positive and odd.\npub fn integer_pair_gen_var_4() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen_var_4,\n        &random_integer_pair_gen_var_4,\n        &special_random_integer_pair_gen_var_4,\n    )\n}\n\npub fn integer_pair_gen_var_4_rm() -> Generator<((rug::Integer, rug::Integer), (Integer, Integer))>\n{\n    Generator::new(\n        &|| integer_pair_rm(exhaustive_integer_pair_gen_var_4()),\n        &|config| integer_pair_rm(random_integer_pair_gen_var_4(config)),\n        &|config| integer_pair_rm(special_random_integer_pair_gen_var_4(config)),\n    )\n}\n\n// All coprime pairs of `Integer`s.\npub fn integer_pair_gen_var_5() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen_var_5,\n        &random_integer_pair_gen_var_5,\n        &special_random_integer_pair_gen_var_5,\n    )\n}\n\n// All coprime pairs of odd positive `Integer`s.\npub fn integer_pair_gen_var_6() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen_var_6,\n        &random_integer_pair_gen_var_6,\n        &special_random_integer_pair_gen_var_6,\n    )\n}\n\n// All pairs of `Integer`s where the second `Integer` is small and non-negative.\npub fn integer_pair_gen_var_7() -> Generator<(Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_pair_gen_var_7,\n        &random_integer_pair_gen_var_7,\n        &special_random_integer_pair_gen_var_7,\n    )\n}\n\npub fn integer_pair_gen_var_7_rm() -> Generator<((rug::Integer, u32), (Integer, Integer))> {\n    Generator::new(\n        &|| {\n            Box::new(\n                exhaustive_integer_pair_gen_var_7()\n                    .map(|(x, y)| ((rug::Integer::from(&x), u32::exact_from(&y)), (x, y))),\n            )\n        },\n        &|config| {\n            Box::new(\n                random_integer_pair_gen_var_7(config)\n                    .map(|(x, y)| ((rug::Integer::from(&x), u32::exact_from(&y)), (x, y))),\n            )\n        },\n        &|config| {\n            Box::new(\n                special_random_integer_pair_gen_var_7(config)\n                    .map(|(x, y)| ((rug::Integer::from(&x), u32::exact_from(&y)), (x, y))),\n            )\n        },\n    )\n}\n\n// -- (Integer, Integer, Integer) --\n\npub fn integer_triple_gen() -> Generator<(Integer, Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_triple_gen,\n        &random_integer_triple_gen,\n        &special_random_integer_triple_gen,\n    )\n}\n\n// All triples of natural (non-negative) `Integer`s.\npub fn integer_triple_gen_var_1() -> Generator<(Integer, Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_triple_gen_var_1,\n        &random_integer_triple_gen_var_1,\n        &special_random_integer_triple_gen_var_1,\n    )\n}\n\n// All triples of `Integer`s where the third `Integer` is positive and odd.\npub fn integer_triple_gen_var_2() -> Generator<(Integer, Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_triple_gen_var_2,\n        &random_integer_triple_gen_var_2,\n        &special_random_integer_triple_gen_var_2,\n    )\n}\n\n// All triples of `Integer`s where the second and third `Integer`s are positive and odd.\npub fn integer_triple_gen_var_3() -> Generator<(Integer, Integer, Integer)> {\n    Generator::new(\n        &exhaustive_integer_triple_gen_var_3,\n        &random_integer_triple_gen_var_3,\n        &special_random_integer_triple_gen_var_3,\n    )\n}\n\n// -- (Integer, Integer, Integer, PrimitiveUnsigned) --\n\n// All `(Integer, Integer, Integer, T)` where `T` is unsigned and small.\npub fn integer_integer_integer_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Integer, Integer, Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_integer_integer_unsigned_quadruple_gen_var_1,\n        &random_integer_integer_integer_unsigned_quadruple_gen_var_1,\n        &special_random_integer_integer_integer_unsigned_quadruple_gen_var_1,\n    )\n}\n\n// -- (Integer, Integer, Natural) --\n\npub fn integer_integer_natural_triple_gen() -> Generator<(Integer, Integer, Natural)> {\n    Generator::new(\n        &exhaustive_integer_integer_natural_triple_gen,\n        &random_integer_integer_natural_triple_gen,\n        &special_random_integer_integer_natural_triple_gen,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_integer_natural_triple_gen_rm() -> Generator<(\n    (rug::Integer, rug::Integer, rug::Integer),\n    (Integer, Integer, Natural),\n)> {\n    Generator::new(\n        &|| integer_integer_natural_triple_rm(exhaustive_integer_integer_natural_triple_gen()),\n        &|config| {\n            integer_integer_natural_triple_rm(random_integer_integer_natural_triple_gen(config))\n        },\n        &|config| {\n            integer_integer_natural_triple_rm(special_random_integer_integer_natural_triple_gen(\n                config,\n            ))\n        },\n    )\n}\n\n// All `(Integer, Integer, Natural)` triples where the first `Integer` is equal to the second mod\n// the `Natural`.\npub fn integer_integer_natural_triple_gen_var_1() -> Generator<(Integer, Integer, Natural)> {\n    Generator::new(\n        &exhaustive_integer_integer_natural_triple_gen_var_1,\n        &random_integer_integer_natural_triple_gen_var_1,\n        &special_random_integer_integer_natural_triple_gen_var_1,\n    )\n}\n\n// All `(Integer, Integer, Natural)` triples where the first `Integer` is not equal to the second\n// mod the `Natural`.\npub fn integer_integer_natural_triple_gen_var_2() -> Generator<(Integer, Integer, Natural)> {\n    Generator::new(\n        &exhaustive_integer_integer_natural_triple_gen_var_2,\n        &random_integer_integer_natural_triple_gen_var_2,\n        &special_random_integer_integer_natural_triple_gen_var_2,\n    )\n}\n\n// -- (Integer, Integer, PrimitiveFloat) --\n\npub fn integer_integer_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> Generator<(Integer, Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_integer_primitive_float_triple_gen,\n        &random_integer_integer_primitive_float_triple_gen,\n        &special_random_integer_integer_primitive_float_triple_gen,\n    )\n}\n\n// -- (Integer, Integer, PrimitiveSigned) --\n\npub fn integer_integer_signed_triple_gen<T: PrimitiveSigned>() -> Generator<(Integer, Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_integer_signed_triple_gen,\n        &random_integer_integer_primitive_int_triple_gen,\n        &special_random_integer_integer_signed_triple_gen,\n    )\n}\n\n// -- (Integer, Integer, PrimitiveUnsigned) --\n\npub fn integer_integer_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> Generator<(Integer, Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_integer_unsigned_triple_gen,\n        &random_integer_integer_primitive_int_triple_gen,\n        &special_random_integer_integer_unsigned_triple_gen,\n    )\n}\n\n// All `(Integer, Integer, T)` where `T` is unsigned and small.\npub fn integer_integer_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Integer, Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_integer_unsigned_triple_gen_var_1,\n        &random_integer_integer_unsigned_triple_gen_var_1,\n        &special_random_integer_integer_unsigned_triple_gen_var_1,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_integer_unsigned_triple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, rug::Integer, T), (Integer, Integer, T))> {\n    Generator::new(\n        &|| integer_integer_triple_1_2_rm(exhaustive_integer_integer_unsigned_triple_gen_var_1()),\n        &|config| {\n            integer_integer_triple_1_2_rm(random_integer_integer_unsigned_triple_gen_var_1(config))\n        },\n        &|config| {\n            integer_integer_triple_1_2_rm(special_random_integer_integer_unsigned_triple_gen_var_1(\n                config,\n            ))\n        },\n    )\n}\n\n// All `(Integer, Integer, T)` where `T` is unsigned and small, and the `Integer`s are equal mod 2\n// to the power of the `T`.\npub fn integer_integer_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Integer, Integer, T)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Generator::new(\n        &exhaustive_integer_integer_unsigned_triple_gen_var_2,\n        &random_integer_integer_unsigned_triple_gen_var_2,\n        &special_random_integer_integer_unsigned_triple_gen_var_2,\n    )\n}\n\n// All `(Integer, Integer, T)` where `T` is unsigned and small, and the `Integer`s are not equal mod\n// 2 to the power of the `T`.\npub fn integer_integer_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> Generator<(Integer, Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_integer_unsigned_triple_gen_var_3,\n        &random_integer_integer_unsigned_triple_gen_var_3,\n        &special_random_integer_integer_unsigned_triple_gen_var_3,\n    )\n}\n\n// -- (Integer, Integer, RoundingMode) --\n\n// All `(Integer, Integer, RoundingMode)` triples where the second `Integer` is positive and if the\n// `RoundingMode` is `Exact`, the first `Integer` is divisible by the second.\npub fn integer_integer_rounding_mode_triple_gen_var_1()\n-> Generator<(Integer, Integer, RoundingMode)> {\n    Generator::new(\n        &exhaustive_integer_integer_rounding_mode_triple_gen_var_1,\n        &random_integer_integer_rounding_mode_triple_gen_var_1,\n        &special_random_integer_integer_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Integer, Integer, RoundingMode)` triples that are a valid input to\n// `Integer::round_to_multiple`.\npub fn integer_integer_rounding_mode_triple_gen_var_2()\n-> Generator<(Integer, Integer, RoundingMode)> {\n    Generator::new(\n        &exhaustive_integer_integer_rounding_mode_triple_gen_var_2,\n        &random_integer_integer_rounding_mode_triple_gen_var_2,\n        &special_random_integer_integer_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// -- (Integer, Natural) --\n\npub fn integer_natural_pair_gen() -> Generator<(Integer, Natural)> {\n    Generator::new(\n        &exhaustive_integer_natural_pair_gen,\n        &random_integer_natural_pair_gen,\n        &special_random_integer_natural_pair_gen,\n    )\n}\n\ntype T1 = Generator<((rug::Integer, rug::Integer), (Integer, Natural))>;\npub fn integer_natural_pair_gen_rm() -> T1 {\n    Generator::new(\n        &|| integer_natural_pair_rm(exhaustive_integer_natural_pair_gen()),\n        &|config| integer_natural_pair_rm(random_integer_natural_pair_gen(config)),\n        &|config| integer_natural_pair_rm(special_random_integer_natural_pair_gen(config)),\n    )\n}\n\n// -- (Integer, Natural, Natural) --\n\npub fn integer_natural_natural_triple_gen() -> Generator<(Integer, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_integer_natural_natural_triple_gen,\n        &random_integer_natural_natural_triple_gen,\n        &special_random_integer_natural_natural_triple_gen,\n    )\n}\n\n// -- (Integer, PrimitiveFloat) --\n\npub fn integer_primitive_float_pair_gen<T: PrimitiveFloat>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_primitive_float_pair_gen,\n        &random_integer_primitive_float_pair_gen,\n        &special_random_integer_primitive_float_pair_gen,\n    )\n}\n\npub fn integer_primitive_float_pair_gen_rm<T: PrimitiveFloat>()\n-> Generator<((rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_rm(exhaustive_integer_primitive_float_pair_gen()),\n        &|config| integer_pair_1_rm(random_integer_primitive_float_pair_gen(config)),\n        &|config| integer_pair_1_rm(special_random_integer_primitive_float_pair_gen(config)),\n    )\n}\n\n// -- (Integer, PrimitiveFloat, PrimitiveFloat) --\n\npub fn integer_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> Generator<(Integer, T, T)> {\n    Generator::new(\n        &exhaustive_integer_primitive_float_primitive_float_triple_gen,\n        &random_integer_primitive_float_primitive_float_triple_gen,\n        &special_random_integer_primitive_float_primitive_float_triple_gen,\n    )\n}\n\n// -- (Integer, PrimitiveSigned) --\n\npub fn integer_signed_pair_gen<T: PrimitiveSigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_signed_pair_gen,\n        &random_integer_primitive_int_pair_gen,\n        &special_random_integer_signed_pair_gen,\n    )\n}\n\npub fn integer_signed_pair_gen_rm<T: PrimitiveSigned>()\n-> Generator<((rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_rm(exhaustive_integer_signed_pair_gen()),\n        &|config| integer_pair_1_rm(random_integer_primitive_int_pair_gen(config)),\n        &|config| integer_pair_1_rm(special_random_integer_signed_pair_gen(config)),\n    )\n}\n\n// All `(Integer, T)` where `T` is signed and small.\npub fn integer_signed_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_signed_pair_gen_var_1,\n        &random_integer_signed_pair_gen_var_1,\n        &special_random_integer_signed_pair_gen_var_1,\n    )\n}\n\npub fn integer_signed_pair_gen_var_1_rm<T: PrimitiveSigned>()\n-> Generator<((rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_rm(exhaustive_integer_signed_pair_gen_var_1()),\n        &|config| integer_pair_1_rm(random_integer_signed_pair_gen_var_1(config)),\n        &|config| integer_pair_1_rm(special_random_integer_signed_pair_gen_var_1(config)),\n    )\n}\n\n// -- (Integer, PrimitiveSigned, PrimitiveSigned) --\n\npub fn integer_signed_signed_triple_gen<T: PrimitiveSigned>() -> Generator<(Integer, T, T)> {\n    Generator::new(\n        &exhaustive_integer_signed_signed_triple_gen,\n        &random_integer_primitive_int_primitive_int_triple_gen,\n        &special_random_integer_signed_signed_triple_gen,\n    )\n}\n\n// -- (Integer, PrimitiveSigned, PrimitiveUnsigned) --\n\n// All `(Integer, T, U)` where `T` is signed and small and `U` is unsigned, small, and positive.\npub fn integer_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(Integer, T, U)> {\n    Generator::new(\n        &exhaustive_integer_signed_unsigned_triple_gen_var_1,\n        &random_integer_signed_unsigned_triple_gen_var_1,\n        &special_random_integer_signed_unsigned_triple_gen_var_1,\n    )\n}\n\n// -- (Integer, PrimitiveSigned, RoundingMode) --\n\n// All `(Integer, T, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `Integer::shl_round`.\npub fn integer_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shr<T, Output = Integer>,\n{\n    Generator::new(\n        &exhaustive_integer_signed_rounding_mode_triple_gen_var_1,\n        &random_integer_signed_rounding_mode_triple_gen_var_1,\n        &special_random_integer_signed_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Integer, T, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `Integer::shr_round`.\npub fn integer_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>()\n-> Generator<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Generator::new(\n        &exhaustive_integer_signed_rounding_mode_triple_gen_var_2,\n        &random_integer_signed_rounding_mode_triple_gen_var_2,\n        &special_random_integer_signed_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned) --\n\npub fn integer_unsigned_pair_gen<T: PrimitiveUnsigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_pair_gen,\n        &random_integer_primitive_int_pair_gen,\n        &special_random_integer_unsigned_pair_gen,\n    )\n}\n\npub fn integer_unsigned_pair_gen_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_rm(exhaustive_integer_unsigned_pair_gen()),\n        &|config| integer_pair_1_rm(random_integer_primitive_int_pair_gen(config)),\n        &|config| integer_pair_1_rm(special_random_integer_unsigned_pair_gen(config)),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_unsigned_pair_gen_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigInt, T), (rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_nrm(exhaustive_integer_unsigned_pair_gen()),\n        &|config| integer_pair_1_nrm(random_integer_primitive_int_pair_gen(config)),\n        &|config| integer_pair_1_nrm(special_random_integer_unsigned_pair_gen(config)),\n    )\n}\n\n// All `(Integer, T)` where `T` is unsigned and between 2 and 36, inclusive.\npub fn integer_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_pair_gen_var_1,\n        &random_integer_unsigned_pair_gen_var_1,\n        &special_random_integer_unsigned_pair_gen_var_1,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_unsigned_pair_gen_var_1_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigInt, T), (rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_nrm(exhaustive_integer_unsigned_pair_gen_var_1()),\n        &|config| integer_pair_1_nrm(random_integer_unsigned_pair_gen_var_1(config)),\n        &|config| integer_pair_1_nrm(special_random_integer_unsigned_pair_gen_var_1(config)),\n    )\n}\n\n// All `(Integer, T)` where `T` is unsigned and small.\npub fn integer_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_pair_gen_var_2,\n        &random_integer_unsigned_pair_gen_var_2,\n        &special_random_integer_unsigned_pair_gen_var_2,\n    )\n}\n\npub fn integer_unsigned_pair_gen_var_2_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_rm(exhaustive_integer_unsigned_pair_gen_var_2()),\n        &|config| integer_pair_1_rm(random_integer_unsigned_pair_gen_var_2(config)),\n        &|config| integer_pair_1_rm(special_random_integer_unsigned_pair_gen_var_2(config)),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_unsigned_pair_gen_var_2_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigInt, T), (rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_nrm(exhaustive_integer_unsigned_pair_gen_var_2()),\n        &|config| integer_pair_1_nrm(random_integer_unsigned_pair_gen_var_2(config)),\n        &|config| integer_pair_1_nrm(special_random_integer_unsigned_pair_gen_var_2(config)),\n    )\n}\n\n// All `(Integer, T)` where `T` is unsigned, small, and positive, and either the `Integer` is\n// non-negative or the `T` is odd.\npub fn integer_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_pair_gen_var_3,\n        &random_integer_unsigned_pair_gen_var_3,\n        &special_random_integer_unsigned_pair_gen_var_3,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_unsigned_pair_gen_var_3_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigInt, T), (rug::Integer, T), (Integer, T))> {\n    Generator::new(\n        &|| integer_pair_1_nrm(exhaustive_integer_unsigned_pair_gen_var_3()),\n        &|config| integer_pair_1_nrm(random_integer_unsigned_pair_gen_var_3(config)),\n        &|config| integer_pair_1_nrm(special_random_integer_unsigned_pair_gen_var_3(config)),\n    )\n}\n\n// All `(Integer, u64)`s where the `T` is unsigned and small, and the `Integer` is divisible by 2 to\n// the power of the `T`.\npub fn integer_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_pair_gen_var_4,\n        &random_integer_unsigned_pair_gen_var_4,\n        &special_random_integer_unsigned_pair_gen_var_4,\n    )\n}\n\n// All `(Integer, u64)`s where the `T` is unsigned and small, and the `Integer` is not divisible by\n// 2 to the power of the `T`.\npub fn integer_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_pair_gen_var_5,\n        &random_integer_unsigned_pair_gen_var_5,\n        &special_random_integer_unsigned_pair_gen_var_5,\n    )\n}\n\n// All `(Integer, T)` where `T` is unsigned, positive, and small.\npub fn integer_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> Generator<(Integer, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_pair_gen_var_6,\n        &random_integer_unsigned_pair_gen_var_6,\n        &special_random_integer_unsigned_pair_gen_var_6,\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, bool) --\n\n// All `(Integer, T, bool)` where `T` is unsigned and small.\npub fn integer_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Integer, T, bool)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_bool_triple_gen_var_1,\n        &random_integer_unsigned_bool_triple_gen_var_1,\n        &special_random_integer_unsigned_bool_triple_gen_var_1,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn integer_unsigned_bool_triple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, T, bool), (Integer, T, bool))> {\n    Generator::new(\n        &|| integer_triple_1_rm(exhaustive_integer_unsigned_bool_triple_gen_var_1()),\n        &|config| integer_triple_1_rm(random_integer_unsigned_bool_triple_gen_var_1(config)),\n        &|config| {\n            integer_triple_1_rm(special_random_integer_unsigned_bool_triple_gen_var_1(\n                config,\n            ))\n        },\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, Natural) --\n\npub fn integer_unsigned_natural_triple_gen<T: PrimitiveUnsigned>()\n-> Generator<(Integer, T, Natural)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_natural_triple_gen,\n        &random_integer_primitive_int_natural_triple_gen,\n        &special_random_integer_unsigned_natural_triple_gen,\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn integer_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> Generator<(Integer, T, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_unsigned_triple_gen,\n        &random_integer_primitive_int_primitive_int_triple_gen,\n        &special_random_integer_unsigned_unsigned_triple_gen,\n    )\n}\n\n// All `(Integer, T, U)` where `T` and `U` are unsigned, the `T` is between 2 and 36, inclusive, and\n// the `U` is small.\npub fn integer_unsigned_unsigned_triple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Integer, T, U)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_unsigned_triple_gen_var_1,\n        &random_integer_unsigned_unsigned_triple_gen_var_1,\n        &special_random_integer_unsigned_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(Integer, T, T)` where `T` is unsigned, both `T`s are small, and the first `T` is less than\n// or equal to the second.\npub fn integer_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Integer, T, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_unsigned_triple_gen_var_2,\n        &random_integer_unsigned_unsigned_triple_gen_var_2,\n        &special_random_integer_unsigned_unsigned_triple_gen_var_2,\n    )\n}\n\n// All `(Integer, T, T)` where `T` is unsigned and both `T`s are small.\npub fn integer_unsigned_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> Generator<(Integer, T, T)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_unsigned_triple_gen_var_3,\n        &random_integer_unsigned_unsigned_triple_gen_var_3,\n        &special_random_integer_unsigned_unsigned_triple_gen_var_3,\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\n// All `(Integer, T, T, Natural)` where `T` is unsigned and the first `T` is smaller than the\n// second.\npub fn integer_unsigned_unsigned_natural_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Integer, T, T, Natural)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_unsigned_natural_quadruple_gen_var_1,\n        &random_integer_unsigned_unsigned_natural_triple_gen_var_1,\n        &special_random_integer_unsigned_unsigned_natural_quadruple_gen_var_1,\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Integer, u64, RoundingMode)` where the triple is a valid input to\n// `Integer::round_to_multiple_of_power_of_2`.\npub fn integer_unsigned_rounding_mode_triple_gen_var_1() -> Generator<(Integer, u64, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_integer_unsigned_rounding_mode_triple_gen_var_1,\n        &random_integer_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_integer_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Integer, T, RoundingMode)` where `T` is unsigned and the triple is a valid input to\n// `Integer::shr_round`.\npub fn integer_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Generator::new(\n        &exhaustive_integer_unsigned_rounding_mode_triple_gen_var_2,\n        &random_integer_unsigned_rounding_mode_triple_gen_var_2,\n        &special_random_integer_unsigned_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// vars 3 and 4 are in malachite-float\n\n// All `(Integer, T, RoundingMode)` where the `T` is small and unsigned.\npub fn integer_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> Generator<(Integer, T, RoundingMode)> {\n    Generator::new(\n        &exhaustive_integer_unsigned_rounding_mode_triple_gen_var_5,\n        &random_integer_unsigned_rounding_mode_triple_gen_var_5,\n        &special_random_integer_unsigned_rounding_mode_triple_gen_var_5,\n    )\n}\n\n// -- (Integer, RoundingMode) --\n\npub fn integer_rounding_mode_pair_gen() -> Generator<(Integer, RoundingMode)> {\n    Generator::new(\n        &exhaustive_integer_rounding_mode_pair_gen,\n        &random_integer_rounding_mode_pair_gen,\n        &special_random_integer_rounding_mode_pair_gen,\n    )\n}\n\n// All `(Integer, RoundingMode)` pairs that are valid inputs to `T::rounding_from`.\npub fn integer_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat,\n>() -> Generator<(Integer, RoundingMode)> {\n    Generator::new(\n        &exhaustive_integer_rounding_mode_pair_gen_var_1::<T>,\n        &random_integer_rounding_mode_pair_gen_var_1::<T>,\n        &special_random_integer_rounding_mode_pair_gen_var_1::<T>,\n    )\n}\n\n// All `(Integer, RoundingMode)` pairs where the `Integer` is nonzero.\npub fn integer_rounding_mode_pair_gen_var_2() -> Generator<(Integer, RoundingMode)> {\n    Generator::new(\n        &exhaustive_integer_rounding_mode_pair_gen_var_2,\n        &random_integer_rounding_mode_pair_gen_var_2,\n        &special_random_integer_rounding_mode_pair_gen_var_2,\n    )\n}\n\n// -- (Integer, ToSciOptions) --\n\npub fn integer_to_sci_options_pair_gen() -> Generator<(Integer, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_integer_to_sci_options_pair_gen,\n        &random_integer_to_sci_options_pair_gen,\n        &special_random_integer_to_sci_options_pair_gen,\n    )\n}\n\n// All `(Integer, ToSciOptions)` pairs where the `Integer` can be formatted using the options.\npub fn integer_to_sci_options_pair_gen_var_1() -> Generator<(Integer, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_integer_to_sci_options_pair_gen_var_1,\n        &random_integer_to_sci_options_pair_gen_var_1,\n        &special_random_integer_to_sci_options_pair_gen_var_1,\n    )\n}\n\n// -- (Integer, Vec<bool>) --\n\n// All `(Integer, Vec<bool>)` pairs where the length of the `Vec` is the twos' complement limb count\n// of the `Integer`, including sign extension limbs if necessary.\npub fn integer_bool_vec_pair_gen_var_1() -> Generator<(Integer, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_integer_bool_vec_pair_gen_var_1,\n        &random_integer_bool_vec_pair_gen_var_1,\n        &special_random_integer_bool_vec_pair_gen_var_1,\n    )\n}\n\n// All `(Integer, Vec<bool>)` pairs where the length of the `Vec` is the twos' complement bit count\n// of the `Integer`, including sign extension bits if necessary.\npub fn integer_bool_vec_pair_gen_var_2() -> Generator<(Integer, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_integer_bool_vec_pair_gen_var_2,\n        &random_integer_bool_vec_pair_gen_var_2,\n        &special_random_integer_bool_vec_pair_gen_var_2,\n    )\n}\n\n// -- Natural --\n\npub fn natural_gen() -> Generator<Natural> {\n    Generator::new(\n        &exhaustive_natural_gen,\n        &random_natural_gen,\n        &special_random_natural_gen,\n    )\n}\n\npub fn natural_gen_rm() -> Generator<(rug::Integer, Natural)> {\n    Generator::new(\n        &|| natural_rm(exhaustive_natural_gen()),\n        &|config| natural_rm(random_natural_gen(config)),\n        &|config| natural_rm(special_random_natural_gen(config)),\n    )\n}\n\npub fn natural_gen_nrm() -> Generator<(BigUint, rug::Integer, Natural)> {\n    Generator::new(\n        &|| natural_nrm(exhaustive_natural_gen()),\n        &|config| natural_nrm(random_natural_gen(config)),\n        &|config| natural_nrm(special_random_natural_gen(config)),\n    )\n}\n\n// All `Natural`s greater than or equal to 2.\npub fn natural_gen_var_1() -> Generator<Natural> {\n    Generator::new(\n        &exhaustive_natural_gen_var_1,\n        &random_natural_gen_var_1,\n        &special_random_natural_gen_var_6,\n    )\n}\n\n// All positive `Natural`s.\npub fn natural_gen_var_2() -> Generator<Natural> {\n    Generator::new(\n        &exhaustive_natural_gen_var_2,\n        &random_natural_gen_var_2,\n        &special_random_natural_gen_var_1,\n    )\n}\n\n// All `Natural`s that are exactly equal to a floating point value of type `T`.\npub fn natural_gen_var_3<T: PrimitiveFloat>() -> Generator<Natural>\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Generator::new(\n        &exhaustive_natural_gen_var_3::<T>,\n        &random_natural_gen_var_3::<T>,\n        &special_random_natural_gen_var_2::<T>,\n    )\n}\n\n// All `Natural`s that are not equal to any floating point value of type `T`.\npub fn natural_gen_var_4<T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat>()\n-> Generator<Natural> {\n    Generator::new(\n        &exhaustive_natural_gen_var_4::<T>,\n        &random_natural_gen_var_4::<T>,\n        &special_random_natural_gen_var_7::<T>,\n    )\n}\n\ntype GN = Generator<Natural>;\n\n// All `Natural`s that are exactly between two adjacent floats of type `T`.\npub fn natural_gen_var_5<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>() -> GN\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    Generator::new(\n        &exhaustive_natural_gen_var_5::<T>,\n        &random_natural_gen_var_5::<T>,\n        &special_random_natural_gen_var_3::<T>,\n    )\n}\n\n// All `Natural`s that are exactly equal to an unsigned value of type `T`.\npub fn natural_gen_var_6<T: PrimitiveUnsigned>() -> Generator<Natural>\nwhere\n    Natural: From<T>,\n{\n    Generator::new(\n        &exhaustive_natural_gen_var_6::<T>,\n        &random_natural_gen_var_6::<T>,\n        &special_random_natural_gen_var_4::<T>,\n    )\n}\n\n// All `Natural`s that are exactly equal to a signed value of type `T`.\npub fn natural_gen_var_7<T: PrimitiveSigned>() -> Generator<Natural>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Generator::new(\n        &exhaustive_natural_gen_var_7::<T>,\n        &random_natural_gen_var_7::<T>,\n        &special_random_natural_gen_var_5::<T>,\n    )\n}\n\n// All odd `Natural`s.\npub fn natural_gen_var_8() -> Generator<Natural> {\n    Generator::new(\n        &exhaustive_natural_gen_var_8,\n        &random_natural_gen_var_8,\n        &special_random_natural_gen_var_8,\n    )\n}\n\n// All small `Natural`s.\npub fn natural_gen_var_9() -> Generator<Natural> {\n    Generator::new_no_special(&exhaustive_natural_gen, &random_natural_gen_var_9)\n}\n\n// -- (Natural, bool) --\n\npub fn natural_bool_pair_gen() -> Generator<(Natural, bool)> {\n    Generator::new(\n        &exhaustive_natural_bool_pair_gen,\n        &random_natural_bool_pair_gen,\n        &special_random_natural_bool_pair_gen,\n    )\n}\n\n// -- (Natural, Integer, Natural) --\n\npub fn natural_integer_natural_triple_gen() -> Generator<(Natural, Integer, Natural)> {\n    Generator::new(\n        &exhaustive_natural_integer_natural_triple_gen,\n        &random_natural_integer_natural_triple_gen,\n        &special_random_natural_integer_natural_triple_gen,\n    )\n}\n\n// -- (Natural, Natural) --\n\npub fn natural_pair_gen() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen,\n        &random_natural_pair_gen,\n        &special_random_natural_pair_gen,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_pair_gen_nrm() -> Generator<(\n    (BigUint, BigUint),\n    (rug::Integer, rug::Integer),\n    (Natural, Natural),\n)> {\n    Generator::new(\n        &|| natural_pair_nrm(exhaustive_natural_pair_gen()),\n        &|config| natural_pair_nrm(random_natural_pair_gen(config)),\n        &|config| natural_pair_nrm(special_random_natural_pair_gen(config)),\n    )\n}\n\npub fn natural_pair_gen_rm() -> Generator<((rug::Integer, rug::Integer), (Natural, Natural))> {\n    Generator::new(\n        &|| natural_pair_rm(exhaustive_natural_pair_gen()),\n        &|config| natural_pair_rm(random_natural_pair_gen(config)),\n        &|config| natural_pair_rm(special_random_natural_pair_gen(config)),\n    )\n}\n\npub fn natural_pair_gen_nm() -> Generator<((BigUint, BigUint), (Natural, Natural))> {\n    Generator::new(\n        &|| natural_pair_nm(exhaustive_natural_pair_gen()),\n        &|config| natural_pair_nm(random_natural_pair_gen(config)),\n        &|config| natural_pair_nm(special_random_natural_pair_gen(config)),\n    )\n}\n\n// All pairs of `Natural`s where the first `Natural` is large (at least 2^`Limb::WIDTH`) and the\n// second is at least 2.\npub fn natural_pair_gen_var_1() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_1,\n        &random_natural_pair_gen_var_1,\n        &special_random_natural_pair_gen_var_10,\n    )\n}\n\n// All pairs of `Natural`s where the second `Natural` is at least 2.\npub fn natural_pair_gen_var_2() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_2,\n        &random_natural_pair_gen_var_2,\n        &special_random_natural_pair_gen_var_1,\n    )\n}\n\n// All pairs of `Natural`s where the first `Natural` is positive and the second is at least 2.\npub fn natural_pair_gen_var_3() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_3,\n        &random_natural_pair_gen_var_3,\n        &special_random_natural_pair_gen_var_2,\n    )\n}\n\n// All pairs of `Natural`s that tend to have large GCDs.\npub fn natural_pair_gen_var_4() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_4,\n        &random_natural_pair_gen_var_4,\n        &special_random_natural_pair_gen_var_3,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_pair_gen_var_4_nrm() -> Generator<(\n    (BigUint, BigUint),\n    (rug::Integer, rug::Integer),\n    (Natural, Natural),\n)> {\n    Generator::new(\n        &|| natural_pair_nrm(exhaustive_natural_pair_gen_var_4()),\n        &|config| natural_pair_nrm(random_natural_pair_gen_var_4(config)),\n        &|config| natural_pair_nrm(special_random_natural_pair_gen_var_3(config)),\n    )\n}\n\n// All pairs of `Natural`s where the second `Natural` is positive.\npub fn natural_pair_gen_var_5() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_5,\n        &random_natural_pair_gen_var_5,\n        &special_random_natural_pair_gen_var_4,\n    )\n}\n\npub fn natural_pair_gen_var_5_rm() -> Generator<((rug::Integer, rug::Integer), (Natural, Natural))>\n{\n    Generator::new(\n        &|| natural_pair_rm(exhaustive_natural_pair_gen_var_5()),\n        &|config| natural_pair_rm(random_natural_pair_gen_var_5(config)),\n        &|config| natural_pair_rm(special_random_natural_pair_gen_var_4(config)),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_pair_gen_var_5_nrm() -> Generator<(\n    (BigUint, BigUint),\n    (rug::Integer, rug::Integer),\n    (Natural, Natural),\n)> {\n    Generator::new(\n        &|| natural_pair_nrm(exhaustive_natural_pair_gen_var_5()),\n        &|config| natural_pair_nrm(random_natural_pair_gen_var_5(config)),\n        &|config| natural_pair_nrm(special_random_natural_pair_gen_var_4(config)),\n    )\n}\n\n// All pairs of `Natural`s where the first `Natural` is divisible by the second, and the second is\n// positive.\npub fn natural_pair_gen_var_6() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_6,\n        &random_natural_pair_gen_var_6,\n        &special_random_natural_pair_gen_var_5,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_pair_gen_var_6_nrm() -> Generator<(\n    (BigUint, BigUint),\n    (rug::Integer, rug::Integer),\n    (Natural, Natural),\n)> {\n    Generator::new(\n        &|| natural_pair_nrm(exhaustive_natural_pair_gen_var_6()),\n        &|config| natural_pair_nrm(random_natural_pair_gen_var_6(config)),\n        &|config| natural_pair_nrm(special_random_natural_pair_gen_var_5(config)),\n    )\n}\n\n// All pairs of `Natural`s where the first `Natural` is not divisible by the second, and the second\n// is positive.\npub fn natural_pair_gen_var_7() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_7,\n        &random_natural_pair_gen_var_7,\n        &special_random_natural_pair_gen_var_6,\n    )\n}\n\n// All pairs of `Natural`s where the first is smaller than the second.\npub fn natural_pair_gen_var_8() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_8,\n        &random_natural_pair_gen_var_8,\n        &special_random_natural_pair_gen_var_7,\n    )\n}\n\n// All pairs of positive `Natural`s.\npub fn natural_pair_gen_var_9() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_9,\n        &random_natural_pair_gen_var_9,\n        &special_random_natural_pair_gen_var_8,\n    )\n}\n\n// All pairs of `Natural`s where the first is greater than or equal to the second.\npub fn natural_pair_gen_var_10() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_10,\n        &random_natural_pair_gen_var_10,\n        &special_random_natural_pair_gen_var_9,\n    )\n}\n\npub fn natural_pair_gen_var_10_rm() -> Generator<((rug::Integer, rug::Integer), (Natural, Natural))>\n{\n    Generator::new(\n        &|| natural_pair_rm(exhaustive_natural_pair_gen_var_10()),\n        &|config| natural_pair_rm(random_natural_pair_gen_var_10(config)),\n        &|config| natural_pair_rm(special_random_natural_pair_gen_var_9(config)),\n    )\n}\n\npub fn natural_pair_gen_var_10_nrm() -> Generator<(\n    (BigUint, BigUint),\n    (rug::Integer, rug::Integer),\n    (Natural, Natural),\n)> {\n    Generator::new(\n        &|| natural_pair_nrm(exhaustive_natural_pair_gen_var_10()),\n        &|config| natural_pair_nrm(random_natural_pair_gen_var_10(config)),\n        &|config| natural_pair_nrm(special_random_natural_pair_gen_var_9(config)),\n    )\n}\n\n// All pairs of positive `Natural`s where the first is smaller than the second.\npub fn natural_pair_gen_var_11() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_11,\n        &random_natural_pair_gen_var_11,\n        &special_random_natural_pair_gen_var_11,\n    )\n}\n\n// All pairs of `Natural`s where the second `Natural` is odd.\npub fn natural_pair_gen_var_12() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_12,\n        &random_natural_pair_gen_var_12,\n        &special_random_natural_pair_gen_var_12,\n    )\n}\n\npub fn natural_pair_gen_var_12_rm() -> Generator<((rug::Integer, rug::Integer), (Natural, Natural))>\n{\n    Generator::new(\n        &|| natural_pair_rm(exhaustive_natural_pair_gen_var_12()),\n        &|config| natural_pair_rm(random_natural_pair_gen_var_12(config)),\n        &|config| natural_pair_rm(special_random_natural_pair_gen_var_12(config)),\n    )\n}\n\n// All coprime pairs of odd `Natural`s.\npub fn natural_pair_gen_var_13() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_13,\n        &random_natural_pair_gen_var_13,\n        &special_random_natural_pair_gen_var_13,\n    )\n}\n\n// All coprime pairs of `Natural`s.\npub fn natural_pair_gen_var_14() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_14,\n        &random_natural_pair_gen_var_14,\n        &special_random_natural_pair_gen_var_14,\n    )\n}\n\n// All pairs of `Natural`s where the second `Natural` is small.\npub fn natural_pair_gen_var_15() -> Generator<(Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_pair_gen_var_15,\n        &random_natural_pair_gen_var_15,\n        &special_random_natural_pair_gen_var_15,\n    )\n}\n\npub fn natural_pair_gen_var_15_rm() -> Generator<((rug::Integer, u32), (Natural, Natural))> {\n    Generator::new(\n        &|| {\n            Box::new(\n                exhaustive_natural_pair_gen_var_15()\n                    .map(|(x, y)| ((rug::Integer::from(&x), u32::exact_from(&y)), (x, y))),\n            )\n        },\n        &|config| {\n            Box::new(\n                random_natural_pair_gen_var_15(config)\n                    .map(|(x, y)| ((rug::Integer::from(&x), u32::exact_from(&y)), (x, y))),\n            )\n        },\n        &|config| {\n            Box::new(\n                special_random_natural_pair_gen_var_15(config)\n                    .map(|(x, y)| ((rug::Integer::from(&x), u32::exact_from(&y)), (x, y))),\n            )\n        },\n    )\n}\n\n// -- (Natural, Natural, bool) --\n\n// All `(Natural, Natural, bool)` where the second `Natural` is positive.\npub fn natural_natural_bool_triple_gen_var_1() -> Generator<(Natural, Natural, bool)> {\n    Generator::new(\n        &exhaustive_natural_natural_bool_triple_gen_var_1,\n        &random_natural_natural_bool_triple_gen_var_1,\n        &special_random_natural_natural_bool_triple_gen_var_1,\n    )\n}\n\n// -- (Natural, Natural, Natural) --\n\npub fn natural_triple_gen() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen,\n        &random_natural_triple_gen,\n        &special_random_natural_triple_gen,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_triple_gen_rm() -> Generator<(\n    (rug::Integer, rug::Integer, rug::Integer),\n    (Natural, Natural, Natural),\n)> {\n    Generator::new(\n        &|| natural_triple_rm(exhaustive_natural_triple_gen()),\n        &|config| natural_triple_rm(random_natural_triple_gen(config)),\n        &|config| natural_triple_rm(special_random_natural_triple_gen(config)),\n    )\n}\n\n// All triples of `Natural` where the first is equal to the second mod the third.\npub fn natural_triple_gen_var_1() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_1,\n        &random_natural_triple_gen_var_1,\n        &special_random_natural_triple_gen_var_1,\n    )\n}\n\n// All triples of `Natural` where the first is not equal to the second mod the third.\npub fn natural_triple_gen_var_2() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_2,\n        &random_natural_triple_gen_var_2,\n        &special_random_natural_triple_gen_var_2,\n    )\n}\n\n// All triples of `Natural` where the first and second elements each are less than the third.\npub fn natural_triple_gen_var_3() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_3,\n        &random_natural_triple_gen_var_3,\n        &special_random_natural_triple_gen_var_3,\n    )\n}\n\n// All triples of `Natural` where the third `Natural` is positive.\npub fn natural_triple_gen_var_4() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_4,\n        &random_natural_triple_gen_var_4,\n        &special_random_natural_triple_gen_var_4,\n    )\n}\n\n// All triples of `Natural` where the first element is less than the third.\npub fn natural_triple_gen_var_5() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_5,\n        &random_natural_triple_gen_var_5,\n        &special_random_natural_triple_gen_var_5,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_triple_gen_var_5_nrm() -> Generator<(\n    (BigUint, BigUint, BigUint),\n    (rug::Integer, rug::Integer, rug::Integer),\n    (Natural, Natural, Natural),\n)> {\n    Generator::new(\n        &|| natural_triple_nrm(exhaustive_natural_triple_gen_var_5()),\n        &|config| natural_triple_nrm(random_natural_triple_gen_var_5(config)),\n        &|config| natural_triple_nrm(special_random_natural_triple_gen_var_5(config)),\n    )\n}\n\n// All triples of positive `Natural`s.\npub fn natural_triple_gen_var_6() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_6,\n        &random_natural_triple_gen_var_6,\n        &special_random_natural_triple_gen_var_6,\n    )\n}\n\n// All triples of `Natural`s where the first is greater than or equal to the product of the second\n// and third.\npub fn natural_triple_gen_var_7() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_7,\n        &random_natural_triple_gen_var_7,\n        &special_random_natural_triple_gen_var_7,\n    )\n}\n\n// All triples of `Natural`s where the third `Natural` is odd.\npub fn natural_triple_gen_var_8() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_8,\n        &random_natural_triple_gen_var_8,\n        &special_random_natural_triple_gen_var_8,\n    )\n}\n\n// All triples of `Natural`s where the second and third `Natural`s are odd.\npub fn natural_triple_gen_var_9() -> Generator<(Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_triple_gen_var_9,\n        &random_natural_triple_gen_var_9,\n        &special_random_natural_triple_gen_var_9,\n    )\n}\n\n// -- (Natural, Natural, Natural, Natural) --\n\n// All quadruples of `Natural` where the first three elements are each less than the fourth.\npub fn natural_quadruple_gen_var_1() -> Generator<(Natural, Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_quadruple_gen_var_1,\n        &random_natural_quadruple_gen_var_1,\n        &special_random_natural_quadruple_gen_var_1,\n    )\n}\n\n// All quadruples of `Natural` where the first two elements are each smaller than the fourth.\npub fn natural_quadruple_gen_var_2() -> Generator<(Natural, Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_quadruple_gen_var_2,\n        &random_natural_quadruple_gen_var_2,\n        &special_random_natural_quadruple_gen_var_2,\n    )\n}\n\n// All quadruples of `Natural` where the first element is less than the fourth.\npub fn natural_quadruple_gen_var_3() -> Generator<(Natural, Natural, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_natural_quadruple_gen_var_3,\n        &random_natural_quadruple_gen_var_3,\n        &special_random_natural_quadruple_gen_var_3,\n    )\n}\n\n// -- (Natural, Natural, Natural, PrimitiveUnsigned) --\n\n// All `(Natural, Natural, Natural, T)` where `T` is unsigned and small.\npub fn natural_natural_natural_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Natural, Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_1,\n        &random_natural_natural_natural_unsigned_quadruple_gen_var_1,\n        &special_random_natural_natural_natural_unsigned_quadruple_gen_var_1,\n    )\n}\n\n// All `(Natural, Natural, Natural, u64)` where all `Natural`s are less than 2 to the power of the\n// `u64`.\npub fn natural_natural_natural_unsigned_quadruple_gen_var_2()\n-> Generator<(Natural, Natural, Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_2,\n        &random_natural_natural_natural_unsigned_quadruple_gen_var_2,\n        &special_random_natural_natural_natural_unsigned_quadruple_gen_var_2,\n    )\n}\n\n// All `(Natural, Natural, Natural, u64)` where the first two `Natural`s are less than 2 to the\n// power of the `u64`.\npub fn natural_natural_natural_unsigned_quadruple_gen_var_3()\n-> Generator<(Natural, Natural, Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_3,\n        &random_natural_natural_natural_unsigned_quadruple_gen_var_3,\n        &special_random_natural_natural_natural_unsigned_quadruple_gen_var_3,\n    )\n}\n\n// All `(Natural, Natural, Natural, u64)` where the first `Natural` is less than 2 to the power of\n// the `u64`.\npub fn natural_natural_natural_unsigned_quadruple_gen_var_4()\n-> Generator<(Natural, Natural, Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_natural_natural_unsigned_quadruple_gen_var_4,\n        &random_natural_natural_natural_unsigned_quadruple_gen_var_4,\n        &special_random_natural_natural_natural_unsigned_quadruple_gen_var_4,\n    )\n}\n\n// -- (Natural, Natural, PrimitiveFloat) --\n\npub fn natural_natural_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> Generator<(Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_primitive_float_triple_gen,\n        &random_natural_natural_primitive_float_triple_gen,\n        &special_random_natural_natural_primitive_float_triple_gen,\n    )\n}\n\n// -- (Natural, Natural, PrimitiveSigned) --\n\npub fn natural_natural_signed_triple_gen<T: PrimitiveSigned>() -> Generator<(Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_signed_triple_gen,\n        &random_natural_natural_primitive_int_triple_gen,\n        &special_random_natural_natural_signed_triple_gen,\n    )\n}\n\n// All `(Natural, Natural, T)` where the `T` is signed and small, and the first `Natural` is smaller\n// than the second.\npub fn natural_natural_signed_triple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_signed_triple_gen_var_1,\n        &random_natural_natural_signed_triple_gen_var_1,\n        &special_random_natural_natural_signed_triple_gen_var_1,\n    )\n}\n\n// -- (Natural, Natural, PrimitiveUnsigned) --\n\npub fn natural_natural_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> Generator<(Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_unsigned_triple_gen,\n        &random_natural_natural_primitive_int_triple_gen,\n        &special_random_natural_natural_unsigned_triple_gen,\n    )\n}\n\n// All `(Natural, Natural, T)` where `T` is unsigned and small.\npub fn natural_natural_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_unsigned_triple_gen_var_1,\n        &random_natural_natural_unsigned_triple_gen_var_1,\n        &special_random_natural_natural_unsigned_triple_gen_var_1,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_natural_unsigned_triple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, rug::Integer, T), (Natural, Natural, T))> {\n    Generator::new(\n        &|| natural_natural_triple_1_2_rm(exhaustive_natural_natural_unsigned_triple_gen_var_1()),\n        &|config| {\n            natural_natural_triple_1_2_rm(random_natural_natural_unsigned_triple_gen_var_1(config))\n        },\n        &|config| {\n            natural_natural_triple_1_2_rm(special_random_natural_natural_unsigned_triple_gen_var_1(\n                config,\n            ))\n        },\n    )\n}\n\n// All `(Natural, Natural, T)` where `T` is unsigned and small, and the `Natural`s are equal mod 2\n// to the power of the `T`.\npub fn natural_natural_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Natural, Natural, T)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Generator::new(\n        &exhaustive_natural_natural_unsigned_triple_gen_var_2,\n        &random_natural_natural_unsigned_triple_gen_var_2,\n        &special_random_natural_natural_unsigned_triple_gen_var_2,\n    )\n}\n\n// All `(Natural, Natural, T)` where `T` is unsigned and small, and the `Natural`s are not equal mod\n// 2 to the power of the `T`.\npub fn natural_natural_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>()\n-> Generator<(Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_unsigned_triple_gen_var_3,\n        &random_natural_natural_unsigned_triple_gen_var_3,\n        &special_random_natural_natural_unsigned_triple_gen_var_3,\n    )\n}\n\n// All `(Natural, Natural, u64)` where both `Natural`s are less than 2 to the power of the `u64`.\npub fn natural_natural_unsigned_triple_gen_var_4() -> Generator<(Natural, Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_natural_unsigned_triple_gen_var_4,\n        &random_natural_natural_unsigned_triple_gen_var_4,\n        &special_random_natural_natural_unsigned_triple_gen_var_4,\n    )\n}\n\n// All `(Natural, Natural, u64)` where the first `Natural` is less than 2 to the power of the `u64`.\npub fn natural_natural_unsigned_triple_gen_var_5() -> Generator<(Natural, Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_natural_unsigned_triple_gen_var_5,\n        &random_natural_natural_unsigned_triple_gen_var_5,\n        &special_random_natural_natural_unsigned_triple_gen_var_5,\n    )\n}\n\n// All `(Natural, Natural, T)` where the `T` is unsigned and small, and the first `Natural` is\n// smaller than the second.\npub fn natural_natural_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> Generator<(Natural, Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_natural_unsigned_triple_gen_var_6,\n        &random_natural_natural_unsigned_triple_gen_var_6,\n        &special_random_natural_natural_unsigned_triple_gen_var_6,\n    )\n}\n\n// -- (Natural, Natural, RoundingMode) --\n\n// All `(Natural, Natural, RoundingMode)` triples where the second `Natural` is positive and if the\n// `RoundingMode` is `Exact`, the first `Natural` is divisible by the second.\npub fn natural_natural_rounding_mode_triple_gen_var_1()\n-> Generator<(Natural, Natural, RoundingMode)> {\n    Generator::new(\n        &exhaustive_natural_natural_rounding_mode_triple_gen_var_1,\n        &random_natural_natural_rounding_mode_triple_gen_var_1,\n        &special_random_natural_natural_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Natural, Natural, RoundingMode)` triples that are a valid input to\n// `Natural::round_to_multiple`.\npub fn natural_natural_rounding_mode_triple_gen_var_2()\n-> Generator<(Natural, Natural, RoundingMode)> {\n    Generator::new(\n        &exhaustive_natural_natural_rounding_mode_triple_gen_var_2,\n        &random_natural_natural_rounding_mode_triple_gen_var_2,\n        &special_random_natural_natural_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// -- (Natural, PrimitiveFloat) --\n\npub fn natural_primitive_float_pair_gen<T: PrimitiveFloat>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_primitive_float_pair_gen,\n        &random_natural_primitive_float_pair_gen,\n        &special_random_natural_primitive_float_pair_gen,\n    )\n}\n\npub fn natural_primitive_float_pair_gen_rm<T: PrimitiveFloat>()\n-> Generator<((rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_rm(exhaustive_natural_primitive_float_pair_gen()),\n        &|config| natural_pair_1_rm(random_natural_primitive_float_pair_gen(config)),\n        &|config| natural_pair_1_rm(special_random_natural_primitive_float_pair_gen(config)),\n    )\n}\n\n// -- (Natural, PrimitiveFloat, PrimitiveFloat) --\n\npub fn natural_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> Generator<(Natural, T, T)> {\n    Generator::new(\n        &exhaustive_natural_primitive_float_primitive_float_triple_gen,\n        &random_natural_primitive_float_primitive_float_triple_gen,\n        &special_random_natural_primitive_float_primitive_float_triple_gen,\n    )\n}\n\n// -- (Natural, PrimitiveSigned) --\n\npub fn natural_signed_pair_gen<T: PrimitiveSigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_signed_pair_gen,\n        &random_natural_primitive_int_pair_gen,\n        &special_random_natural_signed_pair_gen,\n    )\n}\n\npub fn natural_signed_pair_gen_rm<T: PrimitiveSigned>()\n-> Generator<((rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_rm(exhaustive_natural_signed_pair_gen()),\n        &|config| natural_pair_1_rm(random_natural_primitive_int_pair_gen(config)),\n        &|config| natural_pair_1_rm(special_random_natural_signed_pair_gen(config)),\n    )\n}\n\n// All pairs of `Natural` and signed `T`, where the `T` is natural (non-negative).\npub fn natural_signed_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_signed_pair_gen_var_1,\n        &random_natural_signed_pair_gen_var_1,\n        &special_random_natural_signed_pair_gen_var_1,\n    )\n}\n\n// All `(Natural, T)` where `T` is signed and small.\npub fn natural_signed_pair_gen_var_2<T: PrimitiveSigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_signed_pair_gen_var_2,\n        &random_natural_signed_pair_gen_var_2,\n        &special_random_natural_signed_pair_gen_var_2,\n    )\n}\n\npub fn natural_signed_pair_gen_var_2_rm<T: PrimitiveSigned>()\n-> Generator<((rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_rm(exhaustive_natural_signed_pair_gen_var_2()),\n        &|config| natural_pair_1_rm(random_natural_signed_pair_gen_var_2(config)),\n        &|config| natural_pair_1_rm(special_random_natural_signed_pair_gen_var_2(config)),\n    )\n}\n\n// All `(Natural, T)` where `T` is signed and the `Natural` is positive.\npub fn natural_signed_pair_gen_var_3<T: PrimitiveSigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_signed_pair_gen_var_3,\n        &random_natural_primitive_int_pair_gen_var_1,\n        &special_random_natural_signed_pair_gen_var_3,\n    )\n}\n\n// All `(Natural, T)` where `T` is signed and small, the `Natural` is positive, and the `Natural`s\n// bit length is a multiple of the limb bit length.\npub fn natural_signed_pair_gen_var_4<T: PrimitiveSigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_signed_pair_gen_var_4,\n        &random_natural_signed_pair_gen_var_3,\n        &special_random_natural_signed_pair_gen_var_4,\n    )\n}\n\n// -- (Natural, PrimitiveSigned, PrimitiveSigned) --\n\npub fn natural_signed_signed_triple_gen<T: PrimitiveSigned>() -> Generator<(Natural, T, T)> {\n    Generator::new(\n        &exhaustive_natural_signed_signed_triple_gen,\n        &random_natural_primitive_int_primitive_int_triple_gen,\n        &special_random_natural_signed_signed_triple_gen,\n    )\n}\n\n// -- (Natural, PrimitiveSigned, PrimitiveUnsigned) --\n\ntype T2<T> = Generator<(Natural, T, u64)>;\n// All `(Natural, T, u64)` where the `Natural` is less than 2 to the power of the `u64`, and the `T`\n// is small and signed.\npub fn natural_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned>() -> T2<T> {\n    Generator::new(\n        &exhaustive_natural_signed_unsigned_triple_gen_var_1,\n        &random_natural_signed_unsigned_triple_gen_var_1,\n        &special_random_natural_signed_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(Natural, T, U)` where `T` is signed and small and `U` is unsigned, small, and positive.\npub fn natural_signed_unsigned_triple_gen_var_2<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(Natural, T, U)> {\n    Generator::new(\n        &exhaustive_natural_signed_unsigned_triple_gen_var_2,\n        &random_natural_signed_unsigned_triple_gen_var_2,\n        &special_random_natural_signed_unsigned_triple_gen_var_2,\n    )\n}\n\n// -- (Natural, PrimitiveSigned, RoundingMode) --\n\n// All `(Natural, T, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `Natural::shl_round`.\npub fn natural_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shr<T, Output = Natural>,\n{\n    Generator::new(\n        &exhaustive_natural_signed_rounding_mode_triple_gen_var_1,\n        &random_natural_signed_rounding_mode_triple_gen_var_1,\n        &special_random_natural_signed_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// All `(Natural, T, RoundingMode)` where `T` is signed and the triple is a valid input to\n// `Natural::shr_round`.\npub fn natural_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>()\n-> Generator<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Generator::new(\n        &exhaustive_natural_signed_rounding_mode_triple_gen_var_2,\n        &random_natural_signed_rounding_mode_triple_gen_var_2,\n        &special_random_natural_signed_rounding_mode_triple_gen_var_2,\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned) --\n\npub fn natural_unsigned_pair_gen<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen,\n        &random_natural_primitive_int_pair_gen,\n        &special_random_natural_unsigned_pair_gen,\n    )\n}\n\npub fn natural_unsigned_pair_gen_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_rm(exhaustive_natural_unsigned_pair_gen()),\n        &|config| natural_pair_1_rm(random_natural_primitive_int_pair_gen(config)),\n        &|config| natural_pair_1_rm(special_random_natural_unsigned_pair_gen(config)),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_unsigned_pair_gen_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigUint, T), (rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_nrm(exhaustive_natural_unsigned_pair_gen()),\n        &|config| natural_pair_1_nrm(random_natural_primitive_int_pair_gen(config)),\n        &|config| natural_pair_1_nrm(special_random_natural_unsigned_pair_gen(config)),\n    )\n}\n\n// All `(Natural, T)` where `T` is unsigned and the `T` is at least 2 and at most `U::MAX`.\npub fn natural_unsigned_pair_gen_var_1<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveInt,\n>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_primitive_int_pair_gen_var_1::<T, U>,\n        &random_natural_unsigned_pair_gen_var_1::<T, U>,\n        &special_random_natural_unsigned_pair_gen_var_1::<T, U>,\n    )\n}\n\n// All `(Natural, T)` where `T` is unsigned and the `T` is at least 2.\npub fn natural_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_primitive_int_pair_gen_var_2,\n        &random_natural_unsigned_pair_gen_var_2,\n        &special_random_natural_unsigned_pair_gen_var_2,\n    )\n}\n\n// All `(Natural, T)` where `T` is unsigned and between 2 and 36, inclusive.\npub fn natural_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_1,\n        &random_natural_unsigned_pair_gen_var_3,\n        &special_random_natural_unsigned_pair_gen_var_3,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_unsigned_pair_gen_var_3_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigUint, T), (rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_nrm(exhaustive_natural_unsigned_pair_gen_var_1()),\n        &|config| natural_pair_1_nrm(random_natural_unsigned_pair_gen_var_3(config)),\n        &|config| natural_pair_1_nrm(special_random_natural_unsigned_pair_gen_var_3(config)),\n    )\n}\n\n// All `(Natural, T)` where `T` is unsigned and small.\npub fn natural_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_2,\n        &random_natural_unsigned_pair_gen_var_4,\n        &special_random_natural_unsigned_pair_gen_var_4,\n    )\n}\n\npub fn natural_unsigned_pair_gen_var_4_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_rm(exhaustive_natural_unsigned_pair_gen_var_2()),\n        &|config| natural_pair_1_rm(random_natural_unsigned_pair_gen_var_4(config)),\n        &|config| natural_pair_1_rm(special_random_natural_unsigned_pair_gen_var_4(config)),\n    )\n}\n\npub fn natural_unsigned_pair_gen_var_4_nm<T: PrimitiveUnsigned>()\n-> Generator<((BigUint, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_nm(exhaustive_natural_unsigned_pair_gen_var_2()),\n        &|config| natural_pair_1_nm(random_natural_unsigned_pair_gen_var_4(config)),\n        &|config| natural_pair_1_nm(special_random_natural_unsigned_pair_gen_var_4(config)),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_unsigned_pair_gen_var_4_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigUint, T), (rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_nrm(exhaustive_natural_unsigned_pair_gen_var_2()),\n        &|config| natural_pair_1_nrm(random_natural_unsigned_pair_gen_var_4(config)),\n        &|config| natural_pair_1_nrm(special_random_natural_unsigned_pair_gen_var_4(config)),\n    )\n}\n\n// All `(Natural, T)` where the `Natural` is at least 2 and the `T` is unsigned and small.\npub fn natural_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_3,\n        &random_natural_unsigned_pair_gen_var_5,\n        &special_random_natural_unsigned_pair_gen_var_12,\n    )\n}\n\n// All `(Natural, T)`, where the `T` is between 1 and `T::WIDTH`, inclusive.\npub fn natural_unsigned_pair_gen_var_6<T: PrimitiveInt>() -> Generator<(Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_4::<T>,\n        &random_natural_unsigned_pair_gen_var_6::<T>,\n        &special_random_natural_unsigned_pair_gen_var_5::<T>,\n    )\n}\n\n// All `(Natural, T)` where the `T` is unsigned, positive, and small.\npub fn natural_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_primitive_int_pair_gen_var_3,\n        &random_natural_unsigned_pair_gen_var_7,\n        &special_random_natural_unsigned_pair_gen_var_6,\n    )\n}\n\npub fn natural_unsigned_pair_gen_var_7_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_rm(exhaustive_natural_primitive_int_pair_gen_var_3()),\n        &|config| natural_pair_1_rm(random_natural_unsigned_pair_gen_var_7(config)),\n        &|config| natural_pair_1_rm(special_random_natural_unsigned_pair_gen_var_6(config)),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_unsigned_pair_gen_var_7_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigUint, T), (rug::Integer, T), (Natural, T))> {\n    Generator::new(\n        &|| natural_pair_1_nrm(exhaustive_natural_primitive_int_pair_gen_var_3()),\n        &|config| natural_pair_1_nrm(random_natural_unsigned_pair_gen_var_7(config)),\n        &|config| natural_pair_1_nrm(special_random_natural_unsigned_pair_gen_var_6(config)),\n    )\n}\n\n// All `(Natural, T)` where the `Natural` is positive and the `T` is unsigned, positive, and small.\npub fn natural_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_primitive_int_pair_gen_var_4,\n        &random_natural_unsigned_pair_gen_var_8,\n        &special_random_natural_unsigned_pair_gen_var_7,\n    )\n}\n\n// All `(Natural, u64)`s where the `T` is unsigned and small, and the `Natural` is divisible by 2 to\n// the power of the `T`.\npub fn natural_unsigned_pair_gen_var_9<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_5,\n        &random_natural_unsigned_pair_gen_var_9,\n        &special_random_natural_unsigned_pair_gen_var_8,\n    )\n}\n\n// All `(Natural, u64)`s where the `T` is unsigned and small, and the `Natural` is not divisible by\n// 2 to the power of the `T`.\npub fn natural_unsigned_pair_gen_var_10<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_6,\n        &random_natural_unsigned_pair_gen_var_10,\n        &special_random_natural_unsigned_pair_gen_var_9,\n    )\n}\n\n// All `(Natural, u64)` where the `Natural` is less than 2 to the power of the `u64`.\npub fn natural_unsigned_pair_gen_var_11() -> Generator<(Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_7,\n        &random_natural_unsigned_pair_gen_var_11,\n        &special_random_natural_unsigned_pair_gen_var_10,\n    )\n}\n\n// All `(Natural, T)` where the `Natural` is positive and the `T` is unsigned.\npub fn natural_unsigned_pair_gen_var_12<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_8,\n        &random_natural_primitive_int_pair_gen_var_1,\n        &special_random_natural_unsigned_pair_gen_var_11,\n    )\n}\n\n// All `(Natural, T)` where the `Natural` is positive and the `T` is unsigned and small.\npub fn natural_unsigned_pair_gen_var_13<T: PrimitiveUnsigned>() -> Generator<(Natural, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_9,\n        &random_natural_unsigned_pair_gen_var_12,\n        &special_random_natural_unsigned_pair_gen_var_13,\n    )\n}\n\n// All `(Natural, u64)` where the `Natural` is nonzero and less than 2 to the power of the `u64`.\npub fn natural_unsigned_pair_gen_var_14() -> Generator<(Natural, u64)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_pair_gen_var_10,\n        &random_natural_unsigned_pair_gen_var_13,\n        &special_random_natural_unsigned_pair_gen_var_14,\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, bool) --\n\n// All `(Natural, T, bool)` where `T` is unsigned and small.\npub fn natural_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Natural, T, bool)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_bool_triple_gen_var_1,\n        &random_natural_unsigned_bool_triple_gen_var_1,\n        &special_random_natural_unsigned_bool_triple_gen_var_1,\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn natural_unsigned_bool_triple_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Integer, T, bool), (Natural, T, bool))> {\n    Generator::new(\n        &|| natural_triple_1_rm(exhaustive_natural_unsigned_bool_triple_gen_var_1()),\n        &|config| natural_triple_1_rm(random_natural_unsigned_bool_triple_gen_var_1(config)),\n        &|config| {\n            natural_triple_1_rm(special_random_natural_unsigned_bool_triple_gen_var_1(\n                config,\n            ))\n        },\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn natural_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> Generator<(Natural, T, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_unsigned_triple_gen,\n        &random_natural_primitive_int_primitive_int_triple_gen,\n        &special_random_natural_unsigned_unsigned_triple_gen,\n    )\n}\n\n// All `(Natural, T, U)` where `T` and `U` are unsigned, the `T` is between 2 and 36, inclusive, and\n// the `U` is small.\npub fn natural_unsigned_unsigned_triple_gen_var_1<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Natural, T, U)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_unsigned_triple_gen_var_1,\n        &random_natural_unsigned_unsigned_triple_gen_var_1,\n        &special_random_natural_unsigned_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(Natural, u64, T)` where `T` is unsigned, `U` is a primitive int, the `u64` is between 1 and\n// `U::WIDTH`, inclusive, and the `T` is small.\npub fn natural_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveInt>()\n-> Generator<(Natural, u64, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_unsigned_triple_gen_var_2::<T, U>,\n        &random_natural_unsigned_unsigned_triple_gen_var_2::<T, U>,\n        &special_random_natural_unsigned_unsigned_triple_gen_var_2::<T, U>,\n    )\n}\n\n// All `(Natural, T, U)` where `T` and `U` are unsigned, the `T` and the `U` are small, and the `T`\n// is positive.\npub fn natural_unsigned_unsigned_triple_gen_var_3<T: PrimitiveUnsigned, U: PrimitiveUnsigned>()\n-> Generator<(Natural, T, U)> {\n    Generator::new(\n        &exhaustive_natural_primitive_int_unsigned_triple_gen_var_3,\n        &random_natural_unsigned_unsigned_triple_gen_var_3,\n        &special_random_natural_unsigned_unsigned_triple_gen_var_3,\n    )\n}\n\n// All `(Natural, T, T)` where `T` is unsigned, both `T`s are small, and the first `T` is less than\n// or equal to the second.\npub fn natural_unsigned_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>()\n-> Generator<(Natural, T, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_unsigned_triple_gen_var_3,\n        &random_natural_unsigned_unsigned_triple_gen_var_4,\n        &special_random_natural_unsigned_unsigned_triple_gen_var_4,\n    )\n}\n\n// All `(Natural, T, T)` where `T` is unsigned and both `T`s are small.\npub fn natural_unsigned_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>()\n-> Generator<(Natural, T, T)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_unsigned_triple_gen_var_4,\n        &random_natural_unsigned_unsigned_triple_gen_var_5,\n        &special_random_natural_unsigned_unsigned_triple_gen_var_5,\n    )\n}\n\n// All `(Natural, T, u64)` where the `Natural` is less than 2 to the power of the `u64`, and the `T`\n// is small and unsigned.\npub fn natural_unsigned_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>()\n-> Generator<(Natural, T, u64)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_unsigned_triple_gen_var_5,\n        &random_natural_unsigned_unsigned_triple_gen_var_6,\n        &special_random_natural_unsigned_unsigned_triple_gen_var_6,\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\n// All `(Natural, T, T, Natural)` where `T` is unsigned and the first `T` is smaller than the\n// second.\npub fn natural_unsigned_unsigned_natural_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Natural, T, T, Natural)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_unsigned_natural_quadruple_gen_var_1,\n        &random_natural_unsigned_unsigned_natural_triple_gen_var_1,\n        &special_random_natural_unsigned_unsigned_natural_quadruple_gen_var_1,\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\n// All `(Natural, T, RoundingMode)` where `T` is unsigned and the triple is a valid input to\n// `Natural::shr_round`.\npub fn natural_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Generator::new(\n        &exhaustive_natural_unsigned_rounding_mode_triple_gen_var_1,\n        &random_natural_unsigned_rounding_mode_triple_gen_var_1,\n        &special_random_natural_unsigned_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// var 2 is in malachite-float\n\n// -- (Natural, PrimitiveUnsigned, Vec<bool>) --\n\n// All `(Natural, u64, Vec<bool>)` where the `u64` is small and the `Vec<bool>` has as many elements\n// as the `Natural` has digits when expessed in base 2 to the power of the `u64`.\npub fn natural_unsigned_bool_vec_triple_gen_var_1() -> Generator<(Natural, u64, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_bool_vec_triple_gen_var_1,\n        &random_natural_unsigned_bool_vec_triple_gen_var_1,\n        &special_random_natural_unsigned_bool_vec_triple_gen_var_1,\n    )\n}\n\n// All `(Natural, u64, Vec<bool>)` where the `u64` is between 1 and `T::WIDTH`, inclusive, and the\n// `Vec<bool>` has as many elements as the `Natural` has digits when expessed in base 2 to the power\n// of the `u64`.\npub fn natural_unsigned_bool_vec_triple_gen_var_2<T: PrimitiveInt>()\n-> Generator<(Natural, u64, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_natural_unsigned_bool_vec_triple_gen_var_2::<T>,\n        &random_natural_unsigned_bool_vec_triple_gen_var_2::<T>,\n        &special_random_natural_unsigned_bool_vec_triple_gen_var_2::<T>,\n    )\n}\n\n// -- (Natural, RoundingMode) --\n\npub fn natural_rounding_mode_pair_gen() -> Generator<(Natural, RoundingMode)> {\n    Generator::new(\n        &exhaustive_natural_rounding_mode_pair_gen,\n        &random_natural_rounding_mode_pair_gen,\n        &special_random_natural_rounding_mode_pair_gen,\n    )\n}\n\n// All `(Natural, RoundingMode)` pairs that are valid inputs to `T::rounding_from`.\npub fn natural_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat,\n>() -> Generator<(Natural, RoundingMode)> {\n    Generator::new(\n        &exhaustive_natural_rounding_mode_pair_gen_var_1::<T>,\n        &random_natural_rounding_mode_pair_gen_var_1::<T>,\n        &special_random_natural_rounding_mode_pair_gen_var_1::<T>,\n    )\n}\n\n// All `(Natural, RoundingMode)` pairs where the `Natural` is positive.\npub fn natural_rounding_mode_pair_gen_var_2() -> Generator<(Natural, RoundingMode)> {\n    Generator::new(\n        &exhaustive_natural_rounding_mode_pair_gen_var_2,\n        &random_natural_rounding_mode_pair_gen_var_2,\n        &special_random_natural_rounding_mode_pair_gen_var_2,\n    )\n}\n\n// -- (Natural, ToSciOptions) --\n\npub fn natural_to_sci_options_pair_gen() -> Generator<(Natural, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_natural_to_sci_options_pair_gen,\n        &random_natural_to_sci_options_pair_gen,\n        &special_random_natural_to_sci_options_pair_gen,\n    )\n}\n\n// All `(Natural, ToSciOptions)` pairs where the `Natural` can be formatted using the options.\npub fn natural_to_sci_options_pair_gen_var_1() -> Generator<(Natural, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_natural_to_sci_options_pair_gen_var_1,\n        &random_natural_to_sci_options_pair_gen_var_1,\n        &special_random_natural_to_sci_options_pair_gen_var_1,\n    )\n}\n\n// -- (Natural, Vec<bool>) --\n\n// All `(Natural, Vec<bool>)` pairs where the length of the `Vec` is the number of limbs of the\n// `Natural`.\npub fn natural_bool_vec_pair_gen_var_1() -> Generator<(Natural, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_natural_bool_vec_pair_gen_var_1,\n        &random_natural_bool_vec_pair_gen_var_1,\n        &special_random_natural_bool_vec_pair_gen_var_1,\n    )\n}\n\n// All `(Natural, Vec<bool>)` pairs where the length of the `Vec` is the number of significant bits\n// of the `Natural`.\npub fn natural_bool_vec_pair_gen_var_2() -> Generator<(Natural, Vec<bool>)> {\n    Generator::new(\n        &exhaustive_natural_bool_vec_pair_gen_var_2,\n        &random_natural_bool_vec_pair_gen_var_2,\n        &special_random_natural_bool_vec_pair_gen_var_2,\n    )\n}\n\n// -- (PrimitiveUnsigned, bool) --\n\n#[allow(clippy::redundant_comparisons)]\npub(crate) const fn limbs_odd_factorial_valid(n: usize, b: bool) -> bool {\n    !b || n > ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1 && n >= FAC_DSC_THRESHOLD\n}\n\n// All `(T, u63>)` that are valid arguments to `limbs_odd_factorial`.\npub fn unsigned_bool_pair_gen_var_1() -> Generator<(usize, bool)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_bool_pair_gen_var_1,\n        &random_unsigned_bool_pair_gen_var_1,\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// vars 1 through 44 are in malachite-base\n\n// All `(T, T)` where `T` is unsigned, both `T`s are small, the first `T` is greater than or equal\n// to the second, and both are greater than `ODD_FACTORIAL_TABLE_LIMIT`.\npub fn unsigned_pair_gen_var_45<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_32,\n        &random_unsigned_pair_gen_var_33,\n    )\n}\n\n// All `(T, T)` where `T` is unsigned, both `T`s are small, the first `T` is greater than or equal\n// to the second, and the second is at least 2 and no greater than `ODD_FACTORIAL_TABLE_LIMIT`.\npub fn unsigned_pair_gen_var_46<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_33,\n        &random_unsigned_pair_gen_var_34,\n    )\n}\n\n// All `(T, T)` where `T` is unsigned, both `T`s are small, the first `T` is at least 2 more than\n// the second, the second is at least 2, and the first is no greater than\n// `ODD_FACTORIAL_EXTTABLE_LIMIT`.\npub fn unsigned_pair_gen_var_47<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_34,\n        &random_unsigned_pair_gen_var_35,\n    )\n}\n\n// All `(T, T)` where `T` is unsigned, both `T`s are small, the first `T` is greater than or equal\n// to the second, and both are greater than `ODD_FACTORIAL_TABLE_LIMIT`.\npub fn unsigned_pair_gen_var_48<T: PrimitiveUnsigned>() -> Generator<(T, T)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_35,\n        &random_unsigned_pair_gen_var_36,\n    )\n}\n\n// All `(Limb, Limb)` that are valid inputs to `limbs_binomial_coefficient_limb_limb_goetgheluck`.\npub fn unsigned_pair_gen_var_49() -> Generator<(Limb, Limb)> {\n    Generator::new_no_special(\n        &exhaustive_unsigned_pair_gen_var_36,\n        &random_unsigned_pair_gen_var_37,\n    )\n}\n\n// var 50 is in malachite-base\n\n// -- (PrimitiveUnsigned * 6) --\n\n// var 2 is in malachite-base.\n\n// All sextuples of unsigneds that are valid inputs to `limbs_div_mod_three_limb_by_two_limb`.\npub fn unsigned_sextuple_gen_var_2() -> Generator<(Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_sextuple_gen_var_2,\n        &random_unsigned_sextuple_gen_var_1,\n        &special_random_unsigned_sextuple_gen_var_2,\n    )\n}\n\n// -- (String, String, String) --\n\n// All triples of `String`s corresponding to the serialization of a `num::BigUint`, a\n// `rug::Integer`, and a `Natural`, respectively, into a string. The three numbers have the same\n// value.\npub fn string_triple_gen_var_1() -> Generator<(String, String, String)> {\n    Generator::new(\n        &exhaustive_string_triple_gen_var_1,\n        &random_string_triple_gen_var_1,\n        &special_random_string_triple_gen_var_1,\n    )\n}\n\n// All triples of `String`s corresponding to the serialization of a `num::BigInt`, a `rug::Integer`,\n// and an `Integer`, respectively, into a string. The three numbers have the same value.\npub fn string_triple_gen_var_2() -> Generator<(String, String, String)> {\n    Generator::new(\n        &exhaustive_string_triple_gen_var_2,\n        &random_string_triple_gen_var_2,\n        &special_random_string_triple_gen_var_2,\n    )\n}\n\n// var 3 is in malachite-q.\n\n// -- Vec<Integer> --\n\npub fn integer_vec_gen() -> Generator<Vec<Integer>> {\n    Generator::new(\n        &exhaustive_integer_vec_gen,\n        &random_integer_vec_gen,\n        &special_random_integer_vec_gen,\n    )\n}\n\npub fn integer_vec_gen_nrm() -> Generator<(Vec<BigInt>, Vec<rug::Integer>, Vec<Integer>)> {\n    Generator::new(\n        &|| integer_vec_nrm(exhaustive_integer_vec_gen()),\n        &|config| integer_vec_nrm(random_integer_vec_gen(config)),\n        &|config| integer_vec_nrm(special_random_integer_vec_gen(config)),\n    )\n}\n\n// -- Vec<Natural> --\n\npub fn natural_vec_gen() -> Generator<Vec<Natural>> {\n    Generator::new(\n        &exhaustive_natural_vec_gen,\n        &random_natural_vec_gen,\n        &special_random_natural_vec_gen,\n    )\n}\n\npub fn natural_vec_gen_nrm() -> Generator<(Vec<BigUint>, Vec<rug::Integer>, Vec<Natural>)> {\n    Generator::new(\n        &|| natural_vec_nrm(exhaustive_natural_vec_gen()),\n        &|config| natural_vec_nrm(random_natural_vec_gen(config)),\n        &|config| natural_vec_nrm(special_random_natural_vec_gen(config)),\n    )\n}\n\n// -- (Vec<Natural>, Integer) --\n\n// All `(Vec<Natural>, Integer)` where the `Natural`s are positive.\npub fn natural_vec_integer_pair_gen_var_1() -> Generator<(Vec<Natural>, Integer)> {\n    Generator::new(\n        &exhaustive_natural_vec_integer_pair_gen_var_1,\n        &random_natural_vec_integer_pair_gen_var_1,\n        &special_random_natural_vec_integer_pair_gen_var_1,\n    )\n}\n\n// -- (Vec<Natural>, Natural) --\n\n// All `(Vec<Natural>, Natural)` where the second element of the pair is `Large` and every element\n// of the `Vec` is smaller than that second element.\npub fn natural_vec_natural_pair_gen_var_1() -> Generator<(Vec<Natural>, Natural)> {\n    Generator::new(\n        &exhaustive_natural_vec_natural_pair_gen_var_1,\n        &random_natural_vec_natural_pair_gen_var_1,\n        &special_random_natural_vec_natural_pair_gen_var_3,\n    )\n}\n\n// All `(Vec<Natural>, Natural)` where the second element of the pair is at least 2, and every\n// element of the `Vec` is smaller than the second element of the pair.\npub fn natural_vec_natural_pair_gen_var_2() -> Generator<(Vec<Natural>, Natural)> {\n    Generator::new(\n        &exhaustive_natural_vec_natural_pair_gen_var_2,\n        &random_natural_vec_natural_pair_gen_var_2,\n        &striped_random_natural_vec_natural_pair_gen_var_4,\n    )\n}\n\n// All `(Vec<Natural>, Natural)` where the second element of the pair is `Large`.\npub fn natural_vec_natural_pair_gen_var_3() -> Generator<(Vec<Natural>, Natural)> {\n    Generator::new(\n        &exhaustive_natural_vec_natural_pair_gen_var_3,\n        &random_natural_vec_natural_pair_gen_var_3,\n        &special_random_natural_vec_natural_pair_gen_var_1,\n    )\n}\n\n// All `(Vec<Natural>, Natural)` where the second element of the pair is at least 2.\npub fn natural_vec_natural_pair_gen_var_4() -> Generator<(Vec<Natural>, Natural)> {\n    Generator::new(\n        &exhaustive_natural_vec_natural_pair_gen_var_4,\n        &random_natural_vec_natural_pair_gen_var_4,\n        &special_random_natural_vec_natural_pair_gen_var_2,\n    )\n}\n\n// -- (Vec<Natural>, PrimitiveUnsigned) --\n\n// All `(Vec<Natural>, u64)`, where the `u64` is positive and each `Natural` in the `Vec` is less\n// than 2 to the power of the `u64`.\npub fn natural_vec_unsigned_pair_gen_var_1() -> Generator<(Vec<Natural>, u64)> {\n    Generator::new(\n        &exhaustive_natural_vec_unsigned_pair_gen_var_1,\n        &random_natural_vec_unsigned_pair_gen_var_1,\n        &special_random_natural_vec_unsigned_pair_gen_var_1,\n    )\n}\n\n// All `(Vec<Natural>, T)`, where the `T` is small and positive.\npub fn natural_vec_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Vec<Natural>, T)> {\n    Generator::new(\n        &exhaustive_natural_vec_primitive_int_pair_gen_var_1,\n        &random_natural_vec_unsigned_pair_gen_var_2,\n        &special_random_natural_vec_unsigned_pair_gen_var_2,\n    )\n}\n\n// -- Vec<PrimitiveUnsigned> --\n\n// vars 1 through 4 are in malachite-base.\n\n// All `Vec<Limb>` that are nonempty and represent a `Natural` divisible by 3.\npub fn unsigned_vec_gen_var_5() -> Generator<Vec<Limb>> {\n    Generator::new(\n        &exhaustive_unsigned_vec_gen_var_5,\n        &random_unsigned_vec_gen_var_1,\n        &special_random_unsigned_vec_gen_var_5,\n    )\n}\n\n// var 6 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// vars 1 through 3 are in malachite-base\n\n// All `(Vec<T>, T>)` where `T` is unsigned, the `Vec` has at least two elements, and the `T` is\n// greater than 1 and exactly convertible to the unsigned type `U`.\npub fn unsigned_vec_unsigned_pair_gen_var_4<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<T>, T)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_4::<T, U>,\n        &random_unsigned_vec_unsigned_pair_gen_var_8::<T, U>,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_4::<T, U>,\n    )\n}\n\n// vars 5 through 20 are in malachite-base\n\n// All `(Vec<Limb>, u64)` where the `u64` is small and `limbs_slice_clear_bit_neg` applied to the\n// `Vec` and `u64` doesn't panic.\npub fn unsigned_vec_unsigned_pair_gen_var_21() -> Generator<(Vec<Limb>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_18,\n        &random_unsigned_vec_unsigned_pair_gen_var_9,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_18,\n    )\n}\n\n// vars 22 through 28 are in malachite-base.\n\n// All `(Vec<Limb>, Limb)` where the `Vec` is nonempty and represents a `Natural` divisible by the\n// `Limb`, and the `Limb` is positive.\npub fn unsigned_vec_unsigned_pair_gen_var_29() -> Generator<(Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_19,\n        &random_unsigned_vec_unsigned_pair_gen_var_10,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_26,\n    )\n}\n\n// All `(Vec<Limb>, u64)` where the `u64` is small, the `Vec` ends with a nonzero element, and the\n// number of significant bits of the `Vec` is less than or equal to the `u64`.\npub fn unsigned_vec_unsigned_pair_gen_var_30() -> Generator<(Vec<Limb>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_pair_gen_var_20,\n        &random_unsigned_vec_unsigned_pair_gen_var_11,\n        &special_random_unsigned_vec_unsigned_pair_gen_var_27,\n    )\n}\n\n// vars 31 through 32 are in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// vars 1 through 5 are in malachite-base\n\n// All `(Vec<Limb>, Limb, Limb)`s where both `Limb`s are positive, the `Vec` contains at least two\n// elements, its last element is nonzero, and the first `Limb` is not equal to the second `Limb` mod\n// the `Natural` represented by the `Vec`.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_6() -> Generator<(Vec<Limb>, Limb, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_6,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_6,\n    )\n}\n\n// vars 7 through 8 are in malachite-base.\n\n// All `(Vec<Limb>, Limb, Limb)`s where the first `Limb` is a factor of `Limb::MAX`.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_9() -> Generator<(Vec<Limb>, Limb, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_9,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_9,\n    )\n}\n\n// var 10 is in malachite-base.\n\n// All triples of `(Vec<Limb>, Limb, Limb)` that are valid inputs to `limbs_eq_limb_mod_limb`, such\n// that `limbs_eq_limb_mod_limb` would return `true`.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_11() -> Generator<(Vec<Limb>, Limb, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_11,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_4,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_11,\n    )\n}\n\n// All triples of `(Vec<Limb>, Limb, Limb)` that are valid inputs to `limbs_eq_limb_mod_limb`, such\n// that `limbs_eq_limb_mod_limb` would return `false`.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_12() -> Generator<(Vec<Limb>, Limb, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_12,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_5,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_12,\n    )\n}\n\n// var 13 is in malachite-base.\n\n// All `(Vec<Limb>, T, u64)` where `T` is unsigned, the `u64` is small, and the number of\n// significant bits of both the `Vec` and the `Limb` are less than or equal to the `u64`.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_14<T: PrimitiveUnsigned>()\n-> Generator<(Vec<Limb>, T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_14,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_6,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_14,\n    )\n}\n\n// All `(Vec<Limb>, T, u64)` where `T` is unsigned, the `Vec` is nonempty, the `u64` is small, and\n// the number of significant bits of both the `Vec` and the `Limb` are less than or equal to the\n// `u64`.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_15<T: PrimitiveUnsigned>()\n-> Generator<(Vec<Limb>, T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_15,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_7,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_14,\n    )\n}\n\n// All `(Vec<Limb>, T, u64)` where `T` is unsigned, the `u64` is small and positive, and the number\n// of significant bits of both the `Vec` and the `Limb` are less than or equal to the `u64`.\npub fn unsigned_vec_unsigned_unsigned_triple_gen_var_16<T: PrimitiveUnsigned>()\n-> Generator<(Vec<Limb>, T, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_triple_gen_var_16,\n        &random_unsigned_vec_unsigned_unsigned_triple_gen_var_8,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_16,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>) --\n\n// All `(Vec<T>, u64, Vec<Limb>)` that are valid inputs to `limbs_to_digits_small_base`.\npub fn unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, u64, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1,\n    )\n}\n\n// All triples of `(Vec<Limb>, Limb, Vec<Limb>)` that are valid inputs to\n// `limbs_pos_eq_neg_limb_mod`, such that `limbs_pos_eq_neg_limb_mod` would return `true`.\npub fn unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2()\n-> Generator<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2,\n    )\n}\n\n// All triples of `(Vec<Limb>, Limb, Vec<Limb>)` that are valid inputs to\n// `limbs_pos_eq_neg_limb_mod`, such that `limbs_pos_eq_neg_limb_mod` would return `false`.\npub fn unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3()\n-> Generator<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3,\n    )\n}\n\n// All triples of `(Vec<Limb>, Limb, Vec<Limb>)` that are valid inputs to `limbs_eq_limb_mod`, such\n// that `limbs_eq_limb_mod` would return `true`.\npub fn unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4()\n-> Generator<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4,\n    )\n}\n\n// All triples of `(Vec<Limb>, Limb, Vec<Limb>)` that are valid inputs to `limbs_eq_limb_mod`, such\n// that `limbs_eq_limb_mod` would return `false`.\npub fn unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5()\n-> Generator<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// All `(Vec<T>, usize, Vec<Limb>, u64)` that are valid inputs to\n// `limbs_to_digits_small_base_basecase`.\npub fn unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Vec<T>, usize, Vec<Limb>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1,\n        &random_primitive_int_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1,\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// vars 1 through 9 are in malachite-base.\n\n// All `(Vec<Limb>, Vec<Limb>)` where each `Vec` has length at least 2 and ends in a nonzero value,\n// the first `Vec` represents an integer at least as large as the second, and the first elements of\n// each `Vec` are not both even.\npub fn unsigned_vec_pair_gen_var_10() -> Generator<(Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_11,\n        &random_primitive_int_vec_pair_gen_var_9,\n        &special_random_unsigned_vec_pair_gen_var_11,\n    )\n}\n\n// vars 11 through 12 are in malachite-base.\n\n// All `(Vec<Limb>, Vec<Limb>)` where the first `Vec` is at least as long as the second and the\n// second `Vec` is nonempty and represents a `Natural` divisible by 3.\npub fn unsigned_vec_pair_gen_var_13() -> Generator<(Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_14,\n        &random_unsigned_vec_pair_gen_var_3,\n        &special_random_unsigned_vec_pair_gen_var_14,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>)` that are valid inputs to `limbs_div_exact`.\npub fn unsigned_vec_pair_gen_var_14() -> Generator<(Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_15,\n        &random_unsigned_vec_pair_gen_var_4,\n        &special_random_unsigned_vec_pair_gen_var_15,\n    )\n}\n\n// vars 15 through 16 are in malachite-base.\n\n// All `(Vec<Limb>, Vec<Limb>)` that are valid inputs to `limbs_div_exact` and `limbs_divisible_by`.\npub fn unsigned_vec_pair_gen_var_17() -> Generator<(Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_18,\n        &random_primitive_int_vec_pair_gen_var_14,\n        &special_random_unsigned_vec_pair_gen_var_18,\n    )\n}\n\n// vars 18 through 20 are in malachite-base.\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to\n// `limbs_square_low_basecase`.\npub fn unsigned_vec_pair_gen_var_21<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_22,\n        &random_primitive_int_vec_pair_gen_var_16,\n        &special_random_unsigned_vec_pair_gen_var_22,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to\n// `limbs_square_to_out_basecase`.\npub fn unsigned_vec_pair_gen_var_22<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_23,\n        &random_primitive_int_vec_pair_gen_var_17,\n        &special_random_unsigned_vec_pair_gen_var_23,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to\n// `limbs_square_to_out_toom_2`.\npub fn unsigned_vec_pair_gen_var_23<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_24,\n        &random_primitive_int_vec_pair_gen_var_18,\n        &special_random_unsigned_vec_pair_gen_var_24,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to\n// `limbs_square_to_out_toom_3`.\npub fn unsigned_vec_pair_gen_var_24<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_25,\n        &random_primitive_int_vec_pair_gen_var_19,\n        &special_random_unsigned_vec_pair_gen_var_25,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to\n// `limbs_square_to_out_toom_4`.\npub fn unsigned_vec_pair_gen_var_25<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_26,\n        &random_primitive_int_vec_pair_gen_var_20,\n        &special_random_unsigned_vec_pair_gen_var_26,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to both\n// `limbs_square_to_out_toom_3` and `limbs_square_to_out_toom_4`.\npub fn unsigned_vec_pair_gen_var_26<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_27,\n        &random_primitive_int_vec_pair_gen_var_21,\n        &special_random_unsigned_vec_pair_gen_var_27,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to\n// `limbs_square_to_out_toom_6`.\npub fn unsigned_vec_pair_gen_var_27<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_28,\n        &random_primitive_int_vec_pair_gen_var_22,\n        &special_random_unsigned_vec_pair_gen_var_28,\n    )\n}\n\n// All `(Vec<T>, Vec<T>)` where `T` is unsigned and `out` and `xs` are valid inputs to\n// `limbs_square_to_out_toom_8`.\npub fn unsigned_vec_pair_gen_var_28<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_pair_gen_var_29,\n        &random_primitive_int_vec_pair_gen_var_23,\n        &special_random_unsigned_vec_pair_gen_var_29,\n    )\n}\n\n// vars 31 to 32 are in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// var 1 is in malachite-base\n\n// All `(Vec<U>, Vec<T>, u64)` that are valid, `Some`-returning inputs to\n// `limbs_from_digits_small_base_basecase`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<U>, Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2,\n        &random_primitive_int_vec_unsigned_vec_unsigned_triple_gen_var_1,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2,\n    )\n}\n\n// All `(Vec<U>, Vec<T>, u64)` that are inputs to `limbs_from_digits_small_base_basecase`,\n// regardless of whether they return `Some` or `None`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>() -> Generator<(Vec<U>, Vec<T>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3,\n        &random_primitive_int_vec_unsigned_vec_unsigned_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3,\n    )\n}\n\n// vars 4 through 6 are in malachite-base.\n\n// All triples of `(Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_pos_eq_neg_mod_limb`, such that `limbs_pos_eq_neg_mod_limb` would return `true`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7()\n-> Generator<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7,\n        &random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7,\n    )\n}\n\n// All triples of `(Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_pos_eq_neg_mod_limb`, such that `limbs_pos_eq_neg_mod_limb` would return `false`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_8()\n-> Generator<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_8,\n        &random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_8,\n    )\n}\n\n// vars 9 through 13 are in malachite-base.\n\n// All `(Vec<T>, Vec<T>, T)` where `T` is unsigned and positive, the first `Vec` is at least as long\n// as the second, and the second `Vec` is nonempty and represents a `Natural` divisible by the\n// `Limb`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14()\n-> Generator<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14,\n        &random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n        &special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14,\n    )\n}\n\n// All triples of `(Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to `limbs_eq_limb_mod`, such\n// that `limbs_eq_limb_mod` would return `true`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_15()\n-> Generator<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_15,\n        &random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_15,\n    )\n}\n\n// All triples of `(Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to `limbs_eq_limb_mod`, such\n// that `limbs_eq_limb_mod` would return `false`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_16()\n-> Generator<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_16,\n        &random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_16,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to `limbs_mod_schoolbook`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_17()\n-> Generator<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_17,\n        &random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7,\n        &special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_17,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, u64)` where the `u64` is small and the number of significant bits of\n// both `Vec`s are less than or equal to the `u64`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18()\n-> Generator<(Vec<Limb>, Vec<Limb>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_7,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_18,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, u64)` where the `u64` is small, the first `Vec` is at least as long\n// as the second, and the number of significant bits of both `Vec`s are less than or equal to the\n// `u64`.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19()\n-> Generator<(Vec<Limb>, Vec<Limb>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_8,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_19,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, u64)` where the `u64` is small, the number of significant bits of\n// both `Vec`s are less than or equal to the `u64`, and both `Vec`s end with a nonzero value.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20()\n-> Generator<(Vec<Limb>, Vec<Limb>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_9,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_20,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, u64)` that are valid inputs to `limbs_mod_power_of_2_pow`, and where\n// the `u64` is small.\npub fn unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21()\n-> Generator<(Vec<Limb>, Vec<Limb>, u64)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21,\n        &random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_10,\n        &special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_21,\n    )\n}\n\n// vars 22 through 23 are in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned> --\n\n// vars 1 through 3 are in malachite-base\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_22`.\npub fn unsigned_vec_triple_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_4,\n        &random_primitive_int_vec_triple_gen_var_4,\n        &special_random_unsigned_vec_triple_gen_var_4,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_32`.\npub fn unsigned_vec_triple_gen_var_5<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_5,\n        &random_primitive_int_vec_triple_gen_var_5,\n        &special_random_unsigned_vec_triple_gen_var_5,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_33`.\npub fn unsigned_vec_triple_gen_var_6<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_6,\n        &random_primitive_int_vec_triple_gen_var_6,\n        &special_random_unsigned_vec_triple_gen_var_6,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_42`.\npub fn unsigned_vec_triple_gen_var_7<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_7,\n        &random_primitive_int_vec_triple_gen_var_7,\n        &special_random_unsigned_vec_triple_gen_var_7,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_43`.\npub fn unsigned_vec_triple_gen_var_8<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_8,\n        &random_primitive_int_vec_triple_gen_var_8,\n        &special_random_unsigned_vec_triple_gen_var_8,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_44`.\npub fn unsigned_vec_triple_gen_var_9<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_9,\n        &random_primitive_int_vec_triple_gen_var_9,\n        &special_random_unsigned_vec_triple_gen_var_9,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_52`.\npub fn unsigned_vec_triple_gen_var_10<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_10,\n        &random_primitive_int_vec_triple_gen_var_10,\n        &special_random_unsigned_vec_triple_gen_var_10,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_53`.\npub fn unsigned_vec_triple_gen_var_11<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_11,\n        &random_primitive_int_vec_triple_gen_var_11,\n        &special_random_unsigned_vec_triple_gen_var_11,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_54`.\npub fn unsigned_vec_triple_gen_var_12<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_12,\n        &random_primitive_int_vec_triple_gen_var_12,\n        &special_random_unsigned_vec_triple_gen_var_12,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_62`.\npub fn unsigned_vec_triple_gen_var_13<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_13,\n        &random_primitive_int_vec_triple_gen_var_13,\n        &special_random_unsigned_vec_triple_gen_var_13,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_63`.\npub fn unsigned_vec_triple_gen_var_14<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_14,\n        &random_primitive_int_vec_triple_gen_var_14,\n        &special_random_unsigned_vec_triple_gen_var_14,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_6h`.\npub fn unsigned_vec_triple_gen_var_15<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_15,\n        &random_primitive_int_vec_triple_gen_var_15,\n        &special_random_unsigned_vec_triple_gen_var_15,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_8h`.\npub fn unsigned_vec_triple_gen_var_16<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_16,\n        &random_primitive_int_vec_triple_gen_var_16,\n        &special_random_unsigned_vec_triple_gen_var_16,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_33`, and\n// where the second and third `Vec`s have the same length.\npub fn unsigned_vec_triple_gen_var_18<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_18,\n        &random_primitive_int_vec_triple_gen_var_18,\n        &special_random_unsigned_vec_triple_gen_var_18,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_6h`, and\n// where the second and third `Vec`s have the same length.\npub fn unsigned_vec_triple_gen_var_19<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_19,\n        &random_primitive_int_vec_triple_gen_var_19,\n        &special_random_unsigned_vec_triple_gen_var_19,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to `limbs_mul_greater_to_out_toom_8h`, and\n// where the second and third `Vec`s have the same length.\npub fn unsigned_vec_triple_gen_var_20<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_20,\n        &random_primitive_int_vec_triple_gen_var_20,\n        &special_random_unsigned_vec_triple_gen_var_20,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to both `limbs_mul_greater_to_out_toom_32`\n// and `limbs_mul_greater_to_out_toom_43`.\npub fn unsigned_vec_triple_gen_var_22<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_22,\n        &random_primitive_int_vec_triple_gen_var_22,\n        &special_random_unsigned_vec_triple_gen_var_22,\n    )\n}\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to both `limbs_mul_greater_to_out_toom_42`\n// and `limbs_mul_greater_to_out_toom_53`.\npub fn unsigned_vec_triple_gen_var_23<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_23,\n        &random_primitive_int_vec_triple_gen_var_23,\n        &special_random_unsigned_vec_triple_gen_var_23,\n    )\n}\n\n// vars 24 through 36 are in malachite-base\n\n// All triples of `Vec<Limb>` that meet the preconditions for `limbs_eq_mod`, where the `Natural`\n// represented by the first `Vec` is equal to the negative of `Natural` represented by the second\n// `Vec` mod the `Natural` represented by the third `Vec`.\npub fn unsigned_vec_triple_gen_var_37() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_37,\n        &random_primitive_int_vec_triple_gen_var_36,\n        &special_random_unsigned_vec_triple_gen_var_37,\n    )\n}\n\n// All triples of `Vec<Limb>` that meet the preconditions for `limbs_eq_mod`, where the `Natural`\n// represented by the first `Vec` is not equal to the negative of `Natural` represented by the\n// second `Vec` mod the `Natural` represented by the third `Vec`.\npub fn unsigned_vec_triple_gen_var_38() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_38,\n        &random_primitive_int_vec_triple_gen_var_37,\n        &special_random_unsigned_vec_triple_gen_var_38,\n    )\n}\n\n// vars 39 through 41 are in malachite-base.\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_div_barrett_approx`.\npub fn unsigned_vec_triple_gen_var_42() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_42,\n        &random_unsigned_vec_triple_gen_var_1,\n        &special_random_unsigned_vec_triple_gen_var_42,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_div_barrett`.\npub fn unsigned_vec_triple_gen_var_43() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_43,\n        &random_unsigned_vec_triple_gen_var_2,\n        &special_random_unsigned_vec_triple_gen_var_43,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_div_to_out`.\npub fn unsigned_vec_triple_gen_var_44() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_44,\n        &random_unsigned_vec_triple_gen_var_3,\n        &special_random_unsigned_vec_triple_gen_var_44,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_div_to_out` and both the balanced and\n// unbalanced div helper functions.\npub fn unsigned_vec_triple_gen_var_45() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_45,\n        &random_unsigned_vec_triple_gen_var_4,\n        &special_random_unsigned_vec_triple_gen_var_45,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_modular_div_barrett`.\npub fn unsigned_vec_triple_gen_var_46() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_46,\n        &random_unsigned_vec_triple_gen_var_5,\n        &special_random_unsigned_vec_triple_gen_var_46,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_modular_div`.\npub fn unsigned_vec_triple_gen_var_47() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_47,\n        &random_unsigned_vec_triple_gen_var_6,\n        &special_random_unsigned_vec_triple_gen_var_47,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_div_exact_to_out`.\npub fn unsigned_vec_triple_gen_var_48() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_48,\n        &random_unsigned_vec_triple_gen_var_7,\n        &special_random_unsigned_vec_triple_gen_var_48,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to both `limbs_div_to_out` and\n// `limbs_div_exact_to_out`.\npub fn unsigned_vec_triple_gen_var_49() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_49,\n        &random_unsigned_vec_triple_gen_var_8,\n        &special_random_unsigned_vec_triple_gen_var_49,\n    )\n}\n\n// vars 50 through 53 are in malachite-base.\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_eq_mod`, such that `limbs_eq_mod`\n// would return `true`.\npub fn unsigned_vec_triple_gen_var_54() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_54,\n        &random_unsigned_vec_triple_gen_var_11,\n        &special_random_unsigned_vec_triple_gen_var_54,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_eq_mod`, such that `limbs_eq_mod`\n// would return `false`.\npub fn unsigned_vec_triple_gen_var_55() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_55,\n        &random_unsigned_vec_triple_gen_var_12,\n        &special_random_unsigned_vec_triple_gen_var_55,\n    )\n}\n\n// All triples of `Vec<Limb>` that are valid inputs to `limbs_div_mod_by_two_limb_normalized`.\npub fn unsigned_vec_triple_gen_var_56() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_56,\n        &random_unsigned_vec_triple_gen_var_13,\n        &special_random_unsigned_vec_triple_gen_var_56,\n    )\n}\n\n// var 57 is in malachite-base.\n\n// All `(Vec<T>, Vec<T>, Vec<T>)` that are valid inputs to both `limbs_mul_greater_to_out_toom_33`\n// and `limbs_mul_greater_to_out_toom_33`.\npub fn unsigned_vec_triple_gen_var_58<T: PrimitiveUnsigned>() -> Generator<(Vec<T>, Vec<T>, Vec<T>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_triple_gen_var_58,\n        &random_primitive_int_vec_triple_gen_var_45,\n        &special_random_unsigned_vec_triple_gen_var_58,\n    )\n}\n\n// var 59 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned> * 4) --\n\n// All quadruples of `Vec<Limb>` that are valid inputs to `limbs_div_mod_to_out`.\n#[allow(clippy::type_complexity)]\npub fn unsigned_vec_quadruple_gen_var_1() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_quadruple_gen_var_1,\n        &random_unsigned_vec_quadruple_gen_var_1,\n        &special_random_unsigned_vec_quadruple_gen_var_1,\n    )\n}\n\n// All quadruples of `Vec<Limb>` that are valid inputs to `limbs_modular_div_mod_barrett`.\n#[allow(clippy::type_complexity)]\npub fn unsigned_vec_quadruple_gen_var_2() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_quadruple_gen_var_2,\n        &random_unsigned_vec_quadruple_gen_var_2,\n        &special_random_unsigned_vec_quadruple_gen_var_2,\n    )\n}\n\n// All quadruples of `Vec<Limb>` that are valid inputs to `limbs_modular_div_mod_barrett`, and the\n// first, second and third `Vec`s would meet the preconditions of\n// `limbs_modular_div_mod_divide_and_conquer`, given the correct `inverse`.\n#[allow(clippy::type_complexity)]\npub fn unsigned_vec_quadruple_gen_var_3() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_quadruple_gen_var_3,\n        &random_unsigned_vec_quadruple_gen_var_3,\n        &special_random_unsigned_vec_quadruple_gen_var_3,\n    )\n}\n\n// All quadruples of `Vec<Limb>` that meet certain preconditions that enable comparing the\n// performance of two kinds of Barrett division.\n#[allow(clippy::type_complexity)]\npub fn unsigned_vec_quadruple_gen_var_4() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_quadruple_gen_var_4,\n        &random_unsigned_vec_quadruple_gen_var_4,\n        &special_random_unsigned_vec_quadruple_gen_var_4,\n    )\n}\n\n// All quadruples of `Vec<Limb>` that are valid inputs to `limbs_div_mod_barrett`.\n#[allow(clippy::type_complexity)]\npub fn unsigned_vec_quadruple_gen_var_5() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_quadruple_gen_var_5,\n        &random_unsigned_vec_quadruple_gen_var_5,\n        &special_random_unsigned_vec_quadruple_gen_var_5,\n    )\n}\n\n// All quadruples of `Vec<Limb>` that are valid inputs to `limbs_mod_pow`.\n#[allow(clippy::type_complexity)]\npub fn unsigned_vec_quadruple_gen_var_6() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_quadruple_gen_var_6,\n        &random_unsigned_vec_quadruple_gen_var_6,\n        &special_random_unsigned_vec_quadruple_gen_var_6,\n    )\n}\n\n// All quadruples of `Vec<Limb>` that are valid inputs to `limbs_mod_pow_odd`.\n#[allow(clippy::type_complexity)]\npub fn unsigned_vec_quadruple_gen_var_7() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)>\n{\n    Generator::new(\n        &exhaustive_unsigned_vec_quadruple_gen_var_7,\n        &random_unsigned_vec_quadruple_gen_var_7,\n        &special_random_unsigned_vec_quadruple_gen_var_7,\n    )\n}\n\n// -- large types --\n\n// vars 1 through 4 are in malachite-base\n\n// All `(HalfGcdMatrix, Vec<Limb>, u8)` that are valid inputs to `HalfGcdMatrix::update_q`.\npub fn large_type_gen_var_5() -> Generator<(OwnedHalfGcdMatrix, Vec<Limb>, u8)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_5,\n        &random_large_type_gen_var_5,\n        &special_random_large_type_gen_var_5,\n    )\n}\n\n// All `(HalfGcdMatrix1, Vec<Limb>, Vec<Limb>, Vec<Limb>)` that are valid inputs to\n// `HalfGcdMatrix1::mul_vector`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_6() -> Generator<(HalfGcdMatrix1, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_6,\n        &random_large_type_gen_var_6,\n        &special_random_large_type_gen_var_6,\n    )\n}\n\n// All `(HalfGcdMatrix, HalfGcdMatrix1)` that are valid inputs to `HalfGcdMatrix::mul_matrix_1`.\npub fn large_type_gen_var_7() -> Generator<(OwnedHalfGcdMatrix, HalfGcdMatrix1)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_7,\n        &random_large_type_gen_var_7,\n        &special_random_large_type_gen_var_7,\n    )\n}\n\n// All valid inputs to `limbs_matrix_mul_2_2`.\npub fn large_type_gen_var_8() -> Generator<T8> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_8,\n        &random_large_type_gen_var_8,\n        &special_random_large_type_gen_var_8,\n    )\n}\n\n// var 9 is in malachite-base.\n\n#[cfg(feature = \"32_bit_limbs\")]\nconst PRIME_FACTORS_OF_LIMB_MAX: &[Limb] = &[3, 5, 17, 257, 65_537];\n#[cfg(not(feature = \"32_bit_limbs\"))]\nconst PRIME_FACTORS_OF_LIMB_MAX: &[Limb] = &[3, 5, 17, 257, 641, 65_537, 6_700_417];\n\npub(crate) fn factors_of_limb_max() -> Vec<Limb> {\n    lex_ordered_unique_vecs(PRIME_FACTORS_OF_LIMB_MAX.iter())\n        .map(|pfs| pfs.into_iter().product())\n        .collect()\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Limb, Limb)` where the first `Vec` is at least as long as the second,\n// and the first `Limb` is a divisor of `Limb::MAX`.\npub fn large_type_gen_var_10() -> Generator<(Vec<Limb>, Vec<Limb>, Limb, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_10,\n        &random_large_type_gen_var_10,\n        &special_random_large_type_gen_var_10,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_div_mod_schoolbook`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_11() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_11,\n        &random_large_type_gen_var_11,\n        &special_random_large_type_gen_var_11,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_div_mod_divide_and_conquer`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_12() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_12,\n        &random_large_type_gen_var_12,\n        &special_random_large_type_gen_var_12,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_modular_div_schoolbook`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_13() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_13,\n        &random_large_type_gen_var_13,\n        &special_random_large_type_gen_var_13,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_modular_div_mod_schoolbook`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_14() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_14,\n        &random_large_type_gen_var_14,\n        &special_random_large_type_gen_var_14,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_modular_div_mod_divide_and_conquer`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_15() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_15,\n        &random_large_type_gen_var_15,\n        &special_random_large_type_gen_var_15,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_modular_div_divide_and_conquer`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_16() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_16,\n        &random_large_type_gen_var_16,\n        &special_random_large_type_gen_var_16,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)` that are valid inputs to\n// `limbs_modular_invert_small`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_17() -> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_17,\n        &random_large_type_gen_var_17,\n        &special_random_large_type_gen_var_17,\n    )\n}\n\n// All `(Vec<Limb>, usize, Limb, Limb, u64)` that are valid inputs to\n// `limbs_div_mod_extra_in_place`.\npub fn large_type_gen_var_18() -> Generator<(Vec<Limb>, usize, Limb, Limb, u64)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_18,\n        &random_large_type_gen_var_18,\n        &special_random_large_type_gen_var_18,\n    )\n}\n\n// All `(Vec<Limb>, usize, Vec<Limb>, Limb, Limb, u64)` that are valid inputs to\n// `limbs_div_mod_extra`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_19() -> Generator<(Vec<Limb>, usize, Vec<Limb>, Limb, Limb, u64)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_19,\n        &random_large_type_gen_var_19,\n        &special_random_large_type_gen_var_19,\n    )\n}\n\n// All `(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>, usize, usize)` that are valid inputs to\n// `limbs_div_barrett_large_product`.\n#[allow(clippy::type_complexity)]\npub fn large_type_gen_var_20()\n-> Generator<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>, usize, usize)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_20,\n        &random_large_type_gen_var_20,\n        &special_random_large_type_gen_var_20,\n    )\n}\n\n#[allow(clippy::type_complexity)]\n/// All nonuples of `Limb`s that are valid inputs to `limbs_mod_mul_two_limbs`.\npub fn large_type_gen_var_21() -> Generator<(Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb)>\n{\n    Generator::new(\n        &exhaustive_large_type_gen_var_21,\n        &random_large_type_gen_var_21,\n        &special_random_large_type_gen_var_21,\n    )\n}\n\n// var 22 is in malachite-base.\n\n/// All `(u64, Vec<Natural>, RationalSequence<Natural>)` that are valid inputs to\n/// `Rational::from_power_of_2_digits`.\npub fn large_type_gen_var_23() -> Generator<(u64, Vec<Natural>, RationalSequence<Natural>)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_23,\n        &random_large_type_gen_var_23,\n        &special_random_large_type_gen_var_23,\n    )\n}\n\n/// All `(Vec<Natural>, RationalSequence<Natural>)` that are valid inputs to\n/// `Rational::from_power_of_2_digits` with `log_base` == 1.\npub fn large_type_gen_var_24() -> Generator<(Vec<Natural>, RationalSequence<Natural>)> {\n    Generator::new_no_special(\n        &exhaustive_large_type_gen_var_24,\n        &random_large_type_gen_var_24,\n    )\n}\n\n/// All `(u64, Vec<Natural>, RationalSequence<Natural>)` that are valid inputs to\n/// `Rational::from_digits`.\npub fn large_type_gen_var_25() -> Generator<(Natural, Vec<Natural>, RationalSequence<Natural>)> {\n    Generator::new(\n        &exhaustive_large_type_gen_var_25,\n        &random_large_type_gen_var_25,\n        &special_random_large_type_gen_var_24,\n    )\n}\n\n/// All `(Vec<Natural>, RationalSequence<Natural>)` that are valid inputs to `Rational::from_digits`\n/// with `base` == 10.\npub fn large_type_gen_var_26() -> Generator<(Vec<Natural>, RationalSequence<Natural>)> {\n    Generator::new_no_special(\n        &exhaustive_large_type_gen_var_26,\n        &random_large_type_gen_var_26,\n    )\n}\n\n// var 27 is in malachite-base.\n\npub mod common;\npub mod exhaustive;\npub mod random;\npub mod special_random;\n"
  },
  {
    "path": "malachite-nz/src/test_util/generators/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::logic::bit_access::limbs_vec_clear_bit_neg;\nuse crate::integer::random::{\n    RandomIntegers, random_integers, random_natural_integers, random_negative_integers,\n    random_nonzero_integers,\n};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::binomial_coefficient::BIN_GOETGHELUCK_THRESHOLD;\nuse crate::natural::arithmetic::binomial_coefficient::BIN_UIUI_RECURSIVE_SMALLDC;\nuse crate::natural::arithmetic::div_exact::{\n    limbs_modular_invert_limb, limbs_modular_invert_scratch_len,\n};\nuse crate::natural::arithmetic::div_mod::{\n    limbs_div_mod_barrett_is_len, limbs_div_mod_barrett_scratch_len, limbs_invert_limb,\n    limbs_two_limb_inverse_helper,\n};\nuse crate::natural::arithmetic::eq_mod::limbs_eq_mod_ref_ref_ref;\nuse crate::natural::arithmetic::gcd::half_gcd::HalfGcdMatrix1;\nuse crate::natural::arithmetic::mod_power_of_2::limbs_slice_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::mod_power_of_2_square::SQRLO_DC_THRESHOLD_LIMIT;\nuse crate::natural::arithmetic::mul::limb::limbs_vec_mul_limb_in_place;\nuse crate::natural::arithmetic::mul::limbs_mul;\nuse crate::natural::arithmetic::mul::mul_mod::limbs_mul_mod_base_pow_n_minus_1_next_size;\nuse crate::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_22_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_32_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_42_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_43_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_44_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_52_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_53_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_54_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_62_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_63_input_sizes_valid,\n};\nuse crate::natural::arithmetic::square::{\n    limbs_square_to_out_toom_3_input_size_valid, limbs_square_to_out_toom_4_input_size_valid,\n    limbs_square_to_out_toom_6_input_size_valid, limbs_square_to_out_toom_8_input_size_valid,\n};\nuse crate::natural::conversion::digits::general_digits::{\n    GET_STR_PRECOMPUTE_THRESHOLD, limbs_digit_count, limbs_per_digit_in_base,\n};\nuse crate::natural::random::{\n    RandomNaturalRangeToInfinity, RandomNaturals, RandomNaturalsLessThan,\n    get_random_natural_with_bits, get_random_natural_with_up_to_bits,\n    random_natural_range_to_infinity, random_naturals, random_naturals_less_than,\n    random_positive_naturals,\n};\nuse crate::platform::{\n    DoubleLimb, Limb, ODD_CENTRAL_BINOMIAL_OFFSET, ODD_CENTRAL_BINOMIAL_TABLE_LIMIT,\n    ODD_FACTORIAL_EXTTABLE_LIMIT, ODD_FACTORIAL_TABLE_LIMIT, SQR_TOOM2_THRESHOLD,\n};\nuse crate::test_util::extra_variadic::{\n    random_quadruples_from_single, random_quadruples_xxxy, random_quadruples_xyxz,\n    random_quadruples_xyyx, random_quadruples_xyyz, random_quintuples_xyyyz,\n    random_sextuples_from_single, random_triples, random_triples_from_single, random_triples_xxy,\n    random_triples_xyx, random_triples_xyy,\n};\nuse crate::test_util::generators::exhaustive::{\n    filter_helper_1, filter_helper_2, filter_helper_3, filter_helper_4, filter_helper_5,\n    filter_helper_6, filter_map_helper_1, filter_map_helper_2, filter_map_helper_3,\n    gcd_input_filter, large_type_filter_map_1, limbs_eq_mod_map, limbs_significant_bits_helper,\n    map_helper_1, map_helper_2, map_helper_3, round_to_multiple_integer_filter_map,\n    round_to_multiple_natural_filter_map,\n};\nuse crate::test_util::generators::{T8, factors_of_limb_max, limbs_odd_factorial_valid};\nuse crate::test_util::natural::arithmetic::gcd::{OwnedHalfGcdMatrix, half_gcd_matrix_create};\nuse itertools::Itertools;\nuse malachite_base::bools::random::{RandomBools, random_bools};\nuse malachite_base::iterators::with_special_value;\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, CeilingLogBase2, CoprimeWith, DivRound, DivisibleBy, DivisibleByPowerOf2,\n    EqMod, EqModPowerOf2, Parity, PowerOf2, RoundToMultipleOfPowerOf2Assign,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::string::options::random::random_to_sci_options;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, SaturatingFrom, ToSci, WrappingFrom,\n};\nuse malachite_base::num::factorization::prime_sieve::n_to_bit;\nuse malachite_base::num::logic::traits::{\n    BitAccess, BitConvertible, LeadingZeros, SignificantBits,\n};\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomSignedRange, GeometricRandomSigneds,\n    geometric_random_positive_unsigneds, geometric_random_signed_range, geometric_random_signeds,\n    geometric_random_unsigned_inclusive_range, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::{\n    RandomPrimitiveInts, RandomUnsignedBitChunks, RandomUnsignedRange, RandomUnsignedsLessThan,\n    VariableRangeGenerator, random_natural_signeds, random_positive_unsigneds,\n    random_primitive_ints, random_unsigned_bit_chunks, random_unsigned_inclusive_range,\n    random_unsigneds_less_than, special_random_primitive_floats,\n};\nuse malachite_base::options::random::{RandomOptions, random_options};\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::random::random_rounding_modes;\nuse malachite_base::test_util::generators::common::{\n    GenConfig, It, permute_1_3_2, reshape_1_3_to_4, reshape_2_1_to_3, reshape_2_2_to_4,\n};\nuse malachite_base::test_util::generators::random::{\n    PrimitiveIntVecPairLenGenerator1, PrimitiveIntVecPairLenGenerator2,\n    PrimitiveIntVecQuadrupleLenGenerator1, PrimitiveIntVecTripleLenGenerator1,\n    PrimitiveIntVecTripleXYYLenGenerator, get_two_highest,\n    random_primitive_int_vec_unsigned_pair_gen_var_10,\n};\nuse malachite_base::tuples::random::{\n    random_ordered_unique_pairs, random_pairs, random_pairs_from_single,\n};\nuse malachite_base::unions::Union2;\nuse malachite_base::unions::random::random_union2s;\nuse malachite_base::vecs::random::{\n    RandomVecs, random_vecs, random_vecs_length_range, random_vecs_min_length,\n};\nuse malachite_base::vecs::{RandomValuesFromVec, random_values_from_vec};\nuse num::{BigInt, BigUint};\nuse std::cmp::{Ordering::*, max};\nuse std::collections::HashMap;\nuse std::marker::PhantomData;\nuse std::ops::{Shl, Shr};\n\n// -- Integer --\n\npub fn random_integer_gen(config: &GenConfig) -> It<Integer> {\n    Box::new(random_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_integer_gen_var_1<T: PrimitiveFloat>(config: &GenConfig) -> It<Integer> {\n    Box::new(with_special_value(\n        EXAMPLE_SEED,\n        Integer::ZERO,\n        1,\n        100,\n        &|seed| {\n            random_pairs(\n                seed,\n                &|seed_2| {\n                    random_positive_float_naturals::<T>(\n                        seed_2,\n                        0,\n                        config.get_or(\"exponent_mean_n\", 8),\n                        config.get_or(\"exponent_mean_d\", 1),\n                    )\n                },\n                &random_bools,\n            )\n            .map(|(n, b)| Integer::from_sign_and_abs(b, n))\n        },\n    ))\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_integer_gen_var_2<T: PrimitiveFloat>(config: &GenConfig) -> It<Integer>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Natural>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_natural_range_to_infinity(\n                    seed,\n                    Natural::power_of_2(T::MANTISSA_WIDTH + 1) | Natural::ONE,\n                    config.get_or(\"mean_bits_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n                .filter(|n| !T::convertible_from(n))\n            },\n            &random_bools,\n        )\n        .map(|(n, b)| Integer::from_sign_and_abs(b, n)),\n    )\n}\n\npub fn random_integer_gen_var_3<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<Integer>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_positive_float_naturals::<T>(\n                    seed,\n                    1,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                )\n                .filter_map(|a| {\n                    let b = Natural::exact_from(T::exact_from(&a).next_higher());\n                    let diff = b - &a;\n                    if diff.even() {\n                        // This happens almost always\n                        Some(a + (diff >> 1))\n                    } else {\n                        None\n                    }\n                })\n            },\n            &random_bools,\n        )\n        .map(|(n, b)| Integer::from_sign_and_abs(b, n)),\n    )\n}\n\npub fn random_integer_gen_var_4(config: &GenConfig) -> It<Integer> {\n    Box::new(random_natural_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_integer_gen_var_5<T: PrimitiveInt>(_config: &GenConfig) -> It<Integer>\nwhere\n    Integer: From<T>,\n{\n    Box::new(random_primitive_ints(EXAMPLE_SEED).map(Integer::from))\n}\n\npub fn random_integer_gen_var_6(config: &GenConfig) -> It<Integer> {\n    Box::new(random_negative_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_integer_gen_var_7(config: &GenConfig) -> It<Integer> {\n    Box::new(random_nonzero_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_integer_gen_var_8(config: &GenConfig) -> It<Integer> {\n    Box::new(\n        random_natural_integers(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|n| (n << 1u32) | Integer::ONE),\n    )\n}\n\n// -- (Integer, Integer) --\n\npub fn random_integer_pair_gen(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(random_pairs_from_single(random_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_integer_pair_gen_var_1(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_nonzero_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_integer_pair_gen_var_2(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y)| (x * &y, y)),\n    )\n}\n\npub fn random_integer_pair_gen_var_3(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn random_integer_pair_gen_var_4(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_natural_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(a, n)| (a, (n << 1u32) | Integer::ONE)),\n    )\n}\n\npub fn random_integer_pair_gen_var_5(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs_from_single(random_integers(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y)| x.unsigned_abs_ref().coprime_with(y.unsigned_abs_ref())),\n    )\n}\n\npub fn random_integer_pair_gen_var_6(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs_from_single(\n            random_natural_integers(\n                EXAMPLE_SEED,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n            .map(|n| (n << 1u32) | Integer::ONE),\n        )\n        .filter(|(x, y)| x.unsigned_abs_ref().coprime_with(y.unsigned_abs_ref())),\n    )\n}\n\npub fn random_integer_pair_gen_var_7(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds::<Limb>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Integer::from)\n        },\n    ))\n}\n\n// -- (Integer, Integer, Integer) --\n\npub fn random_integer_triple_gen(config: &GenConfig) -> It<(Integer, Integer, Integer)> {\n    Box::new(random_triples_from_single(random_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_integer_triple_gen_var_1(config: &GenConfig) -> It<(Integer, Integer, Integer)> {\n    Box::new(random_triples_from_single(random_natural_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_integer_triple_gen_var_2(config: &GenConfig) -> It<(Integer, Integer, Integer)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_natural_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(a, b, n)| (a, b, (n << 1u32) | Integer::ONE)),\n    )\n}\n\npub fn random_integer_triple_gen_var_3(config: &GenConfig) -> It<(Integer, Integer, Integer)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_natural_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(a, m, n)| (a, (m << 1u32) | Integer::ONE, (n << 1u32) | Integer::ONE)),\n    )\n}\n\n// -- (Integer, Integer, Integer, PrimitiveUnsigned) --\n\npub fn random_integer_integer_integer_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Integer, T)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, Integer, Natural) --\n\npub fn random_integer_integer_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_integer_integer_natural_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Natural)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, m)| (x * Integer::from(&m) + &y, y, m)),\n    )\n}\n\npub fn random_integer_integer_natural_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Natural)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\n// -- (Integer, Integer, PrimitiveFloat) --\n\npub fn random_integer_integer_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Integer, Integer, PrimitiveInt) --\n\npub fn random_integer_integer_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Integer, Integer, PrimitiveUnsigned) --\n\npub fn random_integer_integer_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_integer_integer_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, pow)| ((x << pow) + &y, y, pow)),\n    )\n}\n\npub fn random_integer_integer_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(ref x, ref y, pow)| !x.eq_mod_power_of_2(y, pow.exact_into())),\n    )\n}\n\n// -- (Integer, Integer, RoundingMode) --\n\npub fn random_integer_integer_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, Integer, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(x, y, rm)| {\n            if rm == Exact {\n                (x * &y, y, rm)\n            } else {\n                (x, y, rm)\n            }\n        }),\n    )\n}\n\npub fn random_integer_integer_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, Integer, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_integer_filter_map(x, y, rm)),\n    )\n}\n\n// -- (Integer, Natural) --\n\npub fn random_integer_natural_pair_gen(config: &GenConfig) -> It<(Integer, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, Natural, Natural) --\n\npub fn random_integer_natural_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Integer, Natural, Natural)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveFloat) --\n\npub fn random_integer_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveFloat, PrimitiveFloat) --\n\npub fn random_integer_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveInt) --\n\npub fn random_integer_primitive_int_pair_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Integer, PrimitiveInt, Natural) --\n\npub fn random_integer_primitive_int_natural_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Integer, T, Natural)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveInt, PrimitiveInt) --\n\npub fn random_integer_primitive_int_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Integer, PrimitiveSigned) --\n\npub fn random_integer_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn random_integer_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, RoundingMode) --\n\npub fn random_integer_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shr<T, Output = Integer>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i < T::ZERO && rm == Exact {\n                    n >> i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\npub fn random_integer_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i > T::ZERO && rm == Exact {\n                    n << i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned) --\n\npub fn random_integer_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::from(36u8)),\n    ))\n}\n\npub fn random_integer_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_integer_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_natural_integers(\n                            seed_2,\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_negative_integers(\n                            seed_2,\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds::<T>(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                        .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE))\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_integer_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(mut x, y)| {\n            x.round_to_multiple_of_power_of_2_assign(y.exact_into(), Down);\n            (x, y)\n        }),\n    )\n}\n\npub fn random_integer_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn random_integer_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, bool) --\n\npub fn random_integer_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_integer_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Integer, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::from(36u8)),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_integer_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) }),\n    )\n}\n\npub fn random_integer_unsigned_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\npub fn random_integer_unsigned_unsigned_natural_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, T, Natural)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_integer_unsigned_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<u64>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, u, rm)| {\n            if rm == Exact {\n                (n << u, u, rm)\n            } else {\n                (n, u, rm)\n            }\n        }),\n    )\n}\n\npub fn random_integer_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, u, rm)| (if rm == Exact { n << u } else { n }, u, rm)),\n    )\n}\n\n// vars 3 and 4 are in malachite-float.\n\npub fn random_integer_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (Integer, RoundingMode) --\n\npub fn random_integer_rounding_mode_pair_gen(config: &GenConfig) -> It<(Integer, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_integer_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(Integer, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, rm)| rm != Exact || T::convertible_from(n)),\n    )\n}\n\npub fn random_integer_rounding_mode_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_nonzero_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (Integer, ToSciOptions) --\n\npub fn random_integer_to_sci_options_pair_gen(config: &GenConfig) -> It<(Integer, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"small_mean_n\", 4),\n                config.get_or(\"small_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_integer_to_sci_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_integers(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"small_mean_n\", 4),\n                    config.get_or(\"small_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// --(Integer, Vec<bool>) --\n\nstruct IntegerBoolVecPairGenerator1 {\n    xs: RandomIntegers<GeometricRandomSigneds<i64>>,\n    bs: RandomBools,\n}\n\nimpl Iterator for IntegerBoolVecPairGenerator1 {\n    type Item = (Integer, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Integer, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = (&mut self.bs)\n            .take(x.to_twos_complement_limbs_asc().len())\n            .collect();\n        Some((x, bs))\n    }\n}\n\npub fn random_integer_bool_vec_pair_gen_var_1(config: &GenConfig) -> It<(Integer, Vec<bool>)> {\n    Box::new(IntegerBoolVecPairGenerator1 {\n        xs: random_integers(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\nstruct IntegerBoolVecPairGenerator2 {\n    xs: RandomIntegers<GeometricRandomSigneds<i64>>,\n    bs: RandomBools,\n}\n\nimpl Iterator for IntegerBoolVecPairGenerator2 {\n    type Item = (Integer, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Integer, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = (&mut self.bs).take(x.to_bits_asc().len()).collect();\n        Some((x, bs))\n    }\n}\n\npub fn random_integer_bool_vec_pair_gen_var_2(config: &GenConfig) -> It<(Integer, Vec<bool>)> {\n    Box::new(IntegerBoolVecPairGenerator2 {\n        xs: random_integers(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n// -- Natural --\n\npub fn random_natural_gen(config: &GenConfig) -> It<Natural> {\n    Box::new(random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_natural_gen_var_1(config: &GenConfig) -> It<Natural> {\n    Box::new(random_natural_range_to_infinity(\n        EXAMPLE_SEED,\n        Natural::TWO,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_natural_gen_var_2(config: &GenConfig) -> It<Natural> {\n    Box::new(random_positive_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\nstruct RandomPositiveFloatNaturals<T: PrimitiveFloat> {\n    exponents: GeometricRandomSignedRange<i64>,\n    ranges: VariableRangeGenerator,\n    phantom: PhantomData<T>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for RandomPositiveFloatNaturals<T> {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        let exponent = self.exponents.next().unwrap();\n        let a = if exponent == 0 {\n            1\n        } else {\n            u64::power_of_2(T::MANTISSA_WIDTH)\n        };\n        let mantissa = self\n            .ranges\n            .next_in_range(a, u64::power_of_2(T::MANTISSA_WIDTH + 1));\n        Some(Natural::from(mantissa) << exponent)\n    }\n}\n\nfn random_positive_float_naturals<T: PrimitiveFloat>(\n    seed: Seed,\n    start_exponent: i64,\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n) -> RandomPositiveFloatNaturals<T> {\n    RandomPositiveFloatNaturals {\n        exponents: geometric_random_signed_range(\n            seed.fork(\"exponents\"),\n            start_exponent,\n            i64::power_of_2(T::EXPONENT_WIDTH - 1) - i64::wrapping_from(T::MANTISSA_WIDTH) - 1,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n        ),\n        ranges: VariableRangeGenerator::new(seed.fork(\"mantissas\")),\n        phantom: PhantomData,\n    }\n}\n\npub fn random_natural_gen_var_3<T: PrimitiveFloat>(config: &GenConfig) -> It<Natural> {\n    Box::new(with_special_value(\n        EXAMPLE_SEED,\n        Natural::ZERO,\n        1,\n        100,\n        &|seed| {\n            random_positive_float_naturals::<T>(\n                seed,\n                0,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n            )\n        },\n    ))\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn random_natural_gen_var_4<T: PrimitiveFloat>(config: &GenConfig) -> It<Natural>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Natural>,\n{\n    Box::new(\n        random_natural_range_to_infinity(\n            EXAMPLE_SEED,\n            Natural::power_of_2(T::MANTISSA_WIDTH + 1) | Natural::ONE,\n            config.get_or(\"mean_bits_n\", Limb::WIDTH << 1),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .filter(|n| !T::convertible_from(n)),\n    )\n}\n\npub fn random_natural_gen_var_5<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<Natural>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Box::new(\n        random_positive_float_naturals::<T>(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n        )\n        .filter_map(|a| {\n            let b = Natural::exact_from(T::exact_from(&a).next_higher());\n            let diff = b - &a;\n            if diff.even() {\n                // This happens almost always\n                Some(a + (diff >> 1))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn random_natural_gen_var_6<T: PrimitiveUnsigned>(_config: &GenConfig) -> It<Natural>\nwhere\n    Natural: From<T>,\n{\n    Box::new(random_primitive_ints(EXAMPLE_SEED).map(Natural::from))\n}\n\npub fn random_natural_gen_var_7<T: PrimitiveSigned>(_config: &GenConfig) -> It<Natural>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Box::new(random_natural_signeds(EXAMPLE_SEED).map(Natural::exact_from))\n}\n\npub fn random_natural_gen_var_8(config: &GenConfig) -> It<Natural> {\n    Box::new(\n        random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|n| (n << 1u32) | Natural::ONE),\n    )\n}\n\npub fn random_natural_gen_var_9(config: &GenConfig) -> It<Natural> {\n    Box::new(\n        geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_n\", 64),\n            config.get_or(\"mean_d\", 1),\n        )\n        .map(Natural::from),\n    )\n}\n\n// -- (Natural, bool) --\n\npub fn random_natural_bool_pair_gen(config: &GenConfig) -> It<(Natural, bool)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Natural, Integer, Natural) --\n\npub fn random_natural_integer_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Natural, Integer, Natural)> {\n    Box::new(random_triples_xyx(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, Natural) --\n\npub fn random_natural_pair_gen(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs_from_single(random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_natural_pair_gen_var_1(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::power_of_2(Limb::WIDTH),\n                config.get_or(\"mean_bits_n\", 64 + Limb::WIDTH),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_pair_gen_var_2(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_pair_gen_var_3(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_pair_gen_var_4(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| (x * &y, y * z)),\n    )\n}\n\npub fn random_natural_pair_gen_var_5(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_pair_gen_var_6(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y)| (x * &y, y)),\n    )\n}\n\npub fn random_natural_pair_gen_var_7(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn random_natural_pair_gen_var_8(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_ordered_unique_pairs(random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_natural_pair_gen_var_9(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs_from_single(random_positive_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_natural_pair_gen_var_10(config: &GenConfig) -> It<(Natural, Natural)> {\n    // TODO\n    Box::new(\n        random_pairs_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y)| x >= y),\n    )\n}\n\npub fn random_natural_pair_gen_var_11(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_ordered_unique_pairs(random_positive_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_natural_pair_gen_var_12(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(a, n)| (a, (n << 1u32) | Natural::ONE)),\n    )\n}\n\npub fn random_natural_pair_gen_var_13(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs_from_single(\n            random_naturals(\n                EXAMPLE_SEED,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n            .map(|n| (n << 1u32) | Natural::ONE),\n        )\n        .filter(|(x, y)| x.coprime_with(y)),\n    )\n}\n\npub fn random_natural_pair_gen_var_14(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y)| x.coprime_with(y)),\n    )\n}\n\npub fn random_natural_pair_gen_var_15(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds::<Limb>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from)\n        },\n    ))\n}\n\n// -- (Natural, Natural, bool) --\n\npub fn random_natural_natural_bool_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Natural, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Natural, Natural, Natural) --\n\npub fn random_natural_triple_gen(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(random_triples_from_single(random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_natural_triple_gen_var_1(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, m)| (x * &m + &y, y, m)),\n    )\n}\n\npub fn random_natural_triple_gen_var_2(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\npub fn random_natural_triple_gen_var_3(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| {\n            let z = max(&x, &y) + z + Natural::ONE;\n            (x, y, z)\n        }),\n    )\n}\n\npub fn random_natural_triple_gen_var_4(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_triple_gen_var_5(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, mut z)| {\n            z += &x;\n            z += Natural::ONE;\n            (x, y, z)\n        }),\n    )\n}\n\npub fn random_natural_triple_gen_var_6(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(random_triples_from_single(random_positive_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_natural_triple_gen_var_7(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| (x + &y * &z, y, z)),\n    )\n}\n\npub fn random_natural_triple_gen_var_8(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(a, b, n)| (a, b, (n << 1u32) | Natural::ONE)),\n    )\n}\n\npub fn random_natural_triple_gen_var_9(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(a, m, n)| (a, (m << 1u32) | Natural::ONE, (n << 1u32) | Natural::ONE)),\n    )\n}\n\n// -- (Natural, Natural, Natural, Natural) --\n\npub fn random_natural_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        random_quadruples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter_map(|(x, y, z, w)| {\n            let ranking = [(&x, 0), (&y, 1), (&z, 2), (&w, 3)];\n            let (hi, next_hi) = get_two_highest(&ranking);\n            if hi.0 == next_hi.0 {\n                None\n            } else {\n                Some(match hi.1 {\n                    0 => (y, z, w, x),\n                    1 => (x, z, w, y),\n                    2 => (x, y, w, z),\n                    _ => (x, y, z, w),\n                })\n            }\n        }),\n    )\n}\n\npub fn random_natural_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        random_quadruples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z, mut w)| {\n            w += max!(&x, &y);\n            w += Natural::ONE;\n            (x, y, z, w)\n        }),\n    )\n}\n\npub fn random_natural_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        random_quadruples_from_single(random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z, mut w)| {\n            w += &x;\n            w += Natural::ONE;\n            (x, y, z, w)\n        }),\n    )\n}\n\n// -- (Natural, Natural, Natural, PrimitiveUnsigned) --\n\npub fn random_natural_natural_natural_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, T)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_natural_natural_unsigned_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        random_quadruples_xxxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z, mut m)| {\n            m += max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits()\n            );\n            (x, y, z, m)\n        }),\n    )\n}\n\npub fn random_natural_natural_natural_unsigned_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        random_quadruples_xxxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z, mut m)| {\n            m += max(x.significant_bits(), y.significant_bits());\n            (x, y, z, m)\n        }),\n    )\n}\n\npub fn random_natural_natural_natural_unsigned_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        random_quadruples_xxxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z, mut m)| {\n            m += x.significant_bits();\n            (x, y, z, m)\n        }),\n    )\n}\n\n// -- (Natural, Natural, PrimitiveFloat) --\n\npub fn random_natural_natural_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Natural, Natural, PrimitiveInt) --\n\npub fn random_natural_natural_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Natural, Natural, PrimitiveSigned) --\n\npub fn random_natural_natural_signed_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_ordered_unique_pairs(random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            ))\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    )))\n}\n\n// -- (Natural, Natural, PrimitiveUnsigned) --\n\npub fn random_natural_natural_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_natural_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, pow)| ((x << pow) + &y, y, pow)),\n    )\n}\n\npub fn random_natural_natural_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(ref x, ref y, pow)| !x.eq_mod_power_of_2(y, pow.exact_into())),\n    )\n}\n\npub fn random_natural_natural_unsigned_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Natural, Natural, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += max(x.significant_bits(), y.significant_bits());\n            (x, y, m)\n        }),\n    )\n}\n\npub fn random_natural_natural_unsigned_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Natural, Natural, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\npub fn random_natural_natural_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_ordered_unique_pairs(random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            ))\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    )))\n}\n\n// -- (Natural, Natural, RoundingMode) --\n\npub fn random_natural_natural_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Natural, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(x, y, rm)| {\n            if rm == Exact {\n                (x * &y, y, rm)\n            } else {\n                (x, y, rm)\n            }\n        }),\n    )\n}\n\npub fn random_natural_natural_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Natural, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_natural_filter_map(x, y, rm)),\n    )\n}\n\n// -- (Natural, PrimitiveFloat) --\n\npub fn random_natural_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Natural, PrimitiveFloat, PrimitiveFloat) --\n\npub fn random_natural_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Natural, PrimitiveInt) --\n\npub fn random_natural_primitive_int_pair_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\npub fn random_natural_primitive_int_pair_gen_var_1<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Natural, PrimitiveInt, PrimitiveInt) --\n\npub fn random_natural_primitive_int_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Natural, PrimitiveSigned) --\n\npub fn random_natural_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_natural_signeds,\n    ))\n}\n\npub fn random_natural_signed_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct NaturalBitsMultipleOfLimbBitsGenerator {\n    limbs: RandomPrimitiveInts<u64>,\n    limb_counts: GeometricRandomNaturalValues<u64>,\n}\n\nimpl Iterator for NaturalBitsMultipleOfLimbBitsGenerator {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        Some(get_random_natural_with_bits(\n            &mut self.limbs,\n            self.limb_counts.next().unwrap() << Limb::LOG_WIDTH,\n        ))\n    }\n}\n\npub fn random_natural_signed_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| NaturalBitsMultipleOfLimbBitsGenerator {\n            limbs: random_primitive_ints(seed.fork(\"limbs\")),\n            limb_counts: geometric_random_positive_unsigneds(\n                seed.fork(\"limb_counts\"),\n                config.get_or(\"mean_small_n\", 2),\n                config.get_or(\"mean_small_d\", 1),\n            ),\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn random_natural_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\npub fn random_natural_signed_unsigned_triple_gen_var_2<T: PrimitiveSigned, U: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, RoundingMode) --\n\npub fn random_natural_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shr<T, Output = Natural>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i < T::ZERO && rm == Exact {\n                    n >> i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\npub fn random_natural_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i > T::ZERO && rm == Exact {\n                    n << i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned) --\n\npub fn random_natural_unsigned_pair_gen_var_1<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::saturating_from(U::MAX)),\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::MAX),\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::from(36u8)),\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_6<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, 1, T::WIDTH),\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(mut x, y)| {\n            x.round_to_multiple_of_power_of_2_assign(y.exact_into(), Down);\n            (x, y)\n        }),\n    )\n}\n\npub fn random_natural_unsigned_pair_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn random_natural_unsigned_pair_gen_var_11(config: &GenConfig) -> It<(Natural, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, mut m)| {\n            m += x.significant_bits();\n            (x, m)\n        }),\n    )\n}\n\npub fn random_natural_unsigned_pair_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_pair_gen_var_13(config: &GenConfig) -> It<(Natural, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, mut m)| {\n            m += x.significant_bits();\n            (x, m)\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, bool) --\n\npub fn random_natural_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_natural_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::from(36u8)),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned, U: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, u64, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, 1, U::WIDTH),\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z)| if y <= z { (x, y, z) } else { (x, z, y) }),\n    )\n}\n\npub fn random_natural_unsigned_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 32),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_unsigned_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\npub fn random_natural_unsigned_unsigned_natural_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, T, Natural)> {\n    Box::new(\n        random_quadruples_xyyx::<_, _, T, _>(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\npub fn random_natural_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_excess_len_n\", 4),\n                    config.get_or(\"mean_excess_len_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, u, rm)| {\n            if rm == Exact {\n                (n << u, u, rm)\n            } else {\n                (n, u, rm)\n            }\n        }),\n    )\n}\n\n// var 2 is in malachite-float\n\n// --(Natural, PrimitiveUnsigned, Vec<bool>) --\n\nstruct NaturalUnsignedBoolVecTripleGenerator {\n    xs: RandomNaturals<GeometricRandomNaturalValues<u64>>,\n    log_bases: It<u64>,\n    bs: RandomBools,\n}\n\nimpl Iterator for NaturalUnsignedBoolVecTripleGenerator {\n    type Item = (Natural, u64, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Natural, u64, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let log_base = self.log_bases.next().unwrap();\n        let bs = (&mut self.bs)\n            .take(usize::exact_from(\n                x.significant_bits().div_round(log_base, Ceiling).0,\n            ))\n            .collect();\n        Some((x, log_base, bs))\n    }\n}\n\npub fn random_natural_unsigned_bool_vec_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, u64, Vec<bool>)> {\n    Box::new(NaturalUnsignedBoolVecTripleGenerator {\n        xs: random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        log_bases: Box::new(geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        )),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\npub fn random_natural_unsigned_bool_vec_triple_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, u64, Vec<bool>)> {\n    Box::new(NaturalUnsignedBoolVecTripleGenerator {\n        xs: random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        log_bases: Box::new(random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            1,\n            T::WIDTH,\n        )),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n// -- (Natural, RoundingMode) --\n\npub fn random_natural_rounding_mode_pair_gen(config: &GenConfig) -> It<(Natural, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_natural_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(Natural, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, rm)| rm != Exact || T::convertible_from(n)),\n    )\n}\n\npub fn random_natural_rounding_mode_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (Natural, ToSciOptions) --\n\npub fn random_natural_to_sci_options_pair_gen(config: &GenConfig) -> It<(Natural, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"small_mean_n\", 4),\n                config.get_or(\"small_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_natural_to_sci_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"small_mean_n\", 4),\n                    config.get_or(\"small_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// --(Natural, Vec<bool>) --\n\nstruct NaturalBoolVecPairGenerator1 {\n    xs: RandomNaturals<GeometricRandomNaturalValues<u64>>,\n    bs: RandomBools,\n}\n\nimpl Iterator for NaturalBoolVecPairGenerator1 {\n    type Item = (Natural, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Natural, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = (&mut self.bs)\n            .take(usize::exact_from(x.limb_count()))\n            .collect();\n        Some((x, bs))\n    }\n}\n\npub fn random_natural_bool_vec_pair_gen_var_1(config: &GenConfig) -> It<(Natural, Vec<bool>)> {\n    Box::new(NaturalBoolVecPairGenerator1 {\n        xs: random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\nstruct NaturalBoolVecPairGenerator2 {\n    xs: RandomNaturals<GeometricRandomNaturalValues<u64>>,\n    bs: RandomBools,\n}\n\nimpl Iterator for NaturalBoolVecPairGenerator2 {\n    type Item = (Natural, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Natural, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = (&mut self.bs)\n            .take(usize::exact_from(x.significant_bits()))\n            .collect();\n        Some((x, bs))\n    }\n}\n\npub fn random_natural_bool_vec_pair_gen_var_2(config: &GenConfig) -> It<(Natural, Vec<bool>)> {\n    Box::new(NaturalBoolVecPairGenerator2 {\n        xs: random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n// -- (Vec<PrimitiveUnsigned>, bool) --\n\npub fn random_unsigned_bool_pair_gen_var_1(config: &GenConfig) -> It<(usize, bool)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_n\", 16),\n                    config.get_or(\"mean_d\", 1),\n                )\n            },\n            &random_bools,\n        )\n        .filter(|&(n, b)| limbs_odd_factorial_valid(n, b)),\n    )\n}\n\n// -- (PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// vars 1 through 32 are in malachite-base\n\npub fn random_unsigned_pair_gen_var_33<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    T::exact_from(ODD_FACTORIAL_TABLE_LIMIT + 1),\n                    T::MAX,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(n, k)| n >= k),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_34<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    T::TWO,\n                    T::wrapping_from(ODD_FACTORIAL_TABLE_LIMIT),\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(n, k)| n >= k),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_35<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    T::from(4u8),\n                    T::wrapping_from(ODD_FACTORIAL_EXTTABLE_LIMIT),\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    T::TWO,\n                    T::wrapping_from(ODD_FACTORIAL_EXTTABLE_LIMIT - 2),\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(n, k)| n >= k + T::TWO),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_36<T: PrimitiveUnsigned>(config: &GenConfig) -> It<(T, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    T::wrapping_from((ODD_CENTRAL_BINOMIAL_OFFSET << 1) + 1),\n                    T::MAX,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    T::wrapping_from((ODD_CENTRAL_BINOMIAL_OFFSET << 1) - 1),\n                    T::wrapping_from(if BIN_UIUI_RECURSIVE_SMALLDC {\n                        ODD_CENTRAL_BINOMIAL_TABLE_LIMIT\n                    } else {\n                        ODD_FACTORIAL_TABLE_LIMIT\n                    }) << 1,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(n, k)| n >= k + T::TWO),\n    )\n}\n\npub fn random_unsigned_pair_gen_var_37(config: &GenConfig) -> It<(Limb, Limb)> {\n    Box::new(\n        random_pairs_from_single(geometric_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_small_n\", 32),\n            config.get_or(\"mean_small_d\", 1),\n        ))\n        .filter_map(|(mut n, mut k)| {\n            n += u64::wrapping_from(BIN_GOETGHELUCK_THRESHOLD) << 1;\n            k += u64::wrapping_from(BIN_GOETGHELUCK_THRESHOLD);\n            if n >= k + 5 && k > (n >> 4) && n_to_bit(n - k) < n_to_bit(n) && k <= n - k {\n                Some((Limb::exact_from(n), Limb::exact_from(k)))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n// var 38 is in malachite-base.\n\n// -- (PrimitiveUnsigned * 6) --\n\npub fn random_unsigned_sextuple_gen_var_1(\n    _config: &GenConfig,\n) -> It<(Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| random_pairs_from_single(random_primitive_ints(seed_2)),\n                    &|seed_2| {\n                        random_pairs(\n                            seed_2,\n                            &|seed_3| {\n                                random_unsigned_inclusive_range(\n                                    seed_3,\n                                    Limb::power_of_2(Limb::WIDTH - 1),\n                                    Limb::MAX,\n                                )\n                            },\n                            &random_primitive_ints,\n                        )\n                    },\n                )\n                .filter(|&((n_2, n_1), (d_1, d_0))| n_2 < d_1 || n_2 == d_1 && n_1 < d_0)\n            },\n            &random_primitive_ints,\n        )\n        .map(|(((n_2, n_1), (d_1, d_0)), n_0)| {\n            (\n                n_2,\n                n_1,\n                n_0,\n                d_1,\n                d_0,\n                limbs_two_limb_inverse_helper(d_1, d_0),\n            )\n        }),\n    )\n}\n\n// -- (String, String, String) --\n\npub fn random_string_triple_gen_var_1(config: &GenConfig) -> It<(String, String, String)> {\n    Box::new(\n        random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| {\n            (\n                serde_json::to_string(&BigUint::from(&x)).unwrap(),\n                serde_json::to_string(&rug::Integer::from(&x)).unwrap(),\n                serde_json::to_string(&x).unwrap(),\n            )\n        }),\n    )\n}\n\npub fn random_string_triple_gen_var_2(config: &GenConfig) -> It<(String, String, String)> {\n    Box::new(\n        random_integers(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| {\n            (\n                serde_json::to_string(&BigInt::from(&x)).unwrap(),\n                serde_json::to_string(&rug::Integer::from(&x)).unwrap(),\n                serde_json::to_string(&x).unwrap(),\n            )\n        }),\n    )\n}\n\n// -- Vec<Integer> --\n\npub fn random_integer_vec_gen(config: &GenConfig) -> It<Vec<Integer>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        config.get_or(\"mean_len_n\", 4),\n        config.get_or(\"mean_len_d\", 1),\n    ))\n}\n\n// -- Vec<Natural> --\n\npub fn random_natural_vec_gen(config: &GenConfig) -> It<Vec<Natural>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        config.get_or(\"mean_len_n\", 4),\n        config.get_or(\"mean_len_d\", 1),\n    ))\n}\n\n// -- (Vec<Natural>, Integer> --\n\npub fn random_natural_vec_integer_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    random_positive_naturals(\n                        seed_2,\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_len_n\", 4),\n                config.get_or(\"mean_len_d\", 1),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Vec<Natural>, Natural> --\n\nstruct LargeDigitsRandomGenerator {\n    bases: RandomNaturalRangeToInfinity,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    xs: RandomPrimitiveInts<u64>,\n}\n\nimpl Iterator for LargeDigitsRandomGenerator {\n    type Item = (Vec<Natural>, Natural);\n\n    fn next(&mut self) -> Option<(Vec<Natural>, Natural)> {\n        let base = self.bases.next().unwrap();\n        let bits = base.ceiling_log_base_2();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut digits = Vec::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            loop {\n                let x = get_random_natural_with_up_to_bits(&mut self.xs, bits);\n                if x < base {\n                    digits.push(x);\n                    break;\n                }\n            }\n        }\n        Some((digits, base))\n    }\n}\n\npub fn random_natural_vec_natural_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(LargeDigitsRandomGenerator {\n        bases: random_natural_range_to_infinity(\n            EXAMPLE_SEED.fork(\"bases\"),\n            Natural::power_of_2(Limb::WIDTH),\n            Limb::WIDTH + 4,\n            1,\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_natural_vec_natural_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(LargeDigitsRandomGenerator {\n        bases: random_natural_range_to_infinity(\n            EXAMPLE_SEED.fork(\"bases\"),\n            Natural::TWO,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_natural_vec_natural_pair_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    random_naturals(\n                        seed_2,\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_digit_count_n\", 4),\n                config.get_or(\"mean_digit_count_d\", 1),\n            )\n        },\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::power_of_2(Limb::WIDTH),\n                Limb::WIDTH + 4,\n                1,\n            )\n        },\n    ))\n}\n\npub fn random_natural_vec_natural_pair_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    random_naturals(\n                        seed_2,\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_digit_count_n\", 4),\n                config.get_or(\"mean_digit_count_d\", 1),\n            )\n        },\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Vec<Natural>, PrimitiveUnsigned) --\n\nstruct PowerOf2DigitsGenerator {\n    log_bases: GeometricRandomNaturalValues<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    xs: RandomPrimitiveInts<u64>,\n}\n\nimpl Iterator for PowerOf2DigitsGenerator {\n    type Item = (Vec<Natural>, u64);\n\n    fn next(&mut self) -> Option<(Vec<Natural>, u64)> {\n        let log_base = self.log_bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut digits = Vec::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            digits.push(get_random_natural_with_up_to_bits(&mut self.xs, log_base));\n        }\n        Some((digits, log_base))\n    }\n}\n\npub fn random_natural_vec_unsigned_pair_gen_var_1(config: &GenConfig) -> It<(Vec<Natural>, u64)> {\n    Box::new(PowerOf2DigitsGenerator {\n        log_bases: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_count\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_natural_vec_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    random_naturals(\n                        seed_2,\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Vec<PrimitiveInt>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>) --\n\nstruct DigitsRandomGenerator<T: PrimitiveInt> {\n    bases: RandomValuesFromVec<u64>,\n    xss: RandomVecs<Limb, GeometricRandomNaturalValues<u64>, RandomPrimitiveInts<Limb>>,\n    outs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt> Iterator for DigitsRandomGenerator<T> {\n    type Item = (Vec<T>, u64, Vec<Limb>);\n\n    fn next(&mut self) -> Option<(Vec<T>, u64, Vec<Limb>)> {\n        let base = self.bases.next().unwrap();\n        let xs = self.xss.next().unwrap();\n        let out_len = usize::exact_from(limbs_digit_count(&xs, base));\n        let out = (&mut self.outs).take(out_len).collect();\n        Some((out, base, xs))\n    }\n}\n\n// -- (Vec<PrimitiveInt>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\nstruct BasecaseDigitsRandomGenerator<T: PrimitiveInt> {\n    bases: RandomValuesFromVec<u64>,\n    xss: RandomVecs<Limb, RandomUnsignedRange<u64>, RandomPrimitiveInts<Limb>>,\n    excess_lens: RandomOptions<GeometricRandomNaturalValues<usize>>,\n    excess_out_lens: GeometricRandomNaturalValues<usize>,\n    outs: RandomPrimitiveInts<T>,\n}\n\nimpl<T: PrimitiveInt> Iterator for BasecaseDigitsRandomGenerator<T> {\n    type Item = (Vec<T>, usize, Vec<Limb>, u64);\n\n    fn next(&mut self) -> Option<(Vec<T>, usize, Vec<Limb>, u64)> {\n        let base = self.bases.next().unwrap();\n        let xs = self.xss.next().unwrap();\n        let min_out_len = usize::exact_from(limbs_digit_count(&xs, base));\n        let excess_out_len = self.excess_out_lens.next().unwrap();\n        let (len, out_len) = if let Some(excess) = self.excess_lens.next().unwrap() {\n            (min_out_len + excess, min_out_len + excess + excess_out_len)\n        } else {\n            (0, min_out_len + excess_out_len)\n        };\n        let out = (&mut self.outs).take(out_len).collect();\n        Some((out, len, xs, base))\n    }\n}\n\npub fn random_primitive_int_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1<\n    T: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, usize, Vec<Limb>, u64)> {\n    Box::new(BasecaseDigitsRandomGenerator {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        xss: random_vecs_length_range(\n            EXAMPLE_SEED.fork(\"xss\"),\n            0,\n            u64::exact_from(GET_STR_PRECOMPUTE_THRESHOLD),\n            &random_primitive_ints,\n        ),\n        excess_lens: random_options(\n            EXAMPLE_SEED.fork(\"excess_lens\"),\n            config.get_or(\"zero_len_prob_n\", 1),\n            config.get_or(\"zero_len_prob_d\", 5),\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_excess_len_n\", 4),\n                    config.get_or(\"mean_excess_len_d\", 1),\n                )\n            },\n        ),\n        excess_out_lens: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"excess_out_lens\"),\n            config.get_or(\"mean_excess_len_n\", 4),\n            config.get_or(\"mean_excess_len_d\", 1),\n        ),\n        outs: random_primitive_ints(EXAMPLE_SEED.fork(\"outs\")),\n    })\n}\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveInt>) --\n\n// vars 1 through 8 are in malachite-base.\n\npub fn random_primitive_int_vec_pair_gen_var_9(config: &GenConfig) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecPairLenGenerator2 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints::<Limb>(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(xs, ys)| gcd_input_filter(xs, ys)),\n    )\n}\n\n// vars 10 through 13 are in malachite-base.\n\npub fn random_primitive_int_vec_pair_gen_var_14(config: &GenConfig) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs_from_single(\n            random_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter_map(|mut xs| {\n                let x_last = xs.last_mut().unwrap();\n                if *x_last == Limb::MAX {\n                    None\n                } else {\n                    *x_last += 1;\n                    Some(xs)\n                }\n            }),\n        )\n        .filter_map(|(ns, ds)| {\n            let mut ns = limbs_mul(&ns, &ds);\n            if *ns.last().unwrap() == 0 {\n                ns.pop();\n            }\n            if *ns.last().unwrap() == 0 {\n                None\n            } else {\n                Some((ns, ds))\n            }\n        }),\n    )\n}\n\n// var 15 is in malachite-base.\n\npub fn random_primitive_int_vec_pair_gen_var_16<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    1,\n                    usize::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    1,\n                    SQRLO_DC_THRESHOLD_LIMIT,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| x >= y),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\nfn random_square_helper<T: PrimitiveInt, F: Fn(usize) -> bool>(\n    config: &GenConfig,\n    valid: &'static F,\n    min_x: usize,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(move |(o, x)| {\n            let x = x.checked_add(min_x)?;\n            let ux = usize::exact_from(x);\n            if valid(ux) {\n                let o = x.arithmetic_checked_shl(1u64)?.checked_add(o)?;\n                Some((o, x))\n            } else {\n                None\n            }\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_pair_gen_var_17<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_square_helper(config, &|x| x <= SQR_TOOM2_THRESHOLD, 1)\n}\n\npub fn random_primitive_int_vec_pair_gen_var_18<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_square_helper(config, &|_| true, 2)\n}\n\npub fn random_primitive_int_vec_pair_gen_var_19<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_square_helper(config, &limbs_square_to_out_toom_3_input_size_valid, 3)\n}\n\npub fn random_primitive_int_vec_pair_gen_var_20<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_square_helper(config, &limbs_square_to_out_toom_4_input_size_valid, 4)\n}\n\npub fn random_primitive_int_vec_pair_gen_var_21<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_square_helper(config, &|x| x == 7 || x == 8 || x > 9, 7)\n}\n\npub fn random_primitive_int_vec_pair_gen_var_22<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_square_helper(config, &limbs_square_to_out_toom_6_input_size_valid, 18)\n}\n\npub fn random_primitive_int_vec_pair_gen_var_23<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    random_square_helper(config, &limbs_square_to_out_toom_8_input_size_valid, 40)\n}\n\n// vars 26 to 27 are in malachite-base.\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveInt>, Vec<PrimitiveInt>) --\n\n// vars 1 through 3 are in malachite-base\n\nfn random_mul_helper<T: PrimitiveInt, F: Fn(usize, usize) -> bool>(\n    config: &GenConfig,\n    valid: &'static F,\n    min_x: usize,\n    min_y: usize,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(move |(o, x, y)| {\n            let x = x.checked_add(min_x)?;\n            let y = y.checked_add(min_y)?;\n            if valid(usize::exact_from(x), usize::exact_from(y)) {\n                let o = x.checked_add(y)?.checked_add(o)?;\n                Some((o, x, y))\n            } else {\n                None\n            }\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_4<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_22_input_sizes_valid,\n        2,\n        2,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_5<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_32_input_sizes_valid,\n        6,\n        4,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_6<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n        3,\n        3,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_7<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_42_input_sizes_valid,\n        4,\n        2,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_8<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_43_input_sizes_valid,\n        11,\n        8,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_9<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_44_input_sizes_valid,\n        4,\n        4,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_10<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_52_input_sizes_valid,\n        14,\n        5,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_11<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_53_input_sizes_valid,\n        5,\n        3,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_12<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_54_input_sizes_valid,\n        14,\n        11,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_13<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_62_input_sizes_valid,\n        6,\n        2,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_14<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_63_input_sizes_valid,\n        17,\n        9,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_15<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n        42,\n        42,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_16<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n        86,\n        86,\n    )\n}\n\nfn random_mul_same_length_helper<T: PrimitiveInt, F: Fn(usize, usize) -> bool>(\n    config: &GenConfig,\n    valid: &'static F,\n    min_x: usize,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(PrimitiveIntVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(move |(o, x)| {\n            let x = x.checked_add(min_x)?;\n            let ux = usize::exact_from(x);\n            if valid(ux, ux) {\n                let o = x.arithmetic_checked_shl(1u64)?.checked_add(o)?;\n                Some((o, x))\n            } else {\n                None\n            }\n        }),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\npub fn random_primitive_int_vec_triple_gen_var_18<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_same_length_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n        5,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_19<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_same_length_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n        42,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_20<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_same_length_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n        86,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_22<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &|xs_len, ys_len| {\n            limbs_mul_greater_to_out_toom_32_input_sizes_valid(xs_len, ys_len)\n                && limbs_mul_greater_to_out_toom_43_input_sizes_valid(xs_len, ys_len)\n        },\n        11,\n        8,\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_23<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &|xs_len, ys_len| {\n            limbs_mul_greater_to_out_toom_42_input_sizes_valid(xs_len, ys_len)\n                && limbs_mul_greater_to_out_toom_53_input_sizes_valid(xs_len, ys_len)\n        },\n        5,\n        3,\n    )\n}\n\n// vars 24 through 35 are in malachite-base\n\npub fn random_primitive_int_vec_triple_gen_var_36(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            random_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter_map(filter_map_helper_3),\n    )\n}\n\npub fn random_primitive_int_vec_triple_gen_var_37(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            random_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter(filter_helper_3),\n    )\n}\n\n// var 39 through 44 are in malachite-base.\n\npub fn random_primitive_int_vec_triple_gen_var_45<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    random_mul_helper(\n        config,\n        &|x, y| {\n            limbs_mul_greater_to_out_toom_44_input_sizes_valid(x, y)\n                && limbs_mul_greater_to_out_toom_44_input_sizes_valid(x, y)\n        },\n        7,\n        7,\n    )\n}\n\n// var 46 is in malachite-base.\n\n// -- (Vec<PrimitiveInt>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\nstruct BasecaseDigitsRandomGenerator1<T: PrimitiveUnsigned, U: PrimitiveInt> {\n    bases: RandomValuesFromVec<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    base_to_digits: HashMap<u64, RandomUnsignedsLessThan<T>>,\n    excess_limb_counts: GeometricRandomNaturalValues<usize>,\n    outs: RandomPrimitiveInts<U>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveInt> Iterator for BasecaseDigitsRandomGenerator1<T, U> {\n    type Item = (Vec<U>, Vec<T>, u64);\n\n    fn next(&mut self) -> Option<(Vec<U>, Vec<T>, u64)> {\n        let base = self.bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let ds = self.base_to_digits.entry(base).or_insert_with(move || {\n            random_unsigneds_less_than(EXAMPLE_SEED.fork(&base.to_string()), T::wrapping_from(base))\n        });\n        let digits = ds.take(digit_count).collect();\n        let min_limb_count = limbs_per_digit_in_base(digit_count, base);\n        let out = (&mut self.outs)\n            .take(usize::exact_from(min_limb_count) + self.excess_limb_counts.next().unwrap())\n            .collect();\n        Some((out, digits, base))\n    }\n}\n\npub fn random_primitive_int_vec_unsigned_vec_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<U>, Vec<T>, u64)> {\n    Box::new(BasecaseDigitsRandomGenerator1 {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        digit_counts: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        excess_limb_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"excess_limb_count\"),\n            config.get_or(\"excess_limb_count_n\", 4),\n            config.get_or(\"excess_limb_count_d\", 1),\n        ),\n        outs: random_primitive_ints(EXAMPLE_SEED.fork(\"outs\")),\n        base_to_digits: HashMap::new(),\n    })\n}\n\nstruct BasecaseDigitsRandomGenerator2<T: PrimitiveUnsigned, U: PrimitiveInt> {\n    bases: RandomValuesFromVec<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    base_to_digits: HashMap<u64, RandomPrimitiveInts<T>>,\n    excess_limb_counts: GeometricRandomNaturalValues<usize>,\n    outs: RandomPrimitiveInts<U>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveInt> Iterator for BasecaseDigitsRandomGenerator2<T, U> {\n    type Item = (Vec<U>, Vec<T>, u64);\n\n    fn next(&mut self) -> Option<(Vec<U>, Vec<T>, u64)> {\n        let base = self.bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let ds = self\n            .base_to_digits\n            .entry(base)\n            .or_insert_with(move || random_primitive_ints(EXAMPLE_SEED.fork(&base.to_string())));\n        let digits = ds.take(digit_count).collect();\n        let min_limb_count = limbs_per_digit_in_base(digit_count, base);\n        let out = (&mut self.outs)\n            .take(usize::exact_from(min_limb_count) + self.excess_limb_counts.next().unwrap())\n            .collect();\n        Some((out, digits, base))\n    }\n}\n\npub fn random_primitive_int_vec_unsigned_vec_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Vec<U>, Vec<T>, u64)> {\n    Box::new(BasecaseDigitsRandomGenerator2 {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        digit_counts: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        excess_limb_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"excess_limb_count\"),\n            config.get_or(\"excess_limb_count_n\", 4),\n            config.get_or(\"excess_limb_count_d\", 1),\n        ),\n        outs: random_primitive_ints(EXAMPLE_SEED.fork(\"outs\")),\n        base_to_digits: HashMap::new(),\n    })\n}\n\n// -- Vec<PrimitiveUnsigned> --\n\npub fn random_unsigned_vec_gen_var_1(config: &GenConfig) -> It<Vec<Limb>> {\n    Box::new(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .map(|mut xs| {\n            limbs_vec_mul_limb_in_place(&mut xs, 3);\n            xs\n        }),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// vars 1 through 7 are in malachite-base\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_8<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs_min_length(\n                seed,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, T::TWO, T::saturating_from(U::MAX)),\n    ))\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_9(config: &GenConfig) -> It<(Vec<Limb>, u64)> {\n    Box::new(\n        random_primitive_int_vec_unsigned_pair_gen_var_10(config).filter(|(xs, index)| {\n            let mut mut_xs = xs.clone();\n            limbs_vec_clear_bit_neg(&mut mut_xs, *index);\n            mut_xs.len() == xs.len()\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_10(config: &GenConfig) -> It<(Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    1,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &random_positive_unsigneds,\n        )\n        .map(|(mut xs, y)| {\n            limbs_vec_mul_limb_in_place(&mut xs, y);\n            (xs, y)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_pair_gen_var_11(config: &GenConfig) -> It<(Vec<Limb>, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    1,\n                    &random_primitive_ints::<Limb>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(mut xs, mut pow)| {\n            let xs_last = xs.last_mut().unwrap();\n            *xs_last = xs_last.checked_add(1)?;\n            pow += limbs_significant_bits_helper(&xs);\n            Some((xs, pow))\n        }),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )\n        .filter(|(m, x, y)| {\n            !Integer::from(Natural::from(*x)).eq_mod(-Natural::from(*y), Natural::from_limbs_asc(m))\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_values_from_vec(seed, factors_of_limb_max()),\n        &random_primitive_ints,\n    ))\n}\n\n// var 3 is in malachite-base.\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_primitive_ints,\n            &random_positive_unsigneds,\n        )\n        .map(map_helper_3),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_primitive_ints,\n            &random_positive_unsigneds,\n        )\n        .filter(filter_helper_6),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_6<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints::<Limb>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            (xs, y, pow)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_7<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    1,\n                    &random_primitive_ints::<Limb>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            (xs, y, pow)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_triple_gen_var_8<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints::<Limb>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &random_primitive_ints::<T>,\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            if pow == 0 {\n                pow = 1;\n            }\n            (xs, y, pow)\n        }),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>) --\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64, Vec<Limb>)> {\n    Box::new(DigitsRandomGenerator {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        xss: random_vecs(\n            EXAMPLE_SEED.fork(\"xss\"),\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        outs: random_primitive_ints(EXAMPLE_SEED.fork(\"bytes\")),\n    })\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )))\n        .filter_map(filter_map_helper_1),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )))\n        .filter(filter_helper_1),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )))\n        .map(map_helper_1),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )))\n        .filter(filter_helper_4),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// vars 1 through 2 are in malachite-base.\n\npub fn random_unsigned_vec_pair_gen_var_3(config: &GenConfig) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter_map(|(out, mut xs)| {\n            limbs_vec_mul_limb_in_place(&mut xs, 3);\n            if out.len() >= xs.len() {\n                Some((out, xs))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn random_unsigned_vec_pair_gen_var_4(config: &GenConfig) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs_from_single(random_vecs_min_length(\n            EXAMPLE_SEED,\n            2,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(ns, mut ds)| {\n            let d_last = ds.last_mut().unwrap();\n            if *d_last == 0 {\n                *d_last = 1;\n            }\n            let mut new_ns = limbs_mul(&ns, &ds);\n            if *new_ns.last().unwrap() == 0 {\n                new_ns.pop();\n            }\n            (new_ns, ds)\n        }),\n    )\n}\n\n// var 5 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// var 1 is in malachite-base.\n\npub fn random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )\n        .filter_map(filter_map_helper_2),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )\n        .filter(filter_helper_2),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                    seed.fork(\"lengths\"),\n                    2,\n                    usize::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &random_positive_unsigneds,\n        )\n        .filter_map(|((out, mut xs), y)| {\n            limbs_vec_mul_limb_in_place(&mut xs, y);\n            if out.len() >= xs.len() {\n                Some((out, xs, y))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )\n        .map(map_helper_2),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &random_positive_unsigneds,\n        )\n        .filter(filter_helper_5),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(3)?;\n                    d_init_len = d_init_len.checked_add(2)?;\n                    if n_len > d_init_len {\n                        Some((n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                random_unsigned_inclusive_range(seed, Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX)\n            },\n        )\n        .map(|((n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (n, d_init, inverse)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints::<Limb>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, ys, mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigneds(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|((xs, ys), mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    1,\n                    &random_primitive_ints::<Limb>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter_map(|mut xs| {\n                    let last_x = xs.last_mut().unwrap();\n                    *last_x = last_x.checked_add(1)?;\n                    Some(xs)\n                })\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, ys, mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_10(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    1,\n                    &random_primitive_ints::<Limb>,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 4),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(mut xs, mut es, pow)| {\n            let last_e = es.last_mut().unwrap();\n            *last_e = last_e.checked_add(1)?;\n            if es == [1] {\n                return None;\n            }\n            limbs_slice_mod_power_of_2_in_place(&mut xs, pow);\n            if *xs.last().unwrap() == 0 {\n                None\n            } else {\n                Some((xs, es, pow))\n            }\n        }),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\npub fn random_unsigned_vec_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(2)?;\n                    d_init_len = d_init_len.checked_add(1)?;\n                    let d_len = d_init_len + 1;\n                    if n_len >= d_len && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                random_unsigned_inclusive_range(seed, Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX)\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            (q, n, d_init)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(3)?;\n                    d_init_len = d_init_len.checked_add(1)?;\n                    let d_len = d_init_len + 1;\n                    if n_len > d_len && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                random_unsigned_inclusive_range(seed, Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX)\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            (q, n, d_init)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len && q_len > n_len - d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(_, _, d)| *d.last().unwrap() != 0),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len && q_len > n_len - d_len && n_len < (d_len - 1) << 1 {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(_, _, d)| *d.last().unwrap() != 0),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(\n                geometric_random_unsigned_inclusive_range::<usize>(\n                    EXAMPLE_SEED.fork(\"lengths\"),\n                    2,\n                    usize::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ),\n            )\n            .filter_map(|(q_len, n_len, d_len)| {\n                if q_len >= n_len && n_len >= d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            (q, n, d)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(\n                geometric_random_unsigned_inclusive_range::<usize>(\n                    EXAMPLE_SEED.fork(\"lengths\"),\n                    1,\n                    usize::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ),\n            )\n            .filter_map(|(q_len, n_len, d_len)| {\n                if q_len >= n_len && n_len >= d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            (q, n, d)\n        }),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(\n                geometric_random_unsigned_inclusive_range::<usize>(\n                    EXAMPLE_SEED.fork(\"lengths\"),\n                    1,\n                    usize::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ),\n            )\n            .filter_map(|(q_len, n_len, d_len)| {\n                if q_len + 1 >= n_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter_map(|(q, n, mut d): (Vec<Limb>, Vec<Limb>, Vec<Limb>)| {\n            let d_last = d.last_mut().unwrap();\n            if *d_last == 0 {\n                *d_last = 1;\n            }\n            let mut new_n = limbs_mul(&n, &d);\n            if *new_n.last().unwrap() == 0 {\n                new_n.pop();\n            }\n            if q.len() + d.len() >= new_n.len() + 1 {\n                Some((q, new_n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(\n                geometric_random_unsigned_inclusive_range::<usize>(\n                    EXAMPLE_SEED.fork(\"lengths\"),\n                    1,\n                    usize::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ),\n            )\n            .filter_map(|(q_len, n_len, mut d_len)| {\n                d_len = d_len.checked_add(1)?;\n                if q_len + 1 >= n_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter_map(|(q, n, mut d): (Vec<Limb>, Vec<Limb>, Vec<Limb>)| {\n            let d_last = d.last_mut().unwrap();\n            if *d_last == 0 {\n                *d_last = 1;\n            }\n            let mut new_n = limbs_mul(&n, &d);\n            if *new_n.last().unwrap() == 0 {\n                new_n.pop();\n            }\n            if q.len() > new_n.len() - d.len() {\n                Some((q, n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n// vars 9 through 10 are in malachite-base.\n\npub fn random_unsigned_vec_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            random_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .map(|(xs, ys, m)| limbs_eq_mod_map(&xs, ys, m)),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_12(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            random_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                &random_primitive_ints,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter(|(xs, ys, m)| !limbs_eq_mod_ref_ref_ref(xs, ys, m)),\n    )\n}\n\npub fn random_unsigned_vec_triple_gen_var_13(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigneds::<usize>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, n_len): (usize, usize)| {\n                    Some((q_len.checked_add(n_len)?, n_len.checked_add(2)?))\n                }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_unsigned_inclusive_range(\n                            seed_2,\n                            Limb::power_of_2(Limb::WIDTH - 1),\n                            Limb::MAX,\n                        )\n                    },\n                    &random_primitive_ints,\n                )\n            },\n        )\n        .map(|((q, n), (d_1, d_0))| (q, n, vec![d_0, d_1])),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned> * 4) --\n\n#[allow(clippy::type_complexity)]\npub fn random_unsigned_vec_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if r_len >= d_len && n_len >= d_len && q_len > n_len - d_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, r, mut d)| {\n            let last_d = d.last_mut().unwrap();\n            if *last_d == 0 {\n                *last_d = 1;\n            }\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_unsigned_vec_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(2)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(4)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len + 2 && q_len >= n_len - d_len && r_len >= d_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, r, mut d)| {\n            d[0] |= 1;\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_unsigned_vec_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(4)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(4)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len + 2 && q_len >= n_len - d_len && r_len >= d_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, r, mut d)| {\n            d[0] |= 1;\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_unsigned_vec_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if r_len >= d_len\n                    && n_len >= d_len\n                    && q_len > n_len - d_len\n                    && (d_len << 1) > n_len + 1\n                {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, r, mut d)| {\n            let last_d = d.last_mut().unwrap();\n            if *last_d == 0 {\n                *last_d = 1;\n            }\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_unsigned_vec_quadruple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(3)?;\n                d_len = d_len.checked_add(2)?;\n                if r_len >= d_len && n_len > d_len && q_len + d_len >= n_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(\n            |(q, n, r, mut d): (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)| {\n                d.last_mut().unwrap().set_bit(Limb::WIDTH - 1);\n                (q, n, r, d)\n            },\n        ),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_unsigned_vec_quadruple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        PrimitiveIntVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(out_len, mut b_len, e_len, mut m_len)| {\n                b_len = b_len.checked_add(1)?;\n                m_len = m_len.checked_add(1)?;\n                if out_len >= m_len {\n                    Some((out_len, b_len, e_len, m_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .filter(|(_, bs, es, ms)| {\n            (es.len() > 1 || es.len() == 1 && es[0] > 1)\n                && *bs.last().unwrap() != 0\n                && *es.last().unwrap() != 0\n                && *ms.last().unwrap() != 0\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_unsigned_vec_quadruple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_unsigned_vec_quadruple_gen_var_6(config).map(|(out, bs, es, mut ms)| {\n            ms[0] |= 1;\n            (out, bs, es, ms)\n        }),\n    )\n}\n\n// -- large types --\n\n// vars 1 through 4 are in malachite-base\n\nfn random_half_gcd_matrix(\n    s: usize,\n    n: usize,\n    xs: &mut RandomPrimitiveInts<Limb>,\n) -> OwnedHalfGcdMatrix {\n    assert!(s >= n);\n    let mut m00 = xs.take(n).collect_vec();\n    let m01 = xs.take(n).collect_vec();\n    let m10 = xs.take(n).collect_vec();\n    let m11 = xs.take(n).collect_vec();\n    m00.resize(s << 2, 0);\n    m00[s..s + n].copy_from_slice(&m01);\n    m00[s << 1..(s << 1) + n].copy_from_slice(&m10);\n    m00[s * 3..s * 3 + n].copy_from_slice(&m11);\n    half_gcd_matrix_create(s, n, m00)\n}\n\nstruct HalfGcdMatrixAndVecGenerator {\n    sizes: GeometricRandomNaturalValues<usize>,\n    xs: RandomPrimitiveInts<Limb>,\n    bs: RandomBools,\n}\n\nimpl Iterator for HalfGcdMatrixAndVecGenerator {\n    type Item = (OwnedHalfGcdMatrix, Vec<Limb>, u8);\n\n    fn next(&mut self) -> Option<Self::Item> {\n        loop {\n            let x = self.sizes.next().unwrap();\n            let qs_len = x.checked_add(1);\n            let qs_len = if let Some(qs_len) = qs_len {\n                qs_len\n            } else {\n                continue;\n            };\n            let y = self.sizes.next().unwrap();\n            let m_n = qs_len.checked_add(y);\n            let m_n = if let Some(m_n) = m_n { m_n } else { continue };\n            let z = self.sizes.next().unwrap();\n            let m_s = m_n.checked_add(z);\n            let m_s = if let Some(m_s) = m_s { m_s } else { continue };\n            let m_s_1 = m_s.checked_add(2);\n            let m_s_1 = if let Some(m_s_1) = m_s_1 {\n                m_s_1\n            } else {\n                continue;\n            };\n            let m_s_2 = m_s.checked_add(qs_len);\n            let m_s_2 = if let Some(m_s_2) = m_s_2 {\n                m_s_2\n            } else {\n                continue;\n            };\n            let m_s = max(m_s_1, m_s_2);\n            let m = random_half_gcd_matrix(m_s, m_n, &mut self.xs);\n            let qs = (&mut self.xs).take(qs_len).collect_vec();\n            let column = u8::from(self.bs.next().unwrap());\n            return Some((m, qs, column));\n        }\n    }\n}\n\npub fn random_large_type_gen_var_5(config: &GenConfig) -> It<(OwnedHalfGcdMatrix, Vec<Limb>, u8)> {\n    Box::new(HalfGcdMatrixAndVecGenerator {\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_6(\n    config: &GenConfig,\n) -> It<(HalfGcdMatrix1, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    reshape_1_3_to_4(Box::new(\n        random_quadruples_from_single(random_primitive_ints(EXAMPLE_SEED.fork(\"m\")))\n            .map(|(m00, m01, m10, m11)| HalfGcdMatrix1 {\n                data: [[m00, m01], [m10, m11]],\n            })\n            .zip(PrimitiveIntVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                    EXAMPLE_SEED.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(x, y, z)| {\n                    let xs_len = x;\n                    let ys_len = x.checked_add(1)?.checked_add(y)?;\n                    let out_len = x.checked_add(1)?.checked_add(z)?;\n                    Some((out_len, xs_len, ys_len))\n                }),\n                xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n            }),\n    ))\n}\n\nstruct HalfGcdMatrixAndHalfGcdMatrix1Generator {\n    sizes: GeometricRandomNaturalValues<usize>,\n    xs: RandomPrimitiveInts<Limb>,\n    small_xs: RandomUnsignedBitChunks<Limb>,\n}\n\nimpl Iterator for HalfGcdMatrixAndHalfGcdMatrix1Generator {\n    type Item = (OwnedHalfGcdMatrix, HalfGcdMatrix1);\n\n    fn next(&mut self) -> Option<Self::Item> {\n        loop {\n            let x = self.sizes.next().unwrap();\n            let n = x.checked_add(1);\n            let n = if let Some(n) = n { n } else { continue };\n            let y = self.sizes.next().unwrap();\n            let s = n.checked_add(y);\n            let s = if let Some(s) = s { s } else { continue };\n            let s = s.checked_add(1);\n            let s = if let Some(s) = s { s } else { continue };\n            let m = random_half_gcd_matrix(s, n, &mut self.xs);\n            let m_1 = HalfGcdMatrix1 {\n                data: [\n                    [self.small_xs.next().unwrap(), self.small_xs.next().unwrap()],\n                    [self.small_xs.next().unwrap(), self.small_xs.next().unwrap()],\n                ],\n            };\n            return Some((m, m_1));\n        }\n    }\n}\n\npub fn random_large_type_gen_var_7(config: &GenConfig) -> It<(OwnedHalfGcdMatrix, HalfGcdMatrix1)> {\n    Box::new(HalfGcdMatrixAndHalfGcdMatrix1Generator {\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        small_xs: random_unsigned_bit_chunks(EXAMPLE_SEED.fork(\"small_xs\"), Limb::WIDTH - 1),\n    })\n}\n\nstruct MatrixMul22Generator {\n    sizes: GeometricRandomNaturalValues<usize>,\n    xs: RandomPrimitiveInts<Limb>,\n}\n\nimpl Iterator for MatrixMul22Generator {\n    type Item = T8;\n\n    fn next(&mut self) -> Option<Self::Item> {\n        let ys_len = self.sizes.next().unwrap();\n        let xs_len = self.sizes.next().unwrap();\n        let sum = ys_len + xs_len + 1;\n        Some((\n            (&mut self.xs).take(sum).collect_vec(),\n            (&mut self.xs).take(sum).collect_vec(),\n            (&mut self.xs).take(sum).collect_vec(),\n            (&mut self.xs).take(sum).collect_vec(),\n            xs_len,\n            (&mut self.xs).take(ys_len).collect_vec(),\n            (&mut self.xs).take(ys_len).collect_vec(),\n            (&mut self.xs).take(ys_len).collect_vec(),\n            (&mut self.xs).take(ys_len).collect_vec(),\n        ))\n    }\n}\n\npub fn random_large_type_gen_var_8(config: &GenConfig) -> It<T8> {\n    Box::new(MatrixMul22Generator {\n        sizes: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n    })\n}\n\n// var 9 is in malachite-base.\n\npub fn random_large_type_gen_var_10(config: &GenConfig) -> It<(Vec<Limb>, Vec<Limb>, Limb, Limb)> {\n    reshape_2_2_to_4(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| PrimitiveIntVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            xs: random_primitive_ints(seed.fork(\"xs\")),\n        },\n        &|seed| {\n            random_pairs(\n                seed,\n                &|seed_2| random_values_from_vec(seed_2, factors_of_limb_max()),\n                &random_primitive_ints,\n            )\n        },\n    )))\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_11(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(3)?;\n                    d_init_len = d_init_len.checked_add(2)?;\n                    let d_len = d_init_len + 1;\n                    if n_len >= d_len && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                random_unsigned_inclusive_range(seed, Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX)\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (q, n, d_init, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_12(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| PrimitiveIntVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<usize>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(mut q_len, mut n_len, mut d_init_len)| {\n                    q_len = q_len.checked_add(3)?;\n                    n_len = n_len.checked_add(9)?;\n                    d_init_len = d_init_len.checked_add(5)?;\n                    let d_len = d_init_len + 1;\n                    if n_len >= d_len + 3 && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                xs: random_primitive_ints(seed.fork(\"xs\")),\n            },\n            &|seed| {\n                random_unsigned_inclusive_range(seed, Limb::power_of_2(Limb::WIDTH - 1), Limb::MAX)\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (q, n, d_init, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_13(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_positive_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter(|&(q_len, n_len, d_len)| q_len >= n_len && n_len >= d_len),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_14(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_positive_unsigneds::<usize>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(1)?;\n                if q_len >= n_len && n_len > d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_15(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(1)?;\n                if q_len >= n_len && n_len > d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_16(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        PrimitiveIntVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                usize::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter(|&(q_len, n_len, d_len)| q_len >= n_len && n_len >= d_len),\n            xs: random_primitive_ints(EXAMPLE_SEED.fork(\"xs\")),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_17(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            &random_primitive_ints,\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .map(|mut d| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            let is = vec![0; d.len()];\n            let scratch = vec![0; limbs_modular_invert_scratch_len(d.len())];\n            (is, scratch, d, inverse)\n        }),\n    )\n}\n\npub fn random_large_type_gen_var_18(config: &GenConfig) -> It<(Vec<Limb>, usize, Limb, Limb, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_positive_unsigneds,\n        )\n        .filter_map(|(ns, fraction_len, d)| {\n            if ns.len() <= fraction_len {\n                None\n            } else {\n                let shift = LeadingZeros::leading_zeros(d);\n                let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n                Some((ns, fraction_len, d, d_inv, shift))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_19(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, usize, Vec<Limb>, Limb, Limb, u64)> {\n    Box::new(\n        random_quadruples_xyxz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_positive_unsigneds,\n        )\n        .filter_map(|(out, fraction_len, ns, d)| {\n            if ns.is_empty() || out.len() < ns.len() + fraction_len {\n                None\n            } else {\n                let shift = LeadingZeros::leading_zeros(d);\n                let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n                Some((out, fraction_len, ns, d, d_inv, shift))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_20(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>, usize, usize)> {\n    Box::new(\n        random_quintuples_xyyyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_vecs_min_length(\n                    seed,\n                    2,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                random_vecs(\n                    seed,\n                    &random_primitive_ints,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    3,\n                    u32::MAX,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(ds, mut scratch, mut qs, mut rs_hi, n_len)| {\n            let n_len = usize::wrapping_from(n_len);\n            let d_len = ds.len();\n            if n_len < d_len {\n                return None;\n            }\n            let i_len = limbs_div_mod_barrett_is_len(n_len - d_len, d_len);\n            if i_len == 0 || qs.len() < i_len {\n                return None;\n            }\n            qs.truncate(i_len);\n            if rs_hi.len() < i_len {\n                return None;\n            }\n            rs_hi.truncate(i_len);\n            let scratch_len = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1);\n            let x = limbs_div_mod_barrett_scratch_len(n_len, d_len);\n            if x < i_len {\n                return None;\n            }\n            let actual_scratch_len = x - i_len;\n            if actual_scratch_len < d_len + i_len {\n                return None;\n            }\n            if scratch.len() < actual_scratch_len {\n                return None;\n            }\n            scratch.truncate(actual_scratch_len);\n            Some((scratch, ds, qs, rs_hi, scratch_len, i_len))\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn random_large_type_gen_var_21(\n    _config: &GenConfig,\n) -> It<(Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Box::new(\n        random_sextuples_from_single(random_primitive_ints(EXAMPLE_SEED))\n            .filter_map(large_type_filter_map_1),\n    )\n}\n\n// var 22 is in malachite-base.\n\nstruct RationalFromPowerOf2DigitsGenerator {\n    log_bases: GeometricRandomNaturalValues<u64>,\n    sizes: GeometricRandomNaturalValues<usize>,\n    xs_map: HashMap<u64, RandomNaturalsLessThan>,\n}\n\nimpl Iterator for RationalFromPowerOf2DigitsGenerator {\n    type Item = (u64, Vec<Natural>, RationalSequence<Natural>);\n\n    fn next(&mut self) -> Option<(u64, Vec<Natural>, RationalSequence<Natural>)> {\n        let log_base = self.log_bases.next().unwrap();\n        let xs = self.xs_map.entry(log_base).or_insert_with(|| {\n            let seed = EXAMPLE_SEED.fork(&log_base.to_string());\n            random_naturals_less_than(seed, Natural::power_of_2(log_base))\n        });\n        let before_point = xs.take(self.sizes.next().unwrap()).collect();\n        let non_repeating = xs.take(self.sizes.next().unwrap()).collect();\n        let repeating = xs.take(self.sizes.next().unwrap()).collect();\n        Some((\n            log_base,\n            before_point,\n            RationalSequence::from_vecs(non_repeating, repeating),\n        ))\n    }\n}\n\npub fn random_large_type_gen_var_23(\n    config: &GenConfig,\n) -> It<(u64, Vec<Natural>, RationalSequence<Natural>)> {\n    Box::new(RationalFromPowerOf2DigitsGenerator {\n        log_bases: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs_map: HashMap::new(),\n    })\n}\n\nstruct RationalFromPowerOf2DigitsBinaryGenerator {\n    sizes: GeometricRandomNaturalValues<usize>,\n    bits: RandomBools,\n}\n\nimpl Iterator for RationalFromPowerOf2DigitsBinaryGenerator {\n    type Item = (Vec<Natural>, RationalSequence<Natural>);\n\n    fn next(&mut self) -> Option<(Vec<Natural>, RationalSequence<Natural>)> {\n        let before_point = (&mut self.bits)\n            .map(Natural::from)\n            .take(self.sizes.next().unwrap())\n            .collect();\n        let non_repeating = (&mut self.bits)\n            .map(Natural::from)\n            .take(self.sizes.next().unwrap())\n            .collect();\n        let repeating = (&mut self.bits)\n            .map(Natural::from)\n            .take(self.sizes.next().unwrap())\n            .collect();\n        Some((\n            before_point,\n            RationalSequence::from_vecs(non_repeating, repeating),\n        ))\n    }\n}\n\npub fn random_large_type_gen_var_24(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, RationalSequence<Natural>)> {\n    Box::new(RationalFromPowerOf2DigitsBinaryGenerator {\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        bits: random_bools(EXAMPLE_SEED.fork(\"bits\")),\n    })\n}\n\nstruct RationalFromDigitsGenerator {\n    bases: RandomNaturalRangeToInfinity,\n    sizes: GeometricRandomNaturalValues<usize>,\n    xs_map: HashMap<Natural, RandomNaturalsLessThan>,\n}\n\nimpl Iterator for RationalFromDigitsGenerator {\n    type Item = (Natural, Vec<Natural>, RationalSequence<Natural>);\n\n    fn next(&mut self) -> Option<(Natural, Vec<Natural>, RationalSequence<Natural>)> {\n        let base = self.bases.next().unwrap();\n        let xs = self.xs_map.entry(base.clone()).or_insert_with(|| {\n            let seed = EXAMPLE_SEED.fork(&base.to_string());\n            random_naturals_less_than(seed, base.clone())\n        });\n        let before_point = xs.take(self.sizes.next().unwrap()).collect();\n        let non_repeating = xs.take(self.sizes.next().unwrap()).collect();\n        let repeating = xs.take(self.sizes.next().unwrap()).collect();\n        Some((\n            base,\n            before_point,\n            RationalSequence::from_vecs(non_repeating, repeating),\n        ))\n    }\n}\n\npub fn random_large_type_gen_var_25(\n    config: &GenConfig,\n) -> It<(Natural, Vec<Natural>, RationalSequence<Natural>)> {\n    Box::new(RationalFromDigitsGenerator {\n        bases: random_natural_range_to_infinity(\n            EXAMPLE_SEED,\n            Natural::TWO,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs_map: HashMap::new(),\n    })\n}\n\nstruct RationalFromDigitsDecimalGenerator {\n    sizes: GeometricRandomNaturalValues<usize>,\n    digits: RandomNaturalsLessThan,\n}\n\nimpl Iterator for RationalFromDigitsDecimalGenerator {\n    type Item = (Vec<Natural>, RationalSequence<Natural>);\n\n    fn next(&mut self) -> Option<(Vec<Natural>, RationalSequence<Natural>)> {\n        let before_point = (&mut self.digits)\n            .take(self.sizes.next().unwrap())\n            .collect();\n        let non_repeating = (&mut self.digits)\n            .take(self.sizes.next().unwrap())\n            .collect();\n        let repeating = (&mut self.digits)\n            .take(self.sizes.next().unwrap())\n            .collect();\n        Some((\n            before_point,\n            RationalSequence::from_vecs(non_repeating, repeating),\n        ))\n    }\n}\n\npub fn random_large_type_gen_var_26(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, RationalSequence<Natural>)> {\n    Box::new(RationalFromDigitsDecimalGenerator {\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        digits: random_naturals_less_than(EXAMPLE_SEED.fork(\"digits\"), Natural::from(10u32)),\n    })\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/generators/special_random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::integer::logic::bit_access::limbs_vec_clear_bit_neg;\nuse crate::integer::random::{\n    StripedRandomIntegers, striped_random_integers, striped_random_natural_integers,\n    striped_random_negative_integers, striped_random_nonzero_integers,\n};\nuse crate::natural::arithmetic::div_exact::{\n    limbs_modular_invert_limb, limbs_modular_invert_scratch_len,\n};\nuse crate::natural::arithmetic::div_mod::{\n    limbs_div_mod_barrett_is_len, limbs_div_mod_barrett_scratch_len, limbs_invert_limb,\n    limbs_two_limb_inverse_helper,\n};\nuse crate::natural::arithmetic::eq_mod::limbs_eq_mod_ref_ref_ref;\nuse crate::natural::arithmetic::gcd::half_gcd::HalfGcdMatrix1;\nuse crate::natural::arithmetic::mod_power_of_2::limbs_slice_mod_power_of_2_in_place;\nuse crate::natural::arithmetic::mod_power_of_2_square::SQRLO_DC_THRESHOLD_LIMIT;\nuse crate::natural::arithmetic::mul::limb::limbs_vec_mul_limb_in_place;\nuse crate::natural::arithmetic::mul::limbs_mul;\nuse crate::natural::arithmetic::mul::mul_mod::limbs_mul_mod_base_pow_n_minus_1_next_size;\nuse crate::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_22_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_32_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_42_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_43_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_44_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_52_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_53_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_54_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_62_input_sizes_valid,\n    limbs_mul_greater_to_out_toom_63_input_sizes_valid,\n};\nuse crate::natural::arithmetic::square::{\n    limbs_square_to_out_toom_3_input_size_valid, limbs_square_to_out_toom_4_input_size_valid,\n    limbs_square_to_out_toom_6_input_size_valid, limbs_square_to_out_toom_8_input_size_valid,\n};\nuse crate::natural::conversion::digits::general_digits::{\n    GET_STR_PRECOMPUTE_THRESHOLD, limbs_digit_count, limbs_per_digit_in_base,\n};\nuse crate::natural::random::{\n    StripedRandomNaturalInclusiveRange, StripedRandomNaturalRangeToInfinity, StripedRandomNaturals,\n    get_striped_random_natural_with_bits, get_striped_random_natural_with_up_to_bits,\n    striped_random_natural_range, striped_random_natural_range_to_infinity,\n    striped_random_naturals, striped_random_positive_naturals,\n};\nuse crate::natural::{Natural, limb_to_bit_count};\nuse crate::platform::{DoubleLimb, Limb, SQR_TOOM2_THRESHOLD};\nuse crate::test_util::extra_variadic::{\n    random_quadruples_from_single, random_quadruples_xxxy, random_quadruples_xyxz,\n    random_quadruples_xyyx, random_quadruples_xyyz, random_quintuples_xyyyz,\n    random_sextuples_from_single, random_triples, random_triples_from_single, random_triples_xxy,\n    random_triples_xyx, random_triples_xyy,\n};\nuse crate::test_util::generators::exhaustive::{\n    filter_helper_1, filter_helper_2, filter_helper_3, filter_helper_4, filter_helper_5,\n    filter_helper_6, filter_map_helper_1, filter_map_helper_2, filter_map_helper_3,\n    gcd_input_filter, large_type_filter_map_1, limbs_eq_mod_map, limbs_significant_bits_helper,\n    map_helper_1, map_helper_2, map_helper_3, round_to_multiple_integer_filter_map,\n    round_to_multiple_natural_filter_map,\n};\nuse crate::test_util::generators::{T8, factors_of_limb_max};\nuse crate::test_util::natural::arithmetic::gcd::{OwnedHalfGcdMatrix, half_gcd_matrix_create};\nuse malachite_base::bools::random::{RandomBools, random_bools};\nuse malachite_base::iterators::with_special_value;\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, CeilingLogBase2, CoprimeWith, DivRound, DivisibleBy, DivisibleByPowerOf2,\n    EqMod, EqModPowerOf2, Parity, PowerOf2, RoundToMultipleOfPowerOf2Assign,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::string::options::random::random_to_sci_options;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, SaturatingFrom, ToSci, WrappingFrom,\n};\nuse malachite_base::num::logic::traits::{\n    BitAccess, BitConvertible, LeadingZeros, SignificantBits,\n};\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, GeometricRandomSignedRange, GeometricRandomSigneds,\n    geometric_random_positive_unsigneds, geometric_random_signed_range, geometric_random_signeds,\n    geometric_random_unsigned_inclusive_range, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::striped::{\n    StripedBitSource, StripedRandomUnsignedBitChunks, StripedRandomUnsignedVecs,\n    get_striped_bool_vec, get_striped_unsigned_vec, striped_random_natural_signeds,\n    striped_random_positive_unsigneds, striped_random_signeds, striped_random_unsigned_bit_chunks,\n    striped_random_unsigned_inclusive_range, striped_random_unsigned_vecs,\n    striped_random_unsigned_vecs_length_range, striped_random_unsigned_vecs_min_length,\n    striped_random_unsigneds,\n};\nuse malachite_base::num::random::{\n    RandomUnsignedRange, RandomUnsignedsLessThan, random_primitive_floats,\n    random_unsigneds_less_than,\n};\nuse malachite_base::options::random::{RandomOptions, random_options};\nuse malachite_base::random::{EXAMPLE_SEED, Seed};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::random::random_rounding_modes;\nuse malachite_base::test_util::generators::common::{\n    GenConfig, It, permute_1_3_2, reshape_1_3_to_4, reshape_2_1_to_3, reshape_2_2_to_4,\n};\nuse malachite_base::test_util::generators::random::get_two_highest;\nuse malachite_base::test_util::generators::special_random::{\n    UnsignedVecPairLenGenerator1, UnsignedVecPairLenGenerator2, UnsignedVecQuadrupleLenGenerator1,\n    UnsignedVecTripleLenGenerator1, UnsignedVecTripleXYYLenGenerator,\n    special_random_unsigned_vec_unsigned_pair_gen_var_17,\n};\nuse malachite_base::tuples::random::{\n    random_ordered_unique_pairs, random_pairs, random_pairs_from_single,\n};\nuse malachite_base::unions::Union2;\nuse malachite_base::unions::random::random_union2s;\nuse malachite_base::vecs::random::random_vecs;\nuse malachite_base::vecs::{RandomValuesFromVec, random_values_from_vec};\nuse num::{BigInt, BigUint};\nuse std::cmp::{Ordering::*, max};\nuse std::collections::HashMap;\nuse std::marker::PhantomData;\nuse std::ops::{Shl, Shr};\n\n// -- Integer --\n\npub fn special_random_integer_gen(config: &GenConfig) -> It<Integer> {\n    Box::new(striped_random_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_integer_gen_var_1<T: PrimitiveFloat>(config: &GenConfig) -> It<Integer> {\n    Box::new(with_special_value(\n        EXAMPLE_SEED,\n        Integer::ZERO,\n        1,\n        100,\n        &|seed| {\n            random_pairs(\n                seed,\n                &|seed_2| {\n                    special_random_positive_float_naturals::<T>(\n                        seed_2,\n                        0,\n                        config.get_or(\"exponent_mean_n\", 8),\n                        config.get_or(\"exponent_mean_d\", 1),\n                        config.get_or(\"mean_stripe_n\", 16),\n                        config.get_or(\"mean_stripe_d\", 1),\n                    )\n                },\n                &random_bools,\n            )\n            .map(|(n, b)| Integer::from_sign_and_abs(b, n))\n        },\n    ))\n}\n\npub fn special_random_integer_gen_var_2<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<Integer>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                special_random_positive_float_naturals::<T>(\n                    seed,\n                    1,\n                    config.get_or(\"exponent_mean_n\", 8),\n                    config.get_or(\"exponent_mean_d\", 1),\n                    config.get_or(\"mean_stripe_n\", 16),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n                .filter_map(|a| {\n                    let b = Natural::exact_from(T::exact_from(&a).next_higher());\n                    let diff = b - &a;\n                    if diff.even() {\n                        // This happens almost always\n                        Some(a + (diff >> 1))\n                    } else {\n                        None\n                    }\n                })\n            },\n            &random_bools,\n        )\n        .map(|(n, b)| Integer::from_sign_and_abs(b, n)),\n    )\n}\n\npub fn special_random_integer_gen_var_3(config: &GenConfig) -> It<Integer> {\n    Box::new(striped_random_natural_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_integer_gen_var_4<T: PrimitiveUnsigned>(config: &GenConfig) -> It<Integer>\nwhere\n    Integer: From<T>,\n{\n    Box::new(\n        striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(Integer::from),\n    )\n}\n\npub fn special_random_integer_gen_var_5<T: PrimitiveSigned>(config: &GenConfig) -> It<Integer>\nwhere\n    Integer: From<T>,\n{\n    Box::new(\n        striped_random_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(Integer::from),\n    )\n}\n\npub fn special_random_integer_gen_var_6(config: &GenConfig) -> It<Integer> {\n    Box::new(striped_random_negative_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_integer_gen_var_7(config: &GenConfig) -> It<Integer> {\n    Box::new(striped_random_nonzero_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_integer_gen_var_8<T: PrimitiveFloat>(config: &GenConfig) -> It<Integer>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Natural>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_natural_range_to_infinity(\n                    seed,\n                    Natural::power_of_2(T::MANTISSA_WIDTH + 1) | Natural::ONE,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n                .filter(|n| !T::convertible_from(n))\n            },\n            &random_bools,\n        )\n        .map(|(n, b)| Integer::from_sign_and_abs(b, n)),\n    )\n}\n\npub fn special_random_integer_gen_var_9(config: &GenConfig) -> It<Integer> {\n    Box::new(\n        striped_random_natural_integers(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|n| (n << 1u32) | Integer::ONE),\n    )\n}\n\n// -- (Integer, Integer) --\n\npub fn special_random_integer_pair_gen(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(random_pairs_from_single(striped_random_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_integer_pair_gen_var_1(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_nonzero_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_pair_gen_var_2(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y)| (x * &y, y)),\n    )\n}\n\npub fn special_random_integer_pair_gen_var_3(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn special_random_integer_pair_gen_var_4(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_natural_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(a, n)| (a, (n << 1u32) | Integer::ONE)),\n    )\n}\n\npub fn special_random_integer_pair_gen_var_5(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs_from_single(striped_random_integers(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y)| x.unsigned_abs_ref().coprime_with(y.unsigned_abs_ref())),\n    )\n}\n\npub fn special_random_integer_pair_gen_var_6(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(\n        random_pairs_from_single(\n            striped_random_natural_integers(\n                EXAMPLE_SEED,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n            .map(|n| (n << 1u32) | Integer::ONE),\n        )\n        .filter(|(x, y)| x.unsigned_abs_ref().coprime_with(y.unsigned_abs_ref())),\n    )\n}\n\npub fn special_random_integer_pair_gen_var_7(config: &GenConfig) -> It<(Integer, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds::<Limb>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Integer::from)\n        },\n    ))\n}\n\n// -- (Integer, Integer, Integer) --\n\npub fn special_random_integer_triple_gen(config: &GenConfig) -> It<(Integer, Integer, Integer)> {\n    Box::new(random_triples_from_single(striped_random_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_integer_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Integer)> {\n    Box::new(random_triples_from_single(striped_random_natural_integers(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_integer_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Integer)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_natural_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(a, b, n)| (a, b, (n << 1u32) | Integer::ONE)),\n    )\n}\n\npub fn special_random_integer_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Integer)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_natural_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(a, m, n)| (a, (m << 1u32) | Integer::ONE, (n << 1u32) | Integer::ONE)),\n    )\n}\n\n// -- (Integer, Integer, Integer, PrimitiveUnsigned) --\n\npub fn special_random_integer_integer_integer_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Integer, T)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, Integer, Natural) --\n\npub fn special_random_integer_integer_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_integer_natural_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Natural)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, m)| (x * Integer::from(&m) + &y, y, m)),\n    )\n}\n\npub fn special_random_integer_integer_natural_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, Integer, Natural)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\n// -- (Integer, Integer, PrimitiveFloat) --\n\npub fn special_random_integer_integer_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Integer, Integer, PrimitiveSigned) --\n\npub fn special_random_integer_integer_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, Integer, PrimitiveUnsigned) --\n\npub fn special_random_integer_integer_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_integer_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_integer_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, pow)| ((x << pow) + &y, y, pow)),\n    )\n}\n\npub fn special_random_integer_integer_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, Integer, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(ref x, ref y, pow)| !x.eq_mod_power_of_2(y, pow.exact_into())),\n    )\n}\n\n// -- (Integer, Integer, RoundingMode) --\n\npub fn special_random_integer_integer_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, Integer, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(x, y, rm)| {\n            if rm == Exact {\n                (x * &y, y, rm)\n            } else {\n                (x, y, rm)\n            }\n        }),\n    )\n}\n\npub fn special_random_integer_integer_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, Integer, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_integer_filter_map(x, y, rm)),\n    )\n}\n\n// -- (Integer, Natural) --\n\npub fn special_random_integer_natural_pair_gen(config: &GenConfig) -> It<(Integer, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, Natural, Natural) --\n\npub fn special_random_integer_natural_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Integer, Natural, Natural)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveFloat) --\n\npub fn special_random_integer_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Integer, PrimitiveFloat, PrimitiveFloat) --\n\npub fn special_random_integer_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Integer, PrimitiveSigned) --\n\npub fn special_random_integer_signed_pair_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, PrimitiveSigned) ---\n\npub fn special_random_integer_signed_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_integer_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Integer, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveSigned, RoundingMode) --\n\npub fn special_random_integer_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shr<T, Output = Integer>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i < T::ZERO && rm == Exact {\n                    n >> i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\npub fn special_random_integer_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i > T::ZERO && rm == Exact {\n                    n << i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned) --\n\npub fn special_random_integer_unsigned_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::from(36u8),\n                config.get_or(\"mean_bits_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_natural_integers(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", 32),\n                            config.get_or(\"mean_stripe_d\", 1),\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_negative_integers(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", 32),\n                            config.get_or(\"mean_stripe_d\", 1),\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds::<T>(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                        .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE))\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_integer_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed_2| {\n                striped_random_integers(\n                    seed_2,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(mut x, y)| {\n            x.round_to_multiple_of_power_of_2_assign(y.exact_into(), Down);\n            (x, y)\n        }),\n    )\n}\n\npub fn special_random_integer_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn special_random_integer_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, bool) --\n\npub fn special_random_integer_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, Natural) --\n\npub fn special_random_integer_unsigned_natural_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, Natural)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_integer_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Integer, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::from(36u8),\n                config.get_or(\"mean_bits_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_unsigned_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, z)| if y <= z { (xs, y, z) } else { (xs, z, y) }),\n    )\n}\n\npub fn special_random_integer_unsigned_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Integer, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\npub fn special_random_integer_unsigned_unsigned_natural_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Integer, T, T, Natural)> {\n    Box::new(\n        random_quadruples_xyyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\n// -- (Integer, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_integer_unsigned_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, u64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<u64>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, u, rm)| {\n            if rm == Exact {\n                (n << u, u, rm)\n            } else {\n                (n, u, rm)\n            }\n        }),\n    )\n}\n\npub fn special_random_integer_unsigned_rounding_mode_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)>\nwhere\n    Integer: Shl<T, Output = Integer>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, u, rm)| (if rm == Exact { n << u } else { n }, u, rm)),\n    )\n}\n\n// vars 4 and 5 are in malachite-float.\n\npub fn special_random_integer_unsigned_rounding_mode_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Integer, T, RoundingMode)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds::<T>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (Integer, RoundingMode) --\n\npub fn special_random_integer_rounding_mode_pair_gen(\n    config: &GenConfig,\n) -> It<(Integer, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_integer_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Integer> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(Integer, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, rm)| rm != Exact || T::convertible_from(n)),\n    )\n}\n\npub fn special_random_integer_rounding_mode_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_nonzero_integers(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (Integer, ToSciOptions) --\n\npub fn special_random_integer_to_sci_options_pair_gen(\n    config: &GenConfig,\n) -> It<(Integer, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"small_mean_n\", 4),\n                config.get_or(\"small_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_integer_to_sci_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_integers(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"small_mean_n\", 4),\n                    config.get_or(\"small_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// --(Integer, Vec<bool>) --\n\nstruct IntegerBoolVecPairGenerator1 {\n    xs: StripedRandomIntegers<GeometricRandomSigneds<i64>>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl Iterator for IntegerBoolVecPairGenerator1 {\n    type Item = (Integer, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Integer, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = get_striped_bool_vec(\n            &mut self.striped_bit_source,\n            u64::exact_from(x.to_twos_complement_limbs_asc().len()),\n        );\n        Some((x, bs))\n    }\n}\n\npub fn special_random_integer_bool_vec_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Integer, Vec<bool>)> {\n    Box::new(IntegerBoolVecPairGenerator1 {\n        xs: striped_random_integers(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct IntegerBoolVecPairGenerator2 {\n    xs: StripedRandomIntegers<GeometricRandomSigneds<i64>>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl Iterator for IntegerBoolVecPairGenerator2 {\n    type Item = (Integer, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Integer, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = get_striped_bool_vec(\n            &mut self.striped_bit_source,\n            u64::exact_from(x.to_bits_asc().len()),\n        );\n        Some((x, bs))\n    }\n}\n\npub fn special_random_integer_bool_vec_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Integer, Vec<bool>)> {\n    Box::new(IntegerBoolVecPairGenerator2 {\n        xs: striped_random_integers(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- Natural --\n\npub fn special_random_natural_gen(config: &GenConfig) -> It<Natural> {\n    Box::new(striped_random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_natural_gen_var_1(config: &GenConfig) -> It<Natural> {\n    Box::new(striped_random_positive_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\nstruct SpecialRandomPositiveFloatNaturals<T: PrimitiveFloat> {\n    exponents: GeometricRandomSignedRange<i64>,\n    mantissas: StripedRandomUnsignedBitChunks<u64>,\n    phantom: PhantomData<T>,\n}\n\nimpl<T: PrimitiveFloat> Iterator for SpecialRandomPositiveFloatNaturals<T> {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        let exponent = self.exponents.next().unwrap();\n        let mut mantissa = self.mantissas.next().unwrap();\n        if exponent != 0 {\n            mantissa.set_bit(T::MANTISSA_WIDTH);\n        } else if mantissa == 0 {\n            mantissa = 1;\n        }\n        Some(Natural::from(mantissa) << exponent)\n    }\n}\n\nfn special_random_positive_float_naturals<T: PrimitiveFloat>(\n    seed: Seed,\n    start_exponent: i64,\n    mean_exponent_numerator: u64,\n    mean_exponent_denominator: u64,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n) -> SpecialRandomPositiveFloatNaturals<T> {\n    SpecialRandomPositiveFloatNaturals {\n        exponents: geometric_random_signed_range(\n            seed.fork(\"exponents\"),\n            start_exponent,\n            i64::power_of_2(T::EXPONENT_WIDTH - 1) - i64::wrapping_from(T::MANTISSA_WIDTH) - 1,\n            mean_exponent_numerator,\n            mean_exponent_denominator,\n        ),\n        mantissas: striped_random_unsigned_bit_chunks(\n            seed.fork(\"mantissas\"),\n            T::MANTISSA_WIDTH + 1,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        phantom: PhantomData,\n    }\n}\n\npub fn special_random_natural_gen_var_2<T: PrimitiveFloat>(config: &GenConfig) -> It<Natural> {\n    Box::new(with_special_value(\n        EXAMPLE_SEED,\n        Natural::ZERO,\n        1,\n        100,\n        &|seed| {\n            special_random_positive_float_naturals::<T>(\n                seed,\n                0,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"mean_stripe_n\", 16),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_gen_var_3<T: for<'a> ExactFrom<&'a Natural> + PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<Natural>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Box::new(\n        special_random_positive_float_naturals::<T>(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"mean_stripe_n\", 16),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .filter_map(|a| {\n            let b = Natural::exact_from(T::exact_from(&a).next_higher());\n            let diff = b - &a;\n            if diff.even() {\n                // This happens almost always\n                Some(a + (diff >> 1))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn special_random_natural_gen_var_4<T: PrimitiveUnsigned>(config: &GenConfig) -> It<Natural>\nwhere\n    Natural: From<T>,\n{\n    Box::new(\n        striped_random_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(Natural::from),\n    )\n}\n\npub fn special_random_natural_gen_var_5<T: PrimitiveSigned>(config: &GenConfig) -> It<Natural>\nwhere\n    Natural: ExactFrom<T>,\n{\n    Box::new(\n        striped_random_natural_signeds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        )\n        .map(Natural::exact_from),\n    )\n}\n\npub fn special_random_natural_gen_var_6(config: &GenConfig) -> It<Natural> {\n    Box::new(striped_random_natural_range_to_infinity(\n        EXAMPLE_SEED,\n        Natural::TWO,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\npub fn special_random_natural_gen_var_7<T: PrimitiveFloat>(config: &GenConfig) -> It<Natural>\nwhere\n    for<'a> T: ConvertibleFrom<&'a Natural>,\n{\n    Box::new(\n        striped_random_natural_range_to_infinity(\n            EXAMPLE_SEED,\n            Natural::power_of_2(T::MANTISSA_WIDTH + 1) | Natural::ONE,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", Limb::WIDTH << 1),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .filter(|n| !T::convertible_from(n)),\n    )\n}\n\npub fn special_random_natural_gen_var_8(config: &GenConfig) -> It<Natural> {\n    Box::new(\n        striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|n| (n << 1u32) | Natural::ONE),\n    )\n}\n\n// -- (Natural, bool) --\n\npub fn special_random_natural_bool_pair_gen(config: &GenConfig) -> It<(Natural, bool)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Natural, Integer, Natural) --\n\npub fn special_random_natural_integer_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Natural, Integer, Natural)> {\n    Box::new(random_triples_xyx(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, Natural) --\n\npub fn special_random_natural_pair_gen(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs_from_single(striped_random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_natural_pair_gen_var_1(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_pair_gen_var_2(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_pair_gen_var_3(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| (x * &y, y * z)),\n    )\n}\n\npub fn special_random_natural_pair_gen_var_4(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_pair_gen_var_5(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y)| (x * &y, y)),\n    )\n}\n\npub fn special_random_natural_pair_gen_var_6(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by(y)),\n    )\n}\n\npub fn special_random_natural_pair_gen_var_7(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_ordered_unique_pairs(striped_random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_natural_pair_gen_var_8(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs_from_single(striped_random_positive_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_natural_pair_gen_var_9(config: &GenConfig) -> It<(Natural, Natural)> {\n    // TODO\n    Box::new(\n        random_pairs_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y)| x >= y),\n    )\n}\n\npub fn special_random_natural_pair_gen_var_10(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::power_of_2(Limb::WIDTH),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64 + Limb::WIDTH),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_pair_gen_var_11(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_ordered_unique_pairs(\n        striped_random_positive_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n    ))\n}\n\npub fn special_random_natural_pair_gen_var_12(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(a, n)| (a, (n << 1u32) | Natural::ONE)),\n    )\n}\n\npub fn special_random_natural_pair_gen_var_13(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs_from_single(\n            striped_random_naturals(\n                EXAMPLE_SEED,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n            .map(|n| (n << 1u32) | Natural::ONE),\n        )\n        .filter(|(x, y)| x.coprime_with(y)),\n    )\n}\n\npub fn special_random_natural_pair_gen_var_14(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(\n        random_pairs_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y)| x.coprime_with(y)),\n    )\n}\n\npub fn special_random_natural_pair_gen_var_15(config: &GenConfig) -> It<(Natural, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds::<Limb>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from)\n        },\n    ))\n}\n\n// -- (Natural, Natural, bool) --\n\npub fn special_random_natural_natural_bool_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Natural, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Natural, Natural, Natural) --\n\npub fn special_random_natural_triple_gen(config: &GenConfig) -> It<(Natural, Natural, Natural)> {\n    Box::new(random_triples_from_single(striped_random_naturals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_natural_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, m)| (x * &m + &y, y, m)),\n    )\n}\n\npub fn special_random_natural_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter(|(x, y, m)| !x.eq_mod(y, m)),\n    )\n}\n\npub fn special_random_natural_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| {\n            let z = max(&x, &y) + z + Natural::ONE;\n            (x, y, z)\n        }),\n    )\n}\n\npub fn special_random_natural_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, mut z)| {\n            z += &x;\n            z += Natural::ONE;\n            (x, y, z)\n        }),\n    )\n}\n\npub fn special_random_natural_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(random_triples_from_single(\n        striped_random_positive_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n    ))\n}\n\npub fn special_random_natural_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| (x + &y * &z, y, z)),\n    )\n}\n\npub fn special_random_natural_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(a, b, n)| (a, b, (n << 1u32) | Natural::ONE)),\n    )\n}\n\npub fn special_random_natural_triple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural)> {\n    Box::new(\n        random_triples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(a, m, n)| (a, (m << 1u32) | Natural::ONE, (n << 1u32) | Natural::ONE)),\n    )\n}\n\n// -- (Natural, Natural, Natural, Natural) --\n\npub fn special_random_natural_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        random_quadruples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .filter_map(|(x, y, z, w)| {\n            let ranking = [(&x, 0), (&y, 1), (&z, 2), (&w, 3)];\n            let (hi, next_hi) = get_two_highest(&ranking);\n            if hi.0 == next_hi.0 {\n                None\n            } else {\n                Some(match hi.1 {\n                    0 => (y, z, w, x),\n                    1 => (x, z, w, y),\n                    2 => (x, y, w, z),\n                    _ => (x, y, z, w),\n                })\n            }\n        }),\n    )\n}\n\npub fn special_random_natural_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        random_quadruples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z, mut w)| {\n            w += max!(&x, &y);\n            w += Natural::ONE;\n            (x, y, z, w)\n        }),\n    )\n}\n\npub fn special_random_natural_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, Natural)> {\n    Box::new(\n        random_quadruples_from_single(striped_random_naturals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z, mut w)| {\n            w += &x;\n            w += Natural::ONE;\n            (x, y, z, w)\n        }),\n    )\n}\n\n// -- (Natural, Natural, Natural, PrimitiveUnsigned) --\n\npub fn special_random_natural_natural_natural_unsigned_quadruple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, T)> {\n    Box::new(random_quadruples_xxxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_natural_natural_unsigned_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        random_quadruples_xxxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z, mut m)| {\n            m += max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits()\n            );\n            (x, y, z, m)\n        }),\n    )\n}\n\npub fn special_random_natural_natural_natural_unsigned_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        random_quadruples_xxxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z, mut m)| {\n            m += max(x.significant_bits(), y.significant_bits());\n            (x, y, z, m)\n        }),\n    )\n}\n\npub fn special_random_natural_natural_natural_unsigned_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Natural, Natural, Natural, u64)> {\n    Box::new(\n        random_quadruples_xxxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, z, mut m)| {\n            m += x.significant_bits();\n            (x, y, z, m)\n        }),\n    )\n}\n\n// -- (Natural, Natural, PrimitiveFloat) --\n\npub fn special_random_natural_natural_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Natural, Natural, PrimitiveUnsigned) --\n\npub fn special_random_natural_natural_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, Natural, PrimitiveSigned) --\n\npub fn special_random_natural_natural_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_natural_signed_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_ordered_unique_pairs(striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            ))\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    )))\n}\n\n// -- (Natural, Natural, PrimitiveUnsigned) --\n\npub fn special_random_natural_natural_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_natural_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, pow)| ((x << pow) + &y, y, pow)),\n    )\n}\n\npub fn special_random_natural_natural_unsigned_triple_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|&(ref x, ref y, pow)| !x.eq_mod_power_of_2(y, pow.exact_into())),\n    )\n}\n\npub fn special_random_natural_natural_unsigned_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Natural, Natural, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += max(x.significant_bits(), y.significant_bits());\n            (x, y, m)\n        }),\n    )\n}\n\npub fn special_random_natural_natural_unsigned_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Natural, Natural, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\npub fn special_random_natural_natural_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, Natural, T)> {\n    reshape_2_1_to_3(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_ordered_unique_pairs(striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            ))\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    )))\n}\n\n// -- (Natural, Natural, RoundingMode) --\n\npub fn special_random_natural_natural_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Natural, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(x, y, rm)| {\n            if rm == Exact {\n                (x * &y, y, rm)\n            } else {\n                (x, y, rm)\n            }\n        }),\n    )\n}\n\npub fn special_random_natural_natural_rounding_mode_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Natural, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter_map(|(x, y, rm)| round_to_multiple_natural_filter_map(x, y, rm)),\n    )\n}\n\n// -- (Natural, PrimitiveFloat) --\n\npub fn special_random_natural_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Natural, PrimitiveFloat, PrimitiveFloat) --\n\npub fn special_random_natural_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Natural, PrimitiveSigned) --\n\npub fn special_random_natural_signed_pair_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_natural_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_signed_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_signed_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct NaturalBitsMultipleOfLimbBitsGenerator {\n    bit_source: StripedBitSource,\n    limb_counts: GeometricRandomNaturalValues<u64>,\n}\n\nimpl Iterator for NaturalBitsMultipleOfLimbBitsGenerator {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        Some(get_striped_random_natural_with_bits(\n            &mut self.bit_source,\n            self.limb_counts.next().unwrap() << Limb::LOG_WIDTH,\n        ))\n    }\n}\n\npub fn special_random_natural_signed_pair_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| NaturalBitsMultipleOfLimbBitsGenerator {\n            bit_source: StripedBitSource::new(\n                seed.fork(\"bit_source\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n            limb_counts: geometric_random_positive_unsigneds(\n                seed.fork(\"limb_counts\"),\n                config.get_or(\"mean_small_n\", 2),\n                config.get_or(\"mean_small_d\", 1),\n            ),\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, PrimitiveSigned) ---\n\npub fn special_random_natural_signed_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_natural_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\npub fn special_random_natural_signed_unsigned_triple_gen_var_2<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Natural, PrimitiveSigned, RoundingMode) --\n\npub fn special_random_natural_signed_rounding_mode_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shr<T, Output = Natural>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i < T::ZERO && rm == Exact {\n                    n >> i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\npub fn special_random_natural_signed_rounding_mode_triple_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, i, rm)| {\n            (\n                if i > T::ZERO && rm == Exact {\n                    n << i\n                } else {\n                    n\n                },\n                i,\n                rm,\n            )\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned) --\n\npub fn special_random_natural_unsigned_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_1<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::saturating_from(U::MAX),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::MAX,\n                config.get_or(\"mean_stripe_n\", T::WIDTH),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::from(36u8),\n                config.get_or(\"mean_stripe_n\", T::WIDTH),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_5<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, u64)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                1,\n                T::WIDTH,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed_2| {\n                striped_random_naturals(\n                    seed_2,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(mut x, y)| {\n            x.round_to_multiple_of_power_of_2_assign(y.exact_into(), Down);\n            (x, y)\n        }),\n    )\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 32),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !x.divisible_by_power_of_2(y.exact_into())),\n    )\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_10(config: &GenConfig) -> It<(Natural, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, mut m)| {\n            m += x.significant_bits();\n            (x, m)\n        }),\n    )\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_11<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_13<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_pair_gen_var_14(config: &GenConfig) -> It<(Natural, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, mut m)| {\n            m += x.significant_bits();\n            (x, m)\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, bool) --\n\npub fn special_random_natural_unsigned_bool_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, bool)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &random_bools,\n    ))\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned) ---\n\npub fn special_random_natural_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_unsigned_triple_gen_var_1<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::from(36u8),\n                config.get_or(\"mean_stripe_n\", T::WIDTH),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Natural, u64, T)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                1,\n                U::WIDTH,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 4),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_unsigned_triple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 32),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, z)| if y <= z { (xs, y, z) } else { (xs, z, y) }),\n    )\n}\n\npub fn special_random_natural_unsigned_unsigned_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"small_unsigned_mean_n\", 32),\n                config.get_or(\"small_unsigned_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_unsigned_unsigned_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .map(|(x, y, mut m)| {\n            m += x.significant_bits();\n            (x, y, m)\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, PrimitiveUnsigned, Natural) --\n\npub fn special_random_natural_unsigned_unsigned_natural_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Natural, T, T, Natural)> {\n    Box::new(\n        random_quadruples_xyyx::<_, _, T, _>(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(x, y, z, w)| match y.cmp(&z) {\n            Less => Some((x, y, z, w)),\n            Greater => Some((x, z, y, w)),\n            Equal => None,\n        }),\n    )\n}\n\n// -- (Natural, PrimitiveUnsigned, RoundingMode) --\n\npub fn special_random_natural_unsigned_rounding_mode_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Natural, T, RoundingMode)>\nwhere\n    Natural: Shl<T, Output = Natural>,\n{\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_excess_len_n\", 4),\n                    config.get_or(\"mean_excess_len_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .map(|(n, u, rm)| {\n            if rm == Exact {\n                (n << u, u, rm)\n            } else {\n                (n, u, rm)\n            }\n        }),\n    )\n}\n\n// var 2 is in malachite-float\n\n// --(Natural, PrimitiveUnsigned, Vec<bool>) --\n\nstruct NaturalUnsignedBoolVecTripleGenerator {\n    xs: StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n    log_bases: It<u64>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl Iterator for NaturalUnsignedBoolVecTripleGenerator {\n    type Item = (Natural, u64, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Natural, u64, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let log_base = self.log_bases.next().unwrap();\n        let bs = get_striped_bool_vec(\n            &mut self.striped_bit_source,\n            x.significant_bits().div_round(log_base, Ceiling).0,\n        );\n        Some((x, log_base, bs))\n    }\n}\n\npub fn special_random_natural_unsigned_bool_vec_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, u64, Vec<bool>)> {\n    Box::new(NaturalUnsignedBoolVecTripleGenerator {\n        xs: striped_random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        log_bases: Box::new(geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        )),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_natural_unsigned_bool_vec_triple_gen_var_2<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Natural, u64, Vec<bool>)> {\n    Box::new(NaturalUnsignedBoolVecTripleGenerator {\n        xs: striped_random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        log_bases: Box::new(striped_random_unsigned_inclusive_range(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            1,\n            T::WIDTH,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        )),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- (Natural, RoundingMode) --\n\npub fn special_random_natural_rounding_mode_pair_gen(\n    config: &GenConfig,\n) -> It<(Natural, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_natural_rounding_mode_pair_gen_var_1<\n    T: for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(Natural, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|&(ref n, rm)| rm != Exact || T::convertible_from(n)),\n    )\n}\n\npub fn special_random_natural_rounding_mode_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_naturals(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\n// -- (Natural, ToSciOptions) --\n\npub fn special_random_natural_to_sci_options_pair_gen(\n    config: &GenConfig,\n) -> It<(Natural, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"small_mean_n\", 4),\n                config.get_or(\"small_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_to_sci_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_naturals(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"small_mean_n\", 4),\n                    config.get_or(\"small_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- (Natural, Vec<bool>) --\n\nstruct NaturalBoolVecPairGenerator1 {\n    xs: StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl Iterator for NaturalBoolVecPairGenerator1 {\n    type Item = (Natural, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Natural, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = get_striped_bool_vec(&mut self.striped_bit_source, x.limb_count());\n        Some((x, bs))\n    }\n}\n\npub fn special_random_natural_bool_vec_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Natural, Vec<bool>)> {\n    Box::new(NaturalBoolVecPairGenerator1 {\n        xs: striped_random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct NaturalBoolVecPairGenerator2 {\n    xs: StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl Iterator for NaturalBoolVecPairGenerator2 {\n    type Item = (Natural, Vec<bool>);\n\n    fn next(&mut self) -> Option<(Natural, Vec<bool>)> {\n        let x = self.xs.next().unwrap();\n        let bs = get_striped_bool_vec(&mut self.striped_bit_source, x.significant_bits());\n        Some((x, bs))\n    }\n}\n\npub fn special_random_natural_bool_vec_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Natural, Vec<bool>)> {\n    Box::new(NaturalBoolVecPairGenerator2 {\n        xs: striped_random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- (PrimitiveUnsigned * 6) --\n\n// var 1 is in malachite-base.\n\npub fn special_random_unsigned_sextuple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_pairs_from_single(striped_random_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        ))\n                    },\n                    &|seed_2| {\n                        random_pairs(\n                            seed_2,\n                            &|seed_3| {\n                                striped_random_unsigned_inclusive_range(\n                                    seed_3,\n                                    Limb::power_of_2(Limb::WIDTH - 1),\n                                    Limb::MAX,\n                                    config.get_or(\"mean_stripe_n\", 32),\n                                    config.get_or(\"mean_stripe_d\", 1),\n                                )\n                            },\n                            &|seed_3| {\n                                striped_random_unsigneds(\n                                    seed_3,\n                                    config.get_or(\"mean_unsigned_stripe_n\", Limb::WIDTH >> 1),\n                                    config.get_or(\"mean_unsigned_stripe_d\", 1),\n                                )\n                            },\n                        )\n                    },\n                )\n                .filter(|&((n_2, n_1), (d_1, d_0))| n_2 < d_1 || n_2 == d_1 && n_1 < d_0)\n            },\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|(((n_2, n_1), (d_1, d_0)), n_0)| {\n            (\n                n_2,\n                n_1,\n                n_0,\n                d_1,\n                d_0,\n                limbs_two_limb_inverse_helper(d_1, d_0),\n            )\n        }),\n    )\n}\n\n// -- (String, String, String) --\n\npub fn special_random_string_triple_gen_var_1(config: &GenConfig) -> It<(String, String, String)> {\n    Box::new(\n        striped_random_naturals(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| {\n            (\n                serde_json::to_string(&BigUint::from(&x)).unwrap(),\n                serde_json::to_string(&rug::Integer::from(&x)).unwrap(),\n                serde_json::to_string(&x).unwrap(),\n            )\n        }),\n    )\n}\n\npub fn special_random_string_triple_gen_var_2(config: &GenConfig) -> It<(String, String, String)> {\n    Box::new(\n        striped_random_integers(\n            EXAMPLE_SEED.fork(\"xs\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| {\n            (\n                serde_json::to_string(&BigInt::from(&x)).unwrap(),\n                serde_json::to_string(&rug::Integer::from(&x)).unwrap(),\n                serde_json::to_string(&x).unwrap(),\n            )\n        }),\n    )\n}\n\n// -- Vec<Integer> --\n\npub fn special_random_integer_vec_gen(config: &GenConfig) -> It<Vec<Integer>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        config.get_or(\"mean_len_n\", 4),\n        config.get_or(\"mean_len_d\", 1),\n    ))\n}\n\n// -- Vec<Natural> --\n\npub fn special_random_natural_vec_gen(config: &GenConfig) -> It<Vec<Natural>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        config.get_or(\"mean_len_n\", 4),\n        config.get_or(\"mean_len_d\", 1),\n    ))\n}\n\n// -- (Vec<Natural>, Integer) --\n\npub fn special_random_natural_vec_integer_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    striped_random_positive_naturals(\n                        seed_2,\n                        config.get_or(\"mean_stripe_n\", 32),\n                        config.get_or(\"mean_stripe_d\", 1),\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_len_n\", 4),\n                config.get_or(\"mean_len_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Vec<Natural>, Natural) --\n\npub fn special_random_natural_vec_natural_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    striped_random_naturals(\n                        seed_2,\n                        config.get_or(\"mean_stripe_n\", 32),\n                        config.get_or(\"mean_stripe_d\", 1),\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_digit_count_n\", 4),\n                config.get_or(\"mean_digit_count_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::power_of_2(Limb::WIDTH),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                Limb::WIDTH + 4,\n                1,\n            )\n        },\n    ))\n}\n\npub fn special_random_natural_vec_natural_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    striped_random_naturals(\n                        seed_2,\n                        config.get_or(\"mean_stripe_n\", 32),\n                        config.get_or(\"mean_stripe_d\", 1),\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_digit_count_n\", 4),\n                config.get_or(\"mean_digit_count_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\nstruct LargeDigitsRandomGenerator {\n    bases: StripedRandomNaturalRangeToInfinity,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    bit_source: StripedBitSource,\n}\n\nimpl Iterator for LargeDigitsRandomGenerator {\n    type Item = (Vec<Natural>, Natural);\n\n    fn next(&mut self) -> Option<(Vec<Natural>, Natural)> {\n        let base = self.bases.next().unwrap();\n        let bits = base.ceiling_log_base_2();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut digits = Vec::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            loop {\n                let x = get_striped_random_natural_with_up_to_bits(&mut self.bit_source, bits);\n                if x < base {\n                    digits.push(x);\n                    break;\n                }\n            }\n        }\n        Some((digits, base))\n    }\n}\n\npub fn special_random_natural_vec_natural_pair_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(LargeDigitsRandomGenerator {\n        bases: striped_random_natural_range_to_infinity(\n            EXAMPLE_SEED.fork(\"bases\"),\n            Natural::power_of_2(Limb::WIDTH),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            Limb::WIDTH + 4,\n            1,\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"bit_source\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn striped_random_natural_vec_natural_pair_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, Natural)> {\n    Box::new(LargeDigitsRandomGenerator {\n        bases: striped_random_natural_range_to_infinity(\n            EXAMPLE_SEED.fork(\"bases\"),\n            Natural::TWO,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"bit_source\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// -- (Vec<Natural>, PrimitiveUnsigned) --\n\nstruct PowerOf2DigitsGenerator {\n    log_bases: GeometricRandomNaturalValues<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    bit_source: StripedBitSource,\n}\n\nimpl Iterator for PowerOf2DigitsGenerator {\n    type Item = (Vec<Natural>, u64);\n\n    fn next(&mut self) -> Option<(Vec<Natural>, u64)> {\n        let log_base = self.log_bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mut digits = Vec::with_capacity(digit_count);\n        for _ in 0..digit_count {\n            digits.push(get_striped_random_natural_with_up_to_bits(\n                &mut self.bit_source,\n                log_base,\n            ));\n        }\n        Some((digits, log_base))\n    }\n}\n\npub fn special_random_natural_vec_unsigned_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, u64)> {\n    Box::new(PowerOf2DigitsGenerator {\n        log_bases: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        digit_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_count\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"bit_source\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_natural_vec_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<Natural>, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_vecs(\n                seed,\n                &|seed_2| {\n                    striped_random_naturals(\n                        seed_2,\n                        config.get_or(\"mean_stripe_n\", 32),\n                        config.get_or(\"mean_stripe_d\", 1),\n                        config.get_or(\"mean_bits_n\", 64),\n                        config.get_or(\"mean_bits_d\", 1),\n                    )\n                },\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- Vec<PrimitiveUnsigned> --\n\n// vars 1 through 4 are in malachite-base.\n\npub fn special_random_unsigned_vec_gen_var_5(config: &GenConfig) -> It<Vec<Limb>> {\n    Box::new(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .map(|mut xs| {\n            limbs_vec_mul_limb_in_place(&mut xs, 3);\n            xs\n        }),\n    )\n}\n\n// var 6 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// vars 1 through 3 are in malachite-base\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_4<\n    T: PrimitiveUnsigned + SaturatingFrom<U>,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs_min_length(\n                seed,\n                2,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 6),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                T::TWO,\n                T::saturating_from(U::MAX),\n                config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// vars 5 through 17 are in malachite-base.\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_18(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, u64)> {\n    Box::new(\n        special_random_unsigned_vec_unsigned_pair_gen_var_17(config).filter(|(xs, index)| {\n            let mut mut_xs = xs.clone();\n            limbs_vec_clear_bit_neg(&mut mut_xs, *index);\n            mut_xs.len() == xs.len()\n        }),\n    )\n}\n\n// vars 19 through 25 are in malachite-base.\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_26(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|(mut xs, y)| {\n            limbs_vec_mul_limb_in_place(&mut xs, y);\n            (xs, y)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_pair_gen_var_27(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length::<Limb>(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_unsigned_n\", 4),\n                    config.get_or(\"mean_small_unsigned_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(mut xs, mut pow)| {\n            let xs_last = xs.last_mut().unwrap();\n            *xs_last = xs_last.checked_add(1)?;\n            pow += limbs_significant_bits_helper(&xs);\n            Some((xs, pow))\n        }),\n    )\n}\n\n// var 28 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, PrimitiveUnsigned) --\n\n// vars 1 through 5 are in malachite-base\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(|(m, x, y)| {\n            !Integer::from(Natural::from(*x)).eq_mod(-Natural::from(*y), Natural::from_limbs_asc(m))\n        }),\n    )\n}\n\n// vars 7 through 8 are in malachite-base.\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_9(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_unsigned_vecs(\n                seed,\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n        },\n        &|seed| random_values_from_vec(seed, factors_of_limb_max()),\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\n// var 10 is in malachite-base.\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_11(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(map_helper_3),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_12(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Limb)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(filter_helper_6),\n    )\n}\n\n// var 13 is in malachite-base.\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_14<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length::<Limb>(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            (xs, y, pow)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_15<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length::<Limb>(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            (xs, y, pow)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_16<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, T, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length::<Limb>(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigneds::<T>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, y, mut pow)| {\n            pow += max(limbs_significant_bits_helper(&xs), y.significant_bits());\n            if pow == 0 {\n                pow = 1;\n            }\n            (xs, y, pow)\n        }),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>) --\n\nstruct DigitsSpecialRandomGenerator<T: PrimitiveUnsigned> {\n    bases: RandomValuesFromVec<u64>,\n    xss: StripedRandomUnsignedVecs<Limb, GeometricRandomNaturalValues<u64>>,\n    bit_source: StripedBitSource,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for DigitsSpecialRandomGenerator<T> {\n    type Item = (Vec<T>, u64, Vec<Limb>);\n\n    fn next(&mut self) -> Option<(Vec<T>, u64, Vec<Limb>)> {\n        let base = self.bases.next().unwrap();\n        let xs = self.xss.next().unwrap();\n        let out_len = usize::exact_from(limbs_digit_count(&xs, base));\n        let out = get_striped_unsigned_vec(\n            &mut self.bit_source,\n            u64::exact_from(out_len) << T::LOG_WIDTH,\n        );\n        Some((out, base, xs))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, u64, Vec<Limb>)> {\n    Box::new(DigitsSpecialRandomGenerator {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        xss: striped_random_unsigned_vecs(\n            EXAMPLE_SEED.fork(\"xss\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"bit_source\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        phantom: PhantomData,\n    })\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )))\n        .filter_map(filter_map_helper_1),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )))\n        .filter(filter_helper_1),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )))\n        .map(map_helper_1),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Limb, Vec<Limb>)> {\n    Box::new(\n        permute_1_3_2(Box::new(random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )))\n        .filter(filter_helper_4),\n    )\n}\n\n// -- (Vec<PrimitiveUnsigned>, PrimitiveUnsigned, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\nstruct BasecaseDigitsSpecialRandomGenerator<T: PrimitiveUnsigned> {\n    bases: RandomValuesFromVec<u64>,\n    xss: StripedRandomUnsignedVecs<Limb, RandomUnsignedRange<u64>>,\n    excess_lens: RandomOptions<GeometricRandomNaturalValues<usize>>,\n    excess_out_lens: GeometricRandomNaturalValues<usize>,\n    bit_source: StripedBitSource,\n    phantom: PhantomData<*const T>,\n}\n\nimpl<T: PrimitiveUnsigned> Iterator for BasecaseDigitsSpecialRandomGenerator<T> {\n    type Item = (Vec<T>, usize, Vec<Limb>, u64);\n\n    fn next(&mut self) -> Option<(Vec<T>, usize, Vec<Limb>, u64)> {\n        let base = self.bases.next().unwrap();\n        let xs = self.xss.next().unwrap();\n        let min_out_len = usize::exact_from(limbs_digit_count(&xs, base));\n        let excess_out_len = self.excess_out_lens.next().unwrap();\n        let (len, out_len) = if let Some(excess) = self.excess_lens.next().unwrap() {\n            (min_out_len + excess, min_out_len + excess + excess_out_len)\n        } else {\n            (0, min_out_len + excess_out_len)\n        };\n        let out = get_striped_unsigned_vec(\n            &mut self.bit_source,\n            u64::exact_from(out_len) << T::LOG_WIDTH,\n        );\n        Some((out, len, xs, base))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1<\n    T: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<T>, usize, Vec<Limb>, u64)> {\n    Box::new(BasecaseDigitsSpecialRandomGenerator {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        xss: striped_random_unsigned_vecs_length_range(\n            EXAMPLE_SEED.fork(\"xss\"),\n            0,\n            u64::exact_from(GET_STR_PRECOMPUTE_THRESHOLD),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        excess_lens: random_options(\n            EXAMPLE_SEED.fork(\"excess_lens\"),\n            config.get_or(\"zero_len_prob_n\", 1),\n            config.get_or(\"zero_len_prob_d\", 5),\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_excess_len_n\", 4),\n                    config.get_or(\"mean_excess_len_d\", 1),\n                )\n            },\n        ),\n        excess_out_lens: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"excess_out_lens\"),\n            config.get_or(\"mean_excess_len_n\", 4),\n            config.get_or(\"mean_excess_len_d\", 1),\n        ),\n        bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"bit_source\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        phantom: PhantomData,\n    })\n}\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// vars 1 through 10 are in malachite-base.\n\npub fn special_random_unsigned_vec_pair_gen_var_11(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecPairLenGenerator2 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(xs, ys)| gcd_input_filter(xs, ys)),\n    )\n}\n\n// vars 12 through 13 are in malachite-base.\n\npub fn special_random_unsigned_vec_pair_gen_var_14(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter_map(|(out, mut xs)| {\n            limbs_vec_mul_limb_in_place(&mut xs, 3);\n            if out.len() >= xs.len() {\n                Some((out, xs))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_15(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs_from_single(striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            2,\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .map(|(ns, mut ds)| {\n            let d_last = ds.last_mut().unwrap();\n            if *d_last == 0 {\n                *d_last = 1;\n            }\n            let mut new_ns = limbs_mul(&ns, &ds);\n            if *new_ns.last().unwrap() == 0 {\n                new_ns.pop();\n            }\n            (new_ns, ds)\n        }),\n    )\n}\n\n// vars 16 through 17 are in malachite-base.\n\npub fn special_random_unsigned_vec_pair_gen_var_18(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs_from_single(\n            striped_random_unsigned_vecs_min_length(\n                EXAMPLE_SEED,\n                1,\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter_map(|mut xs| {\n                let x_last = xs.last_mut().unwrap();\n                if *x_last == Limb::MAX {\n                    None\n                } else {\n                    *x_last += 1;\n                    Some(xs)\n                }\n            }),\n        )\n        .filter_map(|(ns, ds)| {\n            let mut ns = limbs_mul(&ns, &ds);\n            if *ns.last().unwrap() == 0 {\n                ns.pop();\n            }\n            if *ns.last().unwrap() == 0 {\n                None\n            } else {\n                Some((ns, ds))\n            }\n        }),\n    )\n}\n\n// vars 19 through 21 are in malachite-base.\n\npub fn special_random_unsigned_vec_pair_gen_var_22<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    1,\n                    u64::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    1,\n                    u64::exact_from(SQRLO_DC_THRESHOLD_LIMIT),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| x >= y),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nfn special_random_square_helper<T: PrimitiveUnsigned, F: Fn(usize) -> bool>(\n    config: &GenConfig,\n    valid: &'static F,\n    min_x: u64,\n) -> It<(Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecPairLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(move |(o, x)| {\n            let x = x.checked_add(min_x)?;\n            let ux = usize::exact_from(x);\n            if valid(ux) {\n                let o = x.arithmetic_checked_shl(1u64)?.checked_add(o)?;\n                Some((o, x))\n            } else {\n                None\n            }\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_23<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_square_helper(config, &|x| x <= SQR_TOOM2_THRESHOLD, 1)\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_24<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_square_helper(config, &|_| true, 2)\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_25<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_square_helper(config, &limbs_square_to_out_toom_3_input_size_valid, 3)\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_26<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_square_helper(config, &limbs_square_to_out_toom_4_input_size_valid, 4)\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_27<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_square_helper(config, &|x| x == 7 || x == 8 || x > 9, 7)\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_28<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_square_helper(config, &limbs_square_to_out_toom_6_input_size_valid, 18)\n}\n\npub fn special_random_unsigned_vec_pair_gen_var_29<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>)> {\n    special_random_square_helper(config, &limbs_square_to_out_toom_8_input_size_valid, 40)\n}\n\n// vars 32 to 33 are in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, PrimitiveUnsigned) --\n\n// var 1 is in malachite-base\n\nstruct BasecaseDigitsSpecialRandomGenerator1<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    bases: RandomValuesFromVec<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    base_to_digits: HashMap<u64, RandomUnsignedsLessThan<T>>,\n    excess_limb_counts: GeometricRandomNaturalValues<u64>,\n    bit_source: StripedBitSource,\n    phantom: PhantomData<*const U>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for BasecaseDigitsSpecialRandomGenerator1<T, U>\n{\n    type Item = (Vec<U>, Vec<T>, u64);\n\n    fn next(&mut self) -> Option<(Vec<U>, Vec<T>, u64)> {\n        let base = self.bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let ds = self.base_to_digits.entry(base).or_insert_with(move || {\n            random_unsigneds_less_than(EXAMPLE_SEED.fork(&base.to_string()), T::wrapping_from(base))\n        });\n        let digits = ds.take(digit_count).collect();\n        let min_limb_count = limbs_per_digit_in_base(digit_count, base);\n        let out = get_striped_unsigned_vec(\n            &mut self.bit_source,\n            (min_limb_count + self.excess_limb_counts.next().unwrap()) << U::LOG_WIDTH,\n        );\n        Some((out, digits, base))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<U>, Vec<T>, u64)> {\n    Box::new(BasecaseDigitsSpecialRandomGenerator1 {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        digit_counts: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        excess_limb_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"excess_limb_count\"),\n            config.get_or(\"mean_excess_limb_count_n\", 4),\n            config.get_or(\"mean_excess_limb_count_d\", 1),\n        ),\n        bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"bit_source\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        base_to_digits: HashMap::new(),\n        phantom: PhantomData,\n    })\n}\n\nstruct BasecaseDigitsSpecialRandomGenerator2<T: PrimitiveUnsigned, U: PrimitiveUnsigned> {\n    bases: RandomValuesFromVec<u64>,\n    digit_counts: GeometricRandomNaturalValues<usize>,\n    base_to_digits: HashMap<u64, StripedRandomUnsignedBitChunks<T>>,\n    excess_limb_counts: GeometricRandomNaturalValues<u64>,\n    bit_source: StripedBitSource,\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n    phantom: PhantomData<*const U>,\n}\n\nimpl<T: PrimitiveUnsigned, U: PrimitiveUnsigned> Iterator\n    for BasecaseDigitsSpecialRandomGenerator2<T, U>\n{\n    type Item = (Vec<U>, Vec<T>, u64);\n\n    fn next(&mut self) -> Option<(Vec<U>, Vec<T>, u64)> {\n        let base = self.bases.next().unwrap();\n        let digit_count = self.digit_counts.next().unwrap();\n        let mean_stripe_n = self.mean_stripe_n;\n        let mean_stripe_d = self.mean_stripe_d;\n        let ds = self.base_to_digits.entry(base).or_insert_with(move || {\n            striped_random_unsigneds(\n                EXAMPLE_SEED.fork(&base.to_string()),\n                mean_stripe_n,\n                mean_stripe_d,\n            )\n        });\n        let digits = ds.take(digit_count).collect();\n        let min_limb_count = limbs_per_digit_in_base(digit_count, base);\n        let out = get_striped_unsigned_vec(\n            &mut self.bit_source,\n            (min_limb_count + self.excess_limb_counts.next().unwrap()) << U::LOG_WIDTH,\n        );\n        Some((out, digits, base))\n    }\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3<\n    T: PrimitiveUnsigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Vec<U>, Vec<T>, u64)> {\n    Box::new(BasecaseDigitsSpecialRandomGenerator2 {\n        bases: random_values_from_vec(\n            EXAMPLE_SEED.fork(\"bases\"),\n            (3u64..256).filter(|&b| !b.is_power_of_two()).collect(),\n        ),\n        digit_counts: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"digit_counts\"),\n            config.get_or(\"mean_digit_count_n\", 4),\n            config.get_or(\"mean_digit_count_d\", 1),\n        ),\n        excess_limb_counts: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"excess_limb_count\"),\n            config.get_or(\"mean_excess_limb_count_n\", 4),\n            config.get_or(\"mean_excess_limb_count_d\", 1),\n        ),\n        bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"bit_source\"),\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        base_to_digits: HashMap::new(),\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 32),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        phantom: PhantomData,\n    })\n}\n\n// vars 4 through 6 are in malachite-base.\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(filter_map_helper_2),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_8(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(filter_helper_2),\n    )\n}\n\n// vars 9 through 13 are in malachite-base.\n\npub fn special_random_unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigned_inclusive_range(\n                    seed.fork(\"lengths\"),\n                    2,\n                    u64::MAX,\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|((out, mut xs), y)| {\n            limbs_vec_mul_limb_in_place(&mut xs, y);\n            if out.len() >= xs.len() {\n                Some((out, xs, y))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_15(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(map_helper_2),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_16(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter(|xs| *xs.last().unwrap() != 0)\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter(filter_helper_5),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_vec_triple_gen_var_17(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(3)?;\n                    d_init_len = d_init_len.checked_add(2)?;\n                    if n_len > d_init_len {\n                        Some((n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    Limb::power_of_2(Limb::WIDTH - 1),\n                    Limb::MAX,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|((n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (n, d_init, inverse)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_18(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs::<Limb>(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, ys, mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_19(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigneds(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|((xs, ys), mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_20(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length::<Limb>(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n                .filter_map(|mut xs| {\n                    let last_x = xs.last_mut().unwrap();\n                    *last_x = last_x.checked_add(1)?;\n                    Some(xs)\n                })\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .map(|(xs, ys, mut pow)| {\n            pow += max(\n                limbs_significant_bits_helper(&xs),\n                limbs_significant_bits_helper(&ys),\n            );\n            (xs, ys, pow)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_unsigned_unsigned_triple_gen_var_21(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, u64)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length::<Limb>(\n                    seed,\n                    1,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"small_unsigned_mean_n\", 4),\n                    config.get_or(\"small_unsigned_mean_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(mut xs, mut es, pow)| {\n            let last_e = es.last_mut().unwrap();\n            *last_e = last_e.checked_add(1)?;\n            if es == [1] {\n                return None;\n            }\n            limbs_slice_mod_power_of_2_in_place(&mut xs, pow);\n            if *xs.last().unwrap() == 0 {\n                None\n            } else {\n                Some((xs, es, pow))\n            }\n        }),\n    )\n}\n\n// var 22 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>, Vec<PrimitiveUnsigned>) --\n\n// vars 1 through 3 are in malachite-base\n\nfn special_random_mul_helper<T: PrimitiveUnsigned, F: Fn(usize, usize) -> bool>(\n    config: &GenConfig,\n    valid: &'static F,\n    min_x: u64,\n    min_y: u64,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleLenGenerator1 {\n        phantom: PhantomData,\n        lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(move |(o, x, y)| {\n            let x = x.checked_add(min_x)?;\n            let y = y.checked_add(min_y)?;\n            if valid(usize::exact_from(x), usize::exact_from(y)) {\n                let o = x.checked_add(y)?.checked_add(o)?;\n                Some((o, x, y))\n            } else {\n                None\n            }\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_22_input_sizes_valid,\n        2,\n        2,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_32_input_sizes_valid,\n        6,\n        4,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n        3,\n        3,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_42_input_sizes_valid,\n        4,\n        2,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_43_input_sizes_valid,\n        11,\n        8,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_9<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_44_input_sizes_valid,\n        4,\n        4,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_10<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_52_input_sizes_valid,\n        14,\n        5,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_11<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_53_input_sizes_valid,\n        5,\n        3,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_12<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_54_input_sizes_valid,\n        14,\n        11,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_13<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_62_input_sizes_valid,\n        6,\n        2,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_14<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_63_input_sizes_valid,\n        17,\n        9,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_15<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n        42,\n        42,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_16<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n        86,\n        86,\n    )\n}\n\nfn special_random_mul_same_length_helper<T: PrimitiveUnsigned, F: Fn(usize, usize) -> bool>(\n    config: &GenConfig,\n    valid: &'static F,\n    min_x: u64,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    Box::new(UnsignedVecTripleXYYLenGenerator {\n        phantom: PhantomData,\n        lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n            EXAMPLE_SEED.fork(\"lengths\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ))\n        .filter_map(move |(o, x)| {\n            let x = x.checked_add(min_x)?;\n            let ux = usize::exact_from(x);\n            if valid(ux, ux) {\n                let o = x.arithmetic_checked_shl(1u64)?.checked_add(o)?;\n                Some((o, x))\n            } else {\n                None\n            }\n        }),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", T::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_18<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_same_length_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_33_input_sizes_valid,\n        5,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_19<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_same_length_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_6h_input_sizes_valid,\n        42,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_20<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_same_length_helper(\n        config,\n        &limbs_mul_greater_to_out_toom_8h_input_sizes_valid,\n        86,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_22<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &|xs_len, ys_len| {\n            limbs_mul_greater_to_out_toom_32_input_sizes_valid(xs_len, ys_len)\n                && limbs_mul_greater_to_out_toom_43_input_sizes_valid(xs_len, ys_len)\n        },\n        11,\n        8,\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_23<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &|xs_len, ys_len| {\n            limbs_mul_greater_to_out_toom_42_input_sizes_valid(xs_len, ys_len)\n                && limbs_mul_greater_to_out_toom_53_input_sizes_valid(xs_len, ys_len)\n        },\n        5,\n        3,\n    )\n}\n\n// vars 24 through 36 are in malachite-base\n\npub fn special_random_unsigned_vec_triple_gen_var_37(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            striped_random_unsigned_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter_map(filter_map_helper_3),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_38(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            striped_random_unsigned_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter(filter_helper_3),\n    )\n}\n\n// vars 39 through 41 is in malachite-base.\n\npub fn special_random_unsigned_vec_triple_gen_var_42(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(2)?;\n                    d_init_len = d_init_len.checked_add(1)?;\n                    let d_len = d_init_len + 1;\n                    if n_len >= d_len && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    Limb::power_of_2(Limb::WIDTH - 1),\n                    Limb::MAX,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            (q, n, d_init)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_43(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(3)?;\n                    d_init_len = d_init_len.checked_add(1)?;\n                    let d_len = d_init_len + 1;\n                    if n_len > d_len && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    Limb::power_of_2(Limb::WIDTH - 1),\n                    Limb::MAX,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            (q, n, d_init)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_44(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len && q_len > n_len - d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(_, _, d)| *d.last().unwrap() != 0),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_45(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len && q_len > n_len - d_len && n_len < (d_len - 1) << 1 {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(_, _, d)| *d.last().unwrap() != 0),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_46(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(q_len, n_len, d_len)| {\n                if q_len >= n_len && n_len >= d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            (q, n, d)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_47(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                1,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(q_len, n_len, d_len)| {\n                if q_len >= n_len && n_len >= d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            (q, n, d)\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_48(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                1,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(q_len, n_len, d_len)| {\n                if q_len + 1 >= n_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter_map(|(q, n, mut d)| {\n            let d_last = d.last_mut().unwrap();\n            if *d_last == 0 {\n                *d_last = 1;\n            }\n            let mut new_n = limbs_mul(&n, &d);\n            if *new_n.last().unwrap() == 0 {\n                new_n.pop();\n            }\n            if q.len() + d.len() >= new_n.len() + 1 {\n                Some((q, new_n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_49(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                1,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(q_len, n_len, mut d_len)| {\n                d_len = d_len.checked_add(1)?;\n                if q_len + 1 >= n_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter_map(|(q, n, mut d)| {\n            let d_last = d.last_mut().unwrap();\n            if *d_last == 0 {\n                *d_last = 1;\n            }\n            let mut new_n = limbs_mul(&n, &d);\n            if *new_n.last().unwrap() == 0 {\n                new_n.pop();\n            }\n            if q.len() > new_n.len() - d.len() {\n                Some((q, n, d))\n            } else {\n                None\n            }\n        }),\n    )\n}\n\n// vars 50 through 53 are in malachite-base.\n\npub fn special_random_unsigned_vec_triple_gen_var_54(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            striped_random_unsigned_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .map(|(xs, ys, m)| limbs_eq_mod_map(&xs, ys, m)),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_55(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_triples_from_single(\n            striped_random_unsigned_vecs_min_length(\n                EXAMPLE_SEED,\n                2,\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            )\n            .filter(|xs| *xs.last().unwrap() != 0),\n        )\n        .filter(|(xs, ys, m)| !limbs_eq_mod_ref_ref_ref(xs, ys, m)),\n    )\n}\n\npub fn special_random_unsigned_vec_triple_gen_var_56(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecPairLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_pairs_from_single(geometric_random_unsigneds::<u64>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, n_len): (u64, u64)| {\n                    Some((q_len.checked_add(n_len)?, n_len.checked_add(2)?))\n                }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_unsigned_inclusive_range(\n                            seed_2,\n                            Limb::power_of_2(Limb::WIDTH - 1),\n                            Limb::MAX,\n                            config.get_or(\"mean_stripe_n\", 32),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        striped_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                            config.get_or(\"mean_stripe_d\", 1),\n                        )\n                    },\n                )\n            },\n        )\n        .map(|((q, n), (d_1, d_0))| (q, n, vec![d_0, d_1])),\n    )\n}\n\n// var 57 is in malachite-base.\n\npub fn special_random_unsigned_vec_triple_gen_var_58<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Vec<T>, Vec<T>, Vec<T>)> {\n    special_random_mul_helper(\n        config,\n        &|x, y| {\n            limbs_mul_greater_to_out_toom_44_input_sizes_valid(x, y)\n                && limbs_mul_greater_to_out_toom_44_input_sizes_valid(x, y)\n        },\n        7,\n        7,\n    )\n}\n\n// var 59 is in malachite-base.\n\n// -- (Vec<PrimitiveUnsigned> * 4) --\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_vec_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if r_len >= d_len && n_len >= d_len && q_len > n_len - d_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, r, mut d)| {\n            let last_d = d.last_mut().unwrap();\n            if *last_d == 0 {\n                *last_d = 1;\n            }\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_vec_quadruple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(2)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(4)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len + 2 && q_len >= n_len - d_len && r_len >= d_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, r, mut d)| {\n            d[0] |= 1;\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_vec_quadruple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(4)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(4)?;\n                d_len = d_len.checked_add(2)?;\n                if n_len >= d_len + 2 && q_len >= n_len - d_len && r_len >= d_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, r, mut d)| {\n            d[0] |= 1;\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_vec_quadruple_gen_var_4(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(2)?;\n                d_len = d_len.checked_add(2)?;\n                if r_len >= d_len\n                    && n_len >= d_len\n                    && q_len > n_len - d_len\n                    && (d_len << 1) > n_len + 1\n                {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, r, mut d)| {\n            let last_d = d.last_mut().unwrap();\n            if *last_d == 0 {\n                *last_d = 1;\n            }\n            (q, n, r, d)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_vec_quadruple_gen_var_5(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut r_len, mut n_len, mut d_len)| {\n                q_len = q_len.checked_add(1)?;\n                r_len = r_len.checked_add(2)?;\n                n_len = n_len.checked_add(3)?;\n                d_len = d_len.checked_add(2)?;\n                if r_len >= d_len && n_len > d_len && q_len + d_len >= n_len {\n                    Some((q_len, r_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(\n            |(q, n, r, mut d): (Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)| {\n                d.last_mut().unwrap().set_bit(Limb::WIDTH - 1);\n                (q, n, r, d)\n            },\n        ),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_vec_quadruple_gen_var_6(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(\n        UnsignedVecQuadrupleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_quadruples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(out_len, mut b_len, e_len, mut m_len)| {\n                b_len = b_len.checked_add(1)?;\n                m_len = m_len.checked_add(1)?;\n                if out_len >= m_len {\n                    Some((out_len, b_len, e_len, m_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .filter(|(_, bs, es, ms)| {\n            (es.len() > 1 || es.len() == 1 && es[0] > 1)\n                && *bs.last().unwrap() != 0\n                && *es.last().unwrap() != 0\n                && *ms.last().unwrap() != 0\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_unsigned_vec_quadruple_gen_var_7(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    Box::new(special_random_unsigned_vec_quadruple_gen_var_6(config).map(\n        |(out, bs, es, mut ms)| {\n            ms[0] |= 1;\n            (out, bs, es, ms)\n        },\n    ))\n}\n\n// -- large types --\n\n// vars 1 through 4 are in malachite-base\n\nfn special_random_half_gcd_matrix(\n    s: usize,\n    n: usize,\n    bit_source: &mut StripedBitSource,\n) -> OwnedHalfGcdMatrix {\n    assert!(n <= s);\n    let bits = limb_to_bit_count(n);\n    let mut m00 = get_striped_unsigned_vec(bit_source, bits);\n    let m01 = get_striped_unsigned_vec(bit_source, bits);\n    let m10 = get_striped_unsigned_vec(bit_source, bits);\n    let m11 = get_striped_unsigned_vec(bit_source, bits);\n    m00.resize(s << 2, 0);\n    m00[s..s + n].copy_from_slice(&m01);\n    m00[s << 1..(s << 1) + n].copy_from_slice(&m10);\n    m00[s * 3..s * 3 + n].copy_from_slice(&m11);\n    half_gcd_matrix_create(s, n, m00)\n}\n\nstruct HalfGcdMatrixAndVecGenerator {\n    sizes: GeometricRandomNaturalValues<usize>,\n    striped_bit_source: StripedBitSource,\n    bs: RandomBools,\n}\n\nimpl Iterator for HalfGcdMatrixAndVecGenerator {\n    type Item = (OwnedHalfGcdMatrix, Vec<Limb>, u8);\n\n    fn next(&mut self) -> Option<Self::Item> {\n        loop {\n            let x = self.sizes.next().unwrap();\n            let qs_len = x.checked_add(1);\n            let qs_len = if let Some(qs_len) = qs_len {\n                qs_len\n            } else {\n                continue;\n            };\n            let y = self.sizes.next().unwrap();\n            let m_n = qs_len.checked_add(y);\n            let m_n = if let Some(m_n) = m_n { m_n } else { continue };\n            let z = self.sizes.next().unwrap();\n            let m_s = m_n.checked_add(z);\n            let m_s = if let Some(m_s) = m_s { m_s } else { continue };\n            let m_s_1 = m_s.checked_add(2);\n            let m_s_1 = if let Some(m_s_1) = m_s_1 {\n                m_s_1\n            } else {\n                continue;\n            };\n            let m_s_2 = m_s.checked_add(qs_len);\n            let m_s_2 = if let Some(m_s_2) = m_s_2 {\n                m_s_2\n            } else {\n                continue;\n            };\n            let m_s = max(m_s_1, m_s_2);\n            let m = special_random_half_gcd_matrix(m_s, m_n, &mut self.striped_bit_source);\n            let qs =\n                get_striped_unsigned_vec(&mut self.striped_bit_source, limb_to_bit_count(qs_len));\n            let column = u8::from(self.bs.next().unwrap());\n            return Some((m, qs, column));\n        }\n    }\n}\n\npub fn special_random_large_type_gen_var_5(\n    config: &GenConfig,\n) -> It<(OwnedHalfGcdMatrix, Vec<Limb>, u8)> {\n    Box::new(HalfGcdMatrixAndVecGenerator {\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", 4),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        bs: random_bools(EXAMPLE_SEED.fork(\"bs\")),\n    })\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_6(\n    config: &GenConfig,\n) -> It<(HalfGcdMatrix1, Vec<Limb>, Vec<Limb>, Vec<Limb>)> {\n    reshape_1_3_to_4(Box::new(\n        random_quadruples_from_single(striped_random_unsigneds(\n            EXAMPLE_SEED.fork(\"m\"),\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .map(|(m00, m01, m10, m11)| HalfGcdMatrix1 {\n            data: [[m00, m01], [m10, m11]],\n        })\n        .zip(UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(x, y, z)| {\n                let xs_len = x;\n                let ys_len = x.checked_add(1)?.checked_add(y)?;\n                let out_len = x.checked_add(1)?.checked_add(z)?;\n                Some((out_len, xs_len, ys_len))\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }),\n    ))\n}\n\nstruct HalfGcdMatrixAndHalfGcdMatrix1Generator {\n    sizes: GeometricRandomNaturalValues<usize>,\n    striped_bit_source: StripedBitSource,\n    bit_chunks: StripedRandomUnsignedBitChunks<Limb>,\n}\n\nimpl Iterator for HalfGcdMatrixAndHalfGcdMatrix1Generator {\n    type Item = (OwnedHalfGcdMatrix, HalfGcdMatrix1);\n\n    fn next(&mut self) -> Option<Self::Item> {\n        loop {\n            let x = self.sizes.next().unwrap();\n            let n = x.checked_add(1);\n            let n = if let Some(n) = n { n } else { continue };\n            let y = self.sizes.next().unwrap();\n            let s = n.checked_add(y);\n            let s = if let Some(s) = s { s } else { continue };\n            let s = s.checked_add(1);\n            let s = if let Some(s) = s { s } else { continue };\n            let m = special_random_half_gcd_matrix(s, n, &mut self.striped_bit_source);\n            let m_1 = HalfGcdMatrix1 {\n                data: [\n                    [self.bit_chunks.next().unwrap(), self.bit_chunks.next().unwrap()],\n                    [self.bit_chunks.next().unwrap(), self.bit_chunks.next().unwrap()],\n                ],\n            };\n            return Some((m, m_1));\n        }\n    }\n}\n\npub fn special_random_large_type_gen_var_7(\n    config: &GenConfig,\n) -> It<(OwnedHalfGcdMatrix, HalfGcdMatrix1)> {\n    Box::new(HalfGcdMatrixAndHalfGcdMatrix1Generator {\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n        bit_chunks: striped_random_unsigned_bit_chunks(\n            EXAMPLE_SEED.fork(\"bit_chunks\"),\n            Limb::WIDTH - 1,\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\nstruct MatrixMul22Generator {\n    sizes: GeometricRandomNaturalValues<u64>,\n    striped_bit_source: StripedBitSource,\n}\n\nimpl Iterator for MatrixMul22Generator {\n    type Item = T8;\n\n    fn next(&mut self) -> Option<Self::Item> {\n        let ys_len = self.sizes.next().unwrap();\n        let xs_len = self.sizes.next().unwrap();\n        let sum_bits = (ys_len + xs_len + 1) << Limb::LOG_WIDTH;\n        let ys_bits = ys_len << Limb::LOG_WIDTH;\n        Some((\n            get_striped_unsigned_vec(&mut self.striped_bit_source, sum_bits),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, sum_bits),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, sum_bits),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, sum_bits),\n            usize::exact_from(xs_len),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, ys_bits),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, ys_bits),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, ys_bits),\n            get_striped_unsigned_vec(&mut self.striped_bit_source, ys_bits),\n        ))\n    }\n}\n\npub fn special_random_large_type_gen_var_8(config: &GenConfig) -> It<T8> {\n    Box::new(MatrixMul22Generator {\n        sizes: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        striped_bit_source: StripedBitSource::new(\n            EXAMPLE_SEED.fork(\"striped_bit_source\"),\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ),\n    })\n}\n\n// var 9 is in malachite-base.\n\npub fn special_random_large_type_gen_var_10(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Limb, Limb)> {\n    reshape_2_2_to_4(Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| UnsignedVecPairLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_pairs_from_single(geometric_random_positive_unsigneds(\n                seed.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .map(|(x, y)| if x >= y { (x, y) } else { (y, x) }),\n            striped_bit_source: StripedBitSource::new(\n                seed.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        },\n        &|seed| {\n            random_pairs(\n                seed,\n                &|seed_2| random_values_from_vec(seed_2, factors_of_limb_max()),\n                &|seed_2| {\n                    striped_random_unsigneds(\n                        seed_2,\n                        config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                        config.get_or(\"mean_stripe_d\", 1),\n                    )\n                },\n            )\n        },\n    )))\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_11(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(q_len, mut n_len, mut d_init_len)| {\n                    n_len = n_len.checked_add(3)?;\n                    d_init_len = d_init_len.checked_add(2)?;\n                    let d_len = d_init_len + 1;\n                    if n_len >= d_len && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    Limb::power_of_2(Limb::WIDTH - 1),\n                    Limb::MAX,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (q, n, d_init, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_12(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| UnsignedVecTripleLenGenerator1 {\n                phantom: PhantomData,\n                lengths: random_triples_from_single(geometric_random_unsigneds::<u64>(\n                    seed.fork(\"lengths\"),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                ))\n                .filter_map(|(mut q_len, mut n_len, mut d_init_len)| {\n                    q_len = q_len.checked_add(3)?;\n                    n_len = n_len.checked_add(9)?;\n                    d_init_len = d_init_len.checked_add(5)?;\n                    let d_len = d_init_len + 1;\n                    if n_len >= d_len + 3 && q_len >= n_len - d_len {\n                        Some((q_len, n_len, d_init_len))\n                    } else {\n                        None\n                    }\n                }),\n                striped_bit_source: StripedBitSource::new(\n                    seed.fork(\"striped_bit_source\"),\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                ),\n            },\n            &|seed| {\n                striped_random_unsigned_inclusive_range(\n                    seed,\n                    Limb::power_of_2(Limb::WIDTH - 1),\n                    Limb::MAX,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .map(|((q, n, mut d_init), d_last)| {\n            d_init.push(d_last);\n            let inverse =\n                limbs_two_limb_inverse_helper(d_init[d_init.len() - 1], d_init[d_init.len() - 2]);\n            (q, n, d_init, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_13(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_positive_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter(|&(q_len, n_len, d_len)| q_len >= n_len && n_len >= d_len),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_14(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_positive_unsigneds::<u64>(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(1)?;\n                if q_len >= n_len && n_len > d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_15(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter_map(|(mut q_len, mut n_len, d_len)| {\n                q_len = q_len.checked_add(1)?;\n                n_len = n_len.checked_add(1)?;\n                if q_len >= n_len && n_len > d_len {\n                    Some((q_len, n_len, d_len))\n                } else {\n                    None\n                }\n            }),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_16(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        UnsignedVecTripleLenGenerator1 {\n            phantom: PhantomData,\n            lengths: random_triples_from_single(geometric_random_unsigned_inclusive_range(\n                EXAMPLE_SEED.fork(\"lengths\"),\n                2,\n                u64::MAX,\n                config.get_or(\"mean_length_n\", 4),\n                config.get_or(\"mean_length_d\", 1),\n            ))\n            .filter(|&(q_len, n_len, d_len)| q_len >= n_len && n_len >= d_len),\n            striped_bit_source: StripedBitSource::new(\n                EXAMPLE_SEED.fork(\"striped_bit_source\"),\n                config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                config.get_or(\"mean_stripe_d\", 1),\n            ),\n        }\n        .map(|(q, n, mut d)| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            (q, n, d, inverse)\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_17(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Limb)> {\n    Box::new(\n        striped_random_unsigned_vecs_min_length(\n            EXAMPLE_SEED,\n            1,\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        )\n        .map(|mut d| {\n            d[0] |= 1;\n            let inverse = limbs_modular_invert_limb::<Limb>(d[0]).wrapping_neg();\n            let is = vec![0; d.len()];\n            let scratch = vec![0; limbs_modular_invert_scratch_len(d.len())];\n            (is, scratch, d, inverse)\n        }),\n    )\n}\n\npub fn special_random_large_type_gen_var_18(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, usize, Limb, Limb, u64)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(ns, fraction_len, d)| {\n            if ns.len() <= fraction_len {\n                None\n            } else {\n                let shift = LeadingZeros::leading_zeros(d);\n                let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n                Some((ns, fraction_len, d, d_inv, shift))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_19(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, usize, Vec<Limb>, Limb, Limb, u64)> {\n    Box::new(\n        random_quadruples_xyxz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigneds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_unsigneds(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(out, fraction_len, ns, d)| {\n            if ns.is_empty() || out.len() < ns.len() + fraction_len {\n                None\n            } else {\n                let shift = LeadingZeros::leading_zeros(d);\n                let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n                Some((out, fraction_len, ns, d, d_inv, shift))\n            }\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_20(\n    config: &GenConfig,\n) -> It<(Vec<Limb>, Vec<Limb>, Vec<Limb>, Vec<Limb>, usize, usize)> {\n    Box::new(\n        random_quintuples_xyyyz(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_unsigned_vecs_min_length(\n                    seed,\n                    2,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_unsigned_vecs(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", Limb::WIDTH << 1),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_length_n\", 4),\n                    config.get_or(\"mean_length_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_unsigned_inclusive_range(\n                    seed,\n                    3,\n                    u32::MAX,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter_map(|(ds, mut scratch, mut qs, mut rs_hi, n_len)| {\n            let n_len = usize::wrapping_from(n_len);\n            let d_len = ds.len();\n            if n_len < d_len {\n                return None;\n            }\n            let i_len = limbs_div_mod_barrett_is_len(n_len - d_len, d_len);\n            if i_len == 0 || qs.len() < i_len {\n                return None;\n            }\n            qs.truncate(i_len);\n            if rs_hi.len() < i_len {\n                return None;\n            }\n            rs_hi.truncate(i_len);\n            let scratch_len = limbs_mul_mod_base_pow_n_minus_1_next_size(d_len + 1);\n            let x = limbs_div_mod_barrett_scratch_len(n_len, d_len);\n            if x < i_len {\n                return None;\n            }\n            let actual_scratch_len = x - i_len;\n            if actual_scratch_len < d_len + i_len {\n                return None;\n            }\n            if scratch.len() < actual_scratch_len {\n                return None;\n            }\n            scratch.truncate(actual_scratch_len);\n            Some((scratch, ds, qs, rs_hi, scratch_len, i_len))\n        }),\n    )\n}\n\n#[allow(clippy::type_complexity)]\npub fn special_random_large_type_gen_var_21(\n    config: &GenConfig,\n) -> It<(Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb, Limb)> {\n    Box::new(\n        random_sextuples_from_single(striped_random_positive_unsigneds(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", Limb::WIDTH >> 1),\n            config.get_or(\"mean_stripe_d\", 1),\n        ))\n        .filter_map(large_type_filter_map_1),\n    )\n}\n\n// var 22 is in malachite-base.\n\nstruct RationalFromPowerOf2DigitsGenerator {\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n    log_bases: GeometricRandomNaturalValues<u64>,\n    sizes: GeometricRandomNaturalValues<usize>,\n    xs_map: HashMap<u64, StripedRandomNaturalInclusiveRange>,\n}\n\nimpl Iterator for RationalFromPowerOf2DigitsGenerator {\n    type Item = (u64, Vec<Natural>, RationalSequence<Natural>);\n\n    fn next(&mut self) -> Option<(u64, Vec<Natural>, RationalSequence<Natural>)> {\n        let log_base = self.log_bases.next().unwrap();\n        let mean_stripe_n = self.mean_stripe_n;\n        let mean_stripe_d = self.mean_stripe_d;\n        let xs = self.xs_map.entry(log_base).or_insert_with(|| {\n            let seed = EXAMPLE_SEED.fork(&log_base.to_string());\n            striped_random_natural_range(\n                seed,\n                Natural::ZERO,\n                Natural::power_of_2(log_base),\n                mean_stripe_n,\n                mean_stripe_d,\n            )\n        });\n        let before_point = xs.take(self.sizes.next().unwrap()).collect();\n        let non_repeating = xs.take(self.sizes.next().unwrap()).collect();\n        let repeating = xs.take(self.sizes.next().unwrap()).collect();\n        Some((\n            log_base,\n            before_point,\n            RationalSequence::from_vecs(non_repeating, repeating),\n        ))\n    }\n}\n\npub fn special_random_large_type_gen_var_23(\n    config: &GenConfig,\n) -> It<(u64, Vec<Natural>, RationalSequence<Natural>)> {\n    Box::new(RationalFromPowerOf2DigitsGenerator {\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 32),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        log_bases: geometric_random_positive_unsigneds(\n            EXAMPLE_SEED.fork(\"log_bases\"),\n            config.get_or(\"mean_log_base_n\", 4),\n            config.get_or(\"mean_log_base_d\", 1),\n        ),\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs_map: HashMap::new(),\n    })\n}\n\nstruct RationalFromDigitsGenerator {\n    mean_stripe_n: u64,\n    mean_stripe_d: u64,\n    bases: StripedRandomNaturalRangeToInfinity,\n    sizes: GeometricRandomNaturalValues<usize>,\n    xs_map: HashMap<Natural, StripedRandomNaturalInclusiveRange>,\n}\n\nimpl Iterator for RationalFromDigitsGenerator {\n    type Item = (Natural, Vec<Natural>, RationalSequence<Natural>);\n\n    fn next(&mut self) -> Option<(Natural, Vec<Natural>, RationalSequence<Natural>)> {\n        let base = self.bases.next().unwrap();\n        let mean_stripe_n = self.mean_stripe_n;\n        let mean_stripe_d = self.mean_stripe_d;\n        let xs = self.xs_map.entry(base.clone()).or_insert_with(|| {\n            let seed = EXAMPLE_SEED.fork(&base.to_string());\n            striped_random_natural_range(\n                seed,\n                Natural::ZERO,\n                base.clone(),\n                mean_stripe_n,\n                mean_stripe_d,\n            )\n        });\n        let before_point = xs.take(self.sizes.next().unwrap()).collect();\n        let non_repeating = xs.take(self.sizes.next().unwrap()).collect();\n        let repeating = xs.take(self.sizes.next().unwrap()).collect();\n        Some((\n            base,\n            before_point,\n            RationalSequence::from_vecs(non_repeating, repeating),\n        ))\n    }\n}\n\npub fn special_random_large_type_gen_var_24(\n    config: &GenConfig,\n) -> It<(Natural, Vec<Natural>, RationalSequence<Natural>)> {\n    Box::new(RationalFromDigitsGenerator {\n        mean_stripe_n: config.get_or(\"mean_stripe_n\", 32),\n        mean_stripe_d: config.get_or(\"mean_stripe_d\", 1),\n        bases: striped_random_natural_range_to_infinity(\n            EXAMPLE_SEED,\n            Natural::TWO,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ),\n        sizes: geometric_random_unsigneds(\n            EXAMPLE_SEED.fork(\"sizes\"),\n            config.get_or(\"mean_length_n\", 4),\n            config.get_or(\"mean_length_d\", 1),\n        ),\n        xs_map: HashMap::new(),\n    })\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::basic::traits::Zero;\n\npub fn integer_sum_alt<I: Iterator<Item = Integer>>(xs: I) -> Integer {\n    let mut stack = Vec::new();\n    for (i, x) in xs.enumerate().map(|(i, x)| (i + 1, x)) {\n        let mut s = x;\n        for _ in 0..i.trailing_zeros() {\n            s += stack.pop().unwrap();\n        }\n        stack.push(s);\n    }\n    let mut s = Integer::ZERO;\n    for x in stack {\n        s += x;\n    }\n    s\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::{BigInt, Integer, Zero};\n\npub fn num_divisible_by(x: &BigInt, y: &BigInt) -> bool {\n    *x == BigInt::zero() || *y != BigInt::zero() && x.is_multiple_of(y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod add;\npub mod divisible_by;\npub mod mul;\npub mod sign;\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::basic::traits::{One, Zero};\n\npub fn integer_product_naive<I: Iterator<Item = Integer>>(xs: I) -> Integer {\n    let mut p = Integer::ONE;\n    for x in xs {\n        if x == 0 {\n            return Integer::ZERO;\n        }\n        p *= x;\n    }\n    p\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::BigInt;\nuse num::bigint::Sign;\nuse std::cmp::Ordering::{self, *};\n\npub fn num_sign(x: &BigInt) -> Ordering {\n    match x.sign() {\n        Sign::NoSign => Equal,\n        Sign::Plus => Greater,\n        Sign::Minus => Less,\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod partial_cmp_primitive_int;\npub mod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::BigInt;\nuse std::cmp::Ordering;\n\npub fn num_partial_cmp_primitive<T>(x: &BigInt, u: T) -> Option<Ordering>\nwhere\n    BigInt: From<T>,\n{\n    x.partial_cmp(&BigInt::from(u))\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::BigInt;\n\npub fn num_partial_eq_primitive<T>(x: &BigInt, i: T) -> bool\nwhere\n    BigInt: From<T>,\n{\n    *x == BigInt::from(i)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod to_twos_complement_limbs;\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/conversion/to_twos_complement_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::sub::limbs_sub_limb_in_place;\nuse crate::natural::logic::not::limbs_not_in_place;\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::WrappingNegAssign;\n\npub fn limbs_twos_complement_in_place_alt_1(limbs: &mut [Limb]) -> bool {\n    let i = limbs.iter().copied().take_while(|&x| x == 0).count();\n    let len = limbs.len();\n    if i == len {\n        return true;\n    }\n    limbs[i].wrapping_neg_assign();\n    let j = i + 1;\n    if j != len {\n        limbs_not_in_place(&mut limbs[j..]);\n    }\n    false\n}\n\npub fn limbs_twos_complement_in_place_alt_2(limbs: &mut [Limb]) -> bool {\n    let carry = limbs_sub_limb_in_place(limbs, 1);\n    limbs_not_in_place(limbs);\n    carry\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::test_util::integer::logic::{integer_op_bits, integer_op_limbs};\n\npub fn integer_and_alt_1(x: &Integer, y: &Integer) -> Integer {\n    integer_op_bits(&|a, b| a && b, x, y)\n}\n\npub fn integer_and_alt_2(x: &Integer, y: &Integer) -> Integer {\n    integer_op_limbs(&|a, b| a & b, x, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/checked_count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::{BitIterable, CountOnes};\n\npub fn integer_checked_count_ones_alt_1(n: &Integer) -> Option<u64> {\n    if *n >= 0 {\n        Some(u64::wrapping_from(n.bits().filter(|&b| b).count()))\n    } else {\n        None\n    }\n}\n\npub fn integer_checked_count_ones_alt_2(n: &Integer) -> Option<u64> {\n    if *n >= 0 {\n        Some(n.twos_complement_limbs().map(CountOnes::count_ones).sum())\n    } else {\n        None\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/checked_count_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::{BitIterable, CountZeros};\n\npub fn integer_checked_count_zeros_alt_1(n: &Integer) -> Option<u64> {\n    if *n < 0 {\n        Some(u64::wrapping_from(n.bits().filter(|&b| !b).count()))\n    } else {\n        None\n    }\n}\n\npub fn integer_checked_count_zeros_alt_2(n: &Integer) -> Option<u64> {\n    if *n < 0 {\n        Some(n.twos_complement_limbs().map(CountZeros::count_zeros).sum())\n    } else {\n        None\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/checked_hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::platform::Limb;\nuse malachite_base::num::logic::traits::{BitIterable, HammingDistance};\nuse std::iter::repeat;\n\npub fn integer_checked_hamming_distance_alt_1(x: &Integer, y: &Integer) -> Option<u64> {\n    let negative = *x < 0;\n    if negative != (*y < 0) {\n        return None;\n    }\n    let bit_zip: Box<dyn Iterator<Item = (bool, bool)>> = if x.bits().count() >= y.bits().count() {\n        Box::new(x.bits().zip(y.bits().chain(repeat(negative))))\n    } else {\n        Box::new(x.bits().chain(repeat(negative)).zip(y.bits()))\n    };\n    let mut distance = 0u64;\n    for (b, c) in bit_zip {\n        if b != c {\n            distance += 1;\n        }\n    }\n    Some(distance)\n}\n\npub fn rug_checked_hamming_distance(x: &rug::Integer, y: &rug::Integer) -> Option<u64> {\n    x.hamming_dist(y).map(u64::from)\n}\n\npub fn integer_checked_hamming_distance_alt_2(x: &Integer, y: &Integer) -> Option<u64> {\n    if (*x < 0) != (*y < 0) {\n        return None;\n    }\n    let extension = if *x < 0 { Limb::MAX } else { 0 };\n    let limb_zip: Box<dyn Iterator<Item = (Limb, Limb)>> =\n        if x.twos_complement_limbs().count() >= y.twos_complement_limbs().count() {\n            Box::new(\n                x.twos_complement_limbs()\n                    .zip(y.twos_complement_limbs().chain(repeat(extension))),\n            )\n        } else {\n            Box::new(\n                x.twos_complement_limbs()\n                    .chain(repeat(extension))\n                    .zip(y.twos_complement_limbs()),\n            )\n        };\n    let mut distance = 0u64;\n    for (x, y) in limb_zip {\n        distance += x.hamming_distance(y);\n    }\n    Some(distance)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\n\npub fn from_bits_asc_naive<I: Iterator<Item = bool>>(bits: I) -> Integer {\n    let bits = bits.collect_vec();\n    if bits.is_empty() {\n        return Integer::ZERO;\n    }\n    let mut n;\n    if *bits.last().unwrap() {\n        n = Integer::NEGATIVE_ONE;\n        for i in bits\n            .iter()\n            .enumerate()\n            .filter_map(|(i, &bit)| if bit { None } else { Some(u64::exact_from(i)) })\n        {\n            n.clear_bit(i);\n        }\n    } else {\n        n = Integer::ZERO;\n        for i in bits\n            .iter()\n            .enumerate()\n            .filter_map(|(i, &bit)| if bit { Some(u64::exact_from(i)) } else { None })\n        {\n            n.set_bit(i);\n        }\n    };\n    n\n}\n\npub fn from_bits_desc_naive<I: Iterator<Item = bool>>(bits: I) -> Integer {\n    let bits = bits.collect_vec();\n    if bits.is_empty() {\n        return Integer::ZERO;\n    }\n    let mut n;\n    if bits[0] {\n        n = Integer::NEGATIVE_ONE;\n        for i in bits.iter().rev().enumerate().filter_map(|(i, &bit)| {\n            if bit { None } else { Some(u64::exact_from(i)) }\n        }) {\n            n.clear_bit(i);\n        }\n    } else {\n        n = Integer::ZERO;\n        for i in bits.iter().rev().enumerate().filter_map(|(i, &bit)| {\n            if bit { Some(u64::exact_from(i)) } else { None }\n        }) {\n            n.set_bit(i);\n        }\n    };\n    n\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitIterable, SignificantBits};\n\npub fn integer_index_of_next_false_bit_alt(n: &Integer, u: u64) -> Option<u64> {\n    if u >= n.significant_bits() {\n        if *n >= 0 { Some(u) } else { None }\n    } else {\n        for (i, bit) in n.bits().enumerate().skip(usize::exact_from(u)) {\n            if !bit {\n                return Some(u64::exact_from(i));\n            }\n        }\n        None\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitIterable, SignificantBits};\n\npub fn integer_index_of_next_true_bit_alt(n: &Integer, u: u64) -> Option<u64> {\n    if u >= n.significant_bits() {\n        if *n >= 0 { None } else { Some(u) }\n    } else {\n        for (i, bit) in n.bits().enumerate().skip(usize::exact_from(u)) {\n            if bit {\n                return Some(u64::exact_from(i));\n            }\n        }\n        None\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::platform::Limb;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable};\nuse std::iter::repeat;\n\npub fn integer_op_bits(bit_fn: &dyn Fn(bool, bool) -> bool, x: &Integer, y: &Integer) -> Integer {\n    let x_negative = *x < 0;\n    let y_negative = *y < 0;\n    let bit_zip: Box<dyn Iterator<Item = (bool, bool)>> = if x.bits().count() >= y.bits().count() {\n        Box::new(x.bits().zip(y.bits().chain(repeat(y_negative))))\n    } else {\n        Box::new(x.bits().chain(repeat(x_negative)).zip(y.bits()))\n    };\n    Integer::from_bits_asc(bit_zip.map(|(b, c)| bit_fn(b, c)))\n}\n\npub fn integer_op_limbs(limb_fn: &dyn Fn(Limb, Limb) -> Limb, x: &Integer, y: &Integer) -> Integer {\n    let x_extension = if *x < 0 { Limb::MAX } else { 0 };\n    let y_extension = if *y < 0 { Limb::MAX } else { 0 };\n    let limb_zip: Box<dyn Iterator<Item = (Limb, Limb)>> =\n        if x.twos_complement_limbs().count() >= y.twos_complement_limbs().count() {\n            Box::new(\n                x.twos_complement_limbs()\n                    .zip(y.twos_complement_limbs().chain(repeat(y_extension))),\n            )\n        } else {\n            Box::new(\n                x.twos_complement_limbs()\n                    .chain(repeat(x_extension))\n                    .zip(y.twos_complement_limbs()),\n            )\n        };\n    let mut limbs = Vec::new();\n    for (x, y) in limb_zip {\n        limbs.push(limb_fn(x, y));\n    }\n    Integer::from_owned_twos_complement_limbs_asc(limbs)\n}\n\npub mod and;\npub mod checked_count_ones;\npub mod checked_count_zeros;\npub mod checked_hamming_distance;\npub mod from_bits;\npub mod index_of_next_false_bit;\npub mod index_of_next_true_bit;\npub mod or;\npub mod to_bits;\npub mod trailing_zeros;\npub mod xor;\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::test_util::integer::logic::{integer_op_bits, integer_op_limbs};\n\npub fn integer_or_alt_1(x: &Integer, y: &Integer) -> Integer {\n    integer_op_bits(&|a, b| a || b, x, y)\n}\n\npub fn integer_or_alt_2(x: &Integer, y: &Integer) -> Integer {\n    integer_op_limbs(&|a, b| a | b, x, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\n\npub fn to_bits_asc_naive(n: &Integer) -> Vec<bool> {\n    let mut bits = Vec::new();\n    if *n == 0 {\n        return bits;\n    }\n    for i in 0..n.significant_bits() {\n        bits.push(n.get_bit(i));\n    }\n    let last_bit = *bits.last().unwrap();\n    if last_bit != (*n < 0) {\n        bits.push(!last_bit);\n    }\n    bits\n}\n\npub fn to_bits_desc_naive(n: &Integer) -> Vec<bool> {\n    let mut bits = Vec::new();\n    if *n == 0 {\n        return bits;\n    }\n    let significant_bits = n.significant_bits();\n    let last_bit = n.get_bit(significant_bits - 1);\n    if last_bit != (*n < 0) {\n        bits.push(!last_bit);\n    }\n    for i in (0..significant_bits).rev() {\n        bits.push(n.get_bit(i));\n    }\n    bits\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::BitIterable;\n\npub fn integer_trailing_zeros_alt(n: &Integer) -> Option<u64> {\n    if *n == 0 {\n        None\n    } else {\n        Some(u64::wrapping_from(n.bits().take_while(|&b| !b).count()))\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::test_util::integer::logic::{integer_op_bits, integer_op_limbs};\n\npub fn integer_xor_alt_1(x: &Integer, y: &Integer) -> Integer {\n    integer_op_bits(&|a, b| a ^ b, x, y)\n}\n\npub fn integer_xor_alt_2(x: &Integer, y: &Integer) -> Integer {\n    integer_op_limbs(&|a, b| a ^ b, x, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod arithmetic;\npub mod comparison;\npub mod conversion;\npub mod logic;\npub mod random;\n"
  },
  {
    "path": "malachite-nz/src/test_util/integer/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::itertools::Itertools;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{MomentStats, moment_stats};\n\npub fn random_integers_helper_helper<I: Clone + Iterator<Item = Integer>>(\n    xs: I,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let actual_values = xs\n        .clone()\n        .map(|x| Integer::to_string(&x))\n        .take(20)\n        .collect_vec();\n    let actual_values = actual_values.iter().map(String::as_str).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(x, freq)| (x.to_string(), freq))\n        .collect_vec();\n    let actual_common_values = actual_common_values\n        .iter()\n        .map(|(x, freq)| (x.as_str(), *freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.clone().take(1000000));\n    let (median_lo, median_hi) = (\n        median_lo.to_string(),\n        median_hi.map(|x| Integer::to_string(&x)),\n    );\n    let actual_sample_median = (median_lo.as_str(), median_hi.as_deref());\n    let actual_sample_moment_stats =\n        moment_stats(xs.take(1000000).map(|x| f64::rounding_from(&x, Nearest).0));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod bench;\npub mod common;\npub mod extra_variadic;\npub mod generators;\npub mod integer;\npub mod natural;\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::basic::traits::Zero;\n\npub fn natural_sum_alt<I: Iterator<Item = Natural>>(xs: I) -> Natural {\n    let mut stack = Vec::new();\n    for (i, x) in xs.enumerate().map(|(i, x)| (i + 1, x)) {\n        let mut s = x;\n        for _ in 0..i.trailing_zeros() {\n            s += stack.pop().unwrap();\n        }\n        stack.push(s);\n    }\n    let mut s = Natural::ZERO;\n    for x in stack {\n        s += x;\n    }\n    s\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::div_round::double_cmp;\nuse crate::natural::exhaustive::exhaustive_natural_inclusive_range;\nuse malachite_base::num::arithmetic::traits::{DivExact, Factorial, Gcd, Parity};\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse std::cmp::Ordering::*;\n\npub fn binomial_coefficient_naive_1(n: Natural, mut k: Natural) -> Natural {\n    if k > n {\n        return Natural::ZERO;\n    }\n    if k == 0u32 || n == k {\n        return Natural::ONE;\n    }\n    if double_cmp(&k, &n) == Greater {\n        k = &n - &k;\n    }\n    let k_u64 = u64::exact_from(&k);\n    exhaustive_natural_inclusive_range(&n - k + Natural::ONE, n)\n        .product::<Natural>()\n        .div_exact(Natural::factorial(k_u64))\n}\n\npub fn binomial_coefficient_naive_2(n: Natural, mut k: Natural) -> Natural {\n    if k > n {\n        return Natural::ZERO;\n    }\n    if k == 0u32 || n == k {\n        return Natural::ONE;\n    }\n    if double_cmp(&k, &n) == Greater {\n        k = &n - &k;\n    }\n    if k == 1u32 {\n        n\n    } else if k == 2u32 {\n        (&n >> 1) * (if n.even() { n - Natural::ONE } else { n })\n    } else {\n        let mut product = n - &k + Natural::ONE;\n        let mut numerator = product.clone();\n        for i in exhaustive_natural_inclusive_range(Natural::TWO, k) {\n            numerator += Natural::ONE;\n            let gcd = (&numerator).gcd(&i);\n            product /= i.div_exact(&gcd);\n            product *= (&numerator).div_exact(gcd);\n        }\n        product\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/checked_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse std::ops::Sub;\n\npub fn checked_sub<T: Ord + Sub>(x: T, y: T) -> Option<<T as Sub>::Output> {\n    if x >= y { Some(x - y) } else { None }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_div_qr_1n_pi1` contributed to the GNU project by Niels Möller.\n//\n//      `mpn_div_qr_1` contributed to the GNU project by Niels Möller and Torbjörn Granlund.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 1998-2000, 2002, 2003, 2013 Free Software Foundation,\n//      Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::div::div_by_preinversion;\nuse crate::natural::arithmetic::div_mod::{div_mod_by_preinversion, limbs_invert_limb};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::{\n    OverflowingAddAssign, WrappingAddAssign, WrappingSubAssign, XMulYToZZ,\n};\nuse malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\n\n// The high bit of `d` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_div_qr_1n_pi1` from `mpn/generic/div_qr_1n_pi1.c`, GMP 6.2.1, with\n// `DIV_QR_1N_METHOD == 2`, where `qp == up`, but not computing the remainder.\nfn limbs_div_limb_normalized_in_place(ns: &mut [Limb], ns_high: Limb, d: Limb, d_inv: Limb) {\n    let len = ns.len();\n    if len == 1 {\n        ns[0] = div_by_preinversion(ns_high, ns[0], d, d_inv);\n        return;\n    }\n    let power_of_2 = d.wrapping_neg().wrapping_mul(d_inv);\n    let (mut q_high, mut q_low) = Limb::x_mul_y_to_zz(d_inv, ns_high);\n    q_high.wrapping_add_assign(ns_high);\n    let second_highest_limb = ns[len - 1];\n    ns[len - 1] = q_high;\n    let (sum, mut big_carry) = DoubleLimb::join_halves(second_highest_limb, ns[len - 2])\n        .overflowing_add(DoubleLimb::from(power_of_2) * DoubleLimb::from(ns_high));\n    let (mut sum_high, mut sum_low) = sum.split_in_half();\n    for j in (0..len - 2).rev() {\n        let (t, r) = Limb::x_mul_y_to_zz(sum_high, d_inv);\n        let mut q = DoubleLimb::from(sum_high) + DoubleLimb::from(t) + DoubleLimb::from(q_low);\n        q_low = r;\n        if big_carry {\n            q.wrapping_add_assign(DoubleLimb::join_halves(1, d_inv));\n            if sum_low.overflowing_add_assign(power_of_2) {\n                sum_low.wrapping_sub_assign(d);\n                q.wrapping_add_assign(1);\n            }\n        }\n        let q_higher;\n        (q_higher, ns[j + 1]) = q.split_in_half();\n        assert!(!limbs_slice_add_limb_in_place(&mut ns[j + 2..], q_higher));\n        let sum;\n        (sum, big_carry) = DoubleLimb::join_halves(sum_low, ns[j])\n            .overflowing_add(DoubleLimb::from(sum_high) * DoubleLimb::from(power_of_2));\n        sum_high = sum.upper_half();\n        sum_low = sum.lower_half();\n    }\n    let mut q_high = 0;\n    if big_carry {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    if sum_high >= d {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    let t = div_by_preinversion(sum_high, sum_low, d, d_inv);\n    let (q_high, q_low) = DoubleLimb::join_halves(q_high, q_low)\n        .wrapping_add(DoubleLimb::from(t))\n        .split_in_half();\n    assert!(!limbs_slice_add_limb_in_place(&mut ns[1..], q_high));\n    ns[0] = q_low;\n}\n\n// The high bit of `d` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_div_qr_1n_pi1` from `mpn/generic/div_qr_1n_pi1.c`, GMP 6.2.1, with\n// `DIV_QR_1N_METHOD == 2`, but not computing the remainder.\nfn limbs_div_limb_normalized_to_out(\n    out: &mut [Limb],\n    ns: &[Limb],\n    ns_high: Limb,\n    d: Limb,\n    d_inv: Limb,\n) {\n    let len = ns.len();\n    if len == 1 {\n        out[0] = div_by_preinversion(ns_high, ns[0], d, d_inv);\n        return;\n    }\n    let power_of_2 = d.wrapping_neg().wrapping_mul(d_inv);\n    let (mut q_high, mut q_low) = Limb::x_mul_y_to_zz(d_inv, ns_high);\n    q_high.wrapping_add_assign(ns_high);\n    out[len - 1] = q_high;\n    let (sum, mut big_carry) = DoubleLimb::join_halves(ns[len - 1], ns[len - 2])\n        .overflowing_add(DoubleLimb::from(power_of_2) * DoubleLimb::from(ns_high));\n    let (mut sum_high, mut sum_low) = sum.split_in_half();\n    for j in (0..len - 2).rev() {\n        let (t, r) = Limb::x_mul_y_to_zz(sum_high, d_inv);\n        let mut q = DoubleLimb::from(sum_high) + DoubleLimb::from(t) + DoubleLimb::from(q_low);\n        q_low = r;\n        if big_carry {\n            q.wrapping_add_assign(DoubleLimb::join_halves(1, d_inv));\n            if sum_low.overflowing_add_assign(power_of_2) {\n                sum_low.wrapping_sub_assign(d);\n                q.wrapping_add_assign(1);\n            }\n        }\n        let q_higher;\n        (q_higher, out[j + 1]) = q.split_in_half();\n        assert!(!limbs_slice_add_limb_in_place(&mut out[j + 2..], q_higher));\n        let sum;\n        (sum, big_carry) = DoubleLimb::join_halves(sum_low, ns[j])\n            .overflowing_add(DoubleLimb::from(sum_high) * DoubleLimb::from(power_of_2));\n        sum_high = sum.upper_half();\n        sum_low = sum.lower_half();\n    }\n    let mut q_high = 0;\n    if big_carry {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    if sum_high >= d {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    let t = div_by_preinversion(sum_high, sum_low, d, d_inv);\n    (q_high, out[0]) = DoubleLimb::join_halves(q_high, q_low)\n        .wrapping_add(DoubleLimb::from(t))\n        .split_in_half();\n    assert!(!limbs_slice_add_limb_in_place(&mut out[1..], q_high));\n}\n\n// This is equivalent to `mpn_div_qr_1` from `mpn/generic/div_qr_1.c`, GMP 6.2.1, but not computing\n// the remainder. Experiments show that this is always slower than `limbs_div_limb_to_out`.\npub fn limbs_div_limb_to_out_alt(out: &mut [Limb], ns: &[Limb], d: Limb) {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    assert!(out.len() >= len);\n    let len_minus_1 = len - 1;\n    let mut highest_limb = ns[len_minus_1];\n    let bits = LeadingZeros::leading_zeros(d);\n    if bits == 0 {\n        let adjust = highest_limb >= d;\n        if adjust {\n            highest_limb -= d;\n        }\n        out[len_minus_1] = Limb::from(adjust);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        limbs_div_limb_normalized_to_out(out, &ns[..len_minus_1], highest_limb, d, d_inv);\n    } else {\n        let d = d << bits;\n        let ns_high = limbs_shl_to_out(out, ns, bits);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let r;\n        (out[len_minus_1], r) = div_mod_by_preinversion(ns_high, out[len_minus_1], d, d_inv);\n        limbs_div_limb_normalized_in_place(&mut out[..len_minus_1], r, d, d_inv);\n    }\n}\n\n// This is equivalent to `mpn_div_qr_1` from `mpn/generic/div_qr_1.c`, GMP 6.2.1, where `qp == up`,\n// but not computing the remainder. Experiments show that this is always slower than\n// `limbs_div_limb_in_place`.\npub fn limbs_div_limb_in_place_alt(ns: &mut [Limb], d: Limb) {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let len_minus_1 = len - 1;\n    let mut highest_limb = ns[len_minus_1];\n    let bits = LeadingZeros::leading_zeros(d);\n    if bits == 0 {\n        let adjust = highest_limb >= d;\n        if adjust {\n            highest_limb -= d;\n        }\n        ns[len_minus_1] = Limb::from(adjust);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        limbs_div_limb_normalized_in_place(&mut ns[..len_minus_1], highest_limb, d, d_inv);\n    } else {\n        let d = d << bits;\n        let ns_high = limbs_slice_shl_in_place(ns, bits);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let r;\n        (ns[len_minus_1], r) = div_mod_by_preinversion(ns_high, ns[len_minus_1], d, d_inv);\n        limbs_div_limb_normalized_in_place(&mut ns[..len_minus_1], r, d, d_inv);\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::div_exact::MAX_OVER_3;\nuse crate::platform::Limb;\nuse malachite_base::num::arithmetic::traits::{WrappingMulAssign, WrappingSubAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\n\n// This is equivalent to `MODLIMB_INVERSE_3` from `gmp-impl.h`, GMP 6.2.1.\nconst MODLIMB_INVERSE_3: Limb = (MAX_OVER_3 << 1) | 1;\nconst CEIL_MAX_OVER_3: Limb = MAX_OVER_3 + 1;\nconst CEIL_2_MAX_OVER_3: Limb = ((Limb::MAX >> 1) / 3 + 1) | (1 << (Limb::WIDTH - 1));\n\n/// Benchmarks show that this algorithm is always worse than the default.\n///\n/// This is equivalent to `mpn_divexact_by3c` from `mpn/generic/diveby3.c`, GMP 6.2.1, with\n/// `DIVEXACT_BY3_METHOD == 1`, no carry-in, and no return value.\npub fn limbs_div_exact_3_to_out_alt(out: &mut [Limb], ns: &[Limb]) {\n    let len = ns.len();\n    assert_ne!(len, 0);\n    assert!(out.len() >= len);\n    let (ns_last, ns_init) = ns.split_last().unwrap();\n    let (out_last, out_init) = out[..len].split_last_mut().unwrap();\n    let mut big_carry = 0;\n    for (out_q, n) in out_init.iter_mut().zip(ns_init.iter()) {\n        let (diff, carry) = n.overflowing_sub(big_carry);\n        big_carry = Limb::from(carry);\n        let q = diff.wrapping_mul(MODLIMB_INVERSE_3);\n        *out_q = q;\n        if q >= CEIL_MAX_OVER_3 {\n            big_carry += 1;\n            if q >= CEIL_2_MAX_OVER_3 {\n                big_carry += 1;\n            }\n        }\n    }\n    *out_last = ns_last\n        .wrapping_sub(big_carry)\n        .wrapping_mul(MODLIMB_INVERSE_3);\n}\n\n/// Benchmarks show that this algorithm is always worse than the default.\n///\n/// This is equivalent to `mpn_divexact_by3c` from `mpn/generic/diveby3.c`, GMP 6.2.1, with\n/// `DIVEXACT_BY3_METHOD == 1`, no carry-in, and no return value, where `rp == up`.\npub fn limbs_div_exact_3_in_place_alt(ns: &mut [Limb]) {\n    let len = ns.len();\n    assert_ne!(len, 0);\n    let (ns_last, ns_init) = ns.split_last_mut().unwrap();\n    let mut big_carry = 0;\n    for n in &mut *ns_init {\n        let (diff, carry) = n.overflowing_sub(big_carry);\n        big_carry = Limb::from(carry);\n        let q = diff.wrapping_mul(MODLIMB_INVERSE_3);\n        *n = q;\n        if q >= CEIL_MAX_OVER_3 {\n            big_carry += 1;\n            if q >= CEIL_2_MAX_OVER_3 {\n                big_carry += 1;\n            }\n        }\n    }\n    ns_last.wrapping_sub_assign(big_carry);\n    ns_last.wrapping_mul_assign(MODLIMB_INVERSE_3);\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      `mpn_div_qr_1n_pi1` contributed to the GNU project by Niels Möller\n//\n//      `mpn_div_qr_1` contributed to the GNU project by Niels Möller and Torbjörn Granlund\n//\n//      Copyright © 1991, 1993, 1994, 1996, 1998-2000, 2002, 2003, 2013 Free Software Foundation,\n//      Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add::limbs_slice_add_limb_in_place;\nuse crate::natural::arithmetic::div_mod::{div_mod_by_preinversion, limbs_invert_limb};\nuse crate::natural::arithmetic::shl::{limbs_shl_to_out, limbs_slice_shl_in_place};\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::{\n    DivRem, OverflowingAddAssign, WrappingAddAssign, WrappingSubAssign, XMulYToZZ,\n};\nuse malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\n\npub fn rug_ceiling_div_neg_mod(x: rug::Integer, y: rug::Integer) -> (rug::Integer, rug::Integer) {\n    let (quotient, remainder) = x.div_rem_ceil(y);\n    (quotient, -remainder)\n}\n\npub fn limbs_div_limb_to_out_mod_naive(out: &mut [Limb], xs: &[Limb], d: Limb) -> Limb {\n    assert!(out.len() >= xs.len());\n    let d = DoubleLimb::from(d);\n    let mut upper = 0;\n    for (out_limb, &in_limb) in out.iter_mut().zip(xs.iter()).rev() {\n        let (q, r) = DoubleLimb::join_halves(upper, in_limb).div_rem(d);\n        *out_limb = q.lower_half();\n        upper = r.lower_half();\n    }\n    upper\n}\n\npub fn limbs_div_limb_in_place_mod_naive(xs: &mut [Limb], d: Limb) -> Limb {\n    let d = DoubleLimb::from(d);\n    let mut upper = 0;\n    for limb in xs.iter_mut().rev() {\n        let (q, r) = DoubleLimb::join_halves(upper, *limb).div_rem(d);\n        *limb = q.lower_half();\n        upper = r.lower_half();\n    }\n    upper\n}\n\n// The high bit of `d` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_div_qr_1n_pi1` from `mpn/generic/div_qr_1n_pi1.c`, GMP 6.2.1, with\n// `DIV_QR_1N_METHOD == 2`, where `qp == up`.\nfn limbs_div_limb_normalized_in_place_mod(\n    ns: &mut [Limb],\n    ns_high: Limb,\n    d: Limb,\n    d_inv: Limb,\n) -> Limb {\n    let len = ns.len();\n    if len == 1 {\n        let r;\n        (ns[0], r) = div_mod_by_preinversion(ns_high, ns[0], d, d_inv);\n        return r;\n    }\n    let power_of_2 = d.wrapping_neg().wrapping_mul(d_inv);\n    let (mut q_high, mut q_low) = Limb::x_mul_y_to_zz(d_inv, ns_high);\n    q_high.wrapping_add_assign(ns_high);\n    let ns_2nd_to_last = ns[len - 1];\n    ns[len - 1] = q_high;\n    let (sum, mut big_carry) = DoubleLimb::join_halves(ns_2nd_to_last, ns[len - 2])\n        .overflowing_add(DoubleLimb::from(power_of_2) * DoubleLimb::from(ns_high));\n    let (mut sum_high, mut sum_low) = sum.split_in_half();\n    for j in (0..len - 2).rev() {\n        let (t, r) = Limb::x_mul_y_to_zz(sum_high, d_inv);\n        let mut q = DoubleLimb::from(sum_high) + DoubleLimb::from(t) + DoubleLimb::from(q_low);\n        q_low = r;\n        if big_carry {\n            q.wrapping_add_assign(DoubleLimb::join_halves(1, d_inv));\n            if sum_low.overflowing_add_assign(power_of_2) {\n                sum_low.wrapping_sub_assign(d);\n                q.wrapping_add_assign(1);\n            }\n        }\n        let (q_higher, q_high) = q.split_in_half();\n        ns[j + 1] = q_high;\n        assert!(!limbs_slice_add_limb_in_place(&mut ns[j + 2..], q_higher));\n        let (sum, carry) = DoubleLimb::join_halves(sum_low, ns[j])\n            .overflowing_add(DoubleLimb::from(sum_high) * DoubleLimb::from(power_of_2));\n        sum_high = sum.upper_half();\n        sum_low = sum.lower_half();\n        big_carry = carry;\n    }\n    let mut q_high = 0;\n    if big_carry {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    if sum_high >= d {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    let (t, r) = div_mod_by_preinversion(sum_high, sum_low, d, d_inv);\n    let (q_high, q_low) = DoubleLimb::join_halves(q_high, q_low)\n        .wrapping_add(DoubleLimb::from(t))\n        .split_in_half();\n    assert!(!limbs_slice_add_limb_in_place(&mut ns[1..], q_high));\n    ns[0] = q_low;\n    r\n}\n\n// The high bit of `d` must be set.\n//\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(n)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_div_qr_1n_pi1` from `mpn/generic/div_qr_1n_pi1.c`, GMP 6.2.1, with\n// `DIV_QR_1N_METHOD == 2`.\nfn limbs_div_limb_normalized_to_out_mod(\n    out: &mut [Limb],\n    ns: &[Limb],\n    n_last: Limb,\n    d: Limb,\n    d_inv: Limb,\n) -> Limb {\n    let len = ns.len();\n    if len == 1 {\n        let (q, r) = div_mod_by_preinversion(n_last, ns[0], d, d_inv);\n        out[0] = q;\n        return r;\n    }\n    let power_of_2 = d.wrapping_neg().wrapping_mul(d_inv);\n    let (mut q_high, mut q_low) = Limb::x_mul_y_to_zz(d_inv, n_last);\n    q_high.wrapping_add_assign(n_last);\n    out[len - 1] = q_high;\n    let (sum, mut big_carry) = DoubleLimb::join_halves(ns[len - 1], ns[len - 2])\n        .overflowing_add(DoubleLimb::from(power_of_2) * DoubleLimb::from(n_last));\n    let (mut sum_high, mut sum_low) = sum.split_in_half();\n    for j in (0..len - 2).rev() {\n        let (t, r) = Limb::x_mul_y_to_zz(sum_high, d_inv);\n        let mut q = DoubleLimb::from(sum_high) + DoubleLimb::from(t) + DoubleLimb::from(q_low);\n        q_low = r;\n        if big_carry {\n            q.wrapping_add_assign(DoubleLimb::join_halves(1, d_inv));\n            let (sum, carry) = sum_low.overflowing_add(power_of_2);\n            sum_low = sum;\n            if carry {\n                sum_low.wrapping_sub_assign(d);\n                q.wrapping_add_assign(1);\n            }\n        }\n        let (q_higher, q_high) = q.split_in_half();\n        out[j + 1] = q_high;\n        assert!(!limbs_slice_add_limb_in_place(&mut out[j + 2..], q_higher));\n        let (sum, carry) = DoubleLimb::join_halves(sum_low, ns[j])\n            .overflowing_add(DoubleLimb::from(sum_high) * DoubleLimb::from(power_of_2));\n        sum_high = sum.upper_half();\n        sum_low = sum.lower_half();\n        big_carry = carry;\n    }\n    let mut q_high = 0;\n    if big_carry {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    if sum_high >= d {\n        q_high += 1;\n        sum_high.wrapping_sub_assign(d);\n    }\n    let (t, r) = div_mod_by_preinversion(sum_high, sum_low, d, d_inv);\n    let (q_high, q_low) = DoubleLimb::join_halves(q_high, q_low)\n        .wrapping_add(DoubleLimb::from(t))\n        .split_in_half();\n    assert!(!limbs_slice_add_limb_in_place(&mut out[1..], q_high));\n    out[0] = q_low;\n    r\n}\n\n/// This is equivalent to `mpn_div_qr_1` from `mpn/generic/div_qr_1.c`, GMP 6.2.1, where `len > 1`.\n/// Experiments show that this is always slower than `limbs_div_limb_to_out_mod`.\npub fn limbs_div_limb_to_out_mod_alt(out: &mut [Limb], ns: &[Limb], d: Limb) -> Limb {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let out = &mut out[..len];\n    assert!(out.len() >= len);\n    let (ns_last, ns_init) = ns.split_last().unwrap();\n    let mut ns_last = *ns_last;\n    let bits = LeadingZeros::leading_zeros(d);\n    if bits == 0 {\n        let (out_last, out_init) = out.split_last_mut().unwrap();\n        *out_last = if ns_last >= d {\n            ns_last -= d;\n            1\n        } else {\n            0\n        };\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        limbs_div_limb_normalized_to_out_mod(out_init, ns_init, ns_last, d, d_inv)\n    } else {\n        let d = d << bits;\n        let ns_last = limbs_shl_to_out(out, ns, bits);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let (out_last, out_init) = out.split_last_mut().unwrap();\n        let (q, r) = div_mod_by_preinversion(ns_last, *out_last, d, d_inv);\n        *out_last = q;\n        limbs_div_limb_normalized_in_place_mod(out_init, r, d, d_inv) >> bits\n    }\n}\n\n/// This is equivalent to `mpn_div_qr_1` from `mpn/generic/div_qr_1.c`, GMP 6.2.1, where `qp == up`\n/// and `len > 1`. Experiments show that this is always slower than `limbs_div_limb_in_place_mod`.\npub fn limbs_div_limb_in_place_mod_alt(ns: &mut [Limb], d: Limb) -> Limb {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let len_minus_1 = len - 1;\n    let mut ns_last = ns[len_minus_1];\n    let bits = LeadingZeros::leading_zeros(d);\n    if bits == 0 {\n        ns[len_minus_1] = if ns_last >= d {\n            ns_last -= d;\n            1\n        } else {\n            0\n        };\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        limbs_div_limb_normalized_in_place_mod(&mut ns[..len_minus_1], ns_last, d, d_inv)\n    } else {\n        let d = d << bits;\n        let ns_last = limbs_slice_shl_in_place(ns, bits);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let (q, r) = div_mod_by_preinversion(ns_last, ns[len_minus_1], d, d_inv);\n        ns[len_minus_1] = q;\n        limbs_div_limb_normalized_in_place_mod(&mut ns[..len_minus_1], r, d, d_inv) >> bits\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2000-2002 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::divisible_by::limbs_divisible_by_limb;\nuse crate::natural::arithmetic::mod_op::limbs_mod_limb;\nuse crate::platform::{BMOD_1_TO_MOD_1_THRESHOLD, DoubleLimb, Limb};\nuse num::{BigUint, Integer, Zero};\n\npub fn num_divisible_by(x: &BigUint, y: &BigUint) -> bool {\n    *x == BigUint::zero() || *y != BigUint::zero() && x.is_multiple_of(y)\n}\n\n/// Benchmarks show that this is never faster than just calling `limbs_divisible_by_limb`.\n///\n/// ns.len() must be greater than 1; divisor must be nonzero.\n///\n/// This is equivalent to `mpz_divisible_ui_p` from `mpz/divis_ui.c`, GMP 6.2.1, where `a` is\n/// non-negative.\n#[allow(clippy::absurd_extreme_comparisons)]\npub fn combined_limbs_divisible_by_limb(ns: &[Limb], d: Limb) -> bool {\n    if ns.len() <= BMOD_1_TO_MOD_1_THRESHOLD {\n        limbs_divisible_by_limb(ns, d)\n    } else {\n        limbs_mod_limb::<DoubleLimb, Limb>(ns, d) == 0\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 2000-2002, 2012 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::divisible_by::{\n    limbs_divisible_by_limb, limbs_divisible_by_val_ref,\n};\nuse crate::natural::arithmetic::eq_mod::limbs_eq_limb_mod_limb;\nuse crate::natural::arithmetic::mod_op::{limbs_mod, limbs_mod_limb};\nuse crate::natural::arithmetic::sub::{limbs_sub, limbs_sub_limb};\nuse crate::natural::comparison::cmp::limbs_cmp;\nuse crate::platform::{BMOD_1_TO_MOD_1_THRESHOLD, DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::slices::slice_trailing_zeros;\nuse std::cmp::Ordering::*;\n\npub fn limbs_eq_limb_mod_naive_1(xs: &[Limb], y: Limb, ms: &[Limb]) -> bool {\n    assert!(xs.len() > 1);\n    assert!(ms.len() > 1);\n    let mut xs_mod = if xs.len() >= ms.len() {\n        limbs_mod(xs, ms)\n    } else {\n        xs.to_vec()\n    };\n    xs_mod.truncate(xs_mod.len() - slice_trailing_zeros(&xs_mod));\n    xs_mod == [y]\n}\n\npub fn limbs_eq_limb_mod_naive_2(xs: &[Limb], y: Limb, ms: &[Limb]) -> bool {\n    let mut diff = limbs_sub_limb(xs, y).0;\n    diff.truncate(diff.len() - slice_trailing_zeros(&diff));\n    diff.len() >= ms.len() && limbs_divisible_by_val_ref(&mut diff, ms)\n}\n\npub fn limbs_eq_mod_limb_naive_1(xs: &[Limb], ys: &[Limb], ms: Limb) -> bool {\n    assert!(xs.len() > 1);\n    assert!(ys.len() > 1);\n    limbs_mod_limb::<DoubleLimb, Limb>(xs, ms) == limbs_mod_limb::<DoubleLimb, Limb>(ys, ms)\n}\n\npub fn limbs_eq_mod_limb_naive_2(xs: &[Limb], ys: &[Limb], ms: Limb) -> bool {\n    if xs == ys {\n        return true;\n    }\n    let mut diff = if limbs_cmp(xs, ys) >= Equal {\n        limbs_sub(xs, ys)\n    } else {\n        limbs_sub(ys, xs)\n    }\n    .0;\n    diff.truncate(diff.len() - slice_trailing_zeros(&diff));\n    if diff.len() == 1 {\n        diff[0].divisible_by(ms)\n    } else {\n        limbs_divisible_by_limb(&diff, ms)\n    }\n}\n\npub fn limbs_eq_mod_naive_1(xs: &[Limb], ys: &[Limb], ms: &[Limb]) -> bool {\n    let mut xs_mod = if xs.len() >= ms.len() {\n        limbs_mod(xs, ms)\n    } else {\n        xs.to_vec()\n    };\n    let mut ys_mod = if ys.len() >= ms.len() {\n        limbs_mod(ys, ms)\n    } else {\n        ys.to_vec()\n    };\n    xs_mod.truncate(xs_mod.len() - slice_trailing_zeros(&xs_mod));\n    ys_mod.truncate(ys_mod.len() - slice_trailing_zeros(&ys_mod));\n    limbs_cmp(&xs_mod, &ys_mod) == Equal\n}\n\npub fn limbs_eq_mod_naive_2(xs: &[Limb], ys: &[Limb], ms: &[Limb]) -> bool {\n    if xs == ys {\n        return true;\n    }\n    let mut diff = if limbs_cmp(xs, ys) >= Equal {\n        limbs_sub(xs, ys)\n    } else {\n        limbs_sub(ys, xs)\n    }\n    .0;\n    diff.truncate(diff.len() - slice_trailing_zeros(&diff));\n    diff.len() >= ms.len() && limbs_divisible_by_val_ref(&mut diff, ms)\n}\n\n/// Benchmarks show that this is never faster than just calling `limbs_eq_limb_mod_limb`.\n///\n/// xs.len() must be greater than 1; m must be nonzero.\n///\n/// This is equivalent to `mpz_congruent_ui_p` from `mpz/cong_ui.c`, GMP 6.2.1, where `a` is\n/// non-negative.\npub fn combined_limbs_eq_limb_mod_limb(xs: &[Limb], y: Limb, m: Limb) -> bool {\n    if xs.len() < BMOD_1_TO_MOD_1_THRESHOLD {\n        limbs_mod_limb::<DoubleLimb, Limb>(xs, m) == y % m\n    } else {\n        limbs_eq_limb_mod_limb(xs, y, m)\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{DivExact, DivMod, DivRound, NegAssign};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse std::mem::swap;\n\npub fn extended_gcd_euclidean_natural(\n    mut a: Natural,\n    mut b: Natural,\n) -> (Natural, Integer, Integer) {\n    let mut stack = Vec::new();\n    let gcd;\n    let mut x;\n    let mut y;\n    loop {\n        if a == 0u32 && b == 0u32 {\n            (gcd, x, y) = (a, Integer::ZERO, Integer::ZERO);\n            break;\n        } else if a == b || a == 0u32 {\n            (gcd, x, y) = (b, Integer::ZERO, Integer::ONE);\n            break;\n        }\n        let (q, r) = (&b).div_mod(&a);\n        stack.push(q);\n        swap(&mut a, &mut b);\n        a = r;\n    }\n    for q in stack.into_iter().rev() {\n        swap(&mut x, &mut y);\n        x -= Integer::from(q) * &y;\n    }\n    (gcd, x, y)\n}\n\n// This is equivalent to `n_xgcd` from `ulong_extras/xgcd.c`, FLINT 2.7.1, extended to `Natural`s\n// and with an adjustment to find the minimal cofactors.\npub fn extended_gcd_binary_natural(mut a: Natural, mut b: Natural) -> (Natural, Integer, Integer) {\n    if a == 0u32 && b == 0u32 {\n        return (Natural::ZERO, Integer::ZERO, Integer::ZERO);\n    } else if a == b || a == 0u32 {\n        return (b, Integer::ZERO, Integer::ONE);\n    } else if b == 0u32 {\n        return (a, Integer::ONE, Integer::ZERO);\n    }\n    let mut swapped = false;\n    if a < b {\n        swap(&mut a, &mut b);\n        swapped = true;\n    }\n    let mut u1 = Integer::ONE;\n    let mut v2 = Integer::ONE;\n    let mut u2 = Integer::ZERO;\n    let mut v1 = Integer::ZERO;\n    let mut u3 = a.clone();\n    let mut v3 = b.clone();\n    let mut d;\n    let mut t2;\n    let mut t1;\n    while v3 != 0u32 {\n        d = &u3 - &v3;\n        if u3 < (&v3 << 2) {\n            if d < v3 {\n                // quot = 1\n                t2 = v2.clone();\n                t1 = u2.clone();\n                u2 -= u1;\n                u2.neg_assign();\n                u1 = t1;\n                u3 = v3;\n                v2 -= v1;\n                v2.neg_assign();\n                v1 = t2;\n                v3 = d;\n            } else if d < (&v3 << 1) {\n                // quot = 2\n                t1 = u2.clone();\n                u2 = u1 - (&u2 << 1);\n                u1 = t1;\n                u3 = v3;\n                t2 = v2.clone();\n                v2 = v1 - (v2 << 1);\n                v1 = t2;\n                v3 = d - &u3;\n            } else {\n                // quot = 3\n                t1 = u2.clone();\n                u2 = u1 - Integer::from(3u32) * &u2;\n                u1 = t1;\n                u3 = v3;\n                t2 = v2.clone();\n                v2 = v1 - Integer::from(3u32) * &v2;\n                v1 = t2;\n                v3 = d - (&u3 << 1);\n            }\n        } else {\n            let (quot, rem) = u3.div_mod(&v3);\n            let quot = Integer::from(quot);\n            t1 = u2.clone();\n            u2 = u1 - &quot * &u2;\n            u1 = t1;\n            u3 = v3.clone();\n            t2 = v2.clone();\n            v2 = v1 - quot * &v2;\n            v1 = t2;\n            v3 = rem;\n        }\n    }\n    // The cofactors at this point are not necessarily minimal, so we may need to adjust.\n    let gcd = u3;\n    let mut x = u1;\n    let mut y = v1;\n    let two_limit_a = Integer::from(a.div_exact(&gcd));\n    let two_limit_b = Integer::from(b.div_exact(&gcd));\n    let limit_b = &two_limit_b >> 1u32;\n    if x > limit_b {\n        let k = (&x - limit_b).div_round(&two_limit_b, Ceiling).0;\n        x -= two_limit_b * &k;\n        y += two_limit_a * k;\n    }\n    if swapped {\n        swap(&mut x, &mut y);\n    }\n    (gcd, x, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::SaturatingSubAssign;\nuse malachite_base::num::basic::traits::One;\n\npub fn factorial_naive(mut n: u64) -> Natural {\n    let mut f = Natural::ONE;\n    while n != 0 {\n        f *= Natural::from(n);\n        n -= 1;\n    }\n    f\n}\n\npub fn double_factorial_naive(mut n: u64) -> Natural {\n    let mut f = Natural::ONE;\n    while n != 0 {\n        f *= Natural::from(n);\n        n.saturating_sub_assign(2);\n    }\n    f\n}\n\npub fn multifactorial_naive(mut n: u64, m: u64) -> Natural {\n    assert_ne!(m, 0);\n    let mut f = Natural::ONE;\n    while n != 0 {\n        f *= Natural::from(n);\n        n.saturating_sub_assign(m);\n    }\n    f\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1996, 1998, 2000-2004, 2008, 2012, 2019 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::gcd::half_gcd::{\n    HalfGcdMatrix, HalfGcdMatrix1, limbs_half_gcd_matrix_mul_matrix_1,\n    limbs_half_gcd_matrix_update_q,\n};\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::{DivMod, Parity, XXSubYYToZZ};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{JoinHalves, SplitInHalf};\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::slices::slice_test_zero;\n\npub fn gcd_euclidean_nz(x: Natural, y: Natural) -> Natural {\n    if y == 0 {\n        x\n    } else {\n        let r = x % &y;\n        gcd_euclidean_nz(y, r)\n    }\n}\n\n// recursive implementation overflows stack, so using a loop instead\npub fn gcd_binary_nz(mut x: Natural, mut y: Natural) -> Natural {\n    let mut twos = 0;\n    loop {\n        if x == y {\n            return x << twos;\n        } else if x == 0 {\n            return y << twos;\n        } else if y == 0 {\n            return x << twos;\n        } else if x.even() {\n            x >>= 1;\n            if y.even() {\n                y >>= 1;\n                twos += 1;\n            }\n        } else if y.even() {\n            y >>= 1;\n        } else if x > y {\n            x -= &y;\n            x >>= 1;\n        } else {\n            y -= &x;\n            y >>= 1;\n        }\n    }\n}\n\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct OwnedHalfGcdMatrix {\n    pub data: Vec<Limb>,\n    pub s: usize,\n    pub two_s: usize,\n    pub three_s: usize,\n    pub n: usize,\n}\n\n#[allow(clippy::missing_const_for_fn)]\nfn from_owned(m: &mut OwnedHalfGcdMatrix) -> HalfGcdMatrix<'_> {\n    HalfGcdMatrix {\n        s: m.s,\n        two_s: m.two_s,\n        three_s: m.three_s,\n        n: m.n,\n        data: &mut m.data,\n    }\n}\n\nimpl OwnedHalfGcdMatrix {\n    pub fn init(n: usize, mut p: Vec<Limb>) -> Self {\n        let m = HalfGcdMatrix::init(n, &mut p);\n        Self {\n            s: m.s,\n            two_s: m.two_s,\n            three_s: m.three_s,\n            n: m.n,\n            data: p,\n        }\n    }\n\n    pub const fn update_q_scratch_len(&self, qs_len: usize) -> usize {\n        self.n + qs_len\n    }\n\n    pub fn mul_matrix_1(&mut self, m_1: &HalfGcdMatrix1, scratch: &mut [Limb]) {\n        let mut om = from_owned(self);\n        limbs_half_gcd_matrix_mul_matrix_1(&mut om, m_1, scratch);\n        self.n = om.n;\n    }\n\n    pub fn update_q(&mut self, qs: &[Limb], column: u8, scratch: &mut [Limb]) {\n        let mut om = from_owned(self);\n        limbs_half_gcd_matrix_update_q(&mut om, qs, column, scratch);\n        self.n = om.n;\n    }\n\n    pub fn get(&self, row: u8, column: u8) -> &[Limb] {\n        match (row, column) {\n            (0, 0) => &self.data[..self.s],\n            (0, 1) => &self.data[self.s..self.two_s],\n            (1, 0) => &self.data[self.two_s..self.three_s],\n            (1, 1) => &self.data[self.three_s..],\n            _ => panic!(),\n        }\n    }\n}\n\npub fn half_gcd_matrix_create(s: usize, n: usize, data: Vec<Limb>) -> OwnedHalfGcdMatrix {\n    assert!(n <= s);\n    assert_eq!(data.len(), s << 2);\n    OwnedHalfGcdMatrix {\n        data,\n        s,\n        two_s: s << 1,\n        three_s: s * 3,\n        n,\n    }\n}\n\npub fn half_gcd_matrix_to_naturals(m: &OwnedHalfGcdMatrix) -> (Natural, Natural, Natural, Natural) {\n    let n = m.n;\n    (\n        Natural::from_limbs_asc(&m.get(0, 0)[..n]),\n        Natural::from_limbs_asc(&m.get(0, 1)[..n]),\n        Natural::from_limbs_asc(&m.get(1, 0)[..n]),\n        Natural::from_limbs_asc(&m.get(1, 1)[..n]),\n    )\n}\n\npub fn half_gcd_matrix_1_to_naturals(m_1: &HalfGcdMatrix1) -> (Natural, Natural, Natural, Natural) {\n    (\n        Natural::from(m_1.data[0][0]),\n        Natural::from(m_1.data[0][1]),\n        Natural::from(m_1.data[1][0]),\n        Natural::from(m_1.data[1][1]),\n    )\n}\n\npub fn half_gcd_matrix_create_string(m: &HalfGcdMatrix) -> String {\n    format!(\"half_gcd_matrix_create({}, {}, vec!{:?})\", m.s, m.n, m.data)\n}\n\npub fn half_gcd_matrix_all_elements_nonzero(m: &HalfGcdMatrix) -> bool {\n    for i in 0..2 {\n        for j in 0..2 {\n            if slice_test_zero(m.get(i, j)) {\n                return false;\n            }\n        }\n    }\n    true\n}\n\n/// This is equivalent to `div2` from `mpn/generic/hgcd2.c`, GMP 6.2.1, where `HGCD2_DIV2_METHOD ==\n/// 2`.\npub fn limbs_gcd_div_alt(\n    mut n1: Limb,\n    mut n0: Limb,\n    mut d1: Limb,\n    mut d0: Limb,\n) -> (Limb, Limb, Limb) {\n    let mut q = 0;\n    let n_zeros = LeadingZeros::leading_zeros(n1);\n    let mut d_zeros = LeadingZeros::leading_zeros(d1);\n    assert!(d_zeros >= n_zeros);\n    d_zeros -= n_zeros;\n    d1 = (d1 << d_zeros) + (d0 >> 1 >> (Limb::WIDTH - 1 - d_zeros));\n    d0 <<= d_zeros;\n    for _ in 0..=d_zeros {\n        q <<= 1;\n        if n1 == d1 && n0 >= d0 || n1 != d1 && n1 > d1 {\n            q |= 1;\n            (n1, n0) = Limb::xx_sub_yy_to_zz(n1, n0, d1, d0);\n        }\n        d0 = (d1 << (Limb::WIDTH - 1)) | (d0 >> 1);\n        d1 >>= 1;\n    }\n    (q, n1, n0)\n}\n\npub fn limbs_gcd_div_naive(n1: Limb, n0: Limb, d1: Limb, d0: Limb) -> (Limb, Limb, Limb) {\n    let (q, r) = DoubleLimb::join_halves(n1, n0).div_mod(DoubleLimb::join_halves(d1, d0));\n    let (q1, q0) = q.split_in_half();\n    assert_eq!(q1, 0);\n    let (r1, r0) = r.split_in_half();\n    (q0, r1, r0)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, NegAssign, Parity};\nuse malachite_base::num::conversion::traits::WrappingInto;\nuse malachite_base::num::logic::traits::BitAccess;\nuse std::mem::swap;\n\npub fn jacobi_symbol_simple(mut a: Natural, mut n: Natural) -> i8 {\n    assert_ne!(n, 0u32);\n    assert!(n.odd());\n    a %= &n;\n    let mut t = 1i8;\n    while a != 0u32 {\n        while a.even() {\n            a >>= 1u32;\n            let r: u8 = (&(&n).mod_power_of_2(3)).wrapping_into();\n            if r == 3 || r == 5 {\n                t.neg_assign();\n            }\n        }\n        swap(&mut a, &mut n);\n        if a.get_bit(1) && n.get_bit(1) {\n            t.neg_assign();\n        }\n        a %= &n;\n    }\n    if n == 1u32 { t } else { 0 }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBasePowerOf2, CheckedLogBase2, CheckedLogBasePowerOf2, FloorLogBasePowerOf2, Square,\n};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse std::cmp::Ordering::*;\n\npub fn floor_log_base_naive(x: &Natural, base: &Natural) -> u64 {\n    assert_ne!(*x, 0);\n    assert!(*base > 1);\n    let mut result = 0;\n    let mut p = Natural::ONE;\n    // loop always executes at least once\n    while p <= *x {\n        result += 1;\n        p *= base;\n    }\n    result - 1\n}\n\npub fn ceiling_log_base_naive(x: &Natural, base: &Natural) -> u64 {\n    assert_ne!(*x, 0);\n    assert!(*base > 1);\n    let mut result = 0;\n    let mut p = Natural::ONE;\n    while p < *x {\n        result += 1;\n        p *= base;\n    }\n    result\n}\n\npub fn checked_log_base_naive(x: &Natural, base: &Natural) -> Option<u64> {\n    assert_ne!(*x, 0);\n    assert!(*base > 1);\n    let mut result = 0;\n    let mut p = Natural::ONE;\n    while p < *x {\n        result += 1;\n        p *= base;\n    }\n    if p == *x { Some(result) } else { None }\n}\n\nfn log_by_squaring_helper(x: &Natural, base: &Natural) -> (u64, bool) {\n    assert_ne!(*x, 0);\n    assert!(*base > 1);\n    if *x == 1 {\n        return (0, true);\n    } else if x < base {\n        return (0, false);\n    }\n    let x_bits = x.significant_bits();\n    let mut powers = vec![base.clone()];\n    for i in 0.. {\n        let power = &powers[i];\n        if ((power.significant_bits() - 1) << 1) | 1 > x_bits {\n            break;\n        }\n        let next_power = power.square();\n        powers.push(next_power);\n    }\n    // At this point, `powers[i]` is `base ^ (2 ^ i)`\n    let mut log = 0;\n    let mut test_power = Natural::ONE;\n    for (i, power) in powers.into_iter().enumerate().rev() {\n        let new_test_power = &test_power * power;\n        match new_test_power.cmp(x) {\n            Equal => {\n                log.set_bit(u64::exact_from(i));\n                return (log, true);\n            }\n            Less => {\n                test_power = new_test_power;\n                log.set_bit(u64::exact_from(i));\n            }\n            _ => {}\n        }\n    }\n    (log, false)\n}\n\npub fn floor_log_base_by_squaring(x: &Natural, base: &Natural) -> u64 {\n    if let Some(log_base) = base.checked_log_base_2() {\n        return x.floor_log_base_power_of_2(log_base);\n    }\n    log_by_squaring_helper(x, base).0\n}\n\npub fn ceiling_log_base_by_squaring(x: &Natural, base: &Natural) -> u64 {\n    if let Some(log_base) = base.checked_log_base_2() {\n        return x.ceiling_log_base_power_of_2(log_base);\n    }\n    let (log, exact) = log_by_squaring_helper(x, base);\n    if exact { log } else { log + 1 }\n}\n\npub fn checked_log_base_by_squaring(x: &Natural, base: &Natural) -> Option<u64> {\n    if let Some(log_base) = base.checked_log_base_2() {\n        return x.checked_log_base_power_of_2(log_base);\n    }\n    let (log, exact) = log_by_squaring_helper(x, base);\n    if exact { Some(log) } else { None }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::basic::traits::{One, Zero};\n\npub fn ceiling_log_base_power_of_2_naive_nz(x: &Natural, pow: u64) -> u64 {\n    assert_ne!(*x, Natural::ZERO);\n    assert_ne!(pow, 0);\n    let mut result = 0;\n    let mut p = Natural::ONE;\n    while p < *x {\n        result += 1;\n        p <<= pow;\n    }\n    result\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod add;\npub mod binomial_coefficient;\npub mod checked_sub;\npub mod div;\npub mod div_exact;\npub mod div_mod;\npub mod divisible_by;\npub mod eq_mod;\npub mod extended_gcd;\npub mod factorial;\npub mod gcd;\npub mod kronecker_symbol;\npub mod log_base;\npub mod log_base_power_of_2;\npub mod mod_inverse;\npub mod mod_mul;\npub mod mod_op;\npub mod mod_pow;\npub mod mod_power_of_2_pow;\npub mod mod_power_of_2_square;\npub mod mul;\npub mod neg;\npub mod pow;\npub mod primorial;\npub mod root;\npub mod sqrt;\npub mod square;\npub mod sub;\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::integer::Integer;\nuse crate::natural::InnerNatural::Small;\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ExtendedGcd, ModInverse};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\nfn mod_inverse_simple_helper(x: Natural, m: Natural) -> Option<Natural> {\n    let (gcd, _, inverse) = (&m).extended_gcd(x);\n    if gcd == 1u32 {\n        Some(Natural::exact_from(if inverse < 0u32 {\n            inverse + Integer::from(m)\n        } else {\n            inverse\n        }))\n    } else {\n        None\n    }\n}\n\npub fn mod_inverse_simple(n: Natural, m: Natural) -> Option<Natural> {\n    assert_ne!(n, 0u32);\n    assert!(n < m);\n    match (n, m) {\n        (x @ Natural::ONE, _) => Some(x),\n        (Natural(Small(x)), Natural(Small(y))) => x.mod_inverse(y).map(Natural::from),\n        (a, b) => mod_inverse_simple_helper(a, b),\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ExactFrom, JoinHalves, SplitInHalf};\n\npub fn limbs_precompute_mod_mul_two_limbs_alt(m_1: Limb, m_0: Limb) -> (Limb, Limb, Limb) {\n    let out_limbs = (Natural::power_of_2(Limb::WIDTH << 2)\n        / Natural::from(DoubleLimb::join_halves(m_1, m_0)))\n    .into_limbs_asc();\n    assert_eq!(out_limbs.len(), 3);\n    (out_limbs[2], out_limbs[1], out_limbs[0])\n}\n\n/// m_1 cannot be zero, and we cannot have m_1 == 1 and m_0 == 0. Both [x_0, x_1] and [y_0, y_1]\n/// must be less than [m_0, m_1].\npub fn limbs_mod_mul_two_limbs_naive(\n    x_1: Limb,\n    x_0: Limb,\n    y_1: Limb,\n    y_0: Limb,\n    m_1: Limb,\n    m_0: Limb,\n) -> (Limb, Limb) {\n    DoubleLimb::exact_from(\n        &(Natural::from(DoubleLimb::join_halves(x_1, x_0))\n            * Natural::from(DoubleLimb::join_halves(y_1, y_0))\n            % Natural::from(DoubleLimb::join_halves(m_1, m_0))),\n    )\n    .split_in_half()\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1993, 1994, 1996, 1998-2000, 2002, 2003 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::div_mod::limbs_invert_limb;\nuse crate::natural::arithmetic::mod_op::mod_by_preinversion;\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse rug::ops::RemRounding;\n\npub fn rug_neg_mod(x: rug::Integer, y: rug::Integer) -> rug::Integer {\n    -x.rem_ceil(y)\n}\n\n// # Worst-case complexity\n// $T(n) = O(n)$\n//\n// $M(n) = O(1)$\n//\n// where $T$ is time, $M$ is additional memory, and $n$ is `ns.len()`.\n//\n// This is equivalent to `mpn_divrem_1` from `mpn/generic/divrem_1.c`, GMP 6.2.1, where `qxn == 0`\n// and `un > 1`, but not computing the quotient.\npub fn limbs_mod_limb_alt_3(ns: &[Limb], d: Limb) -> Limb {\n    assert_ne!(d, 0);\n    let len = ns.len();\n    assert!(len > 1);\n    let bits = LeadingZeros::leading_zeros(d);\n    let (ns_last, ns_init) = ns.split_last().unwrap();\n    if bits == 0 {\n        // High quotient limb is 0 or 1, skip a divide step.\n        let mut r = *ns_last;\n        if r >= d {\n            r -= d;\n        }\n        // Multiply-by-inverse, divisor already normalized.\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        for n in ns_init.iter().rev() {\n            r = mod_by_preinversion::<DoubleLimb, Limb>(r, *n, d, d_inv);\n        }\n        r\n    } else {\n        // Skip a division if high < divisor (high quotient 0). Testing here before normalizing will\n        // still skip as often as possible.\n        let (ns, mut r) = if *ns_last < d {\n            (ns_init, *ns_last)\n        } else {\n            (ns, 0)\n        };\n        let d = d << bits;\n        r <<= bits;\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d);\n        let (ns_last, ns_init) = ns.split_last().unwrap();\n        let mut previous_n = *ns_last;\n        let cobits = Limb::WIDTH - bits;\n        r |= previous_n >> cobits;\n        for &n in ns_init.iter().rev() {\n            let shifted_n = (previous_n << bits) | (n >> cobits);\n            r = mod_by_preinversion::<DoubleLimb, Limb>(r, shifted_n, d, d_inv);\n            previous_n = n;\n        }\n        mod_by_preinversion::<DoubleLimb, Limb>(r, previous_n << bits, d, d_inv) >> bits\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::ModMulAssign;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::BitIterable;\n\npub fn simple_binary_mod_pow(x: &Natural, exp: &Natural, m: &Natural) -> Natural {\n    if *m == 1 {\n        return Natural::ZERO;\n    }\n    let mut out = Natural::ONE;\n    for bit in exp.bits().rev() {\n        out.mod_mul_assign(out.clone(), m);\n        if bit {\n            out.mod_mul_assign(x, m);\n        }\n    }\n    out\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mod_power_of_2_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2MulAssign, ModPowerOf2SquareAssign};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::BitIterable;\n\npub fn simple_binary_mod_power_of_2_pow(x: &Natural, exp: &Natural, pow: u64) -> Natural {\n    if pow == 0 {\n        return Natural::ZERO;\n    }\n    let mut out = Natural::ONE;\n    for bit in exp.bits().rev() {\n        out.mod_power_of_2_square_assign(pow);\n        if bit {\n            out.mod_power_of_2_mul_assign(x, pow);\n        }\n    }\n    out\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mod_power_of_2_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::mod_power_of_2_square::limbs_square_diagonal_shl_add;\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::{Square, WrappingSquare};\nuse malachite_base::num::conversion::traits::SplitInHalf;\n\npub fn limbs_square_low_basecase_unrestricted(out: &mut [Limb], xs: &[Limb]) {\n    let n = xs.len();\n    let out = &mut out[..n];\n    assert_ne!(n, 0);\n    let xs_0 = xs[0];\n    match n {\n        1 => out[0] = xs_0.wrapping_square(),\n        2 => {\n            let p_hi;\n            (p_hi, out[0]) = DoubleLimb::from(xs_0).square().split_in_half();\n            out[1] = (xs_0.wrapping_mul(xs[1]) << 1).wrapping_add(p_hi);\n        }\n        _ => {\n            let mut scratch = vec![0; n - 1];\n            limbs_mul_limb_to_out::<DoubleLimb, Limb>(&mut scratch, &xs[1..], xs_0);\n            for i in 1.. {\n                let two_i = i << 1;\n                if two_i >= n - 1 {\n                    break;\n                }\n                limbs_slice_add_mul_limb_same_length_in_place_left(\n                    &mut scratch[two_i..],\n                    &xs[i + 1..n - i],\n                    xs[i],\n                );\n            }\n            limbs_square_diagonal_shl_add(out, &mut scratch, xs);\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::InnerNatural::{Large, Small};\nuse crate::natural::Natural;\nuse crate::natural::arithmetic::add::limbs_slice_add_greater_in_place_left;\nuse crate::natural::arithmetic::div_exact::limbs_div_exact_limb_to_out;\nuse crate::natural::arithmetic::mod_op::limbs_mod_limb;\nuse crate::natural::arithmetic::mul::fft::{\n    CRTData, Context, FFTContext, MAX_NPROFILES, MPN_CTX_NCRTS, MPN_CTX_TWO_POWER_TAB_SIZE,\n    MPNToFFTFunc, ModData, SD_FFT_CTX_W2TAB_INIT, SerializedCRTData, SerializedContext,\n    SerializedFFTContext, VEC_SZ, crt_data_find_bn_bound, f64_mulmod, f64_reduce_0n_to_pmhn,\n    f64_reduce_pm1n_to_pmhn, f64x4_mul_add, mpn_mul_default_mpn_ctx,\n};\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_6h, limbs_mul_greater_to_out_toom_8h,\n    limbs_mul_greater_to_out_toom_22, limbs_mul_greater_to_out_toom_32,\n    limbs_mul_greater_to_out_toom_33, limbs_mul_greater_to_out_toom_42,\n    limbs_mul_greater_to_out_toom_43, limbs_mul_greater_to_out_toom_44,\n    limbs_mul_greater_to_out_toom_53, limbs_mul_greater_to_out_toom_63,\n};\nuse crate::natural::arithmetic::mul::{\n    FFT_MUL_THRESHOLD, limbs_mul_greater_to_out_basecase, limbs_mul_greater_to_out_scratch_len,\n    toom44_ok,\n};\nuse crate::platform::{\n    Limb, MUL_FFT_THRESHOLD, MUL_TOOM6H_THRESHOLD, MUL_TOOM8H_THRESHOLD, MUL_TOOM22_THRESHOLD,\n    MUL_TOOM32_TO_TOOM43_THRESHOLD, MUL_TOOM32_TO_TOOM53_THRESHOLD, MUL_TOOM33_THRESHOLD,\n    MUL_TOOM42_TO_TOOM53_THRESHOLD, MUL_TOOM42_TO_TOOM63_THRESHOLD, MUL_TOOM44_THRESHOLD,\n};\nuse libm::scalbn;\nuse malachite_base::num::arithmetic::traits::{\n    DivRound, ModPow, PowerOf2, XMulYToZZ, XXDivModYToQR,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::factorization::traits::{IsPrime, PrimitiveRootPrime};\nuse malachite_base::num::logic::traits::{LeadingZeros, SignificantBits, TrailingZeros};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse wide::f64x4;\n\n// In GMP this is hardcoded to 500\npub const MUL_BASECASE_MAX_UN: usize = 500;\n\n// We must have 1 < ys.len() < MUL_TOOM22_THRESHOLD < MUL_BASECASE_MAX_UN < xs.len().\nfn limbs_mul_greater_to_out_basecase_mem_opt_helper(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(ys_len > 1);\n    assert!(ys_len < MUL_TOOM22_THRESHOLD);\n    assert!(MUL_TOOM22_THRESHOLD < MUL_BASECASE_MAX_UN);\n    assert!(xs_len > MUL_BASECASE_MAX_UN);\n    let mut triangle_buffer = [0; MUL_TOOM22_THRESHOLD];\n    let mut offset = 0;\n    for chunk in xs.chunks(MUL_BASECASE_MAX_UN) {\n        let out = &mut out[offset..];\n        if chunk.len() >= ys_len {\n            limbs_mul_greater_to_out_basecase(out, chunk, ys);\n        } else {\n            limbs_mul_greater_to_out_basecase(out, ys, chunk);\n        }\n        if offset != 0 {\n            limbs_slice_add_greater_in_place_left(out, &triangle_buffer[..ys_len]);\n        }\n        offset += MUL_BASECASE_MAX_UN;\n        if offset < xs_len {\n            triangle_buffer[..ys_len]\n                .copy_from_slice(&out[MUL_BASECASE_MAX_UN..MUL_BASECASE_MAX_UN + ys_len]);\n        }\n    }\n}\n\n/// A version of `limbs_mul_greater_to_out_basecase` that attempts to be more efficient by\n/// increasing cache locality. It is currently not measurably better than ordinary basecase.\npub fn limbs_mul_greater_to_out_basecase_mem_opt(out: &mut [Limb], xs: &[Limb], ys: &[Limb]) {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    if ys_len > 1 && ys_len < MUL_TOOM22_THRESHOLD && xs.len() > MUL_BASECASE_MAX_UN {\n        limbs_mul_greater_to_out_basecase_mem_opt_helper(out, xs, ys);\n    } else {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    }\n}\n\npub fn limbs_product_naive(out: &mut [Limb], factors: &[Limb]) -> usize {\n    let mut n = Natural::ONE;\n    for &f in factors {\n        n *= Natural::from(f);\n    }\n    let xs = n.into_limbs_asc();\n    let size = xs.len();\n    out[..size].copy_from_slice(&xs);\n    size\n}\n\npub fn natural_product_naive<I: Iterator<Item = Natural>>(xs: I) -> Natural {\n    let mut p = Natural::ONE;\n    for x in xs {\n        if x == 0 {\n            return Natural::ZERO;\n        }\n        p *= x;\n    }\n    p\n}\n\nimpl CRTData {\n    // This is crt_data_init from fft_small.h, FLINT 3.3.0-dev, returning CRTData.\n    fn new(prime: u64, coeff_len: usize, nprimes: usize) -> Self {\n        Self {\n            prime,\n            coeff_len,\n            nprimes,\n            data: vec![0; nprimes * coeff_len + coeff_len + nprimes],\n        }\n    }\n\n    // This is crt_data_co_prime_red from fft_small.h, FLINT 3.3.0-dev, writing a value.\n    #[inline]\n    fn co_prime_red_write(&mut self, i: usize, val: u64) {\n        assert!(i < self.nprimes);\n        self.data[self.nprimes * self.coeff_len + self.coeff_len + i] = val;\n    }\n\n    // This is crt_data_co_prime from fft_small.h, FLINT 3.3.0-dev, writing a value.\n    #[inline]\n    fn co_prime_write(&mut self, i: usize, val: u64) {\n        assert!(i < self.nprimes);\n        self.data[i * self.coeff_len] = val;\n    }\n\n    // return mpn of length C->coeff_len\n    //\n    // This is crt_data_prod_primes from fft_small.h, FLINT 3.3.0-dev.\n    #[inline]\n    fn prod_primes(&mut self) -> &mut [u64] {\n        &mut self.data[self.nprimes * self.coeff_len..]\n    }\n\n    fn serialize(self) -> SerializedCRTData {\n        SerializedCRTData {\n            prime: self.prime,\n            coeff_len: self.coeff_len,\n            nprimes: self.nprimes,\n        }\n    }\n}\n\nconst D_BITS: i32 = 53;\n\n// This is fft_small_mulmod_satisfies_bounds from fft_small/mulmod_statisfies_bounds.c, FLINT\n// 3.3.0-dev.\nfn fft_small_mulmod_satisfies_bounds(nn: u64) -> bool {\n    let n = nn as f64;\n    let ninv = 1.0 / n;\n    let t1 = n.mul_add(ninv, -1.0).abs(); // epsilon ~= t1 / n  good enough\n    let n1bits = i32::exact_from(nn.significant_bits());\n    let n2hi = u64::x_mul_y_to_zz(nn, nn).0;\n    assert_ne!(n2hi, 0);\n    let n2bits = i32::exact_from(u64::WIDTH + n2hi.significant_bits());\n    // for |a*b| < 2*n^2\n    //\n    // |h*n_inv| < 2*n, so rounding in mul(h, ninv) at least B bits after the .\n    let b = D_BITS - n1bits - 1;\n    assert!(b >= 2);\n    let diff = n2bits - D_BITS;\n    let p = 2.0 * n * t1;\n    let limit2 = p + scalbn(ninv, diff) + 0.5 + scalbn(1.0, -b - 1);\n    // for |a * b| < 4 * n ^ 2\n    let limit4 = 2.0 * p + scalbn(ninv, diff + 1) + 0.5 + scalbn(1.0, -b);\n    // fudge the limits 1 and 3/2 because the above is double arithmetic\n    limit2 < 0.99 && limit4 < 1.49\n}\n\n// This is nmod_init from nmod.h, FLINT 3.3.0-dev, but returning `mod`.\nfn nmod_init(n: u64) -> ModData {\n    let norm = LeadingZeros::leading_zeros(n);\n    let shifted = n << norm;\n    let ninv = u64::xx_div_mod_y_to_qr(!shifted, u64::MAX, shifted).0;\n    ModData { n, ninv, norm }\n}\n\n// This is next_fft_number from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn next_fft_number(p: u64) -> u64 {\n    let bits = p.significant_bits();\n    let l = TrailingZeros::trailing_zeros(p - 1);\n    let q = p - u64::power_of_2(l + 1);\n    if bits < 15 {\n        panic!();\n    } else if q.significant_bits() == bits {\n        q\n    } else {\n        assert!(l >= 5);\n        u64::power_of_2(bits) - u64::power_of_2(l - 1) + 1\n    }\n}\n\n// This is sd_fft_ctx_init_prime from fft_small/sd_fft_ctx.c, FLINT 3.3.0-dev, returning q.\nfn sd_fft_ctx_init_prime(pp: u64) -> FFTContext {\n    assert!(\n        fft_small_mulmod_satisfies_bounds(pp),\n        \"FFT prime {pp} does not satisfy bounds for arithmetic\"\n    );\n    let mut q = FFTContext::default();\n    q.p = pp as f64;\n    q.pinv = 1.0 / q.p;\n    q.mod_data = nmod_init(pp);\n    q.primitive_root = pp.primitive_root_prime();\n    let n = q.p;\n    let ninv = q.pinv;\n    //  fill wtab to a depth of SD_FFT_CTX_W2TAB_INIT: 2 ^ (SD_FFT_CTX_W2TAB_INIT - 1) entries: 1,\n    //  e(1 / 4), e(1 / 8), e(3 / 8), ...\n    //\n    //  Q->w2tab[j] is itself a table of length 2 ^ (j - 1) containing 2 ^ (j + 1) st roots of\n    //  unity.\n    q.w2tab_backing = vec![0.0; 1 << 12];\n    q.w2tab_backing[0] = 1.0;\n    let mut l = 1;\n    for k in 1..SD_FFT_CTX_W2TAB_INIT {\n        let w = f64_reduce_0n_to_pmhn!(\n            q.primitive_root\n                .mod_pow((q.mod_data.n - 1) >> (k + 1), q.mod_data.n) as f64,\n            n\n        );\n        q.w2tab_offsets[k as usize] = l;\n        let (w_lo, w_hi) = q.w2tab_backing.split_at_mut(l);\n        for (hi, &lo) in w_hi.iter_mut().zip(w_lo.iter()) {\n            *hi = f64_reduce_pm1n_to_pmhn!(f64_mulmod!(lo, w, n, ninv), n);\n        }\n        l <<= 1;\n    }\n    q.w2tab_depth = SD_FFT_CTX_W2TAB_INIT;\n    q\n}\n\n// fill x[i] = 2 ^ i mod p for 0 <= i < len\n//\n// This is fill_slow_two_pow_tab from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn fill_slow_two_pow_tab(xs: &mut [f64], p: f64, pinv: f64) {\n    let mut t = 1.0;\n    let (xs_head, xs_tail) = xs.split_first_mut().unwrap();\n    *xs_head = t;\n    for x in xs_tail {\n        let q = (t * (2.0 * pinv)).round_ties_even();\n        t = fma!(-q, p, t + t);\n        *x = t;\n    }\n}\n\n// fill in  d[i * nvs + k / VEC_SZ][k % VEC_SZ] = 2 ^ i mod Rffts[k].p for 0 <= k < VEC_SZ * nvs and\n// 0 <= i < len.\n//\n// This is fill_vec_two_pow_tab from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn fill_vec_two_pow_tab(xs: &mut [f64x4], rffts: &mut [FFTContext], len: usize, nvs: usize) {\n    let mut ps = vec![f64x4::ZERO; nvs << 1];\n    for l in 0..nvs {\n        let r = &rffts[l << 2..];\n        let p = &mut ps[l << 1..];\n        p[0] = f64x4::new([r[0].p, r[1].p, r[2].p, r[3].p]);\n        p[1] = f64x4::new([r[0].pinv, r[1].pinv, r[2].pinv, r[3].pinv]) * f64x4::splat(2.0);\n    }\n    for x in xs.iter_mut().take(nvs) {\n        *x = f64x4::ONE;\n    }\n    let mut k = 0;\n    for _ in 1..len {\n        for l in 0..nvs {\n            let xs = &mut xs[k + l..];\n            let t = xs[0];\n            let p = &ps[l << 1..];\n            xs[nvs] = f64x4_mul_add!(-(t * p[1]).round(), p[0], t * f64x4::splat(2.0));\n        }\n        k += nvs;\n    }\n}\n\n// TODO make macro\n//\n// This is PUSH_PROFILE from fft_small/mpn_mul.c, FLINT 3.3.0-dev.\nfn push_profile(r: &mut Context, np: usize, bits: u64) {\n    let i = r.profiles_size;\n    r.profiles[i].np = np;\n    r.profiles[i].bits = bits;\n    r.profiles[i].bn_bound = crt_data_find_bn_bound(&r.crts[np - 1], bits);\n    r.profiles[i].to_ffts = Some(MPNToFFTFunc { np, bits });\n    r.profiles_size = i + 1;\n}\n\nconst DEFAULT_PRIME: u64 = 0x0003f00000000001;\n\n// This is mpn_ctx_init from fft_small/mpn_mul.c, FLINT 3.3.0-dev, returning the context.\npub fn initialize_context() -> Context {\n    let mut p = DEFAULT_PRIME;\n    let mut r = Context::default();\n    for i in 0..MPN_CTX_NCRTS {\n        if i > 0 {\n            p = next_fft_number(p);\n        }\n        while !p.is_prime() {\n            p = next_fft_number(p);\n        }\n        r.ffts[i] = sd_fft_ctx_init_prime(p);\n        if i == 0 {\n            r.crts[0] = CRTData::new(p, 1, 1);\n            r.crts[0].co_prime_red_write(0, 1);\n            r.crts[0].co_prime_write(0, 1);\n            r.crts[0].prod_primes()[0] = p;\n        } else {\n            let mut len = r.crts[i - 1].coeff_len;\n            let mut t = vec![0; (len + 2) << 1];\n            let (t, tt) = t.split_at_mut(len + 2);\n            t[len + 1] = 0;\n            t[len] = limbs_mul_limb_to_out::<u128, u64>(t, &r.crts[i - 1].prod_primes()[..len], p);\n            // leave enough room for (product of primes)*(number of primes)\n            len += 2;\n            limbs_mul_limb_to_out::<u128, u64>(tt, &t[..len], u64::wrapping_from(i) + 1);\n            while tt[len - 1] == 0 {\n                len -= 1;\n            }\n            r.crts[i] = CRTData::new(p, len, i + 1);\n            // set product of primes\n            r.crts[i].prod_primes()[..len].copy_from_slice(&t[..len]);\n            // set cofactors\n            for pi in 0..=i {\n                let prime = r.crts[pi].prime;\n                let cofac = r.crts[i].co_prime(pi);\n                limbs_div_exact_limb_to_out::<u128, u64>(cofac, &t[..len], prime);\n                let d = limbs_mod_limb::<u128, u64>(&cofac[..len], prime);\n                r.crts[i].co_prime_red_write(pi, d);\n            }\n        }\n    }\n    // powers of two for slow mod\n    {\n        let len = MPN_CTX_TWO_POWER_TAB_SIZE;\n        let x = vec![0.0; len * MPN_CTX_NCRTS];\n        r.slow_two_pow_backing = x;\n        let mut offset = 0;\n        for i in 0..MPN_CTX_NCRTS {\n            r.slow_two_pow_offsets[i] = offset;\n            fill_slow_two_pow_tab(\n                &mut r.slow_two_pow_backing[offset..offset + len],\n                r.ffts[i].p,\n                r.ffts[i].pinv,\n            );\n            offset += len;\n        }\n    }\n    // powers of two for fast mod\n    {\n        let len = MPN_CTX_TWO_POWER_TAB_SIZE;\n        let max_nvs = MPN_CTX_NCRTS.div_round(VEC_SZ, Ceiling).0;\n        let x = vec![f64x4::ZERO; max_nvs * (max_nvs + 1) / 2 * len];\n        r.vec_two_pow_tab_backing = x;\n        let mut offset = 0;\n        for nvs in 1..=max_nvs {\n            r.vec_two_pow_tab_offsets[nvs - 1] = offset;\n            fill_vec_two_pow_tab(\n                &mut r.vec_two_pow_tab_backing[offset..],\n                &mut r.ffts,\n                len,\n                nvs,\n            );\n            offset += nvs * len;\n        }\n    }\n    r.profiles_size = 0;\n    push_profile(&mut r, 4, 84);\n    push_profile(&mut r, 4, 88);\n    push_profile(&mut r, 4, 92);\n    push_profile(&mut r, 5, 112);\n    push_profile(&mut r, 5, 116);\n    push_profile(&mut r, 5, 120);\n    push_profile(&mut r, 6, 136);\n    push_profile(&mut r, 6, 140);\n    push_profile(&mut r, 6, 144);\n    push_profile(&mut r, 7, 160);\n    push_profile(&mut r, 7, 164);\n    push_profile(&mut r, 7, 168);\n    push_profile(&mut r, 8, 184);\n    push_profile(&mut r, 8, 188);\n    push_profile(&mut r, 8, 192);\n    assert!(r.profiles_size <= MAX_NPROFILES);\n    r\n}\n\nimpl FFTContext {\n    fn serialize(self) -> SerializedFFTContext {\n        let mut w2tab_backing = [0; 4096];\n        for (o, x) in w2tab_backing.iter_mut().zip(self.w2tab_backing.into_iter()) {\n            *o = x.to_bits();\n        }\n        SerializedFFTContext {\n            p: self.p.to_bits(),\n            pinv: self.pinv.to_bits(),\n            mod_data: self.mod_data,\n            primitive_root: self.primitive_root,\n            w2tab_depth: self.w2tab_depth,\n            w2tab_backing,\n            w2tab_offsets: self.w2tab_offsets,\n        }\n    }\n}\n\nimpl Context {\n    pub_crate_test! {serialize(self) -> SerializedContext {\n        let mut crts_data_0 = [0; 3];\n        let mut crts_data_1 = [0; 8];\n        let mut crts_data_2 = [0; 15];\n        let mut crts_data_3 = [0; 24];\n        let mut crts_data_4 = [0; 29];\n        let mut crts_data_5 = [0; 41];\n        let mut crts_data_6 = [0; 55];\n        let mut crts_data_7 = [0; 71];\n        crts_data_0.copy_from_slice(&self.crts[0].data);\n        crts_data_1.copy_from_slice(&self.crts[1].data);\n        crts_data_2.copy_from_slice(&self.crts[2].data);\n        crts_data_3.copy_from_slice(&self.crts[3].data);\n        crts_data_4.copy_from_slice(&self.crts[4].data);\n        crts_data_5.copy_from_slice(&self.crts[5].data);\n        crts_data_6.copy_from_slice(&self.crts[6].data);\n        crts_data_7.copy_from_slice(&self.crts[7].data);\n        let mut vec_two_pow_tab_backing = [[0; 4]; 768];\n        for (o, f) in vec_two_pow_tab_backing\n            .iter_mut()\n            .zip(self.vec_two_pow_tab_backing.into_iter())\n        {\n            let [f0, f1, f2, f3] = f.to_array();\n            *o = [f0.to_bits(), f1.to_bits(), f2.to_bits(), f3.to_bits()];\n        }\n        let mut slow_two_pow_backing = [0; 1 << 11];\n        for (o, x) in slow_two_pow_backing\n            .iter_mut()\n            .zip(self.slow_two_pow_backing.into_iter())\n        {\n            *o = x.to_bits();\n        }\n        let [f0, f1, f2, f3, f4, f5, f6, f7] = self.ffts;\n        let [c0, c1, c2, c3, c4, c5, c6, c7] = self.crts;\n        SerializedContext {\n            ffts: [\n                f0.serialize(),\n                f1.serialize(),\n                f2.serialize(),\n                f3.serialize(),\n                f4.serialize(),\n                f5.serialize(),\n                f6.serialize(),\n                f7.serialize(),\n            ],\n            crts: [\n                c0.serialize(),\n                c1.serialize(),\n                c2.serialize(),\n                c3.serialize(),\n                c4.serialize(),\n                c5.serialize(),\n                c6.serialize(),\n                c7.serialize(),\n            ],\n            crts_data_0,\n            crts_data_1,\n            crts_data_2,\n            crts_data_3,\n            crts_data_4,\n            crts_data_5,\n            crts_data_6,\n            crts_data_7,\n            vec_two_pow_tab_backing,\n            vec_two_pow_tab_offsets: self.vec_two_pow_tab_offsets,\n            slow_two_pow_backing,\n            slow_two_pow_offsets: self.slow_two_pow_offsets,\n            profiles: self.profiles,\n            profiles_size: self.profiles_size,\n            buffer_alloc: self.buffer_alloc,\n        }\n    }}\n}\n\nfn limbs_mul_same_length_to_out_slow(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) {\n    let len = xs.len();\n    assert_eq!(ys.len(), len);\n    assert_ne!(len, 0);\n    if len < MUL_TOOM22_THRESHOLD {\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if len < MUL_TOOM33_THRESHOLD {\n        limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n    } else if len < MUL_TOOM44_THRESHOLD {\n        limbs_mul_greater_to_out_toom_33(out, xs, ys, scratch);\n    } else if len < MUL_TOOM6H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_44(out, xs, ys, scratch);\n    } else if len < MUL_TOOM8H_THRESHOLD {\n        limbs_mul_greater_to_out_toom_6h(out, xs, ys, scratch);\n    } else if len < FFT_MUL_THRESHOLD {\n        limbs_mul_greater_to_out_toom_8h(out, xs, ys, scratch);\n    } else {\n        mpn_mul_default_mpn_ctx(out, xs, ys, true);\n    }\n}\n\nfn limbs_mul_greater_to_out_old_slow(\n    out: &mut [Limb],\n    xs: &[Limb],\n    ys: &[Limb],\n    scratch: &mut [Limb],\n) -> Limb {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    assert!(xs_len >= ys_len);\n    assert_ne!(ys_len, 0);\n    assert!(out.len() >= xs_len + ys_len);\n    if ys_len < MUL_TOOM22_THRESHOLD {\n        // Plain schoolbook multiplication. Unless xs_len is very large, or else if\n        // `limbs_mul_same_length_to_out` applies, perform basecase multiply directly.\n        limbs_mul_greater_to_out_basecase(out, xs, ys);\n    } else if ys_len < MUL_TOOM33_THRESHOLD {\n        if xs_len >= 3 * ys_len {\n            let two_ys_len = ys_len << 1;\n            let three_ys_len = two_ys_len + ys_len;\n            let four_ys_len = two_ys_len << 1;\n            let (scratch, mul_scratch) = scratch.split_at_mut(four_ys_len);\n            limbs_mul_greater_to_out_toom_42(out, &xs[..two_ys_len], ys, mul_scratch);\n            let mut xs = &xs[two_ys_len..];\n            let mut out_offset = two_ys_len;\n            while xs.len() >= three_ys_len {\n                let out = &mut out[out_offset..];\n                let (xs_lo, xs_hi) = xs.split_at(two_ys_len);\n                limbs_mul_greater_to_out_toom_42(scratch, xs_lo, ys, mul_scratch);\n                let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n                out[ys_len..three_ys_len].copy_from_slice(&scratch_hi[..two_ys_len]);\n                assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n                xs = xs_hi;\n                out_offset += two_ys_len;\n            }\n            let xs_len = xs.len();\n            let out = &mut out[out_offset..];\n            // ys_len <= xs_len < 3 * ys_len\n            let four_xs_len = xs_len << 2;\n            if four_xs_len < 5 * ys_len {\n                limbs_mul_greater_to_out_toom_22(scratch, xs, ys, mul_scratch);\n            } else if four_xs_len < 7 * ys_len {\n                limbs_mul_greater_to_out_toom_32(scratch, xs, ys, mul_scratch);\n            } else {\n                limbs_mul_greater_to_out_toom_42(scratch, xs, ys, mul_scratch);\n            }\n            let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n            out[ys_len..ys_len + xs_len].copy_from_slice(&scratch_hi[..xs_len]);\n            assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n        } else if 4 * xs_len < 5 * ys_len {\n            limbs_mul_greater_to_out_toom_22(out, xs, ys, scratch);\n        } else if 4 * xs_len < 7 * ys_len {\n            limbs_mul_greater_to_out_toom_32(out, xs, ys, scratch);\n        } else {\n            limbs_mul_greater_to_out_toom_42(out, xs, ys, scratch);\n        }\n    } else if (xs_len + ys_len) >> 1 < MUL_FFT_THRESHOLD || 3 * ys_len < MUL_FFT_THRESHOLD {\n        // Handle the largest operands that are not in the FFT range. The 2nd condition makes very\n        // unbalanced operands avoid the FFT code (except perhaps as coefficient products of the\n        // Toom code).\n        if ys_len < MUL_TOOM44_THRESHOLD || !toom44_ok(xs_len, ys_len) {\n            // Use ToomX3 variants\n            if xs_len << 1 >= 5 * ys_len {\n                let two_ys_len = ys_len << 1;\n                let four_ys_len = two_ys_len << 1;\n                let (scratch, mul_scratch) = scratch.split_at_mut(four_ys_len);\n                let (xs_lo, mut xs) = xs.split_at(two_ys_len);\n                if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_42(out, xs_lo, ys, mul_scratch);\n                } else {\n                    limbs_mul_greater_to_out_toom_63(out, xs_lo, ys, mul_scratch);\n                }\n                let mut out_offset = two_ys_len;\n                // xs_len >= 2.5 * ys_len\n                while xs.len() << 1 >= 5 * ys_len {\n                    let out = &mut out[out_offset..];\n                    let (xs_lo, xs_hi) = xs.split_at(two_ys_len);\n                    if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                        limbs_mul_greater_to_out_toom_42(scratch, xs_lo, ys, mul_scratch);\n                    } else {\n                        limbs_mul_greater_to_out_toom_63(scratch, xs_lo, ys, mul_scratch);\n                    }\n                    let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n                    out[ys_len..ys_len + two_ys_len].copy_from_slice(&scratch_hi[..two_ys_len]);\n                    assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n                    xs = xs_hi;\n                    out_offset += two_ys_len;\n                }\n                let xs_len = xs.len();\n                let out = &mut out[out_offset..];\n                // ys_len / 2 <= xs_len < 2.5 * ys_len\n                limbs_mul_to_out_slow(scratch, xs, ys, mul_scratch);\n                let (scratch_lo, scratch_hi) = scratch.split_at(ys_len);\n                out[ys_len..xs_len + ys_len].copy_from_slice(&scratch_hi[..xs_len]);\n                assert!(!limbs_slice_add_greater_in_place_left(out, scratch_lo));\n            } else if 6 * xs_len < 7 * ys_len {\n                limbs_mul_greater_to_out_toom_33(out, xs, ys, scratch);\n            } else if xs_len << 1 < 3 * ys_len {\n                if ys_len < MUL_TOOM32_TO_TOOM43_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_32(out, xs, ys, scratch);\n                } else {\n                    limbs_mul_greater_to_out_toom_43(out, xs, ys, scratch);\n                }\n            } else if 6 * xs_len < 11 * ys_len {\n                if xs_len << 2 < 7 * ys_len {\n                    if ys_len < MUL_TOOM32_TO_TOOM53_THRESHOLD {\n                        limbs_mul_greater_to_out_toom_32(out, xs, ys, scratch);\n                    } else {\n                        limbs_mul_greater_to_out_toom_53(out, xs, ys, scratch);\n                    }\n                } else if ys_len < MUL_TOOM42_TO_TOOM53_THRESHOLD {\n                    limbs_mul_greater_to_out_toom_42(out, xs, ys, scratch);\n                } else {\n                    limbs_mul_greater_to_out_toom_53(out, xs, ys, scratch);\n                }\n            } else if ys_len < MUL_TOOM42_TO_TOOM63_THRESHOLD {\n                limbs_mul_greater_to_out_toom_42(out, xs, ys, scratch);\n            } else {\n                limbs_mul_greater_to_out_toom_63(out, xs, ys, scratch);\n            }\n        } else if ys_len < MUL_TOOM6H_THRESHOLD {\n            limbs_mul_greater_to_out_toom_44(out, xs, ys, scratch);\n        } else if ys_len < MUL_TOOM8H_THRESHOLD {\n            limbs_mul_greater_to_out_toom_6h(out, xs, ys, scratch);\n        } else {\n            limbs_mul_greater_to_out_toom_8h(out, xs, ys, scratch);\n        }\n    } else {\n        mpn_mul_default_mpn_ctx(out, xs, ys, true);\n    }\n    out[xs_len + ys_len - 1]\n}\n\nfn limbs_mul_greater_to_out_slow(\n    r: &mut [Limb],\n    x: &[Limb],\n    y: &[Limb],\n    scratch: &mut [Limb],\n) -> Limb {\n    let xs_len = x.len();\n    let ys_len = y.len();\n    assert!(xs_len >= ys_len);\n    if xs_len == ys_len {\n        limbs_mul_same_length_to_out_slow(r, x, y, scratch);\n    } else if ys_len < FFT_MUL_THRESHOLD {\n        let mut scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)];\n        limbs_mul_greater_to_out_old_slow(r, x, y, &mut scratch);\n    } else {\n        mpn_mul_default_mpn_ctx(r, x, y, true);\n    }\n    r[xs_len + ys_len - 1]\n}\n\nfn limbs_mul_greater_slow_fft(xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let xs_len = xs.len();\n    let ys_len = ys.len();\n    let out_len = xs_len + ys_len;\n    let mut scratch = vec![0; out_len + limbs_mul_greater_to_out_scratch_len(xs_len, ys_len)];\n    let (out, mul_scratch) = scratch.split_at_mut(out_len);\n    limbs_mul_greater_to_out_slow(out, xs, ys, mul_scratch);\n    scratch.truncate(out_len);\n    scratch.shrink_to_fit();\n    scratch\n}\n\nfn limbs_mul_to_out_slow(out: &mut [Limb], xs: &[Limb], ys: &[Limb], scratch: &mut [Limb]) -> Limb {\n    if xs.len() >= ys.len() {\n        limbs_mul_greater_to_out_slow(out, xs, ys, scratch)\n    } else {\n        limbs_mul_greater_to_out_slow(out, ys, xs, scratch)\n    }\n}\n\npub fn mul_slow_fft(x: &Natural, y: &Natural) -> Natural {\n    match (x, y) {\n        (Natural(Small(x)), y) => y.mul_limb_ref(*x),\n        (x, Natural(Small(y))) => x.mul_limb_ref(*y),\n        (Natural(Large(xs)), Natural(Large(ys))) => {\n            let big_limbs = if xs.len() >= ys.len() {\n                limbs_mul_greater_slow_fft(xs, ys)\n            } else {\n                limbs_mul_greater_slow_fft(ys, xs)\n            };\n            Natural::from_owned_limbs_asc(big_limbs)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::{BigInt, BigUint};\n\npub fn neg_num(u: BigUint) -> BigInt {\n    -BigInt::from(u)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::SquareAssign;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::logic::traits::BitIterable;\n\npub fn natural_pow_naive(n: &Natural, exp: u64) -> Natural {\n    let mut result = Natural::ONE;\n    for _ in 0..exp {\n        result *= n;\n    }\n    result\n}\n\npub fn natural_pow_simple_binary(n: &Natural, exp: u64) -> Natural {\n    let mut result = Natural::ONE;\n    for bit in exp.bits().rev() {\n        result.square_assign();\n        if bit {\n            result *= n;\n        }\n    }\n    result\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::factorization::traits::Primes;\n\npub fn primorial_naive(n: u64) -> Natural {\n    Natural::primes_less_than_or_equal_to(&Natural::from(n)).product()\n}\n\npub fn product_of_first_n_primes_naive(n: u64) -> Natural {\n    Natural::primes().take(usize::exact_from(n)).product()\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::test_util::natural::arithmetic::sqrt::floor_inverse_binary;\nuse malachite_base::num::arithmetic::traits::{DivRound, Pow, PowerOf2};\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\n\npub fn floor_root_binary(x: &Natural, exp: u64) -> Natural {\n    if exp == 0 {\n        panic!(\"Cannot take 0th root\");\n    } else if exp == 1 || x < &Natural::TWO {\n        x.clone()\n    } else {\n        let p = Natural::power_of_2(x.significant_bits().div_round(exp, Ceiling).0);\n        floor_inverse_binary(|x| x.pow(exp), x, &p >> 1, p)\n    }\n}\n\npub fn ceiling_root_binary(x: &Natural, exp: u64) -> Natural {\n    let floor_root = floor_root_binary(x, exp);\n    if &(&floor_root).pow(exp) == x {\n        floor_root\n    } else {\n        floor_root + Natural::ONE\n    }\n}\n\npub fn checked_root_binary(x: &Natural, exp: u64) -> Option<Natural> {\n    let floor_root = floor_root_binary(x, exp);\n    if &(&floor_root).pow(exp) == x {\n        Some(floor_root)\n    } else {\n        None\n    }\n}\n\npub fn root_rem_binary(x: &Natural, exp: u64) -> (Natural, Natural) {\n    let floor_root = floor_root_binary(x, exp);\n    let rem = x - (&floor_root).pow(exp);\n    (floor_root, rem)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::arithmetic::traits::{PowerOf2, ShrRound, Square};\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse std::cmp::Ordering::*;\n\npub(crate) fn floor_inverse_binary<F: Fn(&Natural) -> Natural>(\n    f: F,\n    x: &Natural,\n    mut low: Natural,\n    mut high: Natural,\n) -> Natural {\n    loop {\n        if high <= low {\n            return low;\n        }\n        let mid = (&low + &high).shr_round(1, Ceiling).0;\n        match f(&mid).cmp(x) {\n            Equal => return mid,\n            Less => low = mid,\n            Greater => high = mid - Natural::ONE,\n        }\n    }\n}\n\npub fn floor_sqrt_binary(x: &Natural) -> Natural {\n    if x < &Natural::TWO {\n        x.clone()\n    } else {\n        let p = Natural::power_of_2(x.significant_bits().shr_round(1, Ceiling).0);\n        floor_inverse_binary(|x| x.square(), x, &p >> 1, p)\n    }\n}\n\npub fn ceiling_sqrt_binary(x: &Natural) -> Natural {\n    let floor_sqrt = floor_sqrt_binary(x);\n    if &(&floor_sqrt).square() == x {\n        floor_sqrt\n    } else {\n        floor_sqrt + Natural::ONE\n    }\n}\n\npub fn checked_sqrt_binary(x: &Natural) -> Option<Natural> {\n    let floor_sqrt = floor_sqrt_binary(x);\n    if &(&floor_sqrt).square() == x {\n        Some(floor_sqrt)\n    } else {\n        None\n    }\n}\n\npub fn sqrt_rem_binary(x: &Natural) -> (Natural, Natural) {\n    let floor_sqrt = floor_sqrt_binary(x);\n    let rem = x - (&floor_sqrt).square();\n    (floor_sqrt, rem)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::add_mul::limbs_slice_add_mul_limb_same_length_in_place_left;\nuse crate::natural::arithmetic::mul::limb::limbs_mul_limb_to_out;\nuse crate::natural::arithmetic::square::limbs_square_diagonal_add_shl_1;\nuse crate::platform::{DoubleLimb, Limb};\nuse malachite_base::num::arithmetic::traits::Square;\nuse malachite_base::num::conversion::traits::SplitInHalf;\n\npub fn limbs_square_to_out_basecase_unrestricted(out: &mut [Limb], xs: &[Limb]) {\n    let n = xs.len();\n    let (xs_head, xs_tail) = xs.split_first().unwrap();\n    (out[1], out[0]) = DoubleLimb::from(*xs_head).square().split_in_half();\n    if n > 1 {\n        let two_n = n << 1;\n        let mut scratch = vec![0; two_n - 2];\n        let (scratch_last, scratch_init) = scratch[..n].split_last_mut().unwrap();\n        *scratch_last = limbs_mul_limb_to_out::<DoubleLimb, Limb>(scratch_init, xs_tail, *xs_head);\n        for i in 1..n - 1 {\n            let (scratch_last, scratch_init) = scratch[i..][i..n].split_last_mut().unwrap();\n            let (xs_head, xs_tail) = xs[i..].split_first().unwrap();\n            *scratch_last =\n                limbs_slice_add_mul_limb_same_length_in_place_left(scratch_init, xs_tail, *xs_head);\n        }\n        limbs_square_diagonal_add_shl_1(&mut out[..two_n], &mut scratch, xs);\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::arithmetic::sub::limbs_sub_same_length_in_place_left;\nuse crate::platform::Limb;\n\npub fn limbs_sub_same_length_in_place_with_overlap_naive(\n    xs: &mut [Limb],\n    right_start: usize,\n) -> bool {\n    let left_end = xs.len() - right_start;\n    let mut x = xs[..left_end].to_vec();\n    let borrow = limbs_sub_same_length_in_place_left(&mut x, &xs[right_start..]);\n    xs[..left_end].copy_from_slice(&x);\n    borrow\n}\n\n// Given two slices `xs` and `ys`, computes the difference between the `Natural`s whose limbs are\n// `&xs[xs.len() - ys.len()..]` and `&ys`, and writes the limbs of the result to `&xs[..ys.len()]`.\npub fn limbs_sub_same_length_to_out_with_overlap_naive(xs: &mut [Limb], ys: &[Limb]) -> bool {\n    let y_len = ys.len();\n    let mut x = xs[xs.len() - y_len..].to_vec();\n    let borrow = limbs_sub_same_length_in_place_left(&mut x, ys);\n    xs[..y_len].copy_from_slice(&x);\n    borrow\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse std::cmp::Ordering::{self, *};\n\npub fn natural_cmp_normalized_naive(x: &Natural, y: &Natural) -> Ordering {\n    let x_bits = x.significant_bits();\n    let y_bits = y.significant_bits();\n    match x_bits.cmp(&y_bits) {\n        Equal => x.cmp(y),\n        Less => (x << (y_bits - x_bits)).cmp(y),\n        Greater => x.cmp(&(y << (x_bits - y_bits))),\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod cmp;\npub mod partial_cmp_primitive_int;\npub mod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::BigUint;\nuse std::cmp::Ordering;\n\npub fn num_partial_cmp_unsigned<T>(x: &BigUint, u: T) -> Option<Ordering>\nwhere\n    BigUint: From<T>,\n{\n    x.partial_cmp(&BigUint::from(u))\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::BigUint;\n\npub fn num_partial_eq_unsigned<T>(x: &BigUint, u: T) -> bool\nwhere\n    BigUint: From<T>,\n{\n    *x == BigUint::from(u)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod string;\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::basic::traits::Zero;\n\npub fn from_string_base_naive(small_base: u8, s: &str) -> Option<Natural> {\n    let mut x = Natural::ZERO;\n    let base = Natural::from(small_base);\n    for c in s.chars() {\n        x *= &base;\n        x += Natural::from(c.to_digit(u32::from(small_base))?);\n    }\n    Some(x)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod from_string;\npub mod to_string;\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::conversion::string::to_string::digit_to_display_byte_lower;\nuse malachite_base::num::conversion::traits::WrappingFrom;\n\npub fn to_string_base_naive(x: &Natural, base: u8) -> String {\n    assert!((2..=36).contains(&base), \"base out of range\");\n    let base = Limb::from(base);\n    if *x == 0 {\n        \"0\".to_string()\n    } else {\n        let mut x = x.clone();\n        let mut cs = Vec::new();\n        while x != 0 {\n            cs.push(char::from(\n                digit_to_display_byte_lower(u8::wrapping_from(x.div_assign_mod_limb(base)))\n                    .unwrap(),\n            ));\n        }\n        cs.into_iter().rev().collect()\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::test_util::natural::logic::{natural_op_bits, natural_op_limbs};\n\npub fn natural_and_alt_1(x: &Natural, y: &Natural) -> Natural {\n    natural_op_bits(&|a, b| a && b, x, y)\n}\n\npub fn natural_and_alt_2(x: &Natural, y: &Natural) -> Natural {\n    natural_op_limbs(&|a, b| a & b, x, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitIterable, CountOnes};\n\npub fn natural_count_ones_alt_1(n: &Natural) -> u64 {\n    u64::exact_from(n.bits().filter(|&b| b).count())\n}\n\npub fn natural_count_ones_alt_2(n: &Natural) -> u64 {\n    n.limbs().map(CountOnes::count_ones).sum()\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\n\npub fn from_bits_asc_naive<I: Iterator<Item = bool>>(bits: I) -> Natural {\n    let mut n = Natural::ZERO;\n    for i in bits.enumerate().filter_map(|(index, bit)| {\n        if bit {\n            Some(u64::exact_from(index))\n        } else {\n            None\n        }\n    }) {\n        n.set_bit(i);\n    }\n    n\n}\n\npub fn from_bits_desc_naive<I: Iterator<Item = bool>>(bits: I) -> Natural {\n    let bits = bits.collect_vec();\n    let mut n = Natural::ZERO;\n    for i in bits.iter().rev().enumerate().filter_map(|(index, &bit)| {\n        if bit {\n            Some(u64::exact_from(index))\n        } else {\n            None\n        }\n    }) {\n        n.set_bit(i);\n    }\n    n\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/get_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse num::{BigUint, One, Zero};\n\npub fn num_get_bit(x: &BigUint, index: u64) -> bool {\n    x & (BigUint::one() << usize::exact_from(index)) != BigUint::zero()\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::logic::traits::{BitIterable, HammingDistance, SignificantBits};\nuse std::iter::repeat;\n\npub fn natural_hamming_distance_alt_1(x: &Natural, y: &Natural) -> u64 {\n    let bit_zip: Box<dyn Iterator<Item = (bool, bool)>> =\n        if x.significant_bits() >= y.significant_bits() {\n            Box::new(x.bits().zip(y.bits().chain(repeat(false))))\n        } else {\n            Box::new(x.bits().chain(repeat(false)).zip(y.bits()))\n        };\n    let mut distance = 0u64;\n    for (b, c) in bit_zip {\n        if b != c {\n            distance += 1;\n        }\n    }\n    distance\n}\n\npub fn natural_hamming_distance_alt_2(x: &Natural, y: &Natural) -> u64 {\n    let limb_zip: Box<dyn Iterator<Item = (Limb, Limb)>> = if x.limb_count() >= y.limb_count() {\n        Box::new(x.limbs().zip(y.limbs().chain(repeat(0))))\n    } else {\n        Box::new(x.limbs().chain(repeat(0)).zip(y.limbs()))\n    };\n    let mut distance = 0u64;\n    for (x, y) in limb_zip {\n        distance += x.hamming_distance(y);\n    }\n    distance\n}\n\npub fn rug_hamming_distance(x: &rug::Integer, y: &rug::Integer) -> u64 {\n    u64::from(x.hamming_dist(y).unwrap())\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::BitIterable;\nuse std::iter::repeat;\n\npub fn natural_index_of_next_false_bit_alt(n: &Natural, u: u64) -> Option<u64> {\n    for (i, bit) in n\n        .bits()\n        .chain(repeat(false))\n        .enumerate()\n        .skip(usize::exact_from(u))\n    {\n        if !bit {\n            return Some(u64::wrapping_from(i));\n        }\n    }\n    unreachable!();\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::BitIterable;\n\npub fn natural_index_of_next_true_bit_alt(n: &Natural, u: u64) -> Option<u64> {\n    for (i, bit) in n.bits().enumerate().skip(usize::exact_from(u)) {\n        if bit {\n            return Some(u64::wrapping_from(i));\n        }\n    }\n    None\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::platform::Limb;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable, SignificantBits};\nuse std::iter::repeat;\n\npub fn natural_op_bits(bit_fn: &dyn Fn(bool, bool) -> bool, x: &Natural, y: &Natural) -> Natural {\n    let bit_zip: Box<dyn Iterator<Item = (bool, bool)>> =\n        if x.significant_bits() >= y.significant_bits() {\n            Box::new(x.bits().zip(y.bits().chain(repeat(false))))\n        } else {\n            Box::new(x.bits().chain(repeat(false)).zip(y.bits()))\n        };\n    Natural::from_bits_asc(bit_zip.map(|(b, c)| bit_fn(b, c)))\n}\n\npub fn natural_op_limbs(limb_fn: &dyn Fn(Limb, Limb) -> Limb, x: &Natural, y: &Natural) -> Natural {\n    let limb_zip: Box<dyn Iterator<Item = (Limb, Limb)>> = if x.limb_count() >= y.limb_count() {\n        Box::new(x.limbs().zip(y.limbs().chain(repeat(0))))\n    } else {\n        Box::new(x.limbs().chain(repeat(0)).zip(y.limbs()))\n    };\n    let mut and_limbs = Vec::new();\n    for (x, y) in limb_zip {\n        and_limbs.push(limb_fn(x, y));\n    }\n    Natural::from_owned_limbs_asc(and_limbs)\n}\n\npub mod and;\npub mod count_ones;\npub mod from_bits;\npub mod get_bit;\npub mod hamming_distance;\npub mod index_of_next_false_bit;\npub mod index_of_next_true_bit;\npub mod or;\npub mod set_bit;\npub mod to_bits;\npub mod trailing_zeros;\npub mod xor;\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::test_util::natural::logic::{natural_op_bits, natural_op_limbs};\n\npub fn natural_or_alt_1(x: &Natural, y: &Natural) -> Natural {\n    natural_op_bits(&|a, b| a || b, x, y)\n}\n\npub fn natural_or_alt_2(x: &Natural, y: &Natural) -> Natural {\n    natural_op_limbs(&|a, b| a | b, x, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/set_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse num::{BigUint, One};\n\npub fn num_set_bit(x: &mut BigUint, index: u64) {\n    *x = x.clone() | (BigUint::one() << usize::exact_from(index));\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\n\npub fn to_bits_asc_naive(n: &Natural) -> Vec<bool> {\n    let mut bits = Vec::new();\n    for i in 0..n.significant_bits() {\n        bits.push(n.get_bit(i));\n    }\n    bits\n}\n\npub fn to_bits_desc_naive(n: &Natural) -> Vec<bool> {\n    let mut bits = Vec::new();\n    for i in (0..n.significant_bits()).rev() {\n        bits.push(n.get_bit(i));\n    }\n    bits\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::BitIterable;\n\npub fn natural_trailing_zeros_alt(n: &Natural) -> Option<u64> {\n    if *n == 0 {\n        None\n    } else {\n        Some(u64::wrapping_from(n.bits().take_while(|&b| !b).count()))\n    }\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::natural::Natural;\nuse crate::test_util::natural::logic::{natural_op_bits, natural_op_limbs};\n\npub fn natural_xor_alt_1(x: &Natural, y: &Natural) -> Natural {\n    natural_op_bits(&|a, b| a ^ b, x, y)\n}\n\npub fn natural_xor_alt_2(x: &Natural, y: &Natural) -> Natural {\n    natural_op_limbs(&|a, b| a ^ b, x, y)\n}\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod arithmetic;\npub mod comparison;\npub mod conversion;\npub mod logic;\npub mod random;\n"
  },
  {
    "path": "malachite-nz/src/test_util/natural/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::itertools::Itertools;\nuse crate::natural::Natural;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{MomentStats, moment_stats};\n\npub fn random_naturals_helper_helper<I: Clone + Iterator<Item = Natural>>(\n    xs: I,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let actual_values = xs\n        .clone()\n        .map(|x| Natural::to_string(&x))\n        .take(20)\n        .collect_vec();\n    let actual_values = actual_values.iter().map(String::as_str).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(x, freq)| (x.to_string(), freq))\n        .collect_vec();\n    let actual_common_values = actual_common_values\n        .iter()\n        .map(|(x, freq)| (x.as_str(), *freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.clone().take(1000000));\n    let (median_lo, median_hi) = (\n        median_lo.to_string(),\n        median_hi.map(|x| Natural::to_string(&x)),\n    );\n    let actual_sample_median = (median_lo.as_str(), median_hi.as_deref());\n    let actual_sample_moment_stats =\n        moment_stats(xs.take(1000000).map(|x| f64::rounding_from(&x, Nearest).0));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign, DivAssignMod, UnsignedAbs};\nuse malachite_base::num::basic::traits::Two;\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{SignedDoubleLimb, SignedLimb};\nuse malachite_nz::test_util::generators::{integer_gen, integer_integer_natural_triple_gen};\nuse num::{BigInt, Signed};\nuse std::str::FromStr;\n\n#[test]\nfn test_abs() {\n    let test = |s, out| {\n        let n = Integer::from_str(s).unwrap();\n\n        let abs = n.clone().abs();\n        assert!(abs.is_valid());\n        assert_eq!(abs.to_string(), out);\n\n        let abs = (&n).abs();\n        assert!(abs.is_valid());\n        assert_eq!(abs.to_string(), out);\n\n        assert_eq!(BigInt::from_str(s).unwrap().abs().to_string(), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().abs().to_string(), out);\n\n        let abs = n.clone().unsigned_abs();\n        assert!(abs.is_valid());\n        assert_eq!(abs.to_string(), out);\n\n        let abs = (&n).unsigned_abs();\n        assert!(abs.is_valid());\n        assert_eq!(abs.to_string(), out);\n\n        let x = n.clone();\n        let abs = x.unsigned_abs_ref();\n        assert!(abs.is_valid());\n        assert_eq!(abs.to_string(), out);\n\n        let mut x = n;\n        x.abs_assign();\n        assert!(abs.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"123\");\n    test(\"-123\", \"123\");\n    test(\"1000000000000\", \"1000000000000\");\n    test(\"-1000000000000\", \"1000000000000\");\n    test(\"3000000000\", \"3000000000\");\n    test(\"-3000000000\", \"3000000000\");\n    test(\"-2147483648\", \"2147483648\");\n\n    let mut n = Integer::from(-123);\n    let remainder = n.mutate_unsigned_abs(|x| x.div_assign_mod(Natural::TWO));\n    assert_eq!(n, -61);\n    assert_eq!(remainder, 1);\n\n    let mut n = Integer::from(-123);\n    n.mutate_unsigned_abs(|x| *x >>= 10);\n    assert_eq!(n, 0);\n}\n\n#[test]\nfn abs_properties() {\n    integer_gen().test_properties(|x| {\n        let abs = x.clone().abs();\n        assert!(abs.is_valid());\n\n        assert_eq!(Integer::from(&BigInt::from(&x).abs()), abs);\n\n        assert_eq!(Integer::from(&rug::Integer::from(&x).abs()), abs);\n\n        let abs_alt = (&x).abs();\n        assert!(abs_alt.is_valid());\n        assert_eq!(abs_alt, abs);\n\n        let mut abs_alt = x.clone();\n        abs_alt.abs_assign();\n        assert!(abs_alt.is_valid());\n        assert_eq!(abs_alt, abs);\n\n        assert!(abs >= 0);\n        assert_eq!(abs == x, x >= 0);\n        assert_eq!((&abs).abs(), abs);\n\n        let abs_alt = x.clone().unsigned_abs();\n        assert!(abs_alt.is_valid());\n        assert_eq!(Ok(abs_alt), (&abs).try_into());\n\n        let abs_alt = (&x).unsigned_abs();\n        assert!(abs_alt.is_valid());\n        assert_eq!(Ok(&abs_alt), abs.try_into().as_ref());\n\n        let internal_abs = x.unsigned_abs_ref();\n        assert!(internal_abs.is_valid());\n        assert_eq!(*internal_abs, abs_alt);\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(\n            Integer::from(i).abs(),\n            Integer::from(SignedDoubleLimb::from(i).abs())\n        );\n    });\n}\n\n#[test]\nfn mutate_unsigned_abs_properties() {\n    integer_integer_natural_triple_gen().test_properties(|(mut n, out, new_abs)| {\n        let out_2 = out.clone();\n        let new_abs_2 = new_abs.clone();\n        assert_eq!(\n            n.mutate_unsigned_abs(|x| {\n                *x = new_abs;\n                out\n            }),\n            out_2\n        );\n        assert!(n.is_valid());\n        assert_eq!(n.abs(), new_abs_2);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsDiff, AbsDiffAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen, integer_triple_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_abs_diff_integer() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.abs_diff_assign(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.abs_diff_assign(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().abs_diff(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().abs_diff(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).abs_diff(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).abs_diff(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"456\", \"123\", \"333\");\n    test(\"1000000000000\", \"123\", \"999999999877\");\n    test(\"123\", \"1000000000000\", \"999999999877\");\n    test(\"12345678987654321\", \"314159265358979\", \"12031519722295342\");\n    test(\"4294967296\", \"1\", \"4294967295\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"4294967296\", \"4294967295\", \"1\");\n    test(\"4294967296\", \"4294967296\", \"0\");\n    test(\"4294967295\", \"4294967296\", \"1\");\n    test(\"18446744073709551616\", \"1\", \"18446744073709551615\");\n    test(\"18446744073709551615\", \"18446744073709551615\", \"0\");\n    test(\"18446744073709551616\", \"18446744073709551615\", \"1\");\n    test(\"18446744073709551615\", \"18446744073709551616\", \"1\");\n    test(\"70734740290631708\", \"282942734368\", \"70734457347897340\");\n    test(\"282942734368\", \"70734740290631708\", \"70734457347897340\");\n\n    test(\"0\", \"-123\", \"123\");\n    test(\"456\", \"-123\", \"579\");\n    test(\"1000000000000\", \"-123\", \"1000000000123\");\n    test(\"123\", \"-1000000000000\", \"1000000000123\");\n    test(\"12345678987654321\", \"-314159265358979\", \"12659838253013300\");\n    test(\"4294967296\", \"-1\", \"4294967297\");\n    test(\"4294967295\", \"-4294967295\", \"8589934590\");\n    test(\"4294967296\", \"-4294967295\", \"8589934591\");\n    test(\"4294967296\", \"-4294967296\", \"8589934592\");\n    test(\"4294967295\", \"-4294967296\", \"8589934591\");\n    test(\"18446744073709551616\", \"-1\", \"18446744073709551617\");\n    test(\n        \"18446744073709551615\",\n        \"-18446744073709551615\",\n        \"36893488147419103230\",\n    );\n    test(\n        \"18446744073709551616\",\n        \"-18446744073709551615\",\n        \"36893488147419103231\",\n    );\n    test(\n        \"18446744073709551615\",\n        \"-18446744073709551616\",\n        \"36893488147419103231\",\n    );\n    test(\"70734740290631708\", \"-282942734368\", \"70735023233366076\");\n    test(\"282942734368\", \"-70734740290631708\", \"70735023233366076\");\n\n    test(\"-123\", \"0\", \"123\");\n    test(\"-456\", \"123\", \"579\");\n    test(\"-1000000000000\", \"123\", \"1000000000123\");\n    test(\"-123\", \"1000000000000\", \"1000000000123\");\n    test(\"-12345678987654321\", \"314159265358979\", \"12659838253013300\");\n    test(\"-4294967296\", \"1\", \"4294967297\");\n    test(\"-4294967295\", \"4294967295\", \"8589934590\");\n    test(\"-4294967296\", \"4294967295\", \"8589934591\");\n    test(\"-4294967296\", \"4294967296\", \"8589934592\");\n    test(\"-4294967295\", \"4294967296\", \"8589934591\");\n    test(\"-18446744073709551616\", \"1\", \"18446744073709551617\");\n    test(\n        \"-18446744073709551615\",\n        \"18446744073709551615\",\n        \"36893488147419103230\",\n    );\n    test(\n        \"-18446744073709551616\",\n        \"18446744073709551615\",\n        \"36893488147419103231\",\n    );\n    test(\n        \"-18446744073709551615\",\n        \"18446744073709551616\",\n        \"36893488147419103231\",\n    );\n    test(\"-70734740290631708\", \"282942734368\", \"70735023233366076\");\n    test(\"-282942734368\", \"70734740290631708\", \"70735023233366076\");\n\n    test(\"-456\", \"-123\", \"333\");\n    test(\"-1000000000000\", \"-123\", \"999999999877\");\n    test(\"-123\", \"-1000000000000\", \"999999999877\");\n    test(\n        \"-12345678987654321\",\n        \"-314159265358979\",\n        \"12031519722295342\",\n    );\n    test(\"-4294967296\", \"-1\", \"4294967295\");\n    test(\"-4294967295\", \"-4294967295\", \"0\");\n    test(\"-4294967296\", \"-4294967295\", \"1\");\n    test(\"-4294967296\", \"-4294967296\", \"0\");\n    test(\"-4294967295\", \"-4294967296\", \"1\");\n    test(\"-18446744073709551616\", \"-1\", \"18446744073709551615\");\n    test(\"-18446744073709551615\", \"-18446744073709551615\", \"0\");\n    test(\"-18446744073709551616\", \"-18446744073709551615\", \"1\");\n    test(\"-18446744073709551615\", \"-18446744073709551616\", \"1\");\n    test(\"-70734740290631708\", \"-282942734368\", \"70734457347897340\");\n    test(\"-282942734368\", \"-70734740290631708\", \"70734457347897340\");\n}\n\n#[test]\nfn abs_diff_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.abs_diff_assign(&y);\n        assert!(mut_x.is_valid());\n        let diff = mut_x;\n\n        let mut mut_x = x.clone();\n        mut_x.abs_diff_assign(y.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n\n        let diff_alt = x.clone().abs_diff(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = x.clone().abs_diff(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).abs_diff(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).abs_diff(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        assert_eq!((&x - &y).abs(), diff);\n        assert_eq!((&y).abs_diff(&x), diff);\n        assert_eq!((-&x).abs_diff(-&y), diff);\n        assert_eq!(diff == 0, x == y);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!((&x).abs_diff(Integer::ZERO), (&x).abs());\n        assert_eq!((&x).abs_diff(&x), 0);\n        assert_eq!(Integer::ZERO.abs_diff(&x), x.abs());\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        assert!((&x).abs_diff(&z) <= x.abs_diff(&y) + y.abs_diff(z));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(x.abs_diff(y), Integer::from(x).abs_diff(Integer::from(y)));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{SignedDoubleLimb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, integer_vec_gen, natural_pair_gen,\n    natural_vec_gen,\n};\nuse malachite_nz::test_util::integer::arithmetic::add::integer_sum_alt;\nuse num::BigInt;\nuse std::iter::{Sum, once};\nuse std::str::FromStr;\n\n#[test]\nfn test_add() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n += v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n += &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() + v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u + v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() + &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u + &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigInt::from_str(s).unwrap() + BigInt::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() + rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"456\", \"579\");\n    test(\"1000000000000\", \"123\", \"1000000000123\");\n    test(\"123\", \"1000000000000\", \"1000000000123\");\n    test(\"12345678987654321\", \"314159265358979\", \"12659838253013300\");\n    test(\"0\", \"-123\", \"-123\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"-333\");\n    test(\"1000000000000\", \"-123\", \"999999999877\");\n    test(\"123\", \"-1000000000000\", \"-999999999877\");\n    test(\"12345678987654321\", \"-314159265358979\", \"12031519722295342\");\n}\n\n#[test]\nfn test_sum() {\n    let test = |xs, out| {\n        let xs = vec_from_str(xs).unwrap();\n        let sum = Integer::sum(xs.iter().cloned());\n        assert!(sum.is_valid());\n        assert_eq!(sum.to_string(), out);\n\n        let sum_alt = Integer::sum(xs.iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n\n        let sum_alt = integer_sum_alt(xs.into_iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n    };\n    test(\"[]\", \"0\");\n    test(\"[10]\", \"10\");\n    test(\"[6, -2]\", \"4\");\n    test(\"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\", \"55\");\n    test(\"[123456, -789012, 345678, -9012345]\", \"-9332223\");\n}\n\n#[test]\nfn add_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let sum_val_val = x.clone() + y.clone();\n        let sum_val_ref = x.clone() + &y;\n        let sum_ref_val = &x + y.clone();\n        let sum = &x + &y;\n        assert!(sum_val_val.is_valid());\n        assert!(sum_val_ref.is_valid());\n        assert!(sum_ref_val.is_valid());\n        assert!(sum.is_valid());\n        assert_eq!(sum_val_val, sum);\n        assert_eq!(sum_val_ref, sum);\n        assert_eq!(sum_ref_val, sum);\n\n        let mut mut_x = x.clone();\n        mut_x += y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, sum);\n        let mut mut_x = x.clone();\n        mut_x += &y;\n        assert_eq!(mut_x, sum);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x += rug::Integer::from(&y);\n        assert_eq!(Integer::from(&mut_x), sum);\n\n        assert_eq!(Integer::from(&(BigInt::from(&x) + BigInt::from(&y))), sum);\n        assert_eq!(\n            Integer::from(&(rug::Integer::from(&x) + rug::Integer::from(&y))),\n            sum\n        );\n        assert_eq!(&y + &x, sum);\n        assert_eq!(&sum - &x, y);\n        assert_eq!(sum - y, x);\n    });\n\n    integer_gen().test_properties(|ref x| {\n        assert_eq!(x + Integer::ZERO, *x);\n        assert_eq!(Integer::ZERO + x, *x);\n        assert_eq!(x + x, x << 1);\n        assert_eq!(x + (-x), 0);\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x + &y) + &z, x + (y + z));\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(&x + &y, Integer::from(x) + Integer::from(y));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(SignedDoubleLimb::from(x) + SignedDoubleLimb::from(y)),\n            Integer::from(x) + Integer::from(y)\n        );\n    });\n}\n\n#[test]\nfn sum_properties() {\n    integer_vec_gen().test_properties(|xs| {\n        let sum = Integer::sum(xs.iter().cloned());\n        assert!(sum.is_valid());\n\n        let sum_alt = Integer::sum(xs.iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n\n        let sum_alt = integer_sum_alt(xs.into_iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(Integer::sum(once(&x)), x);\n        assert_eq!(Integer::sum(once(x.clone())), x);\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        let sum = &x + &y;\n        assert_eq!(Integer::sum([&x, &y].into_iter()), sum);\n        assert_eq!(Integer::sum([x, y].into_iter()), sum);\n    });\n\n    natural_vec_gen().test_properties(|xs| {\n        assert_eq!(\n            Integer::sum(xs.iter().map(Integer::from)),\n            Integer::from(Natural::sum(xs.into_iter()))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AddMul, AddMulAssign, CheckedAddMul};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::test_util::generators::{signed_triple_gen, signed_triple_gen_var_1};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_triple_gen,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_add_mul() {\n    let test = |r, s, t, out| {\n        let u = Integer::from_str(r).unwrap();\n        let v = Integer::from_str(s).unwrap();\n        let w = Integer::from_str(t).unwrap();\n\n        let mut a = u.clone();\n        a.add_mul_assign(v.clone(), w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.add_mul_assign(v.clone(), &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.add_mul_assign(&v, w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.add_mul_assign(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(v.clone(), w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(v.clone(), &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(&v, w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = (&u).add_mul(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n    };\n    test(\"0\", \"0\", \"0\", \"0\");\n    test(\"0\", \"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"5\", \"123\");\n    test(\"123\", \"5\", \"1\", \"128\");\n    test(\"123\", \"5\", \"100\", \"623\");\n    test(\"10\", \"3\", \"4\", \"22\");\n    test(\"1000000000000\", \"0\", \"123\", \"1000000000000\");\n    test(\"1000000000000\", \"1\", \"123\", \"1000000000123\");\n    test(\"1000000000000\", \"123\", \"1\", \"1000000000123\");\n    test(\"1000000000000\", \"123\", \"100\", \"1000000012300\");\n    test(\"1000000000000\", \"100\", \"123\", \"1000000012300\");\n    test(\"1000000000000\", \"65536\", \"65536\", \"1004294967296\");\n    test(\"1000000000000\", \"1000000000000\", \"0\", \"1000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"1\", \"2000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"100\", \"101000000000000\");\n    test(\"0\", \"1000000000000\", \"100\", \"100000000000000\");\n    test(\n        \"1000000000000\",\n        \"65536\",\n        \"1000000000000\",\n        \"65537000000000000\",\n    );\n    test(\n        \"1000000000000\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"1000000000001000000000000\",\n    );\n    test(\n        \"0\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"1000000000000000000000000\",\n    );\n\n    test(\"123\", \"-5\", \"-1\", \"128\");\n    test(\"123\", \"-5\", \"-100\", \"623\");\n    test(\"10\", \"-3\", \"-4\", \"22\");\n    test(\"1000000000000\", \"-1\", \"-123\", \"1000000000123\");\n    test(\"1000000000000\", \"-123\", \"-1\", \"1000000000123\");\n    test(\"1000000000000\", \"-123\", \"-100\", \"1000000012300\");\n    test(\"1000000000000\", \"-100\", \"-123\", \"1000000012300\");\n    test(\"1000000000000\", \"-65536\", \"-65536\", \"1004294967296\");\n    test(\"1000000000000\", \"-1000000000000\", \"-1\", \"2000000000000\");\n    test(\"1000000000000\", \"-1000000000000\", \"-100\", \"101000000000000\");\n    test(\"0\", \"-1000000000000\", \"-100\", \"100000000000000\");\n    test(\n        \"1000000000000\",\n        \"-65536\",\n        \"-1000000000000\",\n        \"65537000000000000\",\n    );\n    test(\n        \"1000000000000\",\n        \"-1000000000000\",\n        \"-1000000000000\",\n        \"1000000000001000000000000\",\n    );\n    test(\n        \"0\",\n        \"-1000000000000\",\n        \"-1000000000000\",\n        \"1000000000000000000000000\",\n    );\n\n    test(\"0\", \"0\", \"-123\", \"0\");\n    test(\"123\", \"0\", \"-5\", \"123\");\n    test(\"123\", \"-5\", \"1\", \"118\");\n    test(\"123\", \"5\", \"-1\", \"118\");\n    test(\"123\", \"-5\", \"100\", \"-377\");\n    test(\"123\", \"5\", \"-100\", \"-377\");\n    test(\"10\", \"-3\", \"4\", \"-2\");\n    test(\"10\", \"3\", \"-4\", \"-2\");\n    test(\"15\", \"-3\", \"4\", \"3\");\n    test(\"15\", \"3\", \"-4\", \"3\");\n    test(\"1000000000000\", \"0\", \"-123\", \"1000000000000\");\n    test(\"1000000000000\", \"-1\", \"123\", \"999999999877\");\n    test(\"1000000000000\", \"1\", \"-123\", \"999999999877\");\n    test(\"1000000000000\", \"-123\", \"1\", \"999999999877\");\n    test(\"1000000000000\", \"123\", \"-1\", \"999999999877\");\n    test(\"1000000000000\", \"-123\", \"100\", \"999999987700\");\n    test(\"1000000000000\", \"123\", \"-100\", \"999999987700\");\n    test(\"1000000000000\", \"-100\", \"123\", \"999999987700\");\n    test(\"1000000000000\", \"100\", \"-123\", \"999999987700\");\n    test(\"1000000000000\", \"-65536\", \"65536\", \"995705032704\");\n    test(\"1000000000000\", \"65536\", \"-65536\", \"995705032704\");\n    test(\"1000000000000\", \"-1000000000000\", \"0\", \"1000000000000\");\n    test(\"1000000000000\", \"-1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"1000000000000\", \"-1\", \"0\");\n    test(\"1000000000000\", \"-1000000000000\", \"100\", \"-99000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"-100\", \"-99000000000000\");\n    test(\"0\", \"-1000000000000\", \"100\", \"-100000000000000\");\n    test(\"4294967296\", \"-1\", \"1\", \"4294967295\");\n    test(\"4294967296\", \"1\", \"-1\", \"4294967295\");\n    test(\"3902609153\", \"-88817093856604\", \"1\", \"-88813191247451\");\n    test(\"3902609153\", \"88817093856604\", \"-1\", \"-88813191247451\");\n\n    test(\"-123\", \"0\", \"5\", \"-123\");\n    test(\"-123\", \"-5\", \"1\", \"-128\");\n    test(\"-123\", \"-5\", \"100\", \"-623\");\n    test(\"-10\", \"-3\", \"4\", \"-22\");\n    test(\"-1000000000000\", \"0\", \"123\", \"-1000000000000\");\n    test(\"-1000000000000\", \"-1\", \"123\", \"-1000000000123\");\n    test(\"-1000000000000\", \"-123\", \"1\", \"-1000000000123\");\n    test(\"-1000000000000\", \"-123\", \"100\", \"-1000000012300\");\n    test(\"-1000000000000\", \"-100\", \"123\", \"-1000000012300\");\n    test(\"-1000000000000\", \"-65536\", \"65536\", \"-1004294967296\");\n    test(\"-1000000000000\", \"-1000000000000\", \"0\", \"-1000000000000\");\n    test(\"-1000000000000\", \"-1000000000000\", \"1\", \"-2000000000000\");\n    test(\n        \"-1000000000000\",\n        \"-1000000000000\",\n        \"100\",\n        \"-101000000000000\",\n    );\n    test(\n        \"-1000000000000\",\n        \"-65536\",\n        \"1000000000000\",\n        \"-65537000000000000\",\n    );\n    test(\n        \"-1000000000000\",\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"-1000000000001000000000000\",\n    );\n    test(\n        \"0\",\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"-1000000000000000000000000\",\n    );\n\n    test(\"-123\", \"5\", \"-1\", \"-128\");\n    test(\"-123\", \"5\", \"-100\", \"-623\");\n    test(\"-10\", \"3\", \"-4\", \"-22\");\n    test(\"-1000000000000\", \"1\", \"-123\", \"-1000000000123\");\n    test(\"-1000000000000\", \"123\", \"-1\", \"-1000000000123\");\n    test(\"-1000000000000\", \"123\", \"-100\", \"-1000000012300\");\n    test(\"-1000000000000\", \"100\", \"-123\", \"-1000000012300\");\n    test(\"-1000000000000\", \"65536\", \"-65536\", \"-1004294967296\");\n    test(\"-1000000000000\", \"1000000000000\", \"-1\", \"-2000000000000\");\n    test(\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"-100\",\n        \"-101000000000000\",\n    );\n    test(\n        \"-1000000000000\",\n        \"65536\",\n        \"-1000000000000\",\n        \"-65537000000000000\",\n    );\n    test(\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"-1000000000000\",\n        \"-1000000000001000000000000\",\n    );\n\n    test(\"-123\", \"0\", \"-5\", \"-123\");\n    test(\"-123\", \"5\", \"1\", \"-118\");\n    test(\"-123\", \"-5\", \"-1\", \"-118\");\n    test(\"-123\", \"5\", \"100\", \"377\");\n    test(\"-123\", \"-5\", \"-100\", \"377\");\n    test(\"-10\", \"3\", \"4\", \"2\");\n    test(\"-10\", \"-3\", \"-4\", \"2\");\n    test(\"-15\", \"3\", \"4\", \"-3\");\n    test(\"-15\", \"-3\", \"-4\", \"-3\");\n    test(\"-1000000000000\", \"0\", \"-123\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1\", \"123\", \"-999999999877\");\n    test(\"-1000000000000\", \"-1\", \"-123\", \"-999999999877\");\n    test(\"-1000000000000\", \"123\", \"1\", \"-999999999877\");\n    test(\"-1000000000000\", \"-123\", \"-1\", \"-999999999877\");\n    test(\"-1000000000000\", \"123\", \"100\", \"-999999987700\");\n    test(\"-1000000000000\", \"-123\", \"-100\", \"-999999987700\");\n    test(\"-1000000000000\", \"100\", \"123\", \"-999999987700\");\n    test(\"-1000000000000\", \"-100\", \"-123\", \"-999999987700\");\n    test(\"-1000000000000\", \"65536\", \"65536\", \"-995705032704\");\n    test(\"-1000000000000\", \"-65536\", \"-65536\", \"-995705032704\");\n    test(\"-1000000000000\", \"1000000000000\", \"0\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1000000000000\", \"1\", \"0\");\n    test(\"-1000000000000\", \"-1000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"1000000000000\", \"100\", \"99000000000000\");\n    test(\"-1000000000000\", \"-1000000000000\", \"-100\", \"99000000000000\");\n    test(\"-4294967296\", \"1\", \"1\", \"-4294967295\");\n    test(\"-4294967296\", \"-1\", \"-1\", \"-4294967295\");\n    test(\"-3902609153\", \"88817093856604\", \"1\", \"88813191247451\");\n    test(\"-3902609153\", \"-88817093856604\", \"-1\", \"88813191247451\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"0\",\n    );\n    test(\n        \"-4\",\n        \"-24227802588\",\n        \"-14313318194700\",\n        \"346780247600420147883596\",\n    );\n}\n\n#[test]\nfn add_mul_properties() {\n    integer_triple_gen().test_properties(|(a, b, c)| {\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(b.clone(), c.clone());\n        assert!(mut_a.is_valid());\n        let result = mut_a;\n\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(b.clone(), &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(&b, c.clone());\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(&b, &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let result_alt = a.clone().add_mul(b.clone(), c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().add_mul(b.clone(), &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().add_mul(&b, c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().add_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = (&a).add_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let a = &a;\n        let b = &b;\n        let c = &c;\n        assert_eq!(a + b * c, result);\n        assert_eq!(a.add_mul(c, b), result);\n        assert_eq!(a.add_mul(&(-b), &(-c)), result);\n        assert_eq!((-a).add_mul(&(-b), c), -&result);\n        assert_eq!((-a).add_mul(b, -c), -result);\n    });\n\n    integer_gen().test_properties(|a| {\n        let a = &a;\n        assert_eq!(a.add_mul(a, &Integer::NEGATIVE_ONE), 0);\n        assert_eq!(a.add_mul(&(-a), &Integer::ONE), 0);\n    });\n\n    integer_pair_gen().test_properties(|(a, b)| {\n        let a = &a;\n        let b = &b;\n        assert_eq!(a.add_mul(&Integer::ZERO, b), *a);\n        assert_eq!(a.add_mul(&Integer::ONE, b), a + b);\n        assert_eq!(Integer::ZERO.add_mul(a, b), a * b);\n        assert_eq!(a.add_mul(b, &Integer::ZERO), *a);\n        assert_eq!(a.add_mul(b, &Integer::ONE), a + b);\n        assert_eq!((a * b).add_mul(-a, b), 0);\n        assert_eq!((a * b).add_mul(a, -b), 0);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!(\n            (&x).add_mul(&y, &z),\n            Integer::from(x).add_mul(Integer::from(y), Integer::from(z))\n        );\n    });\n\n    signed_triple_gen_var_1::<SignedLimb>().test_properties(|(x, y, z)| {\n        assert_eq!(\n            x.add_mul(y, z),\n            Integer::from(x).add_mul(Integer::from(y), Integer::from(z))\n        );\n    });\n\n    signed_triple_gen::<SignedLimb>().test_properties(|(x, y, z)| {\n        let result = Integer::from(x).add_mul(Integer::from(y), Integer::from(z));\n        assert_eq!(\n            x.checked_add_mul(y, z).is_some(),\n            SignedLimb::convertible_from(&result)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{BinomialCoefficient, NegAssign, Parity};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::signed_pair_gen_var_12;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{integer_gen, integer_gen_var_4, integer_pair_gen_var_7};\nuse std::str::FromStr;\n\n#[test]\nfn test_binomial_coefficient() {\n    fn test(n: &str, k: &str, out: &str) {\n        let n = Integer::from_str(n).unwrap();\n        let k = Integer::from_str(k).unwrap();\n        let b = Integer::binomial_coefficient(n.clone(), k.clone());\n        assert!(b.is_valid());\n        assert_eq!(b.to_string(), out);\n\n        let b_alt = Integer::binomial_coefficient(&n, &k);\n        assert!(b_alt.is_valid());\n        assert_eq!(b_alt, b);\n\n        assert_eq!(\n            rug::Integer::from(&n)\n                .binomial(u32::exact_from(&k))\n                .to_string(),\n            out,\n        );\n    }\n    test(\"0\", \"0\", \"1\");\n    test(\"1\", \"0\", \"1\");\n    test(\"1\", \"1\", \"1\");\n    test(\"2\", \"0\", \"1\");\n    test(\"2\", \"1\", \"2\");\n    test(\"2\", \"2\", \"1\");\n    test(\"3\", \"0\", \"1\");\n    test(\"3\", \"1\", \"3\");\n    test(\"3\", \"2\", \"3\");\n    test(\"3\", \"3\", \"1\");\n    test(\"4\", \"0\", \"1\");\n    test(\"4\", \"1\", \"4\");\n    test(\"4\", \"2\", \"6\");\n    test(\"4\", \"3\", \"4\");\n    test(\"4\", \"4\", \"1\");\n    test(\"1\", \"2\", \"0\");\n    test(\"10\", \"5\", \"252\");\n    test(\"100\", \"50\", \"100891344545564193334812497256\");\n    test(\"-1\", \"0\", \"1\");\n    test(\"-1\", \"1\", \"-1\");\n    test(\"-2\", \"0\", \"1\");\n    test(\"-2\", \"1\", \"-2\");\n    test(\"-2\", \"2\", \"3\");\n    test(\"-3\", \"0\", \"1\");\n    test(\"-3\", \"1\", \"-3\");\n    test(\"-3\", \"2\", \"6\");\n    test(\"-3\", \"3\", \"-10\");\n    test(\"-1\", \"2\", \"1\");\n    test(\"-10\", \"5\", \"-2002\");\n    test(\"-80\", \"50\", \"1828256793482238093393785743858493760\");\n    test(\"-128\", \"1\", \"-128\");\n    test(\"-2\", \"127\", \"-128\");\n}\n\n#[test]\nfn binomial_coefficient_properties() {\n    integer_pair_gen_var_7().test_properties(|(n, k)| {\n        let b = Integer::binomial_coefficient(n.clone(), k.clone());\n        assert!(b.is_valid());\n\n        let b_alt = Integer::binomial_coefficient(&n, &k);\n        assert!(b_alt.is_valid());\n        assert_eq!(b, b_alt);\n\n        assert_eq!(\n            Integer::from(&rug::Integer::from(&n).binomial(u32::exact_from(&k))),\n            b\n        );\n        assert_eq!(b == 0, n >= 0 && n < k);\n        if n >= k {\n            assert_eq!(Integer::binomial_coefficient(&n, &(&n - &k)), b);\n        }\n        if k != 0u32 {\n            let c = Integer::binomial_coefficient(&(&n - Integer::ONE), &k);\n            assert_eq!(\n                c + Integer::binomial_coefficient(&n - Integer::ONE, &k - Integer::ONE),\n                b\n            );\n        }\n        let mut b_alt = Integer::binomial_coefficient(&((&n - Integer::ONE) + &k), &k);\n        if k.odd() {\n            b_alt.neg_assign();\n        }\n        assert_eq!(Integer::binomial_coefficient(-n, k), b_alt);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(Integer::binomial_coefficient(&n, &Integer::ONE), n);\n        assert_eq!(Integer::binomial_coefficient(n, Integer::ZERO), 1);\n    });\n\n    integer_gen_var_4().test_properties(|n| {\n        assert_eq!(Integer::binomial_coefficient(&n, &n), 1u32);\n        if n != 0 {\n            assert_eq!(Integer::binomial_coefficient(&n, &(&n - Integer::ONE)), n);\n            assert_eq!(Integer::binomial_coefficient(Integer::ZERO, n), 0);\n        }\n    });\n\n    signed_pair_gen_var_12::<SignedLimb>().test_properties(|(n, k)| {\n        assert_eq!(\n            Integer::binomial_coefficient(Integer::from(n), Integer::from(k)),\n            SignedLimb::binomial_coefficient(n, k)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedDiv, DivRem};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::signed_pair_gen_var_4;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_8, integer_pair_gen, integer_pair_gen_var_1,\n    integer_pair_gen_var_2, natural_pair_gen_var_5,\n};\nuse num::BigInt;\nuse std::str::FromStr;\n\n#[test]\nfn test_div() {\n    let test = |s, t, quotient| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x /= v.clone();\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        x /= &v;\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let q = u.clone() / v.clone();\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.clone() / &v;\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = &u / v.clone();\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = &u / &v;\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = BigInt::from_str(s).unwrap() / &BigInt::from_str(t).unwrap();\n        assert_eq!(q.to_string(), quotient);\n\n        let q = rug::Integer::from_str(s).unwrap() / rug::Integer::from_str(t).unwrap();\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.div_rem(v).0;\n        assert_eq!(q.to_string(), quotient);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"1\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"123\", \"1\");\n    test(\"123\", \"456\", \"0\");\n    test(\"456\", \"123\", \"3\");\n    test(\"4294967295\", \"1\", \"4294967295\");\n    test(\"4294967295\", \"4294967295\", \"1\");\n    test(\"1000000000000\", \"1\", \"1000000000000\");\n    test(\"1000000000000\", \"3\", \"333333333333\");\n    test(\"1000000000000\", \"123\", \"8130081300\");\n    test(\"1000000000000\", \"4294967295\", \"232\");\n    test(\n        \"1000000000000000000000000\",\n        \"1\",\n        \"1000000000000000000000000\",\n    );\n    test(\"1000000000000000000000000\", \"3\", \"333333333333333333333333\");\n    test(\"1000000000000000000000000\", \"123\", \"8130081300813008130081\");\n    test(\"1000000000000000000000000\", \"4294967295\", \"232830643708079\");\n    test(\"1000000000000000000000000\", \"1234567890987\", \"810000006723\");\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"94998781946290113\",\n    );\n    test(\"3768477692975601\", \"11447376614057827956\", \"0\");\n    test(\"3356605361737854\", \"3081095617839357\", \"1\");\n    test(\"1098730198198174614195\", \"953382298040157850476\", \"1\");\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"1\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"0\");\n    test(\n        \"915607705283450388306561139234228660872677067256472842161753852459689688332903348325308112\\\n        7923093090598913\",\n        \"11669177832462215441614364516705357863717491965951\",\n        \"784637716923245892498679555408392159158150581185689944063\",\n    );\n\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"1\", \"-1\", \"-1\");\n    test(\"123\", \"-1\", \"-123\");\n    test(\"123\", \"-123\", \"-1\");\n    test(\"123\", \"-456\", \"0\");\n    test(\"456\", \"-123\", \"-3\");\n    test(\"4294967295\", \"-1\", \"-4294967295\");\n    test(\"4294967295\", \"-4294967295\", \"-1\");\n    test(\"1000000000000\", \"-1\", \"-1000000000000\");\n    test(\"1000000000000\", \"-3\", \"-333333333333\");\n    test(\"1000000000000\", \"-123\", \"-8130081300\");\n    test(\"1000000000000\", \"-4294967295\", \"-232\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"-1000000000000000000000000\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-3\",\n        \"-333333333333333333333333\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-123\",\n        \"-8130081300813008130081\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        \"-232830643708079\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1234567890987\",\n        \"-810000006723\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018654\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253979\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"-94998781946290113\",\n    );\n    test(\"3768477692975601\", \"-11447376614057827956\", \"0\");\n    test(\"3356605361737854\", \"-3081095617839357\", \"-1\");\n    test(\"1098730198198174614195\", \"-953382298040157850476\", \"-1\");\n    test(\n        \"69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"-1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"-1\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\");\n    test(\"123\", \"-1000000000000000000000000\", \"0\");\n    test(\n        \"915607705283450388306561139234228660872677067256472842161753852459689688332903348325308112\\\n        7923093090598913\",\n        \"-11669177832462215441614364516705357863717491965951\",\n        \"-784637716923245892498679555408392159158150581185689944063\",\n    );\n\n    test(\"-1\", \"1\", \"-1\");\n    test(\"-123\", \"1\", \"-123\");\n    test(\"-123\", \"123\", \"-1\");\n    test(\"-123\", \"456\", \"0\");\n    test(\"-456\", \"123\", \"-3\");\n    test(\"-4294967295\", \"1\", \"-4294967295\");\n    test(\"-4294967295\", \"4294967295\", \"-1\");\n    test(\"-1000000000000\", \"1\", \"-1000000000000\");\n    test(\"-1000000000000\", \"3\", \"-333333333333\");\n    test(\"-1000000000000\", \"123\", \"-8130081300\");\n    test(\"-1000000000000\", \"4294967295\", \"-232\");\n    test(\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"-1000000000000000000000000\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"3\",\n        \"-333333333333333333333333\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"123\",\n        \"-8130081300813008130081\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        \"-232830643708079\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1234567890987\",\n        \"-810000006723\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018654\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253979\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"2669936877441\",\n        \"-94998781946290113\",\n    );\n    test(\"-3768477692975601\", \"11447376614057827956\", \"0\");\n    test(\"-3356605361737854\", \"3081095617839357\", \"-1\");\n    test(\"-1098730198198174614195\", \"953382298040157850476\", \"-1\");\n    test(\n        \"-69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"-1\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"-1\",\n    );\n    test(\"-123\", \"1000000000000000000000000\", \"0\");\n    test(\n        \"-91560770528345038830656113923422866087267706725647284216175385245968968833290334832530811\\\n        27923093090598913\",\n        \"11669177832462215441614364516705357863717491965951\",\n        \"-784637716923245892498679555408392159158150581185689944063\",\n    );\n\n    test(\"-1\", \"-1\", \"1\");\n    test(\"-123\", \"-1\", \"123\");\n    test(\"-123\", \"-123\", \"1\");\n    test(\"-123\", \"-456\", \"0\");\n    test(\"-456\", \"-123\", \"3\");\n    test(\"-4294967295\", \"-1\", \"4294967295\");\n    test(\"-4294967295\", \"-4294967295\", \"1\");\n    test(\"-1000000000000\", \"-1\", \"1000000000000\");\n    test(\"-1000000000000\", \"-3\", \"333333333333\");\n    test(\"-1000000000000\", \"-123\", \"8130081300\");\n    test(\"-1000000000000\", \"-4294967295\", \"232\");\n    test(\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"1000000000000000000000000\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-3\",\n        \"333333333333333333333333\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-123\",\n        \"8130081300813008130081\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        \"232830643708079\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1234567890987\",\n        \"810000006723\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"94998781946290113\",\n    );\n    test(\"-3768477692975601\", \"-11447376614057827956\", \"0\");\n    test(\"-3356605361737854\", \"-3081095617839357\", \"1\");\n    test(\"-1098730198198174614195\", \"-953382298040157850476\", \"1\");\n    test(\n        \"-69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"1\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"1\",\n    );\n    test(\"-123\", \"-1000000000000000000000000\", \"0\");\n    test(\n        \"-91560770528345038830656113923422866087267706725647284216175385245968968833290334832530811\\\n        27923093090598913\",\n        \"-11669177832462215441614364516705357863717491965951\",\n        \"784637716923245892498679555408392159158150581185689944063\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn div_assign_fail() {\n    let mut x = Integer::from(10);\n    x /= Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_ref_fail() {\n    let mut x = Integer::from(10);\n    x /= &Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_fail() {\n    Integer::from(10) / Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_val_ref_fail() {\n    Integer::from(10) / &Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_ref_val_fail() {\n    &Integer::from(10) / Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_ref_ref_fail() {\n    &Integer::from(10) / &Integer::ZERO;\n}\n\n#[test]\nfn test_checked_div() {\n    let test = |s, t, quotient| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let q = u.clone().checked_div(v.clone());\n        assert!(q.as_ref().is_none_or(Integer::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = u.clone().checked_div(&v);\n        assert!(q.as_ref().is_none_or(Integer::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = (&u).checked_div(v.clone());\n        assert!(q.as_ref().is_none_or(Integer::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = (&u).checked_div(&v);\n        assert!(q.as_ref().is_none_or(Integer::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = BigInt::from_str(s)\n            .unwrap()\n            .checked_div(&BigInt::from_str(t).unwrap());\n        assert_eq!(q.to_debug_string(), quotient);\n    };\n    test(\"0\", \"1\", \"Some(0)\");\n    test(\"0\", \"123\", \"Some(0)\");\n    test(\"1\", \"1\", \"Some(1)\");\n    test(\"123\", \"1\", \"Some(123)\");\n    test(\"123\", \"123\", \"Some(1)\");\n    test(\"123\", \"456\", \"Some(0)\");\n    test(\"456\", \"123\", \"Some(3)\");\n    test(\"4294967295\", \"1\", \"Some(4294967295)\");\n    test(\"4294967295\", \"4294967295\", \"Some(1)\");\n    test(\"1000000000000\", \"1\", \"Some(1000000000000)\");\n    test(\"1000000000000\", \"3\", \"Some(333333333333)\");\n    test(\"1000000000000\", \"123\", \"Some(8130081300)\");\n    test(\"1000000000000\", \"4294967295\", \"Some(232)\");\n\n    test(\"0\", \"-1\", \"Some(0)\");\n    test(\"0\", \"-123\", \"Some(0)\");\n    test(\"1\", \"-1\", \"Some(-1)\");\n    test(\"123\", \"-1\", \"Some(-123)\");\n    test(\"123\", \"-123\", \"Some(-1)\");\n    test(\"123\", \"-456\", \"Some(0)\");\n    test(\"456\", \"-123\", \"Some(-3)\");\n    test(\"4294967295\", \"-1\", \"Some(-4294967295)\");\n    test(\"4294967295\", \"-4294967295\", \"Some(-1)\");\n    test(\"1000000000000\", \"-1\", \"Some(-1000000000000)\");\n    test(\"1000000000000\", \"-3\", \"Some(-333333333333)\");\n    test(\"1000000000000\", \"-123\", \"Some(-8130081300)\");\n    test(\"1000000000000\", \"-4294967295\", \"Some(-232)\");\n\n    test(\"-1\", \"1\", \"Some(-1)\");\n    test(\"-123\", \"1\", \"Some(-123)\");\n    test(\"-123\", \"123\", \"Some(-1)\");\n    test(\"-123\", \"456\", \"Some(0)\");\n    test(\"-456\", \"123\", \"Some(-3)\");\n    test(\"-4294967295\", \"1\", \"Some(-4294967295)\");\n    test(\"-4294967295\", \"4294967295\", \"Some(-1)\");\n    test(\"-1000000000000\", \"1\", \"Some(-1000000000000)\");\n    test(\"-1000000000000\", \"3\", \"Some(-333333333333)\");\n    test(\"-1000000000000\", \"123\", \"Some(-8130081300)\");\n    test(\"-1000000000000\", \"4294967295\", \"Some(-232)\");\n\n    test(\"-1\", \"-1\", \"Some(1)\");\n    test(\"-123\", \"-1\", \"Some(123)\");\n    test(\"-123\", \"-123\", \"Some(1)\");\n    test(\"-123\", \"-456\", \"Some(0)\");\n    test(\"-456\", \"-123\", \"Some(3)\");\n    test(\"-4294967295\", \"-1\", \"Some(4294967295)\");\n    test(\"-4294967295\", \"-4294967295\", \"Some(1)\");\n    test(\"-1000000000000\", \"-1\", \"Some(1000000000000)\");\n    test(\"-1000000000000\", \"-3\", \"Some(333333333333)\");\n    test(\"-1000000000000\", \"-123\", \"Some(8130081300)\");\n    test(\"-1000000000000\", \"-4294967295\", \"Some(232)\");\n\n    test(\"0\", \"0\", \"None\");\n    test(\"1\", \"0\", \"None\");\n    test(\"123\", \"0\", \"None\");\n    test(\"1000000000000000000000000\", \"0\", \"None\");\n    test(\"-1\", \"0\", \"None\");\n    test(\"-123\", \"0\", \"None\");\n    test(\"-1000000000000000000000000\", \"0\", \"None\");\n}\n\nfn div_properties_helper(x: Integer, y: Integer) {\n    let mut mut_x = x.clone();\n    mut_x /= &y;\n    assert!(mut_x.is_valid());\n    let q = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x /= y.clone();\n    let q_alt = mut_x;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = &x / &y;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = &x / y.clone();\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = x.clone() / &y;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = x.clone() / y.clone();\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = (&x).div_rem(&y).0;\n    assert_eq!(q_alt, q);\n\n    let num_q = BigInt::from(&x) / &BigInt::from(&y);\n    assert_eq!(Integer::from(&num_q), q);\n\n    let rug_q = rug::Integer::from(&x) / rug::Integer::from(&y);\n    assert_eq!(Integer::from(&rug_q), q);\n\n    let remainder = &x - &q * &y;\n    assert!(remainder.lt_abs(&y));\n    assert!(remainder == 0 || (remainder > 0) == (x > 0));\n    assert_eq!(&q * &y + remainder, x);\n    assert_eq!((-&x) / &y, -&q);\n    assert_eq!(x / (-y), -q);\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn div_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_1().test_properties_with_config(&config, |(x, y)| {\n        div_properties_helper(x, y);\n    });\n\n    integer_pair_gen_var_2().test_properties_with_config(&config, |(x, y)| {\n        div_properties_helper(x, y);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(&x / Integer::ONE, x);\n        assert_eq!(&x / Integer::NEGATIVE_ONE, -x);\n    });\n\n    integer_gen_var_8().test_properties(|x| {\n        assert_eq!(Integer::ZERO / &x, 0);\n        if x > Integer::ONE {\n            assert_eq!(Integer::ONE / &x, 0);\n        }\n        assert_eq!(&x / Integer::ONE, x);\n        assert_eq!(&x / Integer::NEGATIVE_ONE, -&x);\n        assert_eq!(&x / &x, 1);\n        assert_eq!(&x / -&x, -1);\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) / Integer::from(&y), x / y);\n    });\n\n    signed_pair_gen_var_4::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x) / Integer::from(y), x / y);\n    });\n}\n\n#[test]\nfn checked_div_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let quotient_val_val = x.clone().checked_div(y.clone());\n        let quotient_val_ref = x.clone().checked_div(&y);\n        let quotient_ref_val = (&x).checked_div(y.clone());\n        let quotient = (&x).checked_div(&y);\n        assert!(quotient_val_val.as_ref().is_none_or(Integer::is_valid));\n        assert!(quotient_val_ref.as_ref().is_none_or(Integer::is_valid));\n        assert!(quotient_ref_val.as_ref().is_none_or(Integer::is_valid));\n        assert!(quotient.as_ref().is_none_or(Integer::is_valid));\n        assert_eq!(quotient_val_val, quotient);\n        assert_eq!(quotient_val_ref, quotient);\n        assert_eq!(quotient_ref_val, quotient);\n\n        if y != 0u32 {\n            assert_eq!(quotient, Some(&x / &y));\n        }\n\n        assert_eq!(\n            BigInt::from(&x)\n                .checked_div(&BigInt::from(&y))\n                .map(|n| Integer::from(&n)),\n            quotient\n        );\n    });\n\n    integer_gen().test_properties(|ref x| {\n        assert_eq!(x.checked_div(Integer::ZERO), None);\n        assert_eq!(x.checked_div(Integer::ONE), Some(x.clone()));\n    });\n\n    integer_gen_var_8().test_properties(|ref x| {\n        assert_eq!(Integer::ZERO.checked_div(x), Some(Integer::ZERO));\n        if *x > Integer::ONE {\n            assert_eq!(Integer::ONE.checked_div(x), Some(Integer::ZERO));\n        }\n        assert_eq!(x.checked_div(x), Some(Integer::ONE));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivExact, DivExactAssign, DivRound};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::signed_pair_gen_var_3;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_8, integer_pair_gen_var_2, natural_pair_gen_var_6,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_div_exact() {\n    let test = |s, t, quotient| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.div_exact_assign(v.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        x.div_exact_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let q = u.clone().div_exact(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.clone().div_exact(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = (&u).div_exact(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = (&u).div_exact(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.div_round(v, Exact).0;\n        assert_eq!(q.to_string(), quotient);\n\n        let q = rug::Integer::from_str(s)\n            .unwrap()\n            .div_exact(&rug::Integer::from_str(t).unwrap());\n        assert_eq!(q.to_string(), quotient);\n    };\n    test(\"0\", \"123\", \"0\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"123\", \"1\");\n    test(\"56088\", \"123\", \"456\");\n    test(\"0\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"1\", \"1000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"1\");\n    test(\"123000000000000\", \"1000000000000\", \"123\");\n    test(\"123000000000000\", \"123\", \"1000000000000\");\n    test(\"121932631112635269000000\", \"123456789000\", \"987654321000\");\n    test(\"8589934590\", \"4294967295\", \"2\");\n    test(\"18446744065119617025\", \"4294967295\", \"4294967295\");\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099789\",\n        \"577397114388109712462006371470162814529304445639807296878809567953200969820156259914159240\\\n        9106139481288193067515284601342023565222679498917484131095648263181800618990427694244342686\\\n        4412105186059052689237237088193855584354278755933606296018800151986520872701706693002473648\\\n        4330061421236425747083307907706860804054565348593527605104495080560663025897787060638154303\\\n        7631781316565710346299551930891169154491973589315700505458672804104869879731391323700304\",\n    );\n\n    test(\"0\", \"-123\", \"0\");\n    test(\"123\", \"-1\", \"-123\");\n    test(\"123\", \"-123\", \"-1\");\n    test(\"56088\", \"-123\", \"-456\");\n    test(\"0\", \"-1000000000000\", \"0\");\n    test(\"1000000000000\", \"-1\", \"-1000000000000\");\n    test(\"1000000000000\", \"-1000000000000\", \"-1\");\n    test(\"123000000000000\", \"-1000000000000\", \"-123\");\n    test(\"123000000000000\", \"-123\", \"-1000000000000\");\n    test(\"121932631112635269000000\", \"-123456789000\", \"-987654321000\");\n    test(\"8589934590\", \"-4294967295\", \"-2\");\n    test(\"18446744065119617025\", \"-4294967295\", \"-4294967295\");\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"-14750227965563656560025035845269405189398018669695853517400995652385572010732263815974936\\\n        8080821747949474430587689097259577148476973385751452961609619939409285830226599826048341601\\\n        6576390452204426400593828107256814088351371325554864304425008611048361721593563653380924810\\\n        2692659078914207980563844549476017755177663674783001449501248974399040735523228684207141892\\\n        2992135840957348090162448797731978275542273083446867343807680553295282140602439900681439016\\\n        6694982753079697108601126786460781490631333452551810222191964304044026732368834188903586437\\\n        6137724664457908815322266967227141431524031843984372003980899388641087496934099664501079567\\\n        0213351871698766886593652982743738804219008430900536956471739072625759490261936518009750957\\\n        6624018903777061930820690641412868685634995095262397002303944032370164345741148566677635444\\\n        8186307133288106956593939073729500658176632828099789\",\n        \"-57739711438810971246200637147016281452930444563980729687880956795320096982015625991415924\\\n        0910613948128819306751528460134202356522267949891748413109564826318180061899042769424434268\\\n        6441210518605905268923723708819385558435427875593360629601880015198652087270170669300247364\\\n        8433006142123642574708330790770686080405456534859352760510449508056066302589778706063815430\\\n        37631781316565710346299551930891169154491973589315700505458672804104869879731391323700304\",\n    );\n\n    test(\"-123\", \"1\", \"-123\");\n    test(\"-123\", \"123\", \"-1\");\n    test(\"-56088\", \"123\", \"-456\");\n    test(\"-1000000000000\", \"1\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1000000000000\", \"-1\");\n    test(\"-123000000000000\", \"1000000000000\", \"-123\");\n    test(\"-123000000000000\", \"123\", \"-1000000000000\");\n    test(\"-121932631112635269000000\", \"123456789000\", \"-987654321000\");\n    test(\"-8589934590\", \"4294967295\", \"-2\");\n    test(\"-18446744065119617025\", \"4294967295\", \"-4294967295\");\n    test(\n        \"-85167390638832534155095794307111191155780003684512955609936093881325960865026707945673997\\\n        8115695995227540918591177133606739237724591829175426900075118671527941456047488257049908299\\\n        0491312297889746397086083361625118924209880487666436844160872789514123895317920452925678027\\\n        7597810520028602516194421271297705634312768260197519167321745960256763360219826256892100808\\\n        1944855667091257528737125119080085592631176887680837517744653024363521274834692165422458986\\\n        1062517042681252582968986240751551041944533547263190561023591522603284832387406712887238529\\\n        1373073927546722736469219522612950133888704971058693114130935719034106453236601312328010609\\\n        8646815162879794545517964986689039448179963983254097809173637948296452222906447816773031749\\\n        0819410850670448075039505406703250253039214769072591939993068314351077164686993152712334065\\\n        0054764979233156891346041593972211130527058870153140449004003430210210108369170655037628865\\\n        5266738289939079249411893137923743207131654331337979221879437117652968461408510941832896381\\\n        7060143276727041922971949080953977653567193804161853619694137064794533640190145092141382316\\\n        3405999170707783410783087675682188065142974818640102076011385949818563813372616528648174101\\\n        4907990633728659922633550842446636931629444200404044052858958223971704265454174534805015725\\\n        23448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099789\",\n        \"-57739711438810971246200637147016281452930444563980729687880956795320096982015625991415924\\\n        0910613948128819306751528460134202356522267949891748413109564826318180061899042769424434268\\\n        6441210518605905268923723708819385558435427875593360629601880015198652087270170669300247364\\\n        8433006142123642574708330790770686080405456534859352760510449508056066302589778706063815430\\\n        37631781316565710346299551930891169154491973589315700505458672804104869879731391323700304\",\n    );\n\n    test(\"-123\", \"-1\", \"123\");\n    test(\"-123\", \"-123\", \"1\");\n    test(\"-56088\", \"-123\", \"456\");\n    test(\"-1000000000000\", \"-1\", \"1000000000000\");\n    test(\"-1000000000000\", \"-1000000000000\", \"1\");\n    test(\"-123000000000000\", \"-1000000000000\", \"123\");\n    test(\"-123000000000000\", \"-123\", \"1000000000000\");\n    test(\"-121932631112635269000000\", \"-123456789000\", \"987654321000\");\n    test(\"-8589934590\", \"-4294967295\", \"2\");\n    test(\"-18446744065119617025\", \"-4294967295\", \"4294967295\");\n    test(\n        \"-85167390638832534155095794307111191155780003684512955609936093881325960865026707945673997\\\n        8115695995227540918591177133606739237724591829175426900075118671527941456047488257049908299\\\n        0491312297889746397086083361625118924209880487666436844160872789514123895317920452925678027\\\n        7597810520028602516194421271297705634312768260197519167321745960256763360219826256892100808\\\n        1944855667091257528737125119080085592631176887680837517744653024363521274834692165422458986\\\n        1062517042681252582968986240751551041944533547263190561023591522603284832387406712887238529\\\n        1373073927546722736469219522612950133888704971058693114130935719034106453236601312328010609\\\n        8646815162879794545517964986689039448179963983254097809173637948296452222906447816773031749\\\n        0819410850670448075039505406703250253039214769072591939993068314351077164686993152712334065\\\n        0054764979233156891346041593972211130527058870153140449004003430210210108369170655037628865\\\n        5266738289939079249411893137923743207131654331337979221879437117652968461408510941832896381\\\n        7060143276727041922971949080953977653567193804161853619694137064794533640190145092141382316\\\n        3405999170707783410783087675682188065142974818640102076011385949818563813372616528648174101\\\n        4907990633728659922633550842446636931629444200404044052858958223971704265454174534805015725\\\n        23448224036804997350851153108395928780441635856\",\n        \"-14750227965563656560025035845269405189398018669695853517400995652385572010732263815974936\\\n        8080821747949474430587689097259577148476973385751452961609619939409285830226599826048341601\\\n        6576390452204426400593828107256814088351371325554864304425008611048361721593563653380924810\\\n        2692659078914207980563844549476017755177663674783001449501248974399040735523228684207141892\\\n        2992135840957348090162448797731978275542273083446867343807680553295282140602439900681439016\\\n        6694982753079697108601126786460781490631333452551810222191964304044026732368834188903586437\\\n        6137724664457908815322266967227141431524031843984372003980899388641087496934099664501079567\\\n        0213351871698766886593652982743738804219008430900536956471739072625759490261936518009750957\\\n        6624018903777061930820690641412868685634995095262397002303944032370164345741148566677635444\\\n        8186307133288106956593939073729500658176632828099789\",\n        \"577397114388109712462006371470162814529304445639807296878809567953200969820156259914159240\\\n        9106139481288193067515284601342023565222679498917484131095648263181800618990427694244342686\\\n        4412105186059052689237237088193855584354278755933606296018800151986520872701706693002473648\\\n        4330061421236425747083307907706860804054565348593527605104495080560663025897787060638154303\\\n        7631781316565710346299551930891169154491973589315700505458672804104869879731391323700304\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn div_exact_assign_fail() {\n    let mut n = Integer::from(10);\n    n.div_exact_assign(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_assign_ref_fail() {\n    let mut n = Integer::from(10);\n    n.div_exact_assign(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_fail() {\n    Integer::from(10).div_exact(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_val_ref_fail() {\n    Integer::from(10).div_exact(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_ref_val_fail() {\n    (&Integer::from(10)).div_exact(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_ref_ref_fail() {\n    (&Integer::from(10)).div_exact(&Integer::ZERO);\n}\n\n#[test]\nfn div_exact_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_2().test_properties_with_config(&config, |(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.div_exact_assign(&y);\n        assert!(mut_x.is_valid());\n        let q = mut_x;\n\n        let mut mut_x = x.clone();\n        mut_x.div_exact_assign(y.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, q);\n\n        let q_alt = (&x).div_exact(&y);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = (&x).div_exact(y.clone());\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = x.clone().div_exact(&y);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = x.clone().div_exact(y.clone());\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = (&x).div_round(&y, Exact).0;\n        assert_eq!(q_alt, q);\n\n        assert_eq!(\n            Integer::from(&rug::Integer::from(&x).div_exact(&rug::Integer::from(&y))),\n            q\n        );\n\n        assert_eq!(&q * &y, x);\n        assert_eq!((-&x).div_exact(&y), -&q);\n        assert_eq!(x.div_exact(-y), -q);\n    });\n\n    integer_gen().test_properties(|n| {\n        let n = &n;\n        assert_eq!(n.div_exact(Integer::ONE), *n);\n        assert_eq!(n.div_exact(Integer::NEGATIVE_ONE), -n);\n    });\n\n    integer_gen_var_8().test_properties(|n| {\n        let n = &n;\n        assert_eq!(Integer::ZERO.div_exact(n), 0);\n        assert_eq!(n.div_exact(n), 1);\n    });\n\n    natural_pair_gen_var_6().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(&x).div_exact(Integer::from(&y)),\n            x.div_exact(y)\n        );\n    });\n\n    signed_pair_gen_var_3::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).div_exact(Integer::from(y)), x.div_exact(y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivAssignMod, CeilingDivMod, CeilingDivNegMod, CeilingMod, DivAssignMod, DivAssignRem,\n    DivMod, DivRem, DivRound, Mod,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::signed_pair_gen_var_4;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_8, integer_pair_gen_var_1, integer_pair_gen_var_2,\n    natural_pair_gen_var_5,\n};\nuse num::{BigInt, Integer as NumInteger};\nuse std::str::FromStr;\n\n#[test]\nfn test_div_mod() {\n    let test = |s, t, quotient, remainder| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        let r = x.div_assign_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        let r = x.div_assign_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let (q, r) = u.clone().div_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = u.clone().div_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = BigInt::from_str(s)\n            .unwrap()\n            .div_mod_floor(&BigInt::from_str(t).unwrap());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = rug::Integer::from_str(s)\n            .unwrap()\n            .div_rem_floor(rug::Integer::from_str(t).unwrap());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = ((&u).div_round(&v, Floor).0, u.mod_op(v));\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\", \"0\");\n    test(\"1\", \"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"123\", \"0\");\n    test(\"123\", \"123\", \"1\", \"0\");\n    test(\"123\", \"456\", \"0\", \"123\");\n    test(\"456\", \"123\", \"3\", \"87\");\n    test(\"4294967295\", \"1\", \"4294967295\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"1\", \"0\");\n    test(\"1000000000000\", \"1\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"3\", \"333333333333\", \"1\");\n    test(\"1000000000000\", \"123\", \"8130081300\", \"100\");\n    test(\"1000000000000\", \"4294967295\", \"232\", \"3567587560\");\n    test(\n        \"1000000000000000000000000\",\n        \"1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"3\",\n        \"333333333333333333333333\",\n        \"1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"123\",\n        \"8130081300813008130081\",\n        \"37\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        \"232830643708079\",\n        \"3167723695\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1234567890987\",\n        \"810000006723\",\n        \"530068894399\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"94998781946290113\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"0\",\n        \"3768477692975601\",\n    );\n    test(\n        \"3356605361737854\",\n        \"3081095617839357\",\n        \"1\",\n        \"275509743898497\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"1\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"0\", \"123\");\n\n    test(\"0\", \"-1\", \"0\", \"0\");\n    test(\"0\", \"-123\", \"0\", \"0\");\n    test(\"1\", \"-1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"-123\", \"0\");\n    test(\"123\", \"-123\", \"-1\", \"0\");\n    test(\"123\", \"-456\", \"-1\", \"-333\");\n    test(\"456\", \"-123\", \"-4\", \"-36\");\n    test(\"4294967295\", \"-1\", \"-4294967295\", \"0\");\n    test(\"4294967295\", \"-4294967295\", \"-1\", \"0\");\n    test(\"1000000000000\", \"-1\", \"-1000000000000\", \"0\");\n    test(\"1000000000000\", \"-3\", \"-333333333334\", \"-2\");\n    test(\"1000000000000\", \"-123\", \"-8130081301\", \"-23\");\n    test(\"1000000000000\", \"-4294967295\", \"-233\", \"-727379735\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-3\",\n        \"-333333333333333333333334\",\n        \"-2\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-123\",\n        \"-8130081300813008130082\",\n        \"-86\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        \"-232830643708080\",\n        \"-1127243600\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1234567890987\",\n        \"-810000006724\",\n        \"-704498996588\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         0\",\n        \"-1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018655\",\n        \"-454912836989613466895606299668358255\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         0\",\n        \"-316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253980\",\n        \"-278232688309211835744673381771890580480\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"-94998781946290114\",\n        \"-1149635115107\",\n    );\n    test(\n        \"3768477692975601\",\n        \"-11447376614057827956\",\n        \"-1\",\n        \"-11443608136364852355\",\n    );\n    test(\n        \"3356605361737854\",\n        \"-3081095617839357\",\n        \"-2\",\n        \"-2805585873940860\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"-2\",\n        \"-808034397882141086757\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"-1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\", \"0\");\n    test(\n        \"123\",\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"-999999999999999999999877\",\n    );\n\n    test(\"-1\", \"1\", \"-1\", \"0\");\n    test(\"-123\", \"1\", \"-123\", \"0\");\n    test(\"-123\", \"123\", \"-1\", \"0\");\n    test(\"-123\", \"456\", \"-1\", \"333\");\n    test(\"-456\", \"123\", \"-4\", \"36\");\n    test(\"-4294967295\", \"-1\", \"4294967295\", \"0\");\n    test(\"-4294967295\", \"4294967295\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"1\", \"-1000000000000\", \"0\");\n    test(\"-1000000000000\", \"3\", \"-333333333334\", \"2\");\n    test(\"-1000000000000\", \"123\", \"-8130081301\", \"23\");\n    test(\"-1000000000000\", \"4294967295\", \"-233\", \"727379735\");\n    test(\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"3\",\n        \"-333333333333333333333334\",\n        \"2\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"123\",\n        \"-8130081300813008130082\",\n        \"86\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        \"-232830643708080\",\n        \"1127243600\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1234567890987\",\n        \"-810000006724\",\n        \"704498996588\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018655\",\n        \"454912836989613466895606299668358255\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253980\",\n        \"278232688309211835744673381771890580480\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"2669936877441\",\n        \"-94998781946290114\",\n        \"1149635115107\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"11447376614057827956\",\n        \"-1\",\n        \"11443608136364852355\",\n    );\n    test(\n        \"-3356605361737854\",\n        \"3081095617839357\",\n        \"-2\",\n        \"2805585873940860\",\n    );\n    test(\n        \"-1098730198198174614195\",\n        \"953382298040157850476\",\n        \"-2\",\n        \"808034397882141086757\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"-1\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"0\",\n    );\n    test(\n        \"-123\",\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"999999999999999999999877\",\n    );\n\n    test(\"-1\", \"-1\", \"1\", \"0\");\n    test(\"-123\", \"-1\", \"123\", \"0\");\n    test(\"-123\", \"-123\", \"1\", \"0\");\n    test(\"-123\", \"-456\", \"0\", \"-123\");\n    test(\"-456\", \"-123\", \"3\", \"-87\");\n    test(\"-4294967295\", \"-1\", \"4294967295\", \"0\");\n    test(\"-4294967295\", \"-4294967295\", \"1\", \"0\");\n    test(\"-1000000000000\", \"-1\", \"1000000000000\", \"0\");\n    test(\"-1000000000000\", \"-3\", \"333333333333\", \"-1\");\n    test(\"-1000000000000\", \"-123\", \"8130081300\", \"-100\");\n    test(\"-1000000000000\", \"-4294967295\", \"232\", \"-3567587560\");\n    test(\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-3\",\n        \"333333333333333333333333\",\n        \"-1\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-123\",\n        \"8130081300813008130081\",\n        \"-37\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        \"232830643708079\",\n        \"-3167723695\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1234567890987\",\n        \"810000006723\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"94998781946290113\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"-11447376614057827956\",\n        \"0\",\n        \"-3768477692975601\",\n    );\n    test(\n        \"-3356605361737854\",\n        \"-3081095617839357\",\n        \"1\",\n        \"-275509743898497\",\n    );\n    test(\n        \"-1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"1\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"-123\", \"-1000000000000000000000000\", \"0\", \"-123\");\n}\n\n#[test]\n#[should_panic]\nfn div_assign_mod_fail() {\n    Integer::from(10).div_assign_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_assign_mod_ref_fail() {\n    Integer::from(10).div_assign_mod(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_fail() {\n    Integer::from(10).div_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_val_ref_fail() {\n    Integer::from(10).div_mod(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_ref_val_fail() {\n    (&Integer::from(10)).div_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_ref_ref_fail() {\n    (&Integer::from(10)).div_mod(&Integer::ZERO);\n}\n\n#[test]\nfn test_div_rem() {\n    let test = |s, t, quotient, remainder| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        let r = x.div_assign_rem(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        let r = x.div_assign_rem(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let (q, r) = u.clone().div_rem(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = u.clone().div_rem(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_rem(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_rem(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = BigInt::from_str(s)\n            .unwrap()\n            .div_rem(&BigInt::from_str(t).unwrap());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = rug::Integer::from_str(s)\n            .unwrap()\n            .div_rem(rug::Integer::from_str(t).unwrap());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (u.clone() / v.clone(), u % v);\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\", \"0\");\n    test(\"1\", \"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"123\", \"0\");\n    test(\"123\", \"123\", \"1\", \"0\");\n    test(\"123\", \"456\", \"0\", \"123\");\n    test(\"456\", \"123\", \"3\", \"87\");\n    test(\"4294967295\", \"1\", \"4294967295\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"1\", \"0\");\n    test(\"1000000000000\", \"1\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"3\", \"333333333333\", \"1\");\n    test(\"1000000000000\", \"123\", \"8130081300\", \"100\");\n    test(\"1000000000000\", \"4294967295\", \"232\", \"3567587560\");\n    test(\n        \"1000000000000000000000000\",\n        \"1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"3\",\n        \"333333333333333333333333\",\n        \"1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"123\",\n        \"8130081300813008130081\",\n        \"37\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        \"232830643708079\",\n        \"3167723695\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1234567890987\",\n        \"810000006723\",\n        \"530068894399\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"94998781946290113\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"0\",\n        \"3768477692975601\",\n    );\n    test(\n        \"3356605361737854\",\n        \"3081095617839357\",\n        \"1\",\n        \"275509743898497\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"1\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"0\", \"123\");\n\n    test(\"0\", \"-1\", \"0\", \"0\");\n    test(\"0\", \"-123\", \"0\", \"0\");\n    test(\"1\", \"-1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"-123\", \"0\");\n    test(\"123\", \"-123\", \"-1\", \"0\");\n    test(\"123\", \"-456\", \"0\", \"123\");\n    test(\"456\", \"-123\", \"-3\", \"87\");\n    test(\"4294967295\", \"-1\", \"-4294967295\", \"0\");\n    test(\"4294967295\", \"-4294967295\", \"-1\", \"0\");\n    test(\"1000000000000\", \"-1\", \"-1000000000000\", \"0\");\n    test(\"1000000000000\", \"-3\", \"-333333333333\", \"1\");\n    test(\"1000000000000\", \"-123\", \"-8130081300\", \"100\");\n    test(\"1000000000000\", \"-4294967295\", \"-232\", \"3567587560\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-3\",\n        \"-333333333333333333333333\",\n        \"1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-123\",\n        \"-8130081300813008130081\",\n        \"37\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        \"-232830643708079\",\n        \"3167723695\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1234567890987\",\n        \"-810000006723\",\n        \"530068894399\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018654\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253979\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"-94998781946290113\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"-11447376614057827956\",\n        \"0\",\n        \"3768477692975601\",\n    );\n    test(\n        \"3356605361737854\",\n        \"-3081095617839357\",\n        \"-1\",\n        \"275509743898497\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"-1\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"-1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\", \"0\");\n    test(\"123\", \"-1000000000000000000000000\", \"0\", \"123\");\n\n    test(\"-1\", \"1\", \"-1\", \"0\");\n    test(\"-123\", \"1\", \"-123\", \"0\");\n    test(\"-123\", \"123\", \"-1\", \"0\");\n    test(\"-123\", \"456\", \"0\", \"-123\");\n    test(\"-456\", \"123\", \"-3\", \"-87\");\n    test(\"-4294967295\", \"1\", \"-4294967295\", \"0\");\n    test(\"-4294967295\", \"4294967295\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"1\", \"-1000000000000\", \"0\");\n    test(\"-1000000000000\", \"3\", \"-333333333333\", \"-1\");\n    test(\"-1000000000000\", \"123\", \"-8130081300\", \"-100\");\n    test(\"-1000000000000\", \"4294967295\", \"-232\", \"-3567587560\");\n    test(\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"3\",\n        \"-333333333333333333333333\",\n        \"-1\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"123\",\n        \"-8130081300813008130081\",\n        \"-37\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        \"-232830643708079\",\n        \"-3167723695\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1234567890987\",\n        \"-810000006723\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018654\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253979\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"2669936877441\",\n        \"-94998781946290113\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"11447376614057827956\",\n        \"0\",\n        \"-3768477692975601\",\n    );\n    test(\n        \"-3356605361737854\",\n        \"3081095617839357\",\n        \"-1\",\n        \"-275509743898497\",\n    );\n    test(\n        \"-1098730198198174614195\",\n        \"953382298040157850476\",\n        \"-1\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"-1\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"0\",\n    );\n    test(\"-123\", \"1000000000000000000000000\", \"0\", \"-123\");\n\n    test(\"-1\", \"-1\", \"1\", \"0\");\n    test(\"-123\", \"-1\", \"123\", \"0\");\n    test(\"-123\", \"-123\", \"1\", \"0\");\n    test(\"-123\", \"-456\", \"0\", \"-123\");\n    test(\"-456\", \"-123\", \"3\", \"-87\");\n    test(\"-4294967295\", \"-1\", \"4294967295\", \"0\");\n    test(\"-4294967295\", \"-4294967295\", \"1\", \"0\");\n    test(\"-1000000000000\", \"-1\", \"1000000000000\", \"0\");\n    test(\"-1000000000000\", \"-3\", \"333333333333\", \"-1\");\n    test(\"-1000000000000\", \"-123\", \"8130081300\", \"-100\");\n    test(\"-1000000000000\", \"-4294967295\", \"232\", \"-3567587560\");\n    test(\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-3\",\n        \"333333333333333333333333\",\n        \"-1\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-123\",\n        \"8130081300813008130081\",\n        \"-37\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        \"232830643708079\",\n        \"-3167723695\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1234567890987\",\n        \"810000006723\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"94998781946290113\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"-11447376614057827956\",\n        \"0\",\n        \"-3768477692975601\",\n    );\n    test(\n        \"-3356605361737854\",\n        \"-3081095617839357\",\n        \"1\",\n        \"-275509743898497\",\n    );\n    test(\n        \"-1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"1\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"-123\", \"-1000000000000000000000000\", \"0\", \"-123\");\n}\n\n#[test]\n#[should_panic]\nfn div_assign_rem_fail() {\n    Integer::from(10).div_assign_rem(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_assign_rem_ref_fail() {\n    Integer::from(10).div_assign_rem(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_fail() {\n    Integer::from(10).div_rem(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_val_ref_fail() {\n    Integer::from(10).div_rem(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_ref_val_fail() {\n    (&Integer::from(10)).div_rem(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_ref_ref_fail() {\n    (&Integer::from(10)).div_rem(&Integer::ZERO);\n}\n\n#[test]\nfn test_ceiling_div_mod() {\n    let test = |s, t, quotient, remainder| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        let r = x.ceiling_div_assign_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        let r = x.ceiling_div_assign_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let (q, r) = u.clone().ceiling_div_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = u.clone().ceiling_div_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).ceiling_div_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).ceiling_div_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = rug::Integer::from_str(s)\n            .unwrap()\n            .div_rem_ceil(rug::Integer::from_str(t).unwrap());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (u.clone().div_round(v.clone(), Ceiling).0, u.ceiling_mod(v));\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\", \"0\");\n    test(\"1\", \"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"123\", \"0\");\n    test(\"123\", \"123\", \"1\", \"0\");\n    test(\"123\", \"456\", \"1\", \"-333\");\n    test(\"456\", \"123\", \"4\", \"-36\");\n    test(\"4294967295\", \"1\", \"4294967295\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"1\", \"0\");\n    test(\"1000000000000\", \"1\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"3\", \"333333333334\", \"-2\");\n    test(\"1000000000000\", \"123\", \"8130081301\", \"-23\");\n    test(\"1000000000000\", \"4294967295\", \"233\", \"-727379735\");\n    test(\n        \"1000000000000000000000000\",\n        \"1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"3\",\n        \"333333333333333333333334\",\n        \"-2\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"123\",\n        \"8130081300813008130082\",\n        \"-86\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        \"232830643708080\",\n        \"-1127243600\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1234567890987\",\n        \"810000006724\",\n        \"-704498996588\",\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018655\",\n        \"-454912836989613466895606299668358255\",\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253980\",\n        \"-278232688309211835744673381771890580480\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"94998781946290114\",\n        \"-1149635115107\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"1\",\n        \"-11443608136364852355\",\n    );\n    test(\n        \"3356605361737854\",\n        \"3081095617839357\",\n        \"2\",\n        \"-2805585873940860\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"2\",\n        \"-808034397882141086757\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\", \"0\");\n    test(\n        \"123\",\n        \"1000000000000000000000000\",\n        \"1\",\n        \"-999999999999999999999877\",\n    );\n\n    test(\"0\", \"-1\", \"0\", \"0\");\n    test(\"0\", \"-123\", \"0\", \"0\");\n    test(\"1\", \"-1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"-123\", \"0\");\n    test(\"123\", \"-123\", \"-1\", \"0\");\n    test(\"123\", \"-456\", \"0\", \"123\");\n    test(\"456\", \"-123\", \"-3\", \"87\");\n    test(\"4294967295\", \"-1\", \"-4294967295\", \"0\");\n    test(\"4294967295\", \"-4294967295\", \"-1\", \"0\");\n    test(\"1000000000000\", \"-1\", \"-1000000000000\", \"0\");\n    test(\"1000000000000\", \"-3\", \"-333333333333\", \"1\");\n    test(\"1000000000000\", \"-123\", \"-8130081300\", \"100\");\n    test(\"1000000000000\", \"-4294967295\", \"-232\", \"3567587560\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-3\",\n        \"-333333333333333333333333\",\n        \"1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-123\",\n        \"-8130081300813008130081\",\n        \"37\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        \"-232830643708079\",\n        \"3167723695\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1234567890987\",\n        \"-810000006723\",\n        \"530068894399\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018654\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253979\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"-94998781946290113\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"-11447376614057827956\",\n        \"0\",\n        \"3768477692975601\",\n    );\n    test(\n        \"3356605361737854\",\n        \"-3081095617839357\",\n        \"-1\",\n        \"275509743898497\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"-1\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"-1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\", \"0\");\n    test(\"123\", \"-1000000000000000000000000\", \"0\", \"123\");\n\n    test(\"-1\", \"1\", \"-1\", \"0\");\n    test(\"-123\", \"1\", \"-123\", \"0\");\n    test(\"-123\", \"123\", \"-1\", \"0\");\n    test(\"-123\", \"456\", \"0\", \"-123\");\n    test(\"-456\", \"123\", \"-3\", \"-87\");\n    test(\"-4294967295\", \"1\", \"-4294967295\", \"0\");\n    test(\"-4294967295\", \"4294967295\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"1\", \"-1000000000000\", \"0\");\n    test(\"-1000000000000\", \"3\", \"-333333333333\", \"-1\");\n    test(\"-1000000000000\", \"123\", \"-8130081300\", \"-100\");\n    test(\"-1000000000000\", \"4294967295\", \"-232\", \"-3567587560\");\n    test(\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"3\",\n        \"-333333333333333333333333\",\n        \"-1\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"123\",\n        \"-8130081300813008130081\",\n        \"-37\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        \"-232830643708079\",\n        \"-3167723695\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1234567890987\",\n        \"-810000006723\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"1234567890987654321234567890987654321\",\n        \"-810000006723000055638900467181273922269593923137018654\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"316049380092839506236049380092839506176\",\n        \"-3164062526261718967339454949926851258865601262253979\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"2669936877441\",\n        \"-94998781946290113\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"11447376614057827956\",\n        \"0\",\n        \"-3768477692975601\",\n    );\n    test(\n        \"-3356605361737854\",\n        \"3081095617839357\",\n        \"-1\",\n        \"-275509743898497\",\n    );\n    test(\n        \"-1098730198198174614195\",\n        \"953382298040157850476\",\n        \"-1\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"-1\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"-1\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\", \"0\");\n    test(\"-123\", \"1000000000000000000000000\", \"0\", \"-123\");\n\n    test(\"-1\", \"-1\", \"1\", \"0\");\n    test(\"-123\", \"-1\", \"123\", \"0\");\n    test(\"-123\", \"-123\", \"1\", \"0\");\n    test(\"-123\", \"-456\", \"1\", \"333\");\n    test(\"-456\", \"-123\", \"4\", \"36\");\n    test(\"-4294967295\", \"-1\", \"4294967295\", \"0\");\n    test(\"-4294967295\", \"-4294967295\", \"1\", \"0\");\n    test(\"-1000000000000\", \"-1\", \"1000000000000\", \"0\");\n    test(\"-1000000000000\", \"-3\", \"333333333334\", \"2\");\n    test(\"-1000000000000\", \"-123\", \"8130081301\", \"23\");\n    test(\"-1000000000000\", \"-4294967295\", \"233\", \"727379735\");\n    test(\n        \"-1000000000000000000000000\",\n        \"-1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-3\",\n        \"333333333333333333333334\",\n        \"2\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-123\",\n        \"8130081300813008130082\",\n        \"86\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        \"232830643708080\",\n        \"1127243600\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1234567890987\",\n        \"810000006724\",\n        \"704498996588\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"-1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018655\",\n        \"454912836989613466895606299668358255\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"-316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253980\",\n        \"278232688309211835744673381771890580480\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"94998781946290114\",\n        \"1149635115107\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"-11447376614057827956\",\n        \"1\",\n        \"11443608136364852355\",\n    );\n    test(\n        \"-3356605361737854\",\n        \"-3081095617839357\",\n        \"2\",\n        \"2805585873940860\",\n    );\n    test(\n        \"-1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"2\",\n        \"808034397882141086757\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\", \"0\");\n    test(\n        \"-123\",\n        \"-1000000000000000000000000\",\n        \"1\",\n        \"999999999999999999999877\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_assign_mod_fail() {\n    Integer::from(10).ceiling_div_assign_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_assign_mod_ref_fail() {\n    Integer::from(10).ceiling_div_assign_mod(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_mod_fail() {\n    Integer::from(10).ceiling_div_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_mod_val_ref_fail() {\n    Integer::from(10).ceiling_div_mod(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_mod_ref_val_fail() {\n    (&Integer::from(10)).ceiling_div_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_mod_ref_ref_fail() {\n    (&Integer::from(10)).ceiling_div_mod(&Integer::ZERO);\n}\n\nfn div_mod_properties_helper(x: Integer, y: Integer) {\n    let mut mut_x = x.clone();\n    let r = mut_x.div_assign_mod(&y);\n    assert!(mut_x.is_valid());\n    assert!(r.is_valid());\n    let q = mut_x;\n\n    let mut mut_x = x.clone();\n    let r_alt = mut_x.div_assign_mod(y.clone());\n    let q_alt = mut_x;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = ((&x).div_round(&y, Floor).0, (&x).mod_op(&y));\n    assert_eq!(q_alt, q);\n    assert_eq!(r_alt, r);\n\n    let (num_q, num_r) = BigInt::from(&x).div_mod_floor(&BigInt::from(&y));\n    assert_eq!(Integer::from(&num_q), q);\n    assert_eq!(Integer::from(&num_r), r);\n\n    let (rug_q, rug_r) = rug::Integer::from(&x).div_rem_floor(rug::Integer::from(&y));\n    assert_eq!(Integer::from(&rug_q), q);\n    assert_eq!(Integer::from(&rug_r), r);\n\n    assert!(r.lt_abs(&y));\n    assert!(r == 0 || (r > 0) == (y > 0));\n    assert_eq!(q * &y + r, x);\n\n    let (neg_q, neg_r) = (-&x).div_mod(&y);\n    assert_eq!((&x).ceiling_div_mod(&y), (-neg_q, -neg_r));\n\n    let (neg_q, r) = (&x).div_mod(-&y);\n    assert_eq!(x.ceiling_div_mod(y), (-neg_q, r));\n}\n\n#[test]\nfn div_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_1()\n        .test_properties_with_config(&config, |(x, y)| div_mod_properties_helper(x, y));\n\n    integer_pair_gen_var_2()\n        .test_properties_with_config(&config, |(x, y)| div_mod_properties_helper(x, y));\n\n    integer_gen().test_properties(|x| {\n        let (q, r) = (&x).div_mod(Integer::ONE);\n        assert_eq!(q, x);\n        assert_eq!(r, 0);\n\n        let (q, r) = (&x).div_mod(Integer::NEGATIVE_ONE);\n        assert_eq!(q, -x);\n        assert_eq!(r, 0);\n    });\n\n    integer_gen_var_8().test_properties(|ref x| {\n        assert_eq!(x.div_mod(Integer::ONE), (x.clone(), Integer::ZERO));\n        assert_eq!(x.div_mod(Integer::NEGATIVE_ONE), (-x, Integer::ZERO));\n        assert_eq!(x.div_mod(x), (Integer::ONE, Integer::ZERO));\n        assert_eq!(x.div_mod(-x), (Integer::NEGATIVE_ONE, Integer::ZERO));\n        assert_eq!(Integer::ZERO.div_mod(x), (Integer::ZERO, Integer::ZERO));\n        if *x > 1 {\n            assert_eq!(Integer::ONE.div_mod(x), (Integer::ZERO, Integer::ONE));\n            assert_eq!(\n                Integer::NEGATIVE_ONE.div_mod(x),\n                (Integer::NEGATIVE_ONE, x - Integer::ONE)\n            );\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        let (q, r) = (&x).div_mod(&y);\n        assert_eq!(\n            Integer::from(x).div_mod(Integer::from(y)),\n            (Integer::from(q), Integer::from(r))\n        );\n    });\n\n    signed_pair_gen_var_4::<SignedLimb>().test_properties(|(x, y)| {\n        let (q, r) = x.div_mod(y);\n        assert_eq!(\n            Integer::from(x).div_mod(Integer::from(y)),\n            (Integer::from(q), Integer::from(r))\n        );\n    });\n}\n\nfn div_rem_properties_helper(x: Integer, y: Integer) {\n    let mut mut_x = x.clone();\n    let r = mut_x.div_assign_rem(&y);\n    assert!(mut_x.is_valid());\n    assert!(r.is_valid());\n    let q = mut_x;\n\n    let mut q_alt = x.clone();\n    let r_alt = q_alt.div_assign_rem(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_rem(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_rem(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_rem(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_rem(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x / &y, &x % &y);\n    assert_eq!(q_alt, q);\n    assert_eq!(r_alt, r);\n\n    let (num_q, num_r) = BigInt::from(&x).div_rem(&BigInt::from(&y));\n    assert_eq!(Integer::from(&num_q), q);\n    assert_eq!(Integer::from(&num_r), r);\n\n    let (rug_q, rug_r) = rug::Integer::from(&x).div_rem(rug::Integer::from(&y));\n    assert_eq!(Integer::from(&rug_q), q);\n    assert_eq!(Integer::from(&rug_r), r);\n\n    assert!(r.lt_abs(&y));\n    assert!(r == 0 || (r > 0) == (x > 0));\n    assert_eq!(&q * &y + &r, x);\n\n    assert_eq!((-&x).div_rem(&y), (-&q, -&r));\n    assert_eq!(x.div_rem(-y), (-q, r));\n}\n\n#[test]\nfn div_rem_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_1()\n        .test_properties_with_config(&config, |(x, y)| div_rem_properties_helper(x, y));\n\n    integer_pair_gen_var_2()\n        .test_properties_with_config(&config, |(x, y)| div_rem_properties_helper(x, y));\n\n    integer_gen().test_properties(|x| {\n        let (q, r) = (&x).div_rem(Integer::ONE);\n        assert_eq!(q, x);\n        assert_eq!(r, 0);\n\n        let (q, r) = (&x).div_rem(Integer::NEGATIVE_ONE);\n        assert_eq!(q, -x);\n        assert_eq!(r, 0);\n    });\n\n    integer_gen_var_8().test_properties(|ref x| {\n        assert_eq!(x.div_rem(Integer::ONE), (x.clone(), Integer::ZERO));\n        assert_eq!(x.div_rem(Integer::NEGATIVE_ONE), (-x, Integer::ZERO));\n        assert_eq!(x.div_rem(x), (Integer::ONE, Integer::ZERO));\n        assert_eq!(x.div_rem(-x), (Integer::NEGATIVE_ONE, Integer::ZERO));\n        assert_eq!(Integer::ZERO.div_rem(x), (Integer::ZERO, Integer::ZERO));\n        if *x > 1 {\n            assert_eq!(Integer::ONE.div_rem(x), (Integer::ZERO, Integer::ONE));\n            assert_eq!(\n                Integer::NEGATIVE_ONE.div_rem(x),\n                (Integer::ZERO, Integer::NEGATIVE_ONE)\n            );\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        let (q, r) = (&x).div_rem(&y);\n        assert_eq!(\n            Integer::from(x).div_rem(Integer::from(y)),\n            (Integer::from(q), Integer::from(r))\n        );\n    });\n\n    signed_pair_gen_var_4::<SignedLimb>().test_properties(|(x, y)| {\n        let (q, r) = x.div_rem(y);\n        assert_eq!(\n            Integer::from(x).div_rem(Integer::from(y)),\n            (Integer::from(q), Integer::from(r))\n        );\n    });\n}\n\nfn ceiling_div_mod_properties_helper(x: Integer, y: Integer) {\n    let mut mut_x = x.clone();\n    let r = mut_x.ceiling_div_assign_mod(&y);\n    assert!(mut_x.is_valid());\n    assert!(r.is_valid());\n    let q = mut_x;\n\n    let mut mut_x = x.clone();\n    let r_alt = mut_x.ceiling_div_assign_mod(y.clone());\n    let q_alt = mut_x;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).ceiling_div_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).ceiling_div_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().ceiling_div_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().ceiling_div_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = ((&x).div_round(&y, Ceiling).0, (&x).ceiling_mod(&y));\n    assert_eq!(q_alt, q);\n    assert_eq!(r_alt, r);\n\n    let (rug_q, rug_r) = rug::Integer::from(&x).div_rem_ceil(rug::Integer::from(&y));\n    assert_eq!(Integer::from(&rug_q), q);\n    assert_eq!(Integer::from(&rug_r), r);\n\n    assert!(r.lt_abs(&y));\n    assert!(r == 0 || (r > 0) != (y > 0));\n    assert_eq!(q * &y + r, x);\n\n    let (neg_q, neg_r) = (-&x).ceiling_div_mod(&y);\n    assert_eq!((&x).div_mod(&y), (-neg_q, -neg_r));\n\n    let (neg_q, r) = (&x).ceiling_div_mod(-&y);\n    assert_eq!(x.div_mod(y), (-neg_q, r));\n}\n\n#[test]\nfn ceiling_div_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_1()\n        .test_properties_with_config(&config, |(x, y)| ceiling_div_mod_properties_helper(x, y));\n\n    integer_pair_gen_var_2()\n        .test_properties_with_config(&config, |(x, y)| ceiling_div_mod_properties_helper(x, y));\n\n    integer_gen().test_properties(|x| {\n        let (q, r) = (&x).ceiling_div_mod(Integer::ONE);\n        assert_eq!(q, x);\n        assert_eq!(r, 0);\n\n        let (q, r) = (&x).ceiling_div_mod(Integer::NEGATIVE_ONE);\n        assert_eq!(q, -x);\n        assert_eq!(r, 0);\n    });\n\n    integer_gen_var_8().test_properties(|ref x| {\n        assert_eq!(x.ceiling_div_mod(Integer::ONE), (x.clone(), Integer::ZERO));\n        assert_eq!(\n            x.ceiling_div_mod(Integer::NEGATIVE_ONE),\n            (-x, Integer::ZERO)\n        );\n        assert_eq!(x.ceiling_div_mod(x), (Integer::ONE, Integer::ZERO));\n        assert_eq!(\n            x.ceiling_div_mod(-x),\n            (Integer::NEGATIVE_ONE, Integer::ZERO)\n        );\n        assert_eq!(\n            Integer::ZERO.ceiling_div_mod(x),\n            (Integer::ZERO, Integer::ZERO)\n        );\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        let (q, r) = (&x).ceiling_div_neg_mod(&y);\n        assert_eq!(\n            Integer::from(x).ceiling_div_mod(Integer::from(y)),\n            (Integer::from(q), -r)\n        );\n    });\n\n    signed_pair_gen_var_4::<SignedLimb>().test_properties(|(x, y)| {\n        let (q, r) = x.ceiling_div_mod(y);\n        assert_eq!(\n            Integer::from(x).ceiling_div_mod(Integer::from(y)),\n            (Integer::from(q), Integer::from(r))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivRound, DivRoundAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::signed_signed_rounding_mode_triple_gen_var_1;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_integer_rounding_mode_triple_gen_var_1, integer_pair_gen_var_1, integer_pair_gen_var_3,\n    integer_rounding_mode_pair_gen, integer_rounding_mode_pair_gen_var_2,\n    natural_natural_rounding_mode_triple_gen_var_1,\n};\nuse num::{BigInt, Integer as NumInteger};\nuse rug::ops::DivRounding;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_div_round() {\n    let test = |s, t, rm, quotient, o| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        assert_eq!(x.div_round_assign(v.clone(), rm), o);\n        assert_eq!(x.to_string(), quotient);\n        assert!(x.is_valid());\n\n        let mut x = u.clone();\n        assert_eq!(x.div_round_assign(&v, rm), o);\n        assert_eq!(x.to_string(), quotient);\n        assert!(x.is_valid());\n\n        let (q, o_alt) = u.clone().div_round(v.clone(), rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (q, o_alt) = u.clone().div_round(&v, rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (q, o_alt) = (&u).div_round(v.clone(), rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (q, o_alt) = (&u).div_round(&v, rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n        match rm {\n            Down => {\n                assert_eq!(\n                    rug::Integer::from_str(s)\n                        .unwrap()\n                        .div_trunc(rug::Integer::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n            }\n            Floor => {\n                assert_eq!(\n                    BigInt::from_str(s)\n                        .unwrap()\n                        .div_floor(&BigInt::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n                assert_eq!(\n                    rug::Integer::from_str(s)\n                        .unwrap()\n                        .div_floor(rug::Integer::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n            }\n            Ceiling => {\n                assert_eq!(\n                    rug::Integer::from_str(s)\n                        .unwrap()\n                        .div_ceil(rug::Integer::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n            }\n            _ => {}\n        }\n    };\n    test(\"0\", \"1\", Down, \"0\", Equal);\n    test(\"0\", \"1\", Floor, \"0\", Equal);\n    test(\"0\", \"1\", Up, \"0\", Equal);\n    test(\"0\", \"1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"1\", Nearest, \"0\", Equal);\n    test(\"0\", \"1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"123\", Down, \"0\", Equal);\n    test(\"0\", \"123\", Floor, \"0\", Equal);\n    test(\"0\", \"123\", Up, \"0\", Equal);\n    test(\"0\", \"123\", Ceiling, \"0\", Equal);\n    test(\"0\", \"123\", Nearest, \"0\", Equal);\n    test(\"0\", \"123\", Exact, \"0\", Equal);\n\n    test(\"1\", \"1\", Down, \"1\", Equal);\n    test(\"1\", \"1\", Floor, \"1\", Equal);\n    test(\"1\", \"1\", Up, \"1\", Equal);\n    test(\"1\", \"1\", Ceiling, \"1\", Equal);\n    test(\"1\", \"1\", Nearest, \"1\", Equal);\n    test(\"1\", \"1\", Exact, \"1\", Equal);\n\n    test(\"123\", \"1\", Down, \"123\", Equal);\n    test(\"123\", \"1\", Floor, \"123\", Equal);\n    test(\"123\", \"1\", Up, \"123\", Equal);\n    test(\"123\", \"1\", Ceiling, \"123\", Equal);\n    test(\"123\", \"1\", Nearest, \"123\", Equal);\n    test(\"123\", \"1\", Exact, \"123\", Equal);\n\n    test(\"123\", \"2\", Down, \"61\", Less);\n    test(\"123\", \"2\", Floor, \"61\", Less);\n    test(\"123\", \"2\", Up, \"62\", Greater);\n    test(\"123\", \"2\", Ceiling, \"62\", Greater);\n    test(\"123\", \"2\", Nearest, \"62\", Greater);\n\n    test(\"125\", \"2\", Down, \"62\", Less);\n    test(\"125\", \"2\", Floor, \"62\", Less);\n    test(\"125\", \"2\", Up, \"63\", Greater);\n    test(\"125\", \"2\", Ceiling, \"63\", Greater);\n    test(\"125\", \"2\", Nearest, \"62\", Less);\n\n    test(\"123\", \"123\", Down, \"1\", Equal);\n    test(\"123\", \"123\", Floor, \"1\", Equal);\n    test(\"123\", \"123\", Up, \"1\", Equal);\n    test(\"123\", \"123\", Ceiling, \"1\", Equal);\n    test(\"123\", \"123\", Nearest, \"1\", Equal);\n    test(\"123\", \"123\", Exact, \"1\", Equal);\n\n    test(\"123\", \"456\", Down, \"0\", Less);\n    test(\"123\", \"456\", Floor, \"0\", Less);\n    test(\"123\", \"456\", Up, \"1\", Greater);\n    test(\"123\", \"456\", Ceiling, \"1\", Greater);\n    test(\"123\", \"456\", Nearest, \"0\", Less);\n\n    test(\"1000000000000\", \"1\", Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Exact, \"1000000000000\", Equal);\n\n    test(\"1000000000000\", \"3\", Down, \"333333333333\", Less);\n    test(\"1000000000000\", \"3\", Floor, \"333333333333\", Less);\n    test(\"1000000000000\", \"3\", Up, \"333333333334\", Greater);\n    test(\"1000000000000\", \"3\", Ceiling, \"333333333334\", Greater);\n    test(\"1000000000000\", \"3\", Nearest, \"333333333333\", Less);\n\n    test(\"999999999999\", \"2\", Down, \"499999999999\", Less);\n    test(\"999999999999\", \"2\", Floor, \"499999999999\", Less);\n    test(\"999999999999\", \"2\", Up, \"500000000000\", Greater);\n    test(\"999999999999\", \"2\", Ceiling, \"500000000000\", Greater);\n    test(\"999999999999\", \"2\", Nearest, \"500000000000\", Greater);\n\n    test(\"1000000000001\", \"2\", Down, \"500000000000\", Less);\n    test(\"1000000000001\", \"2\", Floor, \"500000000000\", Less);\n    test(\"1000000000001\", \"2\", Up, \"500000000001\", Greater);\n    test(\"1000000000001\", \"2\", Ceiling, \"500000000001\", Greater);\n    test(\"1000000000001\", \"2\", Nearest, \"500000000000\", Less);\n\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Down,\n        \"232830643708079\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Floor,\n        \"232830643708079\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Up,\n        \"232830643708080\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Ceiling,\n        \"232830643708080\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Nearest,\n        \"232830643708080\",\n        Greater,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Down,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Floor,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Up,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Exact,\n        \"1000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Down,\n        \"999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Floor,\n        \"999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Up,\n        \"1000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Ceiling,\n        \"1000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Nearest,\n        \"999999999999\",\n        Less,\n    );\n\n    test(\n        \"2999999999999999999999999\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"1\",\n        Less,\n    );\n    test(\n        \"3000000000000000000000000\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"2\",\n        Greater,\n    );\n    test(\n        \"3000000000000000000000001\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"2\",\n        Greater,\n    );\n\n    test(\"0\", \"-1\", Down, \"0\", Equal);\n    test(\"0\", \"-1\", Floor, \"0\", Equal);\n    test(\"0\", \"-1\", Up, \"0\", Equal);\n    test(\"0\", \"-1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"-1\", Nearest, \"0\", Equal);\n    test(\"0\", \"-1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"-123\", Down, \"0\", Equal);\n    test(\"0\", \"-123\", Floor, \"0\", Equal);\n    test(\"0\", \"-123\", Up, \"0\", Equal);\n    test(\"0\", \"-123\", Ceiling, \"0\", Equal);\n    test(\"0\", \"-123\", Nearest, \"0\", Equal);\n    test(\"0\", \"-123\", Exact, \"0\", Equal);\n\n    test(\"1\", \"-1\", Down, \"-1\", Equal);\n    test(\"1\", \"-1\", Floor, \"-1\", Equal);\n    test(\"1\", \"-1\", Up, \"-1\", Equal);\n    test(\"1\", \"-1\", Ceiling, \"-1\", Equal);\n    test(\"1\", \"-1\", Nearest, \"-1\", Equal);\n    test(\"1\", \"-1\", Exact, \"-1\", Equal);\n\n    test(\"123\", \"-1\", Down, \"-123\", Equal);\n    test(\"123\", \"-1\", Floor, \"-123\", Equal);\n    test(\"123\", \"-1\", Up, \"-123\", Equal);\n    test(\"123\", \"-1\", Ceiling, \"-123\", Equal);\n    test(\"123\", \"-1\", Nearest, \"-123\", Equal);\n    test(\"123\", \"-1\", Exact, \"-123\", Equal);\n\n    test(\"123\", \"-2\", Down, \"-61\", Greater);\n    test(\"123\", \"-2\", Floor, \"-62\", Less);\n    test(\"123\", \"-2\", Up, \"-62\", Less);\n    test(\"123\", \"-2\", Ceiling, \"-61\", Greater);\n    test(\"123\", \"-2\", Nearest, \"-62\", Less);\n\n    test(\"125\", \"-2\", Down, \"-62\", Greater);\n    test(\"125\", \"-2\", Floor, \"-63\", Less);\n    test(\"125\", \"-2\", Up, \"-63\", Less);\n    test(\"125\", \"-2\", Ceiling, \"-62\", Greater);\n    test(\"125\", \"-2\", Nearest, \"-62\", Greater);\n\n    test(\"123\", \"-123\", Down, \"-1\", Equal);\n    test(\"123\", \"-123\", Floor, \"-1\", Equal);\n    test(\"123\", \"-123\", Up, \"-1\", Equal);\n    test(\"123\", \"-123\", Ceiling, \"-1\", Equal);\n    test(\"123\", \"-123\", Nearest, \"-1\", Equal);\n    test(\"123\", \"-123\", Exact, \"-1\", Equal);\n\n    test(\"123\", \"-456\", Down, \"0\", Greater);\n    test(\"123\", \"-456\", Floor, \"-1\", Less);\n    test(\"123\", \"-456\", Up, \"-1\", Less);\n    test(\"123\", \"-456\", Ceiling, \"0\", Greater);\n    test(\"123\", \"-456\", Nearest, \"0\", Greater);\n\n    test(\"1000000000000\", \"-1\", Down, \"-1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Floor, \"-1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Up, \"-1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Ceiling, \"-1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Nearest, \"-1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Exact, \"-1000000000000\", Equal);\n\n    test(\"1000000000000\", \"-3\", Down, \"-333333333333\", Greater);\n    test(\"1000000000000\", \"-3\", Floor, \"-333333333334\", Less);\n    test(\"1000000000000\", \"-3\", Up, \"-333333333334\", Less);\n    test(\"1000000000000\", \"-3\", Ceiling, \"-333333333333\", Greater);\n    test(\"1000000000000\", \"-3\", Nearest, \"-333333333333\", Greater);\n\n    test(\"999999999999\", \"-2\", Down, \"-499999999999\", Greater);\n    test(\"999999999999\", \"-2\", Floor, \"-500000000000\", Less);\n    test(\"999999999999\", \"-2\", Up, \"-500000000000\", Less);\n    test(\"999999999999\", \"-2\", Ceiling, \"-499999999999\", Greater);\n    test(\"999999999999\", \"-2\", Nearest, \"-500000000000\", Less);\n\n    test(\"1000000000001\", \"-2\", Down, \"-500000000000\", Greater);\n    test(\"1000000000001\", \"-2\", Floor, \"-500000000001\", Less);\n    test(\"1000000000001\", \"-2\", Up, \"-500000000001\", Less);\n    test(\"1000000000001\", \"-2\", Ceiling, \"-500000000000\", Greater);\n    test(\"1000000000001\", \"-2\", Nearest, \"-500000000000\", Greater);\n\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Down,\n        \"-232830643708079\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Floor,\n        \"-232830643708080\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Up,\n        \"-232830643708080\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Ceiling,\n        \"-232830643708079\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Nearest,\n        \"-232830643708080\",\n        Less,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Down,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Floor,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Up,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Ceiling,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Nearest,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Exact,\n        \"-1000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Down,\n        \"-999999999999\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Floor,\n        \"-1000000000000\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Up,\n        \"-1000000000000\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Ceiling,\n        \"-999999999999\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Nearest,\n        \"-999999999999\",\n        Greater,\n    );\n\n    test(\n        \"2999999999999999999999999\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"-1\",\n        Greater,\n    );\n    test(\n        \"3000000000000000000000000\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"-2\",\n        Less,\n    );\n    test(\n        \"3000000000000000000000001\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"-2\",\n        Less,\n    );\n\n    test(\"-1\", \"1\", Down, \"-1\", Equal);\n    test(\"-1\", \"1\", Floor, \"-1\", Equal);\n    test(\"-1\", \"1\", Up, \"-1\", Equal);\n    test(\"-1\", \"1\", Ceiling, \"-1\", Equal);\n    test(\"-1\", \"1\", Nearest, \"-1\", Equal);\n    test(\"-1\", \"1\", Exact, \"-1\", Equal);\n\n    test(\"-123\", \"1\", Down, \"-123\", Equal);\n    test(\"-123\", \"1\", Floor, \"-123\", Equal);\n    test(\"-123\", \"1\", Up, \"-123\", Equal);\n    test(\"-123\", \"1\", Ceiling, \"-123\", Equal);\n    test(\"-123\", \"1\", Nearest, \"-123\", Equal);\n    test(\"-123\", \"1\", Exact, \"-123\", Equal);\n\n    test(\"-123\", \"2\", Down, \"-61\", Greater);\n    test(\"-123\", \"2\", Floor, \"-62\", Less);\n    test(\"-123\", \"2\", Up, \"-62\", Less);\n    test(\"-123\", \"2\", Ceiling, \"-61\", Greater);\n    test(\"-123\", \"2\", Nearest, \"-62\", Less);\n\n    test(\"-125\", \"2\", Down, \"-62\", Greater);\n    test(\"-125\", \"2\", Floor, \"-63\", Less);\n    test(\"-125\", \"2\", Up, \"-63\", Less);\n    test(\"-125\", \"2\", Ceiling, \"-62\", Greater);\n    test(\"-125\", \"2\", Nearest, \"-62\", Greater);\n\n    test(\"-123\", \"123\", Down, \"-1\", Equal);\n    test(\"-123\", \"123\", Floor, \"-1\", Equal);\n    test(\"-123\", \"123\", Up, \"-1\", Equal);\n    test(\"-123\", \"123\", Ceiling, \"-1\", Equal);\n    test(\"-123\", \"123\", Nearest, \"-1\", Equal);\n    test(\"-123\", \"123\", Exact, \"-1\", Equal);\n\n    test(\"-123\", \"456\", Down, \"0\", Greater);\n    test(\"-123\", \"456\", Floor, \"-1\", Less);\n    test(\"-123\", \"456\", Up, \"-1\", Less);\n    test(\"-123\", \"456\", Ceiling, \"0\", Greater);\n    test(\"-123\", \"456\", Nearest, \"0\", Greater);\n\n    test(\"-1000000000000\", \"1\", Down, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Floor, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Up, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Ceiling, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Nearest, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Exact, \"-1000000000000\", Equal);\n\n    test(\"-1000000000000\", \"3\", Down, \"-333333333333\", Greater);\n    test(\"-1000000000000\", \"3\", Floor, \"-333333333334\", Less);\n    test(\"-1000000000000\", \"3\", Up, \"-333333333334\", Less);\n    test(\"-1000000000000\", \"3\", Ceiling, \"-333333333333\", Greater);\n    test(\"-1000000000000\", \"3\", Nearest, \"-333333333333\", Greater);\n\n    test(\"-999999999999\", \"2\", Down, \"-499999999999\", Greater);\n    test(\"-999999999999\", \"2\", Floor, \"-500000000000\", Less);\n    test(\"-999999999999\", \"2\", Up, \"-500000000000\", Less);\n    test(\"-999999999999\", \"2\", Ceiling, \"-499999999999\", Greater);\n    test(\"-999999999999\", \"2\", Nearest, \"-500000000000\", Less);\n\n    test(\"-1000000000001\", \"2\", Down, \"-500000000000\", Greater);\n    test(\"-1000000000001\", \"2\", Floor, \"-500000000001\", Less);\n    test(\"-1000000000001\", \"2\", Up, \"-500000000001\", Less);\n    test(\"-1000000000001\", \"2\", Ceiling, \"-500000000000\", Greater);\n    test(\"-1000000000001\", \"2\", Nearest, \"-500000000000\", Greater);\n\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Down,\n        \"-232830643708079\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Floor,\n        \"-232830643708080\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Up,\n        \"-232830643708080\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Ceiling,\n        \"-232830643708079\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Nearest,\n        \"-232830643708080\",\n        Less,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Down,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Floor,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Up,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Ceiling,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Nearest,\n        \"-1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Exact,\n        \"-1000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Down,\n        \"-999999999999\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Floor,\n        \"-1000000000000\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Up,\n        \"-1000000000000\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Ceiling,\n        \"-999999999999\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Nearest,\n        \"-999999999999\",\n        Greater,\n    );\n\n    test(\n        \"-2999999999999999999999999\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"-1\",\n        Greater,\n    );\n    test(\n        \"-3000000000000000000000000\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"-2\",\n        Less,\n    );\n    test(\n        \"-3000000000000000000000001\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"-2\",\n        Less,\n    );\n\n    test(\"-1\", \"-1\", Down, \"1\", Equal);\n    test(\"-1\", \"-1\", Floor, \"1\", Equal);\n    test(\"-1\", \"-1\", Up, \"1\", Equal);\n    test(\"-1\", \"-1\", Ceiling, \"1\", Equal);\n    test(\"-1\", \"-1\", Nearest, \"1\", Equal);\n    test(\"-1\", \"-1\", Exact, \"1\", Equal);\n\n    test(\"-123\", \"-1\", Down, \"123\", Equal);\n    test(\"-123\", \"-1\", Floor, \"123\", Equal);\n    test(\"-123\", \"-1\", Up, \"123\", Equal);\n    test(\"-123\", \"-1\", Ceiling, \"123\", Equal);\n    test(\"-123\", \"-1\", Nearest, \"123\", Equal);\n    test(\"-123\", \"-1\", Exact, \"123\", Equal);\n\n    test(\"-123\", \"-2\", Down, \"61\", Less);\n    test(\"-123\", \"-2\", Floor, \"61\", Less);\n    test(\"-123\", \"-2\", Up, \"62\", Greater);\n    test(\"-123\", \"-2\", Ceiling, \"62\", Greater);\n    test(\"-123\", \"-2\", Nearest, \"62\", Greater);\n\n    test(\"-125\", \"-2\", Down, \"62\", Less);\n    test(\"-125\", \"-2\", Floor, \"62\", Less);\n    test(\"-125\", \"-2\", Up, \"63\", Greater);\n    test(\"-125\", \"-2\", Ceiling, \"63\", Greater);\n    test(\"-125\", \"-2\", Nearest, \"62\", Less);\n\n    test(\"-123\", \"-123\", Down, \"1\", Equal);\n    test(\"-123\", \"-123\", Floor, \"1\", Equal);\n    test(\"-123\", \"-123\", Up, \"1\", Equal);\n    test(\"-123\", \"-123\", Ceiling, \"1\", Equal);\n    test(\"-123\", \"-123\", Nearest, \"1\", Equal);\n    test(\"-123\", \"-123\", Exact, \"1\", Equal);\n\n    test(\"-123\", \"-456\", Down, \"0\", Less);\n    test(\"-123\", \"-456\", Floor, \"0\", Less);\n    test(\"-123\", \"-456\", Up, \"1\", Greater);\n    test(\"-123\", \"-456\", Ceiling, \"1\", Greater);\n    test(\"-123\", \"-456\", Nearest, \"0\", Less);\n\n    test(\"-1000000000000\", \"-1\", Down, \"1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Floor, \"1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Up, \"1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Ceiling, \"1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Nearest, \"1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Exact, \"1000000000000\", Equal);\n\n    test(\"-1000000000000\", \"-3\", Down, \"333333333333\", Less);\n    test(\"-1000000000000\", \"-3\", Floor, \"333333333333\", Less);\n    test(\"-1000000000000\", \"-3\", Up, \"333333333334\", Greater);\n    test(\"-1000000000000\", \"-3\", Ceiling, \"333333333334\", Greater);\n    test(\"-1000000000000\", \"-3\", Nearest, \"333333333333\", Less);\n\n    test(\"-999999999999\", \"-2\", Down, \"499999999999\", Less);\n    test(\"-999999999999\", \"-2\", Floor, \"499999999999\", Less);\n    test(\"-999999999999\", \"-2\", Up, \"500000000000\", Greater);\n    test(\"-999999999999\", \"-2\", Ceiling, \"500000000000\", Greater);\n    test(\"-999999999999\", \"-2\", Nearest, \"500000000000\", Greater);\n\n    test(\"-1000000000001\", \"-2\", Down, \"500000000000\", Less);\n    test(\"-1000000000001\", \"-2\", Floor, \"500000000000\", Less);\n    test(\"-1000000000001\", \"-2\", Up, \"500000000001\", Greater);\n    test(\"-1000000000001\", \"-2\", Ceiling, \"500000000001\", Greater);\n    test(\"-1000000000001\", \"-2\", Nearest, \"500000000000\", Less);\n\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Down,\n        \"232830643708079\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Floor,\n        \"232830643708079\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Up,\n        \"232830643708080\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Ceiling,\n        \"232830643708080\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Nearest,\n        \"232830643708080\",\n        Greater,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Down,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Floor,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Up,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Exact,\n        \"1000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Down,\n        \"999999999999\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Floor,\n        \"999999999999\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Up,\n        \"1000000000000\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Ceiling,\n        \"1000000000000\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Nearest,\n        \"999999999999\",\n        Less,\n    );\n\n    test(\n        \"-2999999999999999999999999\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"1\",\n        Less,\n    );\n    test(\n        \"-3000000000000000000000000\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"2\",\n        Greater,\n    );\n    test(\n        \"-3000000000000000000000001\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"2\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_fail_1() {\n    let mut n = Integer::from(10);\n    n.div_round_assign(Integer::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_fail_2() {\n    let mut n = Integer::from(10);\n    n.div_round_assign(Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_ref_fail_1() {\n    let mut n = Integer::from(10);\n    n.div_round_assign(&Integer::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_ref_fail_2() {\n    let mut n = Integer::from(10);\n    n.div_round_assign(&Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_fail_1() {\n    Integer::from(10).div_round(Integer::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_fail_2() {\n    Integer::from(10).div_round(Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_val_ref_fail_1() {\n    Integer::from(10).div_round(&Integer::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_val_ref_fail_2() {\n    Integer::from(10).div_round(&Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_val_fail_1() {\n    (&Integer::from(10)).div_round(Integer::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_val_fail_2() {\n    (&Integer::from(10)).div_round(Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_ref_fail_1() {\n    (&Integer::from(10)).div_round(&Integer::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_ref_fail_2() {\n    (&Integer::from(10)).div_round(&Integer::from(3), Exact);\n}\n\n#[test]\nfn div_round_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_integer_rounding_mode_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(x, y, rm)| {\n            let mut mut_n = x.clone();\n            let o = mut_n.div_round_assign(&y, rm);\n            assert!(mut_n.is_valid());\n            let q = mut_n;\n\n            let mut mut_n = x.clone();\n            assert_eq!(mut_n.div_round_assign(y.clone(), rm), o);\n            assert!(mut_n.is_valid());\n            assert_eq!(mut_n, q);\n\n            let (q_alt, o_alt) = (&x).div_round(&y, rm);\n            assert!(q_alt.is_valid());\n            assert_eq!(q_alt, q);\n            assert_eq!(o_alt, o);\n\n            let (q_alt, o_alt) = (&x).div_round(y.clone(), rm);\n            assert!(q_alt.is_valid());\n            assert_eq!(q_alt, q);\n            assert_eq!(o_alt, o);\n\n            let (q_alt, o_alt) = x.clone().div_round(&y, rm);\n            assert!(q_alt.is_valid());\n            assert_eq!(q_alt, q);\n            assert_eq!(o_alt, o);\n\n            let (q_alt, o_alt) = x.clone().div_round(y.clone(), rm);\n            assert!(q_alt.is_valid());\n            assert_eq!(q_alt, q);\n            assert_eq!(o_alt, o);\n\n            assert!(q.le_abs(&x));\n            let (q_alt, o_alt) = (-&x).div_round(&y, -rm);\n            assert_eq!(-q_alt, q);\n            assert_eq!(o_alt, o.reverse());\n            let (q_alt, o_alt) = (&x).div_round(-&y, -rm);\n            assert_eq!(-q_alt, q);\n            assert_eq!(o_alt, o.reverse());\n\n            assert_eq!((q * &y).cmp(&x), if y >= 0 { o } else { o.reverse() });\n\n            match ((x >= 0) == (y >= 0), rm) {\n                (_, Floor) | (true, Down) | (false, Up) => {\n                    assert_ne!(o, Greater);\n                }\n                (_, Ceiling) | (true, Up) | (false, Down) => {\n                    assert_ne!(o, Less);\n                }\n                (_, Exact) => assert_eq!(o, Equal),\n                _ => {}\n            }\n        },\n    );\n\n    integer_pair_gen_var_1().test_properties(|(x, y)| {\n        let left_multiplied = &x * &y;\n        let xo = (x.clone(), Equal);\n        assert_eq!((&left_multiplied).div_round(&y, Down), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Up), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Floor), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Ceiling), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Nearest), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Exact), xo);\n\n        assert_eq!(\n            Integer::from(&rug::Integer::from(&x).div_trunc(rug::Integer::from(&y))),\n            (&x).div_round(&y, Down).0\n        );\n        assert_eq!(\n            Integer::from(&BigInt::from(&x).div_floor(&BigInt::from(&y))),\n            (&x).div_round(&y, Floor).0\n        );\n        assert_eq!(\n            Integer::from(&rug::Integer::from(&x).div_floor(rug::Integer::from(&y))),\n            (&x).div_round(&y, Floor).0\n        );\n        assert_eq!(\n            Integer::from(&rug::Integer::from(&x).div_ceil(rug::Integer::from(&y))),\n            x.div_round(y, Ceiling).0\n        );\n    });\n\n    integer_pair_gen_var_3().test_properties(|(x, y)| {\n        let down = (&x).div_round(&y, Down);\n        let up = if (x >= 0) == (y >= 0) {\n            (&down.0 + Integer::ONE, Greater)\n        } else {\n            (&down.0 - Integer::ONE, Less)\n        };\n        let floor = (&x).div_round(&y, Floor);\n        let ceiling = (&floor.0 + Integer::ONE, Greater);\n        assert_eq!((&x).div_round(&y, Up), up);\n        assert_eq!((&x).div_round(&y, Ceiling), ceiling);\n        let nearest = x.div_round(y, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        assert_eq!((&x).div_round(Integer::ONE, rm), (x.clone(), Equal));\n        assert_eq!((&x).div_round(Integer::NEGATIVE_ONE, rm), (-x, Equal));\n    });\n\n    integer_rounding_mode_pair_gen_var_2().test_properties(|(ref x, rm)| {\n        assert_eq!(Integer::ZERO.div_round(x, rm), (Integer::ZERO, Equal));\n        assert_eq!(x.div_round(x, rm), (Integer::ONE, Equal));\n        assert_eq!(x.div_round(-x, rm), (Integer::NEGATIVE_ONE, Equal));\n        assert_eq!((-x).div_round(x, rm), (Integer::NEGATIVE_ONE, Equal));\n    });\n\n    natural_natural_rounding_mode_triple_gen_var_1().test_properties(|(x, y, rm)| {\n        let (q, o) = (&x).div_round(&y, rm);\n        assert_eq!(\n            Integer::from(x).div_round(Integer::from(y), rm),\n            (Integer::from(q), o)\n        );\n    });\n\n    signed_signed_rounding_mode_triple_gen_var_1::<SignedLimb>().test_properties(|(x, y, rm)| {\n        let (q, o) = x.div_round(y, rm);\n        assert_eq!(\n            Integer::from(x).div_round(Integer::from(y), rm),\n            (Integer::from(q), o)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_8, integer_pair_gen, integer_pair_gen_var_2,\n    integer_pair_gen_var_3, natural_pair_gen,\n};\nuse malachite_nz::test_util::integer::arithmetic::divisible_by::num_divisible_by;\nuse num::BigInt;\nuse std::str::FromStr;\n\n#[test]\nfn test_divisible_by() {\n    let test = |s, t, divisible| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u.clone().divisible_by(v.clone()), divisible);\n        assert_eq!(u.clone().divisible_by(&v), divisible);\n        assert_eq!((&u).divisible_by(v.clone()), divisible);\n        assert_eq!((&u).divisible_by(&v), divisible);\n        assert_eq!(u == 0 || v != 0 && u % v == 0, divisible);\n        assert_eq!(\n            num_divisible_by(&BigInt::from_str(s).unwrap(), &BigInt::from_str(t).unwrap()),\n            divisible\n        );\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .is_divisible(&rug::Integer::from_str(t).unwrap()),\n            divisible\n        );\n    };\n    test(\"0\", \"0\", true);\n    test(\"1\", \"0\", false);\n    test(\"1000000000000\", \"0\", false);\n    test(\"0\", \"1\", true);\n    test(\"0\", \"123\", true);\n    test(\"1\", \"1\", true);\n    test(\"123\", \"1\", true);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"456\", false);\n    test(\"456\", \"123\", false);\n    test(\"369\", \"123\", true);\n    test(\"4294967295\", \"1\", true);\n    test(\"4294967295\", \"4294967295\", true);\n    test(\"1000000000000\", \"1\", true);\n    test(\"1000000000000\", \"3\", false);\n    test(\"1000000000002\", \"3\", true);\n    test(\"1000000000000\", \"123\", false);\n    test(\"1000000000000\", \"4294967295\", false);\n    test(\"1000000000000000000000000\", \"1\", true);\n    test(\"1000000000000000000000000\", \"3\", false);\n    test(\"1000000000000000000000002\", \"3\", true);\n    test(\"1000000000000000000000000\", \"123\", false);\n    test(\"1000000000000000000000000\", \"4294967295\", false);\n    test(\"1000000000000000000000000\", \"1000000000000\", true);\n    test(\"1000000000000000000000000\", \"1000000000001\", false);\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099789\",\n        true,\n    );\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099788\",\n        false,\n    );\n\n    test(\"0\", \"-1\", true);\n    test(\"0\", \"-123\", true);\n    test(\"1\", \"-1\", true);\n    test(\"123\", \"-1\", true);\n    test(\"123\", \"-123\", true);\n    test(\"123\", \"-456\", false);\n    test(\"456\", \"-123\", false);\n    test(\"369\", \"-123\", true);\n    test(\"4294967295\", \"-1\", true);\n    test(\"4294967295\", \"-4294967295\", true);\n    test(\"1000000000000\", \"-1\", true);\n    test(\"1000000000000\", \"-3\", false);\n    test(\"1000000000002\", \"-3\", true);\n    test(\"1000000000000\", \"-123\", false);\n    test(\"1000000000000\", \"-4294967295\", false);\n    test(\"1000000000000000000000000\", \"-1\", true);\n    test(\"1000000000000000000000000\", \"-3\", false);\n    test(\"1000000000000000000000002\", \"-3\", true);\n    test(\"1000000000000000000000000\", \"-123\", false);\n    test(\"1000000000000000000000000\", \"-4294967295\", false);\n    test(\"1000000000000000000000000\", \"-1000000000000\", true);\n    test(\"1000000000000000000000000\", \"-1000000000001\", false);\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"-14750227965563656560025035845269405189398018669695853517400995652385572010732263815974936\\\n        8080821747949474430587689097259577148476973385751452961609619939409285830226599826048341601\\\n        6576390452204426400593828107256814088351371325554864304425008611048361721593563653380924810\\\n        2692659078914207980563844549476017755177663674783001449501248974399040735523228684207141892\\\n        2992135840957348090162448797731978275542273083446867343807680553295282140602439900681439016\\\n        6694982753079697108601126786460781490631333452551810222191964304044026732368834188903586437\\\n        6137724664457908815322266967227141431524031843984372003980899388641087496934099664501079567\\\n        0213351871698766886593652982743738804219008430900536956471739072625759490261936518009750957\\\n        6624018903777061930820690641412868685634995095262397002303944032370164345741148566677635444\\\n        8186307133288106956593939073729500658176632828099789\",\n        true,\n    );\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"-14750227965563656560025035845269405189398018669695853517400995652385572010732263815974936\\\n        8080821747949474430587689097259577148476973385751452961609619939409285830226599826048341601\\\n        6576390452204426400593828107256814088351371325554864304425008611048361721593563653380924810\\\n        2692659078914207980563844549476017755177663674783001449501248974399040735523228684207141892\\\n        2992135840957348090162448797731978275542273083446867343807680553295282140602439900681439016\\\n        6694982753079697108601126786460781490631333452551810222191964304044026732368834188903586437\\\n        6137724664457908815322266967227141431524031843984372003980899388641087496934099664501079567\\\n        0213351871698766886593652982743738804219008430900536956471739072625759490261936518009750957\\\n        6624018903777061930820690641412868685634995095262397002303944032370164345741148566677635444\\\n        8186307133288106956593939073729500658176632828099788\",\n        false,\n    );\n\n    test(\"-1\", \"0\", false);\n    test(\"-1000000000000\", \"0\", false);\n    test(\"-1\", \"1\", true);\n    test(\"-123\", \"1\", true);\n    test(\"-123\", \"123\", true);\n    test(\"-123\", \"456\", false);\n    test(\"-456\", \"123\", false);\n    test(\"-369\", \"123\", true);\n    test(\"-4294967295\", \"1\", true);\n    test(\"-4294967295\", \"4294967295\", true);\n    test(\"-1000000000000\", \"1\", true);\n    test(\"-1000000000000\", \"3\", false);\n    test(\"-1000000000002\", \"3\", true);\n    test(\"-1000000000000\", \"123\", false);\n    test(\"-1000000000000\", \"4294967295\", false);\n    test(\"-1000000000000000000000000\", \"1\", true);\n    test(\"-1000000000000000000000000\", \"3\", false);\n    test(\"-1000000000000000000000002\", \"3\", true);\n    test(\"-1000000000000000000000000\", \"123\", false);\n    test(\"-1000000000000000000000000\", \"4294967295\", false);\n    test(\"-1000000000000000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000000000000000\", \"1000000000001\", false);\n    test(\n        \"-85167390638832534155095794307111191155780003684512955609936093881325960865026707945673997\\\n        8115695995227540918591177133606739237724591829175426900075118671527941456047488257049908299\\\n        0491312297889746397086083361625118924209880487666436844160872789514123895317920452925678027\\\n        7597810520028602516194421271297705634312768260197519167321745960256763360219826256892100808\\\n        1944855667091257528737125119080085592631176887680837517744653024363521274834692165422458986\\\n        1062517042681252582968986240751551041944533547263190561023591522603284832387406712887238529\\\n        1373073927546722736469219522612950133888704971058693114130935719034106453236601312328010609\\\n        8646815162879794545517964986689039448179963983254097809173637948296452222906447816773031749\\\n        0819410850670448075039505406703250253039214769072591939993068314351077164686993152712334065\\\n        0054764979233156891346041593972211130527058870153140449004003430210210108369170655037628865\\\n        5266738289939079249411893137923743207131654331337979221879437117652968461408510941832896381\\\n        7060143276727041922971949080953977653567193804161853619694137064794533640190145092141382316\\\n        3405999170707783410783087675682188065142974818640102076011385949818563813372616528648174101\\\n        4907990633728659922633550842446636931629444200404044052858958223971704265454174534805015725\\\n        23448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099789\",\n        true,\n    );\n    test(\n        \"-85167390638832534155095794307111191155780003684512955609936093881325960865026707945673997\\\n        8115695995227540918591177133606739237724591829175426900075118671527941456047488257049908299\\\n        0491312297889746397086083361625118924209880487666436844160872789514123895317920452925678027\\\n        7597810520028602516194421271297705634312768260197519167321745960256763360219826256892100808\\\n        1944855667091257528737125119080085592631176887680837517744653024363521274834692165422458986\\\n        1062517042681252582968986240751551041944533547263190561023591522603284832387406712887238529\\\n        1373073927546722736469219522612950133888704971058693114130935719034106453236601312328010609\\\n        8646815162879794545517964986689039448179963983254097809173637948296452222906447816773031749\\\n        0819410850670448075039505406703250253039214769072591939993068314351077164686993152712334065\\\n        0054764979233156891346041593972211130527058870153140449004003430210210108369170655037628865\\\n        5266738289939079249411893137923743207131654331337979221879437117652968461408510941832896381\\\n        7060143276727041922971949080953977653567193804161853619694137064794533640190145092141382316\\\n        3405999170707783410783087675682188065142974818640102076011385949818563813372616528648174101\\\n        4907990633728659922633550842446636931629444200404044052858958223971704265454174534805015725\\\n        23448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099788\",\n        false,\n    );\n\n    test(\"-1\", \"-1\", true);\n    test(\"-123\", \"-1\", true);\n    test(\"-123\", \"-123\", true);\n    test(\"-123\", \"-456\", false);\n    test(\"-456\", \"-123\", false);\n    test(\"-369\", \"-123\", true);\n    test(\"-4294967295\", \"-1\", true);\n    test(\"-4294967295\", \"-4294967295\", true);\n    test(\"-1000000000000\", \"-1\", true);\n    test(\"-1000000000000\", \"-3\", false);\n    test(\"-1000000000002\", \"-3\", true);\n    test(\"-1000000000000\", \"-123\", false);\n    test(\"-1000000000000\", \"-4294967295\", false);\n    test(\"-1000000000000000000000000\", \"-1\", true);\n    test(\"-1000000000000000000000000\", \"-3\", false);\n    test(\"-1000000000000000000000002\", \"-3\", true);\n    test(\"-1000000000000000000000000\", \"-123\", false);\n    test(\"-1000000000000000000000000\", \"-4294967295\", false);\n    test(\"-1000000000000000000000000\", \"-1000000000000\", true);\n    test(\"-1000000000000000000000000\", \"-1000000000001\", false);\n    test(\n        \"-85167390638832534155095794307111191155780003684512955609936093881325960865026707945673997\\\n        8115695995227540918591177133606739237724591829175426900075118671527941456047488257049908299\\\n        0491312297889746397086083361625118924209880487666436844160872789514123895317920452925678027\\\n        7597810520028602516194421271297705634312768260197519167321745960256763360219826256892100808\\\n        1944855667091257528737125119080085592631176887680837517744653024363521274834692165422458986\\\n        1062517042681252582968986240751551041944533547263190561023591522603284832387406712887238529\\\n        1373073927546722736469219522612950133888704971058693114130935719034106453236601312328010609\\\n        8646815162879794545517964986689039448179963983254097809173637948296452222906447816773031749\\\n        0819410850670448075039505406703250253039214769072591939993068314351077164686993152712334065\\\n        0054764979233156891346041593972211130527058870153140449004003430210210108369170655037628865\\\n        5266738289939079249411893137923743207131654331337979221879437117652968461408510941832896381\\\n        7060143276727041922971949080953977653567193804161853619694137064794533640190145092141382316\\\n        3405999170707783410783087675682188065142974818640102076011385949818563813372616528648174101\\\n        4907990633728659922633550842446636931629444200404044052858958223971704265454174534805015725\\\n        23448224036804997350851153108395928780441635856\",\n        \"-14750227965563656560025035845269405189398018669695853517400995652385572010732263815974936\\\n        8080821747949474430587689097259577148476973385751452961609619939409285830226599826048341601\\\n        6576390452204426400593828107256814088351371325554864304425008611048361721593563653380924810\\\n        2692659078914207980563844549476017755177663674783001449501248974399040735523228684207141892\\\n        2992135840957348090162448797731978275542273083446867343807680553295282140602439900681439016\\\n        6694982753079697108601126786460781490631333452551810222191964304044026732368834188903586437\\\n        6137724664457908815322266967227141431524031843984372003980899388641087496934099664501079567\\\n        0213351871698766886593652982743738804219008430900536956471739072625759490261936518009750957\\\n        6624018903777061930820690641412868685634995095262397002303944032370164345741148566677635444\\\n        8186307133288106956593939073729500658176632828099789\",\n        true,\n    );\n    test(\n        \"-85167390638832534155095794307111191155780003684512955609936093881325960865026707945673997\\\n        8115695995227540918591177133606739237724591829175426900075118671527941456047488257049908299\\\n        0491312297889746397086083361625118924209880487666436844160872789514123895317920452925678027\\\n        7597810520028602516194421271297705634312768260197519167321745960256763360219826256892100808\\\n        1944855667091257528737125119080085592631176887680837517744653024363521274834692165422458986\\\n        1062517042681252582968986240751551041944533547263190561023591522603284832387406712887238529\\\n        1373073927546722736469219522612950133888704971058693114130935719034106453236601312328010609\\\n        8646815162879794545517964986689039448179963983254097809173637948296452222906447816773031749\\\n        0819410850670448075039505406703250253039214769072591939993068314351077164686993152712334065\\\n        0054764979233156891346041593972211130527058870153140449004003430210210108369170655037628865\\\n        5266738289939079249411893137923743207131654331337979221879437117652968461408510941832896381\\\n        7060143276727041922971949080953977653567193804161853619694137064794533640190145092141382316\\\n        3405999170707783410783087675682188065142974818640102076011385949818563813372616528648174101\\\n        4907990633728659922633550842446636931629444200404044052858958223971704265454174534805015725\\\n        23448224036804997350851153108395928780441635856\",\n        \"-14750227965563656560025035845269405189398018669695853517400995652385572010732263815974936\\\n        8080821747949474430587689097259577148476973385751452961609619939409285830226599826048341601\\\n        6576390452204426400593828107256814088351371325554864304425008611048361721593563653380924810\\\n        2692659078914207980563844549476017755177663674783001449501248974399040735523228684207141892\\\n        2992135840957348090162448797731978275542273083446867343807680553295282140602439900681439016\\\n        6694982753079697108601126786460781490631333452551810222191964304044026732368834188903586437\\\n        6137724664457908815322266967227141431524031843984372003980899388641087496934099664501079567\\\n        0213351871698766886593652982743738804219008430900536956471739072625759490261936518009750957\\\n        6624018903777061930820690641412868685634995095262397002303944032370164345741148566677635444\\\n        8186307133288106956593939073729500658176632828099788\",\n        false,\n    );\n}\n\n#[test]\nfn divisible_by_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen().test_properties_with_config(&config, |(x, y)| {\n        let divisible = (&x).divisible_by(&y);\n        assert_eq!((&x).divisible_by(y.clone()), divisible);\n        assert_eq!(x.clone().divisible_by(&y), divisible);\n        assert_eq!(x.clone().divisible_by(y.clone()), divisible);\n\n        assert_eq!(x == 0 || y != 0 && &x % &y == 0, divisible);\n        assert_eq!((-&x).divisible_by(&y), divisible);\n        assert_eq!((&x).divisible_by(-&y), divisible);\n        assert_eq!(\n            num_divisible_by(&BigInt::from(&x), &BigInt::from(&y)),\n            divisible\n        );\n        assert_eq!(\n            rug::Integer::from(&x).is_divisible(&rug::Integer::from(&y)),\n            divisible\n        );\n    });\n\n    integer_pair_gen_var_2().test_properties(|(x, y)| {\n        assert!((&x).divisible_by(&y));\n        assert!(x == 0 || y != 0 && &x % &y == 0);\n        assert!(num_divisible_by(&BigInt::from(&x), &BigInt::from(&y)));\n        assert!(rug::Integer::from(&x).is_divisible(&rug::Integer::from(&y)));\n    });\n\n    integer_pair_gen_var_3().test_properties(|(x, y)| {\n        assert!(!(&x).divisible_by(&y));\n        assert!(x != 0 && (y == 0 || &x % &y != 0));\n        assert!(!num_divisible_by(&BigInt::from(&x), &BigInt::from(&y)));\n        assert!(!rug::Integer::from(&x).is_divisible(&rug::Integer::from(&y)));\n    });\n\n    integer_gen().test_properties(|n| {\n        assert!((&n).divisible_by(Integer::ONE));\n        assert!(n.divisible_by(Integer::NEGATIVE_ONE));\n    });\n\n    integer_gen_var_8().test_properties(|n| {\n        assert!(!(&n).divisible_by(Integer::ZERO));\n        assert!(Integer::ZERO.divisible_by(&n));\n        if n > 1 {\n            assert!(!Integer::ONE.divisible_by(&n));\n        }\n        assert!((&n).divisible_by(&n));\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(&x).divisible_by(Integer::from(&y)),\n            x.divisible_by(y)\n        );\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(x).divisible_by(Integer::from(y)),\n            x.divisible_by(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen_var_1, unsigned_gen};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_4,\n    integer_unsigned_pair_gen_var_5, natural_unsigned_pair_gen_var_4,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_divisible_by_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Integer::from_str(n).unwrap().divisible_by_power_of_2(pow),\n            out\n        );\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .is_divisible_2pow(u32::exact_from(pow)),\n            out\n        );\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 10, true);\n    test(\"0\", 100, true);\n    test(\"123\", 0, true);\n    test(\"123\", 1, false);\n    test(\"-123\", 0, true);\n    test(\"-123\", 1, false);\n    test(\"1000000000000\", 0, true);\n    test(\"1000000000000\", 12, true);\n    test(\"1000000000000\", 13, false);\n    test(\"-1000000000000\", 0, true);\n    test(\"-1000000000000\", 12, true);\n    test(\"-1000000000000\", 13, false);\n    test(\"4294967295\", 0, true);\n    test(\"4294967295\", 1, false);\n    test(\"-4294967295\", 0, true);\n    test(\"-4294967295\", 1, false);\n    test(\"4294967296\", 0, true);\n    test(\"4294967296\", 32, true);\n    test(\"4294967296\", 33, false);\n    test(\"-4294967296\", 0, true);\n    test(\"-4294967296\", 32, true);\n    test(\"-4294967296\", 33, false);\n    test(\"18446744073709551615\", 0, true);\n    test(\"18446744073709551615\", 1, false);\n    test(\"-18446744073709551615\", 0, true);\n    test(\"-18446744073709551615\", 1, false);\n    test(\"18446744073709551616\", 0, true);\n    test(\"18446744073709551616\", 64, true);\n    test(\"18446744073709551616\", 65, false);\n    test(\"-18446744073709551616\", 0, true);\n    test(\"-18446744073709551616\", 64, true);\n    test(\"-18446744073709551616\", 65, false);\n}\n\n#[test]\nfn divisible_by_power_of_2_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, pow)| {\n        let divisible = x.divisible_by_power_of_2(pow);\n        assert_eq!(\n            rug::Integer::from(&x).is_divisible_2pow(u32::exact_from(pow)),\n            divisible\n        );\n        if x != 0 {\n            assert_eq!(x.trailing_zeros().unwrap() >= pow, divisible);\n        }\n        assert_eq!((-&x).divisible_by_power_of_2(pow), divisible);\n        assert!((&x << pow).divisible_by_power_of_2(pow));\n        assert_eq!(&x >> pow << pow == x, divisible);\n    });\n\n    integer_unsigned_pair_gen_var_4().test_properties(|(x, pow)| {\n        assert!(x.divisible_by_power_of_2(pow));\n        assert!(rug::Integer::from(&x).is_divisible_2pow(u32::exact_from(pow)));\n        if x != 0 {\n            assert!(x.trailing_zeros().unwrap() >= pow);\n        }\n        assert!((-&x).divisible_by_power_of_2(pow));\n        assert_eq!(&x >> pow << pow, x);\n    });\n\n    integer_unsigned_pair_gen_var_5().test_properties(|(x, pow)| {\n        assert!(!x.divisible_by_power_of_2(pow));\n        assert!(!rug::Integer::from(&x).is_divisible_2pow(u32::exact_from(pow)));\n        if x != 0 {\n            assert!(x.trailing_zeros().unwrap() < pow);\n        }\n        assert!(!(-&x).divisible_by_power_of_2(pow));\n        assert_ne!(&x >> pow << pow, x);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.divisible_by_power_of_2(0));\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert!(Integer::ZERO.divisible_by_power_of_2(pow));\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, pow)| {\n        assert_eq!(\n            x.divisible_by_power_of_2(pow),\n            Integer::from(x).divisible_by_power_of_2(pow)\n        );\n    });\n\n    signed_unsigned_pair_gen_var_1::<SignedLimb, u64>().test_properties(|(x, pow)| {\n        assert_eq!(\n            x.divisible_by_power_of_2(pow),\n            Integer::from(x).divisible_by_power_of_2(pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleBy, EqMod, Mod, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_triple_gen, unsigned_vec_triple_gen_var_36,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_5,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_7,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::arithmetic::eq_mod::{\n    limbs_eq_neg_limb_mod_limb, limbs_pos_eq_neg_limb_mod, limbs_pos_eq_neg_limb_mod_ref,\n    limbs_pos_eq_neg_mod, limbs_pos_eq_neg_mod_limb, limbs_pos_eq_neg_mod_ref,\n    limbs_pos_limb_eq_neg_limb_mod,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_integer_natural_triple_gen, integer_integer_natural_triple_gen_var_1,\n    integer_integer_natural_triple_gen_var_2, integer_natural_pair_gen, integer_pair_gen,\n    natural_triple_gen, unsigned_vec_triple_gen_var_37, unsigned_vec_triple_gen_var_38,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_6,\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2,\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_8,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_neg_limb_mod_limb() {\n    let test = |xs: &[Limb], y: Limb, m: Limb, equal: bool| {\n        assert_eq!(limbs_eq_neg_limb_mod_limb(xs, y, m), equal);\n    };\n    test(&[6, 7], 4, 2, true);\n    test(&[7, 7], 4, 2, false);\n    test(&[6, 7], 3, 2, false);\n    test(&[7, 7], 3, 2, true);\n    test(&[2, 2], 6, 13, true);\n    test(&[100, 101, 102], 1232, 10, true);\n    test(&[100, 101, 102], 1233, 10, false);\n    test(&[123, 456], 153, 789, true);\n    test(&[123, 456], 1000, 789, false);\n    test(&[u32::MAX, u32::MAX], 101, 2, true);\n    test(&[u32::MAX, u32::MAX], 100, 2, false);\n    test(&[u32::MAX, u32::MAX], 111, 3, true);\n    test(&[u32::MAX, u32::MAX], 110, 3, false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_neg_limb_mod_limb_fail() {\n    limbs_eq_neg_limb_mod_limb(&[10], 10, 15);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_limb_eq_neg_limb_mod() {\n    let test = |x: Limb, y: Limb, ms: &[Limb], equal: bool| {\n        assert_eq!(limbs_pos_limb_eq_neg_limb_mod(x, y, ms), equal);\n        let x = Integer::from(x);\n        let y = -Natural::from(y);\n        let m = Natural::from_limbs_asc(ms);\n        assert_eq!((&x).eq_mod(&y, &m), equal);\n        let m = Integer::from(m);\n        assert_eq!(\n            x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n            equal\n        );\n        assert_eq!((x - y).divisible_by(m), equal);\n    };\n    test(1, 1, &[1, 1], false);\n    test(1, 1, &[2, 1], false);\n    test(1, 1, &[1, 0, 1], false);\n    test(u32::MAX, u32::MAX, &[u32::MAX - 1, 1], true);\n    test(u32::MAX, u32::MAX, &[u32::MAX - 1, 1, 2], false);\n    test(u32::MAX, u32::MAX, &[u32::MAX - 1, 2], false);\n    test(0xabcddbca, 0x641fefdf, &[0xfedcba9, 1], true);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_eq_neg_limb_mod() {\n    let test = |xs: &[Limb], y: Limb, ms: &[Limb], equal: bool| {\n        let mut mut_ms = ms.to_vec();\n        assert_eq!(limbs_pos_eq_neg_limb_mod(xs, y, &mut mut_ms), equal);\n        assert_eq!(limbs_pos_eq_neg_limb_mod_ref(xs, y, ms), equal);\n        let x = Integer::from(Natural::from_limbs_asc(xs));\n        let y = -Natural::from(y);\n        let m = Natural::from_limbs_asc(ms);\n        assert_eq!((&x).eq_mod(&y, &m), equal);\n        let m = Integer::from(m);\n        assert_eq!(\n            x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n            equal\n        );\n        assert_eq!((x - y).divisible_by(m), equal);\n    };\n    // - !xs[0].wrapping_neg().eq_mod_power_of_2(y, u64::from(twos))\n    test(&[1, 2], 2, &[2, 1], false);\n    // - xs[0].wrapping_neg().eq_mod_power_of_2(y, u64::from(twos))\n    // - m_len == 2 && m_0 != 0\n    // - m_1 < 1 << twos\n    // - x_len < BMOD_1_TO_MOD_1_THRESHOLD\n    test(&[2, 2], 2, &[2, 1], true);\n    // - m_1 >= 1 << twos\n    test(&[0, 1], 1, &[1, 1], true);\n    // - m_len > 2 || m_0 == 0\n    test(&[0, 1], 1, &[1, 0, 1], false);\n    // - x_len >= BMOD_1_TO_MOD_1_THRESHOLD\n    // - y < m_0\n    test(\n        &[\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 1,\n        ],\n        2,\n        &[2, 1],\n        false,\n    );\n    // - limbs_pos_eq_neg_limb_mod_helper, y >= m_0\n    test(\n        &[\n            1,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            3,\n            4294967294,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4294836223,\n            65535,\n            0,\n            0,\n            8192,\n            4294963200,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4294959103,\n            4095,\n        ],\n        u32::MAX,\n        &[4294959104, 4095],\n        true,\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_fail_1() {\n    limbs_pos_eq_neg_limb_mod(&[1], 1, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_fail_2() {\n    limbs_pos_eq_neg_limb_mod(&[1, 1], 1, &mut [1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_fail_3() {\n    limbs_pos_eq_neg_limb_mod(&[1, 0], 1, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_fail_4() {\n    limbs_pos_eq_neg_limb_mod(&[1, 1], 0, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_fail_5() {\n    limbs_pos_eq_neg_limb_mod(&[1, 1], 1, &mut [1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_ref_fail_1() {\n    limbs_pos_eq_neg_limb_mod_ref(&[1], 1, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_ref_fail_2() {\n    limbs_pos_eq_neg_limb_mod_ref(&[1, 1], 1, &[1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_ref_fail_3() {\n    limbs_pos_eq_neg_limb_mod_ref(&[1, 0], 1, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_ref_fail_4() {\n    limbs_pos_eq_neg_limb_mod_ref(&[1, 1], 0, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_limb_mod_ref_fail_5() {\n    limbs_pos_eq_neg_limb_mod_ref(&[1, 1], 1, &[1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_eq_neg_mod_limb() {\n    let test = |xs: &[Limb], ys: &[Limb], m: Limb, equal: bool| {\n        assert_eq!(limbs_pos_eq_neg_mod_limb(xs, ys, m), equal);\n        let x = Integer::from(Natural::from_limbs_asc(xs));\n        let y = -Natural::from_limbs_asc(ys);\n        let m = Natural::from(m);\n        assert_eq!((&x).eq_mod(&y, &m), equal);\n        let m = Integer::from(m);\n        assert_eq!(\n            x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n            equal\n        );\n        assert_eq!((x - y).divisible_by(m), equal);\n    };\n    // - xs[0].wrapping_neg().eq_mod_power_of_2(ys[0], u64::from(m.trailing_zeros())) in\n    //   limbs_pos_eq_mod_neg_limb_greater\n    test(&[0, 1], &[0, 1], 1, true);\n    test(&[0, 1], &[0, 1], 2, true);\n    test(&[0, 1], &[6, 1], 2, true);\n    // - !xs[0].wrapping_neg().eq_mod_power_of_2(ys[0], u64::from(m.trailing_zeros())) in\n    //   limbs_pos_eq_mod_neg_limb_greater\n    test(&[0, 1], &[7, 1], 2, false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_limb_fail_1() {\n    limbs_pos_eq_neg_mod_limb(&[1], &[3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_limb_fail_2() {\n    limbs_pos_eq_neg_mod_limb(&[1, 1], &[4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_limb_fail_3() {\n    limbs_pos_eq_neg_mod_limb(&[1, 0], &[3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_limb_fail_4() {\n    limbs_pos_eq_neg_mod_limb(&[1, 1], &[3, 0], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_limb_fail_5() {\n    limbs_pos_eq_neg_mod_limb(&[1, 1], &[3, 4], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_eq_neg_mod() {\n    let test = |xs: &[Limb], ys: &[Limb], ms: &[Limb], equal: bool| {\n        let mut mut_ms = ms.to_vec();\n        assert_eq!(limbs_pos_eq_neg_mod(xs, ys, &mut mut_ms), equal);\n        assert_eq!(limbs_pos_eq_neg_mod_ref(xs, ys, ms), equal);\n        let x = Integer::from(Natural::from_limbs_asc(xs));\n        let y = -Natural::from_limbs_asc(ys);\n        let m = Natural::from_limbs_asc(ms);\n        assert_eq!((&x).eq_mod(&y, &m), equal);\n        let m = Integer::from(m);\n        assert_eq!(\n            x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n            equal\n        );\n        assert_eq!((x - y).divisible_by(m), equal);\n    };\n    // - !xs[0].wrapping_neg().eq_mod_power_of_2(ys[0], u64::from(ms[0].trailing_zeros())) in\n    //   limbs_pos_eq_neg_mod_greater\n    test(&[1, 2], &[3, 4], &[0, 1], false);\n    test(&[0, 0, 1], &[0, 1], &[1, 1], true);\n    // - xs[0].wrapping_neg().eq_mod_power_of_2(ys[0], u64::from(ms[0].trailing_zeros())) in\n    //   limbs_pos_eq_neg_mod_greater\n    test(\n        &[\n            936369948, 322455623, 3632895046, 978349680, 17000327, 2833388987, 2719643819,\n            4166701038,\n        ],\n        &[\n            2342728269, 2320695303, 2977562202, 4108534583, 1505907268, 3739165110, 101046064,\n            1901445664,\n        ],\n        &[602975281, 3649288173, 1789153785, 3864060421, 3382875975, 610141130],\n        false,\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_fail_1() {\n    limbs_pos_eq_neg_mod(&[1], &[1, 0, 3], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_fail_2() {\n    limbs_pos_eq_neg_mod(&[1, 1, 1], &[1], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_fail_3() {\n    limbs_pos_eq_neg_mod(&[1, 1, 1], &[1, 0, 3], &mut [7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_fail_4() {\n    limbs_pos_eq_neg_mod(&[1, 1, 0], &[1, 0, 3], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_fail_5() {\n    limbs_pos_eq_neg_mod(&[1, 1, 1], &[1, 0, 0], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_fail_6() {\n    limbs_pos_eq_neg_mod(&[1, 1, 1], &[1, 0, 3], &mut [7, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_ref_fail_1() {\n    limbs_pos_eq_neg_mod_ref(&[1], &[1, 0, 3], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_ref_fail_2() {\n    limbs_pos_eq_neg_mod_ref(&[1, 1, 1], &[1], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_ref_fail_3() {\n    limbs_pos_eq_neg_mod_ref(&[1, 1, 1], &[1, 0, 3], &[7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_ref_fail_4() {\n    limbs_pos_eq_neg_mod_ref(&[1, 1, 0], &[1, 0, 3], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_ref_fail_5() {\n    limbs_pos_eq_neg_mod_ref(&[1, 1, 1], &[1, 0, 0], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_eq_neg_mod_ref_fail_6() {\n    limbs_pos_eq_neg_mod_ref(&[1, 1, 1], &[1, 0, 3], &[7, 0]);\n}\n\n#[test]\nfn test_eq_mod() {\n    let test = |r, s, t, out| {\n        let u = Integer::from_str(r).unwrap();\n        let v = Integer::from_str(s).unwrap();\n        let w = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.clone().eq_mod(v.clone(), w.clone()), out);\n        assert_eq!(u.clone().eq_mod(v.clone(), &w), out);\n        assert_eq!(u.clone().eq_mod(&v, w.clone()), out);\n        assert_eq!(u.clone().eq_mod(&v, &w), out);\n        assert_eq!((&u).eq_mod(v.clone(), w.clone()), out);\n        assert_eq!((&u).eq_mod(v.clone(), &w), out);\n        assert_eq!((&u).eq_mod(&v, w.clone()), out);\n        assert_eq!((&u).eq_mod(&v, &w), out);\n        assert_eq!(v.eq_mod(u, w), out);\n        assert_eq!(\n            rug::Integer::from_str(r).unwrap().is_congruent(\n                &rug::Integer::from_str(s).unwrap(),\n                &rug::Integer::from_str(t).unwrap()\n            ),\n            out\n        );\n    };\n    test(\"0\", \"0\", \"0\", true);\n    test(\"0\", \"1\", \"0\", false);\n    test(\"57\", \"57\", \"0\", true);\n    test(\"57\", \"58\", \"0\", false);\n    test(\"1000000000000\", \"57\", \"0\", false);\n    test(\"0\", \"256\", \"256\", true);\n    test(\"0\", \"256\", \"512\", false);\n    test(\"13\", \"23\", \"10\", true);\n    test(\"13\", \"24\", \"10\", false);\n    test(\"13\", \"21\", \"1\", true);\n    test(\"13\", \"21\", \"2\", true);\n    test(\"13\", \"21\", \"4\", true);\n    test(\"13\", \"21\", \"8\", true);\n    test(\"13\", \"21\", \"16\", false);\n    test(\"13\", \"21\", \"3\", false);\n    test(\"1000000000001\", \"1\", \"4096\", true);\n    test(\"1000000000001\", \"1\", \"8192\", false);\n    test(\"12345678987654321\", \"321\", \"1000\", true);\n    test(\"12345678987654321\", \"322\", \"1000\", false);\n    test(\"1234\", \"1234\", \"1000000000000\", true);\n    test(\"1234\", \"1235\", \"1000000000000\", false);\n    test(\"1000000001234\", \"1000000002234\", \"1000\", true);\n    test(\"1000000001234\", \"1000000002235\", \"1000\", false);\n    test(\"1000000001234\", \"1234\", \"1000000000000\", true);\n    test(\"1000000001234\", \"1235\", \"1000000000000\", false);\n    test(\"1000000001234\", \"5000000001234\", \"1000000000000\", true);\n    test(\"1000000001234\", \"5000000001235\", \"1000000000000\", false);\n\n    test(\"0\", \"-1\", \"0\", false);\n    test(\"57\", \"-57\", \"0\", false);\n    test(\"57\", \"-58\", \"0\", false);\n    test(\"1000000000000\", \"-57\", \"0\", false);\n    test(\"0\", \"-256\", \"256\", true);\n    test(\"0\", \"-256\", \"512\", false);\n    test(\"13\", \"-27\", \"10\", true);\n    test(\"13\", \"-28\", \"10\", false);\n    test(\"29\", \"-27\", \"1\", true);\n    test(\"29\", \"-27\", \"2\", true);\n    test(\"29\", \"-27\", \"4\", true);\n    test(\"29\", \"-27\", \"8\", true);\n    test(\"29\", \"-27\", \"16\", false);\n    test(\"29\", \"-27\", \"3\", false);\n    test(\"999999999999\", \"-1\", \"4096\", true);\n    test(\"999999999999\", \"-1\", \"8192\", false);\n    test(\"12345678987654321\", \"-679\", \"1000\", true);\n    test(\"12345678987654321\", \"-680\", \"1000\", false);\n    test(\"1000000001234\", \"-999999999766\", \"1000\", true);\n    test(\"1000000001234\", \"-999999999767\", \"1000\", false);\n    test(\"1000000001234\", \"-999999998766\", \"1000000000000\", true);\n    test(\"1000000001234\", \"-999999998767\", \"1000000000000\", false);\n\n    test(\"-1\", \"0\", \"0\", false);\n    test(\"-57\", \"57\", \"0\", false);\n    test(\"-57\", \"58\", \"0\", false);\n    test(\"-1000000000000\", \"57\", \"0\", false);\n    test(\"-256\", \"0\", \"256\", true);\n    test(\"-256\", \"0\", \"512\", false);\n    test(\"-13\", \"27\", \"10\", true);\n    test(\"-13\", \"28\", \"10\", false);\n    test(\"-29\", \"27\", \"1\", true);\n    test(\"-29\", \"27\", \"2\", true);\n    test(\"-29\", \"27\", \"4\", true);\n    test(\"-29\", \"27\", \"8\", true);\n    test(\"-29\", \"27\", \"16\", false);\n    test(\"-29\", \"27\", \"3\", false);\n    test(\"-999999999999\", \"1\", \"4096\", true);\n    test(\"-999999999999\", \"1\", \"8192\", false);\n    test(\"-12345678987654321\", \"679\", \"1000\", true);\n    test(\"-12345678987654321\", \"680\", \"1000\", false);\n    test(\"-1000000001234\", \"999999999766\", \"1000\", true);\n    test(\"-1000000001234\", \"999999999767\", \"1000\", false);\n    test(\"-1000000001234\", \"999999998766\", \"1000000000000\", true);\n    test(\"-1000000001234\", \"999999998767\", \"1000000000000\", false);\n\n    test(\"-57\", \"-57\", \"0\", true);\n    test(\"-57\", \"-58\", \"0\", false);\n    test(\"-1000000000000\", \"-57\", \"0\", false);\n    test(\"-13\", \"-23\", \"10\", true);\n    test(\"-13\", \"-24\", \"10\", false);\n    test(\"-13\", \"-21\", \"1\", true);\n    test(\"-13\", \"-21\", \"2\", true);\n    test(\"-13\", \"-21\", \"4\", true);\n    test(\"-13\", \"-21\", \"8\", true);\n    test(\"-13\", \"-21\", \"16\", false);\n    test(\"-13\", \"-21\", \"3\", false);\n    test(\"-1000000000001\", \"-1\", \"4096\", true);\n    test(\"-1000000000001\", \"-1\", \"8192\", false);\n    test(\"-12345678987654321\", \"-321\", \"1000\", true);\n    test(\"-12345678987654321\", \"-322\", \"1000\", false);\n    test(\"-1234\", \"-1234\", \"1000000000000\", true);\n    test(\"-1234\", \"-1235\", \"1000000000000\", false);\n    test(\"-1000000001234\", \"-1000000002234\", \"1000\", true);\n    test(\"-1000000001234\", \"-1000000002235\", \"1000\", false);\n    test(\"-1000000001234\", \"-1234\", \"1000000000000\", true);\n    test(\"-1000000001234\", \"-1235\", \"1000000000000\", false);\n    test(\"-1000000001234\", \"-5000000001234\", \"1000000000000\", true);\n    test(\"-1000000001234\", \"-5000000001235\", \"1000000000000\", false);\n}\n\n#[test]\nfn limbs_eq_neg_limb_mod_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_7().test_properties_with_config(\n        &config,\n        |(xs, y, m)| {\n            let equal = limbs_eq_neg_limb_mod_limb(&xs, y, m);\n            assert_eq!(\n                (-Natural::from_owned_limbs_asc(xs)).eq_mod(Integer::from(y), Natural::from(m)),\n                equal\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_pos_limb_eq_neg_limb_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_5().test_properties_with_config(\n        &config,\n        |(ms, x, y)| {\n            let equal = limbs_pos_limb_eq_neg_limb_mod(x, y, &ms);\n            let x = Integer::from(x);\n            let y = -Natural::from(y);\n            let m = Natural::from_owned_limbs_asc(ms);\n            assert_eq!((&x).eq_mod(&y, &m), equal);\n            let m = Integer::from(m);\n            assert_eq!(\n                x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n                equal\n            );\n            assert_eq!((x - y).divisible_by(m), equal);\n        },\n    );\n\n    unsigned_vec_unsigned_unsigned_triple_gen_var_6().test_properties_with_config(\n        &config,\n        |(ms, x, y)| {\n            assert!(!limbs_pos_limb_eq_neg_limb_mod(x, y, &ms));\n            let x = Integer::from(x);\n            let y = -Natural::from(y);\n            let m = Natural::from_owned_limbs_asc(ms);\n            assert!(!(&x).eq_mod(&y, &m));\n            let m = Integer::from(m);\n            assert!(x != y && (m == 0 || (&x).mod_op(&m) != (&y).mod_op(&m)));\n            assert!(!(x - y).divisible_by(m));\n        },\n    );\n}\n\n#[test]\nfn limbs_pos_eq_neg_limb_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().test_properties_with_config(\n        &config,\n        |(xs, mut ms, y)| {\n            let equal = limbs_pos_eq_neg_limb_mod_ref(&xs, y, &ms);\n            let m = Natural::from_limbs_asc(&ms);\n            assert_eq!(limbs_pos_eq_neg_limb_mod(&xs, y, &mut ms), equal);\n            let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n            let y = -Natural::from(y);\n\n            assert_eq!((&x).eq_mod(&y, &m), equal);\n            let m = Integer::from(m);\n            assert_eq!(\n                x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n                equal\n            );\n            assert_eq!((x - y).divisible_by(m), equal);\n        },\n    );\n\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_2().test_properties_with_config(\n        &config,\n        |(xs, y, mut ms)| {\n            assert!(limbs_pos_eq_neg_limb_mod_ref(&xs, y, &ms));\n            let m = Natural::from_limbs_asc(&ms);\n            assert!(limbs_pos_eq_neg_limb_mod(&xs, y, &mut ms));\n            let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n            let y = -Natural::from(y);\n            assert!((&x).eq_mod(&y, &m));\n            let m = Integer::from(m);\n            assert!(x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m));\n            assert!((x - y).divisible_by(m));\n        },\n    );\n\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_3().test_properties_with_config(\n        &config,\n        |(xs, y, mut ms)| {\n            assert!(!limbs_pos_eq_neg_limb_mod_ref(&xs, y, &ms));\n            let m = Natural::from_limbs_asc(&ms);\n            assert!(!limbs_pos_eq_neg_limb_mod(&xs, y, &mut ms));\n            let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n            let y = -Natural::from(y);\n            assert!(!(&x).eq_mod(&y, &m));\n            let m = Integer::from(m);\n            assert!(x != y && (m == 0 || (&x).mod_op(&m) != (&y).mod_op(&m)));\n            assert!(!(x - y).divisible_by(m));\n        },\n    );\n}\n\n#[test]\nfn limbs_pos_eq_neg_mod_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().test_properties_with_config(\n        &config,\n        |(xs, ys, m)| {\n            let equal = limbs_pos_eq_neg_mod_limb(&xs, &ys, m);\n            let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n            let y = -Natural::from_owned_limbs_asc(ys);\n            let m = Natural::from(m);\n            assert_eq!((&x).eq_mod(&y, &m), equal);\n            let m = Integer::from(m);\n            assert_eq!(\n                x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n                equal\n            );\n            assert_eq!((x - y).divisible_by(m), equal);\n        },\n    );\n\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_7().test_properties_with_config(\n        &config,\n        |(xs, ys, m)| {\n            assert!(limbs_pos_eq_neg_mod_limb(&xs, &ys, m));\n            let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n            let y = -Natural::from_owned_limbs_asc(ys);\n            let m = Natural::from(m);\n            assert!((&x).eq_mod(&y, &m));\n            let m = Integer::from(m);\n            assert!(x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m));\n            assert!((x - y).divisible_by(m));\n        },\n    );\n\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_8().test_properties_with_config(\n        &config,\n        |(xs, ys, m)| {\n            assert!(!limbs_pos_eq_neg_mod_limb(&xs, &ys, m));\n            let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n            let y = -Natural::from_owned_limbs_asc(ys);\n            let m = Natural::from(m);\n            assert!(!(&x).eq_mod(&y, &m));\n            let m = Integer::from(m);\n            assert!(x != y && (m == 0 || (&x).mod_op(&m) != (&y).mod_op(&m)));\n            assert!(!(x - y).divisible_by(m));\n        },\n    );\n}\n\n#[test]\nfn limbs_pos_eq_neg_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_36().test_properties_with_config(&config, |(xs, ys, mut ms)| {\n        let equal = limbs_pos_eq_neg_mod_ref(&xs, &ys, &ms);\n        let m = Natural::from_limbs_asc(&ms);\n        assert_eq!(limbs_pos_eq_neg_mod(&xs, &ys, &mut ms), equal);\n        let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n        let y = -Natural::from_owned_limbs_asc(ys);\n        assert_eq!((&x).eq_mod(&y, &m), equal);\n        let m = Integer::from(m);\n        assert_eq!(\n            x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m),\n            equal\n        );\n        assert_eq!((x - y).divisible_by(m), equal);\n    });\n\n    unsigned_vec_triple_gen_var_37().test_properties_with_config(&config, |(xs, ys, mut ms)| {\n        assert!(limbs_pos_eq_neg_mod_ref(&xs, &ys, &ms));\n        let m = Natural::from_limbs_asc(&ms);\n        assert!(limbs_pos_eq_neg_mod(&xs, &ys, &mut ms));\n        let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n        let y = -Natural::from_owned_limbs_asc(ys);\n        assert!((&x).eq_mod(&y, &m));\n        let m = Integer::from(m);\n        assert!(x == y || m != 0 && (&x).mod_op(&m) == (&y).mod_op(&m));\n        assert!((x - y).divisible_by(m));\n    });\n\n    unsigned_vec_triple_gen_var_38().test_properties_with_config(&config, |(xs, ys, mut ms)| {\n        assert!(!limbs_pos_eq_neg_mod_ref(&xs, &ys, &ms));\n        let m = Natural::from_limbs_asc(&ms);\n        assert!(!limbs_pos_eq_neg_mod(&xs, &ys, &mut ms));\n        let x = Integer::from(Natural::from_owned_limbs_asc(xs));\n        let y = -Natural::from_owned_limbs_asc(ys);\n        assert!(!(&x).eq_mod(&y, &m));\n        let m = Integer::from(m);\n        assert!(x != y && (m == 0 || (&x).mod_op(&m) != (&y).mod_op(&m)));\n        assert!(!(x - y).divisible_by(m));\n    });\n}\n\n#[test]\nfn eq_mod_properties() {\n    integer_integer_natural_triple_gen().test_properties(|(x, y, m)| {\n        let equal = (&x).eq_mod(&y, &m);\n        assert_eq!((&y).eq_mod(&x, &m), equal);\n\n        assert_eq!((&x).eq_mod(&y, m.clone()), equal);\n        assert_eq!((&x).eq_mod(y.clone(), &m), equal);\n        assert_eq!((&x).eq_mod(y.clone(), m.clone()), equal);\n        assert_eq!(x.clone().eq_mod(&y, &m), equal);\n        assert_eq!(x.clone().eq_mod(&y, m.clone()), equal);\n        assert_eq!(x.clone().eq_mod(y.clone(), &m), equal);\n        assert_eq!(x.clone().eq_mod(y.clone(), m.clone()), equal);\n\n        assert_eq!((-&x).eq_mod(-&y, &m), equal);\n        assert_eq!((&x - &y).divisible_by(Integer::from(&m)), equal);\n        assert_eq!((&y - &x).divisible_by(Integer::from(&m)), equal);\n        assert_eq!(\n            rug::Integer::from(&x).is_congruent(&rug::Integer::from(&y), &rug::Integer::from(&m)),\n            equal\n        );\n    });\n\n    integer_integer_natural_triple_gen_var_1().test_properties(|(ref x, ref y, ref m)| {\n        assert!(x.eq_mod(y, m));\n        assert!(y.eq_mod(x, m));\n        assert!(rug::Integer::from(x).is_congruent(&rug::Integer::from(y), &rug::Integer::from(m)));\n    });\n\n    integer_integer_natural_triple_gen_var_2().test_properties(|(ref x, ref y, ref m)| {\n        assert!(!x.eq_mod(y, m));\n        assert!(!y.eq_mod(x, m));\n        assert!(\n            !rug::Integer::from(x).is_congruent(&rug::Integer::from(y), &rug::Integer::from(m))\n        );\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert!((&x).eq_mod(&y, Natural::ONE));\n        assert_eq!((&x).eq_mod(&y, Natural::ZERO), x == y);\n    });\n\n    integer_natural_pair_gen().test_properties(|(x, m)| {\n        assert_eq!(\n            (&x).eq_mod(Integer::ZERO, &m),\n            (&x).divisible_by(Integer::from(&m))\n        );\n        assert!((&x).eq_mod(&x, m));\n    });\n\n    natural_triple_gen().test_properties(|(x, y, m)| {\n        assert_eq!(\n            Integer::from(&x).eq_mod(Integer::from(&y), &m),\n            x.eq_mod(y, m)\n        );\n    });\n\n    signed_triple_gen::<SignedLimb>().test_properties(|(x, y, m)| {\n        assert_eq!(\n            Integer::from(x).eq_mod(Integer::from(y), Integer::from(m).unsigned_abs()),\n            x.eq_mod(y, m)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, EqModPowerOf2, ModPowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_signed_unsigned_triple_gen_var_2, unsigned_vec_unsigned_unsigned_triple_gen_var_8,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::arithmetic::eq_mod_power_of_2::{\n    limbs_eq_mod_power_of_2_neg_limb, limbs_eq_mod_power_of_2_neg_pos,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_integer_integer_unsigned_quadruple_gen_var_1,\n    integer_integer_unsigned_triple_gen_var_1, integer_integer_unsigned_triple_gen_var_2,\n    integer_integer_unsigned_triple_gen_var_3, integer_pair_gen, integer_unsigned_pair_gen_var_2,\n    natural_natural_unsigned_triple_gen_var_1,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_mod_power_of_2_neg_limb() {\n    let test = |xs, y, pow, out| {\n        assert_eq!(limbs_eq_mod_power_of_2_neg_limb(xs, y, pow), out);\n    };\n    let width = Limb::WIDTH;\n    test(&[1, 1], 3, 0, true);\n    test(&[1, 1], 3, 1, true);\n    test(&[1, 1], 3, 2, true);\n    test(&[1, 1], 3, 3, false);\n    test(&[1, 1], u32::MAX, 0, true);\n    test(&[1, 1], u32::MAX, 1, true);\n    test(&[1, 1], u32::MAX, width, true);\n    test(&[1, 1], u32::MAX, width + 1, true);\n    test(&[1, 2], u32::MAX, width + 1, false);\n    test(&[1, u32::MAX, u32::MAX], u32::MAX, width + 1, true);\n    test(&[1, u32::MAX, u32::MAX], u32::MAX, 2 * width, true);\n    test(&[1, u32::MAX, u32::MAX], u32::MAX, 3 * width - 1, true);\n    test(&[1, u32::MAX, u32::MAX], u32::MAX, 3 * width, true);\n    test(&[1, u32::MAX, u32::MAX], u32::MAX, 3 * width + 1, false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_mod_power_of_2_neg_pos() {\n    let test = |xs, ys, pow, out| {\n        assert_eq!(limbs_eq_mod_power_of_2_neg_pos(xs, ys, pow), out);\n    };\n    test(&[0b1111011, 0b111001000], &[0b10101], 4, true);\n    test(&[0b1111011, 0b111001000], &[0b10101], 5, false);\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b11111111111111111111111110000101, 0b1111],\n        35,\n        true,\n    );\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b11111111111111111111111110000101, 0b1111],\n        36,\n        false,\n    );\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b11111111111111111111111110000101, 0b1111],\n        100,\n        false,\n    );\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b11111111111111111111111110000101, 0b10111],\n        37,\n        true,\n    );\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b11111111111111111111111110000101, 0b10111],\n        38,\n        false,\n    );\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b11111111111111111111111110000101, 0b10111],\n        100,\n        false,\n    );\n\n    test(\n        &[0xabcdabcd, 0x12341234],\n        &[0x54325433, 0xedcbedcb],\n        64,\n        true,\n    );\n    test(&[0xabcdabcd, 0x12341234], &[0, 0xedcbedcb], 64, false);\n    test(\n        &[0xabcdabcd, 0x12341234],\n        &[0x54325433, 0xedcbedcb],\n        65,\n        false,\n    );\n    test(\n        &[0xabcdabcd, 0x12341234],\n        &[0x54325433, 0xedcbedcb],\n        128,\n        false,\n    );\n    test(&[0, 0, 0x12341234], &[0, 0, 0x1234edcc], 80, true);\n\n    test(\n        &[0x54325433, 0xedcbedcb],\n        &[0xabcdabcd, 0x12341234],\n        64,\n        true,\n    );\n    test(&[0, 0xedcbedcb], &[0xabcdabcd, 0x12341234], 64, false);\n    test(\n        &[0x54325433, 0xedcbedcb],\n        &[0xabcdabcd, 0x12341234],\n        65,\n        false,\n    );\n    test(\n        &[0x54325433, 0xedcbedcb],\n        &[0xabcdabcd, 0x12341234],\n        128,\n        false,\n    );\n    test(&[0, 0, 0x1234edcc], &[0, 0, 0x12341234], 80, true);\n}\n\n#[test]\nfn test_eq_mod_power_of_2() {\n    let test = |x, y, pow, out| {\n        assert_eq!(\n            Integer::from_str(x)\n                .unwrap()\n                .eq_mod_power_of_2(&Integer::from_str(y).unwrap(), pow),\n            out\n        );\n        #[cfg(feature = \"32_bit_limbs\")]\n        assert_eq!(\n            rug::Integer::from_str(x)\n                .unwrap()\n                .is_congruent_2pow(&rug::Integer::from_str(y).unwrap(), Limb::exact_from(pow)),\n            out\n        );\n    };\n    test(\"0\", \"256\", 8, true);\n    test(\"0\", \"256\", 9, false);\n\n    test(\"13\", \"21\", 0, true);\n    test(\"13\", \"21\", 1, true);\n    test(\"13\", \"21\", 2, true);\n    test(\"13\", \"21\", 3, true);\n    test(\"13\", \"21\", 4, false);\n    test(\"13\", \"21\", 100, false);\n    test(\"1000000000001\", \"1\", 12, true);\n    test(\"1000000000001\", \"1\", 13, false);\n    test(\"4294967295\", \"4294967295\", 32, true);\n    test(\"281474976710672\", \"844424930131984\", 49, true);\n    test(\"281474976710672\", \"844424930131984\", 50, false);\n\n    test(\"0\", \"-256\", 8, true);\n    test(\"0\", \"-256\", 9, false);\n    test(\"-13\", \"27\", 0, true);\n    test(\"-13\", \"27\", 1, true);\n    test(\"-13\", \"27\", 2, true);\n    test(\"-13\", \"27\", 3, true);\n    test(\"-13\", \"27\", 4, false);\n    test(\"-13\", \"27\", 100, false);\n    test(\"13\", \"-27\", 0, true);\n    test(\"13\", \"-27\", 1, true);\n    test(\"13\", \"-27\", 2, true);\n    test(\"13\", \"-27\", 3, true);\n    test(\"13\", \"-27\", 4, false);\n    test(\"13\", \"-27\", 100, false);\n    test(\"-1000000000001\", \"4095\", 13, true);\n    test(\"-1000000000001\", \"4095\", 14, false);\n    test(\"1000000000001\", \"-4095\", 13, true);\n    test(\"1000000000001\", \"-4095\", 14, false);\n    test(\"4294967295\", \"-1\", 32, true);\n    test(\"-1\", \"4294967295\", 32, true);\n\n    test(\"-13\", \"-21\", 0, true);\n    test(\"-13\", \"-21\", 1, true);\n    test(\"-13\", \"-21\", 2, true);\n    test(\"-13\", \"-21\", 3, true);\n    test(\"-13\", \"-21\", 4, false);\n    test(\"-13\", \"-21\", 100, false);\n    test(\"-1000000000001\", \"-1\", 12, true);\n    test(\"-1000000000001\", \"-1\", 13, false);\n    test(\"-4294967295\", \"-4294967295\", 32, true);\n    test(\"-281474976710672\", \"-844424930131984\", 49, true);\n    test(\"-281474976710672\", \"-844424930131984\", 50, false);\n\n    test(\"1311693408901639117\", \"-17135050664807912499\", 64, true);\n    test(\"1311693408901639117\", \"-17135050663395328000\", 64, false);\n    test(\"1311693408901639117\", \"-17135050664807912499\", 65, false);\n    test(\"1311693408901639117\", \"-17135050664807912499\", 128, false);\n    test(\n        \"5633680281231555440641310720\",\n        \"-5634717283396403096794955776\",\n        80,\n        true,\n    );\n\n    test(\"-1311693408901639117\", \"17135050664807912499\", 64, true);\n    test(\"-1311693408901639117\", \"17135050663395328000\", 64, false);\n    test(\"-1311693408901639117\", \"17135050664807912499\", 65, false);\n    test(\"-1311693408901639117\", \"17135050664807912499\", 128, false);\n    test(\n        \"-5633680281231555440641310720\",\n        \"5634717283396403096794955776\",\n        80,\n        true,\n    );\n    test(\"18446744073709541007\", \"-10609\", 64, true);\n    test(\"18446744073709541007\", \"-10609\", 65, false);\n    test(\"79228162514264337589248972431\", \"-4294977905\", 96, true);\n    test(\"79228162514264337589248972431\", \"-4294977905\", 97, false);\n}\n\n#[test]\nfn limbs_eq_mod_power_of_2_neg_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_8().test_properties_with_config(\n        &config,\n        |(xs, y, pow)| {\n            assert_eq!(\n                limbs_eq_mod_power_of_2_neg_limb(&xs, y, pow),\n                (-Natural::from_owned_limbs_asc(xs)).eq_mod_power_of_2(&Integer::from(y), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_eq_mod_power_of_2_neg_pos_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9().test_properties_with_config(\n        &config,\n        |(xs, ys, pow)| {\n            assert_eq!(\n                limbs_eq_mod_power_of_2_neg_pos(&xs, &ys, pow),\n                (-Natural::from_owned_limbs_asc(xs))\n                    .eq_mod_power_of_2(&Integer::from(Natural::from_owned_limbs_asc(ys)), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn eq_mod_power_of_2_properties() {\n    integer_integer_unsigned_triple_gen_var_1().test_properties(|(x, y, pow)| {\n        let eq_mod_power_of_2 = x.eq_mod_power_of_2(&y, pow);\n        #[cfg(feature = \"32_bit_limbs\")]\n        assert_eq!(\n            rug::Integer::from(&x)\n                .is_congruent_2pow(&rug::Integer::from(&y), Limb::exact_from(pow)),\n            eq_mod_power_of_2\n        );\n        assert_eq!(y.eq_mod_power_of_2(&x, pow), eq_mod_power_of_2);\n        assert_eq!(\n            x.mod_power_of_2(pow) == y.mod_power_of_2(pow),\n            eq_mod_power_of_2,\n        );\n    });\n\n    integer_integer_unsigned_triple_gen_var_2().test_properties(|(x, y, pow)| {\n        assert!(x.eq_mod_power_of_2(&y, pow), \"{x} {y} {pow}\");\n        #[cfg(feature = \"32_bit_limbs\")]\n        assert!(\n            rug::Integer::from(&x)\n                .is_congruent_2pow(&rug::Integer::from(&y), Limb::exact_from(pow))\n        );\n        assert!(y.eq_mod_power_of_2(&x, pow));\n        assert_eq!(x.mod_power_of_2(pow), y.mod_power_of_2(pow));\n    });\n\n    integer_integer_unsigned_triple_gen_var_3().test_properties(|(x, y, pow)| {\n        assert!(!x.eq_mod_power_of_2(&y, pow));\n        #[cfg(feature = \"32_bit_limbs\")]\n        assert!(\n            !rug::Integer::from(&x)\n                .is_congruent_2pow(&rug::Integer::from(&y), Limb::exact_from(pow))\n        );\n        assert!(!y.eq_mod_power_of_2(&x, pow));\n        assert_ne!(x.mod_power_of_2(pow), y.mod_power_of_2(pow));\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, pow)| {\n        assert!(n.eq_mod_power_of_2(&n, pow));\n        assert_eq!(\n            n.eq_mod_power_of_2(&Integer::ZERO, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n        assert_eq!(\n            Integer::ZERO.eq_mod_power_of_2(&n, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n    });\n\n    integer_integer_integer_unsigned_quadruple_gen_var_1().test_properties(|(x, y, z, pow)| {\n        if x.eq_mod_power_of_2(&y, pow) && y.eq_mod_power_of_2(&z, pow) {\n            assert!(x.eq_mod_power_of_2(&z, pow));\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert!(x.eq_mod_power_of_2(&y, 0));\n    });\n\n    natural_natural_unsigned_triple_gen_var_1().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.eq_mod_power_of_2(&y, pow),\n            Integer::from(x).eq_mod_power_of_2(&Integer::from(y), pow),\n        );\n    });\n\n    signed_signed_unsigned_triple_gen_var_2::<SignedLimb, u64>().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.eq_mod_power_of_2(y, pow),\n            Integer::from(x).eq_mod_power_of_2(&Integer::from(y), pow),\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivExact, ExtendedGcd, Gcd};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen};\nuse num::BigInt;\nuse num::Integer as NumInteger;\nuse std::cmp::min;\nuse std::str::FromStr;\n\n#[test]\nfn test_extended_gcd() {\n    let test = |s, t, gcd, x, y| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let result = u.clone().extended_gcd(v.clone());\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        let result = (&u).extended_gcd(v.clone());\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        let result = u.clone().extended_gcd(&v);\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        let result = (&u).extended_gcd(&v);\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        if u != 0u32 || v != 0u32 {\n            let result = BigInt::from_str(s)\n                .unwrap()\n                .extended_gcd(&BigInt::from_str(t).unwrap());\n            assert_eq!(result.gcd.to_string(), gcd);\n            assert_eq!(result.x.to_string(), x);\n            assert_eq!(result.y.to_string(), y);\n        }\n\n        let result = rug::Integer::from_str(s)\n            .unwrap()\n            .extended_gcd(rug::Integer::from_str(t).unwrap(), rug::Integer::new());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n    };\n    test(\"0\", \"0\", \"0\", \"0\", \"0\");\n    test(\"0\", \"1\", \"1\", \"0\", \"1\");\n    test(\"0\", \"-1\", \"1\", \"0\", \"-1\");\n    test(\"1\", \"0\", \"1\", \"1\", \"0\");\n    test(\"-1\", \"0\", \"1\", \"-1\", \"0\");\n    test(\"1\", \"1\", \"1\", \"0\", \"1\");\n    test(\"1\", \"-1\", \"1\", \"0\", \"-1\");\n    test(\"-1\", \"1\", \"1\", \"0\", \"1\");\n    test(\"-1\", \"-1\", \"1\", \"0\", \"-1\");\n    test(\"0\", \"6\", \"6\", \"0\", \"1\");\n    test(\"0\", \"-6\", \"6\", \"0\", \"-1\");\n    test(\"6\", \"0\", \"6\", \"1\", \"0\");\n    test(\"-6\", \"0\", \"6\", \"-1\", \"0\");\n    test(\"1\", \"6\", \"1\", \"1\", \"0\");\n    test(\"1\", \"-6\", \"1\", \"1\", \"0\");\n    test(\"-1\", \"6\", \"1\", \"-1\", \"0\");\n    test(\"-1\", \"-6\", \"1\", \"-1\", \"0\");\n    test(\"6\", \"1\", \"1\", \"0\", \"1\");\n    test(\"6\", \"-1\", \"1\", \"0\", \"-1\");\n    test(\"-6\", \"1\", \"1\", \"0\", \"1\");\n    test(\"-6\", \"-1\", \"1\", \"0\", \"-1\");\n    test(\"6\", \"6\", \"6\", \"0\", \"1\");\n    test(\"6\", \"-6\", \"6\", \"0\", \"-1\");\n    test(\"-6\", \"6\", \"6\", \"0\", \"1\");\n    test(\"-6\", \"-6\", \"6\", \"0\", \"-1\");\n    test(\"8\", \"12\", \"4\", \"-1\", \"1\");\n    test(\"54\", \"24\", \"6\", \"1\", \"-2\");\n    test(\"42\", \"56\", \"14\", \"-1\", \"1\");\n    test(\"48\", \"18\", \"6\", \"-1\", \"3\");\n    test(\"3\", \"5\", \"1\", \"2\", \"-1\");\n    test(\"12\", \"90\", \"6\", \"-7\", \"1\");\n    test(\"240\", \"46\", \"2\", \"-9\", \"47\");\n    test(\"240\", \"-46\", \"2\", \"-9\", \"-47\");\n    test(\"-240\", \"46\", \"2\", \"9\", \"47\");\n    test(\"-240\", \"-46\", \"2\", \"9\", \"-47\");\n    test(\"-128\", \"-128\", \"128\", \"0\", \"-1\");\n    test(\"0\", \"-128\", \"128\", \"0\", \"-1\");\n    test(\"-128\", \"0\", \"128\", \"-1\", \"0\");\n    test(\"12\", \"60\", \"12\", \"1\", \"0\");\n    test(\"-12\", \"60\", \"12\", \"-1\", \"0\");\n    test(\"12\", \"-60\", \"12\", \"1\", \"0\");\n    test(\"-12\", \"-60\", \"12\", \"-1\", \"0\");\n    test(\"60\", \"12\", \"12\", \"0\", \"1\");\n    test(\"-60\", \"12\", \"12\", \"0\", \"1\");\n    test(\"60\", \"-12\", \"12\", \"0\", \"-1\");\n    test(\"-60\", \"-12\", \"12\", \"0\", \"-1\");\n    test(\n        \"12345678987654321\",\n        \"98765432123456789\",\n        \"1\",\n        \"1777777788\",\n        \"-222222223\",\n    );\n    test(\n        \"12345678987654321\",\n        \"-98765432123456789\",\n        \"1\",\n        \"1777777788\",\n        \"222222223\",\n    );\n    test(\n        \"-12345678987654321\",\n        \"98765432123456789\",\n        \"1\",\n        \"-1777777788\",\n        \"-222222223\",\n    );\n    test(\n        \"-12345678987654321\",\n        \"-98765432123456789\",\n        \"1\",\n        \"-1777777788\",\n        \"222222223\",\n    );\n    test(\n        \"12345678987654321\",\n        \"98765432123456827\",\n        \"37\",\n        \"-577153682403132\",\n        \"72144210138067\",\n    );\n    test(\n        \"12345678987654321\",\n        \"-98765432123456827\",\n        \"37\",\n        \"-577153682403132\",\n        \"-72144210138067\",\n    );\n    test(\n        \"-12345678987654321\",\n        \"98765432123456827\",\n        \"37\",\n        \"577153682403132\",\n        \"72144210138067\",\n    );\n    test(\n        \"-12345678987654321\",\n        \"-98765432123456827\",\n        \"37\",\n        \"577153682403132\",\n        \"-72144210138067\",\n    );\n}\n\n#[test]\nfn extended_gcd_properties() {\n    integer_pair_gen().test_properties(|(a, b): (Integer, Integer)| {\n        let result_val_val = a.clone().extended_gcd(b.clone());\n        let result_val_ref = a.clone().extended_gcd(&b);\n        let result_ref_val = (&a).extended_gcd(b.clone());\n        let result = (&a).extended_gcd(&b);\n        assert!(result_val_val.0.is_valid());\n        assert!(result_val_val.1.is_valid());\n        assert!(result_val_val.2.is_valid());\n        assert!(result_val_ref.0.is_valid());\n        assert!(result_val_ref.1.is_valid());\n        assert!(result_val_ref.2.is_valid());\n        assert!(result_ref_val.0.is_valid());\n        assert!(result_ref_val.1.is_valid());\n        assert!(result_ref_val.2.is_valid());\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        let (gcd, x, y) = result;\n\n        if a != 0u32 || b != 0u32 {\n            let num_result = BigInt::from(&a).extended_gcd(&BigInt::from(&b));\n            assert_eq!(Integer::from(&num_result.gcd), gcd);\n            assert_eq!(Integer::from(&num_result.x), x);\n            assert_eq!(Integer::from(&num_result.y), y);\n        }\n\n        let (rug_gcd, rug_x, rug_y) =\n            rug::Integer::from(&a).extended_gcd(rug::Integer::from(&b), rug::Integer::new());\n        assert_eq!(Natural::exact_from(&rug_gcd), gcd);\n        assert_eq!(Integer::from(&rug_x), x);\n        assert_eq!(Integer::from(&rug_y), y);\n\n        assert_eq!(a.unsigned_abs_ref().gcd(b.unsigned_abs_ref()), gcd);\n        assert_eq!(&a * &x + &b * &y, Integer::from(&gcd));\n\n        // uniqueness\n        if a != 0u32 && b != 0u32 && &gcd != min(a.unsigned_abs_ref(), b.unsigned_abs_ref()) {\n            assert!(x.le_abs(&((&b).div_exact(Integer::from(&gcd)) >> 1u32)));\n            assert!(y.le_abs(&((&a).div_exact(Integer::from(&gcd)) >> 1u32)));\n        }\n\n        let reverse = (&b).extended_gcd(&a);\n        if a == b {\n            assert_eq!(reverse, (gcd, x, y));\n        } else if a == -b {\n            assert_eq!(reverse, (gcd, x, -y));\n        } else {\n            assert_eq!(reverse, (gcd, y, x));\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        if x != 0u32 {\n            let result = (&x).extended_gcd(&x);\n            assert_eq!(result.0, *x.unsigned_abs_ref());\n            assert_eq!(result.1, 0u32);\n            assert_eq!(result.2, if x >= 0u32 { 1i32 } else { -1i32 });\n            let result = (&x).extended_gcd(-&x);\n            assert_eq!(result.0, *x.unsigned_abs_ref());\n            assert_eq!(result.1, 0u32);\n            assert_eq!(result.2, if x < 0u32 { 1i32 } else { -1i32 });\n            let result = (&x).extended_gcd(Integer::ZERO);\n            assert_eq!(result.0, *x.unsigned_abs_ref());\n            assert_eq!(result.1, if x >= 0u32 { 1i32 } else { -1i32 });\n            assert_eq!(result.2, 0u32);\n            let result = Integer::ZERO.extended_gcd(&x);\n            assert_eq!(result.0, *x.unsigned_abs_ref());\n            assert_eq!(result.1, 0u32);\n            assert_eq!(result.2, if x >= 0u32 { 1i32 } else { -1i32 });\n        }\n        if *x.unsigned_abs_ref() != 1u32 {\n            assert_eq!(\n                Integer::ONE.extended_gcd(&x),\n                (Natural::ONE, Integer::ONE, Integer::ZERO)\n            );\n        }\n        assert_eq!(\n            x.extended_gcd(Integer::ONE),\n            (Natural::ONE, Integer::ZERO, Integer::ONE)\n        );\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(a, b)| {\n        let (u_gcd, u_x, u_y) = a.extended_gcd(b);\n        let (gcd, x, y) = Integer::from(a).extended_gcd(Integer::from(b));\n        assert_eq!(gcd, u_gcd);\n        assert_eq!(x, u_x);\n        assert_eq!(y, u_y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, CoprimeWith, JacobiSymbol, KroneckerSymbol, LegendreSymbol, ModPowerOf2, Sign,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Two, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::WrappingInto;\nuse malachite_base::test_util::generators::{\n    large_type_gen_var_27, signed_pair_gen, signed_pair_gen_var_8,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::arithmetic::kronecker_symbol::limbs_kronecker_symbol;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_9, integer_pair_gen, integer_pair_gen_var_4,\n    integer_pair_gen_var_5, integer_pair_gen_var_6, integer_triple_gen, integer_triple_gen_var_2,\n    integer_triple_gen_var_3,\n};\nuse std::borrow::Cow;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_limbs_kronecker_symbol() {\n    fn test(x_sign: bool, xs: &[Limb], y_sign: bool, ys: &[Limb], s: i8) {\n        let x = Integer::from_sign_and_abs(x_sign, Natural::from_limbs_asc(xs));\n        let y = Integer::from_sign_and_abs(y_sign, Natural::from_limbs_asc(ys));\n        assert_eq!((&x).kronecker_symbol(&y), s);\n        assert_eq!(limbs_kronecker_symbol(x_sign, xs, y_sign, ys), s);\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - ys_len != 0\n        // - xs_len != 0\n        // - (x_lo | y_lo).odd()\n        // - y_sign\n        // - ys_len <= 1 || y_twos == 0 first time\n        // - x_sign\n        // - xs_len >= ys_len\n        // - ys_len == 1\n        // - y_lo == 1\n        test(true, &[1], true, &[1], 1);\n        // - ys_len == 0\n        test(false, &[], false, &[], 0);\n        // - xs_len == 0\n        test(false, &[], false, &[1], 1);\n        // - !y_sign\n        // - !x_sign\n        test(false, &[1], false, &[1], -1);\n        // - y_lo != 1\n        // - xs_len <= 1\n        test(false, &[1], false, &[3], 1);\n        // - (x_lo | y_lo).even()\n        test(false, &[2], false, &[2], 0);\n        // - xs_len < ys_len\n        // - ys_len <= 1 || y_twos == 0 second time\n        test(false, &[1], false, &[1, 1], -1);\n        // - xs_len > 1\n        // - xs.len() < BMOD_1_TO_MOD_1_THRESHOLD\n        test(false, &[3], false, &[1, 1], 1);\n        // - ys_len != 1\n        // - xs_len < ys_len << 1\n        // - xs_len <= ys_len\n        // - y_twos == 0\n        test(false, &[1, 1], false, &[1, 1], 0);\n        // - ys_len > 1 && y_twos != 0 first time\n        // - ys_len == 2 && b1 >> y_twos == 0 first time\n        test(false, &[1], false, &[2, 1], -1);\n        // - ys_len != 2 || b1 >> y_twos != 0 first time\n        test(false, &[1], false, &[2, 2], -1);\n        // - xs_len > ys_len\n        test(false, &[1, 1], false, &[1, 0, 1], -1);\n        // - y_twos != 0\n        test(false, &[1, 1], false, &[2, 2], 0);\n        // - ys_len > 1 && y_twos != 0 second time\n        // - ys_len == 2 && b1 >> y_twos == 0 second time\n        test(false, &[2, 1], false, &[1, 0, 1], -1);\n    }\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - xs_len >= ys_len << 1\n        test(\n            true,\n            &[\n                809415104, 1710169977, 881476190, 1104012799, 1326347481, 682701285, 3321863945,\n                1051939994, 3108635835, 1895680941, 2854018447, 4014565990, 3427834973,\n            ],\n            false,\n            &[1909529931, 430037021],\n            1,\n        );\n        // - ys_len != 2 || b1 >> y_twos != 0 second time\n        test(\n            false,\n            &[3810500016, 962414993, 1954977047],\n            false,\n            &[\n                2965238473, 2597078462, 113721090, 1560538966, 3708600302, 1747115778, 2509295310,\n                3964059579, 1937003961, 3783443612, 1437850759, 686587963, 1405672406,\n            ],\n            1,\n        );\n        // - xs.len() >= BMOD_1_TO_MOD_1_THRESHOLD\n        test(\n            true,\n            &[95723951],\n            true,\n            &[\n                3104822486, 256665209, 1106870463, 2021763401, 3319578375, 3716316846, 413568526,\n                2889388423, 2677034801, 1809274412, 609675151, 2287549814, 2615809925, 2139281936,\n                2621623930, 2423765969, 2490520154, 276871549, 2835834558, 3643930811, 2346794500,\n                1716153848, 2882325673, 197745775, 1455312056, 2481758015, 1539562182, 1248381418,\n                643884751, 3963005283, 3999713854, 570674748, 1646619329, 4056981682, 2746165076,\n                2757679283, 1546323574, 3282851400, 1861976181, 2431917382, 1727042394, 490254435,\n                3636744381, 1560042014, 704706907, 4231077753, 3265644143, 25380599, 1231870002,\n                1477457950, 4289279025, 1339161480, 2290594253, 2530008576,\n            ],\n            1,\n        );\n    }\n}\n\n#[test]\nfn test_legendre_symbol() {\n    fn test(u: &str, v: &str, s: i8) {\n        let a = Integer::from_str(u).unwrap();\n        let n = Integer::from_str(v).unwrap();\n\n        assert_eq!(a.clone().legendre_symbol(n.clone()), s);\n        assert_eq!(a.clone().legendre_symbol(&n), s);\n        assert_eq!((&a).legendre_symbol(n.clone()), s);\n        assert_eq!((&a).legendre_symbol(&n), s);\n\n        assert_eq!(a.clone().jacobi_symbol(n.clone()), s);\n        assert_eq!(a.clone().jacobi_symbol(&n), s);\n        assert_eq!((&a).jacobi_symbol(n.clone()), s);\n        assert_eq!((&a).jacobi_symbol(&n), s);\n\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!((&a).kronecker_symbol(&n), s);\n\n        assert_eq!(\n            rug::Integer::from_str(u)\n                .unwrap()\n                .legendre(&rug::Integer::from_str(v).unwrap()),\n            i32::from(s)\n        );\n    }\n    test(\"0\", \"3\", 0);\n    test(\"1\", \"3\", 1);\n    test(\"2\", \"3\", -1);\n    test(\"0\", \"5\", 0);\n    test(\"1\", \"5\", 1);\n    test(\"2\", \"5\", -1);\n    test(\"3\", \"5\", -1);\n    test(\"4\", \"5\", 1);\n    test(\"0\", \"7\", 0);\n    test(\"1\", \"7\", 1);\n    test(\"2\", \"7\", 1);\n    test(\"3\", \"7\", -1);\n    test(\"4\", \"7\", 1);\n    test(\"5\", \"7\", -1);\n    test(\"6\", \"7\", -1);\n\n    test(\"7\", \"7\", 0);\n    test(\"8\", \"7\", 1);\n    test(\"9\", \"7\", 1);\n    test(\"10\", \"7\", -1);\n    test(\"11\", \"7\", 1);\n    test(\"12\", \"7\", -1);\n    test(\"13\", \"7\", -1);\n\n    test(\"-7\", \"7\", 0);\n    test(\"-6\", \"7\", 1);\n    test(\"-5\", \"7\", 1);\n    test(\"-4\", \"7\", -1);\n    test(\"-3\", \"7\", 1);\n    test(\"-2\", \"7\", -1);\n    test(\"-1\", \"7\", -1);\n\n    test(\"1001\", \"9907\", -1);\n    test(\"10908\", \"9907\", -1);\n    test(\"-8906\", \"9907\", -1);\n}\n\n#[test]\nfn legendre_symbol_fail() {\n    assert_panic!(Integer::ONE.legendre_symbol(Integer::TWO));\n    assert_panic!(Integer::ONE.legendre_symbol(&Integer::TWO));\n    assert_panic!((&Integer::ONE).legendre_symbol(Integer::TWO));\n    assert_panic!((&Integer::ONE).legendre_symbol(&Integer::TWO));\n    assert_panic!(Integer::ONE.legendre_symbol(Integer::NEGATIVE_ONE));\n    assert_panic!(Integer::ONE.legendre_symbol(&Integer::NEGATIVE_ONE));\n    assert_panic!((&Integer::ONE).legendre_symbol(Integer::NEGATIVE_ONE));\n    assert_panic!((&Integer::ONE).legendre_symbol(&Integer::NEGATIVE_ONE));\n}\n\n#[test]\nfn test_jacobi_symbol() {\n    fn test(u: &str, v: &str, s: i8) {\n        let a = Integer::from_str(u).unwrap();\n        let n = Integer::from_str(v).unwrap();\n\n        assert_eq!(a.clone().jacobi_symbol(n.clone()), s);\n        assert_eq!(a.clone().jacobi_symbol(&n), s);\n        assert_eq!((&a).jacobi_symbol(n.clone()), s);\n        assert_eq!((&a).jacobi_symbol(&n), s);\n\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!((&a).kronecker_symbol(&n), s);\n\n        assert_eq!(\n            rug::Integer::from_str(u)\n                .unwrap()\n                .jacobi(&rug::Integer::from_str(v).unwrap()),\n            i32::from(s)\n        );\n    }\n    test(\"0\", \"1\", 1);\n    test(\"0\", \"9\", 0);\n    test(\"1\", \"9\", 1);\n    test(\"2\", \"9\", 1);\n    test(\"3\", \"9\", 0);\n    test(\"4\", \"9\", 1);\n    test(\"5\", \"9\", 1);\n    test(\"6\", \"9\", 0);\n    test(\"7\", \"9\", 1);\n    test(\"8\", \"9\", 1);\n\n    test(\"9\", \"9\", 0);\n    test(\"10\", \"9\", 1);\n    test(\"11\", \"9\", 1);\n    test(\"12\", \"9\", 0);\n    test(\"13\", \"9\", 1);\n    test(\"14\", \"9\", 1);\n    test(\"15\", \"9\", 0);\n    test(\"16\", \"9\", 1);\n    test(\"17\", \"9\", 1);\n\n    test(\"-9\", \"9\", 0);\n    test(\"-8\", \"9\", 1);\n    test(\"-7\", \"9\", 1);\n    test(\"-6\", \"9\", 0);\n    test(\"-5\", \"9\", 1);\n    test(\"-4\", \"9\", 1);\n    test(\"-3\", \"9\", 0);\n    test(\"-2\", \"9\", 1);\n    test(\"-1\", \"9\", 1);\n}\n\n#[test]\nfn jacobi_symbol_fail() {\n    assert_panic!(Integer::ONE.jacobi_symbol(Integer::TWO));\n    assert_panic!(Integer::ONE.jacobi_symbol(&Integer::TWO));\n    assert_panic!((&Integer::ONE).jacobi_symbol(Integer::TWO));\n    assert_panic!((&Integer::ONE).jacobi_symbol(&Integer::TWO));\n    assert_panic!(Integer::ONE.jacobi_symbol(Integer::NEGATIVE_ONE));\n    assert_panic!(Integer::ONE.jacobi_symbol(&Integer::NEGATIVE_ONE));\n    assert_panic!((&Integer::ONE).jacobi_symbol(Integer::NEGATIVE_ONE));\n    assert_panic!((&Integer::ONE).jacobi_symbol(&Integer::NEGATIVE_ONE));\n}\n\n// Odd n is already tested in test_jacobi_symbol, so here we just test even n\n#[test]\nfn test_kronecker_symbol() {\n    fn test(u: &str, v: &str, s: i8) {\n        let a = Integer::from_str(u).unwrap();\n        let n = Integer::from_str(v).unwrap();\n\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!((&a).kronecker_symbol(&n), s);\n\n        assert_eq!(\n            rug::Integer::from_str(u)\n                .unwrap()\n                .kronecker(&rug::Integer::from_str(v).unwrap()),\n            i32::from(s)\n        );\n    }\n    test(\"0\", \"2\", 0);\n    test(\"1\", \"2\", 1);\n    test(\"2\", \"2\", 0);\n    test(\"3\", \"2\", -1);\n    test(\"4\", \"2\", 0);\n    test(\"5\", \"2\", -1);\n    test(\"6\", \"2\", 0);\n    test(\"7\", \"2\", 1);\n    test(\"0\", \"4\", 0);\n    test(\"1\", \"4\", 1);\n    test(\"2\", \"4\", 0);\n    test(\"3\", \"4\", 1);\n    test(\"0\", \"6\", 0);\n    test(\"1\", \"6\", 1);\n    test(\"2\", \"6\", 0);\n    test(\"3\", \"6\", 0);\n    test(\"4\", \"6\", 0);\n    test(\"5\", \"6\", 1);\n    test(\"6\", \"6\", 0);\n    test(\"7\", \"6\", 1);\n    test(\"8\", \"6\", 0);\n    test(\"9\", \"6\", 0);\n    test(\"10\", \"6\", 0);\n    test(\"11\", \"6\", 1);\n    test(\"12\", \"6\", 0);\n    test(\"13\", \"6\", -1);\n    test(\"14\", \"6\", 0);\n    test(\"15\", \"6\", 0);\n    test(\"16\", \"6\", 0);\n    test(\"17\", \"6\", -1);\n    test(\"18\", \"6\", 0);\n    test(\"19\", \"6\", -1);\n    test(\"20\", \"6\", 0);\n    test(\"21\", \"6\", 0);\n    test(\"22\", \"6\", 0);\n    test(\"23\", \"6\", -1);\n\n    test(\"-1\", \"2\", 1);\n    test(\"-2\", \"2\", 0);\n    test(\"-3\", \"2\", -1);\n    test(\"-4\", \"2\", 0);\n    test(\"-5\", \"2\", -1);\n    test(\"-6\", \"2\", 0);\n    test(\"-7\", \"2\", 1);\n    test(\"-1\", \"4\", 1);\n    test(\"-2\", \"4\", 0);\n    test(\"-3\", \"4\", 1);\n    test(\"-1\", \"6\", -1);\n    test(\"-2\", \"6\", 0);\n    test(\"-3\", \"6\", 0);\n    test(\"-4\", \"6\", 0);\n    test(\"-5\", \"6\", -1);\n    test(\"-6\", \"6\", 0);\n    test(\"-7\", \"6\", -1);\n    test(\"-8\", \"6\", 0);\n    test(\"-9\", \"6\", 0);\n    test(\"-10\", \"6\", 0);\n    test(\"-11\", \"6\", -1);\n    test(\"-12\", \"6\", 0);\n    test(\"-13\", \"6\", 1);\n    test(\"-14\", \"6\", 0);\n    test(\"-15\", \"6\", 0);\n    test(\"-16\", \"6\", 0);\n    test(\"-17\", \"6\", 1);\n    test(\"-18\", \"6\", 0);\n    test(\"-19\", \"6\", 1);\n    test(\"-20\", \"6\", 0);\n    test(\"-21\", \"6\", 0);\n    test(\"-22\", \"6\", 0);\n    test(\"-23\", \"6\", 1);\n\n    test(\"0\", \"-2\", 0);\n    test(\"1\", \"-2\", 1);\n    test(\"2\", \"-2\", 0);\n    test(\"3\", \"-2\", -1);\n    test(\"4\", \"-2\", 0);\n    test(\"5\", \"-2\", -1);\n    test(\"6\", \"-2\", 0);\n    test(\"7\", \"-2\", 1);\n    test(\"0\", \"-4\", 0);\n    test(\"1\", \"-4\", 1);\n    test(\"2\", \"-4\", 0);\n    test(\"3\", \"-4\", 1);\n    test(\"0\", \"-6\", 0);\n    test(\"1\", \"-6\", 1);\n    test(\"2\", \"-6\", 0);\n    test(\"3\", \"-6\", 0);\n    test(\"4\", \"-6\", 0);\n    test(\"5\", \"-6\", 1);\n    test(\"6\", \"-6\", 0);\n    test(\"7\", \"-6\", 1);\n    test(\"8\", \"-6\", 0);\n    test(\"9\", \"-6\", 0);\n    test(\"10\", \"-6\", 0);\n    test(\"11\", \"-6\", 1);\n    test(\"12\", \"-6\", 0);\n    test(\"13\", \"-6\", -1);\n    test(\"14\", \"-6\", 0);\n    test(\"15\", \"-6\", 0);\n    test(\"16\", \"-6\", 0);\n    test(\"17\", \"-6\", -1);\n    test(\"18\", \"-6\", 0);\n    test(\"19\", \"-6\", -1);\n    test(\"20\", \"-6\", 0);\n    test(\"21\", \"-6\", 0);\n    test(\"22\", \"-6\", 0);\n    test(\"23\", \"-6\", -1);\n\n    test(\"-1\", \"-2\", -1);\n    test(\"-2\", \"-2\", 0);\n    test(\"-3\", \"-2\", 1);\n    test(\"-4\", \"-2\", 0);\n    test(\"-5\", \"-2\", 1);\n    test(\"-6\", \"-2\", 0);\n    test(\"-7\", \"-2\", -1);\n    test(\"-1\", \"-4\", -1);\n    test(\"-2\", \"-4\", 0);\n    test(\"-3\", \"-4\", -1);\n    test(\"-1\", \"-6\", 1);\n    test(\"-2\", \"-6\", 0);\n    test(\"-3\", \"-6\", 0);\n    test(\"-4\", \"-6\", 0);\n    test(\"-5\", \"-6\", 1);\n    test(\"-6\", \"-6\", 0);\n    test(\"-7\", \"-6\", 1);\n    test(\"-8\", \"-6\", 0);\n    test(\"-9\", \"-6\", 0);\n    test(\"-10\", \"-6\", 0);\n    test(\"-11\", \"-6\", 1);\n    test(\"-12\", \"-6\", 0);\n    test(\"-13\", \"-6\", -1);\n    test(\"-14\", \"-6\", 0);\n    test(\"-15\", \"-6\", 0);\n    test(\"-16\", \"-6\", 0);\n    test(\"-17\", \"-6\", -1);\n    test(\"-18\", \"-6\", 0);\n    test(\"-19\", \"-6\", -1);\n    test(\"-20\", \"-6\", 0);\n    test(\"-21\", \"-6\", 0);\n    test(\"-22\", \"-6\", 0);\n    test(\"-23\", \"-6\", -1);\n\n    test(\"1001\", \"-9908\", -1);\n    test(\"10909\", \"-9908\", -1);\n    test(\"-8907\", \"-9908\", 1);\n}\n\n#[test]\nfn limbs_kronecker_symbol_properties() {\n    large_type_gen_var_27().test_properties(|(x_sign, xs, y_sign, ys)| {\n        let x = Integer::from_sign_and_abs(x_sign, Natural::from_limbs_asc(&xs));\n        let y = Integer::from_sign_and_abs(y_sign, Natural::from_limbs_asc(&ys));\n        let s = (&x).kronecker_symbol(&y);\n        assert_eq!(limbs_kronecker_symbol(x_sign, &xs, y_sign, &ys), s);\n    });\n}\n\n#[test]\nfn jacobi_symbol_properties() {\n    integer_pair_gen_var_4().test_properties(|(a, n)| {\n        let s = (&a).jacobi_symbol(&n);\n        assert_eq!((&a).jacobi_symbol(n.clone()), s);\n        assert_eq!(a.clone().jacobi_symbol(&n), s);\n        assert_eq!(a.clone().jacobi_symbol(n.clone()), s);\n\n        // Legendre should only be called on prime n, but it still works for non-prime odd n and we\n        // can't currently test primality anyway.\n        assert_eq!((&a).legendre_symbol(&n), s);\n        assert_eq!((&a).legendre_symbol(n.clone()), s);\n        assert_eq!(a.clone().legendre_symbol(&n), s);\n        assert_eq!(a.clone().legendre_symbol(n.clone()), s);\n\n        assert_eq!((&a).kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n\n        assert_eq!(\n            rug::Integer::from(&a).jacobi(&rug::Integer::from(&n)),\n            i32::from(s)\n        );\n        assert!(s.le_abs(&1i8));\n\n        assert_eq!((&a + &n).jacobi_symbol(&n), s);\n        assert_eq!((&a - &n).jacobi_symbol(&n), s);\n        assert_eq!(\n            s != 0,\n            a.unsigned_abs_ref().coprime_with(n.unsigned_abs_ref())\n        );\n        let n_mod_8: u8 = (&(&n).mod_power_of_2(3)).wrapping_into();\n        assert_eq!(\n            (&a << 1u32).jacobi_symbol(&n),\n            if n_mod_8 == 1 || n_mod_8 == 7 { s } else { -s }\n        );\n        let n_mod_4: u8 = (&(&n).mod_power_of_2(2)).wrapping_into();\n        assert_eq!((-a).jacobi_symbol(n), if n_mod_4 == 1 { s } else { -s });\n    });\n\n    integer_pair_gen_var_6().test_properties(|(m, n)| {\n        let n_mod_4: u8 = (&(&n).mod_power_of_2(2)).wrapping_into();\n        let m_mod_4: u8 = (&(&m).mod_power_of_2(2)).wrapping_into();\n        assert_eq!(\n            (&m).jacobi_symbol(&n) * n.jacobi_symbol(m),\n            if n_mod_4 == 1 || m_mod_4 == 1 { 1 } else { -1 }\n        );\n    });\n\n    integer_triple_gen_var_2().test_properties(|(a, b, n)| {\n        assert_eq!(\n            (&a * &b).jacobi_symbol(&n),\n            a.jacobi_symbol(&n) * b.jacobi_symbol(n)\n        );\n    });\n\n    integer_triple_gen_var_3().test_properties(|(a, m, n)| {\n        assert_eq!(\n            (&a).jacobi_symbol(&m * &n),\n            (&a).jacobi_symbol(m) * a.jacobi_symbol(n)\n        );\n    });\n\n    integer_gen_var_9().test_properties(|n| {\n        if n != 1u32 {\n            assert_eq!(Integer::ZERO.jacobi_symbol(&n), 0);\n            assert_eq!((&n).jacobi_symbol(&n), 0);\n        }\n        assert_eq!(Integer::ONE.jacobi_symbol(&n), 1);\n        assert_eq!((&n).jacobi_symbol(Integer::ONE), 1);\n        let n_mod_4: u8 = (&(&n).mod_power_of_2(2)).wrapping_into();\n        assert_eq!(\n            Integer::NEGATIVE_ONE.jacobi_symbol(&n),\n            if n_mod_4 == 1 { 1 } else { -1 }\n        );\n        let n_mod_8: u8 = (&(&n).mod_power_of_2(3)).wrapping_into();\n        assert_eq!(\n            Integer::TWO.jacobi_symbol(n),\n            if n_mod_8 == 1 || n_mod_8 == 7 { 1 } else { -1 }\n        );\n    });\n\n    signed_pair_gen_var_8::<Limb, SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(x).jacobi_symbol(Integer::from(y)),\n            x.jacobi_symbol(y)\n        );\n    });\n}\n\n#[test]\nfn kronecker_symbol_properties() {\n    integer_pair_gen().test_properties(|(a, n)| {\n        let s = (&a).kronecker_symbol(&n);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n        assert_eq!(\n            rug::Integer::from(&a).kronecker(&rug::Integer::from(&n)),\n            i32::from(s)\n        );\n        assert!(s.le_abs(&1i8));\n\n        assert_eq!(\n            s != 0,\n            a.unsigned_abs_ref().coprime_with(n.unsigned_abs_ref())\n        );\n        let n_mod_4: u8 = (&(&n).mod_power_of_2(2)).wrapping_into();\n        if n_mod_4 == 2 {\n            let four_n = &n << 2u32;\n            let b = &a + &four_n;\n            if n > 0u32 || a.sign() == b.sign() {\n                assert_eq!(b.kronecker_symbol(&n), s);\n            }\n            let b = &a - four_n;\n            if n > 0u32 || a.sign() == b.sign() {\n                assert_eq!(b.kronecker_symbol(&n), s);\n            }\n        } else {\n            let b = &a + &n;\n            if n > 0u32 || a.sign() == b.sign() {\n                assert_eq!(b.kronecker_symbol(&n), s);\n            }\n            let b = &a - &n;\n            if n > 0u32 || a.sign() == b.sign() {\n                assert_eq!(b.kronecker_symbol(&n), s);\n            }\n        }\n        let a_mod_4: u8 = (&(&a).mod_power_of_2(2)).wrapping_into();\n        if a != 0u32 && a_mod_4 != 3 {\n            let abs_a = (&a).abs();\n            if a_mod_4 == 2 {\n                let four_abs_a = abs_a << 2u32;\n                assert_eq!((&a).kronecker_symbol(&n + &four_abs_a), s);\n                assert_eq!((&a).kronecker_symbol(&n - four_abs_a), s);\n            } else {\n                assert_eq!((&a).kronecker_symbol(&n + &abs_a), s);\n                assert_eq!((&a).kronecker_symbol(&n - abs_a), s);\n            }\n        }\n\n        let m = a;\n        let m_odd = if m == 0u32 {\n            Integer::ONE\n        } else {\n            &m >> m.trailing_zeros().unwrap()\n        };\n        let m_odd_mod_4: u8 = (&(&m_odd).mod_power_of_2(2)).wrapping_into();\n        let m_star = if m_odd_mod_4 == 1 {\n            Cow::Borrowed(&m)\n        } else {\n            Cow::Owned(-&m)\n        };\n        assert_eq!(\n            m_star.as_ref().kronecker_symbol(&n),\n            n.kronecker_symbol(m.abs())\n        );\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        if !(z == -1i32 && (x == 0u32 && y < 0u32 || x < 0u32 && y == 0u32)) {\n            assert_eq!(\n                (&x * &y).kronecker_symbol(&z),\n                (&x).kronecker_symbol(&z) * (&y).kronecker_symbol(&z)\n            );\n        }\n        let y_odd_mod_4: u8 = if y == 0u32 {\n            0\n        } else {\n            (&(&y >> y.trailing_zeros().unwrap()).mod_power_of_2(2)).wrapping_into()\n        };\n        let z_odd_mod_4: u8 = if z == 0u32 {\n            0\n        } else {\n            (&(&z >> z.trailing_zeros().unwrap()).mod_power_of_2(2)).wrapping_into()\n        };\n        if !(x == -1i32 && (y == 0u32 && z_odd_mod_4 == 3 || y_odd_mod_4 == 3 && z == 0u32)) {\n            assert_eq!(\n                (&x).kronecker_symbol(&y * &z),\n                (&x).kronecker_symbol(y) * x.kronecker_symbol(z)\n            );\n        }\n    });\n\n    integer_pair_gen_var_5().test_properties(|(m, n)| {\n        let n_odd = if n == 0u32 {\n            Integer::ONE\n        } else {\n            &n >> n.trailing_zeros().unwrap()\n        };\n        let m_odd = if m == 0u32 {\n            Integer::ONE\n        } else {\n            &m >> m.trailing_zeros().unwrap()\n        };\n        let n_odd_mod_4: u8 = (&n_odd.mod_power_of_2(2)).wrapping_into();\n        let m_odd_mod_4: u8 = (&m_odd.mod_power_of_2(2)).wrapping_into();\n        let p = if n_odd_mod_4 == 1 || m_odd_mod_4 == 1 {\n            1\n        } else {\n            -1\n        };\n        assert_eq!(\n            (&m).kronecker_symbol(&n) * (&n).kronecker_symbol(&m),\n            if m < 0u32 && n < 0u32 { -p } else { p }\n        );\n        assert_eq!((&m).kronecker_symbol(&n) * n.kronecker_symbol(m.abs()), p);\n    });\n\n    integer_gen().test_properties(|n| {\n        if n != 1u32 && n != -1i32 {\n            assert_eq!(Integer::ZERO.kronecker_symbol(&n), 0);\n            assert_eq!((&n).kronecker_symbol(&n), 0);\n        }\n        assert_eq!(Integer::ONE.kronecker_symbol(&n), 1);\n        assert_eq!((&n).kronecker_symbol(Integer::ONE), 1);\n        let n_odd = if n == 0u32 {\n            Integer::ONE\n        } else {\n            &n >> n.trailing_zeros().unwrap()\n        };\n        let n_odd_mod_4: u8 = (&n_odd.mod_power_of_2(2)).wrapping_into();\n        assert_eq!(\n            Integer::NEGATIVE_ONE.kronecker_symbol(&n),\n            if n_odd_mod_4 == 1 { 1 } else { -1 }\n        );\n        assert_eq!(\n            (&n).kronecker_symbol(Integer::NEGATIVE_ONE),\n            if n >= 0u32 { 1 } else { -1 }\n        );\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(x).kronecker_symbol(Integer::from(y)),\n            x.kronecker_symbol(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivMod, CeilingMod, CeilingModAssign, DivMod, DivRem, Mod, ModAssign, NegMod,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::signed_pair_gen_var_4;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_8, integer_pair_gen_var_1, integer_pair_gen_var_2,\n    natural_pair_gen_var_5,\n};\nuse num::{BigInt, Integer as NumInteger};\nuse rug::ops::RemRounding;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod() {\n    let test = |s, t, remainder| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.mod_assign(v.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x.mod_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone().mod_op(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone().mod_op(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).mod_op(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).mod_op(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = BigInt::from_str(s)\n            .unwrap()\n            .mod_floor(&BigInt::from_str(t).unwrap());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = rug::Integer::from_str(s)\n            .unwrap()\n            .rem_floor(rug::Integer::from_str(t).unwrap());\n        assert_eq!(r.to_string(), remainder);\n\n        assert_eq!(u.div_mod(v).1.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"123\");\n    test(\"456\", \"123\", \"87\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"3\", \"1\");\n    test(\"1000000000000\", \"123\", \"100\");\n    test(\"1000000000000\", \"4294967295\", \"3567587560\");\n    test(\"1000000000000000000000000\", \"1\", \"0\");\n    test(\"1000000000000000000000000\", \"3\", \"1\");\n    test(\"1000000000000000000000000\", \"123\", \"37\");\n    test(\"1000000000000000000000000\", \"4294967295\", \"3167723695\");\n    test(\"1000000000000000000000000\", \"1234567890987\", \"530068894399\");\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"3768477692975601\",\n    );\n    test(\"3356605361737854\", \"3081095617839357\", \"275509743898497\");\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"123\");\n\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"0\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"-333\");\n    test(\"456\", \"-123\", \"-36\");\n    test(\"4294967295\", \"-1\", \"0\");\n    test(\"4294967295\", \"-4294967295\", \"0\");\n    test(\"1000000000000\", \"-1\", \"0\");\n    test(\"1000000000000\", \"-3\", \"-2\");\n    test(\"1000000000000\", \"-123\", \"-23\");\n    test(\"1000000000000\", \"-4294967295\", \"-727379735\");\n    test(\"1000000000000000000000000\", \"-1\", \"0\");\n    test(\"1000000000000000000000000\", \"-3\", \"-2\");\n    test(\"1000000000000000000000000\", \"-123\", \"-86\");\n    test(\"1000000000000000000000000\", \"-4294967295\", \"-1127243600\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1234567890987\",\n        \"-704498996588\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         0\",\n        \"-1234567890987654321234567890987654321\",\n        \"-454912836989613466895606299668358255\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         0\",\n        \"-316049380092839506236049380092839506176\",\n        \"-278232688309211835744673381771890580480\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"-1149635115107\",\n    );\n    test(\n        \"3768477692975601\",\n        \"-11447376614057827956\",\n        \"-11443608136364852355\",\n    );\n    test(\"3356605361737854\", \"-3081095617839357\", \"-2805585873940860\");\n    test(\n        \"1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"-808034397882141086757\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\");\n    test(\n        \"123\",\n        \"-1000000000000000000000000\",\n        \"-999999999999999999999877\",\n    );\n\n    test(\"-1\", \"1\", \"0\");\n    test(\"-123\", \"1\", \"0\");\n    test(\"-123\", \"123\", \"0\");\n    test(\"-123\", \"456\", \"333\");\n    test(\"-456\", \"123\", \"36\");\n    test(\"-4294967295\", \"-1\", \"0\");\n    test(\"-4294967295\", \"4294967295\", \"0\");\n    test(\"-1000000000000\", \"1\", \"0\");\n    test(\"-1000000000000\", \"3\", \"2\");\n    test(\"-1000000000000\", \"123\", \"23\");\n    test(\"-1000000000000\", \"4294967295\", \"727379735\");\n    test(\"-1000000000000000000000000\", \"1\", \"0\");\n    test(\"-1000000000000000000000000\", \"3\", \"2\");\n    test(\"-1000000000000000000000000\", \"123\", \"86\");\n    test(\"-1000000000000000000000000\", \"4294967295\", \"1127243600\");\n    test(\n        \"-1000000000000000000000000\",\n        \"1234567890987\",\n        \"704498996588\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"1234567890987654321234567890987654321\",\n        \"454912836989613466895606299668358255\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"316049380092839506236049380092839506176\",\n        \"278232688309211835744673381771890580480\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"2669936877441\",\n        \"1149635115107\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"11447376614057827956\",\n        \"11443608136364852355\",\n    );\n    test(\"-3356605361737854\", \"3081095617839357\", \"2805585873940860\");\n    test(\n        \"-1098730198198174614195\",\n        \"953382298040157850476\",\n        \"808034397882141086757\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"-123\",\n        \"1000000000000000000000000\",\n        \"999999999999999999999877\",\n    );\n\n    test(\"-1\", \"-1\", \"0\");\n    test(\"-123\", \"-1\", \"0\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"-123\", \"-456\", \"-123\");\n    test(\"-456\", \"-123\", \"-87\");\n    test(\"-4294967295\", \"-1\", \"0\");\n    test(\"-4294967295\", \"-4294967295\", \"0\");\n    test(\"-1000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"-3\", \"-1\");\n    test(\"-1000000000000\", \"-123\", \"-100\");\n    test(\"-1000000000000\", \"-4294967295\", \"-3567587560\");\n    test(\"-1000000000000000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000000000000000\", \"-3\", \"-1\");\n    test(\"-1000000000000000000000000\", \"-123\", \"-37\");\n    test(\"-1000000000000000000000000\", \"-4294967295\", \"-3167723695\");\n    test(\n        \"-1000000000000000000000000\",\n        \"-1234567890987\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-1234567890987654321234567890987654321\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-316049380092839506236049380092839506176\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"-11447376614057827956\",\n        \"-3768477692975601\",\n    );\n    test(\"-3356605361737854\", \"-3081095617839357\", \"-275509743898497\");\n    test(\n        \"-1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"-123\", \"-1000000000000000000000000\", \"-123\");\n}\n\n#[test]\n#[should_panic]\nfn mod_assign_fail() {\n    Integer::from(10).mod_assign(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_assign_ref_fail() {\n    Integer::from(10).mod_assign(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_fail() {\n    Integer::from(10).mod_op(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_val_ref_fail() {\n    Integer::from(10).mod_op(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_ref_val_fail() {\n    (&Integer::from(10)).mod_op(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_ref_ref_fail() {\n    (&Integer::from(10)).mod_op(&Integer::ZERO);\n}\n\n#[test]\nfn test_rem() {\n    let test = |s, t, remainder| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x %= v.clone();\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x %= &v;\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone() % v.clone();\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone() % &v;\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = &u % v.clone();\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = &u % &v;\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = BigInt::from_str(s).unwrap() % &BigInt::from_str(t).unwrap();\n        assert_eq!(r.to_string(), remainder);\n\n        let r = rug::Integer::from_str(s).unwrap() % rug::Integer::from_str(t).unwrap();\n        assert_eq!(r.to_string(), remainder);\n\n        assert_eq!(u.div_rem(v).1.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"123\");\n    test(\"456\", \"123\", \"87\");\n    test(\"4294967295\", \"1\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"3\", \"1\");\n    test(\"1000000000000\", \"123\", \"100\");\n    test(\"1000000000000\", \"4294967295\", \"3567587560\");\n    test(\"1000000000000000000000000\", \"1\", \"0\");\n    test(\"1000000000000000000000000\", \"3\", \"1\");\n    test(\"1000000000000000000000000\", \"123\", \"37\");\n    test(\"1000000000000000000000000\", \"4294967295\", \"3167723695\");\n    test(\"1000000000000000000000000\", \"1234567890987\", \"530068894399\");\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"3768477692975601\",\n    );\n    test(\"3356605361737854\", \"3081095617839357\", \"275509743898497\");\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"123\");\n\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"0\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"123\");\n    test(\"456\", \"-123\", \"87\");\n    test(\"4294967295\", \"-1\", \"0\");\n    test(\"4294967295\", \"-4294967295\", \"0\");\n    test(\"1000000000000\", \"-1\", \"0\");\n    test(\"1000000000000\", \"-3\", \"1\");\n    test(\"1000000000000\", \"-123\", \"100\");\n    test(\"1000000000000\", \"-4294967295\", \"3567587560\");\n    test(\"1000000000000000000000000\", \"-1\", \"0\");\n    test(\"1000000000000000000000000\", \"-3\", \"1\");\n    test(\"1000000000000000000000000\", \"-123\", \"37\");\n    test(\"1000000000000000000000000\", \"-4294967295\", \"3167723695\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1234567890987\",\n        \"530068894399\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-1234567890987654321234567890987654321\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-316049380092839506236049380092839506176\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"-11447376614057827956\",\n        \"3768477692975601\",\n    );\n    test(\"3356605361737854\", \"-3081095617839357\", \"275509743898497\");\n    test(\n        \"1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\");\n    test(\"123\", \"-1000000000000000000000000\", \"123\");\n\n    test(\"-1\", \"1\", \"0\");\n    test(\"-123\", \"1\", \"0\");\n    test(\"-123\", \"123\", \"0\");\n    test(\"-123\", \"456\", \"-123\");\n    test(\"-456\", \"123\", \"-87\");\n    test(\"-4294967295\", \"1\", \"0\");\n    test(\"-4294967295\", \"4294967295\", \"0\");\n    test(\"-1000000000000\", \"1\", \"0\");\n    test(\"-1000000000000\", \"3\", \"-1\");\n    test(\"-1000000000000\", \"123\", \"-100\");\n    test(\"-1000000000000\", \"4294967295\", \"-3567587560\");\n    test(\"-1000000000000000000000000\", \"1\", \"0\");\n    test(\"-1000000000000000000000000\", \"3\", \"-1\");\n    test(\"-1000000000000000000000000\", \"123\", \"-37\");\n    test(\"-1000000000000000000000000\", \"4294967295\", \"-3167723695\");\n    test(\n        \"-1000000000000000000000000\",\n        \"1234567890987\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"1234567890987654321234567890987654321\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"316049380092839506236049380092839506176\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"2669936877441\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"11447376614057827956\",\n        \"-3768477692975601\",\n    );\n    test(\"-3356605361737854\", \"3081095617839357\", \"-275509743898497\");\n    test(\n        \"-1098730198198174614195\",\n        \"953382298040157850476\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"-123\", \"1000000000000000000000000\", \"-123\");\n\n    test(\"-1\", \"-1\", \"0\");\n    test(\"-123\", \"-1\", \"0\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"-123\", \"-456\", \"-123\");\n    test(\"-456\", \"-123\", \"-87\");\n    test(\"-4294967295\", \"-1\", \"0\");\n    test(\"-4294967295\", \"-4294967295\", \"0\");\n    test(\"-1000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"-3\", \"-1\");\n    test(\"-1000000000000\", \"-123\", \"-100\");\n    test(\"-1000000000000\", \"-4294967295\", \"-3567587560\");\n    test(\"-1000000000000000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000000000000000\", \"-3\", \"-1\");\n    test(\"-1000000000000000000000000\", \"-123\", \"-37\");\n    test(\"-1000000000000000000000000\", \"-4294967295\", \"-3167723695\");\n    test(\n        \"-1000000000000000000000000\",\n        \"-1234567890987\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-1234567890987654321234567890987654321\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"-316049380092839506236049380092839506176\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"-11447376614057827956\",\n        \"-3768477692975601\",\n    );\n    test(\"-3356605361737854\", \"-3081095617839357\", \"-275509743898497\");\n    test(\n        \"-1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"-123\", \"-1000000000000000000000000\", \"-123\");\n}\n\n#[test]\n#[should_panic]\nfn rem_assign_fail() {\n    let mut x = Integer::from(10);\n    x %= Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn rem_assign_ref_fail() {\n    let mut x = Integer::from(10);\n    x %= &Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_fail() {\n    Integer::from(10) % Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_val_ref_fail() {\n    Integer::from(10) % &Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_ref_val_fail() {\n    &Integer::from(10) % Integer::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_ref_ref_fail() {\n    &Integer::from(10) % &Integer::ZERO;\n}\n\n#[test]\nfn test_ceiling_mod() {\n    let test = |s, t, remainder| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.ceiling_mod_assign(v.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x.ceiling_mod_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone().ceiling_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone().ceiling_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).ceiling_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).ceiling_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = rug::Integer::from_str(s)\n            .unwrap()\n            .rem_ceil(rug::Integer::from_str(t).unwrap());\n        assert_eq!(r.to_string(), remainder);\n\n        assert_eq!(u.ceiling_div_mod(v).1.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"-333\");\n    test(\"456\", \"123\", \"-36\");\n    test(\"4294967295\", \"1\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"3\", \"-2\");\n    test(\"1000000000000\", \"123\", \"-23\");\n    test(\"1000000000000\", \"4294967295\", \"-727379735\");\n    test(\"1000000000000000000000000\", \"1\", \"0\");\n    test(\"1000000000000000000000000\", \"3\", \"-2\");\n    test(\"1000000000000000000000000\", \"123\", \"-86\");\n    test(\"1000000000000000000000000\", \"4294967295\", \"-1127243600\");\n    test(\n        \"1000000000000000000000000\",\n        \"1234567890987\",\n        \"-704498996588\",\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"1234567890987654321234567890987654321\",\n        \"-454912836989613466895606299668358255\",\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"316049380092839506236049380092839506176\",\n        \"-278232688309211835744673381771890580480\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"-1149635115107\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"-11443608136364852355\",\n    );\n    test(\"3356605361737854\", \"3081095617839357\", \"-2805585873940860\");\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"-808034397882141086757\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\n        \"123\",\n        \"1000000000000000000000000\",\n        \"-999999999999999999999877\",\n    );\n\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"0\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"123\");\n    test(\"456\", \"-123\", \"87\");\n    test(\"4294967295\", \"-1\", \"0\");\n    test(\"4294967295\", \"-4294967295\", \"0\");\n    test(\"1000000000000\", \"-1\", \"0\");\n    test(\"1000000000000\", \"-3\", \"1\");\n    test(\"1000000000000\", \"-123\", \"100\");\n    test(\"1000000000000\", \"-4294967295\", \"3567587560\");\n    test(\"1000000000000000000000000\", \"-1\", \"0\");\n    test(\"1000000000000000000000000\", \"-3\", \"1\");\n    test(\"1000000000000000000000000\", \"-123\", \"37\");\n    test(\"1000000000000000000000000\", \"-4294967295\", \"3167723695\");\n    test(\n        \"1000000000000000000000000\",\n        \"-1234567890987\",\n        \"530068894399\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-1234567890987654321234567890987654321\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"-316049380092839506236049380092839506176\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"-11447376614057827956\",\n        \"3768477692975601\",\n    );\n    test(\"3356605361737854\", \"-3081095617839357\", \"275509743898497\");\n    test(\n        \"1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\");\n    test(\"123\", \"-1000000000000000000000000\", \"123\");\n\n    test(\"-1\", \"1\", \"0\");\n    test(\"-123\", \"1\", \"0\");\n    test(\"-123\", \"123\", \"0\");\n    test(\"-123\", \"456\", \"-123\");\n    test(\"-456\", \"123\", \"-87\");\n    test(\"-4294967295\", \"1\", \"0\");\n    test(\"-4294967295\", \"4294967295\", \"0\");\n    test(\"-1000000000000\", \"1\", \"0\");\n    test(\"-1000000000000\", \"3\", \"-1\");\n    test(\"-1000000000000\", \"123\", \"-100\");\n    test(\"-1000000000000\", \"4294967295\", \"-3567587560\");\n    test(\"-1000000000000000000000000\", \"1\", \"0\");\n    test(\"-1000000000000000000000000\", \"3\", \"-1\");\n    test(\"-1000000000000000000000000\", \"123\", \"-37\");\n    test(\"-1000000000000000000000000\", \"4294967295\", \"-3167723695\");\n    test(\n        \"-1000000000000000000000000\",\n        \"1234567890987\",\n        \"-530068894399\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"1234567890987654321234567890987654321\",\n        \"-779655053998040854338961591319296066\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00\",\n        \"316049380092839506236049380092839506176\",\n        \"-37816691783627670491375998320948925696\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"2669936877441\",\n        \"-1520301762334\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"11447376614057827956\",\n        \"-3768477692975601\",\n    );\n    test(\"-3356605361737854\", \"3081095617839357\", \"-275509743898497\");\n    test(\n        \"-1098730198198174614195\",\n        \"953382298040157850476\",\n        \"-145347900158016763719\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\"-123\", \"1000000000000000000000000\", \"-123\");\n\n    test(\"-1\", \"-1\", \"0\");\n    test(\"-123\", \"-1\", \"0\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"-123\", \"-456\", \"333\");\n    test(\"-456\", \"-123\", \"36\");\n    test(\"-4294967295\", \"-1\", \"0\");\n    test(\"-4294967295\", \"-4294967295\", \"0\");\n    test(\"-1000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"-3\", \"2\");\n    test(\"-1000000000000\", \"-123\", \"23\");\n    test(\"-1000000000000\", \"-4294967295\", \"727379735\");\n    test(\"-1000000000000000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000000000000000\", \"-3\", \"2\");\n    test(\"-1000000000000000000000000\", \"-123\", \"86\");\n    test(\"-1000000000000000000000000\", \"-4294967295\", \"1127243600\");\n    test(\n        \"-1000000000000000000000000\",\n        \"-1234567890987\",\n        \"704498996588\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"-1234567890987654321234567890987654321\",\n        \"454912836989613466895606299668358255\",\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"-316049380092839506236049380092839506176\",\n        \"278232688309211835744673381771890580480\",\n    );\n    test(\n        \"-253640751230376270397812803167\",\n        \"-2669936877441\",\n        \"1149635115107\",\n    );\n    test(\n        \"-3768477692975601\",\n        \"-11447376614057827956\",\n        \"11443608136364852355\",\n    );\n    test(\"-3356605361737854\", \"-3081095617839357\", \"2805585873940860\");\n    test(\n        \"-1098730198198174614195\",\n        \"-953382298040157850476\",\n        \"808034397882141086757\",\n    );\n    test(\n        \"-69738658860594537152875081748\",\n        \"-69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"-1000000000000000000000000\", \"0\");\n    test(\n        \"-123\",\n        \"-1000000000000000000000000\",\n        \"999999999999999999999877\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_assign_fail() {\n    Integer::from(10).ceiling_mod_assign(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_assign_ref_fail() {\n    Integer::from(10).ceiling_mod_assign(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_fail() {\n    Integer::from(10).ceiling_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_val_ref_fail() {\n    Integer::from(10).ceiling_mod(&Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_ref_val_fail() {\n    (&Integer::from(10)).ceiling_mod(Integer::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_ref_ref_fail() {\n    (&Integer::from(10)).ceiling_mod(&Integer::ZERO);\n}\n\nfn mod_properties_helper(x: Integer, y: Integer) {\n    let mut mut_x = x.clone();\n    mut_x.mod_assign(&y);\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x.mod_assign(y.clone());\n    let remainder_alt = mut_x;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).mod_op(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).mod_op(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().mod_op(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().mod_op(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    assert_eq!((&x).div_mod(&y).1, remainder);\n\n    let num_remainder = BigInt::from(&x).mod_floor(&BigInt::from(&y));\n    assert_eq!(Integer::from(&num_remainder), remainder);\n\n    let rug_remainder = rug::Integer::from(&x).rem_floor(rug::Integer::from(&y));\n    assert_eq!(Integer::from(&rug_remainder), remainder);\n\n    assert!(remainder.lt_abs(&y));\n    assert!(remainder == 0 || (remainder > 0) == (y > 0));\n\n    assert_eq!((-&x).mod_op(&y), -(&x).ceiling_mod(&y));\n    assert_eq!((&x).mod_op(-&y), x.ceiling_mod(y));\n}\n\n#[test]\nfn mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_1()\n        .test_properties_with_config(&config, |(x, y)| mod_properties_helper(x, y));\n\n    integer_pair_gen_var_2()\n        .test_properties_with_config(&config, |(x, y)| mod_properties_helper(x, y));\n\n    integer_gen().test_properties(|x| {\n        assert_eq!((&x).mod_op(Integer::ONE), 0);\n        assert_eq!(x.mod_op(Integer::NEGATIVE_ONE), 0);\n    });\n\n    integer_gen_var_8().test_properties(|ref x| {\n        assert_eq!(x.mod_op(Integer::ONE), 0);\n        assert_eq!(x.mod_op(Integer::NEGATIVE_ONE), 0);\n        assert_eq!(x.mod_op(x), 0);\n        assert_eq!(x.mod_op(-x), 0);\n        assert_eq!(Integer::ZERO.mod_op(x), 0);\n        if *x > 1 {\n            assert_eq!(Integer::ONE.mod_op(x), 1);\n            assert_eq!(Integer::NEGATIVE_ONE.mod_op(x), x - Integer::ONE);\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x).mod_op(Integer::from(&y)), x.mod_op(y));\n    });\n\n    signed_pair_gen_var_4::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).mod_op(Integer::from(y)), x.mod_op(y));\n    });\n}\n\nfn rem_properties_helper(x: Integer, y: Integer) {\n    let mut mut_x = x.clone();\n    mut_x %= &y;\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x %= y.clone();\n    assert!(mut_x.is_valid());\n    assert_eq!(mut_x, remainder);\n\n    let remainder_alt = &x % &y;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = &x % y.clone();\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone() % &y;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone() % y.clone();\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    assert_eq!((&x).div_rem(&y).1, remainder);\n\n    let num_remainder = BigInt::from(&x) % &BigInt::from(&y);\n    assert_eq!(Integer::from(&num_remainder), remainder);\n\n    let rug_remainder = rug::Integer::from(&x) % rug::Integer::from(&y);\n    assert_eq!(Integer::from(&rug_remainder), remainder);\n\n    assert!(remainder.lt_abs(&y));\n    assert!(remainder == 0 || (remainder > 0) == (x > 0));\n\n    assert_eq!((-&x) % &y, -&remainder);\n    assert_eq!(x % (-y), remainder);\n}\n\n#[test]\nfn rem_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_1()\n        .test_properties_with_config(&config, |(x, y)| rem_properties_helper(x, y));\n\n    integer_pair_gen_var_2()\n        .test_properties_with_config(&config, |(x, y)| rem_properties_helper(x, y));\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(&x % Integer::ONE, 0);\n        assert_eq!(x % Integer::NEGATIVE_ONE, 0);\n    });\n\n    integer_gen_var_8().test_properties(|ref x| {\n        assert_eq!(x % Integer::ONE, 0);\n        assert_eq!(x % Integer::NEGATIVE_ONE, 0);\n        assert_eq!(x % x, 0);\n        assert_eq!(x % -x, 0);\n        assert_eq!(Integer::ZERO % x, 0);\n        if *x > 1 {\n            assert_eq!(Integer::ONE % x, 1);\n            assert_eq!(Integer::NEGATIVE_ONE % x, -1);\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) % Integer::from(&y), x % y);\n    });\n\n    signed_pair_gen_var_4::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x) % Integer::from(y), x % y);\n    });\n}\n\nfn ceiling_mod_properties_helper(x: Integer, y: Integer) {\n    let mut mut_x = x.clone();\n    mut_x.ceiling_mod_assign(&y);\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x.ceiling_mod_assign(y.clone());\n    let remainder_alt = mut_x;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).ceiling_mod(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).ceiling_mod(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().ceiling_mod(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().ceiling_mod(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    assert_eq!((&x).ceiling_div_mod(&y).1, remainder);\n\n    let rug_remainder = rug::Integer::from(&x).rem_ceil(rug::Integer::from(&y));\n    assert_eq!(Integer::from(&rug_remainder), remainder);\n\n    assert!(remainder.lt_abs(&y));\n    assert!(remainder == 0 || (remainder >= 0) != (y > 0));\n\n    assert_eq!((-&x).ceiling_mod(&y), -(&x).mod_op(&y));\n    assert_eq!((&x).ceiling_mod(-&y), x.mod_op(y));\n}\n\n#[test]\nfn ceiling_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    integer_pair_gen_var_1()\n        .test_properties_with_config(&config, |(x, y)| ceiling_mod_properties_helper(x, y));\n\n    integer_pair_gen_var_2()\n        .test_properties_with_config(&config, |(x, y)| ceiling_mod_properties_helper(x, y));\n\n    integer_gen().test_properties(|x| {\n        assert_eq!((&x).ceiling_mod(Integer::ONE), 0);\n        assert_eq!(x.ceiling_mod(Integer::NEGATIVE_ONE), 0);\n    });\n\n    integer_gen_var_8().test_properties(|ref x| {\n        assert_eq!(x.ceiling_mod(Integer::ONE), 0);\n        assert_eq!(x.ceiling_mod(Integer::NEGATIVE_ONE), 0);\n        assert_eq!(x.ceiling_mod(x), 0);\n        assert_eq!(x.ceiling_mod(-x), 0);\n        assert_eq!(Integer::ZERO.ceiling_mod(x), 0);\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(&x).ceiling_mod(Integer::from(&y)),\n            -x.neg_mod(y)\n        );\n    });\n\n    signed_pair_gen_var_4::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(x).ceiling_mod(Integer::from(y)),\n            x.ceiling_mod(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, CeilingModPowerOf2, CeilingModPowerOf2Assign, DivisibleByPowerOf2, ModPowerOf2,\n    ModPowerOf2Assign, NegModPowerOf2, PowerOf2, RemPowerOf2, RemPowerOf2Assign, ShrRound, Sign,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, signed_unsigned_pair_gen_var_10,\n    signed_unsigned_pair_gen_var_11, unsigned_gen,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_integer_unsigned_triple_gen_var_1, integer_unsigned_pair_gen_var_2,\n    integer_unsigned_pair_gen_var_4, integer_unsigned_pair_gen_var_5,\n    integer_unsigned_unsigned_triple_gen_var_3, natural_unsigned_pair_gen_var_4,\n};\nuse std::cmp::min;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_power_of_2() {\n    let test = |s, v: u64, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        n.mod_power_of_2_assign(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n\n    test(\"0\", 0, \"0\");\n    test(\"2\", 1, \"0\");\n    test(\"260\", 8, \"4\");\n    test(\"1611\", 4, \"11\");\n    test(\"123\", 100, \"123\");\n    test(\"1000000000000\", 0, \"0\");\n    test(\"1000000000000\", 12, \"0\");\n    test(\"1000000000001\", 12, \"1\");\n    test(\"999999999999\", 12, \"4095\");\n    test(\"1000000000000\", 15, \"4096\");\n    test(\"1000000000000\", 100, \"1000000000000\");\n    test(\"1000000000000000000000000\", 40, \"1020608380928\");\n    test(\"1000000000000000000000000\", 64, \"2003764205206896640\");\n    test(\"2147483647\", 30, \"1073741823\");\n    test(\"2147483647\", 31, \"2147483647\");\n    test(\"2147483647\", 32, \"2147483647\");\n    test(\"2147483648\", 30, \"0\");\n    test(\"2147483648\", 31, \"0\");\n    test(\"2147483648\", 32, \"2147483648\");\n    test(\"2147483649\", 30, \"1\");\n    test(\"2147483649\", 31, \"1\");\n    test(\"2147483649\", 32, \"2147483649\");\n    test(\"4294967295\", 31, \"2147483647\");\n    test(\"4294967295\", 32, \"4294967295\");\n    test(\"4294967295\", 33, \"4294967295\");\n    test(\"4294967296\", 31, \"0\");\n    test(\"4294967296\", 32, \"0\");\n    test(\"4294967296\", 33, \"4294967296\");\n    test(\"4294967297\", 31, \"1\");\n    test(\"4294967297\", 32, \"1\");\n    test(\"4294967297\", 33, \"4294967297\");\n\n    test(\"-2\", 1, \"0\");\n    test(\"-260\", 8, \"252\");\n    test(\"-1611\", 4, \"5\");\n    test(\"-123\", 100, \"1267650600228229401496703205253\");\n    test(\"-1000000000000\", 0, \"0\");\n    test(\"-1000000000000\", 12, \"0\");\n    test(\"-1000000000001\", 12, \"4095\");\n    test(\"-999999999999\", 12, \"1\");\n    test(\"-1000000000000\", 15, \"28672\");\n    test(\"-1000000000000\", 100, \"1267650600228229400496703205376\");\n    test(\"-1000000000000000000000000\", 40, \"78903246848\");\n    test(\"-1000000000000000000000000\", 64, \"16442979868502654976\");\n    test(\"-2147483647\", 30, \"1\");\n    test(\"-2147483647\", 31, \"1\");\n    test(\"-2147483647\", 32, \"2147483649\");\n    test(\"-2147483648\", 30, \"0\");\n    test(\"-2147483648\", 31, \"0\");\n    test(\"-2147483648\", 32, \"2147483648\");\n    test(\"-2147483649\", 30, \"1073741823\");\n    test(\"-2147483649\", 31, \"2147483647\");\n    test(\"-2147483649\", 32, \"2147483647\");\n    test(\"-4294967295\", 31, \"1\");\n    test(\"-4294967295\", 32, \"1\");\n    test(\"-4294967295\", 33, \"4294967297\");\n    test(\"-4294967296\", 31, \"0\");\n    test(\"-4294967296\", 32, \"0\");\n    test(\"-4294967296\", 33, \"4294967296\");\n    test(\"-4294967297\", 31, \"2147483647\");\n    test(\"-4294967297\", 32, \"4294967295\");\n    test(\"-4294967297\", 33, \"4294967295\");\n}\n\n#[test]\nfn test_rem_power_of_2() {\n    let test = |s, v: u64, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        n.rem_power_of_2_assign(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().rem_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).rem_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n\n    test(\"0\", 0, \"0\");\n    test(\"2\", 1, \"0\");\n    test(\"260\", 8, \"4\");\n    test(\"1611\", 4, \"11\");\n    test(\"123\", 100, \"123\");\n    test(\"1000000000000\", 0, \"0\");\n    test(\"1000000000000\", 12, \"0\");\n    test(\"1000000000001\", 12, \"1\");\n    test(\"999999999999\", 12, \"4095\");\n    test(\"1000000000000\", 15, \"4096\");\n    test(\"1000000000000\", 100, \"1000000000000\");\n    test(\"1000000000000000000000000\", 40, \"1020608380928\");\n    test(\"1000000000000000000000000\", 64, \"2003764205206896640\");\n    test(\"2147483647\", 30, \"1073741823\");\n    test(\"2147483647\", 31, \"2147483647\");\n    test(\"2147483647\", 32, \"2147483647\");\n    test(\"2147483648\", 30, \"0\");\n    test(\"2147483648\", 31, \"0\");\n    test(\"2147483648\", 32, \"2147483648\");\n    test(\"2147483649\", 30, \"1\");\n    test(\"2147483649\", 31, \"1\");\n    test(\"2147483649\", 32, \"2147483649\");\n    test(\"4294967295\", 31, \"2147483647\");\n    test(\"4294967295\", 32, \"4294967295\");\n    test(\"4294967295\", 33, \"4294967295\");\n    test(\"4294967296\", 31, \"0\");\n    test(\"4294967296\", 32, \"0\");\n    test(\"4294967296\", 33, \"4294967296\");\n    test(\"4294967297\", 31, \"1\");\n    test(\"4294967297\", 32, \"1\");\n    test(\"4294967297\", 33, \"4294967297\");\n\n    test(\"-2\", 1, \"0\");\n    test(\"-260\", 8, \"-4\");\n    test(\"-1611\", 4, \"-11\");\n    test(\"-123\", 100, \"-123\");\n    test(\"-1000000000000\", 0, \"0\");\n    test(\"-1000000000000\", 12, \"0\");\n    test(\"-1000000000001\", 12, \"-1\");\n    test(\"-999999999999\", 12, \"-4095\");\n    test(\"-1000000000000\", 15, \"-4096\");\n    test(\"-1000000000000\", 100, \"-1000000000000\");\n    test(\"-1000000000000000000000000\", 40, \"-1020608380928\");\n    test(\"-1000000000000000000000000\", 64, \"-2003764205206896640\");\n    test(\"-2147483647\", 30, \"-1073741823\");\n    test(\"-2147483647\", 31, \"-2147483647\");\n    test(\"-2147483647\", 32, \"-2147483647\");\n    test(\"-2147483648\", 30, \"0\");\n    test(\"-2147483648\", 31, \"0\");\n    test(\"-2147483648\", 32, \"-2147483648\");\n    test(\"-2147483649\", 30, \"-1\");\n    test(\"-2147483649\", 31, \"-1\");\n    test(\"-2147483649\", 32, \"-2147483649\");\n    test(\"-4294967295\", 31, \"-2147483647\");\n    test(\"-4294967295\", 32, \"-4294967295\");\n    test(\"-4294967295\", 33, \"-4294967295\");\n    test(\"-4294967296\", 31, \"0\");\n    test(\"-4294967296\", 32, \"0\");\n    test(\"-4294967296\", 33, \"-4294967296\");\n    test(\"-4294967297\", 31, \"-1\");\n    test(\"-4294967297\", 32, \"-1\");\n    test(\"-4294967297\", 33, \"-4294967297\");\n}\n\n#[test]\nfn test_ceiling_mod_power_of_2() {\n    let test = |s, v: u64, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        n.ceiling_mod_power_of_2_assign(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().ceiling_mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).ceiling_mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n\n    test(\"0\", 0, \"0\");\n    test(\"2\", 1, \"0\");\n    test(\"260\", 8, \"-252\");\n    test(\"1611\", 4, \"-5\");\n    test(\"123\", 100, \"-1267650600228229401496703205253\");\n    test(\"1000000000000\", 0, \"0\");\n    test(\"1000000000000\", 12, \"0\");\n    test(\"1000000000001\", 12, \"-4095\");\n    test(\"999999999999\", 12, \"-1\");\n    test(\"1000000000000\", 15, \"-28672\");\n    test(\"1000000000000\", 100, \"-1267650600228229400496703205376\");\n    test(\"1000000000000000000000000\", 40, \"-78903246848\");\n    test(\"1000000000000000000000000\", 64, \"-16442979868502654976\");\n    test(\"2147483647\", 30, \"-1\");\n    test(\"2147483647\", 31, \"-1\");\n    test(\"2147483647\", 32, \"-2147483649\");\n    test(\"2147483648\", 30, \"0\");\n    test(\"2147483648\", 31, \"0\");\n    test(\"2147483648\", 32, \"-2147483648\");\n    test(\"2147483649\", 30, \"-1073741823\");\n    test(\"2147483649\", 31, \"-2147483647\");\n    test(\"2147483649\", 32, \"-2147483647\");\n    test(\"4294967295\", 31, \"-1\");\n    test(\"4294967295\", 32, \"-1\");\n    test(\"4294967295\", 33, \"-4294967297\");\n    test(\"4294967296\", 31, \"0\");\n    test(\"4294967296\", 32, \"0\");\n    test(\"4294967296\", 33, \"-4294967296\");\n    test(\"4294967297\", 31, \"-2147483647\");\n    test(\"4294967297\", 32, \"-4294967295\");\n    test(\"4294967297\", 33, \"-4294967295\");\n\n    test(\"-2\", 1, \"0\");\n    test(\"-260\", 8, \"-4\");\n    test(\"-1611\", 4, \"-11\");\n    test(\"-123\", 100, \"-123\");\n    test(\"-1000000000000\", 0, \"0\");\n    test(\"-1000000000000\", 12, \"0\");\n    test(\"-1000000000001\", 12, \"-1\");\n    test(\"-999999999999\", 12, \"-4095\");\n    test(\"-1000000000000\", 15, \"-4096\");\n    test(\"-1000000000000\", 100, \"-1000000000000\");\n    test(\"-1000000000000000000000000\", 40, \"-1020608380928\");\n    test(\"-1000000000000000000000000\", 64, \"-2003764205206896640\");\n    test(\"-2147483647\", 30, \"-1073741823\");\n    test(\"-2147483647\", 31, \"-2147483647\");\n    test(\"-2147483647\", 32, \"-2147483647\");\n    test(\"-2147483648\", 30, \"0\");\n    test(\"-2147483648\", 31, \"0\");\n    test(\"-2147483648\", 32, \"-2147483648\");\n    test(\"-2147483649\", 30, \"-1\");\n    test(\"-2147483649\", 31, \"-1\");\n    test(\"-2147483649\", 32, \"-2147483649\");\n    test(\"-4294967295\", 31, \"-2147483647\");\n    test(\"-4294967295\", 32, \"-4294967295\");\n    test(\"-4294967295\", 33, \"-4294967295\");\n    test(\"-4294967296\", 31, \"0\");\n    test(\"-4294967296\", 32, \"0\");\n    test(\"-4294967296\", 33, \"-4294967296\");\n    test(\"-4294967297\", 31, \"-1\");\n    test(\"-4294967297\", 32, \"-1\");\n    test(\"-4294967297\", 33, \"-4294967297\");\n}\n\n#[test]\nfn mod_power_of_2_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n.mod_power_of_2_assign(u);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let result_alt = (&n).mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n        let result_alt = n.clone().mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert_eq!((&n >> u << u) + &result, n);\n        assert!(result < Natural::power_of_2(u));\n        assert_eq!(result == 0, n.divisible_by_power_of_2(u));\n        assert_eq!((&result).mod_power_of_2(u), result);\n        assert_eq!(n & Integer::low_mask(u), result);\n    });\n\n    integer_integer_unsigned_triple_gen_var_1().test_properties(|(ref x, ref y, u)| {\n        let xm = Integer::from(x.mod_power_of_2(u));\n        let ym = Integer::from(y.mod_power_of_2(u));\n        assert_eq!((x + y).mod_power_of_2(u), (&xm + &ym).mod_power_of_2(u));\n        assert_eq!((x - y).mod_power_of_2(u), (&xm - &ym).mod_power_of_2(u));\n        assert_eq!((x * y).mod_power_of_2(u), (xm * ym).mod_power_of_2(u));\n    });\n\n    integer_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        assert_eq!(n.mod_power_of_2(u), 0);\n    });\n\n    integer_unsigned_pair_gen_var_5().test_properties(|(n, u)| {\n        assert_ne!((&n).mod_power_of_2(u), 0);\n        assert_eq!(\n            Integer::from((&n).mod_power_of_2(u)) - n.ceiling_mod_power_of_2(u),\n            Natural::power_of_2(u)\n        );\n    });\n\n    integer_unsigned_unsigned_triple_gen_var_3().test_properties(|(n, u, v)| {\n        assert_eq!(\n            (&n).mod_power_of_2(u).mod_power_of_2(v),\n            n.mod_power_of_2(min(u, v))\n        );\n    });\n\n    signed_unsigned_pair_gen_var_10::<SignedLimb>().test_properties(|(i, pow)| {\n        assert_eq!(i.mod_power_of_2(pow), Integer::from(i).mod_power_of_2(pow));\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, pow)| {\n        assert_eq!(\n            (&n).mod_power_of_2(pow),\n            Integer::from(n).mod_power_of_2(pow)\n        );\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(n.mod_power_of_2(0), 0);\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Integer::ZERO.mod_power_of_2(u), 0);\n    });\n}\n\n#[test]\nfn rem_power_of_2_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n.rem_power_of_2_assign(u);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let result_alt = (&n).rem_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n        let result_alt = n.clone().rem_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert!(result.le_abs(&n));\n        assert_eq!((((&n).shr_round(u, Down).0 << u) + &result), n);\n        assert!(result.lt_abs(&Natural::power_of_2(u)));\n        assert_eq!(result == 0, (&n).divisible_by_power_of_2(u));\n        assert_eq!((&result).rem_power_of_2(u), result);\n        assert_eq!(n.abs().mod_power_of_2(u), result.abs());\n    });\n\n    integer_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        assert_eq!(n.rem_power_of_2(u), 0);\n    });\n\n    integer_unsigned_pair_gen_var_5().test_properties(|(n, u)| {\n        assert_ne!((&n).rem_power_of_2(u), 0);\n        assert_eq!((&n).rem_power_of_2(u).sign(), n.sign());\n    });\n\n    integer_unsigned_unsigned_triple_gen_var_3().test_properties(|(n, u, v)| {\n        assert_eq!(\n            (&n).rem_power_of_2(u).rem_power_of_2(v),\n            n.rem_power_of_2(min(u, v))\n        );\n    });\n\n    signed_unsigned_pair_gen_var_1::<SignedLimb, u64>().test_properties(|(i, pow)| {\n        assert_eq!(i.rem_power_of_2(pow), Integer::from(i).rem_power_of_2(pow));\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, pow)| {\n        assert_eq!(\n            (&n).rem_power_of_2(pow),\n            Integer::from(n).rem_power_of_2(pow)\n        );\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(n.rem_power_of_2(0), 0);\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Integer::ZERO.rem_power_of_2(u), 0);\n    });\n}\n\n#[test]\nfn ceiling_mod_power_of_2_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n.ceiling_mod_power_of_2_assign(u);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let result_alt = (&n).ceiling_mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n        let result_alt = n.clone().ceiling_mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert_eq!((((&n).shr_round(u, Ceiling).0 << u) + &result), n);\n        assert!(result <= 0);\n        assert!(-&result <= Natural::power_of_2(u));\n        assert_eq!(result == 0, (&n).divisible_by_power_of_2(u));\n        assert_eq!((-n).mod_power_of_2(u), -result);\n    });\n\n    integer_integer_unsigned_triple_gen_var_1().test_properties(|(ref x, ref y, u)| {\n        let xm = Integer::from(x.mod_power_of_2(u));\n        let ym = Integer::from(y.mod_power_of_2(u));\n        assert_eq!(\n            (x + y).ceiling_mod_power_of_2(u),\n            (&xm + &ym).ceiling_mod_power_of_2(u)\n        );\n        assert_eq!(\n            (x - y).ceiling_mod_power_of_2(u),\n            (&xm - &ym).ceiling_mod_power_of_2(u)\n        );\n        assert_eq!(\n            (x * y).ceiling_mod_power_of_2(u),\n            (xm * ym).ceiling_mod_power_of_2(u)\n        );\n    });\n\n    integer_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        assert_eq!(n.ceiling_mod_power_of_2(u), 0);\n    });\n\n    integer_unsigned_pair_gen_var_5().test_properties(|(n, u)| {\n        assert_ne!(n.ceiling_mod_power_of_2(u), 0);\n    });\n\n    signed_unsigned_pair_gen_var_11::<Limb, SignedLimb>().test_properties(|(i, pow)| {\n        assert_eq!(\n            i.ceiling_mod_power_of_2(pow),\n            Integer::from(i).ceiling_mod_power_of_2(pow)\n        );\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, pow)| {\n        assert_eq!(\n            -(&n).neg_mod_power_of_2(pow),\n            Integer::from(n).ceiling_mod_power_of_2(pow)\n        );\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(n.ceiling_mod_power_of_2(0), 0);\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Integer::ZERO.ceiling_mod_power_of_2(u), 0);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, DivMod, PowerOf2, Square, UnsignedAbs,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{SignedDoubleLimb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, integer_vec_gen, natural_pair_gen,\n    natural_vec_gen,\n};\nuse malachite_nz::test_util::integer::arithmetic::mul::integer_product_naive;\nuse num::BigInt;\nuse std::iter::{Product, once};\nuse std::str::FromStr;\n\n#[test]\nfn test_mul() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n *= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n *= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() * v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u * v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() * &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u * &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigInt::from_str(s).unwrap() * BigInt::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() * rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"123\", \"0\", \"0\");\n    test(\"-123\", \"0\", \"0\");\n    test(\"1\", \"123\", \"123\");\n    test(\"1\", \"-123\", \"-123\");\n    test(\"-1\", \"123\", \"-123\");\n    test(\"-1\", \"-123\", \"123\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"-1\", \"-123\");\n    test(\"-123\", \"1\", \"-123\");\n    test(\"-123\", \"-1\", \"123\");\n    test(\"123\", \"456\", \"56088\");\n    test(\"123\", \"-456\", \"-56088\");\n    test(\"-123\", \"456\", \"-56088\");\n    test(\"-123\", \"-456\", \"56088\");\n    test(\"0\", \"1000000000000\", \"0\");\n    test(\"0\", \"-1000000000000\", \"0\");\n    test(\"1000000000000\", \"0\", \"0\");\n    test(\"-1000000000000\", \"0\", \"0\");\n    test(\"1\", \"1000000000000\", \"1000000000000\");\n    test(\"1\", \"-1000000000000\", \"-1000000000000\");\n    test(\"-1\", \"1000000000000\", \"-1000000000000\");\n    test(\"-1\", \"-1000000000000\", \"1000000000000\");\n    test(\"1000000000000\", \"1\", \"1000000000000\");\n    test(\"1000000000000\", \"-1\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1\", \"-1000000000000\");\n    test(\"-1000000000000\", \"-1\", \"1000000000000\");\n    test(\"1000000000000\", \"123\", \"123000000000000\");\n    test(\"1000000000000\", \"-123\", \"-123000000000000\");\n    test(\"-1000000000000\", \"123\", \"-123000000000000\");\n    test(\"-1000000000000\", \"-123\", \"123000000000000\");\n    test(\"123\", \"1000000000000\", \"123000000000000\");\n    test(\"123\", \"-1000000000000\", \"-123000000000000\");\n    test(\"-123\", \"1000000000000\", \"-123000000000000\");\n    test(\"-123\", \"-1000000000000\", \"123000000000000\");\n    test(\"123456789000\", \"987654321000\", \"121932631112635269000000\");\n    test(\"123456789000\", \"-987654321000\", \"-121932631112635269000000\");\n    test(\"-123456789000\", \"987654321000\", \"-121932631112635269000000\");\n    test(\"-123456789000\", \"-987654321000\", \"121932631112635269000000\");\n    test(\"4294967295\", \"2\", \"8589934590\");\n    test(\"4294967295\", \"-2\", \"-8589934590\");\n    test(\"-4294967295\", \"2\", \"-8589934590\");\n    test(\"-4294967295\", \"-2\", \"8589934590\");\n    test(\"4294967295\", \"4294967295\", \"18446744065119617025\");\n    test(\"4294967295\", \"-4294967295\", \"-18446744065119617025\");\n    test(\"-4294967295\", \"4294967295\", \"-18446744065119617025\");\n    test(\"-4294967295\", \"-4294967295\", \"18446744065119617025\");\n    test(\"18446744073709551615\", \"2\", \"36893488147419103230\");\n    test(\"18446744073709551615\", \"-2\", \"-36893488147419103230\");\n    test(\"-18446744073709551615\", \"2\", \"-36893488147419103230\");\n    test(\"-18446744073709551615\", \"-2\", \"36893488147419103230\");\n    let large_power_of_2 = Integer::power_of_2(100_000) * Integer::power_of_2(100_000);\n    assert!(large_power_of_2.is_valid());\n    assert_eq!(\n        large_power_of_2.unsigned_abs().checked_log_base_2(),\n        Some(200_000)\n    );\n}\n\n#[test]\nfn test_product() {\n    let test = |xs, out| {\n        let xs = vec_from_str(xs).unwrap();\n        let product = Integer::product(xs.iter().cloned());\n        assert!(product.is_valid());\n        assert_eq!(product.to_string(), out);\n\n        let product_alt = Integer::product(xs.iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n\n        let product_alt = integer_product_naive(xs.into_iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n    };\n    test(\"[]\", \"1\");\n    test(\"[10]\", \"10\");\n    test(\"[6, -2]\", \"-12\");\n    test(\"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\", \"0\");\n    test(\"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\", \"3628800\");\n    test(\n        \"[123456, -789012, 345678, -9012345]\",\n        \"303462729062737285547520\",\n    );\n}\n\n#[test]\nfn mul_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let product_val_val = x.clone() * y.clone();\n        let product_val_ref = x.clone() * &y;\n        let product_ref_val = &x * y.clone();\n        let product = &x * &y;\n        assert!(product_val_val.is_valid());\n        assert!(product_val_ref.is_valid());\n        assert!(product_ref_val.is_valid());\n        assert!(product.is_valid());\n        assert_eq!(product_val_val, product);\n        assert_eq!(product_val_ref, product);\n        assert_eq!(product_ref_val, product);\n\n        let mut mut_x = x.clone();\n        mut_x *= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n        let mut mut_x = x.clone();\n        mut_x *= &y;\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x *= rug::Integer::from(&y);\n        assert_eq!(Integer::from(&mut_x), product);\n\n        assert_eq!(\n            Integer::from(&(BigInt::from(&x) * BigInt::from(&y))),\n            product\n        );\n        assert_eq!(\n            Integer::from(&(rug::Integer::from(&x) * rug::Integer::from(&y))),\n            product\n        );\n        assert_eq!(&y * &x, product);\n        if x != 0 {\n            let (q, r) = (&product).div_mod(&x);\n            assert_eq!(q, y);\n            assert_eq!(r, 0);\n        }\n        if y != 0 {\n            let (q, r) = (&product).div_mod(&y);\n            assert_eq!(q, x);\n            assert_eq!(r, 0);\n        }\n\n        assert_eq!(-&x * &y, -&product);\n        assert_eq!(x * -y, -product);\n    });\n\n    integer_gen().test_properties(|ref x| {\n        assert_eq!(x * Integer::ZERO, 0);\n        assert_eq!(Integer::ZERO * x, 0);\n        assert_eq!(x * Integer::ONE, *x);\n        assert_eq!(Integer::ONE * x, *x);\n        assert_eq!(x * Integer::NEGATIVE_ONE, -x);\n        assert_eq!(Integer::NEGATIVE_ONE * x, -x);\n        assert_eq!(x * x, x.square());\n    });\n\n    integer_triple_gen().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x * y) * z, x * (y * z));\n        assert_eq!(x * (y + z), x * y + x * z);\n        assert_eq!((x + y) * z, x * z + y * z);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(&x * &y, Integer::from(x) * Integer::from(y));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(SignedDoubleLimb::from(x) * SignedDoubleLimb::from(y)),\n            Integer::from(x) * Integer::from(y)\n        );\n    });\n}\n\n#[test]\nfn product_properties() {\n    integer_vec_gen().test_properties(|xs| {\n        let product = Integer::product(xs.iter().cloned());\n        assert!(product.is_valid());\n\n        let product_alt = Integer::product(xs.iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n\n        let product_alt = integer_product_naive(xs.into_iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(Integer::product(once(&x)), x);\n        assert_eq!(Integer::product(once(x.clone())), x);\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        let product = &x * &y;\n        assert_eq!(Integer::product([&x, &y].into_iter()), product);\n        assert_eq!(Integer::product([x, y].into_iter()), product);\n    });\n\n    natural_vec_gen().test_properties(|xs| {\n        assert_eq!(\n            Integer::product(xs.iter().map(Integer::from)),\n            Integer::from(Natural::product(xs.into_iter()))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{SignedDoubleLimb, SignedLimb};\nuse malachite_nz::test_util::generators::{integer_gen, natural_gen};\nuse num::BigInt;\nuse std::str::FromStr;\n\n#[test]\nfn test_neg() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let neg = -u.clone();\n        assert!(neg.is_valid());\n        assert_eq!(neg.to_string(), out);\n\n        let neg = -&u;\n        assert!(neg.is_valid());\n        assert_eq!(neg.to_string(), out);\n\n        assert_eq!((-BigInt::from_str(s).unwrap()).to_string(), out);\n        assert_eq!((-rug::Integer::from_str(s).unwrap()).to_string(), out);\n\n        let mut x = u;\n        x.neg_assign();\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"-123\");\n    test(\"-123\", \"123\");\n    test(\"1000000000000\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1000000000000\");\n    test(\"-2147483648\", \"2147483648\");\n    test(\"2147483648\", \"-2147483648\");\n}\n\n#[test]\nfn neg_properties() {\n    integer_gen().test_properties(|x| {\n        let negative = -x.clone();\n        assert!(negative.is_valid());\n        assert!(negative.is_valid());\n\n        let negative_alt = -&x;\n        assert!(negative_alt.is_valid());\n        assert_eq!(negative_alt, negative);\n\n        assert_eq!(Integer::from(&-BigInt::from(&x)), negative);\n        assert_eq!(Integer::from(&-rug::Integer::from(&x)), negative);\n\n        assert_eq!(negative == x, x == 0);\n        assert_eq!(-&negative, x);\n        assert_eq!(x + negative, 0);\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|x| {\n        assert_eq!(Integer::from(-SignedDoubleLimb::from(x)), -Integer::from(x));\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(-&x, -Integer::from(x));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleBy, DivisibleByPowerOf2, Parity};\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::integer_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_even() {\n    let test = |n, out| {\n        assert_eq!(Integer::from_str(n).unwrap().even(), out);\n    };\n    test(\"0\", true);\n    test(\"1\", false);\n    test(\"2\", true);\n    test(\"3\", false);\n    test(\"123\", false);\n    test(\"1000000000000\", true);\n    test(\"1000000000001\", false);\n    test(\"-1\", false);\n    test(\"-2\", true);\n    test(\"-3\", false);\n    test(\"-123\", false);\n    test(\"-1000000000000\", true);\n    test(\"-1000000000001\", false);\n}\n\n#[test]\nfn test_odd() {\n    let test = |n, out| {\n        assert_eq!(Integer::from_str(n).unwrap().odd(), out);\n    };\n    test(\"0\", false);\n    test(\"1\", true);\n    test(\"2\", false);\n    test(\"3\", true);\n    test(\"123\", true);\n    test(\"1000000000000\", false);\n    test(\"1000000000001\", true);\n    test(\"-1\", true);\n    test(\"-2\", false);\n    test(\"-3\", true);\n    test(\"-123\", true);\n    test(\"-1000000000000\", false);\n    test(\"-1000000000001\", true);\n}\n\n#[test]\nfn even_properties() {\n    integer_gen().test_properties(|ref x| {\n        let even = x.even();\n        assert_eq!(!x.odd(), even);\n        assert_eq!(x.divisible_by(Integer::TWO), even);\n        assert_eq!(x.divisible_by_power_of_2(1), even);\n        assert_eq!((x + Integer::ONE).odd(), even);\n        assert_eq!((x - Integer::ONE).odd(), even);\n        assert_eq!((-x).even(), even);\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.even(), Integer::from(i).even());\n    });\n}\n\n#[test]\nfn odd_properties() {\n    integer_gen().test_properties(|ref x| {\n        let odd = x.odd();\n        assert_eq!(!x.even(), odd);\n        assert_eq!(!x.divisible_by(Integer::TWO), odd);\n        assert_eq!(!(x).divisible_by_power_of_2(1), odd);\n        assert_eq!((x + Integer::ONE).even(), odd);\n        assert_eq!((x - Integer::ONE).even(), odd);\n        assert_eq!((-x).odd(), odd);\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.odd(), Integer::from(i).odd());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedRoot, Parity, Pow, PowAssign, PowerOf2, Square,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Two, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_unsigned_pair_gen_var_15, unsigned_gen_var_5};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_integer_unsigned_triple_gen_var_1, integer_unsigned_pair_gen_var_2,\n    integer_unsigned_unsigned_triple_gen_var_3, natural_unsigned_pair_gen_var_4,\n};\nuse num::BigInt;\nuse num::traits::Pow as NumPow;\nuse rug::ops::Pow as RugPow;\nuse std::str::FromStr;\n\n#[test]\nfn test_pow() {\n    let test = |s, exp, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let mut x = u.clone();\n        x.pow_assign(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = u.clone().pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = (&u).pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = BigInt::from_str(s).unwrap().pow(exp);\n        assert_eq!(x.to_string(), out);\n\n        let x = rug::Integer::from_str(s).unwrap().pow(u32::exact_from(exp));\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", 0, \"1\");\n    test(\"1\", 0, \"1\");\n    test(\"2\", 0, \"1\");\n    test(\"1000\", 0, \"1\");\n    test(\"1000000000000\", 0, \"1\");\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"1000\", 1, \"1000\");\n    test(\"1000000000000\", 1, \"1000000000000\");\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"4\");\n    test(\"3\", 2, \"9\");\n    test(\"1000\", 2, \"1000000\");\n    test(\"1000000000000\", 2, \"1000000000000000000000000\");\n    test(\n        \"123\",\n        456,\n        \"992500687720988567008314620574696326372959408198869005198162988813828671047493990779211286\\\n        6142614463805542423693627187249280035274164990211814381967260156999810012079049675951763646\\\n        5445895625741609866209900500198407153244604778968016963028050310261417615914468729918240685\\\n        4878786176459769390634643579861657117309763994785076492286863414669671679101266533421349427\\\n        4485146389992748709248661097714611276356710167264595313219648143933987301708814041466127119\\\n        8500333255713096142335151414630651683065518784081203678487703002802082091236603519026256880\\\n        6244996817813872275740354848312715156831237421490955692604636096559777009388445806119312464\\\n        9516620869554031369814001163802732256625268978083813635182879531427216211122223117090171561\\\n        2355701347552371530013693855379834865667060014643302459100429783653966913783002290784283455\\\n        6282833554705299329560514844771293338811599302127586876027950885792304316616960102321873904\\\n        36601614145603241902386663442520160735566561\",\n    );\n    test(\n        \"123\",\n        457,\n        \"122077584589681593742022698330687648143874007208460887639374047624100926538841760865842988\\\n        2535541579048081718114316144031661444338722293796053168981972999310976631485723110142066928\\\n        5249845161966218013543817761524404079849086387813066086452450188162154366757479653779943604\\\n        3150090699704551635048061160322983825429100971358564408551284200004369616529455783610825979\\\n        5761673005969108091237585315018897186991875350573545223526016721703880438110184127100333635\\\n        7415540990452710825507223623999570157017058810441988052453987469344656097222102232840229596\\\n        3168134608591106289916063646342463964290242202843387550190370239876852572154778834152675433\\\n        1890544366955145858487122143147736067564908084304309077127494182365547593968033443402091102\\\n        0319751265748941698191684344211719688477048381801126202469352863389437930395309281766466865\\\n        0422788527228751817535943325906869080673826714161693185751437958952453430943886092585590490\\\n        23701998539909198753993559603429979770474687003\",\n    );\n    test(\n        \"10\",\n        100,\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000\",\n    );\n    test(\n        \"10\",\n        101,\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000\",\n    );\n    test(\"2\", 100, \"1267650600228229401496703205376\");\n    test(\n        \"12345678987654321\",\n        5,\n        \"286797196211272153445658333952148540084053148773966942500383143133144940612575601\",\n    );\n    test(\n        \"12345678987654321\",\n        6,\n        \"354070611898367606555445954656918550154832595750628623501854823341167403514406003590115726\\\n        6821921\",\n    );\n\n    test(\"-1\", 0, \"1\");\n    test(\"-2\", 0, \"1\");\n    test(\"-1000\", 0, \"1\");\n    test(\"-1000000000000\", 0, \"1\");\n    test(\"-1\", 1, \"-1\");\n    test(\"-2\", 1, \"-2\");\n    test(\"-1000\", 1, \"-1000\");\n    test(\"-1000000000000\", 1, \"-1000000000000\");\n    test(\"-1\", 2, \"1\");\n    test(\"-2\", 2, \"4\");\n    test(\"-3\", 2, \"9\");\n    test(\"-1000\", 2, \"1000000\");\n    test(\"-1000000000000\", 2, \"1000000000000000000000000\");\n    test(\n        \"-123\",\n        456,\n        \"992500687720988567008314620574696326372959408198869005198162988813828671047493990779211286\\\n        6142614463805542423693627187249280035274164990211814381967260156999810012079049675951763646\\\n        5445895625741609866209900500198407153244604778968016963028050310261417615914468729918240685\\\n        4878786176459769390634643579861657117309763994785076492286863414669671679101266533421349427\\\n        4485146389992748709248661097714611276356710167264595313219648143933987301708814041466127119\\\n        8500333255713096142335151414630651683065518784081203678487703002802082091236603519026256880\\\n        6244996817813872275740354848312715156831237421490955692604636096559777009388445806119312464\\\n        9516620869554031369814001163802732256625268978083813635182879531427216211122223117090171561\\\n        2355701347552371530013693855379834865667060014643302459100429783653966913783002290784283455\\\n        6282833554705299329560514844771293338811599302127586876027950885792304316616960102321873904\\\n        36601614145603241902386663442520160735566561\",\n    );\n    test(\n        \"-123\",\n        457,\n        \"-12207758458968159374202269833068764814387400720846088763937404762410092653884176086584298\\\n        8253554157904808171811431614403166144433872229379605316898197299931097663148572311014206692\\\n        8524984516196621801354381776152440407984908638781306608645245018816215436675747965377994360\\\n        4315009069970455163504806116032298382542910097135856440855128420000436961652945578361082597\\\n        9576167300596910809123758531501889718699187535057354522352601672170388043811018412710033363\\\n        5741554099045271082550722362399957015701705881044198805245398746934465609722210223284022959\\\n        6316813460859110628991606364634246396429024220284338755019037023987685257215477883415267543\\\n        3189054436695514585848712214314773606756490808430430907712749418236554759396803344340209110\\\n        2031975126574894169819168434421171968847704838180112620246935286338943793039530928176646686\\\n        5042278852722875181753594332590686908067382671416169318575143795895245343094388609258559049\\\n        023701998539909198753993559603429979770474687003\",\n    );\n    test(\n        \"-10\",\n        100,\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000\",\n    );\n    test(\n        \"-10\",\n        101,\n        \"-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000\",\n    );\n    test(\"-2\", 100, \"1267650600228229401496703205376\");\n    test(\n        \"-12345678987654321\",\n        5,\n        \"-286797196211272153445658333952148540084053148773966942500383143133144940612575601\",\n    );\n    test(\n        \"-12345678987654321\",\n        6,\n        \"354070611898367606555445954656918550154832595750628623501854823341167403514406003590115726\\\n        6821921\",\n    );\n}\n\n#[test]\nfn pow_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, exp)| {\n        let power = (&x).pow(exp);\n        assert!(power.is_valid());\n\n        let power_alt = x.clone().pow(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        let mut power_alt = x.clone();\n        power_alt.pow_assign(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        let power_of_neg = (-&x).pow(exp);\n        if exp.even() {\n            assert_eq!(power_of_neg, power);\n        } else {\n            assert_eq!(power_of_neg, -&power);\n        }\n        if exp > 0 && (x >= 0 || exp.odd()) {\n            assert_eq!((&power).checked_root(exp).as_ref(), Some(&x));\n        }\n\n        assert_eq!(Integer::from(&BigInt::from(&x).pow(exp)), power);\n        assert_eq!(\n            Integer::from(&rug::Integer::from(&x).pow(u32::exact_from(exp))),\n            power\n        );\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!((&x).pow(0), 1);\n        assert_eq!((&x).pow(1), x);\n        assert_eq!((&x).pow(2), x.square());\n    });\n\n    unsigned_gen_var_5().test_properties(|exp| {\n        assert_eq!(Integer::ZERO.pow(exp), u64::from(exp == 0));\n        assert_eq!(Integer::ONE.pow(exp), 1);\n        assert_eq!(Integer::TWO.pow(exp), Integer::power_of_2(exp));\n\n        assert_eq!(\n            Integer::NEGATIVE_ONE.pow(exp),\n            if exp.even() { 1 } else { -1 }\n        );\n    });\n\n    integer_integer_unsigned_triple_gen_var_1().test_properties(|(x, y, exp)| {\n        assert_eq!((&x * &y).pow(exp), x.pow(exp) * y.pow(exp));\n    });\n\n    integer_unsigned_unsigned_triple_gen_var_3().test_properties(|(x, e, f)| {\n        assert_eq!((&x).pow(e + f), (&x).pow(e) * (&x).pow(f));\n        assert_eq!((&x).pow(e * f), x.pow(e).pow(f));\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, exp)| {\n        assert_eq!((&x).pow(exp), Integer::from(x).pow(exp));\n    });\n\n    signed_unsigned_pair_gen_var_15::<SignedLimb>().test_properties(|(x, exp)| {\n        assert_eq!(Pow::pow(x, exp), Integer::from(x).pow(exp));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, LowMask};\nuse malachite_base::test_util::generators::{unsigned_gen_var_5, unsigned_gen_var_16};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\n\n#[test]\nfn test_power_of_2() {\n    let test = |pow, out| assert_eq!(Integer::power_of_2(pow).to_string(), out);\n    test(0, \"1\");\n    test(1, \"2\");\n    test(2, \"4\");\n    test(3, \"8\");\n    test(32, \"4294967296\");\n    test(100, \"1267650600228229401496703205376\");\n}\n\n#[test]\nfn power_of_2_properties() {\n    unsigned_gen_var_5().test_properties(|pow| {\n        let n = Integer::power_of_2(pow);\n        assert!(n.is_valid());\n\n        assert_eq!(n, Integer::ONE << pow);\n        assert_eq!(n, Integer::low_mask(pow) + Integer::ONE);\n        assert_eq!(Natural::exact_from(&n), Natural::power_of_2(pow));\n        let mut n = n;\n        n.clear_bit(pow);\n        assert_eq!(n, 0);\n    });\n\n    unsigned_gen_var_16::<SignedLimb>().test_properties(|pow| {\n        assert_eq!(SignedLimb::power_of_2(pow), Integer::power_of_2(pow));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingRootAssign, CeilingSqrt, CheckedRoot, CheckedSqrt, FloorRoot,\n    FloorRootAssign, FloorSqrt, Parity, Pow,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_gen, signed_unsigned_pair_gen_var_18};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_4, integer_unsigned_pair_gen_var_3, natural_gen,\n    natural_unsigned_pair_gen_var_7,\n};\nuse num::BigInt;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_floor_root() {\n    let test = |s, exp, out| {\n        let n = Integer::from_str(s).unwrap();\n        assert_eq!(n.clone().floor_root(exp).to_string(), out);\n        assert_eq!((&n).floor_root(exp).to_string(), out);\n\n        let mut n = n;\n        n.floor_root_assign(exp);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"100\", 1, \"100\");\n\n    test(\"0\", 2, \"0\");\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"1\");\n    test(\"3\", 2, \"1\");\n    test(\"4\", 2, \"2\");\n    test(\"5\", 2, \"2\");\n    test(\"0\", 3, \"0\");\n    test(\"1\", 3, \"1\");\n    test(\"2\", 3, \"1\");\n    test(\"7\", 3, \"1\");\n    test(\"8\", 3, \"2\");\n    test(\"9\", 3, \"2\");\n    test(\"10\", 2, \"3\");\n    test(\"100\", 2, \"10\");\n    test(\"100\", 3, \"4\");\n    test(\"1000000000\", 2, \"31622\");\n    test(\"1000000000\", 3, \"1000\");\n    test(\"1000000000\", 4, \"177\");\n    test(\"1000000000\", 5, \"63\");\n    test(\"1000000000\", 6, \"31\");\n    test(\"1000000000\", 7, \"19\");\n    test(\"1000000000\", 8, \"13\");\n    test(\"1000000000\", 9, \"10\");\n    test(\"1000000000\", 10, \"7\");\n\n    test(\"-1\", 1, \"-1\");\n    test(\"-2\", 1, \"-2\");\n    test(\"-100\", 1, \"-100\");\n\n    test(\"-1\", 3, \"-1\");\n    test(\"-2\", 3, \"-2\");\n    test(\"-7\", 3, \"-2\");\n    test(\"-8\", 3, \"-2\");\n    test(\"-9\", 3, \"-3\");\n    test(\"-100\", 3, \"-5\");\n    test(\"-1000000000\", 3, \"-1000\");\n    test(\"-1000000000\", 5, \"-64\");\n    test(\"-1000000000\", 7, \"-20\");\n    test(\"-1000000000\", 9, \"-10\");\n}\n\n#[test]\nfn floor_root_fail() {\n    assert_panic!(Integer::ONE.floor_root(0));\n    assert_panic!(Integer::NEGATIVE_ONE.floor_root(0));\n    assert_panic!(Integer::NEGATIVE_ONE.floor_root(2));\n    assert_panic!(Integer::NEGATIVE_ONE.floor_root(4));\n    assert_panic!(Integer::NEGATIVE_ONE.floor_root(100));\n}\n\n#[test]\nfn floor_root_ref_fail() {\n    assert_panic!((&Integer::ONE).floor_root(0));\n    assert_panic!((&Integer::NEGATIVE_ONE).floor_root(0));\n    assert_panic!((&Integer::NEGATIVE_ONE).floor_root(2));\n    assert_panic!((&Integer::NEGATIVE_ONE).floor_root(4));\n    assert_panic!((&Integer::NEGATIVE_ONE).floor_root(100));\n}\n\n#[test]\nfn floor_root_assign_fail() {\n    assert_panic!({\n        let mut x = Integer::ONE;\n        x.floor_root_assign(0);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.floor_root_assign(0);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.floor_root_assign(2);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.floor_root_assign(4);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.floor_root_assign(100);\n    });\n}\n\n#[test]\nfn test_ceiling_root() {\n    let test = |s, exp, out| {\n        let n = Integer::from_str(s).unwrap();\n        assert_eq!(n.clone().ceiling_root(exp).to_string(), out);\n        assert_eq!((&n).ceiling_root(exp).to_string(), out);\n\n        let mut n = n;\n        n.ceiling_root_assign(exp);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"100\", 1, \"100\");\n\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"2\");\n    test(\"3\", 2, \"2\");\n    test(\"4\", 2, \"2\");\n    test(\"5\", 2, \"3\");\n    test(\"0\", 3, \"0\");\n    test(\"1\", 3, \"1\");\n    test(\"2\", 3, \"2\");\n    test(\"7\", 3, \"2\");\n    test(\"8\", 3, \"2\");\n    test(\"9\", 3, \"3\");\n    test(\"10\", 2, \"4\");\n    test(\"100\", 2, \"10\");\n    test(\"100\", 3, \"5\");\n    test(\"1000000000\", 2, \"31623\");\n    test(\"1000000000\", 3, \"1000\");\n    test(\"1000000000\", 4, \"178\");\n    test(\"1000000000\", 5, \"64\");\n    test(\"1000000000\", 6, \"32\");\n    test(\"1000000000\", 7, \"20\");\n    test(\"1000000000\", 8, \"14\");\n    test(\"1000000000\", 9, \"10\");\n    test(\"1000000000\", 10, \"8\");\n\n    test(\"-1\", 1, \"-1\");\n    test(\"-2\", 1, \"-2\");\n    test(\"-100\", 1, \"-100\");\n\n    test(\"-1\", 3, \"-1\");\n    test(\"-2\", 3, \"-1\");\n    test(\"-7\", 3, \"-1\");\n    test(\"-8\", 3, \"-2\");\n    test(\"-9\", 3, \"-2\");\n    test(\"-100\", 3, \"-4\");\n    test(\"-1000000000\", 3, \"-1000\");\n    test(\"-1000000000\", 5, \"-63\");\n    test(\"-1000000000\", 7, \"-19\");\n    test(\"-1000000000\", 9, \"-10\");\n}\n\n#[test]\nfn ceiling_root_fail() {\n    assert_panic!(Integer::ONE.ceiling_root(0));\n    assert_panic!(Integer::NEGATIVE_ONE.ceiling_root(0));\n    assert_panic!(Integer::NEGATIVE_ONE.ceiling_root(2));\n    assert_panic!(Integer::NEGATIVE_ONE.ceiling_root(4));\n    assert_panic!(Integer::NEGATIVE_ONE.ceiling_root(100));\n}\n\n#[test]\nfn ceiling_root_ref_fail() {\n    assert_panic!((&Integer::ONE).ceiling_root(0));\n    assert_panic!((&Integer::NEGATIVE_ONE).ceiling_root(0));\n    assert_panic!((&Integer::NEGATIVE_ONE).ceiling_root(2));\n    assert_panic!((&Integer::NEGATIVE_ONE).ceiling_root(4));\n    assert_panic!((&Integer::NEGATIVE_ONE).ceiling_root(100));\n}\n\n#[test]\nfn ceiling_root_assign_fail() {\n    assert_panic!({\n        let mut x = Integer::ONE;\n        x.ceiling_root_assign(0);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.ceiling_root_assign(0);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.ceiling_root_assign(2);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.ceiling_root_assign(4);\n    });\n    assert_panic!({\n        let mut x = Integer::NEGATIVE_ONE;\n        x.ceiling_root_assign(100);\n    });\n}\n\n#[allow(clippy::redundant_closure_for_method_calls)]\n#[test]\nfn test_checked_root() {\n    let test = |s, exp, out: Option<&str>| {\n        let n = Integer::from_str(s).unwrap();\n        let out = out.map(|s| s.to_string());\n\n        assert_eq!(n.clone().checked_root(exp).map(|x| x.to_string()), out);\n        assert_eq!((&n).checked_root(exp).map(|x| x.to_string()), out);\n    };\n    test(\"0\", 1, Some(\"0\"));\n    test(\"1\", 1, Some(\"1\"));\n    test(\"2\", 1, Some(\"2\"));\n    test(\"100\", 1, Some(\"100\"));\n\n    test(\"0\", 2, Some(\"0\"));\n    test(\"1\", 2, Some(\"1\"));\n    test(\"2\", 2, None);\n    test(\"3\", 2, None);\n    test(\"4\", 2, Some(\"2\"));\n    test(\"5\", 2, None);\n    test(\"0\", 3, Some(\"0\"));\n    test(\"1\", 3, Some(\"1\"));\n    test(\"2\", 3, None);\n    test(\"7\", 3, None);\n    test(\"8\", 3, Some(\"2\"));\n    test(\"9\", 3, None);\n    test(\"10\", 2, None);\n    test(\"100\", 2, Some(\"10\"));\n    test(\"100\", 3, None);\n    test(\"1000000000\", 2, None);\n    test(\"1000000000\", 3, Some(\"1000\"));\n    test(\"1000000000\", 4, None);\n    test(\"1000000000\", 5, None);\n    test(\"1000000000\", 6, None);\n    test(\"1000000000\", 7, None);\n    test(\"1000000000\", 8, None);\n    test(\"1000000000\", 9, Some(\"10\"));\n    test(\"1000000000\", 10, None);\n\n    test(\"-1\", 1, Some(\"-1\"));\n    test(\"-2\", 1, Some(\"-2\"));\n    test(\"-100\", 1, Some(\"-100\"));\n\n    test(\"-1\", 3, Some(\"-1\"));\n    test(\"-2\", 3, None);\n    test(\"-7\", 3, None);\n    test(\"-8\", 3, Some(\"-2\"));\n    test(\"-9\", 3, None);\n    test(\"-100\", 3, None);\n    test(\"-1000000000\", 3, Some(\"-1000\"));\n    test(\"-1000000000\", 5, None);\n    test(\"-1000000000\", 7, None);\n    test(\"-1000000000\", 9, Some(\"-10\"));\n}\n\n#[test]\nfn checked_root_fail() {\n    assert_panic!(Integer::ONE.checked_root(0));\n    assert_panic!(Integer::NEGATIVE_ONE.checked_root(0));\n    assert_panic!(Integer::NEGATIVE_ONE.checked_root(2));\n    assert_panic!(Integer::NEGATIVE_ONE.checked_root(4));\n    assert_panic!(Integer::NEGATIVE_ONE.checked_root(100));\n}\n\n#[test]\nfn checked_root_ref_fail() {\n    assert_panic!((&Integer::ONE).checked_root(0));\n    assert_panic!((&Integer::NEGATIVE_ONE).checked_root(0));\n    assert_panic!((&Integer::NEGATIVE_ONE).checked_root(2));\n    assert_panic!((&Integer::NEGATIVE_ONE).checked_root(4));\n    assert_panic!((&Integer::NEGATIVE_ONE).checked_root(100));\n}\n\n#[test]\nfn floor_cbrt_properties() {\n    integer_gen().test_properties(|n| {\n        let cbrt = n.clone().floor_root(3);\n        assert!(cbrt.is_valid());\n        let cbrt_alt = (&n).floor_root(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(cbrt_alt, cbrt);\n        let mut n_alt = n.clone();\n        n_alt.floor_root_assign(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(n_alt, cbrt);\n        if n >= 0 {\n            assert_eq!(Integer::from(&BigInt::from(&n).nth_root(3)), cbrt);\n            assert_eq!(Integer::from(&rug::Integer::from(&n).root(3)), cbrt);\n        }\n\n        let cube = (&cbrt).pow(3);\n        let ceiling_cbrt = (&n).ceiling_root(3);\n        if cube == n {\n            assert_eq!(ceiling_cbrt, cbrt);\n        } else {\n            assert_eq!(ceiling_cbrt, &cbrt + Integer::ONE);\n        }\n        assert!(cube <= n);\n        assert!((&cbrt + Integer::ONE).pow(3) > n);\n        assert_eq!(-(-n).ceiling_root(3), cbrt);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).floor_root(3), Integer::from(n).floor_root(3));\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.floor_root(3), Integer::from(i).floor_root(3));\n    });\n}\n\n#[test]\nfn ceiling_cbrt_properties() {\n    integer_gen().test_properties(|n| {\n        let cbrt = n.clone().ceiling_root(3);\n        assert!(cbrt.is_valid());\n        let cbrt_alt = (&n).ceiling_root(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(cbrt_alt, cbrt);\n        let mut n_alt = n.clone();\n        n_alt.ceiling_root_assign(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(n_alt, cbrt);\n        if n < 0 {\n            assert_eq!(Integer::from(&BigInt::from(&n).nth_root(3)), cbrt);\n            assert_eq!(Integer::from(&rug::Integer::from(&n).root(3)), cbrt);\n        }\n        let cube = (&cbrt).pow(3);\n        let floor_cbrt = (&n).floor_root(3);\n        if cube == n {\n            assert_eq!(floor_cbrt, cbrt);\n        } else {\n            assert_eq!(floor_cbrt, &cbrt - Integer::ONE);\n        }\n        assert!(cube >= n);\n        if n != 0 {\n            assert!((&cbrt - Integer::ONE).pow(3) < n);\n        }\n        assert_eq!(-(-n).floor_root(3), cbrt);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).ceiling_root(3), Integer::from(n).ceiling_root(3));\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.ceiling_root(3), Integer::from(i).ceiling_root(3));\n    });\n}\n\n#[test]\nfn checked_cbrt_properties() {\n    integer_gen().test_properties(|n| {\n        let cbrt = n.clone().checked_root(3);\n        assert!(cbrt.as_ref().is_none_or(Integer::is_valid));\n        let cbrt_alt = (&n).checked_root(3);\n        assert!(cbrt_alt.as_ref().is_none_or(Integer::is_valid));\n        assert_eq!(cbrt_alt, cbrt);\n        if let Some(cbrt) = cbrt {\n            assert_eq!((&cbrt).pow(3), n);\n            assert_eq!((&n).floor_root(3), cbrt);\n            assert_eq!(n.ceiling_root(3), cbrt);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(\n            (&n).checked_root(3).map(Integer::from),\n            Integer::from(n).checked_root(3)\n        );\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(\n            i.checked_root(3).map(Integer::from),\n            Integer::from(i).checked_root(3)\n        );\n    });\n}\n\n#[test]\nfn floor_root_properties() {\n    integer_unsigned_pair_gen_var_3().test_properties(|(n, exp)| {\n        let root = n.clone().floor_root(exp);\n        assert!(root.is_valid());\n        let root_alt = (&n).floor_root(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(root_alt, root);\n        let mut n_alt = n.clone();\n        n_alt.floor_root_assign(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(n_alt, root);\n        if n >= 0 {\n            assert_eq!(\n                Integer::from(&BigInt::from(&n).nth_root(u32::exact_from(exp))),\n                root\n            );\n            assert_eq!(\n                Integer::from(&rug::Integer::from(&n).root(u32::exact_from(exp))),\n                root\n            );\n        }\n\n        let pow = (&root).pow(exp);\n        let ceiling_root = (&n).ceiling_root(exp);\n        if pow == n {\n            assert_eq!(ceiling_root, root);\n        } else {\n            assert_eq!(ceiling_root, &root + Integer::ONE);\n        }\n        assert!(pow <= n);\n        assert!((&root + Integer::ONE).pow(exp) > n);\n        if exp.odd() {\n            assert_eq!(-(-n).ceiling_root(exp), root);\n        }\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!((&n).floor_root(1), n);\n    });\n\n    integer_gen_var_4().test_properties(|n| {\n        assert_eq!((&n).floor_root(2), (&n).floor_sqrt());\n    });\n\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, exp)| {\n        assert_eq!((&n).floor_root(exp), Integer::from(n).floor_root(exp));\n    });\n\n    signed_unsigned_pair_gen_var_18::<SignedLimb, u64>().test_properties(|(i, exp)| {\n        assert_eq!(i.floor_root(exp), Integer::from(i).floor_root(exp));\n    });\n}\n\n#[test]\nfn ceiling_root_properties() {\n    integer_unsigned_pair_gen_var_3().test_properties(|(n, exp)| {\n        let root = n.clone().ceiling_root(exp);\n        assert!(root.is_valid());\n        let root_alt = (&n).ceiling_root(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(root_alt, root);\n        let mut n_alt = n.clone();\n        n_alt.ceiling_root_assign(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(n_alt, root);\n        if n < 0 {\n            assert_eq!(\n                Integer::from(&BigInt::from(&n).nth_root(u32::exact_from(exp))),\n                root\n            );\n            assert_eq!(\n                Integer::from(&rug::Integer::from(&n).root(u32::exact_from(exp))),\n                root\n            );\n        }\n        let pow = (&root).pow(exp);\n        let floor_root = (&n).floor_root(exp);\n        if pow == n {\n            assert_eq!(floor_root, root);\n        } else {\n            assert_eq!(floor_root, &root - Integer::ONE);\n        }\n        assert!(pow >= n);\n        if n != 0 {\n            assert!((&root - Integer::ONE).pow(exp) < n);\n        }\n        if exp.odd() {\n            assert_eq!(-(-n).floor_root(exp), root);\n        }\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!((&n).ceiling_root(1), n);\n    });\n\n    integer_gen_var_4().test_properties(|n| {\n        assert_eq!((&n).ceiling_root(2), (&n).ceiling_sqrt());\n    });\n\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, exp)| {\n        assert_eq!((&n).ceiling_root(exp), Integer::from(n).ceiling_root(exp));\n    });\n\n    signed_unsigned_pair_gen_var_18::<SignedLimb, u64>().test_properties(|(i, exp)| {\n        assert_eq!(i.ceiling_root(exp), Integer::from(i).ceiling_root(exp));\n    });\n}\n\n#[test]\nfn checked_root_properties() {\n    integer_unsigned_pair_gen_var_3().test_properties(|(n, exp)| {\n        let root = n.clone().checked_root(exp);\n        assert!(root.as_ref().is_none_or(Integer::is_valid));\n        let root_alt = (&n).checked_root(exp);\n        assert!(root_alt.as_ref().is_none_or(Integer::is_valid));\n        assert_eq!(root_alt, root);\n        if let Some(root) = root {\n            assert_eq!((&root).pow(exp), n);\n            assert_eq!((&n).floor_root(exp), root);\n            assert_eq!(n.ceiling_root(exp), root);\n        }\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!((&n).checked_root(1), Some(n));\n    });\n\n    integer_gen_var_4().test_properties(|n| {\n        assert_eq!((&n).checked_root(2), (&n).checked_sqrt());\n    });\n\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, exp)| {\n        assert_eq!(\n            (&n).checked_root(exp).map(Integer::from),\n            Integer::from(n).checked_root(exp)\n        );\n    });\n\n    signed_unsigned_pair_gen_var_18::<SignedLimb, u64>().test_properties(|(i, exp)| {\n        assert_eq!(\n            i.checked_root(exp).map(Integer::from),\n            Integer::from(i).checked_root(exp)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, DivRound, DivisibleBy, Parity, RoundToMultiple, RoundToMultipleAssign,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::signed_signed_rounding_mode_triple_gen_var_2;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_integer_rounding_mode_triple_gen_var_2, integer_pair_gen_var_1, integer_pair_gen_var_3,\n    integer_rounding_mode_pair_gen, natural_natural_rounding_mode_triple_gen_var_2,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_round_to_multiple() {\n    let test = |s, t, rm, multiple, o| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        assert_eq!(n.round_to_multiple_assign(v.clone(), rm), o);\n        assert_eq!(n.to_string(), multiple);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        assert_eq!(n.round_to_multiple_assign(&v, rm), o);\n        assert_eq!(n.to_string(), multiple);\n        assert!(n.is_valid());\n\n        let (r, o_alt) = u.clone().round_to_multiple(v.clone(), rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), multiple);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = u.clone().round_to_multiple(&v, rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), multiple);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = (&u).round_to_multiple(v.clone(), rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), multiple);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = (&u).round_to_multiple(&v, rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), multiple);\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", \"1\", Down, \"0\", Equal);\n    test(\"0\", \"1\", Floor, \"0\", Equal);\n    test(\"0\", \"1\", Up, \"0\", Equal);\n    test(\"0\", \"1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"1\", Nearest, \"0\", Equal);\n    test(\"0\", \"1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"123\", Down, \"0\", Equal);\n    test(\"0\", \"123\", Floor, \"0\", Equal);\n    test(\"0\", \"123\", Up, \"0\", Equal);\n    test(\"0\", \"123\", Ceiling, \"0\", Equal);\n    test(\"0\", \"123\", Nearest, \"0\", Equal);\n    test(\"0\", \"123\", Exact, \"0\", Equal);\n\n    test(\"1\", \"1\", Down, \"1\", Equal);\n    test(\"1\", \"1\", Floor, \"1\", Equal);\n    test(\"1\", \"1\", Up, \"1\", Equal);\n    test(\"1\", \"1\", Ceiling, \"1\", Equal);\n    test(\"1\", \"1\", Nearest, \"1\", Equal);\n    test(\"1\", \"1\", Exact, \"1\", Equal);\n\n    test(\"123\", \"1\", Down, \"123\", Equal);\n    test(\"123\", \"1\", Floor, \"123\", Equal);\n    test(\"123\", \"1\", Up, \"123\", Equal);\n    test(\"123\", \"1\", Ceiling, \"123\", Equal);\n    test(\"123\", \"1\", Nearest, \"123\", Equal);\n    test(\"123\", \"1\", Exact, \"123\", Equal);\n\n    test(\"123\", \"2\", Down, \"122\", Less);\n    test(\"123\", \"2\", Floor, \"122\", Less);\n    test(\"123\", \"2\", Up, \"124\", Greater);\n    test(\"123\", \"2\", Ceiling, \"124\", Greater);\n    test(\"123\", \"2\", Nearest, \"124\", Greater);\n\n    test(\"125\", \"2\", Down, \"124\", Less);\n    test(\"125\", \"2\", Floor, \"124\", Less);\n    test(\"125\", \"2\", Up, \"126\", Greater);\n    test(\"125\", \"2\", Ceiling, \"126\", Greater);\n    test(\"125\", \"2\", Nearest, \"124\", Less);\n\n    test(\"123\", \"123\", Down, \"123\", Equal);\n    test(\"123\", \"123\", Floor, \"123\", Equal);\n    test(\"123\", \"123\", Up, \"123\", Equal);\n    test(\"123\", \"123\", Ceiling, \"123\", Equal);\n    test(\"123\", \"123\", Nearest, \"123\", Equal);\n    test(\"123\", \"123\", Exact, \"123\", Equal);\n\n    test(\"123\", \"456\", Down, \"0\", Less);\n    test(\"123\", \"456\", Floor, \"0\", Less);\n    test(\"123\", \"456\", Up, \"456\", Greater);\n    test(\"123\", \"456\", Ceiling, \"456\", Greater);\n    test(\"123\", \"456\", Nearest, \"0\", Less);\n\n    test(\"1000000000000\", \"1\", Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Exact, \"1000000000000\", Equal);\n\n    test(\"1000000000000\", \"3\", Down, \"999999999999\", Less);\n    test(\"1000000000000\", \"3\", Floor, \"999999999999\", Less);\n    test(\"1000000000000\", \"3\", Up, \"1000000000002\", Greater);\n    test(\"1000000000000\", \"3\", Ceiling, \"1000000000002\", Greater);\n    test(\"1000000000000\", \"3\", Nearest, \"999999999999\", Less);\n\n    test(\"999999999999\", \"2\", Down, \"999999999998\", Less);\n    test(\"999999999999\", \"2\", Floor, \"999999999998\", Less);\n    test(\"999999999999\", \"2\", Up, \"1000000000000\", Greater);\n    test(\"999999999999\", \"2\", Ceiling, \"1000000000000\", Greater);\n    test(\"999999999999\", \"2\", Nearest, \"1000000000000\", Greater);\n\n    test(\"1000000000001\", \"2\", Down, \"1000000000000\", Less);\n    test(\"1000000000001\", \"2\", Floor, \"1000000000000\", Less);\n    test(\"1000000000001\", \"2\", Up, \"1000000000002\", Greater);\n    test(\"1000000000001\", \"2\", Ceiling, \"1000000000002\", Greater);\n    test(\"1000000000001\", \"2\", Nearest, \"1000000000000\", Less);\n\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Down,\n        \"999999999999996832276305\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Floor,\n        \"999999999999996832276305\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Up,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Ceiling,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Nearest,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Down,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Floor,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Up,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Ceiling,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Nearest,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Exact,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Down,\n        \"999999999999999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Floor,\n        \"999999999999999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Up,\n        \"1000000000001000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Ceiling,\n        \"1000000000001000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Nearest,\n        \"999999999999999999999999\",\n        Less,\n    );\n\n    test(\n        \"2999999999999999999999999\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"2000000000000000000000000\",\n        Less,\n    );\n    test(\n        \"3000000000000000000000000\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"4000000000000000000000000\",\n        Greater,\n    );\n    test(\n        \"3000000000000000000000001\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"4000000000000000000000000\",\n        Greater,\n    );\n\n    test(\"0\", \"-1\", Down, \"0\", Equal);\n    test(\"0\", \"-1\", Floor, \"0\", Equal);\n    test(\"0\", \"-1\", Up, \"0\", Equal);\n    test(\"0\", \"-1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"-1\", Nearest, \"0\", Equal);\n    test(\"0\", \"-1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"-123\", Down, \"0\", Equal);\n    test(\"0\", \"-123\", Floor, \"0\", Equal);\n    test(\"0\", \"-123\", Up, \"0\", Equal);\n    test(\"0\", \"-123\", Ceiling, \"0\", Equal);\n    test(\"0\", \"-123\", Nearest, \"0\", Equal);\n    test(\"0\", \"-123\", Exact, \"0\", Equal);\n\n    test(\"1\", \"-1\", Down, \"1\", Equal);\n    test(\"1\", \"-1\", Floor, \"1\", Equal);\n    test(\"1\", \"-1\", Up, \"1\", Equal);\n    test(\"1\", \"-1\", Ceiling, \"1\", Equal);\n    test(\"1\", \"-1\", Nearest, \"1\", Equal);\n    test(\"1\", \"-1\", Exact, \"1\", Equal);\n\n    test(\"123\", \"-1\", Down, \"123\", Equal);\n    test(\"123\", \"-1\", Floor, \"123\", Equal);\n    test(\"123\", \"-1\", Up, \"123\", Equal);\n    test(\"123\", \"-1\", Ceiling, \"123\", Equal);\n    test(\"123\", \"-1\", Nearest, \"123\", Equal);\n    test(\"123\", \"-1\", Exact, \"123\", Equal);\n\n    test(\"123\", \"-2\", Down, \"122\", Less);\n    test(\"123\", \"-2\", Floor, \"122\", Less);\n    test(\"123\", \"-2\", Up, \"124\", Greater);\n    test(\"123\", \"-2\", Ceiling, \"124\", Greater);\n    test(\"123\", \"-2\", Nearest, \"124\", Greater);\n\n    test(\"125\", \"-2\", Down, \"124\", Less);\n    test(\"125\", \"-2\", Floor, \"124\", Less);\n    test(\"125\", \"-2\", Up, \"126\", Greater);\n    test(\"125\", \"-2\", Ceiling, \"126\", Greater);\n    test(\"125\", \"-2\", Nearest, \"124\", Less);\n\n    test(\"123\", \"-123\", Down, \"123\", Equal);\n    test(\"123\", \"-123\", Floor, \"123\", Equal);\n    test(\"123\", \"-123\", Up, \"123\", Equal);\n    test(\"123\", \"-123\", Ceiling, \"123\", Equal);\n    test(\"123\", \"-123\", Nearest, \"123\", Equal);\n    test(\"123\", \"-123\", Exact, \"123\", Equal);\n\n    test(\"123\", \"-456\", Down, \"0\", Less);\n    test(\"123\", \"-456\", Floor, \"0\", Less);\n    test(\"123\", \"-456\", Up, \"456\", Greater);\n    test(\"123\", \"-456\", Ceiling, \"456\", Greater);\n    test(\"123\", \"-456\", Nearest, \"0\", Less);\n\n    test(\"1000000000000\", \"-1\", Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"-1\", Exact, \"1000000000000\", Equal);\n\n    test(\"1000000000000\", \"-3\", Down, \"999999999999\", Less);\n    test(\"1000000000000\", \"-3\", Floor, \"999999999999\", Less);\n    test(\"1000000000000\", \"-3\", Up, \"1000000000002\", Greater);\n    test(\"1000000000000\", \"-3\", Ceiling, \"1000000000002\", Greater);\n    test(\"1000000000000\", \"-3\", Nearest, \"999999999999\", Less);\n\n    test(\"999999999999\", \"-2\", Down, \"999999999998\", Less);\n    test(\"999999999999\", \"-2\", Floor, \"999999999998\", Less);\n    test(\"999999999999\", \"-2\", Up, \"1000000000000\", Greater);\n    test(\"999999999999\", \"-2\", Ceiling, \"1000000000000\", Greater);\n    test(\"999999999999\", \"-2\", Nearest, \"1000000000000\", Greater);\n\n    test(\"1000000000001\", \"-2\", Down, \"1000000000000\", Less);\n    test(\"1000000000001\", \"-2\", Floor, \"1000000000000\", Less);\n    test(\"1000000000001\", \"-2\", Up, \"1000000000002\", Greater);\n    test(\"1000000000001\", \"-2\", Ceiling, \"1000000000002\", Greater);\n    test(\"1000000000001\", \"-2\", Nearest, \"1000000000000\", Less);\n\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Down,\n        \"999999999999996832276305\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Floor,\n        \"999999999999996832276305\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Up,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Ceiling,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-4294967295\",\n        Nearest,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Down,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Floor,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Up,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Ceiling,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Nearest,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000000\",\n        Exact,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Down,\n        \"999999999999999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Floor,\n        \"999999999999999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Up,\n        \"1000000000001000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Ceiling,\n        \"1000000000001000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"-1000000000001\",\n        Nearest,\n        \"999999999999999999999999\",\n        Less,\n    );\n\n    test(\n        \"2999999999999999999999999\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"2000000000000000000000000\",\n        Less,\n    );\n    test(\n        \"3000000000000000000000000\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"4000000000000000000000000\",\n        Greater,\n    );\n    test(\n        \"3000000000000000000000001\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"4000000000000000000000000\",\n        Greater,\n    );\n\n    test(\"-1\", \"1\", Down, \"-1\", Equal);\n    test(\"-1\", \"1\", Floor, \"-1\", Equal);\n    test(\"-1\", \"1\", Up, \"-1\", Equal);\n    test(\"-1\", \"1\", Ceiling, \"-1\", Equal);\n    test(\"-1\", \"1\", Nearest, \"-1\", Equal);\n    test(\"-1\", \"1\", Exact, \"-1\", Equal);\n\n    test(\"-123\", \"1\", Down, \"-123\", Equal);\n    test(\"-123\", \"1\", Floor, \"-123\", Equal);\n    test(\"-123\", \"1\", Up, \"-123\", Equal);\n    test(\"-123\", \"1\", Ceiling, \"-123\", Equal);\n    test(\"-123\", \"1\", Nearest, \"-123\", Equal);\n    test(\"-123\", \"1\", Exact, \"-123\", Equal);\n\n    test(\"-123\", \"2\", Down, \"-122\", Greater);\n    test(\"-123\", \"2\", Floor, \"-124\", Less);\n    test(\"-123\", \"2\", Up, \"-124\", Less);\n    test(\"-123\", \"2\", Ceiling, \"-122\", Greater);\n    test(\"-123\", \"2\", Nearest, \"-124\", Less);\n\n    test(\"-125\", \"2\", Down, \"-124\", Greater);\n    test(\"-125\", \"2\", Floor, \"-126\", Less);\n    test(\"-125\", \"2\", Up, \"-126\", Less);\n    test(\"-125\", \"2\", Ceiling, \"-124\", Greater);\n    test(\"-125\", \"2\", Nearest, \"-124\", Greater);\n\n    test(\"-123\", \"123\", Down, \"-123\", Equal);\n    test(\"-123\", \"123\", Floor, \"-123\", Equal);\n    test(\"-123\", \"123\", Up, \"-123\", Equal);\n    test(\"-123\", \"123\", Ceiling, \"-123\", Equal);\n    test(\"-123\", \"123\", Nearest, \"-123\", Equal);\n    test(\"-123\", \"123\", Exact, \"-123\", Equal);\n\n    test(\"-123\", \"456\", Down, \"0\", Greater);\n    test(\"-123\", \"456\", Floor, \"-456\", Less);\n    test(\"-123\", \"456\", Up, \"-456\", Less);\n    test(\"-123\", \"456\", Ceiling, \"0\", Greater);\n    test(\"-123\", \"456\", Nearest, \"0\", Greater);\n\n    test(\"-1000000000000\", \"1\", Down, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Floor, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Up, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Ceiling, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Nearest, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"1\", Exact, \"-1000000000000\", Equal);\n\n    test(\"-1000000000000\", \"3\", Down, \"-999999999999\", Greater);\n    test(\"-1000000000000\", \"3\", Floor, \"-1000000000002\", Less);\n    test(\"-1000000000000\", \"3\", Up, \"-1000000000002\", Less);\n    test(\"-1000000000000\", \"3\", Ceiling, \"-999999999999\", Greater);\n    test(\"-1000000000000\", \"3\", Nearest, \"-999999999999\", Greater);\n\n    test(\"-999999999999\", \"2\", Down, \"-999999999998\", Greater);\n    test(\"-999999999999\", \"2\", Floor, \"-1000000000000\", Less);\n    test(\"-999999999999\", \"2\", Up, \"-1000000000000\", Less);\n    test(\"-999999999999\", \"2\", Ceiling, \"-999999999998\", Greater);\n    test(\"-999999999999\", \"2\", Nearest, \"-1000000000000\", Less);\n\n    test(\"-1000000000001\", \"2\", Down, \"-1000000000000\", Greater);\n    test(\"-1000000000001\", \"2\", Floor, \"-1000000000002\", Less);\n    test(\"-1000000000001\", \"2\", Up, \"-1000000000002\", Less);\n    test(\"-1000000000001\", \"2\", Ceiling, \"-1000000000000\", Greater);\n    test(\"-1000000000001\", \"2\", Nearest, \"-1000000000000\", Greater);\n\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Down,\n        \"-999999999999996832276305\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Floor,\n        \"-1000000000000001127243600\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Up,\n        \"-1000000000000001127243600\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Ceiling,\n        \"-999999999999996832276305\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"4294967295\",\n        Nearest,\n        \"-1000000000000001127243600\",\n        Less,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Down,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Floor,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Up,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Ceiling,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Nearest,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000000\",\n        Exact,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Down,\n        \"-999999999999999999999999\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Floor,\n        \"-1000000000001000000000000\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Up,\n        \"-1000000000001000000000000\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Ceiling,\n        \"-999999999999999999999999\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"1000000000001\",\n        Nearest,\n        \"-999999999999999999999999\",\n        Greater,\n    );\n\n    test(\n        \"-2999999999999999999999999\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"-2000000000000000000000000\",\n        Greater,\n    );\n    test(\n        \"-3000000000000000000000000\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"-4000000000000000000000000\",\n        Less,\n    );\n    test(\n        \"-3000000000000000000000001\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"-4000000000000000000000000\",\n        Less,\n    );\n\n    test(\"-1\", \"-1\", Down, \"-1\", Equal);\n    test(\"-1\", \"-1\", Floor, \"-1\", Equal);\n    test(\"-1\", \"-1\", Up, \"-1\", Equal);\n    test(\"-1\", \"-1\", Ceiling, \"-1\", Equal);\n    test(\"-1\", \"-1\", Nearest, \"-1\", Equal);\n    test(\"-1\", \"-1\", Exact, \"-1\", Equal);\n\n    test(\"-123\", \"-1\", Down, \"-123\", Equal);\n    test(\"-123\", \"-1\", Floor, \"-123\", Equal);\n    test(\"-123\", \"-1\", Up, \"-123\", Equal);\n    test(\"-123\", \"-1\", Ceiling, \"-123\", Equal);\n    test(\"-123\", \"-1\", Nearest, \"-123\", Equal);\n    test(\"-123\", \"-1\", Exact, \"-123\", Equal);\n\n    test(\"-123\", \"-2\", Down, \"-122\", Greater);\n    test(\"-123\", \"-2\", Floor, \"-124\", Less);\n    test(\"-123\", \"-2\", Up, \"-124\", Less);\n    test(\"-123\", \"-2\", Ceiling, \"-122\", Greater);\n    test(\"-123\", \"-2\", Nearest, \"-124\", Less);\n\n    test(\"-125\", \"-2\", Down, \"-124\", Greater);\n    test(\"-125\", \"-2\", Floor, \"-126\", Less);\n    test(\"-125\", \"-2\", Up, \"-126\", Less);\n    test(\"-125\", \"-2\", Ceiling, \"-124\", Greater);\n    test(\"-125\", \"-2\", Nearest, \"-124\", Greater);\n\n    test(\"-123\", \"-123\", Down, \"-123\", Equal);\n    test(\"-123\", \"-123\", Floor, \"-123\", Equal);\n    test(\"-123\", \"-123\", Up, \"-123\", Equal);\n    test(\"-123\", \"-123\", Ceiling, \"-123\", Equal);\n    test(\"-123\", \"-123\", Nearest, \"-123\", Equal);\n    test(\"-123\", \"-123\", Exact, \"-123\", Equal);\n\n    test(\"-123\", \"-456\", Down, \"0\", Greater);\n    test(\"-123\", \"-456\", Floor, \"-456\", Less);\n    test(\"-123\", \"-456\", Up, \"-456\", Less);\n    test(\"-123\", \"-456\", Ceiling, \"0\", Greater);\n    test(\"-123\", \"-456\", Nearest, \"0\", Greater);\n\n    test(\"-1000000000000\", \"-1\", Down, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Floor, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Up, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Ceiling, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Nearest, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", \"-1\", Exact, \"-1000000000000\", Equal);\n\n    test(\"-1000000000000\", \"-3\", Down, \"-999999999999\", Greater);\n    test(\"-1000000000000\", \"-3\", Floor, \"-1000000000002\", Less);\n    test(\"-1000000000000\", \"-3\", Up, \"-1000000000002\", Less);\n    test(\"-1000000000000\", \"-3\", Ceiling, \"-999999999999\", Greater);\n    test(\"-1000000000000\", \"-3\", Nearest, \"-999999999999\", Greater);\n\n    test(\"-999999999999\", \"-2\", Down, \"-999999999998\", Greater);\n    test(\"-999999999999\", \"-2\", Floor, \"-1000000000000\", Less);\n    test(\"-999999999999\", \"-2\", Up, \"-1000000000000\", Less);\n    test(\"-999999999999\", \"-2\", Ceiling, \"-999999999998\", Greater);\n    test(\"-999999999999\", \"-2\", Nearest, \"-1000000000000\", Less);\n\n    test(\"-1000000000001\", \"-2\", Down, \"-1000000000000\", Greater);\n    test(\"-1000000000001\", \"-2\", Floor, \"-1000000000002\", Less);\n    test(\"-1000000000001\", \"-2\", Up, \"-1000000000002\", Less);\n    test(\"-1000000000001\", \"-2\", Ceiling, \"-1000000000000\", Greater);\n    test(\"-1000000000001\", \"-2\", Nearest, \"-1000000000000\", Greater);\n\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Down,\n        \"-999999999999996832276305\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Floor,\n        \"-1000000000000001127243600\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Up,\n        \"-1000000000000001127243600\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Ceiling,\n        \"-999999999999996832276305\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-4294967295\",\n        Nearest,\n        \"-1000000000000001127243600\",\n        Less,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Down,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Floor,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Up,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Ceiling,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Nearest,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000000\",\n        Exact,\n        \"-1000000000000000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Down,\n        \"-999999999999999999999999\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Floor,\n        \"-1000000000001000000000000\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Up,\n        \"-1000000000001000000000000\",\n        Less,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Ceiling,\n        \"-999999999999999999999999\",\n        Greater,\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"-1000000000001\",\n        Nearest,\n        \"-999999999999999999999999\",\n        Greater,\n    );\n\n    test(\n        \"-2999999999999999999999999\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"-2000000000000000000000000\",\n        Greater,\n    );\n    test(\n        \"-3000000000000000000000000\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"-4000000000000000000000000\",\n        Less,\n    );\n    test(\n        \"-3000000000000000000000001\",\n        \"-2000000000000000000000000\",\n        Nearest,\n        \"-4000000000000000000000000\",\n        Less,\n    );\n\n    test(\"0\", \"0\", Floor, \"0\", Equal);\n    test(\"0\", \"0\", Ceiling, \"0\", Equal);\n    test(\"0\", \"0\", Down, \"0\", Equal);\n    test(\"0\", \"0\", Up, \"0\", Equal);\n    test(\"0\", \"0\", Nearest, \"0\", Equal);\n    test(\"0\", \"0\", Exact, \"0\", Equal);\n\n    test(\"2\", \"0\", Floor, \"0\", Less);\n    test(\"2\", \"0\", Down, \"0\", Less);\n    test(\"2\", \"0\", Nearest, \"0\", Less);\n    test(\"-2\", \"0\", Ceiling, \"0\", Greater);\n    test(\"-2\", \"0\", Down, \"0\", Greater);\n    test(\"-2\", \"0\", Nearest, \"0\", Greater);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_1() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_2() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(Integer::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_3() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(Integer::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_4() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(Integer::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_1() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(&Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_2() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(&Integer::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_3() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(&Integer::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_4() {\n    let mut n = Integer::from(10);\n    n.round_to_multiple_assign(&Integer::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_1() {\n    Integer::from(10).round_to_multiple(Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_2() {\n    Integer::from(10).round_to_multiple(Integer::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_3() {\n    Integer::from(10).round_to_multiple(Integer::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_4() {\n    Integer::from(10).round_to_multiple(Integer::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_1() {\n    Integer::from(10).round_to_multiple(&Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_2() {\n    Integer::from(10).round_to_multiple(&Integer::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_3() {\n    Integer::from(10).round_to_multiple(&Integer::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_4() {\n    Integer::from(10).round_to_multiple(&Integer::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_1() {\n    (&Integer::from(10)).round_to_multiple(Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_2() {\n    (&Integer::from(10)).round_to_multiple(Integer::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_3() {\n    (&Integer::from(10)).round_to_multiple(Integer::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_4() {\n    (&Integer::from(10)).round_to_multiple(Integer::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_1() {\n    (&Integer::from(10)).round_to_multiple(&Integer::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_2() {\n    (&Integer::from(10)).round_to_multiple(&Integer::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_3() {\n    (&Integer::from(10)).round_to_multiple(&Integer::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_4() {\n    (&Integer::from(10)).round_to_multiple(&Integer::ZERO, Exact);\n}\n\n#[test]\nfn round_to_multiple_properties() {\n    integer_integer_rounding_mode_triple_gen_var_2().test_properties(|(x, y, rm)| {\n        let mut mut_n = x.clone();\n        let o = mut_n.round_to_multiple_assign(&y, rm);\n        assert!(mut_n.is_valid());\n        let r = mut_n;\n\n        let mut mut_n = x.clone();\n        assert_eq!(mut_n.round_to_multiple_assign(y.clone(), rm), o);\n        assert!(mut_n.is_valid());\n        assert_eq!(mut_n, r);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(&y, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(y.clone(), rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = x.clone().round_to_multiple(&y, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = x.clone().round_to_multiple(y.clone(), rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = (-&x).round_to_multiple(&y, -rm);\n        assert_eq!(-r_alt, r);\n        assert_eq!(o_alt.reverse(), o);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(-&y, rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        assert!((&r).divisible_by(&y));\n        assert_eq!(r.cmp(&x), o);\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if y == 0 {\n            assert_eq!(r, 0);\n            assert_eq!(o, Equal);\n        } else {\n            assert!((&r - &x).le_abs(&y));\n            match rm {\n                Floor => assert!(r <= x),\n                Ceiling => assert!(r >= x),\n                Down => assert!(r.le_abs(&x)),\n                Up => assert!(r.ge_abs(&x)),\n                Exact => assert_eq!(r, x),\n                Nearest => {\n                    let closest;\n                    let second_closest;\n                    if r <= x {\n                        closest = &x - &r;\n                        second_closest = &r + (&y).abs() - &x;\n                    } else {\n                        closest = &r - &x;\n                        second_closest = x + (&y).abs() - &r;\n                    }\n                    assert!(closest <= second_closest);\n                    if closest == second_closest {\n                        assert!(r.div_round(y, Exact).0.even());\n                    }\n                }\n            }\n        }\n    });\n\n    integer_pair_gen_var_1().test_properties(|(x, y)| {\n        let product = x * &y;\n        let po = (product.clone(), Equal);\n        assert_eq!((&product).round_to_multiple(&y, Down), po);\n        assert_eq!((&product).round_to_multiple(&y, Up), po);\n        assert_eq!((&product).round_to_multiple(&y, Floor), po);\n        assert_eq!((&product).round_to_multiple(&y, Ceiling), po);\n        assert_eq!((&product).round_to_multiple(&y, Nearest), po);\n        assert_eq!((&product).round_to_multiple(&y, Exact), po);\n    });\n\n    integer_pair_gen_var_3().test_properties(|(x, y)| {\n        let down = (&x).round_to_multiple(&y, Down);\n        assert_eq!(down.1, if x >= 0 { Less } else { Greater });\n        let up = if x >= 0 {\n            (&down.0 + (&y).abs(), Greater)\n        } else {\n            (&down.0 - (&y).abs(), Less)\n        };\n        let floor = (&x).round_to_multiple(&y, Floor);\n        assert_eq!(floor.1, Less);\n        let ceiling = (&floor.0 + (&y).abs(), Greater);\n        assert_eq!((&x).round_to_multiple(&y, Up), up);\n        assert_eq!((&x).round_to_multiple(&y, Ceiling), ceiling);\n        let nearest = x.round_to_multiple(y, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(ref x, rm)| {\n        let xo = (x.clone(), Equal);\n        assert_eq!(x.round_to_multiple(Integer::ONE, rm), xo);\n        assert_eq!(x.round_to_multiple(Integer::NEGATIVE_ONE, rm), xo);\n        assert_eq!(\n            Integer::ZERO.round_to_multiple(x, rm),\n            (Integer::ZERO, Equal)\n        );\n        assert_eq!(x.round_to_multiple(x, rm), xo);\n        assert_eq!(x.round_to_multiple(-x, rm), xo);\n        assert_eq!((-x).round_to_multiple(x, rm), (-x, Equal));\n    });\n\n    natural_natural_rounding_mode_triple_gen_var_2().test_properties(|(x, y, rm)| {\n        let (n, no) = (&x).round_to_multiple(&y, rm);\n        let (i, io) = Integer::from(&x).round_to_multiple(Integer::from(&y), rm);\n        assert_eq!(n, i);\n        assert_eq!(no, io);\n    });\n\n    signed_signed_rounding_mode_triple_gen_var_2::<Limb, SignedLimb>().test_properties(\n        |(x, y, rm)| {\n            let (n, no) = x.round_to_multiple(y, rm);\n            let (i, io) = Integer::from(x).round_to_multiple(Integer::from(y), rm);\n            assert_eq!(n, i);\n            assert_eq!(no, io);\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, DivisibleByPowerOf2, PowerOf2, RoundToMultiple, RoundToMultipleOfPowerOf2,\n    RoundToMultipleOfPowerOf2Assign, ShrRound,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::signed_unsigned_rounding_mode_triple_gen_var_1;\nuse malachite_base::test_util::generators::unsigned_rounding_mode_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_rounding_mode_pair_gen, integer_unsigned_pair_gen_var_2,\n    integer_unsigned_pair_gen_var_5, integer_unsigned_rounding_mode_triple_gen_var_1,\n    natural_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_round_to_multiple_of_power_of_2() {\n    let test = |s, v: u64, rm: RoundingMode, out, o| {\n        let u = Integer::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        assert_eq!(n.round_to_multiple_of_power_of_2_assign(v, rm), o);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let (n, o_alt) = u.clone().round_to_multiple_of_power_of_2(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n\n        let (n, o_alt) = (&u).round_to_multiple_of_power_of_2(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n\n        let (n, o_alt) = u.shr_round(v, rm);\n        assert_eq!((n << v).to_string(), out);\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", 0, Down, \"0\", Equal);\n    test(\"0\", 0, Up, \"0\", Equal);\n    test(\"0\", 0, Floor, \"0\", Equal);\n    test(\"0\", 0, Ceiling, \"0\", Equal);\n    test(\"0\", 0, Nearest, \"0\", Equal);\n    test(\"0\", 0, Exact, \"0\", Equal);\n\n    test(\"0\", 10, Down, \"0\", Equal);\n    test(\"0\", 10, Up, \"0\", Equal);\n    test(\"0\", 10, Floor, \"0\", Equal);\n    test(\"0\", 10, Ceiling, \"0\", Equal);\n    test(\"0\", 10, Nearest, \"0\", Equal);\n    test(\"0\", 10, Exact, \"0\", Equal);\n\n    test(\"123\", 0, Down, \"123\", Equal);\n    test(\"123\", 0, Up, \"123\", Equal);\n    test(\"123\", 0, Floor, \"123\", Equal);\n    test(\"123\", 0, Ceiling, \"123\", Equal);\n    test(\"123\", 0, Nearest, \"123\", Equal);\n    test(\"123\", 0, Exact, \"123\", Equal);\n\n    test(\"245\", 1, Down, \"244\", Less);\n    test(\"245\", 1, Up, \"246\", Greater);\n    test(\"245\", 1, Floor, \"244\", Less);\n    test(\"245\", 1, Ceiling, \"246\", Greater);\n    test(\"245\", 1, Nearest, \"244\", Less);\n\n    test(\"246\", 1, Down, \"246\", Equal);\n    test(\"246\", 1, Up, \"246\", Equal);\n    test(\"246\", 1, Floor, \"246\", Equal);\n    test(\"246\", 1, Ceiling, \"246\", Equal);\n    test(\"246\", 1, Nearest, \"246\", Equal);\n    test(\"246\", 1, Exact, \"246\", Equal);\n\n    test(\"247\", 1, Down, \"246\", Less);\n    test(\"247\", 1, Up, \"248\", Greater);\n    test(\"247\", 1, Floor, \"246\", Less);\n    test(\"247\", 1, Ceiling, \"248\", Greater);\n    test(\"247\", 1, Nearest, \"248\", Greater);\n\n    test(\"491\", 2, Down, \"488\", Less);\n    test(\"491\", 2, Up, \"492\", Greater);\n    test(\"491\", 2, Floor, \"488\", Less);\n    test(\"491\", 2, Ceiling, \"492\", Greater);\n    test(\"491\", 2, Nearest, \"492\", Greater);\n\n    test(\"492\", 2, Down, \"492\", Equal);\n    test(\"492\", 2, Up, \"492\", Equal);\n    test(\"492\", 2, Floor, \"492\", Equal);\n    test(\"492\", 2, Ceiling, \"492\", Equal);\n    test(\"492\", 2, Nearest, \"492\", Equal);\n    test(\"492\", 2, Exact, \"492\", Equal);\n\n    test(\"493\", 2, Down, \"492\", Less);\n    test(\"493\", 2, Up, \"496\", Greater);\n    test(\"493\", 2, Floor, \"492\", Less);\n    test(\"493\", 2, Ceiling, \"496\", Greater);\n    test(\"493\", 2, Nearest, \"492\", Less);\n\n    test(\"4127195135\", 25, Down, \"4093640704\", Less);\n    test(\"4127195135\", 25, Up, \"4127195136\", Greater);\n    test(\"4127195135\", 25, Floor, \"4093640704\", Less);\n    test(\"4127195135\", 25, Ceiling, \"4127195136\", Greater);\n    test(\"4127195135\", 25, Nearest, \"4127195136\", Greater);\n\n    test(\"4127195136\", 25, Down, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Up, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Floor, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Ceiling, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Nearest, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Exact, \"4127195136\", Equal);\n\n    test(\"4127195137\", 25, Down, \"4127195136\", Less);\n    test(\"4127195137\", 25, Up, \"4160749568\", Greater);\n    test(\"4127195137\", 25, Floor, \"4127195136\", Less);\n    test(\"4127195137\", 25, Ceiling, \"4160749568\", Greater);\n    test(\"4127195137\", 25, Nearest, \"4127195136\", Less);\n\n    test(\"8254390271\", 26, Down, \"8187281408\", Less);\n    test(\"8254390271\", 26, Up, \"8254390272\", Greater);\n    test(\"8254390271\", 26, Floor, \"8187281408\", Less);\n    test(\"8254390271\", 26, Ceiling, \"8254390272\", Greater);\n    test(\"8254390271\", 26, Nearest, \"8254390272\", Greater);\n\n    test(\"8254390272\", 26, Down, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Up, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Floor, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Ceiling, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Nearest, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Exact, \"8254390272\", Equal);\n\n    test(\"8254390273\", 26, Down, \"8254390272\", Less);\n    test(\"8254390273\", 26, Up, \"8321499136\", Greater);\n    test(\"8254390273\", 26, Floor, \"8254390272\", Less);\n    test(\"8254390273\", 26, Ceiling, \"8321499136\", Greater);\n    test(\"8254390273\", 26, Nearest, \"8254390272\", Less);\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Down,\n        \"154653373227843986982597791055872\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Up,\n        \"155921023828072216384094494261248\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Floor,\n        \"154653373227843986982597791055872\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Ceiling,\n        \"155921023828072216384094494261248\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Nearest,\n        \"155921023828072216384094494261248\",\n        Greater,\n    );\n\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Down,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Up,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Floor,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Ceiling,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Nearest,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Exact,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Down,\n        \"155921023828072216384094494261248\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Up,\n        \"157188674428300445785591197466624\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Floor,\n        \"155921023828072216384094494261248\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Ceiling,\n        \"157188674428300445785591197466624\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Nearest,\n        \"155921023828072216384094494261248\",\n        Less,\n    );\n\n    test(\"4294967295\", 1, Down, \"4294967294\", Less);\n    test(\"4294967295\", 1, Up, \"4294967296\", Greater);\n    test(\"4294967295\", 1, Floor, \"4294967294\", Less);\n    test(\"4294967295\", 1, Ceiling, \"4294967296\", Greater);\n    test(\"4294967295\", 1, Nearest, \"4294967296\", Greater);\n\n    test(\"4294967296\", 1, Down, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Up, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Floor, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Ceiling, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Nearest, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Exact, \"4294967296\", Equal);\n\n    test(\"4294967297\", 1, Down, \"4294967296\", Less);\n    test(\"4294967297\", 1, Up, \"4294967298\", Greater);\n    test(\"4294967297\", 1, Floor, \"4294967296\", Less);\n    test(\"4294967297\", 1, Ceiling, \"4294967298\", Greater);\n    test(\"4294967297\", 1, Nearest, \"4294967296\", Less);\n\n    test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n    test(\"7999999999999\", 3, Down, \"7999999999992\", Less);\n    test(\"7999999999999\", 3, Up, \"8000000000000\", Greater);\n    test(\"7999999999999\", 3, Floor, \"7999999999992\", Less);\n    test(\"7999999999999\", 3, Ceiling, \"8000000000000\", Greater);\n    test(\"7999999999999\", 3, Nearest, \"8000000000000\", Greater);\n\n    test(\"8000000000000\", 3, Down, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Up, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Floor, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Ceiling, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Nearest, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Exact, \"8000000000000\", Equal);\n\n    test(\"8000000000001\", 3, Down, \"8000000000000\", Less);\n    test(\"8000000000001\", 3, Up, \"8000000000008\", Greater);\n    test(\"8000000000001\", 3, Floor, \"8000000000000\", Less);\n    test(\"8000000000001\", 3, Ceiling, \"8000000000008\", Greater);\n    test(\"8000000000001\", 3, Nearest, \"8000000000000\", Less);\n\n    test(\n        \"16777216000000000000\",\n        24,\n        Down,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Up,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Floor,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Ceiling,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Nearest,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Exact,\n        \"16777216000000000000\",\n        Equal,\n    );\n\n    test(\n        \"33554432000000000000\",\n        25,\n        Down,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Up,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Floor,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Ceiling,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Nearest,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Exact,\n        \"33554432000000000000\",\n        Equal,\n    );\n\n    test(\n        \"2147483648000000000000\",\n        31,\n        Down,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Up,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Floor,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Ceiling,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Nearest,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Exact,\n        \"2147483648000000000000\",\n        Equal,\n    );\n\n    test(\n        \"4294967296000000000000\",\n        32,\n        Down,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Up,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Floor,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Ceiling,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Nearest,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Exact,\n        \"4294967296000000000000\",\n        Equal,\n    );\n\n    test(\n        \"8589934592000000000000\",\n        33,\n        Down,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Up,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Floor,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Ceiling,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Nearest,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Exact,\n        \"8589934592000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Down,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Up,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Floor,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Ceiling,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Nearest,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Exact,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n\n    test(\"1000000000000\", 10, Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Exact, \"1000000000000\", Equal);\n\n    test(\"980657949\", 72, Down, \"0\", Less);\n    test(\"980657949\", 72, Up, \"4722366482869645213696\", Greater);\n    test(\"980657949\", 72, Floor, \"0\", Less);\n    test(\"980657949\", 72, Ceiling, \"4722366482869645213696\", Greater);\n    test(\"980657949\", 72, Nearest, \"0\", Less);\n\n    test(\"4294967295\", 31, Down, \"2147483648\", Less);\n    test(\"4294967295\", 31, Up, \"4294967296\", Greater);\n    test(\"4294967295\", 31, Floor, \"2147483648\", Less);\n    test(\"4294967295\", 31, Ceiling, \"4294967296\", Greater);\n    test(\"4294967295\", 31, Nearest, \"4294967296\", Greater);\n\n    test(\"4294967295\", 32, Down, \"0\", Less);\n    test(\"4294967295\", 32, Up, \"4294967296\", Greater);\n    test(\"4294967295\", 32, Floor, \"0\", Less);\n    test(\"4294967295\", 32, Ceiling, \"4294967296\", Greater);\n    test(\"4294967295\", 32, Nearest, \"4294967296\", Greater);\n\n    test(\"4294967296\", 32, Down, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Up, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Floor, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Ceiling, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Nearest, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Exact, \"4294967296\", Equal);\n\n    test(\"4294967296\", 33, Down, \"0\", Less);\n    test(\"4294967296\", 33, Up, \"8589934592\", Greater);\n    test(\"4294967296\", 33, Floor, \"0\", Less);\n    test(\"4294967296\", 33, Ceiling, \"8589934592\", Greater);\n    test(\"4294967296\", 33, Nearest, \"0\", Less);\n\n    test(\"-123\", 0, Down, \"-123\", Equal);\n    test(\"-123\", 0, Up, \"-123\", Equal);\n    test(\"-123\", 0, Floor, \"-123\", Equal);\n    test(\"-123\", 0, Ceiling, \"-123\", Equal);\n    test(\"-123\", 0, Nearest, \"-123\", Equal);\n    test(\"-123\", 0, Exact, \"-123\", Equal);\n\n    test(\"-245\", 1, Down, \"-244\", Greater);\n    test(\"-245\", 1, Up, \"-246\", Less);\n    test(\"-245\", 1, Floor, \"-246\", Less);\n    test(\"-245\", 1, Ceiling, \"-244\", Greater);\n    test(\"-245\", 1, Nearest, \"-244\", Greater);\n\n    test(\"-246\", 1, Down, \"-246\", Equal);\n    test(\"-246\", 1, Up, \"-246\", Equal);\n    test(\"-246\", 1, Floor, \"-246\", Equal);\n    test(\"-246\", 1, Ceiling, \"-246\", Equal);\n    test(\"-246\", 1, Nearest, \"-246\", Equal);\n    test(\"-246\", 1, Exact, \"-246\", Equal);\n\n    test(\"-247\", 1, Down, \"-246\", Greater);\n    test(\"-247\", 1, Up, \"-248\", Less);\n    test(\"-247\", 1, Floor, \"-248\", Less);\n    test(\"-247\", 1, Ceiling, \"-246\", Greater);\n    test(\"-247\", 1, Nearest, \"-248\", Less);\n\n    test(\"-491\", 2, Down, \"-488\", Greater);\n    test(\"-491\", 2, Up, \"-492\", Less);\n    test(\"-491\", 2, Floor, \"-492\", Less);\n    test(\"-491\", 2, Ceiling, \"-488\", Greater);\n    test(\"-491\", 2, Nearest, \"-492\", Less);\n\n    test(\"-492\", 2, Down, \"-492\", Equal);\n    test(\"-492\", 2, Up, \"-492\", Equal);\n    test(\"-492\", 2, Floor, \"-492\", Equal);\n    test(\"-492\", 2, Ceiling, \"-492\", Equal);\n    test(\"-492\", 2, Nearest, \"-492\", Equal);\n    test(\"-492\", 2, Exact, \"-492\", Equal);\n\n    test(\"-493\", 2, Down, \"-492\", Greater);\n    test(\"-493\", 2, Up, \"-496\", Less);\n    test(\"-493\", 2, Floor, \"-496\", Less);\n    test(\"-493\", 2, Ceiling, \"-492\", Greater);\n    test(\"-493\", 2, Nearest, \"-492\", Greater);\n\n    test(\"-4127195135\", 25, Down, \"-4093640704\", Greater);\n    test(\"-4127195135\", 25, Up, \"-4127195136\", Less);\n    test(\"-4127195135\", 25, Floor, \"-4127195136\", Less);\n    test(\"-4127195135\", 25, Ceiling, \"-4093640704\", Greater);\n    test(\"-4127195135\", 25, Nearest, \"-4127195136\", Less);\n\n    test(\"-4127195136\", 25, Down, \"-4127195136\", Equal);\n    test(\"-4127195136\", 25, Up, \"-4127195136\", Equal);\n    test(\"-4127195136\", 25, Floor, \"-4127195136\", Equal);\n    test(\"-4127195136\", 25, Ceiling, \"-4127195136\", Equal);\n    test(\"-4127195136\", 25, Nearest, \"-4127195136\", Equal);\n    test(\"-4127195136\", 25, Exact, \"-4127195136\", Equal);\n\n    test(\"-4127195137\", 25, Down, \"-4127195136\", Greater);\n    test(\"-4127195137\", 25, Up, \"-4160749568\", Less);\n    test(\"-4127195137\", 25, Floor, \"-4160749568\", Less);\n    test(\"-4127195137\", 25, Ceiling, \"-4127195136\", Greater);\n    test(\"-4127195137\", 25, Nearest, \"-4127195136\", Greater);\n\n    test(\"-8254390271\", 26, Down, \"-8187281408\", Greater);\n    test(\"-8254390271\", 26, Up, \"-8254390272\", Less);\n    test(\"-8254390271\", 26, Floor, \"-8254390272\", Less);\n    test(\"-8254390271\", 26, Ceiling, \"-8187281408\", Greater);\n    test(\"-8254390271\", 26, Nearest, \"-8254390272\", Less);\n\n    test(\"-8254390272\", 26, Down, \"-8254390272\", Equal);\n    test(\"-8254390272\", 26, Up, \"-8254390272\", Equal);\n    test(\"-8254390272\", 26, Floor, \"-8254390272\", Equal);\n    test(\"-8254390272\", 26, Ceiling, \"-8254390272\", Equal);\n    test(\"-8254390272\", 26, Nearest, \"-8254390272\", Equal);\n    test(\"-8254390272\", 26, Exact, \"-8254390272\", Equal);\n\n    test(\"-8254390273\", 26, Down, \"-8254390272\", Greater);\n    test(\"-8254390273\", 26, Up, \"-8321499136\", Less);\n    test(\"-8254390273\", 26, Floor, \"-8321499136\", Less);\n    test(\"-8254390273\", 26, Ceiling, \"-8254390272\", Greater);\n    test(\"-8254390273\", 26, Nearest, \"-8254390272\", Greater);\n\n    test(\n        \"-155921023828072216384094494261247\",\n        100,\n        Down,\n        \"-154653373227843986982597791055872\",\n        Greater,\n    );\n    test(\n        \"-155921023828072216384094494261247\",\n        100,\n        Up,\n        \"-155921023828072216384094494261248\",\n        Less,\n    );\n    test(\n        \"-155921023828072216384094494261247\",\n        100,\n        Floor,\n        \"-155921023828072216384094494261248\",\n        Less,\n    );\n    test(\n        \"-155921023828072216384094494261247\",\n        100,\n        Ceiling,\n        \"-154653373227843986982597791055872\",\n        Greater,\n    );\n    test(\n        \"-155921023828072216384094494261247\",\n        100,\n        Nearest,\n        \"-155921023828072216384094494261248\",\n        Less,\n    );\n\n    test(\n        \"-155921023828072216384094494261248\",\n        100,\n        Down,\n        \"-155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"-155921023828072216384094494261248\",\n        100,\n        Up,\n        \"-155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"-155921023828072216384094494261248\",\n        100,\n        Floor,\n        \"-155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"-155921023828072216384094494261248\",\n        100,\n        Ceiling,\n        \"-155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"-155921023828072216384094494261248\",\n        100,\n        Nearest,\n        \"-155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"-155921023828072216384094494261248\",\n        100,\n        Exact,\n        \"-155921023828072216384094494261248\",\n        Equal,\n    );\n\n    test(\n        \"-155921023828072216384094494261249\",\n        100,\n        Down,\n        \"-155921023828072216384094494261248\",\n        Greater,\n    );\n    test(\n        \"-155921023828072216384094494261249\",\n        100,\n        Up,\n        \"-157188674428300445785591197466624\",\n        Less,\n    );\n    test(\n        \"-155921023828072216384094494261249\",\n        100,\n        Floor,\n        \"-157188674428300445785591197466624\",\n        Less,\n    );\n    test(\n        \"-155921023828072216384094494261249\",\n        100,\n        Ceiling,\n        \"-155921023828072216384094494261248\",\n        Greater,\n    );\n    test(\n        \"-155921023828072216384094494261249\",\n        100,\n        Nearest,\n        \"-155921023828072216384094494261248\",\n        Greater,\n    );\n\n    test(\"-4294967295\", 1, Down, \"-4294967294\", Greater);\n    test(\"-4294967295\", 1, Up, \"-4294967296\", Less);\n    test(\"-4294967295\", 1, Floor, \"-4294967296\", Less);\n    test(\"-4294967295\", 1, Ceiling, \"-4294967294\", Greater);\n    test(\"-4294967295\", 1, Nearest, \"-4294967296\", Less);\n\n    test(\"-4294967296\", 1, Down, \"-4294967296\", Equal);\n    test(\"-4294967296\", 1, Up, \"-4294967296\", Equal);\n    test(\"-4294967296\", 1, Floor, \"-4294967296\", Equal);\n    test(\"-4294967296\", 1, Ceiling, \"-4294967296\", Equal);\n    test(\"-4294967296\", 1, Nearest, \"-4294967296\", Equal);\n    test(\"-4294967296\", 1, Exact, \"-4294967296\", Equal);\n\n    test(\"-4294967297\", 1, Down, \"-4294967296\", Greater);\n    test(\"-4294967297\", 1, Up, \"-4294967298\", Less);\n    test(\"-4294967297\", 1, Floor, \"-4294967298\", Less);\n    test(\"-4294967297\", 1, Ceiling, \"-4294967296\", Greater);\n    test(\"-4294967297\", 1, Nearest, \"-4294967296\", Greater);\n\n    test(\"-1000000000000\", 0, Down, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 0, Up, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 0, Floor, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 0, Ceiling, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 0, Nearest, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 0, Exact, \"-1000000000000\", Equal);\n\n    test(\"-7999999999999\", 3, Down, \"-7999999999992\", Greater);\n    test(\"-7999999999999\", 3, Up, \"-8000000000000\", Less);\n    test(\"-7999999999999\", 3, Floor, \"-8000000000000\", Less);\n    test(\"-7999999999999\", 3, Ceiling, \"-7999999999992\", Greater);\n    test(\"-7999999999999\", 3, Nearest, \"-8000000000000\", Less);\n\n    test(\"-8000000000000\", 3, Down, \"-8000000000000\", Equal);\n    test(\"-8000000000000\", 3, Up, \"-8000000000000\", Equal);\n    test(\"-8000000000000\", 3, Floor, \"-8000000000000\", Equal);\n    test(\"-8000000000000\", 3, Ceiling, \"-8000000000000\", Equal);\n    test(\"-8000000000000\", 3, Nearest, \"-8000000000000\", Equal);\n    test(\"-8000000000000\", 3, Exact, \"-8000000000000\", Equal);\n\n    test(\"-8000000000001\", 3, Down, \"-8000000000000\", Greater);\n    test(\"-8000000000001\", 3, Up, \"-8000000000008\", Less);\n    test(\"-8000000000001\", 3, Floor, \"-8000000000008\", Less);\n    test(\"-8000000000001\", 3, Ceiling, \"-8000000000000\", Greater);\n    test(\"-8000000000001\", 3, Nearest, \"-8000000000000\", Greater);\n\n    test(\n        \"-16777216000000000000\",\n        24,\n        Down,\n        \"-16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"-16777216000000000000\",\n        24,\n        Up,\n        \"-16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"-16777216000000000000\",\n        24,\n        Floor,\n        \"-16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"-16777216000000000000\",\n        24,\n        Ceiling,\n        \"-16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"-16777216000000000000\",\n        24,\n        Nearest,\n        \"-16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"-16777216000000000000\",\n        24,\n        Exact,\n        \"-16777216000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-33554432000000000000\",\n        25,\n        Down,\n        \"-33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"-33554432000000000000\",\n        25,\n        Up,\n        \"-33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"-33554432000000000000\",\n        25,\n        Floor,\n        \"-33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"-33554432000000000000\",\n        25,\n        Ceiling,\n        \"-33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"-33554432000000000000\",\n        25,\n        Nearest,\n        \"-33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"-33554432000000000000\",\n        25,\n        Exact,\n        \"-33554432000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-2147483648000000000000\",\n        31,\n        Down,\n        \"-2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"-2147483648000000000000\",\n        31,\n        Up,\n        \"-2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"-2147483648000000000000\",\n        31,\n        Floor,\n        \"-2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"-2147483648000000000000\",\n        31,\n        Ceiling,\n        \"-2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"-2147483648000000000000\",\n        31,\n        Nearest,\n        \"-2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"-2147483648000000000000\",\n        31,\n        Exact,\n        \"-2147483648000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-4294967296000000000000\",\n        32,\n        Down,\n        \"-4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"-4294967296000000000000\",\n        32,\n        Up,\n        \"-4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"-4294967296000000000000\",\n        32,\n        Floor,\n        \"-4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"-4294967296000000000000\",\n        32,\n        Ceiling,\n        \"-4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"-4294967296000000000000\",\n        32,\n        Nearest,\n        \"-4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"-4294967296000000000000\",\n        32,\n        Exact,\n        \"-4294967296000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-8589934592000000000000\",\n        33,\n        Down,\n        \"-8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"-8589934592000000000000\",\n        33,\n        Up,\n        \"-8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"-8589934592000000000000\",\n        33,\n        Floor,\n        \"-8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"-8589934592000000000000\",\n        33,\n        Ceiling,\n        \"-8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"-8589934592000000000000\",\n        33,\n        Nearest,\n        \"-8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"-8589934592000000000000\",\n        33,\n        Exact,\n        \"-8589934592000000000000\",\n        Equal,\n    );\n\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        Down,\n        \"-1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        Up,\n        \"-1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        Floor,\n        \"-1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        Ceiling,\n        \"-1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        Nearest,\n        \"-1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        Exact,\n        \"-1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n\n    test(\"-1000000000000\", 10, Down, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 10, Up, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 10, Floor, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 10, Ceiling, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 10, Nearest, \"-1000000000000\", Equal);\n    test(\"-1000000000000\", 10, Exact, \"-1000000000000\", Equal);\n\n    test(\"-980657949\", 72, Down, \"0\", Greater);\n    test(\"-980657949\", 72, Up, \"-4722366482869645213696\", Less);\n    test(\"-980657949\", 72, Floor, \"-4722366482869645213696\", Less);\n    test(\"-980657949\", 72, Ceiling, \"0\", Greater);\n    test(\"-980657949\", 72, Nearest, \"0\", Greater);\n\n    test(\"-4294967295\", 31, Down, \"-2147483648\", Greater);\n    test(\"-4294967295\", 31, Up, \"-4294967296\", Less);\n    test(\"-4294967295\", 31, Floor, \"-4294967296\", Less);\n    test(\"-4294967295\", 31, Ceiling, \"-2147483648\", Greater);\n    test(\"-4294967295\", 31, Nearest, \"-4294967296\", Less);\n\n    test(\"-4294967295\", 32, Down, \"0\", Greater);\n    test(\"-4294967295\", 32, Up, \"-4294967296\", Less);\n    test(\"-4294967295\", 32, Floor, \"-4294967296\", Less);\n    test(\"-4294967295\", 32, Ceiling, \"0\", Greater);\n    test(\"-4294967295\", 32, Nearest, \"-4294967296\", Less);\n\n    test(\"-4294967296\", 32, Down, \"-4294967296\", Equal);\n    test(\"-4294967296\", 32, Up, \"-4294967296\", Equal);\n    test(\"-4294967296\", 32, Floor, \"-4294967296\", Equal);\n    test(\"-4294967296\", 32, Ceiling, \"-4294967296\", Equal);\n    test(\"-4294967296\", 32, Nearest, \"-4294967296\", Equal);\n    test(\"-4294967296\", 32, Exact, \"-4294967296\", Equal);\n\n    test(\"-4294967296\", 33, Down, \"0\", Greater);\n    test(\"-4294967296\", 33, Up, \"-8589934592\", Less);\n    test(\"-4294967296\", 33, Floor, \"-8589934592\", Less);\n    test(\"-4294967296\", 33, Ceiling, \"0\", Greater);\n    test(\"-4294967296\", 33, Nearest, \"0\", Greater);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_1() {\n    Integer::from(-123).round_to_multiple_of_power_of_2_assign(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_2() {\n    Integer::from(-123).round_to_multiple_of_power_of_2_assign(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_3() {\n    Integer::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2_assign(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_4() {\n    Integer::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2_assign(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_1() {\n    Integer::from(-123).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_2() {\n    Integer::from(-123).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_3() {\n    Integer::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_4() {\n    Integer::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_1() {\n    (&Integer::from(-123)).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_2() {\n    (&Integer::from(-123)).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_3() {\n    (&Integer::from_str(\"-1000000000001\").unwrap()).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_4() {\n    (&Integer::from_str(\"-1000000000001\").unwrap()).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\nfn round_to_multiple_of_power_of_2_properties() {\n    integer_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, pow, rm)| {\n        let (r, o) = (&n).round_to_multiple_of_power_of_2(pow, rm);\n        assert!(r.is_valid());\n\n        let (r_alt, o_alt) = n.clone().round_to_multiple_of_power_of_2(pow, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let mut mut_n = n.clone();\n        assert_eq!(mut_n.round_to_multiple_of_power_of_2_assign(pow, rm), o);\n        assert!(mut_n.is_valid());\n        assert_eq!(mut_n, r);\n\n        assert!(r.divisible_by_power_of_2(pow));\n        assert_eq!(r.cmp(&n), o);\n        match (n >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        let (r_alt, o_alt) = (&n).shr_round(pow, rm);\n        assert_eq!(r_alt << pow, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = (-&n).round_to_multiple_of_power_of_2(pow, -rm);\n        assert_eq!(-r_alt, r);\n        assert_eq!(o_alt.reverse(), o);\n\n        assert!((&r - &n).abs() <= Integer::power_of_2(pow));\n\n        let (r_alt, o_alt) = (&n).round_to_multiple(Integer::power_of_2(pow), rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n        match rm {\n            Floor => assert!(r <= n),\n            Ceiling => assert!(r >= n),\n            Down => assert!(r.le_abs(&n)),\n            Up => assert!(r.ge_abs(&n)),\n            Exact => assert_eq!(r, n),\n            Nearest => {\n                let k = Integer::power_of_2(pow);\n                let closest;\n                let second_closest;\n                if r <= n {\n                    closest = &n - &r;\n                    second_closest = &r + k - n;\n                } else {\n                    closest = &r - &n;\n                    second_closest = n + k - &r;\n                }\n                assert!(closest <= second_closest);\n                if closest == second_closest {\n                    assert!(!r.get_bit(pow));\n                }\n            }\n        }\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, pow)| {\n        let shifted: Integer = n << pow;\n        let so = (shifted.clone(), Equal);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Down), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Up), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Floor), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Ceiling), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Nearest), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Exact), so);\n    });\n\n    integer_unsigned_pair_gen_var_5().test_properties(|(n, pow)| {\n        let floor = (&n).round_to_multiple_of_power_of_2(pow, Floor);\n        assert_eq!(floor.1, Less);\n        let ceiling = (&floor.0 + Integer::power_of_2(pow), Greater);\n        assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Ceiling), ceiling);\n        if n >= 0 {\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Up), ceiling);\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Down), floor);\n        } else {\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Up), floor);\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Down), ceiling);\n        }\n        let nearest = n.round_to_multiple_of_power_of_2(pow, Nearest);\n        assert!(nearest == ceiling || nearest == floor);\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).round_to_multiple_of_power_of_2(0, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen().test_properties(|(pow, rm)| {\n        assert_eq!(\n            Integer::ZERO.round_to_multiple_of_power_of_2(pow, rm),\n            (Integer::ZERO, Equal)\n        );\n    });\n\n    natural_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, pow, rm)| {\n        let (r, o) = Integer::from(&n).round_to_multiple_of_power_of_2(pow, rm);\n        let (r_alt, o_alt) = (&n).round_to_multiple_of_power_of_2(pow, rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n    });\n\n    signed_unsigned_rounding_mode_triple_gen_var_1::<SignedLimb>().test_properties(\n        |(n, pow, rm)| {\n            let (r, o) = Integer::from(n).round_to_multiple_of_power_of_2(pow, rm);\n            let (r_alt, o_alt) = n.round_to_multiple_of_power_of_2(pow, rm);\n            assert_eq!(r_alt, r);\n            assert_eq!(o_alt, o);\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, PowerOf2, ShlRound, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen_var_5};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_signed_pair_gen_var_1, integer_unsigned_pair_gen_var_2,\n    natural_signed_pair_gen_var_2, natural_unsigned_pair_gen_var_4,\n};\nuse num::BigInt;\nuse rug;\nuse std::ops::{Shl, ShlAssign, Shr};\nuse std::str::FromStr;\n\nfn test_shl_unsigned_helper<T: PrimitiveUnsigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Integer: Shl<T, Output = Integer> + ShlAssign<T>,\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n{\n    let test = |s, v: u8, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n\n    test(\"123\", 0, \"123\");\n    test(\"123\", 1, \"246\");\n    test(\"123\", 2, \"492\");\n    test(\"123\", 25, \"4127195136\");\n    test(\"123\", 26, \"8254390272\");\n    test(\"123\", 100, \"155921023828072216384094494261248\");\n    test(\"2147483648\", 1, \"4294967296\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"1000000000000\", 3, \"8000000000000\");\n    test(\"1000000000000\", 24, \"16777216000000000000\");\n    test(\"1000000000000\", 25, \"33554432000000000000\");\n    test(\"1000000000000\", 31, \"2147483648000000000000\");\n    test(\"1000000000000\", 32, \"4294967296000000000000\");\n    test(\"1000000000000\", 33, \"8589934592000000000000\");\n    test(\n        \"1000000000000\",\n        100,\n        \"1267650600228229401496703205376000000000000\",\n    );\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-123\", 1, \"-246\");\n    test(\"-123\", 2, \"-492\");\n    test(\"-123\", 25, \"-4127195136\");\n    test(\"-123\", 26, \"-8254390272\");\n    test(\"-123\", 100, \"-155921023828072216384094494261248\");\n    test(\"-2147483648\", 1, \"-4294967296\");\n    test(\"-1000000000000\", 0, \"-1000000000000\");\n    test(\"-1000000000000\", 3, \"-8000000000000\");\n    test(\"-1000000000000\", 24, \"-16777216000000000000\");\n    test(\"-1000000000000\", 25, \"-33554432000000000000\");\n    test(\"-1000000000000\", 31, \"-2147483648000000000000\");\n    test(\"-1000000000000\", 32, \"-4294967296000000000000\");\n    test(\"-1000000000000\", 33, \"-8589934592000000000000\");\n    test(\n        \"-1000000000000\",\n        100,\n        \"-1267650600228229401496703205376000000000000\",\n    );\n}\n\n#[test]\nfn test_shl_unsigned() {\n    test_shl_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u32, _>(|u, v, out| {\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(u).unwrap() << v;\n        assert_eq!(n.to_string(), out);\n\n        let n = BigInt::from_str(u).unwrap() << usize::exact_from(v);\n        assert_eq!(n.to_string(), out);\n\n        let n = &BigInt::from_str(u).unwrap() << usize::exact_from(v);\n        assert_eq!(n.to_string(), out);\n    });\n    test_shl_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shl_signed_helper<T: PrimitiveSigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Integer: Shl<T, Output = Integer> + ShlAssign<T>,\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n{\n    let test = |s, v: i8, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"123\", 1, \"246\");\n    test(\"123\", 2, \"492\");\n    test(\"123\", 25, \"4127195136\");\n    test(\"123\", 26, \"8254390272\");\n    test(\"123\", 100, \"155921023828072216384094494261248\");\n    test(\"2147483648\", 1, \"4294967296\");\n    test(\"1000000000000\", 3, \"8000000000000\");\n    test(\"1000000000000\", 24, \"16777216000000000000\");\n    test(\"1000000000000\", 25, \"33554432000000000000\");\n    test(\"1000000000000\", 31, \"2147483648000000000000\");\n    test(\"1000000000000\", 32, \"4294967296000000000000\");\n    test(\"1000000000000\", 33, \"8589934592000000000000\");\n    test(\n        \"1000000000000\",\n        100,\n        \"1267650600228229401496703205376000000000000\",\n    );\n\n    test(\"-123\", 1, \"-246\");\n    test(\"-123\", 2, \"-492\");\n    test(\"-123\", 25, \"-4127195136\");\n    test(\"-123\", 26, \"-8254390272\");\n    test(\"-123\", 100, \"-155921023828072216384094494261248\");\n    test(\"-2147483648\", 1, \"-4294967296\");\n    test(\"-1000000000000\", 3, \"-8000000000000\");\n    test(\"-1000000000000\", 24, \"-16777216000000000000\");\n    test(\"-1000000000000\", 25, \"-33554432000000000000\");\n    test(\"-1000000000000\", 31, \"-2147483648000000000000\");\n    test(\"-1000000000000\", 32, \"-4294967296000000000000\");\n    test(\"-1000000000000\", 33, \"-8589934592000000000000\");\n    test(\n        \"-1000000000000\",\n        100,\n        \"-1267650600228229401496703205376000000000000\",\n    );\n\n    test(\"123\", 0, \"123\");\n    test(\"245\", -1, \"122\");\n    test(\"246\", -1, \"123\");\n    test(\"247\", -1, \"123\");\n    test(\"491\", -2, \"122\");\n    test(\"492\", -2, \"123\");\n    test(\"493\", -2, \"123\");\n    test(\"4127195135\", -25, \"122\");\n    test(\"4127195136\", -25, \"123\");\n    test(\"4127195137\", -25, \"123\");\n    test(\"8254390271\", -26, \"122\");\n    test(\"8254390272\", -26, \"123\");\n    test(\"8254390273\", -26, \"123\");\n    test(\"155921023828072216384094494261247\", -100, \"122\");\n    test(\"155921023828072216384094494261248\", -100, \"123\");\n    test(\"155921023828072216384094494261249\", -100, \"123\");\n    test(\"4294967295\", -1, \"2147483647\");\n    test(\"4294967296\", -1, \"2147483648\");\n    test(\"4294967297\", -1, \"2147483648\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"7999999999999\", -3, \"999999999999\");\n    test(\"8000000000000\", -3, \"1000000000000\");\n    test(\"8000000000001\", -3, \"1000000000000\");\n    test(\"16777216000000000000\", -24, \"1000000000000\");\n    test(\"33554432000000000000\", -25, \"1000000000000\");\n    test(\"2147483648000000000000\", -31, \"1000000000000\");\n    test(\"4294967296000000000000\", -32, \"1000000000000\");\n    test(\"8589934592000000000000\", -33, \"1000000000000\");\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        -100,\n        \"1000000000000\",\n    );\n    test(\"1000000000000\", -10, \"976562500\");\n    test(\"980657949\", -72, \"0\");\n    test(\"4294967295\", -31, \"1\");\n    test(\"4294967295\", -32, \"0\");\n    test(\"4294967296\", -32, \"1\");\n    test(\"4294967296\", -33, \"0\");\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-245\", -1, \"-123\");\n    test(\"-246\", -1, \"-123\");\n    test(\"-247\", -1, \"-124\");\n    test(\"-491\", -2, \"-123\");\n    test(\"-492\", -2, \"-123\");\n    test(\"-493\", -2, \"-124\");\n    test(\"-4127195135\", -25, \"-123\");\n    test(\"-4127195136\", -25, \"-123\");\n    test(\"-4127195137\", -25, \"-124\");\n    test(\"-8254390271\", -26, \"-123\");\n    test(\"-8254390272\", -26, \"-123\");\n    test(\"-8254390273\", -26, \"-124\");\n    test(\"-155921023828072216384094494261247\", -100, \"-123\");\n    test(\"-155921023828072216384094494261248\", -100, \"-123\");\n    test(\"-155921023828072216384094494261249\", -100, \"-124\");\n    test(\"-4294967295\", -1, \"-2147483648\");\n    test(\"-4294967296\", -1, \"-2147483648\");\n    test(\"-4294967297\", -1, \"-2147483649\");\n    test(\"-1000000000000\", 0, \"-1000000000000\");\n    test(\"-7999999999999\", -3, \"-1000000000000\");\n    test(\"-8000000000000\", -3, \"-1000000000000\");\n    test(\"-8000000000001\", -3, \"-1000000000001\");\n    test(\"-16777216000000000000\", -24, \"-1000000000000\");\n    test(\"-33554432000000000000\", -25, \"-1000000000000\");\n    test(\"-2147483648000000000000\", -31, \"-1000000000000\");\n    test(\"-4294967296000000000000\", -32, \"-1000000000000\");\n    test(\"-8589934592000000000000\", -33, \"-1000000000000\");\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        -100,\n        \"-1000000000000\",\n    );\n    test(\"-1000000000000\", -10, \"-976562500\");\n    test(\"-980657949\", -72, \"-1\");\n    test(\"-4294967295\", -31, \"-2\");\n    test(\"-4294967295\", -32, \"-1\");\n    test(\"-4294967296\", -32, \"-1\");\n    test(\"-4294967296\", -33, \"-1\");\n}\n\n#[test]\nfn test_shl_signed() {\n    test_shl_signed_helper::<i8, _>(|_, _, _| {});\n    test_shl_signed_helper::<i16, _>(|_, _, _| {});\n    test_shl_signed_helper::<i32, _>(|i, j, out| {\n        let mut n = rug::Integer::from_str(i).unwrap();\n        n <<= j;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(i).unwrap() << j;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shl_signed_helper::<i64, _>(|_, _, _| {});\n    test_shl_signed_helper::<i128, _>(|_, _, _| {});\n    test_shl_signed_helper::<isize, _>(|_, _, _| {});\n}\n\nfn shl_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    Integer: Shl<T, Output = Integer> + ShlAssign<T> + Shr<T, Output = Integer>,\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n    u64: TryFrom<T>,\n{\n    integer_unsigned_pair_gen_var_2::<T>().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n <<= u;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n << u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone() << u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert!((&n << u).ge_abs(&n));\n        assert_eq!(-&n << u, -(&n << u));\n\n        assert_eq!(&n << u, &n * Integer::power_of_2(u64::exact_from(u)));\n        assert_eq!(&n << u >> u, n);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(&n << T::ZERO, n);\n    });\n\n    unsigned_gen_var_5::<T>().test_properties(|u| {\n        assert_eq!(Integer::ZERO << u, 0);\n        assert!(Natural::exact_from(Integer::ONE << u).is_power_of_2());\n    });\n\n    natural_unsigned_pair_gen_var_4::<T>().test_properties(|(n, u)| {\n        assert_eq!(&n << u, Integer::from(n) << u);\n    });\n}\n\nfn shl_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    Integer: Shl<T, Output = Integer> + ShlAssign<T>,\n    for<'a> &'a Integer: Shl<T, Output = Integer>\n        + Shl<<T as UnsignedAbs>::Output, Output = Integer>\n        + ShlRound<T, Output = Integer>,\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    integer_signed_pair_gen_var_1::<T>().test_properties(|(n, i)| {\n        let mut mut_n = n.clone();\n        mut_n <<= i;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n << i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone() << i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!((&n).shl_round(i, Floor).0, shifted);\n\n        if i >= T::ZERO {\n            assert_eq!(&n << i.unsigned_abs(), shifted);\n        }\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(&n << T::ZERO, n);\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert_eq!(Integer::ZERO << i, 0);\n    });\n\n    natural_signed_pair_gen_var_2::<T>().test_properties(|(n, i)| {\n        assert_eq!(&n << i, Integer::from(n) << i);\n    });\n}\n\n#[test]\nfn shl_properties() {\n    apply_fn_to_unsigneds!(shl_properties_helper_unsigned);\n    apply_fn_to_signeds!(shl_properties_helper_signed);\n\n    integer_unsigned_pair_gen_var_2::<u32>().test_properties(|(n, u)| {\n        let shifted = &n << u;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n <<= u;\n        assert_eq!(Integer::from(&rug_n), shifted);\n        assert_eq!(\n            Integer::from(&(&BigInt::from(&n) << usize::exact_from(u))),\n            shifted\n        );\n        assert_eq!(\n            Integer::from(&(BigInt::from(&n) << usize::exact_from(u))),\n            shifted\n        );\n        assert_eq!(Integer::from(&(rug::Integer::from(&n) << u)), shifted);\n    });\n\n    integer_signed_pair_gen_var_1::<i32>().test_properties(|(n, i)| {\n        let shifted = &n << i;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n <<= i;\n        assert_eq!(Integer::from(&rug_n), shifted);\n        assert_eq!(Integer::from(&(rug::Integer::from(&n) << i)), shifted);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShl, DivisibleByPowerOf2, ShlRound, ShlRoundAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, signed_signed_rounding_mode_triple_gen_var_4,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_rounding_mode_pair_gen, integer_signed_rounding_mode_triple_gen_var_1,\n    natural_signed_rounding_mode_triple_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::ops::Shr;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nmacro_rules! test_shl_round_signed_helper {\n    ($t:ident) => {\n        let test = |i, j: $t, rm: RoundingMode, out, o| {\n            let u = Integer::from_str(i).unwrap();\n\n            let mut n = u.clone();\n            assert_eq!(n.shl_round_assign(j, rm), o);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n\n            let (n, o_alt) = u.clone().shl_round(j, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n\n            let (n, o_alt) = (&u).shl_round(j, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n        };\n        test(\"0\", 10, Exact, \"0\", Equal);\n        test(\"123\", 1, Exact, \"246\", Equal);\n        test(\"123\", 2, Exact, \"492\", Equal);\n        test(\"123\", 25, Exact, \"4127195136\", Equal);\n        test(\"123\", 26, Exact, \"8254390272\", Equal);\n        test(\n            \"123\",\n            100,\n            Exact,\n            \"155921023828072216384094494261248\",\n            Equal,\n        );\n        test(\"2147483648\", 1, Exact, \"4294967296\", Equal);\n        test(\"1000000000000\", 3, Exact, \"8000000000000\", Equal);\n        test(\"1000000000000\", 24, Exact, \"16777216000000000000\", Equal);\n        test(\"1000000000000\", 25, Exact, \"33554432000000000000\", Equal);\n        test(\"1000000000000\", 31, Exact, \"2147483648000000000000\", Equal);\n        test(\"1000000000000\", 32, Exact, \"4294967296000000000000\", Equal);\n        test(\"1000000000000\", 33, Exact, \"8589934592000000000000\", Equal);\n        test(\n            \"1000000000000\",\n            100,\n            Exact,\n            \"1267650600228229401496703205376000000000000\",\n            Equal,\n        );\n\n        test(\"-123\", 1, Exact, \"-246\", Equal);\n        test(\"-123\", 2, Exact, \"-492\", Equal);\n        test(\"-123\", 25, Exact, \"-4127195136\", Equal);\n        test(\"-123\", 26, Exact, \"-8254390272\", Equal);\n        test(\n            \"-123\",\n            100,\n            Exact,\n            \"-155921023828072216384094494261248\",\n            Equal,\n        );\n        test(\"-2147483648\", 1, Exact, \"-4294967296\", Equal);\n        test(\"-1000000000000\", 3, Exact, \"-8000000000000\", Equal);\n        test(\"-1000000000000\", 24, Exact, \"-16777216000000000000\", Equal);\n        test(\"-1000000000000\", 25, Exact, \"-33554432000000000000\", Equal);\n        test(\n            \"-1000000000000\",\n            31,\n            Exact,\n            \"-2147483648000000000000\",\n            Equal,\n        );\n        test(\n            \"-1000000000000\",\n            32,\n            Exact,\n            \"-4294967296000000000000\",\n            Equal,\n        );\n        test(\n            \"-1000000000000\",\n            33,\n            Exact,\n            \"-8589934592000000000000\",\n            Equal,\n        );\n        test(\n            \"-1000000000000\",\n            100,\n            Exact,\n            \"-1267650600228229401496703205376000000000000\",\n            Equal,\n        );\n\n        test(\"0\", 0, Down, \"0\", Equal);\n        test(\"0\", 0, Up, \"0\", Equal);\n        test(\"0\", 0, Floor, \"0\", Equal);\n        test(\"0\", 0, Ceiling, \"0\", Equal);\n        test(\"0\", 0, Nearest, \"0\", Equal);\n        test(\"0\", 0, Exact, \"0\", Equal);\n\n        test(\"0\", -10, Down, \"0\", Equal);\n        test(\"0\", -10, Up, \"0\", Equal);\n        test(\"0\", -10, Floor, \"0\", Equal);\n        test(\"0\", -10, Ceiling, \"0\", Equal);\n        test(\"0\", -10, Nearest, \"0\", Equal);\n        test(\"0\", -10, Exact, \"0\", Equal);\n\n        test(\"123\", 0, Down, \"123\", Equal);\n        test(\"123\", 0, Up, \"123\", Equal);\n        test(\"123\", 0, Floor, \"123\", Equal);\n        test(\"123\", 0, Ceiling, \"123\", Equal);\n        test(\"123\", 0, Nearest, \"123\", Equal);\n        test(\"123\", 0, Exact, \"123\", Equal);\n\n        test(\"245\", -1, Down, \"122\", Less);\n        test(\"245\", -1, Up, \"123\", Greater);\n        test(\"245\", -1, Floor, \"122\", Less);\n        test(\"245\", -1, Ceiling, \"123\", Greater);\n        test(\"245\", -1, Nearest, \"122\", Less);\n\n        test(\"246\", -1, Down, \"123\", Equal);\n        test(\"246\", -1, Up, \"123\", Equal);\n        test(\"246\", -1, Floor, \"123\", Equal);\n        test(\"246\", -1, Ceiling, \"123\", Equal);\n        test(\"246\", -1, Nearest, \"123\", Equal);\n        test(\"246\", -1, Exact, \"123\", Equal);\n\n        test(\"247\", -1, Down, \"123\", Less);\n        test(\"247\", -1, Up, \"124\", Greater);\n        test(\"247\", -1, Floor, \"123\", Less);\n        test(\"247\", -1, Ceiling, \"124\", Greater);\n        test(\"247\", -1, Nearest, \"124\", Greater);\n\n        test(\"491\", -2, Down, \"122\", Less);\n        test(\"491\", -2, Up, \"123\", Greater);\n        test(\"491\", -2, Floor, \"122\", Less);\n        test(\"491\", -2, Ceiling, \"123\", Greater);\n        test(\"491\", -2, Nearest, \"123\", Greater);\n\n        test(\"492\", -2, Down, \"123\", Equal);\n        test(\"492\", -2, Up, \"123\", Equal);\n        test(\"492\", -2, Floor, \"123\", Equal);\n        test(\"492\", -2, Ceiling, \"123\", Equal);\n        test(\"492\", -2, Nearest, \"123\", Equal);\n        test(\"492\", -2, Exact, \"123\", Equal);\n\n        test(\"493\", -2, Down, \"123\", Less);\n        test(\"493\", -2, Up, \"124\", Greater);\n        test(\"493\", -2, Floor, \"123\", Less);\n        test(\"493\", -2, Ceiling, \"124\", Greater);\n        test(\"493\", -2, Nearest, \"123\", Less);\n\n        test(\"4127195135\", -25, Down, \"122\", Less);\n        test(\"4127195135\", -25, Up, \"123\", Greater);\n        test(\"4127195135\", -25, Floor, \"122\", Less);\n        test(\"4127195135\", -25, Ceiling, \"123\", Greater);\n        test(\"4127195135\", -25, Nearest, \"123\", Greater);\n\n        test(\"4127195136\", -25, Down, \"123\", Equal);\n        test(\"4127195136\", -25, Up, \"123\", Equal);\n        test(\"4127195136\", -25, Floor, \"123\", Equal);\n        test(\"4127195136\", -25, Ceiling, \"123\", Equal);\n        test(\"4127195136\", -25, Nearest, \"123\", Equal);\n        test(\"4127195136\", -25, Exact, \"123\", Equal);\n\n        test(\"4127195137\", -25, Down, \"123\", Less);\n        test(\"4127195137\", -25, Up, \"124\", Greater);\n        test(\"4127195137\", -25, Floor, \"123\", Less);\n        test(\"4127195137\", -25, Ceiling, \"124\", Greater);\n        test(\"4127195137\", -25, Nearest, \"123\", Less);\n\n        test(\"8254390271\", -26, Down, \"122\", Less);\n        test(\"8254390271\", -26, Up, \"123\", Greater);\n        test(\"8254390271\", -26, Floor, \"122\", Less);\n        test(\"8254390271\", -26, Ceiling, \"123\", Greater);\n        test(\"8254390271\", -26, Nearest, \"123\", Greater);\n\n        test(\"8254390272\", -26, Down, \"123\", Equal);\n        test(\"8254390272\", -26, Up, \"123\", Equal);\n        test(\"8254390272\", -26, Floor, \"123\", Equal);\n        test(\"8254390272\", -26, Ceiling, \"123\", Equal);\n        test(\"8254390272\", -26, Nearest, \"123\", Equal);\n        test(\"8254390272\", -26, Exact, \"123\", Equal);\n\n        test(\"8254390273\", -26, Down, \"123\", Less);\n        test(\"8254390273\", -26, Up, \"124\", Greater);\n        test(\"8254390273\", -26, Floor, \"123\", Less);\n        test(\"8254390273\", -26, Ceiling, \"124\", Greater);\n        test(\"8254390273\", -26, Nearest, \"123\", Less);\n\n        test(\"155921023828072216384094494261247\", -100, Down, \"122\", Less);\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Up,\n            \"123\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Floor,\n            \"122\",\n            Less,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Ceiling,\n            \"123\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Nearest,\n            \"123\",\n            Greater,\n        );\n\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Down,\n            \"123\",\n            Equal,\n        );\n        test(\"155921023828072216384094494261248\", -100, Up, \"123\", Equal);\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Floor,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Ceiling,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Nearest,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Exact,\n            \"123\",\n            Equal,\n        );\n\n        test(\"155921023828072216384094494261249\", -100, Down, \"123\", Less);\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Up,\n            \"124\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Floor,\n            \"123\",\n            Less,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Ceiling,\n            \"124\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Nearest,\n            \"123\",\n            Less,\n        );\n\n        test(\"4294967295\", -1, Down, \"2147483647\", Less);\n        test(\"4294967295\", -1, Up, \"2147483648\", Greater);\n        test(\"4294967295\", -1, Floor, \"2147483647\", Less);\n        test(\"4294967295\", -1, Ceiling, \"2147483648\", Greater);\n        test(\"4294967295\", -1, Nearest, \"2147483648\", Greater);\n\n        test(\"4294967296\", -1, Down, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Up, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Floor, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Ceiling, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Nearest, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Exact, \"2147483648\", Equal);\n\n        test(\"4294967297\", -1, Down, \"2147483648\", Less);\n        test(\"4294967297\", -1, Up, \"2147483649\", Greater);\n        test(\"4294967297\", -1, Floor, \"2147483648\", Less);\n        test(\"4294967297\", -1, Ceiling, \"2147483649\", Greater);\n        test(\"4294967297\", -1, Nearest, \"2147483648\", Less);\n\n        test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n        test(\"7999999999999\", -3, Down, \"999999999999\", Less);\n        test(\"7999999999999\", -3, Up, \"1000000000000\", Greater);\n        test(\"7999999999999\", -3, Floor, \"999999999999\", Less);\n        test(\"7999999999999\", -3, Ceiling, \"1000000000000\", Greater);\n        test(\"7999999999999\", -3, Nearest, \"1000000000000\", Greater);\n\n        test(\"8000000000000\", -3, Down, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Up, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Floor, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Ceiling, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Nearest, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Exact, \"1000000000000\", Equal);\n\n        test(\"8000000000001\", -3, Down, \"1000000000000\", Less);\n        test(\"8000000000001\", -3, Up, \"1000000000001\", Greater);\n        test(\"8000000000001\", -3, Floor, \"1000000000000\", Less);\n        test(\"8000000000001\", -3, Ceiling, \"1000000000001\", Greater);\n        test(\"8000000000001\", -3, Nearest, \"1000000000000\", Less);\n\n        test(\"16777216000000000000\", -24, Down, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Up, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Floor, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Ceiling, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Nearest, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Exact, \"1000000000000\", Equal);\n\n        test(\"33554432000000000000\", -25, Down, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Up, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Floor, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Ceiling, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Nearest, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Exact, \"1000000000000\", Equal);\n\n        test(\"2147483648000000000000\", -31, Down, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", -31, Up, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", -31, Floor, \"1000000000000\", Equal);\n        test(\n            \"2147483648000000000000\",\n            -31,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"2147483648000000000000\",\n            -31,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"2147483648000000000000\", -31, Exact, \"1000000000000\", Equal);\n\n        test(\"4294967296000000000000\", -32, Down, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", -32, Up, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", -32, Floor, \"1000000000000\", Equal);\n        test(\n            \"4294967296000000000000\",\n            -32,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"4294967296000000000000\",\n            -32,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"4294967296000000000000\", -32, Exact, \"1000000000000\", Equal);\n\n        test(\"8589934592000000000000\", -33, Down, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", -33, Up, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", -33, Floor, \"1000000000000\", Equal);\n        test(\n            \"8589934592000000000000\",\n            -33,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"8589934592000000000000\",\n            -33,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"8589934592000000000000\", -33, Exact, \"1000000000000\", Equal);\n\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Down,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Up,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Floor,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Exact,\n            \"1000000000000\",\n            Equal,\n        );\n\n        test(\"1000000000000\", -10, Down, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Up, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Floor, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Ceiling, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Nearest, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Exact, \"976562500\", Equal);\n\n        test(\"980657949\", -72, Down, \"0\", Less);\n        test(\"980657949\", -72, Up, \"1\", Greater);\n        test(\"980657949\", -72, Floor, \"0\", Less);\n        test(\"980657949\", -72, Ceiling, \"1\", Greater);\n        test(\"980657949\", -72, Nearest, \"0\", Less);\n\n        test(\"4294967295\", -31, Down, \"1\", Less);\n        test(\"4294967295\", -31, Up, \"2\", Greater);\n        test(\"4294967295\", -31, Floor, \"1\", Less);\n        test(\"4294967295\", -31, Ceiling, \"2\", Greater);\n        test(\"4294967295\", -31, Nearest, \"2\", Greater);\n\n        test(\"4294967295\", -32, Down, \"0\", Less);\n        test(\"4294967295\", -32, Up, \"1\", Greater);\n        test(\"4294967295\", -32, Floor, \"0\", Less);\n        test(\"4294967295\", -32, Ceiling, \"1\", Greater);\n        test(\"4294967295\", -32, Nearest, \"1\", Greater);\n\n        test(\"4294967296\", -32, Down, \"1\", Equal);\n        test(\"4294967296\", -32, Up, \"1\", Equal);\n        test(\"4294967296\", -32, Floor, \"1\", Equal);\n        test(\"4294967296\", -32, Ceiling, \"1\", Equal);\n        test(\"4294967296\", -32, Nearest, \"1\", Equal);\n        test(\"4294967296\", -32, Exact, \"1\", Equal);\n\n        test(\"4294967296\", -33, Down, \"0\", Less);\n        test(\"4294967296\", -33, Up, \"1\", Greater);\n        test(\"4294967296\", -33, Floor, \"0\", Less);\n        test(\"4294967296\", -33, Ceiling, \"1\", Greater);\n        test(\"4294967296\", -33, Nearest, \"0\", Less);\n\n        test(\"-123\", 0, Down, \"-123\", Equal);\n        test(\"-123\", 0, Up, \"-123\", Equal);\n        test(\"-123\", 0, Floor, \"-123\", Equal);\n        test(\"-123\", 0, Ceiling, \"-123\", Equal);\n        test(\"-123\", 0, Nearest, \"-123\", Equal);\n        test(\"-123\", 0, Exact, \"-123\", Equal);\n\n        test(\"-245\", -1, Down, \"-122\", Greater);\n        test(\"-245\", -1, Up, \"-123\", Less);\n        test(\"-245\", -1, Floor, \"-123\", Less);\n        test(\"-245\", -1, Ceiling, \"-122\", Greater);\n        test(\"-245\", -1, Nearest, \"-122\", Greater);\n\n        test(\"-246\", -1, Down, \"-123\", Equal);\n        test(\"-246\", -1, Up, \"-123\", Equal);\n        test(\"-246\", -1, Floor, \"-123\", Equal);\n        test(\"-246\", -1, Ceiling, \"-123\", Equal);\n        test(\"-246\", -1, Nearest, \"-123\", Equal);\n        test(\"-246\", -1, Exact, \"-123\", Equal);\n\n        test(\"-247\", -1, Down, \"-123\", Greater);\n        test(\"-247\", -1, Up, \"-124\", Less);\n        test(\"-247\", -1, Floor, \"-124\", Less);\n        test(\"-247\", -1, Ceiling, \"-123\", Greater);\n        test(\"-247\", -1, Nearest, \"-124\", Less);\n\n        test(\"-491\", -2, Down, \"-122\", Greater);\n        test(\"-491\", -2, Up, \"-123\", Less);\n        test(\"-491\", -2, Floor, \"-123\", Less);\n        test(\"-491\", -2, Ceiling, \"-122\", Greater);\n        test(\"-491\", -2, Nearest, \"-123\", Less);\n\n        test(\"-492\", -2, Down, \"-123\", Equal);\n        test(\"-492\", -2, Up, \"-123\", Equal);\n        test(\"-492\", -2, Floor, \"-123\", Equal);\n        test(\"-492\", -2, Ceiling, \"-123\", Equal);\n        test(\"-492\", -2, Nearest, \"-123\", Equal);\n        test(\"-492\", -2, Exact, \"-123\", Equal);\n\n        test(\"-493\", -2, Down, \"-123\", Greater);\n        test(\"-493\", -2, Up, \"-124\", Less);\n        test(\"-493\", -2, Floor, \"-124\", Less);\n        test(\"-493\", -2, Ceiling, \"-123\", Greater);\n        test(\"-493\", -2, Nearest, \"-123\", Greater);\n\n        test(\"-4127195135\", -25, Down, \"-122\", Greater);\n        test(\"-4127195135\", -25, Up, \"-123\", Less);\n        test(\"-4127195135\", -25, Floor, \"-123\", Less);\n        test(\"-4127195135\", -25, Ceiling, \"-122\", Greater);\n        test(\"-4127195135\", -25, Nearest, \"-123\", Less);\n\n        test(\"-4127195136\", -25, Down, \"-123\", Equal);\n        test(\"-4127195136\", -25, Up, \"-123\", Equal);\n        test(\"-4127195136\", -25, Floor, \"-123\", Equal);\n        test(\"-4127195136\", -25, Ceiling, \"-123\", Equal);\n        test(\"-4127195136\", -25, Nearest, \"-123\", Equal);\n        test(\"-4127195136\", -25, Exact, \"-123\", Equal);\n\n        test(\"-4127195137\", -25, Down, \"-123\", Greater);\n        test(\"-4127195137\", -25, Up, \"-124\", Less);\n        test(\"-4127195137\", -25, Floor, \"-124\", Less);\n        test(\"-4127195137\", -25, Ceiling, \"-123\", Greater);\n        test(\"-4127195137\", -25, Nearest, \"-123\", Greater);\n\n        test(\"-8254390271\", -26, Down, \"-122\", Greater);\n        test(\"-8254390271\", -26, Up, \"-123\", Less);\n        test(\"-8254390271\", -26, Floor, \"-123\", Less);\n        test(\"-8254390271\", -26, Ceiling, \"-122\", Greater);\n        test(\"-8254390271\", -26, Nearest, \"-123\", Less);\n\n        test(\"-8254390272\", -26, Down, \"-123\", Equal);\n        test(\"-8254390272\", -26, Up, \"-123\", Equal);\n        test(\"-8254390272\", -26, Floor, \"-123\", Equal);\n        test(\"-8254390272\", -26, Ceiling, \"-123\", Equal);\n        test(\"-8254390272\", -26, Nearest, \"-123\", Equal);\n        test(\"-8254390272\", -26, Exact, \"-123\", Equal);\n\n        test(\"-8254390273\", -26, Down, \"-123\", Greater);\n        test(\"-8254390273\", -26, Up, \"-124\", Less);\n        test(\"-8254390273\", -26, Floor, \"-124\", Less);\n        test(\"-8254390273\", -26, Ceiling, \"-123\", Greater);\n        test(\"-8254390273\", -26, Nearest, \"-123\", Greater);\n\n        test(\n            \"-155921023828072216384094494261247\",\n            -100,\n            Down,\n            \"-122\",\n            Greater,\n        );\n        test(\"-155921023828072216384094494261247\", -100, Up, \"-123\", Less);\n        test(\n            \"-155921023828072216384094494261247\",\n            -100,\n            Floor,\n            \"-123\",\n            Less,\n        );\n        test(\n            \"-155921023828072216384094494261247\",\n            -100,\n            Ceiling,\n            \"-122\",\n            Greater,\n        );\n        test(\n            \"-155921023828072216384094494261247\",\n            -100,\n            Nearest,\n            \"-123\",\n            Less,\n        );\n\n        test(\n            \"-155921023828072216384094494261248\",\n            -100,\n            Down,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            -100,\n            Up,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            -100,\n            Floor,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            -100,\n            Ceiling,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            -100,\n            Nearest,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            -100,\n            Exact,\n            \"-123\",\n            Equal,\n        );\n\n        test(\n            \"-155921023828072216384094494261249\",\n            -100,\n            Down,\n            \"-123\",\n            Greater,\n        );\n        test(\"-155921023828072216384094494261249\", -100, Up, \"-124\", Less);\n        test(\n            \"-155921023828072216384094494261249\",\n            -100,\n            Floor,\n            \"-124\",\n            Less,\n        );\n        test(\n            \"-155921023828072216384094494261249\",\n            -100,\n            Ceiling,\n            \"-123\",\n            Greater,\n        );\n        test(\n            \"-155921023828072216384094494261249\",\n            -100,\n            Nearest,\n            \"-123\",\n            Greater,\n        );\n\n        test(\"-4294967295\", -1, Down, \"-2147483647\", Greater);\n        test(\"-4294967295\", -1, Up, \"-2147483648\", Less);\n        test(\"-4294967295\", -1, Floor, \"-2147483648\", Less);\n        test(\"-4294967295\", -1, Ceiling, \"-2147483647\", Greater);\n        test(\"-4294967295\", -1, Nearest, \"-2147483648\", Less);\n\n        test(\"-4294967296\", -1, Down, \"-2147483648\", Equal);\n        test(\"-4294967296\", -1, Up, \"-2147483648\", Equal);\n        test(\"-4294967296\", -1, Floor, \"-2147483648\", Equal);\n        test(\"-4294967296\", -1, Ceiling, \"-2147483648\", Equal);\n        test(\"-4294967296\", -1, Nearest, \"-2147483648\", Equal);\n        test(\"-4294967296\", -1, Exact, \"-2147483648\", Equal);\n\n        test(\"-4294967297\", -1, Down, \"-2147483648\", Greater);\n        test(\"-4294967297\", -1, Up, \"-2147483649\", Less);\n        test(\"-4294967297\", -1, Floor, \"-2147483649\", Less);\n        test(\"-4294967297\", -1, Ceiling, \"-2147483648\", Greater);\n        test(\"-4294967297\", -1, Nearest, \"-2147483648\", Greater);\n\n        test(\"-1000000000000\", 0, Down, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Up, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Floor, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Ceiling, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Nearest, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Exact, \"-1000000000000\", Equal);\n\n        test(\"-7999999999999\", -3, Down, \"-999999999999\", Greater);\n        test(\"-7999999999999\", -3, Up, \"-1000000000000\", Less);\n        test(\"-7999999999999\", -3, Floor, \"-1000000000000\", Less);\n        test(\"-7999999999999\", -3, Ceiling, \"-999999999999\", Greater);\n        test(\"-7999999999999\", -3, Nearest, \"-1000000000000\", Less);\n\n        test(\"-8000000000000\", -3, Down, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", -3, Up, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", -3, Floor, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", -3, Ceiling, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", -3, Nearest, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", -3, Exact, \"-1000000000000\", Equal);\n\n        test(\"-8000000000001\", -3, Down, \"-1000000000000\", Greater);\n        test(\"-8000000000001\", -3, Up, \"-1000000000001\", Less);\n        test(\"-8000000000001\", -3, Floor, \"-1000000000001\", Less);\n        test(\"-8000000000001\", -3, Ceiling, \"-1000000000000\", Greater);\n        test(\"-8000000000001\", -3, Nearest, \"-1000000000000\", Greater);\n\n        test(\"-16777216000000000000\", -24, Down, \"-1000000000000\", Equal);\n        test(\"-16777216000000000000\", -24, Up, \"-1000000000000\", Equal);\n        test(\"-16777216000000000000\", -24, Floor, \"-1000000000000\", Equal);\n        test(\n            \"-16777216000000000000\",\n            -24,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-16777216000000000000\",\n            -24,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-16777216000000000000\", -24, Exact, \"-1000000000000\", Equal);\n\n        test(\"-33554432000000000000\", -25, Down, \"-1000000000000\", Equal);\n        test(\"-33554432000000000000\", -25, Up, \"-1000000000000\", Equal);\n        test(\"-33554432000000000000\", -25, Floor, \"-1000000000000\", Equal);\n        test(\n            \"-33554432000000000000\",\n            -25,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-33554432000000000000\",\n            -25,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-33554432000000000000\", -25, Exact, \"-1000000000000\", Equal);\n\n        test(\n            \"-2147483648000000000000\",\n            -31,\n            Down,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-2147483648000000000000\", -31, Up, \"-1000000000000\", Equal);\n        test(\n            \"-2147483648000000000000\",\n            -31,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            -31,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            -31,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            -31,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\n            \"-4294967296000000000000\",\n            -32,\n            Down,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-4294967296000000000000\", -32, Up, \"-1000000000000\", Equal);\n        test(\n            \"-4294967296000000000000\",\n            -32,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            -32,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            -32,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            -32,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\n            \"-8589934592000000000000\",\n            -33,\n            Down,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-8589934592000000000000\", -33, Up, \"-1000000000000\", Equal);\n        test(\n            \"-8589934592000000000000\",\n            -33,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            -33,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            -33,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            -33,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            -100,\n            Down,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            -100,\n            Up,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            -100,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            -100,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            -100,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            -100,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\"-1000000000000\", -10, Down, \"-976562500\", Equal);\n        test(\"-1000000000000\", -10, Up, \"-976562500\", Equal);\n        test(\"-1000000000000\", -10, Floor, \"-976562500\", Equal);\n        test(\"-1000000000000\", -10, Ceiling, \"-976562500\", Equal);\n        test(\"-1000000000000\", -10, Nearest, \"-976562500\", Equal);\n        test(\"-1000000000000\", -10, Exact, \"-976562500\", Equal);\n\n        test(\"-980657949\", -72, Down, \"0\", Greater);\n        test(\"-980657949\", -72, Up, \"-1\", Less);\n        test(\"-980657949\", -72, Floor, \"-1\", Less);\n        test(\"-980657949\", -72, Ceiling, \"0\", Greater);\n        test(\"-980657949\", -72, Nearest, \"0\", Greater);\n\n        test(\"-4294967295\", -31, Down, \"-1\", Greater);\n        test(\"-4294967295\", -31, Up, \"-2\", Less);\n        test(\"-4294967295\", -31, Floor, \"-2\", Less);\n        test(\"-4294967295\", -31, Ceiling, \"-1\", Greater);\n        test(\"-4294967295\", -31, Nearest, \"-2\", Less);\n\n        test(\"-4294967295\", -32, Down, \"0\", Greater);\n        test(\"-4294967295\", -32, Up, \"-1\", Less);\n        test(\"-4294967295\", -32, Floor, \"-1\", Less);\n        test(\"-4294967295\", -32, Ceiling, \"0\", Greater);\n        test(\"-4294967295\", -32, Nearest, \"-1\", Less);\n\n        test(\"-4294967296\", -32, Down, \"-1\", Equal);\n        test(\"-4294967296\", -32, Up, \"-1\", Equal);\n        test(\"-4294967296\", -32, Floor, \"-1\", Equal);\n        test(\"-4294967296\", -32, Ceiling, \"-1\", Equal);\n        test(\"-4294967296\", -32, Nearest, \"-1\", Equal);\n        test(\"-4294967296\", -32, Exact, \"-1\", Equal);\n\n        test(\"-4294967296\", -33, Down, \"0\", Greater);\n        test(\"-4294967296\", -33, Up, \"-1\", Less);\n        test(\"-4294967296\", -33, Floor, \"-1\", Less);\n        test(\"-4294967296\", -33, Ceiling, \"0\", Greater);\n        test(\"-4294967296\", -33, Nearest, \"0\", Greater);\n    };\n}\n\n#[test]\nfn test_shl_round_signed() {\n    apply_to_signeds!(test_shl_round_signed_helper);\n}\n\nmacro_rules! shl_round_signed_fail_helper {\n    ($t:ident) => {\n        assert_panic!(Integer::from(-123).shl_round_assign($t::NEGATIVE_ONE, Exact));\n        assert_panic!(Integer::from(-123).shl_round_assign($t::exact_from(-100), Exact));\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shl_round_assign($t::NEGATIVE_ONE, Exact)\n        );\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shl_round_assign($t::exact_from(-100), Exact)\n        );\n        assert_panic!(Integer::from(-123).shl_round($t::NEGATIVE_ONE, Exact));\n        assert_panic!(Integer::from(-123).shl_round($t::exact_from(-100), Exact));\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shl_round($t::NEGATIVE_ONE, Exact)\n        );\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shl_round($t::exact_from(-100), Exact)\n        );\n        assert_panic!((&Integer::from(-123)).shl_round($t::NEGATIVE_ONE, Exact));\n        assert_panic!((&Integer::from(-123)).shl_round($t::exact_from(-100), Exact));\n        assert_panic!(\n            (&Integer::from_str(\"-1000000000001\").unwrap()).shl_round($t::NEGATIVE_ONE, Exact)\n        );\n        assert_panic!(\n            (&Integer::from_str(\"-1000000000001\").unwrap()).shl_round($t::exact_from(-100), Exact)\n        );\n    };\n}\n\n#[test]\nfn shl_round_signed_fail() {\n    apply_to_signeds!(shl_round_signed_fail_helper);\n}\n\nfn shl_round_properties_helper<T: PrimitiveSigned>()\nwhere\n    Integer: ShlRound<T, Output = Integer> + ShlRoundAssign<T> + Shr<T, Output = Integer>,\n    for<'a> &'a Integer: ShlRound<T, Output = Integer>,\n    Natural: Shr<T, Output = Natural>,\n    for<'a> &'a Natural: ShlRound<T, Output = Natural>,\n    SignedLimb: ArithmeticCheckedShl<T> + ShlRound<T, Output = SignedLimb>,\n    u64: TryFrom<<T as UnsignedAbs>::Output>,\n{\n    integer_signed_rounding_mode_triple_gen_var_1::<T>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n.clone();\n        let o = mut_n.shl_round_assign(i, rm);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let (shifted_alt, o_alt) = (&n).shl_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        let (shifted_alt, o_alt) = n.clone().shl_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        let (shifted_alt, o_alt) = (-&n).shl_round(i, -rm);\n        assert_eq!(-shifted_alt, shifted);\n        assert_eq!(o_alt, o.reverse());\n        assert_eq!(\n            i >= T::ZERO || n.divisible_by_power_of_2(u64::exact_from(i.unsigned_abs())),\n            o == Equal\n        );\n\n        match (n >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if i < T::ZERO {\n            assert_eq!((shifted >> i).cmp(&n), o);\n        }\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).shl_round(T::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(i, rm)| {\n        assert_eq!(Integer::ZERO.shl_round(i, rm), (Integer::ZERO, Equal));\n    });\n\n    natural_signed_rounding_mode_triple_gen_var_1::<T>().test_properties(|(n, i, rm)| {\n        let (s, o) = (&n).shl_round(i, rm);\n        assert_eq!((Integer::from(s), o), Integer::from(n).shl_round(i, rm));\n    });\n\n    signed_signed_rounding_mode_triple_gen_var_4::<SignedLimb, T>().test_properties(\n        |(n, i, rm)| {\n            if n.arithmetic_checked_shl(i).is_some() {\n                let (s, o) = n.shl_round(i, rm);\n                assert_eq!((Integer::from(s), o), Integer::from(n).shl_round(i, rm));\n            }\n        },\n    );\n}\n\n#[test]\nfn shl_round_properties() {\n    apply_fn_to_signeds!(shl_round_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ShrRound, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen_var_1, unsigned_gen,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_signed_pair_gen_var_1, integer_unsigned_pair_gen_var_2,\n    integer_unsigned_unsigned_triple_gen_var_3, natural_signed_pair_gen_var_2,\n    natural_unsigned_pair_gen_var_4,\n};\nuse num::BigInt;\nuse std::ops::{Shr, ShrAssign};\nuse std::str::FromStr;\n\nfn test_shr_unsigned_helper<T: PrimitiveUnsigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Integer: Shr<T, Output = Integer> + ShrAssign<T>,\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n{\n    let test = |s, v: u8, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n\n    test(\"123\", 0, \"123\");\n    test(\"245\", 1, \"122\");\n    test(\"246\", 1, \"123\");\n    test(\"247\", 1, \"123\");\n    test(\"491\", 2, \"122\");\n    test(\"492\", 2, \"123\");\n    test(\"493\", 2, \"123\");\n    test(\"4127195135\", 25, \"122\");\n    test(\"4127195136\", 25, \"123\");\n    test(\"4127195137\", 25, \"123\");\n    test(\"8254390271\", 26, \"122\");\n    test(\"8254390272\", 26, \"123\");\n    test(\"8254390273\", 26, \"123\");\n    test(\"155921023828072216384094494261247\", 100, \"122\");\n    test(\"155921023828072216384094494261248\", 100, \"123\");\n    test(\"155921023828072216384094494261249\", 100, \"123\");\n    test(\"4294967295\", 1, \"2147483647\");\n    test(\"4294967296\", 1, \"2147483648\");\n    test(\"4294967297\", 1, \"2147483648\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"7999999999999\", 3, \"999999999999\");\n    test(\"8000000000000\", 3, \"1000000000000\");\n    test(\"8000000000001\", 3, \"1000000000000\");\n    test(\"16777216000000000000\", 24, \"1000000000000\");\n    test(\"33554432000000000000\", 25, \"1000000000000\");\n    test(\"2147483648000000000000\", 31, \"1000000000000\");\n    test(\"4294967296000000000000\", 32, \"1000000000000\");\n    test(\"8589934592000000000000\", 33, \"1000000000000\");\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        \"1000000000000\",\n    );\n    test(\"1000000000000\", 10, \"976562500\");\n    test(\"980657949\", 72, \"0\");\n    test(\"4294967295\", 31, \"1\");\n    test(\"4294967295\", 32, \"0\");\n    test(\"4294967296\", 32, \"1\");\n    test(\"4294967296\", 33, \"0\");\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-245\", 1, \"-123\");\n    test(\"-246\", 1, \"-123\");\n    test(\"-247\", 1, \"-124\");\n    test(\"-491\", 2, \"-123\");\n    test(\"-492\", 2, \"-123\");\n    test(\"-493\", 2, \"-124\");\n    test(\"-4127195135\", 25, \"-123\");\n    test(\"-4127195136\", 25, \"-123\");\n    test(\"-4127195137\", 25, \"-124\");\n    test(\"-8254390271\", 26, \"-123\");\n    test(\"-8254390272\", 26, \"-123\");\n    test(\"-8254390273\", 26, \"-124\");\n    test(\"-155921023828072216384094494261247\", 100, \"-123\");\n    test(\"-155921023828072216384094494261248\", 100, \"-123\");\n    test(\"-155921023828072216384094494261249\", 100, \"-124\");\n    test(\"-4294967295\", 1, \"-2147483648\");\n    test(\"-4294967296\", 1, \"-2147483648\");\n    test(\"-4294967297\", 1, \"-2147483649\");\n    test(\"-1000000000000\", 0, \"-1000000000000\");\n    test(\"-7999999999999\", 3, \"-1000000000000\");\n    test(\"-8000000000000\", 3, \"-1000000000000\");\n    test(\"-8000000000001\", 3, \"-1000000000001\");\n    test(\"-16777216000000000000\", 24, \"-1000000000000\");\n    test(\"-33554432000000000000\", 25, \"-1000000000000\");\n    test(\"-2147483648000000000000\", 31, \"-1000000000000\");\n    test(\"-4294967296000000000000\", 32, \"-1000000000000\");\n    test(\"-8589934592000000000000\", 33, \"-1000000000000\");\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        \"-1000000000000\",\n    );\n    test(\"-1000000000000\", 10, \"-976562500\");\n    test(\"-980657949\", 72, \"-1\");\n    test(\"-4294967295\", 31, \"-2\");\n    test(\"-4294967295\", 32, \"-1\");\n    test(\"-4294967296\", 32, \"-1\");\n    test(\"-4294967296\", 33, \"-1\");\n}\n\n#[test]\nfn test_shr_unsigned() {\n    test_shr_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u32, _>(|u, v, out| {\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(u).unwrap() >> v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shr_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shr_signed_helper<T: PrimitiveSigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Integer: Shr<T, Output = Integer> + ShrAssign<T>,\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n{\n    let test = |s, v: i8, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n\n    test(\"123\", 0, \"123\");\n    test(\"245\", 1, \"122\");\n    test(\"246\", 1, \"123\");\n    test(\"247\", 1, \"123\");\n    test(\"491\", 2, \"122\");\n    test(\"492\", 2, \"123\");\n    test(\"493\", 2, \"123\");\n    test(\"4127195135\", 25, \"122\");\n    test(\"4127195136\", 25, \"123\");\n    test(\"4127195137\", 25, \"123\");\n    test(\"8254390271\", 26, \"122\");\n    test(\"8254390272\", 26, \"123\");\n    test(\"8254390273\", 26, \"123\");\n    test(\"155921023828072216384094494261247\", 100, \"122\");\n    test(\"155921023828072216384094494261248\", 100, \"123\");\n    test(\"155921023828072216384094494261249\", 100, \"123\");\n    test(\"4294967295\", 1, \"2147483647\");\n    test(\"4294967296\", 1, \"2147483648\");\n    test(\"4294967297\", 1, \"2147483648\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"7999999999999\", 3, \"999999999999\");\n    test(\"8000000000000\", 3, \"1000000000000\");\n    test(\"8000000000001\", 3, \"1000000000000\");\n    test(\"16777216000000000000\", 24, \"1000000000000\");\n    test(\"33554432000000000000\", 25, \"1000000000000\");\n    test(\"2147483648000000000000\", 31, \"1000000000000\");\n    test(\"4294967296000000000000\", 32, \"1000000000000\");\n    test(\"8589934592000000000000\", 33, \"1000000000000\");\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        \"1000000000000\",\n    );\n    test(\"1000000000000\", 10, \"976562500\");\n    test(\"980657949\", 72, \"0\");\n    test(\"4294967295\", 31, \"1\");\n    test(\"4294967295\", 32, \"0\");\n    test(\"4294967296\", 32, \"1\");\n    test(\"4294967296\", 33, \"0\");\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-245\", 1, \"-123\");\n    test(\"-246\", 1, \"-123\");\n    test(\"-247\", 1, \"-124\");\n    test(\"-491\", 2, \"-123\");\n    test(\"-492\", 2, \"-123\");\n    test(\"-493\", 2, \"-124\");\n    test(\"-4127195135\", 25, \"-123\");\n    test(\"-4127195136\", 25, \"-123\");\n    test(\"-4127195137\", 25, \"-124\");\n    test(\"-8254390271\", 26, \"-123\");\n    test(\"-8254390272\", 26, \"-123\");\n    test(\"-8254390273\", 26, \"-124\");\n    test(\"-155921023828072216384094494261247\", 100, \"-123\");\n    test(\"-155921023828072216384094494261248\", 100, \"-123\");\n    test(\"-155921023828072216384094494261249\", 100, \"-124\");\n    test(\"-4294967295\", 1, \"-2147483648\");\n    test(\"-4294967296\", 1, \"-2147483648\");\n    test(\"-4294967297\", 1, \"-2147483649\");\n    test(\"-1000000000000\", 0, \"-1000000000000\");\n    test(\"-7999999999999\", 3, \"-1000000000000\");\n    test(\"-8000000000000\", 3, \"-1000000000000\");\n    test(\"-8000000000001\", 3, \"-1000000000001\");\n    test(\"-16777216000000000000\", 24, \"-1000000000000\");\n    test(\"-33554432000000000000\", 25, \"-1000000000000\");\n    test(\"-2147483648000000000000\", 31, \"-1000000000000\");\n    test(\"-4294967296000000000000\", 32, \"-1000000000000\");\n    test(\"-8589934592000000000000\", 33, \"-1000000000000\");\n    test(\n        \"-1267650600228229401496703205376000000000000\",\n        100,\n        \"-1000000000000\",\n    );\n    test(\"-1000000000000\", 10, \"-976562500\");\n    test(\"-980657949\", 72, \"-1\");\n    test(\"-4294967295\", 31, \"-2\");\n    test(\"-4294967295\", 32, \"-1\");\n    test(\"-4294967296\", 32, \"-1\");\n    test(\"-4294967296\", 33, \"-1\");\n\n    test(\"0\", -10, \"0\");\n    test(\"123\", -1, \"246\");\n    test(\"123\", -2, \"492\");\n    test(\"123\", -25, \"4127195136\");\n    test(\"123\", -26, \"8254390272\");\n    test(\"123\", -100, \"155921023828072216384094494261248\");\n    test(\"2147483648\", -1, \"4294967296\");\n    test(\"1000000000000\", -3, \"8000000000000\");\n    test(\"1000000000000\", -24, \"16777216000000000000\");\n    test(\"1000000000000\", -25, \"33554432000000000000\");\n    test(\"1000000000000\", -31, \"2147483648000000000000\");\n    test(\"1000000000000\", -32, \"4294967296000000000000\");\n    test(\"1000000000000\", -33, \"8589934592000000000000\");\n    test(\n        \"1000000000000\",\n        -100,\n        \"1267650600228229401496703205376000000000000\",\n    );\n\n    test(\"-123\", -1, \"-246\");\n    test(\"-123\", -2, \"-492\");\n    test(\"-123\", -25, \"-4127195136\");\n    test(\"-123\", -26, \"-8254390272\");\n    test(\"-123\", -100, \"-155921023828072216384094494261248\");\n    test(\"-2147483648\", -1, \"-4294967296\");\n    test(\"-1000000000000\", -3, \"-8000000000000\");\n    test(\"-1000000000000\", -24, \"-16777216000000000000\");\n    test(\"-1000000000000\", -25, \"-33554432000000000000\");\n    test(\"-1000000000000\", -31, \"-2147483648000000000000\");\n    test(\"-1000000000000\", -32, \"-4294967296000000000000\");\n    test(\"-1000000000000\", -33, \"-8589934592000000000000\");\n    test(\n        \"-1000000000000\",\n        -100,\n        \"-1267650600228229401496703205376000000000000\",\n    );\n}\n\n#[test]\nfn test_shr_signed() {\n    test_shr_signed_helper::<i8, _>(|_, _, _| {});\n    test_shr_signed_helper::<i16, _>(|_, _, _| {});\n    test_shr_signed_helper::<i32, _>(|u, v, out| {\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(u).unwrap() >> v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shr_signed_helper::<i64, _>(|_, _, _| {});\n    test_shr_signed_helper::<i128, _>(|_, _, _| {});\n    test_shr_signed_helper::<isize, _>(|_, _, _| {});\n}\n\nfn shr_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    Integer: ShrAssign<T> + Shr<T, Output = Integer>,\n    for<'a> &'a Integer: Shr<T, Output = Integer> + ShrRound<T, Output = Integer>,\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n    SignedLimb: Shr<T, Output = SignedLimb>,\n{\n    integer_unsigned_pair_gen_var_2::<T>().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n >>= u;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n >> u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone() >> u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert!(shifted.le_abs(&n));\n        assert_eq!((&n).shr_round(u, Floor).0, shifted);\n    });\n\n    integer_unsigned_unsigned_triple_gen_var_3::<T>().test_properties(|(n, u, v)| {\n        if let Some(sum) = u.checked_add(v) {\n            assert_eq!(&n >> u >> v, n >> sum);\n        }\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(&n >> T::ZERO, n);\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(Integer::ZERO >> u, 0);\n    });\n\n    natural_unsigned_pair_gen_var_4::<T>().test_properties(|(n, u)| {\n        assert_eq!(&n >> u, Integer::from(n) >> u);\n    });\n\n    signed_unsigned_pair_gen_var_1::<SignedLimb, T>().test_properties(|(i, j)| {\n        if let Some(sum) = j.checked_add(T::exact_from(SignedLimb::WIDTH)) {\n            let shifted = Integer::from(i) >> sum;\n            if i >= 0 {\n                assert_eq!(shifted, 0);\n            } else {\n                assert_eq!(shifted, -1);\n            }\n        }\n        if j < T::exact_from(SignedLimb::WIDTH) {\n            assert_eq!(i >> j, Integer::from(i) >> j);\n        }\n    });\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn shr_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    Integer:\n        ShrAssign<T> + Shr<T, Output = Integer> + Shr<<T as UnsignedAbs>::Output, Output = Integer>,\n    for<'a> &'a Integer: Shr<T, Output = Integer> + ShrRound<T, Output = Integer>,\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    integer_signed_pair_gen_var_1::<T>().test_properties(|(n, i)| {\n        let mut mut_n = n.clone();\n        mut_n >>= i;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n >> i;\n        assert_eq!(shifted_alt, shifted);\n        assert!(shifted_alt.is_valid());\n        let shifted_alt = n.clone() >> i;\n        assert_eq!(shifted_alt, shifted);\n        assert!(shifted_alt.is_valid());\n\n        assert_eq!((&n).shr_round(i, Floor).0, shifted);\n\n        if i >= T::ZERO {\n            assert_eq!(n >> i.unsigned_abs(), shifted);\n        }\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(&n >> T::ZERO, n);\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert_eq!(Integer::ZERO >> i, 0);\n    });\n\n    natural_signed_pair_gen_var_2::<T>().test_properties(|(n, i)| {\n        assert_eq!(&n >> i, Integer::from(n) >> i);\n    });\n}\n\n#[test]\nfn shr_properties() {\n    apply_fn_to_unsigneds!(shr_properties_helper_unsigned);\n    apply_fn_to_signeds!(shr_properties_helper_signed);\n\n    integer_unsigned_pair_gen_var_2::<u32>().test_properties(|(n, u)| {\n        let shifted = &n >> u;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n >>= u;\n        assert_eq!(Integer::from(&rug_n), shifted);\n\n        assert_eq!(Integer::from(&(rug::Integer::from(&n) >> u)), shifted);\n\n        assert_eq!(\n            Integer::from(&(&BigInt::from(&n) >> usize::exact_from(u))),\n            shifted\n        );\n        assert_eq!(\n            Integer::from(&(BigInt::from(&n) >> usize::exact_from(u))),\n            shifted\n        );\n    });\n\n    integer_signed_pair_gen_var_1::<i32>().test_properties(|(n, i)| {\n        let shifted = &n >> i;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n >>= i;\n        assert_eq!(Integer::from(&rug_n), shifted);\n\n        assert_eq!(Integer::from(&(rug::Integer::from(&n) >> i)), shifted);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShr, DivRound, DivisibleByPowerOf2, ShrRound, ShrRoundAssign,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, signed_signed_rounding_mode_triple_gen_var_3,\n    signed_unsigned_rounding_mode_triple_gen_var_2, unsigned_rounding_mode_pair_gen,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_rounding_mode_pair_gen, integer_signed_rounding_mode_triple_gen_var_2,\n    integer_unsigned_pair_gen_var_2, integer_unsigned_pair_gen_var_5,\n    integer_unsigned_rounding_mode_triple_gen_var_2, natural_signed_rounding_mode_triple_gen_var_2,\n    natural_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::ops::Shl;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nmacro_rules! test_shr_round_unsigned_helper {\n    ($t:ident) => {\n        let test = |u, v: $t, rm: RoundingMode, out, o| {\n            let u = Integer::from_str(u).unwrap();\n\n            let mut n = u.clone();\n            assert_eq!(n.shr_round_assign(v, rm), o, \"{} {} {:?}\", u, v, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n\n            let (n, o_alt) = u.clone().shr_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n\n            let (n, o_alt) = (&u).shr_round(v, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n        };\n        test(\"0\", 0, Down, \"0\", Equal);\n        test(\"0\", 0, Up, \"0\", Equal);\n        test(\"0\", 0, Floor, \"0\", Equal);\n        test(\"0\", 0, Ceiling, \"0\", Equal);\n        test(\"0\", 0, Nearest, \"0\", Equal);\n        test(\"0\", 0, Exact, \"0\", Equal);\n\n        test(\"0\", 10, Down, \"0\", Equal);\n        test(\"0\", 10, Up, \"0\", Equal);\n        test(\"0\", 10, Floor, \"0\", Equal);\n        test(\"0\", 10, Ceiling, \"0\", Equal);\n        test(\"0\", 10, Nearest, \"0\", Equal);\n        test(\"0\", 10, Exact, \"0\", Equal);\n\n        test(\"123\", 0, Down, \"123\", Equal);\n        test(\"123\", 0, Up, \"123\", Equal);\n        test(\"123\", 0, Floor, \"123\", Equal);\n        test(\"123\", 0, Ceiling, \"123\", Equal);\n        test(\"123\", 0, Nearest, \"123\", Equal);\n        test(\"123\", 0, Exact, \"123\", Equal);\n\n        test(\"245\", 1, Down, \"122\", Less);\n        test(\"245\", 1, Up, \"123\", Greater);\n        test(\"245\", 1, Floor, \"122\", Less);\n        test(\"245\", 1, Ceiling, \"123\", Greater);\n        test(\"245\", 1, Nearest, \"122\", Less);\n\n        test(\"246\", 1, Down, \"123\", Equal);\n        test(\"246\", 1, Up, \"123\", Equal);\n        test(\"246\", 1, Floor, \"123\", Equal);\n        test(\"246\", 1, Ceiling, \"123\", Equal);\n        test(\"246\", 1, Nearest, \"123\", Equal);\n        test(\"246\", 1, Exact, \"123\", Equal);\n\n        test(\"247\", 1, Down, \"123\", Less);\n        test(\"247\", 1, Up, \"124\", Greater);\n        test(\"247\", 1, Floor, \"123\", Less);\n        test(\"247\", 1, Ceiling, \"124\", Greater);\n        test(\"247\", 1, Nearest, \"124\", Greater);\n\n        test(\"491\", 2, Down, \"122\", Less);\n        test(\"491\", 2, Up, \"123\", Greater);\n        test(\"491\", 2, Floor, \"122\", Less);\n        test(\"491\", 2, Ceiling, \"123\", Greater);\n        test(\"491\", 2, Nearest, \"123\", Greater);\n\n        test(\"492\", 2, Down, \"123\", Equal);\n        test(\"492\", 2, Up, \"123\", Equal);\n        test(\"492\", 2, Floor, \"123\", Equal);\n        test(\"492\", 2, Ceiling, \"123\", Equal);\n        test(\"492\", 2, Nearest, \"123\", Equal);\n        test(\"492\", 2, Exact, \"123\", Equal);\n\n        test(\"493\", 2, Down, \"123\", Less);\n        test(\"493\", 2, Up, \"124\", Greater);\n        test(\"493\", 2, Floor, \"123\", Less);\n        test(\"493\", 2, Ceiling, \"124\", Greater);\n        test(\"493\", 2, Nearest, \"123\", Less);\n\n        test(\"4127195135\", 25, Down, \"122\", Less);\n        test(\"4127195135\", 25, Up, \"123\", Greater);\n        test(\"4127195135\", 25, Floor, \"122\", Less);\n        test(\"4127195135\", 25, Ceiling, \"123\", Greater);\n        test(\"4127195135\", 25, Nearest, \"123\", Greater);\n\n        test(\"4127195136\", 25, Down, \"123\", Equal);\n        test(\"4127195136\", 25, Up, \"123\", Equal);\n        test(\"4127195136\", 25, Floor, \"123\", Equal);\n        test(\"4127195136\", 25, Ceiling, \"123\", Equal);\n        test(\"4127195136\", 25, Nearest, \"123\", Equal);\n        test(\"4127195136\", 25, Exact, \"123\", Equal);\n\n        test(\"4127195137\", 25, Down, \"123\", Less);\n        test(\"4127195137\", 25, Up, \"124\", Greater);\n        test(\"4127195137\", 25, Floor, \"123\", Less);\n        test(\"4127195137\", 25, Ceiling, \"124\", Greater);\n        test(\"4127195137\", 25, Nearest, \"123\", Less);\n\n        test(\"8254390271\", 26, Down, \"122\", Less);\n        test(\"8254390271\", 26, Up, \"123\", Greater);\n        test(\"8254390271\", 26, Floor, \"122\", Less);\n        test(\"8254390271\", 26, Ceiling, \"123\", Greater);\n        test(\"8254390271\", 26, Nearest, \"123\", Greater);\n\n        test(\"8254390272\", 26, Down, \"123\", Equal);\n        test(\"8254390272\", 26, Up, \"123\", Equal);\n        test(\"8254390272\", 26, Floor, \"123\", Equal);\n        test(\"8254390272\", 26, Ceiling, \"123\", Equal);\n        test(\"8254390272\", 26, Nearest, \"123\", Equal);\n        test(\"8254390272\", 26, Exact, \"123\", Equal);\n\n        test(\"8254390273\", 26, Down, \"123\", Less);\n        test(\"8254390273\", 26, Up, \"124\", Greater);\n        test(\"8254390273\", 26, Floor, \"123\", Less);\n        test(\"8254390273\", 26, Ceiling, \"124\", Greater);\n        test(\"8254390273\", 26, Nearest, \"123\", Less);\n\n        test(\"155921023828072216384094494261247\", 100, Down, \"122\", Less);\n        test(\"155921023828072216384094494261247\", 100, Up, \"123\", Greater);\n        test(\"155921023828072216384094494261247\", 100, Floor, \"122\", Less);\n        test(\n            \"155921023828072216384094494261247\",\n            100,\n            Ceiling,\n            \"123\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            100,\n            Nearest,\n            \"123\",\n            Greater,\n        );\n\n        test(\"155921023828072216384094494261248\", 100, Down, \"123\", Equal);\n        test(\"155921023828072216384094494261248\", 100, Up, \"123\", Equal);\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Floor,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Ceiling,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Nearest,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Exact,\n            \"123\",\n            Equal,\n        );\n\n        test(\"155921023828072216384094494261249\", 100, Down, \"123\", Less);\n        test(\"155921023828072216384094494261249\", 100, Up, \"124\", Greater);\n        test(\"155921023828072216384094494261249\", 100, Floor, \"123\", Less);\n        test(\n            \"155921023828072216384094494261249\",\n            100,\n            Ceiling,\n            \"124\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            100,\n            Nearest,\n            \"123\",\n            Less,\n        );\n\n        test(\"4294967295\", 1, Down, \"2147483647\", Less);\n        test(\"4294967295\", 1, Up, \"2147483648\", Greater);\n        test(\"4294967295\", 1, Floor, \"2147483647\", Less);\n        test(\"4294967295\", 1, Ceiling, \"2147483648\", Greater);\n        test(\"4294967295\", 1, Nearest, \"2147483648\", Greater);\n\n        test(\"4294967296\", 1, Down, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Up, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Floor, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Ceiling, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Nearest, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Exact, \"2147483648\", Equal);\n\n        test(\"4294967297\", 1, Down, \"2147483648\", Less);\n        test(\"4294967297\", 1, Up, \"2147483649\", Greater);\n        test(\"4294967297\", 1, Floor, \"2147483648\", Less);\n        test(\"4294967297\", 1, Ceiling, \"2147483649\", Greater);\n        test(\"4294967297\", 1, Nearest, \"2147483648\", Less);\n\n        test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n        test(\"7999999999999\", 3, Down, \"999999999999\", Less);\n        test(\"7999999999999\", 3, Up, \"1000000000000\", Greater);\n        test(\"7999999999999\", 3, Floor, \"999999999999\", Less);\n        test(\"7999999999999\", 3, Ceiling, \"1000000000000\", Greater);\n        test(\"7999999999999\", 3, Nearest, \"1000000000000\", Greater);\n\n        test(\"8000000000000\", 3, Down, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Up, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Floor, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Ceiling, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Nearest, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Exact, \"1000000000000\", Equal);\n\n        test(\"8000000000001\", 3, Down, \"1000000000000\", Less);\n        test(\"8000000000001\", 3, Up, \"1000000000001\", Greater);\n        test(\"8000000000001\", 3, Floor, \"1000000000000\", Less);\n        test(\"8000000000001\", 3, Ceiling, \"1000000000001\", Greater);\n        test(\"8000000000001\", 3, Nearest, \"1000000000000\", Less);\n\n        test(\"16777216000000000000\", 24, Down, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Up, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Floor, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Ceiling, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Nearest, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Exact, \"1000000000000\", Equal);\n\n        test(\"33554432000000000000\", 25, Down, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Up, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Floor, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Ceiling, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Nearest, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Exact, \"1000000000000\", Equal);\n\n        test(\"2147483648000000000000\", 31, Down, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", 31, Up, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", 31, Floor, \"1000000000000\", Equal);\n        test(\n            \"2147483648000000000000\",\n            31,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"2147483648000000000000\",\n            31,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"2147483648000000000000\", 31, Exact, \"1000000000000\", Equal);\n\n        test(\"4294967296000000000000\", 32, Down, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", 32, Up, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", 32, Floor, \"1000000000000\", Equal);\n        test(\n            \"4294967296000000000000\",\n            32,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"4294967296000000000000\",\n            32,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"4294967296000000000000\", 32, Exact, \"1000000000000\", Equal);\n\n        test(\"8589934592000000000000\", 33, Down, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", 33, Up, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", 33, Floor, \"1000000000000\", Equal);\n        test(\n            \"8589934592000000000000\",\n            33,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"8589934592000000000000\",\n            33,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"8589934592000000000000\", 33, Exact, \"1000000000000\", Equal);\n\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Down,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Up,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Floor,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Exact,\n            \"1000000000000\",\n            Equal,\n        );\n\n        test(\"1000000000000\", 10, Down, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Up, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Floor, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Ceiling, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Nearest, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Exact, \"976562500\", Equal);\n\n        test(\"980657949\", 72, Down, \"0\", Less);\n        test(\"980657949\", 72, Up, \"1\", Greater);\n        test(\"980657949\", 72, Floor, \"0\", Less);\n        test(\"980657949\", 72, Ceiling, \"1\", Greater);\n        test(\"980657949\", 72, Nearest, \"0\", Less);\n\n        test(\"4294967295\", 31, Down, \"1\", Less);\n        test(\"4294967295\", 31, Up, \"2\", Greater);\n        test(\"4294967295\", 31, Floor, \"1\", Less);\n        test(\"4294967295\", 31, Ceiling, \"2\", Greater);\n        test(\"4294967295\", 31, Nearest, \"2\", Greater);\n\n        test(\"4294967295\", 32, Down, \"0\", Less);\n        test(\"4294967295\", 32, Up, \"1\", Greater);\n        test(\"4294967295\", 32, Floor, \"0\", Less);\n        test(\"4294967295\", 32, Ceiling, \"1\", Greater);\n        test(\"4294967295\", 32, Nearest, \"1\", Greater);\n\n        test(\"4294967296\", 32, Down, \"1\", Equal);\n        test(\"4294967296\", 32, Up, \"1\", Equal);\n        test(\"4294967296\", 32, Floor, \"1\", Equal);\n        test(\"4294967296\", 32, Ceiling, \"1\", Equal);\n        test(\"4294967296\", 32, Nearest, \"1\", Equal);\n        test(\"4294967296\", 32, Exact, \"1\", Equal);\n\n        test(\"4294967296\", 33, Down, \"0\", Less);\n        test(\"4294967296\", 33, Up, \"1\", Greater);\n        test(\"4294967296\", 33, Floor, \"0\", Less);\n        test(\"4294967296\", 33, Ceiling, \"1\", Greater);\n        test(\"4294967296\", 33, Nearest, \"0\", Less);\n\n        test(\"-123\", 0, Down, \"-123\", Equal);\n        test(\"-123\", 0, Up, \"-123\", Equal);\n        test(\"-123\", 0, Floor, \"-123\", Equal);\n        test(\"-123\", 0, Ceiling, \"-123\", Equal);\n        test(\"-123\", 0, Nearest, \"-123\", Equal);\n        test(\"-123\", 0, Exact, \"-123\", Equal);\n\n        test(\"-245\", 1, Down, \"-122\", Greater);\n        test(\"-245\", 1, Up, \"-123\", Less);\n        test(\"-245\", 1, Floor, \"-123\", Less);\n        test(\"-245\", 1, Ceiling, \"-122\", Greater);\n        test(\"-245\", 1, Nearest, \"-122\", Greater);\n\n        test(\"-246\", 1, Down, \"-123\", Equal);\n        test(\"-246\", 1, Up, \"-123\", Equal);\n        test(\"-246\", 1, Floor, \"-123\", Equal);\n        test(\"-246\", 1, Ceiling, \"-123\", Equal);\n        test(\"-246\", 1, Nearest, \"-123\", Equal);\n        test(\"-246\", 1, Exact, \"-123\", Equal);\n\n        test(\"-247\", 1, Down, \"-123\", Greater);\n        test(\"-247\", 1, Up, \"-124\", Less);\n        test(\"-247\", 1, Floor, \"-124\", Less);\n        test(\"-247\", 1, Ceiling, \"-123\", Greater);\n        test(\"-247\", 1, Nearest, \"-124\", Less);\n\n        test(\"-491\", 2, Down, \"-122\", Greater);\n        test(\"-491\", 2, Up, \"-123\", Less);\n        test(\"-491\", 2, Floor, \"-123\", Less);\n        test(\"-491\", 2, Ceiling, \"-122\", Greater);\n        test(\"-491\", 2, Nearest, \"-123\", Less);\n\n        test(\"-492\", 2, Down, \"-123\", Equal);\n        test(\"-492\", 2, Up, \"-123\", Equal);\n        test(\"-492\", 2, Floor, \"-123\", Equal);\n        test(\"-492\", 2, Ceiling, \"-123\", Equal);\n        test(\"-492\", 2, Nearest, \"-123\", Equal);\n        test(\"-492\", 2, Exact, \"-123\", Equal);\n\n        test(\"-493\", 2, Down, \"-123\", Greater);\n        test(\"-493\", 2, Up, \"-124\", Less);\n        test(\"-493\", 2, Floor, \"-124\", Less);\n        test(\"-493\", 2, Ceiling, \"-123\", Greater);\n        test(\"-493\", 2, Nearest, \"-123\", Greater);\n\n        test(\"-4127195135\", 25, Down, \"-122\", Greater);\n        test(\"-4127195135\", 25, Up, \"-123\", Less);\n        test(\"-4127195135\", 25, Floor, \"-123\", Less);\n        test(\"-4127195135\", 25, Ceiling, \"-122\", Greater);\n        test(\"-4127195135\", 25, Nearest, \"-123\", Less);\n\n        test(\"-4127195136\", 25, Down, \"-123\", Equal);\n        test(\"-4127195136\", 25, Up, \"-123\", Equal);\n        test(\"-4127195136\", 25, Floor, \"-123\", Equal);\n        test(\"-4127195136\", 25, Ceiling, \"-123\", Equal);\n        test(\"-4127195136\", 25, Nearest, \"-123\", Equal);\n        test(\"-4127195136\", 25, Exact, \"-123\", Equal);\n\n        test(\"-4127195137\", 25, Down, \"-123\", Greater);\n        test(\"-4127195137\", 25, Up, \"-124\", Less);\n        test(\"-4127195137\", 25, Floor, \"-124\", Less);\n        test(\"-4127195137\", 25, Ceiling, \"-123\", Greater);\n        test(\"-4127195137\", 25, Nearest, \"-123\", Greater);\n\n        test(\"-8254390271\", 26, Down, \"-122\", Greater);\n        test(\"-8254390271\", 26, Up, \"-123\", Less);\n        test(\"-8254390271\", 26, Floor, \"-123\", Less);\n        test(\"-8254390271\", 26, Ceiling, \"-122\", Greater);\n        test(\"-8254390271\", 26, Nearest, \"-123\", Less);\n\n        test(\"-8254390272\", 26, Down, \"-123\", Equal);\n        test(\"-8254390272\", 26, Up, \"-123\", Equal);\n        test(\"-8254390272\", 26, Floor, \"-123\", Equal);\n        test(\"-8254390272\", 26, Ceiling, \"-123\", Equal);\n        test(\"-8254390272\", 26, Nearest, \"-123\", Equal);\n        test(\"-8254390272\", 26, Exact, \"-123\", Equal);\n\n        test(\"-8254390273\", 26, Down, \"-123\", Greater);\n        test(\"-8254390273\", 26, Up, \"-124\", Less);\n        test(\"-8254390273\", 26, Floor, \"-124\", Less);\n        test(\"-8254390273\", 26, Ceiling, \"-123\", Greater);\n        test(\"-8254390273\", 26, Nearest, \"-123\", Greater);\n\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Down,\n            \"-122\",\n            Greater,\n        );\n        test(\"-155921023828072216384094494261247\", 100, Up, \"-123\", Less);\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Floor,\n            \"-123\",\n            Less,\n        );\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Ceiling,\n            \"-122\",\n            Greater,\n        );\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Nearest,\n            \"-123\",\n            Less,\n        );\n\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Down,\n            \"-123\",\n            Equal,\n        );\n        test(\"-155921023828072216384094494261248\", 100, Up, \"-123\", Equal);\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Floor,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Ceiling,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Nearest,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Exact,\n            \"-123\",\n            Equal,\n        );\n\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Down,\n            \"-123\",\n            Greater,\n        );\n        test(\"-155921023828072216384094494261249\", 100, Up, \"-124\", Less);\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Floor,\n            \"-124\",\n            Less,\n        );\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Ceiling,\n            \"-123\",\n            Greater,\n        );\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Nearest,\n            \"-123\",\n            Greater,\n        );\n\n        test(\"-4294967295\", 1, Down, \"-2147483647\", Greater);\n        test(\"-4294967295\", 1, Up, \"-2147483648\", Less);\n        test(\"-4294967295\", 1, Floor, \"-2147483648\", Less);\n        test(\"-4294967295\", 1, Ceiling, \"-2147483647\", Greater);\n        test(\"-4294967295\", 1, Nearest, \"-2147483648\", Less);\n\n        test(\"-4294967296\", 1, Down, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Up, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Floor, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Ceiling, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Nearest, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Exact, \"-2147483648\", Equal);\n\n        test(\"-4294967297\", 1, Down, \"-2147483648\", Greater);\n        test(\"-4294967297\", 1, Up, \"-2147483649\", Less);\n        test(\"-4294967297\", 1, Floor, \"-2147483649\", Less);\n        test(\"-4294967297\", 1, Ceiling, \"-2147483648\", Greater);\n        test(\"-4294967297\", 1, Nearest, \"-2147483648\", Greater);\n\n        test(\"-1000000000000\", 0, Down, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Up, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Floor, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Ceiling, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Nearest, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Exact, \"-1000000000000\", Equal);\n\n        test(\"-7999999999999\", 3, Down, \"-999999999999\", Greater);\n        test(\"-7999999999999\", 3, Up, \"-1000000000000\", Less);\n        test(\"-7999999999999\", 3, Floor, \"-1000000000000\", Less);\n        test(\"-7999999999999\", 3, Ceiling, \"-999999999999\", Greater);\n        test(\"-7999999999999\", 3, Nearest, \"-1000000000000\", Less);\n\n        test(\"-8000000000000\", 3, Down, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Up, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Floor, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Ceiling, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Nearest, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Exact, \"-1000000000000\", Equal);\n\n        test(\"-8000000000001\", 3, Down, \"-1000000000000\", Greater);\n        test(\"-8000000000001\", 3, Up, \"-1000000000001\", Less);\n        test(\"-8000000000001\", 3, Floor, \"-1000000000001\", Less);\n        test(\"-8000000000001\", 3, Ceiling, \"-1000000000000\", Greater);\n        test(\"-8000000000001\", 3, Nearest, \"-1000000000000\", Greater);\n\n        test(\"-16777216000000000000\", 24, Down, \"-1000000000000\", Equal);\n        test(\"-16777216000000000000\", 24, Up, \"-1000000000000\", Equal);\n        test(\"-16777216000000000000\", 24, Floor, \"-1000000000000\", Equal);\n        test(\n            \"-16777216000000000000\",\n            24,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-16777216000000000000\",\n            24,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-16777216000000000000\", 24, Exact, \"-1000000000000\", Equal);\n\n        test(\"-33554432000000000000\", 25, Down, \"-1000000000000\", Equal);\n        test(\"-33554432000000000000\", 25, Up, \"-1000000000000\", Equal);\n        test(\"-33554432000000000000\", 25, Floor, \"-1000000000000\", Equal);\n        test(\n            \"-33554432000000000000\",\n            25,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-33554432000000000000\",\n            25,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-33554432000000000000\", 25, Exact, \"-1000000000000\", Equal);\n\n        test(\"-2147483648000000000000\", 31, Down, \"-1000000000000\", Equal);\n        test(\"-2147483648000000000000\", 31, Up, \"-1000000000000\", Equal);\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\"-4294967296000000000000\", 32, Down, \"-1000000000000\", Equal);\n        test(\"-4294967296000000000000\", 32, Up, \"-1000000000000\", Equal);\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\"-8589934592000000000000\", 33, Down, \"-1000000000000\", Equal);\n        test(\"-8589934592000000000000\", 33, Up, \"-1000000000000\", Equal);\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Down,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Up,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\"-1000000000000\", 10, Down, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Up, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Floor, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Ceiling, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Nearest, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Exact, \"-976562500\", Equal);\n\n        test(\"-980657949\", 72, Down, \"0\", Greater);\n        test(\"-980657949\", 72, Up, \"-1\", Less);\n        test(\"-980657949\", 72, Floor, \"-1\", Less);\n        test(\"-980657949\", 72, Ceiling, \"0\", Greater);\n        test(\"-980657949\", 72, Nearest, \"0\", Greater);\n\n        test(\"-4294967295\", 31, Down, \"-1\", Greater);\n        test(\"-4294967295\", 31, Up, \"-2\", Less);\n        test(\"-4294967295\", 31, Floor, \"-2\", Less);\n        test(\"-4294967295\", 31, Ceiling, \"-1\", Greater);\n        test(\"-4294967295\", 31, Nearest, \"-2\", Less);\n\n        test(\"-4294967295\", 32, Down, \"0\", Greater);\n        test(\"-4294967295\", 32, Up, \"-1\", Less);\n        test(\"-4294967295\", 32, Floor, \"-1\", Less);\n        test(\"-4294967295\", 32, Ceiling, \"0\", Greater);\n        test(\"-4294967295\", 32, Nearest, \"-1\", Less);\n\n        test(\"-4294967296\", 32, Down, \"-1\", Equal);\n        test(\"-4294967296\", 32, Up, \"-1\", Equal);\n        test(\"-4294967296\", 32, Floor, \"-1\", Equal);\n        test(\"-4294967296\", 32, Ceiling, \"-1\", Equal);\n        test(\"-4294967296\", 32, Nearest, \"-1\", Equal);\n        test(\"-4294967296\", 32, Exact, \"-1\", Equal);\n\n        test(\"-4294967296\", 33, Down, \"0\", Greater);\n        test(\"-4294967296\", 33, Up, \"-1\", Less);\n        test(\"-4294967296\", 33, Floor, \"-1\", Less);\n        test(\"-4294967296\", 33, Ceiling, \"0\", Greater);\n        test(\"-4294967296\", 33, Nearest, \"0\", Greater);\n    };\n}\n\n#[test]\nfn test_shr_round_unsigned() {\n    apply_to_unsigneds!(test_shr_round_unsigned_helper);\n}\n\nmacro_rules! shr_round_unsigned_fail_helper {\n    ($t:ident) => {\n        assert_panic!(Integer::from(-123).shr_round_assign($t::ONE, Exact));\n        assert_panic!(Integer::from(-123).shr_round_assign($t::exact_from(100), Exact));\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::ONE, Exact)\n        );\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::exact_from(100), Exact)\n        );\n        assert_panic!(Integer::from(-123).shr_round($t::ONE, Exact));\n        assert_panic!(Integer::from(-123).shr_round($t::exact_from(100), Exact));\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round($t::ONE, Exact)\n        );\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round($t::exact_from(100), Exact)\n        );\n        assert_panic!((&Integer::from(-123)).shr_round($t::ONE, Exact));\n        assert_panic!((&Integer::from(-123)).shr_round($t::exact_from(100), Exact));\n        assert_panic!((&Integer::from_str(\"-1000000000001\").unwrap()).shr_round($t::ONE, Exact));\n        assert_panic!(\n            (&Integer::from_str(\"-1000000000001\").unwrap()).shr_round($t::exact_from(100), Exact)\n        );\n    };\n}\n\n#[test]\nfn shr_round_unsigned_fail() {\n    apply_to_unsigneds!(shr_round_unsigned_fail_helper);\n}\n\nmacro_rules! test_shr_round_signed_helper {\n    ($t:ident) => {\n        let test = |i, j: $t, rm: RoundingMode, out, o| {\n            let u = Integer::from_str(i).unwrap();\n\n            let mut n = u.clone();\n            assert_eq!(n.shr_round_assign(j, rm), o);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n\n            let (n, o_alt) = u.clone().shr_round(j, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n\n            let (n, o_alt) = (&u).shr_round(j, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n        };\n        test(\"0\", 0, Down, \"0\", Equal);\n        test(\"0\", 0, Up, \"0\", Equal);\n        test(\"0\", 0, Floor, \"0\", Equal);\n        test(\"0\", 0, Ceiling, \"0\", Equal);\n        test(\"0\", 0, Nearest, \"0\", Equal);\n        test(\"0\", 0, Exact, \"0\", Equal);\n\n        test(\"0\", 10, Down, \"0\", Equal);\n        test(\"0\", 10, Up, \"0\", Equal);\n        test(\"0\", 10, Floor, \"0\", Equal);\n        test(\"0\", 10, Ceiling, \"0\", Equal);\n        test(\"0\", 10, Nearest, \"0\", Equal);\n        test(\"0\", 10, Exact, \"0\", Equal);\n\n        test(\"123\", 0, Down, \"123\", Equal);\n        test(\"123\", 0, Up, \"123\", Equal);\n        test(\"123\", 0, Floor, \"123\", Equal);\n        test(\"123\", 0, Ceiling, \"123\", Equal);\n        test(\"123\", 0, Nearest, \"123\", Equal);\n        test(\"123\", 0, Exact, \"123\", Equal);\n\n        test(\"245\", 1, Down, \"122\", Less);\n        test(\"245\", 1, Up, \"123\", Greater);\n        test(\"245\", 1, Floor, \"122\", Less);\n        test(\"245\", 1, Ceiling, \"123\", Greater);\n        test(\"245\", 1, Nearest, \"122\", Less);\n\n        test(\"246\", 1, Down, \"123\", Equal);\n        test(\"246\", 1, Up, \"123\", Equal);\n        test(\"246\", 1, Floor, \"123\", Equal);\n        test(\"246\", 1, Ceiling, \"123\", Equal);\n        test(\"246\", 1, Nearest, \"123\", Equal);\n        test(\"246\", 1, Exact, \"123\", Equal);\n\n        test(\"247\", 1, Down, \"123\", Less);\n        test(\"247\", 1, Up, \"124\", Greater);\n        test(\"247\", 1, Floor, \"123\", Less);\n        test(\"247\", 1, Ceiling, \"124\", Greater);\n        test(\"247\", 1, Nearest, \"124\", Greater);\n\n        test(\"491\", 2, Down, \"122\", Less);\n        test(\"491\", 2, Up, \"123\", Greater);\n        test(\"491\", 2, Floor, \"122\", Less);\n        test(\"491\", 2, Ceiling, \"123\", Greater);\n        test(\"491\", 2, Nearest, \"123\", Greater);\n\n        test(\"492\", 2, Down, \"123\", Equal);\n        test(\"492\", 2, Up, \"123\", Equal);\n        test(\"492\", 2, Floor, \"123\", Equal);\n        test(\"492\", 2, Ceiling, \"123\", Equal);\n        test(\"492\", 2, Nearest, \"123\", Equal);\n        test(\"492\", 2, Exact, \"123\", Equal);\n\n        test(\"493\", 2, Down, \"123\", Less);\n        test(\"493\", 2, Up, \"124\", Greater);\n        test(\"493\", 2, Floor, \"123\", Less);\n        test(\"493\", 2, Ceiling, \"124\", Greater);\n        test(\"493\", 2, Nearest, \"123\", Less);\n\n        test(\"4127195135\", 25, Down, \"122\", Less);\n        test(\"4127195135\", 25, Up, \"123\", Greater);\n        test(\"4127195135\", 25, Floor, \"122\", Less);\n        test(\"4127195135\", 25, Ceiling, \"123\", Greater);\n        test(\"4127195135\", 25, Nearest, \"123\", Greater);\n\n        test(\"4127195136\", 25, Down, \"123\", Equal);\n        test(\"4127195136\", 25, Up, \"123\", Equal);\n        test(\"4127195136\", 25, Floor, \"123\", Equal);\n        test(\"4127195136\", 25, Ceiling, \"123\", Equal);\n        test(\"4127195136\", 25, Nearest, \"123\", Equal);\n        test(\"4127195136\", 25, Exact, \"123\", Equal);\n\n        test(\"4127195137\", 25, Down, \"123\", Less);\n        test(\"4127195137\", 25, Up, \"124\", Greater);\n        test(\"4127195137\", 25, Floor, \"123\", Less);\n        test(\"4127195137\", 25, Ceiling, \"124\", Greater);\n        test(\"4127195137\", 25, Nearest, \"123\", Less);\n\n        test(\"8254390271\", 26, Down, \"122\", Less);\n        test(\"8254390271\", 26, Up, \"123\", Greater);\n        test(\"8254390271\", 26, Floor, \"122\", Less);\n        test(\"8254390271\", 26, Ceiling, \"123\", Greater);\n        test(\"8254390271\", 26, Nearest, \"123\", Greater);\n\n        test(\"8254390272\", 26, Down, \"123\", Equal);\n        test(\"8254390272\", 26, Up, \"123\", Equal);\n        test(\"8254390272\", 26, Floor, \"123\", Equal);\n        test(\"8254390272\", 26, Ceiling, \"123\", Equal);\n        test(\"8254390272\", 26, Nearest, \"123\", Equal);\n        test(\"8254390272\", 26, Exact, \"123\", Equal);\n\n        test(\"8254390273\", 26, Down, \"123\", Less);\n        test(\"8254390273\", 26, Up, \"124\", Greater);\n        test(\"8254390273\", 26, Floor, \"123\", Less);\n        test(\"8254390273\", 26, Ceiling, \"124\", Greater);\n        test(\"8254390273\", 26, Nearest, \"123\", Less);\n\n        test(\"155921023828072216384094494261247\", 100, Down, \"122\", Less);\n        test(\"155921023828072216384094494261247\", 100, Up, \"123\", Greater);\n        test(\"155921023828072216384094494261247\", 100, Floor, \"122\", Less);\n        test(\n            \"155921023828072216384094494261247\",\n            100,\n            Ceiling,\n            \"123\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            100,\n            Nearest,\n            \"123\",\n            Greater,\n        );\n\n        test(\"155921023828072216384094494261248\", 100, Down, \"123\", Equal);\n        test(\"155921023828072216384094494261248\", 100, Up, \"123\", Equal);\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Floor,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Ceiling,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Nearest,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            100,\n            Exact,\n            \"123\",\n            Equal,\n        );\n\n        test(\"155921023828072216384094494261249\", 100, Down, \"123\", Less);\n        test(\"155921023828072216384094494261249\", 100, Up, \"124\", Greater);\n        test(\"155921023828072216384094494261249\", 100, Floor, \"123\", Less);\n        test(\n            \"155921023828072216384094494261249\",\n            100,\n            Ceiling,\n            \"124\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            100,\n            Nearest,\n            \"123\",\n            Less,\n        );\n\n        test(\"4294967295\", 1, Down, \"2147483647\", Less);\n        test(\"4294967295\", 1, Up, \"2147483648\", Greater);\n        test(\"4294967295\", 1, Floor, \"2147483647\", Less);\n        test(\"4294967295\", 1, Ceiling, \"2147483648\", Greater);\n        test(\"4294967295\", 1, Nearest, \"2147483648\", Greater);\n\n        test(\"4294967296\", 1, Down, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Up, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Floor, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Ceiling, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Nearest, \"2147483648\", Equal);\n        test(\"4294967296\", 1, Exact, \"2147483648\", Equal);\n\n        test(\"4294967297\", 1, Down, \"2147483648\", Less);\n        test(\"4294967297\", 1, Up, \"2147483649\", Greater);\n        test(\"4294967297\", 1, Floor, \"2147483648\", Less);\n        test(\"4294967297\", 1, Ceiling, \"2147483649\", Greater);\n        test(\"4294967297\", 1, Nearest, \"2147483648\", Less);\n\n        test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n        test(\"7999999999999\", 3, Down, \"999999999999\", Less);\n        test(\"7999999999999\", 3, Up, \"1000000000000\", Greater);\n        test(\"7999999999999\", 3, Floor, \"999999999999\", Less);\n        test(\"7999999999999\", 3, Ceiling, \"1000000000000\", Greater);\n        test(\"7999999999999\", 3, Nearest, \"1000000000000\", Greater);\n\n        test(\"8000000000000\", 3, Down, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Up, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Floor, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Ceiling, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Nearest, \"1000000000000\", Equal);\n        test(\"8000000000000\", 3, Exact, \"1000000000000\", Equal);\n\n        test(\"8000000000001\", 3, Down, \"1000000000000\", Less);\n        test(\"8000000000001\", 3, Up, \"1000000000001\", Greater);\n        test(\"8000000000001\", 3, Floor, \"1000000000000\", Less);\n        test(\"8000000000001\", 3, Ceiling, \"1000000000001\", Greater);\n        test(\"8000000000001\", 3, Nearest, \"1000000000000\", Less);\n\n        test(\"16777216000000000000\", 24, Down, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Up, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Floor, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Ceiling, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Nearest, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", 24, Exact, \"1000000000000\", Equal);\n\n        test(\"33554432000000000000\", 25, Down, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Up, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Floor, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Ceiling, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Nearest, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", 25, Exact, \"1000000000000\", Equal);\n\n        test(\"2147483648000000000000\", 31, Down, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", 31, Up, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", 31, Floor, \"1000000000000\", Equal);\n        test(\n            \"2147483648000000000000\",\n            31,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"2147483648000000000000\",\n            31,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"2147483648000000000000\", 31, Exact, \"1000000000000\", Equal);\n\n        test(\"4294967296000000000000\", 32, Down, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", 32, Up, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", 32, Floor, \"1000000000000\", Equal);\n        test(\n            \"4294967296000000000000\",\n            32,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"4294967296000000000000\",\n            32,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"4294967296000000000000\", 32, Exact, \"1000000000000\", Equal);\n\n        test(\"8589934592000000000000\", 33, Down, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", 33, Up, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", 33, Floor, \"1000000000000\", Equal);\n        test(\n            \"8589934592000000000000\",\n            33,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"8589934592000000000000\",\n            33,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"8589934592000000000000\", 33, Exact, \"1000000000000\", Equal);\n\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Down,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Up,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Floor,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            100,\n            Exact,\n            \"1000000000000\",\n            Equal,\n        );\n\n        test(\"1000000000000\", 10, Down, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Up, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Floor, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Ceiling, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Nearest, \"976562500\", Equal);\n        test(\"1000000000000\", 10, Exact, \"976562500\", Equal);\n\n        test(\"980657949\", 72, Down, \"0\", Less);\n        test(\"980657949\", 72, Up, \"1\", Greater);\n        test(\"980657949\", 72, Floor, \"0\", Less);\n        test(\"980657949\", 72, Ceiling, \"1\", Greater);\n        test(\"980657949\", 72, Nearest, \"0\", Less);\n\n        test(\"4294967295\", 31, Down, \"1\", Less);\n        test(\"4294967295\", 31, Up, \"2\", Greater);\n        test(\"4294967295\", 31, Floor, \"1\", Less);\n        test(\"4294967295\", 31, Ceiling, \"2\", Greater);\n        test(\"4294967295\", 31, Nearest, \"2\", Greater);\n\n        test(\"4294967295\", 32, Down, \"0\", Less);\n        test(\"4294967295\", 32, Up, \"1\", Greater);\n        test(\"4294967295\", 32, Floor, \"0\", Less);\n        test(\"4294967295\", 32, Ceiling, \"1\", Greater);\n        test(\"4294967295\", 32, Nearest, \"1\", Greater);\n\n        test(\"4294967296\", 32, Down, \"1\", Equal);\n        test(\"4294967296\", 32, Up, \"1\", Equal);\n        test(\"4294967296\", 32, Floor, \"1\", Equal);\n        test(\"4294967296\", 32, Ceiling, \"1\", Equal);\n        test(\"4294967296\", 32, Nearest, \"1\", Equal);\n        test(\"4294967296\", 32, Exact, \"1\", Equal);\n\n        test(\"4294967296\", 33, Down, \"0\", Less);\n        test(\"4294967296\", 33, Up, \"1\", Greater);\n        test(\"4294967296\", 33, Floor, \"0\", Less);\n        test(\"4294967296\", 33, Ceiling, \"1\", Greater);\n        test(\"4294967296\", 33, Nearest, \"0\", Less);\n\n        test(\"-123\", 0, Down, \"-123\", Equal);\n        test(\"-123\", 0, Up, \"-123\", Equal);\n        test(\"-123\", 0, Floor, \"-123\", Equal);\n        test(\"-123\", 0, Ceiling, \"-123\", Equal);\n        test(\"-123\", 0, Nearest, \"-123\", Equal);\n        test(\"-123\", 0, Exact, \"-123\", Equal);\n\n        test(\"-245\", 1, Down, \"-122\", Greater);\n        test(\"-245\", 1, Up, \"-123\", Less);\n        test(\"-245\", 1, Floor, \"-123\", Less);\n        test(\"-245\", 1, Ceiling, \"-122\", Greater);\n        test(\"-245\", 1, Nearest, \"-122\", Greater);\n\n        test(\"-246\", 1, Down, \"-123\", Equal);\n        test(\"-246\", 1, Up, \"-123\", Equal);\n        test(\"-246\", 1, Floor, \"-123\", Equal);\n        test(\"-246\", 1, Ceiling, \"-123\", Equal);\n        test(\"-246\", 1, Nearest, \"-123\", Equal);\n        test(\"-246\", 1, Exact, \"-123\", Equal);\n\n        test(\"-247\", 1, Down, \"-123\", Greater);\n        test(\"-247\", 1, Up, \"-124\", Less);\n        test(\"-247\", 1, Floor, \"-124\", Less);\n        test(\"-247\", 1, Ceiling, \"-123\", Greater);\n        test(\"-247\", 1, Nearest, \"-124\", Less);\n\n        test(\"-491\", 2, Down, \"-122\", Greater);\n        test(\"-491\", 2, Up, \"-123\", Less);\n        test(\"-491\", 2, Floor, \"-123\", Less);\n        test(\"-491\", 2, Ceiling, \"-122\", Greater);\n        test(\"-491\", 2, Nearest, \"-123\", Less);\n\n        test(\"-492\", 2, Down, \"-123\", Equal);\n        test(\"-492\", 2, Up, \"-123\", Equal);\n        test(\"-492\", 2, Floor, \"-123\", Equal);\n        test(\"-492\", 2, Ceiling, \"-123\", Equal);\n        test(\"-492\", 2, Nearest, \"-123\", Equal);\n        test(\"-492\", 2, Exact, \"-123\", Equal);\n\n        test(\"-493\", 2, Down, \"-123\", Greater);\n        test(\"-493\", 2, Up, \"-124\", Less);\n        test(\"-493\", 2, Floor, \"-124\", Less);\n        test(\"-493\", 2, Ceiling, \"-123\", Greater);\n        test(\"-493\", 2, Nearest, \"-123\", Greater);\n\n        test(\"-4127195135\", 25, Down, \"-122\", Greater);\n        test(\"-4127195135\", 25, Up, \"-123\", Less);\n        test(\"-4127195135\", 25, Floor, \"-123\", Less);\n        test(\"-4127195135\", 25, Ceiling, \"-122\", Greater);\n        test(\"-4127195135\", 25, Nearest, \"-123\", Less);\n\n        test(\"-4127195136\", 25, Down, \"-123\", Equal);\n        test(\"-4127195136\", 25, Up, \"-123\", Equal);\n        test(\"-4127195136\", 25, Floor, \"-123\", Equal);\n        test(\"-4127195136\", 25, Ceiling, \"-123\", Equal);\n        test(\"-4127195136\", 25, Nearest, \"-123\", Equal);\n        test(\"-4127195136\", 25, Exact, \"-123\", Equal);\n\n        test(\"-4127195137\", 25, Down, \"-123\", Greater);\n        test(\"-4127195137\", 25, Up, \"-124\", Less);\n        test(\"-4127195137\", 25, Floor, \"-124\", Less);\n        test(\"-4127195137\", 25, Ceiling, \"-123\", Greater);\n        test(\"-4127195137\", 25, Nearest, \"-123\", Greater);\n\n        test(\"-8254390271\", 26, Down, \"-122\", Greater);\n        test(\"-8254390271\", 26, Up, \"-123\", Less);\n        test(\"-8254390271\", 26, Floor, \"-123\", Less);\n        test(\"-8254390271\", 26, Ceiling, \"-122\", Greater);\n        test(\"-8254390271\", 26, Nearest, \"-123\", Less);\n\n        test(\"-8254390272\", 26, Down, \"-123\", Equal);\n        test(\"-8254390272\", 26, Up, \"-123\", Equal);\n        test(\"-8254390272\", 26, Floor, \"-123\", Equal);\n        test(\"-8254390272\", 26, Ceiling, \"-123\", Equal);\n        test(\"-8254390272\", 26, Nearest, \"-123\", Equal);\n        test(\"-8254390272\", 26, Exact, \"-123\", Equal);\n\n        test(\"-8254390273\", 26, Down, \"-123\", Greater);\n        test(\"-8254390273\", 26, Up, \"-124\", Less);\n        test(\"-8254390273\", 26, Floor, \"-124\", Less);\n        test(\"-8254390273\", 26, Ceiling, \"-123\", Greater);\n        test(\"-8254390273\", 26, Nearest, \"-123\", Greater);\n\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Down,\n            \"-122\",\n            Greater,\n        );\n        test(\"-155921023828072216384094494261247\", 100, Up, \"-123\", Less);\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Floor,\n            \"-123\",\n            Less,\n        );\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Ceiling,\n            \"-122\",\n            Greater,\n        );\n        test(\n            \"-155921023828072216384094494261247\",\n            100,\n            Nearest,\n            \"-123\",\n            Less,\n        );\n\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Down,\n            \"-123\",\n            Equal,\n        );\n        test(\"-155921023828072216384094494261248\", 100, Up, \"-123\", Equal);\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Floor,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Ceiling,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Nearest,\n            \"-123\",\n            Equal,\n        );\n        test(\n            \"-155921023828072216384094494261248\",\n            100,\n            Exact,\n            \"-123\",\n            Equal,\n        );\n\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Down,\n            \"-123\",\n            Greater,\n        );\n        test(\"-155921023828072216384094494261249\", 100, Up, \"-124\", Less);\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Floor,\n            \"-124\",\n            Less,\n        );\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Ceiling,\n            \"-123\",\n            Greater,\n        );\n        test(\n            \"-155921023828072216384094494261249\",\n            100,\n            Nearest,\n            \"-123\",\n            Greater,\n        );\n\n        test(\"-4294967295\", 1, Down, \"-2147483647\", Greater);\n        test(\"-4294967295\", 1, Up, \"-2147483648\", Less);\n        test(\"-4294967295\", 1, Floor, \"-2147483648\", Less);\n        test(\"-4294967295\", 1, Ceiling, \"-2147483647\", Greater);\n        test(\"-4294967295\", 1, Nearest, \"-2147483648\", Less);\n\n        test(\"-4294967296\", 1, Down, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Up, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Floor, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Ceiling, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Nearest, \"-2147483648\", Equal);\n        test(\"-4294967296\", 1, Exact, \"-2147483648\", Equal);\n\n        test(\"-4294967297\", 1, Down, \"-2147483648\", Greater);\n        test(\"-4294967297\", 1, Up, \"-2147483649\", Less);\n        test(\"-4294967297\", 1, Floor, \"-2147483649\", Less);\n        test(\"-4294967297\", 1, Ceiling, \"-2147483648\", Greater);\n        test(\"-4294967297\", 1, Nearest, \"-2147483648\", Greater);\n\n        test(\"-1000000000000\", 0, Down, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Up, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Floor, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Ceiling, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Nearest, \"-1000000000000\", Equal);\n        test(\"-1000000000000\", 0, Exact, \"-1000000000000\", Equal);\n\n        test(\"-7999999999999\", 3, Down, \"-999999999999\", Greater);\n        test(\"-7999999999999\", 3, Up, \"-1000000000000\", Less);\n        test(\"-7999999999999\", 3, Floor, \"-1000000000000\", Less);\n        test(\"-7999999999999\", 3, Ceiling, \"-999999999999\", Greater);\n        test(\"-7999999999999\", 3, Nearest, \"-1000000000000\", Less);\n\n        test(\"-8000000000000\", 3, Down, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Up, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Floor, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Ceiling, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Nearest, \"-1000000000000\", Equal);\n        test(\"-8000000000000\", 3, Exact, \"-1000000000000\", Equal);\n\n        test(\"-8000000000001\", 3, Down, \"-1000000000000\", Greater);\n        test(\"-8000000000001\", 3, Up, \"-1000000000001\", Less);\n        test(\"-8000000000001\", 3, Floor, \"-1000000000001\", Less);\n        test(\"-8000000000001\", 3, Ceiling, \"-1000000000000\", Greater);\n        test(\"-8000000000001\", 3, Nearest, \"-1000000000000\", Greater);\n\n        test(\"-16777216000000000000\", 24, Down, \"-1000000000000\", Equal);\n        test(\"-16777216000000000000\", 24, Up, \"-1000000000000\", Equal);\n        test(\"-16777216000000000000\", 24, Floor, \"-1000000000000\", Equal);\n        test(\n            \"-16777216000000000000\",\n            24,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-16777216000000000000\",\n            24,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-16777216000000000000\", 24, Exact, \"-1000000000000\", Equal);\n\n        test(\"-33554432000000000000\", 25, Down, \"-1000000000000\", Equal);\n        test(\"-33554432000000000000\", 25, Up, \"-1000000000000\", Equal);\n        test(\"-33554432000000000000\", 25, Floor, \"-1000000000000\", Equal);\n        test(\n            \"-33554432000000000000\",\n            25,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-33554432000000000000\",\n            25,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\"-33554432000000000000\", 25, Exact, \"-1000000000000\", Equal);\n\n        test(\"-2147483648000000000000\", 31, Down, \"-1000000000000\", Equal);\n        test(\"-2147483648000000000000\", 31, Up, \"-1000000000000\", Equal);\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-2147483648000000000000\",\n            31,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\"-4294967296000000000000\", 32, Down, \"-1000000000000\", Equal);\n        test(\"-4294967296000000000000\", 32, Up, \"-1000000000000\", Equal);\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-4294967296000000000000\",\n            32,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\"-8589934592000000000000\", 33, Down, \"-1000000000000\", Equal);\n        test(\"-8589934592000000000000\", 33, Up, \"-1000000000000\", Equal);\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-8589934592000000000000\",\n            33,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Down,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Up,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Floor,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Ceiling,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Nearest,\n            \"-1000000000000\",\n            Equal,\n        );\n        test(\n            \"-1267650600228229401496703205376000000000000\",\n            100,\n            Exact,\n            \"-1000000000000\",\n            Equal,\n        );\n\n        test(\"-1000000000000\", 10, Down, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Up, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Floor, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Ceiling, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Nearest, \"-976562500\", Equal);\n        test(\"-1000000000000\", 10, Exact, \"-976562500\", Equal);\n\n        test(\"-980657949\", 72, Down, \"0\", Greater);\n        test(\"-980657949\", 72, Up, \"-1\", Less);\n        test(\"-980657949\", 72, Floor, \"-1\", Less);\n        test(\"-980657949\", 72, Ceiling, \"0\", Greater);\n        test(\"-980657949\", 72, Nearest, \"0\", Greater);\n\n        test(\"-4294967295\", 31, Down, \"-1\", Greater);\n        test(\"-4294967295\", 31, Up, \"-2\", Less);\n        test(\"-4294967295\", 31, Floor, \"-2\", Less);\n        test(\"-4294967295\", 31, Ceiling, \"-1\", Greater);\n        test(\"-4294967295\", 31, Nearest, \"-2\", Less);\n\n        test(\"-4294967295\", 32, Down, \"0\", Greater);\n        test(\"-4294967295\", 32, Up, \"-1\", Less);\n        test(\"-4294967295\", 32, Floor, \"-1\", Less);\n        test(\"-4294967295\", 32, Ceiling, \"0\", Greater);\n        test(\"-4294967295\", 32, Nearest, \"-1\", Less);\n\n        test(\"-4294967296\", 32, Down, \"-1\", Equal);\n        test(\"-4294967296\", 32, Up, \"-1\", Equal);\n        test(\"-4294967296\", 32, Floor, \"-1\", Equal);\n        test(\"-4294967296\", 32, Ceiling, \"-1\", Equal);\n        test(\"-4294967296\", 32, Nearest, \"-1\", Equal);\n        test(\"-4294967296\", 32, Exact, \"-1\", Equal);\n\n        test(\"-4294967296\", 33, Down, \"0\", Greater);\n        test(\"-4294967296\", 33, Up, \"-1\", Less);\n        test(\"-4294967296\", 33, Floor, \"-1\", Less);\n        test(\"-4294967296\", 33, Ceiling, \"0\", Greater);\n        test(\"-4294967296\", 33, Nearest, \"0\", Greater);\n\n        test(\"0\", -10, Exact, \"0\", Equal);\n        test(\"123\", -1, Exact, \"246\", Equal);\n        test(\"123\", -2, Exact, \"492\", Equal);\n        test(\"123\", -25, Exact, \"4127195136\", Equal);\n        test(\"123\", -26, Exact, \"8254390272\", Equal);\n        test(\n            \"123\",\n            -100,\n            Exact,\n            \"155921023828072216384094494261248\",\n            Equal,\n        );\n        test(\"2147483648\", -1, Exact, \"4294967296\", Equal);\n        test(\"1000000000000\", -3, Exact, \"8000000000000\", Equal);\n        test(\"1000000000000\", -24, Exact, \"16777216000000000000\", Equal);\n        test(\"1000000000000\", -25, Exact, \"33554432000000000000\", Equal);\n        test(\"1000000000000\", -31, Exact, \"2147483648000000000000\", Equal);\n        test(\"1000000000000\", -32, Exact, \"4294967296000000000000\", Equal);\n        test(\"1000000000000\", -33, Exact, \"8589934592000000000000\", Equal);\n        test(\n            \"1000000000000\",\n            -100,\n            Exact,\n            \"1267650600228229401496703205376000000000000\",\n            Equal,\n        );\n\n        test(\"-123\", -1, Exact, \"-246\", Equal);\n        test(\"-123\", -2, Exact, \"-492\", Equal);\n        test(\"-123\", -25, Exact, \"-4127195136\", Equal);\n        test(\"-123\", -26, Exact, \"-8254390272\", Equal);\n        test(\n            \"-123\",\n            -100,\n            Exact,\n            \"-155921023828072216384094494261248\",\n            Equal,\n        );\n        test(\"-2147483648\", -1, Exact, \"-4294967296\", Equal);\n        test(\"-1000000000000\", -3, Exact, \"-8000000000000\", Equal);\n        test(\"-1000000000000\", -24, Exact, \"-16777216000000000000\", Equal);\n        test(\"-1000000000000\", -25, Exact, \"-33554432000000000000\", Equal);\n        test(\n            \"-1000000000000\",\n            -31,\n            Exact,\n            \"-2147483648000000000000\",\n            Equal,\n        );\n        test(\n            \"-1000000000000\",\n            -32,\n            Exact,\n            \"-4294967296000000000000\",\n            Equal,\n        );\n        test(\n            \"-1000000000000\",\n            -33,\n            Exact,\n            \"-8589934592000000000000\",\n            Equal,\n        );\n        test(\n            \"-1000000000000\",\n            -100,\n            Exact,\n            \"-1267650600228229401496703205376000000000000\",\n            Equal,\n        );\n    };\n}\n\n#[test]\nfn test_shr_round_signed() {\n    apply_to_signeds!(test_shr_round_signed_helper);\n}\n\nmacro_rules! shr_round_signed_fail_helper {\n    ($t:ident) => {\n        assert_panic!(Integer::from(-123).shr_round_assign($t::ONE, Exact));\n        assert_panic!(Integer::from(-123).shr_round_assign($t::exact_from(100), Exact));\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::ONE, Exact)\n        );\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::exact_from(100), Exact)\n        );\n        assert_panic!(Integer::from(-123).shr_round($t::ONE, Exact));\n        assert_panic!(Integer::from(-123).shr_round($t::exact_from(100), Exact));\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round($t::ONE, Exact)\n        );\n        assert_panic!(\n            Integer::from_str(\"-1000000000001\")\n                .unwrap()\n                .shr_round($t::exact_from(100), Exact)\n        );\n        assert_panic!((&Integer::from(-123)).shr_round($t::ONE, Exact));\n        assert_panic!((&Integer::from(-123)).shr_round($t::exact_from(100), Exact));\n        assert_panic!((&Integer::from_str(\"-1000000000001\").unwrap()).shr_round($t::ONE, Exact));\n        assert_panic!(\n            (&Integer::from_str(\"-1000000000001\").unwrap()).shr_round($t::exact_from(100), Exact)\n        );\n    };\n}\n\n#[test]\nfn shr_round_signed_fail() {\n    apply_to_signeds!(shr_round_signed_fail_helper);\n}\n\nfn shr_round_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    Integer: Shl<T, Output = Integer> + ShrRound<T, Output = Integer> + ShrRoundAssign<T>,\n    for<'a> &'a Integer: Shl<T, Output = Integer> + ShrRound<T, Output = Integer>,\n    Natural: Shl<T, Output = Natural>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n    SignedLimb: ShrRound<T, Output = SignedLimb>,\n{\n    integer_unsigned_rounding_mode_triple_gen_var_2::<T>().test_properties(|(n, u, rm)| {\n        let mut mut_n = n.clone();\n        let o = mut_n.shr_round_assign(u, rm);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let (shifted_alt, o_alt) = (&n).shr_round(u, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        let (shifted_alt, o_alt) = n.clone().shr_round(u, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        assert!(shifted.le_abs(&n));\n        let (s_alt, o_alt) = (-&n).shr_round(u, -rm);\n        assert_eq!(-s_alt, shifted);\n        assert_eq!(o_alt, o.reverse());\n        assert_eq!((&n).div_round(Integer::ONE << u, rm), (shifted.clone(), o));\n\n        assert_eq!(n.divisible_by_power_of_2(u.exact_into()), o == Equal);\n        match (n >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        assert_eq!((shifted << u).cmp(&n), o);\n    });\n\n    integer_unsigned_pair_gen_var_2::<T>().test_properties(|(n, u)| {\n        let left_shifted = &n << u;\n        let no = (n, Equal);\n        assert_eq!((&left_shifted).shr_round(u, Down), no);\n        assert_eq!((&left_shifted).shr_round(u, Up), no);\n        assert_eq!((&left_shifted).shr_round(u, Floor), no);\n        assert_eq!((&left_shifted).shr_round(u, Ceiling), no);\n        assert_eq!((&left_shifted).shr_round(u, Nearest), no);\n        assert_eq!((&left_shifted).shr_round(u, Exact), no);\n    });\n\n    integer_unsigned_pair_gen_var_5::<T>().test_properties(|(n, u)| {\n        let floor = (&n).shr_round(u, Floor);\n        assert_eq!(floor.1, Less);\n        let ceiling = (&floor.0 + Integer::ONE, Greater);\n        assert_eq!((&n).shr_round(u, Ceiling), ceiling);\n        if n >= 0 {\n            assert_eq!((&n).shr_round(u, Up), ceiling);\n            assert_eq!((&n).shr_round(u, Down), floor);\n        } else {\n            assert_eq!((&n).shr_round(u, Up), floor);\n            assert_eq!((&n).shr_round(u, Down), ceiling);\n        }\n        let nearest = n.shr_round(u, Nearest);\n        assert!(nearest == floor || nearest == ceiling);\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).shr_round(T::ZERO, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(u, rm)| {\n        assert_eq!(Integer::ZERO.shr_round(u, rm), (Integer::ZERO, Equal));\n    });\n\n    natural_unsigned_rounding_mode_triple_gen_var_1::<T>().test_properties(|(n, u, rm)| {\n        let (s, o) = (&n).shr_round(u, rm);\n        assert_eq!((Integer::from(s), o), Integer::from(n).shr_round(u, rm));\n    });\n\n    signed_unsigned_rounding_mode_triple_gen_var_2::<SignedLimb, T>().test_properties(\n        |(n, u, rm)| {\n            let (s, o) = n.shr_round(u, rm);\n            assert_eq!((Integer::from(s), o), Integer::from(n).shr_round(u, rm));\n        },\n    );\n}\n\nfn shr_round_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    Integer: Shl<T, Output = Integer> + ShrRound<T, Output = Integer> + ShrRoundAssign<T>,\n    for<'a> &'a Integer: ShrRound<T, Output = Integer>,\n    Natural: Shl<T, Output = Natural>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n    SignedLimb: ArithmeticCheckedShr<T, Output = SignedLimb> + ShrRound<T, Output = SignedLimb>,\n{\n    integer_signed_rounding_mode_triple_gen_var_2::<T>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n.clone();\n        let o = mut_n.shr_round_assign(i, rm);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let (shifted_alt, o_alt) = (&n).shr_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        let (shifted_alt, o_alt) = n.clone().shr_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        let (s, o_alt) = (-&n).shr_round(i, -rm);\n        assert_eq!(-s, shifted);\n        assert_eq!(o_alt, o.reverse());\n\n        assert_eq!(\n            i <= T::ZERO || n.divisible_by_power_of_2(i.exact_into()),\n            o == Equal\n        );\n\n        match (n >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if i >= T::ZERO {\n            assert_eq!((shifted << i).cmp(&n), o);\n        }\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).shr_round(T::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(i, rm)| {\n        assert_eq!(Integer::ZERO.shr_round(i, rm), (Integer::ZERO, Equal));\n    });\n\n    natural_signed_rounding_mode_triple_gen_var_2::<T>().test_properties(|(n, i, rm)| {\n        let (s, o) = (&n).shr_round(i, rm);\n        assert_eq!((Integer::from(s), o), Integer::from(n).shr_round(i, rm));\n    });\n\n    signed_signed_rounding_mode_triple_gen_var_3::<SignedLimb, T>().test_properties(\n        |(n, i, rm)| {\n            if n.arithmetic_checked_shr(i).is_some() {\n                let (s, o) = n.shr_round(i, rm);\n                assert_eq!((Integer::from(s), o), Integer::from(n).shr_round(i, rm));\n            }\n        },\n    );\n}\n\n#[test]\nfn shr_round_properties() {\n    apply_fn_to_unsigneds!(shr_round_properties_helper_unsigned);\n    apply_fn_to_signeds!(shr_round_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::arithmetic::sign::num_sign;\nuse num::BigInt;\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_sign() {\n    let test = |s, out| {\n        assert_eq!(Integer::from_str(s).unwrap().sign(), out);\n        assert_eq!(num_sign(&BigInt::from_str(s).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().cmp0(), out);\n    };\n    test(\"0\", Equal);\n    test(\"123\", Greater);\n    test(\"-123\", Less);\n    test(\"1000000000000\", Greater);\n    test(\"-1000000000000\", Less);\n}\n\n#[test]\nfn sign_properties() {\n    integer_gen().test_properties(|n| {\n        let sign = n.sign();\n        assert_eq!(rug::Integer::from(&n).cmp0(), sign);\n        assert_eq!(num_sign(&BigInt::from(&n)), sign);\n        assert_eq!(n.partial_cmp(&0), Some(sign));\n        assert_eq!((-n).sign(), sign.reverse());\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(Integer::from(i).sign(), i.sign());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingSqrt, CeilingSqrtAssign, CheckedRoot, CheckedSqrt, FloorRoot, FloorSqrt,\n    FloorSqrtAssign, Square,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One};\nuse malachite_base::test_util::generators::signed_gen_var_2;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{integer_gen_var_4, natural_gen};\nuse num::BigInt;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_floor_sqrt() {\n    let test = |s, out| {\n        let n = Integer::from_str(s).unwrap();\n        assert_eq!(n.clone().floor_sqrt().to_string(), out);\n        assert_eq!((&n).floor_sqrt().to_string(), out);\n\n        let mut n = n;\n        n.floor_sqrt_assign();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"2\", \"1\");\n    test(\"3\", \"1\");\n    test(\"4\", \"2\");\n    test(\"5\", \"2\");\n    test(\"10\", \"3\");\n    test(\"100\", \"10\");\n    test(\"1000000000\", \"31622\");\n    test(\"152415765279683\", \"12345677\");\n    test(\"152415765279684\", \"12345678\");\n    test(\"152415765279685\", \"12345678\");\n    test(\n        \"10000000000000000000000000000000000000000\",\n        \"100000000000000000000\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000\",\n        \"316227766016837933199\",\n    );\n}\n\n#[test]\npub fn floor_sqrt_fail() {\n    assert_panic!(Integer::NEGATIVE_ONE.floor_sqrt());\n}\n\n#[test]\nfn test_ceiling_sqrt() {\n    let test = |s, out| {\n        let n = Integer::from_str(s).unwrap();\n        assert_eq!(n.clone().ceiling_sqrt().to_string(), out);\n        assert_eq!((&n).ceiling_sqrt().to_string(), out);\n\n        let mut n = n;\n        n.ceiling_sqrt_assign();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"2\", \"2\");\n    test(\"3\", \"2\");\n    test(\"4\", \"2\");\n    test(\"5\", \"3\");\n    test(\"10\", \"4\");\n    test(\"100\", \"10\");\n    test(\"1000000000\", \"31623\");\n    test(\"152415765279683\", \"12345678\");\n    test(\"152415765279684\", \"12345678\");\n    test(\"152415765279685\", \"12345679\");\n    test(\n        \"10000000000000000000000000000000000000000\",\n        \"100000000000000000000\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000\",\n        \"316227766016837933200\",\n    );\n}\n\n#[test]\npub fn ceiling_sqrt_fail() {\n    assert_panic!(Integer::NEGATIVE_ONE.ceiling_sqrt());\n}\n\n#[allow(clippy::redundant_closure_for_method_calls)]\n#[test]\nfn test_checked_sqrt() {\n    let test = |s, out: Option<&str>| {\n        let n = Integer::from_str(s).unwrap();\n        let out = out.map(|s| s.to_string());\n\n        assert_eq!(n.clone().checked_sqrt().map(|x| x.to_string()), out);\n        assert_eq!((&n).checked_sqrt().map(|x| x.to_string()), out);\n    };\n    test(\"0\", Some(\"0\"));\n    test(\"1\", Some(\"1\"));\n    test(\"2\", None);\n    test(\"3\", None);\n    test(\"4\", Some(\"2\"));\n    test(\"5\", None);\n    test(\"10\", None);\n    test(\"100\", Some(\"10\"));\n    test(\"1000000000\", None);\n    test(\"152415765279683\", None);\n    test(\"152415765279684\", Some(\"12345678\"));\n    test(\"152415765279685\", None);\n    test(\n        \"10000000000000000000000000000000000000000\",\n        Some(\"100000000000000000000\"),\n    );\n    test(\"100000000000000000000000000000000000000000\", None);\n}\n\n#[test]\npub fn checked_sqrt_fail() {\n    assert_panic!(Integer::NEGATIVE_ONE.checked_sqrt());\n}\n\n#[test]\nfn floor_sqrt_properties() {\n    integer_gen_var_4().test_properties(|n| {\n        let sqrt = n.clone().floor_sqrt();\n        assert_eq!((&n).floor_sqrt(), sqrt);\n        let mut n_alt = n.clone();\n        n_alt.floor_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!((&n).floor_root(2), sqrt);\n        assert_eq!(Integer::from(&BigInt::from(&n).sqrt()), sqrt);\n        assert_eq!(Integer::from(&rug::Integer::from(&n).sqrt()), sqrt);\n\n        let square = (&sqrt).square();\n        let ceiling_sqrt = (&n).ceiling_sqrt();\n        if square == n {\n            assert_eq!(ceiling_sqrt, sqrt);\n        } else {\n            assert_eq!(ceiling_sqrt, &sqrt + Integer::ONE);\n        }\n        assert!(square <= n);\n        assert!((sqrt + Integer::ONE).square() > n);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).floor_sqrt(), Integer::from(n).floor_sqrt());\n    });\n\n    signed_gen_var_2::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.floor_sqrt(), Integer::from(i).floor_sqrt());\n    });\n}\n\n#[test]\nfn ceiling_sqrt_properties() {\n    integer_gen_var_4().test_properties(|n| {\n        let sqrt = n.clone().ceiling_sqrt();\n        assert_eq!((&n).ceiling_sqrt(), sqrt);\n        let mut n_alt = n.clone();\n        n_alt.ceiling_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!((&n).ceiling_root(2), sqrt);\n        let square = (&sqrt).square();\n        let floor_sqrt = (&n).floor_sqrt();\n        if square == n {\n            assert_eq!(floor_sqrt, sqrt);\n        } else {\n            assert_eq!(floor_sqrt, &sqrt - Integer::ONE);\n        }\n        assert!(square >= n);\n        if n != 0 {\n            assert!((sqrt - Integer::ONE).square() < n);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).ceiling_sqrt(), Integer::from(n).ceiling_sqrt());\n    });\n\n    signed_gen_var_2::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.ceiling_sqrt(), Integer::from(i).ceiling_sqrt());\n    });\n}\n\n#[test]\nfn checked_sqrt_properties() {\n    integer_gen_var_4().test_properties(|n| {\n        let sqrt = n.clone().checked_sqrt();\n        assert_eq!((&n).checked_sqrt(), sqrt);\n        assert_eq!((&n).checked_root(2), sqrt);\n        if let Some(sqrt) = sqrt {\n            assert_eq!((&sqrt).square(), n);\n            assert_eq!((&n).floor_sqrt(), sqrt);\n            assert_eq!(n.ceiling_sqrt(), sqrt);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(\n            (&n).checked_sqrt().map(Integer::from),\n            Integer::from(n).checked_sqrt()\n        );\n    });\n\n    signed_gen_var_2::<SignedLimb>().test_properties(|i| {\n        assert_eq!(\n            i.checked_sqrt().map(Integer::from),\n            Integer::from(i).checked_sqrt()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, CheckedSqrt, Square, SquareAssign};\nuse malachite_base::test_util::generators::signed_gen_var_10;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen, natural_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_square() {\n    let test = |x, out| {\n        let u = Integer::from_str(x).unwrap();\n\n        assert_eq!(u.clone().square().to_string(), out);\n        assert_eq!((&u).square().to_string(), out);\n\n        let mut x = u;\n        x.square_assign();\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"2\", \"4\");\n    test(\"3\", \"9\");\n    test(\"10\", \"100\");\n    test(\"123\", \"15129\");\n    test(\"1000\", \"1000000\");\n    test(\"123456789\", \"15241578750190521\");\n\n    test(\"-1\", \"1\");\n    test(\"-2\", \"4\");\n    test(\"-3\", \"9\");\n    test(\"-10\", \"100\");\n    test(\"-123\", \"15129\");\n    test(\"-1000\", \"1000000\");\n    test(\"-123456789\", \"15241578750190521\");\n}\n\n#[test]\nfn square_properties() {\n    integer_gen().test_properties(|x| {\n        let square = (&x).square();\n        assert!(square.is_valid());\n\n        let mut mut_x = x.clone();\n        mut_x.square_assign();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, square);\n\n        assert_eq!(&x * &x, square);\n        assert_eq!((-&x).square(), square);\n        assert!(square >= 0);\n        assert!(square >= x);\n\n        assert_eq!(square.checked_sqrt(), Some(x.abs()));\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        let x_squared = (&x).square();\n        let y_squared = (&y).square();\n        let xy = &x * &y;\n        assert_eq!((&x + &y).square(), &x_squared + &y_squared + (&xy << 1));\n        assert_eq!((&x - &y).square(), &x_squared + &y_squared - (&xy << 1));\n        assert_eq!(xy.square(), x_squared * y_squared);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).square(), Integer::from(x).square());\n    });\n\n    signed_gen_var_10::<Limb, SignedLimb>().test_properties(|x| {\n        assert_eq!(x.square(), Integer::from(x).square());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{SignedDoubleLimb, SignedLimb};\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen, natural_pair_gen};\nuse num::BigInt;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_sub() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n -= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n -= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() - v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u - v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() - &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u - &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigInt::from_str(s).unwrap() - BigInt::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() - rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"-123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"-456\", \"579\");\n    test(\"1000000000000\", \"-123\", \"1000000000123\");\n    test(\"123\", \"-1000000000000\", \"1000000000123\");\n    test(\"12345678987654321\", \"-314159265358979\", \"12659838253013300\");\n    test(\"0\", \"123\", \"-123\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"-333\");\n    test(\"1000000000000\", \"123\", \"999999999877\");\n    test(\"123\", \"1000000000000\", \"-999999999877\");\n    test(\"12345678987654321\", \"314159265358979\", \"12031519722295342\");\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn sub_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let diff_val_val = x.clone() - y.clone();\n        let diff_val_ref = x.clone() - &y;\n        let diff_ref_val = &x - y.clone();\n        let diff = &x - &y;\n        assert!(diff_val_val.is_valid());\n        assert!(diff_val_ref.is_valid());\n        assert!(diff_ref_val.is_valid());\n        assert!(diff.is_valid());\n        assert_eq!(diff_val_val, diff);\n        assert_eq!(diff_val_ref, diff);\n        assert_eq!(diff_ref_val, diff);\n\n        let mut mut_x = x.clone();\n        mut_x -= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n        let mut mut_x = x.clone();\n        mut_x -= &y;\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x -= rug::Integer::from(&y);\n        assert_eq!(Integer::from(&mut_x), diff);\n\n        assert_eq!(Integer::from(&(BigInt::from(&x) - BigInt::from(&y))), diff);\n        assert_eq!(\n            Integer::from(&(rug::Integer::from(&x) - rug::Integer::from(&y))),\n            diff\n        );\n        assert_eq!(&y - &x, -&diff);\n        assert_eq!(&diff + &y, x);\n        assert_eq!(x - diff, y);\n    });\n\n    integer_gen().test_properties(|ref x| {\n        assert_eq!(x - Integer::ZERO, *x);\n        assert_eq!(Integer::ZERO - x, -x);\n        assert_eq!(x - -x, x << 1);\n        assert_eq!(x - x, 0);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        if x >= y {\n            assert_eq!(&x - &y, Integer::from(x) - Integer::from(y));\n        } else {\n            assert_eq!(-(&y - &x), Integer::from(x) - Integer::from(y));\n        }\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(SignedDoubleLimb::from(x) - SignedDoubleLimb::from(y)),\n            Integer::from(x) - Integer::from(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedSubMul, SubMul, SubMulAssign, UnsignedAbs};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::test_util::generators::{\n    signed_triple_gen, signed_triple_gen_var_2, unsigned_vec_triple_gen_var_39,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::arithmetic::sub_mul::{\n    limbs_overflowing_sub_mul, limbs_overflowing_sub_mul_in_place_left,\n    limbs_overflowing_sub_mul_limb, limbs_overflowing_sub_mul_limb_in_place_either,\n    limbs_overflowing_sub_mul_limb_in_place_left, limbs_overflowing_sub_mul_limb_in_place_right,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen, integer_triple_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_limbs_overflowing_sub_mul_limb() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], z: Limb, result: &[Limb], sign: bool| {\n        let (result_alt, sign_alt) = limbs_overflowing_sub_mul_limb(xs_before, ys_before, z);\n        assert_eq!(&result_alt, &result);\n        assert_eq!(sign_alt, sign);\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_overflowing_sub_mul_limb_in_place_left(&mut xs, ys_before, z),\n            sign\n        );\n        assert_eq!(xs, result);\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_overflowing_sub_mul_limb_in_place_right(xs_before, &mut ys, z),\n            sign\n        );\n        assert_eq!(ys, result);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        test(&[123, 456], &[123], 4, &[4294966927, 455, 0], true);\n        test(&[123, 456], &[123], u32::MAX, &[246, 333, 0], true);\n        test(&[123], &[123], 1, &[0, 0], true);\n        test(&[123], &[123], 4, &[369, 0], false);\n        test(\n            &[123],\n            &[123, 456],\n            u32::MAX,\n            &[4294967050, 4294966962, 455],\n            false,\n        );\n        test(\n            &[8191],\n            &[0, 4160749568],\n            1610678208,\n            &[4294959105, 4294967295, 1560344513],\n            false,\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[18446744073709551615],\n            &[0, 18446744056529682432],\n            18446742974197923840,\n            &[1, 18446744073709551615, 18446742957018055679],\n            false,\n        );\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_overflowing_sub_mul_limb_in_place_either() {\n    let test = |xs_before: &[Limb],\n                ys_before: &[Limb],\n                z: Limb,\n                right: bool,\n                xs_after: &[Limb],\n                ys_after: &[Limb],\n                sign| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_overflowing_sub_mul_limb_in_place_either(&mut xs, &mut ys, z),\n            (right, sign)\n        );\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(\n        &[123, 456],\n        &[123],\n        4,\n        false,\n        &[4294966927, 455, 0],\n        &[123],\n        true,\n    );\n    test(\n        &[123, 456],\n        &[123],\n        u32::MAX,\n        false,\n        &[246, 333, 0],\n        &[123],\n        true,\n    );\n    test(&[123], &[123], 1, false, &[0, 0], &[123], true);\n    test(&[123], &[123], 4, false, &[369, 0], &[123], false);\n    test(\n        &[123],\n        &[123, 456],\n        u32::MAX,\n        true,\n        &[123],\n        &[4294967050, 4294966962, 455],\n        false,\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_overflowing_sub_mul_and_limbs_overflowing_sub_mul_in_place_left() {\n    let test = |xs_before: &[Limb], ys: &[Limb], zs: &[Limb], result: &[Limb], sign: bool| {\n        let (result_alt, sign_alt) = limbs_overflowing_sub_mul(xs_before, ys, zs);\n        assert_eq!(result_alt, result);\n        assert_eq!(sign_alt, sign);\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_overflowing_sub_mul_in_place_left(&mut xs, ys, zs),\n            sign\n        );\n        assert_eq!(xs, result);\n    };\n    test(\n        &[123, 456],\n        &[123, 789],\n        &[321, 654],\n        &[39360, 333255, 516006],\n        false,\n    );\n    test(\n        &[123, 456, 789, 987, 654],\n        &[123, 789],\n        &[321, 654],\n        &[4294927936, 4294634040, 4294452078, 986, 654],\n        true,\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_overflowing_sub_mul_fail_1() {\n    limbs_overflowing_sub_mul(&[10, 10], &[], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_overflowing_sub_mul_fail_2() {\n    limbs_overflowing_sub_mul(&[10, 10], &[10, 10], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_overflowing_sub_mul_in_place_left_fail_1() {\n    let mut xs = vec![10, 10];\n    limbs_overflowing_sub_mul_in_place_left(&mut xs, &[], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_overflowing_sub_mul_in_place_left_fail_2() {\n    let mut xs = vec![10, 10];\n    limbs_overflowing_sub_mul_in_place_left(&mut xs, &[10, 10], &[]);\n}\n\n#[test]\nfn test_sub_mul() {\n    let test = |r, s, t, out| {\n        let u = Integer::from_str(r).unwrap();\n        let v = Integer::from_str(s).unwrap();\n        let w = Integer::from_str(t).unwrap();\n\n        let mut a = u.clone();\n        a.sub_mul_assign(v.clone(), w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.sub_mul_assign(v.clone(), &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.sub_mul_assign(&v, w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.sub_mul_assign(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().sub_mul(v.clone(), w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().sub_mul(v.clone(), &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().sub_mul(&v, w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().sub_mul(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = (&u).sub_mul(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n    };\n    test(\"0\", \"0\", \"0\", \"0\");\n    test(\"0\", \"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"5\", \"123\");\n    test(\"123\", \"-5\", \"1\", \"128\");\n    test(\"123\", \"-5\", \"100\", \"623\");\n    test(\"10\", \"-3\", \"4\", \"22\");\n    test(\"1000000000000\", \"0\", \"123\", \"1000000000000\");\n    test(\"1000000000000\", \"-1\", \"123\", \"1000000000123\");\n    test(\"1000000000000\", \"-123\", \"1\", \"1000000000123\");\n    test(\"1000000000000\", \"-123\", \"100\", \"1000000012300\");\n    test(\"1000000000000\", \"-100\", \"123\", \"1000000012300\");\n    test(\"1000000000000\", \"-65536\", \"65536\", \"1004294967296\");\n    test(\"1000000000000\", \"-1000000000000\", \"0\", \"1000000000000\");\n    test(\"1000000000000\", \"-1000000000000\", \"1\", \"2000000000000\");\n    test(\"1000000000000\", \"-1000000000000\", \"100\", \"101000000000000\");\n    test(\"0\", \"-1000000000000\", \"100\", \"100000000000000\");\n    test(\n        \"1000000000000\",\n        \"-65536\",\n        \"1000000000000\",\n        \"65537000000000000\",\n    );\n    test(\n        \"1000000000000\",\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"1000000000001000000000000\",\n    );\n    test(\n        \"0\",\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"1000000000000000000000000\",\n    );\n\n    test(\"123\", \"5\", \"-1\", \"128\");\n    test(\"123\", \"5\", \"-100\", \"623\");\n    test(\"10\", \"3\", \"-4\", \"22\");\n    test(\"1000000000000\", \"1\", \"-123\", \"1000000000123\");\n    test(\"1000000000000\", \"123\", \"-1\", \"1000000000123\");\n    test(\"1000000000000\", \"123\", \"-100\", \"1000000012300\");\n    test(\"1000000000000\", \"100\", \"-123\", \"1000000012300\");\n    test(\"1000000000000\", \"65536\", \"-65536\", \"1004294967296\");\n    test(\"1000000000000\", \"1000000000000\", \"-1\", \"2000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"-100\", \"101000000000000\");\n    test(\"0\", \"1000000000000\", \"-100\", \"100000000000000\");\n    test(\n        \"1000000000000\",\n        \"65536\",\n        \"-1000000000000\",\n        \"65537000000000000\",\n    );\n    test(\n        \"1000000000000\",\n        \"1000000000000\",\n        \"-1000000000000\",\n        \"1000000000001000000000000\",\n    );\n    test(\n        \"0\",\n        \"1000000000000\",\n        \"-1000000000000\",\n        \"1000000000000000000000000\",\n    );\n\n    test(\"0\", \"0\", \"-123\", \"0\");\n    test(\"123\", \"0\", \"-5\", \"123\");\n    test(\"123\", \"5\", \"1\", \"118\");\n    test(\"123\", \"-5\", \"-1\", \"118\");\n    test(\"123\", \"5\", \"100\", \"-377\");\n    test(\"123\", \"-5\", \"-100\", \"-377\");\n    test(\"10\", \"3\", \"4\", \"-2\");\n    test(\"10\", \"-3\", \"-4\", \"-2\");\n    test(\"15\", \"3\", \"4\", \"3\");\n    test(\"15\", \"-3\", \"-4\", \"3\");\n    test(\"1000000000000\", \"0\", \"-123\", \"1000000000000\");\n    test(\"1000000000000\", \"1\", \"123\", \"999999999877\");\n    test(\"1000000000000\", \"-1\", \"-123\", \"999999999877\");\n    test(\"1000000000000\", \"123\", \"1\", \"999999999877\");\n    test(\"1000000000000\", \"-123\", \"-1\", \"999999999877\");\n    test(\"1000000000000\", \"123\", \"100\", \"999999987700\");\n    test(\"1000000000000\", \"-123\", \"-100\", \"999999987700\");\n    test(\"1000000000000\", \"100\", \"123\", \"999999987700\");\n    test(\"1000000000000\", \"-100\", \"-123\", \"999999987700\");\n    test(\"1000000000000\", \"65536\", \"65536\", \"995705032704\");\n    test(\"1000000000000\", \"-65536\", \"-65536\", \"995705032704\");\n    test(\"1000000000000\", \"1000000000000\", \"0\", \"1000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"-1000000000000\", \"-1\", \"0\");\n    test(\"1000000000000\", \"1000000000000\", \"100\", \"-99000000000000\");\n    test(\"1000000000000\", \"-1000000000000\", \"-100\", \"-99000000000000\");\n    test(\"0\", \"1000000000000\", \"100\", \"-100000000000000\");\n    test(\"4294967296\", \"1\", \"1\", \"4294967295\");\n    test(\"4294967296\", \"-1\", \"-1\", \"4294967295\");\n    test(\"3902609153\", \"88817093856604\", \"1\", \"-88813191247451\");\n    test(\"3902609153\", \"-88817093856604\", \"-1\", \"-88813191247451\");\n\n    test(\"-123\", \"0\", \"5\", \"-123\");\n    test(\"-123\", \"5\", \"1\", \"-128\");\n    test(\"-123\", \"5\", \"100\", \"-623\");\n    test(\"-10\", \"3\", \"4\", \"-22\");\n    test(\"-1000000000000\", \"0\", \"123\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1\", \"123\", \"-1000000000123\");\n    test(\"-1000000000000\", \"123\", \"1\", \"-1000000000123\");\n    test(\"-1000000000000\", \"123\", \"100\", \"-1000000012300\");\n    test(\"-1000000000000\", \"100\", \"123\", \"-1000000012300\");\n    test(\"-1000000000000\", \"65536\", \"65536\", \"-1004294967296\");\n    test(\"-1000000000000\", \"1000000000000\", \"0\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1000000000000\", \"1\", \"-2000000000000\");\n    test(\"-1000000000000\", \"1000000000000\", \"100\", \"-101000000000000\");\n    test(\n        \"-1000000000000\",\n        \"65536\",\n        \"1000000000000\",\n        \"-65537000000000000\",\n    );\n    test(\n        \"-1000000000000\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"-1000000000001000000000000\",\n    );\n    test(\n        \"0\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"-1000000000000000000000000\",\n    );\n\n    test(\"-123\", \"-5\", \"-1\", \"-128\");\n    test(\"-123\", \"-5\", \"-100\", \"-623\");\n    test(\"-10\", \"-3\", \"-4\", \"-22\");\n    test(\"-1000000000000\", \"-1\", \"-123\", \"-1000000000123\");\n    test(\"-1000000000000\", \"-123\", \"-1\", \"-1000000000123\");\n    test(\"-1000000000000\", \"-123\", \"-100\", \"-1000000012300\");\n    test(\"-1000000000000\", \"-100\", \"-123\", \"-1000000012300\");\n    test(\"-1000000000000\", \"-65536\", \"-65536\", \"-1004294967296\");\n    test(\"-1000000000000\", \"-1000000000000\", \"-1\", \"-2000000000000\");\n    test(\n        \"-1000000000000\",\n        \"-1000000000000\",\n        \"-100\",\n        \"-101000000000000\",\n    );\n    test(\n        \"-1000000000000\",\n        \"-65536\",\n        \"-1000000000000\",\n        \"-65537000000000000\",\n    );\n    test(\n        \"-1000000000000\",\n        \"-1000000000000\",\n        \"-1000000000000\",\n        \"-1000000000001000000000000\",\n    );\n\n    test(\"-123\", \"0\", \"-5\", \"-123\");\n    test(\"-123\", \"-5\", \"1\", \"-118\");\n    test(\"-123\", \"5\", \"-1\", \"-118\");\n    test(\"-123\", \"-5\", \"100\", \"377\");\n    test(\"-123\", \"5\", \"-100\", \"377\");\n    test(\"-10\", \"-3\", \"4\", \"2\");\n    test(\"-10\", \"3\", \"-4\", \"2\");\n    test(\"-15\", \"-3\", \"4\", \"-3\");\n    test(\"-15\", \"3\", \"-4\", \"-3\");\n    test(\"-1000000000000\", \"0\", \"-123\", \"-1000000000000\");\n    test(\"-1000000000000\", \"-1\", \"123\", \"-999999999877\");\n    test(\"-1000000000000\", \"1\", \"-123\", \"-999999999877\");\n    test(\"-1000000000000\", \"-123\", \"1\", \"-999999999877\");\n    test(\"-1000000000000\", \"123\", \"-1\", \"-999999999877\");\n    test(\"-1000000000000\", \"-123\", \"100\", \"-999999987700\");\n    test(\"-1000000000000\", \"123\", \"-100\", \"-999999987700\");\n    test(\"-1000000000000\", \"-100\", \"123\", \"-999999987700\");\n    test(\"-1000000000000\", \"100\", \"-123\", \"-999999987700\");\n    test(\"-1000000000000\", \"-65536\", \"65536\", \"-995705032704\");\n    test(\"-1000000000000\", \"65536\", \"-65536\", \"-995705032704\");\n    test(\"-1000000000000\", \"-1000000000000\", \"0\", \"-1000000000000\");\n    test(\"-1000000000000\", \"-1000000000000\", \"1\", \"0\");\n    test(\"-1000000000000\", \"1000000000000\", \"-1\", \"0\");\n    test(\"-1000000000000\", \"-1000000000000\", \"100\", \"99000000000000\");\n    test(\"-1000000000000\", \"1000000000000\", \"-100\", \"99000000000000\");\n    test(\"-4294967296\", \"-1\", \"1\", \"-4294967295\");\n    test(\"-4294967296\", \"1\", \"-1\", \"-4294967295\");\n    test(\"-3902609153\", \"-88817093856604\", \"1\", \"88813191247451\");\n    test(\"-3902609153\", \"88817093856604\", \"-1\", \"88813191247451\");\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"0\",\n    );\n    test(\n        \"18446744073709551615\",\n        \"340282366604025813406317257057592410112\",\n        \"18446742974197923840\",\n        \"-6277101355396255406250174417290596496345921599978512318465\",\n    );\n}\n\n#[test]\nfn limbs_overflowing_sub_mul_limb_properties() {\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties(|(a, b, c)| {\n        let (result, sign) = limbs_overflowing_sub_mul_limb(&a, &b, c);\n        let expected_result = Integer::from(Natural::from_owned_limbs_asc(a)).sub_mul(\n            Integer::from(Natural::from_owned_limbs_asc(b)),\n            Integer::from(c),\n        );\n        assert_eq!(sign, expected_result >= 0);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(result),\n            expected_result.unsigned_abs()\n        );\n    });\n}\n\n#[test]\nfn limbs_overflowing_sub_mul_limb_in_place_left_properties() {\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties(|(mut a, b, c)| {\n        let a_old = a.clone();\n        let sign = limbs_overflowing_sub_mul_limb_in_place_left(&mut a, &b, c);\n        let expected_result = Integer::from(Natural::from_owned_limbs_asc(a_old)).sub_mul(\n            Integer::from(Natural::from_owned_limbs_asc(b)),\n            Integer::from(c),\n        );\n        assert_eq!(sign, expected_result >= 0);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(a),\n            expected_result.unsigned_abs(),\n        );\n    });\n}\n\n#[test]\nfn limbs_overflowing_sub_mul_limb_in_place_right_properties() {\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties(|(a, mut b, c)| {\n        let b_old = b.clone();\n        let sign = limbs_overflowing_sub_mul_limb_in_place_right(&a, &mut b, c);\n        let expected_result = Integer::from(Natural::from_owned_limbs_asc(a)).sub_mul(\n            Integer::from(Natural::from_owned_limbs_asc(b_old)),\n            Integer::from(c),\n        );\n        assert_eq!(sign, expected_result >= 0);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(b),\n            expected_result.unsigned_abs()\n        );\n    });\n}\n\n#[test]\nfn limbs_overflowing_sub_mul_limb_in_place_either_properties() {\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties(|(mut a, mut b, c)| {\n        let a_old = a.clone();\n        let b_old = b.clone();\n        let (right, sign) = limbs_overflowing_sub_mul_limb_in_place_either(&mut a, &mut b, c);\n        let expected_result = Integer::from(Natural::from_limbs_asc(&a_old)).sub_mul(\n            Integer::from(Natural::from_limbs_asc(&b_old)),\n            Integer::from(c),\n        );\n        let result = Natural::from_owned_limbs_asc(if right {\n            assert_eq!(a_old, a);\n            b\n        } else {\n            assert_eq!(b_old, b);\n            a\n        });\n        assert_eq!(sign, expected_result >= 0);\n        assert_eq!(result, expected_result.unsigned_abs());\n    });\n}\n\n#[test]\nfn limbs_overflowing_sub_mul_properties() {\n    unsigned_vec_triple_gen_var_39().test_properties(|(a, b, c)| {\n        let (result, sign) = limbs_overflowing_sub_mul(&a, &b, &c);\n        let expected_result = Integer::from(Natural::from_owned_limbs_asc(a)).sub_mul(\n            Integer::from(Natural::from_owned_limbs_asc(b)),\n            Integer::from(Natural::from_owned_limbs_asc(c)),\n        );\n        if expected_result != 0 {\n            assert_eq!(sign, expected_result >= 0);\n        }\n        assert_eq!(\n            Natural::from_owned_limbs_asc(result),\n            expected_result.unsigned_abs()\n        );\n    });\n}\n\n#[test]\nfn limbs_overflowing_sub_mul_in_place_left_properties() {\n    unsigned_vec_triple_gen_var_39().test_properties(|(mut a, b, c)| {\n        let a_old = a.clone();\n        let sign = limbs_overflowing_sub_mul_in_place_left(&mut a, &b, &c);\n        let expected_result = Integer::from(Natural::from_owned_limbs_asc(a_old)).sub_mul(\n            Integer::from(Natural::from_owned_limbs_asc(b)),\n            Integer::from(Natural::from_owned_limbs_asc(c)),\n        );\n        if expected_result != 0 {\n            assert_eq!(sign, expected_result >= 0);\n        }\n        assert_eq!(\n            Natural::from_owned_limbs_asc(a),\n            expected_result.unsigned_abs()\n        );\n    });\n}\n\n#[test]\nfn sub_mul_properties() {\n    integer_triple_gen().test_properties(|(a, b, c)| {\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(b.clone(), c.clone());\n        assert!(mut_a.is_valid());\n        let result = mut_a;\n\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(b.clone(), &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(&b, c.clone());\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(&b, &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let result_alt = a.clone().sub_mul(b.clone(), c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result = a.clone().sub_mul(b.clone(), &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result = a.clone().sub_mul(&b, c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result = a.clone().sub_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result = (&a).sub_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert_eq!(&a - &b * &c, result);\n        assert_eq!((&a).sub_mul(&c, &b), result);\n        assert_eq!((&a).sub_mul(&(-&b), &(-&c)), result);\n        assert_eq!((-&a).sub_mul(&(-&b), &c), -&result);\n        assert_eq!((-a).sub_mul(b, -c), -result);\n    });\n\n    integer_gen().test_properties(|a| {\n        assert_eq!((&a).sub_mul(&a, &Integer::ONE), 0);\n        assert_eq!((&a).sub_mul(&(-&a), &Integer::NEGATIVE_ONE), 0);\n    });\n\n    integer_pair_gen().test_properties(|(a, b)| {\n        assert_eq!((&a).sub_mul(&Integer::ZERO, &b), a);\n        assert_eq!((&a).sub_mul(&Integer::ONE, &b), &a - &b);\n        assert_eq!(Integer::ZERO.sub_mul(&a, &b), -&a * &b);\n        assert_eq!((&a).sub_mul(&b, &Integer::ZERO), a);\n        assert_eq!((&a).sub_mul(&b, &Integer::ONE), &a - &b);\n        assert_eq!((&a * &b).sub_mul(&a, &b), 0);\n        assert_eq!((&a * &b).sub_mul(-a, -b), 0);\n    });\n\n    signed_triple_gen_var_2::<SignedLimb>().test_properties(|(x, y, z)| {\n        assert_eq!(\n            x.sub_mul(y, z),\n            Integer::from(x).sub_mul(Integer::from(y), Integer::from(z))\n        );\n    });\n\n    signed_triple_gen::<SignedLimb>().test_properties(|(x, y, z)| {\n        let result = Integer::from(x).sub_mul(Integer::from(y), Integer::from(z));\n        assert_eq!(\n            x.checked_sub_mul(y, z).is_some(),\n            SignedLimb::convertible_from(&result)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/basic/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{NegativeOne, One, Two, Zero};\nuse malachite_nz::integer::Integer;\n\n#[test]\nfn test_zero() {\n    let zero = Integer::ZERO;\n    assert!(zero.is_valid());\n    assert_eq!(zero, 0);\n    assert_eq!(zero.to_string(), \"0\");\n}\n\n#[test]\nfn test_one() {\n    let one = Integer::ONE;\n    assert!(one.is_valid());\n    assert_eq!(one, 1);\n    assert_eq!(one.to_string(), \"1\");\n}\n\n#[test]\nfn test_two() {\n    let two = Integer::TWO;\n    assert!(two.is_valid());\n    assert_eq!(two, 2);\n    assert_eq!(two.to_string(), \"2\");\n}\n\n#[test]\nfn test_negative_one() {\n    let negative_one = Integer::NEGATIVE_ONE;\n    assert!(negative_one.is_valid());\n    assert_eq!(negative_one, -1);\n    assert_eq!(negative_one.to_string(), \"-1\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/basic/default.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\n\n#[test]\nfn test_default() {\n    let default = Integer::default();\n    assert!(default.is_valid());\n    assert_eq!(default, 0);\n    assert_eq!(default.to_string(), \"0\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/basic/from_sign_and_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_bool_pair_gen, natural_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_from_sign_and_abs() {\n    let test = |sign, abs, out| {\n        let abs = Natural::from_str(abs).unwrap();\n        let x = Integer::from_sign_and_abs(sign, abs.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n\n        let x = Integer::from_sign_and_abs_ref(sign, &abs);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(true, \"0\", \"0\");\n    test(false, \"0\", \"0\");\n    test(true, \"123\", \"123\");\n    test(false, \"123\", \"-123\");\n    test(true, \"1000000000000\", \"1000000000000\");\n    test(false, \"1000000000000\", \"-1000000000000\");\n}\n\n#[test]\nfn from_sign_and_abs_properties() {\n    natural_bool_pair_gen().test_properties(|(abs, sign)| {\n        let x = Integer::from_sign_and_abs(sign, abs.clone());\n        assert!(x.is_valid());\n\n        let x_alt = Integer::from_sign_and_abs_ref(sign, &abs);\n        assert!(x_alt.is_valid());\n        assert_eq!(x, x_alt);\n\n        if abs != 0 {\n            assert_eq!(x >= 0, sign);\n        }\n        assert_eq!(x.unsigned_abs(), abs);\n    });\n\n    natural_gen()\n        .test_properties(|abs| assert_eq!(Integer::from_sign_and_abs_ref(true, &abs), abs));\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/basic/named.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_nz::integer::Integer;\n\n#[test]\nfn test_named() {\n    assert_eq!(Integer::NAME, \"Integer\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/basic/size.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse std::mem::size_of;\n\n#[test]\nfn test_size() {\n    if size_of::<usize>() == 8 {\n        assert_eq!(size_of::<Integer>(), 32);\n    }\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::common::test_cmp_helper;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_pair_gen,\n};\nuse num::BigInt;\nuse rug;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_ord() {\n    let strings = &[\n        \"-1000000000001\",\n        \"-1000000000000\",\n        \"-999999999999\",\n        \"-123\",\n        \"-2\",\n        \"-1\",\n        \"0\",\n        \"1\",\n        \"2\",\n        \"123\",\n        \"999999999999\",\n        \"1000000000000\",\n        \"1000000000001\",\n    ];\n    test_cmp_helper::<Integer>(strings);\n    test_cmp_helper::<BigInt>(strings);\n    test_cmp_helper::<rug::Integer>(strings);\n}\n\n#[test]\nfn cmp_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let ord = x.cmp(&y);\n        assert_eq!(BigInt::from(&x).cmp(&BigInt::from(&y)), ord);\n        assert_eq!(rug::Integer::from(&x).cmp(&rug::Integer::from(&y)), ord);\n        assert_eq!(y.cmp(&x).reverse(), ord);\n        assert_eq!(x == y, x.cmp(&y) == Equal);\n        assert_eq!((-y).cmp(&-x), ord);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(x.cmp(&x), Equal);\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x).cmp(&Integer::from(&y)), x.cmp(&y));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).cmp(&Integer::from(y)), x.cmp(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::test_util::common::test_custom_cmp_helper;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_pair_gen,\n};\nuse rug;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_ord_abs() {\n    let strings =\n        &[\"0\", \"1\", \"-2\", \"123\", \"-124\", \"999999999999\", \"-1000000000000\", \"1000000000001\"];\n    test_custom_cmp_helper::<Integer, _>(strings, OrdAbs::cmp_abs);\n    test_custom_cmp_helper::<rug::Integer, _>(strings, rug::Integer::cmp_abs);\n}\n\n#[test]\nfn cmp_abs_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let ord = x.cmp_abs(&y);\n        assert_eq!((&x).abs().cmp(&(&y).abs()), ord);\n        assert_eq!(rug::Integer::from(&x).cmp_abs(&rug::Integer::from(&y)), ord);\n        assert_eq!((&x).abs().cmp(&(&y).abs()), ord);\n        assert_eq!((-x).cmp_abs(&(-y)), ord);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(x.cmp_abs(&x), Equal);\n        assert_eq!(x.cmp_abs(&-&x), Equal);\n        assert!(x.ge_abs(&Integer::ZERO));\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x).cmp_abs(&Integer::from(&y)), x.cmp(&y));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).cmp_abs(&Integer::from(y)), x.cmp_abs(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::common::test_eq_helper;\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_pair_gen,\n};\nuse num::BigInt;\nuse rug;\n\n#[test]\nfn test_eq() {\n    let strings = &[\"0\", \"1\", \"-1\", \"2\", \"-2\", \"123\", \"-123\", \"1000000000000\", \"-1000000000000\"];\n    test_eq_helper::<Integer>(strings);\n    test_eq_helper::<BigInt>(strings);\n    test_eq_helper::<rug::Integer>(strings);\n}\n\n#[allow(clippy::cmp_owned, clippy::eq_op)]\n#[test]\nfn eq_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let eq = x == y;\n        assert_eq!(BigInt::from(&x) == BigInt::from(&y), eq);\n        assert_eq!(rug::Integer::from(&x) == rug::Integer::from(&y), eq);\n        assert_eq!(y == x, eq);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(x, x);\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        if x == y && y == z {\n            assert_eq!(x, z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) == Integer::from(&y), x == y);\n        assert_eq!(Integer::from(&x) == y, x == y);\n        assert_eq!(x == Integer::from(&y), x == y);\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x) == Integer::from(y), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{EqAbs, OrdAbs};\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_pair_gen,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs() {\n    let test = |s, t, eq: bool| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == (&v).abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"124\", false);\n    test(\"123\", \"122\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"1000000000000\", \"0\", false);\n\n    test(\"-123\", \"123\", true);\n    test(\"-123\", \"124\", false);\n    test(\"-123\", \"122\", false);\n    test(\"-1000000000000\", \"123\", false);\n    test(\"-123\", \"1000000000000\", false);\n    test(\"-1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"0\", false);\n\n    test(\"0\", \"-5\", false);\n    test(\"123\", \"-123\", true);\n    test(\"123\", \"-124\", false);\n    test(\"123\", \"-122\", false);\n    test(\"1000000000000\", \"-123\", false);\n    test(\"123\", \"-1000000000000\", false);\n    test(\"1000000000000\", \"-1000000000000\", true);\n\n    test(\"-123\", \"-123\", true);\n    test(\"-123\", \"-124\", false);\n    test(\"-123\", \"-122\", false);\n    test(\"-1000000000000\", \"-123\", false);\n    test(\"-123\", \"-1000000000000\", false);\n    test(\"-1000000000000\", \"-1000000000000\", true);\n}\n\n#[allow(clippy::cmp_owned, clippy::eq_op)]\n#[test]\nfn eq_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!((&x).abs() == (&y).abs(), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.cmp_abs(&y) == Equal, eq);\n        assert_eq!(x.eq_abs(&-&y), eq);\n        assert_eq!((-&x).eq_abs(&y), eq);\n        assert_eq!((-x).eq_abs(&-y), eq);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.eq_abs(&x));\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) == Integer::from(&y), x == y);\n        assert_eq!(Integer::from(&x) == y, x == y);\n        assert_eq!(x == Integer::from(&y), x == y);\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).eq_abs(&Integer::from(y)), x.eq_abs(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    integer_integer_natural_triple_gen, integer_natural_natural_triple_gen,\n    integer_natural_pair_gen, natural_pair_gen,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_integer_natural() {\n    let test = |s, t, eq: bool| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"124\", false);\n    test(\"123\", \"122\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"1000000000000\", \"0\", false);\n\n    test(\"-123\", \"123\", true);\n    test(\"-123\", \"124\", false);\n    test(\"-123\", \"122\", false);\n    test(\"-1000000000000\", \"123\", false);\n    test(\"-123\", \"1000000000000\", false);\n    test(\"-1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"0\", false);\n}\n\n#[test]\nfn eq_abs_natural_properties() {\n    integer_natural_pair_gen().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!((&x).abs() == y, eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!(x.eq_abs(&Integer::from(&y)), eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!((-x).eq_abs(&y), eq);\n    });\n\n    integer_integer_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    integer_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert_eq!(x, z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x).eq_abs(&y), x == y);\n        assert_eq!(x.eq_abs(&Integer::from(&y)), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{integer_gen, integer_primitive_float_pair_gen};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_f32() {\n    let test = |u, v: f32, eq: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"123\", 123.0, true);\n    test(\"123\", -123.0, true);\n    test(\"123\", 5.0, false);\n    test(\"123\", -5.0, false);\n    test(\"1000000000000\", 123.0, false);\n    test(\"1000000000000\", -123.0, false);\n    test(\"1\", 0.5, false);\n    test(\"1\", -0.5, false);\n    test(\"1\", f32::INFINITY, false);\n    test(\"1\", f32::NEGATIVE_INFINITY, false);\n    test(\"1\", f32::NAN, false);\n    test(\"-123\", 123.0, true);\n    test(\"-123\", -123.0, true);\n    test(\"-123\", 5.0, false);\n    test(\"-123\", -5.0, false);\n    test(\"-1000000000000\", 123.0, false);\n    test(\"-1000000000000\", -123.0, false);\n    test(\"-1\", 0.5, false);\n    test(\"-1\", -0.5, false);\n    test(\"-1\", f32::INFINITY, false);\n    test(\"-1\", f32::NEGATIVE_INFINITY, false);\n    test(\"-1\", f32::NAN, false);\n}\n\n#[test]\nfn test_eq_abs_f64() {\n    let test = |u, v: f64, eq: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"123\", 123.0, true);\n    test(\"123\", -123.0, true);\n    test(\"123\", 5.0, false);\n    test(\"123\", -5.0, false);\n    test(\"1000000000000\", 123.0, false);\n    test(\"1000000000000\", -123.0, false);\n    test(\"1\", 0.5, false);\n    test(\"1\", -0.5, false);\n    test(\"1\", f64::INFINITY, false);\n    test(\"1\", f64::NEGATIVE_INFINITY, false);\n    test(\"1\", f64::NAN, false);\n    test(\"-123\", 123.0, true);\n    test(\"-123\", -123.0, true);\n    test(\"-123\", 5.0, false);\n    test(\"-123\", -5.0, false);\n    test(\"-1000000000000\", 123.0, false);\n    test(\"-1000000000000\", -123.0, false);\n    test(\"-1\", 0.5, false);\n    test(\"-1\", -0.5, false);\n    test(\"-1\", f64::INFINITY, false);\n    test(\"-1\", f64::NEGATIVE_INFINITY, false);\n    test(\"-1\", f64::NAN, false);\n}\n\nfn eq_abs_primitive_float_properties_helper<\n    T: EqAbs<Integer> + PartialEq<Integer> + PrimitiveFloat,\n>()\nwhere\n    Integer: EqAbs<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    integer_primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!((&x).abs() == y.abs(), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.partial_cmp_abs(&y) == Some(Equal), eq);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_ne!(n, T::NAN);\n        assert_ne!(n, T::INFINITY);\n        assert_ne!(n, T::NEGATIVE_INFINITY);\n    });\n}\n\n#[test]\nfn eq_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(eq_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_pair_gen_var_7, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{integer_signed_pair_gen, integer_unsigned_pair_gen};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_u32() {\n    let test = |u, v: u32, eq: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 123, false);\n}\n\n#[test]\nfn test_eq_abs_u64() {\n    let test = |u, v: u64, eq: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", 1000000000001, false);\n    test(\"-1000000000000000000000000\", 1000000000000, false);\n}\n\n#[test]\nfn test_eq_abs_i32() {\n    let test = |u, v: i32, eq: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.unsigned_abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 123, false);\n}\n\n#[test]\nfn test_eq_abs_i64() {\n    let test = |u, v: i64, eq: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.unsigned_abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", 1000000000001, false);\n    test(\"-1000000000000000000000000\", 1000000000000, false);\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn eq_abs_primitive_int_properties_helper_unsigned<\n    T: EqAbs<Integer> + PartialEq<Integer> + PrimitiveUnsigned,\n>()\nwhere\n    Integer: EqAbs<T> + From<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    integer_unsigned_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs() == y, eq);\n\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.partial_cmp_abs(&y) == Some(Equal), eq);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).eq_abs(&y), x == y);\n        assert_eq!(x.eq_abs(&Integer::from(y)), x == y);\n    });\n}\n\nfn eq_abs_primitive_int_properties_helper_signed<T: EqAbs<Integer> + PrimitiveSigned>()\nwhere\n    Integer:\n        EqAbs<T> + From<T> + TryFrom<T> + PartialOrdAbs<T> + PartialEq<<T as UnsignedAbs>::Output>,\n{\n    integer_signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs() == y.unsigned_abs(), eq);\n        assert_eq!(\n            <Integer as EqAbs<Integer>>::eq_abs(&x, &Integer::from(y)),\n            eq\n        );\n\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(\n            <Integer as EqAbs<Integer>>::eq_abs(&Integer::from(y), &x),\n            eq\n        );\n        assert_eq!(x.partial_cmp_abs(&y) == Some(Equal), eq);\n    });\n\n    signed_pair_gen_var_7::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::exact_from(x).eq_abs(&y), x.eq_abs(&y));\n        assert_eq!(x.eq_abs(&Integer::exact_from(y)), x.eq_abs(&y));\n    });\n}\n\n#[test]\nfn eq_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(eq_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(eq_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::hash::hash;\nuse malachite_nz::test_util::generators::integer_gen;\n\n#[test]\nfn hash_properties() {\n    integer_gen().test_properties(|x| {\n        assert_eq!(hash(&x), hash(&x.clone()));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_integer_natural_triple_gen, integer_natural_natural_triple_gen,\n    integer_natural_pair_gen, natural_pair_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_integer_natural() {\n    let test = |s, t, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v), cmp);\n        assert_eq!(v.partial_cmp_abs(&u).map(Ordering::reverse), cmp);\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", \"0\", Some(Equal), false, false, true, true);\n    test(\"0\", \"5\", Some(Less), true, false, true, false);\n    test(\"123\", \"123\", Some(Equal), false, false, true, true);\n    test(\"123\", \"124\", Some(Less), true, false, true, false);\n    test(\"123\", \"122\", Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        \"123\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\"123\", \"1000000000000\", Some(Less), true, false, true, false);\n    test(\n        \"1000000000000\",\n        \"1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        \"1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        \"0\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n}\n\n#[test]\nfn partial_cmp_abs_natural_properties() {\n    integer_natural_pair_gen().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp_abs(&y);\n        assert_eq!((&x).abs().partial_cmp_abs(&y), cmp);\n        assert_eq!(x.cmp_abs(&Integer::from(&y)), cmp.unwrap());\n        assert_eq!(\n            Some(rug::Integer::from(&x).cmp_abs(&rug::Integer::from(&y))),\n            cmp\n        );\n        assert_eq!(y.partial_cmp_abs(&x), cmp.map(Ordering::reverse));\n        assert_eq!((-x).partial_cmp_abs(&y), cmp);\n    });\n\n    integer_integer_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    integer_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x < z);\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x > z);\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.ge_abs(&Natural::ZERO));\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x).partial_cmp_abs(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp_abs(&Integer::from(&y)), Some(x.cmp(&y)));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_integer_primitive_float_triple_gen, integer_primitive_float_pair_gen,\n    integer_primitive_float_primitive_float_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_primitive_float() {\n    let test = |u, v: f32, out: Option<Ordering>| {\n        let u = Integer::from_str(u).unwrap();\n\n        let out_rev = out.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!((&u).abs().partial_cmp_abs(&v.abs()), out);\n        assert_eq!(v.partial_cmp_abs(&u), out_rev);\n\n        let v = f64::from(v);\n        assert_eq!(u.partial_cmp_abs(&v), out);\n        assert_eq!(v.partial_cmp_abs(&u), out_rev);\n    };\n    test(\"5\", f32::NAN, None);\n    test(\"5\", f32::INFINITY, Some(Less));\n    test(\"5\", f32::NEGATIVE_INFINITY, Some(Less));\n    test(\"-5\", f32::NAN, None);\n    test(\"-5\", f32::INFINITY, Some(Less));\n    test(\"-5\", f32::NEGATIVE_INFINITY, Some(Less));\n\n    test(\"0\", 0.0, Some(Equal));\n    test(\"0\", -0.0, Some(Equal));\n    test(\"0\", 5.0, Some(Less));\n    test(\"0\", -5.0, Some(Less));\n    test(\"123\", 123.0, Some(Equal));\n    test(\"123\", 5.0, Some(Greater));\n    test(\"123\", -123.0, Some(Equal));\n    test(\"-123\", 123.0, Some(Equal));\n    test(\"-123\", 5.0, Some(Greater));\n    test(\"-123\", -123.0, Some(Equal));\n    test(\"1000000000000\", 123.0, Some(Greater));\n    test(\"-1000000000000\", 123.0, Some(Greater));\n\n    test(\"1208925819614629174706175\", 1.2089258e24, Some(Less));\n    test(\"1208925819614629174706176\", 1.2089258e24, Some(Equal));\n    test(\"1208925819614629174706177\", 1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706175\", -1.2089258e24, Some(Less));\n    test(\"1208925819614629174706176\", -1.2089258e24, Some(Equal));\n    test(\"1208925819614629174706177\", -1.2089258e24, Some(Greater));\n    test(\"-1208925819614629174706175\", 1.2089258e24, Some(Less));\n    test(\"-1208925819614629174706176\", 1.2089258e24, Some(Equal));\n    test(\"-1208925819614629174706177\", 1.2089258e24, Some(Greater));\n    test(\"-1208925819614629174706175\", -1.2089258e24, Some(Less));\n    test(\"-1208925819614629174706176\", -1.2089258e24, Some(Equal));\n    test(\"-1208925819614629174706177\", -1.2089258e24, Some(Greater));\n}\n\nfn partial_cmp_abs_primitive_float_properties_helper<T: PartialOrdAbs<Integer> + PrimitiveFloat>()\nwhere\n    Integer: PartialOrd<T> + PartialOrdAbs<T>,\n{\n    integer_primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let cmp_abs = x.partial_cmp_abs(&y);\n        let cmp_abs_rev = cmp_abs.map(Ordering::reverse);\n        assert_eq!((&x).abs().partial_cmp_abs(&y.abs()), cmp_abs);\n        assert_eq!(y.partial_cmp_abs(&x), cmp_abs_rev);\n\n        assert_eq!((&x).abs().partial_cmp(&y.abs()), cmp_abs);\n        assert_eq!(x.partial_cmp_abs(&-y), cmp_abs);\n    });\n\n    integer_integer_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Less);\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Greater);\n        }\n    });\n\n    integer_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(u.lt_abs(&v));\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(u.gt_abs(&v));\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.ge_abs(&T::ZERO));\n        assert!(x.lt_abs(&T::NEGATIVE_INFINITY));\n        assert!(x.lt_abs(&T::INFINITY));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_integer_signed_triple_gen, integer_integer_unsigned_triple_gen,\n    integer_signed_pair_gen, integer_signed_signed_triple_gen, integer_unsigned_pair_gen,\n    integer_unsigned_unsigned_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_u32() {\n    let test = |s, v: u32, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n}\n\n#[test]\nfn test_partial_cmp_abs_u64() {\n    let test = |u, v: u64, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n}\n\n#[test]\nfn test_partial_cmp_abs_i32() {\n    let test = |u, v: i32, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v.unsigned_abs()), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"0\", -5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", -123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", -123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", -124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", -124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"123\", -122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", -122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n}\n\n#[test]\nfn test_partial_cmp_abs_i64() {\n    let test = |u, v: i64, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Integer::from_str(u).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v.unsigned_abs()), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"0\", -5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", -123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", -123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", -124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", -124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"123\", -122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", -122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        -1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"1000000000000\",\n        -1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"-1000000000000\",\n        -1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n}\n\nfn partial_cmp_abs_primitive_int_properties_helper_unsigned<\n    T: PartialOrdAbs<Integer> + PrimitiveUnsigned,\n>()\nwhere\n    Integer: From<T> + PartialOrdAbs<T> + PartialOrd<T>,\n{\n    integer_unsigned_pair_gen::<T>().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp_abs(&y);\n        assert_eq!((&x).abs().partial_cmp(&y), cmp);\n        assert_eq!(Some(x.cmp_abs(&Integer::from(y))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(y.partial_cmp_abs(&x), cmp_rev);\n        assert_eq!(Some(Integer::from(y).cmp_abs(&x)), cmp_rev);\n        assert_eq!((-x).partial_cmp_abs(&y), cmp);\n    });\n\n    integer_integer_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Less);\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Greater);\n        }\n    });\n\n    integer_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(u < v);\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(u > v);\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.ge_abs(&T::ZERO));\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).partial_cmp_abs(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp_abs(&Integer::from(y)), Some(x.cmp(&y)));\n    });\n}\n\nfn partial_cmp_abs_primitive_int_properties_helper_signed<\n    T: PartialOrdAbs<Integer> + PartialOrd<rug::Integer> + PrimitiveSigned,\n>()\nwhere\n    Integer: From<T> + PartialOrdAbs<T> + PartialOrd<<T as UnsignedAbs>::Output>,\n{\n    integer_signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp_abs(&y);\n        assert_eq!((&x).abs().partial_cmp(&y.unsigned_abs()), cmp);\n        assert_eq!(Some(x.cmp_abs(&Integer::from(y))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(y.partial_cmp_abs(&x), cmp_rev);\n        assert_eq!(Some(Integer::from(y).cmp_abs(&x)), cmp_rev);\n        assert_eq!((-&x).partial_cmp_abs(&y), cmp);\n        if y != T::MIN {\n            assert_eq!(x.partial_cmp_abs(&-y), cmp);\n            assert_eq!((-x).partial_cmp_abs(&-y), cmp);\n        }\n    });\n\n    integer_integer_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n.lt_abs(&i) && i.lt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Less);\n        } else if n.gt_abs(&i) && i.gt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Greater);\n        }\n    });\n\n    integer_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i.lt_abs(&n) && n.lt_abs(&j) {\n            assert!(i.lt_abs(&j));\n        } else if i.gt_abs(&n) && n.gt_abs(&j) {\n            assert!(i.gt_abs(&j));\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x.ge_abs(&T::ZERO));\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).partial_cmp_abs(&y), Some(x.cmp_abs(&y)));\n        assert_eq!(x.partial_cmp_abs(&Integer::from(y)), Some(x.cmp_abs(&y)));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    integer_integer_natural_triple_gen, integer_natural_natural_triple_gen,\n    integer_natural_pair_gen, natural_pair_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_natural() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u).map(Ordering::reverse), out);\n    };\n    test(\"0\", \"0\", Some(Equal));\n    test(\"0\", \"5\", Some(Less));\n    test(\"123\", \"123\", Some(Equal));\n    test(\"123\", \"124\", Some(Less));\n    test(\"123\", \"122\", Some(Greater));\n    test(\"1000000000000\", \"123\", Some(Greater));\n    test(\"123\", \"1000000000000\", Some(Less));\n    test(\"1000000000000\", \"1000000000000\", Some(Equal));\n    test(\"-1000000000000\", \"1000000000000\", Some(Less));\n    test(\"-1000000000000\", \"0\", Some(Less));\n}\n\n#[test]\nfn partial_cmp_natural_properties() {\n    integer_natural_pair_gen().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp(&y);\n        assert_eq!(x.cmp(&Integer::from(&y)), cmp.unwrap());\n        assert_eq!(\n            rug::Integer::from(&x).partial_cmp(&rug::Integer::from(&y)),\n            cmp\n        );\n        assert_eq!(y.partial_cmp(&x), cmp.map(Ordering::reverse));\n    });\n\n    integer_integer_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    integer_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Integer::from(&y)), Some(x.cmp(&y)));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_integer_primitive_float_triple_gen, integer_primitive_float_pair_gen,\n    integer_primitive_float_primitive_float_triple_gen,\n};\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_primitive_float() {\n    let test = |u, v: f32, out: Option<Ordering>| {\n        let out_rev = out.map(Ordering::reverse);\n        assert_eq!(Integer::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(v.partial_cmp(&Integer::from_str(u).unwrap()), out_rev);\n        assert_eq!(v.partial_cmp(&rug::Integer::from_str(u).unwrap()), out_rev);\n\n        let v = f64::from(v);\n        assert_eq!(Integer::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(v.partial_cmp(&Integer::from_str(u).unwrap()), out_rev);\n        assert_eq!(v.partial_cmp(&rug::Integer::from_str(u).unwrap()), out_rev);\n    };\n    test(\"5\", f32::NAN, None);\n    test(\"5\", f32::INFINITY, Some(Less));\n    test(\"5\", f32::NEGATIVE_INFINITY, Some(Greater));\n    test(\"-5\", f32::NAN, None);\n    test(\"-5\", f32::INFINITY, Some(Less));\n    test(\"-5\", f32::NEGATIVE_INFINITY, Some(Greater));\n\n    test(\"0\", 0.0, Some(Equal));\n    test(\"0\", -0.0, Some(Equal));\n    test(\"0\", 5.0, Some(Less));\n    test(\"0\", -5.0, Some(Greater));\n    test(\"123\", 123.0, Some(Equal));\n    test(\"123\", 5.0, Some(Greater));\n    test(\"123\", -123.0, Some(Greater));\n    test(\"-123\", 123.0, Some(Less));\n    test(\"-123\", 5.0, Some(Less));\n    test(\"-123\", -123.0, Some(Equal));\n    test(\"1000000000000\", 123.0, Some(Greater));\n    test(\"-1000000000000\", 123.0, Some(Less));\n\n    test(\"1208925819614629174706175\", 1.2089258e24, Some(Less));\n    test(\"1208925819614629174706176\", 1.2089258e24, Some(Equal));\n    test(\"1208925819614629174706177\", 1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706175\", -1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706176\", -1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706177\", -1.2089258e24, Some(Greater));\n    test(\"-1208925819614629174706175\", 1.2089258e24, Some(Less));\n    test(\"-1208925819614629174706176\", 1.2089258e24, Some(Less));\n    test(\"-1208925819614629174706177\", 1.2089258e24, Some(Less));\n    test(\"-1208925819614629174706175\", -1.2089258e24, Some(Greater));\n    test(\"-1208925819614629174706176\", -1.2089258e24, Some(Equal));\n    test(\"-1208925819614629174706177\", -1.2089258e24, Some(Less));\n\n    test(\"-117886223846050103296\", -1.1788622e20, Some(Equal));\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_float_properties_helper<\n    T: PartialOrd<Integer> + PartialOrd<rug::Integer> + PrimitiveFloat,\n>()\nwhere\n    Integer: PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    integer_primitive_float_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp = n.partial_cmp(&u);\n        assert_eq!(rug::Integer::from(&n).partial_cmp(&u), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp(&n), cmp_rev);\n        assert_eq!(u.partial_cmp(&rug::Integer::from(&n)), cmp_rev);\n    });\n\n    integer_integer_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > u && u > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    integer_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert!(x > T::NEGATIVE_INFINITY);\n        assert!(x < T::INFINITY);\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{\n    integer_integer_signed_triple_gen, integer_integer_unsigned_triple_gen,\n    integer_signed_pair_gen, integer_signed_signed_triple_gen, integer_unsigned_pair_gen,\n    integer_unsigned_unsigned_triple_gen,\n};\nuse malachite_nz::test_util::integer::comparison::partial_cmp_primitive_int::*;\nuse num::BigInt;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_u32() {\n    let test = |s, v: u32, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(\n            num_partial_cmp_primitive(&BigInt::from_str(s).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(s).unwrap().partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"123\", 123, Some(Equal));\n    test(\"-123\", 123, Some(Less));\n    test(\"123\", 124, Some(Less));\n    test(\"-123\", 124, Some(Less));\n    test(\"123\", 122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_u64() {\n    let test = |s, v: u64, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(\n            num_partial_cmp_primitive(&BigInt::from_str(s).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(s).unwrap().partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"123\", 123, Some(Equal));\n    test(\"-123\", 123, Some(Less));\n    test(\"123\", 124, Some(Less));\n    test(\"-123\", 124, Some(Less));\n    test(\"123\", 122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n    test(\"1000000000000\", 1000000000000, Some(Equal));\n    test(\"-1000000000000\", 1000000000000, Some(Less));\n    test(\"1000000000000\", 1000000000001, Some(Less));\n    test(\"-1000000000000\", 1000000000001, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_i32() {\n    let test = |u, v: i32, out| {\n        assert_eq!(Integer::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(\n            num_partial_cmp_primitive(&BigInt::from_str(u).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Integer::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"0\", -5, Some(Greater));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", -123, Some(Greater));\n    test(\"-123\", 123, Some(Less));\n    test(\"-123\", -123, Some(Equal));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", -124, Some(Greater));\n    test(\"-123\", 124, Some(Less));\n    test(\"-123\", -124, Some(Greater));\n    test(\"123\", 122, Some(Greater));\n    test(\"123\", -122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"-123\", -122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"1000000000000\", -123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n    test(\"-1000000000000\", -123, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_i64() {\n    let test = |u, v: i64, out| {\n        assert_eq!(Integer::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(\n            num_partial_cmp_primitive(&BigInt::from_str(u).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Integer::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"0\", -5, Some(Greater));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", -123, Some(Greater));\n    test(\"-123\", 123, Some(Less));\n    test(\"-123\", -123, Some(Equal));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", -124, Some(Greater));\n    test(\"-123\", 124, Some(Less));\n    test(\"-123\", -124, Some(Greater));\n    test(\"123\", 122, Some(Greater));\n    test(\"123\", -122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"-123\", -122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"1000000000000\", -123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n    test(\"-1000000000000\", -123, Some(Less));\n    test(\"1000000000000\", 1000000000000, Some(Equal));\n    test(\"1000000000000\", -1000000000000, Some(Greater));\n    test(\"-1000000000000\", 1000000000000, Some(Less));\n    test(\"-1000000000000\", -1000000000000, Some(Equal));\n    test(\"1000000000000\", 1000000000001, Some(Less));\n    test(\"1000000000000\", -1000000000001, Some(Greater));\n    test(\"-1000000000000\", 1000000000001, Some(Less));\n    test(\"-1000000000000\", -1000000000001, Some(Greater));\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_unsigned<\n    T: PartialOrd<Integer> + PartialOrd<rug::Integer> + PrimitiveUnsigned,\n>()\nwhere\n    BigInt: From<T>,\n    Integer: From<T> + PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    integer_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp = n.partial_cmp(&u);\n        assert_eq!(num_partial_cmp_primitive(&From::from(&n), u), cmp);\n        assert_eq!(rug::Integer::from(&n).partial_cmp(&u), cmp);\n        assert_eq!(Some(n.cmp(&Integer::from(u))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp(&n), cmp_rev);\n        assert_eq!(u.partial_cmp(&rug::Integer::from(&n)), cmp_rev);\n        assert_eq!(Some(Integer::from(u).cmp(&n)), cmp_rev);\n    });\n\n    integer_integer_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > u && u > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    integer_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Integer::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_signed<\n    T: PartialOrd<Integer> + PartialOrd<rug::Integer> + PrimitiveSigned,\n>()\nwhere\n    BigInt: From<T>,\n    Integer: From<T> + PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    integer_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let cmp = n.partial_cmp(&i);\n        assert_eq!(num_partial_cmp_primitive(&From::from(&n), i), cmp);\n        assert_eq!(rug::Integer::from(&n).partial_cmp(&i), cmp);\n        assert_eq!(Some(n.cmp(&Integer::from(i))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(i.partial_cmp(&n), cmp_rev);\n        assert_eq!(i.partial_cmp(&rug::Integer::from(&n)), cmp_rev);\n        assert_eq!(Some(Integer::from(i).cmp(&n)), cmp_rev);\n    });\n\n    integer_integer_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n < i && i < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > i && i > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    integer_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i < n && n < j {\n            assert!(i < j);\n        } else if i > n && n > j {\n            assert!(i > j);\n        }\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Integer::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{integer_natural_pair_gen, natural_pair_gen};\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_integer_partial_eq_natural() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(v == u, out);\n        assert_eq!(\n            rug::Integer::from_str(s).unwrap() == rug::Integer::from_str(t).unwrap(),\n            out\n        );\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"123\", \"123\", true);\n    test(\"-123\", \"123\", false);\n    test(\"123\", \"5\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"1000000000000\", false);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn partial_eq_natural_properties() {\n    integer_natural_pair_gen().test_properties(|(x, y)| {\n        let eq = x == y;\n        assert_eq!(y == x, eq);\n        assert_eq!(x == Integer::from(&y), eq);\n        assert_eq!(rug::Integer::from(&x) == rug::Integer::from(&y), eq);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) == y, x == y);\n        assert_eq!(x == Integer::from(&y), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    integer_primitive_float_pair_gen, natural_primitive_float_pair_gen,\n};\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq() {\n    let test = |u, v: f32, out| {\n        assert_eq!(Integer::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Integer::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n\n        let v = f64::from(v);\n        assert_eq!(Integer::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Integer::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n    };\n    test(\"5\", f32::NAN, false);\n    test(\"5\", f32::INFINITY, false);\n    test(\"5\", f32::NEGATIVE_INFINITY, false);\n    test(\"-5\", f32::NAN, false);\n    test(\"-5\", f32::INFINITY, false);\n    test(\"-5\", f32::NEGATIVE_INFINITY, false);\n\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"123\", 123.0, true);\n    test(\"123\", 5.0, false);\n    test(\"123\", -123.0, false);\n    test(\"-123\", 123.0, false);\n    test(\"-123\", 5.0, false);\n    test(\"-123\", -123.0, true);\n    test(\"1000000000000\", 123.0, false);\n    test(\"-1000000000000\", 123.0, false);\n\n    test(\"1208925819614629174706175\", 1.2089258e24, false);\n    test(\"1208925819614629174706176\", 1.2089258e24, true);\n    test(\"1208925819614629174706177\", 1.2089258e24, false);\n    test(\"1208925819614629174706175\", -1.2089258e24, false);\n    test(\"1208925819614629174706176\", -1.2089258e24, false);\n    test(\"1208925819614629174706177\", -1.2089258e24, false);\n    test(\"-1208925819614629174706175\", 1.2089258e24, false);\n    test(\"-1208925819614629174706176\", 1.2089258e24, false);\n    test(\"-1208925819614629174706177\", 1.2089258e24, false);\n    test(\"-1208925819614629174706175\", -1.2089258e24, false);\n    test(\"-1208925819614629174706176\", -1.2089258e24, true);\n    test(\"-1208925819614629174706177\", -1.2089258e24, false);\n}\n\n#[allow(clippy::cmp_owned, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_float_properties_helper<\n    T: PartialEq<Integer> + PartialEq<Natural> + PartialEq<rug::Integer> + PrimitiveFloat,\n>()\nwhere\n    Integer: PartialEq<T> + PartialOrd<T>,\n    Natural: PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    integer_primitive_float_pair_gen::<T>().test_properties(|(n, f)| {\n        let eq = n == f;\n        assert_eq!(rug::Integer::from(&n) == f, eq);\n        assert_eq!(f == n, eq);\n        assert_eq!(f == rug::Integer::from(&n), eq);\n        assert_eq!(n.partial_cmp(&f) == Some(Equal), eq);\n        if eq {\n            assert!(f.is_integer());\n        }\n    });\n\n    natural_primitive_float_pair_gen::<T>().test_properties(|(n, f)| {\n        let i_n: Integer = From::from(&n);\n        let eq = n == f;\n        assert_eq!(i_n == f, eq);\n        assert_eq!(f == n, eq);\n        assert_eq!(f == i_n, eq);\n    });\n}\n\n#[test]\nfn partial_eq_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_eq_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{integer_signed_pair_gen, integer_unsigned_pair_gen};\nuse malachite_nz::test_util::integer::comparison::partial_eq_primitive_int::*;\nuse num::BigInt;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_u32() {\n    let test = |s, v: u32, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(\n            num_partial_eq_primitive(&BigInt::from_str(s).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Integer::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", 5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-1000000000000\", 123, false);\n}\n\n#[test]\nfn test_partial_eq_u64() {\n    let test = |s, v: u64, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(\n            num_partial_eq_primitive(&BigInt::from_str(s).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Integer::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", 1000000000000, false);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"-1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-1000000000000000000000000\", 1000000000000, false);\n}\n\n#[test]\nfn test_partial_eq_i32() {\n    let test = |s, v: i32, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(rug::Integer::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Integer::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", -5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-1000000000000\", -123, false);\n}\n\n#[test]\nfn test_partial_eq_i64() {\n    let test = |s, v: i64, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(rug::Integer::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Integer::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", -5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", -1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"-1000000000000\", -1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-1000000000000000000000000\", -1000000000000, false);\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_int_properties_helper_unsigned<\n    T: PartialEq<Integer> + PartialEq<rug::Integer> + PrimitiveUnsigned,\n>()\nwhere\n    BigInt: From<T>,\n    Integer: From<T> + PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    integer_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let eq = n == u;\n        assert_eq!(num_partial_eq_primitive(&From::from(&n), u), eq);\n        assert_eq!(rug::Integer::from(&n) == u, eq);\n        assert_eq!(&n == &Integer::from(u), eq);\n\n        assert_eq!(u == n, eq);\n        assert_eq!(u == rug::Integer::from(&n), eq);\n        assert_eq!(&Integer::from(u) == &n, eq);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x) == y, x == y);\n        assert_eq!(x == Integer::from(y), x == y);\n    });\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_int_properties_helper_signed<\n    T: PartialEq<Integer> + PartialEq<rug::Integer> + PrimitiveSigned,\n>()\nwhere\n    Integer: From<T> + PartialEq<T>,\n    rug::Integer: PartialEq<T>,\n{\n    integer_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let eq = n == i;\n        assert_eq!(rug::Integer::from(&n) == i, eq);\n        assert_eq!(&n == &Integer::from(i), eq);\n\n        assert_eq!(i == n, eq);\n        assert_eq!(i == rug::Integer::from(&n), eq);\n        assert_eq!(&Integer::from(i) == &n, eq);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(x) == y, x == y);\n        assert_eq!(x == Integer::from(y), x == y);\n    });\n}\n\n#[test]\nfn partial_eq_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_eq_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_eq_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{integer_gen, integer_pair_gen};\nuse num::BigInt;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\n#[allow(clippy::redundant_clone)]\nfn test_clone() {\n    let test = |u| {\n        let x = Integer::from_str(u).unwrap().clone();\n        assert_eq!(x.to_string(), u);\n        assert!(x.is_valid());\n\n        let x = BigInt::from_str(u).unwrap().clone();\n        assert_eq!(x.to_string(), u);\n\n        let x = rug::Integer::from_str(u).unwrap().clone();\n        assert_eq!(x.to_string(), u);\n    };\n    test(\"123\");\n    test(\"1000000000000\");\n    test(\"-123\");\n    test(\"-1000000000000\");\n}\n\n#[test]\nfn test_clone_and_clone_from() {\n    let test = |u, v| {\n        let mut x = Integer::from_str(u).unwrap();\n        x.clone_from(&Integer::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n        assert!(x.is_valid());\n\n        let mut x = BigInt::from_str(u).unwrap();\n        x.clone_from(&BigInt::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n\n        let mut x = rug::Integer::from_str(u).unwrap();\n        x.clone_from(&rug::Integer::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n    };\n    test(\"-123\", \"456\");\n    test(\"-123\", \"1000000000000\");\n    test(\"1000000000000\", \"-123\");\n    test(\"1000000000000\", \"2000000000000\");\n}\n\n#[allow(clippy::redundant_clone)]\n#[test]\nfn clone_and_clone_from_properties() {\n    integer_gen().test_properties(|x| {\n        let mut_x = x.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, x);\n\n        assert_eq!(Integer::from(&BigInt::from(&x).clone()), x);\n        assert_eq!(Integer::from(&rug::Integer::from(&x).clone()), x);\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.clone_from(&y);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, y);\n\n        let mut num_x = BigInt::from(&x);\n        num_x.clone_from(&BigInt::from(&y));\n        assert_eq!(Integer::from(&num_x), y);\n\n        let mut rug_x = rug::Integer::from(&x);\n        rug_x.clone_from(&rug::Integer::from(&y));\n        assert_eq!(Integer::from(&rug_x), y);\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(i, j)| {\n        let x = Integer::from(i);\n        let y = Integer::from(j);\n\n        let mut mut_i = i;\n        let mut mut_x = x.clone();\n        mut_i.clone_from(&j);\n        mut_x.clone_from(&y);\n        assert_eq!(mut_x, mut_i);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\n\n#[test]\nfn test_from_bool() {\n    let test = |b, s| {\n        let n = Integer::from(b);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), s);\n    };\n    test(false, \"0\");\n    test(true, \"1\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_natural() {\n    let test = |s| {\n        let u = Natural::from_str(s).unwrap();\n\n        let x = Integer::from(u.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), s);\n\n        let x = Integer::from(&u);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), s);\n    };\n    test(\"0\");\n    test(\"123\");\n    test(\"1000000000000\");\n    test(\"4294967295\");\n    test(\"4294967296\");\n}\n\n#[test]\nfn from_natural_properties() {\n    natural_gen().test_properties(|x| {\n        let integer_x = Integer::from(x.clone());\n        assert!(integer_x.is_valid());\n        assert_eq!(integer_x.to_string(), x.to_string());\n\n        let integer_x_alt = Integer::from(&x);\n        assert!(integer_x_alt.is_valid());\n        assert_eq!(integer_x_alt, integer_x);\n\n        assert_eq!(Natural::try_from(&integer_x).as_ref(), Ok(&x));\n        assert_eq!(Natural::try_from(integer_x), Ok(x));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::from::SignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_gen_var_5, primitive_float_gen_var_6,\n    primitive_float_gen_var_7, primitive_float_gen_var_14,\n    primitive_float_rounding_mode_pair_gen_var_2, primitive_float_rounding_mode_pair_gen_var_3,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_rounding_from_f32() {\n    let test = |f: f32, rm: RoundingMode, out, o_out| {\n        let (x, o) = Integer::rounding_from(f, rm);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(o, o_out);\n    };\n    test(0.0, Exact, \"0\", Equal);\n    test(-0.0, Exact, \"0\", Equal);\n    test(123.0, Exact, \"123\", Equal);\n    test(-123.0, Exact, \"-123\", Equal);\n    test(1.0e9, Exact, \"1000000000\", Equal);\n    test(-1.0e9, Exact, \"-1000000000\", Equal);\n    test(4294967295.0, Exact, \"4294967296\", Equal);\n    test(-4294967295.0, Exact, \"-4294967296\", Equal);\n    test(4294967296.0, Exact, \"4294967296\", Equal);\n    test(-4294967296.0, Exact, \"-4294967296\", Equal);\n    test(18446744073709551615.0, Exact, \"18446744073709551616\", Equal);\n    test(\n        -18446744073709551615.0,\n        Exact,\n        \"-18446744073709551616\",\n        Equal,\n    );\n    test(18446744073709551616.0, Exact, \"18446744073709551616\", Equal);\n    test(\n        -18446744073709551616.0,\n        Exact,\n        \"-18446744073709551616\",\n        Equal,\n    );\n    test(1.0e20, Exact, \"100000002004087734272\", Equal);\n    test(-1.0e20, Exact, \"-100000002004087734272\", Equal);\n    test(1.23e20, Exact, \"122999999650278146048\", Equal);\n    test(-1.23e20, Exact, \"-122999999650278146048\", Equal);\n    test(1.6777216e7, Exact, \"16777216\", Equal);\n    test(-1.6777216e7, Exact, \"-16777216\", Equal);\n    test(1.6777218e7, Exact, \"16777218\", Equal);\n    test(-1.6777218e7, Exact, \"-16777218\", Equal);\n\n    test(123.1, Floor, \"123\", Less);\n    test(123.1, Down, \"123\", Less);\n    test(123.1, Ceiling, \"124\", Greater);\n    test(123.1, Up, \"124\", Greater);\n    test(123.1, Nearest, \"123\", Less);\n\n    test(-123.1, Floor, \"-124\", Less);\n    test(-123.1, Down, \"-123\", Greater);\n    test(-123.1, Ceiling, \"-123\", Greater);\n    test(-123.1, Up, \"-124\", Less);\n    test(-123.1, Nearest, \"-123\", Greater);\n\n    test(123.9, Floor, \"123\", Less);\n    test(123.9, Down, \"123\", Less);\n    test(123.9, Ceiling, \"124\", Greater);\n    test(123.9, Up, \"124\", Greater);\n    test(123.9, Nearest, \"124\", Greater);\n\n    test(-123.9, Floor, \"-124\", Less);\n    test(-123.9, Down, \"-123\", Greater);\n    test(-123.9, Ceiling, \"-123\", Greater);\n    test(-123.9, Up, \"-124\", Less);\n    test(-123.9, Nearest, \"-124\", Less);\n\n    test(123.5, Nearest, \"124\", Greater);\n    test(-123.5, Nearest, \"-124\", Less);\n    test(124.5, Nearest, \"124\", Less);\n    test(-124.5, Nearest, \"-124\", Greater);\n\n    test(-0.99, Ceiling, \"0\", Greater);\n    test(-0.99, Down, \"0\", Greater);\n    test(-0.499, Nearest, \"0\", Greater);\n    test(-0.5, Nearest, \"0\", Greater);\n\n    test(-1.1788622e20, Exact, \"-117886223846050103296\", Equal);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_1() {\n    Integer::rounding_from(f32::NAN, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_2() {\n    Integer::rounding_from(f32::INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_3() {\n    Integer::rounding_from(f32::NEGATIVE_INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_4() {\n    Integer::rounding_from(123.1, Exact);\n}\n\n#[test]\nfn test_rounding_from_f64() {\n    let test = |f: f64, rm: RoundingMode, out, o_out| {\n        let (x, o) = Integer::rounding_from(f, rm);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(o, o_out);\n    };\n    test(0.0, Exact, \"0\", Equal);\n    test(-0.0, Exact, \"0\", Equal);\n    test(123.0, Exact, \"123\", Equal);\n    test(-123.0, Exact, \"-123\", Equal);\n    test(1.0e9, Exact, \"1000000000\", Equal);\n    test(-1.0e9, Exact, \"-1000000000\", Equal);\n    test(4294967295.0, Exact, \"4294967295\", Equal);\n    test(-4294967295.0, Exact, \"-4294967295\", Equal);\n    test(4294967296.0, Exact, \"4294967296\", Equal);\n    test(-4294967296.0, Exact, \"-4294967296\", Equal);\n    test(18446744073709551615.0, Exact, \"18446744073709551616\", Equal);\n    test(\n        -18446744073709551615.0,\n        Exact,\n        \"-18446744073709551616\",\n        Equal,\n    );\n    test(18446744073709551616.0, Exact, \"18446744073709551616\", Equal);\n    test(\n        -18446744073709551616.0,\n        Exact,\n        \"-18446744073709551616\",\n        Equal,\n    );\n    test(1.0e20, Exact, \"100000000000000000000\", Equal);\n    test(-1.0e20, Exact, \"-100000000000000000000\", Equal);\n    test(1.23e20, Exact, \"123000000000000000000\", Equal);\n    test(-1.23e20, Exact, \"-123000000000000000000\", Equal);\n    test(\n        1.0e100,\n        Exact,\n        \"100000000000000001590289110975991804683608085639452813897813275577478387721703810608134699\\\n        85856815104\",\n        Equal,\n    );\n    test(\n        -1.0e100,\n        Exact,\n        \"-10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469\\\n        985856815104\",\n        Equal,\n    );\n    test(\n        1.23e100,\n        Exact,\n        \"123000000000000008366862950845375853795062237854139353014252897832358837028676639186389822\\\n        00322686976\",\n        Equal,\n    );\n    test(\n        -1.23e100,\n        Exact,\n        \"-12300000000000000836686295084537585379506223785413935301425289783235883702867663918638982\\\n        200322686976\",\n        Equal,\n    );\n    test(9.007199254740992e15, Exact, \"9007199254740992\", Equal);\n    test(-9.007199254740992e15, Exact, \"-9007199254740992\", Equal);\n    test(9.007199254740994e15, Exact, \"9007199254740994\", Equal);\n    test(-9.007199254740994e15, Exact, \"-9007199254740994\", Equal);\n\n    test(123.1, Floor, \"123\", Less);\n    test(123.1, Down, \"123\", Less);\n    test(123.1, Ceiling, \"124\", Greater);\n    test(123.1, Up, \"124\", Greater);\n    test(123.1, Nearest, \"123\", Less);\n\n    test(-123.1, Floor, \"-124\", Less);\n    test(-123.1, Down, \"-123\", Greater);\n    test(-123.1, Ceiling, \"-123\", Greater);\n    test(-123.1, Up, \"-124\", Less);\n    test(-123.1, Nearest, \"-123\", Greater);\n\n    test(123.9, Floor, \"123\", Less);\n    test(123.9, Down, \"123\", Less);\n    test(123.9, Ceiling, \"124\", Greater);\n    test(123.9, Up, \"124\", Greater);\n    test(123.9, Nearest, \"124\", Greater);\n\n    test(-123.9, Floor, \"-124\", Less);\n    test(-123.9, Down, \"-123\", Greater);\n    test(-123.9, Ceiling, \"-123\", Greater);\n    test(-123.9, Up, \"-124\", Less);\n    test(-123.9, Nearest, \"-124\", Less);\n\n    test(123.5, Nearest, \"124\", Greater);\n    test(-123.5, Nearest, \"-124\", Less);\n    test(124.5, Nearest, \"124\", Less);\n    test(-124.5, Nearest, \"-124\", Greater);\n    test(-0.99, Ceiling, \"0\", Greater);\n    test(-0.99, Down, \"0\", Greater);\n    test(-0.499, Nearest, \"0\", Greater);\n    test(-0.5, Nearest, \"0\", Greater);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_1() {\n    Integer::rounding_from(f64::NAN, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_2() {\n    Integer::rounding_from(f64::INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_3() {\n    Integer::rounding_from(f64::NEGATIVE_INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_4() {\n    Integer::rounding_from(123.1, Exact);\n}\n\n#[test]\nfn test_try_from_f32() {\n    let test = |f: f32, out| {\n        let on = Integer::try_from(f);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(f32::NAN, \"Err(FloatInfiniteOrNan)\");\n    test(f32::INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(f32::NEGATIVE_INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(-123.0, \"Ok(-123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(-1.0e9, \"Ok(-1000000000)\");\n    test(4294967295.0, \"Ok(4294967296)\");\n    test(-4294967295.0, \"Ok(-4294967296)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(-4294967296.0, \"Ok(-4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551615.0, \"Ok(-18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551616.0, \"Ok(-18446744073709551616)\");\n    test(1.0e20, \"Ok(100000002004087734272)\");\n    test(-1.0e20, \"Ok(-100000002004087734272)\");\n    test(1.23e20, \"Ok(122999999650278146048)\");\n    test(-1.23e20, \"Ok(-122999999650278146048)\");\n    test(123.1, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-123.1, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(123.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-123.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(124.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-124.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f32::MIN_POSITIVE, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-f32::MIN_POSITIVE, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f32::MAX_SUBNORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-f32::MAX_SUBNORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f32::MIN_POSITIVE_NORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(\n        -f32::MIN_POSITIVE_NORMAL,\n        \"Err(FloatNonIntegerOrOutOfRange)\",\n    );\n    test(\n        f32::MAX_FINITE,\n        \"Ok(340282346638528859811704183484516925440)\",\n    );\n    test(\n        -f32::MAX_FINITE,\n        \"Ok(-340282346638528859811704183484516925440)\",\n    );\n}\n\n#[test]\nfn test_try_from_f64() {\n    let test = |f: f64, out| {\n        let on = Integer::try_from(f);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(f64::NAN, \"Err(FloatInfiniteOrNan)\");\n    test(f64::INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(f64::NEGATIVE_INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(-123.0, \"Ok(-123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(-1.0e9, \"Ok(-1000000000)\");\n    test(4294967295.0, \"Ok(4294967295)\");\n    test(-4294967295.0, \"Ok(-4294967295)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(-4294967296.0, \"Ok(-4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551615.0, \"Ok(-18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551616.0, \"Ok(-18446744073709551616)\");\n    test(1.0e20, \"Ok(100000000000000000000)\");\n    test(-1.0e20, \"Ok(-100000000000000000000)\");\n    test(1.23e20, \"Ok(123000000000000000000)\");\n    test(-1.23e20, \"Ok(-123000000000000000000)\");\n    test(\n        1.0e100,\n        \"Ok(10000000000000000159028911097599180468360808563945281389781327557747838772170381060813\\\n        469985856815104)\",\n    );\n    test(\n        -1.0e100,\n        \"Ok(-1000000000000000015902891109759918046836080856394528138978132755774783877217038106081\\\n        3469985856815104)\",\n    );\n    test(\n        1.23e100,\n        \"Ok(12300000000000000836686295084537585379506223785413935301425289783235883702867663918638\\\n        982200322686976)\",\n    );\n    test(\n        -1.23e100,\n        \"Ok(-1230000000000000083668629508453758537950622378541393530142528978323588370286766391863\\\n        8982200322686976)\",\n    );\n    test(123.1, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-123.1, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(123.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-123.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(124.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-124.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f64::MIN_POSITIVE, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-f64::MIN_POSITIVE, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f64::MAX_SUBNORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-f64::MAX_SUBNORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f64::MIN_POSITIVE_NORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(\n        -f64::MIN_POSITIVE_NORMAL,\n        \"Err(FloatNonIntegerOrOutOfRange)\",\n    );\n    test(\n        f64::MAX_FINITE,\n        \"Ok(17976931348623157081452742373170435679807056752584499659891747680315726078002853876058\\\n        955863276687817154045895351438246423432132688946418276846754670353751698604991057655128207\\\n        624549009038932894407586850845513394230458323690322294816580855933212334827479782620414472\\\n        3168738177180919299881250404026184124858368)\",\n    );\n    test(\n        -f64::MAX_FINITE,\n        \"Ok(-1797693134862315708145274237317043567980705675258449965989174768031572607800285387605\\\n        895586327668781715404589535143824642343213268894641827684675467035375169860499105765512820\\\n        762454900903893289440758685084551339423045832369032229481658085593321233482747978262041447\\\n        23168738177180919299881250404026184124858368)\",\n    );\n}\n\n#[test]\nfn test_exact_from_f32() {\n    let test = |f: f32, out| {\n        let x = Integer::exact_from(f);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(0.0, \"0\");\n    test(-0.0, \"0\");\n    test(123.0, \"123\");\n    test(-123.0, \"-123\");\n    test(1.0e9, \"1000000000\");\n    test(-1.0e9, \"-1000000000\");\n    test(4294967295.0, \"4294967296\");\n    test(-4294967295.0, \"-4294967296\");\n    test(4294967296.0, \"4294967296\");\n    test(-4294967296.0, \"-4294967296\");\n    test(18446744073709551615.0, \"18446744073709551616\");\n    test(-18446744073709551615.0, \"-18446744073709551616\");\n    test(18446744073709551616.0, \"18446744073709551616\");\n    test(-18446744073709551616.0, \"-18446744073709551616\");\n    test(1.0e20, \"100000002004087734272\");\n    test(-1.0e20, \"-100000002004087734272\");\n    test(1.23e20, \"122999999650278146048\");\n    test(-1.23e20, \"-122999999650278146048\");\n    test(f32::MAX_FINITE, \"340282346638528859811704183484516925440\");\n    test(-f32::MAX_FINITE, \"-340282346638528859811704183484516925440\");\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_1() {\n    Integer::exact_from(f32::NAN);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_2() {\n    Integer::exact_from(f32::INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_3() {\n    Integer::exact_from(f32::NEGATIVE_INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_4() {\n    Integer::exact_from(123.1);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_5() {\n    Integer::exact_from(-123.1);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_6() {\n    Integer::exact_from(123.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_7() {\n    Integer::exact_from(-123.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_8() {\n    Integer::exact_from(124.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_9() {\n    Integer::exact_from(-124.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_10() {\n    Integer::exact_from(f32::MIN_POSITIVE);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_11() {\n    Integer::exact_from(-f32::MIN_POSITIVE);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_12() {\n    Integer::exact_from(f32::MAX_SUBNORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_13() {\n    Integer::exact_from(-f32::MAX_SUBNORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_14() {\n    Integer::exact_from(f32::MIN_POSITIVE_NORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_15() {\n    Integer::exact_from(-f32::MIN_POSITIVE_NORMAL);\n}\n\n#[test]\nfn test_exact_from_f64() {\n    let test = |f: f64, out| {\n        let x = Integer::exact_from(f);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(0.0, \"0\");\n    test(-0.0, \"0\");\n    test(123.0, \"123\");\n    test(-123.0, \"-123\");\n    test(1.0e9, \"1000000000\");\n    test(-1.0e9, \"-1000000000\");\n    test(4294967295.0, \"4294967295\");\n    test(-4294967295.0, \"-4294967295\");\n    test(4294967296.0, \"4294967296\");\n    test(-4294967296.0, \"-4294967296\");\n    test(18446744073709551615.0, \"18446744073709551616\");\n    test(-18446744073709551615.0, \"-18446744073709551616\");\n    test(18446744073709551616.0, \"18446744073709551616\");\n    test(-18446744073709551616.0, \"-18446744073709551616\");\n    test(1.0e20, \"100000000000000000000\");\n    test(-1.0e20, \"-100000000000000000000\");\n    test(1.23e20, \"123000000000000000000\");\n    test(-1.23e20, \"-123000000000000000000\");\n    test(\n        1.0e100,\n        \"100000000000000001590289110975991804683608085639452813897813275577478387721703810608134699\\\n        85856815104\",\n    );\n    test(\n        -1.0e100,\n        \"-10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469\\\n        985856815104\",\n    );\n    test(\n        1.23e100,\n        \"123000000000000008366862950845375853795062237854139353014252897832358837028676639186389822\\\n        00322686976\",\n    );\n    test(\n        -1.23e100,\n        \"-12300000000000000836686295084537585379506223785413935301425289783235883702867663918638982\\\n        200322686976\",\n    );\n    test(\n        f64::MAX_FINITE,\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n    );\n    test(\n        -f64::MAX_FINITE,\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_1() {\n    Integer::exact_from(f64::NAN);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_2() {\n    Integer::exact_from(f64::INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_3() {\n    Integer::exact_from(f64::NEGATIVE_INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_4() {\n    Integer::exact_from(123.1);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_5() {\n    Integer::exact_from(-123.1);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_6() {\n    Integer::exact_from(123.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_7() {\n    Integer::exact_from(-123.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_8() {\n    Integer::exact_from(124.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_9() {\n    Integer::exact_from(-124.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_10() {\n    Integer::exact_from(f64::MIN_POSITIVE);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_11() {\n    Integer::exact_from(-f64::MIN_POSITIVE);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_12() {\n    Integer::exact_from(f64::MAX_SUBNORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_13() {\n    Integer::exact_from(-f64::MAX_SUBNORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_14() {\n    Integer::exact_from(f64::MIN_POSITIVE_NORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_15() {\n    Integer::exact_from(-f64::MIN_POSITIVE_NORMAL);\n}\n\n#[test]\nfn test_convertible_from_f32() {\n    let test = |f: f32, out| {\n        assert_eq!(Integer::convertible_from(f), out);\n    };\n    test(f32::NAN, false);\n    test(f32::INFINITY, false);\n    test(f32::NEGATIVE_INFINITY, false);\n    test(0.0, true);\n    test(-0.0, true);\n    test(123.0, true);\n    test(-123.0, true);\n    test(1.0e9, true);\n    test(-1.0e9, true);\n    test(4294967295.0, true);\n    test(-4294967295.0, true);\n    test(4294967296.0, true);\n    test(-4294967296.0, true);\n    test(18446744073709551615.0, true);\n    test(-18446744073709551615.0, true);\n    test(18446744073709551616.0, true);\n    test(-18446744073709551616.0, true);\n    test(1.0e20, true);\n    test(-1.0e20, true);\n    test(1.23e20, true);\n    test(-1.23e20, true);\n    test(123.1, false);\n    test(-123.1, false);\n    test(123.5, false);\n    test(-123.5, false);\n    test(124.5, false);\n    test(-124.5, false);\n    test(f32::MIN_POSITIVE, false);\n    test(-f32::MIN_POSITIVE, false);\n    test(f32::MAX_SUBNORMAL, false);\n    test(-f32::MAX_SUBNORMAL, false);\n    test(f32::MIN_POSITIVE_NORMAL, false);\n    test(-f32::MIN_POSITIVE_NORMAL, false);\n    test(f32::MAX_FINITE, true);\n    test(-f32::MAX_FINITE, true);\n}\n\n#[test]\nfn test_convertible_from_f64() {\n    let test = |f: f64, out| {\n        assert_eq!(Integer::convertible_from(f), out);\n    };\n    test(f64::NAN, false);\n    test(f64::INFINITY, false);\n    test(f64::NEGATIVE_INFINITY, false);\n    test(0.0, true);\n    test(-0.0, true);\n    test(123.0, true);\n    test(-123.0, true);\n    test(1.0e9, true);\n    test(-1.0e9, true);\n    test(4294967295.0, true);\n    test(-4294967295.0, true);\n    test(4294967296.0, true);\n    test(-4294967296.0, true);\n    test(18446744073709551615.0, true);\n    test(-18446744073709551615.0, true);\n    test(18446744073709551616.0, true);\n    test(-18446744073709551616.0, true);\n    test(1.0e20, true);\n    test(-1.0e20, true);\n    test(1.23e20, true);\n    test(-1.23e20, true);\n    test(1.0e100, true);\n    test(-1.0e100, true);\n    test(1.23e100, true);\n    test(-1.23e100, true);\n    test(123.1, false);\n    test(-123.1, false);\n    test(123.5, false);\n    test(-123.5, false);\n    test(124.5, false);\n    test(-124.5, false);\n    test(f64::MIN_POSITIVE, false);\n    test(-f64::MIN_POSITIVE, false);\n    test(f64::MAX_SUBNORMAL, false);\n    test(-f64::MAX_SUBNORMAL, false);\n    test(f64::MIN_POSITIVE_NORMAL, false);\n    test(-f64::MIN_POSITIVE_NORMAL, false);\n    test(f64::MAX_FINITE, true);\n    test(-f64::MAX_FINITE, true);\n}\n\nfn rounding_from_float_properties_helper<T: PrimitiveFloat + for<'a> RoundingFrom<&'a Integer>>()\nwhere\n    Integer: PartialEq<Integer> + PartialOrd<T> + RoundingFrom<T>,\n    SignedLimb: ConvertibleFrom<T> + RoundingFrom<T>,\n{\n    primitive_float_rounding_mode_pair_gen_var_2::<T>().test_properties(|(f, rm)| {\n        let (n, o) = Integer::rounding_from(f, rm);\n        assert!(n.is_valid());\n        let (n_alt, o_alt) = Integer::rounding_from(-f, -rm);\n        assert_eq!(&n_alt, &-&n);\n        assert_eq!(o_alt, o.reverse());\n\n        assert_eq!(n.partial_cmp(&f), Some(o));\n        match (f.is_sign_positive(), rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    primitive_float_gen_var_5::<T>().test_properties(|f| {\n        let no = Integer::rounding_from(f, Exact);\n        assert!(no.0.is_valid());\n        assert_eq!(no.1, Equal);\n        assert_eq!(no, Integer::rounding_from(f, Floor));\n        assert_eq!(no, Integer::rounding_from(f, Ceiling));\n        assert_eq!(no, Integer::rounding_from(f, Down));\n        assert_eq!(no, Integer::rounding_from(f, Up));\n        assert_eq!(no, Integer::rounding_from(f, Nearest));\n        assert_eq!(T::rounding_from(&no.0, Exact), (f, Equal));\n    });\n\n    primitive_float_gen_var_6::<T>().test_properties(|f| {\n        let n_floor = Integer::rounding_from(f, Floor);\n        assert!(n_floor.0.is_valid());\n        assert_eq!(n_floor.1, Less);\n        let n_ceiling = (&n_floor.0 + Integer::ONE, Greater);\n        assert_eq!(n_ceiling, Integer::rounding_from(f, Ceiling));\n        if f >= T::ZERO {\n            assert_eq!(n_floor, Integer::rounding_from(f, Down));\n            assert_eq!(n_ceiling, Integer::rounding_from(f, Up));\n        } else {\n            assert_eq!(n_ceiling, Integer::rounding_from(f, Down));\n            assert_eq!(n_floor, Integer::rounding_from(f, Up));\n        }\n        let n_nearest = Integer::rounding_from(f, Nearest);\n        assert!(n_nearest == n_floor || n_nearest == n_ceiling);\n    });\n\n    primitive_float_gen_var_7::<T>().test_properties(|f| {\n        let floor = Integer::rounding_from(f, Floor);\n        assert_eq!(floor.1, Less);\n        let ceiling = (&floor.0 + Integer::ONE, Greater);\n        let nearest = Integer::rounding_from(f, Nearest);\n        assert_eq!(nearest, if floor.0.even() { floor } else { ceiling });\n    });\n\n    let min: Integer = From::from(SignedLimb::MIN);\n    let max: Integer = From::from(SignedLimb::MAX);\n    primitive_float_rounding_mode_pair_gen_var_3::<T, SignedLimb>().test_properties(\n        move |(f, rm)| {\n            if f.is_finite() {\n                let mut n = Integer::rounding_from(f, rm).0;\n                if PartialOrd::<Integer>::gt(&n, &max) {\n                    n = max.clone();\n                }\n                if PartialOrd::<Integer>::lt(&n, &min) {\n                    n = min.clone();\n                }\n                assert_eq!(SignedLimb::rounding_from(f, rm).0, n);\n            }\n        },\n    );\n}\n\n#[test]\nfn rounding_from_float_properties() {\n    apply_fn_to_primitive_floats!(rounding_from_float_properties_helper);\n}\n\nfn try_from_float_properties_helper<T: PrimitiveFloat + for<'a> RoundingFrom<&'a Integer>>()\nwhere\n    Integer: TryFrom<T, Error = SignedFromFloatError> + RoundingFrom<T>,\n    SignedLimb: TryFrom<NiceFloat<T>>,\n    NiceFloat<T>: TryFrom<SignedLimb>,\n{\n    primitive_float_gen::<T>().test_properties(|f| {\n        let on = Integer::try_from(f);\n        assert!(on.as_ref().map_or(true, Integer::is_valid));\n        assert_eq!(Integer::try_from(-f), on.map(|n| -n));\n        if let Ok(n) = SignedLimb::try_from(NiceFloat(f)) {\n            assert_eq!(n, Integer::exact_from(f));\n        }\n    });\n\n    primitive_float_gen_var_5::<T>().test_properties(|f| {\n        let n = Integer::exact_from(f);\n        assert!(n.is_valid());\n        assert_eq!(n, Integer::rounding_from(f, Exact).0);\n        assert_eq!(T::rounding_from(&n, Exact).0, f);\n    });\n\n    primitive_float_gen_var_6::<T>().test_properties(|f| {\n        assert!(Integer::try_from(f).is_err());\n    });\n\n    primitive_float_gen_var_7::<T>().test_properties(|f| {\n        assert!(Integer::try_from(f).is_err());\n    });\n\n    primitive_float_gen_var_14::<T, SignedLimb>().test_properties(|f| {\n        assert_eq!(SignedLimb::exact_from(NiceFloat(f)), Integer::exact_from(f));\n    });\n}\n\n#[test]\nfn try_from_float_properties() {\n    apply_fn_to_primitive_floats!(try_from_float_properties_helper);\n}\n\nfn convertible_from_float_properties_helper<T: PrimitiveFloat>()\nwhere\n    Integer: ConvertibleFrom<T>,\n    SignedLimb: ConvertibleFrom<T>,\n{\n    primitive_float_gen::<T>().test_properties(|f| {\n        let nc = Integer::convertible_from(f);\n        if SignedLimb::convertible_from(f) {\n            assert!(nc);\n        }\n    });\n\n    primitive_float_gen_var_5::<T>().test_properties(|f| {\n        assert!(Integer::convertible_from(f));\n    });\n\n    primitive_float_gen_var_6::<T>().test_properties(|f| {\n        assert!(!Integer::convertible_from(f));\n    });\n\n    primitive_float_gen_var_7::<T>().test_properties(|f| {\n        assert!(!Integer::convertible_from(f));\n    });\n}\n\n#[test]\nfn convertible_from_float_properties() {\n    apply_fn_to_primitive_floats!(convertible_from_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_gen, signed_gen_var_2, unsigned_gen};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse num::BigInt;\nuse rug;\n\n#[test]\nfn test_from_u32() {\n    let test = |u: u32, out| {\n        let x = Integer::from(u);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(BigInt::from(u).to_string(), out);\n        assert_eq!(rug::Integer::from(u).to_string(), out);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let x_alt = Integer::const_from_unsigned(u);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(u32::MAX, \"4294967295\");\n}\n\n#[test]\nfn test_from_u64() {\n    let test = |u: u64, out| {\n        let x = Integer::from(u);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(BigInt::from(u).to_string(), out);\n        assert_eq!(rug::Integer::from(u).to_string(), out);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let x_alt = Integer::const_from_unsigned(u);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(u64::MAX, \"18446744073709551615\");\n}\n\n#[test]\nfn test_from_i32() {\n    let test = |i: i32, out| {\n        let x = Integer::from(i);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(BigInt::from(i).to_string(), out);\n        assert_eq!(rug::Integer::from(i).to_string(), out);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let x_alt = Integer::const_from_signed(i);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(-123, \"-123\");\n    test(i32::MIN, \"-2147483648\");\n    test(i32::MAX, \"2147483647\");\n}\n\n#[test]\nfn test_from_i64() {\n    let test = |i: i64, out| {\n        let x = Integer::from(i);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(BigInt::from(i).to_string(), out);\n        assert_eq!(rug::Integer::from(i).to_string(), out);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let x_alt = Integer::const_from_signed(i);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(-123, \"-123\");\n    test(i64::MIN, \"-9223372036854775808\");\n    test(i64::MAX, \"9223372036854775807\");\n}\n\nfn from_unsigned_properties_helper<T: for<'a> TryFrom<&'a Integer> + PrimitiveUnsigned>()\nwhere\n    Integer: From<T>,\n    Natural: From<T>,\n    u128: TryFrom<T>,\n{\n    unsigned_gen::<T>().test_properties(|u| {\n        let n = Integer::from(u);\n        assert!(n.is_valid());\n        assert_eq!(T::exact_from(&n), u);\n        let alt_n: Integer = From::from(Natural::from(u));\n        assert_eq!(alt_n, n);\n        let alt_n: Integer = From::from(u128::exact_from(u));\n        assert_eq!(alt_n, n);\n    });\n}\n\nfn from_signed_properties_helper<T: for<'a> TryFrom<&'a Integer> + PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n    Natural: TryFrom<T>,\n    i128: TryFrom<T>,\n{\n    signed_gen::<T>().test_properties(|i| {\n        let n = Integer::from(i);\n        assert!(n.is_valid());\n        assert_eq!(T::exact_from(&n), i);\n        let alt_n: Integer = From::from(i128::exact_from(i));\n        assert_eq!(alt_n, n);\n    });\n\n    signed_gen_var_2::<T>().test_properties(|i| {\n        let n: Integer = From::from(Natural::exact_from(i));\n        assert_eq!(n, Integer::from(i));\n    });\n}\n\n#[test]\nfn from_primitive_int_properties() {\n    apply_fn_to_unsigneds!(from_unsigned_properties_helper);\n    apply_fn_to_signeds!(from_signed_properties_helper);\n\n    unsigned_gen::<u32>().test_properties(|u| {\n        let n = Integer::from(u);\n        assert_eq!(Integer::from(&BigInt::from(u)), n);\n        assert_eq!(Integer::from(&rug::Integer::from(u)), n);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let n_alt = Integer::const_from_unsigned(u);\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n\n    unsigned_gen::<u64>().test_properties(|u| {\n        let n = Integer::from(u);\n        assert_eq!(Integer::from(&BigInt::from(u)), n);\n        assert_eq!(Integer::from(&rug::Integer::from(u)), n);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let n_alt = Integer::const_from_unsigned(u);\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n\n    signed_gen::<i32>().test_properties(|i| {\n        let n = Integer::from(i);\n        assert_eq!(Integer::from(&BigInt::from(i)), n);\n        assert_eq!(Integer::from(&rug::Integer::from(i)), n);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let n_alt = Integer::const_from_signed(i);\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n\n    signed_gen::<i64>().test_properties(|i| {\n        let n = Integer::from(i);\n        assert_eq!(Integer::from(&BigInt::from(i)), n);\n        assert_eq!(Integer::from(&rug::Integer::from(i)), n);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let n_alt = Integer::const_from_signed(i);\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/from_twos_complement_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_base::vecs::vec_delete_left;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::*;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_from_twos_complement_limbs_asc() {\n    let test = |xs: &[Limb], out| {\n        let x = Integer::from_twos_complement_limbs_asc(xs);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        let x = Integer::from_owned_twos_complement_limbs_asc(xs.to_vec());\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(&[], \"0\");\n    test(&[0], \"0\");\n    test(&[0, 0, 0], \"0\");\n    test(&[123], \"123\");\n    test(&[123, 0], \"123\");\n    test(&[4294967173], \"-123\");\n    test(&[4294967173, u32::MAX], \"-123\");\n    test(&[3567587328, 232], \"1000000000000\");\n    test(&[727379968, 4294967063], \"-1000000000000\");\n    test(&[1, 2, 3, 4, 5], \"1701411834921604967429270619762735448065\");\n    test(\n        &[u32::MAX, u32::MAX - 2, u32::MAX - 3, u32::MAX - 4, u32::MAX - 5],\n        \"-1701411834921604967429270619762735448065\",\n    );\n    test(&[u32::MAX, 0], \"4294967295\");\n    test(&[1, u32::MAX], \"-4294967295\");\n    test(&[0, 1], \"4294967296\");\n    test(&[0, u32::MAX], \"-4294967296\");\n    test(&[u32::MAX, u32::MAX, 0], \"18446744073709551615\");\n    test(&[1, 0, u32::MAX], \"-18446744073709551615\");\n    test(&[0, 0, 1], \"18446744073709551616\");\n    test(&[0, 0, u32::MAX], \"-18446744073709551616\");\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_from_twos_complement_limbs_desc() {\n    let test = |xs: &[Limb], out| {\n        let x = Integer::from_twos_complement_limbs_desc(xs);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        let x = Integer::from_owned_twos_complement_limbs_desc(xs.to_vec());\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(&[], \"0\");\n    test(&[0], \"0\");\n    test(&[0, 0, 0], \"0\");\n    test(&[123], \"123\");\n    test(&[0, 123], \"123\");\n    test(&[4294967173], \"-123\");\n    test(&[u32::MAX, 4294967173], \"-123\");\n    test(&[232, 3567587328], \"1000000000000\");\n    test(&[4294967063, 727379968], \"-1000000000000\");\n    test(&[5, 4, 3, 2, 1], \"1701411834921604967429270619762735448065\");\n    test(\n        &[u32::MAX - 5, u32::MAX - 4, u32::MAX - 3, u32::MAX - 2, u32::MAX],\n        \"-1701411834921604967429270619762735448065\",\n    );\n    test(&[0, u32::MAX], \"4294967295\");\n    test(&[u32::MAX, 1], \"-4294967295\");\n    test(&[1, 0], \"4294967296\");\n    test(&[u32::MAX, 0], \"-4294967296\");\n    test(&[0, u32::MAX, u32::MAX], \"18446744073709551615\");\n    test(&[u32::MAX, 0, 1], \"-18446744073709551615\");\n    test(&[1, 0, 0], \"18446744073709551616\");\n    test(&[u32::MAX, 0, 0], \"-18446744073709551616\");\n}\n\nfn trim_be_limbs(xs: &mut Vec<Limb>) {\n    if xs.is_empty() {\n        return;\n    }\n    if xs[0].get_highest_bit() {\n        match xs.iter().position(|&limb| limb != Limb::MAX) {\n            None => *xs = vec![Limb::MAX],\n            Some(i) => {\n                let i = if xs[i].get_highest_bit() { i } else { i - 1 };\n                vec_delete_left(xs, i);\n            }\n        }\n    } else {\n        match xs.iter().position(|&limb| limb != 0) {\n            None => xs.clear(),\n            Some(i) => {\n                let i = if xs[i].get_highest_bit() { i - 1 } else { i };\n                vec_delete_left(xs, i);\n            }\n        }\n    }\n}\n\n#[test]\nfn from_twos_complement_limbs_asc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        let x = Integer::from_twos_complement_limbs_asc(&xs);\n        assert_eq!(Integer::from_owned_twos_complement_limbs_asc(xs.clone()), x);\n        let mut trimmed_xs = xs.iter().copied().rev().collect_vec();\n        trim_be_limbs(&mut trimmed_xs);\n        trimmed_xs.reverse();\n        assert_eq!(x.to_twos_complement_limbs_asc(), trimmed_xs);\n        assert_eq!(\n            Integer::from_owned_twos_complement_limbs_desc(xs.iter().copied().rev().collect()),\n            x\n        );\n        if match x.sign() {\n            Equal => xs.is_empty(),\n            Greater => {\n                let last = *xs.last().unwrap();\n                !last.get_highest_bit() && (last != 0 || xs[xs.len() - 2].get_highest_bit())\n            }\n            Less => {\n                let last = *xs.last().unwrap();\n                last.get_highest_bit()\n                    && (last != Limb::MAX || xs.len() <= 1 || !xs[xs.len() - 2].get_highest_bit())\n            }\n        } {\n            assert_eq!(x.to_twos_complement_limbs_asc(), xs);\n        }\n    });\n}\n\n#[test]\nfn from_twos_complement_limbs_desc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        let x = Integer::from_twos_complement_limbs_desc(&xs);\n        assert_eq!(\n            Integer::from_owned_twos_complement_limbs_desc(xs.clone()),\n            x\n        );\n        let mut trimmed_xs = xs.clone();\n        trim_be_limbs(&mut trimmed_xs);\n        assert_eq!(x.to_twos_complement_limbs_desc(), trimmed_xs);\n        assert_eq!(\n            Integer::from_owned_twos_complement_limbs_asc(xs.iter().copied().rev().collect()),\n            x\n        );\n        if match x.sign() {\n            Equal => xs.is_empty(),\n            Greater => {\n                let first = xs[0];\n                !first.get_highest_bit() && (first != 0 || xs[1].get_highest_bit())\n            }\n            Less => {\n                let first = xs[0];\n                first.get_highest_bit()\n                    && (first != Limb::MAX || xs.len() <= 1 || !xs[1].get_highest_bit())\n            }\n        } {\n            assert_eq!(x.to_twos_complement_limbs_desc(), xs);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_is_integer() {\n    let test = |n, out| {\n        assert_eq!(Integer::from_str(n).unwrap().is_integer(), out);\n    };\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"100\", true);\n    test(\"-1\", true);\n    test(\"-100\", true);\n}\n\n#[test]\nfn is_integer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    integer_gen().test_properties_with_config(&config, |n| {\n        assert!(n.is_integer());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/natural_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::integer_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_try_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let on = Natural::try_from(u.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n\n        let on = Natural::try_from(&u);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(\"0\", \"Ok(0)\");\n    test(\"123\", \"Ok(123)\");\n    test(\"-123\", \"Err(NaturalFromIntegerError)\");\n    test(\"1000000000000\", \"Ok(1000000000000)\");\n    test(\"-1000000000000\", \"Err(NaturalFromIntegerError)\");\n    test(\"2147483647\", \"Ok(2147483647)\");\n    test(\"2147483648\", \"Ok(2147483648)\");\n    test(\"-2147483648\", \"Err(NaturalFromIntegerError)\");\n    test(\"-2147483649\", \"Err(NaturalFromIntegerError)\");\n}\n\n#[test]\nfn test_exact_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let n = Natural::exact_from(u.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::exact_from(&u);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"123\");\n    test(\"1000000000000\", \"1000000000000\");\n    test(\"2147483647\", \"2147483647\");\n    test(\"2147483648\", \"2147483648\");\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_fail_1() {\n    Natural::exact_from(Integer::from_str(\"-123\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_fail_2() {\n    Natural::exact_from(Integer::from_str(\"-1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_fail_3() {\n    Natural::exact_from(Integer::from_str(\"-2147483648\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_fail_4() {\n    Natural::exact_from(Integer::from_str(\"-2147483649\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_ref_fail_1() {\n    Natural::exact_from(&Integer::from_str(\"-123\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_ref_fail_2() {\n    Natural::exact_from(&Integer::from_str(\"-1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_ref_fail_3() {\n    Natural::exact_from(&Integer::from_str(\"-2147483648\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_integer_ref_fail_4() {\n    Natural::exact_from(&Integer::from_str(\"-2147483649\").unwrap());\n}\n\n#[test]\nfn test_saturating_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        let n = Natural::saturating_from(u.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::saturating_from(&u);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"123\");\n    test(\"-123\", \"0\");\n    test(\"1000000000000\", \"1000000000000\");\n    test(\"-1000000000000\", \"0\");\n    test(\"2147483647\", \"2147483647\");\n    test(\"2147483648\", \"2147483648\");\n    test(\"-2147483648\", \"0\");\n    test(\"-2147483649\", \"0\");\n}\n\n#[test]\nfn test_convertible_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(Natural::convertible_from(u.clone()), out);\n        assert_eq!(Natural::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"-123\", false);\n    test(\"1000000000000\", true);\n    test(\"-1000000000000\", false);\n    test(\"2147483647\", true);\n    test(\"2147483648\", true);\n    test(\"-2147483648\", false);\n    test(\"-2147483649\", false);\n}\n\n#[test]\nfn try_from_integer_properties() {\n    integer_gen().test_properties(|x| {\n        let natural_x = Natural::try_from(x.clone());\n        assert!(natural_x.as_ref().map_or(true, Natural::is_valid));\n\n        let natural_x_alt = Natural::try_from(&x);\n        assert!(natural_x_alt.as_ref().map_or(true, Natural::is_valid));\n        assert_eq!(natural_x, natural_x_alt);\n\n        assert_eq!(natural_x.is_ok(), x >= 0);\n        assert_eq!(natural_x.is_ok(), Natural::convertible_from(&x));\n        if let Ok(n) = natural_x {\n            assert_eq!(n.to_string(), x.to_string());\n            assert_eq!(Natural::exact_from(&x), n);\n            assert_eq!(Integer::from(&n), x);\n            assert_eq!(Integer::from(n), x);\n        }\n    });\n}\n\n#[test]\nfn saturating_from_integer_properties() {\n    integer_gen().test_properties(|x| {\n        let natural_x = Natural::saturating_from(x.clone());\n        assert!(natural_x.is_valid());\n\n        let natural_x_alt = Natural::saturating_from(&x);\n        assert!(natural_x_alt.is_valid());\n        assert_eq!(natural_x, natural_x_alt);\n\n        assert_eq!(natural_x == 0, x <= 0);\n        assert!(natural_x >= x);\n        assert_eq!(natural_x == x, Natural::convertible_from(x));\n    });\n}\n\n#[test]\nfn convertible_from_integer_properties() {\n    integer_gen().test_properties(|x| {\n        let convertible = Natural::convertible_from(x.clone());\n        assert_eq!(Natural::convertible_from(&x), convertible);\n        assert_eq!(convertible, x >= 0);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/primitive_float_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_7, signed_rounding_mode_pair_gen_var_4,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::conversion::primitive_float_from_integer::PrimitiveFloatFromIntegerError;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_1, integer_gen_var_2, integer_gen_var_3,\n    integer_rounding_mode_pair_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_f32_rounding_from_integer() {\n    let test = |s: &str, rm: RoundingMode, out, o_out| {\n        let u = Integer::from_str(s).unwrap();\n        let (x, o) = f32::rounding_from(&u, rm);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n        assert_eq!(o, o_out);\n    };\n    test(\"3\", Exact, 3.0, Equal);\n    test(\"-3\", Exact, -3.0, Equal);\n    test(\"123\", Exact, 123.0, Equal);\n    test(\"-123\", Exact, -123.0, Equal);\n    test(\"0\", Exact, 0.0, Equal);\n    test(\"1000000000\", Exact, 1.0e9, Equal);\n    test(\"-1000000000\", Exact, -1.0e9, Equal);\n    test(\"16777216\", Exact, 1.6777216e7, Equal);\n    test(\"-16777216\", Exact, -1.6777216e7, Equal);\n    test(\"16777218\", Exact, 1.6777218e7, Equal);\n    test(\"-16777218\", Exact, -1.6777218e7, Equal);\n\n    test(\"16777217\", Floor, 1.6777216e7, Less);\n    test(\"16777217\", Down, 1.6777216e7, Less);\n    test(\"16777217\", Ceiling, 1.6777218e7, Greater);\n    test(\"16777217\", Up, 1.6777218e7, Greater);\n    test(\"16777217\", Nearest, 1.6777216e7, Less);\n\n    test(\"-16777217\", Floor, -1.6777218e7, Less);\n    test(\"-16777217\", Down, -1.6777216e7, Greater);\n    test(\"-16777217\", Ceiling, -1.6777216e7, Greater);\n    test(\"-16777217\", Up, -1.6777218e7, Less);\n    test(\"-16777217\", Nearest, -1.6777216e7, Greater);\n\n    test(\"33554432\", Exact, 3.3554432e7, Equal);\n    test(\"-33554432\", Exact, -3.3554432e7, Equal);\n    test(\"33554436\", Exact, 3.3554436e7, Equal);\n    test(\"-33554436\", Exact, -3.3554436e7, Equal);\n\n    test(\"33554433\", Floor, 3.3554432e7, Less);\n    test(\"33554433\", Down, 3.3554432e7, Less);\n    test(\"33554433\", Ceiling, 3.3554436e7, Greater);\n    test(\"33554433\", Up, 3.3554436e7, Greater);\n    test(\"33554433\", Nearest, 3.3554432e7, Less);\n\n    test(\"-33554433\", Floor, -3.3554436e7, Less);\n    test(\"-33554433\", Down, -3.3554432e7, Greater);\n    test(\"-33554433\", Ceiling, -3.3554432e7, Greater);\n    test(\"-33554433\", Up, -3.3554436e7, Less);\n    test(\"-33554433\", Nearest, -3.3554432e7, Greater);\n\n    test(\"33554434\", Nearest, 3.3554432e7, Less);\n    test(\"-33554434\", Nearest, -3.3554432e7, Greater);\n    test(\"33554435\", Nearest, 3.3554436e7, Greater);\n    test(\"-33554435\", Nearest, -3.3554436e7, Less);\n\n    test(\n        \"340282346638528859811704183484516925439\",\n        Floor,\n        3.4028233e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Down,\n        3.4028233e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Ceiling,\n        3.4028235e38,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Up,\n        3.4028235e38,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Nearest,\n        3.4028235e38,\n        Greater,\n    );\n\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Floor,\n        -3.4028235e38,\n        Less,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Down,\n        -3.4028233e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Ceiling,\n        -3.4028233e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Up,\n        -3.4028235e38,\n        Less,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Nearest,\n        -3.4028235e38,\n        Less,\n    );\n\n    test(\n        \"340282346638528859811704183484516925440\",\n        Exact,\n        3.4028235e38,\n        Equal,\n    );\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Exact,\n        -3.4028235e38,\n        Equal,\n    );\n\n    test(\n        \"340282346638528859811704183484516925441\",\n        Floor,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Down,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Nearest,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Ceiling,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Up,\n        f32::INFINITY,\n        Greater,\n    );\n\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Floor,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Down,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Nearest,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Ceiling,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Up,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Down,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Up,\n        f32::INFINITY,\n        Greater,\n    );\n\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Down,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Up,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n\n    test(\"1125899873419263\", Floor, 1.12589984e15, Less);\n    test(\"1125899873419263\", Down, 1.12589984e15, Less);\n    test(\"1125899873419263\", Ceiling, 1.1258999e15, Greater);\n    test(\"1125899873419263\", Up, 1.1258999e15, Greater);\n    test(\"1125899873419263\", Nearest, 1.1258999e15, Greater);\n\n    test(\"-1125899873419263\", Floor, -1.1258999e15, Less);\n    test(\"-1125899873419263\", Down, -1.12589984e15, Greater);\n    test(\"-1125899873419263\", Ceiling, -1.12589984e15, Greater);\n    test(\"-1125899873419263\", Up, -1.1258999e15, Less);\n    test(\"-1125899873419263\", Nearest, -1.1258999e15, Less);\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_integer_fail_1() {\n    f32::rounding_from(\n        &Integer::from_str(\"340282346638528859811704183484516925439\").unwrap(),\n        Exact,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_integer_fail_2() {\n    f32::rounding_from(\n        &Integer::from_str(\"340282346638528859811704183484516925441\").unwrap(),\n        Exact,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_integer_fail_3() {\n    f32::rounding_from(&Integer::from_str(\"16777217\").unwrap(), Exact);\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_integer_fail_4() {\n    f32::rounding_from(\n        &Integer::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n        Exact,\n    );\n}\n\n#[test]\nfn test_f64_rounding_from_integer() {\n    let test = |s: &str, rm: RoundingMode, out, o_out| {\n        let u = Integer::from_str(s).unwrap();\n        let (x, o) = f64::rounding_from(&u, rm);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n        assert_eq!(o, o_out);\n    };\n    test(\"3\", Exact, 3.0, Equal);\n    test(\"-3\", Exact, -3.0, Equal);\n    test(\"123\", Exact, 123.0, Equal);\n    test(\"-123\", Exact, -123.0, Equal);\n    test(\"0\", Exact, 0.0, Equal);\n    test(\"100000000000000000000\", Exact, 1.0e20, Equal);\n    test(\"-100000000000000000000\", Exact, -1.0e20, Equal);\n    test(\"9007199254740992\", Exact, 9.007199254740992e15, Equal);\n    test(\"-9007199254740992\", Exact, -9.007199254740992e15, Equal);\n    test(\"9007199254740994\", Exact, 9.007199254740994e15, Equal);\n    test(\"-9007199254740994\", Exact, -9.007199254740994e15, Equal);\n\n    test(\"9007199254740993\", Floor, 9.007199254740992e15, Less);\n    test(\"9007199254740993\", Down, 9.007199254740992e15, Less);\n    test(\"9007199254740993\", Ceiling, 9.007199254740994e15, Greater);\n    test(\"9007199254740993\", Up, 9.007199254740994e15, Greater);\n    test(\"9007199254740993\", Nearest, 9.007199254740992e15, Less);\n\n    test(\"-9007199254740993\", Floor, -9.007199254740994e15, Less);\n    test(\"-9007199254740993\", Down, -9.007199254740992e15, Greater);\n    test(\"-9007199254740993\", Ceiling, -9.007199254740992e15, Greater);\n    test(\"-9007199254740993\", Up, -9.007199254740994e15, Less);\n    test(\"-9007199254740993\", Nearest, -9.007199254740992e15, Greater);\n\n    test(\"18014398509481984\", Exact, 1.8014398509481984e16, Equal);\n    test(\"-18014398509481984\", Exact, -1.8014398509481984e16, Equal);\n    test(\"18014398509481988\", Exact, 1.8014398509481988e16, Equal);\n    test(\"-18014398509481988\", Exact, -1.8014398509481988e16, Equal);\n\n    test(\"18014398509481985\", Floor, 1.8014398509481984e16, Less);\n    test(\"18014398509481985\", Down, 1.8014398509481984e16, Less);\n    test(\"18014398509481985\", Ceiling, 1.8014398509481988e16, Greater);\n    test(\"18014398509481985\", Up, 1.8014398509481988e16, Greater);\n    test(\"18014398509481985\", Nearest, 1.8014398509481984e16, Less);\n\n    test(\"-18014398509481985\", Floor, -1.8014398509481988e16, Less);\n    test(\"-18014398509481985\", Down, -1.8014398509481984e16, Greater);\n    test(\n        \"-18014398509481985\",\n        Ceiling,\n        -1.8014398509481984e16,\n        Greater,\n    );\n    test(\"-18014398509481985\", Up, -1.8014398509481988e16, Less);\n    test(\n        \"-18014398509481985\",\n        Nearest,\n        -1.8014398509481984e16,\n        Greater,\n    );\n\n    test(\"18014398509481986\", Nearest, 1.8014398509481984e16, Less);\n    test(\n        \"-18014398509481986\",\n        Nearest,\n        -1.8014398509481984e16,\n        Greater,\n    );\n    test(\"18014398509481987\", Nearest, 1.8014398509481988e16, Greater);\n    test(\"-18014398509481987\", Nearest, -1.8014398509481988e16, Less);\n\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Floor,\n        1.7976931348623155e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Down,\n        1.7976931348623155e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Ceiling,\n        1.7976931348623157e308,\n        Greater,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Up,\n        1.7976931348623157e308,\n        Greater,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Nearest,\n        1.7976931348623157e308,\n        Greater,\n    );\n\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        Floor,\n        -1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        Down,\n        -1.7976931348623155e308,\n        Greater,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        Ceiling,\n        -1.7976931348623155e308,\n        Greater,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        Up,\n        -1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        Nearest,\n        -1.7976931348623157e308,\n        Less,\n    );\n\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        Exact,\n        1.7976931348623157e308,\n        Equal,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n        Exact,\n        -1.7976931348623157e308,\n        Equal,\n    );\n\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Floor,\n        1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Down,\n        1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Nearest,\n        1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Ceiling,\n        f64::INFINITY,\n        Greater,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Up,\n        f64::INFINITY,\n        Greater,\n    );\n\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        Floor,\n        f64::NEGATIVE_INFINITY,\n        Less,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        Down,\n        -1.7976931348623157e308,\n        Greater,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        Nearest,\n        -1.7976931348623157e308,\n        Greater,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        Ceiling,\n        -1.7976931348623157e308,\n        Greater,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        Up,\n        f64::NEGATIVE_INFINITY,\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f64_rounding_from_integer_fail_1() {\n    f64::rounding_from(&Integer::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap(),\n                       Exact);\n}\n\n#[test]\n#[should_panic]\nfn f64_rounding_from_integer_fail_2() {\n    f64::rounding_from(&Integer::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap(),\n                       Exact);\n}\n\n#[test]\n#[should_panic]\nfn f64_rounding_from_integer_fail_3() {\n    f64::rounding_from(&Integer::from_str(\"9007199254740993\").unwrap(), Exact);\n}\n\n#[test]\nfn test_f32_try_from_integer() {\n    let test = |s: &str, out: Result<f32, PrimitiveFloatFromIntegerError>| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(f32::try_from(&u).map(NiceFloat), out.map(NiceFloat));\n    };\n    test(\"3\", Ok(3.0));\n    test(\"-3\", Ok(-3.0));\n    test(\"123\", Ok(123.0));\n    test(\"-123\", Ok(-123.0));\n    test(\"0\", Ok(0.0));\n    test(\"1000000000\", Ok(1.0e9));\n    test(\"-1000000000\", Ok(-1.0e9));\n    test(\"16777216\", Ok(1.6777216e7));\n    test(\"-16777216\", Ok(-1.6777216e7));\n    test(\"16777218\", Ok(1.6777218e7));\n    test(\"-16777218\", Ok(-1.6777218e7));\n    test(\"16777217\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-16777217\", Err(PrimitiveFloatFromIntegerError));\n    test(\"33554432\", Ok(3.3554432e7));\n    test(\"-33554432\", Ok(-3.3554432e7));\n    test(\"33554436\", Ok(3.3554436e7));\n    test(\"-33554436\", Ok(-3.3554436e7));\n    test(\"33554433\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-33554433\", Err(PrimitiveFloatFromIntegerError));\n    test(\"33554434\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-33554434\", Err(PrimitiveFloatFromIntegerError));\n    test(\"33554435\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-33554435\", Err(PrimitiveFloatFromIntegerError));\n    test(\n        \"340282346638528859811704183484516925439\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\"340282346638528859811704183484516925440\", Ok(3.4028235e38));\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Ok(-3.4028235e38),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n}\n\n#[test]\nfn test_f64_try_from_integer() {\n    let test = |s: &str, out: Result<f64, PrimitiveFloatFromIntegerError>| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(f64::try_from(&u).map(NiceFloat), out.map(NiceFloat));\n    };\n    test(\"3\", Ok(3.0));\n    test(\"-3\", Ok(-3.0));\n    test(\"123\", Ok(123.0));\n    test(\"-123\", Ok(-123.0));\n    test(\"0\", Ok(0.0));\n    test(\"1000000000\", Ok(1.0e9));\n    test(\"-1000000000\", Ok(-1.0e9));\n    test(\"9007199254740992\", Ok(9.007199254740992e15));\n    test(\"-9007199254740992\", Ok(-9.007199254740992e15));\n    test(\"9007199254740994\", Ok(9.007199254740994e15));\n    test(\"-9007199254740994\", Ok(-9.007199254740994e15));\n    test(\"9007199254740993\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-9007199254740993\", Err(PrimitiveFloatFromIntegerError));\n    test(\"18014398509481984\", Ok(1.8014398509481984e16));\n    test(\"-18014398509481984\", Ok(-1.8014398509481984e16));\n    test(\"18014398509481988\", Ok(1.8014398509481988e16));\n    test(\"-18014398509481988\", Ok(-1.8014398509481988e16));\n    test(\"18014398509481985\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-18014398509481985\", Err(PrimitiveFloatFromIntegerError));\n    test(\"18014398509481986\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-18014398509481986\", Err(PrimitiveFloatFromIntegerError));\n    test(\"18014398509481987\", Err(PrimitiveFloatFromIntegerError));\n    test(\"-18014398509481987\", Err(PrimitiveFloatFromIntegerError));\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        Ok(1.7976931348623157e308),\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n        Ok(-1.7976931348623157e308),\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        Err(PrimitiveFloatFromIntegerError),\n    );\n}\n\n#[test]\nfn test_f32_exact_from_integer() {\n    let test = |s: &str, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(NiceFloat(f32::exact_from(&u)), NiceFloat(out));\n    };\n    test(\"3\", 3.0);\n    test(\"-3\", -3.0);\n    test(\"123\", 123.0);\n    test(\"-123\", -123.0);\n    test(\"0\", 0.0);\n    test(\"1000000000\", 1.0e9);\n    test(\"-1000000000\", -1.0e9);\n    test(\"16777216\", 1.6777216e7);\n    test(\"-16777216\", -1.6777216e7);\n    test(\"16777218\", 1.6777218e7);\n    test(\"-16777218\", -1.6777218e7);\n    test(\"33554432\", 3.3554432e7);\n    test(\"-33554432\", -3.3554432e7);\n    test(\"33554436\", 3.3554436e7);\n    test(\"-33554436\", -3.3554436e7);\n    test(\"340282346638528859811704183484516925440\", 3.4028235e38);\n    test(\"-340282346638528859811704183484516925440\", -3.4028235e38);\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_1() {\n    f32::exact_from(&Integer::from_str(\"16777217\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_2() {\n    f32::exact_from(&Integer::from_str(\"-16777217\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_3() {\n    f32::exact_from(&Integer::from_str(\"33554433\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_4() {\n    f32::exact_from(&Integer::from_str(\"-33554433\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_5() {\n    f32::exact_from(&Integer::from_str(\"33554434\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_6() {\n    f32::exact_from(&Integer::from_str(\"-33554434\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_7() {\n    f32::exact_from(&Integer::from_str(\"33554435\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_8() {\n    f32::exact_from(&Integer::from_str(\"-33554435\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_9() {\n    f32::exact_from(&Integer::from_str(\"340282346638528859811704183484516925439\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_10() {\n    f32::exact_from(&Integer::from_str(\"-340282346638528859811704183484516925439\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_11() {\n    f32::exact_from(&Integer::from_str(\"340282346638528859811704183484516925441\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_12() {\n    f32::exact_from(&Integer::from_str(\"-340282346638528859811704183484516925441\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_13() {\n    f32::exact_from(&Integer::from_str(\"340282346638528859811704183484516925441\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_14() {\n    f32::exact_from(&Integer::from_str(\"-340282346638528859811704183484516925441\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_15() {\n    f32::exact_from(\n        &Integer::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_integer_fail_16() {\n    f32::exact_from(\n        &Integer::from_str(\"-10000000000000000000000000000000000000000000000000000\").unwrap(),\n    );\n}\n\n#[test]\nfn test_f64_exact_from_integer() {\n    let test = |s: &str, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(NiceFloat(f64::exact_from(&u)), NiceFloat(out));\n    };\n    test(\"3\", 3.0);\n    test(\"-3\", -3.0);\n    test(\"123\", 123.0);\n    test(\"-123\", -123.0);\n    test(\"0\", 0.0);\n    test(\"1000000000\", 1.0e9);\n    test(\"-1000000000\", -1.0e9);\n    test(\"9007199254740992\", 9.007199254740992e15);\n    test(\"-9007199254740992\", -9.007199254740992e15);\n    test(\"9007199254740994\", 9.007199254740994e15);\n    test(\"-9007199254740994\", -9.007199254740994e15);\n    test(\"18014398509481984\", 1.8014398509481984e16);\n    test(\"-18014398509481984\", -1.8014398509481984e16);\n    test(\"18014398509481988\", 1.8014398509481988e16);\n    test(\"-18014398509481988\", -1.8014398509481988e16);\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        1.7976931348623157e308,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n        -1.7976931348623157e308,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_1() {\n    f64::exact_from(&Integer::from_str(\"18014398509481983\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_2() {\n    f64::exact_from(&Integer::from_str(\"-18014398509481983\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_3() {\n    f64::exact_from(&Integer::from_str(\"18014398509481985\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_4() {\n    f64::exact_from(&Integer::from_str(\"-18014398509481985\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_5() {\n    f64::exact_from(&Integer::from_str(\"18014398509481986\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_6() {\n    f64::exact_from(&Integer::from_str(\"-18014398509481986\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_7() {\n    f64::exact_from(&Integer::from_str(\"18014398509481987\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_8() {\n    f64::exact_from(&Integer::from_str(\"-18014398509481987\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_9() {\n    f64::exact_from(&Integer::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_10() {\n    f64::exact_from(&Integer::from_str(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_11() {\n    f64::exact_from(&Integer::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_integer_fail_12() {\n    f64::exact_from(&Integer::from_str(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\").unwrap());\n}\n\n#[test]\nfn test_f32_convertible_from_integer() {\n    let test = |s: &str, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(f32::convertible_from(&u), out);\n    };\n    test(\"3\", true);\n    test(\"-3\", true);\n    test(\"123\", true);\n    test(\"-123\", true);\n    test(\"0\", true);\n    test(\"1000000000\", true);\n    test(\"-1000000000\", true);\n    test(\"16777216\", true);\n    test(\"-16777216\", true);\n    test(\"16777218\", true);\n    test(\"-16777218\", true);\n    test(\"16777217\", false);\n    test(\"-16777217\", false);\n    test(\"33554432\", true);\n    test(\"-33554432\", true);\n    test(\"33554436\", true);\n    test(\"-33554436\", true);\n    test(\"33554433\", false);\n    test(\"-33554433\", false);\n    test(\"33554434\", false);\n    test(\"-33554434\", false);\n    test(\"33554435\", false);\n    test(\"-33554435\", false);\n    test(\"340282346638528859811704183484516925439\", false);\n    test(\"-340282346638528859811704183484516925439\", false);\n    test(\"340282346638528859811704183484516925440\", true);\n    test(\"-340282346638528859811704183484516925440\", true);\n    test(\"340282346638528859811704183484516925441\", false);\n    test(\"-340282346638528859811704183484516925441\", false);\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        false,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        false,\n    );\n}\n\n#[test]\nfn test_f64_convertible_from_integer() {\n    let test = |s: &str, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(f64::convertible_from(&u), out);\n    };\n    test(\"3\", true);\n    test(\"-3\", true);\n    test(\"123\", true);\n    test(\"-123\", true);\n    test(\"0\", true);\n    test(\"1000000000\", true);\n    test(\"-1000000000\", true);\n    test(\"9007199254740992\", true);\n    test(\"-9007199254740992\", true);\n    test(\"9007199254740994\", true);\n    test(\"-9007199254740994\", true);\n    test(\"9007199254740993\", false);\n    test(\"-9007199254740993\", false);\n    test(\"18014398509481984\", true);\n    test(\"-18014398509481984\", true);\n    test(\"18014398509481988\", true);\n    test(\"-18014398509481988\", true);\n    test(\"18014398509481985\", false);\n    test(\"-18014398509481985\", false);\n    test(\"18014398509481986\", false);\n    test(\"-18014398509481986\", false);\n    test(\"18014398509481987\", false);\n    test(\"-18014398509481987\", false);\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        false,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        false,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        true,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n        true,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        false,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        false,\n    );\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn float_rounding_from_integer_properties_helper<\n    T: for<'a> TryFrom<&'a Natural>\n        + for<'a> ConvertibleFrom<&'a Integer>\n        + for<'a> ConvertibleFrom<&'a Natural>\n        + PartialOrd<Integer>\n        + PrimitiveFloat\n        + for<'a> RoundingFrom<&'a Integer>,\n>()\nwhere\n    Integer: RoundingFrom<T>,\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    integer_rounding_mode_pair_gen_var_1::<T>().test_properties(|(n, rm)| {\n        let (f, o) = T::rounding_from(&n, rm);\n        let (f_alt, o_alt) = T::rounding_from(&-&n, -rm);\n        assert_eq!(NiceFloat(f_alt), NiceFloat((-f).abs_negative_zero()));\n        assert_eq!(o_alt, o.reverse());\n\n        assert_eq!(f.partial_cmp(&n), Some(o));\n        match (n >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    integer_gen_var_1::<T>().test_properties(|n| {\n        let (f, o) = T::rounding_from(&n, Exact);\n        assert_eq!(o, Equal);\n        let (f_alt, o) = T::rounding_from(&n, Floor);\n        assert_eq!(o, Equal);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        let (f_alt, o) = T::rounding_from(&n, Ceiling);\n        assert_eq!(o, Equal);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        let (f_alt, o) = T::rounding_from(&n, Down);\n        assert_eq!(o, Equal);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        let (f_alt, o) = T::rounding_from(&n, Up);\n        assert_eq!(o, Equal);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        let (f_alt, o) = T::rounding_from(&n, Nearest);\n        assert_eq!(o, Equal);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        let (n_alt, o) = Integer::rounding_from(f, Exact);\n        assert_eq!(o, Equal);\n        assert_eq!(n_alt, n);\n    });\n\n    integer_gen_var_2::<T>().test_properties(|n| {\n        let f_below = T::rounding_from(&n, Floor);\n        assert_eq!(f_below.1, Less);\n        let f_above = (f_below.0.next_higher(), Greater);\n        let f_below = (NiceFloat(f_below.0), f_below.1);\n        let f_above = (NiceFloat(f_above.0), f_above.1);\n        let (f, o) = T::rounding_from(&n, Ceiling);\n        assert_eq!(f_above, (NiceFloat(f), o));\n        if n >= 0 {\n            let (f_alt, o_alt) = T::rounding_from(&n, Down);\n            assert_eq!((NiceFloat(f_alt), o_alt), f_below);\n            let (f_alt, o_alt) = T::rounding_from(&n, Up);\n            assert_eq!((NiceFloat(f_alt), o_alt), f_above);\n        } else {\n            let (f_alt, o_alt) = T::rounding_from(&n, Down);\n            assert_eq!((NiceFloat(f_alt), o_alt), f_above);\n            let (f_alt, o_alt) = T::rounding_from(&n, Up);\n            assert_eq!((NiceFloat(f_alt), o_alt), f_below);\n        }\n        let f_nearest = T::rounding_from(&n, Nearest);\n        let f_nearest = (NiceFloat(f_nearest.0), f_nearest.1);\n        assert!(f_nearest == f_below || f_nearest == f_above);\n    });\n\n    integer_gen_var_3::<T>().test_properties(|n| {\n        let floor = T::rounding_from(&n, Floor);\n        let ceiling = (floor.0.next_higher(), Greater);\n        let nearest = T::rounding_from(&n, Nearest);\n        let floor = (NiceFloat(floor.0), floor.1);\n        let ceiling = (NiceFloat(ceiling.0), ceiling.1);\n        let nearest = (NiceFloat(nearest.0), nearest.1);\n        assert_eq!(\n            nearest,\n            if floor.0.0.to_bits().even() {\n                floor\n            } else {\n                ceiling\n            }\n        );\n    });\n\n    signed_rounding_mode_pair_gen_var_4::<SignedLimb, T>().test_properties(|(i, rm)| {\n        let n: Integer = From::from(i);\n        let (f, o) = T::rounding_from(i, rm);\n        let (f_alt, o_alt) = T::rounding_from(&n, rm);\n        assert_eq!(NiceFloat(f), NiceFloat(f_alt));\n        assert_eq!(o, o_alt);\n        assert_eq!(f.partial_cmp(&n), Some(o));\n    });\n}\n\n#[test]\nfn float_rounding_from_integer_properties() {\n    apply_fn_to_primitive_floats!(float_rounding_from_integer_properties_helper);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn float_try_from_integer_properties_helper<\n    T: for<'a> TryFrom<&'a Integer, Error = PrimitiveFloatFromIntegerError>\n        + for<'a> TryFrom<&'a Natural>\n        + for<'a> ConvertibleFrom<&'a Natural>\n        + PrimitiveFloat\n        + for<'a> RoundingFrom<&'a Integer>,\n>()\nwhere\n    Integer: RoundingFrom<T>,\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n    SignedLimb: RoundingFrom<T>,\n    NiceFloat<T>: TryFrom<SignedLimb>,\n{\n    integer_gen().test_properties(|n| {\n        let of = T::try_from(&n);\n        assert_eq!(\n            T::try_from(&-n).map(NiceFloat),\n            of.map(|f| NiceFloat((-f).abs_negative_zero()))\n        );\n    });\n\n    integer_gen_var_1::<T>().test_properties(|n| {\n        let f = T::exact_from(&n);\n        assert_eq!(NiceFloat(f), NiceFloat(T::rounding_from(&n, Exact).0));\n        assert_eq!(Integer::rounding_from(f, Exact).0, n);\n    });\n\n    integer_gen_var_2::<T>().test_properties(|n| {\n        assert!(T::try_from(&n).is_err());\n    });\n\n    integer_gen_var_3::<T>().test_properties(|n| {\n        assert!(T::try_from(&n).is_err());\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        if let Ok(f) = NiceFloat::<T>::try_from(i) {\n            assert_eq!(f, NiceFloat(T::exact_from(&Integer::from(i))));\n        }\n    });\n\n    signed_gen_var_7::<SignedLimb, T>().test_properties(|i| {\n        assert_eq!(\n            NiceFloat::<T>::exact_from(i),\n            NiceFloat(T::exact_from(&Integer::from(i)))\n        );\n    });\n}\n\n#[test]\nfn float_try_from_integer_properties() {\n    apply_fn_to_primitive_floats!(float_try_from_integer_properties_helper);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn float_convertible_from_integer_properties_helper<\n    T: for<'a> TryFrom<&'a Natural>\n        + for<'a> ConvertibleFrom<&'a Integer>\n        + for<'a> ConvertibleFrom<&'a Natural>\n        + PrimitiveFloat,\n>()\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    integer_gen().test_properties(|n| {\n        assert_eq!(T::convertible_from(&n), T::convertible_from(&-n));\n    });\n\n    integer_gen_var_1::<T>().test_properties(|n| {\n        assert!(T::convertible_from(&n));\n    });\n\n    integer_gen_var_2::<T>().test_properties(|n| {\n        assert!(!T::convertible_from(&n));\n    });\n\n    integer_gen_var_3::<T>().test_properties(|n| {\n        assert!(!T::convertible_from(&n));\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        let n: Integer = From::from(i);\n        assert_eq!(T::convertible_from(i), T::convertible_from(&n));\n    });\n}\n\n#[test]\nfn float_convertible_from_integer_properties() {\n    apply_fn_to_primitive_floats!(float_convertible_from_integer_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/primitive_int_from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, OverflowingFrom, SaturatingFrom, WrappingFrom,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::conversion::primitive_int_from_integer::SignedFromIntegerError;\nuse malachite_nz::integer::conversion::primitive_int_from_integer::UnsignedFromIntegerError;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::integer_gen;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_u32_try_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u32::try_from(&u), out);\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .to_u32()\n                .ok_or(UnsignedFromIntegerError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000\", Err(UnsignedFromIntegerError));\n    test(\"4294967295\", Ok(u32::MAX));\n    test(\"4294967296\", Err(UnsignedFromIntegerError));\n    test(\"-123\", Err(UnsignedFromIntegerError));\n    test(\"-1000000000000\", Err(UnsignedFromIntegerError));\n    test(\"-4294967295\", Err(UnsignedFromIntegerError));\n    test(\"-4294967296\", Err(UnsignedFromIntegerError));\n}\n\n#[test]\nfn test_u32_exact_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u32::exact_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_u32().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"4294967295\", u32::MAX);\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_integer_fail_1() {\n    u32::exact_from(&Integer::from_str(\"1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_integer_fail_2() {\n    u32::exact_from(&Integer::from_str(\"4294967296\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_integer_fail_3() {\n    u32::exact_from(&Integer::from_str(\"-123\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_integer_fail_4() {\n    u32::exact_from(&Integer::from_str(\"-1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_integer_fail_5() {\n    u32::exact_from(&Integer::from_str(\"-4294967295\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_integer_fail_6() {\n    u32::exact_from(&Integer::from_str(\"-4294967296\").unwrap());\n}\n\n#[test]\nfn test_u32_wrapping_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u32::wrapping_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_u32_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", 3567587328);\n    test(\"4294967296\", 0);\n    test(\"4294967297\", 1);\n    test(\"-123\", 4294967173);\n    test(\"-1000000000000\", 727379968);\n    test(\"-4294967296\", 0);\n    test(\"-4294967297\", u32::MAX);\n}\n\n#[test]\nfn test_u32_saturating_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u32::saturating_from(&u), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", u32::MAX);\n    test(\"4294967296\", u32::MAX);\n    test(\"4294967297\", u32::MAX);\n    test(\"-123\", 0);\n    test(\"-1000000000000\", 0);\n    test(\"-4294967296\", 0);\n    test(\"-4294967297\", 0);\n}\n\n#[test]\nfn test_u32_overflowing_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u32::overflowing_from(&u), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000\", (3567587328, true));\n    test(\"4294967296\", (0, true));\n    test(\"4294967297\", (1, true));\n    test(\"-123\", (4294967173, true));\n    test(\"-1000000000000\", (727379968, true));\n    test(\"-4294967296\", (0, true));\n    test(\"-4294967297\", (u32::MAX, true));\n}\n\n#[test]\nfn test_u32_convertible_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u32::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000\", false);\n    test(\"4294967295\", true);\n    test(\"4294967296\", false);\n    test(\"-123\", false);\n    test(\"-1000000000000\", false);\n    test(\"-4294967295\", false);\n    test(\"-4294967296\", false);\n}\n\n#[test]\nfn test_u64_try_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u64::try_from(&u), out);\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .to_u64()\n                .ok_or(UnsignedFromIntegerError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000\", Ok(1000000000000));\n    test(\"18446744073709551615\", Ok(u64::MAX));\n    test(\"18446744073709551616\", Err(UnsignedFromIntegerError));\n    test(\"-123\", Err(UnsignedFromIntegerError));\n    test(\"-1000000000000\", Err(UnsignedFromIntegerError));\n    test(\"-18446744073709551615\", Err(UnsignedFromIntegerError));\n    test(\"-18446744073709551616\", Err(UnsignedFromIntegerError));\n}\n\n#[test]\nfn test_u64_exact_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u64::exact_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_u64().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", 1000000000000);\n    test(\"18446744073709551615\", u64::MAX);\n}\n\n#[test]\n#[should_panic]\nfn u64_exact_from_integer_fail_1() {\n    u64::exact_from(&Integer::from_str(\"18446744073709551616\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u64_exact_from_integer_fail_2() {\n    u64::exact_from(&Integer::from_str(\"-123\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u64_exact_from_integer_fail_3() {\n    u64::exact_from(&Integer::from_str(\"-1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u64_exact_from_integer_fail_4() {\n    u64::exact_from(&Integer::from_str(\"-18446744073709551615\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u64_exact_from_integer_fail_5() {\n    u64::exact_from(&Integer::from_str(\"-18446744073709551616\").unwrap());\n}\n\n#[test]\nfn test_u64_wrapping_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u64::wrapping_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_u64_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", 2003764205206896640);\n    test(\"18446744073709551616\", 0);\n    test(\"18446744073709551617\", 1);\n    test(\"-123\", 18446744073709551493);\n    test(\"-1000000000000000000000000\", 16442979868502654976);\n    test(\"-18446744073709551616\", 0);\n    test(\"-18446744073709551617\", u64::MAX);\n}\n\n#[test]\nfn test_u64_saturating_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u64::saturating_from(&u), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", u64::MAX);\n    test(\"18446744073709551616\", u64::MAX);\n    test(\"18446744073709551617\", u64::MAX);\n    test(\"-123\", 0);\n    test(\"-1000000000000000000000000\", 0);\n    test(\"-18446744073709551616\", 0);\n    test(\"-18446744073709551617\", 0);\n}\n\n#[test]\nfn test_u64_overflowing_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u64::overflowing_from(&u), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000000000000000\", (2003764205206896640, true));\n    test(\"18446744073709551616\", (0, true));\n    test(\"18446744073709551617\", (1, true));\n    test(\"-123\", (18446744073709551493, true));\n    test(\"-1000000000000000000000000\", (16442979868502654976, true));\n    test(\"-18446744073709551616\", (0, true));\n    test(\"-18446744073709551617\", (u64::MAX, true));\n}\n\n#[test]\nfn test_u64_convertible_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(u64::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000000000000000\", false);\n    test(\"18446744073709551615\", true);\n    test(\"18446744073709551616\", false);\n    test(\"-123\", false);\n    test(\"-1000000000000000000000000\", false);\n    test(\"-18446744073709551615\", false);\n    test(\"-18446744073709551616\", false);\n}\n\n#[test]\nfn test_i32_try_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i32::try_from(&u), out);\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .to_i32()\n                .ok_or(SignedFromIntegerError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000\", Err(SignedFromIntegerError));\n    test(\"2147483647\", Ok(i32::MAX));\n    test(\"2147483648\", Err(SignedFromIntegerError));\n    test(\"-123\", Ok(-123));\n    test(\"-1000000000000\", Err(SignedFromIntegerError));\n    test(\"-2147483648\", Ok(i32::MIN));\n    test(\"-2147483649\", Err(SignedFromIntegerError));\n}\n\n#[test]\nfn test_i32_exact_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i32::exact_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_i32().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"2147483647\", i32::MAX);\n    test(\"-123\", -123);\n    test(\"-2147483648\", i32::MIN);\n}\n\n#[test]\n#[should_panic]\nfn i32_exact_from_integer_fail_1() {\n    i32::exact_from(&Integer::from_str(\"1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i32_exact_from_integer_fail_2() {\n    i32::exact_from(&Integer::from_str(\"2147483648\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i32_exact_from_integer_fail_3() {\n    i32::exact_from(&Integer::from_str(\"-1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i32_exact_from_integer_fail_4() {\n    i32::exact_from(&Integer::from_str(\"-2147483649\").unwrap());\n}\n\n#[test]\nfn test_i32_wrapping_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i32::wrapping_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_i32_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", -727379968);\n    test(\"2147483648\", -0x80000000);\n    test(\"2147483649\", -0x7fffffff);\n    test(\"-123\", -123);\n    test(\"-1000000000000\", 727379968);\n    test(\"-2147483649\", 0x7fffffff);\n    test(\"-2147483650\", 0x7ffffffe);\n}\n\n#[test]\nfn test_i32_saturating_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i32::saturating_from(&u), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", 0x7fffffff);\n    test(\"2147483648\", 0x7fffffff);\n    test(\"2147483649\", 0x7fffffff);\n    test(\"-123\", -123);\n    test(\"-1000000000000\", -0x80000000);\n    test(\"-2147483648\", -0x80000000);\n    test(\"-2147483649\", -0x80000000);\n}\n\n#[test]\nfn test_i32_overflowing_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i32::overflowing_from(&u), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000\", (-727379968, true));\n    test(\"2147483648\", (-0x80000000, true));\n    test(\"2147483649\", (-0x7fffffff, true));\n    test(\"-123\", (-123, false));\n    test(\"-1000000000000\", (727379968, true));\n    test(\"-2147483649\", (0x7fffffff, true));\n    test(\"-2147483650\", (0x7ffffffe, true));\n}\n\n#[test]\nfn test_i32_convertible_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i32::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000\", false);\n    test(\"2147483647\", true);\n    test(\"2147483648\", false);\n    test(\"-123\", true);\n    test(\"-1000000000000\", false);\n    test(\"-2147483648\", true);\n    test(\"-2147483649\", false);\n}\n\n#[test]\nfn test_i64_try_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i64::try_from(&u), out);\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .to_i64()\n                .ok_or(SignedFromIntegerError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000000000000000\", Err(SignedFromIntegerError));\n    test(\"9223372036854775807\", Ok(i64::MAX));\n    test(\"9223372036854775808\", Err(SignedFromIntegerError));\n    test(\"-123\", Ok(-123));\n    test(\"-1000000000000000000000000\", Err(SignedFromIntegerError));\n    test(\"-9223372036854775808\", Ok(i64::MIN));\n    test(\"-9223372036854775809\", Err(SignedFromIntegerError));\n}\n\n#[test]\nfn test_i64_exact_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i64::exact_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_i64().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"9223372036854775807\", i64::MAX);\n    test(\"-123\", -123);\n    test(\"-9223372036854775808\", i64::MIN);\n}\n\n#[test]\n#[should_panic]\nfn i64_exact_from_integer_fail_1() {\n    i64::exact_from(&Integer::from_str(\"1000000000000000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i64_exact_from_integer_fail_2() {\n    i64::exact_from(&Integer::from_str(\"9223372036854775808\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i64_exact_from_integer_fail_3() {\n    i64::exact_from(&Integer::from_str(\"-1000000000000000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i64_exact_from_integer_fail_4() {\n    i64::exact_from(&Integer::from_str(\"-9223372036854775809\").unwrap());\n}\n\n#[test]\nfn test_i64_wrapping_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i64::wrapping_from(&u), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_i64_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", 2003764205206896640);\n    test(\"9223372036854775808\", -0x8000000000000000);\n    test(\"9223372036854775809\", -0x7fffffffffffffff);\n    test(\"-123\", -123);\n    test(\"-1000000000000000000000000\", -2003764205206896640);\n    test(\"-9223372036854775809\", 0x7fffffffffffffff);\n    test(\"-9223372036854775810\", 0x7ffffffffffffffe);\n}\n\n#[test]\nfn test_i64_saturating_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i64::saturating_from(&u), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", 0x7fffffffffffffff);\n    test(\"9223372036854775808\", 0x7fffffffffffffff);\n    test(\"9223372036854775809\", 0x7fffffffffffffff);\n    test(\"-123\", -123);\n    test(\"-1000000000000000000000000\", -0x8000000000000000);\n    test(\"-9223372036854775808\", -0x8000000000000000);\n    test(\"-9223372036854775809\", -0x8000000000000000);\n}\n\n#[test]\nfn test_i64_overflowing_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i64::overflowing_from(&u), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000000000000000\", (2003764205206896640, true));\n    test(\"9223372036854775808\", (-0x8000000000000000, true));\n    test(\"9223372036854775809\", (-0x7fffffffffffffff, true));\n    test(\"-123\", (-123, false));\n    test(\"-1000000000000000000000000\", (-2003764205206896640, true));\n    test(\"-9223372036854775809\", (0x7fffffffffffffff, true));\n    test(\"-9223372036854775810\", (0x7ffffffffffffffe, true));\n}\n\n#[test]\nfn test_i64_convertible_from_integer() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n        assert_eq!(i64::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000000000000000\", false);\n    test(\"9223372036854775807\", true);\n    test(\"9223372036854775808\", false);\n    test(\"-123\", true);\n    test(\"-1000000000000000000000000\", false);\n    test(\"-9223372036854775808\", true);\n    test(\"-9223372036854775809\", false);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn unsigned_from_integer_properties_helper<\n    T: for<'a> TryFrom<&'a Integer, Error = UnsignedFromIntegerError>\n        + for<'a> TryFrom<&'a Natural>\n        + for<'a> OverflowingFrom<&'a Integer>\n        + PrimitiveUnsigned\n        + for<'a> WrappingFrom<&'a Integer>,\n>()\nwhere\n    Integer: From<T>,\n{\n    integer_gen().test_properties(|x| {\n        let result = T::try_from(&x);\n        if x >= 0 && x.significant_bits() <= T::WIDTH {\n            assert_eq!(Integer::from(result.unwrap()), x);\n            assert_eq!(result, Ok(T::wrapping_from(&x)));\n            assert_eq!(result, Ok(T::exact_from(&x)));\n        } else {\n            assert!(result.is_err());\n        }\n        assert_eq!(result.is_err(), T::overflowing_from(&x).1);\n\n        let result = T::wrapping_from(&x);\n        assert_eq!(result, T::exact_from(&(&x).mod_power_of_2(T::WIDTH)));\n    });\n}\n\nfn signed_from_integer_properties_helper<\n    T: for<'a> TryFrom<&'a Integer, Error = SignedFromIntegerError>\n        + for<'a> OverflowingFrom<&'a Integer>\n        + PrimitiveSigned\n        + for<'a> WrappingFrom<&'a Integer>,\n>()\nwhere\n    Integer: From<T>,\n{\n    let min = -Integer::power_of_2(T::WIDTH - 1);\n    integer_gen().test_properties(|x| {\n        let result = T::try_from(&x);\n        if x.significant_bits() < T::WIDTH || x == min {\n            assert_eq!(Integer::from(result.unwrap()), x);\n            assert_eq!(result, Ok(T::wrapping_from(&x)));\n            assert_eq!(result, Ok(T::exact_from(&x)));\n        } else {\n            assert!(result.is_err());\n        }\n        assert_eq!(result.is_err(), T::overflowing_from(&x).1);\n    });\n}\n\nfn primitive_int_from_integer_properties_helper<\n    T: for<'a> ConvertibleFrom<&'a Integer>\n        + for<'a> OverflowingFrom<&'a Integer>\n        + PrimitiveInt\n        + for<'a> SaturatingFrom<&'a Integer>\n        + PartialEq<Integer>\n        + PartialOrdAbs<Integer>\n        + for<'a> WrappingFrom<&'a Integer>,\n>()\nwhere\n    Integer: PartialOrd<T>,\n{\n    integer_gen().test_properties(|x| {\n        let result = T::wrapping_from(&x);\n        assert_eq!(result, T::overflowing_from(&x).0);\n\n        let result = T::saturating_from(&x);\n        assert!(result.le_abs(&x));\n        assert_eq!(result == x, T::convertible_from(&x));\n\n        let result = T::overflowing_from(&x);\n        assert_eq!(result, (T::wrapping_from(&x), !T::convertible_from(&x)));\n\n        let convertible = T::convertible_from(&x);\n        assert_eq!(convertible, x >= T::MIN && x <= T::MAX);\n    });\n}\n\n#[test]\nfn primitive_int_from_integer_properties() {\n    apply_fn_to_primitive_ints!(primitive_int_from_integer_properties_helper);\n    apply_fn_to_unsigneds!(unsigned_from_integer_properties_helper);\n    apply_fn_to_signeds!(signed_from_integer_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_9};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_serde() {\n    let test = |n, out| {\n        assert_eq!(\n            serde_json::to_string(&Integer::from_str(n).unwrap()).unwrap(),\n            out\n        );\n        assert_eq!(serde_json::from_str::<Integer>(out).unwrap().to_string(), n);\n    };\n    test(\"0\", \"\\\"0x0\\\"\");\n    test(\"100\", \"\\\"0x64\\\"\");\n    test(\"1000000000000\", \"\\\"0xe8d4a51000\\\"\");\n    test(\"4294967295\", \"\\\"0xffffffff\\\"\");\n    test(\"4294967296\", \"\\\"0x100000000\\\"\");\n    test(\"18446744073709551615\", \"\\\"0xffffffffffffffff\\\"\");\n    test(\"18446744073709551616\", \"\\\"0x10000000000000000\\\"\");\n    test(\"1000000000000000000000000\", \"\\\"0xd3c21bcecceda1000000\\\"\");\n    test(\n        \"340282366920938463463374607431768211455\",\n        \"\\\"0xffffffffffffffffffffffffffffffff\\\"\",\n    );\n    test(\n        \"340282366920938463463374607431768211456\",\n        \"\\\"0x100000000000000000000000000000000\\\"\",\n    );\n    test(\"-100\", \"\\\"-0x64\\\"\");\n    test(\"-1000000000000\", \"\\\"-0xe8d4a51000\\\"\");\n    test(\"-4294967295\", \"\\\"-0xffffffff\\\"\");\n    test(\"-4294967296\", \"\\\"-0x100000000\\\"\");\n    test(\"-18446744073709551615\", \"\\\"-0xffffffffffffffff\\\"\");\n    test(\"-18446744073709551616\", \"\\\"-0x10000000000000000\\\"\");\n    test(\"-1000000000000000000000000\", \"\\\"-0xd3c21bcecceda1000000\\\"\");\n    test(\n        \"-340282366920938463463374607431768211455\",\n        \"\\\"-0xffffffffffffffffffffffffffffffff\\\"\",\n    );\n    test(\n        \"-340282366920938463463374607431768211456\",\n        \"\\\"-0x100000000000000000000000000000000\\\"\",\n    );\n}\n\n#[test]\nfn serde_properties() {\n    integer_gen().test_properties(|x| {\n        let s = serde_json::to_string(&x).unwrap();\n        assert_eq!(serde_json::from_str::<Integer>(&s).unwrap(), x);\n        assert!(string_is_subset(&s, \"\\\"-0123456789abcdefx\"));\n    });\n\n    string_gen().test_properties(|s| {\n        let _n: Result<Integer, _> = serde_json::from_str(&s);\n    });\n\n    string_gen_var_9().test_properties(|s| {\n        let _n: Integer = serde_json::from_str(&s).unwrap();\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::num::conversion::traits::{FromSciString, ToStringBase};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    string_from_sci_string_options_pair_gen_var_2, string_from_sci_string_options_pair_gen_var_3,\n    string_gen_var_14, string_gen_var_15,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse std::str::FromStr;\n\n#[test]\npub fn test_from_sci_string() {\n    fn test(s: &str, out: Option<&'static str>) {\n        let out = out.map(|s| Integer::from_str(s).unwrap());\n        assert_eq!(Integer::from_sci_string(s), out);\n        assert_eq!(\n            Integer::from_sci_string_with_options(s, FromSciStringOptions::default()),\n            out\n        );\n    }\n    test(\"0\", Some(\"0\"));\n    test(\"00\", Some(\"0\"));\n    test(\"+0\", Some(\"0\"));\n    test(\"-0\", Some(\"0\"));\n    test(\"0.00\", Some(\"0\"));\n    test(\"0e1\", Some(\"0\"));\n    test(\"0e+1\", Some(\"0\"));\n    test(\"0e-1\", Some(\"0\"));\n    test(\"+0e+1\", Some(\"0\"));\n    test(\"-0e+1\", Some(\"0\"));\n    test(\"+0.0e+1\", Some(\"0\"));\n    test(\"-0.0e+1\", Some(\"0\"));\n    test(\".0\", Some(\"0\"));\n    test(\".00\", Some(\"0\"));\n    test(\".00e0\", Some(\"0\"));\n    test(\".00e1\", Some(\"0\"));\n    test(\".00e-1\", Some(\"0\"));\n    test(\"-.0\", Some(\"0\"));\n    test(\"-.00\", Some(\"0\"));\n    test(\"-.00e0\", Some(\"0\"));\n    test(\"-.00e1\", Some(\"0\"));\n    test(\"-.00e-1\", Some(\"0\"));\n    test(\"+.0\", Some(\"0\"));\n    test(\"+.00\", Some(\"0\"));\n    test(\"+.00e0\", Some(\"0\"));\n    test(\"+.00e1\", Some(\"0\"));\n    test(\"+.00e-1\", Some(\"0\"));\n\n    test(\"123\", Some(\"123\"));\n    test(\"00123\", Some(\"123\"));\n    test(\"+123\", Some(\"123\"));\n    test(\"123.00\", Some(\"123\"));\n    test(\"123e0\", Some(\"123\"));\n    test(\"12.3e1\", Some(\"123\"));\n    test(\"1.23e2\", Some(\"123\"));\n    test(\"1.23E2\", Some(\"123\"));\n    test(\"1.23e+2\", Some(\"123\"));\n    test(\"1.23E+2\", Some(\"123\"));\n    test(\".123e3\", Some(\"123\"));\n    test(\"0.123e3\", Some(\"123\"));\n    test(\"+0.123e3\", Some(\"123\"));\n    test(\"0.0123e4\", Some(\"123\"));\n    test(\"1230e-1\", Some(\"123\"));\n    test(\"12300e-2\", Some(\"123\"));\n    test(\"12300E-2\", Some(\"123\"));\n\n    test(\"-123\", Some(\"-123\"));\n    test(\"-00123\", Some(\"-123\"));\n    test(\"-123.00\", Some(\"-123\"));\n    test(\"-123e0\", Some(\"-123\"));\n    test(\"-12.3e1\", Some(\"-123\"));\n    test(\"-1.23e2\", Some(\"-123\"));\n    test(\"-1.23E2\", Some(\"-123\"));\n    test(\"-1.23e+2\", Some(\"-123\"));\n    test(\"-1.23E+2\", Some(\"-123\"));\n    test(\"-.123e3\", Some(\"-123\"));\n    test(\"-0.123e3\", Some(\"-123\"));\n    test(\"-0.0123e4\", Some(\"-123\"));\n    test(\"-1230e-1\", Some(\"-123\"));\n    test(\"-12300e-2\", Some(\"-123\"));\n    test(\"-12300E-2\", Some(\"-123\"));\n\n    test(\"123.4\", Some(\"123\"));\n    test(\"123.8\", Some(\"124\"));\n    test(\"123.5\", Some(\"124\"));\n    test(\"124.5\", Some(\"124\"));\n    test(\"127.49\", Some(\"127\"));\n\n    test(\"-123.4\", Some(\"-123\"));\n    test(\"-123.8\", Some(\"-124\"));\n    test(\"-123.5\", Some(\"-124\"));\n    test(\"-124.5\", Some(\"-124\"));\n    test(\"-127.49\", Some(\"-127\"));\n    test(\"-127.5\", Some(\"-128\"));\n\n    test(\"\", None);\n    test(\"+\", None);\n    test(\"-\", None);\n    test(\"10e\", None);\n    test(\"++1\", None);\n    test(\"1.0.0\", None);\n    test(\"1e++1\", None);\n    test(\"1e0.1\", None);\n    test(\"--.0\", None);\n    test(\"++.0\", None);\n    test(\".+2\", None);\n    test(\".-2\", None);\n    test(\"0.000a\", None);\n    test(\"0.00ae-10\", None);\n    test(\"0e10000000000000000000000000000\", None);\n    test(\"0e-10000000000000000000000000000\", None);\n}\n\n#[test]\npub fn test_from_sci_string_with_options() {\n    fn test(s: &str, options: FromSciStringOptions, out: Option<&str>) {\n        let out = out.map(|s| Integer::from_str(s).unwrap());\n        assert_eq!(Integer::from_sci_string_with_options(s, options), out);\n    }\n    fn test_i<T: PrimitiveInt>(s: &str, options: FromSciStringOptions, out: Option<T>)\n    where\n        Integer: From<T>,\n    {\n        let out = out.map(Integer::from);\n        assert_eq!(Integer::from_sci_string_with_options(s, options), out);\n    }\n    // For tests with the default options, see `test_from_sci_string`\n\n    let mut options = FromSciStringOptions::default();\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(3);\n    test_i(\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(4);\n    test_i(\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(5);\n    test_i(\n        \"11031110441201303134210404233413032443021130230130231310\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(8);\n    test_i(\n        \"3777777777777777777777777777777777777777777\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(16);\n    test_i(\"ffffffffffffffffffffffffffffffff\", options, Some(u128::MAX));\n    options.set_base(32);\n    test_i(\"7vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(u128::MAX));\n    options.set_base(36);\n    test_i(\"f5lxx1zz5pnorynqglhzmsp33\", options, Some(u128::MAX));\n\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(3);\n    test_i(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(4);\n    test_i(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(5);\n    test_i(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-3013030220323124042102424341431241221233040112312340403\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(8);\n    test_i(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(16);\n    test_i(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    test_i(\n        \"-80000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(32);\n    test_i(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    test_i(\"-40000000000000000000000000\", options, Some(i128::MIN));\n    options.set_base(36);\n    test_i(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n    test_i(\"-7ksyyizzkutudzbv8aqztecjk\", options, Some(i128::MIN));\n\n    options.set_base(2);\n    test(\"1e+5\", options, Some(\"32\"));\n    test(\"1e5\", options, Some(\"32\"));\n    options.set_base(3);\n    test(\"1e+5\", options, Some(\"243\"));\n    test(\"1e5\", options, Some(\"243\"));\n    options.set_base(4);\n    test(\"1e+5\", options, Some(\"1024\"));\n    test(\"1e5\", options, Some(\"1024\"));\n    options.set_base(5);\n    test(\"1e+5\", options, Some(\"3125\"));\n    test(\"1e5\", options, Some(\"3125\"));\n    options.set_base(8);\n    test(\"1e+5\", options, Some(\"32768\"));\n    test(\"1e5\", options, Some(\"32768\"));\n    options.set_base(16);\n    test(\"1e+5\", options, Some(\"1048576\"));\n    test(\"1e5\", options, Some(\"485\"));\n    options.set_base(32);\n    test(\"1e+5\", options, Some(\"33554432\"));\n    test(\"1e5\", options, Some(\"1477\"));\n    options.set_base(36);\n    test(\"1e+5\", options, Some(\"60466176\"));\n    test(\"1E+5\", options, Some(\"60466176\"));\n    test(\"1e5\", options, Some(\"1805\"));\n\n    options.set_base(16);\n    test(\"ff\", options, Some(\"255\"));\n    test(\"fF\", options, Some(\"255\"));\n    test(\"Ff\", options, Some(\"255\"));\n    test(\"FF\", options, Some(\"255\"));\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Down);\n    test(\"123.4\", options, Some(\"123\"));\n    options.set_rounding_mode(Floor);\n    test(\"123.4\", options, Some(\"123\"));\n    options.set_rounding_mode(Up);\n    test(\"123.4\", options, Some(\"124\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"123.4\", options, Some(\"124\"));\n    options.set_rounding_mode(Nearest);\n    test(\"123.4\", options, Some(\"123\"));\n    options.set_rounding_mode(Exact);\n    test(\"123.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"123.5\", options, Some(\"123\"));\n    options.set_rounding_mode(Floor);\n    test(\"123.5\", options, Some(\"123\"));\n    options.set_rounding_mode(Up);\n    test(\"123.5\", options, Some(\"124\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"123.5\", options, Some(\"124\"));\n    options.set_rounding_mode(Nearest);\n    test(\"123.5\", options, Some(\"124\"));\n    options.set_rounding_mode(Exact);\n    test(\"123.5\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Up);\n    test(\"0.4\", options, Some(\"1\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"0.4\", options, Some(\"1\"));\n    options.set_rounding_mode(Nearest);\n    test(\"0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"0.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Up);\n    test(\"0.04\", options, Some(\"1\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"0.04\", options, Some(\"1\"));\n    options.set_rounding_mode(Nearest);\n    test(\"0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"0.04\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test(\"1.01\", options, Some(\"1\"));\n    test(\"1.1\", options, Some(\"2\"));\n    test(\"1.11\", options, Some(\"2\"));\n    test(\"0.01\", options, Some(\"0\"));\n    test(\"0.1\", options, Some(\"0\"));\n    test(\"0.11\", options, Some(\"1\"));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test(\"1.1\", options, Some(\"1\"));\n    test(\"1.11\", options, Some(\"1\"));\n    test(\"1.111\", options, Some(\"1\"));\n    test(\"1.112\", options, Some(\"2\"));\n    test(\"0.1\", options, Some(\"0\"));\n    test(\"0.11\", options, Some(\"0\"));\n    test(\"0.111\", options, Some(\"0\"));\n    test(\"0.112\", options, Some(\"1\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test(\"2\", options, None);\n    test(\"102\", options, None);\n    test(\"12e4\", options, None);\n    test(\"12e-4\", options, None);\n    test(\"1.2\", options, None);\n    test(\"0.2\", options, None);\n    test(\"0.002\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Exact);\n    test(\"1.5\", options, None);\n    test(\"1.9999999999999999999999999999\", options, None);\n\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(3);\n    test_i(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(4);\n    test_i(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(5);\n    test_i(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-3013030220323124042102424341431241221233040112312340403\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(8);\n    test_i(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(16);\n    test_i(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    test_i(\n        \"-80000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(32);\n    test_i(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    test_i(\"-40000000000000000000000000\", options, Some(i128::MIN));\n    options.set_base(36);\n    test_i(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n    test_i(\"-7ksyyizzkutudzbv8aqztecjk\", options, Some(i128::MIN));\n\n    options.set_base(2);\n    test(\"-1e+5\", options, Some(\"-32\"));\n    test(\"-1e5\", options, Some(\"-32\"));\n    options.set_base(3);\n    test(\"-1e+5\", options, Some(\"-243\"));\n    test(\"-1e5\", options, Some(\"-243\"));\n    options.set_base(4);\n    test(\"-1e+5\", options, Some(\"-1024\"));\n    test(\"-1e5\", options, Some(\"-1024\"));\n    options.set_base(5);\n    test(\"-1e+5\", options, Some(\"-3125\"));\n    test(\"-1e5\", options, Some(\"-3125\"));\n    options.set_base(8);\n    test(\"-1e+5\", options, Some(\"-32768\"));\n    test(\"-1e5\", options, Some(\"-32768\"));\n    options.set_base(16);\n    test(\"-1e+5\", options, Some(\"-1048576\"));\n    test(\"-1e5\", options, Some(\"-485\"));\n    options.set_base(32);\n    test(\"-1e+5\", options, Some(\"-33554432\"));\n    test(\"-1e5\", options, Some(\"-1477\"));\n    options.set_base(36);\n    test(\"-1e+5\", options, Some(\"-60466176\"));\n    test(\"-1E+5\", options, Some(\"-60466176\"));\n    test(\"-1e5\", options, Some(\"-1805\"));\n\n    options.set_base(16);\n    test(\"-ff\", options, Some(\"-255\"));\n    test(\"-fF\", options, Some(\"-255\"));\n    test(\"-Ff\", options, Some(\"-255\"));\n    test(\"-FF\", options, Some(\"-255\"));\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Down);\n    test(\"-123.4\", options, Some(\"-123\"));\n    options.set_rounding_mode(Floor);\n    test(\"-123.4\", options, Some(\"-124\"));\n    options.set_rounding_mode(Up);\n    test(\"-123.4\", options, Some(\"-124\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"-123.4\", options, Some(\"-123\"));\n    options.set_rounding_mode(Nearest);\n    test(\"-123.4\", options, Some(\"-123\"));\n    options.set_rounding_mode(Exact);\n    test(\"-123.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"-123.5\", options, Some(\"-123\"));\n    options.set_rounding_mode(Floor);\n    test(\"-123.5\", options, Some(\"-124\"));\n    options.set_rounding_mode(Up);\n    test(\"-123.5\", options, Some(\"-124\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"-123.5\", options, Some(\"-123\"));\n    options.set_rounding_mode(Nearest);\n    test(\"-123.5\", options, Some(\"-124\"));\n    options.set_rounding_mode(Exact);\n    test(\"-123.5\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"-0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"-0.4\", options, Some(\"-1\"));\n    options.set_rounding_mode(Up);\n    test(\"-0.4\", options, Some(\"-1\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"-0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Nearest);\n    test(\"-0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"-0.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"-0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"-0.04\", options, Some(\"-1\"));\n    options.set_rounding_mode(Up);\n    test(\"-0.04\", options, Some(\"-1\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"-0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Nearest);\n    test(\"-0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"-0.04\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test(\"-1.01\", options, Some(\"-1\"));\n    test(\"-1.1\", options, Some(\"-2\"));\n    test(\"-1.11\", options, Some(\"-2\"));\n    test(\"-0.01\", options, Some(\"0\"));\n    test(\"-0.1\", options, Some(\"0\"));\n    test(\"-0.11\", options, Some(\"-1\"));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test(\"-1.1\", options, Some(\"-1\"));\n    test(\"-1.11\", options, Some(\"-1\"));\n    test(\"-1.111\", options, Some(\"-1\"));\n    test(\"-1.112\", options, Some(\"-2\"));\n    test(\"-0.1\", options, Some(\"0\"));\n    test(\"-0.11\", options, Some(\"0\"));\n    test(\"-0.111\", options, Some(\"0\"));\n    test(\"-0.112\", options, Some(\"-1\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test(\"-2\", options, None);\n    test(\"-102\", options, None);\n    test(\"-12e4\", options, None);\n    test(\"-12e-4\", options, None);\n    test(\"-1.2\", options, None);\n    test(\"-0.2\", options, None);\n    test(\"-0.002\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Exact);\n    test(\"-1.5\", options, None);\n    test(\"-1.9999999999999999999999999999\", options, None);\n}\n\nfn from_sci_string_helper(s: &str) {\n    if let Some(x) = Integer::from_sci_string(s) {\n        for c in ['.', 'e', 'E', '+'] {\n            if s.contains(c) {\n                return;\n            }\n        }\n        if s.starts_with('0') || s.starts_with(\"-0\") {\n            return;\n        }\n        assert_eq!(x.to_string(), s);\n    }\n}\n\n#[test]\nfn from_sci_string_properties() {\n    string_gen_var_14().test_properties(|s| {\n        from_sci_string_helper(&s);\n    });\n\n    string_gen_var_15().test_properties(|s| {\n        from_sci_string_helper(&s);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(Integer::from_sci_string(&x.to_string()).unwrap(), x);\n    });\n}\n\nfn from_sci_string_with_options_helper(s: &str, options: FromSciStringOptions) {\n    if let Some(x) = Integer::from_sci_string_with_options(s, options) {\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 2);\n        for c in ['.', 'e', 'E', '+'] {\n            if s.contains(c) {\n                return;\n            }\n        }\n        if s.starts_with('0') || s.starts_with(\"-0\") {\n            return;\n        }\n        assert_eq!(x.to_string_base(options.get_base()), s.to_lowercase());\n    }\n}\n\n#[test]\nfn from_sci_string_with_options_properties() {\n    string_from_sci_string_options_pair_gen_var_2().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper(&s, options);\n    });\n\n    string_from_sci_string_options_pair_gen_var_3().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper(&s, options);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ExactFrom, FromStringBase, ToStringBase};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::exhaustive::valid_digit_chars;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_unsigned_pair_gen_var_5, string_gen, string_gen_var_4, unsigned_gen_var_11,\n    unsigned_pair_gen_var_19, unsigned_string_pair_gen_var_2, unsigned_string_pair_gen_var_3,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse num::{BigInt, Num};\nuse rug;\nuse std::collections::HashMap;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_str() {\n    let test_ok = |s, n| {\n        assert_eq!(Integer::from_str(s).unwrap().to_string(), n);\n        assert_eq!(BigInt::from_str(s).unwrap().to_string(), n);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_string(), n);\n    };\n    test_ok(\"0\", \"0\");\n    test_ok(\"+0\", \"0\");\n    test_ok(\"-0\", \"0\");\n    test_ok(\"123456\", \"123456\");\n    test_ok(\"+123456\", \"123456\");\n    test_ok(\"1000000000000000000000000\", \"1000000000000000000000000\");\n    test_ok(\"-123456\", \"-123456\");\n    test_ok(\"-1000000000000000000000000\", \"-1000000000000000000000000\");\n\n    let test_err = |s, rug_err| {\n        assert!(Integer::from_str(s).is_err());\n        assert!(BigInt::from_str(s).is_err());\n        let rn = rug::Integer::from_str(s);\n        assert_eq!(rn.is_err() || rn.unwrap() < 0, rug_err);\n    };\n    test_err(\"12A\", true);\n    test_err(\" 10\", false);\n    test_err(\"1.0\", true);\n    test_err(\"$%^\", true);\n    test_err(\"\", true);\n    test_err(\"-\", true);\n    test_err(\"--0\", true);\n    test_err(\"-+0\", true);\n    test_err(\"+-0\", true);\n    test_err(\"++0\", true);\n    test_err(\"--1\", true);\n    test_err(\"-+1\", true);\n    test_err(\"+-1\", true);\n    test_err(\"++1\", true);\n}\n\n#[test]\nfn from_str_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 64);\n    string_gen().test_properties_with_config(&config, |s| {\n        let trimmed = s.strip_prefix('-').unwrap_or(&s);\n        let trimmed = trimmed.strip_prefix('+').unwrap_or(trimmed);\n        assert_eq!(\n            Integer::from_str(&s).is_ok(),\n            !trimmed.is_empty() && trimmed.chars().all(|c| c.is_ascii_digit()),\n        );\n    });\n\n    string_gen_var_4().test_properties(|s| {\n        let n = Integer::from_str(&s).unwrap();\n        let abs_s = s.strip_prefix('-').unwrap_or(&s);\n        let trimmed = abs_s.trim_start_matches('0');\n        let trimmed = if trimmed.is_empty() {\n            \"0\".to_string()\n        } else if s.starts_with('-') {\n            \"-\".to_string() + trimmed\n        } else {\n            trimmed.to_string()\n        };\n        assert_eq!(n.to_string(), trimmed);\n        assert_eq!(n, Integer::from_string_base(10, &s).unwrap());\n        let mut with_zero = \"0\".to_string() + abs_s;\n        if s.starts_with('-') {\n            with_zero = \"-\".to_string() + &with_zero;\n        }\n        assert_eq!(Integer::from_str(&with_zero).unwrap(), n);\n\n        assert_eq!(BigInt::from_str(&s).unwrap(), BigInt::from(&n));\n        assert_eq!(rug::Integer::from_str(&s).unwrap(), rug::Integer::from(&n));\n    });\n\n    unsigned_gen_var_11().test_properties(|u| {\n        let zeros = vec![b'0'; u];\n        let zero_s = std::str::from_utf8(&zeros).unwrap();\n        assert_eq!(Integer::from_str(zero_s).unwrap(), 0);\n        assert_eq!(Integer::from_str(&(\"-\".to_string() + zero_s)).unwrap(), 0);\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|u| {\n        let s = u.to_string();\n        assert_eq!(\n            Integer::from_str(&s).unwrap(),\n            Integer::from(SignedLimb::from_str(&s).unwrap())\n        );\n    });\n}\n\n#[test]\nfn test_from_string_base() {\n    let test_ok = |base, s, n| {\n        assert_eq!(Integer::from_string_base(base, s).unwrap().to_string(), n);\n        assert_eq!(\n            BigInt::from_str_radix(s, u32::exact_from(base))\n                .unwrap()\n                .to_string(),\n            n\n        );\n        assert_eq!(\n            rug::Integer::from_str_radix(s, i32::exact_from(base))\n                .unwrap()\n                .to_string(),\n            n\n        );\n    };\n    test_ok(2, \"0\", \"0\");\n    test_ok(10, \"0\", \"0\");\n    test_ok(2, \"101\", \"5\");\n    test_ok(10, \"123456\", \"123456\");\n    test_ok(16, \"deadbeef\", \"3735928559\");\n    test_ok(16, \"DEADBEEF\", \"3735928559\");\n    test_ok(16, \"deAdBeEf\", \"3735928559\");\n    test_ok(10, \"1000000000000000000000000\", \"1000000000000000000000000\");\n    test_ok(2, \"1000000000000000000000000\", \"16777216\");\n    test_ok(\n        36,\n        \"1000000000000000000000000\",\n        \"22452257707354557240087211123792674816\",\n    );\n    test_ok(36, \"helloworld\", \"1767707668033969\");\n    test_ok(2, \"-0\", \"0\");\n    test_ok(10, \"-0\", \"0\");\n    test_ok(2, \"-101\", \"-5\");\n    test_ok(10, \"-123456\", \"-123456\");\n    test_ok(16, \"-deadbeef\", \"-3735928559\");\n    test_ok(16, \"-DEADBEEF\", \"-3735928559\");\n    test_ok(16, \"-deAdBeEf\", \"-3735928559\");\n    test_ok(\n        10,\n        \"-1000000000000000000000000\",\n        \"-1000000000000000000000000\",\n    );\n    test_ok(2, \"-1000000000000000000000000\", \"-16777216\");\n    test_ok(\n        36,\n        \"-1000000000000000000000000\",\n        \"-22452257707354557240087211123792674816\",\n    );\n    test_ok(36, \"-helloworld\", \"-1767707668033969\");\n\n    let test_err = |base, s, rug_err| {\n        assert!(Integer::from_string_base(base, s).is_none());\n        assert!(BigInt::from_str_radix(s, u32::exact_from(base)).is_err());\n        assert_eq!(\n            rug::Integer::from_str_radix(s, i32::exact_from(base)).is_err(),\n            rug_err\n        );\n    };\n    test_err(2, \"123\", true);\n    test_err(10, \"12A\", true);\n    test_err(35, \" 10\", false);\n    test_err(35, \"1.0\", true);\n    test_err(35, \"$%^\", true);\n    test_err(35, \"\", true);\n    test_err(35, \"-\", true);\n}\n\n#[test]\nfn from_string_base_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 64);\n    let mut digit_map = HashMap::new();\n    unsigned_string_pair_gen_var_2().test_properties_with_config(&config, |(base, s)| {\n        let abs_s = s.strip_prefix('-').unwrap_or(&s);\n        let digits = digit_map\n            .entry(base)\n            .or_insert_with(|| valid_digit_chars(base));\n        assert_eq!(\n            Integer::from_string_base(base, &s).is_some(),\n            !abs_s.is_empty() && abs_s.chars().all(|c| digits.contains(&c)),\n        );\n    });\n\n    unsigned_string_pair_gen_var_3().test_properties(|(base, s)| {\n        let n = Integer::from_string_base(base, &s).unwrap();\n        let s_lo = s.to_lowercase();\n        let abs_s = s_lo.strip_prefix('-').unwrap_or(&s_lo);\n        let trimmed = abs_s.trim_start_matches('0');\n        let trimmed = if trimmed.is_empty() {\n            \"0\".to_string()\n        } else if s.starts_with('-') {\n            \"-\".to_string() + trimmed\n        } else {\n            trimmed.to_string()\n        };\n        assert_eq!(n.to_string_base(base), trimmed);\n        let mut with_zero = \"0\".to_string() + abs_s;\n        if s.starts_with('-') {\n            with_zero = \"-\".to_string() + &with_zero;\n        }\n        assert_eq!(Integer::from_string_base(base, &with_zero).unwrap(), n);\n\n        assert_eq!(\n            BigInt::from_str_radix(&s, u32::from(base)).unwrap(),\n            BigInt::from(&n)\n        );\n        assert_eq!(\n            rug::Integer::from_str_radix(&s, i32::from(base)).unwrap(),\n            rug::Integer::from(&n)\n        );\n    });\n\n    unsigned_pair_gen_var_19().test_properties(|(u, base)| {\n        let zeros = vec![b'0'; u];\n        let zero_s = std::str::from_utf8(&zeros).unwrap();\n        assert_eq!(Integer::from_string_base(base, zero_s).unwrap(), 0);\n        assert_eq!(\n            Integer::from_string_base(base, &(\"-\".to_string() + zero_s)).unwrap(),\n            0\n        );\n    });\n\n    signed_unsigned_pair_gen_var_5::<SignedLimb, u8>().test_properties(|(i, base)| {\n        let s = i.to_string_base(base);\n        assert_eq!(\n            Integer::from_string_base(base, &s).unwrap(),\n            Integer::from(SignedLimb::from_string_base(base, &s).unwrap())\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{FloorLogBase, Pow, PowerOf2, RoundToMultiple};\nuse malachite_base::num::conversion::string::options::{\n    FromSciStringOptions, SciSizeOptions, ToSciOptions,\n};\nuse malachite_base::num::conversion::traits::{FromSciString, ToSci};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::{signed_gen, signed_to_sci_options_pair_gen_var_1};\nuse malachite_base::test_util::num::conversion::string::from_sci_string::DECIMAL_SCI_STRING_CHARS;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{integer_gen, integer_to_sci_options_pair_gen_var_1};\nuse std::collections::HashMap;\nuse std::str::FromStr;\n\n#[test]\npub fn test_to_sci() {\n    assert_eq!(\n        Integer::power_of_2(1000000).to_sci().to_string(),\n        \"9.900656229295898e301029\"\n    );\n    assert_eq!(\n        (-Integer::power_of_2(1000000)).to_sci().to_string(),\n        \"-9.900656229295898e301029\"\n    );\n\n    fn test_i(x: &Integer, out: &str) {\n        assert_eq!(x.to_sci().to_string(), out);\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            out\n        );\n    }\n    fn test(s: &str, out: &str) {\n        test_i(&Integer::from_str(s).unwrap(), out);\n    }\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"10\", \"10\");\n    test(\"100\", \"100\");\n    test(\"1000\", \"1000\");\n    test(\"10000\", \"10000\");\n    test(\"100000\", \"100000\");\n    test(\"1000000\", \"1000000\");\n    test(\"10000000\", \"10000000\");\n    test(\"100000000\", \"100000000\");\n    test(\"1000000000\", \"1000000000\");\n    test(\"10000000000\", \"10000000000\");\n    test(\"100000000000\", \"100000000000\");\n    test(\"1000000000000\", \"1000000000000\");\n    test(\"10000000000000\", \"10000000000000\");\n    test(\"100000000000000\", \"100000000000000\");\n    test(\"1000000000000000\", \"1000000000000000\");\n    test(\"10000000000000000\", \"1e16\");\n    test(\"100000000000000000\", \"1e17\");\n    test_i(&Integer::from(u64::MAX), \"1.844674407370955e19\");\n    test_i(&Integer::from(u128::MAX), \"3.402823669209385e38\");\n    test_i(&Integer::from(i64::MAX), \"9.223372036854776e18\");\n    test_i(&Integer::from(i128::MAX), \"1.701411834604692e38\");\n\n    test(\"999999999999999\", \"999999999999999\");\n    test(\"9999999999999999\", \"9999999999999999\");\n    test(\"99999999999999999\", \"1e17\");\n    test(\"999999999999999999\", \"1e18\");\n\n    test(\"-1\", \"-1\");\n    test(\"-10\", \"-10\");\n    test(\"-100\", \"-100\");\n    test(\"-1000\", \"-1000\");\n    test(\"-10000\", \"-10000\");\n    test(\"-100000\", \"-100000\");\n    test(\"-1000000\", \"-1000000\");\n    test(\"-10000000\", \"-10000000\");\n    test(\"-100000000\", \"-100000000\");\n    test(\"-1000000000\", \"-1000000000\");\n    test(\"-10000000000\", \"-10000000000\");\n    test(\"-100000000000\", \"-100000000000\");\n    test(\"-1000000000000\", \"-1000000000000\");\n    test(\"-10000000000000\", \"-10000000000000\");\n    test(\"-100000000000000\", \"-100000000000000\");\n    test(\"-1000000000000000\", \"-1000000000000000\");\n    test(\"-10000000000000000\", \"-1e16\");\n    test(\"-100000000000000000\", \"-1e17\");\n    test_i(&Integer::from(i64::MIN), \"-9.223372036854776e18\");\n    test_i(&Integer::from(i128::MIN), \"-1.701411834604692e38\");\n}\n\n#[test]\npub fn test_to_sci_with_options() {\n    fn test_i(x: &Integer, options: ToSciOptions, out: &str) {\n        assert_eq!(x.to_sci_with_options(options).to_string(), out);\n    }\n    fn test(s: &str, options: ToSciOptions, out: &str) {\n        test_i(&Integer::from_str(s).unwrap(), options, out);\n    }\n    // For tests with the default options, see `test_to_sci`\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.000000000000000\");\n    test(\"1\", options, \"1.000000000000000\");\n    test(\"10\", options, \"10.00000000000000\");\n    test(\"100\", options, \"100.0000000000000\");\n    test(\"1000\", options, \"1000.000000000000\");\n    test(\"10000\", options, \"10000.00000000000\");\n    test(\"100000\", options, \"100000.0000000000\");\n    test(\"1000000\", options, \"1000000.000000000\");\n    test(\"10000000\", options, \"10000000.00000000\");\n    test(\"100000000\", options, \"100000000.0000000\");\n    test(\"1000000000\", options, \"1000000000.000000\");\n    test(\"10000000000\", options, \"10000000000.00000\");\n    test(\"100000000000\", options, \"100000000000.0000\");\n    test(\"1000000000000\", options, \"1000000000000.000\");\n    test(\"10000000000000\", options, \"10000000000000.00\");\n    test(\"100000000000000\", options, \"100000000000000.0\");\n    test(\"1000000000000000\", options, \"1000000000000000\");\n    test(\"10000000000000000\", options, \"1.000000000000000e16\");\n    test(\"100000000000000000\", options, \"1.000000000000000e17\");\n    test_i(&Integer::from(u64::MAX), options, \"1.844674407370955e19\");\n    test_i(&Integer::from(u128::MAX), options, \"3.402823669209385e38\");\n\n    test(\"999999999999999\", options, \"999999999999999.0\");\n    test(\"9999999999999999\", options, \"9999999999999999\");\n    test(\"99999999999999999\", options, \"1.000000000000000e17\");\n    test(\"999999999999999999\", options, \"1.000000000000000e18\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test_i(&Integer::from(u128::MAX), options, \"1e128\");\n    options.set_base(3);\n    test_i(&Integer::from(u128::MAX), options, \"2.022011021210021e80\");\n    options.set_base(4);\n    test_i(&Integer::from(u128::MAX), options, \"1e64\");\n    options.set_base(5);\n    test_i(&Integer::from(u128::MAX), options, \"1.103111044120131e55\");\n    options.set_base(8);\n    test_i(&Integer::from(u128::MAX), options, \"4e42\");\n    // When base >= 15, there is a mandatory sign after the exponent indicator \"e\", to distinguish\n    // it from the digit \"e\"\n    options.set_base(16);\n    test_i(&Integer::from(u128::MAX), options, \"1e+32\");\n    options.set_base(32);\n    test_i(&Integer::from(u128::MAX), options, \"8e+25\");\n    options.set_base(36);\n    test_i(&Integer::from(u128::MAX), options, \"f.5lxx1zz5pnorynqe+24\");\n\n    // The sign can be forced in other cases too\n    options.set_base(3);\n    options.set_force_exponent_plus_sign(true);\n    test_i(&Integer::from(u128::MAX), options, \"2.022011021210021e+80\");\n\n    // The digits can be uppercase, and so can the exponent indicator\n    options = ToSciOptions::default();\n    options.set_base(36);\n    options.set_uppercase();\n    test_i(&Integer::from(u128::MAX), options, \"F.5LXX1ZZ5PNORYNQe+24\");\n\n    options.set_lowercase();\n    options.set_e_uppercase();\n    test_i(&Integer::from(u128::MAX), options, \"f.5lxx1zz5pnorynqE+24\");\n\n    options.set_uppercase();\n    test_i(&Integer::from(u128::MAX), options, \"F.5LXX1ZZ5PNORYNQE+24\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    options.set_base(2);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n    );\n    options.set_base(3);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n    );\n    options.set_base(4);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n    );\n    options.set_base(5);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"11031110441201303134210404233413032443021130230130231310\",\n    );\n    options.set_base(8);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"3777777777777777777777777777777777777777777\",\n    );\n    options.set_base(16);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"ffffffffffffffffffffffffffffffff\",\n    );\n    options.set_base(32);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"7vvvvvvvvvvvvvvvvvvvvvvvvv\",\n    );\n    options.set_base(36);\n    test_i(\n        &Integer::from(u128::MAX),\n        options,\n        \"f5lxx1zz5pnorynqglhzmsp33\",\n    );\n\n    options = ToSciOptions::default();\n    options.set_precision(4);\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.000\");\n    test(\"1\", options, \"1.000\");\n    test(\"10\", options, \"10.00\");\n    test(\"100\", options, \"100.0\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"1.000e4\");\n    test(\"9\", options, \"9.000\");\n    test(\"99\", options, \"99.00\");\n    test(\"999\", options, \"999.0\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"1.000e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_precision(1);\n    options.set_include_trailing_zeros(true); // doesn't matter when precision is 1\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"1e1\");\n    test(\"100\", options, \"1e2\");\n    test(\"1000\", options, \"1e3\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"1e2\");\n    test(\"999\", options, \"1e3\");\n    test(\"9999\", options, \"1e4\");\n    test(\"99999\", options, \"1e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"1e1\");\n    test(\"100\", options, \"1e2\");\n    test(\"1000\", options, \"1e3\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"1e2\");\n    test(\"999\", options, \"1e3\");\n    test(\"9999\", options, \"1e4\");\n    test(\"99999\", options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.00\");\n    test(\"1\", options, \"1.00\");\n    test(\"10\", options, \"10.00\");\n    test(\"100\", options, \"100.00\");\n    test(\"1000\", options, \"1000.00\");\n    test(\"10000\", options, \"10000.00\");\n    test(\"9\", options, \"9.00\");\n    test(\"99\", options, \"99.00\");\n    test(\"999\", options, \"999.00\");\n    test(\"9999\", options, \"9999.00\");\n    test(\"99999\", options, \"99999.00\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_scale(0);\n    options.set_include_trailing_zeros(true); // doesn't matter when scale is 0\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_precision(2);\n    options.set_rounding_mode(Nearest); // This is the default\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Down);\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Floor);\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Up);\n    test(\"123\", options, \"1.3e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"123\", options, \"1.3e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"135\", options, \"1.4e2\");\n    options.set_rounding_mode(Down);\n    test(\"135\", options, \"1.3e2\");\n    options.set_rounding_mode(Floor);\n    test(\"135\", options, \"1.3e2\");\n    options.set_rounding_mode(Up);\n    test(\"135\", options, \"1.4e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"135\", options, \"1.4e2\");\n\n    options.set_rounding_mode(Exact);\n    test(\"140\", options, \"1.4e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"999\", options, \"1e3\");\n    options.set_rounding_mode(Down);\n    test(\"999\", options, \"9.9e2\");\n    options.set_rounding_mode(Floor);\n    test(\"999\", options, \"9.9e2\");\n    options.set_rounding_mode(Up);\n    test(\"999\", options, \"1e3\");\n    options.set_rounding_mode(Ceiling);\n    test(\"999\", options, \"1e3\");\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    test_i(&Integer::from(i64::MAX), options, \"9.223372036854776e18\");\n    test_i(&Integer::from(i128::MAX), options, \"1.701411834604692e38\");\n    test(\"-1\", options, \"-1.000000000000000\");\n    test(\"-10\", options, \"-10.00000000000000\");\n    test(\"-100\", options, \"-100.0000000000000\");\n    test(\"-1000\", options, \"-1000.000000000000\");\n    test(\"-10000\", options, \"-10000.00000000000\");\n    test(\"-100000\", options, \"-100000.0000000000\");\n    test(\"-1000000\", options, \"-1000000.000000000\");\n    test(\"-10000000\", options, \"-10000000.00000000\");\n    test(\"-100000000\", options, \"-100000000.0000000\");\n    test(\"-1000000000\", options, \"-1000000000.000000\");\n    test(\"-10000000000\", options, \"-10000000000.00000\");\n    test(\"-100000000000\", options, \"-100000000000.0000\");\n    test(\"-1000000000000\", options, \"-1000000000000.000\");\n    test(\"-10000000000000\", options, \"-10000000000000.00\");\n    test(\"-100000000000000\", options, \"-100000000000000.0\");\n    test(\"-1000000000000000\", options, \"-1000000000000000\");\n    test(\"-10000000000000000\", options, \"-1.000000000000000e16\");\n    test(\"-100000000000000000\", options, \"-1.000000000000000e17\");\n    test_i(&Integer::from(i64::MIN), options, \"-9.223372036854776e18\");\n    test_i(&Integer::from(i128::MIN), options, \"-1.701411834604692e38\");\n\n    test(\"-999999999999999\", options, \"-999999999999999.0\");\n    test(\"-9999999999999999\", options, \"-9999999999999999\");\n    test(\"-99999999999999999\", options, \"-1.000000000000000e17\");\n    test(\"-999999999999999999\", options, \"-1.000000000000000e18\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test_i(&Integer::from(i128::MAX), options, \"1e127\");\n    test_i(&Integer::from(i128::MIN), options, \"-1e127\");\n    options.set_base(3);\n    test_i(&Integer::from(i128::MAX), options, \"1.01100201022001e80\");\n    test_i(&Integer::from(i128::MIN), options, \"-1.01100201022001e80\");\n    options.set_base(4);\n    test_i(&Integer::from(i128::MAX), options, \"2e63\");\n    test_i(&Integer::from(i128::MIN), options, \"-2e63\");\n    options.set_base(5);\n    test_i(&Integer::from(i128::MAX), options, \"3.013030220323124e54\");\n    test_i(&Integer::from(i128::MIN), options, \"-3.013030220323124e54\");\n    options.set_base(8);\n    test_i(&Integer::from(i128::MAX), options, \"2e42\");\n    test_i(&Integer::from(i128::MIN), options, \"-2e42\");\n    // When base >= 15, there is a mandatory sign after the exponent indicator \"e\", to distinguish\n    // it from the digit \"e\"\n    options.set_base(16);\n    test_i(&Integer::from(i128::MAX), options, \"8e+31\");\n    test_i(&Integer::from(i128::MIN), options, \"-8e+31\");\n    options.set_base(32);\n    test_i(&Integer::from(i128::MAX), options, \"4e+25\");\n    test_i(&Integer::from(i128::MIN), options, \"-4e+25\");\n    options.set_base(36);\n    test_i(&Integer::from(i128::MAX), options, \"7.ksyyizzkutudzbve+24\");\n    test_i(&Integer::from(i128::MIN), options, \"-7.ksyyizzkutudzbve+24\");\n\n    // The sign can be forced in other cases too\n    options.set_base(3);\n    options.set_force_exponent_plus_sign(true);\n    test_i(&Integer::from(i128::MAX), options, \"1.01100201022001e+80\");\n    test_i(&Integer::from(i128::MIN), options, \"-1.01100201022001e+80\");\n\n    // The digits can be uppercase, and so can the exponent indicator\n    options = ToSciOptions::default();\n    options.set_base(36);\n    options.set_uppercase();\n    test_i(&Integer::from(i128::MAX), options, \"7.KSYYIZZKUTUDZBVe+24\");\n    test_i(&Integer::from(i128::MIN), options, \"-7.KSYYIZZKUTUDZBVe+24\");\n\n    options.set_lowercase();\n    options.set_e_uppercase();\n    test_i(&Integer::from(i128::MAX), options, \"7.ksyyizzkutudzbvE+24\");\n    test_i(&Integer::from(i128::MIN), options, \"-7.ksyyizzkutudzbvE+24\");\n\n    options.set_uppercase();\n    test_i(&Integer::from(i128::MAX), options, \"7.KSYYIZZKUTUDZBVE+24\");\n    test_i(&Integer::from(i128::MIN), options, \"-7.KSYYIZZKUTUDZBVE+24\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    options.set_base(2);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n    );\n    options.set_base(3);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n    );\n    options.set_base(4);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n    );\n    options.set_base(5);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"3013030220323124042102424341431241221233040112312340402\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-3013030220323124042102424341431241221233040112312340403\",\n    );\n    options.set_base(8);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"1777777777777777777777777777777777777777777\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-2000000000000000000000000000000000000000000\",\n    );\n    options.set_base(16);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"7fffffffffffffffffffffffffffffff\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-80000000000000000000000000000000\",\n    );\n    options.set_base(32);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"3vvvvvvvvvvvvvvvvvvvvvvvvv\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-40000000000000000000000000\",\n    );\n    options.set_base(36);\n    test_i(\n        &Integer::from(i128::MAX),\n        options,\n        \"7ksyyizzkutudzbv8aqztecjj\",\n    );\n    test_i(\n        &Integer::from(i128::MIN),\n        options,\n        \"-7ksyyizzkutudzbv8aqztecjk\",\n    );\n\n    options = ToSciOptions::default();\n    options.set_precision(4);\n    options.set_include_trailing_zeros(true);\n    test(\"-1\", options, \"-1.000\");\n    test(\"-10\", options, \"-10.00\");\n    test(\"-100\", options, \"-100.0\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-1.000e4\");\n    test(\"-9\", options, \"-9.000\");\n    test(\"-99\", options, \"-99.00\");\n    test(\"-999\", options, \"-999.0\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-1.000e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-1e4\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-1e5\");\n\n    options = ToSciOptions::default();\n    options.set_precision(1);\n    options.set_include_trailing_zeros(true); // doesn't matter when precision is 1\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-1e1\");\n    test(\"-100\", options, \"-1e2\");\n    test(\"-1000\", options, \"-1e3\");\n    test(\"-10000\", options, \"-1e4\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-1e2\");\n    test(\"-999\", options, \"-1e3\");\n    test(\"-9999\", options, \"-1e4\");\n    test(\"-99999\", options, \"-1e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-1e1\");\n    test(\"-100\", options, \"-1e2\");\n    test(\"-1000\", options, \"-1e3\");\n    test(\"-10000\", options, \"-1e4\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-1e2\");\n    test(\"-999\", options, \"-1e3\");\n    test(\"-9999\", options, \"-1e4\");\n    test(\"-99999\", options, \"-1e5\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    options.set_include_trailing_zeros(true);\n    test(\"-1\", options, \"-1.00\");\n    test(\"-10\", options, \"-10.00\");\n    test(\"-100\", options, \"-100.00\");\n    test(\"-1000\", options, \"-1000.00\");\n    test(\"-10000\", options, \"-10000.00\");\n    test(\"-9\", options, \"-9.00\");\n    test(\"-99\", options, \"-99.00\");\n    test(\"-999\", options, \"-999.00\");\n    test(\"-9999\", options, \"-9999.00\");\n    test(\"-99999\", options, \"-99999.00\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-10000\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-99999\");\n\n    options = ToSciOptions::default();\n    options.set_scale(0);\n    options.set_include_trailing_zeros(true); // doesn't matter when scale is 0\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-10000\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-99999\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-10000\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-99999\");\n\n    options = ToSciOptions::default();\n    options.set_precision(2);\n    options.set_rounding_mode(Nearest); // This is the default\n    test(\"-123\", options, \"-1.2e2\");\n    options.set_rounding_mode(Down);\n    test(\"-123\", options, \"-1.2e2\");\n    options.set_rounding_mode(Floor);\n    test(\"-123\", options, \"-1.3e2\");\n    options.set_rounding_mode(Up);\n    test(\"-123\", options, \"-1.3e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"-123\", options, \"-1.2e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"-135\", options, \"-1.4e2\");\n    options.set_rounding_mode(Down);\n    test(\"-135\", options, \"-1.3e2\");\n    options.set_rounding_mode(Floor);\n    test(\"-135\", options, \"-1.4e2\");\n    options.set_rounding_mode(Up);\n    test(\"-135\", options, \"-1.4e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"-135\", options, \"-1.3e2\");\n\n    options.set_rounding_mode(Exact);\n    test(\"-140\", options, \"-1.4e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"-999\", options, \"-1e3\");\n    options.set_rounding_mode(Down);\n    test(\"-999\", options, \"-9.9e2\");\n    options.set_rounding_mode(Floor);\n    test(\"-999\", options, \"-1e3\");\n    options.set_rounding_mode(Up);\n    test(\"-999\", options, \"-1e3\");\n    options.set_rounding_mode(Ceiling);\n    test(\"-999\", options, \"-9.9e2\");\n}\n\n#[should_panic]\n#[test]\npub fn to_sci_with_options_fail() {\n    let mut options = ToSciOptions::default();\n    options.set_rounding_mode(Exact);\n    options.set_precision(2);\n    Integer::from(123).to_sci_with_options(options).to_string();\n}\n\n#[test]\nfn to_sci_properties() {\n    let mut powers_of_10 = HashMap::new();\n    const TEN: Integer = Integer::const_from_unsigned(10);\n    const U_TEN: Natural = Natural::const_from(10);\n    let default_p = 16;\n    integer_gen().test_properties(|x| {\n        assert!(x.fmt_sci_valid(ToSciOptions::default()));\n        let s = x.to_sci().to_string();\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            s\n        );\n        assert!(string_is_subset(&s, DECIMAL_SCI_STRING_CHARS));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains('E'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(!s.contains(\"-.\"));\n        assert!(!s.contains(\"e-\"));\n        let x_from = Integer::from_sci_string(&s).unwrap();\n        if x == 0u32 {\n            assert_eq!(x_from, 0u32);\n        } else {\n            let log = x.unsigned_abs_ref().floor_log_base(&U_TEN);\n            if log < default_p {\n                assert_eq!(x_from, x);\n            } else {\n                let pow = powers_of_10\n                    .entry(log - default_p + 1)\n                    .or_insert_with_key(|&p| (&TEN).pow(p));\n                assert_eq!(x.round_to_multiple(&*pow, Nearest).0, x_from);\n            }\n        }\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|x| {\n        assert_eq!(\n            x.to_sci().to_string(),\n            Integer::from(x).to_sci().to_string()\n        );\n    });\n}\n\n#[test]\nfn to_sci_with_options_properties() {\n    let mut powers = HashMap::new();\n    let mut chars = HashMap::new();\n    integer_to_sci_options_pair_gen_var_1().test_properties(|(x, options)| {\n        assert!(x.fmt_sci_valid(options));\n        let s = x.to_sci_with_options(options).to_string();\n        let cs: &mut String = chars.entry(options.get_base()).or_insert_with_key(|&base| {\n            let mut cs = \"+-.0123456789\".to_string();\n            if base > 10 {\n                let limit = usize::from(base - 10);\n                for c in ('a'..='z').take(limit) {\n                    cs.push(c);\n                }\n                for c in ('A'..='Z').take(limit) {\n                    cs.push(c);\n                }\n            }\n            if base < 15 {\n                cs.push('e');\n                cs.push('E');\n            }\n            cs\n        });\n        assert!(string_is_subset(&s, cs));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(!s.contains(\"-.\"));\n        assert!(!s.contains(\"e-\"));\n        assert!(!s.contains(\"E-\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 1);\n        let mut from_options = FromSciStringOptions::default();\n        from_options.set_base(options.get_base());\n        let x_from = Integer::from_sci_string_with_options(&s, from_options).unwrap();\n        if x == 0u32 {\n            assert_eq!(x_from, 0u32);\n        } else {\n            let base = Integer::from(options.get_base());\n            let u_base = Natural::from(options.get_base());\n            let scale = match options.get_size_options() {\n                SciSizeOptions::Complete | SciSizeOptions::Scale(_) => None,\n                SciSizeOptions::Precision(p) => {\n                    let log = x.unsigned_abs_ref().floor_log_base(&u_base);\n                    if log >= p { Some(log - p + 1) } else { None }\n                }\n            };\n            if let Some(scale) = scale {\n                let pow = powers\n                    .entry((base.clone(), scale))\n                    .or_insert_with(|| base.pow(scale));\n                assert_eq!(\n                    x.round_to_multiple(&*pow, options.get_rounding_mode()).0,\n                    x_from\n                );\n            } else {\n                assert_eq!(x_from, x);\n            }\n        }\n    });\n\n    signed_to_sci_options_pair_gen_var_1::<SignedLimb>().test_properties(|(x, options)| {\n        assert_eq!(\n            x.to_sci_with_options(options).to_string(),\n            Integer::from(x).to_sci_with_options(options).to_string()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::repeat_n;\nuse malachite_base::num::arithmetic::traits::SaturatingSubAssign;\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::conversion::string::to_string::BaseFmtWrapper as BaseBaseFmtWrapper;\nuse malachite_base::num::conversion::traits::{FromStringBase, ToStringBase};\nuse malachite_base::strings::{\n    ToBinaryString, ToDebugString, ToLowerHexString, ToOctalString, ToUpperHexString,\n    string_is_subset,\n};\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_2, signed_unsigned_pair_gen_var_5, signed_unsigned_pair_gen_var_7,\n    signed_unsigned_unsigned_triple_gen_var_3, unsigned_gen_var_8, unsigned_pair_gen_var_9,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_unsigned_pair_gen_var_1, integer_unsigned_pair_gen_var_2,\n    integer_unsigned_unsigned_triple_gen_var_1,\n};\nuse num::BigInt;\nuse std::cmp::max;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nfn test_padding(mut s: &str, mut s_padded: &str, mut width: usize) {\n    assert!(s_padded.len() >= width);\n    assert_eq!(s.len() >= width, s == s_padded);\n    let negative = s.starts_with('-');\n    assert_eq!(s_padded.starts_with('-'), negative);\n    if negative {\n        s = &s[1..];\n        s_padded = &s_padded[1..];\n        width.saturating_sub_assign(1);\n    }\n    assert!(s_padded.ends_with(&s));\n    assert!(s_padded.len() >= width);\n    assert_eq!(s.len() >= width, s == s_padded);\n    if s.len() < width {\n        let diff = s_padded.len() - s.len();\n        assert!(s_padded[..diff].chars().all(|c| c == '0'));\n        assert_eq!(&s_padded[diff..], s);\n    }\n}\n\n#[test]\npub fn test_to_string() {\n    fn test(u: &str) {\n        let x = Integer::from_str(u).unwrap();\n        assert_eq!(x.to_string(), u);\n        assert_eq!(x.to_debug_string(), u);\n        assert_eq!(format!(\"{x:00}\"), u);\n        assert_eq!(format!(\"{x:00?}\"), u);\n    }\n    test(\"0\");\n    test(\"2\");\n    test(\"123\");\n    test(\"1000\");\n    test(\"1000000\");\n    test(\"1000000000000000\");\n    test(\"-2\");\n    test(\"-123\");\n    test(\"-1000\");\n    test(\"-1000000\");\n    test(\"-1000000000000000\");\n\n    fn test_width(u: &str, width: usize, out: &str) {\n        let x = Integer::from_str(u).unwrap();\n        let s = x.to_string();\n        assert_eq!(format!(\"{x:0width$}\"), out);\n        assert_eq!(format!(\"{x:0width$?}\"), out);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\");\n    test_width(\"0\", 1, \"0\");\n    test_width(\"0\", 2, \"00\");\n    test_width(\"0\", 5, \"00000\");\n    test_width(\"1000000\", 0, \"1000000\");\n    test_width(\"1000000\", 1, \"1000000\");\n    test_width(\"1000000\", 2, \"1000000\");\n    test_width(\"1000000\", 3, \"1000000\");\n    test_width(\"1000000\", 4, \"1000000\");\n    test_width(\"1000000\", 5, \"1000000\");\n    test_width(\"1000000\", 6, \"1000000\");\n    test_width(\"1000000\", 7, \"1000000\");\n    test_width(\"1000000\", 8, \"01000000\");\n    test_width(\"1000000\", 10, \"0001000000\");\n    test_width(\"1000000000000000\", 0, \"1000000000000000\");\n    test_width(\"1000000000000000\", 1, \"1000000000000000\");\n    test_width(\"1000000000000000\", 16, \"1000000000000000\");\n    test_width(\"1000000000000000\", 20, \"00001000000000000000\");\n    test_width(\"-1000000\", 0, \"-1000000\");\n    test_width(\"-1000000\", 1, \"-1000000\");\n    test_width(\"-1000000\", 2, \"-1000000\");\n    test_width(\"-1000000\", 3, \"-1000000\");\n    test_width(\"-1000000\", 4, \"-1000000\");\n    test_width(\"-1000000\", 5, \"-1000000\");\n    test_width(\"-1000000\", 6, \"-1000000\");\n    test_width(\"-1000000\", 7, \"-1000000\");\n    test_width(\"-1000000\", 8, \"-1000000\");\n    test_width(\"-1000000\", 9, \"-01000000\");\n    test_width(\"-1000000\", 10, \"-001000000\");\n    test_width(\"-1000000000000000\", 0, \"-1000000000000000\");\n    test_width(\"-1000000000000000\", 1, \"-1000000000000000\");\n    test_width(\"-1000000000000000\", 16, \"-1000000000000000\");\n    test_width(\"-1000000000000000\", 20, \"-0001000000000000000\");\n}\n\n#[test]\nfn to_string_properties() {\n    integer_gen().test_properties(|x| {\n        let s = x.to_string();\n        assert_eq!(x.to_debug_string(), s);\n        assert_eq!(x.to_string_base(10), s);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(BigInt::from(&x).to_string(), s);\n        assert_eq!(rug::Integer::from(&x).to_string(), s);\n        assert!(string_is_subset(&s, \"-0123456789\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, width)| {\n        let s = x.to_string();\n        let s_padded = format!(\"{x:0width$}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(format!(\"{x:0width$?}\"), s_padded);\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 10), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$?}\", BaseFmtWrapper::new(&x, 10), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|x| {\n        assert_eq!(Integer::from(x).to_string(), x.to_string());\n    });\n\n    signed_unsigned_pair_gen_var_5::<SignedLimb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$}\", Integer::from(x), width = width),\n            format!(\"{x:0width$}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_binary_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        assert_eq!(x.to_binary_string(), out);\n        assert_eq!(format!(\"{x:00b}\"), out);\n        assert_eq!(format!(\"{x:#b}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0b0\");\n    test(\"2\", \"10\", \"0b10\");\n    test(\"123\", \"1111011\", \"0b1111011\");\n    test(\"1000\", \"1111101000\", \"0b1111101000\");\n    test(\"1000000\", \"11110100001001000000\", \"0b11110100001001000000\");\n    test(\n        \"1000000000000000\",\n        \"11100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n    test(\"-2\", \"-10\", \"-0b10\");\n    test(\"-123\", \"-1111011\", \"-0b1111011\");\n    test(\"-1000\", \"-1111101000\", \"-0b1111101000\");\n    test(\n        \"-1000000\",\n        \"-11110100001001000000\",\n        \"-0b11110100001001000000\",\n    );\n    test(\n        \"-1000000000000000\",\n        \"-11100011010111111010100100110001101000000000000000\",\n        \"-0b11100011010111111010100100110001101000000000000000\",\n    );\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        let s = x.to_binary_string();\n        assert_eq!(format!(\"{x:0width$b}\"), out);\n        assert_eq!(format!(\"{x:#0width$b}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0b0\");\n    test_width(\"0\", 1, \"0\", \"0b0\");\n    test_width(\"0\", 2, \"00\", \"0b0\");\n    test_width(\"0\", 5, \"00000\", \"0b000\");\n    test_width(\"1000\", 0, \"1111101000\", \"0b1111101000\");\n    test_width(\"1000\", 1, \"1111101000\", \"0b1111101000\");\n    test_width(\"1000\", 10, \"1111101000\", \"0b1111101000\");\n    test_width(\"1000\", 12, \"001111101000\", \"0b1111101000\");\n    test_width(\"1000\", 14, \"00001111101000\", \"0b001111101000\");\n    test_width(\n        \"1000000000000000\",\n        0,\n        \"11100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        1,\n        \"11100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        52,\n        \"0011100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        54,\n        \"000011100011010111111010100100110001101000000000000000\",\n        \"0b0011100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\"-1000\", 0, \"-1111101000\", \"-0b1111101000\");\n    test_width(\"-1000\", 1, \"-1111101000\", \"-0b1111101000\");\n    test_width(\"-1000\", 10, \"-1111101000\", \"-0b1111101000\");\n    test_width(\"-1000\", 13, \"-001111101000\", \"-0b1111101000\");\n    test_width(\"-1000\", 15, \"-00001111101000\", \"-0b001111101000\");\n    test_width(\n        \"-1000000000000000\",\n        0,\n        \"-11100011010111111010100100110001101000000000000000\",\n        \"-0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        1,\n        \"-11100011010111111010100100110001101000000000000000\",\n        \"-0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        53,\n        \"-0011100011010111111010100100110001101000000000000000\",\n        \"-0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        55,\n        \"-000011100011010111111010100100110001101000000000000000\",\n        \"-0b0011100011010111111010100100110001101000000000000000\",\n    );\n}\n\n#[test]\nfn to_binary_string_properties() {\n    integer_gen().test_properties(|x| {\n        let s = x.to_binary_string();\n        let prefixed_s = if x < 0 {\n            \"-0b\".to_owned() + &s[1..]\n        } else {\n            \"0b\".to_owned() + &s\n        };\n        assert_eq!(format!(\"{x:#b}\"), prefixed_s);\n        assert_eq!(format!(\"{x:00b}\"), s);\n        assert_eq!(format!(\"{x:#00b}\"), prefixed_s);\n        assert_eq!(x.to_string_base(2), s);\n        let num_x = BigInt::from(&x);\n        assert_eq!(num_x.to_binary_string(), s);\n        assert_eq!(format!(\"{num_x:#b}\"), prefixed_s);\n        let rug_x = rug::Integer::from(&x);\n        assert_eq!(rug_x.to_binary_string(), s);\n        assert_eq!(format!(\"{rug_x:#b}\"), prefixed_s);\n        assert!(string_is_subset(&s, \"-01\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, width)| {\n        let s = x.to_binary_string();\n        let s_padded = format!(\"{x:0width$b}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$b}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$b}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$b}\");\n        assert_eq!(\n            format!(\"{:#0width$b}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$b}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    signed_gen_var_2::<SignedLimb>().test_properties(|x| {\n        assert_eq!(Integer::from(x).to_binary_string(), x.to_binary_string());\n        assert_eq!(format!(\"{:#b}\", Integer::from(x)), format!(\"{x:#b}\"));\n    });\n\n    signed_unsigned_pair_gen_var_7::<SignedLimb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$b}\", Integer::from(x), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$b}\", Integer::from(x), width = width),\n            format!(\"{x:#0width$b}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_octal_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        assert_eq!(x.to_octal_string(), out);\n        assert_eq!(format!(\"{x:00o}\"), out);\n        assert_eq!(format!(\"{x:#o}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0o0\");\n    test(\"2\", \"2\", \"0o2\");\n    test(\"123\", \"173\", \"0o173\");\n    test(\"1000\", \"1750\", \"0o1750\");\n    test(\"1000000\", \"3641100\", \"0o3641100\");\n    test(\n        \"1000000000000000\",\n        \"34327724461500000\",\n        \"0o34327724461500000\",\n    );\n    test(\"-2\", \"-2\", \"-0o2\");\n    test(\"-123\", \"-173\", \"-0o173\");\n    test(\"-1000\", \"-1750\", \"-0o1750\");\n    test(\"-1000000\", \"-3641100\", \"-0o3641100\");\n    test(\n        \"-1000000000000000\",\n        \"-34327724461500000\",\n        \"-0o34327724461500000\",\n    );\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        let s = x.to_octal_string();\n        assert_eq!(format!(\"{x:0width$o}\"), out);\n        assert_eq!(format!(\"{x:#0width$o}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0o0\");\n    test_width(\"0\", 1, \"0\", \"0o0\");\n    test_width(\"0\", 2, \"00\", \"0o0\");\n    test_width(\"0\", 3, \"000\", \"0o0\");\n    test_width(\"0\", 4, \"0000\", \"0o00\");\n    test_width(\"0\", 5, \"00000\", \"0o000\");\n    test_width(\"1000\", 0, \"1750\", \"0o1750\");\n    test_width(\"1000\", 1, \"1750\", \"0o1750\");\n    test_width(\"1000\", 4, \"1750\", \"0o1750\");\n    test_width(\"1000\", 6, \"001750\", \"0o1750\");\n    test_width(\"1000\", 8, \"00001750\", \"0o001750\");\n    test_width(\n        \"1000000000000000\",\n        0,\n        \"34327724461500000\",\n        \"0o34327724461500000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        1,\n        \"34327724461500000\",\n        \"0o34327724461500000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        19,\n        \"0034327724461500000\",\n        \"0o34327724461500000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        21,\n        \"000034327724461500000\",\n        \"0o0034327724461500000\",\n    );\n    test_width(\"-1000\", 0, \"-1750\", \"-0o1750\");\n    test_width(\"-1000\", 1, \"-1750\", \"-0o1750\");\n    test_width(\"-1000\", 4, \"-1750\", \"-0o1750\");\n    test_width(\"-1000\", 7, \"-001750\", \"-0o1750\");\n    test_width(\"-1000\", 9, \"-00001750\", \"-0o001750\");\n    test_width(\n        \"-1000000000000000\",\n        0,\n        \"-34327724461500000\",\n        \"-0o34327724461500000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        1,\n        \"-34327724461500000\",\n        \"-0o34327724461500000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        20,\n        \"-0034327724461500000\",\n        \"-0o34327724461500000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        22,\n        \"-000034327724461500000\",\n        \"-0o0034327724461500000\",\n    );\n}\n\n#[test]\nfn to_octal_string_properties() {\n    integer_gen().test_properties(|x| {\n        let s = x.to_octal_string();\n        let prefixed_s = if x < 0 {\n            \"-0o\".to_owned() + &s[1..]\n        } else {\n            \"0o\".to_owned() + &s\n        };\n        assert_eq!(format!(\"{x:#o}\"), prefixed_s);\n        assert_eq!(format!(\"{x:00o}\"), s);\n        assert_eq!(format!(\"{x:#00o}\"), prefixed_s);\n        assert_eq!(x.to_string_base(8), s);\n        let num_x = BigInt::from(&x);\n        assert_eq!(num_x.to_octal_string(), s);\n        assert_eq!(format!(\"{num_x:#o}\"), prefixed_s);\n        let rug_x = rug::Integer::from(&x);\n        assert_eq!(rug_x.to_octal_string(), s);\n        assert_eq!(format!(\"{rug_x:#o}\"), prefixed_s);\n        assert!(string_is_subset(&s, \"-01234567\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, width)| {\n        let s = x.to_octal_string();\n        let s_padded = format!(\"{x:0width$o}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$o}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$o}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$o}\");\n        assert_eq!(\n            format!(\"{:#0width$o}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$o}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    signed_gen_var_2::<SignedLimb>().test_properties(|x| {\n        assert_eq!(Integer::from(x).to_octal_string(), x.to_octal_string());\n        assert_eq!(format!(\"{:#o}\", Integer::from(x)), format!(\"{x:#o}\"));\n    });\n\n    signed_unsigned_pair_gen_var_7::<SignedLimb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$o}\", Integer::from(x), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$o}\", Integer::from(x), width = width),\n            format!(\"{x:#0width$o}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_lower_hex_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        assert_eq!(x.to_lower_hex_string(), out);\n        assert_eq!(format!(\"{x:00x}\"), out);\n        assert_eq!(format!(\"{x:#x}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0x0\");\n    test(\"2\", \"2\", \"0x2\");\n    test(\"123\", \"7b\", \"0x7b\");\n    test(\"1000\", \"3e8\", \"0x3e8\");\n    test(\"1000000\", \"f4240\", \"0xf4240\");\n    test(\"1000000000000000\", \"38d7ea4c68000\", \"0x38d7ea4c68000\");\n    test(\"-2\", \"-2\", \"-0x2\");\n    test(\"-123\", \"-7b\", \"-0x7b\");\n    test(\"-1000\", \"-3e8\", \"-0x3e8\");\n    test(\"-1000000\", \"-f4240\", \"-0xf4240\");\n    test(\"-1000000000000000\", \"-38d7ea4c68000\", \"-0x38d7ea4c68000\");\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        let s = x.to_lower_hex_string();\n        assert_eq!(format!(\"{x:0width$x}\"), out);\n        assert_eq!(format!(\"{x:#0width$x}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0x0\");\n    test_width(\"0\", 1, \"0\", \"0x0\");\n    test_width(\"0\", 2, \"00\", \"0x0\");\n    test_width(\"0\", 3, \"000\", \"0x0\");\n    test_width(\"0\", 4, \"0000\", \"0x00\");\n    test_width(\"0\", 5, \"00000\", \"0x000\");\n    test_width(\"1000\", 0, \"3e8\", \"0x3e8\");\n    test_width(\"1000\", 1, \"3e8\", \"0x3e8\");\n    test_width(\"1000\", 3, \"3e8\", \"0x3e8\");\n    test_width(\"1000\", 5, \"003e8\", \"0x3e8\");\n    test_width(\"1000\", 7, \"00003e8\", \"0x003e8\");\n    test_width(\"1000000000000000\", 0, \"38d7ea4c68000\", \"0x38d7ea4c68000\");\n    test_width(\"1000000000000000\", 1, \"38d7ea4c68000\", \"0x38d7ea4c68000\");\n    test_width(\"1000000000000000\", 15, \"0038d7ea4c68000\", \"0x38d7ea4c68000\");\n    test_width(\n        \"1000000000000000\",\n        17,\n        \"000038d7ea4c68000\",\n        \"0x0038d7ea4c68000\",\n    );\n    test_width(\"-1000\", 0, \"-3e8\", \"-0x3e8\");\n    test_width(\"-1000\", 1, \"-3e8\", \"-0x3e8\");\n    test_width(\"-1000\", 3, \"-3e8\", \"-0x3e8\");\n    test_width(\"-1000\", 6, \"-003e8\", \"-0x3e8\");\n    test_width(\"-1000\", 8, \"-00003e8\", \"-0x003e8\");\n    test_width(\"-1000000000000000\", 0, \"-38d7ea4c68000\", \"-0x38d7ea4c68000\");\n    test_width(\"-1000000000000000\", 1, \"-38d7ea4c68000\", \"-0x38d7ea4c68000\");\n    test_width(\n        \"-1000000000000000\",\n        16,\n        \"-0038d7ea4c68000\",\n        \"-0x38d7ea4c68000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        18,\n        \"-000038d7ea4c68000\",\n        \"-0x0038d7ea4c68000\",\n    );\n}\n\n#[test]\npub fn test_to_upper_hex_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        assert_eq!(x.to_upper_hex_string(), out);\n        assert_eq!(format!(\"{x:00X}\"), out);\n        assert_eq!(format!(\"{x:#X}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0x0\");\n    test(\"2\", \"2\", \"0x2\");\n    test(\"123\", \"7B\", \"0x7B\");\n    test(\"1000\", \"3E8\", \"0x3E8\");\n    test(\"1000000\", \"F4240\", \"0xF4240\");\n    test(\"1000000000000000\", \"38D7EA4C68000\", \"0x38D7EA4C68000\");\n    test(\"-2\", \"-2\", \"-0x2\");\n    test(\"-123\", \"-7B\", \"-0x7B\");\n    test(\"-1000\", \"-3E8\", \"-0x3E8\");\n    test(\"-1000000\", \"-F4240\", \"-0xF4240\");\n    test(\"-1000000000000000\", \"-38D7EA4C68000\", \"-0x38D7EA4C68000\");\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Integer::from_str(u).unwrap();\n        let s = x.to_upper_hex_string();\n        assert_eq!(format!(\"{x:0width$X}\"), out);\n        assert_eq!(format!(\"{x:#0width$X}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0x0\");\n    test_width(\"0\", 1, \"0\", \"0x0\");\n    test_width(\"0\", 2, \"00\", \"0x0\");\n    test_width(\"0\", 3, \"000\", \"0x0\");\n    test_width(\"0\", 4, \"0000\", \"0x00\");\n    test_width(\"0\", 5, \"00000\", \"0x000\");\n    test_width(\"1000\", 0, \"3E8\", \"0x3E8\");\n    test_width(\"1000\", 1, \"3E8\", \"0x3E8\");\n    test_width(\"1000\", 3, \"3E8\", \"0x3E8\");\n    test_width(\"1000\", 5, \"003E8\", \"0x3E8\");\n    test_width(\"1000\", 7, \"00003E8\", \"0x003E8\");\n    test_width(\"1000000000000000\", 0, \"38D7EA4C68000\", \"0x38D7EA4C68000\");\n    test_width(\"1000000000000000\", 1, \"38D7EA4C68000\", \"0x38D7EA4C68000\");\n    test_width(\"1000000000000000\", 15, \"0038D7EA4C68000\", \"0x38D7EA4C68000\");\n    test_width(\n        \"1000000000000000\",\n        17,\n        \"000038D7EA4C68000\",\n        \"0x0038D7EA4C68000\",\n    );\n    test_width(\"-1000\", 0, \"-3E8\", \"-0x3E8\");\n    test_width(\"-1000\", 1, \"-3E8\", \"-0x3E8\");\n    test_width(\"-1000\", 3, \"-3E8\", \"-0x3E8\");\n    test_width(\"-1000\", 6, \"-003E8\", \"-0x3E8\");\n    test_width(\"-1000\", 8, \"-00003E8\", \"-0x003E8\");\n    test_width(\"-1000000000000000\", 0, \"-38D7EA4C68000\", \"-0x38D7EA4C68000\");\n    test_width(\"-1000000000000000\", 1, \"-38D7EA4C68000\", \"-0x38D7EA4C68000\");\n    test_width(\n        \"-1000000000000000\",\n        16,\n        \"-0038D7EA4C68000\",\n        \"-0x38D7EA4C68000\",\n    );\n    test_width(\n        \"-1000000000000000\",\n        18,\n        \"-000038D7EA4C68000\",\n        \"-0x0038D7EA4C68000\",\n    );\n}\n\n#[test]\nfn to_hex_string_properties() {\n    integer_gen().test_properties(|x| {\n        let s = x.to_lower_hex_string();\n        let prefixed_s = if x < 0 {\n            \"-0x\".to_owned() + &s[1..]\n        } else {\n            \"0x\".to_owned() + &s\n        };\n        assert_eq!(format!(\"{x:#x}\"), prefixed_s);\n        assert_eq!(x.to_upper_hex_string(), s.to_ascii_uppercase());\n        assert_eq!(\n            format!(\"{x:#X}\"),\n            if x < 0 {\n                \"-0x\".to_owned() + &s[1..].to_ascii_uppercase()\n            } else {\n                \"0x\".to_owned() + &s.to_ascii_uppercase()\n            }\n        );\n        assert_eq!(format!(\"{x:00x}\"), s);\n        assert_eq!(format!(\"{x:#00x}\"), prefixed_s);\n        assert_eq!(format!(\"{x:00X}\"), s.to_ascii_uppercase());\n        assert_eq!(\n            format!(\"{x:#00X}\"),\n            if x < 0 {\n                \"-0x\".to_owned() + &s[1..].to_ascii_uppercase()\n            } else {\n                \"0x\".to_owned() + &s.to_ascii_uppercase()\n            }\n        );\n        assert_eq!(x.to_string_base(16), s);\n        let num_x = BigInt::from(&x);\n        assert_eq!(num_x.to_lower_hex_string(), s);\n        assert_eq!(format!(\"{num_x:#x}\"), prefixed_s);\n        let rug_x = rug::Integer::from(&x);\n        assert_eq!(rug_x.to_lower_hex_string(), s);\n        assert_eq!(format!(\"{rug_x:#x}\"), prefixed_s);\n        assert!(string_is_subset(&s, \"-0123456789abcdef\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, width)| {\n        let s = x.to_lower_hex_string();\n        let s_padded = format!(\"{x:0width$x}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$x}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$x}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$x}\");\n        assert_eq!(\n            format!(\"{:#0width$x}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$x}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s = x.to_upper_hex_string();\n        let s_padded_upper = format!(\"{x:0width$X}\");\n        assert_eq!(s_padded_upper, format!(\"{x:0width$x}\").to_ascii_uppercase());\n        let s_padded = s_padded_upper;\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$X}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$X}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$X}\");\n        assert_eq!(\n            format!(\"{:#0width$X}\", BigInt::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$X}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    signed_gen_var_2::<SignedLimb>().test_properties(|x| {\n        assert_eq!(\n            Integer::from(x).to_lower_hex_string(),\n            x.to_lower_hex_string()\n        );\n        assert_eq!(\n            Integer::from(x).to_upper_hex_string(),\n            x.to_upper_hex_string()\n        );\n        assert_eq!(format!(\"{:#x}\", Integer::from(x)), format!(\"{x:#x}\"));\n        assert_eq!(format!(\"{:#X}\", Integer::from(x)), format!(\"{x:#X}\"));\n    });\n\n    signed_unsigned_pair_gen_var_7::<SignedLimb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$x}\", Integer::from(x), width = width),\n            format!(\"{x:0width$x}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$X}\", Integer::from(x), width = width),\n            format!(\"{x:0width$X}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$x}\", Integer::from(x), width = width),\n            format!(\"{x:#0width$x}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$X}\", Integer::from(x), width = width),\n            format!(\"{x:#0width$X}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_string_base() {\n    fn test(u: &str, base: u8, out: &str) {\n        let x = Integer::from_str(u).unwrap();\n        assert_eq!(x.to_string_base(base), out);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(&x, base)), out);\n    }\n    test(\"0\", 2, \"0\");\n    test(\"0\", 3, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"0\", 16, \"0\");\n    test(\"0\", 17, \"0\");\n    test(\"2\", 3, \"2\");\n    test(\"2\", 10, \"2\");\n    test(\"2\", 16, \"2\");\n    test(\"2\", 17, \"2\");\n    test(\"123\", 8, \"173\");\n    test(\"1000000\", 10, \"1000000\");\n    test(\"1000000\", 20, \"65000\");\n    test(\"1000000\", 36, \"lfls\");\n    test(\"1000\", 2, \"1111101000\");\n    test(\"1000\", 3, \"1101001\");\n    test(\"1000\", 4, \"33220\");\n    test(\"1000\", 10, \"1000\");\n    test(\"1000\", 20, \"2a0\");\n    test(\"1000\", 36, \"rs\");\n    test(\n        \"1000000000000000\",\n        2,\n        \"11100011010111111010100100110001101000000000000000\",\n    );\n    test(\"1000000000000000\", 3, \"11212010201001210101011021212001\");\n    test(\"1000000000000000\", 4, \"3203113322210301220000000\");\n    test(\"1000000000000000\", 10, \"1000000000000000\");\n    test(\"1000000000000000\", 20, \"4hd2a0000000\");\n    test(\"1000000000000000\", 36, \"9ugxnorjls\");\n    test(\"-2\", 3, \"-2\");\n    test(\"-2\", 10, \"-2\");\n    test(\"-2\", 16, \"-2\");\n    test(\"-2\", 17, \"-2\");\n    test(\"-123\", 8, \"-173\");\n    test(\"-1000000\", 10, \"-1000000\");\n    test(\"-1000000\", 20, \"-65000\");\n    test(\"-1000000\", 36, \"-lfls\");\n    test(\"-1000\", 2, \"-1111101000\");\n    test(\"-1000\", 3, \"-1101001\");\n    test(\"-1000\", 4, \"-33220\");\n    test(\"-1000\", 10, \"-1000\");\n    test(\"-1000\", 20, \"-2a0\");\n    test(\"-1000\", 36, \"-rs\");\n    test(\n        \"-1000000000000000\",\n        2,\n        \"-11100011010111111010100100110001101000000000000000\",\n    );\n    test(\"-1000000000000000\", 3, \"-11212010201001210101011021212001\");\n    test(\"-1000000000000000\", 4, \"-3203113322210301220000000\");\n    test(\"-1000000000000000\", 10, \"-1000000000000000\");\n    test(\"-1000000000000000\", 20, \"-4hd2a0000000\");\n    test(\"-1000000000000000\", 36, \"-9ugxnorjls\");\n\n    fn test_width(u: &str, base: u8, width: usize, out: &str) {\n        let x = Integer::from_str(u).unwrap();\n        let s = x.to_string_base(base);\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:0width$?}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 2, 0, \"0\");\n    test_width(\"0\", 2, 1, \"0\");\n    test_width(\"0\", 2, 2, \"00\");\n    test_width(\"0\", 2, 5, \"00000\");\n    test_width(\"1000000\", 36, 0, \"lfls\");\n    test_width(\"1000000\", 36, 1, \"lfls\");\n    test_width(\"1000000\", 36, 2, \"lfls\");\n    test_width(\"1000000\", 36, 3, \"lfls\");\n    test_width(\"1000000\", 36, 4, \"lfls\");\n    test_width(\"1000000\", 36, 5, \"0lfls\");\n    test_width(\"1000000\", 36, 6, \"00lfls\");\n    test_width(\"1000000000000000\", 36, 0, \"9ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 1, \"9ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 10, \"9ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 11, \"09ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 20, \"00000000009ugxnorjls\");\n    test_width(\"-1000000\", 36, 0, \"-lfls\");\n    test_width(\"-1000000\", 36, 1, \"-lfls\");\n    test_width(\"-1000000\", 36, 2, \"-lfls\");\n    test_width(\"-1000000\", 36, 3, \"-lfls\");\n    test_width(\"-1000000\", 36, 4, \"-lfls\");\n    test_width(\"-1000000\", 36, 5, \"-lfls\");\n    test_width(\"-1000000\", 36, 6, \"-0lfls\");\n    test_width(\"-1000000\", 36, 7, \"-00lfls\");\n    test_width(\"-1000000000000000\", 36, 0, \"-9ugxnorjls\");\n    test_width(\"-1000000000000000\", 36, 1, \"-9ugxnorjls\");\n    test_width(\"-1000000000000000\", 36, 10, \"-9ugxnorjls\");\n    test_width(\"-1000000000000000\", 36, 11, \"-9ugxnorjls\");\n    test_width(\"-1000000000000000\", 36, 12, \"-09ugxnorjls\");\n    test_width(\"-1000000000000000\", 36, 21, \"-00000000009ugxnorjls\");\n}\n\n#[test]\nfn to_string_base_fail() {\n    assert_panic!(Integer::from(10).to_string_base(0));\n    assert_panic!(Integer::from(10).to_string_base(1));\n    assert_panic!(Integer::from(10).to_string_base(37));\n    assert_panic!(Integer::from(10).to_string_base(100));\n    assert_panic!(format!(\"{}\", BaseFmtWrapper::new(&Integer::from(10), 0)));\n    assert_panic!(format!(\"{}\", BaseFmtWrapper::new(&Integer::from(10), 1)));\n    assert_panic!(format!(\"{}\", BaseFmtWrapper::new(&Integer::from(10), 37)));\n    assert_panic!(format!(\"{}\", BaseFmtWrapper::new(&Integer::from(10), 100)));\n}\n\n#[test]\nfn to_string_base_properties() {\n    integer_unsigned_pair_gen_var_1().test_properties(|(x, base)| {\n        let s = x.to_string_base(base);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(x.to_string_base_upper(base), s.to_uppercase());\n        assert_eq!(Integer::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s,\n            \"-0123456789abcdefghijklmnopqrstuvwxyz\"\n        ));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(x.to_string_base(10), x.to_string());\n        assert_eq!(x.to_string_base(2), x.to_binary_string());\n        assert_eq!(x.to_string_base(8), x.to_octal_string());\n        assert_eq!(x.to_string_base(16), x.to_lower_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(Integer::ZERO.to_string_base(base), \"0\");\n        assert_eq!(Integer::ONE.to_string_base(base), \"1\");\n        assert_eq!(Integer::NEGATIVE_ONE.to_string_base(base), \"-1\");\n        assert_eq!(Integer::from(base).to_string_base(base), \"10\");\n    });\n\n    integer_unsigned_unsigned_triple_gen_var_1().test_properties(|(x, base, width)| {\n        let fx = BaseFmtWrapper::new(&x, base);\n        let s = x.to_string_base(base);\n        let s_padded = format!(\"{fx:0width$}\");\n        assert_eq!(format!(\"{fx:0width$?}\"), s_padded);\n        assert_eq!(Integer::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s_padded,\n            \"-0123456789abcdefghijklmnopqrstuvwxyz\"\n        ));\n        test_padding(&s, &s_padded, width);\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 16), width = width),\n            format!(\"{x:0width$x}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:0width$}\",\n            BaseFmtWrapper::new(&Integer::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n\n    signed_unsigned_unsigned_triple_gen_var_3::<SignedLimb, u8, usize>().test_properties(\n        |(x, base, width)| {\n            assert_eq!(\n                format!(\n                    \"{:0width$}\",\n                    BaseFmtWrapper::new(&Integer::from(x), base),\n                    width = width\n                ),\n                format!(\n                    \"{:0width$}\",\n                    BaseBaseFmtWrapper::new(x, base),\n                    width = width\n                ),\n            );\n        },\n    );\n}\n\n#[test]\npub fn test_to_string_base_upper() {\n    fn test(u: &str, base: u8, out: &str) {\n        let x = Integer::from_str(u).unwrap();\n        assert_eq!(x.to_string_base_upper(base), out);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:#00}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:#00?}\", BaseFmtWrapper::new(&x, base)), out);\n    }\n    test(\"0\", 2, \"0\");\n    test(\"0\", 3, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"0\", 16, \"0\");\n    test(\"0\", 17, \"0\");\n    test(\"2\", 3, \"2\");\n    test(\"2\", 10, \"2\");\n    test(\"2\", 16, \"2\");\n    test(\"2\", 17, \"2\");\n    test(\"123\", 8, \"173\");\n    test(\"1000000\", 10, \"1000000\");\n    test(\"1000000\", 20, \"65000\");\n    test(\"1000000\", 36, \"LFLS\");\n    test(\"1000\", 2, \"1111101000\");\n    test(\"1000\", 3, \"1101001\");\n    test(\"1000\", 4, \"33220\");\n    test(\"1000\", 10, \"1000\");\n    test(\"1000\", 20, \"2A0\");\n    test(\"1000\", 36, \"RS\");\n    test(\n        \"1000000000000000\",\n        2,\n        \"11100011010111111010100100110001101000000000000000\",\n    );\n    test(\"1000000000000000\", 3, \"11212010201001210101011021212001\");\n    test(\"1000000000000000\", 4, \"3203113322210301220000000\");\n    test(\"1000000000000000\", 10, \"1000000000000000\");\n    test(\"1000000000000000\", 20, \"4HD2A0000000\");\n    test(\"1000000000000000\", 36, \"9UGXNORJLS\");\n    test(\"-2\", 3, \"-2\");\n    test(\"-2\", 10, \"-2\");\n    test(\"-2\", 16, \"-2\");\n    test(\"-2\", 17, \"-2\");\n    test(\"-123\", 8, \"-173\");\n    test(\"-1000000\", 10, \"-1000000\");\n    test(\"-1000000\", 20, \"-65000\");\n    test(\"-1000000\", 36, \"-LFLS\");\n    test(\"-1000\", 2, \"-1111101000\");\n    test(\"-1000\", 3, \"-1101001\");\n    test(\"-1000\", 4, \"-33220\");\n    test(\"-1000\", 10, \"-1000\");\n    test(\"-1000\", 20, \"-2A0\");\n    test(\"-1000\", 36, \"-RS\");\n    test(\n        \"-1000000000000000\",\n        2,\n        \"-11100011010111111010100100110001101000000000000000\",\n    );\n    test(\"-1000000000000000\", 3, \"-11212010201001210101011021212001\");\n    test(\"-1000000000000000\", 4, \"-3203113322210301220000000\");\n    test(\"-1000000000000000\", 10, \"-1000000000000000\");\n    test(\"-1000000000000000\", 20, \"-4HD2A0000000\");\n    test(\"-1000000000000000\", 36, \"-9UGXNORJLS\");\n\n    fn test_width(u: &str, base: u8, width: usize, out: &str) {\n        let x = Integer::from_str(u).unwrap();\n        let s = x.to_string_base_upper(base);\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:#0width$?}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 2, 0, \"0\");\n    test_width(\"0\", 2, 1, \"0\");\n    test_width(\"0\", 2, 2, \"00\");\n    test_width(\"0\", 2, 5, \"00000\");\n    test_width(\"1000000\", 36, 0, \"LFLS\");\n    test_width(\"1000000\", 36, 1, \"LFLS\");\n    test_width(\"1000000\", 36, 2, \"LFLS\");\n    test_width(\"1000000\", 36, 3, \"LFLS\");\n    test_width(\"1000000\", 36, 4, \"LFLS\");\n    test_width(\"1000000\", 36, 5, \"0LFLS\");\n    test_width(\"1000000\", 36, 6, \"00LFLS\");\n    test_width(\"1000000000000000\", 36, 0, \"9UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 1, \"9UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 10, \"9UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 11, \"09UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 20, \"00000000009UGXNORJLS\");\n    test_width(\"-1000000\", 36, 0, \"-LFLS\");\n    test_width(\"-1000000\", 36, 1, \"-LFLS\");\n    test_width(\"-1000000\", 36, 2, \"-LFLS\");\n    test_width(\"-1000000\", 36, 3, \"-LFLS\");\n    test_width(\"-1000000\", 36, 4, \"-LFLS\");\n    test_width(\"-1000000\", 36, 5, \"-LFLS\");\n    test_width(\"-1000000\", 36, 6, \"-0LFLS\");\n    test_width(\"-1000000\", 36, 7, \"-00LFLS\");\n    test_width(\"-1000000000000000\", 36, 0, \"-9UGXNORJLS\");\n    test_width(\"-1000000000000000\", 36, 1, \"-9UGXNORJLS\");\n    test_width(\"-1000000000000000\", 36, 10, \"-9UGXNORJLS\");\n    test_width(\"-1000000000000000\", 36, 11, \"-9UGXNORJLS\");\n    test_width(\"-1000000000000000\", 36, 12, \"-09UGXNORJLS\");\n    test_width(\"-1000000000000000\", 36, 21, \"-00000000009UGXNORJLS\");\n}\n\n#[test]\nfn to_string_base_upper_fail() {\n    assert_panic!(Integer::from(10).to_string_base_upper(0));\n    assert_panic!(Integer::from(10).to_string_base_upper(1));\n    assert_panic!(Integer::from(10).to_string_base_upper(37));\n    assert_panic!(Integer::from(10).to_string_base_upper(100));\n    assert_panic!(format!(\"{:#}\", BaseFmtWrapper::new(&Integer::from(10), 0)));\n    assert_panic!(format!(\"{:#}\", BaseFmtWrapper::new(&Integer::from(10), 1)));\n    assert_panic!(format!(\"{:#}\", BaseFmtWrapper::new(&Integer::from(10), 37)));\n    assert_panic!(format!(\n        \"{:#}\",\n        BaseFmtWrapper::new(&Integer::from(10), 100)\n    ));\n}\n\n#[test]\nfn to_string_base_upper_properties() {\n    integer_unsigned_pair_gen_var_1().test_properties(|(x, base)| {\n        let s = x.to_string_base_upper(base);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:#00}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(x.to_string_base(base), s.to_lowercase());\n        assert_eq!(Integer::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s,\n            \"-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n        ));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(x.to_string_base_upper(10), x.to_string());\n        assert_eq!(x.to_string_base_upper(2), x.to_binary_string());\n        assert_eq!(x.to_string_base_upper(8), x.to_octal_string());\n        assert_eq!(x.to_string_base_upper(16), x.to_upper_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(Integer::ZERO.to_string_base_upper(base), \"0\");\n        assert_eq!(Integer::ONE.to_string_base_upper(base), \"1\");\n        assert_eq!(Integer::NEGATIVE_ONE.to_string_base_upper(base), \"-1\");\n        assert_eq!(Integer::from(base).to_string_base_upper(base), \"10\");\n    });\n\n    integer_unsigned_unsigned_triple_gen_var_1().test_properties(|(x, base, width)| {\n        let fx = BaseFmtWrapper::new(&x, base);\n        let s = x.to_string_base_upper(base);\n        let s_padded = format!(\"{fx:#0width$}\");\n        assert_eq!(format!(\"{fx:#0width$?}\"), s_padded);\n        assert_eq!(Integer::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s_padded,\n            \"-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n        ));\n        test_padding(&s, &s_padded, width);\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 16), width = width),\n            format!(\"{x:0width$X}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:#0width$}\",\n            BaseFmtWrapper::new(&Integer::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n\n    signed_unsigned_unsigned_triple_gen_var_3::<SignedLimb, u8, usize>().test_properties(\n        |(x, base, width)| {\n            assert_eq!(\n                format!(\n                    \"{:#0width$}\",\n                    BaseFmtWrapper::new(&Integer::from(x), base),\n                    width = width\n                ),\n                format!(\n                    \"{:#0width$}\",\n                    BaseBaseFmtWrapper::new(x, base),\n                    width = width\n                ),\n            );\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/conversion/to_twos_complement_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_gen, unsigned_gen_var_5, unsigned_vec_gen, unsigned_vec_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::conversion::to_twos_complement_limbs::*;\nuse malachite_nz::natural::{LIMB_HIGH_BIT, Natural};\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_bool_vec_pair_gen_var_1, integer_gen, integer_unsigned_pair_gen_var_2,\n};\nuse malachite_nz::test_util::integer::conversion::to_twos_complement_limbs::{\n    limbs_twos_complement_in_place_alt_1, limbs_twos_complement_in_place_alt_2,\n};\nuse std::cmp::Ordering::*;\n#[cfg(feature = \"32_bit_limbs\")]\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_twos_complement() {\n    let test = |xs: &[Limb], out: &[Limb]| {\n        assert_eq!(limbs_twos_complement(xs), out);\n    };\n    test(&[1, 2, 3], &[u32::MAX, 0xfffffffd, 0xfffffffc]);\n    test(&[u32::MAX, 0xfffffffd, 0xfffffffc], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_maybe_sign_extend_non_negative_in_place() {\n    let test = |xs: &[Limb], out: &[Limb]| {\n        let mut mut_xs = xs.to_vec();\n        limbs_maybe_sign_extend_non_negative_in_place(&mut mut_xs);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[], &[]);\n    test(&[1, 2, 3], &[1, 2, 3]);\n    test(&[1, 2, u32::MAX], &[1, 2, u32::MAX, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_twos_complement_in_place() {\n    let test = |xs: &[Limb], out: &[Limb], carry: bool| {\n        let mut mut_xs = xs.to_vec();\n        assert_eq!(limbs_twos_complement_in_place(&mut mut_xs), carry);\n        assert_eq!(mut_xs, out);\n\n        let mut mut_xs = xs.to_vec();\n        assert_eq!(limbs_twos_complement_in_place_alt_1(&mut mut_xs), carry);\n        assert_eq!(mut_xs, out);\n\n        let mut mut_xs = xs.to_vec();\n        assert_eq!(limbs_twos_complement_in_place_alt_2(&mut mut_xs), carry);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[], &[], true);\n    test(&[1, 2, 3], &[u32::MAX, 0xfffffffd, 0xfffffffc], false);\n    test(&[u32::MAX, 0xfffffffd, 0xfffffffc], &[1, 2, 3], false);\n    test(&[0, 0, 0], &[0, 0, 0], true);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_twos_complement_and_maybe_sign_extend_negative_in_place() {\n    let test = |xs: &[Limb], out: &[Limb]| {\n        let mut mut_xs = xs.to_vec();\n        limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut mut_xs);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[1, 2, 3], &[u32::MAX, 0xfffffffd, 0xfffffffc]);\n    test(&[u32::MAX, 0xfffffffd, 0xfffffffc], &[1, 2, 3, u32::MAX]);\n    test(&[0, u32::MAX], &[0, 1, u32::MAX]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_twos_complement_and_maybe_sign_extend_negative_in_place_fail() {\n    let mut mut_xs = vec![0, 0, 0];\n    limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut mut_xs);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_twos_complement_limbs_asc() {\n    let test = |s, out: &[Limb]| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u.twos_complement_limbs().collect_vec(), out);\n        assert_eq!(u.to_twos_complement_limbs_asc(), out);\n        assert_eq!(u.into_twos_complement_limbs_asc(), out);\n    };\n    test(\"0\", &[]);\n    test(\"123\", &[123]);\n    test(\"-123\", &[4294967173]);\n    test(\"1000000000000\", &[3567587328, 232]);\n    test(\"-1000000000000\", &[727379968, 4294967063]);\n    test(\"1701411834921604967429270619762735448065\", &[1, 2, 3, 4, 5]);\n    test(\n        \"-1701411834921604967429270619762735448065\",\n        &[u32::MAX, u32::MAX - 2, u32::MAX - 3, u32::MAX - 4, u32::MAX - 5],\n    );\n    test(\"2147483647\", &[2147483647]);\n    test(\"-2147483647\", &[2147483649]);\n    test(\"2147483648\", &[2147483648, 0]);\n    test(\"-2147483648\", &[2147483648]);\n    test(\"2147483649\", &[2147483649, 0]);\n    test(\"-2147483649\", &[2147483647, 4294967295]);\n    test(\"4294967294\", &[u32::MAX - 1, 0]);\n    test(\"-4294967294\", &[2, u32::MAX]);\n    test(\"4294967295\", &[u32::MAX, 0]);\n    test(\"-4294967295\", &[1, u32::MAX]);\n    test(\"4294967296\", &[0, 1]);\n    test(\"-4294967296\", &[0, u32::MAX]);\n    test(\"18446744073709551615\", &[u32::MAX, u32::MAX, 0]);\n    test(\"-18446744073709551615\", &[1, 0, u32::MAX]);\n    test(\"18446744073709551616\", &[0, 0, 1]);\n    test(\"-18446744073709551616\", &[0, 0, u32::MAX]);\n\n    let n = Integer::from_str(\"-1701411834921604967429270619762735448065\").unwrap();\n    let mut limbs = n.twos_complement_limbs();\n    assert_eq!(Some(u32::MAX), limbs.next());\n    assert_eq!(Some(u32::MAX - 5), limbs.next_back());\n    assert_eq!(Some(u32::MAX - 4), limbs.next_back());\n    assert_eq!(Some(u32::MAX - 2), limbs.next());\n    assert_eq!(Some(u32::MAX - 3), limbs.next());\n    assert_eq!(None, limbs.next());\n    assert_eq!(None, limbs.next_back());\n\n    let limbs = n.twos_complement_limbs();\n    assert_eq!(limbs.get_limb(0), u32::MAX);\n    assert_eq!(limbs.get_limb(1), u32::MAX - 2);\n    assert_eq!(limbs.get_limb(2), u32::MAX - 3);\n    assert_eq!(limbs.get_limb(3), u32::MAX - 4);\n    assert_eq!(limbs.get_limb(4), u32::MAX - 5);\n    assert_eq!(limbs.get_limb(5), u32::MAX);\n\n    let mut limbs = n.twos_complement_limbs();\n    assert_eq!(Some(u32::MAX), limbs.next());\n    assert_eq!(Some(u32::MAX - 2), limbs.next());\n    assert_eq!(Some(u32::MAX - 3), limbs.next());\n    assert_eq!(Some(u32::MAX - 5), limbs.next_back());\n    assert_eq!(Some(u32::MAX - 4), limbs.next_back());\n    assert_eq!(None, limbs.next());\n    assert_eq!(None, limbs.next_back());\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_twos_complement_limbs_desc() {\n    let test = |s, out: &[Limb]| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u.to_twos_complement_limbs_desc(), out);\n        assert_eq!(u.into_twos_complement_limbs_desc(), out);\n    };\n    test(\"0\", &[]);\n    test(\"123\", &[123]);\n    test(\"-123\", &[4294967173]);\n    test(\"1000000000000\", &[232, 3567587328]);\n    test(\"-1000000000000\", &[4294967063, 727379968]);\n    test(\"1701411834921604967429270619762735448065\", &[5, 4, 3, 2, 1]);\n    test(\n        \"-1701411834921604967429270619762735448065\",\n        &[u32::MAX - 5, u32::MAX - 4, u32::MAX - 3, u32::MAX - 2, u32::MAX],\n    );\n    test(\"4294967295\", &[0, u32::MAX]);\n    test(\"-4294967295\", &[u32::MAX, 1]);\n    test(\"4294967296\", &[1, 0]);\n    test(\"-4294967296\", &[u32::MAX, 0]);\n    test(\"18446744073709551615\", &[0, u32::MAX, u32::MAX]);\n    test(\"-18446744073709551615\", &[u32::MAX, 0, 1]);\n    test(\"18446744073709551616\", &[1, 0, 0]);\n    test(\"-18446744073709551616\", &[u32::MAX, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_twos_complement_limb_count() {\n    let test = |n, out| {\n        assert_eq!(\n            Integer::from_str(n).unwrap().twos_complement_limb_count(),\n            out\n        );\n    };\n    test(\"0\", 0);\n    test(\"123\", 1);\n    test(\"-123\", 1);\n    test(\"1000000000000\", 2);\n    test(\"-1000000000000\", 2);\n    test(\"1701411834921604967429270619762735448065\", 5);\n    test(\"-1701411834921604967429270619762735448065\", 5);\n    test(\"2147483647\", 1);\n    test(\"-2147483647\", 1);\n    test(\"2147483648\", 2);\n    test(\"-2147483648\", 1);\n    test(\"2147483649\", 2);\n    test(\"-2147483649\", 2);\n    test(\"4294967294\", 2);\n    test(\"-4294967294\", 2);\n    test(\"4294967295\", 2);\n    test(\"-4294967295\", 2);\n    test(\"4294967296\", 2);\n    test(\"-4294967296\", 2);\n    test(\"18446744073709551615\", 3);\n    test(\"-18446744073709551615\", 3);\n    test(\"18446744073709551616\", 3);\n    test(\"-18446744073709551616\", 3);\n}\n\n#[test]\nfn limbs_twos_complement_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_2().test_properties_with_config(&config, |xs| {\n        let out_xs = limbs_twos_complement(&xs);\n        if *xs.last().unwrap() != 0 && out_xs.last().unwrap().get_highest_bit() {\n            let n = -Natural::from_limbs_asc(&xs);\n            assert_eq!(n.to_twos_complement_limbs_asc(), out_xs);\n        }\n    });\n}\n\n#[test]\nfn limbs_maybe_sign_extend_non_negative_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        let mut mut_xs = xs.clone();\n        limbs_maybe_sign_extend_non_negative_in_place(&mut mut_xs);\n        if !xs.is_empty() && *xs.last().unwrap() != 0 {\n            let n = Integer::from(Natural::from_owned_limbs_asc(xs));\n            assert_eq!(n.to_twos_complement_limbs_asc(), mut_xs);\n        }\n    });\n}\n\n#[test]\nfn limbs_twos_complement_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        let mut mut_xs = xs.clone();\n        limbs_twos_complement_in_place(&mut mut_xs);\n        let mut mut_xs_alt = xs.clone();\n        limbs_twos_complement_in_place_alt_1(&mut mut_xs_alt);\n        assert_eq!(mut_xs_alt, mut_xs);\n        let mut mut_xs_alt = xs.clone();\n        limbs_twos_complement_in_place_alt_2(&mut mut_xs_alt);\n        assert_eq!(mut_xs_alt, mut_xs);\n        if !xs.is_empty() && *xs.last().unwrap() != 0 && mut_xs.last().unwrap().get_highest_bit() {\n            let n = -Natural::from_owned_limbs_asc(xs);\n            assert_eq!(n.to_twos_complement_limbs_asc(), mut_xs);\n        }\n    });\n}\n\n#[test]\nfn limbs_twos_complement_and_maybe_sign_extend_negative_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_2().test_properties_with_config(&config, |xs| {\n        let mut mut_xs = xs.clone();\n        limbs_twos_complement_and_maybe_sign_extend_negative_in_place(&mut mut_xs);\n        if !xs.is_empty() && *xs.last().unwrap() != 0 {\n            let n = -Natural::from_owned_limbs_asc(xs);\n            assert_eq!(n.to_twos_complement_limbs_asc(), mut_xs);\n        }\n    });\n}\n\n#[test]\nfn to_twos_complement_limbs_asc_properties() {\n    integer_gen().test_properties(|x| {\n        let xs = x.to_twos_complement_limbs_asc();\n        assert_eq!(xs.len(), usize::exact_from(x.twos_complement_limb_count()));\n        assert_eq!(x.clone().into_twos_complement_limbs_asc(), xs);\n        assert_eq!(x.twos_complement_limbs().collect_vec(), xs);\n        assert_eq!(Integer::from_twos_complement_limbs_asc(&xs), x);\n        assert_eq!(\n            x.to_twos_complement_limbs_desc(),\n            xs.iter().copied().rev().collect_vec()\n        );\n        match x.sign() {\n            Equal => assert!(xs.is_empty()),\n            Greater => {\n                let last = *xs.last().unwrap();\n                assert!(!last.get_highest_bit());\n                if last == 0 {\n                    assert!(xs[xs.len() - 2].get_highest_bit());\n                }\n            }\n            Less => {\n                let last = *xs.last().unwrap();\n                assert!(last.get_highest_bit());\n                if last == !0 && xs.len() > 1 {\n                    assert!(!xs[xs.len() - 2].get_highest_bit());\n                }\n            }\n        }\n    });\n}\n\n#[test]\nfn to_twos_complement_limbs_desc_properties() {\n    integer_gen().test_properties(|x| {\n        let xs = x.to_twos_complement_limbs_desc();\n        assert_eq!(xs.len(), usize::exact_from(x.twos_complement_limb_count()));\n        assert_eq!(x.clone().into_twos_complement_limbs_desc(), xs);\n        assert_eq!(x.twos_complement_limbs().rev().collect_vec(), xs);\n        assert_eq!(Integer::from_twos_complement_limbs_desc(&xs), x);\n        assert_eq!(\n            x.to_twos_complement_limbs_asc(),\n            xs.iter().copied().rev().collect_vec()\n        );\n        match x.sign() {\n            Equal => assert!(xs.is_empty()),\n            Greater => {\n                let first = xs[0];\n                assert!(!first.get_highest_bit());\n                if first == 0 {\n                    assert!(xs[1].get_highest_bit());\n                }\n            }\n            Less => {\n                let first = xs[0];\n                assert!(first.get_highest_bit());\n                if first == !0 && xs.len() > 1 {\n                    assert!(!xs[1].get_highest_bit());\n                }\n            }\n        }\n    });\n}\n\n#[test]\nfn twos_complement_limbs_properties() {\n    integer_bool_vec_pair_gen_var_1().test_properties(|(n, bs)| {\n        let mut limbs = n.twos_complement_limbs();\n        let mut xs = Vec::new();\n        let mut i = 0;\n        for b in bs {\n            if b {\n                xs.insert(i, limbs.next().unwrap());\n                i += 1;\n            } else {\n                xs.insert(i, limbs.next_back().unwrap());\n            }\n        }\n        assert!(limbs.next().is_none());\n        assert!(limbs.next_back().is_none());\n        assert_eq!(n.to_twos_complement_limbs_asc(), xs);\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, u)| {\n        if u < n.unsigned_abs_ref().limb_count() {\n            assert_eq!(\n                n.twos_complement_limbs().get_limb(u),\n                n.to_twos_complement_limbs_asc()[usize::exact_from(u)]\n            );\n        } else {\n            assert_eq!(\n                n.twos_complement_limbs().get_limb(u),\n                if n >= 0 { 0 } else { Limb::MAX }\n            );\n        }\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(Integer::ZERO.twos_complement_limbs().get_limb(u), 0);\n    });\n}\n\n#[test]\nfn twos_complement_limb_count_properties() {\n    integer_gen().test_properties(|x| {\n        let n = x.twos_complement_limb_count();\n        assert_eq!(\n            (x >= 0 && x < LIMB_HIGH_BIT) || (x < 0 && x >= -Integer::from(LIMB_HIGH_BIT)),\n            n <= 1\n        );\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert!(Integer::from(i).twos_complement_limb_count() <= 1);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_integer_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::exhaustive_integer_inclusive_range;\n\nfn expected_range_len(a: &Integer, b: &Integer) -> usize {\n    match (*a >= 0, *b >= 0) {\n        (false, false) => usize::exact_from(&-a) - usize::exact_from(&-b) + 1,\n        (false, true) => usize::exact_from(&-a) + usize::exact_from(b) + 1,\n        (true, false) => panic!(),\n        (true, true) => usize::exact_from(b) - usize::exact_from(a) + 1,\n    }\n}\n\nfn exhaustive_integer_inclusive_range_helper(a: &Integer, b: &Integer, values: &str) {\n    let xs = exhaustive_integer_inclusive_range(a.clone(), b.clone())\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n    assert_eq!(\n        exhaustive_integer_inclusive_range(a.clone(), b.clone()).count(),\n        expected_range_len(a, b)\n    );\n}\n\nfn exhaustive_integer_inclusive_range_rev_helper(a: Integer, b: Integer, rev_values: &str) {\n    let len = expected_range_len(&a, &b);\n    assert_eq!(\n        exhaustive_integer_inclusive_range(a.clone(), b.clone()).count(),\n        len\n    );\n    let mut tail = exhaustive_integer_inclusive_range(a, b)\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    tail.reverse();\n    assert_eq!(tail.to_debug_string(), rev_values);\n}\n\n#[test]\nfn test_exhaustive_integer_inclusive_range() {\n    exhaustive_integer_inclusive_range_helper(&Integer::ZERO, &Integer::ZERO, \"[0]\");\n    exhaustive_integer_inclusive_range_helper(&Integer::ZERO, &Integer::ONE, \"[0, 1]\");\n    exhaustive_integer_inclusive_range_helper(\n        &Integer::ZERO,\n        &Integer::from(10),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\",\n    );\n    exhaustive_integer_inclusive_range_helper(\n        &Integer::from(10),\n        &Integer::from(20),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\",\n    );\n    exhaustive_integer_inclusive_range_helper(\n        &Integer::from(-20),\n        &Integer::from(-10),\n        \"[-10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]\",\n    );\n    exhaustive_integer_inclusive_range_helper(\n        &Integer::from(-100),\n        &Integer::from(100),\n        \"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]\",\n    );\n\n    exhaustive_integer_inclusive_range_rev_helper(\n        Integer::from(-20),\n        Integer::from(-10),\n        \"[-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10]\",\n    );\n    exhaustive_integer_inclusive_range_rev_helper(\n        Integer::from(-100),\n        Integer::from(100),\n        \"[-100, 100, -99, 99, -98, 98, -97, 97, -96, 96, -95, 95, -94, 94, -93, 93, -92, 92, -91, \\\n        91]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_integer_inclusive_range_fail() {\n    exhaustive_integer_inclusive_range(Integer::ONE, Integer::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_integer_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::exhaustive_integer_range;\n\nfn expected_range_len(a: &Integer, b: &Integer) -> usize {\n    match (*a >= 0, *b >= 0) {\n        (false, false) => usize::exact_from(&-a) - usize::exact_from(&-b),\n        (false, true) => usize::exact_from(&-a) + usize::exact_from(b),\n        (true, false) => panic!(),\n        (true, true) => usize::exact_from(b) - usize::exact_from(a),\n    }\n}\n\nfn exhaustive_integer_range_helper(a: &Integer, b: &Integer, values: &str) {\n    let xs = exhaustive_integer_range(a.clone(), b.clone())\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n    assert_eq!(\n        exhaustive_integer_range(a.clone(), b.clone()).count(),\n        expected_range_len(a, b)\n    );\n}\n\nfn exhaustive_integer_range_rev_helper(a: Integer, b: Integer, rev_values: &str) {\n    let len = expected_range_len(&a, &b);\n    assert_eq!(exhaustive_integer_range(a.clone(), b.clone()).count(), len);\n    let mut tail = exhaustive_integer_range(a, b)\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    tail.reverse();\n    assert_eq!(tail.to_debug_string(), rev_values);\n}\n\n#[test]\nfn test_exhaustive_integer_range() {\n    exhaustive_integer_range_helper(&Integer::ZERO, &Integer::ZERO, \"[]\");\n    exhaustive_integer_range_helper(&Integer::ZERO, &Integer::ONE, \"[0]\");\n    exhaustive_integer_range_helper(\n        &Integer::ZERO,\n        &Integer::from(10),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\",\n    );\n    exhaustive_integer_range_helper(\n        &Integer::from(10),\n        &Integer::from(20),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\",\n    );\n    exhaustive_integer_range_helper(\n        &Integer::from(-20),\n        &Integer::from(-10),\n        \"[-11, -12, -13, -14, -15, -16, -17, -18, -19, -20]\",\n    );\n    exhaustive_integer_range_helper(\n        &Integer::from(-100),\n        &Integer::from(100),\n        \"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]\",\n    );\n\n    exhaustive_integer_range_rev_helper(\n        Integer::from(-20),\n        Integer::from(-10),\n        \"[-20, -19, -18, -17, -16, -15, -14, -13, -12, -11]\",\n    );\n    exhaustive_integer_range_rev_helper(\n        Integer::from(-100),\n        Integer::from(100),\n        \"[-100, -99, 99, -98, 98, -97, 97, -96, 96, -95, 95, -94, 94, -93, 93, -92, 92, -91, 91, \\\n        -90]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_integer_range_fail() {\n    exhaustive_integer_range(Integer::ONE, Integer::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_integer_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::exhaustive_integer_range_to_infinity;\n\nfn exhaustive_integer_range_to_infinity_helper(a: Integer, values: &str) {\n    let xs = exhaustive_integer_range_to_infinity(a)\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_exhaustive_integer_range_to_infinity() {\n    exhaustive_integer_range_to_infinity_helper(\n        Integer::ZERO,\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\",\n    );\n    exhaustive_integer_range_to_infinity_helper(\n        Integer::from(5),\n        \"[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\",\n    );\n    exhaustive_integer_range_to_infinity_helper(\n        Integer::from(-5),\n        \"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_integer_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::exhaustive_integer_range_to_negative_infinity;\n\nfn exhaustive_integer_range_to_negative_infinity_helper(a: Integer, values: &str) {\n    let xs = exhaustive_integer_range_to_negative_infinity(a)\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_exhaustive_integer_range_to_negative_infinity() {\n    exhaustive_integer_range_to_negative_infinity_helper(\n        Integer::ZERO,\n        \"[0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19]\",\n    );\n    exhaustive_integer_range_to_negative_infinity_helper(\n        Integer::from(-5),\n        \"[-5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, \\\n        -23, -24]\",\n    );\n    exhaustive_integer_range_to_negative_infinity_helper(\n        Integer::from(5),\n        \"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::exhaustive::exhaustive_integers;\n\n#[test]\nfn test_exhaustive_integers() {\n    assert_eq!(\n        exhaustive_integers()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]\"\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_natural_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::exhaustive::exhaustive_natural_integers;\n\n#[test]\nfn test_exhaustive_natural_integers() {\n    assert_eq!(\n        exhaustive_natural_integers()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\"\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_negative_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::exhaustive::exhaustive_negative_integers;\n\n#[test]\nfn test_exhaustive_negative_integers() {\n    assert_eq!(\n        exhaustive_negative_integers()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, \\\n        -20]\"\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_nonzero_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::exhaustive::exhaustive_nonzero_integers;\n\n#[test]\nfn test_exhaustive_nonzero_integers() {\n    assert_eq!(\n        exhaustive_nonzero_integers()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\"\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/exhaustive_positive_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::exhaustive::exhaustive_positive_integers;\n\n#[test]\nfn test_exhaustive_positive_integers() {\n    assert_eq!(\n        exhaustive_positive_integers()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\"\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/integer_decreasing_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::integer_decreasing_range_to_negative_infinity;\n\nfn integer_decreasing_range_to_negative_infinity_helper(a: Integer, values: &str) {\n    let xs = integer_decreasing_range_to_negative_infinity(a)\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_integer_decreasing_range_to_negative_infinity() {\n    integer_decreasing_range_to_negative_infinity_helper(\n        Integer::ZERO,\n        \"[0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19]\",\n    );\n    integer_decreasing_range_to_negative_infinity_helper(\n        Integer::from(10),\n        \"[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\",\n    );\n    integer_decreasing_range_to_negative_infinity_helper(\n        Integer::from(-10),\n        \"[-10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, \\\n        -27, -28, -29]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/integer_increasing_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::integer_increasing_inclusive_range;\n\nfn expected_range_len(a: &Integer, b: &Integer) -> usize {\n    match (*a >= 0, *b >= 0) {\n        (false, false) => usize::exact_from(&-a) - usize::exact_from(&-b) + 1,\n        (false, true) => usize::exact_from(&-a) + usize::exact_from(b) + 1,\n        (true, false) => panic!(),\n        (true, true) => usize::exact_from(b) - usize::exact_from(a) + 1,\n    }\n}\n\nfn integer_increasing_inclusive_range_helper(a: Integer, b: Integer, values: &str) {\n    let xs = integer_increasing_inclusive_range(a.clone(), b.clone())\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n    let len = expected_range_len(&a, &b);\n    assert_eq!(\n        integer_increasing_inclusive_range(a.clone(), b.clone()).count(),\n        len\n    );\n    let mut init = integer_increasing_inclusive_range(a, b)\n        .rev()\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    init.reverse();\n    assert_eq!(xs, init.to_debug_string());\n}\n\n#[test]\nfn test_integer_increasing_inclusive_range() {\n    integer_increasing_inclusive_range_helper(Integer::ZERO, Integer::ZERO, \"[0]\");\n    integer_increasing_inclusive_range_helper(Integer::ZERO, Integer::ONE, \"[0, 1]\");\n    integer_increasing_inclusive_range_helper(\n        Integer::ZERO,\n        Integer::from(10),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\",\n    );\n    integer_increasing_inclusive_range_helper(\n        Integer::from(10),\n        Integer::from(20),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\",\n    );\n    integer_increasing_inclusive_range_helper(\n        Integer::from(-20),\n        Integer::from(-10),\n        \"[-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10]\",\n    );\n    integer_increasing_inclusive_range_helper(\n        Integer::from(-100),\n        Integer::from(100),\n        \"[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, \\\n        -83, -82, -81]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn integer_increasing_inclusive_range_fail() {\n    integer_increasing_inclusive_range(Integer::ONE, Integer::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/integer_increasing_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::integer_increasing_range;\n\nfn expected_range_len(a: &Integer, b: &Integer) -> usize {\n    match (*a >= 0, *b >= 0) {\n        (false, false) => usize::exact_from(&-a) - usize::exact_from(&-b),\n        (false, true) => usize::exact_from(&-a) + usize::exact_from(b),\n        (true, false) => panic!(),\n        (true, true) => usize::exact_from(b) - usize::exact_from(a),\n    }\n}\n\nfn integer_increasing_range_helper(a: Integer, b: Integer, values: &str) {\n    let xs = integer_increasing_range(a.clone(), b.clone())\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n    let len = expected_range_len(&a, &b);\n    assert_eq!(integer_increasing_range(a.clone(), b.clone()).count(), len);\n    let mut init = integer_increasing_range(a, b)\n        .rev()\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    init.reverse();\n    assert_eq!(xs, init.to_debug_string());\n}\n\n#[test]\nfn test_integer_increasing_range() {\n    integer_increasing_range_helper(Integer::ZERO, Integer::ZERO, \"[]\");\n    integer_increasing_range_helper(Integer::ZERO, Integer::ONE, \"[0]\");\n    integer_increasing_range_helper(\n        Integer::ZERO,\n        Integer::from(10),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\",\n    );\n    integer_increasing_range_helper(\n        Integer::from(10),\n        Integer::from(20),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\",\n    );\n    integer_increasing_range_helper(\n        Integer::from(-20),\n        Integer::from(-10),\n        \"[-20, -19, -18, -17, -16, -15, -14, -13, -12, -11]\",\n    );\n    integer_increasing_range_helper(\n        Integer::from(-100),\n        Integer::from(100),\n        \"[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, \\\n        -83, -82, -81]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn integer_increasing_range_fail() {\n    integer_increasing_range(Integer::ONE, Integer::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/exhaustive/integer_increasing_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::integer_increasing_range_to_infinity;\n\nfn integer_increasing_range_to_infinity_helper(a: Integer, values: &str) {\n    let xs = integer_increasing_range_to_infinity(a)\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_integer_increasing_range_to_infinity() {\n    integer_increasing_range_to_infinity_helper(\n        Integer::ZERO,\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\",\n    );\n    integer_increasing_range_to_infinity_helper(\n        Integer::from(10),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\",\n    );\n    integer_increasing_range_to_infinity_helper(\n        Integer::from(-10),\n        \"[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, unsigned_vec_pair_gen_var_8, unsigned_vec_pair_gen_var_9,\n    unsigned_vec_triple_gen_var_33, unsigned_vec_triple_gen_var_34,\n    unsigned_vec_unsigned_pair_gen_var_15, unsigned_vec_unsigned_pair_gen_var_18,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::and::{\n    limbs_and_neg_neg, limbs_and_neg_neg_to_out, limbs_and_pos_neg,\n    limbs_and_pos_neg_in_place_left, limbs_and_pos_neg_to_out, limbs_neg_and_limb_neg,\n    limbs_neg_and_limb_neg_to_out, limbs_pos_and_limb_neg, limbs_pos_and_limb_neg_in_place,\n    limbs_pos_and_limb_neg_to_out, limbs_slice_and_neg_neg_in_place_either,\n    limbs_slice_and_neg_neg_in_place_left, limbs_slice_and_pos_neg_in_place_right,\n    limbs_slice_neg_and_limb_neg_in_place, limbs_vec_and_neg_neg_in_place_either,\n    limbs_vec_and_neg_neg_in_place_left, limbs_vec_and_pos_neg_in_place_right,\n    limbs_vec_neg_and_limb_neg_in_place,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_pair_gen,\n};\nuse malachite_nz::test_util::integer::logic::and::{integer_and_alt_1, integer_and_alt_2};\nuse rug;\nuse std::cmp::{max, min};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_and_limb_neg_and_limbs_pos_and_limb_neg_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_pos_and_limb_neg(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_pos_and_limb_neg_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[6, 7], 2, &[2, 7]);\n    test(&[100, 101, 102], 10, &[0, 101, 102]);\n    test(&[123, 456], 789, &[17, 456]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_and_limb_neg_fail() {\n    limbs_pos_and_limb_neg(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_and_limb_neg_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_pos_and_limb_neg_to_out(&mut out, xs, y);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[6, 7], 2, &[2, 7, 10, 10]);\n    test(&[10, 10, 10, 10], &[100, 101, 102], 10, &[0, 101, 102, 10]);\n    test(&[10, 10, 10, 10], &[123, 456], 789, &[17, 456, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_and_limb_neg_to_out_fail_1() {\n    limbs_pos_and_limb_neg_to_out(&mut [], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_and_limb_neg_to_out_fail_2() {\n    limbs_pos_and_limb_neg_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_and_limb_neg_in_place_fail() {\n    limbs_pos_and_limb_neg_in_place(&mut [], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_and_limb_neg_and_limbs_vec_neg_and_limb_neg_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_neg_and_limb_neg(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_vec_neg_and_limb_neg_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[0, 2], 3, &[0, 2]);\n    test(&[1, 1], 3, &[0xfffffffd, 1]);\n    test(&[u32::MAX - 1, 1], 1, &[0, 2]);\n    test(&[u32::MAX - 1, u32::MAX], 1, &[0, 0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_and_limb_neg_fail() {\n    limbs_neg_and_limb_neg(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_and_limb_neg_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, carry, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_neg_and_limb_neg_to_out(&mut out, xs, y), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[0, 0], &[0, 2], 3, false, &[0, 2]);\n    test(&[1, 2, 100], &[0, 2, 100], 3, false, &[0, 2, 100]);\n    test(&[0, 0], &[1, 1], 3, false, &[0xfffffffd, 1]);\n    test(&[0, 0], &[u32::MAX - 1, 1], 1, false, &[0, 2]);\n    test(&[0, 0], &[u32::MAX - 1, u32::MAX], 1, true, &[0, 0]);\n    test(\n        &[1, 2, 100],\n        &[u32::MAX - 1, u32::MAX],\n        1,\n        true,\n        &[0, 0, 100],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_and_limb_neg_to_out_fail_1() {\n    limbs_neg_and_limb_neg_to_out(&mut [1, 2, 3], &[1, 2, 3, 4], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_and_limb_neg_to_out_fail_2() {\n    limbs_neg_and_limb_neg_to_out(&mut [1, 2, 3], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_neg_and_limb_neg_in_place() {\n    let test = |xs: &[Limb], y: Limb, carry, xs_after: &[Limb]| {\n        let mut xs = xs.to_vec();\n        assert_eq!(limbs_slice_neg_and_limb_neg_in_place(&mut xs, y), carry);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[0, 2], 3, false, &[0, 2]);\n    test(&[1, 1], 3, false, &[0xfffffffd, 1]);\n    test(&[u32::MAX - 1, 1], 1, false, &[0, 2]);\n    test(&[u32::MAX - 1, u32::MAX], 1, true, &[0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_neg_and_limb_neg_in_place_fail() {\n    limbs_slice_neg_and_limb_neg_in_place(&mut [], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_neg_and_limb_neg_in_place_fail() {\n    let mut xs = vec![];\n    limbs_vec_neg_and_limb_neg_in_place(&mut xs, 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_pos_neg() {\n    let test = |xs, ys, out: &[Limb]| {\n        assert_eq!(limbs_and_pos_neg(xs, ys), out);\n    };\n    test(&[2], &[3], &[0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[1, 1, 0]);\n    test(&[6, 7], &[1, 2, 3], &[6, 5]);\n    test(&[1, 2, 3], &[6, 7], &[0, 0, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], &[0, 0, 2]);\n    test(&[0, 0, 1], &[3], &[0, 0, 1]);\n    test(&[3], &[0, 0, 1], &[]);\n    test(&[0, 3, 3], &[0, 0, 3], &[0, 0, 1]);\n    test(&[0, 0, 3], &[0, 3, 3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_pos_neg_fail_1() {\n    limbs_and_pos_neg(&[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_pos_neg_fail_2() {\n    limbs_and_pos_neg(&[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_pos_neg_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_and_pos_neg_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[2], &[3], &[10, 10, 10, 10], &[0, 10, 10, 10]);\n    test(&[1, 1, 1], &[1, 2, 3], &[10, 10, 10, 10], &[1, 1, 0, 10]);\n    test(&[6, 7], &[1, 2, 3], &[10, 10, 10, 10], &[6, 5, 10, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10, 10, 10, 10], &[0, 0, 3, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        &[0, 0, 2, 10],\n    );\n    test(&[0, 0, 1], &[3], &[10, 10, 10, 10], &[0, 0, 1, 10]);\n    test(&[3], &[0, 0, 1], &[10, 10, 10, 10], &[0, 10, 10, 10]);\n    test(&[0, 3, 3], &[0, 0, 3], &[10, 10, 10, 10], &[0, 0, 1, 10]);\n    test(&[0, 0, 3], &[0, 3, 3], &[10, 10, 10, 10], &[0, 0, 0, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_pos_neg_to_out_fail_1() {\n    let out = &mut [10, 10, 10, 10];\n    limbs_and_pos_neg_to_out(out, &[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_pos_neg_to_out_fail_2() {\n    let out = &mut [10, 10, 10, 10];\n    limbs_and_pos_neg_to_out(out, &[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_pos_neg_to_out_fail_3() {\n    let out = &mut [10];\n    limbs_and_pos_neg_to_out(out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_neg_in_place_left_and_limbs_vec_and_pos_neg_in_place_right() {\n    let test = |xs: &[Limb], ys, out: &[Limb]| {\n        {\n            let mut mut_xs = xs.to_vec();\n            limbs_and_pos_neg_in_place_left(&mut mut_xs, ys);\n            assert_eq!(mut_xs, out);\n        }\n        {\n            let mut mut_ys = ys.to_vec();\n            limbs_vec_and_pos_neg_in_place_right(xs, &mut mut_ys);\n            assert_eq!(mut_ys, out);\n        }\n    };\n    test(&[2], &[3], &[0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[1, 1, 0]);\n    test(&[6, 7], &[1, 2, 3], &[6, 5]);\n    test(&[1, 2, 3], &[6, 7], &[0, 0, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], &[0, 0, 2]);\n    test(&[0, 0, 1], &[3], &[0, 0, 1]);\n    test(&[3], &[0, 0, 1], &[0]);\n    test(&[0, 3, 3], &[0, 0, 3], &[0, 0, 1]);\n    test(&[0, 0, 3], &[0, 3, 3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_pos_neg_in_place_left_fail_1() {\n    limbs_and_pos_neg_in_place_left(&mut [0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_pos_neg_in_place_left_fail_2() {\n    limbs_and_pos_neg_in_place_left(&mut [3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_and_pos_neg_in_place_right_fail_1() {\n    let mut ys = vec![3];\n    limbs_vec_and_pos_neg_in_place_right(&[0, 0, 0], &mut ys);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_and_pos_neg_in_place_right_fail_2() {\n    let mut ys = vec![0, 0, 0];\n    limbs_vec_and_pos_neg_in_place_right(&[3], &mut ys);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_and_pos_neg_in_place_right() {\n    let test = |xs, ys_before: &[Limb], ys_after: &[Limb]| {\n        let mut ys = ys_before.to_vec();\n        limbs_slice_and_pos_neg_in_place_right(xs, &mut ys);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[2], &[3], &[0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[1, 1, 0]);\n    test(&[6, 7], &[1, 2, 3], &[6, 5, 3]);\n    test(&[1, 2, 3], &[6, 7], &[0, 0]);\n    test(&[100, 101, 102], &[102, 101, 100], &[0, 0, 2]);\n    test(&[0, 0, 1], &[3], &[0]);\n    test(&[3], &[0, 0, 1], &[0, 0, 0]);\n    test(&[0, 3, 3], &[0, 0, 3], &[0, 0, 1]);\n    test(&[0, 0, 3], &[0, 3, 3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_pos_neg_in_place_right_fail_1() {\n    limbs_slice_and_pos_neg_in_place_right(&[0, 0, 0], &mut [3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_pos_neg_in_place_right_fail_2() {\n    limbs_slice_and_pos_neg_in_place_right(&[3], &mut [0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_neg_neg_and_limbs_vec_and_neg_neg_in_place_left() {\n    let test = |xs, ys, out: &[Limb]| {\n        assert_eq!(limbs_and_neg_neg(xs, ys), out);\n\n        let mut mut_xs = xs.to_vec();\n        limbs_vec_and_neg_neg_in_place_left(&mut mut_xs, ys);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[2], &[3], &[4]);\n    test(&[1, 1, 1], &[1, 2, 3], &[1, 3, 3]);\n    test(&[6, 7], &[1, 2, 3], &[6, 7, 3]);\n    test(&[1, 2, 3], &[6, 7], &[6, 7, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], &[104, 101, 102]);\n    test(&[0, 0, 1], &[3], &[0, 0, 1]);\n    test(&[3], &[0, 0, 1], &[0, 0, 1]);\n    test(&[0, 3, 3], &[0, 0, 3], &[0, 0, 4]);\n    test(&[0, 0, 3], &[0, 3, 3], &[0, 0, 4]);\n    test(&[0, 2, 1], &[0, u32::MAX, u32::MAX], &[0, 0, 0, 1]);\n    test(&[0, 2], &[0, u32::MAX, u32::MAX], &[0, 0, 0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_neg_neg_fail_1() {\n    limbs_and_neg_neg(&[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_neg_neg_fail_2() {\n    limbs_and_neg_neg(&[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_and_neg_neg_in_place_left_fail_1() {\n    limbs_vec_and_neg_neg_in_place_left(&mut vec![0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_and_neg_neg_in_place_left_fail_2() {\n    limbs_vec_and_neg_neg_in_place_left(&mut vec![3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_neg_neg_to_out() {\n    let test = |xs, ys, out_before: &[Limb], b, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_and_neg_neg_to_out(&mut out, xs, ys), b);\n        assert_eq!(out, out_after);\n    };\n    test(&[2], &[3], &[10, 10, 10, 10], true, &[4, 10, 10, 10]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        &[10, 10, 10, 10],\n        true,\n        &[1, 3, 3, 10],\n    );\n    test(&[6, 7], &[1, 2, 3], &[10, 10, 10, 10], true, &[6, 7, 3, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10, 10, 10, 10], true, &[6, 7, 3, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        true,\n        &[104, 101, 102, 10],\n    );\n    test(&[0, 0, 1], &[3], &[10, 10, 10, 10], true, &[0, 0, 1, 10]);\n    test(&[3], &[0, 0, 1], &[10, 10, 10, 10], true, &[0, 0, 1, 10]);\n    test(\n        &[0, 3, 3],\n        &[0, 0, 3],\n        &[10, 10, 10, 10],\n        true,\n        &[0, 0, 4, 10],\n    );\n    test(\n        &[0, 0, 3],\n        &[0, 3, 3],\n        &[10, 10, 10, 10],\n        true,\n        &[0, 0, 4, 10],\n    );\n    test(\n        &[0, 2],\n        &[0, u32::MAX],\n        &[10, 10, 10, 10],\n        false,\n        &[0, 0, 10, 10],\n    );\n    test(\n        &[0, 2, 1],\n        &[0, u32::MAX, u32::MAX],\n        &[10, 10, 10, 10],\n        false,\n        &[0, 0, 0, 10],\n    );\n    test(\n        &[0, 2],\n        &[0, u32::MAX, u32::MAX],\n        &[10, 10, 10, 10],\n        false,\n        &[0, 0, 0, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_neg_neg_to_out_fail_1() {\n    let out = &mut [10, 10, 10, 10];\n    limbs_and_neg_neg_to_out(out, &[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_neg_neg_to_out_fail_2() {\n    let out = &mut [10, 10, 10, 10];\n    limbs_and_neg_neg_to_out(out, &[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_neg_neg_to_out_fail_3() {\n    let out = &mut [10, 10];\n    limbs_and_neg_neg_to_out(out, &[6, 7, 8], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_neg_neg_to_out_fail_4() {\n    let out = &mut [10, 10];\n    limbs_and_neg_neg_to_out(out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_and_neg_neg_in_place_left() {\n    let test = |xs_before: &[Limb], ys, b, xs_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_slice_and_neg_neg_in_place_left(&mut xs, ys), b);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[2], &[3], true, &[4]);\n    test(&[1, 1, 1], &[1, 2, 3], true, &[1, 3, 3]);\n    test(&[1, 2, 3], &[6, 7], true, &[6, 7, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], true, &[104, 101, 102]);\n    test(&[0, 0, 1], &[3], true, &[0, 0, 1]);\n    test(&[0, 3, 3], &[0, 0, 3], true, &[0, 0, 4]);\n    test(&[0, 0, 3], &[0, 3, 3], true, &[0, 0, 4]);\n    test(&[0, 2], &[0, u32::MAX], false, &[0, 0]);\n    test(&[0, 2, 1], &[0, u32::MAX, u32::MAX], false, &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_neg_neg_in_place_left_fail_1() {\n    limbs_slice_and_neg_neg_in_place_left(&mut [0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_neg_neg_in_place_left_fail_2() {\n    limbs_slice_and_neg_neg_in_place_left(&mut [0, 0, 1], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_neg_neg_in_place_left_fail_3() {\n    limbs_slice_and_neg_neg_in_place_left(&mut [6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_and_neg_neg_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], p, xs_after: &[Limb], ys_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_slice_and_neg_neg_in_place_either(&mut xs, &mut ys), p);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[2], &[3], (false, true), &[4], &[3]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        (false, true),\n        &[1, 3, 3],\n        &[1, 2, 3],\n    );\n    test(&[1, 2, 3], &[6, 7], (false, true), &[6, 7, 3], &[6, 7]);\n    test(&[6, 7], &[1, 2, 3], (true, true), &[6, 7], &[6, 7, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        (false, true),\n        &[104, 101, 102],\n        &[102, 101, 100],\n    );\n    test(&[0, 0, 1], &[3], (false, true), &[0, 0, 1], &[3]);\n    test(&[3], &[0, 0, 1], (true, true), &[3], &[0, 0, 1]);\n    test(\n        &[0, 3, 3],\n        &[0, 0, 3],\n        (false, true),\n        &[0, 0, 4],\n        &[0, 0, 3],\n    );\n    test(\n        &[0, 0, 3],\n        &[0, 3, 3],\n        (false, true),\n        &[0, 0, 4],\n        &[0, 3, 3],\n    );\n    test(\n        &[0, 2],\n        &[0, u32::MAX],\n        (false, false),\n        &[0, 0],\n        &[0, u32::MAX],\n    );\n    test(\n        &[0, 2, 1],\n        &[0, u32::MAX, u32::MAX],\n        (false, false),\n        &[0, 0, 0],\n        &[0, u32::MAX, u32::MAX],\n    );\n    test(\n        &[0, 2],\n        &[0, u32::MAX, u32::MAX],\n        (true, false),\n        &[0, 2],\n        &[0, 0, 0],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_neg_neg_in_place_either_fail_1() {\n    limbs_slice_and_neg_neg_in_place_either(&mut [0, 0, 0], &mut [3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_neg_neg_in_place_either_fail_2() {\n    limbs_slice_and_neg_neg_in_place_either(&mut [3], &mut [0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_and_neg_neg_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], b, xs_after: &[Limb], ys_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_vec_and_neg_neg_in_place_either(&mut xs, &mut ys), b);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[2], &[3], false, &[4], &[3]);\n    test(&[1, 1, 1], &[1, 2, 3], false, &[1, 3, 3], &[1, 2, 3]);\n    test(&[1, 2, 3], &[6, 7], false, &[6, 7, 3], &[6, 7]);\n    test(&[6, 7], &[1, 2, 3], true, &[6, 7], &[6, 7, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        &[104, 101, 102],\n        &[102, 101, 100],\n    );\n    test(&[0, 0, 1], &[3], false, &[0, 0, 1], &[3]);\n    test(&[3], &[0, 0, 1], true, &[3], &[0, 0, 1]);\n    test(&[0, 3, 3], &[0, 0, 3], false, &[0, 0, 4], &[0, 0, 3]);\n    test(&[0, 0, 3], &[0, 3, 3], false, &[0, 0, 4], &[0, 3, 3]);\n    test(&[0, 2], &[0, u32::MAX], false, &[0, 0, 1], &[0, u32::MAX]);\n    test(\n        &[0, 2, 1],\n        &[0, u32::MAX, u32::MAX],\n        false,\n        &[0, 0, 0, 1],\n        &[0, u32::MAX, u32::MAX],\n    );\n    test(\n        &[0, 2],\n        &[0, u32::MAX, u32::MAX],\n        true,\n        &[0, 2],\n        &[0, 0, 0, 1],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_and_neg_neg_in_place_either_fail_1() {\n    limbs_vec_and_neg_neg_in_place_either(&mut vec![0, 0, 0], &mut vec![3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_and_neg_neg_in_place_either_fail_2() {\n    limbs_vec_and_neg_neg_in_place_either(&mut vec![3], &mut vec![0, 0, 0]);\n}\n\n#[test]\nfn test_and() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n &= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n &= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() & v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u & v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() & &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u & &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!(integer_and_alt_1(&u, &v).to_string(), out);\n        assert_eq!(integer_and_alt_2(&u, &v).to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() & rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"0\");\n    test(\"123\", \"456\", \"72\");\n    test(\"1000000000000\", \"123\", \"0\");\n    test(\"123\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"999999999999\", \"999999995904\");\n    test(\"12345678987654321\", \"314159265358979\", \"312331665941633\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"56\");\n    test(\"1000000000000\", \"-123\", \"1000000000000\");\n    test(\"123\", \"-1000000000000\", \"0\");\n    test(\"1000000000000\", \"-999999999999\", \"4096\");\n    test(\"12345678987654321\", \"-314159265358979\", \"12033347321712689\");\n    test(\"-123\", \"0\", \"0\");\n    test(\"-123\", \"456\", \"384\");\n    test(\"-1000000000000\", \"123\", \"0\");\n    test(\"-123\", \"1000000000000\", \"1000000000000\");\n    test(\"-1000000000000\", \"999999999999\", \"0\");\n    test(\"-12345678987654321\", \"314159265358979\", \"1827599417347\");\n    test(\"-123\", \"-456\", \"-512\");\n    test(\"-1000000000000\", \"-123\", \"-1000000000000\");\n    test(\"-123\", \"-1000000000000\", \"-1000000000000\");\n    test(\"-1000000000000\", \"-999999999999\", \"-1000000000000\");\n    test(\n        \"-12345678987654321\",\n        \"-314159265358979\",\n        \"-12347506587071667\",\n    );\n\n    test(\n        \"-18446744073708507135\",\n        \"-9007061819981696\",\n        \"-18446744073709551616\",\n    );\n    test(\"-18446744073708507135\", \"-4194176\", \"-18446744073709551616\");\n    test(\"-4194176\", \"-18446744073708507135\", \"-18446744073709551616\");\n    test(\n        \"3332140978726732268209104861552\",\n        \"-478178031043645514337313657924474082957368\",\n        \"2539024739207132029580719268160\",\n    );\n    test(\n        \"-478178031043645514337313657924474082957368\",\n        \"3332140978726732268209104861552\",\n        \"2539024739207132029580719268160\",\n    );\n}\n\n#[test]\nfn limbs_pos_and_limb_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(xs, y)| {\n        let out = limbs_pos_and_limb_neg(&xs, y);\n        let n = Integer::from(Natural::from_owned_limbs_asc(xs))\n            & Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        assert_eq!(Natural::from_owned_limbs_asc(out), Natural::exact_from(n));\n    });\n}\n\n#[test]\nfn limbs_pos_and_limb_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_pos_and_limb_neg_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            let n = Integer::from(Natural::from_owned_limbs_asc(xs))\n                & Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n            let mut out_alt = Natural::exact_from(n).into_limbs_asc();\n            out_alt.resize(len, 0);\n            assert_eq!(out_alt, &out[..len]);\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_pos_and_limb_neg_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(mut xs, y)| {\n        let mut n = Integer::from(Natural::from_limbs_asc(&xs));\n        limbs_pos_and_limb_neg_in_place(&mut xs, y);\n        n &= Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), Natural::exact_from(n));\n    });\n}\n\n#[test]\nfn limbs_neg_and_limb_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(xs, y)| {\n        let out = limbs_neg_and_limb_neg(&xs, y);\n        let n = -Natural::from_owned_limbs_asc(xs)\n            & Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        assert_eq!(Natural::from_owned_limbs_asc(out), Natural::exact_from(-n));\n    });\n}\n\n#[test]\nfn limbs_neg_and_limb_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            let carry = limbs_neg_and_limb_neg_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            let n = -Natural::from_owned_limbs_asc(xs)\n                & Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n            let mut out_alt = Natural::exact_from(-n).into_limbs_asc();\n            assert_eq!(carry, out_alt.len() == len + 1);\n            out_alt.resize(len, 0);\n            assert_eq!(out_alt, &out[..len]);\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_neg_and_limb_neg_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_slice_neg_and_limb_neg_in_place(&mut xs, y);\n        let n = -Natural::from_owned_limbs_asc(old_xs)\n            & Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        let mut expected_xs = Natural::exact_from(-n).into_limbs_asc();\n        expected_xs.resize(xs.len(), 0);\n        assert_eq!(xs, expected_xs);\n    });\n}\n\n#[test]\nfn limbs_vec_neg_and_limb_neg_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(mut xs, y)| {\n        let n = Natural::from_limbs_asc(&xs);\n        limbs_vec_neg_and_limb_neg_in_place(&mut xs, y);\n        let n = -n & Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), Natural::exact_from(-n));\n    });\n}\n\n#[test]\nfn limbs_and_pos_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_and_pos_neg(&xs, &ys)),\n            Integer::from(Natural::from_owned_limbs_asc(xs)) & -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_and_pos_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_33().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_and_pos_neg_to_out(&mut out, &xs, &ys);\n        let len = xs.len();\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Integer::from(Natural::from_owned_limbs_asc(xs)) & -Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_and_pos_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_and_pos_neg_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Integer::from(Natural::from_owned_limbs_asc(xs_old))\n                & -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_slice_and_pos_neg_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, mut ys)| {\n        let ys_old = ys.clone();\n        limbs_slice_and_pos_neg_in_place_right(&xs, &mut ys);\n        let len = min(xs.len(), ys.len());\n        let result = Integer::from(Natural::from_owned_limbs_asc(xs))\n            & -Natural::from_owned_limbs_asc(ys_old);\n        let mut expected_ys = Natural::exact_from(result).into_limbs_asc();\n        expected_ys.resize(len, 0);\n        assert_eq!(&ys[..len], expected_ys.as_slice());\n    });\n}\n\n#[test]\nfn limbs_vec_and_pos_neg_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, mut ys)| {\n        let ys_old = ys.clone();\n        limbs_vec_and_pos_neg_in_place_right(&xs, &mut ys);\n        let len = xs.len();\n        let result = Integer::from(Natural::from_owned_limbs_asc(xs))\n            & -Natural::from_owned_limbs_asc(ys_old);\n        let mut expected_limbs = Natural::exact_from(result).into_limbs_asc();\n        expected_limbs.resize(len, 0);\n        ys.resize(len, 0);\n        assert_eq!(ys, expected_limbs);\n    });\n}\n\n#[test]\nfn limbs_and_neg_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(limbs_and_neg_neg(&xs, &ys)),\n            -Natural::from_owned_limbs_asc(xs) & -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_and_neg_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_34().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        let b = limbs_and_neg_neg_to_out(&mut out, &xs, &ys);\n        let len = max(xs.len(), ys.len());\n        let result = Natural::exact_from(\n            -(-Natural::from_owned_limbs_asc(xs) & -Natural::from_owned_limbs_asc(ys)),\n        );\n        let mut expected_out = result.to_limbs_asc();\n        expected_out.resize(len, 0);\n        assert_eq!(&out[..len], expected_out.as_slice());\n        assert_eq!(b, Natural::from_owned_limbs_asc(expected_out) == result);\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_slice_and_neg_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_9().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        let b = limbs_slice_and_neg_neg_in_place_left(&mut xs, &ys);\n        let len = xs_old.len();\n        let result = Natural::exact_from(\n            -(-Natural::from_owned_limbs_asc(xs_old) & -Natural::from_owned_limbs_asc(ys)),\n        );\n        let mut expected_xs = result.to_limbs_asc();\n        expected_xs.resize(len, 0);\n        assert_eq!(xs, expected_xs.as_slice());\n        assert_eq!(b, Natural::from_owned_limbs_asc(expected_xs) == result);\n    });\n}\n\n#[test]\nfn limbs_vec_and_neg_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_vec_and_neg_neg_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(xs),\n            -Natural::from_owned_limbs_asc(xs_old) & -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_slice_and_neg_neg_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let (right, b) = limbs_slice_and_neg_neg_in_place_either(&mut xs, &mut ys);\n        let len = max(xs_old.len(), ys_old.len());\n        let result = Natural::exact_from(\n            -(-Natural::from_limbs_asc(&xs_old) & -Natural::from_limbs_asc(&ys_old)),\n        );\n        let mut expected_limbs = result.to_limbs_asc();\n        expected_limbs.resize(len, 0);\n        assert_eq!(b, Natural::from_limbs_asc(&expected_limbs) == result);\n        if right {\n            assert_eq!(ys, expected_limbs.as_slice());\n            assert_eq!(xs, xs_old);\n        } else {\n            assert_eq!(xs, expected_limbs.as_slice());\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[test]\nfn limbs_vec_and_neg_neg_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_vec_and_neg_neg_in_place_either(&mut xs, &mut ys);\n        let expected = -Natural::from_limbs_asc(&xs_old) & -Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(-Natural::from_owned_limbs_asc(ys), expected);\n        } else {\n            assert_eq!(-Natural::from_owned_limbs_asc(xs), expected);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn and_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let result_val_val = x.clone() & y.clone();\n        let result_val_ref = x.clone() & &y;\n        let result_ref_val = &x & y.clone();\n        let result = &x & &y;\n        assert!(result_val_val.is_valid());\n        assert!(result_val_ref.is_valid());\n        assert!(result_ref_val.is_valid());\n        assert!(result.is_valid());\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        let mut mut_x = x.clone();\n        mut_x &= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, result);\n        let mut mut_x = x.clone();\n        mut_x &= &y;\n        assert_eq!(mut_x, result);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x &= rug::Integer::from(&y);\n        assert_eq!(Integer::from(&mut_x), result);\n\n        assert_eq!(\n            Integer::from(&(rug::Integer::from(&x) & rug::Integer::from(&y))),\n            result\n        );\n\n        assert_eq!(integer_and_alt_1(&x, &y), result);\n        assert_eq!(integer_and_alt_2(&x, &y), result);\n\n        assert_eq!(&y & &x, result);\n        assert_eq!(&result & &x, result);\n        assert_eq!(&result & &y, result);\n        assert_eq!(!(!x | !y), result);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(&x & Integer::ZERO, 0);\n        assert_eq!(Integer::ZERO & &x, 0);\n        assert_eq!(&x & &x, x);\n        assert_eq!(&x & !&x, 0);\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x & &y) & &z, x & (y & z));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(i, j)| {\n        assert_eq!(Integer::from(i) & Integer::from(j), i & j);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) & Integer::from(&y), x & y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/assign_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_unsigned_bool_triple_gen_var_1;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_assign_bit() {\n    let test = |u, index, bit, out| {\n        let mut n = Integer::from_str(u).unwrap();\n        n.assign_bit(index, bit);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n.set_bit(u32::exact_from(index), bit);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 10, true, \"1024\");\n    test(\"100\", 0, true, \"101\");\n    test(\"1000000000000\", 10, true, \"1000000001024\");\n    test(\n        \"1000000000000\",\n        100,\n        true,\n        \"1267650600228229402496703205376\",\n    );\n    test(\"5\", 100, true, \"1267650600228229401496703205381\");\n    test(\"0\", 10, false, \"0\");\n    test(\"0\", 100, false, \"0\");\n    test(\"1024\", 10, false, \"0\");\n    test(\"101\", 0, false, \"100\");\n    test(\"1000000001024\", 10, false, \"1000000000000\");\n    test(\"1000000001024\", 100, false, \"1000000001024\");\n    test(\n        \"1267650600228229402496703205376\",\n        100,\n        false,\n        \"1000000000000\",\n    );\n    test(\"1267650600228229401496703205381\", 100, false, \"5\");\n}\n\n#[test]\nfn assign_bit_properties() {\n    integer_unsigned_bool_triple_gen_var_1().test_properties(|(n, index, bit)| {\n        let mut mut_n = n.clone();\n        mut_n.assign_bit(index, bit);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n.set_bit(u32::exact_from(index), bit);\n        assert_eq!(Integer::from(&rug_n), result);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/assign_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, ModPowerOf2Sub, NegModPowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::{BitBlockAccess, LowMask, SignificantBits};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::large_type_gen_var_4;\nuse malachite_base::test_util::num::logic::bit_block_access::assign_bits_naive;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_block_access::limbs_neg_assign_bits;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_4, integer_gen_var_7, integer_unsigned_natural_triple_gen,\n    integer_unsigned_unsigned_natural_quadruple_gen_var_1, natural_gen,\n    natural_unsigned_pair_gen_var_4, natural_unsigned_unsigned_natural_quadruple_gen_var_1,\n};\nuse std::str::FromStr;\n\nfn verify_limbs_neg_assign_bits(xs: &[Limb], start: u64, end: u64, bits: &[Limb], out: &[Limb]) {\n    let old_n = -Natural::from_limbs_asc(xs);\n    let mut n = old_n.clone();\n    let bits = Natural::from_limbs_asc(bits);\n    n.assign_bits(start, end, &bits);\n    let result = n;\n    assert_eq!(-Natural::from_limbs_asc(out), result);\n    let mut n = old_n;\n    assign_bits_naive::<Integer, Natural>(&mut n, start, end, &bits);\n    assert_eq!(n, result);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_assign_bits() {\n    let test = |xs: &[Limb], start: u64, end: u64, bits: &[Limb], out: &[Limb]| {\n        let mut limbs = xs.to_vec();\n        limbs_neg_assign_bits(&mut limbs, start, end, bits);\n        assert_eq!(limbs, out);\n        verify_limbs_neg_assign_bits(xs, start, end, bits, out);\n    };\n    test(&[1], 0, 1, &[1], &[1]);\n    test(&[1], 1, 2, &[1], &[1]);\n    test(&[1], 0, 1, &[0, 1], &[2]);\n    test(&[123], 64, 128, &[456], &[123, 0, 4294966839, u32::MAX]);\n    test(&[123], 80, 100, &[456], &[123, 0, 4265017344, 15]);\n    test(\n        &[123, 456],\n        80,\n        100,\n        &[789, 321],\n        &[123, 456, 4243193856, 15],\n    );\n    test(\n        &[1619367413, 294928230],\n        73,\n        89,\n        &[4211621339, 3627566573, 1208090001, 4045783696, 2932656682, 177881999, 898588654],\n        &[1619367413, 294928230, 25446400],\n    );\n    test(\n        &[1404969050, 495263765, 2378891263, 1299524786, 1654909014, 2724647948],\n        21,\n        32,\n        &[\n            3269073749, 1170977875, 2823122906, 144832001, 3738801070, 1107604886, 4260406413,\n            1766163855, 592730267, 484513503, 1204041536, 3664297641,\n        ],\n        &[2505973850, 495263765, 2378891263, 1299524786, 1654909014, 2724647948],\n    );\n    test(\n        &[\n            4126931041, 1467617913, 1718397261, 904474857, 312429577, 2397873671, 3967827549,\n            3842236128, 3414636734, 1846949256, 1999024107, 424639176,\n        ],\n        27,\n        77,\n        &[977841009],\n        &[\n            1979447393, 4264409764, 1718403071, 904474857, 312429577, 2397873671, 3967827549,\n            3842236128, 3414636734, 1846949256, 1999024107, 424639176,\n        ],\n    );\n    test(&[123, 456], 0, 100, &[], &[0, 0, 0, 16]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_neg_assign_bits_fail_1() {\n    let mut xs = vec![123];\n    limbs_neg_assign_bits(&mut xs, 10, 5, &[456]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_neg_assign_bits_fail_2() {\n    let mut xs = vec![123];\n    limbs_neg_assign_bits(&mut xs, 10, 10, &[456]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_neg_assign_bits_fail_3() {\n    let mut xs = vec![];\n    limbs_neg_assign_bits(&mut xs, 10, 10, &[456]);\n}\n\n#[test]\nfn test_assign_bits() {\n    let test = |s, start, end, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.assign_bits(start, end, &v);\n        assert_eq!(n, Integer::from_str(out).unwrap());\n        let mut n = u;\n        assign_bits_naive(&mut n, start, end, &v);\n        assert_eq!(n, Integer::from_str(out).unwrap());\n    };\n    test(\"123\", 10, 10, \"456\", \"123\");\n    test(\"123\", 5, 7, \"456\", \"27\");\n    test(\"123\", 64, 128, \"456\", \"8411715297611555537019\");\n    test(\"123\", 80, 100, \"456\", \"551270173744270903666016379\");\n    test(\n        \"1000000000000\",\n        80,\n        100,\n        \"456\",\n        \"551270173744271903666016256\",\n    );\n    test(\n        \"456\",\n        80,\n        100,\n        \"1000000000000\",\n        \"401092572728463209067316249032\",\n    );\n    test(\n        \"1000000000000\",\n        80,\n        100,\n        \"2000000000000\",\n        \"802185145456926419134632497152\",\n    );\n\n    test(\"-123\", 10, 10, \"456\", \"-123\");\n    test(\"-123\", 5, 7, \"456\", \"-123\");\n    test(\n        \"-123\",\n        64,\n        128,\n        \"456\",\n        \"-340282366920938455033212565746503123067\",\n    );\n    test(\"-123\", 80, 100, \"456\", \"-1267098121128665515963862483067\");\n    test(\n        \"-1000000000000\",\n        80,\n        100,\n        \"456\",\n        \"-1267098121128665516963862482944\",\n    );\n    test(\n        \"-456\",\n        80,\n        100,\n        \"1000000000000\",\n        \"-866556818573946577800212251080\",\n    );\n    test(\n        \"-1000000000000\",\n        80,\n        100,\n        \"2000000000000\",\n        \"-465464245845483369732896002048\",\n    );\n    test(\"-123\", 0, 100, \"0\", \"-1267650600228229401496703205376\");\n}\n\n#[test]\n#[should_panic]\nfn assign_bits_fail() {\n    let mut n = Integer::from(123u32);\n    n.assign_bits(10, 5, &Natural::from(456u32));\n}\n\n#[test]\nfn limbs_assign_neg_bits_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_4().test_properties_with_config(&config, |(xs_in, start, end, ref bits)| {\n        let mut xs = xs_in.to_vec();\n        limbs_neg_assign_bits(&mut xs, start, end, bits);\n        verify_limbs_neg_assign_bits(&xs_in, start, end, bits, &xs);\n    });\n}\n\n#[test]\nfn assign_bits_properties() {\n    integer_unsigned_unsigned_natural_quadruple_gen_var_1().test_properties(\n        |(n, start, end, bits)| {\n            let old_n = n;\n            let mut n = old_n.clone();\n            n.assign_bits(start, end, &bits);\n            let result = n;\n            let mut n = old_n.clone();\n            assign_bits_naive(&mut n, start, end, &bits);\n            assert_eq!(n, result);\n            n.assign_bits(start, end, &bits);\n            assert_eq!(n, result);\n            let bits_width = end - start;\n            assert_eq!(n.get_bits(start, end), (&bits).mod_power_of_2(bits_width));\n            let mut n = !old_n;\n            let not_bits = bits\n                .neg_mod_power_of_2(bits_width)\n                .mod_power_of_2_sub(Natural::ONE, bits_width);\n            n.assign_bits(start, end, &not_bits);\n            assert_eq!(!n, result);\n        },\n    );\n\n    integer_unsigned_natural_triple_gen().test_properties(|(n, start, bits)| {\n        let old_n = n;\n        let mut n = old_n.clone();\n        n.assign_bits(start, start, &bits);\n        assert_eq!(n, old_n);\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(bits, start)| {\n        let mut n = Integer::ZERO;\n        n.assign_bits(start, start + bits.significant_bits(), &bits);\n        assert_eq!(n, bits << start);\n    });\n\n    integer_gen().test_properties(|n| {\n        let old_n = n;\n        let mut n = old_n.clone();\n        let significant_bits = old_n.significant_bits();\n        n.assign_bits(\n            0,\n            significant_bits,\n            &(&old_n).mod_power_of_2(significant_bits),\n        );\n        assert_eq!(n, old_n);\n    });\n\n    integer_gen_var_4().test_properties(|n| {\n        let old_n = n;\n        let mut n = old_n.clone();\n        n.assign_bits(0, old_n.significant_bits(), &Natural::ZERO);\n        assert_eq!(n, 0);\n    });\n\n    integer_gen_var_7().test_properties(|n| {\n        let old_n = n;\n        let mut n = old_n.clone();\n        let significant_bits = old_n.significant_bits();\n        n.assign_bits(0, significant_bits, &Natural::low_mask(significant_bits));\n        assert_eq!(n, -1);\n    });\n\n    natural_gen().test_properties(|n| {\n        let old_n = n;\n        let mut n = Integer::ZERO;\n        n.assign_bits(0, old_n.significant_bits(), &old_n);\n        assert_eq!(n, old_n);\n    });\n\n    natural_unsigned_unsigned_natural_quadruple_gen_var_1().test_properties(\n        |(n, start, end, bits)| {\n            let old_n = n;\n            let mut n = old_n.clone();\n            n.assign_bits(start, end, &bits);\n            let result = n;\n            let mut n = Integer::from(old_n);\n            n.assign_bits(start, end, &bits);\n            assert_eq!(n, result);\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable, SignificantBits};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen_var_5};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{\n    integer_bool_vec_pair_gen_var_2, integer_unsigned_pair_gen_var_2,\n};\n\n#[test]\nfn test_bits() {\n    let n = Integer::from(-105);\n    let mut bits = n.bits();\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n\n    assert_eq!(bits[0], true);\n    assert_eq!(bits[1], true);\n    assert_eq!(bits[2], true);\n    assert_eq!(bits[3], false);\n    assert_eq!(bits[4], true);\n    assert_eq!(bits[5], false);\n    assert_eq!(bits[6], false);\n    assert_eq!(bits[7], true);\n    assert_eq!(bits[8], true);\n\n    let mut bits = n.bits();\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n}\n\n#[test]\nfn bits_properties() {\n    integer_bool_vec_pair_gen_var_2().test_properties(|(n, bs)| {\n        let mut bits = n.bits();\n        let mut bit_vec = Vec::new();\n        let mut i = 0;\n        for b in bs {\n            if b {\n                bit_vec.insert(i, bits.next().unwrap());\n                i += 1;\n            } else {\n                bit_vec.insert(i, bits.next_back().unwrap());\n            }\n        }\n        assert!(bits.next().is_none());\n        assert!(bits.next_back().is_none());\n        assert_eq!(n.to_bits_asc(), bit_vec);\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, u)| {\n        if u < n.significant_bits() {\n            assert_eq!(n.bits()[u], n.to_bits_asc()[usize::exact_from(u)]);\n        } else {\n            assert_eq!(n.bits()[u], n < 0);\n        }\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(Integer::ZERO.bits()[u], false);\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert!(i.bits().eq(Integer::from(i).bits()));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/checked_count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::CountOnes;\nuse malachite_base::test_util::generators::signed_gen_var_2;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::checked_count_ones::{\n    integer_checked_count_ones_alt_1, integer_checked_count_ones_alt_2,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_checked_count_ones() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u.checked_count_ones(), out);\n        assert_eq!(integer_checked_count_ones_alt_1(&u), out);\n        assert_eq!(integer_checked_count_ones_alt_2(&u), out);\n    };\n    test(\"0\", Some(0));\n    test(\"105\", Some(4));\n    test(\"-105\", None);\n    test(\"1000000000000\", Some(13));\n    test(\"-1000000000000\", None);\n    test(\"4294967295\", Some(32));\n    test(\"-4294967295\", None);\n    test(\"4294967296\", Some(1));\n    test(\"-4294967296\", None);\n    test(\"18446744073709551615\", Some(64));\n    test(\"-18446744073709551615\", None);\n    test(\"18446744073709551616\", Some(1));\n    test(\"-18446744073709551616\", None);\n}\n\n#[test]\nfn checked_count_ones_properties() {\n    integer_gen().test_properties(|x| {\n        let ones = x.checked_count_ones();\n        assert_eq!(integer_checked_count_ones_alt_1(&x), ones);\n        assert_eq!(integer_checked_count_ones_alt_2(&x), ones);\n        assert_eq!(ones == Some(0), x == 0);\n        assert_eq!((!x).checked_count_zeros(), ones);\n    });\n\n    signed_gen_var_2::<SignedLimb>().test_properties(|i| {\n        assert_eq!(\n            Integer::from(i).checked_count_ones(),\n            Some(CountOnes::count_ones(i))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/checked_count_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::CountZeros;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_gen_var_4, unsigned_vec_gen_var_2, unsigned_vec_gen_var_4,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::checked_count_zeros::limbs_count_zeros_neg;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::checked_count_zeros::{\n    integer_checked_count_zeros_alt_1, integer_checked_count_zeros_alt_2,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_count_zeros_neg() {\n    let test = |xs, out| {\n        assert_eq!(limbs_count_zeros_neg(xs), out);\n    };\n    test(&[0, 1, 2], 33);\n    test(&[1, u32::MAX], 32);\n}\n\n#[test]\nfn test_checked_count_zeros() {\n    let test = |s, out| {\n        let u = Integer::from_str(s).unwrap();\n\n        assert_eq!(u.checked_count_zeros(), out);\n        assert_eq!(integer_checked_count_zeros_alt_1(&u), out);\n        assert_eq!(integer_checked_count_zeros_alt_2(&u), out);\n    };\n    test(\"0\", None);\n    test(\"105\", None);\n    test(\"-105\", Some(3));\n    test(\"1000000000000\", None);\n    test(\"-1000000000000\", Some(24));\n    test(\"4294967295\", None);\n    test(\"-4294967295\", Some(31));\n    test(\"4294967296\", None);\n    test(\"-4294967296\", Some(32));\n    test(\"18446744073709551615\", None);\n    test(\"-18446744073709551615\", Some(63));\n    test(\"18446744073709551616\", None);\n    test(\"-18446744073709551616\", Some(64));\n}\n\n#[test]\nfn limbs_count_zeros_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_4().test_properties_with_config(&config, |xs| {\n        limbs_count_zeros_neg(&xs);\n    });\n\n    unsigned_vec_gen_var_2().test_properties_with_config(&config, |xs| {\n        assert_eq!(\n            Some(limbs_count_zeros_neg(&xs)),\n            (-Natural::from_owned_limbs_asc(xs)).checked_count_zeros()\n        );\n    });\n}\n\n#[test]\nfn checked_count_zeros_properties() {\n    integer_gen().test_properties(|x| {\n        let zeros = x.checked_count_zeros();\n        assert_eq!(integer_checked_count_zeros_alt_1(&x), zeros);\n        assert_eq!(integer_checked_count_zeros_alt_2(&x), zeros);\n        assert_eq!((!x).checked_count_ones(), zeros);\n    });\n\n    signed_gen_var_4::<SignedLimb>().test_properties(|i| {\n        assert_eq!(\n            Integer::from(i).checked_count_zeros(),\n            Some(CountZeros::count_zeros(i))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/checked_hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::logic::traits::{CheckedHammingDistance, HammingDistance};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, unsigned_vec_pair_gen_var_8, unsigned_vec_unsigned_pair_gen_var_19,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::checked_hamming_distance::{\n    limbs_hamming_distance_limb_neg, limbs_hamming_distance_neg,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen_var_1, natural_pair_gen,\n};\nuse malachite_nz::test_util::integer::logic::checked_hamming_distance::{\n    integer_checked_hamming_distance_alt_1, integer_checked_hamming_distance_alt_2,\n    rug_checked_hamming_distance,\n};\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_hamming_distance_limb_neg() {\n    let test = |xs, y, out| {\n        assert_eq!(limbs_hamming_distance_limb_neg(xs, y), out);\n    };\n    test(&[2], 2, 0);\n    test(&[1, 1, 1], 1, 2);\n    test(&[1, 1, 1], 2, 3);\n    test(&[1, 2, 3], 3, 4);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_hamming_distance_limb_neg_fail() {\n    limbs_hamming_distance_limb_neg(&[], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_hamming_distance_neg() {\n    let test = |xs, ys, out| {\n        assert_eq!(limbs_hamming_distance_neg(xs, ys), out);\n    };\n    test(&[2], &[3], 2);\n    test(&[1, 1, 1], &[1, 2, 3], 3);\n    test(&[1, 1, 1], &[1, 2, 3, 4], 4);\n    test(&[1, 2, 3, 4], &[1, 1, 1], 4);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_hamming_distance_neg_fail_1() {\n    limbs_hamming_distance_neg(&[0, 0], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_hamming_distance_neg_fail_2() {\n    limbs_hamming_distance_neg(&[1, 2, 3], &[0, 0]);\n}\n\n#[test]\nfn test_checked_hamming_distance() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u.checked_hamming_distance(&v), out);\n        assert_eq!(integer_checked_hamming_distance_alt_1(&u, &v), out);\n        assert_eq!(integer_checked_hamming_distance_alt_2(&u, &v), out);\n        assert_eq!(\n            rug_checked_hamming_distance(\n                &rug::Integer::from_str(s).unwrap(),\n                &rug::Integer::from_str(t).unwrap(),\n            ),\n            out\n        );\n    };\n    test(\"105\", \"123\", Some(2));\n    test(\"1000000000000\", \"0\", Some(13));\n    test(\"4294967295\", \"0\", Some(32));\n    test(\"4294967295\", \"4294967295\", Some(0));\n    test(\"4294967295\", \"4294967296\", Some(33));\n    test(\"1000000000000\", \"1000000000001\", Some(1));\n    test(\"-105\", \"-123\", Some(2));\n    test(\"-1000000000000\", \"-1\", Some(24));\n    test(\"-4294967295\", \"-1\", Some(31));\n    test(\"-4294967295\", \"-4294967295\", Some(0));\n    test(\"-4294967295\", \"-4294967296\", Some(1));\n    test(\"-1000000000000\", \"-1000000000001\", Some(13));\n    test(\"-105\", \"123\", None);\n    test(\"-1000000000000\", \"0\", None);\n    test(\"-4294967295\", \"0\", None);\n    test(\"-4294967295\", \"4294967295\", None);\n    test(\"-4294967295\", \"4294967296\", None);\n    test(\"-1000000000000\", \"1000000000001\", None);\n    test(\"105\", \"-123\", None);\n    test(\"1000000000000\", \"-1\", None);\n    test(\"4294967295\", \"-1\", None);\n    test(\"4294967295\", \"-4294967295\", None);\n    test(\"4294967295\", \"-4294967296\", None);\n    test(\"1000000000000\", \"-1000000000001\", None);\n}\n\n#[test]\nfn limbs_hamming_distance_limb_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_19().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            Some(limbs_hamming_distance_limb_neg(&xs, y)),\n            (-Natural::from_owned_limbs_asc(xs)).checked_hamming_distance(&-Natural::from(y)),\n        );\n    });\n}\n\n#[test]\nfn limbs_hamming_distance_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            Some(limbs_hamming_distance_neg(&xs, &ys)),\n            (-Natural::from_owned_limbs_asc(xs))\n                .checked_hamming_distance(&-Natural::from_owned_limbs_asc(ys)),\n        );\n    });\n}\n\n#[test]\nfn checked_hamming_distance_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let distance = x.checked_hamming_distance(&y);\n        assert_eq!(\n            rug_checked_hamming_distance(&rug::Integer::from(&x), &rug::Integer::from(&y)),\n            distance\n        );\n        assert_eq!(y.checked_hamming_distance(&x), distance);\n        assert_eq!(integer_checked_hamming_distance_alt_1(&x, &y), distance);\n        assert_eq!(integer_checked_hamming_distance_alt_2(&x, &y), distance);\n        assert_eq!(distance == Some(0), x == y);\n        assert_eq!((&x ^ &y).checked_count_ones(), distance);\n        assert_eq!((!x).checked_hamming_distance(&!y), distance);\n    });\n\n    integer_triple_gen_var_1().test_properties(|(x, y, z)| {\n        assert!(\n            x.checked_hamming_distance(&z).unwrap()\n                <= x.checked_hamming_distance(&y).unwrap()\n                    + y.checked_hamming_distance(&z).unwrap()\n        );\n        let x = !x;\n        let y = !y;\n        let z = !z;\n        assert!(\n            x.checked_hamming_distance(&z).unwrap()\n                <= x.checked_hamming_distance(&y).unwrap()\n                    + y.checked_hamming_distance(&z).unwrap()\n        );\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(n.checked_hamming_distance(&n), Some(0));\n        assert_eq!(\n            n.checked_hamming_distance(&Integer::ZERO),\n            n.checked_count_ones()\n        );\n        assert_eq!(\n            n.checked_hamming_distance(&Integer::NEGATIVE_ONE),\n            n.checked_count_zeros()\n        );\n        assert_eq!(\n            Integer::ZERO.checked_hamming_distance(&n),\n            n.checked_count_ones()\n        );\n        assert_eq!(\n            Integer::NEGATIVE_ONE.checked_hamming_distance(&n),\n            n.checked_count_zeros()\n        );\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(\n            Some(x.hamming_distance(&y)),\n            Integer::from(x).checked_hamming_distance(&Integer::from(y)),\n        );\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Integer::from(x).checked_hamming_distance(&Integer::from(y)),\n            x.checked_hamming_distance(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/clear_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{BitAccess, NotAssign};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_20;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_access::{\n    limbs_slice_clear_bit_neg, limbs_vec_clear_bit_neg,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    integer_unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_21,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_clear_bit_neg() {\n    let test = |xs: &[Limb], index: u64, out: &[Limb]| {\n        let mut mut_xs = xs.to_vec();\n        limbs_slice_clear_bit_neg(&mut mut_xs, index);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[3, 2, 1], 0, &[4, 2, 1]);\n    test(&[0, 0, 3], 32, &[0, 0, 3]);\n    test(&[0, 3, 2, 1], 64, &[0, 3, 3, 1]);\n    test(&[0, 0, 0xfffffffd], 64, &[0, 0, u32::MAX - 1]);\n    test(&[0xfffffff7], 3, &[u32::MAX]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_clear_bit_fail_1() {\n    let mut mut_xs = vec![0, 0, u32::MAX];\n    limbs_slice_clear_bit_neg(&mut mut_xs, 64);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_clear_bit_fail_2() {\n    let mut mut_xs = vec![3, 2, 1];\n    limbs_slice_clear_bit_neg(&mut mut_xs, 100);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_clear_bit_neg() {\n    let test = |xs: &[Limb], index: u64, out: &[Limb]| {\n        let mut mut_xs = xs.to_vec();\n        limbs_vec_clear_bit_neg(&mut mut_xs, index);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[3, 2, 1], 0, &[4, 2, 1]);\n    test(&[0, 0, 3], 32, &[0, 0, 3]);\n    test(&[0, 3, 2, 1], 64, &[0, 3, 3, 1]);\n    test(&[0, 0, 0xfffffffd], 64, &[0, 0, u32::MAX - 1]);\n    test(&[0, 0, u32::MAX], 64, &[0, 0, 0, 1]);\n    test(&[3, 2, 1], 100, &[3, 2, 1, 16]);\n    test(&[0xfffffff7], 3, &[u32::MAX]);\n    test(&[0xfffffff8], 3, &[0, 1]);\n}\n\n#[test]\nfn test_clear_bit() {\n    let test = |u, index, out| {\n        let mut n = Integer::from_str(u).unwrap();\n        n.clear_bit(index);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", 10, \"0\");\n    test(\"0\", 100, \"0\");\n    test(\"1024\", 10, \"0\");\n    test(\"101\", 0, \"100\");\n    test(\"1000000001024\", 10, \"1000000000000\");\n    test(\"1000000001024\", 100, \"1000000001024\");\n    test(\"1267650600228229402496703205376\", 100, \"1000000000000\");\n    test(\"1267650600228229401496703205381\", 100, \"5\");\n    test(\"-1\", 5, \"-33\");\n    test(\"-1\", 100, \"-1267650600228229401496703205377\");\n    test(\"-31\", 0, \"-32\");\n    test(\"-999999998976\", 10, \"-1000000000000\");\n    test(\"-1000000000000\", 100, \"-1267650600228229402496703205376\");\n    test(\"-18446744078004518912\", 0, \"-18446744078004518912\");\n    test(\"-18446744078004518912\", 32, \"-18446744082299486208\");\n    test(\"-18446744078004518912\", 33, \"-18446744086594453504\");\n    test(\"-18446744078004518912\", 64, \"-18446744078004518912\");\n    test(\"-18446744078004518912\", 65, \"-55340232225423622144\");\n    test(\"-36893488143124135936\", 32, \"-36893488147419103232\");\n    test(\"-4294967295\", 0, \"-4294967296\");\n    test(\"-4294967287\", 3, \"-4294967295\");\n    test(\"-4294967288\", 3, \"-4294967296\");\n}\n\n#[test]\nfn limbs_slice_clear_bit_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_21().test_properties_with_config(\n        &config,\n        |(mut xs, index)| {\n            let mut n = -Natural::from_limbs_asc(&xs);\n            limbs_slice_clear_bit_neg(&mut xs, index);\n            n.clear_bit(index);\n            assert_eq!(-Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_clear_bit_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(\n        &config,\n        |(mut xs, index)| {\n            let mut n = -Natural::from_limbs_asc(&xs);\n            limbs_vec_clear_bit_neg(&mut xs, index);\n            n.clear_bit(index);\n            assert_eq!(-Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn clear_bit_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, index)| {\n        let mut mut_n = n.clone();\n        mut_n.clear_bit(index);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let mut mut_n = n.clone();\n        mut_n.assign_bit(index, false);\n        assert_eq!(mut_n, result);\n\n        assert_eq!(&n & !Integer::power_of_2(index), result);\n\n        assert!(result <= n);\n        if n.get_bit(index) {\n            assert_ne!(result, n);\n            let mut mut_result = result.clone();\n            mut_result.set_bit(index);\n            assert_eq!(mut_result, n);\n        } else {\n            assert_eq!(result, n);\n        }\n\n        let mut mut_not_n = !n;\n        mut_not_n.set_bit(index);\n        mut_not_n.not_assign();\n        assert_eq!(mut_not_n, result);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/flip_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_flip_bit() {\n    let test = |u, index, out| {\n        let mut n = Integer::from_str(u).unwrap();\n        n.flip_bit(index);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n.toggle_bit(u32::exact_from(index));\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 10, \"1024\");\n    test(\"1024\", 10, \"0\");\n    test(\"100\", 0, \"101\");\n    test(\"101\", 0, \"100\");\n    test(\"1000000000000\", 10, \"1000000001024\");\n    test(\"1000000001024\", 10, \"1000000000000\");\n    test(\"1000000000000\", 100, \"1267650600228229402496703205376\");\n    test(\"1267650600228229402496703205376\", 100, \"1000000000000\");\n    test(\"5\", 100, \"1267650600228229401496703205381\");\n    test(\"1267650600228229401496703205381\", 100, \"5\");\n    test(\"-4294967296\", 0, \"-4294967295\");\n    test(\"-4294967295\", 0, \"-4294967296\");\n}\n\n#[test]\nfn flip_bit_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, index)| {\n        let mut mut_n = n.clone();\n        mut_n.flip_bit(index);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        assert_ne!(result, n);\n\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n.toggle_bit(u32::exact_from(index));\n        assert_eq!(Integer::from(&rug_n), result);\n\n        let mut mut_result = result.clone();\n        mut_result.flip_bit(index);\n        assert_eq!(mut_result, n);\n\n        assert_eq!(n ^ Integer::power_of_2(index), result);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::num::logic::traits::BitConvertible;\nuse malachite_base::test_util::generators::bool_vec_gen;\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    from_bits_asc_alt, from_bits_desc_alt,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::integer::logic::from_bits::{\n    from_bits_asc_naive, from_bits_desc_naive,\n};\n\n#[test]\nfn test_from_bits_asc_and_from_bit_iterator_asc() {\n    let test = |bits: &[bool], out| {\n        let x = Integer::from_bits_asc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(&[], \"0\");\n    test(&[false], \"0\");\n    test(&[false, false, false], \"0\");\n    test(&[true, false], \"1\");\n    test(&[true], \"-1\");\n    test(&[true, true, true], \"-1\");\n    test(&[false, true, true, false], \"6\");\n    test(&[false, true, false, true], \"-6\");\n    test(&[true, false, false, true, false, true, true, false], \"105\");\n    test(\n        &[true, false, false, true, false, true, true, false, false],\n        \"105\",\n    );\n    test(\n        &[true, false, false, true, false, true, true, false, false, false],\n        \"105\",\n    );\n    test(&[true, true, true, false, true, false, false, true], \"-105\");\n    test(\n        &[\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, false, false, false, true, false, true, false, false, true, false, true, false,\n            false, true, false, true, false, true, true, false, false, false, true, false, true,\n            true, true, false,\n        ],\n        \"1000000000000\",\n    );\n    test(\n        &[\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, false, false, false, true, false, true, false, false, true, false, true, false,\n            false, true, false, true, false, true, true, false, false, false, true, false, true,\n            true, true, false, false,\n        ],\n        \"1000000000000\",\n    );\n    test(\n        &[\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, true, true, true, false, true, false, true, true, false, true, false, true, true,\n            false, true, false, true, false, false, true, true, true, false, true, false, false,\n            false, true,\n        ],\n        \"-1000000000000\",\n    );\n}\n\n#[test]\nfn test_from_bits_desc() {\n    let test = |bits: &[bool], out| {\n        let x = Integer::from_bits_desc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(&[], \"0\");\n    test(&[false], \"0\");\n    test(&[false, false, false], \"0\");\n    test(&[false, true], \"1\");\n    test(&[true], \"-1\");\n    test(&[true, true, true], \"-1\");\n    test(&[false, true, true, false], \"6\");\n    test(&[true, false, true, false], \"-6\");\n    test(&[false, true, true, false, true, false, false, true], \"105\");\n    test(\n        &[false, false, true, true, false, true, false, false, true],\n        \"105\",\n    );\n    test(\n        &[false, false, false, true, true, false, true, false, false, true],\n        \"105\",\n    );\n    test(&[true, false, false, true, false, true, true, true], \"-105\");\n    test(\n        &[true, true, true, false, false, true, false, true, true, true],\n        \"-105\",\n    );\n    test(\n        &[\n            false, true, true, true, false, true, false, false, false, true, true, false, true,\n            false, true, false, false, true, false, true, false, false, true, false, true, false,\n            false, false, true, false, false, false, false, false, false, false, false, false,\n            false, false, false,\n        ],\n        \"1000000000000\",\n    );\n    test(\n        &[\n            false, false, true, true, true, false, true, false, false, false, true, true, false,\n            true, false, true, false, false, true, false, true, false, false, true, false, true,\n            false, false, false, true, false, false, false, false, false, false, false, false,\n            false, false, false, false,\n        ],\n        \"1000000000000\",\n    );\n    test(\n        &[\n            true, false, false, false, true, false, true, true, true, false, false, true, false,\n            true, false, true, true, false, true, false, true, true, false, true, false, true,\n            true, true, true, false, false, false, false, false, false, false, false, false, false,\n            false, false,\n        ],\n        \"-1000000000000\",\n    );\n}\n\n#[test]\nfn from_bits_asc_properties() {\n    bool_vec_gen().test_properties(|bits| {\n        let x = Integer::from_bits_asc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(from_bits_asc_naive(bits.iter().copied()), x);\n        assert_eq!(from_bits_asc_alt::<Integer, _>(bits.iter().copied()), x);\n        assert_eq!(Integer::from_bits_desc(bits.iter().copied().rev()), x);\n        assert_eq!(bits.iter().all(|b| !b), x == 0);\n        if SignedLimb::convertible_from(&x) {\n            assert_eq!(SignedLimb::from_bits_asc(bits.into_iter()), x);\n        }\n    });\n}\n\n#[test]\nfn from_bits_desc_properties() {\n    bool_vec_gen().test_properties(|bits| {\n        let x = Integer::from_bits_desc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(from_bits_desc_naive(bits.iter().copied()), x);\n        assert_eq!(from_bits_desc_alt::<Integer, _>(bits.iter().copied()), x);\n        assert_eq!(Integer::from_bits_asc(bits.iter().copied().rev()), x);\n        assert_eq!(bits.iter().all(|b| !b), x == 0);\n        if SignedLimb::convertible_from(&x) {\n            assert_eq!(SignedLimb::from_bits_desc(bits.into_iter()), x);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/get_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_vec_unsigned_pair_gen_var_18,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_access::limbs_get_bit_neg;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{integer_gen_var_4, integer_unsigned_pair_gen_var_2};\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_get_bit_neg() {\n    let test = |xs: &[Limb], index: u64, out: bool| {\n        assert_eq!(limbs_get_bit_neg(xs, index), out);\n    };\n    test(&[1], 0, true);\n    test(&[1], 100, true);\n    test(&[123], 2, true);\n    test(&[123], 3, false);\n    test(&[123], 100, true);\n    test(&[0, 0b1011], 0, false);\n    test(&[0, 0b1011], 32, true);\n    test(&[0, 0b1011], 33, false);\n    test(&[0, 0b1011], 34, true);\n    test(&[0, 0b1011], 35, false);\n    test(&[0, 0b1011], 100, true);\n    test(&[1, 0b1011], 0, true);\n    test(&[1, 0b1011], 32, false);\n    test(&[1, 0b1011], 33, false);\n    test(&[1, 0b1011], 34, true);\n    test(&[1, 0b1011], 35, false);\n    test(&[1, 0b1011], 100, true);\n}\n\n#[test]\nfn test_get_bit() {\n    let test = |n, index, out| {\n        assert_eq!(Integer::from_str(n).unwrap().get_bit(index), out);\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .get_bit(u32::exact_from(index)),\n            out\n        );\n    };\n\n    test(\"0\", 0, false);\n    test(\"0\", 100, false);\n    test(\"123\", 2, false);\n    test(\"123\", 3, true);\n    test(\"123\", 100, false);\n    test(\"-123\", 0, true);\n    test(\"-123\", 1, false);\n    test(\"-123\", 100, true);\n    test(\"1000000000000\", 12, true);\n    test(\"1000000000000\", 100, false);\n    test(\"-1000000000000\", 12, true);\n    test(\"-1000000000000\", 100, true);\n    test(\"4294967295\", 31, true);\n    test(\"4294967295\", 32, false);\n    test(\"4294967296\", 31, false);\n    test(\"4294967296\", 32, true);\n    test(\"4294967296\", 33, false);\n    test(\"-4294967295\", 0, true);\n    test(\"-4294967295\", 1, false);\n    test(\"-4294967295\", 31, false);\n    test(\"-4294967295\", 32, true);\n    test(\"-4294967295\", 33, true);\n    test(\"-4294967296\", 0, false);\n    test(\"-4294967296\", 31, false);\n    test(\"-4294967296\", 32, true);\n    test(\"-4294967296\", 33, true);\n}\n\n#[test]\nfn limbs_get_bit_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(xs, index)| {\n        assert_eq!(\n            (-Natural::from_limbs_asc(&xs)).get_bit(index),\n            limbs_get_bit_neg(&xs, index)\n        );\n    });\n}\n\n#[test]\nfn get_bit_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, index)| {\n        let bit = n.get_bit(index);\n        assert_eq!(rug::Integer::from(&n).get_bit(u32::exact_from(index)), bit);\n        assert_eq!(&n & Integer::power_of_2(index) != 0, bit);\n        assert_eq!(!(!n).get_bit(index), bit);\n    });\n\n    integer_gen_var_4().test_properties(|n| {\n        let significant_bits = n.significant_bits();\n        assert!(!n.get_bit(significant_bits));\n        if n != 0 {\n            assert!(n.get_bit(significant_bits - 1));\n        }\n    });\n\n    signed_unsigned_pair_gen_var_1::<SignedLimb, u64>().test_properties(|(i, index)| {\n        assert_eq!(Integer::from(i).get_bit(index), i.get_bit(index));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/get_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::{BitBlockAccess, LowMask, SignificantBits};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_unsigned_triple_gen_var_2, unsigned_pair_gen_var_7, unsigned_triple_gen_var_20,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_4,\n};\nuse malachite_base::test_util::num::logic::bit_block_access::get_bits_naive;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_block_access::{\n    limbs_neg_limb_get_bits, limbs_slice_neg_get_bits, limbs_vec_neg_get_bits,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_unsigned_pair_gen_var_2, integer_unsigned_unsigned_triple_gen_var_2,\n    natural_unsigned_unsigned_triple_gen_var_4,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\nfn verify_limbs_neg_limb_get_bits(x: Limb, start: u64, end: u64, out: &[Limb]) {\n    let n = -Natural::from(x);\n    let result = n.get_bits(start, end);\n    assert_eq!(get_bits_naive::<Integer, Natural>(&n, start, end), result);\n    assert_eq!(Natural::from_limbs_asc(out), result);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\nfn verify_limbs_neg_get_bits(xs: &[Limb], start: u64, end: u64, out: &[Limb]) {\n    let n = -Natural::from_limbs_asc(xs);\n    let result = n.get_bits(start, end);\n    assert_eq!(get_bits_naive::<Integer, Natural>(&n, start, end), result);\n    assert_eq!(Natural::from_limbs_asc(out), result);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_limb_get_bits() {\n    let test = |x: Limb, start: u64, end: u64, out: &[Limb]| {\n        assert_eq!(limbs_neg_limb_get_bits(x, start, end), out);\n        verify_limbs_neg_limb_get_bits(x, start, end, out);\n    };\n    // - trailing_zeros < end\n    // - start >= Limb::WIDTH\n    test(1, 40, 50, &[0x3ff]);\n    // - start < Limb::WIDTH\n    // - trailing_zeros < start\n    test(0x12345678, 16, 48, &[0xffffedcb]);\n    test(0x12345678, 4, 16, &[0xa98]);\n    // - trailing_zeros >= start\n    test(0x12345678, 0, 100, &[0xedcba988, u32::MAX, u32::MAX, 0xf]);\n    test(0x12345678, 10, 10, &[]);\n    // - trailing_zeros >= end\n    test(0x80000000, 5, 10, &[]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_neg_limb_get_bits_fail() {\n    limbs_neg_limb_get_bits(123, 10, 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_neg_get_bits() {\n    let test = |xs: &[Limb], start: u64, end: u64, out: &[Limb]| {\n        assert_eq!(limbs_slice_neg_get_bits(xs, start, end), out);\n        verify_limbs_neg_get_bits(xs, start, end, out);\n    };\n    // - trailing_zeros < end\n    // - limb_start >= len\n    test(&[1], 40, 50, &[0x3ff]);\n    // - limb_start < len\n    // - limb_end >= len\n    // - offset != 0\n    // - trailing_zeros < start\n    test(&[0x12345678, 0xabcdef01], 16, 48, &[0x10feedcb]);\n    // - limb_end < len\n    test(&[0x12345678, 0xabcdef01], 4, 16, &[0xa98]);\n    // - offset == 0\n    // - trailing_zeros >= start\n    test(\n        &[0x12345678, 0xabcdef01],\n        0,\n        100,\n        &[0xedcba988, 0x543210fe, u32::MAX, 0xf],\n    );\n    test(&[0x12345678, 0xabcdef01], 10, 10, &[]);\n    // - trailing_zeros >= end\n    test(&[0, 0x80000000], 5, 10, &[]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_slice_neg_get_bits_fail() {\n    limbs_slice_neg_get_bits(&[123], 10, 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_neg_get_bits() {\n    let test = |xs: &[Limb], start: u64, end: u64, out: &[Limb]| {\n        assert_eq!(limbs_vec_neg_get_bits(xs.to_vec(), start, end), out);\n        verify_limbs_neg_get_bits(xs, start, end, out);\n    };\n    test(&[1], 40, 50, &[0x3ff]);\n    test(&[0x12345678, 0xabcdef01], 16, 48, &[0x10feedcb]);\n    test(&[0x12345678, 0xabcdef01], 4, 16, &[0xa98]);\n    test(\n        &[0x12345678, 0xabcdef01],\n        0,\n        100,\n        &[0xedcba988, 0x543210fe, u32::MAX, 0xf],\n    );\n    test(&[0x12345678, 0xabcdef01], 10, 10, &[]);\n    test(&[0, 0x80000000], 5, 10, &[]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_vec_neg_get_bits_fail() {\n    limbs_vec_neg_get_bits(vec![123], 10, 5);\n}\n\n#[test]\nfn test_get_bits() {\n    let test = |s, start, end, out| {\n        let u = Integer::from_str(s).unwrap();\n        let out = Natural::from_str(out).unwrap();\n\n        assert_eq!(u.get_bits(start, end), out);\n        assert_eq!(u.clone().get_bits_owned(start, end), out);\n        assert_eq!(get_bits_naive::<Integer, Natural>(&u, start, end), out);\n    };\n    test(\"12379813738590787192\", 16, 48, \"4009824820\");\n    test(\"12379813738590787192\", 4, 16, \"1383\");\n    test(\"12379813738590787192\", 0, 100, \"12379813738590787192\");\n    test(\"12379813738590787192\", 10, 10, \"0\");\n    test(\"-12379813738590787192\", 16, 48, \"285142475\");\n    test(\"-12379813738590787192\", 4, 16, \"2712\");\n    test(\n        \"-12379813738590787192\",\n        0,\n        100,\n        \"1267650600215849587758112418184\",\n    );\n    test(\"-12379813738590787192\", 10, 10, \"0\");\n}\n\n#[test]\n#[should_panic]\nfn get_bits_fail() {\n    Integer::from(123).get_bits(10, 5);\n}\n\n#[test]\n#[should_panic]\nfn get_bits_owned_fail() {\n    Integer::from(123).get_bits_owned(10, 5);\n}\n\n#[test]\nfn limbs_neg_limb_get_bits_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_triple_gen_var_20().test_properties_with_config(&config, |(x, start, end)| {\n        let out = limbs_neg_limb_get_bits(x, start, end);\n        let n = -Natural::from(x);\n        let result = n.get_bits(start, end);\n        assert_eq!(get_bits_naive::<Integer, Natural>(&n, start, end), result);\n        assert_eq!(Natural::from_owned_limbs_asc(out), result);\n    });\n}\n\n#[test]\nfn limbs_neg_get_bits_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_4().test_properties_with_config(\n        &config,\n        |(xs, start, end)| {\n            let out = limbs_slice_neg_get_bits(&xs, start, end);\n            let n = -Natural::from_limbs_asc(&xs);\n            let result = n.get_bits(start, end);\n            assert_eq!(get_bits_naive::<Integer, Natural>(&n, start, end), result);\n            assert_eq!(Natural::from_owned_limbs_asc(out), result);\n\n            let out = limbs_vec_neg_get_bits(xs.clone(), start, end);\n            let n = -Natural::from_owned_limbs_asc(xs);\n            let result = n.get_bits(start, end);\n            assert_eq!(get_bits_naive::<Integer, Natural>(&n, start, end), result);\n            assert_eq!(Natural::from_owned_limbs_asc(out), result);\n        },\n    );\n}\n\n#[test]\nfn get_bit_properties() {\n    integer_unsigned_unsigned_triple_gen_var_2().test_properties(|(n, start, end)| {\n        let bits = n.get_bits(start, end);\n        assert_eq!(n.clone().get_bits_owned(start, end), bits);\n        assert_eq!(get_bits_naive::<Integer, Natural>(&n, start, end), bits);\n        let significant_bits = n.significant_bits();\n        assert_eq!(\n            n.get_bits(start + significant_bits, end + significant_bits),\n            if n >= 0 {\n                Natural::ZERO\n            } else {\n                Natural::low_mask(end - start)\n            }\n        );\n        assert_eq!(\n            (!&n).get_bits(start, end),\n            Natural::low_mask(end - start) - &bits\n        );\n        let mut mut_n = n.clone();\n        mut_n.assign_bits(start, end, &bits);\n        assert_eq!(n, mut_n);\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, start)| {\n        assert_eq!(n.get_bits(start, start), 0);\n    });\n\n    unsigned_pair_gen_var_7().test_properties(|(start, end)| {\n        assert_eq!(Integer::ZERO.get_bits(start, end), 0);\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_4().test_properties(|(n, start, end)| {\n        assert_eq!(\n            Integer::from(&n).get_bits(start, end),\n            n.get_bits(start, end)\n        );\n    });\n\n    signed_unsigned_unsigned_triple_gen_var_2::<Limb, SignedLimb, u64>().test_properties(\n        |(n, start, end)| {\n            assert_eq!(\n                Integer::from(n).get_bits(start, end),\n                n.get_bits(start, end)\n            );\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, BitScan};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_gen, unsigned_vec_unsigned_pair_gen_var_20,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_scan::limbs_index_of_next_false_bit_neg;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_unsigned_pair_gen_var_2, natural_unsigned_pair_gen_var_4,\n};\nuse malachite_nz::test_util::integer::logic::index_of_next_false_bit::*;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_index_of_next_false_bit_neg() {\n    let test = |xs, u, out| {\n        assert_eq!(limbs_index_of_next_false_bit_neg(xs, u), out);\n    };\n    test(&[1], 0, None);\n    test(&[1], 100, None);\n    test(&[0b100], 0, Some(0));\n    test(&[0b100], 1, Some(1));\n    test(&[0b100], 2, None);\n    test(&[0b100], 3, None);\n    test(&[0, 0b101], 0, Some(0));\n    test(&[0, 0b101], 20, Some(20));\n    test(&[0, 0b101], 31, Some(31));\n    test(&[0, 0b101], 32, Some(34));\n    test(&[0, 0b101], 33, Some(34));\n    test(&[0, 0b101], 34, Some(34));\n    test(&[0, 0b101], 35, None);\n    test(&[0, 0b101], 100, None);\n    test(&[0, 0, 0b101], 36, Some(36));\n    test(&[0, 0, 0b101], 64, Some(66));\n    test(&[0, 0, 0b101, 0b101], 96, Some(96));\n    test(&[0, 0, 0b101, 0b101], 97, Some(98));\n}\n\n#[test]\nfn test_index_of_next_false_bit() {\n    let test = |s, u, out| {\n        let n = Integer::from_str(s).unwrap();\n        assert_eq!(n.index_of_next_false_bit(u), out);\n        assert_eq!(integer_index_of_next_false_bit_alt(&n, u), out);\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .find_zero(u32::exact_from(u))\n                .map(u64::from),\n            out\n        );\n    };\n    test(\"0\", 0, Some(0));\n    test(\"0\", 100, Some(100));\n    test(\"47244640256\", 0, Some(0));\n    test(\"47244640256\", 20, Some(20));\n    test(\"47244640256\", 31, Some(31));\n    test(\"47244640256\", 32, Some(34));\n    test(\"47244640256\", 33, Some(34));\n    test(\"47244640256\", 34, Some(34));\n    test(\"47244640256\", 35, Some(36));\n    test(\"47244640256\", 100, Some(100));\n    test(\"680564733841876926631601309731428237312\", 64, Some(64));\n    test(\"680564733841876926631601309731428237312\", 68, Some(129));\n\n    test(\"-21474836480\", 0, Some(0));\n    test(\"-21474836480\", 20, Some(20));\n    test(\"-21474836480\", 31, Some(31));\n    test(\"-21474836480\", 32, Some(34));\n    test(\"-21474836480\", 33, Some(34));\n    test(\"-21474836480\", 34, Some(34));\n    test(\"-21474836480\", 35, None);\n    test(\"-21474836480\", 36, None);\n    test(\"-21474836480\", 100, None);\n    test(\"-92233720368547758080\", 36, Some(36));\n    test(\"-92233720368547758080\", 64, Some(66));\n    test(\"-396140812663555408336267509760\", 96, Some(96));\n    test(\"-396140812663555408336267509760\", 97, Some(98));\n}\n\n#[test]\nfn limbs_index_of_next_false_bit_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(&config, |(xs, u)| {\n        assert_eq!(\n            limbs_index_of_next_false_bit_neg(&xs, u),\n            (-Natural::from_owned_limbs_asc(xs)).index_of_next_false_bit(u)\n        );\n    });\n}\n\n#[test]\nfn index_of_next_false_bit_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, u)| {\n        let result = n.index_of_next_false_bit(u);\n        assert_eq!(result, integer_index_of_next_false_bit_alt(&n, u));\n        assert_eq!(\n            rug::Integer::from(&n)\n                .find_zero(u32::exact_from(u))\n                .map(u64::from),\n            result\n        );\n        assert_eq!(result.is_some(), &n >> u != -1);\n        if let Some(result) = result {\n            assert!(result >= u);\n            assert!(!n.get_bit(result));\n            assert_eq!(result == u, !n.get_bit(u));\n        }\n        assert_eq!((!n).index_of_next_true_bit(u), result);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(n.index_of_next_false_bit(0), (!n).trailing_zeros());\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Integer::ZERO.index_of_next_false_bit(u), Some(u));\n        assert_eq!(Integer::NEGATIVE_ONE.index_of_next_false_bit(u), None);\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, index)| {\n        assert_eq!(\n            Integer::from(&n).index_of_next_false_bit(index),\n            n.index_of_next_false_bit(index)\n        );\n    });\n\n    signed_unsigned_pair_gen_var_1::<SignedLimb, u64>().test_properties(|(i, index)| {\n        assert_eq!(\n            Integer::from(i).index_of_next_false_bit(index),\n            i.index_of_next_false_bit(index)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, BitScan};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_1, unsigned_gen, unsigned_vec_unsigned_pair_gen_var_20,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_scan::limbs_index_of_next_true_bit_neg;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_unsigned_pair_gen_var_2, natural_unsigned_pair_gen_var_4,\n};\nuse malachite_nz::test_util::integer::logic::index_of_next_true_bit::*;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_index_of_next_true_bit_neg() {\n    let test = |xs, u, out| {\n        assert_eq!(limbs_index_of_next_true_bit_neg(xs, u), out);\n    };\n    test(&[1], 0, 0);\n    test(&[1], 100, 100);\n    test(&[0b100], 0, 2);\n    test(&[0b100], 1, 2);\n    test(&[0b100], 2, 2);\n    test(&[0b100], 3, 3);\n    test(&[0, 0b101], 0, 32);\n    test(&[0, 0b101], 20, 32);\n    test(&[0, 0b101], 31, 32);\n    test(&[0, 0b101], 32, 32);\n    test(&[0, 0b101], 33, 33);\n    test(&[0, 0b101], 34, 35);\n    test(&[0, 0b101], 35, 35);\n    test(&[0, 0b101], 36, 36);\n    test(&[0, 0b101], 100, 100);\n    test(&[0, 0, 0b101], 64, 64);\n    test(&[0, 0, 0b101], 66, 67);\n    test(&[0, 0, 0b101, 0b101], 96, 97);\n    test(&[0, 0, 0b101, 0b101], 98, 99);\n}\n\n#[test]\nfn test_index_of_next_true_bit() {\n    let test = |s, u, out| {\n        let n = Integer::from_str(s).unwrap();\n        assert_eq!(n.index_of_next_true_bit(u), out);\n        assert_eq!(integer_index_of_next_true_bit_alt(&n, u), out);\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .find_one(u32::exact_from(u))\n                .map(u64::from),\n            out\n        );\n    };\n    test(\"0\", 0, None);\n    test(\"0\", 100, None);\n    test(\"47244640256\", 0, Some(32));\n    test(\"47244640256\", 20, Some(32));\n    test(\"47244640256\", 31, Some(32));\n    test(\"47244640256\", 32, Some(32));\n    test(\"47244640256\", 33, Some(33));\n    test(\"47244640256\", 34, Some(35));\n    test(\"47244640256\", 35, Some(35));\n    test(\"47244640256\", 36, None);\n    test(\"47244640256\", 100, None);\n    test(\"340282366925890223602069384504899796992\", 91, Some(91));\n    test(\"340282366925890223602069384504899796992\", 92, Some(128));\n\n    test(\"-21474836480\", 0, Some(32));\n    test(\"-21474836480\", 20, Some(32));\n    test(\"-21474836480\", 31, Some(32));\n    test(\"-21474836480\", 32, Some(32));\n    test(\"-21474836480\", 33, Some(33));\n    test(\"-21474836480\", 34, Some(35));\n    test(\"-21474836480\", 35, Some(35));\n    test(\"-21474836480\", 36, Some(36));\n    test(\"-21474836480\", 100, Some(100));\n    test(\"-92233720368547758080\", 64, Some(64));\n    test(\"-92233720368547758080\", 66, Some(67));\n    test(\"-396140812663555408336267509760\", 96, Some(97));\n    test(\"-396140812663555408336267509760\", 98, Some(99));\n}\n\n#[test]\nfn limbs_index_of_next_true_bit_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(&config, |(xs, u)| {\n        assert_eq!(\n            Some(limbs_index_of_next_true_bit_neg(&xs, u)),\n            (-Natural::from_owned_limbs_asc(xs)).index_of_next_true_bit(u)\n        );\n    });\n}\n\n#[test]\nfn index_of_next_true_bit_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, u)| {\n        let result = n.index_of_next_true_bit(u);\n        assert_eq!(result, integer_index_of_next_true_bit_alt(&n, u));\n        assert_eq!(\n            rug::Integer::from(&n)\n                .find_one(u32::exact_from(u))\n                .map(u64::from),\n            result\n        );\n        assert_eq!(result.is_some(), &n >> u != 0);\n        if let Some(result) = result {\n            assert!(result >= u);\n            assert!(n.get_bit(result));\n            assert_eq!(result == u, n.get_bit(u));\n        }\n        assert_eq!((!n).index_of_next_false_bit(u), result);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(n.index_of_next_true_bit(0), n.trailing_zeros());\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Integer::ZERO.index_of_next_true_bit(u), None);\n        assert_eq!(Integer::NEGATIVE_ONE.index_of_next_true_bit(u), Some(u));\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, index)| {\n        assert_eq!(\n            Integer::from(&n).index_of_next_true_bit(index),\n            n.index_of_next_true_bit(index)\n        );\n    });\n\n    signed_unsigned_pair_gen_var_1::<SignedLimb, u64>().test_properties(|(i, index)| {\n        assert_eq!(\n            Integer::from(i).index_of_next_true_bit(index),\n            i.index_of_next_true_bit(index)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitScan;\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::test_util::generators::{unsigned_gen_var_5, unsigned_gen_var_15};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::SignedLimb;\n\n#[test]\nfn test_low_mask() {\n    let test = |bits, out| assert_eq!(Integer::low_mask(bits).to_string(), out);\n    test(0, \"0\");\n    test(1, \"1\");\n    test(2, \"3\");\n    test(3, \"7\");\n    test(32, \"4294967295\");\n    test(100, \"1267650600228229401496703205375\");\n}\n\n#[test]\nfn low_mask_properties() {\n    unsigned_gen_var_5().test_properties(|bits| {\n        let n = Integer::low_mask(bits);\n        assert!(n.is_valid());\n\n        assert_eq!(n, Integer::power_of_2(bits) - Integer::ONE);\n        assert_eq!(Natural::exact_from(&n), Natural::low_mask(bits));\n        assert_eq!(n.index_of_next_false_bit(0), Some(bits));\n    });\n\n    unsigned_gen_var_15::<SignedLimb>().test_properties(|bits| {\n        assert_eq!(SignedLimb::low_mask(bits), Integer::low_mask(bits));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/not.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::NotAssign;\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::{integer_gen, natural_gen};\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_not() {\n    let test = |s, out| {\n        let n = Integer::from_str(s).unwrap();\n\n        let not = !n.clone();\n        assert!(not.is_valid());\n        assert_eq!(not.to_string(), out);\n\n        let not = !&n;\n        assert!(not.is_valid());\n        assert_eq!(not.to_string(), out);\n\n        assert_eq!((!rug::Integer::from_str(s).unwrap()).to_string(), out);\n\n        let mut x = n;\n        x.not_assign();\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"-1\");\n    test(\"123\", \"-124\");\n    test(\"-123\", \"122\");\n    test(\"1000000000000\", \"-1000000000001\");\n    test(\"-1000000000000\", \"999999999999\");\n    test(\"-2147483648\", \"2147483647\");\n    test(\"2147483647\", \"-2147483648\");\n}\n\n#[test]\nfn not_properties() {\n    integer_gen().test_properties(|x| {\n        let not = !x.clone();\n        assert!(not.is_valid());\n\n        let rug_not = !rug::Integer::from(&x);\n        assert_eq!(Integer::from(&rug_not), not);\n\n        let not_alt = !&x;\n        assert!(not_alt.is_valid());\n        assert_eq!(not_alt, not);\n\n        let mut not_alt = x.clone();\n        not_alt.not_assign();\n        assert_eq!(not_alt, not);\n\n        assert_ne!(not, x);\n        assert_eq!(!&not, x);\n        assert_eq!(x >= 0, not < 0);\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(!Integer::from(i), !i);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(!Integer::from(&x), !x);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, unsigned_vec_pair_gen_var_8, unsigned_vec_triple_gen_var_33,\n    unsigned_vec_triple_gen_var_35, unsigned_vec_unsigned_pair_gen_var_18,\n    unsigned_vec_unsigned_pair_gen_var_22, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::or::{\n    limbs_neg_or_limb, limbs_neg_or_limb_in_place, limbs_neg_or_limb_to_out, limbs_neg_or_neg_limb,\n    limbs_or_neg_neg, limbs_or_neg_neg_in_place_either, limbs_or_neg_neg_to_out, limbs_or_pos_neg,\n    limbs_or_pos_neg_in_place_right, limbs_or_pos_neg_to_out, limbs_pos_or_neg_limb,\n    limbs_slice_or_neg_neg_in_place_left, limbs_slice_or_pos_neg_in_place_left,\n    limbs_vec_or_neg_neg_in_place_left, limbs_vec_or_pos_neg_in_place_left,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_pair_gen,\n};\nuse malachite_nz::test_util::integer::logic::or::{integer_or_alt_1, integer_or_alt_2};\nuse rug;\nuse std::cmp::min;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_or_limb_and_limbs_neg_or_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_neg_or_limb(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_neg_or_limb_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[6, 7], 0, &[6, 7]);\n    test(&[6, 7], 2, &[6, 7]);\n    test(&[100, 101, 102], 10, &[98, 101, 102]);\n    test(&[123, 456], 789, &[107, 456]);\n    test(&[0, 0, 456], 789, &[0xfffffceb, Limb::MAX, 455]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_or_limb_in_place_fail() {\n    limbs_neg_or_limb_in_place(&mut [0, 0, 0], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_or_limb_fail() {\n    limbs_neg_or_limb(&[0, 0, 0], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_or_limb_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_neg_or_limb_to_out(&mut out, xs, y);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[6, 7], 0, &[6, 7, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, &[6, 7, 10, 10]);\n    test(&[10, 10, 10, 10], &[100, 101, 102], 10, &[98, 101, 102, 10]);\n    test(&[10, 10, 10, 10], &[123, 456], 789, &[107, 456, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[0, 0, 456],\n        789,\n        &[0xfffffceb, Limb::MAX, 455, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_or_limb_to_out_fail_1() {\n    limbs_neg_or_limb_to_out(&mut [10, 10], &[0, 0], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_or_limb_to_out_fail_2() {\n    limbs_neg_or_limb_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_or_neg_limb() {\n    let test = |xs: &[Limb], y: Limb, out: Limb| {\n        assert_eq!(limbs_pos_or_neg_limb(xs, y), out);\n    };\n    test(&[6, 7], 3, 0xfffffff9);\n    test(&[100, 101, 102], 10, 0xffffff92);\n    test(&[0, 0, 1], 100, 0xffffff9c);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nconst fn limbs_pos_or_neg_limb_fail() {\n    limbs_pos_or_neg_limb(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_or_neg_limb() {\n    let test = |xs: &[Limb], y: Limb, out: Limb| {\n        assert_eq!(limbs_neg_or_neg_limb(xs, y), out);\n    };\n    test(&[6, 7], 3, 5);\n    test(&[100, 101, 102], 10, 98);\n    test(&[0, 0, 1], 100, 0xffffff9c);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nconst fn limbs_neg_or_neg_limb_fail() {\n    limbs_neg_or_neg_limb(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_pos_neg_limbs_vec_or_pos_neg_in_place_left_and_limbs_or_pos_neg_in_place_right() {\n    let test = |xs_before, ys_before, out| {\n        assert_eq!(limbs_or_pos_neg(xs_before, ys_before), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_vec_or_pos_neg_in_place_left(&mut xs, ys_before);\n        assert_eq!(xs, out);\n\n        let mut ys = ys_before.to_vec();\n        limbs_or_pos_neg_in_place_right(xs_before, &mut ys);\n        assert_eq!(ys, out);\n    };\n    test(&[2], &[3], vec![1]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 2, 2]);\n    test(&[6, 7], &[1, 2, 3], vec![1, 0, 3]);\n    test(&[1, 2, 3], &[6, 7], vec![5, 5]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![2, 0, 0]);\n    test(&[0, 0, 1], &[3], vec![3]);\n    test(&[3], &[0, 0, 1], vec![0xfffffffd, Limb::MAX, 0]);\n    test(&[0, 3, 3], &[0, 0, 3], vec![0, 0xfffffffd, 0]);\n    test(&[0, 0, 3], &[0, 3, 3], vec![0, 3, 0]);\n    test(&[0, 3], &[0, 0, 3], vec![0, 0xfffffffd, 2]);\n    test(&[0, 0, 3], &[0, 3], vec![0, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_pos_neg_fail_1() {\n    limbs_or_pos_neg(&[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_pos_neg_fail_2() {\n    limbs_or_pos_neg(&[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_pos_neg_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_or_pos_neg_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[2], &[3], &[10, 10, 10, 10], vec![1, 10, 10, 10]);\n    test(&[1, 1, 1], &[1, 2, 3], &[10, 10, 10, 10], vec![1, 2, 2, 10]);\n    test(&[6, 7], &[1, 2, 3], &[10, 10, 10, 10], vec![1, 0, 3, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10, 10, 10, 10], vec![5, 5, 10, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![2, 0, 0, 10],\n    );\n    test(&[0, 0, 1], &[3], &[10, 10, 10, 10], vec![3, 10, 10, 10]);\n    test(\n        &[3],\n        &[0, 0, 1],\n        &[10, 10, 10, 10],\n        vec![0xfffffffd, Limb::MAX, 0, 10],\n    );\n    test(\n        &[0, 3, 3],\n        &[0, 0, 3],\n        &[10, 10, 10, 10],\n        vec![0, 0xfffffffd, 0, 10],\n    );\n    test(&[0, 0, 3], &[0, 3, 3], &[10, 10, 10, 10], vec![0, 3, 0, 10]);\n    test(\n        &[0, 3],\n        &[0, 0, 3],\n        &[10, 10, 10, 10],\n        vec![0, 0xfffffffd, 2, 10],\n    );\n    test(&[0, 0, 3], &[0, 3], &[10, 10, 10, 10], vec![0, 3, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_pos_neg_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_or_pos_neg_to_out(&mut out, &[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_pos_neg_to_out_fail_2() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_or_pos_neg_to_out(&mut out, &[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_pos_neg_to_out_fail_3() {\n    let mut out = vec![10];\n    limbs_or_pos_neg_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_or_pos_neg_in_place_left() {\n    let test = |xs_before: &[Limb], ys, b, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_slice_or_pos_neg_in_place_left(&mut xs, ys), b);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[2], &[3], false, vec![1]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![1, 2, 2]);\n    test(&[6, 7], &[1, 2, 3], true, vec![1, 0]);\n    test(&[1, 2, 3], &[6, 7], false, vec![5, 5, 0]);\n    test(&[100, 101, 102], &[102, 101, 100], false, vec![2, 0, 0]);\n    test(&[0, 0, 1], &[3], false, vec![3, 0, 0]);\n    test(&[3], &[0, 0, 1], true, vec![0xfffffffd]);\n    test(&[0, 3, 3], &[0, 0, 3], false, vec![0, 0xfffffffd, 0]);\n    test(&[0, 0, 3], &[0, 3, 3], false, vec![0, 3, 0]);\n    test(&[0, 3], &[0, 0, 3], true, vec![0, 0xfffffffd]);\n    test(&[0, 0, 3], &[0, 3], false, vec![0, 3, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_or_pos_neg_in_place_left_fail_1() {\n    limbs_slice_or_pos_neg_in_place_left(&mut [0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_or_pos_neg_in_place_left_fail_2() {\n    limbs_slice_or_pos_neg_in_place_left(&mut [3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_or_pos_neg_in_place_left_fail_1() {\n    limbs_vec_or_pos_neg_in_place_left(&mut vec![0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_or_pos_neg_in_place_left_fail_2() {\n    limbs_vec_or_pos_neg_in_place_left(&mut vec![3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_pos_neg_in_place_right_fail_1() {\n    limbs_or_pos_neg_in_place_right(&[0, 0, 0], &mut [3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_pos_neg_in_place_right_fail_2() {\n    limbs_or_pos_neg_in_place_right(&[3], &mut [0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_neg_neg_and_limbs_vec_or_neg_neg_in_place_left() {\n    let test = |xs_before, ys, out| {\n        assert_eq!(limbs_or_neg_neg(xs_before, ys), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_vec_or_neg_neg_in_place_left(&mut xs, ys);\n        assert_eq!(xs, out);\n    };\n    test(&[2], &[3], vec![1]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 0, 1]);\n    test(&[6, 7], &[1, 2, 3], vec![1, 2]);\n    test(&[1, 2, 3], &[6, 7], vec![1, 2]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![98, 101, 100]);\n    test(&[0, 0, 1], &[3], vec![3]);\n    test(&[3], &[0, 0, 1], vec![3]);\n    test(&[0, 3, 3], &[0, 0, 3], vec![0, 3, 2]);\n    test(&[0, 0, 3], &[0, 3, 3], vec![0, 3, 2]);\n    test(&[0, 3], &[0, 0, 3], vec![0, 3]);\n    test(&[0, 0, 3], &[0, 3], vec![0, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_neg_neg_fail_1() {\n    limbs_or_neg_neg(&[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_neg_neg_fail_2() {\n    limbs_or_neg_neg(&[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_neg_neg_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_or_neg_neg_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[2], &[3], &[10, 10, 10, 10], vec![1, 10, 10, 10]);\n    test(&[1, 1, 1], &[1, 2, 3], &[10, 10, 10, 10], vec![1, 0, 1, 10]);\n    test(&[6, 7], &[1, 2, 3], &[10, 10, 10, 10], vec![1, 2, 10, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10, 10, 10, 10], vec![1, 2, 10, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![98, 101, 100, 10],\n    );\n    test(&[0, 0, 1], &[3], &[10, 10, 10, 10], vec![3, 10, 10, 10]);\n    test(&[3], &[0, 0, 1], &[10, 10, 10, 10], vec![3, 10, 10, 10]);\n    test(&[0, 3, 3], &[0, 0, 3], &[10, 10, 10, 10], vec![0, 3, 2, 10]);\n    test(&[0, 0, 3], &[0, 3, 3], &[10, 10, 10, 10], vec![0, 3, 2, 10]);\n    test(&[0, 3], &[0, 0, 3], &[10, 10, 10, 10], vec![0, 3, 10, 10]);\n    test(&[0, 0, 3], &[0, 3], &[10, 10, 10, 10], vec![0, 3, 10, 10]);\n\n    test(&[1, 2, 3], &[6, 7], &[10, 10], vec![1, 2]);\n    test(&[6, 7], &[1, 2, 3], &[10, 10], vec![1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_neg_neg_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_or_neg_neg_to_out(&mut out, &[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_neg_neg_to_out_fail_2() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_or_neg_neg_to_out(&mut out, &[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_neg_neg_to_out_fail_3() {\n    let mut out = vec![10];\n    limbs_or_neg_neg_to_out(&mut out, &[6, 7, 8], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_or_neg_neg_in_place_left() {\n    let test = |xs_before: &[Limb], ys, xs_after| {\n        let mut xs = xs_before.to_vec();\n        limbs_slice_or_neg_neg_in_place_left(&mut xs, ys);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[2], &[3], vec![1]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 0, 1]);\n    test(&[6, 7], &[1, 2, 3], vec![1, 2]);\n    test(&[1, 2, 3], &[6, 7], vec![1, 2, 0]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![98, 101, 100]);\n    test(&[0, 0, 1], &[3], vec![3, 0, 0]);\n    test(&[3], &[0, 0, 1], vec![3]);\n    test(&[0, 3, 3], &[0, 0, 3], vec![0, 3, 2]);\n    test(&[0, 0, 3], &[0, 3, 3], vec![0, 3, 2]);\n    test(&[0, 3], &[0, 0, 3], vec![0, 3]);\n    test(&[0, 0, 3], &[0, 3], vec![0, 3, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_or_neg_neg_in_place_left_fail_1() {\n    limbs_slice_or_neg_neg_in_place_left(&mut [0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_or_neg_neg_in_place_left_fail_2() {\n    limbs_slice_or_neg_neg_in_place_left(&mut [3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_or_neg_neg_in_place_left_fail_1() {\n    limbs_vec_or_neg_neg_in_place_left(&mut vec![0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_or_neg_neg_in_place_left_fail_2() {\n    limbs_vec_or_neg_neg_in_place_left(&mut vec![3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_neg_neg_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], b, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_or_neg_neg_in_place_either(&mut xs, &mut ys), b);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[2], &[3], false, vec![1], vec![3]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![1, 0, 1], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[6, 7], true, vec![1, 2, 3], vec![1, 2]);\n    test(&[6, 7], &[1, 2, 3], false, vec![1, 2], vec![1, 2, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![98, 101, 100],\n        vec![102, 101, 100],\n    );\n    test(&[0, 0, 1], &[3], true, vec![0, 0, 1], vec![3]);\n    test(&[3], &[0, 0, 1], false, vec![3], vec![0, 0, 1]);\n    test(&[0, 3, 3], &[0, 0, 3], false, vec![0, 3, 2], vec![0, 0, 3]);\n    test(&[0, 0, 3], &[0, 3, 3], false, vec![0, 3, 2], vec![0, 3, 3]);\n    test(&[0, 3], &[0, 0, 3], false, vec![0, 3], vec![0, 0, 3]);\n    test(&[0, 0, 3], &[0, 3], true, vec![0, 0, 3], vec![0, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_neg_neg_in_place_either_fail_1() {\n    limbs_or_neg_neg_in_place_either(&mut [0, 0, 0], &mut [3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_neg_neg_in_place_either_fail_2() {\n    limbs_or_neg_neg_in_place_either(&mut [3], &mut [0, 0, 0]);\n}\n\n#[test]\nfn test_or() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n |= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n |= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() | v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u | v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() | &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u | &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!(integer_or_alt_1(&u, &v).to_string(), out);\n        assert_eq!(integer_or_alt_2(&u, &v).to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() | rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"456\", \"507\");\n    test(\"1000000000000\", \"123\", \"1000000000123\");\n    test(\"123\", \"1000000000000\", \"1000000000123\");\n    test(\"1000000000000\", \"999999999999\", \"1000000004095\");\n    test(\"12345678987654321\", \"314159265358979\", \"12347506587071667\");\n    test(\"0\", \"-123\", \"-123\");\n    test(\"123\", \"-456\", \"-389\");\n    test(\"1000000000000\", \"-123\", \"-123\");\n    test(\"123\", \"-1000000000000\", \"-999999999877\");\n    test(\"1000000000000\", \"-999999999999\", \"-4095\");\n    test(\"12345678987654321\", \"-314159265358979\", \"-1827599417347\");\n    test(\"-123\", \"0\", \"-123\");\n    test(\"-123\", \"456\", \"-51\");\n    test(\"-1000000000000\", \"123\", \"-999999999877\");\n    test(\"-123\", \"1000000000000\", \"-123\");\n    test(\"-1000000000000\", \"999999999999\", \"-1\");\n    test(\n        \"-12345678987654321\",\n        \"314159265358979\",\n        \"-12033347321712689\",\n    );\n    test(\"-123\", \"-456\", \"-67\");\n    test(\"-1000000000000\", \"-123\", \"-123\");\n    test(\"-123\", \"-1000000000000\", \"-123\");\n    test(\"-1000000000000\", \"-999999999999\", \"-999999999999\");\n    test(\"-12345678987654321\", \"-314159265358979\", \"-312331665941633\");\n\n    test(\n        \"17561442137713604341197\",\n        \"-533163900219836\",\n        \"-75045493870643\",\n    );\n    test(\n        \"-18446744013580009457\",\n        \"-18446673704965373937\",\n        \"-18446673644835831793\",\n    );\n    test(\n        \"-18446673704965373937\",\n        \"-18446744013580009457\",\n        \"-18446673644835831793\",\n    );\n    test(\n        \"-324518553658389833295008601473024\",\n        \"317057721155483154675232931839\",\n        \"-324201495937234350140333368541185\",\n    );\n    test(\n        \"317057721155483154675232931839\",\n        \"-324518553658389833295008601473024\",\n        \"-324201495937234350140333368541185\",\n    );\n    test(\n        \"-324201495937234350140333368541185\",\n        \"-324518553658389833295008601473024\",\n        \"-324201495937234350140333368541185\",\n    );\n    test(\n        \"-324518553658389833295008601473024\",\n        \"-324201495937234350140333368541185\",\n        \"-324201495937234350140333368541185\",\n    );\n    test(\n        \"576458553284361984\",\n        \"-10889035741470030830237691627457877114880\",\n        \"-10889035741470030830237115168904592752896\",\n    );\n    test(\n        \"-26298808336\",\n        \"170141183460469156173823577801560686592\",\n        \"-26298808336\",\n    );\n    test(\n        \"-4363947867655\",\n        \"-158453907176889445928738488320\",\n        \"-4363947867655\",\n    );\n}\n\n#[test]\nfn limbs_neg_or_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(limbs_neg_or_limb(&xs, y)),\n            -Natural::from_owned_limbs_asc(xs) | Integer::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_neg_or_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_neg_or_limb_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            assert_eq!(\n                -Natural::from_limbs_asc(&out[..len]),\n                -Natural::from_owned_limbs_asc(xs) | Integer::from(y),\n            );\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_neg_or_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_neg_or_limb_in_place(&mut xs, y);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(xs),\n            -Natural::from_owned_limbs_asc(old_xs) | Integer::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_pos_or_neg_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            limbs_pos_or_neg_limb(&xs, y),\n            -(Integer::from(Natural::from_owned_limbs_asc(xs))\n                | Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]))\n        );\n    });\n}\n\n#[test]\nfn limbs_neg_or_neg_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            limbs_neg_or_neg_limb(&xs, y),\n            -(-Natural::from_owned_limbs_asc(xs)\n                | Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]))\n        );\n    });\n}\n\n#[test]\nfn limbs_or_pos_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(limbs_or_pos_neg(&xs, &ys)),\n            Integer::from(Natural::from_owned_limbs_asc(xs)) | -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_or_pos_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_33().test_properties_with_config(&config, |(mut out, ys, xs)| {\n        let out_old = out.clone();\n        limbs_or_pos_neg_to_out(&mut out, &xs, &ys);\n        let len = ys.len();\n        assert_eq!(\n            -Natural::from_limbs_asc(&out[..len]),\n            Integer::from(Natural::from_owned_limbs_asc(xs)) | -Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_slice_or_pos_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        if limbs_slice_or_pos_neg_in_place_left(&mut xs, &ys) {\n            let mut out = Natural::exact_from(\n                -(Integer::from(Natural::from_owned_limbs_asc(xs_old))\n                    | -Natural::from_owned_limbs_asc(ys)),\n            )\n            .to_limbs_asc();\n            out.resize(xs.len(), 0);\n            assert_eq!(out, xs);\n        } else {\n            assert_eq!(\n                -Natural::from_owned_limbs_asc(xs),\n                Integer::from(Natural::from_owned_limbs_asc(xs_old))\n                    | -Natural::from_owned_limbs_asc(ys)\n            );\n        }\n    });\n}\n\n#[test]\nfn limbs_vec_or_pos_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_vec_or_pos_neg_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(xs),\n            Integer::from(Natural::from_owned_limbs_asc(xs_old))\n                | -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_or_pos_neg_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, mut ys)| {\n        let ys_old = ys.clone();\n        limbs_or_pos_neg_in_place_right(&xs, &mut ys);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(ys),\n            Integer::from(Natural::from_owned_limbs_asc(xs))\n                | -Natural::from_owned_limbs_asc(ys_old)\n        );\n    });\n}\n\n#[test]\nfn limbs_or_neg_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(limbs_or_neg_neg(&xs, &ys)),\n            -Natural::from_owned_limbs_asc(xs) | -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_or_neg_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_35().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_or_neg_neg_to_out(&mut out, &xs, &ys);\n        let len = min(xs.len(), ys.len());\n        let result = Natural::exact_from(\n            -(-Natural::from_owned_limbs_asc(xs) | -Natural::from_owned_limbs_asc(ys)),\n        );\n        let mut expected_limbs = result.into_limbs_asc();\n        expected_limbs.resize(len, 0);\n        assert_eq!(&out[..len], expected_limbs);\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_slice_or_neg_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_slice_or_neg_neg_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(xs),\n            -Natural::from_owned_limbs_asc(xs_old) | -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_vec_or_neg_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_vec_or_neg_neg_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(xs),\n            -Natural::from_owned_limbs_asc(xs_old) | -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_or_neg_neg_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_or_neg_neg_in_place_either(&mut xs, &mut ys);\n        let expected = -Natural::from_limbs_asc(&xs_old) | -Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(-Natural::from_owned_limbs_asc(ys), expected);\n        } else {\n            assert_eq!(-Natural::from_owned_limbs_asc(xs), expected);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn or_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let result_val_val = x.clone() | y.clone();\n        let result_val_ref = x.clone() | &y;\n        let result_ref_val = &x | y.clone();\n        let result = &x | &y;\n        assert!(result_val_val.is_valid());\n        assert!(result_val_ref.is_valid());\n        assert!(result_ref_val.is_valid());\n        assert!(result.is_valid());\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        let mut mut_x = x.clone();\n        mut_x |= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, result);\n        let mut mut_x = x.clone();\n        mut_x |= &y;\n        assert_eq!(mut_x, result);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x |= rug::Integer::from(&y);\n        assert_eq!(Integer::from(&mut_x), result);\n\n        assert_eq!(\n            Integer::from(&(rug::Integer::from(&x) | rug::Integer::from(&y))),\n            result\n        );\n\n        assert_eq!(integer_or_alt_1(&x, &y), result);\n        assert_eq!(integer_or_alt_2(&x, &y), result);\n\n        assert_eq!(&y | &x, result);\n        assert_eq!(&result | &x, result);\n        assert_eq!(&result | &y, result);\n        assert_eq!(!(!x & !y), result);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(&x | Integer::ZERO, x);\n        assert_eq!(Integer::ZERO | &x, x);\n        assert_eq!(&x | Integer::NEGATIVE_ONE, -1);\n        assert_eq!(Integer::NEGATIVE_ONE | &x, -1);\n        assert_eq!(&x | &x, x);\n        assert_eq!(&x | !&x, -1);\n    });\n\n    integer_triple_gen().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x | y) | z, x | (y | z));\n        assert_eq!(x & (y | z), (x & y) | (x & z));\n        assert_eq!((x & y) | z, (x | z) & (y | z));\n        assert_eq!(x | (y & z), (x | y) & (x | z));\n        assert_eq!((x | y) & z, (x & z) | (y & z));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(i, j)| {\n        assert_eq!(Integer::from(i) | Integer::from(j), i | j);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) | Integer::from(&y), x | y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/set_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{BitAccess, NotAssign};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_unsigned_pair_gen_var_20;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_access::limbs_set_bit_neg;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_set_bit_neg() {\n    let test = |xs: &[Limb], index: u64, out: &[Limb]| {\n        let mut mut_xs = xs.to_vec();\n        limbs_set_bit_neg(&mut mut_xs, index);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[3, 2, 1], 100, &[3, 2, 1]);\n    test(&[0, 0, 0b1101, 0b11], 96, &[0, 0, 0b1101, 0b10]);\n    test(&[0, 0, 0b1101, 0b11], 66, &[0, 0, 0b1001, 0b11]);\n    test(&[0, 0, 0b1100, 0b11], 64, &[0, 0, 0b1011, 0b11]);\n    test(&[0, 0, 0b1101, 0b11], 32, &[0, u32::MAX, 0b1100, 0b11]);\n}\n\n#[test]\nfn test_set_bit() {\n    let test = |u, index, out| {\n        let mut n = Integer::from_str(u).unwrap();\n        n.set_bit(index);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", 10, \"1024\");\n    test(\"100\", 0, \"101\");\n    test(\"1000000000000\", 10, \"1000000001024\");\n    test(\"1000000000000\", 100, \"1267650600228229402496703205376\");\n    test(\"5\", 100, \"1267650600228229401496703205381\");\n    test(\"-1\", 5, \"-1\");\n    test(\"-1\", 100, \"-1\");\n    test(\"-33\", 5, \"-1\");\n    test(\"-1267650600228229401496703205377\", 100, \"-1\");\n    test(\"-32\", 0, \"-31\");\n    test(\"-1000000000000\", 10, \"-999999998976\");\n    test(\"-1000000000000\", 100, \"-1000000000000\");\n    test(\"-1267650600228229402496703205376\", 100, \"-1000000000000\");\n    test(\"-18446744078004518912\", 0, \"-18446744078004518911\");\n    test(\"-18446744078004518912\", 32, \"-18446744078004518912\");\n    test(\"-18446744078004518912\", 33, \"-18446744078004518912\");\n    test(\"-18446744078004518912\", 64, \"-4294967296\");\n    test(\"-18446744078004518912\", 65, \"-18446744078004518912\");\n    test(\"-4294967296\", 0, \"-4294967295\");\n}\n\n#[test]\nfn limbs_set_bit_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(\n        &config,\n        |(mut xs, index)| {\n            let mut n = -Natural::from_limbs_asc(&xs);\n            limbs_set_bit_neg(&mut xs, index);\n            n.set_bit(index);\n            assert_eq!(-Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn set_bit_properties() {\n    integer_unsigned_pair_gen_var_2().test_properties(|(n, index)| {\n        let mut mut_n = n.clone();\n        mut_n.set_bit(index);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let mut mut_n = n.clone();\n        mut_n.assign_bit(index, true);\n        assert_eq!(mut_n, result);\n\n        assert_eq!(&n | Integer::power_of_2(index), result);\n\n        assert_ne!(result, 0);\n        assert!(result >= n);\n        if n.get_bit(index) {\n            assert_eq!(result, n);\n        } else {\n            assert_ne!(result, n);\n            let mut mut_result = result.clone();\n            mut_result.clear_bit(index);\n            assert_eq!(mut_result, n);\n        }\n\n        let mut mut_not_n = !n;\n        mut_not_n.clear_bit(index);\n        mut_not_n.not_assign();\n        assert_eq!(mut_not_n, result);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::generators::signed_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{integer_gen, natural_gen};\nuse num::BigInt;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_significant_bits() {\n    let test = |n, out| {\n        assert_eq!(Integer::from_str(n).unwrap().significant_bits(), out);\n        assert_eq!(u64::wrapping_from(BigInt::from_str(n).unwrap().bits()), out);\n        assert_eq!(\n            u64::from(rug::Integer::from_str(n).unwrap().significant_bits()),\n            out\n        );\n    };\n    test(\"0\", 0);\n    test(\"100\", 7);\n    test(\"-100\", 7);\n    test(\"1000000000000\", 40);\n    test(\"-1000000000000\", 40);\n}\n\n#[test]\nfn significant_bits_properties() {\n    integer_gen().test_properties(|x| {\n        let bits = x.significant_bits();\n        assert_eq!(u64::wrapping_from(BigInt::from(&x).bits()), bits);\n        assert_eq!(u64::from(rug::Integer::from(&x).significant_bits()), bits);\n        assert_eq!((-&x).significant_bits(), bits);\n        let x_abs = x.abs();\n        assert_eq!(x_abs <= Limb::MAX, bits <= Limb::WIDTH);\n        if x_abs != 0 {\n            assert!(Natural::power_of_2(bits - 1) <= x_abs);\n            assert!(x_abs < Natural::power_of_2(bits));\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(Integer::from(&n).significant_bits(), n.significant_bits());\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(Integer::from(i).significant_bits(), i.significant_bits());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{bool_vec_gen, bool_vec_gen_var_5, signed_gen};\nuse malachite_base::test_util::num::logic::bit_convertible::{to_bits_asc_alt, to_bits_desc_alt};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::bit_convertible::{\n    bits_slice_to_twos_complement_bits_negative, bits_to_twos_complement_bits_non_negative,\n    bits_vec_to_twos_complement_bits_negative,\n};\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::to_bits::{to_bits_asc_naive, to_bits_desc_naive};\nuse std::str::FromStr;\n\n#[test]\nfn test_bits_to_twos_complement_bits_non_negative() {\n    let test = |bits: &[bool], out_bits: &[bool]| {\n        let mut mut_bits = bits.to_vec();\n        bits_to_twos_complement_bits_non_negative(&mut mut_bits);\n        assert_eq!(mut_bits, out_bits);\n    };\n    test(&[], &[]);\n    test(&[false, true, false], &[false, true, false]);\n    test(&[true, false, true], &[true, false, true, false]);\n}\n\n#[test]\nfn test_bits_slice_to_twos_complement_bits_negative() {\n    let test = |bits: &[bool], out_bits: &[bool], carry: bool| {\n        let mut mut_bits = bits.to_vec();\n        assert_eq!(\n            bits_slice_to_twos_complement_bits_negative(&mut mut_bits),\n            carry\n        );\n        assert_eq!(mut_bits, out_bits);\n    };\n    test(&[], &[], true);\n    test(&[true, false, true], &[true, true, false], false);\n    test(&[false, false, false], &[false, false, false], true);\n}\n\n#[test]\nfn test_bits_vec_to_twos_complement_bits_negative() {\n    let test = |bits: &[bool], out_bits: &[bool]| {\n        let mut mut_bits = bits.to_vec();\n        bits_vec_to_twos_complement_bits_negative(&mut mut_bits);\n        assert_eq!(mut_bits, out_bits);\n    };\n    test(&[true, false, false], &[true, true, true]);\n    test(&[true, false, true], &[true, true, false, true]);\n}\n\n#[test]\n#[should_panic]\nfn bits_vec_to_twos_complement_bits_negative_fail() {\n    let mut mut_bits = vec![false, false];\n    bits_vec_to_twos_complement_bits_negative(&mut mut_bits);\n}\n\n#[test]\nfn test_to_bits_asc() {\n    let test = |n, out| {\n        let n = Integer::from_str(n).unwrap();\n        assert_eq!(n.bits().collect_vec(), out);\n        assert_eq!(n.to_bits_asc(), out);\n        assert_eq!(to_bits_asc_naive(&n), out);\n        assert_eq!(to_bits_asc_alt(&n), out);\n    };\n    test(\"0\", vec![]);\n    test(\"1\", vec![true, false]);\n    test(\"-1\", vec![true]);\n    test(\"6\", vec![false, true, true, false]);\n    test(\"-6\", vec![false, true, false, true]);\n    test(\n        \"105\",\n        vec![true, false, false, true, false, true, true, false],\n    );\n    test(\n        \"-105\",\n        vec![true, true, true, false, true, false, false, true],\n    );\n    test(\n        \"1000000000000\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, false, false, false, true, false, true, false, false, true, false, true, false,\n            false, true, false, true, false, true, true, false, false, false, true, false, true,\n            true, true, false,\n        ],\n    );\n    test(\n        \"-1000000000000\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, true, true, true, false, true, false, true, true, false, true, false, true, true,\n            false, true, false, true, false, false, true, true, true, false, true, false, false,\n            false, true,\n        ],\n    );\n    test(\n        \"4294967295\",\n        vec![\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, false,\n        ],\n    );\n    test(\n        \"-4294967295\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, true,\n        ],\n    );\n    test(\n        \"4294967296\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, true, false,\n        ],\n    );\n    test(\n        \"-4294967296\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, true,\n        ],\n    );\n    test(\n        \"18446744073709551615\",\n        vec![\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, false,\n        ],\n    );\n    test(\n        \"-18446744073709551615\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, true,\n        ],\n    );\n    test(\n        \"18446744073709551616\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, true, false,\n        ],\n    );\n    test(\n        \"-18446744073709551616\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, true,\n        ],\n    );\n    test(\n        \"-10725406948920873257320529212268773241779870075\",\n        vec![\n            true, false, true, false, false, false, false, true, false, true, true, false, false,\n            true, false, true, false, false, true, false, false, true, false, false, true, true,\n            true, true, false, false, false, false, true, true, true, true, false, false, true,\n            false, true, false, true, true, false, true, false, false, true, false, false, false,\n            true, false, true, true, true, true, false, false, true, true, false, false, false,\n            false, true, true, true, false, false, true, true, true, true, true, false, false,\n            true, true, true, true, true, false, false, false, true, false, false, true, true,\n            false, false, false, false, true, true, false, false, true, true, false, true, false,\n            true, true, true, true, false, true, true, false, true, false, true, true, true, false,\n            false, true, true, false, true, true, false, false, true, true, true, false, true,\n            true, true, false, true, false, false, true, true, true, false, false, false, false,\n            true, true, true, true, true, false, false, false, false, true,\n        ],\n    );\n}\n\n#[test]\nfn test_to_bits_desc() {\n    let test = |n, out| {\n        let n = Integer::from_str(n).unwrap();\n        assert_eq!(n.bits().rev().collect_vec(), out);\n        assert_eq!(n.to_bits_desc(), out);\n        assert_eq!(to_bits_desc_naive(&n), out);\n        assert_eq!(to_bits_desc_alt(&n), out);\n    };\n    test(\"0\", vec![]);\n    test(\"1\", vec![false, true]);\n    test(\"-1\", vec![true]);\n    test(\"6\", vec![false, true, true, false]);\n    test(\"-6\", vec![true, false, true, false]);\n    test(\n        \"105\",\n        vec![false, true, true, false, true, false, false, true],\n    );\n    test(\n        \"-105\",\n        vec![true, false, false, true, false, true, true, true],\n    );\n    test(\n        \"1000000000000\",\n        vec![\n            false, true, true, true, false, true, false, false, false, true, true, false, true,\n            false, true, false, false, true, false, true, false, false, true, false, true, false,\n            false, false, true, false, false, false, false, false, false, false, false, false,\n            false, false, false,\n        ],\n    );\n    test(\n        \"-1000000000000\",\n        vec![\n            true, false, false, false, true, false, true, true, true, false, false, true, false,\n            true, false, true, true, false, true, false, true, true, false, true, false, true,\n            true, true, true, false, false, false, false, false, false, false, false, false, false,\n            false, false,\n        ],\n    );\n    test(\n        \"4294967295\",\n        vec![\n            false, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true,\n        ],\n    );\n    test(\n        \"-4294967295\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, true,\n        ],\n    );\n    test(\n        \"4294967296\",\n        vec![\n            false, true, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false,\n        ],\n    );\n    test(\n        \"-4294967296\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false,\n        ],\n    );\n    test(\n        \"18446744073709551615\",\n        vec![\n            false, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true,\n        ],\n    );\n    test(\n        \"-18446744073709551615\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, true,\n        ],\n    );\n    test(\n        \"18446744073709551616\",\n        vec![\n            false, true, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false,\n        ],\n    );\n    test(\n        \"-18446744073709551616\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false,\n        ],\n    );\n}\n\n#[test]\nfn bits_to_twos_complement_bits_non_negative_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    bool_vec_gen().test_properties_with_config(&config, |mut bits| {\n        bits_to_twos_complement_bits_non_negative(&mut bits);\n    });\n}\n\n#[test]\nfn bits_slice_to_twos_complement_bits_negative_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    bool_vec_gen().test_properties_with_config(&config, |mut bits| {\n        bits_slice_to_twos_complement_bits_negative(&mut bits);\n    });\n}\n\n#[test]\nfn bits_vec_to_twos_complement_bits_negative_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    bool_vec_gen_var_5().test_properties_with_config(&config, |mut bits| {\n        bits_vec_to_twos_complement_bits_negative(&mut bits);\n    });\n}\n\n#[test]\nfn to_bits_asc_properties() {\n    integer_gen().test_properties(|x| {\n        let bits = x.to_bits_asc();\n        assert_eq!(to_bits_asc_naive(&x), bits);\n        assert_eq!(to_bits_asc_alt(&x), bits);\n        assert_eq!(x.bits().collect_vec(), bits);\n        assert_eq!(Integer::from_bits_asc(bits.iter().copied()), x);\n        if x != 0 {\n            assert_eq!(*bits.last().unwrap(), x < 0);\n        }\n        let bit_len = bits.len();\n        if bit_len > 1 {\n            assert_ne!(bits[bit_len - 1], bits[bit_len - 2]);\n        }\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.to_bits_asc(), Integer::from(i).to_bits_asc());\n    });\n}\n\n#[test]\nfn to_bits_desc_properties() {\n    integer_gen().test_properties(|x| {\n        let bits = x.to_bits_desc();\n        assert_eq!(to_bits_desc_naive(&x), bits);\n        assert_eq!(to_bits_desc_alt(&x), bits);\n        assert_eq!(x.bits().rev().collect_vec(), bits);\n        assert_eq!(Integer::from_bits_desc(bits.iter().copied()), x);\n        if x != 0 {\n            assert_eq!(bits[0], x < 0);\n        }\n        if bits.len() > 1 {\n            assert_ne!(bits[0], bits[1]);\n        }\n    });\n\n    signed_gen::<SignedLimb>().test_properties(|i| {\n        assert_eq!(i.to_bits_desc(), Integer::from(i).to_bits_desc());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::logic::traits::TrailingZeros;\nuse malachite_base::test_util::generators::signed_gen_var_6;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_nz::test_util::integer::logic::trailing_zeros::integer_trailing_zeros_alt;\nuse std::str::FromStr;\n\n#[test]\nfn test_trailing_zeros() {\n    let test = |s, out| {\n        let n = Integer::from_str(s).unwrap();\n        assert_eq!(n.trailing_zeros(), out);\n        assert_eq!(integer_trailing_zeros_alt(&n), out);\n    };\n    test(\"0\", None);\n    test(\"123\", Some(0));\n    test(\"-123\", Some(0));\n    test(\"1000000000000\", Some(12));\n    test(\"-1000000000000\", Some(12));\n    test(\"4294967295\", Some(0));\n    test(\"-4294967295\", Some(0));\n    test(\"4294967296\", Some(32));\n    test(\"-4294967296\", Some(32));\n    test(\"18446744073709551615\", Some(0));\n    test(\"-18446744073709551615\", Some(0));\n    test(\"18446744073709551616\", Some(64));\n    test(\"-18446744073709551616\", Some(64));\n}\n\n#[allow(clippy::cmp_owned, clippy::useless_conversion)]\n#[test]\nfn significant_bits_properties() {\n    integer_gen().test_properties(|x| {\n        let trailing_zeros = x.trailing_zeros();\n        assert_eq!(integer_trailing_zeros_alt(&x), trailing_zeros);\n        assert_eq!(trailing_zeros.is_none(), x == 0);\n        assert_eq!((-&x).trailing_zeros(), trailing_zeros);\n        if x != 0 {\n            let trailing_zeros = trailing_zeros.unwrap();\n            assert_ne!((!&x).trailing_zeros() == Some(0), trailing_zeros == 0);\n            if trailing_zeros <= u64::from(Limb::MAX) {\n                assert!((&x >> trailing_zeros).odd());\n                assert_eq!(&x >> trailing_zeros << trailing_zeros, x);\n            }\n        }\n    });\n\n    signed_gen_var_6::<SignedLimb>().test_properties(|i| {\n        assert_eq!(\n            Integer::from(i).trailing_zeros(),\n            Some(TrailingZeros::trailing_zeros(i))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, unsigned_vec_pair_gen_var_8, unsigned_vec_triple_gen_var_34,\n    unsigned_vec_unsigned_pair_gen_var_15, unsigned_vec_unsigned_pair_gen_var_18,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::logic::xor::{\n    limbs_neg_xor_limb, limbs_neg_xor_limb_neg, limbs_neg_xor_limb_neg_in_place,\n    limbs_neg_xor_limb_neg_to_out, limbs_neg_xor_limb_to_out, limbs_pos_xor_limb_neg,\n    limbs_pos_xor_limb_neg_to_out, limbs_slice_neg_xor_limb_in_place,\n    limbs_slice_pos_xor_limb_neg_in_place, limbs_vec_neg_xor_limb_in_place,\n    limbs_vec_pos_xor_limb_neg_in_place, limbs_xor_neg_neg, limbs_xor_neg_neg_in_place_either,\n    limbs_xor_neg_neg_in_place_left, limbs_xor_neg_neg_to_out, limbs_xor_pos_neg,\n    limbs_xor_pos_neg_in_place_either, limbs_xor_pos_neg_in_place_left,\n    limbs_xor_pos_neg_in_place_right, limbs_xor_pos_neg_to_out,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen, integer_triple_gen, natural_pair_gen,\n};\nuse malachite_nz::test_util::integer::logic::xor::{integer_xor_alt_1, integer_xor_alt_2};\nuse rug;\nuse std::cmp::max;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_xor_limb_and_limbs_vec_neg_xor_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_neg_xor_limb(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_vec_neg_xor_limb_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[6, 7], 0, &[6, 7]);\n    test(&[6, 7], 2, &[8, 7]);\n    test(&[100, 101, 102], 10, &[106, 101, 102]);\n    test(&[123, 456], 789, &[880, 456]);\n    test(&[Limb::MAX - 1, Limb::MAX, Limb::MAX], 2, &[0, 0, 0, 1]);\n    test(&[0, 0, 0, 1], 2, &[Limb::MAX - 1, Limb::MAX, Limb::MAX, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_neg_xor_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        limbs_slice_neg_xor_limb_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[6, 7], 0, &[6, 7]);\n    test(&[6, 7], 2, &[8, 7]);\n    test(&[100, 101, 102], 10, &[106, 101, 102]);\n    test(&[123, 456], 789, &[880, 456]);\n    test(&[Limb::MAX - 1, Limb::MAX, Limb::MAX], 2, &[0, 0, 0]);\n    test(&[0, 0, 0, 1], 2, &[Limb::MAX - 1, Limb::MAX, Limb::MAX, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_xor_limb_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, carry, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_neg_xor_limb_to_out(&mut out, xs, y), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10], &[1], Limb::MAX, true, &[0, 10]);\n    test(&[10; 4], &[6, 7], 0, false, &[6, 7, 10, 10]);\n    test(&[10; 4], &[6, 7], 2, false, &[8, 7, 10, 10]);\n    test(&[10; 4], &[100, 101, 102], 10, false, &[106, 101, 102, 10]);\n    test(&[10; 4], &[123, 456], 789, false, &[880, 456, 10, 10]);\n    test(\n        &[10; 4],\n        &[Limb::MAX - 1, Limb::MAX, Limb::MAX],\n        2,\n        true,\n        &[0, 0, 0, 10],\n    );\n    test(\n        &[10; 4],\n        &[0, 0, 0, 1],\n        2,\n        false,\n        &[Limb::MAX - 1, Limb::MAX, Limb::MAX, 0],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_xor_limb_to_out_fail() {\n    limbs_neg_xor_limb_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_xor_limb_neg_and_limbs_vec_pos_xor_limb_neg_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_pos_xor_limb_neg(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_vec_pos_xor_limb_neg_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[0, 2], 3, &[0xfffffffd, 2]);\n    test(&[1, 2, 3], 4, &[0xfffffffb, 2, 3]);\n    test(&[2, Limb::MAX], 2, &[0, 0, 1]);\n    test(&[2, Limb::MAX, Limb::MAX], 2, &[0, 0, 0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_xor_limb_neg_fail() {\n    limbs_pos_xor_limb_neg(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_pos_xor_limb_neg_in_place_fail() {\n    let mut xs = vec![];\n    limbs_vec_pos_xor_limb_neg_in_place(&mut xs, 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pos_xor_limb_neg_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, carry, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_pos_xor_limb_neg_to_out(&mut out, xs, y), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[0, 0], &[0, 2], 3, false, &[0xfffffffd, 2]);\n    test(&[1, 2, 100], &[0, 2, 100], 3, false, &[0xfffffffd, 2, 100]);\n    test(&[0, 0, 0], &[1, 2, 3], 4, false, &[0xfffffffb, 2, 3]);\n    test(&[0, 0], &[2, Limb::MAX], 2, true, &[0, 0]);\n    test(&[0, 0, 0], &[2, Limb::MAX, Limb::MAX], 2, true, &[0, 0, 0]);\n    test(\n        &[1, 2, 3, 100],\n        &[2, Limb::MAX, Limb::MAX],\n        2,\n        true,\n        &[0, 0, 0, 100],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_xor_limb_neg_to_out_fail_1() {\n    limbs_pos_xor_limb_neg_to_out(&mut [1, 2, 3], &[1, 2, 3, 4], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pos_xor_limb_neg_to_out_fail_2() {\n    limbs_pos_xor_limb_neg_to_out(&mut [1, 2, 3], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_pos_xor_limb_neg_in_place() {\n    let test = |xs_before: &[Limb], y: Limb, carry, xs_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_slice_pos_xor_limb_neg_in_place(&mut xs, y), carry);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[0, 2], 3, false, &[0xfffffffd, 2]);\n    test(&[1, 2, 3], 4, false, &[0xfffffffb, 2, 3]);\n    test(&[2, Limb::MAX], 2, true, &[0, 0]);\n    test(&[2, Limb::MAX, Limb::MAX], 2, true, &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_pos_xor_limb_neg_in_place_fail() {\n    limbs_slice_pos_xor_limb_neg_in_place(&mut [], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_xor_limb_neg_and_limbs_neg_xor_limb_neg_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_neg_xor_limb_neg(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_neg_xor_limb_neg_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[0, 2], 3, &[3, 1]);\n    test(&[6, 7], 2, &[0xfffffff8, 7]);\n    test(&[1, 2, 3], 4, &[0xfffffffb, 2, 3]);\n    test(&[100, 101, 102], 10, &[4294967190, 101, 102]);\n    test(&[123, 456], 789, &[4294966416, 456]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_xor_limb_neg_fail() {\n    limbs_neg_xor_limb_neg(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_xor_limb_neg_in_place_fail() {\n    limbs_neg_xor_limb_neg_in_place(&mut [], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_xor_limb_neg_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_neg_xor_limb_neg_to_out(&mut out, xs, y);\n        assert_eq!(out, out_after);\n    };\n    test(&[10; 4], &[0, 2], 3, &[3, 1, 10, 10]);\n    test(&[10; 4], &[6, 7], 2, &[0xfffffff8, 7, 10, 10]);\n    test(&[10; 4], &[1, 2, 3], 4, &[0xfffffffb, 2, 3, 10]);\n    test(&[10; 4], &[100, 101, 102], 10, &[4294967190, 101, 102, 10]);\n    test(&[10; 4], &[123, 456], 789, &[4294966416, 456, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_xor_limb_neg_to_out_fail_1() {\n    limbs_neg_xor_limb_neg_to_out(&mut [], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_neg_xor_limb_neg_to_out_fail_2() {\n    limbs_neg_xor_limb_neg_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_pos_neg_limbs_xor_pos_neg_in_place_left_and_limbs_xor_pos_neg_in_place_right() {\n    let test = |xs_before, ys_before, out| {\n        assert_eq!(limbs_xor_pos_neg(xs_before, ys_before), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_xor_pos_neg_in_place_left(&mut xs, ys_before);\n        assert_eq!(xs, out);\n\n        let mut ys = ys_before.to_vec();\n        limbs_xor_pos_neg_in_place_right(xs_before, &mut ys);\n        assert_eq!(ys, out);\n    };\n    test(&[2], &[3], vec![1]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![2, 3, 2]);\n    test(&[6, 7], &[1, 2, 3], vec![7, 5, 3]);\n    test(&[1, 2, 3], &[6, 7], vec![5, 5, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![2, 0, 2]);\n    test(&[0, 0, 1], &[3], vec![3, 0, 1]);\n    test(&[3], &[0, 0, 1], vec![0xfffffffd, Limb::MAX, 0]);\n    test(&[0, 3, 3], &[0, 0, 3], vec![0, 0xfffffffd, 1]);\n    test(&[0, 0, 3], &[0, 3, 3], vec![0, 3, 0]);\n    test(&[0, 3], &[0, 0, 3], vec![0, 0xfffffffd, 2]);\n    test(&[0, 0, 3], &[0, 3], vec![0, 3, 3]);\n    test(&[0, 1], &[0, Limb::MAX, Limb::MAX], vec![0, 0, 0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_fail_1() {\n    limbs_xor_pos_neg(&[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_fail_2() {\n    limbs_xor_pos_neg(&[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_in_place_left_fail_1() {\n    limbs_xor_pos_neg_in_place_left(&mut vec![0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_in_place_left_fail_2() {\n    limbs_xor_pos_neg_in_place_left(&mut vec![3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_in_place_right_fail_1() {\n    limbs_xor_pos_neg_in_place_right(&[0, 0, 0], &mut vec![3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_in_place_right_fail_2() {\n    limbs_xor_pos_neg_in_place_right(&[3], &mut vec![0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_pos_neg_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after, carry| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_xor_pos_neg_to_out(&mut out, xs, ys), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[2], &[3], &[10; 4], vec![1, 10, 10, 10], false);\n    test(&[1, 1, 1], &[1, 2, 3], &[10; 4], vec![2, 3, 2, 10], false);\n    test(&[6, 7], &[1, 2, 3], &[10; 4], vec![7, 5, 3, 10], false);\n    test(&[1, 2, 3], &[6, 7], &[10; 4], vec![5, 5, 3, 10], false);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10; 4],\n        vec![2, 0, 2, 10],\n        false,\n    );\n    test(&[0, 0, 1], &[3], &[10; 4], vec![3, 0, 1, 10], false);\n    test(\n        &[3],\n        &[0, 0, 1],\n        &[10; 4],\n        vec![0xfffffffd, Limb::MAX, 0, 10],\n        false,\n    );\n    test(\n        &[0, 3, 3],\n        &[0, 0, 3],\n        &[10; 4],\n        vec![0, 0xfffffffd, 1, 10],\n        false,\n    );\n    test(&[0, 0, 3], &[0, 3, 3], &[10; 4], vec![0, 3, 0, 10], false);\n    test(\n        &[0, 3],\n        &[0, 0, 3],\n        &[10; 4],\n        vec![0, 0xfffffffd, 2, 10],\n        false,\n    );\n    test(&[0, 0, 3], &[0, 3], &[10; 4], vec![0, 3, 3, 10], false);\n    test(\n        &[0, 1],\n        &[0, Limb::MAX, Limb::MAX],\n        &[10; 4],\n        vec![0, 0, 0, 10],\n        true,\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_to_out_fail_1() {\n    let mut out = vec![10; 4];\n    limbs_xor_pos_neg_to_out(&mut out, &[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_to_out_fail_2() {\n    let mut out = vec![10; 4];\n    limbs_xor_pos_neg_to_out(&mut out, &[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_to_out_fail_3() {\n    let mut out = vec![10];\n    limbs_xor_pos_neg_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_pos_neg_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], b, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_xor_pos_neg_in_place_either(&mut xs, &mut ys), b);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[2], &[3], false, vec![1], vec![3]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![2, 3, 2], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[6, 7], false, vec![5, 5, 3], vec![6, 7]);\n    test(&[6, 7], &[1, 2, 3], true, vec![6, 7], vec![7, 5, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![2, 0, 2],\n        vec![102, 101, 100],\n    );\n    test(&[0, 0, 1], &[3], false, vec![3, 0, 1], vec![3]);\n    test(\n        &[3],\n        &[0, 0, 1],\n        true,\n        vec![3],\n        vec![0xfffffffd, Limb::MAX, 0],\n    );\n    test(\n        &[0, 3, 3],\n        &[0, 0, 3],\n        false,\n        vec![0, 0xfffffffd, 1],\n        vec![0, 0, 3],\n    );\n    test(&[0, 0, 3], &[0, 3, 3], false, vec![0, 3, 0], vec![0, 3, 3]);\n    test(\n        &[0, 3],\n        &[0, 0, 3],\n        true,\n        vec![0, 3],\n        vec![0, 0xfffffffd, 2],\n    );\n    test(&[0, 0, 3], &[0, 3], false, vec![0, 3, 3], vec![0, 3]);\n    test(\n        &[1, 0, 0],\n        &[Limb::MAX, Limb::MAX, Limb::MAX, Limb::MAX],\n        true,\n        vec![1, 0, 0],\n        vec![0, 0, 0, 0, 1],\n    );\n    test(\n        &[0, 1],\n        &[0, Limb::MAX, Limb::MAX],\n        true,\n        vec![0, 1],\n        vec![0, 0, 0, 1],\n    );\n    test(\n        &[Limb::MAX, Limb::MAX, Limb::MAX, Limb::MAX],\n        &[1, 0, 0],\n        false,\n        vec![0, 0, 0, 0, 1],\n        vec![1, 0, 0],\n    );\n    test(\n        &[0, Limb::MAX, Limb::MAX],\n        &[0, 1],\n        false,\n        vec![0, 0, 0, 1],\n        vec![0, 1],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_in_place_either_fail_1() {\n    limbs_xor_pos_neg_in_place_either(&mut vec![0, 0, 0], &mut vec![3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_pos_neg_in_place_either_fail_2() {\n    limbs_xor_pos_neg_in_place_either(&mut vec![3], &mut vec![0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_neg_neg_and_limbs_xor_neg_neg_in_place_left() {\n    let test = |xs_before, ys, out| {\n        assert_eq!(limbs_xor_neg_neg(xs_before, ys), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_xor_neg_neg_in_place_left(&mut xs, ys);\n        assert_eq!(xs, out);\n    };\n    test(&[2], &[3], vec![3]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![0, 3, 2]);\n    test(&[6, 7], &[1, 2, 3], vec![5, 5, 3]);\n    test(&[1, 2, 3], &[6, 7], vec![5, 5, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![6, 0, 2]);\n    test(&[0, 0, 1], &[3], vec![0xfffffffd, Limb::MAX, 0]);\n    test(&[3], &[0, 0, 1], vec![0xfffffffd, Limb::MAX, 0]);\n    test(&[0, 3, 3], &[0, 0, 3], vec![0, 0xfffffffd, 1]);\n    test(&[0, 0, 3], &[0, 3, 3], vec![0, 0xfffffffd, 1]);\n    test(&[0, 3], &[0, 0, 3], vec![0, 0xfffffffd, 2]);\n    test(&[0, 0, 3], &[0, 3], vec![0, 0xfffffffd, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_neg_neg_in_place_left_fail_1() {\n    limbs_xor_neg_neg_in_place_left(&mut vec![0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_neg_neg_in_place_left_fail_2() {\n    limbs_xor_neg_neg_in_place_left(&mut vec![3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_neg_neg_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_xor_neg_neg_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[2], &[3], &[10; 4], vec![3, 10, 10, 10]);\n    test(&[1, 1, 1], &[1, 2, 3], &[10; 4], vec![0, 3, 2, 10]);\n    test(&[6, 7], &[1, 2, 3], &[10; 4], vec![5, 5, 3, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10; 4], vec![5, 5, 3, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10; 4],\n        vec![6, 0, 2, 10],\n    );\n    test(\n        &[0, 0, 1],\n        &[3],\n        &[10; 4],\n        vec![0xfffffffd, Limb::MAX, 0, 10],\n    );\n    test(\n        &[3],\n        &[0, 0, 1],\n        &[10; 4],\n        vec![0xfffffffd, Limb::MAX, 0, 10],\n    );\n    test(&[0, 3, 3], &[0, 0, 3], &[10; 4], vec![0, 0xfffffffd, 1, 10]);\n    test(&[0, 0, 3], &[0, 3, 3], &[10; 4], vec![0, 0xfffffffd, 1, 10]);\n    test(&[0, 3], &[0, 0, 3], &[10; 4], vec![0, 0xfffffffd, 2, 10]);\n    test(&[0, 0, 3], &[0, 3], &[10; 4], vec![0, 0xfffffffd, 2, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_neg_neg_to_out_fail_1() {\n    let mut out = vec![10; 4];\n    limbs_xor_neg_neg_to_out(&mut out, &[0, 0, 0], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_neg_neg_to_out_fail_2() {\n    let mut out = vec![10; 4];\n    limbs_xor_neg_neg_to_out(&mut out, &[3], &[0, 0, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_neg_neg_to_out_fail_3() {\n    let mut out = vec![10];\n    limbs_xor_neg_neg_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_neg_neg_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], b, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_xor_neg_neg_in_place_either(&mut xs, &mut ys), b);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[2], &[3], false, vec![3], vec![3]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![0, 3, 2], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[6, 7], false, vec![5, 5, 3], vec![6, 7]);\n    test(&[6, 7], &[1, 2, 3], true, vec![6, 7], vec![5, 5, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![6, 0, 2],\n        vec![102, 101, 100],\n    );\n    test(\n        &[0, 0, 1],\n        &[3],\n        false,\n        vec![0xfffffffd, Limb::MAX, 0],\n        vec![3],\n    );\n    test(\n        &[3],\n        &[0, 0, 1],\n        true,\n        vec![3],\n        vec![0xfffffffd, Limb::MAX, 0],\n    );\n    test(\n        &[0, 3, 3],\n        &[0, 0, 3],\n        false,\n        vec![0, 0xfffffffd, 1],\n        vec![0, 0, 3],\n    );\n    test(\n        &[0, 0, 3],\n        &[0, 3, 3],\n        false,\n        vec![0, 0xfffffffd, 1],\n        vec![0, 3, 3],\n    );\n    test(\n        &[0, 3],\n        &[0, 0, 3],\n        true,\n        vec![0, 3],\n        vec![0, 0xfffffffd, 2],\n    );\n    test(\n        &[0, 0, 3],\n        &[0, 3],\n        false,\n        vec![0, 0xfffffffd, 2],\n        vec![0, 3],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_neg_neg_in_place_either_fail_1() {\n    limbs_xor_neg_neg_in_place_either(&mut [0, 0, 0], &mut [3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_neg_neg_in_place_either_fail_2() {\n    limbs_xor_neg_neg_in_place_either(&mut [3], &mut [0, 0, 0]);\n}\n\n#[test]\nfn test_xor() {\n    let test = |s, t, out| {\n        let u = Integer::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n ^= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n ^= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() ^ v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u ^ v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() ^ &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u ^ &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!(integer_xor_alt_1(&u, &v).to_string(), out);\n        assert_eq!(integer_xor_alt_2(&u, &v).to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() ^ rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"456\", \"435\");\n    test(\"1000000000000\", \"123\", \"1000000000123\");\n    test(\"123\", \"1000000000000\", \"1000000000123\");\n    test(\"1000000000000\", \"999999999999\", \"8191\");\n    test(\"12345678987654321\", \"314159265358979\", \"12035174921130034\");\n    test(\"0\", \"-123\", \"-123\");\n    test(\"123\", \"-456\", \"-445\");\n    test(\"1000000000000\", \"-123\", \"-1000000000123\");\n    test(\"123\", \"-1000000000000\", \"-999999999877\");\n    test(\"1000000000000\", \"-999999999999\", \"-8191\");\n    test(\n        \"12345678987654321\",\n        \"-314159265358979\",\n        \"-12035174921130036\",\n    );\n    test(\"-123\", \"0\", \"-123\");\n    test(\"-123\", \"456\", \"-435\");\n    test(\"-1000000000000\", \"123\", \"-999999999877\");\n    test(\"-123\", \"1000000000000\", \"-1000000000123\");\n    test(\"-1000000000000\", \"999999999999\", \"-1\");\n    test(\n        \"-12345678987654321\",\n        \"314159265358979\",\n        \"-12035174921130036\",\n    );\n    test(\"-123\", \"-456\", \"445\");\n    test(\"-1000000000000\", \"-123\", \"999999999877\");\n    test(\"-123\", \"-1000000000000\", \"999999999877\");\n    test(\"-1000000000000\", \"-999999999999\", \"1\");\n    test(\n        \"-12345678987654321\",\n        \"-314159265358979\",\n        \"12035174921130034\",\n    );\n\n    test(\n        \"-58833344151816\",\n        \"-163347918670491773353\",\n        \"163347906017862822063\",\n    );\n    test(\n        \"-163347918670491773353\",\n        \"-58833344151816\",\n        \"163347906017862822063\",\n    );\n    test(\n        \"4722366342132156858368\",\n        \"-35201550909443\",\n        \"-4722366377333707767811\",\n    );\n    test(\n        \"-35201550909443\",\n        \"4722366342132156858368\",\n        \"-4722366377333707767811\",\n    );\n    test(\n        \"-26298808336\",\n        \"170141183460469156173823577801560686592\",\n        \"-170141183460469156173823577827859494928\",\n    );\n    test(\n        \"170141183460469156173823577801560686592\",\n        \"-26298808336\",\n        \"-170141183460469156173823577827859494928\",\n    );\n    test(\n        \"-19191697422411034898997120\",\n        \"-748288838313422294120286634350663119087542623797248\",\n        \"748288838313422294120286615158965696676507724800128\",\n    );\n    test(\n        \"-748288838313422294120286634350663119087542623797248\",\n        \"-19191697422411034898997120\",\n        \"748288838313422294120286615158965696676507724800128\",\n    );\n    test(\n        \"4294967296\",\n        \"-79228162514264337589248983040\",\n        \"-79228162514264337593543950336\",\n    );\n    test(\n        \"-79228162514264337589248983040\",\n        \"4294967296\",\n        \"-79228162514264337593543950336\",\n    );\n}\n\n#[test]\nfn limbs_neg_or_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(limbs_neg_xor_limb(&xs, y)),\n            -Natural::from_owned_limbs_asc(xs) ^ Integer::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_neg_xor_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            let len = xs.len();\n            if limbs_neg_xor_limb_to_out(&mut out, &xs, y) {\n                let mut result =\n                    Natural::exact_from(-(-Natural::from_owned_limbs_asc(xs) ^ Integer::from(y)))\n                        .to_limbs_asc();\n                result.resize(len, 0);\n                assert_eq!(result, &out[..len]);\n            } else {\n                assert_eq!(\n                    -Natural::from_limbs_asc(&out[..len]),\n                    -Natural::from_owned_limbs_asc(xs) ^ Integer::from(y),\n                );\n            }\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_neg_xor_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        if limbs_slice_neg_xor_limb_in_place(&mut xs, y) {\n            let xor =\n                Integer::from(Natural::from_owned_limbs_asc(old_xs.clone())) ^ Integer::from(y);\n            if xor <= 0 {\n                let mut result = Natural::exact_from(-xor).to_limbs_asc();\n                result.resize(xs.len(), 0);\n                assert_eq!(result, xs);\n            }\n        } else {\n            assert_eq!(\n                -Natural::from_owned_limbs_asc(xs),\n                -Natural::from_owned_limbs_asc(old_xs) ^ Integer::from(y)\n            );\n        }\n    });\n}\n\n#[test]\nfn limbs_vec_neg_xor_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_vec_neg_xor_limb_in_place(&mut xs, y);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(xs),\n            -Natural::from_owned_limbs_asc(old_xs) ^ Integer::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_pos_xor_limb_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(xs, y)| {\n        let out = limbs_pos_xor_limb_neg(&xs, y);\n        let n = Integer::from(Natural::from_owned_limbs_asc(xs))\n            ^ Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        assert_eq!(Natural::from_owned_limbs_asc(out), Natural::exact_from(-n));\n    });\n}\n\n#[test]\nfn limbs_pos_xor_limb_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_pos_xor_limb_neg_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            let n = Integer::from(Natural::from_owned_limbs_asc(xs))\n                ^ Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n            let mut result = Natural::exact_from(-n).into_limbs_asc();\n            result.resize(len, 0);\n            assert_eq!(result, &out[..len]);\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_pos_xor_limb_neg_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(mut xs, y)| {\n        let n = Integer::from(Natural::from_limbs_asc(&xs))\n            ^ Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        let carry = limbs_slice_pos_xor_limb_neg_in_place(&mut xs, y);\n        if carry {\n            let result = Natural::exact_from(-n);\n            let result = result.as_limbs_asc();\n            assert_eq!(xs, &result[..xs.len()]);\n        } else {\n            assert_eq!(Natural::from_owned_limbs_asc(xs), Natural::exact_from(-n));\n        }\n    });\n}\n\n#[test]\nfn limbs_vec_pos_xor_limb_neg_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(mut xs, y)| {\n        let n = Integer::from(Natural::from_limbs_asc(&xs))\n            ^ Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        limbs_vec_pos_xor_limb_neg_in_place(&mut xs, y);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), Natural::exact_from(-n));\n    });\n}\n\n#[test]\nfn limbs_neg_xor_limb_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(xs, y)| {\n        let out = limbs_neg_xor_limb_neg(&xs, y);\n        let n = -Natural::from_owned_limbs_asc(xs)\n            ^ Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        assert_eq!(Natural::from_owned_limbs_asc(out), Natural::exact_from(n));\n    });\n}\n\n#[test]\nfn limbs_neg_xor_limb_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_5().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_neg_xor_limb_neg_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            let n = -Natural::from_owned_limbs_asc(xs)\n                ^ Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n            let mut limbs = Natural::exact_from(n).into_limbs_asc();\n            limbs.resize(len, 0);\n            assert_eq!(limbs, &out[..len]);\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_neg_xor_limb_neg_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_18().test_properties_with_config(&config, |(mut xs, y)| {\n        let n = -Natural::from_limbs_asc(&xs)\n            ^ Integer::from_owned_twos_complement_limbs_asc(vec![y, Limb::MAX]);\n        limbs_neg_xor_limb_neg_in_place(&mut xs, y);\n        let mut expected_limbs = Natural::exact_from(n).into_limbs_asc();\n        expected_limbs.resize(xs.len(), 0);\n        assert_eq!(xs, expected_limbs);\n    });\n}\n\n#[test]\nfn limbs_xor_pos_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(limbs_xor_pos_neg(&xs, &ys)),\n            Integer::from(Natural::from_owned_limbs_asc(xs)) ^ -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_xor_pos_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_34().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        let carry = limbs_xor_pos_neg_to_out(&mut out, &xs, &ys);\n        let len = max(xs.len(), ys.len());\n        let mut result = out[..len].to_vec();\n        if carry {\n            result.push(1);\n        }\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(result),\n            Integer::from(Natural::from_owned_limbs_asc(xs)) ^ -Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_xor_pos_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_xor_pos_neg_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(xs),\n            Integer::from(Natural::from_owned_limbs_asc(xs_old))\n                ^ -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_xor_pos_neg_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, mut ys)| {\n        let ys_old = ys.clone();\n        limbs_xor_pos_neg_in_place_right(&xs, &mut ys);\n        assert_eq!(\n            -Natural::from_owned_limbs_asc(ys),\n            Integer::from(Natural::from_owned_limbs_asc(xs))\n                ^ -Natural::from_owned_limbs_asc(ys_old)\n        );\n    });\n}\n\n#[test]\nfn limbs_xor_pos_neg_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_xor_pos_neg_in_place_either(&mut xs, &mut ys);\n        let expected =\n            Integer::from(Natural::from_limbs_asc(&xs_old)) ^ -Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(-Natural::from_owned_limbs_asc(ys), expected);\n        } else {\n            assert_eq!(-Natural::from_owned_limbs_asc(xs), expected);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[test]\nfn limbs_xor_neg_neg_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_xor_neg_neg(&xs, &ys)),\n            -Natural::from_owned_limbs_asc(xs) ^ -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_xor_neg_neg_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_34().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_xor_neg_neg_to_out(&mut out, &xs, &ys);\n        let len = max(xs.len(), ys.len());\n        let result = Natural::exact_from(\n            -Natural::from_owned_limbs_asc(xs) ^ -Natural::from_owned_limbs_asc(ys),\n        );\n        let mut expected = result.to_limbs_asc();\n        expected.resize(len, 0);\n        assert_eq!(&out[..len], expected.as_slice());\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_xor_neg_neg_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_xor_neg_neg_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            -Natural::from_owned_limbs_asc(xs_old) ^ -Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_xor_neg_neg_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_8().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_xor_neg_neg_in_place_either(&mut xs, &mut ys);\n        let expected = -Natural::from_limbs_asc(&xs_old) ^ -Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(Natural::from_owned_limbs_asc(ys), expected);\n        } else {\n            assert_eq!(Natural::from_owned_limbs_asc(xs), expected);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn xor_properties() {\n    integer_pair_gen().test_properties(|(x, y)| {\n        let result_val_val = x.clone() ^ y.clone();\n        let result_val_ref = x.clone() ^ &y;\n        let result_ref_val = &x ^ y.clone();\n        let result = &x ^ &y;\n        assert!(result_val_val.is_valid());\n        assert!(result_val_ref.is_valid());\n        assert!(result_ref_val.is_valid());\n        assert!(result.is_valid());\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        let mut mut_x = x.clone();\n        mut_x ^= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, result);\n        let mut mut_x = x.clone();\n        mut_x ^= &y;\n        assert_eq!(mut_x, result);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x ^= rug::Integer::from(&y);\n        assert_eq!(Integer::from(&mut_x), result);\n\n        assert_eq!(\n            Integer::from(&(rug::Integer::from(&x) ^ rug::Integer::from(&y))),\n            result\n        );\n\n        assert_eq!(integer_xor_alt_1(&x, &y), result);\n        assert_eq!(integer_xor_alt_2(&x, &y), result);\n\n        assert_eq!(&y ^ &x, result);\n        assert_eq!(&result ^ &x, y);\n        assert_eq!(&result ^ &y, x);\n        assert_eq!(!&x ^ !&y, result);\n        assert_eq!(!(&x ^ !&y), result);\n        assert_eq!(!(!x ^ y), result);\n    });\n\n    integer_gen().test_properties(|ref x| {\n        assert_eq!(x ^ Integer::ZERO, *x);\n        assert_eq!(Integer::ZERO ^ x, *x);\n        assert_eq!(x ^ Integer::NEGATIVE_ONE, !x);\n        assert_eq!(Integer::NEGATIVE_ONE ^ x, !x);\n        assert_eq!(x ^ x, 0);\n        assert_eq!(x ^ !x, -1);\n        assert_eq!(!x ^ x, -1);\n    });\n\n    integer_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x ^ &y) ^ &z, x ^ (y ^ z));\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(i, j)| {\n        assert_eq!(Integer::from(i) ^ Integer::from(j), i ^ j);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Integer::from(&x) ^ Integer::from(&y), x ^ y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_random_integer_from_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Pow;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::random::{VariableRangeGenerator, random_primitive_ints};\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_random_integer_from_range_to_infinity;\nuse std::str::FromStr;\n\nfn get_random_integer_from_range_to_infinity_helper(\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    out: &str,\n) {\n    let mut xs = random_primitive_ints(EXAMPLE_SEED.fork(\"ints\"));\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_random_integer_from_range_to_infinity(\n                &mut xs,\n                &mut vrg,\n                Integer::from_str(a).unwrap(),\n                mean_bits_numerator,\n                mean_bits_denominator,\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_random_integer_from_range_to_infinity() {\n    get_random_integer_from_range_to_infinity_helper(\"0\", 1, 1, \"[0, 1, 4, 1, 2, 1, 1, 0, 0, 0]\");\n    get_random_integer_from_range_to_infinity_helper(\n        \"0\",\n        10,\n        1,\n        \"[7, 7816, 428, 130, 1, 141, 10, 0, 4, 4483]\",\n    );\n    get_random_integer_from_range_to_infinity_helper(\n        \"0\",\n        100,\n        1,\n        \"[5101205056696451696397798478058511, 1562796, 8799850658374624318722, \\\n        432133157539661383965541544934515144954635954990115469923269847259651409024994917000655083\\\n        9187394388518593842616549212512013, \\\n        279353891976332938189472063076409154515, 1660357170525, \\\n        143642188899218739960634489126387586224289351782452807884934768151051511265288490384892849\\\n        22660727526851378407, 86075361492, 353552745516847393429177033516378899307448925328642, \\\n        577340679116474858586805525866181088123189468507069123812855481357566943854]\",\n    );\n    get_random_integer_from_range_to_infinity_helper(\n        \"1000\",\n        11,\n        1,\n        \"[1015, 1672, 6316, 1282, 3037, 1805, 1122, 1003, 1014, 1019]\",\n    );\n    get_random_integer_from_range_to_infinity_helper(\n        \"1000\",\n        100,\n        1,\n        \"[1206982412795330974999926231143439, 457693356, 169360311075942561584386, \\\n        156864198081133600182484993110222733524619588763603298779764468364382591713280608608755884\\\n        131404116709444244598775565, 66677412650746398524862933431554022355, 26949124609373, \\\n        102746416386110194533593072869947149634954555999655687951279670456046799992002349096588693\\\n        3126118631, 22626063730900, 2792352557430693060292673664470974590025115014402, \\\n        68488724460300171666815845652220555564874106206890863873832895385292448366]\",\n    );\n    get_random_integer_from_range_to_infinity_helper(\n        \"-1000\",\n        1,\n        1,\n        \"[-3, -2, -1, 1, 29, -3, 0, 0, -1, 0]\",\n    );\n    get_random_integer_from_range_to_infinity_helper(\n        \"-1000\",\n        11,\n        1,\n        \"[-3, 136, -1, 2, -3, -731, 981996642, 764, 0, 1411]\",\n    );\n    get_random_integer_from_range_to_infinity_helper(\n        \"-1000\",\n        100,\n        1,\n        \"[70671, 33609936868504473224, 3330, 6514514285313835997, \\\n        141387787476503121093422704441276431644102874620098798311586658867138567258580573643023899\\\n        16124485683507351766006393560845, 250798235515229707219, 136491265145933085529437, \\\n        303813780, 816375814318068602464139315741117, -237]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_random_integer_from_range_to_infinity_fail_1() {\n    get_random_integer_from_range_to_infinity(\n        &mut random_primitive_ints(EXAMPLE_SEED.fork(\"ints\")),\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_random_integer_from_range_to_infinity_fail_2() {\n    get_random_integer_from_range_to_infinity(\n        &mut random_primitive_ints(EXAMPLE_SEED.fork(\"ints\")),\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        2,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_random_integer_from_range_to_infinity_fail_3() {\n    get_random_integer_from_range_to_infinity(\n        &mut random_primitive_ints(EXAMPLE_SEED.fork(\"ints\")),\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::from(10u32).pow(100),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_random_integer_from_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Pow;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::random::{VariableRangeGenerator, random_primitive_ints};\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_random_integer_from_range_to_negative_infinity;\nuse std::str::FromStr;\n\nfn get_random_integer_from_range_to_negative_infinity_helper(\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    out: &str,\n) {\n    let mut xs = random_primitive_ints(EXAMPLE_SEED.fork(\"ints\"));\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_random_integer_from_range_to_negative_infinity(\n                &mut xs,\n                &mut vrg,\n                Integer::from_str(a).unwrap(),\n                mean_bits_numerator,\n                mean_bits_denominator,\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_random_integer_from_range_to_negative_infinity() {\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"0\",\n        1,\n        1,\n        \"[0, -1, -4, -1, -2, -1, -1, 0, 0, 0]\",\n    );\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"0\",\n        10,\n        1,\n        \"[-7, -7816, -428, -130, -1, -141, -10, 0, -4, -4483]\",\n    );\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"0\",\n        100,\n        1,\n        \"[-5101205056696451696397798478058511, -1562796, -8799850658374624318722, \\\n        -43213315753966138396554154493451514495463595499011546992326984725965140902499491700065508\\\n        39187394388518593842616549212512013, -279353891976332938189472063076409154515, \\\n        -1660357170525, \\\n        -14364218889921873996063448912638758622428935178245280788493476815105151126528849038489284\\\n        922660727526851378407, -86075361492, \\\n        -353552745516847393429177033516378899307448925328642, \\\n        -577340679116474858586805525866181088123189468507069123812855481357566943854]\",\n    );\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"1000\",\n        1,\n        1,\n        \"[-3, -2, -1, 1, 29, -3, 0, 0, -1, 0]\",\n    );\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"1000\",\n        11,\n        1,\n        \"[-5135, -4, 108, -1, 3, -3, -3666351202, -1, -37251, 718]\",\n    );\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"1000\",\n        100,\n        1,\n        \"[-2429686799, 648, -2730587924715692, 1, -4964076984094755832797, \\\n        -829471522969346588791746968515146309473173680336193392475266233389518923764834, \\\n        -89318048233905, -17177555, -451081617762069, -2086237]\",\n    );\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"-1000\",\n        11,\n        1,\n        \"[-1008, -1672, -6316, -1282, -3037, -1805, -1122, -1020, -1009, -1004]\",\n    );\n    get_random_integer_from_range_to_negative_infinity_helper(\n        \"-1000\",\n        100,\n        1,\n        \"[-1206982412795330974999926231143439, -457693356, -169360311075942561584386, \\\n        -15686419808113360018248499311022273352461958876360329877976446836438259171328060860875588\\\n        4131404116709444244598775565, -66677412650746398524862933431554022355, -26949124609373, \\\n        -10274641638611019453359307286994714963495455599965568795127967045604679999200234909658869\\\n        33126118631, -22626063730900, -2792352557430693060292673664470974590025115014402, \\\n        -68488724460300171666815845652220555564874106206890863873832895385292448366]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_random_integer_from_range_to_negative_infinity_fail_1() {\n    get_random_integer_from_range_to_negative_infinity(\n        &mut random_primitive_ints(EXAMPLE_SEED.fork(\"ints\")),\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_random_integer_from_range_to_negative_infinity_fail_2() {\n    get_random_integer_from_range_to_negative_infinity(\n        &mut random_primitive_ints(EXAMPLE_SEED.fork(\"ints\")),\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        2,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_random_integer_from_range_to_negative_infinity_fail_3() {\n    get_random_integer_from_range_to_negative_infinity(\n        &mut random_primitive_ints(EXAMPLE_SEED.fork(\"ints\")),\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        -Integer::from(10u32).pow(100),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_striped_random_integer_from_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_striped_random_integer_from_inclusive_range;\nuse std::str::FromStr;\n\nfn get_striped_random_integer_from_inclusive_range_helper(\n    m_numerator: u64,\n    m_denominator: u64,\n    a: &str,\n    b: &str,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), m_numerator, m_denominator);\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vrg\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_striped_random_integer_from_inclusive_range(\n                &mut bit_source,\n                &mut vrg,\n                Integer::from_str(a).unwrap(),\n                Integer::from_str(b).unwrap(),\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_integer_from_inclusive_range() {\n    get_striped_random_integer_from_inclusive_range_helper(\n        2,\n        1,\n        \"0\",\n        \"0\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        2,\n        1,\n        \"1950\",\n        \"2019\",\n        \"[2014, 1964, 2008, 1994, 1999, 1971, 1990, 1984, 2016, 2018]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        2,\n        1,\n        \"-10000\",\n        \"9000\",\n        \"[8458, 8998, 8818, -8899, -9414, 8703, 8540, 6141, 2042, 6456]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        2,\n        1,\n        \"-10000\",\n        \"-1000\",\n        \"[-8724, -9372, -8880, -9422, -8448, -9891, -8959, -8479, -1002, -4963]\",\n    );\n\n    get_striped_random_integer_from_inclusive_range_helper(\n        10,\n        1,\n        \"0\",\n        \"0\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        10,\n        1,\n        \"1950\",\n        \"2019\",\n        \"[2016, 1987, 2019, 1951, 2019, 1951, 2019, 1951, 1950, 1950]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        10,\n        1,\n        \"-10000\",\n        \"9000\",\n        \"[8312, 8992, 8992, -10000, -2046, 8192, 0, 4095, 63, 2047]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        10,\n        1,\n        \"-10000\",\n        \"-1000\",\n        \"[-8432, -10000, -1023, -9999, -10000, -1016, -1000, -1007, -8192, -4095]\",\n    );\n\n    get_striped_random_integer_from_inclusive_range_helper(\n        11,\n        10,\n        \"0\",\n        \"0\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        11,\n        10,\n        \"1950\",\n        \"2019\",\n        \"[1992, 1962, 2005, 2018, 1962, 2005, 2005, 2005, 1951, 2005]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        11,\n        10,\n        \"-10000\",\n        \"9000\",\n        \"[8634, 8874, 8362, -9557, -8877, 8874, 8533, 8362, 5461, 5333]\",\n    );\n    get_striped_random_integer_from_inclusive_range_helper(\n        11,\n        10,\n        \"-10000\",\n        \"-1000\",\n        \"[-9077, -9558, -8874, -9557, -8853, -9557, -8885, -8874, -5462, -2710]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_inclusive_range_fail_1() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 2, 1);\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vrg\"));\n    get_striped_random_integer_from_inclusive_range(\n        &mut bit_source,\n        &mut vrg,\n        Integer::from(10u32),\n        Integer::from(9u32),\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_striped_random_integer_from_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_striped_random_integer_from_range;\nuse std::str::FromStr;\n\nfn get_striped_random_integer_from_range_helper(\n    m_numerator: u64,\n    m_denominator: u64,\n    a: &str,\n    b: &str,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), m_numerator, m_denominator);\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vrg\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_striped_random_integer_from_range(\n                &mut bit_source,\n                &mut vrg,\n                Integer::from_str(a).unwrap(),\n                Integer::from_str(b).unwrap(),\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_integer_from_range() {\n    get_striped_random_integer_from_range_helper(2, 1, \"0\", \"1\", \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_integer_from_range_helper(\n        2,\n        1,\n        \"1950\",\n        \"2020\",\n        \"[2014, 1964, 2008, 1994, 1999, 1971, 1990, 1984, 2016, 2018]\",\n    );\n    get_striped_random_integer_from_range_helper(\n        2,\n        1,\n        \"-10000\",\n        \"9001\",\n        \"[8458, 8998, 8818, -8899, -9414, 8703, 8540, 6141, 2042, 6456]\",\n    );\n    get_striped_random_integer_from_range_helper(\n        2,\n        1,\n        \"-10000\",\n        \"-999\",\n        \"[-8724, -9372, -8880, -9422, -8448, -9891, -8959, -8479, -1002, -4963]\",\n    );\n\n    get_striped_random_integer_from_range_helper(10, 1, \"0\", \"1\", \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_integer_from_range_helper(\n        10,\n        1,\n        \"1950\",\n        \"2020\",\n        \"[2016, 1987, 2019, 1951, 2019, 1951, 2019, 1951, 1950, 1950]\",\n    );\n    get_striped_random_integer_from_range_helper(\n        10,\n        1,\n        \"-10000\",\n        \"9001\",\n        \"[8312, 8992, 8992, -10000, -2046, 8192, 0, 4095, 63, 2047]\",\n    );\n    get_striped_random_integer_from_range_helper(\n        10,\n        1,\n        \"-10000\",\n        \"-999\",\n        \"[-8432, -10000, -1023, -9999, -10000, -1016, -1000, -1007, -8192, -4095]\",\n    );\n\n    get_striped_random_integer_from_range_helper(\n        11,\n        10,\n        \"0\",\n        \"1\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_integer_from_range_helper(\n        11,\n        10,\n        \"1950\",\n        \"2020\",\n        \"[1992, 1962, 2005, 2018, 1962, 2005, 2005, 2005, 1951, 2005]\",\n    );\n    get_striped_random_integer_from_range_helper(\n        11,\n        10,\n        \"-10000\",\n        \"9001\",\n        \"[8634, 8874, 8362, -9557, -8877, 8874, 8533, 8362, 5461, 5333]\",\n    );\n    get_striped_random_integer_from_range_helper(\n        11,\n        10,\n        \"-10000\",\n        \"-999\",\n        \"[-9077, -9558, -8874, -9557, -8853, -9557, -8885, -8874, -5462, -2710]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_range_fail_1() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 2, 1);\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vrg\"));\n    get_striped_random_integer_from_range(\n        &mut bit_source,\n        &mut vrg,\n        Integer::from(10u32),\n        Integer::from(9u32),\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_striped_random_integer_from_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Pow;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_striped_random_integer_from_range_to_infinity;\nuse std::str::FromStr;\n\nfn get_striped_random_integer_from_range_to_infinity_helper(\n    a: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(\n        EXAMPLE_SEED.fork(\"bs\"),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_striped_random_integer_from_range_to_infinity(\n                &mut bit_source,\n                &mut vrg,\n                Integer::from_str(a).unwrap(),\n                mean_bits_numerator,\n                mean_bits_denominator,\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_integer_from_range_to_infinity() {\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"0\",\n        10,\n        1,\n        1,\n        1,\n        \"[0, 1, 4, 1, 3, 1, 1, 0, 0, 0]\",\n    );\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"0\",\n        10,\n        1,\n        10,\n        1,\n        \"[7, 4126, 511, 255, 1, 248, 15, 0, 7, 8191]\",\n    );\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"0\",\n        10,\n        1,\n        100,\n        1,\n        \"[2920647185518839672075671782293383, 1048576, 4739083809502202445823, \\\n        528812496939392674605437340435408671558612951523319156054677508322810572932328766514425150\\\n        8429219658089743953085078238920703, 170472354644468060339516718901910044671, \\\n        1099511627776, \\\n        186415569962779171680854936542673085018277752582758046597588616311812447948859965258255723\\\n        66927316848155197439, 137436864511, 187077834941321271646236832607563322963774152898535, \\\n        897560034344005936431766292731307813053258931074478508157776167326430855104]\",\n    );\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"1000\",\n        10,\n        1,\n        11,\n        1,\n        \"[1020, 2040, 4351, 1087, 4095, 1536, 2047, 1023, 1022, 1007]\",\n    );\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"1000\",\n        10,\n        1,\n        100,\n        1,\n        \"[973535863568279311376735658835847, 268435456, 151115988660057280545023, \\\n        788041621480711912165160823578914479144879663560965225783543272513529599243438802396891675\\\n        96389234574457387517706367, 61144487963324812669777136988278751233, 35184372088704, \\\n        108958909782649556234624985077749301722270247350340375090485228690114398468811820627146895\\\n        0192652287, 34084862300097, 2922291218836765780501982453037225347447510761475, \\\n        113055782260031715275206575103088333621424376204588378848515940842185162750]\",\n    );\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"-1000\",\n        10,\n        1,\n        1,\n        1,\n        \"[-3, -2, -1, 1, 17, -2, 0, 0, -1, 0]\",\n    );\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"-1000\",\n        10,\n        1,\n        11,\n        1,\n        \"[-3, 188, -1, 3, -3, -512, 1073725455, 1023, 0, 2047]\",\n    );\n    get_striped_random_integer_from_range_to_infinity_helper(\n        \"-1000\",\n        10,\n        1,\n        100,\n        1,\n        \"[130951, 19023203726501412800, 2055, 4629700416936738823, \\\n        206378257939585890650633610891897828407043084058691785319121408973257569307274994499096280\\\n        35369831199775792242011278409759, 295147869995014168352, 132373800004962371502079, \\\n        507510783, 1297559231579135076369342163583007, -128]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_range_to_infinity_fail_1() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1);\n    get_striped_random_integer_from_range_to_infinity(\n        &mut bit_source,\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_range_to_infinity_fail_2() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1);\n    get_striped_random_integer_from_range_to_infinity(\n        &mut bit_source,\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        2,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_range_to_infinity_fail_3() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1);\n    get_striped_random_integer_from_range_to_infinity(\n        &mut bit_source,\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::from(10u32).pow(100),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_striped_random_integer_from_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Pow;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::random::VariableRangeGenerator;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_striped_random_integer_from_range_to_negative_infinity;\nuse std::str::FromStr;\n\nfn get_striped_random_integer_from_range_to_negative_infinity_helper(\n    a: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(\n        EXAMPLE_SEED.fork(\"bs\"),\n        mean_stripe_numerator,\n        mean_stripe_denominator,\n    );\n    let mut vrg = VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_striped_random_integer_from_range_to_negative_infinity(\n                &mut bit_source,\n                &mut vrg,\n                Integer::from_str(a).unwrap(),\n                mean_bits_numerator,\n                mean_bits_denominator,\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_integer_from_range_to_negative_infinity() {\n    get_striped_random_integer_from_range_to_negative_infinity_helper(\n        \"0\",\n        10,\n        1,\n        1,\n        1,\n        \"[0, -1, -4, -1, -3, -1, -1, 0, 0, 0]\",\n    );\n    get_striped_random_integer_from_range_to_negative_infinity_helper(\n        \"0\",\n        10,\n        1,\n        10,\n        1,\n        \"[-7, -4126, -511, -255, -1, -248, -15, 0, -7, -8191]\",\n    );\n    get_striped_random_integer_from_range_to_negative_infinity_helper(\n        \"0\",\n        10,\n        1,\n        100,\n        1,\n        \"[-2920647185518839672075671782293383, -1048576, -4739083809502202445823, \\\n        -52881249693939267460543734043540867155861295152331915605467750832281057293232876651442515\\\n        08429219658089743953085078238920703, -170472354644468060339516718901910044671, \\\n        -1099511627776, -1864155699627791716808549365426730850182777525827580465975886163118124479\\\n        4885996525825572366927316848155197439, -137436864511, \\\n        -187077834941321271646236832607563322963774152898535, \\\n        -897560034344005936431766292731307813053258931074478508157776167326430855104]\",\n    );\n    get_striped_random_integer_from_range_to_negative_infinity_helper(\n        \"1000\",\n        10,\n        1,\n        11,\n        1,\n        \"[-8071, -4, 127, -1, 3, -2, -2147484671, -1, -32775, 515]\",\n    );\n    get_striped_random_integer_from_range_to_negative_infinity_helper(\n        \"1000\",\n        10,\n        1,\n        100,\n        1,\n        \"[-2151677831, 767, -2269323280383999, 1, -5008327044809161965583, \\\n        -466786749337581235991134723080519000284817084727848060138773225560246511976448, \\\n        -140672846790145, -29360131, -283605347598335, -2096896]\",\n    );\n    get_striped_random_integer_from_range_to_negative_infinity_helper(\n        \"-1000\",\n        10,\n        1,\n        11,\n        1,\n        \"[-1020, -2040, -4351, -1087, -4095, -1536, -2047, -1023, -1022, -1007]\",\n    );\n    get_striped_random_integer_from_range_to_negative_infinity_helper(\n        \"-1000\",\n        10,\n        1,\n        100,\n        1,\n        \"[-973535863568279311376735658835847, -268435456, -151115988660057280545023, \\\n        -78804162148071191216516082357891447914487966356096522578354327251352959924343880239689167\\\n        596389234574457387517706367, -61144487963324812669777136988278751233, -35184372088704, \\\n        -10895890978264955623462498507774930172227024735034037509048522869011439846881182062714689\\\n        50192652287, -34084862300097, -2922291218836765780501982453037225347447510761475, \\\n        -113055782260031715275206575103088333621424376204588378848515940842185162750]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_range_to_negative_infinity_fail_1() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1);\n    get_striped_random_integer_from_range_to_negative_infinity(\n        &mut bit_source,\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_range_to_negative_infinity_fail_2() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1);\n    get_striped_random_integer_from_range_to_negative_infinity(\n        &mut bit_source,\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        Integer::ZERO,\n        2,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_integer_from_range_to_negative_infinity_fail_3() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED.fork(\"bs\"), 10, 1);\n    get_striped_random_integer_from_range_to_negative_infinity(\n        &mut bit_source,\n        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork(\"vr\")),\n        -Integer::from(10).pow(100),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_uniform_random_integer_from_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_uniform_random_integer_from_inclusive_range;\nuse std::str::FromStr;\n\nfn get_uniform_random_integer_from_inclusive_range_helper(a: &str, b: &str, out: &str) {\n    let mut xs = random_primitive_ints(EXAMPLE_SEED.fork(\"ints\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_uniform_random_integer_from_inclusive_range(\n                &mut xs,\n                Integer::from_str(a).unwrap(),\n                Integer::from_str(b).unwrap(),\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_uniform_random_integer_from_inclusive_range() {\n    get_uniform_random_integer_from_inclusive_range_helper(\n        \"0\",\n        \"0\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_uniform_random_integer_from_inclusive_range_helper(\n        \"1950\",\n        \"2019\",\n        \"[1965, 1958, 1994, 1952, 1963, 1953, 1999, 1971, 1970, 2011]\",\n    );\n    get_uniform_random_integer_from_inclusive_range_helper(\n        \"-10\",\n        \"9\",\n        \"[5, -2, 2, -8, 3, -8, -7, 4, 9, 7]\",\n    );\n    get_uniform_random_integer_from_inclusive_range_helper(\n        \"-10\",\n        \"-1\",\n        \"[-2, -8, -8, -7, -7, -9, -7, -5, -3, -6]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_uniform_random_integer_from_inclusive_range_fail() {\n    get_uniform_random_integer_from_inclusive_range(\n        &mut random_primitive_ints(EXAMPLE_SEED),\n        Integer::ONE,\n        Integer::ZERO,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/get_uniform_random_integer_from_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::get_uniform_random_integer_from_range;\nuse std::str::FromStr;\n\nfn get_uniform_random_integer_from_range_helper(a: &str, b: &str, out: &str) {\n    let mut xs = random_primitive_ints(EXAMPLE_SEED.fork(\"ints\"));\n    let xs = (0..10)\n        .map(|_| {\n            get_uniform_random_integer_from_range(\n                &mut xs,\n                Integer::from_str(a).unwrap(),\n                Integer::from_str(b).unwrap(),\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_uniform_random_integer_from_range() {\n    get_uniform_random_integer_from_range_helper(\"0\", \"1\", \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_uniform_random_integer_from_range_helper(\n        \"1950\",\n        \"2020\",\n        \"[1965, 1958, 1994, 1952, 1963, 1953, 1999, 1971, 1970, 2011]\",\n    );\n    get_uniform_random_integer_from_range_helper(\"-10\", \"10\", \"[5, -2, 2, -8, 3, -8, -7, 4, 9, 7]\");\n    get_uniform_random_integer_from_range_helper(\n        \"-10\",\n        \"0\",\n        \"[-2, -8, -8, -7, -7, -9, -7, -5, -3, -6]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_uniform_random_integer_from_range_fail() {\n    get_uniform_random_integer_from_range(\n        &mut random_primitive_ints(EXAMPLE_SEED),\n        Integer::ZERO,\n        Integer::ZERO,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_integer_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::random_integer_inclusive_range;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn random_integer_inclusive_range_helper(\n    a: &str,\n    b: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_integer_inclusive_range(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            Integer::from_str(b).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_integer_inclusive_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_inclusive_range_helper(\n        \"0\",\n        \"0\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1\", \"0\", \"1\", \"-1\", \"-1\", \"-4\", \"-2\", \"-2\", \"-1\", \"-1\", \"0\", \"1\", \"2\", \"-4\", \"0\", \"1\",\n        \"0\", \"0\", \"1\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 284116),\n        (\"1\", 189679),\n        (\"-1\", 189332),\n        (\"-4\", 84500),\n        (\"3\", 63397),\n        (\"2\", 63173),\n        (\"-3\", 62961),\n        (\"-2\", 62842),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.3356830000000005),\n        standard_deviation: NiceFloat(1.8054398863225456),\n        skewness: NiceFloat(-0.35221934475763134),\n        excess_kurtosis: NiceFloat(-0.2458978296075136),\n    };\n    random_integer_inclusive_range_helper(\n        \"-4\",\n        \"3\",\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1023\", \"1022\", \"1023\", \"1023\", \"1023\", \"1022\", \"1023\", \"1024\", \"1024\", \"1025\", \"1025\",\n        \"1022\", \"1023\", \"1023\", \"1023\", \"1022\", \"1025\", \"1024\", \"1024\", \"1024\",\n    ];\n    let common_values = &[(\"1023\", 300404), (\"1022\", 299811), (\"1025\", 200144), (\"1024\", 199641)];\n    let sample_median = (\"1023\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1023.3001179999817),\n        standard_deviation: NiceFloat(1.0999810889439465),\n        skewness: NiceFloat(0.2889412070926685),\n        excess_kurtosis: NiceFloat(-1.2389995110068848),\n    };\n    random_integer_inclusive_range_helper(\n        \"1022\",\n        \"1025\",\n        12,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1025\", \"-1024\", \"-1025\",\n        \"-1024\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1025\", \"-1026\", \"-1024\", \"-1024\",\n    ];\n    let common_values =\n        &[(\"-1023\", 600215), (\"-1024\", 133294), (\"-1026\", 133261), (\"-1025\", 133230)];\n    let sample_median = (\"-1023\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1023.7995370000281),\n        standard_deviation: NiceFloat(1.1073864781257785),\n        skewness: NiceFloat(-0.990171399672332),\n        excess_kurtosis: NiceFloat(-0.5751529612720772),\n    };\n    random_integer_inclusive_range_helper(\n        \"-1026\",\n        \"-1023\",\n        12,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\", \"152\", \"1\", \"0\", \"-62\", \"5282\", \"0\", \"28\", \"-4\", \"-79\", \"-11\", \"2\", \"1\", \"-1\", \"82\",\n        \"-1\", \"696\", \"-6\", \"-39\", \"1421\",\n    ];\n    let common_values = &[\n        (\"0\", 118542),\n        (\"1\", 95287),\n        (\"-1\", 95269),\n        (\"-3\", 38248),\n        (\"3\", 38202),\n        (\"2\", 38150),\n        (\"-2\", 38078),\n        (\"-4\", 15429),\n        (\"7\", 15423),\n        (\"-5\", 15382),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(130.2935679999988),\n        standard_deviation: NiceFloat(901.4375229872913),\n        skewness: NiceFloat(7.858028656993447),\n        excess_kurtosis: NiceFloat(67.9560213744922),\n    };\n    random_integer_inclusive_range_helper(\n        \"-1000\",\n        \"9999\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_integer_inclusive_range_fail_1() {\n    random_integer_inclusive_range(EXAMPLE_SEED, Integer::from(-100), Integer::from(-10), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_integer_inclusive_range_fail_2() {\n    random_integer_inclusive_range(EXAMPLE_SEED, Integer::from(-100), Integer::from(-10), 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_integer_inclusive_range_fail_3() {\n    random_integer_inclusive_range(EXAMPLE_SEED, Integer::from(-9), Integer::from(-10), 10, 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_integer_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::random_integer_range;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn random_integer_range_helper(\n    a: &str,\n    b: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_integer_range(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            Integer::from_str(b).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_integer_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_helper(\n        \"0\",\n        \"1\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1\", \"0\", \"1\", \"-1\", \"-1\", \"-4\", \"-2\", \"-2\", \"-1\", \"-1\", \"0\", \"1\", \"2\", \"-4\", \"0\", \"1\",\n        \"0\", \"0\", \"1\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 284116),\n        (\"1\", 189679),\n        (\"-1\", 189332),\n        (\"-4\", 84500),\n        (\"3\", 63397),\n        (\"2\", 63173),\n        (\"-3\", 62961),\n        (\"-2\", 62842),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.3356830000000005),\n        standard_deviation: NiceFloat(1.8054398863225456),\n        skewness: NiceFloat(-0.35221934475763134),\n        excess_kurtosis: NiceFloat(-0.2458978296075136),\n    };\n    random_integer_range_helper(\n        \"-4\",\n        \"4\",\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1023\", \"1022\", \"1023\", \"1023\", \"1023\", \"1022\", \"1023\", \"1024\", \"1024\", \"1025\", \"1025\",\n        \"1022\", \"1023\", \"1023\", \"1023\", \"1022\", \"1025\", \"1024\", \"1024\", \"1024\",\n    ];\n    let common_values = &[(\"1023\", 300404), (\"1022\", 299811), (\"1025\", 200144), (\"1024\", 199641)];\n    let sample_median = (\"1023\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1023.3001179999817),\n        standard_deviation: NiceFloat(1.0999810889439465),\n        skewness: NiceFloat(0.2889412070926685),\n        excess_kurtosis: NiceFloat(-1.2389995110068848),\n    };\n    random_integer_range_helper(\n        \"1022\",\n        \"1026\",\n        12,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1025\", \"-1024\", \"-1025\",\n        \"-1024\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1023\", \"-1025\", \"-1026\", \"-1024\", \"-1024\",\n    ];\n    let common_values =\n        &[(\"-1023\", 600215), (\"-1024\", 133294), (\"-1026\", 133261), (\"-1025\", 133230)];\n    let sample_median = (\"-1023\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1023.7995370000281),\n        standard_deviation: NiceFloat(1.1073864781257785),\n        skewness: NiceFloat(-0.990171399672332),\n        excess_kurtosis: NiceFloat(-0.5751529612720772),\n    };\n    random_integer_range_helper(\n        \"-1026\",\n        \"-1022\",\n        12,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\", \"152\", \"1\", \"0\", \"-62\", \"5282\", \"0\", \"28\", \"-4\", \"-79\", \"-11\", \"2\", \"1\", \"-1\", \"82\",\n        \"-1\", \"696\", \"-6\", \"-39\", \"1421\",\n    ];\n    let common_values = &[\n        (\"0\", 118542),\n        (\"1\", 95287),\n        (\"-1\", 95269),\n        (\"-3\", 38248),\n        (\"3\", 38202),\n        (\"2\", 38150),\n        (\"-2\", 38078),\n        (\"-4\", 15429),\n        (\"7\", 15423),\n        (\"-5\", 15382),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(130.2935679999988),\n        standard_deviation: NiceFloat(901.4375229872913),\n        skewness: NiceFloat(7.858028656993447),\n        excess_kurtosis: NiceFloat(67.9560213744922),\n    };\n    random_integer_range_helper(\n        \"-1000\",\n        \"10000\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_fail_1() {\n    random_integer_range(EXAMPLE_SEED, Integer::from(-100), Integer::from(-10), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_fail_2() {\n    random_integer_range(EXAMPLE_SEED, Integer::from(-100), Integer::from(-10), 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_fail_3() {\n    random_integer_range(EXAMPLE_SEED, Integer::from(-9), Integer::from(-10), 10, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_fail_4() {\n    random_integer_range(EXAMPLE_SEED, Integer::from(10), Integer::from(10), 10, 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_integer_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::random_integer_range_to_infinity;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn random_integer_range_to_infinity_helper(\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_integer_range_to_infinity(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_integer_range_to_infinity() {\n    let values = &[\n        \"0\", \"14\", \"0\", \"8\", \"2\", \"6\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 500248),\n        (\"1\", 249491),\n        (\"2\", 62676),\n        (\"3\", 62465),\n        (\"7\", 15819),\n        (\"5\", 15781),\n        (\"6\", 15694),\n        (\"4\", 15518),\n        (\"13\", 3945),\n        (\"8\", 3895),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.289019000000012),\n        standard_deviation: NiceFloat(811.503067487901),\n        skewness: NiceFloat(791.581366511165),\n        excess_kurtosis: NiceFloat(717047.0759703598),\n    };\n    random_integer_range_to_infinity_helper(\n        \"0\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"20431208470830262\",\n        \"2777240\",\n        \"114\",\n        \"12184833305054\",\n        \"1121025855008623490210\",\n        \"13478874522577592\",\n        \"115311695\",\n        \"7\",\n        \"18\",\n        \"54522366353\",\n        \"2183264193236231773387459\",\n        \"824\",\n        \"18558864232439549193912\",\n        \"15\",\n        \"110989\",\n        \"453270\",\n        \"4307150\",\n        \"45388024541\",\n        \"47\",\n        \"3345913274\",\n    ];\n    let common_values = &[\n        (\"0\", 30467),\n        (\"1\", 29379),\n        (\"3\", 14233),\n        (\"2\", 14194),\n        (\"7\", 6984),\n        (\"6\", 6980),\n        (\"4\", 6964),\n        (\"5\", 6929),\n        (\"10\", 3479),\n        (\"15\", 3431),\n    ];\n    let sample_median = (\"3201388\", Some(\"3201522\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.480305129633914e129),\n        standard_deviation: NiceFloat(2.4803051296331898e132),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_infinity_helper(\n        \"0\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"11\", \"182\", \"12\", \"152\", \"50\", \"94\", \"18\", \"11\", \"13\", \"15\", \"14\", \"13\", \"28\", \"24\", \"13\",\n        \"13\", \"31\", \"19\", \"12\", \"13\",\n    ];\n    let common_values = &[\n        (\"13\", 83637),\n        (\"11\", 83622),\n        (\"15\", 83440),\n        (\"14\", 83364),\n        (\"10\", 83305),\n        (\"12\", 82880),\n        (\"20\", 15837),\n        (\"31\", 15785),\n        (\"19\", 15779),\n        (\"18\", 15776),\n    ];\n    let sample_median = (\"15\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(128.81076899999977),\n        standard_deviation: NiceFloat(15255.606035258177),\n        skewness: NiceFloat(845.8189997295934),\n        excess_kurtosis: NiceFloat(789803.2243471228),\n    };\n    random_integer_range_to_infinity_helper(\n        \"10\",\n        5,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"118\",\n        \"56\",\n        \"1714\",\n        \"55845661150\",\n        \"93254818\",\n        \"822568088563644\",\n        \"120\",\n        \"871591019599\",\n        \"99\",\n        \"1171796531603249384284396706\",\n        \"3570371\",\n        \"76271186\",\n        \"69092967935443594634663005648041578296\",\n        \"110\",\n        \"39\",\n        \"25543539470733\",\n        \"317538101910\",\n        \"206\",\n        \"14906804826461850333\",\n        \"95450125556931311\",\n    ];\n    let common_values = &[\n        (\"13\", 5882),\n        (\"14\", 5840),\n        (\"12\", 5734),\n        (\"15\", 5645),\n        (\"11\", 5644),\n        (\"10\", 5642),\n        (\"18\", 2148),\n        (\"27\", 2143),\n        (\"19\", 2134),\n        (\"23\", 2134),\n    ];\n    let sample_median = (\"7289020\", Some(\"7289286\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.8276128186777812e120),\n        standard_deviation: NiceFloat(1.8276117282901724e123),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_infinity_helper(\n        \"10\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\", \"-2\", \"-6\", \"0\", \"0\", \"-1\", \"-2\", \"-2\", \"2\", \"0\", \"0\", \"-1\", \"-7\", \"-2\", \"5\", \"0\",\n        \"1\", \"1\", \"1\", \"-2\",\n    ];\n    let common_values = &[\n        (\"0\", 340125),\n        (\"-1\", 170288),\n        (\"1\", 170110),\n        (\"3\", 42793),\n        (\"2\", 42482),\n        (\"-2\", 42480),\n        (\"-3\", 42401),\n        (\"7\", 10842),\n        (\"-6\", 10756),\n        (\"-5\", 10753),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.031789999999887),\n        standard_deviation: NiceFloat(549.0621114688183),\n        skewness: NiceFloat(481.1013689046789),\n        excess_kurtosis: NiceFloat(256425.40976596656),\n    };\n    random_integer_range_to_infinity_helper(\n        \"-10\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"89270\",\n        \"69403499476962893258904\",\n        \"62\",\n        \"59700386\",\n        \"45674428\",\n        \"696\",\n        \"0\",\n        \"-3\",\n        \"3235\",\n        \"7330\",\n        \"-5\",\n        \"15043\",\n        \"11858\",\n        \"2541784888\",\n        \"7007928\",\n        \"1518\",\n        \"23\",\n        \"909\",\n        \"60054\",\n        \"1\",\n    ];\n    let common_values = &[\n        (\"0\", 27154),\n        (\"1\", 26497),\n        (\"-1\", 26298),\n        (\"-2\", 12852),\n        (\"2\", 12781),\n        (\"3\", 12707),\n        (\"-3\", 12664),\n        (\"-8\", 8085),\n        (\"-10\", 8066),\n        (\"-9\", 7928),\n    ];\n    let sample_median = (\"293781\", Some(\"293783\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(6.04296612240715e153),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_infinity_helper(\n        \"-10\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1032867295426\",\n        \"15476566285494\",\n        \"1005058503561\",\n        \"11872468885656\",\n        \"3085108281010\",\n        \"7786786793950\",\n        \"1848070042786\",\n        \"1008384510771\",\n        \"1035939113223\",\n        \"1034091049134\",\n        \"1097997002237\",\n        \"1066780473347\",\n        \"1232902614972\",\n        \"2160500927160\",\n        \"1039676158979\",\n        \"1075044604283\",\n        \"1421346833487\",\n        \"2100488049827\",\n        \"1090935342918\",\n        \"1033099299962\",\n    ];\n    let common_values = &[\n        (\"1012318490312\", 2),\n        (\"1020804407546\", 2),\n        (\"1040579317197\", 2),\n        (\"1041361099759\", 2),\n        (\"1099357770481\", 2),\n        (\"1000000358874\", 1),\n        (\"1000000635467\", 1),\n        (\"1000000743391\", 1),\n        (\"1000001041678\", 1),\n        (\"1000001124568\", 1),\n    ];\n    let sample_median = (\"1099468717392\", Some(\"1099468761569\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9002084314682.418),\n        standard_deviation: NiceFloat(1175305974058995.2),\n        skewness: NiceFloat(894.6662459454856),\n        excess_kurtosis: NiceFloat(856946.924578041),\n    };\n    random_integer_range_to_infinity_helper(\n        \"1000000000000\",\n        41,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2282426752182\",\n        \"3076375863448\",\n        \"33871433858738\",\n        \"193926771358011304414\",\n        \"683117911635193788\",\n        \"95918191752968866622136\",\n        \"5399022933155\",\n        \"2679643424229893512354\",\n        \"7585953905347\",\n        \"17738519421136481929559726434799186\",\n        \"70600001019637432\",\n        \"77299482847566318\",\n        \"332646018266965594347466935183659688140188647\",\n        \"4856563742926\",\n        \"1110539913949\",\n        \"8169120771017371179759\",\n        \"142409202767618812372\",\n        \"3612730358681\",\n        \"468787385712310874935747551\",\n        \"9607440468294695468459788\",\n    ];\n    let common_values = &[\n        (\"1000006091267\", 1),\n        (\"1000006483280\", 1),\n        (\"1000008421992\", 1),\n        (\"1000009071089\", 1),\n        (\"1000011436758\", 1),\n        (\"1000013492649\", 1),\n        (\"1000014387323\", 1),\n        (\"1000020641917\", 1),\n        (\"1000020859147\", 1),\n        (\"1000020971497\", 1),\n    ];\n    let sample_median = (\"70366472614875784\", Some(\"70368772587252716\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0984547559553134e113),\n        standard_deviation: NiceFloat(1.098369190533207e116),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_infinity_helper(\n        \"1000000000000\",\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\", \"-2\", \"-6\", \"0\", \"0\", \"-1\", \"-2\", \"-2\", \"2\", \"0\", \"0\", \"-1\", \"-7\", \"-2\", \"5\", \"0\",\n        \"1\", \"1\", \"1\", \"-2\",\n    ];\n    let common_values = &[\n        (\"0\", 332922),\n        (\"-1\", 166652),\n        (\"1\", 166524),\n        (\"3\", 42164),\n        (\"2\", 41585),\n        (\"-3\", 41436),\n        (\"-2\", 41400),\n        (\"5\", 10546),\n        (\"4\", 10540),\n        (\"-6\", 10475),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.4130599999999974),\n        standard_deviation: NiceFloat(777.5605240878597),\n        skewness: NiceFloat(-244.83259806631784),\n        excess_kurtosis: NiceFloat(225482.22529172004),\n    };\n    random_integer_range_to_infinity_helper(\n        \"-1000000000000\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"89270\",\n        \"69403499476962893258904\",\n        \"62\",\n        \"0\",\n        \"61363647650\",\n        \"-956\",\n        \"120\",\n        \"99407\",\n        \"-5283\",\n        \"-171170\",\n        \"-346513\",\n        \"-15043\",\n        \"119462940242\",\n        \"6836752184\",\n        \"-1720\",\n        \"-30\",\n        \"-999\",\n        \"-45453\",\n        \"-54\",\n        \"78\",\n    ];\n    let common_values = &[\n        (\"0\", 17993),\n        (\"1\", 17632),\n        (\"-1\", 17419),\n        (\"-2\", 8480),\n        (\"-3\", 8468),\n        (\"3\", 8420),\n        (\"2\", 8265),\n        (\"6\", 4225),\n        (\"4\", 4223),\n        (\"-4\", 4199),\n    ];\n    let sample_median = (\"24\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.2795558914963709e155),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_infinity_helper(\n        \"-1000000000000\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_to_infinity_fail_1() {\n    random_integer_range_to_infinity(EXAMPLE_SEED, Integer::from(10), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_to_infinity_fail_2() {\n    random_integer_range_to_infinity(EXAMPLE_SEED, Integer::from(10), 4, 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_integer_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::random_integer_range_to_negative_infinity;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn random_integer_range_to_negative_infinity_helper(\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_integer_range_to_negative_infinity(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_integer_range_to_negative_infinity() {\n    let values = &[\n        \"0\", \"-14\", \"0\", \"-8\", \"-2\", \"-6\", \"-1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"-1\", \"-1\", \"0\", \"0\",\n        \"-1\", \"-1\", \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 500248),\n        (\"-1\", 249491),\n        (\"-2\", 62676),\n        (\"-3\", 62465),\n        (\"-7\", 15819),\n        (\"-5\", 15781),\n        (\"-6\", 15694),\n        (\"-4\", 15518),\n        (\"-13\", 3945),\n        (\"-8\", 3895),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.289019000000012),\n        standard_deviation: NiceFloat(811.503067487901),\n        skewness: NiceFloat(-791.581366511165),\n        excess_kurtosis: NiceFloat(717047.0759703598),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"0\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-20431208470830262\",\n        \"-2777240\",\n        \"-114\",\n        \"-12184833305054\",\n        \"-1121025855008623490210\",\n        \"-13478874522577592\",\n        \"-115311695\",\n        \"-7\",\n        \"-18\",\n        \"-54522366353\",\n        \"-2183264193236231773387459\",\n        \"-824\",\n        \"-18558864232439549193912\",\n        \"-15\",\n        \"-110989\",\n        \"-453270\",\n        \"-4307150\",\n        \"-45388024541\",\n        \"-47\",\n        \"-3345913274\",\n    ];\n    let common_values = &[\n        (\"0\", 30467),\n        (\"-1\", 29379),\n        (\"-3\", 14233),\n        (\"-2\", 14194),\n        (\"-7\", 6984),\n        (\"-6\", 6980),\n        (\"-4\", 6964),\n        (\"-5\", 6929),\n        (\"-10\", 3479),\n        (\"-15\", 3431),\n    ];\n    let sample_median = (\"-3201522\", Some(\"-3201388\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.480305129633914e129),\n        standard_deviation: NiceFloat(2.4803051296331898e132),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"0\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\",\n        \"-24\",\n        \"-2\",\n        \"-1\",\n        \"-1\",\n        \"-8124\",\n        \"-2\",\n        \"-321835205711\",\n        \"-99\",\n        \"-10\",\n        \"-145\",\n        \"-1\",\n        \"-814468690\",\n        \"-20280\",\n        \"-120\",\n        \"1\",\n        \"-2023\",\n        \"10\",\n        \"-909\",\n        \"-10902\",\n    ];\n    let common_values = &[\n        (\"0\", 116331),\n        (\"1\", 97337),\n        (\"-1\", 96828),\n        (\"-3\", 40657),\n        (\"2\", 40328),\n        (\"-2\", 40302),\n        (\"3\", 40199),\n        (\"10\", 18790),\n        (\"9\", 18745),\n        (\"8\", 18603),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-324066858236836.2),\n        standard_deviation: NiceFloat(2.1808471647947933e17),\n        skewness: NiceFloat(-782.8568751691934),\n        excess_kurtosis: NiceFloat(641629.0527568299),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"10\",\n        5,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-2\",\n        \"-69403499476962893258904\",\n        \"-62\",\n        \"-61363647650\",\n        \"-64671510460\",\n        \"0\",\n        \"0\",\n        \"-120\",\n        \"-79\",\n        \"-5283\",\n        \"-171170\",\n        \"-346513\",\n        \"-15043\",\n        \"-76271186\",\n        \"-260083512\",\n        \"-1720\",\n        \"-1518\",\n        \"1\",\n        \"-3\",\n        \"-49022969236123561123418405268118\",\n    ];\n    let common_values = &[\n        (\"0\", 27157),\n        (\"1\", 26618),\n        (\"-1\", 26439),\n        (\"-2\", 12828),\n        (\"3\", 12822),\n        (\"-3\", 12808),\n        (\"2\", 12788),\n        (\"10\", 8081),\n        (\"9\", 8077),\n        (\"8\", 8044),\n    ];\n    let sample_median = (\"-276826\", Some(\"-276824\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.7536910581415426e155),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"10\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-13\", \"-182\", \"-13\", \"-152\", \"-50\", \"-94\", \"-18\", \"-14\", \"-12\", \"-10\", \"-11\", \"-15\",\n        \"-28\", \"-24\", \"-15\", \"-13\", \"-31\", \"-19\", \"-15\", \"-11\",\n    ];\n    let common_values = &[\n        (\"-13\", 83731),\n        (\"-10\", 83540),\n        (\"-12\", 83478),\n        (\"-14\", 83457),\n        (\"-11\", 83187),\n        (\"-15\", 82855),\n        (\"-20\", 15837),\n        (\"-31\", 15785),\n        (\"-19\", 15779),\n        (\"-18\", 15776),\n    ];\n    let sample_median = (\"-15\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-128.80925900000398),\n        standard_deviation: NiceFloat(15255.606046679814),\n        skewness: NiceFloat(-845.8189981268482),\n        excess_kurtosis: NiceFloat(789803.2223167756),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"-10\",\n        5,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-118\",\n        \"-56\",\n        \"-1714\",\n        \"-55845661150\",\n        \"-93254818\",\n        \"-822568088563644\",\n        \"-120\",\n        \"-871591019599\",\n        \"-99\",\n        \"-1171796531603249384284396706\",\n        \"-3570371\",\n        \"-76271186\",\n        \"-69092967935443594634663005648041578296\",\n        \"-110\",\n        \"-39\",\n        \"-25543539470733\",\n        \"-317538101910\",\n        \"-206\",\n        \"-14906804826461850333\",\n        \"-95450125556931311\",\n    ];\n    let common_values = &[\n        (\"-13\", 5852),\n        (\"-12\", 5824),\n        (\"-14\", 5824),\n        (\"-11\", 5734),\n        (\"-10\", 5589),\n        (\"-15\", 5564),\n        (\"-18\", 2148),\n        (\"-27\", 2143),\n        (\"-19\", 2134),\n        (\"-23\", 2134),\n    ];\n    let sample_median = (\"-7289286\", Some(\"-7289020\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.8276128186777812e120),\n        standard_deviation: NiceFloat(1.8276117282901724e123),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"-10\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\", \"-2\", \"-6\", \"0\", \"0\", \"-1\", \"-2\", \"-2\", \"2\", \"0\", \"0\", \"-1\", \"-7\", \"-2\", \"5\", \"0\",\n        \"1\", \"1\", \"1\", \"-2\",\n    ];\n    let common_values = &[\n        (\"0\", 332922),\n        (\"-1\", 166652),\n        (\"1\", 166524),\n        (\"3\", 42164),\n        (\"2\", 41585),\n        (\"-3\", 41436),\n        (\"-2\", 41400),\n        (\"5\", 10546),\n        (\"4\", 10540),\n        (\"-6\", 10475),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.4130599999999974),\n        standard_deviation: NiceFloat(777.5605240878597),\n        skewness: NiceFloat(-244.83259806631784),\n        excess_kurtosis: NiceFloat(225482.22529172004),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"1000000000000\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"89270\",\n        \"18359148696\",\n        \"-50\",\n        \"-1189717027294\",\n        \"-61363647650\",\n        \"956\",\n        \"0\",\n        \"120\",\n        \"99407\",\n        \"5283\",\n        \"-171170\",\n        \"-346513\",\n        \"-15043\",\n        \"-119462940242\",\n        \"6836752184\",\n        \"1720\",\n        \"-30\",\n        \"-999\",\n        \"-45453\",\n        \"-54\",\n    ];\n    let common_values = &[\n        (\"0\", 18088),\n        (\"1\", 17624),\n        (\"-1\", 17275),\n        (\"3\", 8602),\n        (\"2\", 8437),\n        (\"-3\", 8322),\n        (\"-2\", 8240),\n        (\"7\", 4233),\n        (\"-6\", 4129),\n        (\"-4\", 4119),\n    ];\n    let sample_median = (\"-24\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.821612894174129e142),\n        standard_deviation: NiceFloat(8.821611690087554e145),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"1000000000000\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-1098860169725\",\n        \"-15476566285494\",\n        \"-1039756450654\",\n        \"-11872468885656\",\n        \"-3085108281010\",\n        \"-7786786793950\",\n        \"-1848070042786\",\n        \"-1001655869084\",\n        \"-1066875920613\",\n        \"-1005653510487\",\n        \"-1039550426984\",\n        \"-1016104838230\",\n        \"-1232902614972\",\n        \"-2160500927160\",\n        \"-1077775969857\",\n        \"-1032850377710\",\n        \"-1421346833487\",\n        \"-2100488049827\",\n        \"-1095947428690\",\n        \"-1014665028606\",\n    ];\n    let common_values = &[\n        (\"-1002769937332\", 2),\n        (\"-1073874696438\", 2),\n        (\"-1000000188909\", 1),\n        (\"-1000000496682\", 1),\n        (\"-1000000510433\", 1),\n        (\"-1000000739585\", 1),\n        (\"-1000001292527\", 1),\n        (\"-1000001626249\", 1),\n        (\"-1000002315263\", 1),\n        (\"-1000002353491\", 1),\n    ];\n    let sample_median = (\"-1099462180132\", Some(\"-1099461808833\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-9002075457674.271),\n        standard_deviation: NiceFloat(1175305974119130.0),\n        skewness: NiceFloat(-894.6662458308058),\n        excess_kurtosis: NiceFloat(856946.9244296869),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"-1000000000000\",\n        41,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-2282426752182\",\n        \"-3076375863448\",\n        \"-33871433858738\",\n        \"-193926771358011304414\",\n        \"-683117911635193788\",\n        \"-95918191752968866622136\",\n        \"-5399022933155\",\n        \"-2679643424229893512354\",\n        \"-7585953905347\",\n        \"-17738519421136481929559726434799186\",\n        \"-70600001019637432\",\n        \"-77299482847566318\",\n        \"-332646018266965594347466935183659688140188647\",\n        \"-4856563742926\",\n        \"-1110539913949\",\n        \"-8169120771017371179759\",\n        \"-142409202767618812372\",\n        \"-3612730358681\",\n        \"-468787385712310874935747551\",\n        \"-9607440468294695468459788\",\n    ];\n    let common_values = &[\n        (\"-1000001292527\", 1),\n        (\"-1000003874527\", 1),\n        (\"-1000008544047\", 1),\n        (\"-1000010938009\", 1),\n        (\"-1000029445751\", 1),\n        (\"-1000041463842\", 1),\n        (\"-1000043700145\", 1),\n        (\"-1000044447812\", 1),\n        (\"-1000047340863\", 1),\n        (\"-1000049992535\", 1),\n    ];\n    let sample_median = (\"-70368772587252716\", Some(\"-70366472614875784\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0984547559553134e113),\n        standard_deviation: NiceFloat(1.098369190533207e116),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integer_range_to_negative_infinity_helper(\n        \"-1000000000000\",\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_to_negative_infinity_fail_1() {\n    random_integer_range_to_negative_infinity(EXAMPLE_SEED, Integer::from(-10), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_integer_range_to_negative_infinity_fail_2() {\n    random_integer_range_to_negative_infinity(EXAMPLE_SEED, Integer::from(-10), 4, 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::random_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn random_integers_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_integers(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_integers() {\n    // mean bits = 1/64\n    let values = &[\"0\"; 20];\n    let common_values = &[\n        (\"0\", 969830),\n        (\"1\", 14858),\n        (\"-1\", 14856),\n        (\"-3\", 128),\n        (\"-2\", 122),\n        (\"3\", 101),\n        (\"2\", 98),\n        (\"7\", 2),\n        (\"-4\", 2),\n        (\"5\", 1),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.00012800000000000482),\n        standard_deviation: NiceFloat(0.18133950617561467),\n        skewness: NiceFloat(-0.11594058747329855),\n        excess_kurtosis: NiceFloat(53.17726403139359),\n    };\n    random_integers_helper(\n        1,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 1\n    let values = &[\n        \"2\", \"-2\", \"-6\", \"0\", \"0\", \"-1\", \"-2\", \"-2\", \"2\", \"0\", \"0\", \"-1\", \"-7\", \"-2\", \"5\", \"0\",\n        \"1\", \"1\", \"1\", \"-2\",\n    ];\n    let common_values = &[\n        (\"0\", 332922),\n        (\"-1\", 166652),\n        (\"1\", 166524),\n        (\"3\", 42164),\n        (\"2\", 41585),\n        (\"-3\", 41436),\n        (\"-2\", 41400),\n        (\"5\", 10546),\n        (\"4\", 10540),\n        (\"-6\", 10475),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.4130599999999974),\n        standard_deviation: NiceFloat(777.5605240878597),\n        skewness: NiceFloat(-244.83259806631784),\n        excess_kurtosis: NiceFloat(225482.22529172004),\n    };\n    random_integers_helper(\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"89270\",\n        \"69403499476962893258904\",\n        \"62\",\n        \"-1848070042786\",\n        \"-64671510460\",\n        \"-696\",\n        \"0\",\n        \"-79\",\n        \"70819\",\n        \"7330\",\n        \"215441\",\n        \"-424643\",\n        \"-11858\",\n        \"-84146163512\",\n        \"-7212822200\",\n        \"1518\",\n        \"23\",\n        \"-909\",\n        \"-60054\",\n        \"-46\",\n    ];\n    let common_values = &[\n        (\"0\", 15405),\n        (\"1\", 15074),\n        (\"-1\", 14891),\n        (\"-2\", 7292),\n        (\"2\", 7217),\n        (\"-3\", 7168),\n        (\"3\", 7120),\n        (\"5\", 3593),\n        (\"-6\", 3558),\n        (\"-7\", 3542),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0417062616580636e155),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integers_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"15542\",\n        \"204354108892664954266560767940941860034994328\",\n        \"5282\",\n        \"-323516\",\n        \"-400812728\",\n        \"-248570628312176883893327\",\n        \"5606382754\",\n        \"-63523217\",\n        \"-15024295498724618356672330435\",\n        \"25408382788335305673841323624499957642146385720\",\n        \"70153184455655\",\n        \"331577334953510974497668975717692627852954604565929960256566094891153641703901536975584071\\\n        2936487655650300919339856269\",\n        \"-2179070834703641056854463566957970466590674233219693760530182904389383\",\n        \"-5826316\",\n        \"-8647284\",\n        \"-1\",\n        \"43088412843029635753589496830104451113312\",\n        \"18608\",\n        \"-3946823889925\",\n        \"-114916707179919722397\",\n    ];\n    let common_values = &[\n        (\"0\", 7696),\n        (\"-1\", 7685),\n        (\"1\", 7575),\n        (\"-3\", 3800),\n        (\"-2\", 3773),\n        (\"3\", 3717),\n        (\"2\", 3679),\n        (\"7\", 1889),\n        (\"6\", 1862),\n        (\"-5\", 1862),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.4757098576025357e248),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_integers_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_integers_fail_1() {\n    random_integers(EXAMPLE_SEED, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_integers_fail_2() {\n    random_integers(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_integers_fail_3() {\n    random_integers(EXAMPLE_SEED, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_natural_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::random_natural_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn random_natural_integers_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_natural_integers(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_natural_integers() {\n    // mean bits = 1/64\n    let values = &[\"0\"; 20];\n    let common_values = &[\n        (\"0\", 984681),\n        (\"1\", 15077),\n        (\"2\", 121),\n        (\"3\", 116),\n        (\"6\", 2),\n        (\"4\", 1),\n        (\"5\", 1),\n        (\"7\", 1),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.015695000000000257),\n        standard_deviation: NiceFloat(0.12853281096935348),\n        skewness: NiceFloat(9.11690327111834),\n        excess_kurtosis: NiceFloat(110.73931175909136),\n    };\n    random_natural_integers_helper(\n        1,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 1\n    let values = &[\n        \"0\", \"14\", \"0\", \"8\", \"2\", \"6\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 500248),\n        (\"1\", 249491),\n        (\"2\", 62676),\n        (\"3\", 62465),\n        (\"7\", 15819),\n        (\"5\", 15781),\n        (\"6\", 15694),\n        (\"4\", 15518),\n        (\"13\", 3945),\n        (\"8\", 3895),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.289019000000012),\n        standard_deviation: NiceFloat(811.503067487901),\n        skewness: NiceFloat(791.581366511165),\n        excess_kurtosis: NiceFloat(717047.0759703598),\n    };\n    random_natural_integers_helper(\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"20431208470830262\",\n        \"2777240\",\n        \"114\",\n        \"12184833305054\",\n        \"1121025855008623490210\",\n        \"13478874522577592\",\n        \"115311695\",\n        \"7\",\n        \"18\",\n        \"54522366353\",\n        \"2183264193236231773387459\",\n        \"824\",\n        \"18558864232439549193912\",\n        \"15\",\n        \"110989\",\n        \"453270\",\n        \"4307150\",\n        \"45388024541\",\n        \"47\",\n        \"3345913274\",\n    ];\n    let common_values = &[\n        (\"0\", 30467),\n        (\"1\", 29379),\n        (\"3\", 14233),\n        (\"2\", 14194),\n        (\"7\", 6984),\n        (\"6\", 6980),\n        (\"4\", 6964),\n        (\"5\", 6929),\n        (\"10\", 3479),\n        (\"15\", 3431),\n    ];\n    let sample_median = (\"3201388\", Some(\"3201522\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.480305129633914e129),\n        standard_deviation: NiceFloat(2.4803051296331898e132),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_natural_integers_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1049807948069596877906281043152861735368289016372406\",\n        \"1388880088667859422\",\n        \"26145954\",\n        \"3731388\",\n        \"1470862095575962348216\",\n        \"99\",\n        \"1\",\n        \"835275153\",\n        \"3892061391890507266755\",\n        \"925334710331614885833504493368\",\n        \"221414670923422190\",\n        \"11239\",\n        \"254772031885\",\n        \"1351005164080654998\",\n        \"9136414433496904064275246960259217614\",\n        \"1775\",\n        \"5562\",\n        \"8137327159764\",\n        \"19744859531291384657393101375027010425831988999\",\n        \"2078424122508695\",\n    ];\n    let common_values = &[\n        (\"0\", 15386),\n        (\"1\", 15062),\n        (\"2\", 7592),\n        (\"3\", 7459),\n        (\"4\", 3719),\n        (\"5\", 3707),\n        (\"6\", 3685),\n        (\"7\", 3508),\n        (\"12\", 1906),\n        (\"11\", 1865),\n    ];\n    let sample_median = (\"15157534309527\", Some(\"15157859817105\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.8099447055615434e263),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_natural_integers_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_integers_fail_1() {\n    random_natural_integers(EXAMPLE_SEED, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_natural_integers_fail_2() {\n    random_natural_integers(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_natural_integers_fail_3() {\n    random_natural_integers(EXAMPLE_SEED, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_negative_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::random_negative_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn random_negative_integers_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_negative_integers(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_negative_integers() {\n    // mean bits = 65/64\n    let values = &[\"-1\"; 20];\n    let common_values = &[\n        (\"-1\", 984681),\n        (\"-3\", 7622),\n        (\"-2\", 7455),\n        (\"-5\", 73),\n        (\"-6\", 66),\n        (\"-7\", 54),\n        (\"-4\", 44),\n        (\"-8\", 2),\n        (\"-10\", 2),\n        (\"-14\", 1),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.023822000000005),\n        standard_deviation: NiceFloat(0.20727410662829246),\n        skewness: NiceFloat(-10.72004433095801),\n        excess_kurtosis: NiceFloat(159.60627558337237),\n    };\n    random_negative_integers_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-1\", \"-24\", \"-1\", \"-30\", \"-6\", \"-12\", \"-2\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-2\", \"-2\",\n        \"-1\", \"-1\", \"-3\", \"-3\", \"-1\", \"-1\",\n    ];\n    let common_values = &[\n        (\"-1\", 500248),\n        (\"-3\", 124972),\n        (\"-2\", 124519),\n        (\"-7\", 31554),\n        (\"-5\", 31346),\n        (\"-6\", 31198),\n        (\"-4\", 31043),\n        (\"-12\", 8033),\n        (\"-11\", 7959),\n        (\"-10\", 7935),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-15.68562000000007),\n        standard_deviation: NiceFloat(2088.3045530403606),\n        skewness: NiceFloat(-877.2889258611025),\n        excess_kurtosis: NiceFloat(832799.3689336807),\n    };\n    random_negative_integers_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-22\",\n        \"-4\",\n        \"-178\",\n        \"-55845661150\",\n        \"-93254818\",\n        \"-7577967529619388\",\n        \"-8\",\n        \"-11316951483471\",\n        \"-11\",\n        \"-1005760138411689342464923704482\",\n        \"-948931\",\n        \"-42716754\",\n        \"-81013760999253680590984897748479904878392\",\n        \"-23\",\n        \"-5\",\n        \"-488225822927510\",\n        \"-1558028859598\",\n        \"-29\",\n        \"-200127331174844881647\",\n        \"-4058622214797175252\",\n    ];\n    let common_values = &[\n        (\"-1\", 31094),\n        (\"-2\", 15260),\n        (\"-3\", 15185),\n        (\"-4\", 7586),\n        (\"-5\", 7376),\n        (\"-7\", 7346),\n        (\"-6\", 7258),\n        (\"-10\", 3631),\n        (\"-14\", 3607),\n        (\"-11\", 3605),\n    ];\n    let sample_median = (\"-3799067\", Some(\"-3799061\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.312362311300544e130),\n        standard_deviation: NiceFloat(2.3122865276852406e133),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_integers_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-1030304779202860497815440824491190\",\n        \"-886085025458\",\n        \"-207326\",\n        \"-83590267817164982586207812646050\",\n        \"-142592182196136038718074156629812683467448\",\n        \"-486577913627642327503939268330036386\",\n        \"-5557920650918595\",\n        \"-82\",\n        \"-3896\",\n        \"-259694111319673990840\",\n        \"-38511521798151392412656616617957654586378660839\",\n        \"-637134\",\n        \"-2330568192653124764618470467652346596061\",\n        \"-2516\",\n        \"-512663303\",\n        \"-39317568409\",\n        \"-18536901993439\",\n        \"-4959577657266999117207\",\n        \"-628\",\n        \"-42485719907732979\",\n    ];\n    let common_values = &[\n        (\"-1\", 15720),\n        (\"-2\", 7718),\n        (\"-3\", 7584),\n        (\"-6\", 3790),\n        (\"-4\", 3739),\n        (\"-7\", 3704),\n        (\"-5\", 3673),\n        (\"-9\", 1918),\n        (\"-11\", 1916),\n        (\"-10\", 1904),\n    ];\n    let sample_median = (\"-18438360920148\", Some(\"-18436851140261\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.519478531998525e283),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_integers_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_negative_integers_fail_1() {\n    random_negative_integers(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_negative_integers_fail_2() {\n    random_negative_integers(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_nonzero_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::random_nonzero_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn random_nonzero_integers_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_nonzero_integers(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_nonzero_integers() {\n    // mean bits = 65/64\n    let values = &[\n        \"1\", \"1\", \"1\", \"-1\", \"-1\", \"-1\", \"1\", \"-1\", \"-1\", \"1\", \"1\", \"1\", \"-1\", \"-1\", \"-1\", \"-1\",\n        \"1\", \"1\", \"-1\", \"-1\",\n    ];\n    let common_values = &[\n        (\"1\", 492842),\n        (\"-1\", 491818),\n        (\"2\", 3836),\n        (\"3\", 3803),\n        (\"-2\", 3744),\n        (\"-3\", 3718),\n        (\"6\", 39),\n        (\"5\", 33),\n        (\"-6\", 32),\n        (\"-5\", 31),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.001516999999999985),\n        standard_deviation: NiceFloat(1.0444624404988267),\n        skewness: NiceFloat(-0.00031392947248860435),\n        excess_kurtosis: NiceFloat(-1.2267327517337354),\n    };\n    random_nonzero_integers_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"6\", \"1\", \"6\", \"-14\", \"-1\", \"-1\", \"1\", \"-1\", \"-3\", \"6\", \"5\", \"7\", \"-1\", \"-1\", \"-2\", \"-14\",\n        \"1\", \"5\", \"-14\", \"-1\",\n    ];\n    let common_values = &[\n        (\"1\", 249934),\n        (\"-1\", 249480),\n        (\"3\", 62818),\n        (\"-3\", 62545),\n        (\"2\", 62282),\n        (\"-2\", 62281),\n        (\"-7\", 15874),\n        (\"7\", 15794),\n        (\"6\", 15750),\n        (\"-5\", 15696),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.677845999999954),\n        standard_deviation: NiceFloat(1282.3370760759833),\n        skewness: NiceFloat(271.563399149848),\n        excess_kurtosis: NiceFloat(320730.53239180415),\n    };\n    random_nonzero_integers_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"6\",\n        \"373973144\",\n        \"46887963477285686350042496363292819122\",\n        \"-93254818\",\n        \"-126908\",\n        \"-4471675267836600\",\n        \"1860142159\",\n        \"-118004986915853475\",\n        \"-98\",\n        \"346513\",\n        \"18250435\",\n        \"511570\",\n        \"-7230971744056\",\n        \"-28344\",\n        \"-1006\",\n        \"-1\",\n        \"45\",\n        \"53968471397952150\",\n        \"-1\",\n        \"-5655261\",\n    ];\n    let common_values = &[\n        (\"1\", 15709),\n        (\"-1\", 15677),\n        (\"-3\", 7735),\n        (\"3\", 7574),\n        (\"-2\", 7514),\n        (\"2\", 7484),\n        (\"-7\", 3755),\n        (\"7\", 3713),\n        (\"4\", 3712),\n        (\"5\", 3676),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.1307602130166568e111),\n        standard_deviation: NiceFloat(2.1307597326341758e114),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_integers_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"121396406\",\n        \"28091526743610625648357683081915367485486380400402584\",\n        \"674\",\n        \"-503972648740684226424764\",\n        \"-261225431937620249973589071\",\n        \"-1744034\",\n        \"1\",\n        \"-96963\",\n        \"-33563594322\",\n        \"1085240\",\n        \"221961187000\",\n        \"104563169774\",\n        \"-799255527\",\n        \"-32987221556354134413\",\n        \"-8799240150400653965518\",\n        \"-940783\",\n        \"954\",\n        \"16689620\",\n        \"-392696864519\",\n        \"-31641\",\n    ];\n    let common_values = &[\n        (\"1\", 7878),\n        (\"-1\", 7830),\n        (\"-3\", 3920),\n        (\"-2\", 3913),\n        (\"3\", 3882),\n        (\"2\", 3809),\n        (\"-7\", 1974),\n        (\"4\", 1950),\n        (\"-6\", 1939),\n        (\"-4\", 1892),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_integers_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_integers_fail_1() {\n    random_nonzero_integers(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_integers_fail_2() {\n    random_nonzero_integers(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/random_positive_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::random_positive_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn random_positive_integers_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        random_positive_integers(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_integers() {\n    // mean bits = 65/64\n    let values = &[\"1\"; 20];\n    let common_values = &[\n        (\"1\", 984681),\n        (\"3\", 7622),\n        (\"2\", 7455),\n        (\"5\", 73),\n        (\"6\", 66),\n        (\"7\", 54),\n        (\"4\", 44),\n        (\"8\", 2),\n        (\"10\", 2),\n        (\"14\", 1),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.023822000000005),\n        standard_deviation: NiceFloat(0.20727410662829246),\n        skewness: NiceFloat(10.72004433095801),\n        excess_kurtosis: NiceFloat(159.60627558337237),\n    };\n    random_positive_integers_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"1\", \"24\", \"1\", \"30\", \"6\", \"12\", \"2\", \"1\", \"1\", \"1\", \"1\", \"1\", \"2\", \"2\", \"1\", \"1\", \"3\",\n        \"3\", \"1\", \"1\",\n    ];\n    let common_values = &[\n        (\"1\", 500248),\n        (\"3\", 124972),\n        (\"2\", 124519),\n        (\"7\", 31554),\n        (\"5\", 31346),\n        (\"6\", 31198),\n        (\"4\", 31043),\n        (\"12\", 8033),\n        (\"11\", 7959),\n        (\"10\", 7935),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(15.68562000000007),\n        standard_deviation: NiceFloat(2088.3045530403606),\n        skewness: NiceFloat(877.2889258611025),\n        excess_kurtosis: NiceFloat(832799.3689336807),\n    };\n    random_positive_integers_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"22\",\n        \"4\",\n        \"178\",\n        \"55845661150\",\n        \"93254818\",\n        \"7577967529619388\",\n        \"8\",\n        \"11316951483471\",\n        \"11\",\n        \"1005760138411689342464923704482\",\n        \"948931\",\n        \"42716754\",\n        \"81013760999253680590984897748479904878392\",\n        \"23\",\n        \"5\",\n        \"488225822927510\",\n        \"1558028859598\",\n        \"29\",\n        \"200127331174844881647\",\n        \"4058622214797175252\",\n    ];\n    let common_values = &[\n        (\"1\", 31094),\n        (\"2\", 15260),\n        (\"3\", 15185),\n        (\"4\", 7586),\n        (\"5\", 7376),\n        (\"7\", 7346),\n        (\"6\", 7258),\n        (\"10\", 3631),\n        (\"14\", 3607),\n        (\"11\", 3605),\n    ];\n    let sample_median = (\"3799061\", Some(\"3799067\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.312362311300544e130),\n        standard_deviation: NiceFloat(2.3122865276852406e133),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_integers_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1030304779202860497815440824491190\",\n        \"886085025458\",\n        \"207326\",\n        \"83590267817164982586207812646050\",\n        \"142592182196136038718074156629812683467448\",\n        \"486577913627642327503939268330036386\",\n        \"5557920650918595\",\n        \"82\",\n        \"3896\",\n        \"259694111319673990840\",\n        \"38511521798151392412656616617957654586378660839\",\n        \"637134\",\n        \"2330568192653124764618470467652346596061\",\n        \"2516\",\n        \"512663303\",\n        \"39317568409\",\n        \"18536901993439\",\n        \"4959577657266999117207\",\n        \"628\",\n        \"42485719907732979\",\n    ];\n    let common_values = &[\n        (\"1\", 15720),\n        (\"2\", 7718),\n        (\"3\", 7584),\n        (\"6\", 3790),\n        (\"4\", 3739),\n        (\"7\", 3704),\n        (\"5\", 3673),\n        (\"9\", 1918),\n        (\"11\", 1916),\n        (\"10\", 1904),\n    ];\n    let sample_median = (\"18436851140261\", Some(\"18438360920148\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.519478531998525e283),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_integers_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_positive_integers_fail_1() {\n    random_positive_integers(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_integers_fail_2() {\n    random_positive_integers(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_integer_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::striped_random_integer_inclusive_range;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_integer_inclusive_range_helper(\n    a: &str,\n    b: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_integer_inclusive_range(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            Integer::from_str(b).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_integer_inclusive_range() {\n    let values = &[\n        \"1990\", \"1991\", \"1991\", \"2006\", \"1996\", \"1991\", \"2020\", \"1991\", \"1990\", \"2014\", \"1990\",\n        \"2020\", \"1991\", \"1990\", \"2020\", \"1991\", \"2015\", \"2020\", \"2016\", \"2016\",\n    ];\n    let common_values = &[\n        (\"1990\", 141061),\n        (\"1991\", 140282),\n        (\"2016\", 140025),\n        (\"2021\", 125104),\n        (\"2020\", 124770),\n        (\"2017\", 47126),\n        (\"2019\", 46880),\n        (\"1999\", 39864),\n        (\"2015\", 39502),\n        (\"2018\", 15866),\n    ];\n    let sample_median = (\"2015\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2007.63283599996),\n        standard_deviation: NiceFloat(12.714969927906306),\n        skewness: NiceFloat(-0.39110989081904446),\n        excess_kurtosis: NiceFloat(-1.6497443674417989),\n    };\n    striped_random_integer_inclusive_range_helper(\n        \"1990\",\n        \"2021\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-1990\", \"-1991\", \"-1991\", \"-2006\", \"-1996\", \"-1991\", \"-2020\", \"-1991\", \"-1990\", \"-2014\",\n        \"-1990\", \"-2020\", \"-1991\", \"-1990\", \"-2020\", \"-1991\", \"-2015\", \"-2020\", \"-2016\", \"-2016\",\n    ];\n    let common_values = &[\n        (\"-1990\", 141061),\n        (\"-1991\", 140282),\n        (\"-2016\", 140025),\n        (\"-2021\", 125104),\n        (\"-2020\", 124770),\n        (\"-2017\", 47126),\n        (\"-2019\", 46880),\n        (\"-1999\", 39864),\n        (\"-2015\", 39502),\n        (\"-2018\", 15866),\n    ];\n    let sample_median = (\"-2015\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2007.63283599996),\n        standard_deviation: NiceFloat(12.714969927906306),\n        skewness: NiceFloat(0.39110989081904446),\n        excess_kurtosis: NiceFloat(-1.6497443674417989),\n    };\n    striped_random_integer_inclusive_range_helper(\n        \"-2021\",\n        \"-1990\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-1792\", \"-1766\", \"1551\", \"111\", \"-1567\", \"16\", \"1985\", \"142\", \"1935\", \"992\", \"3\", \"-510\",\n        \"1984\", \"-624\", \"-30\", \"-1542\", \"-1\", \"-2017\", \"-1927\", \"-7\",\n    ];\n    let common_values = &[\n        (\"1990\", 29612),\n        (\"1984\", 22443),\n        (\"-1\", 19100),\n        (\"-2016\", 16609),\n        (\"-2021\", 14942),\n        (\"-2020\", 14868),\n        (\"0\", 13951),\n        (\"1985\", 7476),\n        (\"1987\", 7411),\n        (\"1988\", 7362),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.049800999999855),\n        standard_deviation: NiceFloat(1269.7724478413352),\n        skewness: NiceFloat(-0.007894098306828256),\n        excess_kurtosis: NiceFloat(-1.0358454536315198),\n    };\n    striped_random_integer_inclusive_range_helper(\n        \"-2021\",\n        \"1990\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_inclusive_range_fail_1() {\n    striped_random_integer_inclusive_range(\n        EXAMPLE_SEED,\n        Integer::from(10u32),\n        Integer::from(100u32),\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_inclusive_range_fail_2() {\n    striped_random_integer_inclusive_range(\n        EXAMPLE_SEED,\n        Integer::from(10u32),\n        Integer::from(100u32),\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_inclusive_range_fail_3() {\n    striped_random_integer_inclusive_range(\n        EXAMPLE_SEED,\n        Integer::from(10u32),\n        Integer::from(9u32),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_integer_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::striped_random_integer_range;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_integer_range_helper(\n    a: &str,\n    b: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_integer_range(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            Integer::from_str(b).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_integer_range() {\n    let values = &[\n        \"1990\", \"1991\", \"1991\", \"2006\", \"1996\", \"1991\", \"2020\", \"1991\", \"1990\", \"2014\", \"1990\",\n        \"2020\", \"1991\", \"1990\", \"2020\", \"1991\", \"2015\", \"2020\", \"2016\", \"2016\",\n    ];\n    let common_values = &[\n        (\"1990\", 141061),\n        (\"1991\", 140282),\n        (\"2016\", 140025),\n        (\"2021\", 125104),\n        (\"2020\", 124770),\n        (\"2017\", 47126),\n        (\"2019\", 46880),\n        (\"1999\", 39864),\n        (\"2015\", 39502),\n        (\"2018\", 15866),\n    ];\n    let sample_median = (\"2015\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2007.63283599996),\n        standard_deviation: NiceFloat(12.714969927906306),\n        skewness: NiceFloat(-0.39110989081904446),\n        excess_kurtosis: NiceFloat(-1.6497443674417989),\n    };\n    striped_random_integer_range_helper(\n        \"1990\",\n        \"2022\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-1990\", \"-1991\", \"-1991\", \"-2006\", \"-1996\", \"-1991\", \"-2020\", \"-1991\", \"-1990\", \"-2014\",\n        \"-1990\", \"-2020\", \"-1991\", \"-1990\", \"-2020\", \"-1991\", \"-2015\", \"-2020\", \"-2016\", \"-2016\",\n    ];\n    let common_values = &[\n        (\"-1990\", 141061),\n        (\"-1991\", 140282),\n        (\"-2016\", 140025),\n        (\"-2021\", 125104),\n        (\"-2020\", 124770),\n        (\"-2017\", 47126),\n        (\"-2019\", 46880),\n        (\"-1999\", 39864),\n        (\"-2015\", 39502),\n        (\"-2018\", 15866),\n    ];\n    let sample_median = (\"-2015\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2007.63283599996),\n        standard_deviation: NiceFloat(12.714969927906306),\n        skewness: NiceFloat(0.39110989081904446),\n        excess_kurtosis: NiceFloat(-1.6497443674417989),\n    };\n    striped_random_integer_range_helper(\n        \"-2021\",\n        \"-1989\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-1792\", \"-1766\", \"1551\", \"111\", \"-1567\", \"16\", \"1985\", \"142\", \"1935\", \"992\", \"3\", \"-510\",\n        \"1984\", \"-624\", \"-30\", \"-1542\", \"-1\", \"-2017\", \"-1927\", \"-7\",\n    ];\n    let common_values = &[\n        (\"1990\", 29612),\n        (\"1984\", 22443),\n        (\"-1\", 19100),\n        (\"-2016\", 16609),\n        (\"-2021\", 14942),\n        (\"-2020\", 14868),\n        (\"0\", 13951),\n        (\"1985\", 7476),\n        (\"1987\", 7411),\n        (\"1988\", 7362),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.049800999999855),\n        standard_deviation: NiceFloat(1269.7724478413352),\n        skewness: NiceFloat(-0.007894098306828256),\n        excess_kurtosis: NiceFloat(-1.0358454536315198),\n    };\n    striped_random_integer_range_helper(\n        \"-2021\",\n        \"1991\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_fail_1() {\n    striped_random_integer_range(\n        EXAMPLE_SEED,\n        Integer::from(10u32),\n        Integer::from(100u32),\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_fail_2() {\n    striped_random_integer_range(\n        EXAMPLE_SEED,\n        Integer::from(10u32),\n        Integer::from(100u32),\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_fail_3() {\n    striped_random_integer_range(\n        EXAMPLE_SEED,\n        Integer::from(10u32),\n        Integer::from(9u32),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_integer_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::striped_random_integer_range_to_infinity;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_integer_range_to_infinity_helper(\n    a: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_integer_range_to_infinity(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_integer_range_to_infinity() {\n    let values = &[\n        \"2\",\n        \"4\",\n        \"128\",\n        \"1124203576\",\n        \"4\",\n        \"15\",\n        \"32\",\n        \"751\",\n        \"6400\",\n        \"8376024595\",\n        \"3\",\n        \"60\",\n        \"1\",\n        \"1\",\n        \"65045535\",\n        \"6\",\n        \"0\",\n        \"7\",\n        \"73608\",\n        \"719661083353407616\",\n    ];\n    let common_values = &[\n        (\"0\", 90859),\n        (\"1\", 82901),\n        (\"3\", 37653),\n        (\"2\", 37438),\n        (\"7\", 25786),\n        (\"4\", 25681),\n        (\"8\", 17394),\n        (\"15\", 17328),\n        (\"16\", 12055),\n        (\"31\", 11982),\n    ];\n    let sample_median = (\"71\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.068551928510147e34),\n        standard_deviation: NiceFloat(6.914607365781463e37),\n        skewness: NiceFloat(958.8924868378492),\n        excess_kurtosis: NiceFloat(939262.8054862365),\n    };\n    striped_random_integer_range_to_infinity_helper(\n        \"0\",\n        4,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"8192\", \"8312\", \"15614\", \"1984\", \"1568\", \"1021\", \"1791\", \"260174\", \"9855\", \"98176\", \"1519\",\n        \"2591\", \"3616\", \"8176\", \"1796\", \"8167\", \"262616\", \"4069\", \"12062\", \"1072\",\n    ];\n    let common_values = &[\n        (\"1023\", 31964),\n        (\"1007\", 28139),\n        (\"1000\", 28045),\n        (\"1008\", 10625),\n        (\"1022\", 10572),\n        (\"1016\", 10499),\n        (\"1020\", 10300),\n        (\"1004\", 9705),\n        (\"1006\", 9498),\n        (\"1003\", 9422),\n    ];\n    let sample_median = (\"4159\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(54201665904379.625),\n        standard_deviation: NiceFloat(2.6365321443458296e16),\n        skewness: NiceFloat(608.9470987335318),\n        excess_kurtosis: NiceFloat(388228.1677811064),\n    };\n    striped_random_integer_range_to_infinity_helper(\n        \"1000\",\n        4,\n        1,\n        14,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"8192\",\n        \"2\",\n        \"1084\",\n        \"18871288\",\n        \"-192\",\n        \"519\",\n        \"8\",\n        \"16769337\",\n        \"-408\",\n        \"-65\",\n        \"-11\",\n        \"388992\",\n        \"8\",\n        \"0\",\n        \"-188\",\n        \"0\",\n        \"67044287\",\n        \"3297545015170\",\n        \"-57\",\n        \"4\",\n    ];\n    let common_values = &[\n        (\"0\", 58215),\n        (\"-1\", 53215),\n        (\"1\", 52942),\n        (\"3\", 24172),\n        (\"-3\", 24170),\n        (\"-2\", 24102),\n        (\"2\", 24042),\n        (\"7\", 16555),\n        (\"-7\", 16514),\n        (\"4\", 16507),\n    ];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5127815180423845e54),\n        standard_deviation: NiceFloat(1.512781518042442e57),\n        skewness: NiceFloat(999.9984999993533),\n        excess_kurtosis: NiceFloat(999995.0000009801),\n    };\n    striped_random_integer_range_to_infinity_helper(\n        \"-1000\",\n        4,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_infinity_fail_1() {\n    striped_random_integer_range_to_infinity(EXAMPLE_SEED, Integer::from(100u32), 1, 0, 10, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_infinity_fail_2() {\n    striped_random_integer_range_to_infinity(EXAMPLE_SEED, Integer::from(100u32), 1, 1, 10, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_infinity_fail_3() {\n    striped_random_integer_range_to_infinity(EXAMPLE_SEED, Integer::from(100u32), 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_infinity_fail_4() {\n    striped_random_integer_range_to_infinity(EXAMPLE_SEED, Integer::from(100u32), 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_integer_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::striped_random_integer_range_to_negative_infinity;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_integer_range_to_negative_infinity_helper(\n    a: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_integer_range_to_negative_infinity(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_integer_range_to_negative_infinity() {\n    let values = &[\n        \"-2\",\n        \"-4\",\n        \"-128\",\n        \"-1124203576\",\n        \"-4\",\n        \"-15\",\n        \"-32\",\n        \"-751\",\n        \"-6400\",\n        \"-8376024595\",\n        \"-3\",\n        \"-60\",\n        \"-1\",\n        \"-1\",\n        \"-65045535\",\n        \"-6\",\n        \"0\",\n        \"-7\",\n        \"-73608\",\n        \"-719661083353407616\",\n    ];\n    let common_values = &[\n        (\"0\", 90859),\n        (\"-1\", 82901),\n        (\"-3\", 37653),\n        (\"-2\", 37438),\n        (\"-7\", 25786),\n        (\"-4\", 25681),\n        (\"-8\", 17394),\n        (\"-15\", 17328),\n        (\"-16\", 12055),\n        (\"-31\", 11982),\n    ];\n    let sample_median = (\"-71\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.068551928510147e34),\n        standard_deviation: NiceFloat(6.914607365781463e37),\n        skewness: NiceFloat(-958.8924868378492),\n        excess_kurtosis: NiceFloat(939262.8054862365),\n    };\n    striped_random_integer_range_to_negative_infinity_helper(\n        \"0\",\n        4,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"4\",\n        \"2\",\n        \"-1024\",\n        \"-270182996582056056\",\n        \"-263128\",\n        \"798\",\n        \"-15\",\n        \"-16744652\",\n        \"479\",\n        \"68\",\n        \"11\",\n        \"-1072708599\",\n        \"-10\",\n        \"0\",\n        \"240\",\n        \"0\",\n        \"-34521100\",\n        \"-4385034796639\",\n        \"-60\",\n        \"-7\",\n    ];\n    let common_values = &[\n        (\"0\", 58400),\n        (\"1\", 53191),\n        (\"-1\", 53081),\n        (\"-3\", 24269),\n        (\"3\", 24150),\n        (\"2\", 24142),\n        (\"-2\", 23864),\n        (\"7\", 16659),\n        (\"4\", 16517),\n        (\"-4\", 16397),\n    ];\n    let sample_median = (\"-3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.9240865426395e50),\n        standard_deviation: NiceFloat(3.92408654263964e53),\n        skewness: NiceFloat(-999.9984999993759),\n        excess_kurtosis: NiceFloat(999995.0000009785),\n    };\n    striped_random_integer_range_to_negative_infinity_helper(\n        \"1000\",\n        4,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-8192\", \"-8312\", \"-15614\", \"-1984\", \"-1568\", \"-1009\", \"-1791\", \"-260174\", \"-9855\",\n        \"-98176\", \"-1519\", \"-2591\", \"-3616\", \"-8176\", \"-1796\", \"-8167\", \"-262616\", \"-4069\",\n        \"-12062\", \"-1072\",\n    ];\n    let common_values = &[\n        (\"-1023\", 31892),\n        (\"-1007\", 28274),\n        (\"-1000\", 28157),\n        (\"-1008\", 10740),\n        (\"-1022\", 10689),\n        (\"-1016\", 10551),\n        (\"-1020\", 10510),\n        (\"-1001\", 9498),\n        (\"-1004\", 9330),\n        (\"-1006\", 9302),\n    ];\n    let sample_median = (\"-4159\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-54201665904379.41),\n        standard_deviation: NiceFloat(2.6365321443458296e16),\n        skewness: NiceFloat(-608.9470987335318),\n        excess_kurtosis: NiceFloat(388228.1677811064),\n    };\n    striped_random_integer_range_to_negative_infinity_helper(\n        \"-1000\",\n        4,\n        1,\n        14,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_negative_infinity_fail_1() {\n    striped_random_integer_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Integer::from(100),\n        1,\n        0,\n        10,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_negative_infinity_fail_2() {\n    striped_random_integer_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Integer::from(100),\n        1,\n        1,\n        10,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_negative_infinity_fail_3() {\n    striped_random_integer_range_to_negative_infinity(EXAMPLE_SEED, Integer::from(100), 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integer_range_to_negative_infinity_fail_4() {\n    striped_random_integer_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Integer::from(-100),\n        4,\n        1,\n        2,\n        3,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::striped_random_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn striped_random_integers_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_integers(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_integers() {\n    // mean bits = 1/64\n    let values = &[\"0\"; 20];\n    let common_values = &[\n        (\"0\", 969830),\n        (\"1\", 14858),\n        (\"-1\", 14856),\n        (\"-3\", 135),\n        (\"2\", 115),\n        (\"-2\", 115),\n        (\"3\", 84),\n        (\"-7\", 3),\n        (\"4\", 2),\n        (\"7\", 1),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.00016100000000001123),\n        standard_deviation: NiceFloat(0.18124295000911678),\n        skewness: NiceFloat(-0.332760005499994),\n        excess_kurtosis: NiceFloat(53.997755862907425),\n    };\n    striped_random_integers_helper(\n        4,\n        1,\n        1,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 1\n    let values = &[\n        \"2\", \"-2\", \"-4\", \"0\", \"0\", \"-1\", \"-2\", \"-3\", \"2\", \"0\", \"0\", \"-1\", \"-4\", \"-3\", \"7\", \"0\",\n        \"1\", \"1\", \"1\", \"-3\",\n    ];\n    let common_values = &[\n        (\"0\", 332922),\n        (\"-1\", 166652),\n        (\"1\", 166524),\n        (\"2\", 42176),\n        (\"3\", 41573),\n        (\"-2\", 41508),\n        (\"-3\", 41328),\n        (\"4\", 15789),\n        (\"-7\", 15751),\n        (\"7\", 15560),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.8722809999999835),\n        standard_deviation: NiceFloat(809.560511708087),\n        skewness: NiceFloat(-339.00725481029485),\n        excess_kurtosis: NiceFloat(238310.7740951809),\n    };\n    striped_random_integers_helper(\n        4,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"65536\",\n        \"75521006248971741167616\",\n        \"32\",\n        \"-2199023255520\",\n        \"-68719468544\",\n        \"-527\",\n        \"0\",\n        \"-112\",\n        \"131071\",\n        \"4152\",\n        \"262143\",\n        \"-262145\",\n        \"-8192\",\n        \"-137405429760\",\n        \"-4294967296\",\n        \"1219\",\n        \"16\",\n        \"-1023\",\n        \"-32768\",\n        \"-32\",\n    ];\n    let common_values = &[\n        (\"0\", 15405),\n        (\"1\", 15074),\n        (\"-1\", 14891),\n        (\"-3\", 7324),\n        (\"2\", 7197),\n        (\"3\", 7140),\n        (\"-2\", 7136),\n        (\"7\", 6709),\n        (\"-7\", 6675),\n        (\"-4\", 6660),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.1248652082766593e155),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_integers_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"8192\",\n        \"178427569518544464724715670468776264076361728\",\n        \"8176\",\n        \"-262144\",\n        \"-268435456\",\n        \"-226655146685469074391039\",\n        \"4294967296\",\n        \"-67108863\",\n        \"-19807040628566083848630173696\",\n        \"45671926166590716193865150952632647489410830335\",\n        \"43978334404607\",\n        \"252172839656924666985926477663676528888687738185461429445660194859797887186474365257113263\\\n        9068666062843684114535546880\",\n        \"-1728806579227565766676057273846916536097145074328900789155504620306432\",\n        \"-4194304\",\n        \"-16777215\",\n        \"-1\",\n        \"43556142803623322374103370143943282917375\",\n        \"31742\",\n        \"-4123168604160\",\n        \"-129703669268270284799\",\n    ];\n    let common_values = &[\n        (\"0\", 7696),\n        (\"-1\", 7685),\n        (\"1\", 7575),\n        (\"-2\", 3831),\n        (\"-3\", 3742),\n        (\"3\", 3735),\n        (\"2\", 3661),\n        (\"-4\", 3643),\n        (\"7\", 3615),\n        (\"4\", 3570),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.346385398054525e248),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_integers_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integers_fail_1() {\n    striped_random_integers(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integers_fail_2() {\n    striped_random_integers(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integers_fail_3() {\n    striped_random_integers(EXAMPLE_SEED, 4, 1, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integers_fail_4() {\n    striped_random_integers(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_integers_fail_5() {\n    striped_random_integers(EXAMPLE_SEED, 4, 1, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_natural_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::striped_random_natural_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn striped_random_natural_integers_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_natural_integers(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_natural_integers() {\n    // mean bits = 1/64\n    let values = &[\"0\"; 20];\n    let common_values =\n        &[(\"0\", 984681), (\"1\", 15077), (\"3\", 120), (\"2\", 117), (\"4\", 3), (\"5\", 1), (\"7\", 1)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.015695000000000875),\n        standard_deviation: NiceFloat(0.12845498618458842),\n        skewness: NiceFloat(9.02636021695415),\n        excess_kurtosis: NiceFloat(104.38317092740806),\n    };\n    striped_random_natural_integers_helper(\n        4,\n        1,\n        1,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 1\n    let values = &[\n        \"0\", \"8\", \"0\", \"8\", \"2\", \"4\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 500248),\n        (\"1\", 249491),\n        (\"3\", 62636),\n        (\"2\", 62505),\n        (\"4\", 23595),\n        (\"7\", 23447),\n        (\"8\", 8713),\n        (\"15\", 8690),\n        (\"6\", 7938),\n        (\"5\", 7832),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.16843100000002),\n        standard_deviation: NiceFloat(782.5565010647151),\n        skewness: NiceFloat(800.2073401417995),\n        excess_kurtosis: NiceFloat(728738.7203924827),\n    };\n    striped_random_natural_integers_helper(\n        4,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"18014656207519744\",\n        \"2228160\",\n        \"64\",\n        \"17592184995840\",\n        \"1179440951012584587264\",\n        \"9007749010526207\",\n        \"67108864\",\n        \"5\",\n        \"24\",\n        \"34359738879\",\n        \"2417851639228158863474687\",\n        \"512\",\n        \"9444737328601429442560\",\n        \"8\",\n        \"131071\",\n        \"524032\",\n        \"8388607\",\n        \"34359738368\",\n        \"60\",\n        \"2147741695\",\n    ];\n    let common_values = &[\n        (\"0\", 30467),\n        (\"1\", 29379),\n        (\"3\", 14232),\n        (\"2\", 14195),\n        (\"4\", 13131),\n        (\"7\", 13019),\n        (\"8\", 11921),\n        (\"15\", 11751),\n        (\"31\", 10682),\n        (\"16\", 10555),\n    ];\n    let sample_median = (\"3670016\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.459178425232889e129),\n        standard_deviation: NiceFloat(1.459178425232619e132),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_natural_integers_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1473193827441715154886135497317777215948837626052608\",\n        \"1152921504606846976\",\n        \"16777216\",\n        \"4128768\",\n        \"1180591620717412351744\",\n        \"127\",\n        \"1\",\n        \"1073741823\",\n        \"4722366482869645209600\",\n        \"1267650600226049676594364547199\",\n        \"288230376151711743\",\n        \"8192\",\n        \"274869520368\",\n        \"1152921504606846976\",\n        \"5317074242107007699768820031345917967\",\n        \"1024\",\n        \"8191\",\n        \"4398046511104\",\n        \"11417981541647679048466288345891489974790914528\",\n        \"2251799813685247\",\n    ];\n    let common_values = &[\n        (\"0\", 15386),\n        (\"1\", 15062),\n        (\"2\", 7584),\n        (\"3\", 7467),\n        (\"4\", 7110),\n        (\"7\", 7017),\n        (\"8\", 6866),\n        (\"15\", 6763),\n        (\"31\", 6505),\n        (\"16\", 6460),\n    ];\n    let sample_median = (\"17592169267200\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.6414828903095017e263),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_natural_integers_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_integers_fail_1() {\n    striped_random_natural_integers(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_integers_fail_2() {\n    striped_random_natural_integers(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_integers_fail_3() {\n    striped_random_natural_integers(EXAMPLE_SEED, 4, 1, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_integers_fail_4() {\n    striped_random_natural_integers(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_integers_fail_5() {\n    striped_random_natural_integers(EXAMPLE_SEED, 4, 1, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_negative_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::striped_random_negative_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn striped_random_negative_integers_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_negative_integers(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_negative_integers() {\n    // mean bits = 65/64\n    let values = &[\"-1\"; 20];\n    let common_values = &[\n        (\"-1\", 984681),\n        (\"-3\", 7637),\n        (\"-2\", 7440),\n        (\"-4\", 97),\n        (\"-7\", 78),\n        (\"-5\", 33),\n        (\"-6\", 29),\n        (\"-11\", 2),\n        (\"-8\", 1),\n        (\"-9\", 1),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.023796999999977),\n        standard_deviation: NiceFloat(0.20691241046333197),\n        skewness: NiceFloat(-10.752762867801868),\n        excess_kurtosis: NiceFloat(162.40220891738076),\n    };\n    striped_random_negative_integers_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-1\", \"-16\", \"-1\", \"-16\", \"-4\", \"-15\", \"-2\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-2\", \"-2\",\n        \"-1\", \"-1\", \"-3\", \"-2\", \"-1\", \"-1\",\n    ];\n    let common_values = &[\n        (\"-1\", 500248),\n        (\"-2\", 124818),\n        (\"-3\", 124673),\n        (\"-7\", 47032),\n        (\"-4\", 46853),\n        (\"-8\", 17749),\n        (\"-15\", 17612),\n        (\"-5\", 15660),\n        (\"-6\", 15596),\n        (\"-16\", 6518),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-15.773014000000762),\n        standard_deviation: NiceFloat(2128.8810534178506),\n        skewness: NiceFloat(-884.8410850537254),\n        excess_kurtosis: NiceFloat(843254.2507640689),\n    };\n    striped_random_negative_integers_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-16\",\n        \"-4\",\n        \"-128\",\n        \"-34391195648\",\n        \"-75493376\",\n        \"-9007199120523391\",\n        \"-8\",\n        \"-8796094070783\",\n        \"-8\",\n        \"-950737950171027935941967741439\",\n        \"-1040391\",\n        \"-33554432\",\n        \"-84390026996392738938916902643112875376640\",\n        \"-30\",\n        \"-7\",\n        \"-554153860399104\",\n        \"-2199023255551\",\n        \"-16\",\n        \"-220784470296873664512\",\n        \"-4611685966886694919\",\n    ];\n    let common_values = &[\n        (\"-1\", 31094),\n        (\"-3\", 15250),\n        (\"-2\", 15195),\n        (\"-7\", 13890),\n        (\"-4\", 13880),\n        (\"-8\", 12601),\n        (\"-15\", 12519),\n        (\"-31\", 11397),\n        (\"-16\", 11237),\n        (\"-63\", 10225),\n    ];\n    let sample_median = (\"-4194272\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.1641486095650758e130),\n        standard_deviation: NiceFloat(1.1640776313097e133),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_negative_integers_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-649037107316853596555600210165760\",\n        \"-822486237184\",\n        \"-196608\",\n        \"-141976867225561692967630759002112\",\n        \"-174223242635524708377374895198005052307456\",\n        \"-664594824829454142366461086851399679\",\n        \"-4503599627370496\",\n        \"-127\",\n        \"-2048\",\n        \"-147574233996470517759\",\n        \"-45660775794157599311165096735019350831520546815\",\n        \"-1048320\",\n        \"-1361212544433490269424560431578983940096\",\n        \"-3968\",\n        \"-536870911\",\n        \"-34359738368\",\n        \"-35184372088831\",\n        \"-9297159013149614014464\",\n        \"-768\",\n        \"-72040001986101247\",\n    ];\n    let common_values = &[\n        (\"-1\", 15720),\n        (\"-2\", 7656),\n        (\"-3\", 7646),\n        (\"-7\", 7219),\n        (\"-4\", 7199),\n        (\"-8\", 7122),\n        (\"-15\", 6934),\n        (\"-31\", 6799),\n        (\"-16\", 6750),\n        (\"-63\", 6456),\n    ];\n    let sample_median = (\"-17592186044416\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.796251092974677e283),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_negative_integers_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_integers_fail_1() {\n    striped_random_negative_integers(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_integers_fail_2() {\n    striped_random_negative_integers(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_integers_fail_3() {\n    striped_random_negative_integers(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_integers_fail_4() {\n    striped_random_negative_integers(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_nonzero_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::striped_random_nonzero_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn striped_random_nonzero_integers_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_nonzero_integers(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_nonzero_integers() {\n    // mean bits = 65/64\n    let values = &[\n        \"1\", \"1\", \"1\", \"-1\", \"-1\", \"-1\", \"1\", \"-1\", \"-1\", \"1\", \"1\", \"1\", \"-1\", \"-1\", \"-1\", \"-1\",\n        \"1\", \"1\", \"-1\", \"-1\",\n    ];\n    let common_values = &[\n        (\"1\", 492842),\n        (\"-1\", 491818),\n        (\"2\", 3848),\n        (\"3\", 3791),\n        (\"-3\", 3753),\n        (\"-2\", 3709),\n        (\"7\", 50),\n        (\"4\", 49),\n        (\"-4\", 41),\n        (\"-7\", 36),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0015040000000000353),\n        standard_deviation: NiceFloat(1.0443710206123127),\n        skewness: NiceFloat(0.0008346150701385402),\n        excess_kurtosis: NiceFloat(-1.2794877665824687),\n    };\n    striped_random_nonzero_integers_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"4\", \"1\", \"4\", \"-8\", \"-1\", \"-1\", \"1\", \"-1\", \"-2\", \"7\", \"7\", \"6\", \"-1\", \"-1\", \"-3\", \"-14\",\n        \"1\", \"4\", \"-8\", \"-1\",\n    ];\n    let common_values = &[\n        (\"1\", 249934),\n        (\"-1\", 249480),\n        (\"3\", 62605),\n        (\"-3\", 62544),\n        (\"2\", 62495),\n        (\"-2\", 62282),\n        (\"4\", 23545),\n        (\"-7\", 23428),\n        (\"7\", 23343),\n        (\"-4\", 23304),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.9232179999999961),\n        standard_deviation: NiceFloat(942.1853934867996),\n        skewness: NiceFloat(-30.544317259845204),\n        excess_kurtosis: NiceFloat(179726.72807613286),\n    };\n    striped_random_nonzero_integers_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"4\",\n        \"268435456\",\n        \"84405977732342160290572740160760316144\",\n        \"-133169152\",\n        \"-131064\",\n        \"-2251834173421823\",\n        \"1577058304\",\n        \"-126100789566374399\",\n        \"-76\",\n        \"270335\",\n        \"33554431\",\n        \"262144\",\n        \"-4398046511104\",\n        \"-20352\",\n        \"-1023\",\n        \"-1\",\n        \"63\",\n        \"72057589742960640\",\n        \"-1\",\n        \"-8388607\",\n    ];\n    let common_values = &[\n        (\"1\", 15709),\n        (\"-1\", 15677),\n        (\"-3\", 7646),\n        (\"-2\", 7603),\n        (\"3\", 7564),\n        (\"2\", 7494),\n        (\"4\", 6925),\n        (\"7\", 6916),\n        (\"-7\", 6903),\n        (\"-4\", 6802),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.5217288846207e111),\n        standard_deviation: NiceFloat(2.5217283396166554e114),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_nonzero_integers_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"67108864\",\n        \"47890485651710580317658107747553101683567604294221824\",\n        \"512\",\n        \"-311675034947891977256960\",\n        \"-309485009821345068724780928\",\n        \"-1179647\",\n        \"1\",\n        \"-131071\",\n        \"-17179869184\",\n        \"1056767\",\n        \"273820942303\",\n        \"137438952504\",\n        \"-536870912\",\n        \"-36749372959343247360\",\n        \"-4722366482869645217791\",\n        \"-786432\",\n        \"1023\",\n        \"8388608\",\n        \"-274911460352\",\n        \"-24575\",\n    ];\n    let common_values = &[\n        (\"1\", 7878),\n        (\"-1\", 7830),\n        (\"-3\", 3940),\n        (\"-2\", 3893),\n        (\"2\", 3885),\n        (\"3\", 3806),\n        (\"4\", 3707),\n        (\"-7\", 3694),\n        (\"-4\", 3689),\n        (\"7\", 3608),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(f64::NAN),\n        standard_deviation: NiceFloat(f64::NAN),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_nonzero_integers_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_integers_fail_1() {\n    striped_random_nonzero_integers(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_integers_fail_2() {\n    striped_random_nonzero_integers(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_integers_fail_3() {\n    striped_random_nonzero_integers(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_integers_fail_4() {\n    striped_random_nonzero_integers(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/striped_random_positive_integers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::random::striped_random_positive_integers;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\n\nfn striped_random_positive_integers_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        striped_random_positive_integers(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_positive_integers() {\n    // mean bits = 65/64\n    let values = &[\"1\"; 20];\n    let common_values = &[\n        (\"1\", 984681),\n        (\"3\", 7637),\n        (\"2\", 7440),\n        (\"4\", 97),\n        (\"7\", 78),\n        (\"5\", 33),\n        (\"6\", 29),\n        (\"11\", 2),\n        (\"8\", 1),\n        (\"9\", 1),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.023796999999977),\n        standard_deviation: NiceFloat(0.20691241046333197),\n        skewness: NiceFloat(10.752762867801868),\n        excess_kurtosis: NiceFloat(162.40220891738076),\n    };\n    striped_random_positive_integers_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"1\", \"16\", \"1\", \"16\", \"4\", \"15\", \"2\", \"1\", \"1\", \"1\", \"1\", \"1\", \"2\", \"2\", \"1\", \"1\", \"3\",\n        \"2\", \"1\", \"1\",\n    ];\n    let common_values = &[\n        (\"1\", 500248),\n        (\"2\", 124818),\n        (\"3\", 124673),\n        (\"7\", 47032),\n        (\"4\", 46853),\n        (\"8\", 17749),\n        (\"15\", 17612),\n        (\"5\", 15660),\n        (\"6\", 15596),\n        (\"16\", 6518),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(15.773014000000762),\n        standard_deviation: NiceFloat(2128.8810534178506),\n        skewness: NiceFloat(884.8410850537254),\n        excess_kurtosis: NiceFloat(843254.2507640689),\n    };\n    striped_random_positive_integers_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"16\",\n        \"4\",\n        \"128\",\n        \"34391195648\",\n        \"75493376\",\n        \"9007199120523391\",\n        \"8\",\n        \"8796094070783\",\n        \"8\",\n        \"950737950171027935941967741439\",\n        \"1040391\",\n        \"33554432\",\n        \"84390026996392738938916902643112875376640\",\n        \"30\",\n        \"7\",\n        \"554153860399104\",\n        \"2199023255551\",\n        \"16\",\n        \"220784470296873664512\",\n        \"4611685966886694919\",\n    ];\n    let common_values = &[\n        (\"1\", 31094),\n        (\"3\", 15250),\n        (\"2\", 15195),\n        (\"7\", 13890),\n        (\"4\", 13880),\n        (\"8\", 12601),\n        (\"15\", 12519),\n        (\"31\", 11397),\n        (\"16\", 11237),\n        (\"63\", 10225),\n    ];\n    let sample_median = (\"4194272\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.1641486095650758e130),\n        standard_deviation: NiceFloat(1.1640776313097e133),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_integers_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"649037107316853596555600210165760\",\n        \"822486237184\",\n        \"196608\",\n        \"141976867225561692967630759002112\",\n        \"174223242635524708377374895198005052307456\",\n        \"664594824829454142366461086851399679\",\n        \"4503599627370496\",\n        \"127\",\n        \"2048\",\n        \"147574233996470517759\",\n        \"45660775794157599311165096735019350831520546815\",\n        \"1048320\",\n        \"1361212544433490269424560431578983940096\",\n        \"3968\",\n        \"536870911\",\n        \"34359738368\",\n        \"35184372088831\",\n        \"9297159013149614014464\",\n        \"768\",\n        \"72040001986101247\",\n    ];\n    let common_values = &[\n        (\"1\", 15720),\n        (\"2\", 7656),\n        (\"3\", 7646),\n        (\"7\", 7219),\n        (\"4\", 7199),\n        (\"8\", 7122),\n        (\"15\", 6934),\n        (\"31\", 6799),\n        (\"16\", 6750),\n        (\"63\", 6456),\n    ];\n    let sample_median = (\"17592186044416\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.796251092974677e283),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_integers_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_integers_fail_1() {\n    striped_random_positive_integers(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_integers_fail_2() {\n    striped_random_positive_integers(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_integers_fail_3() {\n    striped_random_positive_integers(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_integers_fail_4() {\n    striped_random_positive_integers(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/uniform_random_integer_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::uniform_random_integer_inclusive_range;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn uniform_random_integer_inclusive_range_helper(\n    a: &str,\n    b: &str,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        uniform_random_integer_inclusive_range(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            Integer::from_str(b).unwrap(),\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_uniform_random_integer_inclusive_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    uniform_random_integer_inclusive_range_helper(\n        \"0\",\n        \"0\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-3\", \"3\", \"1\", \"1\", \"3\", \"-3\", \"-2\", \"-4\", \"-2\", \"-1\", \"0\", \"-1\", \"2\", \"1\", \"2\", \"2\",\n        \"-1\", \"-3\", \"-1\", \"3\",\n    ];\n    let common_values = &[\n        (\"-2\", 125739),\n        (\"-1\", 125293),\n        (\"2\", 125220),\n        (\"3\", 125016),\n        (\"-4\", 124976),\n        (\"1\", 124665),\n        (\"-3\", 124627),\n        (\"0\", 124464),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5004029999999962),\n        standard_deviation: NiceFloat(2.291244004332587),\n        skewness: NiceFloat(0.0011305808123400524),\n        excess_kurtosis: NiceFloat(-1.2381429974564255),\n    };\n    uniform_random_integer_inclusive_range_helper(\n        \"-4\",\n        \"3\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1023\", \"1025\", \"1023\", \"1023\", \"1025\", \"1023\", \"1024\", \"1022\", \"1024\", \"1025\", \"1022\",\n        \"1025\", \"1024\", \"1023\", \"1024\", \"1024\", \"1025\", \"1023\", \"1025\", \"1025\",\n    ];\n    let common_values = &[(\"1024\", 250959), (\"1025\", 250309), (\"1022\", 249440), (\"1023\", 249292)];\n    let sample_median = (\"1024\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1023.5021369999873),\n        standard_deviation: NiceFloat(1.1178079811513417),\n        skewness: NiceFloat(-0.003486279405775989),\n        excess_kurtosis: NiceFloat(-1.3594690811608392),\n    };\n    uniform_random_integer_inclusive_range_helper(\n        \"1022\",\n        \"1025\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-1025\", \"-1023\", \"-1025\", \"-1025\", \"-1023\", \"-1025\", \"-1024\", \"-1026\", \"-1024\", \"-1023\",\n        \"-1026\", \"-1023\", \"-1024\", \"-1025\", \"-1024\", \"-1024\", \"-1023\", \"-1025\", \"-1023\", \"-1023\",\n    ];\n    let common_values =\n        &[(\"-1024\", 250959), (\"-1023\", 250309), (\"-1026\", 249440), (\"-1025\", 249292)];\n    let sample_median = (\"-1024\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1024.4978629999973),\n        standard_deviation: NiceFloat(1.1178079811512938),\n        skewness: NiceFloat(-0.0034862794057047334),\n        excess_kurtosis: NiceFloat(-1.3594690811609873),\n    };\n    uniform_random_integer_inclusive_range_helper(\n        \"-1026\",\n        \"-1023\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"7279\", \"1141\", \"3725\", \"8735\", \"8576\", \"4611\", \"-916\", \"5299\", \"2421\", \"2094\", \"8430\",\n        \"-253\", \"5785\", \"1183\", \"9525\", \"1201\", \"3280\", \"3065\", \"6206\", \"8542\",\n    ];\n    let common_values = &[\n        (\"3214\", 127),\n        (\"7954\", 126),\n        (\"2592\", 125),\n        (\"6885\", 125),\n        (\"7656\", 125),\n        (\"2344\", 124),\n        (\"6392\", 124),\n        (\"4426\", 123),\n        (\"-312\", 122),\n        (\"1519\", 122),\n    ];\n    let sample_median = (\"4509\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4503.707855999995),\n        standard_deviation: NiceFloat(3172.2131846202396),\n        skewness: NiceFloat(-0.0021819995553274013),\n        excess_kurtosis: NiceFloat(-1.196969134950911),\n    };\n    uniform_random_integer_inclusive_range_helper(\n        \"-1000\",\n        \"9999\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn uniform_random_integer_inclusive_range_fail() {\n    uniform_random_integer_inclusive_range(EXAMPLE_SEED, Integer::from(-9), Integer::from(-10));\n}\n"
  },
  {
    "path": "malachite-nz/tests/integer/random/uniform_random_integer_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::uniform_random_integer_range;\nuse malachite_nz::test_util::integer::random::random_integers_helper_helper;\nuse std::str::FromStr;\n\nfn uniform_random_integer_range_helper(\n    a: &str,\n    b: &str,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_integers_helper_helper(\n        uniform_random_integer_range(\n            EXAMPLE_SEED,\n            Integer::from_str(a).unwrap(),\n            Integer::from_str(b).unwrap(),\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_uniform_random_integer_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    uniform_random_integer_range_helper(\n        \"0\",\n        \"1\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-3\", \"3\", \"1\", \"1\", \"3\", \"-3\", \"-2\", \"-4\", \"-2\", \"-1\", \"0\", \"-1\", \"2\", \"1\", \"2\", \"2\",\n        \"-1\", \"-3\", \"-1\", \"3\",\n    ];\n    let common_values = &[\n        (\"-2\", 125739),\n        (\"-1\", 125293),\n        (\"2\", 125220),\n        (\"3\", 125016),\n        (\"-4\", 124976),\n        (\"1\", 124665),\n        (\"-3\", 124627),\n        (\"0\", 124464),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5004029999999962),\n        standard_deviation: NiceFloat(2.291244004332587),\n        skewness: NiceFloat(0.0011305808123400524),\n        excess_kurtosis: NiceFloat(-1.2381429974564255),\n    };\n    uniform_random_integer_range_helper(\n        \"-4\",\n        \"4\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1023\", \"1025\", \"1023\", \"1023\", \"1025\", \"1023\", \"1024\", \"1022\", \"1024\", \"1025\", \"1022\",\n        \"1025\", \"1024\", \"1023\", \"1024\", \"1024\", \"1025\", \"1023\", \"1025\", \"1025\",\n    ];\n    let common_values = &[(\"1024\", 250959), (\"1025\", 250309), (\"1022\", 249440), (\"1023\", 249292)];\n    let sample_median = (\"1024\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1023.5021369999873),\n        standard_deviation: NiceFloat(1.1178079811513417),\n        skewness: NiceFloat(-0.003486279405775989),\n        excess_kurtosis: NiceFloat(-1.3594690811608392),\n    };\n    uniform_random_integer_range_helper(\n        \"1022\",\n        \"1026\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"-1025\", \"-1023\", \"-1025\", \"-1025\", \"-1023\", \"-1025\", \"-1024\", \"-1026\", \"-1024\", \"-1023\",\n        \"-1026\", \"-1023\", \"-1024\", \"-1025\", \"-1024\", \"-1024\", \"-1023\", \"-1025\", \"-1023\", \"-1023\",\n    ];\n    let common_values =\n        &[(\"-1024\", 250959), (\"-1023\", 250309), (\"-1026\", 249440), (\"-1025\", 249292)];\n    let sample_median = (\"-1024\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1024.4978629999973),\n        standard_deviation: NiceFloat(1.1178079811512938),\n        skewness: NiceFloat(-0.0034862794057047334),\n        excess_kurtosis: NiceFloat(-1.3594690811609873),\n    };\n    uniform_random_integer_range_helper(\n        \"-1026\",\n        \"-1022\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"7279\", \"1141\", \"3725\", \"8735\", \"8576\", \"4611\", \"-916\", \"5299\", \"2421\", \"2094\", \"8430\",\n        \"-253\", \"5785\", \"1183\", \"9525\", \"1201\", \"3280\", \"3065\", \"6206\", \"8542\",\n    ];\n    let common_values = &[\n        (\"3214\", 127),\n        (\"7954\", 126),\n        (\"2592\", 125),\n        (\"6885\", 125),\n        (\"7656\", 125),\n        (\"2344\", 124),\n        (\"6392\", 124),\n        (\"4426\", 123),\n        (\"-312\", 122),\n        (\"1519\", 122),\n    ];\n    let sample_median = (\"4509\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4503.707855999995),\n        standard_deviation: NiceFloat(3172.2131846202396),\n        skewness: NiceFloat(-0.0021819995553274013),\n        excess_kurtosis: NiceFloat(-1.196969134950911),\n    };\n    uniform_random_integer_range_helper(\n        \"-1000\",\n        \"10000\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn uniform_random_integer_range_fail_1() {\n    uniform_random_integer_range(EXAMPLE_SEED, Integer::from(-9), Integer::from(-10));\n}\n\n#[test]\n#[should_panic]\nfn uniform_random_integer_range_fail_2() {\n    uniform_random_integer_range(EXAMPLE_SEED, Integer::from(-10), Integer::from(-10));\n}\n"
  },
  {
    "path": "malachite-nz/tests/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::bool_assert_comparison,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::excessive_precision,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::float_cmp,\n    clippy::type_complexity,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::option_if_let_else,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::trivially_copy_pass_by_ref\n)]\n\nextern crate itertools;\n#[macro_use]\nextern crate malachite_base;\nextern crate malachite_nz;\nextern crate num;\nextern crate rug;\n\npub mod integer {\n    pub mod arithmetic {\n        pub mod abs;\n        pub mod abs_diff;\n        pub mod add;\n        pub mod add_mul;\n        pub mod binomial_coefficient;\n        pub mod div;\n        pub mod div_exact;\n        pub mod div_mod;\n        pub mod div_round;\n        pub mod divisible_by;\n        pub mod divisible_by_power_of_2;\n        pub mod eq_mod;\n        pub mod eq_mod_power_of_2;\n        pub mod extended_gcd;\n        pub mod kronecker_symbol;\n        pub mod mod_op;\n        pub mod mod_power_of_2;\n        pub mod mul;\n        pub mod neg;\n        pub mod parity;\n        pub mod pow;\n        pub mod power_of_2;\n        pub mod root;\n        pub mod round_to_multiple;\n        pub mod round_to_multiple_of_power_of_2;\n        pub mod shl;\n        pub mod shl_round;\n        pub mod shr;\n        pub mod shr_round;\n        pub mod sign;\n        pub mod sqrt;\n        pub mod square;\n        pub mod sub;\n        pub mod sub_mul;\n    }\n    pub mod basic {\n        pub mod constants;\n        pub mod default;\n        pub mod from_sign_and_abs;\n        pub mod named;\n        pub mod size;\n    }\n    pub mod comparison {\n        pub mod cmp;\n        pub mod cmp_abs;\n        pub mod eq;\n        pub mod eq_abs;\n        pub mod eq_abs_natural;\n        pub mod eq_abs_primitive_float;\n        pub mod eq_abs_primitive_int;\n        pub mod hash;\n        pub mod partial_cmp_abs_natural;\n        pub mod partial_cmp_abs_primitive_float;\n        pub mod partial_cmp_abs_primitive_int;\n        pub mod partial_cmp_natural;\n        pub mod partial_cmp_primitive_float;\n        pub mod partial_cmp_primitive_int;\n        pub mod partial_eq_natural;\n        pub mod partial_eq_primitive_float;\n        pub mod partial_eq_primitive_int;\n    }\n    pub mod conversion {\n        pub mod clone;\n        pub mod from_bool;\n        pub mod from_natural;\n        pub mod from_primitive_float;\n        pub mod from_primitive_int;\n        pub mod from_twos_complement_limbs;\n        pub mod is_integer;\n        pub mod natural_from_integer;\n        pub mod primitive_float_from_integer;\n        pub mod primitive_int_from_integer;\n        #[cfg(feature = \"serde\")]\n        pub mod serde;\n        pub mod string {\n            pub mod from_sci_string;\n            pub mod from_string;\n            pub mod to_sci;\n            pub mod to_string;\n        }\n        pub mod to_twos_complement_limbs;\n    }\n    pub mod exhaustive {\n        pub mod exhaustive_integer_inclusive_range;\n        pub mod exhaustive_integer_range;\n        pub mod exhaustive_integer_range_to_infinity;\n        pub mod exhaustive_integer_range_to_negative_infinity;\n        pub mod exhaustive_integers;\n        pub mod exhaustive_natural_integers;\n        pub mod exhaustive_negative_integers;\n        pub mod exhaustive_nonzero_integers;\n        pub mod exhaustive_positive_integers;\n        pub mod integer_decreasing_range_to_negative_infinity;\n        pub mod integer_increasing_inclusive_range;\n        pub mod integer_increasing_range;\n        pub mod integer_increasing_range_to_infinity;\n    }\n    pub mod logic {\n        pub mod and;\n        pub mod assign_bit;\n        pub mod assign_bits;\n        pub mod bits;\n        pub mod checked_count_ones;\n        pub mod checked_count_zeros;\n        pub mod checked_hamming_distance;\n        pub mod clear_bit;\n        pub mod flip_bit;\n        pub mod from_bits;\n        pub mod get_bit;\n        pub mod get_bits;\n        pub mod index_of_next_false_bit;\n        pub mod index_of_next_true_bit;\n        pub mod low_mask;\n        pub mod not;\n        pub mod or;\n        pub mod set_bit;\n        pub mod significant_bits;\n        pub mod to_bits;\n        pub mod trailing_zeros;\n        pub mod xor;\n    }\n    pub mod random {\n        pub mod get_random_integer_from_range_to_infinity;\n        pub mod get_random_integer_from_range_to_negative_infinity;\n        pub mod get_striped_random_integer_from_inclusive_range;\n        pub mod get_striped_random_integer_from_range;\n        pub mod get_striped_random_integer_from_range_to_infinity;\n        pub mod get_striped_random_integer_from_range_to_negative_infinity;\n        pub mod get_uniform_random_integer_from_inclusive_range;\n        pub mod get_uniform_random_integer_from_range;\n        pub mod random_integer_inclusive_range;\n        pub mod random_integer_range;\n        pub mod random_integer_range_to_infinity;\n        pub mod random_integer_range_to_negative_infinity;\n        pub mod random_integers;\n        pub mod random_natural_integers;\n        pub mod random_negative_integers;\n        pub mod random_nonzero_integers;\n        pub mod random_positive_integers;\n        pub mod striped_random_integer_inclusive_range;\n        pub mod striped_random_integer_range;\n        pub mod striped_random_integer_range_to_infinity;\n        pub mod striped_random_integer_range_to_negative_infinity;\n        pub mod striped_random_integers;\n        pub mod striped_random_natural_integers;\n        pub mod striped_random_negative_integers;\n        pub mod striped_random_nonzero_integers;\n        pub mod striped_random_positive_integers;\n        pub mod uniform_random_integer_inclusive_range;\n        pub mod uniform_random_integer_range;\n    }\n}\npub mod natural {\n    pub mod arithmetic {\n        pub mod abs_diff;\n        pub mod add;\n        pub mod add_mul;\n        pub mod binomial_coefficient;\n        pub mod checked_sub;\n        pub mod checked_sub_mul;\n        pub mod coprime_with;\n        pub mod div;\n        pub mod div_exact;\n        pub mod div_mod;\n        pub mod div_round;\n        pub mod divisible_by;\n        pub mod divisible_by_power_of_2;\n        pub mod eq_mod;\n        pub mod eq_mod_power_of_2;\n        pub mod extended_gcd;\n        pub mod factorial;\n        pub mod gcd;\n        pub mod is_power_of_2;\n        pub mod kronecker_symbol;\n        pub mod lcm;\n        pub mod log_base;\n        pub mod log_base_2;\n        pub mod log_base_power_of_2;\n        pub mod mod_add;\n        pub mod mod_inverse;\n        pub mod mod_is_reduced;\n        pub mod mod_mul;\n        pub mod mod_neg;\n        pub mod mod_op;\n        pub mod mod_pow;\n        // end\n        pub mod mod_power_of_2;\n        pub mod mod_power_of_2_add;\n        pub mod mod_power_of_2_inverse;\n        pub mod mod_power_of_2_is_reduced;\n        pub mod mod_power_of_2_mul;\n        pub mod mod_power_of_2_neg;\n        pub mod mod_power_of_2_pow;\n        pub mod mod_power_of_2_shl;\n        pub mod mod_power_of_2_shr;\n        pub mod mod_power_of_2_square;\n        pub mod mod_power_of_2_sub;\n        pub mod mod_shl;\n        pub mod mod_shr;\n        pub mod mod_square;\n        pub mod mod_sub;\n        pub mod mul;\n        pub mod neg;\n        pub mod next_power_of_2;\n        pub mod parity;\n        pub mod pow;\n        pub mod power_of_2;\n        pub mod primorial;\n        pub mod root;\n        pub mod round_to_multiple;\n        pub mod round_to_multiple_of_power_of_2;\n        pub mod saturating_sub;\n        pub mod saturating_sub_mul;\n        pub mod shl;\n        pub mod shl_round;\n        pub mod shr;\n        pub mod shr_round;\n        pub mod sign;\n        pub mod sqrt;\n        pub mod square;\n        pub mod sub;\n        pub mod sub_mul;\n    }\n    pub mod basic {\n        pub mod constants;\n        pub mod default;\n        pub mod named;\n        pub mod size;\n    }\n    pub mod comparison {\n        pub mod cmp;\n        pub mod eq;\n        pub mod eq_abs_primitive_float;\n        pub mod eq_abs_primitive_int;\n        pub mod hash;\n        pub mod partial_cmp_abs_primitive_float;\n        pub mod partial_cmp_abs_primitive_int;\n        pub mod partial_cmp_primitive_float;\n        pub mod partial_cmp_primitive_int;\n        pub mod partial_eq_primitive_float;\n        pub mod partial_eq_primitive_int;\n    }\n    pub mod conversion {\n        pub mod clone;\n        pub mod digits {\n            pub mod from_digits;\n            pub mod from_power_of_2_digits;\n            pub mod power_of_2_digits;\n            pub mod to_digits;\n            pub mod to_power_of_2_digits;\n        }\n        pub mod from_bool;\n        pub mod from_limbs;\n        pub mod from_primitive_float;\n        pub mod from_primitive_int;\n        pub mod is_integer;\n        pub mod mantissa_and_exponent {\n            pub mod integer_mantissa_and_exponent;\n            pub mod sci_mantissa_and_exponent;\n        }\n        pub mod primitive_float_from_natural;\n        pub mod primitive_int_from_natural;\n        #[cfg(feature = \"serde\")]\n        pub mod serde;\n        pub mod string {\n            pub mod from_sci_string;\n            pub mod from_string;\n            pub mod to_sci;\n            pub mod to_string;\n        }\n        pub mod to_limbs;\n    }\n    pub mod exhaustive {\n        pub mod exhaustive_natural_inclusive_range;\n        pub mod exhaustive_natural_range;\n        pub mod exhaustive_natural_range_to_infinity;\n        pub mod exhaustive_naturals;\n        pub mod exhaustive_positive_naturals;\n    }\n    pub mod factorization {\n        pub mod is_power;\n        pub mod is_square;\n        pub mod primes;\n    }\n    pub mod logic {\n        pub mod and;\n        pub mod assign_bit;\n        pub mod assign_bits;\n        pub mod bits;\n        pub mod clear_bit;\n        pub mod count_ones;\n        pub mod flip_bit;\n        pub mod from_bits;\n        pub mod get_bit;\n        pub mod get_bits;\n        pub mod hamming_distance;\n        pub mod index_of_next_false_bit;\n        pub mod index_of_next_true_bit;\n        pub mod limb_count;\n        pub mod low_mask;\n        pub mod not;\n        pub mod or;\n        pub mod set_bit;\n        pub mod significant_bits;\n        pub mod to_bits;\n        pub mod trailing_zeros;\n        pub mod xor;\n    }\n    pub mod random {\n        pub mod get_random_natural_less_than;\n        pub mod get_random_natural_with_bits;\n        pub mod get_random_natural_with_up_to_bits;\n        pub mod get_striped_random_natural_from_inclusive_range;\n        pub mod get_striped_random_natural_from_range;\n        pub mod get_striped_random_natural_with_bits;\n        pub mod get_striped_random_natural_with_up_to_bits;\n        pub mod random_natural_inclusive_range;\n        pub mod random_natural_range;\n        pub mod random_natural_range_to_infinity;\n        pub mod random_naturals;\n        pub mod random_naturals_less_than;\n        pub mod random_positive_naturals;\n        pub mod striped_random_natural_inclusive_range;\n        pub mod striped_random_natural_range;\n        pub mod striped_random_natural_range_to_infinity;\n        pub mod striped_random_naturals;\n        pub mod striped_random_positive_naturals;\n        pub mod uniform_random_natural_inclusive_range;\n        pub mod uniform_random_natural_range;\n    }\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsDiff, AbsDiffAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_abs_diff_natural() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.abs_diff_assign(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.abs_diff_assign(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().abs_diff(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().abs_diff(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).abs_diff(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).abs_diff(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"456\", \"123\", \"333\");\n    test(\"1000000000000\", \"123\", \"999999999877\");\n    test(\"123\", \"1000000000000\", \"999999999877\");\n    test(\"12345678987654321\", \"314159265358979\", \"12031519722295342\");\n    test(\"4294967296\", \"1\", \"4294967295\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"4294967296\", \"4294967295\", \"1\");\n    test(\"4294967296\", \"4294967296\", \"0\");\n    test(\"4294967295\", \"4294967296\", \"1\");\n    test(\"18446744073709551616\", \"1\", \"18446744073709551615\");\n    test(\"18446744073709551615\", \"18446744073709551615\", \"0\");\n    test(\"18446744073709551616\", \"18446744073709551615\", \"1\");\n    test(\"18446744073709551615\", \"18446744073709551616\", \"1\");\n    test(\"70734740290631708\", \"282942734368\", \"70734457347897340\");\n    test(\"282942734368\", \"70734740290631708\", \"70734457347897340\");\n}\n\n#[test]\nfn abs_diff_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.abs_diff_assign(&y);\n        assert!(mut_x.is_valid());\n        let diff = mut_x;\n\n        let mut mut_x = x.clone();\n        mut_x.abs_diff_assign(y.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n\n        let diff_alt = x.clone().abs_diff(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = x.clone().abs_diff(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).abs_diff(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).abs_diff(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        assert_eq!((Integer::from(&x) - Integer::from(&y)).abs(), diff);\n        assert_eq!((&y).abs_diff(&x), diff);\n        assert_eq!(diff == 0, x == y);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).abs_diff(Natural::ZERO), x);\n        assert_eq!((&x).abs_diff(&x), 0);\n        assert_eq!(Natural::ZERO.abs_diff(&x), x);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert!((&x).abs_diff(&z) <= x.abs_diff(&y) + y.abs_diff(z));\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(x.abs_diff(y), Natural::from(x).abs_diff(Natural::from(y)));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    large_type_gen_var_9, unsigned_pair_gen_var_27, unsigned_vec_pair_gen,\n    unsigned_vec_pair_gen_var_1, unsigned_vec_pair_gen_var_6, unsigned_vec_triple_gen_var_31,\n    unsigned_vec_triple_gen_var_32, unsigned_vec_triple_gen_var_40, unsigned_vec_unsigned_pair_gen,\n    unsigned_vec_unsigned_pair_gen_var_15, unsigned_vec_unsigned_vec_bool_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11,\n};\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::add::{\n    limbs_add, limbs_add_greater, limbs_add_greater_to_out, limbs_add_limb, limbs_add_limb_to_out,\n    limbs_add_same_length_to_out, limbs_add_same_length_with_carry_in_in_place_left,\n    limbs_add_same_length_with_carry_in_to_out, limbs_add_to_out, limbs_add_to_out_aliased,\n    limbs_slice_add_greater_in_place_left, limbs_slice_add_in_place_either,\n    limbs_slice_add_limb_in_place, limbs_slice_add_same_length_in_place_left,\n    limbs_vec_add_in_place_either, limbs_vec_add_in_place_left, limbs_vec_add_limb_in_place,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_pair_gen, natural_triple_gen, natural_vec_gen,\n};\nuse malachite_nz::test_util::natural::arithmetic::add::natural_sum_alt;\nuse num::BigUint;\nuse rug;\nuse std::cmp::max;\nuse std::iter::{Sum, once};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_limb() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_add_limb(xs, y), out);\n    };\n    test(&[], 0, &[]);\n    test(&[], 5, &[5]);\n    test(&[6, 7], 2, &[8, 7]);\n    test(&[100, 101, 102], 10, &[110, 101, 102]);\n    test(&[123, 456], 789, &[912, 456]);\n    test(&[u32::MAX, 5], 2, &[1, 6]);\n    test(&[u32::MAX], 2, &[1, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_limb_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, carry: bool, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_add_limb_to_out(&mut out, xs, y), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[], 0, false, &[10, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[], 5, true, &[10, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, false, &[8, 7, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        false,\n        &[110, 101, 102, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        789,\n        false,\n        &[912, 456, 10, 10],\n    );\n    test(&[10, 10, 10, 10], &[u32::MAX, 5], 2, false, &[1, 6, 10, 10]);\n    test(&[10, 10, 10, 10], &[u32::MAX], 2, true, &[1, 10, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_limb_to_out_fail() {\n    limbs_add_limb_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_add_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, carry: bool, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        assert_eq!(limbs_slice_add_limb_in_place(&mut xs, y), carry);\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, false, &[]);\n    test(&[], 5, true, &[]);\n    test(&[6, 7], 2, false, &[8, 7]);\n    test(&[100, 101, 102], 10, false, &[110, 101, 102]);\n    test(&[123, 456], 789, false, &[912, 456]);\n    test(&[u32::MAX, 5], 2, false, &[1, 6]);\n    test(&[u32::MAX], 2, true, &[1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_add_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        limbs_vec_add_limb_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[6, 7], 2, &[8, 7]);\n    test(&[100, 101, 102], 10, &[110, 101, 102]);\n    test(&[123, 456], 789, &[912, 456]);\n    test(&[u32::MAX, 5], 2, &[1, 6]);\n    test(&[u32::MAX], 2, &[1, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_add_limb_in_place_fail() {\n    limbs_vec_add_limb_in_place(&mut vec![], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_greater() {\n    let test = |xs, ys, out| {\n        assert_eq!(limbs_add_greater(xs, ys), out);\n    };\n    test(&[], &[], vec![]);\n    test(&[2], &[], vec![2]);\n    test(&[2], &[3], vec![5]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![2, 3, 4]);\n    test(&[1, 2, 3], &[6, 7], vec![7, 9, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![202, 202, 202]);\n    test(&[u32::MAX, 3], &[1], vec![0, 4]);\n    test(&[u32::MAX], &[1], vec![0, 1]);\n    test(&[1], &[u32::MAX], vec![0, 1]);\n    test(&[u32::MAX], &[u32::MAX], vec![u32::MAX - 1, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn test_limbs_add_greater_fail() {\n    limbs_add_greater(&[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_and_limbs_vec_add_in_place_left() {\n    let test = |xs_before, ys, out| {\n        assert_eq!(limbs_add(xs_before, ys), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_vec_add_in_place_left(&mut xs, ys);\n        assert_eq!(xs, out);\n    };\n    test(&[], &[], vec![]);\n    test(&[2], &[], vec![2]);\n    test(&[], &[2], vec![2]);\n    test(&[2], &[3], vec![5]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![2, 3, 4]);\n    test(&[6, 7], &[1, 2, 3], vec![7, 9, 3]);\n    test(&[1, 2, 3], &[6, 7], vec![7, 9, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![202, 202, 202]);\n    test(&[u32::MAX, 3], &[1], vec![0, 4]);\n    test(&[1], &[u32::MAX, 3], vec![0, 4]);\n    test(&[u32::MAX], &[1], vec![0, 1]);\n    test(&[1], &[u32::MAX], vec![0, 1]);\n    test(&[u32::MAX], &[u32::MAX], vec![u32::MAX - 1, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_greater_to_out() {\n    let test = |xs, ys, out_before: &[Limb], carry, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_add_greater_to_out(&mut out, xs, ys), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], false, vec![0, 0]);\n    test(&[2], &[], &[0, 0], false, vec![2, 0]);\n    test(&[2], &[3], &[0, 0], false, vec![5, 0]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        &[5, 5, 5, 5],\n        false,\n        vec![2, 3, 4, 5],\n    );\n    test(&[1, 2, 3], &[6, 7], &[0, 0, 0], false, vec![7, 9, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        false,\n        vec![202, 202, 202, 10],\n    );\n    test(\n        &[u32::MAX, 3],\n        &[1],\n        &[10, 10, 10, 10],\n        false,\n        vec![0, 4, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[1],\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[1],\n        &[u32::MAX],\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[u32::MAX],\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX - 1, 10, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_greater_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_add_greater_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_greater_to_out_fail_2() {\n    let mut out = vec![10];\n    limbs_add_greater_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_same_length_to_out() {\n    let test = |xs, ys, out_before: &[Limb], carry, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_add_same_length_to_out(&mut out, xs, ys), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], false, vec![0, 0]);\n    test(&[2], &[3], &[0, 0], false, vec![5, 0]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        &[5, 5, 5, 5],\n        false,\n        vec![2, 3, 4, 5],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        false,\n        vec![202, 202, 202, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[1],\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[1],\n        &[u32::MAX],\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[u32::MAX],\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX - 1, 10, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_same_length_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_add_same_length_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_same_length_to_out_fail_2() {\n    let mut out = vec![10];\n    limbs_add_same_length_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_to_out() {\n    let test = |xs, ys, out_before: &[Limb], carry, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_add_to_out(&mut out, xs, ys), carry);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], false, vec![0, 0]);\n    test(&[2], &[], &[0, 0], false, vec![2, 0]);\n    test(&[], &[2], &[0, 0], false, vec![2, 0]);\n    test(&[2], &[3], &[0, 0], false, vec![5, 0]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        &[5, 5, 5, 5],\n        false,\n        vec![2, 3, 4, 5],\n    );\n    test(&[6, 7], &[1, 2, 3], &[0, 0, 0], false, vec![7, 9, 3]);\n    test(&[1, 2, 3], &[6, 7], &[0, 0, 0], false, vec![7, 9, 3]);\n    test(\n        &[6, 7],\n        &[1, 2, 3],\n        &[10, 10, 10, 10],\n        false,\n        vec![7, 9, 3, 10],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        false,\n        vec![202, 202, 202, 10],\n    );\n    test(\n        &[u32::MAX, 3],\n        &[1],\n        &[10, 10, 10, 10],\n        false,\n        vec![0, 4, 10, 10],\n    );\n    test(\n        &[1],\n        &[u32::MAX, 3],\n        &[10, 10, 10, 10],\n        false,\n        vec![0, 4, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[1],\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[1],\n        &[u32::MAX],\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[u32::MAX],\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX - 1, 10, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_to_out_fail() {\n    let mut out = vec![10, 10];\n    limbs_add_to_out(&mut out, &[6, 7, 8], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_to_out_aliased() {\n    let test = |xs_before: &[Limb], in_size, ys: &[Limb], carry, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_add_to_out_aliased(&mut xs, in_size, ys), carry);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], 0, &[], false, vec![]);\n    test(&[1, 2, 3], 0, &[4, 5], false, vec![4, 5, 3]);\n    test(&[1, 2, 3], 1, &[4, 5], false, vec![5, 5, 3]);\n    test(&[1, 2, 3], 2, &[4, 5], false, vec![5, 7, 3]);\n    test(&[1, 1, 3], 1, &[u32::MAX, 5], false, vec![0, 6, 3]);\n    test(&[1, 1, 3], 1, &[u32::MAX], true, vec![0, 1, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_to_out_aliased_fail_1() {\n    let mut out = vec![6, 7];\n    limbs_add_to_out_aliased(&mut out, 1, &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_to_out_aliased_fail_2() {\n    let mut out = vec![6, 7, 8, 9];\n    limbs_add_to_out_aliased(&mut out, 4, &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_add_same_length_in_place_left() {\n    let test = |xs_before: &[Limb], ys, carry, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_slice_add_same_length_in_place_left(&mut xs, ys),\n            carry\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], false, vec![]);\n    test(&[2], &[3], false, vec![5]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![2, 3, 4]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![202, 202, 202],\n    );\n    test(&[u32::MAX], &[1], true, vec![0]);\n    test(&[1], &[u32::MAX], true, vec![0]);\n    test(&[u32::MAX], &[u32::MAX], true, vec![u32::MAX - 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_add_same_length_in_place_left_fail() {\n    let mut out = vec![6, 7];\n    limbs_slice_add_same_length_in_place_left::<Limb>(&mut out, &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_add_greater_in_place_left() {\n    let test = |xs_before: &[Limb], ys, carry, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_slice_add_greater_in_place_left(&mut xs, ys), carry);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], false, vec![]);\n    test(&[2], &[], false, vec![2]);\n    test(&[2], &[3], false, vec![5]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![2, 3, 4]);\n    test(&[1, 2, 3], &[6, 7], false, vec![7, 9, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![202, 202, 202],\n    );\n    test(&[u32::MAX, 3], &[1], false, vec![0, 4]);\n    test(&[u32::MAX], &[1], true, vec![0]);\n    test(&[1], &[u32::MAX], true, vec![0]);\n    test(&[u32::MAX], &[u32::MAX], true, vec![u32::MAX - 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_add_greater_in_place_left_fail() {\n    let mut out = vec![6, 7];\n    limbs_slice_add_greater_in_place_left(&mut out, &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_add_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], right, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_slice_add_in_place_either(&mut xs, &mut ys), right);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], (false, false), vec![], vec![]);\n    test(&[2], &[], (false, false), vec![2], vec![]);\n    test(&[], &[2], (true, false), vec![], vec![2]);\n    test(&[2], &[3], (false, false), vec![5], vec![3]);\n    test(&[6, 7], &[1, 2], (false, false), vec![7, 9], vec![1, 2]);\n    test(\n        &[6, 7],\n        &[1, 2, 3],\n        (true, false),\n        vec![6, 7],\n        vec![7, 9, 3],\n    );\n    test(\n        &[1, 2, 3],\n        &[6, 7],\n        (false, false),\n        vec![7, 9, 3],\n        vec![6, 7],\n    );\n    test(&[], &[1, 2, 3], (true, false), vec![], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[], (false, false), vec![1, 2, 3], vec![]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        (false, false),\n        vec![2, 3, 4],\n        vec![1, 2, 3],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        (false, false),\n        vec![202, 202, 202],\n        vec![102, 101, 100],\n    );\n    test(&[u32::MAX, 3], &[1], (false, false), vec![0, 4], vec![1]);\n    test(&[1], &[u32::MAX, 3], (true, false), vec![1], vec![0, 4]);\n    test(&[u32::MAX], &[1], (false, true), vec![0], vec![1]);\n    test(&[1], &[u32::MAX], (false, true), vec![0], vec![u32::MAX]);\n    test(\n        &[u32::MAX],\n        &[u32::MAX],\n        (false, true),\n        vec![u32::MAX - 1],\n        vec![u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_add_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], right, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_vec_add_in_place_either(&mut xs, &mut ys), right);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], false, vec![], vec![]);\n    test(&[2], &[], false, vec![2], vec![]);\n    test(&[], &[2], true, vec![], vec![2]);\n    test(&[2], &[3], false, vec![5], vec![3]);\n    test(&[6, 7], &[1, 2], false, vec![7, 9], vec![1, 2]);\n    test(&[6, 7], &[1, 2, 3], true, vec![6, 7], vec![7, 9, 3]);\n    test(&[1, 2, 3], &[6, 7], false, vec![7, 9, 3], vec![6, 7]);\n    test(&[], &[1, 2, 3], true, vec![], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[], false, vec![1, 2, 3], vec![]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![2, 3, 4], vec![1, 2, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![202, 202, 202],\n        vec![102, 101, 100],\n    );\n    test(&[u32::MAX, 3], &[1], false, vec![0, 4], vec![1]);\n    test(&[1], &[u32::MAX, 3], true, vec![1], vec![0, 4]);\n    test(&[u32::MAX], &[1], false, vec![0, 1], vec![1]);\n    test(&[1], &[u32::MAX], false, vec![0, 1], vec![u32::MAX]);\n    test(\n        &[u32::MAX],\n        &[u32::MAX],\n        false,\n        vec![u32::MAX - 1, 1],\n        vec![u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_same_length_with_carry_in_to_out() {\n    let test = |xs, ys, carry_in, out_before: &[Limb], carry, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(\n            limbs_add_same_length_with_carry_in_to_out(&mut out, xs, ys, carry_in),\n            carry\n        );\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], false, &[0, 0], false, vec![0, 0]);\n    test(&[], &[], true, &[0, 0], true, vec![0, 0]);\n    test(&[2], &[3], false, &[0, 0], false, vec![5, 0]);\n    test(&[2], &[3], true, &[0, 0], false, vec![6, 0]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        false,\n        &[5, 5, 5, 5],\n        false,\n        vec![2, 3, 4, 5],\n    );\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        true,\n        &[5, 5, 5, 5],\n        false,\n        vec![3, 3, 4, 5],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        &[10, 10, 10, 10],\n        false,\n        vec![202, 202, 202, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[1],\n        false,\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[1],\n        true,\n        &[10, 10, 10, 10],\n        true,\n        vec![1, 10, 10, 10],\n    );\n    test(\n        &[u32::MAX - 1],\n        &[1],\n        true,\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[1],\n        &[u32::MAX],\n        false,\n        &[10, 10, 10, 10],\n        true,\n        vec![0, 10, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[u32::MAX],\n        false,\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX - 1, 10, 10, 10],\n    );\n    test(\n        &[u32::MAX],\n        &[u32::MAX],\n        true,\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX, 10, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_same_length_with_carry_in_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_add_same_length_with_carry_in_to_out(&mut out, &[6, 7], &[1, 2, 3], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_same_length_with_carry_in_to_out_fail_2() {\n    let mut out = vec![10];\n    limbs_add_same_length_with_carry_in_to_out(&mut out, &[6, 7], &[1, 2], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_same_length_with_carry_in_in_place_left() {\n    let test = |xs_before: &[Limb], ys, carry_in, carry, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_add_same_length_with_carry_in_in_place_left(&mut xs, ys, carry_in),\n            carry\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], false, false, vec![]);\n    test(&[], &[], true, true, vec![]);\n    test(&[2], &[3], false, false, vec![5]);\n    test(&[2], &[3], true, false, vec![6]);\n    test(&[1, 1, 1], &[1, 2, 3], false, false, vec![2, 3, 4]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        false,\n        vec![202, 202, 202],\n    );\n    test(&[u32::MAX], &[1], false, true, vec![0]);\n    test(&[u32::MAX], &[1], true, true, vec![1]);\n    test(&[u32::MAX - 1], &[1], true, true, vec![0]);\n    test(&[1], &[u32::MAX], false, true, vec![0]);\n    test(&[u32::MAX], &[u32::MAX], false, true, vec![u32::MAX - 1]);\n    test(&[u32::MAX], &[u32::MAX], true, true, vec![u32::MAX]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_same_length_with_carry_in_in_place_left_fail() {\n    let mut out = vec![6, 7];\n    limbs_add_same_length_with_carry_in_in_place_left(&mut out, &[1, 2, 3], false);\n}\n\n#[test]\nfn test_add() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n += v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n += &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() + v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u + v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() + &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u + &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigUint::from_str(s).unwrap() + BigUint::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() + rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"456\", \"579\");\n    test(\"1000000000000\", \"123\", \"1000000000123\");\n    test(\"123\", \"1000000000000\", \"1000000000123\");\n    test(\"12345678987654321\", \"314159265358979\", \"12659838253013300\");\n    test(\n        \"1000000000000\",\n        \"1000000000000000000000000\",\n        \"1000000000001000000000000\",\n    );\n    test(\n        \"157489031134308824401228232926\",\n        \"2350262829889206551114184866\",\n        \"159839293964198030952342417792\",\n    );\n}\n\n#[test]\nfn test_sum() {\n    let test = |xs, out| {\n        let xs = vec_from_str(xs).unwrap();\n        let sum = Natural::sum(xs.iter().cloned());\n        assert!(sum.is_valid());\n        assert_eq!(sum.to_string(), out);\n\n        let sum_alt = Natural::sum(xs.iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n\n        let sum_alt = natural_sum_alt(xs.into_iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n    };\n    test(\"[]\", \"0\");\n    test(\"[10]\", \"10\");\n    test(\"[6, 2]\", \"8\");\n    test(\"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\", \"55\");\n    test(\"[123456, 789012, 345678, 9012345]\", \"10270491\");\n}\n\n#[test]\nfn limbs_add_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_add_limb(&xs, y)),\n            Natural::from_owned_limbs_asc(xs) + Natural::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_add_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            let carry = limbs_add_limb_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            let n = Natural::from_owned_limbs_asc(xs) + Natural::from(y);\n            let mut xs = n.into_limbs_asc();\n            assert_eq!(carry, xs.len() == len + 1);\n            xs.resize(len, 0);\n            assert_eq!(xs, &out[..len]);\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_add_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen().test_properties_with_config(&config, |(mut xs, y)| {\n        let n = Natural::from_limbs_asc(&xs) + Natural::from(y);\n        let carry = limbs_slice_add_limb_in_place(&mut xs, y);\n        let mut expected_xs = n.into_limbs_asc();\n        assert_eq!(carry, expected_xs.len() == xs.len() + 1);\n        expected_xs.resize(xs.len(), 0);\n        assert_eq!(xs, expected_xs);\n    });\n}\n\n#[test]\nfn limbs_vec_add_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(mut xs, y)| {\n        let n = Natural::from_limbs_asc(&xs) + Natural::from(y);\n        limbs_vec_add_limb_in_place(&mut xs, y);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n    });\n}\n\nfn limbs_add_helper(f: &dyn Fn(&[Limb], &[Limb]) -> Vec<Limb>, xs: Vec<Limb>, ys: Vec<Limb>) {\n    assert_eq!(\n        Natural::from_owned_limbs_asc(f(&xs, &ys)),\n        Natural::from_owned_limbs_asc(xs) + Natural::from_owned_limbs_asc(ys)\n    );\n}\n\n#[test]\nfn limbs_add_greater_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_1().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_add_helper(&limbs_add_greater, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_add_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_add_helper(&limbs_add, xs, ys);\n    });\n}\n\nfn limbs_add_to_out_helper(\n    f: &mut dyn FnMut(&mut [Limb], &[Limb], &[Limb]) -> bool,\n    out_len: &dyn Fn(usize, usize) -> usize,\n    mut out: Vec<Limb>,\n    xs: Vec<Limb>,\n    ys: Vec<Limb>,\n) {\n    let old_out = out.clone();\n    let carry = f(&mut out, &xs, &ys);\n    let len = out_len(xs.len(), ys.len());\n    let n = Natural::from_owned_limbs_asc(xs) + Natural::from_owned_limbs_asc(ys);\n    let mut xs = n.into_limbs_asc();\n    assert_eq!(carry, xs.len() == len + 1);\n    xs.resize(len, 0);\n    assert_eq!(xs, &out[..len]);\n    assert_eq!(&out[len..], &old_out[len..]);\n}\n\n#[test]\nfn limbs_add_greater_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_40().test_properties_with_config(&config, |(out, xs, ys)| {\n        limbs_add_to_out_helper(\n            &mut limbs_add_greater_to_out,\n            &|xs_len, _| xs_len,\n            out,\n            xs,\n            ys,\n        );\n    });\n}\n\n#[test]\nfn limbs_add_same_length_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_31().test_properties_with_config(&config, |(out, xs, ys)| {\n        limbs_add_to_out_helper(\n            &mut limbs_add_same_length_to_out,\n            &|xs_len, _| xs_len,\n            out,\n            xs,\n            ys,\n        );\n    });\n}\n\n#[test]\nfn limbs_add_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_32().test_properties_with_config(&config, |(out, xs, ys)| {\n        limbs_add_to_out_helper(&mut limbs_add_to_out, &max, out, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_add_to_out_aliased_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_11().test_properties_with_config(\n        &config,\n        |(mut xs, ys, xs_len)| {\n            let xs_old = xs.clone();\n            let carry = limbs_add_to_out_aliased(&mut xs, xs_len, &ys);\n            let ys_len = ys.len();\n            let n = Natural::from_limbs_asc(&xs_old[..xs_len]) + Natural::from_owned_limbs_asc(ys);\n            let mut ns = n.into_limbs_asc();\n            if ns.len() < ys_len {\n                ns.resize(ys_len, 0);\n            }\n            assert_eq!(\n                Natural::from_limbs_asc(&xs[..ys_len]),\n                Natural::from_limbs_asc(&ns[..ys_len]),\n            );\n            if carry {\n                assert_eq!(ns.len(), ys_len + 1);\n                assert_eq!(*ns.last().unwrap(), 1);\n            } else {\n                assert_eq!(ns.len(), ys_len);\n            }\n            assert_eq!(&xs[ys_len..], &xs_old[ys_len..]);\n        },\n    );\n}\n\nfn limbs_slice_add_in_place_left_helper(\n    f: &mut dyn FnMut(&mut [Limb], &[Limb]) -> bool,\n    xs: &mut [Limb],\n    ys: &[Limb],\n) {\n    let n = Natural::from_limbs_asc(xs) + Natural::from_limbs_asc(ys);\n    let carry = f(xs, ys);\n    let len = xs.len();\n    let mut ns = n.into_limbs_asc();\n    assert_eq!(carry, ns.len() == len + 1);\n    ns.resize(len, 0);\n    assert_eq!(ns, xs);\n}\n\n#[test]\nfn limbs_slice_add_same_length_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(mut xs, ys)| {\n        limbs_slice_add_in_place_left_helper(\n            &mut limbs_slice_add_same_length_in_place_left,\n            &mut xs,\n            &ys,\n        );\n    });\n}\n\n#[test]\nfn limbs_slice_add_greater_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_1().test_properties_with_config(&config, |(mut xs, ys)| {\n        limbs_slice_add_in_place_left_helper(\n            &mut limbs_slice_add_greater_in_place_left,\n            &mut xs,\n            &ys,\n        );\n    });\n}\n\n#[test]\nfn limbs_vec_add_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_vec_add_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(xs_old) + Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_slice_add_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let (right, b) = limbs_slice_add_in_place_either(&mut xs, &mut ys);\n        let len = max(xs_old.len(), ys_old.len());\n        let result = Natural::from_limbs_asc(&xs_old) + Natural::from_limbs_asc(&ys_old);\n        let mut expected_out = result.to_limbs_asc();\n        expected_out.resize(len, 0);\n        assert_eq!(!b, Natural::from_limbs_asc(&expected_out) == result);\n        if right {\n            assert_eq!(ys, expected_out.as_slice());\n            assert_eq!(xs, xs_old);\n        } else {\n            assert_eq!(xs, expected_out.as_slice());\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[test]\nfn limbs_vec_add_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_vec_add_in_place_either(&mut xs, &mut ys);\n        let n = Natural::from_limbs_asc(&xs_old) + Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(Natural::from_owned_limbs_asc(ys), n);\n        } else {\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[test]\nfn limbs_add_same_length_with_carry_in_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_9().test_properties_with_config(&config, |(out, xs, ys, carry_in)| {\n        let mut out = out.to_vec();\n        let old_out = out.clone();\n        let carry = limbs_add_same_length_with_carry_in_to_out(&mut out, &xs, &ys, carry_in);\n        let len = xs.len();\n        let mut n = Natural::from_owned_limbs_asc(xs) + Natural::from_owned_limbs_asc(ys);\n        if carry_in {\n            n += Natural::ONE;\n        }\n        let mut ns = n.into_limbs_asc();\n        assert_eq!(carry, ns.len() == len + 1);\n        ns.resize(len, 0);\n        assert_eq!(ns, &out[..len]);\n        assert_eq!(&out[len..], &old_out[len..]);\n    });\n}\n\n#[test]\nfn limbs_add_same_length_with_carry_in_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_bool_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(mut xs, ys, carry_in)| {\n            let xs_old = xs.clone();\n            let carry = limbs_add_same_length_with_carry_in_in_place_left(&mut xs, &ys, carry_in);\n            let mut n = Natural::from_owned_limbs_asc(xs_old) + Natural::from_owned_limbs_asc(ys);\n            if carry_in {\n                n += Natural::ONE;\n            }\n            let len = xs.len();\n            let mut ns = n.into_limbs_asc();\n            assert_eq!(carry, ns.len() == len + 1);\n            ns.resize(len, 0);\n            assert_eq!(ns, xs);\n        },\n    );\n}\n\n#[test]\nfn add_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let sum_val_val = x.clone() + y.clone();\n        let sum_val_ref = x.clone() + &y;\n        let sum_ref_val = &x + y.clone();\n        let sum = &x + &y;\n        assert!(sum_val_val.is_valid());\n        assert!(sum_val_ref.is_valid());\n        assert!(sum_ref_val.is_valid());\n        assert!(sum.is_valid());\n        assert_eq!(sum_val_val, sum);\n        assert_eq!(sum_val_ref, sum);\n        assert_eq!(sum_ref_val, sum);\n\n        let mut mut_x = x.clone();\n        mut_x += y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, sum);\n        let mut mut_x = x.clone();\n        mut_x += &y;\n        assert_eq!(mut_x, sum);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x += rug::Integer::from(&y);\n        assert_eq!(Natural::exact_from(&mut_x), sum);\n\n        assert_eq!(Natural::from(&(BigUint::from(&x) + BigUint::from(&y))), sum);\n        assert_eq!(\n            Natural::exact_from(&(rug::Integer::from(&x) + rug::Integer::from(&y))),\n            sum\n        );\n        assert_eq!(&y + &x, sum);\n        assert_eq!(&sum - &x, y);\n        assert_eq!(&sum - &y, x);\n        assert!(sum >= x);\n        assert!(sum >= y);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x + &y) + &z, x + (y + z));\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(&x + Natural::ZERO, x);\n        assert_eq!(Natural::ZERO + &x, x);\n        assert_eq!(&x + &x, x << 1);\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            DoubleLimb::from(x) + DoubleLimb::from(y),\n            Natural::from(x) + Natural::from(y)\n        );\n    });\n}\n\n#[test]\nfn sum_properties() {\n    natural_vec_gen().test_properties(|xs| {\n        let sum = Natural::sum(xs.iter().cloned());\n        assert!(sum.is_valid());\n\n        let sum_alt = Natural::sum(xs.iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n\n        let sum_alt = natural_sum_alt(xs.into_iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(Natural::sum(once(&x)), x);\n        assert_eq!(Natural::sum(once(x.clone())), x);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        let sum = &x + &y;\n        assert_eq!(Natural::sum([&x, &y].into_iter()), sum);\n        assert_eq!(Natural::sum([x, y].into_iter()), sum);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/add_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AddMul, AddMulAssign, CheckedAddMul};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_1, unsigned_triple_gen_var_19, unsigned_vec_triple_gen_var_41,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::add_mul::{\n    limbs_add_mul, limbs_add_mul_in_place_left, limbs_add_mul_limb,\n    limbs_slice_add_mul_limb_same_length_in_place_left,\n    limbs_slice_add_mul_limb_same_length_in_place_right, limbs_vec_add_mul_limb_in_place_either,\n    limbs_vec_add_mul_limb_in_place_left, limbs_vec_add_mul_limb_in_place_right,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_pair_gen, natural_triple_gen};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_mul_limb() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], z: Limb, result: &[Limb]| {\n        assert_eq!(limbs_add_mul_limb(xs_before, ys_before, z), result);\n        let mut xs = xs_before.to_vec();\n        limbs_vec_add_mul_limb_in_place_left(&mut xs, ys_before, z);\n        assert_eq!(xs, result);\n        let mut ys = ys_before.to_vec();\n        limbs_vec_add_mul_limb_in_place_right(xs_before, &mut ys, z);\n        assert_eq!(ys, result);\n    };\n    test(&[123, 456], &[123], 4, &[615, 456]);\n    test(&[123, 456], &[123], u32::MAX, &[0, 579]);\n    test(&[123], &[0, 123], 4, &[123, 492]);\n    test(&[123, 456], &[0, 123], u32::MAX, &[123, 333, 123]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_add_mul_limb_same_length_in_place_left() {\n    let test = |xs_before: &[Limb], ys: &[Limb], z: Limb, xs_after: &[Limb], carry: Limb| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_slice_add_mul_limb_same_length_in_place_left(&mut xs, ys, z),\n            carry\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[123], &[123], 4, &[615], 0);\n    test(&[123], &[123], u32::MAX, &[0], 123);\n    test(&[123, 0], &[0, 123], 4, &[123, 492], 0);\n    test(&[123, 456], &[0, 123], u32::MAX, &[123, 333], 123);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_add_mul_limb_same_length_in_place_left_fail() {\n    limbs_slice_add_mul_limb_same_length_in_place_left(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_add_mul_limb_same_length_in_place_right() {\n    let test = |xs: &[Limb], ys_before: &[Limb], z: Limb, ys_after: &[Limb], carry: Limb| {\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_slice_add_mul_limb_same_length_in_place_right(xs, &mut ys, z),\n            carry\n        );\n        assert_eq!(ys, ys_after);\n    };\n    test(&[123, 456], &[123, 0], 4, &[615, 456], 0);\n    test(&[123, 456], &[123, 0], u32::MAX, &[0, 579], 0);\n    test(&[123, 0], &[0, 123], 4, &[123, 492], 0);\n    test(&[123, 456], &[0, 123], u32::MAX, &[123, 333], 123);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_add_mul_limb_same_length_in_place_right_fail() {\n    limbs_slice_add_mul_limb_same_length_in_place_right(&[10, 10], &mut [10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_add_mul_limb_in_place_either() {\n    let test = |xs_before: &[Limb],\n                ys_before: &[Limb],\n                z: Limb,\n                right: bool,\n                xs_after: &[Limb],\n                ys_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_vec_add_mul_limb_in_place_either(&mut xs, &mut ys, z),\n            right\n        );\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[123, 456], &[123], 4, false, &[615, 456], &[123]);\n    test(\n        &[123, 456],\n        &[123, 0],\n        u32::MAX,\n        false,\n        &[0, 579],\n        &[123, 0],\n    );\n    test(&[123], &[0, 123], 4, true, &[123], &[123, 492]);\n    test(\n        &[123, 456],\n        &[0, 123],\n        u32::MAX,\n        false,\n        &[123, 333, 123],\n        &[0, 123],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_add_mul_and_limbs_add_mul_in_place_left() {\n    let test = |xs_before: &[Limb], ys: &[Limb], zs: &[Limb], result: &[Limb]| {\n        assert_eq!(limbs_add_mul(xs_before, ys, zs), result);\n        let mut xs = xs_before.to_vec();\n        limbs_add_mul_in_place_left(&mut xs, ys, zs);\n        assert_eq!(xs, result);\n    };\n    test(\n        &[123, 456],\n        &[123, 789],\n        &[321, 654],\n        &[39606, 334167, 516006],\n    );\n    test(\n        &[123, 456, 789, 987, 654],\n        &[123, 789],\n        &[321, 654],\n        &[39606, 334167, 516795, 987, 654],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_mul_fail_1() {\n    limbs_add_mul(&[10, 10], &[], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_mul_fail_2() {\n    limbs_add_mul(&[10, 10], &[10, 10], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_mul_in_place_left_fail_1() {\n    let mut xs = vec![10, 10];\n    limbs_add_mul_in_place_left(&mut xs, &[], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_add_mul_in_place_left_fail_2() {\n    let mut xs = vec![10, 10];\n    limbs_add_mul_in_place_left(&mut xs, &[10, 10], &[]);\n}\n\n#[test]\nfn test_add_mul() {\n    let test = |r, s, t, out| {\n        let u = Natural::from_str(r).unwrap();\n        let v = Natural::from_str(s).unwrap();\n        let w = Natural::from_str(t).unwrap();\n\n        let mut a = u.clone();\n        a.add_mul_assign(v.clone(), w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.add_mul_assign(v.clone(), &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.add_mul_assign(&v, w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let mut a = u.clone();\n        a.add_mul_assign(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(v.clone(), w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(v.clone(), &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(&v, w.clone());\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = u.clone().add_mul(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n\n        let a = (&u).add_mul(&v, &w);\n        assert_eq!(a.to_string(), out);\n        assert!(a.is_valid());\n    };\n    test(\"0\", \"0\", \"0\", \"0\");\n    test(\"0\", \"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"5\", \"123\");\n    test(\"123\", \"5\", \"1\", \"128\");\n    test(\"123\", \"5\", \"100\", \"623\");\n    test(\"10\", \"3\", \"4\", \"22\");\n    test(\"1000000000000\", \"0\", \"123\", \"1000000000000\");\n    test(\"1000000000000\", \"1\", \"123\", \"1000000000123\");\n    test(\"1000000000000\", \"123\", \"1\", \"1000000000123\");\n    test(\"1000000000000\", \"123\", \"100\", \"1000000012300\");\n    test(\"1000000000000\", \"100\", \"123\", \"1000000012300\");\n    test(\"1000000000000\", \"65536\", \"65536\", \"1004294967296\");\n    test(\"1000000000000\", \"1000000000000\", \"0\", \"1000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"1\", \"2000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"100\", \"101000000000000\");\n    test(\"0\", \"1000000000000\", \"100\", \"100000000000000\");\n    test(\n        \"1000000000000\",\n        \"65536\",\n        \"1000000000000\",\n        \"65537000000000000\",\n    );\n    test(\n        \"1000000000000\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"1000000000001000000000000\",\n    );\n    test(\n        \"0\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"1000000000000000000000000\",\n    );\n    test(\n        \"18446744073583722494\",\n        \"2\",\n        \"4033876984\",\n        \"18446744081651476462\",\n    );\n}\n\n#[test]\nfn limbs_add_mul_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties_with_config(\n        &config,\n        |(a, b, c)| {\n            assert_eq!(\n                limbs_add_mul_limb(&a, &b, c),\n                Natural::from_owned_limbs_asc(a)\n                    .add_mul(Natural::from_owned_limbs_asc(b), Natural::from(c))\n                    .into_limbs_asc()\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_add_mul_limb_same_length_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().test_properties_with_config(\n        &config,\n        |(a, b, c)| {\n            let a_old = a;\n            let mut a = a_old.to_vec();\n            let carry = limbs_slice_add_mul_limb_same_length_in_place_left(&mut a, &b, c);\n            let len = b.len();\n            let mut result = a[..len].to_vec();\n            result.push(carry);\n            assert_eq!(\n                Natural::from_owned_limbs_asc(result),\n                Natural::from_limbs_asc(&a_old[..len])\n                    .add_mul(Natural::from_owned_limbs_asc(b), Natural::from(c))\n            );\n            assert_eq!(&a[len..], &a_old[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_add_mul_limb_same_length_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().test_properties_with_config(\n        &config,\n        |(a, mut b, c)| {\n            let b_old = b.clone();\n            let carry = limbs_slice_add_mul_limb_same_length_in_place_right(&a, &mut b, c);\n            b.push(carry);\n            assert_eq!(\n                Natural::from_owned_limbs_asc(b),\n                Natural::from_owned_limbs_asc(a)\n                    .add_mul(Natural::from_owned_limbs_asc(b_old), Natural::from(c))\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_add_mul_limb_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties_with_config(\n        &config,\n        |(mut a, b, c)| {\n            let a_old = a.clone();\n            limbs_vec_add_mul_limb_in_place_left(&mut a, &b, c);\n            assert_eq!(\n                a,\n                Natural::from_owned_limbs_asc(a_old)\n                    .add_mul(Natural::from_owned_limbs_asc(b), Natural::from(c))\n                    .into_limbs_asc()\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_add_mul_limb_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties_with_config(\n        &config,\n        |(a, mut b, c)| {\n            let b_old = b.clone();\n            limbs_vec_add_mul_limb_in_place_right(&a, &mut b, c);\n            assert_eq!(\n                b,\n                Natural::from_owned_limbs_asc(a)\n                    .add_mul(Natural::from_owned_limbs_asc(b_old), Natural::from(c))\n                    .into_limbs_asc()\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_add_mul_limb_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_10().test_properties_with_config(\n        &config,\n        |(mut a, mut b, c)| {\n            let a_old = a.clone();\n            let b_old = b.clone();\n            let result = if limbs_vec_add_mul_limb_in_place_either(&mut a, &mut b, c) {\n                assert_eq!(a_old, a);\n                b\n            } else {\n                assert_eq!(b_old, b);\n                a\n            };\n            assert_eq!(\n                result,\n                Natural::from_owned_limbs_asc(a_old)\n                    .add_mul(Natural::from_owned_limbs_asc(b_old), Natural::from(c))\n                    .into_limbs_asc()\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_add_mul_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_41().test_properties_with_config(&config, |(a, b, c)| {\n        assert_eq!(\n            limbs_add_mul(&a, &b, &c),\n            Natural::from_owned_limbs_asc(a)\n                .add_mul(\n                    Natural::from_owned_limbs_asc(b),\n                    Natural::from_owned_limbs_asc(c)\n                )\n                .into_limbs_asc()\n        );\n    });\n}\n\n#[test]\nfn limbs_add_mul_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_41().test_properties_with_config(&config, |(mut a, b, c)| {\n        let a_old = a.clone();\n        limbs_add_mul_in_place_left(&mut a, &b, &c);\n        assert_eq!(\n            a,\n            Natural::from_owned_limbs_asc(a_old)\n                .add_mul(\n                    Natural::from_owned_limbs_asc(b),\n                    Natural::from_owned_limbs_asc(c)\n                )\n                .into_limbs_asc()\n        );\n    });\n}\n\n#[test]\nfn add_mul_properties() {\n    natural_triple_gen().test_properties(|(a, b, c)| {\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(b.clone(), c.clone());\n        assert!(mut_a.is_valid());\n        let result = mut_a;\n\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(b.clone(), &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(&b, c.clone());\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.add_mul_assign(&b, &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let result_alt = a.clone().add_mul(b.clone(), c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().add_mul(b.clone(), &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().add_mul(&b, c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().add_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = (&a).add_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert_eq!(&a + &b * &c, result);\n        assert_eq!(a.add_mul(c, b), result);\n    });\n\n    natural_pair_gen().test_properties(|(a, b)| {\n        let a = &a;\n        let b = &b;\n        assert_eq!(a.add_mul(&Natural::ZERO, b), *a);\n        assert_eq!(a.add_mul(&Natural::ONE, b), a + b);\n        assert_eq!(Natural::ZERO.add_mul(a, b), a * b);\n        assert_eq!(a.add_mul(b, &Natural::ZERO), *a);\n        assert_eq!(a.add_mul(b, &Natural::ONE), a + b);\n    });\n\n    unsigned_triple_gen_var_19::<Limb>().test_properties(|(x, y, z)| {\n        let result = Natural::from(x).add_mul(Natural::from(y), Natural::from(z));\n        assert_eq!(\n            x.checked_add_mul(y, z).is_some(),\n            Limb::convertible_from(&result)\n        );\n    });\n\n    unsigned_triple_gen_var_1::<Limb>().test_properties(|(x, y, z)| {\n        assert_eq!(\n            x.add_mul(y, z),\n            Natural::from(x).add_mul(Natural::from(y), Natural::from(z))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/binomial_coefficient.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{BinomialCoefficient, DivExact, Gcd};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_pair_gen_var_28, unsigned_pair_gen_var_44};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::binomial_coefficient::*;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_var_2, natural_pair_gen_var_15, unsigned_pair_gen_var_45,\n    unsigned_pair_gen_var_46, unsigned_pair_gen_var_47, unsigned_pair_gen_var_48,\n    unsigned_pair_gen_var_49,\n};\nuse malachite_nz::test_util::natural::arithmetic::binomial_coefficient::*;\nuse std::str::FromStr;\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_binomial_coefficient_limb_limb_bdiv() {\n    fn test(n: Limb, k: Limb, out: &[Limb]) {\n        let xs = limbs_binomial_coefficient_limb_limb_bdiv(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(xs, out);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    }\n    // - k_max == 0\n    // - ones == 0\n    test(26, 26, &[1]);\n    // - ones != 0\n    test(69, 32, &[10356137869959167254, 2]);\n    // - k_max != 0\n    test(\n        364,\n        227,\n        &[\n            13299750156278230008,\n            15204945566537371181,\n            1343180567794975186,\n            14635289525631461779,\n            10747969514869510295,\n            9942168,\n        ],\n    );\n    test(\n        1000,\n        500,\n        &[\n            2548782591045708352,\n            2287006466848960994,\n            434054286371261995,\n            9307092176803372215,\n            1234012513444138811,\n            6453284806000209963,\n            9510906063553676151,\n            16379477204911690877,\n            4813923858496575229,\n            4008028500528486217,\n            13325564105666315328,\n            7088459241230905245,\n            10525434632971158032,\n            12617275459030976558,\n            17868910957880245731,\n            27735200797,\n        ],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_binomial_coefficient_limb_limb_small_k() {\n    fn test(n: Limb, k: Limb, out: &[Limb]) {\n        let xs = limbs_binomial_coefficient_limb_limb_small_k(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(xs, out);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    }\n    // - nmax >= k\n    test(2, 2, &[1]);\n    // - nmax < k\n    // - numfac == 0\n    // - shift != 0 in limbs_hensel_div_limb\n    test(9, 9, &[1]);\n    // - numfac != 0\n    test(17, 17, &[1]);\n    // - shift == 0 in limbs_hensel_div_limb\n    test(836, 7, &[55217369185858880]);\n    test(\n        1000,\n        25,\n        &[4493608106319329376, 18354803010869864610, 140006850684],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_binomial_coefficient_limb_limb_basecase() {\n    fn test(n: Limb, k: Limb, out: Limb) {\n        assert_eq!(limbs_binomial_coefficient_limb_limb_basecase(n, k), out);\n        assert_eq!(\n            Natural::from(out),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    }\n    test(10, 5, 252);\n    test(67, 65, 2211);\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer() {\n    fn test(n: Limb, k: Limb, out: &[Limb]) {\n        let xs = limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(xs, out);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    }\n    // - !BIN_UIUI_RECURSIVE_SMALLDC || hk <= ODD_FACTORIAL_TABLE_LIMIT as Limb\n    // - n <= ODD_FACTORIAL_EXTTABLE_LIMIT as Limb\n    test(27, 25, &[351]);\n    // - n > ODD_FACTORIAL_EXTTABLE_LIMIT as Limb\n    // - !BIN_UIUI_RECURSIVE_SMALLDC || k <= ODD_FACTORIAL_TABLE_LIMIT as Limb\n    test(\n        10000,\n        25,\n        &[12769553919776416000, 9951314237341865820, 6910797670090152703, 99667982199316897],\n    );\n    // - BIN_UIUI_RECURSIVE_SMALLDC && hk > ODD_FACTORIAL_TABLE_LIMIT as Limb\n    test(54, 52, &[1431]);\n    // - BIN_UIUI_RECURSIVE_SMALLDC && k > ODD_FACTORIAL_TABLE_LIMIT as Limb\n    test(93, 51, &[10325892988062052036, 28774313]);\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_binomial_coefficient_limb_limb_goetgheluck() {\n    fn test(n: Limb, k: Limb, out: &[Limb]) {\n        let xs = limbs_binomial_coefficient_limb_limb_goetgheluck(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(xs, out);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    }\n    // - prod <= max_prod first time\n    // - ma < mb first time\n    // - a >= prime first time\n    // - ma >= mb first time\n    // - a < prime first time\n    // - sieve[index] & mask == 0 first time\n    // - prod <= max_prod second time\n    // - ma >= mb second time\n    // - a >= prime second time\n    // - ma < mb second time\n    // - a < prime second time\n    // - i <= max_i first time\n    // - sieve[index] & mask != 0 first time\n    // - i > max_i first time\n    // - sieve[index] & mask != 0 second time\n    // - i <= max_i second time\n    // - sieve[index] & mask == 0 second time\n    // - n % prime < k % prime\n    // - prod <= max_prod third time\n    // - n % prime >= k % prime\n    // - prod > max_prod third time\n    // - i > max_i second time\n    // - sieve[index] & mask != 0 third time\n    // - i <= max_i third time\n    // - sieve[index] & mask == 0 third time\n    // - prod <= max_prod fourth time\n    // - prod > max_prod fourth time\n    // - i > max_i third time\n    // - j != 0\n    test(\n        1024,\n        512,\n        &[\n            9401457825549664838,\n            2721813090096631178,\n            14255346604713632433,\n            3580037932091556548,\n            1754384789820018233,\n            2635023193750144437,\n            11050518185659523387,\n            12964790596359511527,\n            1445883973524779011,\n            12061501847736594246,\n            3370187743259284348,\n            6342914377781736300,\n            5825027960880516300,\n            13264895533447765242,\n            4401514467996618027,\n            459836855626902435,\n        ],\n    );\n    // - prod > max_prod second time\n    test(\n        1045,\n        519,\n        &[\n            5718966217258963792,\n            18109692964617656624,\n            12203044925148468153,\n            12014411658199454757,\n            12073183713056964826,\n            10217774024310452016,\n            5834695290287326173,\n            15738609591983585192,\n            1510425106975833791,\n            1194950807760887936,\n            13372185138508722787,\n            1955712450906595670,\n            3886453007529083390,\n            2635264355471572346,\n            11248337219650472692,\n            12482562081008645864,\n            50551,\n        ],\n    );\n}\n\n#[test]\nfn test_binomial_coefficient_limb_limb() {\n    fn test(n: Limb, k: Limb, out: &str) {\n        let x = binomial_coefficient_limb_limb(n, k);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(\n            x,\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    }\n    // - n >= k\n    // - k == 0\n    test(0, 0, \"1\");\n    test(1, 0, \"1\");\n    test(1, 1, \"1\");\n    test(2, 0, \"1\");\n    // - k == 1\n    test(2, 1, \"2\");\n    test(2, 2, \"1\");\n    test(3, 0, \"1\");\n    test(3, 1, \"3\");\n    test(3, 2, \"3\");\n    test(3, 3, \"1\");\n    test(4, 0, \"1\");\n    test(4, 1, \"4\");\n    // - using limbs_binomial_coefficient_limb_limb_basecase\n    test(4, 2, \"6\");\n    test(4, 3, \"4\");\n    test(4, 4, \"1\");\n    // - n < k\n    test(1, 2, \"0\");\n    test(10, 5, \"252\");\n    // - using limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer\n    test(100, 50, \"100891344545564193334812497256\");\n    // - using limbs_binomial_coefficient_limb_limb_small_k\n    test(68, 2, \"2278\");\n    // - using limbs_binomial_coefficient_limb_limb_bdiv\n    test(\n        557,\n        270,\n        \"12303897123684661862136414153519313173927533052423815769743887086897271613639625388778793\\\n        435582088957595545453390198975003546712921290727359277922023155427564241544480\",\n    );\n    // - using limbs_binomial_coefficient_limb_limb_goetgheluck\n    test(\n        1520,\n        604,\n        \"75854072694680390545636184213535932745981366536099293315554162782484973010323284519943551\\\n        805370379122919525568608395918396659326939152960648811048376751248471027979484001171948494\\\n        104610240152756095326405688057789446682785317328585217327221577095099162137370467209392535\\\n        545646923979679739966748638562974802230089647823656716367175837356234669272446104178944990\\\n        64852838291828963125461234805108096610500907519032849968173861190511519206171866000\",\n    );\n}\n\n#[test]\nfn test_binomial_coefficient() {\n    fn test(n: &str, k: &str, out: &str) {\n        let n = Natural::from_str(n).unwrap();\n        let k = Natural::from_str(k).unwrap();\n        let b = Natural::binomial_coefficient(n.clone(), k.clone());\n        assert!(b.is_valid());\n        assert_eq!(b.to_string(), out);\n\n        let b_alt = Natural::binomial_coefficient(&n, &k);\n        assert!(b_alt.is_valid());\n        assert_eq!(b_alt, b);\n\n        assert_eq!(binomial_coefficient_naive_1(n.clone(), k.clone()), b);\n        assert_eq!(binomial_coefficient_naive_2(n.clone(), k.clone()), b);\n        if let Ok(k) = u32::try_from(&k) {\n            assert_eq!(rug::Integer::from(&n).binomial(k).to_string(), out);\n        }\n    }\n    // - k <= n\n    // - k == 0 || n == k\n    test(\"0\", \"0\", \"1\");\n    test(\"1\", \"0\", \"1\");\n    test(\"1\", \"1\", \"1\");\n    test(\"2\", \"0\", \"1\");\n    // - k != 0 && n != k\n    // - double_cmp(&k, &n) != Greater\n    // - k < 2 in binomial_coefficient_helper\n    test(\"2\", \"1\", \"2\");\n    test(\"2\", \"2\", \"1\");\n    test(\"3\", \"0\", \"1\");\n    test(\"3\", \"1\", \"3\");\n    // - double_cmp(&k, &n) == Greater\n    test(\"3\", \"2\", \"3\");\n    test(\"3\", \"3\", \"1\");\n    test(\"4\", \"0\", \"1\");\n    test(\"4\", \"1\", \"4\");\n    // - k >= 2 && Limb::convertible_from(&n) in binomial_coefficient_helper\n    test(\"4\", \"2\", \"6\");\n    test(\"4\", \"3\", \"4\");\n    test(\"4\", \"4\", \"1\");\n    // - k > n\n    test(\"1\", \"2\", \"0\");\n    test(\"10\", \"5\", \"252\");\n    test(\"100\", \"50\", \"100891344545564193334812497256\");\n    // - k >= 2 && !Limb::convertible_from(&n) in binomial_coefficient_helper\n    // - k.even() first time in binomial_coefficient_raising_factorial_4\n    // - k <= Limb::power_of_2(Limb::WIDTH >> 1) in binomial_coefficient_hmul_nbnpk\n    // - k.odd() second time in binomial_coefficient_raising_factorial_4\n    // - r == 0 first time in binomial_coefficient_raising_factorial_4\n    // - k != 0 in binomial_coefficient_raising_factorial_4\n    // - r != 0 second time in binomial_coefficient_raising_factorial_4\n    // - k > 1 in binomial_coefficient_raising_factorial_4\n    // - k - lk < 5 in binomial_coefficient_raising_factorial_4_rec\n    // - k <= lk in binomial_coefficient_raising_factorial_4_rec\n    test(\n        \"1000000000000000000000000\",\n        \"10\",\n        \"27557319223985890652556079144620811287477954168595679012345679012345418595679012345679012\\\n        347422646604938271604938264183063271604938271604958214285714285714285714253397817460317460\\\n        3174603457499999999999999999999900000000000000000000000\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"999999999999999999999990\",\n        \"27557319223985890652556079144620811287477954168595679012345679012345418595679012345679012\\\n        347422646604938271604938264183063271604938271604958214285714285714285714253397817460317460\\\n        3174603457499999999999999999999900000000000000000000000\",\n    );\n    // - k.odd() first time in binomial_coefficient_raising_factorial_4\n    // - k.even() second time in binomial_coefficient_raising_factorial_4\n    // - k - lk >= 5 in binomial_coefficient_raising_factorial_4_rec\n    // - k > lk in binomial_coefficient_raising_factorial_4_rec\n    test(\n        \"25694718637547264792682404365646\",\n        \"77\",\n        \"24892107841828531181241909544492918596306121771031452631201178559919761115634737951594564\\\n        134356322099422004184733720911624149235259560430254876738408767931226785921407370175095156\\\n        586781390423037037354806763474907080465964805824615654538038771653753950919821491697271091\\\n        377714045381616063058884296191134488706691089783145326802624153519283791876914093506515827\\\n        833506442633078910514277387531336146210345320293586400210472321425351318080461247076886974\\\n        768698454873923739768679830132931625134235003968808918478243378730618857978191369012739961\\\n        051581373447851611688649593583701011088238159758896124868328792895820245726080012240623605\\\n        641788102744035650422323176408348710487482498610290424711478789115694916288138443827673675\\\n        370569473426454096853986388197987217558182898826734752119147506194959212385238127156463909\\\n        327557739453207008435734881763952972072877981513820560067736400661554297872808149726929774\\\n        009647173110901034073815261251706646282610156215143897705316902472221999807813890716324389\\\n        059130071475748736042259427029862564233394643788711602637944768761312353268539463729212269\\\n        415045191305842571853121600306112590657683014528748487348383916892187205977769846675553991\\\n        678198468541000193638965662990392249005490587691945513633072925439584423085568573063324438\\\n        190079886080774771402863370193790234632425970224213478091984184852108551225355019635354056\\\n        486480357281956498614205484617578531125055573838944472215270078882558231706258591409870228\\\n        048336579336293173152190873375502722426036746069862292026870602177622921149409743274336566\\\n        057103504313000613515998137450390738545271211718490829689241758733404923221326412878356941\\\n        435514837492022527605671586407700532750514057135146338845230795592073866772571401329026443\\\n        608142817184754893131076291570078101560304351288697491914877440785372806706691123696040114\\\n        923681774613230825471864285137036389227443209862850919338428947675401504411181949854055775\\\n        200409538150678687818266389944970852915636139634528094736089467929779413965463990220175083\\\n        710210323999501861734841899661962324188839025051105910476408529885881803658183792799548436\\\n        079055522933471249257212221461038082674897327598629096995991431788007725162706786103836085\\\n        868101229756394404428127938624116484159208824390263198961814488490969603019941815506011834\\\n        656564995524746083712970354462072408140254406415763673750\",\n    );\n    test(\n        \"18446744073709551615\",\n        \"158\",\n        \"55895522534362171876679545770571780830932656730029153560869974856994653843802569288729672\\\n        382637511859126481647849454205948292497053990755261689981054438192648753626841630309709195\\\n        818046531987560211901650810864524918303657683264406997638322847538595795406557688836851113\\\n        964170617643288481686744802130922248594817017440419821564431902277641567516581995890812918\\\n        486722065525008580823765669188839888456062057395467503086550870415427259131515369395143321\\\n        954047801400987772358011644373722286582971360737319736278747048729130702410986775490918876\\\n        230529996180462561974695082885810128945711270133861913341366432968582985806434359568905664\\\n        514713947374000003710986140313054418069500150430587294188316434107034410813333644810868109\\\n        517010015342588756758001231909300692391419214678692034627983296534319977780017419329875838\\\n        305344927801449612412534953383999840286057067187077005869924788433675067369851522793235730\\\n        315737008337149771567919123016352557348492008964898963676372074751843928582292062287972645\\\n        002479275926607204375396328813893195279046674831290420168619360957160719607118724011337751\\\n        884687312078496400868136122166666403111874431469083483195561561046860576791948708097239448\\\n        707700121141752690164054210305897535632910540849799510508361519672108494930297513957744916\\\n        541405888702155034069578507345846043015833055785496095916102636242742597283956473922401079\\\n        208727407330832207583179935719542716898842632948842003593449284004534387840878675132405353\\\n        545617559957750742653148569486728382115360807684946620305181043444563683398002670423056641\\\n        556205884154456331403885923859681242657192316862584038348512448080592213086456602118302523\\\n        497600139305650208731488402477762993305561030251065134570006992415665014910718509829224625\\\n        872159298105076966017786257520264468203354024508924179560925218008493771963278229045367865\\\n        887776645263717204778132848971659200666442585918134220062630814282240784092582922877337752\\\n        874525729691815214017623817845517096588696914035779725717257987350294068144824840587807588\\\n        357158318464027597598240198947245829267827323307370357782705746909925183438673236245050493\\\n        849326967187419243980545566285650601408510053072445047817977219500403018557783113306208827\\\n        167431080889349651649509675460140965485298062146167041924877070444810030309666624075227137\\\n        218638063690047219457567724110789914580071868854478163169581354672185562960327685598076336\\\n        690378854689193418551369074938423269725145368510358579999339101382841905493888240214883154\\\n        842774151093965701354532381623493383136070753785526556095815078903379059184394232509103407\\\n        445242908548214164343171473652463157048465973199937898538847219544675249899299702767453227\\\n        701439662328156741963625896736861699341091781695881895814781993228295591405890355373308533\\\n        69629590890184209436859538990383412624370182464931679935821512705\",\n    );\n    test(\n        \"18446744073709551615\",\n        \"67\",\n        \"17975145518991061179479323219129935574158608347154628002363871092506776489199109934521955\\\n        123099550607217011648682834882233989613437897676528916878068374745801854526845695228287766\\\n        789754958180819896635236168923015045618525205927314379144644668574770271895365790241559003\\\n        144822843889333362041474551859621080410036652606791515505353369554207762483251871851266970\\\n        526017855527470363796741702469836770390720021847155096242244011610914819823947147149757369\\\n        963787213725621805262787399500529025447928970023245860150872609280717916258813202603295120\\\n        573904776695107485006469437484809405204869700461623288629055326810940902543920025198724784\\\n        512861425829561074459250975049818414179892103155718839794288796334197669645772310664090067\\\n        383176579762499437658976815731335276585886004562625663405112281286580831287539250796636410\\\n        499555980578478064777424504455782233056592703195498279137626891735967240326084691333116555\\\n        048351036083482033114827059239588624846987544228990882068278651916209911673445783701818463\\\n        605412513547801208468857612548719031059286380708408871334262084700310978668806235603467446\\\n        875803132012584698568224321090559637699882304716272182566747176011138741513605154927341734\\\n        8337767036988850446297726975\",\n    );\n    // - r == 0 second time in binomial_coefficient_raising_factorial_4\n    test(\n        \"64794141400349148426125344064038245668210\",\n        \"256\",\n        \"66031965476204798455146874331523684080813362175686018331031515911090977873910155832605365\\\n        024088507121468974811846414037841974044761919328109003377289871853511171575036733766570594\\\n        891453274802950544969704784506297953600869073325018040500075322154584368142810932546171082\\\n        852158395260664371405927007989709292505767982485700717462755039001448808389259756963264278\\\n        906088556027912417831893433509962336148107621718179651346831471790176401806766480380429889\\\n        091161537666615007387280496039863931909142998822738027792169782639238146079132322198094998\\\n        802486850137067671945865080411439029612107336301348639088595876320707598941419394424283157\\\n        143766976110612717751687095427384089847206769596670568078428576165333416386232441693390109\\\n        663643281983434582393770222667816544269262132334616225677948861772526297326474869185995248\\\n        147223996638098457580467492870356321781996013113726822987288450823900111773163205636973304\\\n        380289800405883789689472988397794249318636225811197198716377966054543346740613593561974377\\\n        093009085172518201919751004048922207546914508128933773326960672960593784186495358724918479\\\n        796985664038589538200615872665489843329713567750689491887312970295325573546986255121402411\\\n        084560066792113137699614374211253083694137958737734257446884558418163050219974644457688081\\\n        676873402993322999032939870868467432529157509565329259639753569836216746833599315763759693\\\n        829765447474480250973648293550957370797807649367827793436798113040510064141170940749382465\\\n        206220269485857516368112061908007860073237682581918967583093557269558058823518949817468789\\\n        084216644967899755535494281973068520476114970926637305610945283948226717762805241122575066\\\n        678103015124110768502924767744781460648409786391934340118093908438148276389461167601820750\\\n        057069093773693074665652175457980958723759516515717047910383569619901407819068208673474699\\\n        453686471361006890630023875323558303493400544302118291489329274887331045875348205800862710\\\n        175052394281227458757959196016039413945472225266077758335879434496501644524406760148503536\\\n        777844536674510188616914664398525551534555340932552542038044113796537414101079613456296985\\\n        563991419519025675361727124584048105966929210844853432544846497675490471504969416848715119\\\n        092439521396484249151715675927492341087857671196859845186304379535276682803519065353324314\\\n        753738064545044955708632071615933033701914916065271501916712011810342168742156422262920787\\\n        990320364401380933898662355120884340792786670753109271316345859012462545725984191058886315\\\n        780390631728366246215522172383402706101501675956766022277331224839584378620731356043496863\\\n        785541271891585740098376406528987886519218563576267816719725054923546357372040525223848949\\\n        127753974390320001547914359669712714875205242660997027993020756142973623600187114692661037\\\n        463223091304396021296078235892866862323792231314445721295667474988263893282253274196685780\\\n        474772501116806432261201824061161163113862619883103396549652499049127008949545703101415021\\\n        959323424435960397307451027052471053244276197436645437020963781472397247593591077373074717\\\n        094053719991571689422435129889293085327836165576103011597448058754151829033639997737893083\\\n        842550015423824149716583089263434540508738377195408947652432376611378742646557728539254326\\\n        476152890041397510536077837901277246692068153800616280367894133910883810668466983308213587\\\n        221482938745562008958936847061728216788782564518434418288722461230400118273167234421901949\\\n        895714204179305818559684033777442551682966339667887715092224700434706792933312052909488102\\\n        079842621982456264706730931310278553720716127067281236666033604620046598324107408026680346\\\n        412372599646940552339198684588489969280418636356788664147669690402699465461172213740285470\\\n        809128728317682820264186890847420093051962425795653283884719000382298889430710471760502027\\\n        229103999961325795946767445375287269359953381217519871307479690576346343309759003193210071\\\n        556418039142564126112040263001368700411929992559256249934586198220607434498304226202009811\\\n        851202657216426523574148350721115772654468971702946249623853433692813341850096864575825766\\\n        875327019841615467863988595861381027218305979988212099705711032765590105239080603592671851\\\n        263007878964971854611940675180372780784561628267671888044540380421481565399877355853257247\\\n        904912714553488274268173076162924936684919527723389714147069548613898253656186458224176096\\\n        650679656664121232090301986651148027643907951818914611914284611587891731441594791289668499\\\n        732443965790127087948406108626423198713173029654246468017240080444863841518378912082628643\\\n        724261542806751229219083492033570837867883135531192455131856234586805554416472640371021449\\\n        626153219324461765285594058845200904698148046455373363116514572144638111797423237086355564\\\n        247860048288380294928679328053911481495367259163199843147875393924983826306330183640755507\\\n        721631146048737226709507724059249592648982425588036008000118061247531554850396149937729527\\\n        930090878598591797914711906297196260037210666173426412078722356587377867788754800643764289\\\n        349492930056977738160467345399517207696550782762419615728732412876581046942100815806171450\\\n        348045418018196938450493961876960731452162424045420483182667480966924113555262743123695828\\\n        842908617606474347446639604774874895056539625426950012998315670654871344246635345053749863\\\n        496640365576291398308932572744385646669612244790159569747800709995170292663386348773622916\\\n        561134395120135530744456556349965822317543312742948102629799123576739818344673647025657695\\\n        985344238813907956117069517497661033396357007152583146264519158459022423403393518704274469\\\n        555988017487304952556931240339272093145564884487180943346829587730987339974521536847163156\\\n        576792360583613136094081709906550031136279843694368596413923678731949271836013710356271449\\\n        750444414580685902236336967295155735991873355394004365947388684449125129801766071721100317\\\n        754267126693147225832067659102896333959362151819898227685846445795875977111413552941797422\\\n        553933826223370170202722743530536102426573846057258556374829036318491118228532586723711507\\\n        306175083430903562551070805871091783816943579841868012387755648345966129650056499655937025\\\n        786637878092663953415315273277401554564452187856322467035501932551411544392181881298986961\\\n        977669220229531562675556039911519639525744745226708275593777931260713611128737604054948983\\\n        139973224611064054789667235394810524925200258714854048451678007812968231907618644701400069\\\n        416728442304285423001695542417198763520331552551177941831892213963517136796389994665927604\\\n        459301587378625571860379754039201572427152553572980209384382435194093360849052249292611790\\\n        503999041541116237688173853723809560117304453500860053652419055303646548732887211219816022\\\n        640151501792454343959659164109351416330947070094808894238884111531377647551954029108954865\\\n        820855989915402340973344448073147690851869968726931741577360043521731876511950237869229333\\\n        859602928143413880913510506371294577002903467954358083654964723356629201256978479953248587\\\n        837494474562791991946166010566508192581355676686351165394433654073840991635192074086973572\\\n        163621004682262040173522080229706241781899722662323148146556857674870483185715528972858490\\\n        341376734230716934752618524152956020461673836080774036785780214798629565634422775934543353\\\n        476894063593324705839019506068594012535084480289279779876445412055235366951246546684773766\\\n        212435536276729263154137776171656339214503240937372959067826975944390909279310279488186009\\\n        284938438825832468869538671600734260099608765379746524963643065452430188106594098479755797\\\n        093870460951873974971714697637666625870945820997332659684169379272678395704589081533814498\\\n        140005779826762539275887677973897726706795887769141977524446776813526719526578593420736712\\\n        954032634210661657840530040608510833332863779404436297002475234120661252662270361338493492\\\n        578189610080628765357649189060318248893668432942439239400104110762226338091351054740301228\\\n        267114030372038914676357083876933841022019867273340907399707064313910406654589321612531521\\\n        602233355695432124690159097553479392454292250308539955098369447489417568755029977263235806\\\n        737535494742497503685663730366012718441966449290261821980738958389669746636037465845741790\\\n        748315986037312254641500834573322524472364659503566291792471608054787771836144999713040748\\\n        466357834461871406015310449476989294914019751283337432367578854283638114561957941268079431\\\n        890173027032456336882142230048504806653501455520488580583506078652051408716252946680955540\\\n        372281906409585858036827184877008395810459992480127401354027016126387228520620234335154464\\\n        821713911693946238556003001085542056042701510153072679687977939864130493222714210229201112\\\n        642263071677946070197883792071982433883297230356359448021422941875047191241501644623057173\\\n        683380213277548600830552213704456922714478433917536416960698247481747286784162314893055284\\\n        885473180947515913242742950779558619216152807571397814191898554257601274089785855209288639\\\n        494478547781184010543598204017553457188090206965615937213419385871077837956771570536756086\\\n        174306711357612692470993367865237583867552293229085658581609124490438092837633181262633832\\\n        224797483199978752769003102249388926725978940121151544263886670246958179931376644535033670\\\n        467812416073434198259354970151012012393996634623039876371855129029695663871190598266249780\\\n        985956108718263661078782256910771187915990947315908329250697737849898883453664118270530637\\\n        992646293212166265938379652583376259988885243320020604733922599818302151475423517827259313\\\n        745572427630024541315969730421839521723099984520094706630448404321113193582564213335655774\\\n        981763101020538995438787319788215596029041832485363544281092101855739567987099076742200167\\\n        364424955142913668223754444009608547667377068092022968659294922490236070017253740709080640\\\n        315292979235034789700250605885981133239085270171689650328229691156105945528843937717117926\\\n        974279215959289065294575953759240127500933613923927450217241389655578977813273562315693668\\\n        620610689781058230089093580999028877435087490580246008336904216212775259586405528318199698\\\n        927003543457809044748027664785695692314604437532737114872376072006455841723036100877964792\\\n        160706943287071568418614565943721712313708341206571425251067669284456587123688846181674686\\\n        565863767558687263852890202721039246395025\",\n    );\n    // - r != 0 first time in binomial_coefficient_raising_factorial_4\n    test(\n        \"525899105584115331831822389398654378975439821235847075538334479459976804361\",\n        \"39\",\n        \"63916028057105686233224647128326757355318526278850191265753818300077123506148592771686251\\\n        843871031286613741578697393929955287964794759564768972837142349342808068645976054243890830\\\n        335431299980007761289437669633253213451826328048705819152063003640688010892927140146765994\\\n        354038412675123498589995067406959494949003877187335117608898667586172913313268407045309326\\\n        477759661775566817269791782958981335897762329413676812249676003924448031057465002588047731\\\n        852626643205542869258383826751237297401033366907927123119420545541506268940498743697330488\\\n        751030122065781855695143246866312361451074604659115580225953639683092992548231210545034231\\\n        285233852021142144210530482766055167812957716779323951011087624228337943053231819759016008\\\n        625315621642894259660510209185578346141448798234857352488051062830286245538065408386075147\\\n        891775165871474412122232335872318403542887945441629517772432566332148611895718898507734193\\\n        765122244095887688382558927354124421602429208358235005847747779165375960977523729969144623\\\n        942428302069692001442132909094843144966416850972408319273833346995290959884209879178506231\\\n        148534376246222578564697565675661378959062018141850826958907520091990573403348600298989654\\\n        015323124079115828761962218496431800939709402415702347227440683769932960611846922227191597\\\n        870575184258217562373579180321454906142789445372655817629764513368590547268810214608619866\\\n        197718738244504054960382041108971143812515663988260257731991609483301668915756882792269602\\\n        669162926415723894743233548358640390458315117002551455170242787151998722348149039656347608\\\n        551565127458440090648316733044596038381441744468926633398369489669625808759994489694980764\\\n        526999955110732774112122334751376885411610502128309282739439676195629420963063203373174208\\\n        091590129280478685913083169673141792020290565109251623524461277589125997756234920480123074\\\n        209844165277719752489744793568781301978159825605932386339370565204645057536772220679746768\\\n        569224291055005731953230004831223439059300914798178296528394239043745002141250499403742249\\\n        183874569695076545083105825050171871111881712648095404574108051786690297924470700238074897\\\n        792414511177305601932558389549730072609925691552289753566425338003950881601294728845880132\\\n        500287043788618527834331584961373617001959960073108393488866008662550518286185355757098004\\\n        407731116008477326366253892028653451448990656804004447051045116046286082144417019317955065\\\n        059880762228310370726650525371685367667341518793755754089895626603855406071794521713173191\\\n        730870597842233077363902687264007764576583562429780462716550361987547856866479132368207653\\\n        806647693143188635189378544081798845519519486948493126898293329214413593802057692320667583\\\n        766380661973838437256232890788063096146364826652367871270984406087292750139629458354387512\\\n        791101502903444068723989625533851827638409364499043290472310636212447688058605971032119472\\\n        5991269626624579699378058679358476375414026678029422929039835277325354971910400\",\n    );\n    // - k == 0 in binomial_coefficient_raising_factorial_4\n    test(\n        \"55186653679569007523486527767687421937059940360080261894526453\",\n        \"3\",\n        \"28012439529730582769980703531255137397476701127318927388432337037639370308404590341026789\\\n        244616713573401635136679393282116959418116580481496576838954049642935186063159197881085428\\\n        921826\",\n    );\n    // - k <= 1 in binomial_coefficient_raising_factorial_4\n    test(\n        \"821407847938765300653812701638851178\",\n        \"5\",\n        \"31161115310790267810728647115818905409309919004871253034511265989952209125820211890996722\\\n        13934942403111281665464675315630857236685237472673845588842782932266933122933085560371660\",\n    );\n\n    fn test_large(n: &str, k: &str) {\n        let n = Natural::from_str(n).unwrap();\n        let k = Natural::from_str(k).unwrap();\n        let b = Natural::binomial_coefficient(n.clone(), k.clone());\n        assert!(b.is_valid());\n\n        let b_alt = Natural::binomial_coefficient(&n, &k);\n        assert!(b_alt.is_valid());\n        assert_eq!(b_alt, b);\n\n        assert_eq!(binomial_coefficient_naive_2(n.clone(), k.clone()), b);\n        if let Ok(k) = u32::try_from(&k) {\n            assert_eq!(Natural::exact_from(&rug::Integer::from(&n).binomial(k)), b);\n        }\n    }\n    // - k > Limb::power_of_2(Limb::WIDTH >> 1) in binomial_coefficient_hmul_nbnpk\n    test_large(\"4294967296\", \"131076\");\n}\n\n#[test]\nfn limbs_binomial_coefficient_limb_limb_bdiv_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 256);\n    unsigned_pair_gen_var_45().test_properties_with_config(&config, |(n, k)| {\n        let xs = limbs_binomial_coefficient_limb_limb_bdiv(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    });\n}\n\n#[test]\nfn limbs_binomial_coefficient_limb_limb_small_k_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 256);\n    unsigned_pair_gen_var_46().test_properties_with_config(&config, |(n, k)| {\n        let xs = limbs_binomial_coefficient_limb_limb_small_k(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    });\n}\n\n#[test]\nfn limbs_binomial_coefficient_limb_limb_basecase_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 256);\n    unsigned_pair_gen_var_47().test_properties_with_config(&config, |(n, k)| {\n        assert_eq!(\n            Natural::from(limbs_binomial_coefficient_limb_limb_basecase(n, k)),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    });\n}\n\n#[test]\nfn limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 256);\n    unsigned_pair_gen_var_48().test_properties_with_config(&config, |(n, k)| {\n        let xs = limbs_binomial_coefficient_limb_limb_small_k_divide_and_conquer(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k))\n        );\n    });\n}\n\n#[test]\nfn limbs_binomial_coefficient_limb_limb_goetgheluck_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 256);\n    unsigned_pair_gen_var_49().test_properties_with_config(&config, |(n, k)| {\n        let xs = limbs_binomial_coefficient_limb_limb_goetgheluck(n, k);\n        assert_ne!(*xs.last().unwrap(), 0);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k)),\n        );\n    });\n}\n\n#[test]\nfn binomial_coefficient_limb_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_small_n\", 256);\n    unsigned_pair_gen_var_28().test_properties_with_config(&config, |(n, k)| {\n        let x = binomial_coefficient_limb_limb(n, k);\n        assert!(x.is_valid());\n        assert_eq!(\n            x,\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k)),\n        );\n    });\n}\n\n#[test]\nfn binomial_coefficient_properties() {\n    natural_pair_gen_var_15().test_properties(|(n, k)| {\n        let b = Natural::binomial_coefficient(n.clone(), k.clone());\n        assert!(b.is_valid());\n\n        let b_alt = Natural::binomial_coefficient(&n, &k);\n        assert!(b_alt.is_valid());\n        assert_eq!(b, b_alt);\n\n        assert_eq!(binomial_coefficient_naive_1(n.clone(), k.clone()), b);\n        assert_eq!(binomial_coefficient_naive_2(n.clone(), k.clone()), b);\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::from(&n).binomial(u32::exact_from(&k))),\n            b\n        );\n        assert_eq!(b == 0u32, n < k);\n        if n >= k {\n            assert_eq!(Natural::binomial_coefficient(&n, &(&n - &k)), b);\n        }\n        if n != 0u32 && k != 0u32 {\n            let c = Natural::binomial_coefficient(&n - Natural::ONE, &k - Natural::ONE);\n            assert_eq!(\n                Natural::binomial_coefficient(&(&n - Natural::ONE), &k) + &c,\n                b\n            );\n            let gcd = (&n).gcd(&k);\n            assert_eq!(c.div_exact(k.div_exact(&gcd)) * n.div_exact(gcd), b);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(Natural::binomial_coefficient(&n, &Natural::ZERO), 1u32);\n        assert_eq!(Natural::binomial_coefficient(&n, &Natural::ONE), n);\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(Natural::binomial_coefficient(&n, &n), 1u32);\n        assert_eq!(Natural::binomial_coefficient(&n, &(&n - Natural::ONE)), n);\n        assert_eq!(Natural::binomial_coefficient(Natural::ZERO, n), 0u32);\n    });\n\n    unsigned_pair_gen_var_44::<Limb>().test_properties(|(n, k)| {\n        assert_eq!(\n            Natural::binomial_coefficient(Natural::from(n), Natural::from(k)),\n            Limb::binomial_coefficient(n, k)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/checked_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::CheckedSub;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen};\nuse malachite_nz::test_util::natural::arithmetic::checked_sub::checked_sub;\nuse num::BigUint;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_checked_sub_natural() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let on = u.clone().checked_sub(v.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = u.clone().checked_sub(&v);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = (&u).checked_sub(v.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = (&u).checked_sub(&v);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = checked_sub(BigUint::from_str(s).unwrap(), BigUint::from_str(t).unwrap())\n            .map(|x| Natural::from(&x));\n        assert_eq!(on.to_debug_string(), out);\n\n        let on = checked_sub(\n            rug::Integer::from_str(s).unwrap(),\n            rug::Integer::from_str(t).unwrap(),\n        );\n        assert_eq!(on.to_debug_string(), out);\n    };\n    test(\"0\", \"0\", \"Some(0)\");\n    test(\"0\", \"123\", \"None\");\n    test(\"123\", \"0\", \"Some(123)\");\n    test(\"456\", \"123\", \"Some(333)\");\n    test(\"1000000000000\", \"123\", \"Some(999999999877)\");\n    test(\"123\", \"1000000000000\", \"None\");\n    test(\n        \"12345678987654321\",\n        \"314159265358979\",\n        \"Some(12031519722295342)\",\n    );\n    test(\"4294967296\", \"1\", \"Some(4294967295)\");\n    test(\"4294967295\", \"4294967295\", \"Some(0)\");\n    test(\"4294967296\", \"4294967295\", \"Some(1)\");\n    test(\"4294967296\", \"4294967296\", \"Some(0)\");\n    test(\"4294967295\", \"4294967296\", \"None\");\n    test(\"18446744073709551616\", \"1\", \"Some(18446744073709551615)\");\n    test(\"18446744073709551615\", \"18446744073709551615\", \"Some(0)\");\n    test(\"18446744073709551616\", \"18446744073709551615\", \"Some(1)\");\n    test(\"18446744073709551615\", \"18446744073709551616\", \"None\");\n    test(\n        \"70734740290631708\",\n        \"282942734368\",\n        \"Some(70734457347897340)\",\n    );\n    test(\"282942734368\", \"70734740290631708\", \"None\");\n}\n\n#[test]\nfn checked_sub_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let diff = if x >= y {\n            let mut mut_x = x.clone();\n            mut_x -= &y;\n            assert!(mut_x.is_valid());\n            let diff = mut_x;\n\n            let mut rug_x = rug::Integer::from(&x);\n            rug_x -= rug::Integer::from(&y);\n            assert_eq!(Natural::exact_from(&rug_x), diff);\n            Some(diff)\n        } else {\n            None\n        };\n\n        let diff_alt = x.clone().checked_sub(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.as_ref().is_none_or(Natural::is_valid));\n\n        let diff_alt = x.clone().checked_sub(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.as_ref().is_none_or(Natural::is_valid));\n\n        let diff_alt = (&x).checked_sub(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.as_ref().is_none_or(Natural::is_valid));\n\n        let diff_alt = (&x).checked_sub(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.as_ref().is_none_or(Natural::is_valid));\n\n        let reverse_diff = (&y).checked_sub(&x);\n        assert_eq!(reverse_diff.is_some(), x == y || diff.is_none());\n\n        assert_eq!(\n            checked_sub(BigUint::from(&x), BigUint::from(&y)).map(|x| Natural::from(&x)),\n            diff\n        );\n        assert_eq!(\n            checked_sub(rug::Integer::from(&x), rug::Integer::from(&y))\n                .map(|x| Natural::exact_from(&x)),\n            diff\n        );\n\n        if let Some(diff) = diff {\n            assert!(diff <= x);\n            assert_eq!(diff + &y, x);\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).checked_sub(Natural::ZERO).as_ref(), Some(&x));\n        assert_eq!((&x).checked_sub(&x), Some(Natural::ZERO));\n        if x != 0 {\n            assert!((Natural::ZERO.checked_sub(x)).is_none());\n        }\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            x.checked_sub(y).map(Natural::from),\n            Natural::from(x).checked_sub(Natural::from(y))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/checked_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedSub, CheckedSubMul};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_19;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_checked_sub_mul() {\n    let test = |r, s, t, out| {\n        let u = Natural::from_str(r).unwrap();\n        let v = Natural::from_str(s).unwrap();\n        let w = Natural::from_str(t).unwrap();\n\n        let on = u.clone().checked_sub_mul(v.clone(), w.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = u.clone().checked_sub_mul(v.clone(), &w);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = u.clone().checked_sub_mul(&v, w.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = u.clone().checked_sub_mul(&v, &w);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n\n        let on = (&u).checked_sub_mul(&v, &w);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.is_none_or(|n| n.is_valid()));\n    };\n    test(\"0\", \"0\", \"0\", \"Some(0)\");\n    test(\"0\", \"0\", \"123\", \"Some(0)\");\n    test(\"123\", \"0\", \"5\", \"Some(123)\");\n    test(\"123\", \"5\", \"1\", \"Some(118)\");\n    test(\"123\", \"5\", \"100\", \"None\");\n    test(\"10\", \"3\", \"4\", \"None\");\n    test(\"15\", \"3\", \"4\", \"Some(3)\");\n    test(\"1000000000000\", \"0\", \"123\", \"Some(1000000000000)\");\n    test(\"1000000000000\", \"1\", \"123\", \"Some(999999999877)\");\n    test(\"1000000000000\", \"123\", \"1\", \"Some(999999999877)\");\n    test(\"1000000000000\", \"123\", \"100\", \"Some(999999987700)\");\n    test(\"1000000000000\", \"100\", \"123\", \"Some(999999987700)\");\n    test(\"1000000000000\", \"65536\", \"65536\", \"Some(995705032704)\");\n    test(\"1000000000000\", \"1000000000000\", \"0\", \"Some(1000000000000)\");\n    test(\"1000000000000\", \"1000000000000\", \"1\", \"Some(0)\");\n    test(\"1000000000000\", \"1000000000000\", \"100\", \"None\");\n    test(\"0\", \"1000000000000\", \"100\", \"None\");\n    test(\"4294967296\", \"1\", \"1\", \"Some(4294967295)\");\n    test(\"3902609153\", \"88817093856604\", \"1\", \"None\");\n}\n\n#[test]\nfn checked_sub_properties() {\n    natural_triple_gen().test_properties(|(a, b, c)| {\n        let result = (&a).checked_sub_mul(&b, &c);\n        assert!(result.as_ref().is_none_or(Natural::is_valid));\n\n        let result_alt = a.clone().checked_sub_mul(&b, &c);\n        assert!(result_alt.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().checked_sub_mul(&b, c.clone());\n        assert!(result_alt.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().checked_sub_mul(b.clone(), &c);\n        assert!(result_alt.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().checked_sub_mul(b.clone(), c.clone());\n        assert!(result_alt.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(result_alt, result);\n\n        assert_eq!(a.checked_sub(b * c), result);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).checked_sub_mul(&n, &Natural::ONE), Some(Natural::ZERO));\n    });\n\n    natural_pair_gen().test_properties(|(a, b)| {\n        assert_eq!((&a).checked_sub_mul(&Natural::ZERO, &b).as_ref(), Some(&a));\n        assert_eq!((&a).checked_sub_mul(&b, &Natural::ZERO).as_ref(), Some(&a));\n        assert_eq!(\n            (&a).checked_sub_mul(&Natural::ONE, &b),\n            (&a).checked_sub(&b)\n        );\n        assert_eq!((&a).checked_sub_mul(&b, &Natural::ONE), a.checked_sub(b));\n    });\n\n    unsigned_triple_gen_var_19::<Limb>().test_properties(|(x, y, z)| {\n        assert_eq!(\n            x.checked_sub_mul(y, z).map(Natural::from),\n            Natural::from(x).checked_sub_mul(Natural::from(y), Natural::from(z))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/coprime_with.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CoprimeWith, Gcd};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::coprime_with::{\n    coprime_with_check_2, coprime_with_check_2_3, coprime_with_check_2_3_5,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_coprime_with() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.clone().coprime_with(v.clone()), out);\n        assert_eq!((&u).coprime_with(v.clone()), out);\n        assert_eq!(u.clone().coprime_with(&v), out);\n        assert_eq!((&u).coprime_with(&v), out);\n    };\n    test(\"0\", \"0\", false);\n    test(\"0\", \"6\", false);\n    test(\"6\", \"0\", false);\n    test(\"1\", \"6\", true);\n    test(\"6\", \"1\", true);\n    test(\"8\", \"12\", false);\n    test(\"54\", \"24\", false);\n    test(\"42\", \"56\", false);\n    test(\"48\", \"18\", false);\n    test(\"3\", \"5\", true);\n    test(\"12\", \"60\", false);\n    test(\"12\", \"90\", false);\n    test(\"12345678987654321\", \"98765432123456789\", true);\n    test(\"12345678987654321\", \"98765432123456827\", false);\n}\n\n#[test]\nfn coprime_with_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let c = (&x).coprime_with(&y);\n        assert_eq!(x.clone().coprime_with(y.clone()), c);\n        assert_eq!(x.clone().coprime_with(&y), c);\n        assert_eq!((&x).coprime_with(y.clone()), c);\n\n        assert_eq!((&x).gcd(&y) == 1, c);\n        assert_eq!(coprime_with_check_2(x.clone(), y.clone()), c);\n        assert_eq!(coprime_with_check_2_3(x.clone(), y.clone()), c);\n        assert_eq!(coprime_with_check_2_3_5(x.clone(), y.clone()), c);\n        assert_eq!(y.coprime_with(x), c);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).coprime_with(&x), x == 1);\n        assert!((&x).coprime_with(Natural::ONE));\n        assert_eq!((&x).coprime_with(Natural::ZERO), x == 1);\n        let y = &x + Natural::ONE;\n        assert!(x.coprime_with(y));\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Natural::from(x).coprime_with(Natural::from(y)),\n            x.coprime_with(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedDiv, DivMod};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_12, unsigned_vec_unsigned_pair_gen_var_22,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::div::{\n    limbs_div, limbs_div_barrett, limbs_div_barrett_approx, limbs_div_barrett_approx_scratch_len,\n    limbs_div_barrett_scratch_len, limbs_div_divide_and_conquer,\n    limbs_div_divide_and_conquer_approx, limbs_div_divisor_of_limb_max_with_carry_in_place,\n    limbs_div_divisor_of_limb_max_with_carry_to_out, limbs_div_schoolbook,\n    limbs_div_schoolbook_approx, limbs_div_to_out, limbs_div_to_out_ref_ref,\n    limbs_div_to_out_ref_val, limbs_div_to_out_val_ref,\n};\nuse malachite_nz::natural::arithmetic::div::{\n    limbs_div_limb, limbs_div_limb_in_place, limbs_div_limb_to_out,\n};\nuse malachite_nz::natural::arithmetic::div_mod::limbs_two_limb_inverse_helper;\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_10, large_type_gen_var_11, large_type_gen_var_12, natural_gen,\n    natural_gen_var_2, natural_pair_gen, natural_pair_gen_var_5, natural_pair_gen_var_6,\n    unsigned_vec_triple_gen_var_42, unsigned_vec_triple_gen_var_43, unsigned_vec_triple_gen_var_44,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_9,\n};\nuse malachite_nz::test_util::natural::arithmetic::div::{\n    limbs_div_limb_in_place_alt, limbs_div_limb_to_out_alt,\n};\nuse num::BigUint;\nuse num::CheckedDiv as NumCheckedDiv;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_limb_and_limbs_div_limb_in_place() {\n    let test = |ns: &[Limb], d: Limb, q: &[Limb]| {\n        assert_eq!(limbs_div_limb(ns, d), q);\n\n        let mut ns = ns.to_vec();\n        let ns_old = ns.clone();\n        limbs_div_limb_in_place(&mut ns, d);\n        assert_eq!(ns, q);\n\n        let mut ns = ns_old;\n        limbs_div_limb_in_place_alt(&mut ns, d);\n        assert_eq!(ns, q);\n    };\n    test(&[0, 0], 2, &[0, 0]);\n    test(&[6, 7], 1, &[6, 7]);\n    test(&[6, 7], 2, &[0x80000003, 3]);\n    test(&[100, 101, 102], 10, &[1288490198, 858993469, 10]);\n    test(&[123, 456], 789, &[2482262467, 0]);\n    test(&[u32::MAX, u32::MAX], 2, &[u32::MAX, 0x7fffffff]);\n    test(&[u32::MAX, u32::MAX], 3, &[0x55555555, 0x55555555]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_fail_1() {\n    limbs_div_limb(&[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_fail_2() {\n    limbs_div_limb(&[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_in_place_fail_1() {\n    limbs_div_limb_in_place(&mut [10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_in_place_fail_2() {\n    limbs_div_limb_in_place(&mut [10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_limb_to_out() {\n    let test = |out_before: &[Limb], ns: &[Limb], d: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_div_limb_to_out(&mut out, ns, d);\n        assert_eq!(out, out_after);\n\n        let mut out = out_before.to_vec();\n        limbs_div_limb_to_out_alt(&mut out, ns, d);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[0, 0], 2, &[0, 0, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 1, &[6, 7, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, &[0x80000003, 3, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        &[1288490198, 858993469, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        789,\n        &[2482262467, 0, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, u32::MAX],\n        2,\n        &[u32::MAX, 0x7fffffff, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, u32::MAX],\n        3,\n        &[0x55555555, 0x55555555, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_to_out_fail_1() {\n    limbs_div_limb_to_out(&mut [10], &[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_to_out_fail_2() {\n    limbs_div_limb_to_out(&mut [10, 10], &[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_to_out_fail_3() {\n    limbs_div_limb_to_out(&mut [10], &[10, 10], 10);\n}\n\nfn verify_limbs_div(qs_in: &[Limb], ns: &[Limb], ds: &[Limb], q_highest: bool, qs_out: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let expected_q = &n / &d;\n    let base_q_len = ns.len() - ds.len();\n    let mut qs = qs_out[..base_q_len].to_vec();\n    if q_highest {\n        qs.push(1);\n    }\n    let q = Natural::from_owned_limbs_asc(qs);\n    assert_eq!(q, expected_q);\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n    let r = n - q * &d;\n    assert!(r < d);\n}\n\n#[test]\nfn test_limbs_div_schoolbook() {\n    let test = |qs_in: &[Limb], ns_in: &[Limb], ds: &[Limb], q_highest, qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n        assert_eq!(limbs_div_schoolbook(&mut qs, &mut ns, ds, d_inv), q_highest);\n        assert_eq!(qs, qs_out);\n        verify_limbs_div(qs_in, ns_in, ds, q_highest, &qs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - q_len < d_len_m_1\n        // - !highest_q first time\n        // - !(!flag || n_1 < Limb::try_from(d_len).unwrap())\n        test(&[10], &[1, 2, 3], &[3, 4, 0x80000000], false, &[10]);\n        // - q_len >= d_len_m_1\n        // - !(n_1 == d_1 && ns[d_len_s_m_1] == d_2)\n        // - !carry first time\n        // - d_len_s >= 2\n        // - !(!flag || n_1 >= d_1) first time\n        // - !carry second time\n        // - !(!flag || n_1 >= d_1) second time\n        test(\n            &[10, 10, 10, 10],\n            &[1, 2, 3, 4, 5, 6],\n            &[3, 4, 0x80000000],\n            false,\n            &[4294967207, 9, 12, 10],\n        );\n        // - !flag || n_1 < Limb::try_from(d_len).unwrap()\n        // - !highest_q second time\n        // - q_len != 0\n        // - limbs_sub_limb_in_place(ns_hi, limbs_sub_mul_limb_same_length_in_place_left(ns_lo, qs,\n        //   ds[i])) fourth time\n        // - n_1 == 0 third time\n        test(&[10], &[0, 0, 0, 1], &[1, 0, 0x80000000], false, &[1]);\n        // - q_len == 0 second time\n        test(&[10], &[0; 3], &[0, 0, 0x80000000], false, &[10]);\n        // - *ns_last >= carry\n        test(&[10; 3], &[0; 5], &[0, 0, 0x80000000], false, &[0, 0, 10]);\n        // - n_1 != 0 third time\n        test(\n            &[10; 2],\n            &[0, 0, 1, 1],\n            &[1, 0, 0x80000000],\n            false,\n            &[2, 10],\n        );\n        // - highest_q first time\n        test(\n            &[10, 10],\n            &[\n                2460989955, 642673607, 1971681331, 2338977519, 475442971, 2516527409, 3470931196,\n                4262052990,\n            ],\n            &[\n                1430162564, 1873089879, 3090281851, 2861182896, 2502166555, 2486624904, 960387080,\n                3073064701,\n            ],\n            true,\n            &[10, 10],\n        );\n        // - !flag || n_1 >= d_1 second time\n        // - n_1 == carry second time\n        test(\n            &[10; 2],\n            &[0, 0, 1, 0, 1],\n            &[0, 1, 0x80000000],\n            false,\n            &[u32::MAX, 1],\n        );\n        // - carry second time\n        test(\n            &[10; 2],\n            &[0, 0, 0, 0, 1],\n            &[1, 0, 0x80000000],\n            false,\n            &[u32::MAX, 1],\n        );\n        // - *ns_last < carry\n        // - n_1 != 0 first time\n        // - highest_q second time\n        // - !carry third time\n        test(\n            &[10; 20],\n            &[\n                4294966784,\n                16383,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xff000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4095,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffffc,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xffffff00,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                15,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xf0000000,\n                16383,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffff000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4095,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffff0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2540339372,\n            ],\n            true,\n            &[\n                2788498651, 3973284986, 2817551825, 2648982666, 1871496085, 1183691368, 1920086634,\n                2156916676, 2580901671, 858626385, 3833802894, 4255330726, 3612427555, 2966560147,\n                10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - carry third time\n        // - n_1 != 0 second time\n        test(\n            &[10; 8],\n            &[\n                0,\n                0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                63,\n                0,\n                0,\n                0,\n                0,\n                4294966784,\n                u32::MAX,\n                255,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                31,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffff000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2874223232,\n            ],\n            true,\n            &[\n                3459164144, 2642691284, 1062969477, 1392962372, 1677352416, 1850494842, 2123025524,\n                10,\n            ],\n        );\n        // - !flag || n_1 >= d_1 first time\n        // - n_1 == carry first time\n        test(\n            &[10; 10],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffff8,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0xffff0000,\n                u32::MAX,\n                0x1fffff,\n                0,\n                0,\n                0,\n                0,\n                4294959104,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                4160749568,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fffff,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX,\n                3500471700,\n            ],\n            true,\n            &[\n                1188137339,\n                3726116623,\n                2078060623,\n                u32::MAX,\n                2498443049,\n                1067076977,\n                2528078370,\n                1716103827,\n                974820792,\n                10,\n            ],\n        );\n        // - n_1 == 0 first time\n        test(\n            &[10; 20],\n            &[\n                0,\n                0xfffffffc,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966784,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xffffff00,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7ffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3828608089,\n            ],\n            true,\n            &[\n                2643432265, 2230909280, 3987412564, 1770201633, 2297365160, 1655451772, 3061719465,\n                182613124, 3034480808, 3038313569, 3464266718, 249914758, 4270196816, 4141866692,\n                91710029, 4264403435, 2579237268, 67618125, 523165989, 10,\n            ],\n        );\n        // - n_1 != carry first time\n        // - flag && n_1 < carry first time\n        test(\n            &[10; 73],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966784,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xf0000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294836224,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4024661822,\n            ],\n            true,\n            &[\n                201450768,\n                518871072,\n                3015445987,\n                3944509552,\n                208835829,\n                3460787832,\n                1884898895,\n                2547198435,\n                186469778,\n                3505271765,\n                1840399470,\n                2685063887,\n                2953363253,\n                1530364228,\n                3130405732,\n                893752596,\n                3868726834,\n                4151054974,\n                2514125465,\n                3161927869,\n                2354681787,\n                1962216954,\n                2851892627,\n                2800023632,\n                4197573593,\n                3243049600,\n                922941226,\n                2202547330,\n                3061793011,\n                1583790204,\n                3045500683,\n                440439528,\n                2631483812,\n                1993907261,\n                2362030668,\n                4006507490,\n                u32::MAX - 1,\n                2180774078,\n                372389172,\n                842953352,\n                3854387892,\n                1420082779,\n                4086327226,\n                1481011735,\n                2795106458,\n                2092419963,\n                1299755146,\n                3455955436,\n                2935373316,\n                2973368959,\n                208681747,\n                1883779895,\n                599992803,\n                1583705426,\n                4184839928,\n                352155351,\n                1499776059,\n                3341886577,\n                2973508834,\n                452082451,\n                98512703,\n                1051917695,\n                3372026069,\n                2092419965,\n                1233174284,\n                2711177091,\n                1249466612,\n                3854527767,\n                1663483483,\n                2301060034,\n                1932936627,\n                288459805,\n                10,\n            ],\n        );\n        // - carry first time\n        test(\n            &[10; 45],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294967279,\n                u32::MAX,\n                u32::MAX,\n                0,\n                4294966272,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294959104,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0xffffff00,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[0xffff0000, u32::MAX, 16383, 3221225472, u32::MAX, u32::MAX, 2953571387],\n            true,\n            &[\n                1344119085,\n                4210855069,\n                928035132,\n                841350331,\n                528284037,\n                1219359454,\n                3548354897,\n                1057752790,\n                3847832303,\n                1950615424,\n                782270048,\n                1691663352,\n                2130612726,\n                2986797999,\n                2134900501,\n                367200458,\n                366133304,\n                4140157070,\n                1119890783,\n                2133610345,\n                309344350,\n                1553079209,\n                39974261,\n                4150943609,\n                1565848679,\n                3244273595,\n                2309629507,\n                3647061699,\n                1476447016,\n                2423314465,\n                988904489,\n                3076842837,\n                370106892,\n                2669774090,\n                81048948,\n                2207992586,\n                u32::MAX,\n                2794855737,\n                2919419242,\n                2509602689,\n                685991398,\n                3934508174,\n                2079332445,\n                1950605148,\n                10,\n            ],\n        );\n        // - n_1 != carry second time\n        // - flag && n_1 < carry second time\n        test(\n            &[10; 10],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xff000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294836224,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967264,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3833725436,\n            ],\n            true,\n            &[\n                u32::MAX - 1,\n                150659924,\n                1536731131,\n                3027101341,\n                827397342,\n                835599031,\n                2855838328,\n                1016945560,\n                516734631,\n                10,\n            ],\n        );\n        // - !(flag && n_1 < carry) first time\n        test(\n            &[0; 3],\n            &[\n                0xffff0000,\n                2047,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294965248,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                8191,\n            ],\n            &[\n                0xffff0000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xff000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                255,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4227858432,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[u32::MAX, u32::MAX, 8191],\n        );\n        // - q_len == 0 first time\n        test(\n            &[0],\n            &[0, 0, 0x80000000],\n            &[0, 0x80000000, 0x80000000],\n            false,\n            &[0],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - !limbs_sub_limb_in_place(ns_hi, limbs_sub_mul_limb_same_length_in_place_left(ns_lo, qs,\n        //   ds[i])) fourth time\n        test(\n            &[10],\n            &[0, 0, 1, 1],\n            &[0, 1, 0x8000000000000000],\n            false,\n            &[2],\n        );\n        // - n_1 == d_1 && ns[d_len_s_m_1] == d_2\n        // - !(flag && n_1 < carry) second time\n        test(\n            &[10; 518],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            true,\n            &[\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n        );\n        test(\n            &[10; 3],\n            &[\n                0x20000000,\n                4503599090491408,\n                31664835368329200,\n                18410716373991817215,\n                18157950747604419646,\n                2301339547025015295,\n            ],\n            &[18446744073172680704, 18442240474082189295, 18410716376202215423],\n            false,\n            &[u64::MAX, 0, 2305843009213431808],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_fail_1() {\n    let ds = &[3, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook(&mut [10], &mut [1, 2, 3], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_fail_2() {\n    let ds = &[3, 4, 5, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook(&mut [10], &mut [1, 2, 3], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_fail_3() {\n    let ds = &[3, 4, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook(&mut [10], &mut [1, 2, 3, 4, 5], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_fail_4() {\n    let ds = &[3, 4, 5];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook(&mut [10], &mut [1, 2, 3], ds, d_inv);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_divide_and_conquer() {\n    let test = |qs_in: &[Limb], ns: &[Limb], ds: &[Limb], q_highest, qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n        assert_eq!(\n            limbs_div_divide_and_conquer(&mut qs, ns, ds, d_inv),\n            q_highest\n        );\n        assert_eq!(qs, qs_out);\n        verify_limbs_div(qs_in, ns, ds, q_highest, &qs);\n    };\n    {\n        // - *scratch_2_head != 0\n        test(\n            &[10; 4],\n            &[1, 2, 3, 4, 5, 6, 7, 8, 9],\n            &[3, 4, 5, 6, 7, 0x80000000],\n            false,\n            &[4294967057, 15, 18, 10],\n        );\n        // - *scratch_2_head == 0\n        // - !(highest_q && limbs_slice_add_same_length_in_place_left(&mut scratch_init[q_len..],\n        //   ds) || limbs_cmp_same_length(scratch_init, ns) == Greater)\n        test(\n            &[10; 3],\n            &[0; 9],\n            &[0, 0, 0, 0, 0, 0x80000000],\n            false,\n            &[0, 0, 0],\n        );\n        test(\n            &[10; 3],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 1],\n            &[0, 0, 0, 0, 0, 0x80000000],\n            false,\n            &[0, 0, 2],\n        );\n        // - highest_q && limbs_slice_add_same_length_in_place_left(&mut scratch_init[q_len..], ds)\n        //   || limbs_cmp_same_length(scratch_init, ns) == Greater\n        test(\n            &[10; 3],\n            &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n            &[0, 0, 0, 1, 0, 0, 0, 0x80000000],\n            false,\n            &[1, 0, 0],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_fail_1() {\n    let ds = &[3, 4, 5, 6, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer(&mut [10; 4], &[1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_fail_2() {\n    let ds = &[3, 4, 5, 6, 7, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer(&mut [10; 4], &[1, 2, 3, 4, 5, 6, 7, 8], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_fail_3() {\n    let ds = &[3, 4, 5, 6, 7, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer(&mut [10, 10], &[1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_fail_4() {\n    let ds = &[3, 4, 5, 6, 7, 8];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer(&mut [10; 4], &[1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\nfn verify_limbs_div_approx(\n    qs_in: &[Limb],\n    ns_in: &[Limb],\n    ds: &[Limb],\n    q_highest: bool,\n    qs_out: &[Limb],\n) {\n    let n = Natural::from_limbs_asc(ns_in);\n    let d = Natural::from_limbs_asc(ds);\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let base_q_len = ns_in.len() - ds.len();\n    let mut qs = qs_out[..base_q_len].to_vec();\n    if q_highest {\n        qs.push(1);\n    }\n    let q = Natural::from_owned_limbs_asc(qs);\n    let q_is_one_too_large = q != expected_q;\n    if q_is_one_too_large {\n        assert_eq!(q, expected_q + Natural::ONE);\n        assert_eq!((q - Natural::ONE) * &d + expected_r, n);\n    } else {\n        assert_eq!(q * &d + expected_r, n);\n    }\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n}\n\n#[test]\nfn test_limbs_div_barrett() {\n    let test = |qs_in: &[Limb], ns: &[Limb], ds: &[Limb], q_highest, qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n        assert_eq!(limbs_div_barrett(&mut qs, ns, ds, &mut scratch), q_highest);\n        assert_eq!(qs, qs_out);\n        verify_limbs_div(qs_in, ns, ds, q_highest, &qs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - q_len < d_len\n        // - ghost_limb\n        // - *scratch_2_head <= 6\n        // - !highest_q third time\n        // - !(highest_q && limbs_slice_add_same_length_in_place_left(&mut rs[q_len..], ds) ||\n        //   limbs_cmp_same_length(&mut rs, ns) == Greater)\n        test(&[10; 3], &[1, 2, 3], &[0, 0x80000000], false, &[6, 10, 10]);\n        test(&[10; 3], &[1, 2, 3], &[3, 0x80000000], false, &[6, 10, 10]);\n        // - q_len >= d_len\n        // - !highest_q first time\n        // - !_limbs_div_barrett_approx(&mut scratch_2, &mut rs, ds, scratch)\n        // - *scratch_2_head > 4\n        test(\n            &[10; 3],\n            &[1, 2, 3, 4],\n            &[0, 0x80000000],\n            false,\n            &[6, 8, 10],\n        );\n        test(\n            &[10; 3],\n            &[1, 2, 3, 4],\n            &[3, 0x80000000],\n            false,\n            &[5, 8, 10],\n        );\n        // - *scratch_2_head > 6\n        test(&[10; 3], &[0, 0, 1], &[0, 0x80000001], false, &[1, 10, 10]);\n        // - !ghost_limb\n        test(\n            &[10; 3],\n            &[0, 0, 0, 0],\n            &[0, 0, 0x80000000],\n            false,\n            &[0, 10, 10],\n        );\n        // - highest_q && limbs_slice_add_same_length_in_place_left(&mut rs[q_len..], ds) ||\n        //   limbs_cmp_same_length(&mut rs, ns) == Greater\n        // - !limbs_sub_limb_to_out(qs, &tp[1..q_len + 1], 1) second time\n        test(&[10; 3], &[0, 0, 1], &[1, 0x80000000], false, &[1, 10, 10]);\n        // - *scratch_2_head <= 4\n        // - !highest_q second time\n        // - !(highest_q && limbs_slice_add_same_length_in_place_left(&mut rs[q_len..d_len], ds) ||\n        //   limbs_cmp_same_length(&rs[..n_len], ns) == Greater)\n        test(\n            &[10; 3],\n            &[0, 0, 0, 0],\n            &[0, 0x80000000],\n            false,\n            &[0, 0, 10],\n        );\n        // - highest_q && limbs_slice_add_same_length_in_place_left(&mut rs[q_len..d_len], ds) ||\n        //   limbs_cmp_same_length(&rs[..n_len], ns) == Greater\n        // - !limbs_sub_limb_to_out(qs, &tp[1..q_len + 1], 1) first time\n        test(\n            &[10; 3],\n            &[0, 0, 1, 0],\n            &[1, 0x80000000],\n            false,\n            &[1, 0, 10],\n        );\n        // - highest_q first time\n        test(\n            &[10; 337],\n            &[\n                2119562458, 822658147, 3797927043, 3236945010, 3998585665, 1799547707, 694717600,\n                81695911, 596552600, 1030767834, 2420116557, 2879241862, 4265568378, 644932084,\n                525117944, 1830433723, 3385005819, 1023897437, 3938627008, 3218345466, 471356423,\n                1008605584, 192751188, 2084112099, 2804133613, 3079231960, 3746102582, 3887941757,\n                2403297368, 3093735039, 2439864684, 2473555841, 2532233722, 2609655906, 3449112520,\n                2817574574, 1129609143, 821518979, 991339292, 2760112178, 890698714, 990807460,\n                2521797827, 3797612523, 1500537907, 3973412117, 2699035435, 2317986252, 2861160946,\n                2101011897, 1732640676, 3352339942, 3286471253, 1371519955, 1379608062, 2699834414,\n                3261360638, 226259522, 1897478770, 2788528264, 2309134747, 4024965405, 3976506219,\n                1035727997, 3131955545, 3667438412, 384232858, 2419576220, 793788636, 334784748,\n                3765760253, 1098631674, 1499085537, 2112219622, 1421552393, 1432628811, 643517209,\n                3632058889, 1632079643, 2223695587, 1476932543, 1960156116, 3436427017, 2201635037,\n                3182693886, 1548942116, 3157649082, 980646399, 831953531, 2763454966, 3961226196,\n                3582012549, 3882861773, 3003921500, 1404369615, 4000431109, 969558169, 660750652,\n                4122382799, 2357249946, 3678033512, 1327191217, 2116553842, 22168676, 1216607516,\n                2222670817, 4212062746, 3066154963, 4179712741, 406795945, 2599414815, 3647640166,\n                4071465241, 883313541, 1105574450, 866562291, 372730105, 970111908, 749995626,\n                1253456197, 2374658843, 3555086224, 3636919504, 488985805, 2204950393, 1262942086,\n                3204402881, 4275635994, 2310416697, 4135349793, 1226698657, 1188086923, 3222723934,\n                1042266586, 4047620517, 3948968819, 4123810886, 1610456917, 556933362, 4197028761,\n                59668868, 2993790244, 854419727, 933448524, 897309660, 3037260848, 1562257062,\n                4083457628, 981822256, 295330752, 3711901403, 1052560139, 3617703336, 262191843,\n                1142114318, 3848091155, 2086394563, 469188180, 3855914481, 154128290, 2738524940,\n                1460255288, 1285831461, 534017408, 3101261674, 118239159, 1944080872, 4203935546,\n                2653496603, 3202103001, 4264655348, 3809947358, 331166910, 4277075817, 1031408102,\n                866321189, 356095977, 1058770275, 3617580770, 2573338110, 1315597113, 1752964646,\n                2179362239, 2449996072, 1745253117, 85067425, 347176893, 240744367, 123940072,\n                3568364276, 1405760257, 2210945376, 2261469245, 2772215200, 746282058, 568635214,\n                1171903297, 1744293446, 1789334502, 1459265780, 2293069614, 319891368, 1979148180,\n                627405437, 1184813190, 3346831763, 1106015952, 940476403, 1182911489, 1469568725,\n                2364938114, 1157432499, 2372887700, 1043172544, 2250011461, 2085295087, 604304964,\n                340825308, 2422766482, 2410385883, 791761071, 2733359762, 1681282344, 1354240087,\n                1139722734, 1143256298, 2677141676, 664248460, 1670722978, 3073187653, 4102786625,\n                2618886769, 2531436405, 3579964409, 3950031759, 2248680433, 984112565, 3136159147,\n                3101912984, 1099692243, 2145841930, 1116532125, 4172191260, 1659871196, 1924994861,\n                3162922129, 2658827997, 1059354695, 486907692, 3395508395, 295826664, 2173667478,\n                3774792204, 1393285442, 1481797518, 3124974926, 3444355559, 76091140, 368283108,\n                4144769582, 1548649424, 2500545816, 2934156349, 324366676, 3648212298, 4072218004,\n                2165091138, 1096979546, 1763071718, 1899235026, 803276905, 1146994263, 2575402634,\n                2199211565, 757588391, 2673498553, 81023164, 439773287, 3406088797, 2333068608,\n                4043446581, 360179846, 2767375326, 69621430, 1199860390, 2642727874, 2693185292,\n                3218919242, 2999720961, 1196125438, 1368472471, 992806312, 3414591657, 1991386017,\n                1806201055, 3597622657, 998040031, 901561537, 3420061213, 1598740651, 3883097859,\n                2560593523, 2144383095, 2844056757, 689661366, 4046234614, 792024425, 2086938139,\n                1867234422, 1449908164, 4144743168, 1158803667, 2979094734, 1636380917, 2507967837,\n                1146823800, 4089295245, 3701313701, 3893526214, 1323911033, 3620380011, 3952758387,\n                3265334125, 2820495010, 2855022691, 1720959672, 825537074, 1695132633, 4264601047,\n                3483737293, 3618271080, 2259345874, 806986786, 3597560543, 3609564742, 3752395175,\n                1910432839, 2910423130, 2748643710, 2345098346, 3595323045, 1619954943, 4250836093,\n                2316914206, 3801483715, 3657868704,\n            ],\n            &[\n                3231068322, 2952358964, 2649323214, 3829109446, 3277451762, 1929830117, 128637820,\n                2648688236, 3506019657,\n            ],\n            true,\n            &[\n                1863226650, 1957700928, 2397867988, 3361691958, 4165763036, 2541448103, 3330236317,\n                390820454, 3199800095, 1741385769, 489727642, 3156882136, 3364833247, 2137995472,\n                49695877, 3008476841, 2862420416, 3492919918, 3413332847, 336822005, 1172092721,\n                3834063622, 387233639, 4033191572, 825059607, 1739762995, 2020314499, 3839219267,\n                693092469, 33950982, 1177221008, 3244207164, 2680526838, 4242912184, 2481840017,\n                3724363464, 1448349630, 2835676977, 2435088559, 2020244573, 2206043073, 1215858002,\n                3357751071, 3401291562, 3486448975, 1614914078, 3741841610, 3754003433, 545275396,\n                696866963, 2296823190, 2173589284, 3887309169, 2170555018, 2354335949, 1942858008,\n                2275759948, 238261999, 3409767723, 4050603972, 3841360830, 479906857, 3816482700,\n                3132890483, 1442647186, 2664711624, 3255895001, 2304652118, 490441941, 1384930190,\n                3781000441, 1197124175, 3673914796, 3264625683, 2934430644, 4012652010, 645313445,\n                1342417027, 4259899126, 127557767, 1863840635, 4240034833, 3380128902, 1721040466,\n                258484486, 2943320471, 4080044726, 1184529896, 50392490, 99485071, 2656469171,\n                394602583, 3236432821, 829680970, 4180640632, 216345893, 794871810, 776950374,\n                188852287, 2768051863, 1478264409, 3116222344, 2035264630, 3540143745, 3312627463,\n                1243839690, 4283661964, 2255627632, 2493155473, 3422881207, 672998229, 1330645402,\n                805858947, 3157155303, 2449760637, 541100830, 3959355989, 2578797546, 1805505456,\n                1105314669, 4044058628, 3236890928, 2881753558, 2935150784, 3619155497, 1247576722,\n                1057473446, 2602148123, 2591947096, 3098219463, 203480759, 3190196698, 1560456418,\n                1737612953, 1525519966, 1833713546, 2974486003, 3554849856, 1570515568, 3538788251,\n                3534319124, 3133957142, 2947537950, 1328568927, 2472554746, 3121690099, 3058658055,\n                2512921696, 4268236616, 507933028, 1384977378, 2914276309, 2170658818, 2676773599,\n                1344588011, 1406282402, 4240165134, 1774763910, 3592097532, 323634811, 4493032,\n                2026844160, 4259889667, 1561456992, 1745963453, 3318810240, 2613669069, 3295340381,\n                3322882413, 1172726818, 2542871057, 889925562, 2512140586, 1002695611, 3804029809,\n                510918143, 2428502323, 1435737298, 2312478558, 800761403, 822185524, 2215463403,\n                2284293602, 1855687935, 3929793519, 3135842877, 397151223, 819010071, 3143846345,\n                616813752, 2964423320, 2479441994, 2399498982, 3731231486, 1268178985, 637959829,\n                1437260196, 1762640607, 2763892037, 3152346415, 130897174, 150170711, 3043757213,\n                3263747790, 2268840104, 3897286925, 539186347, 2052996062, 427292218, 4071153750,\n                2387542695, 1403176825, 3054171069, 612471588, 1215312135, 1616958897, 1846418285,\n                1376844475, 1228696609, 534770698, 3860539144, 3746082038, 3223899771, 2595640187,\n                243793487, 698835349, 2226712063, 4113186925, 2899418198, 1544475879, 1323263527,\n                3387040179, 3921953055, 1816962743, 3835265005, 512922592, 4131079192, 3966796549,\n                586497526, 3324562547, 4163601002, 2280208374, 1649440850, 2888163653, 1932515002,\n                2915989787, 1835707588, 661236253, 1521623480, 1468090177, 62176243, 1761654778,\n                654002630, 3078945097, 2118465419, 622606572, 1872263161, 371147127, 2407796135,\n                1691024627, 1530874911, 2999266525, 3959644478, 2593752318, 673127524, 2516817005,\n                1435234490, 2950535738, 3814456529, 2728341971, 1618690437, 2649703585, 1797683058,\n                2532611783, 3170196918, 1687541847, 3276477161, 3728293877, 1601226381, 2623169918,\n                4277737387, 972038484, 3652503133, 1692819095, 4166924696, 679045210, 2147824742,\n                1754890006, 3603422769, 760272390, 2805004613, 1482946566, 2730421710, 638284193,\n                1248071107, 1757322486, 2253794113, 446496343, 3072090920, 2265361578, 1244157949,\n                703538048, 36778122, 2938030723, 4284977264, 1670946207, 3674544567, 3705855800,\n                1533888849, 2783879966, 1509595576, 2692068678, 4286514245, 931483302, 2846849819,\n                3750140783, 1937245748, 1537653123, 482103265, 2110925496, 3832643610, 1721135933,\n                1078480349, 2178800517, 768852883, 1630173117, 854612116, 4050668505, 3460165548,\n                3293238206, 4141790935, 764767464, 3763613607, 3433771841, 2639622, 654168294,\n                186019120,\n            ],\n        );\n        // - highest_q third time\n        test(\n            &[10; 37],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3ffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966784,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4261412864,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967168,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294934528,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffff0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3621246934,\n            ],\n            true,\n            &[\n                2097542169, 2497074010, 3595786574, 3396020653, 699180723, 799063684, 1,\n                2097542169, 2497074010, 3595786574, 3396020653, 699180723, 799063684, 1,\n                2097542169, 2497074010, 3595786574, 3396020653, 699180723, 799063684, 1,\n                2097542169, 2497074010, 3595786574, 3396020653, 699180723, 799063684, 1,\n                2097542169, 2497074010, 3595786574, 3396020653, 699180723, 799063684, 10, 10, 10,\n            ],\n        );\n        // - limbs_sub_greater_to_out 2 in limbs_div_barrett\n        test(\n            &[10; 69],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                127,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967288,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                8191,\n                0,\n                4294966272,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                15,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                268435455,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4261412864,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n        );\n        // - !limbs_div_barrett_approx\n        test(\n            &[10; 8],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[0, 0, 0, 0, 0, 0, 0, 2147483648],\n            true,\n            &[u32::MAX, u32::MAX, u32::MAX, u32::MAX, u32::MAX, u32::MAX, u32::MAX, u32::MAX],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[10; 3],\n            &[0, 0, 1],\n            &[0, 0x8000000000000001],\n            false,\n            &[1, 10, 10],\n        );\n        test(\n            &[10; 1201],\n            &[\n                18295077001300582982,\n                11318972173113518719,\n                9127519662193085094,\n                11186232593046463828,\n                9967574749124910412,\n                9534668194866541873,\n                17538998692236597692,\n                8856351994537314708,\n                15915919282507021309,\n                4395337101052053871,\n                4573109461445904651,\n                7471333999959771232,\n                15168214583465292846,\n                10112694665499997517,\n                7468171880957946669,\n                6921645588354592946,\n                13601816639536924709,\n                15354213944627759328,\n                2741837546898925109,\n                2808068836502997863,\n                11740258706413798883,\n                12018890889885101893,\n                14950676973818139848,\n                11571325165054093751,\n                15673140488076698056,\n                111792651078725003,\n                8462112369261970769,\n                3506632968581684254,\n                14492060158927869608,\n                9683679100633315103,\n                8518299955708236612,\n                4652093220482746517,\n                7043533562034634565,\n                12167203625017475462,\n                7117384414390535484,\n                3466429710589950813,\n                17042769017553443224,\n                9042817094280175152,\n                16844111334058787904,\n                3229027329268312555,\n                13434137902318146452,\n                10307081978533698950,\n                16225670675216025408,\n                2520628227212852899,\n                18240849581864299900,\n                1488578585703911609,\n                12729292459179553524,\n                10245967895896970359,\n                13339552018102535488,\n                3997937496978780356,\n                7658709074265624500,\n                1435708185782215934,\n                6431277357886612239,\n                3790371881169902395,\n                6784416241349450757,\n                17724596047816212568,\n                11815611058096852874,\n                18130171813954955659,\n                1024780128434872289,\n                17963095905370618004,\n                122805984702922462,\n                4151944930379965325,\n                17442615003616391312,\n                4994655809588385430,\n                3040428539445301559,\n                17832402824141992191,\n                10165853977855724270,\n                2335376537564192245,\n                16821936144912130606,\n                1159886974868740222,\n                12541069017485894294,\n                7837219358605440583,\n                16446400756537961003,\n                126465459086606815,\n                2083531762113796389,\n                8624382957529422405,\n                11784929789278735279,\n                11213379749377196194,\n                560319428396345164,\n                15149217973310924334,\n                15463814793141030032,\n                198092507050200273,\n                8610639264260168818,\n                261903620794761859,\n                11988086720959071107,\n                17592070826426022758,\n                3768394046587852857,\n                17166555261248835248,\n                14963038520790234947,\n                2241578438524899796,\n                12189060128627683066,\n                2262926845306353696,\n                13779828760616581286,\n                2541235484167862316,\n                12643925053624024515,\n                17496648690832865541,\n                3985970119983125736,\n                3095952870801231592,\n                11840830080834210856,\n                1592987240002085723,\n                10982564110995200636,\n                4643989547154306181,\n                10428500092848201987,\n                6198871498072261125,\n                7023308239893005307,\n                1842762842799324585,\n                14071338712339983613,\n                226982182212975753,\n                10132117640523152816,\n                13755737565472281731,\n                11632719781566051232,\n                15601465236759733965,\n                7426599477609205946,\n                4611356292343480284,\n                8631478323050143434,\n                11591955075248152245,\n                14677238670216581539,\n                8164238761098476942,\n                13987621157141456718,\n                3767319467475575547,\n                12012052271989395919,\n                8337005502962563778,\n                1906268936538377685,\n                3174524835537599456,\n                429665364769606677,\n                4394657478224842134,\n                13121187501762162553,\n                14381551623920212050,\n                8629282374304273880,\n                13263190906733112908,\n                5218608522481599043,\n                12107632235830044399,\n                17543485324435588445,\n                5588590375237119557,\n                653390775866146799,\n                17771172514225072483,\n                7528918736871248090,\n                282399778929005580,\n                2605980929215962661,\n                12146324033914854229,\n                11592565716384131105,\n                18151666657326444699,\n                4388203927026263831,\n                7341614458621896439,\n                8894653933329611005,\n                13805725287465815477,\n                1961833582231565395,\n                7660480270814575592,\n                7471493328104234933,\n                15044319201246839910,\n                4576661672063304734,\n                13536449736957685091,\n                11860387989360659066,\n                14764867249962166936,\n                13360409447124464240,\n                14221155626952092001,\n                17398349115650451905,\n                3184465599333245836,\n                15707751954179380044,\n                12562479861627119924,\n                88057213942976,\n                1597598702141447884,\n                1261772823635792000,\n                15958552215247247021,\n                12793055150726238784,\n                11200918639832307722,\n                5597941261295916139,\n                4315031833738259815,\n                6902838082588292746,\n                12728989104884069511,\n                16918323087316778932,\n                13511521151542209585,\n                553843237172766561,\n                5043573603672626571,\n                17723320900855236842,\n                9608995393314215645,\n                3240943499004890750,\n                2656790654801382241,\n                1676457890700011962,\n                1762227695284006379,\n                7552785576552937293,\n                12811313200785996585,\n                9898873674914761859,\n                17367249174383145486,\n                6558113706220556681,\n                13049161836673606453,\n                518571717053573108,\n                15162122533925516408,\n                11258823008709425295,\n                2435504881057972054,\n                14963790284869753122,\n                17872120991620222840,\n                829886456078946400,\n                3111042046099960191,\n                12008856441265505258,\n                2885441178087651466,\n                13689155834809427488,\n                1131420088641124682,\n                4614200008200617537,\n                6047126292996169487,\n                10306766196213210408,\n                15363972403137500863,\n                4835120368572137311,\n                6423191714064598283,\n                13652834984059479335,\n                16393177507860580647,\n                235892475830229813,\n                6409760052867575115,\n                1550734354829621988,\n                13575662851619075640,\n                718363601454148431,\n                7618105344726885101,\n                13870052170163128170,\n                17099086237059090191,\n                9396086948840999204,\n                2193052566012551739,\n                10987190533735767295,\n                15342771743918665873,\n                1551527591660837277,\n                2481113648650332471,\n                12526575541699553066,\n                17267384064568181119,\n                17289295549595612856,\n                2664460126537239716,\n                6877918636888277820,\n                16082383248389501517,\n                14351409001844089162,\n                8263128092015238423,\n                17346851708062879652,\n                311521651703256488,\n                3981059575604853696,\n                6313669348188551640,\n                18099378411031449694,\n                15968996741727654128,\n                9159799405918354972,\n                9462164989236485935,\n                3684393721233135450,\n                17937865489600192328,\n                1638517822102130933,\n                17395422161525252689,\n                3473709908567621234,\n                9193281964841491478,\n                10331967326496158302,\n                16798696233976578557,\n                7807831077297910192,\n                12652762876222409301,\n                4869797982244064640,\n                17701222287597080443,\n                14198439585207683091,\n                15865499320981581597,\n                10334047464234401983,\n                3015211655799314399,\n                2424108494719176484,\n                5856301803897821467,\n                6554732345079263181,\n                15122890791522644819,\n                10545203438810108056,\n                9012473640708669972,\n                1610970557833154315,\n                16035943676789150718,\n                2896323099257548494,\n                15155422639005018579,\n                2259843538120092351,\n                10245098502137432793,\n                2520646283097234470,\n                18012393436345512168,\n                7561203372316264305,\n                7653799543413918665,\n                2140030530743770178,\n                9857665885574564324,\n                7489977190124210547,\n                9998927813057387755,\n                2762046115540595154,\n                13701876953526406973,\n                9166149367362906555,\n                15040003763080700518,\n                15420365130894777610,\n                2514077990148227892,\n                8504504167644069065,\n                17726177341910187592,\n                2449744483621879771,\n                1723730756025983988,\n                14406403103456534844,\n                1454650873709405887,\n                18385141654478933772,\n                5577491305370650404,\n                4566210906549652321,\n                12646617965385778707,\n                2552078226205003325,\n                12355063666203300427,\n                12178902896368926706,\n                15006718947903716117,\n                16372728326443816683,\n                10180279671730724459,\n                17731483716821982507,\n                17200000119948045535,\n                16335525811156407438,\n                6875979274642807833,\n                15168986439371917908,\n                15864186564710033224,\n                8479084522424050164,\n                15994651879769538679,\n                17760497144399786164,\n                18426614975808400224,\n                14704575934872194992,\n                15181888226941380306,\n                11721908889511702187,\n                102617178928138881,\n                7447495721105104237,\n                7954810306378822535,\n                16998786374321127605,\n                8090790070484230870,\n                16289196329372215488,\n                7526820476636601578,\n                12572297496289928774,\n                113628864092045691,\n                6250550022217214406,\n                4360142915129731393,\n                6501796933114606792,\n                11802403139188476967,\n                3519002220471562974,\n                12904839411442007974,\n                17836996140509983390,\n                10274485582719436243,\n                1702862600039034598,\n                14513867867040307158,\n                7487625572871740440,\n                547811069452644988,\n                14936715197880499253,\n                13562114970675542784,\n                17390100354796730187,\n                2650648508100345126,\n                2284358746933974591,\n                15679445219134526756,\n                10812943946121458631,\n                3086162675176072976,\n                18390684768949838073,\n                6075230822143172142,\n                6982548968812756053,\n                10592236207809317452,\n                4646507818793863055,\n                12915347565287279717,\n                13659140852008443728,\n                3573929783088736212,\n                8525440095045701760,\n                744607937041376677,\n                14783015896444558651,\n                15131086952103884713,\n                5411002486960761278,\n                2088437290856887643,\n                17144271151733343032,\n                13301554666552663294,\n                7896467561063988444,\n                18211131252066266807,\n                18314706540585938015,\n                10366120178981009524,\n                17459923192069900601,\n                4447456409081943565,\n                18283667669702090783,\n                9450771365947353345,\n                4378436544916016463,\n                18212457741993594328,\n                15198669923619110391,\n                1879444567544117559,\n                13563147379710886746,\n                7674325133378880705,\n                3334816774600195478,\n                17381122289894552650,\n                8606404348019304750,\n                11293315989134833536,\n                9316500947082049857,\n                1266335121593205314,\n                13354728313128860089,\n                16404400110998945357,\n                12189461827482124995,\n                8571799438986557328,\n                16924412540155584500,\n                4066705394775144307,\n                8244708734889461660,\n                8298262041269740098,\n                8485079550935558613,\n                10390420936585250554,\n                8032986327114538781,\n                16386580215630153737,\n                1596782152296894307,\n                11436174552386854673,\n                12281350017506362626,\n                1201023713565731644,\n                11354800184560792809,\n                6244435089778753535,\n                14781899671263994812,\n                13453856532164887543,\n                5205173379729650294,\n                6758121452061198317,\n                15199577981158799457,\n                5097188591555664044,\n                17892257447678225776,\n                13090788927117929247,\n                14729055239625004209,\n                4325309995714780542,\n                13696424036200737757,\n                1273472536475971315,\n                2493602685304131114,\n                14343892393575517386,\n                17316017497393506890,\n                7414572135952091508,\n                14030461927641410000,\n                5832918032885817891,\n                5502576889680878828,\n                6923748617342471812,\n                871116026416752255,\n                10966491112110866938,\n                2678875367438552346,\n                880767707416234664,\n                13418969124074860064,\n                14901114133194346006,\n                13532936137684711970,\n                13210870719065554599,\n                5680454822125667478,\n                18160829213663155836,\n                371611573974742026,\n                5989253166049701849,\n                14180420379914515920,\n                15377609392846358665,\n                4353627738587754452,\n                3173054206132556029,\n                7895498175890703618,\n                3080756330636658459,\n                3760068566220710837,\n                6677805614130848551,\n                15143994173468972043,\n                2776883010742953966,\n                7672039583834722626,\n                14012333824083176377,\n                7996303528193834674,\n                11897965609914054208,\n                5088662930442171136,\n                9775050840076636067,\n                155290985412698044,\n                7446050331902513644,\n                3182373073764824464,\n                6333622418059827492,\n                3381171406223616986,\n                6279035658057293263,\n                12457015290254566192,\n                9997746010079880598,\n                6365931066892340107,\n                985007383843617635,\n                17683099066034169719,\n                11690122858292360173,\n                12820337681274901203,\n                10119776165009632402,\n                8025360517304244421,\n                5799209647953164975,\n                11923243886776383739,\n                4434382877035266302,\n                6892316876790904772,\n                13311686201719400688,\n                13070055340969362249,\n                1389161348064595575,\n                17317825074198166229,\n                12352407812302110965,\n                4357096373749880928,\n                15322947805519342504,\n                3393459926528754710,\n                309259942348373780,\n                15221863408129710293,\n                2184432377148992552,\n                5599867762682684625,\n                11692237690560353533,\n                15617277716526144374,\n                16352998506828635464,\n                10683295287531537932,\n                10174768335502056341,\n                9757436149722611038,\n                2152351494881547919,\n                3149777722784977852,\n                8102543602996006449,\n                11216609622075916890,\n                3579652612346447740,\n                16460137215641926135,\n                11507203873319504418,\n                16154205860053489440,\n                2632057472745483271,\n                17753479868310580515,\n                14766406055562904631,\n                8264678782999986871,\n                17190366735089617123,\n                14132490063308838582,\n                5611885333274300040,\n                7809615541777044817,\n                500715652367171775,\n                9987493264173996320,\n                841374560193562207,\n                6977580041132397357,\n                15755392832835879990,\n                2396663158056304844,\n                6954661831316013111,\n                17813876156953598887,\n                8398019579977679371,\n                15855357483987489279,\n                3812760582326753081,\n                17273631953943528844,\n                9938856188329661065,\n                15819226062126522823,\n                15903684874086185036,\n                17013855101741324873,\n                16945130082273335779,\n                12554320244359036189,\n                13649309719081627643,\n                8623047233379225403,\n                4386984048641888911,\n                10553868952837364802,\n                2287715920316141389,\n                5449632814028619034,\n                14866255022956570263,\n                11741122206403462638,\n                16053480635563219127,\n                5950910649550286503,\n                15674410143609173241,\n                18052239445521828504,\n                17771738773780736596,\n                7982624156303669042,\n                3523750006668789187,\n                11709430973580071492,\n                2896965446277645340,\n                8080432872087262526,\n                6780281993621524078,\n                684058261883760969,\n                15989257244423388836,\n                11589699367052272611,\n                10104208263881413964,\n                17189453506869451477,\n                13916361665060626203,\n                2853202431249762367,\n                17209296028258297770,\n                8683507465402308661,\n                9645802663683152169,\n                10358479223375842731,\n                7829663615722911275,\n                16814895244990924256,\n                9450557997282764467,\n                975077777946948005,\n                9552034374331587062,\n                16463119689405074774,\n                17510823549036664049,\n                2497156003024501849,\n                8569401863532688038,\n                10049279418614386291,\n                3587742668108530158,\n                6893073803871002466,\n                8435788430991711447,\n                6027317537544203617,\n                7287819136806388073,\n                8022714784833611325,\n                7097275444704143170,\n                9012025202589703553,\n                9157332853571289532,\n                1993744974767457280,\n                1465502656822405877,\n                9131312205000720858,\n                10325876690137477079,\n                6169134302635077705,\n                8374996558291634468,\n                560822697555683025,\n                1908237605140107852,\n                3071760787762132773,\n                5175055607701420190,\n                16301592270910662010,\n                13309210291635015714,\n                17042047666169332328,\n                9526937776970478108,\n                12098704706218455302,\n                13970362276996674357,\n                6796229436389522906,\n                15062885882848544518,\n                16920623441880575261,\n                14229647915216500624,\n                8741798560844117715,\n                4980134414764225717,\n                11277891936160048605,\n                8669128257761758831,\n                11639866248680237811,\n                14320586036388102785,\n                8445229725159674642,\n                3733656198588769556,\n                2734841737258647101,\n                3180524601127048731,\n                2450617332784964412,\n                11426278631729088077,\n                6103545629653703721,\n                16596235424879528709,\n                3083400506423704996,\n                3326973352265933113,\n                8829291997519615573,\n                10934832120864112438,\n                2237208881368262020,\n                5487788679486358745,\n                6433752820775880003,\n                17592485008402930155,\n                897116185036299103,\n                4177675527876951143,\n                8991005262989032861,\n                12499756317966457681,\n                8950539096741137700,\n                2847881219307650887,\n                15077888665364050191,\n                18223594192550309314,\n                13486903824928920160,\n                388063271439952358,\n                10319980883121211184,\n                7635019531196725850,\n                2427615724424514210,\n                7729266079341799689,\n                6404444267730632702,\n                5433617192107305037,\n                4076855819327886411,\n                13570092861836669774,\n                17637230595629666135,\n                3763591644356069904,\n                16581684393851086944,\n                12542913026947120792,\n                900710323095653438,\n                10736895612395941051,\n                2621023630214846484,\n                7378502763289664634,\n                13474732295031584723,\n                3104494731822189089,\n                8271151412175201324,\n                12279765059279079874,\n                6577258368503226128,\n                6763279491725722121,\n                11416038652636887266,\n                13192060800396327604,\n                16237708051063768614,\n                7089146474910269889,\n                15563073315367269087,\n                3957364145608674590,\n                5323058129820270810,\n                4109735477541683587,\n                12355852476209988798,\n                15985687144714610011,\n                12621726154507263107,\n                14640375261881059191,\n                16363974953655857698,\n                4850702814848069062,\n                15272503445030894973,\n                16921342410168262313,\n                7428955369032396232,\n                14045654759586398366,\n                1824179654748832763,\n                13065290435644832773,\n                6620750261665502627,\n                3710427655103863956,\n                1481622391321253962,\n                15738776155042427147,\n                5393243462308065801,\n                2548893674570156490,\n                15446175308782730745,\n                13099052830471814150,\n                16025011191599670127,\n                2890048025568963952,\n                15911511151530752849,\n                13361640240769822063,\n                12104304782171432594,\n                961887753450176109,\n                15685615589765989640,\n                17189497989928671280,\n                2831942924382855480,\n                4480390308058866189,\n                15123214478066113546,\n                5319876220060588766,\n                7554565254690703099,\n                15333258353184365603,\n                11213391410117524311,\n                15593488040195587753,\n                593648809612765970,\n                12555350446961062819,\n                6229267335263745809,\n                14015166800911232090,\n                13026142996056874252,\n                18183116121398427318,\n                15181376709750626113,\n                1401960981421676957,\n                4293598990318865637,\n                530920581688032599,\n                6940659528892404741,\n                16442234548874017487,\n                11187943673940954369,\n                5477084646686373295,\n                6381208324537451874,\n                8061144699238466390,\n                8077766508626903071,\n                6753688433578836015,\n                15372709739771454415,\n                14767218468779016882,\n                1215884787035963826,\n                14382870766506391926,\n                2777669072491465441,\n                4979926579396211735,\n                1768278590436478191,\n                15494549597590347998,\n                13355843170158138770,\n                9534590495526626915,\n                11105540785007109613,\n                14720148350689650025,\n                6017193011436405301,\n                16984479834548076496,\n                16271637870678307585,\n                12326183850782128718,\n                6046566507616322174,\n                10855966808284447862,\n                14486143464576348956,\n                11338497252460063850,\n                5183772359646668332,\n                18243138296691918952,\n                13528809746451616015,\n                14990329438970768590,\n                5382414247629766136,\n                17839632985912233567,\n                6536591723065785846,\n                15159440725656239912,\n                13722780980393210799,\n                15379786009638462213,\n                13680360627088226980,\n                157894015409385528,\n                5177681992682638634,\n                17291176910176600814,\n                13010475027988538353,\n                1220715812992048990,\n                3158791389064101642,\n                17418153569888323944,\n                14192277962237157065,\n                13201221044060083557,\n                17197741701763036713,\n                1169866928588403159,\n                11475502076729221523,\n                17842351657425532858,\n                8719597950895866531,\n                13655118154496174216,\n                9324866581514290928,\n                6471362086641457443,\n                1120540713350762121,\n                17250869044224608119,\n                10278304262960546351,\n                830716653181086159,\n                528668968156165816,\n                17461167627153646098,\n                2954445364658355279,\n                4279374933577208791,\n                5125629313701256673,\n                13688234303349159556,\n                6162791048326647760,\n                4085886762736458043,\n                12797243781587979166,\n                4186645783941093387,\n                5286754311331113809,\n                12228267120751123127,\n                13244227501124911724,\n                5790695027871396694,\n                1179783746683833033,\n                547187269099730162,\n                3784522572642818792,\n                18032448183921975913,\n                12457662158631096805,\n                15315319400702151227,\n                17578423625750785029,\n                16343351208792817827,\n                12441408408284563210,\n                7954314853731713656,\n                2984276352836570732,\n                13395574438985641870,\n                2307482872375012455,\n                12980078936529177252,\n                10700284809642803759,\n                13865447514364266827,\n                18230467246784513159,\n                10014640149449599139,\n                5878477546561163101,\n                4136028674985152176,\n                13271285149376627150,\n                16149599021017368823,\n                12810144100834492972,\n                10361575929298677228,\n                2536873008009811981,\n                10725873242024230485,\n                6497018066462413733,\n                12672985826259352756,\n                12621580784482696405,\n                3208673605123299314,\n                12964686779683735787,\n                11198928388252299700,\n                9267110518317968851,\n                14949846318732066452,\n                9541744713692425692,\n                15941076237518505589,\n                3430239862814579319,\n                10612575443053695979,\n                13849997225041110710,\n                10812240591348788214,\n                6393517327149796800,\n                3773291149649696828,\n                11772973342821893348,\n                15336626839762886687,\n                9577966728657848673,\n                12885121901356197298,\n                17815545299295776530,\n                6220765473251078270,\n                2771097797711300301,\n                16970067356480780400,\n                1504708658327185321,\n                6907611344237613843,\n                4075093039543471236,\n                13083035552238343340,\n                14250200630765174185,\n                9672767310783428470,\n                11849400399424996986,\n                7035900738271398225,\n                16082635402379245761,\n                16050998072774064345,\n                12233157773887550741,\n                9123081242185639205,\n                10491848564263417153,\n                8146725764960278312,\n                15575340461645603858,\n                4148874142333973054,\n                2993956721277198006,\n                7451409165297669404,\n                11313922544892113187,\n                3194232630201899744,\n                636408375757237004,\n                13608592959958520180,\n                1602275071834536905,\n                17095805362986103383,\n                273804608848916383,\n                7791458085242420416,\n                4108672307826744184,\n                15366005913747176151,\n                1911777325643792089,\n                7650198163620616024,\n                5464577924945397455,\n                11373225807219821179,\n                11803062818149301122,\n                16590458695267155990,\n                5042461121399527303,\n                17546193017727636334,\n                6044754748618261501,\n                18027283631246224402,\n                5490643452609947204,\n                10676364643909038013,\n                11630248788877483715,\n                13656452259036871197,\n                10354144198163268775,\n                15527017933877727076,\n                7934356641322781866,\n                4029898516517466246,\n                18052926818605623623,\n                3540286841764757111,\n                4634551231653920631,\n                14122057670778455103,\n                6502701997202257971,\n                6891458055552018817,\n                15456790929915692095,\n                4755257324171297175,\n                16716123507389519228,\n                3651613652886160497,\n                726970425978162241,\n                1404697533390673853,\n                18337661318309196519,\n                11286275631912876508,\n                16956255978892411559,\n                7232996886210695519,\n                7015333597196144681,\n                2767625396637754039,\n                5012454424073998044,\n                4313194875364346824,\n                10862594252285252036,\n                1780047608637690763,\n                6465610838655107636,\n                14797199105868765000,\n                14892726918517585944,\n                12886955176299933454,\n                12555896806127357876,\n                1579402751470265132,\n                10039610188105182645,\n                13021770347030669513,\n                13884058132948290753,\n                6203460449771372271,\n                17680930315624648890,\n                1135636070221202481,\n                5887167508778361325,\n                6692888760348109187,\n                16471454437283076325,\n                6790413570336457138,\n                4747413456280934549,\n                12256524938413768175,\n                15683900003187016699,\n                7658943070244016799,\n                9373611225821015637,\n                3097782436024673554,\n                3715948327301456793,\n                16620556575387636951,\n                1144786186914086248,\n                2571220709130887133,\n                17221925829597224845,\n                14639715549529666265,\n                2377686026891085475,\n                6175736503910047094,\n                16254346102373555209,\n                2091619280012452304,\n                2977400894759148074,\n                16973091263321852037,\n                18362768537728015363,\n                1991299393262221799,\n                2234896163405550283,\n                18058593386109307972,\n                10550027282767151380,\n                16780239965370137213,\n                799009131584013840,\n                10449833190601914997,\n                5403901802819318335,\n                3399172224735334606,\n                2288410999716774322,\n                5500021116082973302,\n                4679603412526091068,\n                17393554539674064705,\n                9796061166459144993,\n                9467440242924277380,\n                11232005203975958356,\n                5489824429056622584,\n                16693157940463512280,\n                15406446911191459754,\n                4194365386979719807,\n                5203380675405663527,\n                4845608829713153827,\n                12287647978288669912,\n                15124365454705698450,\n                13535980942912919723,\n                8131237757227102165,\n                3174196792035455626,\n                5866637449648808112,\n                16572436768235757709,\n                4014543717417567164,\n                10648229607518736806,\n                11124454154979311706,\n                1769806716148969845,\n                487436280093944655,\n                8499791320565867237,\n                15961111617996045786,\n                5068322564632937925,\n                15412395235178437129,\n                11967627266106331118,\n                8045493101565796203,\n                13046639311331048399,\n                15060301207111006451,\n                14565561077561594206,\n                4358177937116176854,\n                11754827048597359847,\n                13428566207941409974,\n                4886280109612433539,\n                1622891182969078648,\n                5631762445567547687,\n                1001237725533401134,\n                1757759663273866730,\n                16057243644130790443,\n                1499729696211089292,\n                11828414361895128981,\n                14654309635396524180,\n                11291463832641202452,\n                14519357404633231926,\n                10577140847149996567,\n                3792719835563443387,\n                15142788729413823525,\n                9678889469185452465,\n                8297094875949379007,\n                15382627216272468711,\n                15925819828335300195,\n                14660243428068176769,\n                6234311288201569973,\n                3098696262152872404,\n                16414024924130435474,\n                7632710397177488243,\n                3027219954282024629,\n                13613605315723845518,\n                4728284780117539918,\n                1526596142713039913,\n                13362185372491310310,\n                3646060091216202899,\n                7134750524336139051,\n                10748226811567148106,\n                6061127651723295538,\n                1977080743741376721,\n                8247273669544854710,\n                11303352485877072729,\n                3212027501425168508,\n                3372242849830936750,\n                15122856257096582829,\n                3657320729410695570,\n                1079822070530945640,\n                3637761676173672044,\n                12937343848915788544,\n                14571852791540951516,\n                14342466430585531102,\n                11728929959200744262,\n                9616215636394561656,\n                11219596255947364400,\n                8537080980244641448,\n                5536712989388435927,\n                3631171822217372772,\n                17865529156187152852,\n                5037311271195656389,\n                16487502805572224194,\n                2147708277645688540,\n                5001570498819337775,\n                7470084541514784017,\n                17492697990745102157,\n                8070931416656058009,\n                6060950086595339669,\n                15013400715742283111,\n                2306746444225502304,\n                8409359804202256945,\n                164372999763571994,\n                17018131853777354259,\n                12208035939150177086,\n                15378350496540915492,\n                14788480835646558098,\n                10222082122641529550,\n                9826197618153251703,\n                11243600916118905460,\n                11580887407889731032,\n                1393539571585322510,\n                9935346143997187837,\n                7496342550492044399,\n                13651431762540088188,\n                18099050770585698965,\n                7529498299621559528,\n                15208919353243962747,\n                3726212045576545652,\n                4678887453978995265,\n                14257385919526698171,\n                12560466975991464998,\n                1916602273852958082,\n                1580725334554883931,\n                4225567785880728522,\n                11435782961353548865,\n                9711420123575671266,\n                12525556123102287402,\n                2646005433774867481,\n                13608235394975640398,\n                13551601168317309842,\n                16238098975271138187,\n                6304934077364865470,\n                9171945380172233284,\n                12494391509484808505,\n                8265808003325748972,\n                4965580429357067406,\n                2338192348119283399,\n                1178551921476923378,\n                17792386313089099560,\n                9283481247039557200,\n                18034555261167084807,\n                940432788242421418,\n                157287264000433134,\n                8930392502298325360,\n                14945125834809509178,\n                12014926331118784945,\n                16300522776195850517,\n                3339639261621971347,\n                11241360985958214479,\n                16436926344603140983,\n                10678188202681436261,\n                15790390608679380109,\n                3932414003149456454,\n                5930062229915467643,\n                4450937096561861235,\n                6454095283937419925,\n                9191309540370341069,\n                2369208882454404157,\n                12058336702238473519,\n                6689133296485718676,\n                10352121632476532849,\n                3457908119433474049,\n                8564209740315103396,\n                4484492680807237072,\n                6272029608511724469,\n                14111360500805747905,\n                3426639800371632037,\n                9193459114578112726,\n                7715081428105427735,\n                11741225476850793322,\n                5763876427542620399,\n                10485104516843146360,\n                13517901123362979253,\n                10971040515178626597,\n                10880433648809156464,\n                10463748994258517642,\n                6039895771661000246,\n                18291078422235189340,\n                13108581522989000527,\n                15970781344230536695,\n                14450809554308819328,\n                16634698737197679715,\n                10907837400337288081,\n                4981117528505172335,\n                6575031804504949146,\n                7418118826254061112,\n                5934085700009751031,\n                6506575199869110637,\n                6840822251681248761,\n                11392304369263274998,\n                5878363293290930458,\n                3935353596127878330,\n                13113298309412464813,\n                13481516285263684897,\n                9985427214718546766,\n                6516008243224711903,\n                7181072207395196982,\n                3447347579103428171,\n                7443665624167886719,\n                12843482800554270558,\n                1283805457628563062,\n                17578575987130403567,\n                8648960510881174810,\n                16654535114846652064,\n                16246000708166950031,\n                9421890536303267950,\n                2811797585537180207,\n                5221682992061150871,\n                8701033693885846524,\n                510866220487737298,\n                11014183458125585795,\n                7331136142244744171,\n                13347933694384243576,\n                2971027367826241163,\n                16895278402964612481,\n                10343481409259870382,\n                7637469477289176903,\n                14515774696379459873,\n                10726339387643525816,\n                788506778946106429,\n                2659740016403876425,\n                16299202570325799651,\n                10641347864823085647,\n                18351117229710313282,\n                11988134638402872271,\n                9778312471146927353,\n                7381217128978919856,\n                11060274181369112531,\n                7495561798963235349,\n                9055395298714390718,\n                16303796496309697333,\n                8572341055391067730,\n                10552681108574337704,\n                778603576632844717,\n                9200061608692138973,\n                13379830264581686143,\n                3558681711903189493,\n                15333709760058518468,\n                2592042142960702928,\n                407067581456916025,\n                5641562894408640944,\n                12630685466004633336,\n                1951314561801616023,\n                5079140706956976391,\n                3970999389200166383,\n                334899398117822722,\n                8719953466943676049,\n                14359186121933838308,\n                8823579651924661407,\n                1813976296212826001,\n                7289919441079088958,\n                6752583945603678883,\n                11125294819942902844,\n                9024544902550020287,\n                16347203117320623082,\n                16956773689825861850,\n                16095935035076959663,\n                5891276384953676887,\n                15268407330104588524,\n                8413928464863914833,\n                8490251354332486177,\n                6927106640650584013,\n                12126731995366926678,\n                3751336702350408676,\n                5401550620951546719,\n                6931736049013788628,\n                12580678497648710244,\n                14038988011959255031,\n                6324030753850964685,\n                10493602541721624812,\n                2109892633617514458,\n                12146451675883836768,\n                13274122909086796977,\n                9754756986068039363,\n                14495908277997962154,\n                9466734708284504026,\n                4844085276275930177,\n                9796561850244140319,\n                1799849561951724621,\n                12358897468285161083,\n                12177695598696402808,\n                7332427622266662258,\n                6479138013230677807,\n                2934293921862361841,\n                10101747402348634287,\n                17392449178621812522,\n                9076304922506319918,\n                11821100168915316422,\n                2496048241232164281,\n                3879748422895069655,\n                16704268052335595321,\n                17390288111943870483,\n                7693888478144629575,\n                76425240623418453,\n                16567047119010034390,\n                11413373222405397265,\n                16470449866739367455,\n                11214274131174610225,\n                3101065760151847228,\n                6960224778085176498,\n                13808140043074427665,\n                6407627460027904108,\n                15896802775139636956,\n                7832538022931244434,\n                2921401371982230107,\n                5173908476677176511,\n                10421805820757738988,\n                6810895721424324269,\n                9500975479118470651,\n                2857351951424190284,\n                12823190925726244119,\n                1508820218642005789,\n                8299638370676388531,\n                16716319887270456308,\n                49159138387135609,\n                13569342532624466720,\n                13810905518194621132,\n                15814726715984180641,\n                9733273584351206251,\n                2143427140149969534,\n                5005663583690258770,\n                9498096902345501346,\n                8059179870401817189,\n                2748099509860782482,\n                13393750936162889414,\n                8594871683329714285,\n                9350309329045037166,\n                7894115690084420630,\n                16786514420046861964,\n                976749382737801867,\n                10467038807753661049,\n                9339621677902021989,\n                402089271605444461,\n                4137928429977667667,\n                11168137397964197909,\n                17118114157506933041,\n                2466794684933887081,\n                2381322333528956568,\n                16060736976005604675,\n                7659572533258347452,\n                2456177646632167396,\n                5581133606107460922,\n                9386681170001289422,\n                856367678035725915,\n                15662913305262005104,\n                10182759715493794272,\n                6309878850057832646,\n                7310497159043440161,\n                8801096542582865405,\n                17603162305339672061,\n                12464396493690551414,\n                905835578866578233,\n                6335283537487112756,\n                18062909181584849860,\n                18164643260343932115,\n                9611673889224211203,\n                11167605540010764967,\n                5235785776664953431,\n                15827229396414291668,\n                15930079830521734622,\n                10729843207836263675,\n                13661546405175006477,\n                16135164248800319186,\n                17460395396731193202,\n                14180726883841571695,\n                15960200487338673589,\n                8706962802097008830,\n                2160987916800110300,\n                1051526548572672844,\n                9819378916385658549,\n                5286507605709789239,\n                13469546533879771266,\n                9307969742012845248,\n                15615676059776785223,\n                13678628123654222573,\n                4894676242232977237,\n                12463254721383166913,\n                16203870605982620330,\n                16023651922098038612,\n                7232852316950853131,\n                8962741390064610435,\n                11073871852691286666,\n                1951976192995013845,\n                981262607320358571,\n                16888050122965370896,\n                4344384252438731372,\n                7412522378253499740,\n                883175500149730679,\n                9464224172069098591,\n                10275279734394232097,\n                15403548203346787052,\n                9763124462913973107,\n                2389315153739146729,\n                13323697104831839684,\n                5987579865535399885,\n                6129762999102774797,\n                4347951805136348101,\n                2506188997686408591,\n                2557923537528328465,\n                1907502054327326877,\n                11348447673182547440,\n                214394370899217588,\n                1795825157652904688,\n                1079543763001874644,\n                7616884667306755371,\n                14035899738904279037,\n                13603064082194411970,\n                4656663014321257673,\n                2516633233356574316,\n                13157932564393540150,\n                11846837651284282888,\n                16495943766392305895,\n                11420100349017187526,\n                10171218756873499208,\n                6391422370224144667,\n                3018292857029467592,\n                3106481628843315850,\n                6825790880621561776,\n                12921691493010642236,\n                17141277638143731380,\n                4485397080913431269,\n                13546956797638434094,\n                17912330572903817378,\n                8490274475095362840,\n                13555954280504902543,\n                14027241222269053491,\n                10885497045528349179,\n                12019189578091440959,\n                8524809140594718081,\n                6729564987712259454,\n                10294149345473347404,\n                14564176145614125180,\n                10959232484424234147,\n                13881154219512878890,\n                11303202608031861845,\n                9393772422743641450,\n                6070458610875812307,\n                16959999555618324305,\n                10001897689126693737,\n                11648110147126966600,\n                11854195848867487269,\n                1069111130614492919,\n                14992756999092303050,\n                14546869344145489447,\n                8058351440331963307,\n                4274232524574392202,\n                11464289163923391246,\n                8692996261929543956,\n                4508468249049018651,\n                14423278340286421655,\n                2564508301584730834,\n                3859045330752750621,\n                2394646001476710533,\n                15538310772728613959,\n                7119012861567026172,\n                14080676356760895921,\n                10481316516476920127,\n                8953956652625819960,\n                15120007614681010256,\n                1707764772247280369,\n                9418183698843915873,\n                8035252867217811158,\n                11608754122523476680,\n                9711175522978321729,\n                4843904770403152351,\n                13087602715200118413,\n                6994836269212372197,\n                17825214555151605811,\n                2967734810424283243,\n                2387363035965899020,\n                17972801638857345955,\n                14678563586097685754,\n                18332850447185985724,\n                4802373133882822931,\n                10249883805776628591,\n                9771191734968311898,\n                12071190072567592143,\n                9199739750044147248,\n                6156417751384074752,\n                9945419763243948060,\n                16852715112241242836,\n                15498848488019829937,\n                8209154894812848656,\n                7605360745335808686,\n                5813615285131032978,\n                63204830640610456,\n                13528270312138672012,\n                13283862845967502043,\n                8050305155218750215,\n                14674596502349757008,\n                8358424196888559720,\n                1146973740112715424,\n                14964963965589838478,\n                841757193400499440,\n                14177680650235797891,\n                7631715193722403025,\n                5034141147376399263,\n                283111841854752856,\n                14927674423006354942,\n                16964047188773151732,\n                6398259345736930740,\n                16580537252867656103,\n                12301527733370425637,\n                12833132833691646344,\n                17033427146698681927,\n                16008951791940190108,\n                17980249132360677006,\n                16067599779005199581,\n                2081457686236108956,\n                5812601273257050732,\n                17866101689516824721,\n                2684839860280649088,\n                854604419444537598,\n                8905025564636441116,\n                7217301761354685473,\n                13930846346011985462,\n                2228185093512258877,\n                2196889361780157388,\n                7373358985538640633,\n                4616035087050111997,\n                12541255008421421213,\n                6023231021806580561,\n                5345892880580177162,\n                15954974730435085918,\n                1459920705275321361,\n                10512201752571642839,\n                18058356709377865891,\n                4833344764102103195,\n                2509346903506136425,\n                14446963374952835244,\n                17897676329582789951,\n                1678081788586355622,\n                5572980068705774721,\n                2292511766532018507,\n                12515574856517533810,\n                3533113919323294510,\n                15790765656655812990,\n                1229927139455551951,\n                9079999555500778355,\n                10714091306623367583,\n                16702898494447597729,\n                7175066789028512513,\n                16316215516083409859,\n                1335614351511752127,\n                8120563109037646837,\n                15529472665463557381,\n                4320685394030925984,\n            ],\n            &[\n                1672628060742854697,\n                15282246281150199895,\n                1805861883825941289,\n                13054368594875028248,\n                2171479929375595351,\n                9116298011409447511,\n                17306888266286748641,\n                5746239585631076601,\n                9725142985408265462,\n                8496940287015097744,\n                18226505622247538366,\n                6266780941044650332,\n                6156048087444894443,\n                4538057600114721383,\n                97265789122852680,\n                6274289580297275262,\n                5228875786412768441,\n                16242628134361946493,\n                11190536716838148054,\n                14999253618380186569,\n                9431412228781264525,\n                3720693557798279014,\n                16573669939083720392,\n                6740694555820849051,\n                6524091096770490079,\n                3096562044087457385,\n                3445205792069137773,\n                5879395926345036068,\n                11823228934954636111,\n                12371688555199950549,\n                17297616112085246932,\n                2555509880373782106,\n                16223058021752764878,\n                14999422229046575663,\n                4862802819963101806,\n                17693697449754524004,\n                7451546626575486923,\n                16834189484925343792,\n                16509933831486099241,\n                12631184257434523805,\n                17806422081175828224,\n                9024323842858863304,\n                6033612708074245541,\n                14283589057587996336,\n                10842466583038220693,\n                17663757149762543208,\n                17032131808306205091,\n                4374016337917105366,\n                6505220788410699133,\n                5673566217968186629,\n                5932755409025155247,\n                4554145012174950408,\n                17529903423737764658,\n                3815725265250996100,\n                768030762409375364,\n                8101111540473986421,\n                514131312877508602,\n                8467511376623331898,\n                831718339007207491,\n                2504859423595920845,\n                11166837695738109823,\n                14373206768305383478,\n                9082192462384414967,\n                14242379354001692723,\n                12416775352244640482,\n                13103976180057994274,\n                6653815487356775730,\n                4540712387053805867,\n                14570815029195900562,\n                13110042734243091237,\n                3689426930956949722,\n                12593196976319748335,\n                5082154213541346557,\n                8069143451694814354,\n                589978278622072544,\n                10926961016815911289,\n                13766140955627543742,\n                4586220875755960736,\n                16112246436712502875,\n                9204941109851770944,\n                5473914245681242802,\n                3218880288053733024,\n                9536533824552638136,\n                10077047347011578942,\n                14182303267298662466,\n                6026715993374312806,\n                10378524287074681936,\n                2296780928121215418,\n                15754749815480350917,\n                3330943091954471356,\n                1126865601328103283,\n                8951889275386466113,\n                7986378594472968517,\n                793002098840792529,\n                15105672122567239393,\n                14635720719820726943,\n                7943655256838356552,\n                12835998967580492470,\n                756113536611343794,\n                13521679712064841769,\n                6920694928381100485,\n                3963584378724408976,\n                18168458596975089512,\n                6246280487083928698,\n                15693439960182266662,\n                2204976266736113349,\n                17357508962507938891,\n                11151653946273121871,\n                1703605549588045403,\n                16733783926869844505,\n                11316772557004760630,\n                18286184542860447926,\n                17671746225554970780,\n                7808746917349768325,\n                11269882956337693194,\n                12921611154439887602,\n                16678620045935729497,\n                16402009986336505442,\n                12847458604081538511,\n                17755399026300991951,\n                12686461068405877203,\n                14423738039750236538,\n                4909229580701064002,\n                1469887314647249417,\n                13190369397487996719,\n                10548255880673058721,\n                10653993017413970889,\n                15707594908377821293,\n                7185571374210148494,\n                16675774579122291136,\n                6388065414982007363,\n                3817450123651794334,\n                8635533889608537216,\n                6098638948365389616,\n                14307458322530931176,\n                13765784114239575219,\n                14446745783912954054,\n                3962804757561248904,\n                1162536535886696571,\n                8949170256816840738,\n                7643084825050542991,\n                16599216336031476997,\n                17192262166429815739,\n                10667971872031883844,\n                3121128640608730652,\n                10144016131343139900,\n                16895209624213388514,\n                1069213517692929905,\n                11337495802967652212,\n                5324596461543864795,\n                8246685063522286472,\n                18440915663687455364,\n                2785075444444891667,\n                14642175687044056076,\n                7806683982223990578,\n                18188589122349697120,\n                17807393819655286371,\n                9986742896841182780,\n                11733628547230256252,\n                9608069068769719469,\n                2782483964663700175,\n                4481784645254463219,\n                16640245285459980455,\n                7081071197660003592,\n                4682789333184064646,\n                8699027495672091249,\n                2042623593099711310,\n                9915351267439399830,\n                4529441913968349798,\n                17688669638726001150,\n                6969233181109699557,\n                15041947273170766194,\n                17013037482566716685,\n                4028641208180307500,\n                9766684953326663168,\n                16660710246722520539,\n                9300789760989405814,\n                4619559511775411121,\n                11220958186525568895,\n                195220445631146614,\n                8797196939793783080,\n                18091207242784278021,\n                14238252978432062697,\n                14862253422759731673,\n                12947632302042479882,\n                15790153148656404089,\n                1463807601685839210,\n                6696548515759888327,\n                5142603015218451719,\n                9851870076797225221,\n                339341363302195257,\n                7704429898409730537,\n                11167176554577895085,\n                15752522708113359648,\n                15301031230056608579,\n                2313150267472026543,\n                10140513040040392042,\n                3537463966687096726,\n                15456908874173546317,\n                7973357052931918856,\n                7110133225280554584,\n                1404650061415360805,\n                12060443895006083838,\n                11121710524180835999,\n                17692677335419631161,\n                10345142843647975813,\n                11682157366762073463,\n                2218847055822344923,\n                10934859963273441522,\n                12441186660408656103,\n                822437026043744899,\n                2681004617288037103,\n                17757286544288847237,\n                8711785011821989019,\n                2785025474986163397,\n                2215183106863227830,\n                8059198739628780880,\n                571580723319871982,\n                16197606749028159993,\n                14831503691581153694,\n                11539851268300258899,\n                524105877649968839,\n                17416266841947817353,\n                5495778589153513323,\n                968960604106612398,\n                16678615353805682898,\n                11700287878212831351,\n                3622606565047473052,\n                2647340224033760611,\n                6871533508415095757,\n                2659198863719376934,\n                6931677157599383205,\n                5055354256113794098,\n                336562919103163745,\n                2361059542672889740,\n                825783562725949018,\n                11642185020259800092,\n                10047872728458598237,\n                13504093553221294687,\n                8602424918317817259,\n                15282984454184248861,\n                852452176859461039,\n                10050340329117425330,\n                2701111594842630681,\n                3380516875107345403,\n                4136143889811526300,\n                6268876047837425795,\n                2559786284511206847,\n                17755488665395878481,\n                8001355533630793116,\n                14726003870570175656,\n                9103515680317108232,\n                8435167688649445195,\n                14978151287514534341,\n                8379493954467012982,\n                6052576543057882900,\n                15389754048954564920,\n                12385734689115419153,\n                17777831557332306413,\n                9900279278045930351,\n                1206609987039670425,\n                13611112101506709706,\n                12762535112248529447,\n                817294020497817885,\n                10754700156031583495,\n                15389439159096743524,\n                14162879890232853094,\n                5117425864944557608,\n                8604962998164750142,\n                13790816172204909738,\n                4104758843285603165,\n                17930520683724082981,\n                8414454756264175755,\n                10449954739296855658,\n                15479563286299626029,\n                303808843612780921,\n                1389720105318403852,\n                785817621113818440,\n                11448825792535874711,\n                9736582039937653322,\n                12920595361026137481,\n                16699975623529765391,\n                13749646219160470884,\n                11401244124325218336,\n                16282041074080967643,\n                6553330957169095078,\n                2534460029969182943,\n                15346714113583882829,\n                10322797870140362419,\n                8170525298094874241,\n                8993837346481500013,\n                1592337973614036797,\n                4112707017760094378,\n                3653698431433437788,\n                1164503220725896682,\n                4192689923903726560,\n                8728431104977525460,\n                6286869906994648159,\n                15043778140439653995,\n                5615728271150547979,\n                1988572003934603512,\n                15135378657876422165,\n                315512758477949858,\n                16216116870274501948,\n                12504723790971753070,\n                1535348898544488365,\n                10095860684622701491,\n                9132371123926938392,\n                10120783865748871929,\n                5051411488306545858,\n                15543678014917206393,\n                15426909057079235480,\n                9504015675463012967,\n                3066901079497505204,\n                6081911170465869341,\n                11137007540202157563,\n                7450248916723605240,\n                16986119260853423951,\n                7578352278837776349,\n                6751429673444952435,\n                13612365479873100530,\n                7696425067114400131,\n                201953216397633927,\n                10830451601162376941,\n                5745264538351074871,\n                3879748506573515769,\n                13854134445751736268,\n                12219208888937467580,\n                5358318705731611099,\n                10986820887645881138,\n                5254734320802095761,\n                17981689768158240665,\n                4420729817422648815,\n                18361425798056776288,\n                8540074679155734254,\n                1731667252659743593,\n                6152889871893755218,\n                15217521953228771511,\n                3567899098692038741,\n                5389619645758200151,\n                4691008339827948826,\n                10713279365488347571,\n                9745954968251366598,\n                7302191498672369955,\n                12626782502849516545,\n                14447293561102751675,\n                6734094488616523594,\n                5731330022735521614,\n                1465319249901885331,\n                8689750081955043230,\n                12950959544528179017,\n                8224104597108932838,\n                13301534995263852143,\n                5645122690858278324,\n                17908106229077733178,\n                323203859917688448,\n                12815293733143521854,\n                8031863434623615415,\n                15599896533075140903,\n                486382747533668075,\n                2557885075871780373,\n                5639961122845008175,\n                10393998329050866773,\n                15322005771165766426,\n                15578096382762093684,\n                14721580303503888873,\n                8331810764551543605,\n                14134080240781873816,\n                5292301859290420205,\n                12934613667998296598,\n                12759300614679833510,\n                11836905953852898472,\n                10400210724390354576,\n                7895575850616655288,\n                329940446534439796,\n                6948421725680731847,\n                10383034077753168858,\n                14251858051847196147,\n                13417478805898580488,\n                15666356095993822967,\n                2649890612422460352,\n                3960290467905564799,\n                11604699241357916870,\n                2707032916751066910,\n                17162029134544454899,\n                3462167755608084681,\n                7708163267151599835,\n                6060118632496715447,\n                14659850067472343295,\n                916231975382177286,\n                7887196957456909593,\n                16212896135104729851,\n                18388686047231092271,\n                15188059656466677817,\n                10159359915532738686,\n                12209557326012167892,\n                17104166537381148968,\n                8549912606942034263,\n                8608254283565330385,\n                12199789530349117525,\n                17653984748958090856,\n                13236243855027491135,\n                7285865740076703400,\n                15313657680519880233,\n                9809529301268841750,\n                8322107960211428865,\n                5703942948802254530,\n                14812716998355005471,\n                15136016082127517829,\n                7281927702421102653,\n                15373636513805545688,\n                10377353955277252153,\n                2710606888135973500,\n                483290790823167088,\n                16941949237955644494,\n                13114672411012065693,\n                16718085808501163359,\n                15292113884889789796,\n                7981991935175106680,\n                16723904260851495386,\n                4634513538107365365,\n                18324378641217720117,\n                18227662801481578598,\n                5444832827920199100,\n                12893849341139616412,\n                11696684010633795560,\n                12371761519158834548,\n                5017297642292910863,\n                18115726883313877717,\n                18182028244204009400,\n                623586467022528940,\n                12093052177881141597,\n                12472931752552395239,\n                8322821403753201296,\n                9468858393454090922,\n            ],\n            false,\n            &[\n                5918120123986948981,\n                12214866885969252723,\n                11609253883777433902,\n                5635355260056282089,\n                15175771283313717007,\n                15492577498145701934,\n                17281089998867972767,\n                6586417628634894478,\n                12935717257603408407,\n                213518157147993568,\n                17634550085774545221,\n                7802961645411480687,\n                15474328354975317828,\n                3030764988654892480,\n                8848149603966882371,\n                676892117606100777,\n                4196049354216097590,\n                1119069746820091103,\n                13781529735879690406,\n                16275626026273391927,\n                8300205860701261916,\n                7767984337518977035,\n                5352931226469408832,\n                12549815516668122057,\n                11497059402098551468,\n                12238303176301966941,\n                17906048896221344372,\n                11541304749033810082,\n                1087347036356063215,\n                10445124749889523059,\n                2108226265832637935,\n                18326684922164242899,\n                17591839094119199053,\n                9649362351718252143,\n                5419877371634754910,\n                7985315133687996015,\n                4380072020580579165,\n                16785985274039491915,\n                17906401277998543325,\n                16110490995638091421,\n                3199491816914838798,\n                16213219991928431786,\n                9326535095032375619,\n                15738134700481029737,\n                60761202193356037,\n                14526584003657596983,\n                9717506275850427639,\n                8872353450872566613,\n                17495997723658103586,\n                3896491297225969939,\n                15875376698593105408,\n                9826018841003362522,\n                8152616341657954338,\n                14943012924993107558,\n                7125340071924826005,\n                4761034333897027607,\n                7251331321451036206,\n                4747806146235227299,\n                6726751761629566068,\n                18178470774825318512,\n                18189114841849876379,\n                17717832995746573676,\n                2573674198725968785,\n                5853505062283210675,\n                14828791922576430704,\n                17468100460396300527,\n                16548721553868826459,\n                9927275635269960578,\n                3174270457173750382,\n                11071224255186651932,\n                15278979303406616879,\n                9257778059115798365,\n                14655545247523251097,\n                13790831768475677442,\n                6071172380973927546,\n                14653522655958546738,\n                1283852078171252640,\n                17755439659741780817,\n                7042497028732297491,\n                5214827328478127328,\n                8543642755744863764,\n                8612011501311255315,\n                6185713519471448847,\n                10532050115036338934,\n                4085362692096841984,\n                16722145437751649336,\n                9095286107166596594,\n                13057785857928532741,\n                6724302268334378235,\n                16685648673426979898,\n                8043212514589919457,\n                4407985707410781908,\n                4857378688754564057,\n                13943718795425872569,\n                471792017916165335,\n                5215960704545918835,\n                8898677740944188434,\n                16192547849590163757,\n                10927045263666149554,\n                16012942497443086833,\n                17856824427949500892,\n                5311983919389056447,\n                9076063431281448739,\n                2785828113680086598,\n                15110707091558662212,\n                6583010959630797697,\n                1419528267250785056,\n                9595683664056411195,\n                3249323284298806238,\n                9595933966715778670,\n                1500902293448815881,\n                5874310265457777380,\n                5285481081074725330,\n                3692318632564707737,\n                434746415289817737,\n                3244704509795678589,\n                5607528670277715164,\n                6168231075304184647,\n                17820359109262978732,\n                15921865578115170464,\n                6560400307775181833,\n                18092176022757937173,\n                2416917950725208618,\n                5068383455535678979,\n                10996164899950125555,\n                2534117342435778418,\n                9652711066484768908,\n                13461915503471780054,\n                8411049298262654215,\n                11627045183374435993,\n                597713380029364712,\n                9914424860026353436,\n                6398417476997644577,\n                913522648047558044,\n                5233560422688152729,\n                12269904588172515957,\n                2915109300865307211,\n                7061777415895646538,\n                14428707789216354297,\n                1790994874131700041,\n                8134975277497787768,\n                12979580903727579988,\n                11615590867637744738,\n                7000312698420541142,\n                9784693912853241529,\n                10944442549740283787,\n                82531176080969023,\n                14959951731803161969,\n                6668176410821069021,\n                4719500064486095694,\n                5759785414559226561,\n                4970363591469849595,\n                3243428337539320431,\n                3156898109989998209,\n                4247164185502339328,\n                8388168007257316831,\n                8981232323059064529,\n                16860198432014849988,\n                3539236745546337501,\n                17719922367578025346,\n                17210626294345726472,\n                8625129527773205281,\n                15568690990583000906,\n                16537720024170832632,\n                11081163673779633734,\n                14597737748843479829,\n                12286199535506665388,\n                7151442784245909806,\n                5044864980114186877,\n                4391689371296961006,\n                6540168485548659477,\n                2857514210130326707,\n                6969210128397296294,\n                185414187382782164,\n                9788252758640228255,\n                11134472910826455196,\n                9826829185177748458,\n                10391037584385454968,\n                9612702489136097624,\n                15745785329372206817,\n                11985385919699457287,\n                4647950731727578599,\n                13474308436818096670,\n                7407581385161850827,\n                17049401430832148706,\n                11185615615288710943,\n                11340197387195283249,\n                9085306227945895799,\n                13048191724100099668,\n                8222075024390640547,\n                14981122579864582841,\n                10723365510805850325,\n                15882294117621079731,\n                17224307861706260858,\n                404752946419267157,\n                17455653606541202378,\n                11149932181201234911,\n                17174493378281359115,\n                5742746808088101191,\n                6857975670321360348,\n                9488183194120086577,\n                850756444942468501,\n                18251138242152971676,\n                5028044743228145865,\n                1709652293836541825,\n                9336246950855990417,\n                12104001557578243874,\n                7518552932181414217,\n                10953659187130713754,\n                8640278306963064150,\n                3527996602952080033,\n                9724416208794871557,\n                9818471899845617626,\n                2259597663894735920,\n                17196044757056583541,\n                2638888046578257240,\n                6998509470199156531,\n                9192353130659837733,\n                567984143948249890,\n                9591497398626468338,\n                16399018889425267172,\n                11561115484479883223,\n                13399243786692529429,\n                146294187886053462,\n                7961591237166713768,\n                8208718803163953456,\n                1484938287860582687,\n                15046852652421580156,\n                7169416232431254009,\n                5292287501892714727,\n                16630324861460976422,\n                12475975871299584278,\n                13525399861247607934,\n                1565336724846468707,\n                7276508501752242104,\n                11859012083360705479,\n                555007877916338240,\n                14880605908455542248,\n                2705807160288146830,\n                14145160047055578292,\n                9866403983350364712,\n                1195459380772174685,\n                11139370143037652187,\n                11437022067401833240,\n                13682486855606152975,\n                3430673715799609998,\n                8489219321033686862,\n                14395916737962056100,\n                14198819344492488794,\n                4725627873940009758,\n                4377130471348839898,\n                132810124294572633,\n                10250911241920381171,\n                9212291520499301135,\n                14290126791732174693,\n                709484470312549752,\n                13655949074890812034,\n                16390659273052951496,\n                1962161044085964851,\n                6592951073267309884,\n                16635386023505459542,\n                7521725279768638651,\n                10702292265780209953,\n                17508035731310744307,\n                4849314369727221433,\n                3518368935757575829,\n                928772043789904943,\n                13066503627704932241,\n                9170835921766657120,\n                1720438369363860482,\n                9653343145255079951,\n                10806927358101847561,\n                11860406035049881649,\n                1974385665395717679,\n                15975482787244401193,\n                3619432381005082811,\n                9877997566644094001,\n                17053881395186060130,\n                10589869650671333670,\n                11664760554418654295,\n                7590280596977495719,\n                10856366592484551548,\n                2631368840539712836,\n                2839899387286337113,\n                8524146102427533222,\n                4990365012618727902,\n                7151891648819983069,\n                11375481945550229603,\n                8858696180128338237,\n                16384521973744224932,\n                17139452207328725464,\n                13252654993803597499,\n                13434282302115861786,\n                14150706912775302393,\n                10948307646609458445,\n                17388420540008093188,\n                6587864291894884444,\n                7978190567474696593,\n                7928967279204444076,\n                15049296655976922413,\n                289738567977993423,\n                6897438000403266124,\n                5964433949215867587,\n                16648009539233406755,\n                12752972348654131733,\n                2033455762505189299,\n                11364966258849937493,\n                16482570007448457618,\n                11388428709157868651,\n                7266585693081119187,\n                2599499958067785647,\n                1720925230213021349,\n                17626323535654061769,\n                6663193598469739489,\n                12671248167045283050,\n                12140673778531699982,\n                12103201664484858035,\n                8004547753695309336,\n                6455154238957765328,\n                8593204946748750727,\n                10957963623834878235,\n                17888461227536598973,\n                17735403436793241827,\n                4585025702858048319,\n                9246263998993338794,\n                9799856693447240374,\n                13046824397398954407,\n                3257704574039398043,\n                16475559398714306923,\n                16151216692843310157,\n                7492987706459570361,\n                8794687054736704078,\n                14498750737487053007,\n                6499114153875831088,\n                10344627650758003261,\n                3933547531509449109,\n                9252017834015356297,\n                10431927836410739631,\n                5636096958617681173,\n                17723724381959311922,\n                821040401146944398,\n                8509491285814488607,\n                7142450219324257681,\n                2899499047459777930,\n                12095042099304891630,\n                9090217037821987593,\n                3737560355775916991,\n                4433293248592466046,\n                2579586186392778687,\n                5627778192418388032,\n                18000377780513451714,\n                2643121727684540272,\n                13573819511864552202,\n                4784246152290536627,\n                9420370852195292962,\n                712263826591202499,\n                15491886233585377779,\n                9323035863279061117,\n                11045154527883042924,\n                7385229880856543696,\n                6977873611490450039,\n                13639543508335080037,\n                13478048328899736023,\n                18039135682054740779,\n                11521064013981520637,\n                12102327419513222106,\n                9272869873740159480,\n                12775276724893510766,\n                5753913366937783318,\n                2967349222422898380,\n                450790676996347594,\n                14991588921019202960,\n                4473124084109094254,\n                5276806381726757488,\n                572213956369142365,\n                978390961725309052,\n                11077194266341939697,\n                9301606295378325073,\n                6640701743743293068,\n                12862661643802294986,\n                11875074059347396257,\n                2662510629463159961,\n                7518896084004916711,\n                5633197821304310891,\n                13694031055503341476,\n                2390793653044825173,\n                1748645157989562610,\n                12795800048419142659,\n                13894628843525927844,\n                2254756627497371142,\n                17588489135795917364,\n                5359793907722886073,\n                14093783225507224946,\n                12953198522788916163,\n                13706816417396184408,\n                17931918665360327727,\n                3692987813274069977,\n                6331195597561897082,\n                10168077267706641283,\n                9760779913234776768,\n                2948160909961149051,\n                17652740296610148356,\n                12899526691779881821,\n                4089363416315714602,\n                15800160433756171036,\n                4150896140209606169,\n                4332987844457554832,\n                1726137208556197778,\n                2230907531048364518,\n                8037395526181922358,\n                11903227707490817951,\n                13247419964627176543,\n                9656311595299555081,\n                11824744075533270637,\n                5618559869312497469,\n                5589143266997450557,\n                18379067610860048886,\n                11371445493433813486,\n                12614852294401999528,\n                15893311235480705385,\n                13552674216984930943,\n                6331861843109662222,\n                562000957286283961,\n                15993421123194766567,\n                17787868659905745587,\n                884898535478444829,\n                2284336629817602343,\n                13188445592703944671,\n                262346945748782371,\n                16087606565809361134,\n                4452167838802852067,\n                17502476454970888321,\n                8180837608229621001,\n                6395585225706196871,\n                11859771797007351562,\n                14699457447367466778,\n                17084204551310758507,\n                7715446538566999362,\n                14709025739137466139,\n                14530757131065554612,\n                14780426661345509038,\n                45918674395986635,\n                14144922841238297945,\n                3642101397043170323,\n                12593107591216122208,\n                2107492802032040706,\n                3969864990100431674,\n                10726651770322104822,\n                17773265383948264351,\n                16680071697289316333,\n                12864952677492720002,\n                12349506660379881743,\n                12343351742867596309,\n                12895930201825086535,\n                12401346848400595318,\n                8155690734768845822,\n                11075739107507568490,\n                14443945014748180431,\n                4606806037355291818,\n                8618009589158556699,\n                4962909705265320474,\n                7936513201613120511,\n                6885820758344807063,\n                10401668492364333375,\n                16727888475202594818,\n                4154014773292175466,\n                13161203947882521396,\n                13919019307994819468,\n                9598301910556281548,\n                13615929950270046529,\n                9814294142614670228,\n                388842039453995229,\n                3868906497764221215,\n                11133917243382513385,\n                14431233794630116013,\n                13866552635857099237,\n                1446694260333969170,\n                12634186166034145163,\n                5583369938899602777,\n                5137033854197759276,\n                14066215613504391619,\n                3724105431075335405,\n                634452116543180599,\n                16701028791920674351,\n                14689441581249693370,\n                11300117837769921445,\n                5709070571093483362,\n                17979686883221884345,\n                4523042923981658057,\n                1775748550754504259,\n                16344644718339597549,\n                17392052235242169852,\n                12785196418644852357,\n                18211451905528726650,\n                2708064947215446363,\n                8380100165657891871,\n                7137253101551661869,\n                8142616943154617917,\n                17803746564213147436,\n                153826372692538928,\n                5723793786021725861,\n                10196131183953359834,\n                5523825472161035798,\n                18267865405460736489,\n                3283468354748984180,\n                10604208998484587574,\n                7393144798381468009,\n                14384823378526431848,\n                17875404430476094447,\n                12734512376384491761,\n                12434256692947114698,\n                17275896681161726464,\n                3991517411918578920,\n                3341256985625706194,\n                12875923317501906784,\n                11553174191068953395,\n                9402911263274348037,\n                7889147691441176281,\n                2938433861208318833,\n                16835317070524419869,\n                15311222124964640322,\n                13191386070347279526,\n                2797120364879623301,\n                4825023507822429466,\n                850800332384380026,\n                12566471159773669108,\n                10641916485819690941,\n                4533772051636675323,\n                13280511685797693290,\n                1555062755988987659,\n                3239647128855404245,\n                6726066500947499377,\n                6007423757732386662,\n                4149243922709316723,\n                5132586553438157005,\n                15792321766139519460,\n                15816926954768067972,\n                7294118112451354585,\n                17286958838591009277,\n                4907287824228034499,\n                4053237279580028055,\n                15243191806135344763,\n                15160933191318572834,\n                9399541646460123387,\n                10512247032240862385,\n                1549392404477822056,\n                1553664084033256717,\n                8299938816978050250,\n                4506406752176376101,\n                392106422304255528,\n                14325256251728416026,\n                9605320355454775897,\n                149289209445211694,\n                14196672746036566731,\n                16390833843583709204,\n                7306529835380864755,\n                1609617294884241186,\n                4376392608007191042,\n                4686172428942509254,\n                9226100890114720864,\n                4817469637170691996,\n                11063190997882783988,\n                16818806293969511167,\n                16753414946544024233,\n                11652469874726823984,\n                10410834301724561610,\n                4496419155373466708,\n                14860760715530123421,\n                17116153223846910169,\n                7192050227650381565,\n                17378669812287708918,\n                225986433549199368,\n                8470401363462512715,\n                10770868581319043866,\n                9466901035622012241,\n                6699024375729741712,\n                409036602332432525,\n                5386757448559243618,\n                8963450891011896500,\n                8673144181466249760,\n                873094291187559664,\n                12664083699094549676,\n                5775559671211518891,\n                11686008504688202631,\n                15839718905540698056,\n                13266083552259617867,\n                16629163912909716168,\n                12951596193960803465,\n                16680382695263717715,\n                5312112430010155237,\n                183580306753984010,\n                4620614350630898330,\n                146368985100561751,\n                8680242838971693339,\n                16334891003809230168,\n                8296044009054807136,\n                11068535921992539488,\n                13459068409989801398,\n                16330227018753527806,\n                12310150645922723889,\n                16470777689868351201,\n                13885354582351631115,\n                10781416202037656061,\n                14844375805930616264,\n                8719638653924890264,\n                9466966915302767475,\n                16902517274689764268,\n                7637295587685318358,\n                10083082213122260465,\n                8181103359836753090,\n                16962684553940361626,\n                7837156732091767324,\n                269176569842339446,\n                7278095361680012780,\n                3942758955593007702,\n                4528968938190179194,\n                6704240607075070331,\n                3303432731279722312,\n                2158648768224700327,\n                14688749631211044587,\n                11272001457898253785,\n                2068777615217221600,\n                7354581415030465360,\n                4115757448706765204,\n                9845224061747124764,\n                3689237284770699729,\n                18290464418127999238,\n                7852077070988627012,\n                7863151332492806125,\n                251628885737301978,\n                18042357620611449193,\n                14116593607800996151,\n                8096141927089169364,\n                12647877985059926597,\n                8418401584195560472,\n                18060685288941472824,\n                12955326448341608928,\n                17257701815289013872,\n                12412692797833535892,\n                7581020805942464303,\n                1793728477510701265,\n                1440048947029875831,\n                4001344949088306175,\n                4930448054167731848,\n                18351422903276209040,\n                14203523087498470015,\n                4333543995517392762,\n                2404299597925046684,\n                8665180504038796043,\n                4824446420399647636,\n                10289758138518593816,\n                3607452937085742574,\n                5784430632374580381,\n                13224009883109730301,\n                10433302833369492081,\n                8563330309308426093,\n                977134692355658252,\n                868639596313947660,\n                11114845570806284756,\n                10553568804667187456,\n                828402278919864619,\n                8940626136465663544,\n                1412605768723256370,\n                9626895483501195170,\n                16359088278152878811,\n                3692614001269046240,\n                14789154216532717572,\n                4036942485790633503,\n                1049261082210626671,\n                16218938044785968460,\n                85530679118254297,\n                13099694691696048080,\n                3076142799126365810,\n                16178437464286841227,\n                12056596164270992336,\n                13502907218061644868,\n                3588068196299944250,\n                6887727249443337211,\n                1859310871727038082,\n                13661391178199592998,\n                13954271532839623639,\n                10390958586703587961,\n                10379888160727024239,\n                4052888005851455694,\n                7904956370427672392,\n                8519981488846994043,\n                15332926568151370053,\n                1191060154732214298,\n                16959635090494556484,\n                11069336977744897600,\n                17227745386405237665,\n                8089827037565392855,\n                13503095650871818986,\n                16377926887996418472,\n                18093036631333756750,\n                12555984050040346394,\n                7227273171888696040,\n                13299375693247766378,\n                17475709327332183680,\n                15615295930257614429,\n                410338853684361107,\n                8259500083186530998,\n                2735443689396556788,\n                15142914652661121453,\n                2197321929993766794,\n                17346858321220349784,\n                6402361562826954211,\n                17682894801076100405,\n                10016553667127190501,\n                13036488928964213107,\n                12660139296995183874,\n                17212334112539182701,\n                11367734776084342977,\n                8665742805841735408,\n                16025336783181331773,\n                5117698047398356429,\n                12735740150828193823,\n                1081804134485276729,\n                7842045440217572578,\n                6019238819083806569,\n                8727766917839869670,\n                17543657322565662173,\n                14412106950578331252,\n                14543869151173063856,\n                7943364918570979252,\n                14084805295748537131,\n                13111098905227599465,\n                11202865977925716420,\n                5996820135817652995,\n                11571287622023775421,\n                5373524677929215301,\n                17153815447258968833,\n                10046961949080008556,\n                14846860571176635442,\n                10338928091935313530,\n                2940317764326823227,\n                1776405787535180450,\n                625809269984863503,\n                17769559239543673204,\n                3118489222192938565,\n                13250086689910946329,\n                15923099038962390019,\n                10822567853940674338,\n                6978627730782203076,\n                2595174935535264194,\n                9243536850072179353,\n                3406470433637984371,\n                3073959449450317144,\n                15861711889629424487,\n                11928324792455649636,\n                13550524272193533110,\n                15780700931447669545,\n                10131935114090648897,\n                5340317636333714216,\n                15339343608558820412,\n                13396278126027078678,\n                12344841862313043381,\n                12566090228569145515,\n                4467783437523316260,\n                17567821697166775078,\n                9779110602238335971,\n                11793438626400388253,\n                2497240398513373223,\n                10605325543162108671,\n                15082988041680062339,\n                5183965453682540694,\n                6434074123110416631,\n                11620219770967033588,\n                6206234705311197318,\n                9042208974224880901,\n                9727369898804305283,\n                4647900181451243158,\n                9318060116894502304,\n                5257285210765950994,\n                13361487866051577136,\n                3441585901560937350,\n                2240964027883718235,\n                10026719207153507368,\n                17290246452243511459,\n                14480168376982470724,\n                7629280450957209642,\n                14474347826383962832,\n                11317012819726516750,\n                2962115003543065613,\n                12162772852283897343,\n                7157384874230657509,\n                6851750854456963926,\n                15390047842623433503,\n                5489411047155759331,\n                6332140231414210853,\n                11095975516180329805,\n                13859585413297997655,\n                1668754947299094584,\n                7358928682129827290,\n                2766327988455105348,\n                16708694722996588875,\n                2768953098861172595,\n                6914880772284915541,\n                16557166180686635628,\n                3693170667429108001,\n                16072312986624846808,\n                9896456787099841815,\n                17615200765944957338,\n                4199047158638921808,\n                8630520885961961356,\n                12027685245286153560,\n                7891368337618414637,\n                6404928949401724730,\n                18116758261578934492,\n                894858370047540031,\n                2921629729181210457,\n                7745289541745323639,\n                11350346089330756111,\n                10152653266983330591,\n                14798328937825324211,\n                8949208387022094213,\n                17787392503905898329,\n                12486460963965989428,\n                651591352658579316,\n                1237562200852981434,\n                16003240939391023959,\n                6420739448387256570,\n                4823415470543283046,\n                7174592656453798147,\n                11424373324798981360,\n                737331696961998974,\n                4118748058691239361,\n                14616473443770035549,\n                17650444454043907647,\n                17711200809424400157,\n                5091501578910147488,\n                15550101363878126041,\n                4566810755429043240,\n                11107983018581197120,\n                13554292788177360136,\n                3365373296985431135,\n                15610147292789460654,\n                3564088093422756616,\n                10817889322783172996,\n                16159632643279358168,\n                8597419859706760838,\n                11079829268996560033,\n                17269507137857304393,\n                9947618800967513663,\n                462576820491406287,\n                841015303753696179,\n                15512002278736704978,\n                3374877754464709299,\n                1154757937962396227,\n                9537134004482849819,\n                10128571182745135555,\n                3704274043469819984,\n                15034886915357192640,\n                916221862035256124,\n                17425598900953186568,\n                3947379328146942835,\n                3660680652792309828,\n                5007284878115686577,\n                7522847462384788182,\n                10571799915899197168,\n                8013565820738950446,\n                3966675855215748889,\n                129692155915043627,\n                5691183223879520601,\n                12139669617779071047,\n                11814058524451360978,\n                6775079055986650672,\n                16825782776226623043,\n                5104813292662071339,\n                1450815249446379483,\n                13853175235386092441,\n                6694335922759190067,\n                7218434162566164191,\n                17430813386582913632,\n                8498332674216771915,\n                17615391640730478338,\n                241596204271102644,\n                2570852601221578960,\n                4599802214241276374,\n                10438837029660804288,\n                5157548795688936967,\n                3798153122426926247,\n                2692303022775628041,\n                1447520878810147944,\n                5855192377386493733,\n                6514581604771681776,\n                1473660589499588222,\n                18307281621256799329,\n                11125509395109998281,\n                2435145631387070987,\n                1285271838144216244,\n                4541083490208481993,\n                15565142710078764855,\n                13071820190366239674,\n                10807442981250235320,\n                16852181421674849736,\n                794202264952966952,\n                14267784245260213795,\n                13928008029423527207,\n                18135353902736935922,\n                2114431837901815099,\n                6130665714725128892,\n                14739842984474439614,\n                7454369312678179513,\n                15910289572447146154,\n                9146362349279587472,\n                4658814649895066035,\n                4852338178188865614,\n                2192949132388551398,\n                716457667898608901,\n                2399899887449189428,\n                13124730724498682787,\n                1984867750527727115,\n                3299889278515997731,\n                8195306963169862777,\n                14475785604327151063,\n                12724460465724812829,\n                6758639346286631138,\n                15913784793216142830,\n                13171932495254154817,\n                3538643548410335706,\n                12168540036106852345,\n                16425314134821469021,\n                331063747268359873,\n                18155850216697850278,\n                211510699789398426,\n                7935466970847300822,\n                12229125293409986487,\n                8734112355949291277,\n                10071615545797653112,\n                1793864989578041612,\n                11752738563545219357,\n                2554337087062880546,\n                6784160661654190401,\n                685578570200418652,\n                2732494065060693551,\n                7703734784123999976,\n                11477040429265293999,\n                17381175706019390228,\n                14837293364696097009,\n                4833703890663686653,\n                2761757739428920605,\n                9412696259424618339,\n                18336993413001201202,\n                5392220203502617737,\n                12132875900848494122,\n                5897666419764808427,\n                10107214772704578306,\n                5834665481992921890,\n                2244306519766258831,\n                5820675501905835926,\n                13895182007484584312,\n                9733080033395096503,\n                17951749141696177588,\n                7852600446374176592,\n                642107575067795990,\n                16064679065784673939,\n                6040352419222121316,\n                16970428073606505636,\n                433090259886128885,\n                1549830981278788516,\n                3028881619520159752,\n                12587143878061487305,\n                7306602487976240524,\n                6069082702714594855,\n                8317005307998462740,\n                11586696275428727811,\n                10124520395695439236,\n                2195436795699758658,\n                14913315324971455554,\n                5466516946326216931,\n                1717042106502750014,\n                17693487700744112539,\n                17312324646637390229,\n                12185008789555994527,\n                9030058640985830041,\n                10443142281726880983,\n                15264441814628501960,\n                4146653965712179952,\n                8027211328596986571,\n                8811720185546566650,\n                5690186672540385493,\n                251818496025458043,\n                10345253390016854955,\n                7346199546033069539,\n                13632205746357973720,\n                14506822790046125209,\n                12522294874687963723,\n                12449500355426750184,\n                16764643529091852379,\n                2638044797938755324,\n                18319874071056096586,\n                14888037590772700254,\n                6416648884059549407,\n                3741778762412317117,\n                3440707741509585117,\n                6047470481787558630,\n                2492811946256114988,\n                17943897517735339646,\n                16834876807347850875,\n                11693943181588820350,\n                9934491754613191232,\n                7118638609538842310,\n                6721145656345173892,\n                7927663645875889614,\n                4114384607638700718,\n                11775393055826824993,\n                12784890791525439800,\n                2959297838067480856,\n                9238429361931549659,\n                15825672608139947803,\n                3094848335709726824,\n                8091746658688215399,\n                7128309512560006037,\n                3784265539610231208,\n                17653881331317683086,\n                13833532758351825783,\n                3974699445166882529,\n                18126794112732677537,\n                3900550060852543519,\n                17913516784410626641,\n                14238655509846810037,\n                17818640735092102056,\n                14112661809980388763,\n                16347084184144786237,\n                7317578804055819219,\n                15985432390504555226,\n                16103870553153834573,\n                3533821776202300649,\n                8924951458298615732,\n                11378896973645739060,\n                8417337589693233698,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_fail_1() {\n    let ns = &[1, 2, 3];\n    let ds = &[0x80000000];\n    let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett(&mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_fail_2() {\n    let ns = &[1, 2];\n    let ds = &[0, 0x80000000];\n    let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett(&mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_fail_3() {\n    let ns = &[1, 2, 3];\n    let ds = &[0, 1];\n    let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett(&mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_fail_4() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[0, 0x80000000];\n    let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett(&mut [10], ns, ds, &mut scratch);\n}\n\n#[test]\nfn test_limbs_div_schoolbook_approx() {\n    let test = |qs_in: &[Limb],\n                ns_in: &[Limb],\n                ds: &[Limb],\n                q_highest,\n                qs_out: &[Limb],\n                ns_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n        assert_eq!(\n            limbs_div_schoolbook_approx(&mut qs, &mut ns, ds, d_inv),\n            q_highest\n        );\n        assert_eq!(qs, qs_out);\n        assert_eq!(ns, ns_out);\n        verify_limbs_div_approx(qs_in, ns_in, ds, q_highest, &qs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - q_len + 1 < d_len\n        // - !highest_q\n        test(\n            &[10],\n            &[1, 2, 3],\n            &[3, 4, 0x80000000],\n            false,\n            &[10],\n            &[1, 2, 3],\n        );\n        // - !(!flag || n_1 >= d_1) second time\n        test(&[0], &[0; 4], &[0, 0, 0x80000000], false, &[0], &[0; 4]);\n        // - q_len + 1 >= d_len\n        // - !(!flag || n_1 >= d_1) first time\n        // - !carry second time\n        test(\n            &[0, 0],\n            &[0; 5],\n            &[0, 0, 0x80000000],\n            false,\n            &[0, 0],\n            &[0; 5],\n        );\n        // - highest_q\n        test(\n            &[\n                2694350779, 1945458005, 4130424186, 4267238024, 2588565427, 561074857, 3031728663,\n                2495857464, 1122008234, 2280094424,\n            ],\n            &[\n                2460989955, 642673607, 1971681331, 2338977519, 475442971, 2516527409, 3470931196,\n                4262052990,\n            ],\n            &[\n                1430162564, 1873089879, 3090281851, 2861182896, 2502166555, 2486624904, 960387080,\n                3073064701,\n            ],\n            true,\n            &[\n                2694350779, 1945458005, 4130424186, 4267238024, 2588565427, 561074857, 3031728663,\n                2495857464, 1122008234, 2280094424,\n            ],\n            &[\n                2460989955, 642673607, 1971681331, 2338977519, 475442971, 2516527409, 3470931196,\n                1188988289,\n            ],\n        );\n        // - !(n_1 == d_1 && ns[j] == d_0)\n        // - !carry first time\n        test(\n            &[\n                2678906106, 1133029551, 3498992572, 3960506675, 2156562886, 2180928089, 4027866586,\n                3363079195, 2699625088, 10633112, 1776348429, 2657266039, 366882369, 3755249663,\n                1513004482, 385462618, 1235118123,\n            ],\n            &[\n                1454965277, 156018042, 1386304234, 3933017003, 1840527397, 4169420651, 3343338814,\n                1487329926, 3897306601, 3401241545, 3117994664, 2264466925, 3843062712, 3688462745,\n                2751679318, 2963108470, 1519717633, 1232770303,\n            ],\n            &[3907037329, 1526550202, 2796269294, 2117183522, 529127946, 3581684574],\n            false,\n            &[\n                804693922, 2514269410, 4036020089, 2186548072, 2508423987, 4057814367, 1906755998,\n                3240890878, 892733317, 778428899, 2723150360, 1478273149, 366882369, 3755249663,\n                1513004482, 385462618, 1235118123,\n            ],\n            &[\n                1454965277, 156018042, 1386304234, 3933017003, 3311017948, 2590855881, 4216998583,\n                2363684544, 3240958306, 2015516746, 4229646813, 3042340787, 3637479002, 2452334854,\n                2707761200, 1588607308, 1519717633, 1232770303,\n            ],\n        );\n        // - n_1 == d_1 && ns[j] == d_0\n        // - !flag || n_1 >= d_1 first time\n        // - n_1 == carry\n        test(\n            &[10, 10, 10, 10],\n            &[0, 0, 0, 1, 4, 0x80000000],\n            &[3, 4, 0x80000000],\n            false,\n            &[0xfffffffc, u32::MAX, u32::MAX, 10],\n            &[0, 19, 0, 0x7ffffffe, 0x80000000, 0x80000000],\n        );\n        // - carry first time\n        test(\n            &[10, 10, 10, 10, 10],\n            &[0, 0, 0, 0, 0, 3],\n            &[3, 0, 0x80000000],\n            false,\n            &[u32::MAX, u32::MAX, 5, 10, 10],\n            &[0, 3, 2147483630, u32::MAX, 0, 3],\n        );\n        // - !flag || n_1 >= d_1 second time\n        // - !(flag && n_1 < carry)\n        test(\n            &[10, 10, 10, 10],\n            &[0, 0, 0, 3, u32::MAX, 0x80000000],\n            &[3, 4, u32::MAX, 0x80000000],\n            false,\n            &[u32::MAX, u32::MAX, 10, 10],\n            &[0, 0, 3, 0x80000000, 0x80000000, 0x80000000],\n        );\n        // - carry second time\n        test(\n            &[10; 4],\n            &[0, 0, 0, 0, 0, 0, 1, 0],\n            &[0, 1, 0, 0x80000000],\n            false,\n            &[u32::MAX, u32::MAX, 1, 0],\n            &[0, 0, 1, 0x7ffffffe, u32::MAX, 0, 1, 0],\n        );\n        // - n_1 != carry\n        // - !flag || n_1 >= carry first time\n        test(\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x4000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffff000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294705152,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3ffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                256,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                256,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x4000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffff000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294705152,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3ffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                186,\n                75,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX,\n                7,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                256,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n        );\n        // - limbs_div_schoolbook_approx, flag && n_1 < carry\n        test(\n            &[10; 115],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                32767,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2147450880,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294934528,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2147516415,\n            ],\n            false,\n            &[\n                4980658, 4718518, 4456378, 4194238, 3932098, 3669958, 3407818, 3145678, 2883538,\n                2621398, 2359258, 2097118, 1834978, 1572838, 1310698, 1048558, 786418, 524278,\n                262138, 4294967294, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 4294836225,\n                4294836225, 4294836225, 4294836225, 4294836225, 4294836225, 10,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                40271144,\n                2621513,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                65535,\n                131071,\n                65535,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2147450880,\n            ],\n        );\n        // - !flag || n_1 >= carry second time\n        test(\n            &[10; 24],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294963200,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                32767,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2147483648,\n            ],\n            false,\n            &[\n                4294967294, 2147483648, 1073741823, 3758096384, 268435455, 4160749568, 67108863,\n                4261412864, 16777215, 4286578688, 4194303, 4292870144, 1048575, 4294443008, 262143,\n                4294836224, 65535, 0, 0, 0, 0, 0, 0, 0,\n            ],\n            &[\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2863267831, 61449, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967295, 32767, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[\n                13716243670146164789,\n                10080982542333195561,\n                6537250227633874413,\n                12999253343990893001,\n                12265098574469062516,\n                10364481473864190262,\n                3369535821171388227,\n                10993808308731343874,\n                2872517547503231658,\n                12291082106617508077,\n                9131160905399738920,\n                6775211851169928012,\n                8910327134129798117,\n                14142305268873431891,\n                7124925848807234985,\n                2155988926103471984,\n                10449767567966035946,\n                9346026815749340730,\n                1047855496984265723,\n                8616868492917905090,\n                6520418679719901901,\n                7627787833874912128,\n                16237358816885147630,\n                18338579662632174061,\n                13533819409691495819,\n                8877538849543441757,\n                1515670908092000385,\n                11038667469728451796,\n                1811062388681013211,\n            ],\n            &[\n                9995257893114397114,\n                9401504468144459131,\n                558615837638945228,\n                10733662027974786928,\n                18295107704289976677,\n                1814706268673753787,\n                12474943759854623335,\n                8814778832826774208,\n                9159057654048965906,\n                4451260977376821357,\n                18241701617364042056,\n                6169989192350218482,\n                15071965537117101028,\n                13509168527678537782,\n                12224278653171635329,\n                16077066393714953826,\n                1433938684868066489,\n                13014970036232570373,\n                899282336249563956,\n                3089487642230339536,\n                3787737519477527148,\n                16667686214395942740,\n                8787122953224574943,\n                7841835218775877827,\n                9693303502025838409,\n                16122224776459879427,\n                144327425397945219,\n            ],\n            &[\n                2350654041004706911,\n                7834348511584604247,\n                12756796070221345724,\n                3842923787777653903,\n                12373799197090248752,\n                9712029403347085570,\n                1426676505264168302,\n                10586232903332693517,\n                8387833601131974459,\n                6290888746273553243,\n                9503969704425173615,\n            ],\n            false,\n            &[\n                89235393247566392,\n                5198286616477507104,\n                15671556528191444298,\n                6642842185819876016,\n                1703950202232719208,\n                6620591674460885314,\n                9897211438557358662,\n                12382449603707212210,\n                13586842887558233290,\n                11884313943008627054,\n                3205830138969300059,\n                4257812936318957065,\n                11084100237971796628,\n                13937343901544333624,\n                11743372027422931451,\n                280132530083052382,\n                10449767567966035946,\n                9346026815749340730,\n                1047855496984265723,\n                8616868492917905090,\n                6520418679719901901,\n                7627787833874912128,\n                16237358816885147630,\n                18338579662632174061,\n                13533819409691495819,\n                8877538849543441757,\n                1515670908092000385,\n                11038667469728451796,\n                1811062388681013211,\n            ],\n            &[\n                9995257893114397114,\n                9401504468144459131,\n                558615837638945228,\n                10733662027974786928,\n                18295107704289976677,\n                1814706268673753787,\n                12474943759854623335,\n                8814778832826774208,\n                9159057654048965906,\n                10156380351246372681,\n                9009005527785483288,\n                4330767427200269309,\n                11409205475757922767,\n                12430752173702915207,\n                11990819624778098799,\n                4145020291153594556,\n                7099200056207569977,\n                3510167930325480168,\n                4731667122118327121,\n                10720310942075546738,\n                5799804483118787221,\n                17268037247251138479,\n                13305947798457087249,\n                1405091439325174594,\n                13072181651983436371,\n                16122224776459879427,\n                144327425397945219,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_approx_fail_1() {\n    let ds = &[3, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook_approx(&mut [10], &mut [1, 2, 3], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_approx_fail_2() {\n    let ds = &[3, 4, 5, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook_approx(&mut [10], &mut [1, 2, 3], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_approx_fail_3() {\n    let ds = &[3, 4, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook_approx(&mut [10], &mut [1, 2, 3, 4, 5], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_schoolbook_approx_fail_4() {\n    let ds = &[3, 4, 5];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_schoolbook_approx(&mut [10], &mut [1, 2, 3], ds, d_inv);\n}\n\n#[test]\nfn test_limbs_div_divide_and_conquer_approx() {\n    let test = |qs_in: &[Limb], ns_in: &[Limb], ds: &[Limb], q_highest, qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n        assert_eq!(\n            limbs_div_divide_and_conquer_approx(&mut qs, &mut ns, ds, d_inv),\n            q_highest\n        );\n        assert_eq!(qs, qs_out);\n        verify_limbs_div_approx(qs_in, ns_in, ds, q_highest, &qs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - q_len < d_len\n        // - q_len < DC_DIVAPPR_Q_THRESHOLD\n        test(\n            &[10; 4],\n            &[1, 2, 3, 4, 5, 6, 7, 8, 9],\n            &[3, 4, 5, 6, 7, 0x80000000],\n            false,\n            &[4294967057, 15, 18, 10],\n        );\n        // - q_len >= d_len\n        // - q_len_mod_d_len != 1\n        // - q_len_mod_d_len == 2\n        // - q_len_mod_d_len != d_len\n        // - hi < DC_DIV_QR_THRESHOLD in limbs_div_divide_and_conquer_approx_helper\n        // - carry != 0 in limbs_div_divide_and_conquer_approx_helper\n        // - lo < DC_DIVAPPR_Q_THRESHOLD in limbs_div_divide_and_conquer_approx_helper\n        test(\n            &[\n                1745715367, 3242831492, 2189664406, 3695710048, 3400938664, 2983493477, 3450434346,\n                3015863128, 3052023755, 2151651529, 1044116780, 1095733406, 3716653807, 297398212,\n            ],\n            &[\n                3142115855, 4096457822, 1432901702, 1952216623, 2397263357, 1868450777, 1021098076,\n                367053436, 1889683424, 1528567953, 3087804116, 689228227, 2409781986, 2752631639,\n                2960393344, 2301774469, 4157044152, 730723095, 338324989, 783259147, 1430926216,\n                364208092, 2781791540, 805329298, 3841626209, 3970169746, 287294352,\n            ],\n            &[\n                1650097037, 2785533476, 2062924184, 1202017958, 802671467, 2646041574, 1723210259,\n                3842076078, 3483645026, 3596926305, 1708140396, 44589295, 3278888837,\n            ],\n            false,\n            &[\n                3307700692, 2732374665, 3119369275, 1963618313, 3967275780, 1010403672, 2386237047,\n                1636315044, 2452324979, 2121986305, 4198504803, 1202996215, 3246857339, 376322562,\n            ],\n        );\n        // - 2 < q_len_mod_d_len < DC_DIV_QR_THRESHOLD\n        test(\n            &[\n                2955158159, 1759170654, 241992668, 2980193182, 840605220, 1045835548, 3208341497,\n                2808694346, 3017377112, 355832894, 950019940, 696314608, 1276063535, 1858415265,\n                60277520, 2139543466,\n            ],\n            &[\n                3731075771, 2226257702, 854739192, 2333168376, 3831123162, 672459584, 2105255949,\n                3941486408, 3063931623, 3785513419, 2454733900, 2814451407, 149252521, 3850018836,\n                2493517320, 445200997, 3777868852, 753763226, 4021231089, 1034604267, 2132847427,\n                3137530222,\n            ],\n            &[\n                270591029, 2232658820, 2961791111, 2169611462, 3306811456, 395960943, 1347788049,\n                792089960, 2698153968, 3485969429,\n            ],\n            false,\n            &[\n                1488408081, 248978519, 2376028816, 407178103, 178475908, 1057954502, 1272791110,\n                1537402746, 43900650, 1842311580, 1675506505, 3865664908, 1276063535, 1858415265,\n                60277520, 2139543466,\n            ],\n        );\n        // - carry != 0\n        test(\n            &[\n                3168925666, 1401331420, 1768122255, 956650685, 3125577762, 275145267, 4000912215,\n                2182857050, 353954436, 2524534987, 1528525099, 1007392140, 2880118216, 2063897965,\n                1760572146, 1006590899,\n            ],\n            &[\n                3431345542, 1730498888, 4138696524, 681428010, 2575604395, 915393966, 2674130562,\n                2622706300, 1008959988, 202234291, 1715673957, 4288131207, 3157817283, 1254299717,\n                1844271939, 2429564694, 1102891971, 4218541309, 2925340256, 2466247404, 3527404620,\n                1380334293, 3436079542, 200877067, 3607253971,\n            ],\n            &[\n                878527761, 3297204326, 2726502278, 1631019758, 1065904878, 1800983432, 346615437,\n                143744864, 473085159, 3630485760,\n            ],\n            false,\n            &[\n                181883802, 1500895548, 839791393, 3438225757, 1702652997, 2997889672, 398115167,\n                3761202175, 3544971480, 1688702060, 207943299, 1616875104, 3637603520, 3111391940,\n                4267483432, 1006590899,\n            ],\n        );\n        // - highest_q second time\n        test(\n            &[\n                2437003791, 645401979, 1378969963, 3859694962, 1591396376, 1173467855, 1717394161,\n                2958783214, 3972116836, 3930714191,\n            ],\n            &[\n                844935929, 1399477695, 2543116912, 837902568, 1404832613, 3601679936, 681919524,\n                1510676120, 4054159774, 3802723255, 3285008709, 2781902552, 2079211469, 3135384488,\n                3124225549,\n            ],\n            &[4097164548, 2480021577, 1254500038, 3382139236, 615831817, 2805966013, 2977211920],\n            true,\n            &[\n                3611312107, 839029826, 3955154288, 3446643589, 690412234, 2545148908, 2572472581,\n                212083904, 3972116836, 3930714191,\n            ],\n        );\n        // - q_len_mod_d_len == 1\n        // - !(n_2 == d_1 && n_1 == d_0)\n        test(\n            &[\n                4235270104, 498278423, 1233560634, 4293074805, 853780813, 1015040797, 3070872633,\n                2324941085, 3436613312, 2914604270, 3125537558, 1989275393, 2102765265,\n            ],\n            &[\n                2411131391, 1285978457, 4193249971, 1729912476, 3951338248, 4289840260, 894016416,\n                2906952374, 3455712241, 1463845617, 1727541890, 1481030343, 1658748062, 1143697602,\n                3292965673, 2291275076, 3088692422, 2745736668, 4049914342, 1746048268, 398577563,\n                1528894241,\n            ],\n            &[\n                2173999991, 2272873400, 2390524858, 1701140046, 320303811, 2196647430, 90814602,\n                3168314224, 2071538040, 267268559, 2660563785,\n            ],\n            false,\n            &[\n                3525126782, 1512399222, 2720117630, 206486370, 3387391711, 3483623607, 1368424417,\n                1794379685, 2200464811, 3921564486, 2468104993, 1989275393, 2102765265,\n            ],\n        );\n        // - q_len >= d_len\n        test(\n            &[\n                2046213120, 118064180, 676462636, 192405947, 987595058, 3117257430, 2648701979,\n                3334098139, 2300211432, 238540576, 1839171291, 3761260665, 1016976338, 464138847,\n                2985769256, 4173218084, 198170535, 2181413355,\n            ],\n            &[\n                3268984709, 3890178895, 3714425009, 922229459, 124979838, 1582051975, 1533234197,\n                1439049575, 1664144928, 3333243233, 508818207, 1681704030, 573822729, 1791263995,\n                978387652, 2703189437, 2825974585, 854916987, 2566023663, 1086830792, 2353550490,\n                2091798094, 2573588469, 1760161870,\n            ],\n            &[\n                4063752152, 180981500, 1829379233, 4014641527, 2812579451, 2652403028, 1486280954,\n                2616093248,\n            ],\n            false,\n            &[\n                918482979, 147806120, 3245881243, 1658946288, 1766790068, 1379341579, 3971780904,\n                1671161699, 2162749536, 1257881574, 3103952931, 1923216828, 1012333274, 3304761773,\n                243084170, 2889743198, 198170535, 2181413355,\n            ],\n        );\n        // - highest_q first time\n        test(\n            &[\n                2272242430, 2854406627, 1305900137, 1975858742, 4025222745, 212032770, 698550929,\n                632227880, 3284689006, 780673660, 395497962, 765997120, 2856842543, 2158993022,\n                20701243, 2016479159, 934398704, 1923839427,\n            ],\n            &[\n                2079043963, 3911491338, 447442849, 3956113252, 1222080016, 639120617, 2598755724,\n                1080730341, 102550561, 3677835688, 4245198487, 1565695097, 2098176177, 3974320562,\n                1241514653, 856068310, 4158641647, 2053124989, 4149048308, 3508898669, 1748966969,\n                1026687354, 3392457811, 3901741824, 3279053517, 763547094, 1818065987, 2992419410,\n                2814961974, 3367454332, 1015324186, 3391900712,\n            ],\n            &[\n                2456150337, 1126994408, 3067336229, 1544722288, 1285201687, 384279509, 1392445337,\n                548923399, 2471923537, 3222966094, 168537260, 3352071531, 2060967172, 2867808805,\n                1744855395, 2564913121,\n            ],\n            true,\n            &[\n                902145632, 1230897285, 1461544881, 3921469470, 3447138679, 4291295264, 3805913658,\n                2179953362, 3669599647, 3982542142, 3582166894, 852760370, 3665299175, 3877964992,\n                3092149152, 1384797257, 934398704, 1923839427,\n            ],\n        );\n        // - q_len_mod_d_len >= DC_DIV_QR_THRESHOLD\n        // - hi < DC_DIV_QR_THRESHOLD in limbs_div_divide_and_conquer_approx_helper\n        test(\n            &[\n                2108009976, 2838126990, 827008974, 4157613011, 3782799311, 839921672, 879731301,\n                1926496935, 3712149888, 2363043408, 3863476261, 1703718215, 499165670, 2993223230,\n                4279694017, 2976095205, 2193242813, 3593708162, 586354096, 296757650, 242624274,\n                199363552, 2802933005, 2759687879, 3925865458, 4217980786, 621040829, 4008464542,\n                3795907109, 270168250, 3625538473, 759155103, 3959828159, 1835721901, 1818377089,\n                114690984, 2967220963, 2377698568, 2241245638, 2252300906, 3116551983, 3644576818,\n                2608501946, 2181270779, 1815210824, 1268283136, 484429506, 1180516809, 559610343,\n                2543044915, 3719740023, 558939794, 3989231279, 1089033996, 3509826828, 3545449066,\n                3353643945, 2822587915, 2300900020, 309191900, 2371088678, 1169317833, 2688462322,\n                704882387, 1429447898, 2514029776, 1955158460, 3862686818, 1584130288, 482000750,\n                4224830364, 2104097699, 1183456674, 2270729014, 2607655660, 2966545947, 2931252595,\n                759652385, 3970839358, 2487392344, 1507124762, 758697388, 3840603988, 1293583672,\n                252424514, 646352064, 1756992845, 2309291248, 3392597937, 2946557682, 3659552460,\n                1720311830, 3395887210, 2674135679, 3196424053, 2895118562, 1256983146, 2482795730,\n                1922474903, 2105232035, 3692384401, 2891711374, 3496171341, 515080177, 4073860792,\n                2051799135, 2279442367, 3258846627, 70977295, 1937954703, 2800340027, 1760719187,\n                646417623, 3158839049, 3176203007, 213391749, 869819866, 3906922929, 1586646665,\n                1614123406, 3687984980, 1177302158, 272342927, 1441818617, 2083855650, 1541781406,\n                3311904586, 106907162, 4108429222, 662974012, 4140594255, 1984524179, 3259771450,\n                3863443649, 3307256449, 3597197635, 3771753969, 3551628070, 3550518548, 2546464879,\n                3812123817, 2299164636, 2258249267, 815945886, 3725185601, 738801212, 3862546442,\n                207778311, 1535617953, 2150997157, 729581295, 143725958, 1410055499, 4204574368,\n                2185442793, 3653861199, 1767186378, 3537808267, 1766021033, 2239408696, 1986025224,\n                3625288948, 4046347844, 2490523057, 3491861717, 1312039469, 597857291, 206880668,\n                1812928615, 3684502664, 3820772609, 1327777451, 1237379465, 764273090, 3594853086,\n                2859643842, 1243019386, 3444655918, 1596721727, 2221238575, 2483346164, 2064518283,\n                2282844430, 1960424205, 4028198846, 2342293800, 1645322170, 3508868511, 2376856302,\n                1764497492, 2461899059, 3430260828, 1083983032, 1448541077, 2081767380, 1131293272,\n                2121152826, 4212689224, 2039367869, 2193844060, 1864700761, 1182989130, 1481869846,\n                969270162, 3997775597, 1483663077, 394034269, 1586435653, 2281434261, 1937512315,\n                836935557, 59742568, 1854699653, 2116629465, 328821302, 1999851100, 604863759,\n                556389113, 2057620108, 1992554416, 427465103, 813735424, 487055225, 402647361,\n                3006998394, 2146302389, 2308517156, 1063328348, 2382344201, 2665908320, 481118926,\n                2376219143, 1164055989, 128362737, 2711666601, 1898018298, 2928344090, 3862251511,\n                749517272, 2790599579, 3506539103, 2592038317, 1682088920, 1332639030, 3053921374,\n                3066891587, 242466377, 3536065834, 2016487096, 1321862427, 2409873623, 3088797737,\n                2840818323, 2052021858, 4079299898, 452968540, 3880575723, 2680668784, 1502544423,\n                1619882634, 1068420458, 3236073318, 1740351058, 1183565882, 2761799103, 246817911,\n                2967032269, 4003972840, 969974269, 3193561842, 1002645557, 2347161653, 4272895273,\n                1522072178, 972383725, 3026624523, 434293193, 2855690795, 2455822196, 2413168892,\n                2999634230, 784531194, 249556803, 2559695464, 3131798530, 668810109, 2114036394,\n                2861740558, 370716909, 2126014070, 3913884200, 1577476936, 855642956, 2074597201,\n                3461659621, 3292762038, 2153122643, 1658901071, 1562860969, 501980289, 1611843440,\n                2433026108, 3791871978,\n            ],\n            &[\n                2325147333, 1406197332, 1502532645, 137754493, 1488912421, 1014222449, 1678300831,\n                2078887154, 2311629707, 3855402290, 1904906031, 1350026944, 314061674, 919972212,\n                1429252796, 544807358, 2607111216, 3001219316, 160533550, 2875169678, 1402474615,\n                3234840532, 1662112023, 1943050521, 4132256985, 2915369430, 699620367, 59590583,\n                2461837586, 3986106860, 2659659366, 3589796255, 4168995860, 2337625655, 4292546333,\n                1793085295, 2647770730, 2871508164, 2660729400, 3630964395, 3874212033, 1240042620,\n                1713051992, 2105061240, 968807145, 3026819276, 2442427316, 2718248469, 2572140009,\n                1793916894, 2112926236, 1058005225, 1528978151, 98430379, 3348888463, 2121431457,\n                3545708238, 3975070402, 764453596, 192861224, 2698588322, 1493819664, 2502294971,\n                3139295505, 1318649192, 1552623529, 2989328476, 1592829691, 1175278450, 182489613,\n                1858350437, 2440903999, 1622786339, 162763913, 4106583944, 609833788, 1344925844,\n                3910333895, 1369398307, 51929280, 2214052160, 78601532, 642016948, 3966440550,\n                4161875340, 3764174238, 2944905670, 832634369, 2082700552, 3444794582, 962611192,\n                38510846, 2733538376, 2141542785, 621670923, 3130866640, 1666281368, 3628581169,\n                3965100367, 2889091703, 762371524, 3752935086, 656901001, 2374421435, 3084212494,\n                1186140919, 3420046356, 775236355, 1337865306, 2051118555, 713071112, 1946850844,\n                1427068060, 3949026319, 3075128554, 438166063, 3975561046, 858907746, 26964870,\n                3843362808, 1461820702, 3090970200, 1037540471, 289966660, 2768763862, 50890120,\n                580189324, 2911422550, 3684738914, 2025034397, 414622319, 2287243961, 3268939669,\n                3547523099, 4011963324, 1768695320, 1859343614, 2123856143, 4141054481, 765801396,\n                359993985, 3668605792, 3613648266, 1778728280, 2547397231, 2456061149, 2562918666,\n                2903450513, 1994190773, 99234624, 3722083920, 4262323306, 202219441, 4201857695,\n                3988878636, 1533308334, 401400520, 1069756554, 2457773969, 2892388936, 3423117995,\n                1944069442, 492036629, 3426800580, 2282483359, 4006366620, 1695364515, 2555180845,\n                1669287836, 349290429, 778467450, 2020203604, 2218159817, 1450404019, 1278304750,\n                2412695340, 1592154884, 3868182043, 2240370481, 3859902860, 1008825116, 412233394,\n                2475457637, 3664379433, 4204584226, 2750684469, 4113507475, 2916584959, 285955744,\n                739598569, 18278051, 3768126932, 2181905109, 2612988076, 1827656088, 1160380415,\n                4160443718, 1846086671, 3050604645, 2547108010, 2828666778, 3252702258, 3885923576,\n                2331974758, 730724707, 1528859315, 4288784328, 3677151116, 445199233, 3304488688,\n                3566979465, 3541025426, 2491779846, 3112990742, 2583249486, 3403111749, 1930721237,\n                3428792463, 2896462048, 2985885576, 1819460734, 21206096, 3560441846, 987100555,\n                2844904275, 84854892, 1268249628, 3963306788, 3338670067, 2504599089, 65588657,\n                321493327, 4249673617, 4150876068, 721566898, 2186945060, 922948272, 1502464627,\n                1426914435, 2906888275, 3454987739, 2609132626, 2073366782, 1058809001, 1226951003,\n                2624503637, 282722778, 1407178266, 3304346308, 3613017687, 2397594777, 161128076,\n                1938083248, 3042822216, 3958145306, 1431161184, 4147630074, 1744618540, 3729847703,\n                2366216428, 2101731625, 2812677939, 3587016062, 1626785569, 3117017254, 3720581461,\n                4254564252, 2400911475, 750362271, 3062375802, 2182368701, 268751862, 2682134876,\n                274793576, 2417658182, 2321240923, 4200603818, 1349142841, 4066976957, 1043247680,\n                679021323, 2933095037, 1621487581, 225868669, 1030678959, 1236344244, 972640788,\n                1784301152, 578117349, 3509551550, 214420003, 3786992737, 802372148, 3562194086,\n                2187046946, 3600373521, 4275090943, 2120016813, 4177241875, 3185774231, 2397692077,\n                1015362399, 2178889151, 3433916223, 1688082118, 1971242178, 236388706, 3802829765,\n                521309115, 2299816689, 3207614143, 1053195464, 3584561145, 1178690670, 2940812254,\n                3321982035, 2754825123, 3073598062, 202404806, 547895545, 1188944547, 1056841779,\n                529463805, 204665384, 850370055, 2063320161, 3724100092, 1180272690, 1398467003,\n                2814052449, 1311768018, 659771105, 3226477227, 4230080238, 2134344405, 1461172705,\n                2728018383, 1816821358, 3231137250, 2012377728, 2206916761, 3121807673, 3037967028,\n                3653505029, 4164239058, 1337501466, 2487452346, 428839025, 3321493092, 2920064796,\n                2750126813, 3635762100, 2659829309, 1992243088, 2359420187, 861816585, 4182313312,\n                1389528266, 2890138969, 2195001695, 576635805, 1974585967, 851480113, 1896534852,\n                3143828462, 4276040597, 3921135859, 2394233682, 2692972118, 2103941456, 3931376544,\n                3790764632, 2278428793, 3381340311, 3516241824, 2923157557, 1276268033, 3471729699,\n                2370137091, 2637023305, 4027814477, 3711009696, 3667995314, 459819000, 1002878772,\n                2658190707, 1189561796, 1831813150, 2874008201,\n            ],\n            &[\n                1703326352, 1625259628, 3642322228, 911402341, 2158835226, 939248485, 3607511108,\n                2863853568, 1611642161, 1312857772, 1839433327, 567060478, 3139863681, 3642698184,\n                3744632443, 712538472, 2692932947, 576185818, 156934113, 518107105, 2803035863,\n                2284220097, 3447382922, 2400125006, 3565062840, 160044186, 3644393084, 4196433258,\n                3391883838, 1115703759, 2380388002, 962895870, 4001772616, 2311278419, 2620271020,\n                3047789793, 3229254302, 3182628087, 2718480927, 2872538422, 1963990826, 2856537226,\n                1729736384, 372544200, 1482170753, 3370665422, 305555060, 4060802437, 1456459795,\n                2848113958, 1036273297, 3245835346, 3355862097, 3242734427, 3313897419, 4230036415,\n                1425594704, 2428756491, 420147714, 3218149930, 1791217142, 2881741659, 3231612869,\n                845372829, 1635665046, 1525482197, 3779462557, 2279005731, 626908159, 2963734610,\n                215448882, 2517668355, 3294128769, 1167990371, 2344651228, 2882002195, 3350056381,\n                3749638142, 476010196, 2304276366, 1088082897, 1927672185, 3316329053, 1174989749,\n                1101596429, 3054511229, 1685228241, 2301284206, 2526016461, 684171580, 3869889559,\n                2606492401, 2114658735, 1419214215, 2779052449, 2594333668, 2225446358, 1211258458,\n                4029343999, 2816277230, 4098142949, 1987363952, 2732004911, 2516355975, 2365350298,\n                1747416524, 3951513077, 3526462790,\n            ],\n            false,\n            &[\n                1303670916, 3965736473, 654490008, 3337248200, 112312312, 2506678400, 713192736,\n                901474194, 2359721047, 1133557120, 3068598661, 3136858413, 4095957211, 3057328754,\n                1900588230, 1315930687, 3273808327, 2821746043, 4255148500, 3072995291, 1472014781,\n                922081554, 1759317078, 149072645, 2712091402, 2134310281, 708105323, 3703209145,\n                2071594694, 8111834, 3766831226, 2182956891, 2525476614, 1478202223, 4199311113,\n                3813148212, 316780911, 1396844257, 2321402831, 1151134318, 848673799, 735789140,\n                1092813310, 738412079, 1895091662, 2947844274, 31103395, 2559694049, 1194304023,\n                3260126654, 1118043028, 1552558623, 3016599055, 1053142289, 446041643, 2615854004,\n                2105823819, 3769707039, 2784177611, 9564629, 580911617, 1979035813, 1479556681,\n                2599744262, 3097426153, 4195176293, 3497554127, 3484306250, 2114827319, 2314051712,\n                1210812068, 4158781103, 478301760, 2027533091, 1682020897, 129914624, 2066167843,\n                3989890251, 1378700448, 170057876, 3992582209, 1541347967, 3421610776, 697014638,\n                2834243941, 3504973679, 630519426, 1551901326, 3092678418, 1136389639, 1806538485,\n                2208151411, 1598302001, 4041410193, 3574334276, 2340664244, 1624426425, 1200740723,\n                2912910258, 671197404, 2272603994, 909857936, 792804858, 3083891114, 3143045405,\n                2389563439, 115312858, 1445242760, 2065820105, 256586994, 1432132569, 1549619424,\n                2631865338, 1674212272, 2599765330, 3713129178, 1590556325, 3610491293, 709987753,\n                3230113618, 1606099993, 3453954266, 3501213811, 3278809492, 3770342657, 1534951916,\n                1366321311, 3149479124, 3987513652, 2108936446, 1162972378, 279205823, 3711325879,\n                2278557694, 2305274058, 3709507652, 3805940202, 3778288085, 1061153771, 491180471,\n                479623642, 2960728114, 553156023, 1863065855, 2253455830, 14222934, 2488687289,\n                3378176628, 1136227234, 3805644784, 3175842224, 463501844, 2100687360, 2025076951,\n                4064921772, 1000043802, 2482142143, 1463585061, 1044328896, 3966669663, 1023595412,\n                2689537057, 685044345, 2599439954, 3302022962, 2669841238, 3358991646, 351579450,\n                2303934592, 2098132645, 2239011851, 1623838039, 790570033, 2288992150, 2252675624,\n                2479618080, 3624986625, 2129338944, 3796999988, 465518072, 620957443, 1836556967,\n                2894771224, 2904933718, 287211723, 1386209013, 2288387719, 162551270, 370319691,\n                2924564913, 2947669880, 3390862854, 1797811, 3097227838, 2245950593, 1664498395,\n                3380635348, 3536484871, 1217287925, 3149066538, 154911037, 1960867817, 4238493382,\n                1991791660, 509572665, 3386968719, 3880405816, 2335816696, 2519967410, 3482574698,\n                1501302597, 2415671279, 715902305, 1920401004, 3735445496, 1792155851, 2110622431,\n                3695395614, 3311496726, 4035668560, 187609524, 3743601469, 2990357125, 3084998227,\n                767424914, 1388627321, 1381810466, 3799640235, 1423360242, 3375037167, 979951340,\n                3463933333, 387599460, 229837304, 1394766077, 1068156038, 1135935924, 86516134,\n                142150630, 448211640, 3205606056, 1420159909, 4203558153, 2816235778, 4188064475,\n                1490981561, 2934083684, 2693435736, 1351552613, 962789901, 1071201732, 3244341475,\n                1855681940, 4210620238, 2129345127, 2909949483, 3992748944, 3928807766, 2014533910,\n                3099391001, 3112195816, 4009296318, 1247610431, 1474512546, 2530880557, 3597268331,\n                764359883, 4198267775, 1228639730, 736768887, 396797847, 799410613, 582496441,\n                2658423343, 1643853660, 1258585041, 3767032705, 3709454541, 892807168, 1443895160,\n                3500326521, 784531194, 249556803, 2559695464, 3131798530, 668810109, 2114036394,\n                2861740558, 370716909, 2126014070, 3913884200, 1577476936, 855642956, 2074597201,\n                3461659621, 3292762038, 2153122643, 1658901071, 1562860969, 501980289, 1611843440,\n                2433026108, 3791871978,\n            ],\n        );\n        // - q_len >= DC_DIVAPPR_Q_THRESHOLD\n        test(\n            &[\n                1253234102, 1407423154, 1496099965, 1695523232, 4087895045, 3633064637, 1918073940,\n                1994089224, 2894393019, 3803250781, 3557289532, 855915119, 825886212, 2854426287,\n                3305239731, 1558916547, 14680883, 2283482810, 1975429241, 3696056256, 1225143894,\n                401826166, 1805660989, 1715696159, 3407333066, 671337274, 3930782284, 615690969,\n                1799309743, 3261619710, 2139755586, 1418298860, 1130149390, 2049944334, 3646689909,\n                3742182516, 3450706114, 1620481751, 911179844, 2537827243, 1863349000, 2588289405,\n                1379393302, 290595733, 3551967170, 597631845, 3116406696, 418522057, 3052889123,\n                3602625940, 282818149, 870470676, 2360142740, 122311196, 1285732945, 3338688058,\n                2358904627, 1717417860, 1010819896, 1162692117, 745279285, 2988897615, 3882583107,\n                1500499444, 868916372, 1937848809, 1694462512, 3596830383, 3102959500, 2042575803,\n                1732232437, 2619341801, 1399365095, 1742239855, 3363053286, 2955047192, 2536114731,\n                797861027, 3390102223, 1284755330, 1346331125, 3841540834, 224493549, 3323242612,\n                1489837409, 424629037, 2887418470, 2691856116, 51264601, 1998453260, 3606432589,\n                270475934, 1351120072, 13779558, 1467138526, 1834087227, 4205762576, 1570218025,\n                3941564310, 1908199096, 4049815285, 3522198110, 1100468986, 2461406603, 2479269826,\n                536560408, 3804672262, 4126365829, 495636874, 1441896026, 1313080761, 3619143141,\n                3430175499, 1671147767, 461789206, 1605289369, 3711914422, 3538203337, 2188319161,\n                3278799759, 3020736936, 3471537210, 399986340, 1968814758, 969264551, 3530350534,\n                1969502380, 147661179, 3137298512, 1364101497, 1404388912, 1303215423, 2286919520,\n                3249572742, 3330831913, 3586493901, 3162077775, 2991387015, 3706115087, 169578752,\n                1159180539, 3934133734, 558035602, 2925779959, 4063767692, 2885217884, 2752907569,\n                1140725464, 749603258, 672416514, 1032385258, 3864779512, 3712562196, 3208066496,\n                2643074326, 3543548657, 3720627664, 632092389, 1636851426, 594140763, 69489824,\n                2777250607, 2306083065, 3916911258, 3141155998, 1993475481, 68784498, 1770067486,\n                1998044447, 2520569326, 1992263322, 3101331801, 140848189, 3764741027, 1978515439,\n                2361982733, 3127443736, 2897381492, 1302677523, 887097058, 1952041780, 783608822,\n                1097624715, 99755829, 536819342, 2899797741, 3314381803, 4190434837, 928227057,\n                3989607704, 3914272902, 3196195572, 1073079639, 3400734903, 3946657062, 3174732283,\n                2855002505, 1996931952, 2245019261, 2712989234, 1251678454, 578021470, 933525407,\n                1735185706, 3242693894, 757877465, 1570544476, 4054554610, 4232789, 1769248079,\n                3386476948, 1651095046, 1722645365, 3742083849, 249564447, 260470985, 926270254,\n                1849290911, 936613977, 2807355918, 799601174, 2973430993, 3630517123, 1010630102,\n                1596332202, 3693726207, 2696180764, 256508517, 2935861013, 2617574366, 2142295104,\n                1294973507, 4038702029, 3944607195, 3841990618, 98499149, 876432870, 2276059480,\n                2682515232, 633274451, 3670159674, 2039570585, 3672264107, 3435333464, 722344600,\n                590278704, 3403124564, 2414477570, 3921713319, 2561609021, 966607910, 3391894575,\n                1125597344, 1769874536, 1258228103, 1862948975, 3973133769, 2533256421, 88292560,\n                2813190491, 3533833187, 413327252, 3841705126, 2608177858, 3676328284, 2614193419,\n                2483046806, 692717429, 3846808159, 379277707, 1669205079, 4233020303, 1294972508,\n                3928564917, 2407908590, 744791264, 3255079725, 3753322493, 472420344, 1166843119,\n                2467000669, 4140405991, 623716212, 1139273119, 3354207202, 2025876056, 1890550355,\n                3308875843, 4187315065, 568191796, 1415565133, 2687244643, 2241676607, 2580202219,\n                1708640561, 390914458, 3510831086, 1856289438, 1473240478, 2516164037, 56978641,\n                4018676274, 948004161, 2713281743, 1119094116, 1836707971, 65506862, 2266057879,\n                3850031360, 2402902235, 1355795078, 3048720123, 3936358528, 764696513, 3500940987,\n                3117850578, 3798438683, 4211733833, 972363431, 1880167313, 253714622, 76302969,\n                2144921929, 594588250, 3419391407, 110436200, 3019984992, 1696068166, 1311459144,\n                383767145, 4278876264, 1806767552, 478592754, 3307398109, 2106194092, 1374406895,\n                512715289, 2870580756, 1992431788, 63343676, 697633985, 890054481, 1959129172,\n                2577805590, 2764027866, 2020028848, 3876787343,\n            ],\n            &[\n                861890943, 516245383, 733102822, 3373234349, 110977034, 4271239715, 1739646310,\n                3430038451, 2971068856, 1353792561, 273988221, 3727621506, 1880644317, 1169807252,\n                2221765190, 645570626, 1827088960, 1940915885, 4161457279, 3100425720, 996251533,\n                95565099, 1073046961, 2253764580, 2391616729, 3098700232, 106646536, 853783579,\n                1589281984, 1966496578, 2971444515, 4208062631, 3919529557, 3375641417, 1678790027,\n                3548362465, 4197401264, 4152189205, 2578742796, 2352527389, 1289840774, 383594740,\n                604487604, 3605617314, 1576995811, 2410149432, 990820085, 2546262411, 2154758716,\n                618380381, 2206847289, 3469453827, 1341806652, 1019433523, 152426111, 2749431433,\n                3607895359, 3011391435, 1478694163, 851990590, 1027992752, 1059272616, 3480493466,\n                1488043252, 1392852266, 3113620249, 4146237371, 2130545233, 3935615262, 1894052325,\n                3086808567, 1407836003, 3747705872, 2582628925, 4262889138, 874765444, 2961363842,\n                680545553, 2488989749, 3345785826, 952704427, 4098093425, 2516922879, 211154154,\n                1759131069, 1700311172, 2393378850, 189990019, 3378862840, 1411934279, 4058568121,\n                2905294981, 3913230880, 3855904011, 1536608211, 4114811350, 387292488, 691407511,\n                2360232735, 1725740094, 50400678, 3408982759, 2861477438, 2945536307, 3193284782,\n                2711749342, 658984109, 343184872, 1067289865, 2232608224, 4027855946, 3835625791,\n                3914871156, 3647728511, 2766962294, 1158831068, 1928020015, 1802324187, 1465396891,\n                2797410329, 3693678708, 1474899877, 1451659497, 2793780175, 3408416157, 698362941,\n                1638711078, 2942583266, 3345553229, 3337125778, 3898736345, 3233933201, 2121187878,\n                1375122421, 216315377, 285271552, 153543683, 3787450620, 18426473, 2074179790,\n                3707951065, 4276245641, 3503168626, 1741007520, 46035775, 1938996412, 2285217270,\n                1291171645, 4224874181, 602464202, 1803057980, 3577626393, 355587957, 3077316668,\n                2374221701, 2965264159, 1074621373, 4162088640, 2550826771, 2808953809, 1252092668,\n                3357187794, 476206830, 3584460445, 4065428738, 633814711, 2880883917, 3884516376,\n                1513164555, 3300578942, 1670837060, 1132213662, 3351202257, 2610012791, 3257259539,\n                3160483911, 2266079247, 868822128, 4250370567, 1331943301, 1945818535, 1393345318,\n                2060415706, 908741824, 4156794744, 2564813613, 905212060, 3218738129, 3262255881,\n                2263542766, 1227381935, 3663658012, 2226973450, 4231561520, 2818168164, 2670361969,\n                3318293987, 725644295, 4019758576, 998642393, 495827676, 3734906270, 549931550,\n                3628965188, 3223395992, 3590294271, 449855696, 1500765851, 2275616292, 2735068879,\n                2797134520, 2639621186, 4044997105, 3174110149, 13220550, 3092556343, 1435605571,\n                3386705521, 3831842284, 3500054590, 812912044, 2329469982, 1723309995, 2307452017,\n                3303104792, 309903689, 2189249934, 3636229896, 1168371322, 2203364016, 56316585,\n                1507047047, 3978350651, 1287006021, 4136822779, 1754090185, 2908593163, 1172296646,\n                1218980475, 2947600132, 2403727272, 1587640760, 1122215884, 54808095, 1625907344,\n                3722900656, 845603689, 1328648304, 1556638437, 3283968864, 3011502249, 112044910,\n                3596114169, 1850965401, 272070320, 1659402803, 3430852231, 4069438789, 2244303862,\n                651616701, 2182731301, 636443810, 1069166894, 1406346119, 749190002, 1954541375,\n                1807738880, 1450920040, 3158039132, 825986184, 4212536016, 1808707022, 2850318233,\n                429694363, 4071098452, 1248651330, 2275666509, 838162196, 1424879694, 776592838,\n                2740483790, 1284163517, 1280694131, 1134770642, 2077202374, 1206292163, 1284319127,\n                4184450872, 562093874, 952059065, 2799693572, 565666121, 156186725, 2849625182,\n                1184911783, 1502520806, 633585326, 3853907607, 2739083441, 1951262688, 103314579,\n                3831503747, 2993941865, 2470035934, 1778816965, 3674359762, 2878370279, 1350386433,\n                2408142731, 3015205620, 3043051127, 1655111158, 3773182311, 3910770118, 2947352886,\n                3356936393, 2844618418, 3298179444, 1279762744, 2973165223, 1721543619, 4040357913,\n                2673457267, 2733636953, 3004389294, 2106808579, 466071136, 2720455489, 900027010,\n                3351752905, 386568249, 3758644029, 66397961, 2459306698, 2672898173, 1655443171,\n                3369301491, 1855362811, 1446321007, 2158536501, 1872565755, 3914900675, 1397039644,\n                13190889, 514173561, 931870314, 594435363, 1526203696, 2400586492, 2299132127,\n                2876601263, 565427241, 1381196042, 2872681002, 3103160824, 405911440, 954740851,\n                675181390, 2686349099, 4136963415, 4220549550, 2370055970, 3163147061, 4154464526,\n                3976152950, 3281076036, 2145465814, 1952261737, 850385895, 4035222541, 4292853188,\n                187378739, 146395110, 3997223188, 2808707041, 983334910, 2236221581, 1884459573,\n                2703940487, 4077202970, 3803155817, 1872492268, 2837348007, 3074452453, 479001365,\n                3913048191, 3515475086, 4132420828, 3086255747, 4198950954, 3294929815, 811732388,\n                2548414145, 1396214061, 2394099307, 4068762174, 526147562, 1076045316, 1123992450,\n                3733570622, 4220579043, 889069266, 2894360531, 1971615205, 2766482958, 4265953201,\n                2973723720, 3986781638, 529293577, 1884138947, 510069540, 1743552552, 812713578,\n            ],\n            &[\n                2625866541, 2810579078, 3501644219, 2416714925, 1291740196, 3660307741, 2609642196,\n                2505392144, 1722898427, 1674316556, 1432469984, 4097335408, 3108223053, 1374639232,\n                1851930259, 893716755, 2663933335, 1737930775, 3657985359, 3660388910, 2695083669,\n                3386383098, 267519188, 3888348035, 1835595210, 2613536126, 4114884836, 2142604605,\n                8565287, 1755951705, 4130425802, 2850158056, 2234922350, 1949213237, 2449412937,\n                1402509673, 3986161632, 1988171673, 4272507706, 3260139743, 1807943254, 2734619085,\n                740216746, 446923648, 1965334425, 3397454741, 809048263, 494222614, 1484571594,\n                3636917813, 1079987980, 3243842717, 3971186898, 338155234, 863804008, 1792493616,\n                2522062802, 3816014339, 2741664304, 222474042, 154928734, 2936845361, 1353872451,\n                3808072940, 334383012, 1793621170, 2698841688, 3751625796, 3312001535, 1308411945,\n                2231283256, 3335332368, 2732745501, 2266806470, 383612527, 3711228074, 2478058102,\n                2078994051, 975470800, 4179961686, 2605205960, 4060526006, 2648539390, 992385227,\n                1710490965, 385423846, 824778193, 2349766631, 1760192209, 489319807, 2127640163,\n                339639147, 2672582271, 1527261122, 3929636146, 3273385907, 51468511, 4261991464,\n                1868351312, 413372128, 1083615978, 2931924886, 3886667243, 2763475974, 2738582447,\n                2397672301, 2259776571, 2115277994, 2148277873, 2696639925, 1519841204, 811678952,\n                628203566, 2552032086, 4011447443, 3160851596, 258941070, 1535778333, 4063703767,\n                1926535070, 303663750, 2997548738, 1835822843, 2093980860, 1428491141, 3798948389,\n                462487877, 2937763495, 3558060512, 87869235, 3064605488, 295532817, 92123524,\n                2923122754, 569558082, 310878410, 2667249293, 1502523772, 700589809, 402354610,\n                1860279993, 748794047, 3648640215, 3110702404, 2258574876, 2773396367, 3517237080,\n                2990861341, 331348076, 1212514551, 962158293, 1191845582, 2112876079, 2501772177,\n                2831655935, 3995296179, 3011183472, 4288287857, 3132719253, 1897663845, 2153050331,\n                3461291371, 57799706, 461541578, 1483239302, 28451101, 895953744, 3368918207,\n                2594694002, 1268319513, 973441686, 3311571754, 2019274316, 4123248452, 1446014889,\n                1417571585, 615477194, 2194462687, 1708163105, 3293326615, 3383426484, 606654074,\n                1070117839, 630146344, 2571257218, 3961968468, 1929710282, 1868034367, 403216466,\n                3088416046, 449849638, 443975756, 1551823500, 3682150448, 3283842757, 4232686157,\n                4164057310, 2186087032, 2166995410, 3181021883, 3318208525, 2768887999, 2877385605,\n                469197960, 363931824, 752117713, 3980786726, 4244751154, 3858512024, 4033177219,\n                3536702242, 3001143104, 1049662321, 4154276130, 2710845384, 1882050975, 2307442635,\n                2303006043, 1063921606, 92351540, 1383930617, 3560089905, 2221914576, 3599852592,\n                2796496568, 2234040425, 3492209128, 469541171, 919249352, 4275860868, 3002397499,\n            ],\n            false,\n            &[\n                3585575447, 3122160444, 2645674960, 4091549360, 626365202, 1144617016, 3462810264,\n                127827394, 3154238169, 3508098827, 4065321164, 2627720920, 3399886577, 3188051673,\n                1639089029, 2016161381, 1581970985, 237731508, 3479558677, 1944880307, 2562503556,\n                1795700699, 2609445006, 1116190050, 1146777337, 1200401433, 1157695328, 350844679,\n                3282708071, 2845229536, 459139289, 3375883464, 2424175740, 3193435758, 432712800,\n                3851580195, 993388507, 3458606683, 3233513818, 1868436357, 1353535090, 1991321983,\n                1598253594, 3580022384, 1800608735, 3030838485, 1479344427, 2146117321, 3615628302,\n                1468724143, 2513216309, 2478400520, 1881309170, 3573465816, 191069649, 2319303987,\n                36912024, 1056835502, 4085803346, 2567638548, 3614176540, 1774136604, 2502728501,\n                2178987690, 2079375302, 2975418245, 761382377, 3364876440, 3617579499, 1451615440,\n                3143305641, 2435105671, 2844406164, 1247246351, 894541250, 3633445851, 214286649,\n                1891108578, 2579284088, 307573789, 3098902942, 2276329990, 3682940322, 2840709312,\n                3778212298, 2325451725, 3477808517, 31838273, 2670981675, 2270297375, 465284332,\n                2697844185, 2622424439, 4051875556, 814914907, 2448623943, 1299744713, 1873124502,\n                2036773577, 3689282510, 975141741, 1207881273, 2818435693, 3863231130, 3098155233,\n                3073113139, 1724416932, 774815313, 3984444108, 1380084993, 825030359, 1705088193,\n                124122371, 3659155851, 2518826336, 528672560, 2665679696, 1402818456, 782001915,\n                871778931, 2353626471, 685023982, 1884443856, 4156627926, 64651699, 1586126662,\n                1522765556, 3831765770, 3303426700, 2833111857, 928056991, 1307034056, 3386313127,\n                3415959770, 3498516705, 1932766589, 2313751714, 366206234, 3192561873, 2943917337,\n                1140687467, 1640175340, 3542041198, 2895665827, 154126416, 650854034, 2789160074,\n                352460908, 1351655152, 1980048568, 2172281721, 3543770557, 2365332223, 35300985,\n                1050292927, 1349692310, 270125821, 2579494270, 3106522063, 4229421146, 471231049,\n                13349434, 2438602373, 1915124258, 2193214542, 3087834620, 276889911, 2493806637,\n                2402232776, 556133444, 1874277037, 1783512114, 1442646686, 949037422, 4233276648,\n                1359566262, 564784663, 939635477, 1679428216, 2650897503, 1481863691, 1162596971,\n                1097624715, 99755829, 536819342, 2899797741, 3314381803, 4190434837, 928227057,\n                3989607704, 3914272902, 3196195572, 1073079639, 3400734903, 3946657062, 3174732283,\n                2855002505, 1996931952, 2245019261, 2712989234, 1251678454, 578021470, 933525407,\n                1735185706, 3242693894, 757877465, 1570544476, 4054554610, 4232789, 1769248079,\n                3386476948, 1651095046, 1722645365, 3742083849, 249564447, 260470985, 926270254,\n                1849290911, 936613977, 2807355918, 799601174, 2973430993, 3630517123, 1010630102,\n                1596332202, 3693726207, 2696180764, 256508517, 2935861013, 2617574366, 2142295104,\n                1294973507, 4038702029, 3944607195, 3841990618, 98499149, 876432870, 2276059480,\n                2682515232, 633274451, 3670159674, 2039570585, 3672264107, 3435333464, 722344600,\n                590278704, 3403124564, 2414477570, 3921713319, 2561609021, 966607910, 3391894575,\n                1125597344, 1769874536, 1258228103, 1862948975, 3973133769, 2533256421, 88292560,\n                2813190491, 3533833187, 413327252, 3841705126, 2608177858, 3676328284, 2614193419,\n                2483046806, 692717429, 3846808159, 379277707, 1669205079, 4233020303, 1294972508,\n                3928564917, 2407908590, 744791264, 3255079725, 3753322493, 472420344, 1166843119,\n                2467000669, 4140405991, 623716212, 1139273119, 3354207202, 2025876056, 1890550355,\n                3308875843, 4187315065, 568191796, 1415565133, 2687244643, 2241676607, 2580202219,\n                1708640561, 390914458, 3510831086, 1856289438, 1473240478, 2516164037, 56978641,\n                4018676274, 948004161, 2713281743, 1119094116, 1836707971, 65506862, 2266057879,\n                3850031360, 2402902235, 1355795078, 3048720123, 3936358528, 764696513, 3500940987,\n                3117850578, 3798438683, 4211733833, 972363431, 1880167313, 253714622, 76302969,\n                2144921929, 594588250, 3419391407, 110436200, 3019984992, 1696068166, 1311459144,\n                383767145, 4278876264, 1806767552, 478592754, 3307398109, 2106194092, 1374406895,\n                512715289, 2870580756, 1992431788, 63343676, 697633985, 890054481, 1959129172,\n                2577805590, 2764027866, 2020028848, 3876787343,\n            ],\n        );\n        // - highest_q in limbs_div_divide_and_conquer_approx_helper\n        test(\n            &[\n                2317066713, 3734873775, 217584598, 4283181214, 1987296898, 2029964730, 2841877055,\n                215692782, 869134407, 874390362, 2208433375, 645289786, 1962123143, 1210019992,\n                392208793, 479186599, 1403346326, 3121890550, 21351539, 1792046631, 1830759088,\n                3009702825, 2064264407, 1425980591, 2915380046, 2661484230, 272407717, 4286945194,\n                649139597, 3925921591, 1081687841, 2923866665, 563140201, 1426204510, 3994415326,\n                2030662828, 2060697960, 3056670310, 1609787794, 792934567, 2717771124, 4164322768,\n                3913458892, 2759459876, 4091351278, 1717819380, 1097243558, 2147464721, 1228826351,\n                3209546368, 1237764046, 1059356034, 2760411795, 3026477323, 624675850, 3763684075,\n                3540407970, 1913722572, 262369959, 2180102174, 3425380260, 1174673633, 158169541,\n                2382293449, 812030319, 3239921986, 484642353, 2919528753, 1658419979, 366878628,\n                1718980142, 799549350, 4285110305, 2715036325, 2455015536, 3032041112, 2735249018,\n                3310370605, 1181357276, 146624587, 3299107633, 1004501470, 3484807107, 1748985025,\n                1773700707, 1386223716, 4087630817, 750649422, 3611015842, 3444400533, 3725662389,\n                1109727693, 3037130634, 624478673, 633583116, 2378434635, 2687240280, 2673870544,\n                324343858, 731297615, 3614185356, 495482604, 715462793, 3367457094, 2135162069,\n                2612684285, 1189448323, 3887861594, 1345391741, 3430076735, 1913449259, 4268745212,\n                3848733916, 1785626124, 3506024858, 1223431612, 3120693480, 3802248189, 2144116453,\n                557985986, 2604607267, 1018386624, 2418517078, 2442250784, 3582497470, 654976641,\n                2599906378, 2211771862, 4102664307, 836270496, 4128006488, 2260892, 277275779,\n                535619372, 1868873131, 749436370, 1849951520, 783534973, 2957791640, 1636965908,\n                1156916684, 3732442514, 2251346101, 2723065991, 3717891339, 2525911896, 3076617154,\n                3265371035, 3292658676, 409114969, 4086635237, 3264336755, 2836953044, 3037161740,\n                3543275191, 585786355, 3087011769, 2185871252, 2541194926, 2224439978, 3412364477,\n                1350015989, 1311332023, 758561683, 4108017253, 4204509134, 4157141131, 1893317202,\n                1224082165, 880878665, 1834575916, 2572831131, 2631286660, 2578509166, 2240326536,\n                2609750355, 2798227847, 1197386254, 807604908, 1802810117, 2881797181, 3334708065,\n                3583310868, 3599155312, 183678286, 3236382667, 4125313765, 239427309, 3653131096,\n                494732271, 3893107141, 1018082495, 1979944519, 4044560358, 4179896605, 3780149973,\n                3875190427, 3114449657, 3457335347, 2339734261, 2616033966, 1329204235, 1248786560,\n                3467382161, 3028029914, 2536952877, 194748555, 241512194, 3260227272, 2858189566,\n                3881365161, 36968705, 581216076, 4188186728, 2833747030, 1972266392, 1374287701,\n                3058853674, 4101868185, 3030432843, 3731159238, 3617181750, 1742674464, 3668849596,\n                412040791, 406334378, 502702971, 2540238946, 2391871283, 1851296773, 2979189987,\n                199738981, 3379464313, 2875483565, 2404227424, 2501388469, 2789274764, 2515008836,\n                3408871507, 4145552682, 2991097752, 2338096504, 2325133139, 2082275255, 2834180247,\n                537432099, 1257296228, 3446712843, 39458827, 2174956861, 3039757037, 4157335831,\n                733488951, 2064219555, 1158696763, 1747438019, 1904327490, 2069625042, 3220261644,\n                2535390409, 1866459831, 3174902084, 3763763466, 711704437, 3941981941, 3947689731,\n                545125868, 199321616, 195433751, 587082201, 1623079028, 3583449493, 4189372053,\n                656157970, 4065268173, 2321947633, 4117128060, 1042761195, 543619922, 4200179141,\n                2194761475, 878960867, 3598234187, 3791350851, 346665711, 1360737771, 1930187385,\n                2405900037, 3062309031, 2085261831, 707121842, 3173108868, 503413591, 73514434,\n            ],\n            &[\n                1172385474, 2722128840, 3229943889, 318467582, 1270391003, 1178663423, 1974716983,\n                3282704963, 3178774681, 3202829277, 3946239996, 2183661896, 756303666, 3877972989,\n                4251016295, 3386638802, 4082864246, 2928113767, 1526526769, 2729531320, 933752600,\n                3559448071, 3782798998, 249483043, 1511243361, 3564728022, 1594495334, 71444771,\n                3603995676, 816918005, 1243632828, 1550377419, 1008068857, 2948396814, 2093904319,\n                2147043689, 2566638926, 1425327657, 1162199945, 2960758893, 4198224, 2356436749,\n                3424929725, 1080768275, 209858098, 113302786, 3443677754, 3549677964, 3154318213,\n                3154103315, 1582401507, 3617714568, 2767982074, 3761726254, 683939930, 192236320,\n                1080891479, 1143174553, 2075266572, 1844075493, 3593156363, 1292478494, 1945353284,\n                1251725895, 142445996, 3777493501, 3614227130, 2589877580, 1660324871, 652913311,\n                2513923073, 104713426, 2880864765, 717044714, 2176657233, 3162919827, 1461924303,\n                1335307283, 1089899112, 1463447432, 4286236462, 538631465, 1843988250, 978544087,\n                215501900, 93216142, 2947050139, 2693646353, 4213675869, 3765139921, 320058937,\n                1970573977, 43732280, 1873575176, 1055975473, 3361081513, 4080049587, 2593310713,\n                2546627943, 348433615, 2711034081, 1213059756, 3994279311, 2969515716, 3962824055,\n                498958294, 3283335149, 2727270461, 967722336, 1011867961, 3277768890, 1239567734,\n                2615827582, 3138350967, 1983810667, 1258771837, 156352868, 3459871732, 3838966901,\n                1926475715, 2906860513, 2265591974, 739992556, 4097548896, 4063110249, 2614816895,\n                3485800367, 2745680040, 1081661573, 739066934, 1373973331, 1210644481, 2279017196,\n                1005551928, 2040599086, 2689171110, 2107331398, 4229586067, 3246733336, 1653467821,\n                3803759079, 1396785958, 744631377, 2218132207, 655573009, 2223316795, 2924583188,\n                3561375837, 949662445, 1302891749, 1031980062, 864295262, 2438572862, 1504001412,\n                933269347, 1253638591, 1534271622, 2530288971, 3587024017, 4130814425, 2573905811,\n                2785603748, 3552056080, 4244335838, 1333943369, 2283588299, 2119292262, 1681201617,\n                3442164059, 1894009073, 2739198217, 1409299279, 3436643841, 1088847721, 837995626,\n                1423764787, 3020531343, 4051404125, 618735582, 2571970479, 3106734771, 2404302700,\n                1055667736, 397025181, 252340965, 1296678038, 512661010, 963140047, 1161844858,\n                3862111880, 964139113, 3914454392, 2517045255, 3547177225, 2645896340, 2943432060,\n                4173143499, 48482790, 1022192902, 500159282, 3637285006, 1101744863, 2363750224,\n                312625286, 3984163509, 3118100618, 2790609658, 2907841435, 1239943712, 2072088288,\n                159276689, 3267720981, 2856806276, 102734665, 3390376688, 3378951761, 975939361,\n                454652442, 1925083628, 2151124106, 1307480526, 3774198893, 3018272285, 272747408,\n                1016277798, 3605470575, 531634579, 2961498249, 821488395, 3558633824, 2912444276,\n                1657117175, 2153161136, 1884360710, 721291427, 1531829639, 4115435659, 4254348147,\n                1506441630, 4046066015, 556451623, 3337814584, 1018537690, 555628783, 1620746271,\n                2482837019, 3679282774, 2426930864, 2632326440, 2327928883, 2353267828, 3481986297,\n                2112160697, 1022061657, 758309560, 2644660892, 907838024, 1498392732, 528384055,\n                1202823703, 1890604888, 1949099119, 3063001275, 685428701, 1780107085, 2619180751,\n                2954672471, 2283259797, 1374458453, 1565978557, 1093442961, 3891637052, 780517054,\n                503083440, 1375890406, 1386889110, 4237816737, 249672267, 828386282, 1163719531,\n                132139434, 391942771, 1096514028, 3006936950, 2283483449, 1662382851, 3602503245,\n                4242261323, 2784647410, 2828350825, 1288023746, 1017072535, 2006783410, 122598670,\n                1977168703, 4075238695, 1691129759, 2007296448, 1519044036, 1701991670, 1153128956,\n                1512900449, 1261204616, 2927982361, 1657752895, 139288437, 140564828, 100283802,\n                3070382516, 4089107340, 191147528, 1712401819, 391845701, 1540517289, 1700899625,\n                1477882518, 755000874, 480418626, 588196749, 400809532, 2485933533, 2888628826,\n                332783138, 3009527268, 3784829804, 2922060404, 2516820570, 2217403977, 2521013993,\n                2614722986, 3779307621, 317006621, 1733129556, 1267545638, 3033328419, 2185074347,\n                2126485254, 1990828725, 1034359217, 3945891523, 3588995366, 246414315, 2407783722,\n                1985580187, 2106721825, 35659189, 204134384, 203035567, 2650819784, 3097513541,\n                195622280, 620515605, 2016439173, 304017649, 1791577127, 1576105034, 3535138410,\n                3637374201, 3626803115, 1214754525, 1611339531, 1762283227, 2759574029, 32271764,\n                2702968983, 1516226210, 160223584, 3507738999, 146234417, 2990154579, 1436112035,\n                1948173615, 3890958043, 1222277581, 1349923980, 506218124, 1577016965, 3229129980,\n                3912753236, 233704342, 1219563141, 429930162, 2006881030, 3328217266, 3101601662,\n                3008827607, 3114439162, 4169647780, 2658687412, 2809028243, 297647962, 1609437431,\n                3358143193, 1716156248, 1612652130, 2723039108, 2877712792, 227416933, 3655452320,\n                3809918775, 3758975241, 2625261551, 1044900207, 2767833802, 749765276, 1997143904,\n                536279565, 1568228199, 764519151, 4215912350, 263962810, 319470773, 3810995202,\n                3465177349, 1243659365, 864064918, 4136562751, 3062846208, 708743160, 2187738105,\n                3898834484, 2200754536, 4539814, 1789419448, 105721213, 2944213866, 1486345112,\n                32430882, 253601522, 3408074780, 2992349041, 2451728307, 226661140, 2460239549,\n                2100724593, 3852012222, 743449851, 2967418295, 605498674, 2055548507, 1922946771,\n                2632283075, 4086716584, 623236339, 3410294246, 4133057483, 2812524059, 1205446946,\n                3043927830, 3482614376, 1275680906, 3676217583, 513988754, 893728600, 1999049758,\n                598451747, 3593194658, 609427399, 2673100544, 910865729, 3116238253, 736726549,\n                3362221872, 1013768942, 718438609, 2217341124, 3587867839, 2300483002, 1946981080,\n                3920103403, 2292895303, 3117736693, 877577485, 2187888016, 1368957453, 4283009664,\n                1076391253, 1397877819, 2980178183, 3968837715, 867743243, 4043356977, 2946375050,\n                26361492, 3432852562, 1912980855, 130799130, 4033884077, 3349537042, 3182198745,\n                2179478628, 4252455628, 825955887, 93466691, 2196075887, 1784475710, 946546654,\n                3933870986, 2244605733, 3490402086, 4030429100, 3023300148, 1745265920, 4112142076,\n                2903907125, 2758734523, 3896908867, 2564201959, 26549320, 1274768945, 2576126997,\n                3923164846, 3736091709, 370046710, 514332769, 4121086903, 2972568269, 4088911695,\n                803020494, 3034337812, 317708135, 1334283383, 881113661, 1695276900, 3766800569,\n                2061275833, 1227611332, 121744019, 2173946227, 2389688567, 192367735, 3892792894,\n                2172535825, 117291679, 1935828849, 2721596143, 823956503, 1586432341, 2448062771,\n                4054304197, 864073076, 4252759593, 1258481746, 4285979432, 1026798711, 2713633766,\n                114893615, 3134616441, 2817271874, 666109477, 3691375086, 2759951811, 448361256,\n                1541295802, 3882571749, 2284391955, 1326400031, 2777223186, 885169913, 2782624297,\n                3537147598, 1692556532, 776208409, 3241275549, 1904954149, 2405119603, 3819789804,\n            ],\n            &[\n                225066005, 745131552, 2942567538, 4258778781, 1967392927, 3741613691, 1890932195,\n                1506277386, 1146302728, 3715076457, 3577274198, 3953573097, 2085422530, 661098011,\n                4236873637, 2930925760, 3967583938, 2852055099, 355730378, 512021169, 2505846300,\n                2749910007, 1454559275, 2553714326, 1536856909, 733797684, 656941700, 370199490,\n                1949020029, 4091629764, 3452778818, 3434279798, 240547993, 381305151, 534633119,\n                3783352536, 1551443097, 2973034337, 2180000100, 2053656589, 3320616670, 1724644295,\n                589237508, 2241024734, 412948466, 3347181025, 1812386780, 1524837382, 3656593545,\n                501624455, 3029327470, 273718066, 2666953466, 324438884, 2852820080, 120020650,\n                3393646374, 2619314651, 3733169374, 3756112094, 1302185220, 3677713422, 2747067315,\n                2815017712, 1868682331, 1943529649, 1563990165, 319757768, 2031825250, 2139207520,\n                2978578108, 1560356796, 3699549338, 2916893113, 101966731, 1585835576, 2998190164,\n                3967243725, 3959463829, 498949725, 3348011234, 3761007557, 302477959, 3992592959,\n                2447724633, 2460308753, 1858976258, 3525120157, 384425177, 2978081316, 607592077,\n                401773917, 1748638062, 4245512962, 1117346825, 2328817272, 847205838, 3491495030,\n                470052326, 1893860493, 2076576843, 2289319719, 1260754313, 4064542122, 1206836886,\n                523542952, 894395755, 3043786155, 2337338009, 2752103377, 3251660619, 2215772339,\n                3015482729, 2593131420, 3786996532, 3672453772, 651643275, 1988656237, 3347623451,\n                356296282, 2406730821, 3093333932, 2660898588, 81938635, 3783019719, 383826519,\n                2681656944, 3399824694, 3552203202, 3981865110, 1183621457, 146668152, 3118763304,\n                1958273303, 2057041878, 1183522949, 2882248106, 230586931, 680070970, 263636248,\n                2634241968, 677653887, 4023567727, 3777994047, 1592901741, 2761934715, 910715025,\n                1512493458, 165009600, 3565664162, 1187297321, 2558161419, 2468839453, 887950197,\n                220662954, 1244941671, 3095343373, 2063342669, 2090489239, 2010099484, 1948084319,\n                1365644807, 1235644818, 2588736961, 1564371721, 411294152, 3045805520, 1843591393,\n                3688879242, 2388718380, 2305780976, 3853250176, 1061462164, 3916091720, 1198491889,\n                3197591330, 1096143292, 2118906933, 1635799180, 1176220582, 2501989740, 801999335,\n                2705462373, 1003645809, 2186975253, 1064745016, 1555323605, 4095122662, 1852179202,\n                3337474276, 2971325331, 529480360, 4181951721, 1632451986, 1921251025, 2187957901,\n                1550157150, 1055194859, 1178754848, 2551455843, 4253040930, 72428672, 2433250913,\n                3380996315, 868858299, 2205090193, 2621190489, 1284715782, 1308118202, 628595114,\n                2783487525, 3396644559, 3453264010, 1070669284, 1383523038, 3993112084, 1712356129,\n                373012427, 126203575, 2392499470, 607718265, 2253959369, 1040951361, 2590357607,\n                2175608952, 2297182602, 4276086375, 1607963583, 1082087029, 3529235816, 326427724,\n                3716684434, 1901298488, 37770472, 3247695701, 1067103258, 3117586492, 1266520999,\n                1168926910, 2626033388, 630871070, 4243084776, 188878698, 3514192446, 1923550427,\n                206270544, 1634209660, 3863690423, 2574699027, 4168121673, 1449879463, 4224275977,\n                2227130200, 1884692906, 606301209, 1210083889, 3640641606, 2504768822, 3610799696,\n                2178748368, 1708820271, 1819469384, 2802870165, 2246886931, 3567016595, 3555599583,\n                1348994237, 3790873838, 3926636967, 1088645573, 3438253657, 3323650855, 828010249,\n                618829949, 1504599310, 1908275663, 4270232696, 4036146227, 1856897469, 2998994751,\n                2752368926, 870328089, 338595046, 3616029110, 296696765, 1403260870, 1830786965,\n                1227812187, 2223459989, 3589209104, 2051289912, 3318866022, 4094335795, 3787444415,\n                1234353630, 3808781435, 387466633, 3211872777, 4202021032, 639324231, 1976675272,\n                2193056063, 3199669188,\n            ],\n            true,\n            &[\n                3923579889, 1687605753, 3377794191, 3322208449, 1203553350, 2154425101, 1359863697,\n                3023444870, 776353376, 592836194, 2511309652, 3922934431, 4150213939, 858418424,\n                2956152570, 488137268, 931462870, 1642630985, 3149845100, 3318171957, 538998706,\n                5191729, 2137745225, 2297747699, 1984407713, 643246259, 2253618591, 523932289,\n                191175769, 3642012130, 3400043084, 1707948340, 2992423698, 81890223, 2378233131,\n                3079312226, 1066946509, 803135022, 1994948858, 4041732309, 1337312336, 2966488667,\n                3428464355, 2737588983, 4228360315, 2146901404, 3059157811, 2476369890, 75140925,\n                3251604233, 2881152809, 802794015, 3378093993, 96836131, 3099865764, 811380027,\n                133901715, 1047457206, 3609305681, 1771180437, 2461319522, 3515701714, 1066513666,\n                1659070392, 3086795089, 3716662526, 559065127, 3237292382, 3631218434, 3795187732,\n                704836609, 3786271895, 4061286432, 405232026, 3609248662, 3980760947, 3571087184,\n                1847154731, 2094552306, 814159853, 4260485048, 3149179255, 912325889, 3689884426,\n                4138663955, 14357881, 2050778168, 3912490158, 1861501789, 814905489, 3254286948,\n                2032825464, 3271543587, 2219425366, 4225852701, 1857868075, 1298372166, 1102499025,\n                3574133387, 3812312663, 448380962, 3807290049, 4209544034, 2256927203, 412478498,\n                1228300916, 2401082596, 350244424, 3441586361, 3136422715, 945678990, 2116172969,\n                301198401, 3322856984, 3407592301, 188389305, 2628435530, 597331343, 433647333,\n                3063380936, 3817880039, 2901586764, 3507352615, 2352939145, 3490273512, 4090562787,\n                1802676852, 514644644, 4124694011, 3639332010, 1115134207, 227756304, 3818731261,\n                4222040109, 2430937604, 2156693403, 2184651107, 3551740749, 2132540830, 1150238882,\n                1052043654, 571348510, 3172318934, 3673669988, 692769159, 210233084, 2958517959,\n                2297993342, 3316672837, 3302014323, 354145219, 2484852144, 3683759209, 3408466568,\n                2978225356, 4097994925, 2538336670, 1392418428, 2899544976, 457988587, 3773763501,\n                2012444919, 150975722, 2234422639, 1822822763, 551692314, 1014406649, 3374930924,\n                1240545416, 2294327444, 3432793083, 1000394478, 2103969650, 1395783166, 4085383479,\n                1542514796, 194271393, 145341362, 3655868181, 633459061, 328054273, 3431726030,\n                3557285056, 2901104858, 2052553042, 1042550372, 343075862, 4115125230, 3906797654,\n                1301043752, 2559925980, 1623793157, 628627946, 1884173596, 1228259826, 2621415081,\n                2785923512, 4270141343, 315667031, 282856266, 429519802, 3536348488, 2322956754,\n                3194951300, 1510744177, 3616915522, 3309727286, 517266630, 1119984084, 4026073305,\n                2238785198, 732618834, 3368263738, 4087015376, 2697003280, 994552013, 4290467065,\n                2365091630, 59691114, 169931479, 1498618224, 2382537145, 310192470, 900458915,\n                275936028, 3655907299, 1961047155, 943058038, 2333911425, 1578159189, 1847055172,\n                2659538736, 1993399472, 2491904542, 1070133929, 2666142065, 2803306446, 284508539,\n                2535344546, 798366741, 899869216, 282425661, 1522885207, 1934768011, 1935282035,\n                1783703650, 763335394, 1114825113, 4001525101, 3326921253, 1057031491, 231338938,\n                505911721, 3073700058, 3881013726, 2622491116, 2434260580, 2104610402, 77048668,\n                3840229888, 539240724, 272637566, 3598686634, 832397853, 3941981941, 3947689731,\n                545125868, 199321616, 195433751, 587082201, 1623079028, 3583449493, 4189372053,\n                656157970, 4065268173, 2321947633, 4117128060, 1042761195, 543619922, 4200179141,\n                2194761475, 878960867, 3598234187, 3791350851, 346665711, 1360737771, 1930187385,\n                2405900037, 3062309031, 2085261831, 707121842, 3173108868, 503413591, 73514434,\n            ],\n        );\n        // - lo >= DC_DIVAPPR_Q_THRESHOLD in limbs_div_divide_and_conquer_approx_helper\n        test(\n            &[\n                3852468748, 3866732619, 592701608, 3778254743, 1280491238, 2834833773, 550923334,\n                1479705073, 498349312, 767409174, 42211279, 2128147526, 2926662909, 141411040,\n                1065100366, 1527285446, 2874448851, 3117914313, 1218471999, 4280625327, 2037562894,\n                1609603468, 3241376868, 1996556629, 3588969003, 1318580268, 3687594860, 1362481322,\n                2944468172, 1695770272, 3083883725, 2377648522, 2496254008, 749263050, 2770685897,\n                3512231732, 3023316399, 3384859643, 1220306495, 391138498, 804657736, 44216427,\n                1931816623, 339239167, 2662606581, 2648352860, 1235726472, 1626990950, 3004127325,\n                1053956347, 808327756, 1442399511, 4286364870, 31595646, 2379491886, 1328294899,\n                816658097, 3205321744, 3963029596, 2572812025, 87366995, 3217997432, 1508641500,\n                1825064063, 1941897747, 1436358378, 3017514874, 941910582, 3588117902, 135801271,\n                2867936354, 2658316194, 407580200, 665652508, 1146163780, 3147022746, 3669479157,\n                3697518011, 3942322922, 3433464004, 147802483, 1146857432, 73698519, 3370749655,\n                1389534220, 589317299, 177267891, 2688250309, 2128670608, 1265200580, 2019760989,\n                1150930096, 2585252733, 15447323, 3088238466, 1783728664, 2811524431, 3891707403,\n                4029016169, 2907528558, 1270616768, 166893059, 1545869782, 4275310588, 2441090079,\n                2829901749, 3736960597, 3941382642, 2821131110, 564991139, 3126664226, 1998382701,\n                1328551552, 1210689595, 2996963417, 1557893584, 43742716, 876455611, 1677218718,\n                729180347, 315949329, 1732639163, 1821348164, 151672496, 1329099718, 974261301,\n                850419612, 1856037997, 2615159114, 3710750197, 4091633114, 2586774188, 2588577112,\n                1339558569, 1735462778, 1262938743, 1891014212, 3269098922, 1992796362, 2808355044,\n                3874652326, 2745283316, 1735823559, 3407614800, 370629516, 1152369319, 881914057,\n                470647543, 3939410385, 2852748779, 853680636, 3231204925, 296778651, 3315599780,\n                970480725, 1570957625, 3243621138, 4081630171, 2137632035, 488321574, 3274673411,\n                996742709, 1121917553, 684178420, 2611815203, 1398907392, 3313511725, 2114905089,\n                530433742, 1501425765, 3354176655, 3515249223, 3432236694, 2338559491, 3638772717,\n                3253118328, 1594238823, 3094732444, 354679189, 1860678321, 86892394, 826940850,\n                1314179547, 3978569567, 1699444163, 3462511739, 2591772690, 3726539491, 728424834,\n                2932676784, 311068414, 2129104220, 1026553636, 2242765511, 1733810815, 1138330866,\n                3652398326, 3074523173, 3839981206, 1015663483, 722242539, 3272711437, 2982099959,\n                1938802295, 3022788284, 12930779, 878443915, 2907693541, 1979049428, 593163227,\n                3823442786, 3215213583, 3695525644, 1119636738, 3212997654, 3027851617, 1144485880,\n                164747928, 2781230452, 1258345532, 2869324653, 3068929942, 1028739729, 3380289029,\n                2295840170, 3545102314, 2855402743, 1772822517, 724460983, 2228954158, 3208333919,\n                2821114010, 3148029409, 4068546439, 833494094, 2960251966, 160156911, 1983852913,\n                2791477758, 3697190934, 153093720, 104144622, 2441461309, 3159646380, 1733652873,\n                1562477414, 2555472454, 208737200, 2703626976, 3180538910, 2592414545, 3416739924,\n                3356130918, 4069598606, 1949794549, 1771742849, 3756687965, 1452093924, 2443380777,\n                1591957147, 1211239165, 1876128705, 4247423793, 398751752, 2564049252, 3016849411,\n                379369954, 1500293555, 1436202725, 3000709783, 2380370269, 1733644538, 1525628809,\n                13455701, 3296626657, 521910174, 2364967601, 1781968745, 1399663633, 3043350501,\n                1368246629, 2392664448, 1283732518, 785313394, 3034454976, 695088212, 1511797594,\n                1863608029, 299100351, 2597420190, 989884842, 2042620176, 1636899254, 2378486752,\n                402706413, 681449111, 3318018166, 1613374280, 2127967446, 289891229, 191268175,\n                2824016875, 1141385569, 1160748059, 2298038638, 2273363044, 1083067452, 2227633073,\n                3411833901, 2501670656, 1136686475, 449786314, 1206095141, 1428680228, 373851423,\n                1065715962, 3842120141, 1446849052, 142137120, 2503522334, 2890167721, 489029335,\n                2904499752, 3583810486, 141821369, 3975802804, 3139899326, 3360723646, 1325094173,\n                1458543621, 3135728890, 1722244101, 546577431, 2431082502, 2423442975, 3716191600,\n                4106127568, 1535072638, 3490647587, 690007845, 123509837, 3008940800, 2522129913,\n                509564148, 3464677431, 2734250447, 2521445361, 2724421404, 1464248423, 4286188561,\n                2041779154, 2040896472, 951622461, 2742066946, 3643978111, 3702076160, 3277267213,\n                3516427880, 3288032742, 1694027041, 3062496840, 1755611164, 2144317315, 1840150810,\n                3659412421, 269788590, 1685549590, 138245102, 3801925635, 2810327973, 3857961937,\n                3773132978, 2859864128, 1937028826, 1803313773, 1721171315, 3641809479, 561594878,\n                3883288939, 1615573909, 3567576946, 53427597, 3447054169, 924172132, 289810649,\n                3166741000, 991317667, 72203781, 985172668, 3013352759, 2107570161, 3250293704,\n                4114482787, 1050030772, 1057622762, 3438626748, 2519260970, 159154610, 888655185,\n                471817829, 470991380, 2525869562, 257437760, 665926900, 2709862184, 3205674228,\n                1381649365, 1803460892, 4134101678, 2543649326, 1209534353, 1226459212, 3664518300,\n                2168714963, 3110951542, 2920091469, 280549216, 3763064171, 3139277729, 2961240010,\n                3997887886, 2249335682, 4125195068, 2179174964, 4200864330, 1948058108, 1468274578,\n                2376503735, 1402764211, 3508183492, 568398904, 3916597152, 1316008321, 3354808565,\n                243276170, 383567360, 3854059575, 3533629121, 450497668, 1613229695, 1579942631,\n                1479512959, 1708803214, 166236912, 3371361562, 1178374935, 3631449184, 1044231267,\n                43160759, 2872462763, 386332526, 1454108301, 463466433, 2881621607, 1902397631,\n                3675190003, 3262456635, 3682680678, 3921732891, 1604135368, 3949662129, 3129246190,\n                1954536251, 1538666313, 2274928374, 1650180856, 3652524428, 1821056613, 911456961,\n                840333318, 764118487, 2652399697, 2580502346, 2438391701, 2513677855, 2640798083,\n                2778108413, 3625988619, 3121963132, 2016358782, 2026634297, 2454141008, 3719526468,\n                2069512197, 595695222, 1372551058, 2654832919, 1312895472, 3449972978, 1039886392,\n                1219309116, 2158257939, 161673294, 1466523266,\n            ],\n            &[\n                1228082563, 3958970957, 2292561045, 1680572099, 795956301, 3199900361, 2775759977,\n                470071915, 418570831, 1211920274, 3653536884, 1024252286, 2421732290, 2695210567,\n                602247103, 4076240601, 547232254, 3118467901, 373262705, 2538006674, 3879907903,\n                484206954, 2539623040, 4205486376, 1910552745, 3038212402, 2654312301, 3586427708,\n                954791645, 2348064693, 1497313290, 2715388363, 3338088407, 2319307053, 1080519064,\n                4159525507, 1284211779, 4015474700, 3753400642, 388134024, 2776075876, 552537674,\n                1195536084, 1000211139, 3608292187, 456221898, 2979823937, 3666331215, 3448143527,\n                752704015, 3181775208, 1221668864, 3658472905, 2038458530, 2182904194, 1539979012,\n                1086813538, 1185254470, 810158065, 3448748698, 4194931499, 1623694312, 298685602,\n                2265178291, 1937541694, 1775046588, 1544843229, 1529059357, 649269555, 2357792903,\n                2571831955, 176354978, 1299551755, 830143712, 1015814111, 776566019, 2627651913,\n                3960393788, 1268944216, 3414991379, 3922712735, 2519760646, 1906700144, 2590958602,\n                353821006, 2218545353, 1375841084, 2092401658, 1639008622, 4082695593, 2141419111,\n                3236669066, 1724206670, 419369846, 2835126061, 3041510267, 153991327, 2126200895,\n                3461262411, 191209011, 1342692414, 154698036, 563023945, 1510300314, 2248068391,\n                3846972081, 1992059708, 2646433655, 1714730200, 2303707509, 3981692650, 3517398169,\n                2281282719, 2519619923, 4271369978, 293814410, 438829639, 3337765624, 622782672,\n                944352733, 3715313213, 531335520, 113528832, 2419325895, 2984041163, 878536167,\n                3214930707, 2146787348, 4917714, 3257269189, 2452274107, 2672157272, 1585645759,\n                2131367341, 3585828795, 1333843792, 3923459029, 694088371, 1013702168, 1741059100,\n                3997989379, 542853888, 1761645159, 406716499, 1694374453, 1624534824, 3459630459,\n                802104445, 128207303, 144400385, 476582731, 3051345902, 1368383669, 1166299002,\n                2707219053, 4004021138, 2679504095, 2592982338, 1033724773, 1157182117, 711981576,\n                42503937, 2924924484, 3595784172, 3595204272, 2994216676, 4221872019, 3722581147,\n                3333988566, 1523164764, 1080358318, 1413433846, 3738351350, 977402259, 1992977980,\n                1559146947, 3211129812, 2160246550, 2367537106, 446281713, 2153747232, 397871847,\n                3366573642, 2055448941, 41153636, 754933361, 2993598965, 3306066874, 3631977724,\n                3123479847, 2585741316, 2994078662, 2509626417, 4066762390, 4211900185, 3742567686,\n                3545119766, 949327829, 1947239775, 1596917691, 2428932126, 1055142932, 562149283,\n                3199507769, 2908430793, 814804964, 398782122, 1053511625, 2957145782, 4214499480,\n                2538107930, 3510188017, 3044050202, 1179016763, 3073719558, 1010197763, 2365480195,\n                796718852, 2056040043, 872695428, 645007655, 3691376745, 104700630, 2649843250,\n                4122935255, 642238345, 2295983257, 348265112, 2773179245, 898141051, 2579996826,\n                2612225547, 3972451489, 2646202581, 3681992299, 181022653, 1485802997, 2440387741,\n                2520682234, 51353550, 114076802, 51940680, 2817210994, 452896124, 3254045803,\n                2864556183, 81661781, 237542081, 1973800766, 3657654720, 2530129707, 403307022,\n                68172699, 332554330, 1181024212, 811837036, 3695906025, 1961935526, 3608053891,\n                3566607807, 1505243326, 3952431950, 2229199298, 1258499123, 3907526592, 1202974947,\n                4257231754, 383365712, 2370787478, 3966045621, 3709646864, 341562985, 2306743433,\n                3087453648, 1119686719, 3010178775, 1966960488, 4005245264, 742100958, 1841989955,\n                4073161558, 1387924175, 3136835241, 4153208836, 172275833, 118390136, 3068417534,\n                3427994941, 1186924296, 3531763845, 1587276588, 2491453930, 3092663154, 186325597,\n                3735008023, 2520603222, 141263570, 2586779772, 1097287985, 1184074419, 2231683844,\n                1006316112, 4242375661, 3021145139, 2474020608, 3059475910, 4077499345, 2682549550,\n                899267458, 2939020861, 212132728, 4070534479, 899246172, 3206389107, 738644506,\n                1196824568, 4135770345, 665964490, 3404106178, 2800460425, 370991796, 6173656,\n                989425002, 738558511, 1186448823, 1117986518, 3268400991, 694618816, 743869433,\n                1081820528, 1169090980, 2808795201, 2626416762, 1852742088, 3500519845, 1862566642,\n                2528685207, 38532995, 3254975580, 2293790115, 278388535, 4214498933, 3355793258,\n                2429295061, 3055950106, 1916510220, 408474308, 1993547223, 3283433638, 2876081292,\n                3535523705, 2101519467, 4222280709, 1877650206, 1362736623, 1125507149, 2753028888,\n                2871670444, 3984235984, 2837413105, 2740068704, 2501544770, 2062713945, 1827003918,\n                3387715121, 3978334051, 164380626, 911533483, 3159921130, 3896040725, 2453247705,\n                1732359707, 97075111, 1167974376, 1292533086, 3978529628, 1173190459, 1180474283,\n                4027781835, 1819164482, 1138188719, 2554004670, 2238689551, 2719133108, 827123216,\n                3402746862, 364981183, 1215495008, 3697503228, 2459473144, 794939056, 2850414988,\n                3880571940, 3446126388, 387496900, 4012258040, 233036233, 1295469109, 2236990087,\n                289904073, 1533599469, 1786729109, 3155911485, 1361493542, 1709668750, 2979939253,\n                899656352, 2488414909, 2345651638, 857006573, 2499927665, 3004854698, 2767508418,\n                3057934317, 2570296632, 2340731830, 1704320439, 2217465736, 483270163, 433273029,\n                3463124152, 2858495981, 2293137585, 3765138357, 2050975825, 1062202999, 2389813229,\n                327867315, 3524908521, 1060359725, 2437188567, 4037791947, 265987565, 2531318664,\n                3789582609, 1036190383, 359313632, 343266182, 3818075324, 1483429641, 3251308104,\n                2231865653, 2088816062, 1363097078, 2619396780, 3922946100, 2087714470, 2714841575,\n                313007644, 3053385186, 31524825, 420269932, 2184870970, 2633967376, 2976557270,\n                3907847269, 1704768911, 845456817, 3013183512, 673429122, 1088006999, 4254909288,\n                3477532731, 2633706423, 30604022, 381299887, 124029095, 2146491520, 810411389,\n                1842896686, 1189234944, 490339649, 1115698075, 3923320995, 2822835404, 2863188964,\n                2041216097, 3722786391, 1411085302, 643395602, 1892259907, 1276564050, 92834220,\n                2113523130, 3750780619, 413882810, 4162989, 2342682023, 2496728931, 3765633586,\n                1201219647, 1509483486, 1571999425, 2150766213, 4078947670, 1554603889, 2829344380,\n                915004628, 2209136503, 1860939599, 1336190314, 3883277228, 3526987435, 1959059220,\n                2644428109, 4106090871, 917923267, 1544296685, 710190597, 1252330700, 445060090,\n                3748836645, 2225146599, 1869685424, 2948785336, 396398905, 4121416478, 120806631,\n                76766006, 2336284840, 2353857164, 631928490, 2358081096, 2401392404, 1781483930,\n                3507012756, 114196273, 761825995, 1747713254, 3582101597, 748625738, 2646455218,\n                2905499938, 3230684494, 3213162530, 12062405, 2034846069, 2240074509, 3895726666,\n                1559793991, 401560906, 1188895923, 3908766043, 3080529735, 1723996093, 3234235196,\n                1524383480, 3006010429, 1021800042, 2598013312, 2404289459, 359714242, 2353150857,\n                3214159696, 71259951, 3244867195, 1475212366, 1519569068, 396867142, 1704063457,\n                1255619835, 1809747439, 2455947434, 2914124280, 490937656, 1909042102, 2425011492,\n                1653816077, 1744426598, 3540268790, 1266922070, 3157358103, 764478931, 143507967,\n                4138193217, 1618357750, 4064415341, 915914627, 379606079, 1684722693, 731091210,\n                3441411920, 904319643, 4101866043, 1130761207, 2746556498, 2962076734, 2459719176,\n                4014414287, 2306516630, 3241923533, 893098894, 155104880, 2462450145, 3698302787,\n                2611896162, 3483738489, 1960417753, 3190054039, 3176206866, 2149242647, 241842249,\n                3791458236, 266968864, 653002708, 3295229436, 720704829, 668777771, 2920041289,\n                1616327007, 2614675119, 3120745852, 3703698323, 642045983, 664497190, 4138076932,\n                416801804, 3836460143, 2512697726, 1321118683, 3790475422, 2372618883, 3906311778,\n                3636945722, 93045717, 3245150294, 2203703812, 2876544088, 1482347470, 536620593,\n                3055935093, 3219276551, 1736510361, 2882369741, 227297457, 2287462988, 1314417701,\n                2698591585, 3562176889, 1108866670, 986625362, 3935882051, 2153826689, 4088091186,\n                2094026213, 2614688936, 4293577301, 4053305951, 4075217449, 3960924855, 347332803,\n                1968625524, 114389475, 430194382, 3252648209, 4018348764, 1840000995, 1589897244,\n                258799598, 1737020958, 1683355155, 1473302633, 1904664311, 4282826162, 1231154140,\n                4030919851, 1206926359, 3663795445, 2379135003, 303432555, 355307489, 1769635102,\n                2552468836, 3490641321, 3099203148, 528813020, 3258352325, 1295334678, 3143722334,\n                1978938927, 286181973, 2742706533, 1605086426, 1943464059, 2101290175, 2169564592,\n                2507578488, 3835864045, 101762307, 2100748227, 3058433907, 3335629628, 2214316788,\n                1268535268, 402136621, 1768704361, 1113090330, 3771703632, 3647202551, 2716086257,\n                1380543566, 888137953, 3154815844, 1427117965, 4171112788, 1823391124, 1935813073,\n                3498407768, 2295745053, 3209451097, 3427436731, 1760982025, 1197278449, 540450594,\n                3647987196, 3703306058, 1018206619, 2476714098, 3182222236, 2163415625, 1564991911,\n                377612233, 1240138195, 438211, 2660780499, 3842090366, 2254892076, 770175200,\n                24158863, 2695586572, 1592642609, 6566621, 3696323406, 545103586, 1539983422,\n                2835737393, 3243834056, 1307518947, 1449819027, 3732497678, 361142215, 560917662,\n                1000073399, 2993529240, 2447753259, 277468387, 2097588385, 2296579141, 3491393176,\n                593689188, 3981379323, 1199729884, 3155291067, 3484678877, 3241832730, 700414265,\n                1991308981, 4120895059, 1897048619, 3149808222, 439364012, 344761676, 3062212838,\n                1283609663, 4033828278, 1778135949, 2420787257, 893368411, 602240535, 1331176104,\n                3252174301, 2911796787, 3606169310, 3656396589, 3672036583, 2975308991, 3008310252,\n                1216481017, 3571455814, 917390807, 3398014016, 3881198175, 3246069043, 2018429161,\n                2473741365, 115107297, 3264952157, 2580209049, 36273546, 3206338009, 305508401,\n                1376925433, 2056571909, 1019775170, 2706062024, 2901924304, 2190222733, 2740737267,\n                21015048, 1250529961, 4189046693, 1010891679, 1852727754, 2130616276, 548460973,\n                1990672906, 1047266283, 1377617303, 2745241728, 3579697777, 4061895368, 2785622772,\n                2769532205, 3150425811, 210098228, 799917387, 3243975475, 3585288930, 2961830047,\n                3048068800, 3653640841, 3600794853, 2717549000, 2701285348, 3943817837, 1093998117,\n                2069876461,\n            ],\n            &[\n                1904169149, 2631229056, 3049906843, 1882970882, 1342610636, 348735230, 2030868119,\n                308972916, 3291280440, 1713067370, 798189929, 267083738, 1426325271, 1400323459,\n                4220917798, 2838399613, 2788016416, 1808463064, 3797033758, 4019522812, 2732377100,\n                2865589386, 1858695675, 791228146, 3278919839, 1007346809, 2152870094, 4143135690,\n                2156969365, 276568681, 768119249, 3720025676, 3691488609, 2122964639, 1090037461,\n                1573203071, 1029758226, 512965488, 1081406960, 3875174920, 4202135603, 1561629768,\n                144375534, 824852270, 2139340951, 2521611777, 617945581, 1174393067, 83560822,\n                3171084584, 2743715748, 57600123, 2500345583, 509310341, 1466707920, 3965654944,\n                1780152208, 2543890327, 3951358979, 4064884222, 1148693723, 731908693, 2303119198,\n                2162132555, 3899764661, 4062906460, 2910202154, 3507799436, 3049585561, 1547101764,\n                2240591447, 538691646, 3327231079, 4101167722, 3558467927, 632232393, 3069596916,\n                792109379, 1443377440, 4063660922, 2403295483, 3242450069, 2054813912, 3224639109,\n                2116127467, 3510867445, 4131878961, 554538806, 763384993, 4028933429, 784809516,\n                2188214742, 1245086980, 232165771, 3893787601, 1616832299, 3354660858, 3756152253,\n                695071424, 3616331020, 3728930728, 2300889664, 1134765807, 2568071856, 2230185436,\n                1313073173, 3090697900, 2811549719, 2626884644, 3174004164, 3418927780, 1459400962,\n                1170992180, 700259624, 2882894395, 3735934167, 64057275, 4285443281, 3858505044,\n                3530830770, 3881898558, 1248666153, 4057784557, 825094518, 3954584560, 1379703941,\n                456663582, 1936817375, 2100203590, 2269578911, 1927092754, 2056845231, 64996052,\n                3180336408, 3382367590, 1579799629, 369271331, 3393685503, 1678462084, 3580453071,\n                3344059212, 2603016988, 1704438831, 2960085271, 3944849185, 1984458477, 3159618129,\n                1356105311, 3061973253, 1169634390, 1581525372, 2092399029, 3856589897, 2747272433,\n                129370532, 3259112907, 2392093327, 4224720237, 2467960903, 3012864179, 657311189,\n                792107047, 3702308235, 2589079343, 1977762240, 2054656079, 365049703, 1136316952,\n                1766336156, 1574143327, 1448002399, 1545340743, 3343582998, 4266810491, 885565293,\n                1012325697, 4265244667, 4164478481, 3171829328, 3052840557, 1524972073, 3381586754,\n                3989036728, 1081734627, 3737298307, 1869630638, 3072103206, 3329790326, 3520758799,\n                163463995, 3179586285, 2504600081, 2392849343, 2696495366, 77291649, 1524994513,\n                4129364215, 2589017064, 563995388, 2948622336, 3478580619, 1302885151, 1885238682,\n                3399987677, 3819885284, 291981185, 2438308465, 1131073201, 2094997380, 4030538680,\n                2493835385, 781324886, 780626834, 788047573, 3251459753, 589598543, 530167431,\n                691366057, 2997152103, 1895699987, 2067335840, 911810562, 3044146727, 1981642612,\n                2744164616, 1268584352, 4091929647, 739635330, 2535146835, 1232134198, 2821166834,\n                2694137328, 1845150759, 4145746520, 1570842207, 1877662863, 2624263192, 822008531,\n                544782319, 313703935, 2549594582, 1507198513, 1165274204, 3706172942, 1025658022,\n                1367415969, 3754039309, 4187050684, 1116191986, 1599395850, 4255758850, 3627566792,\n                2013052489, 3678795519, 2570182055, 3933838202, 2878788816, 245983387, 3805875941,\n                156152490, 2288310229, 213932492, 2816431456, 3032792377, 4098973047, 1987668121,\n                2178466333, 3171514186, 1824097633, 2477633111, 905563455, 2561821790, 1164919073,\n                3346223498, 85587270, 388762173, 2830714978, 587416024, 118417479, 985918121,\n                2869840425, 1942696561, 1447188301, 1252144775, 1754507324, 2995197874, 348722845,\n                1994558236, 3180590158, 3621098260, 2808142053, 664847652, 2216211159, 1812881783,\n                3652176793, 1818451392, 1492863756, 4248433045, 1393154835, 2899742381, 1639554680,\n                3891616188, 1401178839, 155094399, 3335589331, 3242149447, 1506620207, 4025305548,\n                1378564899, 2250748936, 3892206821, 2999250953, 2404072212, 1227092115, 3842156829,\n                1175300589, 1366215256, 3655797370, 555970590, 2216476284, 356175930, 2316653842,\n                3511159891, 3242198801, 3709284219, 3992609721, 131038128, 561182178, 2366328214,\n                2169412954, 1843648386, 1596245006, 590747798, 29988297, 1032233337, 4148540805,\n                4287292895, 1784151615, 775442479, 3254055272, 1319462308, 1998762911, 462052502,\n                3240867011, 1529884215, 2445458752, 687926411, 320372384, 1993875140, 1103187463,\n                1101261370, 434642811, 3921005377, 476413110, 4114908941, 399340969, 550419121,\n                2138268102, 1961648534, 2475107221, 812733153, 1013882638, 804382040, 597969578,\n                3969389037, 1681594804, 3597283127, 3246865960, 2618922824, 2412709123, 2883379189,\n                2268836289, 4041631960, 3932960611, 2819242006, 3434298940, 1965495785, 1801489474,\n                2483685757, 525486136, 3103413787, 2524236016, 3297675542, 4250105246, 2163911845,\n                868191034, 768077954, 1251877129, 2082725352, 2563716501, 324144134, 2949337083,\n                629793518, 3585348714, 2283159799, 1662388577, 3211992651, 1893003272, 367507404,\n                597480849, 3530706203, 2180056290, 3040505611, 3393423843, 962401948, 1880350816,\n                1059318370, 2185874635, 834999744, 976189277, 2214236591, 1042067189, 3972166345,\n                3379537993, 4180308634, 1894580429, 2768917877, 2304053036, 1074132791, 1172385654,\n                3558332507, 4118553815, 1144817158, 1932880741, 139994662, 2006231438, 1878531442,\n                1451662501, 190676819, 2374814207, 2111662756, 2422642399, 1219123380, 1437107644,\n                3325772043, 803974620, 599430876, 2919848672, 1661638336, 1841139086, 1961142950,\n                3330180086, 844957898, 2211184671, 1097521602, 488948427, 3209202495, 3087475496,\n                2505815200, 1915071794, 989106472, 3460765890, 1592714830, 1577504527, 544612468,\n                527148798, 3186590344, 2423036586,\n            ],\n            false,\n            &[\n                1274629765, 3141211094, 3066783437, 3586463614, 3484042397, 3524692172, 1849759418,\n                639170343, 4042051785, 1786641195, 2781936314, 598559471, 4206822552, 3076839520,\n                3426707763, 2541903555, 3985517971, 2924425523, 805503712, 2235352830, 2985073687,\n                1986582861, 708824890, 508981633, 2929420962, 2821655200, 1435071022, 2815105969,\n                3064101020, 669540051, 64719297, 2298557985, 2663556386, 2872778448, 1920581662,\n                3964906867, 3545183326, 3734685799, 965493690, 2511488644, 1289889793, 2716496762,\n                1482707283, 1243240515, 1600220728, 3386832682, 1230771057, 1851371335, 962673373,\n                3303433511, 2971821380, 465715438, 1476479395, 4210224292, 3326701593, 262885511,\n                2623286176, 2785619040, 3631756223, 2689408595, 895184011, 3039724640, 3256518757,\n                3157339284, 2736033980, 2623616149, 2262942125, 4066660566, 2010739028, 294414070,\n                468536368, 39081857, 488790327, 2978306577, 4076063380, 164990706, 1769246328,\n                2404180723, 1910734795, 1212674812, 3651413973, 4107687624, 3562008089, 2495538965,\n                1060913944, 700681324, 2213076011, 956710321, 3766900265, 1201745400, 1689241027,\n                2023383937, 3309067962, 4290293260, 3262071778, 867200275, 3722256414, 2704572302,\n                798356854, 4060154398, 2192265925, 1631346682, 3841392362, 364742914, 1350896170,\n                3826205664, 1387850479, 2438144424, 1722720699, 3355734439, 281374639, 4294332167,\n                2848655781, 2650822950, 52206106, 1267368119, 3786144635, 3997971973, 3766740222,\n                157940553, 874086492, 567057084, 1468392762, 1319013026, 1763094857, 1258351011,\n                4219111833, 2069011861, 1508267766, 1742493547, 3709667481, 244137977, 3867904379,\n                2749217489, 1901868294, 3141009904, 1334349455, 318703881, 790854628, 2456409186,\n                2729035424, 2140696710, 3057979010, 1943182218, 446440787, 3044060750, 3377747126,\n                2650171384, 2030143427, 68841182, 3417107910, 1982395041, 213127592, 4263826627,\n                3810676045, 2815565679, 4215729650, 2424656131, 2427868488, 3538613128, 2004058276,\n                3156863142, 3493891883, 1282367517, 4021690990, 3880291659, 3234626473, 733983061,\n                3094727704, 2181100156, 2419795021, 261213792, 1806943490, 2451407303, 2727992941,\n                3870486736, 2318523062, 160305854, 3405051241, 3671726857, 3273962892, 3354100289,\n                2703913540, 304014061, 2416130602, 1740666524, 1270481586, 829357964, 3389415821,\n                1783014510, 3440915536, 2186635473, 1638518047, 2861195291, 1925018981, 267706283,\n                1852657873, 3918895473, 3639936236, 1540281136, 3992865037, 1795928884, 535725314,\n                2620251512, 3768070603, 342868542, 2807296004, 1944907465, 766931863, 507809586,\n                1382623024, 3748022748, 809199766, 2606119767, 440758364, 808682457, 1891522267,\n                2798966179, 1932040027, 3544577672, 1613760857, 2497954981, 3761568437, 2673674694,\n                2267348907, 2169995118, 1082902734, 1924288552, 2560273581, 1328627426, 500474681,\n                2740807968, 1058091958, 4193976709, 2145630875, 2850935242, 3475556484, 1444110200,\n                2094948501, 3669224179, 3527535779, 1309727297, 3043349576, 2800927336, 798778876,\n                2615924118, 1736199098, 4167626369, 3609129416, 3696542059, 2660961906, 3709573368,\n                2742620902, 2002154977, 1840222458, 678539421, 391765530, 3711225631, 2336471984,\n                808858486, 2107964482, 2120664214, 3475065201, 3782915227, 2313935531, 1140567569,\n                1920486212, 469939343, 4127720462, 1046677730, 3365009246, 2650242485, 79281379,\n                3069462836, 1131058884, 1346966266, 2182389628, 3425864155, 487991612, 4274615916,\n                3585882986, 3882253255, 3299152123, 3923136894, 4158963676, 1993380396, 3025592126,\n                3697510913, 26996074, 1666693894, 4128726650, 1349974160, 1162680197, 1002804513,\n                2192715135, 3733784449, 1296058713, 756389024, 985468845, 1910174731, 3512126196,\n                2889051038, 896547684, 1052365249, 1712208218, 2895783918, 4015271697, 4194906302,\n                1607592000, 488260174, 1247101503, 2635736706, 101416663, 502456820, 3004088397,\n                2217260735, 3689763077, 2750526303, 2814008209, 4290490637, 459845084, 194661656,\n                3298271035, 499760349, 1457282007, 1720527994, 283878558, 114686420, 207781028,\n                2101242696, 2475285413, 4066549966, 3571095625, 1456774526, 1957825881, 644287366,\n                859324850, 2429216562, 4069493991, 978462144, 4019464424, 269773692, 4086951598,\n                3169184115, 3840130624, 997907757, 3420447554, 999500052, 2700308046, 53871682,\n                1856963, 1188612325, 3393695655, 2729360995, 4101441780, 3357241810, 3598434336,\n                1257477782, 953991428, 4060500318, 1564349166, 1626434500, 1259685422, 4087690819,\n                3327437017, 1630386771, 3761712654, 226730056, 3668971305, 2810327973, 3857961937,\n                3773132978, 2859864128, 1937028826, 1803313773, 1721171315, 3641809479, 561594878,\n                3883288939, 1615573909, 3567576946, 53427597, 3447054169, 924172132, 289810649,\n                3166741000, 991317667, 72203781, 985172668, 3013352759, 2107570161, 3250293704,\n                4114482787, 1050030772, 1057622762, 3438626748, 2519260970, 159154610, 888655185,\n                471817829, 470991380, 2525869562, 257437760, 665926900, 2709862184, 3205674228,\n                1381649365, 1803460892, 4134101678, 2543649326, 1209534353, 1226459212, 3664518300,\n                2168714963, 3110951542, 2920091469, 280549216, 3763064171, 3139277729, 2961240010,\n                3997887886, 2249335682, 4125195068, 2179174964, 4200864330, 1948058108, 1468274578,\n                2376503735, 1402764211, 3508183492, 568398904, 3916597152, 1316008321, 3354808565,\n                243276170, 383567360, 3854059575, 3533629121, 450497668, 1613229695, 1579942631,\n                1479512959, 1708803214, 166236912, 3371361562, 1178374935, 3631449184, 1044231267,\n                43160759, 2872462763, 386332526, 1454108301, 463466433, 2881621607, 1902397631,\n                3675190003, 3262456635, 3682680678, 3921732891, 1604135368, 3949662129, 3129246190,\n                1954536251, 1538666313, 2274928374, 1650180856, 3652524428, 1821056613, 911456961,\n                840333318, 764118487, 2652399697, 2580502346, 2438391701, 2513677855, 2640798083,\n                2778108413, 3625988619, 3121963132, 2016358782, 2026634297, 2454141008, 3719526468,\n                2069512197, 595695222, 1372551058, 2654832919, 1312895472, 3449972978, 1039886392,\n                1219309116, 2158257939, 161673294, 1466523266,\n            ],\n        );\n        test(\n            &[10; 6],\n            &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],\n            &[3, 4, 5, 6, 7, 0x80000000],\n            false,\n            &[3614, 4294966768, 4294967005, 19, 22, 10],\n        );\n        // - q_lo\n        test(\n            &[0; 338],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3221225472,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4160749568,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            true,\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3fffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3221225472,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7ffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n        );\n        // - n_2 == d_1 && n_1 == d_0\n        test(\n            &[0; 780],\n            &[\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xf0000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4261412864,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4227858432,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294959104,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3fffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2,\n                0,\n                0x10000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7ffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4293918719,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x100000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xffffff00,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16383,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4261412864,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294967167,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                128,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4160749568,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4227858432,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x4000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294950912,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                8192,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n        );\n        // - carry\n        // - !limbs_slice_add_same_length_in_place_left(&mut ns_hi[..a], &ds[..a])\n        // - q != 0\n        test(\n            &[10; 10],\n            &[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n            &[0, 0, 0, 1, 0, 0x80000000],\n            false,\n            &[0, 0, 0xfffffffc, u32::MAX, u32::MAX, 1, 10, 10, 10, 10],\n        );\n        // - limbs_slice_add_same_length_in_place_left(&mut ns_hi[..a], &ds[..a])\n        test(\n            &[10; 197],\n            &[\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                32,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4290772991,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                131071,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967264,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[\n                0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                131071,\n                10,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[\n                1976632771194112527,\n                521304770361505402,\n                6547459063177486272,\n                16111887222588973398,\n                11964828684918293857,\n                9728747614510340318,\n                4267206348672680192,\n                10832398719275582210,\n                14900216064213533822,\n                6380760676681064593,\n                2849541272450836814,\n                18142033108417998751,\n                5641128336349728868,\n                2535172385342350806,\n                15911904441417898191,\n                9084408705773921949,\n                15744864820799189887,\n                4463837653601785361,\n                2987490935632187606,\n                11223238737559450353,\n                5105094309856727876,\n                1009868354752173181,\n                13484596105692600309,\n                238858926646454289,\n                1059132889701728020,\n                15279567309856499035,\n                517773561239225477,\n                13637839145813400305,\n                7302869346647374900,\n                1151876675162026587,\n                9504208398199632979,\n                8612638565635453711,\n                2164322139068363749,\n                15512475459854984520,\n                6875534824714840095,\n                16955948007577516702,\n                6471458936191368235,\n                10654427325707436522,\n                15337657345435735346,\n                15231031327469377800,\n                16046593431914105744,\n                8712679690677372756,\n                15831996438112202870,\n                14225387673292899684,\n                17347546671830406364,\n                7848557880774740728,\n                15226813436071672038,\n                14096480347669118219,\n                16389437176481235757,\n                7980211852778477130,\n                16446026267287953606,\n                7958418492797069881,\n                2213403156236979508,\n                8758841210279886543,\n                5431207818821342199,\n                10995901604046539947,\n                18335471104239998694,\n                13564698255420469178,\n                5867947764049999258,\n                1175284037301014819,\n                12349712146059439945,\n                6688979957099199180,\n                15522195128263747693,\n                11640494562411680106,\n                15737920193718148078,\n                3117055011815888766,\n                13625786892636999921,\n                12946533130762629275,\n                2401319620356150536,\n                15224229761057707791,\n                9402116507951822726,\n                17081785103310854839,\n                18332791217613728290,\n                400494137558561035,\n                12279775278166901330,\n                3814281798348375735,\n                16512813422954004929,\n                15443554440158194522,\n                9668157500068914212,\n                6053490056859889986,\n                803053277491258716,\n                13646927161616864743,\n                12206129576276588469,\n                8174515000911774339,\n                3036848877312472711,\n                11063940183681869708,\n                6310270877191259165,\n                9386179633193645060,\n                9559132660384619200,\n                8951064714492945869,\n                14166616301229473652,\n                13071629188826572782,\n                11853790173693535149,\n                209636673262143030,\n                10441446179239151884,\n                10420612973148232000,\n                11908054025560012662,\n                10909003530238644740,\n                5352309958024461387,\n                6231231241710103495,\n                5817566191981122394,\n                9966557507113270738,\n                2526734084799877406,\n                7119546382209824917,\n                11004099504334912785,\n                17101894178044846313,\n                17623127824006159278,\n                8521084772968581318,\n                13811386822752437212,\n                3432971939926452639,\n                9600964573924347046,\n                17748647615012039077,\n                13689755186761681519,\n                16574316982652951580,\n                16782416719434018360,\n                16144163416834277717,\n                2756565693629327141,\n                8059306003700661181,\n                16267666526611427826,\n                11909795646086424444,\n                943806121593842977,\n                13457826244859784108,\n                7239747548483360443,\n                16749825534693166168,\n                14426083390114861929,\n                17648467062688582919,\n                15758353298227492958,\n                8404753209561230712,\n                17152753483008477565,\n                1709121095849985814,\n                9192526565401365977,\n                5811560381076741655,\n                7570776248350537723,\n                10727029289681698856,\n                10402933617834546815,\n                8318965057148775598,\n                13169231870647857793,\n                12802647644833789786,\n                3875248944583119534,\n                12821268270102906356,\n                6572470769294941231,\n                647608152449604156,\n                1871144685026941083,\n                4032548946127357216,\n                16395335442808140376,\n                6736436429481567066,\n                1079601411786263878,\n                2504995255059825437,\n                6763393428021343788,\n                7715029394801749110,\n                11780543684841254832,\n                1383809532223095584,\n                14972882189077591253,\n                7800448071104479686,\n                789117789337480564,\n                14240769726663499540,\n                11053104839957580124,\n                14698906095810695206,\n                11960947912669574992,\n                12154539497540266947,\n                14003595352222612163,\n                9605483083077043861,\n                1678324429116079639,\n                18410093395270606595,\n                17901794159659874459,\n                4555659564807476615,\n                5907892309603612114,\n                6524803775567674587,\n                341147093193233779,\n                12996396640449564521,\n                6720226112934991484,\n                2388493664120597295,\n                4290799651574648025,\n                15852556922046266402,\n                2246578851767626469,\n                2920616190359978,\n                1995918845898424965,\n                10100917236583320084,\n                7326568532476915731,\n                15216155190727196226,\n                12275242131304351295,\n                5999272749153860391,\n                16885847068579318746,\n                2394902793719864009,\n                5326879392776369400,\n                15621103453348562573,\n                316702208555392711,\n                11540860887565649468,\n                18366619672720535993,\n                12809248756928885140,\n                7645410389657248491,\n                14015340112675676632,\n                2512410450534100064,\n                879480154877772022,\n                11649289287186823201,\n                3763895355294089425,\n                6070847093240149275,\n                1985095235894032224,\n                6801453453040268360,\n                2577579383099711197,\n                402372101655687448,\n                5644686065835595838,\n                2514710250566535253,\n                1911966914948814254,\n                3687058531887005876,\n                7434246748483727789,\n                14122808689973017488,\n                17766089471795036547,\n                6666390546144059621,\n                9594245591763828251,\n                10442127131744522659,\n                12010358916814662429,\n                11623966019504805712,\n                12883088750499797281,\n                15648374317449757761,\n                7443275395944491151,\n                2162931565418953025,\n                13144859518518203320,\n                14371376174232659599,\n                14565951115370759763,\n                7113822803057100738,\n                791629390390021149,\n                17035680947686192637,\n                16117534524053580299,\n                16569219763811788776,\n                12157015834931780538,\n                10769346653748666149,\n                1546686602678137333,\n                13300226369383179632,\n                6100259704952035034,\n                3072644701407984585,\n                4030070721794724661,\n                4784297440480155258,\n                8207888015979310860,\n                7318324394866297710,\n                1188255145714469504,\n                7497067679833095894,\n                831722367483141911,\n                3342006775070786183,\n                915228369324832271,\n                12214752361799071858,\n                7220077330608179732,\n                13269901002361366384,\n                13156705894018513856,\n                14069485524218015587,\n                16856376646412467543,\n                5458014833622408772,\n                16052033690985477131,\n                3853276807297699899,\n                4361733283329901315,\n                17976611431135375864,\n                7827211709974023187,\n                2672179408451719014,\n                13336920158316088067,\n                13989361937721365460,\n                17089134261482111299,\n                717462569675369116,\n                2677140142520744762,\n                12527274888132316130,\n                16020437139419307993,\n                5109175831372656675,\n                6967613605928103302,\n                10707316610802880961,\n                3751977410812504643,\n                3338250566945759407,\n                5483469392473217290,\n                17852350745219193880,\n                4273571006338555810,\n                14355529799772896463,\n                9097946801457959042,\n                6170305947438052682,\n                3686031910837362999,\n                13659812758484650695,\n                1078072280470978659,\n                10977423862490226031,\n                8329312879062820322,\n                4304430845375483198,\n                11670535966145436284,\n                9843819566701342756,\n                5423791105551635377,\n                15484617895300773730,\n                11737838788253883653,\n                17352638972287011361,\n                6417215765954491552,\n                5210838541415799099,\n                14459766465462519223,\n                11293780554786569855,\n                3913456812295604968,\n                10038604499286389380,\n                83285032545623676,\n                532455486041684132,\n                10447557457915823565,\n                13091470210751298878,\n                12472561867327718392,\n                14986754996345557860,\n                13353714167702784729,\n                14933692721559793075,\n                4392496650147061013,\n                14233597247368097070,\n                13776324136360206128,\n                2519461559911558060,\n                13447307564192855696,\n                17414679919154962748,\n            ],\n            &[\n                13564422861878112234,\n                3275713182933072863,\n                9034480898755624920,\n                2219243711863369707,\n                1414795403602489063,\n                15894568837862895798,\n                5479009852840249103,\n                13548176561971981614,\n                7335026045847382779,\n                8888321385565889284,\n                1374250446640957676,\n                884800927779782031,\n                8670348570372777926,\n                13918154801540915789,\n                10563048209614776992,\n                13969791730415477716,\n                3452835315790744420,\n                7707311332988117775,\n                4057795468009662220,\n                503791220336896693,\n                11739899866722757790,\n                11508632709875839378,\n                2046257727824251571,\n                14147378955881967537,\n                7621816326428068081,\n                11992669611664635262,\n                4065021093573908389,\n                10481004349510473318,\n                10475301724256756509,\n                2524130821276975109,\n                8593134939742261716,\n                15623538309287845872,\n                12317584420983773918,\n                13199980610882090215,\n                13443389318588629073,\n                803739730193348834,\n                17830865805659102381,\n                11251151180776149719,\n                5892904253365508433,\n                17425282708969635181,\n                7064424708573252994,\n                11602656136970912939,\n                9321057698061643115,\n                11015344462881106465,\n                10461212970348321643,\n                14132875754655537304,\n                15753277783360549383,\n                12320964235023516733,\n                15957290977412221921,\n                15001559471941651986,\n                14955046884332716974,\n                10073992907091554325,\n                4815480386394792639,\n                2369717258966377146,\n                9248685362922918367,\n                11146342741382934626,\n                10126995575484511675,\n                10836902283955631137,\n                18212311536097636051,\n                4203660351079577016,\n                7620879273947445884,\n                3547199160053636344,\n                322234022833908928,\n                13570629391930072285,\n                14555015649158595870,\n                5365173841640051462,\n                18270551664241964745,\n                16860982171375384296,\n                1073487768765270579,\n                533079099712269200,\n                18402112985722301945,\n                5434269089519901126,\n                13639392734635113987,\n                8006521979690287885,\n                1545872313913044683,\n                15377554075787870730,\n                751964771297808412,\n                10798750359921054639,\n                11281008050931496235,\n                173570012084088260,\n                3794273797618100167,\n                7040606489685125833,\n                2026261595126825272,\n                4120208834527743861,\n                539222748500084412,\n                79750673604550443,\n                17475108564705202581,\n                7592139295506453445,\n                5023893374592386852,\n                2824914523935320076,\n                3238624402000298552,\n                14131756234617118206,\n                8788539332133441603,\n                12952024446070112298,\n                10155295021066454828,\n                3941570600498808512,\n                6414922728964194522,\n                4076629519262102829,\n                7536766196851355087,\n                6915125713337987783,\n                4580280718549432890,\n                10168080122054976212,\n                15909510579919558189,\n                14519226511270844173,\n                2083762604858883168,\n                13387991133148007718,\n                16840836457014280191,\n                13080359029893923590,\n                11503510372644227919,\n                7953484793188318118,\n                9854115240624462348,\n                5335772307682974862,\n                4936183703810019894,\n                15994627285462031439,\n                10709370317657097612,\n                16199196738320076993,\n                14938272361213950876,\n                15253370694640585418,\n                10690065705918307042,\n                9549292542903499984,\n                8643187064435534254,\n                11624928373665837384,\n                8023398739766654926,\n                17499066444790402375,\n                9801044615559621440,\n                14552811277630127749,\n                13492161609355707245,\n                9655752034551803175,\n                1755722784425137866,\n                11625636701478868329,\n                3624227495361674626,\n                16165268009822921837,\n                8092810235043787525,\n                5788572199295079813,\n                6854648148487456329,\n                14456461148456692547,\n                14310121083997049160,\n                7059162200334339773,\n                14727298439147858639,\n                2177197582567289597,\n                6545559818086725189,\n                10527371808810639250,\n                4564586802867503950,\n                2652020551780949632,\n                6405684903154669518,\n                1737731788352731098,\n                3469893625756210544,\n                15065635631347129418,\n                13174028003011531358,\n                15454741792218022113,\n                14370595360570179099,\n                18037934040444240682,\n                2964154747013421979,\n                13884952913031178416,\n                597641522633545753,\n                13985314547491780345,\n                8360203218690496165,\n                11794669667587913233,\n                8996326275940748604,\n                14117671113926503561,\n                11301961759403099265,\n                6700188071922378791,\n                15385674866154542642,\n                8468030983307924915,\n                7377911706704156399,\n                2604656541341801794,\n                4418057625951919598,\n                2110519074747192474,\n                6101102874337817025,\n                17886250954206311063,\n                15712345996698736982,\n                10487961467211158758,\n                7074394084984481200,\n                9751971849704663337,\n                7679893214057488711,\n                945225664530152672,\n                1245168954077749403,\n                9513611114031241898,\n                10766452668861159380,\n                10755131449239090448,\n                16388278488885030616,\n                2817843987791967489,\n                11763453497935146995,\n                1092574082244810895,\n                1941447274495784860,\n                13572786039056178918,\n                15061182291913076311,\n                6679943993103806154,\n                15408371401907582553,\n                177747470770242167,\n                15593976009786423347,\n                7461104255684909887,\n                5044076910420087327,\n                17630612657815416743,\n                15051698319468276092,\n                14951988637957301647,\n                954336914910981662,\n                10967373098940345847,\n                2121680414874388243,\n                6976201562796491998,\n                6607602757564910564,\n                2432806802785175299,\n                11440086710224789398,\n                2224788034891182999,\n                5665602195014987730,\n                3821334059850073126,\n                8765713375749646572,\n                933515038511209109,\n                9433768612524189229,\n                2467805208666126785,\n                14871840927317419092,\n                5154749137613554029,\n                14265822875736809648,\n                14610870159067374513,\n                12698797236213924014,\n                9569606658962541579,\n                16162107306292390178,\n                12212893918580781835,\n                4614977216445016679,\n                1352141803214945397,\n                7426333917406258422,\n                14520946858416385440,\n                12446204685829260164,\n                2067433179439046305,\n                10861419565872522342,\n                15042750574419434699,\n                8969751642165063673,\n                2375359711870752032,\n                8547092847092151309,\n                3254399133444460923,\n                6176880426174028076,\n                1267184736498266698,\n                6443556206710696839,\n                5582660421956028475,\n                2003441447753754180,\n                14408039201078176692,\n                9878715208788868318,\n                3156012596211387511,\n                2621328682710618956,\n                1343996423359983728,\n                1659922365403643436,\n                9104705095152231651,\n                161254471946633022,\n                17082420100696680164,\n                12948458999893309534,\n                169193814558716113,\n                11181197557527273709,\n                6214014612630290060,\n                4852610222569086650,\n                4759907655510719027,\n                16416424951651935524,\n                977804021685057099,\n                11673776803881765160,\n                4922236924628996318,\n                17921361428612029549,\n                9649330011870916482,\n                620643376032400196,\n                6391102220914894427,\n                1331509376533438689,\n                14618159860008486331,\n                2457140428084980479,\n                14239221334508169296,\n                4552842402472365258,\n                13656369860726864138,\n                15616197149307562605,\n                4979886663474976519,\n                3721352528085365632,\n                10207378704552161011,\n                14450395034610232613,\n                4394727065169978678,\n                6225996635016717724,\n                10125465703568602374,\n                12627017260126529357,\n                6034795013566274191,\n                14507135436863373853,\n                670092389362258666,\n                16892179404337461285,\n                17907525342655368510,\n                6388033394429406697,\n                14608221204689506984,\n                9725811389591747512,\n                15841826865041066838,\n                12726453974670314753,\n                5294708137059751589,\n                12939898091011681833,\n                17545561031992221346,\n                12940997953067270813,\n                8668645445261571392,\n                17465976365740637310,\n                3297459757903247617,\n                5595819579374915626,\n                4255310297204286682,\n                13444083690317354200,\n                13079687451729978985,\n                17936788196509077492,\n                4731803836376614325,\n                8488258826257443557,\n                15872298653522164970,\n                6136303961972758860,\n                8203587474223770207,\n                6640840421159816678,\n                5369017699494121011,\n                13476518943592512132,\n                18148180997156310554,\n                16551428108902177352,\n                10607422095455667650,\n                18070526307796619350,\n                592194588928348733,\n                9500655832933342555,\n                15906694991065813017,\n                5672170756115546545,\n                5164713544570924308,\n                9654099190010511616,\n                15467930191553249033,\n                15324226386462646310,\n                11654051669492811942,\n                3845504882613220875,\n                17995014637765041183,\n                8451419834021139432,\n                4831660661140974858,\n                1270713005767677247,\n                2854249945191704862,\n                11336191586387214070,\n                6230352080584748033,\n                9904554377773225787,\n                13646007744312337579,\n                12876135209922183651,\n                5590478105512035067,\n                16683787122041782881,\n                2912257455736462263,\n                1161124723702057201,\n                14599086761545813923,\n                13759995150092530098,\n                1187669969167762513,\n                2025210147021211292,\n                8404792573797774696,\n                6043699170259360346,\n                8567182735917474580,\n                11673587056707375436,\n                13729589792471955572,\n                6040294236876235718,\n                14118883879821257022,\n                1472762515001555634,\n                5772607514220590032,\n                12005167700240721094,\n                2562574981556592924,\n                4322916215476956068,\n                2931397736166450113,\n                1981334131663903720,\n                14008950785795439721,\n                2258367698152396200,\n                3193592957432138332,\n                18147159661113326998,\n                7636102688703700127,\n                2455873680142820545,\n                13327423214878219110,\n                12145648468670490988,\n                177980942656438245,\n                7435164945754514167,\n                14611156817208949574,\n                9482801842425137904,\n                17579649951803679316,\n                4395194171697397116,\n                2246099311908860608,\n                2326078108126869227,\n                11810587602203652970,\n                16265527186229236462,\n                4210697026328134418,\n                15046104816787660106,\n                5661711221409653164,\n                13045157006959773220,\n                6999069520359938726,\n                5808420710659641279,\n                15787347158818842535,\n                2851830421850001378,\n                5525485631561271262,\n                711754543881977867,\n                9906329062827899634,\n                13595975648907914352,\n                15095498981812294732,\n                14827890138173702931,\n                10114436220688049709,\n                7728356353192609902,\n                11254468346316497641,\n                15153773712001763014,\n                10207835043420703649,\n                8801897675976972272,\n                2550825610727592889,\n                4806829881527541342,\n            ],\n            &[\n                1408954216269482756,\n                17495363275392015072,\n                7569538419880562930,\n                3159444535690624422,\n                10539713616310108624,\n                12287759471187878632,\n                10762226695213450386,\n                13702928698805429873,\n                9308039037015276334,\n                2693272575243867415,\n                4495731759682297278,\n                17957718702553480973,\n                1695225019270301796,\n                12538720478819195709,\n                7355696648235750501,\n                14609468359145504152,\n                17713212205059712263,\n                7067761757765748297,\n                4455678910009476432,\n                14940946772952633580,\n                7353223946372247705,\n                1966704175929577612,\n                17788828899639927690,\n                5873642145421053485,\n                9432511011769375502,\n                8011456734513040486,\n                18383517818628757190,\n                14804344175107599111,\n                14453706668928035575,\n                212174636863869640,\n                18318201713407159667,\n                15868508625313800988,\n                794570724775389143,\n                6890250104153732120,\n                13215618552493662151,\n                15355712080025289288,\n                14989269405365678703,\n                3440332781177776817,\n                1547041711400466409,\n                16949408083533983339,\n                942645885575525869,\n                3593963961417655151,\n                4158508676658397508,\n                13468348757333127520,\n                11862936891535571513,\n                4377454676311890507,\n                13780065204467937543,\n                15803361323352221769,\n                953489208716892192,\n                17364437917524369478,\n                11384216985369504647,\n                3360175615399279011,\n                7215910295314039412,\n                4449007827158713949,\n                8690290001027040683,\n                772293093052269703,\n                6926666182768252467,\n                7985255216129545232,\n                6665284360882852586,\n                15207741179893001845,\n                15703767897436764321,\n                7914253539478783255,\n                5903013543557664007,\n                4774214457440373599,\n                14080179030683024826,\n                9434035144822929636,\n                5367813517486193633,\n                3304878828952757511,\n                10243535705902406930,\n                1884627861659715947,\n                4978189310017102374,\n                1216698964122740709,\n                15100941079818973803,\n                1749141348527036567,\n                8743320843818547513,\n                9958778070878908244,\n                7858295599866849905,\n                15078222426471283656,\n                7336868524011917281,\n                10555852968409722407,\n                6944256015177961916,\n                17387864131687949624,\n                632732732269768198,\n                16900672962472231809,\n                13484064257890193159,\n                4044769021954392546,\n                15294554445007953309,\n                330214884931606053,\n                8773227351193839544,\n                9933428285510948540,\n                2903959890557503867,\n                6265719520493470019,\n                14025203023893391008,\n                11647283945890530059,\n                13249598051183746227,\n                2074546550971361923,\n                12247825023511227150,\n                2784768583222188866,\n                6407637641382682182,\n                9752576266849520115,\n                15195951757710781232,\n                13752087641373844065,\n                15476511142100387305,\n                14236723356162907578,\n                10822337465577716429,\n                12814664143156135314,\n                10894509357772940167,\n                12457195754516214135,\n            ],\n            false,\n            &[\n                13415846491005578619,\n                13584292933077885365,\n                441953663009890135,\n                7210335717300495676,\n                13057964354000775464,\n                10292169585687982086,\n                12251907425151490553,\n                7386686741811236397,\n                291437469999876541,\n                1843506473757893895,\n                1231339981456887992,\n                7336311449497199296,\n                7176633324357201366,\n                658513238018005674,\n                3117977571063681035,\n                2261787922928337152,\n                4069182574784670800,\n                4786347950692670036,\n                955338065659184695,\n                17893231513983993127,\n                15970449235194675852,\n                18222079201306580439,\n                7381385984359606163,\n                13894071053001480008,\n                17968185102194547794,\n                9652567975385349040,\n                4579378768094593374,\n                2929413774035294909,\n                4858585721157204024,\n                432346869077563062,\n                16632527599028610709,\n                2969760407998231671,\n                8723191162795424532,\n                2205885763249224226,\n                4090893610978417832,\n                727335411538814681,\n                692739901795118471,\n                16185752384798441976,\n                9407352218349207860,\n                15954006133480937416,\n                16002700437312273924,\n                1803166211419435125,\n                16572732079534009876,\n                10103383220489568096,\n                14055635057552795086,\n                6204301430393608593,\n                16304361060342210151,\n                1077463458077785016,\n                846584174947782921,\n                14549143985217156839,\n                4794451719446030954,\n                15070589344871049989,\n                11768766648218861349,\n                193778540633917339,\n                2069627918507475641,\n                17004474480886564748,\n                6387833454863576557,\n                7403048767127663654,\n                6361857152378524096,\n                14590329534696373089,\n                3264224706753004828,\n                15794673518624161617,\n                8471728032197957118,\n                11123707683472607781,\n                5926672570922373756,\n                8353224757488864005,\n                3920855214133136556,\n                4088762124331852387,\n                1351340558126331083,\n                1064663312281497792,\n                6722208927949900059,\n                8191142535859454935,\n                13932575231193375718,\n                13250838834435891833,\n                2482941775014508642,\n                6361967846756283686,\n                12230741962057003367,\n                5322339673572617872,\n                2461502783752535986,\n                15456869581410217577,\n                13516762109813035487,\n                17722517240817407655,\n                12006022535464060948,\n                7693156444704391120,\n                589139607677986600,\n                10992862276542439592,\n                15638442660969354281,\n                6302046879465388504,\n                18186347373545845422,\n                17661768623582090594,\n                11182202442217703360,\n                10323032349274612161,\n                351359225361309232,\n                17208481651320700686,\n                7762799900361196225,\n                18130637050502143037,\n                3527936976222881348,\n                7787458878406549730,\n                9785865244475232340,\n                9313322536748638436,\n                6628693715403354820,\n                8155584772586242242,\n                4298548228131846405,\n                6216995875383402160,\n                8745213713616642956,\n                6205924554981340524,\n                539046468165950413,\n                9024163979699199629,\n                7137709973749463062,\n                4302338034003647906,\n                13829701518024075554,\n                3020599208667394924,\n                2771484371923677669,\n                1332418334924131169,\n                15030111211658663300,\n                8687405539746619117,\n                3255425958083223853,\n                17607580850311952887,\n                6117457031153941598,\n                9667238428907972490,\n                16866165930381488058,\n                9279876560625206616,\n                7219817020774185353,\n                15408311020361635593,\n                10627051636551065581,\n                15435960991076989754,\n                2125427069228602466,\n                14834800748267676770,\n                8338000901565415696,\n                9843107756445251924,\n                11726258180166518722,\n                13216133507413853832,\n                9548542073000115784,\n                4477904860207934342,\n                11559138083775928810,\n                14261941916295954455,\n                2935454921278307407,\n                14578760607502424030,\n                1741904848044422540,\n                10910867960823424013,\n                16471597397244360629,\n                5831225248121651892,\n                12850983616913099920,\n                4576475941872797279,\n                10819576084838658923,\n                9911449990461349025,\n                8071318423647144806,\n                12934895766920841548,\n                1934332324237869529,\n                1138130330895714883,\n                7749002603757035655,\n                6467404987016890639,\n                11255316830064030538,\n                3018235715458169811,\n                15201809744582983527,\n                16342498733210722843,\n                7708152387679592258,\n                9492172974580805134,\n                5866422978520553541,\n                16455719455662584469,\n                13731761368830060542,\n                18292973038079145164,\n                9007521683809498606,\n                11536176422926297746,\n                17069970006150149865,\n                2103718123709857344,\n                9551485804718272266,\n                12273976131107017479,\n                1653874358479460972,\n                10193109839436245173,\n                17209319149808494347,\n                2304536837571895652,\n                6062765286861083817,\n                4897491367356012054,\n                10921490709194148600,\n                7489492882796549046,\n                15346457168511978884,\n                15415284042926257534,\n                3288025229571018975,\n                5490937743897191968,\n                12030244067941846502,\n                6649465014690650122,\n                13043829245604474765,\n                16104656800587069133,\n                15901113890052229676,\n                3837090179127712297,\n                2184801241947831767,\n                14724333584011117924,\n                18042748113599866974,\n                15635242211549384225,\n                11210521843889130992,\n                9474616548314628408,\n                7072588307383545068,\n                7764739347402168434,\n                6456269087620448997,\n                13468842728337937173,\n                10407803768686058347,\n                58702129805853206,\n                9751180010069185513,\n                6064452714620219927,\n                13392800693556694325,\n                18372122025912817085,\n                7516403896475345556,\n                336160785595278081,\n                16607869224650226242,\n                4883984113455670464,\n                7621647467206333443,\n                7975633505870931502,\n                10173870707804084376,\n                15734058126402681870,\n                13198172970791238175,\n                6074102067907439304,\n                7289841954562682843,\n                16642477840387047386,\n                17735102900144975086,\n                4380312697910692464,\n                17348779887199611248,\n                3519767210720195345,\n                3200318167890176110,\n                8763164776273977859,\n                6372373083461058525,\n                7012561740996573104,\n                16229141474971594905,\n                1111767702608658668,\n                10378536678592366267,\n                9247600318566456250,\n                17456358751309498336,\n                8398075459962870518,\n                398315841023187114,\n                10277410686246662542,\n                218781901157848211,\n                618572494658903822,\n                3804414506632334467,\n                17482725095963661462,\n                11945563631700693151,\n                11377949134930807832,\n                11388696917522764394,\n                12397282866398662460,\n                17984588793337249647,\n                11852155346818929323,\n                6282040579217154095,\n                5865043035453987718,\n                12490608990412245333,\n                8662459463589993440,\n                9703534627155947683,\n                9083465368456889169,\n                17385583284480619421,\n                12619315429611258952,\n                4780803560699965289,\n                9760114025973133776,\n                6710382011811335688,\n                4756178837305619434,\n                11338794508489062066,\n                5806084365129173257,\n                5858402760317423580,\n                16972385428332971155,\n                7980041598360573257,\n                17539414382812231878,\n                2807108495977968496,\n                12347721638665260177,\n                2657388420803290454,\n                18291179742275985307,\n                17290651979906283695,\n                18248938193230918423,\n                9700793153607985827,\n                1581581530211316863,\n                421641550279827055,\n                3550734485990309734,\n                8838675277867213091,\n                2325841972611425748,\n                12896051317905757266,\n                2634241676839630629,\n                9793375243415420023,\n                4956535453535085870,\n                1394001153426732084,\n                12161423949049475376,\n                3204414789776213360,\n                3766999954663739543,\n                2885444883803065223,\n                17796581505208708505,\n                7118003311319221436,\n                11737838788253883653,\n                17352638972287011361,\n                6417215765954491552,\n                5210838541415799099,\n                14459766465462519223,\n                11293780554786569855,\n                3913456812295604968,\n                10038604499286389380,\n                83285032545623676,\n                532455486041684132,\n                10447557457915823565,\n                13091470210751298878,\n                12472561867327718392,\n                14986754996345557860,\n                13353714167702784729,\n                14933692721559793075,\n                4392496650147061013,\n                14233597247368097070,\n                13776324136360206128,\n                2519461559911558060,\n                13447307564192855696,\n                17414679919154962748,\n            ],\n        );\n        test(\n            &[\n                3218961335417250355,\n                17081672491164411676,\n                3707650621435880034,\n                12226464081058805510,\n                16651181251520783855,\n                13640009159697172462,\n                4751991872429123135,\n                3148650123879180586,\n                1277783667166791164,\n                8130851378765417486,\n                5973994279255982458,\n                9850645253643520175,\n                7138807895287208194,\n                15375995502112115974,\n                3398898578710810979,\n                17572162751360544244,\n                8819660083286717264,\n                69135776031233389,\n                9998360095371859020,\n                1528928997031509791,\n                12805160204156629031,\n                8189615704171780683,\n                2467675461409164019,\n                782953727844991423,\n                6355321416294201810,\n                3548418573913501932,\n                1385195069445654350,\n                13512602943141297700,\n                3524217759662463436,\n                15981277851376785202,\n                12068598413178807016,\n                18233498041601520144,\n            ],\n            &[\n                18165976559003511263,\n                9223225080462702306,\n                8750698670891994416,\n                10120417502780222451,\n                7032717053294267869,\n                7737301656727013632,\n                18225658593706260392,\n                7369113716849300883,\n                6897596754170972342,\n                12718107066356504381,\n                9547303833255868241,\n                7363473626086637667,\n                1289803166471838781,\n                11172671997578955149,\n                11576917227142009738,\n                4808558430339823806,\n                14087513123418218680,\n                8335805388080937297,\n                6817204158716710723,\n                6461426422998966208,\n                1365262330733891893,\n                9676053381450021925,\n                13152204186994838090,\n                13956491013462127564,\n                2322954839434490857,\n                6310077930127744700,\n                4095927283220333117,\n                9197971078622697427,\n                16090563028856198822,\n                11899164972605215873,\n                7553212707478476751,\n                1757047503535568327,\n                14107358592894281225,\n            ],\n            &[\n                2828382444363234501,\n                14019650302598222399,\n                7149153771500111721,\n                5808789510078375243,\n                11746020933581287784,\n                13963712573526024090,\n                7948303882471336756,\n                1363675852130084180,\n                6084755510768204882,\n                1350344795057047203,\n                9774965847686534495,\n                3240922473188564283,\n                15530555198365657320,\n                9503969704425173615,\n            ],\n            true,\n            &[\n                3405376264873912531,\n                12732472809437054653,\n                130818493222944537,\n                1430180103580323943,\n                11834290994594767473,\n                16311544963273773940,\n                14852866940109114958,\n                11049173384187452405,\n                17390023561952283067,\n                8415736510262004193,\n                7352370979091376738,\n                10787900486113600253,\n                15465246806979411530,\n                12013049514342915482,\n                15910934446693912634,\n                13226375350164320552,\n                12041814675416282230,\n                17264487603347577556,\n                8934954480948017545,\n                1528928997031509791,\n                12805160204156629031,\n                8189615704171780683,\n                2467675461409164019,\n                782953727844991423,\n                6355321416294201810,\n                3548418573913501932,\n                1385195069445654350,\n                13512602943141297700,\n                3524217759662463436,\n                15981277851376785202,\n                12068598413178807016,\n                18233498041601520144,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_approx_fail_1() {\n    let ds = &[3, 4, 5, 6, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer_approx(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_approx_fail_2() {\n    let ds = &[3, 4, 5, 6, 7, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer_approx(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_approx_fail_3() {\n    let ds = &[3, 4, 5, 6, 7, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer_approx(&mut [10, 10], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_divide_and_conquer_approx_fail_4() {\n    let ds = &[3, 4, 5, 6, 7, 8];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_divide_and_conquer_approx(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\nfn verify_limbs_div_approx_2(\n    qs_in: &[Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    q_highest: bool,\n    qs_out: &[Limb],\n) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let base_q_len = ns.len() - ds.len();\n    let mut qs = qs_out[..base_q_len].to_vec();\n    if q_highest {\n        qs.push(1);\n    }\n    let q = Natural::from_owned_limbs_asc(qs);\n    let q_is_too_large = q != expected_q;\n    if q_is_too_large {\n        assert!(q > expected_q);\n        assert!(q - &expected_q <= 4);\n        assert_eq!(expected_q * &d + expected_r, n);\n    } else {\n        assert_eq!(q * &d + expected_r, n);\n    }\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n}\n\n#[test]\nfn test_limbs_div_barrett_approx() {\n    let test = |qs_in: &[Limb], ns: &[Limb], ds: &[Limb], q_highest, qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n        assert_eq!(\n            limbs_div_barrett_approx(&mut qs, ns, ds, &mut scratch),\n            q_highest\n        );\n        assert_eq!(qs, qs_out);\n        verify_limbs_div_approx_2(qs_in, ns, ds, q_highest, &qs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - q_len + 1 < d_len\n        // - d_len_s == i_len\n        // - !highest_q first time in limbs_div_barrett_approx_preinverted\n        // - q_len == 0 first time in limbs_div_barrett_approx_preinverted\n        test(&[10; 3], &[1, 2], &[0, 0x80000000], false, &[10, 10, 10]);\n        // - q_len + 1 >= d_len\n        // - d_len_s != i_len\n        // - !limbs_add_limb_to_out(scratch_2, &ds[d_len_s - n..], 1)\n        // - q_len != 0 first time in limbs_div_barrett_approx_preinverted\n        // - i_len == chunk_len in limbs_div_barrett_approx_preinverted\n        // - q_len == 0 second time in limbs_div_barrett_approx_preinverted\n        // - !(limbs_slice_add_limb_in_place(qs, 3) || carry) in\n        //   limbs_div_barrett_approx_preinverted\n        test(&[10; 3], &[1, 2, 3], &[0, 0x80000000], false, &[8, 10, 10]);\n        test(&[10; 3], &[1, 2, 3], &[3, 0x80000000], false, &[8, 10, 10]);\n        // - q_len != 0 second time in limbs_div_barrett_approx_preinverted\n        // - i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_div_barrett_approx_preinverted\n        // - n != 0 in limbs_div_barrett_approx_preinverted\n        // - limbs_cmp_same_length(rs, ds) == Less\n        // - i_len != chunk_len in limbs_div_barrett_approx_preinverted\n        test(\n            &[10; 100],\n            &[\n                1940112928, 3379564708, 4199340399, 1881321211, 3929726949, 459862695, 1350630556,\n                2137584308, 1243785894, 983397001, 140271427, 1266031183, 3559919295, 702977622,\n                3883080853, 1830599918, 3030922777, 2650241556, 2807154392, 2218698435, 1904442293,\n                2992923456, 1481791037, 4079300846, 2680084216, 656285791, 3396057405, 272065717,\n                766725345, 1681255263, 1707458816, 1535744308, 3830462997, 1607479268, 3475252676,\n                933054715, 4058518411, 1139150315, 1176656025, 2657461768, 3149905151, 2833828072,\n                1407836276, 189062495, 3008111084, 3911286362, 3969377587, 520858887, 1921886086,\n                2410034665, 1853865087, 1218625232, 3157059817, 1933332942, 1324005415, 2613648167,\n                575584498, 1622716448, 2776523679, 1406325147, 1675354862, 559193409, 3342355233,\n                2906475403, 692112491, 30493944, 2020871018, 3990740411, 1951624334, 522929143,\n                339689612, 1674309350, 1834377980, 548522470, 1069818460, 3188037910, 3867849691,\n                141774569, 2470564281, 821388456, 4277724930, 3388680598, 3502532015, 3274512650,\n                734688334, 1114445519, 4090718315, 3618580673, 2579392987, 1832470019, 497126331,\n                752679886, 3640533944, 1359185510, 2078361523, 766787155, 3847437498, 1508816472,\n                3627438612, 1634541191, 742795696, 2960390854, 3550088312, 3226573591, 2822842868,\n                3362189143, 3928024536, 2437449313, 2184757656, 3728018796, 3935919847, 948513362,\n                2073970870, 135663041, 2352180020, 74067810, 2805347538, 2583013940, 2822521171,\n                3940279282, 1038996723, 1890047439, 511776527, 3353284478, 2377633924, 1797661892,\n                1357303377, 2035070964, 1462275246, 529813385, 240201619, 2189253653, 736920794,\n            ],\n            &[\n                543800634, 2770754899, 3204213496, 689485059, 1826336873, 1076055628, 4272024858,\n                559589670, 2749860031, 1191446963, 568428784, 3084221767, 2956512443, 3015109082,\n                4142890122, 1553810981, 1616811544, 2640988818, 4239702102, 3215569246, 4002923809,\n                2144877501, 1973532991, 4210632120, 245033969, 3777546533, 2341963108, 3264590407,\n                2911498298, 3029909661, 3030243778, 3822448105, 3778161582, 4002513281, 405410583,\n                2595147981, 1384025271, 2688968055, 1208777176, 1722256783, 1319267870, 3011578504,\n                2249499744, 1245802205, 2315940873, 1685775875, 3654277152, 3113432869, 924331621,\n                1024360203, 3411941166, 1488722938, 14894550, 2976848938, 1792408550, 1006468168,\n                758547548, 2693569089, 268361906, 3490575936, 2248882501, 3137929560, 2509320863,\n                2201587434, 926371577, 1243694325, 1112023631, 2791032478, 4081106682, 3051719441,\n            ],\n            false,\n            &[\n                2057668, 2838783492, 4112571934, 2985797927, 3502010766, 249276105, 2839050469,\n                4137353790, 2017993048, 1573570544, 2879477808, 2277205117, 3638192330, 748457752,\n                3491012018, 1271254053, 513425262, 1211823879, 867012819, 2598440433, 1263651369,\n                2021347718, 4249300861, 2804939275, 2973559875, 4064802504, 1895088151, 3564064077,\n                4027716297, 3914830075, 1990115176, 1854504344, 4070846044, 9890028, 3874191625,\n                3177041731, 3239277327, 1987223315, 3008019786, 2383741649, 1213911302, 1443565130,\n                976567504, 3330200204, 1895735680, 141240306, 4207639562, 4048459734, 2216965594,\n                4199097617, 2357661853, 3838741723, 3334878567, 3391363083, 1245835070, 263088765,\n                3602928895, 211195285, 1878503011, 3634753202, 1476824331, 2380710600, 1037136857,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - n == 0 in limbs_div_barrett_approx_preinverted\n        // - r != 0 in limbs_div_barrett_approx_preinverted\n        test(\n            &[10; 28],\n            &[\n                1289672612, 59863601, 2751157317, 2012015018, 753744884, 727617566, 1322732201,\n                3978203284, 2280484600, 3096956045, 3846897372, 4039916165, 3268087487, 2544740714,\n                3583698031, 3555712249, 1472500374, 3434100279, 100408066, 1521129569, 3806609799,\n                552198579, 2644816287, 1159339267, 3543498888, 171157498, 3510108197, 1568117536,\n                1428232726, 2356104756, 64268959, 1999542893, 1166391479, 4277110967, 3494387915,\n            ],\n            &[2774518906, 1389562763, 2693574400, 665477625, 1306831105, 2326033317, 2701983394],\n            true,\n            &[\n                1959935944, 2176722772, 2263227298, 52031251, 3734871887, 3327523565, 110124788,\n                3702612244, 3495588882, 1155949119, 2274365757, 1700149681, 157693893, 1287343110,\n                1404704510, 3815550465, 1225032011, 1088256607, 2172622843, 4270557118, 3435679666,\n                4256455092, 679164912, 4183948729, 591513024, 2958428852, 959546540, 1259575285,\n            ],\n        );\n        // - limbs_slice_add_limb_in_place in limbs_div_barrett_approx_helper\n        test(\n            &[10; 1],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                524287,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2147483648,\n            ],\n            true,\n            &[u32::MAX],\n        );\n        // - limbs_add_limb_to_out in limbs_div_barrett_approx_helper\n        test(\n            &[10; 119],\n            &[\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[\n                3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - highest_q first time in limbs_div_barrett_approx_preinverted\n        // - i_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_div_barrett_approx_preinverted\n        // - limbs_cmp_same_length(rs, ds) >= Equal\n        test(\n            &[10; 100],\n            &[\n                2117335661666050915,\n                12541399304153348003,\n                946298540148951811,\n                3706040940807058638,\n                8245328193712015182,\n                2995778607291858486,\n                9642363239685223935,\n                6402096640921797670,\n                11712805591752250715,\n                3201293761729543527,\n                2067868456322875388,\n                14022668248311848844,\n                4632052274282811479,\n                14328717146754990094,\n                14774171516395200100,\n                3932090441073088420,\n                257112211266950213,\n                8641538702124596212,\n                3125093651287853737,\n                17086253003900284664,\n                13301324934271401692,\n                17351307810524827327,\n                10929578147013387375,\n                15271667824914109078,\n                14749348389589883650,\n                6533201755640185223,\n                2371674840347488671,\n                4979324240277110920,\n                735115859885293605,\n                6735013534832335382,\n                10119392873034328735,\n                8587971333550618807,\n                18370051728122323147,\n                9585925514203520684,\n                10610241536420552110,\n                5468885590163205010,\n                9820231198117134549,\n                11691363752858795073,\n                17305814922233352619,\n                859726499782635315,\n                191600792977201905,\n                6645113919639439987,\n                10186139014514132915,\n                13892914247169168407,\n                6236711305574503596,\n                11144904233279320413,\n                974401940116314268,\n                626033050094744466,\n                2363222200699405972,\n                5179961716326453662,\n                1671413606631599949,\n                16140149794420865699,\n                4525104777442472653,\n                15677954115433676863,\n                2638708390995098468,\n                11988738016208980482,\n                9157465979869425297,\n                13700136748402110667,\n                12843998927271872117,\n                8172056912358636191,\n                11114503332573068878,\n                12203499984806198697,\n                18293693840507282811,\n                2347317225764209541,\n                7620549999680469515,\n                266221208971070149,\n                7404318409115354801,\n                11821070343886468455,\n                16743495774393393347,\n                10903651574167871901,\n                8120955791898229966,\n                6256918112663531036,\n                4642094091398991189,\n                17666442779793022150,\n                6979752362584161816,\n                738088006020097171,\n                119461506395194534,\n                2707265934504496803,\n                3596152365672913357,\n                14919229675768492176,\n                15711892957093044137,\n                4388966441873938872,\n                7245386709333796615,\n                977953205631793823,\n                5781210341467685855,\n                5753014960288580146,\n                15207218610262659062,\n                4952531357988639834,\n                15654095960314850064,\n                16211757785947051034,\n                1847823176222065635,\n                13267820071825624266,\n                7825351897308816877,\n                2314230949902785215,\n                13036201409691464885,\n                6084371089556728596,\n                4297442532874624612,\n                532433185229873311,\n                3442779195445707888,\n                2185935771567302024,\n                13911571822971487392,\n                6709028122157209948,\n                8941147419783910451,\n                10057960523899590670,\n                3902932452596575823,\n                18330616827289950879,\n                16003030155941114765,\n                14460484829934394726,\n                3301932590566986553,\n                2576945510271437558,\n                338533333586368208,\n                17133311687376929054,\n                15155994049404735760,\n                9946561124819597870,\n                983339636912873569,\n                7933316580780536493,\n                10915381430875882064,\n                12068808550152064359,\n                1144295877076351834,\n                6170469241760056335,\n                1371470265702819753,\n                8726850576136926792,\n                10647848489928733096,\n                8768829048069168648,\n                13771635456188648954,\n                17554939941431219329,\n                9462385985825033541,\n                748159237152854524,\n                14199895651244313572,\n                9044210482484213648,\n                3880401870711113518,\n                1694971440240542063,\n                13547801197479934494,\n            ],\n            &[\n                6673567349177488920,\n                11342960606651398230,\n                13810764753596302625,\n                9212178722694740287,\n                18084527251132181489,\n                16224438820695147876,\n                14021309035811827770,\n                13013362906859690434,\n                16417289605410335662,\n                17190663644106068759,\n                11146075708059454647,\n                11549029857422506456,\n                7397036559618436638,\n                12934631186266104928,\n                5350679730075628553,\n                7240352255165061152,\n                13372092351570783845,\n                4399593574620862254,\n                6394016331529930198,\n                12785468835634740198,\n                4322747866783581276,\n                11568791147039875250,\n                14991909491573471557,\n                13477304839860990623,\n                9455746029240930041,\n                5341626453207818831,\n                11987393219164946170,\n                4239560960510469879,\n                1182652798618482486,\n                3574433530016984198,\n                14570885001650188449,\n                16721218276523736662,\n                17582595396154395868,\n                10645279465349745085,\n                8467600286036697431,\n                1335601409485137284,\n                5427053117344459552,\n                3050086815044747081,\n                16544140034308828175,\n                16944072159927844572,\n                1776035917115670079,\n                6854263689321209087,\n                1395326973393056556,\n                13328497288435313800,\n                9104953879994634550,\n                13847967313738589938,\n                2043265995513605223,\n                13193995464379134227,\n                5009710316527156329,\n                14279264770257730496,\n                10408308917163910844,\n                5580572910800173671,\n                3609059974654018173,\n                8878539685629369010,\n                15620596077589725028,\n                3646029498286920979,\n                16172850651808491619,\n                15245408082837971190,\n                4561308773951735888,\n                11261441942590830857,\n                14221474405402406790,\n                2504490064796610713,\n                17165895347857529984,\n                12091565718300353127,\n                14873026879861808494,\n                7208276890744094311,\n                13958391986410864884,\n                8096376858901544433,\n                18161016816080485352,\n                9946585096298233506,\n            ],\n            true,\n            &[\n                7142549011416014880,\n                14684691169135507473,\n                1822120729679146161,\n                11841933122038769821,\n                4526355225639296177,\n                8468787586279727777,\n                15714230407431964682,\n                18333537779008451159,\n                16040493219692071303,\n                2049960712985714117,\n                18060699260844232006,\n                11436218371188111964,\n                18247749997104652519,\n                10208028585116703246,\n                6519062707001442120,\n                8663593385407998358,\n                9429327332580418592,\n                11147294715178482267,\n                12622325713357218079,\n                9917628001464406797,\n                8948638694752077597,\n                413202514200140930,\n                13469381266876650437,\n                10995920589784133757,\n                10156568832733545237,\n                7515628739788185693,\n                3313803886141758450,\n                16133860033309869788,\n                13595249790827433309,\n                1761826376674293671,\n                9950121844277925507,\n                7711011638364466454,\n                12239101884168908635,\n                9962222649144848616,\n                9495651849838993161,\n                10726943428780681871,\n                3103236698633674082,\n                18053635426183322245,\n                14277576247420605289,\n                17591792639916063380,\n                11239385027227950840,\n                4103032036605369386,\n                266316975199678275,\n                4262765348359631356,\n                5507126713842059802,\n                8339639832375105582,\n                9642119792134182293,\n                485127249403759007,\n                3452585660397695342,\n                17804977833202015222,\n                1531864037104263565,\n                12597964144177527097,\n                2015301325553239081,\n                1705158706504614015,\n                3632321048208706170,\n                2599148812642503905,\n                18033201044296677048,\n                10122148881615284352,\n                12336433997173007311,\n                8939795914080226824,\n                9195323771605999386,\n                1966840646595138765,\n                6678745632744258779,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_approx_fail_1() {\n    let ns = &[1, 2];\n    let ds = &[0x80000000];\n    let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett_approx(&mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_approx_fail_2() {\n    let ns = &[1];\n    let ds = &[0, 0x80000000];\n    let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett_approx(&mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_approx_fail_3() {\n    let ns = &[1, 2];\n    let ds = &[0, 1];\n    let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett_approx(&mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_barrett_approx_fail_4() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[0, 0x80000000];\n    let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n    limbs_div_barrett_approx(&mut [10], ns, ds, &mut scratch);\n}\n\nfn verify_limbs_div_2(qs_in: &[Limb], ns: &[Limb], ds: &[Limb], qs_out: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let expected_q = &n / &d;\n    let base_q_len = ns.len() - ds.len() + 1;\n    let q = Natural::from_limbs_asc(&qs_out[..base_q_len]);\n    assert_eq!(q, expected_q);\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n    let r = n - q * &d;\n    assert!(r < d);\n}\n\n#[test]\nfn test_limbs_div() {\n    let test = |qs_in: &[Limb], ns: &[Limb], ds: &[Limb], qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        limbs_div_to_out_ref_ref(&mut qs, ns, ds);\n        assert_eq!(qs, qs_out);\n        verify_limbs_div_2(qs_in, ns, ds, qs_out);\n\n        let mut qs = qs_in.to_vec();\n        let mut ns_cloned = ns.to_vec();\n        let mut ds_cloned = ds.to_vec();\n        limbs_div_to_out(&mut qs, &mut ns_cloned, &mut ds_cloned);\n        assert_eq!(qs, qs_out);\n\n        let mut qs = qs_in.to_vec();\n        let mut ns_cloned = ns.to_vec();\n        limbs_div_to_out_val_ref(&mut qs, &mut ns_cloned, ds);\n        assert_eq!(qs, qs_out);\n\n        let mut qs = qs_in.to_vec();\n        let mut ds_cloned = ds.to_vec();\n        limbs_div_to_out_ref_val(&mut qs, ns, &mut ds_cloned);\n        assert_eq!(qs, qs_out);\n\n        let qs = limbs_div(ns, ds);\n        let qs: &[Limb] = &qs;\n        assert_eq!(&qs_out[..qs.len()], qs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - q_len + FUDGE >= d_len\n        // - bits != 0 in limbs_div_to_out_unbalanced\n        // - bits != 0 and two-limb division in limbs_div_to_out_unbalanced\n        // - carry == 0 in limbs_div_to_out_unbalanced\n        test(&[10; 4], &[1, 2], &[3, 4], &[0, 10, 10, 10]);\n        test(\n            &[10; 4],\n            &[1, 2, 3, 4],\n            &[5, 6],\n            &[2624702236, 2863311530, 0, 10],\n        );\n        // - bits == 0 in limbs_div_to_out_unbalanced\n        // - bits == 0 and schoolbook division in limbs_div_to_out_unbalanced\n        test(\n            &[10; 256],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1ffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3221225472,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294836224,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffffc,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1ffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294836224,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                255,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294934528,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                63,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3221225472,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                16,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x80000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x20000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n            ],\n        );\n        // - bits != 0 and schoolbook division in limbs_div_to_out_unbalanced\n        test(&[10; 3], &[0; 3], &[0, 0, 1], &[0, 10, 10]);\n        // - carry != 0 and !highest_q in limbs_div_to_out_unbalanced\n        test(&[10; 3], &[0, 0, 2], &[0, 1], &[0, 2, 10]);\n        // - q_len + FUDGE < d_len\n        // - bits != 0 in limbs_div_to_out_balanced\n        // - bits != 0 and schoolbook division in limbs_div_to_out_balanced\n        // - carry == 0 in limbs_div_to_out_balanced\n        // - *scratch_2_head > 4 in limbs_div_to_out_balanced\n        test(\n            &[10; 3],\n            &[\n                2004133373, 2208332663, 2302126873, 2101318142, 1556208712, 845422188, 1055855393,\n                3791075321, 2255139682, 1837642188, 3011157525, 2408855870, 3298400249, 965057055,\n                1159107131, 881492493,\n            ],\n            &[\n                1319347431, 2633328929, 1132813012, 2337676551, 3505724291, 3258373855, 2627638070,\n                4109307798, 2791039276, 3812830525, 922865115, 1132868227, 50383791, 3208398854,\n                737302397,\n            ],\n            &[839942670, 1, 10],\n        );\n        // - bits != 0 and two-limb division in limbs_div_to_out_balanced\n        // - carry != 0 and !highest_q in limbs_div_to_out_balanced\n        test(\n            &[10; 3],\n            &[\n                2004133373, 2208332663, 2302126873, 2101318142, 1556208712, 845422188, 1055855393,\n                3791075321, 2255139682, 1837642188, 3011157525, 2408855870, 3298400249, 965057055,\n                1159107131,\n            ],\n            &[\n                1319347431, 2633328929, 1132813012, 2337676551, 3505724291, 3258373855, 2627638070,\n                4109307798, 2791039276, 3812830525, 922865115, 1132868227, 50383791, 3208398854,\n                737302397,\n            ],\n            &[1, 10, 10],\n        );\n        // - bits == 0 and two-limb division in limbs_div_to_out_unbalanced\n        test(\n            &[10; 233],\n            &[\n                1120072065, 20030636, 2023698558, 3410014045, 1693005413, 3940821177, 4061897489,\n                3904598150, 1239781075, 2248531977, 1084346740, 3406083359, 715154118, 3499417710,\n                3315749667, 3834314996, 3974469907, 2814389907, 3511455607, 3248220325, 909379929,\n                1899385878, 877989498, 598994477, 3240673535, 2330636314, 306792275, 1197844499,\n                516880032, 2699904331, 945876341, 4162862896, 2209400052, 1190718041, 1558127761,\n                743003038, 846606641, 167779957, 442248369, 4254081958, 378292991, 2269632031,\n                2106325614, 2903467429, 2325283078, 3655634793, 2243956483, 48899184, 1510394527,\n                1220327074, 1986122738, 2771000282, 3801992586, 3807619027, 471210965, 240054629,\n                4138891889, 507966513, 2608584883, 3695585074, 1142049536, 1815447345, 878847029,\n                2425512616, 3404280273, 1809800602, 2708940436, 2746635100, 4246404208, 2039835981,\n                4031917112, 1996943450, 2580411493, 1129753117, 1562335482, 3454161890, 1304546076,\n                266633008, 2243463006, 1495416944, 3194149979, 1187229392, 2598096522, 2717656416,\n                1723138812, 321773293, 3528634550, 4012356064, 361342150, 1407382791, 281788878,\n                387885890, 2614365524, 3674715918, 3735628736, 4055198582, 3441555171, 2873512886,\n                881773623, 2426850436, 308355156, 4092323473, 976626532, 3349954092, 3198525613,\n                1279820517, 1618078850, 1918325121, 535344811, 988051597, 837895483, 3080823321,\n                2284227193, 3889421868, 4104768675, 3163480219, 3024832314, 2949487671, 3104325999,\n                4157724952, 4168869313, 721690106, 3562272836, 4007453971, 550776419, 1766890521,\n                3691651042, 2002769424, 3017703356, 622145868, 984506967, 872390633, 1401216125,\n                2631526378, 3112269305, 432369818, 193905809, 1155233014, 752554312, 145186046,\n                92244317, 3561426112, 1231358008, 454785216, 3928879637, 3214356742, 1926040456,\n                2162944696, 54812965, 2689940083, 3697347877, 2642017440, 1597744969, 861917368,\n                3358318171, 1108217254, 1094946939, 4142346894, 3219881738, 3673252603, 3653156321,\n                1364144882, 942313725, 1035715400, 2330944680, 1224099910, 3349983481, 356524863,\n                3275906855, 3285206514, 4248893603, 4088970118, 89006304, 23030721, 3809886990,\n                2867877807, 2930760156, 2433798057, 3852621687, 3592557226, 3512908344, 1565719632,\n                2354066426, 478797990, 1152699515, 318340209, 760174225, 1631571749, 2271463377,\n                650468891, 507504586, 2693229321, 3120669668, 2544094891, 3144973242, 3636388382,\n                1159049189, 1889357596, 1384924984, 43707224, 3718061345, 2543662513, 3729944648,\n                2644670969, 1377639119, 168824066, 2584279623, 4277720720, 1318206723, 1379145863,\n                3963963461, 4034653496, 3968013334, 2828714546, 1851135170, 1939714189, 3010931551,\n                226867970, 3933697914, 3421927438, 966963996, 1035716399, 790589571, 1188590505,\n                555295916, 3048626203, 3577474856, 155510811, 3536545976, 239763597, 2799111567,\n                3792587555, 4190649328, 3101199245,\n            ],\n            &[3290181794, 4048330047],\n            &[\n                3781336300, 393098052, 601926039, 4290235837, 2822961350, 3264010853, 1395348986,\n                1532724636, 1479458209, 2803797702, 2248954690, 1109326360, 868524296, 1622203818,\n                2233229102, 3747990662, 555588899, 2749663474, 3197509055, 630575671, 4105739578,\n                350883605, 3884847782, 2399406878, 1709869907, 4200326701, 4079556706, 1296998956,\n                1096350538, 524761973, 1629603733, 506636222, 2285887205, 2231667772, 4010753639,\n                917205307, 45978573, 2604387874, 3703883391, 956577030, 301635887, 1366863825,\n                653575304, 4002452771, 1532839774, 365525468, 1207266883, 46605181, 3549725346,\n                1181348714, 1401721152, 3079539285, 904310818, 1291426703, 3423900075, 3724908664,\n                918900181, 492461520, 2051740414, 861850244, 1441070167, 2409123056, 1923594929,\n                2592176152, 762526381, 2608436860, 179967203, 947743965, 3152260497, 3795355036,\n                3128372461, 334341652, 2852670346, 525231164, 2707537479, 423546146, 422356576,\n                2514936736, 1508996402, 2866854016, 2529118278, 1616687498, 3248910372, 3424501529,\n                3509076680, 4206763914, 2036548848, 4062752651, 4244007332, 2701189385, 1278945872,\n                1938315563, 341487762, 2245251522, 2614982710, 3077916256, 291100198, 3611957075,\n                1995518592, 154652263, 1532772306, 248498549, 3231944766, 628801303, 3344272527,\n                1065639153, 1987158587, 1479356917, 2988956252, 4046958565, 2209065419, 477730056,\n                2336652721, 1037902218, 2563735377, 4101524640, 3496286466, 893815781, 370165241,\n                111642164, 1658058879, 322898205, 2985501252, 4080369932, 313430011, 2711111000,\n                1181601656, 555256727, 554722327, 2969317428, 2537636036, 969866577, 3100268542,\n                861181567, 2766358890, 3556106295, 2319452091, 2276583134, 3694687721, 2683079950,\n                3602799233, 3315957548, 1156121233, 2466768002, 351756246, 1311063094, 607227992,\n                2577239074, 3348786927, 3556673019, 1603335686, 2933024191, 2025259240, 1495478557,\n                2032170560, 2121476735, 3193544299, 4119114109, 2928661241, 448576207, 1614958740,\n                345202029, 2600582520, 2742644459, 92765692, 1372450470, 3781561695, 1568934205,\n                145316051, 4006568817, 3666572039, 3335574604, 4261359692, 281814983, 2392237710,\n                1491546468, 2408177492, 3815015525, 1277308779, 3604474102, 796103227, 3177970999,\n                2372049172, 1292258380, 2260556904, 4006251044, 3037386650, 3097581743, 272132478,\n                1428294116, 1610143768, 3421139539, 1124007750, 2568811011, 899340979, 2888377028,\n                148246615, 621225076, 1635442139, 179184538, 2565113048, 524982498, 1477029769,\n                2443496661, 4238972150, 2111945492, 1826948655, 1631527737, 3293499896, 1592525336,\n                1072822530, 398987024, 1403041752, 1154120498, 183009602, 1860553280, 3833836549,\n                639383491, 2747751428, 1967745750, 985697863, 4102756978, 3010429932, 2426159954,\n                1632866751, 2325250581, 1085491035, 2626066600, 1004650627, 734034293, 2634237232,\n                3290134248, 0,\n            ],\n        );\n        // - bits == 0 in limbs_div_to_out_balanced\n        // - bits == 0 and two-limb division in limbs_div_to_out_balanced\n        test(\n            &[10; 3],\n            &[\n                2974709165, 1408789605, 3865174329, 1359597196, 2297806425, 1241510613, 3227134452,\n                325500099, 3798589956, 748039492,\n            ],\n            &[\n                322054190, 2721366349, 534065582, 4284544993, 2403511175, 3934371253, 3610661048,\n                2543303641, 4119337658, 3350506258,\n            ],\n            &[0, 10, 10],\n        );\n        // - bits == 0 and schoolbook division in limbs_div_to_out_balanced\n        test(\n            &[10; 5],\n            &[\n                2333679788, 2356666855, 2364697986, 2341519831, 2855670118, 1220356586, 3077887875,\n                2167847389, 1298352907, 2783063425, 343561812, 1466674656, 2828723164, 2244865405,\n                3261584816, 323262334, 2146252780, 2244363245, 1140774914,\n            ],\n            &[\n                1638368212, 4269779221, 4096262691, 3276079354, 3835296926, 1228438544, 931207076,\n                3941619719, 577971296, 3365897754, 3952671229, 3635074066, 1819466191, 1077726049,\n                2724331936,\n            ],\n            &[985368501, 2737353193, 3370693165, 1798455938, 0],\n        );\n        // - *scratch_2_head <= 4 in limbs_div_to_out_balanced\n        // - !(r_len > n_len || limbs_cmp_same_length(ns, &rs[..n_len]) == Less)\n        test(\n            &[10; 3],\n            &[\n                0,\n                0,\n                4294443008,\n                7,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                4294443071,\n                u32::MAX,\n                u32::MAX,\n                0xffffff,\n                0,\n                4294950912,\n            ],\n            &[\n                0,\n                4294967264,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16383,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[4294950912, 0, 10],\n        );\n        // - bits == 0 and divide-and-conquer division in limbs_div_to_out_balanced\n        test(\n            &[10; 265],\n            &[\n                506643067, 674201220, 4077605637, 870747493, 2507358273, 3724638469, 1035009974,\n                829046988, 3750301412, 3918208469, 3953784269, 1207127792, 4050829853, 461784483,\n                2383763199, 2285448897, 893186049, 2814159946, 583430210, 349181410, 3312529089,\n                3040593764, 3505574840, 2245473386, 499733927, 1870266859, 306858541, 2287239467,\n                3602186482, 2485354048, 3925520601, 1490580163, 3946071957, 831571085, 2671733075,\n                3492322751, 1693084970, 3703683238, 914345023, 1731822012, 971261566, 2899991322,\n                1415427842, 2792111536, 3754030226, 2536140100, 2809833781, 255220419, 1494036353,\n                1435449211, 3699505245, 3939949425, 3424663004, 1987816971, 872486514, 2304200621,\n                3672706956, 3098142146, 4028147917, 3126086923, 3431963845, 2505585471, 2599393784,\n                2703989391, 104322041, 31236914, 1102844188, 1685015561, 3414504334, 3166439653,\n                3856439354, 3774684706, 4074904284, 605442011, 812212716, 1996651776, 4084653341,\n                271581859, 2458893946, 1704814216, 3983060909, 1705321390, 2722920787, 1026280690,\n                3548307184, 2796854160, 2478471453, 2069980586, 2327202328, 3179332026, 2188958336,\n                2717879675, 130062885, 140536268, 2499125438, 3163111280, 4259661702, 2176278885,\n                422519228, 2482586299, 2904549185, 656169575, 2052350629, 1346745024, 2132509288,\n                3672720658, 1036389958, 1864007789, 4247227128, 3920036168, 1436562554, 4261984498,\n                3509215437, 583752676, 3145348403, 2267709494, 2846186667, 95392897, 3743233716,\n                2210401890, 333864866, 4114644153, 3030283850, 2885600773, 209380485, 753945396,\n                719327396, 1293498320, 881901364, 2799735404, 3880748109, 2227099476, 2045911493,\n                279042015, 1825819541, 1783146691, 2256898093, 2186071881, 3753747971, 3588523011,\n                33603847, 1513157507, 3499821617, 3738644542, 1415336880, 2770362204, 2060947257,\n                2730479597, 2685626774, 999367629, 3913677028, 1269070210, 71600754, 1301019431,\n                2216016590, 146670051, 2663607608, 3377525204, 3629426592, 3008812841, 3146776799,\n                2307984538, 3891637717, 2113643890, 191705646, 2335382191, 1140110911, 4020097332,\n                1669672424, 2764048323, 131913018, 3294340837, 1179938248, 3518525865, 2275430195,\n                3163615882, 1433056069, 3632771998, 945256067, 3112805135, 3793337, 2498643598,\n                196475979, 1234934305, 2303169144, 3075871960, 1459180144, 181561979, 3503884769,\n                2684065515, 830368038, 3013649837, 2204747214, 1403496840, 3859560760, 2859158714,\n                3625515328, 1724787311, 751869756, 1068392634, 3152945440, 166456628, 3912875927,\n                1276199042, 3180668929, 2654240450, 3838496263, 1978050764, 1330937637, 3052787309,\n                2179574058, 3771594804, 78717414, 2499543381, 2290126169, 3421184223, 3433039199,\n                3357845254, 2982215557, 486514084, 3948984473, 748257374, 980199615, 2114791508,\n                2263110875, 1438244139, 364374413, 1396459296, 3946812646, 3259529007, 1803026660,\n                4176094107, 3107042296, 3690348839, 3454595397, 2121594656, 576668497, 807899954,\n                1335323177, 4200325364, 2730879357, 3284030486, 3324267006, 27217584, 3455039500,\n                2034759734, 748477743, 1248615399, 1109976687, 476936469, 3606689372, 3993977007,\n                2258238141, 1642523191, 2086149347, 3137863504, 3174920716, 199510880, 1099331674,\n                704556250, 3389523009, 6232858, 4190352603, 2138785122, 3218278977, 1935766981,\n                1255344917, 1933434103, 4229596014, 3581553119, 2147449432, 208926434, 2037430803,\n                4143975728, 2356343321, 937192435, 1637432038, 661638621, 1801480924, 3779152128,\n                4243491821, 1667774376, 1715755489, 3661813139, 1605971891, 4030695606, 2961165054,\n                1368430397, 2222904896, 2817587025, 1714442303, 3822714979, 300305701, 1874484285,\n                2601340412, 2275789197, 2695461089, 2246464394, 1119579754, 1646098622, 3280004748,\n                33497272, 1940830933, 3780770129, 1587254032, 832573251, 1504418072, 4247592896,\n                317874907, 949850421, 2252881736, 3574316069, 3062236166, 1396410954, 3249498785,\n                3495392204, 540855070, 1908700137, 1469179505, 4199276220, 953657385, 3056452157,\n                2141569526, 2342475731, 3746376146, 3271677606, 2770490239, 2212992129, 1758619376,\n                1446549455, 409094501, 767129031, 3284625381, 1887741449, 1134874072, 2988924415,\n                1641550007, 856704035, 80648349, 1467185629, 2753807208, 1609415681, 4087676277,\n                3276525355, 1530490532, 3475014952, 1971819359, 2190766950, 2667577576, 2404497182,\n                4128259693, 2449514447, 4199089872, 2205116036, 4089987616, 457231895, 2931469481,\n                3147651033, 2352907189, 876540006, 3743945364, 1472931415, 1553806347, 917186799,\n                2698606847, 66937650, 3645382047, 853223241, 3225678178, 3306353588, 4116060170,\n                2590602281, 1017313973, 2613704632, 2155925964, 971128116, 2969595931, 2019050340,\n                3266635763, 2229237075, 2897700432, 692684809, 2884804723, 548672200, 4148599125,\n                2903660719, 3024254547, 3711620919, 3505267307, 3040630725, 2741747953, 1929597653,\n                2289604848, 1876399821, 416443208, 113684194, 2458701351, 1129214912, 2220498900,\n                2434385125, 383696859, 1361474230, 1163397052, 2669432319, 3058892712, 180222756,\n                651218593, 799737686, 149785061, 2171639569, 3195389488, 270082840, 119827887,\n                1410384095, 4066783084, 3263839471, 464165531, 3866096625, 2064936052, 221981930,\n                3625198339, 3424885311, 1071723748, 409527338, 1676479257, 3093122613, 3729266155,\n                1862387444, 1361519384, 1243604327, 1643472480, 611403222, 996523967, 4174256483,\n                2326506033, 2418590323, 3423410866, 1529787343, 4205549227, 3997545970, 2223326432,\n                380968195, 3506194936, 3910452712, 4038499509, 1845505874, 1017156422, 1929655910,\n                2711754908, 635288831, 2247734769, 3304323666, 2179819642, 206674737, 590233515,\n                1336492628, 3718075, 3613296921, 3550161900, 1864016712, 114106506, 2398669907,\n                2720528985, 3857377519, 3905792607, 3346298226, 462294071, 3119274864, 3972744498,\n                2110531614, 2149059199, 3948853307, 864424113, 2523103018, 405972168, 1017288780,\n                2875520328, 2155632746, 3241100405, 86049349, 2941679162, 3047748962, 2284186344,\n                3132866461, 2331447040, 1003213663, 1873981685, 3371337621, 3796896013, 4144448610,\n                2569252563, 2859304641, 1027973602, 3158196152, 4058699545, 2002924383, 3295505824,\n                695758308, 544681384, 3452307839, 1190734708, 4232023153, 451772934, 673919865,\n                2022672425, 3493426012, 1142609332, 477542383, 1304798841, 461115870, 3268103575,\n                2243523508, 606810814, 4235312469, 1885993181, 114475077, 757688489, 1965769398,\n                260629125, 2265559181, 2568323569, 4202738507, 422918034, 1258453131, 3552221985,\n                1666914845, 4063631552, 1893061685, 1362616670, 3828572660, 3003680479, 119501228,\n                2101943449, 1119123129, 2512417484, 4143796978, 4123615401, 867855104, 9080683,\n                2989272444, 4071914200, 3126419388, 897981380, 1843424411, 2958654429, 19279568,\n                3561481778, 3620717321, 1713789028, 3466124758, 2114531476, 3750356418, 99077566,\n                1592097168, 3827583318, 620525513, 290829475, 2167034573, 859199755, 859025849,\n                1856340069, 1742571592, 619057918, 448873046, 492980624, 4024378211, 2920022072,\n                1315190691, 220327298, 822905603, 862879897, 2816210126, 1919765070, 2058864462,\n                697509061, 1633189430, 2245037639, 1891169791, 1490604281, 2749203494, 2727100064,\n                3952743771, 745359287, 294665575, 481463143, 2908504060, 3264906873, 4291223436,\n                1078483712, 1974128727, 3336164436, 56705038, 3439879863, 2641239652, 915511148,\n            ],\n            &[\n                275357812, 1380366134, 832237659, 2112384134, 3392548533, 2322411681, 3893212013,\n                4294409814, 4093767003, 825461980, 2478547269, 3404630461, 1971516824, 3442909527,\n                310968935, 3588187524, 1263584270, 1954425632, 710153676, 1490566985, 3851982772,\n                3813403663, 3945099227, 487964380, 413515585, 3154361919, 1595882626, 2396609791,\n                324874877, 1386033964, 3103282602, 2599529608, 2119912272, 1365578038, 3224231142,\n                4103857906, 475734936, 3828952167, 3071966456, 1450111251, 1166414077, 2218130537,\n                3324650407, 1559641024, 2423373264, 2283136700, 1299328382, 3345578599, 840299756,\n                3797238397, 2067196109, 3055917746, 3636953439, 9994084, 848907394, 3724334355,\n                3765535226, 4202522723, 3549598176, 2976719094, 1062012457, 3192129616, 2622008775,\n                4140808457, 3311195039, 2219962246, 583122033, 3484577945, 3996746462, 3163823232,\n                2815287028, 4187316839, 3462896421, 2231360878, 1678307748, 460684903, 3249941390,\n                2444083444, 1885084635, 1384447473, 4228441234, 2992602088, 4233710708, 3252082214,\n                3754932745, 974410439, 749693996, 4239737998, 881588329, 1689075190, 292144262,\n                1373806909, 960467260, 3106551077, 1249264314, 1210555633, 3882913567, 59286933,\n                1593160363, 1969806577, 33237994, 1192096261, 1570929611, 1291838216, 1453595934,\n                1481420023, 1722346701, 3005255028, 2671588519, 1129223015, 1988074467, 2499928090,\n                3504414178, 2670506578, 798157759, 3859749353, 3404813676, 3070374972, 1362004270,\n                388389672, 3227842930, 3141750652, 246994433, 3435384009, 2937163806, 1091298751,\n                3219724097, 1663604618, 1547894794, 2034927931, 2077403472, 1183979515, 1312517327,\n                1652629779, 2840629951, 1320559340, 3379399676, 1763411889, 2852175138, 1013263636,\n                910550154, 529178328, 1437740880, 1545534222, 2859835603, 2271712768, 1100624932,\n                108752761, 3521837118, 2043489286, 2482010929, 2526022944, 784503235, 3989653576,\n                514018710, 3703716272, 4124099812, 1390681784, 2537781805, 201204889, 971348667,\n                2307205686, 1760983313, 2268919139, 3109728863, 1931931512, 1811265792, 2492179233,\n                2839289978, 305552922, 2705812278, 487378575, 1148523689, 4211680716, 3055415169,\n                512649009, 1499343281, 2379775206, 3398729819, 2885867944, 1989458261, 3168583752,\n                3895436961, 435919341, 3229009848, 333401020, 2066985073, 1599311722, 2470446433,\n                2036229414, 3754646122, 1602078777, 349281148, 1872253564, 1044135153, 3952751023,\n                1908969406, 2526035592, 108266294, 1002947027, 3490519747, 1017767773, 1363582374,\n                4236936817, 1095422379, 1476035104, 3938596998, 1896398408, 4013241860, 284937761,\n                5850220, 2334057891, 2272377339, 3385837178, 2094910603, 172965460, 2993236410,\n                1631768055, 1408498310, 4196305218, 2858075969, 3162013919, 3250561599, 2819691478,\n                976316354, 2309193549, 3902122050, 2088052090, 89473947, 3770933220, 1285217956,\n                495480326, 2012241013, 1505071862, 2618825681, 148024106, 2211817594, 3486453451,\n                3547415938, 4170790841, 710399394, 2988742259, 3003999364, 282857121, 3004330911,\n                2445074578, 1614383715, 2436968214, 11188480, 2102332723, 1466315446, 3717470884,\n                2603285911, 908917900, 3806165173, 1397056453, 1461836583, 327667425, 1587556539,\n                1289291700, 446244259, 3478801927, 758862925, 336152650, 518856100, 804638637,\n                2976399236, 3191730168, 3165653830, 4116291332, 1180509997, 787973682, 1833860962,\n                1047583821, 156500875, 1287142618, 2903226831, 2477133296, 625749873, 3687467688,\n                1470807488, 821205035, 4228089759, 498323515, 59751723, 4138495950, 1453952672,\n                2570830070, 521547133, 3428749320, 2363485698, 1810803490, 525920316, 1605961985,\n                2230129511, 1733393350, 1424281608, 2365058430, 3533943852, 258572135, 209602549,\n                687169735, 746097119, 3883623461, 860878590, 899440424, 1064227214, 2191778986,\n                3556832513, 2171344159, 2484630726, 290049039, 2356156351, 740380975, 1960730095,\n                142059661, 4018594902, 3106881150, 930323391, 1255739479, 3337449057, 3148783500,\n                2253473087, 1071245161, 3447698853, 1197848740, 4060561204, 499397149, 2774518906,\n                1389562763, 2693574400,\n            ],\n            &[\n                2892496898, 1447320150, 3590707186, 4252286087, 4099207609, 4105150739, 3969659377,\n                3877581106, 3844075082, 1119395228, 4111657348, 1989245533, 2625018871, 1435016728,\n                775322113, 2486746233, 411477946, 783741811, 294555322, 874068633, 3432359852,\n                2911163611, 1375769638, 3434130437, 985693369, 3510076962, 2092775723, 1201035228,\n                812940046, 388585821, 3460410142, 4102284201, 2588728415, 1834489811, 1860072658,\n                3206722627, 4070805677, 912012520, 1107950571, 2855449499, 2356110400, 1048165361,\n                786166069, 3139410711, 2376418896, 213462974, 2934906474, 4184813074, 2148116146,\n                2886707962, 1072776382, 2999802157, 3058489357, 2949636457, 1567339918, 2296903598,\n                1471627440, 3093553236, 2902773332, 220749635, 1005913375, 859636387, 1837155708,\n                2140012254, 1304301626, 4253207180, 2566725460, 1469242176, 3759058257, 3409005372,\n                1238566539, 1398646155, 974517148, 3314067407, 339946221, 924727838, 1957551537,\n                680280333, 1281468850, 2209761488, 3116305703, 1340386652, 1621222022, 2320551186,\n                862888096, 2491969066, 2767235914, 3271787837, 2762818305, 3533899432, 2143575776,\n                3910952894, 14685217, 3463875857, 2036855868, 4258306113, 1030748318, 524321052,\n                1852279535, 59479177, 3613680178, 3646237449, 1565986281, 2257075320, 2631569154,\n                2895149301, 1938268122, 65582006, 4031119479, 430394105, 3217907221, 543498480,\n                1033294445, 2556400020, 767171781, 50312859, 2780724798, 3203289606, 3870927927,\n                67083759, 2409696923, 3952601322, 3653157894, 923160622, 3398950378, 1555694690,\n                2244182109, 3619744924, 2568706263, 826771561, 640735316, 3641939139, 642767502,\n                950596306, 2695574621, 1644028223, 554000152, 486521532, 3326739594, 117306555,\n                1841260119, 3938389504, 300582682, 3953482514, 430139137, 455233320, 1037301049,\n                3615948425, 136331238, 2572752842, 3241874704, 2846529663, 1268666222, 425076421,\n                1387063258, 2890954385, 4096839497, 575163363, 2677416020, 1370013560, 2172542077,\n                268835184, 2720518386, 2313195126, 2520731985, 1428843145, 1120133039, 3270957840,\n                3315172136, 2870322488, 2870507039, 724984412, 3139237569, 952022623, 3933753186,\n                3828757670, 3909874303, 178407797, 3904699386, 1722471536, 1933503701, 2084550100,\n                714890658, 2573717352, 962347002, 2899589891, 680105427, 2737432908, 602384873,\n                3647759319, 885456319, 2557006269, 2747397933, 2991432384, 2531228735, 235505427,\n                3454054340, 324776205, 2920011061, 2039088389, 1071395333, 3752028462, 3264518328,\n                2221042825, 2520779553, 3023235163, 3336750037, 2776943124, 698637417, 213422247,\n                2253953770, 2289793400, 1099689581, 2183186023, 3600213851, 2987733376, 3240713853,\n                2532959736, 3990244023, 935412481, 4003796414, 4044202737, 2701294309, 2774001322,\n                1246813030, 3523205316, 2877272264, 2808629070, 3952617986, 575846345, 3887709830,\n                2303176257, 2448994062, 1814306890, 1125465602, 1437344932, 57018575, 2882004962,\n                257559391, 129924651, 8107674, 2641593151, 3225211500, 3751185810, 4152912940,\n                2352009510, 1449645454, 1216509365, 2388967059, 2711793416, 1284040889, 1645864028,\n                2051429244, 1605254461, 1917359262, 1805912147, 536698251, 1021142310, 3935443381,\n                2696660773, 1238552336, 3193475557, 1525093066, 1459803910, 0,\n            ],\n        );\n        // - bits != 0 and divide-and-conquer division in limbs_div_to_out_unbalanced\n        test(\n            &[10; 744],\n            &[\n                3587573856, 4227426142, 3896224682, 1468139892, 1853281713, 3230829722, 3544339255,\n                913969399, 3983606726, 181178735, 2741195255, 1539029618, 3261057660, 669185888,\n                26774344, 3042294054, 4000320681, 3616777430, 1701761628, 984410729, 4231348353,\n                2662674575, 1467572439, 2032481283, 1873156172, 115509983, 2937869423, 973418665,\n                1489589927, 1095121637, 506586746, 2535986948, 2719080072, 296096440, 1642945999,\n                2339337213, 988268530, 2303133076, 2256242938, 646154972, 1819375956, 2274317751,\n                3820060724, 742765560, 3675289356, 3771892301, 3075647720, 1818112062, 3031351147,\n                3419055185, 1772759499, 3049965965, 716650100, 3384724295, 3504962640, 3501988647,\n                4073738879, 817690323, 306125872, 4262005940, 2328708878, 2185547215, 3604829167,\n                1214715318, 405219872, 2470967999, 4165888706, 58640780, 3166122711, 1754011174,\n                823366021, 588855436, 539915357, 897646815, 4093176866, 1081711730, 282768489,\n                761405028, 3134899797, 3405740924, 322586217, 2056545290, 2437754480, 104247006,\n                1236818589, 2491440617, 181378199, 1163012610, 1325379332, 4200723192, 1263362307,\n                3234219355, 3292135414, 1507504036, 4161995531, 309710870, 3183147539, 982486451,\n                3492150688, 694819593, 2066057564, 1649903936, 1060155149, 1595975750, 2913835322,\n                1938985687, 3772153889, 3152752661, 1191763263, 3764287870, 3782997871, 81159186,\n                4157520234, 1723748366, 1221210497, 3568223039, 927507384, 4004363262, 1795793243,\n                3503626292, 2692130423, 1081516180, 3595063804, 849797265, 1035581542, 770759929,\n                2889095772, 2572036064, 3097409730, 2958492178, 2450749829, 2069709085, 2687054597,\n                3392070073, 3827943191, 2368917411, 3160758175, 1531480588, 2746326450, 3122359045,\n                1995296172, 310451197, 1100329853, 2141732304, 3562890277, 4172526924, 4143185198,\n                2397101926, 620168044, 828452963, 3271569899, 2726758945, 1647557222, 2748652901,\n                1029871186, 1773072595, 1311795717, 2792240418, 3100733307, 298902661, 2608361440,\n                642743765, 3026335712, 1586592828, 1251923561, 2152803283, 3359308047, 3979690761,\n                2548031009, 2148504694, 2514911217, 401310800, 1418125404, 2325652800, 716233458,\n                422262103, 376190943, 1713380879, 2534508846, 2080413009, 2690193951, 2909422387,\n                2435837201, 176977642, 224472737, 1590904934, 1664979624, 1748982641, 1284257790,\n                2779881254, 385265989, 1148527382, 800142050, 3595556318, 3950265146, 3931111523,\n                3399894595, 4200004994, 3727110364, 1510525540, 429323681, 2586345405, 3441619670,\n                94654169, 2266545045, 1451808026, 286040435, 364003484, 2106693078, 1916214330,\n                2622096560, 3504008387, 1867458297, 4209615436, 2899684845, 3149003214, 2731979274,\n                2481557740, 234269740, 1239420776, 2726912636, 1844267393, 1488044058, 1587005400,\n                145015793, 1637696129, 1990069464, 3053970062, 676336554, 625771493, 1492378707,\n                1231018082, 3059699722, 4113615249, 2967103567, 3335726303, 2137774253, 273460502,\n                1561489611, 1227429414, 778315897, 3061631993, 2437789514, 2566029814, 3017507824,\n                3219754602, 35255136, 1934306764, 1655248959, 3655963814, 2821596564, 1431977748,\n                3114012833, 3915822059, 343010167, 3704265251, 2691314567, 2602475242, 2459094882,\n                58857240, 2230690665, 1357656795, 3025543277, 3488674640, 408985076, 80729036,\n                246851391, 1419653386, 530010128, 3529087076, 3980421141, 4129023783, 1630771696,\n                2057278583, 2501545742, 790764428, 3984347668, 2562445985, 2262348292, 2515967925,\n                1103371818, 3735595401, 3210477145, 3387257181, 538884374, 2695206119, 4211749041,\n                1006274735, 2406061865, 2654644297, 1268724640, 2399689302, 157759259, 564853502,\n                865205768, 2174783618, 3167863384, 1770172407, 1906775255, 3171669377, 2455086709,\n                1355327864, 3351895167, 4184858376, 2699533565, 2939169294, 1702277740, 3447680482,\n                3322351998, 4248517760, 4100425921, 1169799041, 524849931, 1743345401, 3987645088,\n                3022177240, 3263737545, 3656340460, 239445170, 4089162190, 1208712978, 1453215235,\n                3390225374, 3337889603, 717395279, 1066458381, 2162685522, 4009460245, 2575879990,\n                2578471337, 4218103221, 3046325563, 1352991515, 1561949281, 3488911174, 295633326,\n                1993756395, 3677304657, 796898320, 45622345, 2999482773, 2078651788, 1552765091,\n                428170722, 1748054862, 4158222865, 1050292437, 249107, 2651086861, 1540178674,\n                1275557298, 651050585, 1895599156, 4150309716, 2064336046, 1021257319, 2422595446,\n                3116755258, 2756656575, 2328011578, 3632905157, 2576200202, 830418644, 2430246370,\n                3913080080, 2371749061, 2683067461, 3611558701, 1603392737, 796477803, 604567756,\n                1376069347, 1491246154, 2728262664, 4138498935, 3008562381, 1061547384, 285679033,\n                2358943172, 1884649492, 1783482693, 1010268161, 176114433, 794165875, 2362278477,\n                3903204233, 326754905, 1988607850, 3187254334, 1749797209, 2986661384, 1759716588,\n                3137467938, 4067743599, 1134210801, 3799848836, 1955405545, 3881788427, 3097574490,\n                3844756657, 3183850151, 2496328910, 1468671385, 2888878911, 2306353811, 1498824361,\n                4152891378, 1588217107, 79108222, 2883552792, 2390312777, 1587172303, 2070384343,\n                2265280181, 4013380367, 2742676878, 2654283484, 1471778694, 970959698, 1006151052,\n                1276307400, 2874101774, 3169092608, 244587925, 2402787407, 1635687252, 835856534,\n                321407542, 2307278464, 2272745321, 2574317642, 729437319, 1682288870, 1482920833,\n                776000268, 3908963888, 214874919, 4233311318, 1441385448, 2358127573, 2753681514,\n                467574656, 4139948165, 1538275035, 3244920878, 2576965792, 584068468, 3054546876,\n                2629688518, 4253271747, 3723872815, 1652066683, 990821089, 2335421805, 1989570928,\n                240486517, 2872315587, 3869991906, 3870517664, 1540804424, 397183643, 3750033565,\n                1433260634, 1506168711, 3616651625, 512028445, 3746712828, 3278592880, 2611514549,\n                1214563129, 1259227909, 1067976218, 3425169051, 741795595, 893688343, 2674408703,\n                3694908868, 2478153735, 2220661625, 1022546736, 3719214155, 3161293211, 4131981986,\n                1473264088, 1651777063, 1438502715, 290022167, 59234682, 3458968160, 2552001459,\n                3451530289, 3800073253, 717882913, 845719525, 1038699111, 3058303772, 1117505279,\n                3682430977, 2869037104, 2562493618, 960519305, 4147639705, 1817463351, 3166022129,\n                3200769866, 789666262, 2654485924, 3686362402, 2179867687, 3980226915, 3671542918,\n                1896992204, 1514962591, 815867715, 3924270086, 4262628477, 3977258034, 1340257907,\n                6618754, 2720861064, 778635062, 682181834, 2891943360, 3002120306, 3399643048,\n                3139375492, 865948953, 3273305779, 388881948, 3544744413, 3963050187, 3002594763,\n                3339669779, 2722426929, 1246819181, 2786076007, 708438365, 1013683719, 3027751127,\n                1766272571, 2839608714, 2866928644, 2107420563, 4035553421, 2376700546, 621608197,\n                1993043072, 2666011084, 2265522039, 3230507984, 2869423257, 1776134078, 2413254013,\n                3859414865, 193597892, 4255395370, 168637254, 3364100552, 3883433219, 3117797624,\n                2738841992, 3052596910, 3280507008, 2860095630, 4031447725, 3454885698, 1783630119,\n                3036202894, 3585701130, 4184585287, 1329572188, 2352399996, 3076023682, 2989927975,\n                320530428, 2081170907, 933271377, 2974966675, 3452895778, 2331110373, 995864819,\n                1177147317, 4084213472, 1179430541, 361665403, 2401303908, 3027157843, 2778759588,\n                1031442202, 542151276, 4259656091, 745358488, 2580062497, 2004998882, 2066508478,\n                341659477, 958017378, 2415007725, 211645068, 3630737942, 2670158596, 3544834081,\n                2043760261, 2149621570, 1287267516, 3353570061, 3758258174, 4171807709, 1363035595,\n                2692148345, 3728232161, 2672522097, 3234166892, 1337714504, 2475062988, 902334395,\n                3470019951, 1789926953, 39991566, 1071624731, 2480238280, 2010573056, 2975909089,\n                2685102208, 1752958961, 2957725128, 2441562510, 1615057382, 2739912075, 962437876,\n                1445592393, 750430353, 2848157371, 3515397641, 2140566969, 3080139371, 3564834440,\n                561913271, 1812943111, 1349101061, 1627550717, 3467766096, 194766042, 3125120919,\n                3021598191, 2389614341, 2536207717, 3687483968, 3746428277, 1304917109, 4262793424,\n                1046105397, 103309888, 2808595193, 1896772845, 2625389818, 1425524079, 4245371665,\n                1376995745, 1906643058, 4123808395, 4010921636, 3668036324, 538106732, 429893286,\n                1473862381, 692485290, 728791765, 4006267410, 2159349173, 1146991809, 1105326804,\n                855626330, 2350214961, 3945267379, 4182769713, 1218539569, 2795526933, 508156606,\n                1596052577, 4135932990, 4009064452, 3154371819, 1789912473, 3737225773, 2339289640,\n                382599364, 2822801808, 1231473766, 3195594892, 3686689017, 2674031129, 2724276086,\n                4112764261, 79570030, 1908454621, 270118882, 3204318684, 2240304382, 1923066108,\n                3669840087, 3114917464, 57715381, 3015749933, 3183317351, 2563719945, 2409212385,\n                2256893938, 718636813, 3965735223, 1345089653, 1264444, 2296052850, 1092210950,\n                3468764525, 3967443918, 788417425, 1924956491, 3656370968, 4266402294, 389687964,\n                3067575949, 3786278950, 4368934, 3414260125, 1500941491, 4197777812, 1901284905,\n                2548021755, 1986057606, 2732888210, 3872664452, 2787539702, 3264559111, 753549553,\n                1048190618, 2900005727, 1868077400, 1284542693, 3154799998, 395567255, 2005460208,\n                4005052806, 1893310835, 3217932531, 2607307407, 3917316670, 2028218244, 3745680211,\n                2397481422, 736482987, 1916844834, 3868328610, 938512555, 1559481864, 729544587,\n                3690980706, 1759014647, 2060717833, 2250640148, 3619925046, 2153794810, 4127168634,\n                3259374700, 2051907961, 3964686808, 3841055905, 4242264783, 2314742304, 2209077724,\n                2577227865, 1487635776, 1585379583, 3475070421, 1683734827, 3363053669, 3722095029,\n                3857335408, 2852846850, 456879372, 2473892714, 2928343667, 541075767, 3595876467,\n                1688710352, 2071331730, 1142047400, 1817453168, 96871997, 3927306877, 3090061646,\n                3474317652, 437148773, 439538568, 324686794, 772632617, 1424328970, 580538580,\n                3999279969, 2022469388, 2802303848, 1147488095, 2053949131, 3046702544, 3822972379,\n                2920233521, 4031279543, 2356245098, 2951036256, 3287235943, 2760424423, 140913700,\n                689952328, 3916658401, 1694797888, 82150998, 4075118605, 1967095926, 1704543314,\n                3154572744, 408071699, 844684417, 1174429103, 3583461805, 1015646627, 861970508,\n                1906905868, 2272773809, 879277860, 2980820537, 1917774935, 247497916, 2403283458,\n                553129122, 3303057196, 4005726052, 1808761740, 1909802116, 964057278, 1586240623,\n                3097009405, 2048123311, 2481968244, 3155267854, 555253647, 4027932249, 229358586,\n                1015669317, 4112551330, 351151415, 1331401879, 1749898409, 3352469407, 710145444,\n                2903798473, 2876271745, 692844392, 2354652850, 100021926, 4212629124, 2971597719,\n                2697935131, 445511347, 1636699871, 2524940444, 1303870696, 3634945394, 2398930906,\n                1337769794, 3955409228, 2657553814, 1455809030, 701994564, 374320080, 519334058,\n                71402463, 2995013099, 1573823285, 2419768029, 4108602983, 4266125692, 3514998795,\n                2367509976, 2654621106, 562141353, 3101668250, 2753822172, 406447740, 4132920329,\n                3645443797, 4221410098, 1000631411, 2319369935, 3987192941, 609889174, 569928846,\n                3471449767, 761399938, 2925981744, 3610481831, 364846710, 2579622933, 1755359875,\n                3327963251, 2230753636, 3897751713, 3685870953, 720576993, 4008645094, 2170973511,\n                3057371253, 2362087099, 2415801497, 3804893423, 874616900, 4188156090, 2114593709,\n                3626784402, 2090293821, 1178445498, 3501583487, 3787814639, 1160994150, 3773261324,\n                3438864014, 3474697300, 3232616282, 3082635737, 3290126053, 1041836645, 1497490946,\n                2116412677, 78748560, 2610841375, 406515051, 2540982558, 1278151559, 910145724,\n                2942229044, 1412896287, 2420692111, 2829066497, 2762072644, 883699073, 4146766932,\n                968581437, 2262117978, 4102625453, 753476188,\n            ],\n            &[\n                4049869757, 1602523624, 1387514923, 225246600, 155172862, 3856617978, 2201641309,\n                1540516258, 34942771, 4041710783, 3460925118, 1016127034, 1143953610, 3427876200,\n                4178328442, 3374908315, 2087712114, 4171526185, 3514588648, 2986361397, 3768375872,\n                152142192, 1983892945, 2539876375, 1278133015, 3290367811, 3728704045, 2495609578,\n                3383634048, 550401536, 2958764367, 417726361, 3629290307, 3955082917, 3367571078,\n                1156977964, 2700212626, 3890522506, 1407330442, 2072012244, 292784856, 2848511017,\n                2011019434, 3729188240, 1314875514, 1752114201, 3480385261, 1532349465, 1252987479,\n                1748370879, 457308873, 2290488535, 4117600387, 1025979949, 4285742993, 3815216993,\n                1825262081, 665711516, 1319233702, 3390016806, 2279278230, 1335733129, 2732993747,\n                770076251, 2848793746, 893093476, 350727685, 49933264, 3771423699, 1804029403,\n                3544637522, 3176796760, 475781914, 777775753, 2152296620, 1317524444, 3941840558,\n                1662743930, 1905993615, 2485835810, 3925643251, 3071436009, 851721712, 1325046168,\n                3214018378, 1465803515, 2459667310, 2361559987, 2668552637, 2425633974, 3200812339,\n                2594448814, 4170435967, 1112582678, 3198704424, 4028094030, 2482710119, 2990475705,\n                708195759, 612294539, 2794828841, 2498141427, 3805184114, 3010938369, 1479667740,\n                660767380, 1641177565, 1782849661, 1915222559, 1626388136, 1816788637, 1338361170,\n                783877621, 4003339370, 1930607900, 1259399167, 3351643097, 1641708262, 967800396,\n                1800752717, 2198926109, 1163817943, 2710351254, 451351637, 1285647338, 865168955,\n                645286276, 2685132510, 1773153387, 4273868103, 2604563645, 4105767904, 2556376985,\n                158907213, 3579937882, 3059825408, 1920542835, 528717490, 1430681949, 616489338,\n                597761261, 3760865497, 963173252, 2915089223, 1441674715, 1717557648, 1819215517,\n                3449795284, 844168976, 1574237607, 758725457, 762624299, 533122182, 1201164787,\n                1968174784, 896982568, 3419630169, 2247559545, 3983311870, 3975342941, 1112833399,\n                2721518545, 2493587613, 3444837338, 3313000598, 751186769, 2970698395, 915811688,\n                1206259449, 1340427760, 3844346545, 3762393860, 543253569, 1197933603, 3734607133,\n                4037352821, 2263945478, 2831362781, 3363558852, 476952769, 1916745391, 208671986,\n                2395250976, 1549715018, 2746690542, 1219103496, 256305249, 358172450, 2072583005,\n                3916780941, 4158630723, 1190830416, 3779410961, 103078237, 413254256, 341045330,\n                1139999874, 92806975, 1388100212, 1158509802, 2339968162, 1347201015, 784082665,\n                1171121798, 1281820962, 528442543,\n            ],\n            &[\n                1082720091, 3476817859, 1893722246, 3080882169, 3417947745, 3340276454, 3885894760,\n                1942705317, 675159075, 2356580166, 2812410352, 1542004962, 2479082003, 1559105673,\n                1430407422, 3754123073, 3434749261, 3438277207, 3184426987, 2481219277, 3201501212,\n                2336166635, 3118471262, 4257588863, 1129103696, 2036867994, 1362270000, 2205796804,\n                1619465560, 1334326802, 1654568402, 748744581, 529239522, 352036781, 4164399267,\n                339969597, 3948817065, 4118696507, 3167307180, 3299871862, 992173657, 3312501436,\n                4234856346, 1472448261, 454903616, 2135585012, 1182478660, 3108573415, 289552136,\n                3656397512, 471369369, 621698889, 3506241896, 3050415504, 635379448, 309369370,\n                3135812778, 709795745, 3156857644, 1981234127, 777872572, 2069114566, 4227271663,\n                1642023978, 4255257763, 4251585692, 4102236891, 61692500, 3829081047, 2974587843,\n                3417120535, 3759026709, 543679528, 610505883, 2224107411, 952038760, 1845841012,\n                2091165188, 2319077898, 813461061, 4130723132, 819025288, 308176462, 1882359754,\n                1123046783, 351488317, 1740084483, 4031432934, 866128405, 3761028110, 153341699,\n                1557409832, 3958654248, 9848396, 1343150951, 1655256005, 3758327652, 714608206,\n                2476402679, 2222813494, 249341289, 20217846, 3718322691, 1309897917, 1956873127,\n                3780340503, 3187273275, 2997743448, 2763864945, 1015229074, 1035154014, 4111197216,\n                4129892876, 2463400739, 2137142214, 2932334703, 1212478961, 1404771156, 2403376672,\n                1666383249, 2101966267, 2787146653, 3409236902, 382073169, 8092902, 3172754632,\n                2362871022, 174894239, 2851299514, 4035565821, 1576086690, 1863466767, 2147230465,\n                4012739188, 2573883505, 3496112107, 1561836070, 2714989398, 518249309, 585535272,\n                1083806803, 2432909736, 417453124, 3662025813, 3862714644, 2982211872, 3413054134,\n                278502998, 1933231828, 1756355548, 4175286263, 1635691203, 1696182335, 3722603401,\n                3499515010, 2780239369, 2967447083, 3938392642, 1039437781, 156713901, 202025882,\n                3388635620, 4085640754, 2766466060, 3257237392, 1610632422, 2659484643, 759134140,\n                2468303426, 3485429206, 391268866, 3602129409, 466642453, 2027942747, 753837398,\n                2159887674, 1699077410, 3385420601, 2097219048, 1939536260, 4216211838, 1310649129,\n                3770773042, 2367698780, 2182982254, 105876687, 389319130, 956327995, 1042519322,\n                3560831866, 2584066309, 2359741951, 3525689940, 2936794464, 4165100291, 464352315,\n                1510693553, 1019366466, 1339175695, 2900331968, 1808660155, 3444379929, 844617472,\n                594684582, 2551754663, 4184241459, 2541557677, 1600387746, 3461253021, 20795987,\n                2007859697, 2294435372, 2967012275, 427466509, 3926685990, 2687323981, 58620064,\n                463567707, 2009818918, 2587127815, 335237443, 548349111, 2327100548, 3527232221,\n                963188157, 2846759149, 2508857384, 2785887779, 1911224250, 499633849, 339500132,\n                1698755389, 3785332522, 1951026064, 1157235411, 2385637652, 70752751, 3581109807,\n                1000717338, 367332589, 852120579, 1720305388, 2396130011, 2325323294, 3159509753,\n                2304229465, 3412995226, 1302807073, 1047169090, 103900265, 388968533, 1642951622,\n                2119771731, 3904510666, 3214555812, 2090353527, 3439045026, 414952145, 1990923465,\n                2145341503, 3376393463, 1768247381, 2500689220, 3437741376, 2952550055, 202503815,\n                3117369798, 3572610192, 3057469623, 3868128130, 2897590216, 1333004082, 3846323733,\n                1145656956, 2957222763, 1612732059, 636089096, 280438137, 4133371531, 2415302446,\n                3343573484, 450368029, 4013078578, 1776076354, 4055087576, 2875505329, 956580657,\n                1284100217, 484412750, 3403238717, 114812192, 3141957869, 1923373041, 4267447588,\n                1848508027, 3578399081, 3602314328, 2015600160, 3169258369, 4225283, 3215758323,\n                535488666, 2299743753, 2598839590, 2251925973, 3424293163, 1583565986, 822791938,\n                499972304, 3526253756, 3187560030, 839910754, 2473717205, 2920751658, 281393009,\n                1675618188, 279356115, 3737356546, 2987221453, 2784535811, 1716035779, 2728300709,\n                295755590, 79028394, 2321443009, 3334571157, 2092798399, 776878210, 3880589251,\n                3000121191, 895584305, 1972715675, 3933866443, 2459940020, 2535432427, 3442732987,\n                1351280251, 2705869134, 4056756488, 642205063, 1335417345, 2925570768, 3272930570,\n                1215315775, 2270360900, 3920083766, 1800417946, 2267749997, 4044783727, 1769884599,\n                2859569555, 3317860539, 616401729, 639899592, 656298035, 1728919003, 4078302028,\n                666745393, 1560472966, 3582178280, 30041205, 1445208285, 1831729364, 3833375730,\n                2031873203, 110189422, 4001884424, 1172085689, 434283494, 365118314, 2974799471,\n                2419990253, 2254345440, 3303650744, 379954120, 2872690320, 2813488227, 2931609524,\n                750879352, 3553708007, 3932935565, 2268402810, 4181556412, 2645378729, 3996572258,\n                1392500829, 2476571256, 2592516278, 2941009392, 3567442876, 3295525458, 2364649002,\n                1107394009, 3085546406, 3546490308, 3980163356, 3563024751, 1632689827, 2857550583,\n                2854525629, 2769744068, 3179245702, 114619536, 1503846887, 3983245950, 4053448614,\n                3804164557, 483691484, 4154677001, 3343013834, 3198409629, 2196007920, 2814767401,\n                2583091893, 622358751, 1909097055, 4275650466, 2408839673, 975842192, 1807945419,\n                530334006, 2193239360, 3573576815, 3375828028, 343495318, 4289026005, 1962467408,\n                347337978, 3396953980, 884291722, 1137165202, 220827107, 779266710, 2344445455,\n                34856979, 1143045482, 56767308, 1578363872, 3731201669, 3706120565, 3337776817,\n                4289277255, 1854266966, 983344215, 1966863762, 367660085, 2557629697, 926188478,\n                3333617884, 3810871127, 349652103, 217155142, 1688170224, 3319067823, 2885726973,\n                134399180, 5674764, 3973054562, 2273408331, 3833933899, 3417440443, 1041778853,\n                1946826410, 3801686902, 1531220405, 1393391045, 331387982, 3898611911, 268525782,\n                3769634949, 3016559037, 2445833730, 678007929, 1519682189, 746295463, 499000954,\n                1304839962, 2069998292, 572428575, 980128037, 1245074429, 3558109310, 2997264588,\n                658214766, 883463509, 3369353012, 1297551772, 2110922247, 2798156905, 955238199,\n                1636058159, 4078945672, 1404295386, 3413374279, 1206293582, 2450940328, 3853860296,\n                568231531, 3871379428, 801397097, 3548192318, 2198482100, 1425818836, 2226232328,\n                2217750444, 1674221667, 575304554, 339577605, 1944985402, 3285623423, 137164688,\n                2194970053, 3895173964, 2206988857, 560190101, 4150633681, 2529897699, 2877680493,\n                2138142714, 3624049789, 4259353316, 1917725116, 253374220, 1961669318, 524948489,\n                3660413785, 2459743863, 609305506, 4234617120, 1880171213, 2231312825, 3930360917,\n                3757082546, 1598330816, 2275523468, 2537954969, 2648376719, 3949938840, 1179324615,\n                2638061103, 1420005740, 162992051, 2259945784, 1691781876, 2035325287, 3681767229,\n                1864052113, 4098159425, 2904470037, 2739041791, 3653434846, 25187402, 743386308,\n                1617431581, 1955566361, 1609808798, 612646080, 749092400, 3476155485, 372463231,\n                2400385265, 2448935262, 2868736303, 44050485, 1811513622, 244185373, 1058010832,\n                3236838304, 1696379775, 1374320342, 893033010, 2184044974, 2103383697, 3678814304,\n                3707318863, 2232216478, 2121008938, 3391204665, 114653376, 3539615664, 693415359,\n                3948513646, 2472340375, 2689595350, 2911666831, 2862380219, 2277904386, 3052644532,\n                3620922554, 1583320802, 989453708, 2848948202, 2802447076, 314144584, 1963582024,\n                3054383355, 3230565030, 3198370807, 3232305102, 3533915944, 1159220898, 3409956546,\n                739193900, 279482209, 2395025280, 3213913189, 3465386197, 4007322480, 1185701264,\n                882190169, 301180834, 3985404529, 775008128, 1929920973, 498148924, 1653387516,\n                32770831, 84662291, 1070233280, 420774040, 1845466025, 2660849065, 892513130,\n                1220251223, 3462048171, 3639870150, 279428221, 2277386828, 1042423213, 49732010,\n                2156548934, 2306505697, 1610786467, 2412885409, 514239305, 3502348066, 3662528922,\n                3523842425, 499321566, 1558826766, 1025787712, 750835728, 2151253987, 2771548076,\n                1874413816, 1770687295, 242014543, 2896631433, 4270012022, 4154175689, 358416847,\n                62726299, 2459979834, 3959988277, 3138565580, 2632517010, 3757121807, 982781859,\n                3866772115, 1940202687, 143199844, 3711383957, 3192090943, 192177309, 3414164907,\n                2772999412, 3345422423, 3632869399, 298443741, 1301417999, 3779042088, 3129617922,\n                2534671226, 3888890090, 3440629680, 860078030, 3705887480, 1118604355, 1986962149,\n                2134492511, 4252575925, 1247103708, 2063043343, 4018417608, 1435800387, 3604051252,\n                2382645558, 65332182, 359897542, 1245864255, 1609404488, 3987595397, 3239425334,\n                187261326, 4123855750, 1200175240, 2149408423, 3981447331, 4266532762, 2991803305,\n                904593361, 2972818330, 1285040552, 432629695, 3318003843, 1422945986, 903546290,\n                4170273900, 2167679655, 3927128491, 369901225, 3823643528, 3070820575, 153246247,\n                3566780970, 3775810437, 100362394, 3451770819, 2165886441, 3421082619, 2757100947,\n                3862770948, 991992674, 2507717612, 1238760013, 1566046550, 3362507120, 3516476868,\n                591759613, 3252699908, 3659831623, 102934758, 1522937224, 2690593629, 4166523866,\n                2815574307, 1262613047, 3171249524, 859033927, 2026114441, 321675781, 4067069202,\n                1828982470, 1,\n            ],\n        );\n        // - bits != 0 and divide-and-conquer division in limbs_div_to_out_balanced\n        test(\n            &[10; 276],\n            &[\n                108635137, 53042175, 2495789053, 166626339, 2790541996, 3399648116, 704235903,\n                1987319994, 3846313422, 3704598543, 3690196699, 3215164091, 1591950078, 4084137444,\n                3535469973, 369348781, 3853840741, 38365848, 2204958899, 420812105, 2779552010,\n                1548769452, 685824244, 2413919731, 3001005256, 1844653400, 2702666282, 953246091,\n                1180609303, 1728187391, 3376808367, 922212062, 2555240, 3091442748, 2779003823,\n                1730350709, 3884150184, 1912296588, 1381602302, 1132745285, 2605509609, 907722107,\n                764554269, 3991449945, 3268497606, 652777597, 3569835073, 3292533280, 1757212806,\n                4083008115, 1567249607, 2029822077, 1300690097, 542854515, 2421776641, 1792015269,\n                3385254138, 3324421134, 3135185624, 2936968278, 3252736384, 272507607, 2728141594,\n                4200848223, 3001744645, 1397661269, 3892465560, 2335547432, 3245101563, 1241760367,\n                93951076, 2656438422, 1056867098, 3937300802, 2762984593, 3306503534, 1748156730,\n                1129525575, 654008385, 439540212, 2194484000, 3773978123, 3104733633, 3072629324,\n                1956867429, 3192898033, 520613936, 2701719680, 3263467682, 4152521012, 821868901,\n                857419957, 794567744, 1966964158, 1188525445, 25386574, 4072516363, 2420189258,\n                506921989, 4093279187, 45547769, 513061404, 243072258, 3189135266, 3207683448,\n                3842162034, 1133520520, 175840391, 3746219860, 744587725, 660570869, 4002101132,\n                522243467, 2303217069, 1674769460, 3791198176, 3339780616, 3458756479, 1979186301,\n                896682364, 2308144330, 1378320625, 4274094804, 586903390, 2523245831, 395299569,\n                1187786606, 2283803123, 4267141178, 2219595837, 1128697087, 1857876110, 1318499953,\n                3165428382, 1575816218, 956482234, 18588216, 3132721083, 47556415, 81611970,\n                3910123222, 423589575, 1101413252, 3606836170, 1942712759, 3189437565, 1988019498,\n                2092781681, 4236534903, 790511562, 4060480297, 3105894710, 2764365449, 1397438933,\n                1196278536, 2058315951, 2838695613, 4281268824, 3826944690, 1181288743, 369591812,\n                1309874942, 3790984071, 288341904, 1563879876, 165797805, 858735816, 2072353128,\n                685737219, 361047486, 4066070935, 747362930, 2075612928, 247842391, 3759957561,\n                4008727703, 3301939318, 2461349415, 1220733209, 3976094938, 4150525547, 950524413,\n                615359333, 3819351887, 604594973, 967650734, 3412914931, 940128704, 3084501448,\n                3552914752, 1468579018, 3375888808, 272090024, 2102430932, 2231900023, 407815192,\n                3133923502, 808329364, 1437980982, 2714133004, 2541977126, 1644097574, 1605051578,\n                900680606, 1233529861, 1285360886, 262211605, 3340000454, 3059934898, 261179603,\n                1359321373, 2785008571, 1696998009, 4208277335, 1632076295, 1780238612, 1096677031,\n                2326184831, 1755582758, 1271079634, 3473819079, 3524297696, 2971249360, 304707349,\n                1752064216, 3406003757, 2298730120, 3470434630, 1822263204, 3897394658, 1744777112,\n                1474862410, 2619263924, 1883564355, 245003326, 2772487730, 1684833147, 3384787730,\n                3432821829, 1659957487, 4143280212, 2945269934, 2715460396, 3109905612, 2183811774,\n                423754031, 2103134812, 1722483377, 1623977444, 4207250751, 474534834, 2675551745,\n                1065671136, 3814366580, 3372473612, 922981250, 1210468465, 535527770, 590607480,\n                2860431542, 509048194, 3860804971, 3161644296, 1119093457, 2017558623, 3882518387,\n                2116262688, 1592400489, 1330477596, 1812541649, 3066693344, 1681733293, 2837523711,\n                3962139488, 2400483346, 684544040, 618138932, 23933358, 337472067, 4255565569,\n                3863904974, 1571272948, 3063467317, 3199661373, 2892202115, 3466650924, 2813788238,\n                199916841, 6302159, 3020774987, 2959649954, 3051172815, 385827752, 3500074887,\n                1998588949, 740187474, 1537085728, 4040744226, 169795027, 1388002404, 448995184,\n                209159058, 2041030169, 3989416757, 2372340142, 610343086, 3895834685, 3130822270,\n                2937770030, 354183502, 142181574, 2610105359, 2678801631, 3035570967, 3617741371,\n                3969553519, 1367705229, 2107582010, 3358994616, 3893272782, 661536642, 41261552,\n                4179523599, 3717595615, 2660616505, 364657719, 1591424432, 2930227288, 1470954796,\n                2176631849, 1725166260, 2686775012, 818766763, 1889939384, 3037885089, 3635001611,\n                4198592608, 1743285046, 2898224735, 1659026011, 318231763, 4236634945, 2813628609,\n                1962109336, 1610396960, 3016705702, 3623307415, 3832212453, 4249700382, 941544661,\n                720165462, 4093658500, 3453816013, 2079181823, 523275463, 3269528702, 3019887295,\n                3811204518, 159775628, 1722773106, 1469942260, 3026312336, 1636680124, 676646879,\n                1243866643, 3046790125, 3838163884, 456070987, 3400235386, 3209376427, 2052709404,\n                2975905060, 3314477136, 63144045, 1485059871, 162201390, 186441332, 612262739,\n                828760782, 3475105064, 2824483050, 780082694, 2214596670, 79854651, 3785529118,\n                3362875978, 2019456835, 3664773598, 2128455541, 1830176771, 3131136264, 385070469,\n                2166122015, 4242832149, 1871374367, 2866877895, 565736311, 3669481600, 3732705160,\n                920034463, 1676220645, 3589606699, 2654716480, 1934326920, 2849139664, 3961632132,\n                3838830143, 3776089649, 3421594363, 3482840282, 2537104160, 3010338838, 2165340101,\n                1892478832, 2700868158, 1092691010, 2008876123, 752365533, 628818795, 3526690309,\n                1565204, 3539771692, 3129225931, 3999602879, 843176653, 1303696065, 2008779360,\n                3311453295, 1156870995, 3738053906, 359090986, 3637794830, 205702249, 3331669407,\n                3910416238, 3925253071, 3900326738, 1156846221, 567150051, 379723012, 3421075741,\n                2064258650, 2895443535, 753490073, 948868209, 3567651732, 3728641104, 1287032959,\n                710808071, 1107267370, 515160531, 1433094102, 3871178973, 3077300132, 2340844017,\n                1955407235, 1314652042, 3168268098, 2448320270, 2400447335, 3294295438, 1015553266,\n                2155337410, 1202973291, 26721975, 748351815, 3704104726, 493250895, 4196736012,\n                260103997, 1216172054, 1878845953, 2517690048, 2952150363, 2853405105, 3643402580,\n                173602363, 34441180, 4232560859, 3432794922, 1140120890, 3906522401, 1592024957,\n                4187088827, 3565666595, 2036898614, 1513649673, 89930944, 2373451644, 570806865,\n                2966068116, 216216149, 901919588, 2525422962, 926283525, 2020466305, 4176067636,\n                2062906224, 2749700324, 3770003319, 4243016358, 1536893669, 1734422817, 1903034843,\n                2140137740, 2133960349, 2127799686, 3826582112, 219489448, 508455455, 400134475,\n                2681095601, 1225367969, 1189240142, 3928151903, 2223436694, 188587138, 2759880580,\n                2159086089, 139714886, 4230028328, 2668106965, 197527044, 1076021583, 365687428,\n                2429361726, 987702546, 479721329, 370553881, 330849794, 1208154538, 511352639,\n                1347185232, 3309753618, 2165973922, 2714839722, 1566744459, 1258272726, 4003842107,\n                1592609821, 1602879458, 598396180, 1691880384, 1805556651, 951428589, 1382102411,\n                3352671230, 3650598499, 3958924995, 3934211043, 1708901267, 2214291603, 3062058779,\n                3334192431, 794991697, 1238615391, 1385289547, 3821895409, 36111771, 1154601572,\n                3442859590, 72901265, 204664637, 3567057924, 1929964733, 3447462776, 1857620277,\n                1670547089, 3282928074, 1385001633, 905180163, 3027069579, 1563462544, 3261712196,\n                2691524721, 2887321824, 532509125, 1250479582, 1736964157, 1752056130, 2411795965,\n                2530177666, 1944298739, 4021827042, 235488471, 49513017, 364455717, 3051752647,\n                2541367373, 4025312306, 758560501, 2532590036, 2497355449, 2645291172, 4094509748,\n                2811604062, 3938869461, 2314766426, 3949981315, 3113301191, 3961932201, 3642942123,\n                4042045976, 1080625720, 749107450, 2408837571, 773510366, 408327874, 4043794032,\n                2751095877, 4253356392, 1852579882, 2930909909, 22950574, 2455166107, 1518997069,\n                3502877484, 3466955328, 2495681100, 1416465050, 2781446012, 3974552369, 3963181882,\n                4031801829, 971448688, 3324460697, 3468632379, 596003274, 2001813586, 494254023,\n                3111644337, 1214103910, 2547242619, 345292455, 1171889494, 2523157824, 2004995962,\n                2793293234, 3357565902, 3618900967, 1122158351, 1840000495, 3714974862, 2372340013,\n                3036104311, 1987619821, 1915784172, 187130136, 1032034929, 764058777, 1324555408,\n                4258631431, 2565322815, 3622146170, 446425747, 663948352, 3473130059, 3081160831,\n                881843540, 2045224772, 2479557013, 3352503836, 1209737991, 3178334862, 1649664345,\n                3898477658, 2455734938, 2058141628, 1165813520, 3499004048, 1363642302, 1673253013,\n                950040890, 859882680, 3358702534, 2831246639, 3154009927, 3886020609, 4260600294,\n                4292328051, 2154852829, 3071909756, 3083791599, 2780514384, 2089946486, 440735136,\n                2840096690, 3847114327, 4107780595, 1507811167, 319613030, 771404322, 3267312644,\n                343171187, 416166006, 400367691, 354408782, 3664160643, 306037219, 2628548851,\n                2490873938, 147038682, 2557865570, 1918482947, 1550632444, 1104237513, 2381980505,\n                1257779567, 3978083093, 4188937519, 1450461940, 3573655366, 4007222924, 899058972,\n                2762018299, 2973671862, 613016156, 3453147112, 3958949304, 248065424, 750535902,\n                2025904997, 2542540928, 3631746189, 1474696231, 3349867745, 1645065489, 1753887057,\n                62923614, 3355303085, 1757052497, 4111601366, 4122660071, 3488098722, 968401720,\n                2418687776, 3889098632, 1507574874, 1788573805, 930165776, 2563485754, 2283929886,\n                361900473, 3829676677, 2920155840, 2690982721, 2647324946, 933444487, 1982178922,\n                2334110536, 2878917031, 3486781662, 1761730411, 3024808673, 3873242498, 3895635845,\n                1874483821, 1898379794, 4172331028, 3759742822, 339224592, 336709787, 1768365716,\n                3768045522, 1226451429, 2705764626, 2090014839, 2715498023, 15765857, 262371622,\n                1364974277, 3278122087, 1085595683, 2097096706, 4084807931, 342124999, 3362503915,\n                102138122, 222464351, 2367255609, 329998946, 1654125618, 1397194509, 2342407041,\n                4218981334, 3043210002, 1820580167, 3532477643, 3698803212, 2459696610, 3760108330,\n                590088894, 2109406971, 2851337682, 1821297729, 3479206596, 3141773016, 1887780855,\n                3345901315, 3465462131, 1285191121, 3092915327, 141461573, 2073757501, 878536688,\n                1772007905, 1193942688, 1553571015, 2179016361, 3232910452, 897070601, 2148852628,\n                4215017747, 571464735, 3364559156, 4279542294, 3759036030, 2656683267, 1707236123,\n                1356967673, 2580245428, 1451203266, 2299603042, 3068898426, 1148383426, 950626083,\n                3457385021, 2591070383, 3181532137, 3347056243, 1495266049, 2210488892, 720796437,\n                1413487507, 3065309505, 3696802085, 2734150063, 3600467301, 2529953774, 2679381445,\n                4233323864, 1085096641, 1587182738, 4041255127, 891185711, 2340666116, 671752008,\n                4136178412, 379067213, 2916836063, 3982716045, 745125821, 3190060915, 2728700228,\n                4248229826, 822059760, 2434419301, 2390321192, 1529594228, 2455438975, 1623635782,\n                3927813233, 3131415702, 2632189134, 2093836398, 4098626915, 1127324299, 2709110703,\n                1267984800, 2156759432, 947735481, 2766133233, 4227965085, 531828395, 3790033202,\n                3790793152, 2975006665, 1116356882, 2644453515, 2771505868, 3490730292, 2557842446,\n                3338652340, 837555851, 582834001, 3882158027, 384350213, 708918872, 3173032166,\n                14955604, 3415856040, 3404370362, 3759099429, 2374207480, 1534379322, 2698542736,\n                2164045979, 660913601, 3556971203, 1616608268, 1829936346, 3109981160, 697542468,\n                740461237, 1422792083, 3962800663, 3066960795, 1173757342, 769744240, 3750815337,\n                3814517080, 385190612, 2953064964, 1871983583, 1649509432, 1554161863, 3185361908,\n                2106975424, 1538113731, 2523454661, 143645610, 718612279, 1723847182, 747395397,\n                2882688996, 2021890066, 1030716023, 1995073902, 4105305241, 2127982715, 1690451116,\n                1956139100, 530256795, 3558366590, 2724310482, 2341665586, 250870045, 3391930252,\n                3942088647, 3976895259, 112642770, 3730114995, 1371701615, 3644536213, 2026852217,\n                1200740294, 2038780887, 648265626, 1535440607, 782951933, 824579667, 3601202459,\n                2314910152, 4263436566, 442006573, 1248351448, 3167704183, 3934018759, 3957471958,\n                2504687739, 3253599456, 389758313, 3342046926, 278999028, 2652455147, 3325515388,\n                2176380480, 1129683162, 3997989394, 3620086114, 2746229755, 290677810, 1466119856,\n                1528967320, 1110833004, 135210629, 4036023385, 82033834, 420677558, 1964407130,\n                2702828444, 3920237543, 930065859, 2455503717, 544391994, 38795400, 3389365984,\n                2189324221, 3653325550, 2984928969, 985994309, 4212011784, 433292705, 3993514299,\n                272538953, 84416207, 3750907699, 4166502555, 3618032189, 1236823026, 4151994611,\n                2505418422, 1513527578, 1564158364, 2400104436, 2118135017, 497726437, 3029863178,\n                3946017842, 4023841770, 299480378, 3182449534, 3212382324, 3197008823,\n            ],\n            &[\n                4002709364, 963399356, 2782341067, 3945310775, 1640289005, 3723750838, 1254211967,\n                2304588540, 3174496786, 2728509707, 255821323, 110353438, 3720272848, 2229377273,\n                2152240593, 1976405605, 3700189945, 1261817945, 962162212, 2968380111, 734133596,\n                725489232, 1719612084, 3884866627, 28057341, 3961915971, 1325614652, 65176638,\n                3323056153, 1428210708, 2748040079, 943478886, 2463128528, 1179615866, 819519877,\n                745909987, 2928403710, 428934326, 1802933992, 265877181, 784539883, 3368469872,\n                2186856195, 267183160, 711926800, 1784916336, 3062621903, 41142608, 1185902375,\n                3289485275, 2769494454, 845407692, 420641321, 1822514821, 1468465938, 3143456289,\n                1922484069, 4035995228, 3823561491, 3573485374, 1462883391, 949414736, 1205197438,\n                1545720767, 4004962418, 901935939, 1176411707, 3934655491, 1247692219, 3372976809,\n                648846849, 561624310, 4213429112, 388574078, 3876368507, 2459110297, 3629548833,\n                2842464979, 755880226, 109802803, 410812363, 1884761319, 4167310741, 1416731661,\n                4162069084, 3695932529, 2935063704, 1097793995, 2124836831, 724360417, 3061931520,\n                3339903277, 3019747519, 303387593, 3800465715, 4021351514, 2617312748, 2101558562,\n                212720952, 2948123341, 2761073207, 3424660022, 1745409052, 743791614, 3820519067,\n                3495466566, 855725038, 3341655828, 3835113615, 1270021592, 1093683126, 366232505,\n                2382273294, 687690291, 2407217871, 3126999218, 2489109394, 2399521074, 1912270761,\n                1547900176, 112668330, 2418271838, 164643, 788458686, 1283051461, 502966828,\n                2822195605, 3290495578, 1940639423, 1104706107, 334853171, 3663855161, 3267632296,\n                1384333597, 2439397119, 360160344, 913951997, 3699617663, 2223491591, 4152571511,\n                4127552387, 2384896323, 2719106630, 1968080578, 3047590289, 1349230865, 2632158056,\n                417315676, 4047908012, 2058515124, 3962573168, 435657190, 3869063277, 1129208107,\n                371028160, 2341806620, 1837536116, 4062395278, 760408526, 489855682, 1341968057,\n                3582061385, 567307943, 1459157484, 2793270460, 3765006265, 316630926, 3312280213,\n                3038146737, 1954778145, 1255537680, 1872487321, 3078336, 1786349493, 2936757034,\n                3157582052, 656659566, 638195606, 2761830593, 796052712, 1835931537, 3594050559,\n                2825844970, 1783476497, 1587070264, 582928447, 349530572, 3521756034, 3849814263,\n                3898598710, 1487612894, 3546940589, 3702560901, 2571834495, 2432615017, 151334837,\n                1929191978, 456717814, 1822026775, 2905791667, 2187809681, 3085861483, 2527039138,\n                1461502989, 1674065300, 1427963173, 3931324821, 3503894366, 770079370, 2646944748,\n                192300986, 1063095706, 3173456208, 3863439598, 3538143515, 1736463922, 2524154399,\n                2134152316, 2565447595, 2642170528, 3536538194, 1250655424, 359773845, 3664161865,\n                879705815, 1474928595, 2536605270, 1911087921, 2962799796, 4010905032, 2793477763,\n                1959425433, 3713879004, 136714178, 1724676493, 867784003, 3212103591, 453276555,\n                1061978135, 1967464120, 3591583971, 1101672396, 1057025284, 2241955674, 442433290,\n                2456783152, 793285251, 1178449650, 684670303, 1866273007, 1391022401, 3083722623,\n                2493222535, 1189326604, 1199252550, 3969981178, 4060147906, 525899569, 24010191,\n                765321740, 2761772368, 3377909206, 1331140315, 3875549784, 4212148483, 2588352295,\n                1569174674, 1936659977, 626141956, 2533524762, 239859149, 3534146265, 2997682745,\n                71238037, 2732432587, 3908540462, 477053537, 1471594724, 2867685233, 3586191718,\n                1273507649, 1161961515, 2329077270, 2132699100, 2632998553, 1299594849, 1554941646,\n                3548827963, 3889378581, 467940077, 4211088672, 3371367836, 1620737016, 2233519964,\n                2624185462, 843840626, 2427990702, 3297260629, 786361707, 1646501219, 2205482711,\n                1032553750, 3122751558, 4227854173, 3810881375, 423778347, 2970196049, 2431725362,\n                2079714185, 1671048359, 372886771, 3881108825, 1517433910, 980297672, 460700981,\n                1452459198, 1527418894, 1426505982, 3181114286, 1351932282, 2092103967, 2878978239,\n                2422613736, 1750361767, 3327673906, 3090894970, 3102624891, 2501611324, 2723100867,\n                3663964999, 852336624, 4080907747, 3496497293, 865887813, 929644307, 2488175940,\n                838516249, 244558558, 3755455496, 3162262069, 696753816, 1156821200, 2717965945,\n                2023685211, 742596168, 4023287277, 869919872, 809477569, 2011079194, 3221489136,\n                4266255834, 2419594884, 3939612855, 1706366855, 2428360994, 716879901, 3297635122,\n                1769572686, 2873365745, 3831233968, 1661441467, 3919563787, 1226247329, 155760684,\n                2127556453, 3650610530, 3912925100, 3397709082, 2605399534, 844200203, 1218697875,\n                3747822377, 1899143697, 1732546786, 2288016347, 359886996, 3307751257, 2007742513,\n                2748636623, 3533690902, 871243358, 3464803523, 4180212238, 3640833128, 1577830398,\n                1892628035, 2306472556, 2996392130, 3006231684, 2296266179, 3151580099, 3594248718,\n                298545948, 3539272117, 2749678939, 1874404025, 2584227634, 2959840975, 4165861727,\n                959382651, 1009550827, 649210999, 3468285293, 3791505115, 3177835926, 1574975458,\n                3712971814, 2268845891, 3027469655, 2612516945, 2767217349, 3437723210, 361909048,\n                174803142, 1801608370, 2683396447, 4123855575, 3743115358, 855097355, 389967654,\n                3466849183, 62496602, 1570756383, 2619549118, 2702719459, 3205603560, 3517585951,\n                1001571916, 3914648094, 586411011, 2203219545, 1991805170, 291462253, 2626091906,\n                2500429699, 3658425250, 591275011, 3457521561, 1909516648, 1016647432, 1214423814,\n                545389916, 2274937717, 4186397493, 2838711218, 2407104593, 3341370919, 2071188669,\n                1056326847, 279675352, 3143136760, 663034604, 2337665064, 1068045341, 3288706086,\n                1599970362, 1807582654, 3478852750, 3645690411, 634626702, 3016872041, 4009908955,\n                1006051491, 2719021150, 1908698847, 1974558407, 1045151170, 81414730, 1422867232,\n                4197239354, 1591983466, 1874189107, 3882070116, 471160619, 3538033652, 1325575575,\n                3542883207, 2157625989, 3201577383, 609577155, 1394935989, 3283862577, 898081363,\n                1638703961, 2459812069, 2143849566, 1692845986, 191429412, 1947558163, 2654605920,\n                362944274, 652627228, 3005443786, 1907584792, 2260991562, 2033179708, 517601169,\n                1610423429, 3396730858, 3421003047, 2978082438, 1862441924, 3826508713, 1263943479,\n                2041961479, 3942582480, 2128168260, 47267024, 4126534310, 3346534361, 3387023656,\n                2882502992, 851762018, 2559987094, 633154678, 2834924154, 68763504, 2517021392,\n                1787244558, 476241955, 1869261127, 451025182, 1484615367, 1293374777, 849824408,\n                125615889, 34383294, 709860222, 3029061471, 1782241004, 2502486226, 3289755139,\n                1884331971, 3585604373, 708130179, 3812432338, 3121673423, 336729898, 3212815979,\n                1331640570, 368808354, 3927992910, 2583344309, 1604683896, 2377675664, 1432049895,\n                2336708810, 1233966810, 106712876, 1665259905, 4193964217, 192648794, 1498181023,\n                947378957, 2402512259, 1416057697, 1026447453, 3945411820, 3451452905, 3553837717,\n                3947305034, 902601876, 3942899828, 3516283811, 262422749, 2638031869, 712288220,\n                199462641, 3599010749, 3787584036, 1126365450, 4070880751, 3865411772, 1658495826,\n                3570711854, 1735726921, 119145303, 3163130848, 1291336833, 2146796315, 1896458910,\n                3507258381, 3730474410, 647902664, 119220376, 2833167618, 2741203329, 249470903,\n                71327613, 1931728642, 2604757487, 1117219288, 711428972, 3428460616, 322366467,\n                3243077053, 3378897681, 1403843932, 1991989918, 2413012613, 1365744141, 492078564,\n                2676610402, 3773231972, 1970922906, 2318388358, 1112949420, 3487096476, 2360170040,\n                3943418017, 3228760458, 3122193412, 3638387262, 1016961461, 2409174780, 1643889695,\n                3848556024, 3685824617, 3512748976, 3284143746, 748779869, 2874184074, 1232281025,\n                4144896530, 1069350420, 286933366, 416090620, 2657050801, 3108410259, 4063672733,\n                2336832052, 4393947, 1331069304, 1668926341, 3265202467, 169918063, 1585538827,\n                1657996381, 1427959009, 2747423595, 433894126, 2042216201, 426611464, 2098273364,\n                2681925510, 2347419442, 759472315, 358883472, 3566573061, 566399128, 1133339458,\n                3913483015, 1985356395, 2890868444, 306415199, 1693603799, 815436612, 4239331360,\n                2080083468, 2674607028, 308976991, 562939988, 142614472, 2751524972, 2580927221,\n                4040617817, 2258237186, 2077092459, 1424533819, 1818261836, 2255477956, 2463113859,\n                3917783, 3196888747, 1250369919, 2128811027, 4135988753, 2855121231, 2751603541,\n                1748944916, 606818116, 891282707, 1280813224, 3409874308, 890595934, 3601429200,\n                671048320, 3885753853, 2067382323, 3518602897, 4104376817, 3947164920, 2066705712,\n                3805972909, 2493699797, 2966924389, 701802948, 2781603469, 971061938, 1383226196,\n                3438743891, 755681190, 3291987780, 2657031748, 2157421567, 2518108674, 3181389973,\n                225606787, 3198444098, 651201578, 4077819767, 462870400, 1659941395, 3260365109,\n                591607061, 3304541751, 3964864687, 3949358441, 156533293, 798441780, 3281785939,\n                1484494452, 1302095638, 251493387, 4009163885, 2395098738, 2328212887, 496298918,\n                516574034, 2964917507, 76965044, 3856691333, 864137593, 2447187657, 4258071311,\n                3755646436, 4248910684, 2663150304, 1237165667,\n            ],\n            &[\n                1984473199, 3256227249, 2455176569, 2099166325, 4149291216, 3802329550, 4268938044,\n                841307730, 1835702977, 1996082126, 3547567838, 773843704, 4016216621, 2681973928,\n                2642638628, 756126484, 3711891528, 3333768427, 3023107041, 329078158, 3831084881,\n                2250143469, 2740854484, 2065364093, 16475968, 1789063882, 90562755, 2395829638,\n                105502248, 2464984171, 352362049, 1671925562, 1672656429, 3912672783, 2976521985,\n                1857535053, 912101373, 3599178263, 1475622388, 1679421724, 912451536, 1544347804,\n                3409297610, 2780624831, 2956890227, 2759200533, 1377434234, 737077784, 3725690282,\n                3427153748, 1794622970, 939859254, 2855863085, 647722556, 354344551, 3826763791,\n                1345727351, 288135440, 1036229247, 695718102, 815041410, 2006432724, 28242562,\n                1749929211, 875993743, 3126551415, 837166301, 3481584796, 3204894742, 540424284,\n                2500473276, 2033531364, 3658774875, 1170881648, 1587377703, 3303215635, 2382459946,\n                4261489817, 3503640610, 2312174189, 2085919298, 876781300, 3523968595, 3794900435,\n                551562034, 277917899, 4049545585, 1148488459, 3049249256, 3028547737, 385184461,\n                2327045056, 326335295, 1526099772, 4222288321, 3335089988, 3223345238, 3867286782,\n                814275510, 4052015149, 1619520353, 1451459556, 1906956921, 3352694287, 1890686648,\n                4263536151, 3670741827, 3921992654, 2432133033, 3137493217, 587639161, 305609045,\n                3928594642, 1789779366, 151593889, 3742404497, 2236095179, 1327594808, 168249194,\n                3856434419, 1196489310, 3396059561, 647915695, 3822118736, 3541416683, 1851262272,\n                3995631059, 3428808225, 4186414337, 2490990084, 2116008544, 3650220767, 1396560346,\n                907120910, 1909963938, 4088722647, 3467954950, 4004624286, 1977459563, 3110163371,\n                4093373364, 619921165, 3816233891, 1937989728, 3624382539, 2436122875, 544743061,\n                1173132218, 2928770999, 1155101491, 439835796, 978535833, 2767377467, 2446840779,\n                3121046201, 1239790209, 1427805909, 3673596610, 3945221930, 1197651601, 1456742497,\n                177427399, 1394121276, 372545580, 1590879370, 1356252877, 2819023735, 2147545641,\n                3662283870, 4040887354, 3677669405, 1738433639, 291377486, 55300961, 4286101333,\n                3829985898, 2667081711, 1422260840, 1198139136, 4157283455, 3655872630, 1182240668,\n                2228451189, 1436090123, 289825845, 4160160212, 1255112200, 3852671276, 291873274,\n                3097152433, 1700751971, 1521673523, 769906108, 100191651, 909759186, 3738396514,\n                63815917, 3764078995, 4283954803, 3644348060, 1146825084, 3992578663, 1098803369,\n                4234257585, 2499204008, 2806310476, 1805565067, 2148657240, 3603959232, 1973450338,\n                304954722, 187699076, 2886666068, 1565668459, 3119264127, 526428678, 3519310907,\n                4144387005, 2133914899, 367483308, 438788794, 2018175717, 152755342, 2289694022,\n                1623257904, 3632662641, 1438654875, 1957740844, 3866415111, 4036225294, 1540930636,\n                777575895, 1164306998, 905593419, 176596270, 1964891555, 435285470, 427518217,\n                341067847, 1226878934, 3817779176, 655247797, 1445754505, 3726676144, 2254233196,\n                1355909097, 3364332039, 3448860423, 4203238266, 3244898179, 2238989099, 2550902008,\n                20701893, 2266649866, 2508429693, 2270048684, 1797834837, 2026596902, 379667603,\n                2096274613, 976774677, 2606058996, 225173995, 3819162877, 1852526611, 2880769412,\n                1907061042, 1871814156, 1625893023, 1164237684, 405483535, 4277482961, 2315260153,\n                1956694410, 2508860583, 2,\n            ],\n        );\n        // - bits == 0 and divide-and-conquer division in limbs_div_to_out_unbalanced\n        test(\n            &[10; 166],\n            &[\n                1459165216, 3821473485, 1527833631, 534557042, 2641251684, 3809609559, 3061112419,\n                3967227446, 874369607, 3357113542, 172837185, 3063799945, 809083967, 2114991304,\n                3652585499, 3870981027, 260839090, 86387882, 3506805298, 3586414637, 1219151546,\n                1074937346, 1869327638, 417941536, 3278188390, 2755475894, 732985043, 3207584010,\n                452875381, 1770638312, 2520936487, 429394218, 59073091, 2715600775, 2347478058,\n                2065207972, 333851993, 2020557144, 2988851968, 3434603645, 3867986743, 620458350,\n                4176081514, 687997565, 2000470173, 207628264, 2939063980, 2887037244, 88858000,\n                1979351616, 2144759905, 226043352, 2991906207, 2099593474, 388908813, 605491614,\n                917110966, 1440029715, 1265986065, 1353710372, 150747576, 4066821351, 2601543228,\n                3022790779, 2756513327, 2301300942, 4180697886, 536617044, 1792525146, 302356039,\n                2248737864, 1440314786, 2943873916, 194486140, 2460944396, 2163386634, 663134844,\n                1064843562, 683691518, 1346625839, 1429039926, 905082151, 1043984157, 3973238222,\n                3954748148, 600018136, 45112318, 3802284763, 599423421, 1288822021, 2339077887,\n                2053244537, 2215861254, 3570045286, 1668889163, 3129765729, 1881187635, 2099320920,\n                1455508634, 3101359109, 2133360041, 4219848842, 3274735980, 1661020165, 1959002083,\n                2476803683, 2995302951, 3007969525, 2952785468, 2735292483, 1339083985, 1425599321,\n                963296461, 3835062683, 3441026991, 1009908781, 785678562, 362135934, 221588933,\n                2902273739, 3436714793, 672263420, 391421925, 3562850020, 1167915739, 1235366482,\n                3241596463, 839741578, 1600792632, 1356868232, 1717207350, 1486509543, 609703091,\n                1813709463, 1754127387, 103270828, 2294491827, 1977478773, 3581233061, 2076865607,\n                1233918144, 468952816, 3796007953, 765537507, 1015431726, 1729447629, 4075863441,\n                1166265824, 1653283772, 2675507303, 1805466182, 2868049045, 393643708, 2395539658,\n                1405125898, 3106988834, 1449875350, 1921850832, 1103068145, 3501885274, 2708895753,\n                433758320, 3993837559, 3767611255, 312060882, 3998790645, 877231469, 2138719115,\n                4142414870, 1018473073, 533189076, 3104708022, 1178372066, 2975216060, 3907507630,\n                975237132, 386309107, 902266006, 2644385081, 1477475340, 1858200689, 3285099777,\n                1132271153, 2053580658, 1125376417, 874041446, 712345397, 1140230609, 538666680,\n                881721324, 1111893069, 2501306270, 2274122960, 1357144116, 2166627910, 577081103,\n                1122655088, 392081015, 596573533, 3113340265, 3964396084, 1011820872, 1620966576,\n                2716227347, 4149946487, 1583709456, 61899924, 4263575338, 2401528621, 3509028054,\n                3666511577, 397386472, 969124122, 4008000629, 2718198502, 1418318388, 2934063395,\n                2647641395, 1145485096, 2200369228, 1989216706, 2963238435, 1926386286, 2830877782,\n                545778532, 1945014519, 1638724297, 622208887, 1112164416, 2022531771, 2867462821,\n                599490439, 1876923470, 950997193, 1684774054, 3263116384, 859638073, 1516033581,\n                3344695361, 1785593437, 598067909, 2850637811, 2288401518, 1795058327, 4095583229,\n                1222559443, 737107737, 651134240, 7438464, 747824109, 3730428362, 2416724451,\n                2565046767, 2620912429, 2561442128, 2361206033, 3310915724, 858282568, 2272790867,\n                659862547, 461019210, 268119566, 1687038156, 1409316883, 2126896112, 1753824368,\n                2573165648, 3765733919, 1487774113, 2831055305, 21121671, 1366044190, 3078238855,\n                4195255404, 1496590230, 1626222644, 3171354920, 1518148632, 2538776379, 1154154541,\n                1870543847, 2084780047, 603891666, 524384754, 604772818, 2926191905, 3313865705,\n                2210821711, 3918703550, 1119015865, 1362962604, 1749827365, 2045857758, 2562923004,\n                1460944271, 3737144414, 3632123919, 2354988860, 2895025884, 3090512056, 3436396245,\n                3344468871, 136152018, 3202810570, 2877125824, 3677060161, 747702260, 2458095411,\n                1835835611, 1903565435, 1773042151, 1229867663, 1051182633, 1551699740, 46990108,\n            ],\n            &[\n                2983822400, 1175377136, 4004483281, 2235564407, 1822513467, 381114796, 280652026,\n                2967591791, 3307355161, 2377064394, 385476518, 822689029, 4246167127, 11318802,\n                2302723623, 935991327, 3629372113, 2655890047, 2427850107, 3493543220, 1199218706,\n                18464511, 3419074626, 131354313, 1681481125, 1916223295, 3786572616, 4255559076,\n                2934355035, 1723151624, 3248974311, 3738736372, 1475008151, 786397519, 2078941349,\n                3511637043, 626529836, 3727302624, 3446417866, 1056699846, 1674449049, 3597285965,\n                2085431198, 1104070989, 2845556388, 3561365655, 3725037602, 1844214597, 938693814,\n                3351033209, 2761175913, 4231374306, 1596758609, 839842001, 1569016951, 2417309445,\n                1330306602, 1051752810, 136987586, 4191267361, 12875184, 3448410984, 1907451325,\n                2277059171, 4081014716, 1109678253, 3098651582, 2013701166, 3694814849, 2213240606,\n                915706703, 466995892, 2849324974, 4088671183, 3041537520, 256167934, 2378660697,\n                3026916, 3420187595, 3019264354, 2517539357, 3190771438, 3964084208, 464800745,\n                2158354996, 2997461723, 1586829196, 626753654, 1190341385, 32972831, 4211614888,\n                3666851480, 4151894977, 3598196315, 2868568182, 3468849454, 1834890649, 3931331938,\n                1665539267, 344411925, 2706253979, 4175115668, 3417292439, 2920916773, 1978420139,\n                2431824169, 986409380, 1888406655, 3938963826, 1560180445, 3202323406, 1414927418,\n                4029028281, 3561590815, 3654051825, 2798678208, 317536782, 2586849954, 3375941666,\n                2815670947, 2163397988, 2274010858, 3353427146, 3194776320, 1018812088, 248020252,\n                2984616735, 2264657095, 883506886, 1203774994, 3281598423, 4002133977, 2951591465,\n                1380559214, 313180293, 2977296703, 943333173, 196114172, 4050138623, 716791187,\n                3081577264, 2452658991, 1506085116, 96780562, 3815905806, 894431824, 2606307520,\n                4085987609, 286762580, 3059401150,\n            ],\n            &[\n                2808057994, 3606496776, 1638284867, 2965092528, 3070561729, 3046780593, 2492165002,\n                2058133462, 1411482622, 1386159493, 1930973158, 2741344048, 991334618, 23694448,\n                3645114681, 2489826892, 2652335165, 300868672, 2296390812, 1038735413, 1402107292,\n                3134939101, 495678723, 1934871653, 2094500280, 2973473339, 930416921, 1063911356,\n                1613559983, 607236505, 3394770573, 1595743960, 2977461902, 3135858186, 3804985197,\n                2427992839, 40481157, 1194866742, 2665355479, 1208298331, 264923797, 1533531928,\n                589823565, 1623330987, 1821021081, 3936785116, 1670988047, 812003305, 186281380,\n                2006301434, 1859818525, 2519784381, 502212272, 4074421773, 1011623398, 2394120437,\n                1749077131, 358348440, 3091437650, 2632724490, 750658123, 940819777, 1564325991,\n                3192289990, 1922442690, 2098791607, 1410727269, 3997475748, 2046568633, 2328724701,\n                594683983, 2946935672, 250929021, 3546617499, 3147415082, 2862801627, 1752972798,\n                1777319581, 1049723832, 2195152639, 3483521471, 1734219330, 2576240512, 2409422582,\n                2679948137, 3770401512, 1061673858, 1725420873, 718139354, 233062852, 2768861085,\n                4124913273, 3554269730, 2872541430, 4278481571, 768499669, 4277599530, 3185103338,\n                1954279181, 3422846001, 98074718, 551096407, 3681600913, 2349433618, 3210489357,\n                2742261282, 4049115855, 914605405, 3971655743, 62350404, 3980249028, 823758998,\n                3662208770, 3596057304, 1896028596, 1563432047, 3924435289, 1454939129, 1062311879,\n                1403923520, 56670001, 3483882506, 1501725860, 976633875, 2995625644, 3931841873,\n                211374720, 1454175215, 3629938299, 2471336363, 4025409672, 91025627, 421183437,\n                2654995201, 1631399822, 552933189, 3700683612, 3350958380, 2564370593, 3463421537,\n                3068013499, 2815245398, 1236034626, 2411769049, 3471729333, 1807804732, 3870076218,\n                3233217373, 2623595623, 3235588553, 1211586912, 106513608, 1606540242, 735139009,\n                3646406666, 1157995439, 990423165, 1032637281, 3009147147, 3249314474, 1109145355,\n                2938339245, 1916419568, 824070112, 65967478, 0,\n            ],\n        );\n        // - bits == 0 and Barrett division in limbs_div_to_out_unbalanced\n        test(\n            &[10; 1770],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3758096384,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffffc,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                461373439,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                128,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967024,\n                u32::MAX,\n                4294945791,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2047,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1ffff,\n                0,\n                54525952,\n                0,\n                402653184,\n                0,\n                0,\n                0xff000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                44,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x10000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294836224,\n                u32::MAX,\n                4287102975,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4026531839,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3ffffff,\n                0,\n                0,\n                6,\n                0,\n                16,\n                0,\n                0,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                18431,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x2000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4232052736,\n                u32::MAX,\n                1610612735,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7,\n                0,\n                2816,\n                0,\n                0,\n                0,\n                0,\n                4294966272,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7340031,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffff9,\n                u32::MAX,\n                4294967103,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4095,\n                0,\n                1310720,\n                0,\n                0,\n                0,\n                0,\n                4294443008,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2818572287,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2048,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294963968,\n                u32::MAX,\n                4294918143,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffff,\n                0,\n                603979776,\n                0,\n                0,\n                0,\n                0,\n                0xf0000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                239,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x100000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4293394432,\n                u32::MAX,\n                4286578687,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3fffffff,\n                0,\n                0,\n                64,\n                0,\n                0,\n                0,\n                0,\n                4294967264,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                81919,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x20000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3556769792,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                127,\n                0,\n                0x7000,\n                0,\n                0,\n                0,\n                0,\n                4294950912,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                25165823,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967216,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xffff,\n                0,\n                12582912,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fffffff,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294930432,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1ffffff,\n                0,\n                0x40000000,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                256,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xff000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3,\n                0,\n                512,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x40000000,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2047,\n                0,\n                196608,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966528,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0x4000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294639616,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffffff,\n                0,\n                0,\n                4,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4160749568,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                63,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffff4,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffff000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfff00000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1024,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x80000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x10000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                32,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x4000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x800000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n            ],\n        );\n        // - bits != 0 and Barrett division in limbs_div_to_out_balanced\n        test(\n            &[10; 1401],\n            &[123; 2800],\n            &[456; 1410],\n            &[\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565,\n                2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461,\n                226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372,\n                3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551,\n                904203641, 1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192,\n                2486560013, 1130254551, 904203641, 1582356372, 3842865475, 1356305461, 226050910,\n                3616814565, 2034458192, 2486560013, 1130254551, 904203641, 1582356372, 3842865475,\n                1356305461, 226050910, 3616814565, 2034458192, 2486560013, 1130254551, 904203641,\n                1582356372, 3842865475, 1356305461, 226050910, 3616814565, 2034458192, 2486560013,\n                1130254551, 904203641, 1582356372, 1158510915, 0, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10,\n            ],\n        );\n        // - bits == 0 and Barrett division in limbs_div_to_out_balanced\n        let mut ds = vec![0; 1409];\n        ds.push(u32::MAX);\n        test(\n            &[10; 1401],\n            &[123; 2800],\n            &ds,\n            &[\n                170970, 170847, 170724, 170601, 170478, 170355, 170232, 170109, 169986, 169863,\n                169740, 169617, 169494, 169371, 169248, 169125, 169002, 168879, 168756, 168633,\n                168510, 168387, 168264, 168141, 168018, 167895, 167772, 167649, 167526, 167403,\n                167280, 167157, 167034, 166911, 166788, 166665, 166542, 166419, 166296, 166173,\n                166050, 165927, 165804, 165681, 165558, 165435, 165312, 165189, 165066, 164943,\n                164820, 164697, 164574, 164451, 164328, 164205, 164082, 163959, 163836, 163713,\n                163590, 163467, 163344, 163221, 163098, 162975, 162852, 162729, 162606, 162483,\n                162360, 162237, 162114, 161991, 161868, 161745, 161622, 161499, 161376, 161253,\n                161130, 161007, 160884, 160761, 160638, 160515, 160392, 160269, 160146, 160023,\n                159900, 159777, 159654, 159531, 159408, 159285, 159162, 159039, 158916, 158793,\n                158670, 158547, 158424, 158301, 158178, 158055, 157932, 157809, 157686, 157563,\n                157440, 157317, 157194, 157071, 156948, 156825, 156702, 156579, 156456, 156333,\n                156210, 156087, 155964, 155841, 155718, 155595, 155472, 155349, 155226, 155103,\n                154980, 154857, 154734, 154611, 154488, 154365, 154242, 154119, 153996, 153873,\n                153750, 153627, 153504, 153381, 153258, 153135, 153012, 152889, 152766, 152643,\n                152520, 152397, 152274, 152151, 152028, 151905, 151782, 151659, 151536, 151413,\n                151290, 151167, 151044, 150921, 150798, 150675, 150552, 150429, 150306, 150183,\n                150060, 149937, 149814, 149691, 149568, 149445, 149322, 149199, 149076, 148953,\n                148830, 148707, 148584, 148461, 148338, 148215, 148092, 147969, 147846, 147723,\n                147600, 147477, 147354, 147231, 147108, 146985, 146862, 146739, 146616, 146493,\n                146370, 146247, 146124, 146001, 145878, 145755, 145632, 145509, 145386, 145263,\n                145140, 145017, 144894, 144771, 144648, 144525, 144402, 144279, 144156, 144033,\n                143910, 143787, 143664, 143541, 143418, 143295, 143172, 143049, 142926, 142803,\n                142680, 142557, 142434, 142311, 142188, 142065, 141942, 141819, 141696, 141573,\n                141450, 141327, 141204, 141081, 140958, 140835, 140712, 140589, 140466, 140343,\n                140220, 140097, 139974, 139851, 139728, 139605, 139482, 139359, 139236, 139113,\n                138990, 138867, 138744, 138621, 138498, 138375, 138252, 138129, 138006, 137883,\n                137760, 137637, 137514, 137391, 137268, 137145, 137022, 136899, 136776, 136653,\n                136530, 136407, 136284, 136161, 136038, 135915, 135792, 135669, 135546, 135423,\n                135300, 135177, 135054, 134931, 134808, 134685, 134562, 134439, 134316, 134193,\n                134070, 133947, 133824, 133701, 133578, 133455, 133332, 133209, 133086, 132963,\n                132840, 132717, 132594, 132471, 132348, 132225, 132102, 131979, 131856, 131733,\n                131610, 131487, 131364, 131241, 131118, 130995, 130872, 130749, 130626, 130503,\n                130380, 130257, 130134, 130011, 129888, 129765, 129642, 129519, 129396, 129273,\n                129150, 129027, 128904, 128781, 128658, 128535, 128412, 128289, 128166, 128043,\n                127920, 127797, 127674, 127551, 127428, 127305, 127182, 127059, 126936, 126813,\n                126690, 126567, 126444, 126321, 126198, 126075, 125952, 125829, 125706, 125583,\n                125460, 125337, 125214, 125091, 124968, 124845, 124722, 124599, 124476, 124353,\n                124230, 124107, 123984, 123861, 123738, 123615, 123492, 123369, 123246, 123123,\n                123000, 122877, 122754, 122631, 122508, 122385, 122262, 122139, 122016, 121893,\n                121770, 121647, 121524, 121401, 121278, 121155, 121032, 120909, 120786, 120663,\n                120540, 120417, 120294, 120171, 120048, 119925, 119802, 119679, 119556, 119433,\n                119310, 119187, 119064, 118941, 118818, 118695, 118572, 118449, 118326, 118203,\n                118080, 117957, 117834, 117711, 117588, 117465, 117342, 117219, 117096, 116973,\n                116850, 116727, 116604, 116481, 116358, 116235, 116112, 115989, 115866, 115743,\n                115620, 115497, 115374, 115251, 115128, 115005, 114882, 114759, 114636, 114513,\n                114390, 114267, 114144, 114021, 113898, 113775, 113652, 113529, 113406, 113283,\n                113160, 113037, 112914, 112791, 112668, 112545, 112422, 112299, 112176, 112053,\n                111930, 111807, 111684, 111561, 111438, 111315, 111192, 111069, 110946, 110823,\n                110700, 110577, 110454, 110331, 110208, 110085, 109962, 109839, 109716, 109593,\n                109470, 109347, 109224, 109101, 108978, 108855, 108732, 108609, 108486, 108363,\n                108240, 108117, 107994, 107871, 107748, 107625, 107502, 107379, 107256, 107133,\n                107010, 106887, 106764, 106641, 106518, 106395, 106272, 106149, 106026, 105903,\n                105780, 105657, 105534, 105411, 105288, 105165, 105042, 104919, 104796, 104673,\n                104550, 104427, 104304, 104181, 104058, 103935, 103812, 103689, 103566, 103443,\n                103320, 103197, 103074, 102951, 102828, 102705, 102582, 102459, 102336, 102213,\n                102090, 101967, 101844, 101721, 101598, 101475, 101352, 101229, 101106, 100983,\n                100860, 100737, 100614, 100491, 100368, 100245, 100122, 99999, 99876, 99753, 99630,\n                99507, 99384, 99261, 99138, 99015, 98892, 98769, 98646, 98523, 98400, 98277, 98154,\n                98031, 97908, 97785, 97662, 97539, 97416, 97293, 97170, 97047, 96924, 96801, 96678,\n                96555, 96432, 96309, 96186, 96063, 95940, 95817, 95694, 95571, 95448, 95325, 95202,\n                95079, 94956, 94833, 94710, 94587, 94464, 94341, 94218, 94095, 93972, 93849, 93726,\n                93603, 93480, 93357, 93234, 93111, 92988, 92865, 92742, 92619, 92496, 92373, 92250,\n                92127, 92004, 91881, 91758, 91635, 91512, 91389, 91266, 91143, 91020, 90897, 90774,\n                90651, 90528, 90405, 90282, 90159, 90036, 89913, 89790, 89667, 89544, 89421, 89298,\n                89175, 89052, 88929, 88806, 88683, 88560, 88437, 88314, 88191, 88068, 87945, 87822,\n                87699, 87576, 87453, 87330, 87207, 87084, 86961, 86838, 86715, 86592, 86469, 86346,\n                86223, 86100, 85977, 85854, 85731, 85608, 85485, 85362, 85239, 85116, 84993, 84870,\n                84747, 84624, 84501, 84378, 84255, 84132, 84009, 83886, 83763, 83640, 83517, 83394,\n                83271, 83148, 83025, 82902, 82779, 82656, 82533, 82410, 82287, 82164, 82041, 81918,\n                81795, 81672, 81549, 81426, 81303, 81180, 81057, 80934, 80811, 80688, 80565, 80442,\n                80319, 80196, 80073, 79950, 79827, 79704, 79581, 79458, 79335, 79212, 79089, 78966,\n                78843, 78720, 78597, 78474, 78351, 78228, 78105, 77982, 77859, 77736, 77613, 77490,\n                77367, 77244, 77121, 76998, 76875, 76752, 76629, 76506, 76383, 76260, 76137, 76014,\n                75891, 75768, 75645, 75522, 75399, 75276, 75153, 75030, 74907, 74784, 74661, 74538,\n                74415, 74292, 74169, 74046, 73923, 73800, 73677, 73554, 73431, 73308, 73185, 73062,\n                72939, 72816, 72693, 72570, 72447, 72324, 72201, 72078, 71955, 71832, 71709, 71586,\n                71463, 71340, 71217, 71094, 70971, 70848, 70725, 70602, 70479, 70356, 70233, 70110,\n                69987, 69864, 69741, 69618, 69495, 69372, 69249, 69126, 69003, 68880, 68757, 68634,\n                68511, 68388, 68265, 68142, 68019, 67896, 67773, 67650, 67527, 67404, 67281, 67158,\n                67035, 66912, 66789, 66666, 66543, 66420, 66297, 66174, 66051, 65928, 65805, 65682,\n                65559, 65436, 65313, 65190, 65067, 64944, 64821, 64698, 64575, 64452, 64329, 64206,\n                64083, 63960, 63837, 63714, 63591, 63468, 63345, 63222, 63099, 62976, 62853, 62730,\n                62607, 62484, 62361, 62238, 62115, 61992, 61869, 61746, 61623, 61500, 61377, 61254,\n                61131, 61008, 60885, 60762, 60639, 60516, 60393, 60270, 60147, 60024, 59901, 59778,\n                59655, 59532, 59409, 59286, 59163, 59040, 58917, 58794, 58671, 58548, 58425, 58302,\n                58179, 58056, 57933, 57810, 57687, 57564, 57441, 57318, 57195, 57072, 56949, 56826,\n                56703, 56580, 56457, 56334, 56211, 56088, 55965, 55842, 55719, 55596, 55473, 55350,\n                55227, 55104, 54981, 54858, 54735, 54612, 54489, 54366, 54243, 54120, 53997, 53874,\n                53751, 53628, 53505, 53382, 53259, 53136, 53013, 52890, 52767, 52644, 52521, 52398,\n                52275, 52152, 52029, 51906, 51783, 51660, 51537, 51414, 51291, 51168, 51045, 50922,\n                50799, 50676, 50553, 50430, 50307, 50184, 50061, 49938, 49815, 49692, 49569, 49446,\n                49323, 49200, 49077, 48954, 48831, 48708, 48585, 48462, 48339, 48216, 48093, 47970,\n                47847, 47724, 47601, 47478, 47355, 47232, 47109, 46986, 46863, 46740, 46617, 46494,\n                46371, 46248, 46125, 46002, 45879, 45756, 45633, 45510, 45387, 45264, 45141, 45018,\n                44895, 44772, 44649, 44526, 44403, 44280, 44157, 44034, 43911, 43788, 43665, 43542,\n                43419, 43296, 43173, 43050, 42927, 42804, 42681, 42558, 42435, 42312, 42189, 42066,\n                41943, 41820, 41697, 41574, 41451, 41328, 41205, 41082, 40959, 40836, 40713, 40590,\n                40467, 40344, 40221, 40098, 39975, 39852, 39729, 39606, 39483, 39360, 39237, 39114,\n                38991, 38868, 38745, 38622, 38499, 38376, 38253, 38130, 38007, 37884, 37761, 37638,\n                37515, 37392, 37269, 37146, 37023, 36900, 36777, 36654, 36531, 36408, 36285, 36162,\n                36039, 35916, 35793, 35670, 35547, 35424, 35301, 35178, 35055, 34932, 34809, 34686,\n                34563, 34440, 34317, 34194, 34071, 33948, 33825, 33702, 33579, 33456, 33333, 33210,\n                33087, 32964, 32841, 32718, 32595, 32472, 32349, 32226, 32103, 31980, 31857, 31734,\n                31611, 31488, 31365, 31242, 31119, 30996, 30873, 30750, 30627, 30504, 30381, 30258,\n                30135, 30012, 29889, 29766, 29643, 29520, 29397, 29274, 29151, 29028, 28905, 28782,\n                28659, 28536, 28413, 28290, 28167, 28044, 27921, 27798, 27675, 27552, 27429, 27306,\n                27183, 27060, 26937, 26814, 26691, 26568, 26445, 26322, 26199, 26076, 25953, 25830,\n                25707, 25584, 25461, 25338, 25215, 25092, 24969, 24846, 24723, 24600, 24477, 24354,\n                24231, 24108, 23985, 23862, 23739, 23616, 23493, 23370, 23247, 23124, 23001, 22878,\n                22755, 22632, 22509, 22386, 22263, 22140, 22017, 21894, 21771, 21648, 21525, 21402,\n                21279, 21156, 21033, 20910, 20787, 20664, 20541, 20418, 20295, 20172, 20049, 19926,\n                19803, 19680, 19557, 19434, 19311, 19188, 19065, 18942, 18819, 18696, 18573, 18450,\n                18327, 18204, 18081, 17958, 17835, 17712, 17589, 17466, 17343, 17220, 17097, 16974,\n                16851, 16728, 16605, 16482, 16359, 16236, 16113, 15990, 15867, 15744, 15621, 15498,\n                15375, 15252, 15129, 15006, 14883, 14760, 14637, 14514, 14391, 14268, 14145, 14022,\n                13899, 13776, 13653, 13530, 13407, 13284, 13161, 13038, 12915, 12792, 12669, 12546,\n                12423, 12300, 12177, 12054, 11931, 11808, 11685, 11562, 11439, 11316, 11193, 11070,\n                10947, 10824, 10701, 10578, 10455, 10332, 10209, 10086, 9963, 9840, 9717, 9594,\n                9471, 9348, 9225, 9102, 8979, 8856, 8733, 8610, 8487, 8364, 8241, 8118, 7995, 7872,\n                7749, 7626, 7503, 7380, 7257, 7134, 7011, 6888, 6765, 6642, 6519, 6396, 6273, 6150,\n                6027, 5904, 5781, 5658, 5535, 5412, 5289, 5166, 5043, 4920, 4797, 4674, 4551, 4428,\n                4305, 4182, 4059, 3936, 3813, 3690, 3567, 3444, 3321, 3198, 3075, 2952, 2829, 2706,\n                2583, 2460, 2337, 2214, 2091, 1968, 1845, 1722, 1599, 1476, 1353, 1230, 1107, 984,\n                861, 738, 615, 492, 369, 246, 123, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - bits != 0 and Barrett division in limbs_div_to_out_unbalanced\n        test(\n            &[10; 1770],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3758096384,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffffc,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                461373439,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                128,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967024,\n                u32::MAX,\n                4294945791,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2047,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1ffff,\n                0,\n                54525952,\n                0,\n                402653184,\n                0,\n                0,\n                0xff000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                44,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x10000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294836224,\n                u32::MAX,\n                4287102975,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4026531839,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3ffffff,\n                0,\n                0,\n                6,\n                0,\n                16,\n                0,\n                0,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                18431,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x2000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4232052736,\n                u32::MAX,\n                1610612735,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7,\n                0,\n                2816,\n                0,\n                0,\n                0,\n                0,\n                4294966272,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7340031,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffff9,\n                u32::MAX,\n                4294967103,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4095,\n                0,\n                1310720,\n                0,\n                0,\n                0,\n                0,\n                4294443008,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2818572287,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2048,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294963968,\n                u32::MAX,\n                4294918143,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffff,\n                0,\n                603979776,\n                0,\n                0,\n                0,\n                0,\n                0xf0000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                239,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x100000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4293394432,\n                u32::MAX,\n                4286578687,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x3fffffff,\n                0,\n                0,\n                64,\n                0,\n                0,\n                0,\n                0,\n                4294967264,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                81919,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x20000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3556769792,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                127,\n                0,\n                0x7000,\n                0,\n                0,\n                0,\n                0,\n                4294950912,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                25165823,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967216,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xffff,\n                0,\n                12582912,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fffffff,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294930432,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1ffffff,\n                0,\n                0x40000000,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                256,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xff000000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3,\n                0,\n                512,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x40000000,\n                u32::MAX - 1,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2047,\n                0,\n                196608,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966528,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xfffff,\n                0,\n                0x4000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294639616,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x1fffffff,\n                0,\n                0,\n                4,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4160749568,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                63,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffffff4,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0x7fff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfffff000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0xffffff,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0xfff00000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1024,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x80000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x10000000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                32,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x4000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0x800000,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[10; 519],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1,\n            ],\n        );\n        // - r_len > n_len || limbs_cmp_same_length(ns, &rs[..n_len]) == Less in\n        //   limbs_div_to_out_balanced\n        test(\n            &[10; 5],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709535232,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                u64::MAX,\n                u64::MAX,\n                0xfffffff,\n                0,\n                0,\n                18446744073709550592,\n                u64::MAX,\n                0x1ffffffff,\n                0,\n                0,\n                0,\n                18446744073709551488,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[127, 0, 0, 0, 1],\n        );\n        test(\n            &[10; 4],\n            &[\n                18446463148488654849,\n                280925229285374,\n                16285016218270955520,\n                37348968499195,\n                18437754466102935552,\n                4286578943,\n            ],\n            &[280925220896767, 18446744073701163008, 34292631551],\n            &[u64::MAX, 0, 2305843009213431808, 0],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_fail_1() {\n    limbs_div(&[1, 2, 3], &[4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_fail_2() {\n    limbs_div(&[1], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_fail_3() {\n    limbs_div(&[1, 2, 3], &[4, 0]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_fail_1() {\n    limbs_div_to_out(&mut [10; 4], &mut [1, 2, 3], &mut [4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_fail_2() {\n    limbs_div_to_out(&mut [10; 4], &mut [1], &mut [4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_fail_3() {\n    limbs_div_to_out(&mut [10], &mut [1, 2, 3, 4], &mut [4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_fail_4() {\n    limbs_div_to_out(&mut [10; 4], &mut [1, 2, 3], &mut [4, 0]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_val_ref_fail_1() {\n    limbs_div_to_out_val_ref(&mut [10; 4], &mut [1, 2, 3], &[4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_val_ref_fail_2() {\n    limbs_div_to_out_val_ref(&mut [10; 4], &mut [1], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_val_ref_fail_3() {\n    limbs_div_to_out_val_ref(&mut [10], &mut [1, 2, 3, 4], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_val_ref_fail_4() {\n    limbs_div_to_out_val_ref(&mut [10; 4], &mut [1, 2, 3], &[4, 0]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_val_fail_1() {\n    limbs_div_to_out_ref_val(&mut [10; 4], &[1, 2, 3], &mut [4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_val_fail_2() {\n    limbs_div_to_out_ref_val(&mut [10; 4], &[1], &mut [4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_val_fail_3() {\n    limbs_div_to_out_ref_val(&mut [10], &[1, 2, 3, 4], &mut [4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_val_fail_4() {\n    limbs_div_to_out_ref_val(&mut [10; 4], &[1, 2, 3], &mut [4, 0]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_ref_fail_1() {\n    limbs_div_to_out_ref_ref(&mut [10; 4], &[1, 2, 3], &[4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_ref_fail_2() {\n    limbs_div_to_out_ref_ref(&mut [10; 4], &[1], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_ref_fail_3() {\n    limbs_div_to_out_ref_ref(&mut [10], &[1, 2, 3, 4], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_to_out_ref_ref_fail_4() {\n    limbs_div_to_out_ref_ref(&mut [10; 4], &[1, 2, 3], &[4, 0]);\n}\n\n#[test]\nfn test_div() {\n    let test = |s, t, quotient| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x /= v.clone();\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        x /= &v;\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let q = u.clone() / v.clone();\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.clone() / &v;\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = &u / v.clone();\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = &u / &v;\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = BigUint::from_str(s).unwrap() / &BigUint::from_str(t).unwrap();\n        assert_eq!(q.to_string(), quotient);\n\n        let q = rug::Integer::from_str(s).unwrap() / rug::Integer::from_str(t).unwrap();\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.div_mod(v).0;\n        assert_eq!(q.to_string(), quotient);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"1\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"123\", \"1\");\n    test(\"123\", \"456\", \"0\");\n    test(\"456\", \"123\", \"3\");\n    test(\"4294967295\", \"1\", \"4294967295\");\n    test(\"4294967295\", \"4294967295\", \"1\");\n    test(\"1000000000000\", \"1\", \"1000000000000\");\n    test(\"1000000000000\", \"3\", \"333333333333\");\n    test(\"1000000000000\", \"123\", \"8130081300\");\n    test(\"1000000000000\", \"4294967295\", \"232\");\n    test(\n        \"1000000000000000000000000\",\n        \"1\",\n        \"1000000000000000000000000\",\n    );\n    test(\"1000000000000000000000000\", \"3\", \"333333333333333333333333\");\n    test(\"1000000000000000000000000\", \"123\", \"8130081300813008130081\");\n    test(\"1000000000000000000000000\", \"4294967295\", \"232830643708079\");\n    test(\"1000000000000000000000000\", \"1234567890987\", \"810000006723\");\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"94998781946290113\",\n    );\n    test(\"3768477692975601\", \"11447376614057827956\", \"0\");\n    test(\"3356605361737854\", \"3081095617839357\", \"1\");\n    test(\"1098730198198174614195\", \"953382298040157850476\", \"1\");\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"1\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"0\");\n    test(\n        \"915607705283450388306561139234228660872677067256472842161753852459689688332903348325308112\\\n        7923093090598913\",\n        \"11669177832462215441614364516705357863717491965951\",\n        \"784637716923245892498679555408392159158150581185689944063\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn div_assign_fail_1() {\n    let mut x = Natural::from(10u32);\n    x /= Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_fail_2() {\n    let mut x = Natural::ZERO;\n    x /= Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_ref_fail_1() {\n    let mut x = Natural::from(10u32);\n    x /= &Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_ref_fail_2() {\n    let mut x = Natural::ZERO;\n    x /= &Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_fail_1() {\n    Natural::from(10u32) / Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)]\nfn div_fail_2() {\n    Natural::ZERO / Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_val_ref_fail_1() {\n    Natural::from(10u32) / &Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)]\nfn div_val_ref_fail_2() {\n    Natural::ZERO / &Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_ref_val_fail_1() {\n    &Natural::from(10u32) / Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)]\nfn div_ref_val_fail_2() {\n    &Natural::ZERO / Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn div_ref_ref_fail_1() {\n    &Natural::from(10u32) / &Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)]\nfn div_ref_ref_fail_2() {\n    &Natural::ZERO / &Natural::ZERO;\n}\n\n#[test]\nfn test_checked_div() {\n    let test = |s, t, quotient| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let q = u.clone().checked_div(v.clone());\n        assert!(q.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = u.clone().checked_div(&v);\n        assert!(q.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = (&u).checked_div(v.clone());\n        assert!(q.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = (&u).checked_div(&v);\n        assert!(q.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(q.to_debug_string(), quotient);\n\n        let q = BigUint::from_str(s)\n            .unwrap()\n            .checked_div(&BigUint::from_str(t).unwrap());\n        assert_eq!(q.to_debug_string(), quotient);\n    };\n    test(\"0\", \"1\", \"Some(0)\");\n    test(\"0\", \"123\", \"Some(0)\");\n    test(\"1\", \"1\", \"Some(1)\");\n    test(\"123\", \"1\", \"Some(123)\");\n    test(\"123\", \"123\", \"Some(1)\");\n    test(\"123\", \"456\", \"Some(0)\");\n    test(\"456\", \"123\", \"Some(3)\");\n    test(\"4294967295\", \"1\", \"Some(4294967295)\");\n    test(\"4294967295\", \"4294967295\", \"Some(1)\");\n    test(\"1000000000000\", \"1\", \"Some(1000000000000)\");\n    test(\"1000000000000\", \"3\", \"Some(333333333333)\");\n    test(\"1000000000000\", \"123\", \"Some(8130081300)\");\n    test(\"1000000000000\", \"4294967295\", \"Some(232)\");\n    test(\"0\", \"0\", \"None\");\n    test(\"1\", \"0\", \"None\");\n    test(\"123\", \"0\", \"None\");\n    test(\"1000000000000000000000000\", \"0\", \"None\");\n}\n\n#[test]\nfn limbs_div_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_div_limb_in_place(&mut xs, y);\n        let out = xs.clone();\n        let q = Natural::from_limbs_asc(&old_xs) / Natural::from(y);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), q);\n        let mut xs = old_xs.clone();\n        limbs_div_limb_in_place_alt(&mut xs, y);\n        assert_eq!(xs, out);\n        assert_eq!(Natural::from_owned_limbs_asc(limbs_div_limb(&old_xs, y)), q);\n    });\n}\n\n#[test]\nfn limbs_div_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_div_limb_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            assert_eq!(\n                Natural::from_limbs_asc(&out[..len]),\n                Natural::from_limbs_asc(&xs) / Natural::from(y)\n            );\n            assert_eq!(&out[len..], &old_out[len..]);\n            let mut out_alt = old_out;\n            limbs_div_limb_to_out_alt(&mut out_alt, &xs, y);\n            assert_eq!(out, out_alt);\n        },\n    );\n}\n\n#[test]\nfn limbs_div_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_div_limb_in_place(&mut xs, y);\n        let out = xs.clone();\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_limbs_asc(&old_xs) / Natural::from(y)\n        );\n        let mut xs = old_xs;\n        limbs_div_limb_in_place_alt(&mut xs, y);\n        assert_eq!(xs, out);\n    });\n}\n\n#[test]\nfn limbs_div_divisor_of_limb_max_with_carry_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_10().test_properties_with_config(\n        &config,\n        |(mut out, xs, divisor, carry)| {\n            // TODO figure out what to test\n            limbs_div_divisor_of_limb_max_with_carry_to_out::<DoubleLimb, Limb>(\n                &mut out, &xs, divisor, carry,\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_div_divisor_of_limb_max_with_carry_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_9().test_properties_with_config(\n        &config,\n        |(mut xs, divisor, carry)| {\n            // TODO figure out what to test\n            limbs_div_divisor_of_limb_max_with_carry_in_place(&mut xs, divisor, carry);\n        },\n    );\n}\n\n#[test]\nfn limbs_div_schoolbook_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_11().test_properties_with_config(&config, |(qs_in, ns_in, ds, inverse)| {\n        let mut qs = qs_in.clone();\n        let mut ns = ns_in.clone();\n        let q_highest = limbs_div_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        verify_limbs_div(&qs_in, &ns_in, &ds, q_highest, &qs);\n    });\n}\n\n#[test]\nfn limbs_div_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_12().test_properties_with_config(&config, |(qs_in, ns, ds, inverse)| {\n        let mut qs = qs_in.clone();\n        let q_highest = limbs_div_divide_and_conquer(&mut qs, &ns, &ds, inverse);\n        verify_limbs_div(&qs_in, &ns, &ds, q_highest, &qs);\n    });\n}\n\n#[test]\nfn limbs_div_barrett_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 128 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_43().test_properties_with_config(&config, |(qs_in, ns, ds)| {\n        let mut qs = qs_in.clone();\n        let mut scratch = vec![0; limbs_div_barrett_scratch_len(ns.len(), ds.len())];\n        let q_highest = limbs_div_barrett(&mut qs, &ns, &ds, &mut scratch);\n        verify_limbs_div(&qs_in, &ns, &ds, q_highest, &qs);\n    });\n}\n\n#[test]\nfn limbs_div_schoolbook_approx_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_11().test_properties_with_config(&config, |(qs_in, ns_in, ds, inverse)| {\n        let mut qs = qs_in.clone();\n        let mut ns = ns_in.clone();\n        let q_highest = limbs_div_schoolbook_approx(&mut qs, &mut ns, &ds, inverse);\n        verify_limbs_div_approx(&qs_in, &ns_in, &ds, q_highest, &qs);\n    });\n}\n\n#[test]\nfn limbs_div_divide_and_conquer_approx_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    large_type_gen_var_12().test_properties_with_config(&config, |(qs_in, ns_in, ds, inverse)| {\n        let mut qs = qs_in.clone();\n        let mut ns = ns_in.clone();\n        let q_highest = limbs_div_divide_and_conquer_approx(&mut qs, &mut ns, &ds, inverse);\n        verify_limbs_div_approx(&qs_in, &ns_in, &ds, q_highest, &qs);\n    });\n}\n\n#[test]\nfn limbs_div_barrett_approx_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 128 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_42().test_properties_with_config(&config, |(qs_in, ns, ds)| {\n        let mut qs = qs_in.clone();\n        let mut scratch = vec![0; limbs_div_barrett_approx_scratch_len(ns.len(), ds.len())];\n        let q_highest = limbs_div_barrett_approx(&mut qs, &ns, &ds, &mut scratch);\n        verify_limbs_div_approx_2(&qs_in, &ns, &ds, q_highest, &qs);\n    });\n}\n\n#[test]\nfn limbs_div_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 128 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_44().test_properties_with_config(&config, |(qs_in, ns, ds)| {\n        let mut qs = qs_in.clone();\n        limbs_div_to_out_ref_ref(&mut qs, &ns, &ds);\n        verify_limbs_div_2(&qs_in, &ns, &ds, &qs);\n        let qs_out = qs;\n\n        let mut qs = qs_in.clone();\n        let mut ns_cloned = ns.clone();\n        let mut ds_cloned = ds.clone();\n        limbs_div_to_out(&mut qs, &mut ns_cloned, &mut ds_cloned);\n        assert_eq!(qs, qs_out);\n\n        let mut qs = qs_in.clone();\n        let mut ns_cloned = ns.clone();\n        limbs_div_to_out_val_ref(&mut qs, &mut ns_cloned, &ds);\n        assert_eq!(qs, qs_out);\n\n        let mut qs = qs_in;\n        let mut ds_cloned = ds.clone();\n        limbs_div_to_out_ref_val(&mut qs, &ns, &mut ds_cloned);\n        assert_eq!(qs, qs_out);\n\n        let qs = limbs_div(&ns, &ds);\n        let qs: &[Limb] = &qs;\n        assert_eq!(&qs_out[..qs.len()], qs);\n    });\n}\n\n// It would be a little confusing to only pass y by value\n#[allow(clippy::needless_pass_by_value)]\nfn div_properties_helper(x: Natural, y: Natural) {\n    let mut mut_x = x.clone();\n    mut_x /= &y;\n    assert!(mut_x.is_valid());\n    let q = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x /= y.clone();\n    let q_alt = mut_x;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = &x / &y;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = &x / y.clone();\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = x.clone() / &y;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    let q_alt = x.clone() / y.clone();\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n\n    assert_eq!((&x).checked_div(&y).unwrap(), q);\n\n    let q_alt = (&x).div_mod(&y).0;\n    assert_eq!(q_alt, q);\n\n    let num_q = BigUint::from(&x) / &BigUint::from(&y);\n    assert_eq!(Natural::from(&num_q), q);\n\n    let rug_q = rug::Integer::from(&x) / rug::Integer::from(&y);\n    assert_eq!(Natural::exact_from(&rug_q), q);\n\n    let r = &x - &q * &y;\n    assert!(r < y);\n    assert_eq!(q * y + r, x);\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn div_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 256 << Limb::LOG_WIDTH);\n    natural_pair_gen_var_5().test_properties_with_config(&config, |(x, y)| {\n        div_properties_helper(x, y);\n    });\n\n    natural_pair_gen_var_6().test_properties_with_config(&config, |(x, y)| {\n        div_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(&n / Natural::ONE, n);\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(&n / &n, 1);\n        assert_eq!(Natural::ZERO / &n, Natural::ZERO);\n        if n > 1 {\n            assert_eq!(Natural::ONE / n, Natural::ZERO);\n        }\n    });\n\n    unsigned_pair_gen_var_12::<Limb, Limb>()\n        .test_properties(|(x, y)| assert_eq!(Natural::from(x) / Natural::from(y), x / y));\n}\n\n#[test]\nfn checked_div_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let quotient_val_val = x.clone().checked_div(y.clone());\n        let quotient_val_ref = x.clone().checked_div(&y);\n        let quotient_ref_val = (&x).checked_div(y.clone());\n        let quotient = (&x).checked_div(&y);\n        assert!(quotient_val_val.as_ref().is_none_or(Natural::is_valid));\n        assert!(quotient_val_ref.as_ref().is_none_or(Natural::is_valid));\n        assert!(quotient_ref_val.as_ref().is_none_or(Natural::is_valid));\n        assert!(quotient.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(quotient_val_val, quotient);\n        assert_eq!(quotient_val_ref, quotient);\n        assert_eq!(quotient_ref_val, quotient);\n\n        if y != 0u32 {\n            assert_eq!(quotient, Some(&x / &y));\n        }\n\n        assert_eq!(\n            BigUint::from(&x)\n                .checked_div(&BigUint::from(&y))\n                .map(|n| Natural::from(&n)),\n            quotient\n        );\n    });\n\n    natural_gen().test_properties(|ref x| {\n        assert_eq!(x.checked_div(Natural::ZERO), None);\n        assert_eq!(x.checked_div(Natural::ONE), Some(x.clone()));\n    });\n\n    natural_gen_var_2().test_properties(|ref x| {\n        assert_eq!(Natural::ZERO.checked_div(x), Some(Natural::ZERO));\n        assert_eq!(Natural::ONE.checked_div(x), Some(Natural::from(*x == 1u32)));\n        assert_eq!(x.checked_div(x), Some(Natural::ONE));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/div_exact.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    DivExact, DivExactAssign, DivMod, DivRound, EqModPowerOf2, ModPowerOf2, ModPowerOf2Neg,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::common::rle_decode;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_22, unsigned_pair_gen_var_11, unsigned_vec_pair_gen_var_12,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::arithmetic::div_exact::{\n    limbs_div_exact, limbs_div_exact_3, limbs_div_exact_3_in_place, limbs_div_exact_3_to_out,\n    limbs_div_exact_limb, limbs_div_exact_limb_in_place,\n    limbs_div_exact_limb_in_place_no_special_3, limbs_div_exact_limb_no_special_3,\n    limbs_div_exact_limb_to_out, limbs_div_exact_limb_to_out_no_special_3, limbs_div_exact_to_out,\n    limbs_div_exact_to_out_ref_ref, limbs_div_exact_to_out_ref_val, limbs_div_exact_to_out_val_ref,\n    limbs_modular_div, limbs_modular_div_barrett, limbs_modular_div_barrett_scratch_len,\n    limbs_modular_div_divide_and_conquer, limbs_modular_div_mod_barrett,\n    limbs_modular_div_mod_barrett_scratch_len, limbs_modular_div_mod_divide_and_conquer,\n    limbs_modular_div_mod_schoolbook, limbs_modular_div_ref, limbs_modular_div_ref_scratch_len,\n    limbs_modular_div_schoolbook, limbs_modular_div_schoolbook_in_place,\n    limbs_modular_div_scratch_len, limbs_modular_invert, limbs_modular_invert_limb,\n    limbs_modular_invert_scratch_len, test_invert_limb_table,\n};\nuse malachite_nz::natural::{Natural, limb_to_bit_count};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_13, large_type_gen_var_14, large_type_gen_var_15, large_type_gen_var_16,\n    natural_gen, natural_gen_var_2, natural_pair_gen_var_6, unsigned_vec_gen_var_5,\n    unsigned_vec_pair_gen_var_13, unsigned_vec_quadruple_gen_var_2, unsigned_vec_triple_gen_var_46,\n    unsigned_vec_triple_gen_var_47, unsigned_vec_triple_gen_var_48,\n    unsigned_vec_unsigned_pair_gen_var_29, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14,\n};\nuse malachite_nz::test_util::natural::arithmetic::div_exact::{\n    limbs_div_exact_3_in_place_alt, limbs_div_exact_3_to_out_alt,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_test_invert_limb_table() {\n    test_invert_limb_table();\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_modular_invert_limb() {\n    let test = |x, inverse| {\n        assert_eq!(limbs_modular_invert_limb(x), inverse);\n    };\n    test(1, 1);\n    test(3, 2863311531);\n    test(5, 3435973837);\n    test(7, 3067833783);\n    test(123, 3945782963);\n    test(1000000001, 2211001857);\n    test(0x7fffffff, 0x7fffffff);\n    test(2863311531, 3);\n    test(u32::MAX, u32::MAX);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_invert_limb_fail_1() {\n    limbs_modular_invert_limb::<Limb>(0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_invert_limb_fail_2() {\n    limbs_modular_invert_limb::<Limb>(2);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_exact_limb_and_limbs_div_exact_limb_in_place() {\n    let test = |ns: &[Limb], d: Limb, q: &[Limb]| {\n        let ns_old = ns;\n        assert_eq!(limbs_div_exact_limb(ns_old, d), q);\n\n        let mut ns = ns_old.to_vec();\n        limbs_div_exact_limb_in_place(&mut ns, d);\n        assert_eq!(ns, q);\n\n        assert_eq!(limbs_div_exact_limb_no_special_3(ns_old, d), q);\n\n        let mut ns = ns_old.to_vec();\n        limbs_div_exact_limb_in_place_no_special_3(&mut ns, d);\n        assert_eq!(ns, q);\n    };\n    test(&[0], 2, &[0]);\n    test(&[6], 2, &[3]);\n    test(&[0, 0], 2, &[0, 0]);\n    test(&[6, 7], 1, &[6, 7]);\n    test(&[6, 7], 2, &[0x80000003, 3]);\n    test(&[92, 101, 102], 10, &[1288490198, 858993469, 10]);\n    test(&[4294966783, 455], 789, &[2482262467, 0]);\n    test(&[u32::MAX - 1, u32::MAX], 2, &[u32::MAX, 0x7fffffff]);\n    test(&[u32::MAX, u32::MAX], 3, &[0x55555555, 0x55555555]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_limb_fail_1() {\n    limbs_div_exact_limb(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_limb_fail_2() {\n    limbs_div_exact_limb(&[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_limb_in_place_fail_1() {\n    limbs_div_exact_limb_in_place(&mut [], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_limb_in_place_fail_2() {\n    limbs_div_exact_limb_in_place(&mut [10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_exact_limb_to_out() {\n    let test = |out_before: &[Limb], ns: &[Limb], d: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut out, ns, d);\n        assert_eq!(out, out_after);\n\n        let mut out = out_before.to_vec();\n        limbs_div_exact_limb_to_out_no_special_3::<DoubleLimb, Limb>(&mut out, ns, d);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[0], 2, &[0, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[6], 2, &[3, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[0, 0], 2, &[0, 0, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 1, &[6, 7, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, &[0x80000003, 3, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[92, 101, 102],\n        10,\n        &[1288490198, 858993469, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[4294966783, 455],\n        789,\n        &[2482262467, 0, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX - 1, u32::MAX],\n        2,\n        &[u32::MAX, 0x7fffffff, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, u32::MAX],\n        3,\n        &[0x55555555, 0x55555555, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_limb_to_out_fail_1() {\n    limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut [10, 10], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_limb_to_out_fail_2() {\n    limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut [10, 10], &[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_limb_to_out_fail_3() {\n    limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_exact_3_and_limbs_div_exact_3_in_place() {\n    let test = |ns: &[Limb], q: &[Limb]| {\n        let old_ns = ns;\n        assert_eq!(limbs_div_exact_3(ns), q);\n\n        assert_eq!(limbs_div_exact_limb(ns, 3), q);\n\n        let mut ns = old_ns.to_vec();\n        limbs_div_exact_3_in_place(&mut ns);\n        assert_eq!(ns, q);\n\n        let mut ns = old_ns.to_vec();\n        limbs_div_exact_3_in_place_alt(&mut ns);\n        assert_eq!(ns, q);\n\n        let mut ns = old_ns.to_vec();\n        limbs_div_exact_limb_in_place(&mut ns, 3);\n        assert_eq!(ns, q);\n    };\n    test(&[0], &[0]);\n    test(&[6], &[2]);\n    test(&[0, 0], &[0, 0]);\n    test(&[8, 7], &[1431655768, 2]);\n    test(&[100, 101, 102], &[2863311564, 33, 34]);\n    test(&[u32::MAX, u32::MAX], &[0x55555555, 0x55555555]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_3_fail() {\n    limbs_div_exact_3(&[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_3_in_place_fail() {\n    limbs_div_exact_3_in_place(&mut []);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_exact_3_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_div_exact_3_to_out::<DoubleLimb, Limb>(&mut out, xs);\n        assert_eq!(out, out_after);\n\n        let mut out = out_before.to_vec();\n        limbs_div_exact_3_to_out_alt(&mut out, xs);\n        assert_eq!(out, out_after);\n\n        let mut out = out_before.to_vec();\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut out, xs, 3);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[0], &[0, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[6], &[2, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[0, 0], &[0, 0, 10, 10]);\n    test(&[10, 10, 10, 10], &[8, 7], &[1431655768, 2, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        &[2863311564, 33, 34, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, u32::MAX],\n        &[0x55555555, 0x55555555, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_3_to_out_fail_1() {\n    limbs_div_exact_3_to_out::<DoubleLimb, Limb>(&mut [10, 10], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_3_to_out_fail_2() {\n    limbs_div_exact_3_to_out::<DoubleLimb, Limb>(&mut [10], &[10, 10]);\n}\n\nfn verify_limbs_modular_invert(ds: &[Limb], is: &[Limb]) {\n    let d = Natural::from_limbs_asc(ds);\n    let i = Natural::from_limbs_asc(is);\n    let pow = limb_to_bit_count(ds.len());\n    assert!((d * i).eq_mod_power_of_2(&Natural::ONE, pow));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_modular_invert() {\n    let test = |is_in: &[Limb], ds: &[Limb], is_out: &[Limb]| {\n        let n = ds.len();\n        let mut is = is_in.to_vec();\n        let mut scratch = vec![0; limbs_modular_invert_scratch_len(n)];\n        limbs_modular_invert(&mut is, ds, &mut scratch);\n        assert_eq!(&is[..n], is_out);\n        verify_limbs_modular_invert(ds, is_out);\n    };\n    // - rn < DC_BDIV_Q_THRESHOLD\n    test(&[10; 3], &[1], &[1]);\n    test(&[10; 3], &[3], &[2863311531]);\n    test(&[10; 3], &[5], &[3435973837]);\n    test(&[10; 3], &[7], &[3067833783]);\n    test(&[10; 3], &[1, 1, 1], &[1, u32::MAX, u32::MAX]);\n    test(&[10; 4], &[1, 2, 3, 4], &[1, u32::MAX - 1, 0, 0]);\n    test(&[10; 4], &[1, 0, 0, 0], &[1, 0, 0, 0]);\n    test(&[10; 4], &[u32::MAX; 4], &[u32::MAX; 4]);\n    // - rn >= DC_BDIV_Q_THRESHOLD\n    test(\n        &[10; 162],\n        &[\n            3228372949, 511037199, 1766844847, 2482988267, 1469636570, 157644737, 1548533671,\n            1988920387, 949768135, 3990423112, 2320976801, 2511643497, 3093682328, 3428374192,\n            1438878145, 2361210316, 3906032124, 2138110309, 1599933050, 3823943671, 2259360130,\n            823468722, 3291657189, 1273080994, 1300170623, 1148822796, 467501062, 3149282203,\n            94789064, 4211146202, 938886545, 537979797, 2587941131, 108323731, 2067107670,\n            105331677, 1935250512, 1452284826, 1800549345, 723680431, 2794168985, 904704921,\n            3016862976, 1287705882, 4132038308, 624608496, 1997184254, 448598152, 1820893106,\n            195416787, 651904977, 2955157364, 94342663, 437349382, 377636621, 3709576977,\n            1757632127, 4278237941, 34068629, 2454145994, 4156002276, 3961922656, 2767617077,\n            3288237973, 4240277740, 1356471757, 9181081, 1636990395, 1662834396, 626816820,\n            2875878941, 921881987, 2158368015, 840508787, 3305037379, 3711054769, 1268398179,\n            3896061030, 1052597619, 2040268853, 3162123944, 1619537254, 4260249983, 788774918,\n            323831598, 70896907, 791692982, 1081190864, 2374371095, 1425732171, 2496438238,\n            4066183598, 2164924109, 3370833658, 4001560838, 1910191661, 4219785120, 451095085,\n            3421655677, 2108533585, 3424568374, 2891875753, 3180562301, 954785991, 2447015474,\n            3930894331, 715625138, 2543510489, 360538720, 3774920082, 2598943309, 2345969301,\n            1201240332, 3131955258, 115485203, 1731266015, 3565733667, 3708968152, 3343319896,\n            4164543588, 958613110, 460381838, 508487067, 79603149, 4226757805, 2221491775,\n            793628682, 2721231001, 1503226493, 3320680646, 536612991, 1986939605, 3925890122,\n            953289772, 453639997, 3182429348, 3743006936, 4003692116, 1964545970, 4050648413,\n            4076626036, 416351025, 1696831244, 3133590002, 1111664786, 2906324009, 1439094475,\n            2214055485, 2798705323, 435684851, 3596001227, 3036344489, 3889898941, 1065048513,\n            4016594719, 4180638855, 3698313403, 2650988185, 407962531, 3005112678, 4110843613,\n            1265856698,\n        ],\n        &[\n            991539581, 170886811, 1946164502, 4138638160, 4166973165, 3436035151, 3104724201,\n            1844757770, 2340741284, 3474459530, 2913154637, 1985603183, 1490032629, 404439462,\n            2516898868, 4063787328, 2068346028, 3562917355, 3607751063, 4085533551, 3185010719,\n            4194162665, 3987252641, 3919902763, 1349071027, 3498237178, 1424577630, 2755258000,\n            1356884618, 432658210, 1133331071, 1971536170, 609062776, 2584940413, 503389674,\n            833096403, 2005416443, 873663129, 600036946, 1888391296, 3845065736, 2778213007,\n            3174588960, 860483363, 3214125890, 241195760, 4142060378, 3524395685, 2521966985,\n            3548302474, 4280709033, 1127351847, 3384545423, 1156416795, 2964727747, 2348926815,\n            3088158836, 914441803, 741513463, 43888624, 3905516593, 2467124760, 57532003,\n            2507495445, 3391285900, 917840688, 1449210608, 83470763, 2386746834, 518977089,\n            2745927519, 1466192189, 1209060587, 1707570892, 1673078302, 921540600, 3312933158,\n            503196443, 2601292096, 584811553, 315531478, 2613557634, 1029661810, 1565433701,\n            2749963283, 797016668, 2524006881, 4144613766, 342648943, 3634335756, 2886479078,\n            3729634162, 2446396883, 2646833057, 3809228466, 1241062391, 1771218854, 1859001695,\n            181499665, 2243910284, 3135305341, 1144637960, 377778783, 462714009, 1503150032,\n            2671008870, 2934075825, 1452005121, 869697216, 2087204075, 3565024128, 3030614795,\n            4198797483, 4039346519, 601848748, 4060938550, 2096365943, 2015345784, 2227066926,\n            2589779098, 2064017544, 3930785044, 572495510, 1372658164, 2267700924, 3842986739,\n            1865979088, 727501730, 3530720452, 2082196229, 744666215, 1657468106, 1799434953,\n            1390303492, 713826320, 92635671, 3263118136, 4104386251, 2272448841, 2859245350,\n            3739570419, 2388112539, 2973693102, 2566815653, 909557454, 3719121807, 4178393753,\n            2424198070, 1957898281, 1984544495, 1408061170, 3310277440, 1794952171, 452701329,\n            3882836884, 3298396236, 3967258537, 162517223, 3293672996, 764489620, 714009670,\n            31373948,\n        ],\n    );\n    // - rn >= BINV_NEWTON_THRESHOLD\n    // - rn < d_len\n    test(\n        &[10; 1539],\n        &[\n            2598813973, 1904197782, 1215006787, 2930851058, 147918011, 1108782873, 2193711651,\n            927233146, 4123817534, 3041706771, 2553964352, 2170557862, 2838589053, 2708835560,\n            2407955329, 1653207324, 2470552742, 3357058396, 1072990020, 1514783799, 1734243804,\n            1048851304, 3193592152, 1383793603, 2063694499, 3485786208, 990960024, 3569185429,\n            1155708496, 1416333121, 623402323, 3585705881, 2928088588, 4117621841, 3292316347,\n            2217241313, 1950216441, 1391040412, 2926386224, 3240560579, 3973468920, 2847202482,\n            2728825575, 2388048350, 3463506691, 3707514927, 865702555, 681215612, 2250616248,\n            1724513618, 364443494, 318451745, 1623887866, 1280032334, 35195442, 3837277484,\n            3573894817, 1602810477, 2072874171, 3800895590, 4253419440, 3499691102, 3587932863,\n            3517441378, 514856216, 1648457744, 1474005402, 700069688, 1803098596, 378514692,\n            3068261379, 3834605983, 93188389, 516236732, 2468656032, 4095977127, 3706578522,\n            3452719188, 1052956630, 813640425, 3047313546, 754584849, 3584789926, 347367947,\n            1332536470, 94171148, 626270691, 665836088, 426974652, 749957497, 1566095325,\n            3066600838, 4106843490, 318006871, 162882344, 3632111614, 720131390, 2147721707,\n            2217002633, 2466031857, 1087787961, 753159680, 366300446, 3082468114, 3984408901,\n            4057095635, 851983865, 4150513631, 1165194321, 2055798628, 2975996128, 2693369845,\n            3726562839, 3482086133, 4069043610, 1448967233, 700979569, 1698695640, 2318799208,\n            3684286306, 4092668018, 3628416641, 584456626, 1679287620, 1813093480, 177926224,\n            998082621, 3120492909, 1996199168, 3491975384, 3147828383, 2087111449, 381360867,\n            1127916110, 3472685226, 3293954452, 490729044, 3264678372, 1277191068, 4239255920,\n            2343436004, 2451796708, 1844810428, 2031787164, 3768550378, 3743966167, 2637191163,\n            3978079759, 4158883864, 1561267833, 539304561, 3435817790, 277956235, 4028949085,\n            2643928548, 2755470882, 3796376394, 194519280, 98463778, 3179299980, 2447702226,\n            150057260, 3463931601, 906456277, 990239469, 512339370, 2261507614, 2826877099,\n            3855453279, 2271503686, 841719073, 1591142177, 2651714174, 3361609137, 3279250024,\n            3326254458, 333896144, 3528172547, 3941409760, 1558812882, 3841874000, 3172301956,\n            4257828380, 4114850067, 2182891616, 2046840523, 1555755083, 2209766728, 2332501890,\n            607500373, 4124706810, 1713777506, 2341598661, 2284959418, 2746608689, 867377978,\n            336903700, 2503448208, 701980251, 2377952035, 614377477, 4284955660, 3814775340,\n            74129761, 1280559390, 2313692692, 1849232614, 2933185433, 1636271207, 630083065,\n            433420841, 471362220, 4210050941, 406797277, 582028044, 528813510, 2576049278,\n            540310007, 2789529550, 3534664845, 3236430259, 1506736021, 1977751182, 2006662671,\n            3679126532, 3806292929, 322589328, 2243078958, 2178902647, 2189720772, 3791358339,\n            1508304160, 1013509043, 3587377598, 3623382349, 1086144534, 1599008554, 1093927956,\n            2876914186, 543927302, 2219667262, 3853928343, 2487266159, 2613372592, 3550686437,\n            3716813778, 961453654, 2039051889, 4283100852, 3145660844, 1250225831, 198998794,\n            3726057928, 2284062625, 2219120593, 2244278486, 3790941761, 4203700163, 3879487839,\n            2965718505, 2863698764, 63056401, 475617471, 399914031, 459648012, 3133447831,\n            3412742746, 1512219896, 402842103, 4119870394, 2231397283, 1516833787, 1104380754,\n            128232714, 296865691, 1663298638, 716369560, 2904885147, 4237273250, 343946912,\n            2604094031, 217784841, 1162604926, 1345215097, 1426555576, 3614102008, 3943750939,\n            1639058309, 3296139198, 1330339563, 426593850, 1532081057, 1300177557, 1482433791,\n            812987015, 3232993095, 1037853411, 645052957, 2928052694, 1226934622, 2336175954,\n            1920836876, 2517428765, 3726338359, 4041660846, 2092081260, 3380258824, 1697518166,\n            3349439761, 743024530, 1795639086, 1779094250, 503268222, 3554837208, 2986098469,\n            2762697287, 232864157, 3768291070, 2983947152, 1577288457, 1050740564, 834028049,\n            1274280907, 3769464765, 1910494593, 2197778112, 2813074316, 2881147492, 1559228213,\n            1461309572, 1700587844, 2988103759, 1717431083, 951586291, 1707887130, 985013185,\n            3532658879, 2597699341, 1911327175, 3080664111, 3484272917, 794091071, 2311407322,\n            342113645, 1768703425, 2382063884, 3831832486, 3217975952, 3451120056, 3035392294,\n            136312738, 1699608380, 700762772, 3631031559, 1846450824, 1131124755, 1046357323,\n            2552828340, 2598371768, 795498120, 3174589062, 3838467339, 2334795665, 3324675939,\n            3403942196, 2075108646, 4259667163, 545251542, 749294402, 3324014447, 1729518387,\n            3551096145, 1758729590, 2379344936, 2455329109, 1757426268, 1706226190, 902425986,\n            2432676044, 2039145952, 410402636, 1639537846, 1305863342, 256740017, 3207555620,\n            3925040779, 668173470, 1141011911, 4212893794, 1581027147, 363670779, 2004465281,\n            1138726957, 645471449, 3585049231, 2777598154, 2922780411, 2222055902, 3815639175,\n            429697628, 4000303790, 3545345324, 3542109929, 509705074, 3722614775, 1753809005,\n            1973665455, 3780943261, 2494678174, 2641931684, 3388813526, 3347201186, 619828405,\n            2625911693, 3122659421, 3479474745, 3245356132, 1832479544, 3308783684, 1963028441,\n            640786937, 1641844190, 211570630, 1733515651, 2171524601, 3396267685, 3914881000,\n            996687218, 1617466047, 3343054134, 1737892381, 3544966831, 3416864496, 107959379,\n            2249494870, 793869312, 3685840230, 1757287133, 1655716303, 4226516527, 2538565645,\n            278467613, 2644886589, 2699974905, 1984329139, 1005957589, 789155264, 3666799939,\n            1611583926, 809907316, 3452803056, 1107204019, 2209104411, 1462179962, 2853352142,\n            3225410978, 2108213590, 4192481899, 1912371245, 1171525154, 3712460427, 2560727022,\n            1086797266, 952026066, 685685805, 1936296543, 3499184244, 196202245, 3078070455,\n            2171291372, 2730765878, 1573851700, 2931331934, 2847177501, 3478529515, 2313080814,\n            1556316903, 1559216686, 3130885922, 1862119430, 3274978261, 206968409, 2624567354,\n            1978029702, 4063454216, 2415324407, 1518621963, 747943965, 1111109939, 4070402813,\n            3113587512, 898431887, 316373197, 3046639257, 173632841, 3798588025, 1794547053,\n            272903937, 863380298, 2774736392, 2777149271, 3206794646, 32657715, 1025716581,\n            1615425071, 3173842612, 2073903119, 2153824733, 2329799226, 2341967952, 473768936,\n            3486256934, 2848218304, 2428724257, 3159637305, 2126501230, 765243196, 3425509759,\n            1131263732, 2515711177, 3855554546, 1023477320, 787209967, 336492935, 2359162223,\n            1128313353, 2209616384, 389804749, 535230248, 2210531774, 3227122449, 1267072928,\n            675693308, 1385601874, 1416098547, 4192675028, 2716632450, 4177948782, 13560634,\n            3703614488, 3901742123, 2270254077, 3759771486, 581228935, 3949774462, 3458012976,\n            4163726158, 1602955605, 3047124020, 1612897320, 2437308530, 2370536309, 1561087937,\n            2116794827, 1579558066, 431023695, 689842616, 2342172842, 4203138565, 2160272314,\n            4192374041, 3675193896, 1455954294, 3940635994, 4025127357, 4027321239, 1155472117,\n            1928138697, 1875048682, 4087308487, 4291614860, 1175537429, 3503698743, 2187471558,\n            2673330725, 2702107217, 2763809959, 2274134903, 1077148334, 2166895545, 1831099412,\n            3296218829, 2076626325, 1104984380, 1764164194, 3056784327, 1988083103, 3849746178,\n            3460231757, 3983590507, 1641801163, 1321487487, 2277192156, 1700397327, 4163993314,\n            118570737, 2510013157, 342313019, 328214482, 1456063300, 3771950632, 1226087686,\n            2343733178, 1108934200, 3650307976, 118441436, 3857631518, 1808729865, 2826187782,\n            2596972674, 1966611164, 988201436, 3909729734, 2034457184, 3137580128, 437202273,\n            1431097330, 2630459633, 2423317302, 1422128850, 3011012632, 3611423092, 3531891566,\n            1592039994, 734168534, 3492902008, 947200226, 1735249159, 3526990689, 1725556774,\n            1693403463, 3317454666, 2042191731, 3608995702, 497650714, 628421679, 2465885637,\n            4008542175, 68576338, 1372104957, 1927020046, 3573635655, 3090117252, 1774561696,\n            3603424898, 55089895, 2060875413, 116850528, 183816573, 478639013, 3736973628,\n            3606174188, 3086193394, 2548388100, 2591332019, 3032618195, 469584388, 1770142568,\n            205800329, 174943950, 260521576, 2114953066, 3428041459, 860714084, 1560598053,\n            2885505481, 3365355923, 2821218095, 814424502, 94258256, 2857874640, 3213633690,\n            239445181, 1741311155, 70754202, 469749979, 469377271, 634558134, 1314018935,\n            2663122712, 3425107874, 616125297, 1220520411, 363320242, 1717903421, 2177377494,\n            2683338356, 210565640, 3061448891, 1561105018, 3639722552, 2586119577, 264509957,\n            1416442444, 572448512, 3316197518, 4101471127, 1909662580, 3289492851, 702940172,\n            1747588119, 3288795988, 1441233966, 678854386, 2604723913, 373703246, 2055937039,\n            1124872113, 1294098600, 4165350921, 347872377, 4149215174, 3215450946, 3307233717,\n            3600358822, 2659616884, 552889201, 1684681790, 1821948043, 2909781107, 917768879,\n            2259947602, 2019396153, 3413299181, 603749894, 2467542574, 4017401393, 2519998741,\n            1106606352, 2283516402, 4262893045, 931507531, 257221572, 1471379658, 4223521274,\n            2958168654, 1643148068, 537294061, 3213657938, 3835022365, 3594404173, 777970857,\n            1918635217, 1702205904, 1047564373, 67547546, 3019489110, 483595975, 4130252917,\n            3081408781, 436773586, 1982914868, 3527757249, 1553562987, 4080227164, 822023069,\n            1427193014, 2565421648, 3942884687, 586018307, 1138884595, 2613035769, 486310535,\n            233458001, 106898418, 170926111, 3212999317, 3194995097, 827548055, 1783632131,\n            1458445783, 4273893842, 4169283956, 3425898311, 1900133873, 2830934989, 3597188167,\n            60014629, 2917912426, 3137954804, 1361341056, 4180775481, 946784052, 4199341441,\n            976101959, 1662997785, 1179237245, 372119531, 2815699743, 2114995295, 3901740963,\n            3080952004, 938243235, 1717858705, 1880470411, 3714648015, 2698621435, 4276694893,\n            327245390, 2823511048, 1178264505, 2316760826, 1757942990, 1568677829, 1199580238,\n            3100459677, 1386893348, 1600406349, 3128791813, 874040538, 2965907285, 8663319,\n            2919597841, 1169807363, 2130724711, 2817929643, 2594603073, 975728895, 3248945863,\n            1506505714, 8259384, 2395186489, 64139190, 254403781, 3179528072, 3318835559,\n            872874473, 3221533853, 1278142055, 2865063695, 2096015856, 3893588672, 1650965167,\n            852689473, 2456343381, 2227877463, 3533995396, 2567915364, 3260019114, 3354960043,\n            317493973, 4088542285, 603804423, 3133721086, 2455680365, 2501599681, 2371144161,\n            4224001882, 3900064951, 2295679614, 483545534, 500738921, 259183629, 2958675979,\n            3886544014, 3382548497, 1341558649, 764676712, 2686742281, 3585367009, 2470017030,\n            280649561, 504360831, 3177630390, 691028027, 3630869823, 1850039925, 693186712,\n            2234334464, 3019783104, 1258253876, 2759186239, 2705660533, 1535024585, 16228098,\n            3597194253, 3856258376, 2530800309, 1756061934, 3703461702, 1458672824, 3009579190,\n            325542092, 974024523, 937809905, 180338019, 728257472, 1334683442, 1531729599,\n            4257819380, 3701291761, 2423233504, 3786098144, 776062663, 3861731850, 3717496633,\n            2918219359, 2369401162, 1963105504, 2673826226, 3238671093, 568083438, 4121947082,\n            3892853652, 1632686679, 2302193583, 3211408318, 1938993158, 4122064270, 311269184,\n            2105346675, 1581174365, 2485158976, 2443260070, 1986431168, 1124848188, 1841087451,\n            2704521996, 1214274421, 3662035084, 2837679678, 4043497550, 552208260, 1644975825,\n            1950150273, 4027848966, 4079004873, 647675052, 223752470, 637576072, 949880156,\n            2749078102, 2043391316, 1008133, 253411434, 3799679907, 238227057, 2495985662,\n            1475105846, 2961884606, 652180469, 1691635637, 1430944868, 15398684, 2278485165,\n            3795142783, 2981896799, 1330890913, 2239691223, 407470744, 3702570774, 1624292191,\n            3703366632, 2187395861, 2415878960, 2303069741, 1369122706, 2750340520, 4035673151,\n            1425244662, 25186311, 123582970, 2490005251, 936607532, 4115073120, 2730391719,\n            2823090688, 396451377, 2182998280, 1365726601, 4033770954, 3047868289, 2336389408,\n            688454315, 1299725781, 3304644284, 4238176839, 3914620151, 3029466942, 3172492309,\n            1190474536, 569450335, 320580314, 4004925139, 2557991799, 1493351038, 949583033,\n            3275441062, 1311907795, 106222620, 396788468, 3186456628, 517037899, 2177653619,\n            370023265, 532558109, 3182151426, 954367771, 2865591818, 600183719, 2521622949,\n            3079560626, 1906789399, 1612708432, 1801660151, 3565921772, 2688352000, 1101243899,\n            888006794, 2233649225, 2671500356, 1504445832, 1199168343, 2043022343, 1250919220,\n            1374956710, 1107550604, 957179006, 3319703903, 4110453611, 3311143947, 2774029776,\n            1456730624, 1014119593, 3012545941, 1650066434, 3431589287, 3624715486, 1072097915,\n            3568695028, 478299405, 362822053, 2632030958, 955747917, 2974153651, 2880247593,\n            2837857407, 1533402093, 1550331006, 3833005459, 111580345, 1694562098, 2731241196,\n            2659074758, 1347615125, 3711588514, 1514710939, 3788474419, 3668780501, 3266213391,\n            4081085519, 1196081228, 1049947080, 1820720234, 3100382458, 2198468097, 3708538645,\n            1035729054, 1784655621, 507574130, 2908640623, 3615200865, 1223546227, 3675568182,\n            1661330896, 1399689373, 1323389692, 2981922901, 4156332999, 1902241850, 1428680890,\n            3049572611, 4253261231, 2148214199, 1998921071, 3899443086, 1478235253, 3791927172,\n            1483896530, 3565485437, 915921912, 2258155251, 3426051958, 3307670857, 3029363090,\n            3673788309, 4082838999, 624603732, 573907442, 3116664857, 3586999255, 557493850,\n            1739716128, 2397076308, 2312498391, 767640384, 2119706819, 2637314051, 1070866648,\n            664107404, 616236779, 3020748367, 4122128780, 2009706384, 3245363034, 429196441,\n            4195520565, 4209198410, 2158211364, 3659713923, 3985561806, 1747634790, 4115935838,\n            2827667115, 3073689925, 1621229363, 2774950774, 2538390550, 3506768465, 718261358,\n            564823729, 380006788, 897186389, 3414352487, 1032216622, 1469922191, 2196317056,\n            2239269473, 3654751282, 613015420, 4098167098, 1281134924, 849099531, 2523299715,\n            3904840545, 1997547696, 1158713208, 1289444182, 757815917, 899581875, 3622748533,\n            3063686656, 2979790776, 1553609204, 355408616, 3897614956, 3680334470, 25191644,\n            355655308, 111682127, 4053312775, 2921335050, 2200671456, 472639194, 1374183459,\n            2738441274, 1596829615, 959522853, 1993763998, 1832301144, 2263515976, 993190648,\n            4045308024, 2213735364, 4061773476, 2596920312, 1929252967, 3935609312, 982934883,\n            3154772065, 4254233108, 1244999206, 765237459, 2528318166, 1563389556, 2293797399,\n            3495759008, 48504250, 3182637462, 3138309477, 2147232621, 4810076, 3999234780,\n            2279064264, 2264522982, 3079929466, 1524222187, 1598294545, 2049273389, 2729549735,\n            2116985451, 2637892533, 1094214870, 2711414546, 418295062, 98357556, 296649589,\n            2636445209, 4030461397, 3073508440, 4062358649, 1293566861, 1534697481, 1343281639,\n            3078259374, 386875427, 1145986442, 1790533181, 2987076845, 237202537, 2194958623,\n            935119723, 1921262864, 943957815, 2336181341, 2723699978, 1638860845, 2630349960,\n            431757538, 4152375793, 3473513084, 2603606861, 4176464622, 3978369596, 981482293,\n            929741839, 2111696471, 571254437, 1419237733, 901791748, 3340393111, 221970895,\n            2605197016, 22565479, 1000841034, 2192399670, 1207300847, 356824298, 3009617459,\n            2651652098, 2420275852, 1631602976, 575809994, 2928806259, 2831092106, 2629452482,\n            2842897182, 1909556662, 2496151886, 3385330607, 957152776, 2804092840, 3551246686,\n            2730894896, 2027253611, 2531182020, 2258110944, 1391264743, 3902230517, 3835546712,\n            3424753892, 1147410244, 3448482025, 319341118, 1798380053, 2742193162, 2106010955,\n            3267048655, 3886107336, 3334600393, 3772435523, 3985863328, 2950255062, 1012493134,\n            3954831363, 325018235, 2523597002, 2454925521, 2861802043, 4209313262, 3868234463,\n            1685691511, 2786322255, 4244960817, 1991229419, 4239301712, 576152977, 1652411241,\n            1589394460, 521549473, 266587858, 961791319, 1146831103, 3469211532, 3501779101,\n            2312218475, 2321025269, 1346459216, 472196028, 3771324053, 1495430908, 463405457,\n            1940232183, 3937148918, 1156878514, 2831556660, 1644483662, 1787817713, 2339616130,\n            3815974485, 2298018558, 71674109, 2675299410, 960845405, 3569711116, 1673611570,\n            1769369631, 1437416980, 4174063039, 2062712084, 2133844948, 196794643, 1935768058,\n            1831573341, 1418980930, 3294487604, 3544538744, 2334730191, 3988003806, 2274350901,\n            2023027498, 3447859831, 1671781771, 4023665101, 1455029189, 2419433622, 2943475311,\n            4198568768, 1395089836, 1092520718, 2430238564, 437551709, 4097009390, 3375079636,\n            4154198223, 92070792, 974607811, 3873908092, 3374473679, 638725898, 1249915990,\n            1085664087, 3927733894, 1217984426, 1825247311, 2107887775, 170602951, 1075337232,\n            1842870533, 3647067870, 2444592832, 3013106942, 1161476947, 3743427689, 1263482478,\n            69206560, 833594813, 3842989721, 337909675, 3392484922, 370017251, 27594915,\n            2126835633, 1736323108, 1893331695, 1468455680, 1075562062, 455344215, 969605531,\n            294398875, 883453327, 3994410499, 1964955910, 1983678849, 556499140, 2199399388,\n            1506753515, 2562511167, 573514453, 1452183180, 3758124304, 2276736219, 3962356320,\n            160602272, 2732947819, 1312555719, 808517807, 1646633687, 4057383018, 1177836167,\n            2724613618, 724351202, 3082498407, 3292565482, 2024078169, 2339554384, 3963173875,\n            2223760730, 2562066565, 2193608401, 1812209945, 1665831972, 1039920028, 3410644888,\n            3314911306, 2847575459, 2005962667, 2392982038, 2769384144, 1673231309, 2605033025,\n            3097232789, 525491643, 1088675733, 389231889, 4053722369, 1394160319, 920345783,\n            1695188025, 1313259843, 2855284945, 1128781302, 1711293636, 2436253183, 2702553100,\n            2342544037, 2382554808, 1645824427, 700888148, 3820471891, 2062002896, 1600256482,\n            3523617235, 3825142862, 4016136295, 3838255962, 2953276340, 394106186, 956179026,\n            3512260850, 3001113638, 1645204518, 555542490, 409962126, 479780262, 4202384502,\n            549252742, 1340551826, 190095025, 2842856010, 446626748, 2565781573, 2172050474,\n            85422525, 151000070, 2413238086, 224534468, 4102988065, 3524737259, 784974768,\n            3778660388, 2573449273, 956921977, 1416256526, 3821996527, 1297167173, 2183926071,\n            2745200336, 1745460864, 399929970, 3271657494, 1058524185, 3138265217, 3822962039,\n            796872545, 555781465, 3355863387, 4265560398, 2445094472, 546611744, 958064176,\n            2278895404, 2100057835, 789578969, 387055963, 1153298400, 4065547056, 3688020091,\n            783181103, 1789734962, 1466117990, 1740574947, 1632230912, 4155788342, 1714025679,\n            3862124914, 2247239755, 3047057899, 3610673443, 1450313039, 3533121399, 1564221183,\n            4056883174, 319992191, 598075724, 2438292429, 901314271, 2157273664, 435275402,\n            1774735757, 177332560, 3010394026, 3827445200, 2002098740, 1897812156, 454287770,\n            2829500771, 3286056227, 1498747083, 3402858410, 58581019, 1048766033, 1640106396,\n            3774636176, 1228719792, 1768725616, 3094025701, 3705595233, 2943515149,\n        ],\n        &[\n            3303507517, 1737467916, 767592771, 4237693101, 2944498355, 2305367062, 2912464955,\n            2039632714, 957753136, 3932250327, 2923226395, 758588986, 3276864736, 4129542782,\n            3701423701, 1834120826, 1304646722, 2700953412, 4016654202, 1446197632, 4233056281,\n            2795834408, 2358334260, 4031834794, 1761430989, 1322974963, 1041373666, 2212100552,\n            2426361770, 4261631544, 3079923997, 556209919, 2565829294, 1158111010, 1485991528,\n            4015229549, 3673606504, 611864921, 976174193, 806940030, 2732222596, 2259057471,\n            2443961478, 4098098138, 644289655, 180553484, 4059537703, 708282117, 1433746242,\n            1823452813, 685407883, 2203888447, 3826783627, 2594937784, 3968973728, 3226845414,\n            2669006681, 531830322, 453908823, 3201286311, 919570600, 1858088761, 407253743,\n            1432230279, 3303340419, 3210731060, 1388706247, 551779110, 351497524, 3064709178,\n            2129368300, 1872141157, 2752241851, 2688864462, 597028566, 3593773250, 2480760169,\n            1493938468, 320489468, 1206910552, 2899495800, 1583265563, 2935858872, 126264340,\n            2083066625, 2827628121, 3109648374, 3916360359, 389087236, 3766699281, 1333824469,\n            1218761052, 2129210405, 2527568435, 3858191140, 3930233522, 1058437374, 1654914995,\n            911091073, 1037669921, 2949223555, 2606346852, 1104967551, 701746540, 416874025,\n            683350868, 335950780, 486101025, 3696781531, 434131711, 3081485031, 4277564240,\n            2555479895, 3850726160, 3227325468, 553377665, 199290481, 3982285635, 3468419008,\n            3392035752, 1966268427, 1873702317, 2940911086, 2914228436, 1708633307, 662031149,\n            621794577, 2395698305, 2735240556, 1414089965, 3294650435, 479604329, 2426263958,\n            847381928, 873722272, 1110653081, 1951740102, 2731402038, 2556525098, 2219924857,\n            1852070957, 2449841178, 1210250294, 3699155577, 1784858631, 243884741, 2161178521,\n            2410975312, 2681491929, 437235103, 1281548845, 3357384194, 549196434, 4067561207,\n            3450283139, 3652169421, 1874377644, 169053482, 1420061127, 395406675, 3332510954,\n            3856194671, 3006496664, 809601906, 1922764991, 3111985626, 3390014784, 3048045015,\n            2051558581, 2703813358, 3808996437, 3570075083, 3505603444, 35527898, 3996784836,\n            4168425592, 1946706469, 856358712, 3661547641, 141395264, 3094553658, 629697921,\n            3847603586, 2560897876, 2555855191, 1405066228, 896493515, 3694348082, 3454533550,\n            885932680, 3723805569, 493727984, 2574262444, 610088096, 503058120, 2172357146,\n            2481205990, 3987005657, 3085722243, 2250687621, 1050336745, 3740028373, 3019114451,\n            1642616645, 1137174523, 354355265, 1455093279, 304460919, 4116447569, 2981853747,\n            856638318, 3109624356, 3591169837, 4193437247, 443242328, 1666463852, 2097829509,\n            2208974333, 1422720757, 3349658507, 2452053895, 2569932614, 47797786, 3752698672,\n            2215739699, 1652083417, 3346170449, 585897335, 2075209213, 3518121114, 378885805,\n            3744168278, 3903962084, 1064225611, 4197819881, 1867701541, 1058875078, 1828480385,\n            35105056, 2154079979, 4006209278, 3153027209, 3695601551, 3461064991, 3223410438,\n            3090214664, 4250727661, 167290560, 3088602589, 1392761792, 4016528315, 2899219207,\n            2196701677, 1154503712, 810711706, 3932982426, 2420112400, 3293415319, 4134821524,\n            3493789883, 3329390364, 3047733519, 1049261264, 3282299496, 482643201, 1333502492,\n            3412458538, 3505648168, 1030433939, 3681403988, 4159258448, 821956, 3965405477,\n            3688327, 2218271368, 3431171763, 2674850379, 2269778883, 596405244, 2839693344,\n            4146102065, 3215467606, 1891293404, 973749441, 3640452446, 2709562759, 459831821,\n            460230179, 2910252183, 2014822547, 3590552255, 2390315678, 1031487459, 1213313670,\n            2511201602, 1511763753, 3969704570, 2909506049, 1760818720, 1110188569, 154546279,\n            577049207, 1753565754, 4085487615, 3287577161, 2028144074, 4111187020, 3004119870,\n            900037962, 2806754372, 748875551, 2620104615, 2513455401, 1585914851, 239727281,\n            2605810930, 416537433, 2166996582, 1965459949, 758058785, 1510362220, 1824837142,\n            3097689711, 3896639991, 4187903962, 372233538, 4010166025, 1907205494, 3036010338,\n            1576810188, 3371537329, 2895423119, 3461187657, 1440946377, 2483629064, 2639054882,\n            2819542476, 1677376583, 3628809647, 1237686175, 3985351720, 2642412817, 4013664855,\n            2065613802, 817459407, 2876445270, 3076582045, 1810603735, 1174549530, 4260651012,\n            1973700727, 2194803557, 2360115398, 3069422632, 1295376632, 1002159587, 4162264900,\n            963230566, 193817342, 2402613170, 275479630, 116160077, 2599851335, 159870465,\n            211768251, 4017718175, 931115106, 1004170356, 2730898374, 932870994, 1082826978,\n            2961790318, 3424432922, 1300198410, 2280596007, 2164752687, 2135660458, 2665413409,\n            378731924, 3146959946, 1447131084, 624620351, 1626838440, 3569823375, 787344599,\n            398683074, 2909969062, 1166082222, 2222839820, 3445152909, 241015893, 3204685501,\n            1212401564, 4123206390, 1295604587, 1098987770, 3308585450, 3613934791, 1755566651,\n            3657857779, 1263036827, 3678216851, 2402921074, 3493820436, 1704692066, 403162744,\n            3170124922, 3563160884, 3160828389, 464965432, 1118230114, 988354534, 356341207,\n            3849468154, 686849000, 1566884214, 240572604, 3063337879, 731356349, 820769259,\n            941504045, 2706839108, 2723874282, 278246299, 3880298064, 4262421502, 256437639,\n            1773319540, 153110521, 565549233, 1853553593, 4289762574, 4098151149, 3144524222,\n            4144088665, 2052608329, 1464290562, 2110534105, 1113619720, 2516886130, 2842359662,\n            436774705, 2771156018, 1683247173, 3108637805, 2436817839, 4127310701, 3910938906,\n            2062961202, 3341755081, 3583281049, 3534420977, 996954658, 4115691732, 1529857101,\n            519089315, 1800475325, 2866891326, 3674269922, 4258687645, 1222536664, 119098982,\n            3470430550, 2133110377, 10231145, 2797637322, 1573837132, 2948970055, 44978960,\n            4025694418, 3346973726, 1067376893, 2502195176, 14223176, 2185770650, 2887537518,\n            15571252, 2033910005, 63833522, 787872402, 3088869854, 940048320, 409417410,\n            1084110155, 601749701, 914916762, 524011526, 846030561, 4258519014, 2487948410,\n            3192173244, 3091400971, 3644666631, 532480229, 2780924927, 604543953, 756270658,\n            2063413786, 61217573, 780610452, 955642466, 737073209, 97297839, 4258953485,\n            2857641388, 304710700, 3918409840, 2194881876, 196515060, 1845737739, 80004705,\n            3864082477, 2417895713, 1575272517, 2071122658, 4181848470, 699244129, 2719978593,\n            3969766361, 3331919022, 1806356115, 1674881762, 3140317527, 1020055538, 928717808,\n            3657371453, 3576271656, 1661098282, 2787948393, 1612552028, 3154905497, 1703392561,\n            843717976, 1621287936, 964546377, 3549430129, 712295080, 2234282678, 4200849568,\n            2117828027, 1392560869, 1138816605, 1628721368, 1719186629, 499638295, 2276446667,\n            2040220810, 4170119435, 3098091505, 3464708059, 2446105454, 823802794, 561105361,\n            2956734110, 85242489, 3594780155, 577528063, 3814286772, 3517308917, 1542560009,\n            903130712, 3610028360, 1094281534, 428913785, 2017125716, 4147179238, 2416543280,\n            2299224901, 3094092893, 690981050, 1074080982, 3806304984, 42870724, 661112767,\n            951312097, 993899402, 1421924279, 3477956487, 2620630825, 421567847, 1135313615,\n            1871766543, 2089515143, 3125551624, 2893389248, 1822212994, 608096287, 1209599323,\n            1729308570, 3183687973, 4188910249, 4113106401, 3467805891, 421479009, 2067824783,\n            1123275745, 3372672466, 1299403729, 2597804990, 4109910992, 3549093152, 1334873992,\n            2837764304, 217816190, 2798635274, 1928429025, 3532349620, 1432073554, 894604604,\n            1320754530, 2946314029, 1689416007, 4088210274, 3660222258, 1778465861, 2089083512,\n            2489444834, 3020220872, 2955906475, 530018361, 3604331239, 266271770, 1093367251,\n            2425988385, 756441106, 3810449360, 166826417, 4128383674, 2193768558, 1695641441,\n            4163952927, 3844926416, 3179839754, 1485072550, 1035240603, 2716609076, 4025246794,\n            1340294165, 3056622704, 1486949742, 582340579, 1925519282, 1050735048, 33509855,\n            2342941070, 2747830341, 1845018013, 2064583117, 350099328, 937043595, 1618308339,\n            1824995534, 1246976548, 2566004874, 3546659674, 659106533, 2844260619, 3911232451,\n            1416070938, 2388309597, 316855261, 1695213219, 856692567, 50305942, 3668671854,\n            155369786, 2137812662, 4211140628, 1042632363, 287846104, 2375035513, 1607313275,\n            4018768752, 2592097421, 741212831, 2408601799, 903321756, 3509061462, 3142569462,\n            4087971745, 3019038954, 1803053183, 2257944916, 1390909767, 2836222866, 371214087,\n            3682888114, 2241578583, 3605759723, 963603499, 1055335598, 3601870947, 4058606066,\n            377849537, 1843635487, 1835087927, 3393215451, 17492256, 3372299656, 3413139881,\n            4264793180, 1928965951, 4021643980, 2269905143, 545062409, 1389035345, 948398528,\n            271536224, 3504014149, 567335901, 3413496753, 3071719597, 1445310729, 1770797777,\n            1267315070, 2207614182, 3493277503, 4282532855, 2107955232, 133857837, 2087779634,\n            4056521208, 818046024, 1890865855, 2126495054, 697548852, 3485729598, 1695030614,\n            893769923, 184087075, 1500071319, 2080614980, 2480313210, 3450043314, 1064086870,\n            2786617720, 4034347698, 681412032, 2428347460, 3253322495, 3604525345, 1428905795,\n            4035094721, 2101041634, 4183013229, 1705836765, 1682316444, 1879660152, 656187483,\n            3706455747, 2213541704, 669373128, 1529444811, 2814804687, 908625065, 2227416512,\n            2001006578, 607169088, 3393837756, 2682839326, 1093822620, 2249228026, 741792013,\n            3650948262, 2073718838, 2268511569, 1643477360, 2804865813, 3375407338, 1318291972,\n            1414889752, 2869309697, 1958772002, 4162044589, 344252635, 3226572534, 3577208303,\n            1959437424, 899330854, 3892405212, 1622822546, 1644013310, 1300136815, 2640337368,\n            2069864152, 1596350405, 3843745327, 1256171531, 870418775, 2393395126, 3876818506,\n            3944780828, 4008626102, 3127368256, 3426341771, 2086853545, 3827677693, 313614572,\n            3669266463, 4080954414, 1707330242, 2963410257, 3437453487, 2794195219, 3099230302,\n            726769739, 2044701195, 1129715603, 1793697677, 2760059361, 2331714255, 2589913453,\n            4127324884, 2881798920, 3400611219, 2052671160, 3546649304, 2164589537, 2812204213,\n            3337755588, 3983060148, 1899178107, 776922408, 4182115872, 444866608, 1399651129,\n            3474508713, 2842510671, 3402478835, 1423128980, 4178402672, 3172508430, 804756202,\n            1597189857, 1958174560, 3392832851, 1197650976, 3772223860, 2054821761, 4011804750,\n            474742851, 1329523696, 4032274332, 2454461926, 638843849, 2072449514, 764758175,\n            3934751812, 4075369298, 3142015673, 3394043201, 1535751977, 1846529809, 959593533,\n            2235839818, 2814770736, 247085892, 2629667206, 2957898589, 3933947035, 1295728615,\n            3586572901, 4038985747, 1129159296, 1855469111, 1271614337, 1507173551, 332723961,\n            1156816569, 1294330789, 4122256011, 299955786, 3523281781, 2491532525, 1960595579,\n            1730519156, 499071642, 1575886120, 2620965123, 3289148909, 1154711404, 1451719777,\n            2628469322, 1901725555, 823453464, 3761287780, 2261972333, 3596389504, 3137670793,\n            82630428, 3159699693, 837229231, 344117878, 2381467908, 726572177, 304723155,\n            3208229621, 1458659872, 1794857529, 3755652400, 2395146944, 4102358516, 3277747506,\n            1818040372, 3936695066, 2397713693, 1708618418, 1728140834, 1261714327, 1581655946,\n            2071676586, 1202217464, 1344775033, 4250653297, 2492875948, 1126916876, 2945410447,\n            2941087697, 2560380036, 2546735705, 3178023445, 626886956, 484882355, 3357302024,\n            4057372957, 2081549406, 3896175417, 2686162101, 1986295486, 1621237422, 3568031348,\n            4006200466, 1442461868, 3844879388, 3501884160, 4038570281, 4208037469, 183139977,\n            999125999, 530710734, 2507567639, 3058017326, 4201561530, 2864542147, 2696523106,\n            2969212130, 2678586192, 844065498, 2655259915, 1258788749, 2827607705, 2237733350,\n            3783297719, 2313239370, 950226942, 1280595939, 1196906959, 1606546303, 1844760556,\n            228764146, 744772053, 1358152164, 1193261600, 2565492365, 1225744635, 4233301881,\n            2253145769, 1602119788, 1365069640, 52910185, 2636770690, 3298764603, 1878144899,\n            4262332977, 3649154366, 3690806265, 231714913, 2913226838, 1554707381, 2963669507,\n            2049539773, 1775985343, 3627719803, 433359314, 3418531436, 793315695, 913341557,\n            2380241821, 348855994, 234181973, 3722537381, 3525843118, 1275331720, 2537849571,\n            2827984585, 1565515383, 642373946, 1576289295, 2688247425, 3614474901, 1917731824,\n            2884918146, 1646964474, 2383030418, 2488801475, 1560749769, 139516483, 1142139281,\n            3459274279, 2863576242, 2828722138, 717484310, 1564480623, 3172598637, 2368201724,\n            2247871922, 419758505, 3015961787, 3098012702, 1041261606, 984280115, 2438811327,\n            2578749598, 978582878, 968817491, 2965070269, 2780764697, 792560930, 4229722212,\n            4114038484, 817420493, 3041070967, 3191549455, 56820468, 186749905, 784610516,\n            1729092057, 1935036496, 3745217089, 631003694, 3845500664, 1776171936, 2105858365,\n            1027041956, 1638191578, 3198133424, 3040033996, 3224025446, 2046726489, 3326226799,\n            4261577923, 778164631, 4272446112, 967648331, 4223690387, 394608816, 2849103815,\n            1132525868, 4239388057, 3710951992, 582192848, 1372476599, 1228786127, 444221576,\n            1576598378, 4000181362, 2210214319, 3226877228, 3921989392, 3841275639, 1917309689,\n            2860911813, 4290305048, 1796377659, 3485206273, 2654605026, 1122524178, 3609458012,\n            1733743381, 2869375618, 3606400920, 2485406505, 617720548, 497728528, 3826929977,\n            788489471, 1188098828, 3383811959, 836335995, 104474735, 994749139, 523424077,\n            1334471135, 3246261832, 579729621, 539626281, 1917656426, 3649706685, 407844197,\n            3736652416, 449727051, 2451735689, 854611863, 3476911840, 973228334, 374181454,\n            174850286, 4178627179, 3564929895, 1321454916, 3996342532, 3051609408, 3899526499,\n            1406247157, 803997219, 3125646376, 1606457001, 1405170718, 208843195, 1067743855,\n            2152262286, 3179865614, 3639249079, 3035981075, 2732174588, 351444382, 2864637808,\n            1006363319, 3244329910, 405573136, 562447830, 2108083668, 396995391, 326716392,\n            3263476213, 46276814, 1326176087, 1851003306, 2516298844, 3058805571, 2774935984,\n            1856888260, 2568955433, 3218178509, 649282170, 2256866690, 3674417033, 1111304414,\n            2088271619, 3238685708, 1574098232, 4183705418, 1987306144, 1189150097, 1378845891,\n            3654818831, 386424237, 515382663, 1197128686, 2542968522, 3887585643, 73911371,\n            4058793301, 1696639371, 2561358933, 2221990016, 727444672, 1973624906, 3853875864,\n            174963610, 2695490643, 1066818493, 150873363, 3952837259, 2936691596, 3233597847,\n            2506388918, 3711816965, 2536068963, 2311484662, 1093886392, 2704991380, 4059725080,\n            1625573608, 2471671232, 1763939042, 2734410153, 4028854994, 2952269163, 1527756733,\n            3902245417, 803045644, 1140158788, 3552349570, 235707516, 415130691, 1269910803,\n            2620435440, 2226985943, 534205480, 2823709851, 4167053910, 3680035619, 2757219390,\n            253917945, 3675657485, 761900957, 921345945, 3266224194, 3148826681, 1686290818,\n            1647986984, 495687313, 977442969, 519576012, 2062617190, 2755583385, 2380042959,\n            3142598908, 2437799893, 2426856697, 3052553836, 1753471289, 3915929071, 181022453,\n            2017995427, 2796049960, 1358824868, 2906668276, 3538494963, 1500035161, 65877569,\n            3786619137, 2956889923, 2470576554, 1511345314, 2266296788, 2066914712, 94664780,\n            4203735289, 4281330982, 2763817600, 2319245226, 944042376, 3922820514, 3935434053,\n            3397738753, 243208651, 4248331561, 1105500069, 2967638830, 1029380469, 1099175028,\n            3684769174, 970577857, 824995756, 2937133428, 1925916100, 859262581, 1913695947,\n            99275310, 848678738, 1204388593, 2545149594, 4025381218, 2655396831, 4274996806,\n            785850435, 2813888154, 2491029176, 729818073, 3512685438, 2347032890, 236189106,\n            1548333126, 4226775910, 3531794275, 2605168049, 2258187662, 3684015953, 898250663,\n            3771349383, 4093644918, 1624210803, 4281075128, 3093735055, 1291164275, 4037665805,\n            400599276, 1273249058, 2375386975, 3439029906, 3333739393, 21660248, 1230861454,\n            4062325366, 4236459577, 114385419, 3486611078, 2042004563, 1720831514, 2860273565,\n            1626594640, 1874700160, 2999308559, 3363764551, 3500763507, 2853826537, 2479469741,\n            1210500932, 2562869107, 880924171, 3384557003, 4168144997, 1148570091, 3116312623,\n            3172212634, 3567662417, 2642768241, 2015203625, 322037435, 4195745331, 482368754,\n            3667466677, 4219023014, 1434757526, 2822946590, 1936561533, 2947351890, 76179171,\n            2209227842, 2435463017, 276550749, 3368341828, 4262885294, 527655253, 3745940749,\n            947007746, 3600866533, 4084045218, 3905637169, 702492342, 3383700150, 1661174941,\n            1763804378, 961484162, 439776914, 257725152, 2840617852, 2635835773, 2403444459,\n            2908195944, 2902712886, 3595015469, 1460138072, 457118198, 2120525120, 2083051232,\n            2885301328, 3622650790, 400659000, 184135173, 1137972313, 759714739, 1306898817,\n            2898422672, 1499186793, 2809562653, 1117081917, 3344337520, 1802186651, 3627008548,\n            3860814929, 3728070085, 2991502661, 1782981707, 2477289364, 3565582296, 4061650811,\n            1579851913, 3689665892, 75184626, 2690145835, 1228774440, 781089767, 3218967841,\n            4064814684, 3163493596, 2809482905, 208507155, 3756966102, 1779229104, 3680138867,\n            1751377038, 2598643358, 741546321, 1303997493, 1306096237, 3769872893, 3911517876,\n            1315212882, 2839259600, 1408676647, 4129419272, 26525771, 1163846026, 4159566079,\n            3195690749, 3064298320, 2468791883, 2538731242, 3488224592, 840135976, 493847318,\n            3680037513, 4066665187, 1669269859, 29113490, 3642824198, 2180773838, 3705727774,\n            3741660915, 2916119284, 4126524803, 2531904672, 3689890848, 3760318626, 2463539219,\n            2074029166, 3481349310, 834750020, 3864728871, 2085171104, 1481087706, 385893521,\n            1753696318, 262108731, 3110985970, 3185711468, 3592333917, 4001141364, 1777140007,\n            1668227551, 3014458968, 3982753649, 216294504, 3414213843, 553573571, 4237875195,\n            1780838673, 2208517053, 1405463181, 3074428565, 443193338, 3142617921, 426182091,\n            3549357900, 3829054100, 3730720095, 3556916232, 3050819311, 395210557, 3290215021,\n            1925989323, 1278915506, 2074504769, 788246561, 4036378728, 2546297900, 3576484297,\n            881981653, 3844099771, 1100647287, 3275806264, 1545433580, 2973403693, 2010768484,\n            58589600, 2055927634, 900275269, 1772160551, 3642278816, 759464205, 3337186197,\n            2884437454, 1815406779, 1826092146, 1703588272, 91001350, 785570260, 4114370752,\n            2690000574, 4090829518, 3792473390, 2886081610, 712723937, 3835538037, 4094897515,\n            2015334309, 3367660714, 1368192432, 1580207087, 2030632060, 1542088491, 1685523972,\n            4182209840, 1673405540, 4001729368, 595538569, 1903475145, 3297819296, 946281001,\n            1202436672, 4111768072, 412627407, 1029652681, 2792765909, 2040861363, 2987136935,\n            22966596, 3410302892, 3001821942, 1981338581, 3480779498, 1173591145, 4071007940,\n            1927554934, 1430729301, 2103178216, 3055596527, 3263660591, 4266315882, 3008856523,\n            1661503737, 2281231147, 4261532350, 2177588068, 1785850443, 62425813,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_invert_fail_1() {\n    limbs_modular_invert(&mut [10; 3], &[], &mut [10; 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_invert_fail_2() {\n    let ds = &[1, 2, 3];\n    let mut scratch = vec![0; limbs_modular_invert_scratch_len(ds.len())];\n    limbs_modular_invert(&mut [10; 2], ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_invert_fail_3() {\n    let ds = &[4, 5];\n    let mut scratch = vec![0; limbs_modular_invert_scratch_len(ds.len())];\n    limbs_modular_invert(&mut [10; 3], ds, &mut scratch);\n}\n\nfn verify_limbs_modular_div_mod(ns: &[Limb], ds: &[Limb], borrow: bool, qs: &[Limb], rs: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let q = Natural::from_limbs_asc(qs);\n    let r = Natural::from_limbs_asc(rs);\n    let n_len = ns.len();\n    let d_len = ds.len();\n    let q_len = n_len - d_len;\n    let qd = q * d;\n    assert_eq!(n < qd, borrow);\n    assert!(qd.eq_mod_power_of_2(&n, limb_to_bit_count(q_len)));\n    let expected_r = (Integer::from(n) - Integer::from(qd))\n        .mod_power_of_2(limb_to_bit_count(n_len))\n        >> limb_to_bit_count(q_len);\n    assert_eq!(expected_r, r);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_modular_div_mod_schoolbook() {\n    let test =\n        |qs_in: &[Limb], ns_in: &[Limb], ds: &[Limb], borrow, qs_out: &[Limb], ns_out: &[Limb]| {\n            let mut qs = qs_in.to_vec();\n            let mut ns = ns_in.to_vec();\n            let inverse = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n            assert_eq!(\n                limbs_modular_div_mod_schoolbook(&mut qs, &mut ns, ds, inverse),\n                borrow\n            );\n            let q_len = ns.len() - ds.len();\n            assert_eq!(&qs[..q_len], qs_out);\n            assert_eq!(&ns[q_len..], ns_out);\n            verify_limbs_modular_div_mod(ns_in, ds, borrow, qs_out, ns_out);\n        };\n    // - lowest_q && limbs_slice_add_limb_in_place(&mut qs[q_diff..], 1)\n    test(&[10; 3], &[0, 0, 0], &[1, 2], false, &[0], &[0, 0]);\n    // - !(lowest_q && limbs_slice_add_limb_in_place(&mut qs[q_diff..], 1))\n    test(&[10; 3], &[1, 2, 3], &[1, 2], false, &[1], &[0, 3]);\n    test(\n        &[10; 3],\n        &[1, 2, 3],\n        &[5, 6],\n        true,\n        &[3435973837],\n        &[858993456, u32::MAX - 1],\n    );\n    test(&[10; 3], &[1, 2, 3, 4], &[1, 2, 3], false, &[1], &[0, 0, 4]);\n    test(\n        &[10; 3],\n        &[1, 2, 3, 4],\n        &[1, u32::MAX, 3],\n        false,\n        &[1],\n        &[3, u32::MAX, 3],\n    );\n    test(&[10; 3], &[0, 1], &[1], false, &[0], &[1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_schoolbook_fail_1() {\n    limbs_modular_div_mod_schoolbook(&mut [10; 3], &mut [1, 2, 3], &[], 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_schoolbook_fail_2() {\n    let ds = &[1, 2, 3];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_mod_schoolbook(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_schoolbook_fail_3() {\n    let ds = &[1, 2];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_mod_schoolbook(&mut [], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_schoolbook_fail_4() {\n    let ds = &[4, 5];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_mod_schoolbook(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_modular_div_mod_divide_and_conquer() {\n    let test =\n        |qs_in: &[Limb], ns_in: &[Limb], ds: &[Limb], borrow, qs_out: &[Limb], ns_out: &[Limb]| {\n            let mut qs = qs_in.to_vec();\n            let mut ns = ns_in.to_vec();\n            let inverse = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n            assert_eq!(\n                limbs_modular_div_mod_divide_and_conquer(&mut qs, &mut ns, ds, inverse),\n                borrow\n            );\n            let q_len = ns.len() - ds.len();\n            assert_eq!(&qs[..q_len], qs_out);\n            assert_eq!(&ns[q_len..], ns_out);\n            verify_limbs_modular_div_mod(ns_in, ds, borrow, qs_out, ns_out);\n        };\n    // - q_len <= d_len\n    // - q_len < DC_BDIV_QR_THRESHOLD\n    // - q_len != d_len\n    test(&[10; 3], &[0, 0, 0], &[1, 2], false, &[0], &[0, 0]);\n    test(&[10; 3], &[1, 2, 3], &[1, 2], false, &[1], &[0, 3]);\n    test(\n        &[10; 3],\n        &[1, 2, 3],\n        &[5, 6],\n        true,\n        &[3435973837],\n        &[858993456, u32::MAX - 1],\n    );\n    test(&[10; 3], &[1, 2, 3, 4], &[1, 2, 3], false, &[1], &[0, 0, 4]);\n    test(\n        &[10; 3],\n        &[1, 2, 3, 4],\n        &[1, u32::MAX, 3],\n        false,\n        &[1],\n        &[3, u32::MAX, 3],\n    );\n    // - q_len == d_len\n    test(&[10; 4], &[0; 4], &[1, 0], false, &[0, 0], &[0, 0]);\n    // - q_len > d_len\n    // - q_len_mod_d_len < DC_BDIV_QR_THRESHOLD\n    // - q_len_mod_d_len != d_len\n    // - lo < DC_BDIV_QR_THRESHOLD in limbs_modular_div_mod_divide_and_conquer_helper\n    // - hi < DC_BDIV_QR_THRESHOLD in limbs_modular_div_mod_divide_and_conquer_helper\n    test(&[10; 5], &[0; 5], &[1, 0], false, &[0, 0, 0], &[0, 0]);\n    test(\n        &[10; 4],\n        &[1, 2, 3, 4],\n        &[5, 6],\n        true,\n        &[3435973837, 3607772528],\n        &[4123168602, u32::MAX - 1],\n    );\n    test(\n        &[10; 5],\n        &[1, 2, 3, 4, 5],\n        &[7, 8, 9],\n        false,\n        &[3067833783, 175304787],\n        &[1051828726, 2717224210, 4],\n    );\n    // - q_len_mod_d_len == d_len\n    test(\n        &[10; 6],\n        &[1, 2, 3, 4, 5, 6],\n        &[7, 8],\n        false,\n        &[3067833783, 175304787, 3481052211, 2770888938],\n        &[3602692266, 0],\n    );\n    // - q_len >= DC_BDIV_QR_THRESHOLD\n    test(\n        &[10; 111],\n        &[\n            238690007, 851362023, 2059930942, 863267985, 3076614342, 3047275605, 1421974480,\n            393459707, 388753961, 1307811244, 1724185886, 1342073382, 3451829757, 511726014,\n            460409053, 863948559, 755242682, 1610976003, 1095233439, 3983048866, 3486643678,\n            1487854845, 1830823553, 2167088595, 2000609352, 3778875209, 1877274219, 3295032048,\n            1477159538, 2048839778, 1451455912, 2109980052, 1750913495, 391343357, 3276142698,\n            2641970441, 1571798863, 2401599044, 1467594428, 2128234517, 3438746006, 227485655,\n            15222216, 256928874, 3095411638, 111550405, 2230139158, 531435393, 1299420097,\n            783687022, 3432104224, 1656185186, 3410451479, 1448536986, 1411134389, 3874476101,\n            2765514254, 2128294132, 3954579563, 2329369626, 3269515791, 3855344744, 1503334643,\n            1671855141, 3162383277, 1731111055, 3777334519, 1174367318, 1945392580, 966689109,\n            97441364, 1465255424, 1616147497, 1637231485, 1811763876, 2884209513, 3019238075,\n            1328651869, 840247524, 344122022, 795760234, 289967503, 616630287, 675829910,\n            2847875873, 2811380606, 2236228680, 4067593481, 2980091801, 2832971103, 2491091113,\n            1521816576, 4075571575, 2543360203, 935927249, 573194417, 1822073845, 1839465906,\n            3275095514,\n        ],\n        &[\n            2515301847, 3904775757, 133728302, 3903482605, 3523183307, 1531057916, 1011111105,\n            1204888196, 587552558, 2259844136, 2514432920, 3885615695, 1529240459, 2527102686,\n            1527502935, 3607833032, 3108651811, 1015333242, 2650209133, 499583440, 2106087248,\n            3218570602, 187468843, 2524810763, 3875472062, 3825849708, 2963555251, 2365237686,\n            2035410556, 3853326592, 2366649615, 757846500, 2808712542, 1010450631, 2537107077,\n            415304475, 2322781433, 1747200466, 3029815769, 2722060855, 3586580760, 2610036947,\n            2383069225, 1479189021, 3488202013, 3088351671, 2313154907, 1103886425, 3716175621,\n            1172908513,\n        ],\n        false,\n        &[\n            3119021825, 2664508330, 2031628331, 478764351, 1877838675, 14612131, 652799697,\n            1178144318, 581220955, 1647659598, 1352407033, 2397453730, 3102518439, 248362411,\n            760583238, 3183702428, 3503543471, 1633363102, 700510731, 2278494661, 3883161292,\n            2875693392, 778768718, 1830608772, 4092108024, 1084731936, 2636788137, 1618403943,\n            2120905188, 1304331644, 3129515489, 1701146314, 2248764147, 4096904357, 4179132986,\n            1285739406, 4084818677, 3908907080, 2892808133, 3130632865, 1541722253, 754313201,\n            49163159, 4048683373, 1840022468, 3666703478, 149207896, 1807686489, 529174445,\n        ],\n        &[\n            222246482, 233545700, 3332794578, 1998197261, 3881642604, 2334420680, 457729581,\n            1028684141, 1820939861, 393050552, 3364087427, 980919077, 215964517, 2941392816,\n            735903426, 707494399, 1663858662, 1254976633, 2324830169, 279707711, 2388586745,\n            1736265304, 1292267389, 1204103850, 1444415893, 646068967, 361893912, 1168453387,\n            4162569836, 37496928, 2388108126, 4045054107, 479165313, 2859008180, 3729669518,\n            790583185, 1990610890, 653432721, 4260517455, 1533264118, 4071210056, 1925491571,\n            2468006372, 1418208775, 3998441757, 2911027604, 1743255069, 4051022203, 3853317804,\n            3130583770,\n        ],\n    );\n    // - q_len_mod_d_len >= DC_BDIV_QR_THRESHOLD\n    test(\n        &[10; 172],\n        &[\n            119338358, 2430782482, 2540297421, 188973918, 3420087589, 1543598052, 1550450700,\n            3792047461, 889269407, 501191530, 2576798720, 2543454220, 3210031718, 485123386,\n            106926418, 550954803, 939577053, 4245574922, 3198319089, 3116005666, 2750993558,\n            1870348975, 1975807411, 1781898658, 487257459, 1417798881, 2833805593, 3259853663,\n            1497754962, 686849710, 2609757048, 3718757183, 57671149, 3248634542, 3521889134,\n            4157073590, 177642810, 2320627206, 3417728001, 301744109, 1374315478, 1156075184,\n            2442293407, 1057610827, 1297359181, 1747109539, 2141404099, 4281881065, 138386125,\n            3063455685, 3257890728, 3858193084, 3304890228, 238881307, 3445664438, 1185407578,\n            2888653737, 993706894, 1967766053, 127412966, 2403399672, 1285486798, 908290107,\n            1510442679, 4206401596, 3276759710, 11374285, 3959337953, 2236839585, 1565413293,\n            2800534730, 3519885942, 3614906874, 2633795417, 3347806654, 569358328, 2189946218,\n            1203262343, 2746982062, 62980684, 2586441066, 3124531637, 2381648646, 105584535,\n            2941906813, 4638308, 3536520384, 446015359, 345521288, 2337847433, 1716341197,\n            3434262596, 327360947, 2195093682, 1901891799, 2053064947, 1866727148, 1933602442,\n            1896991511, 2434864863, 2509221232, 4146560978, 1738009642, 1186271375, 1991440446,\n            388280769, 169881608, 3374872656, 4866502, 1578994123, 3894433257, 1685621086,\n            3090617712, 2446643244, 1027311466, 2913067733, 415217914, 206402492, 3701056394,\n            1797709466, 3451818053, 648910037, 1949755852, 3049709007, 1611096612, 271402178,\n            2578204568, 481131710, 1944796007, 2365170803, 32134309, 3750170475, 1864104146,\n            3460592883, 1303514890, 1133731290, 3830118297, 591382459, 3363797689, 3707044033,\n            3781009395, 1183270231, 3773122255, 3243748324, 3121647216, 3297073440,\n        ],\n        &[\n            1049478211, 680469795, 747349000, 2496192539, 3157275628, 2809929985, 1340573873,\n            2369546793, 2965031816, 1069643167, 3522649492, 82508657, 3745222809, 2653443896,\n            2691224863, 3638169243, 2790760129, 4050384292, 1236545914, 17769303, 3123357666,\n            3308586064, 230925596, 2288243675, 526850016, 3478799166, 1359885289, 375398501,\n            1996193928, 224867464, 3724522919, 3776621157, 1721777221, 1941498131, 1319934893,\n            335479091, 1206826435, 1008537741, 2525891651, 3027900562, 4088218789, 1755627645,\n            2151342900, 1492538444, 3337655012, 1349454, 757064511, 1793808978, 1243123906,\n        ],\n        false,\n        &[\n            3523610706, 4095718486, 1445432431, 1673437541, 4020367945, 3745015492, 3016399130,\n            2189565108, 2158132813, 1848828598, 2472767424, 878094830, 2680402548, 1260943793,\n            2476928489, 1177867634, 1646518182, 2946352334, 2967411271, 795570707, 2492588175,\n            1099595857, 2363747444, 2197221897, 2821893422, 2883961834, 3448280420, 786023016,\n            2349590684, 2639964406, 1547208182, 3946067756, 3185616768, 3182946836, 2191883192,\n            714873272, 792265815, 933013306, 2758420490, 3469512009, 2749660816, 1740114201,\n            1648303579, 1226176719, 4026247645, 894127522, 574096753, 1891430834, 2973532085,\n            944441129, 1683821712, 681573051, 3596769123, 1196189501, 2202034777, 1230292795,\n            3495428083, 3349595990, 3089151840, 3902324247, 1824847451, 783543484, 3845016445,\n            1815687272, 3454243, 2400067141, 2812607721, 1192925916, 2545803688, 4259913124,\n            2525790266, 1603659073, 2954188152, 3220648056, 4024945180, 1854165635, 2161271037,\n            517485723, 3238095654, 89843703, 3273382586, 3798028954, 1204973927, 2456421551,\n            1909094133, 2001850210, 3332598500, 2971871953, 2353788999, 1241071170, 422153499,\n            3611758239, 1771812426, 1704380646, 2934602124, 2834187644, 518477462,\n        ],\n        &[\n            266027871, 609493494, 1199784782, 1682700206, 4164056974, 2244647064, 14359526,\n            1914376228, 1643693158, 449364942, 41001758, 2790190796, 1578020376, 30923228,\n            2290083886, 793751679, 3951462642, 4187532857, 4144262715, 2260802306, 203413221,\n            3707574023, 576327919, 33186882, 2830664220, 3895250804, 3878634772, 2739709544,\n            1332976664, 1238738498, 2733771934, 2370719463, 1598734028, 1315681082, 1037147578,\n            3551458133, 3406603032, 2882741411, 196631076, 833893415, 1307502306, 2956084628,\n            3466863337, 682644819, 4092006006, 1963236296, 154386710, 1982810036, 3147006703,\n        ],\n    );\n    // - lo >= DC_BDIV_QR_THRESHOLD in limbs_modular_div_mod_divide_and_conquer_helper\n    // - hi >= DC_BDIV_QR_THRESHOLD in limbs_modular_div_mod_divide_and_conquer_helper\n    test(\n        &[10; 704],\n        &[\n            4185751770, 949164274, 3900519725, 1754790124, 2927570383, 1610053170, 3366859463,\n            1066429707, 3501570618, 2367440639, 2328634068, 3704221588, 2322372141, 3380520853,\n            4189820685, 485163788, 2195405920, 3117134592, 3277704486, 3921062791, 4106797055,\n            3045508412, 661029638, 2678369724, 1467681615, 1851814983, 2960522150, 2294339994,\n            489626124, 1242331300, 3385810062, 1149294828, 4088074806, 3724039365, 3770424399,\n            2493469584, 806372748, 3771669403, 1111232705, 3478087568, 4029774748, 3551452116,\n            3110587082, 2488974879, 47749858, 2223367929, 873250000, 2012398807, 1861118382,\n            2706639555, 2880844104, 1868093092, 3743135694, 4074318903, 2930806087, 2281983526,\n            1378855744, 3388340416, 3195092613, 3141388671, 3385803629, 2248154961, 716647719,\n            408786065, 4189607626, 2706804476, 392451433, 843831220, 2117893506, 3763769755,\n            2423989357, 1884254215, 4268634885, 1347756990, 4289680773, 1595972140, 1860322889,\n            3365907154, 654256963, 3331834702, 3229143368, 1643589278, 3268087485, 3428966374,\n            3734153935, 506918314, 2193830653, 1524006905, 2233546309, 2451094754, 983474066,\n            1062775683, 1398440782, 617471652, 233856640, 1491439739, 194893774, 404597210,\n            3349886938, 807897566, 1268209008, 3507741641, 434756682, 3067317419, 1955402334,\n            3598337478, 4236902625, 3345914967, 2108259867, 4199783792, 3533374250, 690146057,\n            2735070107, 3232842523, 3628050608, 139149260, 1670944793, 3256209787, 3411654393,\n            1946511496, 2082461349, 2746160530, 1671886353, 2094620437, 1492520252, 3287026452,\n            1499589769, 2631443030, 4265952385, 1560009101, 1665017895, 3582256582, 583800370,\n            1971617104, 1393694131, 1717803931, 2118915823, 606443859, 76766530, 1028659200,\n            3222396398, 491393514, 2650674330, 1420523709, 990196161, 4164467322, 955609751,\n            3658315631, 3108133206, 2441918819, 119215334, 1647135728, 1151329712, 2270557882,\n            2839636265, 1788114480, 953442631, 220077499, 3739679968, 289913489, 153493659,\n            2215060199, 654989994, 2506760104, 3263600596, 2504124177, 3901175056, 3815693428,\n            4062899928, 656080429, 1691317505, 2738892449, 2218799091, 254384726, 3472889999,\n            452028418, 2323167132, 3160160509, 2790465254, 3506704767, 920776279, 1555295659,\n            2088038090, 3587541031, 704460377, 41385058, 117178999, 3630755471, 2068346931,\n            1737173706, 943790911, 1174415673, 2975257119, 4104946893, 563605415, 3504496607,\n            3460311420, 3481281138, 2065638799, 222198878, 693087774, 2553540537, 3515067895,\n            493992216, 2675820307, 1624273500, 537035998, 1538452403, 227298276, 566431973,\n            3341420291, 2663602752, 849190806, 517998830, 674919319, 1319125805, 3230314450,\n            889723668, 3312911398, 2040926687, 1551018220, 217350907, 1190271637, 2196470418,\n            582739501, 574580675, 627521985, 3462620295, 1826546772, 1200183559, 2511667565,\n            3321520722, 1760501936, 3401858303, 2056315825, 2956669134, 591282350, 2228097677,\n            3953970187, 3763033846, 3981289762, 2843535951, 4035523339, 1074508115, 3233409639,\n            314820046, 1519729781, 1729078105, 4201604342, 3380921403, 2184949152, 2897857848,\n            212321156, 481361797, 3780255393, 2528871308, 2219779174, 3502413298, 2433932491,\n            2088433048, 1119465465, 553056530, 2681509152, 1990025128, 4113937421, 757723844,\n            4065055099, 1438167045, 1714067756, 295039437, 3553014346, 1500257339, 121711495,\n            1299814419, 1481787451, 466462561, 3450349124, 3354633040, 4197116852, 2300067620,\n            2300312798, 734816444, 668372087, 610325644, 1820480332, 312923552, 1371828336,\n            386480792, 3231465004, 2119854347, 2503795939, 37544982, 2127724350, 3977310867,\n            906274532, 3014798043, 1163507806, 39393504, 3203870929, 2603325424, 601940205,\n            1446813021, 4008328844, 1129836361, 2242436794, 1108252363, 710998579, 3822246787,\n            4245857572, 227662739, 3162273355, 2718012967, 512837928, 1146047591, 1624412382,\n            4172642116, 2479791213, 2246659717, 2115301250, 144504796, 3097248580, 1488044443,\n            3235358299, 310016185, 727752929, 3403555569, 1034814907, 572097587, 1799465727,\n            3315327068, 1904601168, 1060041227, 95653066, 3179621384, 2784606474, 3635929233,\n            3002198637,\n        ],\n        &[\n            925120207, 4225173411, 773590203, 2705088909, 760018119, 3560986781, 3276778645,\n            569879745, 275063826, 3553444079, 3591608936, 938243104, 3604596571, 1820901407,\n            4022554834, 1440792481, 574650989, 3656262710, 4150032702, 1559596409, 3960538469,\n            1809314494, 2152378256, 825148860, 2074258358, 2059483645, 3119970833, 3052492792,\n            1083432735, 2994856903, 3287600147, 2502703055, 1752688956, 4149576868, 1709984301,\n            3235915685, 487122947, 437538202, 3178502734, 1263854855, 135705911, 2843982074,\n            4164166971, 4100829511, 3031022541, 3201076966, 1805387578, 1826440600, 557213027,\n            2792934052, 2243352750, 1801883920, 3301321918, 469048417, 2725138727, 2947700289,\n            1913798124, 574678647, 2000040094, 2336849657, 3912194680, 1616490328, 2363261019,\n            3380210359, 2784609072, 835985245, 1062319853, 2519822447, 4185407058, 3253459482,\n            3240288702, 3425190358, 3392304118, 3339858917, 227057671, 2117867538, 1238503500,\n            1783611406, 1671436072, 4020871006, 3708283179, 1814419869, 2809845213, 402675383,\n            700520900, 4021715245, 3864091313, 1886661387, 2898624118, 2266154557, 1538350152,\n            4205425742, 2641391768, 3508390452, 202172288, 2270033614, 787751496, 4225843194,\n            2087465714, 718749793, 4160365132, 121686135, 3232242907, 1290170166, 2696610438,\n            2043913461, 2304403306,\n        ],\n        false,\n        &[\n            4221978630, 1973199499, 4118761517, 1280124308, 1169734844, 4186771056, 1549813668,\n            2075241811, 3420909216, 3907043806, 2541993804, 282548280, 1975129143, 3336674855,\n            4090776129, 2428071752, 3676342369, 3454430534, 316538936, 243907370, 2971927846,\n            251436476, 2221794683, 2822328444, 528428056, 1993265952, 3040794479, 4050913221,\n            2509817742, 2793009366, 3346235129, 4179770275, 1329386656, 3069305579, 422911051,\n            232216774, 3312143191, 81270597, 779322188, 1011095209, 1055038871, 1975842925,\n            1732790895, 733239904, 1557320335, 1710699531, 4221175046, 721245441, 2600219287,\n            1818367711, 1883945801, 1722730504, 3667715777, 3514130820, 2079744029, 4097159692,\n            8702783, 1634848318, 4003868364, 3189174634, 154328123, 3136083300, 1256793950,\n            3908958390, 3995938868, 3505295673, 15682981, 1733079452, 2199765868, 1399865418,\n            3931463027, 216129100, 1771409837, 4170117419, 2889309579, 1323366430, 3037738897,\n            3024721374, 3698031352, 1843487639, 2640258708, 2514361590, 67538017, 3752890769,\n            2377631023, 1117874819, 2034201383, 3233935115, 186520404, 1781753373, 2159589499,\n            1457819895, 1955947342, 3294618852, 2583537479, 1780703679, 1295362239, 4288927730,\n            3528770822, 290885828, 1022721043, 2379556752, 249111996, 1042924458, 3285072303,\n            1799654769, 341780256, 2011707698, 4011728901, 4131230694, 243833190, 3438825130,\n            732870287, 3977999178, 1964878050, 1772633237, 3427011489, 4149075167, 3147152113,\n            4186542306, 3008212122, 2269822538, 2457396003, 2899887041, 3084745386, 2805864858,\n            2636345155, 2806159180, 1448641497, 1724536998, 3602736476, 670315274, 821858587,\n            3976166693, 1431302113, 994517893, 3205096696, 734083218, 684810460, 871706632,\n            1619463495, 1943812284, 3232191634, 1688008439, 959671513, 861714098, 3632682856,\n            4008579961, 1713155910, 621038709, 2171689707, 16974992, 1322572013, 3716365836,\n            1503115330, 3655753010, 3148139022, 862756091, 2477797665, 1345732090, 2351929785,\n            4244479677, 3338662555, 590731935, 3482514189, 1766212776, 1514121012, 3065000224,\n            1126651654, 3402553599, 4032051831, 2997384063, 1732308544, 1185658163, 505658742,\n            12068286, 191037370, 3820036984, 1808669698, 4025106072, 1258717124, 2996770408,\n            104941276, 3293831485, 3303505858, 1959694112, 2104003029, 513795826, 682626035,\n            1611502331, 165846820, 3906438907, 2655225469, 1304471424, 2263663116, 2896749335,\n            2359126350, 2213606484, 1429710281, 2842535444, 2328001305, 1030529844, 72684272,\n            3885232193, 4190971495, 1802226099, 3077502465, 1399196074, 15975559, 1608426341,\n            2824610166, 3242678682, 97752959, 1141976170, 2545270306, 2934382174, 1423201353,\n            4009237774, 989437497, 3792380846, 2436069063, 101138334, 3054205179, 476518326,\n            45092653, 1388468856, 622609810, 3089605077, 273759253, 2522262643,\n        ],\n        &[\n            1326262193, 4033304858, 3860284891, 3270761392, 301590389, 3160950768, 2103051311,\n            421308210, 339700217, 2084975913, 4010857750, 3321647285, 2893234504, 3337934258,\n            2470197482, 3426298259, 3795587565, 2533784226, 1029322143, 2753534641, 1002751731,\n            1383277453, 1739180040, 4179121877, 686043541, 3404602754, 2524149226, 1961421140,\n            739626289, 50422302, 4167603214, 890939538, 544526709, 333127915, 1031745192,\n            2528526981, 2519624435, 2088255264, 2561443326, 3976592858, 1904453814, 37801928,\n            2483368030, 3723552401, 479916426, 2605772934, 4101701491, 2731241841, 516350289,\n            1540979081, 2317342783, 3699898529, 2962115900, 618662503, 360824901, 2483974833,\n            3444107029, 23562940, 1137290279, 793246641, 3743331916, 1726283098, 3569199524,\n            898653133, 4096842332, 1438551593, 32970915, 3426974921, 444732961, 724921875,\n            1414708840, 1717003917, 1924528246, 4171817847, 3372667246, 3830123695, 927406351,\n            2027580181, 1664983727, 2533132252, 1161370976, 2395800918, 1493087279, 3712645656,\n            216022641, 405129823, 437352819, 2790439088, 3977337552, 1902827120, 3057912539,\n            3003163486, 3875702633, 3752739451, 987987508, 2784338852, 840729416, 101169395,\n            3198958489, 4287799304, 1745316888, 3524003193, 1226093819, 3034997281, 714903529,\n            1035449811, 1648914672,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_divide_and_conquer_fail_1() {\n    limbs_modular_div_mod_divide_and_conquer(&mut [10; 3], &mut [1, 2, 3], &[], 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_divide_and_conquer_fail_2() {\n    let ds = &[1, 2, 3];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_mod_divide_and_conquer(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_divide_and_conquer_fail_3() {\n    let ds = &[1, 2];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_mod_divide_and_conquer(&mut [], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_divide_and_conquer_fail_4() {\n    let ds = &[4, 5];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_mod_divide_and_conquer(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[test]\nfn test_limbs_modular_div_mod_barrett() {\n    let test = |qs_in: &[Limb],\n                rs_in: &[Limb],\n                ns: &[Limb],\n                ds: &[Limb],\n                borrow,\n                qs_out: &[Limb],\n                rs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut rs = rs_in.to_vec();\n        let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n        assert_eq!(\n            limbs_modular_div_mod_barrett(&mut qs, &mut rs, ns, ds, &mut scratch),\n            borrow\n        );\n        let q_len = ns.len() - ds.len();\n        assert_eq!(&qs[..q_len], qs_out);\n        assert_eq!(&rs[..ds.len()], rs_out);\n        verify_limbs_modular_div_mod(ns, ds, borrow, qs_out, rs_out);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - in limbs_modular_div_mod_barrett_balanced\n        // - i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_modular_div_mod_barrett_balanced\n        // - q_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_modular_div_mod_barrett_balanced\n        // - carry in limbs_modular_div_mod_barrett_balanced\n        test(\n            &[10; 3],\n            &[10; 3],\n            &[0, 0, 0, 0],\n            &[1, 2],\n            false,\n            &[0, 0],\n            &[0, 0],\n        );\n        test(\n            &[10; 3],\n            &[10; 3],\n            &[1, 2, 3, 4],\n            &[1, 2],\n            false,\n            &[1, 0],\n            &[3, 4],\n        );\n        test(\n            &[10; 3],\n            &[10; 3],\n            &[1, 2, 3, 4],\n            &[5, 6],\n            true,\n            &[3435973837, 3607772528],\n            &[4123168602, u32::MAX - 1],\n        );\n        test(\n            &[10; 3],\n            &[10; 3],\n            &[1, 2, 3, 4, 5],\n            &[1, 2, 3],\n            false,\n            &[1, 0],\n            &[0, 4, 5],\n        );\n        test(\n            &[10; 3],\n            &[10; 3],\n            &[1, 2, 3, 4, 5],\n            &[1, u32::MAX, 3],\n            false,\n            &[1, 3],\n            &[2, 0xfffffff8, 4],\n        );\n        // - in limbs_modular_div_mod_barrett_unbalanced\n        // - q_len_s > i_len in limbs_modular_div_mod_barrett_unbalanced\n        // - i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in\n        //   limbs_modular_div_mod_barrett_unbalanced\n        // - d_len == i_len in limbs_modular_div_mod_barrett_unbalanced\n        // - q_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in\n        //   limbs_modular_div_mod_barrett_unbalanced\n        // - d_len != q_len_s in limbs_modular_div_mod_barrett_unbalanced\n        // - !carry second time in limbs_modular_div_mod_barrett_unbalanced\n        test(\n            &[10; 3],\n            &[10; 3],\n            &[1, 2, 3, 4, 5],\n            &[7, 8],\n            true,\n            &[3067833783, 175304787, 3481052211],\n            &[2216353382, u32::MAX - 1],\n        );\n        // - d_len == q_len_s in limbs_modular_div_mod_barrett_unbalanced\n        test(\n            &[10; 4],\n            &[10; 3],\n            &[1, 2, 3, 4, 5, 6],\n            &[7, 8],\n            false,\n            &[3067833783, 175304787, 3481052211, 2770888938],\n            &[3602692266, 0],\n        );\n        // - d_len != i_len in limbs_modular_div_mod_barrett_unbalanced\n        // - !carry first time in limbs_modular_div_mod_barrett_unbalanced\n        test(\n            &[10; 25],\n            &[10; 19],\n            &[\n                1055350223, 3049382586, 4211404571, 3876314835, 4079443157, 4038320272, 788805966,\n                3784408476, 1246213405, 2888182970, 2261017929, 1076053788, 2501863035, 4127455271,\n                4275509120, 2405873407, 595189898, 734988773, 472621924, 2174894187, 3899735108,\n                215445128, 1522826922, 2013231118, 2572793610, 3364892170, 1420194578, 2506221487,\n                667648088, 810748791, 2612101093, 2650289028, 4056901105, 2431350237, 37519423,\n                2017228158, 1313697295, 2715710214, 1734284446, 2882471675, 3715454439, 1236125406,\n                1443396768, 2933508364,\n            ],\n            &[\n                3663635511, 3774569147, 1456029034, 545218027, 3883722449, 4256811234, 4280475551,\n                446268340, 1439707019, 3006588287, 3015676595, 2251279938, 3776675540, 112585308,\n                2726538330, 1425601246, 1583649315, 3604979549, 1473232315,\n            ],\n            false,\n            &[\n                170063657, 2165570113, 2907518307, 1430243918, 2140749125, 3558893223, 2847072687,\n                4090009629, 4254439605, 2409969231, 3425274081, 4131046019, 2116325398, 2254079976,\n                4252966135, 2463907465, 580945345, 1823337423, 2340467621, 2110070789, 2620914623,\n                3150901076, 1253645171, 1967019766, 2932062934,\n            ],\n            &[\n                2089766457, 292821147, 3117586049, 1036271118, 2574097064, 1232271710, 1288296201,\n                2511496451, 3125977553, 2778795769, 2999224452, 1311965009, 225728039, 1754024341,\n                1242425483, 2864810952, 1157382204, 2754439417, 1927770818,\n            ],\n        );\n        // - carry second time in limbs_modular_div_mod_barrett_unbalanced\n        test(\n            &[10; 113],\n            &[10; 7],\n            &[\n                1780785185, 786171578, 3157515628, 1592442002, 3380766160, 2287562230, 715389251,\n                248693343, 1917127407, 3734172511, 318221247, 353404054, 770901771, 1185388775,\n                1026227030, 2159266648, 4115835732, 3372528053, 3300094046, 4237524737, 3734961305,\n                3971742075, 2838379294, 4275415020, 3696524563, 4195057627, 1748644269, 3938177066,\n                3720834606, 3725787789, 2343496907, 2973877655, 710152359, 3397267742, 2968876692,\n                2888566080, 4065287679, 2995290545, 355522630, 1240165026, 2600807130, 468290838,\n                38477660, 2658554572, 2915670343, 1795675394, 278501959, 1137682730, 3997261853,\n                34007068, 4160869696, 531258143, 1374216847, 1723957411, 277507095, 2287214710,\n                508149326, 2515464872, 1732728407, 258712591, 2285022762, 2447676003, 1262780680,\n                1199002631, 1579465944, 1049912517, 2621415467, 3593350728, 962641356, 1344046504,\n                137232829, 638490247, 3421265303, 2727821003, 2855549593, 827801261, 2202020535,\n                2322971763, 360280234, 840962056, 2736221025, 1257442332, 2541827007, 3410395173,\n                1257508164, 315829993, 2860519251, 3307878515, 1942955455, 1060223758, 1834897098,\n                2073690721, 43780026, 1410663879, 614961912, 2120543497, 2242462397, 2715797106,\n                2037137824, 1831803889, 30458973, 707478969, 1483765857, 206823596, 726188538,\n                4064151055, 1331924582, 2159077308, 299368864, 644097902, 1927782610, 1274113091,\n                780909329, 3276588176, 2622376275, 1944908892, 1548718985, 1478198552, 167729486,\n                2805305447,\n            ],\n            &[2712529337, 3550254038, 912173613, 3471575420, 1584706027, 4183294179, 2032726108],\n            false,\n            &[\n                2145811881, 2853684621, 164754117, 3675200822, 3263953060, 540174416, 540344644,\n                3117220624, 74272150, 2433930443, 2738006052, 2816255289, 2203418744, 911786820,\n                3177797500, 1226409737, 3793898412, 403951736, 2441100417, 2633166493, 3446817232,\n                345329148, 3098851660, 941805631, 3993664945, 1275632198, 508337323, 839461454,\n                1530627916, 271645050, 1670009911, 3116428377, 3731487849, 2293244083, 917189423,\n                1772472525, 3599863118, 187105349, 2474067907, 2795120425, 630120186, 3544350690,\n                3629527923, 759676403, 199697033, 729268782, 314351667, 1979650537, 528328059,\n                1369356989, 4006685949, 3314502758, 3919641191, 1499885293, 1421775739, 4058709376,\n                549255670, 2433522610, 194681592, 1941767539, 3859348464, 2757354972, 2081397265,\n                1728594419, 1355471243, 605531861, 3102620513, 2633037944, 2567352331, 2289344558,\n                1636097668, 2472013149, 1966694756, 3680045927, 3351623316, 3953479661, 1034435973,\n                2559556196, 2727941371, 996730585, 3729767953, 2471327060, 4216682881, 1386133884,\n                3545016228, 2025097022, 2150272500, 2943616975, 4160651382, 4095528727, 3654689124,\n                2442799685, 2211976583, 3869553045, 169899811, 1764168626, 2153322769, 2927176214,\n                3196475524, 1798404841, 220326463, 216721343, 2602454439, 1608608695, 2299642725,\n                685786805, 2299002959, 3664589029, 1143480179, 1493337062, 3847260732, 2243223380,\n                1914898063,\n            ],\n            &[2336930396, 3906180555, 3405422945, 1687575114, 2055613801, 3816276157, 1899020713],\n        );\n        // - carry first time in limbs_modular_div_mod_barrett_unbalanced\n        test(\n            &[10; 210],\n            &[10; 19],\n            &[\n                2957922040, 870247152, 910873828, 2706667305, 2006892424, 1634563813, 287970711,\n                1133803930, 961388798, 2714428017, 4030274882, 3138804883, 547887122, 1780655515,\n                2754780720, 2058686138, 2291641774, 1741543525, 2246044650, 933209107, 4004027900,\n                3379557691, 266017900, 2676189357, 1591355793, 3361078936, 2211217877, 2921128900,\n                1828179459, 1074012967, 43100052, 2836201490, 1311232425, 4155464115, 1757143636,\n                1277755008, 1485841251, 3152888554, 583586772, 3806098743, 782964212, 3226263583,\n                1162123370, 3059562578, 2860980942, 479696604, 2270702751, 75758186, 2277793459,\n                2408711142, 2815967312, 232354809, 1421580147, 108234715, 3286460793, 841443270,\n                1825464019, 3954173086, 4046395553, 1749247097, 1093808724, 3438517259, 359669614,\n                601658924, 1342170297, 1428604227, 182377350, 2587642660, 4286173557, 1885226635,\n                3025582699, 3966955161, 1368652640, 1973817988, 672984222, 1170853285, 4036364126,\n                2637166249, 2697845360, 3566541779, 376105455, 3942586561, 2215680833, 2746461408,\n                2651245592, 760249496, 3897056740, 2058897545, 1283445246, 3868587627, 2438849073,\n                4047410037, 3367521161, 675390171, 775086206, 3438960005, 144798590, 3473698909,\n                836037579, 2050195295, 2470811574, 1614292177, 357128906, 2374914894, 979884995,\n                1299595291, 3731376453, 1227867350, 3881033174, 3084409704, 409188904, 4138760620,\n                4274774539, 1698773036, 3894254462, 3016352503, 1333890087, 2095418435, 3153732455,\n                2176884950, 3593733835, 3605051893, 3005410021, 3887509669, 1018183006, 2630850017,\n                2235284844, 98727747, 3537572449, 1659151250, 1804358600, 886148381, 3364035538,\n                3284706688, 3368127755, 613336882, 2099319807, 2400145286, 2228643956, 2297667468,\n                3984708746, 1630727280, 1283416474, 2286105322, 1331586489, 375863143, 2336260394,\n                379345862, 1592268783, 421930024, 791870237, 34696659, 2830390144, 1045783073,\n                2327165333, 3737840283, 4280928327, 1608634581, 821500409, 2477616696, 748075940,\n                2898867500, 2810718701, 680766084, 1706513434, 2559362270, 2907012739, 557079510,\n                761670334, 2936564915, 2799140450, 263855902, 83724051, 3113029528, 710433489,\n                63647540, 2392860382, 2849685609, 2191113984, 3344692166, 3650051957, 1283783144,\n                679051425, 1874499366, 2982158115, 2233164876, 1068193514, 169526123, 124050420,\n                2254129164, 3129272672, 3748280701, 2962809382, 2925481293, 3971297350, 343974506,\n                1952488808, 298193824, 3111608248, 3842844698, 1134548982, 2796565349, 439974096,\n                661703453, 1670489521, 1331486799, 3296145757, 3970474581, 3498762865, 838199092,\n                3353634107, 1628665432, 439108122, 3585259826, 3022889712, 1940250559, 79233496,\n                1912286078, 4232848205, 2352720259, 952267727, 1536903505, 39209222, 3912743975,\n                3928334222, 2718037985, 1489352573, 2765707939, 598657491,\n            ],\n            &[\n                4281128173, 3027906753, 2001755931, 2775065157, 1187751336, 596325169, 2779056912,\n                170261384, 831473261, 3013867871, 518058824, 3100518656, 3459929010, 2119404241,\n                1145055308, 743036299, 35681442, 2984784309, 2394592752,\n            ],\n            false,\n            &[\n                3545195480, 2830193270, 335420053, 794287831, 2741916634, 2863209122, 3474537493,\n                756302532, 2390999417, 4294477763, 1189935988, 1859141045, 2587320393, 948338846,\n                4082107915, 2964828974, 2707598527, 3327111998, 3063462536, 2651416679, 905396265,\n                2388020551, 593710429, 449874296, 2226775585, 7979097, 1540449503, 3250233597,\n                1312158539, 1991615641, 335908038, 3520510682, 2746466872, 914186511, 1932273631,\n                861083548, 3035810408, 2344742126, 659982098, 2860585760, 2634369596, 2813832754,\n                3952630841, 2075380109, 309440464, 1523149574, 3192186814, 999974815, 2341598038,\n                3017399438, 862035203, 4054680737, 2201990712, 397181202, 1647559963, 1267523856,\n                1199238444, 3731680308, 3790641117, 709354153, 2258539734, 1749483122, 2853840203,\n                1578892991, 2727550048, 2884219240, 3732650659, 2280125842, 2227946823, 2743139282,\n                150244596, 3009923444, 4262641312, 2587401277, 1068934326, 2162268682, 500752745,\n                2478246253, 657149362, 727272162, 1138165722, 3053293624, 622175917, 1883556266,\n                995622659, 3180371798, 2641139734, 636602958, 3974225725, 643270566, 3594175694,\n                1815151046, 181929979, 634258268, 1988561038, 1406268435, 1255929703, 2047200162,\n                327297893, 2089111137, 2465221310, 1515525444, 2651009463, 1627761087, 2816949718,\n                371898069, 3623581394, 2408374459, 852283718, 743629996, 1406343073, 1288623951,\n                1390517443, 3612531871, 1908188719, 20588564, 1991288974, 2134681310, 3976054820,\n                2112398386, 2742074585, 2223277780, 2566567369, 4161267340, 3521909307, 2707583513,\n                771440763, 2374943346, 3684262675, 3129700156, 1702004952, 3829866647, 2745914165,\n                544083442, 3125630973, 3396214384, 3490241400, 3855124301, 1918091363, 2827032159,\n                1870456944, 3090227886, 3351449380, 3758213391, 1013018528, 2291181284, 3221497475,\n                880874956, 4157883302, 3310385525, 1659149070, 1344782497, 1930681950, 237809822,\n                665463528, 2594721127, 3171089793, 17771920, 3012888524, 986806237, 1721541891,\n                203322900, 2850993174, 2812942792, 3291016822, 793893217, 3551981739, 3725150196,\n                3904109269, 908950595, 3445210635, 1732434801, 136778475, 4020163671, 2911572158,\n                2619712085, 695817951, 2564865838, 2683591409, 4128013969, 204856464, 3938011158,\n                472034484, 2799987675, 4277430554, 1053828060, 2996826767, 1330644500, 1181151222,\n                787673069, 1532990849, 432834735, 4011003718, 248480909, 3771359672, 316592679,\n                2847657270, 634291083, 1350943800, 1122137552, 489179352, 3994078723, 852486950,\n                2165215099, 624250642, 3818338360, 4277937938, 3825066593, 1697585856, 845743932,\n            ],\n            &[\n                1692999357, 2954880473, 990817610, 3627848867, 604557740, 926149699, 3727741567,\n                705168250, 257141873, 2721173810, 2517358846, 2668361786, 1527518030, 3882089664,\n                221121460, 921437873, 2477571204, 1545760534, 127126010,\n            ],\n        );\n        // - carry in limbs_modular_div_mod_barrett_balanced\n        test(\n            &[10; 6],\n            &[10; 8],\n            &[\n                1374494479, 2192068018, 2880324652, 42688047, 1794508871, 4043622026, 2888818532,\n                3570449488, 135909991, 1834703233, 99771521, 2930887574, 605577774, 1011468183,\n            ],\n            &[\n                2460992677, 1140036614, 1658868868, 366747528, 1860201147, 2709920888, 1959763964,\n                1863179050,\n            ],\n            true,\n            &[776020643, 407209981, 1979624516, 357370108, 1022326398, 2383287252],\n            &[\n                2671332979, 918397726, 698873472, 823603187, 3540180412, 56598308, 2177764749,\n                4272553129,\n            ],\n        );\n        // - i_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in\n        //   limbs_modular_div_mod_barrett_unbalanced\n        // - d_len + i_len > mul_size in limbs_modular_div_mod_barrett_unbalanced\n        // - q_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in\n        //   limbs_modular_div_mod_barrett_unbalanced\n        // - d_len + q_len_s > mul_size in limbs_modular_div_mod_barrett_unbalanced\n        test(\n            &[10; 139],\n            &[10; 84],\n            &[\n                2646628784, 618896692, 3398943402, 3264540707, 1504960063, 3906164607, 570941654,\n                3580995164, 1443736701, 3590824971, 3860070111, 2945656477, 4251307330, 2402685539,\n                1846137259, 1189307444, 3386646133, 136368423, 249459846, 784663226, 4146072344,\n                2595677890, 733424230, 3453504236, 88571396, 749579536, 918695180, 1666773246,\n                4177391250, 4175984066, 2859904653, 3320165100, 314964734, 1227587574, 2960770677,\n                2399848571, 430617262, 138749172, 3397335244, 100239326, 1527324818, 3102878375,\n                3902410462, 3147053920, 2748042023, 2424421132, 1052940357, 986705203, 3463928015,\n                2137344177, 1023713259, 1900812309, 1091750798, 1033535614, 1704349724, 1274392095,\n                4220281689, 2312523638, 2550288105, 1603152422, 2468778401, 2362990259, 1771954100,\n                2226726386, 2256260198, 1919957004, 3125206342, 1705043648, 275322946, 1578653828,\n                3244824726, 568760497, 2157867085, 3722151892, 982962005, 2605569069, 3011932580,\n                555973834, 3850227878, 1840125026, 859902026, 3226837879, 803396279, 4091669116,\n                3502825211, 2705549345, 2355778569, 2472138162, 2501828872, 1716056509, 2461082272,\n                3407718600, 2048730354, 2754501598, 81705455, 2613874586, 3616438498, 743457455,\n                866447928, 1549437857, 2823907456, 216297612, 4292914429, 4033666199, 449146474,\n                3154061115, 452155000, 160006622, 658415472, 480293619, 2568541254, 523346876,\n                1123518434, 782900648, 4045385592, 969181715, 2603815504, 1562047677, 413762781,\n                164584514, 3971139354, 389543933, 3094350891, 3173761159, 3798939769, 3469659030,\n                2945777042, 2994242422, 3136151730, 2486286949, 2988445086, 1260050525, 1171382725,\n                1867967284, 302235847, 1042890122, 3608326628, 2275778352, 1767146951, 2944622700,\n                2789083247, 4141708171, 1551586595, 3621216040, 2781452047, 1405040348, 1672588153,\n                14666875, 2647122819, 3187518016, 2279001686, 1938063779, 1875081978, 4251256078,\n                2572448523, 3800192906, 1289906739, 2632255896, 2152286481, 3897576094, 1708421957,\n                4073852972, 3476212556, 1875655706, 3865408865, 1201794786, 4216156085, 1050577862,\n                472506848, 2553269926, 840961926, 2090709561, 2675996462, 2446149597, 833756615,\n                1758241617, 2274654294, 2386883401, 449558962, 1197625280, 3018484457, 1526642077,\n                2525115961, 1104794510, 4179539512, 2334981542, 1704190014, 4245163918, 821915893,\n                2958170015, 709350427, 728990040, 1687853788, 786779220, 3852055852, 1751071670,\n                3041460477, 352348239, 1868210536, 3695502625, 830421334, 235096442, 19032492,\n                3460387365, 2186466609, 161794199, 2560621452, 1382113822, 606335634, 2333561107,\n                1707370336, 2209093163, 2998828734, 917854441, 1572665439, 1169967127, 912392167,\n                3799501844, 3071223299, 3987504849, 3355880904, 567811128, 949461215,\n            ],\n            &[\n                175531285, 78228064, 2801564496, 304265049, 891912354, 3315401569, 1026356408,\n                3942470248, 2223627569, 408866608, 2002970320, 4044159622, 3481083399, 1214787196,\n                4080970297, 855215497, 2843678654, 1991914207, 835424234, 3258509780, 1749412212,\n                3777869951, 1129376847, 3137205020, 1400979858, 3150368514, 3165530001, 2207061983,\n                1161753389, 803214774, 3625753632, 590750112, 259965773, 1326162274, 2653188614,\n                26451591, 1562785702, 1235742790, 3331276450, 9510804, 4278241988, 3727506800,\n                2781712221, 543113252, 380099502, 710412699, 905024784, 187278197, 587009259,\n                1508184302, 2414129863, 4152465703, 2161022364, 4124396813, 2190629393, 906688385,\n                102547773, 3659658175, 1420753856, 3400522400, 3636743612, 1520808959, 4198488051,\n                2115490366, 1371548286, 1292662256, 1069684821, 2485205762, 3559685229, 2961412573,\n                847483721, 410608408, 3530014382, 413744145, 1193871608, 3152782990, 1690455930,\n                233301503, 547904857, 2335968082, 845227807, 2094174869, 2149532553, 2291269465,\n            ],\n            true,\n            &[\n                2546777840, 2081991539, 2509769500, 1875915406, 1905948192, 602689312, 3268538198,\n                613162535, 1767316190, 3835834564, 2622706926, 3323532817, 374980976, 3111700826,\n                936860640, 2413052605, 2407595201, 278465408, 3314744140, 4091514460, 2110199799,\n                117453367, 1530925758, 309474103, 1279578725, 70909593, 1326551758, 2779708349,\n                3712869410, 1897725706, 705261972, 1824847489, 1691398432, 3209177026, 1020273962,\n                1167724900, 2567174051, 4116130680, 3208103429, 760573618, 782808697, 2745346818,\n                2496095329, 2811545307, 3946467709, 2483594659, 959341815, 4137660153, 997566470,\n                1730965450, 4089641998, 4267066391, 2858661809, 600039749, 1399987501, 506879518,\n                1186751467, 302620911, 2812551403, 3007055905, 303564811, 4286826331, 788916190,\n                2719882990, 4258512233, 1028190872, 1114024691, 3514649924, 3727249082, 841848367,\n                3084474590, 1059371415, 2166678521, 1581100579, 2950580743, 1574625618, 1082144357,\n                2521093167, 1048084761, 31290854, 2524741152, 808554579, 3189810605, 2992968319,\n                243265975, 603472290, 2860489763, 2101153718, 2034388432, 3710181854, 111490823,\n                1160951531, 1727109115, 746190508, 1539058660, 2839040461, 859789905, 1109658141,\n                2693429224, 364552289, 3793037740, 2280420170, 2901284656, 1614139914, 2372237091,\n                3487857543, 3345177295, 3288910636, 1737015121, 2590600286, 724573974, 197769707,\n                3550689133, 2635427825, 2347968548, 3296511750, 2601097680, 1138768331, 4046279289,\n                2437184198, 938543525, 1764278559, 1965551605, 514794004, 2192820822, 206655186,\n                3857560265, 1879744272, 1999335571, 3017015326, 3516909563, 421663640, 3063628317,\n                60413188, 359364666, 2997260220, 3206275809, 1623244265, 2111620703,\n            ],\n            &[\n                3415280693, 292226959, 592874699, 3763036729, 1688416787, 1967588907, 1135297545,\n                300526407, 488749755, 1494683603, 3165003011, 4282144535, 2476794373, 1988031229,\n                913525083, 454665488, 4180669379, 3576137622, 467981361, 2124275570, 3315398077,\n                2017816700, 2870440357, 2701664661, 2420523946, 2114772415, 3454473078, 3959609658,\n                1750896866, 3529048766, 2526439800, 734193874, 3225577122, 1983738086, 1618614567,\n                4019248755, 1615177076, 1150622424, 2861553604, 317586884, 2084839958, 109391139,\n                4199849234, 407061349, 413639713, 161276082, 1826515215, 462920784, 2166692927,\n                1121252881, 2339049969, 3097449182, 1750060809, 1304728762, 2057029243, 4030798175,\n                3626590369, 3782070983, 103174900, 2174112267, 3202455482, 1120937734, 162805295,\n                2459403827, 1438730035, 1398853228, 3980589931, 411009274, 295760150, 835365008,\n                2046227916, 2834161547, 3061448231, 1463103212, 2485431474, 3580658208, 2859008315,\n                864196777, 1789864771, 1239143610, 84264026, 1385174506, 806629248, 4117925861,\n            ],\n        );\n        // - i_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in\n        //   limbs_modular_div_mod_barrett_balanced\n        // - d_len + i_len > mul_size in limbs_modular_div_mod_barrett_balanced\n        // - q_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in\n        //   limbs_modular_div_mod_barrett_balanced\n        // - d_len + q_len_s > mul_size in limbs_modular_div_mod_barrett_balanced\n        test(\n            &[10; 101],\n            &[10; 102],\n            &[\n                359503822, 930755077, 1384939963, 726523519, 735855137, 4230638458, 2518447149,\n                3461004289, 1461342994, 3713880403, 1117118383, 2325203080, 2382674090, 2102380477,\n                2949789537, 2703453484, 86306444, 2133711224, 4243514322, 2016200957, 2466844919,\n                2791971265, 1678349265, 503608099, 3435266102, 4137444085, 937001532, 485586778,\n                2181285770, 4154702612, 3835162797, 4047003407, 3104468273, 2789877216, 2555048214,\n                312826773, 2193261799, 1490099020, 995118624, 4053513367, 342560776, 1032986831,\n                1842962421, 1301135762, 1524809911, 902292378, 1239258361, 88884962, 1144616285,\n                1492178819, 420992757, 519709698, 2442073331, 1884369937, 26045701, 1835589285,\n                2189835185, 2439987082, 3707057329, 2082610449, 999299935, 1541780167, 1690776984,\n                112340575, 1698317092, 1643561123, 3408357912, 3288699838, 2673112056, 2870952889,\n                3681616841, 2531108070, 1640007944, 506062406, 3401691507, 3344023372, 853239077,\n                4105040843, 2886461869, 3452820566, 1667819286, 3128286539, 2625300568, 1756006991,\n                3341301070, 1308108861, 1414362786, 2458021424, 9934651, 3098138015, 3107892925,\n                2498445889, 3830361110, 379544259, 2568097985, 2246190918, 2856152801, 384822350,\n                1724512815, 3991713640, 3817037833, 3722412510, 2895114053, 2728589301, 19358989,\n                3717195474, 1165862612, 2362092950, 828816743, 2052326574, 2217965628, 2673072144,\n                324120214, 1340520493, 3213377932, 3674602689, 1059080299, 824464261, 2585132071,\n                1440667471, 392712257, 3280116872, 2202169969, 398134473, 1073083450, 2311392108,\n                3823195150, 3284957997, 2227733574, 1303704641, 1615356863, 3190573039, 2485032610,\n                3180590299, 2042457445, 308852594, 690284549, 3598835432, 511022704, 3497853857,\n                659940084, 1641894511, 783187155, 2292526793, 562512416, 1637241073, 1083958605,\n                4163240058, 604721442, 3780983693, 2998951985, 2603228801, 463730318, 1015654434,\n                2651982477, 4118206282, 512096013, 1080397248, 101189089, 2863689109, 354738858,\n                1787339697, 2232290920, 534759005, 2119002163, 3794431325, 232343840, 2486173117,\n                68089103, 2140825959, 2555962430, 2890402101, 2413815707, 1672311294, 2499213554,\n                3468248781, 871538482, 2596129344, 531624012, 2504774829, 1221872721, 1208930227,\n                3557575767, 3709013124, 1698819786, 4123261656, 4065987239, 1688610525, 1294770319,\n                2785995745, 4198307858, 2777810428, 2269402709, 3351492035, 1694111420, 3998731057,\n                2900253048, 1205651103, 396770736, 696872604, 1384642173, 3321829462, 289627277,\n            ],\n            &[\n                2278424439, 3077751259, 1304585622, 1987828284, 3483676582, 456771916, 1922279346,\n                2709541120, 2656843747, 12978767, 316240098, 3536722689, 548385414, 724002627,\n                2476881616, 2166507279, 202171725, 1147560006, 1880112538, 1756777728, 1508901890,\n                1237270434, 2343198647, 2028182871, 1956050418, 3185234762, 2726786236, 1226215383,\n                3283321503, 3550779054, 3962623185, 2233581072, 3685362689, 2523061304, 3432992352,\n                856774698, 642855332, 1539603917, 3436254526, 3438316948, 3678354762, 2885957136,\n                638778530, 3855571391, 738420174, 1718985865, 3616901246, 1722694230, 1556281305,\n                3363415828, 3883725652, 1233902038, 492256678, 810883596, 2933458617, 2930892677,\n                3831374672, 3234208811, 4293259190, 2352386302, 3873041439, 997918588, 2424427679,\n                2782564963, 1728191643, 3952822243, 238626071, 1035613084, 542308994, 2994827340,\n                1113278284, 841529778, 4170703109, 3414455081, 896207174, 1979954113, 2035511039,\n                85618777, 2727640652, 1344449047, 3337583835, 3623474070, 3820508255, 635242386,\n                1085332469, 711665582, 1681624716, 2455915902, 2126072253, 2798572817, 1776815147,\n                453484, 3038980850, 1347504630, 372275114, 403210354, 3868566120, 3631747289,\n                3548627910, 3178868797, 3753938571, 150270533,\n            ],\n            false,\n            &[\n                3465160226, 1253419105, 3124808467, 751085507, 3110124395, 407173395, 2437959899,\n                4040430705, 2411492979, 2914523482, 3840204125, 319435997, 3999044619, 4145842866,\n                3512313567, 1166909167, 2317449476, 3701079118, 126559811, 90896448, 1455026859,\n                2191225041, 3229561661, 1343784046, 2969703260, 2878543582, 273951576, 4116117584,\n                781734515, 1973696951, 3647673909, 1542403693, 2180800305, 617680099, 300639543,\n                1558155610, 1182878845, 3865689017, 1416306973, 198512632, 2832322478, 3504115888,\n                1419290744, 3178356971, 3900449515, 199561130, 64886902, 3940732115, 3447589634,\n                1832464907, 1574927461, 435919088, 4113254992, 3460547477, 513876119, 1205361386,\n                3044966276, 2248267594, 3776615277, 3623228612, 3932766400, 1166892513, 291542906,\n                218374345, 4239344438, 2778233019, 1936059236, 1477081525, 1164400965, 3635983219,\n                4153675354, 3092149950, 937401074, 1818500930, 3870615142, 85247866, 3236546484,\n                3254512410, 3962391971, 2922578976, 95454893, 3077617251, 1113587582, 2603242994,\n                1807246933, 2202312525, 1989071615, 2769213474, 3776552472, 3043026852, 1891888557,\n                3886288480, 2532140003, 2035601305, 2317402048, 606214956, 4160105394, 3090211730,\n                1733339611, 926487350, 965806220,\n            ],\n            &[\n                3221267380, 424988678, 3461740599, 99497455, 420198800, 867051773, 2503641458,\n                2356910464, 401890558, 3995226265, 1173135914, 569117494, 4292931100, 2799167928,\n                2695949014, 899794022, 3039093573, 892570103, 1937446217, 2096306730, 3092703233,\n                541614723, 1040631696, 3029761757, 2957844148, 1645807647, 291224988, 2152250183,\n                1826147730, 3034872166, 3287666699, 1640543162, 3730948302, 1919958117, 1401704167,\n                1823651835, 2352158907, 1673084692, 4217391492, 2392397767, 1316530687, 1884365084,\n                1664508764, 1242497742, 1700540913, 3262218786, 1465845111, 1581184944, 4138608221,\n                3316745971, 4068716277, 1099430011, 3708438587, 2390739279, 2810494457, 2750115918,\n                1906243889, 3659100604, 3033098071, 4226373414, 3983457187, 609871527, 3791925678,\n                404663530, 1206366873, 3160414140, 388713457, 2942486656, 2004345881, 3595245692,\n                2542300575, 2795641800, 2424368091, 424084901, 3116448977, 3602081167, 4024353039,\n                1210988544, 3034081293, 957423016, 1582447550, 3269802842, 1711116416, 3752601257,\n                296665184, 437398155, 285377319, 623507510, 1699111470, 132189609, 500420363,\n                3184770686, 2323445041, 2548878469, 2747066033, 3915257708, 3792192004, 1406510909,\n                2945427566, 210394923, 1847865361, 255836050,\n            ],\n        );\n        // - d_len + i_len <= mul_size in limbs_modular_div_mod_barrett_balanced\n        // - d_len + q_len_s <= mul_size in limbs_modular_div_mod_barrett_balanced\n        test(\n            &[10; 90],\n            &[10; 1294],\n            &rle_decode(&[\n                (0, 60),\n                (4294966784, 1),\n                (u32::MAX, 246),\n                (65535, 1),\n                (0, 295),\n                (3221225472, 1),\n                (u32::MAX, 35),\n                (31, 1),\n                (0, 181),\n                (4294967292, 1),\n                (u32::MAX, 64),\n                (7, 1),\n                (0, 20),\n                (4293918720, 1),\n                (u32::MAX, 143),\n                (4095, 1),\n                (0, 225),\n                (4292870144, 1),\n                (u32::MAX, 106),\n            ]),\n            &rle_decode(&[\n                (u32::MAX, 558),\n                (31, 1),\n                (0, 72),\n                (4294967288, 1),\n                (u32::MAX, 110),\n                (127, 1),\n                (0, 435),\n                (4261412864, 1),\n                (u32::MAX, 115),\n            ]),\n            false,\n            &[\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0,\n            ],\n            &rle_decode(&[\n                (0, 217),\n                (65536, 1),\n                (0, 295),\n                (3221225472, 1),\n                (u32::MAX, 14),\n                (4294950911, 1),\n                (u32::MAX, 20),\n                (31, 1),\n                (0, 51),\n                (4096, 1),\n                (0, 110),\n                (4294901760, 1),\n                (u32::MAX, 18),\n                (4294967291, 1),\n                (u32::MAX, 64),\n                (7, 1),\n                (0, 20),\n                (4293918720, 1),\n                (u32::MAX, 143),\n                (4095, 1),\n                (0, 187),\n                (4, 1),\n                (0, 37),\n                (4292870144, 1),\n                (u32::MAX, 76),\n                (4294966783, 1),\n                (u32::MAX, 29),\n            ]),\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[10; 595],\n            &[10; 731],\n            &rle_decode(&[\n                (u64::MAX, 51),\n                (9007199254740991, 1),\n                (0, 346),\n                (18446603336221196288, 1),\n                (u64::MAX, 39),\n                (127, 1),\n                (0, 170),\n                (18446743798831644672, 1),\n                (u64::MAX, 380),\n                (8191, 1),\n                (0, 224),\n                (18446744073709551488, 1),\n                (u64::MAX, 110),\n            ]),\n            &rle_decode(&[\n                (u64::MAX, 183),\n                (1048575, 1),\n                (0, 4),\n                (18446744071562067968, 1),\n                (u64::MAX, 206),\n                (134217727, 1),\n                (0, 130),\n                (18446744072635809792, 1),\n                (u64::MAX, 204),\n            ]),\n            false,\n            &rle_decode(&[\n                (1, 1),\n                (0, 50),\n                (18437736874454810624, 1),\n                (u64::MAX, 131),\n                (1048575, 1),\n                (0, 4),\n                (18446744071562067968, 1),\n                (u64::MAX, 46),\n                (18446744073709551103, 1),\n                (u64::MAX, 4),\n                (1048575, 1),\n                (0, 125),\n                (1099511627776, 1),\n                (0, 4),\n                (18442240474082181120, 1),\n                (u64::MAX, 4),\n                (4611686018427387903, 1),\n                (0, 18),\n                (134217728, 1),\n                (0, 2),\n                (140737488355328, 1),\n                (0, 19),\n                (18446744073172680704, 1),\n                (u64::MAX, 4),\n                (2199023255551, 1),\n                (0, 4),\n                (18444492273895866368, 1),\n                (u64::MAX, 9),\n                (18446744073709551487, 1),\n                (u64::MAX, 8),\n                (18446744073709486079, 1),\n                (u64::MAX, 78),\n                (18446744072635809791, 1),\n                (u64::MAX, 22),\n                (1152921504606846975, 1),\n                (0, 5),\n                (18446744073709551232, 1),\n                (u64::MAX, 4),\n                (786431, 1),\n                (0, 4),\n                (18446744073172680704, 1),\n                (u64::MAX, 12),\n                (281474977234943, 1),\n                (0, 3),\n                (8, 1),\n                (17870283321406128128, 1),\n                (u64::MAX, 3),\n                (18446744073709535231, 1),\n                (u64::MAX, 7),\n            ]),\n            &rle_decode(&[\n                (1, 1),\n                (0, 5),\n                (562949953421312, 1),\n                (0, 4),\n                (14987979559889010688, 1),\n                (u64::MAX, 2),\n                (18446743798831644671, 1),\n                (u64::MAX, 2),\n                (383, 1),\n                (0, 4),\n                (18446744073709289472, 1),\n                (u64::MAX, 3),\n                (134217727, 1),\n                (0, 4),\n                (18446743798831644672, 1),\n                (u64::MAX, 3),\n                (137438953471, 1),\n                (0, 4),\n                (18446462598732840960, 1),\n                (u64::MAX, 73),\n                (2251799813685247, 1),\n                (0, 4),\n                (13835058055282163712, 1),\n                (u64::MAX, 16),\n                (18446744073709551614, 1),\n                (u64::MAX, 1),\n                (18446744073709486079, 1),\n                (u64::MAX, 4),\n                (536870911, 1),\n                (0, 4),\n                (18446742424442109952, 1),\n                (u64::MAX, 4),\n                (2251799813685247, 1),\n                (0, 4),\n                (17293822569102704640, 1),\n                (u64::MAX, 7),\n                (18446742974197923839, 1),\n                (18446744073709551591, 1),\n                (u64::MAX, 2),\n                (18446744073701163007, 1),\n                (2251799813685247, 1),\n                (98304, 1),\n                (0, 2),\n                (34359738368, 1),\n                (0, 1),\n                (18446744073608888320, 1),\n                (u64::MAX, 2),\n                (18446708889337462783, 1),\n                (u64::MAX, 2),\n                (18446744073708503039, 1),\n                (u64::MAX, 3),\n                (9007199254740991, 1),\n                (2147483648, 1),\n                (0, 6),\n                (18428729675200069632, 1),\n                (u64::MAX, 3),\n                (18446744073709550591, 1),\n                (u64::MAX, 18),\n                (72057594037927935, 1),\n                (0, 5),\n                (18446744073709551600, 1),\n                (u64::MAX, 4),\n                (16383, 1),\n                (0, 8),\n                (17179869184, 1),\n                (0, 8),\n                (8796093022208, 1),\n                (0, 50),\n                (64, 1),\n                (0, 4),\n                (18446744073709289472, 1),\n                (u64::MAX, 4),\n                (268435455, 1),\n                (0, 10),\n                (18446744073708503040, 1),\n                (u64::MAX, 4),\n                (2147483647, 1),\n                (0, 1),\n                (288230376151711744, 1),\n                (0, 3),\n                (8192, 1),\n                (0, 18),\n                (17870283321406128128, 1),\n                (18446744073701163007, 1),\n                (u64::MAX, 4),\n                (51539607679, 1),\n                (0, 4),\n                (18446638520593154048, 1),\n                (u64::MAX, 4),\n                (72057594037927935, 1),\n                (0, 3),\n                (18446743936270598144, 1),\n                (u64::MAX, 1),\n                (511, 1),\n                (0, 4),\n                (18446744073708503040, 1),\n                (u64::MAX, 1),\n                (18446603336221196287, 1),\n                (18446744073709549567, 1),\n                (u64::MAX, 2),\n                (18446744072635809791, 1),\n                (u64::MAX, 1),\n                (4194303, 1),\n                (0, 2),\n                (2199023255552, 1),\n                (0, 7),\n                (18446744073575342080, 1),\n                (u64::MAX, 61),\n                (17293822569102704639, 1),\n                (u64::MAX, 23),\n                (67108863, 1),\n                (0, 4),\n                (18446743661392691200, 1),\n                (u64::MAX, 4),\n                (844424930131967, 1),\n                (0, 4),\n                (17870283321406128128, 1),\n                (u64::MAX, 5),\n                (18446742974197923839, 1),\n                (u64::MAX, 4),\n                (4503599627370495, 1),\n                (0, 1),\n                (562949953421312, 1),\n                (16384, 1),\n                (0, 1),\n                (13835058055282163712, 1),\n                (8589934591, 1),\n                (0, 1),\n                (18446744073675997184, 1),\n                (u64::MAX, 2),\n                (18446726481523507199, 1),\n                (u64::MAX, 7),\n                (1073741823, 1),\n                (0, 4),\n                (18446744073575333888, 1),\n                (u64::MAX, 2),\n                (18446603336221196287, 1),\n                (u64::MAX, 19),\n                (536870911, 1),\n                (0, 4),\n                (18446741874686296064, 1),\n                (u64::MAX, 4),\n                (2251799813685247, 1),\n                (0, 9),\n                (128, 1),\n                (0, 8),\n                (65536, 1),\n                (0, 36),\n                (18446744073709551488, 1),\n                (u64::MAX, 41),\n                (1073741823, 1),\n                (0, 22),\n                (17293822569102704640, 1),\n                (u64::MAX, 5),\n                (383, 1),\n                (0, 4),\n                (18446744073708765184, 1),\n                (u64::MAX, 4),\n                (536870911, 1),\n                (0, 12),\n                (18446462598732316672, 1),\n                (u64::MAX, 3),\n                (18446744073709551607, 1),\n                (576460752303423487, 1),\n                (0, 3),\n                (16384, 1),\n                (0, 7),\n            ]),\n        );\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_barrett_fail_1() {\n    let ns = &[1, 2, 3];\n    let ds = &[3];\n    let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_mod_barrett(&mut [10; 3], &mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_barrett_fail_2() {\n    let ns = &[1, 2, 3];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_mod_barrett(&mut [10; 3], &mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_barrett_fail_3() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_mod_barrett(&mut [10], &mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_barrett_fail_4() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_mod_barrett(&mut [10; 3], &mut [10], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_mod_barrett_fail_5() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[4, 5];\n    let mut scratch = vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_mod_barrett(&mut [10; 3], &mut [10; 3], ns, ds, &mut scratch);\n}\n\nfn verify_limbs_modular_div(ns: &[Limb], ds: &[Limb], qs: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let q = Natural::from_limbs_asc(qs);\n    assert_eq!((q * d).mod_power_of_2(limb_to_bit_count(ns.len())), n);\n}\n\nfn verify_limbs_modular_div_neg(ns: &[Limb], ds: &[Limb], qs: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let q = Natural::from_limbs_asc(qs);\n    let p = limb_to_bit_count(ns.len());\n    assert_eq!((q * d).mod_power_of_2(p).mod_power_of_2_neg(p), n);\n}\n\n#[test]\nfn test_limbs_modular_div_schoolbook() {\n    let test = |qs_in: &[Limb], ns_in: &[Limb], ds: &[Limb], qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let inverse = limbs_modular_invert_limb(ds[0]).wrapping_neg();\n        limbs_modular_div_schoolbook(&mut qs, &mut ns, ds, inverse);\n        assert_eq!(&qs[..ns.len()], qs_out);\n        verify_limbs_modular_div_neg(ns_in, ds, qs_out);\n\n        let mut ns = ns_in.to_vec();\n        limbs_modular_div_schoolbook_in_place(&mut ns, ds, inverse);\n        assert_eq!(ns, qs_out);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        test(&[10; 3], &[0, 0, 0], &[1, 2], &[0, 0, 0]);\n        test(\n            &[10; 3],\n            &[1, 2, 3],\n            &[1, 2],\n            &[u32::MAX, u32::MAX, 0xfffffffc],\n        );\n        test(\n            &[10; 3],\n            &[1, 2, 3],\n            &[3],\n            &[1431655765, u32::MAX, 0xfffffffe],\n        );\n        test(&[10; 3], &[1, 2, 3], &[u32::MAX], &[1, 3, 6]);\n        test(\n            &[10; 3],\n            &[1, 2, 3],\n            &[5, 6],\n            &[858993459, 687194767, 893353197],\n        );\n        test(\n            &[10; 3],\n            &[1, 2, 3],\n            &[1, 2, 3],\n            &[u32::MAX, u32::MAX, u32::MAX],\n        );\n        test(\n            &[10; 3],\n            &[1, 2, 3],\n            &[1, u32::MAX, 3],\n            &[u32::MAX, 0xfffffffc, 0xfffffffd],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[10; 3],\n            &[1, 2, 3],\n            &[1, 2],\n            &[u64::MAX, u64::MAX, 0xfffffffffffffffc],\n        );\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_schoolbook_fail_1() {\n    limbs_modular_div_schoolbook(&mut [10; 3], &mut [1, 2, 3], &[], 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_schoolbook_fail_2() {\n    let ds = &[1, 2, 3, 4];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_schoolbook(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_schoolbook_fail_3() {\n    let ds = &[1, 2];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_schoolbook(&mut [10, 10], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_schoolbook_fail_4() {\n    let ds = &[4, 5];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_schoolbook(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_schoolbook_in_place_fail_1() {\n    limbs_modular_div_schoolbook_in_place(&mut [1, 2, 3], &[], 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_schoolbook_in_place_fail_2() {\n    let ds = &[1, 2, 3, 4];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_schoolbook_in_place(&mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_schoolbook_in_place_fail_3() {\n    let ds = &[4, 5];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_schoolbook_in_place(&mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_modular_div_divide_and_conquer() {\n    let test = |qs_in: &[Limb], ns_in: &[Limb], ds: &[Limb], qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n        limbs_modular_div_divide_and_conquer(&mut qs, &mut ns, ds, inverse);\n        assert_eq!(&qs[..ns.len()], qs_out);\n        verify_limbs_modular_div(ns_in, ds, qs_out);\n    };\n    // - q_len > d_len first time\n    // - q_len < DC_BDIV_QR_THRESHOLD first time\n    // - q_len != d_len\n    test(&[10; 3], &[0, 0, 0], &[1, 2], &[0, 0, 0]);\n    test(&[10; 3], &[1, 2, 3], &[1, 2], &[1, 0, 3]);\n    test(\n        &[10; 3],\n        &[1, 2, 3],\n        &[5, 6],\n        &[3435973837, 3607772528, 3401614098],\n    );\n    // - q_len <= d_len\n    // - q_len < DC_BDIV_QR_THRESHOLD second time\n    test(&[10; 3], &[1, 2, 3], &[1, 2, 3], &[1, 0, 0]);\n    test(&[10; 3], &[1, 2, 3], &[1, u32::MAX, 3], &[1, 3, 2]);\n    // - q_len == d_len\n    test(\n        &[10; 4],\n        &[1, 2, 3, 4],\n        &[5, 6],\n        &[3435973837, 3607772528, 3401614098, 2790010755],\n    );\n    // - q_len > d_len second time\n    test(\n        &[10; 5],\n        &[1, 2, 3, 4, 5],\n        &[7, 8],\n        &[3067833783, 175304787, 3481052211, 2770888938, 2968937350],\n    );\n    // - q_len >= DC_BDIV_QR_THRESHOLD first time\n    test(\n        &[10; 101],\n        &[\n            2614433502, 201952551, 1985699938, 3737156448, 1826834370, 390646530, 3862902767,\n            3701087729, 3240671658, 1498939256, 405421884, 2500498977, 543951667, 3836845972,\n            114681939, 1915271357, 1549193218, 2855181942, 1722136441, 2766310271, 47656978,\n            3837638424, 4016489648, 3574908855, 271673898, 401895301, 1488021015, 2138694572,\n            2044000169, 958933265, 3144481463, 2779079775, 1326886023, 2406822210, 3541050174,\n            2770735565, 2480957566, 2243398174, 2238068283, 311009614, 1882015784, 1325726230,\n            997031698, 1581908377, 2605721422, 3189028102, 272460210, 490645275, 2254115078,\n            1729448452, 3279102284, 4891191, 3182892978, 4279769790, 76488030, 2146767575,\n            3135871036, 2565128600, 1134722432, 4021959710, 2443099174, 3511788218, 3402507407,\n            3887545637, 1602118380, 3373080814, 913482070, 2525212842, 458807656, 2191742476,\n            189120803, 1571244040, 2065986906, 3536519990, 1106920062, 249073982, 3953429556,\n            70634017, 2295215236, 1095935313, 3576698687, 4150987084, 3091466601, 2659048520,\n            2421964497, 478008822, 4183767176, 3019500765, 472981990, 4237993573, 2387724271,\n            2897482399, 2735157706, 3951571091, 1100488960, 772381751, 3385833448, 243788259,\n            2673522310, 2507994216, 422336110,\n        ],\n        &[\n            1465267273, 74481649, 4134700379, 1230170156, 365676293, 3483084975, 1197662581,\n            2640006295, 4011823868, 3248823520, 3487252378, 2404109212, 1035566706, 2348272566,\n            1563713437, 926167746, 4275574143, 2618001622, 3006090084, 758724212, 2363503275,\n            2777706618, 36668516, 1573638162, 826631123, 1003261600, 3834425037, 3917704239,\n            380020162, 1200612060, 4053700768, 4029551185, 1269962948, 3135204397, 1191219015,\n            2005782900, 600631609, 2788434518, 160830671, 1865310436, 2821311021, 1359155705,\n            390596229, 173852699, 2808888002, 845149215, 4091564759, 2997755999, 3196096033,\n            2442709791, 2497943703,\n        ],\n        &[\n            2268505070, 3175859475, 3142537387, 3900159731, 1159682617, 4189328550, 3907703309,\n            1212735193, 532303389, 2766948169, 2016978110, 2967794961, 2774851624, 3217650683,\n            2925509985, 3764969541, 958893059, 3417020824, 1954191584, 3562512044, 2446134389,\n            2177043907, 2722738527, 1056354433, 163366464, 2100641128, 2795771616, 981138683,\n            2004843724, 421545248, 931541656, 2667221997, 1053518296, 3427347852, 943193977,\n            1693724312, 497384180, 1592766692, 3814767396, 496551406, 761630525, 122738561,\n            2053011267, 3134192635, 3959716126, 756419570, 4291525522, 52995454, 2355566740,\n            1535344262, 3457101895, 1561710520, 629646311, 1264617650, 1304911374, 3953997387,\n            101220699, 606111922, 3169531883, 119225490, 2099572326, 3662568011, 2701978464,\n            2354203828, 3024227856, 812859784, 3907484219, 895862916, 2367636279, 3049608863,\n            3534493707, 303599528, 235895898, 3152156937, 3282734021, 2504903737, 3347451841,\n            105947633, 2602282968, 2091238035, 1697885061, 2125538933, 1538362896, 3260245263,\n            4185444552, 1173878884, 860722873, 4135695975, 3027742222, 4045316121, 684087923,\n            2221029460, 2175787664, 4254578535, 1093169950, 3230867467, 1521099406, 1031502141,\n            3310189672, 2767979128, 3491264110,\n        ],\n    );\n    // - n >= DC_BDIV_Q_THRESHOLD in limbs_modular_div_divide_and_conquer_helper\n    // - lo < hi in limbs_modular_div_divide_and_conquer_helper\n    test(\n        &[10; 369],\n        &[\n            926256687, 2852364395, 3370590143, 2584805050, 1597100583, 529558289, 126580396,\n            4262060268, 1358185452, 3688826498, 2880947234, 2448955814, 2642826080, 1444415359,\n            2262174529, 4252876126, 1546829518, 1026350339, 461104688, 3572581738, 1379301297,\n            1469000044, 1232904583, 1130621172, 3414532348, 2076979854, 415474734, 138424304,\n            2741622037, 1356956847, 3700037198, 3056382371, 4003358430, 4114290085, 2632329664,\n            2757229707, 942973054, 2844466602, 2536850025, 1562205098, 2369019562, 479441879,\n            1133122146, 3033404131, 799055770, 2801165147, 333840674, 1266456054, 3826844211,\n            2394399329, 1580344224, 4208515641, 3938843492, 2943006000, 3095897464, 3657696853,\n            1895017685, 1174400257, 856895147, 2769847676, 2637358396, 4211838346, 2677238745,\n            3116142044, 2687432725, 1110573568, 933169252, 2112520496, 1203633399, 706652780,\n            1876380535, 947010911, 2311376766, 3912635689, 3738597172, 2407075297, 1150178856,\n            332957826, 2061573893, 1936087771, 2146544892, 3812143813, 4006647140, 1808470881,\n            3639090995, 3102762721, 3422984617, 3555513955, 3249465976, 4102963672, 1077718033,\n            2477507069, 1259888894, 1319895809, 2840602832, 488930783, 280413795, 1714984325,\n            906714553, 4044121361, 2834701307, 353693245, 630667692, 714081891, 689252325,\n            2538920747, 1229220355, 1965412395, 2366311709, 3490987487, 4244144248, 3004878982,\n            1934198881, 3439419469, 584060055, 3763445399, 1754985895, 3426861913, 3852827741,\n            2905990235, 591028154, 3955620274, 2446523634, 2269181228, 2155869554, 2785380931,\n            1067038528, 4226586573, 938767979, 3463341351, 729920782, 3672068894, 3277213230,\n            3829428878, 78609376, 2725264455, 1334526325, 3852128883, 83033112, 3171538426,\n            212483737, 1705821676, 4130869601, 985721852, 4137618486, 3647946653, 2078761135,\n            2033567134, 922945141, 2842773827, 2731090851, 3725966427, 346163520, 620359799,\n            2807835138, 4251526149, 3329030547, 1785319896, 1412060986, 112477766, 2463195081,\n            2269604331, 1667556850, 3069673827, 2451159887, 3531154947, 859465533, 797558571,\n            2402685684, 1938998432, 3367592143, 1855629490, 415564883, 1771525305, 2108262482,\n            878332057, 3591804465, 742811660, 2001773684, 869241071, 3406728833, 4240156422,\n            1145567809, 1952848548, 1700151067, 95712656, 1166986301, 2821041275, 1639679488,\n            836739412, 159195524, 2990285642, 1385013141, 4175880469, 612922039, 172085215,\n            403018883, 954336314, 686090551, 1892450280, 3747619613, 4144413437, 2234712194,\n            2339662600, 2244879528, 1753875098, 1838725682, 3357280280, 2192624967, 91122545,\n            4248769883, 3595273608, 1004650549, 3206549498, 3722330732, 2319766803, 3308299148,\n            3660385401, 1984746697, 2537428039, 837529793, 3423459313, 3380318451, 3600361999,\n            1289811131, 2814141705, 1934106458, 1264409971, 2339500232, 2513439371, 628923995,\n            161098739, 97046111, 528398469, 1351706370, 2700997745, 3433492154, 3705626784,\n            2281353606, 2351376214, 78178014, 4256447668, 2755024441, 1600945286, 2135856519,\n            2332322194, 1336372796, 924574937, 3984145695, 806549767, 1455952508, 1602006824,\n            1992184377, 175977061, 2976584306, 1501249388, 3211774572, 2177299115, 2436808205,\n            1296153861, 1528208726, 2086869059, 4256091310, 3359280803, 3794379308, 2845006300,\n            3370727254, 4191386263, 3868923083, 4024786060, 3356572949, 1309623451, 3404587756,\n            799637471, 2539690724, 3538256419, 1789660732, 993651510, 868809315, 4070903506,\n            3500550366, 3537383550, 3000705462, 2011729323, 1276336091, 3715263489, 3856442137,\n            3078455161, 2394585974, 1731395403, 209285071, 4286415453, 3634201569, 2714865379,\n            3923934404, 1590322431, 2827746455, 4104930505, 1849053889, 1110373541, 2098826577,\n            3752273612, 1449873597, 1543844883, 3523617712, 4278529692, 3074073157, 32217677,\n            2222114104, 1507299609, 4254234641, 619965639, 52325523, 2586116737, 3828937288,\n            841926627, 3927959971, 1429216471, 4078179238, 4166937366, 964935962, 846542155,\n            3665864344, 1340829030, 3980686425, 1463832311, 2710331305, 4041927928, 287911129,\n            1092730462, 1712349041, 332408781, 721925455, 3228519043, 2399858087, 1126502586,\n            1239406845, 1890441075, 3602881664, 1720394596, 1136141449, 2550451241, 2108470819,\n            2381224270, 196743147, 2289453443, 3352746316, 1442822225, 195272465, 1977411238,\n            619069892, 1120443118, 2367263780, 2339580211, 3244857684, 413188862, 3648382353,\n            1866426486, 3275669837, 714860356, 2503398064, 3520234361, 2602261672, 142956137,\n            3457786845, 1647737711, 3596429731, 98035229, 2134549817,\n        ],\n        &[\n            288812247, 1867980581, 1784848883, 3719376405, 891732341, 4042694263, 2315971843,\n            4173934812, 3724384121, 3438649023, 817688419, 3717708150, 392002651, 1406301870,\n            3000223143, 3208696401, 3333344771, 2069472443, 2868745797, 2276970520, 4200672618,\n            4286576728, 3178657413, 2709499760, 3528379042, 37056359, 713896147, 1464335286,\n            999714577, 4261103320, 2842057702, 532870143, 318250036, 454191633, 3585978181,\n            3853346096, 232386666, 4153228123, 3001669262, 2644858239, 1372523035, 1638844646,\n            221021648, 2633701374, 3889749815, 3749206185, 2682504994, 1691062985, 1564838714,\n            2021047227, 3653939067, 375766416, 1676298932, 1632585265, 1987642618, 3216589770,\n            2139352178, 3531691061, 3135733087, 2974439634, 3240759359, 1441918073, 2963546690,\n            956474789, 1010096752, 3295505885, 1556487598, 2763009589, 2181664193, 3830580006,\n            567013630, 1792629848, 3395572099, 3047782274, 849031602, 3372175233, 1238500612,\n            3602622896, 1224295906, 514205489, 615596822, 3650298487, 3835144940, 4230075746,\n            3563666002, 2171604008, 3860998558, 4030801816, 1966076533, 534702268, 4096165465,\n            118025721, 3217620626, 1281269306, 2026131743, 1083491983, 2634322198, 1319079531,\n            384610271, 343671134, 1924283281, 4110082962, 1035723460, 7922039, 1864294974,\n            3433501319, 612818706, 2074478411, 430050897, 347224817, 3689916278, 431159468,\n            2396947295, 2216850314, 2873958193, 1052280319, 3807224736, 3366982378, 445016867,\n            801857639, 2770754059, 2166713172, 2421080783, 4293281425, 3315144969, 832988729,\n            3203751531, 60602646, 3435936620, 2013384606, 3375674785, 506953530, 4135169500,\n            2547839556, 1670695010, 2532819097, 1595078260, 1906874739, 4140805961, 909986610,\n            1450206000, 2416600358, 78210121, 2461045671, 3017469740, 1248552863, 2491666236,\n            3529749845, 1306097619, 609634854, 1618830814,\n        ],\n        &[\n            2153621097, 2032975874, 1092283530, 2105499851, 2772147020, 797232604, 4197023255,\n            2316448335, 231339989, 790127543, 2827859807, 3740953002, 2953654149, 4028925052,\n            890100763, 944013012, 3074009738, 2799155639, 1581696516, 421616097, 2763522161,\n            460382413, 3452929191, 1491944014, 1268408485, 3706732519, 987986692, 1185168616,\n            312846948, 1736211677, 4257673428, 3728427015, 3445998410, 2787875431, 2693980376,\n            2270279443, 1915043797, 4081500771, 22182374, 2602808921, 4089111581, 316485891,\n            1787500084, 2286785318, 1422270801, 799485298, 870038934, 2055189464, 3431348353,\n            2777540456, 426645251, 1311005497, 3234663366, 540942104, 1278767054, 3141018165,\n            3997602571, 3885692388, 2906279738, 1880065873, 701408818, 1624620668, 2502792336,\n            27895058, 3449141668, 731396337, 2025748336, 3252039671, 2316581185, 1576067456,\n            959043581, 4043904286, 3885331851, 1432462822, 3531781850, 3866289759, 1120305997,\n            421733220, 2095656685, 306908537, 1829908494, 3026950391, 2753364951, 2446351196,\n            3811823100, 2096821518, 2024511440, 1827913918, 540355707, 1677071333, 2189975772,\n            1140077230, 2361607088, 3292807914, 1616778383, 1428264564, 4185564524, 4078951710,\n            3050933070, 1900914292, 1656040826, 4169852007, 3654163666, 459884159, 1142386374,\n            2092770650, 4093216198, 3297930392, 1585102456, 2240909415, 2977419294, 1424884171,\n            3131984332, 3677770202, 1103210323, 3732259374, 3405359572, 1239187170, 1233825656,\n            1171077559, 3166656449, 3557574007, 2517986752, 298018080, 64725485, 3157564402,\n            1895722919, 3711770814, 2165944903, 4108826234, 39205698, 3297059852, 2709772591,\n            3472388897, 1795079771, 1014084034, 1690969319, 188496797, 362199350, 1538080346,\n            3295087220, 3035112492, 860797619, 2138464630, 893193827, 3209353152, 1892791880,\n            3956061449, 2582762448, 123764390, 3853335455, 1109119369, 2810579875, 2557150328,\n            194723070, 1511406773, 308580645, 1506805209, 3800717643, 1154701911, 3327639678,\n            1742392333, 383847505, 808485729, 1107933974, 1843546476, 3160127489, 461019178,\n            2758534633, 3136176283, 4161349001, 1122667843, 529002233, 1756067056, 610266011,\n            868502089, 1924153935, 3733910978, 2089140891, 2010741130, 1699263293, 1974321295,\n            2337744872, 2401421411, 152242715, 1841948095, 4080892494, 3557450617, 1648335241,\n            1739529953, 1965700723, 4159737024, 1826643625, 2624044999, 2662463178, 1453688703,\n            2373328295, 1284900613, 166103125, 2950850796, 224937865, 2363667655, 1395721930,\n            1038140390, 2227351547, 4027728456, 2456853028, 3392407547, 3558026617, 1022960493,\n            324320014, 1741363959, 665626647, 1989801844, 1039225187, 2749242260, 2891585679,\n            413980454, 1421911978, 542423805, 1198826717, 3829692439, 2424493878, 1743568705,\n            3904138435, 957436945, 3380949485, 3874828753, 3764048544, 2784271009, 3709257819,\n            2420168014, 2258006234, 1818204898, 4293192208, 1516897791, 4231562984, 1087919881,\n            3298788303, 409554742, 363790612, 1163362152, 1851768229, 3036249655, 1304207802,\n            2757649751, 1345091600, 3980437826, 845106654, 1191417084, 789417113, 3069537799,\n            4128120253, 1724644264, 1850762321, 440075901, 3081463549, 3296565609, 880610907,\n            3604815503, 825119004, 662787316, 2065720314, 1905930059, 3158622573, 2441285185,\n            609976312, 3214173289, 1972737948, 1856923900, 3881955749, 147509891, 13256522,\n            480264715, 2304077206, 4079499728, 1733454240, 683301825, 2067789682, 357755971,\n            4064960581, 880616108, 2567161687, 2143724680, 295233846, 885328588, 3528678059,\n            2821762581, 438733817, 1651128958, 266078579, 389905061, 451514054, 1632102041,\n            3121845303, 1370227908, 2165682378, 4205795758, 3678759448, 3760360877, 3616397292,\n            3496735510, 2181567729, 1760479516, 2226441722, 1169335764, 1685289328, 3980766219,\n            584449244, 1198456230, 3262408896, 3506319243, 3461775774, 3985269650, 4207509002,\n            2496174343, 4246361431, 2525595216, 505792351, 694109202, 2532334608, 177977694,\n            3590514888, 1386331403, 3322919897, 3677035627, 1748970524, 2355331384, 2803452306,\n            1684779748, 431295285, 2720257929, 1349292466, 196319200, 721926885, 2699941953,\n            2509363172, 2856348470, 971658703, 3158854173, 648569495, 806886112, 894065939,\n            1809981633, 2207773884, 2422134450, 2395969450, 154939100, 2258690857, 1558269103,\n            3746056343, 3625500344, 1655744570, 3783968316, 2684172985, 1026377946, 2668609092,\n            3087350250, 1696799137, 4172271775, 2172265355, 1009592900, 3751494892, 1102570367,\n            728659538, 896138123, 62660027, 2953563063, 2225405012,\n        ],\n    );\n    // - lo == hi in limbs_modular_div_divide_and_conquer_helper\n    test(\n        &[10; 130],\n        &[\n            3959967020, 604241247, 1023896993, 1094415464, 1559137023, 2965982948, 2156029102,\n            1706771649, 894030132, 45266116, 3024397174, 2788172395, 890061141, 3642398662,\n            2446922996, 2040815673, 4240388236, 3527485030, 2696135743, 1863211571, 4250621960,\n            2587213674, 4041734617, 3833321094, 3255910635, 1391342501, 405445752, 1166990562,\n            3729755900, 3449768038, 3995921119, 41398076, 589125403, 1408294985, 2526515658,\n            979087391, 1829542521, 2584013937, 86635251, 3289463217, 1129003160, 4215486047,\n            2533366306, 2464115291, 3785087535, 2492911607, 1526230004, 1102360497, 3665011293,\n            2884421895, 324933681, 708889365, 377966516, 1925322820, 2718776900, 3007014420,\n            2694491006, 64698980, 2283839644, 3204232940, 897214742, 3983354864, 1516406610,\n            4133557944, 2175029320, 609379471, 564247587, 683039961, 1804280416, 4145184207,\n            4080873242, 3101363732, 4184296551, 3096748957, 1158225507, 2896147906, 1844344520,\n            2528253875, 2002410714, 265589879, 3121801985, 3170049206, 1924743552, 3357216142,\n            1965153305, 4252960808, 2092345429, 2837817119, 4284431393, 4293590240, 654671346,\n            442937916, 1896790019, 691824410, 525764843, 1906879578, 1441648208, 101533739,\n            1634254350, 3353889676, 3656414560, 1273785308, 3544127466, 3459937121, 870751892,\n            1042879338, 266055738, 1555417213, 1241879745, 1883960373, 1942927191, 1838179445,\n            1068713063, 2025583273, 531467322, 1876253978, 3303292405, 414426425, 1511200112,\n            4106411687, 3527482414, 1961626864, 2704598906, 3866316252, 3265850188, 3581763702,\n            1084651282, 3286715315, 3240494590, 2037895289,\n        ],\n        &[\n            831013375, 20762440, 1023050464, 2893474254, 1340969251, 2523392356, 3059428058,\n            4273516901, 733612744, 2348114766, 527881926, 1821776884, 342733126, 533682011,\n            3273669965, 3813354237, 730319485, 3494597442, 3842303180, 2653483407, 1439592834,\n            1040222095, 4178562882, 3903858398, 1448880503, 453957758, 2591332887, 1627251265,\n            3845154845, 2189626142, 2509689197, 1600458471, 2116253912, 567231261, 4265711834,\n            4030352409, 1804529170, 4286478946, 2730794561, 4214016930, 265468824, 1147813206,\n            1770605310, 3394893197, 1654160857, 531943003, 32521814, 4040486896, 1507001215,\n            3704501969, 651705156, 969516949, 24702145, 1664997108, 421558584, 372837233,\n            1254072677, 531592109, 3829378883, 2113868005, 960337326, 3547746167, 1987930996,\n            3779916457, 3178987148, 2246813569, 111988945, 2002604914, 923221962, 1220517471,\n            3875731717, 456825253, 4034876422, 444954392, 2767163540, 2138086216, 2109913076,\n            4089697693, 1989588591, 1122017014, 722640034, 2406717790, 980978606, 3956008296,\n            1092718561, 396048014, 3434190160, 3721687760, 980653819, 2134907925, 1119974854,\n            3412876362, 3043790819, 185604051, 2832132094, 3655349262, 2911925829, 377462795,\n            2359250992, 3598561591, 1539340059, 4033418662, 2214700100, 3039512018, 3007111049,\n            4215728089, 2804550486, 3578434606, 227455404, 265376688, 2221211195, 1024077580,\n            4234081405, 2702795924, 1578634809, 696069720, 1613277316, 1828976876, 1070942553,\n            2681872839, 2525247432, 352687185,\n        ],\n        &[\n            2214746836, 963790571, 514240474, 3287959011, 3633281888, 331145186, 2070936355,\n            1275814903, 649598638, 4048580142, 703307156, 1012761762, 1604206100, 3671704900,\n            1413149070, 1684128911, 3864334051, 3517749930, 404335570, 3003402025, 300542403,\n            3126191669, 3699252803, 1439364308, 4192415949, 1299197928, 1611984161, 2452019244,\n            1490517426, 3629863277, 2995875193, 4190690602, 3357095237, 2125051168, 2745878491,\n            133070914, 2983910851, 2032579934, 3884117502, 2707418796, 147936035, 2807568299,\n            463241876, 2904771792, 974710149, 1446026448, 1012503772, 1241584448, 1218926543,\n            22512568, 3540164426, 3704594926, 1675610321, 4283065258, 1692490953, 1496989584,\n            1037241778, 2303280516, 3682225212, 1739214044, 602765408, 4279069132, 4056574424,\n            1288231393, 2447355568, 1822142590, 2659661918, 520518691, 877252364, 1172314748,\n            2143580045, 2927546685, 1702611733, 3329775201, 265548959, 2886036575, 982951504,\n            1898736712, 1808101939, 1001715132, 988772812, 3415931945, 3156345141, 2590276172,\n            1147813273, 1551504667, 4036713818, 2703846994, 3378891303, 3501124044, 3973617807,\n            2147277907, 1948408686, 3297628811, 4200352081, 73680938, 2715396127, 809994587,\n            819313279, 2649935820, 3358862368, 3764689552, 1229451982, 3158810723, 1613280893,\n            2296459508, 3037083750, 2496650271, 814520391, 1890901501, 2263419075, 880319244,\n            571981604, 4091474119, 4150388764, 3742405101, 2249427916, 4175082452, 1674645979,\n            71011260, 2431119031, 1958098093, 3007232024, 389827510, 355733904, 3385289187,\n            3022974738, 3499817070, 70324044, 1955894168,\n        ],\n    );\n    // - q_len >= DC_BDIV_QR_THRESHOLD second time\n    test(\n        &[10; 136],\n        &[\n            1635505187, 367942507, 585747625, 3259895362, 2551559511, 2891390854, 210701094,\n            253381911, 741016565, 1562764630, 647253529, 995079955, 1415112766, 1121555269,\n            3264386894, 1432983665, 3084492729, 4197513843, 2107932479, 911748961, 1669179905,\n            3062572274, 160542021, 1653853504, 3878824697, 4044369261, 1986777757, 3535266551,\n            1866910827, 4275901664, 354208268, 1288584384, 2863182224, 1221901169, 1253657528,\n            592130239, 3568722156, 2486101902, 483424561, 1575660483, 720736121, 1101685031,\n            2565922629, 196632433, 1033148213, 969310472, 1995520702, 3260631554, 1562557993,\n            45802047, 949951688, 3295028866, 2613836943, 4061881640, 2210607847, 14248080,\n            1604642540, 3576146202, 1838134557, 4181752638, 2414843751, 3325579689, 2902708971,\n            2230053926, 1716268270, 3844071486, 3423382254, 2254614074, 234521767, 3030206003,\n            660556467, 4001187396, 3773254173, 2953162211, 943562247, 2352566705, 3238995051,\n            2513628232, 1645194089, 4221434207, 298778061, 1395231701, 3223314097, 3370303237,\n            1905903471, 1408845004, 3916893951, 3646732666, 162038877, 1235325374, 1651995328,\n            4159903692, 716366148, 2592723919, 2588428010, 2841918047, 2236491801, 1439600422,\n            268691456, 2330191766, 371571121, 2510936837, 1992243115, 888863283, 68281559,\n            2527602368, 113695533, 2735585253, 1909150691, 1102365183, 1743094105, 2335719272,\n            958887136, 4011105869, 2588799839, 630693297, 1764561812, 4102816119, 1751306966,\n            3347952786, 2985949642, 2087233415, 4171910514, 4184815114, 2269683542, 2467143008,\n            2240451464, 3865437579, 205000839, 537874053, 1119318572, 169965588, 2947313176,\n            862816324, 3987040697, 1222400428,\n        ],\n        &[\n            3139654297, 2963323009, 2614026787, 2578421476, 2191104461, 2624045036, 3640460632,\n            1417210598, 3126930163, 1027257221, 460590703, 4066457807, 3459488871, 576203252,\n            1688476041, 2466961360, 1837547601, 376220531, 4141413316, 1803893809, 1761371554,\n            3478953436, 130868688, 3859844778, 2980999350, 3309259618, 1059925822, 2182828747,\n            2005291310, 4234145897, 1408307661, 3344594438, 3438553526, 2363099253, 2188599822,\n            3464723571, 1041189464, 1746045537, 1958228487, 3752307692, 303751983, 1642664874,\n            131752811, 1640394963, 2637801305, 3516563951, 1933714212, 1737019176, 2450206053,\n            503586131, 126392718, 2688144827, 1242477456, 2295392334, 466349000, 2569462004,\n            1318597067, 1300781532, 1655398676, 2050075490, 3903849354, 3120503464, 171096473,\n            29581654, 3447431964, 832547958, 3444142819, 3539975343, 4114704783, 521462868,\n            251982313, 1371581103, 3750111566, 2076014585, 988831298, 3885431509, 2528566949,\n            1332909323, 41017395, 250182185, 190467400, 477317824, 3346975325, 1469734194,\n            3287617291, 1797244834, 3716306921, 3132805196, 4130477334, 931614979, 4159691979,\n            2278615012, 3033894917, 953086932, 887198557, 3075690000, 189881536, 2562655208,\n            2340948573, 1756155681, 1434962210, 1786798745, 2696354320, 466230606, 265495223,\n            3772572252, 4060091719, 4091929587, 2602735823, 3377510257, 285339272, 1093341111,\n            1082532166, 1615653819, 2657481369, 1946488895, 3281845888, 8959603, 969779240,\n            3948725158, 3119648217, 4059928239, 2639117089, 715898173, 3730038209, 2531002727,\n            656254619, 4082370365, 4254910891, 2266367871, 2845947517, 91542353, 988318600,\n            2012804020, 2917139165, 2687206014,\n        ],\n        &[\n            344182299, 3565607671, 1425615408, 3688127580, 932395430, 2078412097, 712144307,\n            2579135290, 1670334397, 3526571898, 527889915, 1847317444, 3706898982, 1670379914,\n            3028965264, 1454573587, 1233674887, 1842735039, 673704170, 2755491011, 3144215569,\n            2844132685, 3976352845, 3704439681, 2871494744, 563225203, 477319433, 2394374187,\n            3361238262, 4097585783, 2091409235, 2989027616, 251393985, 2038664131, 1900105723,\n            2726074037, 3903048322, 601506890, 4227623429, 3732979811, 2904090093, 3911663358,\n            694119437, 2312158283, 3761860359, 1226110613, 2077730233, 2543223326, 3098049773,\n            3187544264, 3680092572, 3815125216, 1990113409, 382920264, 3200154083, 970587848,\n            1032771863, 1792989867, 408437052, 2035811594, 2495259018, 423722523, 3044771958,\n            1864896105, 2129868689, 188726050, 1810624947, 1128856008, 504663759, 221476670,\n            3718864116, 2197791369, 288158522, 1522677473, 4187008757, 3299027054, 3045833372,\n            1408455415, 2175274137, 54848700, 3470586256, 2721864863, 3804754388, 1239548951,\n            3301368160, 982306786, 3770156486, 3880485126, 2829505820, 2147636394, 2199815955,\n            3505488481, 1942842807, 1772747693, 4108779241, 2096541274, 930806315, 421709313,\n            3631892223, 1621500079, 1514788551, 2479798345, 4264484840, 4155460021, 258059056,\n            2718683630, 3598111667, 3304295306, 3429094861, 516349540, 2653253840, 1683537378,\n            3529770422, 112780533, 2171129104, 167784124, 2755669738, 3293537875, 3629382442,\n            614431521, 657960320, 376396606, 4098436288, 822064619, 226101057, 1630664330,\n            10604005, 2512924628, 3388389178, 3002235032, 485512099, 1009076950, 1391753479,\n            286560938, 1910351313, 2438028481,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_divide_and_conquer_fail_1() {\n    let ds = &[4];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_divide_and_conquer(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_divide_and_conquer_fail_2() {\n    let ds = &[1, 2, 3, 4];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_divide_and_conquer(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_divide_and_conquer_fail_3() {\n    let ds = &[1, 2];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_divide_and_conquer(&mut [10, 10], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_divide_and_conquer_fail_4() {\n    let ds = &[4, 5];\n    let inverse = limbs_modular_invert_limb::<Limb>(ds[0]).wrapping_neg();\n    limbs_modular_div_divide_and_conquer(&mut [10; 3], &mut [1, 2, 3], ds, inverse);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_modular_div_barrett() {\n    let test = |qs_in: &[Limb], ns: &[Limb], ds: &[Limb], qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let n = ns.len();\n        let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(n, ds.len())];\n        limbs_modular_div_barrett(&mut qs, ns, ds, &mut scratch);\n        assert_eq!(&qs[..n], qs_out);\n        assert_eq!(&qs[n..], &qs_in[n..]);\n        verify_limbs_modular_div(ns, ds, qs_out);\n    };\n    // - in limbs_modular_div_barrett_same_length\n    // - i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_modular_div_barrett_same_length\n    test(&[10; 3], &[0, 0], &[1, 2], &[0, 0]);\n    test(&[10; 3], &[1, 2], &[1, 1], &[1, 1]);\n    test(&[10; 3], &[1, 2], &[1, 2], &[1, 0]);\n    test(&[10; 3], &[1, 2], &[5, 6], &[3435973837, 3607772528]);\n    // - in limbs_modular_div_barrett_greater\n    // - !carry second time in limbs_modular_div_barrett_greater\n    test(&[10; 4], &[1, 2, 3, 4], &[1, 2, 3], &[1, 0, 0, 4]);\n    test(\n        &[10; 4],\n        &[1, 2, 3, 4],\n        &[1, u32::MAX, 3],\n        &[1, 3, 2, 0xfffffffa],\n    );\n    // - q_len > i_len in limbs_modular_div_barrett_greater\n    // - i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_modular_div_barrett_greater\n    // - d_len == i_len in limbs_modular_div_barrett_greater\n    test(\n        &[10; 5],\n        &[1, 2, 3, 4, 5],\n        &[7, 8],\n        &[3067833783, 175304787, 3481052211, 2770888938, 2968937350],\n    );\n    // - d_len != i_len in limbs_modular_div_barrett_greater\n    // - !carry first time in limbs_modular_div_barrett_greater\n    test(\n        &[10; 17],\n        &[\n            0,\n            0xfffffff0,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4294836224,\n            u32::MAX,\n            0x7ffff,\n            0,\n            0xfffffffc,\n            u32::MAX,\n        ],\n        &[u32::MAX, 0xffff, 4294959104, u32::MAX, 2047, 4294966784, u32::MAX],\n        &[\n            0, 16, 0x100000, 4294836224, 15, 1074823164, 4294565887, 2684338192, 2282854407,\n            605372416, 3137181202, 4166294690, 3073446262, 77886964, 3052808264, 3411277657,\n            901277614,\n        ],\n    );\n    // - carry first time in limbs_modular_div_barrett_greater\n    test(\n        &[10; 98],\n        &[\n            1642495634, 526967555, 2241173042, 3209550984, 1676167598, 1610173536, 3438803694,\n            1164362544, 2678449286, 780912452, 2768403743, 2060815434, 3972640317, 2520341055,\n            592620591, 1203487883, 983093889, 890767242, 57706568, 4116094675, 884607251,\n            2877607316, 1277464658, 1436231943, 3566448321, 320221382, 3788109081, 1244065662,\n            1675904837, 2386486007, 3956992595, 319964407, 202742052, 3806969795, 1515593820,\n            3744019160, 2090003288, 3532996659, 1561167831, 1602116916, 624040306, 162765508,\n            3520901959, 2560212238, 1836753736, 4193390434, 2748131373, 2815896923, 2183843856,\n            717268028, 4057685405, 1038000620, 3031926158, 1351486738, 3081828692, 716238242,\n            2133401994, 4055809448, 2426834827, 42249556, 1437875081, 2953322847, 3372525974,\n            807912434, 3231438580, 1532794318, 2545826975, 3083637183, 581139768, 2339238221,\n            1475394016, 3592198406, 2002134106, 444657767, 2223944228, 1052336361, 284385712,\n            2716809682, 457871403, 257228149, 53492436, 3918756724, 902759153, 2804665433,\n            3072525061, 1179183759, 1583887668, 2221275350, 3084717885, 3234652545, 2379337844,\n            3543607479, 1728198647, 1630260072, 2895054954, 2533669171, 1060868412, 547908407,\n        ],\n        &[\n            14618623, 1746469986, 3422287375, 4133184481, 1570537644, 4262126259, 2806378130,\n            3961348569, 2005535219, 3128034624, 2629791421, 2581513752, 3943557466, 4294487356,\n            2073524094, 2453727247, 3583353645, 1921128531, 3406066844, 1698548606, 1946999159,\n        ],\n        &[\n            2734842222, 2285689435, 3313291574, 144014201, 4220859605, 2950326491, 2357784357,\n            1586509685, 2832228486, 1607316550, 280781708, 4284905083, 511390653, 1180279956,\n            1018877648, 2593613350, 2120941422, 3139501780, 905043699, 3767548899, 580952750,\n            2178827242, 2551200564, 983629603, 884994054, 211841976, 2433402391, 1021212454,\n            819127040, 1904972730, 3433697954, 3446961599, 2967793385, 184760660, 4258736086,\n            2575421315, 3702982944, 1090206528, 738361131, 1464668514, 536747506, 1728476312,\n            836227767, 3720425025, 1632791665, 3046719088, 3289636949, 4151602118, 3854618415,\n            3416186138, 83311182, 2337871634, 3256616827, 250345345, 4152926648, 1505633136,\n            1983549218, 3590016829, 2141100866, 3890424583, 3192188136, 3779057143, 3508994270,\n            4056653461, 4016652469, 573993530, 498142680, 2568576590, 3123744761, 893793360,\n            3037437361, 2515586057, 1419850307, 2367351324, 2046622935, 822851473, 550435958,\n            1715769219, 386202898, 2986510451, 1685332339, 1548081751, 2846757228, 2600333304,\n            3154407368, 2550424293, 1762563946, 251045310, 2158430157, 2056859408, 1057424536,\n            2450050482, 2554796526, 3366193628, 4244612028, 1102253197, 3744549054, 521836615,\n        ],\n    );\n    // - carry second time in limbs_modular_div_barrett_greater\n    test(\n        &[10; 37],\n        &[\n            2935526596, 3034554327, 1814238638, 2697925306, 3829736681, 2739165479, 724626090,\n            604324966, 4252490674, 2065896555, 3890359639, 4148922800, 3007022887, 846622959,\n            2009383236, 1908685339, 1526530451, 2415388932, 338610665, 3714252276, 2553761603,\n            3643634643, 496773116, 3423491766, 1075245675, 217851812, 3421283768, 206430974,\n            1384123998, 1106562315, 3884178146, 2393734976, 3612774482, 3699430895, 1007237140,\n            4205715447, 842811847,\n        ],\n        &[\n            205703789, 2117899933, 1318971308, 3978644775, 3407016997, 1105357630, 1976230147,\n            4259422827, 1569463276, 1189711442, 3449406972, 1341407674, 423077568, 1572740530,\n            3866269574,\n        ],\n        &[\n            3183291732, 3833024062, 3586222897, 2197803151, 1007086642, 544727792, 1794027376,\n            3492679295, 555612395, 977509785, 2253915713, 1050562685, 3689706953, 91679594,\n            965381603, 1030563531, 506556705, 1163731842, 1782685644, 1032462892, 838184086,\n            2712070683, 101254061, 2126604889, 1455324808, 4284267836, 3246890330, 2786100847,\n            4292354129, 3612163869, 4255169090, 1705817867, 2385139426, 3288783439, 280839878,\n            1415086525, 3673678347,\n        ],\n    );\n    // - i_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_modular_div_barrett_same_length\n    // - n_len + i_len > mul_size in limbs_modular_div_barrett_same_length\n    test(\n        &[10; 69],\n        &[\n            2082197907, 3463552973, 3033841621, 3293308755, 1318302421, 924962436, 4055211147,\n            3066037067, 189854397, 360674525, 270528549, 1824708088, 1848896300, 2009286050,\n            1723092285, 1962202393, 1691706400, 1228277495, 2169116062, 1340789312, 2688811811,\n            2948615768, 3930757643, 232970699, 1674295859, 2771170263, 29024924, 4025863949,\n            2350200807, 1685576833, 1697147461, 3283768071, 1970079668, 2868576138, 4067067287,\n            2755619479, 1433554174, 570418866, 4193378147, 56846214, 4010333403, 99500968,\n            594166316, 2103126565, 3797481093, 1835813191, 3717816485, 1427301989, 2602454977,\n            2725793563, 4164737951, 1352512745, 3416783056, 1623413593, 3064676881, 1724024701,\n            130815055, 1736837714, 2687511206, 1192745823, 63300791, 2476521677, 2332269618,\n            139603363, 1232593938, 2211955807, 1536891080, 1717467933, 803195014,\n        ],\n        &[\n            571177489, 4171067636, 130205627, 385002762, 3710389308, 2495334077, 2555702128,\n            3776766701, 2374702786, 4018024315, 3321371413, 1939382625, 1735826724, 2610501056,\n            959471237, 3348497660, 3584321092, 3397401589, 1458021574, 3693295416, 1782750542,\n            2587986675, 1266401498, 4096921279, 1864600357, 3704089229, 3712721011, 2510009154,\n            1625100953, 2753044802, 3523244715, 2048819457, 1999850617, 1841193902, 1889118279,\n            2552563105, 37156074, 382481471, 4065787580, 572345799, 140984432, 4192479401,\n            1924809764, 1459787400, 2966035238, 819250523, 1301397292, 2037545391, 1858919076,\n            1830995686, 1796776602, 1566339969, 2002295704, 3651240066, 2475237044, 904307699,\n            3991071672, 1874129794, 4232916985, 755030924, 3876937220, 3359171346, 2215460812,\n            1717512044, 3462640226, 1416735647, 2825930507, 1273943241, 1501109004,\n        ],\n        &[\n            3324824931, 3285501135, 2080039886, 1363439285, 4216289514, 170135702, 3339034566,\n            3206256933, 2049361690, 3880142493, 2355736055, 3496015895, 269070856, 3612458995,\n            3874254584, 2792128956, 3736657578, 2652084650, 3367020175, 1255915505, 1207914599,\n            3301647744, 3872751597, 1044752670, 4048018730, 1158138599, 46279244, 374848909,\n            3803666978, 1097388174, 4125010214, 3492963129, 3793628443, 1566031349, 1950072987,\n            3983338264, 2373811991, 3106070941, 3871479066, 2857657266, 1820484444, 1815087675,\n            3736927857, 3638157771, 1043782805, 1853270968, 2202072929, 2227928131, 1445478612,\n            4065556003, 1988319175, 1719054009, 2654397327, 263746738, 1572373639, 349867437,\n            3114446163, 1211887713, 951929852, 2733483965, 4117156940, 2770305201, 3589296114,\n            83156101, 1563034919, 1982884392, 689027156, 3848414016, 2735835897,\n        ],\n    );\n    // - i_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_modular_div_barrett_greater\n    // - d_len + i_len > mul_size in limbs_modular_div_barrett_greater\n    test(\n        &[10; 369],\n        &[\n            926256687, 2852364395, 3370590143, 2584805050, 1597100583, 529558289, 126580396,\n            4262060268, 1358185452, 3688826498, 2880947234, 2448955814, 2642826080, 1444415359,\n            2262174529, 4252876126, 1546829518, 1026350339, 461104688, 3572581738, 1379301297,\n            1469000044, 1232904583, 1130621172, 3414532348, 2076979854, 415474734, 138424304,\n            2741622037, 1356956847, 3700037198, 3056382371, 4003358430, 4114290085, 2632329664,\n            2757229707, 942973054, 2844466602, 2536850025, 1562205098, 2369019562, 479441879,\n            1133122146, 3033404131, 799055770, 2801165147, 333840674, 1266456054, 3826844211,\n            2394399329, 1580344224, 4208515641, 3938843492, 2943006000, 3095897464, 3657696853,\n            1895017685, 1174400257, 856895147, 2769847676, 2637358396, 4211838346, 2677238745,\n            3116142044, 2687432725, 1110573568, 933169252, 2112520496, 1203633399, 706652780,\n            1876380535, 947010911, 2311376766, 3912635689, 3738597172, 2407075297, 1150178856,\n            332957826, 2061573893, 1936087771, 2146544892, 3812143813, 4006647140, 1808470881,\n            3639090995, 3102762721, 3422984617, 3555513955, 3249465976, 4102963672, 1077718033,\n            2477507069, 1259888894, 1319895809, 2840602832, 488930783, 280413795, 1714984325,\n            906714553, 4044121361, 2834701307, 353693245, 630667692, 714081891, 689252325,\n            2538920747, 1229220355, 1965412395, 2366311709, 3490987487, 4244144248, 3004878982,\n            1934198881, 3439419469, 584060055, 3763445399, 1754985895, 3426861913, 3852827741,\n            2905990235, 591028154, 3955620274, 2446523634, 2269181228, 2155869554, 2785380931,\n            1067038528, 4226586573, 938767979, 3463341351, 729920782, 3672068894, 3277213230,\n            3829428878, 78609376, 2725264455, 1334526325, 3852128883, 83033112, 3171538426,\n            212483737, 1705821676, 4130869601, 985721852, 4137618486, 3647946653, 2078761135,\n            2033567134, 922945141, 2842773827, 2731090851, 3725966427, 346163520, 620359799,\n            2807835138, 4251526149, 3329030547, 1785319896, 1412060986, 112477766, 2463195081,\n            2269604331, 1667556850, 3069673827, 2451159887, 3531154947, 859465533, 797558571,\n            2402685684, 1938998432, 3367592143, 1855629490, 415564883, 1771525305, 2108262482,\n            878332057, 3591804465, 742811660, 2001773684, 869241071, 3406728833, 4240156422,\n            1145567809, 1952848548, 1700151067, 95712656, 1166986301, 2821041275, 1639679488,\n            836739412, 159195524, 2990285642, 1385013141, 4175880469, 612922039, 172085215,\n            403018883, 954336314, 686090551, 1892450280, 3747619613, 4144413437, 2234712194,\n            2339662600, 2244879528, 1753875098, 1838725682, 3357280280, 2192624967, 91122545,\n            4248769883, 3595273608, 1004650549, 3206549498, 3722330732, 2319766803, 3308299148,\n            3660385401, 1984746697, 2537428039, 837529793, 3423459313, 3380318451, 3600361999,\n            1289811131, 2814141705, 1934106458, 1264409971, 2339500232, 2513439371, 628923995,\n            161098739, 97046111, 528398469, 1351706370, 2700997745, 3433492154, 3705626784,\n            2281353606, 2351376214, 78178014, 4256447668, 2755024441, 1600945286, 2135856519,\n            2332322194, 1336372796, 924574937, 3984145695, 806549767, 1455952508, 1602006824,\n            1992184377, 175977061, 2976584306, 1501249388, 3211774572, 2177299115, 2436808205,\n            1296153861, 1528208726, 2086869059, 4256091310, 3359280803, 3794379308, 2845006300,\n            3370727254, 4191386263, 3868923083, 4024786060, 3356572949, 1309623451, 3404587756,\n            799637471, 2539690724, 3538256419, 1789660732, 993651510, 868809315, 4070903506,\n            3500550366, 3537383550, 3000705462, 2011729323, 1276336091, 3715263489, 3856442137,\n            3078455161, 2394585974, 1731395403, 209285071, 4286415453, 3634201569, 2714865379,\n            3923934404, 1590322431, 2827746455, 4104930505, 1849053889, 1110373541, 2098826577,\n            3752273612, 1449873597, 1543844883, 3523617712, 4278529692, 3074073157, 32217677,\n            2222114104, 1507299609, 4254234641, 619965639, 52325523, 2586116737, 3828937288,\n            841926627, 3927959971, 1429216471, 4078179238, 4166937366, 964935962, 846542155,\n            3665864344, 1340829030, 3980686425, 1463832311, 2710331305, 4041927928, 287911129,\n            1092730462, 1712349041, 332408781, 721925455, 3228519043, 2399858087, 1126502586,\n            1239406845, 1890441075, 3602881664, 1720394596, 1136141449, 2550451241, 2108470819,\n            2381224270, 196743147, 2289453443, 3352746316, 1442822225, 195272465, 1977411238,\n            619069892, 1120443118, 2367263780, 2339580211, 3244857684, 413188862, 3648382353,\n            1866426486, 3275669837, 714860356, 2503398064, 3520234361, 2602261672, 142956137,\n            3457786845, 1647737711, 3596429731, 98035229, 2134549817,\n        ],\n        &[\n            288812247, 1867980581, 1784848883, 3719376405, 891732341, 4042694263, 2315971843,\n            4173934812, 3724384121, 3438649023, 817688419, 3717708150, 392002651, 1406301870,\n            3000223143, 3208696401, 3333344771, 2069472443, 2868745797, 2276970520, 4200672618,\n            4286576728, 3178657413, 2709499760, 3528379042, 37056359, 713896147, 1464335286,\n            999714577, 4261103320, 2842057702, 532870143, 318250036, 454191633, 3585978181,\n            3853346096, 232386666, 4153228123, 3001669262, 2644858239, 1372523035, 1638844646,\n            221021648, 2633701374, 3889749815, 3749206185, 2682504994, 1691062985, 1564838714,\n            2021047227, 3653939067, 375766416, 1676298932, 1632585265, 1987642618, 3216589770,\n            2139352178, 3531691061, 3135733087, 2974439634, 3240759359, 1441918073, 2963546690,\n            956474789, 1010096752, 3295505885, 1556487598, 2763009589, 2181664193, 3830580006,\n            567013630, 1792629848, 3395572099, 3047782274, 849031602, 3372175233, 1238500612,\n            3602622896, 1224295906, 514205489, 615596822, 3650298487, 3835144940, 4230075746,\n            3563666002, 2171604008, 3860998558, 4030801816, 1966076533, 534702268, 4096165465,\n            118025721, 3217620626, 1281269306, 2026131743, 1083491983, 2634322198, 1319079531,\n            384610271, 343671134, 1924283281, 4110082962, 1035723460, 7922039, 1864294974,\n            3433501319, 612818706, 2074478411, 430050897, 347224817, 3689916278, 431159468,\n            2396947295, 2216850314, 2873958193, 1052280319, 3807224736, 3366982378, 445016867,\n            801857639, 2770754059, 2166713172, 2421080783, 4293281425, 3315144969, 832988729,\n            3203751531, 60602646, 3435936620, 2013384606, 3375674785, 506953530, 4135169500,\n            2547839556, 1670695010, 2532819097, 1595078260, 1906874739, 4140805961, 909986610,\n            1450206000, 2416600358, 78210121, 2461045671, 3017469740, 1248552863, 2491666236,\n            3529749845, 1306097619, 609634854, 1618830814,\n        ],\n        &[\n            2153621097, 2032975874, 1092283530, 2105499851, 2772147020, 797232604, 4197023255,\n            2316448335, 231339989, 790127543, 2827859807, 3740953002, 2953654149, 4028925052,\n            890100763, 944013012, 3074009738, 2799155639, 1581696516, 421616097, 2763522161,\n            460382413, 3452929191, 1491944014, 1268408485, 3706732519, 987986692, 1185168616,\n            312846948, 1736211677, 4257673428, 3728427015, 3445998410, 2787875431, 2693980376,\n            2270279443, 1915043797, 4081500771, 22182374, 2602808921, 4089111581, 316485891,\n            1787500084, 2286785318, 1422270801, 799485298, 870038934, 2055189464, 3431348353,\n            2777540456, 426645251, 1311005497, 3234663366, 540942104, 1278767054, 3141018165,\n            3997602571, 3885692388, 2906279738, 1880065873, 701408818, 1624620668, 2502792336,\n            27895058, 3449141668, 731396337, 2025748336, 3252039671, 2316581185, 1576067456,\n            959043581, 4043904286, 3885331851, 1432462822, 3531781850, 3866289759, 1120305997,\n            421733220, 2095656685, 306908537, 1829908494, 3026950391, 2753364951, 2446351196,\n            3811823100, 2096821518, 2024511440, 1827913918, 540355707, 1677071333, 2189975772,\n            1140077230, 2361607088, 3292807914, 1616778383, 1428264564, 4185564524, 4078951710,\n            3050933070, 1900914292, 1656040826, 4169852007, 3654163666, 459884159, 1142386374,\n            2092770650, 4093216198, 3297930392, 1585102456, 2240909415, 2977419294, 1424884171,\n            3131984332, 3677770202, 1103210323, 3732259374, 3405359572, 1239187170, 1233825656,\n            1171077559, 3166656449, 3557574007, 2517986752, 298018080, 64725485, 3157564402,\n            1895722919, 3711770814, 2165944903, 4108826234, 39205698, 3297059852, 2709772591,\n            3472388897, 1795079771, 1014084034, 1690969319, 188496797, 362199350, 1538080346,\n            3295087220, 3035112492, 860797619, 2138464630, 893193827, 3209353152, 1892791880,\n            3956061449, 2582762448, 123764390, 3853335455, 1109119369, 2810579875, 2557150328,\n            194723070, 1511406773, 308580645, 1506805209, 3800717643, 1154701911, 3327639678,\n            1742392333, 383847505, 808485729, 1107933974, 1843546476, 3160127489, 461019178,\n            2758534633, 3136176283, 4161349001, 1122667843, 529002233, 1756067056, 610266011,\n            868502089, 1924153935, 3733910978, 2089140891, 2010741130, 1699263293, 1974321295,\n            2337744872, 2401421411, 152242715, 1841948095, 4080892494, 3557450617, 1648335241,\n            1739529953, 1965700723, 4159737024, 1826643625, 2624044999, 2662463178, 1453688703,\n            2373328295, 1284900613, 166103125, 2950850796, 224937865, 2363667655, 1395721930,\n            1038140390, 2227351547, 4027728456, 2456853028, 3392407547, 3558026617, 1022960493,\n            324320014, 1741363959, 665626647, 1989801844, 1039225187, 2749242260, 2891585679,\n            413980454, 1421911978, 542423805, 1198826717, 3829692439, 2424493878, 1743568705,\n            3904138435, 957436945, 3380949485, 3874828753, 3764048544, 2784271009, 3709257819,\n            2420168014, 2258006234, 1818204898, 4293192208, 1516897791, 4231562984, 1087919881,\n            3298788303, 409554742, 363790612, 1163362152, 1851768229, 3036249655, 1304207802,\n            2757649751, 1345091600, 3980437826, 845106654, 1191417084, 789417113, 3069537799,\n            4128120253, 1724644264, 1850762321, 440075901, 3081463549, 3296565609, 880610907,\n            3604815503, 825119004, 662787316, 2065720314, 1905930059, 3158622573, 2441285185,\n            609976312, 3214173289, 1972737948, 1856923900, 3881955749, 147509891, 13256522,\n            480264715, 2304077206, 4079499728, 1733454240, 683301825, 2067789682, 357755971,\n            4064960581, 880616108, 2567161687, 2143724680, 295233846, 885328588, 3528678059,\n            2821762581, 438733817, 1651128958, 266078579, 389905061, 451514054, 1632102041,\n            3121845303, 1370227908, 2165682378, 4205795758, 3678759448, 3760360877, 3616397292,\n            3496735510, 2181567729, 1760479516, 2226441722, 1169335764, 1685289328, 3980766219,\n            584449244, 1198456230, 3262408896, 3506319243, 3461775774, 3985269650, 4207509002,\n            2496174343, 4246361431, 2525595216, 505792351, 694109202, 2532334608, 177977694,\n            3590514888, 1386331403, 3322919897, 3677035627, 1748970524, 2355331384, 2803452306,\n            1684779748, 431295285, 2720257929, 1349292466, 196319200, 721926885, 2699941953,\n            2509363172, 2856348470, 971658703, 3158854173, 648569495, 806886112, 894065939,\n            1809981633, 2207773884, 2422134450, 2395969450, 154939100, 2258690857, 1558269103,\n            3746056343, 3625500344, 1655744570, 3783968316, 2684172985, 1026377946, 2668609092,\n            3087350250, 1696799137, 4172271775, 2172265355, 1009592900, 3751494892, 1102570367,\n            728659538, 896138123, 62660027, 2953563063, 2225405012,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_barrett_fail_1() {\n    let ns = &[1, 2];\n    let ds = &[3];\n    let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_barrett(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_barrett_fail_2() {\n    let ns = &[1];\n    let ds = &[1];\n    let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_barrett(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_barrett_fail_3() {\n    let ns = &[1, 2];\n    let ds = &[1, 2, 3];\n    let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_barrett(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_barrett_fail_4() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_barrett(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_barrett_fail_5() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[4, 5];\n    let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_barrett(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_modular_div() {\n    let test = |qs_in: &[Limb], ns: &[Limb], ds: &[Limb], qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let n = ns.len();\n        let mut scratch = vec![0; limbs_modular_div_scratch_len(n, ds.len())];\n        let mut mut_ns = ns.to_vec();\n        limbs_modular_div(&mut qs, &mut mut_ns, ds, &mut scratch);\n        assert_eq!(&qs[..n], qs_out);\n\n        let mut qs = qs_in.to_vec();\n        let n = ns.len();\n        let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(n, ds.len())];\n        limbs_modular_div_ref(&mut qs, ns, ds, &mut scratch);\n        assert_eq!(&qs[..n], qs_out);\n\n        verify_limbs_modular_div(ns, ds, qs_out);\n    };\n    // - schoolbook branch\n    test(&[10; 3], &[0, 0], &[1, 2], &[0, 0]);\n    test(&[10; 3], &[1, 2, 3], &[3], &[2863311531, 0, 1]);\n    test(\n        &[10; 3],\n        &[1, 2, 3],\n        &[u32::MAX],\n        &[u32::MAX, 0xfffffffc, 0xfffffff9],\n    );\n    test(&[10; 3], &[1, 2], &[1, 1], &[1, 1]);\n    test(&[10; 3], &[1, 2], &[1, 2], &[1, 0]);\n    test(&[10; 3], &[1, 2], &[5, 6], &[3435973837, 3607772528]);\n    test(&[10; 4], &[1, 2, 3, 4], &[1, 2, 3], &[1, 0, 0, 4]);\n    test(\n        &[10; 4],\n        &[1, 2, 3, 4],\n        &[1, u32::MAX, 3],\n        &[1, 3, 2, 0xfffffffa],\n    );\n    // - divide-and-conquer branch\n    test(\n        &[10; 940],\n        &[\n            1617001812, 406941400, 4290122623, 1353643808, 3101415473, 2776366000, 1481378761,\n            1754925789, 2932070541, 2268599150, 3665046852, 1854806905, 1473093751, 1310246577,\n            1085278892, 3448341300, 664884543, 894931028, 2986635139, 2227836107, 657956320,\n            2780373025, 723708052, 3678557934, 205944971, 3639109391, 1410682902, 273368655,\n            137589532, 2752044605, 212717727, 3792430292, 3119625350, 3784798586, 2990465174,\n            4284837080, 1139179612, 1590711001, 1736757382, 3899481945, 3054534962, 3715303406,\n            2871448595, 2613719261, 3519175216, 1742061049, 687836540, 3035159189, 2430146491,\n            3643811245, 1449733326, 909516982, 4131451057, 3824921017, 1370422021, 2664108177,\n            2259517283, 1110019077, 2291074089, 3844959301, 2341419713, 1983390487, 2379479711,\n            3103336479, 3631463561, 4141601545, 3984814009, 2847757328, 925199080, 2677150178,\n            3932146626, 2585985618, 3097165312, 624553107, 3497399511, 2463155636, 1025776088,\n            3972587430, 1776770640, 1070718417, 1149088515, 4112473641, 225083923, 3371457763,\n            2377652798, 2195213316, 3230992135, 2084781295, 2695452223, 2117879824, 920852431,\n            3418533408, 4371131, 2567093115, 3561201955, 3500513345, 1532361440, 2619974821,\n            1999143525, 1723126370, 2374780155, 3680488284, 328733252, 1032411542, 1853229941,\n            2293678997, 3094028501, 2057689466, 732918339, 449235695, 2135519188, 2885118676,\n            1010648119, 2686289702, 3794769615, 3150457436, 896104974, 1933155926, 3334021940,\n            944686456, 2364306114, 4136346953, 4200045016, 1969878091, 2569970022, 685844738,\n            2612152187, 860994125, 3220153414, 2803393155, 981612648, 3042964600, 1071555038,\n            2816042187, 3876557086, 3346011246, 1146392271, 2817040744, 1510282841, 325681574,\n            1630649453, 3288209101, 2072179016, 2821749271, 529631819, 4008039627, 3123605697,\n            3327357221, 1207815414, 2982053815, 4147131056, 1931822734, 353985760, 2963142283,\n            1073494612, 2091657110, 3979899238, 1802218645, 3796622263, 3071022976, 733595921,\n            2814034738, 2643673522, 4145539201, 906706184, 1357361031, 2806820925, 924346897,\n            4024033817, 4170035271, 751396103, 427807833, 1293458142, 825562756, 749911432,\n            2455906530, 2373035821, 2035314458, 523324040, 74749282, 1449696708, 1969230914,\n            1493171573, 1513766478, 4210281190, 1335461048, 707211493, 3186784150, 2467802616,\n            2058950664, 3722342212, 2509828536, 3802882999, 2600271262, 2092219856, 4157404778,\n            3400786142, 155585754, 652633073, 822626032, 3523591903, 1459099206, 2649574877,\n            4113736981, 1830792451, 2727586932, 1760483902, 241823374, 2715302907, 2576249518,\n            3361586004, 726705922, 3486441743, 16464902, 240807763, 1358538485, 4039078491,\n            1424904458, 2071547645, 3899722875, 3750426231, 2344735245, 1643746205, 491168785,\n            1384963465, 1750451847, 4078035388, 1770764243, 4052515472, 3241294450, 4243264539,\n            3310019665, 2887029156, 714075326, 1226997201, 3444729396, 2832779460, 622387501,\n            3969455295, 2045396250, 393223708, 226908064, 4072524790, 714484882, 1907609400,\n            3766575797, 478121983, 60272670, 898422298, 32593466, 2569174567, 391827066,\n            4035751597, 1908938867, 173327883, 2048138818, 230061596, 1242368902, 969448935,\n            1350957584, 1329847677, 1861496005, 381477284, 2549500005, 44785600, 873742504,\n            2067021143, 2991092988, 3548588862, 2442888192, 1877980812, 2914948150, 1098468146,\n            675021252, 3550660795, 705365138, 874024736, 17542161, 2817527888, 3629705143,\n            3195425797, 2175349263, 759180483, 625046999, 323114189, 2947844301, 3753994875,\n            2150414476, 3280636325, 148566019, 3393964028, 3188177781, 3019549329, 543709989,\n            2636840844, 1091743439, 2478470416, 2011975001, 1970347299, 2912238231, 715625754,\n            820695691, 3922781318, 3776236498, 3442057982, 921595229, 1441760440, 161150259,\n            1641485394, 1541289533, 3922947949, 3843619638, 3081238601, 3722091136, 1118176273,\n            621876688, 3997694905, 2566254497, 1508842638, 2833152011, 2269341704, 3805097671,\n            1910097409, 1778233534, 2629818400, 1928875119, 3415886257, 3654500721, 1162300191,\n            2855569689, 2679374632, 3480632355, 1697167619, 1916977851, 522312972, 3598627948,\n            1453501632, 1251971247, 1389213373, 807549034, 3088783989, 3417566420, 2280710564,\n            3403195199, 2495855004, 932408531, 2331161525, 3778497616, 16187086, 3485533486,\n            3495411373, 1786709186, 316453771, 1948970731, 2299432775, 3933979962, 4095089804,\n            379650624, 3914831055, 441554897, 2871518068, 3616069049, 1511616572, 3359750356,\n            4204007612, 2372585636, 3447071366, 2322506117, 272845013, 2251768829, 219574446,\n            805900066, 1562309083, 2747023165, 625123816, 3084319726, 1766945764, 730018360,\n            2396297375, 3185454773, 30578559, 2118564330, 2970233977, 3864914812, 3673919355,\n            387910790, 3961065920, 1279254859, 606858626, 3226772313, 3128243714, 3607492460,\n            1703562315, 2007811259, 2317297443, 3003813959, 3582624750, 2460028613, 4007959672,\n            3387473962, 2321603229, 2634383176, 1530063181, 653942855, 777144175, 3383143429,\n            2938927788, 152348935, 1627498490, 339085549, 1090554742, 566713397, 2625208878,\n            3313094379, 3682455164, 825072458, 3450039589, 825880309, 236573086, 225561664,\n            1245435637, 1331746952, 1353578371, 1858571383, 1507506405, 4248940778, 625956529,\n            3841763541, 1935501192, 113898702, 1717500961, 1803749553, 3698863369, 922793844,\n            3945374015, 4243233523, 4250348340, 3804428707, 375844143, 3217202690, 2958736927,\n            2390653610, 3913327699, 1445233502, 2564009562, 1981762528, 4082411483, 3027869173,\n            1427382679, 1184126161, 818177569, 3869201961, 3896288494, 2991466485, 3711933803,\n            569576015, 1555955484, 2471128165, 1976033094, 2785392947, 2319149042, 4011978677,\n            2965267321, 4102225036, 3477006125, 647674513, 2105038091, 1803927615, 783856168,\n            1324871043, 3615993255, 3431877321, 3971793725, 3934927792, 2179674064, 1248922540,\n            743817474, 1502564707, 803921101, 459529729, 3792678523, 2146248483, 4130547052,\n            3605002956, 3012317918, 4064731802, 4197909109, 4084469190, 1701485661, 3117730821,\n            972406826, 3210336796, 2256307987, 3848993871, 2176735158, 3781051143, 2680104892,\n            3305191212, 1603519343, 602901276, 1617518529, 2454120969, 1268075759, 498226963,\n            260513853, 1438206225, 3423412289, 2731106726, 234808220, 688404693, 1622003954,\n            1671415587, 4289391631, 2811620618, 1159840463, 856151253, 3940102962, 4048700229,\n            426530845, 2638052743, 3885492985, 806562813, 2558031618, 2366389147, 826787397,\n            1423193924, 819474847, 1921929046, 1831867082, 3600381551, 2477872533, 1029143458,\n            769714702, 2814119928, 4191052015, 1167365455, 2457269908, 975781406, 2087117506,\n            69469836, 1923853303, 1135113139, 2334628021, 663459911, 3006299219, 538724612,\n            3334068941, 2700983994, 1073161914, 3486899373, 1634133651, 1157990333, 1503694793,\n            1267044873, 2540754456, 1496511112, 781068794, 3561760800, 3895331222, 2500281154,\n            3412563576, 2764489218, 3868392337, 1074848405, 1646812850, 2199258432, 4258601309,\n            661369302, 874915103, 2014299592, 1949788135, 24892497, 680092321, 146288879,\n            3655059587, 1166284415, 1703237926, 4235856968, 2990205786, 3631372211, 1168518819,\n            1358761778, 2444279125, 2533070212, 2255837372, 3511526532, 3043738970, 1234663270,\n            2988008723, 4269697291, 4118872953, 910125556, 3167731674, 4285191140, 2460574472,\n            3150156454, 1702113899, 313167013, 3377687638, 3851000034, 2336152121, 3957198339,\n            1488999987, 3934439945, 654432127, 2247512052, 2811676271, 3497130291, 450665617,\n            2913226868, 1369911749, 1685617502, 3084648045, 1382681328, 3265795904, 35118333,\n            2698123229, 3632834581, 1779152731, 2940643214, 3013389545, 134571045, 3077109637,\n            4216881108, 3149045213, 4287730821, 3037477329, 1627490387, 1543881990, 375058941,\n            507557878, 2540666574, 2631980166, 487254845, 4018184736, 834259987, 493887543,\n            3678837714, 4006335571, 2894197190, 444039706, 2250255290, 3658855260, 2692485260,\n            3067208848, 177991403, 3168488251, 3931497670, 1064352145, 3704612442, 763514580,\n            2667497882, 2999748217, 1495439415, 231547898, 355122902, 3257752995, 2277957568,\n            3110120058, 857628464, 2568037394, 142755211, 815281764, 2367800630, 1224636898,\n            2080180449, 1355348312, 3289292906, 2297669780, 1847374168, 2276368440, 3819739502,\n            1791466417, 1102305871, 2354766268, 1338112610, 3463874583, 2021767462, 1066043808,\n            2309743709, 2571990210, 3315672796, 2398059936, 365056733, 3447539115, 3746732720,\n            3008661963, 3862798665, 2308467583, 1665116459, 1280978829, 3527882851, 3761190132,\n            671769688, 266901941, 3154667402, 1038908368, 2515820906, 1271818580, 2962093088,\n            3773575104, 2517853396, 4061725672, 3523770889, 2033488750, 2429531509, 2971035542,\n            4238011901, 1000531442, 1416882400, 678786363, 1019864239, 2751310982, 442339976,\n            55517395, 82583326, 1942516957, 3947856921, 722940461, 728206370, 1744336133,\n            2287954803, 292238920, 3911418046, 2155661057, 4159957990, 887247601, 556462431,\n            1016030816, 1512907682, 3069626937, 1472354633, 3141549111, 2016546891, 2821933580,\n            2770752073, 563151583, 221583615, 289067957, 3908737670, 2004753320, 3931101403,\n            883429785, 3689435720, 2987821650, 28050592, 2735311860, 3265507995, 2758493314,\n            2655530609, 2545294868, 2470465036, 1271710983, 545536994, 1327776999, 141840027,\n            1138841565, 1781544782, 3199919479, 681382208, 1245717786, 2930809728, 3280849083,\n            3956551507, 3355385777, 355999081, 2179057718, 882649569, 1825265258, 1442192351,\n            3389922361, 1461142241, 1668273192, 1024455283, 1363451707, 3165776423, 1708618405,\n            3593748137, 553996297, 2695393796, 1317090480, 2473638063, 3722258345, 2520027887,\n            2083034437, 1575395416, 3095210370, 3995459958, 3484130891, 803033008, 9632350,\n            3554497809, 3029973822, 706965453, 2956683625, 3768697729, 2368889001, 3579687116,\n            1507088502, 44440509, 3722401618, 10979986, 1440335280, 360127666, 3537309717,\n            2881783860, 821182819, 2620792872, 1352001982, 4178426943, 4092532482, 2378352391,\n            2593011994, 1487230079, 1280656126, 2550113868, 292018470, 3077472516, 3307900686,\n            3895849291, 1947913132, 636104659, 231356996, 3069426222, 1616111446, 535734499,\n            4152792010, 3810588916, 594013155, 3342644263, 3876779199, 2365417389, 2541878010,\n            631827463, 899645198, 1215887929, 2257594209, 3558848715, 3595018839, 2467717482,\n            368943385, 202032628, 353961970, 189404791, 2740031059, 1445247256, 3111695158,\n            2430510723, 1636469966, 3085197240, 393496208, 1147559660, 3854034067, 144621988,\n            901901079, 1157982037, 3309406483, 881900034, 1419066224, 2147885124, 1202171837,\n            4028375088, 344523185, 4281695498, 2098200318, 4285280344, 830500235, 2819516821,\n            2402660095, 3347692646, 429942249, 118042706, 2413131752, 1801992999, 1419387777,\n            917304148, 2405971626, 2514112112, 1486885522, 3561350045, 1391269566, 2312342833,\n            2165644886, 3237357298, 529810310, 533161912, 573572810, 2388955822, 1839462779,\n            3595785519, 502068002, 1370445852, 2940004806, 3127248122, 402923598, 942165049,\n            1322781936, 2267106055, 963050643, 2271136014, 593519182, 997148741, 1007096690,\n            2862595233, 2455777215, 87788237, 2537341695, 213203205, 3618812433, 934598945,\n            2019611411, 152516526, 2045476718, 4203041946, 1700636518, 2634288824, 957703279,\n            438300965, 752868345, 1741551695, 3299805511, 2787468423, 3915443541, 1822431092,\n            4184623349, 470943777, 3306758738, 2378813334, 887946583, 3895139974, 3274730894,\n            1775157124, 1716784797, 3766822546, 515029397, 366876429, 3967551838, 2567429723,\n            1242834401, 3586292863,\n        ],\n        &[\n            3316717475, 3755784115, 621265671, 2021086862, 474517724, 1164498167, 2627801958,\n            2170528742, 3104726388, 2515033406, 1702293156, 20581773, 1429119997, 2801585517,\n            3698032538, 596509909, 4238480986, 3843806649, 3322888890, 2861086342, 2626735834,\n            3405303428, 1508735314, 2650558814, 76337057, 1202565180, 2949817513, 3758629286,\n            1042329346, 3168950269, 883013312, 3720930735, 2244494029, 489190350, 4140126449,\n            2460687698, 888181262, 1751014525, 1555755626, 2244055025, 763172867, 3257618646,\n            345848605, 3619012015, 2273117624, 135239042, 1894337682, 2498817131, 351760917,\n            1230693073, 3288131984, 3614737212, 1133719825, 185344371, 2675805123, 1402914899,\n            3191767840, 3841311369, 2430249603, 3911615234, 2851144250, 2899717103, 2663597034,\n            1253013791, 851947363, 3119663958, 3884604595, 2250953966, 2832866738, 1236465462,\n            223567620, 1066146269, 3608374122, 1320851988, 3253186631, 2553947674, 1872191801,\n            516096295, 1195634624, 1449552529, 3856722883, 885977930, 3490641956, 2826234306,\n            3220379648, 3128438151, 1512748001, 655293586, 3885072026, 2836395257, 2848550792,\n            2316139958, 4224898232, 2632024198, 3603593725, 2166290957, 1571114837, 2145825902,\n            2043443301, 1891374967, 2046538548, 2488717199, 458651019, 2154445315, 2592455849,\n            3266747300, 98563372, 1904966481, 3676400896, 1716053111, 4206308204, 2658208676,\n            8001594, 1703645106, 2813029027, 894823261, 3726692608, 2449116480, 816030429,\n            3707476830, 1383662560, 2226126219, 3497705382, 1561989294, 2785389389, 3599384314,\n            2861958972, 26104257, 2618018317, 3938629738, 2008094819, 2901123170, 2341058897,\n            4197167100, 1303127374, 2903445052, 2658544205, 4149209641, 3128590068, 2172777857,\n            4127535687, 1057764004, 1621064811, 2989221344, 1862232212, 2949761869, 2620726474,\n            1750641652, 791265704, 2280902366, 3677859617, 1079043155, 1923182939, 2931362944,\n            123886216, 3043646978, 2297249701, 1035980818, 647873384, 2322301058, 2888236714,\n            2426466965, 3992010422, 910268721, 985368295, 1204228737, 3853108154, 2009215835,\n            893158799, 3476709186, 1783358605, 2497820589, 1805443650, 3969566710, 275487805,\n            3039957375, 514336764, 894146804, 2205031305, 2510265732, 1422658886, 227958265,\n            2068145443, 3893567490, 1543534282, 3541044587, 4205612325, 72081868, 3715915655,\n            3036960423, 419507608, 227127645, 434408508, 892436563, 162488684, 2166806308,\n            2727867269, 4081733001, 1736363129, 1586322132, 1569504753, 3585166014, 3409177960,\n            729399842, 600955707, 620409951, 4035728663, 3310125212, 4007687135, 1985227096,\n            198425200, 2174110521, 3681529070, 3128924487, 3475835290, 3105816703, 1645162765,\n            1329687130, 1438822241, 138742218, 545756349, 1589117794, 2874541073, 3226347249,\n            4238593852, 3175238090, 722760824, 2131293683, 359116635, 298494439, 1088923288,\n            1968400526, 425105133, 1003272490, 3419770934, 2286548114, 4069139264, 2021547095,\n            4252514166, 739676914, 1252440864, 2954914141, 891635266, 2569821890, 2274156960,\n            110747191, 10901206, 1932982168, 3445500258, 3634603074, 2076728168, 3765573833,\n            1087331828, 1830739116, 3074239474, 3109493948, 2614390121, 4096514773, 675737774,\n            1507210057, 3191779296, 487432240, 2260865324, 2080515432, 2883102503, 3886146031,\n            2630370868, 4277699658, 2892800514, 2200233033, 4132407774, 1674322414, 2982982405,\n            233528548, 1992281682, 4010179274, 132362763, 3820134833, 940222260, 1630667207,\n            3398377275, 59636590, 4159603377, 2127038731, 3535020648, 2726744939, 4053613473,\n            2694809533, 706296318, 3338739441, 3842009520, 2042421975, 318380771, 2862807993,\n            2988149892, 3967129325, 1725278138, 1137034794, 471477310, 2744784585, 3460424855,\n            1534357877, 3129901970, 2959751571, 981310577, 1151686479, 3917168837, 973476963,\n            1657796170, 57914437, 592921187, 458153097, 1933428006, 3953517828, 3462305086,\n            4127665091, 3416337136, 162732228, 1898167698, 1748974110, 1940432124, 4123185775,\n            3630680071, 582967365, 2778696182, 1253667008, 3496303486, 4269467104, 2724664452,\n            1077655402, 2678165119, 3253518851, 2109204349, 1050417512, 303542903, 1843757381,\n            2118812266,\n        ],\n        &[\n            760607388, 1277184530, 2981799216, 2484283466, 1845234507, 4067960649, 1724479507,\n            83819652, 3545040829, 3052531934, 420422484, 3643672428, 1349470285, 4056685047,\n            2832938505, 1491007438, 178763876, 1111495297, 631150561, 3047444289, 1566356971,\n            2488845930, 425164460, 1595773856, 3837001561, 484465035, 2820607142, 3804528360,\n            2674871824, 3186224219, 4087693654, 2920476376, 8588869, 558775, 3389974041,\n            2969506917, 2965452016, 3676587727, 210868935, 1114006350, 2218193233, 1556179958,\n            148150696, 2219106491, 1462994960, 1292243663, 321251749, 2464568116, 253403500,\n            3875750499, 2872190504, 163483092, 3519534673, 805076316, 2163404152, 615601509,\n            767178352, 1619091211, 1814614561, 1067405571, 1717163796, 3946244485, 3024690426,\n            2792967083, 1807679765, 431637400, 322732386, 2839911024, 3368845765, 1517033346,\n            2660595988, 2750276183, 4061009359, 1623680793, 757894942, 3706877533, 2218116650,\n            2293451319, 569823489, 698352566, 3510886798, 2554837373, 4086146958, 1954697554,\n            573960878, 2250331646, 303856091, 2708174687, 4046135943, 1693832138, 3593561197,\n            3446967787, 2952095018, 2269948291, 1381823220, 3412641037, 1102668748, 621987569,\n            1535069601, 767621348, 2590901967, 3254158348, 3515706407, 733878453, 346561487,\n            989792827, 991774293, 2178089063, 3612432705, 1736330716, 4220679880, 4097313986,\n            214252218, 399876886, 590654784, 1772229036, 768989885, 944426986, 26251316, 461731150,\n            2081388689, 3083458623, 706415427, 1827828472, 3899769203, 4083585540, 4247342897,\n            1726610250, 973927807, 2871216474, 3494935804, 2158506902, 1905985267, 3353223634,\n            3173570788, 1690463510, 382352574, 2134842019, 3565559088, 249151518, 3370936016,\n            2396613398, 3417046586, 3594305304, 3140493812, 1254379168, 698764737, 2933504786,\n            1640097237, 3137847969, 147779617, 2340800809, 3271699801, 123654759, 4243613971,\n            4091038901, 226197826, 2843561677, 452274519, 1696592386, 510445282, 3118679881,\n            85905218, 4025631594, 2028469208, 509528611, 1040836081, 2397186849, 1562223848,\n            2694595611, 3893476920, 2309600022, 2399768696, 296649436, 2674754660, 3089905235,\n            1453504612, 2462730671, 3620829868, 2445109014, 1608966704, 4064616054, 1895591320,\n            4020983935, 2194700822, 810629206, 2473380931, 3571447370, 3670144438, 2241547653,\n            1600037379, 1312769092, 4288987007, 2180603515, 2032431482, 3155930440, 2347081206,\n            1170375513, 804187424, 1588865075, 1003883189, 1403312026, 2521589509, 3447772884,\n            176190746, 2770328111, 1376304849, 3302569355, 2706302415, 771852514, 2551687698,\n            2864197933, 647550216, 2115432876, 906064237, 572464402, 3003545732, 864303856,\n            389881224, 2127293745, 1745696468, 2876423177, 434301283, 2411003884, 1459296715,\n            4116191604, 4123400655, 514083733, 3501677069, 560842328, 3484783459, 3147137690,\n            98562603, 1227984143, 3656369715, 1790748622, 207681062, 1858085765, 3042917557,\n            15051061, 2662004930, 3234896654, 2201418512, 2261075821, 2414525847, 2115659173,\n            1538531010, 3426973282, 1850436548, 3108645332, 3468490861, 103560194, 3847474391,\n            2304980299, 646430594, 3231078594, 939320799, 21325968, 297361623, 4235174350,\n            3627466917, 2483242091, 4046019218, 2574344522, 3739169162, 2592019430, 288825870,\n            4090930955, 4137250565, 3891494555, 3120605826, 2196869924, 3174597170, 1613629883,\n            685507332, 1534687890, 908779827, 3295054006, 3756384184, 2861186142, 1659095103,\n            1717981410, 1263584044, 1519352335, 2462230874, 2507408901, 1017299565, 1783063087,\n            585746985, 3964830516, 3699440600, 3536055582, 2697252588, 2469673820, 962878683,\n            4263311381, 3667261985, 3070169507, 2743455086, 1717498452, 1115060528, 3846008407,\n            2601161942, 1892836847, 2163612072, 759958512, 3415397520, 1318661582, 988342975,\n            1319302705, 2265404538, 1889584918, 1549178474, 3271275522, 2877014458, 290716992,\n            1767870320, 3388946514, 13220617, 3925060219, 884929420, 3247704764, 2619847907,\n            3003460125, 522300420, 1485636618, 3423826468, 4173033596, 9068662, 1399499354,\n            3671771326, 1257731400, 2320092093, 1591017631, 599804719, 155451276, 1685145394,\n            1704457903, 547504407, 515106096, 3101264871, 1006089811, 1373639639, 3788559554,\n            74017985, 1232649413, 780153206, 1697467997, 2186106110, 3727566152, 1581072277,\n            3430739907, 1111233986, 34667293, 1405231508, 1228646292, 1721533476, 476892877,\n            3639232096, 812825459, 82472797, 2919035606, 1949528088, 1351453055, 2062781753,\n            3793110056, 2099220542, 1317878085, 3082007409, 3316362678, 3051185694, 3814721763,\n            4123576632, 299554338, 1863096302, 151300891, 1996738407, 741596005, 1115878980,\n            609896904, 1128474784, 3757075843, 2332323233, 4185436105, 2320459296, 3864402168,\n            1830711645, 4274682854, 3920215426, 3480904315, 1735518575, 1450876856, 4150198541,\n            2232155899, 3944834006, 2497911169, 2383598128, 2094445320, 1342532472, 1789279465,\n            1000444294, 11639007, 1290432806, 4207854768, 3606748345, 1655667625, 1766854649,\n            440958770, 778291729, 2589089910, 3630396169, 3916516125, 1115783505, 1808920531,\n            1936074214, 1379602123, 2109970892, 672050079, 3681625243, 880229580, 1226430335,\n            2376783696, 4021974970, 3642478776, 1316164236, 4224587460, 3674694076, 1609544635,\n            3597979777, 1507369018, 2871382803, 2147895845, 46634184, 3128655439, 2042987970,\n            1565373672, 3820697495, 1861755004, 3965634071, 192091812, 1714797038, 1913602383,\n            1284821271, 535686584, 95183224, 2099444647, 3918351823, 2323427836, 3425011013,\n            4034948283, 830062458, 3077755706, 2664361966, 3369633219, 685190299, 3773862621,\n            3479436350, 2166056948, 1165446941, 597447203, 449505020, 1407500224, 2595439346,\n            4163318436, 2061079625, 328423701, 1694015638, 1739710589, 2700176438, 3868944325,\n            1880345981, 126900733, 4252410326, 1210883987, 2952395303, 2472131703, 2919687101,\n            1151019281, 2923524835, 744738035, 1495025615, 864881767, 3672741575, 3952364434,\n            1561011577, 1661355866, 579464773, 430715700, 3967156099, 3638535987, 3314993313,\n            39754630, 3015258697, 3965969076, 1226994342, 333446910, 1554778231, 1872069078,\n            3265886307, 3661167969, 2545225482, 86455596, 4170100560, 1688415942, 1011498191,\n            1731003257, 3624902119, 2939526631, 3035198743, 1225561695, 172905320, 779745656,\n            3939303614, 1180230735, 2279433297, 2623909995, 2744984397, 2464197534, 1263906486,\n            3664838213, 826505934, 3484580218, 2811919655, 2439097791, 742011920, 3984794087,\n            305740292, 4085693322, 1641069773, 2623476948, 1391797660, 2004149167, 3244285446,\n            1000729643, 537058827, 2761876864, 3370814500, 1632812628, 2024768271, 10435691,\n            1808177540, 3508999569, 4285869266, 3955904362, 999801692, 2701282598, 3234606559,\n            1828569180, 2238113468, 2835896689, 398984954, 628112193, 3250276768, 3848427074,\n            4046507569, 1227584178, 3624650311, 1983600411, 2035997048, 3406710114, 876143052,\n            3576865031, 1808241372, 47133236, 2032404345, 1238579946, 2439947599, 1090627887,\n            3162552029, 3743711685, 2946905539, 2462606049, 1934095111, 2581983028, 2108794193,\n            537838758, 4276183193, 4118403780, 86207174, 241654991, 980261680, 1783811780,\n            3182293354, 2600347842, 3815684348, 2736014977, 1734720333, 4292465690, 296762674,\n            1299907137, 2710350606, 2474176175, 4143658256, 3614357927, 3668497288, 1388238213,\n            4039173642, 4262328310, 2046246019, 11867698, 1389032783, 3383689984, 203861277,\n            1983217572, 66262335, 2302573608, 2106760160, 676069123, 1923174580, 781475291,\n            740922128, 1145598272, 1863497642, 4017642908, 1433452599, 2335232697, 2252173876,\n            2622261950, 558873943, 1782242773, 4277857496, 2736476832, 4066356669, 2928683215,\n            630971298, 1950508576, 1217075937, 657092636, 3655489968, 3906055628, 2142188310,\n            3431799034, 1433370594, 3460735328, 844557915, 1205870649, 1403166550, 664366810,\n            699119677, 2418845509, 2981098211, 1120979748, 3155458151, 1505569454, 1404478419,\n            3580055806, 298814169, 883897064, 1829019390, 1951530736, 450098305, 1015728621,\n            1355065591, 957492909, 2448099162, 1099299552, 3160642001, 40991601, 2335441865,\n            1242957033, 744421734, 1288340852, 838608359, 3740535760, 2237946750, 3362970437,\n            1146604084, 3552223768, 2000474849, 3302747771, 3289090092, 1179750911, 299925783,\n            417958743, 3758178331, 3103400639, 510077191, 2978242633, 4234232170, 2462645467,\n            3759250684, 2930664089, 1112129962, 2041179483, 538852775, 1881748154, 3282982596,\n            692481925, 2461480040, 1321990335, 2603998961, 891524618, 2762291355, 1602130552,\n            3063842230, 1512104437, 1311990640, 1124520432, 1943880370, 1383543514, 659628275,\n            1498309472, 3514392205, 1588156795, 1101447212, 234163485, 1550295807, 2222040367,\n            2338297355, 3634753617, 251867854, 637824295, 3385282073, 2717908232, 3780668880,\n            3282410375, 12579023, 3519277677, 3981301653, 2289038755, 522494362, 2949573042,\n            786166898, 1057696288, 329580624, 3463380191, 2483531405, 700795614, 2675217847,\n            3326945763, 1078245300, 1966168086, 4106783828, 513839480, 452541817, 992723496,\n            2322276273, 1610065747, 262720733, 1456710625, 2076208126, 1528480920, 2344925742,\n            3245103726, 3530526281, 1227544700, 3828557800, 202954188, 844439261, 4143421330,\n            858722987, 791357449, 3651495542, 2338484477, 628819270, 2867425597, 512142937,\n            1740596275, 1958985288, 2954923600, 2724470424, 239279551, 3549834366, 4273847436,\n            4205746302, 1617654892, 4055107588, 3345065763, 3918815107, 3690347759, 2780847799,\n            704192022, 577918201, 2047971125, 199715340, 2815715011, 4100422521, 304495953,\n            3524335327, 3863026147, 1090602107, 55579725, 801128139, 1204054409, 750920527,\n            3494787127, 1695780971, 3713381555, 3067697193, 3857711920, 4229533126, 1848429928,\n            2930893519, 3245738664, 2770202715, 3311103276, 3239813930, 215046932, 768437545,\n            3361501036, 668953535, 2523450946, 3426827629, 4294907906, 3567391972, 2118111054,\n            3636801154, 235010253, 506820626, 4082694685, 1020596576, 4286162559, 93467349,\n            2864513902, 1787418532, 841111654, 3988531733, 1803513923, 2454566170, 2924727696,\n            2008920947, 3384148494, 1392082716, 197522545, 1809534525, 2067947619, 1915304315,\n            1794320741, 3658475265, 2477556156, 3466391692, 759597459, 3446403109, 4175986942,\n            2016300498, 3285587019, 3805614518, 3359773927, 3758992970, 2082537230, 4170722751,\n            1924400162, 3120097767, 1817189766, 4215519640, 1640964039, 3460451146, 553294147,\n            3993022590, 936189736, 3289831433, 2746878752, 218269093, 3641264302, 3746904227,\n            127062817, 3607266633, 3906014892, 3583438340, 1711866360, 1769540234, 8808456,\n            692035790, 3582940716, 2726467727, 1377561547, 355273557, 2147522454, 1648952034,\n            3996367145, 3973855422, 791111697, 504755645, 3306755904, 3160971610, 1420009713,\n            292333945, 1246559702, 502418547, 2839194844, 1755323582, 3824720395, 280335533,\n            2486741893, 3748085109, 1510237367, 913162122, 1367015807, 2150739469, 431332632,\n            2458778103, 468839323, 631541365, 3621249238, 2195421604, 2309648614, 1907083220,\n            1785404891, 1376379485, 1304676200, 1670817555, 1112332257, 2685812955, 3507402533,\n            2655556228, 3969960616, 901856719, 2257719427, 4169793859, 3281921750, 20313081,\n            605538211, 3389947560, 1288421142, 601129353, 2630934375, 1090529584, 3541228947,\n            2135095396, 2428588788, 1720926402, 1972699444, 1936465090, 4196883041, 1513169082,\n            1306967955, 3516168954, 2504390827, 3238431030, 936930168, 3824872735, 519589764,\n            3699706696, 2222441744, 2342278743, 3084957176, 4290410350, 1778787953, 3015190990,\n            2716506129,\n        ],\n    );\n    // - Barrett branch\n    test(\n        &[10; 1659],\n        &[\n            890276236, 341226799, 792588053, 367901941, 3412384327, 710303656, 2007116218,\n            1732149551, 2749665392, 2733077788, 1892910904, 3903262213, 3368335519, 980935858,\n            449583968, 1960964070, 82417675, 2300807023, 737772447, 2848196409, 2168358691,\n            2864360576, 177909817, 2598798571, 1444232680, 2011304558, 436734343, 2531093317,\n            1833818035, 2701704151, 4079761960, 2060337785, 3666406285, 2332405305, 1694319899,\n            2756923912, 2596868778, 3353801212, 2319197408, 949456643, 3210673236, 1574562999,\n            1402290323, 875914832, 1808447500, 1400287402, 1870271379, 3193561790, 2631625063,\n            422393142, 454330683, 1399511891, 887928993, 1982772955, 4249787009, 1042550992,\n            1845718215, 1923499583, 2405586067, 3603194566, 2924605215, 694963825, 1949261922,\n            395815473, 2098120598, 2155391008, 3001875867, 2497152933, 2157055549, 1494381162,\n            2624433809, 445187226, 1230608566, 2984284721, 1836275894, 3306237100, 1841513512,\n            2710642428, 973820593, 514673088, 3144609082, 3051871892, 3428549981, 1521009477,\n            3865181386, 3006578727, 4266792118, 1296136965, 2663669369, 2707104363, 1525098552,\n            3096200455, 83349968, 440117228, 2452613966, 1926577488, 404744979, 1730348753,\n            1281414650, 2753590879, 2501408984, 2436683689, 4018005907, 3151813017, 774894936,\n            928812960, 1406876714, 1300626258, 3795254718, 572793086, 504939191, 1858924532,\n            3208327188, 2458888708, 2209857693, 3635862246, 4015896456, 2424475729, 2407841828,\n            1838875522, 2698758219, 900362220, 3297883135, 2319766547, 3926911411, 2683221001,\n            635164605, 1978063173, 1554445660, 4039067308, 3534363633, 228909859, 2698728084,\n            1446768153, 3078533766, 1803252867, 810281015, 1437865883, 3136549314, 2523233981,\n            1635904205, 2841910210, 2673459917, 302753536, 3721460164, 4235982205, 2610290684,\n            3241605472, 3116643475, 1191081198, 2046254645, 101183106, 1647792738, 1559541261,\n            3806071610, 1461177358, 3272653778, 1407647063, 2448211251, 4228622147, 3316552027,\n            2359816329, 1591928596, 2248518657, 1224679111, 3354288039, 3472204054, 941606258,\n            1209690115, 322676832, 2932831862, 2003163428, 3206276298, 993107033, 2629921131,\n            3427077956, 4115430705, 18758505, 3427417332, 2001126401, 2108037391, 3665577171,\n            1863775255, 943945131, 1612515047, 4135299880, 3120161330, 280157154, 2453614374,\n            314225268, 3156105086, 1108918989, 164492394, 3228445085, 159609226, 3542796998,\n            3908606313, 737372698, 4020386652, 1541117308, 4079987109, 831583516, 710011798,\n            2517260657, 1502443551, 3947743604, 2630448337, 3713488594, 2045169924, 4240999995,\n            1008865782, 4189193897, 1658576435, 2238907645, 1755810942, 797651323, 2137409038,\n            1033636473, 4124730937, 3073837451, 109594062, 2690701355, 4034943218, 1405033142,\n            1440037662, 1082006809, 3569043007, 3728191023, 3761504320, 4122286843, 2321793213,\n            1900629490, 2311374908, 3129571201, 3976202280, 1676045885, 544386369, 2901355594,\n            3307278941, 2444850863, 774358865, 1135879223, 4061259975, 2102938029, 3898096702,\n            3670762822, 2514569341, 3882503461, 1631374873, 2849583118, 3325748020, 2953632965,\n            3236697735, 93102960, 765161636, 3854704169, 1573342719, 1310401001, 2041585538,\n            3684168483, 1596820840, 3244422616, 3149564815, 3111579294, 2543256788, 285031977,\n            1116476069, 1854107100, 2993132022, 2237783497, 1121738400, 1873498161, 3906059657,\n            2868037945, 2128298315, 2461778166, 2519976634, 1169495678, 145517031, 1089544388,\n            3496922453, 3858416589, 3577132981, 819516733, 360815306, 3662368821, 1541910226,\n            2826451779, 1275644110, 1972056710, 1036339248, 3879421912, 168837530, 2778017004,\n            508177746, 1418725768, 2362803078, 1537678007, 4273641757, 1157309391, 2027675884,\n            2766447468, 1140619111, 280217396, 1977767061, 3847572985, 563089282, 2707116985,\n            565542300, 3133606843, 1550118329, 4226756370, 1602547683, 2474372184, 2817100937,\n            2304466412, 3401474958, 1765460555, 514706751, 2958558266, 2788304434, 728359185,\n            3110910343, 2268078075, 2011266928, 1833177040, 3411609757, 2509364835, 2276646789,\n            3090785310, 410706208, 3982922454, 396138284, 1225183095, 2653156018, 1198560357,\n            1081851637, 4266095252, 200467546, 2084872625, 3819726737, 1842926566, 2137414674,\n            3780793518, 3803338949, 2618440541, 3079036479, 1098784392, 2442578090, 3632573226,\n            2172339623, 2589618514, 3908085439, 2879837004, 4287758566, 2751698111, 2126731652,\n            2825624276, 2248293625, 2459102047, 727371099, 1762220065, 2035848579, 2684644913,\n            1138174417, 1607470803, 1910213315, 3392274014, 2122238927, 799528170, 3993036983,\n            3276585428, 3696900606, 3376656588, 3273677417, 3728672429, 2897266369, 1209435480,\n            3668943597, 554740320, 1910520674, 2755821121, 2815354947, 628678360, 1972408136,\n            2959168464, 2823142531, 2826638433, 2423863843, 1087171516, 3879922452, 1945794416,\n            3539137213, 2491723621, 2326706944, 1055221317, 1132982204, 3700164345, 2874108055,\n            4229375434, 2069834207, 242639877, 1033996106, 3133990269, 2480736852, 3972172611,\n            207742724, 3310273273, 3175731064, 3581837682, 76902028, 4245157123, 4269031394,\n            2490069025, 2999666665, 504120169, 191809390, 167412924, 555218984, 1496941280,\n            2093783841, 3208530629, 3145850049, 3933461123, 2175208309, 365172205, 2462688963,\n            3453497377, 1555304950, 4025179114, 2083241909, 168967519, 4078676060, 4042564952,\n            2524740606, 910140135, 2191946661, 36949303, 2750127471, 3088746837, 1513675215,\n            2555879390, 718186264, 2118995763, 2901874435, 2945636440, 2863577556, 2968054349,\n            2987445655, 1391389309, 3362068597, 420379086, 3549925062, 2452687361, 1408886777,\n            2462121091, 3799278878, 3322044177, 4293985015, 1286609586, 2785058305, 4274674252,\n            2778156482, 3910962810, 4068513623, 1564413978, 1181250931, 3988825528, 2788859022,\n            2134808366, 2286009824, 191534000, 673284258, 943092112, 3792387654, 1636364244,\n            1258619608, 2687335657, 2373558306, 1780255272, 192951187, 431701677, 3304549528,\n            1704199693, 314302815, 1733754456, 2651178366, 262110118, 2490882199, 3280711290,\n            3787049925, 328986136, 1023802009, 1956694362, 2484923034, 2727330053, 2638100006,\n            92690660, 3896101961, 1028256658, 3988282321, 2110531875, 1842222098, 2787896255,\n            3395969716, 990977104, 2139528143, 1832975942, 4160298612, 2285171947, 1418666556,\n            222644271, 919581311, 862681678, 2923905104, 1799774966, 2815043367, 2781755775,\n            1331093883, 669689278, 2966365455, 3173764511, 2239898981, 2363266499, 2640372661,\n            2127456692, 2279796862, 1776783331, 2548834983, 472218271, 2900695473, 1495706076,\n            2657343542, 209220262, 275069056, 3271376502, 3733744095, 3534782378, 2464305853,\n            4233994418, 1155007782, 1180251759, 1970459014, 2342844621, 59653648, 2748740588,\n            2766398852, 3832978838, 242101716, 1386468541, 1326666089, 3173296092, 2837432655,\n            3998816786, 3710871416, 679295186, 2135255711, 1894408962, 2653191387, 3752231861,\n            2630930863, 487033484, 1492980844, 3038367576, 4293864058, 2543786315, 3417240532,\n            2205003924, 1597945938, 1509635773, 4283299822, 3442672823, 4165828898, 396431869,\n            648731431, 38097411, 522913513, 957583354, 4279028565, 2596119340, 2064412533,\n            3862275959, 3172491786, 2807778054, 1802160322, 2786925709, 608133700, 156702572,\n            3651500279, 2104603013, 2661177081, 618430078, 2315385783, 299901731, 2422105030,\n            2329676657, 716074660, 1732980457, 1214771864, 1586076972, 1803988277, 3707411655,\n            2659362119, 2373571795, 770730047, 3785576910, 735242862, 2539172759, 2203837147,\n            1488005025, 1384867732, 3789824993, 1122099741, 552382082, 1506769429, 4044090493,\n            1748889897, 4206809578, 781459036, 3672028809, 2541707199, 840152057, 238216856,\n            801669583, 908070471, 3215820340, 277209814, 2800868730, 2623960742, 1086085297,\n            1126632972, 4142066460, 1949273163, 2523144053, 2629334386, 3335675532, 4057941621,\n            1205937990, 1082630648, 1878674537, 1256320064, 1727330605, 2529007873, 4276070038,\n            2148176144, 2447857920, 3472917547, 1158643513, 2671603905, 2829575595, 3450336191,\n            982424809, 882567930, 323789646, 3200918344, 2216686077, 3009541444, 2571083160,\n            1006292466, 437753632, 3278939834, 3355173103, 3481349388, 857243294, 2364943880,\n            3808395135, 3214225862, 3777869070, 3565105852, 2808230263, 221823914, 2758813582,\n            2925915811, 414573289, 2532719232, 2409558681, 270315198, 2558439626, 615075030,\n            4089479722, 3494552549, 2115205628, 74023539, 2750188165, 1839125170, 583459154,\n            3761181274, 2329244963, 1691231890, 507167187, 4046741250, 1026250436, 902121215,\n            2344634879, 2988992123, 2984781046, 3518129686, 1917222692, 1968401639, 2543696192,\n            3620784874, 4204784824, 983090664, 2003341457, 3457430091, 1995667040, 2478215910,\n            1213924330, 902607969, 1674777804, 4280126343, 2726668253, 2097919452, 3522418576,\n            33515971, 1894400520, 3029857368, 150356335, 4243001247, 673978253, 2719146244,\n            2090227855, 4192329224, 2236320436, 2148835059, 3185966796, 941447358, 779143957,\n            2545384906, 340222909, 1163954627, 3190577527, 864905744, 3107306228, 910249975,\n            2948352628, 147585477, 959446574, 3474262008, 4035464440, 1309641572, 1843324139,\n            594300461, 1004840213, 2224007255, 3852374975, 4120257334, 2723207946, 2794257458,\n            1545266608, 1321887969, 2165623498, 4123085504, 1017498034, 2385703284, 1909037055,\n            543047021, 3878828835, 3447407518, 1606126047, 1695313677, 836832112, 3506770595,\n            2603100919, 3453043698, 199938105, 3434291843, 3309362210, 3420539779, 3881672999,\n            3941526979, 1892491834, 1578793338, 2517226952, 2402834890, 5862131, 40700601,\n            3714441463, 729961232, 1925856845, 3468241001, 3115568092, 1631854454, 1701899766,\n            3027256253, 2894901269, 1124111614, 389357030, 3985153554, 552236945, 2703725197,\n            3429926834, 2037737468, 2457575384, 3768369718, 1501137909, 1925317821, 2657749431,\n            3797990637, 4187234508, 327539080, 794903321, 2319399609, 2762815786, 976015557,\n            1691624096, 3787965011, 1187388905, 2626212695, 3807450271, 3591385293, 1093027360,\n            2171140441, 1152487697, 3182952906, 2771269699, 1234596937, 2271936819, 603050394,\n            3263289503, 3560700020, 2800995941, 1196053050, 2414391090, 1881373224, 1884483033,\n            2568796666, 3824541190, 3858390730, 2040352321, 718151978, 1377901177, 1597261066,\n            2356591213, 2419086272, 2844721838, 2553373958, 3487777061, 4036573915, 3960541066,\n            646040800, 4243906341, 2572505351, 1801145995, 664327833, 676356931, 2958233650,\n            3981016651, 481021340, 418338722, 3399065823, 3030397492, 150785760, 1176367446,\n            2939257689, 32665451, 2951976791, 311905711, 1897102562, 3243398501, 1748429176,\n            1746479862, 343846941, 2781004348, 2171670176, 309744191, 2415354772, 1041777746,\n            2288489926, 4248954013, 1910365690, 1113007596, 3208904334, 323062080, 584001309,\n            30088757, 3210313377, 810170431, 1442786337, 854351100, 904966376, 768074292,\n            1149027717, 3752792280, 3857132892, 2279768216, 3349859712, 282292503, 56581336,\n            2391268817, 2947375479, 1126824647, 4105649938, 3962247540, 519562385, 1963761442,\n            395588526, 2431054442, 950162585, 1570376756, 2250607225, 2673908656, 2527346059,\n            288669023, 575810459, 2786581872, 3735760778, 4200489389, 680967503, 1713328630,\n            1930270331, 2425215981, 3980660137, 4014429658, 2192587396, 3942840373, 1564337241,\n            327120779, 4156973813, 3880803765, 3540049821, 1863580480, 3375736133, 4036504068,\n            1785184442, 1955521254, 1453896460, 1053996688, 1978861082, 548425572, 302301885,\n            1991013158, 22073650, 3921072009, 1928162922, 1082841772, 327037462, 1044813693,\n            2938349910, 995698425, 332894183, 1388488396, 3872091479, 4029340893, 3277696405,\n            775391931, 1016127394, 2545485682, 2073876466, 1128541985, 1496426020, 80233992,\n            1338981471, 3354539036, 3085869246, 1640435947, 3318556546, 3284845655, 2946418668,\n            3047158280, 2003184416, 159404031, 2086225997, 3708415056, 820845255, 2941403694,\n            1894980986, 4054398500, 354127917, 1759927817, 461854099, 2756970748, 102702694,\n            1301323588, 2833690096, 1511747665, 2593308423, 1879972490, 1838875158, 2618211449,\n            1797209275, 120683822, 1883611437, 4202360723, 4128014501, 3211136205, 1088772951,\n            1828585088, 2938812583, 2284221739, 3823561623, 4077006488, 1029205999, 3672550742,\n            343538454, 3044781643, 1237692065, 2928228237, 1830634178, 275610581, 3774294394,\n            3361331648, 2196692892, 3255359432, 2329150995, 1274593100, 1328237401, 1721689163,\n            1552282513, 3159830746, 3644636753, 1105036069, 355771027, 1576347151, 944409757,\n            448354212, 1354862379, 339109623, 3510474598, 3466751984, 20825450, 3821901448,\n            2057496944, 2943845147, 3219926439, 1333132401, 183117509, 3498530864, 2182448771,\n            3426279410, 1665731931, 1510911964, 1196289032, 2580562014, 1929195017, 2594768969,\n            809172016, 2653623722, 2512680195, 217752055, 1721337598, 2483986094, 2361703097,\n            2370506525, 1987764412, 517621644, 693022222, 4199398517, 373355871, 3352107025,\n            2338083298, 159801450, 1797870121, 2860144576, 3939907735, 3514862832, 431143617,\n            1623844364, 1508889091, 2387069842, 1972468120, 736883904, 1753611344, 1661123641,\n            2409352944, 461880992, 2038512497, 3457487084, 3961958981, 801429985, 2972366430,\n            3338662267, 3327375019, 2105332644, 998675685, 691868141, 870966463, 1279549664,\n            3134690576, 3190301255, 1631564609, 1367483321, 2646565011, 634484526, 2537380840,\n            2213333282, 472168933, 3498162369, 4174275366, 1543944344, 3557960735, 1147270417,\n            3787417027, 214242757, 3877605781, 1792046194, 1247989220, 4226299524, 2026490398,\n            2743362165, 3282533732, 1766662214, 3166276549, 3016180603, 2258391278, 3962452054,\n            168300410, 2111946937, 713217908, 945581724, 3974119689, 3587010488, 2181601474,\n            246735659, 2543921339, 2723353212, 1467436138, 3185503405, 3831196899, 158015188,\n            490283336, 2084333291, 2741425836, 655722571, 2045963231, 4174037980, 2501752755,\n            148738138, 1307383368, 3787063365, 721414861, 367804370, 3580824327, 4086466283,\n            1279991485, 2037844627, 3544424029, 843306486, 2062910422, 2484907808, 2564538263,\n            2558157768, 3736247186, 2359778109, 2792113263, 2653179154, 1171565785, 970085568,\n            2755189942, 2462193088, 2187804183, 1622505599, 757911218, 3544379371, 4084601374,\n            2831197190, 1128632808, 1911943420, 1064662251, 617203970, 3185110184, 3872537015,\n            2663673571, 1598938612, 2021095595, 1230226206, 3352634834, 3243340070, 3521473899,\n            947764553, 1063048833, 332597817, 1892887725, 885809381, 1232744110, 488758874,\n            1219451925, 3879973077, 3087466985, 1317009576, 4096728294, 1647182459, 2603742762,\n            3671645026, 2351436637, 2208571110, 772272953, 2835855429, 3069601842, 3507496189,\n            956062404, 1530390718, 3749254585, 2207726706, 3111772294, 1060767761, 711759067,\n            2176543833, 2198489800, 808754055, 2305333083, 3151555404, 2509458656, 2135135534,\n            3230952171, 2571117847, 2341460893, 479051995, 1768657443, 1460137774, 2415002930,\n            3360777084, 1122116253, 303290829, 3416566333, 4216166260, 1908146236, 645774129,\n            2687866494, 3150948846, 3002877577, 1584197209, 1906233324, 2943774631, 1302474040,\n            123233115, 3070944438, 4059478095, 966454883, 1124649660, 459555946, 1739202231,\n            220401749, 569942371, 3571881666, 3770440911, 932409766, 2318445287, 414753024,\n            1238020551, 1107839477, 659942128, 3483946741, 465817183, 3283253432, 3332782561,\n            930288386, 1502477361, 289384294, 2672225570, 656751994, 1938557826, 4263515785,\n            3846686615, 1977835682, 3782978161, 3841096638, 2100335863, 1466976524, 905037512,\n            3998859595, 2647592476, 1315412287, 2608076472, 2106055663, 3021269968, 3874586748,\n            3153686736, 3797040333, 3195133207, 1058452397, 471283566, 3289919590, 2491009200,\n            274949631, 1247099012, 4029069224, 2905208231, 2179210118, 3711788704, 3755257973,\n            2928888484, 1052560560, 2967164700, 1635564638, 2408974105, 2650877150, 152761664,\n            3778129977, 6898243, 3642738916, 2085555548, 4208692126, 3516476673, 3689736495,\n            4284496225, 2331191533, 55304992, 3822559904, 2239314561, 371351603, 1372721940,\n            2935911010, 2081736209, 3779840280, 1714652721, 3411278140, 2654198957, 4262940016,\n            713862676, 3977788884, 1302513367, 1393129292, 3633035689, 2006841374, 3188426778,\n            506706704, 4019796909, 2697310122, 2678256017, 4001202363, 4268990548, 1518149683,\n            4051379891, 2122891199, 1746178525, 1962304081, 3865021362, 1312381895, 4177647623,\n            2434495123, 696907907, 482662266, 540053306, 2380506995, 3725670235, 2171452643,\n            3435152939, 4096541777, 3503333448, 3691060485, 1944004703, 898436730, 121854915,\n            1588868274, 2860886605, 1300182839, 1693834903, 3031447227, 3217167554, 2922628107,\n            4114756146, 2079196834, 2684932909, 363311866, 668991145, 1327347517, 2469568598,\n            1913706668, 268108277, 577243285, 1477909197, 1398721081, 4010189391, 2691034717,\n            1036016821, 1810355639, 274912831, 1795119756, 1368326430, 2579557677, 913700763,\n            1609695519, 2382496942, 1044984785, 303066142, 1822891534, 3029842660, 4197043641,\n            584103984, 1997889445, 3604603832, 3119992851, 2675724476, 4061366219, 2925184984,\n            2195814396, 429034966, 1102290544, 3100888502, 3392886272, 630724501, 315124612,\n            2110860880, 3375452806, 1360073167, 1663964263, 3704594026, 2156765374, 2209318060,\n            305106236, 3229984531, 3679679759, 412339952, 3408237957, 4272496758, 1831873985,\n            888956855, 2879515229, 2865192273, 757175501, 1423828575, 1369325109, 100316687,\n            3388465856, 2777010920, 1042158042, 1817540433, 1115141275, 2632434501, 4015855401,\n            4118763832, 942872566, 1619453899, 3946427286, 541394029, 1528755909, 2036673964,\n            1456023963, 4059819153, 4121822726, 2025464163, 3230339097, 68415417, 18265310,\n            1132496724, 2754635682, 385314119, 1567156044, 940632399, 1831395946, 2469397928,\n            541250595, 74019926, 2039901080, 773704780, 590385326, 3107133266, 2143056697,\n            3257519203, 3995912435, 2208286868, 1856405930, 1700973893, 1653979838, 2024515776,\n            3218710950, 1084145854, 1317505497, 3590817427, 123061081, 2076656022, 4077554585,\n            2879482171, 2950794060, 3734348393, 722767161, 3691545699, 1644306454, 333687306,\n            2241964536, 3060788682, 2453668285, 1189757337, 1263877652, 569206760, 3846943302,\n            4010117854, 4059584053, 4044950226, 3638405845, 3879375082, 2049939648, 1496362390,\n            1682303551, 2612201683, 3043389670, 1640230718, 4052525226, 917568678, 863698076,\n            993517383, 3674253221, 744083165, 2026633641, 1428745764, 3316111420, 296209737,\n            825439661, 1138886542, 4238983059, 1093858251, 623018211, 509903369, 3954989263,\n            2875469802, 3163782305, 2068031367, 2440167512, 1590471250, 2577400899, 1401443658,\n            438753386, 973022558, 490459931, 4153136453, 2638113298, 1725729658, 1657506325,\n            4041198040, 3744818426, 1877561769, 4134538451, 3997643962, 3278471793, 2418908581,\n            356962783, 3224136760, 2919949586, 3613171265, 97663361, 3097697220, 3489004921,\n            2697784225, 4279173863, 3772958071, 3905886590, 1711013393, 2126838688, 990698143,\n            3920056751, 3588492473, 2098301822, 1854964825, 1664184868, 3795158895, 151603425,\n            3531429187, 3490656748, 1113504873, 1471018271, 4168869499, 4008256495, 2171869942,\n            609135193, 2986518561, 1725952510, 1976303843, 2274910761, 242274490, 3473272380,\n            3970326612, 2167449820, 1194973795, 3783506867, 348209623, 3135533248, 3532222693,\n            3344736663, 214520997, 1636130783, 2067796675, 2369417375, 2235358466, 86178644,\n            2779810734, 4214159539, 3218271482, 3985230716, 2329504243, 147581458, 1474992222,\n            1674107989, 3428339487, 2770470340, 1986697826, 2655128050, 2876733066, 1471032373,\n            911683545, 2090594993, 3437186916, 3308018952, 533482761, 1086927954, 3676694935,\n            3342609410, 1508797862, 2500353221, 3720936876, 2701068861, 642689761, 3643678624,\n            290806518, 83395626, 1535005732, 2747794047, 3570146930, 914908213, 1337975084,\n            1497808741, 260949154, 4207131444, 593904854, 3888947157, 195239383, 3774140559,\n            2853428653, 3136732762, 1248240658, 2234958820, 3762975745, 1162679573, 272129118,\n            296868072, 3334585892, 2918794318, 1694070693, 2492485295, 2683814086, 298872871,\n            817942615, 1004532076, 2606294117, 4046765057, 2233192255, 3661649470, 2238986852,\n            1062091508, 2399311242, 2885215834, 1798967492, 2531479104, 4074434116, 2111742327,\n            2896836169, 3250431, 1770836879, 2620395921, 501323762, 1835526774, 2803163141,\n            1991155504, 2143149513, 1934058381, 1289076816, 2032493823, 3585211537, 2907068377,\n        ],\n        &[\n            1957536939, 2704233779, 913359386, 2607986801, 2446464778, 489495221, 1977138138,\n            199874920, 2066813840, 4078462749, 1016088557, 337324630, 3990125130, 2305453367,\n            3378159386, 3362499975, 1892329456, 421235551, 960087932, 2138732375, 1747069721,\n            2966299538, 3497725227, 788194103, 2620925095, 3992734827, 2347614949, 1192266871,\n            2152140927, 2595902702, 1509482398, 787254206, 2484597728, 1789728733, 1226715026,\n            114480829, 987023760, 3496800953, 256020284, 1894092757, 47387107, 2176522500,\n            2135704654, 994057186, 2546241901, 4122251778, 3491731236, 384111784, 1236832234,\n            3662603701, 2609281585, 1219883919, 2008118687, 2326006512, 2338027654, 2332414668,\n            2538669365, 2958308350, 3306252952, 4097401440, 245412822, 1134218707, 3076680142,\n            926168655, 451578268, 1698122066, 514466774, 1794890875, 2253188253, 3860209307,\n            4125975400, 1233713256, 1331554757, 4108025645, 636835921, 1849327003, 393004812,\n            2558555361, 1692156580, 3582970009, 914267920, 2658172248, 4012245606, 854232321,\n            1471576996, 3492333793, 2913754320, 2051701466, 1005511236, 3371062639, 3296185640,\n            2678783225, 3650455045, 4263496163, 3495211840, 160882721, 3272734255, 3363410960,\n            1673492685, 2227170400, 1101828895, 1119793884, 1457840656, 2222657767, 3828794092,\n            4237803786, 1329436877, 2830186178, 3860284552, 1337378154, 2783161843, 470651568,\n            1823782186, 497979415, 2298463213, 3726533213, 2304335399, 3374908291, 3136539039,\n            1011793524, 1434135959, 3546472177, 3334783571, 226156373, 1932074218, 631985614,\n            1079925731, 3769906884, 4019194278, 3109451869, 1778729352, 3135074288, 3585179302,\n            536686269, 269921815, 75736971, 1251776355, 3758315612, 1656722319, 3842105657,\n            309256249, 3658053371, 1366755718, 2879694669, 216747845, 1138851530, 180246577,\n            2017139089, 1955595458, 1039824550, 3194217029, 1733371216, 1506550177, 526780059,\n            1134528034, 384391871, 984118045, 3841118292, 1290155172, 3325719027, 2046692404,\n            549115234, 1571136961, 2903831138, 4237164623, 3384940491, 444561690, 1887009067,\n            3032883562, 528649308, 3526917838, 861967137, 849430599, 1174292170, 3363871839,\n            3164890264, 4139898798, 2515068538, 2817798053, 1985333569, 3628916450, 4104808900,\n            834622482, 2376137274, 570637315, 265226452, 2900200945, 3714687255, 2191892020,\n            1444354629, 2162094270, 1794298889, 1027492948, 3254523420, 3973688556, 70444914,\n            4247183201, 2558259799, 1382220873, 363937698, 1293687680, 2257401251, 1821850058,\n            2709286660, 3142574973, 3132883088, 3836062384, 2080511414, 2488073709, 3338281745,\n            158637847, 1975561389, 3788657841, 2878593484, 3932639038, 2471341193, 2976486658,\n            4177193258, 3207728388, 3451499189, 1036976564, 4174152173, 1200214586, 1593901807,\n            1598813685, 3572817953, 381665761, 23270196, 1802671154, 3457511367, 3684670008,\n            4141234293, 4257731307, 1636422959, 740772838, 1988075395, 3741682939, 91025578,\n            3019507910, 1239453327, 15530035, 1805537881, 3030234017, 2850226774, 647324122,\n            367062563, 997518198, 694008483, 317521938, 1160123804, 725289606, 1178038187,\n            1241619590, 3354084342, 2764339200, 624229820, 212334275, 395480330, 1367723402,\n            3193328333, 492787846, 2912412117, 769721138, 1070730529, 448893800, 735046630,\n            3751288669, 2414740806, 2618411130, 405231076, 2516857660, 464468370, 3258011579,\n            1477182041, 493720224, 2850809713, 3137078323, 3502041365, 3173963137, 2479519371,\n            167431223, 3658737457, 3772800354, 1986032427, 1987941758, 3573465175, 326371902,\n            3433869641, 1504044245, 2797511645, 2359717369, 3995931882, 1634803252, 4253137604,\n            4268085428, 3040903829, 2277724443, 128782128, 875783256, 479424864, 528909344,\n            3760571120, 3390001080, 3322552131, 2303766273, 2363235433, 1521779839, 71576180,\n            1476909520, 2716820223, 3668085110, 2404806181, 3808398898, 551144165, 396216221,\n            3351190698, 2567267783, 4253613190, 436775, 1500218837, 1017116170, 4018991981,\n            2949611141, 2820025183, 1026140859, 1421949338, 3652746241, 4092056796, 812077816,\n            400306669, 3639988628, 3886839943, 1895304730, 426912903, 2799536256, 648522878,\n            3154874866, 2278734966, 2267078837, 3248002806, 2570845216, 1716635426, 3324742113,\n            2710305693, 2354409016, 209044596, 1052107641, 1275041956, 2683489172, 2218781510,\n            3218932590, 367423450, 1139521118, 484065443, 2774672726, 2199688060, 2595994858,\n            2766781330, 4010728155, 2471938607, 2443485677, 2512646557, 1783786440, 2586521152,\n            1293511168, 2754786394, 843414384, 2733670928, 2673211126, 1831548704, 1507579292,\n            300108435, 4168221860, 3056060813, 1074051129, 2443218252, 2786872412, 1521579909,\n            3002145596, 1038629976, 333719208, 398037698, 2327562199, 3906306578, 3860291999,\n            2708215457, 2994740784, 2444084751, 2051054286, 3721504053, 13639901, 3131442928,\n            1665891362, 1004981560, 2672093967, 3849433595, 3693322361, 4157500107, 3275912258,\n            939706674, 2775110135, 2772877030, 3937484334, 240094954, 268854799, 358769959,\n            3879082861, 990116332, 3844458806, 3358517002, 157654009, 1888197277, 3767715560,\n            1992005094, 3000885357, 712308948, 97474400, 1032741665, 1474808743, 1698678514,\n            931537527, 1916486634, 2878260947, 3727228108, 2313492286, 3285497655, 3206730275,\n            4284678508, 2506474477, 1389954169, 3751888822, 194362906, 2064318045, 4133690442,\n            2808582010, 2677686297, 3050279294, 2468404997, 1830004272, 2685594794, 477597531,\n            3289330681, 2143814392, 3874622902, 3298844876, 2487277301, 3988787333, 3041371803,\n            4049441073, 3767569736, 2542990054, 2425662849, 1897157558, 1338068625, 3204808408,\n            2152753507, 3746300240, 2482331983, 3385302403, 2758234439, 2759085438, 508998065,\n            1223433126, 2394383885, 132654029, 2315880048, 4098029485, 4024894935, 7497695,\n            1562536823, 3137935348, 3016914619, 2109764983, 1252720630, 145849589, 4083512962,\n            2437495916, 1112513401, 1406756818, 1950408622, 446872130, 2562784674, 179413856,\n            1514287693, 3292189406, 2906659889, 713923011, 3611402990, 1483192135, 624362594,\n            1716375666, 2598996983, 3400508352, 532608647, 1064107478, 3678086402, 2971527569,\n            373188058, 159485586, 1268240989, 3237585490, 3168342804, 3260235693, 1044471752,\n            1794355961, 2708027181, 2350414048, 2578105119, 1701986224, 3287958641, 3731989517,\n            2550833186, 1464424680, 1492730967, 788230494, 1536847815, 3539582664, 2684847209,\n            3275242595, 1175102357, 812199218, 2945417844, 1324851034, 3657118239, 2080012874,\n            2073911306, 348871803, 1385046650, 2256273117, 1079410594, 2685229619, 2682847322,\n            2114480861, 646191989, 2203899983, 3969414867, 3538537702, 4068013123, 3232826610,\n            596198863, 1046306571, 2865628166, 68987600, 2100190548, 3315046820, 3490220594,\n            1096067081, 2941419727, 2558046885, 591489912, 3477689804, 133164194, 2648378976,\n            1672712559, 503765043, 472903689, 2389245110, 576018363, 3148922955, 4125524011,\n            3286180064, 4030404254, 2604010162, 2997085129, 89056299, 1807554852, 3269841668,\n            549895196, 260687385, 3579375620, 187060840, 1942595893, 603206835, 3855746037,\n            591224213, 2177212211, 1725264, 3682481866, 1603335098, 2633406770, 2503221238,\n            3962816132, 1570827695, 2441815283, 2775443721, 2831622813, 331378838, 2661613345,\n            1859324001, 1681417767, 4071306777, 3407361880, 3630093367, 4191434377, 1636246728,\n            669176351, 673352253, 3293415547, 2884409096, 14264168, 3758461627, 1716070268,\n            3988243278, 1362878027, 3980519306, 536008192, 2678505899, 1811539102, 342405744,\n            1073242768, 3131459191, 3387892829, 270841706, 1918541045, 492555376, 4112571650,\n            90351315, 2276388252, 3010748516, 3067881057, 2416288684, 2671243984, 1733673053,\n            438278887, 3784801996, 1744631357, 948419911, 327397862, 862996580, 3011920294,\n            116939684, 2556778847, 3517559828, 3829460311, 4187696223, 1136268214, 4227182561,\n            417640562, 947119687, 1552494427, 3914862791, 3660625720, 3269794901, 3983761435,\n            1080024760, 3542497606, 734720422, 2130766530, 2052008789, 866179302, 3356984656,\n            3353059419, 3601785550, 1473338460, 3554981181, 3284807202, 2537178131, 2660558883,\n            1407764537, 2536942750, 1111424643, 197150902, 1986360943, 570578003, 3230731629,\n            2880732002, 718229319, 2216239393, 2151519911, 3213233733, 140516899, 2705306189,\n            2099103478, 3400320424, 557688725, 1668843985, 873992190, 4038504679, 2235288434,\n            3929442420, 1798837796, 1541815340, 866720679, 912630678, 3653176164, 4183404997,\n            3783207140, 236751523, 4213981998, 2366690759, 3322048028, 1620537970, 150683096,\n            1696323966, 2488037541, 955353889, 3126250139, 2098113031, 996224862, 379286788,\n            1454980629, 1330626720, 3254326109, 114141156, 505833530, 776857882, 3230818694,\n            1513550233, 2944138982, 1138399014, 1232351884, 3762710836, 2726900776, 1754189655,\n            3929691897, 517294527, 1584785665, 3428100574, 493061896, 191275086, 3371640283,\n            3691097600, 660743997, 454351402, 2693537492, 224441543, 4083242290, 2042419433,\n            1749405749, 3326121761, 1143000188, 528164385, 2093408728, 547444310, 742328728,\n            385453463, 1855621240, 693597263, 821097697, 3359254510, 3784781596, 3737350790,\n            1858752558, 3289952948, 3844337741, 3017718436, 747204738, 2068341572, 1829338054,\n            2656623131, 2621869237, 188997883, 894051007, 2539316328, 720156732, 2857142692,\n            479986318, 2311943223, 3461090848, 763159324, 1341957518, 3254977494, 344988894,\n            2995353987, 359814922, 3943690309, 4114837915, 4183023494, 1015984176, 2054910037,\n            88581401, 2304385752, 936890838, 1910665193, 2253192878, 2257283900, 3264567353,\n            3384051258, 2436405862, 3219870836, 739980663, 2626205881, 3700440528, 4116751635,\n            123261973, 97170430, 2912685809, 1847392507, 1227630879, 4041294564, 1594273654,\n            4133439523, 2273557482, 1852654860, 3619550719, 1702837553, 28059816, 102772606,\n            4220040474, 2282708544, 3048829450, 1198037965, 3799925281, 3345026858, 3972819307,\n            3424778198, 3055538572, 3844967902, 3860665646, 3364107827, 3065192652, 313761936,\n            179089842, 1653844636, 1935859587, 4030697757, 941748694, 2581107832, 2215407717,\n            266072062, 151136699, 3862901759, 1913706201, 3703579696, 3175598851, 3518922721,\n            1540670487, 1481796449, 2350248159, 1161169395, 1551024445, 2596829351, 908720646,\n            510631697, 643247275, 7860017, 1436230977, 1642294503, 3987759281, 3697987608,\n            1884149375, 2628751463, 3704486074, 1467870985, 1033168865, 4152476956, 649602304,\n            513167376, 826712542, 850605344, 3235955410, 2269970645, 2692348528, 4086685012,\n            635138347, 3779838044, 3121512906, 3227378207, 1054819334, 31747484, 458159784,\n            4199967375, 1288741089, 1261908606, 1322196907, 66488517, 3887579746, 1119580071,\n            3520963022, 3373216749, 223764043, 2861161993, 747227972, 3482785674, 1405771917,\n            719369505, 1673984799, 276079513, 2508081261, 2515431484, 2922924126, 3597246716,\n            647895476, 3793428410, 3425572118, 1074297825, 821559348, 2839542545, 1897144802,\n            3613259736, 1808031746, 1281519681, 3896118069, 4131591488, 296155402, 638550355,\n            3052325442, 125220535, 450621007, 2279487792, 3201319320, 3970196322, 1300822796,\n            1592875148, 459824311, 3555860014, 37468205, 163861297, 2887286569, 1605580982,\n            2267025263, 852924927, 823513980, 2749888610, 2890486427, 1975455355, 4260140080,\n            2388308835, 2751260543, 2054257325, 898019685, 3076718156, 2748642166, 4107558681,\n            726356635, 2409380553, 4133858015, 2137846929, 1533796622, 3343476816, 2995477096,\n            1906524432, 2463273274, 2821225323, 3240034000, 284966169, 1623621895, 155403754,\n            3702407866, 2384829979, 3527853746, 3965422206, 3695468695, 4111056268, 2851499724,\n            2096098281, 2589036318, 2328285109, 342249683, 1491530029, 1120943322, 2993943428,\n            961500646, 3834036750, 1407279773, 2159771508, 2949114548, 1257703137, 112753236,\n            2687765617, 3264480915, 541858082, 1905233079, 3741673276, 1506206568, 948437457,\n            2072091462, 435343542, 1826721485, 3026216742, 1899272380, 2381726103, 2386973389,\n            3851959892, 676110207, 1429488429, 2456962149, 3434188217, 1759358419, 2012996724,\n            3832387879, 1306928055, 3879599379, 1855514535, 1278340174, 3895170905, 4036851839,\n            1736502179, 902593028, 3041896318, 1088656605, 2205253218, 1400012130, 2261287720,\n            175467724, 2113685409, 2927396005, 2790930243, 1527781896, 1808475280, 462065438,\n            3808277088, 1996854314, 1227914704, 2532981454, 2751135197, 832474648, 278376997,\n            179999604, 3454837790, 4189477161, 3925404576, 724347681, 326641044, 545292031,\n            4132073668, 714677745, 3376764287, 4156659605, 1767724141, 1293260683, 3611915310,\n            2602914479, 705091580, 3795953319, 104155240, 2107810007, 102476149, 2478337301,\n            2728764462, 2324210661, 1662625823, 19728436, 919970704, 408330796, 226002873,\n            1224941092, 3253024461, 703084167, 1686344642, 2710447096, 3741823793, 1800137048,\n            1728578459, 4073670765, 2856520839, 2518678794, 2111509220, 3046036386, 66768381,\n            3409265781, 2031838848, 4139578175, 1919099167, 3614877420, 689717715, 3410494541,\n            659505257, 4116537698, 2258414617, 2602261611, 4243664763, 1148504559, 3060144650,\n            1821973517, 943353725, 2656223194, 2921874644, 737103001, 2682285832, 3365075677,\n            504157948, 2117504770, 1091988882, 138431492, 3089878442, 1947915975, 2861908225,\n            625375400, 3456663917, 2919653950, 3589858184, 3706889141, 2982313688, 2375816280,\n            2734870666, 4188096235, 3604422039, 983639961, 3301762066, 3181745837, 2721926640,\n            3199024837, 1310138874, 1579083497, 2259444203, 3729344966, 3342523607, 3034522197,\n            3782108897, 1886708695, 3226663577, 2702137984, 2606528335, 1872012482, 1786733392,\n            3448253761, 808696129, 3961046824, 746729737, 2209996950, 249014846, 1666060137,\n            3026499663, 1078708282, 370739583, 68889615, 526951028, 3065574510, 263587921,\n            691750675, 2941031793, 234389378, 3121098346, 552746304, 1240292787, 2749223196,\n            2911200879, 3575079143, 2387877722, 56226183, 2234703068, 4280011272, 2242365487,\n            2018017386, 3120559877, 3029127512, 76026914, 3177333864, 3005037212, 779649575,\n            3013183545, 2164743696, 931414036, 59423493, 1275368408, 1414803373, 3990230148,\n            2088594422, 1188225634, 2944724829, 1746820395, 1685910229, 834306437, 1493402276,\n            2360893322, 3553642704, 29771524, 1090675414, 3011165295, 1063371514, 3940303196,\n            2577763706, 2185407339, 2491344105, 780054209, 3253655957, 1491625412, 1765967954,\n            2859073426, 3732521455, 1293856115, 1892088133, 148995653, 1484716015, 1889017950,\n            1269166526, 2838492749, 2418409421, 2209869646, 2522045468, 168513861, 3804997079,\n            1587811051, 1897846173, 2879779511, 3528031017, 2591223604, 3214640965, 3550383759,\n            2783793874, 2203740552, 3118026720, 2574427919, 3540330003, 3341696766, 3490004383,\n            3920451780, 2209488555, 1498679604, 331789812, 2435056342, 3810073792, 1163725363,\n            4006114636, 1560879500, 1837741532, 2185704910, 2798311217, 2991940915, 568480613,\n            2866397512, 3023365481, 970163083, 4289563056, 2270448642, 1850438485, 3664911059,\n            3605978328, 1336002490, 1355682756, 351606621, 3586308334, 1102330800, 3090559563,\n            2148719826, 3215451182, 2702159478, 1432967778, 3401990268, 2400799759, 2484974007,\n            1353690636, 2753559176, 2640489981, 1036931712, 1903649253, 964220241, 2773991379,\n            2133175336, 583322695, 2199489502, 3631891337, 1813009747, 456084772, 2320697906,\n            2974016610, 1520270050, 896145014, 2080304689, 1976066498, 2839737822, 1549783855,\n            4179969968, 1104386050, 837388826, 3165878801, 814640192, 3604179832, 2665037610,\n            3822828834, 2216452945, 2276503837, 634164486, 1412890410, 3261612008, 563171960,\n            3566738474, 2754595658, 681116053, 3118865924, 177463739, 139480302, 281558431,\n            1690126124, 1897842373, 152100710, 1389253223, 656498764, 465779469, 1700329794,\n            1161598335, 4182855549, 2896065503, 1169161019, 988049753, 141540097, 3920962023,\n            1414463815, 2649582854, 1247190586, 2345836198, 2096301443, 1735443990, 2410187529,\n            3110145792, 4259098967, 3496419344, 1323096534, 2280524624, 2704688879, 814213923,\n            2999267246, 3391489910, 3302983115, 105712882, 1051466424, 1317340325, 2155365832,\n            3664348767, 41875693, 2574817994, 2417654542, 2345990960, 3248572524, 2232341334,\n            2323122825, 3467411353, 2464771648, 3558780344, 2048000656, 2550689605, 3832657853,\n            588816494, 1928072148, 882779546, 2585956826, 4115174858, 2041950439, 3851200700,\n            3492163676, 2564516100, 4026987647, 2862754352, 11739424, 3152433432, 3038183071,\n            86904302, 4194617361, 1533432622, 2267744820, 1709636676, 2268808549, 306348255,\n            378915346, 3839473038, 3466138943, 1889711851, 4243725138, 2040287089, 2711698315,\n            2512890389, 1443237091, 1788173191, 3483735845, 187126422, 3972604184, 87146887,\n            1114058116, 3401707008, 1786906060, 1113751464, 3806893326, 752642051, 3083541814,\n            2468915599, 2445639645, 3885031785, 104242888, 3874118728, 2821368929, 2069280853,\n            2465759541, 76153213, 2243998971, 60618079, 432802985, 3403462072, 3617268113,\n            86582391, 978301034, 3106717053, 879484256, 4191758913, 3233938947, 1333422465,\n            4259870922, 878234880, 3752118900, 3493144181, 2923150231, 2387653130, 362351294,\n            3725228020, 446282046, 864505264, 819646991, 2142174716, 757107765, 3054689800,\n            980736009, 3781683590, 3228301270, 733658545, 44816498, 3764513000, 2648527937,\n            1175301170, 689878689, 3284446800, 582872017, 4081139934, 772717500, 2468163649,\n            1154957469, 1063689275, 2686616245, 3968673572, 1552104858, 3208534258, 3719381547,\n            4293124814, 4185971596, 2822157478, 2226770657, 2722172771, 3204920070, 3153368659,\n            3957403777, 3340401452, 358170452, 86873248, 3073864777, 1901787488, 1868606477,\n            3135506861, 2969520380, 612214934, 2360443633, 2158036096, 384976614, 1988412094,\n            2588500257, 2526449435, 4235741613, 440052124, 972557488, 1421976670, 1592981311,\n            1190795166, 123857612, 1450909778, 279599536, 97553494, 2356966581, 2886183120,\n            675956446, 1305595169, 1205008613, 3157245850, 1388240997, 2108861482, 2163666121,\n            3918485200, 2326199955, 3683465789, 3756179104, 1328336284, 703189534, 3141697951,\n            912546716, 3380018405, 2873689339, 1066530264, 272975397, 132319529, 2540398225,\n            3521502371, 2761283016, 2471199096, 3521041929, 756789292, 2527658902, 2755972832,\n            1885214085, 2175187093, 2258837609, 2586448274, 2964587075, 2168070343, 755385185,\n            2820998539, 3455906021, 1853441295, 498516020, 4189729152, 3555989654, 2264955912,\n            2663747569, 754868430, 234525495, 3316740819, 1374506476, 3843025136, 3711134757,\n            2912660137, 1250443668, 2288121539, 1768013429, 659068459, 1033379830, 3479740778,\n            900522158, 1758840019, 1292039331, 692167145, 3562019492, 3793770736, 450238625,\n            3629428994, 291785463, 1925186703, 125661517, 2883876802, 324456772,\n        ],\n        &[\n            838935716, 2203587819, 915639214, 3753735741, 3643959629, 380366065, 2800082357,\n            479609169, 3344910139, 939862102, 341732586, 2006110852, 3452170213, 3812660487,\n            1864783975, 1318854193, 3422317845, 1427228514, 4149153373, 2684083624, 1074989654,\n            4073983073, 763800714, 4006319696, 119085884, 60830173, 991131160, 3219809387,\n            3231928830, 2959951027, 2787097517, 921471246, 453915876, 3731898283, 3251142762,\n            2579466369, 27120149, 2385740750, 1273661758, 3509690455, 3723885200, 4216400843,\n            3843558280, 78594259, 3230699712, 3825953413, 1142802181, 3138293244, 2095371158,\n            2351682776, 2501576120, 1676985000, 2623958874, 4227586876, 1860325172, 2090337755,\n            4281181325, 2213517873, 496143888, 2773301631, 3322452819, 737280293, 940258553,\n            320919084, 1595155948, 755694675, 3627876063, 3556466666, 2945032739, 4212566832,\n            2489967318, 612979803, 2998019149, 791094903, 2331887068, 3848194214, 1669109803,\n            586836653, 17421765, 4174252863, 2502645698, 1463986066, 33539085, 1789626263,\n            3342962255, 3824519205, 2026068357, 2765446594, 844159180, 3508825346, 1134575466,\n            1545918988, 3138211047, 2308850390, 1340320302, 1500877398, 4234310467, 1983405401,\n            1030999951, 2800668723, 4229219814, 3909258449, 3342207809, 3096542283, 1526382630,\n            456900343, 1292423164, 2023977467, 3452242468, 697297984, 2512301505, 1854858696,\n            2453945880, 475365007, 3487108263, 727126356, 3257286385, 514172720, 2342933557,\n            2456659886, 4293261548, 2045491426, 3978264522, 96991830, 728236868, 3356414658,\n            858180648, 3186522835, 315467595, 3025301039, 1022091990, 832213724, 1625707968,\n            1952252164, 1626399404, 2286098955, 1957714754, 935464737, 344352942, 2655128088,\n            2455096079, 3508589253, 1323890983, 18543456, 1120234679, 2368630283, 3464013570,\n            414956029, 1608237042, 3123061407, 3048565223, 1337447413, 2725081489, 3544363169,\n            3162272209, 1757543970, 3268970159, 2449039760, 3153678826, 666593731, 2303670329,\n            4257224320, 977258122, 428570155, 782781929, 3018115039, 453083041, 2998000053,\n            3874611711, 244856874, 2209589064, 365052855, 2255276114, 4268430165, 2172011676,\n            2202715955, 1929862469, 2117294128, 3787626628, 2347621422, 788538718, 690792725,\n            2069984822, 2567516370, 2156040001, 2753711351, 4233613434, 4029666569, 3098679112,\n            4024517832, 2132477759, 1327869411, 659072182, 2909455412, 3730675471, 679967738,\n            182649740, 194375197, 3841653420, 4027960673, 175135837, 1660264436, 3644680859,\n            4007751387, 2899873733, 3767998718, 1048209090, 1751066328, 4286847948, 135738204,\n            2614043038, 1982088957, 758427538, 3475803304, 2870686136, 4094121733, 1912601923,\n            2108805517, 47636847, 230717174, 1648662744, 3198815387, 919877866, 3677274799,\n            599980511, 3198454352, 962418282, 2571908668, 1214590864, 3203010561, 1973877631,\n            4097190280, 980645781, 730416487, 1042657050, 3749371087, 2876213668, 1057105900,\n            452303833, 936771815, 2711618145, 3682803011, 4148511396, 2871128258, 1670210392,\n            363675039, 1226232864, 2545473472, 2847607537, 706216472, 668367486, 3335248515,\n            684311493, 1922073430, 2173646273, 1758431003, 553691538, 2135670731, 4237772697,\n            1307471006, 1673244127, 475473888, 1489978871, 3151848780, 3727938421, 2510602424,\n            1534771587, 1514732764, 3961802829, 1749640392, 3073492043, 4184684257, 2678493181,\n            1016148119, 162968394, 1542225613, 3314073214, 742431147, 2655829423, 2077968934,\n            3307840731, 3166378296, 3380012342, 1628856437, 2492930090, 1125050986, 3917568307,\n            2081901207, 1910847527, 2713093801, 1095695739, 2968092789, 3472722113, 377271708,\n            1040508736, 948060390, 2161675070, 385186644, 4184834501, 1657036626, 2397219251,\n            2440643845, 440875536, 2390881422, 1456820922, 2584489112, 3663536575, 3123816215,\n            2449538096, 3006681818, 2608705815, 4192739282, 1380673229, 3059394456, 1566510861,\n            2531146664, 1359283390, 2012589430, 4200074946, 3098609836, 4006992613, 4077565448,\n            1974438847, 1221683442, 1719050478, 3161792955, 2578040126, 3061737012, 367079059,\n            3046588169, 1563359926, 2224001306, 2791171902, 2289618085, 3388295848, 3287189754,\n            2674283012, 2056956826, 3968642769, 3774531757, 3562296786, 3475855578, 618682730,\n            3174665899, 4290008806, 1008009435, 1700412634, 2902015788, 2972205524, 2584006496,\n            4087976424, 678816164, 2093048627, 2385841515, 846482516, 1762625699, 4062395767,\n            1067045848, 4162678883, 3600728522, 1571165888, 3489010385, 787541038, 1248805154,\n            2599773530, 115140567, 2919051278, 3369387442, 4107879124, 2428887338, 994007703,\n            2665777337, 3130672163, 982959104, 2698714317, 1460766600, 1821697637, 3330816250,\n            2095057996, 830788453, 3990976194, 1800223602, 2026811060, 2393136879, 1189765438,\n            1109812562, 3311727428, 3224449942, 4237200199, 3873080150, 2683760941, 4088732835,\n            614500558, 711266360, 2147434665, 3808624639, 3034313567, 1059395674, 1561883669,\n            103784012, 2032335571, 2800686028, 609480554, 1769603386, 4151398145, 2185648870,\n            1739535600, 1586519522, 572991424, 1068733442, 2619062803, 4041514271, 1086033525,\n            11857992, 3192078073, 1344195581, 1238380717, 4077237295, 3875651208, 292286543,\n            619476155, 2161959405, 1203958830, 4290561761, 3693181580, 3900343517, 2797356182,\n            4084172378, 261394861, 769278713, 4199742495, 2309375370, 3346948261, 3750248064,\n            2567542765, 3972013578, 3992801407, 3056612552, 554436073, 2730615770, 1231284851,\n            2255256795, 1587098949, 1645198162, 2603125261, 1127388761, 860864076, 3375951570,\n            2228774088, 1597961976, 412935124, 2173190974, 1415442621, 3815450429, 4044940139,\n            1867706821, 1053298761, 2092988724, 738251343, 2294030391, 1030772826, 3106409390,\n            2170123922, 1863396860, 690798362, 3794558912, 3566843628, 121083434, 994730387,\n            574163581, 2016938790, 2148010580, 197642070, 2380205705, 3769045477, 1675706118,\n            4120416559, 3559669638, 376897093, 1128063177, 74421326, 761413501, 3392222006,\n            1321099529, 47433813, 2130311331, 1584264183, 4078065031, 4056472694, 1048381830,\n            2103467739, 1824423056, 2776327151, 434780346, 4017942257, 2398098907, 3022379282,\n            21450696, 2803414267, 3336384729, 3655253595, 2013481291, 629727070, 304283403,\n            3969058801, 343107726, 3930196577, 1050996951, 1696216281, 4113049883, 2063680700,\n            3299802318, 2169413090, 599831066, 265205477, 86598633, 1318950976, 2817019822,\n            3523559767, 1192997804, 967006658, 2618135270, 652785590, 1396546377, 85541097,\n            1498343279, 1545058670, 1004723554, 3231552447, 628138355, 4033681503, 2114084638,\n            3662581523, 2278439544, 3504753352, 1762732636, 1199413890, 2921045813, 2558711012,\n            849244440, 3149132172, 2553108318, 1232917889, 3271342783, 3248249426, 1731072265,\n            2957986492, 1684696396, 3968320398, 2537362303, 2030936713, 1234679023, 4192065531,\n            4222971816, 3064892308, 2590492328, 288251267, 2550089391, 879932618, 784103313,\n            3344367287, 676675271, 2000590552, 3777064239, 3282963152, 860961137, 689785050,\n            3572163643, 2233769790, 4104660183, 855938732, 2821571786, 2808753272, 1281740498,\n            969712731, 474012755, 4001231436, 3985764292, 2862143307, 994442730, 1243356938,\n            1775451246, 722781566, 3131106180, 3339337915, 2271184254, 1079900234, 2744647618,\n            1638963938, 4263302376, 3563278731, 1946093388, 1809549982, 2256560928, 2960989550,\n            1799848335, 3793311156, 4262135533, 2448031337, 319777785, 1925667888, 2774876369,\n            2635247551, 2921425304, 1354802634, 2456898309, 1860471049, 2869265862, 3082305168,\n            3898824849, 3125463798, 4212194039, 1623533549, 1173751565, 2496120567, 50014129,\n            13149499, 4167145366, 1955034137, 1636727570, 404325094, 1751899763, 3718846670,\n            2966030995, 3631249081, 850012394, 3102446697, 2042206947, 2248313443, 2785796194,\n            2751107788, 3825364911, 839857966, 3593553796, 2978187162, 1963772991, 2535947700,\n            3591089575, 972097984, 3139361936, 1671749808, 2397938437, 3496814669, 1899924710,\n            750821353, 2796989722, 3330933794, 741406274, 4044115699, 1664390021, 828823849,\n            4263496205, 809061833, 1366595084, 1030792229, 1836547249, 3859902111, 1449813785,\n            658840733, 2048685768, 4124870169, 2673685491, 2426733455, 2333311310, 3492090101,\n            1992837915, 11511403, 2540925625, 2852742586, 2179960638, 2931055419, 3659567067,\n            1933074409, 649207452, 4276721791, 4191972082, 539633860, 17233553, 1594779948,\n            4215033555, 181714143, 685754269, 1956851130, 589401843, 3102481839, 497723403,\n            952363536, 3336958173, 375851460, 3769041100, 2814705111, 503471929, 434207586,\n            4273458948, 3293647658, 2353814912, 2821137839, 2876582042, 160572601, 1201368925,\n            60357568, 139088744, 721227061, 2623980501, 3943799534, 3041058274, 2977612913,\n            3291630599, 349175514, 3961677955, 3235620723, 2972138888, 2079236907, 3547729544,\n            3780005092, 1440555729, 2438143802, 4201044301, 2714313685, 3486585540, 2800950188,\n            1801147672, 3703751487, 2461295830, 380678753, 3708873777, 40573490, 2437248324,\n            198586160, 669549162, 720284965, 2019671626, 1452819480, 495221607, 816889749,\n            3963879039, 2755252053, 1699095522, 1122700669, 292682575, 2542299989, 32521186,\n            2188233807, 2468163267, 292904686, 3223433980, 2703281150, 1173144272, 3313052362,\n            3356734471, 2695828969, 460370984, 3371854267, 351372515, 544848035, 665581896,\n            405416947, 1277394067, 1797975604, 937658179, 794722376, 8125493, 3456647328,\n            1780985597, 3741333943, 3296469654, 1660046360, 2306936782, 3661850759, 4080591659,\n            2501854245, 1384493589, 3663701959, 1729039559, 900961315, 1098594423, 2562550163,\n            1148027253, 3616002981, 334019448, 2850279078, 4060960913, 1287642279, 3376572244,\n            2534805166, 1377930878, 3804442725, 1383027131, 2082023911, 1793040924, 348666885,\n            2304696682, 256389582, 3478053630, 698728310, 2037905177, 3976969740, 3230702660,\n            1299868963, 2833628697, 2930863988, 2357656502, 1343551287, 2011573652, 3097268490,\n            3399030503, 209755840, 537294183, 3998427081, 1076591702, 1263890468, 1782599039,\n            3780229996, 1024431710, 2833602231, 3777979580, 4078024794, 872524254, 352227412,\n            1351273981, 852004662, 1161960014, 1906524671, 204792238, 2663768241, 4072664750,\n            3414324694, 286128037, 1110040325, 900463961, 963252168, 341367983, 3248675265,\n            1219574682, 408882044, 4029283861, 2041191997, 2273854782, 3408304833, 2242938048,\n            3436897597, 2980462347, 2514777114, 2857882805, 461470076, 3109832332, 3200488424,\n            4074902801, 3969927253, 729904888, 4152956776, 689265400, 3124361813, 2969684080,\n            1117396653, 2927468191, 4173382674, 4220933905, 2013331272, 1607793854, 3861336002,\n            1873865360, 16258643, 2300509732, 3479887951, 2336999346, 159459282, 3950452492,\n            3929460924, 705609132, 526429974, 676661281, 3888522264, 1774544613, 3921273959,\n            157436604, 4006393372, 3620960941, 1816027785, 976626829, 1147734086, 4071348376,\n            2542528107, 962473538, 1088491988, 1609404762, 914564813, 1410211333, 3779344617,\n            4175461012, 824484826, 2980214363, 3955476205, 3424635742, 740023698, 1869598491,\n            649848532, 486101202, 2723887281, 2776425384, 682654951, 48707499, 3215265093,\n            2091228948, 3882341515, 2914449810, 4145012253, 2500281477, 1192252445, 2720083567,\n            3606499354, 2308681139, 3417499332, 2673063768, 2245530872, 1594809199, 2961185232,\n            2154329832, 3212262766, 2884845477, 3476290762, 2814732863, 2643163160, 1881713506,\n            2949244325, 4196436484, 2317791900, 4235123047, 1093953049, 5453429, 3068787991,\n            3345927257, 1386287281, 1495554810, 3092636873, 1484259532, 3600514898, 2957555206,\n            3348133074, 2055353028, 681494686, 377599951, 812642228, 1988902688, 2634311151,\n            1839068105, 3616435588, 444035475, 3061487513, 55224199, 2434767613, 2830319279,\n            473221113, 2719964944, 2466794715, 4145309788, 1222340136, 173399292, 2934551672,\n            1337072089, 208573081, 3208261196, 460363797, 2972654949, 4049253252, 3382433428,\n            3953728176, 3042257654, 1441354805, 871221561, 1750912796, 3684367914, 969056696,\n            1128407825, 1312971320, 350151817, 1913948880, 162760467, 2927001962, 271548687,\n            4233867754, 4187064028, 1752223315, 3566855814, 3098906749, 940415226, 1450714578,\n            2089508179, 685807392, 1094880779, 3618434588, 1852947202, 317434962, 1659500546,\n            3597259289, 2888477399, 2671081767, 2440146053, 2035849436, 3156792370, 4265496433,\n            1525348048, 2545566909, 1778313912, 2782108361, 2017683243, 1447595289, 4213477653,\n            356590757, 3887333316, 1375294643, 166093975, 3646164777, 2470748042, 2344217837,\n            1900424442, 3867136564, 3763279553, 3894629246, 1025417778, 4274768880, 3262354653,\n            1368425302, 108316157, 1343309487, 2548223206, 3292698474, 2074720811, 2415701834,\n            2319728429, 4253222152, 1823863126, 671442975, 2815690234, 166017875, 4133918798,\n            2341656544, 1195071311, 3591080201, 2727319421, 323604173, 3467106257, 1807836963,\n            3351025639, 2903513081, 1902463642, 2877952685, 2401135475, 1661402701, 179177133,\n            2157408987, 3104539005, 1187176474, 216324254, 3682100936, 47318979, 4266538909,\n            1364880663, 3089835665, 2974326632, 136715739, 21460991, 875857069, 3634182054,\n            3507421393, 2816493641, 2428086359, 2677298183, 4144250643, 3067655705, 2047511728,\n            581965183, 3555378151, 3320505513, 1784970183, 3537100678, 2661089461, 1915923033,\n            4016714600, 780795784, 660039721, 1585895448, 4267382956, 788816746, 441129301,\n            2642236828, 3236397688, 4098671167, 417254115, 1512419440, 2595207623, 714330442,\n            1793107412, 1915812662, 1065761790, 559987752, 2473228903, 2857904446, 176611125,\n            1056992200, 3785703632, 1081171201, 352847890, 1749283439, 2145600786, 2611374980,\n            2819729772, 1330960860, 237844587, 1927429738, 63223319, 3015994684, 3325055109,\n            1399511661, 2815713002, 2466135290, 681412319, 3776472186, 2316275012, 3463722640,\n            845546679, 3470095507, 141194431, 4021588401, 723350993, 3043631697, 3504648579,\n            2019448585, 3063288730, 581965108, 4096321988, 2137034574, 295040412, 445386599,\n            3257986313, 716955156, 1644931397, 55457860, 252470757, 670110185, 1740055863,\n            2418200077, 2304754384, 3105055645, 23205783, 1131503062, 216403393, 2353961029,\n            3130064620, 3993811637, 1483619628, 649295085, 1095042730, 2656243769, 1223292028,\n            582240413, 1206780397, 2973061534, 4292796836, 3537057693, 4187363592, 491905630,\n            179086816, 1772613819, 2747068600, 1832416612, 1180763400, 818642060, 36609327,\n            1658217467, 2050606159, 3032666431, 3767423337, 1111353105, 1522267728, 1631984380,\n            3190473602, 3680487263, 734566855, 2353333066, 986328581, 3681689264, 1595897310,\n            3335184558, 2507600517, 2490029559, 2745986115, 4181623162, 3432004504, 2145423842,\n            2367982528, 2806960322, 3076340209, 505849942, 533374703, 1257745383, 644213956,\n            2962046646, 2201943625, 237256910, 3874792384, 983086135, 1654746256, 3220085267,\n            3164213233, 1962620300, 3406864224, 284885940, 2339029442, 1267505911, 3660344615,\n            3917330963, 3551145561, 3488278296, 1907092122, 2980179347, 54406137, 1998418578,\n            1902516963, 2207644610, 3941412978, 1623928004, 485916323, 3615926304, 523041942,\n            115202452, 2022521528, 1490106543, 1835947191, 4260360619, 1424916687, 2528887699,\n            3933621604, 3297208940, 2162596225, 1222503210, 2136147383, 2425841507, 3933152399,\n            4238982603, 2877219680, 3629789132, 3074841443, 3440850273, 521778548, 197924155,\n            209664882, 4244045891, 4041802190, 213808, 1061287415, 4109828330, 3118408869,\n            628642373, 537513117, 534884706, 3291471519, 3166304457, 1868482021, 459148534,\n            1009990526, 2380010357, 890059218, 604931398, 3306919535, 2774345113, 820980298,\n            2438859282, 2852945605, 3422427217, 3698390489, 3313390587, 3080508268, 2767314620,\n            3842719809, 3355496804, 2278214546, 1228854785, 3963672337, 3480498117, 1185458174,\n            254331697, 4075265013, 1893263033, 1251932761, 2009544780, 559074272, 253120496,\n            1936501741, 1726021337, 4053670081, 2881809588, 2485095543, 1685412297, 3542536640,\n            2366264687, 637664695, 1837220786, 354783458, 2949531247, 2469565699, 974572166,\n            3336819772, 1219492409, 2302227018, 3368888008, 1441596117, 4139261093, 3992023496,\n            2186276726, 1337085007, 1297128349, 3345717969, 1502084009, 4279269575, 746110129,\n            357443087, 1184174039, 3510875879, 3851501689, 2612516856, 603491753, 797427139,\n            852360679, 1117907315, 1427571936, 817235609, 3158982462, 259347609, 1788586925,\n            1148039424, 3368411210, 1634605211, 400804429, 936765965, 1742182939, 1903805118,\n            1538100182, 2176265557, 2662759467, 984261631, 4020913363, 1487175843, 2947614836,\n            1900701443, 4060998848, 4029580532, 2688679851, 1811723482, 1453238253, 3787617091,\n            2282686689, 3993782144, 21304404, 507557860, 2944490999, 182972447, 3174956974,\n            869715075, 3277689659, 1814259483, 4163075289, 3873534736, 462031943, 3153254355,\n            1301198786, 3943710461, 3909340915, 504180560, 2041140274, 3440956310, 3656453113,\n            3273349780, 3481111110, 3576620931, 2732393968, 3946434431, 659377962, 677158288,\n            670305147, 974547443, 310689727, 94218257, 1724518031, 1905703897, 1286333546,\n            2751245199, 5571896, 3457747128, 2179848102, 3894181682, 4124381231, 3410266880,\n            709398455, 187319059, 3511629688, 3559400976, 2489398231, 600737488, 3595918510,\n            3798083973, 4026752984, 4210193948, 68891514, 3947247567, 3107252542, 1170883420,\n            1834752658, 2941121513, 3841122236, 2470855721, 182150380, 3416558885, 1477637651,\n            995210324, 588847561, 2552679828, 64224740, 961985977, 1427921858, 3494336204,\n            1146890788, 3705393264, 3874804387, 49839043, 1196485418, 4243424919, 215134702,\n            1706006595, 423982823, 710751734, 346438174, 2785074971, 3048570439, 3828658776,\n            443370961, 4028150602, 942994137, 720074843, 1909180916, 647304255, 1473324775,\n            1036517605, 440850580, 3455287996, 2297168269, 2592528575, 323504231, 292579127,\n            649004565, 281112587, 2639333091, 2098301904, 2778751588, 2025098146, 1805301626,\n            1552474374, 3081073479, 4079139025, 919447806, 2132238174, 3776363222, 1050273203,\n            2654179515, 31684454, 55205341, 2546554914, 1088968049, 1402421698, 3682384666,\n            1553165183, 115328209, 3405269619, 2255597873, 1379651895, 2310622780, 1996922494,\n            1033698934, 3481464610, 1795184151, 152194312, 1061361554, 1284312248, 1338186205,\n            4098514812, 2874751651, 2866358430, 412769457, 2483498856, 4198676447, 71720962,\n            3683175370, 3989356764, 2846917228, 921604934, 1635603564, 2971093080, 742806196,\n            2398879483, 3298081490, 4237003774, 2380113868, 1568001623, 2624936612, 3176752214,\n            2867181933, 1917549358, 4044310480, 1307704115, 3767119746, 4201150796, 1450449070,\n            744907957, 1114261347, 2636959698, 117707599, 1450886244, 2336471832, 1236404162,\n            2912700530, 3665684179, 3640387930, 2966734192, 3208997144, 1270408976, 308398801,\n            2329948514, 343477117, 2365820358, 3697864380, 16124765, 968064396, 551610086,\n            3261227824, 3845306004, 2839278865, 1710063436, 529765606, 2590339389, 2232645965,\n            2220674716, 4175021164, 1253655722, 1585348878, 3251476604, 3936991537, 190532800,\n            4099120852, 1806314545, 530090133, 461441516, 3941506885, 3666450612, 3737219241,\n            1320249304, 2052469119, 2016428234, 3789822793, 3096501122, 1858994377, 3384814016,\n            3282125914, 27976241, 4138503041, 4076911591, 2610665395, 992528352, 1507678034,\n            3833126488, 3471104910, 876024133, 4017994422, 3413457336, 534460630, 4014654886,\n            4064894491, 2863983481, 92546398, 1436623597, 2255152241, 1523252476, 3763913562,\n            2628132090, 1984279468, 2113001554, 2108275221, 1060884588, 2747717543, 1986766057,\n            1622949311, 2332772870, 3332840810, 2524006752, 336521846, 4071972450, 324329553,\n            3149454512, 187149260, 2031485001, 3480471856, 2265780046, 3792798369, 3177913371,\n            2347210476, 4081333345, 4046146024, 2917080827, 590638612, 270185333, 2805124246,\n            460831443, 3496962886, 4271837334, 988718092, 1152316522, 3942609672, 3794345353,\n            1149696567, 1402909182, 494716490, 1245651130, 1943182059, 1599846823, 3504994553,\n            1535906884, 1749731330, 1919915129, 3952459270, 1846223130, 602074928, 1536114851,\n            4291196323, 2411210106, 646156071, 636908156, 390344456, 3173016861, 1180977247,\n            1710702402, 2756888285, 747439941, 4092116022, 4113279650, 3090618475, 396445650,\n            3996355793, 3860756326, 3383911526, 2918629863, 564066118, 1331988394, 3762172819,\n            4160630094, 845911615, 4045163162, 2379948201, 4071794973, 3679892002, 1449801312,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_fail_1() {\n    let ns = &mut [1, 2];\n    let ds = &[];\n    let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_fail_2() {\n    let ns = &mut [];\n    let ds = &[];\n    let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_fail_3() {\n    let ns = &mut [1, 2];\n    let ds = &[1, 2, 3];\n    let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_fail_4() {\n    let ns = &mut [1, 2, 3, 4];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_fail_5() {\n    let ns = &mut [1, 2, 3, 4];\n    let ds = &[4, 5];\n    let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_ref_fail_1() {\n    let ns = &[1, 2];\n    let ds = &[];\n    let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_ref(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_ref_fail_2() {\n    let ns = &[];\n    let ds = &[];\n    let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_ref(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_ref_fail_3() {\n    let ns = &[1, 2];\n    let ds = &[1, 2, 3];\n    let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_ref(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_ref_fail_4() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_ref(&mut [10; 3], ns, ds, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_modular_div_ref_fail_5() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[4, 5];\n    let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n    limbs_modular_div_ref(&mut [10; 3], ns, ds, &mut scratch);\n}\n\nfn verify_limbs_div_exact(ns: &[Limb], ds: &[Limb], qs: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let expected_q = Natural::from_limbs_asc(qs);\n    let (q, r) = n.div_mod(d);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_exact() {\n    let test = |qs_in: &[Limb], ns: &[Limb], ds: &[Limb], qs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut mut_ns = ns.to_vec();\n        let mut mut_ds = ds.to_vec();\n        limbs_div_exact_to_out(&mut qs, &mut mut_ns, &mut mut_ds);\n        let q_len = ns.len() - ds.len() + 1;\n        assert_eq!(&qs[..q_len], qs_out);\n\n        let mut qs = qs_in.to_vec();\n        let mut mut_ns = ns.to_vec();\n        limbs_div_exact_to_out_val_ref(&mut qs, &mut mut_ns, ds);\n        let q_len = ns.len() - ds.len() + 1;\n        assert_eq!(&qs[..q_len], qs_out);\n\n        let mut qs = qs_in.to_vec();\n        let mut mut_ds = ds.to_vec();\n        limbs_div_exact_to_out_ref_val(&mut qs, ns, &mut mut_ds);\n        let q_len = ns.len() - ds.len() + 1;\n        assert_eq!(&qs[..q_len], qs_out);\n\n        let mut qs = qs_in.to_vec();\n        limbs_div_exact_to_out_ref_ref(&mut qs, ns, ds);\n        let q_len = ns.len() - ds.len() + 1;\n        assert_eq!(&qs[..q_len], qs_out);\n\n        let qs = limbs_div_exact(ns, ds);\n        let qs: &[Limb] = &qs;\n        assert_eq!(&qs_out[..qs.len()], qs);\n\n        verify_limbs_div_exact(ns, ds, qs_out);\n    };\n    // - d_len == 1\n    test(&[10; 3], &[6], &[2], &[3]);\n    // - leading_zero_limbs == 0\n    // - d_len != 1\n    // - shift == 0\n    // - d_len <= q_len\n    test(&[5; 8], &[1, 3, 6, 5, 3], &[1; 3], &[1, 2, 3]);\n    // - d_len > q_len\n    test(&[0; 5], &[6, 19, 32, 21], &[1, 2, 3], &[6, 7]);\n    // - shift != 0\n    test(&[0; 5], &[6, 19, 32, 21], &[6, 7], &[1, 2, 3]);\n    test(\n        &[10; 7],\n        &[10200, 20402, 30605, 20402, 10200],\n        &[100, 101, 102],\n        &[102, 101, 100],\n    );\n    test(&[10; 3], &[u32::MAX], &[u32::MAX], &[1]);\n    test(&[10; 4], &[1, u32::MAX - 1], &[u32::MAX], &[u32::MAX, 0]);\n    test(\n        &[10; 6],\n        &[1, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX],\n        &[u32::MAX; 3],\n        &[u32::MAX, u32::MAX, u32::MAX, 0],\n    );\n    // - leading_zero_limbs != 0\n    test(\n        &[0; 5],\n        &[0, 0, 0, 6, 19, 32, 21],\n        &[0, 0, 1, 2, 3],\n        &[0, 6, 7],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_fail_1() {\n    limbs_div_exact(&[6, 19, 32, 21], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_fail_2() {\n    limbs_div_exact(&[6, 19, 32, 21], &[1, 2, 3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_fail_3() {\n    limbs_div_exact(&[6, 19, 32, 21], &[1, 2, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_fail_1() {\n    limbs_div_exact_to_out(&mut [10; 5], &mut [6, 19, 32, 21], &mut []);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_fail_2() {\n    limbs_div_exact_to_out(&mut [10; 5], &mut [6, 19, 32, 21], &mut [1, 2, 3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_fail_3() {\n    limbs_div_exact_to_out(&mut [10; 5], &mut [6, 19, 32, 21], &mut [1, 2, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_fail_4() {\n    limbs_div_exact_to_out(&mut [10], &mut [6, 19, 32, 21], &mut [1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_val_ref_fail_1() {\n    limbs_div_exact_to_out_val_ref(&mut [10; 5], &mut [6, 19, 32, 21], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_val_ref_fail_2() {\n    limbs_div_exact_to_out_val_ref(&mut [10; 5], &mut [6, 19, 32, 21], &[1, 2, 3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_val_ref_fail_3() {\n    limbs_div_exact_to_out_val_ref(&mut [10; 5], &mut [6, 19, 32, 21], &[1, 2, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_val_ref_fail_4() {\n    limbs_div_exact_to_out_val_ref(&mut [10], &mut [6, 19, 32, 21], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_val_fail_1() {\n    limbs_div_exact_to_out_ref_val(&mut [10; 5], &[6, 19, 32, 21], &mut []);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_val_fail_2() {\n    limbs_div_exact_to_out_ref_val(&mut [10; 5], &[6, 19, 32, 21], &mut [1, 2, 3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_val_fail_3() {\n    limbs_div_exact_to_out_ref_val(&mut [10; 5], &[6, 19, 32, 21], &mut [1, 2, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_val_fail_4() {\n    limbs_div_exact_to_out_ref_val(&mut [10], &[6, 19, 32, 21], &mut [1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_ref_fail_1() {\n    limbs_div_exact_to_out_ref_ref(&mut [10; 5], &[6, 19, 32, 21], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_ref_fail_2() {\n    limbs_div_exact_to_out_ref_ref(&mut [10; 5], &[6, 19, 32, 21], &[1, 2, 3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_ref_fail_3() {\n    limbs_div_exact_to_out_ref_ref(&mut [10; 5], &[6, 19, 32, 21], &[1, 2, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_exact_to_out_ref_ref_fail_4() {\n    limbs_div_exact_to_out_ref_ref(&mut [10], &[6, 19, 32, 21], &[1, 2, 3]);\n}\n\n#[test]\nfn test_div_exact() {\n    let test = |s, t, quotient| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.div_exact_assign(v.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        x.div_exact_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let q = u.clone().div_exact(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.clone().div_exact(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = (&u).div_exact(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = (&u).div_exact(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n\n        let q = u.div_round(v, Exact).0;\n        assert_eq!(q.to_string(), quotient);\n\n        let q = rug::Integer::from_str(s)\n            .unwrap()\n            .div_exact(&rug::Integer::from_str(t).unwrap());\n        assert_eq!(q.to_string(), quotient);\n    };\n    test(\"0\", \"123\", \"0\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"123\", \"1\");\n    test(\"56088\", \"123\", \"456\");\n    test(\"0\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"1\", \"1000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"1\");\n    test(\"123000000000000\", \"1000000000000\", \"123\");\n    test(\"123000000000000\", \"123\", \"1000000000000\");\n    test(\"121932631112635269000000\", \"123456789000\", \"987654321000\");\n    test(\"8589934590\", \"4294967295\", \"2\");\n    test(\"18446744065119617025\", \"4294967295\", \"4294967295\");\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099789\",\n        \"577397114388109712462006371470162814529304445639807296878809567953200969820156259914159240\\\n        9106139481288193067515284601342023565222679498917484131095648263181800618990427694244342686\\\n        4412105186059052689237237088193855584354278755933606296018800151986520872701706693002473648\\\n        4330061421236425747083307907706860804054565348593527605104495080560663025897787060638154303\\\n        7631781316565710346299551930891169154491973589315700505458672804104869879731391323700304\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn div_exact_assign_fail() {\n    let mut n = Natural::from(10u32);\n    n.div_exact_assign(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_assign_ref_fail() {\n    let mut n = Natural::from(10u32);\n    n.div_exact_assign(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_fail() {\n    Natural::from(10u32).div_exact(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_val_ref_fail() {\n    Natural::from(10u32).div_exact(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_ref_val_fail() {\n    (&Natural::from(10u32)).div_exact(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_exact_ref_ref_fail() {\n    (&Natural::from(10u32)).div_exact(&Natural::ZERO);\n}\n\n#[test]\nfn limbs_modular_invert_limb_properties() {\n    unsigned_gen_var_22().test_properties(|x| {\n        let inverse = limbs_modular_invert_limb::<Limb>(x);\n        assert_eq!(x.wrapping_mul(inverse), 1);\n        assert_eq!(limbs_modular_invert_limb::<Limb>(inverse), x);\n    });\n}\n\n#[test]\nfn limbs_div_exact_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_29().test_properties_with_config(&config, |(xs, y)| {\n        let expected_result = Natural::from_limbs_asc(&xs).div_exact(Natural::from(y));\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_div_exact_limb(&xs, y)),\n            expected_result\n        );\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_div_exact_limb_no_special_3(&xs, y)),\n            expected_result\n        );\n    });\n}\n\n#[test]\nfn limbs_div_exact_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_14().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut out, &xs, y);\n            let len = xs.len();\n            let expected_result = Natural::from_limbs_asc(&xs).div_exact(Natural::from(y));\n            assert_eq!(Natural::from_limbs_asc(&out[..len]), expected_result);\n            assert_eq!(&out[len..], &old_out[len..]);\n\n            let mut out = old_out.to_vec();\n            limbs_div_exact_limb_to_out_no_special_3::<DoubleLimb, Limb>(&mut out, &xs, y);\n            let len = xs.len();\n            let expected_result = Natural::from_owned_limbs_asc(xs).div_exact(Natural::from(y));\n            assert_eq!(Natural::from_limbs_asc(&out[..len]), expected_result);\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_div_exact_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_29().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_div_exact_limb_in_place(&mut xs, y);\n        let expected_result = Natural::from_limbs_asc(&old_xs).div_exact(Natural::from(y));\n        assert_eq!(Natural::from_owned_limbs_asc(xs), expected_result);\n\n        let mut xs = old_xs.to_vec();\n        limbs_div_exact_limb_in_place_no_special_3(&mut xs, y);\n        let expected_result = Natural::from_owned_limbs_asc(old_xs).div_exact(Natural::from(y));\n        assert_eq!(Natural::from_owned_limbs_asc(xs), expected_result);\n    });\n}\n\n#[test]\nfn limbs_div_exact_3_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_5().test_properties_with_config(&config, |xs| {\n        let q_limbs = Natural::from_owned_limbs_asc(limbs_div_exact_3(&xs));\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_div_exact_limb(&xs, 3)),\n            q_limbs,\n        );\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs).div_exact(Natural::from(3u32)),\n            q_limbs\n        );\n    });\n}\n\n#[test]\nfn limbs_div_exact_3_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_13().test_properties_with_config(&config, |(mut out, xs)| {\n        let old_out = out.clone();\n        limbs_div_exact_3_to_out::<DoubleLimb, Limb>(&mut out, &xs);\n        let len = xs.len();\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Natural::from_limbs_asc(&xs).div_exact(Natural::from(3u32))\n        );\n        assert_eq!(&out[len..], &old_out[len..]);\n\n        let mut out_alt = old_out.clone();\n        limbs_div_exact_limb_to_out::<DoubleLimb, Limb>(&mut out_alt, &xs, 3);\n        assert_eq!(out_alt, out);\n\n        let mut out_alt = old_out;\n        limbs_div_exact_3_to_out_alt(&mut out_alt, &xs);\n        assert_eq!(out_alt, out);\n    });\n}\n\n#[test]\nfn limbs_div_exact_3_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_5().test_properties_with_config(&config, |mut xs| {\n        let old_xs = xs.clone();\n        limbs_div_exact_3_in_place(&mut xs);\n        assert_eq!(\n            Natural::from_limbs_asc(&xs),\n            Natural::from_limbs_asc(&old_xs).div_exact(Natural::from(3u32))\n        );\n\n        let mut xs_alt = old_xs.to_vec();\n        limbs_div_exact_limb_in_place(&mut xs_alt, 3);\n        assert_eq!(xs_alt, xs);\n\n        let mut xs_alt = old_xs.to_vec();\n        limbs_div_exact_3_in_place_alt(&mut xs_alt);\n        assert_eq!(xs_alt, xs);\n    });\n}\n\n#[test]\nfn limbs_modular_invert_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_12().test_properties_with_config(&config, |(mut is, ds)| {\n        let n = ds.len();\n        let mut scratch = vec![0; limbs_modular_invert_scratch_len(n)];\n        limbs_modular_invert(&mut is, &ds, &mut scratch);\n        verify_limbs_modular_invert(&ds, &is[..n]);\n    });\n}\n\n#[test]\nfn limbs_modular_div_mod_schoolbook_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_14().test_properties_with_config(\n        &config,\n        |(mut qs, mut ns, ds, inverse)| {\n            let ns_old = ns.clone();\n            let borrow = limbs_modular_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse);\n            let q_len = ns.len() - ds.len();\n            verify_limbs_modular_div_mod(&ns_old, &ds, borrow, &qs[..q_len], &ns[q_len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_modular_div_mod_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    large_type_gen_var_15().test_properties_with_config(\n        &config,\n        |(mut qs, mut ns, ds, inverse)| {\n            let ns_old = ns.clone();\n            let borrow = limbs_modular_div_mod_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n            let q_len = ns.len() - ds.len();\n            verify_limbs_modular_div_mod(&ns_old, &ds, borrow, &qs[..q_len], &ns[q_len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_modular_div_mod_barrett_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_quadruple_gen_var_2().test_properties_with_config(\n        &config,\n        |(mut qs, mut rs, ns, ds)| {\n            let mut scratch =\n                vec![0; limbs_modular_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n            let borrow = limbs_modular_div_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n            let q_len = ns.len() - ds.len();\n            verify_limbs_modular_div_mod(&ns, &ds, borrow, &qs[..q_len], &rs[..ds.len()]);\n        },\n    );\n}\n\n#[test]\nfn limbs_modular_div_schoolbook_properties() {\n    large_type_gen_var_13().test_properties(|(mut qs, mut ns, ds, inverse)| {\n        let ns_old = ns.clone();\n        limbs_modular_div_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        verify_limbs_modular_div_neg(&ns_old, &ds, &qs);\n\n        let mut ns = ns_old.to_vec();\n        limbs_modular_div_schoolbook_in_place(&mut ns, &ds, inverse);\n        assert_eq!(ns, &qs[..ns.len()]);\n    });\n}\n\n#[test]\nfn limbs_modular_div_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    large_type_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut qs, mut ns, ds, inverse)| {\n            let ns_old = ns.clone();\n            limbs_modular_div_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n            verify_limbs_modular_div(&ns_old, &ds, &qs);\n        },\n    );\n}\n\n#[test]\nfn limbs_modular_div_barrett_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_46().test_properties_with_config(&config, |(mut qs, ns, ds)| {\n        let mut scratch = vec![0; limbs_modular_div_barrett_scratch_len(ns.len(), ds.len())];\n        limbs_modular_div_barrett(&mut qs, &ns, &ds, &mut scratch);\n        verify_limbs_modular_div(&ns, &ds, &qs[..ns.len()]);\n    });\n}\n\n#[test]\nfn limbs_modular_div_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_47().test_properties_with_config(\n        &config,\n        |(mut qs, mut ns, ds)| {\n            let qs_old = qs.clone();\n            let ns_old = ns.clone();\n            let mut scratch = vec![0; limbs_modular_div_scratch_len(ns.len(), ds.len())];\n            limbs_modular_div(&mut qs, &mut ns, &ds, &mut scratch);\n            let result = qs;\n\n            let mut qs = qs_old.to_vec();\n            let ns = ns_old;\n            let mut scratch = vec![0; limbs_modular_div_ref_scratch_len(ns.len(), ds.len())];\n            limbs_modular_div_ref(&mut qs, &ns, &ds, &mut scratch);\n            assert_eq!(qs, result);\n\n            verify_limbs_modular_div(&ns, &ds, &qs[..ns.len()]);\n        },\n    );\n}\n\n#[test]\nfn limbs_div_exact_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_48().test_properties_with_config(\n        &config,\n        |(mut qs, mut ns, mut ds)| {\n            let qs_old = qs.clone();\n            let ns_old = ns.clone();\n            let ds_old = ds.clone();\n            limbs_div_exact_to_out(&mut qs, &mut ns, &mut ds);\n            let result = qs;\n\n            let mut qs = qs_old.to_vec();\n            let mut ns = ns_old.to_vec();\n            let mut ds = ds_old.to_vec();\n            limbs_div_exact_to_out_val_ref(&mut qs, &mut ns, &ds);\n            assert_eq!(qs, result);\n\n            let mut qs = qs_old.to_vec();\n            let ns = ns_old;\n            limbs_div_exact_to_out_ref_val(&mut qs, &ns, &mut ds);\n            assert_eq!(qs, result);\n\n            let mut qs = qs_old.to_vec();\n            let ds = ds_old;\n            limbs_div_exact_to_out_ref_ref(&mut qs, &ns, &ds);\n            assert_eq!(qs, result);\n\n            let q_len = ns.len() - ds.len() + 1;\n            let qs = limbs_div_exact(&ns, &ds);\n            assert_eq!(qs, &result[..q_len]);\n\n            verify_limbs_div_exact(&ns, &ds, &qs[..q_len]);\n        },\n    );\n}\n\n#[test]\nfn div_exact_properties() {\n    natural_pair_gen_var_6().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.div_exact_assign(&y);\n        assert!(mut_x.is_valid());\n        let q = mut_x;\n\n        let mut mut_x = x.clone();\n        mut_x.div_exact_assign(y.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, q);\n\n        let q_alt = (&x).div_exact(&y);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = (&x).div_exact(y.clone());\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = x.clone().div_exact(&y);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = x.clone().div_exact(y.clone());\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n\n        let q_alt = (&x).div_round(&y, Exact).0;\n        assert_eq!(q_alt, q);\n\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::from(&x).div_exact(&rug::Integer::from(&y))),\n            q\n        );\n\n        assert_eq!(q * y, x);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).div_exact(Natural::ONE), n);\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(Natural::ZERO.div_exact(&n), 0);\n        assert_eq!((&n).div_exact(&n), 1);\n    });\n\n    unsigned_pair_gen_var_11::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).div_exact(Natural::from(y)), x.div_exact(y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/div_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivAssignNegMod, CeilingDivNegMod, DivAssignMod, DivAssignRem, DivMod, DivRem, DivRound,\n    NegMod, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::conversion::traits::{ExactFrom, JoinHalves};\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_12, unsigned_pair_gen_var_12, unsigned_pair_gen_var_35,\n    unsigned_vec_pair_gen_var_11, unsigned_vec_triple_gen_var_50, unsigned_vec_triple_gen_var_51,\n    unsigned_vec_triple_gen_var_53, unsigned_vec_unsigned_pair_gen_var_22,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13,\n};\nuse malachite_nz::natural::arithmetic::div_mod::{\n    limbs_div_limb_in_place_mod, limbs_div_limb_mod, limbs_div_limb_to_out_mod, limbs_div_mod,\n    limbs_div_mod_barrett, limbs_div_mod_barrett_scratch_len, limbs_div_mod_by_two_limb_normalized,\n    limbs_div_mod_divide_and_conquer, limbs_div_mod_extra, limbs_div_mod_extra_in_place,\n    limbs_div_mod_schoolbook, limbs_div_mod_three_limb_by_two_limb, limbs_div_mod_to_out,\n    limbs_invert_approx, limbs_invert_basecase_approx, limbs_invert_limb,\n    limbs_invert_newton_approx, limbs_two_limb_inverse_helper,\n};\nuse malachite_nz::natural::{Natural, limb_to_bit_count};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_11, large_type_gen_var_12, large_type_gen_var_18, large_type_gen_var_19,\n    natural_gen, natural_gen_var_2, natural_pair_gen_var_5, natural_pair_gen_var_6,\n    unsigned_sextuple_gen_var_2, unsigned_vec_quadruple_gen_var_1,\n    unsigned_vec_quadruple_gen_var_5,\n};\nuse malachite_nz::test_util::natural::arithmetic::div_mod::{\n    limbs_div_limb_in_place_mod_alt, limbs_div_limb_in_place_mod_naive,\n    limbs_div_limb_to_out_mod_alt, limbs_div_limb_to_out_mod_naive, rug_ceiling_div_neg_mod,\n};\nuse num::{BigUint, Integer};\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_invert_limb() {\n    let test = |x: Limb, inv: Limb| {\n        assert_eq!(limbs_invert_limb::<DoubleLimb, Limb>(x), inv);\n    };\n    test(0x80000000, u32::MAX);\n    test(0x80000001, 0xfffffffc);\n    test(0x80000002, 0xfffffff8);\n    test(0x89abcdef, 0xdc08767e);\n    test(0xfffffffd, 3);\n    test(u32::MAX - 1, 2);\n    test(u32::MAX, 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_limb_mod_and_limbs_div_limb_in_place_mod() {\n    let test = |ns: &[Limb], d: Limb, q: Vec<Limb>, r: Limb| {\n        let (q_alt, r_alt) = limbs_div_limb_mod(ns, d);\n        assert_eq!(q_alt, q);\n        assert_eq!(r_alt, r);\n        let old_ns = ns;\n\n        let mut ns = old_ns.to_vec();\n        assert_eq!(limbs_div_limb_in_place_mod(&mut ns, d), r);\n        assert_eq!(ns, q);\n\n        let mut ns = old_ns.to_vec();\n        assert_eq!(limbs_div_limb_in_place_mod_alt(&mut ns, d), r);\n        assert_eq!(ns, q);\n\n        let mut ns = old_ns.to_vec();\n        assert_eq!(limbs_div_limb_in_place_mod_naive(&mut ns, d), r);\n        assert_eq!(ns, q);\n    };\n    test(&[0, 0], 2, vec![0, 0], 0);\n    test(&[6, 7], 1, vec![6, 7], 0);\n    test(&[6, 7], 2, vec![0x80000003, 3], 0);\n    test(&[100, 101, 102], 10, vec![1288490198, 858993469, 10], 8);\n    test(&[123, 456], 789, vec![2482262467, 0], 636);\n    test(&[u32::MAX, u32::MAX], 2, vec![u32::MAX, 0x7fffffff], 1);\n    test(&[u32::MAX, u32::MAX], 3, vec![0x55555555, 0x55555555], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_mod_fail_1() {\n    limbs_div_limb_mod(&[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_mod_fail_2() {\n    limbs_div_limb_mod(&[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_in_place_mod_fail_1() {\n    limbs_div_limb_in_place_mod(&mut [10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_in_place_mod_fail_2() {\n    limbs_div_limb_in_place_mod(&mut [10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_limb_to_out_mod() {\n    let test = |out_before: &[Limb], ns: &[Limb], d: Limb, r: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_div_limb_to_out_mod(&mut out, ns, d), r);\n        assert_eq!(out, out_after);\n\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_div_limb_to_out_mod_alt(&mut out, ns, d), r);\n        assert_eq!(out, out_after);\n\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_div_limb_to_out_mod_naive(&mut out, ns, d), r);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[0, 0], 2, 0, &[0, 0, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 1, 0, &[6, 7, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, 0, &[0x80000003, 3, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        8,\n        &[1288490198, 858993469, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        789,\n        636,\n        &[2482262467, 0, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, u32::MAX],\n        2,\n        1,\n        &[u32::MAX, 0x7fffffff, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, u32::MAX],\n        3,\n        0,\n        &[0x55555555, 0x55555555, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_to_out_mod_fail_1() {\n    limbs_div_limb_to_out_mod(&mut [10], &[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_to_out_mod_fail_2() {\n    limbs_div_limb_to_out_mod(&mut [10, 10], &[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_limb_to_out_mod_fail_3() {\n    limbs_div_limb_to_out_mod(&mut [10], &[10, 10], 10);\n}\n\nfn verify_limbs_div_mod_extra(\n    original_out: &[Limb],\n    fraction_len: usize,\n    ns: &[Limb],\n    d: Limb,\n    out: &[Limb],\n    r: Limb,\n) {\n    let out_len = ns.len() + fraction_len;\n    let mut extended_ns = vec![0; out_len];\n    extended_ns[fraction_len..].copy_from_slice(ns);\n    let n = Natural::from_owned_limbs_asc(extended_ns);\n    let d = Natural::from(d);\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let q = Natural::from_limbs_asc(&out[..out_len]);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, expected_r);\n    assert_eq!(&out[out_len..], &original_out[out_len..]);\n    assert!(r < d);\n    assert_eq!(q * d + Natural::from(r), n);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_mod_extra() {\n    let test = |out_before: &[Limb],\n                fraction_len: usize,\n                ns: &[Limb],\n                d: Limb,\n                r: Limb,\n                out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        let shift = LeadingZeros::leading_zeros(d);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n        assert_eq!(\n            limbs_div_mod_extra(&mut out, fraction_len, ns, d, d_inv, shift),\n            r\n        );\n        assert_eq!(out, out_after);\n        verify_limbs_div_mod_extra(out_before, fraction_len, ns, d, &out, r);\n    };\n    // - shift != 0\n    // - ns_last >= d\n    // - !ns.is_empty()\n    test(&[10, 10, 10, 10], 0, &[123], 7, 4, &[17, 10, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        1,\n        &[123],\n        7,\n        2,\n        &[2454267026, 17, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        0,\n        &[123, 456],\n        7,\n        1,\n        &[613566774, 65, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        1,\n        &[123, 456],\n        7,\n        4,\n        &[613566756, 613566774, 65, 10],\n    );\n    // - ns_last < d\n    // - ns.is_empty()\n    test(&[10; 3], 0, &[1], 2, 1, &[0, 10, 10]);\n    test(&[10; 4], 0, &[0, 1], 2, 0, &[0x80000000, 0, 10, 10]);\n    // - shift == 0\n    test(\n        &[10; 10],\n        6,\n        &[1494880112, 1342788885],\n        3459538423,\n        503849941,\n        &[\n            3112466029, 4165884652, 3488895153, 1476752580, 2095685273, 2437515973, 1667053127, 0,\n            10, 10,\n        ],\n    );\n    test(\n        &[10; 3],\n        0,\n        &[3702397177],\n        3086378613,\n        616018564,\n        &[1, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_mod_extra_fail_1() {\n    let d = 7;\n    let shift = LeadingZeros::leading_zeros(d);\n    let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n    limbs_div_mod_extra(&mut [10; 2], 1, &[123, 456], d, d_inv, shift);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_mod_extra_fail_2() {\n    limbs_div_mod_extra(&mut [10; 4], 1, &[123, 456], 0, 0, 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_mod_extra_fail_3() {\n    let d = 7;\n    let shift = LeadingZeros::leading_zeros(d);\n    let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n    limbs_div_mod_extra(&mut [10; 4], 1, &[], d, d_inv, shift);\n}\n\nfn verify_limbs_div_mod_extra_in_place(\n    original_ns: &[Limb],\n    fraction_len: usize,\n    d: Limb,\n    ns: &[Limb],\n    r: Limb,\n) {\n    let mut extended_ns = vec![0; ns.len()];\n    extended_ns[fraction_len..].copy_from_slice(&original_ns[fraction_len..]);\n    let n = Natural::from_owned_limbs_asc(extended_ns);\n    let d = Natural::from(d);\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let q = Natural::from_limbs_asc(ns);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, expected_r);\n    assert!(r < d);\n    assert_eq!(q * d + Natural::from(r), n);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_mod_extra_in_place() {\n    let test = |ns_before: &[Limb], fraction_len: usize, d: Limb, r: Limb, ns_after: &[Limb]| {\n        let mut ns = ns_before.to_vec();\n        let shift = LeadingZeros::leading_zeros(d);\n        let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n        assert_eq!(\n            limbs_div_mod_extra_in_place(&mut ns, fraction_len, d, d_inv, shift),\n            r\n        );\n        assert_eq!(ns, ns_after);\n        verify_limbs_div_mod_extra_in_place(ns_before, fraction_len, d, &ns, r);\n    };\n    // - shift != 0\n    // - ns_last >= d\n    // - !ns.is_empty()\n    test(&[123], 0, 7, 4, &[17]);\n    test(&[10, 123], 1, 7, 2, &[2454267026, 17]);\n    test(&[123, 456], 0, 7, 1, &[613566774, 65]);\n    test(&[10, 123, 456], 1, 7, 4, &[613566756, 613566774, 65]);\n    // - ns_last < d\n    // - ns.is_empty()\n    test(&[1], 0, 2, 1, &[0]);\n    test(&[0, 1], 0, 2, 0, &[0x80000000, 0]);\n    // - shift == 0\n    test(\n        &[10, 10, 10, 10, 10, 10, 1494880112, 1342788885],\n        6,\n        3459538423,\n        503849941,\n        &[3112466029, 4165884652, 3488895153, 1476752580, 2095685273, 2437515973, 1667053127, 0],\n    );\n    test(&[3702397177], 0, 3086378613, 616018564, &[1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_mod_extra_in_place_fail_1() {\n    limbs_div_mod_extra_in_place(&mut [0, 123, 456], 1, 0, 0, 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_mod_extra_in_place_fail_2() {\n    let d = 7;\n    let shift = LeadingZeros::leading_zeros(d);\n    let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n    limbs_div_mod_extra_in_place(&mut [], 0, d, d_inv, shift);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_div_mod_extra_in_place_fail_3() {\n    let d = 7;\n    let shift = LeadingZeros::leading_zeros(d);\n    let d_inv = limbs_invert_limb::<DoubleLimb, Limb>(d << shift);\n    limbs_div_mod_extra_in_place(&mut [123, 456], 2, d, d_inv, shift);\n}\n\nfn verify_limbs_two_limb_inverse_helper(hi: Limb, lo: Limb, result: Limb) {\n    let b = Natural::power_of_2(Limb::WIDTH);\n    let b_cubed_minus_1 = Natural::low_mask(Limb::WIDTH * 3);\n    let x = Natural::from(DoubleLimb::join_halves(hi, lo));\n    let expected_result = &b_cubed_minus_1 / &x - &b;\n    assert_eq!(result, expected_result);\n    assert!(b_cubed_minus_1 - (Natural::from(result) + b) * &x < x);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_two_limb_inverse_helper() {\n    let test = |hi, lo, result| {\n        assert_eq!(limbs_two_limb_inverse_helper(hi, lo), result);\n        verify_limbs_two_limb_inverse_helper(hi, lo, result);\n    };\n    // - hi_product >= lo\n    // - hi_product >= lo_product_hi\n    test(0x80000000, 0, u32::MAX);\n    test(0x80000000, 123, u32::MAX);\n    test(0x80000123, 1, 0xfffffb74);\n    test(u32::MAX, 0, 1);\n    // - hi_product < lo\n    test(u32::MAX, 123, 0);\n    test(0xfffff123, 1, 0xedd);\n    test(u32::MAX, u32::MAX, 0);\n    // - hi_product < lo_product_hi\n    // - !(hi_product > hi || hi_product == hi && lo_product_lo >= lo)\n    test(0x80000001, 3, 0xfffffffb);\n    // - hi_product > hi || hi_product == hi && lo_product_lo >= lo\n    test(2325651385, 3907343530, 3636893938);\n}\n\n#[test]\n#[should_panic]\nfn limbs_two_limb_inverse_helper_fail() {\n    limbs_two_limb_inverse_helper(0, 10);\n}\n\nfn verify_limbs_div_mod_three_limb_by_two_limb(\n    n_2: Limb,\n    n_1: Limb,\n    n_0: Limb,\n    d_1: Limb,\n    d_0: Limb,\n    q: Limb,\n    r: DoubleLimb,\n) {\n    let n = Natural::from_owned_limbs_asc(vec![n_0, n_1, n_2]);\n    let d = Natural::from(DoubleLimb::join_halves(d_1, d_0));\n    let r = Natural::from(r);\n    assert_eq!((&n).div_mod(&d), (Natural::from(q), r.clone()));\n    assert!(r < d);\n    assert_eq!(Natural::from(q) * d + r, n);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_mod_three_limb_by_two_limb() {\n    let test = |n_2, n_1, n_0, d_1, d_0, q, r| {\n        assert_eq!(\n            limbs_div_mod_three_limb_by_two_limb(\n                n_2,\n                n_1,\n                n_0,\n                d_1,\n                d_0,\n                limbs_two_limb_inverse_helper(d_1, d_0)\n            ),\n            (q, r)\n        );\n        verify_limbs_div_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, q, r);\n    };\n    // - r < d\n    // - r.upper_half() >= q_0\n    test(1, 2, 3, 0x80000004, 5, 1, 0x7ffffffdfffffffe);\n    test(2, 0x40000000, 4, 0x80000000, 0, 4, 0x4000000000000004);\n    // - r >= d\n    // - r.upper_half() < q_0\n    test(\n        1614123406,\n        3687984980,\n        2695202596,\n        2258238141,\n        1642523191,\n        3069918587,\n        274277675918877623,\n    );\n}\n\nfn verify_limbs_div_mod_by_two_limb_normalized(\n    qs_in: &[Limb],\n    ns_in: &[Limb],\n    ds: &[Limb],\n    q_highest: bool,\n    qs_out: &[Limb],\n    ns_out: &[Limb],\n) {\n    let n = Natural::from_limbs_asc(ns_in);\n    let d = Natural::from_limbs_asc(ds);\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let base_q_len = ns_in.len() - 2;\n    let mut qs = qs_out[..base_q_len].to_vec();\n    if q_highest {\n        qs.push(1);\n    }\n    let q = Natural::from_owned_limbs_asc(qs);\n    let r = Natural::from_limbs_asc(&ns_out[..2]);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, expected_r);\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n    assert_eq!(&ns_in[2..], &ns_out[2..]);\n\n    assert!(r < d);\n    assert_eq!(q * d + r, n);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_mod_by_two_limb_normalized() {\n    let test = |qs_in: &[Limb], ns_in: &[Limb], ds, q_highest, qs_out: &[Limb], ns_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        assert_eq!(\n            limbs_div_mod_by_two_limb_normalized(&mut qs, &mut ns, ds),\n            q_highest\n        );\n        assert_eq!(qs, qs_out);\n        assert_eq!(ns, ns_out);\n        verify_limbs_div_mod_by_two_limb_normalized(qs_in, ns_in, ds, q_highest, &qs, &ns);\n    };\n    // - !highest_q\n    test(&[10], &[1, 2], &[3, 0x80000000], false, &[10], &[1, 2]);\n    test(\n        &[10, 10, 10, 10],\n        &[1, 2, 3, 4, 5],\n        &[3, 0x80000000],\n        false,\n        &[4294967241, 7, 10, 10],\n        &[166, 2147483626, 3, 4, 5],\n    );\n    // - highest_q\n    test(\n        &[0, 0],\n        &[4142767597, 2922703399, 3921445909],\n        &[2952867570, 2530544119],\n        true,\n        &[2360708771, 0],\n        &[3037232599, 1218898013, 3921445909],\n    );\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_by_two_limb_normalized_fail_1() {\n    limbs_div_mod_by_two_limb_normalized(&mut [10], &mut [1, 2], &[3, 4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_by_two_limb_normalized_fail_2() {\n    limbs_div_mod_by_two_limb_normalized(&mut [10], &mut [1, 2], &[3, 0x80000000, 4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_by_two_limb_normalized_fail_3() {\n    limbs_div_mod_by_two_limb_normalized(&mut [10], &mut [1, 2, 3, 4], &[3, 0x80000000]);\n}\n\nfn verify_limbs_div_mod_1(\n    qs_in: &[Limb],\n    ns_in: &[Limb],\n    ds: &[Limb],\n    q_highest: bool,\n    qs_out: &[Limb],\n    ns_out: &[Limb],\n) {\n    let n = Natural::from_limbs_asc(ns_in);\n    let d = Natural::from_limbs_asc(ds);\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let base_q_len = ns_in.len() - ds.len();\n    let mut qs = qs_out[..base_q_len].to_vec();\n    if q_highest {\n        qs.push(1);\n    }\n    let q = Natural::from_owned_limbs_asc(qs);\n    let r = Natural::from_limbs_asc(&ns_out[..ds.len()]);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, expected_r);\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n    assert!(r < d);\n    assert_eq!(q * d + r, n);\n}\n\n#[test]\nfn test_limbs_div_mod_schoolbook() {\n    let test = |qs_in: &[Limb],\n                ns_in: &[Limb],\n                ds: &[Limb],\n                q_highest,\n                qs_out: &[Limb],\n                ns_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n        assert_eq!(\n            limbs_div_mod_schoolbook(&mut qs, &mut ns, ds, inv),\n            q_highest\n        );\n        assert_eq!(qs, qs_out);\n        assert_eq!(ns, ns_out);\n        verify_limbs_div_mod_1(qs_in, ns_in, ds, q_highest, &qs, &ns);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - !highest_q\n        test(\n            &[10],\n            &[1, 2, 3],\n            &[3, 4, 0x80000000],\n            false,\n            &[10],\n            &[1, 2, 3],\n        );\n        // - !(n_1 == d_1 && ns[i - 1] == d_0)\n        // - !carry\n        test(\n            &[10, 10, 10, 10],\n            &[1, 2, 3, 4, 5, 6],\n            &[3, 4, 0x80000000],\n            false,\n            &[4294967207, 9, 12, 10],\n            &[268, 328, 2147483575, 4294967251, 5, 6],\n        );\n        // - carry\n        test(\n            &[10],\n            &[0, 0, 0, 1],\n            &[1, 0, 0x80000000],\n            false,\n            &[1],\n            &[u32::MAX, u32::MAX, 0x7fffffff, 1],\n        );\n        // - highest_q\n        test(\n            &[10; 10],\n            &[\n                2460989955, 642673607, 1971681331, 2338977519, 475442971, 2516527409, 3470931196,\n                4262052990,\n            ],\n            &[\n                1430162564, 1873089879, 3090281851, 2861182896, 2502166555, 2486624904, 960387080,\n                3073064701,\n            ],\n            true,\n            &[10, 10, 10, 10, 10, 10, 10, 10, 10, 10],\n            &[\n                1030827391, 3064551024, 3176366775, 3772761918, 2268243711, 29902504, 2510544116,\n                1188988289,\n            ],\n        );\n        // - n_1 == d_1 && ns[i - 1] == d_0\n        test(\n            &[10; 8],\n            &[\n                0,\n                0x4000000,\n                0xfffff000,\n                63,\n                4294443008,\n                u32::MAX,\n                u32::MAX,\n                8388575,\n                4294836224,\n                0x3fffffff,\n            ],\n            &[33554304, 4294443008, u32::MAX],\n            false,\n            &[0, 4294443008, u32::MAX, u32::MAX, u32::MAX, u32::MAX, 0x3fffffff, 10],\n            &[\n                0,\n                0,\n                0,\n                4294443072,\n                0xfff00000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294836224,\n                0x3fffffff,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[10; 17],\n            &[\n                9995257893114397114,\n                9401504468144459131,\n                558615837638945228,\n                10733662027974786928,\n                18295107704289976677,\n                1814706268673753787,\n                12474943759854623335,\n                8814778832826774208,\n                9159057654048965906,\n                4451260977376821357,\n                18241701617364042056,\n                6169989192350218482,\n                15071965537117101028,\n                13509168527678537782,\n                12224278653171635329,\n                16077066393714953826,\n                1433938684868066489,\n                13014970036232570373,\n                899282336249563956,\n                3089487642230339536,\n                3787737519477527148,\n                16667686214395942740,\n                8787122953224574943,\n                7841835218775877827,\n                9693303502025838409,\n                16122224776459879427,\n                144327425397945219,\n            ],\n            &[\n                2350654041004706911,\n                7834348511584604247,\n                12756796070221345724,\n                3842923787777653903,\n                12373799197090248752,\n                9712029403347085570,\n                1426676505264168302,\n                10586232903332693517,\n                8387833601131974459,\n                6290888746273553243,\n                9503969704425173615,\n            ],\n            false,\n            &[\n                89235393247566392,\n                5198286616477507104,\n                15671556528191444298,\n                6642842185819876016,\n                1703950202232719208,\n                6620591674460885314,\n                9897211438557358662,\n                12382449603707212210,\n                13586842887558233290,\n                11884313943008627054,\n                3205830138969300059,\n                4257812936318957065,\n                11084100237971796628,\n                13937343901544333624,\n                11743372027422931451,\n                280132530083052382,\n                10,\n            ],\n            &[\n                12688955427180652274,\n                7641660693922643933,\n                8789985477567049482,\n                5698832637416200787,\n                14684840547760545685,\n                2822100467869581421,\n                3557573565928866957,\n                4409631974409684922,\n                16994214656621423610,\n                4513108841166793667,\n                9009005527785483287,\n                4330767427200269309,\n                11409205475757922767,\n                12430752173702915207,\n                11990819624778098799,\n                4145020291153594556,\n                7099200056207569977,\n                3510167930325480168,\n                4731667122118327121,\n                10720310942075546738,\n                5799804483118787221,\n                17268037247251138479,\n                13305947798457087249,\n                1405091439325174594,\n                13072181651983436371,\n                16122224776459879427,\n                144327425397945219,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_schoolbook_fail_1() {\n    let ds = &[3, 0x80000000];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_schoolbook(&mut [10], &mut [1, 2, 3], ds, inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_schoolbook_fail_2() {\n    let ds = &[3, 4, 5, 0x80000000];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_schoolbook(&mut [10], &mut [1, 2, 3], ds, inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_schoolbook_fail_3() {\n    let ds = &[3, 4, 0x80000000];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_schoolbook(&mut [10], &mut [1, 2, 3, 4, 5], ds, inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_schoolbook_fail_4() {\n    let ds = &[3, 4, 5];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_schoolbook(&mut [10], &mut [1, 2, 3], ds, inv);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_div_mod_divide_and_conquer() {\n    let test = |qs_in: &[Limb],\n                ns_in: &[Limb],\n                ds: &[Limb],\n                q_highest,\n                qs_out: &[Limb],\n                ns_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let ds_len = ds.len();\n        let inv = limbs_two_limb_inverse_helper(ds[ds_len - 1], ds[ds_len - 2]);\n        assert_eq!(\n            limbs_div_mod_divide_and_conquer(&mut qs, &mut ns, ds, inv),\n            q_highest\n        );\n        assert_eq!(qs, qs_out);\n        assert_eq!(&ns[..ds_len], ns_out);\n        verify_limbs_div_mod_1(qs_in, ns_in, ds, q_highest, &qs, &ns);\n    };\n    // - q_len <= d_len\n    // - q_len < DC_DIV_QR_THRESHOLD\n    // - m != 0\n    test(\n        &[10; 4],\n        &[1, 2, 3, 4, 5, 6, 7, 8, 9],\n        &[3, 4, 5, 6, 7, 0x80000000],\n        false,\n        &[4294967057, 15, 18, 10],\n        &[718, 910, 1080, 1286, 1492, 2147483434],\n    );\n    // - carry != 0 second time\n    test(\n        &[0; 3],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n        &[0, 0, 0, 0, 1, 0, 0, 0x80000000],\n        false,\n        &[1, 0, 0],\n        &[0, 0, 0, 0, u32::MAX, u32::MAX, u32::MAX, 0x7fffffff],\n    );\n    // - highest_q third time\n    test(\n        &[\n            1341443830, 680228019, 2358294753, 4240552485, 4220791420, 3445360969, 1267691556,\n            3340881424, 992535572, 1421700486, 4136881179,\n        ],\n        &[\n            342694080, 2041952014, 1126110022, 386493367, 2712278177, 1646877232, 868323005,\n            1128141558, 2508964077, 2270408768, 413397861, 276293957, 2413870149, 3904853505,\n            1276303079, 2556190902, 3967785388, 2803311564, 1963309088, 2281251697, 108392083,\n            3821172642, 2048710986, 445614759, 2901896991, 3601903082, 1748962330, 658337341,\n            3756770944, 2926642090, 7482898, 2241569433, 3381544088, 3275875595, 3036252835,\n            2075586864, 1267727773, 221607050, 3946214050, 921175728, 655433083, 3594825352,\n            1857831165, 3460211778, 2710641188, 1271591399, 263125866, 3619333728, 1041602820,\n            3231202083, 259949419, 4156557841, 3419638674, 3270070813, 2084018311, 2951772182,\n            860428573, 1138531819, 71044931, 3406637788, 3662652535, 3741808197, 86584983,\n            1543795459, 160951322, 1039367499, 2428548772, 3604743617, 1138310711, 2881638514,\n            2899388867, 3501166651, 161644747, 2395978477, 2682256494, 3417971200, 624066885,\n            1772236754, 48275686, 3979745914, 2458268763, 2470110876, 3143857674, 3359279240,\n            46246098, 2912257532, 2916568936,\n        ],\n        &[\n            4267671814, 3181376526, 4204274026, 2772982826, 171341955, 3239339748, 83269891,\n            2325049318, 746305994, 1290717192, 1805639230, 1856363646, 3445599715, 1388597950,\n            2699498310, 246990054, 1396771726, 265087723, 3372840761, 3260397695, 2010115470,\n            2211074582, 1883962263, 256363687, 4012920099, 2367091978, 1485341992, 1836339208,\n            1434180757, 2616877872, 1145425491, 1261399773, 3926766027, 3115015865, 1741783714,\n            3802513218, 4081750672, 3856503286, 2137512595, 1192985123, 1863041957, 700637154,\n            2503934926, 2021744810, 157763047, 453501781, 1898727251, 3741166728, 105996483,\n            3390681922, 1127471458, 4229032301, 254843851, 2729237155, 1707011850, 1756734415,\n            1864969309, 96539023, 220456923, 3061776324, 1741151628, 1199010536, 2099212259,\n            3095715999, 1369052975, 2575251120, 1821995904, 4169452262, 3299830336, 666854626,\n            3647011057, 3965571435, 1551218489, 726151433, 1730753749, 750433250, 2084548637,\n            475638490, 3209308986, 1536371286, 3458731894, 451976715, 1463077982, 2401462738,\n        ],\n        true,\n        &[\n            4074815036, 3472841870, 921256965, 4240552485, 4220791420, 3445360969, 1267691556,\n            3340881424, 992535572, 1421700486, 4136881179,\n        ],\n        &[\n            50882392, 3543059939, 2606418187, 171797978, 3702339267, 3400795540, 1675838746,\n            3131956910, 3246773095, 2366066134, 1942572319, 200951604, 2751524401, 2229461380,\n            953596498, 2149080321, 992246008, 2665146762, 3598754770, 101403369, 2364937647,\n            3687287854, 3518388658, 3773344884, 2952272227, 2179289728, 3985568008, 2985468384,\n            1733586261, 4006520661, 592636589, 1738983882, 3771432433, 334405279, 30528997,\n            3353300809, 3694124666, 1257341879, 1142716002, 3178475445, 1431232435, 2733787829,\n            2350134046, 162973337, 604966704, 1355497537, 2006066960, 1053669332, 2166548589,\n            1297102232, 878976420, 1030095675, 3202690801, 955256572, 1487108550, 2945568597,\n            3875785235, 1390419282, 1216776596, 786261001, 3784540042, 1845909951, 1777517834,\n            12237310, 475982412, 3059699536, 4125207911, 2924612871, 3238196381, 2479221661,\n            1483884124, 433754513, 447002430, 2684532044, 3494064078, 619277683, 2680056541,\n            538552294, 1984267024, 700348592, 1278341418, 1614761367, 3944408375, 1269851701,\n        ],\n    );\n    // - hi < DC_DIV_QR_THRESHOLD in limbs_div_mod_divide_and_conquer_helper\n    // - carry != 0 first time in limbs_div_mod_divide_and_conquer_helper\n    // - lo < DC_DIV_QR_THRESHOLD in limbs_div_mod_divide_and_conquer_helper\n    // - carry != 0 second time in limbs_div_mod_divide_and_conquer_helper\n    // - q_len > d_len\n    // - q_len_mod_d_len == 1\n    // - 2 < q_len_mod_d_len < DC_DIV_QR_THRESHOLD\n    // - q_len_mod_d_len != d_len\n    // - highest_q second time\n    // - carry != 0 first time\n    test(\n        &[\n            3656551823, 3383257247, 550091805, 1932339117, 3279901067, 2864941409, 3440756420,\n            466783416, 651341619, 2318022162, 1201487629, 3064175522, 2345469826, 3581748650,\n            2606599593, 3742095121,\n        ],\n        &[\n            3689695988, 3117118992, 1237207334, 1180101208, 2947083336, 2827697081, 221923985,\n            2507264800, 619323315, 1516562901, 3186068769, 1013769776, 1271582351, 1669896397,\n            2497959088, 3504047880, 4212568439, 1608150067, 4150555892, 374787916, 889323122,\n            3833122938, 4262272989,\n        ],\n        &[\n            3226059476, 722714803, 1915993039, 2160412527, 1484228011, 1715426198, 1611850737,\n            3097214810,\n        ],\n        true,\n        &[\n            3948774568, 277233294, 951139522, 4214130560, 3551225641, 3386184722, 1565143611,\n            2922369553, 2764255027, 5466750, 2823931470, 3552636955, 545484857, 803194457,\n            1615608566, 3742095121,\n        ],\n        &[\n            1074470868, 2174113464, 1715956530, 3963027838, 1871758691, 1809783936, 3173233408,\n            1926929270,\n        ],\n    );\n    // - hi >= DC_DIV_QR_THRESHOLD in limbs_div_mod_divide_and_conquer_helper\n    // - lo >= DC_DIV_QR_THRESHOLD in limbs_div_mod_divide_and_conquer_helper\n    // - q_len_mod_d_len >= DC_DIV_QR_THRESHOLD\n    test(\n        &[\n            2108009976, 2838126990, 827008974, 4157613011, 3782799311, 839921672, 879731301,\n            1926496935, 3712149888, 2363043408, 3863476261, 1703718215, 499165670, 2993223230,\n            4279694017, 2976095205, 2193242813, 3593708162, 586354096, 296757650, 242624274,\n            199363552, 2802933005, 2759687879, 3925865458, 4217980786, 621040829, 4008464542,\n            3795907109, 270168250, 3625538473, 759155103, 3959828159, 1835721901, 1818377089,\n            114690984, 2967220963, 2377698568, 2241245638, 2252300906, 3116551983, 3644576818,\n            2608501946, 2181270779, 1815210824, 1268283136, 484429506, 1180516809, 559610343,\n            2543044915, 3719740023, 558939794, 3989231279, 1089033996, 3509826828, 3545449066,\n            3353643945, 2822587915, 2300900020, 309191900, 2371088678, 1169317833, 2688462322,\n            704882387, 1429447898, 2514029776, 1955158460, 3862686818, 1584130288, 482000750,\n            4224830364, 2104097699, 1183456674, 2270729014, 2607655660, 2966545947, 2931252595,\n            759652385, 3970839358, 2487392344, 1507124762, 758697388, 3840603988, 1293583672,\n            252424514, 646352064, 1756992845, 2309291248, 3392597937, 2946557682, 3659552460,\n            1720311830, 3395887210, 2674135679, 3196424053, 2895118562, 1256983146, 2482795730,\n            1922474903, 2105232035, 3692384401, 2891711374, 3496171341, 515080177, 4073860792,\n            2051799135, 2279442367, 3258846627, 70977295, 1937954703, 2800340027, 1760719187,\n            646417623, 3158839049, 3176203007, 213391749, 869819866, 3906922929, 1586646665,\n            1614123406, 3687984980, 1177302158, 272342927, 1441818617, 2083855650, 1541781406,\n            3311904586, 106907162, 4108429222, 662974012, 4140594255, 1984524179, 3259771450,\n            3863443649, 3307256449, 3597197635, 3771753969, 3551628070, 3550518548, 2546464879,\n            3812123817, 2299164636, 2258249267, 815945886, 3725185601, 738801212, 3862546442,\n            207778311, 1535617953, 2150997157, 729581295, 143725958, 1410055499, 4204574368,\n            2185442793, 3653861199, 1767186378, 3537808267, 1766021033, 2239408696, 1986025224,\n            3625288948, 4046347844, 2490523057, 3491861717, 1312039469, 597857291, 206880668,\n            1812928615, 3684502664, 3820772609, 1327777451, 1237379465, 764273090, 3594853086,\n            2859643842, 1243019386, 3444655918, 1596721727, 2221238575, 2483346164, 2064518283,\n            2282844430, 1960424205, 4028198846, 2342293800, 1645322170, 3508868511, 2376856302,\n            1764497492, 2461899059, 3430260828, 1083983032, 1448541077, 2081767380, 1131293272,\n            2121152826, 4212689224, 2039367869, 2193844060, 1864700761, 1182989130, 1481869846,\n            969270162, 3997775597, 1483663077, 394034269, 1586435653, 2281434261, 1937512315,\n            836935557, 59742568, 1854699653, 2116629465, 328821302, 1999851100, 604863759,\n            556389113, 2057620108, 1992554416, 427465103, 813735424, 487055225, 402647361,\n            3006998394, 2146302389, 2308517156, 1063328348, 2382344201, 2665908320, 481118926,\n            2376219143, 1164055989, 128362737, 2711666601, 1898018298, 2928344090, 3862251511,\n            749517272, 2790599579, 3506539103, 2592038317, 1682088920, 1332639030, 3053921374,\n            3066891587, 242466377, 3536065834, 2016487096, 1321862427, 2409873623, 3088797737,\n            2840818323, 2052021858, 4079299898, 452968540, 3880575723, 2680668784, 1502544423,\n            1619882634, 1068420458, 3236073318, 1740351058, 1183565882, 2761799103, 246817911,\n            2967032269, 4003972840, 969974269, 3193561842, 1002645557, 2347161653, 4272895273,\n            1522072178, 972383725, 3026624523, 434293193, 2855690795, 2455822196, 2413168892,\n            2999634230, 784531194, 249556803, 2559695464, 3131798530, 668810109, 2114036394,\n            2861740558, 370716909, 2126014070, 3913884200, 1577476936, 855642956, 2074597201,\n            3461659621, 3292762038, 2153122643, 1658901071, 1562860969, 501980289, 1611843440,\n            2433026108, 3791871978,\n        ],\n        &[\n            2325147333, 1406197332, 1502532645, 137754493, 1488912421, 1014222449, 1678300831,\n            2078887154, 2311629707, 3855402290, 1904906031, 1350026944, 314061674, 919972212,\n            1429252796, 544807358, 2607111216, 3001219316, 160533550, 2875169678, 1402474615,\n            3234840532, 1662112023, 1943050521, 4132256985, 2915369430, 699620367, 59590583,\n            2461837586, 3986106860, 2659659366, 3589796255, 4168995860, 2337625655, 4292546333,\n            1793085295, 2647770730, 2871508164, 2660729400, 3630964395, 3874212033, 1240042620,\n            1713051992, 2105061240, 968807145, 3026819276, 2442427316, 2718248469, 2572140009,\n            1793916894, 2112926236, 1058005225, 1528978151, 98430379, 3348888463, 2121431457,\n            3545708238, 3975070402, 764453596, 192861224, 2698588322, 1493819664, 2502294971,\n            3139295505, 1318649192, 1552623529, 2989328476, 1592829691, 1175278450, 182489613,\n            1858350437, 2440903999, 1622786339, 162763913, 4106583944, 609833788, 1344925844,\n            3910333895, 1369398307, 51929280, 2214052160, 78601532, 642016948, 3966440550,\n            4161875340, 3764174238, 2944905670, 832634369, 2082700552, 3444794582, 962611192,\n            38510846, 2733538376, 2141542785, 621670923, 3130866640, 1666281368, 3628581169,\n            3965100367, 2889091703, 762371524, 3752935086, 656901001, 2374421435, 3084212494,\n            1186140919, 3420046356, 775236355, 1337865306, 2051118555, 713071112, 1946850844,\n            1427068060, 3949026319, 3075128554, 438166063, 3975561046, 858907746, 26964870,\n            3843362808, 1461820702, 3090970200, 1037540471, 289966660, 2768763862, 50890120,\n            580189324, 2911422550, 3684738914, 2025034397, 414622319, 2287243961, 3268939669,\n            3547523099, 4011963324, 1768695320, 1859343614, 2123856143, 4141054481, 765801396,\n            359993985, 3668605792, 3613648266, 1778728280, 2547397231, 2456061149, 2562918666,\n            2903450513, 1994190773, 99234624, 3722083920, 4262323306, 202219441, 4201857695,\n            3988878636, 1533308334, 401400520, 1069756554, 2457773969, 2892388936, 3423117995,\n            1944069442, 492036629, 3426800580, 2282483359, 4006366620, 1695364515, 2555180845,\n            1669287836, 349290429, 778467450, 2020203604, 2218159817, 1450404019, 1278304750,\n            2412695340, 1592154884, 3868182043, 2240370481, 3859902860, 1008825116, 412233394,\n            2475457637, 3664379433, 4204584226, 2750684469, 4113507475, 2916584959, 285955744,\n            739598569, 18278051, 3768126932, 2181905109, 2612988076, 1827656088, 1160380415,\n            4160443718, 1846086671, 3050604645, 2547108010, 2828666778, 3252702258, 3885923576,\n            2331974758, 730724707, 1528859315, 4288784328, 3677151116, 445199233, 3304488688,\n            3566979465, 3541025426, 2491779846, 3112990742, 2583249486, 3403111749, 1930721237,\n            3428792463, 2896462048, 2985885576, 1819460734, 21206096, 3560441846, 987100555,\n            2844904275, 84854892, 1268249628, 3963306788, 3338670067, 2504599089, 65588657,\n            321493327, 4249673617, 4150876068, 721566898, 2186945060, 922948272, 1502464627,\n            1426914435, 2906888275, 3454987739, 2609132626, 2073366782, 1058809001, 1226951003,\n            2624503637, 282722778, 1407178266, 3304346308, 3613017687, 2397594777, 161128076,\n            1938083248, 3042822216, 3958145306, 1431161184, 4147630074, 1744618540, 3729847703,\n            2366216428, 2101731625, 2812677939, 3587016062, 1626785569, 3117017254, 3720581461,\n            4254564252, 2400911475, 750362271, 3062375802, 2182368701, 268751862, 2682134876,\n            274793576, 2417658182, 2321240923, 4200603818, 1349142841, 4066976957, 1043247680,\n            679021323, 2933095037, 1621487581, 225868669, 1030678959, 1236344244, 972640788,\n            1784301152, 578117349, 3509551550, 214420003, 3786992737, 802372148, 3562194086,\n            2187046946, 3600373521, 4275090943, 2120016813, 4177241875, 3185774231, 2397692077,\n            1015362399, 2178889151, 3433916223, 1688082118, 1971242178, 236388706, 3802829765,\n            521309115, 2299816689, 3207614143, 1053195464, 3584561145, 1178690670, 2940812254,\n            3321982035, 2754825123, 3073598062, 202404806, 547895545, 1188944547, 1056841779,\n            529463805, 204665384, 850370055, 2063320161, 3724100092, 1180272690, 1398467003,\n            2814052449, 1311768018, 659771105, 3226477227, 4230080238, 2134344405, 1461172705,\n            2728018383, 1816821358, 3231137250, 2012377728, 2206916761, 3121807673, 3037967028,\n            3653505029, 4164239058, 1337501466, 2487452346, 428839025, 3321493092, 2920064796,\n            2750126813, 3635762100, 2659829309, 1992243088, 2359420187, 861816585, 4182313312,\n            1389528266, 2890138969, 2195001695, 576635805, 1974585967, 851480113, 1896534852,\n            3143828462, 4276040597, 3921135859, 2394233682, 2692972118, 2103941456, 3931376544,\n            3790764632, 2278428793, 3381340311, 3516241824, 2923157557, 1276268033, 3471729699,\n            2370137091, 2637023305, 4027814477, 3711009696, 3667995314, 459819000, 1002878772,\n            2658190707, 1189561796, 1831813150, 2874008201,\n        ],\n        &[\n            1703326352, 1625259628, 3642322228, 911402341, 2158835226, 939248485, 3607511108,\n            2863853568, 1611642161, 1312857772, 1839433327, 567060478, 3139863681, 3642698184,\n            3744632443, 712538472, 2692932947, 576185818, 156934113, 518107105, 2803035863,\n            2284220097, 3447382922, 2400125006, 3565062840, 160044186, 3644393084, 4196433258,\n            3391883838, 1115703759, 2380388002, 962895870, 4001772616, 2311278419, 2620271020,\n            3047789793, 3229254302, 3182628087, 2718480927, 2872538422, 1963990826, 2856537226,\n            1729736384, 372544200, 1482170753, 3370665422, 305555060, 4060802437, 1456459795,\n            2848113958, 1036273297, 3245835346, 3355862097, 3242734427, 3313897419, 4230036415,\n            1425594704, 2428756491, 420147714, 3218149930, 1791217142, 2881741659, 3231612869,\n            845372829, 1635665046, 1525482197, 3779462557, 2279005731, 626908159, 2963734610,\n            215448882, 2517668355, 3294128769, 1167990371, 2344651228, 2882002195, 3350056381,\n            3749638142, 476010196, 2304276366, 1088082897, 1927672185, 3316329053, 1174989749,\n            1101596429, 3054511229, 1685228241, 2301284206, 2526016461, 684171580, 3869889559,\n            2606492401, 2114658735, 1419214215, 2779052449, 2594333668, 2225446358, 1211258458,\n            4029343999, 2816277230, 4098142949, 1987363952, 2732004911, 2516355975, 2365350298,\n            1747416524, 3951513077, 3526462790,\n        ],\n        false,\n        &[\n            1303670916, 3965736473, 654490008, 3337248200, 112312312, 2506678400, 713192736,\n            901474194, 2359721047, 1133557120, 3068598661, 3136858413, 4095957211, 3057328754,\n            1900588230, 1315930687, 3273808327, 2821746043, 4255148500, 3072995291, 1472014781,\n            922081554, 1759317078, 149072645, 2712091402, 2134310281, 708105323, 3703209145,\n            2071594694, 8111834, 3766831226, 2182956891, 2525476614, 1478202223, 4199311113,\n            3813148212, 316780911, 1396844257, 2321402831, 1151134318, 848673799, 735789140,\n            1092813310, 738412079, 1895091662, 2947844274, 31103395, 2559694049, 1194304023,\n            3260126654, 1118043028, 1552558623, 3016599055, 1053142289, 446041643, 2615854004,\n            2105823819, 3769707039, 2784177611, 9564629, 580911617, 1979035813, 1479556681,\n            2599744262, 3097426153, 4195176293, 3497554127, 3484306250, 2114827319, 2314051712,\n            1210812068, 4158781103, 478301760, 2027533091, 1682020897, 129914624, 2066167843,\n            3989890251, 1378700448, 170057876, 3992582209, 1541347967, 3421610776, 697014638,\n            2834243941, 3504973679, 630519426, 1551901326, 3092678418, 1136389639, 1806538485,\n            2208151411, 1598302001, 4041410193, 3574334276, 2340664244, 1624426425, 1200740723,\n            2912910258, 671197404, 2272603994, 909857936, 792804858, 3083891114, 3143045405,\n            2389563439, 115312858, 1445242760, 2065820105, 256586994, 1432132569, 1549619424,\n            2631865338, 1674212272, 2599765330, 3713129178, 1590556325, 3610491293, 709987753,\n            3230113618, 1606099993, 3453954266, 3501213811, 3278809492, 3770342657, 1534951916,\n            1366321311, 3149479124, 3987513652, 2108936446, 1162972378, 279205823, 3711325879,\n            2278557694, 2305274058, 3709507652, 3805940202, 3778288085, 1061153771, 491180471,\n            479623642, 2960728114, 553156023, 1863065855, 2253455830, 14222934, 2488687289,\n            3378176628, 1136227234, 3805644784, 3175842224, 463501844, 2100687360, 2025076951,\n            4064921772, 1000043802, 2482142143, 1463585061, 1044328896, 3966669663, 1023595412,\n            2689537057, 685044345, 2599439954, 3302022962, 2669841238, 3358991646, 351579450,\n            2303934592, 2098132645, 2239011851, 1623838039, 790570033, 2288992150, 2252675624,\n            2479618080, 3624986625, 2129338944, 3796999988, 465518072, 620957443, 1836556967,\n            2894771224, 2904933718, 287211723, 1386209013, 2288387719, 162551270, 370319691,\n            2924564913, 2947669880, 3390862854, 1797811, 3097227838, 2245950593, 1664498395,\n            3380635348, 3536484871, 1217287925, 3149066538, 154911037, 1960867817, 4238493382,\n            1991791660, 509572665, 3386968719, 3880405816, 2335816696, 2519967410, 3482574698,\n            1501302597, 2415671279, 715902305, 1920401004, 3735445496, 1792155851, 2110622431,\n            3695395614, 3311496726, 4035668560, 187609524, 3743601469, 2990357125, 3084998227,\n            767424914, 1388627321, 1381810466, 3799640235, 1423360242, 3375037167, 979951340,\n            3463933333, 387599460, 229837304, 1394766077, 1068156038, 1135935924, 86516134,\n            142150630, 448211640, 3205606056, 1420159909, 4203558153, 2816235778, 4188064475,\n            1490981561, 2934083684, 2693435736, 1351552613, 962789901, 1071201732, 3244341475,\n            1855681940, 4210620238, 2129345127, 2909949483, 3992748944, 3928807766, 2014533910,\n            3099391001, 3112195816, 4009296318, 1247610431, 1474512546, 2530880557, 3597268331,\n            764359883, 4198267775, 1228639730, 736768887, 396797847, 799410613, 582496441,\n            2658423343, 1643853660, 1258585041, 3767032705, 3709454541, 892807168, 1443895160,\n            3500326521, 784531194, 249556803, 2559695464, 3131798530, 668810109, 2114036394,\n            2861740558, 370716909, 2126014070, 3913884200, 1577476936, 855642956, 2074597201,\n            3461659621, 3292762038, 2153122643, 1658901071, 1562860969, 501980289, 1611843440,\n            2433026108, 3791871978,\n        ],\n        &[\n            1707334789, 979340170, 3926273349, 2029694660, 686358037, 1260123629, 689471236,\n            4127009836, 1697317324, 3024229658, 3968952300, 2265029759, 733830093, 2234057965,\n            799627406, 1641742523, 2511563041, 678204198, 60484965, 1732955108, 1348641815,\n            1389334445, 3762643904, 3914179461, 4076462931, 3234877741, 2806715190, 3058911852,\n            3068848122, 80861952, 660210165, 2035863667, 3882844515, 2652987274, 207029959,\n            4170201248, 1224653886, 3554890284, 323203565, 969583090, 2280910221, 2548241625,\n            2048045350, 3691775573, 3750377304, 2623340073, 1726676400, 2551234664, 3420452119,\n            1785849707, 3581615935, 3521097022, 4008380099, 4200557552, 3795120169, 488463511,\n            3784467967, 2462685342, 1684084055, 1072125823, 765304928, 2900468163, 3209242917,\n            399160769, 3897765190, 3241572534, 1027203705, 4127226109, 154941175, 1755153596,\n            4225252328, 1209101989, 2906888698, 1481930532, 2884731435, 2416462752, 553651049,\n            2247421040, 3347507436, 1936621186, 3156059073, 4059864280, 3191940359, 3872902453,\n            783002816, 3711047515, 1471051688, 357992570, 1061754510, 3765779801, 4106840335,\n            3213049794, 1824410844, 2555550067, 1066295382, 3248869963, 4006861446, 3297772017,\n            3418388327, 2284151457, 766215224, 1091253635, 2070830666, 1435103841, 1408352671,\n            338399542, 2946293497, 412804347,\n        ],\n    );\n    // - q_len >= DC_DIV_QR_THRESHOLD\n    test(\n        &[\n            3333140561, 2349469031, 666934289, 3646788197, 3373340607, 3062489357, 1781577064,\n            3971231072, 2027939726, 18149756, 461121573, 1026270057, 4154481498, 3854995191,\n            2829169318, 2604923553, 1399568275, 4214150257, 1269657447, 527209086, 559827800,\n            1978807620, 1942748659, 3544969161, 760896836, 694370989, 3323597771, 1950755821,\n            1740588707, 2716546795, 1636681281, 131422512, 2683077565, 4107286368, 3475458482,\n            1406752921, 2741526831, 625075474, 1356017187, 660778033, 4078598031, 2127023485,\n            1900179860, 2413773277, 2442990944, 850894581, 1061627184, 2255197913, 490496693,\n            400007380, 3092474488, 1228905086, 1949288324, 1866222251, 4084867584, 219026194,\n            1513678816, 2415719293, 671740632, 2331463444, 1649508273, 622524186, 36198287,\n            385821590, 3891184984, 3888867762, 823766845, 871168771, 4220135146, 3182319759,\n            3811051122, 2244319794, 1994956782, 3515960993, 3523512148, 4142104035, 11404747,\n            3407068856, 2661473296, 1343912700, 1278923149, 1319603671, 3928437020, 2678906106,\n            1133029551, 3498992572, 3960506675, 2156562886, 2180928089, 4027866586, 3363079195,\n            2699625088, 10633112, 1776348429, 2657266039, 366882369, 3755249663, 1513004482,\n            385462618, 1235118123, 2498536948, 2963795538, 373052379, 4211662453, 1125414031,\n            3132282357, 2555861787, 3949045845, 2694335672, 335933961, 2882374566, 3487775198,\n            1816750435, 3017829161, 964613564, 159555703, 1822850997, 2275865751, 4158541302,\n            2501990511, 3721844651, 2781838144, 1795741626, 377630941, 2137086277, 150771080,\n            3410699853, 2181744662, 3165518125, 156617039, 3099687100, 2159351188, 340108091,\n            2408725718, 1639869303, 1752843886, 1941447467, 2157946488, 1515895552, 3624132653,\n            3556726921, 2697391196, 3650363912, 2596921683, 3641623430, 3884964637, 4229700714,\n            1936259996, 3765315225, 4087511128, 746291101, 1752759843, 699518598, 2102672534,\n            2335948897, 4138231225, 3162828440, 2881768368, 1254885146, 2977691172, 2250072411,\n            2614007259, 2771551612, 776074685, 3162839614, 1471012556, 523323297, 1856466918,\n            4090405884, 813410161, 100155385, 1084252628, 1599609446, 139407955, 4121369443,\n            1963225032, 2735275753, 100107317, 1064061529, 50786861, 1654370440, 3334472166,\n            1385803654, 3881645932, 3538258401, 1238925138, 1307191791, 2439918414, 1853442725,\n            3584719283, 2139830944, 1008033673, 2159214266, 1728151904, 2054140804, 2246372905,\n            1296034828, 732486414, 4197166746, 2149038695, 2421556216, 2209917678, 2053724924,\n            3695308867, 2810551805, 3486105675, 979515789, 2065617241, 3321246575, 4275036932,\n            3028497318, 1883398852, 1301060583, 2486427309, 592113155, 2482121819, 53211642,\n            3067158128, 2316354328, 2457370797, 1766767168, 4130364650, 1394191393, 893956183,\n            3188688185, 1875859783, 3686866863, 3294062742, 2146834313, 2406586432, 1574602180,\n            3208002016, 1067708846, 1620126309, 593911816, 1573785767, 2208656217, 4037191927,\n            3437397556, 425721135, 3749387007, 407468749, 4203518167, 557223936, 3186718435,\n            3473504989, 2673679280, 1478635903, 4172750097, 1469776418, 2542136327, 941914936,\n            3438581078, 3116581940, 3479694655, 159558945, 3809792710, 2458053073, 945749848,\n            3386290936, 950397544, 148027778, 275178526, 1664599931, 2000347485, 3312866545,\n            4123761723, 2408292910, 4050298, 4225958969, 2745635153, 1877283873, 90573827,\n            3031684040, 2275034810, 476532317, 4006527249, 2818283214, 661127690, 2880950746,\n            3285389422, 965419004, 1273458580, 1611437669, 4165036259, 503131762, 337440890,\n            1274837150, 3486913543, 1110808141, 3573281492, 3543428578, 4165550725, 79661970,\n            1465954224, 4160343768, 3753977684, 849800837, 1568284940, 1214508489, 777072754,\n            3766232553, 4163385462, 3428999259, 906027128, 4231567110, 1070253805, 2975789822,\n            1794042990, 2937404746, 3315145973, 3978541255, 191961431, 2940436214, 614874984,\n            868388988, 4078685796, 2613877234, 3380127687, 2664922311, 3262235038, 741871774,\n            1144269180, 4258950699, 3668553647, 3162392321, 927199539, 557637561, 1114912670,\n            84346866, 4241634616, 592125931, 1914166161, 1225886409, 722682712, 2163011354,\n            2585075265, 2786722853, 1993844439, 3433052694, 3718814733, 3881165856, 1749980152,\n            2115861966, 3664836486, 1644814678, 603487648, 821270634, 3041437740, 925329308,\n            414275079, 3675481275, 583965775, 3319812843, 270816609, 1752806861, 3191564196,\n            3197116565, 2440000620, 4074382088, 3346183865, 176525856, 3011091744, 746158938,\n            1522027948, 930706422, 2574400675, 4141639266, 758742087, 1418306156, 493509688,\n            4102390641, 3757183059, 2174506350, 3715933078, 3450125642, 1345548124, 3845070193,\n            1563795423, 1304049315, 2604880108, 1998271877, 4078353958, 966179722, 3401781407,\n            1708183977, 3890171386, 698646214, 604975097, 4189977050, 1847675543, 2745048720,\n            1585177380, 3886892753, 2534712423, 1830125662, 796996186, 3789574770, 2219095884,\n            38427113, 3653683439, 1791769536, 3941686320, 2991883118, 1081207663, 3863639548,\n            3017351034, 741393256, 2333573607, 2783158305, 2015776314, 3034707152, 1871224010,\n            1795881414, 928539629, 3211747317, 461147496, 1512738445, 1178891684, 2603472964,\n            1694950214, 3121022285, 91788635, 2303571910, 3259041724, 1240577113, 827064078,\n            3847765430, 1254285617, 2609289648, 82835530, 2235563901, 2939680484, 3327268666,\n            3659752183, 1783109461, 2828509671, 3804296197, 406800911, 2037292519, 941994402,\n            3350211940, 4004870359, 1105941782, 2367553097, 2440982990, 1468367, 2369391483,\n            3613174135, 2337161925, 2600055725, 1612773644, 1037201309, 919122459, 1114016493,\n            670586694, 594109706, 113464329, 4093636009, 307208587, 3876235186, 3370598978,\n            934478190, 2843794891,\n        ],\n        &[\n            2368917411, 3160758175, 1531480588, 2746326450, 3122359045, 1995296172, 310451197,\n            1100329853, 2141732304, 3562890277, 4172526924, 4143185198, 2397101926, 620168044,\n            828452963, 3271569899, 2726758945, 1647557222, 2748652901, 1029871186, 1773072595,\n            1311795717, 2792240418, 3100733307, 298902661, 2608361440, 642743765, 3026335712,\n            1586592828, 1251923561, 2152803283, 3359308047, 3979690761, 2548031009, 2148504694,\n            2514911217, 401310800, 1418125404, 2325652800, 716233458, 422262103, 376190943,\n            1713380879, 2534508846, 2080413009, 2690193951, 2909422387, 2435837201, 176977642,\n            224472737, 1590904934, 1664979624, 1748982641, 1284257790, 2779881254, 385265989,\n            1148527382, 800142050, 3595556318, 3950265146, 3931111523, 3399894595, 4200004994,\n            3727110364, 1510525540, 429323681, 2586345405, 3441619670, 94654169, 2266545045,\n            1451808026, 286040435, 364003484, 2106693078, 1916214330, 2622096560, 3504008387,\n            1867458297, 4209615436, 2899684845, 3149003214, 2731979274, 2481557740, 234269740,\n            1239420776, 2726912636, 1844267393, 1488044058, 1587005400, 145015793, 1637696129,\n            1990069464, 3053970062, 676336554, 625771493, 1492378707, 1231018082, 3059699722,\n            4113615249, 2967103567, 3335726303, 2137774253, 273460502, 1561489611, 1227429414,\n            778315897, 3061631993, 2437789514, 2566029814, 3017507824, 3219754602, 35255136,\n            1934306764, 1655248959, 3655963814, 2821596564, 1431977748, 3114012833, 3915822059,\n            343010167, 3704265251, 2691314567, 2602475242, 2459094882, 58857240, 2230690665,\n            1357656795, 3025543277, 3488674640, 408985076, 80729036, 246851391, 1419653386,\n            530010128, 3529087076, 3980421141, 4129023783, 1630771696, 2057278583, 2501545742,\n            790764428, 3984347668, 2562445985, 2262348292, 2515967925, 1103371818, 3735595401,\n            3210477145, 3387257181, 538884374, 2695206119, 4211749041, 1006274735, 2406061865,\n            2654644297, 1268724640, 2399689302, 157759259, 564853502, 865205768, 2174783618,\n            3167863384, 1770172407, 1906775255, 3171669377, 2455086709, 1355327864, 3351895167,\n            4184858376, 2699533565, 2939169294, 1702277740, 3447680482, 3322351998, 4248517760,\n            4100425921, 1169799041, 524849931, 1743345401, 3987645088, 3022177240, 3263737545,\n            3656340460, 239445170, 4089162190, 1208712978, 1453215235, 3390225374, 3337889603,\n            717395279, 1066458381, 2162685522, 4009460245, 2575879990, 2578471337, 4218103221,\n            3046325563, 1352991515, 1561949281, 3488911174, 295633326, 1993756395, 3677304657,\n            796898320, 45622345, 2999482773, 2078651788, 1552765091, 428170722, 1748054862,\n            4158222865, 1050292437, 249107, 2651086861, 1540178674, 1275557298, 651050585,\n            1895599156, 4150309716, 2064336046, 1021257319, 2422595446, 3116755258, 2756656575,\n            2328011578, 3632905157, 2576200202, 830418644, 2430246370, 3913080080, 2371749061,\n            2683067461, 3611558701, 1603392737, 796477803, 604567756, 1376069347, 1491246154,\n            2728262664, 4138498935, 3008562381, 1061547384, 285679033, 2358943172, 1884649492,\n            1783482693, 1010268161, 176114433, 794165875, 2362278477, 3903204233, 326754905,\n            1988607850, 3187254334, 1749797209, 2986661384, 1759716588, 3137467938, 4067743599,\n            1134210801, 3799848836, 1955405545, 3881788427, 3097574490, 3844756657, 3183850151,\n            2496328910, 1468671385, 2888878911, 2306353811, 1498824361, 4152891378, 1588217107,\n            79108222, 2883552792, 2390312777, 1587172303, 2070384343, 2265280181, 4013380367,\n            2742676878, 2654283484, 1471778694, 970959698, 1006151052, 1276307400, 2874101774,\n            3169092608, 244587925, 2402787407, 1635687252, 835856534, 321407542, 2307278464,\n            2272745321, 2574317642, 729437319, 1682288870, 1482920833, 776000268, 3908963888,\n            214874919, 4233311318, 1441385448, 2358127573, 2753681514, 467574656, 4139948165,\n            1538275035, 3244920878, 2576965792, 584068468, 3054546876, 2629688518, 4253271747,\n            3723872815, 1652066683, 990821089, 2335421805, 1989570928, 240486517, 2872315587,\n            3869991906, 3870517664, 1540804424, 397183643, 3750033565, 1433260634, 1506168711,\n            3616651625, 512028445, 3746712828, 3278592880, 2611514549, 1214563129, 1259227909,\n            1067976218, 3425169051, 741795595, 893688343, 2674408703, 3694908868, 2478153735,\n            2220661625, 1022546736, 3719214155, 3161293211, 4131981986, 1473264088, 1651777063,\n            1438502715, 290022167, 59234682, 3458968160, 2552001459, 3451530289, 3800073253,\n            717882913, 845719525, 1038699111, 3058303772, 1117505279, 3682430977, 2869037104,\n            2562493618, 960519305, 4147639705, 1817463351, 3166022129, 3200769866, 789666262,\n            2654485924, 3686362402, 2179867687, 3980226915, 3671542918, 1896992204, 1514962591,\n            815867715, 3924270086, 4262628477, 3977258034,\n        ],\n        &[\n            491933121, 4095154087, 1190388341, 2123387578, 3299683037, 3840239224, 3891252433,\n            3823858915, 548023871, 3189021809, 130119335, 1406023029, 1691542279, 2101470388,\n            367145009, 521045073, 1370995123, 202251222, 2377400220, 3656022509, 2413445446,\n            3583191945, 150872893, 1253881977, 3664619565, 661519973, 672952411, 1111416155,\n            2582282747, 2253466637, 3993637585, 1023965093, 4055175549, 1721196160, 4271105372,\n            1844335262, 794907961, 3970777280, 1279126024, 3389187110, 6388771, 3557792034,\n            2503975364, 1216157736, 4081863507, 1212796362, 22717034, 3517296783, 3126258972,\n            454147562, 4182968994, 685295412, 2996150679, 840677609, 2775806132, 2555856748,\n            2855553012, 2971949846, 3057579317, 954558068, 1251032539, 2673204563, 697957636,\n            1312479140, 2686740988, 2005131101, 664387193, 2169938189, 4081160067, 3469684725,\n            123152292, 2899902365, 1142266692, 2066860665, 647803613, 3574778631, 1302596512,\n            678200322, 3509569151, 849744577, 1521760114, 3195673981, 111241164, 623461570,\n            3571445453, 200189218, 4138515602, 665845464, 4184871542, 1353865395, 2913489035,\n            3076207781, 2549062531, 3446687793, 685940105, 1430268106, 2488363196, 1172253595,\n            4151501269, 3292280286, 2025935004, 3388911026, 1080796771, 3386986959, 4175562557,\n            2440556214, 9871988, 5488492, 4179517076, 908443542, 364965294, 2303037125, 369102673,\n            1570100894, 3615415741, 3133015360, 2623933135, 211314818, 3377760249, 2285528104,\n            3096807957, 3213907502, 3633343924, 2065769028, 300167487, 1745300631, 1943126607,\n            1065862406, 2422304458, 523765517, 57630113, 520436682, 581485167, 527613705,\n            1677813796, 2698743484, 2448718551, 1681977324, 4183961145, 333724319, 2667028740,\n            3403027352, 1499647517, 2965583197, 1090547876, 1536215624, 3407325498, 1392474450,\n            3354142052, 3326326224, 1138672330, 1577104875, 235932133, 3877789753, 1822119722,\n            305251772, 3802044423, 608489509, 2727503310, 865373313, 3763994776, 3206318655,\n            88097048, 4241064408, 1171067683, 4250936686, 729121178, 763857558, 450636528,\n            2096197907, 1427186250, 1251064262, 3036762405, 2966424923, 880639864, 1995310474,\n            2023015792, 4198637421, 3996151657, 3070092174, 331733799, 2680348059, 2601390369,\n            92920881, 600583651, 1323663334, 4258529164, 2493258032, 3313489774, 2050494797,\n            1494880112, 1342788885, 2493538385, 1096813856, 27701253, 2762164402, 3934044073,\n            2289089808, 721323988, 2246162231, 2514451824, 3095057964, 1921436785, 2847276160,\n            1369952734, 4246781184, 3442030977, 3930627222, 614706399, 3051396564, 3044240928,\n            3450585985, 2120836933, 3006035710, 178202067, 736149219, 623937260, 1958379885,\n            3104814268, 3269365015, 914726129, 2951180538, 3940965189, 1869582492, 2599100173,\n            1009213592, 1410445689, 1179880005, 3583285938, 1921636631, 434725812, 735782942,\n            2548761027, 3733379485, 3466163816, 2455801926, 1673952134, 2422059957, 4005305357,\n            2795894062, 3245947918, 4171997564, 2269244989, 1975479474, 2449387935, 2550893401,\n            4033149, 3723976428, 3871853952, 3210178057, 2062131312, 1434821634, 1130065536,\n            4276609753, 41976415, 968125282, 853099726, 3675357389, 3545982836, 1237895428,\n            88970686, 4259275077,\n        ],\n        false,\n        &[\n            2046945960, 1873732058, 883136475, 2335087597, 1091742925, 3913267466, 1586245016,\n            4163559950, 1402352044, 2528046476, 1941819469, 2309605638, 3377063311, 3151818591,\n            494038776, 3426549387, 3253079763, 124752778, 4008075289, 327167526, 1965527166,\n            717131100, 1676230023, 3836503956, 3686584911, 550652113, 589790309, 2877365586,\n            2824639624, 3138038419, 3640799592, 585603054, 1414821912, 3869326513, 3124646127,\n            813686461, 180141293, 2274287537, 3375883484, 3539423998, 2876480809, 1880629606,\n            2803556469, 687655801, 393062928, 524210967, 2366097978, 2175763640, 3159336997,\n            790281459, 3247341866, 170318031, 1506555227, 246985421, 2165448534, 4166633223,\n            3351234404, 3976060563, 3925058943, 398933467, 3413453047, 3215824401, 2764818555,\n            2281679666, 2124899687, 3988046369, 3496024103, 1898489528, 3748055383, 1888289090,\n            3518616015, 2878886670, 1858863206, 1865431124, 2320246513, 1797214962, 3620561150,\n            3636061735, 1288494915, 1503932934, 333549760, 2000535203, 2963961099, 151292676,\n            4071971672, 2869808036, 801933070, 1423471894, 477371428, 3645363638, 2586777443,\n            3381283382, 3165264014, 1496932333, 2011004150, 558029532, 1103521912, 3099006002,\n            2922027532, 2250375874, 869652089, 386060205, 514086971, 679438817, 2922028193,\n            3519808732, 1083788073, 2102488620, 2723526073, 3287730376, 3961054192, 1086172650,\n            3775096139, 3273358074, 3471776285, 4280446341, 1945339479, 3318103287, 2895065752,\n            4010586984, 3721844651, 2781838144, 1795741626, 377630941, 2137086277, 150771080,\n            3410699853, 2181744662, 3165518125, 156617039, 3099687100, 2159351188, 340108091,\n            2408725718, 1639869303, 1752843886, 1941447467, 2157946488, 1515895552, 3624132653,\n            3556726921, 2697391196, 3650363912, 2596921683, 3641623430, 3884964637, 4229700714,\n            1936259996, 3765315225, 4087511128, 746291101, 1752759843, 699518598, 2102672534,\n            2335948897, 4138231225, 3162828440, 2881768368, 1254885146, 2977691172, 2250072411,\n            2614007259, 2771551612, 776074685, 3162839614, 1471012556, 523323297, 1856466918,\n            4090405884, 813410161, 100155385, 1084252628, 1599609446, 139407955, 4121369443,\n            1963225032, 2735275753, 100107317, 1064061529, 50786861, 1654370440, 3334472166,\n            1385803654, 3881645932, 3538258401, 1238925138, 1307191791, 2439918414, 1853442725,\n            3584719283, 2139830944, 1008033673, 2159214266, 1728151904, 2054140804, 2246372905,\n            1296034828, 732486414, 4197166746, 2149038695, 2421556216, 2209917678, 2053724924,\n            3695308867, 2810551805, 3486105675, 979515789, 2065617241, 3321246575, 4275036932,\n            3028497318, 1883398852, 1301060583, 2486427309, 592113155, 2482121819, 53211642,\n            3067158128, 2316354328, 2457370797, 1766767168, 4130364650, 1394191393, 893956183,\n            3188688185, 1875859783, 3686866863, 3294062742, 2146834313, 2406586432, 1574602180,\n            3208002016, 1067708846, 1620126309, 593911816, 1573785767, 2208656217, 4037191927,\n            3437397556, 425721135, 3749387007, 407468749, 4203518167, 557223936, 3186718435,\n            3473504989, 2673679280, 1478635903, 4172750097, 1469776418, 2542136327, 941914936,\n            3438581078, 3116581940, 3479694655, 159558945, 3809792710, 2458053073, 945749848,\n            3386290936, 950397544, 148027778, 275178526, 1664599931, 2000347485, 3312866545,\n            4123761723, 2408292910, 4050298, 4225958969, 2745635153, 1877283873, 90573827,\n            3031684040, 2275034810, 476532317, 4006527249, 2818283214, 661127690, 2880950746,\n            3285389422, 965419004, 1273458580, 1611437669, 4165036259, 503131762, 337440890,\n            1274837150, 3486913543, 1110808141, 3573281492, 3543428578, 4165550725, 79661970,\n            1465954224, 4160343768, 3753977684, 849800837, 1568284940, 1214508489, 777072754,\n            3766232553, 4163385462, 3428999259, 906027128, 4231567110, 1070253805, 2975789822,\n            1794042990, 2937404746, 3315145973, 3978541255, 191961431, 2940436214, 614874984,\n            868388988, 4078685796, 2613877234, 3380127687, 2664922311, 3262235038, 741871774,\n            1144269180, 4258950699, 3668553647, 3162392321, 927199539, 557637561, 1114912670,\n            84346866, 4241634616, 592125931, 1914166161, 1225886409, 722682712, 2163011354,\n            2585075265, 2786722853, 1993844439, 3433052694, 3718814733, 3881165856, 1749980152,\n            2115861966, 3664836486, 1644814678, 603487648, 821270634, 3041437740, 925329308,\n            414275079, 3675481275, 583965775, 3319812843, 270816609, 1752806861, 3191564196,\n            3197116565, 2440000620, 4074382088, 3346183865, 176525856, 3011091744, 746158938,\n            1522027948, 930706422, 2574400675, 4141639266, 758742087, 1418306156, 493509688,\n            4102390641, 3757183059, 2174506350, 3715933078, 3450125642, 1345548124, 3845070193,\n            1563795423, 1304049315, 2604880108, 1998271877, 4078353958, 966179722, 3401781407,\n            1708183977, 3890171386, 698646214, 604975097, 4189977050, 1847675543, 2745048720,\n            1585177380, 3886892753, 2534712423, 1830125662, 796996186, 3789574770, 2219095884,\n            38427113, 3653683439, 1791769536, 3941686320, 2991883118, 1081207663, 3863639548,\n            3017351034, 741393256, 2333573607, 2783158305, 2015776314, 3034707152, 1871224010,\n            1795881414, 928539629, 3211747317, 461147496, 1512738445, 1178891684, 2603472964,\n            1694950214, 3121022285, 91788635, 2303571910, 3259041724, 1240577113, 827064078,\n            3847765430, 1254285617, 2609289648, 82835530, 2235563901, 2939680484, 3327268666,\n            3659752183, 1783109461, 2828509671, 3804296197, 406800911, 2037292519, 941994402,\n            3350211940, 4004870359, 1105941782, 2367553097, 2440982990, 1468367, 2369391483,\n            3613174135, 2337161925, 2600055725, 1612773644, 1037201309, 919122459, 1114016493,\n            670586694, 594109706, 113464329, 4093636009, 307208587, 3876235186, 3370598978,\n            934478190, 2843794891,\n        ],\n        &[\n            3428605691, 3747865452, 3179948115, 2350061225, 568002466, 1150456745, 398797276,\n            1289784855, 1713342581, 1243415582, 2262476431, 2640854581, 2126611553, 279688048,\n            1750838292, 4147801215, 1090003542, 3022523567, 193306367, 3095010320, 4106129220,\n            2615828356, 2229875117, 1066352114, 1628397898, 370050060, 4157038478, 3551524420,\n            3356007005, 71309641, 801692593, 3448737794, 2187893878, 3694205688, 3993669226,\n            1704384353, 437976508, 281233142, 3685881986, 557022935, 2623696682, 3473835466,\n            2373703925, 4102552649, 3005124737, 1604665678, 2894612216, 113726438, 326916434,\n            2354584210, 2207672568, 1272863868, 1643657755, 453968751, 3873638645, 2388412558,\n            2026577065, 3555348237, 2342844423, 564662317, 3301275728, 2205414701, 1980322846,\n            2111846734, 3351655044, 3986317737, 3746472405, 4065813457, 3783710419, 2063617629,\n            3337397526, 396000532, 1367889075, 3493608147, 3502046919, 4063752078, 2026966957,\n            1730343114, 1889308216, 2064908820, 1350757250, 953211432, 3171180512, 3683852864,\n            2865517189, 9728788, 4075807873, 230559850, 3447666295, 3875782338, 2964025959,\n            3279832060, 1701408562, 1524777719, 2018628821, 877683542, 2894422993, 2842238026,\n            2368190181, 2574790540, 3301078931, 519264490, 2640226714, 1382986517, 2712031077,\n            1268830384, 2018243821, 1374899410, 1932087493, 4236194373, 2079152365, 1069353434,\n            2794047491, 3019576051, 1360117274, 3615353679, 3816194597, 563906666, 1827758233,\n            3391740972, 4039283822, 474920421, 602146150, 3520459365, 2217822485, 1815675107,\n            1257332805, 101198736, 3156910259, 1281759597, 2577040428, 1316988841, 790502779,\n            2183328888, 3514409721, 3117638288, 2751392867, 625199304, 4183171081, 810287943,\n            199775540, 2896399552, 1276626819, 3536203521, 3977249862, 1553852925, 1596788767,\n            4199876212, 4164476281, 1700598937, 4111801568, 897035781, 3318378574, 4049506305,\n            2522517679, 2296942227, 91515126, 2738354614, 3444113221, 776723413, 2322159108,\n            258188842, 4014626824, 2677530556, 2630906411, 2348643583, 2619411399, 1783064149,\n            3684137491, 4249816060, 2342260236, 4186117248, 3931377058, 283592002, 2818946531,\n            2155019855, 1212182985, 937681548, 520081464, 1686760025, 4003314294, 120323668,\n            3282730481, 1331500167, 2103184161, 453960707, 3079516933, 4193898972, 279508919,\n            2459211929, 4262295127, 1413249938, 2652447340, 1521334653, 3641279725, 1047788888,\n            2569690437, 3517124875, 527659101, 950373677, 562851515, 3518587604, 2668894245,\n            2265163836, 2975852422, 3168107907, 3219343979, 3364338005, 4122186542, 3517854206,\n            626303838, 201513242, 4042863292, 4203206994, 154681851, 1046188872, 1014035958,\n            1565481708, 783475007, 1419399714, 1439418252, 3671223860, 338436030, 2221870804,\n            275182251, 790279697, 3288665213, 3033639795, 2320556485, 1648356934, 326278183,\n            429784181, 104482651, 1051376296, 3823684587, 3057907898, 4214146560, 2770254088,\n            2132180852, 515232230, 3723417512, 3994583184, 1170935740, 565152109, 1486190861,\n            2906472005, 3154973145, 1571950735, 1391459913, 2972445791, 1670706254, 2522911431,\n            2665886703, 2875123532, 623767904, 1291947264, 3935970871, 2500309617, 3931020115,\n            3436644927, 3672390796, 2307254280,\n        ],\n    );\n    // - q_len_mod_d_len == 1\n    // - !(n_2 == d_1 && n_1 == d_0)\n    test(\n        &[\n            386353625, 2283334827, 253851108, 4279287864, 2561872983, 1000131216, 216965099,\n            1733322743, 3814906874, 520558483, 2573981410, 3011109093, 1361665859, 2981910167,\n            2501833654, 2673979284, 2696912361, 797890797, 97183495, 2324611911, 3471887001,\n            1013155374, 524729310, 3971281568, 2873934524, 1076401482, 1645093822, 423739674,\n            3400177353, 3716049850, 2858905860, 3351077705, 1478568656, 3370413874, 3966773377,\n            1660817988, 3770638166, 698194415, 92466505, 399941585, 3301477423, 2578917060,\n            3012966571, 1915213695, 3062576400, 2979801504, 3838450560, 975685759, 3154985631,\n            1986911427, 3559636850, 2134674515, 3128102806, 1097660929, 1212690783, 3611467219,\n            1232001761, 904465835, 671601217, 2829397960, 3910014855, 2035732477, 3262086074,\n            3077756473, 1064556527, 3095006074, 436186642, 3844079107, 2798261317, 3470373096,\n            218408908, 4184804463, 2826021777, 1939569756, 1452808097, 1149547097, 316749819,\n            1631475409, 4023391942, 513096309, 3730431754, 3391919570, 4153138767, 1328779762,\n            3015228258, 2487205968, 213982794, 1927310263, 897606115,\n        ],\n        &[\n            133654450, 371159391, 40768202, 2113895976, 2732923987, 3215138425, 2391931662,\n            2672734577, 195120416, 939150931, 1941696822, 2919872876, 2564539452, 3080820908,\n            2846583634, 3349568397, 3465385329, 3550405793, 1724556069, 151917586, 3772273289,\n            4156003461, 2380288065, 356475766, 4123619567, 1619017859, 3739529130, 490749645,\n            267879469, 2890847693, 3854244893, 3384266657, 115723042, 103663103, 267682519,\n            965965574, 1841386548, 2476428873, 6965648, 3347378817, 4174270937, 911558590,\n            1958087705, 1467103561, 1925556384, 607664404, 2051263137, 3092553737, 3239342455,\n            1360744647, 331798903, 938411111, 3063265275, 4144610940, 624250586,\n        ],\n        &[\n            3712980585, 4273305215, 2588121912, 1482202110, 247010829, 2649827458, 2673293530,\n            50266420, 3870816552,\n        ],\n        false,\n        &[\n            362121003, 2089507514, 1304606762, 1263278756, 358438501, 2269424948, 3806457519,\n            1279073058, 2059434869, 1815692099, 652038027, 526160281, 1238911451, 1042947643,\n            2960978573, 3022105016, 2649279744, 1198671551, 2684187685, 1000492760, 431499902,\n            183857299, 3280835037, 1246895529, 2318725685, 2267164315, 979921718, 3857707914,\n            3760109217, 2715707691, 1406885970, 2988297028, 209159729, 4186884247, 1096787060,\n            1637274376, 3553955911, 204938738, 2626213055, 3882415239, 2634475536, 1602083916,\n            1366306436, 671584326, 4002679807, 692653815, 3838450560, 975685759, 3154985631,\n            1986911427, 3559636850, 2134674515, 3128102806, 1097660929, 1212690783, 3611467219,\n            1232001761, 904465835, 671601217, 2829397960, 3910014855, 2035732477, 3262086074,\n            3077756473, 1064556527, 3095006074, 436186642, 3844079107, 2798261317, 3470373096,\n            218408908, 4184804463, 2826021777, 1939569756, 1452808097, 1149547097, 316749819,\n            1631475409, 4023391942, 513096309, 3730431754, 3391919570, 4153138767, 1328779762,\n            3015228258, 2487205968, 213982794, 1927310263, 897606115,\n        ],\n        &[\n            3140142351, 3638334268, 927590030, 3257445174, 190628332, 423978494, 2125526010,\n            2335881748, 2011775260,\n        ],\n    );\n    // - q_len_mod_d_len == 2\n    test(\n        &[\n            3451729766, 1173985848, 93029266, 2489920009, 3973680219, 780152687, 1953113811,\n            856318718, 3314090115, 2569865885, 10849561, 743853677, 1946859719, 3063924404,\n            3352045106, 101532091, 429420318, 3158186124, 1342100634, 1680882573, 4042659776,\n            565667221, 989688746, 4541446, 834463803, 3523014310, 3432977627, 1818084880,\n            3544409611, 1926948225, 3663387900, 1035293697, 285923430, 3096314023, 664014848,\n            2054069437, 3124990832, 115905130, 1379323203, 2244054884, 2012040660, 1620087465,\n            1907788850, 132467852, 3020885577, 238576412, 567018667, 3426013542, 3145012002,\n            2070201540, 1421424259, 2074360440, 810615969, 153078550, 825376847, 2436604908,\n            1365021492, 288298963, 3753461462, 4215347696, 514661745, 3484458912, 4247537127,\n            1579462876, 3865189996, 1018915575, 2974009562, 3501816358, 2821759336, 2722697353,\n            517866351, 632193686, 1959130106, 2570573609, 3726681184, 1695074321, 1803440017,\n            268435105, 2059636298, 1870796488, 3616705235, 779907146, 3840642834, 3690603635,\n            889240128, 4220497978, 1506894274, 3744062951, 3031958651, 4062058444, 2309758423,\n            1411665710, 1638698058, 1784343146, 373693019, 3239595939, 1656022725, 1985062241,\n            2188775097, 395478226, 2732514978, 2804731752, 4294707867, 2796289890, 4286815139,\n            2694259304, 3400027223, 2866208426, 712658287, 3005677674, 3799280383, 333964254,\n            426632823, 1071506508, 424615774, 1216913008, 1528084851, 2440789637, 8647650,\n            1482353199, 1079815951, 1741478231, 335212928, 3230225069, 812456049, 1107265661,\n            309740350, 39813940, 1038050523, 3708554333, 2276389162, 3145208114, 286364489,\n            2078653938, 2343246544, 761958231, 2400118006, 2820784413, 91083352, 868359282,\n            2976918690, 1899156995, 2927253740, 2971404198, 955553520, 2163090892, 1779162381,\n            3706789234, 1427323973, 2892945053, 3765307938, 1888304940, 4281185143, 4063224403,\n            3895821018, 292451283, 1315405597, 1278053061, 2659048964, 1651475603, 2464063324,\n            2470117886, 885060568, 2223396118, 983203622, 2153273837, 909540554, 11662729,\n            1290088356, 3558268851, 2470462290, 3816443571, 1219777270, 1663771088, 2059674235,\n            3741754207, 918293007, 1170814255, 2592844500, 34078497, 868179007, 2916133370,\n            224466504, 1457353443, 743181292, 2045016399, 4268051489, 2582113750, 108054210,\n            1045580699, 1021681246, 4287699909, 2442965928, 2358040249, 2188665290, 2493816549,\n            1868457202, 1538714165, 3141445884, 1886427078, 2413842865, 3754082182, 1242353411,\n            837326189, 1891378866, 2004934119, 2718308820, 1293740965, 3706050263, 660923758,\n            4037329521, 1659464686, 3767070633, 2733667846, 1303579884, 720201259, 4178102594,\n            1521257108, 3676354960, 2861869547, 1694835235, 1663377877, 1033893232, 1788049008,\n            2131980496, 1380320795, 1706971693, 1547085187, 4249747381, 4022331904, 3773862935,\n            186851005, 1122661765, 2869769810, 714482846, 122240297, 1990969517, 1505355345,\n            1418846887, 2157766299, 3944099174, 752193837, 2717991695, 3106584127, 2176113460,\n            2424010054, 2202537322, 735567917, 2635174646, 57167007, 1501943516, 3981020168,\n            2264071537, 1811387936, 3230232665, 2056500724, 2470649052, 298208196, 361093257,\n            837772742,\n        ],\n        &[\n            3759203346, 4116788486, 472182301, 1657732406, 1379670583, 1302865697, 694415200,\n            281678172, 1654699562, 3014506006, 1741431230, 3860463155, 1145719988, 3566676616,\n            2320845102, 2321995000, 536415919, 2387437419, 3567575351, 89009414, 1112333426,\n            3147195251, 3149954561, 1503279897, 3064049622, 172526224, 3226367243, 4252316042,\n            2985921401, 3319920602, 2971463135, 662010514, 2716903751, 3114900209, 4294888231,\n            2302528059, 2985636330, 4227410510, 523042380, 1128527265, 2237860860, 2902190407,\n            2028066064, 43980114, 85965472, 1423570354, 370469915, 2799642260, 678694776,\n            4007712353, 1236341524, 2105667795, 1513858354, 3031596159, 3550734930, 4152331215,\n            778814882, 736616127, 1334786757, 193672910, 4005017476, 49451649, 274162308,\n            193472860, 3849716547, 1147344616, 3779102036, 636364760, 49841072, 4203872775,\n            2917594088, 2516158563, 1718950767, 2409600701, 4112139783, 968713133, 2367692503,\n            1383637739, 1447827357, 70112330, 1597216524, 1036612170, 47442040, 3535655506,\n            3217988958, 1524147015, 1542229372, 4278993048, 1177373055, 2455939135, 3977288741,\n            2323766505, 2631150922, 2494146789, 1766908673, 2014027584, 3170299898, 2200469205,\n            447095672, 3553741345, 1471247393, 1705231371, 3597764506, 2179927417, 2057038135,\n            2877684583, 4157842671, 3988568107, 136943619, 1758053719, 133243005, 1316787143,\n            3912460869, 3007503154, 673776671, 2300353234, 2544200665, 1154464703, 2377559298,\n            2085288775, 570803259, 1718587627, 1887771341, 2141823671, 812587685, 473768462,\n            3537328856, 2051785610, 1867482529, 386483431, 2102139021, 3579998391, 1082229057,\n            4197498026, 2004997074,\n        ],\n        &[3960768807, 1512612890, 3846503597, 4289005374, 3202073567, 4260281911, 4219386150],\n        false,\n        &[\n            3383011450, 2938966556, 422368941, 3441497106, 3409423652, 2305567488, 3562827580,\n            1338876308, 1099736044, 1201047259, 1743369967, 1491174234, 287230448, 3116597437,\n            1643175661, 4211676401, 601814058, 2723977393, 3228175296, 3419496235, 2059811269,\n            2947984775, 469809020, 251557204, 3013739023, 3166260707, 517974662, 920653259,\n            3867055574, 34801513, 4073639353, 766741992, 3966323891, 2226406520, 2341832923,\n            2682492751, 1942828791, 1732324839, 3967931993, 929680784, 1485027211, 2843893078,\n            430780969, 4066926931, 3159632662, 3397052086, 2311817261, 2992832593, 1564064832,\n            3020792541, 1056579269, 3627023013, 1422659846, 3325045886, 345931608, 1290807491,\n            3973995577, 3750219800, 350963107, 4053409628, 4058696363, 3668673317, 1418277077,\n            2159286564, 1868951430, 1399034844, 2585316317, 3592102683, 4163508856, 4075983119,\n            78320926, 2811875443, 4059965405, 1357445571, 2986007740, 326981837, 3415489538,\n            2531041805, 234199714, 3488607804, 1688036115, 744596707, 3014071644, 2766006369,\n            2628073818, 654781813, 4265430858, 4287622569, 2665792473, 4154810693, 2848091329,\n            755306763, 1245738903, 3190845925, 604185632, 294919488, 4045732560, 3602930508,\n            1226696054, 2425992356, 2138768869, 1417531642, 3016312849, 1435667556, 3658864646,\n            277170454, 1681853564, 2140619166, 76500316, 3095347477, 473108630, 4089067082,\n            1142664387, 709297371, 1129824116, 1641660886, 4174467937, 869296342, 332188854,\n            3873253978, 2646933540, 331422365, 2123872788, 1908091634, 1952247202, 3839276275,\n            3725920254, 2040912245, 1038050523, 3708554333, 2276389162, 3145208114, 286364489,\n            2078653938, 2343246544, 761958231, 2400118006, 2820784413, 91083352, 868359282,\n            2976918690, 1899156995, 2927253740, 2971404198, 955553520, 2163090892, 1779162381,\n            3706789234, 1427323973, 2892945053, 3765307938, 1888304940, 4281185143, 4063224403,\n            3895821018, 292451283, 1315405597, 1278053061, 2659048964, 1651475603, 2464063324,\n            2470117886, 885060568, 2223396118, 983203622, 2153273837, 909540554, 11662729,\n            1290088356, 3558268851, 2470462290, 3816443571, 1219777270, 1663771088, 2059674235,\n            3741754207, 918293007, 1170814255, 2592844500, 34078497, 868179007, 2916133370,\n            224466504, 1457353443, 743181292, 2045016399, 4268051489, 2582113750, 108054210,\n            1045580699, 1021681246, 4287699909, 2442965928, 2358040249, 2188665290, 2493816549,\n            1868457202, 1538714165, 3141445884, 1886427078, 2413842865, 3754082182, 1242353411,\n            837326189, 1891378866, 2004934119, 2718308820, 1293740965, 3706050263, 660923758,\n            4037329521, 1659464686, 3767070633, 2733667846, 1303579884, 720201259, 4178102594,\n            1521257108, 3676354960, 2861869547, 1694835235, 1663377877, 1033893232, 1788049008,\n            2131980496, 1380320795, 1706971693, 1547085187, 4249747381, 4022331904, 3773862935,\n            186851005, 1122661765, 2869769810, 714482846, 122240297, 1990969517, 1505355345,\n            1418846887, 2157766299, 3944099174, 752193837, 2717991695, 3106584127, 2176113460,\n            2424010054, 2202537322, 735567917, 2635174646, 57167007, 1501943516, 3981020168,\n            2264071537, 1811387936, 3230232665, 2056500724, 2470649052, 298208196, 361093257,\n            837772742,\n        ],\n        &[1749675900, 83311145, 2319870768, 2301367900, 1271820700, 747192890, 2232034578],\n    );\n    // - highest_q first time\n    test(\n        &[\n            1444823481, 1895962470, 1145820971, 951685031, 1619286897, 645659681, 3225126137,\n            1237595037, 528204561, 3332610202, 2935828481, 3511627759, 3794280700, 504366468,\n            2867551534, 432130908, 1682537913, 2112976328, 291513836, 2849031909, 3326433036,\n            1925364297, 3779561553, 487877982, 435659240, 1540143453, 3711236017, 1440132082,\n            825660149, 1624471959, 1941539144,\n        ],\n        &[\n            110690520, 2114031203, 436730283, 2624140005, 3364550071, 806172129, 2495686202,\n            3508099340, 1915440069, 3196245075, 3757278096, 786923263, 1820433641, 3283619351,\n            2326488762, 119217121, 3545365539, 3063896557, 1866040341, 3325517573, 713948948,\n            2863092530, 2356199798, 3131342786, 4122497749, 3637172320, 2586791774, 2794104974,\n            1738360752, 1591954820, 2633103962, 398797289, 30804220, 2682142316, 1858898375,\n            2406882215, 999588447, 645011646, 3469603876, 3657151690, 2477958807, 286833025,\n            1802487901, 2709688493, 2318425877, 3516543869,\n        ],\n        &[\n            3866576925, 1873138890, 1768109056, 2705255084, 4241776445, 658244374, 286815054,\n            153522406, 2020517918, 87408861, 541283899, 2327698817, 696800449, 1357243166,\n            2373189783,\n        ],\n        true,\n        &[\n            4258888914, 1485342244, 864808754, 1855573169, 2779156179, 2884098865, 3015216190,\n            233158379, 2131022258, 2947161299, 1457166139, 936993560, 1814334647, 2085655570,\n            1964344103, 3265126561, 2194874867, 2958220463, 1400730387, 3516776467, 3089823491,\n            3793414649, 3469628691, 1982433652, 3254747018, 787956375, 1101033526, 351690326,\n            3218501609, 2653245227, 2069227013,\n        ],\n        &[\n            1748815118, 2402822363, 2091637344, 2074482742, 2316188658, 2370992052, 3607116276,\n            2077769165, 1723590682, 2807481888, 338472032, 1807369086, 4009280963, 3941733223,\n            1094544382,\n        ],\n    );\n    // - carry\n    test(\n        &[0; 7],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        &[0, 0, 0, 1, 0, 0x80000000],\n        false,\n        &[7, 0, 0, 0xfffffffc, u32::MAX, u32::MAX, 1],\n        &[0, 0, 0, 0xfffffff9, u32::MAX, 0x7fffffff],\n    );\n    // - highest_q in limbs_div_mod_divide_and_conquer_helper\n    test(\n        &[\n            2516900350, 3628420684, 45459239, 1513614219, 989392388, 453507217, 1512254264,\n            2426221826, 1233076550, 244898124, 2764583004, 3329101881, 1699874673, 3208045667,\n            2210327365, 948719692, 29636434, 309163724, 626642377, 3476255186, 2213282765,\n            3561515942, 4189534597, 950518908, 139348404, 1259661856, 694161725, 2634491186,\n            3727710582, 788362676, 3045474119, 4091304988, 2805201294, 3987583308, 1169494314,\n            1793738933, 1926962859, 143323906, 3767356737, 2736821279, 3155234958, 369913573,\n            2104538395, 1964464892, 120182245, 1607533355, 3512159772, 428709975, 3273911427,\n            1151542509, 2860816013, 1136173381, 662332459, 3578077057, 3243603823, 818341966,\n            1912641848, 3483224197, 605429894, 746864868, 3712846888, 2818736253, 462940792,\n            3732576280, 1660947800, 1011233610, 843846147, 2308498613, 1878649446, 1442264468,\n            2962205673, 2832862233, 1244894861, 1156622958, 1582973750, 1574948490, 3846938629,\n            935089728, 1705244040, 4043433438, 3114254174, 1062986960, 3905677705, 1930766407,\n            1354562200, 955778452, 2932639939, 249007379, 3763599833, 32702674, 3759419411,\n            4281057196, 1688108074, 3861261668, 444663411, 2875533494, 971084229, 1671724356,\n            681694042, 1336342690, 3989885039, 3351736702, 3656186109, 2518436399, 3272921467,\n            235621572, 641659042, 2119882595, 1983842751, 1488017726, 3187465143, 2506358055,\n            3348535321, 999852594, 4293611527, 1073384603, 250481194, 4148825621, 3839501948,\n            3818994640, 1414056232, 2701465891, 499495991, 1361504858, 1308748876, 1650859371,\n            3722040369, 223548436, 2431095012, 3829963049, 367284736, 451104830, 3192609374,\n            959276880, 2266256342, 4176815348, 3580491737, 674113379, 4084740134, 883805748,\n            892822580, 2297912891, 2348080766, 3777075710, 2743249275, 1929349295, 2464988855,\n            1327032420, 1398791640, 2085211945, 889984414, 883598216, 1429348413, 154972877,\n            3622910749, 1670306325, 2187005411, 651154286, 2688016708, 1041316505, 2776658464,\n            161390395, 3846865057, 3267383835, 1010302540, 3607316170, 1418199870, 3954492322,\n            922710287, 1323651551, 2431904946, 3054195005, 902509698, 1670133092, 1092971517,\n            1075109776,\n        ],\n        &[\n            1426636939, 2291732338, 3067548371, 1958595483, 4265832187, 1189668824, 2839754982,\n            3301139255, 530760593, 3029188645, 1298922175, 1055363550, 2070850046, 992858009,\n            1206997984, 1510007185, 2204463849, 2600547912, 3402640587, 372285673, 54684613,\n            211924658, 2690037178, 1114469505, 374316665, 319939537, 1363579227, 25099128,\n            2808696886, 2318162131, 1283473588, 4173665536, 1302236115, 2981103428, 364658024,\n            3500679214, 73401477, 2399140443, 2401409782, 974668784, 3260945138, 700031094,\n            619920306, 2267288646, 225106679, 2520705554, 760523499, 2971006600, 2155228491,\n            967349835, 2899641188, 2567983244, 1086821788, 208644014, 2327565301, 3873773388,\n            1254243651, 3371628757, 1486945462, 3153661571, 3596439034, 3448680976, 2884772533,\n            2113693162, 3571562346, 3271064301, 2352298427, 2624271304, 2147301202, 1628031526,\n            2268489536, 2460058239, 3824853526, 1114448457, 1711950597, 2805133745, 3886047152,\n            1482425544, 3015333985, 1726209429, 1945238011, 2536476005, 1974758758, 3373425305,\n            2797746190, 1649833243, 2549697741, 2772403629, 1276934258, 1197267921, 480328120,\n            3145095762, 647795990, 605209910, 1896440782, 2021024361, 4280085434, 384535302,\n            228210377, 1342562609, 550195641, 304643910, 803682708, 2640613597, 214734489,\n            3610647775, 3787633026, 3169459037, 2718345417, 1486978425, 4213419405, 2452166506,\n            2369416903, 2146131022, 3632701374, 857903632, 2077812289, 2633196639, 1727541399,\n            1445819648, 1663740433, 2573746586, 150961985, 2843003920, 2121435332, 503235641,\n            2162411412, 2641993335, 2306838455, 3013627797, 187911601, 2832638744, 3245525711,\n            4114681913, 4248626985, 892023341, 4180070411, 462293938, 2339665566, 886499165,\n            2680618581, 1275413281, 1653569893, 3506841220, 805196234, 2798162194, 2468871331,\n            3396930973, 2515921922, 897743120, 2034157178, 2373161268, 3355723218, 3914014661,\n            994426990, 2992401161, 2581503631, 697892172, 82419160, 2053001658, 3320533046,\n            3791389127, 1839288008, 270908689, 1413534997, 429338594, 997502210, 3103236226,\n            2401510054, 2663896427, 3727426794, 2724686279, 3944143754,\n        ],\n        &[\n            3845376373, 2532376922, 273377135, 3677509657, 2349096840, 865593650, 3913447585,\n            3605798835, 2383627001, 256434907, 1598943794, 582857664, 2095029213, 493203050,\n            4072709797, 2373943493, 3435129133, 3493851471, 1582101091, 2328189763, 853133742,\n            2400321806, 3544763029, 3255311766, 2487877428, 2345846021, 3540974504, 1867377852,\n            2499885368, 3386759756, 3964579463, 3290899719, 2797957335, 2863338106, 3380325251,\n            1361967176, 2820693326, 1270065483, 2316076985, 20080038, 2796142674, 1493193006,\n            3582143536, 1315905237, 884491638, 2352205614, 3522766470, 1928358187, 1698951621,\n            4079830723, 3210021170, 3465329392, 3919799352, 4222905913, 255999498, 707431500,\n            4259794201, 604859264, 3884712299, 2790776367, 3466495862, 1352500875, 1421557254,\n            3449668508, 339288181, 2600471637, 2364459698, 1593691125, 3908068568, 1590428078,\n            3967743945, 361284513, 1947639764, 2146594709, 698658216, 2934691142, 3852641925,\n            2677524346, 3136105113, 3755616420, 393422782, 4055467971, 836734774, 1342622278,\n            1842869702, 3646198604, 3250586544, 1155965487, 3143510276, 264136749, 764849704,\n            2833843864, 3628999351, 1603529516, 3414178524, 2241268229, 1653241000, 3792840587,\n        ],\n        true,\n        &[\n            3369583400, 1798959332, 2489167563, 2461009697, 1361288842, 1654052513, 3133509548,\n            2052390470, 2454818186, 91621325, 3151880750, 1899967999, 2316081396, 3597413959,\n            4267146135, 1546768645, 474411717, 1597284556, 2105139892, 4124114432, 3190771802,\n            3793203026, 3276311936, 2880323996, 1248675214, 83340366, 3739848429, 2035483515,\n            2728839161, 2427538604, 1330706703, 3030714454, 1781130352, 2866672350, 1381956557,\n            989054476, 1246309158, 3420842543, 2855783980, 2430281813, 846960251, 2085811611,\n            1851093062, 1216231642, 2046747009, 771854370, 301562071, 2564992655, 13210966,\n            3346332460, 602343193, 4038323773, 3846528060, 3292787443, 2312570709, 772642248,\n            3361839528, 2269167700, 4111218264, 1417638867, 3914782282, 3574321715, 2749659194,\n            3611340496, 3547422042, 662840159, 4181609060, 2617950548, 3566455037, 4058070983,\n            3770037022, 2124212778, 1485396640, 423608280, 171333896, 1574948490, 3846938629,\n            935089728, 1705244040, 4043433438, 3114254174, 1062986960, 3905677705, 1930766407,\n            1354562200, 955778452, 2932639939, 249007379, 3763599833, 32702674, 3759419411,\n            4281057196, 1688108074, 3861261668, 444663411, 2875533494, 971084229, 1671724356,\n            681694042, 1336342690, 3989885039, 3351736702, 3656186109, 2518436399, 3272921467,\n            235621572, 641659042, 2119882595, 1983842751, 1488017726, 3187465143, 2506358055,\n            3348535321, 999852594, 4293611527, 1073384603, 250481194, 4148825621, 3839501948,\n            3818994640, 1414056232, 2701465891, 499495991, 1361504858, 1308748876, 1650859371,\n            3722040369, 223548436, 2431095012, 3829963049, 367284736, 451104830, 3192609374,\n            959276880, 2266256342, 4176815348, 3580491737, 674113379, 4084740134, 883805748,\n            892822580, 2297912891, 2348080766, 3777075710, 2743249275, 1929349295, 2464988855,\n            1327032420, 1398791640, 2085211945, 889984414, 883598216, 1429348413, 154972877,\n            3622910749, 1670306325, 2187005411, 651154286, 2688016708, 1041316505, 2776658464,\n            161390395, 3846865057, 3267383835, 1010302540, 3607316170, 1418199870, 3954492322,\n            922710287, 1323651551, 2431904946, 3054195005, 902509698, 1670133092, 1092971517,\n            1075109776,\n        ],\n        &[\n            2033854275, 3346500754, 1026391195, 2931755468, 4132970223, 507488150, 3787819697,\n            4267307150, 2229023955, 3535124792, 2115982537, 3261552465, 1403786253, 4168838966,\n            2905077003, 3343366362, 4058434477, 3051762274, 2754465216, 2139644668, 2121257326,\n            147231635, 1411313351, 1942773925, 1518792733, 4026871852, 1608765600, 2674641821,\n            3388658059, 4045496133, 4161170911, 1328400056, 1288717066, 741487928, 2130937044,\n            3073981280, 486422437, 2174741216, 4004413829, 1284627600, 1179437164, 1177246499,\n            2634583310, 2950709339, 3500520165, 502702338, 3556716680, 3168781392, 201139498,\n            1773610178, 1336109110, 75169920, 4261358748, 3946913462, 1177416531, 1904421971,\n            529501654, 760059661, 2718436151, 1695275660, 769729199, 1160292778, 1476806846,\n            913674448, 1863234151, 2549859956, 2693241338, 2672780028, 1641057282, 3939169714,\n            1414934690, 318354912, 300864018, 400872379, 1081977009, 3047385148, 3103660917,\n            175274494, 1331622900, 1558233166, 3851938640, 205628404, 992837552, 615234521,\n            3588694980, 848421132, 513268312, 468730797, 1030322804, 1991013271, 1629772980,\n            3351179781, 2259742484, 957712992, 1217297297, 2285959262, 947300257, 3115413281,\n        ],\n    );\n    // - q_lo && limbs_sub_same_length_in_place_left(&mut ns_lo[lo..], ds_lo)\n    test(\n        &[0; 91],\n        &[\n            0,\n            0,\n            0,\n            2,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0xfffff000,\n            4294959103,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0x1000000,\n            0,\n            0,\n            0,\n            0xfff00000,\n            0xfffff,\n            0,\n            0x1000000,\n            0,\n            u32::MAX - 1,\n            u32::MAX,\n            4294965247,\n            u32::MAX,\n            u32::MAX,\n            4294967279,\n            u32::MAX,\n            u32::MAX,\n            0x7fffff,\n            1,\n            u32::MAX,\n            4160782335,\n            4294443007,\n            532479,\n            0,\n            0,\n            0,\n            u32::MAX - 1,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4160749631,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            16383,\n            0,\n            4294709248,\n            u32::MAX,\n            u32::MAX,\n            2151677951,\n            16383,\n            4294950912,\n            u32::MAX,\n            u32::MAX,\n            0x7ffffff,\n            0,\n            0,\n            0xfffffff8,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0xfffffffd,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4294966783,\n            16383,\n            8192,\n            0x4000,\n            0,\n            0x4000000,\n            4294966784,\n            511,\n            0,\n            4227858432,\n            4290772991,\n            u32::MAX,\n            u32::MAX,\n            4265607135,\n            4290772991,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            7,\n            0,\n            32,\n            0,\n            16,\n            0,\n            u32::MAX - 1,\n            0x10001,\n            0,\n            4292870144,\n            4294950911,\n            4294836223,\n            u32::MAX,\n            4026531839,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0x1000003,\n            0xff000000,\n            u32::MAX,\n            u32::MAX,\n            0xfffffff,\n            32,\n            0,\n            0,\n            0,\n            0,\n            4294959104,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4294443007,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            15,\n        ],\n        &[\n            0,\n            0,\n            0,\n            u32::MAX - 1,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4095,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0xff000000,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0xfffff,\n            0xfff00000,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            1,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        false,\n        &[\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4095,\n            0,\n            0,\n            0x80000000,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0x3ffffff,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4292870144,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            3,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4294959104,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            15,\n        ],\n        &[0; 47],\n    );\n    test(\n        &[10; 151],\n        &[\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            131071,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4227858432,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4095,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        &[\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        false,\n        &[\n            0,\n            1,\n            4096,\n            0,\n            4227825664,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            131071,\n            0,\n            0,\n            1,\n            4096,\n            0,\n            4227825664,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            4096,\n            0,\n            4227825664,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            4096,\n            0,\n            4227825664,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            4096,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            4096,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            4096,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            4096,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0,\n            0,\n            4294934528,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        &[u32::MAX, 0, 4096, 0, 4227825664, u32::MAX, u32::MAX, u32::MAX, 131071, 0],\n    );\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_divide_and_conquer_fail_1() {\n    let ds = &[3, 4, 5, 6, 0x80000000];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_divide_and_conquer(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_divide_and_conquer_fail_2() {\n    let ds = &[3, 4, 5, 6, 7, 0x80000000];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_divide_and_conquer(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8], ds, inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_divide_and_conquer_fail_3() {\n    let ds = &[3, 4, 5, 6, 7, 0x80000000];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_divide_and_conquer(&mut [10, 10], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_divide_and_conquer_fail_4() {\n    let ds = &[3, 4, 5, 6, 7, 8];\n    let inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_div_mod_divide_and_conquer(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, inv);\n}\n\nfn verify_limbs_invert_approx(\n    is_in: &[Limb],\n    ds: &[Limb],\n    result_definitely_exact: bool,\n    is_out: &[Limb],\n) {\n    let d = Natural::from_limbs_asc(ds);\n    let n = ds.len();\n    let bits = limb_to_bit_count(n);\n    let product = Natural::power_of_2(bits << 1);\n    // TODO compare to limbs_invert\n    let mut expected_i = (&product - Natural::ONE) / &d;\n    let offset = Natural::power_of_2(bits);\n    expected_i -= &offset;\n    let i = Natural::from_limbs_asc(&is_out[..n]);\n    let x = (&i + &offset) * &d;\n    let result_exact = i == expected_i;\n    if result_definitely_exact {\n        assert!(result_exact);\n    }\n    let y = if result_exact {\n        assert_eq!(i, expected_i);\n        (i + offset + Natural::ONE) * d\n    } else {\n        assert_eq!(&i + Natural::ONE, expected_i);\n        (i + offset + Natural::TWO) * d\n    };\n    assert!(x < product);\n    assert!(product <= y);\n    assert_eq!(&is_in[n..], &is_out[n..]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_invert_basecase_approx() {\n    let test = |is_in: &[Limb], ds: &[Limb], result_definitely_exact, is_out: &[Limb]| {\n        let mut is = is_in.to_vec();\n        let mut scratch = vec![0; is_in.len() << 1];\n        assert_eq!(\n            limbs_invert_basecase_approx(&mut is, ds, &mut scratch),\n            result_definitely_exact\n        );\n        assert_eq!(is, is_out);\n        verify_limbs_invert_approx(is_in, ds, result_definitely_exact, &is);\n    };\n    // - d_len == 1\n    test(&[10; 3], &[0x80000000], true, &[u32::MAX, 10, 10]);\n    // - d_len == 2\n    test(&[10; 3], &[0, 0x80000000], true, &[u32::MAX, u32::MAX, 10]);\n    // - d_len > 2\n    // - !MAYBE_DCP1_DIVAPPR || d_len < DC_DIVAPPR_Q_THRESHOLD\n    test(\n        &[10; 3],\n        &[1, 2, 0x80000000],\n        false,\n        &[0xfffffffb, 0xfffffff7, u32::MAX],\n    );\n    // - !(!MAYBE_DCP1_DIVAPPR || d_len < DC_DIVAPPR_Q_THRESHOLD)\n    let mut ds = vec![123; 175];\n    ds.push(0x80000000);\n    test(\n        &[10; 176],\n        &ds,\n        false,\n        &[\n            2468656776,\n            458964117,\n            2715468315,\n            1790012879,\n            3522999749,\n            4214715874,\n            561506786,\n            3302400720,\n            534918344,\n            1263272887,\n            3075782921,\n            2067555491,\n            746647830,\n            518406956,\n            2268770356,\n            199166681,\n            585200343,\n            2568074090,\n            496918528,\n            707408551,\n            2864167181,\n            2697486675,\n            365965986,\n            566676423,\n            4243405542,\n            2529073250,\n            1738952834,\n            695156794,\n            4116132056,\n            240876219,\n            2603129425,\n            2192004736,\n            1342688443,\n            2964614325,\n            4249182840,\n            2414593720,\n            2593965601,\n            2916418334,\n            2637652497,\n            994042154,\n            3834346320,\n            2159029599,\n            988365118,\n            3644217481,\n            1407533479,\n            654358021,\n            2493606292,\n            4023096448,\n            1141066521,\n            983459780,\n            3892764635,\n            2438657556,\n            46466645,\n            374378413,\n            979049107,\n            3284790741,\n            3990074329,\n            928205488,\n            3007997859,\n            3046358137,\n            2915845116,\n            628001258,\n            3465083935,\n            4236663285,\n            474535350,\n            2027435145,\n            3567992797,\n            4283770508,\n            2324985479,\n            376140225,\n            777742614,\n            1991983228,\n            354120270,\n            1512293869,\n            1872844204,\n            2864777182,\n            1662657829,\n            3120313116,\n            1367744326,\n            3903740266,\n            1092780358,\n            4056570813,\n            2945196325,\n            187533600,\n            931587688,\n            2394937291,\n            1507441207,\n            345576625,\n            1601524905,\n            476504330,\n            1269949561,\n            3390313417,\n            881580197,\n            1002436463,\n            2217811800,\n            685849999,\n            185823896,\n            1272490189,\n            3967659522,\n            3205992619,\n            2860215323,\n            3472978514,\n            1224636072,\n            305126296,\n            1759643037,\n            3515215216,\n            4075133951,\n            1224421257,\n            774076486,\n            3594767960,\n            1443121990,\n            2854565002,\n            2031006704,\n            3471036315,\n            2258092726,\n            3015513815,\n            1591867662,\n            2298829418,\n            2586837892,\n            4173923545,\n            3288784297,\n            1655027454,\n            674268161,\n            118227690,\n            4135574019,\n            3420877922,\n            3419101194,\n            2933141174,\n            801148518,\n            2138817011,\n            4265486539,\n            2610068278,\n            3432736337,\n            4263393041,\n            3163494866,\n            1217674034,\n            638081175,\n            1411840480,\n            38063796,\n            989590891,\n            457807629,\n            1412034828,\n            1103809621,\n            2233526783,\n            1436248111,\n            1917272861,\n            1485988800,\n            1517198661,\n            126869,\n            2315908856,\n            3274287261,\n            3670331343,\n            473008784,\n            1471036169,\n            231026838,\n            3870905408,\n            2284494418,\n            3904415704,\n            3550806025,\n            1919076393,\n            1355185851,\n            1830925510,\n            1032027683,\n            3523514211,\n            219638593,\n            1697572843,\n            1874144044,\n            3230672849,\n            2851366658,\n            4206129317,\n            4265556027,\n            241571,\n            120540,\n            4294966804,\n            4294966803,\n            u32::MAX,\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_basecase_approx_fail_1() {\n    limbs_invert_basecase_approx(&mut [10; 3], &[1], &mut [10, 10]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_basecase_approx_fail_2() {\n    limbs_invert_basecase_approx(&mut [10; 3], &[1, 0x80000000], &mut [10; 3]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_basecase_approx_fail_3() {\n    limbs_invert_basecase_approx(&mut [10; 3], &[], &mut [10; 3]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_basecase_approx_fail_4() {\n    limbs_invert_basecase_approx(&mut [10; 1], &[1, 0x80000000], &mut [10; 4]);\n}\n\n#[test]\nfn test_limbs_invert_newton_approx() {\n    let test = |is_in: &[Limb], ds: &[Limb], result_definitely_exact: bool, is_out: &[Limb]| {\n        let mut is = is_in.to_vec();\n        let mut scratch = vec![0; is_in.len() << 1];\n        assert_eq!(\n            limbs_invert_newton_approx(&mut is, ds, &mut scratch),\n            result_definitely_exact\n        );\n        assert_eq!(is, is_out);\n        verify_limbs_invert_approx(is_in, ds, result_definitely_exact, is_out);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - d_len < INV_MULMOD_BNM1_THRESHOLD\n        // - condition\n        // - scratch[d_len] >= 2\n        // - scratch_hi[0] == Limb::MAX\n        test(\n            &[10; 6],\n            &[1, 2, 3, 4, 0x80000000],\n            true,\n            &[187, 120, 0xfffffff4, 4294967279, u32::MAX, 10],\n        );\n        // - scratch_hi[0] != Limb::MAX\n        test(\n            &[10; 5],\n            &[0, 0, 0, 0, 0x80000000],\n            false,\n            &[u32::MAX, u32::MAX, u32::MAX, u32::MAX, u32::MAX],\n        );\n        // - scratch[d_len] < 2\n        // - carry != 2 || limbs_sub_same_length_in_place_left(scratch_lo, ds_hi)\n        // - limbs_cmp_same_length(scratch_lo, ds_hi_lo) == Greater\n        test(\n            &[10; 14],\n            &[\n                299802232, 2821120521, 3181086016, 891739326, 736497831, 3980709285, 3375818113,\n                818447231, 2663163337, 699303808, 3766306416, 1006926545, 2441137698, 2544067966,\n            ],\n            true,\n            &[\n                229224643, 1806820748, 815670549, 204407994, 3185958944, 3971027994, 2329129898,\n                1099516923, 4253768807, 1256057898, 821933298, 3636132439, 2794702458, 2955917631,\n            ],\n        );\n        // - limbs_cmp_same_length(scratch_lo, ds_hi_lo) != Greater\n        test(\n            &[10; 17],\n            &[\n                1333179288, 1649693138, 1336899365, 4171117151, 3070030019, 3225196885, 4108439079,\n                3954646297, 638063024, 4277538414, 3277457249, 211212338, 1364200948, 4280413500,\n                4293399504, 2216765967, 2874951670,\n            ],\n            true,\n            &[\n                3443915210, 2295603218, 2419744057, 2759520395, 1944568016, 862757513, 374771378,\n                2859328789, 3506872242, 2421673342, 2468885898, 3005107568, 562470030, 1627801097,\n                2440421683, 35821881, 2121399373,\n            ],\n        );\n        // - carry == 2 && !limbs_sub_same_length_in_place_left(scratch_lo, ds_hi)\n        test(\n            &[10; 386],\n            &[\n                4139195837, 2812339247, 712806962, 1626328903, 2947517926, 2755997282, 2347019211,\n                3654990401, 2055029559, 2047178043, 738069620, 2149818033, 309630864, 294595925,\n                984043983, 951236822, 3743724193, 376648825, 1593339365, 227563185, 1874134978,\n                2807943566, 2192306383, 2417491485, 3316512293, 297138568, 2944100909, 2810082512,\n                665119620, 3864239577, 3520109855, 3002981822, 2546622683, 1756025151, 1423319454,\n                599853088, 460530389, 705981334, 552539618, 3941502084, 3349709634, 3660369568,\n                4191516275, 1528800983, 2348924921, 536392452, 3446783547, 4055134021, 3504562733,\n                2929958411, 901778770, 4237963198, 259318031, 1332469925, 397810510, 2137922926,\n                2519380736, 2577896406, 1043505431, 785332849, 2822966324, 4191916739, 3770327065,\n                3847462252, 3402720200, 251432210, 1578533442, 1712937183, 923979930, 280220794,\n                3293380821, 58676675, 1844830895, 1423620414, 4194849677, 2680873227, 2987401408,\n                3054997563, 3873823475, 3253516897, 3108585700, 1036642260, 3701470592, 3361442680,\n                3546225277, 2218739223, 564155191, 702047302, 1856675496, 4272520963, 3616818204,\n                3227622340, 7791852, 1610528696, 3522462693, 2296449042, 1081049555, 3405408505,\n                3147562914, 1940148078, 1129402371, 1876701550, 836206182, 1223716477, 1698320293,\n                2529561505, 564212319, 2789696380, 443251042, 2823939041, 3786276490, 4195951187,\n                3667489226, 971532893, 2743600172, 3037330715, 4224128528, 2995464410, 3050205287,\n                3794514069, 3133644716, 856691943, 4201452292, 348501153, 1203620471, 1838400383,\n                3827770633, 2962797354, 3177076525, 845486999, 3837777196, 20436524, 4276721373,\n                1755330325, 2585578623, 1854317259, 959489662, 1160837498, 3571761559, 3163627715,\n                2901883906, 2062957005, 3360581687, 1107261099, 228566566, 2557814383, 3508583772,\n                3839775630, 1987907537, 3937116357, 4075557942, 1464892113, 135879982, 601922490,\n                4155196105, 2081104107, 839459275, 557861287, 880140789, 1056812723, 2199617957,\n                3317528481, 2087992298, 958637907, 921274851, 3154866102, 264017075, 877303542,\n                3865752723, 3807776374, 1302371900, 1869052069, 811485110, 140041357, 2676834656,\n                4125536053, 171179365, 3771700498, 3425440532, 3227264309, 1543154128, 2694625489,\n                3220336965, 2749044579, 709181621, 2938548554, 4119990906, 2253937157, 2107618938,\n                1207222516, 1683811680, 4221953072, 2171761912, 2361269244, 1218314377, 987928344,\n                960497416, 4031250239, 1639847512, 3905432218, 2367546610, 57458558, 3770185025,\n                3589850319, 287603777, 924162991, 4243441755, 28593432, 2234223762, 1214198168,\n                2213332087, 3246012885, 529821154, 1596080010, 2256716924, 2362237023, 1879143372,\n                799154828, 2678703189, 1929808701, 4081552632, 3350711293, 1794596388, 1913506378,\n                2737040879, 198149267, 1887090525, 2083508083, 4031867527, 836150409, 1487419119,\n                3649006840, 1344342026, 3117129602, 3286034010, 531726714, 3818493634, 2688829452,\n                3432248157, 3806552324, 3379192093, 398164062, 4196498468, 1734011552, 3599517541,\n                241509852, 3872917131, 1538621009, 2828040157, 1983017593, 1489296752, 1386698908,\n                156979201, 1922448841, 4076360550, 1664424704, 1927752777, 123651960, 3939944267,\n                3005604, 3709073637, 2967489805, 2852961368, 1801607632, 3956884953, 454504210,\n                748001653, 3508419959, 2390033624, 4237480745, 1883803406, 59501653, 488021688,\n                3997215744, 144013454, 4156138229, 3207190384, 167672785, 256377941, 3785838836,\n                3977721847, 3392462430, 4056881256, 3422674218, 1637604924, 3061791480, 3075439268,\n                2345796777, 3039548956, 3679830975, 4100519548, 4223820878, 1246251349, 2789094988,\n                1261279528, 4128764694, 1552408181, 166251596, 2264884840, 806042015, 1273344257,\n                1858140664, 1995440463, 3254742107, 175101411, 1875902902, 4071806551, 786127358,\n                2299796383, 1344001864, 4174715279, 1521370160, 2176319001, 1345743938, 2456867417,\n                3171076699, 3897764891, 2772973782, 514961974, 3464245463, 1978612418, 292121862,\n                3636736076, 2272659407, 2274331899, 2772880215, 1604910771, 2954725178, 123316598,\n                545555686, 1505282294, 4191700344, 1093499729, 3833383026, 694388959, 2893900278,\n                3764927679, 4192192353, 3782397072, 133448517, 509945324, 2954071581, 722765544,\n                1180635727, 285984716, 2936179119, 967121404, 2905768257, 491288904, 600135579,\n                3439065503, 14264794, 483956926, 686531157, 3363035798, 3905972150, 150791166,\n                2723784356, 3266626182, 1371155093, 250336761, 679758430, 2220669843, 1371404999,\n                4205993408, 537317422, 3612437196, 1870187644, 503652613, 899335706, 1295444931,\n                858056159, 3581382201, 2982334041, 600961969, 1040115528, 3630194218, 3183659540,\n                4266985633, 3006565428, 1121854128, 4106907361, 44957935, 1229739423, 2382159630,\n                2285266310,\n            ],\n            true,\n            &[\n                1760088770, 4080526177, 2608023608, 2694893566, 3004066830, 2214237510, 2072514982,\n                3451962427, 3485197532, 1515079746, 943350838, 4214976192, 2981850513, 1937549988,\n                1829233582, 632967491, 3914179126, 2456791403, 3628658525, 2007162807, 1521235463,\n                948161520, 3827351402, 2205307930, 1303273516, 2090403955, 3125120326, 2973550249,\n                2163659402, 170314532, 2876229226, 494968470, 3718668508, 3650935973, 107817707,\n                2532423658, 285835761, 2250301255, 139168257, 2806883602, 578805866, 3326219151,\n                1901602970, 2556068326, 2844199513, 2698479894, 3728787046, 3617123572, 2737802465,\n                2919596304, 2536928839, 2842472828, 1114232765, 175110451, 2394784754, 1073221182,\n                1632800088, 1157318295, 1717474331, 946089681, 3106197206, 615168037, 418892634,\n                501982827, 2986457953, 1893146468, 2870765383, 2995035310, 2573692899, 3477374183,\n                2071198427, 408851767, 3229401245, 2377739259, 1928791437, 578119252, 2254241267,\n                78652380, 2481343171, 2555454369, 243482381, 3700865683, 2995183706, 2488100778,\n                58054772, 3942346233, 2473745660, 1701522923, 493462489, 2470313146, 1819837247,\n                2330284930, 3142712167, 3950226677, 4007462473, 949452561, 172944267, 1691823870,\n                2219435104, 3533670123, 4033487402, 2444553587, 636683551, 47678947, 1065529762,\n                3263050320, 2092343545, 2519888675, 702264901, 4018827207, 3006140979, 818479576,\n                3732144508, 1702177720, 3844143349, 836374747, 1688156611, 1269107088, 1920184236,\n                3443692773, 2073861277, 891840490, 2064863720, 1253640243, 2497953103, 2358358733,\n                3466359679, 3365482312, 3043490905, 3493002877, 2370987911, 2125398795, 2298093147,\n                3168989499, 37076949, 1291478294, 1505564872, 3116600055, 2110018206, 4029514678,\n                1008993328, 2147039657, 1901430028, 2950027853, 2946649371, 4134547468, 3226580242,\n                67002805, 2061914186, 3435506795, 3305296188, 3118926502, 295938263, 3154848702,\n                1589297569, 1009644335, 1975002616, 494351062, 177792213, 892936667, 1985856724,\n                663011930, 2023064427, 3079345397, 2280115487, 4203733211, 3138908774, 3421884238,\n                3191420860, 764158096, 2603879287, 498589969, 4170367159, 2819475894, 1727077689,\n                1873104274, 915049813, 3805534647, 176482024, 403322181, 3368346834, 727193433,\n                900646796, 3136999543, 1613355909, 3820352029, 471439511, 3471432766, 2597114568,\n                2009837938, 2097632715, 389166167, 1520996840, 2344734085, 512633468, 3658635856,\n                3326549414, 541537802, 3175329594, 1115521890, 3735752302, 533040624, 56216564,\n                1874766932, 1607160247, 3369156252, 1450323938, 1142635331, 4207543509, 435950743,\n                481361367, 3824656441, 125520431, 3292911980, 1675469381, 2431218394, 511182588,\n                3479222912, 589490204, 3553506996, 3661709471, 2316618654, 3550373878, 637631474,\n                3286110763, 244959945, 2755104673, 808873559, 1203129909, 1782570471, 1686763662,\n                4191962546, 2412523467, 1421588889, 723752795, 1565383987, 1318771925, 2220007547,\n                735466750, 230658922, 2961374421, 3695325463, 332357800, 2802182630, 1730542835,\n                2333489502, 2835283919, 2570040420, 1616532567, 3720529315, 4255972038, 829762005,\n                3700718193, 548891081, 4072462181, 2065133636, 1848015799, 3443807950, 2405066408,\n                3915008762, 1771214599, 2430422722, 1128497450, 3442687835, 470675323, 555235400,\n                3286905630, 2352651205, 432555847, 1420447424, 4040437919, 338923254, 2725984822,\n                2023735825, 1460042409, 1908406675, 227654190, 1604523408, 3244243921, 133688164,\n                3064060274, 825400946, 2986602176, 515391607, 3051097076, 300579920, 315609812,\n                2442041976, 3222865686, 118218402, 64228258, 3425231024, 1070030503, 3353054629,\n                1626756792, 1818031100, 2401051982, 1526192477, 3602675682, 4033108418, 591128181,\n                3633475386, 3157206335, 4104216, 4025784094, 4266193286, 3001126208, 1337250415,\n                849416722, 3366284510, 2345597524, 2989746743, 2720174096, 1786442541, 3985055947,\n                4203001741, 3820341370, 471657766, 2355959089, 230906874, 1276534260, 2537678103,\n                811570777, 2584355518, 485370897, 387761024, 1152564004, 3275183056, 53471703,\n                3659550427, 2979266253, 2595802853, 826532396, 204030308, 4056457437, 3759821833,\n                554940888, 3898319353, 3448792241, 43692421, 3180294571, 3458984544, 3685975113,\n                2826822888, 1945528754, 1535708884, 3885432471, 3758699446, 1165404565, 2794772054,\n                3117403039, 1044526214, 2907540110, 633050460, 2831691446, 2669183055, 1559434402,\n                664522226, 458177657, 1420820322, 1119080846, 977395351, 1701334796, 3891507914,\n                3557298907, 1340368221, 4100667588, 2864910492, 1990253606, 3528312622, 322862997,\n                3522066321, 257961239, 4264277879, 2930887517, 1076405866, 1366357571, 2601454765,\n                1784972437, 1588243763, 991217823, 620712910, 2406746141, 2860518703, 3892074672,\n                3777065266,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - d_len >= INV_MULMOD_BNM1_THRESHOLD\n        // - !condition\n        test(\n            &[0; 892],\n            &[\n                996305544975114981,\n                12929066524383774152,\n                16956610067055251962,\n                13012122099231548957,\n                14395689158572846177,\n                7935429077563080059,\n                17542764935243101497,\n                18413828249925519615,\n                17271321257298840331,\n                406766324155888956,\n                14818331828215117974,\n                8187386216945380849,\n                16792638575276899182,\n                6540004189057298818,\n                465689003663102769,\n                11974785539062893556,\n                11523099967255714584,\n                14591636912283935445,\n                4871757987380755363,\n                9308130069290886865,\n                10612219179153523310,\n                5420071244571425562,\n                12724302122592532888,\n                5173545157589181140,\n                1429324130148847596,\n                18414282026575416657,\n                1721766939064217260,\n                185288146264311331,\n                8027581238524003859,\n                12629121378225318691,\n                5422022678890177669,\n                6300007666394297907,\n                13771277516427401556,\n                4461063943424152501,\n                5814271695863693557,\n                9833762282568603070,\n                5534898830643720899,\n                11414581203473717153,\n                13252208296859650317,\n                6070377927034194834,\n                468982118171070321,\n                15569817073538385644,\n                8515954578625472255,\n                17703147536676285546,\n                2713926565223832109,\n                16501613896332875878,\n                12360649233716580846,\n                6951122318765494287,\n                1255018572838364315,\n                5022530899188934293,\n                14471021290055621346,\n                3965972119993826976,\n                10914640319991729939,\n                4671893019190076511,\n                8132288757883741990,\n                7379730619550447967,\n                7082846353163966035,\n                7749284037330602929,\n                17090786448482076935,\n                3623093583024522445,\n                6775174256836032571,\n                5932859643874401763,\n                9263718069255818484,\n                11941172789559596258,\n                7505495305758940713,\n                8374557854631657796,\n                5030384219708396008,\n                3609081759463861677,\n                2444176790044307758,\n                12883357531875110193,\n                2545675590276006076,\n                1091049428613676247,\n                3001645527995991696,\n                9613284625002680960,\n                13486970893816936976,\n                11564610387350917328,\n                7838720830134816136,\n                3368189672511472263,\n                16407993343222005051,\n                3965440550685537978,\n                4708478243468404768,\n                1875742626798710446,\n                109477476572266497,\n                9185060711428219960,\n                2062557879153655855,\n                15504010890019002364,\n                1436468774610332740,\n                470895386030379118,\n                11192666441535176072,\n                7094623340817246353,\n                16041820192281853667,\n                5048179711756437977,\n                1908765243120848557,\n                10810219542319634593,\n                15971282719319513661,\n                8395180060853137311,\n                17415231760777435363,\n                10489441496511966940,\n                3213813993411776195,\n                13309643264471443871,\n                14152370013037392509,\n                9805694808649718454,\n                2991106746654603900,\n                2279780759950444362,\n                13989789024965052794,\n                11942900996372546394,\n                15051646099368945987,\n                7583267444740224154,\n                5192555551306992142,\n                13216959612015226558,\n                14397593124921798192,\n                4374707725758052604,\n                15529039788482882168,\n                16475619415913302762,\n                2649655538625316107,\n                11899566009797061232,\n                16892018353302708322,\n                12364166218684092426,\n                10372683350152669575,\n                5328477050361662527,\n                10949313792626687170,\n                11924230090558408019,\n                636095257275314085,\n                10210914536395617961,\n                6515368615710817299,\n                17001040330117317563,\n                4519581466335837391,\n                12514298524110577503,\n                1744739741016504912,\n                9689951195577973993,\n                2774540351629210180,\n                7646006525601223889,\n                7530479442266342421,\n                10538917317906671989,\n                6031253606146099659,\n                4606167752034374890,\n                17763804757970320617,\n                6871166461842469695,\n                3069238346134678776,\n                6898492556629873366,\n                18330913680324098797,\n                11469514731644700404,\n                541525751461369940,\n                18096353837092553451,\n                16390355202675291281,\n                11980660197830118439,\n                15349236833293249382,\n                1901608480726107605,\n                10754477505423276549,\n                1780265741680781169,\n                6204486525934807168,\n                2675596223932028138,\n                1082656654749778403,\n                15313246555910578407,\n                16597928615331243076,\n                9259667019969423039,\n                13966308744186245944,\n                3711817850123753976,\n                10380302371138242940,\n                1102076039759449071,\n                1796134829015781040,\n                8320143967311972799,\n                12603759772660781109,\n                9343508021191710450,\n                11833581848018650785,\n                5036078561764059265,\n                14477046704375156568,\n                17958581882146395247,\n                6312863763728381603,\n                5890775652924120757,\n                3024100139720533291,\n                15594980805126031556,\n                9929023026443104564,\n                6003618257535256748,\n                10584762467178432077,\n                8070692469310128137,\n                3448506857138757663,\n                12067250229870443464,\n                8289617863280099780,\n                7705347156484755083,\n                8239333463449775936,\n                12953560490361273923,\n                7863343728067574413,\n                15499170354027597711,\n                16789849673988523596,\n                193554686279189480,\n                9324166766841362509,\n                17865442848307712220,\n                4017570072096420828,\n                359910874540192895,\n                14283136222667718022,\n                15545842610688758167,\n                9161703351540143861,\n                10856046010222875891,\n                270665191423043189,\n                15816860058997167317,\n                10604344774996324885,\n                3421439666836669232,\n                15362489920565158049,\n                901986887674190509,\n                8102011985696643347,\n                9831189590417175739,\n                7694208525827500802,\n                17761503253302918415,\n                16843825659097088549,\n                15968418888658984723,\n                13213298841864639514,\n                10768746828601368994,\n                15843374988242905966,\n                10372481985078119452,\n                7145529267057724453,\n                588445411774656377,\n                6907651744680403237,\n                13729433346623178186,\n                7466282812151723072,\n                2397976897839660773,\n                3595288154116844222,\n                3771046205661211665,\n                18292138992930644589,\n                5076094080207419189,\n                16955129624357257007,\n                3929215337030354093,\n                11057894513779502294,\n                11863471976993485758,\n                9408615240131003867,\n                2448439901554368107,\n                7669176413900589628,\n                13955883899642443946,\n                3559761514651432863,\n                5999853120304570098,\n                2807928142993089395,\n                6880972979489023884,\n                8540438276045396759,\n                13336393887543928327,\n                14948024915319356336,\n                754486632845103448,\n                16252590658474672770,\n                11838852632524903679,\n                16841746824793599992,\n                4866584459095974245,\n                13046184814853980498,\n                8710985684981006226,\n                2355658489901240093,\n                17682251256218590491,\n                12738885399031396318,\n                3641463259326479601,\n                11573802402437143897,\n                4785854649163125380,\n                17654700608592820265,\n                7689738254866306083,\n                3911334929659733907,\n                3805687817679677472,\n                3372180752527728873,\n                12516023017017683246,\n                6541569134387572029,\n                14932792460356112158,\n                274079842264421275,\n                14741476297422044947,\n                7640237864595124592,\n                7990415001403780690,\n                14485175485850127358,\n                15701126719940798119,\n                7497786401585040464,\n                2046586308065249596,\n                4234230752844127257,\n                3490034085431124756,\n                7410205974894450493,\n                13594277608316567296,\n                13163068385450899386,\n                6911330603633557461,\n                4165273348787835236,\n                13196815825235476993,\n                15409229411685315073,\n                4238586327560550200,\n                4274172509763128574,\n                8233070080684386642,\n                1152981557203525396,\n                2258263369774438742,\n                16860590243592954334,\n                10642146327347114407,\n                16394076595581895042,\n                3547145813374894294,\n                7303429257652622247,\n                4599869911214805642,\n                1470127264048118954,\n                6553553520469198052,\n                624221776008514758,\n                16024993613079197687,\n                12072685851575104500,\n                4289561477780298769,\n                14522030035108027997,\n                10025959010474970695,\n                4338629041423254482,\n                12668451231751642706,\n                7041673834301289685,\n                1101300709714299914,\n                15830324192849592102,\n                6361267392222383309,\n                12743724653827284764,\n                13913765213720067888,\n                12472686594479717483,\n                17041667280903689118,\n                12612588174971368395,\n                4625038945277105759,\n                4288983616264520473,\n                13257170061268337928,\n                15378358854815534796,\n                1307879339751355693,\n                9045256242044980161,\n                13066137780318064542,\n                17483698129188252816,\n                5537781126683250458,\n                15814088167067959984,\n                17124111106622331645,\n                2228813159198082553,\n                12771677329276373795,\n                7473600359686104579,\n                10172401847101693206,\n                8817322474066906889,\n                10002046533039894942,\n                18350636570159627372,\n                2608194133937884904,\n                16496103406635747044,\n                3203166370447920771,\n                1416097169966651887,\n                860034031549905008,\n                15435212006888252138,\n                4982756044520683355,\n                14527835149012332766,\n                15648655845991912781,\n                15220061209366144565,\n                10713592116389348982,\n                11856331444132914701,\n                13011883287657858557,\n                18375660967945668491,\n                7611177834315648116,\n                11475292136381607303,\n                12142625427672665818,\n                1644376245508948388,\n                14986147846200059747,\n                10358191212479538383,\n                2124663276626493099,\n                15025396046176607689,\n                7566356641233415240,\n                3834259550197202335,\n                7422439917941038432,\n                14335746041650957139,\n                11010643115481291768,\n                16639917992723217687,\n                3400935192914355446,\n                6526469202356090658,\n                2911450085827434145,\n                2592450403666061908,\n                6573976403851247795,\n                4285219873414520276,\n                15329532146725863869,\n                6799347789229688901,\n                6639341479260471078,\n                5137054100466749121,\n                5102420602612942914,\n                12454937665202983967,\n                12962650067948965377,\n                17483657740097839287,\n                12223498331603994543,\n                14079145217780475833,\n                3310333423646124225,\n                8148231670879135605,\n                9541038636961784750,\n                11089617618703446533,\n                3560209342825276058,\n                2574634823119268479,\n                2588311243176990131,\n                15013509191556503430,\n                15455072885984268053,\n                13986137485131324765,\n                5720067926322634989,\n                320358790111393789,\n                15410939285136639329,\n                15697272961739331244,\n                1355846111750777085,\n                2546959351276906905,\n                14534695021313396715,\n                12100942362109396400,\n                1909839808518887758,\n                15057164163203198957,\n                10816292376571145141,\n                17932667027515587541,\n                8894763284691124395,\n                17376767493810914651,\n                1054656077023869452,\n                8186894411081110112,\n                4918609723063820894,\n                10472223930221187526,\n                8210872174259857628,\n                8260857529094096436,\n                11707883934354468821,\n                7798711246011152830,\n                12313898141945763999,\n                4092899057830195664,\n                12768752632246510730,\n                7011904089799177666,\n                18269846218072729005,\n                4472126139715717850,\n                7263280326862818361,\n                4617033187864299345,\n                16062484525314928005,\n                7764862313171817272,\n                5507098054488704246,\n                15417948890339509732,\n                3199184308759380889,\n                12873647785813929264,\n                15851634423390314715,\n                3379562369756927370,\n                2914796073219663247,\n                9453518290639493724,\n                10389507097848983202,\n                6987583823829734148,\n                5644521590882572085,\n                16385036288302112854,\n                14202037992186130818,\n                1662729350231436066,\n                16086866498209553899,\n                11668110277201388817,\n                2581723866463834707,\n                14466562150912612524,\n                18444381539786477861,\n                11792751584642451686,\n                644172128540161319,\n                15714856399314491326,\n                6336413224068482580,\n                15648040294508822482,\n                3581892413107868745,\n                2087860646799841458,\n                12928312782299116049,\n                4630539989871908829,\n                6915603518697601787,\n                14918733616941773093,\n                15087665207194981362,\n                613969264471068110,\n                3544544803540968193,\n                5220360717428049381,\n                3375260723217895506,\n                16778447987047186697,\n                11894812810172861433,\n                14542979312432827779,\n                13561316753657099179,\n                1968473618327458185,\n                5456934299993876358,\n                7469735400543018284,\n                7068657239043349097,\n                9254040800524479410,\n                5214107275553666760,\n                5001330682797736624,\n                17026132790954295091,\n                10969354337912897232,\n                869351389198733586,\n                9574587810937905907,\n                6923373747285449001,\n                12719903474522918771,\n                12250857818862900982,\n                2153256573644871951,\n                13709729097688338391,\n                2899377834668376960,\n                6841869401787596550,\n                10339715141881541659,\n                718655127116157511,\n                13741406681906111321,\n                15392288868670671619,\n                17545786767738322758,\n                11089794771839702758,\n                219094231550242583,\n                9674358307241496741,\n                4002620491443309348,\n                8012290324302967070,\n                8714326673970415123,\n                12380264119087982419,\n                11108551912665576265,\n                3708955946231240253,\n                11607264285750874901,\n                4216424611300123940,\n                8256067698160491644,\n                7506994298913059376,\n                11501100133000306066,\n                7549037119651533111,\n                5112970978157051505,\n                13518442004335850902,\n                7350008695599366666,\n                9542638447580599221,\n                2158188779042279647,\n                1604170908932337076,\n                6391929341437538244,\n                10779746559124306734,\n                12656450449103176181,\n                10121044395803332310,\n                11651522650180060700,\n                16328514328541821784,\n                10523761782294701174,\n                1822303728984452144,\n                7260452386953933551,\n                12204494523152059466,\n                17100382786462731446,\n                12548225060484474439,\n                11326872465335361323,\n                5596285187831113760,\n                5909751003547848587,\n                992306619579834385,\n                2228664329259510492,\n                15196270917670055982,\n                2131889695890586742,\n                9819776790840463517,\n                1473593931814601068,\n                14939513955417919643,\n                7685117665289355354,\n                6724244559482510387,\n                101460542568704969,\n                7352190705745517803,\n                2150669404455836808,\n                455126870518119052,\n                11553577781469330615,\n                10384536636375637150,\n                14364597940339752635,\n                2495319672618636831,\n                8180783418013670444,\n                3773765470722916252,\n                10227754258298095569,\n                4811293038656815364,\n                2304664986814074602,\n                2418992918773594204,\n                6388448639180737685,\n                6893696275605311774,\n                13851958766811817366,\n                4793074330182947851,\n                4813793152033309122,\n                1098414269347239038,\n                11751908186279088029,\n                15167430159498163699,\n                10528686090760108130,\n                17120804521852235295,\n                5538072916971524268,\n                18284870874128074659,\n                224523015148941267,\n                14496093443691170173,\n                5490655299006793623,\n                11584315652765207551,\n                3229579698633170375,\n                5527375504543907996,\n                6239324650299686862,\n                2232148196848710005,\n                9031256656667465794,\n                40023723987633148,\n                14627741678268078967,\n                11950626749898431344,\n                14785414395108523186,\n                870832948163923646,\n                13004928204786500706,\n                11732704426571300600,\n                907514934656616373,\n                11587740830029349245,\n                7583505136677874861,\n                2623787766244261370,\n                10256163025245964672,\n                7257287909572091733,\n                4812915812660879618,\n                3468364439026649335,\n                6604147596013682093,\n                16816894664989923710,\n                3964120271755066308,\n                6086548275463043980,\n                10447117175471304144,\n                12856607441078849807,\n                10592398111690221432,\n                14269275707379118835,\n                4396127772639422927,\n                10489721798852691549,\n                6681412646421684356,\n                12490106130106455109,\n                3624408102113036819,\n                17246634770535451304,\n                73750230380742720,\n                3858795004528971618,\n                18037249274864620640,\n                9013680198221453825,\n                11909298583725721915,\n                7512555591920604211,\n                17449244834240874515,\n                7793591661081767445,\n                16652407448095073621,\n                11804971167281860328,\n                16410605854679152138,\n                1713343542446776550,\n                16483548344281970818,\n                4628627981197409087,\n                9083762764219706193,\n                17065951854876058290,\n                11490185594933330698,\n                9891012968004512035,\n                368256788081374064,\n                470621950908252,\n                17956316299265730194,\n                8221822257224301188,\n                6380872247545425488,\n                9031471961851140451,\n                17956391258409007260,\n                13017604911584754606,\n                9245778199486992293,\n                8056793204522970093,\n                2531655295742236851,\n                16039488662052065607,\n                4695551407385442957,\n                16581782264738209135,\n                9457268466305801158,\n                2502271077174158302,\n                836797013558343943,\n                1224523470498102285,\n                374165187087964522,\n                10212314508075547184,\n                7669093970332858967,\n                9176723313583927295,\n                8839526249801396044,\n                9460240515540152245,\n                526138750665184089,\n                6908994573320912372,\n                12176043050383940227,\n                8431292525679019707,\n                7800865258551716648,\n                2930208417676545581,\n                12001139080437682925,\n                2848294057310329443,\n                3495763019164815081,\n                13998099468531902475,\n                2334207795701343601,\n                1265352082029868252,\n                5352951968929077427,\n                11045950825318827473,\n                17705541510574119706,\n                10388016860076689091,\n                6188336841660552180,\n                3874842388902329486,\n                3586889024655840994,\n                7577730940669490050,\n                3828324032996703471,\n                7382564057518691083,\n                18020764642442034007,\n                3255848346667024023,\n                913981917700616307,\n                6544220161742236189,\n                628453794376152858,\n                5273139986123145851,\n                12804359385937816703,\n                15490118777013724970,\n                5004956137979193113,\n                11537600208633214816,\n                6041778305931749161,\n                18021165191120757752,\n                4439552721639804321,\n                9445924893904633163,\n                6333608419766441318,\n                6265966168082228187,\n                5090746176805509189,\n                12079779788101746835,\n                3405057163683809716,\n                18176431495575685240,\n                5416316679824315388,\n                5666993498240944478,\n                9396996717121195736,\n                15077940112899068312,\n                15769845674133811095,\n                4172092555141541227,\n                10535661541737621064,\n                10760049649331328984,\n                9044328015087752668,\n                4208484814661836163,\n                4524519455413453106,\n                8416163180819044235,\n                76133776812564214,\n                8938397440798861336,\n                7699462000599225384,\n                9542247023407697767,\n                1397476485288102889,\n                12838783590422826565,\n                11111769246893411506,\n                17719085637529819037,\n                18350048131892648764,\n                647133208572620551,\n                3545832683987398107,\n                17392149180006432089,\n                4645454948531556636,\n                4638633830898005179,\n                15832113029610700219,\n                12312766094616504216,\n                11054531676785061901,\n                12882000175930708962,\n                17065292675540451547,\n                7348135285662513163,\n                10368855461513742486,\n                17213692472848349009,\n                5448237816391429929,\n                17475251701204191843,\n                12352004908893419844,\n                4421019229248084817,\n                5233890583141520327,\n                15415498665325430242,\n                8699482400205838797,\n                11081065321342975843,\n                13692414560354688711,\n                2057100631763259620,\n                1768191442150902149,\n                12463118341434320148,\n                14697940362261450576,\n                7225350934202123472,\n                9180626944525820669,\n                14817691250517499688,\n                9524098384486815580,\n                4894140555324164954,\n                2309262794362375113,\n                8645740617004046828,\n                16829903653299752341,\n                4278553392732422821,\n                16174995535301769275,\n                7274361875865992211,\n                5483861345936568593,\n                16555617280692737205,\n                2106788877369503099,\n                6355572984153420404,\n                15413046204382700864,\n                15184587830187202860,\n                17638950466015943646,\n                10142359495639047596,\n                2852278080143788489,\n                14902051473257283997,\n                12684082230048932446,\n                5127878269602498356,\n                1458833335160283623,\n                18343902965575788886,\n                15956410439937236477,\n                10143815431586875695,\n                8519328419973108156,\n                9379288137799805556,\n                11116700304696206296,\n                3269635235146511468,\n                7446145908658980471,\n                8423421258962502269,\n                2960959498368537205,\n                8029834119982365442,\n                12951331847284209016,\n                13335373530776006943,\n                2051038411438343086,\n                14988843915712852160,\n                11070472159205332532,\n                2405233098821133668,\n                12872299485466251244,\n                4146849588411590424,\n                8652997027024585292,\n                9417874732592565535,\n                2771366489480367357,\n                16381568131097774387,\n                1160190173665475303,\n                12142110843989704382,\n                17157977103678150822,\n                12240974252728213375,\n                8005232037362794911,\n                62748564819661432,\n                15562900352067429326,\n                13819933941831285726,\n                8700733640462543781,\n                17417693392111317966,\n                11195518897113567806,\n                8656545261572504126,\n                2665140739762930045,\n                2523114891549547532,\n                15947075740878853027,\n                16617762624958355772,\n                9189411410511795645,\n                9417682881040880723,\n                1220008371097876826,\n                4473435335583972063,\n                12416336276688398745,\n                9439155074539900208,\n                17599514971068491442,\n                1382978212068751289,\n                12012964446858847311,\n                13059411911626363940,\n                9000605160655962560,\n                18444429515577739106,\n                1678358883660355393,\n                5074103451266196440,\n                1108189786283239561,\n                10612698979413855931,\n                4989895863474068758,\n                653620819971957060,\n                12060263383072344947,\n                15076531277958824549,\n                10597595939754188762,\n                15724450558403473627,\n                16382650125476798913,\n                8738893762787150302,\n                9733212779214420390,\n                5558001311635500417,\n                2720376062751869999,\n                2936217033743496825,\n                3059230718610361194,\n                5589670835881847684,\n                12297086381101763222,\n                12830838307506907529,\n                7727866232017902927,\n                16978583538503170044,\n                5646531489086592542,\n                5696883024644775459,\n                1778382958859079024,\n                9219341275099378906,\n                17593963150311257769,\n                198176573650528594,\n                10425519151629874209,\n                13457055667833759545,\n                17213583299444020650,\n                14862117423842849302,\n                16906392281688863338,\n                4290302946266596427,\n                13505570400341984024,\n                2056510386911305907,\n                11571082458161054292,\n                7566281435617775832,\n                10210241606684674096,\n                10697498687651578080,\n                4947318501826974509,\n                5861434792576988890,\n                9869040491958929661,\n                5532013052186573089,\n                12416594018569715230,\n                10820734898252214278,\n                8537468997207455166,\n                439343392893541672,\n                14734630723072977466,\n                9898041261033982210,\n                17393034157801306127,\n                13758525217758656857,\n                2713096067589327874,\n                12442874178280670969,\n                14498768890161377807,\n                161967360889456606,\n                11930601082339405958,\n                11362787206913160786,\n                12545070484550723467,\n                14815095129086834610,\n                8605787829002095856,\n                12923597973881209899,\n                10587151577465292584,\n                14183134664818382968,\n                5172374334040473114,\n                9364926097792520560,\n                6171919845492918332,\n                4386231931762251578,\n                2155663571428617218,\n                7765511219465701910,\n                12061535530010910259,\n                16100330205655290696,\n                9974384126080194942,\n                9674175848724908032,\n                1687977953933677553,\n                2052842863240418404,\n                18296704913226861337,\n                4023434438910601547,\n                9899743965354682742,\n                5310198234766113901,\n                5162456985274720081,\n                8646509974119784542,\n                6113717383160009894,\n                6014191554047499022,\n                8484348411248636487,\n                2876047496375093909,\n                6660788054730924011,\n                1664197372146636482,\n                2820993293910648101,\n                11665512417100144808,\n                6502457677692154814,\n                2170150732610996776,\n                15522116097990839236,\n                15440086643427998964,\n                3675113412536301313,\n                8316358419658521853,\n                189389437052919038,\n                6981753429704993440,\n                12802645856607643857,\n                7243825699014665843,\n                12796799374814419834,\n                8068467907492367066,\n                16310382387876189712,\n                1486061732225930791,\n                382533986053029739,\n                16359148449656380800,\n                17246074348224240328,\n                11700746273206874174,\n            ],\n            true,\n            &[\n                15498103360604201801,\n                14680681220073716272,\n                2597755073189185031,\n                3031720638800363592,\n                1920406924732488878,\n                10671706282978043129,\n                6228787134876346903,\n                379886459615822925,\n                13395893364837647375,\n                2539271575052356599,\n                5822821431547583252,\n                11653751705603753257,\n                12529814421763290515,\n                16725786429659625136,\n                8733808577647898400,\n                16438345524314195560,\n                13777363959694830441,\n                14778407189296268050,\n                7947204033657518709,\n                12198601215715000710,\n                14004671183850272040,\n                2889674051614386577,\n                10853297240118727311,\n                6550855388784511682,\n                10594647619939535751,\n                16524423461967409279,\n                994846650169701593,\n                4039993035738174198,\n                7455026353542067531,\n                13807909686230087400,\n                16619061172485859478,\n                1546401888779565694,\n                9690928310204887436,\n                5454239242551327618,\n                3786919253240050536,\n                2972332442098923930,\n                1865268881810449860,\n                8339549666946765074,\n                13006352754592757965,\n                1714792330552067567,\n                6220026947940415121,\n                4048069131584252803,\n                17688504380133199508,\n                17216109827709949817,\n                11949387591167859998,\n                6855711313153816508,\n                17917442589402729465,\n                8600885059137106442,\n                14888743631958063001,\n                9431744630167571473,\n                8272246627545091450,\n                17341832173311952535,\n                5160662201476171772,\n                15038444760033175970,\n                14039296666679545981,\n                2263167394422146208,\n                8446862552035629888,\n                4853953753265406906,\n                6685969515208740927,\n                8256430291108630658,\n                10896747900245806123,\n                14368162519606825238,\n                7786764717051573685,\n                5370546488631029142,\n                15582578406703215017,\n                9494185062826522189,\n                6363441093260940599,\n                16190691295942052876,\n                12724998683972539048,\n                2102181153200211977,\n                879764964453554414,\n                3347396463829460164,\n                1027339669743783444,\n                17583129106206895304,\n                282387697705284642,\n                17110710405896291662,\n                11498688457889144764,\n                6965355384393768126,\n                13278709567767772146,\n                4819923293192931680,\n                1170338567469074232,\n                763615589049737121,\n                2348050584087482620,\n                14097296695204456959,\n                6384334913949883710,\n                6028544760791927713,\n                8187545488055362231,\n                7063217129888877167,\n                13479644449093004187,\n                11992733912376194292,\n                7409310591773283984,\n                13031150744286911622,\n                9332879416429877896,\n                2001884409427827782,\n                15203114628217631180,\n                14017477444722883946,\n                7610351877068962234,\n                9319846690308621869,\n                7203395294399241513,\n                1778452692808043374,\n                12850855729587627891,\n                1360166033214989666,\n                13959275740256150433,\n                1843781989277689675,\n                13164190414140016883,\n                3081307608579392680,\n                8221511042828430700,\n                10565795978869754992,\n                855511478939793280,\n                17555024393632391969,\n                4676606444126992994,\n                16536255467354733310,\n                7706482596057768719,\n                7982435643880136195,\n                2343558441420595688,\n                8038073847992125590,\n                6532371125691312796,\n                3497211664997370445,\n                17060901251779314901,\n                8091433945761175425,\n                16183609030655920635,\n                16134243026506678734,\n                9180668788515171706,\n                18003960143664339508,\n                13887735155279069367,\n                2659683821455572987,\n                1331603854454319596,\n                16082403620038202501,\n                369464106971055547,\n                16311050942660421666,\n                2994870778517660556,\n                11130168214536899193,\n                3300406311663170456,\n                1075089886256539971,\n                9012950151532917276,\n                641757861159507369,\n                15966286426551108727,\n                1226877989263316310,\n                17112637329270715265,\n                17323663008089158231,\n                10026469426888150267,\n                524479246512834180,\n                10905694386442894721,\n                3672252371967730615,\n                15037399789406973858,\n                12269806864516545683,\n                10761709967947971245,\n                13105266188161840706,\n                17338364687856820797,\n                16100433027433167590,\n                14337016682458810045,\n                3332196670791019099,\n                5195803899392128754,\n                12941547540344482902,\n                9032161337701862144,\n                5119058081849308896,\n                9293401341523949372,\n                2355093473782322052,\n                15065206658334786999,\n                6783932346331470797,\n                2282237337525993718,\n                12116195797686921304,\n                12268793128461513563,\n                10265900513243166078,\n                2970086998765846777,\n                5285800515582961715,\n                12385459780641615157,\n                5601921082969230188,\n                5739224955818992148,\n                5974530395831456872,\n                11711584111803267702,\n                15646178135498987414,\n                12157670326998106818,\n                7791656942816786940,\n                14344848147208564924,\n                8700884833629903231,\n                18177769559740364464,\n                18382136005865921159,\n                222823780357781604,\n                497948724088869099,\n                9863620480969751318,\n                16308985429832874022,\n                1368611891476963920,\n                8858581712296235685,\n                1793308458534327344,\n                7396111023030682916,\n                3895507615963378822,\n                14177713440849561511,\n                14508402349077922893,\n                361323830993616269,\n                2825345270910018629,\n                3016833259740851983,\n                14483705479778190024,\n                3191843655544259254,\n                17070318950017119283,\n                2247769061143051061,\n                10292893110800209725,\n                11180590473858949296,\n                491608769894573367,\n                4091862619508686394,\n                3622150583759937322,\n                9568595877746213070,\n                479214495394894017,\n                13004153549418065685,\n                11861044287632377914,\n                5905426964527919438,\n                15015303818527343634,\n                9416264667829720601,\n                16081900471086526579,\n                9098802851390736358,\n                7391232700349409101,\n                13667214033814761539,\n                12794230344463343073,\n                10563713604936057218,\n                10052294573876784373,\n                7759412720896564264,\n                9366854730557707997,\n                2352461940723137072,\n                11608039586815592966,\n                6223890086918678767,\n                16955768079151639030,\n                13958082335128634418,\n                6355109232855010962,\n                1203057641719310190,\n                11741473200072129728,\n                5883089625042104026,\n                697399775759770323,\n                7003550520208088794,\n                15639267143578516315,\n                5207168854484713319,\n                15549927463564155687,\n                16813194272724195518,\n                3203632921993014264,\n                2659632200539494052,\n                3200887485387849503,\n                3016394023706511246,\n                1685176993209004988,\n                4998042426381070680,\n                12308396269304618142,\n                10440905572279671571,\n                7289258316425236560,\n                11420492019403843671,\n                3435739014286885023,\n                1183580578914549974,\n                12391022286588593670,\n                14444662377984361207,\n                3027667768274959200,\n                10234843522693820701,\n                8137024801098838373,\n                2175956518454571415,\n                6512856431774372320,\n                17425077298837902611,\n                15619030842709663170,\n                4328733858250197414,\n                17049066271793844563,\n                16740818455336098686,\n                12803231563237450023,\n                14343207585545120929,\n                40565370554270873,\n                12269808301108907911,\n                14237854148444748363,\n                10889535537041659002,\n                5359832735901121412,\n                2280455121926342381,\n                3698460136651532460,\n                15500853660111634993,\n                4832455315374609219,\n                11551934315514307960,\n                15059280723596882650,\n                11460904528728722381,\n                9970203721365112078,\n                13412504833312966786,\n                2206569743519066169,\n                9674034118822376378,\n                1759760896325455600,\n                10687307483631403928,\n                132216754299839087,\n                15289917908856362717,\n                1309517963883189412,\n                18384862652234479475,\n                14945947123806962003,\n                6882615358601571684,\n                16513199887693192411,\n                17124752213270846694,\n                7283515403266723292,\n                12670977044098443396,\n                14485430674802409203,\n                1442934611356195090,\n                2021608864368655648,\n                10147644583900548957,\n                7371857896328825503,\n                2026947477675445350,\n                16313500187754293138,\n                8719670043093194236,\n                9933635014681005842,\n                822035763478980397,\n                2335471145280263358,\n                6109201632743197420,\n                6557042951458164883,\n                18289983318532010507,\n                9986031355445219324,\n                15882873198924587879,\n                1098360009929048631,\n                7417842524061545043,\n                11644845667626684475,\n                12942727688395215899,\n                581290207332301664,\n                8125070223816106784,\n                11423720844597916472,\n                10762562165784879144,\n                18174238106661068956,\n                9781731830317872009,\n                14559997564850144831,\n                15072792132406040717,\n                6428710680341821974,\n                8638270714640158948,\n                4747635406887618639,\n                8166831520970770757,\n                16942363651143481863,\n                79838347512847759,\n                6797482772873510007,\n                8323313311501674325,\n                17315123295476467077,\n                17834823603692454763,\n                10308328726247533052,\n                12030775355448257403,\n                2824788998758389510,\n                14109078089313897312,\n                11641130520145898166,\n                5636888963936541037,\n                18167395440091628041,\n                13372321523258588071,\n                4953410089393985196,\n                16105978672566938901,\n                10601583498278860290,\n                422348575551778984,\n                15238612832267589376,\n                1558937784171631375,\n                4331786449779679969,\n                15337418327813603463,\n                3313623259710416722,\n                17208498059429816255,\n                11251165400370815573,\n                17196498271703547709,\n                4097082694964734509,\n                7556946433095242856,\n                6347844528857916723,\n                4396355829072866852,\n                15635886121326888262,\n                7946520529777546618,\n                17096795895172408901,\n                9111548767024605867,\n                16907865654057151888,\n                5359925595440508025,\n                14237051989030130933,\n                17920964492648856901,\n                9862823344875030309,\n                7831769621036765714,\n                15021371912684571004,\n                13219589878808411721,\n                3953374146380746931,\n                12281692872760829769,\n                17693057212120612558,\n                5241268511066516428,\n                4584240683173043100,\n                11307963236856502036,\n                7464986033622734170,\n                11524680505188643482,\n                17257089978727055496,\n                18059877653952752717,\n                15575226900606154880,\n                3221287664925276003,\n                12861272282032425661,\n                17679280856858968683,\n                3805991681496902676,\n                11826697782075950609,\n                11798316213508884820,\n                7256245301505607009,\n                1942097151423080080,\n                16676392041435466123,\n                3541826565176409368,\n                13666275375614477812,\n                13646853539556393482,\n                12122709830935888872,\n                5785269903265304048,\n                5868625090434118091,\n                3864460472305508684,\n                8895862569614586345,\n                12252663534383898572,\n                10626162454630951434,\n                7883969995276923964,\n                17478887037876608342,\n                6525728841689878159,\n                17336841599087317704,\n                11085223335146350423,\n                1222123164560134901,\n                5595334910355692295,\n                7363771988069998591,\n                9010542397617207628,\n                8434654566307931545,\n                11206543728876967867,\n                15587365405946669727,\n                2320942588082952209,\n                15311261788951755580,\n                2614614644094425585,\n                16217798751029591830,\n                10309196366595871818,\n                14539656466339188474,\n                10003084092804057729,\n                17222779654871765458,\n                7744845468535171480,\n                771418309849778572,\n                11853058894145105205,\n                7897815886550766898,\n                5556587033994696457,\n                5714513807268881046,\n                17023601577918379389,\n                7803604781873663765,\n                9673291697515318071,\n                751122971760046241,\n                12388950643138021462,\n                6504250773221959796,\n                2900483328540996047,\n                16094938562348725597,\n                13572318981601654924,\n                776133591684824066,\n                17428665954631228492,\n                8871325163368356380,\n                6583256885218221021,\n                1423625032359763948,\n                8622740667699315995,\n                15406519135004097712,\n                9334369631470070512,\n                561254366250448269,\n                2451227769609519941,\n                8184551011516832687,\n                14941775554735050609,\n                2759039806353480037,\n                11925431361731619347,\n                10618650992098344834,\n                5791425757755968063,\n                11660536948841586794,\n                2857507999616493872,\n                5825182218810570134,\n                17584369622325436663,\n                794055755026372106,\n                12883797727322545150,\n                18063953891303933291,\n                1790841919243736465,\n                5922286747060715395,\n                13635166140759297450,\n                12934485298710265323,\n                11510394440285739488,\n                12653058381697761786,\n                3520206312932507527,\n                4915681338581827651,\n                14909516590488540050,\n                8456908206610978485,\n                2644237539946939762,\n                6968908545546543585,\n                17353040957162817288,\n                228004544586749645,\n                13386917106721017370,\n                2184106151122208429,\n                16467989441911105753,\n                10601823028219711509,\n                18167950260390545512,\n                8277286857156019519,\n                13563912571686595957,\n                15582544648763444728,\n                9860615950719022688,\n                3933595180193208944,\n                12737069340933819752,\n                2548892651686437285,\n                3303413609438162579,\n                17777198402933062639,\n                5612657840907832552,\n                10097325046301879419,\n                13502797453096229412,\n                16293091837583275620,\n                10149785319153721053,\n                10917494345308567085,\n                8633251221833283482,\n                15738850746404276595,\n                6752312563210507217,\n                7135284369428244819,\n                13321936134618682416,\n                11186187484044006385,\n                15467255718596759448,\n                4015680278938498487,\n                8912017791951568885,\n                17369296825929516384,\n                11139067090598960686,\n                13891662388974658401,\n                3024082309075874431,\n                10424315222954594810,\n                14513618925484751860,\n                7276364549692054193,\n                11034452333610388814,\n                9789225329773407471,\n                12095760644845543832,\n                3633636993638476391,\n                15639450070030165345,\n                14131121496387047030,\n                1997628424286182611,\n                4886205421027198894,\n                2281507686083878983,\n                14449854216333401840,\n                11502216356832663403,\n                13217816854604559250,\n                13361208817170243759,\n                3141182044294776671,\n                943014545321951171,\n                9633879085127205937,\n                16989828445793452648,\n                11835207147831430092,\n                7872611687915144993,\n                4049881848896294199,\n                3290792016280792924,\n                16059058124944821524,\n                18117071023279943008,\n                2165714551511825906,\n                4833662604885929274,\n                10526578162287941048,\n                13206778162496184746,\n                3896743010069301483,\n                16460014844475236489,\n                15154725474972641298,\n                14345270766528744663,\n                17402402453289603334,\n                3288718495566280780,\n                8993733837232386155,\n                3833085535083527294,\n                7847978509748787883,\n                7972924047649057079,\n                12473398711254555491,\n                15731808600224711384,\n                3182304439100627450,\n                2222507844556822292,\n                12748274553933993123,\n                3732391409121408330,\n                5896704990342262438,\n                10476090783680276673,\n                7391366085325406250,\n                9360823097004384536,\n                1522113286895808467,\n                12026598040119338948,\n                12893282189675353714,\n                1548700654335322520,\n                11308375302858097618,\n                6607303211456996260,\n                12621767746489750095,\n                16790296314382286229,\n                4205006354245204458,\n                6862768412190121175,\n                6199274374008955620,\n                6149173056349597341,\n                4671022687150055483,\n                2339406038313386086,\n                2580712663495884399,\n                5155064204644202167,\n                10701280261854167679,\n                2003705784272479623,\n                891800345438178258,\n                2015157615957402424,\n                14734603996366190682,\n                2500055061464995368,\n                7565076598722386219,\n                797833630650518729,\n                8246811997609042702,\n                307274411518370206,\n                15392638891124529583,\n                8133595059008797235,\n                2133482744567035368,\n                6768583867520736798,\n                13870757981396451531,\n                3905284165590317986,\n                3725077298590384134,\n                11913658005747634296,\n                16413425521993511734,\n                16928435840770689079,\n                15158417916852732700,\n                15078403577663587115,\n                3604841662928070482,\n                8779579673678636779,\n                1844972348783550177,\n                1955688372597214830,\n                10648724934575366934,\n                7678993761009537627,\n                6073617291696587360,\n                3615200825975967408,\n                16371640817143729595,\n                16928482556305122249,\n                12990694152278275704,\n                5640259820302602755,\n                4989122819964029214,\n                7590422812313190613,\n                15721317340593136631,\n                14456366058538546421,\n                6859291583171100475,\n                17730064557195549303,\n                12219353466802479223,\n                11213809090707058129,\n                6321450736904845757,\n                16151341499792188358,\n                4253083896566756937,\n                1178914272955904563,\n                13890560466563563173,\n                17998034639207894616,\n                15698739872825380840,\n                7704370348197248021,\n                14688093845995269729,\n                10994178222689427725,\n                15202615776454662278,\n                2397376818002250319,\n                16152831963735085706,\n                1343705646975602069,\n                9971858951327064782,\n                13758691325336329519,\n                17302762426880499898,\n                8807701590488219892,\n                6199420116262704967,\n                9664416484578619747,\n                10236591429744542118,\n                4423424052098369685,\n                17610466725009345131,\n                18294628161039087585,\n                16968894997210109518,\n                10551385103597485203,\n                9947281806024743977,\n                14758108212921747826,\n                10549325689211416175,\n                6587235771698546584,\n                14966278167349758870,\n                5528693664081443227,\n                11949914318271519709,\n                8016488460872121417,\n                2207215439863076393,\n                8975573544109811696,\n                684661245008108269,\n                9509929980012046821,\n                3032917475263357561,\n                2266490715697348333,\n                8183312483725612477,\n                240525392577752196,\n                15478661834874363472,\n                3470245043229935761,\n                2464525278395619404,\n                11110278275554344534,\n                4908085575640720862,\n                15064778674958610402,\n                4828835356862930951,\n                6202584064584953358,\n                10295563005485174947,\n                3163276082607976067,\n                14049639598239105180,\n                3650233217585203620,\n                12608886534768827942,\n                3981905877343315598,\n                39468275061822561,\n                17591426002006430904,\n                7594517119640797959,\n                14880567798374375908,\n                4017486827885574448,\n                13737692776882788427,\n                6158794355989980812,\n                383745276846808810,\n                5108235151843952780,\n                6581178451981594031,\n                11451128845105388295,\n                698564733531409693,\n                13590491791704146886,\n                10352604600393091731,\n                6213449185937997650,\n                4348280587322608966,\n                959194844934412287,\n                15484062908308664344,\n                7387861422874591620,\n                17667235454770559565,\n                2440272288352768767,\n                15313076085483229881,\n                4394939461270873554,\n                1628152315473173420,\n                1415402097762366967,\n                15346329547611571068,\n                11311158606059373217,\n                2366068387763653832,\n                15827874528350068510,\n                13478669408398828575,\n                5936593674063517567,\n                10584447941392540523,\n                1317442477979981269,\n                8979238841918884811,\n                5240407513739116940,\n                12227540356097433044,\n                11331718208669401235,\n                11393510971894295226,\n                478480586582623369,\n                2028112196418916108,\n                16944217440280198338,\n                9814942465102597148,\n                3183401114378360681,\n                7794238633501499150,\n                6535042020255030123,\n                16258670974723154594,\n                2212968344770363453,\n                5719260649695922910,\n                4606011453115746425,\n                18085523271336811794,\n                17023461305362306011,\n                4247443272385203825,\n                6453251596576818368,\n                18153292782216062723,\n                5969466175493841801,\n                6321027330911253733,\n                10620114383079958080,\n                11515725563710830976,\n                4682443894174103379,\n                9005330096592740147,\n                11358291404660090303,\n                15135083403206933818,\n                6370715174201910549,\n                6105822410739604100,\n                8316207692961349510,\n                8259189295390750903,\n                2909742184369137309,\n                931815393357021144,\n                3709546617072645818,\n                1586929876111184413,\n                3725106404003481751,\n                17989670899755090663,\n                16491755486151566843,\n                18235557335072238517,\n                16819814180993789265,\n                3041428806510990731,\n                6865566553245145098,\n                5559130936912499682,\n                7868492591048735877,\n                516631801965947304,\n                12161391763229603010,\n                2099765767202237253,\n                11018187982047213443,\n                1806434721568654790,\n                14516670445144859820,\n                14996026277919828161,\n                1979400560260923097,\n                530899540924426437,\n                1544520666424388930,\n                12533232064152026916,\n                10636267691556545099,\n                11484747390613915689,\n                11975226862445058044,\n                18241416109577265729,\n                17650249201626190339,\n                5761319483108090030,\n                9726766041568799984,\n                18315404984942763135,\n                17485602863250344984,\n                7542671955399167106,\n                14167359599732935525,\n                14822899150603891301,\n                11294686994492532553,\n                4045981924741516243,\n                6288727179049989333,\n                6271716940971079785,\n                5997800943644820668,\n                12705895494256190348,\n                18325566440733423026,\n                15268015809894548522,\n                13529897842266058970,\n                18331490128621572171,\n                10350274989230142044,\n                7235025897971980354,\n                16944603767727061155,\n                17046851593613065508,\n                16086819789503268069,\n                2290872333130971056,\n                11984271223439423839,\n                1968822742298832180,\n                9083741104320807061,\n                3490731051051179842,\n                6072547544689161806,\n                40892107681695834,\n                8194227897552725559,\n                2721703120818905136,\n                9182734210123626257,\n                10113312346515496162,\n                1627809854903310227,\n                4186406494017506284,\n                10256817089933617761,\n                2890871166679209745,\n                9992704421054257501,\n                13713795077083289625,\n                3497800266051164878,\n                577588120720483057,\n                7743155312369684850,\n                647582273058879352,\n                11847425330561165923,\n                7451614373862558947,\n                787695141116308299,\n                7020373641750093706,\n                18434370843004147346,\n                16766305512676347566,\n                11415044418032097316,\n                482952101064757562,\n                18365897665965731898,\n                6881852757206457367,\n                13295203415856753793,\n                4499519949012683341,\n                17639942290890472204,\n                2755065488659651945,\n                9099541245887106039,\n                8663706628944419889,\n                17311177494160805304,\n                3306401809449207660,\n                2992016527983769757,\n                6087225719072057672,\n                6533774652927754545,\n                18039943409631383264,\n                1540245282770191318,\n                15277302707208554957,\n                17334457161902221476,\n                10845441929461561460,\n                11846394699980441664,\n                9115621611590602269,\n                2922854986832564065,\n                17451398518651662455,\n                1624359634333743178,\n                14135939137800853431,\n                5650014301091287122,\n                1008856784246308033,\n                16575426331385040544,\n                11769760111485998379,\n                18047362944033116891,\n                4430274753462093265,\n                10745539796374847916,\n                10143880086904985637,\n                11789608990060323996,\n                9802343997665591732,\n                5669534112895101423,\n                16251907517385954967,\n                6261903170633780259,\n                8303151037984901826,\n                13675205335362018011,\n                4667052050829987784,\n                5394729392207077204,\n                3621809308351225757,\n                17881301996012426281,\n                18399425005085138360,\n                11784479206713797182,\n                10851557031496270555,\n                18242614516595162924,\n                3073485463193110742,\n                13919662806477670818,\n                15467987962430305736,\n                17976204998667974976,\n                8621215111631964342,\n                7126454543525487791,\n                12434044822613840789,\n                17437950370500401683,\n                8791748056601765148,\n                7578617491717957648,\n                17385069130528753926,\n                9612850688404007777,\n                8114351499558902046,\n                2647542888905057502,\n                4835591961742843525,\n                5890936468602936453,\n                13302065294648475030,\n                14976820931424228464,\n                3279343125067124808,\n                10626838744682430018,\n                12709395681192284704,\n                7430874177645136330,\n                18115853546653664013,\n                371015040294693882,\n                15943602063165443616,\n                14943822821811562326,\n                7804830422267751664,\n                14895692916762302315,\n                12698274826067610241,\n                4758182647740913674,\n                4888906871671527431,\n                1572622354970534142,\n                9250392132777844371,\n                12615538942854370319,\n                6020495506206849796,\n                13058788715426468132,\n                14422825795723441575,\n                3943209974410467764,\n                12768876895569234627,\n                10635363936797354481,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_newton_approx_fail_1() {\n    limbs_invert_newton_approx(&mut [10; 6], &[1, 2, 3, 4, 5], &mut [10; 10]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_newton_approx_fail_2() {\n    limbs_invert_newton_approx(&mut [10; 6], &[1, 2, 3, 4, 0x80000000], &mut [10; 8]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_newton_approx_fail_3() {\n    limbs_invert_newton_approx(&mut [10; 6], &[1, 2, 3, 0x80000000], &mut [10; 10]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_newton_approx_fail_4() {\n    limbs_invert_newton_approx(&mut [10; 4], &[1, 2, 3, 4, 0x80000000], &mut [10; 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_invert_approx() {\n    let test = |is_in: &[Limb], ds: &[Limb], result_definitely_exact, is_out: &[Limb]| {\n        let mut is = is_in.to_vec();\n        let mut scratch = vec![0; is_in.len() << 1];\n        assert_eq!(\n            limbs_invert_approx(&mut is, ds, &mut scratch),\n            result_definitely_exact,\n        );\n        assert_eq!(is, is_out);\n        verify_limbs_invert_approx(is_in, ds, result_definitely_exact, &is);\n    };\n    // - ds.len() < INV_NEWTON_THRESHOLD\n    test(&[10; 3], &[0x80000000], true, &[u32::MAX, 10, 10]);\n    // - ds.len() >= INV_NEWTON_THRESHOLD\n    let mut ds = vec![123; 175];\n    ds.push(0x80000000);\n    test(\n        &[10; 176],\n        &ds,\n        false,\n        &[\n            2468656776,\n            458964117,\n            2715468315,\n            1790012879,\n            3522999749,\n            4214715874,\n            561506786,\n            3302400720,\n            534918344,\n            1263272887,\n            3075782921,\n            2067555491,\n            746647830,\n            518406956,\n            2268770356,\n            199166681,\n            585200343,\n            2568074090,\n            496918528,\n            707408551,\n            2864167181,\n            2697486675,\n            365965986,\n            566676423,\n            4243405542,\n            2529073250,\n            1738952834,\n            695156794,\n            4116132056,\n            240876219,\n            2603129425,\n            2192004736,\n            1342688443,\n            2964614325,\n            4249182840,\n            2414593720,\n            2593965601,\n            2916418334,\n            2637652497,\n            994042154,\n            3834346320,\n            2159029599,\n            988365118,\n            3644217481,\n            1407533479,\n            654358021,\n            2493606292,\n            4023096448,\n            1141066521,\n            983459780,\n            3892764635,\n            2438657556,\n            46466645,\n            374378413,\n            979049107,\n            3284790741,\n            3990074329,\n            928205488,\n            3007997859,\n            3046358137,\n            2915845116,\n            628001258,\n            3465083935,\n            4236663285,\n            474535350,\n            2027435145,\n            3567992797,\n            4283770508,\n            2324985479,\n            376140225,\n            777742614,\n            1991983228,\n            354120270,\n            1512293869,\n            1872844204,\n            2864777182,\n            1662657829,\n            3120313116,\n            1367744326,\n            3903740266,\n            1092780358,\n            4056570813,\n            2945196325,\n            187533600,\n            931587688,\n            2394937291,\n            1507441207,\n            345576625,\n            1601524905,\n            476504330,\n            1269949561,\n            3390313417,\n            881580197,\n            1002436463,\n            2217811800,\n            685849999,\n            185823896,\n            1272490189,\n            3967659522,\n            3205992619,\n            2860215323,\n            3472978514,\n            1224636072,\n            305126296,\n            1759643037,\n            3515215216,\n            4075133951,\n            1224421257,\n            774076486,\n            3594767960,\n            1443121990,\n            2854565002,\n            2031006704,\n            3471036315,\n            2258092726,\n            3015513815,\n            1591867662,\n            2298829418,\n            2586837892,\n            4173923545,\n            3288784297,\n            1655027454,\n            674268161,\n            118227690,\n            4135574019,\n            3420877922,\n            3419101194,\n            2933141174,\n            801148518,\n            2138817011,\n            4265486539,\n            2610068278,\n            3432736337,\n            4263393041,\n            3163494866,\n            1217674034,\n            638081175,\n            1411840480,\n            38063796,\n            989590891,\n            457807629,\n            1412034828,\n            1103809621,\n            2233526783,\n            1436248111,\n            1917272861,\n            1485988800,\n            1517198661,\n            126869,\n            2315908856,\n            3274287261,\n            3670331343,\n            473008784,\n            1471036169,\n            231026838,\n            3870905408,\n            2284494418,\n            3904415704,\n            3550806025,\n            1919076393,\n            1355185851,\n            1830925510,\n            1032027683,\n            3523514211,\n            219638593,\n            1697572843,\n            1874144044,\n            3230672849,\n            2851366658,\n            4206129317,\n            4265556027,\n            241571,\n            120540,\n            4294966804,\n            4294966803,\n            u32::MAX,\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_approx_fail_1() {\n    limbs_invert_approx(&mut [10; 3], &[1], &mut [10, 10]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_approx_fail_2() {\n    limbs_invert_approx(&mut [10; 3], &[1, 0x80000000], &mut [10; 3]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_approx_fail_3() {\n    limbs_invert_approx(&mut [10; 3], &[], &mut [10; 3]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_invert_approx_fail_4() {\n    limbs_invert_approx(&mut [10; 1], &[1, 0x80000000], &mut [10; 4]);\n}\n\nfn verify_limbs_div_mod_2(\n    qs_in: &[Limb],\n    rs_in: &[Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    q_highest: bool,\n    qs_out: &[Limb],\n    rs_out: &[Limb],\n) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let d_len = ds.len();\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let base_q_len = ns.len() - d_len;\n    let mut qs = qs_out[..base_q_len].to_vec();\n    if q_highest {\n        qs.push(1);\n    }\n    let q = Natural::from_owned_limbs_asc(qs);\n    let r = Natural::from_limbs_asc(&rs_out[..d_len]);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, expected_r);\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n    assert_eq!(&rs_in[d_len..], &rs_out[d_len..]);\n    assert!(r < d);\n    assert_eq!(q * d + r, n);\n}\n\n#[test]\nfn test_limbs_div_mod_barrett() {\n    let test = |qs_in: &[Limb],\n                rs_in: &[Limb],\n                ns: &[Limb],\n                ds: &[Limb],\n                q_highest,\n                qs_out: &[Limb],\n                rs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut rs = rs_in.to_vec();\n        let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n        assert_eq!(\n            limbs_div_mod_barrett(&mut qs, &mut rs, ns, ds, &mut scratch),\n            q_highest,\n        );\n        assert_eq!(qs, qs_out);\n        assert_eq!(rs, rs_out);\n        verify_limbs_div_mod_2(qs_in, rs_in, ns, ds, q_highest, &qs, &rs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - q_len + MU_DIV_QR_SKEW_THRESHOLD >= d_len\n        // - d_len != i_len in limbs_div_mod_barrett_helper\n        // - !limbs_add_limb_to_out(scratch, &ds[d_len - i_len_plus_1..], 1) in\n        //   limbs_div_mod_barrett_helper\n        // - !highest_q in limbs_div_mod_barrett_preinverted\n        // - i_len == chunk_len in limbs_div_mod_barrett_preinverted\n        // - i_len < MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_div_mod_barrett_preinverted\n        // - n > 0 in limbs_div_mod_barrett_preinverted\n        // - limbs_cmp_same_length(ns_hi, ds) >= Equal in limbs_div_mod_barrett_preinverted\n        test(\n            &[10, 10],\n            &[10, 10, 10],\n            &[1, 2, 3],\n            &[1, 0x80000000],\n            false,\n            &[6, 10],\n            &[0xfffffffb, 1, 10],\n        );\n        // - highest_q in limbs_div_mod_barrett_preinverted\n        // - i_len >= MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD in limbs_div_mod_barrett_preinverted\n        // - d_len_plus_i_len > scratch_len in limbs_div_barrett_large_product\n        // - i_len != chunk_len in limbs_div_mod_barrett_preinverted\n        // - limbs_cmp_same_length(ns_hi, ds) == Less in limbs_div_mod_barrett_preinverted\n        test(\n            &[\n                3347432287, 667250836, 2974407817, 429996943, 2750501459, 981155607, 2784121354,\n                3415523349, 1074478768, 1820977205, 231390348, 1372589414, 2069009514, 2430571486,\n                1857553253, 1536218533, 3666738280, 3477095993, 1509486443, 3092180985, 1588218081,\n                2448257324, 672729993, 2374023188, 2913701567, 2541072953, 762935357, 1333399576,\n                2676378567, 2962748936, 744662462, 1379794240, 2290146289, 4080012384, 2739115667,\n                701035190, 4208500661, 2190862255, 3061320303, 3853993751, 2324138270, 2878407932,\n                3552024846, 3816909905, 3815506441, 1255343574, 1901570312, 91219029, 1399539132,\n                3118241152, 3325617992, 2881339798, 2520199899, 3667594206, 1853889834, 866669545,\n                4104229459, 2070282300, 1484152931, 3098893530, 358952500, 2164190448, 4138312509,\n                727032566, 2750086730, 3119399990, 1390731909,\n            ],\n            &[\n                1037101017, 1727794380, 1490452070, 1098486148, 4011045557, 2946764072, 697788893,\n                2534857680, 3261736561, 2991036431, 3203952375, 678147993, 1718071908, 1324397528,\n                3227412704, 2808109049, 2498489092, 1483895999, 1974627636, 774482390, 1844543122,\n                3947438938, 1357670917, 3021715202, 2044056785, 26339702, 2002972036, 2442219903,\n                3581261805, 291932047, 3070844846, 1561991523, 2591235485, 4062653222, 432295028,\n                3024980126, 3174836607, 1645982854, 968272899, 3101889669, 3996099656, 1637081358,\n                2998072999, 2235890151, 553838585, 1688691976, 4092350095, 2065416776, 3709647283,\n                1072755910, 2385936305, 2615766642, 136864038, 757727106, 2199116578, 2066024664,\n                3784388877, 896467499, 298040025, 315565009, 4174702765, 3225704704, 23210826,\n                2346706257, 1990744556, 2040289114, 1584842987, 1498510914, 2668413122, 2503096531,\n                2005961409, 2272795985, 394426800, 2285275525, 2471642108, 2784697818, 1258928804,\n                151106578, 3449120105, 169880528, 3307735530, 1735274873, 1875100806, 2033402873,\n                1707359177, 2748179285, 3611534985, 3379681783, 1722155183, 1210860589, 1583939074,\n                1413313200, 1958033089, 1382323587, 3321046184, 2567768608, 2706224116, 1925292443,\n                486456966, 33556563, 4003036360, 624876701, 2847313485, 3451353450, 3432337713,\n                1567344163, 2879538252, 624051431, 1206504435, 3713613381, 1062990555, 498008949,\n                1798769609, 3937669287, 4147083150, 2479873449, 1454286408, 665997230, 331654711,\n                1482116196, 2545259161, 1591656626, 904758973, 1600224317, 3734588228, 2386781283,\n                4212676921, 1479533912, 2157734799, 3588439224,\n            ],\n            &[\n                3380102021, 2452922302, 1962966574, 3357220828, 3890634007, 1037328979, 1799391942,\n                1004666291, 3982464365, 4257152024, 187444313, 3439720141, 1266693503, 724678963,\n                3437259008, 1572104078, 4039559445, 3285865736, 3569601379, 1308348984, 1718729371,\n                284719758, 444404442, 4151851178, 2692003849, 1055982587, 4035467383, 3921915216,\n                3487944745, 1817447325, 1542763265, 3937726417, 2223825009, 1394339428, 1214099970,\n                4192217805, 3753293552, 3811191236, 706896668, 1075933013, 3658129436, 156288657,\n                1259909922, 1889374713, 2941065257, 81950085, 649933990, 3336906952, 2183193381,\n                1175410937, 2580459452, 3904196981, 2723001189, 1789637716, 2009908016, 3170700121,\n                18873175, 2237687603, 1424198121, 980763182, 1043721413, 1070004656, 3240828354,\n                1874904174, 1859325685, 914946875, 3171367435, 891888508, 94557928, 2528939804,\n                1026794028, 412407977, 1504097351, 2321903212, 4049474173, 2376576188, 2102495452,\n                1976457360, 2692728936, 3130170922, 2123163736, 3537525633, 1557920518, 2628772698,\n                453031939, 451448604, 2142259, 3310964267, 2745320950, 2734144127, 3699687158,\n                784837860, 1503636827, 811700689, 582299446, 2429787592, 1210273821, 2702547973,\n                2699574096, 3370153605, 1236597584, 1088015704, 2939670102, 165924895, 18853284,\n                3700200624, 3220442711, 2965715000, 1488424876, 3464105223, 217616508, 315230760,\n                1429465794, 1372241659, 4248780864, 767395681, 4105247821, 1532652179, 2100932260,\n                2674903482, 484464190, 3609058420, 1471559178, 4122200129, 4198439348, 1623393770,\n                4254969136, 2270601790, 4239377868, 588832613, 2695326914, 1952240370, 2369526722,\n                669955508, 1561380904, 1661607015, 491163324, 4063133286, 339180970, 1218080293,\n                2858927543, 2211268294, 4242441810, 4166777931, 459461625, 2722830085, 1984526624,\n                2371328931, 3795073119, 313183280, 3291949415, 1843511154, 809173981, 3006056205,\n                3286577997, 74654418, 3553288229, 2169290280, 151023939, 1586116459, 3040308252,\n                4142315068, 2646953656, 4225002928, 4051564438, 1032308582, 4166856711,\n            ],\n            &[\n                2427812263, 4051563058, 1632406385, 3107965286, 2723923069, 1032718410, 1300669246,\n                1686783039, 2900234860, 381961320, 3860838802, 3653570244, 1848772343, 2404802446,\n                17732494, 2990806772, 1910668969, 3421521828, 1829199569, 2997918403, 3557175274,\n                3519619382, 740250212, 998547797, 140767728, 1892932539, 668118324, 497299250,\n                937663333, 2612689662, 4010699478, 389960621, 3786256383, 1395295829, 1276717484,\n                1869006600, 2093853956, 1555847120, 101097965, 231988325, 1792259822, 29327628,\n                408838665, 3646864419, 2451151869, 3859710466, 2245716151, 2883931737, 1198282734,\n                2659505911, 354206954, 3482662941, 3212522494, 4106878300, 1901956875, 645864641,\n                1078147214, 1797412778, 3856838800, 2428567766, 662568175, 698243503, 4146493635,\n                150220967, 3723014797, 1944885174, 2282033009, 3395489773, 473095209, 3085161317,\n                2999589203, 3878818308, 1223719023, 352990164, 249223561, 4143029861, 2622703186,\n                796827870, 1054862138, 677020780, 1289629518, 3449239587, 3541454564, 3311081075,\n                583050818, 491332673, 1997521794, 627632367, 2864835203, 2880916227, 233376741,\n                1067584403, 2454677969, 4048829167, 2955413920, 651548741, 1667224967, 659069317,\n                4019573675, 3305249558, 3965166031, 2657374006, 1899323245, 2478966232, 2865170658,\n                819362488, 2414458118, 203150817, 3555808793, 3366944226,\n            ],\n            true,\n            &[\n                318412713, 166261607, 2009115186, 2592695300, 909481568, 921495628, 1252820069,\n                2134562168, 1472790817, 1608088310, 689541000, 69370609, 2685209974, 3562066729,\n                55850493, 1884247907, 2876898529, 3115161272, 2620296992, 3497928383, 4079349604,\n                2838452936, 3352297661, 3503798900, 2830174901, 2750509727, 1984400813, 797374166,\n                112488353, 4244342514, 2411618910, 4209213781, 3477038403, 2142115980, 1949259992,\n                1303854388, 2073509204, 1462419537, 1282719064, 770376429, 874669429, 674943385,\n                4182481942, 2641210646, 1249878403, 721250586, 3561964927, 4189270923, 2494976587,\n                1232128515, 2160491104, 2258727309, 3620010609, 252515683, 3388122763, 4155289792,\n                1020390516, 2070282300, 1484152931, 3098893530, 358952500, 2164190448, 4138312509,\n                727032566, 2750086730, 3119399990, 1390731909,\n            ],\n            &[\n                2882761542, 785407498, 1124133487, 572386909, 1169675686, 3567625455, 4199715839,\n                3851396630, 3274146684, 3477301663, 3302596192, 1480559142, 100842294, 3530609196,\n                4086393700, 1190308308, 4263459677, 1142007717, 2247036858, 4120633014, 2294603452,\n                2399429000, 2624162280, 1454610696, 270143073, 3957844361, 3046891288, 1549007386,\n                233535161, 3109659080, 209449866, 498073310, 2626910641, 195499996, 3976787267,\n                3922992490, 349292363, 3307104635, 365992265, 4190381097, 3755383481, 2478897620,\n                1546723896, 4001998632, 1128630761, 2676599750, 2475921888, 3233603626, 1483504432,\n                2551193799, 3557144097, 313815765, 1349744193, 1374844288, 2400211342, 2986607421,\n                3195157472, 1299836347, 1861689827, 742292964, 2823852296, 448143737, 1667945403,\n                633976860, 2902355589, 2157443145, 243118113, 2840619921, 2919500120, 2742747945,\n                845926917, 220468159, 1355718767, 2330428847, 3717678284, 1787470596, 2523167223,\n                2214932965, 2055827539, 27888400, 2211687684, 526284755, 994343204, 904008663,\n                487598580, 2347713123, 3532282785, 3549720901, 2459046510, 338578128, 1168895967,\n                3291681132, 3787087696, 1555047248, 894667165, 1085939503, 4100902874, 309142266,\n                1088553857, 2096128611, 1104848719, 3907470805, 3414980158, 3260046959, 2704772147,\n                288217831, 1781865616, 179692408, 1428188291, 2562193479, 1062990555, 498008949,\n                1798769609, 3937669287, 4147083150, 2479873449, 1454286408, 665997230, 331654711,\n                1482116196, 2545259161, 1591656626, 904758973, 1600224317, 3734588228, 2386781283,\n                4212676921, 1479533912, 2157734799, 3588439224,\n            ],\n        );\n        // - r != 0 in limbs_div_mod_barrett_preinverted\n        test(\n            &mut [10, 10],\n            &mut [10, 10],\n            &[0, 0, 0, 1],\n            &[1, 0x80000000],\n            false,\n            &[u32::MAX, 1],\n            &[1, 0x7ffffffe],\n        );\n        // - d_len == i_len in limbs_div_mod_barrett_helper\n        // - n == 0 in limbs_div_mod_barrett_preinverted\n        test(\n            &mut [10; 3],\n            &mut [10, 10],\n            &[0; 5],\n            &[0, 0x80000000],\n            false,\n            &[0, 0, 0],\n            &[0, 0],\n        );\n        // - q_len + MU_DIV_QR_SKEW_THRESHOLD < d_len\n        // - !highest_q in limbs_div_mod_barrett_large_helper\n        // - !_limbs_sub_same_length_with_borrow_in_in_place_left(rs_hi, scratch_hi,\n        //   limbs_sub_same_length_to_out(rs_lo, ns_lo, scratch_lo)) in\n        //   limbs_div_mod_barrett_large_helper\n        test(\n            &mut [10; 125],\n            &mut [10; 405],\n            &[\n                2824467771, 3299124311, 2818671068, 3680778570, 981687343, 2406693669, 659467593,\n                2993414243, 45406089, 1478779191, 1711786852, 1750419133, 2909274013, 511107722,\n                3561218251, 1136025710, 993075881, 3516743656, 2114794292, 1997914, 3812643652,\n                2505455342, 1465178283, 1978590884, 2983823507, 1628362808, 1695987706, 2508198478,\n                518693670, 835288758, 1012607974, 749782274, 577737644, 2333209317, 4167594129,\n                2270730042, 3116080031, 2989072664, 3700594452, 2080277190, 1740782490, 2022893854,\n                2980102855, 751636825, 3922671264, 3391149880, 614930929, 120867901, 2567507861,\n                1524427749, 2580678371, 2199894921, 1776614185, 1166041925, 1079838738, 110556090,\n                2831653230, 2555307604, 1415160216, 250952335, 1727168666, 4114643415, 3895205129,\n                692242739, 1888273350, 3407947612, 2500185766, 2392325992, 454908683, 1510488259,\n                627605677, 2579656597, 503296566, 732883994, 1804534661, 1024632105, 2582676903,\n                2186193446, 2035546222, 1537608294, 2871563506, 1842379464, 4285710796, 1145782664,\n                2168389602, 2821015070, 3799000303, 1910989354, 2712163170, 2373188937, 94374379,\n                745462864, 1273218817, 599427865, 3025428597, 4170147632, 654664457, 999597566,\n                1301587861, 785951171, 1404519917, 226625774, 114784173, 1303174335, 1991080402,\n                953508169, 2955695351, 4272100018, 4152229685, 505603829, 1367830508, 275280730,\n                1743334800, 136640107, 543638242, 2867205034, 3205072197, 122133232, 2907110177,\n                2577983454, 4044792269, 1426164254, 3391219052, 4077004042, 60445643, 361888880,\n                1370511290, 4140611, 1545574856, 337863511, 2696753299, 882513095, 2220102704,\n                4040224968, 3895008884, 3144563393, 2298197836, 2781817257, 1704369652, 3931316078,\n                315544063, 3497851423, 3664143565, 952326443, 3938628137, 2331019960,\n            ],\n            &[\n                3222658839, 1719980949, 49002116, 576454969, 2480526346, 4090562449, 3826526799,\n                1957153338, 2225171960, 2687643162, 708981609, 3176715792, 2962973059, 2652817195,\n                1197341180, 2939993186, 3554367730, 1570613844, 2536409086, 499280456, 3247067732,\n                1595825640, 2368929206, 663346056, 3132360609, 1474802683, 2339072148, 2202454503,\n                3728785029, 3203437738, 904057293, 3413710811, 2642403758, 3344563036, 4027597111,\n                1888090288, 1863907782, 2464957062, 2688706102, 569142547, 397802070, 245946780,\n                3489512252, 2617239243, 779718731, 179625066, 4023449096, 3996006819, 953561942,\n                1127504598, 1992436862, 3073123794, 1835220635, 3142367806, 3159289192, 1927251431,\n                2830198394, 910503635, 2897643083, 2932878381, 1507827586, 3067247947, 885528755,\n                2017570727, 3134837176, 499511463, 1535166690, 1643153113, 2968177930, 3952804609,\n                3989699184, 256167900, 567717900, 3896800262, 2310644620, 2351013373, 1964719080,\n                1905779649, 3311747907, 1340733718, 2870734940, 3144732377, 1107086597, 3017452910,\n                32224803, 2995638379, 1782145516, 3064028223, 405412838, 4063680301, 3415165225,\n                1788170832, 3805938672, 1902801261, 2231309030, 1810036873, 3470233158, 2413346472,\n                3530489706, 110880408, 887205258, 3604865827, 2857625992, 3018122209, 2631997677,\n                1125977084, 2461114861, 2161802286, 273825728, 2086061888, 541221199, 1806844610,\n                1376732414, 3802142465, 3535151037, 2954021790, 2116798495, 3735046347, 1186632354,\n                2833281426, 3457883657, 3962766016, 13814577, 1650009216, 4147309188, 2302630822,\n                3980940746, 4258997501,\n            ],\n            false,\n            &[\n                914514400, 3342502906, 521760868, 1049115929, 3824837806, 2763332026, 79145590,\n                2361118660, 3694174875, 582606291, 2236610090, 245694427, 1561619352, 186706776,\n                239856728, 3342500541, 3049919767, 2350706825, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                671156763, 3522970087, 1803674928, 705095332, 2537912304, 2452859779, 3450873050,\n                2679364048, 3526396093, 4177976105, 266611217, 1151557614, 2132817166, 3877142811,\n                507210298, 2972523503, 3073806840, 3566048488, 880991998, 3345680417, 3235170656,\n                2403723979, 1313154315, 2771932402, 1330267204, 3414255915, 1179382708, 3233207082,\n                2503609750, 249317411, 2632726993, 130324620, 2032071659, 3005726146, 3875282024,\n                887247870, 1998016163, 4254819443, 3740865454, 3553274754, 2446121384, 3275444724,\n                233325872, 539446483, 1087952312, 1835245616, 3627109091, 2510529404, 185630261,\n                3706778570, 3098183261, 1931085512, 798171652, 3040444481, 1161846676, 1038636293,\n                3421904104, 2901743603, 300733872, 3719079820, 3468813384, 2881344572, 2125343174,\n                1936937822, 598427076, 1712995528, 4084208860, 3733468538, 1669487237, 1385196430,\n                4053752992, 3005943092, 2525935674, 282240792, 4279794411, 4125983631, 2329629976,\n                2704369810, 1464421682, 1313908108, 1226002425, 1808406752, 3275768064, 3175836384,\n                931684775, 589156533, 3002460872, 2667576199, 1619914000, 3662683434, 3389418364,\n                772131109, 3768421507, 3396906380, 2736076174, 2900071166, 538472464, 373492649,\n                1143475222, 591038056, 3736209846, 856338986, 232250025, 3427987228, 159577157,\n                485970599, 624042727, 2427226926, 758605639, 309500365, 1623348751, 4085018849,\n                1073894303, 3272403714, 3990448709, 1089031712, 1648217954, 1406121363, 1462876615,\n                1399073841, 3264088864, 3357032142, 1754184006, 598504776, 2188603491, 1888083714,\n                2827226198, 3414026126, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - highest_q in limbs_div_mod_barrett_large_helper\n        test(\n            &[10; 115],\n            &[10; 1254],\n            &[\n                2401497277, 3741262706, 691871239, 1949640889, 266070694, 3295242537, 3037066187,\n                3875417448, 1358853731, 4158125741, 737486219, 2625351318, 2205206855, 501024225,\n                2060376077, 1953521053, 3762056723, 163485007, 769999701, 2385831686, 2388009068,\n                3120433785, 609866149, 1014929431, 4255522153, 3908104955, 1296186549, 1400337892,\n                2481196402, 1530226708, 1736756203, 4267671814, 3181376526, 4204274026, 2772982826,\n                171341955, 3239339748, 83269891, 2325049318, 746305994, 1290717192, 1805639230,\n                1856363646, 3445599715, 1388597950, 2699498310, 246990054, 1396771726, 265087723,\n                3372840761, 3260397695, 2010115470, 2211074582, 1883962263, 256363687, 4012920099,\n                2367091978, 1485341992, 1836339208, 1434180757, 2616877872, 1145425491, 1261399773,\n                3926766027, 3115015865, 1741783714, 3802513218, 4081750672, 3856503286, 2137512595,\n                1192985123, 1863041957, 700637154, 2503934926, 2021744810, 157763047, 453501781,\n                1898727251, 3741166728, 105996483, 3390681922, 1127471458, 4229032301, 254843851,\n                2729237155, 1707011850, 1756734415, 1864969309, 96539023, 220456923, 3061776324,\n                1741151628, 1199010536, 2099212259, 3095715999, 1369052975, 2575251120, 1821995904,\n                4169452262, 3299830336, 666854626, 3647011057, 3965571435, 1551218489, 726151433,\n                1730753749, 750433250, 2084548637, 475638490, 3209308986, 1536371286, 3458731894,\n                451976715, 1463077982, 3275775647, 1176722184, 946473888, 295088963, 1154092407,\n                103838303, 3743650178, 4149308777, 1617840168, 3465913339, 4133656500, 186966677,\n                1624567957, 3264214229, 1285455678, 3951367256, 1685500601, 2890483019, 3692192743,\n                503129144, 3972113270, 2472468030, 3386552094, 520995657, 318761291, 3652507947,\n                876136924, 451086694, 2855321222, 557040372, 805677163, 2526778273, 2320694361,\n                1256424719, 1952008095, 4056766614, 4133706458, 3948099450, 343436346, 4192911370,\n                284826582, 674589589, 2186532130, 3868256489, 3551620239, 3301954255, 1174676675,\n                603478538, 275555563, 2405977791, 1847784099, 896249737, 2255526478, 1787445221,\n                239988612, 1297053793, 4022115314, 3399153034, 1717528213, 1660404772, 3074772866,\n                2806710693, 1643510791, 3184377187, 1540838982, 134943412, 4022881239, 1840380980,\n                3861497294, 2510066751, 1433230269, 2045075002, 2415627101, 1223566402, 3367143819,\n                612631145, 1154322627, 3247079704, 1778868389, 272795417, 933297265, 3458460741,\n                1389431679, 2907745644, 2086192882, 2684128325, 2650239535, 1784197442, 3949401651,\n                1783533373, 4288056634, 888203755, 437001866, 1407050668, 3135687315, 3463879635,\n                1702062054, 1204976730, 4177166610, 739673691, 2277342971, 3478834440, 4081300483,\n                914246861, 2121339885, 1961961557, 92095006, 2260302382, 2461228008, 3993959318,\n                2950464602, 1950783601, 1224172324, 2576903297, 576707684, 4125788986, 2560012161,\n                1956729376, 1629575657, 4036954933, 300086502, 4022406600, 3237472700, 1646970397,\n                2062807673, 1759249491, 1956866526, 2025198625, 1297980907, 2709447351, 3977405586,\n                3105592010, 4167079730, 2234262082, 3282437095, 3492171389,\n            ],\n            &[\n                414354569, 1366704839, 3104154714, 3052961192, 1917209478, 527538773, 96279538,\n                131392026, 2197344782, 2544900655, 3721689046, 1511768113, 2703760155, 1445726112,\n                1858496576, 1575565932, 3793123807, 1385830602, 411844037, 2236175811, 573323765,\n                2565409615, 2461667516, 3785284514, 4260465727, 3052818977, 1895970970, 3792821387,\n                4109605593, 1615504561, 3239716852, 1706559703, 3187779838, 3278892149, 3231274931,\n                4198044737, 1513165468, 245082668, 1270047387, 3396787938, 1940745611, 3740768753,\n                2072323188, 285189880, 644016853, 3495689253, 1168360917, 2400702434, 984958722,\n                222994595, 3006232190, 2064852513, 2152929014, 1163603446, 3191172136, 1835493220,\n                3277922296, 3636603619, 1531000264, 3057499684, 3823394467, 2647235938, 1717867123,\n                499456838, 4094707383, 2454454468, 3671059285, 3201191048, 2439390676, 3022007460,\n                4061878398, 4243531226, 3389689292, 558186288, 3777835601, 3123712634, 3503180938,\n                3691679764, 1701324443, 835309072, 3906212426, 4049064285, 1768153688, 2228746280,\n                3594304220, 2961136397, 213262897, 80889120, 4109164941, 1704207190, 149603550,\n                4140450876, 835389387, 2885880052, 439529491, 1516869648, 2050960198, 926155485,\n                475035022, 1187115633, 894340078, 343754206, 3955497730, 1344991704, 598758584,\n                4056958135, 2153619389, 2541228501, 3084209032, 689848357, 1722405264, 3359713626,\n                1572612273, 740065643, 1582253391, 4070651569, 1908850964, 495396647, 4057999777,\n                3077955309, 4157175191, 2258556901, 2113839, 3880102604, 2790333280, 2943303426,\n                3912791781, 4284145483, 1840413180, 3097912758, 1064553745, 1126983800, 2256085399,\n                2448922218, 981100464, 266358012, 1971087790, 1988527723, 237308225, 1936681335,\n                4258331432, 1348277821, 529864588, 2497818319, 4244738664, 564460927, 1832999941,\n                65438986, 1185234412, 1316363591, 1608606945, 1000964619, 1732529786, 527797972,\n                150140396, 2156815817, 4220448391, 1051855867, 4280728484, 1058663428, 4250194724,\n                1036504424, 3657621656, 189944192, 57605355, 3072751931, 752978294, 1461890065,\n                2724185615, 141061473, 1466705961, 304569847, 2188875717, 617186800, 3058558545,\n                1591798676, 88078245, 623288082, 132838333, 1534710499, 2200810995, 2857112538,\n                3863089059, 3060974440, 16773497, 1918012630, 3327340967, 3661341852, 2395761457,\n                1535964139, 746843178, 4060399981, 4287382590, 1336021602, 1599090737, 1174816250,\n                481099617, 918021470, 1173582832, 1368734491, 888221269, 510154884, 1262941262,\n                2567813829, 1077623012, 2261930141, 2307570205, 2069365574, 3586190102, 1698424580,\n                615530592, 4037104804, 1283475105, 4214495193, 3288288012, 3585802470, 261207221,\n                3506861813, 1536248070, 3151134123, 645179327, 490399820, 2479385864, 3709733877,\n                396138285, 2627168580, 4028642442, 2012757271, 1884810033, 4051927252, 2652348818,\n                2069059332, 2416554871, 28369250, 1321756354, 3314148643, 2588326180, 3141604522,\n                1974534297, 4170320959, 2683069809, 1278314467, 312763173, 1481522722, 2846196729,\n            ],\n            true,\n            &[\n                2089919886, 3662797229, 1688302765, 1220493490, 974788570, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                3521949631, 142488398, 2558755806, 546733190, 2792635139, 1330279357, 3430917364,\n                206259042, 1647608238, 3662226174, 2677354502, 501681320, 3339919968, 736768019,\n                4258570929, 4202792087, 1651152858, 415339868, 1437647081, 1371825040, 1535867295,\n                1113678172, 4268196599, 2619516870, 4117420686, 2491883937, 1711537149, 3681498741,\n                487272454, 3249094136, 2833249206, 1984417080, 608254353, 2280645468, 3395986408,\n                3532393236, 285299266, 249977069, 1222542802, 1102282847, 2598354195, 439643199,\n                2126654464, 607909799, 2936741523, 3763227596, 4235714917, 1698786602, 1862433691,\n                2965568505, 2196568398, 3068583313, 2467355500, 2575639252, 3699104542, 1440347634,\n                2202871610, 1085633678, 2985993155, 1566387171, 2653399887, 3340197769, 2614511546,\n                565555655, 4058797643, 1841325854, 671657716, 560998985, 334170781, 85067287,\n                1935383603, 3452109092, 3454188157, 154367468, 3636444053, 3436201211, 2489786062,\n                1247734460, 4255062573, 1485745449, 2725636745, 3754874076, 4135899179, 2423709040,\n                392644331, 2072210265, 339068725, 3933463273, 4288485419, 4212008073, 3733609991,\n                4120877958, 1466616375, 2958829060, 83050688, 4089523843, 2719660596, 3345635470,\n                4218331277, 176804352, 2942885054, 1103429906, 1232548981, 3336211973, 2320933704,\n                2354076844, 2529582693, 3959342251, 1769056129, 3021361560, 1001511651, 766365010,\n                303546733, 2838329868, 696771802, 2198903959, 3831700812, 4192525926, 2867372730,\n                3200189248, 2637281548, 3606733360, 2672897488, 2624221199, 1766256987, 3059086417,\n                3482969658, 2697305862, 415920845, 1575345078, 931452186, 2064246173, 3556532318,\n                1127897667, 4176776745, 1103206019, 759429637, 3840446634, 2669415208, 4098858695,\n                3968696636, 474286523, 3603742455, 3683233930, 3910949095, 1016216353, 1693878242,\n                2936976170, 2258461087, 1543964790, 1257134506, 2705742284, 619723369, 2313052342,\n                1916338183, 3578695856, 2388468521, 1417556272, 2630850792, 2327790132, 3594026023,\n                1659979016, 477242076, 1948563308, 2803059042, 2392360966, 2007275313, 272222339,\n                264018609, 1147760126, 4131679216, 833601075, 1429546506, 3426172207, 1125974375,\n                3584187622, 1582857679, 1084294484, 2193982331, 3084073169, 892928835, 2823566821,\n                3544239939, 172135078, 2430777811, 1620416268, 1792703584, 2899867927, 3974701277,\n                1890638601, 3367278100, 4278027820, 3171315428, 3696212814, 1038269559, 2729624661,\n                173005716, 3652244541, 724827867, 3530325019, 2203073321, 2587791340, 1909841295,\n                1412031121, 1429200221, 3614105795, 3265396657, 1362525000, 1906071103, 1060149404,\n                2733619757, 2675449568, 3414488370, 210765135, 2800530139, 3014478492, 3230858260,\n                3409460781, 3411785589, 2543986390, 3934724152, 3235965806, 2053739672, 4085596199,\n                1563589410, 2817526968, 4048637993, 3055675422, 2173262993, 2970495556, 514198452,\n                1591956633, 3852865086, 124440700, 1002712372, 596340824, 3999538417, 117476573,\n                2037586050, 3291573274, 1511567035, 1614566437, 3821078763, 961133253, 2796121934,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10,\n            ],\n        );\n        // - limbs_div_mod_barrett_helper, limbs_add_limb_to_out\n        test(\n            &[10; 9],\n            &[10; 167],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                33554431,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                67108863,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294965248,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                536870911,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967294,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[0, 0, 0, 4294965248, u32::MAX, u32::MAX, u32::MAX, u32::MAX, 10],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294965247,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                33554432,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                255,\n                0,\n                0,\n                0,\n                3758096384,\n                67108863,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294963200,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                10,\n            ],\n        );\n        // - limbs_div_mod_barrett_large_helper, limbs_sub_same_length_with_borrow_in_in_place_left\n        test(\n            &[10; 2],\n            &[10; 452],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                1023,\n                0,\n                0,\n                4294963200,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                134217727,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294959104,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1048575,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4278190080,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966272,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2147483648,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16383,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                15,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294959104,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                33554431,\n                0,\n                0,\n                0,\n                4026531840,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2097151,\n                4278190080,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            false,\n            &[u32::MAX, 10],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2145386496,\n                2147483647,\n                1024,\n                0,\n                0,\n                4294963200,\n                u32::MAX,\n                u32::MAX,\n                16383,\n                4294950912,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4292870143,\n                2097151,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                134217728,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                16,\n                4294967280,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294959103,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294959103,\n                8191,\n                0,\n                0,\n                0,\n                0,\n                33554432,\n                4261412864,\n                u32::MAX,\n                u32::MAX,\n                4026531839,\n                268435455,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                1048576,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4278190080,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2097152,\n                4276092928,\n                16777215,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966272,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                10,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[\n                9467139676469209549,\n                590281264913108801,\n                2444597864339828042,\n                14864081623018167053,\n                17247631583397892818,\n                14553244820490552393,\n                12829855212365838534,\n                3531466761266135925,\n                11372171159031384620,\n                5870847048926628622,\n                9193240591510160396,\n                4025304033900694645,\n                17261252553070218810,\n                1960954339685170046,\n                9689788042403522315,\n                6777781555383721706,\n                564338697137211139,\n                2236230241770389317,\n                7260612298284603217,\n                7551831827404764167,\n                14240930170717885933,\n                5403113159439788814,\n                11890192816726889700,\n                4571074562843162754,\n                6585174915018781919,\n                16820621164336832115,\n                2906428786044704407,\n                14549789283221663094,\n                8574533295629171239,\n                2554371108614275803,\n                12102140726062325305,\n                5927759880327312421,\n                1947106727211751169,\n                4243634376196439953,\n                3958901784387088795,\n                11997496505606868854,\n                8614259227764305665,\n                2851316343853334425,\n                7360014330841540867,\n                12833167596911644967,\n                16420023392297553774,\n                448987443751486030,\n                1127916262354476550,\n                998365641524414747,\n                771182118275428982,\n                3644906482543632509,\n                12008471662501141232,\n                6735530311778854203,\n                14937996347189247818,\n                10310266533399488799,\n                14173112110010990829,\n                10048196983951682150,\n                7660343487007291390,\n                5442254482173747309,\n                11894682918116055490,\n                555474340707057713,\n                5454210195350763050,\n                6335921756850263208,\n                11125242160747149811,\n                5950900297278200050,\n                4972887779003626968,\n                15099558014605218082,\n                8070946285642924813,\n                5661924633602804698,\n                4017981546647826153,\n                3298784914124356106,\n                1048634509662954303,\n            ],\n            &[\n                1601810336850541391,\n                6414377018375174391,\n                919960012376992260,\n                7432535796251013733,\n                14687204344100976419,\n                4239980047441451729,\n                3419961342059496953,\n                16241811836659790563,\n                582511433240649668,\n                246415310737356671,\n                4213289580820322712,\n                6570486144808547472,\n                649071692625916450,\n                16246395526862594705,\n                5418002168615819323,\n                8787804720479728592,\n                16606257073152622475,\n                1410262373214068670,\n                2846556520446018460,\n                12702224195603835801,\n                14824788470038136235,\n                8070823597295684045,\n                10064047777457825217,\n                12473928276513608352,\n                4502242984490214594,\n                8213242804638977717,\n                11407293275124988149,\n                15303970978422100227,\n                5734015081210218763,\n                6780255848655226189,\n                5308681743121306497,\n                3590094480707706491,\n                924657275311967241,\n                13313245703725306506,\n                13755314570936606477,\n                1722612846595274627,\n                11310713460998976321,\n                17860713973992950196,\n                4832972642835413575,\n                6159638888337886550,\n                16436259186156623772,\n                8219825892743153908,\n                12825816757113080127,\n                17576561025816321316,\n                16426316569762062979,\n                7041069634919241163,\n                14958139263401063299,\n                8541928253694453091,\n                14623281385826596559,\n                5881920493887697974,\n                2856125878289959548,\n                13138961086309035424,\n                1445182795958550281,\n                989371283719803801,\n                14414401959190662319,\n                12694741659414145902,\n                4944169755440522083,\n                4850330269090259826,\n                7263731888738583042,\n                3847985956261979907,\n                10886313908655224591,\n                16884924304355496352,\n                17434369248195376612,\n                9624045826924140661,\n                9440358242723121635,\n                44413621672380228,\n                14501853932445164832,\n                4412509400967439905,\n                4059150452772511000,\n                14121559478607349396,\n                6939247432141568945,\n                9144772592231287902,\n                9035665952014395555,\n                14897716038428818227,\n                15076823799682351749,\n                16277606343067785741,\n                1901372957955104636,\n                9089098420745572372,\n                7424125507905187829,\n                12368330388186365917,\n                12778631331588513256,\n                7648700244963873530,\n                3776028467270636181,\n                16107369772612157292,\n                9046543866366629415,\n                13251838453492673272,\n                2975138303374961664,\n                2462966081502544324,\n                814917744063498594,\n                13005222969141014201,\n                5026855542811222762,\n                2382391535955253463,\n                5899528506680208740,\n                13336141787604226636,\n                2972106516856532181,\n                14045206722662122716,\n                13361481863470745757,\n                1303122885509130861,\n                2127042842590220699,\n                6185514996199626930,\n                16622745329653187578,\n                1256533115604594696,\n                11243434057073050028,\n                9066405370642929758,\n                4552716624777987017,\n                1128092841571320177,\n                3756894170446405064,\n                3328979948330012406,\n                15049042231988504879,\n                3530903968533512703,\n                17905884378428276079,\n                3713606437359152813,\n                9370125751473669209,\n                10012381228375856292,\n                6916709082927033810,\n                17606888822444197359,\n                10818646898854586102,\n                9927520028322801489,\n                17015575684851383261,\n                15287563104761130407,\n                4246630569287612899,\n                6737522138244324583,\n                16956805675707509108,\n                10507692348129622148,\n                1144006384258648355,\n                4260138925314579646,\n                14508270375905482517,\n                3559046762122289814,\n                15199903498605585717,\n                16432575538338639756,\n            ],\n            &[\n                5592822181652430458,\n                17506309594623475426,\n                14050063092843436505,\n                7714948654849123602,\n                12960251261153655218,\n                12293354553127881932,\n                18236552269356335752,\n                8116592444680865353,\n                5788148289215893900,\n                8971586422059718981,\n                7830225577778842728,\n                16542468928391674395,\n                7685364916096821326,\n                10621040870461365797,\n                13017786142160529410,\n                15623634767986429431,\n                3570280230795725028,\n                5462496964935066825,\n                13096782281304038571,\n                1028538565298248606,\n                1306240401949593430,\n                9752885768751332733,\n                16834186448734276157,\n                7637206024963845142,\n                14347989823115406647,\n                11694534965309339857,\n                17506164867360865472,\n                18226657528377127028,\n                17113377911080849277,\n                12836900580850373696,\n                7624296086468816307,\n                3241150049341673184,\n                11432625191496196476,\n                7201112746916642381,\n                14159401858377741999,\n                13042389876849434472,\n                6539044773109830458,\n                5626612565019858620,\n                16855355146181557220,\n                2896027096805100269,\n                1749121842377065409,\n                14486576285464434664,\n                13003134176160772443,\n                4520736241988979615,\n                14386190542886985088,\n                5203873393963986621,\n                2767011034432552285,\n                6993214728799607735,\n                16219726698174042484,\n                12883752315794694947,\n                4638588568194864850,\n                13671093412063473486,\n                16507766724668892429,\n                508640878850638089,\n                10821378407060575406,\n                7345992160360704865,\n                10043908069076742056,\n                18320857698273010360,\n                2218460838923946432,\n                12515547441597943704,\n                8373193888106171069,\n                11138535537637434655,\n                2449630875466873477,\n                8767699022869197665,\n                6446940169111329267,\n                12481583138381941451,\n                18405856492243480913,\n                8856983257605794349,\n                11977198292403090397,\n                4992072464455161558,\n                1429124422280954077,\n                16695629052720642207,\n                15320583853113777709,\n                9270873446273846783,\n                9544568698292818385,\n                16150036388405871492,\n                4707553634577955164,\n                12819651092171657742,\n                6194167822526464289,\n                3302239600303656809,\n                13520149877311082646,\n                3658928982143500918,\n                6938149248133961941,\n                3561482775788486836,\n                11608588618646326460,\n                9312042305619109305,\n                7752033026671842884,\n                17638989744464665362,\n                11720586895422616384,\n                17488161719714908794,\n                14359533380966089634,\n                9112047402314539693,\n                9045007769242360827,\n                14039981061261051366,\n                12161985564133395359,\n                12552005864162233454,\n                13987473146854769743,\n                18218863257920884509,\n                527093394921779615,\n                10809320813728048297,\n                9176568449151735783,\n                16181777654712188911,\n                3708863559833042684,\n                15705373009786311560,\n                12044345266545331965,\n                15745097802473032619,\n                3448641903062070968,\n                7079863925626111888,\n                10936059842602692227,\n                3949990826310278419,\n                8781569794504977516,\n                2710649351206510739,\n                8045244454460377457,\n                16793164706992819994,\n                14171071447733414359,\n                6442975288102390424,\n                13408292761208182437,\n                18190891873633561623,\n                14416452326133420106,\n                11467995109126255854,\n                10355921853391241663,\n                3362337025912778005,\n                12828210017750944427,\n                6724529289281531448,\n                17910365619735459537,\n                18061583666579344364,\n                7385510916096038449,\n                14735084634699542626,\n                2983574817812405387,\n                1160726944282883582,\n                2119364765206141036,\n                6464791768964988391,\n                8824016806539484116,\n                8270030586906660422,\n                15002907845345901548,\n                5776511587881140498,\n                8026215921305305807,\n                4715947225014261487,\n                1386404302622265399,\n                155879991043344208,\n                7029054386547293524,\n                11220489073691424833,\n                2733588115435171341,\n                5063187558440228172,\n                14208382232307280669,\n                3376720278729662133,\n                14690710213721258877,\n                11094816467682244196,\n                13929756812886477086,\n                14698847015580325706,\n                15992372099283576304,\n                5818288394714584003,\n                5038324365106419021,\n                506432342213631013,\n                7781480413773762085,\n                2275557418573742756,\n                8703301345083257514,\n                11424227525030059244,\n                8529590924998378026,\n                5577211436885609271,\n                16859602499387351883,\n                5848360527348246100,\n                2118117857825986323,\n                3178709503818913442,\n                14068618324826971348,\n                7820101807986528976,\n                16849757836429474618,\n            ],\n            &[\n                10900792384749518304,\n                1752565570529908396,\n                3402229115647561238,\n                2472381872242532960,\n                15748089475115162936,\n                1958855681762413475,\n                12100416912810779188,\n                12256578057348862042,\n                6556831077371185734,\n                15914846823057329492,\n                17346954154793811255,\n                17566187606614467459,\n                1433606366066775495,\n                9089332045922722756,\n                10056944581186126460,\n                5324425019386643029,\n                5281765195814058625,\n                1449711238109407238,\n                5903959110668039125,\n                3336955200427408551,\n                751494194154096512,\n                15350321905800137137,\n                12407374450431165353,\n                8705815621686854350,\n                18038286270431178148,\n                11671842546699641930,\n                9343865367071815679,\n                13401838367914321671,\n                18365991333043790435,\n                17428290065100096976,\n                6040216493892400727,\n                4224515713015397505,\n                16578741590625036060,\n                11835373548777581169,\n                18413478850867685366,\n                8453265724386285209,\n                5394500720474148965,\n                1927463313122594080,\n                4177838821929605731,\n                10680620304882583021,\n                180005403771618203,\n                2256408572502279608,\n                11718426532525535626,\n                14260315287467647015,\n                4035759666841010016,\n                16259497729863184485,\n                7772704202422133476,\n                6815813069474359325,\n                11207378575459431371,\n                18308033894506293455,\n                9875145231436590806,\n                15354934628544213986,\n                761822562304640527,\n                7391550101325083295,\n                4023926600201752832,\n                922969942182092752,\n                12110946035817932140,\n                16574399923422896843,\n                7087993004495856759,\n                8299428112066197874,\n                4589434828506762129,\n                13978205413565566735,\n                15675366647238478172,\n                7819770375827015142,\n                6823625407675143456,\n                2042269662440457350,\n                11521115322912473140,\n                13703874674141705702,\n                1295561690992462505,\n                12464082489717915012,\n                11378922861990148970,\n                2076282285705918066,\n                1390689690731346588,\n                13670979351308531000,\n                12980996477862222169,\n                10496970808504864546,\n                14015388605987660396,\n                4171129107047347396,\n                1656857204469415571,\n                17492457435753920912,\n                10132937897450237781,\n                5065601177732655021,\n                17498367701449356268,\n                9552937910825811119,\n                6213399497134928078,\n                12865519292113075754,\n                8548871019474664332,\n                12973212090641168109,\n                3018095992673320728,\n                4102580256148037725,\n                11411505815957245048,\n                8044142604358855954,\n                6163064685377006161,\n                7676133172626151339,\n                15177331097378985405,\n                923128391789363540,\n                8405355494789853124,\n                8409013636286216842,\n                17519952046647436442,\n                12690425880634822079,\n                7295927951214020420,\n                5103171252065286692,\n                4531269626482776566,\n                17509133779966482098,\n                16771567673323510549,\n                9940518318209913958,\n                2566490491730418524,\n                4997841530198583881,\n                11759671980624847072,\n                12804335234851198898,\n            ],\n            true,\n            &[\n                564820221219774034,\n                4488711358679422475,\n                10020082426042197380,\n                17225157352286806558,\n                5780768250525361575,\n                1970180556702143116,\n                5857604197270789289,\n                4060596445048742789,\n                4197799076012455571,\n                7044577438443748571,\n                9865458079653433267,\n                16329626967551115891,\n                4152461199188161627,\n                13000775528850398936,\n                7619420622350160180,\n                14900279174214956337,\n                1704825421557733731,\n                47372161928033978,\n                3056759021249434255,\n                16034528189533406528,\n                6435981853629992716,\n                7347416955208902363,\n                7867885339734871956,\n                16003312811447303393,\n                11973054691848315139,\n                4061237791967812067,\n                2991418391396596002,\n                4703879799196538602,\n                7912263594713072930,\n                10103623638174366026,\n                10329033596439147117,\n                17155789472068722424,\n                811379340807249314,\n                16011199724895161224,\n                3304315874218574570,\n                8105141063347209779,\n                2750621792338662113,\n                11379790872842995450,\n                3804288408313301542,\n                2401920265819467507,\n                8046761544384349111,\n                14485522278750006278,\n                13468921503494590590,\n                345391242184932873,\n                13063364294012052475,\n                9333826905573469899,\n                194256409910599419,\n                14732838482552366259,\n                1399589143134623506,\n                3979386708177190104,\n                8831973874140082077,\n                17265655065442874316,\n                12810778560618597071,\n                3646538182485961898,\n                10947011750214431344,\n                709929350993015196,\n                5828094472112746203,\n                6335921756850263208,\n                11125242160747149811,\n                5950900297278200050,\n                4972887779003626968,\n                15099558014605218082,\n                8070946285642924813,\n                5661924633602804698,\n                4017981546647826153,\n                3298784914124356106,\n                1048634509662954303,\n            ],\n            &[\n                11770973102809246906,\n                5654064914644075203,\n                14154195031168297145,\n                3196816914765589663,\n                13269534898382935070,\n                6602763211194544985,\n                16018516851544910792,\n                3180625223944165224,\n                5350941027330432714,\n                6398743157953739295,\n                1906167046060045935,\n                3556291732895289080,\n                17581917949159063577,\n                11917842024560925369,\n                5513291200181693371,\n                2805207190711928628,\n                10488935147153720707,\n                9353681503295456349,\n                11923702266366452872,\n                16445534228693736707,\n                1321572029020662220,\n                2088179387423767363,\n                2940575338916006997,\n                5660751381096282465,\n                9379032325552965866,\n                6155754375040762615,\n                17757845483758379498,\n                4791726927249442785,\n                2271154604380575561,\n                2810516188026226067,\n                17085166475121940699,\n                99572451658953140,\n                5696266492111718158,\n                10862208603440047636,\n                17394577092287756526,\n                8594037627948854376,\n                15384378431083587966,\n                8688372331869182594,\n                6898185140759317855,\n                9871173932216986045,\n                12528452101456458662,\n                13557460938391962098,\n                4450262203153213242,\n                9384263431241833822,\n                9013347668307504163,\n                11311595079831956259,\n                936915772753461789,\n                8433063029106192581,\n                16896552532247465449,\n                436920621494623275,\n                17030913520242164150,\n                9892849888317096483,\n                10846215292694646349,\n                8237341484379572099,\n                16094501558496758251,\n                1945916543779639318,\n                18090461816104963907,\n                4146339453090156488,\n                16829166437621172993,\n                3078631608488886297,\n                4439257821416126689,\n                7705380192038328855,\n                3538871580337510846,\n                13746211561839200096,\n                11905905983562326697,\n                13358208869614303744,\n                5843566918809605864,\n                9427926296554685300,\n                14598289187890400060,\n                11008519655031485653,\n                8593121017807548632,\n                9396415039249055836,\n                6268435325877250293,\n                17232661262414298575,\n                72834733148045272,\n                10210620080322964005,\n                4785045324389620807,\n                12743978039683515133,\n                1532018623508178307,\n                1626858325392940984,\n                14509988664710915642,\n                11484970178386722683,\n                9637331423956040786,\n                16727570268905595418,\n                17007646468471636895,\n                11784309337440826435,\n                8264087540904628249,\n                5386650781848750246,\n                2634849477861627672,\n                13571530405202238935,\n                957020390364360749,\n                10551951282480361215,\n                5860903308359481633,\n                7956790956638521305,\n                8737258119314118945,\n                12342128112549159916,\n                16715653993533680030,\n                16954242660912593528,\n                2489318600286989195,\n                7710331526401780284,\n                14799339212986303952,\n                15607538409164651487,\n                16839239842720015730,\n                12565794445330275268,\n                11582072386774199841,\n                7158773820903321984,\n                1329934199003039189,\n                6297267245832566486,\n                6153026408185751289,\n                3259942857823462030,\n                17905884378428276079,\n                3713606437359152813,\n                9370125751473669209,\n                10012381228375856292,\n                6916709082927033810,\n                17606888822444197359,\n                10818646898854586102,\n                9927520028322801489,\n                17015575684851383261,\n                15287563104761130407,\n                4246630569287612899,\n                6737522138244324583,\n                16956805675707509108,\n                10507692348129622148,\n                1144006384258648355,\n                4260138925314579646,\n                14508270375905482517,\n                3559046762122289814,\n                15199903498605585717,\n                16432575538338639756,\n            ],\n        );\n        test(\n            &[0],\n            &[0, 0],\n            &[0, 0, 1],\n            &[0, 0x8000000000000000],\n            false,\n            &[2],\n            &[0, 0],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_barrett_fail_1() {\n    let ns = &[1, 2, 3];\n    let ds = &[0x80000000];\n    let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_mod_barrett(&mut [10, 10], &mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_barrett_fail_2() {\n    let ns = &[1, 2];\n    let ds = &[1, 0x80000000];\n    let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_mod_barrett(&mut [10, 10], &mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_barrett_fail_3() {\n    let ns = &[1, 2, 3, 4];\n    let ds = &[1, 0x80000000];\n    let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_mod_barrett(&mut [10], &mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_barrett_fail_4() {\n    let ns = &[1, 2, 3];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_div_mod_barrett(&mut [10, 10], &mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\nfn verify_limbs_div_mod_3(\n    qs_in: &[Limb],\n    rs_in: &[Limb],\n    ns: &[Limb],\n    ds: &[Limb],\n    qs_out: &[Limb],\n    rs_out: &[Limb],\n) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let d_len = ds.len();\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let base_q_len = ns.len() - d_len + 1;\n    let qs = qs_out[..base_q_len].to_vec();\n    let q = Natural::from_owned_limbs_asc(qs);\n    let r = Natural::from_limbs_asc(&rs_out[..d_len]);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, expected_r);\n    assert_eq!(&qs_in[base_q_len..], &qs_out[base_q_len..]);\n    assert_eq!(&rs_in[d_len..], &rs_out[d_len..]);\n    assert!(r < d);\n    assert_eq!(q * d + r, n);\n}\n\n#[test]\nfn test_limbs_div_mod() {\n    let test = |qs_in: &[Limb],\n                rs_in: &[Limb],\n                ns: &[Limb],\n                ds: &[Limb],\n                qs_out: &[Limb],\n                rs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut rs = rs_in.to_vec();\n        limbs_div_mod_to_out(&mut qs, &mut rs, ns, ds);\n        assert_eq!(qs, qs_out);\n        assert_eq!(rs, rs_out);\n\n        let (qs, rs) = limbs_div_mod(ns, ds);\n        let d_len = ds.len();\n        let qs_limit = ns.len() - d_len + 1;\n        assert_eq!(qs, &qs_out[..qs_limit]);\n        assert_eq!(&qs_in[qs_limit..], &qs_out[qs_limit..]);\n        let rs_limit = d_len;\n        assert_eq!(rs, &rs_out[..rs_limit]);\n        assert_eq!(&rs_in[rs_limit..], &rs_out[rs_limit..]);\n\n        verify_limbs_div_mod_3(qs_in, rs_in, ns, ds, qs_out, rs_out);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        let test_only_verify = |qs_in: &[Limb], rs_in: &[Limb], ns: &[Limb], ds: &[Limb]| {\n            let mut qs = qs_in.to_vec();\n            let mut rs = rs_in.to_vec();\n            limbs_div_mod_to_out(&mut qs, &mut rs, ns, ds);\n            let qs_out_alt = qs;\n            let rs_out_alt = rs;\n\n            let (qs, rs) = limbs_div_mod(ns, ds);\n            let d_len = ds.len();\n            let qs_limit = ns.len() - d_len + 1;\n            let mut qs_out = qs_in.to_vec();\n            qs_out[..qs_limit].copy_from_slice(&qs);\n            let rs_limit = d_len;\n            let mut rs_out = rs_in.to_vec();\n            rs_out[..rs_limit].copy_from_slice(&rs);\n\n            assert_eq!(qs_out, qs_out_alt);\n            assert_eq!(rs_out, rs_out_alt);\n            verify_limbs_div_mod_3(qs_in, rs_in, ns, ds, &qs_out, &rs_out);\n        };\n        // - d_len == 2\n        // - bits != 0 in limbs_div_mod_by_two_limb\n        // - carry == 0 in limbs_div_mod_by_two_limb\n        test(\n            &[10; 4],\n            &[10; 4],\n            &[1, 2],\n            &[3, 4],\n            &[0, 10, 10, 10],\n            &[1, 2, 10, 10],\n        );\n        test(\n            &[10; 4],\n            &[10; 4],\n            &[1, 2, 3],\n            &[4, 5],\n            &[2576980377, 0, 10, 10],\n            &[2576980381, 2, 10, 10],\n        );\n        // - bits == 0 in limbs_div_mod_by_two_limb\n        test(\n            &[10; 4],\n            &[10; 4],\n            &[1, 2, 3],\n            &[4, 0x80000000],\n            &[6, 0, 10, 10],\n            &[4294967273, 1, 10, 10],\n        );\n        // - adjusted_n_len < 2 * d_len\n        // - q_len == 0 in limbs_div_mod_balanced\n        test(&[10], &[10; 3], &[0; 3], &[0, 0, 1], &[0], &[0; 3]);\n        // - _q_len > 0 in limbs_div_mod_balanced\n        // - adjust in limbs_div_mod_balanced\n        // - q_len == 0 in limbs_div_mod_balanced\n        // - i_len >= 2 in limbs_div_mod_balanced\n        // - ns_shifted[q_len - 1] >= (DoubleLimb::from(x) * DoubleLimb::from(qs[q_len -\n        //   1])).upper_half() in limbs_div_mod_balanced\n        // - bits != 0 limbs_div_mod_balanced\n        // - q_len == r_len in limbs_div_mod_balanced\n        // - do_extra_cleanup in limbs_div_mod_balanced\n        // - !quotient_too_large in limbs_div_mod_balanced\n        test(&[10], &[10; 3], &[0, 0, 1], &[0, 0, 1], &[1], &[0; 3]);\n        // - !adjust in limbs_div_mod_balanced\n        test(&[10, 10], &[10; 3], &[0; 4], &[0, 0, 1], &[0, 0], &[0; 3]);\n        // - quotient_too_large in limbs_div_mod_balanced\n        test(&[10], &[10; 3], &[0, 0, 1], &[0, 1, 1], &[0], &[0, 0, 1]);\n        // - bits != 0 in limbs_div_mod_unbalanced\n        // - bits != 0 and Schoolbook condition in limbs_div_mod_unbalanced\n        test(\n            &[10; 264],\n            &[10; 30],\n            &[\n                3099176493, 2686179191, 2963763290, 1498905807, 2459138342, 883505904, 186294937,\n                1240988195, 1152000807, 3485254691, 3058980612, 4051918579, 84687528, 3474110821,\n                825051253, 2495113655, 4269053297, 531158278, 2131423786, 735959410, 1116746011,\n                2099249419, 427789428, 2182383446, 3493666451, 2086611578, 2349523902, 1865831092,\n                104597580, 720145483, 1653677313, 2449086005, 1225118075, 1458687427, 2284889737,\n                1178000580, 1204354477, 1109887135, 2302764777, 1833071533, 2749496868, 3989183692,\n                3112262804, 2143914125, 71393498, 3686808425, 568295620, 856601035, 205234115,\n                617861388, 102368116, 561132401, 733711249, 2931194848, 1371887453, 2942553563,\n                977874680, 3567773306, 2225947571, 668306082, 3150218776, 3697051793, 4272816685,\n                2926797142, 2177250555, 2840203688, 51052169, 1663516163, 3085068676, 471736374,\n                3127282104, 1358199856, 250868071, 54398826, 2107868776, 1621910930, 1677400830,\n                20889047, 4180454819, 908186988, 1625301399, 817226551, 4039437379, 261787419,\n                1484678288, 1183594253, 3154399910, 888455895, 1713982625, 2925178936, 2076694919,\n                2288237521, 620657938, 2457761902, 2906110636, 649773865, 1387981473, 1600821385,\n                3512543520, 2803028516, 1584293468, 1443490691, 2589741655, 3170284085, 1902835632,\n                1603116322, 2850443356, 60694796, 779743237, 4006039758, 3272304347, 2442366350,\n                3601524312, 720808564, 3291979084, 1675880280, 4139440559, 3672978467, 3938651783,\n                3257918674, 2077369764, 3027135446, 3940308694, 2533432781, 4105883289, 626796131,\n                608794713, 810463080, 2363401530, 2800065942, 2679046183, 4063827982, 2327835929,\n                522607612, 1660561124, 817356463, 2984129158, 146372510, 4293731514, 2558750639,\n                3948304613, 1448810261, 826590770, 2423032883, 1050524737, 2770168039, 265887860,\n                3353243705, 2674401993, 1496121248, 2053790031, 1863298286, 1068977659, 2875518960,\n                4137037281, 2888534695, 473250405, 3368783492, 3797281057, 132028186, 316202261,\n                381223941, 3366394660, 425124513, 4083952857, 2301832392, 3321645917, 509444341,\n                361894284, 3976042471, 2957832871, 250836826, 1408114735, 1614725824, 4214313885,\n                4081964203, 2663894263, 145380453, 2329325761, 2055092903, 126874014, 1000460254,\n                3910319503, 2561073113, 4231784000, 1042785346, 3511487116, 1270832223, 3456586087,\n                1210528079, 4119713948, 3299598065, 4178946856, 1623358249, 1001721969, 3964704699,\n                4133343553, 2193492316, 407893767, 2484237727, 3782842008, 2959959832, 449539588,\n                2978317444, 4008576738, 3478248618, 98697842, 3986898689, 1622966191, 3594042026,\n                3280563264, 270713233, 3999415188, 401848066, 623805281, 1710411200, 1801291443,\n                640646012, 2283134929, 1043531051,\n            ],\n            &[\n                3120245340, 1558358768, 2311090615, 3377497278, 2047683134, 1453801550, 1974940808,\n                1545066418, 2840151982, 2463969682, 2025473894, 697610529, 906262319,\n            ],\n            &[\n                3603474202, 23640019, 2133576502, 3778379659, 883962915, 1866519837, 1888919496,\n                2545522706, 1473641504, 1017307414, 1207107908, 43613763, 2001107652, 1295816376,\n                3276720994, 750683734, 862054731, 2423105118, 647184565, 82749472, 3134905644,\n                3469243304, 3869523273, 2200822282, 2271529456, 1805512365, 576197860, 1881352922,\n                2694444088, 700188823, 4014261501, 998600230, 3921476919, 3042342458, 1113168589,\n                1849643027, 272533119, 3745240014, 846408292, 2765600200, 337759056, 1580016038,\n                958561971, 2320387143, 2022805900, 1706525297, 2849929806, 2816448769, 4287480228,\n                531300416, 3987101730, 2194947684, 1539543472, 2563500078, 250905437, 2906546975,\n                3420715312, 1399943972, 2573547036, 2517309835, 3506368432, 609682764, 2647408356,\n                3234556565, 4224842927, 440117919, 2582391054, 3173478111, 1215556799, 1989776959,\n                1675806417, 3878920467, 243984561, 272254140, 815747813, 2471627048, 531500590,\n                126500733, 3476535401, 1877907075, 2939545031, 4041939245, 626658366, 2742940646,\n                3814661399, 3153036624, 2080267727, 412913879, 709446334, 1928720530, 3215012198,\n                1340243607, 4170012693, 1863453653, 1692829830, 3479433296, 1015591610, 2369310060,\n                1289466663, 1652392162, 348688115, 2813901666, 1381977739, 3968353944, 3449363379,\n                1249293688, 2453835214, 750904326, 577039386, 3965310144, 1188022514, 552527181,\n                2964971453, 1145764708, 4147965668, 632850159, 2337487248, 3382593879, 3632939001,\n                2658993791, 2820040018, 1556252114, 397274557, 490831003, 1052830763, 1914107101,\n                1353387689, 2482075969, 976484162, 2282876383, 4269190628, 139809131, 1188730299,\n                1650745941, 2014147322, 1678125742, 223161009, 123908503, 1950841716, 576079068,\n                3330988019, 932533018, 1319346982, 1356010466, 1972839391, 3937944592, 2091834184,\n                3610099681, 3420417182, 182310440, 651615236, 1741788918, 873416547, 99212541,\n                4107741571, 15809533, 2996576548, 1121127050, 2786591053, 2205830989, 3933647253,\n                3009211397, 2474199526, 616438769, 217585320, 626425556, 2196061289, 2231311076,\n                2237166829, 683712700, 1232727911, 2782798599, 2626930217, 3593762186, 2432346581,\n                1165370034, 134611782, 343289563, 4182953926, 3066331256, 1857734341, 132757904,\n                2635310959, 1313863984, 2215899094, 2574941352, 2348626035, 2950919138, 181796835,\n                3322669423, 3336363510, 767753600, 5374509, 3674971984, 1030279018, 550713284,\n                1341338555, 3995296635, 1696197965, 1833947598, 4208080450, 377211595, 1040418139,\n                1967465586, 998434750, 2027799751, 650545326, 1, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                4239744213, 626950715, 3916878897, 2974637695, 488695410, 1094975104, 2496621051,\n                205419221, 4192241096, 3583664917, 511224033, 2016541230, 718692763, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - carry != 0 in limbs_div_mod_by_two_limb\n        test(\n            &[10; 148],\n            &[10; 215],\n            &[\n                59488434, 3053025912, 3197673861, 28499967, 919132002, 3254889605, 3510992086,\n                4155414397, 1401076337, 3663475665, 3859836963, 838452584, 1714061888, 756807500,\n                721664913, 2122189093, 190377396, 772161692, 337532878, 2801246946, 3347165247,\n                504261973, 4207433768, 3203836949, 1637702776, 3950126612, 3575550053, 630469114,\n                2468674532, 3237190898, 2699368075, 2126693510, 2005217541, 990977199, 211751826,\n                4095342386, 2390539499, 553381774, 1202910267, 3124334908, 3631027545, 3118560130,\n                3505258080, 2533393565, 3897399802, 1644233433, 2966724466, 1228506720, 4266980301,\n                1975806255, 3087455989, 430105567, 2496389669, 2559019944, 1343075842, 515604272,\n                2623722375, 3549762134, 3517683279, 3564893038, 3816995397, 21727446, 2930818039,\n                2672793843, 1589653728, 2917937865, 665591277, 1222288512, 1197537333, 2425822187,\n                3647080994, 3180811677, 3800694132, 4006852228, 1392314914, 1823809919, 3315974102,\n                2004045597, 2557007205, 532899885, 1088861606, 3969820933, 711573681, 3744617855,\n                3618206965, 3834838995, 601286347, 1494520421, 2007503431, 3672534190, 3437739925,\n                3075991743, 1108097829, 438830502, 854842946, 798336207, 2497251014, 985928236,\n                1930130581, 260199427, 3446617597,\n            ],\n            &[4005818469, 1809723722],\n            &[\n                3451340519, 1823569360, 2748474762, 2379400860, 128212466, 361580627, 4041171442,\n                914389241, 3615201878, 3760016986, 2510499050, 3863385767, 36040042, 2251851610,\n                3210062577, 3672600394, 1663820028, 3073274096, 204666796, 2644054989, 1349439868,\n                1510081385, 286811203, 2996214643, 52859440, 3057966118, 2864727410, 1423659659,\n                1075210206, 3609454422, 3252263523, 2843960331, 927166023, 951309132, 672342687,\n                3596154210, 3997816532, 417627069, 1674501808, 3480074829, 2081711134, 3258035904,\n                1912656239, 2929955725, 1760162477, 3439128620, 3247428686, 2554948803, 1823534619,\n                2390298418, 153525011, 2577068170, 2912027555, 3356439173, 2878222520, 3673969868,\n                1465531030, 2707072452, 840674665, 2018453620, 3959489183, 853967262, 3462469779,\n                4149541196, 2692208503, 130843211, 2074716794, 2092443671, 3814231863, 3497057086,\n                3471416493, 1131939280, 2342388876, 299693157, 3210385182, 2920296477, 565691872,\n                868167224, 3148093393, 1215844287, 3565781208, 3578206636, 1537052552, 2438538598,\n                1664889116, 1383231686, 4042617071, 1777130014, 4179189376, 1391393677, 3822307038,\n                597944414, 2695354041, 2634181099, 2054915922, 810822072, 2370856623, 1541755236,\n                3884794992, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                1137651599, 55996911, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - bits == 0 in limbs_div_mod_balanced\n        // - q_len == 2 in limbs_div_mod_balanced\n        test(\n            &[10; 373],\n            &[10; 178],\n            &[\n                3300759985, 47489222, 1596412201, 3681499224, 721942549, 2798268772, 1725678834,\n                1018213306, 278963757, 2162182910, 4238919550, 1480123217, 3550714331, 2714414047,\n                1584331762, 3790545549, 2452172382, 3823866136, 3793112677,\n            ],\n            &[\n                2532879920, 749327979, 378994598, 3512427187, 1768486327, 874381062, 3750599339,\n                1824619676, 4102262081, 3872688397, 4080392661, 1233784995, 3967512105, 536874,\n                1334357500, 533131065, 3802334171, 2688028352,\n            ],\n            &[\n                1765718367, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                687097313, 233246948, 2670005176, 2918696316, 2059690051, 3559547370, 982825692,\n                2828616847, 3397764024, 1640472335, 1827782800, 239756415, 4169556349, 1129911247,\n                2514993175, 2469589340, 3137350801, 1512435665, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10,\n            ],\n        );\n        // - q_len > 2 in limbs_div_mod_balanced\n        // - q_len < DC_DIV_QR_THRESHOLD in limbs_div_mod_balanced\n        test(\n            &[10; 4],\n            &[10; 6],\n            &[1, 2, 3, 4, 5, 6, 7, 8, 9],\n            &[3, 4, 5, 6, 7, 0x80000000],\n            &[4294967057, 15, 18, 0],\n            &[718, 910, 1080, 1286, 1492, 2147483434],\n        );\n        // - i_len < 2 in limbs_div_mod_balanced\n        // - i_len_alt > 0 in limbs_div_mod_balanced\n        test(\n            &[10; 3],\n            &[10; 4],\n            &[0, 0, 0, 3, u32::MAX, 0x80000000],\n            &[3, 4, u32::MAX, 0x80000000],\n            &[u32::MAX, u32::MAX, 0],\n            &[3, 4, 0xfffffffc, 0x7fffffff],\n        );\n        // - i_len_alt == 0 in limbs_div_mod_balanced\n        // - !do_extra_cleanup in limbs_div_mod_balanced\n        test(\n            &[10; 10],\n            &[10; 10],\n            &[500160962, 3482059973, 3833374734, 2382534866, 7345183],\n            &[1962915382, 2761901894, 931109938],\n            &[4192427024, 33881415, 0, 10, 10, 10, 10, 10, 10, 10],\n            &[3497463394, 501014622, 297308821, 10, 10, 10, 10, 10, 10, 10],\n        );\n        // - ns_shifted[q_len - 1] < (DoubleLimb::from(x) * DoubleLimb::from(qs[q_len -\n        //   1])).upper_half() in limbs_div_mod_balanced\n        // - carry in limbs_div_mod_balanced\n        // - q_len != rn in limbs_div_mod_balanced\n        test(\n            &[10; 25],\n            &[10; 20],\n            &[\n                3406830026, 653096149, 665840651, 3475733215, 2990001405, 3962996135, 1125790437,\n                510807273, 2268497988, 3801098676, 4251717337, 4009243500, 3093915781, 2221063229,\n                1145961534, 1520950302, 4156341537, 4051749345, 1887697916, 2938053362, 1317017771,\n                2551451381, 1165783725, 1692722530,\n            ],\n            &[\n                757200076, 1850648953, 1310285965, 43796838, 2811750593, 2350568971, 1162649579,\n                3588922014, 843685186, 327689313, 822131258, 632127361, 4287259347, 855554137,\n                2978907761, 2140676852,\n            ],\n            &[\n                1485327588, 946067489, 2418948212, 1981289301, 1964021912, 3125032408, 3497971833,\n                3396209894, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                1472562202, 467285767, 3874015352, 3774608073, 3547803297, 3252310888, 379016022,\n                3915526178, 172347662, 1424794357, 2354655682, 1763403834, 1622341466, 1527845266,\n                321699454, 1968063162, 10, 10, 10, 10,\n            ],\n        );\n        // - carry in limbs_div_mod_balanced\n        test(\n            &[10, 10],\n            &[10; 3],\n            &[3156053040, 2869923590, 2300216426, 1369503],\n            &[177914576, 1102898054, 1547778],\n            &[3800268463, 0],\n            &[0, 0, 0],\n        );\n        // - divide-and-conquer condition in limbs_div_mod_unbalanced\n        // - bits != 0 and divide-and-conquer condition in limbs_div_mod_unbalanced\n        test(\n            &[10; 674],\n            &[10; 255],\n            &[\n                4077004042, 60445643, 361888880, 1370511290, 4140611, 1545574856, 337863511,\n                2696753299, 882513095, 2220102704, 4040224968, 3895008884, 3144563393, 2298197836,\n                2781817257, 1704369652, 3931316078, 315544063, 3497851423, 3664143565, 952326443,\n                3938628137, 2331019960, 3709840874, 886597817, 2718223965, 2271519236, 1069952925,\n                2973484971, 694036791, 3948658826, 1091836994, 3976014345, 2590014773, 1030558914,\n                3050284515, 4064531951, 227487465, 1614818201, 2853653798, 312516670, 1131265287,\n                1079324522, 2790732553, 2857570668, 2459258033, 3676592728, 1861660079, 3846516218,\n                2487383610, 820186200, 670229005, 795815915, 4236865449, 388462685, 3530199852,\n                4067109237, 228011739, 3243897206, 2102622551, 3066279582, 2307396469, 3918457987,\n                3177100158, 1165801255, 3470877002, 730654273, 225744395, 303984647, 71923315,\n                2631641933, 642193977, 214491076, 4083126324, 1300818039, 3145270519, 3071074628,\n                533164498, 2260983885, 2398373112, 2291850622, 2549903002, 2876921663, 2087750942,\n                3012568578, 2072377257, 2300996389, 1724754966, 3663537905, 2452259556, 681943280,\n                495483009, 1806854180, 2022877157, 3545541285, 3155213185, 1520127898, 881038528,\n                2682219847, 2061051159, 4091777429, 2973569703, 2243163157, 3812478845, 2868568231,\n                538252316, 915738068, 3645567840, 557499318, 586868707, 334386881, 1009292772,\n                9683309, 1394382805, 1469121902, 3538152891, 192398621, 3298083372, 291538032,\n                454155529, 3467440904, 107593274, 2581455983, 4068643130, 1289926312, 2620830750,\n                3599696168, 845286964, 93649777, 211929373, 405469122, 2046160625, 4269019707,\n                3153165259, 3273675158, 740768718, 1724953971, 4107531497, 3669145824, 2308427932,\n                4057339865, 30691770, 4215434099, 2209368084, 3410096812, 3930010459, 4058257897,\n                1401228000, 3205298856, 919645629, 1080800085, 3531478127, 4244298042, 1920158944,\n                4150416695, 2942997287, 621554087, 2193963845, 3535984780, 1948458592, 1237268195,\n                4059838770, 4178023707, 2225635923, 1078133440, 1904752780, 1129557671, 2721601376,\n                3991770285, 2491529378, 2424674576, 4164361438, 1566434777, 3112804218, 2185237562,\n                2557399204, 967876237, 2243639679, 2436745635, 2376273731, 3848434966, 1970386149,\n                294413738, 1420657192, 694358663, 647017168, 4094657777, 3013362236, 590143693,\n                2285757920, 2393504081, 116938458, 891518480, 696284131, 2710811430, 3317562620,\n                1647436225, 1605219555, 3358343198, 2183786684, 1105785201, 248367120, 1398964063,\n                3309346508, 3273593185, 2032930327, 2675472140, 557577078, 692086759, 1588022257,\n                1734092444, 927029618, 3696557822, 3370092072, 2151067302, 2650483754, 3670460764,\n                2763985465, 1126450086, 3029345718, 1504895755, 3694166108, 578785502, 294874178,\n                110079616, 1327583117, 2661938072, 2345632606, 3722933355, 656745495, 671269721,\n                2346516327, 1169529001, 4238866211, 949351039, 3500460463, 4199863511, 2082398726,\n                1281275042, 2560151133, 1138051905, 468589983, 727511715, 2554428159, 2014177155,\n                3346720979, 1317583392, 1714879892, 4249909774, 2158352329, 3040382616, 964600510,\n                319055149, 890296957, 2071841867, 2811829970, 3945344817, 4075668231, 1336582250,\n                1632615222, 2996499016, 1247703908, 2161089989, 1757474064, 1957983140, 2427088146,\n                3819098678, 1414774317, 1685786700, 2842967660, 2434489739, 2748571761, 2393986575,\n                585646425, 733271380, 4096908487, 866235842, 1811304066, 2337315068, 4064326552,\n                2517677609, 595634311, 929413085, 2556167349, 2814648343, 3447175234, 4171314821,\n                3354462286, 2190450759, 3693163187, 817168953, 753817804, 2679932775, 2584000650,\n                511478235, 2858863655, 2320104001, 2367392444, 1724096919, 1152655320, 3131579385,\n                2076635048, 3557452129, 3931367674, 1011051727, 3910860016, 3742755232, 3977120817,\n                178461096, 1938068862, 1480470517, 2997286985, 196403685, 3581556360, 3800228840,\n                2583177118, 3801520456, 1254931401, 3392702841, 1046934176, 412728369, 2864978525,\n                970771733, 672204372, 1528132877, 2673063996, 740759188, 1840165684, 1821213771,\n                3111387733, 2386566079, 2682984985, 808050061, 4160818440, 1656303941, 2884647798,\n                3997066586, 3727980283, 4181671626, 2736389654, 1808865173, 1642983278, 875419327,\n                3960909969, 3751011271, 2807559080, 1535615269, 2321637137, 2745054513, 3020092780,\n                1359015906, 2466514344, 591997660, 2754906030, 3487658632, 3722637404, 1613546148,\n                915678357, 1842708127, 701921987, 1207101857, 1974760740, 2410755764, 3324705651,\n                3105821672, 335929431, 1887715703, 4035171395, 2815003797, 3632947325, 3664189665,\n                2211203246, 1473602679, 3802261181, 3699100807, 3964975584, 2757250875, 3240191191,\n                3824907808, 1582581356, 116402974, 2321914135, 933007824, 136161346, 2857937718,\n                1044097090, 477414473, 3966936277, 21169877, 2518410639, 1938987054, 4164953085,\n                3287593768, 96004465, 3316812094, 2635456314, 2931969475, 3535012794, 3954299175,\n                4188146823, 1054040153, 4020697192, 3043463112, 487456176, 1536604607, 2191156801,\n                2869189759, 650124563, 54254415, 910946976, 3240585021, 4240104628, 989174439,\n                3235043341, 607641178, 2910679971, 4072297259, 2664931864, 2560203429, 3992282762,\n                480443057, 3944140064, 1601223002, 3984987075, 3894479377, 1082591102, 2444518988,\n                2566734417, 1272094512, 2581007089, 3838472665, 2810473520, 1590808097, 143027202,\n                1667662742, 3686892725, 228309572, 4091365295, 1107025920, 938240502, 567559985,\n                2237721627, 1939039548, 3053102548, 3379831217, 3536253061, 1586694963, 931323468,\n                593457460, 1981974171, 443146100, 11888347, 2403661012, 2646485528, 528884126,\n                1040587284, 2828170682, 512577110, 3534338212, 1642316111, 124785841,\n            ],\n            &[\n                3924577409, 3801138880, 2554871927, 1797946680, 1773117295, 3509783608, 281892096,\n                2358224613, 4217828194, 1339769957, 439570060, 3151617679, 1384372613, 4141908033,\n                3034076248, 201556707, 1940999750, 1134129834, 1062995144, 3653931665, 1653789920,\n                2219526834, 849219893, 3448402897, 890163003, 378127096, 3324725657, 2858888153,\n                4101277783, 1736762052, 4083759525, 1398269743, 946713296, 1332088349, 1241448676,\n                820326205, 1554372778, 2902257209, 2531752530, 593903741, 283370156, 1184475111,\n                4048000423, 3262885223, 3065903568, 2181798675, 970937186, 2831985588, 3318099557,\n                125775489, 2602810229, 1265835529, 370295842, 3885440035, 332195328, 803805465,\n                2339766805, 3074827324, 176637217, 2717782694, 3228882886, 2079180306, 1985828369,\n                1451458086, 2647399511, 653380804, 2816232893, 580123271, 1284828784, 1488365849,\n                3992136885, 1712696753, 3200712671, 4019248351, 2502831049, 3353947366, 3805407296,\n                3975182552, 1255379188, 3079539536, 2754826248, 2654365805, 1932758080, 2018940849,\n                3987435655, 2107608701, 1979416324, 2553264951, 2332482333, 3854067399, 7383141,\n                2032883058, 209316404, 1509786266, 891329562, 2446773803, 981357189, 289424276,\n                1563495883, 1124421740, 4019623418, 229810471, 1293459273, 685378813, 763089605,\n                543868756, 4294383498, 4256223402, 3521141578, 1300426165, 4203249157, 2446225842,\n                3483103616, 2930204118, 3459214772, 2242535858, 2845721016, 2523036196, 1191008269,\n                1438983871, 1990994626, 1369473842, 3325530252, 2436280648, 3247037040, 1827745637,\n                1440370214, 565710731, 918521819, 3174181412, 2021188910, 1292274207, 3161583133,\n                1940037031, 1320244184, 1944735324, 1624924970, 1914256377, 1558283566, 1557557944,\n                819014915, 3477749819, 2317549528, 1815788616, 3410581584, 865672422, 3902451420,\n                47231850, 2052078859, 2128580726, 2861615294, 2875806926, 2504678981, 2922243612,\n                2567002225, 3176460060, 3501319351, 256937154, 986867411, 2877370533, 3829593455,\n                169449010, 1762966206, 126552381, 3303194639, 437611604, 2065984359, 215674808,\n                2549495983, 226202732, 19733282, 265226462, 732006741, 2011526642, 2592527346,\n                3141322109, 980881336, 4085884669, 2038689570, 3704380296, 1688979285, 1869912321,\n                1472588169, 3395855158, 2409096192, 2603014340, 2571643809, 1244430574, 2331499515,\n                234553812, 3949996932, 1906820531, 1849149876, 4204335779, 1113287279, 1165814564,\n                3834491692, 3992932111, 1545656810, 1251393152,\n            ],\n            &[\n                1794394879, 681672307, 1749784971, 3875852290, 2605775875, 3830937493, 1776664153,\n                2164658304, 3052389122, 121103990, 2532311556, 2668274136, 1883610764, 747104693,\n                408690547, 2248739723, 259855129, 2934993883, 2176924250, 1485355327, 1127644750,\n                856342931, 303483764, 5142053, 651773086, 625244098, 2731424936, 2350150371,\n                112631240, 1275290840, 4277356426, 3524679625, 242960953, 38072741, 2625824106,\n                3378716297, 2200097651, 3700674881, 2915988853, 596256955, 3040402748, 3720241079,\n                1756922775, 3093790065, 1609216017, 3777740724, 3784972477, 1832540396, 3490124554,\n                1020072047, 4238953885, 2842509290, 1000994976, 1809915247, 2550234689, 278010821,\n                2286612383, 3355766530, 3432337462, 2193122316, 1639147782, 3225990501, 208759694,\n                998787272, 1642795010, 1560281600, 2893662837, 3412088625, 1789543945, 134279791,\n                138110696, 3588552537, 3112564659, 3163154447, 877493420, 3664273345, 2755762243,\n                1258332153, 471466382, 304823311, 4211933030, 2150727708, 2218469374, 2393674811,\n                1501890427, 196739488, 341729196, 1105616285, 1176146479, 2705538889, 3565383221,\n                2299341008, 1060768503, 3218783689, 1009846994, 3473661394, 397249216, 13506754,\n                3621623374, 3497151661, 2898512014, 3630774848, 1935370085, 4267120880, 4135899051,\n                1799409148, 3505276358, 269078904, 2454901039, 25026941, 3541071795, 320224295,\n                25570166, 3637410887, 3066266074, 1551849913, 3855206886, 646778908, 3499920598,\n                1807392173, 2974658193, 3899170154, 2028217657, 223895356, 2694366517, 2696487317,\n                1259241092, 1452450347, 2872701257, 1465266387, 1227664185, 1852988079, 3265840174,\n                1314955140, 4073824270, 3212823909, 218445285, 1520746645, 4031847794, 3149615466,\n                1274808703, 370944499, 1824664178, 2735686429, 266060777, 3448762326, 53610860,\n                2123530021, 4143115834, 3225521174, 4010735833, 2635569855, 986902780, 122656384,\n                1339558267, 1284193679, 2736231797, 2963307804, 1626189148, 1233185099, 4139608947,\n                464077508, 4046285469, 2555743157, 3580743777, 3735247525, 4127955544, 4010576069,\n                1345310021, 3320552976, 3399711244, 3850568096, 1644768234, 2092743449, 1307520618,\n                3326695560, 649696140, 702848925, 138141565, 644912687, 2425292401, 1411631036,\n                3440461177, 3328837680, 2755185884, 2989552286, 2790272888, 3664124418, 3269945962,\n                2604287363, 1618340662, 3679959200, 4050805993, 1339789151, 3336692676, 2115818874,\n                2085307949, 2292717793, 3240684688, 2542744650, 2126759311, 399221966, 123686284,\n                4172595169, 3670712777, 2379819943, 3438823735, 3774292021, 506637095, 1055885463,\n                25709264, 3995986987, 742675655, 349888342, 3977445313, 3680517912, 4131805201,\n                3892493076, 2099913466, 1704689141, 578202598, 982472653, 3353811282, 3106111697,\n                2102812484, 1381551617, 1645348055, 3743699078, 4026522120, 1465113716, 2586289393,\n                2164999569, 748805860, 2837286220, 1641999730, 4171579513, 3835462317, 3732455291,\n                876396979, 3868206280, 2846621181, 3305441853, 3080114558, 1862673159, 2378144974,\n                3952061855, 1185723458, 3653385196, 1985735779, 847725020, 3859801001, 1049156371,\n                1895793200, 1830383465, 746355981, 281226425, 692646446, 2574915700, 1101022556,\n                3422609839, 428283554, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                1301325451, 2202463531, 827674839, 2990077551, 3515177881, 1362651403, 481136630,\n                3397298241, 3518449263, 76128572, 4225087952, 1094548681, 282440964, 1243437992,\n                2536206935, 1312305087, 2350135248, 1191467757, 772049416, 1651785710, 13757971,\n                4177684085, 4225218737, 3829973687, 4224488792, 835349925, 807373018, 2003072240,\n                1998180420, 1893011542, 2772647530, 1845722545, 3927750947, 1582656468, 3929302887,\n                2309901890, 2219253077, 74452907, 3721812597, 3102504646, 1837697683, 4169869788,\n                1109227870, 1893389948, 1637025892, 401123956, 2362840033, 3249816285, 1331916977,\n                11330013, 1790389738, 4046514714, 4242300773, 386281183, 4154390602, 2907471583,\n                596332521, 1031920105, 1416982457, 936732589, 620289351, 2021344934, 4134683536,\n                254271151, 3153428294, 2775130118, 767392350, 1524517878, 1803212363, 1935475282,\n                476597337, 1665283842, 385826494, 1418089792, 1583155781, 904332458, 2167494919,\n                4213977373, 2749948942, 1366862995, 974249813, 2151831423, 2426239456, 4154619782,\n                1909704093, 82889380, 1836307000, 1860128761, 2497608852, 302875545, 2512570768,\n                3465381901, 3664521586, 2113690348, 3208498261, 211553098, 1122435807, 3989762258,\n                1790955068, 1274985561, 801567833, 206607829, 1945509947, 2689438654, 630881630,\n                3166357111, 950757161, 2525660644, 2782583030, 2082925684, 4017471838, 2770389652,\n                3152723497, 2730012549, 375610667, 331640140, 3189394626, 1169047456, 1269402316,\n                366259196, 659129976, 1835642575, 1109092533, 1409510258, 1055228915, 3865844484,\n                1951513725, 1561115766, 1535328235, 566121235, 1218990885, 2397023975, 110038834,\n                410651474, 2293988363, 1341825237, 3049031992, 1068909343, 3433095008, 226980250,\n                234888265, 3753182189, 712474545, 3392300015, 358854770, 2053632965, 2314494072,\n                3270641699, 1763895670, 4027033942, 3610557903, 1952033954, 3311300088, 2108677074,\n                2293958755, 649449413, 1137877459, 1632674803, 3368118971, 4027363661, 3533599056,\n                4112294692, 1992613374, 2157460184, 2344709644, 3126961604, 3915648450, 163946806,\n                3452706048, 3278493797, 3569418312, 619110361, 1791108219, 53432167, 1675611199,\n                3468608269, 3380246190, 3977636639, 2303818017, 2959386722, 4259696814, 2826759181,\n                1786462977, 974733518, 2879253522, 3102475706, 2731858652, 2537398244, 2096104946,\n                3000514581, 821433471, 3175348116, 2836803346, 3386301193, 400757797, 3528093517,\n                689295706, 494008951, 3664544857, 1053036864, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10,\n            ],\n        );\n        // - DC_DIV_QR_THRESHOLD <= q_len < MU_DIV_QR_THRESHOLD in limbs_div_mod_unbalanced\n        test(\n            &[10; 62],\n            &[10; 1098],\n            &[\n                1563750116, 2761722522, 2234492700, 664378669, 2289696554, 166287485, 476834844,\n                2920420087, 2528304999, 1938173917, 3950825207, 4243596790, 2986888741, 3513584208,\n                1621935302, 3010962100, 97331004, 3497602837, 3156993605, 4246943277, 3773399914,\n                1791046376, 1330596670, 2066725731, 3080890361, 1411737887, 1547876370, 3080590448,\n                1532248923, 1435492412, 3448185497, 1125870178, 3236487585, 411921826, 2813696973,\n                3217407722, 3223519146, 3065092232, 2369951103, 2509352358, 926337125, 3014682136,\n                2966028824, 1505359010, 1713762975, 4092602064, 637732943, 1302647295, 2902550792,\n                889992967, 3865589903, 1419953312, 9792449, 3415320263, 564771153, 1688162383,\n                2484779041, 309493832, 218454065, 3482805065, 3854968150, 917520015, 394395502,\n                1316087688, 4013170326, 3611139371, 3969996396, 845435642, 1250928392, 3564637530,\n                3534519817, 4193257039, 1210838207, 1018604374, 1039438522, 3241956599, 283401613,\n                3791643370, 2495704071, 2807365421, 66163757, 3720427495, 929326153, 1056427022,\n                2224017890, 3983649303, 3242577483, 2252715700, 3763817420, 3945056819, 2536219802,\n                2347365037, 1332467980, 932313386, 1344905435, 1546705437, 2064541576, 1511380419,\n                3830839286, 1360902083, 3503290266, 3917441903, 1833414880, 3943874358, 1755117544,\n                2923194969, 2839238526, 1436154878, 2022570233, 2627252135, 514344885, 3629007310,\n                2734265902, 3693108522, 3208247898, 2234133971, 1972552128, 2954899309, 2020593517,\n                2046949131, 3731357545, 1937584680, 3590346900, 3944796673, 1847972007, 2243279972,\n                659814707, 354026232, 3897554349, 2861167827, 616720453, 3566033773, 667580062,\n                2925065641, 1209421025, 2590558623, 4061392256, 1200913167, 951116272, 3677973046,\n                3503505276, 3890324717, 588682794, 1822470598, 3062466072, 1622960923, 2217967478,\n                1671943310, 3797078111, 306673750, 416365363, 1127402537, 4051830565, 1295357578,\n                3597600014, 3944475003, 289083572, 792152829, 1866204223, 154676033, 1521441452,\n                3508161103, 925444108, 1492828246, 661274700, 3234551268, 2848116256, 2684114954,\n                1278505794, 1135004416, 1528837298, 903435517, 897822285, 1306717602, 1475128383,\n                1820901356, 1682104357, 2694156349, 1295051939, 3518824442, 250688398, 2216356021,\n                3513738778, 1822646861, 2230691522, 3766112863, 615919379, 1974329303, 1351423644,\n                2477642991, 1213629777, 1378792281, 2617577340, 2140073178, 2191340227, 2566413020,\n            ],\n            &[\n                3993985187, 418743558, 1313360511, 1682822200, 2190606963, 1153956890, 2732042229,\n                1286070126, 662863720, 4186279397, 540453600, 3865675059, 1267823400, 3515598059,\n                2652841176, 1202274130, 1747727592, 4024332644, 1774850346, 681999022, 3602470822,\n                2758087563, 1879963947, 3431635945, 246837220, 425774791, 1105979956, 2942553343,\n                1698889280, 2350552370, 3068812671, 3185616175, 3088938498, 878065968, 4173406915,\n                3359260462, 3381157370, 170884832, 4229318755, 2494013993, 1549083413, 4140845217,\n                4084551031, 3363271174, 234069829, 579586268, 409399673, 3823445787, 644521777,\n                2518846537, 536802144, 2920279334, 18872050, 1166062818, 330384075, 567479240,\n                242105288, 2256634487, 2099809688, 3182064703, 3455323968, 3796049588, 913224553,\n                1273986744, 1216752331, 3471953608, 4141617369, 113668956, 2271813874, 3836046471,\n                1442113087, 1985184453, 1605355495, 4002876308, 3555195054, 1327862010, 2467826608,\n                2786784068, 2229364499, 4162880057, 2362120653, 2428764072, 3253302211, 4041072194,\n                3342725375, 5091414, 4236090390, 645428080, 2998645452, 2029624491, 56740124,\n                2165228859, 3087533984, 1636492749, 2209776976, 3692581237, 607934780, 2356087899,\n                844604833, 3795358717, 1191407440, 2348446542, 2260870238, 3095317646, 2239633241,\n                1510395276, 1414456297, 1992793921, 2093060671, 3555947012, 2097207883, 2341507439,\n                1797902178, 3894103463, 589765482, 4279776370, 1462654158, 1306903445, 2072601153,\n                2881422521, 41492691, 12234573, 1317588012, 460035424, 2087095783, 1325294692,\n                639610198, 163158835, 583584804, 2753511772, 3964488699, 2486983401, 2238895215,\n                1588375790, 2681620680, 4165955199,\n            ],\n            &[\n                191160977, 1213228253, 1438665503, 2959833037, 428771185, 3495423600, 919673997,\n                3884278974, 2821606108, 3332861208, 2205644743, 3483267644, 3604026186, 2215417553,\n                2139152976, 746332817, 1763682853, 1100669552, 495776985, 2816532175, 2063832600,\n                3128459671, 3849765047, 1543117375, 4168563146, 912783864, 700345848, 4172185590,\n                3008292117, 4097449922, 3103811732, 3816126299, 2071211439, 2427293197, 1964661455,\n                1195541057, 490289276, 795794482, 314985500, 672557932, 539503340, 2302303785,\n                1102570205, 3216815566, 2112797258, 2783671087, 1390099077, 3312724493, 908130100,\n                1220098318, 1193663953, 1149221829, 819778349, 3289614534, 865016664, 2219777967,\n                589857044, 2513517779, 639503753, 2645890189, 0, 10,\n            ],\n            &[\n                847465617, 4013314980, 3846912964, 910246757, 2972404216, 2762134840, 1953196515,\n                4029750073, 4055861164, 1261155057, 4100430088, 2785511074, 497236120, 1367918422,\n                3738577206, 736241263, 650868678, 2349520844, 3387563635, 741561301, 2423229549,\n                2724745547, 894805326, 2982356553, 4201925489, 3718492797, 3268940283, 1316855216,\n                535979702, 1867135512, 2894454664, 1953954059, 3331547089, 3629484636, 809197002,\n                3453878941, 2710176999, 2236099000, 2474407754, 508610082, 3021250908, 950343151,\n                2347617926, 3116087366, 387686701, 1840236979, 608794169, 80987566, 2929948001,\n                3099591933, 1498594442, 976518465, 2412591727, 4182908032, 3079365048, 2450010282,\n                2281968581, 2243779001, 309401913, 3783895152, 2093682035, 2006514294, 2836109544,\n                964684103, 1645279117, 3042605589, 3518893342, 3753614018, 3245078642, 976146102,\n                470909372, 417907929, 584991811, 4141480919, 3596625836, 3530716922, 1149488478,\n                595234233, 353336372, 638993563, 341110766, 984515266, 1262652725, 843520981,\n                594906936, 3922870845, 2571018879, 2329734185, 4233366705, 2923004114, 168356226,\n                666545721, 3625364230, 2627653737, 2717371138, 3344260869, 893744508, 407453169,\n                1376334915, 1670800848, 320471216, 2114539766, 1671037181, 886024377, 1940914459,\n                1457430737, 1427559259, 3091470472, 2856003945, 2098123517, 1418768818, 2088924969,\n                3884270171, 233325771, 2475658630, 3306400235, 1042747488, 2251057616, 288186037,\n                1069520858, 1716749834, 2851756715, 3107695069, 4055132959, 1800778936, 1250813397,\n                4225902318, 3898227912, 2436303557, 4099682647, 4014271299, 2579688947, 2474049743,\n                1793988451, 1750223744, 2886556309, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10,\n            ],\n        );\n        // - bits == 0 and divide-and-conquer condition in limbs_div_mod_unbalanced\n        test(\n            &[10; 320],\n            &[10; 915],\n            &[\n                685114319, 3257424506, 414393229, 2860628494, 121479429, 2579870766, 1597023839,\n                2474392621, 3223958133, 1457435159, 3048194581, 3047568591, 328216793, 3688729284,\n                1474966660, 3229714080, 1674178552, 3622356479, 2813923308, 420491140, 1181947036,\n                2552013519, 2545590339, 977030817, 1410754865, 418734423, 3219708398, 3814271579,\n                856825330, 886986018, 2340527841, 1574000724, 1326246490, 2345646501, 3649082184,\n                1757236341, 3333117097, 4191792834, 771549916, 4014890173, 1767239699, 1537408864,\n                860021926, 3301854273, 2439584990, 3450574632, 2067936331, 2217599411, 1936116337,\n                3184038132, 3501118169, 1312763670, 1815889084, 4185547518, 1921708290, 4252193163,\n                733366199, 1748333822, 3613571030, 2021878401, 674325326, 1834274504, 1974211381,\n                2155793730, 666543182, 3988638747, 719903603, 4243752700, 3417033998, 578937389,\n                1954345891, 438767411, 1067012960, 2140679028, 2616731558, 3608791372, 234168266,\n                115663374, 37715525, 3155431063, 1484074906, 2987669067, 1980354536, 201618151,\n                2443603378, 442745319, 2757914412, 1266139308, 4142086597, 1989465976, 3517367864,\n                1441253229, 1295109068, 2757883716, 1533532909, 4121897334, 3324479034, 33282683,\n                1821922930, 1002968212, 762196862, 13770263, 826603273, 4072569825, 780821896,\n                788706413, 2104768306, 1607373740, 341951230, 1675442736, 3679554432, 4040499065,\n                571466582, 467434507, 1883560688, 3831540337, 740943368, 2376257013, 1304728970,\n                917813781, 3342830532, 3374539547, 1366263565, 1830393744, 3801219913, 3174561984,\n                3973286677, 1398849159, 369072692, 656722452, 2994544393, 2007585192, 3393313477,\n                2976738602, 1184554260, 1566038994, 826752733, 477094709, 3837269061, 2769881480,\n                2709841643, 2163313442, 1223013930, 2855285371, 472880962, 695734454, 3106659328,\n                336220721, 2424316775, 1005851508, 3997249632, 3813922059, 4109122372, 1011074885,\n                44571353, 3135429322, 2678006854, 1812501650, 531726754, 684688016, 82728273,\n                2816638159, 2837354685, 3655899911, 36796549, 4088908020, 1199108102, 2363335387,\n                2702162409, 1359179115, 4038752961, 4132030616, 3472925013, 918360670, 1612076468,\n                1617334280, 3399902835, 1794719516, 1364930290, 3884047381, 1715844217, 2543581627,\n                1948226880, 3734808909, 1123962649, 6885664, 4055662667, 2036545059, 1825684950,\n                626135857, 3682021373, 2923868404, 1141437069, 301320286, 2038697946, 4203441370,\n                2625080149, 2416510088, 3453059660, 2196830401, 1003239496, 766384828, 1454135529,\n                3753927217, 289196672, 3027589815, 386319177, 4286570851, 34998813, 2808034465,\n                654631613, 2919774640, 3980646343, 3390105294, 3876707444, 342623382, 3063311246,\n                2951194817, 2409427609, 277380170, 1128962197, 512899487, 1130696384, 337608154,\n                4248250968, 2538526153, 408791364, 1355901969, 930023605, 619907788, 1270155017,\n                2669635170,\n            ],\n            &[\n                933436633, 2314417619, 1779862136, 2339830299, 3359221691, 1983848875, 2097698892,\n                1645402710, 49190984, 3806363526, 2374325643, 638588450, 3467828663, 2693267297,\n                3081019625, 2568134532, 3644457728, 2630819968, 707790566, 1984505565, 3749563552,\n                3700374589, 2579510542, 4246015133, 1527325532, 3034605869, 2134963426, 3613350443,\n                2082268909, 3145097012, 497158738, 1750605816, 1683654362, 1392048080, 2595287102,\n                1859642116, 3880370994, 773829956, 2727575776, 868421082, 910865307, 4010486592,\n                72360528, 2330397412, 2764112435, 2833247271, 1236763483, 1139702723, 3454679019,\n                3138128998, 3268622050, 3622582141, 1726130545, 2831795892, 391680447, 1964919870,\n                2937963749, 260385042, 1893950828, 1182888075, 3460030123, 2590897592, 3391091057,\n                3700415037, 1619162545, 1524016666, 1313243906, 3716478858, 1054838129, 1929422210,\n                4093970820, 1243478860, 3650034984, 3598628391, 99479112, 2103638976, 3422493162,\n                3133671222, 3540259323, 1874029880, 1634209319, 2379655185, 1946213151, 2520479253,\n            ],\n            &[\n                3601647142, 1198081127, 2017909663, 2850560144, 2525189596, 3322651433, 1196731903,\n                2005963472, 2134066324, 2610149081, 450546169, 188828597, 1723795042, 2336113352,\n                3907052140, 3494836209, 715365512, 1993048254, 1925488994, 823976428, 2233248290,\n                2422705001, 3872792781, 2414526209, 1756149349, 1280574399, 1755135863, 1247153316,\n                1728175244, 1243737647, 2892353496, 4039291447, 2822417936, 1802319071, 2421598944,\n                3822986016, 1165555397, 2706895746, 3653134185, 3710916752, 2131271858, 1948052061,\n                263095829, 3665120472, 3941304005, 2412990560, 214802237, 2000697426, 2019125997,\n                4285690497, 458482240, 3763367750, 3740974398, 18717988, 2994310518, 31139573,\n                2962856782, 2635167300, 1374305995, 1904881724, 594198221, 3362552684, 4265460501,\n                274321353, 561861394, 1648066133, 2292362828, 3514463789, 3295772513, 2531715202,\n                3705228042, 3001079609, 3079883010, 3054352160, 2260450577, 4705408, 1098764342,\n                3839802990, 2734256, 1555041092, 1134828750, 3567598995, 192771362, 2717018386,\n                662391953, 2584453057, 2585537103, 2576027868, 1668324201, 3624757426, 460065697,\n                1929435817, 3408543056, 2538334724, 3248763392, 549345600, 386006368, 3558580119,\n                3062181549, 1775062641, 2633004162, 2187541778, 4022833250, 2741897083, 3947772701,\n                679751089, 158802595, 285267524, 328299044, 3021797568, 2510593713, 2545541570,\n                1206900374, 1414348252, 4082633309, 274916917, 477912774, 1556311254, 3077433173,\n                2797875659, 3143263862, 465042590, 2147512274, 3300509342, 3506297514, 2410981614,\n                2358295490, 3388832427, 667531680, 2815589176, 4196689902, 1375855277, 3423352186,\n                1308972370, 3156982991, 3705393539, 756586648, 1240095514, 4216114488, 559069171,\n                2307911019, 636721718, 223194289, 1878543863, 53769785, 1002080984, 368614887,\n                254165863, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10,\n            ],\n            &[\n                4135839129, 3082159379, 2808741151, 2746492478, 1317271925, 1590248590, 1871245480,\n                883232624, 3985674442, 3997584338, 2338792001, 1776575346, 2531584902, 261625854,\n                3578066182, 2058830353, 684820033, 3683099826, 1776182826, 2182228087, 919424929,\n                4095708279, 1423878550, 172604911, 255380658, 4104949687, 3178922494, 1444103543,\n                1691042525, 1011488353, 3955571774, 2253259467, 3143874569, 377143694, 2390377782,\n                1070304427, 1715840158, 2972468795, 455414172, 3300053546, 2552753048, 3276730351,\n                1581696761, 1405031742, 2503564946, 1980393840, 2686153828, 3279538716, 1074513470,\n                2389426005, 592338809, 348493719, 3669366843, 2086362650, 1888752201, 1485850549,\n                3098846363, 839653456, 2380177511, 1732519385, 1998829691, 3296699081, 2705709135,\n                2848494034, 4155180828, 1425421469, 3752183557, 2319259329, 2757221818, 1921158733,\n                3302049214, 1696454223, 3356952349, 3100878977, 324054921, 2131412976, 1078305944,\n                698318350, 4151030129, 2259288990, 762849915, 3134288938, 4090864118, 1223661238,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - Barrett condition in limbs_div_mod_unbalanced\n        // - bits == 0 in Barrett condition in limbs_div_mod_unbalanced\n        test(\n            &[10; 1459],\n            &[10; 1458],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                1699768805, 1493014143, 2592376845, 190926105, 542951397, 3841252648, 1343830055,\n                2073311615, 2471501748, 1744126095, 4269392231, 3721081862, 3530443208, 1084284148,\n                467429630, 306942799, 1316059964, 2458728017, 4217570360, 2624704102, 3521450981,\n                2608224726, 3040435965, 2267671055, 471534848, 3629410298, 1363200167, 203206966,\n                3414918917, 3335382360, 1913622484, 1218762755, 3956682428, 1037359525, 5531615,\n                3407338094, 3864111971, 3057551672, 1048359741, 3074041931, 1285559492, 2147056083,\n                4091000908, 3900432305, 3556431023, 1451794634, 2393864263, 2505694122, 2968009980,\n                1048797969, 1048151529, 817832869, 2521994756, 2426006163, 3275649087, 941801312,\n                1575422758, 361314564, 722834359, 4247301247, 2186131251, 3429599060, 2212966801,\n                1219957676, 1702525945, 940680423, 333505183, 2493537355, 354760063, 274436852,\n                1639243309, 2924727204, 4285739645, 4001422648, 105606253, 3112142556, 3975066309,\n                409404932, 3040839303, 4022137216, 276092852, 3345019055, 1650156126, 169273103,\n                1920493641, 197903490, 4009771827, 838073342, 3939112618, 3406907996, 4120898973,\n                2720730518, 2834644027, 3448317034, 3673080760, 1810888516, 2181591183, 2952080694,\n                3794819074, 676604950, 3118739900, 606918192, 1316167449, 2730639798, 1815557579,\n                1808982050, 2109827633, 1671035061, 7558450, 1554665087, 520056416, 4218246290,\n                1161585267, 1878255675, 2486870832, 2088887262, 1303298097, 164712340, 2377403159,\n                525890592, 3347413040, 1697811557, 3373912443, 1800652721, 1430587466, 630390988,\n                1443110580, 572173114, 3006613569, 163802577, 3661300485, 2066285319, 3197778371,\n                1266266830, 3617690296, 4233259050, 3805452611, 2682754452, 1121170085, 4239996815,\n                2574739406, 3293943958, 589250712, 694935820, 2394149134, 3507180662, 2403010680,\n                1341157799, 688040930, 1064943055, 1576175762, 2748814503, 3365706670, 2331616371,\n                3891308187, 3625939659, 834228833, 2747861390, 4238259694, 2400594789, 1064448439,\n                1457694712, 2503273199, 848323770, 3879018391, 419366498, 2787183492, 1572178433,\n                1143352485, 4132728989, 3611364165, 2042218208, 4202715626, 4222254124, 3573214358,\n                2530238089, 3214459960, 199438106, 1990033748, 3797350881, 2039620692, 2196170141,\n                2867974320, 218349677, 2334991902, 2199173454, 2635928703, 1960733130, 3298739914,\n                1745262170, 2022670546, 1773942006, 4022957449, 3487536364, 4203797706, 321674131,\n                2963478216, 482717037, 423207073, 2529853593, 115650857, 1559406958, 2515253401,\n                4253176221, 1494891359, 54215779, 145831030, 2534290332, 722379383, 3288965822,\n                3478280697, 114345927, 438460383, 4120362834, 3417392370, 3871144709, 2774707897,\n                2662801524, 3802201761, 1044223137, 817062608, 964570171, 2627601973, 2648686193,\n                2728498120, 1589690733, 3285610776, 295629246, 3995872256, 2573726546, 231960020,\n                4274030532, 3444536058, 3882840099, 2252235022, 3959235737, 3485371602, 1365773288,\n                33313646, 1392617408, 1844121885, 993486158, 821274239, 2676605019, 3812510576,\n                3432776114, 495146668, 216967234, 3172737228, 3417198461, 1629229154, 1821830950,\n                1340735610, 3211463144, 3560398150, 1050123642, 874441227, 3169516221, 2783241998,\n                99843330, 1175436161, 2825581162, 3259620982, 3350111857, 1606464613, 1911911079,\n                4127551535, 3229370127, 3828823712, 2744685123, 2859704702, 1106636072, 369804135,\n                2989745290, 2768260583, 3275220193, 1104864623, 2290350054, 1049972093, 1592992521,\n                3598788064, 3350912109, 2954408081, 4230173468, 2901042813, 1614811380, 1930643862,\n                4235254046, 3520012632, 1160373738, 3249852125, 923106635, 2511906301, 2055083218,\n                3193170540, 843255473, 3274357481, 1069334404, 2160558830, 1247811861, 1960090087,\n                1260505746, 273679994, 628898405, 3731946987, 3821611375, 1479367897, 406962212,\n                1951524671, 151905808, 2697376333, 2827375721, 3738186384, 2398267382, 1189552516,\n                3271847863, 3695955312, 839640611, 391563549, 2851226168, 533382637, 4005632192,\n                779063015, 972248299, 4160069328, 1551848869, 2901173293, 1788886403, 7742522,\n                1152154246, 3162815742, 3933026131, 2093435260, 293643707, 537139803, 166837469,\n                1353454767, 647497063, 3056417780, 4130500121, 2563320691, 3004161478, 4266673072,\n                1525376895, 2692236203, 612090721, 3803502732, 1472545930, 1285255741, 3563385061,\n                354899818, 3985901869, 1077755288, 3764626839, 1736779714, 1388617683, 373259603,\n                406803142, 2250511459, 3661744930, 1712371282, 3755716304, 1001652736, 1437790589,\n                2722214878, 3509431789, 1045623456, 1477384299, 1529044191, 3485492831, 777726776,\n                3111945645, 87325680, 3674053827, 3777562490, 2467629264, 3920974102, 1118313420,\n                518650065, 2779852693, 3938004723, 351444334, 2301762313, 1696242659, 915234550,\n                3426770333, 2623516555, 2367502869, 1764681654, 3012087599, 2970366387, 1214823325,\n                1416807413, 1002068525, 902786108, 4219021066, 3685197343, 627261248, 275319515,\n                1048180581, 184895903, 4054317442, 1164782510, 2969271356, 448119019, 3225650628,\n                3586253056, 13844949, 4265695528, 3156376136, 2094798072, 857381027, 2996376430,\n                2313835774, 421527113, 577824604, 2027011737, 1936987926, 1716119129, 2495416975,\n                1566342556, 1974265475, 100699876, 3818621196, 864167162, 264481383, 2779691848,\n                2519054856, 356904428, 1425193402, 2029146838, 3791198981, 1181286580, 2106244436,\n                4074963191, 1156817098, 2002193018, 584536494, 1252244761, 3576951572, 2017920970,\n                1604293290, 3010503460, 1201492606, 1555982397, 2556964369, 3428819809, 4168489079,\n                4171058202, 404720822, 2480856269, 1813722898, 2093837710, 3164853594, 3430042720,\n                2545385245, 1253945679, 2067139932, 1049755734, 4162345450, 1330690410, 2567802121,\n                3494789533, 4027320953, 1359086506, 697144652, 2171860846, 1885681379, 3200348033,\n                779514913, 3892431243, 3292022849, 3206367229, 141294896, 1247341423, 1286221471,\n                2030904879, 133272354, 1441910339, 3982161305, 2696309947, 3801057775, 4053369379,\n                3233631762, 3173498696, 19486328, 3282282805, 2117833655, 416934200, 2476837107,\n                3550654071, 835595228, 2784887835, 1849982594, 1215825494, 120169702, 3628150453,\n                813273996, 3164608875, 2585886019, 3468354974, 2529654702, 3937155612, 2948360421,\n                3839784361, 3626976122, 3884938510, 2182665318, 1984077334, 3592802345, 974314095,\n                2658877268, 3320515471, 3220348329, 2057524489, 3330170042, 1859432638, 180803537,\n                1712128971, 2278567221, 2233418239, 2029256422, 183505236, 1671411329, 207176584,\n                2036148357, 2313901094, 3988184694, 2436690588, 211724920, 3032356297, 3340214696,\n                117345076, 1500403818, 1365050888, 2323945197, 2919933846, 3023641486, 599606728,\n                3628676259, 1581385213, 1427038937, 807104522, 3978940995, 3629484758, 47151915,\n                1224789415, 2759574529, 2839954032, 1315873434, 3168847820, 1610459325, 3726598118,\n                896590825, 2419742875, 3430079217, 3778931934, 3687222980, 332999836, 1043316180,\n                4189864653, 685607150, 3695627010, 196835870, 3941428183, 676485145, 986494888,\n                1049128467, 1888162207, 2801108003, 2947315222, 1894059346, 454711531, 3589935315,\n                1803051198, 3655137369, 983821858, 3081875497, 3803393764, 2428490033, 1679378736,\n                246071720, 1483050983, 1382043974, 895942294, 2442009263, 68111122, 1626094364,\n                1007851423, 4064984075, 1533309302, 3360582064, 2740180933, 883885210, 2989133634,\n                678055765, 2661431250, 92559696, 1032783565, 22899740, 2361882691, 2393385114,\n                992907787, 3373832203, 343145453, 1165167516, 290287284, 1707286378, 634939907,\n                1875541381, 1297012104, 3157634640, 1929967474, 1519414443, 3881762803, 2681995819,\n                1775206192, 2755218098, 3910825543, 1860602393, 1832806570, 415596447, 2186155905,\n                2791826564, 1816344456, 4023525966, 243382839, 748453584, 512556810, 3922005623,\n                1061467548, 276741166, 2229273612, 1738207771, 4128865796, 1984054190, 1324502121,\n                2297662740, 1222235249, 3182342363, 1665477641, 2147473685, 2421806673, 2322492629,\n                3459362839, 293710623, 3706578807, 1598383617, 3666283079, 1011133678, 2189483475,\n                938644636, 847088475, 195518118, 544927250, 1332819612, 2366720962, 3995717811,\n                1985243513, 948001598, 634366393, 3212334449, 4000960249, 3974258285, 4013403482,\n                418753555, 1101654041, 1090819318, 1675158019, 3683152713, 1204756106, 3841987860,\n                2260147808, 102023094, 238154404, 533560693, 4086126380, 642534617, 1632145671,\n                1006291121, 1435987078, 1313038313, 4186175328, 843360286, 1839639056, 1353648132,\n                2221125136, 3732368512, 3339185832, 662563454, 2744469998, 1331973650, 1343096038,\n                3251304725, 3601378173, 3422205067, 172706680, 908147887, 3728762498, 3795011129,\n                3044217576, 67031330, 2499472547, 4147725229, 2529069049, 3741434149, 4201254595,\n                3779595001, 42489268, 2053548825, 985282652, 3980674776, 3248961215, 3376433654,\n                38182659, 2602101994, 1925777855, 806407427, 2317267910, 1380652265, 3701097444,\n                1220848862, 2025812459, 3482791264, 1753046753, 598143651, 2616070898, 2479609320,\n                1868138196, 945178683, 3832269010, 2314371642, 2400732781, 2048750780, 54093670,\n                327716566, 3334970102, 28861124, 4118278855, 3714357594, 541833330, 2000911880,\n                2666752754, 499968133, 1548730866, 1814521338, 2487369228, 1138644653, 739248636,\n                126190040, 3978033791, 1817304821, 1225794794, 2871919793, 940731169, 504076316,\n                995594649, 3329757458, 2846947354, 3891292748, 3959049218, 2127628616, 810346662,\n                2271875593, 3880247584, 1164066271, 1750445267, 338639562, 1699074958, 959302743,\n                2956590033, 867798509, 627451437, 3510106002, 2473252158, 1509206912, 3352377241,\n                3802665519, 2147957812, 56184472, 1718654148, 3672624374, 3511414009, 2682054173,\n                3922316656, 2414259176, 1496250883, 3967344788, 3214918603, 1624761599, 2724006253,\n                978208159, 1113357772, 3487098045, 4270740839, 633061828, 2261921853, 3462914738,\n                1530768806, 1364864048, 2876294873, 2510835104, 4242821662, 2474987381, 3633586220,\n                979932165, 4155189874, 2525154569, 1335483880, 639760624, 1660790427, 2226690500,\n                4135706134, 150618757, 593063255, 3258479253, 3728374085, 3007800944, 3679685736,\n                694904689, 102552353, 1428747995, 1176285881, 641509845, 3270509599, 272169854,\n                3047261598, 1287492008, 3351279172, 2404469180, 459751592, 1333387953, 735177161,\n                215716037, 536597459, 3665567562, 822815388, 3602692316, 3168229037, 1054147108,\n                4146505577, 1580773238, 1088501561, 3629868530, 2978204283, 3610240644, 2223237525,\n                3153209697, 448561701, 895234984, 1592358205, 57857782, 851682344, 4181525201,\n                1988009551, 3651424110, 3655716749, 3787661870, 2925252014, 3708997912, 3309060091,\n                4188222270, 1673276025, 2192528846, 958274526, 1258766035, 3525801758, 1215614889,\n                3051826051, 2354974337, 1541657893, 1271755575, 496264166, 2626820052, 936952045,\n                3785181421, 1294902361, 1958901697, 1604821791, 218282718, 2246953449, 538193118,\n                1919817946, 1243076425, 799521120, 279827487, 2722496365, 4019574708, 990869332,\n                2181585056, 2705356597, 610157367, 4119248513, 3343890269, 3121261960, 4085000780,\n                1022014736, 4240976369, 2817889889, 4075894073, 560049242, 373205120, 334714162,\n                1892034277, 51733004, 1776487312, 1265439929, 529285398, 2048981213, 1833004632,\n                827301005, 1648393113, 4281016481, 2048185380, 784315559, 3245679058, 3513265995,\n                1369181664, 4269143782, 113931975, 1398194472, 540409306, 216516009, 2627890586,\n                3694809441, 2573974797, 1396611872, 2646365320, 988053471, 84792061, 963667070,\n                2114579379, 3564371585, 3893773169, 4197725787, 2378021272, 3273607654, 1738197474,\n                2402812179, 1278628015, 2317178895, 3160300732, 603898477, 1287079046, 392763347,\n                445875312, 318139180, 1903469143, 3585413276, 885483094, 1674549044, 3911672420,\n                1575430246, 1867282418, 2115410448, 4189894183, 3512999498, 2833930381, 4284803257,\n                2594863293, 3053172089, 442647755, 2456733276, 3207156565, 1248598530, 3135346976,\n                2511563725, 2761431370, 3552853409, 3064928230, 1668127734, 2151818142, 1573413967,\n                2528903432, 2255579949, 4086541389, 1008056620, 651544198, 4099217330, 2147059795,\n                4189054906, 3160158060, 3084688966, 1829066970, 366751766, 1086760266, 1823021570,\n                3035776668, 3725549438, 303569416, 1637955291, 3070457854, 2756834184, 1117066585,\n                2815830458, 1229154243, 978732541, 3666377420, 2646214554, 3084488532, 2757010866,\n                1756160517, 2475577838, 467860047, 3125348085, 990351000, 3303850398, 1120462919,\n                1920695807, 2980611720, 142863055, 2378648555, 2707355873, 3519612422, 3266835497,\n                2512195477, 1941306513, 365527762, 592954943, 2552580189, 2606501901, 1933724422,\n                2729691276, 28289820, 3017728757, 3650961916, 3696374759, 4228636665, 1241471494,\n                3355869165, 1455843481, 2403725149, 829901760, 2618851388, 2623034964, 2752098284,\n                962418521, 964160519, 1174284358, 2043907493, 848741317, 2520932535, 53649688,\n                4228750878, 3694987632, 2694050164, 1097113047, 1221352269, 3997202409, 2858697527,\n                2874569664, 82995009, 2474870382, 608319794, 2793235942, 1762763510, 593568738,\n                4140942494, 3399850155, 3632742015, 1495257590, 1987803076, 3040781503, 4185563847,\n                2095097137, 2984180367, 2385825018, 276655462, 2186224265, 242785858, 25971964,\n                960934651, 4259630073, 2869516035, 1099452330, 1108772812, 2208212843, 138327599,\n                3047969124, 2406962821, 3234115454, 2013090243, 1253595634, 379537518, 966627542,\n                2289594467, 3820588844, 3307962615, 2251395356, 1086612191, 2411787092, 716861072,\n                488537062, 4279016079, 1024670198, 3162868375, 2993498248, 318817475, 1204805151,\n                2917216152, 202544687, 4055006202, 2166902046, 777932120, 1954248209, 1436706075,\n                392807099, 3560992122, 3690436481, 4086456539, 1672219993, 718561908, 1329443408,\n                41759831, 3830929272, 468558885, 2850993192, 1203438200, 173099196, 3100895691,\n                3212371819, 2727223413, 265778175, 1306749738, 1945372531, 3409735664, 1829111612,\n                73857789, 1967847248, 111126146, 1941085939, 2157306354, 932967688, 1524770100,\n                3562820290, 1815865396, 618928660, 1954521715, 2791055048, 1472833149, 2745012885,\n                2590581857, 764068138, 3810864565, 2068720839, 423731968, 2781829173, 671016197,\n                3626671545, 578830019, 2263629204, 3196999908, 979097653, 3960854009, 2652280123,\n                2014180777, 3212225669, 1901793582, 791028866, 1535961645, 3425925260, 1728220859,\n                906987059, 1320441954, 103740087, 138471919, 2751991892, 3763793139, 1930252328,\n                2302777807, 4166228863, 1898736904, 2679190175, 1902812084, 3494412200, 2003091421,\n                647088593, 1275527793, 1571337951, 1296166873, 952173553, 3873665860, 2863399704,\n                1687749991, 1019315430, 262989750, 1995806398, 3977438566, 3065387570, 194327737,\n                2433254350, 3852864758, 3086016127, 1848276257, 872733825, 4293282833, 3839899541,\n                1287823073, 2617969813, 1718468275, 640897626, 2796238324, 2471345611, 3038580905,\n                1824539690, 2178312422, 3642675324, 4168141874, 4093223514, 1058804935, 1645178046,\n                3320651392, 2520046692, 1724703883, 821899232, 481110608, 2492775734, 922020621,\n                2923405792, 3392950548, 76237439, 3904683294, 256504571, 727968315, 59423766,\n                3078236506, 2465675774, 2942973709, 2930861254, 2455418902, 2986403934, 3056400696,\n                3599867309, 595501194, 2042151651, 2763604081, 65000450, 398696589, 3026108404,\n                4199385741, 3349995311, 129915120, 2486649758, 775313272, 2784093349, 1582665104,\n                2775814261, 1584569957, 2195691054, 2575677337, 3244017237, 2457054839, 3897157261,\n                3195991591, 2030342150, 3727062402, 3706029571, 1179068874, 94821848, 2230566710,\n                3669075264, 2425831169, 2438414276, 1720898289, 138216286, 3807634131, 346144588,\n                1780209932, 694722911, 297024116, 2795490416, 1836169972, 2915769303, 591959219,\n                2377921602, 4158591575, 1182337705, 231710027, 2274507465, 2241869617, 300827881,\n                4150367209, 3585840019, 4167111741, 1023965277, 1674153048, 887595527, 1601672948,\n                1765479313, 4065509701, 3915091640, 1297871355, 3479625154, 2831036720, 3785201761,\n                1221164796, 1647627464, 2551945655, 1768755122, 2079192478, 347747455, 4045445050,\n                2954562195, 3495749867, 2264323612, 3116421719, 2118887029, 432847575, 3976298717,\n                30083877, 78749340, 2656872748, 3171516677, 944561854, 202462342, 339834758,\n                1199920281, 488096540, 3380838041, 3470160182, 1755758102, 803450485, 738480354,\n                357618351, 8551902, 812925594, 3218358491, 2918846080, 3174772578, 822290689,\n                51990462, 3350891640, 2729296982, 2723805763, 3540769319, 1145905142, 1754039404,\n                4289454572, 4153901476, 1336760032, 2717506348, 2938254966, 1476941276, 3458786809,\n                2378593502, 1537570700, 476723401, 1207306095, 1092996894, 1187377294, 3666979500,\n                3948059620, 4150681293, 719413909, 1118296918, 3753268822, 905882560, 1638884713,\n                1259563753, 1063300422, 1502884288, 2285369399, 1874551590, 2040785043, 1775679918,\n                1144757520, 3854262168, 3821097323, 282903083, 197139966, 976017372, 3684024526,\n                3746169537, 108937132, 2444167905, 3366454633, 1002555971, 3961863482, 1693512346,\n                4219424106, 2731825813, 2173055658, 3589347522, 1180897582, 349307065, 132252171,\n                1286185962, 2906205536, 2843606103, 27822898, 2481699072, 2948630201, 1774092707,\n                1171123309, 3404061713, 2905420837, 2351973006, 3971568799, 3248015376, 2297549471,\n                2624549152, 2864086950, 2757145051, 284981704, 4116824485, 786416861, 455364234,\n                810567289, 1304615212, 2127708286, 3066389895, 3906659140, 1621009466, 4060905456,\n                2498550541, 2021095657, 189923381, 3015918335, 394513300, 395082750, 1997152191,\n                3900214471, 2076041515, 2762331608, 3059576182, 634566583, 2077367009, 239466771,\n                3512081528, 3492757347, 1343506243, 144657866, 1186993011, 2942254420, 3813487876,\n                640076454, 3107898063, 4057144155, 2951251839, 4059833593, 2265248880, 2051308911,\n                3838642653, 1427962716, 1138966813, 1697969541, 3885404282, 2547515947, 2006341172,\n                1338884621, 3673075887, 2250647769, 2303605646, 4029999904, 2015620651, 429025216,\n                4230380695, 3438741639,\n            ],\n            &[\n                4140022839, 1332918634, 385973856, 729517205, 4200666083, 3186247306, 2216473287,\n                3967994940, 3549880551, 2351334526, 2534881763, 2681541703, 2415670560, 1563911606,\n                1997982500, 1605736458, 1167308742, 3790043183, 1281410972, 4023693410, 2615885090,\n                4061771357, 831983168, 1009160127, 63254496, 1067286614, 3975642271, 3217740495,\n                1975825580, 854854016, 1915702280, 3908074524, 285492350, 1679287901, 1104416954,\n                3695854744, 3144705003, 390542060, 1273889374, 3084930693, 4021045456, 3870124465,\n                1499147739, 3994210128, 3405516906, 3623362998, 3181013060, 1438540318, 4272229535,\n                306800092, 1181814571, 3620542147, 3869706343, 2217038651, 3688188000, 3236239747,\n                2170551399, 3953686852, 198893646, 182904951, 2546842722, 1735943345, 1114476981,\n                405616403, 3534536074, 2023951294, 1480810150, 3151805839, 382753314, 3801503696,\n                2647293617, 3687313025, 3690190955, 3611357942, 311999520, 1479537441, 1417453958,\n                432157481, 3078614193, 3775508939, 64222726, 3924944108, 2439554192, 3257110815,\n                1419675816, 1340749298, 453811150, 1561302035, 1676196487, 1180208338, 3665601239,\n                1668250078, 2824874050, 623744389, 2632051421, 2939514497, 2726660986, 3692620466,\n                342565691, 900445430, 1837938808, 3156072699, 1435577065, 848877849, 3301087391,\n                2965859650, 1031009120, 2161708655, 140555963, 2153100207, 4212548871, 2619127334,\n                3918882470, 1432982383, 3390781349, 3716882367, 4184486270, 2277586036, 470252938,\n                4112802036, 1170864674, 583933362, 3436794416, 2375532943, 49632807, 3418743752,\n                3474436229, 3170120487, 2315065091, 3188088177, 590943243, 3782256578, 1083050403,\n                786791806, 967853931, 1985229455, 2650153654, 1329623293, 2081902975, 2953142527,\n                1454174427, 956392778, 2653248919, 2825319626, 2568111104, 2273785507, 2681572985,\n                2942580495, 1582788144, 774169635, 3400727324, 4131339023, 3522701030, 319714447,\n                458707788, 3752893403, 2443453767, 2781969719, 3372652584, 2121224611, 2434396226,\n                3653609151, 1787303898, 3116390348, 1921974414, 1712268671, 2949516740, 1622664220,\n                161136625, 497442963, 3317256575, 2957603271, 986452621, 3805208504, 2188469415,\n                140689727, 1797077961, 2162618915, 3322199776, 3924576551, 944631509, 2240768158,\n                2759297442, 1749164955, 3082686335, 3003330954, 1180096875, 2313197002, 1149750323,\n                3900540274, 1995494972, 2408692703, 2046549780, 411448793, 255559985, 3477747740,\n                3894106684, 4213478926, 3984564898, 2712600956, 3287187119, 816891367, 2106294719,\n                1106097934, 2910176802, 2608974151, 3469858998, 2100827559, 1199787244, 3568298,\n                591666042, 328113877, 3372271726, 3376926821, 2110192502, 2024579892, 2139201149,\n                1247359283, 2768125945, 2549569459, 2612808458, 2318203790, 130370887, 4254847480,\n                4001483865, 3878364734, 3541076697, 2506919390, 3651245283, 3792308185, 411720929,\n                3304656118, 1031630616, 2882095508, 2575128889, 1941130594, 3620512291, 1584273173,\n                298857748, 1816941748, 2999070534, 3251147932, 1387106514, 3520710326, 1393970408,\n                2451356112, 159701226, 2454829360, 3908203803, 2096649839, 3785552552, 2810782392,\n                3683175936, 2049748560, 2728594433, 3807332520, 3378848389, 879276013, 806429365,\n                2062382159, 685759815, 4103606920, 3837126864, 4044942116, 1361913605, 3538745256,\n                4260118682, 1468436403, 3266698300, 2298805804, 3550824836, 2931275954, 1201599658,\n                3732266565, 3356136327, 3721347742, 1028089391, 470390407, 838305008, 1154116269,\n                2955121230, 1969987690, 96777497, 2525384567, 3280604030, 2954089608, 2870616682,\n                383452739, 2851853443, 4247435667, 1968078656, 2157562040, 2298288548, 2057507768,\n                3694060404, 1371214831, 691452969, 3349919462, 3931314405, 2996280220, 2073252676,\n                3500529769, 3308852650, 4013710550, 2128361215, 4120449957, 2644175204, 2771183255,\n                3881988169, 4057679961, 3263153248, 1702685317, 317599410, 767790225, 40124243,\n                1722383190, 1975688792, 4175872056, 3846629460, 2643060200, 4204702999, 3742204598,\n                1998112415, 3570363511, 625953345, 1899666414, 4202545026, 3330022508, 959584356,\n                4092102387, 2602888631, 1180144128, 2154538601, 1195848017, 2998497271, 1397107840,\n                3412220808, 465149695, 2877827512, 248680930, 4060793970, 127179801, 3479407908,\n                1039497650, 1589401135, 1785006420, 4270265648, 3759909234, 433296685, 2364021432,\n                2489444512, 829658611, 2658111199, 3782549974, 1011476712, 4211023677, 1914407156,\n                3639480936, 1313292962, 72715740, 3746156019, 154708522, 3703285093, 507957038,\n                1196454422, 4164637758, 3835084902, 1974263654, 4097488680, 1017286328, 2381514791,\n                3008685528, 797211770, 2421604636, 2469811051, 2448855528, 3200879216, 150917686,\n                1386549503, 951269912, 884416859, 3270671738, 4173496604, 2352492574, 2312459813,\n                1381728090, 2225432681, 2624147380, 1753378914, 3784057767, 1849246765, 2097893023,\n                1813860006, 1309569046, 261246408, 1352760534, 655383919, 822735207, 2080963562,\n                785386674, 962647863, 3855351034, 163148442, 1638002593, 2361285757, 2942885144,\n                3801953893, 2050867773, 3719126889, 611516050, 241996878, 2359976268, 3116112772,\n                525763893, 3795367885, 1899100059, 1826668521, 3968490725, 1184477065, 376409549,\n                746651808, 2755958490, 690064601, 1335602324, 2315651118, 1798021213, 3057146144,\n                361981243, 3683370219, 3495845024, 4229047082, 3665386898, 2448070295, 2103815950,\n                2282815628, 2728867302, 1675855376, 4246790452, 3451647092, 2752025505, 3696059121,\n                1776536840, 2501328953, 108497888, 1674323829, 524525402, 2031653211, 3739008218,\n                842744685, 1787133262, 571129007, 1522748508, 2869008999, 3669532986, 3107783215,\n                1087834784, 909862848, 3671334552, 1604234750, 1868039767, 3277936848, 3892010410,\n                3604408115, 804539188, 2593245850, 1848873611, 1717694352, 50916242, 2543833083,\n                3321591984, 3860808446, 973275623, 1426440356, 878204766, 2518066829, 3609815944,\n                1178130909, 3463022868, 1259354393, 660781485, 696960611, 294179566, 2623547513,\n                4025779112, 4289956495, 1716509851, 4255486421, 1742423706, 181083582, 1576335154,\n                2400595517, 3017395276, 3510949481, 1775378365, 2675541160, 4181947126, 458529395,\n                69232536, 67987398, 2855644109, 1641330784, 506233303, 2545017731, 3604602302,\n                2316102379, 4021957608, 1362988002, 589652170, 3287129679, 646961616, 2741167343,\n                1059694828, 1294695889, 3286103374, 3610609446, 1880809887, 1000550267, 2311288273,\n                2150509497, 2387358122, 1755230652, 1623678481, 660120160, 2362168609, 4284517997,\n                855059721, 1701363080, 2654809044, 2751921880, 3540973385, 635986452, 4005249717,\n                1433280704, 3916647210, 3042341804, 2761453879, 2077007662, 3296723936, 3466880283,\n                2491001159, 2109091000, 4073525474, 2496408082, 729984271, 4039357488, 2111341421,\n                2499441761, 3659919241, 1137617785, 1194350142, 3319664610, 2841053011, 3485613539,\n                3898686580, 2337910268, 529215038, 3933384825, 3048164724, 3392190075, 1198986188,\n                201875403, 3776454656, 3574314726, 508211398, 2990122727, 3462663039, 1258115643,\n                2862943783, 3952621480, 626721278, 354658674, 266436877, 2279900047, 4140177395,\n                3611401140, 720994657, 2619255647, 755150209, 1673688098, 1267362287, 1821789133,\n                510222616, 3931771335, 2041130289, 1196341210, 3372955715, 4045256105, 1539159220,\n                2187027664, 1289255586, 2507529354, 246384965, 101778058, 1336141232, 2030836804,\n                3555070947, 2540732193, 2281068220, 1082424123, 1850093489, 3769741173, 602125081,\n                3757503918, 604811852, 1052381749, 189435693, 3642461764, 1573464316, 2296426935,\n                2340526263, 1459850834, 2751113293, 4273708006, 3295958131, 3610793060, 2618547711,\n                2886178254, 3168984730, 3896008389, 2910684641, 1920019587, 1667878611, 1691252955,\n                3994472380, 2977338229, 2576984626, 1351501113, 3282383656, 1895943533, 3499135774,\n                1923355202, 960512068, 2164140475, 1409823362, 90738535, 863701612, 2347007954,\n                748064492, 191656587, 2411360951, 895287351, 3599283834, 3869423593, 996172278,\n                1343958987, 4204232129, 862186651, 4240883199, 3892297078, 3426320726, 3826202456,\n                1691966729, 2680477006, 1151773552, 3420034107, 478329790, 2776338319, 85306325,\n                301696000, 4020575783, 1047443936, 2434816967, 844360331, 1358522767, 3451833642,\n                277400701, 3790214849, 1600773312, 1374401216, 3587961434, 2218115041, 554687844,\n                1455373089, 2415557558, 4185944221, 3644298685, 813130403, 1803175896, 2141326869,\n                1993778480, 3229151677, 4022953349, 1250408313, 726142251, 4052078854, 1572753212,\n                3088327523, 734957233, 4140608595, 799532378, 3130800248, 3179102660, 1290963726,\n                3671626909, 2258829788, 1103104173, 2115377976, 2247341092, 1301956403, 1833471854,\n                3662831447, 1344786344, 2540851541, 554976441, 3985164853, 1538266468, 2085479071,\n                3369085596, 2283036863, 1880236792, 3210743188, 1521915907, 3358852380, 3074581226,\n                1752478027, 714306799, 3302922277, 2597012016, 4130751078, 4214555128, 2628587553,\n                1531096623, 199872584, 955170151, 669657590, 1894747756, 1734152212, 1353348674,\n                2319549030, 3289364904, 648833538, 1850063548, 2741510265, 878914348, 1757164095,\n                1912901164, 97276445, 1411832265, 838060298, 1610234873, 2723117095, 2609845475,\n                2259244006, 1261890709, 2844142420, 1147885155, 3369135375, 1613476195, 3417049767,\n                2537355294, 2053515427, 1399515658, 145763359, 2482971113, 991709643, 2138676150,\n                1818872095, 1302171429, 1568090509, 3275531750, 1497380322, 945407229, 1822760862,\n                4228040908, 1940517075, 230246089, 3963321737, 1138094364, 3400867993, 2181433825,\n                3305102925, 511506388, 3528785436, 2879653029, 1926046085, 4143670679, 1150191731,\n                285291427, 2685918049, 312767991, 4231911307, 1880157802, 2096745103, 590684735,\n                2432966875, 2116020629, 630495259, 2253830476, 1313727939, 2791912760, 2351981765,\n                3251513736, 2599152303, 2660227829, 124307715, 3135200655, 2482790133, 2271101300,\n                1989104610, 3073191272, 2152082822, 1971138214, 1045327, 659102103, 2885552100,\n                2565948175, 777943450, 2675195962, 348776090, 2995731289, 3758589532, 4025556286,\n                257655013, 1730311656, 3698180322, 2241973994, 568561445, 1188334933, 1946887145,\n                859125395, 3482471605, 550147837, 2058651912, 405932042, 3893823580, 1614629224,\n                3412449577, 651241210, 3061461973, 574810638, 71361216, 4020596156, 2396933510,\n                2356436008, 1248054342, 200369296, 3712728011, 4011870981, 4266142254, 2720800691,\n                4069057194, 2501639775, 2484471739, 434977093, 797544023, 2570613282, 3886296071,\n                1015700927, 4290596355, 859758311, 1174682680, 1562063833, 1324565576, 3332475453,\n                4073935411, 2176440226, 53930109, 1686994234, 3678627525, 3373660623, 747493144,\n                535648778, 3674317346, 1305675282, 1150814201, 2803793911, 2512646071, 771940597,\n                3647355999, 3368179321, 4058511426, 1217012830, 1798535844, 1737906025, 3999269518,\n                3424818174, 2089527288, 2639547497, 695593140, 663988481, 2419596334, 3462868145,\n                3475802818, 1753477635, 2527218844, 3145557245, 3911980182, 1533706830, 2097434290,\n                183240521, 3788929990, 1779682324, 3724458093, 3073497049, 3465759597, 1474943606,\n                1573286105, 2475506690, 3461534603, 4152775580, 3631550490, 1699689806, 3829642010,\n                1282316060, 2662021448, 472675346, 669363918, 2371875811, 1146052026, 1118224828,\n                2861361748, 2015009562, 2878512978, 2442465428, 3219237043, 83434832, 3214067809,\n                3404145170, 871844412, 2343292833, 2897770929, 2293007334, 513785118, 1366807188,\n                169985021, 1530708725, 463131517, 1546654520, 1088914309, 44472394, 3008593345,\n                2694951514, 2232781270, 436583961, 2935635715, 231976418, 741587681, 3448976579,\n                236186582, 4252390528, 472879255, 3229739022, 538200076, 1762392842, 1710301339,\n                56783367, 1961703833, 1674101533, 3944799467, 1107734217, 426021150, 450787910,\n                1135363928, 1422694911, 793598682, 3381976482, 3932766847, 1292864939, 1678995521,\n                2190978815, 2431912766, 911135553, 2831351577, 325868757, 802420541, 3983523312,\n                2559890678, 3857026632, 1885246049, 3146727643, 2765128037, 1589823584, 3065411923,\n                872021375, 3311812203, 881521209, 747137786, 1000063898, 4179502904, 886971834,\n                4080397638, 3665528562, 2249307047, 2450795045, 1536473676, 850174262, 3788478504,\n                150976104, 200295633, 2153651630, 2249578122, 3985317910, 1064906261, 1022848907,\n                4220566724, 3216656807, 870116043, 3758680505, 3705749884, 1139091108, 464338309,\n                180190377, 3552869299, 152240175, 3980504246, 4271460058, 3106014727, 2149379356,\n                1183751575, 1040186257, 3494088390, 3752192162, 2582668840, 2597589280, 4007048334,\n                1778752844, 99620680, 2641234020, 3386178446, 506319377, 3103448882, 1147167957,\n                377320373, 2497010457, 1000662354, 2868328072, 922615819, 3970174196, 1461002909,\n                3753696352, 593319197, 1532590741, 1875289108, 138731777, 499151617, 4032772524,\n                3122220215, 851080138, 262060487, 2672031422, 1097448973, 3189786243, 1797858651,\n                4244888125, 3819604663, 4081313171, 1832908389, 2377912868, 1847228618, 3104197710,\n                1112047092, 899391336, 25843412, 3238157180, 927329896, 3835265149, 4131266143,\n                3837840238, 4065666327, 2386113761, 1064968537, 2141571934, 4050080197, 989947624,\n                3228918065, 442069281, 1556500487, 308551397, 4271798672, 1012927931, 1974219749,\n                1471451147, 1122581592, 2557944616, 2776424641, 1726474870, 724419567, 2407585803,\n                399430939, 3202481237, 853574375, 4169880447, 2035965381, 3159142693, 4087427281,\n                4204744473, 2474028992, 3798061448, 3191976206, 3120499674, 3479294815, 1733377752,\n                3657201267, 1480888860, 2961598821, 411586368, 865110282, 2341972482, 2344688435,\n                2421214281, 1570048415, 2896452877, 1277537301, 2283577309, 751577431, 449046766,\n                2378532630, 2595133499, 1063829692, 4188088082, 461333493, 1908087872, 2658523609,\n                3569418974, 1070871225, 2357598817, 4292134786, 3476191658, 2805937374, 403338560,\n                1212974003, 924302178, 625202418, 1459471363, 655272954, 545977887, 3925403669,\n                3905429650, 202344993, 1022243223, 3519555225, 3995996715, 3495955340, 1531262614,\n                805883967, 552365643, 824579115, 352329222, 2214775478, 1141873437, 4176338150,\n                2431351884, 3821463016, 2241018444, 1830341716, 4281293374, 2632577683, 104553534,\n                4228525818, 81311374, 1416321600, 868978934, 1556952824, 2506428984, 1605875665,\n                1028001984, 2071100053, 883637341, 3497247423, 2859438818, 2035817804, 1655619706,\n                2876228696, 903008988, 45752216, 3179847931, 1654196760, 4191521402, 68775206,\n                2067177360, 1755767049, 3568557060, 4239419860, 3514957631, 3471866719, 311987081,\n                403749913, 1261293110, 446382351, 1483679335, 2692556303, 146604582, 865795316,\n                1833151165, 870688614, 2467816272, 2449912450, 3430026814, 3055553592, 2460877343,\n                4117618048, 2400028590, 1902522093, 1090459846, 1037099175, 3719648076, 3190107914,\n                2683135016, 1231028497, 4027483771, 924307969, 801053376, 954497527, 3347069242,\n                886000463, 453530242, 972468416, 3035618670, 1594272021, 2700569422, 3793393799,\n                1518016174, 2625828448, 1984364244, 2136657614, 3775705358, 676668216, 4036059109,\n                3871682951, 1295429007, 290889627, 4110067154, 3565163083, 189319471, 2176690992,\n                1368068628, 2861883430, 297404302, 1555651386, 4283682929, 2078440612, 1530250824,\n                1007971128, 3074660650, 2724633898, 3129535048, 375590183, 3617921628, 3123163094,\n                2604938584, 3091482218, 1578248319, 1804580725, 3030194226, 2158090275, 2223882595,\n                2836244064, 1162211541, 4144942976, 3721042806, 1647757766, 1447025305, 1118891857,\n                1563361770, 2309821167, 2387329512, 855463165, 769472501, 1489521344, 3369561939,\n                2274906295, 2125752596, 1787159736, 199924260, 1780938880, 3649141711, 2340757833,\n                699166103, 1746203973, 818394345, 1125628807, 2542356884, 4150623740, 1888868286,\n                3745774934, 2128521740, 1918735504, 4064631087, 3564585770, 723018111, 207533877,\n                1133081391, 3880643558, 3976896917, 1841086146, 2888834682, 1737374656, 1703611383,\n                2012913400, 694766250, 3861321783, 2516192867, 3761835775, 3343643163, 590603614,\n                1385290112, 2700600120, 207214751, 2371677819, 1210343671, 1728112455, 3720216384,\n                3903650715, 3561837883, 3177305787, 2355775836, 3068608053, 1887582056, 4190357576,\n                3910654511, 88819933, 2306809855, 1332041550, 1050789271, 3469446146, 2488469708,\n                1416544857, 1425028521, 2747872322, 3129490163, 2564654546, 1587932947, 4261106204,\n                1620978021, 2257130639, 2819418418, 52714980, 3418522356, 40167526, 4134923373,\n                2539755532, 3064981812, 3387538608, 1012034832, 4241330628, 2329203924, 1099862144,\n                292732436, 2017940373, 2397577521, 1582076519, 2960516164, 2006032264, 858932757,\n                1391187597, 1373080359, 1172877124, 4241912676, 4134947311, 2367655641, 2375764648,\n                2393945667, 1825712583, 1906250637, 502204827, 1233539319, 4013594888, 1959712448,\n                2552663179, 4227809025, 486479310, 1975104978, 2896563986, 551237600, 1194609747,\n                3075900028, 3061335793, 2728762768, 2955419238, 3589869325, 1888973202, 852008308,\n                1917501497, 1625287585, 298893075, 2076272664, 1843055430, 263190501, 4148349679,\n                905113736, 57762247, 2231089523, 2125301642, 807837564, 2834619161, 3845495969,\n                591906810, 1100346851, 699291254, 1715817360, 2427638743, 3840867316, 3932350493,\n                3412282614, 3694900426, 2807704524, 1066636475, 3438115659, 3355131770, 3341962062,\n                3262708171, 1232960254, 1869251006, 3525364421, 1547705609, 1528968807, 3767707767,\n                3237184893, 1556181875, 1960589866, 2668826245, 197638116, 3510004367, 1498061377,\n                414050101, 1868279989, 273436188, 2937861546, 225967853, 4178355034, 1653778860,\n                302857263, 4291922353, 3060239340, 1653754556, 2992964514, 235006151, 638877560,\n                3373103168, 2014692868, 3132811322, 2993012887, 2015301852, 4036277177, 3788322771,\n                1042860784, 2268227965, 25586980, 2307365481, 172888216, 4196345828, 579281005,\n                618139269, 4217291893, 2306625190, 2693052733, 2154636683, 2948735822, 2120515448,\n                1279430119, 726555353, 1213908688, 803633496, 2302786543, 3417413164, 3876465323,\n                1796216538, 1069420612, 1,\n            ],\n            &[\n                1988498380, 3050132581, 84001963, 3445692001, 2734783387, 1774219496, 2162032114,\n                770345120, 3457703796, 3559428633, 4257360364, 1090466591, 3567817053, 2497380424,\n                3534691541, 1279435419, 2742018051, 2205075879, 641106, 1754923528, 58973331,\n                1715000559, 1117715270, 2272741525, 2115935795, 1483835360, 1296235, 1796957756,\n                3968651424, 152068196, 176938861, 570875261, 3336099773, 1193842175, 3048757774,\n                764666488, 3843941623, 1548464729, 1897867882, 2878929765, 448571520, 2406065734,\n                3568376411, 108079736, 153179622, 376615879, 462260105, 973865240, 3413391101,\n                2811718165, 3572533591, 3909460695, 3134008033, 3897396582, 1040616570, 2998174467,\n                4068999806, 2523162074, 948788147, 2600716643, 3959424266, 2966714, 526886335,\n                3296693425, 2243375988, 4143935802, 1111766991, 1144066805, 2311007495, 1010976381,\n                845073483, 1135483459, 3990880342, 294797346, 2679966602, 2533930988, 1664564718,\n                268281267, 2092673357, 469524764, 3945653712, 326073803, 2694037849, 3507600917,\n                3290201609, 121045908, 22654279, 1505718612, 551101589, 2556674091, 3163892929,\n                1910818775, 3418844366, 3372741206, 130020156, 715267628, 4274925122, 1048026555,\n                2835427841, 3505581892, 1602295761, 2414351668, 1553499591, 4229635398, 2519192505,\n                2021787900, 2301738189, 2691817702, 5305850, 1565221152, 3538706617, 3057801765,\n                2874943612, 3131932103, 2612726193, 1166707551, 2820888127, 3160538692, 3124232750,\n                481384322, 2617755783, 3630694751, 1672329146, 3497041986, 441500257, 1563794131,\n                666530710, 1149258814, 4274365529, 169180791, 4187510295, 2714548495, 3562799169,\n                2904591043, 1774457729, 800521106, 1411048330, 2663300606, 22655328, 3774883767,\n                3819965706, 3800295936, 3668492475, 1379825015, 4213938165, 1132023495, 3760304231,\n                2917225913, 189390673, 1938798483, 3140766517, 2153396970, 1928404388, 2785977327,\n                934591575, 2405323840, 3637359453, 981340132, 242310679, 981811654, 2288564752,\n                2987925303, 4031514738, 197635692, 2859303437, 2533609681, 1151769485, 2644644277,\n                2635940433, 3366453887, 4277743333, 929550085, 40133408, 1833321431, 2429701519,\n                1464545187, 3066929948, 3904082769, 373116082, 2430829492, 2571513045, 3885018135,\n                603068030, 1172828581, 4065558289, 1163895893, 2468059427, 1548489900, 1717402470,\n                4016751470, 1013738008, 1034029588, 3482329597, 3435207029, 1673410325, 397717038,\n                1500823297, 1911172810, 1420629560, 3358784452, 1312197637, 1152173034, 367120884,\n                384630941, 3440282377, 2522765605, 1597847376, 2683717257, 2561199311, 639683785,\n                3817861808, 463544224, 3991704969, 3376721583, 105154089, 1533594425, 335823085,\n                1107739913, 1452695631, 954081147, 1472744072, 109401385, 3210541127, 1847806577,\n                327707567, 2422910059, 2867854042, 1286261864, 2777291397, 2491134001, 1866376440,\n                1442628329, 1148774257, 327348168, 796722022, 1651402005, 2839518531, 707220227,\n                442580375, 614584592, 4054371638, 313021875, 3191805300, 2207878775, 3933190445,\n                2035546077, 381129617, 3161098198, 1019615010, 2743759521, 1458405016, 1891243747,\n                3502084250, 951344904, 2669441803, 966435550, 1450947158, 2445618755, 2629179958,\n                1786188217, 1157343233, 512400759, 3058846955, 1691540553, 3902487730, 53457416,\n                827127510, 109080803, 2065162700, 2595989450, 514516885, 3571421189, 1946474067,\n                3695201586, 529285628, 2120794437, 1831163308, 1518439076, 3361874260, 3805558145,\n                2288973775, 2352901588, 4206307376, 1343461937, 1115914255, 241429811, 2386351727,\n                3283851422, 1570726296, 4171557460, 2197857248, 3493510408, 2254067927, 3407035296,\n                1925479341, 3186474620, 953208782, 715061374, 1181448968, 1220358590, 1370257748,\n                2925654278, 3323438388, 1322650109, 3766704524, 3870430557, 3257441173, 2439781482,\n                1554488089, 800150735, 1514175574, 3153400949, 1583649143, 1280421056, 3882604400,\n                2181270798, 2782475677, 3148486479, 4071326639, 1764147111, 3505719068, 1862656169,\n                1261162987, 2211270974, 3217710591, 2927566184, 4232715549, 3582658271, 1363726747,\n                3233373581, 3022128605, 3193686951, 1851291940, 2618042857, 2848579530, 4293396464,\n                1928252986, 528145280, 300907511, 3891802439, 1267856769, 1165928777, 4227625628,\n                540012700, 469250948, 966533455, 2875072197, 2230103081, 2000106078, 3086794985,\n                4244235827, 3081744548, 3713073740, 2925851679, 2315339278, 2558156736, 3723155058,\n                3227292432, 2941681952, 4041413976, 2097513703, 3042683335, 3624088138, 3936977773,\n                2820887559, 1664662915, 2334141648, 4092839529, 274159708, 4055649255, 3512716978,\n                1365039076, 3916570667, 2158939813, 403036637, 942532489, 378445989, 2167306547,\n                753402418, 1193358264, 3877024670, 3743152347, 116435136, 1948333248, 569098908,\n                2922999784, 917671206, 2718173867, 1010784137, 1804409345, 2242631895, 3989814639,\n                2044343096, 723486672, 1841507274, 2333301606, 4260854855, 2763867469, 2805327422,\n                2351089720, 1719837442, 4008440919, 16200186, 1228294632, 3833322142, 151876299,\n                3340352893, 647820547, 3228338641, 3940895065, 1697980005, 2505263582, 77077868,\n                1311758352, 2346165371, 2652028800, 3480066477, 1481299332, 2948248752, 501377681,\n                3276784059, 4102724530, 1207318829, 2947644680, 3069480791, 1116349810, 3395241135,\n                3570300879, 3836110678, 23881082, 2523984619, 86893874, 2919930037, 3241130876,\n                3697730978, 1459589531, 486161579, 3036213671, 2106273230, 391770200, 1135761788,\n                3542580424, 2902564186, 4169447111, 1908429065, 498329772, 2010302804, 1930725702,\n                1614128757, 1901201146, 2340750074, 2621544559, 1554979341, 2490973900, 3039157328,\n                2525878574, 2064002895, 2981842962, 513591182, 48663763, 346106995, 1067873617,\n                1664056855, 3497080122, 2640223678, 4006771320, 1595836468, 2008498009, 1036368219,\n                238997308, 168075897, 876079826, 2934854956, 1075263443, 3803042525, 2802898866,\n                2169905202, 3377165843, 2465797619, 1978983742, 2322310751, 1590628498, 1459551643,\n                4156365433, 3054380889, 1819890111, 2928185712, 2553214234, 3066671630, 3394771139,\n                1734126526, 247246953, 3320484300, 579355057, 1177404814, 1327413352, 2035170753,\n                1052379386, 3339678481, 2430828601, 3360847369, 2961791848, 484983472, 3181472945,\n                3105431626, 1283580906, 3703197182, 1961222326, 3649286491, 2664156595, 2335129028,\n                230491131, 468504878, 3710487036, 3159611165, 3544126878, 1088644958, 2961497435,\n                2785759884, 1537524580, 563225344, 2114093362, 4212602497, 1169631938, 2088081811,\n                4006629680, 3089709789, 3749609771, 1969435408, 1786420402, 3870446123, 2169555554,\n                1571013574, 506991779, 2174983408, 2376333115, 1813451470, 2875689985, 2056697043,\n                2022446139, 828430986, 710475734, 785980495, 505758805, 3139780897, 3708680832,\n                3390307357, 2434318195, 330093210, 3019701899, 3546042185, 202048370, 3017694172,\n                3813711930, 1950710894, 2336832114, 3123649938, 3799964456, 1278675670, 1776925346,\n                23381263, 909581672, 3084101661, 1592521095, 3095643203, 1245783006, 917301336,\n                1175072489, 1493603974, 537178477, 3098462691, 848961674, 4083634813, 485866548,\n                2460787176, 1957075662, 1653349530, 193311723, 1510554197, 615759127, 3054909658,\n                3810118423, 3275067767, 2822189856, 1822027915, 641453111, 3902949794, 1707895715,\n                187255999, 1547540130, 3996925138, 3744594623, 279929032, 2815355330, 1197018567,\n                334914949, 104288985, 152451615, 2257137946, 495821725, 3891425071, 2698902656,\n                4248123041, 3994796663, 2283493355, 1792145295, 771358160, 57983054, 2699162282,\n                3252719646, 901108453, 21411013, 1214186627, 3971974103, 4284646962, 505661368,\n                2014789373, 709655680, 4019528811, 3456428712, 3896941342, 25228952, 3267679573,\n                2554048052, 1140488725, 796840032, 1008803984, 1769445882, 450164846, 183418978,\n                1557823191, 2205206958, 2186287277, 4041341207, 2277585274, 2647704834, 3299210809,\n                465486816, 81165601, 3688958209, 4134919427, 308497409, 1670228519, 1054621084,\n                3997139209, 642331675, 877436795, 3750152836, 2099953927, 2407318768, 4064392686,\n                3499776748, 2890558934, 4257002037, 409497686, 1871363314, 3488166608, 368834184,\n                683374402, 3315975032, 3919319927, 1636872711, 3746724350, 411713899, 3127168268,\n                1541472093, 481068370, 3914726958, 3809187727, 1019234471, 4257529799, 1795024406,\n                2169201644, 180192691, 3146544995, 3086567728, 1371853848, 3442647104, 1956649571,\n                3221872492, 2599010979, 3825880037, 129532942, 1962882180, 2981643769, 501519665,\n                1104150124, 3577388513, 530338682, 2379351921, 476796974, 2079075205, 523122306,\n                4175790511, 1769173929, 3684943051, 203952644, 2367960727, 2956929713, 724249999,\n                3868724734, 3128867062, 788369620, 183457300, 4030548412, 320471199, 818557389,\n                3673114423, 3427092352, 965641427, 4165737446, 546271097, 3179039741, 1968478116,\n                233505213, 3523513681, 3185397073, 1639252860, 192368536, 2476919576, 1286359266,\n                3468793964, 3927932569, 1554017778, 381977140, 2630912557, 3248408028, 1380148387,\n                434027229, 3679247941, 2320186711, 4049616334, 1306803801, 3657216807, 4072237788,\n                2409653033, 16652557, 777239076, 3435314631, 953899982, 375200832, 3240441496,\n                1403201300, 3463532889, 2152357282, 1492290956, 1756116611, 2979347831, 157726282,\n                597994889, 3571510881, 4022595441, 3689069225, 3371053456, 1105664287, 381184864,\n                3760869170, 2128986335, 4138730626, 2108903255, 3330167716, 1193420433, 4081108869,\n                2371248791, 2008259868, 329286806, 834934063, 1587339743, 3835392552, 3027794970,\n                2946227510, 2759445311, 4153403869, 3246082301, 2169502676, 4274409702, 1618245891,\n                3538641406, 2440237498, 291928949, 1309678695, 2248858018, 1259269551, 3062553916,\n                2375747923, 929738114, 3593316299, 395934754, 1240422334, 403599738, 3596058407,\n                4199195184, 708535732, 1045565478, 2985960024, 2935035441, 1902361158, 1360356647,\n                655818324, 1464367881, 1402852252, 1605910196, 1553177831, 2270937291, 3867336542,\n                1242299751, 4201495317, 1894193944, 2952284338, 2983597634, 3331327699, 2688007694,\n                1534358324, 151501193, 874435351, 113820939, 3053243228, 2461547215, 3493411866,\n                2931307581, 243458129, 2419713971, 2259098050, 4153522826, 1347753364, 789286836,\n                3723853308, 282228699, 31083181, 212832201, 3992535406, 3841973318, 3150180785,\n                966530634, 1983757001, 4224102508, 4103842551, 2315916292, 797697662, 915301841,\n                727577536, 3413485655, 917582931, 843507358, 1529131982, 1843003612, 3002449886,\n                346610535, 991891575, 2565267970, 3912371508, 2710618386, 2330075864, 2735484155,\n                2546043717, 3241769509, 2210455214, 4169254026, 1482724431, 674379398, 565771066,\n                3142137141, 515638418, 939683105, 1345730468, 2404207571, 249108973, 1883806778,\n                2156914196, 1564711040, 3370156804, 1857590348, 1147780810, 3733908955, 2181248732,\n                1904993207, 3694175594, 619779923, 3491824168, 3612713452, 1216174279, 663457690,\n                4014509322, 2569761593, 14109664, 1828397087, 2936522368, 4158885908, 657033012,\n                3173212007, 472151655, 684251460, 4075235611, 4224354174, 1004777987, 505536516,\n                1454022092, 824505586, 3067613896, 2235424889, 3665322087, 3481517352, 2363451123,\n                2771040650, 3235122422, 1154036889, 969497501, 2563704447, 3797108, 1395020021,\n                2762840789, 1908946824, 3014468569, 925225402, 1138335619, 3624023401, 14380823,\n                2839985590, 1786726385, 2046596657, 862236402, 214661254, 79111383, 1583211853,\n                1641485501, 2710635102, 4088715922, 3860998541, 1323605849, 3597942622, 1491675000,\n                1599602967, 3388494990, 3354632479, 2528582795, 215618636, 394082738, 1141528681,\n                1784788922, 1221028471, 3234711669, 904205099, 1676230442, 3127792899, 3994795553,\n                2452526892, 2165805680, 1335373003, 192721187, 4240993835, 3133423197, 1689272558,\n                3673814847, 1422539041, 3736049673, 1833170900, 282944559, 2338828666, 2779222702,\n                3327509347, 103394172, 3158363803, 1906876457, 2941521396, 4107834947, 3417951529,\n                880661309, 2072508295, 589009441, 1335393037, 4277398556, 2493403024, 3409655003,\n                3109850219, 1180552996, 2381399690, 2298638016, 3501746890, 846617313, 2905524779,\n                2707401285, 2041915730, 2296396459, 1041902038, 889847207, 1989421094, 1389388870,\n                3827587250, 1783862700, 3828138938, 1868614698, 4248902541, 3581264817, 3916285777,\n                1776264454, 2214767964, 2937276417, 1736659895, 1395637227, 280854206, 226975266,\n                3550562380, 1121092319, 159004679, 3748222278, 1260252989, 1422903228, 3336410666,\n                194417341, 2723594163, 2281242077, 1784282179, 1034680840, 1402111826, 335654645,\n                294940873, 2853511062, 378984905, 2532157416, 2195182123, 3873081897, 1625154299,\n                260395831, 3540310196, 4273320806, 2622305394, 2711543735, 200100618, 3414809217,\n                2926348222, 1329786033, 4245332557, 3574371092, 2777917577, 321179615, 3642895588,\n                1496048120, 797710555, 3671936109, 2438718323, 45015662, 2137354414, 874208938,\n                3450439142, 1916685905, 1662667234, 2856738964, 3829688032, 3404462996, 2848035045,\n                2061762938, 1260861712, 3010572066, 3394836279, 2342878342, 1271875691, 4111464444,\n                2126598368, 2380694046, 2430271490, 1145499017, 3787409979, 1555528697, 3376084869,\n                642452482, 2589187231, 1081315770, 2087941360, 3364823763, 3805619618, 486395332,\n                908395706, 2499268457, 2420556587, 474512813, 2481646657, 3492741661, 1968018988,\n                1074530387, 2014914730, 2803826225, 3220982875, 1438277839, 2775829138, 1528403642,\n                3794191286, 2608342366, 410785526, 2637600256, 3490750019, 1440381245, 814635701,\n                2260916755, 2650730282, 415890751, 2524080685, 3474570208, 2446217936, 2397550701,\n                231181743, 736834280, 1383997656, 1496783958, 623278112, 1645711091, 2659144562,\n                2936379758, 424018844, 1549465529, 2669736270, 1664977313, 1523334854, 193915346,\n                917134660, 1861003559, 2211424692, 3594457673, 521847126, 2663400187, 3341032570,\n                1640978768, 3374727890, 2984430165, 3295971473, 3727310438, 4148801904, 2931771022,\n                3471915299, 3774018978, 243266066, 719450229, 786371556, 1967721517, 3662692002,\n                2660462613, 3406551440, 3689369626, 4170908863, 927580754, 1492537107, 1444056133,\n                934562830, 964303678, 1533941876, 4122966823, 3705199737, 1112924448, 95199848,\n                343531614, 594658489, 808416147, 2905432520, 3584653211, 1387698320, 3110254075,\n                179755886, 2585492770, 826193502, 633023598, 1166009098, 1290016012, 672935203,\n                442560997, 2496163987, 4194310358, 522918013, 4222433924, 1620670288, 1584642952,\n                1110116518, 2050444989, 3738181405, 2449666200, 1322361471, 3346873860, 1704204055,\n                2765918523, 1681401174, 1734783149, 2990922980, 2845873797, 2655480068, 1134013632,\n                627992748, 2305459149, 890878648, 3702690433, 2308583593, 1647897272, 3079544696,\n                2470471677, 4040208261, 2073585273, 1793034905, 1713771355, 2220715251, 2553773388,\n                1442482611, 3113497415, 2768408881, 1270025121, 1399831313, 1630862433, 3377364946,\n                1442504714, 2789927137, 3191151633, 2578873407, 208337033, 3096561372, 3943415949,\n                3118056636, 1664092654, 533371474, 1132049460, 1378502069, 1205939688, 2646775436,\n                873517579, 3647947118, 4249353240, 1234899426, 3562671303, 1028908207, 3806236229,\n                2688126461, 2379248861, 4273316716, 1028554767, 960050373, 34458263, 2497415615,\n                2000699114, 1654490516, 3970420809, 430138864, 2839090700, 2992085491, 2048751357,\n                747829112, 2102051019, 2747342438, 3939874657, 204736053, 132477025, 2895769009,\n                4049016784, 4006488678, 3010059929, 3869487365, 820665998, 3637576575, 1400083196,\n                3176270933, 1580718861, 1862589245, 3687231820, 2811111046, 288642712, 2708675068,\n                3659920550, 1043267703, 2675211709, 2471783225, 3908671780, 1796097076, 3884725302,\n                2618455344, 2727437605, 3198512809, 77833978, 4002905580, 2475905855, 4285041054,\n                1379496519, 2810710199, 3524329171, 2422823286, 3888601537, 1921960588, 4141779429,\n                3945205304, 2680621131, 4186120628, 1952951538, 2875169441, 3303243339, 574383361,\n                2010030917, 3924461786, 1497240891, 3972138842, 3082719894, 700821923, 1225799274,\n                39941891, 1579154501, 2895091775, 2026419054, 3180814760, 1239600240, 3443816247,\n                4103641786, 1778116375, 1356356349, 3003002432, 2464906412, 3106084532, 620250446,\n                2199567717, 4285388064, 1443224417, 1183702872, 2361871288, 2889920918, 151923059,\n                3665604400, 902272748, 3673929087, 777413599, 2880183228, 3116820884, 12649513,\n                2151951398, 2517689255, 2603024997, 1540902312, 413276528, 463295145, 1270795006,\n                3197387059, 1235198896, 1591251569, 1536841283, 183104831, 1099570929, 4157586543,\n                4245916264, 1187513801, 2725120513, 2263045835, 3616676335, 1441932591, 859970322,\n                1785738074, 2632201495, 3074325275, 3739260875, 3210655551, 3115242275, 2776972168,\n                1857654859, 3388697322, 816121986, 4034608581, 3645370625, 3901309336, 3655082618,\n                694485749, 2189293828, 4003306605, 2104718709, 2248125819, 1242466666, 3425122185,\n                2526773969, 1997783773, 3366295660, 3638946293, 236310604, 3074020533, 1544508523,\n                2720105666, 4275312048, 2125511485, 2928099726, 3115904574, 1659470574, 2302631502,\n                2782437446, 3351759933, 3997936888, 2966997408, 3158966556, 2819300721, 1647111112,\n                3003598038, 2858959466, 2179510155, 2584211049, 2202151208, 3064305858, 898246753,\n                1503685985, 3011437597, 3645693595, 2240988222, 3440343576, 4238868402, 3504605984,\n                693969911, 37266154, 53849195, 240646457, 1676768678, 3078948456, 353299888,\n                3398599422, 1225876435, 3474721352, 2919885255, 1645273187, 1329251097, 63136291,\n                3744051145, 3578975497, 743346836, 2992151082, 2097992510, 2029339826, 1064760489,\n                4287623009, 690583934, 2137261889, 2523731672, 2989051237, 3080671706, 891097198,\n                705467787, 3974619780, 2507988307, 3580098689, 2900468355, 2065761093, 1093422169,\n                3699292714, 3679511724, 1376356943, 190833907, 1757023356, 2392875706, 1341718208,\n                3312756053, 1335629721, 3842952633, 1585023162, 3483717351, 1166983906, 3797224124,\n                2704194560, 3663191348, 1943345575, 2900370013, 98538425, 2337184175, 665720157,\n                3985681094, 1514818198,\n            ],\n        );\n        // - bits != 0 and Barrett condition in limbs_div_mod_unbalanced\n        test_only_verify(&[10; 19901], &[10; 100], &[123; 20000], &[123; 100]);\n        // - limbs_div_mod_balanced, q_len >= MU_DIV_QR_THRESHOLD\n        test(\n            &[10; 2283],\n            &[10; 2648],\n            &[\n                3352941598, 3865259069, 4100372468, 1153884783, 3551739464, 59160376, 542012042,\n                2236793144, 552149400, 3785998871, 2245653521, 2409739829, 2573999247, 3383580072,\n                3537839900, 1800846733, 3935526498, 361012784, 2531357419, 3553113631, 2410557200,\n                583408141, 3768359305, 3429382207, 653740782, 2770578614, 547505820, 3799199419,\n                579588554, 2311425149, 389629528, 1207262435, 2369107295, 3706674098, 3539705585,\n                1291978910, 48205553, 3769782509, 116475615, 3232605021, 2340006404, 3412987383,\n                1384309659, 2215239759, 1942462745, 2588181253, 2684650591, 1257320673, 4277802941,\n                958808384, 606057277, 3147308225, 770499239, 1471078323, 1270490723, 1467056681,\n                1895212705, 2201929338, 2102169879, 3620413218, 635666763, 569457881, 3894059482,\n                2680054308, 3602399856, 4134893864, 4290529946, 2930760993, 4047561930, 2289637023,\n                3542709032, 192324913, 2131616688, 1889179343, 2830556125, 2071197973, 2105996730,\n                949597522, 897750365, 70094343, 3723815252, 2416305558, 1343266059, 3370097189,\n                806498684, 206432944, 3041278862, 1744541256, 224141755, 3110999564, 3362772841,\n                2421877055, 1717381634, 348336738, 2637922202, 2392853940, 3292333937, 2201713794,\n                2114914809, 1121818844, 1870800821, 3147561780, 3324016521, 1200997507, 1342809995,\n                850923048, 3583522625, 2731648896, 2594584541, 3890526868, 2599265209, 2411009154,\n                1774254374, 532444790, 2622092896, 3509086892, 2563255478, 3507174912, 3134562215,\n                3573536461, 3803846265, 778670720, 2230332276, 1697423243, 85700226, 969711479,\n                3505043587, 3297200562, 3609467049, 3662693589, 1818999322, 4028100981, 4171049232,\n                2406321492, 2679681856, 857327639, 3423532043, 1257720770, 3090300222, 188156280,\n                3651878387, 2836134823, 3082809968, 3017209674, 2994744466, 2209427910, 2161073841,\n                2518334235, 2747949904, 1514181761, 2963843535, 270222615, 4096734680, 2099374675,\n                1696553128, 1926409097, 3454305722, 1118607235, 2127714518, 4097359941, 1136116769,\n                1071932743, 2900390949, 442288212, 3866263192, 717449078, 909539744, 3089568997,\n                1780473113, 4109927051, 2885887984, 2499567691, 2657115664, 1600427383, 3916185142,\n                1159449752, 3516682650, 2230663677, 3808047887, 3311279083, 1113070132, 2694645626,\n                2405191541, 102053937, 1253521286, 4264380542, 395088166, 4244788789, 737121534,\n                1533918350, 1421656021, 1823064241, 4285578303, 1145239996, 1373063198, 1447479413,\n                3110566560, 2228989155, 2568955150, 3091730457, 2167077931, 1000704813, 1365724058,\n                1622364628, 2600037337, 497840569, 1286515240, 1963466706, 3435274784, 1444436503,\n                3072121470, 3528252416, 3499581434, 1487555088, 2939147354, 1884571487, 568110034,\n                1867883974, 3613945741, 2941248381, 3062867723, 1051501799, 1341244124, 2776237803,\n                1573493621, 4261946497, 1174438344, 3969798321, 3102138455, 727003024, 2176697125,\n                410088182, 1687162110, 334286567, 476511714, 1268317677, 1366540862, 971968086,\n                2138545348, 314951050, 2549414696, 565905760, 752921380, 752912976, 919710852,\n                1747578544, 637407331, 895745615, 3928514299, 236178919, 2099477779, 2964313723,\n                3735673656, 2936293548, 1281316406, 2181151134, 3376904737, 3557977206, 1928051613,\n                2852078038, 1824332746, 512024805, 1603493621, 2435305148, 2144349581, 1331930562,\n                3278175766, 1538591372, 351100581, 3662257053, 3132051881, 4014279503, 3747909981,\n                829713073, 210609157, 3696228065, 1740580647, 4134052799, 755637464, 795323419,\n                2849194170, 821499939, 3879325297, 3763047250, 943359378, 411631726, 4062170203,\n                268447990, 41972768, 2368084446, 2195089954, 485925597, 3124084755, 3180106404,\n                4183765083, 1541224878, 675908427, 2052803359, 249079602, 3524972440, 2170545402,\n                3446583891, 3710920834, 1942843298, 1218812510, 1382515762, 2725872755, 999055630,\n                3177157328, 3721528640, 1836334439, 2344692655, 834120671, 3024104186, 1076667078,\n                1133950510, 4188852844, 580162168, 1918097294, 1770073085, 590997459, 1210599652,\n                1632475170, 3051890039, 42749444, 4269218580, 2222311225, 883198162, 1888411854,\n                4183890545, 3246570683, 195442368, 196037051, 974729437, 1342078148, 32826947,\n                3572916171, 864015929, 295109535, 2224357476, 1361921758, 298048697, 726601358,\n                2826594017, 554358481, 966095240, 1972650035, 2817068489, 1969200190, 2467562829,\n                2081888672, 2831836860, 1790053370, 1806900511, 248405477, 4212079279, 2050637813,\n                3530389869, 3211759308, 1819585111, 3529543975, 41959328, 1229293924, 2778327079,\n                3410107750, 1442913286, 2637085780, 3883716744, 4045095498, 2205587602, 4281963295,\n                2631929941, 3285243142, 1613783652, 2182382436, 285809098, 1288018550, 1703517393,\n                2680782178, 4260228630, 2930513450, 1616109485, 773198330, 4287295895, 1236258458,\n                461840545, 2803605868, 3156784273, 3166478490, 1801557871, 2904634333, 3502927223,\n                3070532647, 2198772324, 381276809, 2943658000, 2148911850, 1426315320, 1005257343,\n                4276366730, 2202788903, 2161973870, 3609320518, 1461876661, 3668805867, 2080797435,\n                1225245034, 3735216484, 870533159, 3529202324, 358216445, 1990249735, 3407662275,\n                1313139948, 1381815569, 1818671019, 1762902291, 1548317770, 2642568638, 3157152070,\n                962148359, 3249314108, 3285001996, 234560851, 2533219266, 1450736514, 2328971594,\n                2147646886, 2911182861, 289496119, 3820875108, 1613803218, 240307579, 428421238,\n                1219773262, 1375112614, 268056704, 842341040, 408523626, 847433923, 107050208,\n                86686181, 2890182805, 1583672238, 2043054348, 2975392387, 729830685, 2449742790,\n                4196893844, 2272991634, 447829360, 904418846, 3769077942, 1428195213, 3927252138,\n                4021669144, 2881630524, 323590000, 210792473, 194270793, 3020394847, 765483391,\n                349124164, 2615178332, 3314188419, 3822943107, 2988433008, 908388966, 1922979134,\n                982324796, 3165493043, 2849765788, 842972206, 3591780767, 1395976813, 3228082170,\n                2792837035, 3191784579, 2660042933, 1748797889, 1321422746, 3145111502, 3141814433,\n                3652370786, 591050983, 3494741231, 3350752369, 1421763191, 3132442705, 558545178,\n                975892805, 341911030, 656356144, 2286165340, 450346669, 637140221, 89072045,\n                402213236, 1975885020, 3285218084, 2193991887, 2011954846, 2606898818, 3436080580,\n                2926281199, 55934162, 817769705, 287501970, 3676724976, 1175741578, 4073198053,\n                2495889009, 3073551599, 3155339747, 3969770190, 299485369, 3168323564, 580294856,\n                2875848326, 809536699, 656115601, 2114309196, 1654373062, 3712639373, 3130293194,\n                2807928548, 2954498836, 240485275, 3113332823, 3086822109, 1702151749, 3175011934,\n                4181496971, 836977696, 3745555232, 2371262786, 2867226506, 720581270, 3045708244,\n                1733608256, 3465966605, 3677990793, 2314229597, 698448638, 2489820843, 1526372643,\n                2027666288, 1707567327, 2734820117, 771109161, 2417603233, 2694932721, 452911264,\n                661420216, 1631366353, 4011280330, 3480917150, 2392724203, 770895055, 605594002,\n                3677652265, 1070596605, 1695550370, 1520192671, 3480373122, 3550693150, 1315349952,\n                416034556, 3771261849, 4194856143, 2851623790, 2299561959, 1875357982, 3295047991,\n                2579162284, 476437292, 2621344047, 1994816148, 3905959610, 71550537, 117252386,\n                304043394, 1873648084, 4239350106, 3199297662, 3310636359, 2954431106, 792209675,\n                3870777325, 1853576687, 3581538525, 433574806, 2860924556, 3390621376, 2368554871,\n                627364129, 1574995609, 1142271456, 1569717699, 4094936125, 2944660699, 43018112,\n                2512847729, 2019324938, 3901821844, 3420172849, 151080197, 4016039285, 592588830,\n                3906756109, 4224187012, 301712264, 1658594148, 2249329290, 1292403150, 813304860,\n                4088931985, 1585941827, 390195485, 969134553, 429346518, 568274453, 3605800519,\n                1487806472, 2714928861, 1045313889, 2638728579, 388915952, 270137007, 3010641250,\n                4034539301, 2350307082, 265782436, 2132362406, 3998149319, 2667174578, 3076526276,\n                1383452424, 3003910302, 3125664737, 3778790933, 4217219395, 1379756451, 3479313901,\n                2060882141, 2023484131, 1770391098, 1902931577, 1138972185, 1452977171, 2976115132,\n                3054397980, 2628446996, 201510624, 1412377429, 3907225543, 2304879017, 2142288120,\n                1086991753, 2232923429, 1479196079, 3572928742, 3543916016, 386405050, 719851631,\n                1870310482, 2962941579, 1883689338, 2676428384, 325734318, 285783456, 733481369,\n                2288445534, 2693091674, 2379843793, 205284521, 1884435247, 852671716, 2325353908,\n                4124913230, 392937477, 327089835, 3062247560, 916672747, 4156917521, 3082343686,\n                2693674622, 3446490976, 3436686617, 247823536, 1859601916, 1162033593, 1057243325,\n                744353288, 3435250176, 1935338485, 3028907291, 3961675510, 303110937, 4007030239,\n                3605372969, 103872478, 3052027611, 1081381736, 3561624671, 2918477489, 3971020070,\n                363648285, 3183344665, 31806155, 232323427, 4017720528, 1954445749, 2050700022,\n                4205157578, 512705308, 381960300, 1731331282, 83759392, 2828421050, 2274470436,\n                494185741, 3400884913, 3811076252, 123814107, 2965005277, 1477118286, 3339701951,\n                1091278307, 1116337920, 1418768144, 1581978167, 2613621202, 1223672049, 181842720,\n                2767416127, 875394740, 1142663941, 1729589357, 3090510457, 2184462714, 2428219712,\n                4214716589, 4247769652, 611414190, 1045261582, 3393575974, 171426311, 3441038236,\n                3066029567, 1498812939, 1839959393, 2321762739, 3099316323, 67890600, 3996080557,\n                3993720333, 62433539, 1468624962, 1788898782, 1972996857, 4174341914, 3280590419,\n                2244731930, 3556666805, 691033915, 3208212556, 830813083, 1560342479, 1134321379,\n                2813257340, 2482755860, 2646521539, 3584723926, 3446624641, 3625856671, 673792232,\n                2939933598, 1991301800, 1276891074, 3316991229, 3394991590, 2609715024, 1018617151,\n                1031310709, 1932593857, 4237137128, 901129393, 3082376671, 1433662587, 400269957,\n                3727171113, 330909419, 736956423, 4168039731, 808990789, 3150079653, 239610305,\n                1359468908, 3231418820, 1068230593, 1979002685, 2592886371, 640867886, 3044611728,\n                3787517458, 1024767066, 3213575946, 2698388841, 347657989, 4221105184, 1779863053,\n                1046341482, 1812302311, 3656596638, 1724800455, 3703046924, 751974902, 4122226429,\n                3738981746, 3671275895, 502862348, 417110769, 1973326978, 3615811973, 638559911,\n                1155883350, 2422515487, 2718728830, 1481097457, 1479175209, 824381311, 1858110581,\n                2364677028, 2080382672, 1505406194, 3993956365, 2715420718, 271231652, 2941588080,\n                1950700302, 3846220322, 1419598607, 62770719, 2939727949, 1569073417, 602595177,\n                1245626305, 3359798055, 1703355349, 3690743168, 178363954, 2908127350, 3466799309,\n                4163361670, 787973888, 4008520220, 774913405, 2342214829, 746086478, 3001029718,\n                1878022140, 2782622440, 3392054168, 1257667320, 565538943, 94004702, 2025355884,\n                2968981941, 4000193667, 4168608420, 1155851325, 4224702393, 556865462, 1461683187,\n                3158342266, 1166073416, 1273699263, 2554565259, 2702271939, 492522911, 579919413,\n                3885103462, 556735539, 3432964532, 698421864, 2225260692, 2545013724, 691191564,\n                1289731157, 1780213562, 2296279347, 460468173, 3952053879, 1920067027, 3167597200,\n                3699004523, 2153401532, 3210453855, 1125886564, 4225393243, 512562002, 2855351059,\n                3052922695, 3345993204, 3607746483, 3548799028, 2875625551, 1900275389, 3331125610,\n                224989674, 3527083381, 256805087, 2060275194, 3926180491, 2519363257, 3651109823,\n                3366742327, 1975034105, 1369971546, 4291565104, 2283529341, 2975378004, 194061946,\n                2811908685, 195122659, 30698277, 3264261714, 3143157243, 288763231, 2440056066,\n                2038814389, 444224631, 2238280221, 1503289660, 1334078583, 3724601449, 3300355959,\n                430546443, 4089192701, 57041070, 4196017516, 1508165596, 2889497246, 3745130267,\n                2182795017, 3574952253, 2808300879, 1111081240, 2553888706, 2673754047, 2591543351,\n                90021410, 2953439372, 3797444432, 556661921, 4131718258, 3617100594, 3934689382,\n                332330933, 3005860472, 1591919565, 2055730929, 635280917, 4111376974, 1023831659,\n                435448232, 2726078206, 77158690, 2153293015, 3369430400, 3630029124, 1133297771,\n                4267564846, 263729482, 3205345537, 1981047493, 2365111109, 2389382724, 3463942123,\n                1252789836, 1631188759, 3931403155, 1089070145, 343485369, 2482907957, 39564190,\n                3278898721, 363035113, 1536288420, 170308081, 3629240119, 9963, 3045711510,\n                2913470241, 4291636337, 1529754056, 262759009, 817271712, 1607080688, 737593827,\n                786413904, 3615013534, 487306804, 531158814, 3769512541, 1916818391, 4225331905,\n                2263017901, 3640159446, 3910329829, 3054168261, 781668891, 185410657, 1131242667,\n                2313538067, 16617931, 3088923134, 2285596567, 97320018, 2296939715, 3108674784,\n                3300398814, 3751582111, 881235571, 2889009763, 3491919944, 3263323399, 3347337487,\n                2427854010, 2812041675, 3539673368, 198495814, 1164322846, 4048000025, 3739084371,\n                3734085769, 3235510699, 926485538, 957553562, 3176108272, 622844963, 3094460156,\n                4074719719, 2870619664, 1930018982, 3808075326, 666404853, 2705852762, 619691053,\n                4221033144, 217503338, 2498645430, 1957980210, 2710477511, 1441331060, 1453965392,\n                1218329146, 3234626249, 2734978851, 420187145, 3875048836, 4109064695, 2023449386,\n                3705316294, 3734226228, 1678173088, 2355852399, 2545273442, 1660679545, 1047346445,\n                2851483434, 2385495686, 1845313467, 1434170548, 1876684260, 2864173169, 2858434057,\n                1606312665, 1404069374, 1409272983, 1501865176, 2629801523, 1156531379, 1966173113,\n                982374943, 2780186025, 51018911, 1670745883, 3433098563, 2796786690, 2521705837,\n                2349895698, 3414672511, 1189601967, 2691663763, 2003563011, 3170083221, 446706685,\n                2905548069, 2473452500, 2672119163, 1938341073, 1963072058, 3308540972, 2512499996,\n                3890193954, 3190271472, 1294547060, 154292633, 1145441043, 951556529, 1982588182,\n                2644881742, 1346657469, 1639969796, 3344053522, 1134687904, 603093703, 936617365,\n                2509419533, 680100671, 3656867476, 844884523, 1426442225, 1247488423, 1442787747,\n                4038072298, 560676042, 3167315140, 1367214747, 3536486947, 2853294519, 1136378567,\n                4026892739, 3443804471, 3243823117, 3189117970, 3844359512, 3716938307, 540784417,\n                2981956124, 1720572142, 3834798996, 3204329258, 3524043696, 891709759, 2358715990,\n                2249911045, 3497271760, 1870817405, 1453778751, 179255677, 2275729572, 1720686084,\n                2198280122, 587446621, 3277712905, 2994960400, 2828218934, 2978053083, 1152064605,\n                1863664141, 3416092329, 3147585282, 2404365896, 2520923621, 4144562663, 3306225086,\n                2030220496, 3587351850, 4122478346, 2659218421, 708542702, 2920393449, 2724650275,\n                75837497, 2495363342, 323083023, 4113859057, 1224677188, 3523705698, 181614693,\n                1464538763, 2447172354, 14093408, 325546099, 675680947, 3772468734, 345460982,\n                3224933462, 354558048, 449647873, 3016480523, 999347881, 2244728783, 3607973886,\n                1243947858, 2867395630, 1677541562, 4148542415, 862425012, 1470826913, 1052156219,\n                1728527766, 3578908356, 613335170, 2846084569, 1561352258, 291274331, 3704626207,\n                2762818579, 3245081919, 1343250043, 1615662229, 2531097670, 219127971, 2938579671,\n                3018648863, 3648602704, 721153328, 3110227800, 174697874, 643678501, 2670530392,\n                3158908975, 2804952646, 2356598803, 2050807595, 107662147, 1685361536, 1308533998,\n                1201813904, 2765954423, 1339748516, 3870256564, 2218776576, 854059437, 3907628986,\n                3886388047, 1688308435, 201296086, 3766085655, 2036555838, 3481613745, 948797408,\n                623304414, 1696856886, 1141726531, 3305871632, 2059599793, 908357061, 831275983,\n                849593710, 534797383, 793513545, 2370402315, 2777618690, 2628626407, 1757921480,\n                1691753018, 1285901466, 3426285239, 1331079772, 4146654863, 4024544110, 2979788510,\n                368467125, 24345681, 3073350707, 2969826896, 3884548140, 1799669248, 303853872,\n                207913625, 2141350731, 4138734403, 2939418084, 2306193173, 1408426023, 53245159,\n                225958934, 3592303602, 2276071422, 3558775671, 3798844796, 2812825104, 1149309307,\n                1671473834, 3741733619, 3464120030, 816392559, 2544850933, 3324452198, 2766215433,\n                2754927401, 136530698, 1546386029, 1670932675, 658949286, 170713198, 1210990734,\n                3743021444, 535276301, 1626462684, 1738421569, 2230576599, 3137963179, 1069299320,\n                455706470, 2580258203, 1360344399, 2862263047, 1370723388, 2792952777, 3846954515,\n                4209499685, 2927081264, 1204584971, 2379333741, 558569530, 1853212826, 3391360408,\n                1040513901, 1559770267, 876307615, 2824088, 1726280519, 644171358, 2706107769,\n                1680502933, 3489334226, 3424452901, 1495977214, 2224502270, 3728096365, 544320834,\n                4204260145, 2679681016, 820042458, 2850750985, 309319576, 1824964053, 1698100227,\n                3367290062, 361573975, 92583228, 2004326206, 493109001, 19484891, 3513638673,\n                2024772169, 4182578488, 3969090556, 88306186, 2631515405, 541817465, 3963902259,\n                994021943, 2974115977, 2296327675, 586210092, 1897225015, 4176474579, 2151973839,\n                2337213554, 2187117024, 2420055192, 3210640273, 2324839717, 1368233728, 288508901,\n                4085658026, 2082314040, 3764593412, 3125476362, 1600660512, 2149788730, 2427665180,\n                2997014598, 2154927292, 3917694996, 1539578838, 2368889526, 2995386165, 3409788340,\n                2886433974, 305855824, 3257718445, 261611974, 4227264599, 989750356, 1040361259,\n                4210137765, 2025815163, 2075444018, 583224675, 1301409366, 952488236, 864737326,\n                778670543, 8355060, 2923623421, 570431183, 2146789689, 1321011113, 247566633,\n                3943346875, 3696321262, 3176959573, 116528996, 13668972, 3406819072, 1902636191,\n                3113341004, 983724362, 3272488923, 4030017163, 835027824, 2238285483, 2548203205,\n                853361272, 3602065527, 1893771807, 3292565667, 340846533, 1750230819, 42266476,\n                718060706, 1584722703, 2580995200, 3686307554, 42260378, 1141531492, 791080198,\n                274869305, 4239725097, 3419290367, 634711851, 997215417, 1544807754, 2078245666,\n                4238725987, 1172084063, 573057941, 3811717672, 1862508866, 2392223776, 2246649095,\n                1911826635, 3716573075, 4256209707, 3522457949, 1340206478, 2517529807, 2221194466,\n                798990140, 759140438, 2674366145, 1344189665, 72595386, 723597581, 3593659419,\n                335376232, 2753787811, 4017574301, 2990058171, 3225943710, 1953159124, 3613021838,\n                1905719752, 1955073033, 2340717037, 2676910034, 3772473222, 3296466198, 3389933517,\n                2434303156, 1827448545, 1094002802, 3686776366, 3309239944, 1401087443, 260302646,\n                3203194394, 2134171894, 719448679, 1930627162, 3244219325, 3378404381, 3812681251,\n                2441318219, 2554633492, 1638940565, 3656938790, 3303253879, 828306443, 3638677120,\n                1326652936, 338801470, 2089611888, 2182150992, 3959668269, 3276592769, 3232487203,\n                2699698479, 3711459231, 1260821803, 1941766867, 4251289643, 2593320982, 4208132401,\n                3268186492, 1107538016, 2560397818, 1455893406, 772798556, 2010059348, 1412329555,\n                2751622179, 3345879875, 981350120, 4220854172, 2570887849, 2604765825, 4152631207,\n                1280682784, 3587177396, 3678567847, 710852020, 4067970368, 852353955, 3615534147,\n                2639984158, 4167767411, 2761837378, 1513673525, 694793254, 1894362672, 3263805017,\n                2976737806, 2775946012, 1564642610, 550950721, 3276449658, 1159035543, 2521734550,\n                2336608068, 2877139214, 2245730435, 3068431322, 4272866276, 274664347, 3097556962,\n                3342326698, 3870423352, 1062641621, 3999456880, 1663122741, 2137008455, 1150577129,\n                278182406, 584570470, 413288288, 953893357, 1619838786, 954237462, 2030868600,\n                3341078837, 1505588254, 996685690, 3838869263, 1899435389, 2717743049, 3274864849,\n                3237346116, 2342164642, 139415908, 543879245, 281171972, 2551065661, 2525750051,\n                104753154, 3488693617, 2239811298, 3907183760, 1861147359, 2237652376, 821384415,\n                2556443506, 923807176, 1114497964, 1688435037, 418913733, 3780821965, 855870812,\n                382500784, 3672042270, 3987791218, 240406871, 3177312849, 2339645894, 3663387343,\n                1718477391, 609427853, 47138600, 1392173474, 3322084900, 165330900, 191665056,\n                3375525145, 1887282863, 3045589263, 340365534, 3681803191, 3761997474, 3100098094,\n                3217118214, 1203379379, 1450361464, 457167927, 1523878470, 682498098, 877912245,\n                3964961947, 3161518987, 1518633749, 3120873652, 2576970448, 3300695214, 2791936052,\n                2714172087, 2724523327, 2456178494, 3245773223, 3724143762, 1011922455, 2468133615,\n                1328520608, 4243852002, 3530232048, 3958621534, 2186530782, 3190800545, 421915440,\n                3732105573, 894766418, 3912473160, 1873602277, 3818847891, 2911857216, 4022363100,\n                2455241114, 2315909413, 4188396625, 1322637246, 2354013201, 3533097733, 3150407740,\n                3447711566, 4171141781, 3043204910, 3805211328, 3849054297, 1738944382, 960458108,\n                4100056853, 1452230905, 3671771463, 793342064, 2052502384, 126345260, 4266351554,\n                2739791171, 2564099162, 2054176940, 4104860610, 2880824279, 1824609945, 2290885592,\n                2080132465, 3293516142, 3225255226, 1903846973, 249770957, 3607270679, 2039840265,\n                1484740747, 2799626769, 232574972, 3198581021, 3408176098, 2283476893, 1378712722,\n                2267853117, 3801697208, 4042881095, 214208749, 61544914, 723875937, 2544717728,\n                3107244281, 1942406924, 2204315142, 194788263, 2081604187, 1429321846, 3818022117,\n                2227370780, 35034435, 3300785703, 1916258515, 3792740919, 341949768, 1510985228,\n                935888111, 2831355401, 1172367405, 2779293526, 381002684, 1203468318, 791299579,\n                3228453447, 2164274465, 1578115502, 2644529284, 340751106, 116209844, 2355694636,\n                2729630500, 3450921193, 4212016059, 804469812, 2549255576, 1849673577, 2728107038,\n                299357951, 297926966, 1885179687, 1460468723, 1061492634, 2653222691, 2880953738,\n                394617822, 2279747967, 3993584895, 3177779497, 3847988196, 1617034158, 561325326,\n                3691960099, 655631397, 3717838062, 783893013, 2851649543, 2631344086, 3916534255,\n                4239514467, 1949848383, 3484594726, 1770224734, 3906314793, 4005839418, 4207121646,\n                2201510217, 528220266, 614751096, 351840326, 1436422606, 3907682814, 3423937400,\n                4097091480, 132496980, 1854199064, 378621641, 58135356, 768061170, 261902503,\n                3235989531, 3944366822, 2897288002, 76638955, 1608646444, 888012857, 2965667012,\n                1070852076, 2826174185, 826355269, 461939309, 2089015901, 913565948, 297310628,\n                1453100438, 351883424, 3277154215, 232696739, 373302545, 254462392, 1382840549,\n                2396260914, 395629689, 3690272782, 347837558, 3442928069, 565974422, 3199867881,\n                1394223081, 1414226204, 411776212, 366110497, 2215785507, 3336617752, 1389191042,\n                3230116820, 2286308091, 1103652934, 3278839516, 3987773259, 2751916818, 3426671738,\n                52390424, 3788159002, 336944991, 2490094935, 852597407, 806843902, 1247443822,\n                2022880264, 2704535770, 4119940159, 3352245584, 614580992, 22768085, 3281732273,\n                3360660161, 3184765773, 2103780889, 1975453788, 1520016309, 3642758446, 2329500419,\n                301513139, 818876954, 4020148877, 783951920, 2289116618, 2759423270, 3546488753,\n                3471283776, 1350688833, 3882816801, 110527762, 731506281, 3875805926, 361558987,\n                2733293446, 4149112272, 2738842435, 3457365282, 1911203461, 3791694111, 1986738012,\n                1121816344, 332259749, 2539780233, 1500659471, 1583130056, 712133978, 1118188024,\n                1648568355, 1769554028, 3303786687, 2270603708, 822978229, 3963942206, 3944801693,\n                950968052, 1427806001, 1761238700, 927940075, 3972749169, 207889573, 3360276654,\n                3703034669, 2752232151, 1355645600, 3309499666, 2234034742, 3333706992, 3679565790,\n                77914175, 330403612, 3453596334, 3459410678, 175508592, 3753692883, 373965805,\n                3840567680, 1424343310, 1202542810, 3690575999, 3214807968, 918808778, 709316579,\n                1472859715, 2605553991, 1502769065, 2626246324, 826592139, 1164837467, 2821720060,\n                2611020842, 4187248140, 3363390475, 2799120749, 3670536960, 2795389205, 707717410,\n                2060782639, 1982852844, 4060378888, 1138561015, 3906784820, 2931775722, 908740949,\n                2432273836, 498592088, 1637289171, 2159879590, 4047017466, 3660792958, 2115652508,\n                1209950895, 2345077512, 2128606337, 3052623652, 2014505870, 2055498585, 4179829578,\n                3728976993, 275050537, 2552939213, 620323796, 3714857310, 62090404, 2682354799,\n                181021002, 3494582794, 600379307, 3560414895, 1350459482, 3565826612, 524507499,\n                1413687814, 1405059824, 2383744607, 3387756791, 2559380951, 3351617500, 3677287602,\n                348058713, 3224158492, 3746961259, 3757007545, 316694990, 1967943132, 1845094737,\n                2029405643, 4226275584, 994479209, 1270994116, 1958491610, 4132050946, 3967659388,\n                3029819959, 2977591836, 151469162, 2398127247, 1593561927, 3507232654, 241564748,\n                1740951350, 386885364, 2933913818, 1720957320, 87561347, 1723480837, 3552803561,\n                3556853653, 2031086874, 491826579, 2079567355, 2169699209, 3044943289, 4056924672,\n                2307645608, 3537713376, 2908104019, 3177159128, 929013201, 433566853, 1352264950,\n                2480483252, 776517141, 1309218572, 1434953184, 3391313612, 2741185955, 3363829478,\n                1675086390, 972223600, 2744479033, 3266794923, 35658808, 1579045646, 873399878,\n                389478288, 1382367939, 3653633542, 3233170189, 620600047, 984251838, 3024949168,\n                2365493295, 3895194616, 4057529727, 1430697808, 596632735, 515576435, 3485088618,\n                1561260468, 2326132425, 1441097513, 2650789119, 2657744738, 2044628817, 420984447,\n                1799231880, 2547017352, 2745434926, 1298092765, 485912325, 4050696110, 2449075835,\n                492836822, 3202477568, 1240801219, 3646284028, 1647715380, 3149177250, 2943417567,\n                1413539007, 980840595, 1125336194, 3751306352, 2855978526, 494149037, 2867775588,\n                4113812967, 1263704367, 2910496580, 1593721994, 1085528744, 2264130185, 83269382,\n                1115238432, 2604100592, 2577869874, 4196698412, 2704878249, 3617944011, 1349932536,\n                978828117, 99862233, 449450281, 2396577116, 3678387947, 4259742516, 1322631672,\n                1915561686, 1264795767, 2769207380, 804413524, 1232505337, 1220009724, 1294287873,\n                2855456734, 3927255440, 2712197443, 2491275022, 2240407480, 2761036179, 1837202003,\n                1106888468, 1417477688, 915296319, 2039342274, 2733613182, 462637863, 2840649864,\n                3100484828, 2719672892, 151906935, 2261319585, 2656759829, 1519948884, 719129572,\n                1682072090, 2781457991, 1350068632, 3274154190, 2109173442, 1908724382, 2419052419,\n                2028679234, 3203173989, 2590495456, 1989273280, 531511733, 3566448108, 3462338174,\n                4277911603, 22298737, 1524273119, 2709336519, 938092901, 295799642, 902385642,\n                2137236380, 2789233877, 3682007324, 3625684954, 3614857056, 202468198, 1226661917,\n                3159277477, 3560648153, 3819621278, 540332999, 2944854747, 2409193978, 374804764,\n                1336405091, 3018475595, 213078133, 3384614741, 3290633661, 3332242057, 3224858586,\n                3203591826, 1245392207, 2580283994, 2701486219, 2384381770, 3098276020, 3123910700,\n                4085709500, 4128158718, 603139521, 1135525058, 3857642684, 1410378644, 78359003,\n                3406390922, 4092337337, 3213773240, 4197894447, 1942316430, 1258637305, 4239250867,\n                3475475336, 2655363530, 3739419561, 3143231964, 3957503737, 4047803818, 434992995,\n                2450348156, 2837933497, 51567125, 3207610947, 3292696078, 3101011969, 3766828611,\n                3055435588, 2877370050, 226359606, 3392837464, 193077577, 3311782725, 3894789730,\n                3316160046, 951206256, 555159409, 3162879474, 472431400, 570576174, 753157825,\n                4105008110, 1211132986, 318543594, 3685357622, 773996108, 3754567744, 1249414550,\n                275208091, 721342432, 3031780362, 3383028662, 2217171095, 3427901388, 3933669498,\n                109992127, 1145753994, 1494149615, 3600238607, 3201504597, 580777735, 618124048,\n                242104221, 129496845, 410772906, 2537408883, 2754275686, 2639107980, 725841242,\n                2443820926, 1893265753, 3447797702, 2933959901, 3214099889, 934279127, 65128819,\n                3272362684, 2552082822, 2090528760, 2559891538, 118281105, 2672518703, 2096202720,\n                3273414364, 2037459504, 3370827896, 1699701315, 1606070586, 2904479552, 3315003695,\n                2820748303, 1793140491, 2962952508, 2710637011, 2678335574, 3590547790, 882661210,\n                277613712, 1784245098, 2779933225, 2310988284, 1408095043, 1622616915, 1839606749,\n                2605774208, 2254855010, 2957400503, 4242380003, 2773759547, 972422801, 967128554,\n                2340551928, 1861158625, 2404129215, 3647330257, 1574228621, 3419433492, 2124217412,\n                240959784, 1320622909, 1747700367, 2755288827, 1824869076, 407182857, 336533520,\n                736075625, 1196548381, 3239474159, 3048296225, 483742895, 2994857359, 3209699333,\n                1469442024, 923109824, 1382969239, 3174660371, 3212452354, 1807036900, 3961861384,\n                571414940, 3034500868, 2064945562, 1884621518, 4273342775, 3337870380, 772881427,\n                487872381, 1460921875, 167725087, 1193045309, 3438378745, 206582715, 733951678,\n                3780148814, 2296573340, 2888500099, 793860351, 985954389, 2244404490, 1686378278,\n                1286463227, 504058677, 2940924721, 3628549544, 2298279082, 4074139272, 3318550839,\n                2078691953, 3904311006, 2751358613, 3134421831, 3689866939, 471611259, 3585450053,\n                53341630, 1433114211, 4137751343, 3233461668, 3138867815, 1669897675, 301150150,\n                73141700, 1222677780, 1821445642, 2626124657, 3869544082, 2466140961, 1867437858,\n                2283701970, 2364920272, 3852084637, 2567337268, 3683422908, 2747924360, 3880780234,\n                1860180562, 3714959304, 4123133298, 2021423060, 2077485881, 225646782, 2336847691,\n                1461822489, 130273718, 2894035181, 1084935869, 3834746928, 2778596117, 1594764681,\n                700265718, 1902646838, 1363673254, 4114066892, 1859912045, 435194699, 2491267954,\n                1053346475, 2418313825, 184677741, 2294122112, 4244326950, 1517107134, 3572119836,\n                2968484987, 3666330450, 3979403703, 2036049749, 2719225873, 3938641674, 617427440,\n                815463497, 575728460, 3291828497, 1043374761, 604294591, 3619555499, 194736919,\n                2546021062, 1050882061, 3837091824, 555004663, 1668443581, 1907761109, 1777339140,\n                154502652, 1192574008, 2967586359, 1956114947, 1059598381, 1680712924, 2611921118,\n                1170015973, 1798997495, 362951246, 3172658646, 3632419746, 1334773961, 3976403025,\n                1604507134, 4057780710, 2463567881, 621884418, 434643179, 2303536415, 1378521501,\n                182935114, 4226457937, 1861600714, 3698888173, 710367560, 2290293929, 1660299298,\n                1003266145, 1614223266, 3903798180, 1421639545, 3329173822, 1980085434, 2610822457,\n                2296634936, 3837413666, 152461017, 4072600229, 3860162625, 1102141974, 1707290459,\n                3416778051, 2826572991, 224792111, 620251130, 4001879930, 3041187018, 2257061408,\n                2953988237, 1050117564, 1566680723, 3569348398, 3895084389, 2279563192, 4145303386,\n                3865963395, 917194771, 1529108810, 1483738511, 1364174636, 2884583785, 1890244693,\n                958296239, 3472389716, 1186326098, 2140878101, 3783117706, 991645649, 3444958227,\n                1241410709, 2300684342, 585778329, 2121441728, 200352242, 3554821900, 3515050051,\n                1013367459, 4150105309, 3592078139, 4074451175, 587413402, 3265599719, 2529856805,\n                4244056558, 4072403842, 3104615316, 2805257814, 390680494, 1879691966, 2588945355,\n                935618168, 3813809475, 3315398574, 3636679403, 29389301, 956420692, 2461914496,\n                4107004684, 2723760888, 3936011913, 2024331212, 2450012726, 302988290, 2741245539,\n                489985017, 168854395, 4145632475, 3348641173, 3483375137, 2267242998, 3821788835,\n                1500990181, 1102216180, 2522627710, 3739104751, 3968030494, 4150934004, 489690835,\n                260506722, 1113595250, 825720166, 4271989921, 1692626437, 756162517, 3018843962,\n                1009961164, 776249663, 1457130315, 2499776103, 388172068, 1401931394, 627698688,\n                287314572, 269662701, 3149013861, 1642206188, 1180957409, 371610907, 2393570134,\n                2964591267, 2480333347, 3025831710, 3717481964, 231048978, 194179706, 587444409,\n                2010083858, 980770207, 1026370399, 1179743068, 2792643637, 4132609170, 49332703,\n                1412722994, 3016115316, 529076589, 1972709189, 128813830, 1532167613, 646111429,\n                2038237049, 2552100089, 1852245650, 2121119349, 4050924288, 1001258012, 3002257343,\n                1006242596, 4197333726, 3785607155, 1899057351, 209150997, 2943164961, 271141033,\n                308133959, 1598574082, 946544384, 3049246031, 3136618323, 2964435656, 2378700241,\n                2878579386, 2797948570, 575272375, 3675742452, 4044544470, 3518398596, 340879154,\n                1751409701, 2003106873, 2680471427, 3034973115, 404982343, 1648254750, 3438446325,\n                326496853, 414296402, 2298977583, 2033290810, 1517186933, 696398609, 434702008,\n                1636984193, 3182749650, 3067231181, 821004408, 491225538, 2694332105, 3634010658,\n                523231120, 1261908927, 1630854003, 1338318556, 2787957072, 1884258157, 4003603151,\n                3068923237, 3204155879, 1508622908, 1215621040, 4259301989, 3430911876, 4080344501,\n                2599578809, 1912454190, 767417636, 4012455246, 2151245570, 974420560, 2719564908,\n                3280911801, 4241226322, 3777914170, 536905698, 835045394, 1911481927, 3620312534,\n                2942899656, 3760905009, 2074926029, 4176746017, 2469508557, 1929255162, 1657639950,\n                2716801832, 22336494, 1195357815, 1422585254, 1874307911, 3198517022, 223354754,\n                3323948180, 3209547520, 1190171800, 394784888, 1640980643, 630307724, 2036676005,\n                287039132, 3251918809, 1030982007, 4246784801, 1244050735, 3074276551, 1250819685,\n                3809668227, 104238959, 2670846655, 1533972167, 3067023947, 2415515608, 917603302,\n                592440565, 611377455, 1299190767, 1939156996, 1788934393, 3186649882, 3681837145,\n                2083672672, 1196126620, 1806064279, 1806838116, 4240579640, 739999337, 1098091142,\n                1664190189, 2991224025, 1923902267, 3945259600, 2658937590, 3726575401, 1230419543,\n                764707230, 3549313932, 3642424943, 1172885982, 1789374295, 2360482756, 2780394134,\n                2473472446, 3209657800, 2099441302, 343054463, 1459528931, 1021394506, 1816423506,\n                1601401383, 3064233088, 3259222355, 823671598, 3534219776, 3057131487, 4112592391,\n                2783467128, 3868566268, 702854391, 265064015, 344847057, 588017928, 2234898225,\n                1072515401, 3858512687, 3172259969, 2790437958, 2812769030, 2651544961, 2859171487,\n                4071197034, 3260715658, 3653780825, 960634056, 1279190064, 3663377179, 1328571309,\n                237244914, 663195520, 1121502200, 1386985313, 2964079428, 990137762, 3677208200,\n                562536179, 522373400, 2577496881, 2954694441, 2901335475, 1678665494, 3580889300,\n                137429613, 583855456, 2768859992, 1684983888, 887775211, 3667114619, 4013712371,\n                466790664, 3399994087, 1172332809, 2809459941, 623322023, 1753469431, 1675051448,\n                498176279, 2207442562, 4016251328, 3185194281, 2600040851, 4270582732, 1723627381,\n                1631498182, 3960806710, 2190355785, 2137601052, 2278263342, 2066183413, 3859845987,\n                2932413281, 4138343518, 4135936067, 1789261648, 3051029009, 40477262, 325390641,\n                3536676044, 1511190721, 2002391507, 2334607786, 3872900627, 2558273463, 2249944299,\n                306737834, 3077116541, 3436927049, 2837294326, 3939848585, 1817825412, 3689962232,\n                3874263331, 2528990281, 4020542608, 87030143, 2888357544, 2386482209, 2430768040,\n                208306461, 10322350, 1326860706, 3769524590, 2648363096, 4288581473, 714713903,\n                1505322989, 2287854817, 1900232455, 717665487, 2206697255, 3320079515, 238263521,\n                3779932000, 4291033226, 1135011350, 1549279832, 3468014233, 3779721960, 3664469845,\n                665493332, 765366809, 1006405486, 3594166055, 561989023, 882671877, 2264533342,\n                3140063933, 406699684, 4246323920, 2339167001, 1783144553, 2086830194, 792259729,\n                2055752400, 1503053078, 3772837246, 4206234055, 1820416778, 109615414, 4101436885,\n                1735287569, 754370562, 262726395, 1566536381, 2291152860, 656632823, 3795882518,\n                3102217658, 665395103, 1608144010, 1445439113, 900539898, 3853476929, 2401562096,\n                1380339985, 2652722097, 514817454, 2508510877, 2242620781, 3092675696, 2176715756,\n                751784508, 3829100853, 929922339, 3976876619, 428408992, 3103972711, 3091047489,\n                3499654318, 730418292, 3976731332, 720471960, 3321231524, 3822050235, 3006219256,\n                4128715548, 1901210946, 1904321687, 2347804532, 2441708401, 644662079, 2642956374,\n                1202342572, 487559801, 2541351849, 3506127277, 3748411961, 1020813277, 2204234834,\n                2668314131, 3540550786, 3156593674, 689247699, 183287391, 3623291437, 3096141502,\n                1122829497, 2830342673, 1277696873, 523256736, 3580548409, 412193661, 3390072822,\n                1910577718, 4000272642, 3157003401, 3120575397, 3347285717, 1105801291, 3526168444,\n                2277601066, 4126289064, 3603202161, 3714461246, 637329241, 1506073901, 140763919,\n                159059625, 570372100, 310655276, 4274054126, 652820072, 2665232536, 3249851629,\n                1215359787, 2325162303, 2513932058, 3352242508, 2859049505, 1484882680, 4235526646,\n                2025797853, 164609077, 1438493508, 3761009218, 3665206095, 1595187746, 1062512728,\n                956546028, 3846483422, 3574864413, 2743831638, 1475164144, 2011784204, 2110784939,\n                2358003518, 3759373203, 4256674738, 1436800746, 1411553200, 2774888497, 425035555,\n                1915114919, 448640415, 4163842478, 1189142075, 2598603359, 2150021519, 475551616,\n                4043651335, 2879473669, 2633187236, 2307941991, 168392305, 2351213187, 7536760,\n                1570396346, 3287927468, 2942827206, 4208388387, 3851127056, 1750219284, 3767183313,\n                3893440254, 928449456, 472638248, 50253946, 1304140612, 2794306168, 308727834,\n                2870656027, 189076424, 1746584410, 3959695155, 3279489516, 3039347640, 3096646029,\n                2748502756, 3324587967, 3261840469, 3057046585, 2727997697, 1104035019, 1280696830,\n                3477204367, 1297971334, 750607414, 2433365552, 2601518004, 11258684, 1040704941,\n                3715818873, 2158787114, 7016446, 2925548686, 622135942, 1619542473, 286908419,\n                718362729, 121666472, 3119289134, 3087945776, 861582939, 425296970, 1263438729,\n                4065557937, 3959986517, 4134693254, 1925794123, 193437418, 3476905956, 1511712377,\n                3238874232, 3312526937, 1773669437, 1585186417, 627240956, 1936130968, 1481159394,\n                4283758747, 2641584867, 2666928986, 3452821649, 4178531521, 1822700059, 3415376573,\n                3881394922, 1692296803, 382840841, 4000638979, 1899699449, 3696396074, 2530736870,\n                1339745766, 1620430034, 2696251887, 907474405, 122959529, 2311046870, 2707913370,\n                2068155025, 871578813, 3199933316, 4109893644, 3364535059, 2689483583, 2733315419,\n                2816581989, 493597647, 4233326794, 2707337061, 2466491155, 461645590, 3394920046,\n                2364034700, 2927025934, 3561869025, 1766019166, 1087480153, 3423282059, 2131323526,\n                443966965, 1322332697, 1188782069, 2328104863, 101502730, 559580730, 292683787,\n                4260616850, 106658508, 2316309568, 2434308741, 2540198387, 3872202391, 1683466445,\n                361864473, 1073947479, 92799404, 1093412917, 1797622721, 2090746539, 2283241835,\n                2132221790, 683313217, 2605586840, 272071431, 778910196, 1178669312, 3122370980,\n                2530336330, 3970158473, 2490258456, 2190693705, 596284947, 1765600807, 3350342078,\n                2794589150, 2635443956, 807439784, 3903077782, 3945796325, 942763420, 2713046382,\n                1698713811, 1317857903, 1110525719, 3495131608, 3223505065, 946629392, 2972584044,\n                506707999, 94736771, 3765880923, 652903571, 1540406962, 749211644, 3014228203,\n                3518499041, 3422675143, 570554490, 376540369, 3468500338, 2654381732, 1082043102,\n                547740010, 1376776268, 2368736622, 2340164956, 3274206213, 1585675606, 2526948269,\n                3685826888, 1303281228, 4233726619, 3077043885, 946095382, 1772054857, 3629314636,\n                3668407285, 1679245410, 3015824845, 3419133504, 1772118397, 3869309009, 3116086793,\n                2476315498, 2727156416, 2073358304, 2493520250, 3184598335, 3426023846, 2535765177,\n                1350497350, 3842761924, 193088781, 3549291691, 2898323987, 528541515, 3931652212,\n                2628035505, 3220688025, 1327873644, 2630505529, 2645555986, 683371565, 94682890,\n                3088159400, 666832937, 1170664070, 2982432118, 1240862344, 1541705759, 3848566925,\n                470074324, 3299004854, 2806142952, 739137245, 2220277210, 3177719291, 2655324779,\n                123152485, 811519781, 201013561, 3301124472, 1329382140, 41951119, 620138375,\n                2546585592, 625899600, 3326495333, 4213033328, 3082520072, 2891613782, 459582846,\n                2097858672, 717773013, 361515587, 2355289195, 1151755260, 1300970819, 1575593593,\n                252818119, 1942833848, 3291967541, 664516403, 1757721427, 617231947, 3341602112,\n                2134171110, 2655152316, 4171063368, 2266853692, 2249705420, 4229017828, 3808551569,\n                1022164534, 2764922040, 1186169196, 480930826, 3626411618, 191179196, 3084727732,\n                2279466761, 4262348380, 3415268683, 2678080982, 4222640244, 3707472424, 397923840,\n                475207557, 1315511880, 1883992100, 898749016, 1879798163, 2017024751, 4062544133,\n                806475517, 3051502018, 3708841910, 2096099031, 2472482157, 1257669380, 4098373733,\n                3753948004, 1449830867, 1906256745, 545503177, 1730793521, 1951534912, 1016204794,\n                3644912944, 2756593845, 1084912829, 2782536566, 3940309671, 4041993642, 3625686158,\n                3342172669, 3350618388, 1432134919, 3394172396, 452736283, 3746356467, 1206978644,\n                1071262458, 3418727601, 3753580695, 1155910123, 3621981229, 974633491, 4270218948,\n                139365450, 1903294135, 4213872458, 2609351473, 1806785011, 4061492016, 1658876611,\n                1725649895, 4238767421, 992865751, 2011385765, 111748306, 2649459396, 221192812,\n                4156176160, 536764228, 2796826913, 1239184361, 2672911755, 3006728942, 2027502333,\n                163000014, 829865457, 2838930988, 1890078144, 464268512, 2194804859, 3938455874,\n                1014614635, 1776352812, 4242636730, 250288235, 399096520, 591848475, 3913262575,\n                3472268179, 4154557375, 3758335140, 1187320829, 1385358369, 2785309889, 3598306971,\n                2407716186, 3628617916, 4288509869, 3267216806, 1856454511, 2928214947, 83101206,\n                3202050500, 965501838, 1912359870, 632876507, 1208660227, 778560438, 2876747643,\n                3513939362, 3961376920, 4110658869, 3126278195, 364426099, 3234695768, 2990525857,\n                796682824, 1791220715, 405843908, 124880551, 1855027244, 3746450180, 191162010,\n                4082012263, 1581699691, 2764243440, 277355349, 963430298, 3566230933, 38625380,\n                768212651, 1512496904, 1874854932, 2450757328, 2786594782, 1412558861, 1395849717,\n                2747218492, 3495543061, 1846920941, 1898677827, 2422832755, 3921580192, 107001262,\n                2741893884, 2313862769, 1259354486, 1588034006, 2331911183, 3195037905, 2648622432,\n                2978006124, 2561556210, 343248328, 4270266947, 3123864518, 228539497, 2407750681,\n                883695218, 2745594856, 2247519066, 4231094, 3581492796, 1675476648, 3620672884,\n                705741717, 21140076, 3982005817, 2694829480, 279149408, 4168326852, 316910772,\n                3383945497, 107689253, 1930173490, 896093152, 2913961684, 3725633499, 3050991063,\n                1315775057, 2197755799, 1142448087, 3961882716, 2593319623, 3492417047, 2019475096,\n                3414459666, 748384462, 499802845, 3126485939, 2047865095, 2560586698, 365444713,\n                2028626826, 3873328802, 74720391, 1993493319, 3232526894, 3721087504, 1967755320,\n                668632378, 1664543524, 1468291947, 2952440865, 1254499682, 704856107, 3454907905,\n                1964686149, 2452514339, 2293075687, 2004179645, 4015953950, 2947022984, 1173640303,\n                3314346410, 4272848163, 1425734659, 189190656, 786794043, 3946370116, 3085382345,\n                195301679, 4033242297, 1514196051, 3136636993, 4124105667, 1194214926, 489226345,\n                4080514545, 137488511, 4103330635, 1341258892, 1995718006, 202036240, 2939663429,\n                2187110372, 1576986644, 2100184388, 257157287, 1505449570, 3072904390, 523897480,\n                3619460547, 380563300, 669924233, 3918009837, 3169238035, 4209189486, 1240386377,\n                3643960492, 4267039098, 1045161394, 619826520, 3227734068, 425851327, 1814371668,\n                2114793343, 851360717, 1089263423, 1146150256, 3569229004, 2947755440, 326298952,\n                2159409889, 1578326684, 1453272682, 2251621847, 448102574, 623114003, 2807384207,\n                4212076107, 932326520, 2090364258, 3399577451, 4004091583, 952313228, 2574159231,\n                1854395394, 2705398428, 28644137, 302699461, 2929946845, 2052869589, 1470767307,\n                1144233294, 3039104974, 1656359271, 3353995119, 1755814610, 374073025, 1415373730,\n                1263008081, 276443594, 2844698199, 936296608, 52983486, 1213318387, 3037986992,\n                1150786479, 2177266424, 4187211253, 667257572, 100299652, 1701434678, 2229094793,\n                2589354623, 3277721085, 2778825478, 3059387080, 2015082842, 4084788098, 2105734286,\n                4117727535, 1077417510, 1280959967, 3207427510, 3001681767, 2287516411, 807245294,\n                943791596, 3567936516, 1175510623, 970953875, 1603914526, 3736436896, 3132876687,\n                1911058141, 1902151321, 2882818778, 2129022628, 4147170175, 1665613532, 1339380240,\n                1295409124, 2519006226, 1589066702, 3555085149, 2567876837, 4073965037, 1105941413,\n                3390819744, 184772468, 2876844310, 3055730007, 1867650446, 2066626685, 2382337144,\n                3731581159, 694748949, 4037311148, 3311787740, 2400074253, 2611534780, 3949492046,\n                3768082359, 3715389991, 1821116255, 619535405, 3526020385, 981623321, 451820079,\n                4037309001, 318196631, 2851710377, 2693083957, 510705188, 3309245549, 2952849981,\n                1195988301, 408775548, 3399824599, 2652897529, 3888595751, 249737658, 2553914719,\n                3085382480, 3761350827, 275315172, 3214461141, 2902235262, 519532287, 297992837,\n                3160553840, 335649192, 1512852903, 1903834058, 799630905, 2367526032, 441909661,\n                840254872, 2131794245, 1764935775, 1927169311, 3463226678, 1472402236, 1767217158,\n                3205167853, 3927785614, 3573286096, 3753099950, 2228929210, 1659221107, 2746211993,\n                810190361, 949046192, 3192506604, 4088392527, 2847106980, 2936788348, 4156916135,\n                795573075, 3496252351, 3678494, 1220639620, 1190792577, 2327376947, 238604068,\n                1443497716, 1284955950, 2598236634, 2746974481, 1397718164, 4007286832, 1962880570,\n                501731990, 1536158589, 2703567548, 4033741310, 1043951332, 2178030208, 502382330,\n                397014065, 3437941627, 2102353911, 3105472874, 133677020, 2501316468, 3498041685,\n                1233221581, 598304446, 1256058298, 856556625, 1668346687, 1834508098, 414982247,\n                968825298, 728571643, 3066334051, 205267651, 642009878, 2938411293, 3400735822,\n                1111934622, 304392877, 2678708182, 177181264, 1984975730, 1969199060, 1244467610,\n                1654243204, 3654035062, 3366916456, 3737272025, 2650746504, 2185763245, 1889212024,\n                4246389927, 3390547957, 1332135365, 296506871, 4177217258, 2700794658, 2242564412,\n                836397977, 1676121129, 422154043, 216339390, 3750079775, 2310419665, 511516103,\n                1739906592, 799210035, 3712311464, 1455592792, 3349937262, 1598562662, 2486265409,\n                519166017, 1297435763, 1392763799, 2022600061, 510735474, 2478097195, 506759619,\n                796379426, 399080223, 666623180, 1124185019, 892437879, 485826853, 1656496716,\n                2938611183, 4178286512, 2439599863, 1598034092, 3269993250, 3450031166, 475866618,\n                1806759119, 2393680802, 1970747471, 2099713240, 3875517845, 1207984196, 2516007974,\n                3965473493, 3948490816, 2119377154, 1839612738, 879208677, 246542905, 2630201999,\n                2928517000, 1097588026, 2965830207, 498130572, 1798823308, 1795905178, 187806215,\n                1287988379, 2031912144, 646835032, 2767499591, 1124794926, 2577129465, 3037704214,\n                2639841971, 919973961, 2033290775, 2885700032, 3520462836, 765528422, 446633427,\n                3123360363, 2298081977, 1390131662, 4230413914, 1902215370, 3616013845, 2260513001,\n                3747377440, 2817779138, 3264575558, 826783367, 1292120871, 1208887850, 265679868,\n                3872810982, 2675698014, 4061565567, 4152710054, 110655396, 780958816, 2763524359,\n                3633986695, 2010942553, 160739946, 3619904389, 2947803112, 179114010, 3738984586,\n                4013670177, 1088797110, 1276754564, 2440296283, 2399071424, 434487060, 1560826919,\n                4157071910, 2976509345, 2893695026, 768343063, 3824495669, 2655391168, 1167184615,\n                1621514532, 3975881006, 836459681, 3885571349, 508166775, 214823162, 2276274638,\n                4195487102, 1195690824, 188782154, 29205793, 4136541674, 3381782951, 3561011302,\n                2915898541, 581308861, 2514950412, 2711252254, 3661076924, 1554606681, 1729955597,\n                2723146055, 200346906, 1552082335, 410639853, 1691198816, 1384831443, 877670880,\n                1170630543, 982426045, 1450261819, 3227495855, 666934888, 2420401338, 2087666752,\n                1563061416, 1657331301, 3553602125, 3056899951, 869589327, 139857133, 3767113610,\n                1303974605, 1723201762, 263844574, 2503243858, 358826296, 4173491333, 3687643809,\n                1625871493, 4198946919, 624894510, 3700331886, 3329004524, 799770921, 2298483872,\n                2335302132, 252126903, 2666987340, 2847670745, 2812544104, 512934167, 4280220084,\n                3224849468, 2219609098, 3179622399, 1764701927, 378248121, 4261315889, 1025924236,\n                1196055308, 946511871, 1660111110, 4193689984, 3547572682, 1714485709, 3208296103,\n                1879031614, 3993387879, 74759326, 2535726908, 20781750, 3772441705, 3140626384,\n                4022054925, 3132004834, 4128133333, 555857086, 219631928, 4066401226, 2364736568,\n                2372067565, 3238914984, 1096667213, 689491983, 2785309740, 1587072461, 3410938009,\n                2847008597, 3514882839, 1910022341, 1653248734, 1499301492, 384557449, 2844135017,\n                3322424352, 2468876483, 1801577798, 396633331, 2182190443, 1629994414, 2959059506,\n                3964895515, 1761306860, 1805894432, 3922729773, 2411151815, 889157855, 1026886856,\n                4026036674, 193965600, 1570181022, 633532461, 177300986, 3371224064, 1748120023,\n                1761340469, 401130679, 2744459475, 2720260552, 1908778372, 286268774, 1859399551,\n                2795691203, 649400262, 3721810747, 1895622116, 1270653455, 2482668703, 1928217432,\n                3870565217, 3195815102, 1002226446, 2319234940, 1849617444, 241443443, 1960134849,\n                3257532571, 2122442138, 3357237384, 1091603714, 1400399574, 2764930769, 3639652992,\n                1075992067, 3354008606, 3674434180, 1269912324, 3480210695, 2694195272, 3120019549,\n                4204414893, 3115582945, 62860, 3100959926, 869419887, 1501173206, 989959599,\n                4194175791, 1874919226, 4132268124, 941227636, 1117180576, 2798307927, 674257397,\n                867344324, 747456843, 2751244875, 2885134775, 3838427931, 1873728410, 611603176,\n                2959150253, 2181196683, 1710737373, 3705891697, 3034486028, 725440065, 1923636551,\n                4151354804, 2346141321, 2707306865, 74049846, 1541018327, 1790958807, 3077570591,\n                1139993470, 2417568601, 4004865519, 1041577893, 3235167060, 3254089701, 2570838319,\n                2475603200, 3859647482, 2993708386, 143247127, 3734661089, 826230775, 4116635923,\n                199135364, 588292673, 824443751, 568341079, 1016456619, 1604002702, 1772195110,\n                3964951887, 1493560899, 2866906460, 2936090282, 946222747, 525981003, 2325353316,\n                2886265911, 4179416306, 3370849462, 1893142846, 2681054547, 3735197589, 3776524206,\n                1296370394, 4238698717, 2003830728, 3887946826, 2829434435, 1875801233, 3277229923,\n                4123505719, 774917414, 3564778974, 1353262063, 1276224511, 1774196274, 2512537568,\n                208846945, 483611843, 1566083971, 2070150886, 738949232, 4244252079, 1367631629,\n                4274810101, 4148053121, 2262045233, 1323571644, 3874729248, 20229007, 1930672366,\n                2535449036, 2724644158, 2337868550, 1980878450, 3084405876, 351999056, 2331600327,\n                803554490, 3414519030, 3508616719, 1312233895, 1276476199, 741671465, 2052571533,\n                784575034, 3477049444, 1778569772, 4002036361, 1117181350, 2042796171, 1211457669,\n                4052197160, 185043729, 2924935303, 3596780754, 3912420895, 3627811273, 1985659887,\n                3753611409, 2047663715, 3318805362, 149285966, 3179895001, 1237672670, 1985820626,\n                1298372520, 4284591011, 341224454, 454999791, 3750564549, 4107533271, 213131740,\n                4012841780, 603326064, 3017166441, 279885978, 1915229757, 1348159257, 1548745560,\n                2981789576, 4749968, 3020261054, 2037208068, 117001672, 815291934, 317905993,\n                465148647, 3623981244, 190010148, 1709761935, 2835947327, 3517022470, 2178243690,\n                2497438014, 1876568825, 641590597, 288338736, 1164573506, 2218432212, 3072549385,\n                2808266324, 4204926341, 3781762011, 3181513185, 4246729183, 3028889447, 3479420370,\n                1293238383, 3671370466, 357540249, 544681902, 1619466883, 2095482859, 2351601097,\n                1294354403, 3924412452, 3509201400, 394596275, 2000769208, 936155928, 2980604496,\n                903974142, 2430419875, 4100610868, 1228760002, 3303634223, 2793866830, 751125932,\n                951956482, 280266344, 2891935450, 1873629086, 5570516, 3354888472, 149771485,\n                338307762, 2822577121, 1237324803, 3342007852, 3441674541, 3974115083, 2186803670,\n                3504599397, 3344339108, 3913996367, 2303206643, 2511334168, 3254784413, 1378993575,\n                2422186725, 2959643285, 4212948275, 788681136, 4207545241, 2851838191, 2114800129,\n                933612608, 2319524742, 1877560809, 4206760104, 1731687165, 171699922, 3463277658,\n                2795199671, 3866480958, 622763825, 3094649971, 1423332786, 2717336129, 558587665,\n                2491633038, 2364130945, 3360297817, 716787448, 2782951458, 1575189363, 226384805,\n                1089938862, 2914472892, 2706981436, 3863385624, 2637979099, 3616845051, 2684045904,\n                1905176309, 2846718196, 3558902951, 3891946352, 1254905803, 269913489, 1082165285,\n                1833207584, 4115780246, 434319330, 1742079497, 647885839, 2863394952, 3038238702,\n                413347594, 1719976258, 4034848482, 2328176830, 1613364718, 3940789192, 3739394322,\n                2362355131, 115437714, 3583561637, 3840825890, 2914519890, 1212102726, 3481009106,\n                736166974, 718171257, 2199668000, 357589147, 1280278871, 1491363454, 955868050,\n                789879528, 2698794649, 1915436774, 1686943875, 1758449247, 1150886369, 2922900881,\n                208227464, 1143826808, 4191332816, 2696921387, 3692310240, 76470987, 3289165344,\n                623567006, 4188640667, 2864843705, 796242042, 1597539994, 34970604, 962193696,\n                2654314888, 2896643079, 972723042, 1891747952, 1034976782, 2949023272, 2341526400,\n                1742458173, 2052910327, 2072192599, 2793782047, 3358992152, 3911277496, 1831587768,\n                1243577120, 4249315708, 2013672927, 2547035442, 941512412, 360581387, 185821450,\n                1761992495, 1628978782, 3866270262, 1939713190, 2410442029, 1842360003, 100022960,\n                3489472548, 2137169704, 3508042620, 717338936, 1716080536, 4174165314, 1779870772,\n                4188693983, 2720756617, 4132300777, 3257213784, 782058413, 1875126093, 1095563746,\n                1715694327, 2066141725, 1846928857, 3429251073, 2122502370, 2298283254, 3089071457,\n                4031218271, 1134630355, 2385033542, 456362630, 1957570996, 1042213984, 703226120,\n                265051185, 4023801258, 3225097623, 831815050, 2355101173, 3982484216, 3634887390,\n                2443592608, 1362657087, 3987480592, 1452761837, 1326430527, 25981182, 2573055937,\n                1095878064, 3985298805, 3302487006, 1202505595, 390727865, 1826073018, 1989386218,\n                1898055969, 3392648337, 727907640, 1593813478, 3211587452, 3210864466, 3762668884,\n                2902234025, 1292462085, 1742646865, 1549756508, 675034357, 3053829169, 1471227718,\n                3124180515, 1807018783, 2453567817, 3992883600, 2268519457, 2035724962, 1436456489,\n                4264737023, 708223934, 3028559606, 501587643, 2707807431, 325077208, 2416334023,\n                3694645865, 1685743923, 604273842, 2649984654, 2845588843, 2933252684, 2730336951,\n                3580925423, 814225121, 3366268425, 1770717149, 1486401167, 3804277507, 1456752174,\n                6337974, 2409833340, 1617313876, 225498760, 1983179608, 3402609150, 744149761,\n                9987060, 3366937625, 3438474150, 4063360667, 3385409664, 3769624981, 4072601314,\n                3280258332, 298354566, 4056036825, 1561486207, 3007704270, 1662043103, 3892618780,\n                1804001291, 562253753, 4067841977, 2995255243, 80526741, 3057512084, 475203264,\n                2986752586, 3957883503, 1802853615, 311819332, 2837767349, 2388888673, 3277341280,\n                966408880, 2072943634, 539516418, 79462313, 2004099787, 2453102486, 603261020,\n                207424431, 2855582760, 2902494889, 741106176, 2468329430, 861181190, 282067858,\n                3684697365, 2623982006, 3801013044, 1168619526, 3894563665, 1944151972, 484249400,\n                2065256884, 1354519084, 3787011034, 1665285189, 2185133696, 633574470, 1522160849,\n                3190731137, 3963083576, 1769923208, 2261196778, 1079503357, 1414231568, 2141083825,\n                3772913971, 2048406301, 1513088102, 3812670713, 3248749895, 674551953, 3112555045,\n                3285597033, 189516445, 917663541, 1185071584, 2241980593, 2147308254, 3090205461,\n                3246618291, 290677042, 2461014414, 208431436, 290062660, 1228872528, 1963818101,\n                2419660283, 957129217, 135746754, 1315404499, 2924407396, 2700594564, 4124385669,\n                1690270299, 1360970740, 3034185919, 1285708700, 3277837412, 2891370147, 2083671223,\n                1244859227, 3629315723, 3331276912, 3100624908, 1692720362, 4162739079, 1171668716,\n                1019917260, 2960968382, 4239429154, 330832212, 2492679465, 3914351164, 2808889733,\n                3618854112, 3006959176, 883348238, 1728184215, 749952887, 2053405316, 207244847,\n                667629088, 3103931639, 3209824599, 4184808738, 117315862, 2026537671, 1562413553,\n                51345937, 3030421576, 813196369, 1177468730, 1399926526, 3101004500, 718483271,\n                1666840428, 1341570325, 2878342532, 358644994, 1438403479, 1036501667, 2791104898,\n                3825098773, 1174900477, 1564073696, 1006841031, 1226328839, 3800714361, 955435755,\n                1441308303, 2803693950, 3007187706, 3856940286, 1018239338, 1888688014, 1004758210,\n                332259430, 2579813580, 190823703, 295727938, 3560564104, 4073975972, 1195227660,\n                2044024465, 1483690487, 1910935996, 2323731591, 744962529, 2081905760, 1333818677,\n                1904243684, 1957392189, 812731343, 3589031064, 1160013846, 420235851, 3194898584,\n                3216802636, 3774331753, 3140756417, 1101314431, 3839920531, 3137953037, 542091325,\n                585982585, 67002391, 574032484, 1082814026, 982927169, 3343037305, 2499327969,\n                1014383634, 2128207535, 3143311258, 811145884, 1733742038, 1401919609, 2347405339,\n                1688793501, 130901125, 1385522776, 1610371130, 1332586336, 1524228264, 564391738,\n                981401281, 196991208, 3182621051, 3793780661, 4081937694, 1011590214, 1557984820,\n                1386727610, 1596730208, 44173985, 1294188761, 2868988806, 694733848, 1105838051,\n                1058473773, 345764388, 3923435382, 413963178, 2348630075, 384455613, 1557846890,\n                3572852130, 227635462, 1553781408, 3368144363, 3190344882, 2500047004, 389502182,\n                1951032182, 1025162499, 2375933612, 822062590, 375772173, 466764721, 2209593473,\n                513776010, 1807603230, 1905631247, 2102145812, 1878880833, 261887521, 728430148,\n                3553454410, 3877709566, 2747867557, 2339647168, 3102826569, 3883347586, 390581341,\n                2881151029, 1633488411, 2816794805, 2192621063, 543414115, 3832288603, 332599431,\n                2623361470, 212358006, 4240266170, 684331595, 3519558920, 2607974922, 4281769784,\n                1880377186, 3258299025, 780109431, 2460011815, 3306081571, 3682519163, 690153507,\n                2663605533, 1316874873, 435432769, 1844774748, 3579784610, 3192012120, 3816514493,\n                1486578621, 1711039154, 3024371827, 3961681035, 1833846744, 502498483, 4197209668,\n                1250998235, 2332362239, 273574790, 3414542188, 3757096517, 21687122, 4149375708,\n                2775774025, 3885486699, 3764828482, 3169684879, 1117267736, 563210996, 3358060713,\n                184906203, 260230243, 1407818763, 2566183894, 1022937550, 1704423600, 3768409750,\n                1675234354, 3205910089, 3849094279, 2775898525, 4171610541, 3027555101, 1995615707,\n                2875301755, 3119844309, 454813608, 2090164325, 1635654480, 3286845309, 838176838,\n                700409389, 1759207814, 3708137884, 1734213966, 2458469923, 1120465439, 2280792603,\n                251883086, 3307893883, 1147090770, 2478925252, 1571333237, 2110931086, 3071393123,\n                3639019776, 1527571161, 116756486, 4154212295, 4071193782, 160866177, 3822684608,\n                2812877367, 1187661933, 813375893, 4274355110, 3563648184, 95719798, 2321509863,\n                1705316827, 2624456109, 3729011434, 1980377637, 81244603, 3643221080, 2327782863,\n                2796726383, 1095348620, 694915451, 3869647965, 2102740931, 478028556, 4176353850,\n                1624886689, 1810087026, 3469284847, 279474143, 2654551468, 1650083553, 3786269063,\n                3975583314, 2715946934, 2176813425, 3911871341, 3162842812, 2484168385, 3039170731,\n                218808232, 2431971182, 1440889340, 259578859, 2693612833, 3234083238, 2456743001,\n                4251021668, 3086139771, 2655006781, 2585623969, 1517231877, 2905797824, 2564746181,\n                3228165387, 3837985644, 1990176697, 1156148007, 2314574003, 2513356051, 3161514242,\n                395936304, 85293272, 2959851853, 2699879800, 3388798371, 971502522, 25055937,\n                3578505718, 2265183946, 195596295, 314183619, 325141022, 2254229711, 3167471176,\n                991640389, 124907210, 1027834766, 306444940, 1237553404, 2020281085, 3652504468,\n                4166735853, 1579142390, 989985405, 1127757650, 3729807159, 2928562908, 474945706,\n                2481405227, 2572235402, 1318027793, 2375964164, 2182156758, 1147762477, 312894346,\n                722913909, 2048214621, 2526350014, 3878110937, 3763322101, 3802543443, 1971787277,\n                3836674074, 1019754041, 1229366887, 2095273765, 3240112698, 893657076, 1649975247,\n                1961083610, 4128219362, 3651979629, 560387431, 2272018206, 3455417001, 3591835175,\n                2202299987, 3219733860, 511772453, 932647786, 2934565812, 2620296847, 1412673738,\n                432452030, 2699068520, 3290349229, 1260200576, 2387873837, 1020650889, 2896929722,\n                46043276, 3175381592, 3640150750, 3359402253, 36379711, 2766622628, 1554648268,\n                423799075, 762803372, 1518772429, 3767916634, 2349860008, 3999813858, 4146982465,\n                3598588618, 42286784, 2318972122, 158301187, 1413340234, 2569385797, 2986790265,\n                1601097767, 3186903402, 1492083499, 2186589123, 3007389491, 3890657249, 526248321,\n                4163624347, 442866336, 1628632908, 3473974029, 3187528117, 785940226, 578554732,\n                3156675263, 385881021, 4069927986, 2627409796, 2493786632, 1220112150, 2494935162,\n                3940544959,\n            ],\n            &[\n                3863301396, 4107573608, 769303631, 3610738414, 830788656, 4093448067, 3961045012,\n                32998969, 2051223797, 3423229921, 1904051975, 3173276200, 1228524945, 3991474867,\n                2558817552, 2412845289, 2693892487, 2807867297, 2840990073, 3357897643, 4077724130,\n                4256256142, 3215370719, 961574649, 2783373145, 2888444892, 2290228211, 2438375496,\n                2172850779, 1371470591, 2145309256, 1373633064, 4127606380, 3237788058, 4161678101,\n                3117205711, 3367678015, 1835932588, 103170075, 2086719399, 3635268234, 1075092783,\n                2322705303, 1181088871, 2119517037, 1941053194, 2426223899, 1223640157, 2806178916,\n                1837938782, 3474314935, 1094340946, 1519955632, 2393278998, 2573377932, 1478044003,\n                1551179941, 1707547400, 836897832, 1100557452, 4127181141, 883244422, 1924787802,\n                4265368319, 1084411345, 416214779, 3210503977, 270111460, 570730254, 2856794581,\n                2308577544, 1601765064, 1555967971, 922066792, 2413427606, 2872234780, 2604193566,\n                3388171005, 1570309289, 2294854396, 2658009782, 2591918480, 3522202025, 231757146,\n                4204857543, 3547860361, 1464338574, 3046135352, 2156639880, 4202540070, 2025826159,\n                3098079937, 1936927235, 2324543615, 4118634899, 2173483850, 2792340068, 1873251935,\n                1329676397, 4043896491, 2309336419, 980209872, 2777302910, 3606217402, 3661029657,\n                3300621321, 1682483184, 1403461142, 1223784743, 989364098, 4013393779, 3101723344,\n                3920771322, 3654398113, 659304100, 2541187212, 866322486, 3272793365, 539079315,\n                691963245, 1257923717, 2386692694, 2687779700, 4058653147, 3991344999, 897061149,\n                2324025121, 2967160685, 786657051, 2252177489, 980079755, 3131679746, 3324117860,\n                4055735401, 3845118353, 2451175052, 184232145, 624678568, 2101388835, 4142018772,\n                2748564864, 2176101753, 290591054, 2465352612, 1359620450, 3705457053, 1692771801,\n                3882450774, 3055204792, 888363043, 574687565, 1207688631, 2763529019, 568213190,\n                3846386580, 547028270, 695643805, 3592508514, 3670105804, 2822171601, 869109705,\n                1004643975, 2589161100, 1630131925, 3278288666, 2691788554, 2121899712, 2397877521,\n                1435285741, 2269606420, 4256438690, 753043674, 3171716037, 41205438, 3121289912,\n                1323558351, 1361648638, 851327672, 3104712715, 4004974077, 1301613261, 2833338776,\n                3359514548, 1454336368, 2759103629, 1960046482, 1092082457, 1499734131, 811024496,\n                3572058602, 680905751, 300633989, 2424260077, 3501914344, 563961991, 1037919651,\n                3916889833, 1787252091, 2894072139, 1402432736, 1292040125, 682437315, 2969913946,\n                314458596, 1751517864, 3350980225, 1439799227, 1636821554, 3406541220, 1219732804,\n                3202430109, 1914037453, 563664320, 3367122241, 2515249318, 4047342823, 2606550211,\n                2167198989, 1523186563, 452794059, 1346414345, 3332356711, 1383558530, 2011404918,\n                2878045272, 3235959584, 2338004003, 3703022278, 976253964, 3367441096, 1031350937,\n                3245197722, 1599344278, 3041157247, 2825168448, 256034927, 3591345113, 3217325239,\n                3017793609, 848837066, 2474357857, 1438488646, 3582043621, 3167628029, 3875878184,\n                750243293, 2350679755, 3998775646, 638861873, 2526770107, 2769525670, 738597950,\n                1994625812, 3723039945, 2937249595, 3756565658, 3171285120, 1791315722, 62587833,\n                1395408127, 3693836917, 2738507457, 2306644854, 1474880765, 1160674040, 2845323575,\n                420810975, 1899118535, 1598631145, 1287542219, 208660872, 2670540827, 4285356488,\n                3940367467, 2553544428, 3288950243, 2385345193, 1834621976, 2731668575, 826787064,\n                4129914940, 3098181877, 1647015619, 487963810, 3621584170, 2941528453, 1404599035,\n                4123744367, 3242445801, 639956074, 1576331544, 3989605601, 262974392, 149652296,\n                771649267, 2863404594, 212076261, 430647394, 2620118033, 134762381, 3200455716,\n                1300726789, 2837061400, 630227810, 876215174, 4066609908, 1702081865, 2811686994,\n                3651804679, 4104022340, 3509034466, 505886247, 2823492341, 3718178477, 2350711654,\n                1091894884, 991761658, 2416007280, 3262724307, 2788106539, 213178296, 96331913,\n                2488727943, 318433030, 1284078995, 599654997, 3374493799, 2383380175, 1921627781,\n                2006909313, 3722858815, 1216826854, 2917401357, 1676843856, 389470213, 334298917,\n                1965856677, 749841577, 3683568719, 708694228, 337850258, 3111094818, 2782798319,\n                4005027416, 581456353, 611481801, 1294462617, 29883974, 492092705, 1519669277,\n                3859693035, 1889037872, 1031737207, 2578726208, 1972815393, 188943053, 1485570324,\n                526754497, 2470561029, 1220023327, 4210753221, 3493817654, 133559404, 3002705638,\n                2498655424, 3860497340, 3331608996, 1405034307, 2629878850, 476987772, 3610433569,\n                1023762843, 658844517, 3090909301, 907135177, 1408007749, 3914369905, 508522333,\n                3316282642, 1050991069, 4208430570, 3612474296, 3203199646, 3816629579, 2319236875,\n                479063253, 1512092787, 929610795, 2715987221, 1270125585, 1011146594, 2342272581,\n                130885952, 3412056503, 4187759189, 882073708, 4183872848, 172107317, 2957726207,\n                3280137581, 336758918, 1225340863, 2980372021, 727900139, 83467744, 3112049220,\n                3022765871, 3092091329, 3429841070, 2481778911, 1228662170, 796434253, 3799895828,\n                4245142305, 4060814107, 32186386, 2762465842, 3106581250, 1879981484, 1044873406,\n                4245445901, 515382924, 2067565497, 889935212, 1897047746, 1837757206, 101552593,\n                2684290698, 137909205, 879061337, 1558061909, 2653072754, 4247712148, 951006500,\n                1219781407, 1073570653, 2696083564, 621148580, 176025161, 3955431920, 2229129171,\n                3584030730, 1983508788, 3708181991, 2786434403, 1254465085, 846041455, 1592631656,\n                1522495938, 1934663236, 3068611723, 320091931, 2587695487, 3191009209, 29787986,\n                468991587, 1595518822, 3373815179, 2308734497, 1843368977, 942275147, 1148248505,\n                4234927039, 2416737763, 433582485, 1730443177, 15151120, 1912575096, 1589875286,\n                3467980504, 2102706272, 4064622680, 3321081735, 1278382005, 3743042633, 4094549164,\n                2003156479, 878239104, 788871490, 3911621039, 2585364529, 3842385316, 3707497759,\n                4257004160, 108649445, 3177789050, 1363721622, 2898922735, 1467428903, 2019157527,\n                4024265210, 163512519, 124230527, 2015871258, 4147623411, 1276959372, 3521852578,\n                3832954702, 223998324, 3663355248, 1866084068, 1034709049, 1357099318, 3064263741,\n                2772852849, 1112354774, 229271352, 375671972, 3577874614, 1456769098, 2514337878,\n                2958441448, 2521768862, 2332946402, 1306522363, 2051612216, 1798549572, 2328587715,\n                250374248, 1181282837, 2401502703, 2561171171, 167987730, 4291774408, 1297255113,\n                377921436, 896506850, 2666513068, 2215986608, 2417034530, 4103536478, 2650538608,\n                153287877, 2013466969, 4283997596, 3235129347, 1597613202, 3775501616, 940975219,\n                3651296726, 3935519507, 1711331252, 1382619450, 98804289, 2828250792, 1113234481,\n                879722963, 4181357652, 335298543, 298230884, 2842345357, 2897108219, 2131811279,\n                1610217235, 2935752175, 1980703969, 96565072, 2285804804, 3441818431, 4027097405,\n                1453644439, 1404165497, 2137407333, 4133788414, 2012339193, 2914917166, 1212496804,\n                863513903, 3641661674, 2344878371, 1624332397, 3193401691, 3589187922, 3492743685,\n                1074343035, 3549688503, 1235879378, 272458456, 1530905055, 633600272, 952169022,\n                694842255, 2924520177, 3733576543, 3412038548, 3355971570, 3319754603, 35156185,\n                2711361786, 1908801108, 2007786947, 1471019471, 682257175, 3452454141, 4086992517,\n                619063037, 3527436755, 873637727, 2540048683, 4216590989, 2517973204, 856413582,\n                3410373161, 3976252825, 1076697656, 4084517409, 3558844395, 1708431648, 4121221409,\n                500433207, 69169381, 3518331925, 1903010337, 2945573052, 1916961424, 2296550276,\n                1473104968, 570605625, 2970669612, 2930435606, 1407290785, 1362262639, 1643553808,\n                1379331415, 814987507, 3738591405, 868048552, 609381189, 3044266817, 1073709216,\n                2273520370, 4174096914, 3211778166, 1775963388, 4195045652, 3903545039, 27421359,\n                2831518698, 2264275203, 3825390392, 991249490, 2033327389, 3437683812, 3589994222,\n                2095797327, 2693270490, 2446965435, 3532382189, 4225020538, 2438827018, 3599722660,\n                2059526307, 916675930, 4032044649, 3832545177, 4265752161, 2025270161, 1700180813,\n                2724405129, 894375853, 2158154452, 1992158364, 1104234105, 4095063140, 549680132,\n                295278223, 3399425354, 502455385, 925070896, 25265139, 3138056117, 2485080362,\n                3122750407, 2110469673, 2519059530, 2245336963, 386180475, 103198797, 189274207,\n                3711966958, 1497301749, 2091705140, 2998746394, 3197222872, 1586189053, 2434615335,\n                865658181, 410299428, 283623349, 2593258180, 3319619642, 111650022, 3054665890,\n                3379592188, 362888191, 1774728950, 698157433, 1196199247, 231783178, 3854883494,\n                944662656, 2849527466, 18761251, 757793978, 3575863519, 1522566520, 935676887,\n                2205620771, 848824700, 487422055, 3045852915, 2821647442, 942847641, 2420057003,\n                4122422133, 3221662523, 3948174115, 1511012575, 2712620547, 154277939, 1260340613,\n                764036546, 1258666603, 2736493060, 2398218922, 332369172, 3321255431, 3735363230,\n                3130335168, 1471863620, 2350818699, 1666699401, 263809178, 225879205, 3475801107,\n                41747506, 1281025890, 2613054861, 1941686229, 2161424264, 998469013, 1567825824,\n                2708371812, 4234191147, 1416171194, 893931380, 965714073, 595159859, 2094181000,\n                1274027425, 3400425068, 960344775, 2934909672, 552371896, 3250358914, 2867135600,\n                714318092, 3437291998, 1218637856, 2592190957, 3215592510, 1154397448, 92253472,\n                729368671, 1238758682, 876266136, 2532748595, 3277383450, 2002640396, 1096082385,\n                3097263866, 3774645444, 143160707, 820702860, 2963502810, 2295329126, 1738773598,\n                1662291270, 2109612228, 2254641499, 82516534, 3161744187, 3679464233, 1358033344,\n                2995955069, 3624029481, 2392653637, 163541126, 103712334, 304309084, 84468238,\n                2162950986, 4246306060, 262053879, 894859385, 1440182788, 3032139842, 3204874529,\n                900031376, 4267138270, 1841498413, 3989603237, 381201084, 52369466, 3293766866,\n                3539091133, 2826516997, 451466955, 1474183607, 1650264638, 55944005, 922622657,\n                1648352125, 2905899264, 2376709984, 494615258, 2094380542, 1818828149, 633848924,\n                217595087, 2514129298, 2686868725, 1334881256, 945657314, 3287435007, 2934095457,\n                3252504849, 2198733907, 3325659469, 3651948905, 2792934808, 3967802298, 2660224790,\n                2498216702, 2191920241, 1388358405, 1762131463, 3930963570, 2634828966, 157650978,\n                3583842536, 3242164879, 3088432937, 1681039203, 3521823186, 2711390389, 537666406,\n                376858519, 3748935340, 4140298933, 3491468466, 712574481, 2722290823, 3829138812,\n                4159064276, 2077023449, 927927769, 2794552777, 478084560, 3993993319, 2103681826,\n                1287040024, 3438112843, 946795562, 3787267183, 1066818694, 3032121002, 2604020549,\n                768054703, 2506165286, 1915485245, 3059742383, 2693940456, 1983217549, 2556130441,\n                3043340405, 2402731290, 1100667933, 804329802, 442779347, 559541894, 1528504026,\n                2430094040, 380854895, 1924878482, 1122304788, 72444675, 3969057890, 714896496,\n                1494340534, 597259814, 3447834580, 2159188321, 1818909926, 3314125974, 4200637638,\n                2442370766, 343066112, 2918772200, 1301372507, 1469386163, 2329124057, 1063769022,\n                1976395812, 1172302345, 3034217238, 2565781187, 1333195768, 1802803443, 3542179279,\n                2595530300, 1298867338, 2131992457, 4008141933, 3551156725, 1910959429, 926841893,\n                722213632, 3001255255, 2877951087, 951003498, 1850325282, 961774018, 2564886523,\n                3851438777, 894949398, 256796330, 1959581786, 2633182213, 347574201, 1192307709,\n                3562336091, 4219631762, 3241567097, 2990515345, 2420064232, 2970262593, 1461569831,\n                959873136, 339106858, 1193176040, 958105449, 73335412, 414655367, 2703505850,\n                3523782649, 1836045931, 2238239231, 622571598, 2306296237, 2739009399, 2235729403,\n                4049021645, 1139357889, 3707063481, 3027045705, 2536246044, 3463101979, 164310463,\n                3068187810, 3712847292, 1194203136, 315781630, 3635235621, 3210331632, 3843708250,\n                1994373266, 1594553425, 774598913, 4048276724, 789636282, 3215162174, 2262339544,\n                1305015749, 4007832380, 599420190, 2326564224, 2581496076, 1490199678, 2345840465,\n                2587986101, 2223352107, 899040275, 2032648532, 492046170, 2775769948, 4025191184,\n                2066154698, 3282686682, 1947023303, 877230065, 2379757900, 1421079241, 1472867997,\n                1256546466, 2015075685, 564334856, 1596942756, 2067271158, 1525094696, 933563085,\n                2736916537, 1289719444, 2825124575, 538020056, 1948821945, 3347107101, 2079729373,\n                1572505804, 3433209293, 1344499437, 3949051563, 3232199037, 3082371535, 1331266164,\n                107382829, 600011905, 2444019204, 588880467, 3129757140, 464629376, 849856979,\n                423898800, 88832098, 1081264490, 984244991, 2741490369, 302293134, 264947875,\n                3559707631, 3163924576, 3570999744, 3669081938, 2295906825, 2650299087, 1113300657,\n                905751103, 500693370, 2100014668, 3986098399, 1812213805, 2493587511, 950742301,\n                3760594111, 1988198331, 1873596690, 2635981672, 869076633, 2899275440, 909196488,\n                426688577, 1424894512, 2514329532, 1429386171, 1601662235, 698006110, 3413993105,\n                2770364726, 2118460870, 2739235711, 985371284, 1878394461, 2601294175, 682033607,\n                3495222984, 3705210174, 363192243, 2726571167, 128884760, 1240146787, 3016436128,\n                3416184840, 3975805871, 1867343818, 367917036, 2840825415, 3109229134, 86399602,\n                29168346, 643436421, 855684886, 2698919498, 2573030045, 1310289643, 2632411665,\n                3280803400, 3031393328, 2706966620, 757184666, 1870090363, 1089529774, 405908185,\n                3185354428, 2211285265, 3069886124, 1833781576, 4109099359, 2041763376, 1412307932,\n                1108344823, 2934287361, 3748982678, 997317374, 4034047498, 1589982531, 4000312659,\n                961015296, 3096991478, 1531557499, 3851171859, 3915206184, 3845090477, 360397185,\n                3650820078, 2671471668, 3582096970, 98103656, 293910129, 688011927, 2301307999,\n                891574533, 1096467904, 1772826405, 2251911696, 257754158, 3595310014, 3071881112,\n                330145073, 2003841156, 3503655584, 2500095275, 2581430324, 3750572141, 2399342110,\n                793019159, 2908904187, 3048524529, 3121098597, 2426325849, 3141829183, 730031729,\n                631358017, 2816312406, 2140259643, 2705520489, 249478212, 3810678698, 112873024,\n                1316257435, 3829349326, 512530284, 1791055446, 977334578, 2132878588, 885903211,\n                1036930474, 3730775044, 1701720120, 2244244496, 1471396055, 4218527872, 2282408914,\n                2863265592, 2524710962, 3681247194, 1021315023, 1936348533, 763047529, 1864565264,\n                4056081562, 1341771220, 3280140661, 470866172, 491650059, 833461558, 3663381328,\n                3131958008, 3888395947, 190302498, 3369220408, 3194531411, 4268320815, 641711829,\n                4145336402, 3637433757, 3916511879, 2178833411, 3528637090, 921304408, 848707877,\n                74460658, 4156338096, 3758212244, 4041754743, 3783679569, 2464912581, 389100529,\n                2749390487, 1272451842, 1982831993, 3205451183, 3611482027, 2856507974, 3045919911,\n                787026444, 3326213299, 3742042988, 1179040305, 1079935839, 1099752002, 2208759695,\n                3321518120, 625037743, 1196410750, 2539925852, 3637757870, 4076045265, 2521116350,\n                257980137, 1792560058, 4080511201, 2295460214, 3430291767, 2341109458, 2373054528,\n                2964565865, 448201628, 2789539343, 3122329385, 1041274565, 1354785628, 1790951895,\n                3835101816, 2927123449, 1699998449, 822436141, 442731999, 253622870, 2051004295,\n                2119605933, 788752772, 3859931127, 3342223111, 1766122016, 2442973203, 684168317,\n                1723020245, 154195179, 3840290724, 197981657, 3225996975, 1370627218, 1351642439,\n                3678888257, 2134899360, 1190824919, 2672793161, 2594374637, 4003067381, 3768518618,\n                983310739, 756053185, 740998700, 170333885, 353078645, 3235856060, 1175961245,\n                3465368919, 2715457241, 25728426, 1205273122, 1007876083, 2046909066, 3387646551,\n                300617592, 2304621094, 1783616228, 4108300103, 586016796, 3730618599, 3601593992,\n                1497117442, 1382687044, 856047991, 3446843207, 2718610562, 1648426450, 316212126,\n                3770040316, 4085290555, 3839828266, 1824200161, 1558151259, 2451017528, 4144269623,\n                1926063180, 3430941798, 3283263584, 3623728522, 1321248896, 2213285073, 1427594731,\n                2251376848, 3156851965, 3184709111, 3145527411, 3930726181, 3730945673, 846201422,\n                731360758, 4265684973, 1939059752, 2176908121, 4194865292, 4067633000, 2038583049,\n                3475282686, 1326107151, 498945469, 3441081476, 2360019237, 1877755648, 2980984493,\n                937159856, 1765157866, 3158122715, 2419599545, 686694843, 3369792550, 1593995909,\n                3205417509, 972506778, 1749567615, 2334033091, 3965294821, 510805665, 1753849516,\n                249859705, 2412460463, 2378513928, 2986924333, 2985311978, 1103056985, 1321159371,\n                3294519955, 929620231, 4106207278, 4270651331, 3587554722, 2548230974, 1382890621,\n                3583771152, 3542820493, 1248566046, 1451098024, 2031079077, 2958317520, 408683181,\n                1322401171, 739053183, 2763421668, 2050043200, 2027533054, 3479908048, 1846767499,\n                937808196, 4080393047, 618895890, 345507295, 3836887679, 3486959977, 673180241,\n                2986760251, 609039359, 3790679251, 2816013571, 3674501891, 2510023654, 2140217074,\n                1918529247, 1295289994, 2852923944, 2968882596, 2374994285, 2339464893, 3530889069,\n                2047732915, 1888856899, 2303610, 1266797804, 2451766648, 2651393253, 4200986449,\n                1305014630, 2017208592, 1878532929, 2601631173, 3905586154, 3600492846, 3185555607,\n                3685032847, 2313651900, 2203112200, 2821359262, 3290447334, 2051909399, 2681200978,\n                2681643754, 2030516748, 2198940390, 560748330, 3035412164, 2222960210, 928429057,\n                1269561797, 1103973285, 3614653856, 2885465202, 2451268620, 3178535744, 3816260981,\n                2989224422, 1462753367, 2867544236, 3638993558, 2857844328, 871331601, 3290183874,\n                3357526835, 258572105, 74152014, 712442772, 1849061379, 2049304441, 1088152569,\n                2456861437, 4193739116, 903105013, 991152330, 3610977022, 3586484046, 2744021039,\n                2290293141, 265948355, 3393021731, 3823630150, 3404747914, 1260993824, 1021536000,\n                1793676912, 1445707769, 548650645, 2471023129, 1722482397, 1598031653, 1594850289,\n                3998091782, 2583735047, 4112635463, 4234758004, 61638741, 3499059311, 4255669520,\n                15597809, 4087916888, 3362090556, 613317221, 3135646367, 3745275152, 4183259686,\n                3005121894, 507799850, 718271315, 1030377735, 2148053708, 2062123531, 3453548255,\n                4131065481, 3413716172, 1106611811, 2253913656, 1217267302, 3521325090, 3202345697,\n                121303188, 2221607947, 200493459, 1536064549, 3701264585, 902459672, 2821419562,\n                3071361031, 1740183748, 2204817065, 2794368953, 2538416643, 1337013619, 1616927622,\n                3369284587, 306231805, 2471779547, 3343914379, 611812604, 3026990327, 1335972784,\n                2378840193, 139258552, 3711256482, 1887306531, 1842343803, 490997472, 1573143855,\n                2397027602, 114182794, 4008507325, 383983854, 3474881466, 1166904981, 1175073889,\n                1110485910, 3196990699, 4043619493, 805814251, 3373120547, 3788327425, 1533909416,\n                122434679, 3233582914, 295171787, 3657217515, 1578609722, 1948311121, 3999105875,\n                926524223, 1716729206, 2647249755, 1295295684, 1398742476, 1293649163, 3301318792,\n                1249107492, 3524708489, 900623614, 370317173, 3023227877, 2970370655, 438972951,\n                1453396240, 1074644125, 3045346916, 3937515917, 3535500112, 15511707, 21092320,\n                1808975979, 1836053162, 1131843404, 3321948476, 3302484273, 1327089406, 1414697348,\n                3320224015, 3616020523, 2344106677, 3914949717, 1612099005, 3159929782, 3472685206,\n                822813935, 1667292129, 976813491, 524378253, 1423919370, 1608169807, 273400699,\n                4009308334, 2421399647, 2280736582, 2766712283, 880839455, 2987899032, 2225630634,\n                2180172035, 2543875929, 2519364125, 3173433087, 1374125784, 3773143786, 874684944,\n                2053073738, 2343241744, 1895902701, 2366578082, 3825280261, 3757786236, 487512505,\n                1439635617, 1938815713, 2765729372, 3899164654, 3939832878, 4093082626, 1667022796,\n                3717556594, 3576843936, 499863677, 309936726, 3673342852, 1506381090, 3981017018,\n                133430156, 2132647863, 3475909759, 3665468568, 1623556555, 1085940983, 1366059584,\n                3025235319, 2970652374, 918600524, 2658744166, 2146092500, 2559792540, 3027296124,\n                3707023583, 739669772, 2930461897, 4224273847, 662889673, 1789566189, 2115222049,\n                2306045628, 1477918479, 3477961272, 2200326274, 2369335807, 2494565418, 1530641215,\n                1856911599, 1275429767, 866170004, 2745000546, 472242075, 1148993577, 798297321,\n                55095409, 2748938057, 929342181, 3387367510, 2828846404, 3637875254, 3732596202,\n                1557186170, 3381990740, 3426821093, 2834907694, 3939509161, 256757454, 3493347492,\n                1430037675, 724227592, 3233425142, 4193858302, 3143893061, 1935755610, 3752077517,\n                371021776, 1488573226, 3656803611, 1397487558, 114178560, 4143176526, 2827786662,\n                699057361, 3618652178, 3599020362, 883404904, 4076765018, 2869084935, 3430236310,\n                1142749989, 858868390, 2586327245, 3689072619, 3252574271, 3363933552, 3954232405,\n                2841098694, 1982066393, 2919650679, 972054529, 4263034065, 4202926574, 368921376,\n                2413687507, 1964998417, 1988513324, 1398922010, 672186161, 2525728596, 823408642,\n                350612408, 535241906, 4193747053, 3792454954, 4256440194, 946622562, 2670085778,\n                1489269745, 1957616797, 4145373127, 1921334332, 1154509428, 655312838, 338018742,\n                1492255818, 2530469964, 1474144450, 2544683314, 3920946287, 2107625122, 3071888029,\n                1093629422, 3957291155, 730207247, 687256411, 3258444139, 3382358863, 3665785701,\n                2294231690, 2744545482, 318434024, 1834441139, 3028059443, 1871862592, 1485031020,\n                2593743370, 697263431, 2210865421, 886961312, 2439951771, 898199987, 3761197168,\n                124724274, 2825616292, 2116702434, 1827284511, 1436381597, 1143344478, 2186418061,\n                2883101965, 378396187, 202806650, 3493016233, 3939805873, 3409895940, 3163956514,\n                3373046225, 2392603855, 2395190604, 3887042662, 966537920, 1465769860, 3846762642,\n                1449184266, 3361962069, 1673370925, 2958808530, 2121780302, 1683265706, 3285605311,\n                3961408003, 1543405091, 3037678236, 2408131699, 1787522757, 532868180, 3660710907,\n                737195751, 2579810447, 96617884, 2062138541, 2841404191, 1126197758, 772281033,\n                2192259642, 4125174714, 1587858335, 2227253460, 3228097564, 3808342348, 1930401381,\n                1718652876, 2762016003, 1896072752, 346749331, 3331590536, 2680437094, 1358381816,\n                1219099791, 2113769757, 514300773, 1510306590, 2620476138, 4192783798, 1375258173,\n                1517398070, 930184940, 3398516162, 2751947685, 1774049194, 3212098936, 1853827081,\n                1551809481, 4006909361, 4078910330, 1093611256, 3546035934, 3855068033, 858010820,\n                2321366198, 258458600, 3514203269, 1963201552, 1421264067, 1283367171, 441633157,\n                1845368475, 3362267277, 1133521382, 3051588901, 3331080283, 226988630, 2950015695,\n                1136423795, 27821883, 3776906112, 1472027322, 3101124287, 680641770, 1610005117,\n                4267303048, 2779573177, 145212881, 787862669, 2540284848, 2542323265, 3107232433,\n                2803967209, 1022688977, 2623452425, 3494748854, 111839415, 3449508061, 2614845097,\n                4279526745, 449560047, 382457375, 3060479998, 2948798581, 3774205704, 293384035,\n                1606331620, 4042994563, 565887987, 1141791257, 2033992531, 824325187, 3271632932,\n                3344669331, 205920938, 517437389, 3974257596, 1307157514, 3477428627, 2698403329,\n                3240285673, 1192057106, 1071891060, 3673531594, 923453309, 3687423291, 2724369809,\n                2003024538, 3800279676, 2094946084, 497354294, 1824040717, 2958898075, 2581987757,\n                4122751267, 1424305065, 1354551820, 4236177572, 1793895565, 4030145142, 3660321673,\n                2018007866, 4213196204, 1668717301, 2070438973, 3539891506, 3346804175, 1928891907,\n                530432338, 1978654608, 55791536, 3348858146, 154895971, 292221119, 2987688682,\n                1164399118, 2430342431, 2428527198, 2496113248, 454730991, 1971063328, 1258681134,\n                1813932199, 210407227, 3340111973, 1084627479, 1064216514, 4064722485, 2215309052,\n                2993288075, 3146502847, 1831511244, 2280232151, 1590405456, 2200667755, 1628965450,\n                2761404145, 3717575260, 3798572094, 493632921, 255074552, 2384177829, 2778689435,\n                659238302, 2327047407, 832728694, 3100546768, 81046048, 2887377108, 578242373,\n                2799531209, 1295083006, 3419337072, 1345094121, 3216919515, 2343387385, 4153152162,\n                2161067647, 1022049107, 119048368, 3916106008, 565831742, 2794988440, 800430879,\n                2447084785, 453855289, 4132400296, 2669036842, 296861197, 2202167592, 661965250,\n                909220018, 1527898574, 2667058573, 588621789, 1998764042, 372858612, 1477125875,\n                2647615554, 1983954649, 2388809988, 2016597037, 1089073774, 3433137953, 815616715,\n                551673059, 894250325, 1559189236, 18389714, 4228703818, 517820013, 2111620514,\n                2544469443, 389336009, 4175846461, 1243110116, 4108914066, 1211738389, 793931364,\n                1801248621, 472881962, 2841706465, 1274000666, 2209746053, 2475239540, 275807348,\n                3274559590, 278907706, 215711806, 461479011, 35786016, 2256077091, 3898546316,\n                2586194294, 2834624674, 3854613059, 349247533, 3330821143, 2484986035, 1118490626,\n                109596634, 1102082878, 3639363802, 4123644328, 583993094, 950048702, 3739148555,\n                989914794, 1878111588, 1705085869, 1515179520, 71552189, 2889476532, 289469054,\n                3359213779, 998546497, 1617722977, 4210818802, 2212383714, 42057675, 1064166190,\n                3128172126, 2743461504, 2779205797, 3839262319, 2645572700, 4040270163, 1638247754,\n                4271726795, 470879176, 3889433544, 3751756626, 2995468452, 2585565812, 999116819,\n                3508547190, 2161381426, 1016925093, 1000171248, 1494314082, 4022087643, 1102083259,\n                4009453582, 4186192569, 3212042270, 2178496725, 1460473606, 4018333955, 2005109618,\n                4283613923, 2169746853, 2524549630, 3509522975, 720025572, 3624177652, 1590493281,\n                56530035, 1056103439, 3171190085, 2733026440, 2459096713, 2043383257, 3089026843,\n                159409060, 1417617528, 680269607, 3936036271, 3533484516, 436828291, 1110616994,\n                1409703119, 3293167841, 3330632855, 1806501600, 665466700, 2138584065, 1134927945,\n                2636023322, 902992604, 1467516266, 3163905998, 2748534143, 3338909086, 2773650360,\n                2351882854, 2618618051, 1307786697, 1329236348, 2960590099, 2274451740, 2016354728,\n                2239789753, 3033989968, 1384792327, 922785320, 92821760, 438784782, 3757769042,\n                567367146, 1003466644, 1726035240, 2262967263, 2726288557, 4095316988, 4477560,\n                4043153559, 3917834466, 2042703909, 3964168936, 2533496967, 565827498, 3044782857,\n                1426618089, 50646973, 2813326961, 3628087749, 2907344581, 2537993920, 3598160970,\n                1028651184, 1717080965, 3269360889, 570217843, 4186276351, 1082213825, 926440426,\n                2070827707, 3294185079, 2449173840, 86727007, 1435055586, 3065557879, 2351425539,\n                1286878886, 3818639923, 4286969439, 3271121683, 2981208936, 471223863, 1362601479,\n                3999136827, 2947233786, 2942179272, 4165102641, 1585257917, 3601973938, 3372610933,\n                4045268939, 3936571497, 2375540043, 1711605304, 2745105944, 60319076, 846801314,\n                3244316989, 3280757716, 3106180603, 1876680557, 2199367803, 2589208677, 721055873,\n                922630059, 1548218484, 2646172490, 2856162971, 861677714, 2013479067, 4125064047,\n                3135259174, 1987391034, 1612240980, 3901607644, 1989084918, 4064704523, 1617603086,\n                3624548836, 4228236160, 951778179, 2258253293, 2844302721, 221571638, 45481005,\n                4115699132, 1497796421, 4267752533, 891937890, 1035077096, 2209048878, 2922535041,\n                3098592820, 4042474064, 1697703755, 2399789403, 424377247, 2260587022, 2193368797,\n                600282097, 2742041813, 1336804874, 2650658716, 2970310817, 4045380756, 2688502007,\n                3926497235, 1096372043, 1338172683, 1237644267, 2798132618, 4214417948, 350223564,\n                2294825555, 4042231686, 257708548, 677230641, 1925625022, 4241883500, 2695106980,\n                3028571259, 2887580741, 1180867256, 954435786, 1057867101, 1558741430, 3348329056,\n                866764562, 3344476407, 1111689088, 187045741, 2391307551, 2959008045, 3948691948,\n                1319187960, 675359019, 2984386771, 1840667056, 488976976, 2325589449, 3007129454,\n                408435318, 3694608179, 2542389000, 3687602293, 1123412948, 1374633563, 2112015185,\n                2546930077, 2404921048, 1414947884, 404979651, 3135158757, 1510573459, 1710196771,\n                2713693744, 1070462689, 1213959292, 2534266780, 661012500, 1874896877, 3271767429,\n                3275230980, 4264750161, 3572375081, 1579194793, 1742321855, 1961359715, 1488092333,\n                2831928507, 2798998762, 3843198441, 3176393593, 3214277128, 2393328325, 3566395385,\n                2774611529, 1428232834, 2110323330, 791378925, 216120541, 3861236968, 231370989,\n                2639794499, 624599731, 1219997589, 3787521330, 604314725, 3461276607, 4050374542,\n                3642233765, 194872120, 189897179, 3261758346, 469130126, 3340624526, 968498604,\n                355999757, 3837862051, 3904146415, 2873860611, 869804381, 299440640, 3520424116,\n                467765288, 1174495386, 3568117911, 3678085175, 1146375992, 2008699612, 2353114304,\n                1071351122, 2303361684, 862351484, 1648692826, 1224344365, 4272397711, 4083818503,\n                513078016, 4124881085, 1496441405, 4009634631, 2028357190, 2064925965, 130259652,\n                4158281641, 3339267074, 2346473402, 3040620475, 302567288, 2098529576, 2557666596,\n                3815840311, 683165531, 2914308335, 4044834414, 4252332010, 3278908623, 769564314,\n                3697741763, 2167955348, 3203861471, 2126706587, 2456367636, 3772712294, 2092879871,\n                863396039, 508902802, 2793550452, 2693435437, 1391736628, 1157153689, 1409894468,\n                807646877, 271880092, 2088023280, 827665392, 1435968155, 529346767, 3332013609,\n                1707352770, 1166889197, 3084999870, 2984300978, 2396541821, 780406104, 4069234239,\n                1386380802, 3372735777, 3654121391, 2926997272, 3418571197, 481723726, 156396805,\n                3225545154, 136794862, 1845380077, 1434076416, 2469706378, 1818524696, 1020300445,\n                3961599464, 1347758807, 1580244193, 3105582525, 4224693377, 85103854, 221740682,\n                583809331, 1876617658, 190405249, 434449658, 1905985766, 1004630479, 534307076,\n                3645762882, 1516085517, 1235003680, 1311064464, 892154476, 3004766628, 1015993206,\n                249377204, 3871066261, 2893118754, 2466150031, 2139448418, 4269228198, 512105997,\n                2790471018, 3932220953, 1659370949, 81403428, 356737648, 4153182358, 3806788782,\n                2102548424, 3227939175, 3000515829, 1141241618, 856180425, 1217257095, 291825148,\n                29808179, 946834904, 2727274069, 2659003572, 2778333831, 170117914, 2900631470,\n                1650666906, 3004242406, 3422959408, 4060912839, 114575898, 1842399219, 962270342,\n                3676883280, 2930727789, 3839654913, 2161690357, 680073756, 1898043108, 3687931421,\n                3644299988, 2354196541, 2450591233, 3155696561, 2851736135, 200426970, 3098061401,\n                1143058922, 2859561130, 191439515, 2380738368, 3453524409, 243865967, 4204885436,\n                1854308264, 2651192364, 215699541, 3667750969, 92453718, 2870815953, 2350285294,\n                2860516750, 180810177, 3523383186, 132903803, 2874303329, 1836934344, 1769424123,\n                2074849407, 2436859811, 796104248, 3837530147, 2693412114, 865664534, 274559048,\n                3156205156, 3318629936, 725125344, 927243554, 3507933982, 2771564181, 511265012,\n                2360434429, 790740438, 67312079, 2232773510, 4159603181, 2666116581, 911742448,\n                2773650983, 1537336504, 1123767928, 1245244759, 755395243, 2230363192, 2311150865,\n                1310905897, 3635633537, 915322772, 3309277755, 4102148078, 2737064941, 116557272,\n                3395885355, 3492962591, 2154943050, 4283933288, 1187022256, 2337945824, 2140138623,\n                1243490701, 1664618771, 2723135057, 477750234, 519210867, 990489192, 2010998441,\n                2405731553, 2328924508, 1027928316, 1471509675, 448099363, 2464256239, 3912226872,\n                2086652210, 3206856094, 7300210, 1998193697, 943722522, 254166499, 2111943630,\n                1127624858, 4001349711, 3044456286, 1531676981, 3763383233, 523495565, 625810415,\n                4285822939, 1882476395, 295164493, 3251126307, 264629432, 3058573006, 4222655455,\n                4193922449, 1947989063, 1625940097, 965463176, 1540545082, 4269802379, 3096278327,\n                1917287030, 811928072, 2021954213, 3352534952, 2069143641, 1011142292, 2013199459,\n                1983584044, 3378795515, 1073003188, 3542525645, 4256818813, 2893719471, 3997051418,\n                2019353119, 3254985548, 3031865, 313156230, 1875615965, 3520020372, 2398543168,\n                269701833, 3585027713, 2172521845, 2365672940, 1148380788, 1918167676, 4244569795,\n                2283551383, 727538472, 1530708679, 2512271941, 2142650333, 4236443712, 2249548500,\n                66575576, 3430978190, 4160214541, 2373906807, 4038023459, 3358632548, 3594956519,\n                1035453391, 4145796024, 1156514907, 1246913527, 2241586732, 3979448944, 4224967589,\n                92230190, 3201011336, 786008427, 909198170, 2192884584, 1418258734, 2169216084,\n                3388716292, 3273421687, 2807726209, 3178922474, 1243431685, 1921275148, 2464361452,\n                1596390320, 776990882, 1812414638, 437620977, 12213113, 4179461440, 498724925,\n                1371593337, 2419938007, 3418848663, 3084795577, 2099025380, 450764221, 3933062083,\n                2894530307,\n            ],\n            &[\n                169261212, 97019657, 2010098423, 3060596318, 2200430153, 2869077638, 3698742283,\n                630687593, 1344435198, 14077903, 384687684, 536665320, 33712500, 1110160663,\n                1132275258, 755052985, 3538444513, 2168204486, 1431872026, 2944859263, 151411172,\n                2055104382, 2850392235, 3204051758, 432306835, 811337238, 2814548049, 2643221792,\n                4046346365, 3018313224, 1385088585, 2725111255, 3634261412, 2210377846, 1304209844,\n                3231053663, 931121572, 3651371093, 2734237688, 1736817020, 1266539929, 2040761720,\n                580656351, 672494919, 1095514416, 1562672852, 4036170315, 2378771331, 3846827522,\n                752910893, 130805753, 1015401095, 2737607490, 4133741161, 410356140, 2533339641,\n                2271585092, 2961265479, 2637760446, 2158261474, 680899708, 163993353, 2997711760,\n                4215808749, 3723292800, 2192481625, 2556236735, 3085843169, 3092082759, 2465630516,\n                3247488074, 1705364646, 814558461, 3702622021, 241980441, 4140873510, 3885766880,\n                4012271283, 3999222517, 148661894, 1282933302, 1770982817, 3186160246, 1901652026,\n                4066201988, 2160372795, 3268508049, 1795046973, 866721742, 2075628922, 2807956783,\n                3295312433, 1999667844, 1333068683, 1149723459, 72589844, 1092560851, 4282555118,\n                3510140080, 522259828, 3385050651, 1937511732, 761458722, 1293935175, 2214664794,\n                10242119, 3063498224, 4222607771, 642844662, 1351241302, 1536474598, 4122373319,\n                3737795066, 2617562249, 2974564444, 3058044388, 2028712828, 1829321567, 2548853558,\n                2574521694, 3312702962, 1865006140, 1501367075, 456299067, 2942841642, 4196219184,\n                3498196346, 2569794425, 3802868405, 356077732, 3430096358, 1630488232, 1667012225,\n                1212294536, 538718198, 1407896138, 3172899401, 4248307113, 2864880507, 2852924732,\n                1281650298, 3789759257, 2435025122, 2392372329, 1516476552, 3800421041, 4033823692,\n                1936348564, 1434124331, 3273281793, 3592180633, 3962067590, 4287698149, 1519025535,\n                3563650753, 481915643, 196362100, 1760975324, 387341865, 4218232910, 223829427,\n                3264588279, 2066845936, 1898648367, 1048579696, 2407743538, 688452394, 1749433021,\n                1355601447, 820585203, 1020713467, 4173935621, 3483593644, 487816899, 93580477,\n                2944973103, 2300781257, 3103447323, 2951726120, 1970055032, 3830054424, 2489896194,\n                1046031109, 2245455797, 1867332719, 3150097735, 487517766, 2966736739, 4061236172,\n                2438285500, 1032477139, 364267316, 2952150398, 858946610, 1472690045, 920469949,\n                2209121191, 864450987, 3106150723, 2969726486, 2845130450, 1849358041, 3005036358,\n                4235423404, 97347937, 175921091, 1348170234, 770199516, 365087161, 991425113,\n                1533529912, 3818277147, 709418670, 4199014005, 1109879416, 3319928498, 757645463,\n                258144610, 2336236633, 650087839, 147117363, 812176287, 3720773532, 36900249,\n                2987629201, 720304279, 2467854235, 3815514608, 1066410164, 2802842865, 2173716894,\n                1982188941, 1128651664, 3558904900, 4058483597, 3270204162, 1330681110, 758186224,\n                2172595164, 1448125003, 2173830084, 3215033023, 1851182505, 2713002256, 3835030966,\n                2229814851, 2233929591, 2244641624, 1171786638, 1378913849, 1556728648, 2949947972,\n                4074487734, 1505921507, 748234195, 3600080354, 2028262296, 1470704954, 3470426878,\n                3122530841, 2410213039, 3408701679, 2501278564, 2084471422, 4258561313, 69281285,\n                77000318, 2036112677, 3928311555, 4243023562, 4014794170, 2383505475, 3292068789,\n                2907501855, 3311234451, 1145983385, 3319882794, 3653205285, 3725028918, 3729871024,\n                1390021708, 4222789914, 218974342, 3821348650, 1368295153, 1279495709, 4278066442,\n                3297583909, 1821526324, 2973731013, 1041979214, 489278942, 2124166216, 3405155013,\n                2219346020, 1318848327, 1829360017, 4134292239, 1354535698, 3077327835, 3264258673,\n                2012426550, 4177109126, 601960462, 3163195869, 1445745889, 898171740, 827204772,\n                2258489433, 2062776641, 1021468635, 2390809492, 534241200, 1797102980, 1845684576,\n                2118715856, 72319402, 413085624, 4008263605, 632503759, 1686868824, 1754787516,\n                4294687573, 2013002089, 803099033, 1273543325, 4245916534, 3037861929, 2991538180,\n                1799210280, 3000981395, 499844317, 2877414269, 2329779164, 4220434292, 562828242,\n                2741213468, 1944223012, 1861372602, 819033522, 2681839553, 828991290, 928793250,\n                2344560370, 673594463, 3751423502, 3807439725, 3979850161, 3547495108, 3707143288,\n                1858125101, 4142196157, 2373721462, 1518142446, 1548054547, 442881448, 1738298750,\n                453949092, 1970124231, 3424857338, 1820967071, 1736209613, 1091836295, 2809423605,\n                3481631497, 133425586, 4015083333, 1984612975, 923514530, 655227462, 2775293769,\n                2712696699, 828247566, 3829922109, 3871571738, 675598020, 555032496, 923212291,\n                639720389, 2919964342, 4004944983, 2217510339, 1925954172, 2418913014, 589615454,\n                435489824, 2245278741, 3491912204, 3342199322, 4013531036, 3426342754, 678591516,\n                4258986026, 1682355128, 788886889, 2218536681, 1317056760, 750073663, 1793777336,\n                518564031, 3108963423, 1523426771, 1198654802, 2719985938, 521075618, 745829783,\n                2389591028, 3716963027, 2238978453, 403983408, 3781517404, 1836423104, 2198030139,\n                2302949603, 4173024897, 392102066, 930721646, 1094357046, 3808728794, 2852832081,\n                2314321478, 150826424, 711452896, 647663402, 3016271507, 213728995, 4127389886,\n                3720742331, 874266103, 712172019, 1315187042, 729949129, 2284688094, 1817849857,\n                2709846568, 3092049463, 1161688426, 56968775, 2489474475, 1404650164, 263784267,\n                908154757, 4290307608, 1375864071, 2725649740, 1247176526, 3679406490, 4236673427,\n                413662550, 3792331497, 479205991, 2852263799, 1042720125, 3950417785, 1001301598,\n                4015555465, 334867024, 4253731418, 764002502, 1119482483, 980052531, 1558968415,\n                116027612, 3045193528, 216886097, 3377362470, 452394673, 2745755946, 3996292608,\n                2672041571, 1369242942, 3549593046, 217715905, 1091134633, 1780559106, 2338755733,\n                811628867, 314006903, 655439900, 1803434434, 2061142553, 1119728935, 3070087224,\n                2533572837, 1408968356, 2424595522, 2737313431, 1127783352, 2637282584, 641318539,\n                2988938943, 1101438454, 354997500, 1532790146, 1946117468, 1260866996, 3198198219,\n                10975301, 3918093929, 2825812082, 538313674, 1768430706, 3738638001, 2667074884,\n                3358956925, 2410322745, 1076744040, 375884360, 3751703965, 3161863052, 1457146467,\n                3832520550, 3233502144, 3669902726, 245281689, 980364295, 3800611124, 3491342490,\n                579797343, 4250558994, 4153483609, 4258531200, 572001069, 453700369, 579285386,\n                1726550780, 677036467, 864962793, 4131217567, 2169450313, 3795432981, 3369719591,\n                1347751707, 2987508248, 589435126, 849216358, 80245949, 3523392244, 1329490478,\n                2846195592, 1283476607, 3988324775, 1226554934, 2524758910, 4115217052, 264772855,\n                846505996, 1974293917, 3071402363, 171606341, 80617760, 1218055661, 4202796081,\n                1431247412, 1205540953, 1035047106, 1562320516, 3549999782, 1724161454, 1280483311,\n                2462179501, 604829659, 768655290, 1447536294, 144890904, 1718444137, 253182878,\n                2781922595, 2107474328, 3912782422, 2132300849, 252022782, 4071842247, 536916710,\n                2410520005, 865716811, 4217017985, 3405855693, 489680629, 4018805509, 1851896495,\n                3292625358, 864499941, 3240462025, 2075476643, 938753688, 3665130887, 4050325243,\n                2454104972, 1298917629, 1343787954, 4100160453, 1768484371, 1266082612, 238720905,\n                3180785770, 867009796, 2035104678, 3520470624, 559830721, 1459820613, 1707305731,\n                2269616662, 1576379671, 3903748424, 1436765334, 3048417647, 2253458581, 3416118525,\n                1271698793, 3601159380, 3271921040, 2369386936, 1192728003, 1122107959, 706191870,\n                3978806926, 2539808936, 2998649492, 2864374813, 668066219, 2640264057, 1281805203,\n                598078394, 1301198855, 2947966501, 2555954897, 1999895199, 3567728711, 2965019228,\n                2511728126, 2956114261, 2995201734, 4123471616, 457926115, 2385329272, 4012223776,\n                3469911190, 3267267247, 432918904, 2419068123, 3755513135, 2791185744, 758833690,\n                3119576271, 112374229, 3625202266, 315354366, 1568978273, 1708623705, 2064937453,\n                1124067903, 513216095, 3600324289, 1796860007, 1650966402, 2904683505, 1536173911,\n                1194264833, 513210391, 3723175142, 735565798, 1834230448, 2261021807, 3908447305,\n                1057830830, 2776652319, 856596767, 2408743106, 3248755512, 3799111617, 1459677314,\n                3511723346, 499123179, 2708042922, 3492700205, 305184657, 1157916233, 3495088020,\n                2259888881, 1084374759, 500610066, 564964925, 4131273965, 4039883025, 3168377277,\n                254683919, 72093362, 1633531730, 1268664506, 1996711604, 3890322048, 3880828363,\n                3683271754, 2649717281, 658488513, 3017375859, 3323992513, 1910609388, 2895184148,\n                2111754597, 4005561580, 3122346347, 2993430208, 1199752820, 3108668091, 4218258049,\n                2822905539, 691305232, 2961667717, 1592996194, 2452161541, 50809045, 3557234166,\n                4011426161, 4041745783, 3204617417, 647976586, 1613272265, 891115055, 879063893,\n                3810802553, 3324904075, 988210689, 3334787768, 3235291491, 1406547399, 1509369724,\n                2678898670, 996757247, 621865039, 1415546535, 1635533836, 785967648, 3519780499,\n                2306303512, 2608109709, 359246803, 794297329, 1984469432, 860434555, 4188210328,\n                3560452183, 3324289086, 1341545766, 3210361014, 1550450120, 1999237534, 3419330139,\n                2052886381, 1713799546, 3838907316, 1300491982, 2376293684, 4058197568, 3717833550,\n                917200668, 237670602, 3700755001, 1177316153, 1660105335, 260378933, 3544708874,\n                2760016197, 174001204, 3662445679, 236165327, 2352314383, 3876396412, 2842836038,\n                680492466, 2660856178, 1251120958, 2853698773, 456537263, 898086106, 2998300997,\n                377764496, 1543994003, 2189371744, 1255653737, 4002649460, 2687989728, 2526120649,\n                2771515626, 603147406, 1301287096, 2424823104, 4141553409, 2594874275, 2043054687,\n                169776785, 4218374604, 3662370269, 2905747555, 1746018134, 357240197, 502016893,\n                1474347041, 219646155, 483088078, 3514453507, 3217126533, 2412744587, 1413706460,\n                3659693851, 2763885745, 3512330896, 3369579836, 987519219, 1511534086, 2988205816,\n                2061616536, 3145760504, 1795367921, 1255779803, 2379607545, 410665900, 1407996847,\n                3494698253, 2200535289, 615174944, 275789962, 2965302786, 747758065, 399661,\n                664465050, 967613913, 125247217, 2794499891, 2702820795, 125088830, 2440619784,\n                291501124, 1302832003, 4097601407, 3942447907, 4190666347, 238558373, 2615163708,\n                650543751, 583615336, 274528855, 1116046575, 1191854544, 500294666, 178065110,\n                1136050609, 847527472, 2214527390, 1376266014, 536073983, 1549513725, 49053874,\n                3854314141, 665952982, 3072097827, 3377813806, 2214813699, 3972044240, 706712408,\n                1694621635, 1547391041, 508243162, 1582084361, 3109229183, 2354675221, 2691073826,\n                247654849, 3300964107, 920809617, 355328468, 1689727187, 2482106376, 3398454675,\n                4214185480, 1920179926, 3602682077, 2103634868, 465683507, 1949801248, 3203673832,\n                3614462347, 2628322849, 3412024211, 3058963268, 739635165, 168941792, 1084170381,\n                3020427408, 3027788526, 2767887509, 2350507515, 3794342601, 2701457973, 756909326,\n                2148742735, 4276521984, 372610377, 3595171701, 1430047080, 778291005, 4051284928,\n                3770991142, 4020832961, 876293685, 4204224949, 3328204949, 97989228, 1597721355,\n                1310541270, 1187240092, 362259278, 1473083151, 3673028806, 2288833254, 818795041,\n                2550563052, 11964728, 329354443, 269689053, 2202758728, 640290438, 2319494670,\n                2820841677, 1991707137, 4003582526, 1987274151, 685337695, 3389490388, 47364191,\n                2019974308, 1796560073, 2242052145, 132168074, 3664740900, 361328363, 312012382,\n                3787517201, 2134021202, 4221983070, 3092531591, 4015482354, 2383783835, 2935132128,\n                1073105385, 1051702314, 188642192, 1840755701, 2194015262, 2970833720, 3418173712,\n                2252291293, 896755811, 651041213, 2225339647, 3799501024, 3424383062, 418261680,\n                219007048, 686407479, 336359847, 815174575, 2476150653, 395070317, 112893476,\n                3236677850, 3043491435, 4141851912, 1741291050, 1447570359, 4060099803, 2025408789,\n                730965869, 421345011, 1940000014, 3939429382, 955964946, 771910038, 423132332,\n                3928015638, 3828592830, 3062230638, 299535389, 2287150162, 2665328140, 1340823063,\n                1797607489, 441789856, 921536914, 1038801198, 3684047183, 1436606597, 3683958696,\n                2132905377, 2812354533, 710326258, 2053698821, 4157794269, 3865258382, 3434923942,\n                352173601, 3698116441, 61131962, 1831719345, 4924961, 1843981357, 700878228,\n                3450757256, 2056793283, 999928739, 4282817569, 842381781, 3597643631, 1773109621,\n                3736994722, 1006105110, 1984548595, 1549955286, 2252538952, 2134791896, 816830151,\n                2573239801, 1318436425, 1215534200, 584845949, 1503621472, 2135150542, 1205539732,\n                3946745009, 3379992771, 2693969248, 3372345019, 2830977120, 1615941834, 1665464385,\n                3189732495, 2091398892, 1420883664, 3478609997, 3624116279, 2008982698, 3436952257,\n                3091084695, 2110787732, 773082120, 3133624299, 2225398192, 4086665432, 2754332922,\n                498589840, 1032159204, 3615509977, 483862860, 413051959, 3147549436, 203215668,\n                864863242, 2260028710, 1792523541, 1886034938, 4117866346, 3907544391, 1792457196,\n                2413537412, 1123222281, 1881205239, 338064304, 1854384474, 3567492850, 1936538538,\n                4003096252, 1552683498, 4245128768, 439398918, 4170165755, 4159254873, 2096750598,\n                2291173747, 402334911, 2054654988, 2484919497, 3081708303, 3279239445, 108764284,\n                1057932939, 3308339365, 2207596480, 1449496569, 1696511884, 1834486206, 3308019401,\n                322787272, 294989059, 3308250023, 2710211918, 935435567, 74574252, 3918706572,\n                995180801, 2743621566, 2564939789, 2233249899, 3800182678, 3356656333, 3735865703,\n                119633377, 2083925509, 2463491366, 3923690669, 1079463335, 3057356162, 967864883,\n                3852737202, 1231024601, 1966227476, 1364301520, 3559098941, 2224735562, 2140723583,\n                2954206392, 2792110922, 1612283936, 4116236064, 3975950903, 1906705634, 3397946250,\n                3425584528, 933399048, 2654489483, 2465523840, 265969028, 3944317432, 726011247,\n                4165272642, 3707806595, 1980231873, 3916598482, 2208019315, 1055848462, 1396382428,\n                3565198447, 2259626619, 1629781689, 641856706, 1567056255, 4157261705, 3272229411,\n                2887326518, 4112471500, 3407005857, 2165760760, 2245192644, 2387432860, 2948884081,\n                1894578563, 4051596444, 4264496837, 1037225999, 406391535, 3697484571, 987529602,\n                828660915, 3322759290, 3336752646, 232274025, 1425642089, 790855420, 559144975,\n                531066167, 4111730690, 3535290287, 2382110606, 4012402298, 1708817394, 3887552584,\n                256426575, 3468310594, 1318238511, 410028308, 3076830889, 3142568555, 617939456,\n                268991245, 2600800869, 3068613261, 4159995171, 1629469694, 3607924061, 1126466101,\n                2409909797, 2602008720, 1676826993, 101555029, 1543891625, 1425841171, 1381575655,\n                3157322434, 1502237687, 1765553298, 2196226984, 2144309744, 1920733185, 2417117835,\n                7914446, 824040601, 3658371011, 3764653611, 3882418008, 3131863018, 3734042302,\n                3886679853, 2046795709, 2102441413, 774651843, 3153107599, 3441128733, 1816520377,\n                1550198216, 296013733, 4204605434, 1702162229, 4225881387, 836166567, 2965646145,\n                166521501, 271613715, 1191068489, 3073239720, 2533295935, 305967434, 2025841195,\n                578863608, 1347597556, 790549374, 836951743, 1016821465, 2546000514, 3963969693,\n                3758198764, 3154272861, 3997249588, 3488724105, 2694683883, 1672107026, 846981198,\n                3208072415, 592509645, 2825113079, 929097667, 4017105126, 721112884, 529877910,\n                1957406684, 3590512653, 2256381674, 1326953526, 4145690793, 299038714, 312037364,\n                929796369, 4076045375, 232059136, 48191462, 2609783390, 2793032740, 570795792,\n                2196568883, 2379554324, 53898640, 2778733606, 1650134377, 1356622380, 1413120072,\n                1497564725, 3121339218, 2339710583, 729121036, 1226260959, 310416282, 1068015305,\n                2988960158, 1087871955, 3901334475, 382701389, 3419394711, 1197193940, 1145893534,\n                4213285962, 2358861326, 3998800674, 2393159007, 3284066750, 3802242851, 1313120318,\n                1363843377, 1864600319, 63244244, 4008207492, 25997534, 1096534622, 2512363231,\n                2822756078, 1502763806, 4160151918, 1229692802, 2027837957, 2682155120, 3622762160,\n                2350798073, 3364105528, 2242135190, 2198683774, 3004743957, 341703900, 2063637675,\n                1872726597, 369384611, 1228961924, 1174849959, 3429920072, 388013006, 3711844897,\n                3458411733, 558446990, 881810677, 1612852481, 2341850382, 2615440366, 2756996485,\n                69608033, 2051792699, 879427566, 860445240, 2799693963, 1529796847, 2693841749,\n                2241425469, 3509318038, 2310074766, 3970361365, 4137984377, 2640268429, 1179754608,\n                987219549, 4018070677, 997817346, 639088040, 1490544586, 4291233088, 3379985752,\n                934787373, 2545981495, 1791682456, 1831741597, 674344163, 3222780829, 807041479,\n                3982102682, 4194907534, 2382110434, 1305255837, 602454212, 1959169268, 3491589095,\n                4274490818, 1407854427, 4285073354, 3181358931, 1413064917, 1136150007, 1567762961,\n                2613870921, 1915481443, 39052775, 1638846611, 1514008892, 3881142793, 1681639953,\n                851015338, 2913922957, 3768834738, 2690174502, 3822191500, 2710964289, 2884125750,\n                953870770, 81197866, 877172811, 2824832010, 879150580, 1996758685, 32277063,\n                3986128633, 3479151959, 4227758436, 1856386632, 1937580142, 2006837739, 1272263848,\n                58649929, 364183573, 2651849529, 514447392, 2336954024, 700118423, 3608261942,\n                530454875, 4232722227, 3245016835, 3107778289, 1294145943, 2322823463, 3200734771,\n                3997000237, 1394603080, 1521731730, 2099402018, 4076865358, 2952642380, 1998818851,\n                1113503600, 1304568624, 156004729, 2524292645, 2196657034, 838089549, 852921142,\n                318774773, 535471800, 3303288655, 11720307, 3920050060, 1828240211, 524002979,\n                3048477395, 3534464096, 3963965163, 965647042, 1254821357, 1076701084, 2092634935,\n                2227885879, 2211769441, 4149106576, 108232835, 1044586194, 907173178, 33459410,\n                1802126318, 2254795011, 2504657317, 2646373524, 1874357148, 3605965029, 1140229111,\n                683774180, 1809530666, 1065795157, 1426067459, 579103711, 2163604958, 508216473,\n                1358516833, 1857560558, 2375569242, 2924422020, 2493986279, 729547351, 54833281,\n                3560718296, 2168295149, 2812939376, 3488876993, 4293921905, 106256919, 3235972461,\n                571493829, 2879800589, 3939771200, 3173435794, 1528411227, 2644147095, 3099154467,\n                3780711788, 3974962776, 3038048098, 3815481320, 856676641, 2816739527, 2163011160,\n                2429846008, 2574499461, 119664881, 199459917, 3413283247, 768994425, 2761139109,\n                287075146, 2513460954, 3946445315, 3896813683, 341660798, 3771058010, 1948705192,\n                1023508457, 2862084803, 1760749154, 1666275298, 1181277511, 2612599583, 3323548077,\n                1187252244, 775332124, 3631948959, 1634443470, 2542063810, 4141442087, 3558732104,\n                2216948373, 2165466142, 409718746, 4038251685, 2652525312, 3147566726, 939782543,\n                634685444, 4171370098, 1242056880, 1509271389, 447023005, 63439402, 753908776,\n                4007669178, 3612271563, 2941872224, 2339268139, 3167669951, 3980741106, 3989254815,\n                1392085272, 2825617612, 956934399, 693542348, 388806851, 2961997752, 3537162743,\n                165236021, 3568156596, 2285015214, 1348352477, 265706007, 2902421909, 3911380709,\n                456741743, 2843416287, 381948901, 1723053624, 3637546635, 488437141, 2056924346,\n                3245456457, 3348178830, 907978865, 3949328523, 3105952503, 2583910709, 1005480091,\n                2592364506, 4212210190, 1616794263, 3063505007, 592323106, 1258310856, 3641811727,\n                3350224634, 309905898, 4040991440, 980414012, 177467055, 217549578, 2392128580,\n                296868908, 1084522467, 2436484542, 1317628251, 898381082, 1111060884, 3948408286,\n                2371873032, 2226259852, 4058234570, 2076955067, 2121848190, 3826134000, 1986232314,\n                3499478289, 1151387495, 787568209, 1612098354, 726090716, 3069387528, 3976962630,\n                11690122, 1514834375, 2808050579, 1071588017, 2715771085, 437010571, 2212330428,\n                1453821701, 3145667973, 1767906839, 3146700047, 4258425268, 3254514728, 3407434515,\n                4223362441, 2099546808, 830143900, 697083215, 2751907755, 1322473957, 900523897,\n                2264299413, 1819302867, 806605230, 2799217353, 4141245107, 2305511413, 2796286940,\n                1505198926, 4225291875, 3419813095, 371941609, 894282352, 3479699537, 2884117847,\n                248087943, 1920569071, 2946559495, 712099571, 322392405, 3179639943, 1574300690,\n                2867358013, 2572247714, 2563009176, 2358102551, 3259794641, 3054031241, 565630085,\n                599078879, 862629306, 1222169625, 2841254325, 2978934915, 1803471284, 622464338,\n                1354864342, 1901488888, 3205841023, 2319170073, 2904669324, 726542457, 1875424943,\n                4281642921, 2733515426, 3395862316, 3074062952, 4007451622, 3514683310, 1293909285,\n                1564336286, 2757910036, 3740249853, 2635743866, 1699257190, 855262188, 2797562313,\n                2308409571, 2253291408, 3845709526, 3154706518, 1770564626, 2996626195, 1879190681,\n                2386507312, 1705385750, 1368311878, 3107016242, 3053769309, 1152662782, 3526989793,\n                1902149904, 1902713811, 1304553510, 2290942581, 994180644, 56936189, 599820797,\n                628353940, 2338146967, 2227276356, 3246471204, 2978741305, 321966222, 734612620,\n                904416002, 1929536581, 1325321823, 2240235157, 3921782780, 2377955413, 1963840910,\n                1390622328, 2216413136, 1687027811, 569207696, 652619399, 4260710017, 2551934365,\n                128469616, 3999651830, 1649824406, 2553389567, 3992265912, 867004062, 3467311621,\n                3883161582, 3171530997, 4135113186, 2525098373, 4127647431, 1239629070, 1752753702,\n                2554081705, 478672844, 1252671738, 401028269, 981568864, 1532744660, 2664413649,\n                3073701514, 328844958, 2280704902, 2820551746, 554581755, 2039689489, 3587864476,\n                3575114490, 886087913, 231160170, 1237051234, 1485907068, 3678959111, 772097566,\n                1428405353, 4048938898, 3109482280, 1435032640, 1835231833, 232340095, 1426343085,\n                3667550549, 3131273021, 595482068, 2141954646, 1432221631, 1746392369, 3843312686,\n                34950246, 2816690285, 1045968443, 38087956, 1588670084, 234385795, 1180629994,\n                373759660, 3873059192, 3277260485, 1750965294, 2851237408, 2070340801, 1298152607,\n                1791737110, 3240276593, 2371282968, 295305820, 3105367956, 1030783254, 2361722325,\n                1010613854, 1695440553, 2311171792, 2219950094, 2774978735, 2694247550, 110928242,\n                2747578028, 255588253, 890925956, 251245116, 2392813905, 2414578306, 900686275,\n                648109093, 3359108729, 9572800, 3154921879, 2936477949, 2806878192, 1570137434,\n                1047231293, 2966514714, 1969235114, 3821617637, 535808314, 97656562, 4198277832,\n                1089921216, 3395530343, 1137276020, 1830819579, 758187601, 773887976, 3831934509,\n                1923796236, 1341680867, 913019441, 3965990038, 3759247519, 3440863001, 529202042,\n                3075812116, 1166356691, 4278485955, 1794714579, 1193119096, 3961305347, 2229650504,\n                2297510904, 270375426, 2793019230, 304714534, 1585992009, 445066303, 884042704,\n                91232658, 1662385806, 4264570167, 3095721922, 978954050, 3444729637, 3666872358,\n                1511495455, 4122290371, 2375985997, 2310836319, 1572001398, 1452824364, 815272928,\n                360989272, 1472815262, 1183233980, 2693925021, 3070992885, 428567726, 1923132646,\n                870680902, 61334733, 4271169929, 1202450261, 3874156717, 3615524040, 445431985,\n                3669093913, 1422476991, 311965702, 1417684717, 1234301513, 1340738181, 2539564284,\n                1741389949, 532861019, 397460158, 1025691229, 348704568, 757498655, 1082072963,\n                2211584104, 4248378436, 581118102, 280058941, 2711609473, 1283305525, 1157715406,\n                4231811513, 2418383425, 1647805755, 3089074013, 4043454068, 2851114191, 3362588837,\n                48533473, 1297952280, 2283341403, 3894166150, 2375381028, 3154331156, 3834699351,\n                2961474424, 3395077458, 2479986544, 4021481315, 1360350208, 4027622151, 1889459682,\n                822951371, 2773824837, 2622968707, 1216338372, 1436799036, 228980341, 260550308,\n                3290695384, 1179830564, 713457843, 1961397091, 3022066718, 60400459, 710482200,\n                1326388333, 866098456, 988957043, 594546317, 112224322, 1686309163, 2673427515,\n                1480561387, 3719778253, 189373921, 740479302, 753019699, 2546788894, 1928428757,\n                3753951145, 1111306054, 1674018696, 1374154164, 66028805, 1169871060, 2942556110,\n                3383298011, 3948130716, 520357725, 3601036029, 2809274873, 1404107262, 2239311886,\n                2205203007, 1747688431, 1305067003, 2495767700, 3435341083, 744065202, 2893661505,\n                3631471766, 1348058193, 3290931841, 1783052691, 3545333754, 2885010405, 3015101869,\n                1816466873, 445215974, 55469969, 708427338, 2670076660, 2749713334, 600727729,\n                1015194815, 7563398, 3314338860, 626668465, 463724106, 843782950, 1440417991,\n                2606259873, 1072028034, 2814019719, 1373997202, 2666900010, 4176313376, 1576887401,\n                1887901460, 618965715, 3928901268, 2756253242, 908674445, 2783555991, 3145253475,\n                671884197, 2798251670, 610439611, 2479534986, 3193743292, 3016810470, 4116360208,\n                330168713, 1143619883, 2702848180, 3323979924, 251520862, 3080153930, 2721102100,\n                3645026600, 574398990, 2681106313, 2664633763, 3589752630, 1589507214, 4031662545,\n                1422801893, 677504516, 4032699133, 2580409667, 689884803, 4207215400, 2242741325,\n                1700880086, 18943211, 1186581791, 900206253, 2336736788, 79204608, 539780241,\n                636226674, 375779182, 4069215835, 1908716833, 379009447, 3605914215, 1522568903,\n                4040671234, 2120018121, 2114864129, 1357210322, 2711209295, 2241517755, 2299541072,\n                1003731941, 1285293545, 2895160814, 3448925696, 3014223150, 1986102505, 918021216,\n                1895559974, 2968756830, 1782617764, 3842402057, 506957063, 2794128870, 2723929084,\n                1790694617, 3819994108, 1796867407, 2348433259, 1855143178, 3340341657, 639892717,\n                2673209190, 1411690552, 79209238, 3485688689, 411330608, 1097436549, 3022819216,\n                3328590415, 2498382669, 2688145691, 2333608262, 2206781451, 1615021580, 3535503209,\n                188493173, 851224538, 2629538998, 3538694915, 3195915323, 2470454372, 2836404795,\n                3037684755, 2029634947, 2480471703, 4256103912, 1677074447, 3285177667, 2202069462,\n                3664482806, 133405527, 1619292952, 1179718513, 2810618561, 4147162567, 1990145900,\n                1418108687, 2801415083, 2141121066, 3043945114, 3424083024, 1845146157, 4014278960,\n                2690703066, 505360624, 1732127460, 562124320, 3526601753, 955179947, 3591457224,\n                679719161, 297241111, 4108320331, 864134418, 1333562459, 70858138, 2853172817,\n                1219721500, 1025014572, 3300750566, 2211754460, 991410483, 938799966, 2410403222,\n                442916956, 3350691005, 808760, 4130790737, 2746612085, 3276621096, 2647227164,\n                681856395, 1257288473, 1413712379, 1522258369, 3118343404, 2489706870, 1471908966,\n                2844043282, 1124423147, 3066981623, 594250653, 67819044, 526822929, 777003105,\n                50825748, 75903841, 1594424835, 793251734, 2458067235, 491807081, 3381117014,\n                1465584653, 2882491124, 3410605180, 827689385, 2357158234, 3863254832, 1910156500,\n                478425738, 434763393, 3130649408, 1557159391, 3192315391, 3648822439, 3820808146,\n                1252113848, 1395689995, 4291373887, 1333204702, 1522583226, 3077867787, 2132184325,\n                26511430, 2845341536, 2936737873, 1963433591, 584753689, 237431516, 1522453220,\n                86696668, 2754619137, 795919532, 2240162667, 2266874211, 597113619, 387562260,\n                2495984678, 3176140312, 3613000869, 3002833403, 2881801810, 1354059370, 472516870,\n                299801435, 1094226210, 3036033414, 3597911882, 1663838219, 4174262658, 3860098876,\n                177331920, 2980423231, 2241317010, 2236131872, 4009575873, 205213156, 2801357992,\n                1761279322, 291587360, 2857705814, 3265468724, 1333694034, 3153113696, 1981765837,\n                4180801648, 3177874603, 3419835662, 1422518551, 234578164, 3035560631, 2977642177,\n                2826017116, 693022312, 4002892189, 1984270335, 3966818281, 1449559836, 1580743741,\n                1221247885, 49265144, 237645723, 3688431518, 2644307901, 4247118948, 3711144286,\n                747817992, 608833440, 1520829247, 3824111021, 678228162, 810382036, 3825158806,\n                3989772169, 1237886049, 3067089131, 932255296, 3253516486, 3066949529, 2358323679,\n                1883424307, 3579121260, 326865116, 1470953433, 2483136260, 4202451688, 3199596490,\n                2860013262, 749139668, 3240279399, 3174098421, 1172311557, 2001947608, 3298861893,\n                3498198144, 2132465324, 1381243268, 72984231, 2119259388, 853533695, 1552099388, 1,\n            ],\n            &[\n                1048607726, 142412324, 3250800312, 1077166691, 3553793686, 4228441628, 3203079399,\n                1202791260, 799001727, 1030363239, 1081996306, 2584161993, 3105539669, 2513998685,\n                4130331711, 3550728490, 1554513655, 4178882888, 781786346, 2080285035, 2740757392,\n                539616476, 1486958112, 3986698615, 1921400669, 1147589945, 2901977179, 3882011895,\n                3184378754, 2895226410, 690455662, 1190546349, 2220742959, 2051575810, 540146951,\n                539062650, 2310850033, 1556710312, 2279375644, 3357053280, 1676861190, 131504401,\n                2967730434, 82164296, 3149325066, 3482489407, 817143551, 2015288431, 3228437308,\n                905767502, 3933983825, 2027435163, 1570365157, 3561664566, 3300012446, 3405843634,\n                2537652810, 1460717190, 1544462148, 529475468, 484660801, 2529788802, 4294022942,\n                2334555233, 872784994, 3455279604, 1035665898, 2101483995, 2171449070, 246721522,\n                2400142253, 4238880814, 819242783, 2258413710, 705995468, 271390846, 402766610,\n                3816209662, 2234701477, 2452466394, 4213942774, 3278770703, 3998052049, 439764839,\n                309852143, 3929931316, 1550731629, 2868770243, 2431523761, 488401131, 1370587819,\n                2557822445, 716319861, 2599351696, 2796412436, 3147432724, 2520879833, 144393128,\n                698522794, 2546333916, 627318794, 4246242694, 1220884539, 3346273775, 1071300069,\n                1601718155, 3760578403, 1426969773, 1627940230, 3747385244, 962484480, 1164046906,\n                2606826923, 1240876116, 1623862569, 2100011929, 1743793088, 995602808, 2769415714,\n                1252942287, 714554977, 2031164465, 2276588141, 3728901018, 122946257, 1858841224,\n                770012953, 1293680777, 1650616396, 788795923, 2897629253, 398117719, 1274119920,\n                2903266721, 1229746351, 1962723219, 3497182756, 2689318549, 1514884124, 428587693,\n                2594122257, 2255868181, 1213534981, 473438460, 3259926899, 784898828, 1740586706,\n                2493427182, 604737398, 2545731397, 661514446, 152703462, 4226882176, 2763904320,\n                3169889376, 3526208587, 3107915060, 3226820443, 4186456471, 3018794099, 523425582,\n                447127557, 3315536887, 2638060561, 4253140999, 2778958816, 136563180, 889096332,\n                2156297749, 2633584027, 1709332969, 3628824594, 2213804574, 1109051684, 3946712344,\n                1562010546, 732978546, 1769212829, 541807011, 2330452140, 1259982384, 4244981534,\n                1446677613, 1494947962, 1886609176, 1890798392, 1278248805, 2089372606, 1464145854,\n                243399923, 4211737502, 1818727317, 2988620475, 967898340, 1580663464, 2153157677,\n                1925889642, 3632162291, 141271097, 386524308, 2500718963, 482731158, 2062686924,\n                219086577, 3285135277, 629410216, 897503263, 3908515354, 1620444287, 2430031229,\n                934361166, 1796358719, 4124248671, 638890537, 1432980354, 3148696701, 67367302,\n                2623937754, 2612868021, 80761026, 1141232637, 3269660781, 1889586531, 3256841450,\n                2670581455, 3744999014, 2431354450, 2059640453, 1149532609, 3217977165, 4063910813,\n                2038505080, 477944338, 3867820883, 2041535667, 149604452, 2179375611, 153526327,\n                131491024, 280454069, 2548076235, 406520943, 2273013398, 1610586692, 136533182,\n                2579763983, 3505264999, 649562207, 2152208510, 4109589512, 913916439, 2770616731,\n                1104198273, 1202831344, 1255751355, 3447468228, 665264080, 477725270, 2692532968,\n                1870693866, 3851762774, 997405540, 2042036508, 3726396028, 1379580311, 2439697975,\n                345704789, 242944825, 1137146938, 988466318, 3882464952, 3107721748, 17414629,\n                1662467057, 1280533760, 812371865, 1883212013, 2434696745, 1223107282, 3596170173,\n                565858852, 536542408, 2433577281, 3132259324, 927119620, 1882095984, 2261424849,\n                2564496532, 806455696, 2635858001, 1840281829, 1429686119, 3246338601, 836772651,\n                1360857075, 2774016575, 4122295000, 1246981145, 3699426177, 4097010166, 2362501646,\n                3279563, 2709151847, 671939434, 2540411298, 1237267379, 1533499075, 1029636334,\n                3329917063, 3015797724, 241909419, 2435929696, 2196157828, 376150999, 2758243214,\n                609760865, 3449122098, 1743972313, 4091850250, 671738770, 2364789363, 1916675262,\n                304618359, 4119966810, 2850975933, 165283783, 686409432, 719782946, 3511536373,\n                3395113947, 3984649666, 1785678028, 265739219, 887986970, 2855120100, 3564162829,\n                268532078, 4139618232, 2400629035, 3035579533, 1697435623, 255084169, 1464704590,\n                1969412123, 1474218865, 1068169710, 1486590349, 3981484600, 574030985, 2187701187,\n                1896404752, 4221469159, 3433453595, 1136439656, 328113653, 2084810857, 509246959,\n                3940661151, 3802993380, 2825285631, 3972592023, 193253710, 1105971629, 1023278470,\n                2506284183, 705358340, 3886603586, 1357318457, 1425410849, 2872776361, 255660592,\n                1313207097, 3156112223, 2830882366, 694005909, 2906618499, 2520527692, 1449611271,\n                1849318233, 725033292, 2446520944, 2915986673, 2763045905, 2877683241, 1026458781,\n                615272660, 187420409, 943610851, 1812634652, 2273048325, 98138901, 2725026118,\n                2967557799, 3270136886, 2059346281, 322818454, 2229832363, 1421907280, 1790203450,\n                3309886466, 2218371394, 1723058643, 141062552, 2848609617, 3178614253, 3697309878,\n                2621643540, 3453793862, 4098981072, 1509842023, 669644032, 1780348545, 1347261194,\n                1942473489, 3177185986, 2974907342, 2498656520, 863579786, 534304671, 658990181,\n                3867449603, 2592395109, 2899904485, 24363917, 2582826966, 3202040405, 4276755802,\n                333639144, 1055214722, 2593914648, 4006021860, 1862629360, 1984390962, 941140443,\n                1975514676, 1444701897, 2077986133, 1321299657, 240670064, 1907831864, 3548899199,\n                3417333093, 93616467, 4042521537, 669172764, 1509883566, 1410028566, 2465323811,\n                1548825994, 3883910619, 3234661467, 3105117973, 4114740676, 3200175759, 2178246178,\n                633150960, 3955508938, 3460166584, 2110457566, 3753290715, 2770574241, 2049063426,\n                573027729, 4156077678, 1407126170, 216038396, 2102970600, 3194950401, 4017319979,\n                1291946975, 2300933104, 2099048635, 894312712, 1934513279, 2557556618, 3248883960,\n                260082879, 3059635004, 3069327264, 1714535246, 1831216556, 414921881, 3289293516,\n                944181322, 3925790739, 3359968475, 1846968300, 2609486679, 1850019504, 1944960161,\n                3750774956, 2296180799, 2486016936, 2570802263, 3691641463, 3848645994, 2487460912,\n                3997753905, 3027763387, 3960275222, 840918160, 743404502, 1575447943, 1886521982,\n                882571777, 3530937658, 2589305705, 2678878307, 1307010984, 1256181931, 55466926,\n                2188902026, 2395613978, 2514869503, 2982962505, 2054026528, 2157945040, 39790067,\n                2647728191, 570680119, 3483166779, 3446354771, 1333593377, 2251539900, 3433452892,\n                2268781405, 1187783236, 3432951380, 1296750451, 1842142891, 911250979, 2905313019,\n                247454604, 4158769786, 1283681216, 1339246742, 2404495800, 1902364864, 3144630274,\n                2371884247, 1665809985, 3444104202, 385659994, 657155685, 2255995967, 1905981216,\n                2736009248, 1428368476, 2624996710, 1145643837, 2786210682, 3485069535, 2999714050,\n                1002675335, 4174976414, 1248658090, 880109681, 3070247226, 66466048, 3111549103,\n                292579238, 339279340, 2344203213, 2176303622, 3906973220, 2905978660, 2190987192,\n                2594302473, 3664921655, 2097010421, 3960926873, 2179851435, 36046787, 3494331530,\n                1138328290, 100401628, 2319700689, 2151407026, 3811406180, 3438415433, 2827821485,\n                3243639281, 3556903243, 636198560, 4273411963, 3842446478, 4050639786, 2854770013,\n                1403448237, 1556407557, 3221360095, 1567961792, 37915355, 3857273364, 759462610,\n                1596782015, 3997591545, 2208738987, 3029977760, 248859738, 1283529230, 1415005957,\n                1972668381, 1136025839, 165926394, 427559678, 2587400498, 2049663228, 567766412,\n                3161812322, 2435932699, 2668793445, 1531281830, 3565406590, 3664348935, 2265420009,\n                3929560982, 142270226, 3509595350, 2352645495, 2905368949, 1049755192, 888023262,\n                2438967112, 4254921568, 3319930823, 3984992816, 2765963407, 2806247137, 178106618,\n                3411420675, 1286002529, 2982691785, 2873859269, 3369594395, 4167720102, 4143525238,\n                3717603632, 3191223634, 28203420, 775269803, 412179788, 1962047866, 1813776568,\n                733160490, 1545749793, 4068549595, 2389240832, 378753614, 4104045591, 3657852010,\n                874025036, 4056508979, 2951515898, 1124709994, 3783222963, 1012308188, 2229271510,\n                2219096628, 2458020702, 3621530574, 1080427507, 1517056900, 301884898, 1290494301,\n                4123182810, 4189508696, 3988834325, 3689801913, 513395950, 1744594764, 3290355805,\n                2403507478, 482652462, 2821811425, 993426434, 1014456377, 904787565, 440111472,\n                3902930297, 4142551056, 1591497191, 286221577, 2152371786, 996720255, 3895520923,\n                3985861127, 3251025271, 2700743537, 3239439576, 2969935613, 1691240642, 1493465575,\n                1053359537, 2355791459, 3910993255, 2403970629, 1187413316, 4240222384, 1371714172,\n                3965808637, 746046851, 1242409855, 1595856627, 3182235189, 2115649167, 3417666039,\n                2827475911, 3419665752, 2224557620, 1207076402, 2188810252, 2013649922, 1578650227,\n                3675331676, 1746814009, 994279655, 979461807, 2150039433, 1488417808, 410096171,\n                3115127198, 4205833441, 3149429906, 2331868780, 3732482276, 1317599654, 708995455,\n                3471263525, 2203689020, 3813526622, 57733901, 3221347386, 1875131483, 1871230123,\n                3503204429, 279302990, 1008515956, 2958288963, 3997438534, 2218418435, 3325971377,\n                1036477492, 1667373986, 2935447535, 3272214732, 1916937801, 3411973075, 190188148,\n                3259518452, 2744957335, 987959381, 2926241446, 4028119966, 2659487306, 2364177521,\n                1707356830, 924143357, 3495026759, 3224492066, 820998238, 521377600, 409920327,\n                3022575390, 3408451909, 2446120177, 253505828, 3013593681, 751866448, 459847293,\n                4151089466, 2734658906, 3628614093, 1204026156, 3836104854, 133921563, 1906374634,\n                13937476, 493403406, 900335320, 26546070, 1285100637, 854607887, 4109641695,\n                1398374294, 227160874, 799394835, 1021062743, 1106469748, 17498306, 1228416509,\n                941032865, 682571704, 2464984044, 2082388629, 1494996330, 3394857640, 244442806,\n                1377332949, 1391098255, 49637159, 571188827, 3707911702, 1723324451, 1643372792,\n                1140473043, 866463091, 653154991, 1297445690, 573376538, 3981781235, 3696912668,\n                565267791, 4185635602, 3480070858, 4050228235, 893269043, 2925165903, 3337269632,\n                1840579081, 2457286075, 744856935, 287770719, 2668837353, 991298351, 1967208622,\n                2418132114, 908335335, 890083308, 23221927, 2853213933, 807614974, 218855713,\n                1501222052, 2494434864, 3153286947, 2002393426, 1937810340, 2196991305, 1201314450,\n                3995545220, 2109262516, 2587798229, 1522992967, 3290897323, 2844799547, 2362679901,\n                2499652853, 236409787, 1821770534, 1385634971, 780550390, 1992356749, 361422561,\n                1911938329, 985103802, 2446932867, 1781316431, 2862433888, 1710440644, 1630007296,\n                3895088584, 2584069445, 4109526636, 1215052693, 1879156818, 2454307146, 2104746099,\n                4224392284, 286611992, 1778618995, 2141695259, 2711187183, 4257553041, 647228281,\n                1295156827, 1552913077, 213807527, 2252596158, 2051124395, 1241226424, 1140277576,\n                131906315, 1277450464, 3948826599, 1266865951, 2478887003, 2605897720, 1991636367,\n                2192624302, 1280448240, 194619382, 2005700446, 2926770241, 753480478, 603647115,\n                3213709892, 882887847, 1895753586, 1815651065, 2481200593, 2083558189, 3700353603,\n                3991937366, 619042791, 2825773803, 1041174867, 3851789531, 3214460859, 1140471650,\n                3196668456, 322856926, 1460664681, 2638812276, 3663403397, 398669302, 1037797389,\n                552494379, 2219226623, 1705521916, 27946460, 280394090, 3773459630, 1253024509,\n                2879489206, 1767188167, 916184538, 1199740381, 4263858782, 3986775882, 3044707269,\n                611283348, 1526180610, 195582791, 1730668165, 3073839585, 907890001, 2481144221,\n                3782885147, 217960406, 3054908023, 1837860495, 3848079760, 2917706776, 3944231881,\n                3086946659, 1791437342, 3605338932, 1949911356, 3711518847, 3125234193, 1241545832,\n                333629901, 1042934573, 2394347103, 2851879566, 1778541946, 2808769668, 3248943939,\n                2073787511, 247734098, 3837843645, 2171779606, 2141888351, 2575430218, 2166342642,\n                3714912603, 3024488117, 2290054554, 3394256909, 3083054909, 584692472, 4063088234,\n                2746953830, 3850784297, 3335013306, 3364320672, 1128684862, 4001742473, 1536088780,\n                4198240687, 1581849589, 2423268362, 3246412217, 1454863643, 1108610164, 3878934470,\n                38892282, 245169604, 1274726846, 3803493626, 1744937663, 103002740, 502054946,\n                1892247461, 2623709034, 3995377274, 3044743413, 3996081168, 772081511, 2286981943,\n                3068018767, 3983416027, 3641407152, 2757340837, 1836414225, 3244876917, 3573033415,\n                4138495962, 3311045110, 295783324, 173431332, 3611538103, 2361066151, 3015722298,\n                1343609822, 1282836993, 588785015, 1551804562, 120847676, 2210229385, 575857299,\n                4149396254, 885356301, 597576777, 3931353525, 1785590947, 1472332500, 2741133655,\n                3562427458, 2362380834, 2479477684, 4236191078, 1767966538, 4178971734, 2932483246,\n                2958030392, 4101226876, 3921481958, 633626263, 1769237825, 3533263201, 2143256898,\n                2215605389, 2895081471, 1728913742, 1805410928, 2970038245, 2463197162, 4200176957,\n                1564826577, 3267987851, 614250648, 3900292330, 1769065434, 4232208574, 3592015556,\n                144180881, 2509343022, 2439166937, 852496649, 826798105, 3564967947, 2918197096,\n                4059790058, 2255368011, 3523829294, 3319959687, 4156223144, 1133583449, 3454229874,\n                1557011911, 3458427548, 4230055622, 4190826337, 17883382, 124954346, 40987641,\n                3563510070, 1941316727, 1359068976, 2550479444, 627239665, 3063146127, 3351478702,\n                2504515151, 1068440347, 916246986, 720364258, 3947921413, 1150872866, 1875253368,\n                3832839852, 2778439355, 3289279511, 2889088515, 1856943409, 2903940647, 184310325,\n                3217001628, 319129082, 749624857, 1832240983, 2640398028, 860496046, 3522090122,\n                323134571, 3153179517, 3065488900, 1184373041, 3532771604, 2401547734, 3152768461,\n                1782533689, 234187710, 424333209, 722591632, 3763004948, 4153495192, 1728824235,\n                348843722, 308766489, 2093510996, 850299604, 4217675914, 2195899127, 256544001,\n                3226528914, 2962551672, 1328234458, 2986580052, 3233545816, 180971160, 419014901,\n                3912253012, 637008115, 1205945402, 1503804357, 4012660565, 4156469030, 2582083821,\n                199488563, 458440108, 2849662824, 2704948215, 795518706, 1000777821, 2004820266,\n                2822441063, 3764807805, 2681140792, 1491528833, 400635370, 3401974306, 1862815705,\n                2561957438, 2983350168, 3904191142, 146855111, 3927193381, 2731433733, 673747148,\n                3253050213, 4239533938, 4046300384, 63718730, 394253960, 28039621, 1200917690,\n                3116360994, 2676755349, 4241904784, 3959007578, 4031049777, 3202945405, 4122030991,\n                137424116, 1142687397, 338198709, 1594649019, 2508774575, 3211820212, 3002454781,\n                1566031505, 1916162942, 681747305, 200923992, 3809405102, 3721492621, 1786753592,\n                3227675559, 1213303313, 2346133839, 4242483508, 1977660151, 3145905223, 3492890380,\n                2021133693, 181054296, 4282292922, 1199764816, 2333541081, 4259709876, 769347186,\n                2399481048, 2778284357, 3762399931, 2234414972, 1839810677, 102290666, 4240663622,\n                2902993370, 2184365004, 3243124072, 3955281908, 2765439260, 2135672711, 2989999631,\n                3787014518, 614587906, 933777560, 3348884554, 3804856256, 2711182813, 1170529113,\n                368238835, 1773069460, 4229876441, 2594105862, 1075367781, 2216618737, 3125174865,\n                318524823, 1020662435, 2523775978, 3750101384, 3948363519, 3304724022, 664366799,\n                84875872, 4137905023, 4216040944, 771707291, 3135286886, 1079340376, 141842777,\n                1111481799, 1532734553, 1980818988, 3722270308, 1566396676, 1019009, 717064453,\n                3372969819, 506661632, 2063798179, 2423583087, 2656391525, 1630100941, 2479950284,\n                3657991172, 2371699826, 4199252741, 2521889397, 3324104671, 443020662, 2271816278,\n                3749381900, 554658420, 2887078027, 1375538749, 2337582266, 756385786, 1104904157,\n                628107957, 3929401682, 2450090419, 157294829, 1993439139, 220713980, 3472905742,\n                3113447906, 467991303, 3249685152, 1191502788, 1643194722, 66946652, 3325985891,\n                3655086037, 589852547, 4114108739, 3474857286, 2212167498, 518108528, 1061202903,\n                1834419839, 3515790230, 432023349, 1792804209, 1376908486, 2799134354, 407169155,\n                3760230799, 31952730, 4237093098, 559932983, 338621103, 2777797418, 1176552774,\n                1043376225, 40393076, 1543484797, 2835954021, 4280169740, 2726285215, 678780856,\n                2234240248, 4106921813, 3468591277, 2347844488, 1286704498, 693550934, 636005574,\n                562601422, 3806801557, 518760153, 805523449, 1807233646, 2340277386, 1764245323,\n                3893899160, 732166191, 1519923334, 2287823447, 1847983638, 2757449629, 1627605149,\n                3249509794, 1248043307, 16594694, 680804929, 4087351011, 1788938681, 3636487025,\n                801119410, 3000953659, 191016393, 564779703, 2567794023, 4235935246, 130144285,\n                1612660013, 400272330, 1080646757, 3775916055, 960046260, 1380362532, 3441542350,\n                3252871445, 2045998548, 1475566564, 1155903948, 1551712446, 3407113964, 1992638852,\n                1950218946, 1565489847, 2819274347, 1167904963, 4156357668, 3889678881, 861634597,\n                1177972497, 3769153896, 1764256941, 2735480696, 3045090663, 506102454, 2207236307,\n                4179160848, 736180119, 1105109838, 1816897482, 3650337200, 3399862146, 3877657330,\n                807392854, 1903312622, 876336464, 60413064, 2629999006, 4052780402, 3804059563,\n                3805986115, 2325037255, 236398700, 2898403681, 193636779, 2977069801, 666013355,\n                47616353, 749954976, 4048172198, 2782182603, 366812230, 1865894290, 2548867210,\n                3803685394, 4266343191, 805883814, 3771810872, 2276556842, 2489193099, 1813625903,\n                2150529688, 1552801160, 2887420624, 1604048554, 2450479040, 3827176094, 1896156795,\n                2478871586, 118817859, 1361329827, 2990876811, 505801955, 2238407528, 2761195506,\n                750435627, 2441696264, 4186437002, 672360518, 3949971889, 3634836549, 777538567,\n                2152384322, 1347995475, 966537071, 2192031274, 454113577, 1831918275, 72945292,\n                2134532522, 806000481, 3391255587, 2601288989, 2375000414, 1984718442, 2766094083,\n                2871392044, 2908879884, 3206209067, 2495491120, 695154173, 2275211574, 2648325390,\n                2042875058, 4184470059, 205717683, 2549735036, 4142739910, 3226096901, 784305247,\n                2643409298, 3940551169, 799181258, 2278468111, 1262890692, 1810968035, 4230881612,\n                4010863801, 1310173617, 1877791166, 3392974657, 3310629609, 1294111179, 1691717910,\n                2243195728, 201100405, 1860817865, 3992517629, 2110903561, 1072241403, 2490794850,\n                2657190577, 491600738, 2738950799, 721276717, 4115495505, 1249753963, 733586712,\n                3785610108, 3531709114, 1092285370, 2483693547, 2377719792, 2530971004, 654112433,\n                1370215652, 3194499974, 971522642, 4288355310, 4153013974, 1073702593, 1588497013,\n                3931168881, 2297644577, 1971171469, 3526077049, 653418467, 1184518933, 3903410468,\n                1431385791, 2135588004, 3746548756, 1300360760, 2983521883, 3680677366, 1114764921,\n                2067504244, 4037354341, 1328353836, 3681470518, 1296904099, 897792099, 3889325469,\n                1620581231, 1057101059, 2623957214, 1416465790, 2321249288, 600221944, 745706052,\n                2884744632, 725459359, 2151136086, 1022690555, 2101534544, 4235991561, 2526289534,\n                4090433148, 3414669915, 994816426, 3364509792, 1685851067, 916262427, 2653730670,\n                4107563285, 492616131, 4213854692, 2383881706, 4072301786, 2768754227, 268515465,\n                315313193, 836553593, 2730985350, 2073139965, 2398076251, 558256342, 1788344547,\n                2984051379, 4109409395, 3614988625, 1956541383, 1880479368, 3202603508, 1425106476,\n                2480560240, 304989404, 4139136237, 307799893, 2298991754, 114036851, 1259328780,\n                4262189101, 2653754063, 1502449452, 3375251268, 2192199048, 3791883037, 2668934777,\n                1425476067, 4049800425, 1668283262, 2667327420, 2933151991, 4019716343, 2330828453,\n                3498211009, 3769685326, 3264444082, 2991844381, 2321900855, 117851441, 842442946,\n                2118410931, 3143493727, 2344874932, 3816911655, 4211335525, 3674661885, 1221645719,\n                4096136746, 3067959751, 3886517668, 474527889, 13436509, 556504311, 2037544501,\n                768123789, 3109215060, 2111841029, 4066422103, 2509393756, 2613607688, 1934939639,\n                804143648, 979630044, 3032976830, 1789262393, 3800185863, 1684588922, 2856996817,\n                3980253276, 3747721886, 2040009573, 3786938617, 4184189589, 2909473305, 4005326975,\n                169151147, 3555459784, 1680052614, 357068529, 3902867798, 4134705630, 2460264703,\n                3446281088, 2506686175, 2140253907, 2524031008, 3748672241, 2637079427, 596462645,\n                1756428494, 4079242605, 2154048804, 583321194, 3323589816, 435553745, 985041064,\n                2207815591, 1541521937, 3977646346, 1466656860, 1701122017, 370668095, 856054136,\n                983678454, 1869763666, 2906502004, 3590037337, 3674457348, 4190173453, 840012341,\n                3173978322, 2071940589, 3907580805, 1066268792, 624296315, 1619840813, 4184498156,\n                2417585810, 313712078, 2648134631, 3458957331, 25928886, 1616655447, 1597586003,\n                2422906806, 3753518055, 1382145270, 2264934263, 693781264, 1245009193, 208844628,\n                1626364957, 1570465417, 2904762226, 2704404565, 2698439442, 838859405, 681405606,\n                3270592794, 114323964, 463704433, 3008664129, 112133631, 2466737566, 99913252,\n                3107521111, 2967401892, 3610987977, 2746833516, 278618614, 24782692, 4186221509,\n                184204380, 1132823616, 2205467018, 1963448884, 1793230230, 3245502016, 2062710723,\n                3289617322, 2424440484, 2687983608, 3112733899, 3238195835, 2191413483, 2942981831,\n                2468923457, 109598858, 1921003506, 1867451786, 2069725403, 1789618297, 1332853677,\n                1255099134, 1845389783, 1380514769, 221106554, 1417110717, 4271433429, 2613671844,\n                4283741954, 1039802998, 3530487181, 2813442650, 2933398011, 4213197108, 4038929941,\n                146649145, 1889293476, 2479307454, 2210098336, 3439692794, 1655802607, 4247139691,\n                1694322066, 1779056134, 34699089, 3358014766, 3795933745, 1652860608, 1013413276,\n                3660600634, 554286455, 377171445, 3694311441, 1362736640, 2317624482, 2105488535,\n                3907800383, 2739752543, 659143664, 1266278408, 14379155, 2842357425, 3578153666,\n                1210028003, 2292709595, 2461065183, 1060627985, 1916482582, 2047777944, 374805563,\n                2855466869, 2243765299, 88602660, 1309015120, 1794831005, 3217210436, 575982793,\n                146096222, 4183228001, 50568213, 1080395281, 3719456079, 4174019042, 2836192500,\n                1028264017, 1563161897, 3153715814, 20965921, 1786764091, 2068658040, 334984384,\n                672639999, 1795028197, 3479475131, 2410760560, 717812557, 2347632908, 1700901001,\n                3001721233, 3310592578, 16086271, 3774008122, 3689378213, 1885471476, 2901220836,\n                1715551356, 1893280548, 3286583788, 553079801, 2351975790, 490104937, 4090146754,\n                634172285, 256165689, 2147466137, 2413755525, 4149288700, 1840031596, 588585345,\n                933371499, 151941262, 2291598029, 1558175109, 2205961485, 3279743313, 662618489,\n                928026255, 2315088032, 2393177614, 1975851571, 251169825, 2844282749, 1577745923,\n                3717002386, 1306224863, 3095824220, 100258507, 1043298283, 762332010, 3662156511,\n                324729017, 3173025242, 3018005111, 226292042, 3693510184, 1551950805, 4270336845,\n                414941324, 59765929, 1409167125, 628242312, 504567837, 2654788266, 1503480310,\n                3757851583, 3647297321, 618810458, 298766937, 145543352, 972529625, 4006011378,\n                3902655343, 1704213062, 4277457734, 584553954, 369288135, 2377121631, 1596097246,\n                3974978658, 216680729, 3946882169, 3632432957, 202232795, 3398084585, 3713222132,\n                1288467794, 1142439074, 2360536800, 4151455478, 1088521481, 1195327196, 1602839012,\n                2953796466, 1815602329, 3514635026, 1774774321, 2374040735, 1925157728, 2332391415,\n                1234977504, 1381581253, 903985422, 971877975, 1392602998, 454395919, 2045134551,\n                316284213, 2190742535, 2783640915, 3239126304, 3543417906, 149651663, 2439212212,\n                476510431, 106147908, 1640247147, 3589889334, 1703804993, 4113626973, 1918936481,\n                1562421946, 1146941118, 3775194923, 418383335, 3871173886, 4179550043, 405447285,\n                1012425284, 2303549182, 2892019780, 2729667706, 4078173312, 2470025705, 1324397742,\n                2828838965, 2935720150, 2238693574, 867355806, 2193601218, 3280892195, 2247553430,\n                3448996084, 1655942402, 3680936068, 67725183, 3204263936, 3043409732, 3955540766,\n                415375390, 1755128377, 2528734418, 1792464404, 3184424158, 643865569, 1862465812,\n                2090335917, 2707692972, 1217649324, 3993780143, 3619942265, 3501265789, 2221019617,\n                56988249, 3012876501, 392522600, 2001797432, 1047913195, 1537292461, 2680755293,\n                428657196, 3198027984, 4204053927, 2454206119, 2689406141, 4005981783, 2006813447,\n                324015368, 1364194912, 2619685538, 2444093870, 3849270705, 1627584507, 816114131,\n                1219945742, 2158042708, 1023080013, 3749899796, 217196112, 2556865648, 1040004967,\n                3669140364, 2162023748, 2793508972, 685969446, 3839946268, 4095529400, 1044010880,\n                236277423, 2028710759, 3540673645, 1266224279, 395323073, 3682742496, 1996225489,\n                426996724, 500059552, 3026743941, 1686345089, 1811167335, 4133545193, 577693922,\n                1681085597, 2863808567, 1972726650, 791532555, 3060621312, 1042840997, 4186315276,\n                2615862938, 3318562748, 3816578039, 3857359734, 3632212033, 2247534109, 2184530934,\n                2472630317, 1558485216, 859102614, 2048162191, 825356872, 359544751, 3403239469,\n                674674212, 1957563770, 1296318164, 1266552461, 2160687728, 3335753693, 3432986702,\n                1230729674, 4159438343, 2912873721, 3848793786, 991531769, 3058585677, 52710525,\n                697741785, 785232610, 3294858478, 3011485669, 3475026752, 2238609462, 577017207,\n                1478684897, 629526962, 3367047382, 408605384, 3419371293, 3731500720, 2411014418,\n                1074468417, 2147325269, 387968308, 1878764768, 2912609159, 3000669691, 2205894515,\n                1726031277, 3862581587, 654428449, 1435491333, 1982567117, 883646517, 1213287163,\n                422593417, 3148866580, 440528113, 2604566415, 960194632, 1054708709, 2281968814,\n                2178014147, 119455690, 2805298477, 2276632809, 3157907488, 3604132410, 1300852807,\n                964851233, 483630605, 634097080, 3815600057, 359410053, 1801332993, 3396608815,\n                2035465575, 3693605339, 2260082808, 3768318407, 456831610, 1784896347, 1993961602,\n                3367680195, 2925998416, 1692304064, 4017997519, 988139663, 1172195776, 677056045,\n                2996742609, 1817105632, 2206587093, 1339440427, 3115619024, 2137452547, 2583411781,\n                531984158, 2972052723, 1119548166, 2552741930, 1740178731, 3414605445, 2304800008,\n                843429176, 1687215212, 2348034820, 3585915064, 2116619858, 2939781180, 12638302,\n                2015346190, 3310257159, 3812182659, 1929038994, 392010725, 2816962432, 365845012,\n                1966332800, 2331495590, 3282664549, 1565343709, 720795201, 274820494, 2573327352,\n                834206249, 2120328806, 2122466443, 3552259992, 319200107, 1887946580, 3275565177,\n                2214525605, 738814547, 928993058, 3139215937, 89284281, 3595637762, 1784520615,\n                1659233101, 1538260873, 2962979310, 3313688954, 2626898666, 3733084731, 770537802,\n                533232722, 2624520459, 2254466625, 2000199242, 2850289393, 3581680978, 1306543443,\n                2731694315, 4214864861, 987449903, 1337556927, 971618652, 562554112, 933714896,\n                3365336106, 3022295433, 2393633675, 426316712, 1945028387, 1347027978, 2736909937,\n                2134829411, 73979674, 55019955, 2012450470, 2348886159, 3424147355, 2447440437,\n                3161600497, 3157707664, 4219238506, 2297279601, 2411947365, 1714194929, 2466112961,\n                1223895820, 1852439360, 2900645877, 2372468244, 2993491906, 4140450304, 3289653733,\n                78074619, 1860352651, 2471757345, 1742864175, 2860681391, 283215926, 2730553569,\n                3695205783, 2508794543, 2898776688, 2440433292, 369374088, 2520129209, 1297447417,\n                4085044427, 454499846, 3776430362, 4048231919, 2078269113, 447150081, 502285383,\n                1290765738, 666955917, 1496143525, 3095658311, 1004015786, 3902083656, 608537333,\n                2570742756, 894957982, 2920024516, 2030269977, 4168722532, 2901933123, 2799872620,\n                2444444753, 3445465651, 826603018, 446153324, 3203157537, 2506406304, 223810067,\n                759136959, 2868603029, 4122642584, 715786506, 339816921, 3558811374, 246428935,\n                655313389, 1964431859, 3727543494, 4131082215, 3514937976, 389882274, 2108836808,\n                686658518, 247041449, 1580425893, 3619334465, 38297597, 2623967825, 256196002,\n                950708889, 1604756990, 2284090906, 2764905572, 3243572005, 91323796, 2372081166,\n                971118391, 3223082462, 3657959176, 3916088510, 876198567, 532411151, 1245822880,\n                2967282993, 3683945008, 2604865059, 1312816639, 1526063192, 3709858508, 541160516,\n                887438549, 1605566680, 316061163, 2717518136, 3202624914, 4286142265, 37932352,\n                2280000189, 3574083833, 616660103, 186007304, 3579480040, 4172855165, 3061121219,\n                2664433865, 582225734, 1498440115, 954466500, 1740424462, 3094153782, 1187633960,\n                2178324759, 3721660768, 1980280304, 3918075453, 2854136894, 3035212071, 369889928,\n                3318180449, 3880555344, 1741811985, 3111529874, 4063756931, 3492254213, 1485092366,\n                3763735860, 2363926030, 2981956449, 2849831138, 2025730596, 3905485701, 470980499,\n                962666217, 3549434234, 2940438956, 1300471200, 335327941, 130508638, 3084917853,\n                3243225177, 4225033895, 1685117220, 1103258167, 310727863, 3731698514, 110353031,\n                2677159441, 262645976, 69502397, 4142500369, 44273624, 2561626371, 4055984328,\n                2458564605, 1160926149, 2336828638, 3658545338, 2209496238, 2501847046, 4149648788,\n                1804898244, 3203259142, 995640966, 4111713010, 4256965601, 889096426, 2046359378,\n                2387978410, 4130716718, 2095157696, 1961147811, 1960183532, 164838879, 3444405849,\n                626148875, 2952415260, 1533519138, 4277482566, 1223727646, 1200427663, 4017440522,\n                2188055283, 1634298257, 3459215521, 492491429, 596752184, 3072588207, 3843332436,\n                773938296, 2593034010, 1097064791, 1915293085, 2209596761, 4254557865, 1433887599,\n                2099572369, 3884213536, 2359656999, 3115513575, 3851397787, 1765911954, 3275173333,\n                1722769015, 3454767171, 3918573616, 216313730, 3949302453, 3200254389, 229916177,\n                1121204461, 1330735176, 1717289746, 3668412925, 1644023445, 2283088904, 3557171827,\n                3056900036, 1778244577, 3595924212, 872667586, 1197158642, 3234491598, 172146091,\n                2014705894, 33279590, 571001578, 1948965857, 3009595051, 1556760510, 453148385,\n                1675972822, 366761520, 798807211, 1232401108, 3040172477, 2170351532, 3569675569,\n                2417102923, 1019261436, 2683810943, 2344308389, 3194319863, 2577226907, 3703945667,\n                3111376847, 1317654146, 2148638525, 996159628, 844072733, 307958944, 105943548,\n                2007781657, 1588114, 2750589103, 1746465119, 4239391159, 129209852, 4127384176,\n                3908370239, 3051559082, 300427753, 1527209534, 441877589, 3777172921, 3682277937,\n                2578951337, 952723401, 1638973752, 657222197, 950982327, 765295671, 3922241689,\n                3339076687, 1140001630, 1375537922, 1377470415, 400397279, 2079788604, 2709952526,\n                2379097212, 896580422, 3779262114, 1279325572, 4266133362, 879053306, 2465184182,\n                3704483987, 4247230526, 2678554635, 1492996125, 3718393868, 1621062588, 2593729831,\n                3561472420, 3167586565, 4199345398, 2367889564, 2725438277, 4029056280, 57956979,\n                2113392763, 1834941097, 725273836, 3435290245, 1221495376, 3829652832, 3742636942,\n                357848024, 3791413177, 3966631496, 2287469375, 3008002390, 1748658003, 3237163429,\n                1159572541, 4048446324, 508643870, 2672687864, 1607401925, 1147147667, 2055873100,\n                2662684175, 114519117, 2740281092, 1088299689, 3656675431, 3317348295, 2239055466,\n                2786446378, 2177806798, 4081920224, 4036375509, 1379076356, 475411811, 3480425274,\n                3096540510, 1246069411, 2552543737, 3691125098, 3708761388, 647070382, 3654474345,\n                895508246, 3821094606, 685711293, 3433236794, 280551223, 2253092286, 465155427,\n                51156263, 3598662025, 779787368, 4008704214, 1285583345, 4024712339, 3656160558,\n                1874433302, 1646839208, 844610019, 1878842109, 3645139659, 946453509, 1461659014,\n                91586562, 3498886254, 3283439756, 3971699775, 2305270524, 4201973861, 2289308009,\n                1198674110, 1918349466, 195525652, 2140360410, 1721981151, 2408926798, 1425931703,\n                1217754763, 1219341160, 781018523, 692209302, 1091974787, 496031969, 3730567525,\n                2722454404, 2962379865, 3238697411, 380426314, 198771613, 3672237099, 1881647940,\n                400688324, 3086010163, 3001448434, 85789128, 3786848369, 1282699876, 3111531037,\n                1466042151, 404041098, 2846201024, 265539915, 3126668874, 3510276810, 594380959,\n                2471268617, 3517102299, 3207314782, 1103070659, 1412524949, 100266650, 331188293,\n                1432143322, 3556739414, 1568633613, 2607329227, 2205653840, 1127637801, 2157182903,\n                1977783564, 2579631731, 1807013737, 362289356, 4245038233, 2412483343, 2562775465,\n                1025258397, 1322639906, 4078999618, 2646473383, 3694773355, 1504919321, 2785506462,\n                2052914740, 2141266707, 878037524, 3969401813, 3566092309, 3888635284, 2553979069,\n                4209191456, 2295889100, 666961337, 4037948352, 4250228512, 1973928677, 826541289,\n                2635094545, 10,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - d_len > 2\n        // - adjusted_n_len >= 2 * d_len\n        // - bits == 0 in limbs_div_mod_unbalanced\n        // - Schoolbook condition in limbs_div_mod_unbalanced\n        // - bits == 0 and Schoolbook condition in limbs_div_mod_unbalanced\n        test(\n            &[10; 17],\n            &[10; 17],\n            &[\n                9995257893114397114,\n                9401504468144459131,\n                558615837638945228,\n                10733662027974786928,\n                18295107704289976677,\n                1814706268673753787,\n                12474943759854623335,\n                8814778832826774208,\n                9159057654048965906,\n                4451260977376821357,\n                18241701617364042056,\n                6169989192350218482,\n                15071965537117101028,\n                13509168527678537782,\n                12224278653171635329,\n                16077066393714953826,\n                1433938684868066489,\n                13014970036232570373,\n                899282336249563956,\n                3089487642230339536,\n                3787737519477527148,\n                16667686214395942740,\n                8787122953224574943,\n                7841835218775877827,\n                9693303502025838409,\n                16122224776459879427,\n                144327425397945219,\n            ],\n            &[\n                2350654041004706911,\n                7834348511584604247,\n                12756796070221345724,\n                3842923787777653903,\n                12373799197090248752,\n                9712029403347085570,\n                1426676505264168302,\n                10586232903332693517,\n                8387833601131974459,\n                6290888746273553243,\n                9503969704425173615,\n            ],\n            &[\n                89235393247566392,\n                5198286616477507104,\n                15671556528191444298,\n                6642842185819876016,\n                1703950202232719208,\n                6620591674460885314,\n                9897211438557358662,\n                12382449603707212210,\n                13586842887558233290,\n                11884313943008627054,\n                3205830138969300059,\n                4257812936318957065,\n                11084100237971796628,\n                13937343901544333624,\n                11743372027422931451,\n                280132530083052382,\n                0,\n            ],\n            &[\n                12688955427180652274,\n                7641660693922643933,\n                8789985477567049482,\n                5698832637416200787,\n                14684840547760545685,\n                2822100467869581421,\n                3557573565928866957,\n                4409631974409684922,\n                16994214656621423610,\n                4513108841166793667,\n                9009005527785483287,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n            ],\n        );\n        test(\n            &[10; 3],\n            &[10; 23],\n            &[\n                748159237152854524,\n                14199895651244313572,\n                9044210482484213648,\n                3880401870711113518,\n                1694971440240542063,\n                13547801197479934494,\n                5244069077418598572,\n                17329479401291658084,\n                12613311850003558282,\n                5618071535926791206,\n                16954511293879569524,\n                8600749590433482901,\n                11708546551548237376,\n                10879843710159659952,\n                9101678715417935644,\n                12126242459863584426,\n                17259866272884195621,\n                4418382641453775715,\n                542305129955142216,\n                6563442437678466173,\n                12794875758080454756,\n                7461769876910639905,\n                17925257245127463276,\n                5137728719899113924,\n                12905981752247605071,\n            ],\n            &[\n                2654882163556630563,\n                2047318842992691178,\n                17944530594807555614,\n                17278864523505748498,\n                1160166728089482341,\n                18368953657130322418,\n                3937719995815345698,\n                12007028340444721520,\n                1496744539933999053,\n                1476923054783110845,\n                6551619938265612084,\n                16801911333947266527,\n                13986495313155597995,\n                6571595571877061463,\n                10140569634762389822,\n                16210530410764331582,\n                15172903143228403872,\n                5831780706385794192,\n                12288937301416472500,\n                16224579586702000460,\n                14545605105156691376,\n                8614987803254853144,\n                16629891239728134900,\n            ],\n            &[17831022488782895576, 14315989140983049585, 0],\n            &[\n                18140975738986113396,\n                16765596268029991308,\n                14497740378349400824,\n                8834432760455669008,\n                2081502095596466916,\n                16785570606386467383,\n                5299348241512211807,\n                17503170383548190207,\n                16775442261989831354,\n                8131705923782084593,\n                266320274487676679,\n                6602256474512308593,\n                2102043233085822823,\n                11614561527212258722,\n                17915538208051341722,\n                5710195504177465517,\n                2094480568485157388,\n                14339014023087152780,\n                6947889352398323832,\n                10985139413433625547,\n                12373170520775701923,\n                9198039438688117621,\n                15475638737141339650,\n            ],\n        );\n        test(\n            &[10; 60],\n            &[10; 56],\n            &[\n                14660214196707223375,\n                14265972253040120215,\n                15506320303100465818,\n                17085621003033826581,\n                11203337550022453944,\n                15493204961705835371,\n                5803021083410871755,\n                8112917457002746745,\n                12663484193891261040,\n                1721048899893287199,\n                8062187621610464306,\n                13431761655884620090,\n                7331427712144411262,\n                3626934647030185267,\n                13231383914073320042,\n                11637171044660683638,\n                15189928975258171045,\n                941827519265124224,\n                2992792486091076914,\n                2044203374633195985,\n                8310380355675814732,\n                1677894573715118386,\n                1863631713396879617,\n                13750903464355877990,\n                13561054993991137710,\n                6643134394212488277,\n                9782189322903525535,\n                7987880548748269544,\n                17396502810230452231,\n                9355336424066456608,\n                6974435047841500624,\n                4695995454788932008,\n                9790410161672155866,\n                7324176676989916049,\n                14873447357313289350,\n                17933513319573948354,\n                16221633809094225356,\n                1119296061370324791,\n                13659405622992751643,\n                10536448431317839371,\n                15771892335411705715,\n                6450515195565208913,\n                12583173873673842188,\n                8943105588740166659,\n                16781237121411387206,\n                7355272525679995848,\n                8924936502454129260,\n                9464007023044637842,\n                2392086820925613645,\n                6952992660961663836,\n                15709161892606831425,\n                15961199354349516091,\n                8170938350051511007,\n                10106337242460916657,\n                4519632767875399815,\n                13966478644099829332,\n                18146666299243951179,\n                18001892575388798951,\n                17442461326088111501,\n                12996149925790510613,\n                15125238000270787220,\n                13458137050174539117,\n                7565676737178758148,\n                7820895745333505106,\n                18391820881894926862,\n                17227107494212736312,\n                16170524482788524562,\n                18292226432698054709,\n                16409124153431213414,\n                2622798522164114141,\n                2030148142272451724,\n                12631034221630749586,\n                12521714531249855181,\n                4869764655816857917,\n                18312880399388298885,\n                1881841240505020002,\n                16686085102712131293,\n                1638984612454565124,\n                5980766772519196081,\n                14473546029553426533,\n                2610255570241349719,\n                4121823778233332328,\n                15196027812344512481,\n                17634932614139407184,\n                14566629132274047837,\n                6629067916649366603,\n                39453246491293667,\n                4118307938296638515,\n                176389639877922730,\n                2385844666265721927,\n                14424300909552701177,\n                2596064544694255252,\n                9262830285738421829,\n                8366979142044016136,\n                12451088247268499723,\n                16456341544263224076,\n                405434591376297036,\n                5989071471671786526,\n                17922319711997177283,\n                12402685985480014221,\n                11440567647536028583,\n                17109382986734751589,\n                1165111999013207871,\n                9042409351611763515,\n                335396288523389342,\n                6889397323074150916,\n                13998858741906849976,\n                15927944587197048898,\n                10995067153735213576,\n                13255077995174337515,\n                11985913648073551062,\n                16606199253171990948,\n                16615211378568935152,\n                13000672060735124358,\n            ],\n            &[\n                6726150808576237754,\n                9590776370558469124,\n                4613857594775205869,\n                5605914158178321857,\n                12627075307783464761,\n                456502911636413728,\n                6201419543988208076,\n                12457367465345491402,\n                9194484469177303126,\n                14469237774454463326,\n                8872571916644400618,\n                10371861714649740250,\n                9551882050917532587,\n                1418647961867356190,\n                11742587182398063873,\n                11015016132415914044,\n                8777839015232205587,\n                11080046461630228193,\n                13740325869131645472,\n                17716201322003396844,\n                2184375889136968144,\n                2744007897878529583,\n                10107840174031679018,\n                6807210551800087042,\n                3927845063936277496,\n                4657264236265855475,\n                18202437017170404187,\n                5332422779150911238,\n                15515262280249200267,\n                248667350560422394,\n                3473467338029486524,\n                5450666559053310869,\n                9114347711968955703,\n                1001965327187909086,\n                9391480248060184246,\n                9069754537718985217,\n                6108113375902101471,\n                615335597740998377,\n                7341924484422171664,\n                7557688311245960406,\n                10629369615492290302,\n                6551022068682485711,\n                13009629572214277263,\n                9801266711191462998,\n                12475469715378400041,\n                16817728089246511388,\n                5318131496704799888,\n                14034696640350324685,\n                173195053797772988,\n                9465580662794117123,\n                9395502290798332505,\n                172507413604644051,\n                13462235362634225088,\n                9267822876689174860,\n                12978933587961252639,\n            ],\n            &[\n                12372756710207599663,\n                9737052986771636298,\n                16735862446672978006,\n                1139195382411501599,\n                4025384807176208306,\n                10128156782936698507,\n                7100085357301525578,\n                10639782880668134749,\n                3972383448210895518,\n                16316091826865092258,\n                14638110565144662169,\n                17027377005940147919,\n                1984424298563015784,\n                10943215534705396352,\n                4761407742818533080,\n                536799158643182373,\n                3577912885973196462,\n                8426618872156874849,\n                13718975316423099691,\n                9890119685862829437,\n                1661366149680121631,\n                18221664832966866708,\n                1501909944594354041,\n                15664453277583965124,\n                3204453056814894230,\n                11234664797845870989,\n                865170089562739167,\n                15036893469165510103,\n                9555056751383235767,\n                10793253279766963078,\n                10975966662822330260,\n                6344197561810800775,\n                10052816891387114632,\n                5489737378772055553,\n                3577007843046523907,\n                5025363426761413084,\n                11669827237042875622,\n                15298941946562692234,\n                5287362685718508737,\n                14167437013528222514,\n                108442285706035530,\n                12321077902001896155,\n                4987860952577552150,\n                4822344167562733502,\n                5046873607058225743,\n                15023457088946801127,\n                10073890866526654379,\n                9395914048369797781,\n                12331509678230261831,\n                4207910636930067124,\n                13640015182632895728,\n                16512336849198622133,\n                750194286339711619,\n                3343827571253159031,\n                1179021970615059386,\n                9309853498190567264,\n                8323638524074867625,\n                2319424490723820181,\n                30896532530597901,\n                1,\n            ],\n            &[\n                16979197013852036393,\n                4534519222829727882,\n                5127955051936920534,\n                5669732551578654322,\n                13787946500638697314,\n                2666880029397285003,\n                18286001525339884787,\n                3747928243980886079,\n                5670276194023029484,\n                15201258611907138387,\n                6046915833599742673,\n                13282924752646783062,\n                18026143804639821221,\n                10186643213552896189,\n                17209309200088910354,\n                13215180252119768256,\n                1246399679408038126,\n                4186715523775575401,\n                16756959752065842207,\n                6600048850655585015,\n                4543693866439677976,\n                15594233518271892275,\n                15247811862837572166,\n                6322126320582019533,\n                649809830609098083,\n                5229876751712742127,\n                17719948521867410031,\n                10737539927122287433,\n                12476905306147178753,\n                1539850235988803702,\n                13572545877865905325,\n                11163694899331373883,\n                7882148214994127637,\n                8164419266634080608,\n                5782587821804107698,\n                12155391719814216620,\n                8020222143449740150,\n                8489927257914490530,\n                15688922762526028920,\n                207673185831465902,\n                13825819490340731785,\n                14207999229863934400,\n                10163751595898713958,\n                17777080404153962435,\n                17016927136773389232,\n                3820023214020965653,\n                1892439588667561762,\n                16909683715900311832,\n                11919385779232783009,\n                11201007117990222527,\n                8700983269916503928,\n                5034192113764375450,\n                12790439085134048151,\n                17790018876931315900,\n                5953092655978688336,\n                10,\n            ],\n        );\n        test(\n            &[0; 2672],\n            &[0; 1031],\n            &[\n                18285600144381611747,\n                2607658718107379546,\n                9747604544742966856,\n                2960103437306950033,\n                11333576199308712527,\n                14238003202284088532,\n                16265332193148604979,\n                1379942304307770309,\n                16938783330207677640,\n                2745252988447228002,\n                6791234087903673829,\n                12518174636027607009,\n                15674280970395865818,\n                13974288954585950791,\n                14841204964098561443,\n                8748517132169388864,\n                17525897240098709564,\n                16349048229068678114,\n                17968982428715890523,\n                9358013674764648602,\n                5199229606169954727,\n                422943872008603371,\n                9250194632016078797,\n                10021555560097390790,\n                2684614891063859627,\n                7440654004485895845,\n                15497536988658560429,\n                16091759101488274182,\n                7624403524401510649,\n                10159556756468762769,\n                2567573898157529790,\n                15609657766585643253,\n                16236943306986434793,\n                5890548198293774422,\n                17362921261219419202,\n                2808858681174890249,\n                6640440299319480962,\n                4326748503634915406,\n                11456055721778818238,\n                10707187402450482341,\n                10505948868316563545,\n                18366980076276187881,\n                15068095720303300745,\n                4952650647951470154,\n                15911634980226720120,\n                10740745397838202379,\n                3200127162032008025,\n                3763543940730164508,\n                3723483274937556495,\n                17871783614248259146,\n                8786059543177366813,\n                13050056601003380055,\n                5623281846050325544,\n                8511114651096961385,\n                10891975825673952044,\n                16080052858418260073,\n                7171941023859325850,\n                2503165103241590389,\n                11967819128596062687,\n                17746426492658731021,\n                1524291256148953421,\n                2076038155471824980,\n                5880985691677435840,\n                4713693495653829540,\n                8577899432290161344,\n                11976146392187565938,\n                2529575305527670284,\n                3765314673643814808,\n                7234028569335439232,\n                12375682646064399341,\n                7101569992574162906,\n                11098657045492285566,\n                1153652218824818047,\n                1210454437960036069,\n                2694638310421669121,\n                7870059579873173861,\n                3508868899875540240,\n                13609981818610730741,\n                10703439073683625892,\n                13071420953159015459,\n                13716502475013538938,\n                10634244764110852465,\n                16403497596959564382,\n                15306415780193612609,\n                17601327182445704540,\n                18298349615021078405,\n                18111916165749794999,\n                7537294468737253688,\n                7386987937618099419,\n                10775482015504178918,\n                8525379645714838775,\n                8788609183023289620,\n                895207535126054757,\n                17118106622782691546,\n                16749800484842219686,\n                10933310771357651927,\n                17045784651422893806,\n                10055875188754575183,\n                9519498699655590213,\n                17322601174638910336,\n                12118730165352641482,\n                5930728976613565641,\n                17159697904528121051,\n                15309680603600886131,\n                2354852814839706361,\n                1866864355164982520,\n                14799678913936204761,\n                114516480202556771,\n                13374320542339641716,\n                17948849241297689882,\n                11937303202723535389,\n                8708253685264852524,\n                14784022410383824926,\n                15741150074911773529,\n                4751508515383369506,\n                6753819133127024063,\n                7615256392835158829,\n                14330334546462075477,\n                5916715905113385520,\n                16699087896061936717,\n                2161501163497237132,\n                7657705954734728178,\n                13842299391403386537,\n                6172027960597539813,\n                5307601271781038790,\n                4555363624168980660,\n                8897561972602250232,\n                492135721000809790,\n                196374542645899516,\n                14990889098212601995,\n                6381940097804056460,\n                7088456247368733765,\n                174918913838309902,\n                14001140535865588809,\n                16643163063827173806,\n                1238954875765713073,\n                13202778059857945377,\n                13892311264186089515,\n                13771970066908683469,\n                14995846051430041367,\n                17421145547571170005,\n                10821698378431695436,\n                5316647583697276386,\n                14051654090444941132,\n                18388943018780729150,\n                11259779711269878259,\n                8742581111664031470,\n                8889827116461862655,\n                17319531559654594882,\n                6500455467003400955,\n                3959184730122082747,\n                4054561166041887982,\n                17316966724931034861,\n                1607293446195331113,\n                1556357414629043861,\n                11011377910730701009,\n                13217502480646592162,\n                5556764467305459566,\n                12021589498137324260,\n                531690648537094954,\n                1038223775874752655,\n                10112707642670009067,\n                16909364180557997068,\n                13549292338140530580,\n                14089674983696767092,\n                14960833416043686252,\n                3361732906192010803,\n                15411952217752187419,\n                475547270098839964,\n                8227352829235176532,\n                4333410121135356569,\n                16974375358381043398,\n                7462799035629267008,\n                3961814110661375506,\n                3191195952723002366,\n                15267463856820101363,\n                2682345599906528119,\n                9202835087842166762,\n                5753494002443879006,\n                13496926465554347490,\n                15537050413782275199,\n                4005699994847427717,\n                13011783168070790177,\n                16932430119108925312,\n                10469912374234875027,\n                5996081763274312546,\n                13299322992254047535,\n                13566444816251120959,\n                13441242515242491906,\n                6531470165275421029,\n                6998803913624387519,\n                5190923639408924125,\n                1301326112306077751,\n                2724835656803633652,\n                14868270067404848561,\n                16428689823791581153,\n                6363562758622431773,\n                5795421246045082577,\n                13738077193279334339,\n                17818084837848061577,\n                7409215264364848571,\n                2893214122000373991,\n                4066741278513513286,\n                6208913273098798518,\n                5323770029909018782,\n                5551337708190405618,\n                10281953507639521630,\n                7674048265312145606,\n                13913805095945202464,\n                11645578449852204207,\n                5216827728522108969,\n                18149089235876418482,\n                4193193659542496963,\n                4384037638695340997,\n                6264405355262516799,\n                5923041840648053673,\n                18445416708501282570,\n                1449616427668184913,\n                17814282379016188485,\n                11394546105942760801,\n                514272123860845956,\n                5487867953647208460,\n                9765982880054791980,\n                15269612196572547812,\n                6933672683776753268,\n                10897766962490536850,\n                7963503740124897799,\n                1249067770622312125,\n                8521634516253063564,\n                15047118858576393194,\n                3052485574284313450,\n                15762145598668916146,\n                18313105704770544279,\n                6541634279146063106,\n                3775400747866844137,\n                16496810669859720010,\n                8379319521731425820,\n                10800415684660017782,\n                6142541123129235279,\n                8861768666560539302,\n                15721050291326133652,\n                11134786092605171040,\n                13017548541999335364,\n                16909509841464459084,\n                8484654924270783553,\n                15005512331960977142,\n                4074672441814183738,\n                4078543398182843194,\n                6773998236248908357,\n                631977413504183184,\n                9491750397437496755,\n                3377999220825657249,\n                3346615552296940898,\n                17604589720878522247,\n                5769086022977878966,\n                17347842858220401404,\n                11931418629108149400,\n                14490915772427782374,\n                11545152969051431084,\n                18194530049847403452,\n                14802318193842666424,\n                16217304261948074309,\n                1412773250833563909,\n                7479345161017490691,\n                14305628603682480019,\n                14047111540339531390,\n                2202019933845371318,\n                213291111871207451,\n                9537101822050445095,\n                360483935799398585,\n                15821799940301882413,\n                13587044781648265473,\n                11158232757574497759,\n                12493764616797894572,\n                12454593638118113923,\n                16175783796857016626,\n                11972175061436709392,\n                14628387199635430458,\n                5253379621963585234,\n                6809274079261887574,\n                1124840670828961539,\n                5990829238947221675,\n                16084193379498378212,\n                6869638953004510310,\n                17906409028525617365,\n                2739791577758847487,\n                480131078003075884,\n                16023370915391221306,\n                15817682603522356534,\n                12423449398808644199,\n                14130320721960901031,\n                7934273914237433979,\n                786249691033407308,\n                318299827682676802,\n                17097143809787660310,\n                17521193394806881361,\n                8643211685837497345,\n                1204030043754228035,\n                2676537878172957478,\n                1780844249865247048,\n                1857038044392024228,\n                15537174113724189402,\n                15216184620024948614,\n                18295257315773355758,\n                5049495368122551869,\n                511689711728309335,\n                16940513174832634299,\n                12104504465679211266,\n                15914220570778735059,\n                6279446781938212962,\n                601029894044123455,\n                17804281207827746870,\n                433540216199633732,\n                7944481812184613751,\n                3853777775611712418,\n                12126936213601232312,\n                7065913778676807607,\n                43238211455364752,\n                8192260579196809431,\n                8266744677261407642,\n                4334793912650253838,\n                12956232517663155469,\n                5369404211871099568,\n                3235414488456415006,\n                12567595135095181283,\n                13364037675200086203,\n                2815554933029326376,\n                6185051196142844265,\n                16989212187178652008,\n                3878956585408701458,\n                708958585074504373,\n                16920922562467588927,\n                18249699025766906652,\n                18027337540317897651,\n                2618966708286475266,\n                1113776870378384593,\n                5988471205905783011,\n                11449408349082147321,\n                6427498821108845882,\n                8757628250113942992,\n                3713195263318788838,\n                601232850676293890,\n                9498794059653193118,\n                6534298968814526870,\n                12486527138072517297,\n                15783607638066166551,\n                17817123635789116996,\n                1248377855370621035,\n                11141540237607695650,\n                11310946791190236066,\n                12846390650128150341,\n                15186900836698527641,\n                3867690890119912186,\n                4589172752928224161,\n                18406516299291763072,\n                11413251654981660385,\n                16024801440525265600,\n                4278405775100889986,\n                8755603474239908996,\n                3160069975842943114,\n                9906744402561181341,\n                9965035381218832722,\n                6752543667701180453,\n                9346639648731189767,\n                10661232594877011901,\n                14936909082854570803,\n                1969452932415658459,\n                1696145335740060250,\n                18164995195644723626,\n                5001142711409868759,\n                502680569449519136,\n                3022117952710893422,\n                10177903082752941255,\n                15652975217635236869,\n                2966845407346038740,\n                475611270044318476,\n                16066077773226714888,\n                15255919358962415817,\n                11732084421089027684,\n                4677384405854396649,\n                4610350216539332701,\n                10328878907789481841,\n                6555568935797623159,\n                3017832515483377819,\n                14707077320201566872,\n                12590581217649731730,\n                3161603588075729925,\n                2563665003397527163,\n                5979170469664323613,\n                5626012705821413010,\n                14527466196441398570,\n                9288633927607394750,\n                14475257195709120279,\n                11865264300717431518,\n                17136126069177251144,\n                1473429666850111981,\n                7510246272136643144,\n                18310164183004169194,\n                3593138027022744772,\n                6350576143506118040,\n                12773591294872180021,\n                4700465661075210908,\n                18143542497507479548,\n                7719757932210686713,\n                4338121025681527358,\n                15571485830471842974,\n                16406722845577898376,\n                5721314859539898709,\n                6589287198671761501,\n                9745964795756887415,\n                10659452091068591333,\n                6690465060747950210,\n                728586915321808599,\n                8500603684008829799,\n                6301121250492508617,\n                1984503548524816268,\n                18268190305907234300,\n                7454276134026583117,\n                8547492859943863047,\n                9499474055416732782,\n                300834181303701699,\n                6423420221300563233,\n                10906772834067949181,\n                12139236772746843296,\n                15479617127388528892,\n                7255634393137870745,\n                422813312578980582,\n                1148428423488055078,\n                2405372466822606988,\n                18202859592780650711,\n                15123472874738759666,\n                2160560009262204586,\n                1220679802754985663,\n                8755041458565252857,\n                10511683773218681884,\n                3102123453859609904,\n                2170460789136594842,\n                10540612896965819281,\n                11507452270722296921,\n                3888033478974547053,\n                2913172211662715309,\n                5819754293645132724,\n                5417423241393498910,\n                1121133064615112577,\n                8899735394209007976,\n                17939515994389118968,\n                3057735335191827376,\n                6167592388365551096,\n                7859032161115089000,\n                16392857948131842701,\n                9672772119042623246,\n                6861392074297507574,\n                10079830057029967718,\n                1610021695530123734,\n                11499290474395739628,\n                18357287834621605730,\n                7842767805813604560,\n                17595414094496571456,\n                7727166516961623663,\n                5489874195960679366,\n                16978517381214022058,\n                11807176188692933608,\n                15778362166265505627,\n                12826269652469979971,\n                7799517220815997172,\n                6941343467007860979,\n                14716681029145080878,\n                5685272761645196256,\n                13841850638623453280,\n                18117357664247936176,\n                11360524534267913074,\n                18408319184374782489,\n                7834872787814949745,\n                16527576874764684677,\n                16576008924894848236,\n                12304125447826256834,\n                18301056937365686021,\n                4783517752793787963,\n                2014695633627143026,\n                8288284640512774782,\n                14976342552024779031,\n                2436344641520555003,\n                13990286257760881060,\n                18118120610252892651,\n                8432102189510702685,\n                9013208900764457155,\n                15956895100219663594,\n                11965405775699735022,\n                11479704069694999185,\n                1315304162999565265,\n                7619720903122481473,\n                10798255112249544769,\n                9067939483463584201,\n                8242338589636256000,\n                11595456341434427053,\n                14057071507676286987,\n                13492895734414905617,\n                8167664880787891961,\n                13065353170057145433,\n                1390434145929843432,\n                15097573448811012551,\n                10002618775785350116,\n                13037941058513405166,\n                10812662834979031696,\n                7926490047107184245,\n                5399553758270644040,\n                15603376937288512903,\n                3817798784005377844,\n                12622533130989118638,\n                12217900933744511855,\n                11495811053435066455,\n                17088770095627295990,\n                6282760152901843934,\n                11339571359698956951,\n                10010250182369906159,\n                11956984034096448616,\n                230656938835165573,\n                155123462325204273,\n                16323688331673735090,\n                12405389233556129322,\n                16866268093283320126,\n                8076215192615100819,\n                17788391733691877517,\n                13738263070347903116,\n                17514698963264490076,\n                14361153193344045623,\n                10697613194968260318,\n                398797896589607036,\n                11354436663860273814,\n                3988804407101251650,\n                11718246560466989132,\n                10607955713165345856,\n                12293428353299936422,\n                2774193885283164233,\n                12111880818145942696,\n                5269109320979566091,\n                17700804638146972952,\n                13483325589659749714,\n                7018249448187819229,\n                16605502462498173206,\n                14334331196281817568,\n                17997264741331536966,\n                16942067749941194095,\n                18326105716816079857,\n                2873713554755956975,\n                89972251875212547,\n                11011206003344840167,\n                16263607631557095555,\n                3956845690962774124,\n                15843733851407790844,\n                4532327333478987933,\n                14523922448792187179,\n                671512032483507444,\n                9051952980308527779,\n                5771887136664598504,\n                7318486125138347367,\n                2056863287621362849,\n                5319340499967729915,\n                6771692072764865726,\n                4993497900077789612,\n                14846578576184294087,\n                8749976795074478239,\n                13944161778625889141,\n                13939659589211557709,\n                8674498121103871446,\n                13858955528517010167,\n                6854968788299690525,\n                9785571842093558996,\n                6616581398547260916,\n                11173134838307567854,\n                15020736287331849950,\n                213678875278769463,\n                8136043007787109258,\n                963815884865140222,\n                14383997603758711218,\n                2441395136452256841,\n                2285295004115032555,\n                14143394511135418137,\n                15622142144369079201,\n                16493347221813991820,\n                17474381401274268608,\n                936058552355041089,\n                12942246561895670820,\n                10317584384347004208,\n                11782536454405046773,\n                12350945172113506786,\n                7391214981076111463,\n                7073023377646396731,\n                4011509139909188128,\n                2257833537102580311,\n                7274600296374037369,\n                2769150843750451970,\n                9102426399850639067,\n                8214223108585585549,\n                11637757222275081002,\n                9169116734789273638,\n                13195915003973211388,\n                5475411329499291917,\n                5086118280372242975,\n                17718728186337638844,\n                16105088227769019766,\n                6209815346219807551,\n                2881314910093736440,\n                12490322405428340882,\n                12004395323760866113,\n                9968698365927837252,\n                17316938449682856319,\n                15625883316417529399,\n                12226632472013770838,\n                14161693092908388449,\n                17778030898846793856,\n                13976693691407275877,\n                3477953777282076567,\n                13740936608896808297,\n                17180555612721269478,\n                13416907629329031924,\n                5869124347540464645,\n                13384341358033251916,\n                14313718444333031397,\n                3376219002404246289,\n                339811206717616611,\n                2616093060711965335,\n                8204344482414301835,\n                9186789611379643507,\n                14338727533336579685,\n                12784860191396059227,\n                10489777731949698480,\n                14621154301243573986,\n                13692422118348399108,\n                3784610479458294357,\n                7735714461152647872,\n                12931998015666009092,\n                12887123618479150667,\n                4005389619579094200,\n                12949896351841026182,\n                4274952326880371758,\n                2252542616091249178,\n                11223191016227664360,\n                12276921256190460942,\n                9311103011248164424,\n                14618190821987444804,\n                16794211813689377361,\n                17066759525543500866,\n                7695930135720339816,\n                15636206560014700744,\n                7080595571863441999,\n                16002741097850788650,\n                7266069110373243930,\n                18266417640341330095,\n                12863061635472560818,\n                2804143153090216476,\n                5360410260257436881,\n                10259005860191386447,\n                3129239898744374569,\n                5704118451966324874,\n                2617683975038617110,\n                1419008983250810424,\n                18176995508939903574,\n                3428325565738056333,\n                15807295691769067887,\n                17098475885649833094,\n                435386771621069983,\n                3749240361804507548,\n                3484935049619675621,\n                14151734623085313892,\n                7107401439542109862,\n                9140252282652202082,\n                17139755393802157327,\n                1840890360164731160,\n                13945742659422648167,\n                2993927710006218010,\n                5123393630446195909,\n                12126601606897174993,\n                3757237441333108331,\n                13430475145736272456,\n                141286591810884028,\n                13716994059020442018,\n                16256272733681835404,\n                13021661888272553737,\n                10938682475722641190,\n                16670594791610413108,\n                7581768967654565510,\n                7258449528404661741,\n                16972464178815325271,\n                13103916238623071625,\n                14383222643604888683,\n                9134614536502072501,\n                4484749605592970811,\n                7617523826265603571,\n                286970167644433897,\n                17350844883213337166,\n                9372418001867268906,\n                11036524012081184976,\n                14599471605351296864,\n                14353873970303354160,\n                13804851709719425521,\n                12542207662034387249,\n                5455404902951618435,\n                18208534021141654431,\n                10760289922882806669,\n                10594303509090562894,\n                10523612649331418075,\n                10175165805141093468,\n                3845925331470243881,\n                9968712325133293994,\n                12632170237051093440,\n                14407500129795275129,\n                7039838041956792694,\n                8486437057635491253,\n                12990896208114377714,\n                2169038646525679305,\n                17731701498975515823,\n                12645000352324144895,\n                6940383608615873690,\n                17112601588170442293,\n                9898015000882658910,\n                14088035355956248952,\n                507013420654526970,\n                16055894587901325067,\n                17646639921892423762,\n                9750921155184562446,\n                854792204257329267,\n                1907596925043325411,\n                13186585073232938657,\n                17324756184357468589,\n                13215141704644982246,\n                9990033614756242368,\n                10703741257062175210,\n                17316690423805264994,\n                10087888281338300084,\n                1089239266776577821,\n                12176439490507890322,\n                12695856964012192215,\n                11884436036930363286,\n                16729977556989227363,\n                10923433806234038450,\n                12992592892604117864,\n                1268144030942582108,\n                10300209358150898566,\n                7832544414491392865,\n                6657397193574515418,\n                17331856360490769436,\n                6685863352121534775,\n                4872607912521754323,\n                13925034245904306548,\n                15794800294630432773,\n                4150702655832044776,\n                1922931668614047821,\n                12163445688451808604,\n                6814128619400384333,\n                1631984743731389500,\n                3778862171994919347,\n                15454466802087055901,\n                9264991358295251267,\n                9936918682375797148,\n                18157798989566244240,\n                5581635369737696387,\n                4479378944085838523,\n                1634001250673190201,\n                9492710507275012642,\n                9234172590874940829,\n                8783494515876021547,\n                10628896245581316049,\n                9175567334027325902,\n                18216027702703135409,\n                11634672812751315604,\n                5707660447334077643,\n                10202156378293455124,\n                13892983828551272913,\n                9908193203293924452,\n                17571530454157193212,\n                15072879288037447844,\n                127116006100922087,\n                11771185510908260613,\n                2445074823174851909,\n                10670868476525820983,\n                7425728342067716996,\n                2985971528087667631,\n                7395252277468977294,\n                2997333798387301672,\n                17435969755936090886,\n                2284549800776567351,\n                1549552636061955968,\n                2562232096971944509,\n                18175473291905577073,\n                2694680735549112623,\n                1791226765063856042,\n                6639691018975209776,\n                14450608736185529781,\n                776581885259523327,\n                481545710834071552,\n                17904221072369375896,\n                7658678246624118033,\n                14858939803632465766,\n                16638621759785444057,\n                7852705140401778814,\n                15504288742303235325,\n                16123480377693163548,\n                17580674642691781753,\n                2060059788952429927,\n                8044488423463356775,\n                12159915697800522747,\n                9979462535316088472,\n                11464540989399692426,\n                9723421225194612320,\n                6449580914984939699,\n                9406550367550615810,\n                5311403373873226147,\n                3066770575413693918,\n                633416401733094941,\n                11712977725629062725,\n                4883265930195070560,\n                16189146570612520152,\n                1698905934763835706,\n                950927367170890858,\n                8829376333788190736,\n                7907286046365739950,\n                3164878452294289455,\n                10511755255842705560,\n                2924155429164172446,\n                16124299828159551950,\n                6010099555943764977,\n                12724759932455911822,\n                8127212736140639283,\n                10128696763620279450,\n                18035084640302368027,\n                8781918799260800755,\n                14441294204200284647,\n                1927193541320801341,\n                17060847707989835700,\n                8195209044950545498,\n                4420757359342589946,\n                3727277256040667922,\n                385534260624886499,\n                3266025280223616765,\n                8307518494652840749,\n                10628505726158916146,\n                12481632216062021685,\n                8443059664409740255,\n                17083655987996225144,\n                730490563149619104,\n                16115455384269067104,\n                2382469211629823819,\n                15299473012699513736,\n                2545726390341274697,\n                9566636451267734313,\n                17404798143522728759,\n                12853265630229752228,\n                2172148070178466503,\n                11003520300346660378,\n                1134402141777052949,\n                11771658227786580781,\n                12088790715698048033,\n                17088312113295353834,\n                9858438140481896937,\n                4732279313243969474,\n                9302577460868509370,\n                10413475674288905591,\n                13021872760990946904,\n                9638439145954399186,\n                2342341335564065825,\n                18026701375952328694,\n                5788988813536004381,\n                6112690485750689530,\n                12277817288452946380,\n                7006316162927315897,\n                12091459534025657274,\n                2152473017451714429,\n                7117646493299604201,\n                1591263581497951670,\n                12905706257967317715,\n                9739330975167177950,\n                14245120246238342654,\n                5445126088677322792,\n                8475451974915724213,\n                16532703318231814798,\n                11346158079313546034,\n                2587775018559680831,\n                16042335036595321112,\n                2783584919636232962,\n                9477074304137314302,\n                6679970828349102077,\n                14914134423793746235,\n                8835496380779847657,\n                13649036745393349622,\n                11800533244055495841,\n                10329924636422821002,\n                12857463828194064326,\n                376873602561854006,\n                13991526512239117933,\n                4244930150917248420,\n                9377193637737929560,\n                13470983451570137106,\n                13709193869228195237,\n                873834737899882109,\n                17298475531540644799,\n                5157431525573101837,\n                15694890039292357223,\n                7263973093257735703,\n                12810611197004081294,\n                17159179774131359627,\n                16320123751204284184,\n                6659167957772819702,\n                3559977382115542403,\n                12297726256906381994,\n                10545494770323931829,\n                14423760345131502963,\n                11951650428815262297,\n                3552160721881779344,\n                3921553500551057972,\n                8827773853996085356,\n                13035185276040540279,\n                2431229196115555640,\n                8867095302754162942,\n                5824531700307273486,\n                17795693614810306555,\n                5327408766240893952,\n                16204495625665346776,\n                4520750388436708886,\n                16011790401268552431,\n                13186223796877430470,\n                5894651091707364204,\n                7349710328825984565,\n                12990495590567591633,\n                15789659485048909512,\n                8110395238510363562,\n                7157879492847706094,\n                1855521204456327951,\n                9387090323123631218,\n                6983791028671987424,\n                17264360937175821593,\n                8964335962673307125,\n                4438686713691513133,\n                4609268036048721815,\n                13573223706586323329,\n                4370839728814507274,\n                7190667190262397984,\n                10585250032143309718,\n                5262324401338557970,\n                18436298550586124762,\n                615281048933821162,\n                7892081066718287534,\n                4153026337684348988,\n                1998277297931299322,\n                9570951836837442866,\n                4214601792245837204,\n                12544321637650748092,\n                9861635514343412559,\n                5163007832201827055,\n                8357508302373244198,\n                14941521234529596324,\n                3025149840692592346,\n                1565659965409485275,\n                8113415648323406877,\n                18047137088865383715,\n                4761751436090139639,\n                410742697284005702,\n                8123281234742203725,\n                2300465198396824513,\n                7573276443955885792,\n                18354607580020177721,\n                13826724636992006395,\n                8759796250561912860,\n                15446866439938431144,\n                6466830870344794620,\n                7248618897690538684,\n                10968843377874574640,\n                4538534083565844065,\n                10463149345079834509,\n                7862094636026465434,\n                9363380870281847317,\n                17750231516234915849,\n                10605066658889662478,\n                8651524573226517322,\n                18099624785064356749,\n                9012260115980472797,\n                5112736631921184699,\n                16433387801586396924,\n                11364983784749187252,\n                4592720300056375272,\n                17400478621152089229,\n                9960304372235946193,\n                6810543488590694603,\n                9421463587360187007,\n                11110051932845796606,\n                15820198248392525417,\n                17370225890188484838,\n                5511348958827419764,\n                2047354351196049067,\n                8842128025677787612,\n                2546794526658883557,\n                9990966093285021784,\n                10968573027006701235,\n                8153649946073344163,\n                3435896373516278367,\n                8854351008479838087,\n                15172945879518770400,\n                16101272223167010392,\n                6080119325930559085,\n                18336117387797080742,\n                11495477657407490192,\n                13799378353686928991,\n                814519040394412554,\n                4055424121543431351,\n                17971320561372651,\n                3045424347018335501,\n                9144749175919467258,\n                17693139582687085722,\n                15549618811805620741,\n                10042978303090035766,\n                11250820672049577391,\n                14650606162160854310,\n                681053092156505443,\n                1467784211081816986,\n                14292070206822113207,\n                3356550259250142987,\n                8897529911380186072,\n                15774124171111764637,\n                3608035896189707114,\n                14945841364780812283,\n                13638982384303383036,\n                5615554819198447325,\n                6604755778043315386,\n                13154764512915240378,\n                15781224930202608619,\n                5254282127938948208,\n                15314350610960881010,\n                127785624547347482,\n                553562291991422824,\n                2665385793464509946,\n                11960374868185251273,\n                11044390920977985650,\n                4524189753866435423,\n                11922516208188195244,\n                7322728958220573958,\n                4566122595518047958,\n                9257927878541886507,\n                11778087706650674305,\n                12675707724087743775,\n                14040780876086782366,\n                10310608200410344735,\n                14747492163773576994,\n                14763717547881637874,\n                4519119406094329744,\n                5416745750548195790,\n                8698677371585009606,\n                10540691781438295688,\n                7621321253979898000,\n                12870309033904607776,\n                8766530226422390333,\n                14410571192410377800,\n                5017391940288233504,\n                8156621488957733235,\n                5701635921482105032,\n                8697544584237000467,\n                14463840701596743299,\n                1132393248669674482,\n                17783802461705335925,\n                3379973927717106230,\n                170233915427480249,\n                7721198001501959996,\n                5984888435057942981,\n                11741252369856674270,\n                2667584213579254971,\n                12391311788904160680,\n                6403858222659082204,\n                1706835705335237525,\n                6951651160442697621,\n                3395001754770416725,\n                16336009550495654242,\n                1588611969581977597,\n                3369833199693136814,\n                16679631221398536370,\n                17143410383401198876,\n                10718378066292328788,\n                5098802788047763943,\n                5003995899412543356,\n                7797753734199884695,\n                9804992578690571817,\n                852561252664521182,\n                676543942240459737,\n                12047623372899199507,\n                12688884395525848756,\n                2909502726897081899,\n                6031120528123066491,\n                10187664230696218588,\n                1634984456433807424,\n                13461263282968829173,\n                562535253767547543,\n                3262317265760851658,\n                10159933570831396212,\n                9610081805557490182,\n                10645180788472548796,\n                3825134762043109512,\n                11454131642474959474,\n                9401675919629678678,\n                14450914272139752267,\n                7874801920832590192,\n                18054728540681521894,\n                15303403280502540543,\n                15467520708986418749,\n                7705766485597949742,\n                204013254901132813,\n                13967733294005655167,\n                4001477583895779972,\n                5972807400755250985,\n                1217989087590450380,\n                10862887725324735466,\n                1706534929358469389,\n                13264418588578493513,\n                10626892394654962607,\n                2832066031146486501,\n                6506140673085843042,\n                14326905332890415966,\n                4447185119806812807,\n                10289677945299645724,\n                4459612687423833871,\n                10867968914888905042,\n                6485974059834599556,\n                14142727197114410913,\n                8587964753565667799,\n                8972765350531032618,\n                2292328948393940314,\n                935062418987300570,\n                6736600688398044784,\n                7931198222933701097,\n                12299736294122528410,\n                14482610418638535345,\n                14434918807907278467,\n                2439305975663118437,\n                4480608229958318339,\n                3952066067287563861,\n                14258451016047506475,\n                1231074371015334625,\n                10331248234059926878,\n                748201218435577445,\n                17462982229802307244,\n                15686869687340151573,\n                17053063210448785862,\n                3599854718778131864,\n                9301737618251045483,\n                7627446349617553731,\n                12835054936982245416,\n                6336754664191040283,\n                5870029311999289016,\n                6027766907695007223,\n                4082089270941640253,\n                10932978191544782698,\n                858542788191451824,\n                18173438258887704458,\n                15950175591359254382,\n                10496438189070905854,\n                3761196574957125185,\n                8070795822731288097,\n                14333885717356195593,\n                12907535393235068762,\n                1300746091836895017,\n                16095775835363872226,\n                5221409894943186677,\n                10801943559441670680,\n                2226518879270450694,\n                14144518871296969095,\n                8329328663632421754,\n                14151247548153947290,\n                7005388744793033852,\n                3731783672032466610,\n                5642923046890143070,\n                2243566518435928649,\n                17827722312011386647,\n                3288494091174335807,\n                12802408479052688767,\n                3941775622555625432,\n                13974527790491109973,\n                7184506709498460272,\n                11905130726430415767,\n                12898188848602614942,\n                3336329541205892765,\n                16740350675338109671,\n                335449286526469870,\n                16670399530115701446,\n                3370759555155341636,\n                13153054802454960430,\n                17020347152181004363,\n                16005180766456295251,\n                16035747705790056677,\n                1904525470716808389,\n                1362939978621142721,\n                14268989953945718594,\n                3131759537359596393,\n                12623877369046640758,\n                16034480904634718634,\n                7205849095551422163,\n                18352760423874563428,\n                9294184574071126998,\n                4855176006968938932,\n                13740659884417148386,\n                9678792914697707031,\n                17346691148499799327,\n                3661296281536466662,\n                1858171995289042067,\n                18199380542019467146,\n                18435270579529426778,\n                8792805062170870691,\n                2216926146372155391,\n                3336698928747087340,\n                15361162057883195491,\n                2230334966886787987,\n                6790919905652555693,\n                9523654540872868833,\n                2373039885555601800,\n                4493652711092482273,\n                4848735304745253118,\n                4615650132005261688,\n                7011332091469251441,\n                15051588471309214410,\n                16436499359483898767,\n                5534529923924019676,\n                8031782014972324826,\n                9587715117105518067,\n                5201232572863714631,\n                6949484852216655045,\n                11242297859309211887,\n                5445327566402416511,\n                11759527029723480062,\n                7401655792007047741,\n                12981437329323060492,\n                16627917972301844941,\n                16086064209851186236,\n                18317605428363897776,\n                5479987106722795675,\n                470044962552825995,\n                3263508437049006276,\n                8532199872517472836,\n                179963713893634086,\n                14750710828805195780,\n                8566890372208465530,\n                457434420254160615,\n                9026428119711082888,\n                5051697286542220522,\n                4066845298260571291,\n                15266943848838025449,\n                7790231715639606132,\n                18047039423184779192,\n                7097787949459808218,\n                12326346119319424869,\n                14895758855340221400,\n                270818421368673258,\n                10953991395430365501,\n                10722834322274726220,\n                7175276538034253286,\n                12293270138776886211,\n                10868230614957475384,\n                15568806031450505970,\n                2173332627995000239,\n                14888402241228040414,\n                18405500854031799916,\n                9396217995786697609,\n                8638079772902395024,\n                8700301862255582170,\n                16669714149683986916,\n                11791960995856983997,\n                6941956874526614041,\n                471913500417437253,\n                12645657659237731696,\n                7344954555441957686,\n                8576764504255171238,\n                17045229481365431866,\n                10710908163870404781,\n                11301570355963434173,\n                5971177578976838887,\n                115032958122130333,\n                16996195561179864691,\n                5303610406571283411,\n                1557215249726500571,\n                429079935597742432,\n                6007572072647948719,\n                8793841786368287656,\n                209772504980789061,\n                12514491936429933001,\n                7014555801251009174,\n                5854792368971550756,\n                867919854085761466,\n                11854155159921686895,\n                13142074624110571417,\n                7907850875814485970,\n                16861742288872511551,\n                1208590626489658408,\n                8601279929820923503,\n                2258924690462246171,\n                9585184984627008623,\n                5315828210383196353,\n                1297805663260559339,\n                7398320505542428444,\n                17073967214624996598,\n                17704120650146094638,\n                1299385581680024947,\n                1443489762904405882,\n                13518221354231615324,\n                9070126881206870042,\n                993730884724745294,\n                14081041013869681380,\n                8359943552596347499,\n                6866696380166200245,\n                3837542845849508667,\n                14602652064433499913,\n                14314340020057352466,\n                8839559535694012406,\n                14227230979046046062,\n                10298228782846904508,\n                13298718693240900028,\n                13909155817605919274,\n                8780642200132615642,\n                9412091595152829592,\n                6822145839018577251,\n                8785978531052338151,\n                4948528066049804851,\n                1172628369060862431,\n                5666685907911162463,\n                14153629140204265152,\n                10500845530057771412,\n                14608765724027887761,\n                5087095504941752721,\n                8701919577673940506,\n                17137520717957261114,\n                9199637801040704714,\n                7095886304415555902,\n                15925336741311965253,\n                13077337771490692636,\n                145710441006655783,\n                13157185292334340173,\n                13407008567503772150,\n                14215960022966892561,\n                11985156240556559472,\n                17945288516894513884,\n                14097688271959790972,\n                15505832877271523166,\n                5843174730859038007,\n                16205337090179264073,\n                17606308108912062454,\n                669419080191010051,\n                15851467430769620452,\n                4936909049694472990,\n                9426661750545745060,\n                15134074240235574428,\n                7927257239677744604,\n                13865931916371651548,\n                9055694221969554578,\n                18105938911030359772,\n                17344312477772739728,\n                7984780979580024449,\n                17946659128143746086,\n                3659014353178730517,\n                10881946920507249755,\n                9643240829875041416,\n                9979006042478131099,\n                3624673912637648606,\n                10183097162206305022,\n                14705929380474025749,\n                8560872261129163553,\n                8542571307034562924,\n                2849336599501641328,\n                1427173016960915063,\n                10561422500956348533,\n                13953646915815013961,\n                14711009426065697276,\n                17629582482698947067,\n                5068672373293663589,\n                10328236305608973133,\n                11390625625852214740,\n                16171676010227409920,\n                12007752012156277746,\n                8787339600696104751,\n                17147558071877953304,\n                6243146155416198819,\n                16781815705425825152,\n                9276534213532622927,\n                5681999116735330218,\n                16852010554258505062,\n                1705868855435043353,\n                14818213196970587370,\n                9256091199810743680,\n                10438037318676504268,\n                16794099631419865392,\n                9815261792343983998,\n                8286783569926236889,\n                337573434858179240,\n                16820096306284770618,\n                15966431763494632363,\n                6481208570789422743,\n                8429344246220730373,\n                27262454150324780,\n                9516508385964067765,\n                12876008564654096078,\n                4071754764426708210,\n                11593726207040321843,\n                10464906996437266409,\n                17795281436982488931,\n                7949644313068982658,\n                7004988298640898067,\n                12037768710549869791,\n                16790409316897618369,\n                7084103797769437957,\n                2419445775321185382,\n                8074279743518467644,\n                8069323749479463736,\n                17160974715554385442,\n                6446198417065372686,\n                909199233418090118,\n                17988046405451941411,\n                15619199660230837101,\n                8540771809211736979,\n                15004059727603767665,\n                9970067037279458294,\n                18037810830226270966,\n                7395784361237814976,\n                441608911830412969,\n                15193617525949907726,\n                8329750585903900376,\n                9232838481221040709,\n                13862722871242295122,\n                2651785001097390772,\n                13513885689469842635,\n                2916635381190975954,\n                14673366675350976320,\n                16796162449704211211,\n                15311238965453782301,\n                17048079530325153354,\n                6357896971279650981,\n                6912501188214061635,\n                15767706566209693421,\n                4950547784710662682,\n                6818275469676220067,\n                6311416403137682772,\n                14192827820659451230,\n                5519753761822532883,\n                6327790738344616319,\n                1571492847028444517,\n                519836968001291628,\n                8880684714326015791,\n                4414274058554177288,\n                6693694082558848552,\n                9180328506312734588,\n                11851754793034588133,\n                17892308745832908148,\n                12122989628255788470,\n                9813496966285232956,\n                10955347908495147392,\n                7570827623140202413,\n                12207236341183232786,\n                4777412212063025006,\n                12385252236023114447,\n                9508166476039999651,\n                114906234504385867,\n                9207258060511755437,\n                9210800729712345963,\n                5771423404639548192,\n                15194614200877751860,\n                4338352328776016735,\n                2610599495858282641,\n                16733979028371628176,\n                1929910361255473211,\n                14137591116693762330,\n                11276030669834631098,\n                8384908437274376663,\n                9932945040858512861,\n                6671057894832572720,\n                15600691762738444868,\n                1090424207156031951,\n                7633234269493162481,\n                1452672955493924651,\n                8042177265524791320,\n                5918487395429243286,\n                6071477929355428400,\n                8446553879294519239,\n                17238305490194970122,\n                8987047329207310489,\n                12398791106166157316,\n                15174911221193868718,\n                16946345338721827201,\n                10949948458544444544,\n                17318691300002579588,\n                3998415180681624527,\n                12750967780890975278,\n                288347833998723232,\n                16095212211245790724,\n                7822321122528030405,\n                1109063169170634828,\n                4652215944166612902,\n                16803163450585461189,\n                2776655336762420387,\n                15642000619067002463,\n                2018031858324511467,\n                11237756472829950832,\n                17565143038179107620,\n                16281738469740252935,\n                17600775725533342946,\n                14750124410220606835,\n                12883103971220877489,\n                15936542280450981255,\n                9714323865324229767,\n                1469778854158587075,\n                9593652974682074282,\n                11762461414294133530,\n                1404229929827068795,\n                16503900992928085410,\n                14684251465993475323,\n                17706137844161464268,\n                3909560365123413776,\n                9861484314350641439,\n                12009083324415037686,\n                18169123171153377641,\n                2393555352820887974,\n                12841835092045423984,\n                5564097118032313065,\n                12777929502410633133,\n                5078336225337553091,\n                8694020844593690446,\n                11388328638584884970,\n                13970084235020262491,\n                829772823417380360,\n                8286179729255644084,\n                957139202750627952,\n                3221879212666198953,\n                7645002751366998370,\n                16715354970243034507,\n                18304845819423800855,\n                9447343833119941047,\n                15163436489241423867,\n                2479924668890227186,\n                7818020209349584296,\n                10580682200967646169,\n                13911404593504958709,\n                8718275660345998055,\n                10124290490841409455,\n                7651303722187917624,\n                8976889705380896709,\n                11163660337280624646,\n                10388784795451265724,\n                3541771203499561964,\n                6075152751154669243,\n                2218667547472367527,\n                3995516111323252367,\n                11180655997089000245,\n                5073383660790586917,\n                13458152992621454755,\n                11676714551890338118,\n                1494799466123513971,\n                7327872328474238339,\n                2389581909384645325,\n                16687753253842922782,\n                11699615151482669193,\n                14774804959571915475,\n                947896829667145566,\n                10573954710522391072,\n                7072571908216975157,\n                1921454675444217366,\n                11232731567954977537,\n                14840397076140631292,\n                5060980672779376677,\n                12975040048834693618,\n                10752224255692434704,\n                1306885046650589222,\n                1930876755170305305,\n                8739276995254053408,\n                17062175909187112484,\n                13994219820475631601,\n                15241051299228638903,\n                13189674117437271785,\n                3224946313788614445,\n                2946953495584212148,\n                12515092889993340415,\n                8549243107224308830,\n                6555967774604787675,\n                17074340742411084655,\n                15860252206376208136,\n                2452901849982359121,\n                1217176756850333549,\n                15260442969744536089,\n                15266619117940483626,\n                3092040621234773226,\n                8592622982489602359,\n                17268283100249965729,\n                9118863795573669565,\n                5004589504450812591,\n                6062182260926951061,\n                17997691517876082652,\n                4684918577412859882,\n                15422706458772273904,\n                10373853167444581181,\n                9008368442714488639,\n                3624691764843327336,\n                1028359463583846893,\n                859230892908817598,\n                4558109131236939269,\n                9197636145007824268,\n                3397702897203024845,\n                17645318682095346025,\n                297912191657103235,\n                16707811002284900618,\n                9544713268645707384,\n                18174588433767285273,\n                14115044574398526220,\n                9550382630286578375,\n                5669098498675234593,\n                1419240760313025600,\n                2624357144105750680,\n                1883325833631791743,\n                12465653732071455581,\n                14016850785680848114,\n                10853862374929837476,\n                9213307118918963573,\n                17446748283231651532,\n                6944359057113621208,\n                4376214699313790455,\n                4272171302826636053,\n                1361571807732899930,\n                15928311517924806859,\n                10979193193168197302,\n                14315748858106823250,\n                11415251230794226377,\n                14341688199410222112,\n                13372316746789815573,\n                12205797915700991132,\n                12054245058919264469,\n                7420566807537884143,\n                5432588773028217373,\n                6350587654471565537,\n                6531829368743229731,\n                2207976572300046135,\n                12703622166413274712,\n                18356491416550058865,\n                11743861089192075323,\n                9975481076082250423,\n                5270519543247843824,\n                16596875614345327407,\n                264970638689993857,\n                12731851329939038802,\n                4100374548344342900,\n                11696626303514932259,\n                5795347109604371486,\n                4018536166291403802,\n                11605839014492166891,\n                4046122976220313619,\n                7173051512574373511,\n                10760222355399775007,\n                2397452537849365173,\n                7000689557970901078,\n                3508218483424754056,\n                11249130935335670874,\n                15485017380487364008,\n                14838383309738250533,\n                1654265944033471910,\n                6550408986795246586,\n                11574017534658799615,\n                4938545842279886871,\n                6987608227293293739,\n                8490763818451756454,\n                15553940026252549950,\n                6498239556873819401,\n                8894315085699368208,\n                1767452481216158212,\n                17391068041642225358,\n                12099770647562592260,\n                3232275359468560052,\n                9875417733360604587,\n                7344425724555447442,\n                18431729052975636742,\n                2951164042491135904,\n                15903903429564563858,\n                17834292681718510486,\n                4198460729209826867,\n                18283343945753908147,\n                13114879247072451198,\n                6308546439134988873,\n                8448793227573510403,\n                12883523838880467178,\n                12608354838733343984,\n                12284418193790956340,\n                3099459343498815410,\n                3160460005758859474,\n                17209423043124247155,\n                10299954565801063517,\n                17312198705527288316,\n                1159079074290265282,\n                13803764368072178660,\n                12357928111570535493,\n                9319226950413258817,\n                7861389264222959398,\n                4208357822974886032,\n                4724453996000826506,\n                9219506857747054473,\n                16650755835313196333,\n                4602357483273387357,\n                8421668150799174361,\n                12464268335381289971,\n                16842331782835636444,\n                2164847798539863920,\n                11848181286892607238,\n                8483204622866252940,\n                5177013341061819166,\n                6794893916803855304,\n                830729528874930746,\n                10838023688403983614,\n                2936119661394195602,\n                16749442537019148931,\n                6282125361565649956,\n                12522652324110588825,\n                706946363036865451,\n                287377191870510960,\n                4079038197618045672,\n                65600267963984525,\n                15852196146124192732,\n                7791496333170096323,\n                1197307315361468886,\n                12564376588501612052,\n                18287064409980818748,\n                16513413097113895910,\n                13772586176619885924,\n                17412579692431697526,\n                9943582674770693553,\n                18017460763820483721,\n                12774668415999817484,\n                17419661422487800791,\n                8542296650831811427,\n                11030794367359113173,\n                3091992835617551759,\n                6647390664467556203,\n                4760797422569339325,\n                15821430759187595540,\n                15905919720868415262,\n                6964495470980486330,\n                11481098497210815485,\n                13606157196874073055,\n                2545548939497776096,\n                17492549168216383449,\n                976625893298873591,\n                3307888858281262315,\n                4406331424039826265,\n                7251492960589745703,\n                1462803411594068207,\n                14615947077492017745,\n                14477853980032711958,\n                6580067844089943084,\n                8164600499091902269,\n                4672103301095852237,\n                355042099720565535,\n                11026766258596173656,\n                9849960052517135155,\n                16725670149953992537,\n                15683028676578831515,\n                10104782290810509683,\n                4905343590849641899,\n                17726532108833531580,\n                13910286230069122723,\n                9139857611408342006,\n                4873918044036171351,\n                5211230260928194081,\n                4862798578450111352,\n                8040863435679951765,\n                9157211979753234216,\n                5969001182224545740,\n                14666007377730777715,\n                746412171062253704,\n                5788296420214704699,\n                16052313287704740168,\n                15016980204491105152,\n                128634126176999080,\n                12474550947728802418,\n                17798334047543705551,\n                16546317352521543345,\n                5935130659172645630,\n                9017751516052971809,\n                8734332868677069231,\n                4489180421214586024,\n                10852153455030219222,\n                9452853792027507,\n                7518566350390737179,\n                226398539584556263,\n                11348207575144575782,\n                11286381051277848898,\n                2699324198517442237,\n                5176288375717881953,\n                7814733078102607208,\n                2870574509136744908,\n                13870395192961519685,\n                16224938596653908092,\n                1164830155402073602,\n                6289706313355675934,\n                10093838410108560175,\n                2551691589709651401,\n                15882696485463451559,\n                3395731646324122865,\n                12473003610421288231,\n                7149619960361615882,\n                9872807622306918213,\n                6663012576266477470,\n                17016549792515115205,\n                7914178572800158023,\n                17014701567637435932,\n                14346020259284370257,\n                5074365976986728463,\n                4760168726990175515,\n                9895948792206852207,\n                18273255159788978236,\n                15744547484672365588,\n                16864050091650583468,\n                7152138044891906219,\n                3133231435713995056,\n                14654289506261133725,\n                14216037513719362689,\n                6883938067921952514,\n                13637751749205284541,\n                3930907102025842836,\n                7818503413066881742,\n                16512268473175446131,\n                13618638131220285482,\n                3526560852689406895,\n                16317348279030286281,\n                5781706287563855208,\n                16877706843053345782,\n                9787389520151320440,\n                1672625892740702444,\n                17775094144895143457,\n                7284734471708236532,\n                6265912061217026214,\n                16428427284586036469,\n                7239300285490611080,\n                12257099262814629130,\n                1443098110450745157,\n                7111333716613874437,\n                10912463389630114261,\n                16046472632120791101,\n                11071308475967108461,\n                15827031925467657247,\n                8451701545861351835,\n                2032718007638091987,\n                9275305708809424137,\n                10133532607349132521,\n                62031173551766505,\n                1069668934694816298,\n                10021315903394494037,\n                18062320514241791111,\n                16614273374620642998,\n                3874528406029009574,\n                11609554407744278526,\n                6664429329059042685,\n                2466789265733227250,\n                13791862987730476433,\n                3100076428479694646,\n                1940573727807547478,\n                1717992312877296193,\n                3858278897688455120,\n                2708391244967786582,\n                5897077897033357390,\n                13903090124093303714,\n                5210172753029188249,\n                7461814148277300830,\n                9825991953137124992,\n                8749849231144845954,\n                15733619176610014569,\n                2536045915051793710,\n                2795322555877650589,\n                15164137179922407098,\n                11311210084140344802,\n                10571285191092929225,\n                4809833504711226607,\n                15053596169163492600,\n                12405664553095020547,\n                16471715640263755395,\n                3828351876877550724,\n                8499888452131579133,\n                5279727535149011805,\n                788643833745941437,\n                11012285726544455006,\n                15140257364221864448,\n                1834285009459528474,\n                6667182475201903438,\n                15294024395589453460,\n                10526482467856757788,\n                11877982762793807927,\n                16230316864465358123,\n                15723393603594181628,\n                18424513935220466565,\n                2247141586434891619,\n                9561372576131838874,\n                8725104655684175177,\n                4143398848385382705,\n                15142179196637056843,\n                17330386941741492571,\n                8185673125837710067,\n                14939737481973173962,\n                10478395787666924945,\n                2774689508274990026,\n                12451742284278860222,\n                10819437460867617255,\n                13731567691766219490,\n                2010973683387239919,\n                9908150371329956596,\n                5142510757399393995,\n                8739166923706997151,\n                16903649040425907246,\n                6887419514989237100,\n                1875697363324020800,\n                16410802797521308346,\n                135862499096678312,\n                1002710565280860416,\n                5506348106905501784,\n                11368287034717703998,\n                12947266586015982813,\n                5318254909926585664,\n                9296468205284792595,\n                8004814724160061752,\n                366393468717204226,\n                10790734687437783398,\n                4968864942084278227,\n                15798662312565535644,\n                1358717464422009379,\n                12888686466434430386,\n                370520483338984073,\n                9184642588343372758,\n                9427179068402613262,\n                10546786545869440465,\n                12655417731444306355,\n                9241957630409402290,\n                821497951821470195,\n                3197970711092278947,\n                2184424336239199737,\n                5106022623290447939,\n                16287048031456496603,\n                14037056338746814782,\n                7474000199931218562,\n                12188148167023924203,\n                4192028392289466906,\n                7847291769851591899,\n                3599561900723047299,\n                851922034760320751,\n                13587138821847499752,\n                15960408996225570897,\n                3252001517847791314,\n                794174927197992513,\n                13500786923616416327,\n                10492520307372562282,\n                17778963725733766896,\n                9940193524688369200,\n                7839429243680619309,\n                11152685327758330011,\n                4793514629906514769,\n                12571317405831554973,\n                14236764890442489777,\n                14285226682975878252,\n                4752465601541667238,\n                7069073862761309134,\n                18297621617638524964,\n                16921089529724869008,\n                15310629395363439387,\n                13959904965987734388,\n                5530325767118220975,\n                955257971161171732,\n                9249687876412175486,\n                6437014646360143974,\n                1355675591008680076,\n                14363814817404705228,\n                11444699168208672882,\n                16890344077647521215,\n                13663194688247169944,\n                9311758702620596945,\n                9111333905244008262,\n                3739308534752587737,\n                10082399017494306243,\n                14502104680453962352,\n                3240447658814963588,\n                1945616413338215240,\n                12702436196323839746,\n                15056103164643567233,\n                14232906369316952845,\n                8850081479512611348,\n                78742167026295742,\n                10346207199790592003,\n                8330318603106182342,\n                7555172829812303483,\n                9135554534047252825,\n                2213978715965424041,\n                14487841485121669529,\n                14201073224315526620,\n                12002576656710628646,\n                9216161229854384642,\n                15287364979646883311,\n                4707577895128497224,\n                14025232799632084648,\n                5317706395334588893,\n                1489525665074354154,\n                9157439364142092486,\n                7033808256892914411,\n                2856904746309353752,\n                11315255790030198921,\n                12167475608624586287,\n                14898366696798509538,\n                9918128939648387398,\n                15155651994814693417,\n                7300960472494546400,\n                2127526231515960912,\n                8923406206829661118,\n                16210393114988425815,\n                6582813395371196199,\n                15621762854392338472,\n                3789550044424910854,\n                16988798023618902953,\n                16490593537106458722,\n                14139545158028230044,\n                9923635478455782946,\n                8897217280317716469,\n                8453814653444266828,\n                7491325054712040563,\n                12316700761490127631,\n                3768457975900229126,\n                3000037930881673503,\n                16933057766750635435,\n                15031174928418481583,\n                3019987484089942716,\n                18385609936539305759,\n                17538768527945166806,\n                5447221007766299602,\n                4022798439534764827,\n                17074805847175217989,\n                9477194110020170032,\n                10200259846152838876,\n                6455055232471034376,\n                5679758327656142352,\n                7374147007380920949,\n                10200477410022066193,\n                2678287199491553725,\n                5011120062607229052,\n                7214257460239674372,\n                9631753064650306646,\n                1151983673963114572,\n                2455508156322019163,\n                13344796472161923955,\n                17003695385004214505,\n                11166307372098954131,\n                2221946328882472137,\n                7061489614039858629,\n                3790971501091116413,\n                7833733804721228481,\n                193935756315502298,\n                10256338066976304411,\n                6065749049589877362,\n                10736472690437134411,\n                10155365416269683464,\n                8189737882773858983,\n                13671211115390707327,\n                9578025336797949473,\n                4003423028251739147,\n                4500512304316856151,\n                16693811644887033093,\n                7707767344560596984,\n                5599541458797859603,\n                11592325835943024402,\n                13355669588132489385,\n                15932001697488084536,\n                9870357379952328535,\n                18310499762741838752,\n                16196774945614723862,\n                15790487345250753382,\n                11990590655367464148,\n                6718674416650039299,\n                14857329469228715563,\n                15423479737409206383,\n                17779878703537243863,\n                2210183662909405344,\n                2815540909030329829,\n                5940765014986549489,\n                16884893974961992656,\n                4351638805125702042,\n                17084353252120736247,\n                5724252085645496824,\n                17794301429798973952,\n                7949129492433028333,\n                17290229503720706399,\n                12839841549866653659,\n                14863383260888850679,\n                15788917858243172461,\n                12477975711782044218,\n                12362210923589911101,\n                12864920132785914749,\n                10860162458674426789,\n                15634366676531407135,\n                6076026769874036504,\n                12186624835981223643,\n                477838969646790588,\n                10209086843687255723,\n                4453597694185557465,\n                9792638779490749472,\n                8664773568287178159,\n                18322711946104316656,\n                5061590004040013161,\n                11611936838758532137,\n                3299611430381151917,\n                3978890638406515286,\n                5081581149863744934,\n                6181936955807580784,\n                3372188069238850634,\n                17854265102071578827,\n                1268076978660794505,\n                4722477313014336378,\n                5471980643922086499,\n                16788648796682094709,\n                13328529160256523927,\n                17816434316065398701,\n                4038311782651024619,\n                8255869964978262613,\n                8890037824421975027,\n                7319879894513022697,\n                15914698902244750946,\n                8857389029776818687,\n                441863541258666465,\n                3208037884158506723,\n                6113734693574039276,\n                264986606662698668,\n                1166237501799711319,\n                1823307447602740420,\n                5025672756710206999,\n                18278689422657324853,\n                4594507497487291210,\n                1280886041213346013,\n                11896598892872950706,\n                5576693076164380614,\n                10907097907235031727,\n                317196941106545936,\n                10598515286008372146,\n                10232665246931238263,\n                16641631582624438065,\n                1996845757059763068,\n                8450189738658666487,\n                16874433980334624325,\n                11462456373743157203,\n                17922058749640783486,\n                10312126789368172997,\n                13340565145612845891,\n                2211332034685909397,\n                6280821632118062402,\n                11495261020831147497,\n                7525751008510944548,\n                16481618138878161375,\n                17687291635686050126,\n                4726039693402439590,\n                6224312974372200845,\n                177270674822437819,\n                12844674102136119940,\n                2765095317735756740,\n                6375785787962152345,\n                4765877337254522185,\n                5699318866607950771,\n                7726266014961936643,\n                10439969907866586583,\n                11215604933445164846,\n                11144874084048847665,\n                16677507722859793772,\n                14926605406115980653,\n                11021418173114133993,\n                18143508384673173911,\n                17869384978881128193,\n                539841771736061948,\n                813906843235746774,\n                2120916504386756315,\n                17563694758070096975,\n                5807011249822640473,\n                12074412278826937750,\n                10494691749052118094,\n                4034710777981084065,\n                12945928140391853828,\n                13460531663356368909,\n                9805968628270501084,\n                8389235258735557083,\n                4653641631812286778,\n                8961436573446073348,\n                6695344158613046716,\n                16832827001219019801,\n                5227374831316662089,\n                5088308882683339576,\n                3279167959625059741,\n                10436103497832123501,\n                2797296687506317311,\n                18305760283738580632,\n                3531912382829235411,\n                8745021258521548248,\n                2062796519113317445,\n                7005506890190360164,\n                15260828944473012523,\n                11736618288708934540,\n                15523033936060000556,\n                9071328583193116055,\n                2949954518191771020,\n                9219149478710608069,\n                1788704922178497999,\n                3917123331723493156,\n                8283987826876682192,\n                3926515941902592230,\n                4576777655155350003,\n                2895291773949819710,\n                5409491793062473762,\n                7827016058731337158,\n                2360244091777092634,\n                17765210336693396066,\n                15413391993237156529,\n                9542656815625824892,\n                9430563399204843121,\n                11559365450247449510,\n                15796909749180552904,\n                62820771556683371,\n                17275496805851130274,\n                6527142162623953967,\n                4324187305635963626,\n                8775772925418898915,\n                4283973075245351015,\n                8846184539722500106,\n                2860502690824226817,\n                1240652940592194,\n                15064048316358894661,\n                15864254034666279286,\n                4098943802367114793,\n                2956682521101031793,\n                1877556925464957894,\n                9589792900125026809,\n                12161426439049578986,\n                6435540582736037161,\n                10575856639119978060,\n                14751225739652781433,\n                3642975302329400055,\n                10213336036038833464,\n                7137807512192531866,\n                15715238576819145647,\n                17891816262406767004,\n                2885759842806217828,\n                10001842985502100171,\n                16889965688337087910,\n                7192241521508241891,\n                12459052609846245573,\n                16045056395445218777,\n                14263408894637697194,\n                6319194484923808205,\n                6887168986137924562,\n                4723017923445345268,\n                8785445940747788332,\n                2221153194351157100,\n                4112058037714640844,\n                16624774310058492682,\n                18155682498135649179,\n                4932684590312312624,\n                6466580926084050461,\n                13095557293811313234,\n                5629819270691955218,\n                6705036397567572049,\n                15096504303120814344,\n                17813708390329054153,\n                2867801270346878637,\n                4428369643259246081,\n                14356128800268363075,\n                2105538175211522946,\n                8157169805154179676,\n                13281934124532911335,\n                721993975496515367,\n                9731311970803693633,\n                17408383560695508306,\n                3661032291356469843,\n                17118601234529144108,\n                14173384340046827967,\n                13956269658151533336,\n                14193288209519401944,\n                10854924829501094491,\n                9362722838007437994,\n                13139075107441548779,\n                53888779219483732,\n                9991228977857148506,\n                11866192603390104699,\n                1903043806364214756,\n                14664090553522048890,\n                94655028324146279,\n                5944941626254245313,\n                3067815658183085252,\n                10088835779690593635,\n                12586879497500128294,\n                17338285387265829132,\n                13546679410630118150,\n                4684155179104389445,\n                17373141188216408963,\n                10683275227724384825,\n                11727464505463619204,\n                16890013009763926299,\n                12256558554118856945,\n                1692369148468240661,\n                14260594858617396870,\n                8079067481737035693,\n                17302479952759473929,\n                3465288033646104738,\n                7033532051975356541,\n                5750806504528053243,\n                16142598027708695045,\n                3763071556050151375,\n                747332911728793689,\n                7125512446937882000,\n                1711762381076986594,\n                15200743445044769163,\n                567070148436076824,\n                11150986733649743405,\n                1751542514779667937,\n                14904426643112052682,\n                16243812463903474525,\n                4313436371286419450,\n                18281797249258270726,\n                13863976627696030069,\n                12604750965802575212,\n                10295616727116267978,\n                7795942372543067322,\n                6713137871239810667,\n                13830865828728404463,\n                11139257890131452244,\n                2759969414377994154,\n                151123411588221984,\n                1548247161690787301,\n                16234894685549118874,\n                13392592243844300663,\n                4341718471344294648,\n                7137644906875460827,\n                5416631993939117377,\n                11693386548832817142,\n                11851058952064231493,\n                9690204938813699131,\n                68528268163302809,\n                13565043622050152230,\n                7983220844142817842,\n                6794808910151851013,\n                2118666482985725107,\n                7247597207626321306,\n                16937693375274789158,\n                10616884815388828659,\n                11696015248644704721,\n                3352478958667054947,\n                3225871086863590754,\n                180230908445925268,\n                6654741577584823985,\n                11710009687907650028,\n                628457965752902770,\n                1735690146666342885,\n                16556237906505825388,\n                12440271636242780312,\n                8713058872068144699,\n                8975441040195700002,\n                10850963832660773043,\n                86339822673122508,\n                4000323666157343936,\n                12142567722725546249,\n                3374710818178624781,\n                6392232680788016964,\n                12790199390015157427,\n                4671003891873822839,\n                4452182512321524727,\n                3905095889403963026,\n                16726139916064776463,\n                3453332349452466770,\n                16221710379420353742,\n                4632551944540970365,\n                8387501246722919769,\n                9326344266173346561,\n                14810846036626389828,\n                7283658938651037849,\n                5813262143148998917,\n                11727805907650385268,\n                9857096480403873519,\n                6356324418997451940,\n                4218579215729792881,\n                10470999063206203293,\n                622196070040738252,\n                17021144211023071215,\n                272053703337182123,\n                1450758744433386057,\n                8397337301039096971,\n                1756739264090010567,\n                14804942979114893233,\n                12762190712783408010,\n                4486114271404551982,\n                13538690353341899530,\n                6182493449368831960,\n                2768435790455158079,\n                8491588540734758297,\n                5001428683933385935,\n                16861055012236061995,\n                10578636081126268849,\n                14449779720168257980,\n                9370646703732609468,\n                476896208068404545,\n                11604128769892258429,\n                3178840918267575500,\n                3407583825966649895,\n                17913378662961900390,\n                1138652617523020638,\n                4702124733398535376,\n                16197108716716127538,\n                16852598869081929632,\n                5020614776073585872,\n                1188708373797737364,\n                13456434315549496452,\n                3798071449732352219,\n                6593816705053129140,\n                8463318160472344568,\n                10114730768365942765,\n                2093191144313711189,\n                12720945689550243678,\n                17481264965133664645,\n                17640221870440170657,\n                3490097599238691289,\n                3624992904734580452,\n                5383687377060455481,\n                10776924742527744182,\n                15746021472289883888,\n                17925392760128571522,\n                12689005861958409137,\n                5231100489367895272,\n                14007286820825332338,\n                2397858260918981403,\n                3320067181759583430,\n                18227252228223404573,\n                18011328143837002368,\n                4798104660333169602,\n                10865877383638846865,\n                3767167656736085179,\n                13252620599128939387,\n                6636747284560413010,\n                13514887050922862847,\n                422456370340431886,\n                9612933469182009435,\n                8572209183721381907,\n                8056048067037472186,\n                16714990476240297166,\n                3520645146861432874,\n                4395550491627332110,\n                9462218612700999094,\n                6214250154185857186,\n                7628194292741759764,\n                3556878717144745691,\n                18413027616459454704,\n                10160691680912469038,\n                13717170760433051685,\n                15180833335295580609,\n                1819382907555618141,\n                13320476638466170165,\n                10422294181974936444,\n                7164181547072169074,\n                4206492057553506325,\n                12633015044784588629,\n                379171732810097117,\n                10351100759422011738,\n                3673330411049649463,\n                15927757725693044281,\n                13690250449236882125,\n                15900551197649269941,\n                18329662994600175312,\n                2110669219011944740,\n                2226752393294287183,\n                1014550150137152480,\n                9887871066385753226,\n                4568683160401484222,\n                10951431797661196524,\n                2312645127290056695,\n                16937439673591720324,\n                6396609076318661377,\n                8389300110486808887,\n                1923677274274786580,\n                3549825163974227141,\n                8566399761898493308,\n                639620030714191084,\n                768228320555967661,\n                8108418530085400912,\n                10272182341228792152,\n                16750158829727849854,\n                4444117530817286053,\n                586462195320680600,\n                4278069062735193163,\n                4273315131401359275,\n                11611787428091079232,\n                11835985289253260719,\n                3096230712379885797,\n                5322239580881209060,\n                11938666223318366819,\n                5060592382016062327,\n                109409443906808448,\n                2380457102117134635,\n                15857731461784222805,\n                6584665638956888535,\n                5947254465908568523,\n                9420786545084124002,\n                4503761263873856534,\n                6641486141146012370,\n                9121700908113990684,\n                9720958769231915561,\n                7003782806520614311,\n                16920307773004245532,\n                12763580883987437513,\n                13231043349317133789,\n                16203109836791501802,\n                698049430375939280,\n                3030494131166195541,\n                10815604140749178453,\n                13804995432448225904,\n                2055424018541357006,\n                17073648888173819706,\n                15463924428711597599,\n                13403700103090470402,\n                16763806955533746160,\n                10509071477142331263,\n                7405199613665848444,\n                1289961083639614668,\n                13019156453931533504,\n                511380020193300140,\n                15833618630547184883,\n                16532434650886462678,\n                7779349734049489490,\n                6380411322746302134,\n                9492908436973173105,\n                7167088077189974813,\n                17396059932024334263,\n                16483611260630861934,\n                9669468321319436238,\n                12712646425834594093,\n                9288405016973860570,\n                11325843021373113165,\n                11258335193384041947,\n                1997545595799365359,\n                17390606419645620788,\n                5130387948734042681,\n                3121742342628196576,\n                6099609462914905352,\n                6524840389448497409,\n                3251588966299685263,\n                12515453442966781968,\n                4351131781828315306,\n                7915089733711494046,\n                8605641240710406093,\n                11102717433954517200,\n                8816805538627940082,\n                17227753413606850602,\n                10263075023716628113,\n                7686631682618468388,\n                10330530590800536028,\n                2587341603576202527,\n                11500396296312301825,\n                13531587115648414633,\n                15808917747546864365,\n                14333112763098420691,\n                14761783111500015307,\n                53964954401492398,\n                16533467491022296104,\n                3096485428305684908,\n                6318844018415466634,\n                7132560604178571060,\n                16428604738409136626,\n                4375929108222206025,\n                10112133284375140971,\n                3256631261503314080,\n                16136845689782815155,\n                15928971771356595498,\n                14645130502697393764,\n                14481748170304871772,\n                1698922547070724229,\n                9468607121868930261,\n                11617214057068823437,\n                1382928294652688250,\n                12680084220201263431,\n                15926122141331194025,\n                7979147799621842755,\n                9803599832824191350,\n                11150566171126503035,\n                11946016594155356252,\n                8452284422264862510,\n                8621047342992105610,\n                8991106617593209637,\n                4607652189428377711,\n                312850746210123282,\n                13020253158865282886,\n                9665527964173507749,\n                18176337504665053651,\n                10689513521305445515,\n                1839607582702602917,\n                13793618456770339778,\n                12156395506174115903,\n                15230345865671590927,\n                4715973552531673115,\n                14606516029379763286,\n                17293771405588962821,\n                16175698567845501145,\n                3789965395433901756,\n                7250432289837425960,\n                2507460993020556336,\n                16416011798948565038,\n                6033312224978543324,\n                14568892906298810894,\n                9207153067892339499,\n                14537938431481818790,\n                16550516704016530385,\n                9907670198667127499,\n                11918889385815695319,\n                5981318855234384164,\n                6303359496211585544,\n                897784439258088201,\n                7533487805017595619,\n                5938457201719040924,\n                10019150195260257017,\n                12026554931880038202,\n                9224513724236448133,\n                18208973061276109233,\n                14240550756243930801,\n                15387974810151313549,\n                193781859214087276,\n                11713954174101604255,\n                1341093990140003013,\n                6012491122871297010,\n                13892530467037865965,\n                1368649256526022373,\n                7020819021722718671,\n                15787587617733723291,\n                7785870968748246057,\n                1947448600658942561,\n                16530328214840567615,\n                6317941331086952570,\n                7139842027589405175,\n                10933153414206777090,\n                9672586073744099620,\n                17228494407277874159,\n                11578033579087247602,\n                15459493510831207600,\n                8222705886823487604,\n                578413881840029844,\n                2972330100500591542,\n                7515621234174823899,\n                6704318956697481184,\n                7539293268516643247,\n                1580608997901534862,\n                1201050878740265829,\n                10170365701874480907,\n                9870363666224664306,\n                17305296184407747996,\n                4224805619364289032,\n                15085837243579345311,\n                2443632602903912157,\n                13046843267919167284,\n                12116351035376725179,\n                263232896451917215,\n                7772071638110042980,\n                16549817644785034122,\n                15257628965480096285,\n                13004189693733577363,\n                3864285740392230962,\n                3468607145721577697,\n                354566527372793754,\n                12925883576993237617,\n                12693175375557728813,\n                622461988842871628,\n                11397527121006480165,\n                12911631110359477732,\n                13101149248297235307,\n                3443924800339223639,\n                11021054325079132422,\n                5789359016899607332,\n                15670032899436160802,\n                17231336489372520758,\n                15011195019101462587,\n                17697169511730379360,\n                6214385185627447169,\n                10180011765464756731,\n                11047248145840743090,\n                2742832730133990272,\n                14029491892088421031,\n                7977004417662816272,\n                14199429721808423163,\n                18279997024327708476,\n                13359704350594785266,\n                18410294947752215697,\n                4900459096393373794,\n                17759944268317835227,\n                7514273237508120753,\n                5036409225635108741,\n                18108376710275555530,\n                2676982762515162946,\n                510220139774948017,\n                9208245069742717667,\n                10376186455595199891,\n                421637325546718875,\n                16791119924695165602,\n                5075099022211468458,\n                12517850612529158688,\n                14010730112031892170,\n                9181830456575508952,\n                8562092376348428853,\n                13106552497603917850,\n                14302339172367595976,\n                3354417171377350434,\n                11375931064094009915,\n                7367612779037974062,\n                17960646160089319914,\n                7765039110674214207,\n                11258859351125514864,\n                6790503465712539668,\n                15367600556170700044,\n                6616796092052086761,\n                12472062233228758417,\n                6844102383328993237,\n                12811249515443122455,\n                5102740036611216259,\n                15944761788498002902,\n                14694830622589958200,\n                2106296585469395117,\n                12001390986454100522,\n                3886258101634881021,\n                7626447484564536615,\n                12121778508662936673,\n                4637632611996699763,\n                284639519767470911,\n                6111767225293430109,\n                14899978058938638435,\n                9492490138059005865,\n                3457376194893217608,\n                6384991674167924954,\n                16479663265444998572,\n                2182180597909020672,\n                15349832040611960272,\n                6995769868581799282,\n                7434433066635564427,\n                7330931577518389882,\n                11026383041313003706,\n                12870325652218422628,\n                1151311929447712791,\n                9598200806509616050,\n                17161065747263888006,\n                6901765437989220429,\n                17524807833762947972,\n                7424089904607803796,\n                10169273845585922571,\n                427683750176118191,\n                16198716196396797311,\n                4234469982734082109,\n                10433113399561032205,\n                8455659057075573351,\n                5339947829324400827,\n                8994757262942082927,\n                16110373093388044843,\n                8165219755821135739,\n                11079951015921397003,\n                17913162205445436558,\n                18307573113704258140,\n                5184334744599569992,\n                8209592006521651537,\n                15233048304519008983,\n                3893904742760952245,\n                12843184579518607189,\n                16317789833580002355,\n                3932965922048250109,\n                39643566078340112,\n                14454778211007988105,\n                11325761588512978910,\n                7326308723838667358,\n                918638912645150633,\n                11749550850384896237,\n                11656774623671896072,\n                4102579533296639675,\n                1131200342214858221,\n                17002635763021940679,\n                12699501461265202766,\n                18366533628748257986,\n                4211496006430696197,\n                15592383694738584641,\n                12132073284414780422,\n                14112124548036073660,\n                640983069936058034,\n                12843837916043035998,\n                12619927090786907296,\n                14878814042191779303,\n                26802691526432636,\n                13542740387876579301,\n                3027951464265029786,\n                16531319427892075667,\n                7433366770688989904,\n                17675108936726475823,\n                12991848794171434707,\n                11308307557943773008,\n                8441361375349434971,\n                16048668185725998079,\n                6848195560782317706,\n                15732631277486546880,\n                8796031012662685103,\n                471880524013342791,\n                2847727284878021151,\n                8909402802655050731,\n                9155393982976367055,\n                5339419398360353054,\n                12394943475850749453,\n                1082481852253596422,\n                2475925758143360234,\n                16780844326338173281,\n                9955442783741736414,\n                16398521725460554238,\n                11754389093333746016,\n                9510081579192799387,\n                10740614081401142716,\n                6751836211534532930,\n                3310216743613517077,\n                4711354618706526528,\n                11761966320912417805,\n                36323519866736684,\n                2431075662700945654,\n                15771975356730131291,\n                14504980176985527547,\n                5551404397884447150,\n                7328632262405216781,\n                6659335151951442348,\n                12904376258123706403,\n                14766024566003307212,\n                2729153030346049029,\n                9776447889426450664,\n                8565088926995480737,\n                12733048698734167426,\n                16140690590167093278,\n                11999311158468044755,\n                13598288633972733571,\n                13732432400180070386,\n                15194135950298716633,\n                13160554968820068964,\n                10539080943199862762,\n                15115912129273478029,\n                17652613656477189074,\n                7952212396658049573,\n                16131569825649579263,\n                14739342068703048684,\n                2756008787672952449,\n                17980612557340090024,\n                4505357043573157185,\n                5886347178459794981,\n                13467166348185532762,\n                7542340141940109840,\n                8604473128836312462,\n                14161530301987102049,\n                7768636854450163149,\n                14487815318986749283,\n                6851630924543230233,\n                15816812718841829697,\n                13309960537373415159,\n                13533823018337269511,\n                4066246092121693604,\n                9157035362257855573,\n                412214665099375028,\n                14477789736289307578,\n                8471884807077804890,\n                5401116457851954216,\n                448871182302722508,\n                11307725734317055468,\n                10916897930231800956,\n                12320324583264666269,\n                9855253221365914708,\n                10341139850853598251,\n                473763070798790310,\n                2738091302514798630,\n                5726660080813664052,\n                4685085520987362,\n                142836371012422078,\n                12594070839012993809,\n                10074822048682622819,\n                12827059438505836814,\n                16625605990012653363,\n                5223703331085192665,\n                9833285584664723263,\n                8290425612857589870,\n                6306954960404098112,\n                9412474111491552241,\n                3143257994045884457,\n                16371722385530408059,\n                155878147658248091,\n                14824551048836933161,\n                6944511999081736143,\n                12540758531163865907,\n                11983135069038529053,\n                4545712278933588398,\n                15077557719097293644,\n                8824726955621677512,\n                9467059989026717476,\n                1832994947759543686,\n                9395963500530779164,\n                10187513723496037742,\n                9614996490866381781,\n                4074827755791565698,\n                12833908036330960194,\n                16292730478901857762,\n                17035820163674794684,\n                989273775053529110,\n                10590449105705689408,\n                2922575348536557726,\n                9097036857789013295,\n                12287791133096088844,\n                11574082336078807433,\n                16687006015927882120,\n                8596744673168310178,\n                8970905056348840750,\n                5517972678784462826,\n                881430805465529877,\n                3412610955059774968,\n                7028178389869167183,\n                5170343795610265286,\n                11012307439076817531,\n                12613254778376420629,\n                4047156878552340678,\n                14789560647177930279,\n                4218958252980142613,\n                6013379809704688444,\n                10780282427110087598,\n                3110875217681031780,\n                1760113645124538802,\n                4510301077917148010,\n                11245657134256982381,\n                3975465112728195039,\n                10147869619910151776,\n                9521542758217967325,\n                9796643369778561059,\n                18438740993593422996,\n                5755122647194246655,\n                13089871854524075038,\n                6020811568278170849,\n                2905460035802413789,\n                5770692989150859960,\n                9121733696504177003,\n                9054740045617104954,\n                6651061222026801570,\n                6979411400071458744,\n                3760933926638598638,\n                16334302020381288285,\n                2057660950359678276,\n                11293316249797872974,\n                11604535997697431331,\n                11921660539545426320,\n                9756548788646446777,\n                7269421896006778050,\n                3975439838039732758,\n                4483475473549910496,\n                11780853832789946501,\n                8179840661787229204,\n                2659883347338825753,\n                11257903019053621162,\n                9583945287877466892,\n                16363933527036814071,\n                1290785704105238692,\n                8655198258069320180,\n                12518299182873150764,\n                7361462000368712194,\n                9733702303272955573,\n                2362863984326388251,\n                14125653338074659438,\n                8452977297932581636,\n                12482787099763665262,\n                14889071888466818806,\n                13718685624353930921,\n                5045136353562987858,\n                5296643588295054890,\n                13213371806126402767,\n                3277278393660323717,\n                5669363365118437907,\n                15016463550423536857,\n                16936344489863263921,\n                2565955327304029560,\n                4796734652908453706,\n                1378655232854232950,\n                9591923038316868621,\n                16194271618909991898,\n                8523814065658657216,\n                968783876319889044,\n                11876875087504947472,\n                15343430958924511022,\n                4726016088940609325,\n                15814602580682745621,\n                17553495950903097582,\n                3845404925865098583,\n                18216981879371013309,\n                4102006890010720614,\n                15988113496959934091,\n                6019266456198657999,\n                11837451541533231967,\n                1877408958200970989,\n                11155878481768284249,\n                16966216363889316426,\n                16449662703095636488,\n                11722657415321325203,\n                8151686270422518591,\n                6829105588528021796,\n                5605072424730907975,\n                9610630778445319623,\n                12490688233524207364,\n                15924383595417258143,\n                6293909456050977691,\n                1520031459958370315,\n                16878056482786965582,\n                1567491557266512441,\n                11553059083075601436,\n                16588286805077499576,\n                2831700015193252058,\n                9291679435178297105,\n                16696183961702972685,\n                6110717331497256774,\n                3508641981673281301,\n                2888222167255453397,\n                6382434826249612462,\n                1615495003744037219,\n                3450690972855989121,\n                7373699525385823603,\n                1487214282399378665,\n                5054239246312770486,\n                6325543252810070667,\n                604916284274232643,\n                5705249803789781860,\n                1347389337137481378,\n                17341491803371701023,\n                7562092053824458983,\n                11528860291431916871,\n                10058885809804159773,\n                12028682695619691748,\n                2072309850975849144,\n                17510902039090560383,\n                10964691654809950146,\n                8557150693328114885,\n                10018287661176094357,\n                12067793619240607034,\n                12258652923874874737,\n                14315661805556678059,\n                1532344907755129707,\n                11548306890701017011,\n                9836569326549702085,\n                13196528743664879413,\n                16910466377189639446,\n                305247665277886260,\n                10234652344969601959,\n                6426209661333831948,\n                13316514153882647236,\n                320668129269757278,\n                9513807142666087825,\n                12132502292274229629,\n                7907062113630478532,\n                6769256578404078947,\n                11077216337588272062,\n                11192173094112274045,\n                8665424743913923338,\n                17273052641666860613,\n                8242738008086379196,\n                13851918804734763571,\n                7049674271488004214,\n                1410604294587433641,\n                13544384176158464923,\n                12468330754572317265,\n                1317196613823108318,\n                406832464837758362,\n                6039154084839734004,\n                1995025881371264773,\n                15399759218648596543,\n                7323767619167721842,\n                14228968351368149001,\n                14556483677198851362,\n                10822573411785744110,\n                13457687797488671733,\n                15113597365244568644,\n                5830040833200595947,\n                10782120448577939853,\n                5923233368326767564,\n                13565433709591402733,\n                7409835447323460538,\n                4942580795960776301,\n                8068857330020361381,\n                11063008871093537743,\n                6583328726807166886,\n                2194893842926463044,\n                9586490095482756942,\n                11811119386143060256,\n                3644614927094824958,\n                4762559862573353606,\n                7054841812193239255,\n                104169344287246978,\n                13956225391862408166,\n                4507288715283113798,\n                11772996098884686986,\n                12792586168475881829,\n                15798457727837504001,\n                16896795677207949298,\n                10265172010623416483,\n                14814049521182301273,\n                14251567652536773005,\n                11041033214099412656,\n                6589290323087713529,\n                17080306026857684487,\n                8536449894500168140,\n                13538904949191682258,\n                998478434926587432,\n                14670273496850215516,\n                15311327973305354729,\n                12644104051633342488,\n                12970733262467631495,\n                4625272733914046269,\n                4694472538276404068,\n                3167371560249938056,\n                12856489429820568743,\n                15490218655488023802,\n                16928081564771690940,\n                8200145788070169286,\n                3346452930233714534,\n                12795482436352374291,\n                3314315705851242852,\n                3285152211139935017,\n                11224563416094698786,\n                9705270177443534531,\n                17644295182363680941,\n                13520301373099144288,\n                3541351715009433425,\n                16020276637771846482,\n                6027464490277968416,\n                4251343941648935652,\n                17763014962498696031,\n                720132515041512177,\n                5173394266280593900,\n                15204667210087004583,\n                17335914961708883300,\n                13218634015062319702,\n                128827822406486046,\n                13559392235200971420,\n                17252636495073021415,\n                750007296061102031,\n                18254099543935170871,\n                7509241234704231102,\n                8157193578702246807,\n                10298529352072110821,\n                5298418177375924856,\n                4741852588831255524,\n                14527267204533561544,\n                9095259534397569417,\n                344527310846137539,\n                13247449783957233078,\n                2586644247732041192,\n                3100790169250176954,\n                16510173867908259851,\n                11333281937378448547,\n                10849352377567806999,\n                18082377466933472402,\n                13561723472079052715,\n                14547157815982897407,\n                9391369342410485871,\n                2348830231178979433,\n                16863733530713957956,\n                18119733445408743443,\n                13725121556809406883,\n                9229975878895702895,\n                7401016155946807916,\n                4811692959864213177,\n                6237359194264984939,\n                1904440073749912075,\n                6353600963009324869,\n                4984137724622228146,\n                1196090958128593834,\n                5119707990981594180,\n                3310978073014066771,\n                12983216966379762511,\n                6612762118768660390,\n                4003198331951059920,\n                6385796970903716569,\n                17680686381236190132,\n                7090591178254990847,\n                13123476457069922276,\n                11991645307762636710,\n                5129610078187868363,\n                5604361132348700067,\n                11043762682351635495,\n                6391120985682487625,\n                4455513730428273542,\n                3762654197950669235,\n                9310420262887992163,\n                11993439152830872164,\n                15439986350739535069,\n                1488229606606016585,\n                8189570287966130481,\n                16920767496097942040,\n                7797006069350129228,\n                17531953262576833935,\n                17024439366185018969,\n                8083356010952666614,\n                6837066330579419154,\n                6443183984423798969,\n                4776996086855661713,\n                9156255850041051387,\n                6083831993070398816,\n                14543764421371224439,\n                11977571598909514982,\n                10188060030334373973,\n                9449009160086154971,\n                1300044225109284268,\n                8825712025626564634,\n                5510762923192959602,\n                7324962531338046625,\n                11942013042939202021,\n                13598796371758253088,\n                3794998887633576199,\n                5084084225782194038,\n                15889660289095533051,\n                15428522601238467679,\n                13696067867927948600,\n                1072542240072425197,\n                9785760286300726328,\n                17624535067298229622,\n                3938570677885383673,\n                3705077412606219929,\n                5340068085943913770,\n                4210056340846145048,\n                1976665594829638831,\n                13311220586145473347,\n                6943938959824844891,\n                7268540691149845607,\n                4375885954089016506,\n                14963703931344653483,\n                2580585000938123597,\n                1068177107148635952,\n                2341910556569696351,\n                9142288039937977251,\n                8517576956327184753,\n                3376248516190748921,\n                13301443214809490744,\n                13173593921898127720,\n                17359893842944679338,\n                7047222128454518811,\n                5947406210583265494,\n                7833766002049023813,\n                18234948673625328162,\n                16320032712674678534,\n                12642441645902018157,\n                16283613144322847005,\n                7863579138098504089,\n                6035051266438089663,\n                5453172248583632847,\n                13775470103081167926,\n                1182333285767268205,\n                10495826772905540632,\n                3056962127861644896,\n                3638669906264037789,\n                11198631986907530450,\n                13541149168510941603,\n                3250675262588623536,\n                1880073565717482485,\n                11936216765079705804,\n                7530067836231811508,\n                16311420158606635425,\n                14900155531445760709,\n                9999132967166761272,\n                1476154866153451041,\n                7195014637072196640,\n                7248062023586150152,\n                12914546489578466976,\n                16344645330454865081,\n                13063707322424725098,\n                15370611307815629185,\n                2118132721549701162,\n                14789791523379164567,\n                13011177800824348207,\n                18047963884795850285,\n                13689837669785098672,\n                5906277653382226335,\n                2699555162272597747,\n                14303717239113776133,\n                3323572003892592160,\n                2809044788581830880,\n                12842135035209068787,\n                12962493426638468571,\n                7435779585695058098,\n                677266868482172083,\n                10678064418979058702,\n                10945593620822631517,\n                8023058850263770330,\n                13198960821944542699,\n                11380271889111358356,\n                8834711603621437912,\n                4878802483786297049,\n                13441769216931046849,\n                2621489868509896160,\n                2739596448875968624,\n                18316605028815878992,\n                6393166579696267066,\n                16501151485480928243,\n                5164267149115550765,\n                2594692795895679355,\n                14280335185447698254,\n                4970220064329069703,\n                12700511247281457031,\n                9357661341818532747,\n                5976227213729484842,\n                2603370613961010712,\n                12878876453986011658,\n                12614332416265768442,\n                11711218014924643648,\n                10655032017324143953,\n                17992359291438428544,\n                2028340169188763801,\n                11337597956814839013,\n                3790580704158447112,\n                15661080312640132051,\n                5990952720662828532,\n                2238062688033035456,\n                7214374085319154262,\n                6225683889287881657,\n                14352811622893565131,\n                14441940256427869428,\n                11264789359569297809,\n                13541671887968904175,\n                8127321364325418809,\n                1617127834649530192,\n                11585884571784117082,\n                3211445923374162685,\n                17806365145235708527,\n                14310538800447604307,\n                6443392190904066779,\n                12304012177210398685,\n                9644770647148205176,\n                10349883319707014538,\n                13335242320392313944,\n                11550748494455916510,\n                14451727464612357396,\n                12354315710763337118,\n                5654383747200879937,\n                12534212795765636178,\n                5562388391253840440,\n                18294236533364599656,\n                1155120808307866205,\n                7354961778452510694,\n                18411509148244472731,\n                16833067451811570610,\n                11664219918607046336,\n                1931829024033366436,\n                9466235535733377083,\n                16125981341055192255,\n                13123158579309508422,\n                2811914968022899296,\n                13666576380287885316,\n                12073873146611787542,\n                13976563976935754757,\n                16819184991876208483,\n                7126372516019046104,\n                3771351679962818186,\n                14749464410272499350,\n                1158403298912255932,\n                2704550233949493414,\n                2361919431011664920,\n                5147560855044821678,\n                316960590350675551,\n                8956506393667806523,\n                14816316691312040724,\n                5483483435418414420,\n                16492702091910529628,\n                11531197856172089811,\n                9119688446381120307,\n                9148465870444231525,\n                11348956949863877257,\n                16515747438741224650,\n                14748627773020492829,\n                6792333258618815286,\n                12745044341734710216,\n                9118601693019210121,\n                3426576167844415246,\n                4516979855142897567,\n                18383203113196616305,\n                6037335393642080610,\n                5178029553332071284,\n                120594988188384758,\n                16911068593865363851,\n                5611330513352860577,\n                3672922004740508910,\n                9348962843954154258,\n                13167081398063848866,\n                8662579917294749869,\n                7714235959241362618,\n                1992168626444259154,\n                2892890698408203389,\n                4458208962709454498,\n                16006038729069481615,\n                9254965750786898182,\n                9178915422232682008,\n                7329871300650615008,\n                3409678840041114839,\n                8437730364512235388,\n                12654053093050306243,\n                17603379767897285990,\n                11140578823362012333,\n                18400373855086378549,\n                13179220706346381456,\n                9393189516096637793,\n                7962379756613380226,\n                3887762359860195719,\n                4702005148801552936,\n                13554138609046523902,\n                16949160381904484821,\n                11391648750970778464,\n                3884921049575088732,\n                2209098818625079997,\n                17799308759029324494,\n                8498222108115834352,\n                5958053849320451390,\n                2912489977852727908,\n                9002784252893780496,\n                9103973893872873428,\n                8800570704285521553,\n                8871184059044310741,\n                16063400495158915832,\n                4031307968282193036,\n                8573254083908951390,\n                16828584717166299815,\n                6494527269040260826,\n                7249207279315565170,\n                13665554008066255134,\n                16839236341242902217,\n                4123411447375871691,\n                10234357340093040168,\n                3518390908608069874,\n                1349715014789845667,\n                4808798653471270523,\n                10095338955926329757,\n                12695489128540790910,\n                16406780457966718375,\n                9629301538534411032,\n                15498997222980997073,\n                14953211317262356769,\n                13024285896073029281,\n                14612862358802352485,\n                13035854789120349150,\n                7106552057026833281,\n                14174041880363702304,\n                10636381469539675255,\n                7187203466667480841,\n                17084717625060872520,\n                14126252750523939037,\n                15698822748718907462,\n                7397904980198721162,\n                3690934666532247692,\n                15065052457896220534,\n                18426160025856536769,\n                8825186243264577791,\n                1029026778404309644,\n                6950954458719738495,\n                8771914568967577350,\n                9728022865849579333,\n                17765239852650572501,\n                8343956648157842199,\n                6334778100080475126,\n                14664915370166297479,\n                12941375852754193937,\n                6405436436050091550,\n                9909891363532277572,\n                17675467189601777836,\n                12324897459248787941,\n                13981335142409795938,\n                17744674612593350856,\n                2757587566489447009,\n                8956578028983169012,\n                17018240562727015214,\n                16391639968111798359,\n                10795774151465209457,\n                2093281970351304070,\n                4858229909673020125,\n                9933967343419708401,\n                6016509820559456727,\n                8502253989054157587,\n                1829270427581251166,\n                15709494579608995279,\n                8568909950760020667,\n                10892820698227375197,\n                14181785622385373392,\n                1741244869916907800,\n                5584342639358924336,\n                10920058455798795209,\n                8773147161499562392,\n                17372651285045475439,\n                4317270331835178992,\n                12072221230432227872,\n                5409998193192839065,\n                5774604676764375748,\n                6270673186535390929,\n                11593578005123149455,\n                1350291030727318811,\n                1734041789149423611,\n                17594245397221493182,\n                10230281830065256754,\n                17395251244463936984,\n                6363273717700984685,\n                6898868518537597264,\n                5078809256797027276,\n                16014780232233692324,\n                12698021273486013402,\n                10034628326465398981,\n                803921083181133037,\n                15053987885932962839,\n                2543409146477711493,\n                1443575144201918042,\n                15527634810280511429,\n                4846659158470140918,\n                12183993101313012462,\n                12953651110928456969,\n                15038003468538497849,\n                16252394591537250522,\n                4193562522090296620,\n                12800591763579590396,\n                15408603400942806170,\n                17682640208554596681,\n                12409260763379977486,\n                9315397818726387830,\n                14193643034683668324,\n                16508104272720261755,\n                13905815394730317134,\n                3679293709974358468,\n                5907121386159753765,\n                5304769534414875015,\n                18444287322445993596,\n                16494909212649576365,\n                1411980536871151577,\n                16554121151776992767,\n                10463210072047518059,\n                18023249470213998238,\n                12383793606215823679,\n                800485989566329537,\n                15071139529581604306,\n                1895628018455249296,\n                1105126069974836026,\n                663584933815778847,\n                3312928249076628720,\n                16646825576352631842,\n                12151072254529924642,\n                8642785126263747138,\n                15111584853907028239,\n                2776308895820674677,\n                10812673714292641746,\n                15054903323219264732,\n                2933094921150563585,\n                17830062919092998452,\n                10432330036767081552,\n                1033494976738144353,\n                9761049718456631119,\n                2978550270506139328,\n                2266577450295768406,\n                1214959603409486419,\n                4338607014040436,\n                4115159162283844446,\n                16888561205519247430,\n                4412890126763454080,\n                85232547048588047,\n                9970948529228850752,\n                3713393126801217778,\n                10760802738778841380,\n                4895931449000106045,\n                7255762665740428559,\n                335936537100116164,\n                17662778773720603199,\n                12685690660905184006,\n                14808811012699062151,\n                10663380197090780332,\n                7067049757688041329,\n                5878922448066220307,\n                14490189620281922843,\n                14473260627169887886,\n                14832232348370447833,\n                5951438093661647765,\n                4872796166881199876,\n                10429350570401478982,\n                15251172935852223950,\n                7325621106097392986,\n                11834629549993290294,\n                11569303197879748368,\n                977753391334101798,\n                6969686311950446853,\n                7366200137172124620,\n                14212998724743560415,\n                8081354270400804456,\n                880037272912518632,\n                380852277882293501,\n                8947498467697222234,\n                12757931014561147509,\n                667810441349799809,\n                2059689120439565076,\n                4750342010666522618,\n                12492546560830555305,\n                10465223395020225996,\n                9585389043436680319,\n                16512031046174235646,\n                9200703296926083957,\n                2032951915453711444,\n                8002381174072382487,\n                2389280604724196215,\n                5721524692632905547,\n                7647110976590069211,\n                12059178411864741586,\n                11975912934455308497,\n                17753420811972470476,\n                9192795740173474360,\n                12105166740957629248,\n                1250032644270746132,\n                4765787287696278663,\n                13422669569705597563,\n                11373393845567526876,\n                9153761787497611672,\n                12030450058080806969,\n                16537144145501712177,\n                5983397454957073922,\n                2683673672010015032,\n                3861849825629132671,\n                12629475949497494729,\n                9966234113604834798,\n                8466461060632654110,\n                3335857898642241962,\n                10682117780482341111,\n                39787149161941136,\n                5109208035333406420,\n                15684027554962652735,\n                11748970404336820351,\n                4095159288133322954,\n                11402790565133565981,\n                7401785106763668233,\n                6248303083190138658,\n                8738855753439299071,\n                15339296752899687482,\n                3182643107247815384,\n                9378566535341755855,\n                14162009846460499887,\n                4109114270719890973,\n                1511416153435046138,\n                9020508522805341634,\n                7477142615652523025,\n                18385803953807265839,\n                2546195602154738889,\n                7405815335061777589,\n                669094957884330982,\n                6056073383962448124,\n                7353716808540962518,\n                4360012167404246482,\n                9748894070631625514,\n                533481526701689863,\n                10374030482918918166,\n                8591056344610511021,\n                5753611323076772742,\n                17682325790000893453,\n                17410739240868104811,\n                5651721564405833200,\n                6771155463622294161,\n                16102506172900055409,\n                3922155114242412611,\n                8047195046803908182,\n                10181935025035061310,\n                7790459581343029499,\n                12616035204180788696,\n                11350000801651108812,\n                9664257517083996508,\n                6877290837507516646,\n                2900668296021062883,\n                5478674374212655343,\n                6296162153147759087,\n                16234745308754151636,\n                7633277882818614712,\n                12843201503731712898,\n                14050083812260020416,\n                95836250787434633,\n                8997148048216279615,\n                5687865929885690952,\n                7684029056960298539,\n                17362423790832901707,\n                15489463223618769754,\n                489477444088932230,\n                17185715982289417959,\n                11823522798262762160,\n                16827938740128105724,\n                13257410922007807743,\n                4679309639860400639,\n                10164917239224603264,\n                7304922446473936277,\n                5597481581945817575,\n                3820424595621388213,\n                6884972150866725771,\n                2694324376629657414,\n                16833520400918984369,\n                10912563532735352632,\n                7352008235482304863,\n                15885791964406330114,\n                11790453162438620892,\n                7239285021069261812,\n                10125071555494474444,\n                3796211625840968848,\n                193266766691985397,\n                14792644085266904226,\n                12987152514130686235,\n                9436744123646480376,\n                8251406129814681521,\n                6271920831800751835,\n                12738844182063426283,\n                15330691163818996222,\n                1166041665727565335,\n                13315209544138143871,\n                2216677316767409466,\n                12690036582164080137,\n                3031307738126062683,\n                11944440105997765289,\n                2026188631449062025,\n                9212773879860499293,\n                3341981308024472580,\n            ],\n            &[\n                13169652012768583147,\n                11662749290968821290,\n                15540028649212863382,\n                15222191772599122928,\n                15852211273603082347,\n                2960464712590969339,\n                9805532347048503730,\n                11483156842014743008,\n                12223751000089978338,\n                2069577308821362462,\n                448020966454441311,\n                3493610387626232963,\n                5182130948708681868,\n                4456536535034921689,\n                14139535083059739910,\n                16341604127053129275,\n                8476750032358968964,\n                10942274856214572646,\n                4426573651999058804,\n                17958371714565221264,\n                4238987860855800392,\n                14450925264923938948,\n                4364481289454625563,\n                13074790925168694865,\n                17725186031491616550,\n                3252385755044260850,\n                2489691844698347065,\n                12584453984545921259,\n                16484939371755776909,\n                17591699265602016514,\n                387926126025483991,\n                2463760292646247776,\n                1563580628888369628,\n                12118979090065897855,\n                7930230430393343357,\n                8834023487181578700,\n                3705061516543521950,\n                4053176902619603587,\n                6269266280509284877,\n                5236641881717368169,\n                6899670106034156441,\n                12840225294220778634,\n                3029440279850048735,\n                9595166473221718273,\n                14550471357175468027,\n                1255830945916836371,\n                5122133954630663971,\n                1502740582962090101,\n                9086275497101221342,\n                5421916064800438697,\n                2179464833779544632,\n                8247585817871008274,\n                10322070671895980987,\n                10962237209348590213,\n                1167315820290398061,\n                4563405457798620948,\n                5324869835018392710,\n                3941515430275954463,\n                1740094742017128848,\n                6138471019874045522,\n                9176213051434147108,\n                12501904812453849864,\n                11388325168842467058,\n                17687408972570957542,\n                4497137255970523312,\n                11770269946165024215,\n                10156397926378383551,\n                2019377424484113393,\n                3590983554593693717,\n                15657928449196312716,\n                14894403732533901822,\n                14625564293418317463,\n                17710716015671252818,\n                638852277383858770,\n                13800670797826096071,\n                5519007738268375392,\n                1013914690263468265,\n                13249504241724137521,\n                12893315643913486917,\n                2437939332985629386,\n                9866735673756110580,\n                7894145839618709904,\n                7802203558085957599,\n                2394814001366981818,\n                7648858197866754106,\n                45932857419714984,\n                9659675215715090679,\n                12803466849037463477,\n                10717587339591792614,\n                15131328571226415781,\n                17805628124155724278,\n                13655343682572989974,\n                17362327502804463995,\n                1075287460052064029,\n                2626850396158965217,\n                6885136253881452991,\n                18424853270962528365,\n                17198461501972637926,\n                6379806426022159044,\n                8783653573177405838,\n                11457364326293914599,\n                4889546163609369345,\n                8345334679410921999,\n                8128212263869118047,\n                5243835377297724594,\n                13077589216209892913,\n                14947690960428829294,\n                7468326754846892750,\n                8665069680383178636,\n                17267364262089018920,\n                14794644088627434581,\n                5781944628494317535,\n                13467037542503882140,\n                5504287258083448304,\n                3101706185952735851,\n                16528687565738693574,\n                6853101285149030710,\n                958150364135525317,\n                13159192403688468400,\n                9000130047394330226,\n                12454106782612240528,\n                10410037892467703265,\n                2755063393447593674,\n                16909229563067880679,\n                14030067308250726680,\n                304063827283258286,\n                18020451823918033658,\n                4591035690657100956,\n                13162350837887011458,\n                7701399978207767086,\n                15815279200816529309,\n                15597387052720630170,\n                4740390593486726162,\n                2909712595092459460,\n                15729877265226222100,\n                12096570103612063938,\n                13702753332858235272,\n                1411835182384377603,\n                17487917594195511154,\n                996305544975114980,\n                12929066524383774152,\n                16956610067055251962,\n                13012122099231548957,\n                14395689158572846177,\n                7935429077563080059,\n                17542764935243101497,\n                18413828249925519615,\n                17271321257298840331,\n                406766324155888956,\n                14818331828215117974,\n                8187386216945380849,\n                16792638575276899182,\n                6540004189057298818,\n                465689003663102769,\n                11974785539062893556,\n                11523099967255714584,\n                14591636912283935445,\n                4871757987380755363,\n                9308130069290886865,\n                10612219179153523310,\n                5420071244571425562,\n                12724302122592532888,\n                5173545157589181140,\n                1429324130148847596,\n                18414282026575416657,\n                1721766939064217260,\n                185288146264311331,\n                8027581238524003859,\n                12629121378225318691,\n                5422022678890177669,\n                6300007666394297907,\n                13771277516427401556,\n                4461063943424152501,\n                5814271695863693557,\n                9833762282568603070,\n                5534898830643720899,\n                11414581203473717153,\n                13252208296859650317,\n                6070377927034194834,\n                468982118171070321,\n                15569817073538385644,\n                8515954578625472255,\n                17703147536676285546,\n                2713926565223832109,\n                16501613896332875878,\n                12360649233716580846,\n                6951122318765494287,\n                1255018572838364315,\n                5022530899188934293,\n                14471021290055621346,\n                3965972119993826976,\n                10914640319991729939,\n                4671893019190076511,\n                8132288757883741990,\n                7379730619550447967,\n                7082846353163966035,\n                7749284037330602929,\n                17090786448482076935,\n                3623093583024522445,\n                6775174256836032571,\n                5932859643874401763,\n                9263718069255818484,\n                11941172789559596258,\n                7505495305758940713,\n                8374557854631657796,\n                5030384219708396008,\n                3609081759463861677,\n                2444176790044307758,\n                12883357531875110193,\n                2545675590276006076,\n                1091049428613676247,\n                3001645527995991696,\n                9613284625002680960,\n                13486970893816936976,\n                11564610387350917328,\n                7838720830134816136,\n                3368189672511472263,\n                16407993343222005051,\n                3965440550685537978,\n                4708478243468404768,\n                1875742626798710446,\n                109477476572266497,\n                9185060711428219960,\n                2062557879153655855,\n                15504010890019002364,\n                1436468774610332740,\n                470895386030379118,\n                11192666441535176072,\n                7094623340817246353,\n                16041820192281853667,\n                5048179711756437977,\n                1908765243120848557,\n                10810219542319634593,\n                15971282719319513661,\n                8395180060853137311,\n                17415231760777435363,\n                10489441496511966940,\n                3213813993411776195,\n                13309643264471443871,\n                14152370013037392509,\n                9805694808649718454,\n                2991106746654603900,\n                2279780759950444362,\n                13989789024965052794,\n                11942900996372546394,\n                15051646099368945987,\n                7583267444740224154,\n                5192555551306992142,\n                13216959612015226558,\n                14397593124921798192,\n                4374707725758052604,\n                15529039788482882168,\n                16475619415913302762,\n                2649655538625316107,\n                11899566009797061232,\n                16892018353302708322,\n                12364166218684092426,\n                10372683350152669575,\n                5328477050361662527,\n                10949313792626687170,\n                11924230090558408019,\n                636095257275314085,\n                10210914536395617961,\n                6515368615710817299,\n                17001040330117317563,\n                4519581466335837391,\n                12514298524110577503,\n                1744739741016504912,\n                9689951195577973993,\n                2774540351629210180,\n                7646006525601223889,\n                7530479442266342421,\n                10538917317906671989,\n                6031253606146099659,\n                4606167752034374890,\n                17763804757970320617,\n                6871166461842469695,\n                3069238346134678776,\n                6898492556629873366,\n                18330913680324098797,\n                11469514731644700404,\n                541525751461369940,\n                18096353837092553451,\n                16390355202675291281,\n                11980660197830118439,\n                15349236833293249382,\n                1901608480726107605,\n                10754477505423276549,\n                1780265741680781169,\n                6204486525934807168,\n                2675596223932028138,\n                1082656654749778403,\n                15313246555910578407,\n                16597928615331243076,\n                9259667019969423039,\n                13966308744186245944,\n                3711817850123753976,\n                10380302371138242940,\n                1102076039759449071,\n                1796134829015781040,\n                8320143967311972799,\n                12603759772660781109,\n                9343508021191710450,\n                11833581848018650785,\n                5036078561764059265,\n                14477046704375156568,\n                17958581882146395247,\n                6312863763728381603,\n                5890775652924120757,\n                3024100139720533291,\n                15594980805126031556,\n                9929023026443104564,\n                6003618257535256748,\n                10584762467178432077,\n                8070692469310128137,\n                3448506857138757663,\n                12067250229870443464,\n                8289617863280099780,\n                7705347156484755083,\n                8239333463449775936,\n                12953560490361273923,\n                7863343728067574413,\n                15499170354027597711,\n                16789849673988523596,\n                193554686279189480,\n                9324166766841362509,\n                17865442848307712220,\n                4017570072096420828,\n                359910874540192895,\n                14283136222667718022,\n                15545842610688758167,\n                9161703351540143861,\n                10856046010222875891,\n                270665191423043189,\n                15816860058997167317,\n                10604344774996324885,\n                3421439666836669232,\n                15362489920565158049,\n                901986887674190509,\n                8102011985696643347,\n                9831189590417175739,\n                7694208525827500802,\n                17761503253302918415,\n                16843825659097088549,\n                15968418888658984723,\n                13213298841864639514,\n                10768746828601368994,\n                15843374988242905966,\n                10372481985078119452,\n                7145529267057724453,\n                588445411774656377,\n                6907651744680403237,\n                13729433346623178186,\n                7466282812151723072,\n                2397976897839660773,\n                3595288154116844222,\n                3771046205661211665,\n                18292138992930644589,\n                5076094080207419189,\n                16955129624357257007,\n                3929215337030354093,\n                11057894513779502294,\n                11863471976993485758,\n                9408615240131003867,\n                2448439901554368107,\n                7669176413900589628,\n                13955883899642443946,\n                3559761514651432863,\n                5999853120304570098,\n                2807928142993089395,\n                6880972979489023884,\n                8540438276045396759,\n                13336393887543928327,\n                14948024915319356336,\n                754486632845103448,\n                16252590658474672770,\n                11838852632524903679,\n                16841746824793599992,\n                4866584459095974245,\n                13046184814853980498,\n                8710985684981006226,\n                2355658489901240093,\n                17682251256218590491,\n                12738885399031396318,\n                3641463259326479601,\n                11573802402437143897,\n                4785854649163125380,\n                17654700608592820265,\n                7689738254866306083,\n                3911334929659733907,\n                3805687817679677472,\n                3372180752527728873,\n                12516023017017683246,\n                6541569134387572029,\n                14932792460356112158,\n                274079842264421275,\n                14741476297422044947,\n                7640237864595124592,\n                7990415001403780690,\n                14485175485850127358,\n                15701126719940798119,\n                7497786401585040464,\n                2046586308065249596,\n                4234230752844127257,\n                3490034085431124756,\n                7410205974894450493,\n                13594277608316567296,\n                13163068385450899386,\n                6911330603633557461,\n                4165273348787835236,\n                13196815825235476993,\n                15409229411685315073,\n                4238586327560550200,\n                4274172509763128574,\n                8233070080684386642,\n                1152981557203525396,\n                2258263369774438742,\n                16860590243592954334,\n                10642146327347114407,\n                16394076595581895042,\n                3547145813374894294,\n                7303429257652622247,\n                4599869911214805642,\n                1470127264048118954,\n                6553553520469198052,\n                624221776008514758,\n                16024993613079197687,\n                12072685851575104500,\n                4289561477780298769,\n                14522030035108027997,\n                10025959010474970695,\n                4338629041423254482,\n                12668451231751642706,\n                7041673834301289685,\n                1101300709714299914,\n                15830324192849592102,\n                6361267392222383309,\n                12743724653827284764,\n                13913765213720067888,\n                12472686594479717483,\n                17041667280903689118,\n                12612588174971368395,\n                4625038945277105759,\n                4288983616264520473,\n                13257170061268337928,\n                15378358854815534796,\n                1307879339751355693,\n                9045256242044980161,\n                13066137780318064542,\n                17483698129188252816,\n                5537781126683250458,\n                15814088167067959984,\n                17124111106622331645,\n                2228813159198082553,\n                12771677329276373795,\n                7473600359686104579,\n                10172401847101693206,\n                8817322474066906889,\n                10002046533039894942,\n                18350636570159627372,\n                2608194133937884904,\n                16496103406635747044,\n                3203166370447920771,\n                1416097169966651887,\n                860034031549905008,\n                15435212006888252138,\n                4982756044520683355,\n                14527835149012332766,\n                15648655845991912781,\n                15220061209366144565,\n                10713592116389348982,\n                11856331444132914701,\n                13011883287657858557,\n                18375660967945668491,\n                7611177834315648116,\n                11475292136381607303,\n                12142625427672665818,\n                1644376245508948388,\n                14986147846200059747,\n                10358191212479538383,\n                2124663276626493099,\n                15025396046176607689,\n                7566356641233415240,\n                3834259550197202335,\n                7422439917941038432,\n                14335746041650957139,\n                11010643115481291768,\n                16639917992723217687,\n                3400935192914355446,\n                6526469202356090658,\n                2911450085827434145,\n                2592450403666061908,\n                6573976403851247795,\n                4285219873414520276,\n                15329532146725863869,\n                6799347789229688901,\n                6639341479260471078,\n                5137054100466749121,\n                5102420602612942914,\n                12454937665202983967,\n                12962650067948965377,\n                17483657740097839287,\n                12223498331603994543,\n                14079145217780475833,\n                3310333423646124225,\n                8148231670879135605,\n                9541038636961784750,\n                11089617618703446533,\n                3560209342825276058,\n                2574634823119268479,\n                2588311243176990131,\n                15013509191556503430,\n                15455072885984268053,\n                13986137485131324765,\n                5720067926322634989,\n                320358790111393789,\n                15410939285136639329,\n                15697272961739331244,\n                1355846111750777085,\n                2546959351276906905,\n                14534695021313396715,\n                12100942362109396400,\n                1909839808518887758,\n                15057164163203198957,\n                10816292376571145141,\n                17932667027515587541,\n                8894763284691124395,\n                17376767493810914651,\n                1054656077023869452,\n                8186894411081110112,\n                4918609723063820894,\n                10472223930221187526,\n                8210872174259857628,\n                8260857529094096436,\n                11707883934354468821,\n                7798711246011152830,\n                12313898141945763999,\n                4092899057830195664,\n                12768752632246510730,\n                7011904089799177666,\n                18269846218072729005,\n                4472126139715717850,\n                7263280326862818361,\n                4617033187864299345,\n                16062484525314928005,\n                7764862313171817272,\n                5507098054488704246,\n                15417948890339509732,\n                3199184308759380889,\n                12873647785813929264,\n                15851634423390314715,\n                3379562369756927370,\n                2914796073219663247,\n                9453518290639493724,\n                10389507097848983202,\n                6987583823829734148,\n                5644521590882572085,\n                16385036288302112854,\n                14202037992186130818,\n                1662729350231436066,\n                16086866498209553899,\n                11668110277201388817,\n                2581723866463834707,\n                14466562150912612524,\n                18444381539786477861,\n                11792751584642451686,\n                644172128540161319,\n                15714856399314491326,\n                6336413224068482580,\n                15648040294508822482,\n                3581892413107868745,\n                2087860646799841458,\n                12928312782299116049,\n                4630539989871908829,\n                6915603518697601787,\n                14918733616941773093,\n                15087665207194981362,\n                613969264471068110,\n                3544544803540968193,\n                5220360717428049381,\n                3375260723217895506,\n                16778447987047186697,\n                11894812810172861433,\n                14542979312432827779,\n                13561316753657099179,\n                1968473618327458185,\n                5456934299993876358,\n                7469735400543018284,\n                7068657239043349097,\n                9254040800524479410,\n                5214107275553666760,\n                5001330682797736624,\n                17026132790954295091,\n                10969354337912897232,\n                869351389198733586,\n                9574587810937905907,\n                6923373747285449001,\n                12719903474522918771,\n                12250857818862900982,\n                2153256573644871951,\n                13709729097688338391,\n                2899377834668376960,\n                6841869401787596550,\n                10339715141881541659,\n                718655127116157511,\n                13741406681906111321,\n                15392288868670671619,\n                17545786767738322758,\n                11089794771839702758,\n                219094231550242583,\n                9674358307241496741,\n                4002620491443309348,\n                8012290324302967070,\n                8714326673970415123,\n                12380264119087982419,\n                11108551912665576265,\n                3708955946231240253,\n                11607264285750874901,\n                4216424611300123940,\n                8256067698160491644,\n                7506994298913059376,\n                11501100133000306066,\n                7549037119651533111,\n                5112970978157051505,\n                13518442004335850902,\n                7350008695599366666,\n                9542638447580599221,\n                2158188779042279647,\n                1604170908932337076,\n                6391929341437538244,\n                10779746559124306734,\n                12656450449103176181,\n                10121044395803332310,\n                11651522650180060700,\n                16328514328541821784,\n                10523761782294701174,\n                1822303728984452144,\n                7260452386953933551,\n                12204494523152059466,\n                17100382786462731446,\n                12548225060484474439,\n                11326872465335361323,\n                5596285187831113760,\n                5909751003547848587,\n                992306619579834385,\n                2228664329259510492,\n                15196270917670055982,\n                2131889695890586742,\n                9819776790840463517,\n                1473593931814601068,\n                14939513955417919643,\n                7685117665289355354,\n                6724244559482510387,\n                101460542568704969,\n                7352190705745517803,\n                2150669404455836808,\n                455126870518119052,\n                11553577781469330615,\n                10384536636375637150,\n                14364597940339752635,\n                2495319672618636831,\n                8180783418013670444,\n                3773765470722916252,\n                10227754258298095569,\n                4811293038656815364,\n                2304664986814074602,\n                2418992918773594204,\n                6388448639180737685,\n                6893696275605311774,\n                13851958766811817366,\n                4793074330182947851,\n                4813793152033309122,\n                1098414269347239038,\n                11751908186279088029,\n                15167430159498163699,\n                10528686090760108130,\n                17120804521852235295,\n                5538072916971524268,\n                18284870874128074659,\n                224523015148941267,\n                14496093443691170173,\n                5490655299006793623,\n                11584315652765207551,\n                3229579698633170375,\n                5527375504543907996,\n                6239324650299686862,\n                2232148196848710005,\n                9031256656667465794,\n                40023723987633148,\n                14627741678268078967,\n                11950626749898431344,\n                14785414395108523186,\n                870832948163923646,\n                13004928204786500706,\n                11732704426571300600,\n                907514934656616373,\n                11587740830029349245,\n                7583505136677874861,\n                2623787766244261370,\n                10256163025245964672,\n                7257287909572091733,\n                4812915812660879618,\n                3468364439026649335,\n                6604147596013682093,\n                16816894664989923710,\n                3964120271755066308,\n                6086548275463043980,\n                10447117175471304144,\n                12856607441078849807,\n                10592398111690221432,\n                14269275707379118835,\n                4396127772639422927,\n                10489721798852691549,\n                6681412646421684356,\n                12490106130106455109,\n                3624408102113036819,\n                17246634770535451304,\n                73750230380742720,\n                3858795004528971618,\n                18037249274864620640,\n                9013680198221453825,\n                11909298583725721915,\n                7512555591920604211,\n                17449244834240874515,\n                7793591661081767445,\n                16652407448095073621,\n                11804971167281860328,\n                16410605854679152138,\n                1713343542446776550,\n                16483548344281970818,\n                4628627981197409087,\n                9083762764219706193,\n                17065951854876058290,\n                11490185594933330698,\n                9891012968004512035,\n                368256788081374064,\n                470621950908252,\n                17956316299265730194,\n                8221822257224301188,\n                6380872247545425488,\n                9031471961851140451,\n                17956391258409007260,\n                13017604911584754606,\n                9245778199486992293,\n                8056793204522970093,\n                2531655295742236851,\n                16039488662052065607,\n                4695551407385442957,\n                16581782264738209135,\n                9457268466305801158,\n                2502271077174158302,\n                836797013558343943,\n                1224523470498102285,\n                374165187087964522,\n                10212314508075547184,\n                7669093970332858967,\n                9176723313583927295,\n                8839526249801396044,\n                9460240515540152245,\n                526138750665184089,\n                6908994573320912372,\n                12176043050383940227,\n                8431292525679019707,\n                7800865258551716648,\n                2930208417676545581,\n                12001139080437682925,\n                2848294057310329443,\n                3495763019164815081,\n                13998099468531902475,\n                2334207795701343601,\n                1265352082029868252,\n                5352951968929077427,\n                11045950825318827473,\n                17705541510574119706,\n                10388016860076689091,\n                6188336841660552180,\n                3874842388902329486,\n                3586889024655840994,\n                7577730940669490050,\n                3828324032996703471,\n                7382564057518691083,\n                18020764642442034007,\n                3255848346667024023,\n                913981917700616307,\n                6544220161742236189,\n                628453794376152858,\n                5273139986123145851,\n                12804359385937816703,\n                15490118777013724970,\n                5004956137979193113,\n                11537600208633214816,\n                6041778305931749161,\n                18021165191120757752,\n                4439552721639804321,\n                9445924893904633163,\n                6333608419766441318,\n                6265966168082228187,\n                5090746176805509189,\n                12079779788101746835,\n                3405057163683809716,\n                18176431495575685240,\n                5416316679824315388,\n                5666993498240944478,\n                9396996717121195736,\n                15077940112899068312,\n                15769845674133811095,\n                4172092555141541227,\n                10535661541737621064,\n                10760049649331328984,\n                9044328015087752668,\n                4208484814661836163,\n                4524519455413453106,\n                8416163180819044235,\n                76133776812564214,\n                8938397440798861336,\n                7699462000599225384,\n                9542247023407697767,\n                1397476485288102889,\n                12838783590422826565,\n                11111769246893411506,\n                17719085637529819037,\n                18350048131892648764,\n                647133208572620551,\n                3545832683987398107,\n                17392149180006432089,\n                4645454948531556636,\n                4638633830898005179,\n                15832113029610700219,\n                12312766094616504216,\n                11054531676785061901,\n                12882000175930708962,\n                17065292675540451547,\n                7348135285662513163,\n                10368855461513742486,\n                17213692472848349009,\n                5448237816391429929,\n                17475251701204191843,\n                12352004908893419844,\n                4421019229248084817,\n                5233890583141520327,\n                15415498665325430242,\n                8699482400205838797,\n                11081065321342975843,\n                13692414560354688711,\n                2057100631763259620,\n                1768191442150902149,\n                12463118341434320148,\n                14697940362261450576,\n                7225350934202123472,\n                9180626944525820669,\n                14817691250517499688,\n                9524098384486815580,\n                4894140555324164954,\n                2309262794362375113,\n                8645740617004046828,\n                16829903653299752341,\n                4278553392732422821,\n                16174995535301769275,\n                7274361875865992211,\n                5483861345936568593,\n                16555617280692737205,\n                2106788877369503099,\n                6355572984153420404,\n                15413046204382700864,\n                15184587830187202860,\n                17638950466015943646,\n                10142359495639047596,\n                2852278080143788489,\n                14902051473257283997,\n                12684082230048932446,\n                5127878269602498356,\n                1458833335160283623,\n                18343902965575788886,\n                15956410439937236477,\n                10143815431586875695,\n                8519328419973108156,\n                9379288137799805556,\n                11116700304696206296,\n                3269635235146511468,\n                7446145908658980471,\n                8423421258962502269,\n                2960959498368537205,\n                8029834119982365442,\n                12951331847284209016,\n                13335373530776006943,\n                2051038411438343086,\n                14988843915712852160,\n                11070472159205332532,\n                2405233098821133668,\n                12872299485466251244,\n                4146849588411590424,\n                8652997027024585292,\n                9417874732592565535,\n                2771366489480367357,\n                16381568131097774387,\n                1160190173665475303,\n                12142110843989704382,\n                17157977103678150822,\n                12240974252728213375,\n                8005232037362794911,\n                62748564819661432,\n                15562900352067429326,\n                13819933941831285726,\n                8700733640462543781,\n                17417693392111317966,\n                11195518897113567806,\n                8656545261572504126,\n                2665140739762930045,\n                2523114891549547532,\n                15947075740878853027,\n                16617762624958355772,\n                9189411410511795645,\n                9417682881040880723,\n                1220008371097876826,\n                4473435335583972063,\n                12416336276688398745,\n                9439155074539900208,\n                17599514971068491442,\n                1382978212068751289,\n                12012964446858847311,\n                13059411911626363940,\n                9000605160655962560,\n                18444429515577739106,\n                1678358883660355393,\n                5074103451266196440,\n                1108189786283239561,\n                10612698979413855931,\n                4989895863474068758,\n                653620819971957060,\n                12060263383072344947,\n                15076531277958824549,\n                10597595939754188762,\n                15724450558403473627,\n                16382650125476798913,\n                8738893762787150302,\n                9733212779214420390,\n                5558001311635500417,\n                2720376062751869999,\n                2936217033743496825,\n                3059230718610361194,\n                5589670835881847684,\n                12297086381101763222,\n                12830838307506907529,\n                7727866232017902927,\n                16978583538503170044,\n                5646531489086592542,\n                5696883024644775459,\n                1778382958859079024,\n                9219341275099378906,\n                17593963150311257769,\n                198176573650528594,\n                10425519151629874209,\n                13457055667833759545,\n                17213583299444020650,\n                14862117423842849302,\n                16906392281688863338,\n                4290302946266596427,\n                13505570400341984024,\n                2056510386911305907,\n                11571082458161054292,\n                7566281435617775832,\n                10210241606684674096,\n                10697498687651578080,\n                4947318501826974509,\n                5861434792576988890,\n                9869040491958929661,\n                5532013052186573089,\n                12416594018569715230,\n                10820734898252214278,\n                8537468997207455166,\n                439343392893541672,\n                14734630723072977466,\n                9898041261033982210,\n                17393034157801306127,\n                13758525217758656857,\n                2713096067589327874,\n                12442874178280670969,\n                14498768890161377807,\n                161967360889456606,\n                11930601082339405958,\n                11362787206913160786,\n                12545070484550723467,\n                14815095129086834610,\n                8605787829002095856,\n                12923597973881209899,\n                10587151577465292584,\n                14183134664818382968,\n                5172374334040473114,\n                9364926097792520560,\n                6171919845492918332,\n                4386231931762251578,\n                2155663571428617218,\n                7765511219465701910,\n                12061535530010910259,\n                16100330205655290696,\n                9974384126080194942,\n                9674175848724908032,\n                1687977953933677553,\n                2052842863240418404,\n                18296704913226861337,\n                4023434438910601547,\n                9899743965354682742,\n                5310198234766113901,\n                5162456985274720081,\n                8646509974119784542,\n                6113717383160009894,\n                6014191554047499022,\n                8484348411248636487,\n                2876047496375093909,\n                6660788054730924011,\n                1664197372146636482,\n                2820993293910648101,\n                11665512417100144808,\n                6502457677692154814,\n                2170150732610996776,\n                15522116097990839236,\n                15440086643427998964,\n                3675113412536301313,\n                8316358419658521853,\n                189389437052919038,\n                6981753429704993440,\n                12802645856607643857,\n                7243825699014665843,\n                12796799374814419834,\n                8068467907492367066,\n                16310382387876189712,\n                1486061732225930791,\n                382533986053029739,\n                16359148449656380800,\n                17246074348224240328,\n                11700746273206874174,\n            ],\n            &[\n                3594586856237428958,\n                5997824235581423095,\n                18106945694572591425,\n                5369777421009534827,\n                9691872015485910029,\n                8277223356613193320,\n                8300414822670435844,\n                5725520566058443298,\n                12306974089982798958,\n                18060317567863429618,\n                7394823371293544803,\n                5138546813912625630,\n                11381762187063629918,\n                13795891775219840404,\n                16941170847361878780,\n                3114101041076250480,\n                1627441821796544575,\n                14373434374909899003,\n                15751823974120672095,\n                7114844122374964294,\n                12348870676901510257,\n                3151173383417682310,\n                776184657901342694,\n                7622972041378828791,\n                5661139589349233199,\n                18444306068281950084,\n                16717471472783576773,\n                2453181864182798762,\n                13878855636164163574,\n                2697911612949310053,\n                11500180712127697310,\n                623643852696618616,\n                13977789271289438007,\n                16089002372294802889,\n                5700728318869652447,\n                6942655181316110482,\n                9295484069162391794,\n                12555799549023063196,\n                12437824612510230228,\n                4067237838638331527,\n                4042260540157790426,\n                15358031372213218981,\n                7375293741308867395,\n                15371448718880351190,\n                8424391863249382116,\n                18197512030851004638,\n                4697565561992305539,\n                13311590212527810876,\n                17503569525573518831,\n                2367367325069191744,\n                1326471798779182816,\n                2280875067412000116,\n                14549571747015679842,\n                8045789489671491841,\n                4497686055416253635,\n                4010202321388359450,\n                11363219040443956347,\n                9612974469743198684,\n                7690596049793655898,\n                11690906809673142565,\n                1370450637740102802,\n                11687342070217262803,\n                16093412299942800414,\n                9997008751721738184,\n                11754987271691383075,\n                13819834885151063188,\n                16845077938435135186,\n                8911914559373522274,\n                343887892671262909,\n                4494892451719462524,\n                12103980406521808959,\n                6488834388353468959,\n                4152486077751296306,\n                16639967652404039047,\n                5858398271090603523,\n                14257817111576896046,\n                10213327217611696698,\n                2387098889564047316,\n                17081070436212715347,\n                1911079021927109060,\n                15803126456028273645,\n                1310809663301800181,\n                17222305861889876939,\n                10573069897260961823,\n                9412558929525252792,\n                9682369889898408635,\n                11962049311090563982,\n                5965079569584605350,\n                14865733614651514205,\n                2447981910438979972,\n                17328967927265824822,\n                15648469744389136728,\n                18262394773605934263,\n                14636605825851807882,\n                9083797794473945893,\n                9025739053249539298,\n                11188290513227823984,\n                10587217410587380579,\n                13580707444446986131,\n                12415686714142468705,\n                1356990184364231130,\n                14994095845793627286,\n                6171876359780280353,\n                17884842314222278490,\n                4436207453841323338,\n                17723367308109227012,\n                15941907207802500160,\n                3078577564444952378,\n                11409457214199360500,\n                9887901919260789486,\n                4175383141916761814,\n                1254666319327392127,\n                1282221168759331968,\n                11987113675417120377,\n                5027561805712958447,\n                3579051369716154108,\n                12829602108415654749,\n                5394026478388836602,\n                16667874914598892310,\n                3330196459483415008,\n                16737702178681428488,\n                1445510889972879885,\n                17548042718866769585,\n                3222268498568736762,\n                17503995634561733238,\n                2772145265286633159,\n                9575234631002014001,\n                6346834313174322240,\n                327191781114223341,\n                4183895557314694544,\n                16857140696266627351,\n                18436460138829666667,\n                7798020615570072016,\n                12122516145084219004,\n                12341788428980295562,\n                10542442298029530954,\n                8783455073968960735,\n                14365264653978832010,\n                9696668385411924921,\n                1353441155706063556,\n                12228488114599325384,\n                3203876433604606847,\n                16806676632896446483,\n                8463840989872033198,\n                15588927437296468624,\n                4451301342299362366,\n                18319945996946207766,\n                13389929674620308820,\n                13104054207717801481,\n                10315091670901042550,\n                16344473241124585953,\n                10552683838679802859,\n                5880207654879155934,\n                18375988906573500273,\n                10832453134957582131,\n                4636353071690443111,\n                4654121661690917078,\n                3577146264251561815,\n                12797832477719435241,\n                10740671490864269215,\n                15040149558523329308,\n                7796816016238387863,\n                9542353300619344166,\n                11390258959435632952,\n                2087457610716219502,\n                10422615268763127393,\n                13112339405809012053,\n                8723535168958386014,\n                10239921146965340278,\n                6513282921669469325,\n                3450908699159768885,\n                18047494649011673198,\n                10298878480552871924,\n                4031517553125024915,\n                14129880200307273385,\n                13245341565180251740,\n                142293936665696849,\n                15100564023304297719,\n                12129521945437763262,\n                17006618776295397352,\n                2359253016977701921,\n                15372275938288271263,\n                7030508790783967633,\n                5981151788826319564,\n                8623897852847710240,\n                1290827653422197869,\n                8990203960900044825,\n                10962966372027430885,\n                1990016349334739667,\n                17697377957496422880,\n                11049784557063177783,\n                15397557779693153825,\n                7163175851305743276,\n                17977382692150907540,\n                7938361598612816465,\n                18312648915972269634,\n                39898235407970467,\n                17237577292102821383,\n                14768770315845268220,\n                12163275050128474188,\n                3281298543083649154,\n                16919047222554278693,\n                4475656313290072462,\n                18253843931892737611,\n                1866825044100640454,\n                9098280484278986844,\n                10905592904227149672,\n                9996855374063860018,\n                16867360352959165488,\n                11231826979343065358,\n                14975578212243777674,\n                1816159648349497108,\n                15754341121195873006,\n                14232605178836670191,\n                12612606094775533127,\n                16751615573455906924,\n                6508871566239411316,\n                14264419405559865222,\n                1232093328837969021,\n                4170583985227962960,\n                2303330123802005356,\n                11644297178221861888,\n                8692410420922916348,\n                2712993562192444989,\n                8026831745141520189,\n                8802307139389858344,\n                1941809897174066559,\n                17322010029079648390,\n                342656065441322286,\n                9672113720462539930,\n                10910866529513431242,\n                4289492423082900396,\n                11058177478258586748,\n                1364514196857691678,\n                7032285894941128959,\n                12066375748474424358,\n                15365104738538072299,\n                11816829927945134731,\n                397729498625998286,\n                3741077467460124252,\n                3877765007757413560,\n                5477217126381252416,\n                17665551840782024512,\n                14957739222760165933,\n                13737131533183627675,\n                273054997495525283,\n                1697327593809047125,\n                3590262663858049582,\n                4204421060558050693,\n                12726801568577723109,\n                15145359045822981311,\n                7480634943476006094,\n                9921671236717343483,\n                11511245887474917062,\n                15623196281189992157,\n                8475118117184247401,\n                5999059679518067111,\n                9214567244340364868,\n                13198873116939014797,\n                6655215016500908787,\n                1625660385265393064,\n                12228308354030327384,\n                12626179472567594306,\n                12736031813304319055,\n                8242816500290963115,\n                12956122689020642237,\n                10284362726459938859,\n                3927314022795636984,\n                12541703238882675397,\n                1331111124071806660,\n                12167414537228645643,\n                7836312689846302768,\n                17868735452323208457,\n                3031578802060773881,\n                14199956931959656115,\n                12687814210556209068,\n                5894567003184644132,\n                8572760900561098617,\n                3633198830157294391,\n                796332493389832666,\n                2041313463324032959,\n                8724710971529329269,\n                955634893021271295,\n                1684853491026057131,\n                5435036667387015735,\n                2295851767890888248,\n                17797894669834829008,\n                12146236866491126001,\n                3437637227298033850,\n                16766898487486492541,\n                9367430061730288336,\n                9028668269324087410,\n                14500356941199773752,\n                10638204516750195784,\n                10052294793853632619,\n                6140242340805688971,\n                14340939633164106180,\n                7596475908553648821,\n                5804277951065053377,\n                8985885780654311003,\n                9702056522849965220,\n                1110953655051664758,\n                18084119329270648632,\n                9692529734296553135,\n                13741246141721263549,\n                9860293090921242304,\n                15262709059312175738,\n                15050881295633264500,\n                15102394376219894586,\n                1187517286918163909,\n                4600494490457780813,\n                9949997737543033222,\n                12548051273588091575,\n                1251294250005854372,\n                12514674967656354350,\n                8209795734416267670,\n                5621953688199880086,\n                2625216234966125794,\n                1816441518826280116,\n                14745883011138909066,\n                11529564033952170224,\n                7915149464909709510,\n                11092522205731322220,\n                14000262827040453262,\n                11500588741410946006,\n                5464182528201394183,\n                1347089631519193755,\n                9394782847346205171,\n                8301709505992105074,\n                789343227810667683,\n                16184737414317269551,\n                3952607262504811823,\n                5889460465432404143,\n                5965100411548663972,\n                4496487369263481883,\n                10867267336114414339,\n                7012299638735890009,\n                6226091031016319999,\n                11275972049928859942,\n                7202533585953054701,\n                17863262545987604213,\n                829102422123668526,\n                9423125806946321138,\n                3195060302966047690,\n                209948536736776432,\n                11345127486138365640,\n                18062559394584387629,\n                2142702288780102565,\n                9848954741666431469,\n                9785773656402403362,\n                9317384270775958187,\n                2617653067849148931,\n                14133946690353986680,\n                5772105535189370283,\n                10595418510466854473,\n                2906482636756668487,\n                3018817677365523798,\n                7447507351909056786,\n                13526968716904621523,\n                17092790697122522100,\n                8641236682859520051,\n                16502034166142995058,\n                14955857037584629856,\n                1007758504466420460,\n                5851324741621223589,\n                16596211145178902745,\n                18186625241699221408,\n                1267103353578998461,\n                243071599922609707,\n                14517210614638912070,\n                15057372306565561130,\n                9979838156624188051,\n                7975133518909054568,\n                13545925822097273499,\n                12867658143516063524,\n                17533881262462511358,\n                16356670253522979342,\n                6092369572598992581,\n                4573028473421447357,\n                13938304275335513178,\n                1315263866482735308,\n                380057684148231406,\n                3835456480460755042,\n                1828600490288690572,\n                11524648692118700936,\n                7668575675477254961,\n                4927847007606585681,\n                7642968749404523824,\n                7681851777026821870,\n                4005760681469873112,\n                8422795643629558920,\n                5036390889567087433,\n                1380690399737709501,\n                7361251140747803201,\n                9250287313903956089,\n                9740587600198812657,\n                14906555012214851177,\n                12881827769629431561,\n                17572244782122473499,\n                18370454099654336853,\n                17860629679055514004,\n                3546134039020957530,\n                7931381106272112944,\n                11706419130620665789,\n                3740185226392899084,\n                12262698676041212700,\n                17026388295780548288,\n                13694778344125167325,\n                3072926588523932274,\n                3756372223493163520,\n                2335619280215352683,\n                17531438597287171576,\n                4552132324090931463,\n                3286011129278460598,\n                807082643964194568,\n                4666185161440732584,\n                14542335508110047022,\n                4748593087952186957,\n                4012889075062716273,\n                521589536973278552,\n                17896788016392525340,\n                17039689444406542056,\n                6553554992456494849,\n                1512896227367613872,\n                12822921313714807925,\n                4111454639616903489,\n                14251706422354285056,\n                13139747483840995717,\n                1273069312535292496,\n                2162114314684424541,\n                4163850841149348549,\n                3664043121154853083,\n                14729191601853260054,\n                15284744750744306898,\n                12510768474336929255,\n                11145273181903059662,\n                5085653485125305352,\n                6747370505378000381,\n                15479121662679221243,\n                9596872513868588029,\n                5806144004708237943,\n                17661913749716657482,\n                12335340174016639322,\n                8468074092315538150,\n                13291538602635559911,\n                2821204544422246680,\n                17783435143556609123,\n                12993990360954000430,\n                3773276397662491809,\n                17525402731899178090,\n                17168762357406194265,\n                10542489918853487246,\n                15811159675024564336,\n                15488196215489418830,\n                8818235696498333905,\n                3126553358413855458,\n                8375860131343651072,\n                2687150660280108423,\n                11622270767066056142,\n                17328049472948882340,\n                11220911893655381529,\n                224986233278212797,\n                6604366207763258982,\n                10303213229226473460,\n                6150391194307548313,\n                1532769822993189093,\n                15441342515854434751,\n                8341588131988799593,\n                8558135921887321205,\n                17208924441221496201,\n                7858767700070844969,\n                16471624916022463650,\n                7717459047018176330,\n                10599641480680231262,\n                15994255185665328355,\n                12696756615582176715,\n                14863453143000367171,\n                13847952559705482124,\n                13784944020159703430,\n                11340906950214356755,\n                11292879710786126405,\n                16143496660810886411,\n                16724520942083796554,\n                8368982799465903051,\n                2150857094949894324,\n                8955935246122327128,\n                18438158648606397729,\n                12835653824919990872,\n                11957883793292221645,\n                6052451328426769733,\n                1746957330104831742,\n                2757224925857577697,\n                17661658240813358336,\n                3709266717503365759,\n                14389949788790643304,\n                11675670476414905296,\n                15500498798366693199,\n                8258104249313492616,\n                764096997356311949,\n                589951004095337118,\n                12485552986090158378,\n                1068031484948243915,\n                16605740691516699028,\n                10473029485340063167,\n                3049351104913923232,\n                15845731788695586589,\n                14287046325879279879,\n                6320073903366051707,\n                16066709192467332521,\n                15231205866572467189,\n                16108188309301277950,\n                10035490566382353246,\n                18186672753013695389,\n                2876707137968900193,\n                13756992643025211507,\n                11733973078940380621,\n                1043890832441880486,\n                8496204537482976481,\n                6246303435819606060,\n                6751199421379153121,\n                4947488112166675894,\n                4821550422447014784,\n                13874443557443817072,\n                15491151791617785605,\n                8890963329181817287,\n                3458374110836980981,\n                8848682385288002461,\n                14591433581421428549,\n                14306147895001110991,\n                17935563696896336143,\n                8676844021218567810,\n                11881349447079652233,\n                4497976175675682165,\n                10693808496201580095,\n                13391168868254925122,\n                15629435612796015718,\n                15922689757186949286,\n                3412029294328545342,\n                701052949043722294,\n                2423314665570871346,\n                4353513413515515775,\n                18166762391978185574,\n                9186156162309331881,\n                1268279649890100625,\n                4308217856415291067,\n                12173857132780712488,\n                18144886979589922015,\n                16243378756945549068,\n                13507249524703516854,\n                16831330011876503831,\n                1994671814775470066,\n                12796942923946388445,\n                4529951020994856861,\n                1714548922942971735,\n                12371202587820946720,\n                705076235612627678,\n                18205142645136588080,\n                13596626625484305353,\n                9972137708933558834,\n                16743495633512909,\n                1997864468110042410,\n                3645819153758869891,\n                1635150662123830519,\n                18255329060805359785,\n                9623833873270912396,\n                6707206270726414923,\n                115178768724123514,\n                9107180622069529336,\n                5779697096131347405,\n                6562577309923052469,\n                16399518123999752109,\n                12767521663616393182,\n                3437327565019673630,\n                636692249439777277,\n                5913139906815072528,\n                7033361214831924363,\n                3734621293407093089,\n                10070285767840610976,\n                643318167867702369,\n                16179749096376018639,\n                17943149477486904936,\n                4337354385379270895,\n                9324323254182908698,\n                9430256495080031743,\n                6610492419629128562,\n                14310625820190029921,\n                17178454846869464054,\n                9747133334416100079,\n                13896799715381654411,\n                5925123084043322916,\n                17541914329530815758,\n                7522533365357126514,\n                8783646848572998744,\n                14124286620728075053,\n                11584012692380832279,\n                12964323900711387940,\n                9014571252110133244,\n                4291912469528547260,\n                6995910770375595064,\n                15225286416316441630,\n                11856347119730041734,\n                18352892908708908239,\n                8986410291078412150,\n                16224902571115364893,\n                4995793911920860524,\n                10582495465487609975,\n                7219473912244254743,\n                6105825861348916268,\n                3031788142624263331,\n                2405120948753921386,\n                3388158164171415180,\n                15569752261469238728,\n                11865711447329483913,\n                17596961426365956296,\n                15751473638139106576,\n                11834338523813355103,\n                13955575815298784847,\n                16300180716626739956,\n                10129809968419608061,\n                14618424154534525058,\n                5865323586443341580,\n                9536853263477083912,\n                17331617928467723487,\n                2507541630984584427,\n                11810566947361745765,\n                4088556367114834748,\n                14927557845434061919,\n                3531659285508871954,\n                990032578264635138,\n                3080790007096957728,\n                16774711611413763702,\n                17277430241980248523,\n                18159548027432263984,\n                4006322693443146518,\n                7180053478882046712,\n                4240829398198232701,\n                16769511613034925015,\n                15868464444235003264,\n                10658884407927468064,\n                9589753730320791995,\n                13702671134001044499,\n                12013501078802924056,\n                14238660455565587789,\n                2508715080067956581,\n                5780940886051583044,\n                5443409745788847011,\n                7087326994450046144,\n                6502079163893407796,\n                8465058330099867354,\n                12329363930722540361,\n                2269752097155035673,\n                2473179708552781752,\n                17813411053932910307,\n                16718849503997955009,\n                10311907893650909603,\n                11711060061729778846,\n                6202000401339614885,\n                3175344880215722164,\n                17102839007824360668,\n                6084952160688038415,\n                17055890059971299514,\n                11459717661872795857,\n                15376852828128412609,\n                13588795185785649570,\n                10811729059202241157,\n                2519756038449154050,\n                11772434372968017926,\n                17918830988326226715,\n                13640825138017500589,\n                3616123121466473500,\n                9468167612990666976,\n                4316969512187481955,\n                1290629479158951458,\n                16455502329838682258,\n                1393000865873261712,\n                11125215634614933537,\n                5192310971032689984,\n                13233724647142845976,\n                12952476789215665369,\n                15899648440834464417,\n                4269253090160480011,\n                6973988417787048080,\n                12333953403131658858,\n                10726127211359008958,\n                14591247367332788547,\n                380641304012439491,\n                7498776422064942305,\n                13885928008449988518,\n                1467814545179490761,\n                1860370982665971777,\n                470045086002328260,\n                6181958881837577979,\n                15419457425464630845,\n                14798662432051819245,\n                11251583330874690989,\n                22384040680022034,\n                10150888362324542926,\n                3760439535169014583,\n                1602991507463397082,\n                7459085908332152360,\n                10605327307673329635,\n                15917898735677308173,\n                8343322342584750559,\n                5393553119991558102,\n                1290398580225413157,\n                2838851791633617924,\n                6337842314760282180,\n                13081835650479907029,\n                18255270689222102761,\n                5678712167855221687,\n                12541328464692110959,\n                14559909979575628692,\n                5734353279371918564,\n                12436917190356078564,\n                10579543055668860017,\n                17337964340272444620,\n                17657301701865541311,\n                7908664268390946834,\n                8862641381140028009,\n                4974749065227820364,\n                4337141413352332575,\n                8199120275579213476,\n                12891202443273262660,\n                2231773361773555021,\n                13035819132778862135,\n                2254546336903660762,\n                15884370260923032144,\n                12247481155770539743,\n                14424361930230669374,\n                13563593156228061299,\n                8781543351600786157,\n                393240631721848409,\n                16796624926836825378,\n                16477666032336065319,\n                14883422530366228333,\n                1915530027608907935,\n                5868846719035039746,\n                12587791606048318066,\n                8723399038462045079,\n                346740222600932583,\n                14828068206708180956,\n                10977283960077369593,\n                12847694693977292546,\n                16056726334641439095,\n                15594259272644602416,\n                10118349040635649900,\n                12741230853182662390,\n                778622439867435462,\n                17514270972681376560,\n                16971854740961521018,\n                14118650456693216183,\n                5046965006942474027,\n                16614897108688462037,\n                7340138226120218912,\n                14527773120548425866,\n                15646352228941852973,\n                4302426896604984169,\n                16784052455801005321,\n                15921844867285253784,\n                2381478634388948068,\n                4470300649945796067,\n                5479197665701535286,\n                12776981959611628366,\n                2319879365110208663,\n                17856444665198974031,\n                10746217064232488945,\n                4315227157765058572,\n                9898070875314793964,\n                15229043488147304556,\n                10381942274045522381,\n                13512202749827418899,\n                3763587155861562300,\n                7620809723570809390,\n                2526243279162956104,\n                1465872318491853187,\n                163352369311588190,\n                5468294321100649081,\n                7104806806817952024,\n                14063132590628866011,\n                1707301373088073668,\n                15246878701953806777,\n                5159707047607769848,\n                11769340238034172709,\n                1430874020413856642,\n                7388615858502655185,\n                9923975911358924921,\n                13315267657543568416,\n                10792641201388628130,\n                14048832996048194815,\n                14474171538894906602,\n                9267693476225801285,\n                2166605442077617520,\n                9678297978343640745,\n                6961373802827361366,\n                16194647787487880440,\n                1992823145284553818,\n                13555598311149681377,\n                5055968556909288675,\n                3965798133217150763,\n                6133510486411807656,\n                6314071801668480472,\n                16826390388722280257,\n                9925190747598025431,\n                16711420950523223090,\n                6226330251492191145,\n                4109937645127578403,\n                12444630715323326673,\n                6847234274170061977,\n                16186450916082564829,\n                10654826735664227808,\n                11534265071422990323,\n                17734451515035863233,\n                6451694540470755002,\n                7404688784264462072,\n                1844661270910640233,\n                4876341683982415291,\n                4621995404496263504,\n                15852427353416125199,\n                14340224393479650811,\n                863610120069989202,\n                4751334033539172809,\n                2980159108692947478,\n                15411410315907827734,\n                173168597281837854,\n                16032690352854550631,\n                16378768553918775022,\n                13737092227419742025,\n                11762934705688982692,\n                7938503345444696565,\n                8435418179073387725,\n                11712985912566689058,\n                16004386961795471387,\n                2962358855338280974,\n                13259543794369478103,\n                6353427702673058383,\n                7085772493310959859,\n                3588364186986115552,\n                17915845125226305763,\n                9808251701390486828,\n                2158142165912850942,\n                4691348075235986465,\n                8053891876321060263,\n                1701595525057119500,\n                8245755748230064557,\n                8613492467772362763,\n                13675149462262611397,\n                10509064953231417547,\n                9646349997577567853,\n                14545533711220311875,\n                13021446960830862200,\n                794927318570186488,\n                542833742837941003,\n                5063693132805983501,\n                14684878417631512070,\n                5114822238580567625,\n                8273364330389654264,\n                3571857504693143628,\n                799239708861260901,\n                6273313022460270078,\n                9518525634488459248,\n                13571489290801311273,\n                15752141778029048657,\n                7291402494164012460,\n                4290469266006480900,\n                6554507066785644516,\n                2959997759427662836,\n                10541592608900391159,\n                4293139875450935136,\n                5525397732806767970,\n                7898908356659466050,\n                12509781753727155943,\n                3405800083118177733,\n                17728371249128642252,\n                3947127960407548200,\n                10092113439899026978,\n                9328040765672854917,\n                1248332462096323315,\n                10603315719765713608,\n                8205950523916923730,\n                2296370110105587862,\n                18038211446840649899,\n                2071027033926644952,\n                2611716943963267584,\n                565426880963215684,\n                12082798431989647818,\n                1262807306541300883,\n                15357984945904141115,\n                13582028649501060893,\n                18161107447184229572,\n                14454134435524387052,\n                5552991415567030103,\n                3123389384775661664,\n                16206147663947982662,\n                3947731318667216443,\n                11593347455162248920,\n                18415263555421379096,\n                6340683777373226440,\n                10266965750546344944,\n                11542931066524989244,\n                13352235220023597245,\n                13043895623791507632,\n                14986530571343407676,\n                11639651500495701895,\n                6444695200791802651,\n                12640532142813710882,\n                7911807904924532124,\n                10719275786098695360,\n                12483421480373657656,\n                3778288462364007034,\n                5651386731486987155,\n                4477484045499644604,\n                14045624179073493961,\n                16656727073144501697,\n                4169610857150766018,\n                4456317538389096551,\n                16209680505815783326,\n                10063139284800726283,\n                11765236618067514557,\n                11803908282525267169,\n                6938903930594536075,\n                10810073822459096647,\n                302871153039929433,\n                18326501470477070216,\n                11817798423225837847,\n                17502172116387562424,\n                4133457004641928583,\n                4148986140630370278,\n                10188415158928654989,\n                17379180441624469170,\n                7259204778614767039,\n                16646751529258875918,\n                11647482332259019910,\n                8619186828439261930,\n                8490981817732827712,\n                10369422717234637195,\n                2892527542280695470,\n                17425318346121195814,\n                10828145750999096351,\n                7078995839941276570,\n                213352343672063316,\n                15094639946644127831,\n                12607985439395566916,\n                5955916733332521986,\n                8579933433192887946,\n                7871442941120869085,\n                11554632074995494135,\n                11652936450602906436,\n                11007984151853848873,\n                1041761267322399780,\n                6144819907763081643,\n                149612314949206299,\n                7474008064792379770,\n                5334042690241861180,\n                9085572098291138687,\n                16106658597496927280,\n                10622412062145819612,\n                15221216499725086492,\n                6713674554418687336,\n                8919398431941295272,\n                1259305198131407767,\n                4125305034269587099,\n                11292723729687104587,\n                17550520272904869926,\n                14300285663118054122,\n                17651649700385538325,\n                6515515389639875255,\n                5998975387477999392,\n                4979569443689280403,\n                720170541160814491,\n                14252726231900434814,\n                151009130836684142,\n                5985542076789010191,\n                5480528376021282440,\n                16074646089168847472,\n                8744642307435880660,\n                14992623685451277867,\n                7322978655333382474,\n                9459133969841668298,\n                11616558612523121938,\n                15237288627981848441,\n                12340283711300227220,\n                4307385426083957835,\n                5060287555018892180,\n                10025087470765614277,\n                14171329543463245476,\n                7492526979752985447,\n                6346616424925159985,\n                6141223327769225159,\n                17247946171138841556,\n                6261404185163537151,\n                5023163377322105313,\n                16254767204788026306,\n                2828324189558285147,\n                13506099055854015775,\n                5346000241174155935,\n                15287345424248447504,\n                810002714789219825,\n                2135544417484474120,\n                16141045060472012127,\n                15566657453202917165,\n                6838050207450986724,\n                13707280726755471796,\n                12825372709716849409,\n                1151801150079586709,\n                11706356117928581631,\n                17737810825329609628,\n                5892064243059884309,\n                5994591573500892658,\n                240598676092243371,\n                14621152024470867517,\n                7638751021408304543,\n                3188469996351498175,\n                15093187474130017739,\n                8102143523845853067,\n                7226177729464461341,\n                8765920226853376093,\n                17241792527728310878,\n                11089343816812804469,\n                13289800619211752263,\n                9577227935668680360,\n                9196502297120503559,\n                11910897679656003185,\n                12482528177605398384,\n                11727271477018247784,\n                12907509334852191408,\n                8117063924304605269,\n                17988853154120124135,\n                412009925290001119,\n                17562369799410911811,\n                18077585798078666358,\n                5187081341925388214,\n                10050438195489331613,\n                15887294460579717822,\n                13146778271460113079,\n                10954434742696832355,\n                15714296124420481265,\n                4919364231403856909,\n                8799773700844205148,\n                8772661678971369936,\n                1511002248336701195,\n                8677060651418759379,\n                12053102151285350380,\n                4291428539944984036,\n                16248193550878652744,\n                3824637663415011217,\n                18225446007255047962,\n                13248770985631889130,\n                1762023222033963816,\n                3596805537342084941,\n                3815595957794072272,\n                14221867433187923369,\n                5047749264671185377,\n                18318162823063931218,\n                18043061991589279569,\n                13988989248662657339,\n                6282390326345347911,\n                17920705910930099359,\n                2847517881043829272,\n                18414344723509685565,\n                8464555818524253131,\n                4696858676453751023,\n                1984951604633238437,\n                17261635602989789255,\n                5596537801149349046,\n                4616202707945507437,\n                10212991105412466196,\n                17007993587029315970,\n                5827974697795686227,\n                6175870734113731440,\n                3567413808879435622,\n                14988330267451940337,\n                13736819085881144174,\n                6544430186937532784,\n                1333896442106016567,\n                17651538382929345912,\n                7645895762930408229,\n                16335539228424437965,\n                14762126228238041817,\n                17638681736142153574,\n                4801147597457504427,\n                2593572506126770503,\n                10777851773729995812,\n                7597035761959927357,\n                2894959229604383104,\n                17813862374126875493,\n                1667537312990079705,\n                2111094049852968706,\n                5512916913740522055,\n                2313024390417876380,\n                10374076149445622481,\n                1070924077269143897,\n                14272486039721259695,\n                4852057081224622449,\n                15871762249192081445,\n                515235442010765235,\n                16114206216424388585,\n                8245890551024474044,\n                16257218411161590232,\n                13950049707316054488,\n                18086082736991085709,\n                11521768039421816004,\n                16278766730067268905,\n                445021635202226342,\n                16534369824738425273,\n                853000201976490163,\n                3341635576142727743,\n                7507169208341537913,\n                11735547653623757373,\n                1187806331431749552,\n                4421038865123494484,\n                11056722462547624612,\n                13754650479612351630,\n                326222490866134332,\n                9188864979197147317,\n                2271946967571040075,\n                11674821381118154464,\n                1202775853353787798,\n                1799855237671823946,\n                11759565113802254057,\n                14891253643598468643,\n                5798627104869023436,\n                5422824534737725532,\n                2338362469987961961,\n                1765062885694374272,\n                5541710212221099404,\n                2421202716764084844,\n                8798140732950326206,\n                8077790960191128699,\n                3130257835322872201,\n                18095796129387652899,\n                10567043499984600112,\n                10565948662089842632,\n                4081434024917174309,\n                5620143047638028243,\n                8287199545790302891,\n                4590832326473224620,\n                1377872673376488959,\n                4616051169850979198,\n                11918102346407772457,\n                13797555928826955336,\n                5629375614052972666,\n                793764946850555548,\n                298593192495296597,\n                13643998402531755926,\n                4612390137906915583,\n                11473709230976143742,\n                11340806663028478976,\n                15979335277407525286,\n                3382976563275445295,\n                2992061340144632629,\n                3005044936437934847,\n                11499151483727989417,\n                15253336153928196413,\n                6291119148276832279,\n                13516340268274482521,\n                867708850716575053,\n                3398142748022933862,\n                6641053332830210386,\n                10401620377568476448,\n                15151139781527318024,\n                14109502641600673815,\n                15920595307494001474,\n                17321718006665648826,\n                10716082197892102029,\n                12054728641069632745,\n                16853165359732652897,\n                518996277787655763,\n                18102063294376743672,\n                3205036357911683862,\n                9432302472718874342,\n                13940253316796739130,\n                15902396957939556327,\n                12804434055641637086,\n                10900852703214093959,\n                6214839016355089314,\n                3421088351131279364,\n                13618608303059802359,\n                8587843003643177485,\n                13521718276206728450,\n                18263060908440747350,\n                5800331361655879155,\n                7530113700895940506,\n                13202874917918172882,\n                14616800240220645356,\n                5937559843823118902,\n                12091459054144934373,\n                10953801563518715863,\n                16849143362645073351,\n                6348588031927972798,\n                12184557995395680386,\n                17164648569628470093,\n                173236179981584650,\n                7739020618507749879,\n                2407025576603197656,\n                13619101571430203391,\n                17179931218690131705,\n                9285980237565185530,\n                442047070740903416,\n                8962603603234817570,\n                16584548588877119739,\n                4705022601549530771,\n                14016313032441334336,\n                7361079649571850282,\n                6069184397159611582,\n                7597198683333267789,\n                10136712733185102462,\n                12822423667571059281,\n                17125882173994320255,\n                15561492369338179806,\n                14928805692743950120,\n                9544191551141455841,\n                17809625259400830487,\n                9055445008280062840,\n                8020117400928630492,\n                17227722487996339155,\n                14601418607249783001,\n                10119058804993586012,\n                2013497430499002421,\n                5870521083008018311,\n                12872127376995267701,\n                14779433437438001136,\n                4257318763082705976,\n                9800931713728889471,\n                15672805070193657710,\n                9824998734373167483,\n                6515096257980305885,\n                3114082402068450018,\n                10432755919204823459,\n                11161904653460844874,\n                12367548341480903432,\n                312804941917152200,\n                10283873964481346287,\n                1595588969824113471,\n                6338911369456871430,\n                3907406277527440756,\n                9470219563379708408,\n                15503137061970659225,\n                7861636390602048222,\n                16963596896930915939,\n                7155843803996585638,\n                515206483478520636,\n                4620661362482811196,\n                17984676933167854430,\n                11746565393808560013,\n                3663079656320759032,\n                8459316298636378799,\n                15380228333692207982,\n                15674029362437449957,\n                3058615386053614424,\n                13272588032975448845,\n                9253010992972022192,\n                8648821998170886822,\n                8496039742746984095,\n                14262429223710979566,\n                7358593643192027253,\n                12029817394250979484,\n                15060112505401150146,\n                9540213806836470710,\n                10737868983367426066,\n                5354054353160215187,\n                12167002774907503613,\n                17269779296322432918,\n                10488023097382373776,\n                2076518077268332220,\n                14627512845597448866,\n                8547196352174154905,\n                16202146535871021890,\n                16199548520701244171,\n                12672232170111243275,\n                16024981077313047843,\n                18425865771930531631,\n                2129910576502695957,\n                4520831484431084718,\n                17698215720270168730,\n                13625145001218408941,\n                3060708793266990343,\n                6902137911719822574,\n                4036189651081679589,\n                1364700933898836504,\n                18317596547376101706,\n                4465819716720437370,\n                15502144794460842367,\n                15678849676752815172,\n                12626175056053132903,\n                2236526388064628635,\n                5773951157772200518,\n                10433367551848091278,\n                6345511203913780563,\n                10016115949949912390,\n                14489566045759218180,\n                13632999912860513697,\n                9400120846257243757,\n                13879574790471142703,\n                12729185044957070959,\n                14837732057410367180,\n                13707039717518502222,\n                1478840900618127135,\n                10022739110683499841,\n                1085300049627456467,\n                18374180922241278710,\n                11113263379188399234,\n                8323091712777379724,\n                13303287070971157187,\n                5881333120165044446,\n                17289168019467058259,\n                4352346315266652995,\n                17048693622617070380,\n                5375643740896152681,\n                9463410116162395728,\n                14011802387533450941,\n                10506922322301476703,\n                736147119424806357,\n                14651443393187204200,\n                1789716011004515699,\n                8674068176625995831,\n                3772548884634554298,\n                6066809733699760288,\n                11996643895572412701,\n                3016035580260393227,\n                10359734755057395853,\n                3231360485259740561,\n                17058419130624653472,\n                12054301342150639560,\n                13557887442572034462,\n                6676378795274656629,\n                2991764245307954263,\n                14422737049355291769,\n                6507074200071143464,\n                9304450117720665205,\n                12937792283375351751,\n                4775291188892116651,\n                1657417881602428230,\n                14592588804217603885,\n                198641122402313775,\n                3245497468996556524,\n                2063807586650747380,\n                17774289269818686966,\n                15890942843939161311,\n                17896677076611253034,\n                7061659020774534947,\n                7052051283994487161,\n                8522986888590503052,\n                16164950784047439642,\n                15722471590245455645,\n                16476792238440758290,\n                7845398727452302385,\n                4606767613531400490,\n                3218993439303046183,\n                5981268411278581823,\n                2528820699401079272,\n                9096015514839751191,\n                6703189116584251534,\n                10440925736738406514,\n                7471586021720190903,\n                17294475123240260528,\n                1924391209889224849,\n                15188568825067354262,\n                8621275628870940189,\n                14644155652527688733,\n                3951408744713347457,\n                17770124769997486609,\n                13868539020022671551,\n                15638629279267568113,\n                11477921878735325863,\n                9472653318249633758,\n                14202532955164809363,\n                16535370727896415875,\n                7445288758268536500,\n                7068987396572544597,\n                8418420489883878791,\n                13154621189702387861,\n                15107007450863487474,\n                16134034636689135373,\n                12145189861174644341,\n                2763729420009574112,\n                2342224067876049929,\n                1574861857553854847,\n                5112464449359771791,\n                10220900379209507413,\n                6662200590815208051,\n                8683215886726112491,\n                17021644651395693066,\n                1703318512048449293,\n                4792432496729301234,\n                10822433316732821935,\n                16857401887549809525,\n                1302676010472583420,\n                15469088288489132609,\n                6987791491465850850,\n                8020922250916291337,\n                8723383673396825916,\n                209618812168005306,\n                863147691780840243,\n                2261258140547481604,\n                4523264281944194003,\n                6617004151646627262,\n                16180601329864141854,\n                6966082563709973037,\n                10421816014728281630,\n                101123035978874833,\n                17063499646415794027,\n                10816933943603385680,\n                14311803210157127664,\n                16808963640231641404,\n                16429284467284647587,\n                10745599117685253791,\n                13995686705297457818,\n                13836110408967038001,\n                7060054210253257697,\n                6186854614027150736,\n                10893888996790358870,\n                4329193319031075500,\n                832514682419239753,\n                2762200648842524701,\n                14810831243892005398,\n                110871285919222530,\n                14550177899034441091,\n                2185578722876905899,\n                5537084333607722134,\n                4078093767296457414,\n                6103925737887687077,\n                8325329972961379893,\n                16271339898152868935,\n                1138347867297980412,\n                114138619972231576,\n                5740428581193693489,\n                693613775886515198,\n                8029436153456249652,\n                3344308355696312922,\n                4541242366340473938,\n                7528482809825011820,\n                4152133086009434785,\n                9315015619955905031,\n                15104363855493496419,\n                2594468929320270321,\n                5109083866657386901,\n                16374897994774124344,\n                16083959732406743242,\n                5090837124606889332,\n                3258608291626164581,\n                1629588549235601846,\n                1616635562542911906,\n                9231707360684534688,\n                10952413647773186158,\n                17868542504461850613,\n                9925468414044638566,\n                13854424759141049298,\n                17034570371808369993,\n                12297537197377405600,\n                13939041732952801729,\n                3380964897248364951,\n                14563077242064122168,\n                10657389386018033192,\n                2886754279183664086,\n                16642890180982646692,\n                861273068365160052,\n                1758020898997212990,\n                15613846049063666752,\n                18308267712772765967,\n                17739201502006020362,\n                1784151606563307696,\n                7300607175097014470,\n                16341738772418413744,\n                15971459354868364456,\n                11165614502213695374,\n                6587728139169672539,\n                1786277632003808713,\n                13171307029307411510,\n                327546644505871659,\n                7614925720580811111,\n                6326435263563299482,\n                15953442436210332366,\n                8456480261206292733,\n                8590510172717967165,\n                838937024086432351,\n                1856061773879855233,\n                4069964491639101834,\n                327493480584993142,\n                7520829108532062641,\n                1614967126926521014,\n                11307463881054155232,\n                17864587100878517255,\n                15763537575896112956,\n                4578262687539382027,\n                8502225719669465976,\n                16179696620016923315,\n                9758472315944533714,\n                16779725203968381226,\n                6183875480666892950,\n                2608493615086467,\n                17180723153980641883,\n                3456686138572211050,\n                7884527685732508700,\n                14241925547686939705,\n                13058647316908264970,\n                6875784030440641084,\n                8933325337294393084,\n                12422630052702391657,\n                10079614668510617802,\n                10573331982193065383,\n                7650262932518899908,\n                17128707710941830916,\n                10870510854800752099,\n                17773491963246260474,\n                806524961307578658,\n                6842764457708128243,\n                3445079159386238232,\n                16483764513234069067,\n                10653084184989938490,\n                5903700814029759409,\n                6828901479408398563,\n                11912063888633218185,\n                10913388972688885642,\n                11885744739002746708,\n                9257195893081201223,\n                5930681678077971137,\n                11806521592186912965,\n                2630575534018589484,\n                18026378680378255914,\n                17084784948241081538,\n                17326896384453274331,\n                1866099945567656014,\n                9550282146391637756,\n                2463074436852589087,\n                11585733093552042453,\n                13174738554743021931,\n                15035950777112630117,\n                5558081283202249541,\n                11689273974223163681,\n                14741840413427477553,\n                3416816424414858607,\n                6766458899003324603,\n                12410952811502392413,\n                16409582904445478163,\n                12759024403161588303,\n                5846506096916040331,\n                6071852583112909104,\n                820557947487718625,\n                741480266405970307,\n                12417187439190974741,\n                13229163230117065775,\n                4530194262024109565,\n                8008555870618085417,\n                17877305109343366799,\n                13815905787026003389,\n                7324640884761711445,\n                349028049855052879,\n                16353193971302918640,\n                22560372595432518,\n                195820086483372832,\n                18344647481464459551,\n                737255555262795096,\n                12070614125814171566,\n                8614765570997215695,\n                17372555543859256439,\n                6743171019085030464,\n                8139326738322408600,\n                4165908420227580373,\n                18442514040545838968,\n                16630844454588561050,\n                9571416190602912452,\n                4657012508686090594,\n                3686778704845805223,\n                15973638309180986685,\n                11656159185708435932,\n                13322431680068273959,\n                1751564542162438659,\n                3348182923206453013,\n                13874845053138703302,\n                13876308253542917552,\n                17285310216133973117,\n                4000034777188849113,\n                8256124542460267806,\n                16590833794204607204,\n                7704458184954868301,\n                12492177596185537078,\n                6001301052100279356,\n                11072159473051203657,\n                6151252917038612200,\n                7836035158533234234,\n                11335306549737820717,\n                19315177086761227,\n                6171461384626983181,\n                1822458354600202855,\n                13099374198983726273,\n                13408159522301905657,\n                13851767528819394957,\n                10181771579192114476,\n                9415015639283483660,\n                4263806536662962495,\n                324848264924658129,\n                14503209993079817531,\n                14000340004327513046,\n                11818582924568900321,\n                8109110686397620337,\n                2042190457766210642,\n                8828110432697935381,\n                5820418605711370666,\n                9919829550970909666,\n                12052488162210869057,\n                15934869979999273254,\n                7215348901248890832,\n                3159330338015572597,\n                742740348898429240,\n                5571998578872474833,\n                16341933651780730964,\n                8273383098225845565,\n                3326034376020872344,\n                7274584357797518106,\n                14773843215521859474,\n                16698106264937405391,\n                14040455717338582024,\n                16448479196576319861,\n                17266605361670295779,\n                2205080422456791959,\n                9583005632984852594,\n                10250070524499117272,\n                6651451781199685657,\n                6176632022465435688,\n                8122087199625247517,\n                4510616174816472548,\n                8182983669598271561,\n                118122593711296597,\n                9934905917233313395,\n                3039393435969291444,\n                8120493050432758690,\n                4058819847716511440,\n                4599342760755215154,\n                1480973302998690238,\n                17828904850143881097,\n                10593342770857406535,\n                4478070465435761692,\n                4682095412797127843,\n                16898667833473266754,\n                8748764197976097462,\n                3185375635683792611,\n                13120281814172681751,\n                17914614591764258837,\n                9484169199088431905,\n                4807650520903510792,\n                17575569597016375886,\n                4712387700771102151,\n                12219631271326131718,\n                1624416933083818800,\n                9746390230010361259,\n                12061121252780758123,\n                13191062388618927691,\n                15449059962369037347,\n                12895355194704606432,\n                11847552441436471571,\n                11344827248575736226,\n                7292490505767840,\n                1008341823945074655,\n                4127364818131211815,\n                4270946748779871651,\n                12027658246374555578,\n                12990486587941873323,\n                11841755495420779485,\n                14047350735395451602,\n                8959489495395244296,\n                4420034934416652173,\n                12624150215794407836,\n                6573790355548719031,\n                13861586779706223977,\n                11297305894055413472,\n                9038105502288863696,\n                11783474356604103336,\n                1551845953634669763,\n                17537406743655251318,\n                13836420862857190675,\n                8773267827726588192,\n                18124754071337566386,\n                11768358750377725767,\n                17755389318101260579,\n                3274283977014019260,\n                1778416556501527345,\n                5382190231425722642,\n                13133414606279361249,\n                7734093784869764550,\n                215957712867719475,\n                2984414766272767856,\n                8131723947477567286,\n                4398666896366893320,\n                206703154206980441,\n                12326076546363934220,\n                8160942357092498215,\n                15924256117279207120,\n                12939783368798075,\n                5395310234100182365,\n                607679949225746410,\n                5666550719038113256,\n                17675108580067826210,\n                15502816799164713523,\n                7841099702038392534,\n                15882497369954745148,\n                9402399706745145695,\n                953583398505708528,\n                18445717741487620584,\n                764024304101902997,\n                14868487130868498451,\n                1635358341560953539,\n                4039563583787687147,\n                16550238810277498954,\n                16537486469106960712,\n                3336346802567132577,\n                11082627603539096034,\n                4986362159313854530,\n                15835824893860140029,\n                2031897620572139540,\n                15230511233628159373,\n                14516214625788235622,\n                222036853239298635,\n                8073718635044114045,\n                8911051883637240099,\n                8827781801920171670,\n                12310426504065367326,\n                14816948656941007537,\n                2827084462190879353,\n                13161685568663608198,\n                10249625892127978099,\n                3296264739939232247,\n                7033509689079490421,\n                9525086171579835607,\n                6473169618871652018,\n                5392360298796775732,\n                14776423049723888629,\n                13597358828152620725,\n                16833100318324887296,\n                11971166522475145732,\n                11872097206066985694,\n                8256886017230123355,\n                10314412535333389753,\n                16835045724519439495,\n                4706039712196379299,\n                5870726373620303435,\n                14198515533136338940,\n                2470636378569326935,\n                11369690958187205818,\n                11254490024722864067,\n                15445609396452113187,\n                12551994365532706504,\n                7340653992159982335,\n                8648473678223506625,\n                4626489449677435768,\n                7626866618263441143,\n                5977361104488869811,\n                11325231017650670468,\n                24021926143410559,\n                10518928419015543169,\n                3128581167201575566,\n                10845247038876435111,\n                15367170626696526581,\n                15590613878930469966,\n                17686020409985847800,\n                9351869023028888665,\n                2223400353718632810,\n                8445700103445407057,\n                5743254019080062425,\n                9641427191996032782,\n                2880617337710745321,\n                98705364498162062,\n                6212426535960692329,\n                18096049861029213399,\n                8169816906599295342,\n                9000616375508345603,\n                6726042380097823076,\n                17315167572538836920,\n                13646571690813788783,\n                2919528228383142104,\n                10223074182558417965,\n                3697230257399535848,\n                10728558488011771506,\n                12436437847366171572,\n                18362374704789353589,\n                190724538241540940,\n                14997455344563417220,\n                731172890970164138,\n                4964378684833634132,\n                18060859650136590217,\n                18045696668597737456,\n                17653418903394015975,\n                15544323640715880530,\n                16994229219390286256,\n                18205591550040615103,\n                17734493044884548797,\n                6296908060462462265,\n                7283087819126840178,\n                7426061537866959644,\n                3191966234323480855,\n                14129783695999936076,\n                3360711429774065684,\n                17866164958845125536,\n                9861298124909413210,\n                10580599508841918494,\n                8282189157119747191,\n                9197770707447859186,\n                11694374178492840076,\n                18368802017288109020,\n                16394403946675230099,\n                2141375654291981867,\n                18161140844771142338,\n                15126603772139881848,\n                15048331495212797822,\n                3995638033918575250,\n                13169773405085893541,\n                6025934495808462918,\n                4572080001196751852,\n                2783436619758877302,\n                9024267503032915850,\n                8025963435130321847,\n                3640916310708301788,\n                6840661953417469238,\n                2749986769734168735,\n                8348551153246843562,\n                6913211236889562838,\n                5360496605723998569,\n                13618712664935776158,\n                17575162850298585815,\n                12169990262268572131,\n                14119680116784171735,\n                1796931188281174155,\n                10578372750642831964,\n                12810071554500166106,\n                5459429092645213854,\n                18226416005848684767,\n                12263214363209816529,\n                6391897541120811759,\n                13788023593478687878,\n                15185370313399382407,\n                7852752634323735614,\n                10680723342128514587,\n                495733052464175715,\n                12912465070347673754,\n                18250665729393432770,\n                8577020260491948036,\n                9680999401313764336,\n                4055511702466531936,\n                13922829230551608093,\n                17044580456782760928,\n                1461920314690075938,\n                9935774488507853328,\n                4310590961865401313,\n                17768854053466349121,\n                8972728810615767879,\n                10807101176895750865,\n                14259912900082333579,\n                17455570158393905272,\n                9400361617644197827,\n                3222585990549980881,\n                10934919781824967404,\n                4994963365508091459,\n                97387422948156243,\n                2281022370495958783,\n                14043000925252669887,\n                1950770421033313531,\n                14292039006175938578,\n                17228036599323652443,\n                16418594962299649300,\n                9220515969405166671,\n                13807068206103427496,\n                5762654027968454005,\n                9482191002376611836,\n                3077925584740242035,\n                8071711316681168024,\n                2883691495308653922,\n                13301661594185617316,\n                9766117548540486903,\n                8893678796058966564,\n                1477610205544057259,\n                9796020550269402643,\n                10463846413771564798,\n                3399627051454484744,\n                7300449297128631354,\n                6200293739440149096,\n                17316815833695165145,\n                279212299313192572,\n                3190098250649783077,\n                3555664269010983807,\n                15309533678245941225,\n                3261793309629691333,\n                13037226838231936140,\n                8453766822110843744,\n                14669528518699125877,\n                5825134144024227911,\n                12297418399180362780,\n                7770269489755807915,\n                17888986363036981664,\n                2931111415852485201,\n                14639292244087297189,\n                6847208753088773757,\n                12089103539757219324,\n                10126240302424868138,\n                1796081446544571499,\n                8199277808225787921,\n                1594480600886668204,\n                10641848027714533213,\n                11484122555645255402,\n                16973005969540728518,\n                17196319920931889668,\n                2709835346052075661,\n                18084755852456247033,\n                2132028799062933816,\n                11248099656748788651,\n                3078026107054490219,\n                1287642267969602293,\n                7327615983552677470,\n                1900974316027471940,\n                2465104796974688011,\n                440465215621247360,\n                3494821416222993400,\n                17898838494846832483,\n                10628897889977925683,\n                14309314836127630966,\n                13505109427062926685,\n                6386142816860188269,\n                2901784813617829333,\n                15551975240312695477,\n                9435122587613303018,\n                4226649603223681280,\n                331997962735647934,\n                10485568742856225265,\n                14917030094729116730,\n                2073637171424798316,\n                915835583737744089,\n                17383229556085295687,\n                1461250216293218529,\n                7068239943500340146,\n                10288334490641399525,\n                15208234780964400514,\n                8475559502294427792,\n                2926092195198358430,\n                12656704633781670277,\n                17070487838667522168,\n                4403502814416839647,\n                2376050098451057091,\n                13199999628005904480,\n                14120263009554684577,\n                2468181014903045196,\n                4273221404238097090,\n                5154057720219142551,\n                5027721477518319942,\n                12609684452417053274,\n                1922522277320945218,\n                6436521746874764418,\n                4093773539251325000,\n                8706855626187686051,\n                9846278305273128275,\n                17417037056110132459,\n                12263059830781470664,\n                427676242647324801,\n                3468283337511895036,\n                4275816585741453581,\n                192897459204823952,\n                13550372326052910187,\n                133570839986679541,\n                540585874453202119,\n                11780659758049122569,\n                12360323334925415470,\n                13534100053419999325,\n                2652713032439489910,\n                2795629568052283960,\n                1336633232954655365,\n                9929395103342768040,\n                10647541508025671068,\n                13921459546315253196,\n                12181239385729053155,\n                9244592432264107366,\n                14917953490315439053,\n                8292023989071301332,\n                17207435505444165616,\n                10343948035647838279,\n                16305270801891202880,\n                10567341749348113023,\n                14902153447723505143,\n                11356931487252822795,\n                1535255066112284835,\n                15930640229535365568,\n                15573560888823279647,\n                15076975392882629685,\n                10960578593980276783,\n                17370096640931089566,\n                3501405511953164372,\n                14633610166889715568,\n                1524313386292624933,\n                11407257912918611941,\n                16740555220240538654,\n                16871144196023049970,\n                2018800046134001582,\n                8348490438648921871,\n                4982085025316319837,\n                11415043705393855624,\n                222784703639654682,\n                3466558331671746969,\n                12326013777821768371,\n                3025583346757120511,\n                5724955292043245917,\n                18294065676811894744,\n                2085076369095100979,\n                4972732150574468481,\n                1584581915654164553,\n                15440097755359411249,\n                6279260627318411655,\n                10980381824523944119,\n                14840228887064362306,\n                166495909003667136,\n                15457192490388086685,\n                17222407220359250689,\n                12843576496752906544,\n                7560072307906075608,\n                16259381729801863869,\n                12189888379620317078,\n                5782443157660099818,\n                1736348385658973348,\n                8546351327576605005,\n                10456802501541553424,\n                3192223036731401522,\n                13106139199515235143,\n                15411306387434042331,\n                9970219405739610742,\n                11520445287416838825,\n                177854206445398423,\n                11107078321275218413,\n                239654546708824773,\n                1768902774088704837,\n                5254588776066635495,\n                5979463581485074905,\n                5347777749022576815,\n                6937683941497626074,\n                10711461148089050119,\n                8144687895487491189,\n                3276439454308985400,\n                9934358778921844165,\n                9422385106116957775,\n                15095456547064717516,\n                5070800636017351412,\n                6521931756812739700,\n                3932156166666605130,\n                6050699959511074652,\n                17344541664528753954,\n                2988889255669683201,\n                9353782714615053491,\n                5589156711002183436,\n                6682213996533276248,\n                15943170238383197905,\n                14899562877580150641,\n                6764298931472895517,\n                16276682584602387751,\n                12125732792481305307,\n                17741795378783264776,\n                15129593569550778017,\n                6986829961662604333,\n                9964948114247450317,\n                8616960908998657824,\n                384856055964112635,\n                7974572227450703998,\n                1092885432563198587,\n                545805536762933819,\n                17706486245067983795,\n                1263973849644445141,\n                12021885634205650976,\n                4608166390735539641,\n                2734796012081282351,\n                6200604703378756159,\n                5974505481761285766,\n                9850928205854570116,\n                9239207633120526870,\n                3193081802420914840,\n                7886722472854682054,\n                2670751422274014085,\n                8331709031964299441,\n                8556867030324218740,\n                5864602765164463878,\n                9702767835252903283,\n                2818119218455916326,\n                11051813316976151726,\n                2798361718784864539,\n                12803891989808651361,\n                6525684565274580238,\n                14390328213500260195,\n                1185542698331478180,\n                2771467110443644732,\n                1812331778743510053,\n                16478172183640173140,\n                2162862050541547690,\n                3823461949825666589,\n                17911219118740261734,\n                3056316107218167659,\n                14036209218452819052,\n                14745942794335524299,\n                5518564424136376571,\n                2935575073419114001,\n                1483009244754615051,\n                16104489200811397531,\n                1730333865076822590,\n                8965484080196217492,\n                9061681468831583021,\n                16959687546205760251,\n                10739598289468131077,\n                12535622924924225066,\n                7363619354002287057,\n                14293421377654448317,\n                5060439359147843578,\n                12129527773941979550,\n                2112230986391195828,\n                4769804105653663352,\n                10070457010640222959,\n                15957265372702119122,\n                13474265233601984371,\n                6223229738974064148,\n                1310635690812010762,\n                911270365813712259,\n                15875629933427367379,\n                17125468695201492944,\n                4284280976538402366,\n                3746830346804474068,\n                12276499488868328766,\n                8321930370653221471,\n                9942135371805312885,\n                10489617323540613662,\n                18366063404217450865,\n                10893390470035335263,\n                10458487667984072095,\n                16596433155292684319,\n                8360603581927746599,\n                6971939394626558508,\n                4060283887681078391,\n                15351723438016065412,\n                11680267245463551920,\n                5790802096533806773,\n                10713087820458206775,\n                11332424792139478655,\n                17912160512036322815,\n                5732788143095160128,\n                194157036885958663,\n                3706729391433574290,\n                18104188640582475340,\n                2780227969681270554,\n                1601397086848874520,\n                12428065507807642469,\n                13780772997162403588,\n                17069706121483733548,\n                1665870987398124497,\n                307096882476461439,\n                13456064556530600971,\n                14733632907318555004,\n                4923387323367659585,\n                9154104095651762498,\n                9800443787974033655,\n                15459794479644588197,\n                451426040309413854,\n                2788798329416281365,\n                12293463599613327106,\n                17830121799669654935,\n                10759079676082513720,\n                65630473606081049,\n                5096392528063815709,\n                5346856252299867951,\n                80155407479215991,\n                1196433294196930514,\n                16533172301373380653,\n                10731233255622272875,\n                10178436775016758536,\n                9988031047616269623,\n                12514938561427851997,\n                15073963212371245955,\n                2453302056249682923,\n                12178237101317908190,\n                11696016410691479119,\n                5364207712435662739,\n                13799039328758617062,\n                7635951899542908293,\n                15581988062504838154,\n                12199296096057685395,\n                9571716157701330260,\n                12770833407230845374,\n                7046359335328802215,\n                6682409275392804966,\n                17514350522256500453,\n                2172379224582021646,\n                13091288462267965772,\n                5260878034136529591,\n                5445248199264341584,\n                10781829337947177278,\n                11497567710589338478,\n                5003880921543975167,\n                17626281977932980526,\n                16887485374890873816,\n                962245908798511322,\n                5108152989985995665,\n                3799396524860156187,\n                18162096808895379340,\n                11529283547909399639,\n                6390455738944982802,\n                9936405535146220224,\n                18410905191303666268,\n                15806049958088998276,\n                6686540065405205814,\n                14871651081256051438,\n                1965464759731195941,\n                12452727450091289729,\n                2722304580139295067,\n                7449771214146795823,\n                11184908118487828423,\n                14059936441587749863,\n                4087442731977108274,\n                6305864056451738754,\n                10570807037282543326,\n                319866202550247123,\n                15676864417883625396,\n                257981265506291104,\n                1262875953150419606,\n                7028205644086142472,\n                115549004372063886,\n                13349068651466391379,\n                3871401499320965508,\n                8851966218204065575,\n                5085214474391233098,\n                17945732365705154249,\n                15777212209105057513,\n                5140440907304885371,\n                18438678204170428777,\n                16248096869816190655,\n                3367864749909816871,\n                3722916700775577873,\n                9992809420040804866,\n                8403577374360399236,\n                17679170457988008390,\n                13194410331607642562,\n                16187509812940048427,\n                5026298175140220386,\n                4876974840029834684,\n                12871788850461667764,\n                7104759827829094479,\n                9436288244563973239,\n                3159281221018851642,\n                9752883085161300217,\n                16232691476973353350,\n                6189216786307783578,\n                6640532398843609593,\n                14448033262042085168,\n                3940382498318820890,\n                10262048882525860904,\n                10061274065512561499,\n                18423790370453874819,\n                18050205654249499458,\n                6839499987405858276,\n                9642878486148661075,\n                14327871474315862149,\n                13544992232424681908,\n                11373787680316347001,\n                14533412760069469807,\n                441032119858968952,\n                16002383214623845047,\n                14218288608791285257,\n                11106928674889946673,\n                8570586512119540188,\n                11634529846030850802,\n                4995459497476047290,\n                9490295984153672908,\n                15468267065499713211,\n                2989892364601413290,\n                2581156939788249728,\n                13724611105556739546,\n                2102140712261013213,\n                18120444433685527592,\n                12940831520428557209,\n                7164672115808745211,\n                12966905792848817589,\n                11773978195497059476,\n                890352368276286044,\n                13026135521433759140,\n                12478244758302866463,\n                6413389638484948810,\n                3885955303549003020,\n                11545296721384143264,\n                4229509895730985110,\n                16895351180647205028,\n                5433434349823096592,\n                8863810222360116552,\n                7098452189641277834,\n                16333877257727727689,\n                15013037256819216230,\n                4302560698506558603,\n                16202520488073319843,\n                12907881483678831600,\n                16621305076726276091,\n                10355314267211608878,\n                7452413003135799377,\n                14400166494062685646,\n                1844590774059759861,\n                4021099544936514680,\n                9876925569360801137,\n                13518909505947029222,\n                6973061477093797453,\n                12727661908508644209,\n                18408844351147807641,\n                7377726373507399562,\n                6066950890380320527,\n                7608982295434371124,\n                7179905088110251795,\n                17152549488149335071,\n                8233463606996434952,\n                5206624787865188169,\n                11008399855237240239,\n                1404478959738544072,\n                10222437285137279198,\n                13764842761476361167,\n                267526775623218909,\n                14074888593090104209,\n                11079629091416144703,\n                9971542278925476006,\n                8892245231600747204,\n                11294258223088575084,\n                2098993585796801554,\n                2071313165222807226,\n                2133768860233001961,\n                14915133693464879855,\n                1581952331538464319,\n                9639175840198850752,\n                4603279036103545771,\n                397124688914837400,\n                15508222727364896635,\n                11625935495747427151,\n                2747623392460771576,\n                7890205116581168115,\n                15886026517658120311,\n                12212687251218189134,\n                4479673077377102803,\n                12554927112669616051,\n                5630714043829684681,\n                9034914377094571344,\n                6438149969690220481,\n                6244960371398694214,\n                1052896917557446974,\n                10567823414630738347,\n                2892355401008719855,\n                17414574580084103225,\n                3893733317450926092,\n                4731799036816590152,\n                11430162725623505378,\n                5515277686190787105,\n                11234159093341446162,\n                5305935514397952757,\n                9493854744231574883,\n                15824659478003978852,\n                13748377356768536535,\n                15270190824826719622,\n                13911471579150742952,\n                941469693484857457,\n                8543583469838768654,\n                9570355218602367528,\n                15908271030011892500,\n                15775504622577685589,\n                15502440155453094152,\n                13472074873501854186,\n                7786488156274856633,\n                325184390931240459,\n                391006079612096881,\n                6488611888067900595,\n                17119716183319735070,\n                5722239810452364688,\n                15570270881885807205,\n                1187208346653885920,\n                6495212251536365385,\n                8885994153346273911,\n                9244631118417101083,\n                13319829010425196781,\n                17498600102170453483,\n                2606308062729035588,\n                12140631681722133972,\n                7423666497758255197,\n                4909403267534121212,\n                17291602738067558307,\n                13883694141147284443,\n                15775430310693654790,\n                1365705943610219466,\n                17555638125582494966,\n                12523045031729295704,\n                2392330575426183349,\n                14112467861828070587,\n                1030880217600210745,\n                4385374903004324357,\n                7395532527566274798,\n                4295926697583681461,\n                15824788647062302529,\n                12658431479636413054,\n                7298062229900514919,\n                16762658064265907647,\n                3614060328089930704,\n                1965221455109127938,\n                4537598493017046373,\n                11871860809507888384,\n                4907011922598075617,\n                4907239727404512330,\n                11737261078675068763,\n                6960397578813780713,\n                3287532194305208859,\n                16242004798434108216,\n                5355636867689031522,\n                198206763030220413,\n                12314787670525495844,\n                2597610581767828313,\n                912155910938669031,\n                5621874863922518809,\n                17621042986327515098,\n                6509935032915649610,\n                12034984039300936360,\n                2432672903988649889,\n                16938359086817358514,\n                13683276641443682344,\n                9789874815574933787,\n                5073084314220813473,\n                1320947981283979966,\n                17394333226431571790,\n                9065574734268429766,\n                7547029374160057813,\n                15702678031816921355,\n                17830114942365551555,\n                17586226390965307450,\n                8689045925427717290,\n                13674100805654651310,\n                14947272468697895793,\n                1536415037143716596,\n                900913689058556593,\n                3760203057221746680,\n                15534161016973117105,\n                1882158767141436539,\n                9962312604984275976,\n                8663719069302836304,\n                14448629851288213661,\n                11178083838591395463,\n                5074408974555005944,\n                10002377000305244941,\n                2950452703859403170,\n                8778821961607207068,\n                9599108141368609734,\n                13727328471806688988,\n                8463951250490880363,\n                4985262606975468843,\n                14509435574055577477,\n                2251537913677065242,\n                10838249382772174175,\n                1886092796840457263,\n                17613611691827851266,\n                8675160855459284527,\n                14495552730962688498,\n                981068889151431304,\n                14833582687603804101,\n                16034396285021871754,\n                3289585821311065992,\n                229916794190431942,\n                6158096718005366984,\n                15892365411025682258,\n                16012104260833699937,\n                7229050832450090139,\n                2375455030577448526,\n                18332502145755936854,\n                8113592353194015904,\n                12102179397583890885,\n                6146882145645781232,\n                12871796063368466806,\n                9689896919156456048,\n                14832308820056147126,\n                14224603261131126315,\n                10728994166622935095,\n                15844504707021590914,\n                3148463731124076169,\n                2191614241121958650,\n                3930394497432164211,\n                14975570445035451094,\n                6175957568623475979,\n                13457827038927582204,\n                6569550482770305651,\n                7910721054828235868,\n                5396757648809577484,\n                12425946269835609615,\n                13080000545390338873,\n                2228497309022463045,\n                1000793072110534276,\n                339755678733494105,\n                7675452834746366033,\n                13597453887369667370,\n                4743316555026734805,\n                8000798391810099453,\n                4236658960114346261,\n                4314995954098326729,\n                3378109784202067494,\n                738889711516394796,\n                18249502043229708967,\n                13638135114617560728,\n                7407906194322093125,\n                9677124450328656632,\n                5239160397780299008,\n                4951998289937269566,\n                5582475260866563152,\n                4943398101196515933,\n                14092315760820484720,\n                13498356481480779062,\n                2477405837259253676,\n                2982053805267631149,\n                5613277799593112895,\n                3872536722336143530,\n                14313275147580522478,\n                14098081093274007449,\n                9245627422179538192,\n                12713948618824123036,\n                3663098222106707616,\n                16833593522902690993,\n                9200636416412258830,\n                2943605946405441891,\n                531743763255619302,\n                17390753300460096085,\n                2824093762754005683,\n                9353749113650326235,\n                17521094940135854001,\n                9905656590497951128,\n                320439950481807664,\n                8408113336526795788,\n                17685823149692305464,\n                12450049056842881140,\n                17390416669425632857,\n                1504913544165201790,\n                10449491162901619745,\n                8772252083370989187,\n                14728900004814406794,\n                16291675511356570691,\n                16619460908565992108,\n                13188318675119868117,\n                3193278148390763985,\n                10499359052762173622,\n                14791030350259837161,\n                13388837175628846034,\n                2481027855558432974,\n                5101481046077782932,\n                14962852444038402778,\n                13800116268058936257,\n                4209800634572843335,\n                10873765289322019141,\n                1283737927472492064,\n                6693974210682179363,\n                3926941883152776947,\n                14425372513689620175,\n                5059676940855286392,\n                18024474835648567947,\n                6651263573794035122,\n                13938725133484148737,\n                17549714769345186933,\n                5447384381239220446,\n                10651750950824041822,\n                305544616118117333,\n                14065593823540675662,\n                14976453164111946509,\n                4540050816321398688,\n                5451505567317419192,\n                2316208300786426665,\n                8310776038629040900,\n                16208971995495558244,\n                13551785652790880950,\n                1449640464272106217,\n                12544857006610783141,\n                10144884639080693658,\n                10059099142245117548,\n                10523915445981994172,\n                10876835489035635204,\n                2968860783309380797,\n                5016151962821162573,\n                17935393084803559776,\n                11158849805035424490,\n                9018915535973487771,\n                4357127364458044907,\n                10097519122235494012,\n                17863724194881168069,\n                8249387391663480731,\n                17194137921140035540,\n                4565175158332004125,\n                14196633677254426720,\n                12711637975982192334,\n                1808846428077990103,\n                7220474391737006935,\n                6984910202113287757,\n                8668719005115949313,\n                15689332789493403404,\n                11256157016049092832,\n                16752089932600169557,\n                2976791285708292128,\n                8709736126011521271,\n                11904675423100207085,\n                16364980313730775588,\n                10856165918087528208,\n                4982665602671848433,\n                6941618699135128169,\n                12852532311018706484,\n                14764579611477773304,\n                2680106450342504094,\n                2638046584561806901,\n                2594041699562272096,\n                2830485688608983066,\n                12140745904697927112,\n                14457013334763286122,\n                14405891806907201412,\n                16737034769744161242,\n                6600192696191266517,\n                8700425283962262097,\n                18346405359930526606,\n                8491388585134861252,\n                17484443895627327293,\n                6437654615718885147,\n                15991528328390185419,\n                578665836842411959,\n                12826411398220057302,\n                16935304019869439869,\n                161325410229363246,\n                15656104915507544477,\n                5195403881958848260,\n                8066669430631501373,\n                3422823046399351289,\n                9842336929164283364,\n                14025201114079171450,\n                6383160327527294474,\n                9304888540999769418,\n                14823032853534026080,\n                16142342107979604987,\n                8684662129668287901,\n                17237002878422481510,\n                1268377522566088747,\n                2727385801453676653,\n                458981449659087882,\n                15555517854587152653,\n                11733606025323073847,\n                14555600935550669653,\n                14737823349360352373,\n                6059539353329428657,\n                11478286028886927504,\n                3886949283607812930,\n                345824557705046004,\n                2158851091870555662,\n                11495933931583933350,\n                8794457607221170216,\n                5458340265128732576,\n                2872964225108859294,\n                3279822755074032388,\n                2257159391808810540,\n                11307352514621811375,\n                8781774397128929722,\n                8461654994159402867,\n                13470239546503549381,\n                12451839385253051360,\n                13649919205807350692,\n                12307759654667195662,\n                6121462529213153103,\n                3178361975991080567,\n                14969619058896452804,\n                6543743675636390116,\n                2570068118140327141,\n                13782677705633311464,\n                15539361910618929218,\n                815767500851296252,\n                16343440944270931513,\n                13869851574220153798,\n                7979967566517823577,\n                1079617792028207654,\n                17059495379547625159,\n                3394944722544524901,\n                146658049450392036,\n                920710892733750179,\n                18267466400597724081,\n                12840104746512458153,\n                308895484061420208,\n                3973848977921678681,\n                2682725058127533019,\n                5268781362212396412,\n                0,\n            ],\n            &[\n                12622393184452988185,\n                6576838566809301648,\n                5775205735049728716,\n                8287278668518156534,\n                12192798229753293112,\n                13075940713888694545,\n                12454048030060066070,\n                811912065849436865,\n                14514498508890956207,\n                3718975340013031462,\n                5748599663081118833,\n                7103827618714489700,\n                1300608812711622052,\n                6273491418082608362,\n                10602503410062294488,\n                3181236738912952810,\n                11220558709822910991,\n                1757050625501318151,\n                13622421981172568598,\n                12832273400791276781,\n                5855047466166966026,\n                8265514107974512007,\n                4674109636920327418,\n                15064411300962651052,\n                10245194862302150019,\n                14697255588820327266,\n                15300902461722524376,\n                4133685444341227543,\n                10059303764976223858,\n                12025228906916712453,\n                3342699448606724702,\n                4043427178402639607,\n                8354440664524965265,\n                14685529799335576021,\n                1998565942493742826,\n                424458568212209524,\n                17175147416410219809,\n                8429313419702361615,\n                13100329766043560847,\n                16630087004934016029,\n                1975643079807205422,\n                14257249811747812832,\n                16201214544277583293,\n                10834834555324096005,\n                12974966771898232184,\n                10175033989408956356,\n                13198699716510876245,\n                12667628170354632487,\n                13500517333069730437,\n                16670408922706885903,\n                16358625308423139600,\n                3004604642549199974,\n                15303830789363557104,\n                8922231358023374966,\n                5889284410855917356,\n                14457653243881523958,\n                1394588608017240060,\n                15159743360841977286,\n                16367826019458727864,\n                13291054711118709892,\n                5739609590986339029,\n                16727185121517285485,\n                5857477526908140920,\n                7564539623883188584,\n                15028512432506130151,\n                9451165299139733038,\n                7720569164934553601,\n                12250119607377112932,\n                13838627703516838495,\n                4013168924318862931,\n                15619946084866502269,\n                4850331740702252734,\n                4489013954543776517,\n                10588792414395604443,\n                3902488335149478186,\n                5227683403359005885,\n                7076009259772820031,\n                8343084757976224303,\n                5177402640814818565,\n                2803445024434417300,\n                4085994593957453089,\n                17829839529352422672,\n                3578735210913423849,\n                2792806554222369562,\n                15534236200548977629,\n                3124727634409390443,\n                1084234245147417462,\n                1598571627717804884,\n                752329673301761003,\n                12688955135473243162,\n                3217100306345888294,\n                14566509229614296336,\n                11270786911681876633,\n                6662721337309084196,\n                12158803014774283480,\n                8518459513237421390,\n                5910661800660978266,\n                744628824726848011,\n                5469395445007916291,\n                17702754906843708743,\n                7968296670638284359,\n                7510310566936008628,\n                1793306228498108099,\n                6353661129197447108,\n                3126760188195263395,\n                18414397606186055674,\n                17486033377523869654,\n                12070987014285382902,\n                9991875370105670503,\n                16129470720148507308,\n                1039596679504335478,\n                12158960746785703045,\n                14081886766117011421,\n                8985649855006063812,\n                16817043795641114882,\n                3052278422002310841,\n                11364643265564647695,\n                5842131153676887611,\n                17671187237412914007,\n                8666277097534907268,\n                1983817527033510933,\n                3541460822071490249,\n                6007905868789893806,\n                652610536509913563,\n                11037032573713184751,\n                11009156643744878354,\n                17591018917017615621,\n                11710867183921879437,\n                12251167927128949787,\n                8974964125845019147,\n                16969705468711169632,\n                677161721939989175,\n                1648428070692386013,\n                17084411431327447982,\n                16079687398141624486,\n                2070436743667033809,\n                2763689681570019260,\n                5133447300857161972,\n                15255425835157483742,\n                5966697992253286903,\n                361687726752744332,\n                422697286210467434,\n                7041898431113518823,\n                13795043150550399420,\n                583755960417947241,\n                2875531821527607804,\n                4394534528084370577,\n                12535851821369757920,\n                7213044591651422167,\n                1000544905146371455,\n                4653559762494073142,\n                7779502532203369012,\n                16702927718605692181,\n                12982197318021037408,\n                11786209078045506353,\n                15564445991051693791,\n                168023569501370168,\n                14266568007896652015,\n                5832135998445910960,\n                5245116375679737807,\n                13311176288056325459,\n                3321928379396402727,\n                2233377424088736972,\n                16828319963915513015,\n                9909739734979137218,\n                9397081158643758651,\n                16237610644843443174,\n                12049861989729092874,\n                963173337050875289,\n                1393288980328672002,\n                8369734762526854678,\n                10087190917060030061,\n                16611332898402499111,\n                17383970934682687319,\n                1806005829620081904,\n                2572338165105796552,\n                12096685872124824149,\n                10625877836202904943,\n                3565777311969108583,\n                2012783419915002762,\n                9017825065020723376,\n                16320469478354954310,\n                11806049513756650829,\n                7727243155747891778,\n                15158785566684134320,\n                2456938594466970469,\n                7873271366166028790,\n                7686875950801483839,\n                5617367656140550179,\n                13464612212949386527,\n                14757590544232715739,\n                11128260848489879698,\n                17626653494839808091,\n                4716501168031180893,\n                564851231412074685,\n                8132887702611477369,\n                17552681344611428819,\n                3132957846371517857,\n                11213590168035816092,\n                5431508051609838979,\n                4515078710323627036,\n                13543555744861125477,\n                309309746143903518,\n                16853539194117891693,\n                12430835367581296760,\n                9255793325320254163,\n                6591016556383892120,\n                17100720673447110167,\n                6061633534359930907,\n                2424801126737847877,\n                143356278625650878,\n                13554246058973057,\n                2522638740117423042,\n                17137049738161235473,\n                13176139598975768388,\n                1166120501092890058,\n                13609465226914230670,\n                1875448353263386203,\n                11743691709994844759,\n                11061975822835649567,\n                3910967390258776729,\n                13577511757143681922,\n                13827967505806592907,\n                2051032579834721288,\n                13464396192578309450,\n                12800325352123601126,\n                5662172040792660351,\n                4668403599689432265,\n                13491732430526501935,\n                14157448317801936638,\n                9727633765236455195,\n                9719667367393442680,\n                65474725188749034,\n                541181075058713986,\n                1362959920153019155,\n                909082441655242031,\n                10411762570666372898,\n                11947296633429547042,\n                2358875224077331054,\n                18328103363666444110,\n                9866396237081281387,\n                8956667376401863125,\n                3553975952663161681,\n                14635072569697080107,\n                15544243098851103691,\n                1716867379502200816,\n                8776276410599591217,\n                15666047021340369577,\n                18147839669015605124,\n                5572968214423121059,\n                3098271794032834805,\n                9673511458079712674,\n                16010905689567823114,\n                16267201338365627673,\n                3382936832397700934,\n                14957330839370249294,\n                2642620075223240608,\n                1037193656622159510,\n                9012211029341477206,\n                11431820793941846484,\n                8851179188286979417,\n                1398798117665992200,\n                10789412881967821793,\n                9415310270308545401,\n                3878698623022480586,\n                5863277386811827416,\n                7839335917417032151,\n                2682939031547768972,\n                13397811690933306272,\n                6260148512861761963,\n                250324816893616712,\n                9085404939459661953,\n                9291403781568194640,\n                4943156069611799558,\n                4012150457352746082,\n                6743913241329187121,\n                12017429880940425975,\n                12929043722801309882,\n                10207563294594880008,\n                11011363281303738187,\n                15710481255331302269,\n                16065095211995167995,\n                7729419910130307261,\n                14687299092290139624,\n                14212774840097619295,\n                2696933303282739820,\n                18380487173546723450,\n                16340353901250449060,\n                16974439742831865800,\n                950395719691498193,\n                14294722598295985858,\n                9819629466618736444,\n                5134213478899186274,\n                15000357065088523575,\n                10866834082882265182,\n                5562209566130970606,\n                11574047289359876875,\n                14220066737185616618,\n                7779431549476206578,\n                6164322776781074672,\n                12698699879532635460,\n                9775735470622210670,\n                3418783774094779723,\n                11711261272918394032,\n                130965081793297038,\n                17951168177437733692,\n                10982891057320326220,\n                15446335221541982820,\n                3245348832258032003,\n                16936841548783354130,\n                17845797372140897632,\n                15738639878561184724,\n                8036219019342274839,\n                1452217306593250967,\n                6524640126112677080,\n                9487637664603922399,\n                9816896718276865827,\n                6660361176840108508,\n                7155686979915548241,\n                5363459444036855846,\n                14211791847250927632,\n                3758021753984352623,\n                14892848306282510880,\n                5622159652308652067,\n                3013224027720379126,\n                6593658810977588348,\n                8737392006680055212,\n                13098306207053606600,\n                10321069935686406569,\n                7922126603433897812,\n                16345323120534317859,\n                2051345375893155420,\n                2642889174797452752,\n                15490895676079176387,\n                3421728094884350553,\n                1403789733153795522,\n                18095248776246397645,\n                1141680856759996549,\n                18100437303596844925,\n                10084704427684498223,\n                6594067795036706889,\n                6973150786346631215,\n                18179961484385983667,\n                13461945752721759987,\n                11607193624374158079,\n                15870559753884484047,\n                5909010369355025391,\n                6576523373028484144,\n                16932784188428621626,\n                4532369146195665092,\n                8439234310823545929,\n                1340079530194594172,\n                14887691618471650731,\n                12957273899514368091,\n                12528827801491392116,\n                13543620352724873404,\n                15027641031340635112,\n                3497080345802388600,\n                12532486649114668085,\n                6567958427571461048,\n                15524967599943619324,\n                9687676309746098775,\n                17837290175131112775,\n                6562577965471546738,\n                15069045445640377298,\n                15845870183628003510,\n                4882896822391168376,\n                299291354580119732,\n                1253349370757830450,\n                4019946893924061554,\n                4835687088435778153,\n                560543554021366834,\n                9073367421711646017,\n                7210725233620419378,\n                1298874732344651234,\n                1572176424217571034,\n                13459119860690231055,\n                14894361022235972365,\n                12479129811186551951,\n                14014563421012570478,\n                5045150035901968604,\n                8669967307441751567,\n                1905648106987249698,\n                15427548300560765880,\n                16929690218389356941,\n                2257784955568148289,\n                16671033335294376858,\n                17747845134586030566,\n                1166533040996500790,\n                15593722083313803843,\n                9396109408892612308,\n                11499981530721896824,\n                16970499445754392592,\n                8812544874418820841,\n                8398666252211387757,\n                2704923715823740363,\n                5314497299504523542,\n                5160833323750080202,\n                4489614019342255168,\n                16950479847425158028,\n                6792145380267486390,\n                14740232145636169668,\n                621507344077794685,\n                3751460578157408141,\n                8129084486654095901,\n                10001447130583054783,\n                12074020860950174718,\n                4077799248444467034,\n                6822188364356126108,\n                600699026381065222,\n                4751815635139776884,\n                15367619962178612777,\n                5104893889903277375,\n                4661242055023047595,\n                2154923710109688891,\n                17429472085810639176,\n                15724063920670689806,\n                15216015843686884607,\n                12102731527843294992,\n                5923322163550614145,\n                578844978773347240,\n                10464767667513753088,\n                4422886088759698238,\n                16103295972923438952,\n                11952617258811913803,\n                6497649448616698694,\n                7393337205916981343,\n                18096118845330092692,\n                9417521917459925024,\n                10361801380161480586,\n                12227883220061157093,\n                12402861272457739535,\n                16959542957232270118,\n                3100109669354124792,\n                8252021294756255295,\n                6601544514524806222,\n                2299228880186395084,\n                17206687535661702962,\n                11126365220307664227,\n                14027475381759030281,\n                13930713973102273385,\n                15470781455897247423,\n                11132792425729103210,\n                12743536155285333682,\n                18404252734721007574,\n                4471349713039799575,\n                1097648964215121725,\n                3481722566194833071,\n                17004865376724342545,\n                4412003432895082804,\n                7207210335443122075,\n                11185557399280223037,\n                17791545657588716507,\n                15001384756479157715,\n                7068904123591490511,\n                15342280096772936670,\n                2962241209356984664,\n                11085614675955826760,\n                17304628576563637894,\n                13276820937207248747,\n                8496585032541849567,\n                16867719644448479323,\n                3556128556368553119,\n                4135507236401264417,\n                8300362706308478874,\n                12391805295598536754,\n                212746375693666561,\n                17668657797254926684,\n                11472227395456264735,\n                3346261809041337938,\n                10494844376481252742,\n                1039434633412734920,\n                3537248641106173003,\n                15722028107965146028,\n                3957344489070663630,\n                171520814732107885,\n                15701539439111209401,\n                16266903088897196785,\n                8162180034652464302,\n                751396451910146673,\n                6284978536639446110,\n                9475038153254288249,\n                3366181839966720435,\n                38511352552288459,\n                5091650762875915484,\n                15684434521130749089,\n                3313175693887858849,\n                3512862245616351559,\n                5836672242124333533,\n                7050189281309530509,\n                6693570573437863470,\n                1180929186779755232,\n                13670569646431885520,\n                12219171873489819591,\n                4177796076111463096,\n                12523988008299904003,\n                2573301004696669683,\n                14000913768617402515,\n                1901514323758988374,\n                15680204389035820646,\n                4057543360329026133,\n                10484558774556926484,\n                16880563214620981386,\n                9806529946108790649,\n                64858070620446021,\n                13058265791054866751,\n                14208780393297513060,\n                132444534110050230,\n                18171930401783150790,\n                3788701567251119654,\n                8068556048675251486,\n                7698349927972499523,\n                4200940425301802259,\n                5859679210997281495,\n                1196917998587841402,\n                293846739593611503,\n                742395111532740587,\n                7299921458271130779,\n                4013584019577681930,\n                13051907051578937053,\n                15460522300561557538,\n                11739346111540426460,\n                6000392060961693921,\n                2093513337710768996,\n                2971782196230136142,\n                14650675906567946197,\n                13044422653436935289,\n                5393154276677237552,\n                9414604975305044529,\n                14383902696216976975,\n                3526706571033049996,\n                10453515348838320881,\n                1300027919459661427,\n                18220108229306772305,\n                6736376168692276304,\n                14279821335279300725,\n                1137238529965897445,\n                10675553998207815811,\n                10380811037741532194,\n                8166481736795163463,\n                1781828658320585086,\n                12391009694347491828,\n                917764047682931238,\n                5513578507525454078,\n                17200064132172477743,\n                17870911035870211136,\n                14336835701074601920,\n                11250050928475332766,\n                11433063323885652386,\n                7083842474651714165,\n                2491363132897582954,\n                6822759191074732531,\n                1975703285786766592,\n                4664247346348091399,\n                6200670517431733578,\n                7625423344374743344,\n                12752241152270105853,\n                1792181265050143868,\n                9684341866777183803,\n                2519544645709853691,\n                10916780105681637442,\n                10344955420168669639,\n                9942180203006299987,\n                12084291513489188332,\n                3948266540776100311,\n                9154092837114088215,\n                5346858599403446633,\n                16526650534031004365,\n                1000379885777408481,\n                9962324609830950859,\n                17358968356608808633,\n                16077501442923026330,\n                16373391819852480638,\n                7285769258546345039,\n                9258849101785002591,\n                5742154400061770227,\n                6000603993323989058,\n                14647716329474708008,\n                9759234782041772304,\n                10140774772642173806,\n                12417308406161902675,\n                787743125041003665,\n                16505409716496421861,\n                13496346584666506754,\n                6161155548184037990,\n                6052945594671650378,\n                3943721555742518361,\n                1724411800658421894,\n                5539278770081464366,\n                15345354647968324153,\n                11115348357173195281,\n                14941897866359059705,\n                13232123053046857932,\n                10293530598380524712,\n                6785485284866633954,\n                2274573151581626897,\n                7914418682634630883,\n                9050484888129037258,\n                5596144246310386066,\n                16947403501604289983,\n                4629498933991963153,\n                12809658963208366731,\n                15794201530500048648,\n                13688081233074642819,\n                13734318539544366298,\n                17338613223770563244,\n                8949201706050038962,\n                7457293230715991355,\n                3392962986871707645,\n                2665311774547334828,\n                14769130061609548831,\n                14798608201523559143,\n                4248204495368930031,\n                2118780687916441347,\n                7587741700881576871,\n                14435287502544940055,\n                5661100765027979237,\n                16339955561566207846,\n                8140260981243250155,\n                8056431096984667176,\n                7147782631749791333,\n                2489306669890900889,\n                4475802923302768991,\n                16154685423804744738,\n                7934898789690822040,\n                6879516481280076285,\n                9089400825108258886,\n                17930990199515864021,\n                14768387486978797965,\n                18129863777024625000,\n                10818394317143489199,\n                15491447326600259816,\n                16981166881989734434,\n                16302476576745273904,\n                6518490351683715742,\n                8412288793616962739,\n                6351653340417195445,\n                13150568765377194334,\n                13805040795477806115,\n                5934147261272121494,\n                1994383077577350943,\n                16635675973993021427,\n                12605935823956703560,\n                17476993101523741670,\n                6478809187431271696,\n                2732525537481875395,\n                9879991725842211511,\n                6807932982002010721,\n                7352337837011779903,\n                2817471936912129199,\n                13262278618157850043,\n                10769791684153169602,\n                16373519399949306992,\n                2899723188139359765,\n                10536102085057036916,\n                6542494148698745845,\n                8208357062363683807,\n                7135654628053388596,\n                9239547683832094589,\n                5857943902095897523,\n                2988676895399293972,\n                10864744325417622458,\n                5315919323785706256,\n                17726255358609389283,\n                548416274855739353,\n                14341121194849694922,\n                7541833390688838500,\n                12990342594130240843,\n                18010249397570629115,\n                12270534655132211820,\n                11089591099925577121,\n                8904086294203345138,\n                360354335597452271,\n                15390384602644239058,\n                9646385913080766351,\n                7807991425432087787,\n                9178671661816533936,\n                14127492076118037414,\n                2392162322212242991,\n                14036941142798507711,\n                6502240351436565564,\n                7893899872624843337,\n                14288594129943657110,\n                14040928483141897687,\n                1592502089611546139,\n                16817286687244219231,\n                1288452307437286948,\n                14067519453346137912,\n                10075887672168075195,\n                16769912598561257346,\n                15456884559283078393,\n                8711311950138380878,\n                17440519414852901585,\n                4031578079792007763,\n                17459032506776526507,\n                6047439267180308295,\n                13036838382774047407,\n                5995888809898483332,\n                5666540365944124863,\n                9669239227306108902,\n                13524757761279567441,\n                9100467949589737947,\n                10630607884662362720,\n                7656432890734400844,\n                14587775638685276238,\n                13512825387557617884,\n                7244019832094584382,\n                14996712660826603119,\n                15920594541485478011,\n                18302888448007121275,\n                2860853013354641768,\n                16346890198034118818,\n                3995008638584894259,\n                15431133287252532218,\n                12007621448583591973,\n                12654616832949992670,\n                17218932927375784084,\n                5108339176271521031,\n                1475805094516082093,\n                12897404584908775312,\n                12902004423289195678,\n                632420305961082974,\n                3939829721363017782,\n                8159027656096857323,\n                5289724432039220494,\n                8105874082275331898,\n                7058967362148243623,\n                7084554565361601863,\n                10713529750643129586,\n                16053444010682289763,\n                16789097964014031314,\n                2561050582281530128,\n                5001739943623024256,\n                5563376828383980501,\n                7029523460044084584,\n                3734303822831180195,\n                17604507458906309331,\n                15410396100097854167,\n                12072617536058855445,\n                9343913967197010858,\n                17464576053666161449,\n                14222234943442423138,\n                3029903299346511292,\n                2439504202412922232,\n                17909602716813870812,\n                7163148054936239235,\n                1203376532559407808,\n                13308342071396905822,\n                9659238717159340331,\n                9298790467854663751,\n                13879727520175998029,\n                3540668590936352635,\n                9319928603109010852,\n                7135941863720734900,\n                4755935102616669000,\n                16186952942091333092,\n                868417045309212144,\n                4614771873250033976,\n                12695043568719791838,\n                11555375308916964213,\n                7608623603624110550,\n                2657517781272739364,\n                16275540663546067547,\n                13686833504204824152,\n                12138906647042213779,\n                10867610696309111099,\n                14724502273153125344,\n                16861685577613202946,\n                8743302596210517799,\n                14587474243501868159,\n                2572487334058012273,\n                603248717087965084,\n                5059320325228404990,\n                16238530369175832077,\n                4519037757700474392,\n                12378671739975925965,\n                12407484273586632994,\n                15313162588758450641,\n                7715370120812724109,\n                16244624049595468844,\n                16509798106801620258,\n                8670816985658531869,\n                17161563202276681629,\n                6760859082822229695,\n                6807294103798050445,\n                12102809409961330094,\n                15733867019982720404,\n                4500829814752383546,\n                276727174991039753,\n                7166981968731078898,\n                6839153022681710561,\n                9052935609363333850,\n                180023864532346968,\n                15036321241551927313,\n                8004861917338601611,\n                10433381600254688194,\n                58897018650060884,\n                12176800300096084156,\n                1677464574753824642,\n                9033479160050603494,\n                15102533506708978663,\n                14084179961157892415,\n                15862200228768947299,\n                13406816340465864482,\n                4480435244557703388,\n                9328135622344307924,\n                8569086569674090389,\n                117119659942779713,\n                53818961148559993,\n                17499848839935720391,\n                9136357190515762310,\n                9027105858395986940,\n                17989890318601901443,\n                18097540417946691193,\n                14525610539500917353,\n                2154941454922905428,\n                5904339583092243168,\n                13443891604996267,\n                17266860992297653711,\n                8744756382159865790,\n                18024305737878696983,\n                2546630949169889692,\n                14096991573794098342,\n                6037463192406505117,\n                16222309559186427347,\n                17465566247484999322,\n                12659653001889101916,\n                17145147704704336749,\n                270028953681259627,\n                10687721792402042274,\n                7909714047373529261,\n                1516466812193933964,\n                18277293846935305743,\n                16998707418464340047,\n                10456180009273456482,\n                10894339053818039134,\n                7931553102963941505,\n                5469019641482786787,\n                15559448848625861221,\n                13379845259726008039,\n                15222258432394099771,\n                9220502339943331578,\n                11041492625928826773,\n                13723142119880743788,\n                13406366780219048563,\n                16242021890137344914,\n                3242681820103600264,\n                7433022400269598514,\n                13800053899816348927,\n                10971582708599334044,\n                16780079125754812721,\n                7499355964098143157,\n                6683080229097120149,\n                4643838630497962703,\n                2452976410357582431,\n                13628797043976089046,\n                12208582264105438774,\n                10972823060808439197,\n                5834946779865455467,\n                7061987228048265540,\n                1207502404391064867,\n                4999557813060557947,\n                6110696626660879360,\n                16155026384042239167,\n                14271653985173561903,\n                15409968780617538981,\n                12583134000526518362,\n                14425350186270986364,\n                4240634153006170791,\n                15186331103475807077,\n                3441220359690995595,\n                7730377008237943835,\n                4028688972105728738,\n                2120709666343944557,\n                15275844229510750384,\n                18298631304947594122,\n                13289696428719138891,\n                12902251465979698800,\n                17784642778353395327,\n                8932078122697958597,\n                2343784433129198521,\n                2625325561581989570,\n                6226848264428179755,\n                9341106183231718139,\n                9098935814035218596,\n                7352506358300392706,\n                2344104557164367420,\n                12260380423821950355,\n                5334772679936050516,\n                4625031027053042238,\n                16182107767362335138,\n                16366374610370031102,\n                4836384899789893883,\n                7955273434480297668,\n                6911864392544134089,\n                16417538807637628387,\n                7095497393911852501,\n                13038578327075160812,\n                3237033976078933963,\n                12153345193878928470,\n                8529208509214849086,\n                3557796804144548743,\n                4802066316596054332,\n                15433632645238893171,\n                7546572980385595878,\n                11926731397057053166,\n                12459060237931625488,\n                14141685648156683211,\n                7288151748928762022,\n                4432041251568429780,\n                15563480646640553472,\n                16053290806405898796,\n                15137506699232809093,\n                8005443786172873610,\n                2583037632942587270,\n                17849394642972838924,\n                14162302110936479805,\n                2509458716192360405,\n                5356417310559321341,\n                13186254752172487693,\n                11386136498514963040,\n                17709391199907333437,\n                10287520916427793726,\n                16609632513291109233,\n                2167580474521363269,\n                12093450528168333086,\n                7863381164011802024,\n                3333719694645745323,\n                11940256871115614834,\n                15608703623597862105,\n                12353758136546081384,\n                6684006108125243153,\n                12729735272407622593,\n                5729918571797570178,\n                836259910264806143,\n                14839853436536328663,\n                3503216322132876395,\n                12081845346843956683,\n                11452606043277089033,\n                3278971557269095943,\n                14460255683089324678,\n                26212371609850095,\n                5791996297577934908,\n                11791872952518605557,\n                4303537542168010174,\n                16090584062354399534,\n                4908264648595320164,\n                7751540775663330461,\n                6257171389619325857,\n                10426410760581414335,\n                17538696865214967217,\n                7467505509612490667,\n                9596349531846363101,\n                10432645685361251072,\n                4554200269336177591,\n                14164090620513306305,\n                12703411361203184202,\n                10381679821480302262,\n                17407993808772229676,\n                13447212664492178323,\n                6368763612994722491,\n                6985317877139191413,\n                3304210073159911148,\n                11815333377693368073,\n                5807352926666783905,\n                15497939312564010706,\n                6997355376158126843,\n                8894976899204659904,\n                6062763749482474444,\n                12366982438149692528,\n                5811941270446802002,\n                1365585056061256612,\n                13475218612693439913,\n                3101226957898170052,\n                7483152820787337316,\n                11966132556998778392,\n                15847594708317668544,\n                8536570052230898519,\n                17755327099574675677,\n                4573875060013426627,\n                10571694422987443237,\n                13886938922370949941,\n                13243541345182765869,\n                2407150453734919381,\n                3504658143291885737,\n                7031357511394950972,\n                10000971933511773390,\n                13912116329153795479,\n                15031415497603451939,\n                4599320279014918550,\n                11777085389799050565,\n                10789465428143426974,\n                13380525436974205384,\n                481819144611018854,\n                5450316677878014202,\n                15246244400696673845,\n                2539248742679727539,\n                13402910818618694139,\n                17131842085718107785,\n                1254150638176089903,\n                4995981122218138624,\n                7087931693181888823,\n                15049301175005363928,\n                108059457248600792,\n                6415264753538529207,\n                8176266644263202488,\n                9913473944910878449,\n                1695436935634773000,\n                17297145186449223950,\n                12551494433741244515,\n                9893572477404506151,\n                5018441835213902689,\n                2942536196417517781,\n                16905131659211501459,\n                6905710711318770295,\n                7616899203962297179,\n                14893845862286767619,\n                9802013654239316989,\n                17646160800663090718,\n                688334719842856096,\n                2007794688466179654,\n                654395123253282904,\n                8101085388166846547,\n                129085352126721490,\n                5656513500529597182,\n                5068380157352571940,\n                16823659606299635586,\n                18201953606184755353,\n                14292322613095109457,\n                16683857805140576716,\n                2453074754987128823,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_fail_1() {\n    limbs_div_mod(&[1, 2, 3], &[4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_fail_2() {\n    limbs_div_mod(&[1], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_fail_3() {\n    limbs_div_mod(&[1, 2, 3], &[4, 0]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_to_out_fail_1() {\n    limbs_div_mod_to_out(&mut [10; 4], &mut [10; 4], &[1, 2, 3], &[4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_to_out_fail_2() {\n    limbs_div_mod_to_out(&mut [10; 4], &mut [10; 4], &[1], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_to_out_fail_3() {\n    limbs_div_mod_to_out(&mut [10], &mut [10; 4], &[1, 2, 3, 4], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_div_mod_to_out_fail_4() {\n    limbs_div_mod_to_out(&mut [10; 4], &mut [10; 4], &[1, 2, 3], &[4, 0]);\n}\n\n#[test]\nfn test_div_mod() {\n    let test = |s, t, quotient, remainder| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        let r = x.div_assign_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        let r = x.div_assign_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let (q, r) = u.clone().div_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = u.clone().div_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let mut x = u.clone();\n        let r = x.div_assign_rem(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        let r = x.div_assign_rem(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let (q, r) = u.clone().div_rem(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = u.clone().div_rem(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_rem(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).div_rem(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let num_u = BigUint::from_str(s).unwrap();\n        let num_v = BigUint::from_str(t).unwrap();\n        let (q, r) = num_u.div_mod_floor(&num_v);\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = num_u.div_rem(&num_v);\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let rug_u = rug::Integer::from_str(s).unwrap();\n        let rug_v = rug::Integer::from_str(t).unwrap();\n        let (q, r) = rug_u.clone().div_rem_floor(rug_v.clone());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = rug_u.div_rem(rug_v);\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u / &v, u % v);\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\", \"0\");\n    test(\"1\", \"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"123\", \"0\");\n    test(\"123\", \"123\", \"1\", \"0\");\n    test(\"123\", \"456\", \"0\", \"123\");\n    test(\"456\", \"123\", \"3\", \"87\");\n    test(\"4294967295\", \"1\", \"4294967295\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"1\", \"0\");\n    test(\"1000000000000\", \"1\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"3\", \"333333333333\", \"1\");\n    test(\"1000000000000\", \"123\", \"8130081300\", \"100\");\n    test(\"1000000000000\", \"4294967295\", \"232\", \"3567587560\");\n    test(\n        \"1000000000000000000000000\",\n        \"1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"3\",\n        \"333333333333333333333333\",\n        \"1\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"123\",\n        \"8130081300813008130081\",\n        \"37\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        \"232830643708079\",\n        \"3167723695\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1234567890987\",\n        \"810000006723\",\n        \"530068894399\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018654\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253979\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"94998781946290113\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"0\",\n        \"3768477692975601\",\n    );\n    test(\n        \"3356605361737854\",\n        \"3081095617839357\",\n        \"1\",\n        \"275509743898497\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"1\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"0\", \"123\");\n}\n\n#[test]\n#[should_panic]\nfn div_assign_mod_fail() {\n    Natural::from(10u32).div_assign_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_assign_mod_ref_fail() {\n    Natural::from(10u32).div_assign_mod(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_fail() {\n    Natural::from(10u32).div_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_val_ref_fail() {\n    Natural::from(10u32).div_mod(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_ref_val_fail() {\n    (&Natural::from(10u32)).div_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_mod_ref_ref_fail() {\n    (&Natural::from(10u32)).div_mod(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_assign_rem_fail() {\n    Natural::from(10u32).div_assign_rem(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_assign_rem_ref_fail() {\n    Natural::from(10u32).div_assign_rem(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_fail() {\n    Natural::from(10u32).div_rem(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_val_ref_fail() {\n    Natural::from(10u32).div_rem(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_ref_val_fail() {\n    (&Natural::from(10u32)).div_rem(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn div_rem_ref_ref_fail() {\n    (&Natural::from(10u32)).div_rem(&Natural::ZERO);\n}\n\n#[test]\nfn test_ceiling_div_neg_mod() {\n    let test = |s, t, quotient, remainder| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        let r = x.ceiling_div_assign_neg_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let mut x = u.clone();\n        let r = x.ceiling_div_assign_neg_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), quotient);\n\n        let (q, r) = u.clone().ceiling_div_neg_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = u.clone().ceiling_div_neg_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).ceiling_div_neg_mod(v.clone());\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (&u).ceiling_div_neg_mod(&v);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = rug_ceiling_div_neg_mod(\n            rug::Integer::from_str(s).unwrap(),\n            rug::Integer::from_str(t).unwrap(),\n        );\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n\n        let (q, r) = (u.clone().div_round(v.clone(), Ceiling).0, u.neg_mod(v));\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\", \"0\");\n    test(\"1\", \"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"123\", \"0\");\n    test(\"123\", \"123\", \"1\", \"0\");\n    test(\"123\", \"456\", \"1\", \"333\");\n    test(\"456\", \"123\", \"4\", \"36\");\n    test(\"4294967295\", \"1\", \"4294967295\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"1\", \"0\");\n    test(\"1000000000000\", \"1\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"3\", \"333333333334\", \"2\");\n    test(\"1000000000000\", \"123\", \"8130081301\", \"23\");\n    test(\"1000000000000\", \"4294967295\", \"233\", \"727379735\");\n    test(\n        \"1000000000000000000000000\",\n        \"1\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"3\",\n        \"333333333333333333333334\",\n        \"2\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"123\",\n        \"8130081300813008130082\",\n        \"86\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        \"232830643708080\",\n        \"1127243600\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1234567890987\",\n        \"810000006724\",\n        \"704498996588\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         0\",\n        \"1234567890987654321234567890987654321\",\n        \"810000006723000055638900467181273922269593923137018655\",\n        \"454912836989613466895606299668358255\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         0\",\n        \"316049380092839506236049380092839506176\",\n        \"3164062526261718967339454949926851258865601262253980\",\n        \"278232688309211835744673381771890580480\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"94998781946290114\",\n        \"1149635115107\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"1\",\n        \"11443608136364852355\",\n    );\n    test(\n        \"3356605361737854\",\n        \"3081095617839357\",\n        \"2\",\n        \"2805585873940860\",\n    );\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"2\",\n        \"808034397882141086757\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"1\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"1\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\", \"0\");\n    test(\n        \"123\",\n        \"1000000000000000000000000\",\n        \"1\",\n        \"999999999999999999999877\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_assign_neg_mod_fail() {\n    Natural::from(10u32).ceiling_div_assign_neg_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_assign_neg_mod_ref_fail() {\n    Natural::from(10u32).ceiling_div_assign_neg_mod(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_neg_mod_fail() {\n    Natural::from(10u32).ceiling_div_neg_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_neg_mod_val_ref_fail() {\n    Natural::from(10u32).ceiling_div_neg_mod(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_neg_mod_ref_val_fail() {\n    (&Natural::from(10u32)).ceiling_div_neg_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_div_neg_mod_ref_ref_fail() {\n    (&Natural::from(10u32)).ceiling_div_neg_mod(&Natural::ZERO);\n}\n\n#[test]\nfn limbs_invert_limb_properties() {\n    unsigned_gen_var_12().test_properties(|x| {\n        limbs_invert_limb::<DoubleLimb, Limb>(x);\n    });\n}\n\n#[test]\nfn limbs_div_limb_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(xs, y)| {\n        let (qs, r) = limbs_div_limb_mod(&xs, y);\n        let (q, r_alt) = Natural::from_owned_limbs_asc(xs).div_mod(Natural::from(y));\n        assert_eq!(Natural::from_owned_limbs_asc(qs), q);\n        assert_eq!(r, r_alt);\n    });\n}\n\n#[test]\nfn limbs_div_limb_to_out_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_13().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            let r = limbs_div_limb_to_out_mod(&mut out, &xs, y);\n            let (q, r_alt) = Natural::from_limbs_asc(&xs).div_mod(Natural::from(y));\n            assert_eq!(r, r_alt);\n            let len = xs.len();\n            assert_eq!(Natural::from_limbs_asc(&out[..len]), q);\n            assert_eq!(&out[len..], &old_out[len..]);\n            let final_out = out.clone();\n\n            let mut out = old_out.to_vec();\n            assert_eq!(limbs_div_limb_to_out_mod_alt(&mut out, &xs, y), r);\n            assert_eq!(out, final_out);\n\n            let mut out = old_out.to_vec();\n            assert_eq!(limbs_div_limb_to_out_mod_naive(&mut out, &xs, y), r);\n            assert_eq!(out, final_out);\n        },\n    );\n}\n\n#[test]\nfn limbs_div_limb_in_place_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        let r = limbs_div_limb_in_place_mod(&mut xs, y);\n        let (q, r_alt) = Natural::from_limbs_asc(&old_xs).div_mod(Natural::from(y));\n        assert_eq!(Natural::from_owned_limbs_asc(xs), q);\n        assert_eq!(r, r_alt);\n\n        let mut xs = old_xs.clone();\n        let r_alt = limbs_div_limb_in_place_mod_alt(&mut xs, y);\n        let q_alt = Natural::from_owned_limbs_asc(xs);\n        assert_eq!(q, q_alt);\n        assert_eq!(r, r_alt);\n\n        let mut xs = old_xs;\n        let r_alt = limbs_div_limb_in_place_mod_naive(&mut xs, y);\n        let q_alt = Natural::from_owned_limbs_asc(xs);\n        assert_eq!(q, q_alt);\n        assert_eq!(r, r_alt);\n    });\n}\n\n#[test]\nfn limbs_div_mod_extra_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_19().test_properties_with_config(\n        &config,\n        |(mut out, fraction_len, ns, d, d_inv, shift)| {\n            let old_out = out.clone();\n            let r = limbs_div_mod_extra(&mut out, fraction_len, &ns, d, d_inv, shift);\n            verify_limbs_div_mod_extra(&old_out, fraction_len, &ns, d, &out, r);\n        },\n    );\n}\n\n#[test]\nfn limbs_div_mod_extra_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_18().test_properties_with_config(\n        &config,\n        |(mut ns, fraction_len, d, d_inv, shift)| {\n            let old_ns = ns.clone();\n            let r = limbs_div_mod_extra_in_place(&mut ns, fraction_len, d, d_inv, shift);\n            verify_limbs_div_mod_extra_in_place(&old_ns, fraction_len, d, &ns, r);\n        },\n    );\n}\n\n#[test]\nfn limbs_two_limb_inverse_helper_properties() {\n    unsigned_pair_gen_var_35().test_properties(|(hi, lo)| {\n        let result = limbs_two_limb_inverse_helper(hi, lo);\n        verify_limbs_two_limb_inverse_helper(hi, lo, result);\n    });\n}\n\n#[test]\nfn limbs_div_mod_three_limb_by_two_limb_properties() {\n    unsigned_sextuple_gen_var_2().test_properties(|(n_2, n_1, n_0, d_1, d_0, inverse)| {\n        let (q, r) = limbs_div_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, inverse);\n        verify_limbs_div_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, q, r);\n    });\n}\n\n#[test]\nfn limbs_div_mod_by_two_limb_normalized_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_53().test_properties_with_config(&config, |(qs_in, ns_in, ds)| {\n        let mut qs = qs_in.clone();\n        let mut ns = ns_in.clone();\n        let q_highest = limbs_div_mod_by_two_limb_normalized(&mut qs, &mut ns, &ds);\n        verify_limbs_div_mod_by_two_limb_normalized(&qs_in, &ns_in, &ds, q_highest, &qs, &ns);\n    });\n}\n\n#[test]\nfn limbs_div_mod_schoolbook_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_11().test_properties_with_config(&config, |(qs_in, ns_in, ds, inverse)| {\n        let mut qs = qs_in.clone();\n        let mut ns = ns_in.clone();\n        let q_highest = limbs_div_mod_schoolbook(&mut qs, &mut ns, &ds, inverse);\n        verify_limbs_div_mod_1(&qs_in, &ns_in, &ds, q_highest, &qs, &ns);\n    });\n}\n\n#[test]\nfn limbs_div_mod_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    large_type_gen_var_12().test_properties_with_config(&config, |(qs_in, ns_in, ds, inverse)| {\n        let mut qs = qs_in.clone();\n        let mut ns = ns_in.clone();\n        let q_highest = limbs_div_mod_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n        verify_limbs_div_mod_1(&qs_in, &ns_in, &ds, q_highest, &qs, &ns);\n    });\n}\n\n#[test]\nfn limbs_invert_basecase_approx_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_50().test_properties_with_config(\n        &config,\n        |(mut is, ds, mut scratch)| {\n            let is_old = is.clone();\n            let result_definitely_exact = limbs_invert_basecase_approx(&mut is, &ds, &mut scratch);\n            verify_limbs_invert_approx(&is_old, &ds, result_definitely_exact, &is);\n        },\n    );\n}\n\n#[test]\nfn limbs_invert_newton_approx_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_51().test_properties_with_config(\n        &config,\n        |(mut is, ds, mut scratch)| {\n            let is_old = is.clone();\n            let result_definitely_exact = limbs_invert_newton_approx(&mut is, &ds, &mut scratch);\n            verify_limbs_invert_approx(&is_old, &ds, result_definitely_exact, &is);\n        },\n    );\n}\n\n#[test]\nfn limbs_invert_approx_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_50().test_properties_with_config(\n        &config,\n        |(mut is, ds, mut scratch)| {\n            let is_old = is.clone();\n            let result_definitely_exact = limbs_invert_approx(&mut is, &ds, &mut scratch);\n            verify_limbs_invert_approx(&is_old, &ds, result_definitely_exact, &is);\n        },\n    );\n}\n\n#[test]\nfn limbs_div_mod_barrett_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_quadruple_gen_var_5().test_properties_with_config(\n        &config,\n        |(mut qs, mut rs, ns, ds)| {\n            let qs_old = qs.clone();\n            let rs_old = rs.clone();\n            let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n            let q_highest = limbs_div_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n            verify_limbs_div_mod_2(&qs_old, &rs_old, &ns, &ds, q_highest, &qs, &rs);\n        },\n    );\n}\n\nfn verify_limbs_div_mod_4(ns: &[Limb], ds: &[Limb], qs: &[Limb], rs: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let (expected_q, expected_r) = (&n).div_mod(&d);\n    let q = Natural::from_limbs_asc(qs);\n    let r = Natural::from_limbs_asc(rs);\n    assert_eq!(q, expected_q);\n    assert_eq!(r, expected_r);\n    assert!(r < d);\n    assert_eq!(q * d + r, n);\n    let d_len = ds.len();\n    assert_eq!(qs.len(), ns.len() - d_len + 1);\n    assert_eq!(rs.len(), d_len);\n}\n\n#[test]\nfn limbs_div_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_11().test_properties_with_config(&config, |(ns, ds)| {\n        let (qs, rs) = limbs_div_mod(&ns, &ds);\n        verify_limbs_div_mod_4(&ns, &ds, &qs, &rs);\n    });\n}\n\n#[test]\nfn limbs_div_mod_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_quadruple_gen_var_1().test_properties_with_config(\n        &config,\n        |(mut qs, mut rs, ns, ds)| {\n            let qs_old = qs.clone();\n            let rs_old = rs.clone();\n            limbs_div_mod_to_out(&mut qs, &mut rs, &ns, &ds);\n            verify_limbs_div_mod_3(&qs_old, &rs_old, &ns, &ds, &qs, &rs);\n        },\n    );\n}\n\n// It would be a little confusing to only pass y by value\n#[allow(clippy::needless_pass_by_value)]\nfn div_mod_and_div_rem_properties_helper(x: Natural, y: Natural) {\n    let mut mut_x = x.clone();\n    let r = mut_x.div_assign_mod(&y);\n    assert!(mut_x.is_valid());\n    assert!(r.is_valid());\n    let q = mut_x;\n\n    let mut mut_x = x.clone();\n    let r_alt = mut_x.div_assign_mod(y.clone());\n    let q_alt = mut_x;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let mut q_alt = x.clone();\n    let r_alt = q_alt.div_assign_rem(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let mut q_alt = x.clone();\n    let r_alt = q_alt.div_assign_rem(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_rem(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).div_rem(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_rem(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().div_rem(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x / &y, &x % &y);\n    assert_eq!(q_alt, q);\n    assert_eq!(r_alt, r);\n\n    let (num_q, num_r) = BigUint::from(&x).div_mod_floor(&BigUint::from(&y));\n    assert_eq!(Natural::from(&num_q), q);\n    assert_eq!(Natural::from(&num_r), r);\n\n    let (num_q, num_r) = BigUint::from(&x).div_rem(&BigUint::from(&y));\n    assert_eq!(Natural::from(&num_q), q);\n    assert_eq!(Natural::from(&num_r), r);\n\n    let (rug_q, rug_r) = rug::Integer::from(&x).div_rem_floor(rug::Integer::from(&y));\n    assert_eq!(Natural::exact_from(&rug_q), q);\n    assert_eq!(Natural::exact_from(&rug_r), r);\n\n    let (rug_q, rug_r) = rug::Integer::from(&x).div_rem(rug::Integer::from(&y));\n    assert_eq!(Natural::exact_from(&rug_q), q);\n    assert_eq!(Natural::exact_from(&rug_r), r);\n\n    assert!(r < y);\n    assert_eq!(q * y + r, x);\n}\n\n#[test]\nfn div_mod_and_div_rem_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 256 << Limb::LOG_WIDTH);\n    natural_pair_gen_var_5().test_properties_with_config(&config, |(x, y)| {\n        div_mod_and_div_rem_properties_helper(x, y);\n    });\n\n    natural_pair_gen_var_6().test_properties_with_config(&config, |(x, y)| {\n        div_mod_and_div_rem_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).div_mod(Natural::ONE), (x.clone(), Natural::ZERO));\n    });\n\n    natural_gen_var_2().test_properties(|x| {\n        assert_eq!((&x).div_mod(&x), (Natural::ONE, Natural::ZERO));\n        assert_eq!(Natural::ZERO.div_mod(&x), (Natural::ZERO, Natural::ZERO));\n        if x > 1 {\n            assert_eq!(Natural::ONE.div_mod(x), (Natural::ZERO, Natural::ONE));\n        }\n    });\n\n    unsigned_pair_gen_var_12::<Limb, Limb>().test_properties(|(x, y)| {\n        let (q, r) = x.div_mod(y);\n        assert_eq!(\n            Natural::from(x).div_mod(Natural::from(y)),\n            (Natural::from(q), Natural::from(r))\n        );\n    });\n}\n\n// It would be a little confusing to only pass y by value\n#[allow(clippy::needless_pass_by_value)]\nfn ceiling_div_neg_mod_properties_helper(x: Natural, y: Natural) {\n    let mut mut_x = x.clone();\n    let r = mut_x.ceiling_div_assign_neg_mod(&y);\n    assert!(mut_x.is_valid());\n    assert!(r.is_valid());\n    let q = mut_x;\n\n    let mut mut_x = x.clone();\n    let r_alt = mut_x.ceiling_div_assign_neg_mod(y.clone());\n    let q_alt = mut_x;\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).ceiling_div_neg_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = (&x).ceiling_div_neg_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().ceiling_div_neg_mod(&y);\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = x.clone().ceiling_div_neg_mod(y.clone());\n    assert!(q_alt.is_valid());\n    assert_eq!(q_alt, q);\n    assert!(r_alt.is_valid());\n    assert_eq!(r_alt, r);\n\n    let (q_alt, r_alt) = ((&x).div_round(&y, Ceiling).0, (&x).neg_mod(&y));\n    assert_eq!(q_alt, q);\n    assert_eq!(r_alt, r);\n\n    let (rug_q, rug_r) = rug_ceiling_div_neg_mod(rug::Integer::from(&x), rug::Integer::from(&y));\n    assert_eq!(Natural::exact_from(&rug_q), q);\n    assert_eq!(Natural::exact_from(&rug_r), r);\n\n    assert!(r < y);\n    assert_eq!(q * y - r, x);\n}\n\n#[test]\nfn ceiling_div_neg_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 256 << Limb::LOG_WIDTH);\n    natural_pair_gen_var_5().test_properties_with_config(&config, |(x, y)| {\n        ceiling_div_neg_mod_properties_helper(x, y);\n    });\n\n    natural_pair_gen_var_6().test_properties_with_config(&config, |(x, y)| {\n        ceiling_div_neg_mod_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(\n            (&x).ceiling_div_neg_mod(Natural::ONE),\n            (x.clone(), Natural::ZERO)\n        );\n    });\n\n    natural_gen_var_2().test_properties(|x| {\n        assert_eq!((&x).ceiling_div_neg_mod(&x), (Natural::ONE, Natural::ZERO));\n        assert_eq!(\n            Natural::ZERO.ceiling_div_neg_mod(&x),\n            (Natural::ZERO, Natural::ZERO)\n        );\n        if x > 1 {\n            assert_eq!(\n                Natural::ONE.ceiling_div_neg_mod(&x),\n                (Natural::ONE, x - Natural::ONE)\n            );\n        }\n    });\n\n    unsigned_pair_gen_var_12::<Limb, Limb>().test_properties(|(x, y)| {\n        let (q, r) = x.ceiling_div_neg_mod(y);\n        assert_eq!(\n            Natural::from(x).ceiling_div_neg_mod(Natural::from(y)),\n            (Natural::from(q), Natural::from(r))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/div_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivNegMod, DivRound, DivRoundAssign, DivisibleBy,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_unsigned_rounding_mode_triple_gen_var_1,\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::div_round::limbs_limb_div_round_limbs;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_rounding_mode_triple_gen_var_1, natural_pair_gen_var_5, natural_pair_gen_var_7,\n    natural_rounding_mode_pair_gen, natural_rounding_mode_pair_gen_var_2,\n};\nuse num::{BigUint, Integer};\nuse rug::ops::DivRounding;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_div_round() {\n    let test = |s, t, rm, quotient, o| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        assert_eq!(x.div_round_assign(v.clone(), rm), o);\n        assert_eq!(x.to_string(), quotient);\n        assert!(x.is_valid());\n\n        let mut x = u.clone();\n        assert_eq!(x.div_round_assign(&v, rm), o);\n        assert_eq!(x.to_string(), quotient);\n        assert!(x.is_valid());\n\n        let (q, o_alt) = u.clone().div_round(v.clone(), rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (q, o_alt) = u.clone().div_round(&v, rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (q, o_alt) = (&u).div_round(v.clone(), rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (q, o_alt) = (&u).div_round(&v, rm);\n        assert!(q.is_valid());\n        assert_eq!(q.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        match rm {\n            Down => {\n                assert_eq!(\n                    rug::Integer::from_str(s)\n                        .unwrap()\n                        .div_trunc(rug::Integer::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n            }\n            Floor => {\n                assert_eq!(\n                    BigUint::from_str(s)\n                        .unwrap()\n                        .div_floor(&BigUint::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n                assert_eq!(\n                    rug::Integer::from_str(s)\n                        .unwrap()\n                        .div_floor(rug::Integer::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n            }\n            Ceiling => {\n                assert_eq!(\n                    rug::Integer::from_str(s)\n                        .unwrap()\n                        .div_ceil(rug::Integer::from_str(t).unwrap())\n                        .to_string(),\n                    quotient\n                );\n            }\n            _ => {}\n        }\n    };\n    test(\"0\", \"1\", Down, \"0\", Equal);\n    test(\"0\", \"1\", Floor, \"0\", Equal);\n    test(\"0\", \"1\", Up, \"0\", Equal);\n    test(\"0\", \"1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"1\", Nearest, \"0\", Equal);\n    test(\"0\", \"1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"123\", Down, \"0\", Equal);\n    test(\"0\", \"123\", Floor, \"0\", Equal);\n    test(\"0\", \"123\", Up, \"0\", Equal);\n    test(\"0\", \"123\", Ceiling, \"0\", Equal);\n    test(\"0\", \"123\", Nearest, \"0\", Equal);\n    test(\"0\", \"123\", Exact, \"0\", Equal);\n\n    test(\"1\", \"1\", Down, \"1\", Equal);\n    test(\"1\", \"1\", Floor, \"1\", Equal);\n    test(\"1\", \"1\", Up, \"1\", Equal);\n    test(\"1\", \"1\", Ceiling, \"1\", Equal);\n    test(\"1\", \"1\", Nearest, \"1\", Equal);\n    test(\"1\", \"1\", Exact, \"1\", Equal);\n\n    test(\"123\", \"1\", Down, \"123\", Equal);\n    test(\"123\", \"1\", Floor, \"123\", Equal);\n    test(\"123\", \"1\", Up, \"123\", Equal);\n    test(\"123\", \"1\", Ceiling, \"123\", Equal);\n    test(\"123\", \"1\", Nearest, \"123\", Equal);\n    test(\"123\", \"1\", Exact, \"123\", Equal);\n\n    test(\"123\", \"2\", Down, \"61\", Less);\n    test(\"123\", \"2\", Floor, \"61\", Less);\n    test(\"123\", \"2\", Up, \"62\", Greater);\n    test(\"123\", \"2\", Ceiling, \"62\", Greater);\n    test(\"123\", \"2\", Nearest, \"62\", Greater);\n\n    test(\"125\", \"2\", Down, \"62\", Less);\n    test(\"125\", \"2\", Floor, \"62\", Less);\n    test(\"125\", \"2\", Up, \"63\", Greater);\n    test(\"125\", \"2\", Ceiling, \"63\", Greater);\n    test(\"125\", \"2\", Nearest, \"62\", Less);\n\n    test(\"123\", \"123\", Down, \"1\", Equal);\n    test(\"123\", \"123\", Floor, \"1\", Equal);\n    test(\"123\", \"123\", Up, \"1\", Equal);\n    test(\"123\", \"123\", Ceiling, \"1\", Equal);\n    test(\"123\", \"123\", Nearest, \"1\", Equal);\n    test(\"123\", \"123\", Exact, \"1\", Equal);\n\n    test(\"123\", \"456\", Down, \"0\", Less);\n    test(\"123\", \"456\", Floor, \"0\", Less);\n    test(\"123\", \"456\", Up, \"1\", Greater);\n    test(\"123\", \"456\", Ceiling, \"1\", Greater);\n    test(\"123\", \"456\", Nearest, \"0\", Less);\n\n    test(\"1000000000000\", \"1\", Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Exact, \"1000000000000\", Equal);\n\n    test(\"1000000000000\", \"3\", Down, \"333333333333\", Less);\n    test(\"1000000000000\", \"3\", Floor, \"333333333333\", Less);\n    test(\"1000000000000\", \"3\", Up, \"333333333334\", Greater);\n    test(\"1000000000000\", \"3\", Ceiling, \"333333333334\", Greater);\n    test(\"1000000000000\", \"3\", Nearest, \"333333333333\", Less);\n\n    test(\"999999999999\", \"2\", Down, \"499999999999\", Less);\n    test(\"999999999999\", \"2\", Floor, \"499999999999\", Less);\n    test(\"999999999999\", \"2\", Up, \"500000000000\", Greater);\n    test(\"999999999999\", \"2\", Ceiling, \"500000000000\", Greater);\n    test(\"999999999999\", \"2\", Nearest, \"500000000000\", Greater);\n\n    test(\"1000000000001\", \"2\", Down, \"500000000000\", Less);\n    test(\"1000000000001\", \"2\", Floor, \"500000000000\", Less);\n    test(\"1000000000001\", \"2\", Up, \"500000000001\", Greater);\n    test(\"1000000000001\", \"2\", Ceiling, \"500000000001\", Greater);\n    test(\"1000000000001\", \"2\", Nearest, \"500000000000\", Less);\n\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Down,\n        \"232830643708079\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Floor,\n        \"232830643708079\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Up,\n        \"232830643708080\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Ceiling,\n        \"232830643708080\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Nearest,\n        \"232830643708080\",\n        Greater,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Down,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Floor,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Up,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Exact,\n        \"1000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Down,\n        \"999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Floor,\n        \"999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Up,\n        \"1000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Ceiling,\n        \"1000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Nearest,\n        \"999999999999\",\n        Less,\n    );\n\n    test(\n        \"2999999999999999999999999\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"1\",\n        Less,\n    );\n    test(\n        \"3000000000000000000000000\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"2\",\n        Greater,\n    );\n    test(\n        \"3000000000000000000000001\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"2\",\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_fail_1() {\n    let mut n = Natural::from(10u32);\n    n.div_round_assign(Natural::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_fail_2() {\n    let mut n = Natural::from(10u32);\n    n.div_round_assign(Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_ref_fail_1() {\n    let mut n = Natural::from(10u32);\n    n.div_round_assign(&Natural::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_assign_ref_fail_2() {\n    let mut n = Natural::from(10u32);\n    n.div_round_assign(&Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_fail_1() {\n    Natural::from(10u32).div_round(Natural::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_fail_2() {\n    Natural::from(10u32).div_round(Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_val_ref_fail_1() {\n    Natural::from(10u32).div_round(&Natural::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_val_ref_fail_2() {\n    Natural::from(10u32).div_round(&Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_val_fail_1() {\n    (&Natural::from(10u32)).div_round(Natural::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_val_fail_2() {\n    (&Natural::from(10u32)).div_round(Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_ref_fail_1() {\n    (&Natural::from(10u32)).div_round(&Natural::ZERO, Floor);\n}\n\n#[test]\n#[should_panic]\nfn div_round_ref_ref_fail_2() {\n    (&Natural::from(10u32)).div_round(&Natural::from(3u32), Exact);\n}\n\n#[test]\nfn limbs_limb_div_round_limbs_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(ys, x, rm)| {\n            let result = limbs_limb_div_round_limbs(x, &ys, rm);\n            let a = Natural::from(x);\n            let b = Natural::from_owned_limbs_asc(ys);\n            if rm != Exact || (&a).divisible_by(&b) {\n                let (result, o) = result.unwrap();\n                assert_eq!((Natural::from(result), o), a.div_round(b, rm));\n            } else {\n                assert!(result.is_none());\n            }\n        },\n    );\n}\n\n#[test]\nfn div_round_properties() {\n    natural_natural_rounding_mode_triple_gen_var_1().test_properties(|(x, y, rm)| {\n        let mut mut_x = x.clone();\n        let o = mut_x.div_round_assign(&y, rm);\n        assert!(mut_x.is_valid());\n        let q = mut_x;\n\n        let mut mut_x = x.clone();\n        assert_eq!(mut_x.div_round_assign(y.clone(), rm), o);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, q);\n\n        let (q_alt, o_alt) = (&x).div_round(&y, rm);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n        assert_eq!(o_alt, o);\n\n        let (q_alt, o_alt) = (&x).div_round(y.clone(), rm);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n        assert_eq!(o_alt, o);\n\n        let (q_alt, o_alt) = x.clone().div_round(&y, rm);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n        assert_eq!(o_alt, o);\n\n        let (q_alt, o_alt) = x.clone().div_round(y.clone(), rm);\n        assert!(q_alt.is_valid());\n        assert_eq!(q_alt, q);\n        assert_eq!(o_alt, o);\n        assert!(q <= x);\n\n        assert_eq!((q * &y).cmp(&x), o);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        let left_multiplied = &x * &y;\n        let xo = (x.clone(), Equal);\n        assert_eq!((&left_multiplied).div_round(&y, Down), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Up), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Floor), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Ceiling), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Nearest), xo);\n        assert_eq!((&left_multiplied).div_round(&y, Exact), xo);\n\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::from(&x).div_trunc(rug::Integer::from(&y))),\n            (&x).div_round(&y, Down).0\n        );\n        assert_eq!(\n            Natural::from(&BigUint::from(&x).div_floor(&BigUint::from(&y))),\n            (&x).div_round(&y, Floor).0\n        );\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::from(&x).div_floor(rug::Integer::from(&y))),\n            (&x).div_round(&y, Floor).0\n        );\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::from(&x).div_ceil(rug::Integer::from(&y))),\n            (&x).div_round(&y, Ceiling).0\n        );\n        assert_eq!((&x).ceiling_div_neg_mod(&y).0, x.div_round(y, Ceiling).0);\n    });\n\n    natural_pair_gen_var_7().test_properties(|(x, y)| {\n        let down = (&x).div_round(&y, Down);\n        assert_eq!(down.1, Less);\n        let up = (&down.0 + Natural::ONE, Greater);\n        assert_eq!((&x).div_round(&y, Up), up);\n        assert_eq!((&x).div_round(&y, Floor), down);\n        assert_eq!((&x).div_round(&y, Ceiling), up);\n        let nearest = x.div_round(y, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    natural_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        assert_eq!((&x).div_round(Natural::ONE, rm), (x, Equal));\n    });\n\n    natural_rounding_mode_pair_gen_var_2().test_properties(|(x, rm)| {\n        assert_eq!(Natural::ZERO.div_round(&x, rm), (Natural::ZERO, Equal));\n        assert_eq!((&x).div_round(&x, rm), (Natural::ONE, Equal));\n    });\n\n    unsigned_unsigned_rounding_mode_triple_gen_var_1::<Limb>().test_properties(|(x, y, rm)| {\n        let (q, o) = x.div_round(y, rm);\n        assert_eq!(\n            Natural::from(x).div_round(Natural::from(y), rm),\n            (Natural::from(q), o)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/divisible_by.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleBy;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::slices::slice_test_zero;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_vec_pair_gen_var_15, unsigned_vec_pair_gen_var_16,\n    unsigned_vec_unsigned_pair_gen_var_22,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::divisible_by::{\n    limbs_divisible_by, limbs_divisible_by_limb, limbs_divisible_by_ref_ref,\n    limbs_divisible_by_ref_val, limbs_divisible_by_val_ref,\n};\nuse malachite_nz::natural::arithmetic::mod_op::{limbs_mod, limbs_mod_limb};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_var_2, natural_pair_gen, natural_pair_gen_var_6,\n    natural_pair_gen_var_7, unsigned_vec_pair_gen_var_17,\n};\nuse malachite_nz::test_util::natural::arithmetic::divisible_by::{\n    combined_limbs_divisible_by_limb, num_divisible_by,\n};\nuse num::BigUint;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_divisible_by_limb() {\n    let test = |ns: &[Limb], d: Limb, divisible: bool| {\n        assert_eq!(limbs_divisible_by_limb(ns, d), divisible);\n        assert_eq!(limbs_mod_limb::<DoubleLimb, Limb>(ns, d) == 0, divisible);\n        assert_eq!(combined_limbs_divisible_by_limb(ns, d), divisible);\n    };\n    test(&[0, 0], 2, true);\n    test(&[6, 7], 1, true);\n    test(&[6, 7], 2, true);\n    test(&[100, 101, 102], 10, false);\n    test(&[123, 456], 789, false);\n    test(&[369, 1368], 3, true);\n    test(&[u32::MAX, u32::MAX], 2, false);\n    test(&[u32::MAX, u32::MAX], 3, true);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_limb_fail() {\n    limbs_divisible_by_limb(&[10], 10);\n}\n\nfn verify_limbs_divisible_by(ns: &[Limb], ds: &[Limb], divisible: bool) {\n    assert_eq!(\n        Natural::from_limbs_asc(ns).divisible_by(Natural::from_limbs_asc(ds)),\n        divisible\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_divisible_by() {\n    let test = |ns: &[Limb], ds: &[Limb], divisible: bool| {\n        let mut mut_ns = ns.to_vec();\n        let mut mut_ds = ds.to_vec();\n        assert_eq!(limbs_divisible_by(&mut mut_ns, &mut mut_ds), divisible);\n\n        let mut mut_ns = ns.to_vec();\n        assert_eq!(limbs_divisible_by_val_ref(&mut mut_ns, ds), divisible);\n\n        let mut mut_ds = ds.to_vec();\n        assert_eq!(limbs_divisible_by_ref_val(ns, &mut mut_ds), divisible);\n\n        assert_eq!(limbs_divisible_by_ref_ref(ns, ds), divisible);\n\n        verify_limbs_divisible_by(ns, ds, divisible);\n    };\n    // - n_low & d_mask == 0\n    // - d_len == 1\n    // - d_len == 1 && n_len < BMOD_1_TO_MOD_1_THRESHOLD\n    test(&[6], &[2], true);\n    // - n_low & d_mask != 0\n    test(&[6], &[4], false);\n    // - d_len != 1\n    // - d_len != 2\n    // - trailing_zeros == 0\n    // - rs[n_len - 1] >= ds[d_len - 1]\n    // - schoolbook\n    test(&[1, 3, 6, 5, 3], &[1; 3], true);\n    test(&[1, 3, 7, 5, 3], &[1; 3], false);\n    test(&[6, 19, 32, 21], &[1, 2, 3], true);\n    // - d_len == 2\n    // - d_1 > d_mask\n    // - trailing_zeros != 0\n    test(&[6, 19, 32, 21], &[6, 7], true);\n    test(&[10200, 20402, 30605, 20402, 10200], &[100, 101, 102], true);\n    test(\n        &[10200, 20402, 30606, 20402, 10200],\n        &[100, 101, 102],\n        false,\n    );\n    test(&[u32::MAX], &[u32::MAX], true);\n    test(&[1, u32::MAX - 1], &[u32::MAX], true);\n    test(\n        &[1, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX],\n        &[u32::MAX; 3],\n        true,\n    );\n    test(\n        &[1, 0, 0, 0xfffffffd, u32::MAX, u32::MAX],\n        &[u32::MAX; 3],\n        false,\n    );\n    test(&[0, 0, 0, 6, 19, 32, 21], &[0, 0, 1, 2, 3], true);\n    // - rs[n_len - 1] < ds[d_len - 1] && n_len == d_len\n    test(&[0, 1], &[1, 2], false);\n    // - rs[n_len - 1] < ds[d_len - 1] && n_len != d_len\n    test(&[0, 0, 1], &[1, 2], false);\n    // - d_1 <= d_mask\n    // - d_len == 2 && n_len < BMOD_1_TO_MOD_1_THRESHOLD\n    test(&[0, 1], &[2, 1], false);\n    // - d_len == 1 && n_len >= BMOD_1_TO_MOD_1_THRESHOLD\n    test(\n        &[\n            4217434641, 2983831158, 957997048, 1656831590, 3000005030, 3397493916, 1524177764,\n            1158142389, 874701225, 1462813081, 1367619360, 2801303018, 2789627609, 215719367,\n            3216170452, 431698475, 626354765, 1948186092, 2374814145, 3144956155, 601105061,\n            1178232240, 2555160313, 2595360911, 4288604684, 4266583859, 125722653, 201817397,\n            664583805, 1753913919, 2144999578, 3776810790, 1371327248, 4182636558, 3002281720,\n            1871734359, 2973117455, 2090705384, 824744451, 4231117477, 1910500161, 31831336,\n            2931836758, 3786849205, 2959137635, 2746351664, 4074106964, 2451006035, 2637785805,\n            1672606871, 2076991740, 4073897939, 923576835, 1556160088, 3713754032, 2220129449,\n            1665613419, 2890565429, 2007962628, 3653583281, 3958263098, 2634902570, 503308768,\n            2860598088, 4267080858, 486522024, 1950214271, 2459522693, 3179388659, 1827961427,\n            848836381, 2558276851, 4179490611, 3898139084,\n        ],\n        &[2987492981],\n        false,\n    );\n    // - d_len == 2 && n_len >= BMOD_1_TO_MOD_1_THRESHOLD\n    test(\n        &[\n            256, 2983831158, 957997048, 1656831590, 3000005030, 3397493916, 1524177764, 1158142389,\n            874701225, 1462813081, 1367619360, 2801303018, 2789627609, 215719367, 3216170452,\n            431698475, 626354765, 1948186092, 2374814145, 3144956155, 601105061, 1178232240,\n            2555160313, 2595360911, 4288604684, 4266583859, 125722653, 201817397, 664583805,\n            1753913919, 2144999578, 3776810790, 1371327248, 4182636558, 3002281720, 1871734359,\n            2973117455, 2090705384, 824744451, 4231117477, 1910500161, 31831336, 2931836758,\n            3786849205, 2959137635, 2746351664, 4074106964, 2451006035, 2637785805, 1672606871,\n            2076991740, 4073897939, 923576835, 1556160088, 3713754032, 2220129449, 1665613419,\n            2890565429, 2007962628, 3653583281, 3958263098, 2634902570, 503308768, 2860598088,\n            4267080858, 486522024, 1950214271, 2459522693, 3179388659, 1827961427, 848836381,\n            2558276851, 4179490611, 3898139084,\n        ],\n        &[128, 10],\n        false,\n    );\n    // - divide-and-conquer\n    test(\n        &[\n            2169104186, 2266546494, 587315734, 3739269241, 3114885960, 3686571368, 1230083221,\n            1369517966, 4291553725, 1232833631, 3745253511, 963470524, 3412093994, 715605915,\n            3178840986, 1537155511, 2643999117, 1124945145, 1130467184, 505174687, 279956991,\n            2029663376, 3099875141, 4078932665, 3507974056, 3764533985, 2928504341, 2999119478,\n            2235181988, 8120813, 2049630814, 816255631, 2958134171, 2134573459, 1356483654,\n            1353858604, 1377057347, 3050515126, 1981544721, 3471014354, 2173072144, 1505712122,\n            2385668585, 1593490077, 92053253, 1525861712, 1903853398, 2590603784, 545440811,\n            731662535, 2914628805, 1579744586, 2159061521, 3862444433, 3486035778, 3569159590,\n            1798578513, 679586822, 1027034006, 2821087869, 138364116, 3862434540, 3700050828,\n            3041238135, 203907970, 2724479836, 666267271, 4276247071, 1210965278, 3212904426,\n            3198623953, 2953530971, 254157796, 4263106694, 389863197, 928000244, 489453825,\n            3398590663, 3892546275, 132887015, 982972816, 1812112076, 3203181556, 729377309,\n            2468997822, 4114200925, 3495511499, 2423156091, 642381751, 2588236007, 508136034,\n            2909297716, 2020665371, 2823339182, 4093944876, 1753900312, 2227288358, 3843178420,\n            1383018274, 1337754144, 4067699321, 4094839667, 3612619766, 241995072, 43874530,\n            1329365494, 1161788309, 1343981322, 2661807206, 3916970745, 3208129678, 2607521742,\n            4068076440, 2254858029, 52800437, 2977865502, 2752070351, 840472004, 993872687,\n            118561354, 281929094, 241294936, 894356352, 289721033, 658212066, 2618650207,\n            997997486, 2912241249, 828533444, 1694023493, 368405691, 2952571418, 1897728140,\n            3178382549, 433809308, 1079641707, 913972412, 127906934, 1696809357, 4135380244,\n            862031081, 3680249566, 4137097186, 3602972472, 3335499618, 2982048038, 2435876884,\n            4160199134, 3332420996, 1469463193, 3949621168, 4019057802, 3431928811, 241891262,\n            4190148730, 991409256, 487806424, 685244570, 703993726, 4044357137, 3327796046,\n            1784380542, 1000763217, 966313870, 3075333333, 1734085949, 913022609, 4245248443,\n            3252643922, 806393395, 2476394527, 3747108106, 392268399, 2776259136, 2995460881,\n            3323006399, 2205717476, 3139072617, 3312440544, 2390989321, 3330711647, 280322670,\n            3221287591, 3672189452, 2085991953, 2701899535, 944470536, 3459091473, 669958019,\n            3341466114, 1375663389, 4178951502, 1887416017, 2960114949, 1805082649, 1897118491,\n            1735206477, 1086467373, 3454663842, 3027811502, 2681987258, 3932510644, 1041830424,\n            3552076035, 3424876359, 1886621954, 2650649785, 3695516428, 71584725, 168707053,\n            740198485, 2245105417, 1249177483, 1722102768, 374173663, 297078497, 2990861606,\n            925762985, 2001492, 1646443443, 3583906616, 3312776133, 1157309588, 1335281328,\n            2109828349, 34076132, 2168747053, 3778129093, 2613456818, 1560157805, 4195434489,\n            2487913229, 1609822712, 2764757271, 4283118804, 91257607, 1080744325, 2493394532,\n            326260208, 187395392, 2939059459, 1885652903, 4191985814, 3258074631, 3513150040,\n            3580927149, 3407053353, 226470876, 1817235991, 852868000, 214844744, 4207902570,\n            2902398660, 1397161252, 4138041363, 757796679, 3031247970, 1048623352, 661015139,\n            1415029830, 2485923562, 141373475, 1787794282, 1976681319, 1253461810, 1392275594,\n            2429887226, 2877605657, 1263266041, 3484472193, 2640875272, 1801160237, 4069713126,\n            1934086126, 192869060, 3283904145, 2763023257, 989311613, 4108856559, 4226641951,\n            3128021950, 2529670899, 2772914524, 1201442981, 176669049, 3707600374, 3706141284,\n            276672151, 2904754467, 1347188130, 769251759, 3322969014, 4037207402, 89044259,\n            1314731683, 1220332916, 438537136, 827090059, 272783156, 38244839, 2305761897,\n            3723044685, 644855780, 3551390010, 3080020204, 3622120389, 1104906535, 2333407502,\n            1345296288, 3700728088, 1599981349, 3670637655, 3168618533, 1373988250, 2598638204,\n            2174612205, 945499273, 1516940873, 1689708547, 3883475244, 1794555293, 969139846,\n            319304823, 197055825, 2598587648, 3355480329, 2619765319, 1140474610, 1254318132,\n            547674601, 852635669, 2448264593, 1227857672, 2436426747, 1094311339, 1981571015,\n            648000603, 4136039667, 1172894412, 2484651184, 1368629311, 1617781838, 1466927120,\n            110324911, 650355804, 3280790286, 242161684, 3602009741, 1994089400, 3324228020,\n            1722483735, 3385991773, 1733478840, 1986423929, 3118968494, 4214422449, 4257358954,\n            3002156517, 3342276360, 3961751029, 1044818187, 1302652353, 3780349809, 208159762,\n            3921381160, 3104805287, 701555864, 1353151101, 2110331602, 1065775293, 3138173139,\n            2673335412, 1332663987, 2532658640, 1175704936, 3679818302, 2587893347, 1209649581,\n            2160090389, 330309148, 812388071, 1856530929, 1621848118, 3595859350, 372670625,\n            856076462, 1710799422, 2493451671, 142603177, 1359238753, 3676968997, 3302712549,\n            2781924367, 822719137, 1553432401, 2179118972, 2647958472, 4231975017, 3662950204,\n            1513113991, 3143506626, 4261352924, 2900864288, 2505227245, 1285289303, 3374032515,\n            1343085626, 1298169727, 2712611178, 2519581207, 863950575, 1044705613, 1608844529,\n            398557619, 2405597933, 2442595621, 3756322386, 497719075, 958070332, 710843530,\n            1361414502, 3604632029, 3231349850, 3610106540, 3750520155, 2250988708, 2584496493,\n            3558352960, 847973690, 291227960, 3347729096, 718140050, 2842802593, 45528740,\n            1213748814, 823269856, 1820806986, 2274362480, 3357823158, 2054374162, 3650723151,\n            1083860767, 3888008023, 2654794365, 1844177589, 2412317894, 665263029, 68335398,\n            1937681761, 1826086466, 2497132629, 2053584711, 766478134, 3524809898, 2670148828,\n            2393556691, 3637792476, 3212231999, 1742932892, 2227017682, 1415769555, 2646519675,\n            4134401864, 4082068803, 1489292682, 1791908612, 1508761188, 2209720169, 4078191455,\n            1533239903, 1768397400, 2157145812, 2565607675, 519979525, 4034426142, 1802535614,\n            3593889411, 3552848103, 4200389446, 3707485453, 1542526970, 1196075302, 2665590567,\n            2739194250, 1399657538, 113759040, 3183789024, 386168896, 3295775459, 1126370167,\n            3951610340, 3551153197, 1690373840, 2358923787, 4229534809, 2290337908, 3142294436,\n            6187128, 1890727395, 4243456854, 3017228946, 3877724493, 3444342781, 4211602385,\n            183761949, 1350782665, 592876667, 433343586, 1817557528, 261342788, 2125735308,\n            3252124670, 1044819933, 2708341279, 100284000, 1935238212, 3692459811, 383621158,\n            867374712, 1021196147, 530727196, 3915886219, 3705268858, 2857571834, 39817906,\n            728954116, 3793147370, 406405776, 3215234366, 2390137796, 1950992336, 1570696989,\n            2517131965, 1753011612, 3117489998, 1817087642, 4076432149, 212175604, 4209324605,\n            249521560, 23902299, 4101107861, 620892789, 2870257694, 2409554819, 4089101702,\n            752496922, 362566394, 3459326044, 2058596304, 2035287414, 1288805897, 3459829946,\n            3477025798, 2693442504, 606291269, 3716454206, 2017617901, 739955186, 226702924,\n            1506656210, 564432407, 698436937, 254384295, 187952024, 3541301121, 4130651539,\n            2092000582, 1462681196, 2024159384, 3025822813, 4206822061, 3305239609, 2483534937,\n            1068789172, 3171775935, 4213371381, 2105143064, 1715930888, 1869129579, 1721290855,\n            726914406, 1055443769, 4127573087, 1131510133, 3464915074, 3962097334, 4198659475,\n            449084358, 1255330246, 2217278306, 3142203879, 1060366183, 1086505252, 2196640428,\n            3020011420, 101613015, 3615286211, 3719078597, 512776700, 1670970979, 2918688390,\n            539186647, 3899361016, 3899238233, 1503014623, 1487072013, 2554631966, 640480738,\n            2906553626, 1264192892, 2306406723, 4030568138, 4056096494, 3608358777, 3240979341,\n            2671626653, 3715996998, 983432302, 712348732, 2406877846, 32785806, 3076643355,\n            2166512728, 1664977926, 379356343, 2822820700, 2920574885, 1252499465, 3427197294,\n            1702237632, 1641655300, 310170158, 1001329555, 562240182, 3713127974, 1400603861,\n            4291073476, 485459242, 1624227405, 3436522834, 1213896273, 893370150, 3608415729,\n            89540222, 1549103010, 2362944877, 636789508, 2413471028, 2932597865, 3523220925,\n            3113130274, 669409867, 948785250, 2353176063, 3868467803, 3484917154, 2551915221,\n            1497486585, 4152651850, 473143127, 998729612, 2905656591, 1182540548, 3623426979,\n            1806548948, 598537433, 2345218067, 2744900190, 3658378705, 1964774718, 2557442350,\n            1799636549, 4153665976, 3300594666, 682645932, 3787913729, 2627374889, 2780368898,\n            3053617139, 2751701327, 1952207418, 761193466, 795600024, 460949087, 2883354289,\n            2416166804, 2024094265, 2645942993, 1321335098, 4080983696, 3719057466, 2761861073,\n            876455883, 2265708436, 1295460078, 4221100394, 327768739, 3015153526, 631331115,\n            3428464785, 644806658, 1607685691, 2709965965, 2477974591, 4185293236, 3564199615,\n            5024334, 1218905327, 2381178079, 3421492726, 3210172738, 2208193787, 3497539969,\n            67679408, 7015329, 1644345354, 1219650877, 3999432182, 787420821, 3125125301,\n            3551310228, 1514288276, 4184725579, 3923600454, 342747221, 2581849732, 654180323,\n            2328957051, 1611256108, 3331006737, 788693120, 3401041379, 2099076468, 1628705595,\n            3859087292, 2072660933, 3257911942, 984362662, 3077084901, 1851298543, 1203131946,\n            1027287045, 3054998432, 2653266373, 3019736717, 195024883, 4171454841, 2527872129,\n            1247020327, 2238591475, 2136657438, 2340932338, 2934529639, 3272613638, 2185810440,\n            165859626, 2304003399, 3993415600, 2437076830, 3780217527, 2707007352, 208843797,\n            3155075128, 336707716, 568567552, 2653218265, 561879893, 2244946665, 369107514,\n            449372466, 3941906096, 4130057272, 641659453, 4111061561, 812270662, 4279338122,\n            470975590, 3494637046, 2762073253, 1757357680, 867114230, 2219045455, 94626870,\n            1137750480, 2094083377, 3138049052, 3894576321, 1378390851, 2665729658, 3104615470,\n            2936479206, 635788017, 3475293009, 702959182, 4237902922, 313651363, 3029245314,\n            2741552996, 3659722846, 2604607686, 534266423, 2704761681, 1711186117, 1592045306,\n            305708572, 1642121404, 1597934575, 1265263680, 4290920109, 537137446, 3140075852,\n            2898671495, 364470582, 3399686556, 427464562, 1727273367, 4033988735, 2229384209,\n            977641014, 3910691764, 2268933684, 3451806563, 204040124, 1396741907, 3978224431,\n            2183874291, 541967491, 3026397898, 2065096561, 961793538, 3683498094, 3088514164,\n            3743738285, 1346128225, 3719735346, 3228089802, 3009395215, 1568158796, 1870781853,\n            728601499, 2727218958, 50783576, 351811718, 1118170454, 2810777608, 1996734855,\n            2444030542, 3509123551, 1649933419, 2057107104, 381073891, 1651296068, 3691277418,\n            1252885223, 604972451, 3560912853, 3381041205, 97236104, 4018969688, 3285100340,\n            906433788, 1674945334, 2291802158, 4143691201, 1121520461, 1907818021, 3817648523,\n            2696920177, 2029578019, 3359867876, 4035314026, 814831395, 402590457, 2757255435,\n            1617756566, 2573316001, 952926090, 26184857, 1491250719, 479641193, 1246115200,\n            2071561116, 1740343273, 3930947184, 849382562, 3146753986, 2079815766, 1124558195,\n            706118855, 1624669925, 2345125117, 1104509365, 4253600455, 2178123171, 51311084,\n            644240166, 4235897745, 1552583610, 2721864023, 2417820136, 866003296, 3100038290,\n            1138399889, 2621877527, 35166564, 2925990087, 676411279, 824163386, 3059725138,\n            3436858126, 639114670, 2354917892, 3668885469, 538607516, 1188540552, 2077947642,\n            4214121777, 1024066855, 584585760, 3330067560, 3289211050, 4227743647, 1048503204,\n            3682815131, 3593095813, 724046659, 177523551, 789173931, 3210826214, 4114794229,\n            2001369528, 1922224607, 2449629560, 2990923760, 1590140407, 3066241294, 2032178641,\n            1673025735, 728782818, 2805995869, 3173476316, 4095043043, 4188792079, 961420687,\n            78547373, 331719917, 3623238477, 4199725886, 2474752488, 1757124968, 837328916,\n            1408306379, 3214330220, 3355378613, 389392287, 2212359467, 2671491064, 2411527388,\n            3622122999, 1506404106, 3192630979, 135884006, 2398972643, 3221225957, 827475224,\n            2670120145, 3556393877, 1151874066, 4001558171, 773853920, 261365390, 2930272664,\n            2171104793, 3679192861, 1286480701, 3052752341, 3704064736, 2857905507, 323617567,\n            500166971, 3590167140, 46687505, 3603631510, 574954751, 1921803608, 2826015895,\n            3138948179, 3471354167, 1087583334, 2872377970, 589736930, 3600161138, 4280276795,\n            610467300, 4258855269, 1847560302, 89888737, 3455621079, 1271345555, 446001635,\n            1740292174, 1118130455, 1649510985, 1314419877, 2732937708, 749289315, 911962385,\n            361189198, 1736019975, 901913856, 1697911811, 512137942, 1863970636, 2127135390,\n            2362086418, 1086237732, 509394495, 2529713980, 229310079, 1661114917, 1240908759,\n            1028403199, 2183953926, 1127564377, 3529642168, 557447511, 314233677, 1785885521,\n            948058680, 3314696870, 3418731379, 1093740990, 1408897230, 1674741555, 2040518897,\n            500968889, 2496717966, 1599286253, 927417612, 846393794, 2100310692, 654673974,\n            2475673804, 3656332830, 4291477953, 3810417562, 1914048410, 1890554346, 1707870195,\n            3321510012, 1070941267, 1096480276, 2946865379, 3751928683, 1860758395, 3419660556,\n            4012128602, 517029378, 1439950265, 502253691, 2697781940, 2999363300, 2555052305,\n            852916430, 3054976477, 3742735044, 2485908580, 1698982608, 2625028734, 1580539136,\n            3300904616, 633144061, 886348308, 111258399, 1439126181, 2276519459, 3959771808,\n            1314171199, 2322947590, 706448164, 998967466, 3140589807, 3516861163, 2443112013,\n            2783111182, 792015165, 1578481086, 3460528207, 1455852169, 3304443593, 123860242,\n            1860448346, 2199267391, 3894670775, 3728263116, 530899313, 3431936766, 497193688,\n            3964977529, 2359257224, 1413751341, 953616340, 2193659597, 2870937129, 2560871048,\n            3424144210, 2330060314, 476593761, 4111398811, 224492168, 2426790462, 1366265513,\n            3547692500, 237014373, 126994210, 1698344909, 3097624535, 2606367774, 2139247575,\n            4278291258, 3111057613, 3597265089, 1486559051, 3888932297, 2068681921, 4018333295,\n            1237578874, 1394533778, 3019039915, 2435030995, 361267457, 2911469665, 109581803,\n            4017370036, 3519506811, 1390346590, 4165412046, 1729882859, 2014283168, 1289243407,\n            2679198626, 49392930, 921068681, 903443552, 3928862909, 3914934492, 1656987052,\n            432711693, 1092080705, 1009507400, 3442035405, 2796451416, 178836372, 1341085119,\n            472247744, 1804872218, 209397624, 3871538735, 2625371000, 275406901, 1757188449,\n            2669657607, 3604284276, 1912410848, 4250918838, 1504400908, 2246112278, 2284856099,\n            1017170859, 106995822, 2930347834, 545564822, 1065545923, 3484558996, 3235687826,\n            1118147092, 564820628, 3004798730, 856304451, 822860516, 3255412373, 398693215,\n            2329594629, 3107774102, 3795269757, 1827602725, 2395215194, 3203911581, 1655534638,\n            211158317, 3318323836, 1658306711, 3266378120, 967971461, 3700196933, 4059454123,\n            641302150, 3758966844, 3400068366, 4198115937, 485338847, 4078693738, 2194750103,\n            1916610491, 1608221201, 592771197, 305961735, 3496309244, 458632142, 1436284187,\n            1883874902, 362906529, 38314525, 1950785222, 3918473285, 4280158367, 239076663,\n            2870128186, 1858894036, 1027494104, 3282242213, 4129496568, 441027295, 2379941678,\n            2193414438, 2212796476, 2277788540, 3450917896, 1884715287, 4063547227, 1121537361,\n            1032757188, 272161392, 1784943104, 1790206106, 713995873, 1769042326, 535564457,\n            178454254, 618864620, 1597799935, 3270467251, 1842808299, 1018709091, 3361794236,\n            4221130656, 1039251424, 1054506074, 2666864849, 3685051761, 2437756290, 4019119161,\n            832674533, 2148950955, 2940298749, 1756399996, 1105163896, 1271960636, 3581940733,\n            4143342134, 3823790830, 3488841246, 3005908556, 1229249490, 2249360558, 1520953855,\n            2394117874, 2966743152, 1745813079, 3874896381, 4191350629, 3459390903, 458890909,\n            3016227910, 2882279471, 1489028867, 3561423182, 3768844180, 3613799407, 1316785634,\n            1110714379, 3825900063, 3005543401, 2578216023, 536834091, 1054735610, 2490400103,\n            3824100200, 1622334988, 2973431210, 3511057535, 3411074810, 2839293801, 3615424236,\n            1494356926, 2903750858, 2317164586, 798613884, 2208508524, 1120667415, 459634045,\n            208258335, 2160960212, 3770793497, 1682162327, 2891358722, 4253581389, 1506921959,\n            1520649651, 1728239848, 347197154, 1030568701, 231999862, 87543989, 4039870891,\n            3025487032, 4160936744, 824286621, 619876628, 3974227642, 2732935886, 3410258822,\n            2406057333, 1165743060, 940866829, 3430451491, 1309520185, 262533243, 947988428,\n            640974029, 2310827524, 1568049953, 913937604, 523285756, 4019938271, 997714649,\n            2289745882, 2914301529, 2284035199, 1811643961, 1014663687, 2060371185, 3157474020,\n            348590874, 2826896064, 1227085771, 547468599, 862186803, 1711960313, 1600420494,\n            1479186385, 3931860334, 602002980, 2799154778, 1091430947, 3212154168, 1149219740,\n            3667760717, 1338808890, 2090747344, 3732991295, 242914573, 2349118025, 1074929252,\n            1578439132, 486000813, 3540915699, 313415647, 1456544360, 2413478967, 1922572049,\n            3983685868, 1692333399, 2800078402, 3672468944, 941785200, 2799315558, 3495998609,\n            54827483, 3471966058, 1350080114, 1185538001, 1146752796, 2383192228, 816416261,\n            1367006476, 824307946, 1275718301, 313125425, 4174575084, 2115741142, 2899939598,\n            1437334171, 4036006477, 3402338404, 1622118790, 1903918451, 2195630834, 2817175072,\n            1580143842, 10841607, 2218444240, 328726045, 2172285181, 666198999, 47210791,\n            217474374, 3425261191, 3792177351, 1102768641, 194832930, 2798628092, 1099023742,\n            2169630244, 1006780406, 4040150832, 3495364601, 1795130764, 2557506394, 687172551,\n            1437043653, 596022564, 4124841760, 2832726960, 3976626928, 1940701362, 2129400780,\n            1335265202, 2623243469, 475218973, 4176790636, 2894028481, 3311380020, 3407731969,\n            3440303872, 4282973538, 1107580287, 2913854988, 3832450081, 2983552995, 3234935353,\n            1905487397, 1438250438, 199108879, 1165802593, 3979735320, 292406483, 3789152918,\n            1728782338, 1538302953, 3095891341, 4067011302, 947270848, 2901984827, 472807909,\n            1124867728, 967972503, 1179911480, 905593964, 3081206343, 1396858745, 1962485374,\n            660034736, 2323793427, 135073240, 1624297728, 1102603846, 2597005485, 2882403403,\n            890183758, 3191082568, 1919982661, 3168083235, 1958438352, 1304175725, 2908775316,\n            1173988864, 294889039, 4007902026, 1120126077, 1310854594, 546116031, 2848470459,\n            1869698025, 1813333748, 2963438773, 3933908194, 825386399, 2267683410, 2388979811,\n            1581641113, 433859520, 3307533954, 3715973826, 3034129662, 1356470162, 2053300467,\n            3705599280, 3545214348, 881711657, 3370463532, 2612058211, 3022216886, 166079300,\n            3792395371, 771494606, 367422082, 908499242, 1751065177, 3739297223, 2531239191,\n            1790567517, 3657254622, 1969671979, 1753491710, 4166832315, 3390847739, 2694228751,\n            3731820124, 1556938927, 832291283, 2595430255, 3509265058, 1963314910, 743669390,\n            2316110695, 3553152608, 1539708075, 2581957193, 3581782561, 3733834639, 3874869903,\n            821452300, 2654378399, 1826247143, 427372641, 2528090922, 3136006832, 716079731,\n            3725286491, 3774681077, 2364200620, 520438267, 936152988, 1300229995, 3318827623,\n            893385987, 827395790, 1238576928, 1365658130, 4213726033, 68568077, 1878508859,\n            2980664309, 2505293566, 647443774, 893999753, 576745315, 3786437080, 408297414,\n            4253424139, 56347062, 1531788504, 4279766238, 897659733, 588650771, 2281920358,\n            2662121367, 1247856184, 4077376735, 3094366352, 3475315562, 140900543, 2320176873,\n            2731282493, 2529550865, 2646680520, 3977230880, 610342446, 1738659355, 2322564480,\n            1977463984, 3253404512, 3381161114, 4072345980, 3740051219, 2680106281, 3143028156,\n            3832831863, 1270452360, 127171546, 1648356616, 2300166574, 636625275, 1177009521,\n            846853350, 1040691569, 2730938915, 71966795, 3559433301, 466808619, 1872187366,\n            3586382562, 358150119, 1901267937, 1893851852, 3145952136, 3674931561, 1233478860,\n            40233330, 3052854867, 2874428838, 1759762421, 3681648875, 2015813552, 886942698,\n            1158156557, 1493555589, 1504676074, 3260453531, 1445680526, 606176540, 3851133425,\n            3378052885, 290847531, 608022018, 409268527, 2561487059, 552122872, 3296447559,\n            657047951, 1631287800, 3753000079, 4193809942, 884351757, 650107527, 2377568881,\n            3347052935, 2286485244, 3723839791, 2320149490, 2621979946, 3594571203, 1034530050,\n            1013146660, 4171674723, 701670817, 2422914046, 3977354486, 3004818531, 2002938131,\n            3118226044, 1543549044, 4092997654, 3942653186, 1844763496, 2322984163, 3124918738,\n            1417239715, 235247237, 1050357214, 2534723786, 4219669748, 4011595633, 2692726487,\n            2351983087, 2725167432, 1625523175, 4047392192, 2234302489, 2849441834, 3972066233,\n            1791829507, 939116825, 1749334517, 2363503506, 1794949600, 3554843296, 3658516450,\n            3792519561, 2851405786, 612179385, 3421837507, 1838122126, 1526446643, 473977778,\n            970578022, 4289507606, 3575021665, 4054714975, 1548076097, 3509765025, 1066969507,\n            3153376781, 3298819216, 3889250694, 69259617, 1666832803, 210278288, 3699475297,\n            3835947114, 3339052234, 612647103, 875803198, 3239057673, 3476910228, 1774715092,\n            2997268264, 1885163212, 2535759355, 4037082439, 4131425791, 1431931269, 2344841786,\n            589132544, 3925395746, 784033909, 2001561327, 2875535943, 3682912780, 1098615571,\n            801194772, 2827770013, 1354890928, 2166517733, 939353793, 872778539, 3631178723,\n            1264903893, 4095947484, 4181434456, 4200174517, 1474870556, 1627027654, 151292710,\n            368473093, 3942717951, 819142369, 2349507002, 4074749712, 2489107860, 1097307038,\n            3020812166, 190306378, 3215127968, 397275036, 2249230863, 443420014, 464013638,\n            2524035741, 2741857795, 2086019319, 1734459117, 3393166271, 3474161219, 2289897976,\n            4189280756, 901946899, 1802590992, 2188289127, 2913766496, 1889227592, 3897013662,\n            1464728618, 2940520918, 2906043873, 2148982467, 2404803587, 894173079, 2495095800,\n            1534807391, 3036557983, 3313990361, 3092310990, 3745247632, 2003342030, 4001597438,\n            170941187, 3898936460, 1767517480, 2465767943, 2725934507, 905298257, 2054030074,\n            1040718227, 130491459, 462307151, 79634941, 39984710, 3394369759, 123808373,\n            1976379290, 2760361748, 2906583982, 2953946087, 809471573, 2116054715, 3917916932,\n            2343670492, 3233424199, 774812558, 1756949698, 3194486356, 946191489, 3049294096,\n            206896940, 2241842324, 2913740804, 2608611645, 2252633590, 1782956542, 2558802876,\n            189416278, 2914035148, 53575167, 657929910, 2197973107, 1186173886, 1652038937,\n            1667328710, 3827180894, 1328118528, 627951742, 3852917235, 1261933427, 2796832443,\n            3909139439, 803119467, 3434493749, 3852387669, 827924266, 4132690149, 261809517,\n            898612437, 1360913566, 3963554976, 3291202592, 3510814304, 1941420827, 410368266,\n            1914132178, 4062923120, 1846671715, 3606753265, 3301693690, 2422891416, 4171900211,\n            1179609418, 3026009073, 1460697318, 81708763, 2241853979, 3184526697, 2433342232,\n            3825378463, 1733696008, 1589648295, 130255373, 693921782, 1859354595, 1919721838,\n            1186247508, 4108823444, 77734465, 2629607792, 1076377333, 1990488420, 2937396723,\n            3004759683, 2318594408, 1150102008, 2213733556, 3220708392, 2308953052, 2749064027,\n            2085137171, 1117546275, 1886156676, 98424960, 2074093393, 2154503198, 189860005,\n            2916276379, 1952025216, 3574945482, 3027541861, 3394630765, 3511855818, 3454027741,\n            2764910997, 3888451786, 1821639450, 208178455, 2500754493, 2116466467, 2562510724,\n            2236268494, 3533596053, 1136585978, 1638867361, 2351171373, 1768471085, 1475147430,\n            3007554507, 138204569, 355310868, 514355272, 3368854386, 4017757574, 2764261877,\n            2324034334, 1307181094, 2699433145, 1799666796, 1658078944, 3051201857, 4064940189,\n            2720978395, 1229071670, 571398165, 3644846781, 1901207895, 398691399, 2312366555,\n            933751814, 2120985531, 2216142231, 3139218360, 1909928326, 4233628411, 1909827411,\n            2995576052, 3808488656, 2242622915, 3933434554, 3788084924, 3334517362, 3266016991,\n            1568666969, 1229301195, 880438760, 3568043601, 4141504174, 840071256, 426306577,\n            296537409, 3733271638, 617460425, 4156981489, 1596412970, 2310467087, 3835423522,\n            4164901542, 2204793257, 644780121, 1452829515, 2477069580, 516109421, 524261758,\n            117982878, 1282333694, 2307680806, 3224487996, 1113925619, 2143297676, 3177316878,\n            2381663400, 3278164422, 2125512960, 1035639931, 795806882, 3988921620, 3738216448,\n            1187094494, 111058657, 1478788191, 1563430022, 3618637339, 247022523, 12616232,\n        ],\n        &[\n            2598813973, 1904197782, 1215006787, 2930851058, 147918011, 1108782873, 2193711651,\n            927233146, 4123817534, 3041706771, 2553964352, 2170557862, 2838589053, 2708835560,\n            2407955329, 1653207324, 2470552742, 3357058396, 1072990020, 1514783799, 1734243804,\n            1048851304, 3193592152, 1383793603, 2063694499, 3485786208, 990960024, 3569185429,\n            1155708496, 1416333121, 623402323, 3585705881, 2928088588, 4117621841, 3292316347,\n            2217241313, 1950216441, 1391040412, 2926386224, 3240560579, 3973468920, 2847202482,\n            2728825575, 2388048350, 3463506691, 3707514927, 865702555, 681215612, 2250616248,\n            1724513618, 364443494, 318451745, 1623887866, 1280032334, 35195442, 3837277484,\n            3573894817, 1602810477, 2072874171, 3800895590, 4253419440, 3499691102, 3587932863,\n            3517441378, 514856216, 1648457744, 1474005402, 700069688, 1803098596, 378514692,\n            3068261379, 3834605983, 93188389, 516236732, 2468656032, 4095977127, 3706578522,\n            3452719188, 1052956630, 813640425, 3047313546, 754584849, 3584789926, 347367947,\n            1332536470, 94171148, 626270691, 665836088, 426974652, 749957497, 1566095325,\n            3066600838, 4106843490, 318006871, 162882344, 3632111614, 720131390, 2147721707,\n            2217002633, 2466031857, 1087787961, 753159680, 366300446, 3082468114, 3984408901,\n            4057095635, 851983865, 4150513631, 1165194321, 2055798628, 2975996128, 2693369845,\n            3726562839, 3482086133, 4069043610, 1448967233, 700979569, 1698695640, 2318799208,\n            3684286306, 4092668018, 3628416641, 584456626, 1679287620, 1813093480, 177926224,\n            998082621, 3120492909, 1996199168, 3491975384, 3147828383, 2087111449, 381360867,\n            1127916110, 3472685226, 3293954452, 490729044, 3264678372, 1277191068, 4239255920,\n            2343436004, 2451796708, 1844810428, 2031787164, 3768550378, 3743966167, 2637191163,\n            3978079759, 4158883864, 1561267833, 539304561, 3435817790, 277956235, 4028949085,\n            2643928548, 2755470882, 3796376394, 194519280, 98463778, 3179299980, 2447702226,\n            150057260, 3463931601, 906456277, 990239469, 512339370, 2261507614, 2826877099,\n            3855453279, 2271503686, 841719073, 1591142177, 2651714174, 3361609137, 3279250024,\n            3326254458, 333896144, 3528172547, 3941409760, 1558812882, 3841874000, 3172301956,\n            4257828380, 4114850067, 2182891616, 2046840523, 1555755083, 2209766728, 2332501890,\n            607500373, 4124706810, 1713777506, 2341598661, 2284959418, 2746608689, 867377978,\n            336903700, 2503448208, 701980251, 2377952035, 614377477, 4284955660, 3814775340,\n            74129761, 1280559390, 2313692692, 1849232614, 2933185433, 1636271207, 630083065,\n            433420841, 471362220, 4210050941, 406797277, 582028044, 528813510, 2576049278,\n            540310007, 2789529550, 3534664845, 3236430259, 1506736021, 1977751182, 2006662671,\n            3679126532, 3806292929, 322589328, 2243078958, 2178902647, 2189720772, 3791358339,\n            1508304160, 1013509043, 3587377598, 3623382349, 1086144534, 1599008554, 1093927956,\n            2876914186, 543927302, 2219667262, 3853928343, 2487266159, 2613372592, 3550686437,\n            3716813778, 961453654, 2039051889, 4283100852, 3145660844, 1250225831, 198998794,\n            3726057928, 2284062625, 2219120593, 2244278486, 3790941761, 4203700163, 3879487839,\n            2965718505, 2863698764, 63056401, 475617471, 399914031, 459648012, 3133447831,\n            3412742746, 1512219896, 402842103, 4119870394, 2231397283, 1516833787, 1104380754,\n            128232714, 296865691, 1663298638, 716369560, 2904885147, 4237273250, 343946912,\n            2604094031, 217784841, 1162604926, 1345215097, 1426555576, 3614102008, 3943750939,\n            1639058309, 3296139198, 1330339563, 426593850, 1532081057, 1300177557, 1482433791,\n            812987015, 3232993095, 1037853411, 645052957, 2928052694, 1226934622, 2336175954,\n            1920836876, 2517428765, 3726338359, 4041660846, 2092081260, 3380258824, 1697518166,\n            3349439761, 743024530, 1795639086, 1779094250, 503268222, 3554837208, 2986098469,\n            2762697287, 232864157, 3768291070, 2983947152, 1577288457, 1050740564, 834028049,\n            1274280907, 3769464765, 1910494593, 2197778112, 2813074316, 2881147492, 1559228213,\n            1461309572, 1700587844, 2988103759, 1717431083, 951586291, 1707887130, 985013185,\n            3532658879, 2597699341, 1911327175, 3080664111, 3484272917, 794091071, 2311407322,\n            342113645, 1768703425, 2382063884, 3831832486, 3217975952, 3451120056, 3035392294,\n            136312738, 1699608380, 700762772, 3631031559, 1846450824, 1131124755, 1046357323,\n            2552828340, 2598371768, 795498120, 3174589062, 3838467339, 2334795665, 3324675939,\n            3403942196, 2075108646, 4259667163, 545251542, 749294402, 3324014447, 1729518387,\n            3551096145, 1758729590, 2379344936, 2455329109, 1757426268, 1706226190, 902425986,\n            2432676044, 2039145952, 410402636, 1639537846, 1305863342, 256740017, 3207555620,\n            3925040779, 668173470, 1141011911, 4212893794, 1581027147, 363670779, 2004465281,\n            1138726957, 645471449, 3585049231, 2777598154, 2922780411, 2222055902, 3815639175,\n            429697628, 4000303790, 3545345324, 3542109929, 509705074, 3722614775, 1753809005,\n            1973665455, 3780943261, 2494678174, 2641931684, 3388813526, 3347201186, 619828405,\n            2625911693, 3122659421, 3479474745, 3245356132, 1832479544, 3308783684, 1963028441,\n            640786937, 1641844190, 211570630, 1733515651, 2171524601, 3396267685, 3914881000,\n            996687218, 1617466047, 3343054134, 1737892381, 3544966831, 3416864496, 107959379,\n            2249494870, 793869312, 3685840230, 1757287133, 1655716303, 4226516527, 2538565645,\n            278467613, 2644886589, 2699974905, 1984329139, 1005957589, 789155264, 3666799939,\n            1611583926, 809907316, 3452803056, 1107204019, 2209104411, 1462179962, 2853352142,\n            3225410978, 2108213590, 4192481899, 1912371245, 1171525154, 3712460427, 2560727022,\n            1086797266, 952026066, 685685805, 1936296543, 3499184244, 196202245, 3078070455,\n            2171291372, 2730765878, 1573851700, 2931331934, 2847177501, 3478529515, 2313080814,\n            1556316903, 1559216686, 3130885922, 1862119430, 3274978261, 206968409, 2624567354,\n            1978029702, 4063454216, 2415324407, 1518621963, 747943965, 1111109939, 4070402813,\n            3113587512, 898431887, 316373197, 3046639257, 173632841, 3798588025, 1794547053,\n            272903937, 863380298, 2774736392, 2777149271, 3206794646, 32657715, 1025716581,\n            1615425071, 3173842612, 2073903119, 2153824733, 2329799226, 2341967952, 473768936,\n            3486256934, 2848218304, 2428724257, 3159637305, 2126501230, 765243196, 3425509759,\n            1131263732, 2515711177, 3855554546, 1023477320, 787209967, 336492935, 2359162223,\n            1128313353, 2209616384, 389804749, 535230248, 2210531774, 3227122449, 1267072928,\n            675693308, 1385601874, 1416098547, 4192675028, 2716632450, 4177948782, 13560634,\n            3703614488, 3901742123, 2270254077, 3759771486, 581228935, 3949774462, 3458012976,\n            4163726158, 1602955605, 3047124020, 1612897320, 2437308530, 2370536309, 1561087937,\n            2116794827, 1579558066, 431023695, 689842616, 2342172842, 4203138565, 2160272314,\n            4192374041, 3675193896, 1455954294, 3940635994, 4025127357, 4027321239, 1155472117,\n            1928138697, 1875048682, 4087308487, 4291614860, 1175537429, 3503698743, 2187471558,\n            2673330725, 2702107217, 2763809959, 2274134903, 1077148334, 2166895545, 1831099412,\n            3296218829, 2076626325, 1104984380, 1764164194, 3056784327, 1988083103, 3849746178,\n            3460231757, 3983590507, 1641801163, 1321487487, 2277192156, 1700397327, 4163993314,\n            118570737, 2510013157, 342313019, 328214482, 1456063300, 3771950632, 1226087686,\n            2343733178, 1108934200, 3650307976, 118441436, 3857631518, 1808729865, 2826187782,\n            2596972674, 1966611164, 988201436, 3909729734, 2034457184, 3137580128, 437202273,\n            1431097330, 2630459633, 2423317302, 1422128850, 3011012632, 3611423092, 3531891566,\n            1592039994, 734168534, 3492902008, 947200226, 1735249159, 3526990689, 1725556774,\n            1693403463, 3317454666, 2042191731, 3608995702, 497650714, 628421679, 2465885637,\n            4008542175, 68576338, 1372104957, 1927020046, 3573635655, 3090117252, 1774561696,\n            3603424898, 55089895, 2060875413, 116850528, 183816573, 478639013, 3736973628,\n            3606174188, 3086193394, 2548388100, 2591332019, 3032618195, 469584388, 1770142568,\n            205800329, 174943950, 260521576, 2114953066, 3428041459, 860714084, 1560598053,\n            2885505481, 3365355923, 2821218095, 814424502, 94258256, 2857874640, 3213633690,\n            239445181, 1741311155, 70754202, 469749979, 469377271, 634558134, 1314018935,\n            2663122712, 3425107874, 616125297, 1220520411, 363320242, 1717903421, 2177377494,\n            2683338356, 210565640, 3061448891, 1561105018, 3639722552, 2586119577, 264509957,\n            1416442444, 572448512, 3316197518, 4101471127, 1909662580, 3289492851, 702940172,\n            1747588119, 3288795988, 1441233966, 678854386, 2604723913, 373703246, 2055937039,\n            1124872113, 1294098600, 4165350921, 347872377, 4149215174, 3215450946, 3307233717,\n            3600358822, 2659616884, 552889201, 1684681790, 1821948043, 2909781107, 917768879,\n            2259947602, 2019396153, 3413299181, 603749894, 2467542574, 4017401393, 2519998741,\n            1106606352, 2283516402, 4262893045, 931507531, 257221572, 1471379658, 4223521274,\n            2958168654, 1643148068, 537294061, 3213657938, 3835022365, 3594404173, 777970857,\n            1918635217, 1702205904, 1047564373, 67547546, 3019489110, 483595975, 4130252917,\n            3081408781, 436773586, 1982914868, 3527757249, 1553562987, 4080227164, 822023069,\n            1427193014, 2565421648, 3942884687, 586018307, 1138884595, 2613035769, 486310535,\n            233458001, 106898418, 170926111, 3212999317, 3194995097, 827548055, 1783632131,\n            1458445783, 4273893842, 4169283956, 3425898311, 1900133873, 2830934989, 3597188167,\n            60014629, 2917912426, 3137954804, 1361341056, 4180775481, 946784052, 4199341441,\n            976101959, 1662997785, 1179237245, 372119531, 2815699743, 2114995295, 3901740963,\n            3080952004, 938243235, 1717858705, 1880470411, 3714648015, 2698621435, 4276694893,\n            327245390, 2823511048, 1178264505, 2316760826, 1757942990, 1568677829, 1199580238,\n            3100459677, 1386893348, 1600406349, 3128791813, 874040538, 2965907285, 8663319,\n            2919597841, 1169807363, 2130724711, 2817929643, 2594603073, 975728895, 3248945863,\n            1506505714, 8259384, 2395186489, 64139190, 254403781, 3179528072, 3318835559,\n            872874473, 3221533853, 1278142055, 2865063695, 2096015856, 3893588672, 1650965167,\n            852689473, 2456343381, 2227877463, 3533995396, 2567915364, 3260019114, 3354960043,\n            317493973, 4088542285, 603804423, 3133721086, 2455680365, 2501599681, 2371144161,\n            4224001882, 3900064951, 2295679614, 483545534, 500738921, 259183629, 2958675979,\n            3886544014, 3382548497, 1341558649, 764676712, 2686742281, 3585367009, 2470017030,\n            280649561, 504360831, 3177630390, 691028027, 3630869823, 1850039925, 693186712,\n            2234334464, 3019783104, 1258253876, 2759186239, 2705660533, 1535024585, 16228098,\n            3597194253, 3856258376, 2530800309, 1756061934, 3703461702, 1458672824, 3009579190,\n            325542092, 974024523, 937809905, 180338019, 728257472, 1334683442, 1531729599,\n            4257819380, 3701291761, 2423233504, 3786098144, 776062663, 3861731850, 3717496633,\n            2918219359, 2369401162, 1963105504, 2673826226, 3238671093, 568083438, 4121947082,\n            3892853652, 1632686679, 2302193583, 3211408318, 1938993158, 4122064270, 311269184,\n            2105346675, 1581174365, 2485158976, 2443260070, 1986431168, 1124848188, 1841087451,\n            2704521996, 1214274421, 3662035084, 2837679678, 4043497550, 552208260, 1644975825,\n            1950150273, 4027848966, 4079004873, 647675052, 223752470, 637576072, 949880156,\n            2749078102, 2043391316, 1008133, 253411434, 3799679907, 238227057, 2495985662,\n            1475105846, 2961884606, 652180469, 1691635637, 1430944868, 15398684, 2278485165,\n            3795142783, 2981896799, 1330890913, 2239691223, 407470744, 3702570774, 1624292191,\n            3703366632, 2187395861, 2415878960, 2303069741, 1369122706, 2750340520, 4035673151,\n            1425244662, 25186311, 123582970, 2490005251, 936607532, 4115073120, 2730391719,\n            2823090688, 396451377, 2182998280, 1365726601, 4033770954, 3047868289, 2336389408,\n            688454315, 1299725781, 3304644284, 4238176839, 3914620151, 3029466942, 3172492309,\n            1190474536, 569450335, 320580314, 4004925139, 2557991799, 1493351038, 949583033,\n            3275441062, 1311907795, 106222620, 396788468, 3186456628, 517037899, 2177653619,\n            370023265, 532558109, 3182151426, 954367771, 2865591818, 600183719, 2521622949,\n            3079560626, 1906789399, 1612708432, 1801660151, 3565921772, 2688352000, 1101243899,\n            888006794, 2233649225, 2671500356, 1504445832, 1199168343, 2043022343, 1250919220,\n            1374956710, 1107550604, 957179006, 3319703903, 4110453611, 3311143947, 2774029776,\n            1456730624, 1014119593, 3012545941, 1650066434, 3431589287, 3624715486, 1072097915,\n            3568695028, 478299405, 362822053, 2632030958, 955747917, 2974153651, 2880247593,\n            2837857407, 1533402093, 1550331006, 3833005459, 111580345, 1694562098, 2731241196,\n            2659074758, 1347615125, 3711588514, 1514710939, 3788474419, 3668780501, 3266213391,\n            4081085519, 1196081228, 1049947080, 1820720234, 3100382458, 2198468097, 3708538645,\n            1035729054, 1784655621, 507574130, 2908640623, 3615200865, 1223546227, 3675568182,\n            1661330896, 1399689373, 1323389692, 2981922901, 4156332999, 1902241850, 1428680890,\n            3049572611, 4253261231, 2148214199, 1998921071, 3899443086, 1478235253, 3791927172,\n            1483896530, 3565485437, 915921912, 2258155251, 3426051958, 3307670857, 3029363090,\n            3673788309, 4082838999, 624603732, 573907442, 3116664857, 3586999255, 557493850,\n            1739716128, 2397076308, 2312498391, 767640384, 2119706819, 2637314051, 1070866648,\n            664107404, 616236779, 3020748367, 4122128780, 2009706384, 3245363034, 429196441,\n            4195520565, 4209198410, 2158211364, 3659713923, 3985561806, 1747634790, 4115935838,\n            2827667115, 3073689925, 1621229363, 2774950774, 2538390550, 3506768465, 718261358,\n            564823729, 380006788, 897186389, 3414352487, 1032216622, 1469922191, 2196317056,\n            2239269473, 3654751282, 613015420, 4098167098, 1281134924, 849099531, 2523299715,\n            3904840545, 1997547696, 1158713208, 1289444182, 757815917, 899581875, 3622748533,\n            3063686656, 2979790776, 1553609204, 355408616, 3897614956, 3680334470, 25191644,\n            355655308, 111682127, 4053312775, 2921335050, 2200671456, 472639194, 1374183459,\n            2738441274, 1596829615, 959522853, 1993763998, 1832301144, 2263515976, 993190648,\n            4045308024, 2213735364, 4061773476, 2596920312, 1929252967, 3935609312, 982934883,\n            3154772065, 4254233108, 1244999206, 765237459, 2528318166, 1563389556, 2293797399,\n            3495759008, 48504250, 3182637462, 3138309477, 2147232621, 4810076, 3999234780,\n            2279064264, 2264522982, 3079929466, 1524222187, 1598294545, 2049273389, 2729549735,\n            2116985451, 2637892533, 1094214870, 2711414546, 418295062, 98357556, 296649589,\n            2636445209, 4030461397, 3073508440, 4062358649, 1293566861, 1534697481, 1343281639,\n            3078259374, 386875427, 1145986442, 1790533181, 2987076845, 237202537, 2194958623,\n            935119723, 1921262864, 943957815, 2336181341, 2723699978, 1638860845, 2630349960,\n            431757538, 4152375793, 3473513084, 2603606861, 4176464622, 3978369596, 981482293,\n            929741839, 2111696471, 571254437, 1419237733, 901791748, 3340393111, 221970895,\n            2605197016, 22565479, 1000841034, 2192399670, 1207300847, 356824298, 3009617459,\n            2651652098, 2420275852, 1631602976, 575809994, 2928806259, 2831092106, 2629452482,\n            2842897182, 1909556662, 2496151886, 3385330607, 957152776, 2804092840, 3551246686,\n            2730894896, 2027253611, 2531182020, 2258110944, 1391264743, 3902230517, 3835546712,\n            3424753892, 1147410244, 3448482025, 319341118, 1798380053, 2742193162, 2106010955,\n            3267048655, 3886107336, 3334600393, 3772435523, 3985863328, 2950255062, 1012493134,\n            3954831363, 325018235, 2523597002, 2454925521, 2861802043, 4209313262, 3868234463,\n            1685691511, 2786322255, 4244960817, 1991229419, 4239301712, 576152977, 1652411241,\n            1589394460, 521549473, 266587858, 961791319, 1146831103, 3469211532, 3501779101,\n            2312218475, 2321025269, 1346459216, 472196028, 3771324053, 1495430908, 463405457,\n            1940232183, 3937148918, 1156878514, 2831556660, 1644483662, 1787817713, 2339616130,\n            3815974485, 2298018558, 71674109, 2675299410, 960845405, 3569711116, 1673611570,\n            1769369631, 1437416980, 4174063039, 2062712084, 2133844948, 196794643, 1935768058,\n            1831573341, 1418980930, 3294487604, 3544538744, 2334730191, 3988003806, 2274350901,\n            2023027498, 3447859831, 1671781771, 4023665101, 1455029189, 2419433622, 2943475311,\n            4198568768, 1395089836, 1092520718, 2430238564, 437551709, 4097009390, 3375079636,\n            4154198223, 92070792, 974607811, 3873908092, 3374473679, 638725898, 1249915990,\n            1085664087, 3927733894, 1217984426, 1825247311, 2107887775, 170602951, 1075337232,\n            1842870533, 3647067870, 2444592832, 3013106942, 1161476947, 3743427689, 1263482478,\n            69206560, 833594813, 3842989721, 337909675, 3392484922, 370017251, 27594915,\n            2126835633, 1736323108, 1893331695, 1468455680, 1075562062, 455344215, 969605531,\n            294398875, 883453327, 3994410499, 1964955910, 1983678849, 556499140, 2199399388,\n            1506753515, 2562511167, 573514453, 1452183180, 3758124304, 2276736219, 3962356320,\n            160602272, 2732947819, 1312555719, 808517807, 1646633687, 4057383018, 1177836167,\n            2724613618, 724351202, 3082498407, 3292565482, 2024078169, 2339554384, 3963173875,\n            2223760730, 2562066565, 2193608401, 1812209945, 1665831972, 1039920028, 3410644888,\n            3314911306, 2847575459, 2005962667, 2392982038, 2769384144, 1673231309, 2605033025,\n            3097232789, 525491643, 1088675733, 389231889, 4053722369, 1394160319, 920345783,\n            1695188025, 1313259843, 2855284945, 1128781302, 1711293636, 2436253183, 2702553100,\n            2342544037, 2382554808, 1645824427, 700888148, 3820471891, 2062002896, 1600256482,\n            3523617235, 3825142862, 4016136295, 3838255962, 2953276340, 394106186, 956179026,\n            3512260850, 3001113638, 1645204518, 555542490, 409962126, 479780262, 4202384502,\n            549252742, 1340551826, 190095025, 2842856010, 446626748, 2565781573, 2172050474,\n            85422525, 151000070, 2413238086, 224534468, 4102988065, 3524737259, 784974768,\n            3778660388, 2573449273, 956921977, 1416256526, 3821996527, 1297167173, 2183926071,\n            2745200336, 1745460864, 399929970, 3271657494, 1058524185, 3138265217, 3822962039,\n            796872545, 555781465, 3355863387, 4265560398, 2445094472, 546611744, 958064176,\n            2278895404, 2100057835, 789578969, 387055963, 1153298400, 4065547056, 3688020091,\n            783181103, 1789734962, 1466117990, 1740574947, 1632230912, 4155788342, 1714025679,\n            3862124914, 2247239755, 3047057899, 3610673443, 1450313039, 3533121399, 1564221183,\n            4056883174, 319992191, 598075724, 2438292429, 901314271, 2157273664, 435275402,\n            1774735757, 177332560, 3010394026, 3827445200, 2002098740, 1897812156, 454287770,\n            2829500771, 3286056227, 1498747083, 3402858410, 58581019, 1048766033, 1640106396,\n            3774636176, 1228719792, 1768725616, 3094025701, 3705595233, 2943515149,\n        ],\n        false,\n    );\n    // - Barrett\n    test(&[8; 70000], &[3; 60000], false);\n    test(&[9; 120000], &[3; 60000], true);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_fail_1() {\n    limbs_divisible_by(&mut [1, 2], &mut [3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_fail_2() {\n    limbs_divisible_by(&mut [], &mut []);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_fail_3() {\n    limbs_divisible_by(&mut [1, 2, 0], &mut [4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_fail_4() {\n    limbs_divisible_by(&mut [1, 2, 3], &mut [4, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_val_ref_fail_1() {\n    limbs_divisible_by_val_ref(&mut [1, 2], &[3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_val_ref_fail_2() {\n    limbs_divisible_by_val_ref(&mut [], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_val_ref_fail_3() {\n    limbs_divisible_by_val_ref(&mut [1, 2, 0], &[4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_val_ref_fail_4() {\n    limbs_divisible_by_val_ref(&mut [1, 2, 3], &[4, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_val_fail_1() {\n    limbs_divisible_by_ref_val(&[1, 2], &mut [3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_val_fail_2() {\n    limbs_divisible_by_ref_val(&[], &mut []);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_val_fail_3() {\n    limbs_divisible_by_ref_val(&[1, 2, 0], &mut [4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_val_fail_4() {\n    limbs_divisible_by_ref_val(&[1, 2, 3], &mut [4, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_ref_fail_1() {\n    limbs_divisible_by_ref_ref(&[1, 2], &[3, 4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_ref_fail_2() {\n    limbs_divisible_by_ref_ref(&[], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_ref_fail_3() {\n    limbs_divisible_by_ref_ref(&[1, 2, 0], &[4, 5]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_divisible_by_ref_ref_fail_4() {\n    limbs_divisible_by_ref_ref(&[1, 2, 3], &[4, 0]);\n}\n\n#[test]\nfn test_divisible_by() {\n    let test = |s, t, divisible| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.clone().divisible_by(v.clone()), divisible);\n        assert_eq!(u.clone().divisible_by(&v), divisible);\n        assert_eq!((&u).divisible_by(v.clone()), divisible);\n        assert_eq!((&u).divisible_by(&v), divisible);\n\n        assert_eq!(u == 0 || v != 0 && &u % &v == 0, divisible);\n\n        assert_eq!(\n            num_divisible_by(\n                &BigUint::from_str(s).unwrap(),\n                &BigUint::from_str(t).unwrap()\n            ),\n            divisible\n        );\n        assert_eq!(\n            rug::Integer::from_str(s)\n                .unwrap()\n                .is_divisible(&rug::Integer::from_str(t).unwrap()),\n            divisible\n        );\n    };\n    test(\"0\", \"0\", true);\n    test(\"1\", \"0\", false);\n    test(\"1000000000000\", \"0\", false);\n    test(\"0\", \"1\", true);\n    test(\"0\", \"123\", true);\n    test(\"1\", \"1\", true);\n    test(\"123\", \"1\", true);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"456\", false);\n    test(\"456\", \"123\", false);\n    test(\"369\", \"123\", true);\n    test(\"4294967295\", \"1\", true);\n    test(\"4294967295\", \"4294967295\", true);\n    test(\"1000000000000\", \"1\", true);\n    test(\"1000000000000\", \"3\", false);\n    test(\"1000000000002\", \"3\", true);\n    test(\"1000000000000\", \"123\", false);\n    test(\"1000000000000\", \"4294967295\", false);\n    test(\"1000000000000000000000000\", \"1\", true);\n    test(\"1000000000000000000000000\", \"3\", false);\n    test(\"1000000000000000000000002\", \"3\", true);\n    test(\"1000000000000000000000000\", \"123\", false);\n    test(\"1000000000000000000000000\", \"4294967295\", false);\n    test(\"1000000000000000000000000\", \"1000000000000\", true);\n    test(\"1000000000000000000000000\", \"1000000000001\", false);\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099789\",\n        true,\n    );\n    test(\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099788\",\n        false,\n    );\n    test(\"1\", \"94815577610368829905234938913859\", false);\n}\n\n#[test]\nfn limbs_divisible_by_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(xs, y)| {\n        let divisible = limbs_divisible_by_limb(&xs, y);\n        assert_eq!(\n            (&Natural::from_limbs_asc(&xs)).divisible_by(Natural::from(y)),\n            divisible\n        );\n        assert_eq!(limbs_mod_limb::<DoubleLimb, Limb>(&xs, y) == 0, divisible);\n        assert_eq!(combined_limbs_divisible_by_limb(&xs, y), divisible);\n    });\n}\n\n#[test]\nfn limbs_divisible_by_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_15().test_properties_with_config(&config, |(mut ns, mut ds)| {\n        let ns_old = ns.clone();\n        let ds_old = ds.clone();\n        let divisible = limbs_divisible_by(&mut ns, &mut ds);\n\n        let mut ns = ns_old.clone();\n        assert_eq!(limbs_divisible_by_val_ref(&mut ns, &ds_old), divisible);\n\n        let mut ds = ds_old.clone();\n        assert_eq!(limbs_divisible_by_ref_val(&ns_old, &mut ds), divisible);\n\n        assert_eq!(limbs_divisible_by_ref_ref(&ns_old, &ds_old), divisible);\n\n        verify_limbs_divisible_by(&ns_old, &ds_old, divisible);\n    });\n\n    unsigned_vec_pair_gen_var_17().test_properties_with_config(&config, |(mut ns, mut ds)| {\n        let ns_old = ns.clone();\n        let ds_old = ds.clone();\n        assert!(limbs_divisible_by(&mut ns, &mut ds));\n\n        let mut ns = ns_old.clone();\n        assert!(limbs_divisible_by_val_ref(&mut ns, &ds_old));\n\n        let mut ds = ds_old.clone();\n        assert!(limbs_divisible_by_ref_val(&ns_old, &mut ds));\n\n        assert!(limbs_divisible_by_ref_ref(&ns_old, &ds_old));\n        verify_limbs_divisible_by(&ns_old, &ds_old, true);\n    });\n\n    unsigned_vec_pair_gen_var_16().test_properties_with_config(&config, |(ns, ds)| {\n        let divisible = limbs_divisible_by_ref_ref(&ns, &ds);\n        assert_eq!(slice_test_zero(&limbs_mod(&ns, &ds)), divisible);\n    });\n}\n\n#[test]\nfn divisible_by_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let divisible = (&x).divisible_by(&y);\n        assert_eq!((&x).divisible_by(y.clone()), divisible);\n        assert_eq!(x.clone().divisible_by(&y), divisible);\n        assert_eq!(x.clone().divisible_by(y.clone()), divisible);\n\n        assert_eq!(x == 0 || y != 0 && &x % &y == 0, divisible);\n        assert_eq!(\n            num_divisible_by(&BigUint::from(&x), &BigUint::from(&y)),\n            divisible\n        );\n        assert_eq!(\n            rug::Integer::from(&x).is_divisible(&rug::Integer::from(&y)),\n            divisible\n        );\n    });\n\n    natural_pair_gen_var_6().test_properties(|(x, y)| {\n        assert!((&x).divisible_by(&y));\n        assert!(x == 0 || y != 0 && &x % &y == 0);\n        assert!(num_divisible_by(&BigUint::from(&x), &BigUint::from(&y)));\n        assert!(rug::Integer::from(&x).is_divisible(&rug::Integer::from(&y)));\n    });\n\n    natural_pair_gen_var_7().test_properties(|(x, y)| {\n        assert!(!(&x).divisible_by(&y));\n        assert!(x != 0 && (y == 0 || &x % &y != 0));\n        assert!(!num_divisible_by(&BigUint::from(&x), &BigUint::from(&y)));\n        assert!(!rug::Integer::from(&x).is_divisible(&rug::Integer::from(&y)));\n    });\n\n    natural_gen().test_properties(|n| {\n        assert!(n.divisible_by(Natural::ONE));\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert!(!(&n).divisible_by(Natural::ZERO));\n        assert!(Natural::ZERO.divisible_by(&n));\n        if n > 1 {\n            assert!(!Natural::ONE.divisible_by(&n));\n        }\n        assert!((&n).divisible_by(&n));\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Natural::from(x).divisible_by(Natural::from(y)),\n            x.divisible_by(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/divisible_by_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_20,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::divisible_by_power_of_2::limbs_divisible_by_power_of_2;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_9,\n    natural_unsigned_pair_gen_var_10,\n};\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_divisible_by_power_of_2() {\n    let test = |xs: &[Limb], pow: u64, out: bool| {\n        assert_eq!(limbs_divisible_by_power_of_2(xs, pow), out);\n    };\n    test(&[1], 0, true);\n    test(&[1], 1, false);\n    test(&[2], 0, true);\n    test(&[2], 1, true);\n    test(&[2], 2, false);\n    test(&[3], 1, false);\n    test(&[122, 456], 1, true);\n    test(&[0, 0, 1], 64, true);\n    test(&[0, 0, 1], 65, false);\n    test(&[0, 0, 1], 100, false);\n    test(&[3567587328, 232], 11, true);\n    test(&[3567587328, 232], 12, true);\n    test(&[3567587328, 232], 13, false);\n}\n\n#[test]\nfn test_divisible_by_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Natural::from_str(n).unwrap().divisible_by_power_of_2(pow),\n            out\n        );\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .is_divisible_2pow(u32::exact_from(pow)),\n            out\n        );\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 10, true);\n    test(\"0\", 100, true);\n    test(\"123\", 0, true);\n    test(\"123\", 1, false);\n    test(\"1000000000000\", 0, true);\n    test(\"1000000000000\", 12, true);\n    test(\"1000000000000\", 13, false);\n    test(\"4294967295\", 0, true);\n    test(\"4294967295\", 1, false);\n    test(\"4294967296\", 0, true);\n    test(\"4294967296\", 32, true);\n    test(\"4294967296\", 33, false);\n    test(\"18446744073709551615\", 0, true);\n    test(\"18446744073709551615\", 1, false);\n    test(\"18446744073709551616\", 0, true);\n    test(\"18446744073709551616\", 64, true);\n    test(\"18446744073709551616\", 65, false);\n}\n\n#[test]\nfn limbs_divisible_by_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(&config, |(xs, pow)| {\n        assert_eq!(\n            limbs_divisible_by_power_of_2(&xs, pow),\n            Natural::from_owned_limbs_asc(xs).divisible_by_power_of_2(pow),\n        );\n    });\n}\n\n#[test]\nfn divisible_by_power_of_2_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, pow)| {\n        let divisible = x.divisible_by_power_of_2(pow);\n        assert_eq!(\n            rug::Integer::from(&x).is_divisible_2pow(u32::exact_from(pow)),\n            divisible\n        );\n        if x != 0 {\n            assert_eq!(x.trailing_zeros().unwrap() >= pow, divisible);\n        }\n        assert_eq!((-&x).divisible_by_power_of_2(pow), divisible);\n        assert!((&x << pow).divisible_by_power_of_2(pow));\n        assert_eq!(&x >> pow << pow == x, divisible);\n    });\n\n    natural_unsigned_pair_gen_var_9().test_properties(|(x, pow)| {\n        assert!(x.divisible_by_power_of_2(pow));\n        assert!(rug::Integer::from(&x).is_divisible_2pow(u32::exact_from(pow)));\n        if x != 0 {\n            assert!(x.trailing_zeros().unwrap() >= pow);\n        }\n        assert!((-&x).divisible_by_power_of_2(pow));\n        assert_eq!(&x >> pow << pow, x);\n    });\n\n    natural_unsigned_pair_gen_var_10().test_properties(|(x, pow)| {\n        assert!(!x.divisible_by_power_of_2(pow));\n        assert!(!rug::Integer::from(&x).is_divisible_2pow(u32::exact_from(pow)));\n        if x != 0 {\n            assert!(x.trailing_zeros().unwrap() < pow);\n        }\n        assert!(!(-&x).divisible_by_power_of_2(pow));\n        assert_ne!(&x >> pow << pow, x);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert!(x.divisible_by_power_of_2(0));\n    });\n\n    unsigned_gen().test_properties(|pow| {\n        assert!(Natural::ZERO.divisible_by_power_of_2(pow));\n    });\n\n    unsigned_pair_gen_var_2::<Limb, u64>().test_properties(|(x, pow)| {\n        assert_eq!(\n            x.divisible_by_power_of_2(pow),\n            Natural::from(x).divisible_by_power_of_2(pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/eq_mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleBy, EqMod};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_19, unsigned_triple_gen_var_21, unsigned_vec_triple_gen_var_36,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_7,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_10,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::eq_mod::{\n    limbs_eq_limb_mod, limbs_eq_limb_mod_limb, limbs_eq_limb_mod_ref_ref,\n    limbs_eq_limb_mod_ref_val, limbs_eq_limb_mod_val_ref, limbs_eq_mod_limb_ref_ref,\n    limbs_eq_mod_limb_ref_val, limbs_eq_mod_limb_val_ref, limbs_eq_mod_ref_ref_ref,\n    limbs_eq_mod_ref_ref_val, limbs_eq_mod_ref_val_ref, limbs_eq_mod_ref_val_val,\n    limbs_limb_mod_exact_odd_limb, limbs_mod_exact_odd_limb,\n};\nuse malachite_nz::natural::arithmetic::mod_op::limbs_mod_limb;\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen, natural_triple_gen, natural_triple_gen_var_1, natural_triple_gen_var_2,\n    unsigned_vec_triple_gen_var_54, unsigned_vec_triple_gen_var_55,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_11,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_12,\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4,\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_15,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_16,\n};\nuse malachite_nz::test_util::natural::arithmetic::eq_mod::{\n    combined_limbs_eq_limb_mod_limb, limbs_eq_limb_mod_naive_1, limbs_eq_limb_mod_naive_2,\n    limbs_eq_mod_limb_naive_1, limbs_eq_mod_limb_naive_2, limbs_eq_mod_naive_1,\n    limbs_eq_mod_naive_2,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_limb_mod_limb() {\n    let test = |xs: &[Limb], y: Limb, m: Limb, equal: bool| {\n        assert_eq!(limbs_eq_limb_mod_limb(xs, y, m), equal);\n        assert_eq!(limbs_mod_limb::<DoubleLimb, Limb>(xs, m) == y % m, equal);\n        assert_eq!(combined_limbs_eq_limb_mod_limb(xs, y, m), equal);\n    };\n    test(&[6, 7], 4, 2, true);\n    test(&[7, 7], 4, 2, false);\n    test(&[6, 7], 3, 2, false);\n    test(&[7, 7], 3, 2, true);\n    test(&[2, 2], 7, 13, true);\n    test(&[100, 101, 102], 1238, 10, true);\n    test(&[100, 101, 102], 1239, 10, false);\n    test(&[123, 456], 636, 789, true);\n    test(&[123, 456], 1000, 789, false);\n    test(&[u32::MAX, u32::MAX], 101, 2, true);\n    test(&[u32::MAX, u32::MAX], 100, 2, false);\n    test(&[u32::MAX, u32::MAX], 120, 3, true);\n    test(&[u32::MAX, u32::MAX], 110, 3, false);\n    test(\n        &[\n            957355272, 2717966866, 2284391330, 238149753, 3607703304, 23463007, 1388955612,\n            3269479240, 881285075, 2493741919, 360635652, 2851492229, 3590429614, 2528168680,\n            215334077, 3509222230, 1825157855, 3737409852, 4151389929, 2692167062, 1409227805,\n            2060445344, 1453537438, 3186146035, 1159656442, 954576963, 2935313630, 2288694644,\n            400433986, 3182217800, 3929694465, 3346806449, 131165877,\n        ],\n        1529684314,\n        1469269654,\n        false,\n    );\n    test(\n        &[\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            511,\n            0,\n            0,\n            0,\n            4227858432,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            511,\n            0,\n            0,\n            0,\n            3221225472,\n            63,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4294443008,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        0xfffff000,\n        u32::MAX,\n        false,\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_limb_fail_1() {\n    limbs_eq_limb_mod_limb(&[10], 10, 15);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_limb_fail_2() {\n    limbs_eq_limb_mod_limb(&[6, 7], 4, 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_limb_mod() {\n    let test = |xs: &[Limb], y: Limb, ms: &[Limb], equal: bool| {\n        let mut mut_xs = xs.to_vec();\n        let mut mut_ms = ms.to_vec();\n        assert_eq!(limbs_eq_limb_mod(&mut mut_xs, y, &mut mut_ms), equal);\n        let mut mut_xs = xs.to_vec();\n        assert_eq!(limbs_eq_limb_mod_val_ref(&mut mut_xs, y, ms), equal);\n        let mut mut_ms = ms.to_vec();\n        assert_eq!(limbs_eq_limb_mod_ref_val(xs, y, &mut mut_ms), equal);\n        assert_eq!(limbs_eq_limb_mod_ref_ref(xs, y, ms), equal);\n        assert_eq!(limbs_eq_limb_mod_naive_1(xs, y, ms), equal);\n        assert_eq!(limbs_eq_limb_mod_naive_2(xs, y, ms), equal);\n    };\n    // - xs[0].eq_mod_power_of_2(y, u64::from(m_trailing_zeros))\n    // - m_len != 2 || m_0 == 0\n    test(&[1, 1], 1, &[0, 1], true);\n    // - m_len == 2 && m_0 != 0\n    // - m_1 < 1 << m_trailing_zeros\n    // - x_len < BMOD_1_TO_MOD_1_THRESHOLD\n    test(&[0, 1], 2, &[2, 1], false);\n    // - x_len >= BMOD_1_TO_MOD_1_THRESHOLD\n    // - y_0 < m_0\n    test(&[6; 40], 2, &[2, 1], false);\n    // - y_0 >= m_0\n    test(&[6; 40], 0x80000002, &[2, 1], false);\n    // - !xs[0].eq_mod_power_of_2(y, u64::from(m_trailing_zeros))\n    test(&[0, 1], 1, &[0, 1], false);\n    // - m_1 >= 1 << m_trailing_zeros\n    test(&[0, 1], 1, &[1, 1], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_fail_1() {\n    limbs_eq_limb_mod(&mut [1], 1, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_fail_2() {\n    limbs_eq_limb_mod(&mut [1, 1], 1, &mut [1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_fail_3() {\n    limbs_eq_limb_mod(&mut [1, 0], 1, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_fail_4() {\n    limbs_eq_limb_mod(&mut [1, 1], 0, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_fail_5() {\n    limbs_eq_limb_mod(&mut [1, 1], 1, &mut [1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_val_ref_fail_1() {\n    limbs_eq_limb_mod_val_ref(&mut [1], 1, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_val_ref_fail_2() {\n    limbs_eq_limb_mod_val_ref(&mut [1, 1], 1, &[1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_val_ref_fail_3() {\n    limbs_eq_limb_mod_val_ref(&mut [1, 0], 1, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_val_ref_fail_4() {\n    limbs_eq_limb_mod_val_ref(&mut [1, 1], 0, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_val_ref_fail_5() {\n    limbs_eq_limb_mod_val_ref(&mut [1, 1], 1, &[1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_val_fail_1() {\n    limbs_eq_limb_mod_ref_val(&[1], 1, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_val_fail_2() {\n    limbs_eq_limb_mod_ref_val(&[1, 1], 1, &mut [1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_val_fail_3() {\n    limbs_eq_limb_mod_ref_val(&[1, 0], 1, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_val_fail_4() {\n    limbs_eq_limb_mod_ref_val(&[1, 1], 0, &mut [0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_val_fail_5() {\n    limbs_eq_limb_mod_ref_val(&[1, 1], 1, &mut [1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_ref_fail_1() {\n    limbs_eq_limb_mod_ref_ref(&[1], 1, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_ref_fail_2() {\n    limbs_eq_limb_mod_ref_ref(&[1, 1], 1, &[1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_ref_fail_3() {\n    limbs_eq_limb_mod_ref_ref(&[1, 0], 1, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_ref_fail_4() {\n    limbs_eq_limb_mod_ref_ref(&[1, 1], 0, &[0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_limb_mod_ref_ref_fail_5() {\n    limbs_eq_limb_mod_ref_ref(&[1, 1], 1, &[1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_mod_limb() {\n    let test = |xs: &[Limb], ys: &[Limb], m: Limb, equal: bool| {\n        let mut mut_xs = xs.to_vec();\n        assert_eq!(limbs_eq_mod_limb_val_ref(&mut mut_xs, ys, m), equal);\n        let mut mut_ys = ys.to_vec();\n        assert_eq!(limbs_eq_mod_limb_ref_val(xs, &mut mut_ys, m), equal);\n        assert_eq!(limbs_eq_mod_limb_ref_ref(xs, ys, m), equal);\n        assert_eq!(limbs_eq_mod_limb_naive_1(xs, ys, m), equal);\n        assert_eq!(limbs_eq_mod_limb_naive_2(xs, ys, m), equal);\n    };\n    // - xs != ys in limbs_eq_mod_limb_greater\n    // - xs[0].eq_mod_power_of_2(ys[0], u64::from(m.trailing_zeros())) in limbs_eq_mod_limb_greater\n    // - limbs_cmp(xs, ys) < Equal in limbs_eq_mod_limb_greater\n    // - scratch.len() > 1 in limbs_eq_mod_limb_greater\n    test(&[1, 1], &[3, 4], 5, true);\n    // - xs == ys in limbs_eq_mod_limb_greater\n    test(&[0, 1], &[0, 1], 1, true);\n    // - limbs_cmp(xs, ys) >= Equal in limbs_eq_mod_limb_greater\n    test(&[0, 0, 1], &[0, 1], 1, true);\n    // - scratch.len() == 1 in limbs_eq_mod_limb_greater\n    test(&[0, 1], &[1, 1], 1, true);\n    // - !xs[0].eq_mod_power_of_2(ys[0], u64::from(m.trailing_zeros())) in limbs_eq_mod_limb_greater\n    test(&[0, 1], &[1, 1], 2, false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_val_ref_fail_1() {\n    limbs_eq_mod_limb_val_ref(&mut [1], &[3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_val_ref_fail_2() {\n    limbs_eq_mod_limb_val_ref(&mut [1, 1], &[4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_val_ref_fail_3() {\n    limbs_eq_mod_limb_val_ref(&mut [1, 0], &[3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_val_ref_fail_4() {\n    limbs_eq_mod_limb_val_ref(&mut [1, 1], &[3, 0], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_val_ref_fail_5() {\n    limbs_eq_mod_limb_val_ref(&mut [1, 1], &[3, 4], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_val_fail_1() {\n    limbs_eq_mod_limb_ref_val(&[1], &mut [3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_val_fail_2() {\n    limbs_eq_mod_limb_ref_val(&[1, 1], &mut [4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_val_fail_3() {\n    limbs_eq_mod_limb_ref_val(&[1, 0], &mut [3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_val_fail_4() {\n    limbs_eq_mod_limb_ref_val(&[1, 1], &mut [3, 0], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_val_fail_5() {\n    limbs_eq_mod_limb_ref_val(&[1, 1], &mut [3, 4], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_ref_fail_1() {\n    limbs_eq_mod_limb_ref_ref(&[1], &[3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_ref_fail_2() {\n    limbs_eq_mod_limb_ref_ref(&[1, 1], &[4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_ref_fail_3() {\n    limbs_eq_mod_limb_ref_ref(&[1, 0], &[3, 4], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_ref_fail_4() {\n    limbs_eq_mod_limb_ref_ref(&[1, 1], &[3, 0], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_limb_ref_ref_fail_5() {\n    limbs_eq_mod_limb_ref_ref(&[1, 1], &[3, 4], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_mod_ref_ref_ref() {\n    let test = |xs: &[Limb], ys: &[Limb], ms: &[Limb], equal: bool| {\n        let mut mut_ys = ys.to_vec();\n        let mut mut_ms = ms.to_vec();\n        assert_eq!(\n            limbs_eq_mod_ref_val_val(xs, &mut mut_ys, &mut mut_ms),\n            equal\n        );\n        let mut mut_ys = ys.to_vec();\n        assert_eq!(limbs_eq_mod_ref_val_ref(xs, &mut mut_ys, ms), equal);\n        let mut mut_ms = ms.to_vec();\n        assert_eq!(limbs_eq_mod_ref_ref_val(xs, ys, &mut mut_ms), equal);\n        assert_eq!(limbs_eq_mod_ref_ref_ref(xs, ys, ms), equal);\n        assert_eq!(limbs_eq_mod_naive_1(xs, ys, ms), equal);\n        assert_eq!(limbs_eq_mod_naive_2(xs, ys, ms), equal);\n    };\n    // - xs != ys in limbs_eq_mod_greater\n    // - xs[0].eq_mod_power_of_2(ys[0], u64::from(ms[0].trailing_zeros())) in limbs_eq_mod_greater\n    // - limbs_cmp(xs, ys) == Less\n    test(&[1, 1, 1], &[1, 0, 3], &[0, 7], true);\n    // - !xs[0].eq_mod_power_of_2(ys[0], u64::from(ms[0].trailing_zeros())) in limbs_eq_mod_greater\n    test(&[0, 1, 1], &[1, 0, 3], &[0, 7], false);\n    // - limbs_cmp(xs, ys) >= Equal\n    test(&[1, 3], &[1, 1, 2], &[0, 5], true);\n    // - xs == ys in limbs_eq_mod_greater\n    test(&[0, 1], &[0, 1], &[0, 1], true);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_val_fail_1() {\n    limbs_eq_mod_ref_val_val(&[1], &mut [1, 0, 3], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_val_fail_2() {\n    limbs_eq_mod_ref_val_val(&[1, 1, 1], &mut [1], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_val_fail_3() {\n    limbs_eq_mod_ref_val_val(&[1, 1, 1], &mut [1, 0, 3], &mut [7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_val_fail_4() {\n    limbs_eq_mod_ref_val_val(&[1, 1, 0], &mut [1, 0, 3], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_val_fail_5() {\n    limbs_eq_mod_ref_val_val(&[1, 1, 1], &mut [1, 0, 0], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_val_fail_6() {\n    limbs_eq_mod_ref_val_val(&[1, 1, 1], &mut [1, 0, 3], &mut [7, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_ref_fail_1() {\n    limbs_eq_mod_ref_val_ref(&[1], &mut [1, 0, 3], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_ref_fail_2() {\n    limbs_eq_mod_ref_val_ref(&[1, 1, 1], &mut [1], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_ref_fail_3() {\n    limbs_eq_mod_ref_val_ref(&[1, 1, 1], &mut [1, 0, 3], &[7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_ref_fail_4() {\n    limbs_eq_mod_ref_val_ref(&[1, 1, 0], &mut [1, 0, 3], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_ref_fail_5() {\n    limbs_eq_mod_ref_val_ref(&[1, 1, 1], &mut [1, 0, 0], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_val_ref_fail_6() {\n    limbs_eq_mod_ref_val_ref(&[1, 1, 1], &mut [1, 0, 3], &[7, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_val_fail_1() {\n    limbs_eq_mod_ref_ref_val(&[1], &[1, 0, 3], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_val_fail_2() {\n    limbs_eq_mod_ref_ref_val(&[1, 1, 1], &[1], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_val_fail_3() {\n    limbs_eq_mod_ref_ref_val(&[1, 1, 1], &[1, 0, 3], &mut [7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_val_fail_4() {\n    limbs_eq_mod_ref_ref_val(&[1, 1, 0], &[1, 0, 3], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_val_fail_5() {\n    limbs_eq_mod_ref_ref_val(&[1, 1, 1], &[1, 0, 0], &mut [0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_val_fail_6() {\n    limbs_eq_mod_ref_ref_val(&[1, 1, 1], &[1, 0, 3], &mut [7, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_ref_fail_1() {\n    limbs_eq_mod_ref_ref_ref(&[1], &[1, 0, 3], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_ref_fail_2() {\n    limbs_eq_mod_ref_ref_ref(&[1, 1, 1], &[1], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_ref_fail_3() {\n    limbs_eq_mod_ref_ref_ref(&[1, 1, 1], &[1, 0, 3], &[7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_ref_fail_4() {\n    limbs_eq_mod_ref_ref_ref(&[1, 1, 0], &[1, 0, 3], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_ref_fail_5() {\n    limbs_eq_mod_ref_ref_ref(&[1, 1, 1], &[1, 0, 0], &[0, 7]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_eq_mod_ref_ref_ref_fail_6() {\n    limbs_eq_mod_ref_ref_ref(&[1, 1, 1], &[1, 0, 3], &[7, 0]);\n}\n\n#[test]\nfn test_eq_mod() {\n    let test = |r, s, t, out| {\n        let x = Natural::from_str(r).unwrap();\n        let y = Natural::from_str(s).unwrap();\n        let m = Natural::from_str(t).unwrap();\n\n        assert_eq!(x.clone().eq_mod(y.clone(), m.clone()), out);\n        assert_eq!(x.clone().eq_mod(y.clone(), &m), out);\n        assert_eq!(x.clone().eq_mod(&y, m.clone()), out);\n        assert_eq!(x.clone().eq_mod(&y, &m), out);\n        assert_eq!((&x).eq_mod(y.clone(), m.clone()), out);\n        assert_eq!((&x).eq_mod(y.clone(), &m), out);\n        assert_eq!((&x).eq_mod(&y, m.clone()), out);\n        assert_eq!((&x).eq_mod(&y, &m), out);\n\n        assert_eq!(y.eq_mod(x, m), out);\n        assert_eq!(\n            rug::Integer::from_str(r).unwrap().is_congruent(\n                &rug::Integer::from_str(s).unwrap(),\n                &rug::Integer::from_str(t).unwrap()\n            ),\n            out\n        );\n    };\n    test(\"0\", \"0\", \"0\", true);\n    test(\"0\", \"1\", \"0\", false);\n    test(\"57\", \"57\", \"0\", true);\n    test(\"57\", \"58\", \"0\", false);\n    test(\"1000000000000\", \"57\", \"0\", false);\n    test(\"0\", \"256\", \"256\", true);\n    test(\"0\", \"256\", \"512\", false);\n    test(\"13\", \"23\", \"10\", true);\n    test(\"13\", \"24\", \"10\", false);\n    test(\"13\", \"21\", \"1\", true);\n    test(\"13\", \"21\", \"2\", true);\n    test(\"13\", \"21\", \"4\", true);\n    test(\"13\", \"21\", \"8\", true);\n    test(\"13\", \"21\", \"16\", false);\n    test(\"13\", \"21\", \"3\", false);\n    test(\"1000000000001\", \"1\", \"4096\", true);\n    test(\"1000000000001\", \"1\", \"8192\", false);\n    test(\"12345678987654321\", \"321\", \"1000\", true);\n    test(\"12345678987654321\", \"322\", \"1000\", false);\n    test(\"1234\", \"1234\", \"1000000000000\", true);\n    test(\"1234\", \"1235\", \"1000000000000\", false);\n    test(\"1000000001234\", \"1000000002234\", \"1000\", true);\n    test(\"1000000001234\", \"1000000002235\", \"1000\", false);\n    test(\"1000000001234\", \"1234\", \"1000000000000\", true);\n    test(\"1000000001234\", \"1235\", \"1000000000000\", false);\n    test(\"1000000001234\", \"5000000001234\", \"1000000000000\", true);\n    test(\"1000000001234\", \"5000000001235\", \"1000000000000\", false);\n}\n\n#[test]\nfn limbs_limb_mod_exact_odd_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_triple_gen_var_21().test_properties_with_config(&config, |(n, d, carry)| {\n        let r = Natural::from(limbs_limb_mod_exact_odd_limb(n, d, carry));\n        assert_eq!(n.eq_mod(carry, d), r == 0);\n        assert!(r <= d);\n        if carry < d {\n            assert!(r < d);\n        }\n        let a = Natural::from(n);\n        let d = Natural::from(d);\n        let carry = Natural::from(carry);\n        assert!(((&r << Limb::WIDTH) + &a).eq_mod(&carry, &d) || (r + a).eq_mod(carry, d));\n    });\n}\n\n#[test]\nfn limbs_mod_exact_odd_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_10().test_properties_with_config(\n        &config,\n        |(ns, d, carry)| {\n            let r = Natural::from(limbs_mod_exact_odd_limb(&ns, d, carry));\n            assert!(r <= d);\n            if carry < d {\n                assert!(r < d);\n            }\n            let ns_len = u64::exact_from(ns.len());\n            let a = Natural::from_owned_limbs_asc(ns);\n            let d = Natural::from(d);\n            let carry = Natural::from(carry);\n            assert_eq!((&a).eq_mod(&carry, &d), r == 0 || r == d);\n            let p_1 = &r << (ns_len * Limb::WIDTH);\n            let p_2 = r << ((ns_len - 1) * Limb::WIDTH);\n            assert!((p_1 + &a).eq_mod(&carry, &d) || (p_2 + a).eq_mod(carry, d));\n        },\n    );\n}\n\n#[test]\nfn limbs_eq_limb_mod_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_7().test_properties_with_config(\n        &config,\n        |(xs, y, m)| {\n            let equal = limbs_eq_limb_mod_limb(&xs, y, m);\n            assert_eq!(\n                Natural::from_limbs_asc(&xs).eq_mod(Natural::from(y), Natural::from(m)),\n                equal\n            );\n            assert_eq!(limbs_mod_limb::<DoubleLimb, Limb>(&xs, m) == y % m, equal);\n            assert_eq!(combined_limbs_eq_limb_mod_limb(&xs, y, m), equal);\n        },\n    );\n\n    unsigned_vec_unsigned_unsigned_triple_gen_var_11().test_properties_with_config(\n        &config,\n        |(xs, y, m)| {\n            assert!(limbs_eq_limb_mod_limb(&xs, y, m));\n            assert!(Natural::from_limbs_asc(&xs).eq_mod(Natural::from(y), Natural::from(m)));\n            assert_eq!(limbs_mod_limb::<DoubleLimb, Limb>(&xs, m), y % m);\n            assert!(combined_limbs_eq_limb_mod_limb(&xs, y, m));\n        },\n    );\n\n    unsigned_vec_unsigned_unsigned_triple_gen_var_12().test_properties_with_config(\n        &config,\n        |(xs, y, m)| {\n            assert!(!limbs_eq_limb_mod_limb(&xs, y, m));\n            assert!(!Natural::from_limbs_asc(&xs).eq_mod(Natural::from(y), Natural::from(m)));\n            assert_ne!(limbs_mod_limb::<DoubleLimb, Limb>(&xs, m), y % m);\n            assert!(!combined_limbs_eq_limb_mod_limb(&xs, y, m));\n        },\n    );\n}\n\n#[test]\nfn limbs_eq_limb_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().test_properties_with_config(\n        &config,\n        |(xs, ms, y)| {\n            let equal = limbs_eq_limb_mod_ref_ref(&xs, y, &ms);\n            let mut mut_xs = xs.clone();\n            let mut mut_ms = ms.clone();\n            assert_eq!(limbs_eq_limb_mod(&mut mut_xs, y, &mut mut_ms), equal);\n            let mut mut_xs = xs.clone();\n            assert_eq!(limbs_eq_limb_mod_val_ref(&mut mut_xs, y, &ms), equal);\n            let mut mut_ms = ms.clone();\n            assert_eq!(limbs_eq_limb_mod_ref_val(&xs, y, &mut mut_ms), equal);\n            assert_eq!(\n                Natural::from_limbs_asc(&xs).eq_mod(Natural::from(y), Natural::from_limbs_asc(&ms)),\n                equal\n            );\n            assert_eq!(limbs_eq_limb_mod_naive_1(&xs, y, &ms), equal);\n            assert_eq!(limbs_eq_limb_mod_naive_2(&xs, y, &ms), equal);\n        },\n    );\n\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_4().test_properties_with_config(\n        &config,\n        |(xs, y, ms)| {\n            assert!(\n                Natural::from_limbs_asc(&xs).eq_mod(Natural::from(y), Natural::from_limbs_asc(&ms))\n            );\n            assert!(limbs_eq_limb_mod_ref_ref(&xs, y, &ms));\n            assert!(limbs_eq_limb_mod_naive_1(&xs, y, &ms));\n            assert!(limbs_eq_limb_mod_naive_2(&xs, y, &ms));\n        },\n    );\n\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_5().test_properties_with_config(\n        &config,\n        |(xs, y, ms)| {\n            assert!(\n                !Natural::from_limbs_asc(&xs)\n                    .eq_mod(Natural::from(y), Natural::from_limbs_asc(&ms))\n            );\n            assert!(!limbs_eq_limb_mod_ref_ref(&xs, y, &ms));\n            assert!(!limbs_eq_limb_mod_naive_1(&xs, y, &ms));\n            assert!(!limbs_eq_limb_mod_naive_2(&xs, y, &ms));\n        },\n    );\n}\n\n#[test]\nfn limbs_eq_mod_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_6().test_properties_with_config(\n        &config,\n        |(xs, ys, m)| {\n            let equal = limbs_eq_mod_limb_ref_ref(&xs, &ys, m);\n            let mut mut_xs = xs.clone();\n            assert_eq!(limbs_eq_mod_limb_val_ref(&mut mut_xs, &ys, m), equal);\n            let mut mut_ys = ys.clone();\n            assert_eq!(limbs_eq_mod_limb_ref_val(&xs, &mut mut_ys, m), equal);\n            assert_eq!(\n                Natural::from_limbs_asc(&xs).eq_mod(Natural::from_limbs_asc(&ys), Natural::from(m)),\n                equal\n            );\n            assert_eq!(limbs_eq_mod_limb_naive_1(&xs, &ys, m), equal);\n            assert_eq!(limbs_eq_mod_limb_naive_2(&xs, &ys, m), equal);\n        },\n    );\n\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_15().test_properties_with_config(\n        &config,\n        |(xs, ys, m)| {\n            assert!(\n                Natural::from_limbs_asc(&xs).eq_mod(Natural::from_limbs_asc(&ys), Natural::from(m))\n            );\n            assert!(limbs_eq_mod_limb_ref_ref(&xs, &ys, m));\n            assert!(limbs_eq_mod_limb_naive_1(&xs, &ys, m));\n            assert!(limbs_eq_mod_limb_naive_2(&xs, &ys, m));\n        },\n    );\n\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_16().test_properties_with_config(\n        &config,\n        |(xs, ys, m)| {\n            assert!(\n                !Natural::from_limbs_asc(&xs)\n                    .eq_mod(Natural::from_limbs_asc(&ys), Natural::from(m))\n            );\n            assert!(!limbs_eq_mod_limb_ref_ref(&xs, &ys, m));\n            assert!(!limbs_eq_mod_limb_naive_1(&xs, &ys, m));\n            assert!(!limbs_eq_mod_limb_naive_2(&xs, &ys, m));\n        },\n    );\n}\n\n#[test]\nfn limbs_eq_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_36().test_properties_with_config(&config, |(xs, ys, ms)| {\n        let equal = limbs_eq_mod_ref_ref_ref(&xs, &ys, &ms);\n        let mut mut_ys = ys.clone();\n        let mut mut_ms = ms.clone();\n        assert_eq!(\n            limbs_eq_mod_ref_val_val(&xs, &mut mut_ys, &mut mut_ms),\n            equal\n        );\n        let mut mut_ys = ys.clone();\n        assert_eq!(limbs_eq_mod_ref_val_ref(&xs, &mut mut_ys, &ms), equal);\n        let mut mut_ms = ms.clone();\n        assert_eq!(limbs_eq_mod_ref_ref_val(&xs, &ys, &mut mut_ms), equal);\n        assert_eq!(\n            Natural::from_limbs_asc(&xs)\n                .eq_mod(Natural::from_limbs_asc(&ys), Natural::from_limbs_asc(&ms)),\n            equal\n        );\n        assert_eq!(limbs_eq_mod_naive_1(&xs, &ys, &ms), equal);\n        assert_eq!(limbs_eq_mod_naive_2(&xs, &ys, &ms), equal);\n    });\n\n    unsigned_vec_triple_gen_var_54().test_properties_with_config(&config, |(xs, ys, ms)| {\n        assert!(\n            Natural::from_limbs_asc(&xs)\n                .eq_mod(Natural::from_limbs_asc(&ys), Natural::from_limbs_asc(&ms))\n        );\n        assert!(limbs_eq_mod_ref_ref_ref(&xs, &ys, &ms));\n        assert!(limbs_eq_mod_naive_1(&xs, &ys, &ms));\n        assert!(limbs_eq_mod_naive_2(&xs, &ys, &ms));\n    });\n\n    unsigned_vec_triple_gen_var_55().test_properties_with_config(&config, |(xs, ys, ms)| {\n        assert!(\n            !Natural::from_limbs_asc(&xs)\n                .eq_mod(Natural::from_limbs_asc(&ys), Natural::from_limbs_asc(&ms))\n        );\n        assert!(!limbs_eq_mod_ref_ref_ref(&xs, &ys, &ms));\n        assert!(!limbs_eq_mod_naive_1(&xs, &ys, &ms));\n        assert!(!limbs_eq_mod_naive_2(&xs, &ys, &ms));\n    });\n}\n\n#[test]\nfn eq_mod_properties() {\n    natural_triple_gen().test_properties(|(x, y, m)| {\n        let equal = (&x).eq_mod(&y, &m);\n        assert_eq!((&y).eq_mod(&x, &m), equal);\n\n        assert_eq!((&x).eq_mod(&y, m.clone()), equal);\n        assert_eq!((&x).eq_mod(y.clone(), &m), equal);\n        assert_eq!((&x).eq_mod(y.clone(), m.clone()), equal);\n        assert_eq!(x.clone().eq_mod(&y, &m), equal);\n        assert_eq!(x.clone().eq_mod(&y, m.clone()), equal);\n        assert_eq!(x.clone().eq_mod(y.clone(), &m), equal);\n        assert_eq!(x.clone().eq_mod(y.clone(), m.clone()), equal);\n\n        assert_eq!(\n            (Integer::from(&x) - Integer::from(&y)).divisible_by(Integer::from(&m)),\n            equal\n        );\n        assert_eq!(\n            (Integer::from(&y) - Integer::from(&x)).divisible_by(Integer::from(&m)),\n            equal\n        );\n        assert_eq!(\n            rug::Integer::from(&x).is_congruent(&rug::Integer::from(&y), &rug::Integer::from(&m)),\n            equal\n        );\n    });\n\n    natural_triple_gen_var_1().test_properties(|(x, y, m)| {\n        assert!((&x).eq_mod(&y, &m));\n        assert!((&y).eq_mod(&x, &m));\n        assert!(\n            rug::Integer::from(&x).is_congruent(&rug::Integer::from(&y), &rug::Integer::from(&m))\n        );\n    });\n\n    natural_triple_gen_var_2().test_properties(|(x, y, m)| {\n        assert!(!(&x).eq_mod(&y, &m));\n        assert!(!(&y).eq_mod(&x, &m));\n        assert!(\n            !rug::Integer::from(&x).is_congruent(&rug::Integer::from(&y), &rug::Integer::from(&m))\n        );\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert!((&x).eq_mod(&y, Natural::ONE));\n        assert_eq!((&x).eq_mod(Natural::ZERO, &y), (&x).divisible_by(&y));\n        assert!((&x).eq_mod(&x, &y));\n        assert_eq!((&x).eq_mod(&y, Natural::ZERO), x == y);\n    });\n\n    unsigned_triple_gen_var_19::<Limb>().test_properties(|(x, y, m)| {\n        assert_eq!(\n            Natural::from(x).eq_mod(Natural::from(y), Natural::from(m)),\n            x.eq_mod(y, m)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/eq_mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleByPowerOf2, EqModPowerOf2, ModPowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_4, unsigned_vec_unsigned_unsigned_triple_gen_var_8,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::eq_mod_power_of_2::{\n    limbs_eq_limb_mod_power_of_2, limbs_eq_mod_power_of_2,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_natural_unsigned_quadruple_gen_var_1,\n    natural_natural_unsigned_triple_gen_var_1, natural_natural_unsigned_triple_gen_var_2,\n    natural_natural_unsigned_triple_gen_var_3, natural_pair_gen, natural_unsigned_pair_gen_var_4,\n};\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_limb_mod_power_of_2() {\n    let test = |xs, y, pow, out| {\n        assert_eq!(limbs_eq_limb_mod_power_of_2(xs, y, pow), out);\n    };\n    test(&[0b1111011, 0b111001000], 0b101011, 4, true);\n    test(&[0b1111011, 0b111001000], 0b101011, 5, false);\n    test(&[0b1111011, 0b111001000], 0b1111011, 35, true);\n    test(&[0b1111011, 0b111001000], 0b1111011, 36, false);\n    test(&[0b1111011, 0b111001000], 0b1111011, 100, false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_eq_mod_power_of_2() {\n    let test = |xs, ys, pow, out| {\n        assert_eq!(limbs_eq_mod_power_of_2(xs, ys, pow), out);\n    };\n    test(&[0b1111011, 0b111001000], &[0b101011], 4, true);\n    test(&[0b1111011, 0b111001000], &[0b101011], 5, false);\n    test(&[0b1111011, 0b111001000], &[0b1111011], 35, true);\n    test(&[0b1111011, 0b111001000], &[0b1111011], 36, false);\n    test(&[0b1111011, 0b111001000], &[0b1111011], 100, false);\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b1111011, 0b111101000],\n        37,\n        true,\n    );\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b1111011, 0b111101000],\n        38,\n        false,\n    );\n    test(\n        &[0b1111011, 0b111001000],\n        &[0b1111011, 0b111101000],\n        100,\n        false,\n    );\n}\n\n#[test]\nfn test_eq_mod_power_of_2() {\n    let test = |x, y, pow, out| {\n        assert_eq!(\n            Natural::from_str(x)\n                .unwrap()\n                .eq_mod_power_of_2(&Natural::from_str(y).unwrap(), pow),\n            out\n        );\n        assert_eq!(\n            rug::Integer::from_str(x)\n                .unwrap()\n                .is_congruent_2pow(&rug::Integer::from_str(y).unwrap(), u32::exact_from(pow)),\n            out\n        );\n    };\n    test(\"0\", \"256\", 8, true);\n    test(\"0\", \"256\", 9, false);\n    test(\"13\", \"21\", 0, true);\n    test(\"13\", \"21\", 1, true);\n    test(\"13\", \"21\", 2, true);\n    test(\"13\", \"21\", 3, true);\n    test(\"13\", \"21\", 4, false);\n    test(\"13\", \"21\", 100, false);\n    test(\"1000000000001\", \"1\", 12, true);\n    test(\"1000000000001\", \"1\", 13, false);\n    test(\"4294967295\", \"4294967295\", 32, true);\n    test(\"281474976710672\", \"844424930131984\", 49, true);\n    test(\"281474976710672\", \"844424930131984\", 50, false);\n}\n\n#[test]\nfn limbs_eq_limb_mod_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_8().test_properties_with_config(\n        &config,\n        |(xs, y, pow)| {\n            assert_eq!(\n                limbs_eq_limb_mod_power_of_2(&xs, y, pow),\n                Natural::from_owned_limbs_asc(xs).eq_mod_power_of_2(&Natural::from(y), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_eq_mod_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_9().test_properties_with_config(\n        &config,\n        |(xs, ys, pow)| {\n            assert_eq!(\n                limbs_eq_mod_power_of_2(&xs, &ys, pow),\n                Natural::from_owned_limbs_asc(xs)\n                    .eq_mod_power_of_2(&Natural::from_owned_limbs_asc(ys), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn eq_mod_power_of_2_properties() {\n    natural_natural_unsigned_triple_gen_var_1().test_properties(|(x, y, pow)| {\n        let eq_mod_power_of_2 = x.eq_mod_power_of_2(&y, pow);\n        assert_eq!(\n            rug::Integer::from(&x).is_congruent_2pow(&rug::Integer::from(&y), u32::exact_from(pow)),\n            eq_mod_power_of_2\n        );\n        assert_eq!(y.eq_mod_power_of_2(&x, pow), eq_mod_power_of_2);\n        assert_eq!(\n            x.mod_power_of_2(pow) == y.mod_power_of_2(pow),\n            eq_mod_power_of_2\n        );\n    });\n\n    natural_natural_unsigned_triple_gen_var_2().test_properties(|(x, y, pow)| {\n        assert!(x.eq_mod_power_of_2(&y, pow));\n        assert!(\n            rug::Integer::from(&x).is_congruent_2pow(&rug::Integer::from(&y), u32::exact_from(pow))\n        );\n        assert!(y.eq_mod_power_of_2(&x, pow));\n        assert_eq!(x.mod_power_of_2(pow), y.mod_power_of_2(pow));\n    });\n\n    natural_natural_unsigned_triple_gen_var_3().test_properties(|(x, y, pow)| {\n        assert!(!x.eq_mod_power_of_2(&y, pow));\n        assert!(\n            !rug::Integer::from(&x)\n                .is_congruent_2pow(&rug::Integer::from(&y), u32::exact_from(pow))\n        );\n        assert!(!y.eq_mod_power_of_2(&x, pow));\n        assert_ne!(x.mod_power_of_2(pow), y.mod_power_of_2(pow));\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, pow)| {\n        assert!(n.eq_mod_power_of_2(&n, pow));\n        assert_eq!(\n            n.eq_mod_power_of_2(&Natural::ZERO, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n        assert_eq!(\n            Natural::ZERO.eq_mod_power_of_2(&n, pow),\n            n.divisible_by_power_of_2(pow)\n        );\n    });\n\n    natural_natural_natural_unsigned_quadruple_gen_var_1().test_properties(|(x, y, z, pow)| {\n        if x.eq_mod_power_of_2(&y, pow) && y.eq_mod_power_of_2(&z, pow) {\n            assert!(x.eq_mod_power_of_2(&z, pow));\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert!(x.eq_mod_power_of_2(&y, 0));\n    });\n\n    unsigned_triple_gen_var_4::<Limb, u64>().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.eq_mod_power_of_2(y, pow),\n            Natural::from(x).eq_mod_power_of_2(&Natural::from(y), pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/extended_gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivExact, ExtendedGcd, Gcd};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_vec_pair_gen_var_11,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::gcd::extended_gcd::limbs_extended_gcd;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_pair_gen_var_4};\nuse malachite_nz::test_util::natural::arithmetic::extended_gcd::{\n    extended_gcd_binary_natural, extended_gcd_euclidean_natural,\n};\nuse std::cmp::min;\nuse std::str::FromStr;\n\n#[test]\nfn test_limbs_extended_gcd() {\n    let test = |xs: &[Limb], ys: &[Limb], gs_out: &[Limb], ss_out: &[Limb], ss_sign_out: bool| {\n        let a = Natural::from_limbs_asc(xs);\n        let b = Natural::from_limbs_asc(ys);\n        let mut xs = xs.to_vec();\n        let mut ys = ys.to_vec();\n        let mut gs = vec![0; ys.len()];\n        let mut ss = vec![0; ys.len() + 1];\n        let (g_len, ss_sign) = limbs_extended_gcd(&mut gs, &mut ss, &mut xs, &mut ys);\n        gs.truncate(g_len);\n        assert_eq!(gs, gs_out);\n        assert_eq!(ss, ss_out);\n        assert_eq!(ss_sign, ss_sign_out);\n        let result = (&a).extended_gcd(&b);\n        let result_alt = extended_gcd_euclidean_natural(a, b);\n        assert_eq!(result, result_alt);\n        let (gcd, x, _) = result;\n        assert_eq!(Natural::from_owned_limbs_asc(gs), gcd);\n        assert_eq!(\n            Integer::from_sign_and_abs(ss_sign, Natural::from_owned_limbs_asc(ss)),\n            x,\n        );\n    };\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - s == 0 second time in limbs_gcd_subdivide_step\n        // - scratch <= scratch_2 first time\n        // - n < GCDEXT_DC_THRESHOLD first time\n        // - ys_len <= n\n        // - n < GCDEXT_DC_THRESHOLD second time\n        // - !mask.get_highest_bit() && n == 2 in mpn_gcdext_lehmer_n\n        // - !limbs_half_gcd_2 in mpn_gcdext_lehmer_n\n        // - let Some(gs) = gs in gcd_subdiv_step_hook\n        // - d != -1 in gcd_subdiv_step_hook\n        // - n == 0 in mpn_gcdext_lehmer_n\n        test(&[0, 0], &[0, 1], &[0, 1], &[0; 3], false);\n        // - gs == None in gcd_subdiv_step_hook\n        // - d == 0 in gcd_subdiv_step_hook\n        // - qs[qs_len - 1] != 0\n        // - qs_len == 1 in gcd_subdiv_step_hook\n        // - q == 1 in gcd_subdiv_step_hook\n        // - d != 0 in gcd_subdiv_step_hook\n        test(&[0, 1], &[1, 1], &[1], &[1, 0, 0], false);\n        test(&[1, 1], &[0, 1], &[1], &[1, 0, 0], true);\n        // - ys_len > n\n        // - slice_test_zero\n        // - n != 1\n        test(&[0, 0, 0], &[0, 1], &[0, 1], &[0; 3], true);\n        // - d == -1 in gcd_subdiv_step_hook\n        test(&[0, 1], &[0, 1], &[0, 1], &[0; 3], false);\n        // - !mask.get_highest_bit() && n != 2 in mpn_gcdext_lehmer_n\n        test(&[0, 0, 0], &[0, 0, 1], &[0, 0, 1], &[0; 4], false);\n        // - !slice_test_zero\n        test(&[0, 0, 1], &[1, 1], &[1], &[1, 0, 0], true);\n        // - limbs_half_gcd_2 in mpn_gcdext_lehmer_n\n        test(&[0, 1], &[0, 2], &[0, 1], &[1, 0, 0], true);\n        // - q != 1 in gcd_subdiv_step_hook\n        // - n != 0 in mpn_gcdext_lehmer_n\n        // - ys[0] != ys[0] in mpn_gcdext_lehmer_n\n        // - u == 0 in mpn_gcdext_lehmer_n\n        test(&[1, 1], &[0, 2], &[1], &[u64::MAX, 0, 0], false);\n        // - v != 0 && u > 0 in mpn_gcdext_lehmer_n\n        // - u_high != 0 ||  v_high != 0 in mpn_gcdext_lehmer_n\n        // - !overflow in mpn_gcdext_lehmer_n\n        test(&[1, 1], &[0, 3], &[1], &[1, 1, 0], true);\n        // - u != 0 && v == 0 in mpn_gcdext_lehmer_n\n        test(&[0, 2], &[1, 1], &[1], &[0x8000000000000000, 0, 0], true);\n        // - v == 0 && u < 0 in mpn_gcdext_lehmer_n\n        // - u_high == 0 && v_high == 0 in mpn_gcdext_lehmer_n\n        test(&[0, 3], &[1, 1], &[1], &[6148914691236517206, 0, 0], false);\n        // - qs[qs_len - 1] == 0 in gcd_subdiv_step_hook\n        test(&[0, 1], &[3, 1], &[1], &[6148914691236517206, 0, 0], true);\n        // - ys[0] == ys[0] in mpn_gcdext_lehmer_n\n        // - c == Less in mpn_gcdext_lehmer_n\n        test(&[0, 3], &[2, 1], &[6], &[1, 0, 0], false);\n        // - qs_len != 1 in gcd_subdiv_step_hook\n        // - us1_len >= un in gcd_subdiv_step_hook\n        test(\n            &[0, 1, 1],\n            &[1, 0, 1],\n            &[1],\n            &[9223372036854775808, 9223372036854775807, 0, 0],\n            true,\n        );\n        // - c != Less in mpn_gcdext_lehmer_n\n        test(&[2, 1], &[0, 3], &[6], &[3, 0, 0], true);\n        // - mask.get_highest_bit() in mpn_gcdext_lehmer_n\n        test(&[0, 0, 0, 1], &[0, 1, 2], &[0, 1], &[4, 0, 0, 0], true);\n        // - n == 1\n        test(\n            &[6848271667560079512, 13861374652666379954, 600542],\n            &[15542],\n            &[2],\n            &[1371, 0],\n            true,\n        );\n        // - lehmer_un_mag == 0\n        test(\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0,\n            ],\n            false,\n        );\n        // - a_high != 0 || b_high != 0 in hgcd_mul_matrix_vector\n        test(\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18374686479671623680,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                2305843009213693951,\n                0,\n                0,\n                18446673704965373952,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073172680704,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                34359738367,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709549568,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                1,\n            ],\n            &[\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 536870912,\n            ],\n            &[\n                11355937970588734278,\n                3544497895965036599,\n                5225991727718279257,\n                11457652450237970096,\n                16551604813668836209,\n                17754241944512523883,\n                3176704704142514002,\n                12283547505852043241,\n                17557436704460508104,\n                18048039364826572929,\n                13333500704188093729,\n                892648222726932282,\n                2946704070161030146,\n                15809102852568649812,\n                10556060496835357758,\n                13999563791465516709,\n                16795394648020203645,\n                5473855374714961257,\n                6317849519380440741,\n                9533351922984224766,\n                11199301811587071415,\n                16104396350303499941,\n                15525110145422212736,\n                8203351698546552543,\n                17779816949061549823,\n                6150214384826970115,\n                5864639845877226066,\n                8432436556130946426,\n                1694754843869495379,\n                6921022520123639010,\n                8168244414130645390,\n                17924728491331090321,\n                5240620769674049674,\n                7948733356420425838,\n                4164556574449762846,\n                3737022941502002636,\n                6332550616406374427,\n                12049373251003406842,\n                8298091260394621227,\n                11402785868193393498,\n                4794141068545824715,\n                2293061622321195974,\n                3997898020907247759,\n                11390523742316421611,\n                18016308015666214138,\n                330601620407517096,\n                3729949217978051654,\n                3717164522225869060,\n                17148162338327991034,\n                15562487010827154314,\n                16995664998781727861,\n                12334576623153650165,\n                13954922206742126295,\n                616324677452280283,\n                12138651863053041411,\n                2901393340055663681,\n                4057675599502751888,\n                12867219672291525155,\n                16025369701447219309,\n                18291145072066168978,\n                6697243850930356977,\n                18183870876245151507,\n                16808339866631232379,\n                1434968293346404500,\n                7007570804021103186,\n                8146472655024139630,\n                6170247347038667771,\n                11180987210188215702,\n                2526778521668153406,\n                11296437792442738742,\n                2674596804625062286,\n                15397706259368836490,\n                8055008760994234140,\n                3655064363381212415,\n                6387522636703297186,\n                14765097444277449868,\n                2587920917390548071,\n                3777601956819414189,\n                1367003930735636394,\n                14480186758186795163,\n                14461758439666061901,\n                3591570641418361261,\n                6011456982940110770,\n                13775036746519870557,\n                3515973171287160407,\n                11543702048022668014,\n                17156805461772215077,\n                7789863248521128989,\n                8783344931315906614,\n                8862457044352814825,\n                12036193712578424925,\n                10229084237758914039,\n                2530599756212694767,\n                12603356233950916099,\n                10928947856790716992,\n                1278323263344144909,\n                10314562964341343646,\n                1847967980534411513,\n                5032414221301943483,\n                15681738326271406631,\n                3194671023664910533,\n                8791405941685450275,\n                2545048889497795432,\n                10838955567082805298,\n                13202048406979146028,\n                735163755852225584,\n                6550497094317723662,\n                7255798445537127650,\n                15294347560795923278,\n                13594615253945427774,\n                14024060147812684782,\n                12481381765690694528,\n                9035353722672177955,\n                2282788968895170640,\n                16368080906407574474,\n                13331353391507147025,\n                6871599878570595479,\n                5812073143362706756,\n                682268425977891017,\n                17355206475547621290,\n                12788943360185483133,\n                3134625393734037339,\n                2225918008009480818,\n                1378922681447539115,\n                387302346471424560,\n                7981952752578031427,\n                14970285989368295976,\n                15275338493119346159,\n                2055310172270254742,\n                13764120124381520856,\n                11664936006922659164,\n                2643366467379458616,\n                529226747378840064,\n                13267220164946692785,\n                14547927549716284389,\n                6963741308123560970,\n                8742711245029444284,\n                15261140288624259959,\n                1578268278352959223,\n                6373230977423218554,\n                11890422386430555010,\n                5886607793090514799,\n                7833563136219755985,\n                7841472882102640873,\n                13312461380742060831,\n                2395694462667717061,\n                10862004384554721034,\n                1646776064683378692,\n                13189208103829969973,\n                5966205004575172180,\n                14738838372597365974,\n                15020396446219768334,\n                14413755716895328474,\n                9344949375716586309,\n                1229771678439710784,\n                7660206584697636723,\n                1183107462498095108,\n                11726292635609054827,\n                10699209342165514955,\n                7230229562793714711,\n                11021478292667450773,\n                2118474640913963907,\n                2558516995497623930,\n                8845333270363517287,\n                3191138491812047327,\n                16410588907577198668,\n                5980624009289925929,\n                2451953326569686471,\n                10018381451241044084,\n                16452767950546421264,\n                17471045363239371647,\n                1626642226703803238,\n                11701104567773084690,\n                14938496887472066956,\n                18243954799407678852,\n                3462341165977180702,\n                4440268961210232011,\n                16503624676021811103,\n                4947555292161588113,\n                10068740357286544174,\n                12722024646736164621,\n                5215319244188856897,\n                12819613534111856139,\n                11761503529124767748,\n                11212463947616450658,\n                988714827896034783,\n                2795486984158021882,\n                4896614548481253474,\n                17264411928998635411,\n                6991695123855584251,\n                1887206336532761600,\n                13527521258177629646,\n                12908415090831708154,\n                10207645441625616573,\n                15856236799516388865,\n                3288848037346427414,\n                17930163082958088951,\n                782564826362252176,\n                11323264037662272410,\n                7001711656841223364,\n                4079977115693631469,\n                695716839503085981,\n                3374637294286489469,\n                15889407156945307136,\n                17581338039905274592,\n                17094348597898315039,\n                16353196845043490093,\n                11759713419000324565,\n                8686366945008222125,\n                8269792945343586814,\n                5052016679434417836,\n                5028743688612381403,\n                8025468352838073803,\n                7047540105303099705,\n                12096113813124900449,\n                13098595410767341653,\n                9941645490018528903,\n                2681768029589535927,\n                8355744438980253398,\n                18089008391368793427,\n                8436024776108933006,\n                17749009211783191721,\n                10332647584692068706,\n                15007009936211828918,\n                6204066299283285761,\n                5021281476904826405,\n                1600764813061514271,\n                4462704966228492576,\n                17611024951628662247,\n                15690341426616812337,\n                8381957287367776145,\n                14636503690521318459,\n                16361586613759350563,\n                7143185398224610804,\n                7421332207926427448,\n                5160495049104271179,\n                11790556434194897523,\n                3358499649843784501,\n                17568668957737000399,\n                14738977031978362240,\n                10941958707885889897,\n                17560490313279047521,\n                13068293955179990434,\n                1311621805545412288,\n                1724645583247697802,\n                16533119668392562139,\n                15946397208845217035,\n                2606300340733658128,\n                17993371923203650980,\n                6437813290399616223,\n                9301478356539410429,\n                9078893833335741694,\n                9800029831447697604,\n                999283483544934750,\n                9314490672154120559,\n                9858011191982789554,\n                12615742347248446820,\n                12745352278127739580,\n                2917880301505433570,\n                8592553693086187941,\n                4266384572653881881,\n                17812593099833733246,\n                11162145325572414420,\n                7027733596218655312,\n                14251233149261343358,\n                15929293070633912143,\n                1200937482512714713,\n                13064217620622038479,\n                2015406846017082843,\n                15462831244280919552,\n                7394985535627986306,\n                14150714741297842281,\n                13793998316779245847,\n                3289635678328566848,\n                9558502002378655190,\n                16878996228940187116,\n                8476207859286148837,\n                11697860830632493725,\n                7479109953251976933,\n                10627692553918524640,\n                4493048087427514604,\n                16424502988035425858,\n                15872913387110937441,\n                6678548325919201705,\n                3759106456777908735,\n                17905057981958618796,\n                5531956864218250481,\n                5081485037631244129,\n                4438034926824582251,\n                9750567356872273685,\n                11765980608710836596,\n                7992997025333311324,\n                1072399829816605510,\n                13720036779440702296,\n                13696412511769531727,\n                10520426519064259348,\n                14083672259849678575,\n                12606102699487046517,\n                4552441171728662711,\n                10068561237678333153,\n                8335629340697562266,\n                621345583992405086,\n                11625499998573086286,\n                12530589677423097443,\n                5784247379112031930,\n                9573881388612216072,\n                306900559918462036,\n                10802792644526464293,\n                9005291427573133098,\n                3210472577739818680,\n                8109893900355246116,\n                17173601172370596807,\n                5639355372463629115,\n                17776827907372018842,\n                1825555716078714820,\n                5825409710015598549,\n                6386380706326136025,\n                5491078696742670261,\n                10890062618237596098,\n                12934757950932017519,\n                6089055221572465849,\n                5302771001651365064,\n                6529251571951350570,\n                10422598446055788321,\n                6986883759388823904,\n                3479857387959793651,\n                13932683391655597163,\n                11857116184895981757,\n                13620148450025966737,\n                9662736511030645005,\n                17272098448231972157,\n                7373488914627711700,\n                13816388856223655937,\n                9152021189383388805,\n                15526953697508927384,\n                4566792369617010321,\n                17748819712249574290,\n                3975645351903836057,\n                1254146463110192234,\n                12624642013341638958,\n                13179991023549425193,\n                10496183700093856869,\n                16501626902202924145,\n                15437434336748083012,\n                13304628263916915134,\n                11770409937478909051,\n                10425572757187528521,\n                195983147614623088,\n                15825069226305924435,\n                7677098711006719767,\n                7180623381906900889,\n                7606998129912024028,\n                8878945880606186704,\n                4306880255210982291,\n                3567917901108795660,\n                14439736515945599744,\n                10064132280866806031,\n                11114740602207314960,\n                12269057055975187988,\n                4685568551722956272,\n                15841611643677594787,\n                16532384271143875227,\n                3177002035311213189,\n                2748439165446028467,\n                2982768316945625393,\n                17654574962578819927,\n                4719556020732610801,\n                12576980019584600906,\n                3022659802135895783,\n                3345674780500898476,\n                5960242413432350886,\n                9379987545573944751,\n                4790778513006264594,\n                14424237671028891391,\n                9006219756866701479,\n                9012561253523913521,\n                10382281003999164758,\n                15656746742177270975,\n                9209056340857015002,\n                6446905061392500350,\n                5543733769387719725,\n                1821801893357102752,\n                9539889038990067613,\n                2168207589826710703,\n                7899714816887939703,\n                2867435044255337312,\n                11475557911370381186,\n                4616251164227426777,\n                6325316036089337296,\n                14220172204078683737,\n                1479433236288691151,\n                364395557328561445,\n                10181347790448231666,\n                13031251690,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            true,\n        );\n        // - limbs_half_gcd_approx, n != 0 fifth time\n        test(\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                1125899906842623,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446742974197923840,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446181123756130304,\n                u64::MAX,\n                262143,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744069414584320,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446743523953737728,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                536870911,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446673704965373952,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                127,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                8388607,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073642442752,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                3,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551612,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                65535,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744056529682432,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                1152921504606846975,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073707454464,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                4611686018427387903,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18158513697557839872,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                1125899906842623,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551104,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18445618173802708992,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                1099511627775,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709486080,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[1],\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18445618173802708991,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744004990074879,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073705357311,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551359,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18158513697557839871,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446726481523507199,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744072635809791,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709486079,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551611,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18442240474082181119,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446743798831644671,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073692774399,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709550591,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                17293822569102704639,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446673704965373951,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744069414584319,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709289471,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551599,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18428729675200069631,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446742974197923839,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073642442751,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709547519,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                13835058055282163711,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446462598732840959,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744056529682431,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073708503039,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551551,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18374686479671623679,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446739675663040511,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073441116159,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709535231,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551614,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18445618173802708991,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744004990074879,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073705357311,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551359,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18158513697557839871,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446726481523507199,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744072635809791,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709486079,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551611,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18442240474082181119,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446743798831644671,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073692774399,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709550591,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                17293822569102704639,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446673704965373951,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744069414584319,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709289471,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551599,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18428729675200069631,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446742974197923839,\n                u64::MAX,\n                u64::MAX,\n                1099511627775,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073642442752,\n                u64::MAX,\n                u64::MAX,\n                134217727,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709547520,\n                u64::MAX,\n                u64::MAX,\n                12287,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                13835058055282163712,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446462598732840960,\n                u64::MAX,\n                u64::MAX,\n                1407374883553279,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744056529682432,\n                u64::MAX,\n                u64::MAX,\n                103079215103,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073708503040,\n                u64::MAX,\n                u64::MAX,\n                7340031,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551552,\n                u64::MAX,\n                u64::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18374686479671623680,\n                u64::MAX,\n                u64::MAX,\n                648518346341351423,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551104,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446739675663040511,\n                u64::MAX,\n                u64::MAX,\n                43980465111039,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                17293822569102704640,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073441116159,\n                u64::MAX,\n                u64::MAX,\n                2952790015,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446638520593285120,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709535231,\n                u64::MAX,\n                u64::MAX,\n                196607,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744065119617024,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551614,\n                u64::MAX,\n                u64::MAX,\n                12,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073708896256,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18445618173802708991,\n                u64::MAX,\n                u64::MAX,\n                15762598695796735,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551568,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744004990074879,\n                u64::MAX,\n                u64::MAX,\n                1030792151039,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18383693678926364672,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073705357311,\n                u64::MAX,\n                u64::MAX,\n                67108863,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446739675663040512,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                18446744073709551359,\n                u64::MAX,\n                u64::MAX,\n                4351,\n                11917197538718384128,\n                467259134428645418,\n                6788357750791208406,\n                9242329996563429548,\n                10886176818018943828,\n                11527963904631924557,\n                4619262020403083793,\n                4693016615877260538,\n                10656992932246037101,\n                1201267464050846418,\n                16892806369450387862,\n                7260834969008935227,\n                10946994085667026297,\n                2372478557069238877,\n                2649634673312662431,\n                1971108451836424232,\n                15920910453133967577,\n                18343035775416390501,\n                17675740189836358098,\n                7961908122306947630,\n                10522116250551573754,\n                10720452547870905110,\n                13993818308946817901,\n                14981440820269029550,\n                3964393654674426139,\n                9188834164259890791,\n                760657968153329411,\n                15794852728413988195,\n                121692186286907108,\n                8438358951770764798,\n                4083268543268227949,\n                14314095372356483592,\n                16367456820484493888,\n                16488070997942369178,\n                2456304038484914065,\n                5318034970699522900,\n                2959567294926710167,\n                771227150064772722,\n                9625724702091381259,\n                5539648733388948632,\n                6296516403289377967,\n                6612868998968848580,\n                14679407116108799957,\n                9179506663297215386,\n                3126498424100063612,\n                16405144875690137401,\n                14320022863621427985,\n                805941381509761086,\n                17332784969460251591,\n                14850035139935864203,\n                11221361687842258009,\n                17232401019581260846,\n                2512367718866898464,\n                7358878735486392979,\n                13696731821427345557,\n                9293081417681328102,\n                3376318679991353011,\n                12202221967868047883,\n                7633929001522110487,\n                469745074978237658,\n                15671305152530474150,\n                16741062484850963239,\n                9709027825588259965,\n                14965798704955220546,\n                10321462006555968081,\n                14718003047093590717,\n                14951149626183661907,\n                18370518234692703192,\n                6648761387169923655,\n                3495449149370393733,\n                4867982887169583834,\n                2940602529760848239,\n                15303244725027837240,\n                12022601737602548345,\n                5207641806555834805,\n                18224346526787935271,\n                5860200105418976315,\n                4716922763266916746,\n                2931793719851896344,\n                4282902489945622759,\n                15498436420567618761,\n                17476940285323706249,\n                10494618185564967295,\n                17600927612503861693,\n                4004386666445630489,\n                7077257573845093177,\n                15605638591238936360,\n                12750149264765234722,\n                16517469446437411092,\n                5331921608656301987,\n                15990624057943095044,\n                6614187095350567819,\n                14196302046322991345,\n                13429850979948350957,\n                11931776027829375931,\n                13084698857801127574,\n                12621848468679923389,\n                733319738320099215,\n                309720041492809697,\n                4603997955364266904,\n                7631309139653548926,\n                13725082120663996537,\n                10680613565153942003,\n                8829919775953886886,\n                16493213914010845102,\n                16144038634921769479,\n                15174454398009102002,\n                12702158768945839471,\n                2046486227451675592,\n                7191766299935265091,\n                10798251950288187041,\n                10987381149500371882,\n                10099075929210891590,\n                2743950294733236634,\n                10712909458831282788,\n                5399984310001985045,\n                8862585223946748337,\n                4543078657879193640,\n                5972083794371718328,\n                9524422364141495239,\n                4362149695406553108,\n                11158165961894005297,\n                6972411493150091411,\n                4453604966534596347,\n                17984472834103892444,\n                5843292965076477748,\n                6717839842474511028,\n                7073071703492082564,\n                7124040220204291820,\n                15920817649921953414,\n                6033261800600136301,\n                13264404518327225501,\n                3262602253202307370,\n                6118361192463397201,\n                8193286771316418532,\n                10590174942484499293,\n                18086507478089323191,\n                1972161174303495199,\n                13370520826144684729,\n                7006982756954362332,\n                3412148043338776494,\n                2943191784843802601,\n                15479594962300053635,\n                15676367408812095850,\n                9531517811856243576,\n                14665612461344295683,\n                14183812331462869997,\n                13605479300860815251,\n                439986791286981930,\n                4999695897383135613,\n                16752742798876703505,\n                5416349380281137684,\n                13367864008272215535,\n                11925862678811350949,\n                9931716501482730002,\n                5334420036079300287,\n                1839353492333744653,\n                6443019339779438740,\n                5782025392680955786,\n                3310359077816541781,\n                3071937103121471824,\n                10467119917919082270,\n                8363994716135013286,\n                9195653300387363065,\n                1458755452304995485,\n                14455866113820571344,\n                4601934972694450428,\n                8546684886584049785,\n                2910056131585330183,\n                8182159409537093240,\n                11195069301928068927,\n                7430372455973036835,\n                9376197352558750907,\n                7875367292416398486,\n                13472289725149857346,\n                12372323834109182274,\n                13185122839580952616,\n                13191058148790302164,\n                4060060639960051391,\n                14876197669688797412,\n                6688909374239616805,\n                14518552553633126579,\n                17439288972835129221,\n                11119504087401935490,\n                16008905564850227906,\n                16939859930478593139,\n                7728220727027034101,\n                17728948512884482185,\n                2247176307913903150,\n                17171980041243635507,\n                12564914981092814500,\n                8485599174904740776,\n                14944569965672542135,\n                8092344633505138892,\n                2766034468358519906,\n                11524026593306884882,\n                7089566729505727299,\n                16241632485631823277,\n                2191809207409558025,\n                8036842641714644233,\n                3890183076329235441,\n                8506260809383482703,\n                8607260503876159174,\n                5219459906773816617,\n                6248409563984118024,\n                16880377339391885924,\n                7508875978912613905,\n                11838550668904162038,\n                5741644075555979832,\n                4243030907223624999,\n                1548584199410565508,\n                4823393122958215219,\n                1697336748032007427,\n                4231380010852496070,\n                17774901739207687366,\n                4282151946448260460,\n                15342283292560246,\n                8454274642438206112,\n                14884124815651203946,\n                4801003094746403247,\n                8409235268196886949,\n                15945645341541852418,\n                10566745003011016319,\n                5373818074808734154,\n                5957111697658145675,\n                8098283285193372750,\n                10627395543896437107,\n                1004114139502611844,\n                13028365652123892366,\n                17285136039620601966,\n                9771197788525663003,\n                10778155523054662726,\n                1252434210094493683,\n                3104428099285903840,\n                14545119360465992545,\n                13482789168297897256,\n                16892024151842829743,\n                14958949737586351765,\n                176813717701605980,\n                12903584614896208825,\n                3544269214939263116,\n                15415961180239667229,\n                10207167364902374899,\n                8258933860707013576,\n                8763504928324220767,\n                5852219836524758714,\n                8917845927309407708,\n                8650576021936229287,\n                810800948731327073,\n                9432436806001512551,\n                10071761069693900691,\n                17210238083627540362,\n                16157914338762250976,\n                18119096037382139092,\n                15842037880142981298,\n                1938796891348188518,\n                18038449534545012835,\n                830305259048726407,\n                9824993594160172645,\n                14270772538553547844,\n                9335522008741474704,\n                1598988872301369352,\n                7135098133003130869,\n                14517764710188845484,\n                8381545218247466939,\n                17513533292688300788,\n                9979799724575001006,\n                11871456754305636334,\n                500149224166155575,\n                7328657073651369466,\n                8248404162062141993,\n                15340141459299322505,\n                9206212673038925179,\n                2619013708805290566,\n                8436839150868422552,\n                2890681915050735858,\n                2770401271866467392,\n                14574922130718551270,\n                10225699659804069030,\n                12923931425056680729,\n                10689108797349759959,\n                14297241156294088830,\n                8389319625465870296,\n                5887233723227419685,\n                12840203084613907356,\n                18162673586865404776,\n                8624225914841328830,\n                17256823539327648869,\n                12003135778415512826,\n                3597599245381760686,\n                17835387163699274799,\n                14764468716785611669,\n                8824977215853469639,\n                13212822925878714768,\n                9541684495307807183,\n                289792700466037634,\n                3317984079493445473,\n                10424421285541300784,\n                5233593699053119648,\n                860833127156653416,\n                7602647302770159713,\n                13448229100450689027,\n                15851757830006066413,\n                4347783812519020968,\n                9705162038645948138,\n                7816355078824599111,\n                15657526035174035224,\n                8345530277219893955,\n                12809745956138560820,\n                2322613832317857662,\n                8390418154009047298,\n                17480153839918560903,\n                4531493019552839961,\n                13306559295694752187,\n                14105099140485348487,\n                977744740519166616,\n                16173275597988793525,\n                1572613977539690615,\n                2791693683090500468,\n                10895607070984380351,\n                5857659842923811345,\n                14369477901457758602,\n                15971387397482177656,\n                13980771174271954277,\n                1306374729521782078,\n                14876646097142535131,\n                6079868902377495274,\n                14529054656896311525,\n                12651646699699387721,\n                3280738441344740258,\n                6324653974318535909,\n                9721040498224073208,\n                10048475139421707795,\n                14406563703126166799,\n                11594579356863630189,\n                15703055934976840648,\n                16980517382158489374,\n                10822592770083340009,\n                997497860286465677,\n                17713652607295352317,\n                14640107518605433045,\n                11504921534044091590,\n                7886774575725192134,\n                16232729784979957146,\n                8701022159004659597,\n                9422932370459637065,\n                683387794982212396,\n                12522805309568448835,\n                7838941626001579771,\n                9312605586518699382,\n                7599970463029680247,\n                7574987664186768331,\n                531198888309344974,\n                4905818237198157767,\n                5287443443847767752,\n                11054912261682802779,\n                13345315441145166898,\n                7182824994183807062,\n                14675180049751250933,\n                12631232313785864828,\n                17989108850471182585,\n                18050543115820893637,\n                18423857768930007266,\n                3273900906530304172,\n                17484423258652475360,\n                12801016888087344821,\n                17711012173189143731,\n                6549738307451038612,\n                4867667988808303389,\n                14312538923504157926,\n                15142482147452710051,\n                16121208240437843523,\n                17171879328661211137,\n                11677738961972655962,\n                13078497464995716606,\n                7751113107414976650,\n                10081753473167432013,\n                4468516464426989825,\n                18127602331094353429,\n                16767975702693811382,\n                8668788169830842397,\n                8498402294335646393,\n                12966177070433820606,\n                8250332058268580156,\n                15811118180207537374,\n                2361477232834668905,\n                6222737058090237269,\n                1587885103313658896,\n                13218473962721980915,\n                12951574701461712049,\n                12411105451558595778,\n                12644766231497403771,\n                9843819911067664651,\n                9081495749584620433,\n                4594060340198124646,\n                3463880046614810802,\n                9052295694844495814,\n                5855780626312371907,\n                1792160660767445345,\n                11189389626486793331,\n                16480123866965071427,\n                13538658156240740247,\n                1337769093889100585,\n                25213735131173653,\n                13594693503798686715,\n                2786395866168922127,\n                9745235819809541326,\n                1847567857621537325,\n                3661408106486742428,\n                15822353907251746649,\n                635253737448279801,\n                12536768008212611637,\n                16205598701707230534,\n                6208704468299969673,\n                12632814267855645761,\n                3983629484208856920,\n                14463715595702959132,\n                14068644471445808672,\n                13071424163135564830,\n                5048244838017897198,\n                3957348508978029479,\n                5171890733073780158,\n                6090355458677010676,\n                18410043021067699918,\n                102411056976507785,\n                12496578301072641109,\n                7489537163555902605,\n                4222835379178602700,\n                11897049925808045969,\n                15254226892154904380,\n                2427764677907392764,\n                6097459900604836271,\n                14167293803271640391,\n                15572454008598321436,\n                4479437047685147582,\n                14634864923535733535,\n                9440363258554695720,\n                14447172202107496642,\n                7737099397251411392,\n                10872252838093293197,\n                2347781704700902159,\n                12892601897325517851,\n                18187570864085126771,\n                3862570130037604031,\n                18415681868605222990,\n                14872486503424548851,\n                290001522323890694,\n                12689386207005040067,\n                18367639946821497130,\n                23954916269174833,\n                17245821941163862773,\n                11894661335959030463,\n                959150115393729462,\n                2015998969739268525,\n                15315512592879336413,\n                17353907236181211247,\n                6439362580061316324,\n                3694810751520126307,\n                7251119290538843884,\n                2902818723072045378,\n                16029591053956459275,\n                5864718627412226067,\n                5790025469765734459,\n                6773868036272256548,\n                3999623636821784476,\n                2497507128350253602,\n                8302623393498593261,\n                11471292698362373968,\n                8320975184255973432,\n                15654963738169930347,\n                134083697380355810,\n                1100458250563753914,\n                9283598718625555235,\n                5673024045082942208,\n                3336856015239924756,\n                8991471779663227287,\n                18220352109739797206,\n                3201920047088347377,\n                14048295331995920496,\n                2023216756502051055,\n                3937018610966240739,\n                9265528332519197997,\n                13340683957228210488,\n                16395501556237436690,\n                11882279545751936849,\n                10654538555885887306,\n                1213641065209991369,\n                8686438495717443238,\n                3204522269330159380,\n                15749257989555621891,\n                7200829664472660344,\n                4606035142128288244,\n                7738145978279406878,\n                8005750434116314508,\n                10039090611220128432,\n                5919432049926072824,\n                1898955354979287264,\n                13742546998210628515,\n                2062380153955383477,\n                10627849102165617898,\n                10263733156880394488,\n                6187246165891479344,\n                6842758231513896980,\n                1044980371062368886,\n                11619956366420670628,\n                5306150757083506465,\n                14493806618830043219,\n                8516775388512886261,\n                12966310564897513054,\n                7977410936359711070,\n                6472070119922783488,\n                11685909650081989228,\n                11077466008455317410,\n                93779104345285196,\n                2263631665127678501,\n                8484269669373998463,\n                4317253498968686951,\n                4086096203557045487,\n                13581861404151879145,\n                5728397180081682581,\n                7010007051891978798,\n                2821912591057075698,\n                5879426090505992869,\n                13569541343551121555,\n                7149443705748294066,\n                13910494223862857288,\n                12658627337344496058,\n                2951750024777275755,\n                22962926030546005,\n                11049711249112626032,\n                6001166774644846695,\n                7990182725043000123,\n                13513885125683051345,\n                8512916727377461799,\n                9117393073038165173,\n                18018665698956545109,\n                9317438210677247667,\n                13228179741076658181,\n                8661423552785887573,\n                16181753946942005215,\n                5817006592457107177,\n                4946404759149000501,\n                17025463002044524938,\n                3091573145940415028,\n                5624455086851730975,\n                299596446419786514,\n                16997248996797575926,\n                5442881049272221237,\n                16640822063105180490,\n                7201369405851839100,\n                1990572593974844456,\n                18065512913263752946,\n                18435803827758421726,\n                3940680480451692192,\n                14695541863675895009,\n                18237945747361846765,\n                11523059833149211458,\n                14801621049236961830,\n                13093650885612556220,\n                18073264199739840152,\n                11232873781393214848,\n                4738273277154183967,\n                8770083886080393014,\n                9448453106360155017,\n                16808957868302654163,\n                15595086290970401573,\n                6687124880891546159,\n                11219335141762698876,\n                9380127018866822584,\n                10327758572616370786,\n                12205962561173980334,\n                1292378777928694178,\n                7701183202987422345,\n                18362257942086401551,\n                6058850841413861423,\n                13437237384376816904,\n                10936547361793543928,\n                15650097713642375395,\n                9913147450601628212,\n                15909605568129499495,\n                11513460193413160213,\n                12780098351351910037,\n                5212701352903210016,\n                11564025864354328627,\n                8700098770020742313,\n                4899380922086558778,\n                4050898917285079051,\n                13661989352190807516,\n                10966728149436612554,\n                16847843417882464903,\n                274924042498303488,\n                18222284358029704003,\n                7577065190825838785,\n                15003614659630419448,\n                2624069814584755546,\n                16881026613694635169,\n                15300060653308040957,\n                9570234639793768301,\n                5784677630619169063,\n                1135179792440620182,\n                878922669379348230,\n                13627915631233840567,\n                1985946077482791264,\n                6391853516359415788,\n                15570291686878623581,\n                501707176891222139,\n                5957022918137638671,\n                5956247526180593898,\n                18226765754149736016,\n                13338056793022561402,\n                6432376523812042513,\n                767152662715876804,\n                10201155875474385234,\n                7446824482480043740,\n                10487128891092272938,\n                8753372664509444428,\n                18079456715932134001,\n                11624853191447527022,\n                17566358671204115242,\n                17018919029686381250,\n                2111234374616573204,\n                9480242526387098658,\n                2429728644808764358,\n                7252446333936316953,\n                14812862792274767439,\n                5422271871225914827,\n                12412305305577171801,\n                1185008520838149346,\n                3050026111086571739,\n                1479014294376021732,\n                18040200323783099330,\n                445973913795316809,\n                9501364820370671400,\n                7229301050267458578,\n                5215280963194612127,\n                17088616964070030911,\n                1211285093482602371,\n                16412084179763424819,\n                6127319388370601780,\n                14321419570407056924,\n                12145388950945552845,\n                3151594979185432120,\n                1675376244241883765,\n                16035687529597509596,\n                7571293182649441152,\n                175550498630765698,\n                16593238056068470505,\n                1814341778388969595,\n                3311024737818411516,\n                12770957752805211539,\n                17631719244677199941,\n                8795460689496576017,\n                3690652674506323732,\n                2428882789489849159,\n                14730942683624044492,\n                18326270070598508149,\n                11964271508281591609,\n                9829424265343173509,\n                15758964916794844298,\n                2461618406724607460,\n                709439034532299949,\n                571182269550622472,\n                1379073389911508673,\n                16644335569340215058,\n                17367543108812074229,\n                13444880229306119718,\n                15724530661215895601,\n                4047906541646187785,\n                4686650652361404048,\n                17238280140069784141,\n                4068910883473961263,\n                17655282977204804312,\n                11518276288990596576,\n                3467897255047563766,\n                743113880655434578,\n                1942535316548544695,\n                6619981797071393726,\n                5025961891257111145,\n                16592110483904182561,\n                3928324895371240622,\n                9737258859280736451,\n                5661254605396046378,\n                11163745722429719144,\n                17083006376780241503,\n                17506382401952249312,\n                1764127145955644136,\n                2308897656615883377,\n                122979845480243850,\n                8075446398869802985,\n                2187259826315952725,\n                18434025953725754274,\n                3124178986621188904,\n                12866647436942698703,\n                1357236272197199912,\n                9078709271602493271,\n                12468293812747433865,\n                12437259926403880115,\n                14436048005013653854,\n                89642992988117440,\n                16523797273367389305,\n                9043367976020866146,\n                12463395346461196797,\n                9862261089924822182,\n                14657746177936768112,\n                8825469242077938034,\n                9129609557253922495,\n                6888044783796588921,\n                6266713628643147669,\n                5220942463058228458,\n                10813630780587283743,\n                7968832679516396373,\n                15970129806498677212,\n                5643891883064886939,\n                9824143743589185710,\n                10400697215263251029,\n                8190620745660574041,\n                10238618355555564865,\n                8918941655352077567,\n                10871235401787589340,\n                1460739087571168519,\n                2823745702037521010,\n                15337263495117106268,\n                968161936177366335,\n                16689016160632043912,\n                7848489458860449863,\n                10398358129317695375,\n                11584918823272315734,\n                13901934479805418812,\n                9574709144377930221,\n                2111587472743157797,\n                9404690877383586391,\n                1590261001575452774,\n                6134044942408749913,\n                9839924636511642837,\n                14493598904422521457,\n                15632908487818372617,\n                487545237727920944,\n                1802722569923057493,\n                1958947450166852109,\n                6867362149480730072,\n                4772292527599116912,\n                10583080518323476356,\n                1221855970145623550,\n                5948499263531823034,\n                3495089086729498045,\n                12066360463076595030,\n                10771591788577692723,\n                3954187584618376697,\n                8187128112385053815,\n                1454504010792563026,\n                15959458072896963922,\n                1581292658782340862,\n                9692831561010284189,\n                10309426695412145821,\n                17906554304756557589,\n                15054157577871514625,\n                5058050233476401027,\n                8977640754771236893,\n                9627862855892683832,\n                10699519167644754760,\n                8312772912482187477,\n                8332644095735932279,\n                9049498226063315161,\n                997818841660225453,\n                3693781389037645036,\n                1144225405512234695,\n                3247638062925459825,\n                9845499292221371832,\n                7214100452002833535,\n                13714743610307947023,\n                9960430565581967579,\n                15735339179405466356,\n                15625934646641742062,\n                17726446932751133474,\n                12466451891602142569,\n                6375000197140594959,\n                1804204775829221428,\n                4530402129749433189,\n                14921578666027523559,\n                17772348524780474456,\n                5690248012292173794,\n                18333653072911688035,\n                15767765611816527995,\n                5732035322385811433,\n                5691521304590002551,\n                16083874229056371081,\n                2974572122345241237,\n                5328620585473031115,\n                15044351400969060080,\n                14466412200009582770,\n                17782787336388788204,\n                3316258621322435409,\n                11748403349011599839,\n                861962132923513040,\n                4887924627919467034,\n                18409613134327857507,\n                1745648181716009640,\n                5126024415670625429,\n                16863431110236260032,\n                2600510782962714478,\n                942626199781748852,\n                496511142761735889,\n                6759476802769137517,\n                16696041693879173804,\n                16687962170563294152,\n                3414843693481777663,\n                11365529158754670742,\n                11372869234139609818,\n                11819362223430480664,\n                18033204110273523753,\n                5618547869326219703,\n                17704195460847759589,\n                16049329338769286554,\n                4133452506455359139,\n                16326665087942006883,\n                4297538536529132241,\n                5047883522524396976,\n                14714906005027183437,\n                5329799583480738955,\n                10690501377556811520,\n                3652332036981148106,\n                516750725933923982,\n                4827800595674301759,\n                10448722013809472310,\n                11596999240332271563,\n                5927034132466409103,\n                12147048889264772882,\n                1089987820933222753,\n                4192412164568901269,\n                11908801153277116781,\n                10197687527260251620,\n                17895324101664653242,\n                10630777741097080977,\n                15358104418706100699,\n                17713199249506024637,\n                6459301066733754263,\n                16403734392003091136,\n                4604905190697647969,\n                17619115205002424831,\n                5574765860444266579,\n                13544006739749082480,\n                234951002765790631,\n                9100908206014736874,\n                10656401365796207537,\n                16925148628801893669,\n                9449341584538177921,\n                17352850195614236618,\n                1022065146657905242,\n                17397845413549299667,\n                1472464743447070941,\n                18057563713057329794,\n                8983459205909631202,\n                4925912043959382413,\n                17616318842542666695,\n                5163968491091913551,\n                14413758582451093019,\n                6337633891942044037,\n                7925297373525658970,\n                198793232404117347,\n                7758553085065395961,\n                4066515756447206607,\n                7389360101646457251,\n                8434909634529440653,\n                14266840326541123051,\n                3664978103235861792,\n                11163743218713176050,\n                5634257584230363951,\n                8083953074398386596,\n                16065890200113083079,\n                8110187990551805421,\n                17356164101512399606,\n                17992861118993870844,\n                10807783544543478597,\n                9106380242531919579,\n                3247174148476821056,\n                879857043201935030,\n                7277837200255844536,\n                10342478810494109596,\n                7769376500905648935,\n                6757777022343131040,\n                14433140844987570288,\n                3667302115484509962,\n                4952536985082809733,\n                1157782009537443994,\n                7388263404883144155,\n                13472936065806592300,\n                17712841629692457235,\n                5995317353880662009,\n                10921426583438212143,\n                12179213766915844655,\n                5936895377887378184,\n                14322156414482589235,\n                3826747354860666209,\n                572716595769055849,\n                2210089877779855353,\n                13835979775768645560,\n                17170702006657807683,\n                14591913253321414828,\n                6903263328385067839,\n                13237096933292161026,\n                16330366375298997716,\n                5525224905127580645,\n                8788863357092236563,\n                12448635220486228412,\n                18383201057494917349,\n                5685763045488991174,\n                14048501692736865413,\n                4769882810124814370,\n                11545233589288188582,\n                4494517485389924572,\n                13535319148707364133,\n                13735436845168944725,\n                15623475297010432846,\n                15624175619779801061,\n                1105816345140707954,\n                3727827862044247913,\n                15622289192708498694,\n                14187891019453013466,\n                13669457386124092325,\n                7787875468170725248,\n                14784127481172851456,\n                17500738909398230430,\n                2638672195611188012,\n                4369922987899757508,\n                9267506988909833873,\n                83899162371683818,\n                5657982455700308645,\n                13933782505443221438,\n                1385537874543388417,\n                8959434570591275846,\n                11221790620561509485,\n                14228125069662643278,\n                9909285045196542290,\n                13339627666512404139,\n                5072335295730660920,\n                7706783060191260337,\n                17231367447326094941,\n                13611972450650655904,\n                7252643560574698729,\n                1084812010386004798,\n                12946864548261445854,\n                1400313932997877069,\n                4588814836223113033,\n                987850811243060775,\n                3864997441785283522,\n                17599159350799904312,\n                13358032302365334533,\n                10141406154556810755,\n                17519361843239805040,\n                10915050108045622994,\n                10037174394817457317,\n                14469957883502949034,\n                7894829998151829341,\n                5636706558663217429,\n                15322279537825265034,\n                2396991900646263908,\n                8687396393462659176,\n                13485046092881595881,\n                9515659004930683430,\n                9429407622645326903,\n                9775248867058718405,\n                10916394549216341610,\n                483499136658695224,\n                11696589183261297643,\n                17279704547926580810,\n                17981456583759837666,\n                13325285482477722136,\n                10885197771076066967,\n                11092160349269277927,\n                16052410044282049678,\n                5037152622918883442,\n                11990176335222269624,\n                6948248507362872214,\n                16693754514326339970,\n                10461487764282800089,\n                2923564231271193330,\n                1920420216782302061,\n                7678699056037047591,\n                17659248341954076160,\n                1344087719368849432,\n                6013967839271137192,\n                7354032241978048812,\n                15496951280651194682,\n                6849045677301130055,\n                7404988064599461311,\n                17038584755626314135,\n                13989234369614587716,\n                137578066471879568,\n                12026307344383044322,\n                11253546536381009806,\n                2413006684071354921,\n                11797891407965975240,\n                13725020517275346702,\n                15664516332778507640,\n                5062525165078702547,\n                14354507223678652178,\n                15914941475966331443,\n                12639494759681519326,\n                6380510796548352415,\n                4480105256516383199,\n                5535744400880483113,\n                1895958289260972381,\n                12590320805441890710,\n                10985511241601241382,\n                9398017657977186818,\n                2799034594416011077,\n                14151939373239242853,\n                645490586599440523,\n                3809153665439075705,\n                4137467509776042994,\n                17354288216922338214,\n                6861193332615528070,\n                14738703648309330785,\n                98425663280239976,\n                12633851606975418481,\n                9785309034847603183,\n                16384799002475880508,\n                10931676995354970357,\n                985219608827803071,\n                17116957879956090141,\n                9101128336896036709,\n                11759983146088777269,\n                13015836674349684930,\n                15182092148682035351,\n                12836219866833634742,\n                11351106793190323210,\n                7840239307741716217,\n                11953726720158733414,\n                6628111943421404725,\n                11533662362420450459,\n                18369026228019546563,\n                7378513891084408617,\n                18154554674430175598,\n                156313846508387694,\n                16389733506781231332,\n                13914842726751003220,\n                18359517497569945195,\n                153206050418651881,\n                1048545139235406179,\n                2343069945378490119,\n                13221277598353216411,\n                1007579421943431502,\n                1087244838874317765,\n                13458642723894472673,\n                17777936966601400310,\n                7403025134549352232,\n                16597313881116482506,\n                17238957863339639244,\n                15264094753736934506,\n                1521680934845861710,\n                1557119627713031502,\n                16758686315895245035,\n                3796780137441489417,\n                8041960852929629915,\n                16608665948179582203,\n                1625645673158223013,\n                2300155596532077984,\n                8697518146661645554,\n                7409532402929679963,\n                6094459603168865699,\n                6558659569835998408,\n                8795865676999740518,\n                7414435640027234930,\n                3251947257573801174,\n                18427982151104544826,\n                5089951943467385160,\n                1401320279557700072,\n                3443749410134273405,\n                14030504630906880686,\n                17717719525826942963,\n                13215855120775253817,\n                3132504310059563638,\n                16144721530636034096,\n                4419633161552666567,\n                14954927501148389788,\n                16040852488245131634,\n                17441383469187402203,\n                5726385465541871539,\n                7394309454153803838,\n                7805509969418156305,\n                18037815606213679868,\n                5291835626363349632,\n                14635636495828813980,\n                9527936813559225710,\n                12597950725219919442,\n                4482140912854906507,\n                11126850444677396594,\n                4603523671821822232,\n                1649284289763661202,\n                1352906224724359281,\n                412590628646840670,\n                6996792898450011479,\n                4249279972226121347,\n                16031651732968496391,\n                2572334158533663991,\n                12347635976334350133,\n                6050273196783955591,\n                3246101772441301834,\n                13236089237569405152,\n                17471674455305786061,\n                1374645614093451841,\n                6815512315773585362,\n                11212487861088835231,\n                11308144268901363980,\n                17583948142960339023,\n                17810432752181566118,\n                12908796636670459090,\n                2122965481552992886,\n                13847569072419969913,\n                1885242280013246820,\n                16817717666957161753,\n                14122999869920814272,\n                9859723031623103719,\n                11303579127011954292,\n                18003588455125152868,\n                11608919537471305040,\n                9044967188677210322,\n                6634260888999233338,\n                7574880733619538648,\n                13351352388185143358,\n                7396424494525052331,\n                671815673850175731,\n                12474963203784163870,\n                9547951060319591849,\n                972244301322094093,\n                17949023223636564564,\n                12094555917714073753,\n                1826916629327265902,\n                13700478109063132032,\n                17067231999223770315,\n                243553916488249389,\n                11271453694238339233,\n                8732841242081706152,\n                9630793208957172586,\n                17446946104225081590,\n                5386829181566009948,\n                6054032971247389454,\n                6425015402571254341,\n                5006727812077047764,\n                1649789753514978836,\n                14723706592535708266,\n                4623978742676807297,\n                12710669164864869688,\n                1227780667083299405,\n                13714687322378497593,\n                3970422473073140387,\n                17265185031574773737,\n                6044830517845117529,\n                4453913678950321656,\n                6070005351778429309,\n                12176528240255678941,\n                7634537565077394947,\n                5920003618676265431,\n                11151627697721642783,\n                2098910925983806783,\n                15884306031133129509,\n                310067712781609295,\n                14024583474469751439,\n                17367719315694324874,\n                14424048877787895622,\n                12898411728086808947,\n                8953476654824027211,\n                7420571574695821582,\n                16094462443071534333,\n                7924169231214629362,\n                6878953677396960568,\n                154878602193835204,\n                13117567967104831967,\n                16556390858921765924,\n                5307332782841571348,\n                18150137521763992397,\n                3419976873747586767,\n                5858343539030355643,\n                7242296027220085783,\n                10965812104117451576,\n                16926965337779877856,\n                1601745124903955748,\n                13043994460177786078,\n                965169794640251015,\n                1943838529439481814,\n                10512319789812683259,\n                3844363432719685472,\n                1784837719119553167,\n                9468342792812849672,\n                2079904699316123181,\n                4129639703756184131,\n                2758297517205037135,\n                108586575672941788,\n                15547613664182116875,\n                6035998724236756,\n                17879991472252388776,\n                13693503069715806549,\n                3369358401497786056,\n                9688014843989801938,\n                10886459666257554215,\n                10393873019075670260,\n                6474159222462837717,\n                11243201032507786025,\n                16480121773023363798,\n                3226162915341963901,\n                1639108311236754072,\n                2585899667596998192,\n                14880301282874412647,\n                6970353541542233591,\n                7066115370491066021,\n                12694378779036437026,\n                17300617989102326075,\n                8283880842910890844,\n                5733876387824463732,\n                7951637249672862628,\n                1884141858212572689,\n                17015562239978558793,\n                4101828539017111698,\n                1103941533641964734,\n                13926022087478456712,\n                5024297271233621371,\n                9812418390690689673,\n                14992175312699678246,\n                16469893987247590657,\n                17570003134344434044,\n                13774143797513849932,\n                15772170500133732473,\n                4505821373766406837,\n                13996105830221088706,\n                1307766568769961087,\n                10729111457938251830,\n                11903845284444031988,\n                7854954755461745670,\n                10702619846963864915,\n                10608054100914243590,\n                6496893465131516234,\n                7241847511138135473,\n                3290888428315871736,\n                12664403582508649645,\n                9256771540519762367,\n                10264702404701897883,\n                3440088740965487374,\n                11529228460257674505,\n                2557227963071325614,\n                4351683269520556301,\n                11480097036161740240,\n                5615804147927032409,\n                8696276544281707589,\n                8117054923564791760,\n                4144540882354007558,\n                5246282716979102995,\n                16995837840762814682,\n                5002830053652768385,\n                5801390823422242943,\n                4685082241623089592,\n                3291652231640469960,\n                6091224371117976744,\n                1812763503175439853,\n                3813538854131386704,\n                4814848514078956363,\n                4046304873091181065,\n                17556508066037799794,\n                1871634009072900244,\n                14472650181236778075,\n                9420859677652280464,\n                9135633053662681532,\n                675213668906522010,\n                10682442267742318053,\n                5711990428027981792,\n                10951451073519478982,\n                766857567858898227,\n                10847907462605970605,\n                6065052831567493122,\n                10532184994483451863,\n                8084511492809001972,\n                6013718559355095905,\n                9089889612727338792,\n                13799378013888921126,\n                12551785775851801559,\n                1847395314627620923,\n                7067465808110764515,\n                9273405725950712925,\n                16061184093788784079,\n                14194983586797031158,\n                16125782867927384767,\n                11616632751689821401,\n                13227070560643064832,\n                17594387943145043458,\n                5137778382639156537,\n                16174520549303126373,\n                12122202659641254860,\n                11003713498475843935,\n                4971801422905630248,\n                1217212572287812698,\n                1036227015807837693,\n                10442906734009178473,\n                11284864730138525025,\n                9947575731798924567,\n                5027362708159125049,\n                3752129144967291560,\n                2960641676085640474,\n                11584372829953454537,\n                10976279527368184254,\n                4580831562516225285,\n                8086204985855056132,\n                8996712180244650002,\n                7715599106322448832,\n                15931472255763524212,\n                1971619108491661283,\n                18244317999002456195,\n                1284415258819328801,\n                12125649841582739326,\n                4806115081395231902,\n                10635010712401904408,\n                13489993017783266749,\n                10755180102170600666,\n                12016345415613188833,\n                3471063253445106726,\n                14021420171198356055,\n                17293350725318280803,\n                10889721386265843914,\n                16367368287829061159,\n                6301860042408593060,\n                8629376189523509271,\n                3317489641303687379,\n                15735798542524987110,\n                11962155895247876771,\n                1443629942311540747,\n                12029637317319989121,\n                7498249727135946277,\n                14712667982794134650,\n                12944084830528446084,\n                2764765003066482070,\n                2854445344561625747,\n                882610519371119320,\n                1386247692016949804,\n                11437494134261570337,\n                3707107567076075237,\n                2363673877960951426,\n                7184162656421523580,\n                1374330300807540634,\n                15336828516996887157,\n                5900781099131610159,\n                17092261865532565915,\n                14088693182396856300,\n                7691375190364331095,\n                3746409477975447222,\n                17991091905749914953,\n                14111419322357715842,\n                13211318834446203111,\n                5418516281310316920,\n                5670045581494629441,\n                17658334361689239595,\n                2108029137002093549,\n                14313622615058753167,\n                13683987417197870862,\n                16060144913570862782,\n                1067763430575665666,\n                12632051224603852245,\n                10851697926622672865,\n                9588075001168783072,\n                400613793270516128,\n                12297195143507882693,\n                8054731338565754541,\n                2296983723110295570,\n                15136311235051063598,\n                10701258502087521714,\n                11558922171074870259,\n                11722638033542392484,\n                14806800759537087336,\n                15531881014378368883,\n                12427494893532097503,\n                467394085720083263,\n                18159008869017580345,\n                5214197392903202485,\n                6579828274439693162,\n                9167401586009547292,\n                10817157266021471160,\n                3303353746725980480,\n                5316609299445779753,\n                1679025852722401379,\n                11221832940207984935,\n                8821536010854863600,\n                17311869774039475233,\n                15460739364466765413,\n                11210609456295001830,\n                6043888992904451998,\n                14195602925816930035,\n                17690712454067213912,\n                10708905609224242910,\n                13541652695119112477,\n                2484803431998114675,\n                905241005534806640,\n                2741427072113199786,\n                179516635379145221,\n                145341081986266738,\n                4109486671197751144,\n                9592092440988458306,\n                16717627225748860784,\n                18440345496969754461,\n                10672639747468022467,\n                4474225683973246234,\n                10670817900687737355,\n                3687654351172481057,\n                2697942980000674645,\n                4667131075695104356,\n                11914563608342066044,\n                10294211024044167256,\n                12179704490813269468,\n                9011172897832539131,\n                11966680153227839937,\n                18047985765325405039,\n                5048883640165276858,\n                11131260788346730474,\n                13188143378547512028,\n                3377339845104314856,\n                11824975074156196159,\n                17750235040691621925,\n                10690204996569842363,\n                256640914422017998,\n                357868591023193335,\n                7876808526238499727,\n                4228665387819803646,\n                7578347308951882891,\n                8253955030111801990,\n                7255801529299328384,\n                14954517686447376866,\n                3929485329094621864,\n                8602942584826959129,\n                16791305395345025533,\n                8712508978289902124,\n                18383688978826077507,\n                3668185011075959874,\n                1847275755905255388,\n                13833908477296618289,\n                5832883455277909516,\n                4168134403464322648,\n                10925334857444642955,\n                12275783674949681665,\n                13388380204448837518,\n                17172136531633985230,\n                10080697440998614693,\n                16579748389167624320,\n                12262047791024296091,\n                3883734914407012192,\n                16413746672773190340,\n                9163722456199806655,\n                13632385029033553946,\n                7257756678447084352,\n                10570740578549843944,\n                909182340352774742,\n                9973440265165496585,\n                15793302665658758423,\n                892957810907494964,\n                13567460345135637802,\n                15915801753926444463,\n                16314426909780627203,\n                4325332491558892825,\n                10282318917480106916,\n                1430342891281168225,\n                4340436763451344083,\n                8602444773228369786,\n                12577613701092723202,\n                16840931257276539234,\n                4094467763753102002,\n                2249502336046865460,\n                7328248091561257375,\n                4621638961215672766,\n                17229541560790693173,\n                16545671095960283233,\n                14518571375507105332,\n                5804973654107391003,\n                8709229380030480574,\n                9990434914736733794,\n                9723644027904806142,\n                12057903405794717044,\n                10818591074630083757,\n                18348136862696637400,\n                14678266375372084601,\n                16900409476169964341,\n                3034963882425259293,\n                3167651946632659846,\n                4410235577786583447,\n                13575184744453193590,\n                7077248547196566543,\n                16830457306748119087,\n                511485899348349454,\n                6901473958934680887,\n                785696383276801953,\n                8922677902813387176,\n                5028694348653606724,\n                17437317432033809094,\n                14981237845783583485,\n                7400686487113533807,\n                12001974820586931621,\n                3118056124031208024,\n                10717883141114711950,\n                17013562329850461449,\n                7532923731827628356,\n                1833580041892114837,\n                12251179626826968345,\n                11548412145272879822,\n                1120123386501627862,\n                5131867092830440217,\n                18075081008098942170,\n                12014815695321045021,\n                18030589421941047544,\n                16504293085968714380,\n                17252487903048824044,\n                7640487705898588388,\n                3897229150582196255,\n                11439950389496976994,\n                17513829770930387561,\n                5124348564289236103,\n                13515270180377522144,\n                18184762162962780302,\n                3688748029759276686,\n                4903308852396077465,\n                18338836340627671787,\n                4911275278056517679,\n                15768289954506458447,\n                11882722021630771588,\n                6718393444557840787,\n                17679718798591753847,\n                4219104908979367799,\n                11823590828003448947,\n                5792287036297286600,\n                1492912452063926925,\n                13338698090707287608,\n                7078736767135710087,\n                6895222399159193001,\n                1613471817627361876,\n                1228002015523674896,\n                9110592915729799342,\n                16469419496360499135,\n                12414779780779902169,\n                9455433338050198187,\n                10953322759902347771,\n                687091476176112493,\n                5471312586012729173,\n                11228882600950307957,\n                632835700636907199,\n                17575996154731445607,\n                2880149435400104285,\n                15321998767805560423,\n                2018468709500559555,\n                15035929994060302869,\n                4685637389004573381,\n                3702610763727170468,\n                4896722462139312004,\n                11612596970172007145,\n                4616444404271446613,\n                13042306566897879324,\n                6076061359144311187,\n                8320474397881696685,\n                8867301758476067815,\n                18387741191438019300,\n                347670170064456387,\n                14761545560141811395,\n                16303475827138059519,\n                6863265773658620949,\n                4261565355829199190,\n                11772361460121452650,\n                17423974086149689574,\n                12681129455489980346,\n                5754420294087598158,\n                7964184772992158089,\n                7006632461862580536,\n                7230054181425297855,\n                7347859753792559535,\n                6882434486449872811,\n                7102419138826470627,\n                14610386652763771585,\n                8878942332824329099,\n                11644699200154914272,\n                15054537940617141807,\n                7164285287229640985,\n                8022822127993686066,\n                7058617349866886726,\n                3019338566698601538,\n                4696154451315354756,\n                6126435485082221366,\n                2654526620337154797,\n                17276765426024735235,\n                9289064677212272920,\n                16894647485984726643,\n                14973287106016047023,\n                6537958514178456591,\n                13768213571063461973,\n                3189698594428075903,\n                7040981916653914956,\n                7476787091985031490,\n                8122024880128693863,\n                1485994591131551483,\n                14539266872860076173,\n                15075162335010586478,\n                8663214674123590959,\n                14980664576759386812,\n                3264511451583107616,\n                16660442336996209760,\n                13755067931389298150,\n                3555348286524718365,\n                16066823018481011177,\n                1009485870684643739,\n                16928829830176023338,\n                12593383784352958789,\n                13576909900638717802,\n                8010754241336861457,\n                8194925413818645067,\n                17501332405299764854,\n                18044180854274700566,\n                5663787458489580246,\n                13083485429814184115,\n                14314282841638677445,\n                8350220439067108544,\n                8738835826281352023,\n                12528500853838783816,\n                9812633903167926546,\n                886282588018221528,\n                416147658393672753,\n                13694192015584360325,\n                3327910040517474007,\n                8172937500772585829,\n                17333974400158156025,\n                11848986334948736049,\n                10622557117777672416,\n                1129941979036597547,\n                12168369103511572815,\n                9074668820441846070,\n                11533110649544965806,\n                3156369834071381572,\n                17936728294421846939,\n                4561241156147284199,\n                13734562965145777350,\n                5276857787442099625,\n                3990232838045952002,\n                10728645564246549083,\n                4822495109057834927,\n                4429949123242424233,\n                12688029222319074493,\n                669680392456321210,\n                17722380388342762339,\n                4269595772790284951,\n                3335023966198498491,\n                11516392821056344201,\n                9041952461508609253,\n                15687025895078718235,\n                14560897698334506574,\n                9016479274115282812,\n                16897021433072924395,\n                18172555947711149923,\n                8613359814568774235,\n                12662118507684162438,\n                18115608179444768196,\n                10096995119867331301,\n                15689359985844883957,\n                5052951553295244820,\n                14194640351068690551,\n                9226144077055849859,\n                7070792885547658582,\n                13478450510867878730,\n                3528788801611599888,\n                1358031493355295656,\n                7215903336933229336,\n                14001607369109031663,\n                11296683305872531621,\n                12225728043235597625,\n                2783845218926930333,\n                832523950912558029,\n                6537921841160872686,\n                16655673248615176903,\n                3655607938115286171,\n                1563701058216047015,\n                17498532603296576941,\n                3724097542032768642,\n                1322295798949574975,\n                14822423238604209870,\n                11097117957896819969,\n                3937819528496302837,\n                17274565246881023067,\n                15537338620040053121,\n                1415840569465800875,\n                5097809290847166342,\n                13308794489786964510,\n                10045694316133243145,\n                3203702183981460129,\n                11892246328800749268,\n                5346819227097419135,\n                8161642858180510690,\n                18404329522341705953,\n                6667284079159551629,\n                13331394309390364091,\n                9418064170232105489,\n                14079617197476330632,\n                10007761636440287929,\n                12914080562421721628,\n                18113231676002877066,\n                786975794319221829,\n                14523653887731625294,\n                10180382829219895764,\n                2236935642758046746,\n                13537255082936007982,\n                5027843085254689574,\n                896691321163055234,\n                11678262980292549278,\n                17510613197338625579,\n                15617034645939458747,\n                6426372294284491254,\n                9878131142019681656,\n                7028419299471247274,\n                9951301707966380523,\n                6051424005064861800,\n                16321993232172611515,\n                6009273340224874864,\n                16868777393760599996,\n                420080864297372651,\n                14292171550152541625,\n                18017208527943818861,\n                14260202539735654373,\n                852696131942719722,\n                6988735350972839043,\n                3318740395029351344,\n                4123261571324085504,\n                15548297437520045000,\n                4527080397327303882,\n                2885662654426481577,\n                11553617744287073167,\n                13632897248287146672,\n                3155708576640639179,\n                2806396943812538034,\n                12960421410313926625,\n                5538346920487066869,\n                11936724786881105079,\n                4454497098555324939,\n                12124962776483380654,\n                11305627091649666474,\n                11735775105402210825,\n                5333950336526186205,\n                10422103167921191032,\n                14756072429691103006,\n                11750422858083924515,\n                10208182356772880837,\n                10621209043357401646,\n                4390175275014413825,\n                16261941456326475333,\n                164254036716799575,\n                10166844304615487512,\n                6244791849379505525,\n                16078011614750997232,\n                4036318310177585263,\n                14361097783282321656,\n                14585505580965219492,\n                9507822645456572052,\n                4664349727078578430,\n                7052354054958471179,\n                11947092215759110337,\n                13460111811661626699,\n                8994769339012900452,\n                4277387408904797372,\n                8360068307002692900,\n                9310378853432279044,\n                3615902653439898384,\n                5041769760427780496,\n                13410727718700716906,\n                9110797065505590467,\n                11579771720285768750,\n                14285192567240714149,\n                17274599643845366595,\n                17286874018883337370,\n                11454013703351143610,\n                5597926447486120953,\n                13176325654882888793,\n                6313101041421319619,\n                108740634031532815,\n                14905269195276741638,\n                11322366307935514017,\n                16815633528983748913,\n                5882022600736612155,\n                12439189562728364185,\n                4856643353739105379,\n                3954327036570021262,\n                16048674300333666208,\n                15827759856980676596,\n                17069752674814299652,\n                1483637473027207338,\n                6399302372831392528,\n                12543829322110213119,\n                6557398028878481559,\n                3235861062713108609,\n                18114854664282579841,\n                7928121073523092773,\n                11824281386341684618,\n                4613879360523932330,\n                5898762324569966588,\n                427539657478203002,\n                11065231551776559723,\n                429948483707412069,\n                6017279081626619506,\n                1434241201696613539,\n                13441512677683347815,\n                7991819517048182282,\n                7820532433809080051,\n                12291118114411950946,\n                18038050760607761151,\n                11250884854027075924,\n                6536389319007101094,\n                2979526318345262538,\n                958731029266946664,\n                9561847878611512227,\n                4955270217488244180,\n                8692233104356576272,\n                5650399453825682919,\n                5316898078890392808,\n                14204725556732388857,\n                12472296594517129237,\n                114028932859603693,\n                7346441007951279455,\n                2993553390412865590,\n                11214018066767678661,\n                8216551076124430893,\n                9043724174699501024,\n                11187961728062826346,\n                6973801053057154092,\n                3191578252155726184,\n                9278206335605853441,\n                14382261713468120095,\n                15680426048463410266,\n                18309945385029197397,\n                6065510162527225490,\n                3719251193844189251,\n                4582246851961785569,\n                16681448117305890800,\n                2912633942611231941,\n                2429705579928960963,\n                6988351191388166237,\n                11932315913872258577,\n                4931244219942820925,\n                4940928714975771244,\n                5324071194710253709,\n                16277125251573781039,\n                2751637676037259786,\n                10401440256814804764,\n                1307572889759068499,\n                1502250984032475492,\n                7726545925440886045,\n                1656032806662940221,\n                11822218397552301015,\n                2289520846031533964,\n                15490893692267786891,\n                4535934513444611134,\n                17633149417288572702,\n                16874001204471565927,\n                13540306092530783871,\n                4145907438805773709,\n                10871695985794371090,\n                5005301488035997955,\n                13756561158373279308,\n                6896402457870892227,\n                284706874677256937,\n                2580973494286396192,\n                3836219749648256661,\n                15231665013567003561,\n                11612604375066871019,\n                6517307196995501234,\n                8924364917697766089,\n                9984145169861218661,\n                2870524370981372424,\n                3933185181454136636,\n                11977430299213353784,\n                8471957562861313117,\n                2833957102140580373,\n                16977932011524885779,\n                11426873969291870718,\n                16401003021892216560,\n                5223971594004997778,\n                11164273851659337825,\n                15108691663490140242,\n                8946903902462228322,\n                17743480016719743536,\n                11670221545230088109,\n                12173929035160130791,\n                14127233364451534793,\n                5537616024506708066,\n                10990324138102407756,\n                14481409468334196024,\n                14922231597684630782,\n                16012376992552686237,\n                12540288017260078276,\n                2480498301539644183,\n                7472323237010890907,\n                13559737596066548001,\n                6418157844127987707,\n                9864404905640343955,\n                5128898457183887413,\n                3872687913360014460,\n                11423567717750037264,\n                11523574907142504854,\n                14716344991839142571,\n                15831732058740562246,\n                11006715245055274608,\n                1199701175047093182,\n                2149180782602444574,\n                1421128213655392022,\n                8934095049012315045,\n                5459205696187852592,\n                17914269599441710739,\n                1402122902543914213,\n                9044256663261456705,\n                6406909240180604811,\n                1754865501804167107,\n                1761485560842534079,\n                7291671102292596380,\n                12060138754799383202,\n                11472026615302964201,\n                696057073114098665,\n                12629911631647560962,\n                9367347405349590600,\n                85807136927016125,\n                15430213380946414862,\n                12233268548637196687,\n                2140692199223470805,\n                17737335457474117675,\n                14908016691200697723,\n                17804554105716051046,\n                15069742595017583075,\n                12525483225890821211,\n                14837612620041397231,\n                9670067110512761492,\n                17714417835835552983,\n                8428117771878070096,\n                11562484570396319871,\n                10526422333922154544,\n                11615006619466995865,\n                13452572857187284567,\n                1609873102665335578,\n                4879154920235573125,\n                11010206388113931565,\n                4137448431318189276,\n                5968008172826792067,\n                17162550769485448158,\n                13909224795264552514,\n                17630913553694492809,\n                643009131249431123,\n                2207362898923276875,\n                3448854862427882075,\n                7262560717947893240,\n                6058618404810332952,\n                3268497246010872177,\n                11957591260328108638,\n                6125210992988008288,\n                5047137679409695221,\n                12728758876124663989,\n                17029066770181704401,\n                9178379647957568897,\n                15507807900660863525,\n                3292952536722640354,\n                7050459093823182267,\n                12340393048340211547,\n                18336389747399520777,\n                644190587862899283,\n                8023959351238392671,\n                83727676981969748,\n                16584836488540229052,\n                1259432055716651306,\n                7727914358746015216,\n                6448714769369717457,\n                10278960654771263010,\n                15199591652851415939,\n                7062747548846039875,\n                8811388495913321729,\n                2711047781547287895,\n                5401009748431019206,\n                3824967589243349861,\n                1526460623375056008,\n                2465353132172645194,\n                14826396768770243764,\n                10906493952495351160,\n                15460723786729923232,\n                6062815131777206320,\n                1377316900622524996,\n                12800047861216579689,\n                11815332574635611781,\n                6065594571194629340,\n                11254396164654802195,\n                1279831430879743741,\n                17214226290291957102,\n                16983364995788549700,\n                7012924463687489067,\n                2997757160603943396,\n                2417746965176164872,\n                12143030173664736699,\n                11099341012873078843,\n                9272827296180936057,\n                9664025317089888748,\n                5158247874366416013,\n                17037506484977904136,\n                618692057566195685,\n                10784254437015823955,\n                7040574858791904652,\n                6519736019879042146,\n                9770135322632666665,\n                4170596140464934956,\n                6463094379474393805,\n                1072529125484704476,\n                4841056206278251713,\n                739244513488127808,\n                17148076982612194465,\n                8805269968390532559,\n                13887881542261625314,\n                3366926544980853178,\n                10348128422039475858,\n                11820238417797034629,\n                7962099948786351603,\n                14818709100788043938,\n                7534275744141732779,\n                15843587983232353197,\n                16879641327119860831,\n                9445713810238212537,\n                10789773358477883888,\n                11533828394901429930,\n                9295477255768831460,\n                5790856533021606615,\n                8333830111421885632,\n                17773010270819901596,\n                6505758672939126990,\n                7969176850027496505,\n                10938043141814890949,\n                12181594889570146041,\n                401687323080081287,\n                13924025978165151092,\n                15397532958907819783,\n                2056101797584940312,\n                7742931591025575975,\n                11124839955692797850,\n                5114695543398304656,\n                4518298707923922944,\n                16877557778441938008,\n                10976178479860920849,\n                13751444909853634815,\n                9773498238519080356,\n                18135455812086228799,\n                8260614999062789364,\n                1025804710726167431,\n                11580541884499409155,\n                18013675698992726523,\n                6713678418531943563,\n                8186296733002816257,\n                165136842509319808,\n                15267111329319412552,\n                1264019288126808215,\n                18059369012090166399,\n                6858689468954000456,\n                1334489658659607346,\n                9599991333640053082,\n                11701464904365002057,\n                3854923311258700669,\n                13150991028845012172,\n                17021095010246530720,\n                17896123562985460032,\n                14525228140230556154,\n                14025688135222907262,\n                15309551971735811350,\n                6139869695052085053,\n                17086137392089401258,\n                18374020364774510211,\n                1228409558703295466,\n                17984501054878977687,\n                11478733700613093594,\n                9807018845906174394,\n                5116050770904746964,\n                253781193362282034,\n                7977918401840910181,\n                14846046156658368537,\n                18188202868821956474,\n                12345573536400494969,\n                1137168150068290765,\n                1098033166201752795,\n                13979129705387039996,\n                4317707477574981873,\n                3951870491690795715,\n                8980981677896386476,\n                6941778574542064618,\n                18257719818335954529,\n                6566600869588104931,\n                4027201752989399733,\n                2614999819200366970,\n                195374302680629540,\n                5235101844655770717,\n                12318374474018970184,\n                16155186168361195946,\n                16921004739228036228,\n                1020916417531530896,\n                6587653082428756573,\n                15225850526589296014,\n                15576607236338810110,\n                12023054768107002055,\n                1268885256958117097,\n                1387885256395721962,\n                86143020515480382,\n                770859194853623071,\n                12199285654960385502,\n                2671698434115520767,\n                15694823183817751335,\n                5262937970748799529,\n                13165639376314045335,\n                18123748696869614254,\n                1691330945206503377,\n                4344052292378390094,\n                4980806319203410528,\n                3869116687748586797,\n                16959027439001726553,\n                5479329206018608168,\n                14617542496041117010,\n                732506766617530293,\n                9267567674637442447,\n                2895098663207534116,\n                6132091457305790709,\n                11329205076565039645,\n                3761087265440840348,\n                5142445732760231031,\n                13573259145836490154,\n                5065000115155919536,\n                2043805904940961196,\n                9629132978962327986,\n                7244888518089969830,\n                1948921979722125022,\n                3313201915963548230,\n                5757814806871679459,\n                6094552970640076337,\n                1439487867693348435,\n                14417385597401774055,\n                7841792999657658902,\n                3076809775902249639,\n                14814563776238376067,\n                7712812702438315350,\n                898014195199434041,\n                4044248619428358689,\n                7613922997582320177,\n                8490531434165853067,\n                3223592688880474029,\n                7232119155624682394,\n                6370122322792490919,\n                17291986194226706841,\n                9513732286024852726,\n                2707459798290295657,\n                14946966441201639899,\n                8633812368898027351,\n                16683352123811299836,\n                9776364893153619186,\n                2384839478093779221,\n                17952826390389579364,\n                2878951794358881640,\n                13106943397009054942,\n                10962082447119441594,\n                11714960526602107545,\n                18198260212816385861,\n                16638971078900097217,\n                8474088692354411132,\n                3730125342381902288,\n                1920529178255848241,\n                7982008994855916096,\n                10492251611244882579,\n                3045343214341924821,\n                2035230566268106301,\n                3992453840084465649,\n                10103901945422429452,\n                7973222863593860365,\n                18052915162214720421,\n                6926081449378421754,\n                17481391009761975025,\n                770249856887805459,\n                6913840410997136795,\n                14978985291892326303,\n                5700257453542123820,\n                11921413291993075035,\n                1371903176063359325,\n                14184549292918054821,\n                8498988469340843940,\n                12069095114955064545,\n                8255176110717313286,\n                3697699706969730497,\n                7452682375661551542,\n                8499256547722143535,\n                7382594324831597176,\n                8626942486336636315,\n                8956465048555252593,\n                15950113059022757973,\n                10156648759102264717,\n                4395696884234079020,\n                10036245504043971129,\n                5950619280132942479,\n                9168460833348158874,\n                7620387487793767514,\n                9277320833806734008,\n                10382865638416451480,\n                8411739037702301346,\n                15801274139139552145,\n                13692759444960236941,\n                8563292317718588244,\n                10925108551772953001,\n                15308221065571417876,\n                12606519560536496815,\n                1425600522958627644,\n                14974380436528759922,\n                302177378847238152,\n                4334555303983646630,\n                128793880545063465,\n                5507340077141715611,\n                5054619723051255696,\n                12403597630560990351,\n                17073919416859000964,\n                9281887294428457895,\n                1488534379756068778,\n                5568344527998161881,\n                13797501273282457715,\n                4488385602017344411,\n                1553738284126167233,\n                7903010851789823832,\n                1368825049294659792,\n                6765641777280503880,\n                10507216635318096685,\n                8961380496928780667,\n                11241770898792963184,\n                17509492195761274684,\n                7396071766087139346,\n                14251591074268897344,\n                5086964574743594036,\n                4880908160114797331,\n                2235630954691175555,\n                6733752218135280084,\n                11190266532543308203,\n                10541603736673243674,\n                14990593910397068876,\n                2179293842335286944,\n                10941405748298103474,\n                6854075889962691746,\n                17124531760241584071,\n                15375769732150799184,\n                3487279552700733733,\n                8699616349045582587,\n                13163169994678372657,\n                10596180029688151624,\n                4185715526490586672,\n                13678404153576422235,\n                2088615142302400637,\n                16697270157510423652,\n                5487378316758341360,\n                14880501956946456619,\n                3734812580188132853,\n                6979371733875968251,\n                11881343947991552925,\n                10633021967360223399,\n                13491982804411891763,\n                13213376568500536010,\n                2058922053233291267,\n                12881536125287205059,\n                7874132473293104087,\n                2501514450152693578,\n                15171006305203001186,\n                8909432522370667253,\n                18054269355355933961,\n                10313552183455136101,\n                3832848210585996650,\n                4606578973882183018,\n                15049716177665425881,\n                11790008416426702531,\n                7299530752113020112,\n                8569064548093242975,\n                11538333797058080064,\n                16921140284614147784,\n                16062010705605068840,\n                10172456083532452532,\n                5879039819604254641,\n                5844084193748684986,\n                2901572555718625824,\n                3154868065983899039,\n                6079151086118673158,\n                10833945584771699263,\n                7749273335166854823,\n                5714416769361852910,\n                2856733009890239285,\n                861486403877371140,\n                1603264402517455056,\n                6610410755884163844,\n                8741999029695562468,\n                2720140197580685707,\n                195099765755947882,\n                3002292589827409659,\n                7280149689188131074,\n                2642105055100929838,\n                363920280727416429,\n                7155051547275182716,\n                13420734408574626363,\n                3383159474916359167,\n                744815011998384635,\n                4792413897876970982,\n                5872646386592314832,\n                12847609697504088709,\n                11049991000453989924,\n                11778505465529757045,\n                16644096103569552997,\n                13132639218780573483,\n                17735276982649303508,\n                18324604540958855318,\n                13751001906313080019,\n                9280247986707408879,\n                14095442870869494842,\n                9220946755408984076,\n                14175583104563887407,\n                4548175433510589664,\n                12894769826017544143,\n                10391970538224194186,\n                4124450461341175034,\n                18326013397595057116,\n                14639886094494508479,\n                16029721131827725713,\n                4913057860707405985,\n                1342743410006138344,\n                2155851841363094539,\n                5569763813476663528,\n                5610030607420557801,\n                13370015946103513354,\n                16591485597018017373,\n                5090594226365374544,\n                13513116075969985364,\n                5397789496524651749,\n                6325333914758699623,\n                10021901477969961938,\n                4685259496793640922,\n                12660262814582224254,\n                14644990613126766624,\n                10535025267127768113,\n                16118427467518738063,\n                13317378382651159012,\n                15563740596549744348,\n                7217572356154676713,\n                8628546738744453130,\n                2610104798471691778,\n                17619854956884267322,\n                14218126334866390765,\n                16555843983955757581,\n                15263173850242170454,\n                13761500681846019210,\n                17348110822241283702,\n                5502484046183766825,\n                3294179870989894738,\n                12416341159928104426,\n                1999625858621638274,\n                2862266536813639513,\n                12183136020749935755,\n                17897412530693306043,\n                4957686079307409548,\n                16645344857638222138,\n                9643043409865754403,\n                12234909134059228744,\n                6668513591081479096,\n                2342611675640859764,\n                18083178289407029800,\n                7998389929560710048,\n                10851828003425643619,\n                14984495328198583903,\n                8980101809150358094,\n                16524003296347874279,\n                1474933593585755651,\n                5144422401974480352,\n                15712825936980779182,\n                250182768272668706,\n                5121690924796146936,\n                4971458407555002659,\n                11362565773279690951,\n                2836476881889502752,\n                2865560168686439851,\n                38131667576793724,\n                6418143577872873902,\n                12677992079859880769,\n                16657750063059423772,\n                4986738252060260763,\n                10837925372402907062,\n                16150081226348307154,\n                10396350591435006631,\n                13766091613372915604,\n                1549496982697356105,\n                7792502859194314858,\n                12761572613067197764,\n                17049993598526082459,\n                868729278549666045,\n                1615996458243387652,\n                10448645719813456995,\n                14691557604932982497,\n                8513116463021305278,\n                3646034824771746171,\n                16427856941706896762,\n                1478208271091648021,\n                7352097525108907535,\n                4553021145465722797,\n                13739331677419028919,\n                12109675070757452580,\n                11753113013883440201,\n                8034056646251312605,\n                11098667427307970832,\n                12556016254090077813,\n                6818557622115713005,\n                5488462183448755622,\n                12037029063880715057,\n                12387116855729309193,\n                11649941887264343014,\n                17934840540156085492,\n                13484602771387774047,\n                12071971451684572918,\n                12318286660913819142,\n                15000129779756918695,\n                7622652981715917177,\n                1941141261167294069,\n                10066274630204119671,\n                15700113432403355792,\n                6548237200041107746,\n                1317727701078369716,\n                12538601764087511866,\n                13107739114994017632,\n                11329245241925466577,\n                8443732354610441919,\n                16838034729120458983,\n                1295367438438984602,\n                13208644763541494811,\n                10148259094169859404,\n                2977227751878274493,\n                17188840334593079627,\n                283448850202454244,\n                8401837417216766185,\n                4487644930048504532,\n                3156993532811122373,\n                1138015013744168987,\n                5926890760746486500,\n                16264358176148091366,\n                412129087756566499,\n                2611107355404374018,\n                12856972341657392961,\n                3407262884040770992,\n                6837804285766927422,\n                1625957534009986762,\n                18304560731519780849,\n                4651311055214373439,\n                2842766752688257234,\n                4669846989537204528,\n                1150750474478328166,\n                9283219454858343324,\n                9676799940058516485,\n                9535769819821220898,\n                4216118818081696379,\n                7986805549489581730,\n                14868854119363157417,\n                725733410570198205,\n                801999277962258001,\n                13206373632625309059,\n                3760414440586727733,\n                16840016771540534492,\n                9282485457149687215,\n                391660042335454040,\n                89095263622412647,\n                667207475971320549,\n                2435833794203345512,\n                15457776145581912292,\n                1266826669088883628,\n                15972850652875384484,\n                7181604665995622887,\n                10279792397224347447,\n                3646646678644615658,\n                7438918469622920053,\n                3005423819338038989,\n                9214478018440060298,\n                492335584352534986,\n                16634613640494803192,\n                12802460657367498847,\n                17508961995711425056,\n                6430345804738922208,\n                16447927318274766099,\n                5642694475860178585,\n                7676330869648145581,\n                13281876988262423281,\n                12531007649212465595,\n                3098228591464601210,\n                9928444057503016020,\n                10446708652519584832,\n                17663019705237623696,\n                11611354087596473817,\n                7972196754795248838,\n                13883479044827771718,\n                4030336379541805318,\n                14288630327375339473,\n                15336739048455044386,\n                10725470152329451086,\n                4511132777640431631,\n                2104159951384601163,\n                1074648154669597319,\n                12576298471736230338,\n                3988484885384363660,\n                1896565318825047566,\n                2192489736970121614,\n                8208783911084384627,\n                9662313388797282250,\n                4042419181841741058,\n                9436595455667108373,\n                14630397932342980447,\n                7418269832739529622,\n                5582525728087765736,\n                12356259344183898484,\n                14773185212978089317,\n                9021406452090249914,\n                12521835756457456438,\n                13300392157047361944,\n                5786616474159631237,\n                11658990613893617225,\n                3564145209044171749,\n                6176094153853368204,\n                4472077630315691522,\n                669490520051498024,\n                983973593760858360,\n                15439105675344215143,\n                8899845831677639376,\n                5542861433123934028,\n                11219402864556685554,\n                16228880390469218684,\n                3535940373392638788,\n                2388420272100198976,\n                11501553552198346715,\n                4045226064304188825,\n                17164733155110543079,\n                11887602938273783707,\n                2405996419585631660,\n                6313079676993177979,\n                554293591942122383,\n                8111819752396326540,\n                4618132309026710151,\n                16496971100102831766,\n                9051035532500397457,\n                6466496038777077423,\n                15468435833615177307,\n                5940699253740568860,\n                17718623687002183744,\n                7921752055496583008,\n                14083952605798838602,\n                2784508214930637696,\n                827210449935480354,\n                10523898530260576693,\n                17261757252211364439,\n                12435872147459061359,\n                4801120065269861679,\n                4507038720982711353,\n                15022958300666509337,\n                3466195915775756041,\n                17056703437397795899,\n                5032414486866127579,\n                4460407349226646342,\n                17618491294669832989,\n                8342035164337146088,\n                15835140500563133213,\n                12306383136166961273,\n                9311267541528810827,\n                8710163699797239159,\n                10527927593789976089,\n                5023057011324582236,\n                4214395317065013911,\n                1988021212043469334,\n                3308854157275769242,\n                1669821858580911503,\n                1292299602023200349,\n                9999700130597378451,\n                3039603156497167303,\n                17231017483669458025,\n                2459852806047222029,\n                11079756598252700442,\n                10112619658231412747,\n                10770614875273841990,\n                544736197283340750,\n                16580266104210218625,\n                12614455090929871217,\n                2934226079137110511,\n                18004304398447730016,\n                7416717446208912085,\n                12163064049978815111,\n                4893763963938738258,\n                6509354404907597721,\n                6325085281943652570,\n                11984901314521563718,\n                14282973825477465483,\n                5714567012661078960,\n                16772765125071416533,\n                14651207183300066940,\n                10191770239707765729,\n                17149725124332256486,\n                4690209155634308806,\n                8520738959493303734,\n                14561086913064233184,\n                17800760173747167468,\n                14472389034842835414,\n                5403737324129354163,\n                11749701019289937875,\n                4741513798969134715,\n                9780504626937729230,\n                10960003022828004721,\n                15258900429112413542,\n                2262948687031028651,\n                6294928924020932131,\n                7547753650112118891,\n                10823591529909358272,\n                16832354587130586627,\n                14169835747462772759,\n                7309804829255164479,\n                17705713796418377471,\n                10742295753142489586,\n                7600981436366483337,\n                2427395011226258517,\n                10129372736203276174,\n                16753031800552306295,\n                6506489737738421903,\n                18059874435102886761,\n                2976515802180143867,\n                4156942128767398413,\n                13237126584532261028,\n                17008810702460226588,\n                14049267949137828087,\n                8758735846922903749,\n                6793053622933564358,\n                10478083492253714431,\n                12360026616848218195,\n                9291146653661796150,\n                6486933751821767874,\n                6838648905700449976,\n                15421478995275913640,\n                6509001710056253889,\n                4503397806109962463,\n                849610157122863946,\n                9449186064733075333,\n                9425817453208643895,\n                3545405330173226031,\n                5480088929666881749,\n                14998382455517742089,\n                17997091255332462765,\n                6490038724033845598,\n                2615971105626337870,\n                15846937377463844481,\n                9478678072181052774,\n                17198019661862202475,\n                16989872775527902270,\n                12045574565512903232,\n                1535739634699138227,\n                6870369663749928658,\n                14074141003578186155,\n                15341569269191922427,\n                6781073497207583805,\n                16387313021995867490,\n                9528582840408150724,\n                2889351218318895013,\n                8894114255682892490,\n                5362576750886764259,\n                18015538182640548393,\n                15407645145770926246,\n                7675871236873542484,\n                1651147983996178077,\n                17456414881325543882,\n                1481798489266646244,\n                2217203618641967417,\n                10855180092479814444,\n                6598233241408631079,\n                13065611539127026297,\n                3717859246570543785,\n                6729665115064723174,\n                16526117635926672270,\n                17881524254979056029,\n                11726308082414488972,\n                8314224276214531669,\n                18241927651544624528,\n                104200762255380907,\n                3008509790108001982,\n                6145139744234379970,\n                1036038853992424695,\n                1973355598635229002,\n                8570635883412505884,\n                14054581519160169224,\n                1556201076209357948,\n                15943768594544228268,\n                1513155835862984066,\n                4363161143157494144,\n                5820377245820278256,\n                10198361540002917829,\n                767043871261244881,\n                7443956531685316056,\n                9284331333096250621,\n                8935133575787953006,\n                15200652193392659189,\n                8056712435239102863,\n                16756818209019893602,\n                9343226056494439350,\n                3506162196904760966,\n                6260373898356213156,\n                15150209586446889979,\n                2784586581379403342,\n                4540380141065828865,\n                7757418812393030281,\n                8273294732966366961,\n                4727924630469683301,\n                13375618296146569214,\n                3964754111798509444,\n                8123960256194764713,\n                13998712814232413275,\n                1152977784398432330,\n                5890404343588959641,\n                6950895782734829498,\n                5059884094199777410,\n                16597208796982226,\n                718843944856621102,\n                11848918483770063267,\n                12000925027170347107,\n                12597611018517804046,\n                5718998717332312877,\n                8110605227325508456,\n                1985758694665945275,\n                4519633440143326178,\n                13423707213455231658,\n                15784938969952654968,\n                8208544497117553485,\n                9659953713035913903,\n                9321587020770012756,\n                2087882724388865696,\n                15335927353602577288,\n                4885014610259028587,\n                9372743482129951826,\n                6274778247258661234,\n                9634411916626919826,\n                4523001562907364613,\n                15369212986412657667,\n                8840975084897747625,\n                3064783763370957235,\n                1622171395572591443,\n                1400903150821880824,\n                3145798450489825432,\n                3019929935687520943,\n                4514424740291089162,\n                1119017893812439241,\n                235132163998217267,\n                13364228050998359839,\n                4588820876082475911,\n                7195397215200596297,\n                4633351752138300558,\n                1200561772848463895,\n                11999111784877677855,\n                3515014993548986881,\n                7630631031677618724,\n                815843603725414525,\n                15924302202194543354,\n                14763652070709132400,\n                1449365498347098434,\n                4571064241668101422,\n                4292811896359448226,\n                16453846927054309997,\n                426837151166526619,\n                712068857293805334,\n                928449188054083970,\n                8911797645243492493,\n                14891176613544732991,\n                2206577781330260168,\n                9335637607885610626,\n                18392467357634279632,\n                15765389947245465563,\n                17393660415076192986,\n                16085850839645596007,\n                11691058094766112608,\n                2817179822694367327,\n                930444656245579987,\n                3164553527192601352,\n                9174958030450605065,\n                5376840420505663371,\n                11107902395101842683,\n                243984915529749293,\n                5518860592235265115,\n                7615228019861017436,\n                3920891386601626615,\n                13494884915155497444,\n                5294307483393825921,\n                4041905660571667001,\n                1633580366026153454,\n                347906503315428568,\n                7557404877313144124,\n                5267775115526069937,\n                4938397725897039932,\n                15455077922444970484,\n                15549977328403561026,\n                11991859023815693028,\n                2964593792497517781,\n                12853508080092904533,\n                15007139139577959607,\n                14255373463767235095,\n                2167416467128614253,\n                15034193822134529069,\n                15542412129864400355,\n                1739094818789829367,\n                3251355985939667959,\n                6188717326774755165,\n                14676952870412609933,\n                12843647308683490155,\n                12693426455139845275,\n                15441717063571747950,\n                11292965910125324965,\n                18416540647565742265,\n                3644383303581996762,\n                12454603000034434095,\n                17258137073514536075,\n                17035480272282368486,\n                3692027693098460257,\n                13042244040458074122,\n                14593709879345117166,\n                377808174597068792,\n                3910597941335600101,\n                1639206563387626349,\n                17639685993484083333,\n                8341893781740907026,\n                3399482951883713266,\n                9494556199895966229,\n                5477425431243160927,\n                7506325802369160085,\n                13434567653969427228,\n                9137336048227511331,\n                13041587471477288222,\n                6583663533314467526,\n                12733881436954683825,\n                1209367975582170770,\n                12621218467455625922,\n                14529850862267842457,\n                17399463206531788152,\n                13183797877091275002,\n                17218396986893401474,\n                10472885892073183987,\n                3023406489489045870,\n                16368766808557690360,\n                8037618701151923127,\n                6106039970594201131,\n                16602642324869267867,\n                10069277905876386041,\n                10698031878409163893,\n                16317483238809829466,\n                8622589479253013357,\n                8035830134083966202,\n                3466789368751326950,\n                8809822341797077328,\n                16241448642666433623,\n                10634479988374588371,\n                7351366827359208595,\n                15379505454490775443,\n                12524731493685212915,\n                13198010890124456961,\n                10281590580742577462,\n                11815743543936657353,\n                16427825605786290275,\n                5206988116217064154,\n                12698993858793472480,\n                2147098972970774835,\n                10844703842232588345,\n                754149093730464121,\n                15524670084145457365,\n                18442396931289442600,\n                15526194806214575227,\n                11226399258068037952,\n                6803959331859231227,\n                685330062188179512,\n                1667774848728925310,\n                2477557307441249224,\n                9107594310619086447,\n                3467444511657093926,\n                12974103859367141247,\n                16065451317684768653,\n                10424184331911790711,\n                4986897706620920921,\n                16445020967004563083,\n                7110818062157330393,\n                10120806882027715724,\n                13342217923857744053,\n                18119257660241875712,\n                4587748292549759312,\n                13986361365713765580,\n                192845879240337583,\n                17739304337797051346,\n                620118818440128083,\n                1600199803056704504,\n                116046090030718708,\n                14617471831122659266,\n                13943584176529643645,\n                1112657171573544393,\n                7284493486199486007,\n                7309257126821711860,\n                17260473038559056656,\n                13283037481207443666,\n                13665385997096965883,\n                17459542133008358045,\n                8267138424051619797,\n                2799174643161534155,\n                11863012576953080530,\n                1941987460916586134,\n                11943360221741722363,\n                1457715441863528715,\n                277329889242428718,\n                332873825095835194,\n                7501402992688587579,\n                3628806491618898634,\n                7768316150525370308,\n                2993059064858857122,\n                12301993560945128533,\n                2080438918249564342,\n                2720997471111607497,\n                417122196402345872,\n                16746724723643865223,\n                5800623165948012296,\n                7278930935549481211,\n                2205036363744818461,\n                15383578674856097783,\n                17688896809108014274,\n                18091705869385930641,\n                15299584681599895689,\n                14341958767182589412,\n                10793720060741965763,\n                2388709234383191992,\n                13648455390813431619,\n                8099772337498694197,\n                11310861744682595222,\n                11160192519470468011,\n                10509581407755286586,\n                15373404840384875718,\n                7278990844786196949,\n                8794445823871031405,\n                3098191891952046980,\n                10060322354539802633,\n                13823794368891250532,\n                15805011174620089588,\n                16945784220420378289,\n                13590278912550106289,\n                3592661444908880171,\n                15949627482054903045,\n                15772915220982128265,\n                823197668483087459,\n                1618046035248201472,\n                1569590959026390225,\n                14523234633419544388,\n                7961503998156731156,\n                15627835578621440869,\n                3560306887993015418,\n                6938587264408152808,\n                4787752326200843144,\n                611061396208139781,\n                11641518795898305841,\n                8324161177781401618,\n                10938195331294167031,\n                5851054513035129812,\n                8452327800224939966,\n                10446295932308757205,\n                1830073659885394871,\n                3279098048840542481,\n                17221852200905023571,\n                12950231534805229080,\n                14424497750515463186,\n                16733053727953017870,\n                15242696754808178265,\n                14920851384706958163,\n                18041462820381813550,\n                13238602970376315330,\n                13242119968088342859,\n                1733782148141510754,\n                3448505378883116750,\n                8186541718004755311,\n                7131351957647573506,\n                10188018472213724742,\n                2207173121534036106,\n                12108311126599926187,\n                17892207799400411138,\n                17037421531247930480,\n                12734837881320648437,\n                18126534759448645223,\n                4111714275094514509,\n                1439374133237106024,\n                1012729810458125326,\n                16402685735794125514,\n                1123233161750004286,\n                15010675148269385952,\n                17480778429271958342,\n                3110280444394188958,\n                16960074024004555099,\n                7993184340806640318,\n                5297659831179840435,\n                7367988682729477498,\n                7223595458419964146,\n                1214342385239353004,\n                166053549827465408,\n                16044557811456363812,\n                11956833600697072366,\n                1051182785418653279,\n                9036163790930076520,\n                3345291322848864256,\n                3766254070219277594,\n                4838760200219922801,\n                7064061086490458642,\n                9620981472707141322,\n                5372273351861077067,\n                9268560589347317068,\n                11896991449117870670,\n                4658382946972062559,\n                3212925312074794504,\n                7164249051239334466,\n                8982521670287388677,\n                634546871782659835,\n                4439935278560648430,\n                4683860465504567096,\n                9979318036592370962,\n                7944267721914772355,\n                926407151551170175,\n                6024508200551734755,\n                17644513304459109409,\n                4850626730876551878,\n                33742330204515779,\n                16029830391244237919,\n                18008080643688566144,\n                9735662429229401670,\n                7923291891026262232,\n                6492765676679809223,\n                1025380667418959293,\n                12291331628813390780,\n                4725341855921686811,\n                5019192253040683458,\n                12660801616573408431,\n                1798491736202373717,\n                17437116372297300095,\n                1146702207119796755,\n                9906894350724939493,\n                12556294068279879168,\n                3497093078755646243,\n                1351567753016754277,\n                8885792570339545281,\n                7808861980575456833,\n                12029767717793833754,\n                4672046316778539147,\n                2564702071323571812,\n                6195798103971696351,\n                2347332678935385950,\n                16025274631093172152,\n                6479168990306240665,\n                6243316335765688288,\n                10362429540780000581,\n                7993344388745516777,\n                8705452196007240474,\n                1646872239784781861,\n                14684873660364803941,\n                18072288026947543374,\n                13032728012411697150,\n                5299733198726218881,\n                9543973837436721304,\n                6053122207506134689,\n                3762184894933544820,\n                1510406071648488171,\n                12551920471843808738,\n                14226105012742626829,\n                1128399128656388225,\n                1483627947279346866,\n                14290971912789548492,\n                12463964661934070028,\n                5045475485173717018,\n                3152005529915689685,\n                17103568736274868485,\n                4007090876531888128,\n                8405101586358620248,\n                9937473108438343540,\n                17711053794813027962,\n                12507745859403893440,\n                4926600379393247173,\n                13155467843985734527,\n                225903764017035136,\n                12869674224895414149,\n                15563799404524158130,\n                4282732373778923452,\n                14127691149210333754,\n                46164326901096390,\n                4975883363087601606,\n                8969099128924193741,\n                5000052206585316126,\n                2988737475365684150,\n                4599698860941872507,\n                9040350077295174480,\n                13082787420920215972,\n                6390490941315643460,\n                14348441428418931576,\n                16462073567657549099,\n                15235294944329363449,\n                16315523965665762573,\n                41535089398351151,\n                13121765570651988195,\n                3957062665693927028,\n                515254810501965010,\n                14879665755970829216,\n                16127348355184074199,\n                6338785176491350083,\n                1759306290554890386,\n                4370834190411036222,\n                18089616164495715666,\n                285337772631130600,\n                12319821347949750627,\n                9137018167207056578,\n                11281056895414041059,\n                17372813089508340211,\n                16924685014312545226,\n                17454489946335356177,\n                256467995482802999,\n                14100328988579474424,\n                12333254810237747557,\n                9415666686529622384,\n                1047391820973039827,\n                10848706068771908213,\n                14190666472922576499,\n                11873504703487125335,\n                5180672692049675813,\n                18273034321108422712,\n                3535311693005977337,\n                12708395321856074946,\n                2762649881855117229,\n                14926839529439224642,\n                2788951805429568305,\n                11870118452934828734,\n                4432072422779606786,\n                5294568137458580077,\n                12885179771124208318,\n                7579343333299664338,\n                3904402522110232917,\n                12276342431805990716,\n                8408054797774319933,\n                13240467605703131992,\n                4690596374046782281,\n                16154879448100541682,\n                3803119835047337952,\n                7479937186444969041,\n                4857280192679190310,\n                6670727446432380509,\n                10888007857212732752,\n                3502021384983124929,\n                18134159133259661308,\n                12013884292814132123,\n                12511168716026218852,\n                15041763947615035820,\n                1747630449768436369,\n                15325131514659929726,\n                6703539015475553957,\n                14688815588447428768,\n                10368301362442999770,\n                9809572111807556873,\n                4460022268292037165,\n                17526113707193592812,\n                13269588295632932383,\n                4166204288479227423,\n                3216788132331712537,\n                9549163652044355593,\n                9844396548399052183,\n                9335851721631510288,\n                12676650725966656147,\n                18024438749036961622,\n                3131420681891221888,\n                16132675902897404786,\n                581927403140754533,\n                2754324863941832517,\n                9779750278789387154,\n                4297934551052203877,\n                6467356523142796499,\n                8604483201299499224,\n                6337408066829584212,\n                8922053472934621748,\n                8746945597319229662,\n                16971622123220156347,\n                7948504138275600711,\n                17735370366312131433,\n                12008472501734835414,\n                13291204068391603838,\n                8386527531991280088,\n                17133120987291052491,\n                11748772375292182291,\n                13526198700280450226,\n                5899512913956180185,\n                7266411146495216150,\n                13568838290051574266,\n                13033236152930383904,\n                6669538505842883960,\n                8121150499135604883,\n                3269740345166188719,\n                4698936081730974128,\n                9717231797239076687,\n                17953604985799701256,\n                5472963240502563084,\n                12219581918594554057,\n                1177923466299803888,\n                7220225792698698307,\n                6519976584059515440,\n                13257739288133541977,\n                8513973228295541064,\n                4256536311342518055,\n                4545785886955603913,\n                3814357504355962863,\n                2993386207472748670,\n                8742967047711331344,\n                11560801106698134310,\n                15814523315233922232,\n                17857691279016187605,\n                2139948240315287405,\n                4320804512615632576,\n                7825246577951372837,\n                17773549472581094838,\n                622682596523409835,\n                17947133725048078498,\n                8117734638310414299,\n                8796856063250752410,\n                18037619052916271668,\n                5796076881294205295,\n                17023947053361435447,\n                3935346903960768070,\n                374758818957650273,\n                8168050406006071529,\n                8747681807216328314,\n                2657007752847161439,\n                8250697365074967904,\n                3069370441040948847,\n                7251644013243440677,\n                2355591785155253335,\n                9024941558405974070,\n                12587136685658664079,\n                16009856695692496339,\n                15484672303602881469,\n                16147185411186423391,\n                16504884094715062458,\n                13855533029982388925,\n                14890011718100201360,\n                15613513089782136953,\n                8165117711830614628,\n                4152676446900699357,\n                18434519859021475469,\n                12433115243826354337,\n                9262683485290985951,\n                16961215102991701113,\n                13772978727212602545,\n                5439355243959409088,\n                13690835360790820495,\n                2781503970251780784,\n                2018788090954205919,\n                15873736665489401557,\n                1624467943271322534,\n                15397369596002880491,\n                13698210041093480449,\n                7254532444481365829,\n                13938276555872154647,\n                17403299192818230500,\n                17300900391753474342,\n                15823587634602776708,\n                13596982771906664242,\n                16517900074719099164,\n                16550906358301019631,\n                3383582004706444687,\n                6693998219827048243,\n                18175393713039033001,\n                9224838094152519332,\n                1001817119638508260,\n                3851720173551942604,\n                7423100210161735740,\n                601876652081542359,\n                17768598337583788121,\n                11907848480462908240,\n                12879608127741104472,\n                4578043373124941840,\n                3960728812747329208,\n                173270169400073604,\n                9613182110382996262,\n                7261894326870559465,\n                10852334891076958347,\n                10066751330920937418,\n                7410944074347516414,\n                426044005962092514,\n                7393759344960291254,\n                2391601550198502201,\n                11853343544961086987,\n                13309835142317078770,\n                6986670231910860872,\n                4275951483446283108,\n                9688908301648403660,\n                16210576897906400097,\n                14980068656282174480,\n                1481380337930648019,\n                10392181060459099960,\n                8998654262671254388,\n                1787386242116304722,\n                9482249120102287728,\n                4265617223531740693,\n                10442412550271143801,\n                17793897510873343069,\n                17171428856996590182,\n                4692740185767780190,\n                17654375126704136192,\n                11005676982629229590,\n                14284668016441548929,\n                11084952759435237010,\n                17383491326720728908,\n                13790740388217035608,\n                9346913141047548014,\n                9132025420201643264,\n                10994659389442857768,\n                8005151900929388182,\n                12532558397287408182,\n                17630313180856459785,\n                6409786025423439159,\n                3506122461599813718,\n                7980481922086521834,\n                2591953102074452448,\n                676314937024308089,\n                18076449756015982872,\n                2754945238605354977,\n                2697071483018576807,\n                13223028333842558334,\n                9060420454378301609,\n                11012363480529831631,\n                3563329797828938565,\n                4244145017166687325,\n                17767545229430850494,\n                7653249414371803322,\n                14583502847827405892,\n                2526332860421572859,\n                15958037269213558558,\n                4145329928447000171,\n                4471730307350457108,\n                7521251523140417172,\n                3111741595034417435,\n                6099109097781624426,\n                12021508046798894588,\n                5583706685772202433,\n                2602498476004898619,\n                6033589213449407782,\n                1510353808776771211,\n                12987062733178126565,\n                4649295309586282514,\n                11386724881084205105,\n                5412292907152878701,\n                3173705331351537802,\n                18156981629930402970,\n                7575917798563989959,\n                4907029581994779885,\n                2812829259529190584,\n                14887679915597054603,\n                7469589257050081635,\n                4036711473116353822,\n                8064603872881566430,\n                12589744487775628468,\n                3398796853962881829,\n                3272474912442022303,\n                14426577092658762097,\n                11160485656781492599,\n                14202444516205804985,\n                12484027793360908785,\n                17570996928062666601,\n                5502983724724173871,\n                12631809808658632835,\n                2765162484901831182,\n                16096645888581581404,\n                1922580848351658355,\n                3021651210670611456,\n                16725111780432998137,\n                16123666969517859349,\n                6818353363180347143,\n                8654332990526409165,\n                14761396254845316579,\n                2825364801562362844,\n                11688132862347855852,\n                639915178146882300,\n                14458476609976551808,\n                615091437364449676,\n                16965018890552839452,\n                15631632543181545115,\n                10363411110252146444,\n                4641768019598289534,\n                3337717668591499297,\n                4032279587062157033,\n                15715048231061282294,\n                8145342649114088105,\n                11108969196885954454,\n                12952335318953053529,\n                9779828041482081981,\n                2118029380994447880,\n                15543465899762612133,\n                13061358323449031278,\n                11029667414464801594,\n                6444974349348616819,\n                3478478453027033227,\n                11095132347296028965,\n                16622649840533858680,\n                12669350756637290969,\n                7604537880706889554,\n                11075262189205452999,\n                17848568097412720543,\n                4439380568850727902,\n                3050974537077464502,\n                16977762972576641326,\n                3071208956232070758,\n                12006925938232278918,\n                17139387541568045551,\n                1029028403147446993,\n                2531769580835082665,\n                3621299895812654421,\n                15040097540945119746,\n                3126376340493092964,\n                8291155842071126939,\n                14354644429618763676,\n                18174719584505858806,\n                594607486937478873,\n                14712489031452783888,\n                7521992906805861700,\n                7583555445032630784,\n                13540089462881207097,\n                17379778862108738403,\n                7497769788698834249,\n                7271297004671342163,\n                14978947979260447386,\n                1424662641618379589,\n                8177317170008198038,\n                2718664838590272342,\n                16843951979854132263,\n                5497276664118513853,\n                4777262616250457514,\n                16116133946405130506,\n                16384844676068622949,\n                13411539656969890680,\n                3428796555601393402,\n                12678089312746097377,\n                13355076607868992794,\n                730874146974805572,\n                10067155129450460492,\n                14448473196403840735,\n                14633029330581370624,\n                13237745128351506495,\n                4485472252382345363,\n                2464355242470120078,\n                18092330992486483443,\n                1608746660247486309,\n                11240083599284269315,\n                16767129078362415418,\n                12943617255526784891,\n                3387518134947108318,\n                8305964440059804243,\n                10741331734199493966,\n                16447837936971542423,\n                9386581477129031081,\n                5026063376792473825,\n                12951793209262677312,\n                7832228956945548620,\n                10847237584085266730,\n                6744706870591455793,\n                3827795409985050436,\n                13018060898653577737,\n                6897162046534702726,\n                13458224049337953945,\n                8793383525032746872,\n                5551312226569691027,\n                3673957760566517446,\n                16626600182750615858,\n                17964491861666341897,\n                13178253663031001179,\n                1485441606142367144,\n                8849644662345581463,\n                2987934691593642836,\n                17088012223663480541,\n                17805475483517845973,\n                9639648306195237530,\n                16170580609553263987,\n                803975342335625922,\n                16904392454261784475,\n                9496797177347695250,\n                833391991562050799,\n                13884430889601767769,\n                1399425793939971731,\n                9669147101224524506,\n                17387072155956429410,\n                10249368505544998668,\n                3187328726622350900,\n                6284671360870943954,\n                13885730698193800868,\n                13469933597227158867,\n                14865921771049599636,\n                11068384810566085490,\n                6672241429515474633,\n                767656968935235961,\n                1210338046709859412,\n                16266543621320324076,\n                10798914035656813927,\n                15298640884679743932,\n                7961930035371383040,\n                5655258760428371405,\n                9207134073914205902,\n                3899155088446105094,\n                17792259193674587989,\n                17056465744456219235,\n                17400556305547534285,\n                17502188141658577916,\n                7713328388382019919,\n                12940743948688393585,\n                8189438952002546451,\n                3995778812000715687,\n                357189510436862907,\n                10327019172184332971,\n                14115342301650128694,\n                3659816433284350278,\n                9242045595803247672,\n                492084308509986910,\n                15296058780201622957,\n                4103716578320155935,\n                10609017886137134648,\n                7303352787746979366,\n                7200863092744824049,\n                10946162431970607069,\n                4793907825411597748,\n                17221676203534711732,\n                2123197280153264437,\n                4490336379513946223,\n                4079195848999035957,\n                13897303357999428987,\n                14778990894625188190,\n                8832366364673069085,\n                11688078750300240334,\n                10156403777309085466,\n                16152060316096929112,\n                946073018639738029,\n                15824837400050099984,\n                2331032097341716793,\n                11749726278180048513,\n                3493980882668221181,\n                8553314938842944784,\n                16555546863807027494,\n                11342451878441368651,\n                14909271131547230374,\n                17753212539966711022,\n                13932914662177669490,\n                2244037794914221969,\n                2738235439278475922,\n                7976219997349009523,\n                1678514278278786584,\n                17601058859440730415,\n                9603606579608208382,\n                8462945328050541329,\n                4730866709237902283,\n                12093039977452908967,\n                4666928052580836,\n                5497566805220777041,\n                185606854266135538,\n                3679620669313527839,\n                24082693554547233,\n                6497385575924244039,\n                8003599111831814113,\n                5378003049550960090,\n                13602896386178353774,\n                17343085835266212821,\n                4284151436028780416,\n                7031446591435174981,\n                296161209152974819,\n                7771211154626084447,\n                4993504749934625200,\n                15899899719762915665,\n                5631006189516911547,\n                1520210104263088378,\n                13336691969159614550,\n                10099472222145463563,\n                11102134333522810275,\n                799973464581554812,\n                16696483008544375857,\n                17275688158593400457,\n                2830651348456776191,\n                8561640222838341065,\n                5927394439969190339,\n                14337331167814987197,\n                873195269832328729,\n                10951208197954893562,\n                7598038760248036011,\n                15571273667787969162,\n                642437384453728307,\n                1612201519235672377,\n                15088059640392686686,\n                3897575791527764359,\n                14088243142182984912,\n                7208032776641816649,\n                3392467592234537679,\n                18350133499320297696,\n                1370369301534692051,\n                14089000100660650199,\n                16590033024664363954,\n                4613841140259143121,\n                10948486091338489900,\n                4964486316614010566,\n                6108814066080624107,\n                3859061645497262242,\n                9929624355021227122,\n                12365087599218259369,\n                15261320050004905408,\n                10030282029223356088,\n                17465432443125294698,\n                15509237629421161755,\n                6721571464751422812,\n                9988866795627150958,\n                9033182163187335985,\n                1230513633149349464,\n                13410037090215851236,\n                13603148167465525942,\n                1399048741732778865,\n                11894863627095856395,\n                17097126701091498247,\n                5245820012173399473,\n                12943311619865068894,\n                11559376495772265397,\n                9907178558214704197,\n                8132388361641008943,\n                17479358858237055639,\n                17077092513540945380,\n                7575912724941868395,\n                12868244636613777199,\n                2843721422029125246,\n                8631483452718287224,\n                3937771687411430627,\n                7612340530213420538,\n                1632411560207547096,\n                6525956156749130644,\n                17879324930415147455,\n                13410977357394242798,\n                1264859501683143391,\n                3442427426804895011,\n                12339413920929722852,\n                14426536401657755097,\n                14407457523472832287,\n                12420904904723916214,\n                1585794846933417175,\n                6456440328717299525,\n                8226929716358767328,\n                11691968347019298064,\n                775237360506581246,\n                5688999584721067020,\n                6844977392207370769,\n                15974212211191916835,\n                7823063632945856633,\n                3556177597887157798,\n                1628753509556845069,\n                8358138361138028910,\n                4310772800450676148,\n                6922068004317423878,\n                42506053333018259,\n                14399301946228750816,\n                14858506531945257576,\n                467244703551498310,\n                2963637344649884754,\n                10869474233465961041,\n                5147667463265701371,\n                7468505150411182449,\n                6272164769594196577,\n                901090327063162984,\n                10381620034549723834,\n                15251473191487258386,\n                12240031983677035483,\n                130619789232430555,\n                4297037685308237307,\n                9095722555999267001,\n                15376634175844006339,\n                17930955480543244718,\n                2703287302620414018,\n                15765274054265256230,\n                18086736165397226303,\n                18406756160722155315,\n                1253540830332662609,\n                485808894919515873,\n                2048130977076397386,\n                2211553136252184297,\n                3254983787536093233,\n                3225583789107672981,\n                3465700358331572457,\n                13545956631613345610,\n                11257013535203093534,\n                3768554384420572178,\n                17680666510495636538,\n                18019613346842663244,\n                13683650661788039959,\n                3216837734679454344,\n                599768182346543780,\n                15351694834892667012,\n                1989348249687823498,\n                4435586676023744436,\n                10538276361095224243,\n                7775108989585178791,\n                3399671890568400507,\n                10057867644642888093,\n                4843149402449929834,\n                13835572318041555367,\n                8800852406641485791,\n                17112320859664463142,\n                14107454142887771966,\n                4598011239748494911,\n                16306487158209555886,\n                1660471658317783506,\n                6265159083777451463,\n                4979661182937870423,\n                15911077141382206186,\n                10583937503792622212,\n                12821209672436063125,\n                13379314410757060073,\n                5547367267265196321,\n                9327146685831728398,\n                18343093688835768900,\n                13747314782052591056,\n                16807537949609050821,\n                12285613541024393213,\n                4564567329408377827,\n                7114033999707759968,\n                9007070389230522756,\n                1867939081541596499,\n                9685628885188241199,\n                15449816836858405320,\n                2661580061957725400,\n                7930747809049799646,\n                4149580420032760508,\n                17666438595093585267,\n                5460007779168649058,\n                17356675974936286646,\n                15319285063623010739,\n                11241268155457616020,\n                4212136860213643757,\n                1241257408276375839,\n                11619927894746062143,\n                3420590129249181844,\n                3886069937736406626,\n                2771257278182062305,\n                7178241026728422387,\n                8023976869179869730,\n                2904198768396340875,\n                4399558450402160924,\n                17165664237884954143,\n                12428535955846507119,\n                7834234463575808440,\n                6170468324715467941,\n                3611715647217579735,\n                2689775469310725956,\n                17517019791755178778,\n                17399427211266158886,\n                12539486999876025945,\n                16610972628254475501,\n                5160685735427131095,\n                1053071193335831220,\n                11929205402515419489,\n                10683398745150878784,\n                406114136790304455,\n                10043508860585031939,\n                10476972703627940622,\n                13484157494360196101,\n                14639106592106172749,\n                5758975570569287489,\n                7797640411499256285,\n                7281315207961356340,\n                1919799239293125324,\n                13642360166378290156,\n                12575445858832217792,\n                7132983665440037868,\n                6587252534464540637,\n                5391820394707043889,\n                16664606660343981947,\n                6061927195190257111,\n                12868301027775621989,\n                13168068866547789098,\n                1318345134529141398,\n                11266663603744656734,\n                4582221915587287234,\n                6723933983842182249,\n                6062860569105782282,\n                4727183021972063171,\n                5284120009497525474,\n                6778511295287344467,\n                4843206337225340637,\n                10767518182754239836,\n                1548354626042658549,\n                9001977408058927195,\n                7217754508542745498,\n                15631458265402110530,\n                13864685302379111891,\n                13535152488792849972,\n                11818782599083369311,\n                9603495527061931870,\n                8839167499196567295,\n                16088151549556216066,\n                13482887515416292649,\n                2513999180838980773,\n                15608057147429203582,\n                4794774913131833975,\n                17638371484885917448,\n                8144969168948411819,\n                13965388907240272982,\n                7687647619807877867,\n                4350345813816806479,\n                10023434507930578747,\n                8532518202219247949,\n                5980099969372155816,\n                5518220377115813619,\n                15561231086992162674,\n                11915431750339478980,\n                7706791213665021310,\n                9583355955406832508,\n                6170148717887590541,\n                17259131867922972451,\n                17080151529684503270,\n                16753756347299773085,\n                5964302397539577181,\n                12333452998338138196,\n                8851688937286092339,\n                3768586873607448488,\n                14916498919739535270,\n                7999154263564268888,\n                809923163071843452,\n                18421613792137973831,\n                1312941051093419403,\n                2445381438822735841,\n                11098134972538191779,\n                17967301096450664820,\n                13824050126159561263,\n                4064030765568052261,\n                6477672197006089054,\n                13527512461763806053,\n                2111605512594216638,\n                4574411455434392685,\n                10008363457929914105,\n                2489430936389265730,\n                524855035488230515,\n                7683228374472821228,\n                2310156754124388214,\n                8169531515270404587,\n                7551208252532540509,\n                5657512663784848001,\n                9635095312974401841,\n                16164453424602712406,\n                1454360776919925351,\n                16083748669010295668,\n                8005759396488668651,\n                9955164538215072318,\n                14108427416365096821,\n                5846260207310163761,\n                11589992900467052107,\n                1185661327558100149,\n                6083166426747148447,\n                10113993265216780324,\n                4418653805692064053,\n                17645291308565297881,\n                18157338316165172541,\n                5844729449876416186,\n                17457426784643091435,\n                8780375001861987411,\n                8024301087269372033,\n                10726363838890861487,\n                4665112162461249412,\n                5691641309040964849,\n                1089361550193688438,\n                6657252921262118708,\n                9613139752297579353,\n                9206659400878617274,\n                10061109165927950517,\n                5006740993929657062,\n                18017091661979372068,\n                3038725011112820302,\n                14286878314162804516,\n                3711478827511187211,\n                7399329339103807107,\n                3277843147503059037,\n                1214589757545642577,\n                2641130110405329075,\n                2310964301861955557,\n                17244270578204744223,\n                8615488285531158010,\n                12395000459712064924,\n                10986585300186870432,\n                17798076680461624991,\n                10366363964870504746,\n                2595530900609161113,\n                489845555863713198,\n                6909196170366930243,\n                1338615857388008510,\n                4122435222372546696,\n                17914347855138707201,\n                252991105939933990,\n                2228648829562493492,\n                18130878113557923510,\n                3794528427945329583,\n                16570231967757063017,\n                10982257444688527431,\n                6215019330326783857,\n                0,\n            ],\n            true,\n        );\n        // - x_high || y_high in limbs_half_gcd_matrix_adjust\n        test(\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                255,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18442240474082181120,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                8796093022207,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073675997184,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                268435455,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                4611686018427387903,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                4611686018427387903,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[3],\n            &[\n                2515001291402742141,\n                854420613834689431,\n                11039020760595827143,\n                6756568413549859118,\n                2136202424706040178,\n                14816339433745171807,\n                5979726425609054965,\n                17860763079996696285,\n                6137842758941809619,\n                16208311820416030796,\n                18420476178176474797,\n                2134933733929182961,\n                9646501134892720916,\n                1462076564527020674,\n                15145739517548143307,\n                17085395263023945148,\n                8286583684341088741,\n                3343151313427310229,\n                2575901666292279126,\n                6307558616370235581,\n                82586436666909222,\n                4828590655561120997,\n                5416657653621327806,\n                981277938279968645,\n                13261936915909041036,\n                2650518741132171629,\n                6246594792539184293,\n                17110677893222712596,\n                17080932936076115432,\n                10710018177426387786,\n                8319370182836017772,\n                54644844274267615,\n                10338588040015641008,\n                12314370078315829535,\n                30985249843116621,\n                5860983927537346563,\n                7300274990782092627,\n                1032465354725755342,\n                17918827441796904950,\n                948266268839213404,\n                14080050351370841785,\n                11154163051991817178,\n                8418568617568650378,\n                2931808994425212696,\n                14520755666422248554,\n                17879225383639426345,\n                1389350041568104293,\n                18418682222614156823,\n                3626912026478935225,\n                13691264771654640536,\n                2957609324705255103,\n                2504324778887164565,\n                540648196212357210,\n                819771208764003611,\n                13207260621640142174,\n                4225979564410740502,\n                17350218361613991007,\n                6134528954232718156,\n                7854153205633315907,\n                13395593586288016536,\n                15762316148952715379,\n                7694036610128122312,\n                328606494635430301,\n                13668443390964500027,\n                15891607328268609015,\n                14158365113256769142,\n                11181404893930872837,\n                3991260254355359695,\n                9396572444676943517,\n                17014475636467042721,\n                7000393941432237072,\n                8150349275162771166,\n                4631170617920477010,\n                6635544524720191779,\n                9908920515828101594,\n                5300702252992372600,\n                7510566684982239474,\n                108286438156484504,\n                4824190781658509967,\n                12581692589316752185,\n                11159838221811848616,\n                14968542183549253374,\n                17084948808360591461,\n                8191412738586448292,\n                15677020614935285837,\n                5215581678572586933,\n                353723820169197428,\n                16978751111369553172,\n                12772558029276683127,\n                12483628181661652345,\n                10439703577672350134,\n                9784945668944849304,\n                18318385882830590471,\n                10688587052076496763,\n                8699671510172701755,\n                13565813105517860139,\n                16641955038793794044,\n                1571349497717409374,\n                10044316396998302601,\n                12550672299534617062,\n                11227013398790037661,\n                13301296643867969379,\n                10812643949960334215,\n                5799004776816415978,\n                986124572499604435,\n                3026735939923394639,\n                18035239152455536425,\n                2821484567968768351,\n                6772748663092767963,\n                3349352749986649667,\n                15771700017042457091,\n                2812228100793983087,\n                8966593753220735997,\n                2813400646060206620,\n                9851206416208153804,\n                1746798591540633790,\n                15069296932125882874,\n                16531718734480334277,\n                16910413985181271676,\n                2793840408495526000,\n                448987935536301546,\n                14569625030330502514,\n                6065214866412927214,\n                17232757532354239812,\n                13829286547109138523,\n                2921754733414082261,\n                13303248667654369031,\n                3891969494180421122,\n                18167594588298270036,\n                13498114336686627178,\n                5851530730899716960,\n                4946353268947078458,\n                2144332232832247414,\n                9916272042008669847,\n                12426238636657392056,\n                4522343502857098731,\n                5264233711902098449,\n                3954779775408830813,\n                10152975213010389931,\n                15213008065604787974,\n                11906788830806904419,\n                13727551850222869623,\n                5581774594200415894,\n                3138893663025062097,\n                14227501657171208008,\n                2659407144214370141,\n                2470566155700025775,\n                5963582299596013003,\n                13476546953720331658,\n                5938042981535304450,\n                11568592500582515672,\n                17163862660310846968,\n                12049485632173014393,\n                30540173088117290,\n                17274458890463538297,\n                12797745934375629964,\n                5221784094376183558,\n                12887507818248264743,\n                3073813380843058717,\n                1938915953226043327,\n                6215200949568404039,\n                17293727619435885814,\n                17350499520763989487,\n                12296292807324796485,\n                9330319810635756213,\n                9867294643968220409,\n                12999888684556283098,\n                15586741203686585657,\n                3585691735603878541,\n                111047201349693111,\n                3532536732335552811,\n                9506597734466317004,\n                11078033442850698018,\n                10310334087676638489,\n                17519738454843726681,\n                1504580147682249334,\n                5740967789031283951,\n                16239711638006293914,\n                7081767932694792480,\n                2507705597412670155,\n                6743492328845447866,\n                13311574418396928678,\n                17077677532004370398,\n                535518464752018831,\n                73839616593119839,\n                10885240189395538812,\n                880676260073339171,\n                14555785395122230436,\n                990634367782179525,\n                3690893067528551893,\n                18134732819841678250,\n                152075761421318941,\n                643324364968596914,\n                2707944766236889072,\n                2446246525023988921,\n                8941720554917641159,\n                13298063652766245912,\n                15693609475952662965,\n                16218869215244787608,\n                4935920149548733196,\n                12147665972107143149,\n                16986769241359478623,\n                15970562718750671008,\n                11637849485926271203,\n                814178805403427365,\n                9973952093046043725,\n                13501264880263037297,\n                10349630860648909346,\n                7464255681522686521,\n                12871076891447140204,\n                7394689874210043674,\n                16300276938237421544,\n                14728438677586311805,\n                3359535383018364674,\n                4127781846509358372,\n                5741600339581174212,\n                13244497569979557385,\n                3782350829137505339,\n                5625990115735138668,\n                14895478463059224740,\n                13994624425384882290,\n                8186538127184846054,\n                2675760749528318059,\n                11677806371436173648,\n                257446551006261452,\n                7961448079232066398,\n                10306944304325243729,\n                5528847959046042995,\n                8040444385105100306,\n                7525704557088309836,\n                17549739621208763668,\n                13680452064407681517,\n                7178228674544011471,\n                5619710811438216228,\n                3607399530780455118,\n                5538141615865239620,\n                18226947480498324562,\n                14230448756606521728,\n                17876036637709099183,\n                5688793892421081608,\n                933530647226902936,\n                15258158162113456871,\n                5297315348809380891,\n                10586605564572500962,\n                3503963101907878240,\n                14289878178522832568,\n                17165985800898060484,\n                12853979216315383732,\n                7404472913193394806,\n                13913202037589418363,\n                11634222484170875844,\n                3026266052863507538,\n                13399280110778987507,\n                17627931264441141608,\n                6071499774479067879,\n                15110650858167631937,\n                11382084799343456884,\n                9504750370497627769,\n                13033616890871910192,\n                17729168561253698166,\n                466743073658850858,\n                17764316323418014434,\n                4998604969161617284,\n                13549279412875167315,\n                9296269997641019870,\n                9166595675043755174,\n                10529988328854732328,\n                7144041704891627420,\n                16361003346086079235,\n                9943807039687895557,\n                7046383518941749496,\n                12722671227372792947,\n                1779562253292504764,\n                12537820465345260220,\n                2614462454272293083,\n                14193120596701917762,\n                10780905727513177031,\n                1374415829793928097,\n                6748734894530971729,\n                15928220926843157001,\n                5535675968257661756,\n                1525840979353320984,\n                18122227845708966132,\n                7230720160297300530,\n                6852396017866833011,\n                6266552900448780761,\n                8828036573065632414,\n                668473016918889641,\n                8276491790393950978,\n                7279053552529835886,\n                9804715513235295735,\n                16434777317288501672,\n                5678310437624346546,\n                12396952033434667150,\n                2768090263379613177,\n                7572255419503115756,\n                10194149750863488419,\n                547740606870280321,\n                1868734200889842633,\n                12291540836011261895,\n                4086473465988937851,\n                2246345386624277202,\n                8725515398399179464,\n                12296543879285572534,\n                13915669807663935494,\n                17799835982674024419,\n                16234795638068414452,\n                5041839365397131364,\n                3116481237710138732,\n                7007209678955587212,\n                15484085310618002551,\n                12384347212382933526,\n                10731365408680754607,\n                7979224485340689000,\n                11682000340934638914,\n                7715146871166213069,\n                18004937464958667759,\n                8767958691288745734,\n                4384543045398316360,\n                3485127456363678341,\n                7128262331077171193,\n                13284990951702615619,\n                1452484727870755752,\n                17111341335049135767,\n                476002247405406477,\n                7146493491496444929,\n                13990600380366933983,\n                10496666477640843438,\n                6465434602120964021,\n                1103336350096377287,\n                8596287640450410898,\n                16738742077912987000,\n                5486092722515814573,\n                9391966854232607555,\n                2924901822237211905,\n                5111802913982387368,\n                15205738951038958336,\n                4696051498319690013,\n                14568233460671228033,\n                15625721869732171151,\n                17104653160814902481,\n                1221691498953690384,\n                2602902073875174288,\n                12802595970918777252,\n                11308198298413908437,\n                12431376153828579139,\n                3896128004167757830,\n                1759145605331852061,\n                3364680692104667476,\n                6392746910923337863,\n                14634448362305139043,\n                1059936506490182404,\n                18384038961084523528,\n                15307337632849520847,\n                5057750764679452628,\n                3105851082659899174,\n                4308041544222906525,\n                15191230344446017934,\n                18373321560647226542,\n                2919731949711530505,\n                10727119707982269723,\n                6190766667049366265,\n                4000897272982517177,\n                16089676642731055439,\n                14119628184550513593,\n                2006134976415861124,\n                3698544745472959784,\n                14481017188550498866,\n                14155887862378761376,\n                5842886212661624997,\n                16238887906885634399,\n                7835107379437844190,\n                4240679714676942653,\n                9864798697895861741,\n                2654889426506129056,\n                2443750612854924475,\n                3050756945961331983,\n                7730619795125910161,\n                915197777412081303,\n                4993690451949388914,\n                17632803739051902073,\n                5230703765105447969,\n                10177762924482276703,\n                18425135642721773802,\n                7047081536552732930,\n                5347536594056270854,\n                2633293018784451184,\n                7466111061656128094,\n                6420112623715945624,\n                5823698284278701868,\n                17953979574630844601,\n                3021282477843919237,\n                15119256823961490651,\n                15965505077327397485,\n                9877099833369183988,\n                18144349252100197236,\n                13157507941120467158,\n                13464212874985038180,\n                9504795610281513916,\n                1703591669233958042,\n                15650479956261780549,\n                5217281837497790894,\n                2078962277648208560,\n                7678727969347867092,\n                12682511819801310331,\n                7956802483950223219,\n                6875858131074550350,\n                16436613901290988133,\n                3794223136758377105,\n                14658822450166390225,\n                13017728987867106711,\n                7155247879359864457,\n                7965517847318671916,\n                522339382271833929,\n                17465238844685474394,\n                1818095920916760722,\n                12863182984416729310,\n                15409235235254242938,\n                37651504890804797,\n                12090214519410624135,\n                9935022871661094477,\n                13620229379418906699,\n                6249121756195807709,\n                791826603140909652,\n                3771084435754642155,\n                6319295620210998713,\n                1210757004298517716,\n                5517177838368090815,\n                15883102636645032206,\n                1012083124214994601,\n                9499143535129292111,\n                10067482779956600392,\n                15334057071623629003,\n                17298012274184577575,\n                5893650809269089241,\n                11626975905507353664,\n                1466731847162385960,\n                12417063392373210363,\n                10865945396821522088,\n                13198490943208480126,\n                13483622688756049446,\n                1066515323059661003,\n                15013161421243860218,\n                1771721670141859352,\n                855202711094875600,\n                6982928918038238124,\n                17068464697542898752,\n                787760719502861608,\n                246796619611468344,\n                215178779923359289,\n                4745058650198919472,\n                11056535399601364354,\n                8570138833315993558,\n                2043113223559066060,\n                13925275147217350542,\n                4749445102592224230,\n                8046472464363712176,\n                8807717763949288182,\n                12370494318644096180,\n                12670824172342933514,\n                15474395937397955519,\n                6444038014380761529,\n                17984464511410020727,\n                7063661334184573121,\n                8384633981109339188,\n                1393964766359295732,\n                5592842941053003601,\n                17430502775035661619,\n                4093755182167319381,\n                15608931425653503688,\n                17881325231794873601,\n                7390221156748691812,\n                2934084929295527733,\n                4518943364478494442,\n                15444554029548285996,\n                1106395487294911879,\n                2327338137505958123,\n                2377315771703720407,\n                15797000292931323115,\n                16113097742465596201,\n                7934236897987641139,\n                7116627593084442219,\n                7110521353828111764,\n                5968499948739939245,\n                18062722304252905252,\n                4704635294771488780,\n                8620494853070890873,\n                17386359699766399821,\n                9455163570109053432,\n                802647262668548585,\n                8981375779157233557,\n                1180623229659042175,\n                11621638083573431795,\n                6206508153262567322,\n                425948179895758977,\n                17034149675322907190,\n                15469737557795513008,\n                8762441777319685671,\n                1474432004999733987,\n                12493767938524031150,\n                1616342227776059029,\n                9474016112144497150,\n                13451807583447437677,\n                17510689659266049272,\n                11335563229002520488,\n                13793961974769287831,\n                16340429251575608769,\n                13292831858541393641,\n                2246818338971190262,\n                9878804687053045429,\n                12174826839542241856,\n                11118437124370748137,\n                12662817975396705529,\n                4145154758820420093,\n                17506617245101781983,\n                18138019040323987912,\n                8037383931308538554,\n                13130844879143696846,\n                11507881769800396112,\n                12313177391611223505,\n                4133773647679987553,\n                15563992181215663625,\n                8179779096123962923,\n                1216215279641195710,\n                8006702878066821179,\n                3334877862737012203,\n                3681401992292006334,\n                10549528370291796939,\n                2455409770316887322,\n                18371511937477382343,\n                15671614306759003925,\n                5214943663849407047,\n                18019664708706320088,\n                13627796185555316860,\n                11381831881829304807,\n                10313921141263578021,\n                6340963035203353121,\n                16989136496655750259,\n                8303662035865456265,\n                14841434918510827739,\n                13510657559389555107,\n                4747690424585188835,\n                3264163299674819924,\n                15096799417767492567,\n                17282031138576733123,\n                14719148755565244732,\n                13238320462169256357,\n                6747272587453298508,\n                13407725450570859624,\n                8203939948942345615,\n                786981056301196136,\n                14820419160799021571,\n                11448664349898477068,\n                7042304000127893534,\n                14895196209378473293,\n                13556163463336956506,\n                8622797343804615812,\n                14962622149215497881,\n                12231195146261802261,\n                4037799004974128959,\n                10895854889815810142,\n                5862802978616392012,\n                16844593706102362476,\n                12049789751324972243,\n                16893233259205437203,\n                13078288919529193926,\n                13946925587670565896,\n                1696596771385869382,\n                14070087665755371969,\n                3504929149575661201,\n                650588081987055591,\n                1849929156722191555,\n                10169160434034851215,\n                12447143612128801280,\n                6971967466031659071,\n                12810267986621425573,\n                11503214623483139309,\n                13110106711526222489,\n                18415764155594451641,\n                16856391804960268797,\n                6432728590161040269,\n                458784258357986814,\n                3224916599861516196,\n                4933037293710291204,\n                5638412326890009907,\n                9772005446547314323,\n                8200609863563573442,\n                10153178348513441694,\n                12134352733435333826,\n                3857162135298749717,\n                16227936124983595744,\n                14513727546361656534,\n                8583116838139674427,\n                17743031726736986394,\n                14110212125866090996,\n                8119106921974863718,\n                6225571996480263370,\n                2609337420315491288,\n                10516746392251636366,\n                15751915882435849159,\n                12483067544808116829,\n                1485652270032314803,\n                18311102530070418113,\n                8719450882587331208,\n                5553122267530249160,\n                2145920356165283996,\n                376978604376728991,\n                5672211522473036947,\n                5809254138632877473,\n                15153594272521870586,\n                1391673376708207090,\n                11423004622685819622,\n                18258959003506130710,\n                13613945546585665525,\n                4164749841720685135,\n                16571156176323775872,\n                11514039312048340292,\n                16155396173582622202,\n                17463725357964465212,\n                9184887395633443106,\n                13020029065881558512,\n                4942506926631582664,\n                16381045959201045589,\n                2106362836831948837,\n                12261161563699997010,\n                3947431246524753362,\n                17733471504322404071,\n                12286793252521616564,\n                6426220193144082621,\n                6947292739247733270,\n                11641057623708737282,\n                1322566685850015235,\n                15427224547857483209,\n                10016146846058307328,\n                3792978918426301133,\n                13304198151150388704,\n                10871657560529690675,\n                7179906814714163649,\n                7374362796928293622,\n                2220654016555180380,\n                11389139868700680742,\n                7807019663885318404,\n                9484925769603602711,\n                11931166942211373205,\n                12987559998400499815,\n                2993067006370734831,\n                15016376717666102550,\n                17724776981081606278,\n                15024614106401594703,\n                12336690208537854392,\n                5778612453669957143,\n                2914324590910553322,\n                1277143230814707196,\n                2411642454892953157,\n                17281298722756218929,\n                16260366008209366749,\n                5565586386404272938,\n                4435223658689854575,\n                9529550531014416,\n                3351867128828304393,\n                4560011016724032524,\n                9043424316421809350,\n                15837033487214224743,\n                11244859892602225290,\n                6834184957643434845,\n                9817412346858656960,\n                13676148928799976439,\n                8927334960637906275,\n                7518996774367520636,\n                5390270987862064933,\n                11888476837807808325,\n                13038912368901074882,\n                1929750137522667001,\n                10493945861592226388,\n                1205816297639347798,\n                16656017435467115354,\n                11862277687543658465,\n                16162338227952735598,\n                1846247801505420043,\n                11081597879978960856,\n                11029588866050905290,\n                16331000228856041725,\n                6933067536224583387,\n                14460933722873690843,\n                13362400988688028331,\n                4849640302737666445,\n                634757368798041041,\n                668693994058214887,\n                13702501766399245617,\n                4926369712576722934,\n                6378768149720874710,\n                6263888538011175835,\n                11106611436976763157,\n                3279430840294884881,\n                3809900877678530864,\n                11180590846261231348,\n                3561936376824286124,\n                5320983168820213119,\n                17583037133221783618,\n                1740588168669989923,\n                883855664743217711,\n                13527896816865391372,\n                17665956710316912297,\n                12228013318526264324,\n                14133831831179373911,\n                2743541888235700854,\n                978178954210294260,\n                8864340359148715893,\n                14019636027423379701,\n                2478210586996267925,\n                13522083140148984575,\n                16800404428561425370,\n                12131307908060979527,\n                4053103291376911672,\n                711384950201301929,\n                15241925078196143736,\n                13615239229147362421,\n                18423149255950976551,\n                6736017045802041716,\n                15664777527200425750,\n                12726921588094239882,\n                13852811095163412373,\n                5402201901281053490,\n                17929368853880302775,\n                1043323482801391585,\n                2499131487827857634,\n                17283221477703939976,\n                10871484974950159601,\n                2873394744290477627,\n                16674121765230014396,\n                14686151691619646864,\n                10923716745368347429,\n                13535885537432572323,\n                9886781372817521461,\n                1908144129995508302,\n                8614283914638637190,\n                9877729515991275153,\n                7229536295127001600,\n                7593406000449141890,\n                2330387904526182713,\n                14554050992341215823,\n                17084528578795238428,\n                7467265620977732102,\n                10371131499453119314,\n                6489294400536453489,\n                8003181381972406766,\n                8991233424749683730,\n                13222810618849642581,\n                5138341903426323813,\n                4621812142883961480,\n                17220249279314560954,\n                18370376338489383808,\n                2121454475874851695,\n                7292384979495486428,\n                12451859669059432139,\n                17005116503985692572,\n                15923887364736082190,\n                9741040868077231452,\n                9287307062186394601,\n                5276119823106920204,\n                4332299501988583036,\n                59429114366007149,\n                16055723554462734342,\n                15383076468565012810,\n                4336335395667289482,\n                10147983307882841907,\n                16304864533239932099,\n                16502972388644867399,\n                10048792028018429564,\n                15830567447633935220,\n                12909672717119212257,\n                13836473249028475447,\n                10273644770906048389,\n                13788356665950330782,\n                1707937150769909860,\n                4493067460049015536,\n                12693543858340204651,\n                4884772311435918990,\n                553385166831159301,\n                5274955907770780927,\n                2411800679320271599,\n                14178853531475327882,\n                8613133194082393096,\n                18220883512350630771,\n                18378054362351620143,\n                8127790493380643851,\n                7823830353485168333,\n                14586153800473533889,\n                6822514383395850618,\n                2589830795463718924,\n                8279858441672078294,\n                17396935117984044209,\n                17345788727688123714,\n                18351439089509717106,\n                14538543373326411710,\n                10396908224065911949,\n                13338978934446505793,\n                18313701688577710077,\n                16293563596460502099,\n                5730554990853211898,\n                7344386183726263182,\n                5184494300197764987,\n                17385718390641642556,\n                15700751405525322963,\n                5242201705194534975,\n                14831963366354935921,\n                15440693243366151289,\n                12068397107522921875,\n                12379624965637155049,\n                7651137481027798367,\n                10519679814338694702,\n                13733165732395488595,\n                13516802141996347129,\n                17506600274430688719,\n                3977477974911304010,\n                17877588986976054126,\n                15198589821998017010,\n                6077336913323725455,\n                5888658105251434685,\n                5958596416011299696,\n                2265856881346294191,\n                6465474878629275174,\n                12960151298655211819,\n                14876269269667052818,\n                16949705866062378238,\n                1460194160657425487,\n                14905284933093808706,\n                320370970420919442,\n                2858279891147207173,\n                16744820089976252400,\n                11038610998540477411,\n                12880439103074226901,\n                468981031211522553,\n                7508448318407368493,\n                8699031766472587398,\n                6347767978817287861,\n                17930797297509649848,\n                9844232056995521492,\n                10563017446095284703,\n                14177667692198975142,\n                16022970984583323636,\n                11729917614716953215,\n                5470991142379430611,\n                16519181592859327617,\n                16218214856346114420,\n                18186543820910153675,\n                3636166537466120786,\n                15361868400737807631,\n                58232580730402134,\n                4421434451592010614,\n                17771650290281880613,\n                16725846289913759833,\n                6523114594721655826,\n                13281393051091272965,\n                16482766403877211829,\n                1120665891566488363,\n                9423655761882537812,\n                4337313589373653909,\n                5619532470612393939,\n                3145715311210082224,\n                309557327092666823,\n                691075480884455205,\n                13170281640773069653,\n                4723554535449281167,\n                1867239505027672548,\n                1966431821400460860,\n                5177035529985006486,\n                13295648982205641188,\n                3817457344931950490,\n                2747064579001556418,\n                17104865812966545020,\n                7533200625109842590,\n                387134316653880241,\n                6695213147717592539,\n                3480369320010043121,\n                8634306672090942752,\n                10876805862404750662,\n                8676104055203724461,\n                11203164490585546350,\n                1434200188233611420,\n                2785883103715267889,\n                6268988508718431362,\n                1064864703151248481,\n                14583487175209956210,\n                17729173451243854288,\n                5638564896294884528,\n                6743768267045183973,\n                2710040265691230729,\n                15184406458994826425,\n                13142446436271228553,\n                12307500358371189897,\n                18045877569178129751,\n                11688277226610063498,\n                1395376112399516882,\n                4454781974294348951,\n                6398527639583479461,\n                12700137666635334939,\n                1313564223084004481,\n                8610599465532839289,\n                4080635225085571400,\n                16420676167679215208,\n                2513207328953160534,\n                10668954077397322782,\n                4305500819258312889,\n                13305015432166052623,\n                614088297254355642,\n                4071991968555173348,\n                2424395969401947628,\n                5381967489801823734,\n                13487375359018757578,\n                7838485949831319679,\n                18261302325099872988,\n                13281138566888854873,\n                1626217206074679834,\n                9386517865001236267,\n                6394473794258772168,\n                1201319982566981136,\n                11686378161425758880,\n                15853921274264793290,\n                10501105997420093691,\n                5319645284327825889,\n                9765963311056990259,\n                17077237164338316373,\n                5436751834627583088,\n                9040607447642471003,\n                15653939325437140812,\n                17660435209356079888,\n                4457604051578661526,\n                15885560556170182150,\n                1253251786546623035,\n                14873695397158863333,\n                5475831779502532820,\n                1739158307586912378,\n                7583695389236158180,\n                6192072175290089941,\n                4548649192267893250,\n                13649910683736986507,\n                1161819030542120347,\n                4420774647848510287,\n                17077149490728643378,\n                1657996450079810595,\n                9319425350407785256,\n                4504012284927128498,\n                7582713871139686563,\n                12084023229443220890,\n                12164387696540997240,\n                7104554354286539588,\n                7207756866534235178,\n                390030225406167015,\n                3044361583650602672,\n                12149268747999208591,\n                12403060843805545823,\n                9076338743083943637,\n                13370910250573748381,\n                12723144068139098703,\n                12383397832265476334,\n                3763610445407784540,\n                537511732463380955,\n                9133848270180885437,\n                7320300043438524570,\n                17884842967962779547,\n                2769066184110596305,\n                9016076870552304313,\n                16184696582130341704,\n                11615845055468105752,\n                1117304977957955843,\n                3693196379049358550,\n                14044062327095135822,\n                15795337425181710374,\n                10462348800142411127,\n                9996758688467879440,\n                17421964866607841564,\n                3175335366202798914,\n                17449138142485208572,\n                9805829195827408715,\n                10468542820318207455,\n                16177197826794610802,\n                6181362590501631518,\n                2124068883298087208,\n                247367958403628271,\n                2372366957433359846,\n                1695132931060001133,\n                6164391294309833361,\n                64663675256179300,\n                11557588651043857059,\n                14587134744505040865,\n                9114710405134229156,\n                3510606399464550426,\n                1743434973047649583,\n                13366042950828121008,\n                1509124301373416132,\n                16764474142924931816,\n                7110340253305365916,\n                16147986363433013053,\n                4906616039461634982,\n                17722338746846189937,\n                7031554771986944232,\n                11375877284248183451,\n                4001259763077681142,\n                3728383667644750458,\n                16069914496245153304,\n                9341845011074192066,\n                7629257426543503158,\n                11291059329299977140,\n                726211393725385413,\n                1980253097495525816,\n                11064505416132925136,\n                7925519815715815327,\n                13863781109281331936,\n                5389442125722254058,\n                17138511222519768234,\n                5804924297336654018,\n                6348919933707702880,\n                8164519969547439976,\n                5241570656254779757,\n                6638454643300708218,\n                14104198925773079339,\n                868055213396551514,\n                16808838493536747687,\n                15739397852572719983,\n                12763965506592626933,\n                6481852598507148753,\n                16887649107647827020,\n                8909752446027296716,\n                9664272216574653900,\n                7029326684912627559,\n                4410637660270574429,\n                18171744024888831544,\n                15589209566844927401,\n                8572838356098210445,\n                1002894101529664561,\n                12448972282950506812,\n                12109591013980103320,\n                14753471218059627686,\n                4611455272318570281,\n                2222782975178834005,\n                5005342132682509292,\n                11657849844203324022,\n                12050666096059869804,\n                4659492679271987741,\n                14931245896443346747,\n                2139983811541781725,\n                16084326278814208310,\n                8789983356354886921,\n                6666290577816260839,\n                17778958944836481462,\n                5002924097135734193,\n                6639214290496917576,\n                555202190923605886,\n                1906584755795216755,\n                9283828365983077290,\n                4635216157403995891,\n                11478860109902514888,\n                6819845410379307110,\n                4903762642991040707,\n                10399594149641024654,\n                16091159693062065407,\n                17640149989785297150,\n                10019776964298776287,\n                13152955796527646838,\n                9023339539227756670,\n                17467726694216589144,\n                7479030676030757371,\n                3131106677233082700,\n                1526295300257181071,\n                18247240124634767683,\n                12993466218079650323,\n                12770945267118729042,\n                4324960674102949940,\n                4458028041066435410,\n                11125067996360148925,\n                6246177566999997987,\n                12265378476572004320,\n                18120427643132058360,\n                3295141820497992342,\n                18202623225686951473,\n                6249772977581501532,\n                13320873145304469837,\n                11791952748164924379,\n                10294102429543166000,\n                11469337705392103067,\n                711334877449512339,\n                14224951446850982692,\n                6996297868920347279,\n                4511503545127977307,\n                11428118344834629264,\n                18297179477826106040,\n                17646353842338150831,\n                13671110980064914264,\n                11851552485973603782,\n                1066732520686157810,\n                4264959023279443858,\n                12784690586746327673,\n                331700500761748402,\n                10634602570342502550,\n                12705759435340278246,\n                197559533053287738,\n                5790905675666544160,\n                14559323930359023019,\n                10168056191608291394,\n                8469865687764748976,\n                5807710907522869034,\n                6155991700771100165,\n                4813888405585473244,\n                7354992806522927697,\n                17144270287872715638,\n                11591562526757417686,\n                5729892916794623347,\n                2484312878306509716,\n                17051569757193435701,\n                4269678769245487813,\n                306644384864157586,\n                7968443033438304205,\n                2887633885939912221,\n                2748493552715807039,\n                1615335327048478088,\n                10006917269263164470,\n                1268928268884465335,\n                2024284360938964975,\n                10269257250047717731,\n                17572217995947717243,\n                899984848746623928,\n                13714824776884095214,\n                13982497664886023533,\n                2915279402212207490,\n                1427211981304978097,\n                5109119376509951772,\n                4782899418354964393,\n                8219440134860918793,\n                18073944328002211956,\n                11591057268516089089,\n                18281133770656996690,\n                15542053463085377943,\n                8306755400628159081,\n                12720964388751174925,\n                8315237200656295943,\n                15792283567846089634,\n                12259971141270073831,\n                1751772640819723419,\n                14361349416869685270,\n                13703661671230315684,\n                732308317562759883,\n                542088073203739381,\n                10182637241455920165,\n                2450123856702709326,\n                6585820828774621156,\n                9091773130662137397,\n                15903509652202794073,\n                2580247163893445885,\n                5445561102333903653,\n                14728770027890355194,\n                16053806323041146000,\n                7333012193888736046,\n                18129090936047093950,\n                9469627704339179549,\n                2514858183302989638,\n                13751604744034622139,\n                691011265923886767,\n                6722126760852552815,\n                2615396821608088909,\n                2402770843551098083,\n                15057441181434869747,\n                8267284207720283271,\n                14045078736841505930,\n                7023176877104670866,\n                2465478386294433911,\n                10931902401373117903,\n                2096584880933803006,\n                12434049572052797831,\n                4095103484823948194,\n                16900548245752732148,\n                10567780520197611476,\n                1588652019451817404,\n                7640026991163147257,\n                17018948230786291724,\n                4882085518985090204,\n                4732629495956171265,\n                5251362635290772306,\n                1162856488427388640,\n                10050314133279871352,\n                15979172975837662186,\n                10452708099005791218,\n                8164431510325330646,\n                15966596978004857041,\n                1768047579017921401,\n                17182877298710730793,\n                9232635109907326699,\n                3233836244248744028,\n                3742579069164385108,\n                13149581049169737533,\n                14306708069460415147,\n                14261961778628813934,\n                10761516721924690271,\n                18324268268253686319,\n                2701816801863213274,\n                12607677693654033429,\n                12497910122479699809,\n                8600979099960919197,\n                9887983342592952834,\n                585741923663487108,\n                8736554544652962175,\n                12496638444187586088,\n                6843918325624016192,\n                15390950310770663214,\n                16328857335961363784,\n                6497141978978653003,\n                9512813350685746938,\n                7381308653385117819,\n                6989449401305836430,\n                14117027662053934074,\n                17622545260249553820,\n                17691938506164480588,\n                2733037860583718306,\n                1768166115637405052,\n                16901475573141191754,\n                10447593195229927574,\n                6570249206928994706,\n                8383930355787788217,\n                3395181838551168764,\n                10743213969491008175,\n                8321207301725795382,\n                3811470836827875186,\n                1253693353280624114,\n                2267669678985667417,\n                8774537139024787382,\n                1941313376450516756,\n                11539214566830300998,\n                10173732441935399623,\n                15560794992773525533,\n                13831868012912319578,\n                1535267024957994897,\n                11354906930263963264,\n                6004337559798380427,\n                10416008011036712856,\n                5998325195889004736,\n                12049120205423599397,\n                11864336868929480796,\n                13867933383425955856,\n                18247665060104625905,\n                14290137640730504472,\n                296413631388457505,\n                15477932055973215581,\n                3219305508054546546,\n                13249156662241663181,\n                17748041842466462268,\n                16810207447839738565,\n                5233887209586580723,\n                8604749809320254505,\n                6346688219143701739,\n                15836474120869883497,\n                14402339910625700148,\n                4005479838887410638,\n                14341958600162769140,\n                6086506098398557049,\n                5183875457229035643,\n                5052329760288184636,\n                15672017676245854801,\n                6467939817719469463,\n                16419835770517321290,\n                15872993232864737319,\n                3801117759053043883,\n                17249592862637031158,\n                11506237310501662383,\n                946057480719444507,\n                7247933928220480121,\n                8836628154035093259,\n                7491323203406751196,\n                2055067657963297458,\n                16314696752463674690,\n                11753904836092730401,\n                8242617865337722940,\n                13103156419834699947,\n                1674595314038372899,\n                11546729184974721935,\n                17008340376328356977,\n                17019306230317931411,\n                331965197024552644,\n                18057296070972683538,\n                4401751254592429722,\n                11171342315201387111,\n                17674848504785510396,\n                3476546872703590279,\n                12590641241781275478,\n                5028351869821596009,\n                6736890726908322125,\n                10057143593243048001,\n                17989298325083994464,\n                12097938229471744170,\n                2694143631170362134,\n                15355527081523462234,\n                12257826206242171599,\n                16655492895464947739,\n                9365856149251993166,\n                13547900257399139314,\n                1627818568517554584,\n                10133304924492875149,\n                18074916321590806559,\n                3042159546484328950,\n                16864898996457431371,\n                10017074950495504491,\n                11635657652211224399,\n                8730172234639076345,\n                17949990698017225794,\n                13505243465904932922,\n                17012173736815684173,\n                11607434340252196249,\n                15351042857703640064,\n                15976552654179018599,\n                9059881157827397374,\n                5489495552742669102,\n                17474805334518846459,\n                9931111719569706470,\n                16687788330467547587,\n                13023920214754731024,\n                18377162237118002883,\n                1005609682301417341,\n                7802654138731775151,\n                13801687162897800057,\n                9477319527505843492,\n                1220847322375676065,\n                3544072477095293028,\n                5222690874449684718,\n                682645379058438222,\n                14431934482103782163,\n                14672201492986023261,\n                11244316269152966893,\n                10157295901888189805,\n                15953537037945376830,\n                11945945444907003832,\n                12730361236674352722,\n                17958650141410421012,\n                6162560113355379561,\n                17981594347195083829,\n                13015393920110391907,\n                1698663270779280202,\n                1974726965676640750,\n                7027988304859124181,\n                16534814642504300097,\n                17577748268099038287,\n                14873573909100745537,\n                2718247919794438252,\n                9767645849367821308,\n                4424671581975295981,\n                1594908807275063217,\n                14213430608695304644,\n                1539495542021484928,\n                7983929030851536201,\n                13787217531285446874,\n                14106895738477166399,\n                4702727572615649671,\n                7887778585587939328,\n                1830987756939994292,\n                14351814450897504803,\n                10605141271196984101,\n                10021693838372338202,\n                858494216928196352,\n                12704544021080890322,\n                3297972477241318260,\n                13644515069733001722,\n                15594022823426520712,\n                8742875502718056393,\n                10966036217936525052,\n                11550626313340401925,\n                4140886717484686575,\n                6572187662349356233,\n                5483362840358692700,\n                18242544725369541122,\n                6431286756407979372,\n                3035903235595609827,\n                5853217611737969253,\n                13644220257500304744,\n                10848624307514546444,\n                17250712209344446229,\n                893317990939302355,\n                13994565153977368729,\n                4483260791808769144,\n                13967481393480842186,\n                1226496844816404142,\n                7836446202870707208,\n                2589554945045136623,\n                1473239823031110948,\n                15502086729624411461,\n                7151015290753221343,\n                13904325826714152011,\n                7116295506272082710,\n                17325628574845106404,\n                5618443576510946670,\n                9926155212668147452,\n                3494955217698800870,\n                7735404764194703679,\n                6486041726831620030,\n                2921576690244010685,\n                7913446190610943743,\n                8069982549034129595,\n                13615160897497718442,\n                3206525310916223883,\n                10337161370019503678,\n                9418362316042839429,\n                1343449678358882486,\n                2485272006767584561,\n                3463133281486754438,\n                14762319158904676062,\n                11608703099935814517,\n                6040895804344857155,\n                1916100797052361631,\n                10836367455173159550,\n                8421069469273746808,\n                42758744991666431,\n                9980255051281087572,\n                15776338626023931626,\n                11674488032580756220,\n                7857825703702437799,\n                13087345831504893933,\n                13436891231109251849,\n                2277312332838299819,\n                1884729449070239871,\n                3388888339357489789,\n                11486925060155251805,\n                18199013885083131459,\n                11871716622616964499,\n                18413905714293555516,\n                11096368277816629190,\n                10487461828696364453,\n                14698582381427357827,\n                5966818095265464638,\n                16590080959627864680,\n                4665946687834090881,\n                18351541705759007326,\n                13516620690203788542,\n                4012239856889635890,\n                12529168935151928045,\n                10651740022343900846,\n                14798647082288231349,\n                16265301445664953609,\n                14725558145401739596,\n                4382649460436336904,\n                7773047458743487467,\n                11979125331882349714,\n                9000238148327613219,\n                18295290675788721875,\n                2914799643701042561,\n                1216075308319805711,\n                2416632093699289211,\n                16878877178334976624,\n                17386965148353835750,\n                11499932301030857125,\n                13714714323296213362,\n                12772072059696863529,\n                18279267952019317536,\n                4915355418689594342,\n                15565939457843054354,\n                10703825488641735673,\n                4485946847474345224,\n                6200445842656420295,\n                17739055698631942745,\n                6698159437409604579,\n                10306192568952172837,\n                2262187032854957120,\n                17085393967977758173,\n                9663392210762758876,\n                9180883428350697004,\n                1356299310683971895,\n                12119332688607271638,\n                2589348634573352497,\n                13217357434834148566,\n                8984549409768341639,\n                8053051170625489008,\n                2992761396737634547,\n                7389660559374485564,\n                5335747850892359506,\n                16099918398517293767,\n                9569320656094517230,\n                1401588637902105091,\n                12191649493498875622,\n                1268322210870561533,\n                17463304952723735167,\n                13893168950727729813,\n                11302851151488679912,\n                1572907331509703731,\n                7983905557511536547,\n                1443247665625874613,\n                17488980868184992673,\n                9589343083211045929,\n                8226463193531541548,\n                8317142415248683382,\n                10668689618531552443,\n                10925748625878201207,\n                2755689456654047283,\n                14814154528249494695,\n                360426969469058288,\n                13552224868036462873,\n                9152635562602226966,\n                1827448246054496370,\n                516268798028709288,\n                5164887411146695677,\n                5108531696699282353,\n                10163085058919700871,\n                5195709678361021690,\n                6927711623015799404,\n                10126226022374014767,\n                8362634427915575441,\n                16488667289280115309,\n                6298197803457595448,\n                10871823233649585612,\n                8089440322305859439,\n                16235273238777296227,\n                10557460853800241770,\n                7766320564989824109,\n                7852071482019744053,\n                8690572403558001062,\n                9941541025712297752,\n                15998254373070112010,\n                15081714657886839424,\n                15185033584926799929,\n                6268264385514519419,\n                15788611920315865027,\n                8161172680964199644,\n                15029778178674506536,\n                13938206641136902225,\n                17961678397477118975,\n                12626368307855840694,\n                17605426670316034685,\n                4079393182514997713,\n                12702669529883350280,\n                8792885437258065206,\n                4898770386310743994,\n                8183108892911708376,\n                9410755321843997365,\n                1428121854605213388,\n                10543202978546689375,\n                17297434777400707846,\n                16069287131716537913,\n                2127573267393321073,\n                6275485943101037846,\n                17693562170448017776,\n                2641176285234151264,\n                13727592881310575371,\n                9898531095295696331,\n                4527791778418376936,\n                13977477636481780556,\n                1335119049062954770,\n                14733815080412582939,\n                2792185556309817260,\n                1177775690814244206,\n                15184431170493354830,\n                15488298453275225512,\n                17951089858115154609,\n                3388497802780001089,\n                9454698276958531217,\n                2557451230621741573,\n                17093029488146499318,\n                13450942206973315555,\n                12147070395527835,\n                4726470054593536796,\n                12596554881342530968,\n                4660430264092530452,\n                686599603731750948,\n                4103973267144621277,\n                8392218014453523651,\n                9680634981575008947,\n                2383091101841159554,\n                689551045294137239,\n                12108831248236854284,\n                4755786229450275834,\n                17355725370483969119,\n                2449563179852044511,\n                8549699882415582647,\n                9969569853887854624,\n                2156443791404023935,\n                666020200687112927,\n                11345632395159494981,\n                9654186900483857594,\n                3754125146540439407,\n                4664262430114282546,\n                6438026076108589763,\n                15024182917100054826,\n                2959578856570772381,\n                9799617572819763390,\n                15226177450710180009,\n                11716015302806391886,\n                12568331176650972027,\n                17170130236480363247,\n                14602128289074376768,\n                12620803195024204728,\n                4279592762733123058,\n                2546168472614599040,\n                5367039617284753414,\n                2944161051537973279,\n                10452752616167548701,\n                12422456152463887602,\n                2377215183411524801,\n                15040474219925479810,\n                16550041584131598281,\n                18395524689854611039,\n                13360480998188672474,\n                11419198807921962789,\n                10335111336352245471,\n                11135075744240285661,\n                10688249198263722394,\n                15428273449001923267,\n                6900957395454868598,\n                2641719371700640225,\n                17821918784214268701,\n                5546115436914850632,\n                17575504853647190088,\n                1895383559608928876,\n                17451482626019754164,\n                827767814317232288,\n                7795988622693306556,\n                15913670401599393330,\n                4260501096442485671,\n                5500286428869433618,\n                3656967577741137659,\n                10876909627820165674,\n                12014475667506704453,\n                12644687203306840163,\n                15527533353811003868,\n                6782165186471928912,\n                12833844674143628685,\n                12287888738170986794,\n                6750633161695866785,\n                6502384995651976530,\n                5691627495978205678,\n                12282138833123754462,\n                951684251514906056,\n                2676827337473763149,\n                5651032487027370650,\n                10317884252370823764,\n                14180022930931217626,\n                18371166438102163717,\n                17949838183249854899,\n                18045212799073717666,\n                17865891574493228559,\n                10589748710520668930,\n                6108251715119331162,\n                1997744906266875067,\n                7722627043158497033,\n                6843914242192678624,\n                7089480134810514471,\n                7910655100432631670,\n                7356986596203549841,\n                1017302610519091310,\n                6135339454032388199,\n                4584853782183684914,\n                18145250460720150634,\n                13456681415955879104,\n                17959310712198629194,\n                8262370079635518591,\n                9129773941441313870,\n                13492638159724456425,\n                16712223353038417146,\n                18429755306802579506,\n                5004531147310074765,\n                10234353991821631974,\n                5844406031776740414,\n                10891116973398461367,\n                11234937854329256927,\n                8807491177843391259,\n                16169195622306930273,\n                685667514278736120,\n                15443691253132530766,\n                5148853626298138559,\n                14042321497049403088,\n                4575537677436329612,\n                9080158806615481977,\n                12344760731075881203,\n                16615807852476536800,\n                13076850880099004478,\n                6635208725942342282,\n                10988721896810464058,\n                7081800602755356036,\n                12198887776815344120,\n                5060069320503715993,\n                17889890666635871149,\n                3403246532832959625,\n                10279919248721834259,\n                946672354098566055,\n                15426852245120708179,\n                9218010203958060038,\n                14394878370635074331,\n                2034320435005053895,\n                18216177347609412418,\n                479416409275315350,\n                16566805486174263867,\n                13207625451141530337,\n                15182242405141216237,\n                13295508645753596575,\n                17467630368571635526,\n                1229183237675045188,\n                5797456475832344152,\n                11709109467479260788,\n                7660135615077800856,\n                1333273646913149485,\n                11727288283866874886,\n                15815969532567585784,\n                15869757936255176724,\n                12370598362160235167,\n                14258783772170797521,\n                17917941786619918024,\n                16726605088253440824,\n                14813410438710887063,\n                50038849583098496,\n                17740645152281120155,\n                5309439396710080285,\n                3610986888154294470,\n                13338414464724903172,\n                12543037668143456237,\n                18364920562577944123,\n                14929054351197662597,\n                6789627103011330358,\n                4258098936481392294,\n                18161589582043031948,\n                9938007296833840995,\n                10080003489028335523,\n                11163404721965160503,\n                8561848816443387177,\n                4408220715833913781,\n                14590367358965455760,\n                10438642851610329493,\n                9276391605648693565,\n                17538235423081182124,\n                677895694694285966,\n                3747388757489477642,\n                5016980456267171322,\n                12593231220724356494,\n                1453382565549732227,\n                14486778507544392309,\n                13005636717826905832,\n                7734063902739306578,\n                12294529312969714466,\n                17864380130764224982,\n                3824062162912226448,\n                15045628103798816311,\n                17997632444227085407,\n                7287934410895597570,\n                16856720652090360735,\n                12254213686554664876,\n                9001356487241376278,\n                5687227347843954389,\n                2032485274623659150,\n                2380223130904738730,\n                13173436303450476006,\n                6696431373479280964,\n                9220284150057321065,\n                4025804818801098669,\n                5800084260213432321,\n                14025999890678919831,\n                10245696946707126693,\n                17648876148364679235,\n                1611415031483345712,\n                12966576446262869655,\n                147785670415286737,\n                9116192315476937298,\n                17338351935897431736,\n                9265863717624874614,\n                4235011690366298002,\n                463373234157965326,\n                14141619466658627731,\n                246532360524953765,\n                13606022891448264382,\n                10178139364174851885,\n                2494560827576649714,\n                15984825820325558192,\n                2144655353025684706,\n                14215513064738032459,\n                9762590622238425005,\n                3330122025064378209,\n                15018349400806757472,\n                11521616236145417844,\n                17604907448224384006,\n                5329681146136677644,\n                9043949155386668189,\n                7091376406886828660,\n                17199401079985710720,\n                14586782375608012851,\n                16952934176672022001,\n                15446929413389095640,\n                9407353556937371905,\n                2342657837633359776,\n                15307615161338488132,\n                8868186885670877974,\n                6170194821563734064,\n                12471282804749921526,\n                17655276352015409298,\n                13142605243800327213,\n                7313683268395293173,\n                9053955665803502525,\n                8254298709040851972,\n                1392252389689462878,\n                2047311284981390295,\n                5370730727424045368,\n                1003579048248220272,\n                13623050024541824562,\n                2747869603491587322,\n                18011995124616088090,\n                12489879745711260410,\n                5716263864607163560,\n                16493129586312826761,\n                4252860335617561536,\n                13534378467988441394,\n                11641986757695145565,\n                7764596020985369741,\n                15527473536748620700,\n                11065830314361559754,\n                3383722340332864679,\n                650077073233988148,\n                8542034465356044586,\n                15930442680489272465,\n                2672993857465915002,\n                6074860910883570648,\n                17225929086546788498,\n                7944492553855124647,\n                6981081770961263762,\n                15314780993506676828,\n                14428863566721175483,\n                13619375644602366102,\n                7197152481918005013,\n                17679875741231746998,\n                298283916735204473,\n                15669083776507206817,\n                8387259617627304831,\n                12246039993039527160,\n                9134365349018270683,\n                6396470644083685896,\n                4151613355909304150,\n                4650271524050972739,\n                4010285478839376965,\n                8980904275601015648,\n                12914926074912656585,\n                1420918868209717362,\n                5793362247641412564,\n                9432237333808527185,\n                3608072678916598220,\n                1508876331560526220,\n                15486092742499189208,\n                12468755918640089260,\n                12487415071967422089,\n                14975564713496643639,\n                717766782015419948,\n                4583011795677391833,\n                10431434081342684717,\n                18029062858736553760,\n                3551855154784497868,\n                4526239048891581831,\n                4729648150089414468,\n                15181665415415784231,\n                5138160418781584082,\n                3210943746159263229,\n                13875588919377441555,\n                7636147787150944567,\n                9735153169744120003,\n                7305448201529921527,\n                537487794215265611,\n                5100275075877624391,\n                16825130346999769619,\n                12149893255312799615,\n                4369968394379189971,\n                341441244658381973,\n                17746623334144800723,\n                4828926439203311160,\n                13603182757410567154,\n                2258457473598484044,\n                6352248869084350746,\n                6577304939567299631,\n                10435461896848223157,\n                18096985801785355758,\n                7537055197691054100,\n                8160940963020890456,\n                8435945022001866973,\n                15979457103453824205,\n                1957679621424407064,\n                9898206090357423391,\n                7817909936371509840,\n                15374813993316015934,\n                6355307985498980347,\n                12010588404057067424,\n                14123879852935100031,\n                9539167801680744322,\n                16560643173108608893,\n                8066719645353494954,\n                4787914433366516790,\n                5850355167699461761,\n                10006197759326785084,\n                7221221895720610267,\n                17344463526023172265,\n                3433134768528219218,\n                16265872547547573454,\n                12191343693464144610,\n                950845942272347997,\n                12313934626496120402,\n                7229818459140965650,\n                15614134223481457326,\n                10135456210398935451,\n                1090950758040588071,\n                8398476328725605015,\n                1355715495963912428,\n                6209376685976295259,\n                9005656041398321671,\n                15711691060211237759,\n                10277523831267480163,\n                11727876656662293206,\n                8831726166908190426,\n                11753502413658091110,\n                4847097836558222325,\n                15188918346803566330,\n                164642710349652400,\n                3874955979128701671,\n                3707475388488560944,\n                118680436172075180,\n                7470475059247484621,\n                3061899480186353128,\n                15105738822866170631,\n                4046374500253195601,\n                10730158779855605159,\n                10327922912359031388,\n                3666932828820205380,\n                18441140066247343935,\n                12466963136852511347,\n                1915861432256793979,\n                9665076161272512931,\n                4493168219425349192,\n                16027633592936849830,\n                10780076764340573842,\n                4901746694797429872,\n                10217087161152212157,\n                1434598235505982653,\n                14550581226985699668,\n                2909012021870260820,\n                2221506302851566864,\n                13447840706384344678,\n                10248839259740437433,\n                17148581724332029152,\n                10680087368083151445,\n                15330100753786539014,\n                6013383871585679385,\n                17804337498670019839,\n                9981371635421549402,\n                9533383178727980755,\n                6040305839260194285,\n                11083436435213010826,\n                10506549280675880980,\n                13365451453979725478,\n                14918618948396614143,\n                11909181115630743637,\n                2396227035301473824,\n                1816854220174599080,\n                11217296410329195900,\n                14660609603695548267,\n                6379797494015156334,\n                11928359345306576400,\n                754903689907011506,\n                2126809552235524519,\n                1897824169321318449,\n                4555354446738162080,\n                12705285348910480062,\n                11012890672300310420,\n                15057491630550073824,\n                8180696341523981966,\n                16843862420462057274,\n                13646428529391265551,\n                6049347760995938113,\n                4404151806756096491,\n                11541667245907179008,\n                9212878996484513769,\n                8481200654014318835,\n                584556822495344359,\n                2537575096305976911,\n                17707346432087076478,\n                15455807035829085598,\n                12775927255815911352,\n                16448248038909958718,\n                94831719398223066,\n                18311020152278458654,\n                8920015673225800959,\n                11659763938924054460,\n                16932805802351878200,\n                7365528043625539981,\n                9390008014084423569,\n                9974482441079471271,\n                6035819913252177259,\n                11510958473146499088,\n                4870159695137832294,\n                6439409922899588111,\n                7122868728045601213,\n                485458708547870160,\n                8099181092193537055,\n                7782471347343769188,\n                11002149757998176658,\n                9851550671388336221,\n                1849343516837040542,\n                15913275140760853917,\n                17453111596066830490,\n                17872400777819557230,\n                13178231050590716912,\n                8853687323839933453,\n                11396093957564100717,\n                5964438257532151962,\n                2299747606127114042,\n                10692649258171410241,\n                8850207100951095431,\n                12718888898304797427,\n                2582561174483856810,\n                12881679014607433351,\n                5401259815482563621,\n                16636234862554946288,\n                2675281638042591442,\n                3327968313756418042,\n                1097821402063109479,\n                7256603776215037436,\n                16159780022292663956,\n                17964893318700077025,\n                10962902536107975247,\n                7320550439447854389,\n                14334780521409633054,\n                4699452739827576826,\n                9093268785303487009,\n                6344405044849339468,\n                11848292709291959714,\n                14760683788704509466,\n                4225108478874620861,\n                2901943652303490660,\n                6818132424834122414,\n                16174008530442037804,\n                6271947949436459450,\n                3570604482108849930,\n                12890452366190704954,\n                8515100912972766831,\n                2328912653110868223,\n                2551276586468841097,\n                1777511200124317812,\n                13775576098140883402,\n                3898067160703376056,\n                6351161380350484527,\n                16859278051445776112,\n                14690763963896054237,\n                9567946959436887085,\n                15838477932738238738,\n                9730676848478313229,\n                8066271786694050339,\n                4122621761286909553,\n                15283986993063032338,\n                3752996388177035008,\n                15404074806158244183,\n                4664569365239309400,\n                17671699018667543313,\n                6690783097548235595,\n                6466585595067583758,\n                14022028503333983234,\n                7939754610094515610,\n                8163183386194559637,\n                10476051353580213825,\n                4511583491988680073,\n                9188502261872559113,\n                7408378497508188518,\n                1649670196419579816,\n                1053916178593140007,\n                7911309861374389712,\n                15032485360640049189,\n                9124570128447866504,\n                14046893636531415981,\n                250111365613429267,\n                1643606250555524120,\n                4155955491523436557,\n                10870726304981416869,\n                14944082243353063876,\n                16421238461518880167,\n                15924408471434652318,\n                10731945555425051586,\n                14495249000183794562,\n                8846884895280158170,\n                5565891773087990332,\n                1837792939541241349,\n                6112699197700624176,\n                7562264824078865510,\n                16849021028091575913,\n                17246255673370327668,\n                17580006033844531064,\n                1351562679496436002,\n                16771152552690652203,\n                5274051012054233957,\n                7648406455783604255,\n                1246471362969897938,\n                16120472728146043782,\n                16166681434816599117,\n                2623886897349824851,\n                4023278728763402245,\n                7283187577873923080,\n                5084224325637364730,\n                1476723572967543249,\n                479713893390980167,\n                1896209313557836901,\n                254984415576149738,\n                8415027322583137901,\n                14041872703600168181,\n                11935559776977783011,\n                13364349759217490994,\n                15780035685521226192,\n                8676579092208619555,\n                16064345951756800054,\n                5638114870421263136,\n                6270982746853694228,\n                13130830212820724188,\n                10518270735201681053,\n                11245308360082873244,\n                3151879320488972838,\n                8402166224245273877,\n                5495337374477483425,\n                18356012286937648925,\n                2129448815318200193,\n                7817762379822334015,\n                1308094065360667428,\n                9452125716061917909,\n                16830335368607333043,\n                7115352597517763002,\n                12961077632058697621,\n                6264739998394856219,\n                10711361719217759622,\n                2805729415502011801,\n                16310918919711006710,\n                14984568792320800815,\n                5033473820547421598,\n                12187842566826705754,\n                4078001430260229995,\n                4636228512388579231,\n                11348937457465299114,\n                5847070676214632205,\n                8079399555440215553,\n                6457432316721536567,\n                4951083125808061965,\n                6293687095689620804,\n                11406482222093560959,\n                12658825924452667114,\n                10143584571617814544,\n                10022366761772053513,\n                355937325950036313,\n                9105402276098628794,\n                14972622607769590007,\n                4815136695954494351,\n                9515549740001371280,\n                4507108044850455980,\n                10153991335189677806,\n                10475976860885183218,\n                18392897880757235177,\n                7749647359532990440,\n                10232160559790081825,\n                1832228719152017993,\n                10890777646249905570,\n                13622006085705339951,\n                3231946825126030723,\n                15685731590656020016,\n                6084715112214186784,\n                1215214721646491153,\n                4231466600123546797,\n                8168820323486969127,\n                11634735777117238886,\n                15448533925907917735,\n                15937944514800610778,\n                4056349991916377957,\n                5094616519526616735,\n                5413794077342350279,\n                17973381638741991988,\n                4337914915291663099,\n                13739150828488185155,\n                12791593666472076388,\n                6307708804293666112,\n                18045762826377694670,\n                8496356868191969871,\n                5807060217263995474,\n                128039966698714827,\n                6431461066104336028,\n                18004817073090175031,\n                1800020996723291496,\n                11580212732146715316,\n                13816860669240708872,\n                3861721497954223568,\n                5744224278046122943,\n                3839434585307875902,\n                773812752136737676,\n                0,\n            ],\n            false,\n        );\n        // - size == 0 in limbs_extended_gcd_cofactor\n        test(\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n                u64::MAX,\n            ],\n            &[u64::MAX, u64::MAX],\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0,\n            ],\n            true,\n        );\n    }\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - scratch > scratch_2 first time\n        test(\n            &[\n                3897754892, 1591443736, 3731539623, 2201049795, 667019954, 338792079, 2659170876,\n                3110296069, 2376679457, 2383464170, 1556639511, 3319121799, 3166670999, 2106071868,\n                4114757632, 350183771, 1813104833,\n            ],\n            &[3508657757, 3011352011],\n            &[13],\n            &[1373166577, 18362570, 0],\n            true,\n        );\n        // - n >= GCDEXT_DC_THRESHOLD first time\n        // - scratch > scratch_2 second time\n        // - scratch <= scratch_2 third time\n        // - n >= GCDEXT_DC_THRESHOLD second time\n        // - nn != 0 first time\n        // - nn != 0 second time\n        // - a_high == 0 && b_high == 0 in hgcd_mul_matrix_vector\n        // - limbs_cmp_same_length(..) != Equal && (us0[0] != 0 || us_len != 1)\n        // - lehmer_us_len != 0\n        // - ss_len != 0 && ss_sign in limbs_extended_gcd_cofactor\n        // - size != 0 in limbs_extended_gcd_cofactor\n        // - lehmer_us_len == 0 || lehmer_us_sign\n        // - lehmer_vs_len != 0\n        // - us1_len <= us_len\n        test(\n            &[\n                3762839616, 2967303351, 4062879665, 4165640742, 2234446345, 1620638488, 448679871,\n                1137926410, 875978589, 2449429151, 119500812, 1645681298, 2261230243, 4012109892,\n                1880039262, 3823761915, 3823287146, 3298525947, 182661440, 1727722474, 3533552734,\n                701287629, 2616764708, 3283986955, 1488777769, 2704219188, 3077818025, 1332124621,\n                1289136174, 2954906289, 1428812861, 2396554867, 1921203057, 2784693210, 2216238152,\n                3284610812, 95149300, 461371838, 3227938939, 2641070942, 2375717459, 3203938917,\n                1868106937, 4078179036, 2189762153, 2180822395, 3379470590, 4012169608, 3070486814,\n                325836440, 2847713220, 3933125061, 1877517798, 2859136122, 2708155707, 123325553,\n                749102782, 3101320654, 1289955955, 2400149618, 3506792555, 4078214206, 3239665558,\n                566182347, 3617280016, 2149509005, 13381270, 260919523, 3902125900, 1378889636,\n                3568804679, 2795835774, 2820285329, 2553570971, 2887752390, 106251296, 2204563920,\n                2108659045, 772859668, 2676569826, 3062588931, 2781116609, 1249633190, 1317945945,\n                3848689824, 2255648615, 858513646, 3636484450, 1846465706, 348176034, 2538183889,\n                4094178045, 3345266791, 725000962, 2785581015, 484198471, 2576668150, 1563131970,\n                2080449279, 1403091456, 4217712236, 2849047009, 2457566162, 2112594498, 282536535,\n                3675707661, 919672617, 1763625368, 3483048959, 3627418205, 3149707026, 1247936956,\n                899012765, 2975733799, 4075719513, 3712606177, 1596851592, 1200276105, 3678643745,\n                1657748004, 268026781, 216321281, 3542039833, 1034844323, 2165371654, 415846125,\n                672088830, 1109960702, 590813340, 2856536701, 1324154592, 2925233312, 4128642860,\n                4224883829, 2946877752, 2516423945, 1920408555, 948662453, 1802422733, 1550713261,\n                3765914851, 2391591503, 809461282, 1682796307, 430607881, 2259629147, 4205981011,\n                803329433, 2922597120, 3867519412, 1845488268, 56866391, 1749624959, 3789345017,\n                852019444, 746073761, 2217066953, 3322916922, 492290040, 3860587330, 3045516348,\n                2402113307, 1072947248, 3287650314, 3729416957, 3288560211, 2648923449, 2947384134,\n                978738351, 4206727716, 3799518272, 2523890380, 4240712847, 139648756, 1849818862,\n                129885306, 1596458797, 592938917, 1695490670, 1049264694, 854799233, 95358756,\n                230932304, 286523788, 489674484, 2194824544, 2837471612, 1167420495, 561170122,\n                2323842053, 2693817101, 1977318979, 1803712373, 100240938, 2823914585, 3305999827,\n                1991119105, 3731378313, 2741941084, 3182956207, 3805467102, 3567148328, 644528644,\n                4117795281, 1862948151, 3039205689, 3735294192, 3944679490, 2996177165, 3819378812,\n                1839330932, 3652801991, 3989628037, 1372430413, 1067509161, 3729244886, 3069275542,\n                329434844, 724055239, 4072117251, 1739491639, 1820536186, 891863943, 3188986409,\n                3282105241, 1443494725, 3191928513, 3180924502, 2670529247, 1020294985, 4255388313,\n                436387871, 984529800, 2639531245, 2836663830, 238179551, 3280695056, 394858620,\n                2853787135, 520661464, 828033417, 1206402039, 2388038671, 3167724755, 992289854,\n                155743860, 3841622716, 3264917318, 2656941314, 2977148407, 1411905882, 1607242955,\n                1033507899, 414422850, 2740309834, 3620002421, 279386928, 3369823140, 1133353466,\n                2401145759, 300829644, 652434123, 4062297302, 2765186813, 3352720931, 1965242866,\n                3048509317, 1047329756, 3283783583, 1102536736, 2867627346, 713434240, 1900974984,\n                1889658765, 424376438, 4066161359, 3595866981, 349425704, 1339975348, 3489209212,\n                4108023084, 1021821676, 3854012048, 2379788417, 4223914814, 1019701671, 3032063795,\n                2915803116, 815008284, 639272216, 2031646920, 2274852463, 3347440003, 4015644452,\n                3528407171, 309435395, 2115945360, 660896703, 2842673452, 4278731819, 3716277170,\n                283430113, 2843703539, 1035009984, 3920409252, 2783446318, 1126636158, 3067742837,\n                1191242603, 2171152922, 744214603, 1361159732, 2246988530, 4093546546, 1599908321,\n                922131016, 2517982795, 2540991722, 1318294259, 2620311038, 4294566241, 123572629,\n                4103296441, 3132380177, 1621894546, 3452280633, 3910486070, 4275454874, 97296377,\n                716413318, 3491146417, 2929708827, 1527112018, 781388525, 3651012169, 282448756,\n                3283582572, 1898078758, 1788942303, 1995178922, 3441777049, 173604069, 1724943732,\n                860875392, 80717574, 2954413462, 2552039446, 2631438427, 1693507278, 3353262523,\n            ],\n            &[\n                1693377439, 2515180469, 2439214130, 4133741269, 2582353740, 242054029, 4277621427,\n                2504984707, 77434695, 2984274878, 1564979151, 3285070373, 2252781630, 3364774938,\n                3002449910, 1680353696, 1217306725, 1396375684, 2599013453, 3102429128, 4278239524,\n                3169571622, 1167640580, 2453974881, 2335368085, 1242479084, 2857593953, 3802180829,\n                3567800871, 3865342345, 3119715092, 379851163, 1397558188, 770778293, 3785859192,\n                3662070793, 1657684760, 2766622517, 22322818, 2648843872, 885524552, 1667222975,\n                3327780957, 3899267759, 2700168414, 1035990630, 2964803242, 3658514285, 1521662985,\n                3875666074, 384714566, 4023835084, 1712455255, 1633372627, 4105720974, 1214600656,\n                2697565604, 3991985789, 275972215, 2558541893, 549181418, 662068140, 503219765,\n                447509030, 2261465632, 3114832534, 3921496979, 853023187, 4224408890, 2979976205,\n                207077487, 1101645904, 929902458, 2590079399, 3323735589, 3164178351, 92191438,\n                2164068486, 673800185, 653476923, 1564764455, 907896117, 3177543114, 4277815432,\n                850719138, 3515239072, 3716534814, 4190421623, 312943968, 3826875600, 1990994491,\n                3709985301, 4221256674, 3556567657, 2610085896, 3745970187, 1435011594, 3892109511,\n                1715581482, 2105913079, 2419019493, 3909752637, 3371571260, 3345828095, 1028723886,\n                1191606681, 2887118757, 265947242, 2226697675, 1949040274, 976693848, 2720509879,\n                1605048137, 2459501086, 1131995726, 2371676741, 3850355205, 3213110584, 1364148839,\n                4044081326, 1524307989, 2520341453, 3184534510, 534185823, 3259475834, 2531104741,\n                3170241627, 2809437947, 1223276703, 2218190753, 2148040222, 2903447873, 1896662098,\n                88908799, 2496611452, 1038079086, 1541073446, 208649800, 1109996254, 1685147065,\n                4127948847, 2874587139, 2210510801, 1989034966, 3468467699, 3226999107, 2921297089,\n                3500577322, 1932873731, 1789716188, 4112814531, 165371344, 2432727073, 842353729,\n                840790720, 1477582335, 1801483328, 1805128359, 3698633967, 3501617244, 855186793,\n                1230557311, 3486176081, 2409494601, 436296379, 2343301859, 255459172, 3499418449,\n                555156558, 2170432178, 596711781, 3036850923, 88664421, 1942739632, 3123209816,\n                2220529354, 3706515643, 1804005296, 728289710, 4075256444, 4215063814, 1180523869,\n                3481812761, 2904673863, 1722094894, 3238283099, 3983051053, 1438237631, 1121945410,\n                4229945817, 1270004103, 1119108133, 1935109657, 267055487, 956248707, 3855027428,\n                2226764505, 984782979, 689899815, 2020393263, 4007327071, 3186231458, 2451483690,\n                2664159307, 2624554845, 3315837097, 2441190188, 3506544698, 3929763769, 2030117497,\n                3138752244, 1711107972, 2582482362, 10064793, 872799969, 3783903762, 386063328,\n                1205008174, 537775062, 2669375356, 3419058256, 1171712416, 1774647095, 1497660848,\n                3169310977, 295784793, 2216281857, 2466578023, 1813328265, 290536445, 1099646980,\n                4138641573, 775042501, 77053349, 15639833, 3034370119, 1634213368, 2884099476,\n                2274185957, 1226572167, 1740332810, 3674005254, 3631482994, 1156096480, 3606707530,\n                426829415, 1232519516, 25270879, 3086722770, 3941364397, 3405781167, 2415115506,\n                1517840345, 1606833111, 2565163912, 3988365259, 330707489, 1617180807, 814469081,\n                2263039715, 1556805104, 3942915981, 458673662, 3877105328, 2446254642, 1556590500,\n                826262573, 3724262368, 2213879994, 1450645885, 1056572628, 4000758956, 4160404794,\n                1891118025, 1715959086, 1211501563, 577988969, 2129952979, 3907919003, 4051278550,\n                3461444806, 131544635, 2593930090, 431700375, 350623646, 398604570, 1171577992,\n                3886290689, 3850610723, 1591600825, 2928989840, 401164946, 4144495423, 452010787,\n                3246123860, 1872084940, 3263472759, 1050558595, 2095418475, 3402226626, 3757833605,\n                1461484814, 11285668, 2262295928, 1891730627, 2181259816, 162673695, 3362648426,\n                1167165856, 722354045, 1845723331, 2064834481, 3971671786, 1714853922, 3199429669,\n                358016658, 208221582, 1670486500, 735570681, 940123172, 4101442559, 3587213701,\n                3552665637, 1900305803, 1548158612, 488426234, 3800857128, 2406068943, 3444303271,\n                3252716429, 405136720, 4011758616, 3969423411, 71862739, 3329146881, 1260239194,\n                395385046, 296902642, 3948201723, 3835744605, 1695111845, 175164568, 2187945981,\n                3522227152,\n            ],\n            &[1],\n            &[\n                1393609056, 1668089679, 388101919, 3438788800, 4194117699, 2189254312, 1598588274,\n                3879253996, 2127868385, 3471466265, 2337251129, 1921288799, 392679821, 1665416984,\n                1079669059, 1573900002, 1964806532, 2102176554, 4095311226, 3507401786, 2214644498,\n                883768833, 1519501665, 1304100050, 2966925652, 4224555623, 1799109462, 376762510,\n                1168427484, 4016439230, 3733525310, 163928847, 3454421957, 1013235746, 4152862368,\n                1291761337, 1519763430, 27576847, 1580902245, 3591746340, 1007577498, 1184863609,\n                275405856, 905021963, 3725730585, 3138204434, 3050531811, 3753821538, 4123611368,\n                2554499493, 644559702, 169964742, 2719569988, 590330270, 74782727, 1034630774,\n                409876667, 886756373, 3403621554, 3637008468, 864505940, 877730074, 38002984,\n                2390955925, 3098237160, 291842393, 3391582458, 2018940044, 4060204863, 4153199304,\n                3763045923, 1440843292, 1571876254, 2366883331, 689380750, 634873145, 2318283923,\n                3208426517, 3271060718, 1280295173, 2544392122, 1301307279, 1657074264, 1342838957,\n                3049729249, 1004945554, 2253574816, 1525961110, 2510687431, 514819540, 957979057,\n                313615390, 1607095417, 4061382021, 3941379563, 1101265462, 1313622484, 1837703852,\n                2673117468, 1437174024, 1499621627, 529083376, 1940278425, 776798184, 1123682684,\n                2122099660, 3074020283, 2094844126, 3428277975, 3294333385, 48114786, 2689586655,\n                3538009580, 1745291826, 489247647, 3322213232, 959686083, 2666000275, 3771267440,\n                3495977761, 2431492604, 916073707, 436504411, 200716576, 72474591, 2937145867,\n                1583010373, 4186277170, 2537013278, 2698078347, 393025935, 4150124187, 224908520,\n                3447498563, 197596967, 3560825651, 3097801455, 2945720980, 659464691, 2979792921,\n                1348822961, 2747044617, 3337218782, 3229027566, 908197840, 3134460360, 2841826299,\n                2481153225, 1047716291, 90931696, 1679067328, 2568036144, 2915134830, 489068184,\n                2772007434, 787204345, 1359526321, 1108174931, 4117450905, 820904957, 3350408170,\n                1771963799, 866682718, 2435333265, 876077850, 1033960917, 1645617627, 1650743672,\n                3940682757, 1770347533, 517189836, 920250625, 4008776544, 3119334766, 2164852932,\n                1430249573, 4056499214, 2473908787, 3470156455, 3546319710, 3909127421, 1660272144,\n                1089002319, 3675125278, 797600811, 2022127439, 2739608587, 3439244966, 3463881000,\n                1836767606, 2859304929, 520573508, 3233204064, 471627213, 4182072094, 1251347368,\n                3602733112, 1033377063, 2460642996, 1016213436, 3231592120, 3226200884, 106079916,\n                3696456858, 3128931316, 3521087294, 3349410512, 1082958228, 75668315, 3464591731,\n                2952627950, 1017048554, 1574302947, 1109268720, 3264722269, 3617623906, 47366057,\n                233054575, 2477361108, 919474704, 3831927354, 3420634778, 3395208828, 851029512,\n                2323975556, 372064504, 3471244010, 2788291215, 3166971224, 1960533331, 2407342180,\n                1129220597, 347329439, 1871810614, 340007359, 2759144798, 2286800096, 107458106,\n                3630233388, 1826813106, 2927588246, 1982203941, 825172593, 708608518, 3042987277,\n                1724767260, 2508613865, 799077018, 220909067, 3894286154, 3926799271, 2358623483,\n                3925218124, 2860669724, 1158499946, 3220435185, 3371813630, 3307737058, 2629255355,\n                359567492, 2904443397, 2635944803, 2112449220, 2211181964, 556540968, 2909852447,\n                1037277002, 4076912375, 2101537861, 3686624842, 2828607232, 3377387494, 2210360409,\n                2411894734, 2466571187, 2138028095, 1440618752, 3569307243, 912762213, 699744466,\n                3771103410, 2890482012, 2912012447, 2658641861, 652064016, 3099409172, 998011974,\n                1523595687, 3333564359, 983370044, 3841364864, 3424833451, 3066298350, 4126305990,\n                1400044010, 1205863433, 793974470, 362425761, 2387396037, 2977549597, 2075854219,\n                3124515174, 3471006981, 69707483, 872083528, 4040308644, 1523307219, 1074317105,\n                3664463569, 994741592, 4252689215, 505599222, 4060502974, 3061003002, 1418799529,\n                1680036101, 2316739007, 2468222441, 1045693481, 1473917157, 4182272343, 3855611698,\n                3668311253, 3286026043, 323272750, 7410276, 1984804150, 1801786556, 264019842,\n                2066806575, 2925947809, 3721069056, 3755918310, 1429760301, 1134071192, 3565767674,\n                2487124209, 1642250487, 1038092541, 3790194524, 519027477, 2656188663, 805313971,\n                1581787635, 0,\n            ],\n            true,\n        );\n        // - scratch > scratch_2 third time\n        // - ss_len == 0 || !ss_sign in limbs_extended_gcd_cofactor\n        test(\n            &[\n                74310550, 3684857215, 4195563540, 1932463403, 2701977359, 4052089791, 2826747541,\n                1491226437, 2117772829, 2404853855, 1681591153, 501486090, 4035630834, 2942773950,\n                3965991474, 4174952080, 1311942174, 967870714, 2272005008, 1224704677, 1184062144,\n                3981077533, 1360003749, 290818846, 1347799497, 2235021764, 3820496078, 2088443415,\n                1249972471, 3795966103, 2489816539, 1081993569, 706286461, 2866235029, 106879314,\n                2375809606, 3142865583, 1013483211, 3505736665, 1018680206, 2204848950, 681988775,\n                2095459452, 2399591422, 2677947559, 3678360365, 1094565217, 2173800169, 3656600695,\n                4086541844, 894958491, 4122901419, 3753678287, 2178442254, 902457379, 984358218,\n                2914419433, 1531443436, 4148703424, 203601029, 2344242033, 404262744, 1130385058,\n                107099317, 2972886656, 2996679753, 4235390624, 3809459200, 4131414295, 4051400485,\n                1414437089, 3243092392, 2881511575, 776072878, 2435162818, 3450788997, 1630916173,\n                691381501, 3962265403, 3276437521, 253507689, 599902663, 1579004169, 4202480377,\n                2042450196, 558721125, 2146913618, 3503780971, 372811960, 2210806951, 1767967910,\n                1804820784, 1701734377, 4259228040, 868893527, 2102141044, 642487995, 2139687168,\n                3217271118, 3807418215, 3261976935, 929051287, 3943894160, 255758822, 3861729768,\n                1584488251, 840003021, 3035292132, 100163217, 1544310956, 1321895757, 3730997455,\n                3431322122, 3712192042, 2587337131, 250371835, 4292213317, 133986444, 2467011381,\n                3222257561, 358247829, 1077622444, 4034574796, 753244486, 1417883886, 4173847504,\n                2395611782, 3784624740, 1170553448, 96736306, 324810407, 163356845, 2781370737,\n                2626965592, 1711364942, 3620321815, 1037634179, 2159676882, 3030237577, 4003655416,\n                1317909197, 3872252045, 801107604, 2605152822, 1726177269, 2639322764, 634608690,\n                202505283, 4287528588, 3529992483, 323119212, 392355407, 2810111885, 1518012210,\n                1687498186, 2200403413, 3552634997, 925734954, 380011454, 2038632642, 723250497,\n                2183915576, 2375404879, 3597027590, 1465229539, 1441179962, 1101992056, 465581252,\n                521753873, 3402618493, 3660408267, 2191505084, 3025386009, 1110551535, 3696253833,\n                2934449447, 270918983, 3088802491, 3122991822, 1438682320, 1440620889, 2730839421,\n                4143462998, 137656753, 565499602, 2535950098, 556793223, 321223212, 1525925221,\n                4171365642, 3904725909, 3644902683, 2051318676, 387867671, 1770768052, 510814112,\n                723471713, 873977447, 257236365, 615515201, 2578395673, 2753664576, 905559712,\n                2500927371, 1296710732, 3886865363, 3005960899, 3684007331, 4143041158, 2366878938,\n                1714542138, 3410115077, 2879409644, 3328247532, 817839754, 855825811, 1894716618,\n                3629567121, 1206627978, 2852031409, 230625254, 3368218591, 4042809617, 1915413257,\n                3555530943, 1475738483, 695002857, 1926295572, 1226821611, 3004377400, 2555002778,\n                3651774914, 3437714157, 28014986, 2973285277, 3673083025, 3242773182, 1517435827,\n                1421912587, 1177464830, 2455554109, 2595190727, 3155583291, 3310352929, 369038486,\n                178372520, 1649325320, 2422315435, 3258510890, 3575437924, 294226406, 1387707173,\n                1920980667, 890867321, 1972378523, 1227213297, 2361130999, 4167202579, 2163533171,\n                2383008798, 3494162449, 3385820353, 2710406521, 2985041632, 2694848326, 4068305667,\n                2942916526, 2476626358, 1660135201, 727042092, 268512304, 2048192807, 1207211865,\n                3670015910, 77783405, 2681566726, 2681823572, 2094390259, 1567797140, 3746350911,\n                2837598968, 2442753220, 3374824876, 2463794949, 4026074137,\n            ],\n            &[\n                3601838339, 3389527135, 3199255267, 167429870, 4120438511, 3791081297, 1051610496,\n                2831925658, 3138327153, 1738612299, 142767461, 451766065, 1523426819, 1808217463,\n                1662507181, 433628334, 612971737, 3384254423, 1524658464, 154523660, 833536371,\n                737557796, 371547944, 1654120803, 835831538, 1784970368, 1788323399, 545602792,\n                1786466785, 974820691, 2239220379, 1494785387, 3801297697, 75457861, 781481706,\n                3502813399, 3172635468, 531427646, 3409899873, 3441423830, 2093952094, 205557919,\n                3981485225, 1751839582, 1974962270, 3891786411, 2096714479, 1971711392, 3256278198,\n                1035760556, 1066075733, 653493168, 3136688239, 3402779557, 3205564309, 1206349448,\n                3160959668, 530694406, 2004091029, 2446160779, 2011849976, 902714644, 3007498124,\n                505798654, 600285365, 2281470223, 780710454, 1905845719, 4092492421, 3973361188,\n                676446183, 4170170431, 542862256, 2648449136, 1107762383, 4168697101, 2423190399,\n                634645690, 2427748780, 1100910614, 2480475038, 800791297, 3718104965, 3114992885,\n                751937105, 2852127039, 3366541691, 1221876612, 633153490, 3280813177, 538197296,\n                3704159053, 214017394, 4173347526, 2996370431, 3354186763, 964498456, 2614298215,\n                1295317447, 428880416, 4032691632, 340223270, 1769526294, 3905215417, 31921576,\n                1536219531, 1566836356, 3150642622, 595168147, 1299756321, 2674132095, 2971109047,\n                459958242, 2946581288, 1727142010, 703973706, 763870983, 984639964, 2631113497,\n                501205034, 2799535391, 2400194671, 3292745359, 2786435398, 1521799401, 1082838265,\n                1561857367, 3191086584, 3021982259, 2827962005, 4216748738, 257549630, 3114248619,\n                189933651, 965281549, 681160742, 3092658868, 3631419991, 350669652, 2258678213,\n                2802738039, 10053030, 2224029759, 2587869134, 2954399881, 3203751998, 2244828285,\n                3023569974, 4052208026, 107088743, 136096065, 1044340914, 3956070202, 3303754650,\n                3128172551, 837572504, 420546271, 1042960901, 2450628487, 1443820393, 2453824614,\n                3576780987, 3916987256, 3683003957, 3077152988, 2820843100, 994775381, 2721865418,\n                2135991139, 624991155, 1118457663, 3552077852, 4201035247, 75044940, 574256973,\n                3946688245, 69642536, 3075052287, 2136563917, 598694353, 488979649, 2287218854,\n                3275172664, 2890192435, 1267136240, 2792041779, 1815565573, 1634974334, 211096868,\n                297005246, 3504012622, 1072110147, 3212420667, 2158377307, 3718128929, 262446033,\n                1551719654, 2813501675, 106403179, 2870213468, 1483616723, 242287943, 2208733614,\n                3711810589, 1437091905, 1234730132, 3672062627, 3394277988, 3774429922, 1179097821,\n                2290210831, 3639274568, 3221308057, 842782026, 3031989022, 276644709, 1697723959,\n                3742435088, 2548019495, 2980018951, 2436631391, 1182761076, 3162919388, 340442296,\n                1214857666, 878131886, 110740326, 1307427842, 2331304285, 2202030177, 534226195,\n                2751735378, 4012895666, 318125704, 2993146500, 1669696977, 1779052631, 592764374,\n                140645184, 849345706, 3386384106, 1494695680, 525110148, 3360506653, 2674752886,\n                1931006280, 606982322, 1388477671, 636146571, 3683742943, 1118871516, 2900077755,\n                2912836028, 3336213952, 3744044153, 302021444, 3994958705, 3934494823, 3784076284,\n                1481317384, 1994455765, 3359047713, 4189189868, 2775684855, 2268293895, 2244043733,\n            ],\n            &[3],\n            &[\n                3743605517, 4179569329, 2073207865, 2553816512, 4117833349, 2637359383, 3704896208,\n                378306359, 2705719088, 2880185160, 3444990912, 4060308087, 548140866, 2004200601,\n                3472416250, 1429192756, 3208447353, 4039217005, 4106085374, 4040549815, 1626542807,\n                2942613069, 3392841446, 4035125853, 947826882, 938796203, 1145736949, 2938715945,\n                840660849, 3710125848, 588663267, 2882936046, 2949062660, 235176621, 1851170909,\n                901829062, 3120584500, 555282352, 4259152968, 2423820899, 588264049, 1149200408,\n                271528610, 1833941193, 3174986896, 562267934, 2220670279, 3894873858, 1012195213,\n                306864348, 1680322240, 699702484, 300813063, 212871964, 1564539128, 1204678629,\n                1457509501, 124310398, 1638616079, 1544535804, 2077138368, 210219765, 2483616536,\n                4254280024, 2340265287, 1796976054, 2198447684, 2605412473, 3617375869, 3033256303,\n                2875673780, 2320809525, 3575396572, 805995054, 1564225156, 1626913897, 1292974128,\n                2135559780, 1878970422, 3894404000, 94713723, 2561470561, 1660648203, 979776327,\n                3949215531, 698838945, 1843823969, 2751208029, 610079597, 3754455960, 360823624,\n                2987158356, 2994782418, 566986116, 2404661005, 273867727, 869887518, 949533613,\n                3842355789, 3783404515, 1463818381, 4147016693, 289049355, 1672164913, 3106023939,\n                2315507851, 2857811126, 3550477869, 860460763, 620224458, 1835826089, 1268899797,\n                3439121015, 2482534704, 3284302513, 1761503569, 4000140663, 2162987234, 1096469906,\n                3044581491, 1667797669, 468730477, 2630281039, 3020160336, 3295784045, 633349537,\n                2531146461, 4245451986, 37001682, 4203279524, 1618196223, 2558909681, 1715347160,\n                68236321, 1201150886, 817854094, 1480912789, 1255626224, 3294629333, 3940789659,\n                3125357036, 1599656071, 134729316, 1674181206, 2494740541, 1739168882, 3321943862,\n                594912209, 118454926, 248900353, 4112996779, 2798650952, 2166813104, 398470519,\n                1737480311, 703830919, 3410153747, 1614114161, 1358720344, 439750188, 697686526,\n                2495881421, 3478343208, 443559010, 3876059116, 4263230127, 4247623333, 939127550,\n                3316698975, 572023281, 2575474657, 1901362389, 1903267166, 3889333747, 3237411152,\n                4226596762, 1120071913, 2482937441, 1544332266, 625134331, 1591508498, 3106874019,\n                2851071518, 104456679, 1915266024, 55682651, 2001837660, 702405811, 3100702526,\n                1645665128, 1345512696, 2022651937, 1007011973, 2944039647, 54653045, 2445423242,\n                1693931160, 1230191385, 812251921, 858953374, 115415998, 1008523979, 1198867456,\n                4233225816, 2796537162, 1195686984, 2199106552, 480720883, 3010965825, 2535760037,\n                2352986652, 254106110, 3749353513, 1592688563, 2353884844, 3906141933, 3067022490,\n                3216957447, 1241127308, 3210786485, 656356244, 461264467, 41838622, 2791209640,\n                3882461708, 1905589240, 699011852, 4067016151, 3607049493, 3240323965, 1546024465,\n                1681907639, 4281764142, 234683244, 4012306441, 859073253, 2109486501, 3896985008,\n                2402673571, 450935651, 2255996995, 1871535824, 107766737, 3036831750, 853695499,\n                2071762278, 2901839029, 1804820556, 2461865290, 367151607, 2508680843, 2311143384,\n                1697717932, 3809283596, 1545348801, 2354684536, 1789458423, 2261515026, 235458984,\n                3654263365, 3089351522, 3779807866, 843150936, 1354871808, 2127328047, 313337276,\n                0,\n            ],\n            true,\n        );\n        // - lehmer_us_len != 0 && !lehmer_us_sign\n        test(\n            &[\n                3714073558, 375193035, 1620772021, 2308204402, 626547013, 3688150199, 1448538382,\n                2668595114, 1009561668, 1343823926, 1509608795, 4028253859, 1815980651, 1785146987,\n                1342958609, 3553568195, 1725347486, 151259885, 2320707416, 2987769959, 3741775337,\n                818070422, 827367513, 753102779, 74383384, 1382795590, 1881554822, 227618421,\n                3934359081, 1962657040, 998065041, 338982340, 1281868418, 2999179107, 1652003177,\n                3123097903, 3257098, 1621937355, 812876371, 2397377805, 2170739943, 1419963806,\n                92617000, 3668729026, 2240231990, 3514746217, 3492237442, 2559241670, 1525109693,\n                3005514966, 3852872611, 531448444, 1669232883, 148128188, 1239481575, 889075183,\n                2769552448, 2509351360, 2158188017, 1208314937, 2800429516, 4172256108, 861328391,\n                3116173930, 4030544020, 2551025568, 4268865357, 1482211250, 657549589, 3306982572,\n                2933298890, 56098708, 1989729224, 1743604790, 110376592, 2139866017, 1072327219,\n                3469499313, 381416910, 1760787277, 1363950668, 334943331, 3654960685, 782150592,\n                3701034853, 1136642643, 3692640414, 1959495485, 812950011, 3249389091, 3259364568,\n                1685592552, 4256698651, 2036050133, 2433308803, 2325012565, 2650618050, 709154390,\n                2387307041, 118573438, 3470337072, 2607784310, 2364405729, 1417625047, 3236813797,\n                2729521018, 3639006705, 96799629, 4108743714, 4177055576, 1544958097, 3899425671,\n                469081179, 2539369616, 2986882604, 1335697326, 2186395654, 3911059390, 4189281233,\n                2426450063, 3956940807, 3883295955, 3550183055, 3853112591, 1929765171, 245863045,\n                1784682505, 4002404844, 2509707717, 4274582128, 967068840, 3767407516, 1130216371,\n                4245379947, 4024085884, 2184101616, 3749613502, 3516580777, 3578117768, 2353774157,\n                2642207837, 3725043408, 1828260039, 915702978, 2705406301, 3535196378, 2877116312,\n                3679028343, 2070581078, 3559165185, 773435559, 383510436, 3209711995, 4004820838,\n                1998784655, 2871662581, 2529625272, 622878861, 2863694253, 3914220048, 2679188786,\n                3050594298, 3045251700, 3512780649, 2906941324, 3942757081, 2907048772, 100041843,\n                4170806507, 3700825180, 2709242073, 2179276763, 597377847, 3463521373, 225180682,\n                1750686210, 1093215152, 3352780093, 1077233189, 3245228123, 2396717084, 3787246723,\n                892320530, 1029311734, 4280196574, 2345165313, 3450587453, 34019938, 1280657875,\n                3548776991, 221784082, 3463424486, 4129053861, 2357286454, 1994868751, 1353736236,\n                691568564, 4253680566, 4055927368, 1499648079, 1286708763, 1365610481, 2611290963,\n                83252581, 4163076670, 1565784615, 972801101, 3913786720, 2999013362, 3798728041,\n                1581006671, 404535456, 856581363, 1508425066, 553497914, 3090372112, 603773943,\n                3850767240, 1741397001, 4026283585, 2777649580, 3530633927, 267199452, 4120305103,\n                1366237421, 2861373191, 4008286372, 571708589, 4259212487, 4210946087, 976721978,\n                2468468308, 426418605, 3496624920, 225318850, 2194812088, 3227558244, 444008974,\n                2090459961, 2364873754, 632622517, 3955662100, 4155243543, 1610700691, 3338597107,\n                937549997, 3402931779, 3336911213, 2512983483, 1602321580, 385279681, 219089337,\n                1311034097, 238759500, 390515148, 4014040379, 3622671161, 560560741, 2174041032,\n                272454444, 4242752401, 2135675415, 4069493753, 2346744121, 2940951489, 3461267243,\n                1485096605, 279517788, 3812451507, 1527749536, 2519024910, 1054202103, 3151806385,\n                4045340674, 1756112458, 4218041601, 53056302, 1298620474, 541870411, 1907995687,\n                3015193382, 2289454404, 2422235646, 3379667784, 2654976724, 231577350, 1935104189,\n                604588941, 2815299657, 596740826, 2100583598, 1737397117, 2096370396, 3411467032,\n                2531389141, 80135848, 3230839253, 4011475632, 381422820, 792708197, 1426670359,\n                2119901750, 2324153190, 1682237962, 137137837, 1206643795,\n            ],\n            &[\n                1878485618, 2582823939, 3526257766, 3491869588, 2508972765, 249421064, 1431449671,\n                3872030994, 3411988094, 2806831307, 3820262770, 53035764, 2850291145, 374665519,\n                2246783701, 1466683201, 271427494, 2157692599, 4021749208, 409438247, 3155661705,\n                843312510, 2889651408, 3649983796, 3032237477, 1696325992, 2559886399, 1256508327,\n                3109597138, 1906214881, 1709991816, 2562870361, 1860860055, 2418306985, 2322779826,\n                3265670082, 1213618630, 1154886991, 594074344, 3632593081, 163910128, 2797803240,\n                3572330107, 244626448, 902896355, 3699561111, 4254902447, 2484872968, 3981424715,\n                10061257, 3123081717, 180908376, 1859280280, 39983663, 1024528265, 1521567703,\n                2695062267, 149048575, 179176529, 144520692, 2604716899, 1174209826, 1031181796,\n                177237457, 2719241498, 179940181, 1906705445, 647593808, 1420363719, 3297208800,\n                3352463250, 788193177, 3800276204, 1542750256, 3053223337, 421095772, 1726003798,\n                1155660421, 523307670, 1998474431, 1979224306, 391343343, 4104067353, 386326853,\n                313019445, 2456282888, 641413741, 736340248, 3874706631, 2144435461, 3920080898,\n                2738344935, 1625068457, 1257024866, 999908850, 396413465, 302677517, 712478295,\n                4288330089, 800161765, 114814077, 2598054557, 4249317809, 3562854500, 484269782,\n                2535373010, 1557871774, 656903352, 2034241763, 777050079, 1802902792, 3756904133,\n                1141679055, 4129277659, 2972241705, 3435283434, 1415816578, 2554167499, 4240752855,\n                3423411208, 1505288832, 2753282826, 641148943, 1428513558, 3001607402, 1533357009,\n                1485563002, 2673090064, 3844139398, 2561836665, 2754722198, 970356743, 2201350930,\n                1066125294, 2733447686, 2885807404, 1881146091, 3757473749, 3701029696, 664108669,\n                1832641491, 4170070819, 2551964945, 3773757575, 661100690, 3207291047, 986146628,\n                3383827271, 2748125590, 3125972817, 202953436, 2278076196, 3110516930, 1168599337,\n                899932496, 2243910143, 2853281488, 3059106833, 2044583068, 4147861221, 980210874,\n                1469351302, 1095747203, 4153622485, 2513280487, 2134885617, 1218973898, 2842913398,\n                2337016140, 1594161385, 3481631667, 664510962, 1960349422, 2148836029, 1934322678,\n                2994217052, 2807256387, 586972467, 4178498347, 849308960, 2927784294, 951361420,\n                43586941, 3648229750, 3829346381, 2465163307, 2761354627, 290145462, 2055302756,\n                1957506334, 739571549, 1176710229, 586545560, 49762561, 879936127, 2492005742,\n                2451254722, 3053414952, 2429125990, 1577259591, 2688316136, 747050298, 1402431037,\n                1325712566, 1332667383, 2001670166, 2064093114, 1617959363, 1485971531, 2472812436,\n                433644713, 2191207097, 4235759995, 3894627335, 423077375, 3883830117, 1935314236,\n                399390428, 3709392940, 3059959818, 3661588523, 608272270, 2929333408, 1168195668,\n                1014359665, 1608963119, 1434740769, 2972657265, 140005123, 2823943018, 308312387,\n                1460444398, 840581898, 648060681, 594474654, 3815936159, 3321362565, 2723923184,\n                1387304627, 4087764401, 3188914647, 900026899, 3428649429, 443357120,\n            ],\n            &[2],\n            &[\n                3406323328, 1437213148, 3172074291, 3580970206, 509361480, 237281083, 795015447,\n                816594087, 2228031405, 2771964340, 4273929734, 3611483248, 33870382, 1800679979,\n                1174132590, 3808880801, 2623161229, 722129827, 3899957385, 254163815, 2027839137,\n                1054474142, 169607034, 3184835763, 3564636008, 3159869550, 3200899831, 241206548,\n                2386472242, 277074084, 1312960750, 3253603208, 3299988794, 2001720781, 1936109342,\n                4197993187, 2720279340, 3705901329, 370955006, 3234985000, 340427671, 3281730335,\n                745227198, 1609322938, 765008262, 574118537, 401712292, 3304798364, 2063272851,\n                1991525044, 2544645387, 4017998867, 3558728466, 508950878, 4246503638, 3527416569,\n                1898445853, 903897734, 3649484651, 2563954102, 1404672239, 2869315442, 3218531949,\n                3947288847, 3670363468, 3196146733, 2891736634, 1115855957, 2003404410, 3607223796,\n                333049480, 3450292464, 857797924, 3821154687, 73688414, 2940240320, 3004681958,\n                2711715733, 2933235760, 641242249, 1606904497, 1256934537, 1455408390, 2990631750,\n                2231685976, 1516663662, 4211813488, 775680722, 1686065755, 953397401, 2846902531,\n                1127878546, 2643735029, 38290869, 1615881341, 2413854321, 1315472301, 1616214705,\n                2917695496, 4148218743, 4258696849, 1728311609, 861478712, 1850401706, 3177380718,\n                1929863520, 1679722908, 1746431603, 625484937, 3441894984, 474753749, 2064025745,\n                3743725824, 3205246567, 554972664, 90620439, 603727869, 3355308857, 201216683,\n                3643436268, 3340080348, 3822084805, 433694918, 2730450197, 1291413960, 3928122518,\n                3536301210, 1142177298, 485662346, 382958943, 1922383639, 1224207852, 3978041786,\n                2536300002, 2882290104, 2550681515, 3125284589, 2706207244, 2123995239, 2756726197,\n                620302338, 643860526, 1519091714, 2811159746, 620831961, 747749790, 4234219486,\n                3839492109, 434640682, 3515645257, 377435626, 3002722589, 3449736432, 4247384093,\n                301245934, 3125659472, 1614908177, 2112184032, 650630492, 1745801604, 3916359745,\n                4232243904, 3434748876, 1773785657, 3076590870, 2808388038, 2662142992, 317806835,\n                2316000017, 2973502772, 3446099497, 921292530, 3679071298, 2418515437, 184601389,\n                2602694528, 1379032605, 629857518, 2498812614, 2883185264, 1561661304, 2328919226,\n                3205863336, 3082815661, 2741957664, 1771875666, 1720200563, 1495377715, 1857046184,\n                827146152, 1907180130, 3270990004, 695333232, 665408820, 1614127720, 1875284305,\n                1074756407, 1714481511, 3427196833, 2977599359, 531127355, 2445543921, 888001330,\n                2098527764, 3269327839, 2204466715, 1366782935, 1347889789, 479690362, 1872069165,\n                1666602647, 2771347873, 2625720435, 3337206684, 4261602004, 1908074343, 2391517538,\n                1479533928, 1069369919, 1736863859, 2247189883, 2754033409, 3222422367, 865055697,\n                1483030511, 1872918152, 2334541320, 2659208136, 1817963243, 938114447, 1091767874,\n                2063578826, 2306967373, 1014685314, 3767981460, 3394910046, 3762192898, 21709636,\n                2808026654, 323922863, 487838342, 4007808710, 2691217180, 32532376, 0,\n            ],\n            false,\n        );\n        // - us1_len > us_len\n        test(\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                33554431,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294963200,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2097151,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294966272,\n                2097151,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294934528,\n                255,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1048575,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4290772992,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                32767,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294963200,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                15,\n            ],\n            &[1],\n            &[\n                3912025888, 886896747, 3373539372, 1267971119, 2147779021, 3312219999, 2719874009,\n                3172532945, 2640908453, 2045545547, 3615956967, 4080410788, 3972086932, 3552447088,\n                3319021097, 3809844465, 1918653728, 747400109, 1879308392, 3962271345, 3614322235,\n                793758289, 2287865193, 3157669196, 1077683203, 1670927043, 2580216486, 3905212400,\n                2918489481, 93135036, 2143954792, 1799458293, 3683476316, 753701792, 1089322801,\n                1358135032, 999717196, 806389310, 1201158081, 1383118311, 753409317, 2686010612,\n                3636712738, 194326449, 3996942488, 2228506655, 1941500305, 143503947, 3241601529,\n                77371472, 3156241712, 2656403371, 1947068169, 144587741, 230138483, 1706046558,\n                200645164, 2214318189, 1024476384, 704795680, 48216132, 4092341579, 320876282,\n                994006676, 3187326006, 4232852015, 3916528332, 3569555832, 117636514, 3843928238,\n                1821537056, 3160390627, 170292086, 2631142219, 3914822703, 564666372, 4056933637,\n                853978997, 287616595, 2408719114, 3434192280, 2130741740, 3168128757, 680434144,\n                3404585176, 458928157, 367835397, 4110770980, 2695931191, 11343704, 698798114,\n                3625673959, 1043790052, 42058605, 66384410, 184835270, 2315385908, 1364230376,\n                892966470, 3357617286, 108301707, 2803459914, 2217958282, 1725796552, 4071520189,\n                3010175533, 3524994779, 1453496319, 2567457858, 3860171805, 655593324, 3899607441,\n                647072905, 3503789019, 283753888, 2432787665, 1918775105, 4034937401, 461045025,\n                1262551920, 137876938, 1626022576, 2125039095, 2951694631, 2525624750, 2605995038,\n                3556223501, 326613547, 2589685852, 3986176776, 2395752193, 2831210611, 506343935,\n                2171409011, 2461001173, 1996789217, 3980633713, 321717431, 965251765, 886772948,\n                64269788, 4115781956, 1635655185, 2849299284, 1390620294, 3395985232, 2482124294,\n                35597591, 3997281025, 1453879097, 2766291359, 1604081205, 3973715212, 775011402,\n                996856315, 3314398346, 3763730761, 2868042149, 2548185993, 3658638415, 3582069455,\n                2534916356, 2262189034, 2470576613, 741902204, 3798471577, 1042223894, 2744176327,\n                4102481616, 3815841673, 2528021725, 1956439567, 3626885367, 1826970821, 1833655643,\n                2182769461, 2901285886, 3148028130, 1549794171, 3867025612, 2540838114, 545015290,\n                3981077932, 2059392483, 3012154937, 1616718892, 2232172984, 4106220952, 3821667025,\n                3698143135, 616003913, 3801506973, 2784367244, 975154127, 4114993094, 3560006433,\n                2380530636, 2790971794, 2341455943, 1784545866, 3140308722, 1611418568, 292814187,\n                2704783587, 1092745053, 1821185432, 3755423279, 1274854684, 1338434098, 982681233,\n                2404821761, 776511636, 163394779, 81014300, 1775679315, 3796004898, 3396729377,\n                3095436406, 4090460397, 2133841999, 1036521501, 71056224, 3099728386, 3974229113,\n                1681723397, 2384237717, 2740596008, 2690063482, 3343120218, 1712550476, 1731513942,\n                892884876, 1858597869, 3964286687, 565337651, 252743644, 1829273449, 2466499588,\n                2561551294, 3302171118, 1018994570, 2589015429, 1224020052, 3359662565, 3099494184,\n                1311043757, 3341028275, 1082339712, 892972502, 1829253720, 1001497557, 117124196,\n                542653614, 2450347600, 276857137, 1161175520, 1063660386, 2307654631, 4237080774,\n                2251229868, 392169910, 1391102821, 3540553702, 109530896, 2, 0,\n            ],\n            false,\n        );\n        // - nn == 0 first time\n        // - n != 0 first time\n        test(\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                31,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                31,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294934528,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                63,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[1],\n            &[\n                96334512, 809184833, 609979439, 917841564, 1376291946, 1335372660, 2164003694,\n                2673108150, 3650205264, 3068908070, 2927066464, 2340580023, 529792913, 1825835699,\n                4031333697, 79641126, 1524940942, 2201130345, 216393180, 4071458329, 2334778398,\n                1463729248, 2688261544, 961061519, 734363607, 2195650904, 2552076064, 304989719,\n                458920782, 688145973, 667686842, 1082001847, 1336554075, 3037365544, 1410343154,\n                1271544010, 4011614679, 1337488001, 3278149327, 1487025366, 399705731, 2067502643,\n                1679754713, 3078833879, 151612438, 1393885150, 2434664396, 3337954982, 79498345,\n                3108679211, 3674525568, 793907199, 3009814506, 558417352, 3284867560, 1384771311,\n                175686933, 4116330913, 1883204498, 868169797, 3628031203, 3535175829, 2431624713,\n                543336157, 3786207655, 2343717122, 3270990563, 1420835158, 4174715792, 1691072618,\n                3024039265, 998065535, 2793871814, 1953366923, 3134561452, 3159790431, 4185140253,\n                181607511, 4190203131, 882632170, 656530666, 2670822774, 1000882492, 3808856169,\n                896665594, 824911035, 1132193821, 3890029849, 2872143627, 2480131083, 3557471007,\n                1229275468, 3208259312, 3837824516, 857041242, 3857046659, 2911246604, 736370418,\n                1052532875, 1000185943, 1218613152, 3313489721, 3740882987, 496443522, 767956888,\n                1519603218, 71709979, 2350234153, 2114565927, 2855426752, 3369805903, 1978241900,\n                1002352731, 3241499607, 3388983493, 1778735503, 614637734, 1604129656, 1918912258,\n                2576004269, 1928523329, 1455623302, 2515668857, 2673750085, 500092971, 2756790224,\n                3804228508, 1870441493, 248221761, 383978444, 2907285257, 2183338637, 3322600724,\n                1057282963, 3575197024, 1684902951, 3136604598, 2648660013, 3768233451, 3841975394,\n                889367751, 307318867, 802064828, 3106939777, 3435485782, 964261664, 2875295299,\n                3405318076, 3484358690, 250046485, 1378395112, 4049597902, 3082704394, 124110880,\n                2339472870, 3601126276, 1091669318, 3808784010, 528641481, 3935082160, 842451475,\n                3715785947, 3471813654, 1884116725, 4068471345, 2592167523, 153659433, 2548516062,\n                1553469888, 1717742891, 2629614480, 1437647649, 1702659038, 3889662993, 125023242,\n                689197556, 2024798951, 1541352197, 62055440, 1169736435, 1800563138, 545834659,\n                4051875653, 264320740, 4115024728, 2568709385, 1857892973, 3883390475, 3089542010,\n                4181719320, 3443567409, 76829716, 1274258031, 2924218592, 858871445, 3462290888,\n                718823824, 2998813167, 1944831496, 62511621, 2492082426, 3159883123, 770676098,\n                2178511368, 584868217, 3047765217, 2420400977, 2093046690, 132160370, 4204996012,\n                3431838340, 3076430134, 1941695237, 1544771005, 4238343308, 1721783704, 2185898506,\n                637129015, 3609592944, 429435722, 1731145444, 2506895560, 1499406583, 3119899396,\n                31255810, 3393524861, 1579941561, 385338049, 3236739332, 2439917756, 3671366256,\n                1210200488, 1046523345, 66080185, 2102498006, 1715919170, 3685698715, 3118331266,\n                772385502, 2119171654, 3008375500, 3240432901, 318564507, 1804796472, 214717861,\n                865572722, 3400931428, 749703291, 1559949698, 2163111553, 3844246078, 2937454428,\n                192669024, 1618369666, 1219958878, 1835683128, 2752583892, 2670745320, 33040092,\n                1051249003, 3005443233, 1842848845, 1559165633, 386192751, 1059585827, 3651671398,\n                3767700098, 159282253, 3049881884, 107358930, 432786361, 3847949362, 374851645,\n                2927458497, 1081555792, 1922123039, 1468727214, 0,\n            ],\n            false,\n        );\n        // - nn == 0 second time\n        // - n != 0 second time\n        test(\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                536870911,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4261412864,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16777215,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294934528,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[1],\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                536870912, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 1813905408, 2994399669, 1767025046, 1779086942, 2560788905,\n                2495652644, 1950438505, 3389856413, 1199187240, 718638698, 161601559, 2077442333,\n                4075407509, 3845277390, 14683020, 1999538680, 1419751200, 96817827, 3347799490,\n                3662737933, 3342437314, 3102257506, 339105132, 3272853101, 3730379334, 787705221,\n                3554111725, 2785203515, 1774419661, 1465128767, 2602265406, 1521228109, 2739053496,\n                1046627426, 3656923613, 765353033, 1104147101, 671302339, 3262461653, 4078630863,\n                1657670358, 2544039916, 2179179584, 497830601, 1482049256, 126030725, 742845439,\n                2175237293, 4033678621, 2228415677, 1670564945, 2759306986, 1023439704, 1488958197,\n                3429597203, 3123171067, 3318052400, 2984530569, 3715635421, 183121370, 1084349991,\n                1691629951, 1899065687, 3149068608, 826500663, 2281938276, 3041462185, 2178159831,\n                756736147, 1862529845, 2995511255, 967989798, 3903250574, 1193472430, 1277486602,\n                3518754695, 904406626, 314088647, 2374901767, 2196134749, 183213822, 926245790,\n                3702808932, 3957649599, 2848150668, 4213124583, 1670145672, 2807366853, 1385422640,\n                2991547553, 624165205, 3881438754, 2305933460, 3911438826, 927582491, 4032889069,\n                347916803, 2134561554, 3302645587, 1357660924, 2154811081, 1280187591, 2735553875,\n                373975768, 678841196, 853469015, 3278550564, 520475764, 3157311891, 3489429195,\n                1060397627, 3203177479, 2337930986, 58133713, 1525621667, 689658334, 816131014,\n                3860225340, 4013991369, 1328655415, 4175620430, 953950024, 4222675682, 1818741405,\n                1159575257, 1412128505, 3305654799, 3520417706, 1008173334, 3164638212, 862034677,\n                1310804450, 4180955140, 2973360708, 3424935052, 3917844393, 2359655519, 2586539049,\n                2904566386, 343412185, 765339035, 855298558, 2095812656, 1404030208, 1088714807,\n                2226459449, 469240772, 1549973701, 751095118, 434095298, 3043907071, 4193862455,\n                196583660, 2253182506, 1773878770, 1865148082, 3446101993, 1149907000, 2889378134,\n                1974364104, 1551603166, 2821220488, 3626740916, 3777658710, 746300305, 3535016512,\n                955214869, 280863174, 335526048, 1145561312, 430003002, 927068165, 1706340717,\n                4284648397, 3372557344, 3424201062, 740939606, 1563007928, 979547149, 3506089694,\n                3740685364, 2042197748, 2097283242, 199931170, 544120174, 3139948651, 3136397605,\n                479334915, 3367331783, 2456091806, 458065766, 4035284494, 713748985, 2151274283,\n                1168495352, 1499758476, 3008738604, 1823792739, 2502749346, 592079210, 4013832609,\n                2543711568, 3491177809, 4058973993, 2679304829, 817407178, 2488687339, 3039082602,\n                2949402470, 4023391299, 2054197820, 2261532032, 4109107205, 2058289294, 3334809850,\n                4141674277, 960086508, 2551762669, 3957189062, 1960976610, 459116317, 4282783819,\n                110240464, 1979653617, 2054424813, 3849007869, 811381958, 3202923933, 180903478,\n                436575542, 1558945067, 573205897, 3911059745, 2987264945, 412640580, 2125178023,\n                1306319004, 1139223170, 2987568401, 2139924318, 3170068581, 548871255, 1042520000,\n                892658617, 3449354772, 1669391581, 3971788655, 3934256792, 2934498383, 803442713,\n                0,\n            ],\n            false,\n        );\n        // - limbs_cmp_same_length(..) == Equal\n        // - c != Less\n        test(\n            &[\n                1582207393, 3257769320, 312002593, 3788671422, 2562360222, 2018485950, 1642000633,\n                3752939185, 762402457, 2742058693, 4078581054, 758428677, 982403960, 3766131700,\n                1255139079, 3108603950, 126568705, 2528314074, 2415295075, 21918673, 3116053283,\n                4135693331, 194784423, 1808182332, 402979294, 596411796, 931794242, 195206232,\n                1868897994, 918784542, 1261363777, 1006480341, 1062659638, 1058805882, 3206714055,\n                2895853157, 3416291273, 514638714, 2849366146, 3426402264, 1666868481, 1897213704,\n                3045828738, 1446169376, 1041377319, 4238908508, 3638156887, 883962932, 816559901,\n                2638036722, 2363061328, 3964491706, 72585974, 925161746, 1218735144, 4004333943,\n                2080361157, 1967088019, 2626134784, 1335072842, 838772777, 3390829698, 415396526,\n                3678882944, 63941908, 2600794954, 1817578917, 3433169905, 1940244273, 1945108649,\n                4224113008, 3718898573, 818893106, 1481689799, 3896622334, 2229854427, 308038381,\n                3666467894, 1888945489, 2732049108, 3922935639, 1169676153, 4024049892, 4187442278,\n                70141574, 945492349, 2888651303, 2991638890, 3912330221, 2097621812, 2083222651,\n                1545563177, 3543864532, 1628613583, 88188644, 1615033727, 2745317568, 2729755781,\n                2565654320, 223793519, 1473930704, 1340424864, 2241709609, 1183201612, 3538474481,\n                4132703163, 1383006083, 3710294684, 1649559007, 1138758070, 497232832, 385488871,\n                2030896967, 2012159214, 2690074301, 1177105881, 276967925, 2552357416, 1497159533,\n                1249045564, 2558564347, 3731938099, 3299279784, 2013438962, 2176217881, 1044900010,\n                3368297890, 1359676847, 2543368247, 311995556, 2992582099, 1265877360, 3340992352,\n                2640095305, 1496247286, 3736589714, 2190815591, 1130837558, 1293450511, 2472175246,\n                2117374312, 155971543, 2522195432, 2309601428, 4120082948, 227295766, 3923631693,\n                617757311, 415744536, 1570375946, 949708862, 1885319289, 1417726186, 526651128,\n                4220673038, 2768125994, 872982153, 335787553, 3117513091, 2641049716, 269634766,\n                870696055, 3692553352, 3202663357, 979816689, 1199675084, 721523678, 1405171049,\n                2436925869, 901381817, 3604940484, 1712751101, 1793704398, 1145600581, 3353832520,\n                2969573925, 1532429694, 3128602535, 3075652125, 3969048034, 3626545438, 1523568077,\n                704701136, 2085974891, 2009191184, 3585301931, 1887341277, 1421410368, 3087960281,\n                1112574025, 2166745609, 177664096, 3179243282, 1920685246, 3406716775, 1983173180,\n                3101662354, 764088114, 3426634938, 3196605606, 2737417379, 1278512447, 1293248712,\n                1865368759, 327254618, 1774912263, 2669405639, 208073317, 685646662, 2122803096,\n                3747942556, 3275924256, 1123816196, 2550246338, 650674914, 3952581813, 589693641,\n                1650990718, 572049977, 2097148216, 1404038978, 2620523718, 742609424, 954335977,\n                2825152969, 3540511318, 710103906, 2787842272, 2704858874, 1527789354, 812157329,\n                2665361451, 1206140479, 3171524710, 3000676456, 3254291138, 150412446, 3929427198,\n                203714225, 941149876, 849467518, 2614757179, 265139398, 4054468456, 224160914,\n                779119629, 2564623259, 2376221955, 2179586090, 1198887503, 681,\n            ],\n            &[\n                435825370, 4098074553, 3454392562, 2463980626, 2066205125, 4034750267, 1235550246,\n                3612964936, 2824559949, 1670195687, 438223870, 344385955, 444736095, 3199444570,\n                158172638, 886704977, 2044060213, 3288661494, 4001830393, 454465757, 3064791897,\n                2782564601, 3955023420, 346666935, 4203002761, 275338593, 522709058, 1284976224,\n                2948751667, 3367485833, 1233249232, 249971808, 3540695933, 213088602, 2833797476,\n                1742024205, 3452629647, 1696507510, 832914218, 1580729092, 2465374891, 68437950,\n                2231956715, 3260684823, 308203263, 2746696707, 1043692812, 3437464714, 3825284901,\n                166045774, 2083375883, 770398732, 3567792379, 4235901693, 3593552254, 271363761,\n                2808185977, 359264175, 3140291166, 3520675423, 3711176850, 951843838, 3535829616,\n                2487240547, 371184029, 3071441064, 2845112039, 1832840857, 2692234524, 4231322034,\n                3355583776, 4188014983, 2817671218, 413502535, 4284697057, 1051690593, 1240409713,\n                165879548, 2316064371, 3497882311, 2157985374, 4048825739, 2209831432, 680648571,\n                3859995817, 3381008940, 2130982229, 2372662317, 1074987446, 1352350087, 2015117098,\n                1569849261, 2562226880, 1758118230, 880317596, 225881481, 3197302071, 165280429,\n                3563559378, 2815615927, 3350513453, 2901794431, 1943518670, 831985412, 2025414377,\n                93627198, 1529173611, 3054993858, 2314502307, 208142722, 3072703531, 2154180133,\n                2987426635, 588063047, 3552374157, 1437548625, 3219728668, 570531186, 120668486,\n                2393191311, 1075671596, 1946938953, 2738773367, 342620223, 2383633904, 3866173204,\n                1097677156, 3538147128, 3585976646, 3571751243, 3324323588, 2709817236, 1679128706,\n                1646091223, 1428791560, 3878051836, 1674262915, 297087248, 1609058557, 1953194481,\n                2343513420, 2049634662, 1189446703, 1871140029, 710948767, 3681771268, 1790615645,\n                2587436460, 1102785925, 2584527240, 3983566595, 3602286784, 869716973, 1560082461,\n                754477791, 658106538, 2945530833, 1544959316, 2200987146, 374766255, 662433671,\n                264742168, 1832966994, 687330684, 222172109, 2483932397, 3256908853, 3984808097,\n                1333166330, 763252245, 2097445399, 3838271657, 1836132920, 292130122, 1366967552,\n                1839326060, 2996527157, 263034457, 2169887190, 3624556345, 2979074912, 4271570982,\n                3150483255, 963738217, 1476868390, 2501930333, 2174990124, 3674869563, 1585059704,\n                1918987053, 753723008, 2510106958, 2625196367, 2139177155, 3881218468, 258089974,\n                847766473, 2260969254, 4087904289, 385192817, 4201377213, 1003557987, 2550497304,\n                3137880396, 2485029919, 1649596665, 2666506058, 3979866806, 1142714106, 4249830455,\n                1420179693, 3527969716, 3003794782, 3592819030, 1341666099, 2396616618, 628721075,\n                2882635818, 3682568652, 2713784147, 250751105, 243141974, 3458061894, 1593432079,\n                3115289400, 1287899488, 293287525, 1587078352, 1684392149, 1243277372, 52614597,\n                2955462792, 1786223494, 3348936519, 3893130724, 65397082, 2743236235, 1417893267,\n                236140504, 2014414835, 2586217097, 843553596, 47,\n            ],\n            &[\n                533748887, 249255803, 2930278111, 2944470994, 3468438302, 1853367511, 3473647788,\n                136162040, 2512039442, 4104038916, 3852375212, 1275965329, 1008075871, 2214169813,\n                1888868725, 1279476908, 4276240090, 1145241832, 967923289, 3300068750, 787590574,\n                372485986, 1752804777, 563557630, 458612420, 24065909, 2138189643, 1735118829,\n                2777615332, 4084773909, 1994648171, 1468124229, 3843301824, 3048990130, 3644669511,\n                2843255684, 1878415349, 935329872, 2974790965, 541343777, 3578971699, 3084472759,\n                1424633701, 3685324111, 3104832506, 814688603, 2875695455, 3922894541, 1129836145,\n                5401754, 2147990257, 3049844880, 2173716916, 938037603, 3330445082, 3666254041,\n                3405270910, 3095678827, 553456595, 891085809, 3061727528, 3662498742, 2303227072,\n                1295539877, 3135256485, 984687031, 2062195016, 4160985717, 4256936349, 1127108300,\n                1822161590, 1231105886, 799858776, 1165579553, 1680070401, 2892850160, 648277660,\n                1647906015, 1349312712, 764587048, 3479139752, 2548452125, 1587150396, 1936309995,\n                1397979205, 1160028331, 2481265236, 4096534487, 3145854678, 1359507566, 3145122135,\n                1464105608, 1341054633, 2384267946, 3072197904, 4101048745, 3497220211, 2496500822,\n                722428108, 2759126028, 157978299, 436271355, 2915111871, 819788815, 61498946,\n                531442637, 2748307930, 3964009512, 907090206, 3579477513, 1410311474, 3879339413,\n                3797360756, 525701452, 1865404342, 2036819036, 129435563, 1301441027, 2315064858,\n                37796474, 2259680720, 3209271106, 3616621433, 1524540162, 742243486, 4244739241,\n                3963525923, 3841435812, 631237661, 2750627705, 4061472984, 4187741587, 1602558897,\n                3739064311, 1787560972, 2417808286, 1669713644, 242684701, 4212963222, 3184994942,\n                2931588398, 3055841256, 164516699, 575009540, 3804101567, 3503774895, 2271510891,\n                2575068623, 3311266347, 600516698, 1830644170, 197244387, 1762254458, 2485090809,\n                2054999517, 445307681, 1916458424, 2764936458, 3968851404, 116007945, 1259880908,\n                2990377981, 3157975500, 63446352, 2623120799, 2892145188, 382309118, 428854973,\n                1627463852, 2943880856, 2716994163, 757412094, 73981451, 288837540, 683761684,\n                2645114357, 1148980595, 115985531, 1159455296, 2012810946, 3906610855, 1070751850,\n                3855881544, 2899111698, 1698770184, 927911082, 1201557705, 2190432453, 3174200176,\n                1716956464, 80922238, 1516540063, 4140722877, 2868191373, 4074259242, 3395204892,\n                1374888410, 569580618, 1352129381, 2834006812, 3958858137, 3965389351, 2153688696,\n                240913347, 3717468255, 1650698409, 3732578951, 4060697881, 1987293497, 3608486299,\n                2752719263, 3992727960, 96185389, 3861467259, 821639014, 1177132211, 3275501405,\n                4849019,\n            ],\n            &[\n                1655755711, 4258340418, 2774516366, 1572935911, 499947623, 907167292, 3725633407,\n                1192948598, 1407557914, 2562035879, 632809853, 3145196737, 2065022779, 818461714,\n                3282493345, 794082591, 4062248109, 4105226099, 3252991187, 3950905876, 2145419927,\n                1859968878, 2278702340, 1297226377, 13775, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n            true,\n        );\n        // - n == 0 second time\n        test(\n            &[\n                104199695, 1437842355, 3026540896, 1036691142, 2895760091, 316986459, 3848493166,\n                4283163139, 1409731068, 2162161861, 3180981287, 2664973704, 3129778597, 1141759869,\n                3423483599, 3304860181, 1499458172, 2283443318, 304208206, 3898070080, 1624380249,\n                4217356185, 3984965450, 1989320468, 4046024996, 290564828, 982998126, 714749497,\n                1256133149, 1964245093, 1989969476, 2845229677, 75994139, 1534010229, 3551668582,\n                437558754, 2400783907, 1104529196, 2628109158, 767576225, 3386003603, 2589581389,\n                3197373266, 1119570806, 2388054566, 560919780, 2181214692, 895228346, 2455964730,\n                1236092704, 3460190245, 2187848751, 355369047, 1999986258, 3567727382, 1691926629,\n                2725212068, 2592492178, 797372755, 1342659622, 1706103226, 2741335822, 683303027,\n                2714389761, 3546978425, 1986412131, 762213298, 2333449774, 778670753, 97719623,\n                581978613, 3531804453, 1122531574, 1722591132, 2538512178, 1919025659, 3171826961,\n                3494777585, 3878057786, 1159079409, 1839284455, 1154718578, 2665661658, 897285327,\n                1500853657, 2633085447, 1751356374, 3270858770, 1163694943, 3330045700, 1488678831,\n                3027918693, 502928061, 1337476314, 3692361284, 2178683191, 3096849964, 970332766,\n                1824923766, 846751495, 2918346590, 70616406, 3836757211, 2684780384, 2463029602,\n                3457312899, 887456732, 3244684159, 1709425071, 1650827329, 1114331473, 2300037523,\n                47504219, 2349860938, 514226917, 2830450926, 3649882524, 3714094143, 301323195,\n                4142782943, 3785993652, 866247992, 2164534671, 2737799129, 3275770468, 215424696,\n                4257046307, 1733065842, 2434034911, 1462340609, 3642973392, 3350853644, 4199792744,\n                684333086, 217713765, 3411993450, 1792335767, 4171842881, 159579156, 2430618740,\n                3131183234, 3163246383, 2128439763, 2401347699, 2936760275, 3236944394, 2200904017,\n                2436166477, 4193014474, 3613539040, 2916219306, 4261812949, 115873482, 2180021985,\n                4055598752, 1260608904, 2416550157, 1259155018, 1431188781, 1176329051, 2299641742,\n                3980571345, 1599289272, 1782362083, 3811356761, 1974756300, 533380582, 3641430046,\n                832768712, 672407572, 1502225325, 1016817644, 14093203, 1980541787, 1908462143,\n                3913154473, 724095260, 1182316086, 719426427, 75511913, 3523894057, 3990195494,\n                2120530771, 3562485018, 1433690638, 2518584164, 1493664787, 3968793063, 3670159139,\n                157980348, 1301197374, 3305985080, 3941044403, 612257166, 3771911392, 2763453419,\n                2718688747, 3693090746, 589991197, 498197071, 2438022286, 3991964070, 377079193,\n                3099592329, 3321736969, 3902471945, 2307760142, 3013676133, 3258936160, 4011810226,\n                1053219984, 2837546691, 1856062985, 2092610837, 91102249, 406247891, 890201919,\n                2559127506, 338532027, 395154770, 3275565770, 1258530084, 2939576662, 2055294057,\n                1883048671, 3836169741, 2026424182, 3339579277, 1542609345, 417648228, 4191728149,\n                2895752032, 1515160584, 278532504, 1393858866, 1730994375, 3794676496, 1670361915,\n                1258111291, 2422641149, 2347194379, 80193494, 2358530906, 2877787771, 1965418230,\n                4205347720, 2666879163, 4215296303, 2916779693, 3935289306, 3244538076, 1632052180,\n                4176725684, 992286325, 2739073795, 2079197711, 2797905589, 2449598406, 289423436,\n                762177014, 2363661744, 772167940, 2765100761, 198147685, 572172334, 3817619946,\n                162288540, 1223981567, 540177774, 2154166987, 2653356928, 3206160568, 1862076861,\n                3133558385, 474824123, 2525460202, 3924632969, 1146129872, 1432186566, 737582770,\n                3316793636, 3709987676, 3557072993, 567470616, 1129703040, 1521364280, 3566052322,\n                916273230, 2293310523, 1377033267, 1508571570, 3382970810, 2996523808, 1581520543,\n                2618222496, 3288125825, 2313878894, 349906863, 2219317771, 3176122714, 1013378826,\n                4116023745, 1921798849, 3062375628, 2736960803, 2501959999, 1510561246, 1700569625,\n                1652836989, 3312274215, 4195830099, 1132143254, 950525497, 2316560086, 375651095,\n                2664099671, 455151019, 1159444553, 4198810519, 3127984438, 2144120008, 1969060002,\n                562539184, 1602239482, 2852481959, 2095454819, 3210933640, 3500352077, 3422305025,\n                2014869566, 2974700896, 3465912392, 2040467605, 4197300028, 3591134045, 3895974116,\n                1820422501, 1395818068, 2660152096, 1916184939, 3260276758, 53585995, 927898271,\n                2259302740, 963522240, 2856612864, 3450205940, 3367413678, 3535931570, 397649639,\n                3700183847, 1270654564, 3500464902, 3997758233, 3130672822, 2562223359, 638317405,\n                3181668171, 539650504, 2914453051, 645816251, 4007289298, 3438058969, 2770073590,\n                864060896, 2320524273, 3692263013, 3473619051, 3882200592, 499549190, 2692529571,\n                1895097838, 3793943961, 3454593367, 1512683055, 852698565, 1995890144, 865090611,\n                609912127, 2960073872, 1078887,\n            ],\n            &[\n                3965328483, 312519701, 3403268855, 3606492602, 1902761898, 851349064, 3139262646,\n                633064190, 2260801841, 3139511175, 2981429315, 570792856, 3276826258, 3740173343,\n                2258820496, 613809729, 241642072, 3441475901, 4294219823, 976984900, 2389777673,\n                4191459734, 1003327410, 1302790361, 2451013524, 2641182095, 3622343124, 2806631117,\n                3967790700, 581646251, 2019686780, 2032370136, 2076036058, 856161788, 3365012291,\n                2890451318, 2127795458, 2187590985, 4093939520, 343783955, 4242308697, 4157888926,\n                2564079477, 4260723333, 221747269, 2643548554, 3833528808, 1763870742, 825076470,\n                259966747, 1095002154, 931639969, 3831275768, 2810876375, 3231187357, 3440619698,\n                2434935986, 612813763, 1378882183, 2162485107, 1140428311, 3695900833, 3397094290,\n                4162195979, 2662618085, 3751543150, 3243820436, 3516498989, 707780244, 2079085110,\n                448686345, 1895725327, 2371954578, 512402760, 2522669399, 3692228697, 4274764985,\n                3682675544, 3852971158, 3189904769, 3141125752, 3990040037, 688067094, 4206021309,\n                1411303768, 751179620, 1438168058, 3448172742, 917372130, 1562060869, 515503757,\n                2481107086, 2276549351, 4210575064, 1210846101, 3889280108, 1149707690, 3998423549,\n                450077793, 3069409039, 1205057532, 4241449813, 4263835068, 777002153, 97116780,\n                1862501041, 4173027391, 538950023, 2024750625, 1067091172, 3975089902, 3595618138,\n                1162626458, 2892893888, 185770841, 2582369494, 3927002631, 3209126940, 3017762169,\n                3322211458, 184442973, 577978350, 564069165, 3126111172, 1558987521, 3158591140,\n                2367515315, 3627578322, 3638689514, 2197481806, 387613, 3780351852, 2801314434,\n                1919960640, 414138073, 161239652, 5955360, 4204709093, 49134550, 1616981665,\n                2152668401, 3606726895, 1857761242, 1299061544, 3099986598, 3846390597, 3355161875,\n                595322253, 2252701581, 2283337465, 675228606, 2653548638, 3430616197, 2380374646,\n                3784410660, 1379122536, 3178229817, 3972552968, 3447966842, 1961475461, 918042062,\n                1365972881, 2129295687, 2448607551, 2884167968, 3568778297, 2408690044, 469704050,\n                304852349, 2906236085, 2120391091, 606392149, 1797001614, 3658187294, 2116257019,\n                2708625014, 2498918970, 3223950057, 4105341944, 243352585, 3784332349, 522017452,\n                1593525595, 4137737627, 167793374, 4087606703, 344557611, 2032896579, 2593781680,\n                1431393249, 141052093, 2496087765, 2700336339, 516501742, 1876246139, 1822328287,\n                2252547797, 4061227450, 2006777028, 3501565120, 3466396566, 735894510, 255684379,\n                303584386, 1336037903, 1323979436, 1064067294, 3553551979, 2832942530, 1268770967,\n                1027134407, 545735300, 3866535246, 2986685637, 1613305389, 1267557025, 31509612,\n                771698397, 1878270300, 110063942, 4276370389, 3260973919, 2964940734, 1109302596,\n                1411099702, 4020146211, 3169853494, 2389480541, 556890992, 1074682663, 1708332475,\n                2658991487, 2894729410, 2296152345, 1870102242, 955236482, 2125245922, 1470432646,\n                1889719140, 3468723644, 35016220, 2579705046, 2403600204, 2455839109, 738153092,\n                361506106, 1501550475, 1570537857, 2512180427, 2079164570, 3284728752, 2525205632,\n                1765298251, 324508463, 4289185078, 3262124640, 590432268, 3609992720, 1056480497,\n                1521962672, 2902938979, 3633169769, 818640538, 3205732694, 3783707657, 1320287971,\n                3427819133, 123698783, 1954647368, 1478731664, 729732421, 3485056101, 3384149754,\n                886686555, 3524117645, 3672706053, 3467528186, 1825239229, 3605286168, 4252587265,\n                2476737792, 1468148598, 1767076404, 3098062795, 2235174734, 3938633722, 3377437243,\n                2055298570, 974103332, 1521104891, 1331281005, 3901922961, 2788866965, 1326440607,\n                3830433543, 2349058686, 1891550867, 289592648, 833149915, 4062577431, 300173440,\n                3618259462, 2437802253, 1988806398, 1196009062, 1693726935, 4261250055, 3358655485,\n                1354639338, 4217909066, 3173323323, 1256774815, 2873946595, 783721831, 3287664797,\n                1212500109, 544495281, 3943757093, 3869342488, 3580616897, 2288353173, 1381949567,\n                1954109845, 1071065683, 1907373154, 1605862239, 399825655, 1608845741, 1366351932,\n                1757744839, 2456500252, 4271660304, 2736932691, 1256196079, 654792440, 3432423047,\n                814117095, 3916828311, 1478775709, 2623979306, 3502313771, 1912113011, 826313993,\n                2137260095, 4198684443, 54736831, 380668741, 872309827, 3132896276, 1131528234,\n                1143308601, 528742460, 3890747269, 2898367605, 3531963195, 2576564587, 2690837364,\n                2676539983, 1748034501, 3722941468, 2157585074, 738387831, 161914314, 3886930899,\n                805359701, 84535132, 1019698896, 1024816471, 2120663635, 4600563,\n            ],\n            &[\n                436512665, 1372743407, 342109034, 2762999440, 1801741181, 1128075399, 536773409,\n                2462344174, 4092132461, 1413817282, 3712114490, 446843050, 2277642284, 924335942,\n                250799808, 1300467839, 3708770080, 346693759, 1462440153, 2514050355, 2607744870,\n                572189306, 18842802, 85605861, 3453161777, 65109244, 1981480639, 1036404070,\n                3325202117, 858703184, 1098140435, 137595022, 1796280951, 4121604160, 927712201,\n                2983534703, 1277109179, 1842338521, 684621561, 3003060670, 1334445980, 3716987280,\n                2509263629, 1481158588, 101476260, 2332533799, 3920104238, 1799849987, 289899178,\n                3790057285, 3090879719, 1847908743, 2289570281, 899352588, 1237257524, 3478208269,\n                2864532864, 4237285852, 2021619931, 2299181539, 2990516063, 1146232131, 1906740225,\n                365885015, 436254990, 1572217307, 2276239798, 2938321029, 3411408571, 782341583,\n                245501560, 1212705343, 3987607268, 2685812792, 3162630759, 525514772, 1738934514,\n                4026775891, 675427556, 2638310706, 1872560581, 378254209, 3521602859, 3209772533,\n                2171756894, 1916654768, 464606995, 1021746380, 1509799815, 1803124229, 1626950142,\n                1757247127, 3463260849, 2059493644, 3328028905, 714292268, 4221410307, 3024039287,\n                245477866, 4111629244, 2454388273, 2288605764, 4069258877, 2417991112, 1008037684,\n                1584471268, 480491917, 657289197, 740153804, 3304298858, 3549803564, 3389482897,\n                2285883880, 3754282415, 3452581852, 1300983995, 2563854813, 3387253149, 3144283055,\n                4223958762, 2984826191, 3538501116, 1630274809, 3571211850, 3145706384, 119892266,\n                3268130561, 2893468680, 3796377730, 1313792196, 84565900, 2317626527, 1585112821,\n                2831830124, 3879773053, 3823642743, 260829176, 113541293, 2698035069, 1162236214,\n                56045023, 2572314428, 3303774518, 786546397, 3304627813, 2532190633, 733612212,\n                3194392916, 1538645070, 871903777, 346960285, 3824030942, 991737609, 660569608,\n                25531145, 3125334834, 2019398137, 136254844, 2601227241, 3740691089, 1400597961,\n                758494376, 1289737416, 176798002, 52677595, 1282844193, 2029711214, 1154925510,\n                924664133, 2384558292, 2657323714, 3032100806, 2076618856, 3874064840, 2301862464,\n                2613824074, 2408544438, 3475871678, 4286594061, 3888658535, 1599077513, 3091123524,\n                691764425, 571533226, 643388614, 1946732585, 231085233, 3636702918, 3681581111,\n                3187061512, 1902159644, 1741637618, 761538126, 1536383210, 579538109, 2344701437,\n                1320685197, 429406282, 614226248, 3064576305, 3913009213, 1408468081, 2953160453,\n                1860909301, 1257356077, 2326226229, 512992927, 4173707647, 4227234757, 2055824003,\n                1797074658, 723531295, 1055503760, 3723048013, 1019848561, 1813977292, 2245679653,\n                4188374262, 2764314541, 3543381795, 700976608, 1790968603, 1926021909, 604162486,\n                3885171802, 886529425, 2545372123, 1099009280, 2144253074, 2286027026, 3759545247,\n                65262690, 867405492, 478202482, 3860597229, 1950145935, 2338053342, 1301482230,\n                1694465994, 665328168, 1639519384, 1246558025, 3758953070, 514219744, 1033396600,\n                2585944964, 73215891, 1407268144, 3275177322, 713201364, 1552227337, 3796620920,\n                464835142, 2341943175, 3119000857, 2088431307, 3897368907, 878918678, 1090403719,\n                3163407018, 1730981592, 3537552166, 2597674257, 4098649693, 1903525249, 274610490,\n                2448833117, 3013444547, 2285961959, 1309148292, 4284801003, 1457869563, 1131416271,\n                1048930443, 2513500006, 1482041073, 1625081763, 4053050668, 2518621166, 3969148109,\n                2761689155, 2164832372, 81475261, 3345442184, 3349299825, 2006252039, 3489857052,\n                1658875101, 691754231, 849076446, 3627267661, 317685450, 4140537807, 2104452006,\n                3534476970, 2383041805, 3170903305, 738640319, 3255529797, 1446723654, 1118811539,\n                2937204107, 1614377664, 2969444277, 2952928746, 4001684504, 1718111127, 2073038934,\n                1656108772, 3191239768, 1185532158, 562604415, 3971592886, 3000494224, 2019311576,\n                3398207772, 1017177624, 2967316419, 1650769512, 2231731784, 3739468469, 1827669898,\n                141217323, 4207733620, 2832371984, 1621792041, 4151096498, 2547492982, 308078925,\n                3687686062, 2475718624, 3561209065, 4026891835, 1696468987, 3574384454, 2592420513,\n                3300544973, 2850962487, 656760200, 2508381898, 419452052, 626276936, 285665799,\n                3657891297, 554297412, 2239031137, 2012129,\n            ],\n            &[\n                3473487727, 2715824269, 302636924, 3827274248, 3626525609, 3832203487, 2822157013,\n                3986038466, 2374406499, 276102688, 3649155824, 3628559734, 4208420641, 1414875841,\n                3147732484, 3104062388, 2316940851, 3263871297, 737125952, 694969868, 47137177,\n                826969068, 2129205294, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n            false,\n        );\n        // - c == Less\n        test(\n            &[\n                187934912, 3963930250, 231958896, 4245982773, 1934140206, 440616703, 3262112836,\n                3803339338, 1055977017, 3477409956, 3459418279, 3536333193, 1703660800, 2104503975,\n                833240224, 886952920, 3757005223, 3905587728, 2036421476, 979947267, 617694154,\n                2023645391, 1275759231, 3404109586, 2938320668, 1202003004, 2980604512, 2032763306,\n                3902352209, 806323951, 3542789010, 3588280904, 2414505309, 2789124635, 708104571,\n                1248766971, 1432171576, 1128356364, 2875611376, 2278912471, 1150861966, 1291115162,\n                2748948894, 3634464032, 2110058367, 3206659726, 168682764, 1776545630, 3468415616,\n                1732523967, 4281271517, 3638902065, 531069836, 2942748381, 2696304125, 3283898896,\n                87384650, 1737516049, 155566843, 1249785223, 4063953505, 3904749325, 2017386943,\n                936929068, 1468046637, 686939124, 1127421717, 3660187784, 2539722337, 2063935548,\n                3712297932, 3468383353, 4239207397, 2627208190, 772818110, 1676680020, 1846256035,\n                3171012575, 1630885689, 3774178183, 624829565, 3829281971, 3575590705, 1125584859,\n                331886114, 2810170897, 180881990, 2376892097, 346183958, 1002811024, 2287792836,\n                2721987172, 1353923230, 173519658, 2840578452, 3046951447, 280393883, 1934407313,\n                3450248943, 3960335583, 2936886127, 2837374367, 1167738321, 11803000, 3709093930,\n                1660429674, 2214045250, 3121062633, 1551000516, 3932704671, 1434892291, 3144179262,\n                1765285735, 919580204, 212878018, 3986423325, 2643867381, 664022808, 1148663675,\n                441609369, 790629951, 2700888529, 1528024872, 2655036879, 926252445, 590467168,\n                69936158, 543426961, 2407749697, 3983036014, 3086285416, 1698716849, 1730836693,\n                558966155, 3162488766, 1631913078, 468599839, 987281756, 1175534538, 1143324775,\n                2780081223, 2255743401, 600016013, 1213392671, 1581032372, 1214585858, 2655366727,\n                1703054794, 1334202166, 3011637212, 3091624188, 2151823204, 1922265826, 1392986173,\n                2440236131, 546335907, 2571698069, 4064180854, 3016119932, 1276149514, 2750959023,\n                1846484680, 2487394348, 3192553460, 2046714633, 2105197122, 2859158014, 798086272,\n                3982320680, 2847110299, 566095532, 1909918779, 4064894596, 924591979, 3757772259,\n                204200652, 2316781277, 1618431160, 1291740177, 2823517809, 2489902405, 3808225904,\n                2814320098, 2402867452, 2628984107, 506097881, 3690769018, 1916622416, 3396296036,\n                2817276852, 294193788, 4014046110, 3348468266, 1808087416, 1217606688, 3107405413,\n                20303602, 2605163877, 4255862987, 1827267797, 4172243166, 1923964418, 151022861,\n                2805154409, 2725518846, 2804473785, 361448192, 966384361, 1011003843, 2130801904,\n                2756270251, 977045660, 1231631015, 4117590378, 1824472438, 1239240410, 3967925324,\n                3591091215, 3425508458, 2441519937, 1576668646, 3970317623, 3149254726, 2461311180,\n                2975630926, 2573169699, 3785791997, 1817505813, 2416636291, 243972919, 854993073,\n                641309278, 933994018, 2436076046, 714583961, 4233911749, 2877006599, 1841754465,\n                798678061, 3291065690, 4250181129, 1054668988, 133850660, 112252231, 1248382546,\n                2745722364, 2414244177, 1537381601, 375780842, 57,\n            ],\n            &[\n                1219238520, 458286836, 571303475, 1095503760, 3936266545, 2915216623, 934419627,\n                108694817, 825922308, 3909996859, 445552390, 3436248982, 17043256, 2600050693,\n                3575940214, 4206950518, 1409086111, 3580010797, 4200868738, 3791772787, 3461031842,\n                3741905335, 1645461538, 2796220093, 571250449, 1978665721, 3872196348, 3512770614,\n                2265675397, 1898914436, 1471543164, 104009581, 1069204671, 3588685237, 3450163092,\n                2030632179, 448989709, 741456689, 1962549854, 4122206837, 394103306, 3616942037,\n                1828786100, 3308044126, 320612466, 2551987032, 745240126, 939005175, 4206308,\n                3000252168, 2480777179, 130665597, 3796761496, 1775773864, 2872549417, 625407398,\n                2323690020, 2598551921, 221395795, 2846135335, 1677691399, 1764804747, 1322480221,\n                2702514092, 907481141, 1520010856, 2089109102, 3213176228, 2731628980, 1909676512,\n                2922375030, 3610676871, 1917186130, 2032601964, 212603593, 2765257336, 3826304165,\n                2961560381, 2451767748, 1494602925, 450986581, 1939887496, 2375124190, 2296714928,\n                2097227393, 2659664732, 797225077, 3883459807, 267885304, 338353083, 43190940,\n                3825976024, 3634497457, 1621047893, 74803135, 1769067819, 3180705641, 685501232,\n                3040073389, 2934885674, 166648054, 775479293, 1448421834, 2276093488, 1738529462,\n                841982763, 1787134020, 1657493921, 908974950, 338854924, 3663099125, 1085361174,\n                1036174733, 3763552557, 26982837, 413060618, 1373197819, 1979314730, 3213976777,\n                1302698249, 970720900, 1026620489, 622266192, 2286432101, 3319123912, 3320832875,\n                7879744, 969439985, 165474540, 2783335670, 4017257129, 1393620424, 3686559536,\n                2508583884, 1397700564, 1059657114, 3253108688, 3016769809, 2955518996, 3439762840,\n                1604575612, 3040353199, 1887901043, 2891741754, 3012261550, 321348872, 2842231132,\n                3205943301, 2186892599, 3416397958, 3130842469, 3049587515, 1348282946, 3082616990,\n                229484403, 2826363885, 2099377666, 150762968, 1443375484, 1366019051, 574671368,\n                3425374251, 3605765854, 1133360577, 2107400592, 189470407, 682742956, 329159853,\n                3068502457, 2834141510, 3819877515, 443046013, 1887862589, 1289509196, 1476348830,\n                1890826827, 1049086736, 351021297, 391832608, 2086035132, 3540615308, 3691174269,\n                2350843456, 342151347, 1267574301, 4072009402, 4014660146, 225798818, 2079491499,\n                546273689, 3761716237, 4145812188, 1436903670, 700677104, 180962847, 2186328381,\n                2164757885, 1504132650, 136850620, 877049642, 74786002, 2379972976, 3248155677,\n                3811577426, 3703108610, 2542849491, 2801014761, 2439612323, 1227548239, 315200269,\n                1034453004, 540738039, 4093700781, 2455957542, 3200948464, 2592553580, 3880742794,\n                1453493027, 1877232780, 2259655253, 297001748, 2136807271, 3193696895, 3875290906,\n                3209590629, 1538087872, 3584987471, 3733925871, 1104935002, 1693308027, 4180523234,\n                4155046152, 4045108046, 2011123316, 3487256278, 1875596161, 2871056745, 4174156727,\n                1344816542, 3857831725, 2962655023, 1798522437, 3832165252, 3587644818, 1176470348,\n                3313939000, 1778856308, 3338213749, 138881,\n            ],\n            &[\n                1997129832, 3629657202, 2915022059, 3343024882, 3990459908, 2694411795, 3258514756,\n                3026472385, 1853702029, 3885584109, 1571649067, 4146409127, 3984530047, 2610215790,\n                3737462160, 1099406791, 2146662218, 788888709, 3056174154, 1041105130, 805009138,\n                4059467671, 126218581, 1172679122, 977235966, 3659492466, 1913792212, 2951333370,\n                2882677768, 1142407645, 1914628530, 2290380457, 2645294608, 1071540072, 3675338742,\n                4268569133, 1325890402, 2114120206, 2748674301, 887843538, 135110258, 858895625,\n                595035002, 88286008, 368465230, 3466333800, 3978181230, 2244157953, 880291304,\n                1415196906, 1950141619, 183120630, 3331343751, 3085264924, 3772977910, 2344692597,\n                1372314528, 4241980412, 2518506943, 1793179256, 3502781717, 4138291196, 631566271,\n                2941001615, 199022841, 3005296926, 454728643, 1266860929, 1589661982, 1894863838,\n                578957394, 1114371740, 2919435517, 2479023152, 185063110, 2777031077, 1762844924,\n                143409635, 3450352997, 222248907, 2631593823, 2561012513, 445601702, 2619088364,\n                2551601117, 1369538011, 2600641370, 882915033, 3960089315, 894064017, 2204735730,\n                2859261389, 1569163540, 1412453825, 335934685, 250113882, 2581213657, 2113774668,\n                2333833748, 3550525401, 2830439907, 3027550887, 1296938289, 4155767149, 1847057132,\n                1262782444, 2104318482, 2969377868, 2942666919, 2780256120, 72912746, 476732544,\n                499935671, 2613299648, 3770003380, 3907567510, 1570763914, 613427901, 75022176,\n                760795510, 980487515, 3982014189, 1706577930, 1261188031, 2870746969, 234951136,\n                3857521632, 1051273058, 2871865682, 3661635885, 2141962953, 1115899513, 4060498786,\n                2643559294, 830174517, 1317284160, 1367063869, 161782948, 3985824171, 981195659,\n                992438988, 1733040918, 1209715468, 4244765037, 1507960056, 26996790, 308817914,\n                120748456, 4074583276, 4288631919, 1756259216, 3539103142, 2594578601, 939606767,\n                3170169733, 3302019519, 2595861584, 902451826, 2171009482, 3018639962, 4122320509,\n                13953107, 720393910, 1565490086, 863799491, 3286780228, 3837205729, 1522600897,\n                2688343839, 102578734, 4122020506, 2487793514, 3882018410, 2657573876, 1560242433,\n                3913939651, 2722125884, 2569012670, 2119668862, 332479976, 3976410832, 441652705,\n                428547637, 3653985669, 3541034639, 140605135, 3401899925, 2195242099, 3515812005,\n                3799203204, 1162859943, 3822268708, 1042520132, 3579913270, 3487482443, 697875289,\n                2992841272, 1965247641, 2154121107, 3413224392, 4257940059, 2921786635, 488976439,\n                1651666056, 4129306837, 874002760, 3753306770, 1455127647, 3856964540, 1208320745,\n                492650068, 3978622128, 3967533748, 1419634792, 2289002630, 2909276676, 8,\n            ],\n            &[\n                2887151513, 2955117088, 3686481916, 1282567524, 1792560750, 4239267230, 3914824829,\n                3001031255, 3151588641, 956076517, 1285983934, 4183803874, 1140560885, 1030876542,\n                3543344996, 1462200064, 4016479346, 606984379, 721894422, 1276631426, 45197611,\n                2675196050, 4142633094, 2013186106, 3704885393, 644846435, 2022612550, 964745357,\n                3786420454, 4020594532, 83626040, 2888472095, 556, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n            false,\n        );\n        // - n == 0 first time\n        test(\n            &[\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967292,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294967039,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1023,\n            ],\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294705152,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                67108863,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                255,\n            ],\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0,\n            ],\n            false,\n        );\n        // - scratch <= scratch_2 second time\n        test(\n            &[\n                2207864798, 267946504, 372323977, 838488163, 989944659, 2604803451, 4238223922,\n                3691348995, 2672166889, 2939963021, 3204498048, 4080880943, 520137010, 27769463,\n                2996159453, 1607673725, 49056055, 2967627226, 168375317, 1738935943, 1325619184,\n                713770625, 2156270437, 281935012, 847234582, 4187043368, 2605789371, 2211145637,\n                1570439865, 1275820484, 1958339168, 4105135748, 1923071232, 457462043, 761246786,\n                4214022096, 2195638580, 112902937, 712461934, 4150385043, 2909280359, 1210932542,\n                2559422380, 2784873521, 1639849226, 471070719, 370170546, 119573553, 1368711102,\n                1550820770, 2952943579, 1078928939, 1933590639, 3128564987, 3729618936, 380208622,\n                746284712, 397317393, 1370494230, 3280997641, 741056649, 926342725, 3063757104,\n                781251372, 2248837423, 4289444674, 3481867568, 2059529012, 2144237229, 1476518116,\n                2913224606, 2784322121, 1097765568, 1168414897, 1147821222, 3213813929, 1626172092,\n                4271849462, 2576546258, 3083396894, 279893624, 3759599720, 1914220656, 828504008,\n                3974235088, 3853012955, 2315717336, 1369841715, 2099820461, 2355062255, 2644110523,\n                3939540670, 1818016878, 1195833762, 865290937, 3227403814, 1989864511, 1481749490,\n                3485866574, 310041183, 2533950297, 75004791, 3170685440, 3048279373, 3575702533,\n                607339517, 1986365212, 1940313431, 3142582191, 353694395, 871105395, 2372958566,\n                543478756, 520650729, 1271503005, 2299655823, 1652537103, 823994264, 2608198867,\n                3138891496, 1607548416, 4245522527, 806354235, 370312244, 940261358, 3517654229,\n                812483183, 4170416364, 3055737710, 597269095, 445327768, 2982695405, 673942649,\n                3328034346, 591105255, 392089798, 144695525, 1256851674, 624209363, 3254182856,\n                3318200640, 2228436782, 2636252257, 3867863804, 3299061215, 4250741776, 1207426433,\n                4111586753, 1433876171, 3615256411, 4063241139, 2498423720, 1094424000, 3501308247,\n                3428304735, 62836544, 283854756, 190630197, 231903905, 57469653, 2752417874,\n                3101673320, 3005834242, 1529425204, 3429882832, 1804302400, 1318870337, 3239774213,\n                1334291598, 269327930, 582347024, 1364483740, 3892520550, 4289141082, 990514330,\n                2567575103, 1849070181, 4221031912, 1282643459, 593306019, 4102935754, 2687630825,\n                2454603670, 2459317428, 15501938, 3220012509, 3194948341, 2770827885, 310256151,\n                752576061, 2802821281, 2143132954, 1951186309, 299076884, 3784631385, 3065258766,\n                2300539722, 1724661440, 1345721863, 1147424999, 3414798132, 2527323313, 691503965,\n                1255394592, 1035171486, 3133259824, 4119299626, 2493608670, 599503941, 2765526454,\n                913507389, 158575106, 2604793526, 3681411980, 3672418896, 2370104217, 2345217795,\n                2451256505, 182685832, 370382859, 1240673894, 2151490488, 1145090727, 2583769931,\n                3389299303, 3617246559, 2294336112, 2073635621, 1226465224, 437889431, 994073059,\n                2739895539, 124748784, 2577790545, 4038673486, 2597483545, 3481432375, 2505906026,\n                3679053579, 2567446299, 2503584552, 1724814969, 2074264558, 3116425221, 134201557,\n                1904374056, 3315661235, 549731342, 454384735, 3566798071, 3867940763, 2036012380,\n                3964771234, 2078494356, 2910348743, 747797952, 2098288390, 986676007, 3208665881,\n                1099888732, 2812049765, 2863541208, 2056114848, 2807277926, 4173414039, 2185629714,\n                3676605702, 4090003868, 1521812446, 1591739644, 2803711764, 3349612318, 4152536289,\n                167187079, 1109738310, 3386413010, 1638194434, 511325059, 2815222562, 2979314390,\n                888373194, 1756285774, 337401670, 1312397774, 2225199035, 1193707747, 95565948,\n                3829450604, 2889994162, 646979858, 1291101250, 2723798680, 711154682, 1562997144,\n                3387241029, 2812924248, 2054189861, 2169838638, 3629024244, 840598691, 609335244,\n                2414653125, 679470536, 79538859, 1624495387, 2511298639, 2309910409, 3555938356,\n                268130581, 1947633553, 3045420973, 549742072, 224897407, 668694907, 353072335,\n                3526743582, 1307392155, 1190166001, 535370516, 3860183456, 4280474483, 4212105054,\n                4201052689, 2222668678, 1132900091, 1875434903, 780351451, 4242541455, 341093661,\n                2036456209, 1265036963, 4205331811, 330055099, 3993013070, 973468955, 3971628834,\n                259595192, 762722015, 2480719174, 1710909965, 2123904953, 196992042, 1557228268,\n                1413718141, 3778152886, 2345636147, 4003574271, 334744826, 1632792779, 3919020616,\n                3350171760, 967345803, 2004912676, 2345756953, 431565280, 425143888, 2508188340,\n                2547798264, 1254968085, 1863009118, 398460841, 1879223599, 494787534, 3574856019,\n                2613953972, 250872328, 2567364999, 2635183965, 2959501381, 2452785113, 662128752,\n                4120986560, 2400899916, 3250192037, 4004124111, 633976982, 1310968479, 3727657282,\n                1817457036, 4229391439, 3957420779, 3239547770, 3301276480, 266768554, 4284644798,\n                1745391213, 1262080108, 3199469071, 853588407, 2606347792, 2941502225, 1876190400,\n                930981169, 3941623801, 1625100318, 2604943583, 3782802841, 4060464082, 3647780641,\n                5070295, 1623035143, 3958489901, 2521266672, 599485990, 1015886800, 1253517067,\n                2724576291, 3813475335, 3121280611, 1633026042, 1195587036, 2940382331, 529194299,\n                1351837567, 3738569469, 4045542638, 2346072268, 1273398955, 267131951, 396975896,\n                286803659, 1149330511, 2801542386, 4199751737, 103066683, 730138847, 1747702256,\n                3943184911, 1592324021, 3100174818, 1170108054, 295368469, 2424270403, 1735209619,\n                2694218542, 3164559995, 320787887, 78612319, 2284898023, 11760395, 1289538398,\n                2139493945, 2627390499, 956126278, 3294394229, 558269595, 3881840986, 1107587531,\n                1856221042, 1934595832, 1977407844, 111930272, 3225213770, 4099233643, 3154542598,\n                3008462371, 1277874557, 1835389114, 1375729246, 1757935365, 1022886910, 157600366,\n                2218081795, 3638914215, 3989555118, 2514846600, 1364123507, 3997150189, 331489658,\n                732412399, 61544381, 3486712684, 2067650074, 2442996119, 132546950, 3013930940,\n                286094619, 1351608462, 1526299551, 1736674287, 2966093870, 2304608780, 2310910201,\n                3584030181, 2286788688, 3580208800, 2724383396, 2370465396, 4031550116, 3189384914,\n                2876438438, 1882299544, 843001851, 4230731183, 2046387427, 2928994095, 371034597,\n                3934073305, 1573675188, 2406063825, 2982153066, 2528190111, 3260662096, 3002143549,\n                1048991067, 686266540, 3261750556, 3221346523, 1507114940, 2647179569, 422609670,\n                1364060069, 82429640, 176161954, 3184770293, 2169179636, 3563306373, 303785467,\n                486879944, 3872236636, 518027929, 2299495525, 3476857792, 3781803472, 98494826,\n                178025696, 1214390986, 647981013, 820079024, 15594344, 2603289961, 3759408136,\n                1311725377, 2126848746, 49064670, 3681656437, 4273985052, 3089745094, 381952953,\n                3381602452, 1394470919, 2709871606, 1713656628, 3464289356, 1341017672, 2638003074,\n                4022970468, 3951442590, 3856460108, 3901197576, 1704975892, 4179858327, 1431684317,\n                2828263518, 2508657849, 3947513951, 3935760369, 3404427334, 3832119005, 718983465,\n                1749978964, 215727325, 4216502901, 229208963, 1354930099, 649831302, 2025249346,\n                2693822228, 502075714, 2421819020, 2747240795, 980027199, 3374599408, 544706505,\n                2013624864, 2766333752, 2098502440, 3902772424, 338884604, 3634940605, 4080595246,\n                1638807668, 1684259728, 3059250443, 2172893199, 3538110152, 3478895157, 2800095107,\n                4043539656, 738227109, 3948708786, 1357612601, 3881918572, 1356664172, 2722239998,\n                2453995713, 2625605974, 470854339, 1935940818, 3428649222, 2842707479, 2159686685,\n                2398586602, 3679073343, 4241106730, 3642573010, 3575665306, 1468515834, 398421162,\n                950044483, 1441313135, 3470466287, 470281996, 2070040948, 639744573, 1886496784,\n                16593554, 2208929955, 4260306612, 3193473955, 3375276611, 3996290151, 1136146657,\n                1489196229, 1419887692, 2292036861, 3694112622, 2919706063, 3100194667, 1484197325,\n                3549945004, 1522671191, 24002284, 3211652949, 2762484261, 3939747829, 1994490545,\n                1144446909, 1822384341, 1901184544, 4268199168, 2605681981, 697139491, 2856504476,\n                3045275346, 3379852695, 2641104141, 1330467965, 2369583793, 2478837155, 3509876047,\n                1888573009, 825341526, 743325155, 1645582432, 3691310401, 1229080683, 3871746042,\n                2875308637, 169010848, 137004370, 2194237916, 3583760613, 1851012996, 726079332,\n                1505680146, 1297204040, 2132899026, 4089124529, 2486768213, 2590417760, 817026308,\n                1141898311, 2558632297, 4105699206, 2987428229, 597663836, 2212062554, 819846513,\n                923428648, 2462552489, 4135795414, 1543581349, 3064612878, 1312692328, 599302820,\n                1025016110, 2669833556, 56885279, 1591168366, 3239302690, 2325183122, 1798020769,\n                2104555363, 340901196, 3194669248, 390374937, 1727515068, 4108789610, 1288974809,\n                3795317714, 3464480796, 2292039476, 3470123229, 705713191, 4256764273, 2161348120,\n                1447485170, 3758494209, 788131452, 780229334, 1106864775, 3793660699, 2445133966,\n                3777035595, 819389524, 3892566390, 3407549413, 3227341183, 300518463, 387764471,\n                2380248113, 1729197239, 3428482984, 155455760, 829543768, 2722547370, 3554403124,\n                812426914, 3192715449, 2683124433, 3704774242, 2168519994, 298764353, 697574938,\n                591667235, 1988966365, 50246387, 4078997041, 2562651834, 1501631915, 2017042659,\n                3127123704, 25503995, 3119397638, 3301140486, 2329565378, 1981524624, 1297772077,\n                472910707, 1113726624, 2246419297, 2173176490, 3179858158, 295919283, 1830694225,\n                1999826380, 2297530317, 2448843247, 2518592623, 1141482305, 3773458233, 3781707512,\n                1233919318, 3304887301, 1445910053, 607614300, 1129306627, 986762603, 2308600978,\n                2865579095, 464341339, 1874976807, 2472734638, 4243348378, 1589361130, 1268999506,\n                2328885250, 3453241404, 3161700650, 2022592823, 2434991366, 2905501888, 1000676904,\n                2945640510, 350883243, 2057706565, 3723496599, 1312397857, 443053385, 1656623019,\n                436794531, 2972149131, 2101756085, 2636747785, 2827788136, 3325399240, 1519360112,\n                2148131487, 4275408126, 2559264929, 2155218555, 408705191, 2678426907, 35399714,\n                88724426, 1292649545, 193199758, 1785136437, 3293099017, 22207906, 1704235368,\n                3813101835, 1859471334, 1536488896, 3801116568, 2980539495, 129286719, 3431136037,\n                422860547, 1093808922, 3271487412, 436540190, 1214949518, 3434807061, 1246383625,\n                2045880999, 3670278334, 2091673673, 1931453474, 1228423758, 1049668346, 2302097300,\n                2400619235, 3016364582, 1225008042, 4200508302, 3450569819, 2092048469, 3507292221,\n                153341111, 870856813, 4181342018, 1189866155, 3010246912, 2579053800, 1117609369,\n                2417897276, 89947314, 3761785076, 2414464808, 3888012859, 527327488, 1933822526,\n                362688102, 155109985, 4048770501, 846572819, 2837447967, 2770664498, 145789694,\n                3839553910, 2866036746, 1808293083, 1070005863, 3548714703, 2507585620, 1302729888,\n                718439670, 676557718, 3614065087, 3077432353, 2395163490, 4192287340, 322031736,\n                3582400735, 4205960063, 411313311, 50068028, 2364544815, 3733256371, 1831962662,\n                3273642479, 1799226082, 3422917229, 79914988, 3885678539, 201486939, 2174260526,\n                4278173973, 2367863611, 2768836913, 1087889156, 124138064, 3808061676, 2018110790,\n                682700696, 204550776, 625691105, 1744714606, 1730621404, 3600374506, 1586924064,\n                2248351654, 3971777918, 1741870997, 4064054751, 2884162546, 3952625505, 3952739050,\n                172969533, 932280451, 3088028569, 3980924886, 188319657, 1008821011, 897498538,\n                618759017, 1934226832, 4056744150, 517758257, 1266466953, 1408510284, 4030648224,\n                3312465353, 670664097, 918175230, 1981211089, 2985646689, 1004639722, 2959165856,\n                3023976880, 2729741254, 440746831, 1823292900, 3793265589, 726419087, 3812731147,\n                1386805021, 919129844, 2261286496, 576405850, 3960900338, 3818458090, 2925072331,\n                2547976826, 1802644337, 4238066789, 2720089855, 3876034741, 3997915349, 2674746723,\n                2818969610, 520496674, 41932556, 4123589031, 1743180571, 1421796312, 4144865302,\n                3006197001, 2227936167, 315485534, 2242455699, 2456927057, 607376874, 2675064510,\n                1495909763, 1239994157, 4005467423, 3082847040, 669418602, 2096857008, 469663740,\n                1666657154, 3296043597, 1516742664, 4195397062, 2923718687, 3030047089, 3888372574,\n                3236272437, 3138650044, 3129018831, 4125760857, 3337205269, 3400132539, 1857007007,\n                1596984050, 2829397366, 4244126509, 2823631628, 2523726031, 1677710269, 2013214373,\n                798959878, 1793629380, 2132968888, 1648075931, 2845025107, 2097490113, 3906486861,\n                1807833101, 435514889, 3934764479, 1098486125, 4032520466, 2815744570, 2773869997,\n                2575535711, 3746043311, 4009497844, 3747962986, 735431675, 3807774883, 1999690510,\n                1293100149, 1661461083, 2131154404, 4006902927, 1296628909, 1294936716, 1415807603,\n                1791067758, 2218414480, 2831527418, 3975259639, 2807570946, 3605807085, 1905516363,\n                1811255151, 2663406871, 946197416, 1052953874, 1452588707, 1222425888, 485961625,\n                2056322360, 2510622018, 2005905014, 795785021, 1310920835, 2853342075, 1839541335,\n                964552872, 3047952597, 2254414197, 2255269464, 2926189131, 1254336754, 1439392090,\n                1781045022, 3157005256, 3483123654, 4037579045, 3428424709, 293895523, 2758713523,\n                3617061254, 4288799727, 960408289, 2739844991, 2074136610, 3541374620, 3227061912,\n                3441616651, 3833993152, 3897293889, 1896341258, 2945397484, 2479746639, 1303521728,\n                977852420, 4280253969, 477750734, 315603138, 1542659211, 2286924731, 1664791134,\n                3764251784, 2683369743, 2302296704, 190280742, 4155403524, 1959987119, 4018799944,\n                3661747660, 420947441, 1758427231, 4067565082, 3644362023, 4146725047, 3363603799,\n                2186132521, 2285103006, 38292869, 4185461861, 3425353017, 138771686, 425583559,\n                3478794692, 2760287534, 561443352, 1494564865, 250902498, 2087645947, 2076144240,\n                1642460632, 4288407840, 603095924, 2394191304, 3798358252, 4227860896, 368672739,\n                1555920455, 173107565, 2567400351, 65160714, 762867799, 1148461951, 2614770170,\n                458503218, 1735511062, 2269875099, 171964488, 2136814257, 1228414445, 1927572185,\n                2160278324, 2054309428, 994804285, 2021021470, 4114554993, 1634603738, 982118070,\n                608007472, 2416606, 249711725, 572999697, 149618916, 1483648820, 2227411430,\n                2388613276, 2021804305, 824462328, 1735571526, 3019974769, 1749385085, 382545215,\n                3416879049, 2790726904, 4069675602, 252299181, 3002819063, 2332346451, 308641746,\n                1957137326, 449388289, 2118742623, 3669011855, 4152476874, 3965751318, 4236449456,\n                490466694, 4226329460, 2240230067, 3216403093, 2994870716, 119762713, 2230455654,\n                1399381494, 2101641317, 3187433334, 2108055078, 1391388188, 254099050, 2589444481,\n                898951953, 2072283422, 3927467514, 845007169, 3577789684, 1558628724, 2651045034,\n                1212903351, 343329096, 1898445525, 1326838604, 3047851038, 2157437823, 845680213,\n                518174357, 3522670470, 534362915, 3664218865, 750303749, 1724920686, 587767680,\n                2139076488, 847957445, 1538394424, 1661039145, 4049218121, 3471436969, 4206426359,\n                1337744569, 2535491673, 3502643500, 2130710337, 2402741313, 3361602809, 724016021,\n                807987580, 3177217641, 36267848, 3985940203, 4216766274, 608000979, 2344883927,\n                2983040167, 456888620, 2160109651, 3855758720, 1150083868, 1971074955, 1150475749,\n                2208716822, 4053070093, 2383609214, 509367456, 2976646853, 2707623442, 1297168815,\n                4284713829, 2174028883, 1414644915, 1541470075, 3266194202, 2650005104, 2992521109,\n                1617855119, 1820910085, 556354320, 1331692718, 3919092863, 483469781, 739285226,\n                2970950520, 786712984, 3606513875, 3341063418, 1853823168, 293688524, 3140711652,\n                1492806246, 4149135803, 3878795308, 3579077295, 1196448459, 3313646103, 835334685,\n                3564142049, 3930788469, 1095693627, 3017450909, 3296148217, 1686531301, 4201249479,\n                4249709697, 1733600093, 2968646742, 84669239, 911666828, 4218457075, 2397100750,\n                3946354862, 3895122510, 78534891, 4242121559, 487384917, 1234287101, 325300674,\n                552528806, 28967938, 2743714447, 880207179, 924380132, 323670498, 746809207,\n                1873876944, 4001744977, 551745798, 177210549, 4027516709, 3503445130, 2810800759,\n                2063027261, 2603496827, 1858275470, 2455908148, 3752388973, 3125514303, 447041729,\n                1331722548, 1601928576, 2663711250, 2157712093, 3107351309, 37006319, 1773106797,\n                956557516, 3422376226, 2889017577, 1692316830, 1953125949, 1967796663, 3083756768,\n                1926757633, 2727010078, 115237822, 1110144495, 489100004, 698396872, 668015191,\n                287016765, 153684426, 3314893591, 1738305917, 2124636239, 3065607396, 1211922237,\n                4155779026, 2686135517, 3152689181, 2273765741, 2305929046, 3102311785, 4067099644,\n                376227668, 850456121, 2655093559, 2253410767, 3053960186, 3136517000, 2376506714,\n                2198978076, 167053539, 1674606069, 2111411809, 3213120115, 780298251, 3145583860,\n                2106951428, 176501355, 3196899217, 1006630234, 1197567396, 729828289, 4008008083,\n                2031252014, 3339512627, 1905231540, 2153178437, 4058419567, 2549419534, 1715698713,\n                1187830199, 2690465091, 2699515267, 387902295, 684677883, 1758402132, 1077553874,\n                671829629, 1579362859, 3470373493, 2083206420, 1522523196, 2152754996, 1049504922,\n                3497597593, 303295213, 2681342137, 216056523, 3675528810, 1473254965, 3765716290,\n                121672078, 3340992172, 2485207380, 723308636, 2669088429, 4128123447, 2047156743,\n                2477418036, 4121144203, 3357339724, 3564422774, 1669395917, 4079088771, 3993308922,\n                2459948573, 364881959, 1315333244, 4014398665, 2430429976, 2016468670, 3177070707,\n                201701441, 3637392629, 1441169637, 1754712142, 4174632016, 4176705647, 693975874,\n                3368012845, 4274414278, 885317914, 1953640138, 2381435303, 1738796345, 1133209251,\n                1168367788, 1362136868, 2479222746, 3782466280, 863855088, 1923912907, 1125624828,\n                679234693, 1634797603, 2094454206, 3142755816, 2908162961, 2072001788, 1661299913,\n                3875625332, 2707731618, 423307058, 2898907250, 3503268717, 3181758121, 737767364,\n                918943481, 1304348279, 2566402815, 3496814351, 1564856704, 1388657691, 2406023896,\n                1896198305, 3069457253, 2923754138, 119355642, 2857705293, 769341058, 2978345004,\n                1534553527, 663090564, 847347997, 2587240491, 242187107, 2896367723, 3472050655,\n                2347813662, 1356685945, 494637732, 680685257, 1425963307, 1890409650, 391111402,\n                117486478, 2687271121, 2569131442, 3448367135, 328970411, 1279479011, 1332847023,\n                3999391195, 3967117874, 881199244, 281885599, 2831346171, 2662229591, 1111976857,\n                3384886038, 3385627855, 860959649, 1063819909, 333825758, 4121117400, 1103147759,\n                918519660, 3863046147, 275149412, 4037688836, 71150444, 3250961101, 3616961172,\n                764177351, 2871544730, 4294515525, 3907217335, 3960609997, 3990722348, 1874554171,\n                839685879, 3208875400, 4253927853, 1335778155, 3536387240, 4193480399, 1271939158,\n                1931098057, 3413750198, 1240012911, 2396181303, 2934711314, 4116556712, 2497540168,\n                1417536580, 3901731019, 1144472333, 644042442, 3533397404, 1987400541, 3754946564,\n                2970823585, 76024287, 4146754204, 1160107992, 2522776052, 1035755005, 2198611662,\n                2401924452, 246565027, 273575685, 3342921856, 162720950, 515478011, 4110888187,\n                2447034792, 270332860, 2612078407, 3765975483, 1467244922, 1697259556, 3633635754,\n                1518955080, 4035333100, 2314861466, 4082794026, 2698813143, 1041245647, 172854116,\n                2514009189, 1660242354, 2410532964, 1249062576, 1759112273, 2861193269, 1859853497,\n                423258407, 572469463, 2385055402, 1737018384, 3951247404, 1775922045, 2943917817,\n                4124850023, 4153955379, 3591756960, 3555365287, 1628013687, 2519466401, 1835517069,\n                803270943, 1901180414, 3222192168, 2430688685, 1126575351, 3964298512, 2870880038,\n                3596780915, 3280732674, 3962818511, 2399058457, 1405004423, 499866991, 53000375,\n                2632025099, 1622793184, 1553006183, 3794494151, 2458706012, 2523459527, 126475368,\n                4106824016, 2194771061, 3688396860, 974769395, 1297012764, 835010776, 2720278216,\n                63697952, 2810166462, 2144133117, 3029262703, 1543619115, 1995238361, 70403905,\n                1619836963, 468473393, 3676095258, 1202459143, 297731154, 2710062651, 98122944,\n                3122073331, 1645035563, 1108115397, 108145364, 2330954276, 526078568, 1404447222,\n                3526386755, 4140740686, 2322362279, 2587623705, 3384373140, 3046474613, 1536723611,\n                1686089515, 2571353196, 3088816320, 2761978195, 4069639571, 458472479, 1667007366,\n                3586522709, 764791214, 2651221071, 1258368830, 1168063154, 1688030022, 82496799,\n                380035370, 181435803, 794910172, 734721870, 3546283870, 308796098, 1050055665,\n                2263473439, 266580540, 118179498, 2083060809, 1340514773, 311819645, 4157383340,\n                1883326002, 660889540, 3418539360, 1752696786, 2275366810, 2614933182, 3518544185,\n                1267253138, 3889405643, 124625361, 1117414446, 2551289039, 1020556710, 2071173079,\n                993669125, 448240121, 4198691303, 2317385191, 2347367078, 2180467974, 2562147194,\n                3426306008, 342770977, 389071347, 2626938676, 3577495844, 2012092897, 1126580865,\n                3897331973, 3739466185, 3126476921, 1506468186, 2594251884, 3294645514, 1420129006,\n                3546602078, 3496104880, 4189405101, 3435121191, 1825436329, 439731432, 217831139,\n                3592377934, 2570558676, 3588355878, 167489809, 3098995631, 1171541367, 285921519,\n                743609214, 4206476898, 1546426566, 3039013901, 3906658086, 4242703098, 118469340,\n                288477448, 3303781383, 2719115933, 3828501724, 4045253773, 1841177224, 3192383594,\n                3279278833, 1930081728, 4190212501, 2897283764, 2844960201, 2771350527, 3138042688,\n                2694672301, 2131602218, 1150704347, 3013434029, 1173064751, 1305558427, 2843386810,\n                1471391482, 2759202452, 855547399, 1956204053, 3370880522, 1255955321, 2795686336,\n                1076458302, 970300036, 3153299065, 4223547074, 3860939449, 4230718590, 38001240,\n                3064810513, 3384957816, 439992760, 4026444170, 1058668347, 1922732368, 4193111406,\n                356852998, 3870316532, 3397225746, 668917921, 2266851967, 835585776, 780426826,\n                3498269726, 3162168287, 174523526, 3443784212, 3504266379, 1642016255, 2273394208,\n                82106921, 3031323073, 1327917773, 3671270812, 515360527, 3485174413, 1622293521,\n                2292557065, 1534517419, 2834918852, 2009648839, 406363840, 1564078559, 3221438119,\n                85746215, 310257526, 896742646, 225399336, 938279191, 489743135, 3166616288,\n                749448040, 1659919527, 2643680756, 3053562861, 2626371453, 2789182905, 4256520229,\n                2266034708, 1897042968, 1489068281, 3151211597, 3938498615, 643560855, 2408383229,\n                2016412422, 1970225890, 3127859458, 1123567461, 1375149358, 885276948, 1927174646,\n                1504220730, 1155235804, 3493735453, 1050114482, 705530258, 40892990, 2552903793,\n                2959299427, 1052264649, 3677672328, 1769321260, 80289741, 4089483475, 2224947548,\n                1916309738, 1431857202, 1074482608, 861817142, 2451620781, 1923149737, 281314181,\n                1045720895, 2805465876, 3877165887, 2508795311, 2658788574, 1802041190, 1653833199,\n                2016289858, 2562056916, 460818753, 1988829810, 620386006, 1201360991, 212428852,\n                2970308761, 445763026, 1902689676, 1259338648, 1635521532, 1336529279, 3385368606,\n                879504562, 2477265215, 32430763, 1330178819, 1681621049, 543867373, 3975593432,\n                934817020, 1424412060, 3868906817, 1958034967, 3221474893, 3396815063, 923123078,\n                2491071956, 2898837529, 2083510542, 3750663645, 1546801413, 3836848323, 3873887257,\n                1774964590, 223297132, 2867810846, 1025837760, 3141260827, 3591004993, 2996508015,\n                794889711, 622599472, 2716485001, 3771834349, 3250439816, 969134693, 798429189,\n                3095405242, 4109754137, 807412357, 2679863978, 2036846998, 387342363, 335795869,\n                3080104754, 3985604208, 2453238086, 2155458134, 3885993301, 3727575438, 2088458021,\n                299414086, 235421224, 2322887197, 2170976579, 1720810544, 4057325852, 716222429,\n                630466531, 108963102, 3405479941, 900376377, 2134868198, 1369037446, 735382677,\n                2596226624, 3160709333, 1759175216, 3109953837, 959302650, 1701311308, 4004119915,\n                3938153091, 3756203586, 3215670726, 3902940441, 970223515, 4265172557, 3131049990,\n                3018035071, 23938165, 3830252593, 3096941341, 2534730323, 540189608, 1257687675,\n                2224611640, 1098273642, 919283405, 936743460, 2044686015, 1289697682, 2705980395,\n                1460360764, 2882507518, 957012809, 1857196248, 2374943094, 113023629, 2772719931,\n                3393213693, 1457109280, 799171674, 1227543017, 3124650768, 1561299938, 1958193362,\n                2558867781, 2030627581, 3056580313, 1546708173, 3369294573, 990086654, 1018890730,\n                4269430159, 2978612816, 1393034326, 966883943, 875558742, 937751814, 3254120159,\n                4125279962, 1890777572, 2548823748, 1766634072, 4154457908, 2927533548, 1337202963,\n                1799866026, 3588751997, 540880761, 2601559406, 1290846119, 2946813313, 2440536968,\n                1585788395, 2535923551, 2544923063, 1091952113, 2408246024, 1833297455, 1245351586,\n                35996687, 2561575102, 1245679498, 1797369424, 2539459724, 4018603980, 1266905522,\n                3359991042, 2965523367, 2842136887, 3640375794, 1846651190, 926838720, 2797630797,\n                1656280503, 3716993260, 3815634216, 2829852267, 4127790956, 3069637970, 1297143679,\n                4036009161, 3451848971, 331658705, 4183579900, 2977429397, 869650821, 2823210870,\n                1384423216, 3355992925, 327220443, 3377291078, 2183157960, 2170753129, 3685297616,\n                4002815254, 1218631307, 3500571556, 485900266, 2223534543, 1781234150, 3522077821,\n                3994164616, 80005254, 1107899367, 2373439633, 2416239294, 4077248641, 600562639,\n                2506709277, 35719881, 3057800476, 1664138944, 3617887436, 4170522081, 2642895279,\n                2925504625, 1493795246, 3723550391, 1040365926, 787018705, 3735881512, 1261887079,\n                2625034884, 314234302, 1009128380, 2741746546, 1502189325, 1956583908, 860027349,\n                16253404, 2279931243, 2142800419, 2056732515, 3091443754, 257936547, 938621453,\n                3531654261, 1138201098, 1468158367, 1588936014, 2076905766, 1881555238, 1115940621,\n                980620, 1921666937, 243373074, 4065573935, 3327157425, 1181889476, 2773479966,\n                719236841, 2344522929, 1563036498, 687363491, 2853124242, 3942171582, 2891270183,\n                614415772, 3888652984, 2522401747, 483917577, 1607503539, 3259835375, 1845214990,\n                2544390924, 3510428752, 518287508, 15401488, 1537862071, 2607212256, 737021210,\n                59269435, 31901400, 3178751704, 823291635, 540970256, 3611930566, 3780782884,\n                2548373515, 2502777177, 689549215, 3391163060, 808307728, 2646717405, 2147997472,\n                2735020579, 2566584531, 1630107504, 39531, 1297790849, 2655041187, 2370282243,\n                2361911777, 1282851326, 3457585571, 907204238, 548668403, 941578097, 4181153446,\n                2468509367, 3912761648, 2441117016, 2616287806, 4195570577, 2064118612, 2318617113,\n                750221145, 1610517261, 2177813430, 3308454999, 180937478, 3206619146, 2074509599,\n                3983048387, 4105185044, 4126069239, 1177339043, 3092246754, 560726304, 2649026329,\n                2441046785, 2956435873, 1104195280, 3789602406, 2057735173, 3944401972, 1637107114,\n                3295404389, 940828999, 2372552464, 1301436580, 1635292578, 2463978109, 1507708380,\n                3157587545, 3107331090, 3033124569, 1952302059, 2174022081, 2468554200, 3669966186,\n                2950489482, 884022410, 1273464555, 2109238458, 75941470, 3505597749, 3016439296,\n                4110905824, 2697859427, 1113621242, 1927971013, 263777075, 209890344, 674546626,\n                406422800, 3433735010, 1894806300, 3213385994, 1438836610, 108558096, 2503418887,\n                826008761, 1756346775, 556419644, 2418173354, 697723090, 4204316540, 2438521010,\n                3708324212, 3859786082, 4007756898, 1207658913, 1876739876, 3362333185, 2002564051,\n                2376092083, 529190103, 4091783008, 696071515, 602161487, 2450891505, 3994285904,\n                3673645797, 1761598859, 394892777, 2326707057, 4177076947, 2877672514, 1108139616,\n                1481659690, 3913915235, 21522046, 137490441, 2064131542, 4016824673, 1815999718,\n                3395971408, 3872898814, 2704664018, 739122335, 3879952614, 2170216895, 822171254,\n                3864211038, 1157543801, 4279556974, 338667522, 3778390249, 4251673243, 1134882446,\n                3449048461, 2497814175, 490372194, 1614478034, 2449676507, 3285255597, 698188477,\n                2211286358, 3572358210, 2064461182, 3280673986, 2679425296, 1021956592, 1263445490,\n                3641226340, 2305222965, 1242131538, 3728624529, 2545230520, 2469167240, 2496394127,\n                970395708, 3765098302, 1007752991, 3313230621, 3815999369, 3974761468, 4151581136,\n                3872189039, 757531491, 1761466676, 764238951, 3992056236, 4033462971, 273089723,\n                5130216, 635102000, 1358869059, 4235827151, 3842068474, 834470549, 1382495504,\n                4077628729, 1223495534, 229282291, 3707402138, 74008911, 3423512426, 268619776,\n                3183737001, 4116691592, 1561234472, 3174521724, 3964629359, 2934992758, 3385929863,\n                3678150546, 1033521112, 1033631320, 2398336734, 3927058372, 61775127, 3503024314,\n                2543416818, 3002873454, 3273671920, 2314439554, 2343128370, 2560404004, 223200564,\n                3505824167, 2029929172, 652609431, 1843797677, 2556526959, 389484140, 4168965605,\n                1713633569, 519723200, 467547811, 2950521066, 956859071, 2865951480, 1547835342,\n                1356165679, 2048881525, 625833450, 2195811934, 754355770, 597026413, 1145132789,\n                257410419, 1351464915, 3268216458, 1688290503, 2421168405, 3084659622, 1664317679,\n                654476981, 3089839290, 4043322371, 3169046544, 3039409567, 2983777737, 2384745587,\n                3822729800, 3952168366, 646743126, 2878675149, 3695507160, 2122663932, 3833408626,\n                1100226590, 2080497564, 1254861104, 869549291, 4129861030, 1333339898, 3199185304,\n                1951696094, 2127229443, 952554241, 1962675343, 330897097, 1155824411, 2399540123,\n                3849911581, 502304153, 1228525171, 2090678312, 2778936604, 1928685248, 1326148668,\n                278949133, 1155380569, 2077014021, 2154248261, 1811547707, 3092104962, 1877536544,\n                2258902690, 4015463079, 2518922484, 313873124, 3114627572, 168782757, 4292739149,\n                1699426393, 1054120991, 2897087402, 1016299387, 348166873, 1656210558, 3277400802,\n                1234839024, 3653821699, 1047939580, 3320592601, 1680797677, 206912832, 1673987761,\n                721342671, 71472161, 1183247443, 3861076616, 3375952709, 3717870592, 2708317584,\n                3637121110, 811088203, 2621702262, 1812508633, 2137382046, 2942356198, 4241340356,\n                647478471, 862601530, 3254259589, 4191366771, 1783038785, 3492781592, 2694731846,\n                4035229945, 2514483134, 19314785, 1559470376, 2598636927, 707522098, 913629879,\n                3316725542, 2197890863, 3259943868, 790933912, 1209008600, 977252818, 560870087,\n                1345858049, 1272598532, 2100101860, 1460073301, 3810231967, 2332779907, 3329728566,\n                3374513586, 380064777, 3559279778, 199067497, 1496247894, 3013403693, 1505292651,\n                1527020411, 2248666664, 1072740489, 3349142584, 2190946807, 2531908207, 1325920971,\n                3362462391, 283097209, 2976343972, 4118998769, 409630812, 596914346, 3556152068,\n                98997087, 1133520, 2018406002, 73893637, 684033678, 700648351, 1016840579,\n                375714874, 3205686569, 1611515901, 2982866029, 2489442949, 2978944926, 3026043400,\n                1741032417, 568313262, 616435295, 1322139456, 2115673147, 2122726766, 1171022314,\n                2271561100, 1925355022, 3132186990, 3284714989, 595797359, 1780525301, 224557524,\n                1782677730, 1382233152, 3762179158, 1190829764, 2851043401, 1797988695, 484888476,\n                3425567483, 1309865473, 2159690577, 3076787705, 2954117748, 879207894, 3653374210,\n                2635114894, 961988277, 814246497, 1655626503, 3078243965, 3985381952, 1845355762,\n                302605246, 3409331998, 165146303, 2877521999, 436450944, 3505698203, 626475985,\n                3175335946, 2861253467, 2906362681, 3457214865, 3900019220, 3707324556, 3744297070,\n                13941252, 324629421, 56931867, 1637452242, 4133211044, 967059531, 2392073552,\n                2155222929, 827777228, 224705208, 2679136100, 2928193744, 1680538879, 2674977225,\n                431299707, 2656838543, 338076941, 3925410476, 1453159665, 1638291904, 3717080438,\n                2594117423, 1796481757, 566292664, 1101232579, 1892524354, 2867824980, 1986194419,\n                3645022734, 95501445, 1035398942, 4206156453, 3313967906, 745187521, 1490957950,\n                2887345352, 2351344415, 3624760687, 1385080065, 1385613344, 3628174115, 3325276383,\n                3019903359, 19708163, 59916348, 2259420453, 4156768184, 1972374389, 2713826926,\n                3263625409, 525776986, 593277138, 2528773656, 527534624, 4192986568, 4069704011,\n                2353381625, 3443164316, 917873859, 824621613, 1348015973, 2791013820, 912713245,\n                2301066231, 1043271452, 1427176131, 2194070572, 1515038936, 2214605589, 3319491726,\n                1909339943, 2792999697, 3352439695, 3846954040, 2746362829, 3422849540, 4234166054,\n                888443580, 3419461068, 294678858, 2963203454, 3691629423, 1229141312, 1025641218,\n                1076117873, 1882194608, 2746501222, 1048453531, 3570791631, 1611657035, 1619323055,\n                3312615746, 2129243489, 3662602052, 2023333004, 4250359816, 3705135710, 1521186945,\n                1557379762, 4293623153, 3474061277, 889662967, 149515716, 2286534743, 2580349289,\n                2493889647, 3936210607, 3777337336, 3648682329, 1749187339, 3307377676, 2373135578,\n                4290786668, 2331614525, 3758294724, 4090863676, 788127985, 1308353102, 2981273145,\n                4272092012, 2592918397, 80242490, 1789804765, 648951797, 1810479995, 463468086,\n                876446290, 3224927410, 2741684758, 1511448286, 3280636620, 2111736381,\n            ],\n            &[\n                1646146781, 3355366092, 2702609393, 2501235092, 3733186010, 700936760, 2949254378,\n                3941657596, 1111121033, 4114047683, 21857804, 3660896777, 3180332813, 426317358,\n                759192794, 133148016, 2444168985, 705181436, 810858227, 544973542, 1045076571,\n                2767631874, 1386197246, 2229668431, 2408262678, 1954842634, 3210209379, 3240609796,\n                2975719943, 617575291, 2866649129, 3426939111, 937961033, 2054180310, 3471431788,\n                1672676648, 3156950223, 3869664161, 2172901918, 1518975727, 1575628045, 1232340363,\n                3157709780, 1259140866, 3436805064, 110644241, 3472914360, 3885831843, 1214796010,\n                2486779305, 3866219100, 3359465263, 3846595218, 2133165621, 2667175892, 706531988,\n                1917852025, 3933960303, 1438158614, 3474111452, 3630409082, 419107516, 1644047204,\n                340459195, 580898688, 576012343, 4014031077, 3154640491, 3864900517, 3736610191,\n                3202885253, 2034477116, 400359289, 2065940182, 2338917689, 1071531644, 4121237496,\n                2530330005, 1036182313, 2226961460, 2130726372, 1703507010, 3358389574, 1225776313,\n                1887309618, 1041140724, 2976038173, 1594845227, 2269484592, 941206007, 1323369145,\n                2376782526, 2067414392, 3709104198, 481479269, 645500232, 1764555773, 4276112852,\n                3020598880, 433428226, 363294871, 2382460155, 1741592224, 751560264, 1763549028,\n                1027869401, 858293834, 745414920, 2275280160, 200515730, 337140642, 1917257826,\n                4005848489, 2489874622, 1544738876, 1865379047, 887297512, 1175944717, 3655727089,\n                2031696781, 2736254777, 2818871878, 2461747542, 4291762939, 1286151054, 867203316,\n                625891936, 2270318752, 3694153050, 3636484252, 945112863, 2572193756, 1040297298,\n                2854336893, 3643535993, 3919773026, 3548702381, 4065778594, 3925809349, 1114320208,\n                51831817, 883978342, 3685226305, 3790877730, 2759683223, 1186418715, 2915574045,\n                2306134333, 438568791, 436432277, 1508448090, 3999224995, 3003289861, 3131995873,\n                2626109782, 2125783393, 2590734454, 3521431348, 379388900, 4037066789, 3285658717,\n                216950511, 2146635151, 1008841483, 1088995930, 2317014732, 3812136931, 3052665149,\n                623586000, 4291592846, 159122978, 1098774636, 1161856516, 1443893456, 1247911225,\n                2691592128, 4264994549, 2932303848, 310043971, 2439138785, 1471300723, 72590841,\n                416269517, 1742690078, 2955604770, 126459712, 1237916340, 3832622593, 3766542510,\n                3954115374, 462741019, 4154011681, 2422631136, 1831626214, 1724126713, 3374004102,\n                1617908227, 1823502680, 383531122, 3274056604, 3410013023, 2716762020, 1282998507,\n                1263573709, 1814401622, 493902553, 4186488610, 1176732404, 1538896701, 2460489097,\n                1587982136, 1526971541, 1877728886, 501343654, 2394712320, 635931406, 1962574554,\n                3223124541, 3732290209, 2418986942, 1060861829, 2352911498, 639287502, 2712704718,\n                1657230104, 2177202118, 1857324074, 2671537289, 3653958575, 3052416395, 1409120341,\n                219280650, 207974641, 3801486048, 2053036362, 989398634, 2036886128, 4057159303,\n                2391998524, 1318700555, 1061459168, 4106033714, 4032643681, 466625771, 1256123990,\n                1667983928, 2189315362, 2551360770, 617849547, 812261463, 3470708155, 2585475768,\n                2320365336, 1298782542, 3998064195, 3346965201, 198859120, 3305395420, 1790931927,\n                3297472010, 1269104527, 2507420556, 3420815083, 1101711384, 3746991716, 1567229876,\n                1065930578, 3063199524, 3304959814, 1626772921, 65856676, 2848887803, 2288463723,\n                3248694053, 3079420802, 3968253791, 402813667, 3508325296, 3349973232, 3688041923,\n                1301619532, 3685871260, 487170548, 570123370, 4125725456, 3677755226, 2157460925,\n                427108406, 3879547774, 869853205, 2554135153, 4061381160, 1913392263, 1365980653,\n                3908381940, 3129294403, 4292759986, 2875699867, 3804570020, 3144713839, 3363828079,\n                2252500219, 2989960833, 4022527656, 3371232929, 1658953553, 4065476169, 3864636723,\n                1530129807, 2034452468, 3810606961, 1400085318, 762877038, 547416674, 3824691318,\n                2503818238, 2493425324, 1231786822, 2142499902, 1899830999, 3073913029, 2551549271,\n                1988003374, 1933834159, 886172974, 727208241, 1017262994, 3988743024, 3609733723,\n                3737234596, 373762137, 262189319, 2434235823, 1359363910, 1597683672, 454900071,\n                2050706103, 4107843825, 1938290587, 1024370354, 2592270551, 3962726762, 1637931050,\n                1053400878, 927450698, 1000390015, 2385445684, 2572969347, 3739841633, 3684234613,\n                271137822, 563269856, 1465838147, 3005314960, 4229712654, 3837253448, 435587471,\n                828030019, 862923027, 730290720, 1912025891, 2390308153, 2583390009, 3343546426,\n                79956066, 2827980992, 3413931069, 408627338, 1798679536, 1119514034, 980810067,\n                2144998123, 2607179866, 2828481231, 1319660174, 3716254590, 4132334094, 3218261136,\n                1985916552, 1781165079, 1903530289, 1735545873, 3511460291, 2365970305, 2760279427,\n                2211944401, 2446029333, 2874084882, 891630672, 503547522, 2161173297, 2621987372,\n                3071277407, 3858752694, 3901093525, 2628974288, 2719072256, 2275671814, 379871489,\n                925158760, 718779106, 761096692, 1507689428,\n            ],\n            &[1],\n            &[\n                1384477170, 2884998501, 1180219469, 4109004296, 997383516, 4044033164, 1642951852,\n                1446808083, 37175391, 2282859045, 3021624688, 1519116461, 446662799, 251919701,\n                3626002578, 435516186, 4024242472, 150377540, 2423436388, 3823918787, 4080248194,\n                3948319529, 2000604485, 3122826894, 3526159102, 3366269145, 2534542644, 2550218265,\n                3200129864, 2159209452, 2182432402, 401115950, 2821309687, 239933185, 2664953808,\n                2357894845, 853801210, 3660041542, 318923345, 3517297895, 2212131962, 714145218,\n                4282708480, 9060286, 332854610, 1640882737, 2274474152, 359553548, 772749702,\n                21304777, 2685844123, 250427744, 2712214224, 1732121973, 696245192, 3692005482,\n                431760978, 4036957805, 947474652, 507006669, 1844245414, 3447048613, 4118003939,\n                3258234256, 332091427, 2676890228, 581426731, 724721810, 3284157922, 2832713193,\n                3430818129, 1695270315, 1267960932, 3717578816, 447816382, 3427035588, 2945239339,\n                2054990649, 944648822, 4277320760, 4232599274, 2383932030, 3955112699, 2167411416,\n                2401960559, 2449661069, 1066034957, 1109347927, 812652844, 3137823672, 1081890562,\n                2425070195, 4115043270, 287066004, 3477258057, 3243315240, 265080242, 1183810880,\n                3153328886, 4242653340, 2977780908, 3377641, 2118786885, 3211374316, 2291698760,\n                3035946153, 3478658417, 2319878939, 786270837, 1645769599, 1867721861, 3170407804,\n                821369564, 832960650, 28775725, 1301119218, 1275059098, 3451682256, 4158144332,\n                745700491, 2936987949, 1899895335, 2346517904, 1325249418, 863110111, 1168153138,\n                1560258437, 3401092928, 2117866811, 1802618925, 1402878426, 2797692103, 592665881,\n                453682, 2631030100, 149759352, 2084534022, 1795101898, 4182881971, 2649866336,\n                1921107451, 3994934130, 2816002578, 1822991777, 1349573145, 3032559829, 2540814714,\n                3013758928, 163664171, 191165209, 2331004477, 1429461234, 2716039347, 2185719156,\n                1252162106, 464555833, 4154750437, 3679682194, 987581007, 2806961127, 1887482586,\n                254459861, 2072955038, 2243973750, 2198996441, 2437053653, 3665070992, 1854548618,\n                3949323616, 2025113759, 439338007, 402662802, 264268340, 3680188821, 151523769,\n                1731425914, 4278670439, 3370237175, 362147816, 886490711, 1141110037, 2453736536,\n                2044605310, 3105398498, 2157501656, 3910457974, 691927672, 1446337471, 1613812436,\n                2666418229, 712270021, 3236367167, 150725347, 1084313070, 1795001305, 1231031361,\n                1709897758, 2442210046, 3002335200, 3780675251, 3023181201, 3990675322, 3265698246,\n                3578374156, 912240552, 3797996535, 942494693, 46776743, 2266421929, 4259387576,\n                3248631026, 677049778, 1453865772, 727557964, 3158196760, 4063847549, 3729108589,\n                1777788538, 2663505460, 1694551555, 4189846403, 1646696173, 3085522472, 1719621415,\n                3707623970, 3935633904, 4088061793, 1081642164, 2952049343, 327976869, 2512996297,\n                3343771543, 3125428726, 2308478069, 1566295941, 2893752657, 39300663, 830599015,\n                3367437319, 3024938506, 1042041491, 2570706837, 462611755, 3486119893, 2035139721,\n                1635071811, 569595532, 1720829657, 1358110023, 2914778930, 219340570, 1530923910,\n                2576687137, 216246939, 3960993840, 2208752072, 3840693415, 472560666, 174320230,\n                2007799992, 2726548658, 3816296630, 2703856294, 732227014, 3984094206, 1651367171,\n                496225802, 2327983813, 197957522, 3819963453, 1286871047, 2505137551, 3313005770,\n                628085062, 478935762, 1739071792, 1625549370, 1198147593, 2291378564, 3651449689,\n                399851227, 311179769, 1483912270, 1824355223, 1763094698, 437432824, 2953027184,\n                1022534349, 36805731, 2288180438, 3686039894, 3542100244, 3571608951, 163368977,\n                92026250, 1303579581, 2386223491, 2086519661, 279834940, 421495954, 2205711554,\n                763664240, 4220494928, 3669200795, 2725843891, 2942466103, 2008412116, 2067360644,\n                121006392, 145470486, 2754718513, 28756690, 2686802151, 534105911, 2227506204,\n                2915524950, 374448528, 3564386234, 2402483348, 1977446727, 1483606137, 2952984093,\n                4139816448, 1647736560, 459815661, 3285933154, 1207099812, 175342675, 1741221097,\n                352840926, 2625096334, 2710737503, 2629594976, 3681301317, 2442494828, 1869698490,\n                3179988132, 4055843278, 3537171797, 2323976681, 2894226889, 2016219796, 1785512150,\n                1685999381, 3040725772, 3211050132, 3211545999, 2932416769, 3157674122, 3611745811,\n                1615208817, 754103285, 2917997451, 3057928191, 2740171565, 2322640572, 1252615274,\n                2175924660, 3853203495, 3691442798, 3389931870, 2729950991, 2582622100, 2045535192,\n                2165169808, 1715842299, 2841471402, 3631926092, 3961888437, 1563175160, 4006882514,\n                2443776711, 3570024276, 2788029127, 3244589184, 2037749031, 66483334, 3934700964,\n                885032286, 1488668201, 3115615962, 1637760832, 2832027294, 33854763, 3028541518,\n                3945363766, 692524956, 1013718106, 2016756299, 2300366534, 3562014518, 3108634777,\n                67494910, 2707199766, 1429312309, 1443945944, 3723903532, 961216960, 1135263177,\n                3349312249, 3843381071, 1825349027, 649833729, 0,\n            ],\n            true,\n        );\n    }\n}\n\n#[test]\nfn test_extended_gcd() {\n    let test = |s, t, gcd, x, y| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let result = u.clone().extended_gcd(v.clone());\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        let result = (&u).extended_gcd(v.clone());\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        let result = u.clone().extended_gcd(&v);\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        let result = (&u).extended_gcd(&v);\n        assert!(result.0.is_valid());\n        assert!(result.1.is_valid());\n        assert!(result.2.is_valid());\n        assert_eq!(result.0.to_string(), gcd);\n        assert_eq!(result.1.to_string(), x);\n        assert_eq!(result.2.to_string(), y);\n\n        let rug_result = rug::Integer::from_str(s)\n            .unwrap()\n            .extended_gcd(rug::Integer::from_str(t).unwrap(), rug::Integer::new());\n        assert_eq!(rug_result.0.to_string(), gcd);\n        assert_eq!(rug_result.1.to_string(), x);\n        assert_eq!(rug_result.2.to_string(), y);\n\n        assert_eq!(extended_gcd_euclidean_natural(u.clone(), v.clone()), result);\n        assert_eq!(extended_gcd_binary_natural(u, v), result);\n    };\n    test(\"0\", \"0\", \"0\", \"0\", \"0\");\n    test(\"0\", \"1\", \"1\", \"0\", \"1\");\n    test(\"1\", \"0\", \"1\", \"1\", \"0\");\n    test(\"1\", \"1\", \"1\", \"0\", \"1\");\n    test(\"0\", \"6\", \"6\", \"0\", \"1\");\n    test(\"6\", \"0\", \"6\", \"1\", \"0\");\n    test(\"1\", \"6\", \"1\", \"1\", \"0\");\n    test(\"6\", \"1\", \"1\", \"0\", \"1\");\n    test(\"6\", \"6\", \"6\", \"0\", \"1\");\n    test(\"8\", \"12\", \"4\", \"-1\", \"1\");\n    test(\"54\", \"24\", \"6\", \"1\", \"-2\");\n    test(\"42\", \"56\", \"14\", \"-1\", \"1\");\n    test(\"48\", \"18\", \"6\", \"-1\", \"3\");\n    test(\"3\", \"5\", \"1\", \"2\", \"-1\");\n    test(\"12\", \"60\", \"12\", \"1\", \"0\");\n    test(\"12\", \"90\", \"6\", \"-7\", \"1\");\n    test(\"240\", \"46\", \"2\", \"-9\", \"47\");\n    test(\n        \"12345678987654321\",\n        \"98765432123456789\",\n        \"1\",\n        \"1777777788\",\n        \"-222222223\",\n    );\n    test(\n        \"12345678987654321\",\n        \"98765432123456827\",\n        \"37\",\n        \"-577153682403132\",\n        \"72144210138067\",\n    );\n    test(\n        \"53210985212644002683182379010242100104171729746702422680779813004957564024060483478832914\\\n        482130776086943264778009917785771400263865734996803824227786705410307715728084358345686525\\\n        666955903442304160728096000478646410984438412892096337955320031377720994976196082976902515\\\n        475717316111445459643194929610572824881990973023469555025226995677148631273880820975143597\\\n        831952984119683964055138681965121900967812243353623419763457671607645603999610405594590486\\\n        872093104567190784464147432587592450898810445955458144467151620244389730813698904479644791\\\n        294670488649490319750421527379672354012120444416458908757409522861289562515268026280499438\\\n        641806141881438096739080037626687584189564479677582527752608125024890483099472450227206754\\\n        624817717578290132794377168533077053784736901385512425558741488599375141073342655809435567\\\n        227547685589123962107657740818440198851187052376695978652283425565793719694392992719063521\\\n        134328692281771049779324906964172346910876836649893103029553852739448996157575281261917767\\\n        462289778120317683016791957216391056858799293583579767530391770523628160305771464317552404\\\n        286415844497761280740749180268592936052323253151358109674397371860779496995312051516136343\\\n        612847181875036518544052191404281333580248246008117110841406622141848028115726825781495096\\\n        023066580543384031510610514530023329859191130909987959067533104292226831366117223117365539\\\n        076389748270068524013958358846689057807214037472552997058633682932574608802897333022001067\\\n        339767267512913044107763435719066947490496062127159179697412179675200594498582437769062032\\\n        106609527647647155310901097021926836956717765421150081077663197060352698277949891205344276\\\n        398861495791843547732671833443384827472568583890381928618497270970782368809415629392114681\\\n        048034518825010025530558395212016441248426070937066334000515283429231039788299226204028103\\\n        035156559074396814100222600998417211095724539178513979945252990396059722845072657522704853\\\n        530011258265578883744793665826446961940035340770987704528846170661806469860862323120060600\\\n        188716257174964605689834771035334287148298050873783292933007990864633863360851706708152274\\\n        741836663844952580453159016288332429022925661018852374290980352561723666338668811453247679\\\n        014938296095366457872688823644411907108248712726680503309453969901050687122079964577461573\\\n        162449057761724243617422749368227513730067603187116527525816979714703280645206367108943359\\\n        106913022723406929677039338452031585410723171878810424664534307822051012682445600878401920\\\n        391578438489860798959109565416251907002316381271860455740167875993364799515992972687239649\\\n        262505346275006613584575234884720386321569557741241845741527499938163930315502221011033166\\\n        978332933186840659678745110368027451832524439637158308990469666455002407888248194456358359\\\n        003303584715991518021477565902469791143312856111094055209930912059849631368408330026958170\\\n        300500052755648852405373421396065524685232424910319283382913578078436761328209023838453572\\\n        133871613682203794227711619723455082311584610371110039795962654391918340254088377920041056\\\n        377309453598423058002481787581331503006766698794968240393060646993432133789355956306077522\\\n        005838667605083279202957084353020652660658144238653295685751148726967548735573418209687787\\\n        467834141377482348535629112173783424658448326805091434859993190291004665837059259500568711\\\n        455850112822407840990469904590429374564214805016358736565409593989044710192662123765463450\\\n        672972588274038572597891463730749923741649553162200715118457359135337272102100729029198028\\\n        918389058264289464021962419840267900832170796088946861843699490514285866139817826140431958\\\n        589415626642762349104083760670177290291718048221838912239788379338860589682678474741960115\\\n        308805411814721629474003485325145328968908328606072640911502882836248802102769614929782398\\\n        730979902324112602478726951562229293169116613797296312251779636711555303451849944537708310\\\n        801131408238364215456625216763655273938127881890527292337937027210899452008994857736727918\\\n        885033534731416970620401446325145822869475926086614847561269180270467972553000381511940196\\\n        279182572288987445388104237426718319436680800461093698741076654884624736167050671120089075\\\n        282386495334580204700654987554577746716144292112714866349972381971774912662283900282488295\\\n        218996190161997330321826846740433118110308620925798899930220391255594082221295100829777595\\\n        979347307584113527503428496108921160529535700435459104118653387569562978972671042516904693\\\n        810745225490997755749644402714924878354004249270957656670619686002686882814167999260187282\\\n        055328251894795584803808155697918384152898853694821363462264146320840510264219534810450612\\\n        929827615517166467144562282245695274013804708632196293102656043771290261465998585780112007\\\n        388542114043156335580538623481266070034537267475499199416632459400066621964519464083762939\\\n        464714380427800499737792650032454181044342899816120428850127417546623784657922281632200912\\\n        161848262920191580623945633091088538955337107042051551668697130031566457950434604523676163\\\n        043032891652256507757622090615452544894824913511398707666352802094610340994251033590813299\\\n        765364312236108674038130828085071997231118916261973118087939248672075257862843017917893314\\\n        033345178209992539373295968119618157737049619102812429241222762039593668904550053680641639\\\n        389267383134196322949369118104847075367153574163403499344124070556491291271313163644785541\\\n        723453866178786858649956547169137241403737306831022854961563771690691014668445005399015743\\\n        939371799899140664516745666984533538205690486945356410433150062226302533155376556003683260\\\n        539391785706720537621070094792397845909047047655976082519165231675957064976971963495074845\\\n        400818760119815443094989219656728142533401627244302260359118740813768823984374575959252833\\\n        144167528744407735299199580787932320541816850832666571997744821660306170268434905949899327\\\n        266240469172212654527453885049713145956756927127727870583364826726128281756089904146355590\\\n        455829914673593711898789960872024428250898271592856329301689603627742736402591974705801123\\\n        913488054626112958406496491382377502094688225568173187111352310212308380669459790084393363\\\n        960883523181682291456431327909193716881944868315280595392569779974711532990380265055310891\\\n        022051373675075944778564890967215880361915872678562811138776286273858432617125011313032313\\\n        168318678984271504040530108775957206558580572943170989601778895262364393281094944972007762\\\n        124094331253870797410638264171838445695086318338080769305587531419584524233105109659682203\\\n        090923064062775237309184959029009607296104219167515035467015219883113736043851707266717383\\\n        559193712086972417551299928007610742208281705317863761479399221643255488085627999915211142\\\n        672046384840617199937210833843040740102526458882638797167263946326576840910916562011762226\\\n        706661382306360487929173691857388546757991075899605094253100264860031215071642999888965997\\\n        869390671338431704166432399428812946998317163816600390678925054197124972370304217477166546\\\n        089768163889437951691529426837016116240793274480116483450272217878061145047170546441620981\\\n        823170749155210537097780210174902502329952048525709554527381750141111597875089446887970940\\\n        262534007886042193961250806085012300304485692195713700363250476128223889785924988282242047\\\n        811208321107880647174999725298510927743456763226114735869121851323770951914868919115215317\\\n        365494366183599970291302382989049305582844781286411645202771800782108267056030270481771127\\\n        232627235326276085068150025360962124512278936384527298219083493101010604796985932149592092\\\n        070170567378681819658905585158346941619724195113662650366802273496667910050658093652805409\\\n        869963179595758113779491694369787691558670017783776813409931952830118752601701691901037586\\\n        418610004899832067781002855042381352969423310148491105412551508860494898767560096264317892\\\n        830589036793601578974344275517003959077442276732058503049385598570378664682089672636076453\\\n        082080632305926571864613777254452402275747692731274482901812940957009957142654303337221353\\\n        798094669642765671629562320046032765636176312442669290989279817217560679987637165595701228\\\n        351366685037359968240182767578602441805653770668496072883137747821769182663422011405220423\\\n        727217640104065163573431179928538260507079965922712687776153947468313356665668723515996291\\\n        552340142968459634562542946557786741048870587285010793715863275713556072680213389279361568\\\n        038965518710201803091193737009363656674819832448879814850406487813509908693767107886427038\\\n        476937063288525152867128415946460612768771476070887109107975523614045879552703548213926998\\\n        419846194661441809164103065854852763932318796907774950751348476157538370208075103687065896\\\n        948167859797720286187663893016336917905106535811345801047375780666495580554323392997728250\\\n        541187081595078546945520695566326266506064602589830874234940044630797297248761948040553129\\\n        503418374270682794301831412022012475533904383260395490657136380535495354618029622928612139\\\n        519593340366467161755196399806646295817737292725855915047117049822881000515392663832145766\\\n        188353944809699342668752899960862785380180673655165578750508424013605762525153272579409328\\\n        924500985979930675570919202129414835727967374179300788518918789482400970793425585256228619\\\n        081740926041287768110312330089409730950092765206723292820551676037697566463588073440027619\\\n        983938331355169156857627805220863954826347048067823720549066551110268768271517993610317591\\\n        513522070495592868434278031802044259419208412545225016316781705305455205097065236119922084\\\n        771404744955209445760506196414721295328700384580971655488748393727344372310863411826316595\\\n        739254443259354847917481178271709881972592331937735246506251014152117886027428023838429577\\\n        732111238549313001110216938283754490570632543294130258292207071256171783238651813426163606\\\n        628095387459232009512518082630058983995863610016577240052696973235745212040970034367232808\\\n        104731784606406027056204571625394610236258846776494225863131465466566526405374505823370473\\\n        520707017673738942998569172434684116370340822663158977787712737333206451248305988888549603\\\n        955197923343072509971172659371651177380410476108204283117487321411337910686990689261335221\\\n        338447456406133595687997654886951956396949111457705781116687931764802765061924644289463419\\\n        393414121046439112415317741512004234248773134964634958890904518960762592129237311077431104\\\n        588549710974693588401501363556926820587180528921974033260435999235803014570593669413052639\\\n        436919382666978608848780897560711427110650599116424995300681743791426389613664702302620282\\\n        121838824749211336073909492561563101037774890259297393161326986784880258206030293504023492\\\n        370086206401508292494549552549202756745363414493020119441643375954875549438754562314408814\\\n        426936447009665627565711004615869460295005775122173629710447631252774622228457241518587615\\\n        956791269541912241072131273480752931405509875234056047437577200248846944137530449155089538\\\n        394376552420473710983527523419509606059777670885940592326889264118264472276983496825554814\\\n        763115461594047614125625603423290018459740978768242759023788556284706971531970679882147267\\\n        031347386386695261790217699134862613984017229899919526937449697985754434840814975722630828\\\n        042807504163238870614971272376079064355220059355027968580734422261145684039864327533625629\\\n        676278136526912980702004761045477499121964848643675704865393521158794355626208344526004780\\\n        789059780492659952275224196637486580408272129416475260644240132339669185687684808739426659\\\n        897298261137374008000798171978135550443929130844771865653204625562676864531115837728704760\\\n        497273891619605225880387092718405651497906324643561511236430550544649637999926184319221247\\\n        618194357758089057134164362561038381271782792662090240950491969354492855505655908064120034\\\n        812933302781984817940008716135592679756965697066715740320334780368449441966885213229372986\\\n        171328622261598326858518868539318302276595053793818260449670297599949805816456533278515282\\\n        486611166138379819987079275968286707072075400932533136998497276084731936017797620097821291\\\n        361480270741140435974508680757195666173216352453388395174374030653704233046487081634203106\\\n        207578691279885846031260954415577833653989433166649581327941516166162451774602342782382455\\\n        794918167699930744044597561495347138903501195320961502043502535219479152801485120443622289\\\n        571172204994874763402189523133946117802128111379244125914628860530274893123999063129909629\\\n        246510888813000461704527831246184145713985209447157599663956515433838904179905280769383252\\\n        408345027952081044657330942288651843864378904424143599259186715899747781545562079953463616\\\n        610795016981202182267568087866584306853806059810551537195844600879555996597315278760544939\\\n        368949212046012458251172874859445840568576598132809498656874159336323866122390377126092357\\\n        264383212385984858590110103690717148531908354149441382452158926433127232267720449649030735\\\n        896505540225228012970976277749633885099429501038767455418562060354992992057303994294167925\\\n        518419271324194262573208628114565671227955125776936190934277505877045484040688946030844159\\\n        075885247477763270118332191608617711225564068780820085063043694080355310945662744175498934\\\n        420807611108461164889145870368848775016800251186657074179977099160163550518984762260042887\\\n        609526367904339069246014677160442152350852856796092327576207334456459293513900086057711602\\\n        561347813818574603599472588038639012282330059576904032633735133953280934508892281502600860\\\n        229862131002115408498417938208784776614578451591750103148464697447572476861283707386221202\\\n        603909900897089264054060199552054752291214332546697940488919568451724127217621421420845102\\\n        356233578592141456565700246730386492288071008754656762006009007329378194049268147773606863\\\n        258387539539064263134806899481224009378544903883454861150988875568477665582083252452308788\\\n        833546551591473441894955111772939643569652319349313157991259432634539326119547082757948962\\\n        775892992837603973349617164295745322764342086135715570961883793392925689007387796152941295\\\n        432265149815966623798777628312464956240455268099824925584879630078628469974900734949410774\\\n        336871837391836112151522941773680110965561490576707550754390661973195239156498337100763445\\\n        286859818988332314619966060843870503662242319006842916039780988850243739504331159131000546\\\n        811960036529188560674732472022520197003398047290180608553081595345518026025906646381325706\\\n        326791392541881930302445181537640936424758161873696536163789755487011712382340766197510895\\\n        254722596950753098572161799361261932438878445226616639621778736957120056365263820325648859\\\n        370872993818108818309776221279227966259765679861760757363232181118810231919829746681417020\\\n        315669960804259123974454277214083893996739023578209473820994234452353870483469432185371963\\\n        885012025935738870429419499211919327792588569642928402617617427620460693508406430479129132\\\n        106595517004852196676918840774185222598359879439930811127173482659886372549193030765261515\\\n        676472568182787899363857207144896351438911627602215270072417457473112896280508843333677296\\\n        714252523405352142691739893765616318447733411067731879226511656839611367947869122535369359\\\n        793901353815062581799432643955863175839344268544118463434583260393372664240845940633821910\\\n        066980284808805430274724011966553069689877496625231934990712513982515464942953801745975271\\\n        276891686437177410275958037893709120720948628116620044922474190975356430869903177662717034\\\n        090321858797330630951296639746516301614418881707168695120064299669944883292984036975554245\\\n        181143796029419109626750862492866113152291511447787407729716296738717129074765485380736103\\\n        858918674960662109851833748685139785343314124276248707355935194899760496940670983607319059\\\n        928397655138469897213091513119343029056496922477643069123081954778154004596086675503166344\\\n        461292561211593161378564280015825191149387011464644991110126260688460777118892191187129776\\\n        055873415039585889255864709394474515535630844768443406927936742309168300362819502230788342\\\n        664575797100114176933230234025766207391727933509738897076775660602810565434591906857056972\\\n        946465687652222471350696269053735088383284345847358219799428381343610096430035374038365551\\\n        400535331845775502238953745161041565491443302090491162262678046015541266809622780216414237\\\n        288231262740746260757185008098050706938808358141011032508978277429648021640783534937065618\\\n        771904176199645260350942468041004902798155285293164378582031779315295695228761727648611460\\\n        025464380670255245373415551194786362938237470615318607946639031047923837814426470925702692\\\n        674689200851472865811417322993294864615593803357690505947198740075923802158981214027255978\\\n        669291969574409656405164981697032483740377816864489771377719132206882915444641199168159392\\\n        336358069692922805656500075089909599195858869228042414966685803930179036613126605406902255\\\n        002158583678820208983436383558592165188401267670268446103187229472385950598833849537318663\\\n        538663450368135724192467172894429666615066746184623923538478136581153536955448776424262070\\\n        673474746413862815178563692867520086902567919958365836601672696316779281371827544824455367\\\n        065558130090967135223347998103398492498151386657535029281007295873629327366387897277851725\\\n        213700651431714307252894971393586315861313246213941227713914460433228477355667587893827216\\\n        820878830583441757729556009536021276467253565200183930886317339759890638303706426520100985\\\n        278945028441901357482600338331886519537663646611955086520491311839889060328604783205824086\\\n        245206621338669328975285401062126574672754288985299321299539081642303391741255871788518657\\\n        980401514608830508629260152684831273870497061640010492479243737011642499497347574057542087\\\n        742797107502068544775340766642694764181945383403598265759421361831462323454672096906514483\\\n        329209312674015064165194973441475998425773543391258409755652171121029257886154401301802997\\\n        006883388108755307485581166455497587091892681482676248500999083981280563797834765461933403\\\n        151907194562468098621511757749883920988296596636571096756507642145710376635399779988049487\\\n        819147927778389096349250470755893476565919579208435912892023825372516182571618463277666903\\\n        520218673909614883367279769311693685874610803223057242199404275715494253811661601622408944\\\n        283280551137111891775362449835171355882938424278209982338157642498799717975230250156177526\\\n        282112036508442616267714780958659026055137471192950787360704382684411165438201039412174827\\\n        086789449531691962686188372213347422493386094879641356148709873720109790456914996305263281\\\n        170527101801412682315373971757398564573336883973445747894540215702734902613010545182161780\\\n        820398650432306479387064236834093552809873998691704831133179206564244369602152734294186137\\\n        257130680513733350719249378070960664466848998285927763045897717702778310706096778280178543\\\n        379191393406049107223534550468136073680671435840019825389478094485359546603086881963136822\\\n        051959914104065111098170049092035898400074889322754788871720158413365477351565764794891528\\\n        903421232474802909551719640259874469580599122309503864658994327322505122611309900798453963\\\n        867524092599420188471176351618815906029085683406960540265569050692372543401338413590392775\\\n        667931935781736736345757414400619178864955561447378022112848249908001507467283235081097667\\\n        684690018606302002651981845653986672800536639049716226057917899508512561568770687130640878\\\n        798294428553259583969214288688443190955615558825601276239172886637902528482464477654619747\\\n        720552411877930064538516724716403737329011118126782378597939930246405984520278068208540844\\\n        267662269719028631115742059444614934141643368652878541123255813339427239569351536380657366\\\n        293415719419706633252780491815202434218114688017671076637060903715524887572348608569078922\\\n        878913327885421713558406785721290106997899056788981152217904688031149042539660017819638460\\\n        219878124437934404071359454904609849517186309990094429782626938458891344285942204442335092\\\n        681991516295159648633572588011901755950797119080390871798997000100056864098652477737323603\\\n        779966475553999532363386226719218469588015822012503831280476941772486218042448111216579351\\\n        987945958562756506783174447421635283569309323895258645755720814301734633011040505201553456\\\n        510143629662216857441285142627707917430019735772392985813064679514506920729038942277162370\\\n        606081935951634552130528385537741466236016590326698925079932239860701919181744046682440936\\\n        792111121884365650694532358779107006728325186559116109426907971427552389076866463278632033\\\n        850328088209519477997984456503309480142915392579055953693271498389938190769932574123246172\\\n        776870649138605357217160711844401066095946011428760992009303609248293469510297497490192127\\\n        275652736478887004845273814716833712778223360716806799051597137997912038318399732920094392\\\n        926815819613679325793400111530235933680530448072206981085223173065879842857368938922308096\\\n        431174739786409215412520953580484422941453967255871319595335732867311092733319819476821311\\\n        808017497213887538296122904403469844473320288292264292591347104660390230736716435861879755\\\n        693120331059064348274443863246130969420789093792567240038182555669969374947773991584655446\\\n        181560451999463938265187620183249761548311984773282827945825583746804383164803640771567872\\\n        647960230909731485950825279142123246507654835540451598708378355860518705649658674267099175\\\n        372485029322665572728706208246880841408808333402128123017120121316200331345386126073097837\\\n        026209846135148431863604208434109311326695113281113954421301638942768605768869320865510627\\\n        373229151636257367378194064687839360104550419327935117353074606269149060819423786773540534\\\n        241625560787012168675251113746164402030330355941136032658094210316472491187725655296137051\\\n        878552844072269739270846255967276306240116398299180794679959069586582684937384083260796099\\\n        598718751037838635833766337451905979033678892259198802999187169938559678041912437623511784\\\n        186187588552300881347666934019579668196817403655121532520979884701127916058445377119261302\\\n        382495687540837489854126545678454487462113002817541158600834750918048840029670520213078601\\\n        590950234650747939074758354225769799125558855795394185076919422331444299308122170581997473\\\n        451979906448509165348678386581212488801237641951122708880409408520527482744122048127984886\\\n        147508584551082521462388317094971685236625727506796968006488338940502645613667120225748474\\\n        925381734315145132933823942475882350474022223841773921062597397599959147812820629664973316\\\n        127612714429285183151659101578904052320465338662289551498987550887777000946708897359959452\\\n        865027856563421096002711991631032829764441640553340146701871056047009876771435845257943853\\\n        055716143030909226523366326074715190907559097327189806739742784198712428048694134607945077\\\n        831470633018941771266098103132017692263289698580950805977669499660166863822419155406940359\\\n        819771935938788849763554252984089992858738303390032099886675414163496309520208674721707670\\\n        896474082760684170800496605663871346768216667853517619349328927082924644531745397550797764\\\n        860422749879283352711129723850586678123506654165365192288246417111663874175828836035491286\\\n        669145621230476458649482908896604208970369861820798034442892002234198480212274873739725039\\\n        206135116681371512380492991497871588642014022582902719601283731812007185441227894775442871\\\n        234643650063511582770585111484263398730114707343686821695421516596916899960064725074805571\\\n        873937357829101380964978427694894971794245941463313096587124940467221581612481864301773393\\\n        301318561854433111829820756808003402515943154040260525261066342101361599665644649218619915\\\n        213518153701436861653011940347312469693273015483618506481696580783275677514584529378380365\\\n        953562686966166658078625404951577010110284645790068401651331271004435750522638568217774088\\\n        889644047390925159616106583508494910922644267494180975038577468115959485005200892732266444\\\n        816367103239292670008575197672772982090797246898872909161424793174775644090683591704305844\\\n        100048598599553869736245347684394894797524892162603450945024735951197071033610168303757907\\\n        341014338607720184129201525602890024264465625124297477342165127838479383845195473884161211\\\n        611688099544094975159311976009856960096117269950219170873900670020208495723176551564308561\\\n        820223586624190922624906104334853748140969913817060530264446616895763727138957509685830074\\\n        843413423767732092986526615771863442237777219812523011614383889077092189901006635873208719\\\n        922066553645997398575739002296886606517202811916245948330816384554965448138907398013080847\\\n        112892857463538216015832494218779318114414595530818029252127014869947058922852500662746072\\\n        397263586884748445665873463177326597187572793033185928650313148185709319480353293058568866\\\n        793564547922284904452118235674361044404333090903578117855838512283103693076221715207422180\\\n        398526049207919707707807110567925667603705194867270242093175963801658781239826716711231123\\\n        136461859769568886130896454869797472642337234934740135201017850594829854901851851924870423\\\n        104698485960717323181058740024681269050206600642325124160608799253460497754289168422555754\\\n        575403067503400531888584177944707920200664073736544932905162493281792864990422586909413520\\\n        894274611926299502215825902212397522450982169603386188025469603239243743106187780346541141\\\n        170851428331075081483358839289006704517681359158825073690579737183832223643503835949078697\\\n        069178510954159534310607500776562922438260099559171439862697895303397811546214855329615411\\\n        101432879692972826613594365787918674975202444196490774798036452061667504277048744542428053\\\n        588377780885871952827658565556265008045207428891707890344382985215693071260031317745356827\\\n        349753756773649095394221686657326046088074577421506630307117484439466669356705200900372057\\\n        099934802028920366291275566737247603620431701137706461620735559365627051678264704688961995\\\n        338941916167578929607733045835720703815303696667655338579129235467413693421399657418814032\\\n        474963919215056351063242502435532926046611975593868647456900169811587988239772248518812094\\\n        020026398398192899311809598867001800958675363511831931442740247331474406832526214802884309\\\n        427549741146648383898477788018122534309571063106823339879071310423816585129634551609162836\\\n        446740721613298798362019280534884186182223512248285272800723495004099228593680196692849458\\\n        509138834946844185526188997026958578849961862119989784985378063927521625593806777420339363\\\n        960544182354965388506398381248875137396898550847553259309959014531415401304973572715347555\\\n        838647724733285249331516101920564912404019464667161164682913167497312949087115219648422670\\\n        769533931086700190083171784358492731515796526842614816274013859523470237801122446840256487\\\n        312199280406869363282295581607449044711323618199930444796755021147560598841717449581032745\\\n        630645567124549827485228772729156299697740419146038238812490152889126719797918198178741556\\\n        194168247474794622081887046891451934692168292790011031223295760213939737596633741644197249\\\n        941360621872997980244812470037974149675137662017463403644846140129447654957379918568876013\\\n        097262455934668632855283900450178951930924801963357396410331892464527951029666805949602854\\\n        417116141729192289659744024120725915937710668565221989608074963639829168573025253958414328\\\n        755590675732087563933811834531796725921066474791676760254759496575323936261984896520148207\\\n        686358631210953507615008232867100558574211443007189542483852113208292296578812235140763632\\\n        265694819834772278056825404073178563982747184447383725498164160514961362653090869194531008\\\n        142069061816095585236953888593533920569659264607596903412786841294411157818460023722975678\\\n        050034516818353711244154952718462513201282067964255358242674298995978493000333833947375719\\\n        830944083662528218512383608366150619700642114469134348523830311194088142753262297023528509\\\n        572193563530612536877412118522547732739263958460549069867815692621487290445644956138621063\\\n        852065373262006190285970629614540866791538822028579730504110653893889513226460027154161904\\\n        687882100883731173136611077723250015285347847879937333598274642757346545127770015258740804\\\n        897109780902220973295842591492235284777574773067515508323994560936375177494513882110393384\\\n        372339973171374745624207040413337416938094584033869484663983941368232305649351539825261849\\\n        680841109525989067690565432666254520464519749210317225296208097305878315388121732090974025\\\n        410462446683326456646041939152989671929525357297790331045751354036667544139098453835383398\\\n        160936168958456313222933191558794330943564631934932094480452128264314633274940461123588508\\\n        738670222149198697288540527444746526495524597081669570454433472750597763119122130982292813\\\n        473427163567656953069769843956461225577969997316944595897614105104557616135482599931670440\\\n        362170658450122969197810733427928481381178601245469455393122322323998511767395909511159642\\\n        059381975909244067306309019605572881778847444629785612428606278895278892366525934977226189\\\n        865966339758934266243461057693030563725992125711075647263027596217735556451995662542185212\\\n        041857008351134364738750998912895326060881523288524106593060603965069473884048043330819926\\\n        174556474796267714773448587754030984825894131129185609549288091484935017127782563633481182\\\n        424467666185651664536335217625858513308110018615642491345657183448684371556153471340587462\\\n        966319172422795764408334807360337444184458825049826426872631152604949581856435980204629712\\\n        199499434662588829627712849969923949287542656597934989015086340490064126015419440183525423\\\n        586287608657524098923117707886226609523333327960853549331092429077458534632309240321459468\\\n        793115965528272722786020226905010570572400272117311644867882949885282220621684025714578243\\\n        030612999332117195845085398858221494619057941777129855255407348639885448580784404949664397\\\n        429661590787586413458997215709493701933178295095437408505139782774668497859560923113208981\\\n        743983407519964060724211253904926909801834013231536733348307234677164697757543330391047943\\\n        903064021101241362736160036341551490624892592605739663328164747835182505529206766985601292\\\n        004858800822630634807604841941579621684797042992443712336905150832742887070777763809699220\\\n        262915466253173122264146926765524209778395789690567690230085466577943866970970420385744688\\\n        323971024422970089771109314915006713151756339079044571900228144242636760531240052367292641\\\n        731563538099553082436169551737485312933005366459701305241404807328799739544792075011983818\\\n        810608804240457591234933004949835451960824908495111627326170545693457672160922684756810085\\\n        448430619227791650955567650710250435868247217961846982166425683621489844955192752190030302\\\n        778730490560551787378163545694580493063317868354407855295937736882617076251720976872868752\\\n        191385701598981082434259839549586589533692175949446257088497696631357171647677524231782254\\\n        676670066642597789184415140815985051157906471609745766766522673794908628596431049606497826\\\n        361415173430964496952895128881487041280136267382135451259696949237343852006993487980348166\\\n        865558326844337598837189537383775357964292953322958461810090078003922443552187608702910155\\\n        880114128385653870753117999842405065144485006883468308285804213078336025030145941797974589\\\n        835061496244578877498564532008761364759118931827268178041717255341873047550652709228971748\\\n        043812770174208342971442572127171205014851149788024935489294998518091893316894537660153057\\\n        821092424128048919292166749589129110699281150528189365527351286497239204441591428656274705\\\n        357913402617119872749229349594044780055027997877812068505428570227226937336797668414861427\\\n        488378163211753940058941620351355901373029821260990259954493891024013213999606949147075818\\\n        389674239887678654957636321933731406424582583265803308050736573660017819910858239718261983\\\n        213146038280279210476577719003189303267021758821353608658759270743081970061090628992692652\\\n        493275175933994025583013448233529521177953247128279061050863879744746407089199213669284804\\\n        122473919209608646667016485253952107093274367521027614593042778796392069834773008378000178\\\n        252473647255980826095031285496264743495967519345731757935340754394482870549622571795560937\\\n        534577148741215121942450171144092736260214572278501119170626439919602583539478632457123953\\\n        627860252940614313365244326362800684891233336494344101965430602349117446118148332798488196\\\n        510533962754886078315089216230117888298925103103772007094331795778534585840366815168327005\\\n        687124896633127140896959787279895061154285170464807284231725803933994355761987140359303077\\\n        573028344604046984975343953075636303986282207425767088277084890911575999452746804469123666\\\n        746126784751775663445305658091178529213226897296502215799361192478194036564888641174919371\\\n        165817580181420797996740863622970242734188942995365594703617340764959715314478591897575435\\\n        603368658363590139560493130407956415603128152060916843608083096104960513357975827764045164\\\n        058273113962536768019298188406938320408699793695463118442023803103461161434627863037712903\\\n        954566536441157881423593362266799006107739624661053099597864544681645628768351485523540555\\\n        015092592269745182065869670162733906220399455096303718351689728685876278766606554489282202\\\n        705279464643729227920093299810689160121803260993413348487800475050049696611969172621073694\\\n        659457873936493316690096742986778354273628509796021661463589579337492979334718539857515236\\\n        070612467316326436810790824369319776523135994231605250021442809723626391656578072409266339\\\n        787498479152683728603396581062278585022135991617908706690970401595714531337600335881022231\\\n        503670837767149415208542560911238877188365476015527527438662589174260301835144236636625959\\\n        325105968312328292023166543547147466452416524014037652482725258955709911830889050651323501\\\n        172013143193194795566383325044026549932739429606758402867616267968802605108730043722651029\\\n        359387860608688809812458841931168503470143968340157886231924896244472797683354296982571402\\\n        685207514402350278448004843502335591060939401767155739985654307380883063334462049690615894\\\n        852114008793206461268697169982089767632619211805781392783427077719840756014750378300839173\\\n        367933984993483361962422415542045037227388377815900098004654899668168298009578269125669577\\\n        592653961049459055278153017462550709577571083774869032880033588619678476105353526847424853\\\n        396957262303459591649188095065887954521418668108618064171553959381793544626601993533638338\\\n        305108986871472602608803820356417501358072696989570858010158406715546196969486067144965051\\\n        029086483122185812016245962497290491780697070691312822801324203124322470109346578100311688\\\n        261334150061903521491355160487342316451350852525193685178284794143016146875256977425595950\\\n        439992974542211918830775191450451379881307597595436387782897701966996028797276286877139873\\\n        500992211672331402071265765934719578423085967575249070127538732461788226607585565614692679\\\n        148513727416766282392269806098714742285932603275805463356484358260465211397732149191861254\\\n        471976889365978493443502972591324728405696836326488914390197017645244356020673496604632051\\\n        330585509461741888327863670910872033500157591760904416756199558034453111262534439295453222\\\n        711171934523057756555944470594592820620059929958762055950676753541215039732010402966069172\\\n        878019159492244679967459043966073877235070932703486131153304602652028576916369169223090331\\\n        147728862712207794535311038273650490179795637894424255503588470623759143310310957684701822\\\n        646331262368247399913371171961759719532346100081944225359059980584967538406427689502798576\\\n        684201468845804772860668944539777905816704242491506323913691438988238717498840109637940027\\\n        549715170038313293507132418773882566114471042294851297104491472536941514513454162573924043\\\n        148037192779427214788822332655329336324617565761511846125493008842605337966637588199492804\\\n        154675050745285205718602733363577787420118163691912528210721563607691199375805612503223434\\\n        402905178386964507886448947869679760151923781011525105997513514250132286649806498491927726\\\n        714468887289462343806443761430838653666729932963413594414016136974417528988432881550892082\\\n        558088990727087543368411399238240589245436121160779532949516685847923079529035248664548659\\\n        538153631931451669734950339294279191692292424977111455520987667567560456829156465196992933\\\n        539546522508489554465616715201633261824850526018531850964084767533211600606155034891067062\\\n        499419027736705393349360755738828453517660651272520889264293087973107781447740472255144640\\\n        372189983480972371057260226092424689278989029078857524726755149401445434465012332730426471\\\n        717047708055451664454842791370662602151030271861543553794000712302423052829357277391013635\\\n        194723307425953807165117212195762228647886765435793509174764013889080873943058997856620352\\\n        822307300917635846452593675992752927208177768489605001109642859204928563934212770768942554\\\n        811834447085803222523050355205600724868854701396202242652796774776277073374504563289850608\\\n        830565260374898160769491555279813987618366184531777016083566628924730031571308601605641645\\\n        236619268581526672298075223771072892344716731212688194444134139324815405877967007918483526\\\n        043982235475224712151356809660171796993096102878647945813040863171515562010152966109634168\\\n        885508986883779453441843342920418871861056815518503664724278834845440021077689584932245929\\\n        024607732280345254647583135617342292907805802952041310619712406544670760382128153680225914\\\n        278673857746663060902782397598494857269646751077136495475261413665174551628433295594157066\\\n        414547602700554218547505310914877055116360686061714276547014866570837125104471664995609660\\\n        182048749790989169909588557362854380538889978091157550677531864884219973393528055604180281\\\n        090322931593870124840803038189260912789253744809340364951159543996923355048910890419878212\\\n        518077517276776022736162236943217049201883147474629276121877929906322315462101934866673916\\\n        810811481692033991207810886748113326018499083303636283703314599281137721517454691160581443\\\n        788879099193831422155516383327637260852537289205905007668556394430970406874534208151060389\\\n        286448115005583316303476154417323820358921161639539101302641040971341248957955710576950814\\\n        976037772216268764110896879831694569557305794330372692230038239880805909889895742193975124\\\n        496625908181232696128459928817787696194235706874417753641249616636816622525916685727638165\\\n        013658243166939442759543761517863889383447853229274292794282626020199085846325119660460786\\\n        108814120037391435615332504582841077375692383822329012408842994299556055443358077085764861\\\n        462394900903076654348301248968128606909768390865852658759631487333204170819847917848096300\\\n        356819107537163713753655073451835002983179487695129262438158892623937347507751405202078818\\\n        485663526931819489738670235288132710336673203765905594752868501313132368762367923836453312\\\n        011744077988613281995706241894545168808583416683487071195173636456197093411032333891044113\\\n        888653940511803805163666655079463582106641857188382883975379757806738350901596312440784398\\\n        395047545425518638471748444559474170074843888999750669949690091314766706159669951753609249\\\n        272933069504033246116129934843556404836660996586619656036585438009999775776896409871338145\\\n        811736842220030153547990154277919530527059312451339753928566631159382851779751455949490721\\\n        520427868112093453127578008085805813035160233628619910447083395808387454239408861312315962\\\n        354670344460889358139559385426808422327551018156634282249557360917197430499879694581890396\\\n        456907800998956535741198414945308095005710323494352588741143414024873388658254623015207199\\\n        724134987767625720939265461283238000345907697064666924263018179171287108843633967121731742\\\n        280937352303381044147921184473670785114833766060050023586470228933936024178429097628412886\\\n        837609505148199088218427368208741891303971425183689209958500604579830978751735650059360903\\\n        887684695947901853092159857932937648830126870508255329363959585871286349426650114920139441\\\n        119148617335022683433195029238211321948796263153589183479342594246154210838662393526023863\\\n        368583045308267410141951632644678017986464840984023422885884951729582630642486573016367589\\\n        302543164851068254903477435754771393468709949702897146101201120498758869216033766010460308\\\n        447050412134415492443296522485649104022166728993070915387965360227707334705276505509348253\\\n        399299827580999140093104677934743786075996598872496611472571355623335444103960650495749583\\\n        469184599618440443608947725581626057271573040251779354006380604179226460648767743336830399\\\n        030308556276690297432730800222428047507583851678503534309047050724394369481579049893871525\\\n        921673150869534824186758190404096590345091087435402179954910916462897678480704214407341811\\\n        197721736564904422094788508215570526338354643416730837173598647148304817505076435054553127\\\n        938814558963231516740213263884957858449256250731343089659028986062995722179371729008327748\\\n        223828634341604417478815224337016521246953324705330795411170414743445725444078081505147877\\\n        226673528250054569962527799898781771104753328907821489939683924069209200099451033202928105\\\n        941911695349702891890037890727763312366585201769727765688836495648811804663219970166801416\\\n        339814356026318247245523681419020379648425879884207413225288366792005313529186519955748990\\\n        774286017876953309959593182086801990620818082289042853582166720330696168824797838924612665\\\n        433695060737419307289777029480918675100384565983756404995617757417333089434470677463715104\\\n        567014385876210809107648779723870717978528331202189871798425005907521798376573560028194160\\\n        838820830025402156502418188480124090154530358840195880703625452475876568144991352664766643\\\n        367550100504104656999317746511767098500169413998425519771685930809301528464599878798597144\\\n        417496985947487966239904495222524826018356972846207036778450083095898204219561527425290081\\\n        100392168684954871789898330174837335448469481305993720976227224822480060203607345870160221\\\n        319516198904031432407589029322846757602308232887228800510129190877071112704092890569214356\\\n        520590212390444011647866930315697634309394751212460674264573704071758880126224065367233236\\\n        831302888049346078762159224760380378831004367955411996061710659950872049512829214509534935\\\n        804410516259937362581084601214866855893696723638219903514209097772347516766444061742941994\\\n        798318495387687984710968027808301734611520628135344301586357217192887053721753301218833664\\\n        083322284741516803815600812503420669668186176239684986775061599681640207626479673354553351\\\n        309386933794512333552525735552617039284409366066630705562341033752624873871716696286440179\\\n        633729402449831735366502142841104789697124585941126884512154685895682146211213018640428627\\\n        751559219414357158285051465222654824444821125872856106780640147622072673739139880389234076\\\n        124918568453356285106449326659724916733233545111375520521452240828229296938688802229981527\\\n        601440606225717359232340598383637661289643660065476822429535832138591060774806255229038116\\\n        264608741957816762235337308478990045543978772150473889120994897168448327407311688614320718\\\n        215888843055818091915454955841942328260938570352479081533474152748998291733515385880226451\\\n        883219241977272533626184311133177735846656198462660501953498881845874059153310409821287413\\\n        998545592588354322322677576471866648865824692602042163932292944199292452925094397535219230\\\n        205486272540331689882451358883643588600650513622347125731994425885793555893035509343400419\\\n        642742147637478981502636200063754174837493116848814115718040460275261780390927555252049067\\\n        923147942866562057222129842375538000649438238962616527887474198310396283978516062818815412\\\n        881606149098240570959492930005671131214850852335172806158430332790663568452597724405141806\\\n        435982886558113546799528419013621214683412472940839948561706059039409307375041862182760558\\\n        100596809756798770534048122270065914239135464399244860082080863522843443249934872395976370\\\n        796330962877376458021316441310725016747994190346444959682586124165194651657869640616396624\\\n        096078101531864349581758158418563969669438189558137779073275638377195218521963709480623634\\\n        063213587403917849798102305505881642349775154737749718522444233216281217211831557672017251\\\n        192810751192151346443700939623854646840601746321981767816603822095691113509783908959135000\\\n        773440289527029695453654011948844417497096698782521226319081591007112366382636311571354246\\\n        138488837606586471976365401488057928668374549408845813174878770411583266460024851259214853\\\n        117164880094834521135752105569851245264648974362802291001508731945738874609347630380352448\\\n        396947950366287397753757245345984797351535570552876412479886673535621745553251779112495209\\\n        779274661613463787721083976636007062881690330605103730785399197915324203398500367835587633\\\n        595728132659662544429085184839627655733762583304523980409654984660954742576083490752135304\\\n        635436703286399615224265095380154399027232164465994726824080617830847871222856057337083970\\\n        265911543297055516850735870996216167609177220281089722371923283082606193940847699222758415\\\n        553427392679912784501817536601570475032053236533651436811906768739894040126585781488113401\\\n        890967176657062710978087326390296155600529647567292772469593181828874178305242484401456309\\\n        312229085900446941432849399350813296493558102034476639262437288107085988320324250909214063\\\n        410904238477836040459006049068782144036984973038917316414843977567546818054722080284587879\\\n        812109349480632728176148720630271595880541248652887395099097678781264498477922929162239307\\\n        386715064637983519845455368536007070099626510223812169288965038001260588195642574811711278\\\n        044138327082935546692500386145802400405987194103700579701806017640671715820914024487109129\\\n        789492000054564056942766294560354168485967964447510794375836170340664440999221598099751799\\\n        652475699868045099549471033049948151932778738503878936044122155267246070147312367531005835\\\n        766488975439067836193805818003159648304144159533085657396146070324827303931725956472221073\\\n        702053872385595224633269198318721462237829505519888724525190350280301969635014258868895693\\\n        102776340812794910329711268650047374629774560144718292778052475086039610781425818745976919\\\n        171321640454435815252205967069116540588460624022846556771463354109856108278756436122349211\\\n        003154025917934852718435387559260631681034603616158652496594515361531488910398040334273009\\\n        632377275226609565755185528494397437324937217908723826648015960269589542365679028745717954\\\n        251324667485247103329031431465345106538264438618856815850799877761395668583051206579345008\\\n        914021828806986137488338004803518533600366255020878454161522706511893110908977864432833739\\\n        879740445461786879720037599838135659594638041023784937831594000304272060659387665856365827\\\n        702438935937555960477510278295513162794095450989514355243230521661489476143953542924449652\\\n        760598496299651344228596539268492188580424482340653035359231581027604547756521096153907812\\\n        932733432649964089397611351077079062591509001517254013671828813718416110310733580906085760\\\n        951564067899646203218368291961881374304689853788016189258437546571171111668203192695950359\\\n        870235689461082945216171364384250554435966188749791148454770603909116175261538689430550141\\\n        897333282441529186332275845281378468828895235329155143045374789091344965851943850856879448\\\n        984119525027305802796470522799193754284463354150747661306908900868714357191560932290361823\\\n        176349573722208503797056308973747493878446681067718447516642549562811808761669745508429654\\\n        069275204530255898287506112115238257086450106721380163639887273778279017339732863080691516\\\n        163207455314172979350091044911103562458574954103374618497326732721829089341351937576803920\\\n        593238077177464904844014649921266460071375341999590273810018548499659174325703645950415749\\\n        282017512099197928427786962519532874824841133364534758903211023759918931694115055890802388\\\n        875058218479164578964456877967376876590309595800426523174844486613224552878503456401561714\\\n        271381192924165793442216113041549341602093450489035015280623381385799123212806729643963798\\\n        684440539084972849253253234797331940561132028067785948775713368766366062674675489794637050\\\n        363151637971588364837178614725471776571594177909530917043799807133334663373644221974177835\\\n        067197986066349776386031092587836320302669605686443159833614542518891330677923122653617842\\\n        399876827879530823884297462619016321037462101022157301893533678875163541207016856262402562\\\n        810886294737689925979004135596919368038622270340807038306280673272048756228409957736069441\\\n        260265147401045809513062320090982978978062094687788485304028342894584904059452767549477427\\\n        973155205883563413111928133131286886741837589372488034951118123592801825953220661606387451\\\n        861681883180322239123344351150305365172133441111041461643264034829377283728221473476217090\\\n        577355222808234343725665853059459481531105426766339329275036950803507941507607068885488745\\\n        368568388987432850145792905563116948005807705770173361497346924071599873966275262796509303\\\n        833133209541369209593707970637591817887452995875976814330417536647557351927425456466525927\\\n        493262663249097844137696374078785414754435994261793384601723635758231910288735940775323731\\\n        727370396556677766204185143643244741025332304066843196926059794145215479039568808971677535\\\n        448529335685573654409439024737596181756641955394123196023465047028327962811418469515601881\\\n        550896447376933661420102209743419712722286634454573195654839480135403757437832172162774934\\\n        099753965746603567791436363186221798782132802497477944705698360948988037835720909850851773\\\n        530118355961904729552026270725992160284010457488971493727393771647737751572227468442670703\\\n        488735572094227676492363375112363930620250817980479257162904502218515184437365925333676572\\\n        571115306275210167713887710943517057149518256476543239356233930865368653169530022063230405\\\n        131834927655529724201678685444289714669918709721252680152754612157167052780183988302183910\\\n        917397004480275778330610867050837704471627606501591951019374927543699737135159065504501771\\\n        734682673176167445827560026788737764443344046680126524069682832039054325840089065146852654\\\n        369208030872967566023734095215002014048862337478045995816646816205713112086364825369150617\\\n        974762655866491205387779843855772393304357178039460136935657549049872897946486314012612725\\\n        343723040816325763417192182889507424415044658289369176781890317342310756217953749342986103\\\n        522789425380502911100994575954948825192738022403009303035931399047799555221365331085737500\\\n        715325887963828520258785082609288336908012719913709346034429837016818920194271331489639993\\\n        154379922267924434957970117668563504554434926159547361705481390228331638432535891011057751\\\n        157146228246901674987019128888532315632348556883191440516048950243946541594661180312445578\\\n        525728584878250913346407134526193481918083807162768143539727456850343896398279313823262691\\\n        593252372318400927769858812481793601599588245300093193242288016807120062817937987813241779\\\n        118916389935189395423294030059972572503224591507083743179456718757361232466105266611526373\\\n        931878152719652158360594732444811320328467361015728718747661888102548659041443121582300710\\\n        450242806407007030788460760892662603094040767261731339067153304709370530390142583712466020\\\n        994047177346291787398913101964868037613775414361721781816513799085173751310922192349889115\\\n        020112806665179284627318623852901386140536266088892800581469662654017864011754345595419786\\\n        795573875715828238021203539751443197811795478610667962062428967809194529981077076577682015\\\n        781540927782325092701611695386939015864053806983498499084719328570953737739408003647306963\\\n        040072538908753949491657875252921903788892937909047178864528696184200552780145714456872803\\\n        269263784844486861880629238217340845149968645174604415516695071056135682345902472632498062\\\n        682106164994747809217433496246293033915040575771791756900073283004407632879461204541599611\\\n        419673105266850863014426818517256401602738910464438636564378292083306879945448761137439276\\\n        375907579391943800443326047564376980730119835574816396216532562670280025138781324262533175\\\n        116873311024007112151836411656040276931702353520365742112544828063930054558608447648677739\\\n        414245415156272687098396989681147615076063686504052186029559273766663167593079495321684953\\\n        194453229609119793819625338902403798569452327166187161254015115883098166678278412803987893\\\n        840843194745384677490806064449744558944634700570756126775985644546395590848876343715059194\\\n        402187126012425441460688986024242298300313497762930922173509593802305479953544921710941555\\\n        947184482409935051987628911126123973053867591934518020975420864953799799531508214012897405\\\n        216214000062429268294213182651310436381986675039299069021409871791311458380181816383500039\\\n        046424219742112173490006578134174273521964245314430114787168157882202069218876201330410642\\\n        140360655923828430606592830486942105073817044147272527621703558942041051428494652503931210\\\n        669390409184638609420072921399699026097744179449769829230283435792692810785935470652673635\\\n        256791723662390644990631704572759064611078833748384456075211277608538192556044041327753148\\\n        138639089892045656444936555988475562589065877286760984558547751976600325972129678575227225\\\n        619685799920528350030051970348487136864847191035440635728456432603615008132600506394057133\\\n        347058832971653764198268857925162950816448503492411487470076612928218406251820348991550612\\\n        940801800895674341756917604699374767359698534057372195223429721919232420234242877352136900\\\n        639006816351482858740449976868443079528909008477582130610036320235546788113777273650552445\\\n        202943894982941552686445756482978479365405361717704484939828203688102960925073585596916779\\\n        200990858847661941434918337723251192147125531272401841411755944094971056482744695721992542\\\n        229821369305080298147493567756959755644000002717938319966578319722333029522361298481868505\\\n        745685587048313714600332457985932335326661117477408799649350100292159909465328950650100777\\\n        794701920168160041918064495704546924598425978458982463001390216551227492158341712951185197\\\n        022400948626033593059570224022300324239045849245422803309086630270955200195554499237056468\\\n        519498149019026900697448497498180290886871558399432063973627229371876379166555264322111736\\\n        730860872775700652199984879330972515341655852894025803682855719912685355401781090787843237\\\n        372793441993586872176536524092641299822891826409054304053448080653350337688989011695763954\\\n        978682287905440865124017382857922518949568590973446452418607539992894697787738730292996438\\\n        360891296615859179318813487450813801704106222182696978117226262772579473611978806436936387\\\n        729323129003612702560685747031820501607363267983580334725536397620184040066535245481965878\\\n        264213944931818618141383250883112767184783434793752383419455501047704319037236322573535491\\\n        860520345433647915862191356422931755917625639299951797014068648004213171058087285800084726\\\n        309038395765953087147936895272154611386976886488210423281260392346219329728397638625223844\\\n        179889904196692345857717255130057224702866687538722399620449874818129559471201328352676471\\\n        175711204330578605866469803680052605358450553065410515507917361228783273508565515911256306\\\n        138761878649247420300802879186183893223588744866121392905246316922887271538688579146877100\\\n        479678157576565003576000332573350981599170852539644324196018548994311316629833150584121268\\\n        888751615077446178199662593235940453562410211435827189223671128109880010684373765425487846\\\n        008408669788036744426313844777266464696289511549446371232669189800160864266408820751038188\\\n        739637459342773372461314485507296836840439497982395356998429550677139406691261223866169086\\\n        887602933722405597235287965254563142018212643898348721872081557316807412503629666165153145\\\n        943837304471633443785325736192673052957930025318987402191366405425579152041996215945766605\\\n        825847658649629423534033474414985522142274007340198625834814349142230855554434530814001376\\\n        649665188703530675498052952958827093079531068792394880781726265970296180123850083601437173\\\n        160828860344261740331914428555821832381155920270838450789611999893054586599176134832242660\\\n        910274446922478189393520535648463500947067109720577399010684666004078418790520413046678769\\\n        116669858075822877576721334963736208553717448270789290025799034629698620091041169373807350\\\n        972302507302970746814118960521590522077460411551473464736701225454111898228347351613343760\\\n        338947587983148987451359652272528287146593338376909906143470662112527289781258986755766222\\\n        384258207054104526963433485857079484987240759019353725664476320817915900008353636231201914\\\n        025680289469000489598955631297181064034030517737167646283031374938775671141139995109997756\\\n        561063869575681307108296767951569585272210647166476004356617428713288777638543838980667707\\\n        317693431159583213719533228532303403144118481720659905333549487484127225393552733259446052\\\n        835579743980902278915432548863055431621101056680906592996714989071051104563798765385898764\\\n        590147381051992001797428328216505077035930818902412345479475304612240047586994685061073310\\\n        497535792298492906081336180047170420596839385809732846252711823348000342070733339727417738\\\n        476014798873056778903740243036427255142841442231804348994531243383298887010914083756317992\\\n        412534424826664149684363456627554510767011071997017399368306248339538989050236195349436214\\\n        196554357141604384555483656416665423088521475180151210474736625538871183116930214210693569\\\n        778691453709954494465514969808363683156213775655815038067162705669437897333827712222930919\\\n        676078469238348663312684252847375562125580663661103166484406800762235868176013484956174181\\\n        120758036651239295119882287348268866193490812958441363941472832072056464413623599604287844\\\n        512356159553632061450069362048306914394704109664333398709668476593635796311101372798669783\\\n        672904581823789502675783005335162812802802772811882012715737204085647914565009012159716689\\\n        863532747246607654324221352069664612619413482896283955921218909296428209428117475464728746\\\n        609989358909560917448831183856289144939467445707217533951055842532347038109318529756994655\\\n        940344975210086221874118412332296854413466462184592534249188378213829009501177613372825379\\\n        357927657073141087020073937679685945328818391578972437757537575758882517555854721915810256\\\n        961703028180219669261225920957879471853129832119639820318147154051816955080493120442964237\\\n        970104813420169168992362485130717390469865425916555301918385629799004668418578510979583741\\\n        202165645189987929649820132160949568446266303427866244389058490344394227247108839611546870\\\n        202860717688348606182901406849071981517064624816795297507499949877585707416575106311338991\\\n        765373552997777837663466055293965965519333033992565011327683916969128753115666662245882391\\\n        642975166451186196617471070906053329246697340314097031893258409828662120358629517897032481\\\n        480712481925131239155131215251868109642851263281750420346528154324625814135582601460741861\\\n        780787196689426938898949817269854392357530298640320507153198643382981226942285073913191730\\\n        087851376901303283279421757635097893941260711813281226734709140743525129187725356744834400\\\n        308957013553754143117778808112573626985705001753169752852247938225055640744899837808268907\\\n        459071069422593865969665001821196778103714826781322262054525193698149505328780309371438120\\\n        280516373554981458960093680329524997935297872437997964803444348857175573049077734369900478\\\n        893014026559037487223493326208397585481055941457777011424936743558852112547446017219801673\\\n        419618185786878496379071893366320174050504139229452740649443883505696487021743944832585722\\\n        362306222361274814367762591369510447519662422733126456025738365750197234101465296803609654\\\n        367898547033293356131770768449001649051082896793012653779557410005020366724061795480987034\\\n        942196861347384494909310832941985760871194532849466900502644450867177485661573335897195768\\\n        584749895368188541658187278187363192030995074350645017713722052518032551228609495027449876\\\n        908375753225703097788607783476816163186066048294367872184735523346048841428941032484945311\\\n        805805455698311459390892886070548241905704007778972652047110421764893656080730763350965398\\\n        353428283354153494632046065941660652260188611628196401670446956051337007858933175789668194\\\n        531252016901551654923048812641774693485089537264834697912856704886205769664959065477354230\\\n        914385964193862081128824121144483305114356773952400117780491293122506258267978048029335974\\\n        830312321582304187814492085741337626182749859766854805854357164234095017522892087668087137\\\n        539406998049852784258919493426217457279818629288398524980574734678693168451025623491699319\\\n        491723762254927041885235686316320558699438527155682886871555681806709937335619076966531389\\\n        150835813429675250413984112603471807619453394977248598827090679617872430368692730959410393\\\n        415183104795318088656958542822224735549637210891261051857900420973322589491351970100135635\\\n        410567163799951305290220074369325774725148226961611982766132008361102652960465503756313262\\\n        686631759508539998646865550881069191002920813066067807898399880061333323406250307613981232\\\n        250485248546783062851336256381083198779870449936203114246303597457907906576522325498922442\\\n        429537703309126861030170697587247585679376967818640151334853661433379541439094820992109725\\\n        277329343780364273275942628457233452664946863135325257158782290250896596898879375633317848\\\n        658353043008456685415254569419137224339938809294047003295280285475040153042017111254844253\\\n        688955155169428956938095780032913294581737195480236922218344635855388669149195203366003996\\\n        068304820973172034936144051170561573866793836966364184744383299762766720141949399739221890\\\n        404720452945462345014146843527725873925430520705732144733913689513938521725838828008914800\\\n        593077533513762646478184904879833962743431975003725034241824108216056320136608106643705544\\\n        836599668234332177418025435010560351791067637187965881626807183626467131179545755619011346\\\n        636276494619556603292915194230947611188885317742160050192803328815924839388171728591005620\\\n        041862878103713859290282847686065415545723683907348715723674382690756614236844568818645582\\\n        811325540187772657136447888182363599636938101310668673062071334532944161905468234944530314\\\n        746290447908050975505256327278587308049400222285585679918818397442168344377039693501686060\\\n        390304937181130673841118397023933390770413107863221238160457575814434267617239035323364537\\\n        915193424081046562082800763675268493743362640047606639801197116103923615433164428888660232\\\n        132762534446699356488131224313376978568637725278532038802004023677555728604347250918925008\\\n        950851413132455221824730596073603429222745640055662149705603880405322091978449119056969443\\\n        637173091149747213574801555824973100664931969537375105057700384102852443240941875202514488\\\n        042171060490708855227212616576167232895624346120862678002761595037506029536582284363110459\\\n        215082997198370873303708615988512390995129920612987470029732563039338854509618573131410605\\\n        894895751924202434562703378316794561524994687016340487217035732328932792576492536294213651\\\n        103254159646894625768049497501247179120188590815575696196636948761717953457604852558577816\\\n        569365834088543602733071177178558201775020798141558097435760335012498645819213842941503837\\\n        382401397027816509375254517491287462560872157200422079885174324202033612923426031172542609\\\n        402781484907578508548171653141343296484091708401374858657048335957972443432061870851436127\\\n        139179522026506594082672873918170659041623738344007985177121379449374222244599267591843559\\\n        288290928467521359237950344790975435904872991641606325341984164759552080883232215387609090\\\n        764909020783244253109412545020280343858856532665862283575263496064707127349248679455008218\\\n        818542303213428548008305505688174413269691120419603317590717324018407279795576803230527201\\\n        085491634181583488050700228316220619194118993318005748870021375019552327465022456213616440\\\n        767622946026370868695306192176268393791428335970361892352665973222250148335784875487945489\\\n        781074175737897866382581576464131424662844003190381261146838390404240564675813454783664477\\\n        839078049604244679081858575555856032810490461686536143600742490459367871820545656621596692\\\n        309350830563756676176403588703992747665405565241561151846488349408520372614380540725374650\\\n        075062463820744777485967751297221492040168136469662974450828651646074861009699760214628520\\\n        555649974602967682500526821687684945145399216675182202287074187660874105284594646617057035\\\n        063400320987706964970142786803801317718643677449299469523796186484412880553217118543734862\\\n        522744454039134352271146013345055478615174782472400120439948589650438449635035092367806631\\\n        780125058236696398692859625075964852542667289195505065762040882131417732990394309448390546\\\n        673840482444783858805451696565460889541100162458479385879830998488340179561962407002174343\\\n        555374621237751793772920897809665083019787046324042230911038438440656879498772045934889974\\\n        137186638007545027032203456927631915109085010161509393275481973708315493632468771644718798\\\n        975066665406623907439625929611165700140122360447300916202777345500061784621555250142658071\\\n        149577061371417159885364176391176900912942387372694148494227641826947138049493730351907745\\\n        545551844018775712629102950631161845757377189714118088128082341986474046346613825402951683\\\n        511892377479763577917452981170790858759080280485234272512765197801927132211575913235321414\\\n        612685986743093152127968660054382787444813605179435378743877617435020217633129282621969703\\\n        902517451369583002830847872288305470613811691693566257802799288015104408267625338666957229\\\n        382976968123498765753619241537052057500344946828789133113262236962865117734198879530930117\\\n        413795561479947770265040268832933282661915738398765559654672858954111744151588376223608701\\\n        869515540231789939758237616106925356282368285453081473271807315509263386218373543407185121\\\n        399261063778973674933684689921557020633346066624132241394727721445167341015290020035546950\\\n        095821174274659507952317137193622387301719009275915579839859267298950201098227084143715563\\\n        290438686498364023960549260569112283520816235308556155335993071174686791093008878547467053\\\n        664902373064894806064249668760103944041487318145518392745085491985861833339144396520539373\\\n        554431855094841489952971627190797162781024110057281288642623129390899286095555842265166879\\\n        084253347325523519201046398810520006348173923902978358609842121829019232773446845679089687\\\n        411815074108290528035839605310737044535104306073852732093073596130551591518790028175414413\\\n        800963204942860288489620064062143126442468771302826251773446614496922642646248921728544983\\\n        982799928288685837719598772201273245266475894018562885275472358119771746910767074239417861\\\n        270847501129120085303512205824108193596803467324618109567027292921889108052810490713013739\\\n        737303813636626175738352151532036089189821286863269322852200079339887785109480313960989981\\\n        570974220577938459584936715457555751845609512428446101017962373208714058060193230089689422\\\n        871995754815981375833599203874328821181996926682765168917803661813655628660340726198852363\\\n        121364601262782497315722462720508886207002216935528087872676781242289848048037986125773960\\\n        633986939935248249858495245837867568473553107400425781817602643348650340048705334403698262\\\n        756687937059903365653229646815072112555345733788344523015082241287340085984639572430945723\\\n        810093658971598375750899869288892216044995874458306901923969575494671457215517149367039730\\\n        362841234496313948924762815552102228673240597923921775621549807211481701379206580311113188\\\n        457602604685181166943433274048181759091408933133568520347712150931740003487846384905697636\\\n        493168628102779788899303990393923941058486658251505241747815178900558068820879026655002735\\\n        919751915308534601247932343199762417370756337341733723764680480037685647141514704265980025\\\n        239138158121903697220295044119087552795403443854595323043207420149383545043292167949406337\\\n        898255991895289236258596574418761244501240642154277450471255423596178793402167102690731177\\\n        872734674951594993623085396948095917730386289150338574141696476536939218847167710154937965\\\n        600695482838017779195881981682528791469106757983698470432830569568747804506103511939570168\\\n        345225468311659043726835804190347696565864379069620534925368680528383367150410101079080415\\\n        942108165669716036641215547328096135282028963055886682338860867065525992898704493547829264\\\n        775269472527511919893273496455381820738895021190467038886711115916895929014408454122028957\\\n        233747602421018226742287722205392634432667651862843760416270671173465851016195601557232955\\\n        800509373744431272085390476601021098743755430675635621966250623645432021061056691739778813\\\n        362715898122392866200901924421097933956713788910593382822559685373876365707333054824389760\\\n        996861890072268135596665964003487846177663986372668439930032689538907788180187843541442368\\\n        071433066507595306055357689941871290523068121485230993817520430607009740823684519998653069\\\n        160591383085302931947120323517923258145682903217615784996749231264609364824521646107842902\\\n        886592363231965100845926630325327626028465499254957037551362154773993596618117086666695879\\\n        021470948262637498797784920979367186359882087557086643739995290124346555492471017035308962\\\n        189547803328256327784586762547922854117648708148696270438368634640842334707027877308966637\\\n        991644059181222408222211827842303477741722863837266405778741368148802440368165246725857113\\\n        781517233834289511068943276220397616456877338189808623253198102148778021585300425039117347\\\n        186707458321236406984104969849265614019696696980939736297911899584726370316939420265135825\\\n        365141524293084089829049119608849812007504152181003314197227300006373767154509849347046779\\\n        545765091569316238165043111999913381686080480705724946449817461125584748595281309510612565\\\n        715211226641536755102006081089213367470924775449685451938001231793791219617938754477763104\\\n        123823454918472272632250529974292346999988260593903026321946450668938166712234012844498708\\\n        513548165113257636027183974524755569774744181529560764807037424051484271122444709444535387\\\n        807499275990049129172897786564149923820653336131036247771297822667202095769899575581756342\\\n        595823919462061212110301005403757359160197538032893852340212895832998711248830211461851426\\\n        724518237835068585280015530948756066144440242854196638477714582851492062298312383275981450\\\n        260104691613458731252655735340583221552093537413512168315437721111905432503480701652034333\\\n        118389113037214235478835110010834720659350962683398882981853393638916128212434779637232388\\\n        211599905796182341625923888987988242484048212194380356316450605502046612057622732559248866\\\n        558596793770515368368699372282245608430303307294724477694513537369854349885372543820311836\\\n        365233796477758068246459602124772335227322672237777936851843438016394577742381827700090720\\\n        073646056270034109613892564554829927366698940786566705942370091761483749110716656204287786\\\n        601037004362601142103018457282870191679009907884363719095665781192811372791468260588973472\\\n        218017955882269558086372806496479791410519211666361125398922574651866852319152168636632985\\\n        826336573428612553874270092957886344273644567067223286853232544479673616779251369191200257\\\n        350425488359940923923488893088216032878939102971212664973163983139941691617731057318101532\\\n        419534064023873666936850111419758894033236943914389677517562252684305563471578959384314375\\\n        559704982434345983405977688933390420455763362995087079953083458798154849378263225146616296\\\n        176027290395831169118112507275826980713183910705765288387077575571470541300685102548356571\\\n        491822142721345610390383582894367534060819033833643746164018362528911612759262146850138194\\\n        504686146878314275394147367636949532567048330395200214540799703905252085959399928177569969\\\n        057444806508371614079817236893247099803857916694028446266015360028843752857891756620664983\\\n        772329271281224107525969446650127813217063735763930303627036651608573650559624440209283076\\\n        152282918764711560106198270529206945332936554518231908393858594696441962414372002421219825\\\n        792073820239252616059646810596333527970050040175264402624244522403402435536082142319379287\\\n        866128561068352102090205243084762986515890064000463971695483345530523394301233930237699765\\\n        178400286277210236040413364262542764004307862678103677255035178378290366837409519933109194\\\n        155409456227529457012290263565976798225449302325867260541338312769362329433013659284452149\\\n        304335941571062715900158314557306672191729749274419650408429305740516678045268214894121636\\\n        068529504038913417945904584470425541229548077564988375224726035205859608367148771841019659\\\n        389682244540392467932528177593999367604917427831776095498822601317575913430330753553922214\\\n        342070867603897076634245377182444070324901239525879598910708942726225786219967777050558108\\\n        767186969577939773503425659275998668283010301842187633684113870098549941174647432502308073\\\n        619846225653890466558053362958063660480311189672734633826101841982458764210262578949643133\\\n        257881148521077337480454592705177152205114892872152565325163622727944396325060978907936415\\\n        848920171045031612974784947624619562475446366522853584028030478591323988463273186995734911\\\n        741062083560950328708921120487034214384362311293523299746109282787660825986709808472885202\\\n        078987462968530082305947765920853060888008580505740807076817710916663800533086887880852810\\\n        528074057813929456211095087238643210769350361390915434179610108601018802035874415512864272\\\n        401451518970246702408974560137582585474724204791531977821627493852420273050251455292477873\\\n        712013704809711757975085009912168041907965289089534626426228652969692620453929931796658249\\\n        007214956811375068317159696275054675508865683928365685584963366021594168738878084683400286\\\n        821031514757616615807966062248660806785980608345258844850130050768546896011676817570115927\\\n        114274110308723993093144390137443348855523338188811033217680694070906708354335007301758446\\\n        057014081939254655600105770084278918719349692597833409112788662623757848194453638947704116\\\n        613329485785108236724202701275879329044986407489883277265498600209418383303857737161477237\\\n        388115409732832165911244586608719316212850918558407945139326998447906978657863795883753956\\\n        186743555223746687313911341142889546894344049182885624562295676361571641121730124984058354\\\n        500794992672145130608635817546287099255770540733366690503434341227281148004189073808145492\\\n        473722031716450683981257518938539635355222135943390906825836727664947954183040019133823053\\\n        241701873856124237550317612863393413187411553510686071246845282734094923086379455469059127\\\n        468454507519305779741960475047368250935154377046933699124722596955540328912074023312885050\\\n        679976766170324298075040573432281823086135089910186171556706541225120549270818310257705522\\\n        126901869463603966584980044161734675128812963646129259942994519680513395422485672828146342\\\n        981400549246491556183623452918730409850914564226152795202381299383953438223917764336205587\\\n        393222138615369734894926216800966072792160805447429752231570208730823401306809160245190150\\\n        652951688306242793666152906295236889790595373203411893678812111009226689837286390594762755\\\n        937767871752638798064977649473957295569538897951421185872665095271448432164530912237494409\\\n        648509238384728413458749224132229012508025355710209545098284261685654800276690548820699221\\\n        830118398585408910672453311156719468929932381798222147806898695769042675936834752268033647\\\n        824461834564355494050611449250009198095851762813584775764869576693190436473480910688444878\\\n        562019649611754762706399218426776863639595983758470559987115390738032379622832529984940539\\\n        483983767463838091023166748853449818294083778736934603557439733778775759603098722339579270\\\n        503384560462010849835756845582353296657224136080870345559095173743965656628905228705339923\\\n        103963097134376678650121188174921140719441868471948055365743845231318726666532810073529307\\\n        749368355031834448528332083983987052122993421383671307944362273702629257040156540570742412\\\n        025039115344379205001148237112096860028473863413464187607983084900497309560152931480882276\\\n        469582980835766222355771949792224937490670160393550241831422211625215897357444719947611144\\\n        455468074884184067967488405804793862846610439488722291724750258543663144231885434853957977\\\n        370828034119170313731385482558783576734324563537638874859656286152418903834111897516467473\\\n        481420558673221463411298018569439729478126205509968630576192985780293500877873627053142796\\\n        479637506067513608656176349421747736956423947925245058613042366201925720298872746074410348\\\n        533129986733587723343123684323199984746091136761717759024949478880585880096810819133567185\\\n        790994377277617430613243674027376214647309332220168572511275849271125214714345641697668732\\\n        016019356326508721066288065098439546364207800881539874889401606252398493976336439923106807\\\n        562351458662295515134676051871759398715724342010549256814478334487818936425361152162464497\\\n        717595710200852268303628811175242191161573184775186624513056107568967668387715856601303575\\\n        161516530993709220960212777545280000569772540197442949811552322009667043614377925831638761\\\n        010332508247613494012072252930928312162780465504156960364029274508613967807293271158151973\\\n        254123151050872496131546986151105421650789867224861512597528131079655255156962828693727862\\\n        788348742711254409534509647114596870154417113338325125988995829047919031435750910197325784\\\n        512015904010151268525125664768101577006806986692924216426085943281541270044352493075977612\\\n        981257576887109189992702577490907224127201145849030818211676385991687435069571384838554407\\\n        015983811117522728575378869085501429447207379833044626313380402526164439402381714908980030\\\n        308263458823179548539432606644445717840389478255658680642662356674268644308036885216881171\\\n        605084795529476095318386537497800291521968226993773734885305239553210820376761290254103513\\\n        064877528462482197880474514217504126095053758912504991184758542368255567806580608907596875\\\n        808620955935904579493655693335525933673695171641789061138631762084570676499202288494989545\\\n        676744802706205199440267282246407608136845343204664962918921813298204546465431625325291757\\\n        777875759119194932765070130853156491489281330482851672992610305859875813105854444045866330\\\n        195832930272962868090251629001262427672036352030932271624573869445040044409426115918852352\\\n        386190488015340472837090770129658523162849641878761448646778950103454738730628574019190893\\\n        195178961367639977865782855667756942414285086005893214607178681636846032388085361643100224\\\n        312897103937406450810131171146839155260242860037545658280474321925843225475921991500059904\\\n        893724867170418166647704369625862112242132648665765232686397266259933413564501203426805064\\\n        304319947071544477404329128753364984628929227792310333609413373447991009689145772741442871\\\n        118441121959040036230789198742103810466444010033665192151623482733379862439005446056835930\\\n        548011647871178517009918194136541722487367967728333796530346553122117742581032147561934805\\\n        597725949865622154541530752826622344311133946071541064883391118537120396048480336186457043\\\n        962813791248765286267310243145437402487777748117843552155873907033272251113386216428240877\\\n        695657651055659021793921091263372680271735839186618464541192774632232900340878356462048584\\\n        643002143578081834962551834647596645904115465806112721779925717522470006694636594541418059\\\n        471711348513259826932096758858040775604486877576573612811180134242880097875285667838302707\\\n        784650956456614083375464215702896348907784522203537032572397228017931252063839431293942361\\\n        387112168827004958386477465876815968062631615099821322287274435494544704305865146284909425\\\n        752190115162930996337599961297377993898095757946803647616597127302962527260449414393232184\\\n        109789154051021476399035838298018155643514192250276335920910054645950817628892075124490352\\\n        917207444471031911579756903279720476459685884696728521440642700713409969772174267462858789\\\n        513871181398264896347134332316202728361532264224340888812166540800216231606329985270731825\\\n        526583588696051602366554350377300001219724190808034927772291703095303454758257080750712881\\\n        171283327025276282836128382912380657249088149916130455622082428081335137598426087120002006\\\n        352150088632113052065194653674512930227472975796898513622387814235816564018304016843251816\\\n        970878940744373070979752030366628960482215788330110556397241899346561620661098211406686043\\\n        357487244583582765727391555643897052341557307570749704033366516837414991314023295965335528\\\n        205263747423608045241981391231911705867722936544972609569568326136736300995682212378916221\\\n        614754012264597745077406333627790846614162867565105995074600755947306011672661928934963859\\\n        356721696856359853979336130350393612226742538783062843384049466185315797957940709571142587\\\n        682771827929074054315241526630467647638215287611720015591269220129929114193823048976443925\\\n        444289752166885563579889887129713409634060799468362969318710370368918880590390651407563874\\\n        988908564213926543693627881039662002322516832660873727280453277613470608259837382278226521\\\n        693280123059332612011513729119557790671108961807087934703122444773747371215757499212817293\\\n        491296263305291247482434462803569253778567582638607631637966722996747286225878804250443706\\\n        952916301328088938191866899257794561370583018029167225635511332829467483935597840251166946\\\n        973464998761204164542720737578057135767370446607879487669940418903447444725221179018471286\\\n        872538815397600171100668199216920904591483004596395106458756290908779244781862535202061994\\\n        654435638034196467563708787769742322737315587773536401647455326106935356697906498185416946\\\n        358380402622532181548321503572802117946270790595849184012640937066865116732654512574826265\\\n        300440927188447262014069991571758310380517971050823181642417563176242157968913841627149539\\\n        767482546510628399404319016477244511216291384745165998956569908742127439449409225332439548\\\n        199744897818541967112641312000004919360568508913389315141008346671201357938700807237242764\\\n        175612671095710707190924871639482148667739603770081107666365285050180218421762832999856314\\\n        555776280393007773303338320487187735009158203206454693065330580625167361011015239203563939\\\n        670354562096034451813230420652498617104671334353491692041489789430326150789341564242978170\\\n        386819341131546669175177110921518699422185516660246656591430670406865333300782452050059151\\\n        246076742443463871729428758936388613115090689750067412469852864959866958859641545687393717\\\n        390883145748237210175931692486062179050404695444469712614798990456607955176135906694443076\\\n        367461848535498780078265714455055407186437114822766208593268581146905592143235331349830178\\\n        497578076356678053685774194762464557512834895722684120853517597756564866109041170792960587\\\n        224322922571847971935380601186363715138359724322751509149383850509998408399580083549047628\\\n        893725380329671081574653755482079952013856558751398407606239621348451578588094057399731098\\\n        532897935534054342892269914232731323928331429487662480739384018765362548503020718815738466\\\n        404109033487749892085255158449132132829862948454516652953498009698128038756104845631791913\\\n        264195920655962240750681011977519469288198484679127626251198365008136156751528470881302986\\\n        963738691272689346317565389605450039096659819789843822496777079409569728323359873697606857\\\n        219908242318848573709357184575924838372159022850096103230059929580645091389431197227402407\\\n        204660802021533900213569023210717453218508495958390596459406149353527106722665878990927703\\\n        691708535069004187080494536745092882517793371854118060643581160521480658019346196496913290\\\n        733327494627985536865562100422471592319077141081010056553688822333860018899158642527743478\\\n        289432946742343050884983132829084707858031545256541369405698544783865200458223175005239169\\\n        515958096851777293893944971532492230055439266034940615355144103987825128225642023817710417\\\n        677270518590324282312369742212937032086949295311480972380159037349281880243323462548559564\\\n        036148564084885624579621609670069598197303484535139909382126618558416065645363264521290712\\\n        659075640385901469453335293004925422168955388369770710075906023369558181331536059450505543\\\n        649886145964644573961293151405882255279583802786976689021153056324185556768052162135245500\\\n        380117823840841567192612660393148715628475976017707508909449627847101777304727517437948680\\\n        070987926783281646672653515558931371935178660324825022563133305822065147395326088467510809\\\n        335857672608811240471781821770080748692221417435895777442105862295865660331993993242161014\\\n        395598217652348309159623592384756565078227920911303508037926069029298772005211594736941227\\\n        550879675369652280250725705742667735383317560302922120467692528907811367069970518206268659\\\n        763774009956893863308500331649078592931203171123352517907617259767228785506666764151476203\\\n        817181719582074168808198064140339865825976662129667495845409023550257211397572253883138723\\\n        946625686246351625926738822217539589095332910755391967420588355794106600721911348694567116\\\n        456772724309337558527716790360773120926958218717634311161620113915353672465658072397738294\\\n        865720988224280587614684004902800784029986983516289313606893789078380001484627234192440164\\\n        908280955649075614294115830716837873566972065901168676826891589185983283946232334076758075\\\n        111533225339219070679416548013270176645186488735002181966704279838348733197574813884342167\\\n        080460674830249768425460935873817549542311473842354465326642131007500706387201763024136299\\\n        359242128977116787993597421699388777796469439779054263046423282044626175070511095816336979\\\n        695938246995776700257395172622253330792335984600393784165149355913972400111586275226059528\\\n        071680719287698179571822060104898765049960669845727202887995927676658793595914758863792325\\\n        211090582394265841487064022796023689890862847001746523769847033747263480107576895047451369\\\n        058584954852592323298009229479130824116389676209451862729111887834434712466865758792529440\\\n        489958356088415964018862863948341012182768265335552103724811820491573102230558963549145601\\\n        900646378148701973337893877881763865079130247943446518308891509951308496583570066059434248\\\n        192218459573809718393810466003332657527821455318249355764904508368671624162539077644461203\\\n        692492131927969004751318820643262823882883218719858194775850910443543458700134044350693671\\\n        168627197433306505226243766686216337965401016942690899606629506557562963091156294145255262\\\n        661741286030817656213045294446376016029880731086649716644887758315306689601076907561108702\\\n        169896119774909306431429208396110540319115228369931752426347005261050627301765698103275440\\\n        586489326900733099767304615724090841032682975391197365500068749889874623936007063151271092\\\n        025957354088084894551653488789843974629947240546533687096348925032396895434510188335439205\\\n        017703217362985915814862753614626455684220321481262821227003277558404637805214772781194229\\\n        989287195140150305091504649601057490834376908135508958791856629971219262264783584134605005\\\n        143809902648802662261409499363515893858997830190483425427111416200392851751915534898935376\\\n        225265204593445747961823434507517589935010448048633710215253148307730785525824748160359193\\\n        829260766485623015304355774375465943786424910264254595614065858974531793804354964352279492\\\n        447598956027658878595009622421851651482821119417239721236949780453807897518479112441484892\\\n        188292087630778224392472284435202178165567006481358645070705601797598718951505104227306443\\\n        846429356155034939666023276593685270252328917696391954185565047621545589361819188567608179\\\n        342967274399411705645903495150979925338678598908983102842515061482305438062049825053782774\\\n        607766651558398540384733154743837601382967901936533437432805757321815782019716515429420611\\\n        476092931135542432874292969479080276065735922993157332981387011718328212897720287505992178\\\n        379537395822413275743377155554307493737073202517448238317573573355132952688924235651766373\\\n        201070832612879648731047232920929940611479451030930155448550600007889745745231892386743273\\\n        209002268686100510019527887711092411733571204658142586049865876951088587084003380691668229\\\n        693517509832670443442409762408012903364302455536243943786709155080243752866569007216858307\\\n        904839798384646987487388454302752753842516011430109454202000271672728518180818990092239140\\\n        612669850864605543503596603360539619223508385903644516342573854515157748686211302223684474\\\n        731708343264666995341947804863112080905935415486832036442995474721496936445718246545389915\\\n        196998541873484728749825118732158464412141384735012748824037358644355975370997230696122765\\\n        995673096065735166873251692065222630103057524617069848918401781966067160015028616000087752\\\n        441874667842576438805400751799498818374414789287350548628976074876297719970166852812246321\\\n        938928858305689927476140904745799072491794964506866128982091420908376763259819780206055092\\\n        152709260416178906396072404868670431370237284226573897697962667460869092042286713300485627\\\n        163574126592455870841398774942632705805410803772690396411203269379260677431533816246941783\\\n        795453409006720697926032099689941579057159131432788111681434558987045860646681318216892288\\\n        980454256718068037426806924678558146663918465413885297116507179252271417350534888598189147\\\n        466563826575192981672602039119367277005045000942505770196755650698618499775290430745599178\\\n        198675483438382756410680338972159378088736221630708590893404952541639854982939176437747590\\\n        441091779503265500004375786402418922562259530761319147106606618582926033332180209946152844\\\n        479883274488205639519829920029586712866356752187971088919195054217264647454961294055114147\\\n        097423707012966007430692426438018974232518180009453463077610781530398041018271765503624888\\\n        267551300683672439048885596952711026206032822041848601876955276865054648936969601242991163\\\n        468132386742076304870027372767795582862822288992929802973820813761972191944072065668979954\\\n        832654970825615692708030373237833630414233503736709360360854144627800159599634863847349094\\\n        195910918844290566538735523879231392542644239295650535994167707530208855970569508582142762\\\n        515978150470065581846886607138164929691439138020394533249612370712184962466504944480602780\\\n        949878243907557364709747082343790891171163190643109487560482213799733758308954250973677318\\\n        517311848431444093065443073116374364163545593377448991384394858979433337954735733815410500\\\n        583486699250575677139243747867571173647249146180982521407876743599298356863041872781978550\\\n        369736653688495068005542260976599776994235050796064402406372807307195744863412039043567830\\\n        287884425225447699441761028754693162873270147713305672036772880610999416492954769533137410\\\n        444411149101711092906308934329133997028196781791442852616582672060078198706709116184572179\\\n        456864963558937969452838969223121429662055314025946635874388068243040636042717385653221639\\\n        542798798849219728055487325268280680800346320487276663896347714867154116520120268055496515\\\n        248254068448546087026744166429556344869691444637977783809774052556180687485836749002986334\\\n        975993104991659339175751336011118749280632082415518320979302547371432390200088605990101280\\\n        643285405501712304961055185970899033480139782322067827495605256498458240963053045149282992\\\n        750457126196507480698488009102735294685271463226617056822225098089455521935884866153314002\\\n        005493158467256206566847421627508640107771351754986756140159768910648481453017991852074495\\\n        162981822205608327387103693249650550524035069413585909333832252975877746870278724056565932\\\n        291907901170118125846000280456308868790475360671106371012830114692455446077624345190211337\\\n        168874543135520828398193897604635051458158640871741874953935737075477438415272230251625675\\\n        759960321541175106560143283994957724171405256402847751678631278260769511470737547026812062\\\n        336633123665206526474107723123674374751741115083792194920214071038959941907495895037396673\\\n        448683077177900181441669426146974107450912132387955016572390183752305074128254199024337714\\\n        128109367484767457972061645697469113977266132846315186977556912459165078861282699234614413\\\n        642902293977037634958118640128898328615687185724592327120508293802142218646096285723308972\\\n        250810523778469850276673700386529195509267285321458677649789538978006450792782756249019709\\\n        483094305364973843312369550343496542828815259556687749265424162817213079179144832513222739\\\n        529895381827244825400538551978786604141933806495263694150773854557509288674468524742235976\\\n        040356854594791258326837251201081521418172351512733489780249085837416241612207988638157463\\\n        898336262689713898209525457890551736498243939262494573244757322711168373071161148732745047\\\n        625404441803924748019649398526917120666768521487711593979739076486635564615308576474495031\\\n        161407642081115993949503485798236198814623476127947590046447170220097703023505957339994268\\\n        810694663657200083008719702506977273412840083741620318604482639849739798913959791624548045\\\n        787976372212317073271825317110523802202364636615128729716326389303608487318745749202066215\\\n        446099077440563842278062274609474227868543987320443194159104382922849979492049510469533885\\\n        664528634971096642610048849171985326909036233953040930405678415579471763448772809762106002\\\n        240520188064482683228684432626859804536853273920566034068413929229824219906574892652007708\\\n        911305815573371760828586896652200243309285447011806818650151360469081938782079505431741022\\\n        898631746748876572431684001548178020016387237231453975077897805194210272480756007595047817\\\n        072179641515698081724359536200388835279394499535426179567656068776179076422779380946901593\\\n        296037912775673679908356871920865222776852930422902573517689917141936405232445748192766752\\\n        326149114210496843311918312722833233503867222294539424714546680826831431089395830583061110\\\n        621799703531543112481542835464829973300479213622694624942766451741469287589480772124356517\\\n        484032241777158244828277226738157892222222774297195682200477454281602781566529432439520678\\\n        962207922197669500582775135179739758800532765477640360539091021219538810440745503819174974\\\n        543678830777020963919732277478995943176313802084792368621344588594718937746657023837304438\\\n        759492483292461465409726716016339256043632909825482806204539795500174658179177788302620851\\\n        015054726016343362755465477175551702077367816907413663692552902360310772569027147098358138\\\n        176953080329454468976717130473268258403920268606189394538864533513001272228375760734722902\\\n        949196778633685221915617523575922091890321476636670102476133480400305484165691133181892873\\\n        285602300633681336333326980320535419895301776584658910756847682255202181224728027384264113\\\n        605327717169159314596640988380041964126571004937859339462111794281117404128442632606095302\\\n        216135318508625893485388698404614908870852878149653901801202031680106302606973515614142945\\\n        021645407742130961298687397139048808266715608971126774954702069266129390591418273608210741\\\n        259248494408071911273584395664558613460549516230861165699050985989877179367325141372995684\\\n        893325155600253522411792216393245129764629320394610882016137420305615278371611350031064850\\\n        450517144360143958067819227360006456163145886094262954546334759968535770187841445910494483\\\n        090426961383683055809496573835263363736794876492758007394999296905844558984090704733913792\\\n        926878531926474428760038488000392742707013479382032566825590647204587496000887019741593791\\\n        930751546687732745488232359610811879433451337305883193449568393012878887828311857591540372\\\n        152368564512417672409543849830156148454290984732685831169705065271949149891324447714705640\\\n        479239961751411167257772348847090215972921374451287282560659001384161897947792004636342451\\\n        097273679074442716088066777066727945744574828358267649596623681376787463084288157368508394\\\n        983100279541128475640821629631603635893611755116868173090366115038011857845712456314410635\\\n        339316084812241799415471575051868505721201175674016234013148487189187783563763059549663968\\\n        545186369894787858990640633477172084078474527402445523110422092800088165962038606708262509\\\n        405529073417953868863004636110531807264177444439784167619818270671697809335443896472067055\\\n        391262524314971313594763228477895020105127268747115467640031793571876020545182899912559371\\\n        515890437442155112606143052716794170091724480601020832811613516581435790660081668903652866\\\n        344778611924669118187984910110489920249572382055192090483390367550511107244305630411308476\\\n        246034973417701566827086650817892082268399452608247497138757452413970380239277204651133588\\\n        195386583375706752456037932879205415818838946871991812918268798652996353603229825377961286\\\n        525690638601578415944844449338605302011066760204714339008292388283590992941385144297181525\\\n        681725219627499750943008070030267952639705517325993040396807649287955801312996530693704504\\\n        893858711714845695166214823377102941274203331794795987217861761102582133518332225495412332\\\n        794865769776117657728976710091961906510058802202868352826020098788746426151913989606754585\\\n        083170982229392644738185802395607511169818825907062400228934499744969376312838562624835963\\\n        449813109448585481726215828925845960304199979371315813318000963634632578011854880871703266\\\n        745182161071312572144174593794444470407254103868882677060552177259664684562687005376804734\\\n        423920390840193907054307323802381480445473113378564453740133451782178956305235908128823078\\\n        636951948157439244853043577381568069057107414992597148951838962480526682349033976855559886\\\n        768333360201946264640091464408656617309149852431253488829237267983043644895109455682738590\\\n        628338233678662331108405458869239108175329649953772577369620664208066777406604247550680198\\\n        204806249474537813949661966622620241266236596146285628772799759180084369133653644899184803\\\n        199819197639172538736540825685304737368452743030754495422428874999950062866154624614602389\\\n        287070144613962661974769449799699775548480531783909649281485248628043470058665293722356554\\\n        880471411204580090725309280310147584006035143226657335593486783564727318205537734390268599\\\n        256035629932661414054959338927478521810662688725005434112509496696331972087774539450114157\\\n        497187074593278096319993002606004247594674444021059350148937292103383339525225320608095711\\\n        632869400777902046134936588858385025890890380010578272311671619035444658590952483824993307\\\n        311125107625358818994409675336468321351203765462647979814149039271332090364166897038210652\\\n        085958840135144700475892890442085564399781650659873195178899091660280092632155432834890759\\\n        184224468448707611630968599262109508135261629480817297922135676652679970335687416812318561\\\n        789469546170732951987381753231529954418533372238195872663616020522123720168125538587208557\\\n        555946878191194074997352803631808645437803132969068066305538771077530012744291209735376656\\\n        431912020074086829730431253839909948042486217325631420949754395935887245928310466845063108\\\n        880911868655398898675761320809627011469338079149151691981338168921279809082474511870613033\\\n        383936915399562675416350951190518496533142823683002975235816914297819972014901873281703177\\\n        157735663442776785617167135778448996433767744227846200153465412380749278637414708921096753\\\n        194739038131872185923979374218450097138414431949754937593867093220466225243675201725776595\\\n        190008499980121406118122896357474176746873241299556717583740275096294752214550949299354091\\\n        914857852830006376249449590208625201590816685279904725772037272100295716992880651489411491\\\n        974749059001644361899755581624219885921071096082313539117859154204566276202574518640156669\\\n        991115133089644915630837435447710936937748204984618026335128642542050519435551328828421914\\\n        820720325910446182881346221016850383884424071499543221334260986557907070203053000119554756\\\n        745714266111775725941533048479943827435251584022831205890358063279185974149214939272879661\\\n        183429850873400851444870573784934172199338402247968788702081580766662859378475606829728768\\\n        465047089354054048522407833598263451368027296802207184935570651562824617625138161562567740\\\n        557049414674866570897167246001377324098810527025506025248634952289505612008127192046937719\\\n        895230220427539784405756892998610560159941320534272573766067633548595544285724450047126510\\\n        728047529734949700446144176376193686634775933000333311765162590551926122200464221087092147\\\n        758254291212546570476027322986234596587998580606094108120802503401022363950622785306398735\\\n        107831241310459190514632632269229805001237303351131894583859789627186916634232706327281594\\\n        104872235954597725611606564636127031845083212235770353552050167026999352648281675665415269\\\n        411437773190481496005442332397933906697849720571392876807788026976905314207983204450888440\\\n        716006065229624618649535244893733349748363220595216457580341010722707672080231160713630492\\\n        993184204388255083361949121966199532693263516561310928020079320904649951861105886417341696\\\n        472915558865431315823188914817721486834112177741267944954948677034753612494748387072629819\\\n        756537513571211040525967861151110056418205210068268984648682398173221129372823967610359320\\\n        720868347175592825677945781224920495204577337591322353462852339731722991032689171236257135\\\n        578230101110503962652894359843915458398847085509538860115589927888261194110467781716503467\\\n        432975718740824884438022951344455676655182195054414463886556400032301644246098556585057311\\\n        546751580741950626429755591889298716409466794099585716944749529678531120202337903496876615\\\n        165622966044389646266944134607486991947499105864192741373592881720201815775339733862214683\\\n        250892425876318451742585755396603322792190049408232489975358298149805159136323045203223062\\\n        089533940203774786509759462875457010255340194807426469726613857095274152760709576752861136\\\n        343090472530362954639097423431110123349130014599224528425417876995134068330844903531612021\\\n        366510996284457354043812484511901646979649160948328451055838695255317134880130921661794259\\\n        805062985206389896321840011654961597343650228842732867140899567802806004861573668827601412\\\n        164828306770650894969487528340548256781941451871711857894939266476800166422288777579057560\\\n        366805661624684486933529424246662011632883971016420857644480363099797064430479492623440691\\\n        605523311318692290142775414168321647619304698318628808961182376599034034332955414832567780\\\n        827387778563380321618842818007911179591021589001506406125427718741292760418407223244381283\\\n        249468038000849231456254436833976197868612812480175157334445529278999446455467559658409615\\\n        221705850416847657881271759106438354510966315577112464590677047033144214898841393307604689\\\n        628317928667390366415827610433179766679008678579932468105586461301125236624322796614883929\\\n        088327496083429533409681976860850136388534170807401366007081717723518891163007426148403025\\\n        707949861767067441199850613983186789139671953585342432960341291646521101610163079358004763\\\n        779588286662340532575603834158350392014708872418069701999186124605547481590286213613899729\\\n        252253197423799843923546220649183477078608985577180291823621936385385111027801361823875700\\\n        554380246422474067684442988109651704317207171318087893042416584605627468037579218414768722\\\n        395710690168729596686682745071637354932561366345482509721228212355663337189028720856492833\\\n        744887592038406303624032902732604618747517241666803983932798099811078126156432983249184932\\\n        473136572307146854615781787504214488823623822207282237451385961404022080549083543735057830\\\n        078625359266219032498946296033342496967334137744772656968928260141620854055085178850164926\\\n        966163110798375382442578243086329744653139520104735091231773446275069515239708357989884940\\\n        259762884547112594628115079860745073717477371224953481873188607421989899925669464506534765\\\n        315832211855736580979078332191340642607672024611896901736635958092452806328787088254707750\\\n        810296559903236476757018102375743624653382025962020905387255595326834271155337737570960701\\\n        126362899387053591160403382148549056958617157480097927304635569061076501464422461558422871\\\n        719274903148306130083749845128286690037446939323440977451259226675678786924849429703261050\\\n        078699779544603709546416898200303604921965901966739621079369797329691209940055207022848650\\\n        850120234855370246061573153096734344579808093359339167896797868890939240978596243588801835\\\n        566932348798054099424097479437654044919794668255179495446506282879142122428904822604567804\\\n        809212174463782525848869524423515136620019328820657452371554345734028886972604813756085142\\\n        695128000135255167064104978031426010335586584132358183986707331301718592663484171256265696\\\n        827386195465252591821727129614691077312098971026449495548094661246536715033400219440381339\\\n        050939279860235113768112384293895172770560191416852175017202353717944307488430970017445902\\\n        991414630171771627441856642731130048823800687449421860072322735790128760444057044225440854\\\n        641880474223441567328886228584420951792909470612464842219303001515269646638034847331607617\\\n        295172905878575178911604084226350700222100432604678889370632689904233406118233045506095065\\\n        479209575688604275397263069324199916676323699068831625663012082799958332811645505094984156\\\n        882891812191744747939227691624340578933761852652298612630701899486128576583061793294219433\\\n        204506787846507163286981973260807566884823848718656503577885230412324762118698687155132689\\\n        155609070357767942128077574996707926931711975604858655907326154073653157263549608459799093\\\n        878298615727412162248423308673582935269980285569350033530454431081448610509377414596978455\\\n        535179077245802932313248605968555406350283832887778615882121860304873324004373133786332090\\\n        579688147848693092684637067817495022377582230525258773063477882289008085968918394791322317\\\n        180625714470995010360773055724914272257023496173901990568040350179680643909460244074158780\\\n        899267150188989719587263436118563621425629514841356709058617850478048599635473401401302549\\\n        487057768223564263211661020028112704238389209566949834778050515383488322164489903890634630\\\n        787082922625570917536038325346131874848277664953788711668659291007139020778719701774489285\\\n        770052544144241621206676900540635934791644404554993917216777610578867081736023355270807782\\\n        026140606588473450429941263009930241855215247181378704595846267730745425295281947225019478\\\n        890836381664382576806020247406249722930194605659888988773274232694496489223266344802567289\\\n        095509093071422011485578096045410854089803415057240347231255441508775084902081991914425972\\\n        682757232064532393847798803346310000710176797840190048144486098228764863010842530023727388\\\n        890406061733786346284822599853003356708849637188791406834510939764422440140038457222679412\\\n        869944171351398025075756826180558676362407068336671423682972405813575058365291417381270436\\\n        252634979728042320257810122696347785459983155670781951349052442511560634900447996471610913\\\n        558203151102900621122343649394727258252894077852522420262321167927416066811130818872331886\\\n        384411496081610094820707968514899635836282436270448625530551867701741689087219413741907483\\\n        303006372951080315863644183302558565600160707444394101909936633140497846760016702168436701\\\n        041391533633662081837449021935746582246327317820575813666812366363788208142591568010850475\\\n        565265973969612820222295995777172202676243959127979676064320997922278889187114535711427023\\\n        388134947816557182255726036768915930034750421800979830489093634049356013277340811560053696\\\n        708210234546437359490037883329254262127458561524809162699982302320211977958385638619396750\\\n        584315342067577186261412240331619185062795418957999338158196149422949785688017230460062919\\\n        391301228838132414311547083235730760237053326735562675899841833991684542150174148682882466\\\n        716679626630379820889089177131419554674700935764070833604579427642232609659002948697191333\\\n        359555610060668704386903939577904889683386230386135356228326002785943648269230493417150906\\\n        816867363150131431418991262791598509154611194943010143698188010247997600675221374192019001\\\n        258536678010794762058767602097498480306319364447173990414944444310915594084983622467587036\\\n        733468286071724922448436281799390647690552350263518734955683889005087257899331236094086355\\\n        596292869754670676829081962068968092702963219719148711559495435769020625081526376494903171\\\n        888299538225048159010636706430141636481924724841451993847511336878702067372651362150019886\\\n        320278210923950189274647295313671276916349507822922900950709902541837457116287891528256804\\\n        163622548395685688353588830574503091077316005563783210083306510925680346408180601220429988\\\n        564081191652821776542055168473219261226828750817630405576548229070598113447515611115731442\\\n        436141219042846761952289435207330980780386972526801138623666896745153682517024465387931795\\\n        649389985327072677183129398826042589973593024105438244196232842063517253256625665867334881\\\n        916534480986763428493868706905601179631142859993777010282182506697591463042556361997595988\\\n        625740329156075441383575975073040645372924414662180844689122596854078085881035058604117634\\\n        048870467374085876855500551016620651005103259410314494626298400029489400669948922612184259\\\n        633813049452786575718225144292003688952920623087252891267508927716028159422970303592340020\\\n        206320250974137167576176120630725257645922573330584745081463445994382367274472107376267415\\\n        861852026813615963647053024675786755873581626487358864569099290650740948966808382951353867\\\n        798519156757041420545680486354790279358191960864824612371976584588608712804128344463824880\\\n        557162484258573591969449621686567377012939106713008094272836542007766036255777711161037102\\\n        864304896895486745587029819995754115416308852304342500322891439682294248283417164891789388\\\n        964683060270812974373120152188767442021094213697371394396156878661887640168690668291609792\\\n        579521106251945909115899365342560558247523025009318460503965637777468187324503983449394481\\\n        191659963511685119649858345826533563547990202841500140026486352743457483103229831371150862\\\n        719166145289505458399536924699756864862813875630592398822135090328615247496005185815165043\\\n        427259154541291415472503958549337020102602509921405725763639960250746925539727209250540673\\\n        789952330733501642208550454905824014373709427673241753369533165170693817992813763408742910\\\n        890860072472914734748916057077837897625982620287043943263515577357296774108974620909015897\\\n        821593378406689735629791688868910668311922021895814220518471358981510882739599697158281546\\\n        772369695939714558905235318447769171091759577171927782564536611159528231714044331725309572\\\n        148048605303696101250853749560558247506259564368725027338640683395203742514854314749368042\\\n        862679505750873501496981100757368471354470143249509848809163231583968293708833309569436562\\\n        656683668749050706245164835699619920641507763247981769049869524240784704659436599891031160\\\n        593212225236492891365792588731721189259589394456517262853344452117456469286102653954538148\\\n        611292558306683781159158705773029614757843401886766635281558084149856355944562552928125286\\\n        795768922195939460083634477921849688760269784241934897944846856873942450441687210213716855\\\n        058391422955248259387025726334446959221285224118006664585610824913562441585709266312729574\\\n        930404901321586058467300493386586896431494049812177913137375134569841094812718317298134733\\\n        974054542106533853292674821723954653461747797168821854717411145877959646864516550069633592\\\n        702586049543072919341809849769801193303846787156234825424793958441195143782167404224752955\\\n        886185849600159026402542303271446301410033873705634336963804640427621760446117331757246167\\\n        630251743030744490259587710539765867793208734102657436189882016257423158363991837207407011\\\n        723745232135686419695921066233663274202602273897832942068545505473508027982889060562501985\\\n        784912442106157678262135704232046583879592645472615560124169290589871813589560144610511304\\\n        653084567249407224488051119844520873593857530665272554234130553847996706095958340767247389\\\n        437550102838276914090863885096349143007649318110600062409367991451779012008530165945853595\\\n        126725813632035083556405803927364962190910362259474638376448162740393441231098898143271479\\\n        418396813471563315813993538485188886059981049108194801891454541586189155825774846929764420\\\n        361110440704324355622269134064521615719852781709831866249434065099195761453993691649550630\\\n        280522533795142858908609680915592022539858966052466051144091292260058381342484073008782997\\\n        506849621701987152602130976349384138850811464582360302170473483599771191195769441349492286\\\n        270054990098119570497269201938602994327286525227538178850084665620394761772584698350007842\\\n        812833358050440730521671316551253208514121744988096128738553988914136510910998063035863871\\\n        289288957001180056851115849289219097190682426574747278858258830147949019782535691647462811\\\n        854060001211182521787812857284689712849625119111832624298431821623483504929554348547051810\\\n        004943030877417320571524874832690298211594329166219740524468332972920024389888787941754261\\\n        723492672638998005383271020271459957722255539763716024877000463362873040283387957819689443\\\n        812823487554118544396731177720470665449888522496965295620012348782699539200893365798260545\\\n        653556424656120643365723314431658015927689932559065245130962218109023456470747881202422784\\\n        516081355690216764283018613189351241194527855867687117114933328453984191927080913150510188\\\n        053900973546988092066432582339497884109641800100329840191278918935065191291054887540391341\\\n        938937914253452717895208324979525104850332885716289309066724447003874630355891587343213629\\\n        295813397188307429073740523681132772531308477583128640680764927338120768649006083821178534\\\n        231882421252593160475209347876366022867894786346161989300104170530416596685584108386379250\\\n        648960270039496104007853678264191149544304170619408606745550730246028289419799215089083030\\\n        357779550900547233642285022611591450201535610220670241161823500710530351306589598951476339\\\n        962538590701115039376288702576866092369110293721730793357258686940503936971875060806904283\\\n        450172626406305611530347647615937848772028119358834615417184851493391088745654551203516741\\\n        049252625779941388683608251123016695946703624605778686102608501949278384638802687672795596\\\n        101987910231056478732778755542742098497398706021166366631096586913407253211199019028032079\\\n        887902886464331703411701397951161365211269109661735796937867092707794733743067336832875903\\\n        644574676989384544631166130437333542500706745373337299710704629124879789369167412410374122\\\n        229333540534789624046636561052951181998007191289705010095525673434353667968966277973878367\\\n        032667466123821409908470565358374387914742809113973925281589469357404181624952686639787235\\\n        553858657823751457634178101614716979318930589368932544513817939542776550243395612324971283\\\n        981644794341354626756409056527567305052782710200245934375457665275621318747951883639756564\\\n        262352461930368366604963962952173822510321961896985927253441955816117358923425092450848619\\\n        642137682993248945574466178398123078103013572003611141584245535265186693381011540791087277\\\n        753791269346268624487177970740087735772330112007363804305732617292382170057476489979663707\\\n        730516936708850329337446242291895369660713218350206191875230323688012052846027864882848259\\\n        701228357313964337999592919094187542954315038199934947351626232636660813900683995931429234\\\n        275232497883988387531746796147980559728644094032550849320858447017225191053779746122025390\\\n        293856659524118700940670618255377041328161470153565769885348129692600671991346683406187404\\\n        122162260559118061168556125016695766778501991528337127988723843289142276071954357101572277\\\n        747492357946304708982397416829755276712621092325294086731199992464671408884307828064526627\\\n        154858618012984893144529254065982651440535202322594021843831491681617202732508862135260971\\\n        054956925383323817099659792847789592103705266129996676820628100720066735040261318266402281\\\n        895202358676507456306345227539986877419326853929528618956878195537235695921499279604750824\\\n        588765075564055392116444178757900011181848811794331791298695702082965280042280234181108123\\\n        456296503173665516376497198275013897623495321371366964170732065174285988636380245811724321\\\n        642699521502348090492297677147796202905758003566831023601973035417752762549932933198482519\\\n        033340228846684288573601294796104079178029935084349235918263815409392202162191126337299973\\\n        085391905507691530404523972877912023502020268259524123685245249722717806623898593059219721\\\n        671125285966083589136586569241144798577749561424730365261715542445053121404880119549009963\\\n        940262229780266389459421325711642452074666067479827481424500358755413989311032224554098600\\\n        574565090710931389978486043939125309152103942909706547255766111265331703053938672472656511\\\n        737190668202667955961568647373933368504367595246796560022670828614024510944001419843570812\\\n        035316882802096152987157192635175599145696929365351128280840469102759254457096887698704481\\\n        227730529643558479156854116915125046321711006632709104074508545831086758358396848811368582\\\n        168268135110202243520982111839335996265588876954982247250866935203576355207081462043166690\\\n        224797698996092949545640451370732244152951305287915235643316412484417319161785947349874164\\\n        420493634114416403338368439170503832547660676000292210949209559366174989996963051092763659\\\n        739217101256203680052534093269572885689640918448275087111358268648076610357729307926314390\\\n        736377283544241978604202729155353922391701334129386139054611641222931440889949319415919574\\\n        965760368509976487269003294029030908533570888930299070935666660324420317046763615235198855\\\n        805723479369543519711530650534833557727400563194470682036867192541214827247160244347606329\\\n        437505568163698740244545933582137985460278090391079898426302190888599593203108093243796000\\\n        837051500005677415307442023841296321429595533657886608005990023595093038618870168228908048\\\n        907997679829388915693339278939164067080422245717423906256309395520118753052222897430119677\\\n        679524735595489324426737976645241292326623772291197564152114277878984801156634916071678505\\\n        070627677237321581043324158835984791444707011693571085749226645312961361799982095689269872\\\n        220836335728393266358739159822042068866879998976711541770675645254343685674227484481160283\\\n        370420564547224464386038569714609371300588180742505737575858790359905300498379894816312604\\\n        682024071823813328040378220499308551193272903834894542174618040863674572075532211153485505\\\n        994192637118706786454062304969550359770549218823456415819585823182124532911704477695790440\\\n        724343169970597782710712144341827675482033003922965698963206685687598793119841743683203851\\\n        189542344830972426311389035901052711211193165639094994625002338118606707863672619400314067\\\n        055303369739231130861626694281827389605365111612253660517264388368729056831372055264207608\\\n        703602087996042936370551486004168518628158586817918533781935905750385451226387690311232190\\\n        751221826417128365161241275011610603164330193726587616113141660492866242483747071073169769\\\n        635512074696824594293961238286756634065162567135491685659136988836701083054696429316827261\\\n        748741994511427403295611849052379501908408409429890575318268021614100032495060929337047238\\\n        886493196099200412859027950129950023122955239626288365396604288132328191922258258633109225\\\n        740162199890632526703417497215914037546382069102125313696510346781192537133289241484185472\\\n        191994207912350578927731782204121136438529707886961713961900059381650629266160385604255414\\\n        812610441885792558475534332776485111024308513533723742360313386451081721865147713467439351\\\n        166233199052697441034130017200437878204499782025048339277991179273538441427436885663044325\\\n        347246689446898607830707017087349294966809793794528161472360208878541805364972744252373111\\\n        950645208069918973045079779054771488030758531984127997276190919078284116347858530059060502\\\n        973977271236335837624517580067704646948275577230459828239880836857472122696441163856735899\\\n        937138593135001631499766800488361478258298501701768877935809297758214362885297259006518947\\\n        434757962698550239303113302469447679737036435465978158966217972784366291350652807294029366\\\n        017595253801959655253981909215020208610634637266462782872612117590296831895699429923136985\\\n        002152086719201885134903865004159364714295080669164318755587913488516068682785428681051450\\\n        311719224165020474338154852151646941634921372305907905628415334275370832931674705225184469\\\n        504011117569571607786226007425108760766851889664329109441321343124377157025893065802266219\\\n        093396000013750100568443887734085728806768012678059162465708901892508876845390422152523855\\\n        791458713645099185634678263676665871741837932800054588943282887835273785261908723176410467\\\n        369641656675135370757889653781228103054241121688685818663775876630507617418767673395379168\\\n        632709705331936487133501351591017075577275947040812881585100120161229734355016484195119741\\\n        067125252087855021757941772874228122556040050247330856849156883108419638562082765203727733\\\n        053438152874350279016372907896031132216812541985645012178754867937975571357114545231527041\\\n        865571908863288443096333124557512538156351716877712771170996233179735707548910026184975287\\\n        060134407697297834708058511251325214969961948585213069463677620556609247957743166622715360\\\n        200278724851201455977470408020007196865873450650035877862683156738584094868224201783629459\\\n        357012216903000117352936586258042353273126269411727103235395218852807604298822998623634981\\\n        467317840189567675615543880603673804680783999871881965570283438249366329502602137840313216\\\n        370723714436718287359112101339796337967458706231172948276553303516673986916760702246716913\\\n        197930156344779389953724667626332988336624131878252708523954165290120063994913201453152111\\\n        254307081222094254756865565092428295276271004403776412442501486058320614804271080300097824\\\n        540860558678266306686687439747328171919222597486524843817399047114395086858509795268603048\\\n        501572158601002439969506518498438010040029959422806746715137935409329625242798391908052405\\\n        919581725103492224678547694054309288983279202059075881787277202356474690497128045882022785\\\n        120144279320748261737471698775015314207357452634152513949851185435204823732243137714788210\\\n        069121725221913486844454548558824224716363884769813462391399381386264013736157750249350653\\\n        859914473264154041521165563788762178450501641686607053570897529544386087766616328725819543\\\n        901828453387944308167456166545660852912531980418824133778681939029423225236759800064117962\\\n        426018965385940930738102044884342341961911879343141265862321612174715902959600092409864645\\\n        665811705453176054609462660361302822927920927886486768586049382098641738679290492942412052\\\n        642862669893870087597680590975354197814997105778462286387390516234350362839658478775110370\\\n        792194147052568852662335958222717292304720859963726535400584066003174352691840697308015820\\\n        108225302737777647044790471274104708322247367181329484303405140774608920655083152273850525\\\n        642797645356766354373336165804708994016707355690433034405299388101821764438788801637863706\\\n        268017246320342981232612653263324728489400894105111661526950491445558915934331109363479487\\\n        700996529948291515636266965946237181136138047533438901397893500855361482648234830120728895\\\n        275655096620923030249131510581820984751954941048243786985351356025803292494307789155782087\\\n        365801823945460122311992774579448550606971966921957173510486681285163133603226093764710012\\\n        366514376355134971179398057605368629379888185702344751878601233954901544074327497404115609\\\n        079270678908697207469256038960465926030391454569512567368556013804578339241694393908176799\\\n        318917278595880318045840137101283459580044824211455654786344904590421238002961130576032019\\\n        295188692520480481111849503738618428112790307781671826746760286484127372466609139052302306\\\n        141427938821535333046432218521518751688366555513859578008395402485192853052315589186046240\\\n        336659379232510575114063940174088286546231232375094624572064605313525559428480724129280002\\\n        473561533375247676467576539138598800258364762597436404774378234654280047626470635245280798\\\n        856113993982555390271865695778075205520502714479234742337739390013704668999318501607050723\\\n        571253341312677076099097929950352242133897423820131218568747158036984654782489334054012899\\\n        350457859902368925482345333939823598995840815258712068542907348652018937216680175648578347\\\n        280600631860952404908048051081500201584012382050417695910440129103106717505745127620999572\\\n        565461172707373578874360272620131450504898604876638945238995199733604095699954659933593339\\\n        956683608436111072290778933864052755497173730865386920409141509229729056716236217019966504\\\n        414801805058358940995117441519290940620061782066783035286225965680856429726020686594753790\\\n        552334753503972439232780957604304715275125113033720235609770463230184828628364135598683448\\\n        464172758917544023410375783573121877810955564664855333583062173409351472686918753051966534\\\n        360562138980541994128848579537986987473099323835936589469429671490573526125563585061603521\\\n        887227437564868439308836947588029163131713130443730950726811766072804290811286447790602624\\\n        607158565456519846975019561478144296208444321386158225409554468680883480732997101700070899\\\n        871337163518096857764640888353376224104894402388839212889044228280798826455981312548260573\\\n        302466872626136956058851365053985178945894311794979384773036557689575761237892583397489778\\\n        634650121976078180959903786157236401381622072532459953964100686664142203340728874481570806\\\n        938449833508002363162676209020698107965165028943963542134436695963841043713577528704444098\\\n        641362720065227930419878395898161271592417828661189136443196005246083195041912103002045673\\\n        643474779290515457485006631383609895544104164935265274513380242294585467221782830608789114\\\n        016088204989165842398235678561549657371085758269089411047865628947223849255626218237335558\\\n        271508564470104237275796045778375044948942340914626143848122340356637304179790337276037940\\\n        250599713921378676396350686799137440789780860299548492788975979089564412968411339337355964\\\n        969106481228800442561413460381657450128053777860658569315188272872739221697816932431400485\\\n        844079311141837381494881969273040099451533628999978539285860032800628035954633877902521477\\\n        930085693997392922865757243128759131936454522265287765178327037830386985176458600868252843\\\n        803395118112444081315841135854516287006178425229976181802317875442294702325881121459470216\\\n        401895919134456511866498263277885881131408682067764349868874607661878403734183756393639386\\\n        093177918645369578848596411550928251658126865886293017646170825358310879915418855549378429\\\n        614923995315560133325364462165981048913635797307898351955183481082835033630615626694584505\\\n        349039622426550608295469229425933549609690644586772554622369689578222332197218442115248340\\\n        197542009097622344093350300161241885733884429478812067570031214075034208044147139683693986\\\n        738283638173426285091977125672321699921496651158554063413641273519826378773294725205535247\\\n        353835552070684288104308094495904438232180714144716654221591029416831552382750963104009173\\\n        650246896840097059895392230079771653080340892617966803049581244339483590100874257711214210\\\n        765740179532294625314914504053578793434211959259681414246153992935040172095232154275345712\\\n        387522794580039057566795224464316983245704899936720342063200026858764886327924238265650177\\\n        859516177045051668289231278688237206232438272612667863795175640158139298492311616238008629\\\n        425959815582026628729282265268739395113306786691926756017071415984308378958374011814836520\\\n        919586202399674582815274941001802875096942160301001448198331312345156060026754802936996906\\\n        713521643249665497242343102785961586374244166483721450125197070610974421080382478456844781\\\n        140350762655293403438466564121174477294769406325517589377426324313614982252887530283561214\\\n        095139637581896923304589858605802173887342071887673117960027401325121974712222700879403739\\\n        937379652482990841932688876374568096315485746678069675760449098433889444760292773707066356\\\n        734514139367234666967750021379351601977196099780593652841714877874273897076999700995877784\\\n        484254224542187364417240127037500070064967215820049746439705772389221397746808100890662987\\\n        678059284127771720130608989489006969705397948996457137368571925521493212944282518740417900\\\n        318065137750312220267652743504527022409087153138628483688413776611698484966099352233295753\\\n        058101507786518018163169965900093076364630416894359375266391896845120634200220596154637245\\\n        038015789483306305496940578597112136941203453177455683104626248237405020531012455054306266\\\n        461429766551231608755532248035147667710799575702985725312348897701245449850023407573330826\\\n        080212600314834506189352522878827755857431429567250822726581726990358253034155160178561356\\\n        299613215386506134318647797421364593054165338462150438362187128711768622210204074707036514\\\n        769810563021689294971906209497375568056382771610051183032807410401990291005403256323591858\\\n        179477996257618804324273972891637521484810284677341296358967623115721025861472918959371209\\\n        955914895106132818594949773538145773887447960663776070386477222718043264626338576830634431\\\n        604874140223006489276034016762832193787265518571505506627985459644540648942313914283972474\\\n        264947160011411259101578785132398127765329665431655750277663100801474963288033774497279291\\\n        916294773733271215698084214280417833867770632988957953412409199912553780600134664301911522\\\n        927416812652853657907891553370592607086458180572359745255866068429921890034627797772501915\\\n        906711535800235444861010185077151768099257736969104756244894183623922864411826339723241502\\\n        386081474542560075698748071215114007869866870517801947237860846416464165668946081838839065\\\n        438030889901029182672666454406359555850414990072273151719426474311901040514086485210033055\\\n        182138035198438530340544045428087925823983791885196183219157475590463612039213173634555074\\\n        502252287308689018177449316202634077864235544219295863242051755419083631358039691976910768\\\n        712392964629085234040524930745725491166474825106177394852328597798072061226847878415546784\\\n        436237626075492694927459463054308382449278480619931056086935888257470752423799731471482968\\\n        189690403091486078503197687181605807908599061462196675029345994307712989285033910124611124\\\n        617515236800759742036191302458540127639621245868286075276590655148823984980950524956048059\\\n        462410770747474492079968699369428701265046530952919040544320852234288996696947029932170581\\\n        675010258659555742407319209148263668937127040453012275534504027462283875602654920985947336\\\n        746984925111415756041586494025203540932977979406785155992041738885866983528252711090001126\\\n        658033854334235866904087633115294753515658939488469834204183733862203607885111360612675183\\\n        244499196399350700036674104497606815716696409469867899195882954448582740735543961363748724\\\n        743740126325198742632987451652472936656797691515259071360623713397503708195299902472961533\\\n        919504798130589454700446450763193705887109573240127420347350032320154053534114639452176145\\\n        280599429017677145230996220144062790042855839573406554119830951846793361384981605380599370\\\n        943175767863557569568891879777200527700496996277467356750412946073709906825587775797516169\\\n        057524990736142297489343752885807056445981506198385316282534170959869444237464762384970737\\\n        709357536536634857829415426723635212857152474733861124359300179589023398417459217940339640\\\n        437074430044236230343124590839679224014422546898812036918523569667217725175152469934259697\\\n        273282597639015550460365135439819211263856452643234976883979986639684164304333384857161253\\\n        156554627877549993473967908692378269491402059094717026393716894665719061760106978880278899\\\n        748376509138645533499832783484568516015554654190257575462600607281103734672941990434195422\\\n        928494591743533285467302899990723929770879747318205893008886529057041409468523141397009819\\\n        534784948522111624441106506030103669998399060464398113943781537367346282943872312729933455\\\n        351014196518090276926576068051761219721534258171961338383635624959561021205323887895639376\\\n        707688639305127092461026074647092179516532810705950364676458024039008286741695396490887700\\\n        491097704124970574572423396241740380677642717757172426601908137753492250841394772492536788\\\n        695459704420227316778944019245629197423520448413609127872558233074869226510246952164683834\\\n        691240897095132736331942305850792353275922110923209974398663118164945565405975460234571146\\\n        247583118993345025519121566695411844785818447287367487539051053812433210834346104733598625\\\n        322403001864567085028395627188935463064103545033760399449823558943366725161691586551226760\\\n        297836242265063354238200790523133867072541000467336935555740602793776630761717552566931256\\\n        246841161176973246177495867465397298838043635017920594555718483836207336811089517105035564\\\n        889757721341725581022496713438777882472359601270286277257874551099575668001936525633020735\\\n        477972200458142432645715006034630239680077043855770490466015294169284998044077276475278351\\\n        279599949297237953054090947785167105283042450058044257116722195073191682913720167571705460\\\n        023910364422446168123557198404951242122670141806679683455234724871079673800669476763785646\\\n        990722853339180390942492232016306232440742092938580028572993856856754652280004885740348848\\\n        158525092140399790850166217975948862827384496942753929045305978288543408385763598707892493\\\n        792894688401671699945999384098904828369031385867711025112264491353142821462478649163932604\\\n        582223305512259105107549873911911750031965157243660222661787079470923843600479547458205776\\\n        760355330330125995615021823323558378250677226482592010852059558115503942941332077126341355\\\n        914801310682653041692862892554076093594527871494836040974394905661388402549848200986306542\\\n        735478192537273777688969106419267061777218569373276934338439477901184876774864414090637646\\\n        250703978331394112029880233370038202082678452980920333607341278103708787340480810029396687\\\n        286170881430569951612113494609293682789333024992993009917714163545057420505550963890551133\\\n        513421069081328008469929060644499144807654337680628040168552158466733178230076700550089619\\\n        511567046118923273172758397333762220149237220162323860762991076947099500943296288510271528\\\n        942558751170948115200998029445222759207482945972404167484663728575749848542882433257751542\\\n        580616146913568713381620189504600109375036587294665060233664333030845109896451302193314459\\\n        702262225680405825270083581331734175068110108176313834280403882332421225259730542663199815\\\n        901192018907685131520208264251917239375487782191748452641331719969065563535235339319428016\\\n        016442453556515955110470446740681620667172115010440113458545035042711324274731358301497987\\\n        628033929771074213262488279882193299538864873910665410414892295330017003091127380932684586\\\n        207341711990530994693377987183148453615113213909015593895672761432272924733459359900095275\\\n        343426309397938253813556004614901381479341410649437879631427150655825049591569920625902203\\\n        793436281718900528975523828471214689403661747345953083630746235422723895932048794673334098\\\n        878011267002120554378948746994313336256168183443475199948603530584008303382753575138211391\\\n        049387768349488348361807740536193988874333033506117086986270618585132637455650572845821791\\\n        136341442563983653286522105656076939802625328301543100870207559526295341858049116948433128\\\n        211906148184235122364737817220486810960333885127391468182364036820560572438450175110012769\\\n        595827294143488028031986006320674667761727455008970139879780646357333553806958995959753640\\\n        119320234480985834138518032808880919445718284392769341972613706988261085974255896898148808\\\n        766915558704252679371548323230821911938592376052317687552996618384213759905631006009392374\\\n        791090350493370698390282919725401929825019666057301930479437437001671624227467258715152009\\\n        304864164297132923973580507829216590607402867968505132960957170458193626139468791855509303\\\n        307077309598991478623175663180982512319275524639706861607213128768424408000418835932860471\\\n        395906861432685695856917336426069543039753344402280000343741234574426795452852982184202247\\\n        423960010094753425428463596214794438349901355288139607818007271798035303225230674234152672\\\n        263656667947003234789568837603113226065121846320969851834227256571500858990011513250223411\\\n        444493584891604219849802463958472877746441691856721758365518892567058861404494660657131794\\\n        210349947705738770067749837791847771455580690035239348057971457916527629257134647235819890\\\n        126505514212505720435582559910669949641810271051769356419546258888300927597734262145463923\\\n        147688629047271443167172969003096370395209831128302169778520293179477520211507408988872073\\\n        303575754572330014635335413875712202468778331187593857878881480448290039210843250510431610\\\n        916900968194409869237435496878617384881941397940446741731072418133302394242932099681189108\\\n        780295473637617987301240157905651646338148045032076147110854278016466327542005573818395933\\\n        990814857736636672311355102457367324674289366114555653698598312284082531665947602258035425\\\n        142687048211169763817831024407517329971403235104944071641202457924236434923760288404656542\\\n        713083027755775258209963103409168455621333810230509345589438941835459524428773097023089008\\\n        745959101788421201038434121900253826870317070247003701036833903181772874779096708475905356\\\n        512712484207156109549053090681031132386096226298304719088979619299905725915048170260140707\\\n        029638019426208785589149090071245947946868788595502503678830711807742885183045013400845507\\\n        379451969204400012812326626382483660771887161897773419854540790511453329052789601099716040\\\n        371880340096414263246830201951412226682205858970162550022209132779229549206166207028294298\\\n        436542054532131893096795673352316484282235117016612450754309688628715490615638311277209843\\\n        229326111076977951972900027388358885633010289978561727897011932205243885427115701030074750\\\n        690979871486406297387372287068879742584731121127179556623967388114459467818838193831619150\\\n        472157229988506829483580549761210785736963968896239398513202932009955536246857710951128326\\\n        193382973043086900322950274019352166444711881242633979156143330428790318079341982827423275\\\n        327714184915660815599124235753331656219268736219961191236097800078128167219990826275358780\\\n        145358949358207827418639228216989249605358372898860435622201722022887135391890585832177778\\\n        890092284960776710861908660521794748907274908280344962488832788940424516132926846052300514\\\n        403762188816474941407120139780238123999955941671492298133698179926019163449358922433638483\\\n        511685224428046980291758406252464561148824867101485940355306784163516427555719164001253712\\\n        009833024880330212869198223289482054781651014598502909291429165481190396184732550421495664\\\n        756012523187399230539020417715960524478488621439190718225228160459586725585116088341536234\\\n        540423724197727262640821015289877730350760003269281825213340015546310289776713057033977917\\\n        893502162870106835519141632881701341137017235661373996009586235152180021727258519062092428\\\n        476594528072512348334858692388080243604187964152882516402046508298038290287633962493751911\\\n        600462615924239335352663534079039032245951852402268110448919375189627688200373549292790604\\\n        815597681524033589514582285724513696914897760355118174220427873086778036932844354838715108\\\n        597556701890034679956545226416946071927195573242890828184592919486766598358762181304563521\\\n        050212226801893610913387619920158316227497379920428694789695087274670285198439278814517785\\\n        917147799675171948047720049665793526391800355731012337544750707275654261636436134146781573\\\n        313097447195364506520948235011201583810064686237350113130351305397882757892450402175050541\\\n        288737341309701672221931866581780933979550803293285021753845846890849501971096690044917026\\\n        071072867690938930530262054642795539723046329677908373345106230696919139951334015326849976\\\n        853644752985513912610914704664138226705254945662138629059724861104529291168148077214432191\\\n        556094067605561762428461244836704112445460314492191734566176933711529367446845034391578014\\\n        069445423774626848149889869479209231546786409495061653443083466918327010035070088282390366\\\n        725353640405552070454337254468884223452518006113184648295650989905467995926583695647390388\\\n        316077523044659647430684168637065060435683142086384565563483754958410316616922513388979686\\\n        977568355221822186678648753788280763395030466765459368488932685586900448910500271695214488\\\n        162702918468516390879823616839690108918166681333200998583668246140627128706119112794421585\\\n        338021856407105708606571950127714284183333551046997156171104728603704778366932750803027264\\\n        636125584740990006101940958256281313479331561064556642814295562554504819577610858667821346\\\n        038223788117546979014698061847355663629918146970335375379127067719213654469500370837869288\\\n        798564735693630305489590713287602117990877410972872095693593264918675247033135457614603825\\\n        479990832680004910835323223002558446789836775887127052689182540991787467645897300385478071\\\n        427496170058755427621462452656652629510705120514181816945458854532121213586927522257510404\\\n        040209174830882069447664445158331780206696071720248373854350609689361561147986781484025744\\\n        803736778842701742546800546539623498215040490895962181977774719639568800055513137003222664\\\n        902494647385182997972043453962751256101983776047386102139721100954937489831011254181979237\\\n        522212085463274487414980752927361669885594765780328036872568030937208729590834434018459219\\\n        875122739141696181439949795716512102684395051831848041533336320918683681798741712488555611\\\n        457966337273921301264359143829564129320150793850299463609004312011996709076231964494601447\\\n        928898709669077901911947948436198570683107369938898348619882273473679961436383086936539295\\\n        077264792422508666093770276348050934362536038158313939292545986978946876350653325517906907\\\n        577759604003516634979759086701330225168817208219598282810013627005990105269122815882003997\\\n        895123914332399777900330589829077390310902482152269872179764775897215319319335129925700976\\\n        191793132802142407240707309287040591400325339720691908669239773482432847566852892743617624\\\n        716654139554105729907144407595379797813383835909426383203013785701060049909616672563311609\\\n        431866651014834813796176955363392746035546634607850097617912515427797200103601033931854791\\\n        459411524458159668476854727477487280337496421711514070335822578782593472645679344532781996\\\n        259906939784311553246528226676627350655869368240701651878293978605404807315121373682745367\\\n        026911068619168745951418634259086849048527741346210559602383702341448325036937962877244448\\\n        201323647437337763389881937457314044888301763556086593593388528571044109903383766126278297\\\n        903753190424181199068068454135448348114482705628533042487434360091628845986142570797794087\\\n        542044386595112887823848503491811194655226967898479093836020074113197068040418745551382273\\\n        409394660309364105803272828875463024772361962642804235027703413814964870094755369058351488\\\n        400839743942994094795831476831595776689655039041942511228047553790838781078613905096389469\\\n        205462598917901482750960816133560724098610399344578581420327253030047169151755490411142506\\\n        825908504261244955156446905146578891917425751056062155646940339573259566667169076790817108\\\n        139077723702463025099694328157873508138004528054626496192733647413111239081218337612927421\\\n        674091008897108637434307162845693677797795692354762285132253828603208514773625710230020722\\\n        239385303943166812681985395933862668047315294832152524262496659344092356540813121453568368\\\n        570427476609811288562830611233675713382811032811405783468681002801643984680655650958929211\\\n        526769835175698413596300470985581129542625366573419093627793138904478728749471773766711515\\\n        475119655165597811006551374411450101587903885246654524655130879220785141960148463192233155\\\n        253254708257355362683101025573792811706550827733255024365465484600888897583651175523547936\\\n        049676635318816752701034645767190387406079644068348373088908196566491875091464319013088414\\\n        334635734989252238528009448667715239053755405080654887027812772031793398388431305061522705\\\n        700754008877673768418476856290926072445239232218838615123693077394641116349288221087255165\\\n        987936788220596408608844256351442846640311232197775525477317170455503487461334178141706541\\\n        573051574526569715202681246182950291540368143160010753589033963440327660081178282392784989\\\n        786418133950196666994502846835488683484895939939381335102687049178177493228967145083318501\\\n        531428488075732228606093354416042211916334058581499289613347230357939063273737732174457000\\\n        304189440120016672335771254170035183643830031003899575661077835661600745929121572078594403\\\n        401131491610297414718813892009476795052308113552421388142832726092468971889179729418395897\\\n        170321150512787335697909947154749235430104522807195684173334522393230690959646054001638389\\\n        157130045814487664196598546153667299015052079978021572835969348092662447831520618406046538\\\n        743205133719795065110720491409673729346388219349601556162761126518623762013445550541426096\\\n        866572628548171913025004217367656107808118815036271245565338989349104922522969348133635195\\\n        911796146544177372772928182698723656156079981566565872511568918614822529781787357834673428\\\n        305265035349326042285939683766324448817811205776328732734889299504015061312187293493613911\\\n        797273753052569784531552875464290783475913710588828315243424419885146426922529755960253152\\\n        869653520835950409587189585223127397104699656436310414191880323888077880481240586032538790\\\n        240662980219644995237734293236693514147624547964977396333742616458518956810540654145043054\\\n        202394429205039103644112999809204762548209432928849948627758346263983194850603357763378893\\\n        804368082012757183618929421713254985389910360070367033118488143381903045209669029148742069\\\n        526774224568685217625009725566004175944441964134290697598362041950230036070510297567418760\\\n        508670107610495441510951147097807072294809058464096447291215960257000389830882606387553195\\\n        081487379931551996418237804329866274208088372238755708841837016741068062738506049611240708\\\n        661621993695039389005596562645832680931795053640827696002713781761117361779978660771837575\\\n        040954056498016867214859773971728723401882072598898679372538036443221366727787074625343176\\\n        743986993932691092922518238614376256391098644596884717559858973821004428626002082853544271\\\n        845736216521026852618342461640318445660726070972711928816889589040282119822069775273984417\\\n        897546120313175532912266024069889346996900904900177047810668770381177075474538544947564933\\\n        912231450203804481747229975369096805333317816576536030432983762037028929083484446532383951\\\n        994582531587170585618896043257574779062262042582556248887373959666139771745034987200023988\\\n        587570009087752197810191387687420058527009595456324654792323616390402803630312998489117721\\\n        945476822669023175189221261322035708470365382533895043962586215431638022083733959689604335\\\n        808274702038575515508704776903102893165238790403027547864147609376027562185664063504781566\\\n        805475247709673996211486735469525378626220396088218290583564622831298613942729421363195400\\\n        991877507303477645410347745114660973358949081920858964190648046567656704390885905030291909\\\n        235550419132823638605913286325284558771499042482058508725028825937640550483109291681617121\\\n        874254970515745226086991672606330054087514824968837487167004839849023114452294617330968416\\\n        539702251673504893569522143872738084919122024223832462285791992983861062267250687601248318\\\n        835841915534385432615012385358087348416559747423953598720019664782789682400292744433116343\\\n        679205410513002945126275715320178462890835164227973069639229586125746402100797824447492781\\\n        712144879480751815384106733445014815038663265752436713987592841191843056418607402850713384\\\n        761270616094353130623001975263970014967960006598630985918271731382167091587832475273652678\\\n        956585347622397309805418482869192447153890532842010001622777412823785372899904995659634327\\\n        865821133473298967057532387678638361103880075753434341948150232332774665986834053269871835\\\n        030722778608264785601879127309815044601846240557653260618409785535752928538685598976082972\\\n        522253668502044715004670656192785887936168343738649125044330500724537698061409255704614926\\\n        545357781029106313832012743274011593296962376897442865592391997052358745449913591835350162\\\n        518267444937029259870615692123530043338539197151321910011252626082228712636511688425057368\\\n        003289626341468996849366810897633477913185356699911630154955361306784681723846597935676765\\\n        395381111856124317822739645175858546535954438530278608470607641763231373592331592142311323\\\n        442001608066245942508235499012713144191940330321132866479524791974622133878458787414119636\\\n        470740018994004200429624626561294680534754417115841953268916522295303985924302312357538759\\\n        286248162982127909072502486102358892945229320753783508656681487736192647021720141619653228\\\n        575689930431400420679199230240406041803705389751273223387334740426422248465566012298586399\\\n        393229827035328284226661157262529439924122669244207615201218557902696129512577936801911620\\\n        069632203983816410362940678305347976560000450980570135580102860243767098900763664769818374\\\n        979890824838100094772732181161497728855197224128072440884255212273232352386228510927718371\\\n        803794865497045667676379881489047938653253921532556625207230094028845793836345817907067333\\\n        645525825107930125039728057768641672196131143084755712500187720246655499386212959412813535\\\n        664612874971511941082791282463540250455481105300063402868637261079684201381107564751470650\\\n        464812030127919142323387435597989691164405258221439726404721719450520675281049331965058570\\\n        538736257004497534276407709257065503751479920195944648842458417062585351602587746066939490\\\n        758774881162381225548848834507942456057983688019605907602516766081624970375289321070701164\\\n        233686741651854396566584828538787888887687902753753128514884083491569032045232590346288391\\\n        277556420124600928004104309098313545604711228999096115794561757503563543449850527739765286\\\n        394238027577731402046665013295830798047026523140143475429240155774581541649025824241052662\\\n        229044339753268407409490138439860374811628924230504311850661721421248459192672137755629543\\\n        000730291234355481197461679856647964393831900815932055654129087370901173904845183884116797\\\n        376054494790723417338141062866448024058357076678138698979866584954390861168480026574657856\\\n        992293050953820082710316735872328089959170634105026502292341436200655269689124119663834228\\\n        202049732405591471132221273826213364420990853873095875774308475516946790400730811267882072\\\n        300395229821126755538999963397444013510290478303737114150376149350397721586539791131141731\\\n        351168935506300880914858376369374279448860807065967591778254228720676737827527500880892838\\\n        684661926327974263053917982318955765568213804940287492013103440816885478837312056198913066\\\n        344832559187113588700659045514498402201324886012017217446020777732515544330354225550944593\\\n        706457274853244264459797375097421029358414284465213619954375291979097554807152776366437259\\\n        598821188010706387375286303549351349769062495721421065419019359986730205133318964707638171\\\n        722645346610717864203388037833115934211011329537013984304487504602766562074491807828097150\\\n        215364061426213379730642639434690142053328283948977355611391931619228518385040280754684837\\\n        058933181049038449721407680003874967254090113478433541687424481836451234834322202675244436\\\n        888416759100643939597513849836325993543610084899948049028958997054834371177714245154007388\\\n        796026719425832980435567598423636126381482840791398567797471633613582117089160323797908955\\\n        321010432982899958492304813564867929223137334989737890937695541385154549653321610965385394\\\n        358781330883506331653321127956640643009244209101288789620980195584991501232577336404361293\\\n        324186820361541841181123706104875506734668499051687479002623604622909191790965010802221836\\\n        060317019896236136453035271672284497373240452094171823032037881117625160155618610664744867\\\n        218398658759717399132165011976645279208298029524633670225138996435944507436060473055620400\\\n        558985739913912206142454439245502853560954119443694582057205091855111318988797338119746667\\\n        584702068000917061729295794867466929801647017749789467028060090220061047245721078121258764\\\n        044698952474752647018612299793875507461055231990454503110712701669388561909246173524795041\\\n        025832930482653304844933070004766251559381942131546408359546049385664979784997753339025046\\\n        128571167588774849250338752907159073827161797861165717829283806516765524139800350663500472\\\n        696056932217613201061845098976776413284716230715676950412679654234151554339174006678410631\\\n        143482177314762706817759812247438070444310226352081127170737732702978815708223851618578960\\\n        867951087495337472155133924294595299556621943305057169209540613779304695273113384351116875\\\n        818193508305605912778347311102177044891853156505933891534522984733043365821408583205628279\\\n        259606777662275493396077117786016879421910887787832634695242631995528533759475530320910866\\\n        990932291370286271608059747151798905542643533382893193652615369279786203767102104643516183\\\n        854188251980254965023556055872514919273532769713905892896686367112393665032957354494857473\\\n        056839963077807492469863994369575550815628858551976029271143035321080867366858843628800107\\\n        593851444651405348130943640418645806997022865278865644010686889015639285999633117895481627\\\n        302026233450316863690537998950824617891104652894965304602637410876519583586529864963817190\\\n        164709391980541185067794323417425373078953681118991318542747373872244414376456701403715978\\\n        355178988306012598464663243644398067985361979506610939875762574210533212865406942930438604\\\n        216465973914679944422876151432387489080825148997609996331922328611602012516415225936074992\\\n        989885244745892561470126917717900238246088075881384869433981100321758797804214872357064731\\\n        311803015167235105570435983749306219904203535368682469274835356983236529004450204104947349\\\n        110129395637147478759305711816894520582135668575547567812179709602951894752400910679369292\\\n        089307848291072064980512428980622211833592767848858377093085305076605032861462776498803523\\\n        808358869576235294656851029057526153886347373634911563199626498006237226838133349318913461\\\n        691958699653612324083118067766513550302383615847896383853810980190136106503060593997967544\\\n        866606442475845293815915704599019525279188877619080163388503503735759120340354473736257582\\\n        885353888657571752591979271050162212959738879177129724427820933280319959262687502369734466\\\n        038407019454588520875836685735879325252395818982712426055570558870093069217845810075788559\\\n        435355847846682657576652702014772691978250005513370493198397393524048351920569139080193210\\\n        235576785093732051024074057519660685986829324888141799364143244054525387032340352369257969\\\n        416474274946402982271253832881854382875883762647690776815877982513019256907892958603594286\\\n        793318785015691782060993857611664870671144959706918764441280915224236555046533598369471221\\\n        725194267208379288816576748932682780785654101617584596332630832801920734795110698399503112\\\n        157855992328934836271015874379576524534480741896748103177137856141355255400388179020534589\\\n        684755534680617228740745249530326670223892112958227668931553907170000680071349615220106362\\\n        312355744390518299275947736234778559656989292144919707963677049593674271096626937137430231\\\n        653546459364687627896714489043866010348279766454379034841869268294822604157718495180157721\\\n        784403737535579185484450092126116565054172089839964714238509560373848835363679558243031437\\\n        592189926170807813876377610934978934501904785629881862283133868803366507805218267695609033\\\n        432000899053293962372318085661632609413063771465247958473180174242844665495253240208739005\\\n        408994850964177591745984035723551326885114847150505808960768282816026211032591525275664971\\\n        557524290223790359906777959720800593016248943466360425806103837208208342437661731529484288\\\n        680790947146955773267823307793479082244086114002736901200374586369601060006263408262213219\\\n        282081461272052124029099009776006225436284347348287653044690426707658206980911197618434086\\\n        989196621879762242937287697152085425280618600251335998865142247076454495849431255043215505\\\n        957760935160739422078905950443261531233820995622349193302578308181398432396796967134780822\\\n        073856716567371009641950539650753485245276393689286438232134036375821686593110107432825057\\\n        673075700736448009893877169912136736344409286488342576410622454844261846274866299717136827\\\n        073548429099184860559634415174917940478375108503807742373576697468654162826523746243761119\\\n        285235801976546180146506208692710556528139446610642009631550275682230100841060877920113083\\\n        834149251983139108575641538943874126860892737288407202739139803988946516770275042257823483\\\n        486997038661182362863642670609109526677611237454100706292972759849453019625246260766109908\\\n        206302445609771693333269492451720518137491248813631253739544484888506043823233988643129684\\\n        152056711091442086322813513698920306036323206235466355926913563550602518804491838451636211\\\n        633455754117251321174121249954245940384693735445853882529084948663411567300723117164357217\\\n        548435449389467480145002831298174264750747785014381874425364093402690929162640879207200445\\\n        776592614643252134986683840327960804073766331005432421152177094773458006851982966068799726\\\n        112960913269023913310388937634417388148355871665563656514651499209998457848991312959808691\\\n        694070689188610179605860655422841689717095416683808563145628178634060934252424697410042445\\\n        060450378635670902813531964125039538812907110531811064987808010734658682921232267013968272\\\n        701544006970734894954545315288671260635678832785976394848646153661519467186663678050136635\\\n        826003877720674444769947305630499066595107623769547014161382543314069490424158215530022680\\\n        604020635881634799492630324574566540959658329334973290972238933738689446328993567638192888\\\n        934925902189474069301285723563712301045194446696421857938426775161116906140369287459326570\\\n        731451727330342560933372979540167932939250871514537784642332571274031517459558922143259815\\\n        689175685990530589451934483835721893254793944678828581305140537118348336705096578996061695\\\n        858723123882713906361152433792989602747826994194014146443214448519398806911432757013476096\\\n        334389213885431166550398304321416587157319414541205209673710544791720931692785988356145487\\\n        625442114777655222063813778495518203657344728076283761113138472159709831051616301313784518\\\n        632968325582176212988166198196779646941023035312848868481552951898673469372097735773434089\\\n        894031285605696687061149999451051226513835957110612819403052474127239028755915310514993916\\\n        116610483489947597295892410084500438250396073891693226372889065509415964304316723803771737\\\n        660146339621642220588213340963015512396559907502053707452391076771170820585519826383620191\\\n        111030558013632593961507571036711481331223901260563059502323455328553218467262734345973983\\\n        667337413343867590141623098769104106285699492574418891339317110974413229858042629190133506\\\n        191012804891031157385328459935042694575927293871848349590285169972300433021859319822177973\\\n        445312211820756960273576882295314070175800078495190043995735400461506811197022259541270449\\\n        080658271068318720150685941971568425235830816255625090866307143865164947111915989960801577\\\n        124911678124807040509337805584372329086432145208074879308243365701293249837402609435383780\\\n        262850727351774836380357185927231718168473810827135357314877652383049747792035499143209570\\\n        993816543512288049863389550581251827576983490827453017377740655225270528554263878889116439\\\n        495529160774055865900562513375141367942028387267048874588821022231000667955526490671149670\\\n        022667151288944281626333746380920537261943418750782330179773564341711788109192946382550134\\\n        584697805182220240014191185191538229021753782339742955324162367677417396914442082561263735\\\n        311910918897215914980031972718126814852407596710346836951608119579758213362421497661286825\\\n        847975925442449494298918359088549452411357405218281371584655048547060139601383062607485493\\\n        063225014001881390267329868883824769877780316844076055967980250160641354045202256809270616\\\n        201730805717025468790963691616178942965344645895405879957444461615803895063329934405810769\\\n        625892170625883267322223106258628695642987934655413250982296975189497698290997235610626095\\\n        211589033170680799066689268685433992969306885638262735276616165958564152081678269854409447\\\n        918276494289122680460849677428689642066413127656794508839421252853323513951015434757392140\\\n        210765992332279727228297996332028186785538336331633176232920064998085038492360428504848498\\\n        073448495092607969215437103114039742748939296386439742263162695212159282929475268874066368\\\n        431672535138242426721351910695872194401493362945275312070720309891441688302926891312344905\\\n        475681461545073742868173099328472241268167985186595876846173017367690181320417605801075791\\\n        339936503803229442187840714622425488391513214282724876820494226852083536569337926222463034\\\n        930109941629494342747891138359194023218680635222197224028866776042503751500468538626369835\\\n        207814978222247695949619160228601735862457027326082377776250672080339441179048637444892456\\\n        214419622988690726400137526438797900199396815211670157295976657899266591716361704725696802\\\n        550325296901034510761138717012726829976521724542002861210167344159304069996002635321662744\\\n        191920910199360395920503390028154170667565264039383896027449599548356112496513095213419010\\\n        933746946966427814712677171631860976493368267422092531698554615839557758025788071154171673\\\n        980746661426793119213341121195758178138377075367399783657836311140222259650321743778055495\\\n        041980067392929166048779276390807796144853598378896422021626607949862722021025070453418659\\\n        431237658629499776917834482759177350635740797716052455264456026770183488860277107409478815\\\n        993713362475590392821206210975664823755188792042302365864053216398584303948323500861332892\\\n        113011467729824831314484043171850153622037811045751637539339464936774579581859047817462377\\\n        568860614034281508154676175079798993829110080202595100736124187282003271370987314739194028\\\n        985899348124430838835677101514005965180527889455478103821908142002423034934230249957192402\\\n        199874272416865080855175822181543116691963088051055211434164585867143918890570504620143658\\\n        076923837767104419687590694345424152241034609713426107732348351324463907242193083402118740\\\n        831649155312845140788596286844512233841433740716043574747635502795947515950070110897802680\\\n        499758207842675504680837049811882228687905600152485213518075868099203132631718200703450220\\\n        878947640082405523631870248797216545792651089836719670045229445527352980566594342028822916\\\n        759793244025961988991307777241659565123851490891365873957242831661307525242949244236883863\\\n        074930285508649943460309207344247758371421216699564229742112278861069798945908323073509244\\\n        536174708167038310462962458775589269123745745250921259036625022471943221741526683343859533\\\n        037148343801805273952495783109601915262056455157218385171017832467399534989128323375265413\\\n        236722339054595624318990856122054503232795111167176061016563701285772367863094820004532588\\\n        853013535327737866735336975396280473653252752469884498762746603152416849018243733160638163\\\n        799475230544083035995664644866333534107057150591010823722562044699638719434787634655363321\\\n        946930487938751559570999129818893536665544036533810337504131459951215796391890830360999043\\\n        251306370571394964856559918305641692071803348508876153870104183969534427394415052078937852\\\n        384290056977414826207574192342602422324745760365399347088056278619707252630429325739773545\\\n        779710380777784904920675138644873684796612631427693423427344363237314206700186198465669410\\\n        754388353725411741662703818579247276128438506660421640330410308488284968449451929831613717\\\n        143620700367976620530795798245716886585167465805008842667759813823996950323081206248732777\\\n        196617790794700049050602497113009007945378966311315853821748993142046298271400198783467438\\\n        480463713034309656644565928098431195730413993707449826231310903613439220117273672754572156\\\n        283942876535631682107523071603670023508588946291217921605050257640350314955181214044957573\\\n        630026279885437300506671419263205154061397594775249020388459079646539732156240971713013181\\\n        633856674725651158298200391721187803382167115320217641745965393813101863614491713621962221\\\n        745226270246285853866895174920269815241523338096984766339324879894144815135451791521655321\\\n        199547311592932617123914340523088024355788623577255348944987911365641577339604268491451269\\\n        884796657284927564607215252192854577610859052413161105342355484359595956128526914396564266\\\n        058414013231114923842829869578703708414207734124664220143747741486654866411711026980005587\\\n        114182994259202098441503240217871711211136185071045553090628123288530158876016543132312862\\\n        339268678679764009343529522140321198239339460110782087709913996148465089095469864140232433\\\n        336510305339332715050115747916941992208993994182843010276517160912122185561162073883055198\\\n        428427754503525905221172366968493356679647521204620154147658994103333001026857943753445956\\\n        744767595884182909203831423606051791606115419219951159573272885496747544447947434152020410\\\n        796631147972786963306430731020573748219854961084763306068375210800579405583630887370738966\\\n        440147335998517604756532094608853489335299743802751248335310478666586001854381977167595641\\\n        881531187652209330345170489157475303103221786142224100482453109547880122933426253033482590\\\n        864829468556949825793144110587627928767941219122281962621286358758160539596894708622093484\\\n        539015071843010446799572884572860952827928581930844346838624752980364782219902201241369325\\\n        506242535601862254932690692666523141941422723737080529588461884577078656885747651705661129\\\n        232293582969646666758221538914793225686142532388491298425394256478776284780291437892478304\\\n        743350247240447716833125868746409412739744961456416327837696826127546159624548233360448245\\\n        789770577484863598240042240937806195732498325123670172963396135241835416730829265162854030\\\n        776010583704530020455269062513527405951036149998919680164184244204706981398933160863140937\\\n        340588909547706481989363256622065856164051484447052730514817549167724560210091336900990825\\\n        162200840051421714251692729476637415374279848199137459869230189764091031126902826129640388\\\n        891542588232076436826846181418554177407910048442984627591801871722640768074014132486550376\\\n        485881798489747677849950648541140668793193474544335249643850637004296967328758756321411977\\\n        325959192352218454603003197607980214561638551220717168391960045995222362577528582888406681\\\n        440021249510437743575897357314940167168030779164242591339535087813071502291265896660692015\\\n        203623709747610771118467268578903780031661223279963412000288012563084398943277222297470781\\\n        382172635089686762092238016070355493881888081083840469036099200176033826970638253212720611\\\n        828803569387028958918134695661375744763681906383179588146318373091922302593216969549969626\\\n        683607403557096773365238543891245865722748082864971965759474417624851482928166448248583688\\\n        611455611525202086430295827455595567598714683342668521295069555416756988683695315685694594\\\n        244700249924965155241973953489009832153766406850250047036298257270520884602070820794708605\\\n        772415028524314485232380962443978770349064080040222124290605548440893515535893639503306993\\\n        494158285752075790899979788821442369247064074502824242214891030615083379605008480423194065\\\n        662909947216082833343122998176452635969573242852427229596663277080462587288786605325967041\\\n        242472394759696715718586639517317200284885109247140976729315465957457501866124772010764588\\\n        621786005976032827713367122600850666807369652100830477048632082765325500582952692584397598\\\n        612513281576135596750657829863699810732924466784414942701957510939931148158547484448022033\\\n        977931879515949597465251680611507071573544826160359563288230510225496105153232936782213997\\\n        007500792983546931908221666643153477807721279577385002288627595222474879141726267139283306\\\n        083182512772223175116191144603849166570431293384498409436406360209814467610098074888465872\\\n        200020862521288520722824453721779789418124071486326005575186321114411252564130679902383269\\\n        634354416592793353731481284773370131322779333627557704740948554273462048190118138002190318\\\n        941199859422369168705655092792561671922336888025771757078259100029373074930041083658408218\\\n        841635231421874962295967913816738423778457510295260332295991322570774769989300706863291073\\\n        274730077563074844375204087220441976879022624635260439548828705034433758275470459688781971\\\n        504075797834297815236588798464112448482968546277555528853755579538391465384850561353284337\\\n        828449543050635337771807520421834793415857203787096162719505451705769845021009353726000365\\\n        629722509362407502621626931756351353705421933881023076057155303466860016190296837582591568\\\n        809423495285331178676679094813398071454931634322688470093218811022020588887744027567120481\\\n        050372078888184546166909772274384827711537840573443168879585000184300505306444947383425027\\\n        346794766669254418510884117212672586161045978073533386662612135573436000308275641949813848\\\n        194039379725881246836992334979943793806163942508626095363492967234107921848103915185198232\\\n        404312495012357370536214944161909818342113186141268182678938435679936601378022166299866027\\\n        689307149467550495181173442819941121505090696692023278393818394050743940389817691228030887\\\n        356985461770719685695690648380176698301713355926237747778278061648342657074769859896241078\\\n        683191246648966911891547778036854688166667435005368785330855875257426100152573162542308285\\\n        117498717524852356092485728359500467341962522811663330163879076388451303163609359651960034\\\n        258766509117931213231294836477357572936223867334283935159221935880322360503229548848226215\\\n        622244933738640073555120160527637244245998199269632497296649322219368434994141486295967015\\\n        594389865671371900917920406217002725954071716930295714267429354440248820635207756049374495\\\n        367194025468925785827328353692371567286454725580943701164441783908854966207011574917357045\\\n        259172497350550510255744691625987190785833453108191679737072689483250121805476747531238833\\\n        807037830312948335838854790915063231880992187136120419691288047256462823023511868624342651\\\n        553438772164009783951213810953009504659155584498344723548862160086506531703294027628845380\\\n        105533746242849630687907430019051334409240737303302821171029346761520604640722321139783230\\\n        540682747303736831920688399267136280159696936357681593543121643249414200996506130244649584\\\n        376851172121790453914569420296860620332446554660252434509250164398830888127761993167251842\\\n        918251778080316475537147324789285078330114039067978146722216283325975683380805138732258915\\\n        227060702437230999132008198373752985834207364110395710013401108541662357049928179314919553\\\n        675352123666053611942748946311246495619395639544342783963990130814762525143657881094336728\\\n        005121581040725980258464169111138887922357726220447764418738068653127743930571718513265696\\\n        058525985412763215777616087223376709617625202372834010800038457098502008727978515917912076\\\n        158477374777185823304975751193924333920655776330255889889819038572355589614813580638021171\\\n        930328386547986048135651640016237241542257013429923557638750784528748890814376018563453954\\\n        214596242754816485225537643040569381112203227408707177066725868278722227100167898828982526\\\n        323265600479664501432571526686334616056101213371737748433640228713055132339081403837925418\\\n        163328110546423606577294374979203146731075728179422067059032339696137958992712836082790056\\\n        132850788119436774544163293780089895040095196184907260404714370737137186505557376398927575\\\n        873953038719422200903573508885915778768674238923369630909425749611113054378499075449218350\\\n        575262744757419667367225145620032474310245907348701425166190115493138055347229372822784742\\\n        311752563953857789757641407911377337430045135367567509103039464941361190577285234927563883\\\n        793803777115633155785038531968739973640265863843678214096988808276487594994341304111768135\\\n        515083061668463666802036689871912276053930159160474272573797854358458690610867563890075964\\\n        565034680568424757604845886611552435691202254342542413791246074640866115378231589822913557\\\n        413112598675240633597608386957214963799528807222127109281275192209247715570942241483158518\\\n        613051873826852021476885091850035038913101326759999634999613872694986005754506750405248523\\\n        239594704667208546676794863658621674150707584732881339274262986736020455060676576831486487\\\n        036059057737449370158778345118137944534224672887381266877373522517087908247320902217668389\\\n        955588854374837935086243046129689849226565621229782135914567474117611126874186239857693108\\\n        726105749057694209132069101020037233944668244217620767433209182058994136750653309226830858\\\n        845559290225915349838359236610339153778140787406131817806420554560484447216522494135103118\\\n        745415184705238357304929643707316342333337546797016248538070257281697765468470412113293823\\\n        511315205714106546868031695760564641836655301075209173786094902703151395303703364442687035\\\n        850709841097579351895827338192837348094235151854581379066861638065906883083030435411887408\\\n        252770589038270160164391294478038124983193351966315936586995059839316288909455532640728332\\\n        515293387773416533447659399770061832366923767846328666181207715074638354199769137128765757\\\n        489303647494688534650937161641563014937622216989373700025734766021737763900727886383064620\\\n        829157795304168815585743803290327736836207340803924248565553482355089905940288375961923087\\\n        575387414201139309985804670629023476295842412412553049439164952462617899444424820539215117\\\n        673307869618498065438953525324903826776406903553997114219569289775786648858394897939059753\\\n        848554974025104048565054904734957391431987877832711897322756539142740918807748235922974330\\\n        981415871386848151831768354752286473690913849983112397811008456105591629295960038611355845\\\n        512671078590587246219779907444070895882053220992788089394563885675741686680940225094261572\\\n        629931057390084625757979825107111580648693076857320809929720359245030891240941490603786411\\\n        048998551145737805070346864076740002344952511245744182409852860502510957045658535070923804\\\n        509507248985376923385576176707217096721517594114884204706832278719007993314495624383905592\\\n        758699524779882584566987475755716590812674697775754702481414063897444622102415726787442445\\\n        762492581583964578348759099647873689024112736801173764741373387632250062949681062318995702\\\n        850671947782805710519299146024799571681035464837973503625887088545957064759593211663192197\\\n        645235515355788754980997378396149542292536932624083143419955730765045492022404936539791279\\\n        112807123338097299430366422840117467136877471571488459242125401907621000954072879013677335\\\n        303455919757445094356858702360242611838142796194367257525122450332629457803259739718923916\\\n        749037513921956021816970499003338334750434149581950502076601183096432230556889924373006687\\\n        287274369328108597718616009755658957521583437653260042907459326348798607612624927160252050\\\n        849659057647221962817768272115441474288832541410341284522290350354764984604345407713936889\\\n        450633549551745462426002476812668304320560559959705969254279600395205716241021134690683702\\\n        693065413906726594739671987617025004919349812561011976800275556378397599798510722151986674\\\n        042595226741479334215879697796482822695862602392560251340403866288193510407162857620520553\\\n        679812423844990144681780416513486831962054127759733871556582550337890537205133566442073152\\\n        645361331337977801664597007882460817338579741274194055493476955841144058646594308377678127\\\n        853591609108868412790225034743659380538371025333424567539419414296016626749713658509229374\\\n        166248794782635945772949798929872740196043072491571748201939647715789068024187766922439215\\\n        884193345129277680479573237008250307649255143668482464216064745535025204066913988913639163\\\n        368905332704235376967972083156602897045243381090682302701735880171799467339758653359030877\\\n        071218627028812912196799159979972944059080642677261021119582546265000333678623622013193009\\\n        428369647613020082470279957221913936707941610340233740726836399028283573589351611366505047\\\n        978342414054611825884943519155916814427953322956953608063409751330345525519537162857669026\\\n        114890242970928354943408491600898680748749134846704884385215354633440023451158947766122557\\\n        455756795229992560023889862630807113289015651127944299483964525261234221593545529708936161\\\n        349306686895140727229260672171338224339518386612778711254349073867847716215383856621358336\\\n        612772783708444107036556899745056042741383064310447375506565580611012047663201236023875766\\\n        960732030726653402404191685925396774951523060606833973755609546293372508308470935811305292\\\n        782917846463961308417902523067462260580877544598103628979482817722457520465297807936656823\\\n        687584457229743313817231072091934054822811119808255860698356888862558375045238723492949643\\\n        786943431491538336317392645317075175689507141721496924763397237506104892708539493696561302\\\n        563244888608394786338807732277405694371670383535225420937289429633107244264413029049488603\\\n        232861753750714812843565911923925233318574663795076497945955907174121651597658585331785885\\\n        449802335043982170782114946412816960648708596083299569029266676300965012959564284322581268\\\n        273897678946663616622275349626043126106999557448178655266915604108638370695178689004783785\\\n        400310305607974327824557157515101432741993812654890291641758312601039495242355249910831570\\\n        277905963283261032767603243520418850072389502994554484535258549947295380725173977617857051\\\n        721628840475251540386961255101254706523434957765809557100440671555003319923671878791639768\\\n        668709560957467133706660327005171738855737810993335977042116790011236198517650927225670240\\\n        558634057717998740757438259357565994915668257612258687394214278422417448044104038550322681\\\n        950132979695845779673167764559839305963722763954588595827449780057060206807437158177796550\\\n        639928851089120391236550453137835787969049970279758183652600079201650219258390079205379301\\\n        027145044745227065820671719305024834050755247292326993978424814422652020716391651030834234\\\n        406885133844110487760020504445006692408056477802278960716552858988828479368933522030162003\\\n        642836267306545228769941284745263413544100794263775260558762666737172059157636664931667275\\\n        928160002903321701535914206030705828098305383619922402209175109547945961089658111083710529\\\n        817341517462145165618785880964476434551572312010170614351264100944391005397346045674534805\\\n        945189269362289080589974827622864095418161408495741367592486452550286505114650195145305135\\\n        096438367628921425172001066005335090071954348505990002723796644550786077670146427543007281\\\n        714334411531951070805027734946839858114322147331924105873473689075644929140597163572405967\\\n        690014932624169519309388797534835389636346245562266893071447793637546733743131923506861658\\\n        582140078183111549189634271080117585691605372909120213397497523348102156930264916007746587\\\n        616486361192955787702731147250149743440337548418142955816883501275861337972242767186558174\\\n        631187296435763665739365048475446247220745327187168820837510416688245944372105997275459913\\\n        010703232178142743545893132044539057889561730097265053734300577300663398745646344120753852\\\n        679485890644741534240786072337745833375257885409076667472503098863043291091687728376885215\\\n        648613558919374992959081283437027822000450049045021486760945656678574828122674706265458560\\\n        437742534835547443143124019501826826411820822897709881524366563716736727713572331863847619\\\n        509185717873773217789669831462357180084527102821503483727925929688815128927302582960427720\\\n        829370350076165606097743131247603785876180733362971469386283170560750805774169782773115777\\\n        032834379552092486062038667619691459956701497746646688883775205851397639634310979433736932\\\n        215823512685658301769462712086360113528580665019033348809985467776067598490283077121018394\\\n        439210255210999068498567323003043707853993594878028801850851083060807314389576197231052949\\\n        810107001640483275199783612174242770644062902061090630424288375760959066019492125354913721\\\n        291531303541863878307815340827318849859354824634744671488288165242143969153822668940916469\\\n        287885282197976814466477055263822612352744220572591151314172977793469944350706042725372596\\\n        486983054524748615311842932595681510696382376215074891881134140020260210982066324103938181\\\n        869465754022710562635755378161067658224261788252612963505597023473175198069419750654198047\\\n        783153671203650973558442415420800069609626661974235649790838758208828705313731376828130864\\\n        980697736978804692277328108311884913041208819268042274160816123919031549173428003025987346\\\n        352665235754954607026980215133144180349022126899041001637807600021618621029385225333931299\\\n        968080274149753975121628595399866205781757213839168684933235499071840115558070312151758699\\\n        979854189006998191212856384695381664866105347753986261866579154055768464851901942258968233\\\n        956609170525159440640097774461542675690118505538180646563330330647047762549300849361255300\\\n        693663896100271486336272502587559540571630364750593676682636328117731081026809966362416310\\\n        800681248734313552865268786083230282479926440894511250367245029223591084129219276187638397\\\n        982197897223086634516198314846312205576808365442316915103253952726422973122278880661027605\\\n        644711908569772862670056818370586824676373324561184165155148816585471865243381914690894087\\\n        033015351221686947365996737687577357665527776884590974544534900904786072889023630837190934\\\n        800452153735686043162998298142853895761259036488152866893049263011294669259698081502589889\\\n        549983123087011699370782138238511176776756850404339828536680927018842316086403759519437432\\\n        708532101895438358536902636652244749678598873960626484687550715098314234935964301266523258\\\n        366185289655747866196498033856047792614284566394969169211394407037105330436712340273833024\\\n        797343204692580422110306470109504647324791688865962674158301251808264836599096339091676504\\\n        875008763744935698882549796877154577856300685742812333324899096774205510395592484115150256\\\n        204490300513758936405489214784505743485207696657584169792984432657469009833411319893715338\\\n        935902706542186105803133375161088010868504280589367984571919628848540299805137496981271005\\\n        084178453670157790533666627627903545745050281713322718874448925968596269108117391192719025\\\n        525540150440635351588817527444405377190753595038202502349418664515007900910531208155341998\\\n        042121875956046996974126408217442370561496612621699937322355311514596469181360667782762616\\\n        107773746806428394720110567481345909042296054095157701066079529990682551562543536421591108\\\n        600947180825141553470371192460503436361936133183212270639765008466223421490397812472464567\\\n        853684559222138298061651971448396908408517648174243285148005804613298047314679100132698278\\\n        043964260654736046833072381815562662030924078841307785971486168997169179534460440131649506\\\n        975564806175106835984227947017839983548535736384610232038178044827953228492553533970412814\\\n        363450383967218425341805746325723089876541632587516095976912698267731522575516343406824129\\\n        367427583531052454621183406968560118906190317025526611902778794762282977329923906622829056\\\n        795886909414556756427305992674829970605537260320911031492281197176566556614917380887542456\\\n        697521049205963834265628402447250221548908105599431109187317655499089771999682240916966063\\\n        349913261473200904074000061420379514804633443199510543068327644170709892392892952789135667\\\n        722869907024790499708119528169316603996615250294572281513906289613607501790518531489044677\\\n        451987162113501479804059280973407477482936793836315543880412187176861554309155814435206887\\\n        203079723800161281286930815457721592649400264900394028165145864294240577715045149021957563\\\n        249897467826039643841608891807845502473945399618400145109686453084591497580557736553103337\\\n        584100376503186963138271468493761006531482335893426639327982408509868442577823993984735599\\\n        468157072918698203090879893451059593994806490722903145113511887984571878602452679779138169\\\n        775167935716453991470490182025859313873874160048975637460092091636592275114273838208255353\\\n        349355597244136143948922038033712587690862944231562545077422392125075566038258555211812151\\\n        090554924560901859155830550314942237999201906638008220551716247410005772945360311240922425\\\n        104845420517351345602882166728415002092182748883683772867327917480308265539790657949579553\\\n        078841888935312555628082799426973996332441310344135590372674991508142506059786757464718273\\\n        265909899790607968809331951511512876893361628990410967034459829704814458198011082048942837\\\n        406029405725936109869321440749606160939927195780580017586124567701473147758069771417486288\\\n        901188703137498739052955999835003777825347539263859635949832767467401193879406818269780502\\\n        264053642480776371038913654028000063170176460854626439799183002971968334725873858494254439\\\n        356113496834315966434506497486453324874119657697513341478450004663176352491121330832549655\\\n        450937826987475115327729338280474405726300857745542736747445009535828626094599622382009408\\\n        069131553312277795816789683162603715028703718918736573178027013816333580611220814088357725\\\n        998701444618923351810208690756176163634115623404257373591799692706732074232308358797583497\\\n        905944899729992153278494047405727689003482086458916410946750286876880005023576602589247211\\\n        416381716192579688220691332269033091635657931254981369207694529962709948203550322657834785\\\n        739484966763615466969487143386830418307206081767232631724450026750369032978993975882427376\\\n        407471598913095519990130168641681175895608903313682189561187591149641981650495555484673175\\\n        656440569369630462292245502654311732351440711551111829544021803740683807435164704469879644\\\n        953450957513183703053355802792400502933034855702232637673569309770340652491476726018099705\\\n        933301480836066473389846073801546160196508327332764489655202522651464615619899073480906116\\\n        143518385515147335222956814564091523956414990998852751796019115986071579993457433999124537\\\n        469677516574712213537286819043763005642320306411985169467963219605292935035145456538825127\\\n        982664728780296440687913036266089600487419887498761019150016256357421754671388895059558583\\\n        190824458764318768197022514761066210691231967575747245626374214599942170971178927199212705\\\n        732372062445453888982016716437542816864032459671268612460663469726841393984115766920293214\\\n        995445037673393468112160173538723804612967890628182541616799635052668089621319372464946704\\\n        969699499126915743750904003441392322007532939784247483016268201004596759356946145178724923\\\n        644288434519193626120227261575245027766299715492423180230618125566903455764280192769422797\\\n        215869412012980822930019652695968321320963476432070052285676335323221910638237904476500902\\\n        128263898560118483218705055691430537566255572592340970145184164348620173250702296291227498\\\n        369824257177220827633509656883598347384732745143548521524105928175666615548175375381667832\\\n        354436318231202338006268950956115449663093487569348853444573078383968978691229890907243007\\\n        310359224931866459074718126204370677594323249911616854631851948929523491009058039835544205\\\n        295735553111036181761257228792678228403117859599421646118738225588375081749900226221422409\\\n        590511604533009230375215339041712723449443934909529602408637268087468658375769476637087035\\\n        387558289414335634941536080782746531233674581979047237146616134203795141880568715149633703\\\n        905639213352897843655244984251940072046778287972954202646416662189063031497470980688134735\\\n        731753214533413136981870116832658950678200914073131476666915216780297810452227354873066987\\\n        518888121080223387480876769060815389590208676423255892292306874441199613327879745456517893\\\n        404634513039214401495131440000652802281599127810272247550400047138859512733995769768147896\\\n        533986667928731119720266636676154850204711059946584205653721341541623199664157830520195484\\\n        864883846146834349958464806047219153201843282510726560421268714491562540035488894109832955\\\n        103810754225754867764146257793244292040489827028645899205541387967062079625120270550616307\\\n        538302353707199787251933443754394143239953882356373687949563751923937994628562153054191056\\\n        408325584537340778893892517210433511920217543597550208619447846917409797825153627275119641\\\n        354351834642862989949266510816297850919652814302322281477429218915280224659242398625265053\\\n        138421072197746987384733585983496782702041088013077723319494648483055369692103432384316309\\\n        104928507639711171071596841215881727952685638595710569864127561180329781289556393385689284\\\n        983954115542268683036537673905120580508287581766911608778504923195938991614506547391983385\\\n        594818969427677078509844907827699283428333584521886786503110390665656057014122305251660919\\\n        228191373610352574188654366703414114198617450621137815400904794578782767485148191230375155\\\n        771980220227510044016222198991636223534675886839487046163690572776927660617167987950088108\\\n        168103354849767233256897345331350298597386388980985379105808503662615377619459957808186539\\\n        318458549127297880222449107613309564638486505116112731188627263951348373250309457552007168\\\n        450531131180252547628231767166755461224244589807418776045212576857635775076194490189775089\\\n        567041344518690363226451985641657492698403832426821164135370761072835677047042593500070371\\\n        856228883320121900210723314792473814019098482875948150704022387326969706917461593502980627\\\n        483732711206827086295133499380295380634562294042034768842257326008759124161098518371090280\\\n        925360145867359997494499622389268228986663046898994402299421019759313303744868535942188906\\\n        935630593365728900918272642618789716737193426236579567796965847075617059243306050767951390\\\n        577083620197148742385786758628857741028558776376578099785030656275095145975435711472787837\\\n        251158514856643288201901848217522577112339726951637694050777279929692020325502084983764918\\\n        307045117209379689330959715623172877300439555567190290841697311584024364348339253346855599\\\n        796670548777484642395942546774799942462359669994193367105530061142447168136754435344259286\\\n        651567642229946877472393232549413921821470030832434235604729311178160509636369048337089013\\\n        291315464927744692892866806700654893982773531759949598248888181117195223491650873275749090\\\n        336634832838657606131067102782380369216768419296963177932166749525656681372631616055239982\\\n        430108750071907829338166609971757557862246730919236854170158773717705974921442824186940744\\\n        579657166381939951802406648804200489232876086408917851491837869906165902225290699666755584\\\n        913880348128421355681321820505515895910666900649168841537225454544094249472098564910664133\\\n        523169200280504870775175840965396128689845501899436993862721532186618715708063329530352772\\\n        924074494376409735225837892626163904149079718422547617749012531936982601481578459999011184\\\n        787680684934639811320367580924172463034329549632203794849334765072246415316493794375793212\\\n        654244519295777643205782434674157491237057368480196149337245135044952782637176900980619703\\\n        142091064625129495489810016163322410818518466156897402938579470639212166360960854844993590\\\n        461667989097629145325001332727419724292186497346787953772164468869302566535319783381860543\\\n        382696009351539668511335249400366843840257932922871286651820107444434429999296283844437254\\\n        272796008730305327725023793443682124195099173187926292595673699684944800255654175338821474\\\n        584815656543170995639947144244047358779945521077421113045407034864056975997065893699858417\\\n        046964770491024141878773809945807222741644782741897532838505032620903079591600534664417963\\\n        143945577010490674425833202119886795811176497607378093822426316664790567816626047207554060\\\n        762372940224790689253499749289618673258666730080918007629064500393512200048097109220722397\\\n        904669364008876861031074236629280849833816881734375707978515552479563970680897866362414066\\\n        793745105303992393964219912643496481749744437917023045427550290981753057830730439644275108\\\n        385627862616940512122572168109062282456311161926623337627773051860467270797246045240643989\\\n        326090253003587156139241120019703325467663495757541206689009256747914795219052229310375818\\\n        315474347019629018503512511542782776167257279602283585529897385765011088200998306003279625\\\n        376028925342579080410086764860605742442624777234083282101798211614113953723350461495125106\\\n        370181179498556409587180036283907808693604473810572473197802566186687130630654231754324833\\\n        307613717373556673034356657402264829897798113050530809586346609003722262175139965545328906\\\n        016249482491588682274372704316084122032226889423687517904391857644489430639190217438249964\\\n        668855273538438413108611914346038643616872042011396663348870909602225698181445216120085236\\\n        481909314824543617034610254138025469458818423692207678006379356088963681794457791303521853\\\n        846606685990771082274008534983739433685442414652510012850371344622786936690326787199481335\\\n        419830014195605417965345941066708597881708852327283567695259309199922823663699556347813038\\\n        119893900758510644173989428628841566186025424974110086443895373817048168860652178645373250\\\n        006515355338745052163281196905311481468413334630558010812266878276273486597010096349383483\\\n        993628359152522190296814701349806769866071378002703099851118642269696517398506257470621935\\\n        869637959163178318616960348030544252480700075332658054141340797370797866330521380633500231\\\n        232411012619586562347669432690618465885205539617553953571418196690889432461836094938309852\\\n        781861942166126289123201440888779752234693238659096699554032724835534520143859988394847657\\\n        326208729496496342190769854288527202761367139993683026132242775745450216592250147977811523\\\n        343220304591021018976335211811620321207572276690955176558672495482977111338664414259542756\\\n        802026031582923711800994087137078778382171240151112684463021679985139029012856371016467750\\\n        772224282819182984872108386365475958097750994462055652920828070180457729079602901274595941\\\n        864499845872577621768985037377475963193061200606405846794635734510353255285781074471942699\\\n        209268573292240455912980446255054564004842261027248823624155755349424634788254040285356676\\\n        046827288009596167205000017137943937701873005626937174908366627895142985156432967029368831\\\n        342707209589646948780144113417159107979947763115792792721331421221270938598967929834770107\\\n        129398599631437675416296860667412170501067511300611690593960148182393985499232933423864649\\\n        982921668950444890347099838846744339971427449970130808727792647363552393818754425023077071\\\n        044764197342904146878743520729044389926092952387249100550158330389957137487104445966066521\\\n        065784873421978944702452408387771818602111154569649044272940430408515504106006793129110596\\\n        159029151731362605145368167406370362179452273653571436489877942169391167610424615724926177\\\n        936978732746322848337688200932672144716304886218507292044572075561262143490190364460332371\\\n        375679090265003974478774499248408700589941386958089139386631258968308198536562710465168553\\\n        021457157138995330415750999167499078740176084527524062522932250997056270391618029019454700\\\n        614996383415616460296703600999880550211841202715316179379230891339240985449610617872453958\\\n        970266971626312596464171630427691691746411077409225971541544120851015544904834545760810520\\\n        323888408592143048917510794495378596785096154882234565740617639205549784318929489921530992\\\n        883930931946993374429629800752211273482611346829575732453271172216578070253453096299549741\\\n        148534683483409309083391142245359559011850979739080223930796586030452544695321984934259103\\\n        478927989358332718299964955347615070979139589762530787003209310920598649141794218311022777\\\n        473774377048885947922080317963271979513854562795093099581998051213629135974111371361790130\\\n        937366725613431601865212229702276497882677907824154219849225950404366283819694885152292484\\\n        564684337847446693316965445691501777914614311570622279374045332604417221380117494981951984\\\n        950061029307535402565803014177877976734470282019003579942597517822856357371281538136864153\\\n        709645313220486327361670134295899919990487837799806793719974050662569553370071114115545173\\\n        897957797050528900264335781727915686264777216275758753495097937406108267908098867284146061\\\n        311910344608976011227942137342936735321068428524212531273451033237498352381565017711802288\\\n        043018298717573771235034762699910114388244957008456083789603083047947008641948742474028580\\\n        681916098255883884315350106717978291596707490450252507169468392890367873578694536689110658\\\n        914327959399693531076282369110507576652178181478513354443256365962913113139607508217033030\\\n        768308277771540933732266786466952618932677094565084289407436261930145718116857542401559321\\\n        555144026355350474235106440840084139058056737359993178080360563268427059256162755177995029\\\n        210053272340260760972924858923946496106558887694198529737713573880989223990457488205209152\\\n        604052237127317254399678676537796049774343023500758783973753918269206997638894728958187457\\\n        448945261926219859557089370330073103009632125276127893989481385372738374530866335542018528\\\n        370573629122540353328459493798665407727827201593055799077095653662927864037533179987313944\\\n        759228333136415422663573312820703190038477204713551895241171382088572847683055795678290302\\\n        333293024621107106461544599877346270252261778567842259674755590641641815395478074451523883\\\n        148933628767890730039431176162011548675317468058187056836369961656576734805191255492959726\\\n        181887884264308592457080936680012154996434227773854806732327952356632085173773115218879108\\\n        917798736566167121425663420931713518638124073397977652224448864985336788086940984735712320\\\n        172749929846016853504179783878486329217321974085945953477578336605537254763874580994559599\\\n        922271822668598551970972062351033564076825298977194565401989113472908229196241237750292154\\\n        792403702864047505257984583210631326684033145095213382321326958640316805961106003279617318\\\n        397101937106450145785000684668770160880396141887021715720365222253450405452626596725004937\\\n        852380497572678339460413908625580940188461933336996762649439076859554750554359367821317498\\\n        321141289846119763809773630203474497945283713923590617224392390801084518281018359141543924\\\n        241929094096142552021902522927941479243759896416069976668809176939789502721662708115109872\\\n        937479999138187828369037849881151312499597898048468990323767651662548432699683839196035054\\\n        160404584785172080446109019856678974261810841372766326887570596160843148108928295242942495\\\n        164802861437185772093649965536134513598652147934983016636223544925797774573086576487066757\\\n        638417175559587318311910660943774270756816430741275031269969101998777664261893131152066653\\\n        431504347726518731782466848887834685960773805157538841849248459369987354911607158065594896\\\n        511598491870451321434295050046619082625634189964795452468669117219194879778673064170582396\\\n        272808866089479246757626587390845363323854238718157149268303502820161297109510695142099738\\\n        871521991221252985457650763619348791160505121507764197374570533505356574042732817146918209\\\n        261211752928820823880019528251480589873563077602339650057060120759771565194147529858111196\\\n        351428100055996969031233595816708949250061089741400353223230526500782112545965379833927531\\\n        346533552259868931304990589930087735762010913861662979192040218930023022573160878109618138\\\n        550912345575179642845101658498461804615316685603324007475095633950470738695958901097090924\\\n        027192404711700217191599521989484330620417628264093800263420247411498275569459019798349375\\\n        792933211547993287804870529755185803968841032136178828536972034572786833525480167484124627\\\n        473655211124173221803550703648360604081416675799360034254061326608308948135636389329446973\\\n        674736232697199498482508539246866873775434186826626425506399522413427219515051488786008734\\\n        571267510296990317489786661409810481134362773626176250881288631898800708472220839279070044\\\n        827720006588578381638673452039438476529045247270666832729385851810841619306529396204867297\\\n        430950474746376198697758477303607893916957862862553259597091302715051901686319291071586507\\\n        998277153314287046961047115525048615071748408507067448031797093784773914051817282200248625\\\n        333846037348594303954968562232671078425909563031902548306798558561992671313992810763030678\\\n        458893995148770501663916419608065247037664821318184687362951168387422335742950577954557127\\\n        606714109573413192715795057371235932452122235761939102726510939334109593139904966940211278\\\n        710977779232114273519801267532421100644798166956389381226766727199427152450133063964298003\\\n        439817117817442666149371236382489713109434946656838748507300685836637318959636609497082286\\\n        045509064325663262735517244604603295985276136257198296193338934379413239294392685167913093\\\n        916885763062621879585003012477274091334307346896855350466635081914647992311091245897901746\\\n        218943642884741889670348535125981263748447372723113730286064642995157235817520326515703528\\\n        639132541748209022093319372151341497734589915043639053970583517870169117832621596410708901\\\n        091549264572496006738413548729661769227414545277371511580912263009894257492154356703442224\\\n        536010345563617074363684182398438473948841266195448584320054548942835260010641850687490438\\\n        614199589956460481337303408040354902854493138781114536357964427033935632488786705604892776\\\n        330549948020810384576576349731649917106101219822779780762760995310885448735337968518767618\\\n        101965139163862651774909549138464616767857630923920111937791344497721475948445241386079965\\\n        566350120819661251015998120900871163242963128478568588224922539838526958867978898240183512\\\n        072371661931991791794132661699971285249651767457111994284296566773751434166199500313215786\\\n        453918943139919968745092338783601890003751115022964111031999734166920481973135651674501116\\\n        358595644649112479922405240628404592812752073798012585551597702579885052999219991161579395\\\n        882099382196099456855883741535036887012044461140960316549811288802213779971599490227476416\\\n        701488872156708433329144652397105908768265158096526600258314693549525050704342812936639569\\\n        391330034319991338462878920309861480304385916337497726213516806173288763539380390420136913\\\n        496137979765421553001328549373064722077026795171489778424304978924856197146629461420577092\\\n        220656537206982287349155858276912970849914882881528914787725569675927179807956969780527591\\\n        704362304279932919850651745126506986724438779667331563382190294240628160862870395317464584\\\n        883414453330291456618328566449829639863041677031809661956985299742674209075896798856954352\\\n        378861454791412247477179735968275862822215604002157076010570379953096739600756948763959592\\\n        534407865218264245415510968483150607700029121679450971750232399811007822397560941506652929\\\n        421385371554842662268597444775762188569570216266206278369021145700656514940323051814686464\\\n        004969972660465387408811405349940644591409593776212350271958436443575632551252190047889964\\\n        064460467926674690424889596537492774121346710002175190442309851375425835828788759877128157\\\n        787538574925695461348889034258830230202349280930198845541571689750366341724841268222880852\\\n        588535800654343855776476447487947176457940644524015339402800341545755450374460463902108686\\\n        803158329337525694577833670446726012462701162460837636161854634842329904024195906541338350\\\n        882272608424680455449784245731536249274287293319011911894072519992666537762778607006300367\\\n        384469250135566838199836433336141249140850033452252102997503651854357055327221308149212661\\\n        339034189435076839190551772226095274788667778845421817622067613455740612676095883704645017\\\n        866747031140305371131225469251761648501754912432516580369190203848375477498202681864778467\\\n        154943279154913873009074490332058035407523452588340537162499089141102791714079215752814367\\\n        074302089018555272834039028414834274403443501349830415189810030869470494178386478089649936\\\n        712407082919173997439493501609473595926010281534388671589437323695473258698738760859833884\\\n        645386676193487148931350550991240576767802124627564087408271552456289306118626989871844751\\\n        895142521870319286524710930565768434553331903181615086452017087377762673476445780695864158\\\n        129121454202951696142530104360655685153822950157948069863555965929816726452950609756713796\\\n        979204333212860042505575547954675274139820929328996840702425337229822039465230992608874235\\\n        339708475523225003206637776861525598014391565792522507409207547520869447793462177911647154\\\n        798379634546591782651407245642490993012060936469156245065646035379800435522159498277248014\\\n        940412220885012750695637735840615856815339544376162960613099326246057788585584089114826807\\\n        670400724778285438301991274521542114623895223809417811023785308423675404526039067845639342\\\n        200532948692596429250533256517880146365297547500755593108420443223954265266363489311045018\\\n        439459247789504621376553374779278518583122525421721827240351379663694106232114164876279411\\\n        685475516434271403881602132525375342757773976344739195278876292120912939609130037882930322\\\n        183065120234821163665743286171951291051061543063780663704327153071008267159374665179316486\\\n        941133007212183171707393793490520526872088971472984174908301170862534241327040574560964110\\\n        974366138198501816760784055546878138538136155724875522221007276192018695415685785679865515\\\n        288643290393636524034866317270760208364285252796022797598317889320597474789426927251371399\\\n        624938532810602167499671611132763997133270582206970993001388515561132692258252463989450157\\\n        488513317737169705404180766427243136685520491164623029536564736608829584512426781225028477\\\n        251980696829315884540692794814324282168423744261550579127436998111687558655256104209468728\\\n        751905619546372011787731692375892945031848403473191076967749702448328640772097422449753544\\\n        197553589628672813159095308162623011739954498762637506692835081461585904158408677438054524\\\n        593652325922157481238845164663725595086338256857244835011006332204310887992112230873392602\\\n        604731775223886006147403297516174091004681685212146436766286018890358903717584402585443882\\\n        474783257953581429145721358435991296677069456072401588816978578499724035856065905074066083\\\n        976539745480217518017531487357795920403003243609850123967852077040775556414870441612352690\\\n        401351409004285523113023671481444402816652687113492858448673884923004309521546906281761285\\\n        828854900146061087262966693250177148986045798426648413512408202255144293967346460591794275\\\n        183982281443937292606760697211498247354113485030269392900797114560168900549632923198301277\\\n        833723151580924817150730091074280418196704149708681692648666094992756642325783631486895432\\\n        294591598940016690130692143237042737296986261966697482455944321879256687743349732613202496\\\n        466406297970730201599441562296761017173528466330159181653671522331159736805001610338560285\\\n        248982661599929009540401375075418531666032000985084296834876332492015945070370505871887360\\\n        826189043343378897827652970928553452755180056425814609876413484566548370606196620957825320\\\n        486734982032080228463788142401780411184663987418464306985702509643600128802443131628887792\\\n        196445873798248028821837874146672946048618374314477161814250735332979767090428088471963376\\\n        020102805241021102232366403134306610218945194539093207783682572434158817504483753322075069\\\n        847911650157716628704350517573463570431167099772268798604542163452134948367967486033067349\\\n        063723458036258444293722234953184981301775867342831392715642220689345521383565570366620737\\\n        919221893650070111418525905198740915902698579007121894777638164177852081365849316512059699\\\n        790141198246514502156599834700003448747007570634487030821979893886561851533247879763487964\\\n        141776086223783176924957448074722521480252455886744851854138506157191109231292044732561402\\\n        448552785343676577668734371188191580384166660572557090917350482940816397881070567613950757\\\n        986271285782206930271964685072867955976136347667736756435131285745463984778871833902075954\\\n        766724903098489976231997169793363499057755757538517557778553667570641633533615171456381011\\\n        713025610884450726512862761114413724214212773217835687622943494207430640430914937737581869\\\n        041155964818122403123902694163927209895405331025109959758921301628871377967033324341792168\\\n        306753260798029642786725891012312592557428727060724426306785754313366873191337522396264888\\\n        315297212965339200625969110915687660415825086712296490266088237071356085541345756809694470\\\n        608898031815176206063440380706502594892671613982150361537117221610454105221385481606085385\\\n        099603250843725179590950408953757297934020086257434607266786098751679532799167653310535385\\\n        505121869689795911581763135981674940010713327702080072238883873153151910204436427314797300\\\n        028302471581197687530602780862840594353824603841364505477837178778878096549076930783594084\\\n        708326194514237962488867323469495768088047112233337328368588520417704171837803201018096846\\\n        193564783663284432520892251773285598023248366141142568704660394850391804810048087939527578\\\n        707697796980259825040325619260617560980254906596059591538374140856706676337318525165044758\\\n        517200323643578908083563670502425077112460864764712300732385160170175942625134806565842452\\\n        782944561508004263112700079875586982113417562364020284241742564270070437674466155138310747\\\n        288396643987955431486284031487612248968191674319509884310897839081873580060936748463470513\\\n        990479024172320323058621085686315376100240538233666045752113855172292363253654160203255226\\\n        607826638689606290027488237780815122058994796770298007581749058525313920012892091761937175\\\n        387405457501757071176334883253196051891333958440431521229165914847946059513945549497047575\\\n        835027505311683980186819015949628607609992448819771498633704415643627080459758323389271131\\\n        666282433620001508791545080516491578281013066707409910261087736115714313771934224519139397\\\n        326531675349805740633221407842447409692807027042186273946250181706220610027512238424852421\\\n        718979605964788320197492068302441498420790015068340308231881142702345308128938551678752681\\\n        115003766761445711726762617665709118621618770932813125064265260331019706526206909536547738\\\n        519508617444189960188494105155264079475655710080423102023512434611145744181627196961220694\\\n        749910209086344451222004993172965908433301511981572659326456798119420184450074711424745385\\\n        026121439298395878110492835278478428352974188824342813601260439728338625939752166211022858\\\n        788041220307532816131193288319094801708607069505824868290531824502867642434207863894164227\\\n        129730752542809961608053349016465968956714070809772904612342712880377104782693875766425937\\\n        649383327286324391641098544148776870276867952308006839979897466648669238592846708152013949\\\n        675766825553293144828966484847482395123384678803091368930168458288536916085589318975409157\\\n        710417442558178956383476775936717769660791475794656472463981733229196674333817812078634302\\\n        296357780420073497703409087519853497285490708992713422681792026695710779882571554424080515\\\n        691076051617973324038308868726114302992859730263030819236653619232191474372234231170593275\\\n        370977070545976863299239780268915306642621407693303992921087247763726028447395791773259386\\\n        080482011683924817166950803975653089377797856501360331884811559293049629870671465320386425\\\n        166479697308640672061924295768138272172000594287315591539290803649805260807960116622088034\\\n        851008703196313375743731316720963916217408638021823801266949681536057162968510021026026974\\\n        284407032653187364448194874120603420948173961606210993584306899551705886574940460812978329\\\n        628174287720066101439942343276848431953698030343351086699544162142922673000068619091351680\\\n        284957222230049419793870880025145291290723198015945132796487612233968407464404722729817805\\\n        541915789223930912902477812581463098100174546012591436278877966939788380950765334113347274\\\n        606976562141470961353284238318849061673979161819992989721320183600836333309188019280714283\\\n        796938242871251704365191336252208614693151987591841307012518328732780044685751466205100885\\\n        229354993748276036540857167862363073491415719819386888525529256390757000203091307559553879\\\n        886229843187397550617268325308562516667858876289415157332504989847776841875702542869447491\\\n        452972264917293949861980963124701491024753123818024157077356803154625347763486608086943123\\\n        770481706535266191172996171244796988540334116958423636011404157511437856309887141169604146\\\n        916708622635077647297514026186444743745004186823617100451708176723724376244381103460280242\\\n        535887886531978347008274150191176018620945216083422982536028332573253553489211050330827789\\\n        090783857008803888518558615415665146079128599994117519233000835994849498327055691542631199\\\n        545859802474369743526936024402971561749572643124010387944415937231529238857774674851768075\\\n        573568633834050058306057883239561536555338870814131932370447207157613044371490955704189005\\\n        657823141563993737841252529307411718092679395721621360349915249716376650041179735986724216\\\n        694061487216102743825803564309620609277110879876905558099932536520600695902908479855433034\\\n        118489317122468323512481393742483462105884264407753318828521822220311092733383576637398626\\\n        461740979740480928975458027593008161395261613308709766816407821061189373065992361643107867\\\n        664874736727190459342752046969394983559019178560889474978387905068091924369021714119518176\\\n        808655834120806154408093544255283123581986372255414085098262769664890004014167691169137628\\\n        884828677026810545233805489749297751177437281801897137580592392655730764962244698984069472\\\n        242999983686165318569714903304933704356552177001691310595741248700100478511239555369680126\\\n        990091000985234359273344426935185357852638106160116445286563521616126730107307987639305924\\\n        002012169982964610957810470107745773593942652619881893348108397650611762331135632929747959\\\n        270486409030146943995800373419428738447896106850875368671512929907029239201592367084267899\\\n        649468077029926269204198590646494729700274014354782698079603068478864517567702526943263414\\\n        486774243151106652721269777002764576319264752989231013268727841649868099220891804554986844\\\n        637904176694471696329531126183680166244379671940238365255981970912115678122205772385402402\\\n        707814662382184140923869951668879730492849886399670358419787805531291843460055625935245733\\\n        931877371802567332873431064899263814501000839232575574439647335220947953612994392671811879\\\n        678702198329439176374512134545066278228333004847265335433578281889440670246613548775419496\\\n        592106644909367791996965221508032811909331971180437270907343750140352848269431405619669858\\\n        024686945585435334986505382883874504451237661360280779049742073665152291498129485815713597\\\n        791594919897495430011045575421709730956124189155222693250200454323763544700388211809271754\\\n        337131146959469865839634157231275245418287380485995031806356461518127050872567095517036428\\\n        715100871813151311895258423281661546453773605518024827105149702252283311411517484177744466\\\n        328656605170284749025233764000200950433012087466818570841741423416442307754176681712234008\\\n        954992161307295030968063958922705041388660781484386398831946016597426603213345318356130458\\\n        805367917703332589754911662862731481460461972498361098093635094129769670133510017932277650\\\n        959802990394767937447755851409183224967834397387334001867453632249231237289370657094302028\\\n        860972433464576515629925712175345940788986758008621344810334058480105569209361294563415765\\\n        927665160126942134378694803946772338663489235180442299404472152964372135543752091879474633\\\n        133588246637717247348379095099673847841857812866861761381159944379122975863719234274307122\\\n        121735981830274796422901046343934829831442516870186536522979518301615869013325931768001988\\\n        095920932351662007280967963638902816630331385117661736979435631200843555419264578453023706\\\n        136704279794756269747126462867256801653224439950362380491368249266787621593065061802062092\\\n        190684193487494846201905182354357364701961007152531828077364521633693710855910878699340382\\\n        673385747254407376577364907784950086172005620975916935114193574854855244099518269898433383\\\n        375349595427022767781703263672553932939707957666489292260261466266557837948690949188868422\\\n        067186042293126606761508219239574485959525789720720484158138220428742018855237740817066411\\\n        669988509838024725522294718702001126515465546397182160780124593848964133046792521213038410\\\n        124936806061850047811600425489932034639179690021782334659004036004615548393288350094506338\\\n        456895782571074776540348270640678490756595492467032790861916324243897670480141219229317783\\\n        768773828740478157014780654521040570640980101683390816214245068478388397687744101395965668\\\n        932579712822944669145770047967949328660280385195641822765422121498034317843186512059378874\\\n        433495288079020891499227154615813085219358362399509328757270355792277272369854597687783694\\\n        396056285050391193772823350897472885778517806017164289916043606369200950032962516343650004\\\n        806296676449029674558690169809190551553415819484535267640776804870578717685889594202309293\\\n        381740177753687038056263031591852524654650501026313597186012099946259254701286202973082600\\\n        583875577240401608051181894184107954020867213187617916070318983727275433145118686212151160\\\n        233917465401189518348345628600967187914597600018600837515170707626745763573697675633342729\\\n        520623519867693784768488856117148347257180333725274677136878580399393320788547738090686721\\\n        393094955899571293720375088313807452465137353992990019146935025115252227240374209943183442\\\n        811516934486621427881674745660469493752667836950061518652623698918275682154543950161787591\\\n        476824973377150353417975644457821425693441508805879423312100534871836425766107429269588136\\\n        008750016909603381068222308268932912143832832821051294520227001618371477650466264783767771\\\n        749495636590082947314773169005808873013953308329633229389458447617882634221178314398554624\\\n        134765778708998862794645200349242812476814034440791128833708992045758074160549787916523827\\\n        086201782509423198178084449298964215298605609498307896160841280924861213870240913773660712\\\n        070390481908182690065832111755328777571566699172012457149093445566355849693788673077262476\\\n        284651595531070544890774884929040024735839047730435863689599939252627874906145526562811757\\\n        315743653254426787787077806788739133453921571097934623073854650168148255794934843033926377\\\n        249729125337319647652452485467430465999749769768293316988890511357150733167505268534671354\\\n        866158267120918806259148719625611569653898816722352057999344504505029478812371857232568572\\\n        478841118435613024588484414213677081629763324916075757821545917231475971931893389642464288\\\n        981792398339233026521540460584021214698469262663158629260739675529989351074917855362236917\\\n        204277022614282832952364145698866994590423520067398686727366251189801564525703200506276675\\\n        680353815756288876404143026359116869544399160860809459403422924023805485912434567477930400\\\n        864659182725825279614625915178997015650016213415012522910682681532648775424607151929245866\\\n        376853538697757654105984583746087502500027271124504911639135450613303823370152593084971546\\\n        117789681059139870622314809320091350956770740357579314461045400478759539894230852237157876\\\n        362984644158415021182862228365140461012446733441550668439927694734177690628156652429999979\\\n        848804690480070004872095677919554841608628057944613385575917560686589102880395675337456093\\\n        448784029061322194464755089324956761791334550823512894654295123619865972642178980688162256\\\n        317586314414838484045313605715646222972232208763210385140992638596387028521495627384741351\\\n        040888394960166537758994603015621068439637349837707669899172120691434990311371546697083871\\\n        883617072941082600176918580404269061292831370223065646787269897285367302373491674449694769\\\n        063434868950773027535205188895049296491167458396112327488001464042959127659277477466370393\\\n        116546259058461828434702980551375293410126614415703296536622454834875896237610480911675737\\\n        474989721555698522102270330167587012295542821546422423976353551062801645120124781660859604\\\n        819109683518610261374063154346568115664163731364962491240396857326809693242657474663171189\\\n        827380163220421071147067772698922812539452449856453328596721632474211350901138650341447369\\\n        157539704559139055802952226116624040738930743114725740026518076925314501619450671604363721\\\n        516648679889571879590124428694727457902415232957039377646981460953151815972678488833290194\\\n        980788721649206208182600727057537112040823616614990394376568021160927487729815631056897376\\\n        543699481963040425010131191005681237624153009236875987647595805492101512400487563848214271\\\n        801608218761628810588249693896567756213743174758492776316042700244846195756731580419659959\\\n        536210994852785448893347535555692164706709722983814666966448160861606889121651722540791946\\\n        233695617142957079387486465141855809941941127114661891583100139738425236877776615988859106\\\n        099105596034811566696817952564435046816550389007631562946538784509268191151139524550705426\\\n        081028076264978217304090212248058255683045742105607556112092321776366956068901673154157452\\\n        636788069746209504501930569790209927158606541317397836244932936696465508284743074219172183\\\n        070938161749193049839459875101143095209549198359120005358677331859068307835780202236657500\\\n        746888365408254631006163484459230013638211258390251770269126926069792117115292768537441649\\\n        934300660818705524146691354330809492290764847499065286208773509289360328234117826015717285\\\n        103189554239054670897871567720135039117837059489045683172812276230639978795204496072418411\\\n        958812599180933735915780408967070361127215863685911658800065707596938621473439191653762221\\\n        797830759768081688369050676144736666598735505842846725840031288427627373362905507122940164\\\n        570519929220966305012176868586729090772719558051318951881378911033706575287283748247805271\\\n        402473693452124543676967333477485461581212699204610081518855482151200602678225141408613885\\\n        893176168054134958926650644805554769927676908199086342013193067396111252746798040812314705\\\n        194941684900426902386019808389990004046178737549128266569538470152772661797672063544268699\\\n        930922255198346258975971509368791880911903375121552961098359879735829841264495462755793904\\\n        080190532154170532175043101373744271146101414553517973116227388062347236521053763643356307\\\n        488194195839902535437486330961397955408328824101023140931024023163683256755056321351838284\\\n        822418347806845937626842417565616214935874985379740964089142142666233028403551184343140009\\\n        986274439137322971886285738357243072006157389410228162722332089819854135868917829648270811\\\n        326981788333739471049092859238101238979352360075633603719725176925714354213949434165619089\\\n        603621903432562704216927903577188938653991765501161425244715805159573572565021476511034664\\\n        437198493478670797463952518029302215885592299219909826471643501657615339747806626229616877\\\n        346307030518522047846573803123795478561659602695113971875252672704323590472778697464073979\\\n        480451556902593587640503195823408306277277075833207950636803141287503195975314855160818691\\\n        517631990691499619632185437779952872360174600370785161315195292163928014647666433896211698\\\n        359020874605243126711237413690487823770369017287991997874818068997556600476852253171815010\\\n        966694502655090983463654204093599218481519719030326642724134171339545890293399220336473590\\\n        600155565814210781052164197662212023914819858510291765577141949448157177520721343120751519\\\n        902898374918076142625270373526486309557963617617791464050506235217864728983510097889162759\\\n        202545417004748377541463348566936879912238102608720845158778605444301578893836537907298864\\\n        531053320680081460490560651764775109970424673144156325407456190883358510196688455009552782\\\n        913251446192233116017209524654304646299170665865348045427503437628476332462642218378792639\\\n        849177224732340177771536134092132155684854079042049301051603943399748734215116477058818756\\\n        935874261035008830625737657513053848659636207620928499137634370471298591090833026571024437\\\n        958642152978333200883430622508240032509154375230047228958205026794437919238542440311796696\\\n        955095110327495360689976456935272924903504382159674562880563182931984045348321788384940851\\\n        976007632241143034928808428187519853387065848947287493818000928724297709742702820930412162\\\n        996723016375065136717143271958351973590128845770805473175054691895001718288489188216183602\\\n        187594625288761828936542655876348644833671185017021354858280242199694710227945080000473160\\\n        146837875735180056363801028554776712802010569408723329419888618556325112841802630878043464\\\n        166514555596867797673652723974226158974537893466993912874056478973718284434980222717021144\\\n        079825347165230573953676073212945514520297147072976958540082163053342244399479411344152362\\\n        509399597158884488239823762984425647238217328952844993802807579523775708647084714505351770\\\n        955219557336823933934942723168106058232937667802385887396112782311858051680734576471694771\\\n        097567830512799943379525662606975115099592320021881760867069186613162425553217730898756747\\\n        479809569358392254753574329612678209388298016235149613371036960131566939150249888193616386\\\n        243033520390200773722008876330895531684780802145049655745176063738611154884781865562394700\\\n        104851966205467536111925674541852097953532003191077137187446075621883890400923753271582919\\\n        800688576698713468244673467673215276885277300605467345375928503620724761164503238201637111\\\n        057299960909132380573784714085125413510166467634003471869975956370026421751642707732346043\\\n        054580811077429690907288967798552122802274445537499882173492317201387215674138988698972530\\\n        980384456712535025189743643490600536146923227883403333602307988595103684527950296585590174\\\n        415523210099606497816665661075103951975700583276981187143792274070550296870853840306818535\\\n        376667712410076229523973405718766031186181143643531213304975420560288836100059314975630002\\\n        776295061435247002828804394155379635488115682056949475147461812350693599210258128770600071\\\n        834749833206442798561554433421606315137333695461297758209955629142340725870256290999562862\\\n        900564956779456906025934709062352067366121709003517620942698283162500422789770574567675395\\\n        911902931457360831900989326704882321040207540519442460002113389298639924483303667928746697\\\n        258727041480577963189450797835768467430986284630372852141883686911337566882489934104942045\\\n        163739792390923695850636115305009918049015983219404366107343440066574887782592620682818425\\\n        088838576174782320249837017572844458731914110578294285791544537789331029052699382284193942\\\n        804677743563804637146519489826398294011615330495791121320747962672535812458628484865036061\\\n        824552429898787810388193464042236371998147594187492046866387231101987008882923086581488219\\\n        172335853683237481753520038110495925222964600786297124034915794718393959750168901460807371\\\n        528540524622224264645751927649877005526130381558105466397644480658092214521975908543046920\\\n        373554585993518395688709256976088032323974936152206673912663391658505690770921062897210772\\\n        391506505521943716890878857222818702613724065456210466434356748693767776607844222926894752\\\n        843581825810409248267372380586491955369488974644774244965388695344209783246414109545467244\\\n        344227791098870136837742890643132429021026192020472793019393335214378910786254038755849643\\\n        426085704884247907078922727795481420484099334583601044386214897289527674983144269690941291\\\n        257146762888158914605802787210579824585946196276198384762451732933090040835838909131607620\\\n        239513911034869174509786277725328413499241069998391646782336019517987399359970037678032993\\\n        420077712745571198404572585622803066138470592085742543245688037859880799922777989028511187\\\n        872306081901191283383417799215698751855096473830618767850215808425665834186711081940966981\\\n        406766282633755278487707591579240715582701725999478600292297501552735209889696310111713701\\\n        183831505522467343715461954112835530589952260899798839816962338132469806277202981362781355\\\n        862728998774708109002952308919969555923177682385539820706945318333803786334682840463103257\\\n        087095122043076322420481078005299611237416264803696912648242826069074328577274208425140631\\\n        745601240264561522954926168467527113551607702136891868714809592050289677715213943658624399\\\n        772620511202320197167657757789377692613148844827361462029686759018880688348579856861373710\\\n        505562054558940537689577881308055867174607584325107447274140819338128694521586059861729088\\\n        814644797161929262540441333355602604232473200869554553214761817144138707005599275945321506\\\n        473678554662173612220786657388619690816009817351338647920351110827412594186208393694070741\\\n        458297406241786032310882257969147950300359826668151192972642829651055647702073950368762988\\\n        782561154753220780038335404384758311083313730076141993630701121114281325293908054109824465\\\n        652780576217371193993597967292424956832959785154036718081012923920194087350750969424534228\\\n        102427804174350507008607125016945475527588335462026187709111873823208637297510286957735234\\\n        055467674812750230820868464197900724308061364768228998539960929415399041729515488265236326\\\n        600029438356074805137113489760686462987505771903854806861348343095089465683052739624660722\\\n        842770619231605333424081972026141141159047999041172236247107189790133023368790041639371320\\\n        109719409100750578017837617441547288027751492359139003614208422733702684193992429615416310\\\n        971027866404680961659200718454148592391119735787722988698666866547384333728554407036087116\\\n        848688565037591841629677298613049096446738482451211911534828536950954834181986777360575317\\\n        436364951736551175496686080473622700865769061730312897412072715262080001314373578187397166\\\n        365163047185952712593890409716860970543913372199865518309334774663829413325000110352963939\\\n        603075827011874110929258397251848401673753748484383439643571721617149805470014675216898315\\\n        517226789897559284180279551283776338070144545027184099759365075190023735673903633444732912\\\n        041648095651036740068361342118280479836465862451567166497964509657878243596819384439809935\\\n        767909332342288886317378810038782123343101711400118381284854638872931385438385020486517024\\\n        411168906323194724226570499038602321397302276500304022735624187363004652256929684441408580\\\n        473297258167629287125278364408255267821872644124884987204028780092533178360083178480842441\\\n        265908461300860229941549020964521890135042968557234786768520310093935798257933355250048219\\\n        242859498582980403621536589928562639149526350635738038467772487799313529097955585273796303\\\n        499948235858504288199279739924178456832036359603568178383711620979536107547198226908078102\\\n        942847756751240669766022418606697516554066991667577569249331211646226660429321804025458372\\\n        739079174250238946447695860374192128966607780809082812098096861372452473338487294996506169\\\n        896370422719089341935268847018608471182962503979681313965718325873060041446712966320873383\\\n        492863527677976423955963124643923389792265080795256625630536858568087207610924788315777552\\\n        401982320803120855775367359523023578068052330667726752090046405653088527874213219731632520\\\n        077169145542644804373419818805507870545637378423846473718456607042983557463182117943973121\\\n        988296977945306814327341584187959013877332116535327289743655634755751285761702586102075952\\\n        137676511153605695566861051139827381470184415714692306276318601539420643418535541041613496\\\n        485461074326113050405048625668966303385421319153197488419530388773292017110199678645174169\\\n        835711291993088654623552610816814449530315379630342949455764266036644706391922877664890724\\\n        693695580831105058531676840233807624664515441613978342677288914188050413895568230965528753\\\n        061217075284864060837533497784714011249195167516079041538254161873434508372479416544362704\\\n        418920528156223568460997911747946734984121583135538902324808605307188907261904417073019747\\\n        958691696459581894048318482647274978044666763884973636293168129017376190765234678481637206\\\n        538761223974449083596354264215247553901648689909917648201255473664019401383584777302302974\\\n        848332760224242610414231456403166274718035870707054087488677554255625263706456628547339266\\\n        940689820916484358156868203469771192397233146385646679344055307627358464118317612124973008\\\n        442984023722410486453205589444673847943195351524581553531899267364518745017840498662843038\\\n        528117286200036624213721360952875241836416495630651089022395201292160307959509618714493837\\\n        999986611990445103709954662722865275642250669607704200993895480755674563924863063665800672\\\n        447346036935279536640671963906911758370902086338270690790206389482974380426600772310898967\\\n        908944212973460047300440360727663986274529987366830587094072560919195378243861736718737179\\\n        164619003924021096856249744062318082758518572941830056341889380895509456298497581074514832\\\n        123496743260753541862016951387122359964784763175346756568021457072118893169811066625363668\\\n        975376913627049477231507594106110275672609411910118160789650484901315510885572616906073369\\\n        798416099597988101786365406829999036232344477406151616433502363610468468503138122389653364\\\n        705335626206112307011064506983753907102637897277192679726402406617027311373373634939371732\\\n        304530917729619214060197078937117404976987400018992833221796841153075380335314272785598463\\\n        575998149279758860439379680559926100077422099027532690482477049104741442046841561346421721\\\n        621052053672006357469915455532290306393790172334562735842848654535821726239111238592461013\\\n        161471765267759367572981132418136696871824429226631816890320564054905655704848292694553647\\\n        732471205774096504965706128566754081329049628300237117418189354083679743317178253682772862\\\n        100175034455584624635804770668846947497858954034368217943145163627367687809072210976374100\\\n        707220942817619463006205165429842000614610080752469820840928229730499320488504550120929450\\\n        098931810614194473956541951568202347745915683607522641585910123431640668097739240845397624\\\n        529798159532539240802933532735180331303386453267885242150525824907715722716394582206957637\\\n        391318387871265256514124148187446060842966484565299696287273196926994401880757489223337726\\\n        874676743044067223824483231667162104115518182019549563764789233653433739883328847644594924\\\n        737038747145567119028382451723735283737804503551017549791877990389066131121388150957724033\\\n        053171810834946059398712536223839852705739905130428759257785478232160019034771396092777889\\\n        574778490594929083528696364268488729557552749169833311410498499228455208448422583829410982\\\n        950498762946622485950085259780549094179044179427853522747845783317036987840714344001395035\\\n        991037510156674604725937057495705582202596166993871774762984915470531242297388431514913720\\\n        800487070327015602331545333284835203821230878397091916806679019431966355412511490499609540\\\n        307801136112553591391949730168009028008796768966633698079081215142724182306894544281578316\\\n        007226674487589378371723580451680081046496983838394954736140503199251620499504337094370243\\\n        990381273511093543956971832702772890068048689241856184778414761637437587408709758797913533\\\n        607375951561076526255857580612132094867807217304862157153095295642312102086619464695032303\\\n        305005028203304507653770991393797542701205912599291342682421938292286475603644762782588395\\\n        866794304828831451845360683334799458936676451562696322716254785096929266864681155237654106\\\n        756555591643586426961047059647265634556925375669280825354908744447231225468824775307798708\\\n        653044113431133514276217944080305942554250577826138510746636601799295181383179340364193951\\\n        094872045476281180193004541672121910080756879097075950002354194114065630982072952225427318\\\n        595771665558757540377246752732677754033136069928156724581129571199330932407842236255266395\\\n        195296514483224460688024471303845943681181095407975359322253118856989030827048091460702735\\\n        723826030829400122767005062529225108070832544958724385513236771178979426648268340956897457\\\n        880865905938977404219826472492075581324304970772176733458172650598999816803392184251958688\\\n        268027583133447687468488301117236578813807939929594904800182594386915321358300345478330991\\\n        126047315084869513958767314919515333147832103388717797692020264349151066155109581864745200\\\n        748617039778592564037430180511463148257097810232240712446492788984571588062120300807567934\\\n        079991751792609437442609925246413864350752861586192159070784500133216762847139670495442893\\\n        882847330109512240330281527656733780316147828092849218837694646425974228042191474477519922\\\n        051752902038919568864862008877170889569670536714666221670922692174051614430474741030088485\\\n        116239117553574584185450369074559387591380414904466887560847676330156983741089190360683866\\\n        144715498068167689654221335051668826911076986300794497051530461566426926508008790139142016\\\n        070666278942093539471183116611923995498092558856609933707408327719017906119462015089013843\\\n        983184906667533318052634477024641111506209937327291327832202564619409883892101536618738387\\\n        894333621080987519869716469180254104732459366433510892816377150708286017652646696439539186\\\n        178906121382083011497873781211731003759315203305660135390170366885799275256571444201061710\\\n        927250549104199337934522016537423211037199367325427511143640679276273750321737521156977415\\\n        565374415333799668140362471049767561266037982073989552648719592886093008312123142132399747\\\n        257395256103087664724913725764736531115249316981859440107424353655287887219767351773851641\\\n        210642686538657523737808279588706361858629899681291684862571719810762865888321028108699795\\\n        322366367006718220738386200464973404935768961938870493447535964476793682624279336449835678\\\n        565596871411528605108865234825227287081447761130955215797291101865057907783575125629880196\\\n        416400265870952492848823466385070190371407883788974396405368677760863611258548820815192621\\\n        389412233671378885098024796386045676887623240096951242110962330596453799326354001841533282\\\n        965638585589293138006253275704455855227353195403294252888547243766839212057265391842338419\\\n        836060235139159036808333162415055572214792881971998671057543468966950103092481430835958805\\\n        227219504599405022085212434444576861538474302954395649766210708678446694909356135890590086\\\n        863931167951467924447968653998731070192015579533226808161518406721655354914945704309349699\\\n        294075472775107506696766224426894559497892783442540554141565449499719807410761906642174614\\\n        422963230589907815510752577878590138776310307888239747355764122476708916800611729830696597\\\n        713945462288259378994957807887396942979450862907418739872091703686564978319061218249575571\\\n        944991177703103410123837731496452716931709058658905118585432141495566593099507500459745598\\\n        336103736020240484533952455119807008679976905357609842300487325251754549891430950475683294\\\n        972601856031332285250404702596491730205347416091616374205025731372441606923716246126944868\\\n        998319310585099785459893727321023436515561135617366142460730920952952812072269008279740713\\\n        854642327194694781381555911014585442048918536009211671755396528065019645354668676330639035\\\n        321992140651829047748750840759283839055141313787526363582376525084345625636982166790833604\\\n        924825011001057310455931230462056325563063105167815607697028873196502955656275147462988120\\\n        633562341883292268582144376223091982703775131952165287240786846407961216617082062611382697\\\n        846189031206707419683436197212847121103789823018399314364132560777168710825942159321070307\\\n        908907582156967349884503400147929528527889456527458084790619725271481712563187743988648103\\\n        189224772325098517525352192190602556479795240001244653039167631518331506475098982195502050\\\n        254716444113919946776081086052795812911540653207041200415191847896846474815437367830321628\\\n        561124514663325294549697347421380255453659522656785485979888020672594290530146261803759798\\\n        370389677743167109320308177842644356804100727358722052091357644990390763583593598739417203\\\n        845800748908383165037541225846995322534129743773350451682576838150789934253481810722401106\\\n        763707446181189751333143902330057184220730558148662215054003623652818675491688765482389331\\\n        013500591413975383931374332243514997642641620132291868630727671122642159320153909252477883\\\n        108480122548509849950794609338299491491730867185441859406101466827331312816500822485108919\\\n        426451328509380919137769892512256056804002754465805230155255038247418971633658880297048368\\\n        730045363520972630441091142675397648185810778168131104694729082847265376453768270938189355\\\n        983046298735593463647186237592211597975530483716110810876485191129539717928890004525981067\\\n        614487021157879708285835811264034174371912807934736276370497977793968466405539494107046055\\\n        149612373157018872361102189516030924046412701538757194024260916757135520609755137015110883\\\n        263721340767799679043197268128954407789045370000533013759250639972734600284188875240267246\\\n        803220602288364954947620155415535929740539918146212590646433636063039057147773114774842223\\\n        948969637718795695403641458576659879047623903435323755040006746196295894157095282094390640\\\n        828217133098464304178580904654176281911083182357703962482491236109294866313317715715355673\\\n        826595765397073204944600494668351589987050271809807929052278939880034879742569071498046184\\\n        890727340643906482976894931642914673805433557622018853706874712053857974432234604333349134\\\n        914500334973791645831360359351786945053134816503149773566596658041656865280484596194484203\\\n        433081388195234548169221469675736136325767117131880630833686610355823024216381184465854106\\\n        574394912461741058754001440880470773936271351783782221838775678677336790138159785435222718\\\n        247138847717211727118792112203424213203145012646745420736536717200245396241549151320997097\\\n        626668548042434086053560480660369052619040801262262487172225088265947701174382984940823522\\\n        865783531116588482455857908511252619141062170539637631300715029386125583574621492199256609\\\n        735240274741996301653656400203932975680164759402593578286232899973131096759117772898617740\\\n        070899611725424505680537288529658933111647577615594362702145001335247091514113479602416443\\\n        166985920433155720273051597787885974249741232929117368163434381196792057669684371527640373\\\n        581469433480507729093978962620730135276227584888887111450634085384754811963763715797634013\\\n        622876524598301062890207929926716392913103704379457375493701136459286336014235374034385458\\\n        923486492108013087998992874619320516756351906657867950484721844496085133529483843608437879\\\n        681957601891522658977640045218387061306791762342360141711468483342190530185447099217535756\\\n        106427978445534230621252059808349217264266831609958393129826326325567448299276234558643983\\\n        731561803327220314735374885475579344376726115165858084345920477079873486365896555401360091\\\n        167158990599957368796246713666192496758592466073999625866957729785714809740532154616313798\\\n        100199718415444112250106252351118041805333008288409075787086020500952261515220759563597837\\\n        066436405756349164043267907743908360091404123029584129869237055311098475123949623229266366\\\n        390841716132139550280069591515973660819777752720507683111250939190045573187324792687077512\\\n        799278292641598322625661676895336648238151507427852003578802980279200321761684449647150397\\\n        422739044239604844176752669694083261935305519189370246018741005839756419589828876764037070\\\n        866445767396824034750156491486972128614139133919138205374834121416612758374552690370451579\\\n        522330179440484617665904118916710759471955137923572174456010959685325543544348882405488669\\\n        804838245383376098206553488299480704488384052121841483537931255547973221698982331507009854\\\n        175120626702767620348550693520974373340360957767262402761777566930233635003430247813284923\\\n        167246138530342835072436061370785754431592518354286401209212936585171547070816213709878083\\\n        426901310203758038038841467441871622825253320209527195310620979673972909941137653068721188\\\n        599004112993060537286461006912465140694738056942975192287056995300874277612256800930366258\\\n        772815996913213235754048284075117023304767114485375227812020508864578673108331193168343056\\\n        718629203434375401872851356377272740129684536554547014489523196596341537897238372876513944\\\n        983813729442976245487135613013311357617583985063544407955632662630197274757513432634627658\\\n        018941593209460299089649941435463212516289347748935227307203686000366033187463813156341877\\\n        444308431625782649323827519343867638765315164506448592899495940528451286064796841763173092\\\n        834696764632687648803553221536318909512679035123767991279472094193543630921927171221380497\\\n        508739118356803007331196856848762320307284499505946480856512965938660409927835413584217343\\\n        126406866518956386235917067498433949439257171244876151095981804704118632662792873362585437\\\n        090436676586523147943080901145770327121684930348180727540378785004683544245078655535593770\\\n        097262369989627797302222571147706878132666427341729864842133484855031656881795195825228942\\\n        589130968940470031845589966893303362719527092067354823204209459068015868508187477019377047\\\n        858115429952215312656896581956320540760116203529525185765292395845058863825148702531527941\\\n        268330717402052212639167583216754545733682771059987589612600995178551339566382637295080357\\\n        155791588165861014657555359935495878686013472033342301301334083446396367569956648642645024\\\n        175033346657761991715552720948003195178412318558067431278186689067100702908345099096424578\\\n        724624525337701610169964707589440294765010881908251823926276482451800939366711383496899922\\\n        936832682308450250053575338691515694435819034374140587054467475534524367294226339066311125\\\n        036897776742565843820098107196138101925050889542771249772108001075314456963279016375159007\\\n        722081579527546658165423599263293327565229121207344782567095835881228480874996444170405826\\\n        841299531540363614446830947858700184293907365701136774170888847697862187104584996785908172\\\n        237735249822701119471664981546080791721684666359681091393940507232756212267975956916951274\\\n        908811862578295594361837548594474624954768592961937082300299046730891399164128055014488131\\\n        991133004557682178768536024806147221787645065355648729643877098202280225301974395915918335\\\n        997115562722771243650727917601664246303016453038004778887352845480821030887049464464488640\\\n        661430541804072244003186749569953489419952815476072535996453950500750023114087882356336695\\\n        765649531698200170105174019885887413859873897856107408175845483101229726923051010149885313\\\n        261798209590663544712049688718754709100297930738310612353972779384616106839071334023120515\\\n        602544408920133495066008011893303243811578828998314745748500846945402301769290141308561816\\\n        237896324644756607525011066847286498120285071662582256181598203585661021603060214266012131\\\n        284670619504759709573719731415521068464771786118642809005514184575501463196512553182779454\\\n        911136613802304391840458777204561773231347080298788405897115748969026447576997450542576826\\\n        210844338635850156771228637169303934952077684009216221744183409560421930395581516674404713\\\n        225099209209698509989883302487697683794091414994011895967836867223773212934405243887761987\\\n        391155570036205977389369624450022026352261026077144930651319739872377910880014147512498290\\\n        093856967654144018975725355603821544683181989907982844230971963637791238676050180236145415\\\n        807089131982082713213579881582749665392617986161960345283672809623260233905974271607251535\\\n        148763133197637310624802859929623976883770646196632381178335267120021290100932220432283274\\\n        092066641082639816262281481306900868406571342996588550186271715610500639811036875035970506\\\n        904795308973460591633636849431596815094216043040647502360164838508918012099070860690274242\\\n        794128198808204654462339512639117391799776030385879171229000773058170637968254564157098694\\\n        992562863663456286802179387543100698306956086383963751948279992821656983269524385565984805\\\n        865697958003860622632291114495192821618601902945867702372430137740068607119414905310966890\\\n        823070516320794046550985720286961785673334655909889718806609227995476793397536706023609657\\\n        806579824774578965351911226971871704464419496502106989078980592573274681274662798676248323\\\n        464666458437757819975049785866852289327140724309823813461211386279250403525543131483697581\\\n        158973334442685551071348606726184925062871912348093275719952703829404270551027457619443538\\\n        788117616064572702544851916652620447784370774406679497849284566566035728518460896086729237\\\n        020336547115504569470357109752938171527163937361053713457284756039133710067058502210650167\\\n        152612849574487854931252625519900054647065160240785879398476323643195486490701934690583770\\\n        271374088562928117625455790883300579889725767573776055757254529396266666575553052678497627\\\n        892231206865651997999351137251908004825644085033546808721794809368829356824571950023885403\\\n        505427031643248789547913591176221056465081595897308059828232386145053777494916171236156292\\\n        418983202105820906072753800676364125022247806375660289363678292677460537925761232386185407\\\n        939935515870489384815285363989731967406254961119727925097109576713257569719806573287412783\\\n        298340410106950253913707470296169298561756691326312191316934804479996094769481301078291305\\\n        332968330218937724338732491697825475396355835472491789812905073072570797545539821438087953\\\n        668376704219708234892498270239357331449759111193008735910347226063092675006309060068295203\\\n        001283721869648724531367921287968150574693570997538297873297709465647012950166049577096384\\\n        572862727963818775003041403860165515362922533395133654281559827144495321146568999158390318\\\n        503772437314888308669651104182731630911093829782065515230052433802286703998047921994952748\\\n        548315856064108756938141217646226180213255556464868285332967239963575905868286351243195279\\\n        543748360618482641356102383995914979384316307806084466359016133705736871443792558530926616\\\n        658856377256152780156358982625377333510822508828292713884718203293147778192205852402864276\\\n        953985013170328019302945244550850906533524501090311799123470637524486950844509851167312392\\\n        438185515071129739682698385410696773306371787188975195102968494494247011853550101583709218\\\n        058769938724105054295318120879192492946731443565337739468341955461943046004143823215297752\\\n        217672997113063229453139238788786820774516250481619973174338533079093848554998473371852187\\\n        230354529446745245175947100397114301486110574006095919650981271398282623595928415422014962\\\n        327461887766323404638365571878170185385594609566280490448766884789019983466617881513588067\\\n        631091566268049346051253627710522356342467635472132256942352548926795250344004871766927676\\\n        070523707886003511691001646406588893258425281360575478963396102731472038535028489665239853\\\n        664574072412059839545183704855747291822932034741234950554055536833721275741139594323465427\\\n        003044826500755410959179952975454495927757139359498133423680561588123640663805811388875820\\\n        041289548133859801502545536305410809946977272594981498106025288061392410130143818650429574\\\n        216204011526102728391246374003294501886178750913980543296500749225259866264383882293045576\\\n        922956442227030425468356372044483412082057433232093251048572631842919410671229779592077604\\\n        654973849513255526345194720992230082271616140367882907442525939759157894527065087514371760\\\n        926323320767473735385037787485600521290427362744825475036615553491492557028834179209815223\\\n        505279740748189617124581952819152356091075070470871173278111396720877465047921017764862763\\\n        736349120370913955052347990351144941806322786752804525642338755095509926704426280810973634\\\n        404762843382148605181772232259857347801461733043560177127982744887832455965984385081829242\\\n        328399865343360096015508899403399153608015578102555023800984832919690307022599312768220184\\\n        482399042953648025098570891236088903405149586926101524954334675220308030422941880826468428\\\n        380266857796172529234591154963358190681880329364063007170576897345224615170648113523364537\\\n        437761970199442261398908109430118755048599268527256065907754430473645189029412504118268109\\\n        925894205336345598872186272167036198727052280000002684537926378934585111951748702933673085\\\n        617279454136871853458441729981963664473963234413330070006585956667431314108855568420594186\\\n        691612178730533281470362340042384756333647996653363690318159452118910429887892249100974697\\\n        855264353998778619461272166367832401278572331167679627343903969530328505038897545162091347\\\n        463992114398470534908816698985334680780699101236149218869360135362368190671793871386948672\\\n        507140366687896834641323782589493462582725768754274609752620759844263845863695310722244397\\\n        350313727706027267080224453000884894393164126872714885752743028561310560235453330483637756\\\n        447048725712415482770604216663510116924125547899921308780931913545627068040999532549455182\\\n        705264608689227283944902205247049120673498616171005017230642479263205192455719384124953500\\\n        641418005545962927021979336111308776883676726339127455466668046663948250835000842554395381\\\n        802146242474123778738530089106180270606767638122459243185822535851699669421480225407358506\\\n        388813749805174989196976852089883660465203566764979991707860866141608210896467509204751757\\\n        130225395287426437286992860100472581757633911782130845981331092200486712577138852034192992\\\n        561781782421321670434567732551693455467196590627482507944511302227933728625872916119278531\\\n        884640454579410956270180121346298527158707983186303809806992941016092830600471311108130416\\\n        140125311908551605844782144243140674504785647785729437050671985402940674574818795823986293\\\n        821861176389514509463967832922690199043650641819561026777969823407221311632583666850573133\\\n        678367007649219426201514764196134614042691629187894907006622216343485780950794438901508584\\\n        490371634297550230723581733113386365527270050621512743998437778326390816015810847782193598\\\n        803220744489953134081629507734867689224581169142591081652694772321403783717851744890582105\\\n        404787781193633867119079469691688832730981655583578849394714728223111383333003775340470326\\\n        075550084822565431846794346348337153219870326340275964513830404665884016010655505856664638\\\n        530600086766811132519885401126630466499747276983371725148483879278340277479889933639634551\\\n        553655952230096838474740207654295658814423200871809899401419806193049753593354690728802084\\\n        831263409354170451109290175745713008773719932323392647442122515041637854452801152011721981\\\n        202691588999132878682175045229512421868241607329603025333078885746104612640809221998944058\\\n        787140579277310874538993995606749737486416095542456272650322249028677992583792351603705238\\\n        185057734484265520523958689666515523885710979237092789051866471903754221149169046166397287\\\n        310647471996983906553383539575894842476940664017928480083134172528138575194646359066785850\\\n        199612780775906039582742654228247314308803022670891375185179204923886419690731405160774054\\\n        744703454853558825910063870637160510418771918749281689124837293089970618478403206529146841\\\n        924138723978416975728652070881421523480466317664630255658694436761927604015671738531762422\\\n        398571918425302398670820541558252856807450164801414420795593211581606129370137561554408987\\\n        116524238496938765230594797424695225821699180487660233682581468068226206893172899432188812\\\n        447547450588158259205957073540292364987741294193706120024012223552102081152465060926503946\\\n        863174261110074811694127056447365812358997369143385554941170476404872898740989262642712883\\\n        321368065751575560087409064273086276469117943078184110896939762779951782505861571495715348\\\n        070691940406168589293710426477438533900531131466918909924831951640012484479606934477348180\\\n        218887501481356550942417522758427929654021821959307371467840453716519813321591814303799080\\\n        563266741455899739719975303202742058596290226089100379641169194632376806479257252714311162\\\n        550880044850519892541334484320009012811181157023180444957884236363866113201711672421647146\\\n        724201693772122952752302378389481263476487459344288486565928245456855718195457800019301552\\\n        299593100886854099865412131248106028534505356057968453137393939346686312428486268731197071\\\n        221146044123175815981131583709736065021571268819359960066577364641426017658846705654560061\\\n        420817749266208380293321193189080836085687756572543002939556995306023968814646159676596003\\\n        332638549009888724056790280599827616010132603949478141690118611562733526986935843330313732\\\n        541140806485395544492524802566213392547601570026280667459532477405516089090102478635123472\\\n        070122546488539474773224821167630951648704931027544868872214243111277673478969318397254407\\\n        135730112938890898648993707333506534145568102764973906296287307958239305737773394969332757\\\n        980420199637619728407799123881570051364793519669521861540736543192889216125991130988996754\\\n        653216629446278900274524540893864964475644693632463644311077776847991003840636713062041354\\\n        042288817995419408342227046539878230906065565716506681226007408805748077958852490827642367\\\n        537448295257780407827705035875151620421155625519031314519903941343267902642709462556671515\\\n        789960105558122592345408111812706796575934185902107923224453427164996076238590110132818355\\\n        642277853056994944682795205856143661914394932993600824050242272824875620978422282919825073\\\n        657978661509044262427173896920652729897455073381027639711406975942586117329528243007177222\\\n        287299097858959251484540687953225859912350704620437253425282745521732110453861481342609286\\\n        255323137438098790329320501545934003686785627288133691513908636466519739318332197123810474\\\n        530469625771778367092152024312818600629076143535470808075784549411285637688184249035535017\\\n        269357732637438158725033681149502599388605542847919815843000533610748036822954371857092838\\\n        123832526943364716409060703123011160667272850271217219210085054292903883514781951336770987\\\n        033901099894140470452396436335717702820545861019195569590383673639850435482385284258279195\\\n        804837454996711420966692439763650923278823209799650643817500381005022096674345237086552148\\\n        711520455150420078649336365837367742625099629513171216392882478357777030603870359516740749\\\n        159633076828031047669339315086709484205564827477605124646237385288211905134894097954519191\\\n        152815629434640588619816845149673372731392412604630049706778225030661640254176375593366847\\\n        497070062097875648279426819433545294771234860697215918536972573116962134052217861350754781\\\n        397969725557018886144985666674977790056104883499178203989489829309944945888699323204932128\\\n        504790440540077900537723954159947039143233928245290625184023793148788121537196878500153746\\\n        973085050395373187295206968059603445792084766073169284382350374866711084318277882441431096\\\n        688445900026519467456831090477475811072738889220629586774325579632754702375441307143505020\\\n        578616715017769878997607098222325006298010917335126737337307972406316063056596600509368680\\\n        742259538169854285873842972417539766482226632615420065917425003564934487378580585261359254\\\n        041556186199495768857660576839503991313895900597501712498401595559850108649658015566408574\\\n        761858391347868857296571242796671381721439699466808935514989546407444279007285369631004805\\\n        142567979018674313787579720293553364375468023792475344673709500905237814328593223485847161\\\n        954848717123287850322790277847676936592615709926980616077173471063814277099499724691192639\\\n        486849617277204504623340377540993336340115123411500781692347746656920348345466097198464457\\\n        121380523055563518575439109172893658483820967276452390970705755087738227632465308231061013\\\n        532377234004448203357381720918211350679790192317812502531951205996386339637522184796459342\\\n        168206751184633711082984425983035738652778584280285926898102975706498168528489458536974820\\\n        311492699982792171684007170410722317224101706484010181066859373418862884931993286476264821\\\n        653146269754784487364008283990397670277332184448711987598583044335470018889862496450228445\\\n        456002326525614189868200721984208224616182490314473186110761550192626149708553384672796695\\\n        802322368711966525624575283972771606307860328932090547717111087516024103308137153276708844\\\n        697408622190720181549880331222914272598847205913418103045235693466790672983114538455291073\\\n        542337758485283817058644237540733586617250208152352934284313855830670088332951376649006813\\\n        865646180308827455523306355206857658522304518850116240902240670421237479867307079027929207\\\n        480821261094550078469272201256753474143099722362967135613155937844422707655462905334741383\\\n        015574899565967978353447577678914487302735252313937729137278104049408905517890227418948136\\\n        824803366935024407841269155232533740291281873961589796923506366528301780992031509113155369\\\n        720792776786100434405662781880890395949713026542073491825596027499656714334973434210556231\\\n        772154741822539741566117250084268616764368307411265662330393593862859192954279137696646582\\\n        092479240477575940263874859129771525523952323943219452883540258501801992279557746398151078\\\n        792568917170989809686297936350907504144619857561799540241828739089445803999180664439040479\\\n        306455045309364061923025869975122275214693311068390966995965815615946296041942695976361628\\\n        297252107028609759805033956884075800967876443071423941309194798407130783740480431135905144\\\n        374355392052395106402839432032200576505784176371569392145447346328344453281920758982048335\\\n        175310652990176402280190883921835731520902219875271874117013186351393558810041022378626257\\\n        477946856306489738498982753103884145282864896864247695465779507126237331089347216034295660\\\n        380794880800510318145877181487031560163141962214186495219542633342977282937029962660448099\\\n        718956861678194708495659819442158413324584402476400584832005553757005236223723269740207196\\\n        878376032208223058721569922423517444047046373677546675376399213736146264751983757729264652\\\n        542352016701246490420204067810721304738208880511730090854778084752028948486143871538656729\\\n        217237809633325906730720374338078111695131136778720564194039418260721192328874773333732979\\\n        817183770526000160817942682379456504116129842664364260407751559322751919347126628988732384\\\n        436318337701325388391783490587536758941602448290057259103840178579522291639416906620470210\\\n        613371853117474448981857970097185379960737973413709833061234098551304060793233060395285947\\\n        246808839623190938037981000969490622024429214011298724086161905295307407245304868234595699\\\n        872960866358339927075453303371272344724653288889886815906549198000605999809072756015820534\\\n        128888632423905343266955782255246855501140265336855217709527509871376878698560598919676354\\\n        113057761985337330874390897575773263826377027145360261920964401496210090185260972812587255\\\n        597032220656715880266468993966219143124751100280282723327925652020275004289168325391078002\\\n        718419788985113446124545009387611556357551709265904026283407401028087401867302063226293519\\\n        356925900675315561169511476089644724414640017395641082658362311163933148453824302812352744\\\n        722424017922855429800624757463096314037924120506231658212271022380152275409777188134182925\\\n        394090431485515063648451395499566227449492701031771082674455517223905602755434225521474400\\\n        531616024024842709644328584702684491799098187338005168992561305201780019141733825772262909\\\n        493258383334267726997939608038792576289939394643106323957082372613010467660363856541748485\\\n        096915329043756145651532766303817721347318349626498047732860613195782222091173097139995260\\\n        249453420633259434067786168267904237380752725168396563667027836633239845535497561408830117\\\n        968723566628397566985784494351445732937649335558057983430343924660200533084344834618585005\\\n        785200518823011292907500073577800006065943786268351131223728572687078646282952763196683589\\\n        753849508649126686829590934247659738169681222518507435075709433736511065538563503507058227\\\n        722927826602874200268404493904744520960842768938655314406430758132078073283811891110937161\\\n        055943007739392574506013004103000045598569220401207559462651638587875892448469075801525586\\\n        342966813749017372911146963470717340519468244303275502427468586225991068609329775909023624\\\n        352447991770804961690841200843547819029270510275832422668782509959808756278067865294959222\\\n        103404794279204202466129786446960180743951094353134377428564910937623192403422605391769116\\\n        023583313852051342214572523359860961648513300791042237701948017957695239197701061884004465\\\n        093814657158170666706043613888128493193473241338370724864106883268646808142181472969297953\\\n        688078998593515626578174987860562445259762887515695401876711610243602800278907704437341747\\\n        864544791911228361372170920912756429631123621860818653851197444870400534683283104892309826\\\n        847472518722146719341482232308230231611966775330961299905822568617605126460498355052952074\\\n        378648136605026205033775707208412125443705173635130955093546593651109036017155744335028746\\\n        154721909922819431724218946201547333257599519534424026746873345045416086624469637767036993\\\n        910134628589379482700803165804990205848359026561547030179807980133235279091557463354906825\\\n        702230565741951452511316041063933822295499692800474193215397818626307162951242932425543656\\\n        601703450200834480923080583547087241932157818622126630743898988199370279459932644262751330\\\n        670583398739334597677847952037250700789245622495982336235684589883860643523279709271549993\\\n        448937768213226339452263955365669736336955848730325337462551094540060567027542952311708753\\\n        723888160448407752454546828202701252282002342795710509814862227223451684690402719741053941\\\n        565570989310817940626817812299536931143774616147462825511700897162666210524995745301823842\\\n        877580041370762911028932770848476148491204359628147997012704702860598013145516453170732807\\\n        846801467239939352297128196693194917977198761429520125866377723003396182817444318684727034\\\n        258871171299542353091006361492068853867723515330914461264485635984207714725830469740865675\\\n        669195629165046352091316642129203031054992787196074198460023852947881869025229983505427160\\\n        580914495477993064834419757031525756177681958346643177064777069517006221028582902362662480\\\n        384995688967078429962663103040929774528495201483531086627106233844656767640186471161994279\\\n        747979343743179934156352380984537486865000147237932067493662377307748292537136238463338658\\\n        045403146215123963411386484273064151695996737608119243474942625706826769062051274572161085\\\n        403212461061668608542692766783169762720403242024300306075855921161726821919446110477563208\\\n        856282177595570990376991041718155341655022788511349652833213277964002715245938142262668244\\\n        812186456877857078703797100077410084458380264319461772271501969846007366584880731968667312\\\n        382069687140158304255083557670137226124770612845679118195652493813870509482064306671490332\\\n        826175712213400809513527032553085015294813347468651728891150157227087934068032768154980218\\\n        797163966739806841445703098717488426143850754023169206230798107007381965938327696681575943\\\n        833666227302640555896947730875763023898723843327014125891768629337934445929133472075422724\\\n        950985524294226890097609600037102271247971719817853556513429638366136375599391041209470018\\\n        841293622268761528936343099609138063411580678107418635274298276879535794560965912858554420\\\n        233909898398666210802977358482789067298493565098342094377496297364917739178155354456062604\\\n        808617963923960771055844737652000400679615274050887678729255532899984442234712740801221828\\\n        286852584254347104047723931656096984997090251361652072952466921718311420516387590225024406\\\n        089970409339578980795216629145402536680931340298131751800122538203120571418778306562038056\\\n        074690964665718759328631650021389838337525607275060020273905036746807175890136031662531045\\\n        275905470274918086262718844969468895315661324588742003423679510814979684682387137517157585\\\n        767388013682864348962530210555817976173739305358180070878266225830661811933444447155971675\\\n        318624312930672630223597538408659769711180017508312217652398893284197505444383685638366837\\\n        122933032636205682600330205360507232615464574666488315382114928616855773209845347894950417\\\n        898821955001499101971255207702948256640387113424567295458179450853613484742816194990634414\\\n        523393774403963628394583717921357239708655977398903671245022816914553109834105542834274649\\\n        384159174594425764203723548197214642856579170488263456132914919494686957617049734022904859\\\n        591634185983006110831586100627799456945510024744771776320822286943695732181721285957464263\\\n        153520531782997861809944409067459565437774355577451270707766819494113079678855827945480306\\\n        284732335825580654018271907063156210644551174315979232725307001209815462535349385739903438\\\n        462444854938279057961988074998417676726083906215232644834501385846962623078943543027598864\\\n        473970334605017369336574539420546374648943226402501076574539618339368169508802177840541674\\\n        819950450226380531509220302279148378470669569587020995808310606169908080007540977911789022\\\n        643769614337972274513231615028408910892449254796691987367098393589915087742728754223885809\\\n        378110692503120686935099119704959148671797929929021647349840629590521039195613595243238698\\\n        752763704544524903831597142649440256284004218667014156397456900763740470995799829455153550\\\n        543295562072189836960705167684603835288145611390987307725458270241258293195781577899252546\\\n        086716213516024465824975336014543918777641349397934700766993460044745608209347527777882182\\\n        670461640664711918016431212316339412277865260546761328851023573243317795114688432525665849\\\n        339222594260682703914397533412685420151098627839651274179249201651119995981510956751441216\\\n        883604734986826061706800289391524740230210467667466119569362923790304908530049539739479213\\\n        896221566702937154853423470360924688390626449641511296432021830525248530782413897954839341\\\n        250181257255170206150775948433541297011926006653944490668204585482983251553592573804226193\\\n        451957794878379681874001891373527425790797699000189213466299986448598296308850200219613195\\\n        436473497866737445794968104721532864348306283829068698294219532846015871332241429930450504\\\n        936338103550429184940115532008756784205112122202410280789136455711539721363137998387766967\\\n        357786067073428216011888689064531380126622911907979172041903164404173615288337284078105128\\\n        956690974409048226528150426413761257687970617006471925837821428369950040823148105919162109\\\n        423142591335253756224434068211706668433034867663535896986478319649288253479209500848916671\\\n        842178522280072623046596430194382660891094530697808362135312883879190904367085951389033235\\\n        019237255184001277300958506936068237600378627076909055701419306979297756331118168211528469\\\n        850427989783423164008711649603111040251167816893387330978288093560874751435105328058849536\\\n        273978811336231749099540721618510622877467534809568676706150182545142179608169234850363361\\\n        851260300179787691854573208022023443631068234281670907232994212863489233334795143723881777\\\n        090790428047561187060753267420250304929305760535525966249107739485288295720018105565644597\\\n        016558134709107304760830538454978831701653979609756956640072576414206839900075122472167027\\\n        829563302425128889911060923191683526442792244643678074315007589414227489076394025842097360\\\n        334750038249471775360233908200284147294466595003590592479606080639023704939764358224153531\\\n        098392096705396693951953247459928086965592961341405419323508306894541574152477382219716932\\\n        605436105825885604699680251622934610435366227936507964079210424274279114414134300729094425\\\n        925720623009423320614989458343821073606043616002932364876365226212019007791563872060703377\\\n        121357536271853928854476259687984041564779506875008516236369335787021218369770528588409905\\\n        056776314296341126297455682992743429731361930271204637150897108750646756318966476691497005\\\n        080118420109316249498800108755705840448734623927849359296040221581178795106372209831419686\\\n        056357849532547487049428825583440251320222910490858507620602591650975613946139486328331405\\\n        385683550859745658195850841169110198650293216028303864353715461776072864701695345856944583\\\n        895513757153579614724385327447901218213630259871238796820798200421202321265048381859091341\\\n        928482970754833451061001526802443193047705691394972937163183037795404396338085397972413537\\\n        752121710024897084722763948473630603195735845002294792160425936400385804214347740413328060\\\n        538700001178943658864881860314812400356355229950804561181931489262959146953537404966236106\\\n        759191526964588169807523730855806115251643670080723702151529870348548704858044318976680884\\\n        747538588062767743794639484768368860038998162626412630236147100124939637818857924432562784\\\n        779741937763634686719180567355400920263854647691626433804764735207404194999846872727818737\\\n        243702821756315305750095986278103395169990544055954107325494483103410036029385470858319272\\\n        763095730002173864704240979404114731821621589020485100741959568643924103813131479631048950\\\n        140457705778065149770937585844037008577943725190487288401372964129520270328776738670522320\\\n        366971267352429688291203418710075461469256350802589204673159238377401207911831859949177007\\\n        567385236112751325702805305452980643416544425675888345247186665559367364609252996685358086\\\n        685729776476868096850380396577506740531802234590639164703034897671198152063445160767171189\\\n        157113694162810394192491478919445702469009171936761841452422480071136987076592113993404316\\\n        929524789170785404380992947492627820912342686810636632436704743934223856682899339759149668\\\n        698065213178127481335542399895844454431153998900745643672543039575770480699986255732895556\\\n        758685333551018200539137753718582311162241817098623610520883290229067452268951152913268153\\\n        137131990970298674205426927057447571042805142046491392624228530693200831208256492923656903\\\n        760759626382746481745314119296321790925827841468353827988687419936029439741653538209114964\\\n        210286767050677709843441281144319615728856470567979378693562536389903970497953931726152984\\\n        303070818123256142429632701744554142680625812279938117636348862019925169632678845722882040\\\n        818425436924717988931921806965856200200588377353766757359298040261966348621844566237532006\\\n        894325146387508435589315755088105482768389059736224164548857603445346582738097439060864125\\\n        910534150252604194104943513352929736305630542488274426063783434751270338343697217558932755\\\n        390870839192317767102626100681786940300861529289983816877721030612720243435318024588143851\\\n        025938823962359897753703011528077013003751825550396671978602650094074828987753963121940937\\\n        822278566828090815895603900710773287279788433694506859331123149725807256441713062480534882\\\n        926699498379257530355094925596883670351589973731449191450303841418684127826702752270101712\\\n        339213312953084795941432903732657623828665421663664936495833913542949187601108825351863007\\\n        571458715912680455205503732260796492789733489215113057817588341037709320461952384517074521\\\n        893679620328810380490325943091589484692827558916365300695763132998326576614663266508820934\\\n        928053470183672109404719429921437482981505296795828170122391932600300239613000261804241261\\\n        642345915699092927348474813662248350976356888614178592813137133893845366526491009412779986\\\n        597314049772153474553357056773818194150343614625788527357491277224812095975610475229107365\\\n        246492217549708365552859559198774871143863431109408951753095074008104272970314344306571104\\\n        009998417693033152382496205323757876215570102219648025366521594627618327671429249377579910\\\n        953259375807843581163279524553060046348150761684692093952116302636610604310872270917433043\\\n        343716818782774439576354333069139329480847578341063819223715926458917107369318087238565622\\\n        497349105820157006858771427509250846128235395054460547976644776121511149814488600476721362\\\n        698101075399459727262214585706778053140615578456912923534166498978125896260186318190120424\\\n        467554458589204336418121062697281301531945022822617245145092945063045027082993705091211436\\\n        710123983796195506879479060470488019176785582611746147474988327270190334904615062118140222\\\n        948773809223445764574999037605130667454348566067159204703785144752511767743412404911043711\\\n        001126931525523687922169517904857149199894182627793694998061203095721414918323848006258228\\\n        678216339487636015454586611222049484045016185372173662727422716269157981025412732369305403\\\n        121929494147555989961722309473227822809692827879352544157313868957755394528803557395712820\\\n        005814234599038632136208443313871239047602620400983540818603586651509735402900331716927638\\\n        266468605186080047273574247621173233725919002356590090077750156176579050351015764578397328\\\n        946020992991310585950626723895490046348854883587844625532627745714067914605419294402168643\\\n        042420031350597777433589215626512243727919337284834370176588839335349410953563318708521918\\\n        395492889299697933074431586778837603627381948950880382837667810389349561375056086400259968\\\n        897386195253777987267349048373674985816891078123940947847495701241702653158952349047822200\\\n        829847007036098123380442443477007832886407876474648736414784479617985615283881904726872321\\\n        560053582986112720884608132098537202245546518057088743899588720379139798736234643476179341\\\n        675302262881610533857492926451007574877952039363550367313935473086354448302956651203148314\\\n        759244822010001567505495231121608769447612363656076067682598626416776810259165746406805176\\\n        814027566335518874098263886395811315934828710621264985462130007888152557606138312190428241\\\n        027575726978272094371014914110258219917207385157816708172815693917538480417705404689240057\\\n        246126176999481548166686890650934613839586119019270284209935658503733513063662946853621470\\\n        831295736089546079918094208204021305428366856506722539135536132674946120657450625987900561\\\n        207104037389176008412953935487546809982095660613327435462355461913439798053994024055494971\\\n        845240678308055300249593802920440428894430671319792809595998493596223164044290951325361734\\\n        441231816989677411650398761492104323290963878500365428327748816619923261107565762355563633\\\n        061062561483874616516187902317025851095255935971729826304931587344603850033176762764169885\\\n        673629912659578386258506072242918191292365329700299670364188673336155963122376752537958154\\\n        722732326721609767087598653396089954492939048544857274796533117412139828951837430544574513\\\n        046239051860499289065062890077039876980180781135104694732160812880610481622412049648775030\\\n        487962747479712420741679879000954539477093020631128336369235145255308227675261196842379158\\\n        078575730685622144614992594607983010967188314694116502118501618501750847208430224125994254\\\n        929657885392869970472521738412762781440626738427601428356319547727726330408922777040541741\\\n        722186723257043175317122946353225184574324923593638674246185958369285048801977851445625443\\\n        038464854304907538314285854622222070974464844139132317151398168240033499094149260686180086\\\n        288223563084153475014564041633895205007194877511300045750164962108063404594932617953130792\\\n        887157370163374777419593002572521280179974370593022235852192502313959183509499597067440427\\\n        950464940196945734798779569501649848435190622394709934087615695046229794776728423658461508\\\n        658574914083602363646773189993164631372953361407836831128317953926078522616096977555351171\\\n        275279453118441954993093134463720713890646424152840598504208174845705617869673104209796893\\\n        381732705127654455731384435583436970533939491545565552068706453032224148863821071612924366\\\n        024618490056037817327771497770955484451714758774873650603334913448268109401011148399031495\\\n        435378519752102482572318883289369563375051446130045821634099032808910954315075165955235234\\\n        508047988944469568016390188555114112047732125184615377454903595803731833898279163347225338\\\n        171679307906688159621631782292487930748933363690075805610531762195312661423225877215512489\\\n        438346672526111507357178155856796261586710589582569629880891073045187120503912296344297715\\\n        473228998483501206407697079208784846681493165633309105348142838893080914010913125271926176\\\n        964821793921795549943890667530303121780154852050734703381344513036182533151380189992643893\\\n        304029832366492909802719543742828296281995607279114085881840270659203496290995326210085056\\\n        384985719651358705302141383135756740824432071347973540434993811377333367964948428888145448\\\n        244452760977469422365922425033823548820651588340717797528387853420030400811663873905001627\\\n        265348791986411729067695966498922187032981694172959258339821285346210713521346087906957600\\\n        220909546484086061821156693278349121635745108254566551313066110762746968569360990381150435\\\n        346689691741908487608301307915532685350516578947705060930103397173324154378424464556762737\\\n        904834952231340027890150914275314814638393188412512343437750833332382263843709855149567480\\\n        433949546490603380448273841267857983402334524696715826859222037597384411974694471500718566\\\n        270892814395957149180844025026674251863774706530808447349141202438445653811021644460990108\\\n        168070752956251343000820087665406084776522079617531071135300032785448374143244909494643915\\\n        869065000736243421317418415855210493800234835949377070066065265898772313620656242551392000\\\n        642974101070225828467052256340177424704597985399985725835593669760231924909559883365148197\\\n        686415063943307120200752246232788713400996933102339086207249076150656345756859266226154906\\\n        968641684218893163954365532394353912072287233385134763373343904206189876328238137253250601\\\n        547514573465837402503765096843582345903247934339681924781974727882530755572133701530247723\\\n        949509384210622130208887803891710651429616341575087060688979892641273412924334515705082157\\\n        865857972506867811556351461022423746382676404485552401499083789879227693647336262767465285\\\n        681387979399307132874801602584381527570548737909489485696717868258223822197464912452289454\\\n        527981048371758332849865320784240949547693899923805416792776750646094232436287382059569128\\\n        766045028001410356974400451940272681389266969149874067080039625230454051417569349634125920\\\n        787485762896796317367758956675388923617079951637412185354477713593833729901292174017179161\\\n        211579459265359545340464837869997287960420085790468486385856403335569819770906940223314982\\\n        214329826286514779551110861124314216552844473668705967650194024974686241182889528835465847\\\n        357550611408471611930201838398991320502058631443226734169878563378236057282799127921915138\\\n        194944454355761154807905879533312958697663457195808933441159855526855374257089320743681205\\\n        241004963886476995473365764367009601404855644208329888037176954811919882017015584783089372\\\n        558307716957223405323400201747348500456703000404184202963155628621728238812062550757673123\\\n        101909723640551244168825273062850477849467641206662292603127802607363271223807530082262449\\\n        916267969032038234224766137935191785300204106947317806042338242816933708721063213810538806\\\n        087942370330270326218812259059381520597144110735293471903511533958031090472021209214334994\\\n        786770698276205170616229719405029804838104206378163173090141885212275855127678131315068997\\\n        411733758985295791720063108081138786076803159601362439046197536262053480364936656850123233\\\n        094053868644391267517633310252976583571379099695745293259402663745547834020178944435002748\\\n        592364953558238994514650383172789263078196790595751949395317985215668100080902025419770073\\\n        832167506355361409114055266146803601665203830925510579511128245998956946311640237873582354\\\n        850558000243871888673837227340368144067187533447305346976553892853106099658883897197918439\\\n        315122429489521089509377842532539511071121948421077044643562278690951911233021072930351686\\\n        590878810087820896624129587896490939370100170351272713208584171531079240883936883486071577\\\n        759928881746358510798975476490159836504220450800782716069036450834518566277687614954883670\\\n        494818203272771061839026285040843011909993163016400467856311379524648211994756325764804466\\\n        656781139684625303247644907071652445515020670866135661663407554292121874594622178681420152\\\n        881973079948522547742797539138964879108370133870899564033995007682300908636423886605884506\\\n        399493294789346129748377613796806975307486800390217083243195295363740506393494013122984559\\\n        671294109472224031073551771255889076399627601487332931592256197848191291943931725559210789\\\n        359478684225100571624173092922212998856084472075303608246641343438082654850318333567343402\\\n        095027053197684745250598393693552672526831903880701953029682303901776675158391646991758996\\\n        861170076343956288198121422400778655537810198350620805080245372652086429059564576074774440\\\n        573785374658344243469828840436535286564432784233413149407619893426058163696638744287594444\\\n        361086887259634011132992190779992898493293130052247281765175739540734946949034171094941617\\\n        702383402845339884220280565455366409969154898924745060676578645442871695536712447108955981\\\n        874632852069649768857585634143155221610213518255973224661967076272780062035047624546190489\\\n        092894544056505972773419973035602601467214284781436663638943962855729289678595112243114035\\\n        810107925988941094267407086775273230169957521840033731207160777019184644168347004479489709\\\n        926861805353905906037263020097585422325620989369072446169902085496543469290667284421587157\\\n        339938681128146753504674952294826712553152788120177321120909063159290535301391162715635854\\\n        588740626658996451831193365898529664806646149861959691776789092541120582426676543611909507\\\n        299626434104294576594913344051051600550255854457097885478754472073748183562951018514172891\\\n        656120407384635107412516642747557601007206281699644533149065348287104684044306334772612698\\\n        065365579320017769996788065144933039268708310128784910225964811074800267085763888108775754\\\n        535111702240781775044378617756644745068573019972023934022875685232352006475820911179193679\\\n        016617541963649401359718331877249371438927461126051021970136248391926932733308457058472169\\\n        256589196042503975883746842752342685234399500717930194783421854698144080953382810805536688\\\n        096394870393157724169724860393391995546252586449214542682714753556555859609884380497650610\\\n        848337604923875925687380381970061743657257172826688155946490354174670973047415914951179138\\\n        396331091387445533397453423797015169933688037959908823426204918750379951075741473033820785\\\n        912924779270811000537380264400809479736586899792556596781797434449854483879533429751643524\\\n        469188690791388375614556665203956150175458398420077091616984828378020534317437508951865889\\\n        273076292844139279047400683927915597998967663917695690014291387162034581304443360268408283\\\n        315548081418910831521112115343457817768966771924740924178489503900018373980291054601528221\\\n        939025209958788171188384577850612610874486824613150217106017253292887510552033998976660180\\\n        752818140629984152567658677702870211100971382903559508841218192811195293510251417989964133\\\n        681389649677711669881225194404022975175591519728022658045548550232933575952856368646768700\\\n        578896243178238532028087289650964863309041316044712981481510707094408433874094420504757887\\\n        026085598191353744571614453127992815250345957549308372300550132449790747898541288334576048\\\n        406909507236128173045347111961658315076737224410452074551375267827903281256451801446801002\\\n        142317232995043080945134567308630898146784010896230002867377862222572842929814408561194680\\\n        975118144833318817268454381283438732677208365698726705776597432017241903821323843757327831\\\n        954068971364501322104007957163157548145804339799817932294900888819459879000132819220112407\\\n        714394772287214555759044998334067987759818768267369804893055078912524266144160470389226312\\\n        363749345590992397516577884452956114320103196654628448888518824070959051094620376571177710\\\n        125914723998842311936987553050069347844431532234194158537507359658179531691702418697990608\\\n        771693262262633740452920295195842461123753989042573200454908124986477395588882008213689541\\\n        022090404160026959258846797456287849505540002647497630449953625022876547868382940348620417\\\n        075577411307273871443284065023619974373653678337065940970137092807309170684648462802118197\\\n        089141823050460866856548760045263626947925294668390169526078324537545816079883495073071039\\\n        796930029702083137568450070051809150286946883066835896432946297145635018065206224321546398\\\n        671896728198100311554344016595053546430620819370841659030925762514266032667081901039414053\\\n        810454749544907705230753303063332786210082592294017885584502999552082712301166889655128630\\\n        464491410474216585386850642906453721267111338556606539383601432829240561876476787389545602\\\n        175072656441711240059527395294761513917363528182542073426087949808772591762514664919954431\\\n        054299205674306678342470630595435994012740268519736832140972723984955734048888403971563761\\\n        710980245101979505512090495227414785580088119727500742405220029681357955370372843720050128\\\n        259833774077431701193410722401301604440839657535745587105177358235477435074268968743619492\\\n        912832510260591130903115593336937317079086770582736487490518835164740467310051910260213947\\\n        166160524707450421541052066264180154615541037408371877230639325735710743854701728817714591\\\n        774239782821611256969124544482408848053160277455768430576895799853978352693161351654455275\\\n        659119017349346439759786697850873197173494832969836369442171553517626296576165437924243620\\\n        728200985594409637364334651792730798595541491003303279326736075273413537126794210047274603\\\n        976607764047596457957630829698573917695318326405468049820482437692230901528851111494729053\\\n        582842000642159789730827091734364745931191777913201704023136135880790721423039055974383501\\\n        203034737032758153526347305365014310757933042173603663767685683856021317787539573631723661\\\n        411225727353926881790519695867687242636432148791953351019961529355389505021669269816008185\\\n        651499366801044501182921481113185371179200183721879616072062152305098750600419580036873168\\\n        103317058876627837374554941656608924758424228139214741488915396904160794479827789793945654\\\n        737222552863483098313640340496657786296097880049390207996691786765457040792787842909056868\\\n        978803961215284247375360268219619935834950276838377374099370836175420760073006427616262012\\\n        119689855378958067551767718936798754630316390330297285089456183189247048874740812642678334\\\n        661976549631405239219975997358196961485982143998482278341608159628999386214812184723813025\\\n        917265064138382954700221114000365917639630215295767394413717246959351130463207834893797456\\\n        435662016438083717565921512931120265076252544704942630990800063007650791545298552856248167\\\n        481770564247399480449217999235030321824243350788833613174001807895677750497848129216531268\\\n        505683847273351972617446602067500783604907863122922034786529505781264761909775000962404125\\\n        034388384807283962621450457839550980448141064675639536426190938949792916263049378881143741\\\n        107936302883466596610022456128282993361022873628361316271674590023879286933270896695583709\\\n        015629997130346424924721155060296040042038835021509587569390613866060630292455733434074096\\\n        843881527670309669786275094861434166180578366498588279401608162650769478887987781687083671\\\n        136084521307300753122892716452092880646943180868054286381780071880094527760840411827001321\\\n        723108461850643346122746573032996360272646283730179870102037276837088601574457568597751618\\\n        067471324836951378476878573521703891439898653002590285659149683494957859507558932439059927\\\n        709802415450780482538782899618397184534523329377266446241784262245149172084255398589120323\\\n        386925414597371177814251466968048435203576252148296661460496976641925985408315121787774955\\\n        647767183215477137282097068562449099033908677349179086594795541179659381291899606739383013\\\n        143913288685756043691028699691385106196686371468956981743026834530501779066426664055080948\\\n        616331357710373520733734394256168302194066061996915469787354219385558090907881709669145776\\\n        969828331339620676409596957933409975895798982161906449838704664799723163018673165787609803\\\n        860070905181579719093276571655561929080256939917752629510516985990315654974218951101897099\\\n        887170616992748682907153355107041654012934255815228707151342519770647170372587676745742800\\\n        724279522939392083375306422034248534996920486418616901787799172358283264472046794837220017\\\n        460695553860122283915782202467457570436780894608748252905776221769955331784596802622159435\\\n        292101717879388296681995449387906029228880034125519143575312064549224956460874479025738282\\\n        012541872220199388909473303824974195287675416835195818967805952535028433488893236121147696\\\n        344433347945199581103903271244429797754063984067525769806977286468815839425501982038612470\\\n        040283378232282497719084074570072289310765837419993291788572084237076742829347980463405847\\\n        659584916698694232351728632559452581592976379218159200196039589159838545115561073852170272\\\n        079764430716263816190673068580786460067857905064596018283662136534498323039858175296785306\\\n        411424958938124830112047771615903987724899671835935975742918117747350812956270698640813864\\\n        835034972088028791590931115231490274351257786934776989103169597216018745037722401124424282\\\n        519911032544731036156473253788996570951761943750097530517042513135664039722875309585765570\\\n        965051286847936739139989147955800243442623577903404912018050243242865871532590932209340578\\\n        623056058315071240952749988523340704546994849082092801057868194126360985515548045421466861\\\n        240340199310107669813685683243525913230628203563869652695239355712633245186298757366326271\\\n        9380221770020348551638219417104711019028877341823736981738972250112\",\n        \"16570940594449550688674241867425473646648690681374316099763498099863146330209996906092559\\\n        691551097398316242957988023229502701153583224815411587436774067137110605065059603104899863\\\n        689798510778429765986191754049259872399520375709881193692819552575414431070026005995777550\\\n        531756241179528686457808666201032136206623066317710103258842707463480333513555844332454314\\\n        580108641494595957093883459804729096084483650175439183992412790899376329674890052511117433\\\n        593417401288194287076951423058816192963088408649958209920662203801011752536689515729004122\\\n        335906427430425915276646755401102628925840280499382223119732170999930587760582020385827816\\\n        233624251487698744688545912167127036752105188286670047177927191958606341308628684451172616\\\n        828427857392661371051125383043872056485148752359617720985231846787694466072936055466626535\\\n        920164527849310780572612785286727249673457793497153343212217760981800115908647549822893508\\\n        001189534557962236186694708134771375051413051395836683200360498761435924468016810794627150\\\n        154707151917113596684806434425791439636084934993325202303729096753325692538287745568297076\\\n        617648621388826956739129469628257274943210020007870563745790904702483699041238154273663315\\\n        275105897309743202893218476291728322101767504992242686501300244112782888192676260476520526\\\n        483719773970535619138744621733935089393325744497776207550688282200424540838957793859183855\\\n        030255881444701710083679804462971631696401464908101486299145476292988743598181932121587450\\\n        844803103290087119676061383920282195843971182613201962637394556991215724937209737798826609\\\n        164735545782598202317146058892527025173838054533279541361097497078955428363190598205374724\\\n        521326252464829903301506578696657636629589304779241322006856795093758648774778192841566880\\\n        058954061668065334796510517699057641859900906617789125339844118362982337065423405146220596\\\n        056562300954294698314558086958286421614809190073606580406652259058398691420757593814911632\\\n        599286268428798710134300631362492517287955546068069536544759155264696204739401915405047259\\\n        558838920797084577467546224472608523491245314940834399330187800374418445997511620247385536\\\n        469137905949455356434251865893041223317361356038278029157178490974670859297727394451519564\\\n        881620327137722642961810172048476773286496030599654549252364117292299014058611331673493804\\\n        021993032629944134052475561091632384607526127754826740425998011936093971452558168733676059\\\n        704297552343112833295893189818671770809099429815722142660702417514713871728466918205983283\\\n        872890373075322185636781620902054614717605579045345033254018616690433463291298112960849247\\\n        815994321930083982197060789514418619010269230460340048010604012433389844013158253741564672\\\n        436647250646514760400580021974184366090518927825927619678456765280786209901714208361936714\\\n        601874605291957741919407078796915500547783476025174156331673648501387235155794785187179582\\\n        907365006656385692970741816150159671865209659395111768873094826321085093742339011168758263\\\n        008051690254587134901968705787702378190303010865410163776169124812248840248313778371177581\\\n        773203786199413392078554036469538166646695538263934518029822131638803870519000527558913288\\\n        381334728621364799345850577245820275049243628483150174716061134187396126531998503431801076\\\n        573550368364209362727133957269053946248410108135947162883142584409667696362449868911288181\\\n        396217709453407567817560094568432031175323659672079348802200739222490977183078683516131061\\\n        531153347527809274051565281787581863127153579139073412881289888792845850213082120704609559\\\n        921367644201279988888342018049576717745786399677818619593904593676764144021237820472539586\\\n        952045935077412243138128309226148948850040714445753595292375996134279426398247385175406541\\\n        430939416631898072341987303095343108400681592975927206647604607049908550456320381760996957\\\n        529827893907768188703923222386738270860429586693465640848799560071364285556538532661321975\\\n        826755513717225904443193003801434627573284885032072915497656173027253663097337660574083063\\\n        787633885747311562284586439333841999831892905974473161882897102107140568746733249463747567\\\n        382127757960971380733777075000841689688355103081337856305717903726750738577862756965094592\\\n        582357487898496112555864699750441047817882344945106411688131017386126043429867793253529657\\\n        684268872129701560609248632825226941792972548391296446529306541848552363184737672254358987\\\n        464864404414163692592951453715484223056499204200589227622722522457095919898362025805044746\\\n        003391021791104895165741251471417371047107188398658426175619860382835788825481892538691010\\\n        426308214303654481143205036387364376072875858319427842914653329431042160289446284150151934\\\n        045333872929268856453832723482457576320071401836328494423497455362168210711771873320456007\\\n        443686334623274581417709884274616142643658258293639486245193083346756066984980004933039736\\\n        636057582797952246216819999558033202125617000599454166418267595512175825630389889378126768\\\n        552000593996134128437192848521804163452800434833088141497566677187041405695419747699674528\\\n        807552178177151360209038177362078356391334447931364105260608406526894493180933842333655149\\\n        754033626803473803407640353326085376525825675602425138665997121922053939061286554155058782\\\n        031959722005217789193613571545466125378562057561861401775577596007039391515081691500180053\\\n        686631100363627194008627232998992086870429534553091524829057671178072339082797739364589484\\\n        095773724876689470656147007601897136224197438623291885986615927847290047257207325498950332\\\n        600600675882951040041293608859401838710576189476632160734500817534218097338100658443020274\\\n        188558046114550688584592973599508911942686620264498651989772826117486855507872935790225904\\\n        925091153700177874188471993633940903659740935076982545689515435273518918156258179986783680\\\n        608258603706090751366060936002315760603474643016725429924275611093840989464093456544483541\\\n        358717945474938156292298563384698240118005973099352438133323320540298949517071390425196268\\\n        427050478985141497469137872960968859324777856513321783479167889088324148724064614398741229\\\n        239653374854313989513827796223066279579908334186382785966927108150912245653005014685138284\\\n        848872262019246029533118414128000588679980627030901626039193647624784814469562554312146772\\\n        979137251305947356920280521465549831139793605197458035707725956936058993977839759251756273\\\n        710671132382982639532703339932574354326865282396116731441846593739884426489288484861595126\\\n        579507540640792396703336523589235463350810652484861713573418979445759264458821082878918086\\\n        351414368291182584706691109964483455579621560505121960169250466832701714143980359968361682\\\n        299249847446913924570607441133757206214420677537449127055129254902443750358877015766420835\\\n        814293755366396969371762439897940284518790225245107820928799245005845181580393762526382733\\\n        822143931350502154437216237101705930328615008273563120572138418916525710777338351966608565\\\n        519759062970825934003822021725250258631965723241073905303776013215244865388834107234820933\\\n        598896431612363042556275897437220793748116994505214937155763898171598369196021879574928339\\\n        835586271388241949948203850793517587542972903943655770288481149127553367376946616952183827\\\n        075395987146716233927829066384232722991192074729800986545816039835944642597269664305741218\\\n        261099538539162568075285350768211868848759504492788697015411121589606193309717310688289125\\\n        151749708524666474174663009868542447974545853462096205490760748294006284759502234393584510\\\n        489817091225602228068400170301553179617596242961255015164814797212554177071991647936545372\\\n        022414738904707349663229776147749173978873330131917467231682230996074283034411604898315277\\\n        257985887669181048755471779659284275815994622977636415635246971713581354942579916063917719\\\n        765665527649448872185786444827182450464483089074593932921718915701794076687411916192379420\\\n        460787834709511385680688068131286593152285952522294604841818449492902500828039345110163621\\\n        298017110262903159370601290061999083258558222609756930428764593682268509899113123713243988\\\n        624175590768883709820700308783691448743691022621514451496016155665028029912809623077896657\\\n        296870113256382753755858401140201128296248003809076947355615999156379871877401528292773071\\\n        924349264512533914058917358314062923903086236319493782101416736540502076445771735699521250\\\n        494568405076617790263047341430717778925062086476919099845003294255737932960217009752532524\\\n        450339113564644077630012267112819428421245949091616387368183195958458172327505717376614656\\\n        786878709034009154204446947840851304779667848081736390273304924677063644544100952008950905\\\n        827298894925782759565568031909576230532981117505774626603475446945483431705287990490444554\\\n        872006989311159965135064845634570226946481486258900108618301086652227154134421175149152081\\\n        093343745225448757204015596681832232462482968905863592012245789940713151278288054893013093\\\n        811126025484661361526246674401709131169778985424152631878441305640746879739091564418641109\\\n        324366333073818448434104402815311838679325237922663141034570779663188818880313457533535676\\\n        755006119407295188263815089954239725665142159212281315790093063816455351351813928680868809\\\n        510482280314474852913262977724156137174039624211647665654620832484488041172211618923191679\\\n        073787109179439073077220486417307320886238674854884482099132458397416254527495189265816687\\\n        255371517371945224798121157714366672202172348024115985154559171990626136387667315370961725\\\n        766494739509558266194085909748847626643046239031759091642318416645956068594845488673788751\\\n        739079150696379317737899348271200816347564129891849186849687944799924446439429436993554705\\\n        240949115639378638678374555254298167349495572707520048181798473795261951775250992525658920\\\n        462978071496269225572198859142876565647685828256518502818530904139092152894993639428251989\\\n        774934000596424546228835489933826417509583204965680563722694674670822413492818786453653518\\\n        258840155412039628727538635866503952384976817748956505786547389971140903545694595450746745\\\n        443009471493708971145934146337477543638543664146900076734543367504201499685070203204524529\\\n        706972494258876562917130067876307322480883634222235038435526355993543588581645172523860508\\\n        372786117352281319665395527423966814248634538837369681255655273730554999977317303627840762\\\n        500442796006614366111025815741314844919904289973351367137969047072594049040855538080906199\\\n        222343718952104319230467941738474680213987606039662948452176187972593552507642727300421078\\\n        714173098033041895516783417066228763058324345069636117464176620331111798175954960228534672\\\n        219142559159359056697003080564653064544783163278730536757868995245363563545114234474266063\\\n        534023546152332218623564900486962754529597424973968977601923434080921204048176842120531347\\\n        813272905375197888040438069598461312196559356331789372949788463498140909082727249183779456\\\n        521594268381021196752259346000641150522241633045681109319363297425475363998363318911013461\\\n        853246450916581406259021825662461442763035532997398243035290418685196321447993791966267268\\\n        901150936339713420484842956391981013591611853547885111049885012765668613687523808764833265\\\n        566370968557868920062401202771648941679664942447871196710700533891175721968587967906638745\\\n        859472050298440555091166507824116827679365329102047346268126444567899226849130155796034020\\\n        136368846930763025653751948273777989136153770692140247674844691242169551223264894823695676\\\n        580617176196607534458529645383226516884612053364563302821848131236716254773448086387444796\\\n        745845185004697729375951879127467988781179330881085474868251277465468428793801093692341949\\\n        986222435984866802472765122427048483837885628358656400000160038945365543624624249352843511\\\n        352252886172685706996991793489439909192779830529163540728599246252197947593480074080489521\\\n        727760229598333214960392041002947237545452665682530646937052366486798774131561102123824235\\\n        259122592181128334360557115912008610740893490986741152110931680108541571789778490807704295\\\n        275022924865624567363721016402191776641103580770859817893299513906016069887974804950212042\\\n        912377036694205382820414143884852923008337677111714950294044985518132769477026227220600494\\\n        655699795777500434628528905406716631882210651552412315355024261450688005330445711892808620\\\n        979702620540813562815538932903495676001817896614458274531998362096025944530372847374502258\\\n        985443906595983114644500166817523317830901416625080328634795778525562500040453212033035456\\\n        170906903976395178223290528807119722810947523664942879779261659974688181863756103254577848\\\n        796260276771338639606960716669165581501376880694081052194907811770291835566155604034879611\\\n        912284108103570563084283928166999209860628419772034569534622214947562413618545733578426618\\\n        081747227920173432994641485403749249265957071102326302700424726536130069014412055380238490\\\n        642850254652930139839649611490055238916772034737647794979527609722746245859147819110812120\\\n        018949817471655193289952117931682616480296872204760418608976658898377496120206977244362758\\\n        196712771772219488993459527808841453914028509298956507165427663736590462293194757967712448\\\n        107671513476623569513810304968636659348267796082083066455879220615641280299128175033062136\\\n        722625332334308984512949657062146795639902488168404848644782455974221724626614071472223134\\\n        731375397801067756146603030388549763480593477554764511157897555170646363177897001058146520\\\n        216898077791209097206266499047252825883109407200984293985363313163025845547153546377319408\\\n        297888402276206488099939896182087044217744557268362216081217060033937645643789629997712918\\\n        533591821319319834469371650132181598078803957886224137114944988969734312746026674223273052\\\n        391566790672052040646718962378608552909938762642389469390343572652348066454028197959360843\\\n        386783765237360469510933804248771988636348549730003502689163592430932290222444792228942339\\\n        257716474373233049990927748676273055430569334450371169317826089622086656047125852968385135\\\n        261949960172245047926794992718636541357388936383478222140101861093632023862456951750052706\\\n        098533172342214370485966011780604499037464851639266293548831046320167049649320167231532156\\\n        109335188931336237649748798939452454489645884172510816217500216466366872045609727942032482\\\n        496246132131645252369558145693493510820243074490962474971805184614655375767919505004526291\\\n        656460688112131087403855918534578893617870578480247252762140989263301453206383725075171908\\\n        151858645399181387949774895400211144462887576300292593225888332359211919945564862328557027\\\n        823571140671217287848648685825787047836754054240934030183951193301951240285667211048231083\\\n        760142624700899909449706669724857906104503105636948169039946127638398027097295517075674527\\\n        856232318527196842041544023774726059437066102348575124543245850601121470822697158851991506\\\n        192583755340469420769850424518197497699882630342361107156432103351869344884230916573988272\\\n        962364368206459068041067750244232644579557777565591369979261214709376300089789621760018148\\\n        770199026473007041929246658849239220348683565808486212040923008150490908706877625723654432\\\n        882794040367143797929713634448927639503992337136262089987581201656417157958162158592392346\\\n        988180457984846875932830615431897385564311000209785607557082393092860166345830811155788804\\\n        713041092447798650847557363163681342298442894609588623908962044105751110217970202127337482\\\n        956653861549797393876615109018168593936175217341659624035961133077400863394007220032694626\\\n        972973278955272047641244460062000321460697595988645236487373501051661457397734191126465421\\\n        239653577049772263330486151678089331371685241563916165922827206226895317817994982413560087\\\n        144803225289088518140293968985153288887237675782459096143196131349318561925866475291483250\\\n        287294941365676659790030615982501570167126413740800217134262756950601747833413949440156509\\\n        628845084854316599842040672110997952984040911562096204701516197885195651238641116631154482\\\n        069822557925043703656700603960827792015093834364526994660238091610097196913704649873224795\\\n        318401161380640491288567482409202722252566004046323170583589101095271573507008048119545797\\\n        238023368572412852112548123618150923660645314025145897766465750718530987218766355554545416\\\n        980255442206014385310363811567096907035482276124351542160253909024829509911505851725685514\\\n        391847837086898232759787887370471288794500115713528213445307466927777688081471068165526939\\\n        129498747924358458490637221284321758689712819089962881201383104081251985201703470534533550\\\n        782927949344570785090084284343173519770611184520720432151895552655201383062843360443332334\\\n        566622098289197076390914322303650061249156162072662209224707678598179767554411670471812293\\\n        113148104217574229172898799005643135453567843317445289299166553768509929756389465669404403\\\n        112830263109384833224327551023690759924843030836008348799967844627318636074400343610381806\\\n        577597862554273484762367996772045218543017247626064682490817280451872721250135049674996080\\\n        320168681356083141278245264226210123917664801600089798341302064628170490633552386673547779\\\n        629459935523009182796049294230583813227820931504488223487265238270059539959480194584320271\\\n        401199462771430931042427237249868862279511463299652377905825601176340222780250466358017499\\\n        741416375009007601534322467873289087513152923349548284378835281756900724593519775864992139\\\n        039387818930245534648672115790131320310749840113836557703902810561558294353376338259212654\\\n        838265769627968951684212229355604532096380116059632958960024414928444981500629201312258083\\\n        446620521575297892112313686034026420660241178550386738173521954010953393461990966187125587\\\n        718125674282926226065321012518997303111661390779405635207045155465695302589253072047875735\\\n        541944011691691678767595537946741242819139304959920057583483694774573805454015558487640404\\\n        535859219300316046467666996038468136636694003374312188054533884988463592734856844811898374\\\n        577428158833498998963602732425732084550424404713527826249706330307490742411732073565223963\\\n        686404410800377960582183762531134961001092468573068718242252318366410128318891216189677588\\\n        841342851356772778134355157035931623120190340100851047155652659645610493408050586282902312\\\n        696258659714033688324421694743826334335672681791801125207587881761361034712455675612360859\\\n        023482661311995290533755771074945729830072379748234276319624904115557395658571487947986977\\\n        465570120912985186087095833977836579051889754524761889915068546139270221796292798683221806\\\n        170984166803767657889062807640670057127761656799460594794514598052734454505982606942643854\\\n        322890865774500732180594677676286384058742147847865053389426050433475350531496638921638563\\\n        713375745513148683233932108132805489532224630272617987635137590340326882485148020249372161\\\n        773609869220103238450301511518943301559753461902227045456131560863243608441976279785070163\\\n        755421868422973548848724674575138934517098056869778082682725286541892742708446824315314585\\\n        480088344873987445700806575528775926977604430488083364942287735779460460769558661529385748\\\n        852682252957758937613488394167483839677176208328025254829966286941975764387906234209925303\\\n        105343374350280217169514000443480665166058346258755868888863500999634358442394794833611074\\\n        406705482267206173218460713668505317856225266437863273049930896046835345686939184157234552\\\n        435910696540492506154144109745916380855757038012531914898022815889387408369041630233587624\\\n        379744803912814830500998568922518239987612890498619335550019400644731698248247776705960218\\\n        254480206499759610947322741992463588851870628955608337954403439915156735017709196051710505\\\n        083405775288590048390605924011412637313677062121763070353505476403733725899127580428976318\\\n        786656692327567579486696619808413468040531237995199044308237233514292185847169193251466313\\\n        337701736493914236705228082340353788489955424146145726129566663741871985644542647610860883\\\n        067608861817091920254563020909125586664597276272937172751605144195770053768603521365748140\\\n        927148653396611928148485764505130002075807082154381557838434834321916239228184311647945570\\\n        758793176949767340612845025702364016980014903973666861008262830045540116386268474526183223\\\n        698156604061680619183408004467383660329762434636322229472684214058960582186255885846097656\\\n        436129475110718124031689568768272563514170926839865540359095663549309597630027180695029043\\\n        327867292166456898764494970505482964863913354311174356537382509448593779818332291776797071\\\n        438041061539067137953826198290623853282989238447628455690223880467926231068432852167735320\\\n        032794290530913801146093955270402943916580762538763738536386232107806642346013980602646153\\\n        868121943755882846278808170195366392926394030172305876658583452829545654239536722686882743\\\n        027906655883910164407061629204686010140836462596514881643657976656485499519475318056482479\\\n        333111055298476286194039252524687367530025124062809107214691597671475996132368459797049911\\\n        619796443505195878101414257288230920213536431558321242212454592260158641475934003489025459\\\n        208013416500329404390889980566434237892403146755726772285834759141871181259776656327461827\\\n        219251936375278711298144945000841474482637017386282934063906016010044211573921859186180696\\\n        026362353938185125483961769108820777995153693761823068436788758003851289448247957441987621\\\n        994272908901808330654811274315031789644250506197571028019467123513834298978864783159995239\\\n        012203585181607513130064205632471614325088133344429546414172122807319771545645125651700441\\\n        625734955286367563048662480032233975494630901524627528598931082620175660871709538595145351\\\n        602044294046613376721375565282255875894742202127176812567641733743144149684425366292656338\\\n        805639138494670086910979127749030036345492386945022269329382031819928242645093127495848915\\\n        313806313342990163426219474177812949233570601595520432797125007814511521978871170100401601\\\n        624527888498258274474618207575794799699209619868930786924849768444836611733585941692181398\\\n        736117247895444093699063656387398865536841367799047400349205653667371885438658635750652180\\\n        606052229659753988020820158000236798639256194633829741341608747358563296028712040953084057\\\n        850991646140871193985138011841475387481250923409067125073272439444196630021538828783650934\\\n        364508456955084547285221614282590049306570569622468823830359710292295169976661212747790835\\\n        962965504922238218040928264145392367427185004564730432158050206269536011418014261675769012\\\n        362720893163536214684536300857690792789969173553370849615604348638378458578174250447996657\\\n        095783236816185816885226969037228919430647556692377896339543943842744742255168806206977580\\\n        321963111352868785613439094626579768485222559183236813535617186350582745167087502506450657\\\n        968065060846153990637150561130933704310442577337875408529166308496422328819375711879150700\\\n        609536920244627499072459589380212206270929833213492757189730518173125338722536600728257454\\\n        325296444417938902767948778929046247677457105754464091349406964821833217783949417999005799\\\n        695527041099550220589432108403914300452089872583123538946789016662823809869917914999497934\\\n        726059458722011493978268115384425114636629420326723319499159753455481088491700262438186172\\\n        948999950926744822217270658314182650259070046369504108098912143094007415071968698384782468\\\n        954551187327385579555571089691621611063136890511886438900432161272852039986806354981437597\\\n        839056872011555358466701365448815878052799615386450861458580401408025763241187644128572307\\\n        402139985879238268455630966522794926570377029544068395645966758474690400246783773420627522\\\n        871481343577681691932786928359861814959262633103310854851250099456202483098885854559988016\\\n        960106733555315136531507495287942546177296194843112694877383953570799563510511561966787241\\\n        410142976171873392422123539943999965493130778563249546575888483262991585839422163964060371\\\n        924648244131012441584885369255627748696594733832864720939291497852874926080487804659456918\\\n        820139192324625507557145656485595794063197695112945347610582213307047675367040689224420963\\\n        816690762807724758368186690570460260852311298888381955983249872105765878693133389234275828\\\n        584918011668136754039162536694881956954045751679882068211342563195152210995247891826287857\\\n        515774032655434407603833843230124069685201193864992901269427003270234362102736993518930595\\\n        296381269542052099075744893551988447364442980840976016240668675951450824764059943017196309\\\n        459589898419366567674533696135372114756829602395005618989032948188641336690496745570287001\\\n        523215408114181382703703674380690928901408638201146747546569473701242381792456008281554261\\\n        059122937886184898845916831230376412195739588940703689292965261230670485215752659306911401\\\n        093995778548083604949657423781111045206689448180846905558558885753992097496775384366584520\\\n        148655473608597563806927097182649281335155115044512462366998916437344318154786717581313019\\\n        940716557727730643488760996416977830324224685514629505851846268565448039473896223156700739\\\n        818409498934838585099396743715708688457116960668213601943542922764012159270732526066671992\\\n        790481983171041316369126661639760010387421799472672133412870328435034527301342513031000700\\\n        669778788117127155667403739087796036331503998966439065297782968391930567174267233644561494\\\n        241487632660746917795753974663065042609663510872094579125173247299002486390480721076569862\\\n        021738370634423911774028995133267430135812892130023301257538734682038649182610897669733305\\\n        696371280187998173361965321966622582012086365510912334309993587798182223425414124264132798\\\n        281920390738319551834643243709758963785752694519475617058300179335869820293679723411463621\\\n        290683905806383488209312508454999962303238096625764366586477601703158349308456777071460280\\\n        432165582549780495340516374298450274762789306486133328908649652884610064537489515469469534\\\n        151497361551839630820967702576900317225353525942633768160163217121154986399025076208299073\\\n        146309518394644150607651941220360153371512489366286346991904561523048266364756002957038375\\\n        400277081281681861492618940789486667867448962678055304116292811482003835651309501648598512\\\n        959302901116479609192313013314730847757198442600213404511053673295975544848098574970138278\\\n        741678902759722497991988798374741515743167313043040331254782713440234320686374989973344502\\\n        508160690076121392910056173842375577952066303991189830098861877824894193454908433804760993\\\n        989164913917422285084525532397453089629864712409678998533857217962133832665532356904231800\\\n        915778320854520587740129622626234688922644659073594729480613003966219997369369854792679029\\\n        648100815254527306928697310532380588836862959090884593665948604062154919652544667460037757\\\n        597112533399331739713424104927119290700773958733507888183789672620264006040497538349397747\\\n        983453147007151268113699265712882923820044493775034201673758417963067692814185852202616483\\\n        246895628029989645552174956382218841001776405557840555095433878691531818844383372285895221\\\n        724211337991272070451076086869148835024462764023255284306916389828633808711378476906425864\\\n        710286127402472692638136155425261658282967567298144517269927021279914116707658997940292328\\\n        337344567806596842360697666717854446096091013316204239231782865826404857784660912774222704\\\n        584180963835022047147774560904968842027052997700586777908478719198168717704732001705809430\\\n        857351246493591185059708772629426763995363424999962223497654075351457945482668182885740010\\\n        749126168681605445045744468919267694217406453351276183345489563950565832852326661047793946\\\n        520569039604217006795359121765791689267345186014325461577285696400244416523690534687767535\\\n        832804295521681575043131146263602084659623413174726494684877878416984826214850162057908595\\\n        779103584992792905280336701027654162769994646412858728850362882844893722792278247400643143\\\n        434282352173798430728665020679325331012107022013892966354596826464954506292813894707278340\\\n        379296332490053016780455136018144212045651699247057564459945707347193783043252214749146831\\\n        540380953424162955660067124547419042296887835923999880788478906424441130936046964773356807\\\n        311033534770650202225301991202422613122257193553646750828206759581919324133787243712297217\\\n        017849025056841862366828272874709297038546791406630284023700632471280725248515125800700713\\\n        412228213153756073518957146037923036779602546187684085545570558749703874971358387897439253\\\n        112160023081043596306612533898808003058256228370692571159423303730855370142393232381083588\\\n        147601725303520058454537537754967603838005620243291237379676121859351198326747903353687324\\\n        605246633701559397771354709459051863223388311875968945384885268934894203646638634613499699\\\n        616416658805984769747442829361987741596666771794100482564250971161920031556829521124996080\\\n        650699981094438002745421878062527093084118871519817167260695201341410010074047292855031559\\\n        357659778398718890314831454621773782013996136959565221827898519457159837217484130471855710\\\n        052416168144225336212421629287788490393830961395497851254065566148124521061961155735758611\\\n        274350399510230463127899385928178618048465255589747361787384358858153975627799106908363324\\\n        242347046587763087106842740602784495180868280435501755471408201812983563918610737952125256\\\n        379756735814131276697482840391309146365659239624787973059891605570855513322066118991776901\\\n        611272249085921662320590725596536460896126315570229494385084134268982141534089055023884483\\\n        558555456574926893459240125263791540147998140789902309356386250141650467779607680426764328\\\n        704077846707166183537408903903758803918090029998227679075485874036441269193172070356253589\\\n        363224374731506862934568000562118515710253114456287074403886384039578732206963806635746596\\\n        059326707073560793467189356325361502328801383402997338040370688066679914504126257727315631\\\n        171455813307298781270443303184891904848821845452258563895726728387850031476895897679662100\\\n        905696392399440070988821133253450246184711096100359920488691122958338003444505113162817859\\\n        665594389869462396721573920391780706602659643971157282149684147541072257766759979568747984\\\n        909301463406775616904273678922708408619966931617911802966327798621251107857910142076844401\\\n        312806896430124576660696907509305478912697071996967428125912752729358028868104493613443372\\\n        878294966663300804331788727638745765788463364235720751267075178702106847718197120857272548\\\n        255246715552768892002450828542105956466692886337660315979392882814749634493915193739507153\\\n        311157675725731289325169022656231469155227822846758395406846975004888449526441104234022277\\\n        589475662899443953195651564958785703115649227361885752420338500840189657547075145024248721\\\n        091549347434943580530777764576957335917101519137549250710068820712691375428602890075534613\\\n        865360589441308100616656193440365982636874615327940877685402917416614944504190179124711919\\\n        542358174904303657867705163885264895003942664980830765506701938661077660673971374049881292\\\n        253428955689134045210567286987961631144652780963889887962209933022854068404306974967569866\\\n        323000445388765529483424210457781104964243329150090423847934114762256600063804660154967096\\\n        467828997676044886538065609561339788879630536391380544827171294250508560228413511464214042\\\n        030363105660820082261557696359276939438234363968155418154099271212124289328453905802823248\\\n        994106332628307703834797326209168484347886611543903883835208742254645346321694086506319383\\\n        059097020079340561957941530689602465703654619599513243593211295453933739142086513710683504\\\n        973573822782701844415216242194082667777347115300479917927202671536225656835204331834189695\\\n        318038065881590888177967953805254390621535322140616319033174729162490420092776800551770977\\\n        828014534078358897124639635798181176303067345404504801759445730686218618505404893717136723\\\n        779349000774398839649009793886037355249836625657663974766542445528533512230450758116449308\\\n        550288144569956886588228247895030617666306410364891028771284647097414497803740386869445653\\\n        720243018217449917819856129459504747019774954369942324981684687922532023245191990349128597\\\n        567797048876808918959003177413776568755658974409132052775994562016452374352522628521631846\\\n        947978423713269577550292789173277415842327790982936234228452391824076293974738769636561792\\\n        893192587169846051410301673547885473251631390343694951863773909282509717576410977563431278\\\n        406691735675267702221594104275815506868132734791617385337269976117203969864384340732306536\\\n        231375832331681784873525619903294159899382942310418714395561711689371942343204408435587180\\\n        553742536585413797331972764125029816580316202122718104272847261900465256637667302432512194\\\n        734523447365160888804024997137061421779196596787437091064922231725528798078850077477772876\\\n        293946754021331599151769726008269415684146624691481632893468428464230775832011738119056552\\\n        236684285072891707049098115609251809032438915160951433030013779459188984427310537016775158\\\n        365723578098610968389076593143379567553845061707016399741360833806664076231861816537433616\\\n        243986021567993471976186671037521351060855464568839349636364597566972713097701603485891702\\\n        586541998923843576774977437080683540845903081466672590724237916226404628867294821857919330\\\n        643216662219943799317883948695317703425905509769087106715905117164124939338762274904865962\\\n        674699587061626504825532304995584076918390345564383172800664999046664844648580597707200890\\\n        844857746389041544787184682341452332261735718229715111546718468281424300643040344515697758\\\n        204633550824884202751542248399760218151151357777668962872911274445723957112297991925016729\\\n        462225342722839265131175836024850673838936088265065990563776385094370742841972705660830890\\\n        297297422741449084876559831453472326728859372388373476785705146241242324512548704968738049\\\n        971544443842646667469291546535769261661132235177966214328536260399310486304341351141547651\\\n        416934446594729567867730040915393864017319782896452172235705714398288448248694443895212974\\\n        968559893517200575952335150732951248374046476579662699458809949631779017914913076252136652\\\n        846116692049335718529473107939611688457037654164756679002714729447200063251465963864837783\\\n        906927980079127224592386948591606857439987180337249684204348072130366664732360225894661443\\\n        143569260351297035748304896026792389618888728935732045307973111822179611183356139713558303\\\n        688024339399926063791661795300337498207271112338301283467295256152325586353774597483964482\\\n        016877487340279725861327640017279710368662694830085779354030962574224878865792037216430225\\\n        516272306465835145852946332700197684180947886367593026251810710813620380105448206158357195\\\n        369973751273143025230159870465352010633892622576141087753794180152675842957104967120118331\\\n        655075283813354466724700960293375661778760901262624371723024548541923723480724442791489542\\\n        163690863364013516263045102906066911657903817462636657473163033542688825919804853862693174\\\n        663238938554389279145786461542708854417977035723413687599937950228164695894948103830624799\\\n        786667253338722546375128758422674669302594957536871228274848886131931388873514407356766317\\\n        401867220515057888585549245048924183366091609640010744531160104990504491287041806844412544\\\n        507984435346865333728063460881607813551135087227425026604306852524642221752708157446459776\\\n        319295641860073957750899006713218414355688215060947419138749621257488851365443516370188110\\\n        654289386120880511272768413544256024540857253318833192941165520733738257664095433147569079\\\n        423997951155732765798104943452414275689163596796432828798584975740977129587568904438062612\\\n        581357888264793899608057432463863252224480772426602062602728021961552194676876007565047420\\\n        526115300874934428569625318965934776193364904572395702608859053110109486879495220264005880\\\n        321813605318580694688417422155105093493407669351956990401878453936283731955716746863590450\\\n        238311240577523860180868754806174708785749045756851587300735153625797107761835472085805828\\\n        389223948063739633743231617347361628785509495399349078889527370165667741943104623188678326\\\n        622934311407138655551770090263698195035069041931884593492857461773034693050603396084184179\\\n        962628448806727596828066440036188310513987588358660280923924552183316421172429704506987201\\\n        987083699211694131005915221912579531903921082627736027405690555472049625088940955468397843\\\n        210746327570899302958745653816624642566098229395573772570025323837622263802584739195766494\\\n        695503422170282054199031612573256788826373340371859704023257168813194282019547875808972645\\\n        509424839670486790198245314029957261426604849395447155319681360262886744793536407213984902\\\n        903380252320617223181202359431496751668386095030798373820269443628613458520776366872509910\\\n        183454084563551657720845802943695534683957392697785350474034595797326411454714706388211448\\\n        385404834852561948235574150704110570893767795388079501517823781886415061782004393291565530\\\n        269795226675173501599652869172546872105343195339662543737901254215443295566663265947224357\\\n        871824528601265091226382382050554110936555447759110652847062964958539125914650365257530532\\\n        138777168374246530408911927011587591439346234181803457181521400026235370311649283528956614\\\n        298274264893212070075556718102195760052672784254645187540833059577546935083090696208781427\\\n        846652631554670429469825922568533777514950420793343184508395904023923424087421694819592780\\\n        612268053830738210650610435929234766944516955014489026603365564914807337448554319643251022\\\n        479484905359236345673654367071469143838899595959426449918630460030431322823864453135549797\\\n        416355050063003781289654297527484982539900453927694209501690309285483277796626526594454712\\\n        036258823822784399226840995149184544793606599122509625386371857898644915841980814603497837\\\n        729615764618847531914260601780770189189484353677211642923805941490251996899716338994400175\\\n        233602019094613309202668997744091469653207741233629373581062255743936719763367545020534950\\\n        765621552834511813371082980498151391144237239755200151191456769235348317826038336167385797\\\n        031672452637927476355335086862119697285598774684705228347490815352052565757296306576250357\\\n        936395701028870980256250782647258536004237337661408485515940996526687343262228076059117550\\\n        408860745561914215025549603121045558768165064076200075795961374799119931100655318800557346\\\n        413471593725169941418674594088778177459810549712043613410506674207275376793425380623117927\\\n        984589617666769956505271130258959576508500305644279853498406100394259884038786874590726963\\\n        006642170344873725831155096312021422093311879167136871732239748432267620591525817114049261\\\n        488390158184917582857589589699685612163700638029571794432751879124074551065877924957621440\\\n        531674456196877752144197920460499901786657974628744548830217402981605659514870686208991905\\\n        512131767873440632087463348232584368384008030638083621549010773287853725924655090968294261\\\n        670023351323829466745282937579381889320376544861618873489707472923342216150982369553361443\\\n        930956082218278328523832530130203337042828858333223723523669018869522753172988055817742214\\\n        284162430702233819888170595536118573235793159780671094775199002519106299695446357234079559\\\n        601502416214873037162772246134983831080942247375496888476654896040005083143988907482833714\\\n        717603501855528829353633367327505464057860752048298337968613707670729763212486992825733026\\\n        666051005836892182772206217684472077757067539839010057369801777261658247365292540839569746\\\n        506307783768996730185633681227557696018465513246586637715419744563290930473741975842617090\\\n        286099674931686370464276133986368285973696655890773005007335413732471703986115080534910536\\\n        699070902581443916885422071946429485151939120886821621853777443970992724803208936831454587\\\n        565381810595864112582262491404805012210279864665329115520589756264585130579876159858113978\\\n        112329926401344644196895629236586425685920614980786127697688680357288256878189282684237913\\\n        541101352080410754526920955529550771715297388823965970208974375389201979627076207630931129\\\n        543140179806865120059764894575864422017220986643749093748810867818056970889367355435601742\\\n        866653208039916117656007531059277830321501335401045020007094747705913481815305714364064963\\\n        057682708145345312574712212863986599753141842940895516891639588623459446691887981199865201\\\n        593093566513520104731766097528047765652412326859495391365808094287320308283428602258802351\\\n        633705741977956694436281069981854962963856772601895325313754094825388940884639180683333884\\\n        441109157237336243737565254329827974375159474842112806699787650992546796618541308129165413\\\n        271375953278258675676674244473849092423095308913267354949124510371813485861790877206200413\\\n        226824648409900781362062472005124548181695703697310643914309260125710593789788923715126177\\\n        289132695023385841351970989267628857306394801350985999898399426906247557055856089779658273\\\n        707173624979258954454324368272854446962586719533610547279056834453974191304935897796618293\\\n        321278782044656146567639487546452415108507143878165871000810068514134580115426453379714235\\\n        316898815550642151572301929739624377930987662427099426626105530638644339846892096128228613\\\n        098737724120090983913077768759758862685010016040208196779615503192572960704793664924140139\\\n        257654461839378672053700218375622447291556425648981008647774051591247106929964842818518416\\\n        162612190797151585971072730314235901242324560755346917598764064617498867689314407260928051\\\n        326812544458068186846812086210388801798881390741648051931189746392667340634460964049653701\\\n        208399831697900452845045889794997472536439547462088263971329455274460800593042705713848482\\\n        363547406569078821584947508116040087989031826773128785894073243652068403140931066507504105\\\n        588376287433279621430821416996497697449900609334943771781045862160195927177726337990255228\\\n        324327891674402575970146028851323679094116356993768401870503739324282891662310716304823097\\\n        429815356023255837556163415762244634375018248560156622966369898374702776229558378011965086\\\n        032359750932562339247113011679914737657416772986855865429428862497835462114403458638676101\\\n        109828104346278202252478553979573106377491580033399368757422870144022182833833253059879114\\\n        538034190848133878361077082782290997510048349245864480736003473411658955462946538556418331\\\n        935454799554563230493513447149553799255083761596463667781843290161230344348857568597123721\\\n        336404399838574678633560129451511597585250486252455634464101442202911730348204516730911548\\\n        753734545902103343647891032742898429808308582457686076378477641101393087618362442844432576\\\n        339581414568508702317578866147888026371989829532570662473561515448334267520416091775868068\\\n        962183238628280476834804440198141985372010791772237709498858585212776990373505203732467022\\\n        404812404374834605667659059721812238920131321401785510144575808351885023451381412707254137\\\n        053358856301900983404716982298796610388715352712244981177037665662024625177461040505220508\\\n        716966020500899269994366935909967502905630683624316591812817780541588953775094701329322633\\\n        987059893952591036033979376806510331242093367210741658515826975516889888412432479920921988\\\n        182405104145050242042789002531833988891920489788913031447982335804725969828327923154815275\\\n        326111635998595288797918114593032709856674337964120593520386415579805549080570828091329737\\\n        294338185030543331823257101883411241980445147824587195070601385352110539863460031887346357\\\n        960180544976420130111372627241359061153560267022825065200833693382574461047691066653528169\\\n        561815030006571884742503352995836034227257624333861911896686610114111459621718388411208761\\\n        457799549706583735550074054299148730796488909055588688134486192306307085818887014707844347\\\n        631754558600944402631681687808894815744648082685589980388529333503195745580377759003477260\\\n        993593768595773274465243441801482958098763626289096787450016718825295442571640696099247294\\\n        331842893915270547216131364030214758507006606712305291201294306750318563750036004197126559\\\n        256729063281300294834804851834465825554252852246843632389886995446135838317908927000002835\\\n        716072696646906085060336625414943710459788669233218743215767943644805648192355433840545886\\\n        905054693081464376693770151205718531419900676997921907305987275597783467222378924821551231\\\n        394178398026410349186890611395811590003884770946548924474155815915298848193018151197975499\\\n        065092461374162199809718208116325812372495209471039555481751892262682517282290489715350185\\\n        716281910444089887976008572314092262644459173613090025518152142714079112173844988187766243\\\n        307947310992353241032535742121801616818851954183256552502862570466105253871211133240789079\\\n        258924830655251247952073491087624063209035708000942732522888056901671307889055727466332058\\\n        167926239022475102195214397611488963702579989782853420731007770092115726106978194154807661\\\n        786690692075738107811261877889018492875443036992624187517009626058806647635225926537433544\\\n        467110523580716007287214451245117497127192040369898540635587590427652826451452399641212615\\\n        917798755309521087434819097303021023416913383133495299225605780848139458195669811398676084\\\n        587234791373272619635792031919282252987959628572816162030623110116868280873746569721781586\\\n        304685033730098438052496218555851414503348089966472386585037178262930935232745801431646888\\\n        431530271732006721736261189664523678552638520333755204716789819934611547854532953439689911\\\n        928755449805360703021701405640053927037598234112674343581684433911455975675887839148370542\\\n        378086720365130535520991945983668989242247526772285617421456721408560524968547738574650752\\\n        004832100867983043810481257933299647776030783731994758992957944308993855513346573307205390\\\n        801281157759301270346001252577209241180698664218169769692489497920004473548004111594299828\\\n        313161967823364081027798662867966433529066420837792045758007909127555245736308097315790188\\\n        491474233731502342287491978453557123202284498679858808168140608221989471177438010087130928\\\n        084495878803571671822369870491915504416525326855707918672673953033836714840840542694649466\\\n        158836604321963494156181864351095700387049092563775647122309709271224953126649905740499486\\\n        165950471767644534900855535445229709222510445033995694364814968984284034085828773163564231\\\n        063657726664341734695953088282782573905351054776128376704778563505288103430868031145165326\\\n        193030629295367569790589623266008983034499184388186507950085845737751561534855880368429962\\\n        630036836405998470478105292223054460471940608828533978319079687889638151813534728864600393\\\n        545478284214071105124106084138982704557114346795416104583257059431274282250403940065901629\\\n        540785136664175246846540170258066122548879362769943820330938434076519694514123272875645824\\\n        635828276680947774601411170782839338375294190600344879749343139970466599673918004573872479\\\n        925831647389194767902341479764021290718962507285042597964888348923917848404825240937979667\\\n        980836050073831738368260726430759340626212713455490120419656036273845405545129204430220022\\\n        990678693176415485417690436645155613478260667768864621580604267083865243957851643141266677\\\n        741359883208268535086322376092909491066499317408818636531018488604214854767121100642938547\\\n        324484406512621870749517705818560331905346559923513572349005354779014435312459874657099064\\\n        340751199568748126335707601331168774490749288063077890276026203556716029610309606088263940\\\n        909485789874705787690366826617792804542930019939057123091097865498259573359069084907843441\\\n        877175873435360885074566607415026696892705565056495876940808934518471510793917039199491138\\\n        947743668940843572231101858976247075770934571058200548874359869758344481963405859074665640\\\n        428003573923058925944689785861328470701298666106556158692837831142278212410566128095359043\\\n        659826109809620942729243870546308760861144912010946330503520727309439495463461616444102871\\\n        557375264536432945328576813905437728492208769079170524090515285716219878045038666475394453\\\n        341637287364898495947313856797961564446729702773068906330555215171871130166445888195182606\\\n        017430302703685149106627729946142854810860737992447645649253083096547614978966472549202504\\\n        592956824436820638541447727835290495387604465580956702187954337175157448001418048656678201\\\n        591852892400128833445436490536050189280782574599625378576109974007697944127619085873291301\\\n        889033338966247961142875681603343316903848933557584865212235272024810632108350879269418296\\\n        436018730829815030628007763677830761235880752112161383125091563805475291591434375260912680\\\n        690367661798715514732686383228310945101830909430873473662232805513934706672007643740145914\\\n        868595593141385236442100164370434082554300006755432174155522259280318632316861689724409419\\\n        167621946548621432401930680963162873909467878518066617016058818469402032591196762211921499\\\n        306463938676198653919983666043978736316584069394729193347275667505425615358592538080889621\\\n        366882570182068380095171096794990659040402043140913119289709207068284231145914452147585194\\\n        007521801130391072125893718970690278834188480453689942588383296615422147540517641197415323\\\n        085208097487751724816022051003821383386021783745670551311279064002007387088514793945887025\\\n        396749578994621314013405302608897484232246641773142426848776822644449338962813446062632072\\\n        735024053757206484749609056203819614767190105843753298783853878762795947830839686932657178\\\n        506521566231578663752567259673444300354779093217363002779801554228509911521850943476332449\\\n        268069669516864200534676962440933180748413823322207330475494362268140163938410200092920283\\\n        071685278445079416361979891042095361187880017970206382904109142936550608443766765370695959\\\n        068893703964695020125366599114057622401456645903390016626619328652945514269975437046759433\\\n        379696488531771670479230698192576115560841746570936315812675128010679410281542567792028170\\\n        168050296912452789782035430512499303004145468104368742274240112729972069008518574308050085\\\n        153225961826715080816379792107608757601064801457130359277487165388170582954444172161304955\\\n        478705536963855356189145837642976169247591215216901873570916260858772908378361763308562945\\\n        332650838963693786042517139511036062147739023906395183252153667412047712003573929364738648\\\n        779744545829079353290750567369602218478252215847797408011361565195584214338987776445758154\\\n        591488289780050843445228233805815101299450560274750122841743039406842727247966444186707195\\\n        941783961357815709925952733612122438291438967228467764016961228112269633261407568310666432\\\n        766922850475229250356690648859748807738983084774391621127383350784220037273782671799240067\\\n        737611611478581993828424354359778112836832031256400670067020430223614081165688397029851328\\\n        942125045018299094556399008489721913378634176486669821830010301772805683946232519197143678\\\n        489678687135469543954819879280492518573588967486784066297586204818618618509913618145263091\\\n        665584828960294737647800144499305050473764280666130723812007942016466152749355348000455804\\\n        269061498831381669206820924735515168998217282608862084658425368998475533570904732074838814\\\n        780731306094347613300660939849150615244811319997929470326137478694000509292875419022468593\\\n        406878221260600180795180579171027468088150087915655293288046287815116160123972507016998210\\\n        017815854964425520068505535320899452365581195149191487754575203987502103198085589195980708\\\n        037702568529873017753192481304684773485403815771798653697784980909359139886303708209263165\\\n        998754246595232254282729522396389653429627301118728595590925990381338663916600016296884828\\\n        754611210925297781599543692542646097177788538974174285598804163709557653888251406513635373\\\n        009169798521624208179815073199707945525946554683710741896587068870513981287478131751903960\\\n        298900245465780950481552517811100047546329972937563017003297401502897047826767895862915363\\\n        832771033034932465207012335934079259093526532952728651297608129757173867178874645368984452\\\n        607486835037304376056912225396132336439075317156766578493421021924361881659287056346445222\\\n        852057092764349471926534924573143980014389555974410964485292684232346690969221513705163015\\\n        339871227906433118579963757665385790551761632520479993952776803099430120194356422468196746\\\n        385825769444995773531037514812852790371778385671362139422400047022583721109482759499335881\\\n        362138949504409270741992839434219238664672747975338936991888834426399182442390327963312718\\\n        424619197493749465190837126865997530014015197015900239342583868542322437254759735340294752\\\n        725834061001497831194024784621999518685852543701893528603394590601475481597909629872496523\\\n        616549385596187131512682295310096699229116591360367775318076386600159986799868575036356534\\\n        142696267135760014113814128012940306480433328223573345919675864144057624246632971124533085\\\n        270582255368449571744186478000757030410830644973628019986893897581999020443001201406664324\\\n        779568481871171998025174150570111393955372543179179598617700301401194367469282788154611821\\\n        863281044729280366170180583257655839955935786205023253818964762240549470600585501507408062\\\n        415788071801684715579696507674806423473386069053542302843593397529426378789526810508202007\\\n        047091990345184827863396004448901307175685948910362334860387350074665125046297414092435668\\\n        895810977138425044289392786360531805360639807118222177037766732121220447443201998875297677\\\n        196699576398277191069866544326276565683637121982816966597466957372659583985691391167476887\\\n        284717237176415444063373082312310954153455308760650302920450606071763207728040323320817609\\\n        028024117378826538453650459110962175821612954091206159745935826005651407473900199415067821\\\n        280766551374247443451370137769870642255072569805633961336339120055919519967760728122519148\\\n        958088542536734467558977624202202568803067983034475370101047417803015390387804106229275233\\\n        707823984661637263263762324321240512411253697432320039373185931268728204209843262792852693\\\n        500877603092605458290589932538752612709809288173569196768538127311421742836481671159259255\\\n        124607785487739889436775787989727651840617317952612782916530356713404806634302423431056492\\\n        766139762324630184011978804664952608743514310528251011936652112444381809986147513278670751\\\n        056129409595491963199434026843230703535074804145664902572907635518468766694990898730925971\\\n        290305609441554661943327398451689727709418681502146607239231458775984338564039991397783099\\\n        171672312922711984403823855863903219469304842730767309348152344925271454797960992437269350\\\n        367332623254362919789008280393737507749516238976092126895102083893632736582531981149622882\\\n        241041126030470458929056413936552728587948574502225346792173932786976138068161103386471175\\\n        526598488097433073833221691489899385011947570698933456722019241481877060528558973405478235\\\n        776484136635374221611726089729766634937245970166065208831538244539306626971881116174788610\\\n        543527596877831540869107064081438778197988938770632441217502528158682424690862894901336804\\\n        546296051240349367126753829832694428927197008309172138977131146182152897553864202148177656\\\n        023280809026352500361373917217811229210578097667879223343840904831083386051157295586356266\\\n        760688785544463343069638825411269590140359451735362854906127509521973397063312141873797314\\\n        335334708770768158113611846141759720097748266062295057329018205132018231364708559738934572\\\n        812392786132767638004440506400279957454700944784904527599407008395041185110143618674815403\\\n        587592830093859205310957510835013418258812812896197608871700975462913990928546280033562025\\\n        876167842644135542589496411196950824437033867220082813251349349590127635712509192172685405\\\n        899024478720617392755302407068770484107343519789005569731380939542164429147992769948652534\\\n        822174163212622610631181885930358957720037290747429710708852112157192620454118924982084286\\\n        948090913619217700624093052772573826340010033551806226933151444540495750624536615068514014\\\n        560514307453668674052095135721615808357188860290872852538721768937044304577893035001841319\\\n        934152879742718435234286402277627722900179121061868901510608491858784747600724977823813757\\\n        637046602897572979185749413238571205427816350819033595965925157951578747255672296838451110\\\n        393113521251295121019554558480519503555164488047153542759637865619280669165508015563023760\\\n        789014132149241856428712864545370176708189606950967440115910510517051993272578616273262874\\\n        985624154623030113835330625434427340348183671926262409675157470210851717248482156459311588\\\n        742128353368199674060045055660561825791459631642825426029565741415067523556271617640853545\\\n        302354202494047329449144443447427406052600421581380921135906709334730302967074532822162665\\\n        572081420517775753387265202339735811725286235985093680753119015072019323615911178012611573\\\n        380366967209004137111212947956496681724924135944851169981399525120691691452773409129510598\\\n        782819411375179189868502259700195019893750373308212434858079033445643660607843831426690434\\\n        868973894108147407820091665594515511868102970218056938946531181089798464379320702368676595\\\n        891018946633583807095926638503303245228465699641420668602491398725805400019782554347603566\\\n        946542263680863485011443452802091722174199481098709980552092550781429484487788799010348747\\\n        274638942052594112798114003095650397292565316834364199188537579638966215853674154969713253\\\n        967483753637686518047921358077234504823818220479923430381970834889326786364581354422587137\\\n        539538716523929617661587915491371020154089262907900729992762664604558765718533453985990056\\\n        572907450257318017571352754551833345224031433074840577838196336280016254266960895566922163\\\n        502762248967909564153440257965161228416739460998710405019331867971495727841759834273347133\\\n        677797331638461297693218094016913934436190186755012593716376958315660612730165939638566601\\\n        153460486704024347835074808601883679628410461627113744828185767894294507774981358998676995\\\n        799101293621575210704449517813759419955124261812447202929403883269918827177153271358892570\\\n        408453014122421772098058481945138429625097843959219456481828809472139785802465641020221591\\\n        476517700259867528032261855972287026638567352903733708947631290925972292138633845464000151\\\n        248226219390003402699181723191771748641150596973616578596214623528700832046176249530196356\\\n        593669419619347704671306721871987131015636610013104812506168095781706649039072543612248822\\\n        460956148448778720012242592891693859569061126763287313103889342971642374525217215726786605\\\n        668603824717552044232758071677986430634347780817537527017222304852507552660183231677329336\\\n        702174006366112504123602885116597474303295655914006281907198553412109052599531852439299624\\\n        330289586875019683417577558168935722338025157222869108336492533548080625262327938383155962\\\n        919458859634308679595815235165797525779953190307068776572195044944268417578241428760904674\\\n        802959233294415983361524887934958230899744651738036457419907942648615727223041907527299887\\\n        934211132706635671485661522733837752170592802341069776804170971829805839817383972253854330\\\n        800389100023968737574548471569716331117585666239476962658851560625187478622800151840247553\\\n        592360947458354371685020698942447336616278238710022788469330436375847994460567471399409440\\\n        546974115206381603864407982181467320231849245249227861304163915601985844778106498288613470\\\n        942180962992255826864796594327707373615889697723132482443605126747793605507221078929355031\\\n        276695618827871222027065754393582105287828321509719096227697606943930621854449409898151024\\\n        870761600931974753520777027171735667258285124267991004552577657454611489959295167192148312\\\n        725536665562927160062937188886615280609698706045106460457124135876618056288645690532485780\\\n        607704003303137667730179471368157877563913902138824772017233187776136196562254103712180493\\\n        364469205419288963680169237579509339682192937256531953272982081371282856310126475304463433\\\n        399253321792310742169334901312556057870962801361056666082053853399434540865735379435796001\\\n        818191709878625044540270857972667247686960433776244304308078030870582732059727243540499889\\\n        691005207256295040678412147737238816684678887348944511386525919860359617632750900525290072\\\n        875217521180245635910668415709984177840381913605389319683207071623062412575993983130289922\\\n        576054379816378775482669155322523051302721698715512524212398406243721216780264792733898399\\\n        787345368625471550065629905182747996626601567920571904761905091923709264472333242698738639\\\n        282526663396855448468540846545904897924598878075380051053754638030637058013171191659381306\\\n        191289510893667163260039461265707648511015932920128993279722840708042077613022042884575148\\\n        255530882300832197288810800976885324483248437440011516001730590496795211649773184045207807\\\n        990708873384248328934309655116043474397822909183434127486197514809062403187556625468342476\\\n        402407525071179978978360737094749105926673035867565595325856308029673736449787694552163235\\\n        915400705923285098810671941571419837195370843952023186476681821613888898186946022114330806\\\n        938626676390608143912678186346361570383729840430014338693285030038750833384531120635919428\\\n        165245051265206206876021238402530018522110917313359013205235823844387539744648513837382444\\\n        389316328788065812317326433873048619344779088430266456565556215839667975523786707975044615\\\n        537219979634886773882992152230105126761023265878699559929374100638919739565647978516318835\\\n        687586044821205009134490968549752232972454095856700683248818097510870282481747791625736136\\\n        072402698803570334989408768199507497597374216501585823420314933553547245648053040952140198\\\n        012508027843727374774215266984965682397355181162056663702958949786834761811360699539872907\\\n        331091096030507771901645933677886815768123569280107907887161526245609739979241098722246084\\\n        847185548005690738089187465650481608210018659127707603802276278195923878809428098017902567\\\n        979256744724302494019194246494125075535787738088540429752956939565753030698190737748203363\\\n        650783121333601660077772316570430399956953967381635676933262905051162674970164777970322263\\\n        525260017680570213483916149745604472878727893904578713476709102248941762694321148597282710\\\n        988772224517347330979398715275347020169213557305677034131039490380330263545980493560205778\\\n        279977896376659499248713501670862636757290440881872617857949614205740349887794904949543422\\\n        458188384934616817633398790348241520206668438771995891825935336742718111093649514305732772\\\n        836876643710883471088676431597819555314338447003956187617149646276483013076880879209627646\\\n        015692476735098683529240827525607214619864825288055654530034882725347123721625192225899009\\\n        265707265890139680070785557444953292123836425885998033512510415879057663289907499693876612\\\n        260577764097116403499218860812445792504860297464790960506572702846048414569099542502425972\\\n        842140823474690426570793723032665400434153465688842855587752623217892920368881757644690682\\\n        489037601028209510864234960278349727581926308344427536264962667101925201617177279347619787\\\n        336336825470304294710238115758271668832049611388613784347376245135571990146623835104015625\\\n        834092793882196760491906885231706766301389127232569076916091279569505373344456360137192126\\\n        710122758478306935263858123393224722048316872175010296185907444771041164093064361860365328\\\n        564284551281651082728737926825385320208771474922046959575274424117640988893769077776748478\\\n        308028187453739633053864077088029550016767884078801867952916688668856367481623232706605569\\\n        112617857803748689321796157216663313855143376205170276237021065560904779920570334835624165\\\n        284511349981279374326779564600354361596523072438832455446704528879224970818757103808093648\\\n        986524706073751165854726307845694270835682654945739565397118862194734608110444349987460532\\\n        644321118641415621872359616089875697652229001380020125847021029812274849650674845280316451\\\n        880462817610222279177543685869793521848572356496517176665562605706926061758925669842258515\\\n        743094847021450759947347701333402669639937164220296696184847995022825412979200119910397551\\\n        479366569334274670882328889863264554347903255722479771028057992779989756722369566051197123\\\n        685510564538515813115741025733669984309416022583062821976224637948613455040834769247282528\\\n        425623263688143427024184054117970257155577769139555464675175249569373898856178021942020992\\\n        506395410738382683836972787336231972286949933622248956116528410118739138686637293111586672\\\n        705516047844886018782224292339768384771626701732524984622710459992570300864445099892174118\\\n        423395046835360457597396576100370501769277181152854039547624089687609636268417387795002327\\\n        437527434309352282886069661588350321241650807500614700229539848178399251448180970949359992\\\n        587744065887273906820327365703163762695913654608268900422537277666035470496282994032133733\\\n        668724154846657676157601729491753945120919460201973870474269152979868283744467074308600332\\\n        561689963614550212719973981812577576319582715132647576948012811491220989478249015448505207\\\n        910327340262774778943768985974773333894552562005597413757555065165686552732304985031608661\\\n        661606628621948056467880981607314938906625290443715833001595607828464341539360847042390201\\\n        120077459113913955641760634141458006203571708072387094163455852942022790477501379736236654\\\n        958512710348096936061209151200850089927346560586252734765100457102887503736791224458015408\\\n        373495320050119066249700974413987449829291392568239585528561802710515440773419429638449621\\\n        939796061251827654649265996460258893982054154188864949524579137294246862944099703080232709\\\n        693415673940624805583938989177675472432770605971250113111669876450774695398257801548536628\\\n        932749695429092993318684341911440396012415619401451355888916988416484082901724794278225141\\\n        395979791510641405142073119347346536994793511927710044768916321724780497125188379776608197\\\n        715936748087500859108032536785372407363580234362075405148436512708641843570466390603110139\\\n        343266949695804473056297292151901705579317341343591020458603837042475621453888787975265335\\\n        051633148881573635407930863965906284234411137834112681309887136586999879918179675116486993\\\n        877647272904374934755634979422392670133496689342231037879608360110756388004738425326545063\\\n        252869317218358270777615682465717442943410217774812016926185652663723041774580181971780700\\\n        038373522008267710930672361594955322132743852564395223743217671094864411584101877284475615\\\n        917443022323892194833324576912928405943278056845443097829633357842911031974932575169542868\\\n        401041257439883823146093059991300589995814755709030464051782992937638379561404181632699488\\\n        039589384866897530846864436964404058801710140491406471815917814715550267908001056916511510\\\n        584749404032142052387710486147909965043111180907143099720409680020979408616308066859903656\\\n        201091674720690095565773479558194099827819799845041885883488711900053122956369030904413954\\\n        630079714596109012446769075439874496271885859970034920427414390009750395878800588422358633\\\n        469370349309505469675004017881025031481282656197047925474496993670790177006374493973269993\\\n        113484438003515249717357425708817910436214623169035072168905804738854295508809414259200077\\\n        927966098184370380873294955081298359639656503219402906988285302253014030142144558616857976\\\n        338975370693276796655276410529848062720942628017821138119652460068258880033245690514732511\\\n        615488596136335510222527118436475086752061717592162365406333100110888338461912946824899922\\\n        050992029139426027930852743467203797104925753378454572339747642402179312184962073085406492\\\n        798608746632894993857197184372514618075049230799855814257352795543975351434179637787267208\\\n        454047637830144282959621319250521733875502855144385024240006864513491561098405501580985045\\\n        891232472631902745751372951004456111883078442449202031906217287583410421115675602772968496\\\n        675113942603253130168601025805258365186770511307816252902612258749380869366845910765664416\\\n        271156659526390168508529240740834288484486960690939680207492802435110801098128896548682817\\\n        461648308534996971920495830053143108187356510276602903930215785733440813633962321056094766\\\n        975053520498409820668727070505147425359506631740058308470448588333548378648900511657699595\\\n        311911502000406475380234742960875772084798989936651761175441019313758408937290104800823834\\\n        175983123129597255656470402962000880241860521333557562633469009856252532749975006876074067\\\n        384929645974512636030352534376059530350039871467767666404587467900325080321051510028691923\\\n        221683162768298149013165286104654372770886785938729155230110406307635127341589173802739103\\\n        947538918313439304209410589875553506892176152822474874005061122360072240108048641364874673\\\n        655595145829185102682923251967085392458130977388694402894657761397388956846398813761018172\\\n        180714891992188211122735791013934370615012216696471108600506150493590716094372161559948168\\\n        535382577491021628689401862292741550928952289951073255206908985986939737095057346325254178\\\n        965184612627562339959129181332243938359659578942518056129897240426595050419448815418332332\\\n        480632485406637539269121299052683910730297923849834179303381703532978313174281584630288361\\\n        711222565011634587924563091645814196314515962740019966288877147436301581283389783127447394\\\n        154801605472291396568593303474074506388233928712121472058248635838448535087127898027353701\\\n        417937922092329753109760384920322664359918295157511736267912459199956493234106994497353763\\\n        671799168715488939281588371885994099909181792017117164847437536111246316295056569117092492\\\n        260025831664199826180001413621430722276372056490721097889773437552126467176785655253000800\\\n        537219797897968218835110494143246245081504722384815897001820930320491506617563200938082866\\\n        167245161359360068547635533917128077771289167568590745791587965029048440994062521495612462\\\n        096116151116268829934322077495318952546735886113830122410716964210984996937312672699755014\\\n        074497951470500877589401422810124985577220444951685332204788831280482420777934380893998097\\\n        521560400886792253634822640823527114859632141090564824456294520839828966342692984223444678\\\n        858711546175596196680370568728443321698865555295196996751205147626130230827507121273617256\\\n        308147095112414646685535181467744244043252735359629877190370416548165892267217467713163206\\\n        526244479332436777569201537264655454818762180433994110003337649192132927573630961869690405\\\n        571222513445334992244170849659152189849346205433783301730164790123541159565851715100217758\\\n        664917552758337727468772029198290924745886441462251839886291179141094247667792843277082068\\\n        083047764739968743148798639932420859231580467485640144836421786941484864103816127587924431\\\n        738980120963447232658818113917619467719388984750935024070533067899259982269847077127180892\\\n        411868575256251889363784060768519157853446641909461586502537608202369161484097149586871199\\\n        923221611242095803508859236983898814136966264223994509713206578705402514486928616260371405\\\n        333615836228600224983712711034687898008653861067005455282920029349435031427129489108630450\\\n        296600840652736889861088009872545971683195268926877019610982340043762720123437375867369777\\\n        296012678981972423709493644344701817185397225318740847848308407437400569706181878048289315\\\n        818904560573850711384289333427803517864340982919878292284370476038293984973564234770986494\\\n        948056523766440056108698723655832895123417618905077229842527928806521148027755084699553189\\\n        411327646090216753912304639839273412459505986886404750677217769162228468253058391457889582\\\n        872046257524751844147441917887679887070213026381418992873697191757741747956994668253853562\\\n        544073149146395368063543418490898742909094138048122361512563706561264540066793939345562836\\\n        435386951112649957814692879273860081768134806461542721438095047544158362970157794955404869\\\n        446499307971982797065957685399744614876517593501919586167926264388791368003295612564477512\\\n        964173361747752189697388172035729519336808227802651898960534649859080844239280497025708190\\\n        693869895935996406004876620723028915150280379188950657014027082737209628734470334932822072\\\n        175376288006082838369274638934318779872218521034579824120635172686447249649569881783995414\\\n        744695593445443713223014469047985399098888456142170824112315004258709483369887915247807473\\\n        505604202817933115979239515466993048193206556091052185962606180808125907161000894953877778\\\n        035775177287221788425373400471736150430088861485396491253820837774563092755148004884372967\\\n        273649252875013772771030791055745137002899244883894803341845573320148697258398009335142010\\\n        087448358924302964326019789229620111228826703567496678404841534776922483933367393278911378\\\n        309667421709693192642283110830739630913679854135905949916415143662754292741090052647347608\\\n        201059681038336569666573449274451783494304457767890173015456253908604730632510842259023356\\\n        658407764954387964758522777791610439713287726199456828790876077940108414432857566307232743\\\n        337581806849837778468943191230067395144562552139400551410891096169961062965936563539196026\\\n        237789218355354079407014179222598125867974157190600773150572288229254385430747452113400285\\\n        699187161249072953865553929408903133520243715907554942267642963584627475908124666427486727\\\n        588987667454018135427297543949039057931592556141423897130012008243035089779001153328843688\\\n        762745641624934148108184941475706499851755074916467071690217220928823325632583001849656961\\\n        917099197168993762944690344581014059514912389267159809396419394294134216486712146857516268\\\n        625535777396335232808482429988099163043911474014996793972117414701725411973424270051120536\\\n        441198390588045690215338089467224945981803631244151663964585299609622554401506624039425457\\\n        945659726790363637066324617176323381740271752581741663652867076798302809050821583587789548\\\n        991811235254909748471260197012887107308762094182293785627548978772679990628927858817496423\\\n        222409215464087085808728574079811240516346817063344468170135402751561791508752740082786649\\\n        839630012750256688007415322849083178011669514008561125900405204671688440200076945521381174\\\n        599428229423352377776596777577555039049391183167294523066542674049321862070611049037039918\\\n        755851821118547658493032015393525386391653975616416216319322958075681034539154408428191510\\\n        169272878151433791821283301823111908508206569072869250272488086300534205609803799627032025\\\n        054421359719831919644821653307223880477851159114837210554375744457510145341245317421896311\\\n        389831140258311130032092620338697093106253478711438833702729035134011972583248668586729072\\\n        113407512307046528661089184945504949058587557568481166494619606527841024426355179503286663\\\n        749072771677006591622699506255081132395248018019685144856363531467099318114185350439292933\\\n        508324955741153626635458355933579147518701994322755542432208280525174069506371887033657471\\\n        846656229374824622400150473849348019756393773164148126067327391365932882548069381828122714\\\n        541749519688503269950554276422595064306576362784011975034498534974223623534869519045652565\\\n        214451530044187928297600297274728465121973808078883900999809734900532781946631827156869661\\\n        013019012110875434375847026657590848007603600198122388982771494573093423110332015803379575\\\n        632892439345888184295085425401819991105165031894129552096782869574576824694450359251419866\\\n        437488377000924555739926544229228352507141499494541816681323602955740627858190833307168545\\\n        942203519036151249018489935218341735516247607973559921110517589703512115298037436737549640\\\n        154275222891988888181392142846784357480633100016283824422775580170323209322164846591231092\\\n        007661872796572227095899808930052789965767067033000464659464961654305279418534802162523510\\\n        069495327409873141673205524261091530229668328408705197327487088911964156914299550914633066\\\n        657725586440842630571090414360297136949319355926621514635825842334103963963262596794175009\\\n        513908142817170522027165227137614782174044388259125407916053996881458733782205621391794990\\\n        610892679335155374679217612285445687868920757517878364981246253337133556934108159836534044\\\n        157945065357831150090023505246773036902334383242590200526764709728710637951442742249602522\\\n        936685802508568890959286882411812590207350140455664854995109433363268525354179872995983490\\\n        851579289678363221551518721057784486018770194558168332957008875990031636915911259508176000\\\n        508536923284171933058905248324461881756919069171105363310933420752829956345621157022362790\\\n        686579403969379048658123649754158768249130487077081091934811744644012578918696534447465447\\\n        085666019623829597330641866256169182992674788156381771387275643679418735074569097574206274\\\n        331551997178016967289455984163020072778069910529898124079754037700011600575545748429279752\\\n        534811830150270308238666684035739527662025824950201962607420953127036856378205001450207475\\\n        500682286102211662606776648860334119665537973708597729181029782683669687923140209388655002\\\n        708269157522922804831686199824153524103351315386984147705443823421280929177776573598400198\\\n        763694782317814376372580618166803356140770059866617944257194135859684984660129011956998544\\\n        905139527409467717230160578696710829430982562486385213829893134758381022456070046706927868\\\n        815987690231317135983181389125898758137522160153755351587844038979925323673861703350722277\\\n        633712341910647712219310207871038198096470277618101788110624310645923659879588847786439124\\\n        857425346069426842340223820737055534984479136352216264646028172376556403564407391167367780\\\n        350745578449243069291944747111705551715531143804554148673839321429201953396377512414759127\\\n        505990679254075265039766191976420200503259439369884412877928189069163389824824542450405616\\\n        142122932476013090221035441737291702534987220958532393040013752606864746911104095687475378\\\n        600497487785974407572169795573223175203515457827870497734337194695547177149814954225816789\\\n        918940157423610272884421106618550349544852829431626888428886017092305978533898883450673189\\\n        627650921425108411803457110143752440119031234231696628349947154369260067445109306043793591\\\n        815910584330180415174441277718181410158231294597281707035218010383447529277073147374784461\\\n        121703938600848336029122312647757327363799640516797027326512702807474768145439166886395437\\\n        705144477649623044467811388832353681107099808617107797730338654884661198837747672173168114\\\n        240304171015988056120583114394337624768419487837165370822989323454544037281233664978886707\\\n        171052420413622211897975126909064371999553082070063347462790399442372560002462279881346540\\\n        241268354138063618078837505157917480037914538113008224062011994156798851591821109444755307\\\n        475786509761703864620526438497580364719068263002441443453832488349349819127222124944674874\\\n        175251542535904232662311449118864040822452443506662297362767637255442948599302028272512474\\\n        708380388804159348770840137379756343348255452585469072412819343417254398606065262589879369\\\n        627137831727749816744514676358878223058453094637641741745996236902053789603943252009496469\\\n        650232565184163012612746506495666808425460985763812248248330308889628906037963348921266434\\\n        998162445245079971717419576416650452074492893459870262066067636624453762114224886326570199\\\n        363371318752890223414205015501141165083466470371642495252718076437645279729695927601054874\\\n        175647755046334359567614602915356430060015442559945011583838724712856065600557068335549107\\\n        543457433210320928372239166598371129454350890475405970600420637065518083973022808777438565\\\n        489305287322544882393849235709584616073434583166009183638775255290247341450557201015475312\\\n        441129391268280269502281278411165205917924507619532880428442211852110676710106108921684214\\\n        095089898796780912851036012728252931051566857094166662820877295837390812434556121903075610\\\n        611177287445109549326752722219940076306198695679591338196147684020779809071654434894933125\\\n        403262221656633794152722350726346478508495791767889943819432389524048371117662735950284038\\\n        122630741483233565632459316686922310590972886720045033098916588482809743690203990008910572\\\n        169060591431306706926504898284962881930937453339123229776453268446404421509176147826722883\\\n        331397491218618327114067742446020431904556821639713550602776904228684940066581293299263470\\\n        953957223784075799995925998033480250709932164007453956811258556793735234901136506422340194\\\n        771216153210724052195521109673791919636106089935157906156011296566102061552179695630702778\\\n        974250308431771788089458548541074432513344416092954474496627609791991800703742717944891391\\\n        757316043319897593806086000177811435472003620294860883093218307366389723397105246064765251\\\n        251356590214506390282140528451455869920743286633181875364535753074356757927082065045091195\\\n        831058158220724614153495158911232219058511092037791534608277125173358551291289766749788080\\\n        784762258188686202500152925455499970522289381983389267646984704679237359660928123950396243\\\n        233960812750851746884109227781849314416910839809896432262265609487951829188062865710201156\\\n        012699146150910226469895475900923924029813777971354976040126447676687056240787036068509618\\\n        823520980101495847606528067528929262014207756807267692543858655092693184939326732487687349\\\n        132898543947711650428723997295236848692744135935628660417967582546389766754596083440755129\\\n        028182520505274356050115642575502363744104495791576967003536127392930286556384196154374979\\\n        845843736557511687718271685724174703594296546875068600023251867232884204336525621795618138\\\n        015652886433042694600144253678466858915803671981152589704998382204477005792186852231442109\\\n        866920291495200089461563468116041607194799345516908226635374411263277218953463471327287511\\\n        113070046215003259461240495068688591922058839913911958245809509883223324527450910898119872\\\n        499719491070323618150763135893881994545976666722371035754367537793068057627433119759864707\\\n        926688927472732557957232239944325167182043716998530149194713988965904498152925346681404957\\\n        440823398890317622099950279723681717442553115970634190137491415433891653620741106496628369\\\n        725121476249864459430545267746012517626364104885701450510712547676983970004666174934258198\\\n        938322153132312228809344211317256743034725413797265680111985534533238855406732928799714695\\\n        393092084192184157687281778252443727895486064143453006201405090503682372475266395856754560\\\n        011162647119258225637496263448133991151286919943127705728913571578805231690086153456429634\\\n        651149806713427317943808885970269470062936622170623444549827179457533200312346306694141348\\\n        505041727003601572129875486303226398906659336645311901322045946994664341394843652546195389\\\n        938185175194900414951682812663113497926204762965641153112568527150253874380635411939856609\\\n        125819266003969076859964841362693110111782898583015047232954090248922099978897908716093476\\\n        394155985108783772282145297069964094678409253515236901703303257565580437615471870465075882\\\n        327471148053988757317546489751381677492791670682894547552250886093562283100935061757443063\\\n        505421584756288188048027035627245299406752426508419252535067545294620721624198449784147614\\\n        163098725802978993834568058380318715720326593249573224423528742848900818399988489709129184\\\n        605976909541230215844877962090347282774315271098356117122900313407577998094674065231606055\\\n        861400097619818525192683944452472247291764132184942128201452801702225757494043321210453464\\\n        256515142043205898374874851820353959467484321188991796324710019390627469386118991564527085\\\n        175578326673389365654962734658301433180155990743518539974385419008497825597834334300010044\\\n        709733152623803191020228664836773387448790170044909344466875956654175709852107226488346238\\\n        564746325719560155391574433324442695793327360722007804127957400337964997010267116727294632\\\n        198236725078113875104893005170412386625860594856591416842225198665646032244553516238850450\\\n        834010657539123768322348315372028474283750740408359553875389044989771404951065115375136558\\\n        398357500684885954802902782784342653741192490637629528282887621215681813484578428320673981\\\n        229600196075370754615262147115810439195871436195342450262313139018853011368808305714656166\\\n        355253059168711608377543735413859072190292310691555919552778581249678947714756485487879495\\\n        509985850757575342895015791825397478485606257370349634917978465328471969904798438743836835\\\n        061411278268187668260216343375151626631455685405711592668212972179654899919228380150960187\\\n        581540716367190898067861581967158283644398357777696720429406435578008633254328211954154885\\\n        568161594925146483789808423684905645404228201026005616128313614041520765268513755266303922\\\n        138025910009345199873262271049085309392007461040457011782297031347449303614838964126607699\\\n        347979400404125564214378005772509090069108662135427458923491628532450220125229925081144760\\\n        625562794307074612834779874112395861648200804554906110473292909875528039484921144059064072\\\n        243433456342593258949120070760095053914717328558442932846420909449746827896769389826619947\\\n        488911436613777689773718507089874128445268790631780523664454007082368971111791642212376505\\\n        577479986405643839484690607916486914584603138923262892869616721925920158060233282326724152\\\n        014039715417755739070030841461870481829504504484453930971766192156117408637853402644044588\\\n        231052644231997288902193915853721333725839337584889240519733512363715494852659533850069268\\\n        825964442235235641231962411488083060866705315394789650043784805341528715463080733241646172\\\n        622044579106246910762854101373404553742381043804142456170514067630503817722419049925255584\\\n        088079267488303334710466848003089469096375940630089140398675216474547616009986227339888429\\\n        083518127472554749639688337090724408697427985133411233137834369343443829970682040538282749\\\n        076522916442771922428057220638780168398699931046528070622691472531443103088981336341298627\\\n        293063141177926512192875352596828005913257685103896894740743159360099575409164502549932780\\\n        286202194363588552049738203027387469743247787678784668447405838009685810435810960737508121\\\n        091997642721586407254758946684701077603603685705541553834348086739935897161389684414972049\\\n        750833738818409083436927100790595814468471356543972260340090117437536122050133778811323072\\\n        516010041133160113709485422676356757328879149560547370767142762787476759537995207629347629\\\n        847939541464976134306615127964888712106764769724131151704448104967405597340031913120708564\\\n        938008480131341263658908193056250820938644360737624151187522302175202128908322695242993648\\\n        341042286721347094356637864626200563527281238101882858163894891571910538474517461642970009\\\n        334868790194949429100763774736531321921440988431123243696603634076905977653832506084922369\\\n        840965445516254935323356509045400336749284496706195955914498513700041689932675103164286779\\\n        784070492940567874399675195611299474458269243359846272830874873672172184110598717512834392\\\n        083912540511894764211132665686595306682754779701455618564601957518670397039995729227571194\\\n        733484411776063616753364787676502722906371241579405638797589716065855072635095015217354712\\\n        030416516536669157391648188935850286723235974938381805041336320497248426294582412497701219\\\n        671366116194617086913327741114467860688779107881727508245262455884840890205164032704223258\\\n        897407964263692763315283104324972182886131232372476426038028117799044123307875035434503917\\\n        256196624801057526214226015015057631029068916017715460315126736231352758166465764210541425\\\n        180381969438833472954753900233264477037810902340987455683365128088193826754284531453524847\\\n        961938220763108557503658604511985241831135859521702647957110045708762882797613588506729952\\\n        735512618913567463374614780707514924869494057884020307445837015572539171794542972811872192\\\n        473137946541666040672153887851564656236578129077918801309416114778114117944941181019960975\\\n        340342670172647749798698853830325154733695335396047892536593008284346820619843160243492789\\\n        374633526069156171636274724606477943736230190912780647962866449649540705281539849000320143\\\n        178691163397798785516559793994620636483131921410455709966930834321751637889214473471683427\\\n        000499788263154000787998935333820367177224506881166021897167800379537247607661864294796964\\\n        152910496214284763744899351933291781140345568191907999428458596083878871624666131806390119\\\n        261227855930379523611690880602039892879449989370614719531486593220594569628018504220936794\\\n        331936884332512960668282328619161184416862753845653491005592360386203016370668035009927832\\\n        480671298780833848188401845439221877011390884486309887383269366974824908731732458778795766\\\n        895163422612518482215126272507178691913976199116395405290926415556648252190966360123331047\\\n        787731893194106690189578091562614737133804231758695593983475392056384338872441823357853097\\\n        810076812377246456113698423051994581097875318868321591059991954169232958524651372225730542\\\n        067459719630914135924247016875354086363359899752917981280053440349896212452455825571237973\\\n        718811917618166415222846313740348760645622848395104306318199016262929532086605348222011373\\\n        849682754937019031302017732675913307996343362465550796712879018162791788996865251318873535\\\n        432751328856699418919358870752346126916044539963164409927433616574119805811276225040070243\\\n        329931930625856054660225994298530341845824309884889669887054049865546391507588111994810850\\\n        537305028124913830771042315366037545272978524541377836631670953314743953493874608449229123\\\n        140910947428170455483687397677424974687849073894144438367717415303544820320015963994333516\\\n        349914079504978094768370679722766139806178202935857188655003249321535170066951619817645808\\\n        850355797605302250774739237841447669654164190562348935673473268343156753089550421283305821\\\n        939414343909771300679351747668053505344693063353213376879000341185057382260333015625392852\\\n        746088592319686561260570228248906183980506378207026104916230583629759441464463303345936616\\\n        231099942220268765040946439240786522558500626765170604672679904142178777488399289747483737\\\n        568610784601438240858046344840215230225039252185650564996137056390012742275511583630785947\\\n        371701809157639319439082661324300154323707367172809734511125123521673046929641008749062598\\\n        470787205732380107422521200017902051333160254878708687887047435311491137757519676422220070\\\n        760947706966153139449661235594007529937463626719658440603244360518633050844856025332101694\\\n        566503406447053495512779410922297731704425090339362896617824125577931835456936041132771849\\\n        570819434973518810085842070955152125162469422026224280973828493299827907262670204891983144\\\n        671007979747396356829131848473477694384516245401471229466701166144608579329772482858774632\\\n        652756917519780684773681796667121740807924288200566945693639393457612578099932052088973705\\\n        785746434650187305271298613724479217065667771058951430139783745523030348822707352844046249\\\n        533866391048364356437596432806452037978480323105116603242070691117029880733122524285864217\\\n        313502246150941791166254258869258566257759081306510614254354924637736741642291052040922055\\\n        221150865099124141379655227106168157792882053673070476697097325118883145247092216434805578\\\n        215686640917031868705473910971492406627253667515113155752993720316033309600907375933417618\\\n        235428442901700210695137100379809876334005609393468426504866190020801336978111905200606618\\\n        449482155911846386314325453284740232015272668623384576477013645590057274834385947198768533\\\n        431788048873592111622315944849043126265710479202757164026089114129137644682836566224882668\\\n        598187468502403809422290085692512977426626874519448813236857279742621954758133244524376190\\\n        264786396629180319690231918174921275676991410113733874738648225446914744409753580567599373\\\n        646637143316965601072839751735716478405163153633936065321189484462982855386914874041470057\\\n        770825037205799582865648452960666551668524214225078492962688720677916852311052211451283814\\\n        374552463625456164184688335823261073364521461802750266137077697575057562234072533135462815\\\n        853736288242247324113316086487710473895630508156948678432134145256269962294050271512757109\\\n        836991292527027373249154675962411262132251769052664253090578060994403818820087448968370006\\\n        046160360459826111088015267643943257713901733411589018977378361384499841953871582077244742\\\n        189012748442063659628506077064348424699820761997366001674655416695625068371996299990687891\\\n        706298967244468596871852041077309119523647239509155042812955086243140841635939909535484628\\\n        555185572563554446189600061522306293708294086607693063813278304182413452525707135520051610\\\n        300388363141909885938348083340056758916940910201262864103579834015425325339658308114355878\\\n        458262419784586452764451878711939548774438233422063587875552470656300536871368728673370592\\\n        853034545876140557382131095027392232583167052401504167033622287175895883549081419245964045\\\n        323510679889162813632336051069134332856559495236720789856964855719145559756614999433287213\\\n        223071053311248753539792483610549698720997247196487938926833237321443006988412686265371554\\\n        947749102869922185888657688860711431173096190478627006645691569674762472196715631823620544\\\n        565047075053161196368195291214492396283541195974617411473590551739844592322516510296891427\\\n        453696345897201617164288509264230199161360408703191420137841958010832585774389700584795120\\\n        515316121918079640355508838846429063580348006508073744702096310464227134881654392060136386\\\n        733214818394476683195667422667148248539512581766453094252206325635298112470440248203526025\\\n        391147696248637349976071238131810460187327887748112764880866403320017409951178577361157730\\\n        894626455521115173862792002393683857906659472094494105457434265664262367893407148746797854\\\n        690493242630736900705090133221583461402615794691488538670597631601841456249729347490431810\\\n        420234992975434289688371463321037159802872806047369026801557457732696393919428055623221937\\\n        830363645750014694892977411996399803804436538037446996419001584646595955936966394426845616\\\n        704551321808868972329257691969439531413598199765065280761298064560617207788122629994026638\\\n        783981546036964132864051175879874528314633371223445649260007287943726677960927634134457675\\\n        869945692074824260734080301544941666657147316753305668981214735480816864845460504243332292\\\n        551351729951441735945613478274469994560011617116870080286202079689245594310750382413363166\\\n        663509557209563125555665904829813148779001299209061285370332027157592227742300145667812067\\\n        227618195922983588751526602619371256557464223559171959326531038714174074645873196557480197\\\n        774713420571897130896254163327555295518853143801300398350265602501422648473179784054619147\\\n        106264570733747295489740718169070986443863310090184906553957912311333798239803154857113637\\\n        642562518094034963944881132541813846036671923155768996669745434937924668597446632256511924\\\n        248715392800730099765372859272291994091510082904164317418903806016073793023924667982134173\\\n        400544693417208860991436301397622475848500931372209932471227512484746258767916310057952151\\\n        201664414932856153676805194072568496216839695402467862071363593701613730569684708626112393\\\n        714420677139952243228083609143295620065665091630006002469850355324463828586190139628939789\\\n        071862701334962777959088085083038117914566301271089549484843196506102172565649120814551898\\\n        137094791136056344499857929095182252282820116415837508305600498203980853115585470927760970\\\n        050691669484361877218938259577380840868921836486702631789009436932028806407656131974029145\\\n        700078085862194065128176103225944164469075595192973773969790580520277582965215587090761598\\\n        072688155930885795742274453131966516151805214973979350696703667272460432845602817310590335\\\n        728181089700620873364814984562732097705280127830775021973925093474252568544968611900940275\\\n        217928683032370024539536834755391501399325999605488887824387816202829773991958683000221100\\\n        743650123006492416290886272849765610481384367091964082902076323906691874298042499787407578\\\n        743977987247361309218719950672314151569783726958159321958802006237392334716435468494440825\\\n        568669475582638370223665946516507419418593384056284910637111777077467355429125623798506368\\\n        361557702274115789872460783589861261189158612255010524442290140941157061584677402419836086\\\n        888880857012501434936039561806107650636053550138220052558114411620420080597922045257518414\\\n        387575697532469042983079667502578193393868449569743877836952848111511813831667948641069323\\\n        786817396826184587434557705205552621527719641899261122705996913427166019079254336271128349\\\n        966590101161169700005078153510425637242672765648567461963610402580507234646566663724815818\\\n        325920718830417101121374513301412569260847387111822649102976324170394517088834195830443292\\\n        738199594262614291731710301959293004869171757063253806756021275891161445604137516537791938\\\n        925257371038688611306241060063993373843031622652720963353574557490265184600516833879553552\\\n        207670852283961495062888838470440456216029763029772317144858306987310474817400848080785126\\\n        931945158589294223858590442021740897223962796036205875510240373092804316489859898611464189\\\n        463573646949690514879008166317620528944950954953634957359107541893253070642344937062785002\\\n        913469886621758807772145117160063930899906322839466877164242962284742299687827954412339381\\\n        058181510461271390490564624467484946221887899663606188919627903982293399346283515356795543\\\n        597373778854006454337234349243185355813492154763935777299551966680287301419054382307863503\\\n        310291949883420860841857571805212712016054509736976863597812145192483093890005060212760686\\\n        727004738632409027875821138085894058838743846007219399507053572377095392713689151754334806\\\n        803915716958010827381906103573087731825790377200080990510820212848270411703237786282671583\\\n        467785236853007766802957669939702717280072912478037098262857025336198306713069039593237827\\\n        077173730016955415500317950317259004886069273062729931973338276346539033306512966251356806\\\n        343070919266727150724777611101648436850474187315519978441987246715770906493058356197425382\\\n        108173130491461456737713924901967953644163898793018325638453964739450047559788135710615148\\\n        299294803942046505645223895694924967360483865445752317239239084897405365635180675419491102\\\n        155982397948167539602983071875188617162168008995886818483264650604958997282297699559655287\\\n        543290587233695458104028947436368485276766981964614847918957732481781855424357592600961575\\\n        227080447677190319498588016105320827541448121654000402423236793972844071175297590317585916\\\n        585637191412012511406443393706779769202695926781300830176246296263967065716781907688210055\\\n        209546440488380692122707706762693483949339871441146696512976006401873019388141406475002166\\\n        641852709736988969583098692041536975534149927727786085295126164638207220047784137263928350\\\n        635530157656484783180196075133633378679505326991367600569627562772320955131579495550416063\\\n        577335448625797582874963222814149382421395823986253413589518073591783141308060958673773517\\\n        844692173183972001439963107090659253140153944301783753984298425753202841343993359022386301\\\n        870003577824488559297724705402767347961152682305708145868577823561587501380281710368695175\\\n        446710030242706112700552544104689701748387738873465295124306434928185871822102794621591113\\\n        284288872525218772274769063608634371487737709627055005898143350982784512957440012248955908\\\n        753635231619591815634610104057102765038643314606393196957779151987804341161848585160046013\\\n        524349741956230788622043254732618173106627228583843552761602315826280295801927720957409145\\\n        626847632872560624343120880705138604020061308086240759822866865028965311815518825564203562\\\n        090157154466304034323128281277728005986763205289753825974585642181550074990762771382127217\\\n        723800728571164009337894965856673557877375146480586852093994859326016219143175239023359579\\\n        408824992163028941089944009145922205347769069292775567180039154786579316258561053433714701\\\n        118783353926104167379391367597330844774678001238889097070539847688248573182320027462989567\\\n        438512974718285250739405445601041266805260465247924658258508330059723081447498735199626398\\\n        009038523185556384474455457976518625793836207802136226421468322522062802576075908435138995\\\n        052159262498765467584564232152838452718603045609631216146948189437691129557741806170613379\\\n        086247935341106811067602679118127315535329315934324500078821941524270391784136731608607993\\\n        367374545270810475772302463880252651985671523492464052326489600080701971592543337094951286\\\n        019532651318426984586589631317463095187101621460808225115973305141505968355110051620160449\\\n        088825508854152753294586977897669400769145204036127197821897845155564396292591840093603297\\\n        537000502222322082049917781576631059187252537564037292974714720271217653962932385374605947\\\n        951359226245557286600010820695974840290900941227838676532857565510827164283369072609829773\\\n        357161932849108803133015231178784185714210510716336994087221362527697482590456117456361302\\\n        978824504271017347693776450575606965805316995165604366281453963933425455974059525390435815\\\n        567242031438847294707925962819525386725523991743863096399175281479440498488500579133045520\\\n        137275076401337800700216727749186325315472484867068655680474843701091304521843291437663807\\\n        063672657249055249121248005399435671372464914371944621046720431527922044881452141046811394\\\n        998531672170897060201008914228657746256950325987327607067389693657200246200439075650041535\\\n        176662413967461263016032084456525096632973198059849298023672106305075413010296456223207192\\\n        963386904968418308013192271732750545957160350748516009712865716988121567068963369987705487\\\n        122655660008270522269521808053261554565069698425702981775428723637459615020894691875579858\\\n        041649898221339526305858516782276867801351140421755268268805871543506468418547134928462235\\\n        869173545212591693142810336531147343231398334950060334511502221197393909063746148634683890\\\n        313981420719323748437116626199055823471590050457505561147619572107159040134768806164467066\\\n        597225200892847146107763372300738368492604395796932161111954499191475214219361306286614501\\\n        670613596151283719771563785891923014909838491239909681948790131578194859422065505797687619\\\n        378249250651149742429102239029942070535154911521361649762540754582063138673928981231072463\\\n        610759058329427455333719541688595406648976415839265156942985788760245071187342453296969087\\\n        942960194003922998162670059669239875018657636307928661170234780254264937253189396901029264\\\n        277441285512271484412075143254794675872345517260550408393502957860130850069575385146462174\\\n        886315992498625612922686749088165817238936000207634028825667283437690608345495303852250532\\\n        662335797885362094946831352960591934084537936546524209644465784063474643545753387185603181\\\n        863154466155087596151522546211193019244656684448029927738664345504613938451691530909709294\\\n        274372658330524162680226230270577268128080566524705523388620863786775924066259690977255269\\\n        904910676193153215774636076041617780630627159237956309693668981199592124104949587810501821\\\n        396716175693550812727608724902180509813839255004248425144889558322783417994774424554591215\\\n        775576368800394084623083187545966287016554596540617024581457169001601381521586564878780895\\\n        811760927560862588483710345798692854977839531183639118371308586733955444606807875134804997\\\n        411349394407033634617902483885955790709328028723006949505529917842664675149388632310043974\\\n        440662262436827779038981879131582417979548469981960338888311742306797149261321157203750070\\\n        800029305519255948678812214059594213098604578164011458710152717928052887679105926044827123\\\n        699447039765762643143238275925446712123082840615882796650253087229620904586375660450637727\\\n        448996018707864033819157519276763274600281361332309442285624223994588109604598794288930430\\\n        892570007336324912938441343945253631838538301580064134510723753948299158047240346119457897\\\n        440595133867463465521410941165329793378423983673273768433085643809960538775423189992713930\\\n        269448704054770768000100835182131421315223704871477587963057071136993490670115271247761549\\\n        316402574351420637221294440997009312538674157428570472737013881635027717142038113677491076\\\n        433269341812743433275400248801054712034428978909846758302093371246276488837003675520341565\\\n        020557451155331179837080665746343364986638323807037386552245001572865245651870061955001253\\\n        448890797802768982581811694710295173737119825872288794920434001549481623341177434500276750\\\n        343629459402440664025408230254320855857733501566285760756220717940827164150544465432984877\\\n        750061244385940636261192954532303208867789692193639693462619515172636198922368907436350458\\\n        352815025525338756256782109590774113919826490668815478078472901761832962953457895719698952\\\n        492330254759173301095017982159728515839573165642516999864581945848566096930586434588148107\\\n        460237964315401525153060279483863812981440093872952721742067648485159660010754464532014336\\\n        921927228573795739807337572808448142400647626409233890417126326713057026469624063973154300\\\n        001216718233593107761452638496363485313268932461653422351971902545022165484914297476918537\\\n        853527266935949268075113765737398825463563413748261106053664774365582107711330919715477212\\\n        573682239904132193776125051092663602418545880878328452942763018438141450339189478723717599\\\n        594784009054219206891216551387967200779285164740601732774861856697229055158578030180219630\\\n        613488264798711979420180321274929855786207990991679612653227682890557257326974858561241306\\\n        974438524064205724166185733333034317930887721273036241059480338437133124601235019408889552\\\n        091699906305417685738890446598065627344082722709422779167649927032269749399767263440814253\\\n        268614675199691877930453639843751327270609678780522396555256433101759225112753700271526205\\\n        459010917251720491296609647808082508890041198049201117029272189031081535193109032475710440\\\n        770758716832071623401399561502647405187916211606003905242690827502099185189859095169783036\\\n        878869032085178952406026306844297281095215831681805000959737344234521345181431905151217005\\\n        389602741989264437278620735541805171814119697944882752963858297753284340844261557052180948\\\n        798004657249097322446684202241977146760233339257560854012782205647406191238730247496238471\\\n        166236074497417802765495778836862772699965201811132134505779783817430714646147179521759272\\\n        368389938193196058236776065112495486949806362999714208873730577708179435342414526033518053\\\n        789435787216531454961577065380999410864434623174745367108577223074525657731701035137732575\\\n        217956753417178564230141843408854463132780577935640697602062910234306085444485451866804159\\\n        009219914110926173477523137824718817669831078591629095833511116104937191729105635179797143\\\n        128002143552124477284150555475248534695284026696066466214060054122906427983404284415972430\\\n        380764901122551478204494094552739962025841646735729817555428241361876295238962550494005069\\\n        242988987099917695084778209546700357070878713405496058869652212123174363097333438174273776\\\n        289522429632726204814206405936013677728011032408129088760360318271989594028215478594898254\\\n        422559223005863017990901702177168423545448226639869174353208763493487473413548374195432994\\\n        258206654079522599969995677395858605192311415104510596364170386956132426762982092643975298\\\n        047526669238404436230398738010304064653981965687515962264118948925697683988233524817665773\\\n        659155569114697797359087606010503435097687527530195764662644848618478770606012139915464136\\\n        126497465610709665678279146662918423269766451011071820308480151852318144159087959142884346\\\n        951266531238909269952631854768799497960083392028988923857348618960356675947040474684190804\\\n        219689313981188277117315911677078980135122983452850303211438508364047843801407159831757138\\\n        498195970385706338942655957207394323234244570189547552859163046867177536293763396576878436\\\n        009723432381692139681224239382372944541962904646092313343888366588710066415448673987861216\\\n        488532872696716903825854372470638763054147858889199571748768906209669584061667826779328839\\\n        862541470412890788810346405991790184617385771618636278768006775877193133600327591257869323\\\n        150011538682941004955257989427562414405539144263953419496295662908621544779337279863233417\\\n        548917543199833005175292612863449653387764039615943620413853672364422730612001818995938480\\\n        727671586367143340269442247538457673297083570604392898746458271917106500465521228378536663\\\n        275450910258105395292395714241555343154431306970348657559992341530468242564026978882868467\\\n        225419768752379354272182254483220251375416067413924988908560420080451691352558533383394943\\\n        626175393297754847283537561682681308385271075916304596414182855840519606482739076032405368\\\n        424853318663011638109382074777842885135778245876034135449534474777838983109304756663401588\\\n        612279213991679434138677395545368303739157701644780516848932724538775523584709778128811657\\\n        351657721912617883822517961245255299645315792140522448553111743146884357407463834827245112\\\n        777258139387398459220133755979909264197811220202845894240971997480829358107572756028877037\\\n        373561399507684906432079738680656159897397971229375257466834663252318317686130869062587230\\\n        868861256726061610153081318642296363546260938126947126642490463552320846639343090135581092\\\n        234329489357185191060543320361060285266520607626932641590776175114086364673698080772225559\\\n        128712963248942399930413426722302380070449372599288655557187171643158424628378444369565531\\\n        449697927111294731213956599145995822438484627338683587082612500704956538324098094501406987\\\n        293595455601923862556419538805204124564896497189012568937154813875373126758606323353120904\\\n        686428407718661570116023423300058918532699624862961225165616402209279983773166351074374875\\\n        774850092772760469811261689764472569935884108837210960492272051536132011544748210953102800\\\n        250295350414600385273454887391071098966328654613007800102219002610235543864053294476390309\\\n        286888818766766932399560089774453435065226340102369384317497628236693542240036468662248707\\\n        349026346368215122527118543871848453433596826618139609696243440725676584699297088623426785\\\n        567743881095283002146300025621178885423622983514014293253191458061566241416482967809752602\\\n        213510315695009426193813111636169032411690438892517045448461615212667673770485869817108966\\\n        933625649237911435348239025027636235735306883203282447646393801644253742651151762188170772\\\n        877374222852200827811032883615095137746365854936876291028821730227904336517965481399074834\\\n        672987622065590110695479566843199613075484415651355753074299367941320953615667610789483232\\\n        809116816247842956810525853529068665793242262284711749441173826873307530503704400229349858\\\n        014494724083628525418225384678988805955009517748320646175429022532971504999966591959271479\\\n        477096469955029405226866079170980503773631685348848625777681832481377920843930226681519480\\\n        375692271574966757300478112129713094813411189804467168345052237190570431676952616431503890\\\n        215552244052059114641852958646972642615639490448020648777478209965013482603078888355616476\\\n        040138942697816807111850603751510803940351595098269102896123053370595414526683909054816419\\\n        437700242168549302302811554895733676471507136793328526733837011463261329636813858098893751\\\n        873668793533581695456179799765486135222364733281039771939366054130790682175000117417825441\\\n        689348027216526213437402099172486626026166584360360761417066184913774122846821666509842787\\\n        243032989669400267830016628152101576326028235314127312222435337048739125896439153071794296\\\n        289077816352246545855890158291244138051365757452173460986304552021002372688797863651208719\\\n        152588910181228090950890050694457377266976003115699003560617968372511013932949289771136544\\\n        725684553100118572453710616007402268755627797407039168768336069434547633394927268033470331\\\n        356481389463449043964416473647458061153664831200370884561048620249807811336331450209741203\\\n        575877110067883183143710290927887322107626935989402478722144195121284016704274365386548382\\\n        781003321859547319360026282008611949262075123475569887874238189602558009016712802239332912\\\n        070860688562618116408699224279267004613503663457544795768001250993102380324898838630537078\\\n        285950155401789967606392400590298131814544013935579715548165889251326938307416917250513720\\\n        680422921662393681870410657515846026308596383919027730436391671209421989620130636664689138\\\n        399328676874586061637289785236937449530931038949746134872196202485169322363727534263674223\\\n        756570900767692610362769641694173581625757308839296811982176788482131663678310276879312138\\\n        533245059456406042982513080287206037634919044028486256928312423548490549051472451073249647\\\n        736115709682984775990980222254988124172930845787777480053791050694401036262592593975288094\\\n        917806371067460325585283463603043888629864593965354731635769752806030831398761780168256048\\\n        420701388503011895551535571678999029417043355509283947128135695876259350242118102742090457\\\n        251610790584232290684860360074506618197184131546808337682831560542591182033292562811024636\\\n        521792668088952699189484893958002425295553648913983056563247539373013223818865395481863336\\\n        574425107275693894568866575665891760245128449073331408490870973117297258025394147601004980\\\n        777437518195975908488392016044465733330504492328639342661096490752835210946946152061354175\\\n        681103893300935024172379261634785503439658624885979384147967848286128325276080991668805988\\\n        482878651422480963524942033341451792173616151781309302727706673023295928222888626047435205\\\n        205040313136475545319059955807101289721988084576436297139358507215808289479712278282205097\\\n        294195928719049796776703246934367703995480315320994397668182167696011977401912240608180889\\\n        741077266234716435575560795005337227573743806501461645453723723780673245305934851259891006\\\n        249515842729512517409979543132258918446807467654632750184097148103013351234951697121866140\\\n        511538113951305545401642004872609757879853668919070528447196300303755588373596395491864671\\\n        065618617174432193544466098212886006065421003488893750916000934134630866620418939574910899\\\n        036739871087345589683862197066052446239803134358076854550709577659556427906715523600827282\\\n        169928712867366718296313122688790520552582649855364595838268631813434996697169334069716415\\\n        314921175692054143242928833185805882440245953331867598017616186846109550063817783547320575\\\n        156311621414039132877494020126601340663448224527036339464320560543328218371820527966554201\\\n        314284459642635287581391861752217997581658930375817792356084914169082276986008284220906663\\\n        317678882488974557505481956557530205793074783719142420107339351917443587887193355550148653\\\n        620425505134236664873158955369365572818983563919808833021168531507121965014061027668992015\\\n        917998959270263491909882870763900299705470548551450713972190358445943640173423732446441161\\\n        377465740806707867505704863581828782132229498454100780345948987752773324729896354221810206\\\n        626792686080169259722316841144568659027213337371390766492732308743951138394789235495622180\\\n        167137569512314553011125929153691992494975623772674252669325600671174498430098292377878842\\\n        404787040569775714843632841983220558168120944284942903014097681408495696195603642230456575\\\n        546156649495376816272217608123144363097910764284531632460310832415407467563728652937141368\\\n        773024191204649696607706920534763612550126095362223371180874663370769472224214542599690096\\\n        668131482249591430395282221143472346725158111001375640143069321596366710595960380086446893\\\n        076841228814000755213628909384322280995185693415488922394380706250082729262959162898539131\\\n        064148476775229962042623266944623612540047884006407870241361998041242652250168587879438367\\\n        028611183157071520122970651218113871829069023120789428352080673471126486807056091251055392\\\n        778085094987538577934345304195831521687212341599599081816288258842742867860492556221336462\\\n        686034706202726827212593910955745946499985494243536774948456904613604130360450731373031305\\\n        715854490456455618749355547878718013509577494493739840274954919498989859870952616725776288\\\n        020869522277186197675410412251126033241735209855244232391128037483163620034067132698715155\\\n        889654754842016343154597449437674628355751704035423464906455055226903468858918635561335649\\\n        865821911781216031678391353571104897954066400872310364980904436288770573681040915865990291\\\n        129160082270541535193878389849188032063481036748115825667412152157391416296057616012595801\\\n        475995346022655770584869581024158142538658291602792921778176761768324435051991320368747237\\\n        416928654806010802596144230817132329046898707882273271621601501848299914576612203747654780\\\n        711191059498633883488942648286217114144311357850832797625717788867637110345160873620193835\\\n        818467881154720168234097172899428743836306650622313186884793461804257197567195369572151145\\\n        763067103338719663408217550550273983873002446809657859261378381621615133820122603246644246\\\n        562399612034177827211391577143410457835134736620779706441286672505262999669244631053461802\\\n        264823746712456934388221216953155579863663318292432354275757988851278504483763356860043272\\\n        575162037545120436935674931869697729427217902235016682355307316050450451788396796144077557\\\n        591671971436353714594813369944662997452020107724385565823540928642799203647978421840629079\\\n        270837382838376502563890584485505981813211927158608829665908521144322548130192623625478173\\\n        992736700878288087198666229008759440524663562048807946137270888442010307229668195173112768\\\n        694692157263398575081107437934687296466125605732485518382117034432221892481724034284458515\\\n        286130140416699526460680534616435581410310294795618043640886733578512451869975973542112655\\\n        274998112581670526323042648778974686541121024155698652196203510416335932907678244689081263\\\n        684110270858537928217973457031225758854018109185245128516756428357568175950794058921580168\\\n        973196920932254992802554755796090349125400768584113649858891518226990587390337908827023733\\\n        364042308129625916677321533067242843910690317293762099448445993131656804750234217669479438\\\n        449794251535886612057924592542244297075651307791597429842256852625563363095594259660875267\\\n        264543458272067375294211034213440822696628308531846807918392912630122416095566771379192049\\\n        506198266043532385960111222166806897587075758810456718513926362501549083397564077734272124\\\n        627304932530446162119089307418395977536856593322004398535675381204871331109667887063353033\\\n        646860140173426727370797925090229319516628902360487659313928978943589605291201874426439622\\\n        759156977313745244881501375915090558273589515476587434544813727894021957141937802941856583\\\n        679758604535140900246125754072166894052920679649489139123140590818166292286960896192298628\\\n        735314071997718379477275149274129857644455234761867544258537070464997600888985185358317069\\\n        546402567021357411154706746817201402155640689820968587770353086302961912974469010649953293\\\n        143485920610372625529751650372600511423004835187362279945025964921744074403933853608434894\\\n        346922957354265527265851089073799396348316695495055159665359785219390945650598356735008728\\\n        200671288855147076924935267836418716044267465099988413943718913741266763429950825933180776\\\n        231312121568429209218100386215486127421661222911709787203468300547970592725022530135232845\\\n        934343625826864686584713014223116131913001339666371101454566733973706307373625649595127699\\\n        923626230620144893971910339078505289088312865865092805828341473541681210873267318982419287\\\n        334790198976781132701115269507535511428302640291976729587610952650313310516120706365547963\\\n        694164970906095976670746070301590308723620407712248905058874161238717151226250447353804689\\\n        881292468279219813369353204948316938647369336201661304901951879794276493613449826486211180\\\n        058334277499755680768111771411749864190316990655132525970382074689735996100448751732115101\\\n        172967820300637627167813500402433398569467960536727239711130626512611184507946851665445594\\\n        650330069305518017853109639717302067695043865691914043312401163917723705849469119606549264\\\n        452578666468901738482722517419869783980832444777645786165819453913883173354201506832414905\\\n        371060411586977549522150672953625787300819568313298535291483211444148163794142607816544840\\\n        270295405080430096086167389334816861787064094921001788009469616473525389902728978849013352\\\n        620037036175134477795376569277043511436217567907467350334549695465656340357692148529760264\\\n        944616985974782451436834258107062517540651732830748237937932724814669269116394084577579261\\\n        614877513720396816868127960299678919829833939250556023088589835902662422666282587163510049\\\n        323867790883575991441134913062802197903937950072364363279731691172744962194218877575689747\\\n        202813627917851021058636191311434271265709497663639115697502723996741196468892134368200107\\\n        330663142228020662908868077849836959054403810784580394606750883614847006434073770509686509\\\n        346370715181004826718535977953480368089436250003429041694976605570673986456388744063900062\\\n        266910338592914435079071104727660299656299137212490487551510065686523142085884066720891113\\\n        365949367632079379274362348499827919838485139021270942656127902982071822858856117802167842\\\n        596289236166898887233737963956882572614402449584928343983326134829153374494274557319469141\\\n        716729604343649493124785715178057426479515233077419522785152183257729243143966385385720879\\\n        960551564047201046972840610913518215229102327806364999304906324152993985919000198545778391\\\n        089516679372282096133540296602765234382064276911420483136333063293401092061468419807458671\\\n        404135263857149683231098466336552544967555406934525270917703937733023410826137732286334660\\\n        588566858649837038833101802239981250593518667489737422532979116552624317329905842034798618\\\n        910146312581848175377333296838076196855903545958304535846525956781666549000258839935933925\\\n        415751144774729449912325951683672049825217352106737064457003862649092727271533029346012859\\\n        205953947915240914389410424602336883112243053134772615473645636555320499926133126637414312\\\n        448421505271581097674059837063321632917882852027213928163288564918082462002016864202848666\\\n        080930199892136644194453773335906870967797699418726017163745394174754791086927572124690287\\\n        625354758140521478795706914860742215299108707382296019399768429856807812092298395718309589\\\n        999569272662435523678176299075211993674739916714327077527874616177445703326358120367498360\\\n        774859113276712339067937443641739750294094740444618053287575297584165145221754534227181237\\\n        980246212643340780730361130553719964234498639106144684520790922747550969385520634380914402\\\n        588918840970406943132172346366731641333207547012221956938314385867038097834032647050293587\\\n        259964950736353355736960325048958598285605285057898034278825276086312894255946957256644844\\\n        851534101126497983771080360843803263048609084164241774458857325621284122595563027561864862\\\n        962318515806002804143690988926901163478414344942937082600987065649802957465525192166847920\\\n        044290989050506132518490957010981238944046932752108381748206684338012721514378429966783626\\\n        000314131871750183979915700270817821596661844607871435605204527644362638553030038348822901\\\n        366615956472075278261797171579509315227326996453099278802112330077519841109748196551022530\\\n        125839450385181340720220906837783491560369960512287342384317763115856832439935048044235033\\\n        417430668208585561304072064993619310779929522168220935198618905937314451050659907175606806\\\n        408161054518571487288750866795987097120077331920621827716718145636841189424473397212932599\\\n        328688479873550427808346899950623373943612121868755125527947148889701260410503821456845219\\\n        999800929099058333583545711920959669009299502689305897634713273974431080229998308263332644\\\n        946565093837857390793235262469502788150387358778870568027483958318278471844304056243185566\\\n        719038151177457338194087235106475598595327412019348392399980492049561311917961088551234225\\\n        679286642585451379865251423339875285072647779958161327121179258717280564088563293691337357\\\n        705743837424470789045573638950040354990364609448316544155245272494711094383663876323759851\\\n        752167572977250443930840366659423555358267403986970507973334058338458360079992057289229006\\\n        878022741321296247076971834490218108546738718393413124985850023960644468205825766707192300\\\n        122931041344895965547588343452125705679369968121204060518085528191099718851319153308595737\\\n        744846282485239814983216649369499575989404486532176590583459192458886493976460201042015559\\\n        611881158618163858618156695067612560495871135759606194042264787668804444587001638948045395\\\n        389105181915512371656842375292808184845312717682110639824273376953201180568707396950231351\\\n        488961140176958186495193414340755747607128429852964244559135713247151017384102770256654915\\\n        194668103167600398579155355919397705628913142554667222877679666398191608752746613051177332\\\n        627837753548125287657773413746338404436134244250389651250428361381140275572653030369912972\\\n        797921034971581705045829149629850840279900007986099290270184315333054502597391892417347409\\\n        625336935376032411694938419572722904597566210567001386014353303647470683696094086419461441\\\n        639021073706267389677884928163000346761703525564896489453824652093678370029628547549767882\\\n        742247601763710883608876413443260680556358118671233589223322484443711519530278062501892803\\\n        635930925278747363094973066327065360111865639054517646471538954637019849123209018102223045\\\n        126175096851549834951551924858194092207669016561646539141552479431371166611094097591134830\\\n        461789048104050191054466777937342515501454773127234742341018551015582686541959236879376103\\\n        293437201677126936893541824411778003130384593068039008432685609618779591844977971495771784\\\n        206066069562065299472890166592688799365212633202037502093827696911028590333095092335604820\\\n        262516037866924488062091371984631391861421541277967221061356689737063731288696342135476843\\\n        938738124001049537936758388924073516875478089545703120281940944876617857368533717747207004\\\n        081276940130703442064311928516395763222405579859469867485927469614815417181941291997684825\\\n        894354587508026513326608695133530837048007030685207344631212721498703120642985786889731442\\\n        613682539014226045494358582303169340743922818055151107531728097841401104892173351727399876\\\n        288144308480601559214513499426207219613496680638309736620692536707016795486403617903245346\\\n        886773684788353738731609262627553851129577601720742568770923007437022428210692059147674913\\\n        683353705681464013489118642506792933796287130114256863148836177246453029128672994538795448\\\n        242769825884588816230570189934500983447890578250461494910804270117170226660148938042591634\\\n        452937700926148168045894959591593430796338202073862561600696608822562405963132981116609046\\\n        216354285536768649507764614800778759932394232130597430913820343441762843593793992473988551\\\n        785454157333383065399779383115367129850609030248878534721830189251066146184519236872730962\\\n        414939889913198830719300727185917937778960603588888252516509264667531961082409118271836149\\\n        118059926208454966826106195417879294890330479445622250542766698081221487973570586619425652\\\n        836169430453391754173002081938382795482971723037313833901105300570626416630380916379407094\\\n        213597498311963132665214398524012348969360773418720398211636329967456265306926444332418959\\\n        475516711052178557964311851385832986995760681160358390500932318146767173370660604338883322\\\n        751970427940255682189511281158542534448461715217301816791690726694867023341687766939808625\\\n        619464613921404463182326130532938564806992718976508631843708682892640789107704064554852713\\\n        526665440299317553805775543539498865450456465047331657151223149359173791474164045050608560\\\n        382794836042464016749275283884211410914977684856002654082443047643358361042755609652867446\\\n        980260522110193812966410443017165358375351227285718884070501005476419892769691422503399862\\\n        492336186396110516561649136926367867794887555512663393910798017554016300613454617616037754\\\n        521573004814393869479590943002648175159363637781374426283738851183829432545535782921612464\\\n        547427088142029799455043118177158220246461289839362675963822368024532792849380761001456530\\\n        189283332992162084283402673500078775103839586563058920154792225594408071469441624566306745\\\n        312431283753287137754188904473207958037409991460881400588418812389859327127611907233131305\\\n        405256847493793176829453847952199102558264572170329832251953041253944442103128346916120342\\\n        585709901383296673198078435348559342056949922885442183502681195830692236944842033500649583\\\n        699924589711186170704611419888090825643089990883506299809462489202483280919375174543291519\\\n        826395515008579194333429996758729515851398398503771581628733773700857786483145084800718776\\\n        944089681276737724529741607850051936741961020549920918394797727122065475464526064812497444\\\n        581443943110924010181334434651820449912298124675605089101345520939943122648324133395616664\\\n        416392368172632842300192452024332308749200820531721928879344213010702755358616346022663885\\\n        791590503943655540646182184742434809042431489207045115837211418478688744842231566670927768\\\n        799555223191197273297877007661413185995369985809075247257918173995501906423536096874458536\\\n        882726101875507925599635622956396545543675482716321132393526546283079967756722714683570159\\\n        962055907240223440243115050677954478475274394779873041225291977562418948161133822993900045\\\n        499307507263025490602171479263175599803471949566027593071886440162326628496411331264005584\\\n        653819047983270753718407003522080883835360012827751683226720575477480935845942920258276277\\\n        710397346820377965686771178778220480897791285291013417684129594191760589245868820205388082\\\n        352012191228094398017601999026842122713616390755747993036626034337300331840617089302517117\\\n        306901596194065196203213687713133880278049245280927179547428343954333266943914769729712018\\\n        986683029114373378233687888430817508811980482091325073417204637878701963668380992122208476\\\n        469656426915792605346737890781960988365785659179568326894681809736272271742888682265032285\\\n        719956411280913278680408998010302980807456909909952988164927804181728541303616132794037121\\\n        970678635766131403335195818654045724525795279375704416450072268142006812656038752559676553\\\n        111941083707447776714311553337326777258735465324141633551909708273182974946902309082436165\\\n        297868057171145476676975684752928768974655110877559955370463337598004260410507062410268797\\\n        288881426874384304060437034620750253419711861538974618752206668223010876644603463990040324\\\n        737202891369611265952371589654367647665408142169173289936170820914197882121299479591904157\\\n        820001699289243629640672397518132179320441562969714650939695348359886123994069396315438807\\\n        797307066785966470828836105398531992166610685316723401104735144135378970271996388957324638\\\n        710409513845013975110932281547665067719954104468127293614946858069464441305377310306912732\\\n        015556392786496011119208412471742730972535192220788837258170752380735569861126381078665612\\\n        304222548689025568228836740743516719603692972353530132622361405982583373012471608336108472\\\n        081655473082311221718166906819610495679724684125306710719639946325126891417239584276495849\\\n        097838137451255275920661694939915336809285306427797147670930393832818786785700786423166103\\\n        493892708987833189515998940215113093165433413145500509940982495483660269677402456544342841\\\n        772167918444658047897615430923408269559375198793771572744713640096423768851867362088801545\\\n        394236752297554172387526439289206703654701347713860716186901804395404718930017470345966342\\\n        609303197861681136681676417729705564213539213378507074630025438792690119595865333562028662\\\n        524484095002347035887799067545196458476358774826890494863933755851403027061586018678961215\\\n        501641989481429900789867692252025479943177067766580501838572666791239248593508078360518372\\\n        933633340108230749939216590071688441019093632688592795569886387272379187734759152055590991\\\n        406619084984137058292679301311194060010766409714331141555927191517651337401539361687721633\\\n        595782213111878505516903875764244082388626828102282797731408009084573585263019031868700431\\\n        409235896041541047348108612581104583029654870021238351696530273307615923769348743336809305\\\n        890505646883479163869801047114155624725877385237125236091993261287022376622373612446203964\\\n        227397139903236137286778980498378762857579267265755016927849077108731396311056133883981918\\\n        134643039277098066340605907086519441811156549704123003632037789802524769975252103261184163\\\n        351173014390422656627474648500546798601688456321028792847261873771524427641095900986274517\\\n        171958985418903002227021804752699356197698311107817474299445925458354696435124502987114927\\\n        230465624329343841201035515696472552928680530760244257331827636536589340902124019285075573\\\n        932697886411524094675263214792716901777017505268546274442076946838037968879153903895596917\\\n        172997116794337109700335286001622413369342967889210152570821592800265820167155700749424379\\\n        066887922620978259517399594193575776287162143812179439288279843948522953069360067311849189\\\n        550867755701948718159045707585999384284459115476146728499504135731596589047466480407844975\\\n        967115187887646791320865445732299732822001326187339917726696241384460919924912776275521086\\\n        294579550452752638185542530794310048836527115777290808953700814437267241825582664259013096\\\n        175755152132225490686758153099862241493819587146413422302488643113315439267901765578014130\\\n        082938954670264370281516213014558454582681201527299989247340265673583429168673303057015481\\\n        892659540911354650939653664216567097872882691078363455411007427706102874904732497569520393\\\n        094650242757021054352176741286574654628456135922484219906004448500738537273261191743693973\\\n        846043236059576155596359185219175135221403453011720683955634769984468318498708407384566995\\\n        344176092997808568888856085560294413226883778162514336849594998578304752440345105632931070\\\n        975798072587913295957854839720450097115943955397788911453363441420243393097289372433419661\\\n        114626787716644091872336089727234032974140669087695245675930888896764471590626057485053590\\\n        649019404347353408386774374315067075208567336126003600170057290042227535324556267936208180\\\n        333745713270480232665238366827488798596449499623828153753832348054622141732185477446919960\\\n        550014572768144709029494228446064194299995202448460203477262523454057014824179055128175461\\\n        092566377036924940856410900671980797178282671396289452599751940081205140964256885877509909\\\n        924309461297227510253500311330907089719674872919730651034383659123424870428823914860230071\\\n        769014220833360312891427696168154490057957277648875017888800735955162863915799675501828471\\\n        966825471539253061841095816097601364553535876668314491039059812427342162323159356487515010\\\n        523180530971499962127861428226915674780800134176806981978789156705994843997337676491367424\\\n        001989597877533238213484320681525762363731783472227254999481466914210748792393401931634751\\\n        911211741757235640471349004152866109331284248487936403740881289587370319815783652173350893\\\n        924513198877928845719800936775062004026852461458138832560175301400798141268351573006256914\\\n        222425431061450014797559767291254729324114393965485431934683635267012492964473419488320693\\\n        464946280788151783687214732714880374176323311282951002678695487572684272633938567168591629\\\n        022277274839413298729037585014046300561558288185652924656604669449620473402685989937179662\\\n        935178963641176597599376718675012801721630354959203747274528529732037487947893191847196425\\\n        442870981522095565195913382099370302722331612854944905580056873557969635865618373934418538\\\n        721598920468141839809013351364873727432059976808988425495897787319791699716401955522056545\\\n        535465918040730350990222446602147986599944414575447726631642714335212780310600925802957748\\\n        199446371485945309689013789201285686457205024698507963610951531245905649095503142775969631\\\n        861499113876845248874561121676088536022800713247274145260004849899169594475236264136869108\\\n        452994649190882042191314268376702218256497302965458013907500264189766024397474370565317645\\\n        888272176269197358383570135388433836544679216657658323942166608235755176577953130406650157\\\n        190559481344478513767832075357521547955595615636817358076434598815462571411564892860315893\\\n        987232003743983088300513724560935135750050283457307112148832452534329022830246866186372993\\\n        226740967658286643973250498275949830684421875524860081861503400518102857492940547282824656\\\n        188740147437811074344549952232728342914667872940534478672743184650812781197637536530155293\\\n        160091909034114632608486110012077396780695372276165656286842491415208693690976382547045704\\\n        920143537518587627801735250016481391773961243429517789764601484341823050452956987049783621\\\n        929135117559608695811887578832177714167125391360853158159094591109738954263289514099808253\\\n        635480006860708465548611360040530937157387957254670799793491069303678445129962460177103245\\\n        844065254495434116833333981097899833320498877058914370858208275511470384957850286116973096\\\n        680177977327474638766424485770180064289555431075683952776713284645358010244345499876549832\\\n        540539202781748862119371889610299886509353731907843847738364486055466116018473312096752806\\\n        673157582539770861891503195867508952900802434208382394861123294703446461024774084591236993\\\n        209574643396595185963920427322824385160898399458311465936948988486428550907816261508693592\\\n        740752205950993046783473015958426398507493557287401312275783862807888935672165012578576481\\\n        495002350716117817215921456573054707469140958626301703543700847233690445774645361673355241\\\n        523284564387503043520595923328687297044948706190224137247507993669374941737654639013442400\\\n        050258898433200393507274373332314774662951161126066053451501604093646041994280089547124047\\\n        499813641152465111877661612382140932337981754428166615877738332846460770748393918967053484\\\n        132396903937261829412227892960804099375892402317129838011214613251064762145851235571343392\\\n        826143278642005313281468646280464567863802242693989379018833253270036978645886067902313807\\\n        023642438275322323439808779283276035187851822712155584072360455927077380947239318949330321\\\n        576782161624589344695425929330076605362319437550397536291222413631062345007547688760620445\\\n        739622436433394982691496354498111540440408822508100914695043642791184764556481823257917305\\\n        268654199383970181308653620665950407335557738931188079725309655723942261127952049667330339\\\n        859485493389878577705459908615419344662172592590571964114722245496280879721260948085948125\\\n        523935640309407332133287664452908408564796098535397555303905553734128008283064674178673138\\\n        313675924687156628538849650253767641291353079050172770646419382447962513068344750757920756\\\n        456776281291535274146644289418030894037634168162132582101430334506805654097937035607670994\\\n        271502031936001276909799999531421022851022166003618956646812643076639085161143210494283346\\\n        161069034839534567815207262475325858500079117383321125625596150776322690170656341244476347\\\n        062525919375800229860879512699890347604874859252481151714658533775253624672228995974882174\\\n        608620116702561827788252903109237472369621729728951380038157959055906599818854746054665812\\\n        989302899127794512619677178467680233657659831784091910071109432751768240530613038070683742\\\n        200726885195494260198511705816331974781015754955615058364273101666024352076784527802381573\\\n        744322737788570996038167851669916363865581128700370511713319425275076886432987562028976618\\\n        410914854441662274146213329384825455489711956824759689546878529252724151042171301963268529\\\n        429037853327993042073439755975363814333098292571450770630054648231690665296987904753260628\\\n        403854620705642458892439578485248668181362726260498554188572887643552065856106848691322486\\\n        520941860812316326824088145661194402646859215375653462203506057058144897536871940808154445\\\n        348067224623479374426655025887937513469896869089284501326452179259724517079353707227769607\\\n        113514291474901832669924814960855922006805548368498322343335294162386313872385206673875378\\\n        807122037942654954496862466143231461982927088855243418130869229555233113762939859936902774\\\n        785925077560435921239775574200717855072745412456224758835666290608026088238529744120379708\\\n        755428606388979954553534757215696204421444721100437677850648355775690647624962050979270317\\\n        165880779961829921951991555559176477583396554828450494835484649976633692962533390983201981\\\n        275799431173538891638248314488740196985595279049263940554403719396386553681485128456633992\\\n        025050560770250648600755788964120392545288986419321492047454245536001569594073797113502496\\\n        691193698822742173239576965418268802003215157835436361566810323735366145503408089033570347\\\n        446130385505781902345373664335790551030948570064405163917005656575424981814788020833885783\\\n        022953780881435146142464245308790523127713855483970686326527462330412328776970882181054066\\\n        065387743293134341675839968200042856749040607172321940203258489420606747028843705165140099\\\n        483716082055554528927091210724184914625841007611204384560861941894671355541050257058338948\\\n        549289541015759469878058832855986519365045149523033315126650801697168205625848746080392142\\\n        225068398061166364111195375131430763944473639397544482377171257746327783816136118031933379\\\n        579510491532883653498630908202020712626532059319327895680663434301519708778298702241036476\\\n        976396552529576579390054725406419970073171476295407496838345616061608552787723949877817920\\\n        221927130603372346017718905398813092244477297136608565310722966058653794663676632908065620\\\n        162713806766168778580296727711393608344753005440880595325460254356933978303446076950354868\\\n        550845958228208059750198504203032999147503795111026495485863873709525995431052854689268121\\\n        874090669389910280578288915685888388378459483259642056377840629046863189621066457311586734\\\n        311188800317584024208659403295521928937954931815938788094094485331152458764493470718075186\\\n        253067527783725920357522495665759245734386525491225664250649519432138582430771770594215339\\\n        640716392983499102849364957074210464201788198027983977262406334226672774037524725704512589\\\n        051499501938089928980545972384167149815400669526678414111647623517306298982055903405789023\\\n        112017505227097240342481232625505572254803195257759848172126314054978197301856708023847110\\\n        614878870073602540279210405884514517749795085225326531279627737913449621068712161316085910\\\n        243813599632232908411480095830539045384505379461270787051666245956537365840754077037523784\\\n        703723726416874931549023349407778819956031694274848822749540038753567317407754252568089862\\\n        825940367174418715126903674190255138684505827088272718462660888557184138880426951943117729\\\n        166673959803761612669473167282610240300993185204368108667647306906156190950395824124005952\\\n        513342678662586130060789199804730564594641753228386070632461541671332372535434676164697046\\\n        144173815282698227442898138358124521626168139904997696740703517412144419742576679232639315\\\n        460914111866749681197976962658372676730316816076919638017679510488666187360124290899236410\\\n        552256177962632665793951108572005188889622240197095059845848239693008198224125005664921049\\\n        003654876969838683135976189442041914652184759412569606137274994469992771431647296102855609\\\n        613339088508869372704898770518145950484900057393128918065071737662144323018449806542358217\\\n        914393112405660566586530849019223058066759770291958543874581447470772337925801569107112113\\\n        024494054866031244472030572250607811703274946045188507560501682921466482648594560886714324\\\n        426618936223460259335690849624629719289648012351684685655843375218034140891688222391017330\\\n        631773789370933097563404557157043060316986501007997783169418635715735905132240407699404011\\\n        217848033270129264360250586987011533551844429492766390887349671185928139606702529907829494\\\n        405416744796240512725186051334298663971448641234553272850232637027326936616570199804655869\\\n        457690983826891217338357365057050770439990626014392181619435598293748875378839579268095344\\\n        826507276288941803789352481977221276026294915168922327984347456788019995227313100820859501\\\n        484029095330677003126001622553891155913544159079458224695287251671208560928966445620886100\\\n        662507836820557009926750756894139354872263669906027087249958465649228346039620705399208437\\\n        362074823078547372184052339859301557809579710284480541192913664752047043935056707415451362\\\n        975026097219643555102242779929961006081395646691393291639947253457430339864140853189978599\\\n        316623677081022807136093385177534160475244832115856664806385068901301438131003475794562132\\\n        475269056061671364909995285634204221768745200518565350515837896370368473133867811782994095\\\n        100461395433895362380785013757517259736098724793175887210562459776112355045091723102537219\\\n        304624642552153272462800859913580962270398268994958693773157315415972424138532450593474297\\\n        418191323092654074966539464958243809834150220672921485693045872877281114162897698704133330\\\n        831439777410191895532490768069921798430968041140846064004645199581015374017881730618162654\\\n        337232410799600437824171749707401534418875396541896098866572038561243608992777909240397878\\\n        171504738601100588421873402273921536826695423595441600086787825831152649052358558542052186\\\n        359736857152643848142927709876092630083051262335951582833703709468398100939754382346670952\\\n        728479240339693246072857278453337234922894626532432498566895067387994828809012451900771967\\\n        929807906173886959597414937301874303735927944353495845944248642551569139059139490084413922\\\n        038867501149294839437895340354587761521599059867928165114885535450469040863937831790434113\\\n        891571487699431910344000066502887626763480292978265626206101648527794153611651308224645815\\\n        437532707516560822862279766251131209095392155400471211826024946492626429777078052740936686\\\n        143384036738640712120817590118257001124534705589089322265600081404074610345780399588536190\\\n        869104818935840868085229779779183652182738201335875256631463517823837855932974794837830339\\\n        342475525351667928848078137689136740583108397985892558965300801251271630466216973243329560\\\n        560873880030462594772256036891075873274142251396705697861353445670707261173380635068245418\\\n        764678385029923687826667277276002742827656308082015874709975210577695670375677395019971437\\\n        767429679512373796284858867317703390739735811227781001204805667076746151961561238247481106\\\n        324090943979592949473786625556693486806409759703222354855487175234173595609013791563198829\\\n        246430201102482566283709217798329856852587229962424336703434158162040407048115707981852000\\\n        736218886197296364224610241430865089451584680304321805557471594484140406081533243481573416\\\n        505539591898550648660269274606706897400224718674793508215513066574699272090434774725276518\\\n        612805007227918360538100227851487806348659168051666177179667973298639299297041110405233188\\\n        728354312033451566803659570255087274782483278524663442427151124409578680430621187799316305\\\n        258967690909515617145316564872066240420937829565997377131955003565049205929487107475409302\\\n        173873197226292691747913536403412280810194374533150529705609864623599865296905567914929355\\\n        672640135735482841398026069528678332107857864758747902478544208530721958551773365985044682\\\n        670049943044778960796146062344773805612325206044593565361008616274356577258534515611509096\\\n        491554651266248202381631392232438242622432487907467975948232459223727172270046484519876265\\\n        760357082942948004239534488912218858006386732873425059893302969214925487224690642524622991\\\n        774187066521876050405680875379112027799066336460266848445444438094496351825591067104667300\\\n        067348297376903901535808070507647906128206450246578862240790315673442527154943700614651212\\\n        727997813519836989095168309162704490146689577356291957783727061642258632377540599547413820\\\n        227468707321692287984833427076296136550818739055433979634968601852866593968367402789137908\\\n        030477361221059547656914184325932706591124501763636742313007492413798411180580483348580494\\\n        342899901596970512604770595528493674404597275298907188743611840243640851193307923011484282\\\n        127249953578182485853749777549140125166780736619372481414469889818371940052763495095296446\\\n        552618199478042734417356857059292022938345976291469326185529441183466271551229454192214259\\\n        454457394999971360862704978989094530058121963226072442316071399471153889818130007885399582\\\n        616657115904806983785352022650368212289793227352536033728855831452107171272218634151144250\\\n        592764698711213433623691063664974682628857612785080812295388662402858289167402623066066658\\\n        237807197117273505515935793570067876585165906784456595910290121429811437400400923611205604\\\n        275726486457064658889999646069761867812233680792002475064436219608020428155850100326216553\\\n        084587653013780119665215400920097968498819851812421942057239668756584918547099429807575124\\\n        879110178604113366142510668853685363840384625330223589372756786836732906723675749094145667\\\n        354868460536624958542897003984223562600793057725817957501691695844277758801345516190258776\\\n        321871218122120354567722234105309027867514788494845554700563753372026682475505518606562805\\\n        227608407096372256700097942576826318375372767684865847703172135598358136879549019960511922\\\n        739537092359217949803883195155134246729430589804463997179540882903407830157960152357752394\\\n        520052207791626402290943808145465348589285438502692452118725044535820130676248322580992773\\\n        306906950712029792922547087179728190571996231100878245301286623421981976515101741296368609\\\n        995615288538051511116488140600185545850388185630968241878876361183947303775102103024819146\\\n        434057376856403087917049980372431992597418460267961842920061708061457023919866131359495873\\\n        982068985058961850002802456315511324108245765348601725521570956954993317912757677750107542\\\n        632797358154628077236502661384365510116147897254646154352383093554074508067908944891720856\\\n        782753590969921454492337865410528321312402935545381495919218896366034772639467414570325525\\\n        700100387955672004577071041507201214992101220719082364136031084759712380386634672249040889\\\n        673891958922403473529996309602340475645055532817129425532859540237298364502035693368294352\\\n        469253875997590709617655392326283383109466625253852078780296929115199074358457284678935866\\\n        074731960493923668806092460946062120420512143904010667487175916829828361455633303437240877\\\n        538767388918857547704911252115207348405112799550434986657138252953661748953714112220378394\\\n        185378168236952420361371266115618290125341936767369979157659825779689012206624954844238730\\\n        171497840776288064030097498296675770050706888334414650392641977974851683546461376676350822\\\n        480083813955139265080838884638397074822290069099535715106444975654788982979958318544094151\\\n        236633415442775357047751485530685674769560330106814828676903170739440946563364283858841174\\\n        380530414371619584790461225394422744975203376436954700070899502677962042297997812764390339\\\n        534746697727807128711438901785696391109613579380515550184306368769213417969599990226483862\\\n        830734504533290358111543979032940401017123961634731523392406638766522755005302855354053052\\\n        543690977057742100615434434981309966684477740957141339742701351754065569019131785926082990\\\n        595407975500691759352253997847639892309060834130584871358863668719710188924936138965304086\\\n        257592604098595016867009069472318704343238080314941857932574172567393237018652170725206729\\\n        541013597927421102030212029889930383622051541862044371683551744386102210189562340902902670\\\n        851403365331774091315078703642734145665875356488824054643007535064045894232417638527262093\\\n        621434608452125289940103869008182540385864967733428664593767373415004665397718330494357503\\\n        358657644144923066634103319837082397439851819295958844879732009861023105711438130254936624\\\n        219168059244658713987316695641782342745016869649284852425484439414494521504549515658202946\\\n        660606150707301792795684860688269102035957246905755071639666407696197017241718756302980742\\\n        797662745681388288406679607672744172987906565631364968390725252816250605636141650235317716\\\n        206131531585914777372500624464833881899936109706048600463049078614615552179915963564265832\\\n        778804553591161118896430978554485908357188050235088267758508893123602591729583277661042332\\\n        635683286617532661905819985439666018294411880762459033489795742069808823037170560158021415\\\n        700312900708883400313262644289025110539482413213624269486548327340899363128285272708193609\\\n        408755812454621081321957030212564511908499972261762508127776108975194014528158620280125857\\\n        744313740015884959627954067357952282541458269985729743860952500732526181746501688392723469\\\n        597670936488444065489862337262864488462343422794322547673457745053307654825678098143199006\\\n        255831262792281337999920490970094993080925809991952389862157887084254413743414341313132296\\\n        484820423351321744561772618454574732989975835470587096962707851165374809361825037019833188\\\n        050194178421487062554323131075188593533573126432571969531229562395773190447934795284984889\\\n        806742457890984003315576072857561955822524587134188613149679555183469087523669673703708037\\\n        535912352962287109402691836308005155351360469630171921562203517177511548669621735240455965\\\n        203353986928952759066311928438300559379370821653321668239212939110025392884549180618162852\\\n        543492973968827257988618983526038126908436699645985476762179317068113659030301382570026621\\\n        669486796805414783888265147080310955700135462859134873144220732180294009423929989236659396\\\n        927192489167660809791065467705274008901861667305354345402094574982745580891197856867679078\\\n        594733470487495987851277495136317834644641506231061570412640258486840630338189354980272703\\\n        168504453859338409794029050656506969435241632432352773073017338370508779664466661866333982\\\n        623671693617934911099705310785203355160833014566137387664146766566864587475958997155787929\\\n        440947284166822046894292234103645105532608284647346594832962642126496579717367494151130637\\\n        582913161459633215497531566577955836195074131052261528465877832730547980713299898442549666\\\n        972371441551109236061541022139294176880415451818616765261104826693333535165907008465176036\\\n        941153483707182133503414686105098371066169847298628080702276371587942249006632827551618791\\\n        383192974090202043789610513394516038410018600235716724447008135673146451727955775721438167\\\n        713521101698220986211876120231653910295083840241141316657425620673346607383106822181401735\\\n        418574063058576593356076520208439649686520385185219368056382976954217650958474511381866348\\\n        827269168155496150259791385969885111550122245578897459052231468904226719806961538985047368\\\n        075235072488327200464485639836473201467875672884622543036532975634708971737184655527306674\\\n        815211767201044458160348567496234056166767683725789118335072159318725821091630832886531309\\\n        392417807460025519574355234588632439639360825648315738107751210657534288018933893460389731\\\n        201584717399474417625301495550132890984145788081137243505907505209204491077396433536479250\\\n        424195338097477370854525001522133680607474837404689989967658731790447207744243297211921188\\\n        929720978948994030551763149928505360195381415128605720147708107309331186477619789156871594\\\n        443775907395412388877763477006452884290554870789684001520065237540798976715129077824117973\\\n        859495880847934143632436292418000673569289900938033108962873954232616237234897188485223817\\\n        554520973806277951920354453301171842089815045487875228935459775577964711779001345159437534\\\n        136660863969755953642200086432690172000619477251125237796130387245949842518329595933432723\\\n        136925879643809538615337999071640997639748803494723378079191556190530189683042811264325795\\\n        607755978487900368255008422167896527175743709802282170960146987700082830152248334177218369\\\n        782286880234838991778948484337604556384407080016777361390796726748221479715415323431570846\\\n        666931178702300245218099045179486184551514521293309564119138355418121394083929210553335367\\\n        061968422818847873138165840782161683098130962720978127889553631543502680362494562548949274\\\n        297232357230864529887310357323634739854476068359068381784080575579919124497582871040813018\\\n        942816014696763335269596050430134126014281309543521359742144644905182042946567505679933414\\\n        970602788775964550375153846056216904022865101460878252401787632363329611250293762483030088\\\n        841266362017347564556720380349801454680387971282823493914843284788472500185392980659476706\\\n        615221645058247809683806103186955080545861514253347002588629304095402771197399895726279837\\\n        649987308386968500952987840611020991635704250317226809159014849108364729313708151311128777\\\n        985826165341199345498535951972825301374579563732245470841107102560053551613930148807539436\\\n        337126081462674959382407271706711791166671885655916764152776561922629055221820947290541709\\\n        019656588576019041360506814506024053399856712840748696984760722881347675975903867577381744\\\n        420206492220535294630210911021151651148049194271995534166739644702156308576571535486923807\\\n        731670314609344358376616514768407827961520050055275739997560135747507086770906893416097012\\\n        659102644451015566436051742174577141140240382298681362140625605691690764001272656874290065\\\n        192902859585745285875236530542758538393506735689165939474826737872793075196188302285595837\\\n        967717275831563935420733275777939063474935945834531150476951539758476250475446339446484932\\\n        733983357829045097007313972001430902530254143674366989216933143898022211841740335776052163\\\n        532986656250962207885457533170744246681314939649919089758961987473969680381862495941318531\\\n        458311214657228627416084082809006769853310016540724119500341765981267030106796332323755045\\\n        672517347785598807445516764246176746018558581339203397653985322951173935029961809237546872\\\n        898000802042200746672487077004655180089748650068589489648494273926239442252041115890231088\\\n        452313240846186155449461039209171903553103472187251278975974085921714857610004388322669195\\\n        893134175204953586047152433641142479742935408799718880155936157000759014144693710144322866\\\n        145714147134983290834409251043677617112562909314152502889554368595445577717827332149652698\\\n        991754090947246228732633934711796212696885146883464318471953506638109743291284584509302220\\\n        903889571200429371989474891274388700676483109132082651608375434850468180314642790340943731\\\n        930592105000771802054348891355375156168983825599982690537042600921339839153775782073418990\\\n        445791932120999540704057634782240235560126403340604261652174818434219893640872605488351944\\\n        334857843015208956077854557009449052732271773538179863514436986649888069004640672310776323\\\n        307022273914001793993636412502702826119662592906703867901025126045854516339829037040040948\\\n        485870316077845700127735787541716890145628190434400821784543150549754549877301238910644671\\\n        599997404309617472520178067129808264512104949120517778815842336201657197026983397583793359\\\n        386394851165283463798267664605637865647665198968503889850724891300784147439005263286600063\\\n        569550971950398147611441778577956189636701120190307348791016608304888239216140300813322479\\\n        280739154285655970576517870070095065360973959465197467313761111986963218491149064041999346\\\n        782356152502272114588343025730112674396503294602858387897237659097746063219939503175459506\\\n        049295731661203721057937952829473932322160396704497741446256919743107736557938301901582346\\\n        921959698651357675373143131820666751009248893800818700179861662523968338968062937366072135\\\n        269447002921682741525152616553305824888611469638786874190746704743458392123716189515697214\\\n        892938048447711660557609469250886537746601466470413512768977722654786637409832248571564623\\\n        645738458774874131959123701640859962661201904518126242862678059902058315228786506877674420\\\n        462945951074680800576877978914403678055067234714888622341444535625353767675153344918686605\\\n        438402722946508734768414553556129590811353584350116404906212162312508747700846973538649032\\\n        332723615248521921791692695858591445414680799564761106943266983479160274867620685576940433\\\n        285390454412319688349595905540108174963901601939092022065116699698538761768300541804872795\\\n        606065450212238103088226538281196771493958098950662896408903794175225043864473740041246984\\\n        469092679224209874255663725238245498596755506460393856841638298927364384951389158513305431\\\n        472728450486876049277782394185010904724709023830056305201942004657299903460275793061180832\\\n        060638596444245345327170108859335780364196783473216720603049611145960582534818033933802753\\\n        327030918895352947335009183365663627153300188297543049651154040728752684940683677375519221\\\n        950541203265843521674373868548134861807520947143386890032142743690454182390983092462580360\\\n        845054248726735009660851180766407710001891025029276146894264784314926161257967136282582856\\\n        967951571782449153655271838110864601809500216686960109494907882195021478774107061870477114\\\n        561591636446855026160805310279458307839132134497087942395250253289733813336562918262822829\\\n        150934265873915892189241722015213431982545940990170999076390784934241153172704939887387845\\\n        510961836046829585987242656291275148468601087435204515600915964680033791967896369704837799\\\n        467377066391106744070097951544579562730838666999883589513633404142392975598040467634078295\\\n        989257960442986247496972578347817037322069022575545431978104529588573250859147279668159148\\\n        580989481090511479320871790350081669454294455090386610904053325256882104161809213016894063\\\n        386090309951569733416568731445360702214564526532031836797253024334335625895441860418790215\\\n        439762452592875984585436552088344391670338458703954232966288987197087890778661038239548257\\\n        707995915794319447738714429421202215844948565849611204556857647765963841006220855481311965\\\n        438507705023389841153382893893563249950682033122851345482301957437272608145065074238162807\\\n        825489428957871130096817728685095449832630366260799239435109753818794913882634279224417165\\\n        173314704292383580424322814015831342947837386782712333580623085788424996146357917709430288\\\n        755208908557167665276774178865167018309581545126595481384836080612296674693029413779653791\\\n        977188488652317962858805641182515499286756134377862576885714945582716841870840891072857724\\\n        657479917650913031986646000198906562167310279657866367834496226977305875929363015901455607\\\n        018664841083892226118830873389240214468674469934220184082968895504521788785081292235412269\\\n        807049027771821000996334820951054522447253525517757045129317227376221258471641633781964982\\\n        633972844214227084877428547568678558529747965443872697946190811653229801380232576745745892\\\n        900816355973380666297974788188350619191125348746822912293915023792933723544034178028847993\\\n        677481838029344065480887928113797457724584306779759537451150386212227914367941808435187726\\\n        486266579592443119146971135255851111155023824502854113532587178917705868798548415893029999\\\n        069383396138308887956582523618663980039309563820451073356224246818342981909755913248968156\\\n        923384433381746084873743113248658448006965505186184344226639843912495676601092614016678425\\\n        048936573940151995631468580800598632566713078460103567671490106211105873620014819057126083\\\n        731528663583240408278066921194451448966139949111178071015800208615554834344697662500803292\\\n        887559119532861299626579816960925266889270722242105903064606865507158410546748009644195953\\\n        153025874694830978322782908542287018896666658845641463616128478687320061396294956874290763\\\n        999948713569493736626932227645599694374927694042719414904075096883172239493347306178042173\\\n        449804171228119054151705527654011067738745019820138283577449194785408209892511327878678234\\\n        138742494758202547469030971727906654147707504194778424131706196184009675292993119396900503\\\n        908880452103152345003887274853548693279564462594734900460445244057785248054300857899291044\\\n        238879303423099436286150816720254271472121331134827064545840371228876985626216480189054975\\\n        348367037675618635782372362518243777911951767661731099335452790488495484825598611574761861\\\n        201180486292119724300461652901986943890280475006727557901271311274501367611177383744563720\\\n        594931279840861195414380218670014812371057349874858621136466099987346653180030545712797337\\\n        243121679484214449676179263150393315434727960325634450736049379005837128371272232261509785\\\n        423206967451509293722664754397980026666896608847838340726457124437605632525566387538010836\\\n        250235226139265908555131492354746500692891747139340123920506152721468018877432734545095112\\\n        690656796191376082099154919214966234331238515694129060220146174370434904550720093161867020\\\n        513792063868398149674157341702187098242564936431752273393954293454470887025079782294537239\\\n        742919561105547819597663645352335797454994753769178044644901530465759855458350042910112407\\\n        485992487318467819852289240004115486599690229131202092653042184132865284986822781573833803\\\n        465379827488149561058457507820283541529692056365359279044947337883791567406274630876318864\\\n        701145322055878852713252013961101046639843260144114242148342027470462947184154343415012153\\\n        383469080607963823515752375573863647390468894908174370772553512035541265253463916261553969\\\n        470817126246389830347311370781465945890705157280444558669158551927888881314474118126863440\\\n        025488954391219091614046621902517641152602608554961188815550930705175493536824451387567630\\\n        751385214121621111742123876705053496665306422089719898833139806000833807721655000102869640\\\n        947887059199383681521984929616333266784905628579137350345908995801205930898254449411187030\\\n        503450942137962397947415439815149756290492793141838781480477886581940021251575489373065258\\\n        253741331236222403780755319342340155162314508458410550655177413213236866481228467004590711\\\n        257186873340957490948126491119820173688092429959923820433249527611859484523531538475923475\\\n        618682286622841446704552291543156945936211784924578799145619870370781086492502217423845951\\\n        118730313097544155065027606195874888633366946973802087264497571002570046297853561246828467\\\n        702348760618244608449415200079548254044254565866809706828042918816337765727292693012132390\\\n        764891434686870832629385118039461619134792918068314048000965698233840527031228154224422762\\\n        916988747548656722384983251504153984245435807339003367264133628007200406697122467010597126\\\n        131420264483912620081105996146416058301723891013050303013830533653292051555434591055753815\\\n        742824451549438828172733223172616585115010010650027588353753668887897029231520788998675477\\\n        785873469759651214362490376006237938429232386837811517222492865897482868197697995363912286\\\n        013238370008420465663560035663992897816766716919765253146488008005146428440000839529556280\\\n        585534915532758354738705590469782415706081341732737113487012230528422770514257841282218367\\\n        008294999345743562986496617235551245802945440140043871829374497437224100013086451589019151\\\n        063151868141693817273282942725188087982725571219558573927651454874287359077609647012649966\\\n        338189375136500817556884841066254143474500916744470186127691891551019688920043509332794962\\\n        050489006189079240192083267670685099788072156844817300922734794308346275263612529261401334\\\n        816113147918008935552497575090652970050254963807888835275132584065015446690388176004412533\\\n        161675589249287342765575311728930377146896882630963416676067527942830072740744000637552537\\\n        126427245019108987392745112050337871154517267730032980466602196616471186328191504736968537\\\n        862974428870322861430216884796281021252168211000694667192636076520314906620891401776407408\\\n        565633672160556653696585415224394713215987736512582979057105773955128048011408985380362314\\\n        929910028984967237853773672050750293814827213798180716929041381056382986072948495749606020\\\n        262831205207050075631437416697163554276181157578905742973473434778002383772862474440108082\\\n        357807452430061090658802274555215860288765162422410717302413481495317603440270497420058115\\\n        209495467773045643667949592083173471098685965881583879260367950825828336166349423133658919\\\n        007875896767224883758166502247154582960667999878761472963010897365479731406053539631871631\\\n        171689993477811313876189828563179079651838385412077888122351084719782507931944464599113083\\\n        041290951278000684977590935076859182984630149744422636564393095734650008444057709682660549\\\n        811583718760146461580729305323882934028493214107279400867335112940680809229968293803965245\\\n        940599316455385549939525148456972953167145711088501489237824975980706315875503774607612372\\\n        973341291666142125833569110503676679730805631358445294501219579714600978461424432659831337\\\n        817456423902196841649700017247570501268786055529264512930259570490710230269181637670917708\\\n        760160114219187412301604113674734889240250564149528135842057490439899013459072693967135525\\\n        059578069840711704303373361220603497103790275583153943967572363514763363256601873639794356\\\n        056316598362130578380149837930740641363150587031110123757748789705090310553171229691807038\\\n        191895576888824454796782062571576099935070937635437895359314320355334587657467558158239306\\\n        218306454826677265778254993143628351937778137336232899745868382179004770783757434677609698\\\n        250941304450650925900803846720376141367261198446827265567723096954360210082294169941365520\\\n        290588851431997825061558502567117762882688784301198455720068507108688371741906762068948399\\\n        987421234140620441301163237796218097099283301536035863717280348822036918183697898734797865\\\n        802973665281309338744434075350256369106889255846305314370941947427758356627643364451395592\\\n        553201383008327886076165294170635129802633180119079853140897242615367352523817107467474096\\\n        041491467180092351257673243130989903384860583320385376253002691167321867699528538998989309\\\n        366569319089222109440335088750034935899612408907567854771713273356411286450300257262071790\\\n        682857434133697992058138059620945811978859713675323917147847558365563862310790585977606110\\\n        559040634038493599512892351148019115930544649747884674285809260114577112279807750428326866\\\n        613882570431895802778554330492966801114151599312777576880282963179131915336545355792386156\\\n        745520747345340107710302070040341635037514080191145078350640341080910502687267873130733392\\\n        110840983746192727490694293466209482048244741517598376724950749225275210984435329500243620\\\n        850019579897751734051581797251343308138244388898261062657225576513391367654197837521621226\\\n        047770400492356319766594432848874569325567207346204888664556822244173429246737899620767841\\\n        072535939312015726061008630046947899975545395534737213271286228839371027046737470053316474\\\n        941479562184771478667793359029217450481529358238528872033283869460662584841727323746155880\\\n        281344277545816887328850117087817216856627850574955104625193387467285016748913363754737376\\\n        087273211959492659223654184743160561897457151333382477764264829457422427381707292358112956\\\n        949111030564150698483060673018173666869930032310177215766914962382985015763825079928931084\\\n        942114495122222333646653441726533898572442256139051126026587826668959584945021221319019381\\\n        192686271554125934139241275625505838895131215601590615967165486683919822877241319414763397\\\n        580084760506671571436452894380249640419996862552542811724636031828153547154700579933798001\\\n        767317156549895883989454948435218148508911222245262829823374732915181105073639589778030437\\\n        954328106324957289510132419518730619594931294601410424484045930397160866745272654142434653\\\n        947351430093574928591994258529530402066577690545441088029549816116857912203189055610562420\\\n        921072541645885500015028306862209881437171928900407659747135873026736843142574029034986980\\\n        377613953355699312036455529882833766361318779971730107748013697661054432289928242778107037\\\n        724663906215818756597766628320363525742768520155007589067459885837624838147884439099789073\\\n        416203695804869860829133132063298968810134675982899869521266407417552972281203795268398666\\\n        030336496346966102248965743578028187686793359357244236988441164377622870030431410897300182\\\n        060132983855115316779020083820856494077968448131558794965500167784084485415915203732350542\\\n        785882013213766386794128283881950178184031058285972862247728723858779957859858482506411000\\\n        695476619204407121455535854642870222786380746292003790979786095079821312191749209531657965\\\n        663043138727837754640236577595368971277718242480085384802788530645488262313190736686523687\\\n        635710802308106882747657265089551994245174029170756482410187724102383781219006218384928179\\\n        989677671778617019754680020928059381932252831330591029852546046357584592056422098859579772\\\n        087813049907086783787325929356142130475210918225256462255595148538819435809550137228406489\\\n        313202311518014025172131749019722009307109977168320320734665858084157126522602492769147386\\\n        896736955639606722133819186464189942323366548884901569117947147469415998827024512255105208\\\n        272980225160430844984642521418689192580858454960376890607302022639103003964848764208289595\\\n        927908986387445793261194650433491820864185038704795653863580714441434900916796557121086402\\\n        672301891247218522501781720362206736884735194807305816937982590346386040844947224815588373\\\n        693913557223402395689125506696066429690678430233369653262465954787377997019273018892698527\\\n        221450857462869035536345154311394169574404124430165515130694434767289236393466432557858604\\\n        461909004850615881362437396126993740485285202446229981029726856965768549665898692255265060\\\n        666673892115905260439629358901354804868012932961752058452846541846185991575754653014334150\\\n        783602490021040465544724874851810694134187325973911364868107541863115043854763904404535190\\\n        482343854724888337125918550973114215562659756230513315942499770080785760147421343435137261\\\n        152332567970930718117569683615193124252810502480358778211790272397047364835954025061237982\\\n        322980000390004892911221382907165132566954214712078972093883437130632723722060976986592218\\\n        153696946257355900556425741819115012175522737942889603561029205694424153523158326763697440\\\n        496545989248328410973285210959250861833510325187130692700661641518908100186663344207799022\\\n        275057487183678916113081044699424710792516744105587621763651386727016994210907707998538036\\\n        566405098741010099554322604347439707144300846521522114835318912971640070386674462716421998\\\n        110168388489319474796122650507909489691933049442130066221172433180336899889759777740789589\\\n        014154404275765663982838481439179267781397735371951145340274944889370842298063683059568542\\\n        522858955401764030895126350059418648465648301451748419196552658344211471606871368370186343\\\n        056657857571340160402591538609294389324449072167351115549280385898765985293011194226777927\\\n        712059112507052148169049384575936929851380507642626226883196555231831346948186574749503247\\\n        629752889556032791462254544515204976968472071699151555818633560323714543102460585009530957\\\n        700944325343307058668030990509041465415676800179983359030484918452195136143209927441068023\\\n        301893968443360762539680447833687804535382281582734021425406155956415784304393218053137807\\\n        238186712411619126526001323310920256313449908844740830000169468078749879654216348414217921\\\n        502871339946285554439243646026284039450655516067707576489486479478024417605883652594072069\\\n        123720432511122817157460073399718211947599961450321448554620421756564195101592370249640116\\\n        543498336550752411062509269917535101758241802790255584301029937744508820451669596977320838\\\n        955908367099339885597539060338299018311943601685281525686569633224920799327689467635814976\\\n        567779680299644318548917054480583308145690011730106248666618304007688488132571082526965390\\\n        027116844562528986899673622774111272100550823554637621659724217525476103280204654121673927\\\n        058855504853241959246483922713969223430301061442589295764843773424701666062797069575236407\\\n        850225829267581583748380159135779851897164469129540250554327483476557147572480504774036353\\\n        110978025396961373407252768718289741650613192788266963871727686738157571644448435481041694\\\n        064763237086857522489977013757196753313007848973327986621156252963472510074355337672885273\\\n        116955499093013657418571036878203403245477264743724954618000342750479677719512125805238212\\\n        454146694061242588437532646234516227247775386212994038270444673878133047218221710322375985\\\n        318198439158288846740084256552484419744016152716649205676254389283460420891651731799413347\\\n        321426880953568323868036730000986539269549418372583362070250771285086397498285407488539089\\\n        391485963741812091743626604154394551405547437853948986896413887585358958480621482904849965\\\n        071038148694631274855885489266586900004460701280726469517072603679834578535676727361931293\\\n        241266613227363537475168172182967867082341219616396144478513856945482807124944346019960298\\\n        211861684893955551954921825422643005651417118436811954934793521878155645150659385435287953\\\n        458866626802006447358340875520150280052912228325726438908731105575466635024059307769423906\\\n        960244826832722464251787269079802754003468840700353790533063099550067375564275545193849586\\\n        314955003412676109749256121196546781491689679790890835826890419087042137409018005932554625\\\n        589601299761152269899718855730716139062528891702227346091555177275360924510841643683831545\\\n        619710348813284635258582101049383720595715014172350963450733283357227961018433727010510621\\\n        083027328788099424391317625536733463614958700632999130285253353590694927700161326585995711\\\n        489215265844904011873482969009403210536831305625641665005644727478073955878058698979715868\\\n        474065123657604152895408623274637714346252156859884865183897151083755144148603524212996079\\\n        588620636780864643423254743783167473339562377105749685696010482868861178093898923724843708\\\n        390642997502433278466677548445624101856306714647645504973651163100310438100178169285587409\\\n        040734828968604645232751716819081715733043996298570718890483691756232289275061916253482422\\\n        850168055624662004744494498365297729349283534368605109094036398662787080449847080153257879\\\n        975849364437672755865354895504785501007177719339242891467630909950216366999763877857638440\\\n        346693141176732029409145717127157878963266757389877432162295146501849807769131755589294613\\\n        239447671412421027943073074185436580015411378342844662171533423120599992725780574341923043\\\n        216989470014307425138657704744941417902212582029539716065263612175762369872854811471910636\\\n        617842861369499528143950214516109010501663678380527735689048143907872594240827756904331543\\\n        965739680556146103037459727673595562443699618059410070687676216098487099935603146150960534\\\n        748550186564152325959412287528018180915111846756115779924898181238993562258108292874310550\\\n        904304290147801362196665652182941342550783299992150547033539534817302638735582940944594735\\\n        435516961950498530027044255372551026811964025143105831695701297093601788566970998068650623\\\n        931197394652298079910566219590432173125470221868269867248412552237857840341360084437750528\\\n        596370514590581841411265673435586081535363511465451158206214348437620831831374120331033747\\\n        295566918828444232780855049486154229181875855736509897941986189553822628451125399339885656\\\n        686689182652826095605189088861406848597217499569605003549625340685651515105493754381533370\\\n        604607532628301247519972764732857969437498866894204308705044180943076132486406357187928872\\\n        834481913393738308036645903596988029263299881319615644438131408965927988576732990771021412\\\n        651520163073028967445129675179829220230209718631652391329940526208471494031617216114087112\\\n        031747783568880308302983711956954959066280892324579787698413891521518450740862515005213829\\\n        968173782580769540636662921362629103436498707306551642471944155974785105063525914510291474\\\n        033380556487822812711209549683732316065473460401895195332922915825580386623156558207402442\\\n        488745268948595326219719773532223996268043376136366344828609870582675983230260402039856721\\\n        802341639254829366408576059303752964869938348631295753744620796408864317393125453472362756\\\n        943340223021607029261964464916590948100293751120832563649683420824674400139998206956081636\\\n        270315677656882379530030922517431997013457679785973217302676308884097153793680356170293966\\\n        452574921656764362009778245786782684775807623342688263917887907999518694262574475578905754\\\n        432310194057960384805652852283458476610121299200339934392235943767677597445213085033652546\\\n        934001804044551061679262225156451597402822875804716523643879325648853484216548010456900299\\\n        379222966791052790127090548094314767088554380350268179446777334992183183217622269111888518\\\n        386988349147825614344666008349327513105611150606460358875223766479250083233424898858597004\\\n        352913546872956034472577380620014481388756556445392940978280324291152294437428279058881026\\\n        626783415737654349200280732682182417200759757973202832593874001364666779959717651008479495\\\n        640513628801321283722029629845380561010712779489624347389433032489033793314430987641219188\\\n        959700246125024988739795402504396137497467202945784392175414894611657116744595994473412473\\\n        966849829360385574445011758496563668594411215287055760380904433731006608047285199840927651\\\n        624515277362125688625661006510910682315930915711390632976468888197883279759305863656739556\\\n        859582567954364623966603122009165175453680383363406894523713603977429199048405319515067532\\\n        928137274193419292252518957936672201616404632818544350808534373900606543720518113267927518\\\n        484881089166476716065619373182169584818418214604113726929750286353032358110518240532229057\\\n        723852967430015435312420309240789162640382556722350824076007367378311586014031067481966443\\\n        201788899198931239216481326850961022743233479325566187380684276066268777230340193540774975\\\n        529949525874726746567691386975792595409800376937058837220818246939352374947644353652598261\\\n        664922456067446957322541896847680681903919126876493731567770572400019016843745093781891821\\\n        518991049883641884321365634000119488837520691560005215144772167599052898831129169749508457\\\n        834121746421986118289912677438908097607170990927887983676650931644482914342648360095743055\\\n        654942617509664002176780816218919423716337353248394272720432359926408175689475808104128504\\\n        365667906410409809335977607787446625735608637872314226181742559384796123969845263290520756\\\n        487223219360592374069369392538571372184327804939301336171256498842445425134600816221171046\\\n        900971728383246913124300054976618318494522425703761560191830956171171237585393192994115248\\\n        261398403855979432813413027326497172144573066741138529444036347260686661416638804629647272\\\n        027903823679138549945962471149273558796624193315660183545076082186608651658193076092470586\\\n        772548546314622763771014864414733683434498078433551433750102983751672123171081373712317652\\\n        630587775644474478186059461705360160396528726036490871386386590404352560626215664083250738\\\n        231396359324811440679784768513549897029926150313751782470984473136058270271347183358413770\\\n        658743292264626621154061590961214823642447913907821205677724638317421412150326273591559714\\\n        476767249669210282001140961668542174466171489663919207051813821322176550228294046866514412\\\n        162215383449640031062421323715537696957782260704546353711502917745688671781439546529339499\\\n        514040614807937402624856688398016482123875748007689489176780301792352431415565863784175889\\\n        624556689692713587522401064717758465648879098412735773983218632698463551250037063782036699\\\n        026750116059257217336905496257464187086255629876528958272436416317979237961410543473707393\\\n        717848826982419190206393480458324661135940529477797873500996306259120811164436664774415955\\\n        500428981366175496765586955154568280038586855769877847922115469206037196631386024256008043\\\n        088666261803312556567132488711745735148635966793712388734013211460733027764561937401470960\\\n        793062313867869132558828702916408813708150499087085461537870229973707774808364451111316064\\\n        720517856977544336959756296977283745438875731202600976807373684874818284753584091438414637\\\n        056475076866097396577549177475690640939068236325451108414341238451632265983982197897715306\\\n        869189906076521508049754774755403419854611390990883948089120667175983714436920561850097390\\\n        079803826766977959953257171247965304128393240120758630692461550120949095614124111415088827\\\n        575820756884401281461807574121663873804575100796231027936031038108092214359282804162208969\\\n        338830648817861027827096460363446547506381715743427108332808134847975479161647582315634558\\\n        643323094847465725594424492373101625025544234496998990668624819381743430403200798307560372\\\n        299922621375882466515669675932685040724759342867631396876596473690221261448789604432735230\\\n        991683156624152893843172532996612565029189563476854255808394804586720886490348741906063781\\\n        979852872074375019500043564308847519598161344500622894473807947887546635918870760191286253\\\n        283201971817244622007084877146024121460320892016053881366722607056582001732200003548619258\\\n        670807548317141459552673991194861925767545086685647251818605449696962167362537710321084267\\\n        757054495460978643989403480404827650310457782450342010124498686185926965508843109298541175\\\n        892750014166533048429183802066879082209200090814516626970880832921084482701014325340582356\\\n        782639118463453049926700171258436674041480553440067880782203501550762374930799368535443199\\\n        339252278001692461952634269307901712802214947320390790726753982934873344392437834642748560\\\n        531366913380840494420555425674008120006550628268007133015938430360310634746238567565258880\\\n        255004636681628834611150470464589340978041611938443145217886582652546422575500618609347871\\\n        300965537083827434112534563400016643846330911151089362523882762967648978465403469684407827\\\n        000622816094330801939305383228303076396528923302649278906505522511173595420145790939538827\\\n        744420921077165048322075159674709794026348789888273779067232194877883145934283237011004496\\\n        017289656949794154621746700838045150706622824687225276223122208697750457123648193896115149\\\n        700245077955869044461386316145745801376428448892624279018314135959920660492443240976094643\\\n        803458203242585807054687013284079006587060758394935225792217550117373035220422174352338354\\\n        331478205975115003913794060310909059708563798104243854893587319648493209880947789936133526\\\n        740308914790744053282526299180998300427863041733977903954469904927654582543742949101353454\\\n        965736753970051230593000823734778520651194757772880400998360513078781580945466949027451046\\\n        561524435118854719657513334973642187742528540018549096029609697346015218293122624683248891\\\n        210524377103505695200113290000101822727887018985840100718264735653600179513579220193137247\\\n        749993471624271965771177109609621360389338155773605428919718928671186957911065946415127314\\\n        596574656865866662069430160816352712241399142679613879007516427100149493443986879524396966\\\n        129726405588417620114932462690105719259933609772285556121782377856633724419168366758950867\\\n        065818622603895190254580846738267560671213286658981053539859536306995464670571657227020625\\\n        591074640141926270564229859994910780920013126290611892145391756816483697162471151755877080\\\n        205744593788244345736856432138338752482971392321479716992129315328178254500414505174091368\\\n        701546368496010009293857793876532239352439814678478262669371074094337665696816446910185841\\\n        846359588560081032639075937635538304404279749287951297065728173901758669459463142465022077\\\n        742912121862896058272543384948036298863870195040207028236475748338689967184921490983061944\\\n        937346991832180784017579917453080773247152339670531359008677764414079017808682467358949716\\\n        553987371803673692175629800267730106600621732943341861616445978899056667446764706321699532\\\n        156935222427591091527570028272915837483732506852818186271359017831687657240462719980524982\\\n        308695847809460911855718903035892586241215546690509578420183217503403721205512620121648585\\\n        801905803150289892508764604092088148849036441415912836938581323187463954176830759688096200\\\n        062867341782020837097174867586348918062197626124620604993037715470960562840814364267979962\\\n        961267987273507647133788838309299283385202095192673228272113044178829763176828783671412847\\\n        357226527402801615986011204860342921051852935420203296075641557947482486969891378362254189\\\n        216621647759527755735347850774145173158055599602128626533747716556770638534633421320695292\\\n        922577787872517751509445701823461793036206333103708917141187300637796583574917608476198442\\\n        056363570709861208208863809881970166324782687861781838857265596076339162680928819159204711\\\n        003370614079361967009368027231235566297344330900632788574785800853710841613734223778191249\\\n        861919785511292555640942113192765287142639165393855949294444827086021835104539447596643259\\\n        946765132267404836565550506629393524414875075909406197731452357051223422481092027151391230\\\n        263207204885022797038548653679509394632537321169924769662325595796261248544041810715577020\\\n        278563552534048891241704929360387191418788227655072046667812088270139982893938120709781184\\\n        329537349828691077516263229194825069558354755071131820339605927724387195475485886461143491\\\n        301300301975846447741037117059673666901551890408934717859159229223441343527678600827660434\\\n        292998344403357654957763102423231090255849790120481174635685265788365366494872018984811960\\\n        697629449298377014461145230914793562020452796370585289538155624803245639856663539690424366\\\n        761629768022956024340250649446520055513028919313980155291870775597055408048782075214312150\\\n        456318984842089020928888806068306163698321477773566887893691411886206395570142140297020172\\\n        620173376778189101236922592242068294071758868904707733834723934524370858751729002405235842\\\n        760175015288146841460761004002439495208417066766709771704811573800143423573247946267852118\\\n        756109860614621581210916092976875104418566084022366637152160585840949952054962669672234436\\\n        335094773162927648774062573240731320039329141911029331457011084663113967203960455022667481\\\n        822966036530235193347516068005083609490928180763676495155190316762720695805910909825005366\\\n        264642032970659015368032421708287690574476124415268539967304461698697810807027534728564095\\\n        380439692261527710161362305300276993619626577054686443642538203659171353078169941533610423\\\n        577066966521193510519079159214249233898693507903059843399688623719189534629696620169711046\\\n        144648809793357536605782615021517875579927918433720803496320411194486222913896137777764812\\\n        517339632612850836012106908002540633075147198305161784558144088629547931336260374907822439\\\n        033748628440495478970387752858201576492320286564571123146561453742261994486128029084890967\\\n        971722701179358579595032260095492351496306006309825409705090218163266512499785814771522064\\\n        162940408894901222484528989206657874430820340914542866648357892827734392312065432388670935\\\n        541889329473491035753831063205978038936316936879427806791421807433099718331780932112462255\\\n        572838001477478761510475919306240204882990836554603774560038514428463132223256357257743431\\\n        058634214464322222435251551911166771851010050492795367235448542581829410575351932595163912\\\n        853064227234153698774315134040580366550489405417649317957786041413538250948021220213594164\\\n        321515479794143553730088113989874481090230406917861017085358009123003916187581225478198169\\\n        933449473774603839631887124457546336058318078907807281822215745270596087530179010741349030\\\n        487876438722733826005555437445931883640375618060274062583798319143061209655165205273908374\\\n        832205439572427921024274868673377112737260744314627067605470450813394739485980168715006867\\\n        833198485419169224576382299859055650967647571416196900429349145958282583437709041505538374\\\n        543323381254823193143292962239240311495190700190982713956487604589313186776115438446458848\\\n        012939274723984198842384387368328886207189654096077025916294757702823100421673729937184982\\\n        060563797278493576188544042413649635578556190308083138652916913017932366510185993090650168\\\n        274465414231738528959897016279839269797052008386424520075460254348337694526626695510378303\\\n        924246261392826402374492825000969869415033930791299990772383637839359377784142571747089415\\\n        625826670189158316675676013307128098768062488794098570578890323048955843610628878579798697\\\n        732549671171946737488818060353987070261408821699665356008497702762002328075649318252790081\\\n        627959067124044491518006887612763616113852038228258782111671257360523874778531332765523617\\\n        503736559500023603418048249248261312315545756331826586173396904515749020656538503878137373\\\n        078693780103343738014428630433179925859264216580192747190854341743656700550740285793398486\\\n        744663529072105668697632653530565320038484148927610867990417923018195081612293450498152959\\\n        392944380942953621678799198905062504666562399204442862998913446234202860596455408054273370\\\n        636476500993143155189288914109434357892253720942472534941810154121725633146606953576181797\\\n        861875709242807705605600286205802496388134182448859434990805278860387884249856342993260487\\\n        929691606087491660035872695423367664580559609321190619705726452070505727542931748299673948\\\n        369690542704676278943376687994231497094803901786352907015769313893501389377326900362084568\\\n        021285949162379203841873420376843885452660811964700236152910834143966063800470414032011935\\\n        812952917986644160095038876776864199144802296170480100987178860046099112647254895267178397\\\n        731946948852461106469409887181665625783417344383419264312768580686470294704434326543225195\\\n        224913818321979758695051574573513120031428684176930305359738154190949882626029985974905033\\\n        778047324825206604908864551497304191001272904899711535438277255839603961369244798745931413\\\n        153111861737480731757861526359691893347213106068106911606038689893548484786845426479344109\\\n        377382031957305273080007908525939083992429499091328224055878883291789087214426648378622748\\\n        896399791616641387296688850233502889297619226651403163758146847724330308856027455799946262\\\n        086668936288084126862019801691692671296381636358532981867796704027846294551100999364983084\\\n        297196473223832047429360415895383760283882496311411563554864660955659924712595986404218603\\\n        178110505429675898708725419056065570150778104108011060616754905197198641385054593234033069\\\n        492145494050737313308446640797483183552725764933245306270860366864412071155263587070154390\\\n        105784333067625234347514113614629399910230424178556903092260818479748720864878268993428745\\\n        914178555948889780942446110504009895831995790147793760995675541327461197805097965922110057\\\n        656501181754207700545587715985509648766580566347050518699661562986553059908032897436599247\\\n        387267885926490097434764797298254407030061798560251538980990354204288437932747097937635131\\\n        667288929953279028011040838750985400737948702870099851051763125241204197659770115982180938\\\n        533568030396246556194552094300951647433416755315501068824865063162416386687369697913813910\\\n        096132302666157910449376343280122956446639316628874852141682584699474557700368922513422979\\\n        359709797903662735084544262999617246961445213158450878162734585596651695494229893561270749\\\n        821030097229003863752472500065972867161551937625936551068485120495484210800827350902308499\\\n        398616364887775945769749127319506531737380871174867005573115440347947512879593426189448610\\\n        334434913119343463863051341952373340956441998490841060851041944258095903854040091297760624\\\n        254425136755499288773190649271169824821957179450398848094142218059553108734194448871320466\\\n        856882712834085342946639515352866445288925199415531862915694291145720492022076946328285041\\\n        230212811437156000829395837127682149393135594865921620957352213803298558498097493830645739\\\n        516536980977636910978537842544355897100471654856354303453035454924651558548802738893941666\\\n        603421062301133326376860054173314896089358416938198898921137016894841358039387986347982035\\\n        285973549398100509750500034254529509963818523668464557295156040469029834602543835237816931\\\n        101051280969067611132083111025359729105204199731387698943207467486643714229967949571020458\\\n        713019524402361377373547598176027637072326682002500206878341841829805985724473620896714921\\\n        479646082549785879888512584850375830512467140474386236599704907700898549556328506698101244\\\n        466052400589085501149550504269609037042588800309004823934579396153664668922872556825907302\\\n        773745385888919676734819078038255401304190753668260905175485812983509915417390071541999916\\\n        122518448273406678956611871416997605218456610796003894958983124869865873638002556068509717\\\n        632769850441564795624396377536242933264663232033246738542806359158815190916729177503671705\\\n        611039673119864383521120553219388607041327496597999182210175681601427612180729891524483149\\\n        819570806031334113718444199643769577353859609146397763125228330462979514397130066979218621\\\n        480850668197829354391841012561280920825100921054206536427629166650176824636198570393591710\\\n        211507993084952409266015567619713637985632398681787525885010107541384617309727164081169296\\\n        831350142141491508030823769520097159870296202565212814426273588684830666122992114557243318\\\n        112694974387493195121772610262320885431347566791482835683473635917737694563242689026959290\\\n        991615006899622947585761021590342956890527609826805014158304553772443535578953010811812116\\\n        445786598986433369041194171416459815056033545945788839317992778847624526161232711718517546\\\n        226098342389639398498958315658397892767300589599708838141435750337431327197070342323326336\\\n        980060959539385125205880669374712739498069324185010742387802378417014722390701295116083877\\\n        007734664859970611340410260131062471140329605702711112956680948924225703487197905016346567\\\n        064297983983407671787011608197624708181631578423606452888873412396972553448138911676724872\\\n        825412657368662514790182001878743664599473703281472089886904342451502112391608171442250751\\\n        270051658133367708825788115893880736725947701878603901313435479673619492762335929530796202\\\n        609505990077039045798464221283411253429176009203722951886400522285987484787637251261463394\\\n        564655972875310365309966710749672242705094931719620360627113856277483418201455893970478563\\\n        107255393579803434444504778910020493571218713096762591160050835172039208691968643585869299\\\n        826491606500398242013642871392859894686292250133793859614819304880457873212180427600752666\\\n        505759472613336286837783053611673871246668651061933290151056923144775978422551941488366321\\\n        597451396244313133894395026951140691582969049964759290073311045024857082374454884552476844\\\n        905720213319588017110745738616085959888179451446123512563731023630313102268522986058781347\\\n        900207769223558313621407239305298855243604188217428929271035835621659145265820534451440216\\\n        246350391220472116125995522321179080657497395559863476638647675143773946039690649599502231\\\n        316587747766438341509768993246406830674938944257830432954651578514908644258233117435926324\\\n        965744759724767415841936899974631422805418652837275423092498261030938827807801566116126843\\\n        414751028704173099098731557777980534786449385679377025059351570038471778087697587394753207\\\n        490707196050847628279435715215543093355362212422733727268552873478572782222459666746858887\\\n        219718858714830992725920227231631051337402315651657994239894144875348997635934219254518444\\\n        877280876049302281691568150611615585011590279813144703498786267903603501090830961052551676\\\n        765619165581831946995223326094797763850490265185620082329946483182308918789074315161176122\\\n        717898640880621634008684711901528789121051037024353320267875342325136162090209101545564619\\\n        877955024829061609537471880515774880400535422554613102648745859795772486107895087313862036\\\n        333762871422159828399976976828203901850118903725144157838046231102730118115332000254220419\\\n        939809506929796630606114559134493027242983442524274928002260816451104960043644325716232284\\\n        872105386680611853534466911547978130603797902226432955385675539046260280595788748645647343\\\n        568375457479936762840877179899351131549072570218954593235205660542535845384234275010197423\\\n        934644409311344952305309402569479405860310216529646731038530976854127986726957851340769968\\\n        414590451003545999074150101127235638467742366808555088451406132852128711723603812966882096\\\n        519016348229099038930500785173201554039789126780220815707227350156885318617573818235479330\\\n        685181680118536058209396483813491114112437438816990027057678138939766143538664604402558879\\\n        364276253391864208563021509369104410917088102914803478754746602358348279096269396591614822\\\n        563114049760501821004675443715892655242836931327471727178745945966750249284275189114487848\\\n        207155277111337611331303901103975161438932045969556043873511101912493859583498122853163209\\\n        911776568367949481209477674232487235474889248194915672281379128603166238565434307038558345\\\n        149821376726173246824176590671720479527619340624753172902130864161542931476638891719377408\\\n        012258322186933794318691333822337609170176765130077348747009842116832140902601933751064655\\\n        216304225005557593987190257017250751137248844525324921812159989443211212141233888668587847\\\n        890396370652369626924714869583340538681766865237480245449684605406225784929558270003309208\\\n        603473872033256966501329619515894225459696402201322332911132837944776697077677769691832497\\\n        196880040197619500925178555108993525307421946985819867900217553625928368548677374284555803\\\n        279192745543503148912874884170868131068012667053752661435166224101288737906790592074610681\\\n        748724674864323077176053367433426849963718489655402030921566813652082435325094850561281943\\\n        186033464508182733272518005193877351269818233759077678922391360922540586088262853988304193\\\n        054755777052783744523545125856505752416055469545790573964716122590052090524271466173418590\\\n        730801218081618730573093197542501866443893688878186856104660233258827812538623297732499365\\\n        847722947624669259996114471609977058276676605815911348145334262852236443141437579416233651\\\n        783463051113366129122562834277193238984117598550516771328091375784039261286344729967140649\\\n        338292334374273490177652690419121222186760383500186979113921713945961766599799824015754350\\\n        854911802196131153799852876034397588146647261173537993285012315020825808095590988899076217\\\n        250387311730634457314469978367840323967210313949718194131409638652300644597089085009784944\\\n        403053153088950793332340683579760490585797013961852825285310018344504399056694034963764279\\\n        573819932400136549064513923115943458788873475161946309713039358686751421451237800636922477\\\n        025486167426159510579333175512825433213707776199062644563781469096492673635106032321498998\\\n        290792884490369629148858735949356539249215757481928075042503331974105596798547620969425460\\\n        516020591558129345529466807011749029814423966158620817251902610715926483415248071938848604\\\n        036879683262539701986524291938150625799036004612236336742925826811113162126420159165439067\\\n        522150912320315605301678581351130525749021500558886022790613830599315764432313748383321580\\\n        200929878891990022615904141656782295421827325495579861476237156937111817482503809132296022\\\n        362688814474952168779554555154951203888977093278996856763325380501131190714718786334923698\\\n        494638738194466719971491109646804891415397437399206464063825761919249539316503065225307342\\\n        884252945013389306277373880182632062969391381497524446618795478411334945627334258006587948\\\n        239779671238685833122361770769116082728324219381598980517550179803544582889369469983187654\\\n        242651121765230246838216812098944367965926957443730093067055463928392575016326314186476149\\\n        737699823228207878093512754013568123502063678606553971480786920198978106452748061103367142\\\n        546727438406486299895037345399419745824612583508544243345981093804781845385491704448846212\\\n        610711898253968863043108941939740156495510161868441564928136692076561130955839537651933545\\\n        036039509416763348338357363875144471423940812194600520125566568344174071486886970493991377\\\n        243342039107913700749614967220122252118306134231255356234384819111116993644581220947678624\\\n        973952008595324376260380754508646958321395804286945366222783993790038180893424384263540911\\\n        247036507341899005900246094686960683149030384866358700764497319338539340051277171858594602\\\n        440585186154916210015456486106386628784559338603251531381568263170475827434560803068355145\\\n        974377781526014331584744355979966168425535711388562492338966178276147634850091266141743870\\\n        215855370621329006805508647787064786385884318444424688741014554396846106420322759002903479\\\n        131024056570457169165224733618679177718767231092224171144280832960759713314037407461590432\\\n        013672159884325608474429677688855846444840834500907332678267132730032157529202407326270672\\\n        115716184676572689448690169006182234145224042442973172982112125930785742832653715570506217\\\n        846343308053043596574846376135214105248334646672947998617017690475192638253701077002286720\\\n        385499658384925928177464567749201352674512439071656300212219254728700090640717747174248969\\\n        132782390648847157287962846899582203285160048770398498484862588056267898981476611064097584\\\n        008385440869573325467637846352099593533477486941896882414390798786062872380949613533141605\\\n        767895224501767149484752248782698309479930802009948782383850231360901876172286985999892393\\\n        830549337063856184219194437562419490751072697521841783494663066121359295945919262052692334\\\n        102239668088055849433832009645480819747743780592243873136287592675107702977115714500610283\\\n        828229601447565960855959134169491334318386045370108792120177167896297051323485738337524388\\\n        542948025603789440737070701803017101742587188735890926864042558324733468681754450544008040\\\n        188643635710838016085214997043036917642538008484473963624718143851733730924256676126387484\\\n        752284543368643131241540504214209058696293136783940634219179014278429099352245722582220828\\\n        948557070778581176954629257680246818117690303013891781142334942270181251776071098548618585\\\n        060621036759127430690635839725556160044782121111384957970782575330073901433067401486194918\\\n        037188842865614048125408617851510920099955073322226027484755276489613760820111733985060124\\\n        532666603236804699829247044510996510259116467157306423028777679675659985541345876716013689\\\n        122730597440756709821291855123529813477007238573034546818549773010179062402329151153697272\\\n        571648151778859603181982726138144485570781461136771734828576624048511137570914124206725465\\\n        787775861762535720001830224185522674375319738941146964852745624531506772461016403320487712\\\n        454333162624944942185622281958776206857648065776633885905781722973023076032284762570534834\\\n        273331575882583397185519111910326041863363661098625848121472368342028165179745045387771024\\\n        885029072734264780160920268745126275830919727697539984246703646228149297787975270539048599\\\n        027843327519982299361856316242997021507477624239093474077931689103505983295723561815520500\\\n        568574059197916150700152576900650389098745195063979651781188336971917961255972556115383619\\\n        280712907265350614533367300255609363642474764153606498453631121303405599875658014176781367\\\n        149919380550045689185397005661039733665840786451741966829369746028861292690097090478538677\\\n        185349502265835539296694194768214835965860488488014190963155789683131540954094515801047415\\\n        636898895156863398922005150660748845663917507434876412237994738688565341724366920278224027\\\n        082827153044528952219337296855958926319221687349504618765879392278473456042054582969517952\\\n        915116453024394558679245000446248146546289294982364922308943311123083894899230108967541698\\\n        562376619665437482778088174052025338516736739175034309993371053549107631603988687192206316\\\n        596022615568416950664570427125222642853184705468138751249490527905106400347224654065795861\\\n        671046604737229047171205791709543624318072105644659741656185611102511660656072119890843235\\\n        976720690271486622291104781102982439965257693674881980189592752991094662101990323886512835\\\n        070326055616347819387120071097226469557612503884460988357523493780481883147580784732346894\\\n        915776950646419231961879340905008943370364379976185983891658257001827893655481367165528766\\\n        581910899464615820313781250362011342951378862265047064025742895723315940686244831066366690\\\n        813187230798792142558297299251382187757021061769190542165486622376722662738943087029578264\\\n        447056765055961008035588027330541492904876475854855605753703023944802551178024930001892796\\\n        128733775084585969955931783522492302954861694696368267880820895985099343671565200824153580\\\n        261746996026059830876574862525161632094214768022105503647878019470456874690773989058703419\\\n        354162465206369753581558512485886596272807886790572642627063970249843197375914323138269692\\\n        125924321022624461157861528235983952801027855365926142124870508248228460752837499384260961\\\n        143814919811568572634348699575009835425365164531780743408792057277854166007172387938855672\\\n        795618344643495712270013842172533300495480650161063491588307317031685673419675973422338209\\\n        718445565473348545361538043684270240962707364808182103307851055743130208335048691572000803\\\n        445355889316071281477818462425493804313998486464158759070934895071421133815225573472670957\\\n        225597302365627529633927655696389297078124491265176642850713878080694296889129058125174215\\\n        658787499138982634468932208481638767955068243293551543251900340426024772430221430423081378\\\n        735092891648747485924997375969515610318279573571898534748197182161461751772879545612723942\\\n        022901336069257703340572269799946883608354800108340157027540870877280461671841311069437331\\\n        637273094281221239735732238189157886597877253845108670324699939947795426099410675249498977\\\n        050766412450287418006772633591343872243070362987386523241568292910825328901366476952078556\\\n        058529082478009312082084802878156831393187493354623556414223171510492879542682767153458164\\\n        047160210334263412813512036009215882199075872918230518930353959086190062640484024732974568\\\n        406962201799306514827156756222417941152315990785124060716415992757127543157218061049421482\\\n        704337786394503639743989074204481062459102418467515005784211955736198152894778211028922352\\\n        724431886378789169463661862507856505994780642521030439055661536300952715564855435126314498\\\n        378716269866142810923532649462236813281215435133145443785467375845648210884915986560253077\\\n        360279134397762177754828098007624953876161535555024055812059003239815503737509123095044644\\\n        920688195260054119871710218735128140112323010500603400776743633504982880485919128691552381\\\n        342980256194313984261707357284719198843513906270505259200470342682807110956248639383468090\\\n        703704334569613570000785126281450281183878861918112361395243785091219756538134264407439054\\\n        894645571311154344653695182545726318698703486099259364616119332305821090569523171992811560\\\n        804267006339299347238917928943086868801223596787444522457597179852875281480378608474465035\\\n        894760339381909178621898581732429662912551873870478523854925462642108590152790534926556955\\\n        872532414347076306337084484616929692867393905811461016669961416635603637555469588114434442\\\n        544468676603099171854435988144767313562344001958659711795053923290422001551407411441762682\\\n        577934335726848564154649651711465682500421315449217900363615916333778583295644443151663070\\\n        693379760694611274294269984635277863358932481308367315134383132141913204127240444708785100\\\n        640440162120297177829390805030136342686413202015114050121816510611266750902542558761538991\\\n        174329661068230272547185576886154179052153848796079830598536162421856419086559586945413773\\\n        190394525122663700880133043338676856747921911565308469348815521468928914278141035539041633\\\n        592960118458518582748303051770057701153564342426482340099190885279923801693168593384448385\\\n        454275082801906123675858817223420165526917275106226944858638711806359164098112782256673653\\\n        168588611181178830711961246198382630680530577833749599533057124361509312722043801556708558\\\n        224103144191423135586951020680639064349632831599845284107694400075066420291681858436618513\\\n        589640395669689227165976470347841059883924738975177800778791682091827283072084617965360846\\\n        664435896744860414703776583639106450613804099862563780853447527134273533330352108147922250\\\n        803546704423281533185058534615449514409907125094548324433626243969663785845069687630044095\\\n        006194254001787169796420604135541551808782143547429864218332816201630841188759179954139869\\\n        823408178115884499173175511607577782690352814061077535371256359738609072786804032869889700\\\n        198187886643225312747930229726624607932458930848603396675760208580304653754868511427991697\\\n        653149212609403739238274170625059496739403633888811584742885189742872470237685022282016057\\\n        505023786010033025163058091667011912579579167971824185317223527583711961602243937753561373\\\n        120697993535288408995619277947345176691388820092884812022014823622119609230788717949427644\\\n        862920446072097115978531294037263534333073627239494705926923109320957486120118615132310403\\\n        530719534250182510988039137951326241227352122961755217255032229794533724601680248710070761\\\n        131623264113466018856824587274428086203690985580600445536852171873811051110686019617595268\\\n        676198094054473833882598359557581526719412199186248413638190223261636365570623509033667319\\\n        069519527737993628185864265200132131456742716772422319432055165814830642933496549411953109\\\n        163362278137683746940516564730933707434985995490717817912923507929420375607188340899950302\\\n        799717529108100699349237518404976161838972029709943848257040414580397556489342343109862472\\\n        196584584065153726403350153339517874373288392237135167847706025921154159045671069196324586\\\n        273913456190099809602200332337064094989813933696501792795236505812693668630387453818572562\\\n        862528643859053666793039497310904827400402069919210256973770931916403593033775106626676889\\\n        309305451572240829016583474499590911265672863137091570371974849240988947072628679854626505\\\n        153026399148292836586527976313723685428347513303114679989494948499386281396810200352424266\\\n        818651280444265950196086509357379888153338283199651257995968691721519208715203955282761717\\\n        517459597661693386723907791869754977890108134962700459027527025063693301079225013790566471\\\n        301508889688903635984285620457829126066436274423192193339739838673536185488353356754834422\\\n        422477038893540800767108245466836930116749762565739008661839922231373931212735520649802939\\\n        418679553900133456934742655071385875145202638165778165545565089473845315268834806789962169\\\n        895055376520820846309183715093486861988504468131634504244467652897370823192322584457673859\\\n        018757265363325896561317089061562648603013638249335772853581054737615398735451806153762920\\\n        569125242180412375504223730550144695231551053930827316332617180071565817442291743855839253\\\n        585492035759182588078158094940843681789346277377283145957951646228126862325971688610515757\\\n        168688214010417579410574034184812761622160747257623374490303333543348445011604677415022228\\\n        472743883538087251475617876961838674569502806825452454586024828414478653956749404324074839\\\n        226132449249959849107231065466572262530532860722843870228904495686447497675507095937298590\\\n        519077494308467636248270374499926516356784695249275183823426901652545884387591025751654825\\\n        415805045823861243665912170087406208406276311822163308859796476352266396191688078709586268\\\n        260097514631282955356757532106019621289013707906989802548918277970552834712333812329008788\\\n        861061238585318233956087837705005987203108776959565735352126209363163381102453292986862686\\\n        842099876054716820160868659495179873559767108335031146968290716117653415036498810094943789\\\n        763009936726499102267786696677392421318680653196994662206081941719942035250696237009924812\\\n        276860643976649781306683265760953331170773213183053756592365442570900835438129757689205997\\\n        578321146276971431106684822200983735733920469000336308575007686746260876088673903539589547\\\n        480119800217278758512632630470188166448943459259429344587726003408686416397845863403264495\\\n        535107131798146880042161397613890953127690001380870939933248897173761560119778946033084485\\\n        049427171804756777665378261488257645694250477299551878678259143791926979877986530982360153\\\n        303426049247071653815421924890008517623121933841660166049165579816299920449919068950593135\\\n        861841605958929250799781217737388954991903866839039806674020635555812958632810737556430505\\\n        210478443326172964625773804275399460601338808364266386535124570741818494917711924755298013\\\n        094815519270806816509154477581460150967627060448159304670513908093291696796726412934079680\\\n        653845746892462503124554649125148236759489716191884659507881139039845406302124201672066382\\\n        158796027082476892485821964200069524235163141643279993004789287173883441728070448061045190\\\n        320490263030990980098693589404954928090236502056838304581165862807416207704791230625643734\\\n        400281922292172993827576669193177177596938422969295438621190402986563043937730960731257576\\\n        797471286109641703967950183160458792455256491018183935127733355985340154325236386269492177\\\n        175438475850034234941389119348607987215127617652089822842541156516613912372032037059169593\\\n        478320027084193106947712058569855272142567762181149453483150742168288851205786797561425543\\\n        985419691825418999837706192544020055649072723486081762322861605024991456964494518694082430\\\n        399655037396624410068279396267473587268204924459505547306088174654191823249937081501200185\\\n        919597248791741687832210132225847159692317763371228475086132060027473068109842706628054442\\\n        439045434753362824103412940568679311022871269356756062141616561384112425296800938925532480\\\n        337559365449409147240428684495644733839595981215929618182533334653205002160544883941896887\\\n        919423314802462594515042453222030000601510873618198329075569064613235346335717957494349926\\\n        491167945502926044010607910735343557199416559346004363723241088509778637585041262517830408\\\n        568067913055082822072734052675106762257367654660100029365834504599946587820729372488494455\\\n        888145498374843790878095054970255353636206184216122824867313642064935284645817701138342148\\\n        971605650014302173874965799211510783767358199997810503861192526200805468333977082688533496\\\n        627086967237608830066140477191652501666384479357516644261136670117855870528055406094423879\\\n        695084539492366030868968444042700506996324066053405737664774667367044031096215938951217663\\\n        495511726122426757718116704081809533443063106633376454842305033582755664901422044750009116\\\n        483269536552963451206351539639105423580075566115268251553061668365345103726217888415671391\\\n        700092225951314484299202697964096656157559436349467015809778577876992445354075498366439087\\\n        749193673949066285116346098144072778159670588890476239211485074778980597993353278376710890\\\n        987974303603209993391524231957502503926179022153426496738446228520147739123271111623393817\\\n        751497249300136080191207110577703285434868232089915850538282089113517964148964040148595508\\\n        482206015547050502873369432169604021641869740213817218775200346027298854373442567985854471\\\n        641579775233962810151185370791667762090961531485856075880651753353874008480447676851838612\\\n        962277781271608045019745520520996706063815711549000552928893141803438931358997663190775590\\\n        490110724709959060835726555302739602201011556186032036431304840774669072166825241357746603\\\n        632723975123813677145526307373296830220992359454881690255064235604927707067757875988784295\\\n        252499932363064786965802928812027761663684220340283869034718102354427829676323166113873675\\\n        393786939648196216320786933782104307719935022613300247704303277201871980638668637854217368\\\n        610292191126080285831781060574240985796930692506028472335745745881514882969941310339449749\\\n        445169827776255695664798444738753295629549811328327199742592777105573481895397160118606593\\\n        374801150456091194402156730402931770833893976598384796411181239800772900379409749995736876\\\n        797989403263601480796877937571240314418024711833645818109386564463826247475655481683733225\\\n        743694266788223124556508845993973969322251094172354923654563238386299588665799823349198825\\\n        584068793526186322326129573872333555950628214063821867058786266440886436938901299971202246\\\n        249857659777748313677046799078170806571834036561256112846916623153328029387615565425084041\\\n        027362709437781458154746796241510643349525411080657622151695539387765480778647115613410416\\\n        469284136891685311450204504234522500845005143867265787323401417956966850580112758754432919\\\n        658084628298241049927235468716326579776914747191020239467093960691068003510826423724121682\\\n        482621236720649432292823465796049037154635898844502819572065218015507142858650095977432311\\\n        536248513913841015370275054751076132675061253700456790074856516698163417008809964529638593\\\n        913555024145613907112778518056850201684534644003677700141645549850877231255706949704874092\\\n        544719454828886778258939764316501729767474125342943033148340177340137324564333546732880764\\\n        512377197344710410209289418197689309614792845769598971652995074510705485507815720875687393\\\n        062949499376870133449171285641498833528452818801479951158572965644898752035380477756775010\\\n        624479390303241278881904413251479125979076981274101200809566240364887778930776924882842664\\\n        555678376484072461031820332225214224878865176210216203794860028600824288942470951041016525\\\n        204290971220357904639998154883195592925244895312548078207776080075433682855848084777809555\\\n        439700191616416938329608513646861506781767433168218476446643092253055139297598219728275418\\\n        442543373928531613711045143833173843777248833270410168364296366386892671116305360170023419\\\n        244451984029374450686418915311249262453037169472197156932835785749714750912821275479623720\\\n        340463898302984179351297673837317980297926931949439232145001608298215419715656503031966074\\\n        986958604076189312531440552358025672819029490762777423735810553085443445862467459957805349\\\n        911831791630211335124394249590766239339015471716369287382186160050004161421161416285815805\\\n        394028742304920870566944872919248546442607709801811250777642605996246468168661110573568833\\\n        355761050695423181574649420538266035429111650546042335677269840742466985128123224710780285\\\n        543012875044034487501847547943223326642777274795301391248985562613295790179894830295998488\\\n        492259589080685936170993424042324392980130356026980676430267041951371742369925414282905074\\\n        887110881455657988042810058048055680844991274109522035421777748472518324155249568609858206\\\n        286835362466754378899847535329042850473854822479046610617682969057950334252962957610998089\\\n        577393931347993104817320512256665725201132864636621804261711937459829099159266813341146804\\\n        892252549434178024172156340119284707149450379283247499394575461709070055326366282657666365\\\n        147036139509796891688423983498615962284463383258380609096789959092760048334165808541510943\\\n        569772640193211893966349383023485036396071522623642107156630790464100891119585361098169709\\\n        900263661618310328751341280850901794898672363352480366978493526792469101996557135836134114\\\n        550390388372734802051844935034213152735069879173898489536259166135741702362194732934947067\\\n        212831356725495796221627707811761326278423085462707763541899235667621893030656683760240246\\\n        301453808596872903830307604326901511962739221294755624139549322578027378753417523393741067\\\n        469764868698765701819592051211351367076365710429996778310868587608867479430932835680241143\\\n        703062070209341038150813258561677861372974682165396178715759441696412832652823716647892581\\\n        292418483015360421750049519849955872509302081043926284016711908136851616179854971100708232\\\n        792313393222259738040078718192897507089371472270280417177114906927460623861568039948722962\\\n        173674878766461763113201292167130856044393493164923127023950337708608059088688945233140833\\\n        205412916971242938667073096544274757024581502725722872961436741466541496279485428466476814\\\n        771942727675872532468660878063722485206116280087971688106714069993655873894466333373155220\\\n        568850897827844862886607447914591308567027106775603675317216965765056567566130351011090165\\\n        925235413986697465302650065448248003364724359980831269844958914484794739859994759923048870\\\n        349923218460714477871545710073799811858888325384849126747689897999004608084336709310951409\\\n        582930394119580913059585260605406002656368532620608420132171442880395182257121463134458203\\\n        687399646524580804474478826256707310080217102780571339799917678443345505319596368192167890\\\n        925953248841209153551864860580401594917590360266180178467632272091792142327292178906932344\\\n        353201574725031652307576519018588010804909311612639551002271574840908526576190082956008780\\\n        348943307406308338001335468716452847708141752085782250759423834544687526995547145095611116\\\n        844297503491975592521847680019093347793370218927818371785939155376764428400895119275032317\\\n        203061177002004720548906323979303216709787849639300496716635265904914779753414006043778678\\\n        729267403983409626478411781026733650048858775174586201482373527790818713519638478321876562\\\n        437149455944046436111853109944870358818089876466973888152276334869574563976509749077684059\\\n        390708266879332976005851980536772847994190406121071664499930370266123047629985092598312431\\\n        561808338566404150789304534455611316389793728174250926479708817308070439918328623989669194\\\n        714312231075894121867439855000322183820552974212931289484322337184072549254637586913161473\\\n        779742838214553905802005554552353141511825073387001343129294765665293417187802524423371755\\\n        264797714177899661167043286434849441673300349056629051501558978274777477675134397238785018\\\n        156961322508457088730898793621731992995103879772150542341194621874985248557222383800142048\\\n        143204643665307222707147873923733257799991988621804025429990874694820545226725235001972902\\\n        656690794053402913340620453103002454003655737284357872489178486740982790901030061531584941\\\n        522115519750627220479911618602077430521465121327217860651712673267635124459703410241910836\\\n        121679476099872323462257477512215183205384798103173332115604192586645814505764256752342616\\\n        171279854400807937542604887287053910749136096779876815290487964620232725110097400341182151\\\n        071179771146126627441087486718425893259122293301561532516640308089098712678108305158733514\\\n        471833586429601050440088572126727267085404590962628568855235830678691853765220505011175116\\\n        704842794115261865511783838771779256876530773945323328664371190681784623109538097303279028\\\n        447476210595593871392973896211605017207512892003765783542096329648842761351124804611621541\\\n        061922338704376144024218090753040373440108152708856032619259510434201950920051490083485107\\\n        808074126006510920579317427468863233240881330763402649554368437278859099934747214569746600\\\n        590425027435166692721229817223617595434965323780779422390762900203177298289929016119696468\\\n        311345576513621034335462562945147150860510035044219534845521881930836150668605843333250237\\\n        541944438396310949919756451350361935910114516825053447974658645130304388292026628272115110\\\n        910557607256951525224976404022858393876770965291787300514105324361404121550383539549597650\\\n        762547231165637724066266762013975845068125209734279210710571625826535805472359171621021841\\\n        654179126830433809775110044192256663599003707700679721374453809259543277989941784827997529\\\n        206066813316732088628420311675073814877141075049060643244280959605893376943092274638048958\\\n        580466713272817158827721148464653592575493749532857912343592630205076463631451958583684264\\\n        363067833129837973764697579699763821513332743604545473019314901569204780778329888427675413\\\n        237351367283795232181858596264285977738546279591351339138775418037244041791814378063507811\\\n        020808758498675570688068435372204885085554380078441559200383958896493184942243322314509396\\\n        368035680523371352862644853972906320307038707014685531306931479987376863814637671007321684\\\n        550252074667777763182828020136358320262656901770688155088997035377197903829146895426186064\\\n        622518534576812293963468221231695082493321606611847247868051422264129675770703220635632545\\\n        244724997505727101029094595914590421420523764208956030456776444809288418178926303439079087\\\n        387467437384806018303132810340416615566523239625821465639688464074386603546637765834762435\\\n        448280419945793920112699849169595746257121751870734112277655008732256808793201609830155021\\\n        382409864378914399309626296144624416946088266627185522724704265858420446424451966419496651\\\n        240297131529988737661493723463656834509200893147563851944070752587726287209731636138198277\\\n        236323620268249717927317261301778269148169260940191527069810875673534005789427548325098800\\\n        896209284900434650498230542425124035136146736156532933288029686664354341698645197984275886\\\n        732005073698532991885885694048566840549392247082009734251720426088521276538603908477607688\\\n        461595538277687914017052212705738564046404701967686664016951106334838614829278257818057208\\\n        557578715034796526441949626003472224921800407846481918164552864134438224328471277084061405\\\n        678160012201972788251858862871239318689425919271192957976446464018113561699813285725693387\\\n        675410565854708736978555454012321879380549853337302119298963240742254388239969205648211314\\\n        268310521403128277568772766345849391002289721147872551135650803294207083898095485595725317\\\n        427260431715931085781252208155944671369434289662133608977630607323199594199895930454779361\\\n        076399970607741704143841719340491903251978154087527001780024611914346283992267619148072619\\\n        898306897245912374032737046751997056043044377340787119011549118427630185740790068029628751\\\n        918126468617787885415475393595280194856118057534314875690494953479668360107672845994083906\\\n        616633711194059668264370050313261007036002476086875191428782204824566754466428057495570183\\\n        109955077277499279072951410120374907565358556546541534803440224771154943886096128753007320\\\n        521437334353225676818883931175674014948024561306631132435694916578752248180555578517255029\\\n        610056286765485952528369575487455087015685864535094492383250761415145916383197866582640962\\\n        028937107306712296927184548633215396332234289537882542522100516959508768919923081653601257\\\n        364999958661765748800919248335061511847298194123093862186126879413866381321323377925975274\\\n        740260150389211055949911690374554318265637873958778920022854043590057408184440387005600454\\\n        369753298274690790976075835802558124104548582574708704830773405630204445891209054791635077\\\n        553025392675747915589332819027559615298589375634334673409870987029916200362946941363431340\\\n        812011069147362829355841314104204963183741176751337962454501559660725555553631819504515542\\\n        791068862260090944212234172553045235417404029854428004528297433355022877020829052193463982\\\n        073973809003923300715351469199518208444426132097271261899738908655044969093822997986005376\\\n        062627229696037595145081939971246180222112744017722962125831966714814033455449545248263421\\\n        629028397573155767008515328595789917211633633262986035399744567189023178295385386228807764\\\n        510543113009835239224117958669913431806884595588152450143797295828139645933930824559261493\\\n        687776153770131848587727422903446275200545349727146056614787503799705180801693294787262750\\\n        225520982042888676747594638818771799481051687380846788017922469384072671343453356081824405\\\n        037331069331789591119193134065150656935813088537759311832739343730437969917096523829365610\\\n        328695627687647520682140764717372376524076945121186984935609226368511970148446674171079544\\\n        682750859617990865639125903974299029611684599490493283204193023346779936447375278346770947\\\n        767745373087680111009500750807625340246172898269310745257243393397220486289611565157661988\\\n        389283549928118535523929389251718387062645624503639459772322712043858200187396171239777024\\\n        478881846170982473809533980184017802477777636577028685651746318137834510582401277023109871\\\n        594666105016432390195707779476956831681213629504728235304650753965620872119855597261590606\\\n        403234966827919659271890958173800023629617178496425616971300545073862363107489211402839469\\\n        383016152045302223988753952913823145738271830945098520568831807323601464603514834346696260\\\n        912698774411446764495458376434860590705712296650035060298661783671126425315923814776954345\\\n        735747363716866395825670846547446161436787603266461640389557093288546550522289438965279338\\\n        291364564616066387759142281488368847095048667869600727984407530590491105606812443925470624\\\n        870565153355780481485382565610169447824021522026117583836178104300647529235658134481677507\\\n        659690665795887983797106052050430110083232324474414056907601684218221626238421710754057987\\\n        382647076980734016097538221218522814679789766225342189925782546339827640814451968683541542\\\n        132815560652711614318345022335854998130215028278227031444227607730003928189477940558918123\\\n        132520834952369657730134001595652327087128110968628347504450263139480651188149788471912691\\\n        066076141206630357621646633736428316253067786808852278961783698739767902859092149003897501\\\n        245457719073314745049510416583525386357458977121197451924001836386013496162975159497875439\\\n        524808166714169291646673027978544702577736713790660924201258081533602530675226865941246323\\\n        791806093053625179691214558642099600028643787347709717135110694864023396834729197203837431\\\n        701962186957728501618847455331786974921235478241062486899556698348280046855482203054292668\\\n        396454287679110649855553223726548076546262782507840806090344779302392679918990940491326743\\\n        894308405105462026918237928608552749042628371360365336258532585315118343626119656161653360\\\n        110285583194716046091204190975293124405462440594622266797462598128622526912969294394518016\\\n        894619000763744835348564506014544940409604965083045824559813530315638000128710699275856056\\\n        591624723275782805566258102033137078288654395984079334944881314892353849342268210104659300\\\n        342695807817422744278023854113646171614441039241190271910009414853809520773910692928162113\\\n        643639540288960755844358590216681226360224626230678773583013499368605836296340113509492636\\\n        078709587805803968127496789809493785724138287220519114219562918526123232673629468791230354\\\n        619835781781863594356793627840149909981919888045042811314229258186259336241617156625067483\\\n        573742145712930410331943366541319771764502354611145001266654505585379422175601141011090732\\\n        860767361803157165101639334667083850703260774604830486782288886443367276883267412318783008\\\n        413218720406840653729627145097796614050366312107081907988638608265903028907141887652494174\\\n        995420851205003917830744226798585123837126513539519220038159145199099997910524563856049808\\\n        061942954652193433236929044200353290995179036472678754813971340823375084674719658213972996\\\n        400285735698996513936169168752662768980962407509019038542952767286375023442972244707485538\\\n        826203960602910150506197451022410606494142251280617137249529464082616162453209981483464176\\\n        427712395622896521795566879754489434262727066071891198194670527156617426052442947778226876\\\n        917545700606397589823321315096657872717582090271487671648411160106542563756549915714127721\\\n        252046707887163435758403641739675201043984416651453346204244956137982028344196757691963703\\\n        968305618051645729085998644174216839001406910492986719110188920544271122968151960999455801\\\n        527999794917547986343314378164380973465404516841311690814113692680907196107487379537368665\\\n        131100746884443337627200851014345283778651097643335848494503384868234849583456907502663187\\\n        079138010710343686953555843107993450280334503575312234210797935593156450157551357031009163\\\n        066373695846067966370685758849198214856777916379920405223410151588099802477042919700088149\\\n        997159996554722967869244506314330815421711603308823558123523145351722455897767968704010390\\\n        975946077692159568071017092144443450839434068503230939705062451978094567989205605463333210\\\n        114251772797928331226407989718196105923658736724894804994623258942296710665402989484131287\\\n        741817806801286385183778977187042991656857964263204457701319413449808562832097450298066472\\\n        851986515822720797492974036964139363072182057215628526104187455668227043522116773804212374\\\n        470399327723005544172450524371112304106371019707850152334874547395065522974746290892108641\\\n        698444241181512343337907965502675470114358491681832955180315120257003795917739848917205442\\\n        817701697735857755387052177521154801946832602018968375215645798893189328256381023625071273\\\n        790154850702080122736188720305008817584299371308616598727120321490522079756984969569287932\\\n        229846848073021439901730791415825739885790660633964973904194517410990893197287450358555289\\\n        793343325652734296825344547687715739671166741237033313839768269337418351234639326337793731\\\n        175941231977983930062252787769147545969595438657428065847991552787058188746994518330552757\\\n        386894706980519954078230281763628656841901063406184792138373703531335167816884257874528259\\\n        664613734968829877692396359309969566251026859093102473306690403314520436638065697781811922\\\n        931022162318322846516608778038937909448501493969576286325212069541026232172557177586554204\\\n        361292914759676181586153479511270561242956729863791553860974477169587234633630833690766869\\\n        277825314353060758440235529690024592940241092836655501310580434725822348120207768159282817\\\n        358053050064632134820463798676888313866406150172591899933677466515515287412155639351612338\\\n        837815646550933517502744195812920547296428580632141925382769205017900885647101456191095330\\\n        089571509668113002759047322263770565142165458471872845395769727590306024940033360920121305\\\n        853970978848837144978236120318082125396669314422968907082477780463941424393559842704747758\\\n        446329461065648703066504088359570101074432309020147807274240709716091995714213911583393107\\\n        184852574148799928427144068636317763794054090592702432215468051997655556347150688700416460\\\n        573346099520771345987545285066787530671815786163790903604656317068939423818835814848980767\\\n        334319761792380987918444975956416377885131448414380308300017974777687615839990409509716223\\\n        206962286680010895422470338150041010696252823196221508743467144493076430583762298637915828\\\n        318694115921815675291967364466522956173256509837059997929216708905049214783814796362397504\\\n        042289440118762864570289039111766010742224177093057745884426318361357944280311382669552877\\\n        005751295074586592270363809630983818548728010193661302422914635234844604816962085048882984\\\n        958484353857499901580880528097759199802917002252694342368307160141503823320243813401891631\\\n        931768473671488595917583813945873846150634456744300799987147271884502929392569908447829245\\\n        621641299871060512811598253683913674328815652251631035799134969714768319328966733652258926\\\n        593273203877397225160067104837020550578782221837730755975582123203622337280910518616348766\\\n        095459105583989375260945763495958010717068689955629668614881203655727038958629011991585465\\\n        604340255894161547469729413180034082607257137072217219434969902127270160321716141376537877\\\n        874964768994265624515356641213521402517495610404959816711621420415864488314723696123193669\\\n        842222596234184834915308487821397258125204424463351951453719733901719319237436287684119171\\\n        199899060067312266150737776382540740831484300847841942801094356919525019071330411990218246\\\n        182575501206196196770397006532379478672890401692358517074641621229772488784047877655747850\\\n        412129998266662205903904158332740036327448879308571952000970043907644676666634944508975986\\\n        035698303065290025557203014321053046392676873993823162877936747703804327839595677147969881\\\n        159607122986193055285660898940104720977611958288260440404922601734285445147249724581136132\\\n        248517721429624155549710063690401438704194632154384779761822496445435909960793004709686260\\\n        006011049510922800883066817263166949138625312374866011497874997162148177693063379759214973\\\n        451765968087296848066374779975346412340116735683967316625166322836613160950350784794834209\\\n        692121505439778457108520392979973753506500459220951852052861525047966875951023606354717049\\\n        654331120812282388097199922582509363054337284727407289397694521524432196265434327716369588\\\n        688782743222781570063776811646470075588222730558387330321074708236664852853478247045216489\\\n        068714117012111535600868062811819054463147096403582448025452096661821066930934883446977810\\\n        939710558723890014533019949832710956527779529591091881314637241835660831158581790748794384\\\n        399661783317903403749561309206878353285818811770817441611757978630676055554873579333752193\\\n        272001027093748949404801088486371693751498306776321707861499560412986111885503860333503781\\\n        627885246729264115371100739513558240116207515294067122704442194793267775586713757350206136\\\n        431092318755474497114317661184409929714639946510421747472770139215012993653240213225129796\\\n        726138392196140083229801202237978632466737057731965862004864340410974362758674812556058013\\\n        074718206184915909449241422533416428719940715074385998537404442335510181383816091652206039\\\n        957823406375602432010648433360207369709027942622136164053175316523218162633715755446242594\\\n        659704192395382752036378009927780577375770037818499000760872482019191730934438742011938112\\\n        041777994293913127663644615774247356088980049175013107782004726909671494160704637358763360\\\n        364076672231420722321086459027152787953799177446015699873440773227508847640153001052984189\\\n        816317438202655761980798581017636536439131547656845946499963716553797195732450930777057312\\\n        233536775350200381398109626234844667123128311707622900780540212163671941318405357756513293\\\n        061827156756350433425729522296126689784868591921102946076526157315828711709768630697735095\\\n        266669804412911586986473723338977996532121937934819476435981958862706756312897554859032202\\\n        314985511499450160253323174264814614808233292530886964422554746739342155947332919937775347\\\n        699217958931001953201422489342143218288674850922859959996712732320878765938135056617728398\\\n        304102205403724383048998649685656114630818539906009412035046476124420286124901032722385261\\\n        170376571902092064645396281098524009718381330363895697339032574592495554023804482839539385\\\n        344139184072897503106930721224737183975123174491261867229073542162730503903813553368859453\\\n        311846799423092453371333712215696039451066057509052718542343860998642774406812653633500041\\\n        145192586332341942681566112039722655832599951248592850021888315823084621841945999106167378\\\n        315479820695190056105859504485391374792785456420202046423341203186404660850261439687186161\\\n        531187900404832746680757095306227523054186002035487773786449717505822832198122208667073083\\\n        703512426087158044381914871127544535490663860266532114232176605898737857567044541739005789\\\n        351681949718484244849025875443154908875641305216088562734531189962929618439678054520621037\\\n        758560654058114213180979149396158746608080390699627159898887941174848601789643340582273058\\\n        672849939624631568937017998306508564948940542947121618008433098069106668877500040984794236\\\n        712912901427088767703096639971100590410371866861515991732376029476808354771688255466737240\\\n        115778273417383332388931788747532068898547820383640193323764400527548568232465555604819473\\\n        033220304910020836171753052620846287735018411763755721463783184625052899642511821885082672\\\n        020650160659848415221325270298332685355855107767344486205593056731566818850873955082680433\\\n        097502721130887887567210030374056901261346164636347736486168834785154841871124929212977149\\\n        038612795220958082965894580573988354281396035120540024192201532468190627196734055473387478\\\n        336649282240142871829321182099722790699125463230519029756882359103273778277413722592415963\\\n        445434049034292359996174149880249649511120148087173728814289879973103532597598187902185853\\\n        968784648755063494962162227525778710631444658353778204499578048740740590486950350283927687\\\n        995033334734067582511927440449923990000433807036319976981220902477876116776831891342806340\\\n        476059589205769127962862764128825827885841138269503353662711494519042624994110333866768008\\\n        023606864638687451388665805824281504069794718932999295844839561264579766767178509714731572\\\n        053875975189282561911935429476319557121178849256471675378781960223949574421134035336768293\\\n        924142589382284318742327663193989311698702865940569793554826271062167497839459867600411832\\\n        701794258324969122374861358824909905093526371169685513579717034703554190050254582260217189\\\n        466396582257490766683230462624055785620834168235670746188048994361638623137586781125688381\\\n        604869167223575946178807250012219958245340370003048557425018007466477710392080139566011052\\\n        618098033011505118304274254307054210248273655104248336271076223826589894747241952966948174\\\n        706258899288441236768091614508418460303459213775871587846051313556126579425138093921214228\\\n        505417842238139301719218184238382135300416527801435892366668385618170763532412863828797602\\\n        201923919074857080064938332783240638047635761416130209934690695460978114583268506775803038\\\n        208153538538779271133469432504816178428956212506527434983897237783616351972988404100561630\\\n        354343861421128739014325962879443864068208353290858010422366842457627866423449373180398423\\\n        730458940744773758969462412716516866052162280459501490124904391730178575064322254796056733\\\n        607210310312860472413212325126966142215216108756635261029549294685496315922928331053480443\\\n        806731193668043706274947349878800418519664127937887507573847288226802805310919321174311261\\\n        589473254217538105039034069010034931099556186819114020273364060079382193244967548152196598\\\n        872153431052425162020898625946314588987349306823360677861513067058512872251791323956357311\\\n        345117501587855724333348786132872899553534014191262256437055959713490372986682075104949903\\\n        132743108878602147814813911714018177585780210408322131968814559539598128262644287861032214\\\n        401100952315747220570505782605041946829323232517886376668612266508384508167670529360096376\\\n        500685740064237992324056935568889028008722791958186401536403953427392752244007664513745522\\\n        193885415411688217554846152018672612975883695249566775725183857838052232540063308614030555\\\n        456358400998100138137958500111594607966180055124499802273159953361174015294771719824095095\\\n        695974236980721136581625301586043923643367391065553228131899457583175638640923629388181232\\\n        873743731097444731473358690338603190733334806583336081223050204188076249007571123130998007\\\n        676064736167986429029870139981959552167153421374647472670873026448192341418399612240951491\\\n        428798770912768014467618294792938746251282991103656497376942625805342111034080321909767924\\\n        449851872714621684837950329260252106945147270324269482831716168350119692419558782230720988\\\n        336285263278181048887301598998543288648832822679823836472374676596444814122885611549032569\\\n        528418157899947407443165406590103537085511987460394716146210077797865368797059191612506387\\\n        552661409894671260962814003756553251781176407833305792557377182478946176992288680070224337\\\n        616364092222747792864711617449014183656512608185125806653046904956658956331491448335254423\\\n        110637632827252924173062675608111657478050727348635984004653631076265041057381366891747500\\\n        078356808070078505132638659145417803696839398296703925623917564729473235353982521067202607\\\n        123218036764329473839445713807873786752525745304596258033604724720889220024354960065429624\\\n        650337819667642722217718891986544019175802564968133990234276460780371817570550335099045335\\\n        799827853736353052328033277843404699203530093423012253895902995312076405110124656320728387\\\n        908270485773257721921853346927625535717751058655721707573283837769407219320642361978159383\\\n        176407690058770842480254679334469323891812370662824300877332610696212306538021070864980589\\\n        743127200556038067473811713376941157915012877220336984737814741607576790756445003439137109\\\n        036876495649487753232671165258484328509605054645389622306052802256906707541956900891309278\\\n        225061175277992371807993767617636881833361410171911894479148146585470178528251968609770552\\\n        754637654162437272564163934171157802355045200153095671841748428869396985983421765124940011\\\n        130329796000828089335274096706351071070654244725866312435397678934315640915505162602696706\\\n        343368734844096304701237521752796532146152059302776292020629921815259030180017166658587904\\\n        394163973120116116781729316351097560596983198366866922231368457576525749455052388987925581\\\n        459850379799149379859760775581269808241160663606248380252038326806593328494469527156379122\\\n        283544020086635599771961513834239814463328781724479353156169410428274199954914376647875235\\\n        157080232408854848598940579388950645224400738909640919311662981057867506679252590969997468\\\n        291969192919162230667261799097031498076143196545453336813907154402579720914077456672465304\\\n        214882884455753105905341792498075595982548563467449914275133634495997005318370177325878932\\\n        883556729306772922229920464565695363746308146328114430206008323355131280987459579459590957\\\n        247131223434989034005686356185085304497380156911154315954166097959006721746239768538683516\\\n        373154945689101347573298378767316700999292327219828017362466746710345657219537541158211830\\\n        146459435755743616992209512412771600355405545561487950415236489576625318659522043138203036\\\n        336967973099118911439137736558876292403908922516507528716853390125957849542092430626507613\\\n        108845152599861637829496591416664215117353638340003071788823037741536345005902970174368356\\\n        699826979698511526273717352473303177971815229594793239391671746524771961118447958812698524\\\n        561137492727615202294939176845814225053692324111984381036495758349109085547612537520869625\\\n        403434820407110335535534508907035428335336247241499151553311546030666553646322678385477376\\\n        345310981592277860546829632022055020558514577368659892806392726667022021947826029102059935\\\n        565729721560281810805015360173224172237304485230011965146167352004996896928433264000099191\\\n        787725330943952495496006639164400708571875770645647259277152827156091354613756394526725233\\\n        787881095641256201744303760957143655776693015597581762470392076124376182996208443577541737\\\n        829843601636721831128180932285798709798738571787439676430585040426310882428442668163376471\\\n        618061350828388543378761399724932293893036043278921517543320035711345631077961778661582491\\\n        583276844034122002153004765592822260502831793877386981580792519233053516517145228477383891\\\n        901154203302923115926183504681738630346517186083067483346883254502407390230115571306988025\\\n        071191214542436368944297932429131520813667988227987690269189351581870125045100459773193535\\\n        666320563250328899418603779550363612942830369763093712698420662511416840251351528872846111\\\n        458917320107311183126493411713684029847636882110121947895898913133554420735943268730681978\\\n        525319697845581353313920351956221426664236203743319212327666096449690975256043882130202498\\\n        348610696847246029096522311251951719076573681142029822559480208750979088909232511875529005\\\n        623956852463490795928831557909374423949871754503191093276793823764968420822802059797648619\\\n        418094367940235872059466077735539788013572755030458927885373493385926931987682942677872034\\\n        945280500325419816624443605687051722094154198438502177208031571825175219452838640375698107\\\n        691665953720376214887509863684282123981372924174122010130480251429690466580559440400853048\\\n        844087385181339841621064061449095716104280864987764463456118127811437594046698298661140972\\\n        513595760373691753315937366094085059094485306872215439698393414326950564977553189789369869\\\n        100937281713675415911145169489810833534820095214086183297256556625567663898352226463832185\\\n        061487383284397137244017320236277848492359101820127821033341105535357887146947539099889526\\\n        428395859789586156198420555996004607925504866619586304740978403348588470600462142789010745\\\n        138742510850172686704817030814941079438443948598144265044628475815784090830113815026252798\\\n        890845502144561885301935779246778904952278370546230430669569727923973551804453549593148578\\\n        956746448303830430090462977785081565083316076037514800861047040533587444081332058015570900\\\n        255109685579348922223685281462041382450453975417089191442587644146372235252071825056591270\\\n        915170815340593707808757511987596843123474631438335895310524654513646667220833787832256762\\\n        370457712775867021340317601567883611261494011518138350752236614636120515096448132239623150\\\n        115238243679034761956896416891431753852224393701522084209974044075600692259687846431601035\\\n        309540390468892250449732866008527953040796512168609530176433052088238676648363847865597337\\\n        374594647390784266395292690599953306082982852217465919670696602562173885584236289699815383\\\n        798005076252317316045718598659243759570273848246137736118492825704394805445443270314107457\\\n        556071311888618342004404177257702349258204857822218961423619308438163573275654071103571651\\\n        331620891014237751868248406162313382559767835415853513723795943214764353342759772491941675\\\n        418667765262495415855660308997140744599293301953183298644238083361496794505271911491015654\\\n        424037204634088014403247352097509183533858337428042641954107647311230029880262516416658242\\\n        844780204262561081166183818051718071352773867998621721791111782128405370785339802670554423\\\n        125200505176886991834230633378435288229017159072303123166965938615751232606720033882114207\\\n        595525642299792379007897069789385700323161478852277396051328051680401948833735713098354558\\\n        720060239160341563758228465385195895259698439011272095927786993219275281249122526250274873\\\n        077035736894555870466896941802753175700194416013822768228676617465318041861329940472565963\\\n        066868475115504031224883100116469581332428179441549089854329640504589903312635897081175123\\\n        246609515771846053932913018988734167738080840774370490013204284784820751459648025724856591\\\n        094107780839533780140457368684296488136103554797146094109465770312547598046103858674829402\\\n        948333314161685808370140943659478014453028245733863328610366692995057483691142951356622341\\\n        627739351070594631404107906386812233570183846342126687675562361464907354172146012403208110\\\n        127811786564788372456667499167792704667905968538910199872537152997994626307513193642807090\\\n        911876261586207963626795953950112446350951735585835748867778018709738542667355603298555927\\\n        365998764937880318089561541610725780060321798650837835630498817338781336643092496458598096\\\n        227674610831367093201853881827678312996254990829884503000829541273045629016025614654459471\\\n        069452966921130940520678178555037157795422511012895533791688221736202708335113089802514489\\\n        654672789159850183725195815013652571586211016482729671165813105389771656040066506516117384\\\n        328693704537899381752157427297575165827293323482306942340546797930330727143057760778009781\\\n        206164189549184505196312913600578298250377070741133535267347308171555458144802779808625356\\\n        506955536340760336254293367792119423231687725333073126706584974559493906916432885749605019\\\n        850431455804710830214915540112755750801247129558330055436273971804860935596256269761776590\\\n        384418636289034183176385542611545530507581033002297493751106724597483691106142941122359005\\\n        763366491698126906513380542642632524802968374518584742385701653959972977810282043519487333\\\n        869614877183906361977954693647398197214640247819639157709217230270917481689084465113605860\\\n        234959669674076590471502721557942148704661654939683365714519541244968661993282476577400221\\\n        644367035307261568866440597993321371999762223406080641049669703031502916796847410815170770\\\n        802402488377141953754145313948831331681122371776100440372747023903651161108509208107683303\\\n        225173413846396177056870454414572011947458077182908068069151651745163111424429855887565485\\\n        506936112734800456991610065376495282327090387895909557630912187149528301756899773831007162\\\n        696285561677947093917274165231850112793217008297561400596560076776809672649042002089721075\\\n        945995585791394341614882419783253735983726173521967429928502855607164683086439263073688224\\\n        306227453121389565498092595294629727660645014764259309690865563165545030056389248811587155\\\n        742637973631801273445835831730824073195994608240808601932574404345255613557249514918934526\\\n        165452104577924895016941458382953323293979467389228897132701206827618380742715990295774327\\\n        431050199753821815010098325146478896399956508539943805915843528005298093874745856181478165\\\n        087955424179761593198054699446020421953293329059612419337727684704129650919694747751342771\\\n        688708449698973337724482754752027109125924015040991139056068206949180708227057564220803589\\\n        089491239288535798338954986798201289465566666324734024534070296785604341956802340610280972\\\n        545367491477243285666487689984084068672972880320113151806200558815149887936741038195587847\\\n        348954412771349726203155381345583362018988970044305969827884569037456727134444071379334242\\\n        263729397171967230415364564379061433285731312150464625207361089277252782400053937087636749\\\n        791664174226509450368457058750658111032018055167022492141350260364141123286976523213354591\\\n        875063602740465181238666202734068629045689008697003252100017169627208925325053337612413055\\\n        509981655837532460640270914814435222025524456195085529259298036233624226129884189067644035\\\n        219295578583444244822920724245009638780708977001115258437247063852444661786235209527840203\\\n        085006718955624427994586555747046395258655398356934346713336715169254383733066445655964255\\\n        020011568967873930272626135068502164548202055910563448024737208320516056107275591487171051\\\n        956999228961885346527119673377237204285545569573337295912568071076203860222457578722224616\\\n        848515638211056063127231965358264566327792603721560221724884596196496083362224675761142211\\\n        259334723216541028726417984738012366567064018058841197329261099320434258725031983681626768\\\n        053854651336494936839175632826295223049879424959253415353502180389260573344124605083642678\\\n        300202678880277861989766207365189162931208511231208632082788877229420547674286303020533172\\\n        315347630594434174340623826862619911517832655711562907911686915104540425229103918448586814\\\n        024339570986883713717174626703306180969436813235564065924759755380987600611829664377027115\\\n        968468808464152123893888265368681384511043395030539274509038353859543238739714460475163788\\\n        144075908149661738105800607370514957714486514161698394144549643390794758123855846988278762\\\n        583662137009026033256534021337157107215909089164354977734694072324304086141428047793428811\\\n        333274167201914422279143710677546941946896862235794939944131634344411509828155353053401826\\\n        373461464401678153861098633848648378807109956662018703347581424035315030346069285158333665\\\n        398162844665093532005238003809801527918228855723447623538650344340754595661826399322625876\\\n        259428365232725179481563647163082345407206458338236463692721475895377390068018486921079163\\\n        830583392017797189543166000289489941048508149986751630382076809136122918349000968919624303\\\n        035539102484539039336142712260720251989800196741346702438773575549260291387021044689247398\\\n        308529043253072097969046117496838479207144711978720757498955417981375854452352636237982991\\\n        600358170826364084252540188047806120498118445830061622409896544599152379488314814077147618\\\n        129386670355121434303533382507603184101824279833960088490369505014743540397278458925841656\\\n        989160877603465222196744408889964735865539153982484458357484476405363520528656991671056507\\\n        578812633747891556462795537016412974077965796999607810879666088973863599546171122003600772\\\n        193635949681661614587777425295060628438331920860614917760159737297221002736216540195898854\\\n        139746866251745274622762287140604532720252716124742836393693343557242200588845274131787750\\\n        118400298478494021516546125811776292462374895859885765476755786546734728254675303212223393\\\n        366530989306134674383642253354879121899924922991020438810379463971214400342900719838472080\\\n        121357666453802351028329650083282334004530480941755323193825915080269811755663969106653398\\\n        105810825950318728729738401171525399409110794632567428233097286557171505824959580203461293\\\n        483184113877889844811611510798652390299589280931390360934884068347816423170948432129264590\\\n        210729581099244879212002758753931045699830629227416865587847778065431757471293549760507204\\\n        086988590869046506664694401825433155499284955847901084578026733381172810567515511293397781\\\n        652863080385086246751330772671273589525988716024863803988586313111124031950762184759479171\\\n        463775317537269368916763015011125755865217972096420680238424610477098130078188578045612479\\\n        976321993464059049703548196667947338157979182733825904370432953765140030792406197280277165\\\n        164460293338894864710510900651884524152510629046468452497014959267651634675083946584997475\\\n        352649476038155840555999814111663624710967874107764341495224343468882867530432200103293889\\\n        759276260523376157690051321316877206382565914979929054180591019803563421916596002747779529\\\n        196397576332264788037873594318507619152693518838836605981471245192884780563391655801407309\\\n        899769135166424250394623127478598466619648384025234725818443383161782792425060267415065393\\\n        117091564917753656091525974834923989845823720388503612730020581308854065944064092329159690\\\n        112536002729762003585727101633960108549803363437661785007553153968365018372135715731541194\\\n        397245506180255375077448339912748848886795885596889017321460047771518538173447904773714596\\\n        257952044870213673180200326027823327221170893277164534404602091919083644482180338746272958\\\n        748190541240025741817089078822769359969354273127765576050589674873137973720831873387861969\\\n        629409946783595303965318653494036605047222423589013132450844024436239296872077092325890078\\\n        458028124949165053591147078137640445466782907597678010225458410704180694454298214121982462\\\n        134523908164817177962452447404031526422463638416726708487093806611551875241655858274384249\\\n        650054116833904324978784052057274655129769695400317436398759198242569563947657023237578346\\\n        087113505158689173603168048064229198891338488604405111702677693575364599640070425282142562\\\n        878202998239577132013310122870842247445792277403295056331881321638220932244984447859801365\\\n        046146075921314639083482990013419092082167090441777342761104682355390834031440901524590313\\\n        162776599342081779809633670472909286384068652419686775217516923818575289369193945615991381\\\n        537838474122432476946077797105497556788744479121604608806684545097210593941547408677319133\\\n        964714840566837816818754794807195729490499513422950881335975728443917924426109192641715851\\\n        142683735374691108704426266272456327613780096813345207605705588762500708244117491879741402\\\n        923543124924260899824653599935640821094740692143010931972732785361783918761596806866325072\\\n        472964009883071130428217513603577307007889986539358066443309268964888594986415335152516314\\\n        956474047913039256477179692287800392324510898574106230091697577820977094480061444263123435\\\n        539376956929503609878021321538128658543861160195738582201823802981123574424960633488365998\\\n        459841580418652857718468268498787143591563512161651001533214094911229348710722357143971665\\\n        114038226645515028355972465996724363624198375185430294984335051862981273559558394470752397\\\n        736603704571134378597452493154016041677946002143265391217911151617406335189753724323534784\\\n        741630253239308864978642570402259787107939654633998506460814921561429922008079108605170640\\\n        153866235459830602687481593456759785869841802517755198110115059898107044788435413962235811\\\n        287037152630569311474799488067680987540678768069163179214250082370096581843843779457871108\\\n        015554371506967885600721407416541963555568404499609857793124910252101481788083365700626182\\\n        645643319562694366061104800279475392498484708862623021853792120801618866112172356797060960\\\n        515975508421724157481936899488717563173623418760767548200753871422435413858996608549666385\\\n        503747406640283698903809250121442858257580422275509999636195209042329975365760155512657906\\\n        332301004967056663456324274681392695317952275226702839407476327144537716313768533119920873\\\n        294830529748197276999315556954392495123334723179716483127203906963627400852268431212209722\\\n        316016445991779203681111417356680820216535804386070587875756401592297042789596022951358158\\\n        458164130749195178761862762300006209221878563322893303109287373105846866377995462413784189\\\n        459561456448573091694293326337367646692425927742780262046238668444252626050998304298951459\\\n        302485384253757201587308673616789176295578292656888467747754177721674628713067647847673160\\\n        737099521260754275282985026145382815424574706463549408140667055016722903642678039775117038\\\n        882465810161886845034480797215913283192548810669173070652986297359594090341917725941310134\\\n        730946150579331269108918675049647303004975969100239356179255524921208581162553722997230084\\\n        136746927632410287607529152007515844467336118877911987266042766309671733639824582239586695\\\n        763809343563432766804908476388541645923386922389190379662636337766383639013238844011670403\\\n        987291984104686543585992253035785900503601635903190279135779261982925835303597871591324666\\\n        716371317821518632312340172524791884862318086717127822584569456648198321132683908635189863\\\n        613701569831090812743535389504921475862824375743774525019719280333498303537280775882463117\\\n        819159869837333502311792086797517172410046644613281770402371887938076997126448448410469302\\\n        905962950574289016991168214138919164694451184111301024366907582639805091633896988346227250\\\n        692377573848823264547619385974350289222991497632862876414683263676473819443753557370929915\\\n        359503820381103645255444337838558814590834603711782625576705272011322923313443857286772434\\\n        480943509251681457054757550511756185726830353615496492779968610132963083489700448743594944\\\n        063384292743863097181591139055877231038430265701343841174741654910867466475497985730279970\\\n        429929717180020293595475486873020775134647486271857648790447075852307878677993971703054166\\\n        908013098090054718819666039166261078561526025144555925931193924144364197833361305379911139\\\n        576860455849304154692236529581664869325243062910001929436021680129531231737232840652627185\\\n        811502908465944947532327661352443985712836808860801384188693311965718512468510336465414936\\\n        318676993153860150828248664891399269835500898252906646079019654623775253479841311857078045\\\n        173654147218513408705000292761292387201066916253083197653707380160117784111219581183025572\\\n        049315712525211414709849007744143653294489094106524506342167584259057329447444456418210270\\\n        495245636174744433104309021527323201910280144894213822951329230030848533955549379972294932\\\n        197733839451350394862975091687171563759164606957538758260794033553065642436607033400568623\\\n        071707834205040223574866838482613074114707960875918571800239581242028390472660050662239936\\\n        940912490974892875524061303324817657378088045313745809670659457092736689145151462822510862\\\n        779968645697605660633910369009338374840521871053522756518589262587532050448307069418554741\\\n        824903333278962754354762829863590837701512256256169974053014081651213683270930326789709936\\\n        073930362362747250285729582689042594077260642946309951006468345042644256414420046113323451\\\n        249745305900212134611998587638295881320792199031369191795634478231156924275604876477579017\\\n        673355723877553422619290368016284979522621565722169354381958775215113900320277548376153173\\\n        899600350630344897110125795831110721469226841255090402777308555326587250708911752772067219\\\n        624180860034435028835931603856045193678115037700108855215472548173905303381162837195529358\\\n        750177220220315141472218017905700522709901993407490330956007849125663552837490170995120165\\\n        667913087633764285266265833484257615089954421327359223736647925475131186329337174842905970\\\n        496654361098594917055209252326414117750631767525400259937284604844698410636404455370002837\\\n        012242706314686045946061595323497141615958642474789880736203353196259258432786435954315532\\\n        936883264036191594142255183701193787516837090397796304640284555069732326276821627758845977\\\n        708384931865134402288628223492549783902763660357415686298398289809800606204216189705230957\\\n        235803231178494843457232044638022312908773205008435134747107198380144564366017258809994444\\\n        894369556340393811065096399761102348630027038069006157777667495253724829413885236299150012\\\n        141574748497632038748879562612847785129220876859375060945334967957180162429606126634571069\\\n        090111398669227547122417286272235039793634266624060609263092786576193049676183699346490795\\\n        613696781306332289906613921781106298818112736067165099693988895656143823443167764083660097\\\n        793948353319800299255012515403116239405390220939395803488536346670552563583892984373688608\\\n        373966212400110839632421042373855856328252323067988760821564148620508783717608761256379023\\\n        084427458378568095875884003114506767826348968698810844281923460022667800703379004332634501\\\n        571134260748037354569009763930802146252162559521154802524767866534723108295090007645529939\\\n        032358101866771329578008419932443392676668345321279256585824399206255888769122177594491985\\\n        130404522327832811329334239067398035515289297387214208928434733521805442006185912266380554\\\n        618337567939419498857296185198049972893755431616948379578777707675929927083665695018898375\\\n        449192233151338921192095152283498881560031698320545272593064827159140535865510246466368537\\\n        087166367485555218869859064323275847971652914567893177417393300172134318778933839737846371\\\n        191563189629949844549735595321558614768009690117686843210468449730881377307491980784465874\\\n        855352496546741645544210449611654345802456966033120020725273284429166716736892163134272574\\\n        492457138419581932892534427481179433760489803101898598588631196036920000323270934589524234\\\n        682018641107565728819794058602091036373521043122645140598753174599071431575232380975498559\\\n        969698689968851244766935241886273771542028575414190712719242366774066520150035157570760272\\\n        018271738736780093411224855007876660733991416143324285706495556166433694453476636246751757\\\n        968149669693130037819398855887680442891312932178377547495900179765138426388231460995843072\\\n        412525924087872958844486097693182677934733534920220931207111178780222666145813343453082705\\\n        392512508222037575023296562065795624939450650340541576535374623029075456041997739855981467\\\n        155283840321722024021332253160465616117619455499523344579276691523302231892713314236874277\\\n        571823719848128562245935090829883696736933855204371910571012761739385711080286666127573003\\\n        889529641027632672142284478309967704987305198492501209630361764636126975229075566765393176\\\n        305517779875043487803311228094587385629363193844456004726871342285915446429320422864163313\\\n        242393355939322288113414244442589629933661833625697401648109672560078526059256796760182436\\\n        205093992322054664887068410958684658858194432035707431527523327935680777226893983045428889\\\n        533354594616267261947395855270783544146840236216003580786464220306965020557738956260504142\\\n        452577700162762754942991539075427006654316508748359896649248800374189770201665920458402076\\\n        789541525893010478427276803456041611729066528515750993062956978852103268786419174999586150\\\n        663512221920414205157108857708692460865394477802405944638997916374277418886444714277798243\\\n        470191590923721218596458622503769334413017088357290453508761139330576339423445075015598230\\\n        526668835326151701473260444888476282747860014763861250858442347002025457436205037065634065\\\n        625149476022029975421214337414545717192869923612463360608217999466022407806366772142909479\\\n        515952960715606056475311825557737196883624014011034037284308213375178252989539890578731979\\\n        539653335954949191975810420394950290261447056852388603975763194181418591745541753078486389\\\n        896528373309548268277576531590137701567697985182549892370651913533642323188664090452994417\\\n        344227485520135072683938885942589327606143354139676602474617174795132473334255559470481817\\\n        214560601388541425639344326748184268798221790853774907791716983447220918168699216971504020\\\n        032589904596118145986348184682922370772712012136630366080700000142570126749950644288443136\\\n        008218709101470823674487462951709662951409002700685027848690397880449122931200391626345901\\\n        781271235929009097712162724595406577674145239571290792105752222360338777273703077175474574\\\n        988428662507460492143972860778049424400590839628151076531340117658945319596063835043318723\\\n        788356825966692090651236693385080237407792836339119768451961118168332610009175466765544228\\\n        949950966848645604564079705274746331185549564037816671276064229341213539288800912389556745\\\n        604724754395549651810695837287725980454594892748679420448482342810763312245112327624667246\\\n        557646489999192537850415322191336201382836819316256565094988897234190591376000904425821845\\\n        194962855142957027467313982140926831118603121096049052529933666633752832793879377197311826\\\n        480012874081015247483268971251265377353642121255861532782479625974410247619277764608598066\\\n        811878385444669888370060775807341483441530051233178556437795695705025150393411806921293807\\\n        763476854249369243741127264531333011556183558559279641967515901069383720315817928458147139\\\n        097408378594200864795589373529374537382667029021106231290953920271063283043431367894953389\\\n        278649242643564840594313913893320813693722069971721258396047787914131229186548574408603449\\\n        813063685671247489589783625027184601750229677998033760068212641862509866377038106143054239\\\n        702916511216679700667168430666329649938585036029574836611073849141542489071945977491091094\\\n        253408849066058665056016536219012321214247588859826942099504758619062550223826400538780743\\\n        114167189923296411666170402409575540912288691219792624122485559505951329011557118642226111\\\n        964933962114868877078207901087592925546287117184962532415709110241087967442453831449484816\\\n        401370137572027856917719383876277794636276633361691069358456966767850004902680140948282602\\\n        102151873871483070407763712959204379905202085013891672805970781513897733993504439544625684\\\n        776794056076882029855189597043995776131063315563547075632857093211662063323610308202013949\\\n        858308406060276614823281532927421159837060853620311731771632032325528481785242277858445199\\\n        845825690930690635185780425925370050420141309800582819751999791324397575655220670891982779\\\n        041802303209519906647178876447446263745625812341805106787873189759798528359682128767131415\\\n        214234671556157533367991304549810871154323286903337099954799775749738285818084149746030398\\\n        315589162221400183213254046457680698892458026897595034543761690086582211607427515126523490\\\n        981772922817149148730708405563189905745699952998892412027439369791697793938950437962557113\\\n        476047356964898075160390152989669768219451939678218590696614505133973740437470125583218009\\\n        213485286600324320289990689038449084452564219460089260639820488820905559646274602401483898\\\n        705092768209003121549307905100196795812416170816145646572380084491316518014110154432955933\\\n        284837242653592910330003305147904804308774646485366475625713768517244581947176865325752105\\\n        947860325821570419677427742273467775788392742465139812734714326445709314431417824533480899\\\n        644943369721021536953560312479461089425711214095225163602819495789598182564390749424612116\\\n        953392885715494180985253418546328147692854213203670703911593138058422222398280974686403541\\\n        621705226351752063467805564980322132334743654255760226011110908680315784520015002018611376\\\n        684090031986906722271036202770082792795569649342923271797391015196009033697682430388079105\\\n        611820107057942632160426646793227056996269554259872819033848062237946065501577317340667106\\\n        376835229427023460604520451891148568917939514270783003654048714495655270000454047033161920\\\n        856280845522200091653698349534457106378275138676724616997192819673826806954591843994730319\\\n        028307703603819216591461476027643788064554769815846092549952469146908790738513815592094429\\\n        459035395041712660519713925049039302561892274322493113189017634399250403863324376936133561\\\n        830183915057241282801875870465300988847606526248038812212701266143876307958895331268708782\\\n        455669216380796658988581047161499092747724802290023116136162992723336013672612033776327774\\\n        763800208036991510349735660085859975234687089517334234436627445153628861119382305098284525\\\n        742249047774958330305182192684836489974671476842234590237517999666688931355194224929239137\\\n        322426385122558655496761554653671703929436979547975069466515071451181413815694200390930239\\\n        208822467626361698100938896007190476088914531810552697204725172646473103216969111982297426\\\n        527275686204825408910471207507805257206716469887445781811057966780179607528945321055578910\\\n        892619177980609552805736618347529457588505814142767768468906631637213354541806332627410399\\\n        279104371454344936331104466943972550249216498939203800687924487953650954895340607722136267\\\n        512308749837477555170425944347996800158569120078920088106046107874565833674891625063235934\\\n        694376541398058591650127624230613127196169111914591091755830183517225734466815401252987897\\\n        977616246655519420744889974343510958312557867354437765356907201691702662078573776505421480\\\n        625916660114074142523747388399625330445300080344536669196788156490016224147212197722412779\\\n        824303412199998724974820727484578027276859096796005668708696757279369819016129224200989715\\\n        846179187462603479210282350663801189882531892442519855059974704732608506583455775310362283\\\n        993565328208037316426862943012303059178183197085770122283889861169198338841260277099055533\\\n        850392997999089087796693129501577778539835858017817492636202776694264582380779652320993470\\\n        993182161635970569205684327853591952597731923352941184285276534176541729604805809552480250\\\n        512105601479825243802452011472572174185811887788758954230308539039268376292523073778076388\\\n        514810763645534945693554177420042159097043924112987178349214864560040499832074106187015829\\\n        239944536416565323447609365181222137242468096672653729954613757845222173663769859991196229\\\n        578953425946323267099139020150509826556046314369533878339527143650658069830941901168871217\\\n        107749479075461147517116281620053401435246300426732080863202176293593867609773242529858606\\\n        611189022396919364593815112945718963187442330053206676077079042478272984568739408778587702\\\n        584137623582101244990791908314336742823083292258366915244435092323545228395998239604974037\\\n        259487596720671137362000654508632857592033205294788241361349188720585988768304583564723467\\\n        187848548893796574933096222122589183591838029872817542302394993367646508960327977970247401\\\n        537552736333341730468357567625614588069569642195136952618918630649900605364198683923114503\\\n        220090727540374198629893869427799529003824387480690430667332731129085739023955875615103961\\\n        170488346850534062551287879402374977678782401231341148350110079912974965402057174353500827\\\n        364945415172405145883967178290837786908919326984968279492473206977896849156950921060529113\\\n        738661032289971738701867721600513737241334264194797804313970084941749298173469694260609773\\\n        963182060376432134462100454139556939559481439099496186445117631887791890235343829228300693\\\n        422622075451868924880081288785672580297988377809664615227889698980735978217246514291623858\\\n        956299995999556587835585698274468422113147402731645920462340223420239607340075350592568875\\\n        427968839613506728855566093851831013640090616092177848180462361637497881078426191427773687\\\n        691497219935976732836996534188946540883960766501238111745335345723368352190039718621297228\\\n        599561385255859358075169503735402459210909552563753921061297390921761950479178752584359939\\\n        552111399630022947252274658526158391834878906982276830750794901049556488086747432613305999\\\n        580641873979559630124378485593721493514175450389323126936846265463108215331064973248177527\\\n        256047482890825482387749379682382111080322359858558137232675906122027374300446994857675076\\\n        383969411295058615058836250462514477151017912399209586113142823276325311818894117825083277\\\n        691607933980243252232390017148437951566687708668863124756979365895057467745424486462294246\\\n        167964335084994697815046723783163502810210953266192849746444888813851738613545140526249746\\\n        502452662848962727009356645271760721222176987946355490449306058684947776750439662033028097\\\n        379309405658565867354112127054533936804083625413150662567836299638363210661922184613182459\\\n        027147178103118304595661353703048812269982156141437001501032801362012793476821526861473831\\\n        020379384538424563035840047090800972469045616162471979046629067312843301024239396380332911\\\n        604203632301364800785574415526640508917159884385108183907565386285538628074816687468135507\\\n        201658546707370916627723747051488739020012716670418040760871825581381811364660546099543035\\\n        277534274189815599144840310336734468203450592086883424116316735086627749075376631302353152\\\n        053519495674686148813083115159291225416007449090140899345551213599068970385491560414374912\\\n        391326664623084142342691007943487313183362332101373857479162084915883699198480597253126040\\\n        600148454883317797740452339364483843382264680351850196990040097600593062660519699158490829\\\n        994170134411075431019790697467957459734626309560211772834233467558485534124872003192704080\\\n        438453153395867000785379582705576369673259524275867551760676325419482752632874623498178819\\\n        379072223749827677142576278506762146624583757489326714189215888369045514972784800767239205\\\n        177063966459958463822598098252871480982052745978607200246855560395100637557024047256010085\\\n        361254579185134704817996216894670115984062184319213079452146470429058279078033520688646543\\\n        315016631032486703982094264032486425023050243248288596618934098842845202220002982809973999\\\n        512105563159935506117095342478111935343809559493721310588576914063491787992365127740634282\\\n        856987986391715709835945633612215369751975882444945321794681759504655713036011135281722141\\\n        474449922749243111965435875327454420680049561382715502080402546645718821452643838310542174\\\n        254660134062467843989683551019360716453923611154613109569757928747017904500100946520124057\\\n        803430992962926244121804025233725949916151784523207822633808031227502615100062376648963296\\\n        552658385397410088684977059617059040035158466324478421471517989211600848274006433326935033\\\n        351151774969027306504412610310760686026332747610087203619806231068015629254199349954970908\\\n        430330799139067985565254918482193815211413691460974269025605782905805702709870743011108221\\\n        300309758199405596187474104273218585513123341279058730847633582899207076312823065889381524\\\n        801477647838846107527902030258603105525430681202168288832398867927188668681724979072556273\\\n        150134062850875828237272874060531193035520543446052238399662282885214881216047643916496802\\\n        381777045870911703665128095348515026130184628780351580679526947107334159139775892073194672\\\n        914520200472456471616266345146156759959701975175183757065692295225352652403337492227146487\\\n        304482261277621459699207730517128408136148813299231274026897945021536639392747926697816515\\\n        825101320691467262588969601678612598922887331317433441599631310009863668642414193856216544\\\n        415885163596623039471279660215064149885069655038917357843065835620230587588169765593118484\\\n        826787040741042238129654950577667211734466835582111465387799066525651431414031618498584012\\\n        106587166689051373282539302199225482956707931615704553954849827812271886058454405713484149\\\n        921854723454906008931563779678887646893311840384255967541543110351333192438823062974867706\\\n        035391137249998471742024033338353456480732328886875609130718334406315488304314564203532167\\\n        493435290193712585738751600548865526672588354543764055881827904765770784273657528222957839\\\n        402414182604300253394252579352089785367457568563837886204337874879545449504781846187559245\\\n        911555008182608702191554950465187456622933835792775659266734540807414280549485829501319903\\\n        592419771976962936494675605175472409161328787292078804914780985942542400027693967164405583\\\n        727206934049445673784710309530247890036623587892714989419339668447885607590579330954903263\\\n        937253616917677688971474857594119487521685846761841368252116129045372911757488790308120824\\\n        631994972000816035006731614601034743038574888135946670629783911873414228467883646036235876\\\n        470480946069838611557096888502092453173715447684286374980379613356804614317417253085735119\\\n        753237451116805508456583048041927664067634720917605598420661859902478476855114560402372118\\\n        171206758671429518843491965021376958702793609163201063550323909805788184726072711772146948\\\n        739069961358389649983378690636574047503901406958722068964258161657980352198630764084631986\\\n        742622176129880787885285976078902891381517098281180121072555796851027504693026743259122524\\\n        993530889524528221368130436181121988902178728899181581139236121150959769410547965057275156\\\n        794022292630732802956115216791079057111419016040828928934749738286324193051160055076290663\\\n        223326669668580214989616910030898205797462818106692424656629387816836589761537214587913754\\\n        856351418126184002065758050496901504482859986433947680438768722493238958379141214917821969\\\n        473669961596172474370108862141949462146559889615609025299698797215613711838281233754218445\\\n        684606390857800844385523780039503418676774496198202499529294383769396400173338360986079968\\\n        632029521793747495358661118029677116915739888593262147323704255296477555185650290244218829\\\n        766933147906369795538162321109149946384152365923897094187370539286643310021067571020220637\\\n        153262123006443531832197119330267621426307931212461464086422935894249473296837284530174600\\\n        815034981228019280983199374565571265496590233516242211870960594103067594474895725125497217\\\n        753879445174072201790223797537381044839710251091861116755927623912593115845884382054013730\\\n        586620363473526582161878872419486996938175400501227764533048739735579098834331441822613307\\\n        932145619791531923860734308212535544175471760194708232167559371599514337131326754646809596\\\n        412929037753184691429382600627426091259624718537986980476500303900115221055361049975158976\\\n        166897010325442953892166507191293830785815649900313814112197593858884642586396788546354474\\\n        701047847494798114621888604125551507423319615267852936039920277515689909858716661779031294\\\n        492024195919977580247703930481780541869983413787259022141726525336680025935382961788199588\\\n        990439055717394881439337992690900834442059715304737736743891540912824711776603088577005510\\\n        662129692656248647940921295396607287066902809799380103362384064108596523859199917889677288\\\n        565536524952615083977629524067627188126115767293149567272687847642615433743370378519096703\\\n        240341996309373671551140930927875529938294304345469067371229323940358264069683961603258574\\\n        464362049473074070251737663986249000108047881981067563932429577644850162575562628911192451\\\n        271281857648623159237296771682864169994735296409568280597719737021181897668740008015910819\\\n        572554846624458573503368396588281335531827735601173632933225059992931997879893728541346573\\\n        140025712212626984326267318404489965187413889348837675706186109956592888922438807989644452\\\n        817536681931600248918927817563394469791425311714972879995657608071344037264505304161290676\\\n        999609817248566499178369852946056737983146231026606708656776094877789104680001028697816629\\\n        966989591485856958129919323608829681529795454892870528264023849224913496613233190810698544\\\n        649714208415513006382558542708045482986842757315733208292555539210942381582889513123513293\\\n        182119022571371050576755952599730805075168112673198661120449560668631994589722332168020537\\\n        225245900837108261368525657484280602159395259924361413180417596287249220740374481734002215\\\n        442868338051767825633763442143764611092942601964960344634392508184979861652687858593913212\\\n        284017651140306727637379373564840499331953696958400191033939887202980186524398587376076425\\\n        988296866429655314329625213348514813292639393866044970678376383903912256370105049124710199\\\n        770923892010081024239659654632962516466936422384269959247133421667612572345666536481377527\\\n        655622021522346195402978324903204116663309417264329135688149013115186697471838314420716619\\\n        653380955323191609786252181914309422419540809962167239902130215040086640140320834088163533\\\n        543207247466810987110208730454426211844865150895125177697268584626260687356237330936608859\\\n        071818342774648273601127102082286624452083386781022226549172639269485135377234921061850911\\\n        841968313088404579464762828231059173283740627147248692259388082351116630986603905670525373\\\n        999507564619622849671149982704782413142079580812587151316304310114266733399978133901350621\\\n        962691803676439521984425567937780210084025767753158852143005357423071302505303370253851226\\\n        124416660862659289467762811476414303091859696564464763376254215314290951283492597976893346\\\n        810323563307032415512857657818320811995394283349460370611497297218157795292977099198158997\\\n        298323609476954870181368997642017615738342204460348020261463238457668570605319779850293826\\\n        635887448665055287881179934033757017125751900249910370750711522351900923529550338932872536\\\n        155714640934098225056295162314582522597524314756859393817377989097624046912121690332799944\\\n        031247257057250514617405557536068402018937494069957941478254156110329430736024185551829020\\\n        109579968997316504900273399577403799130388154902358041811298130002389061430781796907045127\\\n        965032610228008777646421080465916986088713167013923541602887967450019652483872624390393043\\\n        038527424500532904980908466739288337132193918154693734082598108848281939252068498759057341\\\n        021647774811842005939311327234894551081184657893750856390314284359923280914203842902822844\\\n        511442624941915071813520696472792446838909551881863649570278631028860738517168129935174091\\\n        805351677557621444065790278765704210210445892385927630206190938065343514820607245711555042\\\n        894092004989596983121520855580503799292475170962318326566381993800351747801451508488624182\\\n        741583741201048249825972680976997500051822706621953691320806865909989551204324638083783542\\\n        049222349152343050574252484702847143795419886958948294646728755756518569453782280663754143\\\n        682676224724229807294917738882063572250040118203971950675985006568119809869509839052128591\\\n        532624168430123662815563307232105073255184402212253950506932227718742027006055258172575426\\\n        004143718064743179121683658936279524687101846903625176998570343475253653129151010723700369\\\n        234637995301276121855445012852129920659674824809026233592657184502583925779480451288353275\\\n        747069505926261898068862885145294711998184076036346477013143315540482628726714540918176252\\\n        914689648793011607058965868698447125617694423165220884124998124418041588058625846856055510\\\n        144880521712647174047914426276006636711373511667073882583633815699012311222847162618636598\\\n        730161155241426095853944097991696851135610432045500287198210686484000738181556080761239861\\\n        477220015691630208966596709748530335492528749015096880941034861419432433257943519717262562\\\n        097424296796342708285619115076032757608275795792297043825878031089148104336514193666022836\\\n        522607529156980014699668548804817900287921625160124261885629157181677353253049312639103607\\\n        375750878923891860822771442293091084455547640010862660284955012423643506180873304643838840\\\n        148479381639534005863301327227688879251525052543859423096955851683014126137498594087452426\\\n        314564096871053267455279774877662853922810915719409627325553777054576158955597812673504452\\\n        439690894166464166787165892266597782219720451225866443484780593738298038696577713417692778\\\n        528823847421239712377866384260602022065393412799714580450637892787738755757211240365325349\\\n        987544641309869301333579654288482194965309113885039186955262936596365395830902075597260520\\\n        644380602982692257048831534969376200573309972957808979476095719339158293426331125376659360\\\n        170815714334475013048408643808632008055484998014607923430249399286889140027445835671280676\\\n        380646572856705923794961777948456910523989995895277394265215995521210640107246750431329547\\\n        962832594233175679454000750449848248129190418941553977307125367115702913438890632427879819\\\n        360557596969927682890630732818699696325246869867179746573565294111684810461960544524713904\\\n        245903504655320948554297396947728630528472168906162626293398016840072805671218717997594868\\\n        531438493152229995236756815549089510295479689992896196250431531374500840825345489798755994\\\n        504492530850652084614348692140246258231939088355476877695423185490479379135531814976643728\\\n        145657347407460315318146627192844134474710049515321037113560588685573587635314150018093140\\\n        340475733803627750068257243667613860266555742925472344509521933014576792173400473191878911\\\n        797011903725781703294414881850023323777407780467585430411813349372002367953610547121311846\\\n        830290468938722129372355110930085155878154875035439348525830393536063395378430927266039486\\\n        452067364454794808913327863700542190778278187578826079248470244574260246932215696780929716\\\n        127411704751195386852321423048609405800207469138607289979065194399330268873223703836040845\\\n        131181845950457693016936013402098069597307438967018715957141118505956193552453640132078742\\\n        760404150685873725053608812636728647053450281389808643157091015170026232645380041143007929\\\n        718088321521326515234937986144938832947635414566359189338847596343630979667525365928114200\\\n        824049499599513923934683254992722681817444321399122765714169026063757273563133320194650376\\\n        840367480358449810850680845063378585252253172459672008752277079535902830773170575647332202\\\n        045666828129204766401175497911150628003298278037582460373737841620680034015369758407535060\\\n        193273768960865543711551363963530800036252392485964635556871541519618394361553614981271963\\\n        292109735566551640347562768378860712060769182551333185308631782333497707896849733889547194\\\n        161244021053968049103347301268529159574062272247213861788594413307992044732910919741710029\\\n        366143110487254626627055609437313586562815910492556689079042775069127674580254262463476199\\\n        538379590485424294307805038782921541742178088178667421131075373305027787785721851700172715\\\n        107401001322626054114955891999801314517394646426254017854801205357504467645126257899174648\\\n        580224550043458257405976191415690011728452581764257672165244241933978321909358904182004899\\\n        494272491011341211571265348460247746019790599300704354474131167809797634584856417688714696\\\n        755971007756588889581209563280635702917537655640019976557584169043106754804924389653559454\\\n        546421812970882725890840973721156722619778115513801954737273187330719713464478690264378016\\\n        526861719833290336141793569395468605334347467378791754670499216543820506130379509937294423\\\n        654546547167307372090567199809560985867558011989796414588220762835256810783284450407688890\\\n        313034877379948044660292088466012409552822889449578040940179314497728705916081491539763774\\\n        229956826614636815633583198485289276044651611567777968401291321060849983403058522936329298\\\n        76861144592523815077121759238607120354676473768607637380\",\n        \"18080559735315991653476070208258543411613478595752227867648697116477698547113561838299360\\\n        823904662001558266807556573299452203868322702160067421164446303788610702985052627604833776\\\n        466763155721160607188797074082727106688856892448985617847667398955874144444783562748472258\\\n        082884371135234630612697146518313080494507839041082020114345523859147835965048521747806440\\\n        550937005581463272674348609014432422269257615249415545949446969635186391957037911617627676\\\n        526841833770707593007061502849201037284572193970948684451926828373269170513666157648050862\\\n        455910858821269484926888257988614900319272692811134003454727401515964686508588357335179464\\\n        745016857223790678103820595786105321934227873649228951600144381226346229024934916568740532\\\n        320566547563991727073543057250726617354500083806679149192874601233267145136138876714917963\\\n        009879546551191068658690796593144422183383330992185103460435125850623469768824316944216319\\\n        297621353824512114592383572819035846374021939536510772302661241931346688058122307266272012\\\n        319513552268736446347367970392856720429413494858476782461993817670417259950280646699096408\\\n        558533695822638015651618776714755198202500440665195370830738045721746499101194168699681409\\\n        639821156453418388871136143715537771271961026456316617942623317473902997784849634906667376\\\n        915813511251554114437561172046490186572198191142432397111986899058259311172203247961692653\\\n        467636940368482598484707381100776025499787307092875727994421393717736619709190646577441608\\\n        156722690366484539398444739679419538416839814010973499747438503586665968570642585665194166\\\n        008732927409385330961349317754593456612850653965236776722830093365422235310843689339925768\\\n        135511294015423519793265183882084232520982661668341367495234829841669583336911361155483480\\\n        348460031690476901786752222863420659661208122060047622124530164677139202464548669416506853\\\n        555479087384185703410790144513521623245263782539513710291357903348419923125650597747864822\\\n        766583026855202072941951285795984668822164864879611610603180971379494055514906505248211885\\\n        502983282235262330328025477023199690783122524164321096020354555369016383295683547325594480\\\n        755571644082304644845339227787859402341929159957541838752216363301075045377020403231476855\\\n        236952348676217262820113972316633302554850807882079209044350573098934773066886850471070786\\\n        237964703581256222744827566729713913175026938701704626952734988415461399239244545551218576\\\n        338417101067354721489914248365155530435241175685192498809669466176143244493141644508064814\\\n        012152103246823231050110313852660136698312316851624040603244895974859534683120107609424935\\\n        693338625329229212453568424055261888338251277174490012667978932174356380818048495109270742\\\n        722209626501706771319641615132257277691014155609789442018161118859649839593034633336961498\\\n        474724583393739279265165486910530797879226311272886295895097760316780158239914138754345428\\\n        887380533879020222590340205736543162131037705406547732656864168745112793566598762928023713\\\n        357652860640309814308249954668274626723843247698677587960706206380196648319983310964573016\\\n        714105009422913884839331809985639907539079425781348525196029864975711538428809628002289742\\\n        059147381690832426052628722127498637793517010428978650822152559694123322397119628712547886\\\n        026485631625725547629224962839603877133923039439681841307357789450544111551622327954939229\\\n        185420525953625026220342260247607861648364050486293714357892113616823979843682858141364192\\\n        956407283222733805239253283193230651198752755245807585848385671949924703261605231171899500\\\n        957721151814376781009756257644278140359549265274435751722947117718256098376729816556291696\\\n        757867136054028329781083871204394068847096308513077751548815050471744387871955238687683086\\\n        779401063733112074026478425777188288167736259293249388929317679845766470037900929514125493\\\n        483944368515811607634095348987559513308146278323316585493003062997436242421724428553793616\\\n        220219876858974510730580780807039742826327305587087082889065849413534896355619427194153735\\\n        575717196607585042377890747298088222143878902398431111747634466793205757564396140714761560\\\n        950218052945065571043805146998965910741312368256396321315043786431495911196064441560751540\\\n        377374962190918481743583195837954226256364397363752443000368944688949153928697230694197107\\\n        851574984260071697124043771219032159404512599455616947955361804522911570547171923058856978\\\n        295117932888553463802175029190451519356178170507029678269673193791043769463315453758156025\\\n        516831204440146075006233327847976240310989808383654780165493395243663585631639813632640021\\\n        816958134768734597762375964875014531439611212617198871651587890933187376210695175142029924\\\n        150530458813701668940651048282693752122740270964580034866555588160141567321184591767674901\\\n        944927318903274769035506547201183117365503054340489967939391160459345323481806725530132438\\\n        680433998062702459983342023879198405543895613798708811042797266205829955547731528128196167\\\n        444457494043689891340482674840361334573787907324870296965621408928778938517954162766149827\\\n        918480220770631866399209111726123655374032645905486129270737089987291483993967968028816608\\\n        706653263984659430699042819385343766361022327221916322468999624585582957951179292521448560\\\n        234020300039445091463863879946906011363611345291550740512385244233837777290102511182467485\\\n        531633126550113905317280319596342534753763560555469260054796422049881537279648180587804668\\\n        336967177423390409612784232111773607982639009419895104160522926041536772398766924013613468\\\n        932178203690686853383880897047402654300379630832714954614842307593825860108039435056747137\\\n        041738412514422508372715477605354412688455671298477421802648845669209492138827049185932008\\\n        273017247958395122275456462502691480400587628116745008347588163522880474223750952289707101\\\n        821222239603570650004736666096029507826990209553752407613022179118629854639143167454736420\\\n        360344551643387376441660636144259776684166906106855990877528109674990087036066119047919503\\\n        291697128323111851840910270867796291400000681855421927302682182719995328470172961484636346\\\n        865298510834565575646199313612797386188435977034516291659953225772648871465815775807511655\\\n        275424889846481274197890020359423485326984761565148409121811996520813047877362589950357142\\\n        724688470903509146043573220938285018816324111032685993061124578918786336038414476468378065\\\n        092951979635788118237876352815121707966625962422183220991696551593203795820984568984669676\\\n        444533588489983407197380228858459873939425217132222960126104080965574279217659828595664400\\\n        190730759445037180548342272552065932953296735294397349047324500000540913126539423252159305\\\n        703689136127099284973685954744506027263072394263222357073411554992003350750295098397710704\\\n        415968954988805689129111376774441602294819667139346735128141071858761429284977863300105934\\\n        959408400991501130323201274383508053152092841086742800772875938133021958005840812814344245\\\n        468522418367691294074009440085700115299985003186871812295793389807878251097826430003040436\\\n        086248819267868286188845060328920411390679550844535492133758378317907126177996750270156667\\\n        466901352284152804802669275744986727904234867397398169509764382158357157190741778550000838\\\n        008053524402283066521145930402892078482389122547063859063946364761772031400495392491491215\\\n        720304401743143152479013732731894267847398406874715130288276402409401669185242950286222092\\\n        349600577835416046493701149351591259172580938330390263281287758885415411345564719242733113\\\n        323974431679196979163705474293308018724174831334605881831696925775794724174501831239814969\\\n        088977543201085231190526287523590042183496980395257686110859470229315369943837778981825011\\\n        344232087004426163990379826982638075145679758635398728065225331603619819635862368016912919\\\n        959406803167120905323615316937354093252233052823581830216758371252548231175879834782961797\\\n        041750599733733823887384988776529348445945006246694324814628440843441998690824838184261981\\\n        667467055776285016584966796706543984403569049139552656240000584977752173425914550890338175\\\n        600099176149224245470392465136689222698061658623049974329817293775767393969951677686937254\\\n        121075522649243823987328562851391818512268129295450081650527344730172598220381982976207898\\\n        031495286120914774650082269042779665066487688087042211732414326070397393925066188521475949\\\n        376358268257745044210408676088486202811339310979076771246720930260153975433102676985121255\\\n        554863155602751546417253550653020529732183170780451542762252257821548599537354662735157710\\\n        272453380767908823974141886092779508099411757015181831507951307353506799531083398895842435\\\n        700617991959484665080103034495617949798067515091312475504575669241706930196869760208712327\\\n        031501478384608676495723172083355304281781567920995410596843635618308537406581362277911879\\\n        284579788400479261013712499274152686692138057643435782499371003062685688719800301103684382\\\n        061759870713395298014992244327290448246137028955540562417197628716127360913376233003878021\\\n        129458254882006077140883258506611771533618925121245533247439882303949533686775935594413175\\\n        459677594702165377811978989006006429746420158728393300155732791926835919100084201958405361\\\n        541384418380677833620674100617764854180513894689185591654580878749445748358284307642405565\\\n        231286872047710713350044739071998175330334635193641250821256701967743786626132965373915814\\\n        307243624236437472920708874404727432079435839554680546316659144353716617326438604623275359\\\n        513794386253959196826112993311096534030960671682730003384960571944826466637806501331285787\\\n        861874114667462767784078161623163170067939218129709959876043605243314502470881947207073623\\\n        478809738337815382791145511095415630808927080516215544394729864731169597645495029327200355\\\n        255535333551343397563021860591215515407361743234094712366622865774507557377018448634747669\\\n        432580671296437785260441605470903717188611393078376719646818151699975348428516853293565010\\\n        596809210371711812203396283372526757925317327861722341431337327790239658992632065274354094\\\n        517438440146646910618239320622352524950558290938349343682237088718470969106214466171514201\\\n        642004431881149604461470508075836764348404772291884737372212730181305687924302300536123465\\\n        499173331339897642186053204829787520565633212201148024688278143614319207857191324929311537\\\n        769130561167069091890438914845640632468704297005169974516790093517494204404643012041138170\\\n        846234607362048154010441584948811682639868702873082122172172271827698623234786870268482775\\\n        077359190002760721858782393044322038453199334816688706326980311253721111537748864725439259\\\n        718434544799079405424422148555099143321848912349167191715823714347314817211198136796872090\\\n        474142331163938808739911963935585522711556839532380462140049473166245146426970237259842036\\\n        586853414607576574297566346864633056498958777607453139651756058434468386992411540594165823\\\n        300108221239212563848909121313085966395418435519850521587772315881289103983666623819744312\\\n        421322729980019518171331769799937949309371482760393011538299453277855936012083095208105877\\\n        032615479666961921389687960618980315887238569106828931047724604586100317660394417287786863\\\n        366000798651564565816027216998846782165292267879103230697962607166220492781464957748453098\\\n        876815234540681358474517411225226858710014735312184676382905679662769355744134664793787815\\\n        287149390484366113725435387562492834132039161458076124197735117500489639331886578333342226\\\n        367119618079033012828613639603160968403595319429322151091623865193707917896098557230258404\\\n        732968114189655456307476695579825329542426355058627839090007575345714215280496618960090858\\\n        905972959630181925252641032358626865350319726989900766762529104678473178742071673274490985\\\n        679775363374783963258234865111745338644367890838577686026052380590875742758958982354161305\\\n        112576857579790166548823776846210679938467566491752465822639814295443607610101197719217938\\\n        355139731853268303256708974916596938007286174009438835656146579618638865898271662759983054\\\n        343204175643172337212204613998407979572016288783179368343431936574966744277298792337550711\\\n        526553698301176734710252051324520438656604869212054286880714084988122117905865711645148670\\\n        788317505561768059673885244879457027956873719041661537802608319225998024877634958759243167\\\n        121455191512225689449402086581638826264981792811880382751588236782562038894354718610318308\\\n        231203952402925111753918460151688866631695492708114043337354347451264038214260332376560522\\\n        257730118436618957444497573363330170719807908118025688753012170854770940489118751319777515\\\n        242082534788342647884713488707153378015365535751023167431780900305197050671547686113559218\\\n        963292664829382950694664397071226557579661409530441798727128137107241159308059376326307195\\\n        453451031737430391559974432045458039975953161908346829196541130680829135335978988651686915\\\n        360087076603979852224470901494069461068185337879658920558220002245580490746648987082597201\\\n        496970823607332987016310525539063701075064702288680319972582602312027274541293846659326187\\\n        520212412033178380096854416881427687374414833364866941540091212928777084380044772401581040\\\n        727285568871630972191617770880972105892926626346402557427195909463552600635318753221055655\\\n        564998907886273468556094641073690703081606943956502807362101383830820753751735407122236566\\\n        691889396522634330281572693075802808338933841623378083295274098347542779681656152615721817\\\n        104716409533032720331421134991914118890931666753480703673565088882836324721850928795991244\\\n        240873992885645733096973825787803087962868583209539192659308485620271621451934138331934031\\\n        248287550324155627132296075316933061309755816400537032028313316080571489813118920466353195\\\n        061761278601117267135553611110174019506283744113085387192763931989032767125912911249056301\\\n        308718449723200592099555366975096064560385617981544650155726626768516569570071531699304882\\\n        801197214022707189791986488189795093853163061688811756420067772978400640210043898767399401\\\n        602845144304804718527247833953803113582421307347174489849111448394492161117110532297501081\\\n        127382796727014014261348533478243680428479679686164717690702502443341903411035708144621119\\\n        702790949355254791448099739140733293949770018641422945386233325927700899305282526669713205\\\n        398155725487094847565100403322049358063190443141908248618573209065471685702179650849342550\\\n        535069606601680431537490272099652122583794944921168899335033629061084481498523932541006640\\\n        012982303353237645991697336156177310133209010518015839572968196006687218111076550613414308\\\n        676372248315492036459907071124713158914120613332987097726600816233236003456585118620717678\\\n        366039777922315519599231512949693556018262043721992427837716521562798871173486100537603819\\\n        051265306589718917715298332402352501044726361180406909826145427770647341434651989410313028\\\n        381643977778380596840957901433141793998374972619245546541655912636709438570103564962643648\\\n        807914654458931967059313799245709064521762438078713196299118808958209980297279406398252843\\\n        530797390893966132297112080071410463219805820175357910794022572038852322008296375532313076\\\n        200569043586791992243813497525164440617719348246628585101094386517941882531702167402095644\\\n        063460235703861863560237890609498847553674549232698399927668519595586499572353698263077111\\\n        120740174394472160224606870317600103774199029143900618128758911182084685760344513871578040\\\n        016600210645427837380756166768415494118973029022844645984436956537224875047590336916003473\\\n        191388586795392332019334720188189101477342938906440802097914063430897385134512991072172639\\\n        132686170002050597766695535516764215805919956870113725665447037447416306385101917075209430\\\n        747633410210716136582622072886604447398334088740457972958554791945187729970723626693191430\\\n        218950100479941614484805843939278459852075194236784760956809037101270306814712177567297156\\\n        996397065155727068094119342903653812713618407076178869546623522117836337423773810671080385\\\n        238047627650797802684336936861147109443472959339340033909779183840321368374341105362488806\\\n        779220265585780317512590411267422531038074892251079117571570619640187477584383887840064015\\\n        364102640148564535348793112589021357799801048106489343817567642554830398228509559982695119\\\n        116704512193121868129214343781439161247595543540785694213209496780656784245962538054769795\\\n        387643261203402783788320796168583060750182747024334108393713586005731231507303904782556873\\\n        095035557918678768872579793771427341740262297914177894568747510533350211190301452894020024\\\n        845571002556512485891406732399002943731499406372955823728905679416678326228681188718599536\\\n        147010355658694212926663768985325036389750608250022365354076745601658720706837289914098703\\\n        049914963774957960594207943435517513548781091401304539535886978912289981941120415955004954\\\n        183747526496647323758065137365084738450417120222643905158341014577450564612191803578955056\\\n        955141661661685054300628918765342991816270682999498112709638135738294512166342716192749522\\\n        820783549066161858504693542787272921155716947938118353616097239566868846790890105440191495\\\n        031430460797728925843222907022629860208682916267191312575395282358368818707930133242701342\\\n        488659598998265513441713032431863368229593499046508373934347997014353156968701939460657020\\\n        614502865616645840149190773523719051037901002639262646508989914523919326639107804268897930\\\n        130831598556003170492278653102508272750661742340570987492945866884055167166388648615360382\\\n        213934320507876808728579438572430062354398514862836216392984393042495188686782869399632600\\\n        850489849217545097760915380619666615434905118584525497637760698181413202444030503901697970\\\n        105044684836908019779588855972058770533939630167647493883130752201183942300304454574083883\\\n        042290062520877549754193804802951447836647899991524484681402550610757595293556805807708956\\\n        131477883143551150064520598123610112256012503606083994406714449338046264758915760274096322\\\n        494937630068464205625900873790048592507784485101337402324336402509909868216030336898677440\\\n        748369367083748257066044982302327069701246869395460945484318733884276588082257704496423628\\\n        869239803700492075578049384757418358421276241409781574218945587999402229876305466960003608\\\n        995798479394379835513565183597534450971202010329725053053109331651123827154808383727331136\\\n        139537514633968273703116954591760979691262049436975902158980879030180226894830989176170938\\\n        168265741574892194184467598763250126827407639982156572421494210866891047206019893096257396\\\n        071619949760139492051892560036151213307517882478730442692349633505154860553760990902981284\\\n        948526779342052499644511243186047656005952346277072336706137251931482347049927085368356603\\\n        292838319780867190383360275096519159382213774779535752647951585820098765012763287401471857\\\n        673460484663865957292567761972700337949409515645106352480204809248909190247107824786427023\\\n        671610267867826071388590438821232510470988503181960184866580245994310654032637254304820494\\\n        828296241828628888824014365003947008208493594658693103342803441990063434821718132222448608\\\n        914251023746581742435834791868161108522778506561256452516753431262674838165638355049406368\\\n        556272908658455615627507812724909706364911772731747201765601868636368145008054318086043697\\\n        980623615011207025617898924876248173380271408635960499395992494873293542563016987647980160\\\n        320530814767210229640704283388483935041392918254872351851961438347363224464220117607611017\\\n        320565373216835928553654685138973525387771758951481433173824171763768607149968991465881575\\\n        702663075116837188564426352909565826850101989915944253346158283524393370303428715948396320\\\n        700380371006008655932120566441583861113363184802302369840928172904792343032677215810538472\\\n        577252303628971651441846766176721850613532890954254339168965250413819318655696033312157223\\\n        804232517109746768187250365288615889725754751336877461500827420587312425897059751840627570\\\n        806926320848086608610501571508631735535673356749681195023723969314249552435013210203554472\\\n        658755729357378630198622742015755416431893215426934895861359610295327012994166267376096647\\\n        046342540006784314760137326657871264604387322061364405239670267955031011006517659629327891\\\n        559812118292047380292863410154474030226230690394562514087024897397960028072523333858715102\\\n        624424255489268933344398962237647005069332469944637180238421870071438390278669086784726003\\\n        978770396952264955408623253204484752960255346844575830896512150808187416153937243255701716\\\n        494730355176860861301681020175128180534279986927724012281470662401634395164750999668405991\\\n        126950335026853258374440761774020087604787077122838672978480241850146848580103342219171867\\\n        174317759061802804628474898522890727149634010159221141455500794281066949452972560836903054\\\n        894532620541687950463763410936864524777201977855248492639857035836235207585524978629856562\\\n        258925201026364966868345770963418562208968895059732562411530663955561158610501786998503685\\\n        012608204603889997461897497619265335145029042043264821291566794198060615889531239107227381\\\n        008188958761065101998820831740354181887259994743316509545589307546149387781904887022131001\\\n        780650088509790203950291749849318886841019580300933078746683664612561785320799039526303089\\\n        994054575419587729718991222406818546515799871239356173453525413650369103473876208368862121\\\n        009110607027361939035362038643719074748347513246974143811268554348206120434616821049986310\\\n        042051933021145134015870883521484747936172433691919121818909102597710111001397236819684004\\\n        693399242514188207948554291429132284856454812305486614286776092101551952858936869865032180\\\n        844532891478574682533981306616131803872812036197833784295569565090642474830785636621155291\\\n        974688870898020130035539167348225353226337011366077173796921144745481086144022322678698611\\\n        410126546375634582053840511274389212517546821635809846708170433235393118814135412130893508\\\n        970970336714039859930190798735000892225149541171572263514712824622329176655947815360376982\\\n        597661014636787833659114682526783098211913410569284129709184463284528028614618471041703883\\\n        702721761360877395341505325672398276116909189038149632763725109211352854678044604957948211\\\n        611946624027947388224134430775719914331552457532716421998580449263779075469726037946288053\\\n        036895969409344452599228985661576950983649311553013005782333710679824942611113536661072106\\\n        654287322843076586689974837971052511286513957052288491696702460736953378295735364014280523\\\n        897409974833482385083237659800122962889213476557321005638856564195049164160860326680075901\\\n        910150235263192907411389782837787117273223779402466807384920513878615662522843883584058867\\\n        205161219617720111605758847784231187488162336754398050953336945665923447449614492538348149\\\n        419641170143743895836348965762245662158222321543609700125619626213917574767098709421453728\\\n        471342096533163724009678985369365446630784682964762033559201912605760302062088364868635459\\\n        390390292324697157454524442619756878788663233266561322112019740519283246852451639793771593\\\n        206307362681986433857626947631009226332157528948285371005080421195171803735287238395202547\\\n        269223770297680850574127650557535454455427401869672550034479428754999428036033669871990384\\\n        510196046129592968674606658798481273472351773017034892022020988095935768275603124329977047\\\n        838763848697611156888533626462642073091432521561912987239986941702649559581349730678417682\\\n        355718558425961323339911632966742919353221784218735302656395319047051945061982358737070769\\\n        510321467219860769866074137894737977034648704626895017104249139566366650317801456644376831\\\n        389798827522684363788872591676137347121934335310400760554113773999284845211092169421968890\\\n        671909550213068021666755832550328289035750977073557350519290234841892503422832394074147570\\\n        591842096108057534752860117714819782571354253437645073446219756813157254877214480943141156\\\n        792647064660638369082932592197115303735325863455451424169878012854599152551102995607242975\\\n        116809463991353832197453847719926431094928543484775207122425417875664729230204685314106264\\\n        606364349772341956109676681696406311672763131889500704416221618080540456408481540623014621\\\n        787432536764857076533929089180919746400922117770167922046337795765038156365598336426818232\\\n        668106868082310907664130143807191097772018896556421296241771530603434584026973770708716646\\\n        817517324656295546006385163808284134981461377312364106964746102189534900288647587114693758\\\n        592222731704110487350156281431680785551440905762600140434334896372843694594800663485171725\\\n        782519582316475319657087419537746961544360544186768639770688649308177070281841383024184674\\\n        032312443326736561331586029649627837280618049168359381888144392479537209413413924697546123\\\n        471854261721854110491534633932574196916822771550234181058265859179178480589642412766760048\\\n        686436659622845015905029305675602563207659014253282438922239828112138461776542525873740407\\\n        044729320734752709269125478911007727356465392994587582551276652475101272762396788205755586\\\n        325147999748246797702240171110654692348077618117866152991197014880884679202570527335266841\\\n        312097891893655124766776638133188153761444131895920365067324210642576431050306380798071880\\\n        272709635423864040774403943418093699946118246003195214749720934769427917501680783625496571\\\n        522190318812851081757446517993374679432887228465587185942636136088079742389640753565867024\\\n        975047383863325890222215732354705250680504888126277215145708167274145082471433274680263506\\\n        083496190757223456938214801526043209997615995113523983035768332095568461557969189579222141\\\n        755108757961880297848955753766992421277152015116391642081014514527563183543679116583012252\\\n        071818050391105870188457923819197178235713539286718637680715437314628493399702401399381289\\\n        494798567927848715726488838661601170967643065787270264334744213901181021125299186681144100\\\n        635807434606225751556250975071742019317408924192797953573501504984607115486614080565316119\\\n        692578815465282258773926062710644523784610800619647723741093242455001265672989459619787194\\\n        366166229846884589067820368225294886575126469530697468347193771102513570006700373988479128\\\n        443083924608368477485719253797570419054332110010952697806510107119222102788544716365053098\\\n        734645778752909620085040875189830097827038839834363039967300129898560070731879136375327191\\\n        359060448392494903504381709259627367364041377787297208728252309493718121551179890697745790\\\n        544792154917441604880851650361646312150392974125006655338358462280123551758011378887534494\\\n        196040518211464005116874673562866673475328086495102286687307549443216277381902616772517484\\\n        325598685727392304321981249782254805365307250582455889224995466434813450484179250065757059\\\n        759325138423101028977975988241037725983492749627798363674266557147114170676950613414276829\\\n        696949084990911364005382269567011213808092530314901394858564686206200534996680674679036188\\\n        642499445992532830390106323764157021450378857629571051811826358396421003912169819749572245\\\n        009060238232771389698413240243196586371275011178807445339870155495298247450812452940264052\\\n        335305073592488412564483917944891488943268321172043911249597933939548886927863041360140671\\\n        049565541664193521912960520501361332954315410254148541189004238211957020612017427402006816\\\n        912302303861443642561824993280473177658606280250349275645076752703196674142452177354849778\\\n        513652396790965654167491227636426196200262971011672916578206450951654726221537079636240536\\\n        342283257661428775203963485904396447062487145377232557755187862343205777577275739211138481\\\n        709654948115642025441544363827544733656712298687906620988344616934588051885248539287482740\\\n        467315208672849921202321760216289674798394688269511172584758385972325928096561907448638736\\\n        598492667817593732537340626082227919830153554711240181160920421247885495200183581085241516\\\n        859619335473064301851839286893698331331586326948017262429827836393499401039147396381078038\\\n        673937910310619226715335909406209770292514376816432738106490032150680524133055378011113149\\\n        658959094340301068819375316444489789190918002115102333413727705953618112896537143925030823\\\n        346240870710783862948563892867861466338852956385663973857502724888566549214868994438965804\\\n        730336689235251285715969961131729373230673669686268623578363216017370873012441922577331109\\\n        432652775806415420772803669288082686648663821796644463197964096968966090462846340801920037\\\n        557732603830286400744114455843602786259976791449699600712746640501783834021183436551626379\\\n        695899093105394862402918235991209132416280368778666994149484456615560608925656025276159782\\\n        472291632234189739498535953086540047609468568651133830984189174333478553809087549074451911\\\n        267256366597265750451866647976164986642761848158975240809333781437954309284676537638215266\\\n        354263491429839750207163347404013731301580811987476586746120205323060056596262860098445829\\\n        838501930622923036709957126725674972781495741956145344785887006147693396164813952595998057\\\n        431642875763892083247054355508345155443581623840095242080257826391693325741985320590544364\\\n        040278631048232330233368751985379464347690754266889701848014091461620082286155557862507678\\\n        320227385190144770047639627727317743245792243094218220234964823318705052880366387550103327\\\n        493430276334565777896521293817045246910958112217305002945373555765195923067061780598999756\\\n        269966518380084929111009279607833372893872614622527373001788279937609365480848911594722539\\\n        079009774048740735922336372501079005004806890075978338921553472201636471889647407805445797\\\n        319392360472506112793746976543307618689438939225037254869679115036576125579333152304669595\\\n        180197461253934341239233766404550124848151131635527388492756058704479353199809769421548763\\\n        526674900157463899772526407262043074524708701349939301890819271756827275720197608119035414\\\n        086910206795005694796343168501083228039171907010437524071865040769154692338860123410310851\\\n        999013454519680593076181829717986236803857240052699301300927245848923363902994247234908091\\\n        388859856830900278098084857494075531347421018381441392450038758605751463993103189933876570\\\n        183392123698303065764961904182440053660430761810177601950410195262111518515776692899888535\\\n        960818081330249534432537279464393367059721053122438496765455782697072555490150350526512151\\\n        571745242895613248121320999361550515838925262987938675843469955378031066132045548170377469\\\n        236887034206754938885176324504579469293949715011806239576997599340014847562368098307304241\\\n        480358500032508946168981363469195731024993670575085131023219727403597607931796501362210066\\\n        524037570786958727299979992944582032429483324207137895944520601732008112372265913982395698\\\n        569155175394556370496670243328403189584578540153005457993917147629039573125477715212979584\\\n        557565350071191960504199404659346487744804427773158351577252797699033206925252991811857492\\\n        659581463504741401902958354851571265839141895596717647577498656083081879383689810953080285\\\n        674464507635428014763423287888777919731368625861399875158533112122632341394487203902348972\\\n        256165072434548847070245708700552285215965286682907853461308150479765913265712723699868846\\\n        829003935808359163472546502719347563245103198402225146056426997549257958165488252143848507\\\n        965720422699424135702389175911017471708135540476289612142147580303068632502975631529371846\\\n        479032019789500836432511845420758259513706509837445112872422692506598228070652684757870970\\\n        887166804148257196201038163588711858319345190416895648465704054061946228124577536736767921\\\n        384059532218459999319514167259010360715840231304973558992717477230312573403740593267887405\\\n        289691642438254254620048916021880986836735894557147007934759085183732551756147297848085525\\\n        883101804487877645429751497060991980501091821060102776229443276428862477940081812488976720\\\n        623596372740267596864002090310940865547723260948403061195127591562466913546958146219359050\\\n        724563157264006757498937110303046532348020005279776821578402287206162547004615383806992496\\\n        770569088386151413115699234281365117955827592634298769152730217878350716899736155084561568\\\n        785094072398259807592104591857527601827570129236978623004734949640975871608762732123474228\\\n        511029056580594076993397195399768911739490210239441049202862185518262699797686556038119275\\\n        818097518778674509279690848195687333160664175674991897648920926591425382771209234714161254\\\n        841676684644620190246371714041626626952289890266054793332933827730627702734471536471318429\\\n        952299538886281072690904637007435488161140930022124860605032158100651349785725079682669117\\\n        039307823560438815878271751293811821102416414181436458964128671543701759157344111443146385\\\n        184894302235637473347850644934427464179289666675265625119438530296142084553855330221763549\\\n        858402702115760128747315091022246650368754418078041848910688903519262778576169741505955354\\\n        628019523508289661066599191310312748711703412918634225552579291052845750678256883178660337\\\n        156888901697918960422205401339389568539708056132919691946907035397884451522501289341864151\\\n        095025351089695470757358617199418799130378787380809423625338599946665329564465154607123191\\\n        271657432765653119866964767708947784853663873498876926748918918890417328510911739780936805\\\n        979460664302599140949951756422765724305833339967071058618769783425664173481110831392482043\\\n        450712632106431909708139183020558699919414081386895303177049444661352889343887461656005802\\\n        380100658863200059290966388311728627792142717882990681617725324492610707294180781635550195\\\n        229474400841228058121988848094168820437958263755801289970702575422418234492729955131308871\\\n        798999792745914569724474538071608076553107266819644558569631798554129808933927847360545846\\\n        096475341046864039724558906590345935327627373911110604944201141970970293612636627825437505\\\n        621976417961334916210017438739953280730358953221992110835702738234729837769941926725884517\\\n        412625953843585072131216524566301065840845120478969391020577249488056861959404288127438410\\\n        366343144187297331721859118675031147531671716426543662003454454880641290766378804516806790\\\n        604977738102141497564924917460712588166032299685390680932970648435294971205701917921630676\\\n        589085528316762798081020691763976267313494346210274410685955161691894860312253344233674175\\\n        443185467844610445770937767035287264423396389593322835118391118529776775308615548986524126\\\n        318010149414940060145294589843413247006073001190302404763881320615008397903248620428838571\\\n        279193879714584103693717912584829817870739618490643071397611147734534323967837564196123124\\\n        607612984725669164800208253914282965145876514204508027137675553607645281482172846475741271\\\n        385702201891186930807991766802340402017391537475135846512493555657217759757024089537023887\\\n        735712809678631175640611364103413010595826740612412341669738052661954213165773048066163823\\\n        728947687671751542716161572343218359419301960330711067555026010120400310373548053702766411\\\n        342439956011202586726179197992970695834225719987188425294931942410515638846466046073811250\\\n        955220927246436011448069885653563043878553090060869822595627590466954638453686882573178035\\\n        834501363805454193548256192126797321069306504317400655088778571742138056630135847475568959\\\n        197329957396149140549891282354727287487287286075917709721265053011857248487602234743710441\\\n        647858952560964252632287187053493715337171356860974098093547235616190518764811203539862692\\\n        126260758077198916465861518957656835075570863452139847953361990742990594046643357528872230\\\n        657576027914788751403867882027996257995236423144087898005805027932118657403495784954662207\\\n        217841274048291431288876723415689157707432387821239761938033982412388674711006670793787971\\\n        824359949663724637426896627527216920408949696642740201814396573218395168760056849714778977\\\n        888273919286371480654420111414559770062851682518157558601353135051070297634872684731481464\\\n        000978667664872464190432708102345022188650880454219610858445076512367336983506012736743269\\\n        301922364722306547372685517085486590229982472635809900898316836790729634150053651274692202\\\n        179238767779608985745388091142218149039376436967300361770212026692298937333927883257809861\\\n        104078209255316057841974744904305137716982457077753308660729847356708049984007840089326429\\\n        156965772826064363340946721258938893184056828886055215185292211062304193498218141239963274\\\n        611901266887699085270304273224173321592265167775809989021623807831027704859056035819040888\\\n        421073258726989182945455350823730109087556894891940002210083178673444436493754278811046932\\\n        563893678036602097206254887786701544202351263621146258269570218296401468288758130274817224\\\n        032826921495766150325902759200539352680118950469976011433268757090317371025186099470062155\\\n        691389861772041182887275494141419162787065650372657881036669694242264266002086891214494583\\\n        155175421499960564023228833194541072954702462657587628499778468978078063993177796731428742\\\n        305484733164927739935471533816669701807467556756470587591692153979251180526301383817552171\\\n        049866886296197135913547210730486905795383585174803858974597879686167760390173446515329167\\\n        684037073629831072574683554026159596520054505105801272431022629158950755665171190730111004\\\n        050134775774442170700306193023287723407757102902274260716295647044804173093717223435042268\\\n        180857336743435700734620922460431908930336945993786806428663374200096316444995796478225414\\\n        719520110200542150454148750187613650361836739564930385589820473578635112532833380735774015\\\n        611495716687247191064160039999860218942000838808540659492564592254467900925578984603010217\\\n        841675777320562921253764320615544454001862607748124457158961047351157202560125354902157927\\\n        690565578760523612277121129842037632214563694994691063764334406007611416352909488764293140\\\n        681809497857461047120506456459119629591489023665289301739864087334889136453476391425842696\\\n        307306245331833408061218128239355435153572253406478742542278366306143669599730991051816096\\\n        346234468947078160917257389997041300805664324193697370755079686534663875324567420384897987\\\n        117850618345029868728208234709152517062885308245701652362935518301444633691429079072701270\\\n        076878762283071891281789153928317576135282202769890768179945097331209478984951419117677524\\\n        587414096802301149376098676256437001952319042336651502160013420464951294296693958346472647\\\n        216771968178724529492553840063071730382769977216478751829961531179222154763663549287285007\\\n        335699017900194814964443850091849498577317319037854635026493073706534199798436718163590808\\\n        617626279810335312955850896044109139381007053986175822651572706804624823144685163810257820\\\n        431222553228641126122675553821064549377702800358866307419646480488044777435468449416828907\\\n        843136130474151217991658848487790363719862252654862988512963172279987620886068706195953785\\\n        478860110105736433023682497991808315624695758888565878252765727538270456670209767453195005\\\n        856610533648758899184340343203088188950565338474300310121612405881981519044559029732797629\\\n        985387804673372021865549710245972682447650420609456365568078882753019050923233461745272866\\\n        126046404517642461926079440230091520658746020929433702930876540356361347652270415274429326\\\n        858485326503739240807473781035412177426508198708777178117967233534711855404374385572900786\\\n        929051090292797060898091460703314330649781321083708363556558131004453337853946812372053230\\\n        584150362150952998834607724154550919510781200452005056593918148695214354836147460067540172\\\n        455221663950215520059019567067508534489433392654446854618091802117398340588791552429404958\\\n        495858467989811649978576025161892065965861726516153818109184942995895339432778430154706156\\\n        742508022982540928331670507720150811710566301104206966424372745268365743115098571904034188\\\n        002511458732781830857188632853089611964055194292339791443096102943764704692829034811146490\\\n        022425979629967459653284995220636842721930029135094449259338748926767297216681523757170677\\\n        395828416492926826136279788983538989324906427569574419041593162139201162210943138532741498\\\n        265591414239111356150420308298443203872259935107680953348018281186356912391776599585195639\\\n        607748926001426572039286928056393714740992725730409421626408477697293386228377856752752080\\\n        791916921182144424470331835992753383091736163964686654988118523683047077003167230592915173\\\n        162673873090526822560054702676817135824264171915909001763885869348176413636292371044757674\\\n        031223486496985484964866743146004358987245620296033487612366399065226325093793462980274593\\\n        320059836729741671194016052948223848072929022229398982841468228867988956796599061865666762\\\n        651300582895693509863784022551239327520516861119647103429451736226075559495683697020746631\\\n        639745260808335467407342728006416320269114363286028289075613986332989055315461064262262314\\\n        347782070502623430810441509326399360038754985377030453767137740644340491945197610870429438\\\n        874534163955044196389378695349569419561919439371979674222818594441392674754734874089336871\\\n        923919204055228289583882476363817105114330732181823134021512587634502288570467559224287018\\\n        932111860801214140368389716733806187768527623090335771856386326541048449498760570336914166\\\n        540724692559127717624004675264616966876905180303490067695478898583424316266125883882537487\\\n        121598596508690730367168211656251181844152303190222265528476519436396814701329897592988556\\\n        331347250485258822371808777935776439400799135464738921902049524882822399177875031583336218\\\n        272249398325371292067296108827609987950376997607162083672541284494064524432626723288511241\\\n        199263859580280057754500869867744265669429549911411014035305739247304978730874499493060907\\\n        500279078463304055208818664390294181362479146540712280908310744349858743364963217097940009\\\n        344630331243485707148103478709104731474856403670247898351739007101217894064267466407060871\\\n        355816451231181972620277436347954498607371002664567896759580439418159411298587597818676004\\\n        320086476245724833178699607189518918756384756620326010730808823068268769410353096478687342\\\n        991155182120180002391339945872371047711652613667972855501300209878008837745725020020449182\\\n        960702104752579881890976138327205006030681582365911432592773216883725220343917450775374387\\\n        174719227949462339207560301307685982231815505384963065659403122366933009938682631948320147\\\n        158261271411763704891280946420735792043182475549432523033916713045161583207005520969324010\\\n        248465229310542471517459983976054894394388603120473296232023165464072990975646579076838416\\\n        246502916787444830905249063793397834755053479378122277179828727001527558545903253000948852\\\n        309294710377553533617935804469267391517603182973152071173438559571173693843447879546891845\\\n        668304589602225570626816849809546323158837883551840985387300406182675950179723944167978289\\\n        325253215356741951582916862368490401127020773881086432506945600122472035299054335642600538\\\n        252095241060931670802877146423268346074187824900869803676128719888308907964426609783711000\\\n        952985923075011940549874867203097428774329304651093502764308698946016245036447872770063404\\\n        965951519466611586224962390836592002338515392096451431723483982346258068529808169135705967\\\n        568143221941924443513905679837103915349519812418242716858282239049446678538842284414541939\\\n        285044498447498718770547072832398000084194823251696761987496826386928118544972855759095968\\\n        733927371788804108750719544876390869464752928461184163420889108834159762097262639922410396\\\n        248710923434633669943828983058014647160344088254234820482825625576530995230898983415675178\\\n        761773928255951771050301463849824256803591455942219710383918155419574448240928019494257051\\\n        808708868066284020400002587142046737431433470184633440970098818503392002026476466881574067\\\n        548152483554410826698999348394658844723543329641710913526919243746309721546161892005189758\\\n        823326619424939976734935518750297230756138979127414943476834427971611704401854645702267015\\\n        422559827658345323562296635459527725491229196194289805493596270685186808864601290006131061\\\n        754225332605338332997683531012776910677781914205773134889538339713885721222621679865803420\\\n        886371257234502020614509330685122535837534639634399379104803393873119367906013305279239820\\\n        701339546624574011558883381465928843753678003871700917004033202651510648001876171069549404\\\n        267534159611981518520743163737078672562540904688630923404741223771494103376148982202297756\\\n        540815978380732039898447113804225576870753507810424112168307262899651919387888612631080725\\\n        368926365324321222369958732480752719164334622275176707430691477497444333568045550931908110\\\n        760426659418505729427090120055579185078136722577474031602647851159646922999298060301198719\\\n        046830682238097860958758095750286123494015355098715076801177321761033366929406514885623226\\\n        465801779828202468840257971015602321771324132406045507090396712692870920233343183219121110\\\n        978729588674169456357870807742040770536878483153924957904751725106686136918635301181833367\\\n        294589050676241100993791979726023853513562091326458555917661391154127214507994986414573754\\\n        201673304194632787441301748801112111313676036447097213492529359739379132650598555129193565\\\n        389742486106402237679026084342364892653816026846252030012339950642201152459863259117192047\\\n        548513084540015771948057924298645386540715055182889806308490106588530885578183795661830208\\\n        637055584211642754722107425496341602545378694691562536912048054187585704798895177561883614\\\n        051908912504415586616709395825772538348063433048546650296123322268355330103755276916153729\\\n        586452409694623550955584359690189071836623820653308785521148508304595750731287277331373745\\\n        521255589745436016310611521451994498629088452557855436880166272107858745158289720392566564\\\n        130813123892687123525560203071747941597264333232308538613667037570620185401636095221684389\\\n        607574634480973084325398870330779074992624991766681456702307268272918319570803798085362418\\\n        015776488785300320986856423350753156102445517062037694212075250102416181994725948267676239\\\n        611761523264377198487149150607822152246175857879181082312740385514195352826245287554335747\\\n        772471679656547923810166637002574113955828331273853143085909845312794744634520753376881150\\\n        113317318679741677196816122414708323967254168869355872720119854499023272429932478318070622\\\n        070347806398025175532521002902025500096930551128689561521062697489651400730847905449531983\\\n        703382870204333189273975106110548717920633454660856051459964370117266591316123697686438606\\\n        422229702794133899821936916570061141087332462042213434788915266390893942108034644536731584\\\n        215791551165556504601647624618260664472420788771907675718101377383155966342459828216282071\\\n        203759676628006096357418319394973106158086312339861663406769102234373979278632645962711019\\\n        468048400774943182181905522740472684052433445919066000007894025362541679514585951930363769\\\n        493061855696410274875364527924944954583203771075062512192108111412067129682260705195760561\\\n        835311731051312069434380577459628861489157539815746192178315418367570716387016525027585617\\\n        894381030774146862646732840271123651291156395684965926557054591975569227339835915388083255\\\n        705326150853898664359196174086909825156449055370141717053001931358605784948442280309834708\\\n        473070514397859067341459675772692577394775905579677922496908727315857614440292177804938891\\\n        696724181909757391092456225687868168275458442303990284309404790120132650295762840867832583\\\n        243840547740738206421698988324027956335747832337623424255231576435099703998089149326989703\\\n        879671203666849498462447157449937944270508934896466806276250455983903149225150424218867470\\\n        174728802719326603681799236496569665826484927438563904140616988520202950619176731926136369\\\n        203244221754213130116613482719853138675720738854706634636716097772602517925925900592841000\\\n        488523714968528788023809136918518999004029094118949571447534428760551356034789203919375207\\\n        182588051626772141251268230983521338784196512583951772855035698222962792341097653981266456\\\n        857524061478560926998076832946807977099181494803395421318776423673098600434370778132171592\\\n        807643677011376022362593016883457365906193359753862143750653766198495862483231879306501456\\\n        111820751088197755095372432835081839718650147333176819608538556245765388983393312199523722\\\n        015204500904265497934755546233756539908381159642194181900736626457264770261902557976628146\\\n        977896476851416753283177325052085381168546074893595217671769199142888998726872236556183772\\\n        101310684120351923168249424523101962680914022495861929152460000831608153277783973680097512\\\n        509731750179981842914722967901323572145086668510498230419864623682638605039947956425856368\\\n        418767239654042611130860537045539076988620642926865059601627342950080156075586128170250107\\\n        051230549776064573991061340693122762942801350607920597959210004251157029520464724837878693\\\n        230465234040603181008202642158149664967745232430241969941493891041487556964612716940819718\\\n        670472624412756928279541840517467710404977051025267123824375966330658298218784884430117213\\\n        475989644684681202779795569637483890276857356155897187304430963586341767349854429944905263\\\n        668351408385677754039507456102238318671409082709314023782434886308442472490244863447364842\\\n        038802127824978136209384196653551832676752374392513909866126418853883797894022977619610496\\\n        146237938155834358951795691350005335262159957657038722756293291472375900581390993077842605\\\n        757145100663122606882887906775320233238629535914957896316286537453839147790690552679490942\\\n        922881935371740374474531539918059684292199363986239806962004602211839502416543750689227873\\\n        688975488355981434423885872328774020723193114042877469753462953402826010092416840362401397\\\n        504982535418961020301218487151679097676143485678665520087690884245933013319103887621781902\\\n        896264243063265352580458470488515503069621813999301649424159716945248166375815958857014459\\\n        206479940315162010721514438658983724783902266231728879802130197914465635814083094658908610\\\n        857020562786731176990749266016849721570969456950757165003307046884491747521141162508095672\\\n        476600768668856423564674767166281510808941321701142330759421245665530161366724642566951073\\\n        626997999524220111096688121062412032818260016054634955049739080614023324282352069102596887\\\n        159965948129026032013604698842988326897518245586832065540918605534465333286746865162324369\\\n        400618391397120604020467630804000262917586300377144429909903286499757774051065399344522094\\\n        986264090656156487790488086620149810365812518032486182592379920314678324174538549476275009\\\n        399774772625992043555886117746091318117389385168077730472801152411632490345725945325886867\\\n        440314014076482999649423434192071872173373890512021201655479636035836005831589331300831951\\\n        827481137919359124844766883595928335869058613256041915762327447318727625462919421315738017\\\n        743588149534496622928585719334695581485357370009165943026825295715843773190872354936836566\\\n        995365227701994142506075202554904860380458456065420609822101874032599821441560927368681211\\\n        138024002416990088297488362117570846114341825101344671633501499532836762376002578311841794\\\n        788250490545367323761651383521038045843801596683075083660511328668259367520497196751142496\\\n        693538311770724434559721283442473986198762112670137229631585975307832759154247273897596279\\\n        301334704690128777634809717808778597392586669254091223753365429441451080419539320728710037\\\n        293397273491009599562192555572135323212918264613817278817188872273707646511545535399515141\\\n        713053223615503092137505086124431535942857358083290020420206388699685316852839999113054237\\\n        178533458533540725024640868602044114576583710021820559134585841752332353893184450031852577\\\n        643079767623086643699491067649066412248573310280451511725662175396906103846629094105867013\\\n        314099607194321405397006772430177421410827888617315100273775359221495762563465741809762886\\\n        898512878449657872986302115459710915392576359403602911072717829761034879509670663031267945\\\n        722294853171595042883122144997130465159444139934779961406190660556902400151163389906334047\\\n        508581853973993885251418783553859874606638722157919699199505234329828254530958980975138229\\\n        059548819075795971610250082191472086913552191731531764713269868692152378519624835106983905\\\n        282453451736900299103372436331275245198484617086666281895730434988117136803767232895206715\\\n        986297238932359847214254962713684175218561586627346494658533778662065498532371417089691229\\\n        734302164567807216995125430339828475225099109446216238156598257814973245036805933250162414\\\n        281936919631132724975738090171521802683415781010410589781095795848869420513298295351312994\\\n        488113503992717032418490777489162470467708773501394917258112832074765413560198057097662809\\\n        484729515699828916277854385716704359948709463530977344414442961420684224127571252042247368\\\n        815932653118603715412708149140695707026269936802051236397936284470250516107258797451374259\\\n        994419302632752454440120209135199103811913998119349627192505386930414491429402170509017926\\\n        391366572842712300025432536562199476239997790580805131117541000673623600551677129223536455\\\n        171039639121489145752208139852236539593192516400493627363938505189065732724076306416886459\\\n        700438343601662867063353856281229954078760532759748764243737638940340581040982262093177293\\\n        189804649942232030822279423384066983840695456192816915076623501648935180540262074311313438\\\n        916850002461783641525546825178489130319522979150463564002450192728459563836958226364680066\\\n        992526992802221517791799454513059641086451699398014540599704193039042178245933172430026350\\\n        317830582010477392503824322375913195132010561769543093781440280281600810214937749763285422\\\n        905423808032980896514669392036888496182373419168625308782752707236520923247842599286023935\\\n        171481922445999145970176864113314131965230900081469851800117044355944589770948520379236512\\\n        261898707507899595929446141623641840338519389568252505156683608290377983800575356722678808\\\n        016027624777595776042569662807921652505515212031294561122525574770805046520211439272602702\\\n        092181236352064034582490139038968282604708930450231771001199027638198146967639859017973199\\\n        859551367060472047187523484301966434120200585451645063317834668865709088502680799226666964\\\n        646860447444535228576659640840659797134259287908909833667352586289635144521209201065497250\\\n        846549617600120443914242394801291058407971629544917658850480285166204290087558134764637746\\\n        483721609263331892141724645136524410389227630303795129735433768632335917494233681745944700\\\n        905555682741900546604189814017848645403079491085450404421472415599810426108845956692152730\\\n        566206138466875437805257206096983637809067256237846708142908841886824555486926215116973988\\\n        788073541088719325487269529063276963948326427575862672390540110777656272662177277064010681\\\n        377069190444372170886706656612374517403113363207575233262616024710450614594390025371796769\\\n        962059125867896937674559600724471706824309698881517905453870624893030514966999687223886368\\\n        264475498335049998537370190757898943298766487124720607512704220299039293205609631146923395\\\n        662390989357638174532214393140340492900622403980501016386160677353321995180961870470981470\\\n        023588231727927626953794444436053906507574387808908190340838585124762817907073448628160008\\\n        020398196453264657110130331874264894736312853514924581785520665634202246622768532337408749\\\n        811878918484311289202968663422213320804329669679081813375059368645952783461280900259346401\\\n        492226879770639766100589430418477869164099098712065410266215665828036938099050347288377241\\\n        917652204649388244145039808357373837186081979337602960355049923486605906381725354416084810\\\n        946039596133153573164932532491196192433452943221106069696434844811092122094764642368518169\\\n        559142490444550312110969435091258254153290278524242794151085909074662376002809685280133235\\\n        390969472711878726514072920602026151463072479243766002394515969170595006464935140335279764\\\n        194890629810771448279415119170357383439994989045608296501057557578237749540378711973031195\\\n        822754262836365390967967033673321223831167153385399960661627161340923764422173907199844683\\\n        224368593054226069109027103578929522927794934610975877668250154604288693637279724497764377\\\n        421470901759468234178507556124567211283942906145011235686141670822060422600738735963839764\\\n        904153606549575023367248905371352928379989184562769664575659219497377762167994708394387121\\\n        250065095633483793000193249122572343010183588742566720885247268863397320192551339470272013\\\n        085284145531781960533577712938389227976626646482160889084488322722435844672488147175135054\\\n        159770500107789997132915605021576005593622692796003066327031798844309870081750148242731032\\\n        600054394860118920869948225479822920975012126810185441573502543180594068375175285821024410\\\n        436131650449488281488578639591859987799612000522989863643937715873782565805735488736338761\\\n        192967242242555165549843271602716538490872836504225731031392758723676482401349954850357272\\\n        966537375247570949165493377201649261560487210333528471502717259401067614908414871097148315\\\n        491275013885782993547166933266025670932325409126015275650309709077244478473795599456198172\\\n        298865080329894216832414431625512880838572524102257630954742870429671845727900241005797182\\\n        877625677991041220335637131836739369414585713856889534546766989995660497342368528418061679\\\n        546795138408232750573418514727558619750188191469273653428772523872210341239737915673923248\\\n        592935707513816819073987227970033528087737555618467179918988902469768004086328743941228785\\\n        031819817601198632662232102201951853996028281009809302521128048123012095576382081107774052\\\n        035467469749008110580159811668802228455347350456732849104498418776014468403576321672379464\\\n        945123869368882621572271342235648016365176379652496307869608407398582399671145142959346581\\\n        528743344382476888319524588513888449226522291464864867191294789210314146150284038952254427\\\n        537664973224479674864859325325518145915296495490360328491854707075535250172016822724392956\\\n        377475065489309918228080528623990565151369329508800726409539544360775515962185392803500547\\\n        143965256985172220610355941149289153583177715027143866812909531677824435452149388880116460\\\n        266794604029382762657190213378638129654565823608724082328938939269204159915652813667722777\\\n        169261650980247742597371691851417984313770874239495006450927263291777690819639456151812122\\\n        195362134266019370177233861948117253812989788953646106809805868151327793680682587840731046\\\n        060556610003247706697657215671391846976474290212554995001238918924690805528595299016047896\\\n        011785438958301442536196826367326045483276315210046557489155153638529198346854778150366413\\\n        13203423185070990681268388596224531260264663483490569412\",\n        \"-1072886528964602468763814059009904508014133318304867541510165207934389161532591989776328\\\n        690432876813004121271071261853651495309404705438348339419067798831979321818034739406091382\\\n        748030878507569254284256796377123007942881471894729435871950373200002861892706831689914874\\\n        333999159043586247134920165452925374562913180066132557313458003721730019009101787228316835\\\n        929646503307865911464933114731303380750849415007888604576931708910810725233979541512928438\\\n        179115683504901592600024386445201762563350113395680656604244185957468761475543304208735907\\\n        799358712352980442404749529644368144399174061689370502697867438236244844348925525750443219\\\n        566069373340381738885949703556474764030929615093748497478361782752683536563492791049327096\\\n        096855333302289028550930080415879281926872993128647180656916727630195466996530098696426116\\\n        502218614031479280766891765530456204458529300017169817715097783754592741636808138092907828\\\n        768903542350172663514280395847635758977469404183742213057553840654331883918536310017542646\\\n        588370982981254536880527498761301961061878943034131828066945557799066933805176377024741268\\\n        873936924112191784529300762687685961481345729104639249226668184018336603043934490956590267\\\n        409475401699235754101151176185081024075862978244306572366007403197202026325607359813805060\\\n        129934380896793150152789254784152666712774013225934342571580770339380614468284632241644941\\\n        834831902014167422931756377078835064805672986713788827628449148508403670470127378105009839\\\n        324322995308822030493403778080289310270422495829339999545311980561995408286605196469566205\\\n        595213756196049340516046651105022197810523522322284959936216837487359677213798184860938411\\\n        849037206016072232992821453838926165910452514666556476259310042533326640387488479357277979\\\n        635281506658420939205485166084368097544182189277907646602684448904576857632562414881073275\\\n        164963925599444698176783206868216256725368651026308891502455998853779277688749882165429168\\\n        024826647819626128730202679886091371462272166219629206967439330899564714209167190492808914\\\n        633353019623375661262458905957039049255741111822052089699885342604159383681852184762810974\\\n        817101092102360797012607182272642919837337941616856495178621898578928155890999206217659763\\\n        275398877533394100234657811801500325090341092897103440876197397161612647019595386621445047\\\n        062707317560029639650185687499981864187760176643902809761256362387773686188711352579902539\\\n        429444283302348461778470464409978630255499243858920156900905899158606389501793977542574457\\\n        134937802441755849190574616029581485621389052450960790512985152517292885513013506488057439\\\n        782768955702620361636864974627073081056778475260456945759346282784344053426162908954561928\\\n        200633104395207430556315113882285292818370183574732290730442365278954711274813688074066334\\\n        221449262857161871224269378905130663512604612822161002336590389158055048658011571431003760\\\n        956863043904471004425138310892485930479773252338235300882812180806655096615307003041002941\\\n        449126738368227355360010366583974673513153989969404089586976169867571720875354756225984739\\\n        817049304883358024826746146421712678878438908806853838198721787278330728069768581473123213\\\n        413132632603833450592776852065084023317298542779725412147259979930107175460741978725388792\\\n        380360273819044538629647872632246727523382789979018982169692721814856805076026052583640833\\\n        091808273549243372354847363924031977505338636751745060417521090869291791688128952051103131\\\n        259014012483912891661429336580134448017703278445098952233481666529715466249632491263970210\\\n        745382694865672910875542903271588480714198576145583651021143904352566726195997095214142976\\\n        527913331270500411287808998883787076914672571881561046712843421512200233068262049491119352\\\n        615787616115971758651250829471841358761717343881060375300253100581784675242765886360843645\\\n        145909760685223847526964421867280461191363981802946265750317441563957364818705776613982215\\\n        327048796976479985267595320527297883505014114615116854109564330795798405361684028294595487\\\n        368912275668295711804363240154884920089182750284831613406882705101990693314003280189717283\\\n        267358216911583657789263567027936898201382735149932224842689491850166658783646429113915579\\\n        339871385430965950032148309511567293065410243428328994634694269385665154519951018023472261\\\n        234711251093389476606080094143455902781783687651630223382825547203200442507817370575661861\\\n        563579678673324831907854999896852922812936146381546305234938072735671814262819905039888456\\\n        150813028093577425581794129364235904752930684615691951662687139252446571234973358534998280\\\n        197966884159412352403359206078904200530265780051467131732286895030709409168315763573312011\\\n        607723553786838465754507194784354010877579247279838077618795879688888185033788297132144767\\\n        774821321036889503210410675535886767821739880781272084435347046186263410839232647445463222\\\n        597557448917041487616557830313099205628973157482984870620535667250803502893711317764167138\\\n        851773960775496271468634203467926217828319248235919305022039066721074937032402853729397478\\\n        175474413916042651327350083667789452764437154996640099236463059245193519405741507619845734\\\n        054852901962234059652174461384858420071502327738721902988701640059942915676803274983745413\\\n        766876555610541680818081377950516737626890177044674401712833796401725697845599141291192163\\\n        329934983144437162778365422808606615293619078797807988371051111269619559959743888145473992\\\n        376515585651721286590431134923518460015985496186873109935311610862746508410686181657961022\\\n        006758062144363535894581910460192461083674779124124421571797238287437251752393502473978052\\\n        683980157269715017347193665688581435433810496429251447197104374358547383180142560838221349\\\n        789520442508660605847251028551691780887241107988907783485653814182844068783893764443943426\\\n        674316456353227356821356982302090632004782910160756258898997804622036709328379240158388213\\\n        914042775445676382962406000262070391721039374512996285113439822344433982382999665661685650\\\n        657643588580942831844194059459824534068671358067503461636026246686427684085603187518143546\\\n        144286128135618730589719034080924800125321722022664992062771718613306029144916499083559595\\\n        312289444641132834452319859930627870915841343494830300784023511760618532156780708441766264\\\n        188093792488438465520932276953698168863146785339766182135715049288302677005768223524127018\\\n        480633663325054810052848337041195320585445219331931043307794366274587050468192351488901850\\\n        168234598879161976847440648949558738461876625732136035229739031015545688512485984781597604\\\n        092370383344804158403759498786593402717663610418910584980577051939364313495993801676036660\\\n        724563903985804680975202197607821521926898640033941955905756529411681766321080947465730160\\\n        368364666007938699628236112178317108093941645913925480837128525489778023962413231137792044\\\n        569217387580410248514263907963843783021514573477773981776153058250307877024038524589521271\\\n        568955297324892350618295525023304079783233114983516706778801938541088345074680576523906028\\\n        509965480197009641726178440231235936614001176046972170941268173193051444886080616443779081\\\n        884503974768026739378607342396547768678532643415719773349592739119576539396597692070733284\\\n        057222864005555249223513191080003192056079959060052790385029884165130484477630935437065600\\\n        785539269378870696778960852691469736852576987855674657959195698773516211435769569454638641\\\n        458545465547324675134371189961557091101652348107709328788685172874428093249708501103268525\\\n        939160605172057772817420564562338213867141907377055621384797439870481053568113949033534043\\\n        080716933340602971534535154078778769277007387445070865691799465808431660366840297547593364\\\n        259082504645025471341988422655790003347008185147121939116117050513928117358914084392413876\\\n        285160744252954121115220449342395095602275425239025349383506129474332348263359151591752080\\\n        851323688493478895882133454510745726654530166068397710380286451470911424813808053498650368\\\n        276265962003684876515198858140454837743410424278144584313308589019430400429614145786262227\\\n        208450325033700511999469468170012169240775968310614811202773975188143527583177614412822919\\\n        538720583704324811319606520963953872809317875286164204339025471576698227072539441558716625\\\n        653335449885894341138517782803875370269705058196280987836390197295413941437768301647915496\\\n        164713166499847948911836904036632999364927073127412173570161054712129644279802705977790288\\\n        920202840738407150068313756947329622127818494285385460481037345755035540660415172166172423\\\n        200084324069461470584735249202967642481295153553325537904838392890691897284418596770707624\\\n        348701252411808013568088948001605917510419357329534448944307518441690824311929589201706589\\\n        214176803583894700375091106786751716595124437598498799306007293455828734867367362381936044\\\n        491749397756221569439183975100566386584866905301714949996268673411298446070016554446099690\\\n        819534890403830250636760175272914667852838814940336746579195760295398606117618273703773452\\\n        110553731280686649851504858947895624253340562542221313373254355679212006102173214764500386\\\n        760994721623144212994369513811644426738480612210300900456084123194222413177158741586349141\\\n        437715321591894181572184524135153388261344825416402128719730484766434458174868839632172396\\\n        446391590690735849895777360844492667751832990095484726657134736860176920442551029823444750\\\n        797491364251273230099054029184927223399162472348946834223040230823643491762174450998199329\\\n        240056704628481770579846848678013595124909759516733561970356436294866578815923647374092377\\\n        188787429229387468791157332478379287320352834510032227698712528628885645029488997379355275\\\n        067195494729255967841725132841437536664991153189615602975752154288226149859277644104413093\\\n        563452628009334720118190898769685929449723817272644954784712454901807051460316560032344983\\\n        451278264777308221230186260473387140000534468354210380789891883759998960570807284658152482\\\n        154481140013484103160080828852252539056754138740449691285928802524607664025138798135523245\\\n        948669997928835527245239854016085258498816740251651332042362153972226254740313345386332645\\\n        485672627918373982018984567891133069177580860920150775027749816164291844762898648655097714\\\n        819763867110663610241406686971028957318521180263559695658320235104104090200625906759937379\\\n        140884313098196215766548994699792876728085301556485980670263467925122643629999455795008022\\\n        649758218275423143036233804759287418282756171409129171476521964147601651682824758875416077\\\n        400714009251755163132944915076526291061978886440176263364989812742494251943167340328040002\\\n        739795598124749584778401233706723236735849822270252316811809615436974119217607791264865190\\\n        969317514034409966401365453657826296547152714038356064814006959356426577995034416500559492\\\n        730288813050908649336330183265417979942855474782345457098204089862348646931115200235645131\\\n        343998972334353343648328329613875250881500918152409342443960666085820909557500948426782885\\\n        489855269250960242312994132398724721884746117128058514828157464805350801794932316114935927\\\n        093917864867805137437719339383967160005298460928134138061283401364970115614863493653038451\\\n        342292850297609024159336677644157231543944703887159965961281900871810874008267503683845727\\\n        594868465323316700073679426980648534848992708977281046261503925916515073718205087246827318\\\n        487371778405088522666440768343684374869856297639436516932309680193696461679715736962992094\\\n        601281450743823561858498359391602938845229860627170887335834961140746868819881767037465005\\\n        375534147915574885803200951762400006064036304707254950653237074927262773597517151332552829\\\n        948820125079820502169975474854664538681022449104065663140260545341378300651317356610921768\\\n        587665423121464714932068478292992864123953972032207951858244227174089925005047699912274455\\\n        557586659256647811944146879410482600579038855013117923641873345521005781916061553399614662\\\n        783900301590880190915599250607770961909655890568140119313630546538029111211276074579809058\\\n        196294492258758144260851074484410628321514372070685973654389299806719775770088300096423603\\\n        738579921134008538377550184054866147562635795232396558825353810138686939867082227578014873\\\n        060608376647402299848946279281793459211227008662034612999610727389355129946445998090013257\\\n        948246206017757520577530270955576537745056817650345771040682219229680589374920599380427286\\\n        460186281458617615618153062335534507840502904723078291459998991168192722350964745909735742\\\n        527745069992680668498511720978151581184913669673363826330207177298556106201611559484232365\\\n        766964214027981379842675338862608576140361326243954804737929355231543626456064579525843557\\\n        752327010948645742500300518667150619933978951529276434896296943055528869025337822419867277\\\n        807926208423315624862164290513918528189566223174769312797093470125617367907744458452449059\\\n        130683274639664758718397108697850825086593769089636730436385684306451450531276184780872230\\\n        230378697758633686351015438834086114637335639812841525921600147682801475399348914787236619\\\n        074640903479960574687470695359455192915516458380783669974170987209828160396377053956411851\\\n        125549656749094190039591213424375356365599531373025886140818526758624947379214400417194677\\\n        173828700447596090747597802756063769474573778242061000146949471753518178740793795492000151\\\n        469858630511085283440284191659300428237655354556407566147031581636196409392414814440901564\\\n        382222952027485676447881500240333707835786753832622287215821321391335837924027878085098480\\\n        518552670508809808696321387037909959568985721575394669533061186710721841699935329400869218\\\n        084515116616896525103567782446955242827340497504898000573173138719316545408200437488492139\\\n        258757686550551906134450403818386369969017158857574046576916551115163382802866826244880142\\\n        289650134358618472612532630792031985394917395953666057621263076300723568367855993981275352\\\n        727665747619793673118525185824047828498123189540498938348327112314284997086780678679991345\\\n        026767532494288729412407577184733305761627050605791963837359110354491277108813401616954874\\\n        384948949341150337482347438078984731668978835771706889622227614339845950309170566489787354\\\n        378119190972597722669839877569905166236462562142056224286652222933393016864111698673996393\\\n        134784241308225692477593956386414829565357946970979390864895293046983493522184433285998523\\\n        926033322982767997839129784462158925435241144091394530860850125151926701539986943120482763\\\n        963265958818528504183844497407159778915616671613335627707433311969989212453363125291927586\\\n        982305074970014750757927912474582810412563786171994713090400077367618749812487755132167017\\\n        482627030083136050777868556563900001676108136923018904546962771470307072487722358501371451\\\n        712972960534701067630780126830373863826162966157189663343852255454377604183383534031251190\\\n        142456293295655591754023033032357940683832073867992848926608015525159659409933579050812267\\\n        760248522256559641865577452362215029845764565883572121750894013672156985148184404652734455\\\n        464404536125985814369748235954857575692138310808391963788478721136132534081140986240533172\\\n        613920353339971389037021294634985478932663661277407630405875789909428734717696127768010030\\\n        740818748802480694633696771750578178842519074383364080691350449981424307402877808700610337\\\n        354599206330934322481434326035600205852124537397441108989312571074097879305074700243185139\\\n        849408660131959012510191346873083300939089048668140828570468498578666148806549205225889347\\\n        000476912477131554039207141113748409558908817789701576152421960635460413591059937472342795\\\n        601704823675931372928017224372749088005188242537454952388226728117611394504915232084312018\\\n        405464345827021792391381165058518299028285250332412823105746285352951036173890953019340593\\\n        902980367308448242252827718012660549337736161623623929718204867950089989585425551065436337\\\n        597857204671880959288416109911627938519477160758267162459761438600549123591595945507578526\\\n        882628831092945482542442511460331014927915449804991638580040805718881140276853834627657622\\\n        864247156210198825097868786282355275515411362783584072692353517238980899449878326352672281\\\n        290681099994592349129620236230142799261990010794713081390989660876907359707556415064655959\\\n        277726133881726736187694957408341354949957430226373778610208163092622689044207630785547496\\\n        434731521467183375528329052945150656807873842357642766313977696659769907477959182339073539\\\n        693477284463046659260404833788376975944344825425891534405719117126035425164976282663121212\\\n        830658108909708739278643076041349359725621553896942700985033951159307623361120272358269251\\\n        999835997572594080386919575963113952601248775487555616191220024471887390136276452493287770\\\n        930482407367206566384302603967498005384194726149228010939368518846420502266806995296255362\\\n        285992293304294698487525288864946507808814324086157787285978004603866418154469892748664491\\\n        614574200312114043395720070957748256247347067023849672642511538831726531037624762188875841\\\n        724382449265187602848228481864060306344228596346895264778822587279205297897450321323735694\\\n        332114355431586127663006787204014075672003309259496568847552698414577575457993177028966606\\\n        844058321141138462231931804303275635678541048746694655585032626716199226880527682597284129\\\n        638541879751034079964150236485313911426943056274632945767220805667053728708184786038967270\\\n        952050363153293235459658937587940433144005313282895416426694930163761205351066317966412537\\\n        443942707531619327793237029282285603660992570108965940494478021866888402913187724270531831\\\n        455607585727312202704678204396127770006314081962871646069209340578252824270574111214246455\\\n        409197142803426095032528479462194806768210821362157000555511391486648371888279300714040096\\\n        924881295867876301818429709141243165532801954011439696044380386177664503397310212447977067\\\n        118111216452137811020404929527467776236218879426959251197938434764276673923606250094419338\\\n        795580124723083282518220174692801265233628355444816295637902605101125956378641140094600241\\\n        322238831442035803459870819229950481487243525738744013231968777729319055401681943221791987\\\n        980594453997809968524889879486902046587035262467506414666743872244172322728026292408738651\\\n        022693176083674526295322115423352298869152301508745399650002265999413596444791333669219067\\\n        858851614013547915650705616040810573288459232477906293124289281130733551778325646820662513\\\n        169565265735285687722957994227127176898294274160592491811221465695073360005962980109858814\\\n        570901408129503159809199241780216564478092358180769703254694634595092383516369047811720593\\\n        560636314223762389349742572510982774760276547153055179530098789459102151396056511837366579\\\n        845354196213391232740899324842769170301211431805110563237378128314831328324712422281518834\\\n        421657518737115206894642201728410698046417840425985412307843391879882935991530088868156488\\\n        401434342253963479012381768210255561346125356801515024910100096261622034257633222298011860\\\n        462877485317452607727592797381817348632863818353680451229803159658409024059564192321972762\\\n        801220943187503097637901285880048696322730260696176839893693072825973848181187219835010376\\\n        206710211317551184417012100033081733286147776232743507709180191364835550569525911762167173\\\n        043820550536715050002589954301230159480685578438399676614589677709143096664047740748739521\\\n        179269008893681385087867494236577552671228670524996375589456641335381476711235487092202663\\\n        080058863177199597505455192780070609700144500286898959337478153521259393587458990631282664\\\n        411814516633325598657885905912833741884019404971520088181565367307289500709391996616349595\\\n        229035577645522444974967499460314632965222400510732866829500085149639243240640082354708095\\\n        681311950812140638108428906011047099690324536131136491101432427335586286662326989995632588\\\n        546527292997263111092455268305424148708566445166669560077591603920076691167905756580442736\\\n        093811270942777884437820956585399489003724215775858631900423468355504477313641568241699999\\\n        788809587822983743086173943574358467810290348561024254049613348370946880654015723576061021\\\n        102949319943338922703592613764914999369063069975332683122622683809387551216760044500718329\\\n        927190534742675628698657282232367729958477899450751655023196622085079673833042212225694060\\\n        578893598362050220300793096007706059819493378053847442002942356456737750537164421041857968\\\n        352418351021406371882070843386657415447438953671815808835136362496480413909027139873624123\\\n        213211826486641045461815785402730032246520007331066598087411548826779431860778074402569719\\\n        357253013305550800153230050202803832093602230689187089669007142690511070976668196930432628\\\n        288789441789057306093323031046594728804875718845372509367709356499600922772476815139090389\\\n        955945970056272353461325864091797670575081528172943818011147193437284998385974882494733749\\\n        046697962202541761972624316315558401525237235091248204924783346178389125226526889470846196\\\n        654300761646644283723703493077393880715365713210116389187989751449317161616106570495339159\\\n        340783648478575075083459063412325467807206719259832515217494737579868472254421833000300989\\\n        109453460574004053101310403202446987595803540234692988515266902711772207673095823960894327\\\n        536398987560017218601088296043156499974099915822605854046700034188007558358931991132378884\\\n        941818244761625680619172285826378284125677970450095023113727823295581111436528138129155487\\\n        917841691588887047690695133043165075637698533471262923691260994015859897547369987743838656\\\n        317369939994790188049601491542941618501766464937204079204588019248973288458557418301303009\\\n        332998273347857601348775974939627850134812727096979894738053039324606134692004276445852371\\\n        456994256190702917036394481525546924262320879989812883799385118194367359589300009595518215\\\n        885236965144277904710297295969899500791778069333738589612526524735311502142650183467333386\\\n        812210029684732018997108809660845005456217580373487719060077068755774065269765893612628115\\\n        240818521185179069460595342256452226185287667617254514407282318987352576485302417325851378\\\n        876170513471947730507948966816120215942719167737297287479290278698950759006170181604784701\\\n        080742578527753717761019504973439320745910212537186209159873458124290208984696273780219138\\\n        358825376934828070892589885415678801719852379950709532278023541651500980572217064884652491\\\n        336995257178710795382595695147930059486993003925455644123706191759057827606721702588760412\\\n        087307861509491847930476716497744386404909706753692571069614619644988267320145985204814360\\\n        666350463183415808088318934867194326939362182656337554803441043740765676874970575306900314\\\n        934187416216993795160201040601013702902942538910003140700674715540500985477220572964325527\\\n        073530069191837193043639643328940251342105276797615179462511524150139575744854751571669388\\\n        646846194697342434115404333568693798631851771467227819934811387408843596916350141228936649\\\n        038047884243204411974274429223408359586063912167857672706676504656642739530611847281383314\\\n        281701257973453880189916250416658682409878036171674585981365311853120715537560247175493670\\\n        236672544535207189202360031038360714400466375707820177567282531454153431913252820498925773\\\n        754133593800400586739286937409521876621187234505176109947926332449526752233826550432817790\\\n        590024122636685772700630631651551308531082375570469331491515020175179038662352833511060025\\\n        103233362609382085357810533928583092166478279397828425821733569880017904040587850559882893\\\n        760485654432104042255864847197262968669225793719886831261998046044049218034832856960588698\\\n        998937675252889860014424055455724407387636026004012605493771837618195190545034415030636400\\\n        994776274558463738709572350831912130149070908860227170448376282947270512328737987165665331\\\n        914185882039448562370581085367164611722283790829004211582451662414066654973729904764183463\\\n        195518691762066477114365290555149757768731988676228903915297466801490242638087441096897381\\\n        267255122584027678892506282320174916228529788122226199782197390663036041659796804933496854\\\n        700306640167847346747590254007873058527009519570188797737188602728118409327338660452219512\\\n        722067071752885470935240241679080944216811345310185703564792167483030081246190528414365648\\\n        843952047198715969729134162592888168788706016376720903664864515890175471380975319057179642\\\n        971747599626976342389710798989433707786947742146515899760325327418243442106852806767074197\\\n        196709511297745671106218528067972959859167111189482176886926341120582086933238610360693610\\\n        318877238911232074877631312451724405771868031645684605269666037253234038714461022498960970\\\n        143144759411967961141936790886704155134965350032705528140706328551070853008623675234395539\\\n        257320536045797942846016003655812583980743097353001810835329321571002569605990682149883635\\\n        815040823820739032070168803969590233935432324779216413885662589377372441066573196305884374\\\n        431609058954032147708287743256033768038740441907013758321433840178207730849434968969096470\\\n        169582468703026048040620980357802104807160054674284946580393121698554865813825737809453154\\\n        670282845168680887197199736138080097554230405575747057123506377987111670792435963694411183\\\n        041557308908482058206372798286217109441938624854366096189470351434020890464730247720192050\\\n        873308646157584275667312987489115284284554656178233459347382607732467422403550895930027959\\\n        627967286245208728948108547186164241942146445298643140206917380348178301028910251582468906\\\n        424394583379260847829643999243688711127134367756139386942224212896481832142333469586965870\\\n        832664468469607693346706748598965477802124355492453954257953782063947826254961101262129955\\\n        409203372242671929939900377672065204030132129325364747061599992654686039072923351902273356\\\n        171601736967046533947399036795453580498916756406514051060799136169125549776890181970235415\\\n        589232175578415485846720180164029934629006598921570669659983418488217600421660131746180829\\\n        954877252747077085608771408900486947195550303865911055592585010980368493226888632993187890\\\n        603116654641004876651753322203939228299012777171196905927286076828456532605572154809104155\\\n        381616941815123393726773760603810819559459612704264570285582794451301102332087950453362544\\\n        012510256960410929163380783606814165577771365866735255752168513859474939726750590861619983\\\n        720443726111552529863808046697286867726879758640429874852638330215000017337307636586659031\\\n        659051567364549125682054661638739107968914177936889279179175609541152420442861936421036677\\\n        656574275636304787148670334376413150600712230205016982846670151698640105612892058026182201\\\n        840202777401372323835947608258659260989811692131863922846170060121916775639616401975568794\\\n        146088402493055959409573476849251629720590577635141945091623453520350840856309284682653188\\\n        651325111915910328346035143747360512672426829068360760765662931614939429177109393279575247\\\n        496564344906668413171416627233542484782002769057321363832117365285519400706564085510721040\\\n        056775685254768759538424421937769351103889221742152476992896262159118491838981083541533893\\\n        209875035573210031453769947258004580824596386382665062772825356343237974493350121979983020\\\n        797017474651328573089429956588799836795432485479468140383686354285700235164736654787011058\\\n        628282614660291777569516683176781016098132720217192504912674405892807689453407163113602719\\\n        928429681830093745282781638222684907222289306412374659516858759799515173136805091793887036\\\n        952200062281787809595001207738127841889531558786572649929752915898024032850015105226295569\\\n        902561675215925038089859709348662507570001007322684587374601236711974487928504619049786211\\\n        744706971680668822809714094789316648038582228559857524985728937069469869891420795429749516\\\n        873031872122177499207766906842148349143071929030259968783810385006293511776473463872246156\\\n        985207687712811661822873265976347720916386456901968621229934333274796359184040759538234820\\\n        135630793909581492493052686781735175289723595946960161789419926944937641212299618367146530\\\n        322657209520330735293182936032230663835290075546984859183265806914789230347749373214144361\\\n        111536155027060656208942419937474964993734001078127086065530171502211821405503100257203309\\\n        880929573767337725896100368219184962323363561898109161054305251937334135318089226349732705\\\n        801607893553526759348431525529268237099497437979679791851840885513311804865702133628736301\\\n        637002953592749447074090875066767718906401268714907425769496434990769219455564899677848218\\\n        127757962580846593223611061314845982888540105328937225960124785101731084562973850628457851\\\n        297233520893630226542228530145498686458598537500024676434182537321283355333101142279409892\\\n        259215935487986836911247054691862038030331638227786522062276035369042951955903084154780390\\\n        257821236398078675739012399381841577623270330618410198693209438149989807681746054041589577\\\n        510127170294895638402332852767479162765134763936296433563041189391575474379696656896844553\\\n        965192374590621947688510786417476440647542247609326468254309373121864274847523965748624355\\\n        150420628591521570104314396129168133442021604342682023610603920016865721794398518710330220\\\n        355682540919297388945771736342445644000170962548581908767612969497569702292237841420114029\\\n        781713389461655383815423233540455583237321437408194611758984546508443331544713745681315561\\\n        031307802794673323104845855894631003790872369683612071245821152822401959894928951615791466\\\n        825883830316719144306640753624468755615919787888404886875342036881372549887017766857080283\\\n        581008021659418463767981227632458063967447238136191057135997592441524524934118005976752840\\\n        551610405213705136287728037592513382619901252716587424799126288959972492934382116029910068\\\n        439929153503958666526987842030443670749178463515118564409098737901029989872450473197708957\\\n        088055618450551030974767897043520120559224963086775481325562116003807597322682535381862998\\\n        430126421312941392400741435900639792053294792674765174464501890568476987135029347984071036\\\n        824698718962664188090549885338057675168763675824857032030921553538530233537163577360382189\\\n        366535863983277889362255784805577008648707897611015440985535318611902498119253358632786947\\\n        858753184990098064985305164811808894060051015868252070450619584752569066249605347281094257\\\n        065636272582996003131930021970961940745690396362795205216925066460566308578143662493421243\\\n        860576408093478367737462416151339922019382925124294489430294786058936389596398462355495970\\\n        037954815059326976208604357454695226782599321702206309627788379741854761185942053087143090\\\n        467528494787556724505092239598504735538495002378101102743433579588750262322896956936430312\\\n        816570477938666781833372366758475196630993293052359727271820851556263352399657293536562133\\\n        825917029099912532424894863615570306831506988881627926011976765012829670425557878648079587\\\n        681828029731264740120752959984845052766526159389917180696368613729930090415350372058554847\\\n        749228585626478041601780128498976625044671484757479432345972817231782576028835284687746071\\\n        291002192051839927966615031636781390847249271570744624105814378649538417259464621979938008\\\n        493700694125558181861314174196279302504754174253028146756733384153728047307648210932134490\\\n        521451152532152987425429627658172196596582425980817996485972585947758102100797114073618143\\\n        291860159954733922921324543840515196435768291409516640918484413120679562455487219650947724\\\n        778308432540570570045664015584729093311904880872174184167723311684064306591033976276610430\\\n        387224670869194748078045595091505597021273536393892257815782797282491988268250259948525701\\\n        483637247343162228042380178696514075102004997328511559779605543531016669844046207478731875\\\n        396017395884188917096257878403533047746355496024586618882837679753774103387285896750418139\\\n        132286114599684081242799969532917625639657163678041260943452266704121645901240387725507837\\\n        178838300382558846125136395465817422710272339724075664550487210858274442535380748912729202\\\n        140706507882433883891271677846964664699639333253028101659701673475682022913742896899926541\\\n        407276324212134396140146539213808523383055233340104369396358028512490098811761751716090556\\\n        907436110634057081250700872342613151369426371305345079527871808955705132057566953122635769\\\n        146398318335027854985783285683923759691502860111987502232382547288380354032987685639948243\\\n        024750347084679690974484495221816253484223762698695184482182507606379302492808464961945854\\\n        033595180701811438840427196212269919267054537803548652923756760920475735620292683520359318\\\n        011973856032392974309453222387101873250043388606141126280685994918027450162854900022328402\\\n        748479119134436723714569828905368343082356043605645149822194982463221048216105986236373017\\\n        534762732623361201367863367424769789540991969905725114849210479654578516502552165932270618\\\n        952069379637609595681867881550904359166201414469162036867044586074465623733770756041465521\\\n        738622187537401746538968481556494843972448938316917057227289832638274569993866461385718045\\\n        958073996097202536765228812105765861253041705976234315163857905593530221206839259818934180\\\n        519710729243692732236076244358799376652224440861947663386482461618323512594377578323837339\\\n        362414278649726128948064225593152042947220801373164830440405949703987342569462572632808754\\\n        702261500103361611133645065875178956107922001945730818689382166064012281278390195885108400\\\n        604518634275904892626398619433485160981695764032320950332221934787558573929382837504735969\\\n        773931773902593023836361735434965527739610872021762107540491918975658255067089108142873360\\\n        654106382824670127797255444840607837260918692506232571934689150143078867214010978861393145\\\n        186471336515639271890877816097324216998102688088246091475925613850412074045732691630851644\\\n        176638749053604291423322141143139442423838093431738065543758283257350906197538167047424954\\\n        907841716003125510564786908916316723217592523809242620191252710528233473819151363735225594\\\n        195801779718382461276521328040266054683138764243561623383521811128570267123158213578709775\\\n        172309823443127015860796727024093923837798316876866324003405486955504531185755059868440781\\\n        164946928750489784535247717956664123298886511483832556385414746193218169983668369481984622\\\n        215082749744245162570767627241506761366223807390698216752957539502830892214589669367463208\\\n        397578285076695693473162960914628150930347460367581655750191049529626028450868981734082924\\\n        836902282558918869955268234692161406410008976036479792139892744779108928186819529561056630\\\n        804335969986176177348367032404351540988119379371658139912471979657504833511989159400753415\\\n        506936868212436459251048942967672641923961952341318767579354472339767344382713425445842002\\\n        487547463102643217092281918603479846392254140463926168017808285363711082931031760033515654\\\n        320445136958223455850975839014163228169843634886255775940481736735730113445491256963555164\\\n        915722088048096014938948359647652490179866899344294714285821270839315616734153356013524681\\\n        621699377149887307586946650276262451186410666474209780131953242885489747625001729504916948\\\n        095984980509145908555287810352097709842291794740873247863118864543664899249286025390511576\\\n        779353881114486244657628586842092497091714451535302571823992977382521400792165888072484633\\\n        530955410058154839740361230671692145915639160855226840439988010717232043470200861075844978\\\n        518272297833973206890616507688898970387307341520300527790056348853174599392186690584131590\\\n        581975630670624421722102209739928309350570100421747891060885480907255854667475146039977614\\\n        731728161100114604852228137064035305553036750252593860247087731493522310878827817356128360\\\n        873327238090740269821088691780560764713515185623535182633363063779932918319072879312627766\\\n        497824027922098582925041308559605571599972968655768525209608757102139789238097148853381914\\\n        715817008193027690734360561133932490260431711236460328853573591756022310063196819276718658\\\n        977991792598783710483325631109096071865852735119550612388260630465336715050337184444436175\\\n        480698430379501254955292228383228125083554213110143717877575903205861223522257272747980680\\\n        711784170402576862944620613364552175607573647022649713428818752932752219552511064075571367\\\n        681720775384956977731467632744912290429639421213648291639679754464649016256972209523824918\\\n        899636690434251631511927280595257810454003296396085606227275986697267314866595330615348861\\\n        389524973571442482501347926954284750488649450090274901229524687898409228258631194978064391\\\n        215310826264796542145022215774190887543527716131450800603914217562127878510793324710422462\\\n        090658911121676104610783267235323784268502008784450693730806095661999274394608040023583349\\\n        190661766054238754353516187165596297204477713746088427713753886004418818874172902694561754\\\n        345129520234952948509432101587839562983751855458650899923562951279870663743989678430728198\\\n        594157053087419189223828809637674432936099835173346082717756613153368918511500050192022196\\\n        197498460809650371630290253546222442436445393543684513174204046432474152251345826045859130\\\n        156289734397819349701201005466509510214008384552771878772004440132904554013910745455576444\\\n        770206316269741416345289840097193746149084561464209243881139670866069587750780967872669416\\\n        666016801474493473763474589217107608306422579013131527840600180381244448656553168949868953\\\n        318134735641044925178700091994372231667517134177643488515510462606408309783032870397680696\\\n        496783451575497524831954620074774879445190098943440056425684501983155810240049442011423947\\\n        834765524563652861173038312158039106975206603659756866186540582021292527125886782766832625\\\n        170153391068432649684495408122591931596633669621769744371021413478609548559217578825282625\\\n        187308183498194414342226157338909406578898998915767427471912270982357763165141902742251381\\\n        036087591240037645837612821398332398513656088024119244046119607826273969868205074520483364\\\n        996693228472957463215804413717651227510863497925372045987501213235434207145257081289352662\\\n        679707426988417818425548763727127569500457175444780296682592542349271168136133815455035732\\\n        625349366140459479165610598298697782010930733683805446673984692063245123881345064346299322\\\n        333176821830347590886393698588043901931582732135965672219662914404230895440521191791395123\\\n        367666714884674425051298770844897371440041417470836423566741949711162860040124920063228817\\\n        683117291611263744805243530425473163386027566453546786587719133972172114977992099353243686\\\n        083440048287179039839560588081409315150308834002724482331618039711072285228673898169861304\\\n        298537763388928370343473312430473723048053999141390137194166888835639358342837422783558439\\\n        876795888962783760490141317281538401464518666096300764777085099178094983413051402176203527\\\n        348634210243345623934128098809228679588873671485291280066934693921393075773361780745397160\\\n        197353852062299560110020316197672121046476375806263612458389553292990325699484156649480814\\\n        702112970314483773079850054456060480519461068517209850041806713512457189745414358707829050\\\n        483821586986981536931284192012975131175559896602532482132276472186286112573951737230474439\\\n        930147951468064401410700424774636320142061557939223861400077639932631806054359809166992444\\\n        667577998230363804697683640420063620149316658476806211241939152544472833634248868296031887\\\n        597470998528760714560378889421571609461654858434538000764588157337380659568412379856339567\\\n        165777470280635669158802679904159444790181868572779167228430565006929744969419967466340600\\\n        679051089257509139148017822066597933865066875515152419939442936951576019236679970522844466\\\n        396196368470046961894838906761230889325617056988841518997834927092146680126220521789995650\\\n        649329826801327258643153232158280791412901592158758386646626979303033609273420094883868855\\\n        995209811968271712797779213605960448945849219324264793707750441186116998497093011100861445\\\n        705931244705880281006135202810679684246831019590990069769186916067267949801966633267328586\\\n        371073221335029816357045086132035080545220700930116388973297918787392155254336433019873918\\\n        929883087637363670114375424976462334382490508928844967064114234269922551618557110815934901\\\n        876906160861132736228632165899298718943501206629663170780172488017107938313679614820532295\\\n        543618421571768942751293193790122270519731078734363104037404215817775961622071706710667673\\\n        312487272952115228707475202606126327462815938340094035200380231686341882709577674992059940\\\n        963295978770791937575861358368415148598656386349396319056163454569830526866943056584767692\\\n        024089696546418459683159256632009149359569006637264313503591659482676109683427057074033378\\\n        339082283158331809096449318714336075135936011278567801735364603544651105391148146365240841\\\n        166892168731809139164359107296092111059157735755967234067803504909879507376876716761959311\\\n        920378673432732492712381851564805164381901385128789829973052996808092181555959187695554942\\\n        480581033393085142281520685429056854037585607328997151995739558540077871159988050141092953\\\n        662292640953326356202828315356032917096796173892378015328556261153978101876655691406116605\\\n        607587773467578165086912389735561622951996741711620469752510194812505386957063138887410250\\\n        911831161684931666290557233579773605547985901529337897990019003727687474074693471311983001\\\n        681219236339581582808800726913754063113256608526838311595415415428272790510262145128835500\\\n        721062716587787283315458186841929620226676728447273030546434233595229673526489474526360798\\\n        809231033843578563696477622290105965256148180684752877081173347746267062100149720229920410\\\n        951286864777934759580260068914503690632874462399195865371760988338348539350275717698321830\\\n        226334015252372261589653390538291368621365039209648906550792212107804188170470877353908320\\\n        826727167051347846169966090800241979467753010421664680301215533370424078812420523253903811\\\n        916965508052829287836454904824629638900280144756115701568814090402935615816218335109313535\\\n        054079395218292587891318792234048179289576890026947366581405282678238246857135112850682162\\\n        007207280212690865831228591911696948127262323901130553240607783549443166525063027505336421\\\n        815941395295974964549714276306891301117372998094674697520822988024027991119318493542437751\\\n        160014869152621710936890071711047865749377744534573175485343445360680236016465823381186157\\\n        000768318736800786145798282520818277416400032475424781970252970962994972387917054094071947\\\n        402567612404525229186210641205841364083827112977732831807718753061247589528838682496198083\\\n        238848440136670558793578216275256198129812672958311429052666292989729673278796867716243399\\\n        845941795519020818112594336913731337553303030359637239471735809326575575231812155355892068\\\n        887855682292625417924426786565563441342963251955645476861091091364114637297343505014905308\\\n        732295888576826154321355565732780632139739223091886045141266172094375363307556236401922821\\\n        788316556493119072342567173753901091561461002681782638777876523156995253491488915812587157\\\n        053413847047984234119302655191541645917986301116471336698337441758044832293292904063194872\\\n        096628203244669592588780746372110082239212361364686964249197646651020787722073610050318292\\\n        436449297589223841735964766019354736450339933630561673866369168893225327076409742015785361\\\n        989835846057413085797169815535045297680519411762996274784525099417347088711936700043299215\\\n        303504736195427621192037830011279659604234725713970152296543088131832184423372777280240162\\\n        542035431290242166639955298880233811437094710331194447588789598981683506737644434107486744\\\n        765378009728867699120155067109785611988267727714580838412470030292399466901232781109501737\\\n        618935527601441098097898999439331084690118455671595717657323714477150664111947490616548341\\\n        951616621349502071740359291326597989781537008925611500805997619146357502362849363895431041\\\n        461305509483806974207737851856585195331941648483139160707723659618337365227015539093967312\\\n        649674273034727264765393831953456252198097585361558354047266855018313621219908450929094402\\\n        135571542647536382717105046414881623017320702662447209485348295222642067998811512814961169\\\n        506998578558700107504443380795976155077588830420905523971448229773872096834980395228447384\\\n        858631748249122526673235890206591533998094359805185090030780759265217318932092981323835951\\\n        294341530751511696197139000351605111828278132369354724264291343174801798229685931759618872\\\n        360335267349516685058362527963111185480253069737135296282738912900928118252871003004013262\\\n        369314009791134343115426073133052049130322324753875427388903160217520612053028843024733045\\\n        377214607718540527368205955366615710230715435746299825284774313620592377550836594171083852\\\n        905893434064472292929015794485536549063129048185225993554393445829114250051079892901516894\\\n        142896096115936728257547014510780512923855395217408958427868714448949470736574672796415101\\\n        442741062881390978598329314070412406570689416104966923795853134171200147571776292710467928\\\n        945722876366043435203862147172964379968951345208371950392724824258804834050977023615799938\\\n        453018246262796351965924103865230420901275802788561772778702885309354343418248172202958815\\\n        519453966694628537377212196374306111131572924257148355412164443336742782794197513717366786\\\n        586489031430059991101071702011260462882271944420432836430337463827239248075552508263252023\\\n        032440771888512184558140099088140323605887787164301611898086193844257471954353248310939280\\\n        993268415535716779395162394524219959916718572433400183040759819585041256568393381207766219\\\n        355186525735290447321031784275039231200182557348926618638891469682872766425135759671608811\\\n        883495436434976256355202519546638459729792246729353165117725540125485353381226823007945822\\\n        384010562461310992527075617523438086397738738529652112106412608845589726314747589109634123\\\n        228401293432966677777960866147207969640980823894229049404096072682502456664254328972702523\\\n        585947224847853277557699089820614250713798810158234685951417384238945581753773823594691125\\\n        396362263931118087464923282973043111251486433066540087688553095483791563023213414682753536\\\n        014565911504622979412237283327917960397784240012377144282633390281362326984094599209677746\\\n        101648862671997590386892556163588305076053210770585106496922693633814304348443352574307351\\\n        942359812363438307960128285865751019634780185759022075382516571795438888026289970650956794\\\n        627075003799480852546724377963776266559333868307318680485534402319827454269891478720492229\\\n        940214491884136509149148489350103955457465470179476777774755581810409988069294163684261127\\\n        660143938837488346262193833549232895260976473255415318552433884590198284452888441149752461\\\n        585611146394306335531586810602581313853869237232624999097946719244884511981717382862175013\\\n        176055575318282381337315478506391081184454378868823934608879050290152472668009276133761874\\\n        877585443654984763350477109419202259754706764477297687733014520121296151141255625101902034\\\n        578308732282059402510900320935886573649446109308178205270895924268211433160752948813574968\\\n        936687423735638544883994125734075572661763786395102299869448986691705729277503761735976841\\\n        690073763454875017300247680768374394004108758035837634016841692073486920110365350366034001\\\n        472403907739061567360325694407292434502872772581217038366268934185343373394799082493681788\\\n        275373395375355261454212858188990708139827961777120968772668107426406065067761244780693434\\\n        109080524629956151550652242213898698536382650238317656228795588244829859339869997196882098\\\n        236944060811243370417883942680679566106964530934900243507293031998418992536462776106301247\\\n        889380120560596275660853982458756145999295566419709013852928633660462551376611277851470013\\\n        989162783556845656181820041854045855500929180072983052718607150049806134677302042993174025\\\n        067909740223965955181911676915256583610141592097606945684454149633440549998923726287348395\\\n        856974525910228675766129506289982674026777738275529334030156081855371470056506325922975984\\\n        257552957958919024341307029787260500052431878425009597996801825998334161633412643727840063\\\n        188665028448152183325710113986911985927843857915709484773943615922228875738436234102223501\\\n        782548051450945021044864209252227470661510291595452599058578496478848338630395679505115398\\\n        440740946329788440378398326816716722855984697856060668086893782390452278167380882417332155\\\n        797298531127755362219340618982410376725420909614444593559516135151508267672240323580804385\\\n        421203113262088807566286609505459617858017547099710603754451442292456001619365272535604568\\\n        164584133796883000998636450216418412732485360818354675734196530644548806966998871560681833\\\n        320150532393127039962607352649819530846907914688913982802838263496805510942772454510598122\\\n        529608547891352384780218521708212849869618875259315650910193069071991863411679939101438998\\\n        849397127130060152092019600778188567290201801941912544532539748152948963839845861729766603\\\n        385476649070701435438396033835206581032057100875358134355283880234097658544912301781310530\\\n        357466003300573431262009658798976167257600829323582202442210400773133065796249790244520900\\\n        751126503919427709670528700539062321819129699836853233021836731290327655620718617512083266\\\n        252892092442054354031761855401657894782504328994105995077014018461130928191498823963707399\\\n        686585607931551535732021331118880948828638714964141960009930284207807540330910788233575449\\\n        491496306307625186173107532060634416110310400808768324310668271668638317784736603056803144\\\n        475736688791710899799828518993417206586764460996604146389593136065946348552048266955548251\\\n        618635847179904493652887837973165739178811362059715080382587344487913046471911278437475292\\\n        856678513124050441560906268013735755374698458542303503558302884143733782832954930631777008\\\n        910991929074367728568512638820226683808141758513709836240008481979960017479423434148889899\\\n        074974966282943913643575333333714345936723998958701230719172069292499493539532544167796563\\\n        219908085352456616276359304345934893304669364931898098558414330801885490532515424924733657\\\n        778384619951326199925175191948635162707449876335586896087884878339136225743227270197386222\\\n        277240308854127713864439642854231461809686432792104564571249000147916524984597808308308761\\\n        298109831309224308230565030858536165951043440881702160095141255491036492008510494898909100\\\n        228990767467194714930354472116331393095195907053702573694843688039206601614773430708382373\\\n        623476235759315168850441108750647295033041493152438965296495570036593263412543144969817959\\\n        785255921519690540321829273072298383467030956758177310102431983709766552833815604249506792\\\n        376488780818730270186869570649024044118318406327576288480073554058869044116252269218487818\\\n        331419324113219219245831146373092349796942422020016819591053264149724863605727664808618061\\\n        639045265367476288098062311189308273803274923107895709788067293327467698473334971025852460\\\n        528576579965170192097102620095179872573970351692899749219499269022629041847339591019135236\\\n        156636276571639490940096117305752284209047623120663706101614484740141788347154656765225755\\\n        727055166540738603983783303333141874898452815375394752689294060148342645894974770393750677\\\n        735578223476254360332890497273549584457884683608529408450248665822457380121345573543745792\\\n        577418258087962511766821345219899558393877246055221627071667767385037816773555486307800513\\\n        156621477672895759821180209096583882602471042430024916087582703805641739105658266094025001\\\n        246890805248438706168101564013657003693748952227119432885473424404082511865551641342637870\\\n        920397521320130365184093138101503458674128005445386212864338474436055196252355022795267177\\\n        942380641681852601850272529649863151090566759043773266114233300073244788324943393061861915\\\n        002005075680482004362039752579052885993384650137831388058011036110515881509951985449115037\\\n        350346820241301369947845095491936317035869241791855626389302974466195262238166848191091403\\\n        898076513241780110328913789189711419493699996308764805957437434406808346904681835106914050\\\n        954286662232515185724777186582490309523304841477020417561811037429510074777726746462514899\\\n        199223975580364615456525387955982340591298398795520969086188462911181413986965234317630918\\\n        333366144245284198466396927116835321011122268366573830840772810163686574381170988081288505\\\n        545538895174725279494195877267528043358528909258536489339059337965762153973962220852381326\\\n        450549433940129792329310583229433485069668046207845220499168645755264627598439252558413940\\\n        992010792409154480761629197578238653465343631006736050847285344058067350447602100263745799\\\n        761017040817958089100817554958962000073778446149217744665569914704061856518155976016756654\\\n        927355237429480266310570057877370617317876367587874880609913121237801262564979485197907421\\\n        620139687611112248631958504940242051468972506438480853050987877100517474144466525614343117\\\n        164239908137780495181382041192331397349595334090534024909295021958583566709869771330842567\\\n        685183273192761211711881521964700852012923460066654891031138905424613071814807544032419863\\\n        332677468840562060595518661057063060119580701086188456667334773407021783062636292037440783\\\n        079154573981721262364092324874192387804419725627560284043296214582386914264556441244262925\\\n        476342107328819653722741473107629795929708749688607642445345504878661938845500635307478718\\\n        653877981177044776144386859773048577591546384347412413244225926285764033384746058330085691\\\n        960944045324251540037873696671836195329637748786230992871155065538569924367586944300738563\\\n        883628313589652605857937833098997616762063345117431339854900035600129829422517731417649109\\\n        546129918293013553363859487592026406375054384617408580960906400839943965090689396918372033\\\n        883007741906683157523425441724945466747884125990036643416229562193763669052030099125825190\\\n        790662245550188622225900792488630684129371606844880550253434459632453104538448773783147887\\\n        451057523978889647438330045029483010785426728377060809845884620807365166876016287331615871\\\n        990357761317553782255657711301009448672256562630731155332514418666675481598443353739998313\\\n        079698385092515415143139954257321576118102089416300756401761572563744629737897361225817953\\\n        109216111741025040715350253469281295036256389417091930133892910492231370511455876731130591\\\n        539211938474016255006848777099316498087031146567820384472717203430150528196662255817840410\\\n        294634684640015301513980296572661167609135465050621575780614927713787583858222355282982986\\\n        544077784349717719885137589481245570812501964664014435792294930185760446812764295556682432\\\n        887362843738578585264900389620123578861463459038871948005110949830550733231863759682658855\\\n        023551052765742550461419169908664656809865515038563371844377859114553773296800040025825491\\\n        012969567504415651665712650904719381166174909914935897543190272215560591699693215027537745\\\n        388447248264007747233096277342852831961305023600865596520508148388061268903827317213184893\\\n        288839787460374992205234490256272991894149998037585419438904901963357140533837336505283803\\\n        767064708333768804447266011548493851454571488814648140711009959208032142104390379672795630\\\n        130084169444663862300395180799016239377646874384258365390436516626982094268279418265151135\\\n        204398738381652557670247770554754023736080338672291384103458560831428977396368660728092257\\\n        952962971817227608917691712776896570778204196484343263931571322766777508303553377628616966\\\n        410189167117664677350373536161705602419562174387852840788943650168194415938025334810262673\\\n        656500114973525790714649652120681686300418323471097481433566856838475906381114998693628663\\\n        749004424394430887259777935793852422505893818782386589108321894283503814506354853233377456\\\n        146964984665472208014828415738651572763211139758405878392138700482864519924105042107643269\\\n        756419930288377708102786438781254709322563207129781069248481333918367920959781504511174268\\\n        214887802235821129921316227261346313861072771793830693132880828158709849460021196323091647\\\n        224404080259814044474883557558851070864778287835084469433322743190792404414522552784602473\\\n        771930684441690785490750905598853823853633775941645416306710969091756385577843220421847153\\\n        685745567952665490933754011854376609835113165835483697951991986612534148444079561283259519\\\n        754586796904117584435485781936295386781545036840009850956786412760145658448892651142192532\\\n        851068333342086429755548206608804122641092460534952827167749079235194182267373365075016345\\\n        522350768925838045731429620368238597066151555490335483393566273470483714391230964267325733\\\n        711453492126240678026768816840491057555321537598528099407861910266337174883326020249334856\\\n        843674199694930861577032245550524482533322394458279977774097932434422102593464011491788817\\\n        500824877226449746677755667267945204553607957049657105913431831364551149150325072090466045\\\n        366197021223228852043057537215860682718328354759410261964543518075779289024285211581631650\\\n        152202340192306502930590873374061126422723931431889916775530938665277955808860163047301861\\\n        762227059814233452848924362057645944968070642530013935393036688911494965281115344712283814\\\n        605010453169501180163593142607051236840496210794617210932970057625058828504507928855649291\\\n        681789829218739171736207809423449769329446373523759863325546866027408680743220864169469441\\\n        682899183327881730002724013274231863077642074399342203975489213052992464500009492908109391\\\n        334736954204848196251327763224697388135263444973793434066821630030046945532009787723938952\\\n        096419670382423868336484149940952981181841442094939522944142495449952861472590649402916323\\\n        983669029973414902152457112832765812912065056029666377231421043912906176957489330880601607\\\n        352010538555558159766079975439212307700528418217204451847744761309768020756172764756165586\\\n        793757946857382178496070375425797408034544070355404784664584071940890635269486021586203414\\\n        958893534488821912515451310351654530570205262810335348784725465814748043272186060088013178\\\n        453851261350627267286159535698786473942335161114079004431756842517404633611388827805423216\\\n        997488244155134861490990595821404381838285034574621495816396321840675740316169216220821035\\\n        346133488721733147387779559042978178595741375888645767879423648458788328648864425178709825\\\n        811602665327542022802769106347341515804177345536587397386367574224380623296379762697531058\\\n        630552966437749986249410352345789268367280100879220135957109939603734725426704307093398470\\\n        668369028726197038412647615521455820205742376740755841803790555871015831232943982950601670\\\n        082870542368923350378063876438341617693526476213105556127905332445058513281036328950074039\\\n        466834993939759597504394711330891065072116222931397715610499367411879360626984034233637774\\\n        506814802590154821639707234731090414290171194190338296950716260854936328222130101944269176\\\n        195214534749884417460389855104718453694955288761628236660489958281235693703646401752119548\\\n        154779051027199211172624216723132477664152271553724059804470020163193955475299467133601044\\\n        895754749158271113940527759431889429079871001264355516389191664256785648420644201184104259\\\n        466383530848627157456680862307688008438343003119439602815586878147316063251737927164720295\\\n        414356017262087663087871081224621170283450550710130211042218518240645751090984217341556805\\\n        085907681608118146390608644278871449317437034687802408732420581021056634639748630417215150\\\n        414477539914083170317951840140846031888642534831374111233584554433632366611643778071521108\\\n        243908076637672308075941027910383319373995182960914409222574791797008698501241361898547370\\\n        828304213095161588899163891406997446235417856989317046402791396650195215432788949964879011\\\n        915812044961812881570193374014206317809356460600838614572588080483156171112490432795731201\\\n        166113616834621403433464391253254770278867577271922368981105100430293940374565816566975970\\\n        398399276617598987435547938265417157364138335901638369338099485892561305334799974333499285\\\n        800300820252675529817802846880383396028784240673867908957391631912318829785135502467483121\\\n        617713983983342932630608092352563957004577635893205027761894256625532660153061373592537763\\\n        219717341168822357664385549557038660078916828052182702394006739879529220228298085186609846\\\n        128565336991224684887315981161696106185204899136793158020212929950937274796788005070293655\\\n        137586831921667778015597890951159712109000472086833698017687824900754634136327382254538956\\\n        339512641199026303842984966836521329887957607172655596837823959056370209692964267387430384\\\n        163058635255164178917122359772870224465039879988359976836282524435522693660261104563326486\\\n        516791535221139246043616911384753242547068693919364064148585519774918055294225490507640513\\\n        732919734508773953481803843969697441915490062144585613235505551075155310977927698602637731\\\n        166751912313217382456810542784799034647931769831929898742198103174616451067843188917652536\\\n        920462245429098992999130547362630275465414552443942034436517798660834606640822895992705463\\\n        580381971382219614070016570981777809300624561212771321786379572484580786396315544966036612\\\n        289394677063408499127314005565241330513817257075472694337094012635750737305770648765576210\\\n        221563789991589456199285558808718898183020122875142728870318587680509166653874087359963348\\\n        689292997116108946565728551705912280318963330163724021277225446153289465154916698680193597\\\n        342960799506356659552747181798804891461572534891820621532046924555860504572758532661395688\\\n        428695508489921064277332655062138235872002740335804831222092565153859377902178148421324873\\\n        414885683121326213560940310400536414009745546157635018009739775819372532951453735089286697\\\n        574905203475102756921630537823646298211015952830951132132712767752162686313352627057380151\\\n        088182720929652101048911675162140531034805987063449076235991767071423819652074026199326264\\\n        521326871548065012835515814267943795023244402889732170177486869602956459462243622056265202\\\n        101739491410835119165237952656917307377245179703667483580676425433546252698342113145961295\\\n        783227487207005956745579137736713075545680714089912218622592885013397649280690329739398529\\\n        260539438974000329433396253388893849015175985053210501285074446754037522817151258298550832\\\n        851605398774310315946557183872567846496481140550450355903803675715114742273671494698177092\\\n        898641684830735299457782138325738915785789357094376670418877115594414775215765133157084683\\\n        207656122971266886229146230601081277467178107986624288792162110311688124067403931642270856\\\n        970438506192833149129312566922775060680066863085277673886252899358580470754002281893370162\\\n        238175028917644516469418409413969809174458990978372501418186055487813758365137363943855718\\\n        675572928099093837524346719904881331450151812203518796775437891709875497338423708778893222\\\n        414522826803514877090291354545796648229797129867947962881358462491174010958653714398339360\\\n        591891786253474719073342317338616986610674001174274871422177084007473536769322497239765840\\\n        134537643472620563429421876844545350633734874566492830693128697490816584586881495447766462\\\n        586176305507814462274109350195792994910539241541515555891068983041235991852692991248062603\\\n        162271059360182672408129468634341704348007538374607408180246579119923001683643027948379754\\\n        712459187716066311795548327576295631602387902462727998300432501222473832281604996104265790\\\n        854920458766436613394670710194808751242716945747883907608057267065698781668926269291132705\\\n        671357926608540959747199566891842576348306804287556164447921913182721923242234061019871441\\\n        347548914673017532460799668596615253705072903208358621483917295591606100561811961514923527\\\n        111508512272905001212357490174968971689738495192641591465321405821273372269490988366567287\\\n        659607552329564545145233612686948796733219741061969557271675770282198909205449957312843185\\\n        594553361219870561213646595268401868635332174660208127252513409212630584660335254641369458\\\n        493558905564604970628138182871125896957475953842624470020143786043450555836149824798150142\\\n        602395472537270888219203772603069771840377161313749231072621142055030236689096203280543229\\\n        710722600768302775193957195814224825288352578523106108560010120400429609168368887679286840\\\n        471664777771294104221818735948867109060955795636187064921602821982610731874054604159024791\\\n        051509449128935285426246763678491690144063419819977292902351809643098284746266538261602516\\\n        173241103603747602954100404677356972268503491470258858799058441854645466578438131158140973\\\n        519735795490723926710511985936448882450849506058077372417120347863841670642841631540327007\\\n        326847968121318296435617227366587572477645167760349548498997237290804938601124613552123699\\\n        144227927398955766295596097647033152038992976230969500751880188757760368956922343193979603\\\n        793906704423250592425099433954672994389206043576409095758296545681727058238002318174972189\\\n        858226559924299010282302380271815914584287455300300721806809751449891030234046741951816408\\\n        313937214879054829214901461893331874540336643066752987662636677891779551241012296758612416\\\n        560539115903675102427788474800658798952265883576419577730242257469877768258661441169549487\\\n        252545803795868735885134695624411241135990115763391641009535914923110114412234543423019090\\\n        060803199986261092718797734378927625176687018741575442736590555315643074310893569766927985\\\n        149767187002606494850067139287908334049986381189115338834408440394464822236154222584924268\\\n        427383934937567481013619571704640982679668842586571743112158562229539081446151646980811446\\\n        212261738418041259507392698388405177254120992830502678488338134766601739490109333620545279\\\n        825382079526407211744802677559122529352610812273162788344709527772060372270021050449982608\\\n        138627578379786299084040258054367213064806266903683735801140996382032589985013841631634429\\\n        304684843805565526912699625685513321455766332919110196334798892528590138826858142390733719\\\n        855462464430245963171598648257299533349299956150330529096193192777011123580618617271477134\\\n        527367553133380862654764346945649775009488297101497061194783024606566162686994402467378238\\\n        650108259367950580810361661348229071042016911681201152392425554197195373126936923288396502\\\n        803662548203922911854164057179485094614214958643847518765298613553345697974345120011215960\\\n        529749410647461068960587773966506815042084819409528159314242183174983586836490606808465523\\\n        590142104451937143013653859426064652037692521095904814838027761242779447251400889213356953\\\n        254615929555507297749543778692148287317103557999805434227694798162004262646358955388218283\\\n        087591835013617618744412372927103116549992597051994154933672283525524434038752309345672005\\\n        107825942658859117654180680250192875505694496069229602916959875445943698470687498805644769\\\n        975733784938324307213795163086316967380874754907633336448130154390419135152330031326281572\\\n        413543432522527060369687063195174545862679995044031683729573392859264345823001991500619862\\\n        121269414977703130950918654295790969169660157860478935755963122529682088521163846995931393\\\n        350646598266684396825264099736522806964728838978442285854238898885973848044270328928751226\\\n        434202880964650408182990139270463724778278929486234773453029114451189784003117149621825704\\\n        286047991379132707746827015900614761850640693869505306651842775381308390535778874468333419\\\n        546163797990486224134869743449292650546257922289660931567932625109070343334449547539515212\\\n        327910424910681627558747375059351143289845288236007332732779192519573796942916893505554234\\\n        717482235049975786747874427067590616730352580255329051062433319866837295374849251036939275\\\n        399374569454808740447969046122368728880011344510141179635254027726546033010799669235098409\\\n        733948262525339545952324575543725173168268637861138335530788450458141861041839640866229375\\\n        250654864888323536066490811987799315495693582777198735528275415655069922485298076191586597\\\n        459561372907344682056645207833005563884832805028871914402269192672026386249300881032526024\\\n        997043798789791069137777320473382653917506178340456144532352684312891416122559048863637745\\\n        347623089226255091310846867841920943504308382794464827451209056003341942207650668432030459\\\n        068101877872478967943550640614005049457116969689604727832589061961627824599198686176615521\\\n        185575644504553126428573968191883440745578756857060477942335975880767991864513607976077276\\\n        309033266042395408507019610689899087925307031679501853635845498151084986876730324442048372\\\n        435298405916907723789817530588494725367998276745055905588276101510825901479569784122252823\\\n        007943690662289804335293130645534048139987200140161702460183073471550288248425280424130903\\\n        505109157346656972066437647817782138809847067954097500426729434142902281400385117755460909\\\n        291116779978205482558293454127004890598508908478557528673358330354125670625507146059241898\\\n        269005586039007973917449728122569377330802713322989439330831674153499099478575219816820157\\\n        515119392571722666516280092076150157117076245459783625997108146677980727750792040800730819\\\n        053170611630507433191548477799860474014295840558143304597609501532439950579792834197368238\\\n        120444565984215825657702762871436227204972534030175534358352558744882654913092559548293896\\\n        158056190030887351529099842048601981249861238131338424899866011571863488882739934279854400\\\n        819378650633175159246275264882493554597430598773647099479980586167446399466003000318779334\\\n        825539284076812949621321433489027913593225295882832802516776661470506102510597167048768492\\\n        683001688400881207407554788443934664774790556530693123053495213402962244042396433861093720\\\n        040542584423764230436584375605867723940997207547047373114481808794614015547537379475856247\\\n        127774232267699468810448903857273269523292192055165253333194338141245260304996833225480991\\\n        520932356432727479639457246002479012156232183277197074903550960430125002341290947060444644\\\n        337694383953766090051195210958147743155375260500243664001882141899018881730726421062482287\\\n        898842553541455666858076607618032512967352771451352407378411578502063516789317716848302348\\\n        600780801114233264438828512202518424639376035243145784592976369210832738256454390616499081\\\n        112332205512512074604051998338965795233584612360598059927460946335887860395696195804639814\\\n        704591577452171246524772256664322364425926626811932299860110624869149321299162333534166017\\\n        593632197325597763767790965960213734248599649261493125585852195200256442303258069166992552\\\n        855968874316254131399436661896811757500980068462889133136958357216514128593850190051249336\\\n        761350424777549563452268233439911984180123737686884066377175370133541636811901150835019759\\\n        917881916923224667341780071471108049176681912060198913988051351018155010924470046382412189\\\n        844592791577010983618734733647064486534180092617568179814489570201469454500853239064923235\\\n        936550849457135989434764356858178300969583269581731813006272744042732471797669417777220029\\\n        852176891812526476035564315794867443293158123726730318050345505667133249526552680632343337\\\n        309568992834879374205529545859701753915362653366179481967781313712818871986250556401897705\\\n        555360719447175696180811876037974945423742039988227314081896380909456279715112567080690769\\\n        411701719411276260703432791672439287510583833936395744496909869399567913441339196008050959\\\n        549736681168258561114238656393887209169002762522237880268572529047990022857482832432296504\\\n        579664615537285045470233451880731888808168358257299225264545432360379381548885583601934156\\\n        238195347436076496681726085333107048177092568269294635642038836012091846369726856752639821\\\n        144451275618945545591539910479307606457358999757875761517595910173553546491846202280019550\\\n        922209099914649133467080204269779484982985922655692782541953328299352957333771544590332333\\\n        657994240038396516540102919508082081143412961457433601285957806641379193179063120320384672\\\n        928060117956135013047993425224297885198565101032703926012316280917045075420629613263358381\\\n        867645310455598075319710950592013534166829751234218035611433754694848812767331665924493733\\\n        669391158696989421101099506230281982696580765268150201480400983830019582253245969124379055\\\n        769715619494879743030132520406473211088085543674116077980479120698169050765727432912964775\\\n        298841698108832109881727933254149982061386261420219861463075566910116372741604242588314550\\\n        511737073148963996242092698483504911821164948909251942628290326964630806392570480045964295\\\n        179263350420790112243024800749968377399739750214203714109192637842038428646842191337537194\\\n        220887272158598808359591373873235908352912687731496369047614356829722103484420202419285003\\\n        187080056982329219956901133561861467613202290507434125669111571003666186278179331940841692\\\n        624604751628169102614418760795022736186638846918036861603632009221814737235140769304422374\\\n        909327078926975272426329076018492574273722865747138655015588207571803594952886006733600024\\\n        355886517068384317441929224949177431550920187933207763977715673461403800432841144796850607\\\n        677904512928654350522409197023598646066016719206058597901840010047651387978894431878077653\\\n        981646977152340008952466204872280463500243924361567309615299225196061278917223239103729138\\\n        386035332568305624300671786944418385327911828592276638710998473393795856024941185203199397\\\n        180633647224474195665751431687104114915294139507158737238090751409097108312163220086456889\\\n        079679458319586351815916642784791406272754797490224849045827138287614630011029061842274674\\\n        533248327956979074381129020365121496529811253237488026868990123115237491781007048945264425\\\n        454531638112434837512171468999276507835157318949270869505095646363514140580081778271375388\\\n        895818019736330852103809987834849257755301249376744217950861305540157291605166048420089011\\\n        590961858286753021089963272806070161240163157613042721852961652677660434142326571296234919\\\n        708315211480834867114987310428184598167631017044139858074041015458685846940702349327108431\\\n        362584940009911533919324764686012523604047593159684685202020288711346658913681881524379239\\\n        898346328698558732057582972969130068084311955005459656931079106753806415107301847800649095\\\n        209312720359464510283837747293913390619932941311690268563233840953709039082894016315647472\\\n        946799798522296371384572894989370422697437663626988728079767182123060053910001373404335933\\\n        891521097733442840084613936926999214408830981309150808152370273329376266625177394608275657\\\n        144847111364896507518608708502276023315960883998383579752516418440458547693280948047099966\\\n        176448023671619319312823346701699295137911653781823152589209697330493924805995876713118555\\\n        779219899850666292950749271341064542684351500784875289826136576306248571603526931613356064\\\n        287716558645144513052759679346591644812021539953139223208564611966894127887919802483211507\\\n        407777023762447045212954944417913537153289794032363699887526202181835399462234982111874417\\\n        848143418747359333851922527427095615836631742689806825047107179846280565355797917152255462\\\n        321517414315660489220114533666308044372505635750732997849675675128987320108886021144279928\\\n        552189685551227575659263904274264339180308522002976571598530483084809316342548218763731956\\\n        514009543196135633510418199234070809479133023568202199001544455507241489918317865494805174\\\n        002462970866297343934476614843787476443501702142969603482715020269370298500814447097345924\\\n        130707436662802322178621471607091854995915395960525093793110871366861013489358630794043267\\\n        242385930828636732461870959221497123060245357201741681245192488462221414158411511100592911\\\n        770863846920175440232015547288645174766050428945222517961291262132238351986938913017047531\\\n        153098603909207513776782285339004796401323153135389685023003768594295981036844920203233871\\\n        204358912622874045281514335876691594619554463355143240222845430581297296158863094519879070\\\n        988338364439766503775165634696876786111368324701212740461014642034425162390780688322422099\\\n        729680249215712339196015756557663061098448699312584725168211078656136475369030576257153373\\\n        154445882689232114342379064055835393389480362988888682303495152582702361925285538031202350\\\n        587381821002142759764612304833565175578072704245412621116056795603069610420686278819743062\\\n        382663268284154004581126656414090645461211963254286612314001262801187851455867325401681508\\\n        250929564895557219972100221265402620856805680229626295056450203146235920988896838929844873\\\n        190145374167882543180766196024770856873329384958621838504846483943125131526002887363742357\\\n        124977550489432385007120040338831234679114100851892450839073130496737838222111348475819501\\\n        851161818725742594479638652629041908636364161285196428264793835578089962723751293580365268\\\n        502101557045768313343027667114123433085490060252880604175480420145360649656044907509275007\\\n        535331589932837687929944013994907909760192057250488213684261022091995374377690784961646564\\\n        784611109957230609859790690484338526832657753049860919203168714812513166155473799550335732\\\n        542106196285919396830231237407262321350767476716331859420097853036973024030520928736099335\\\n        970695047373588792176175124367963990006354511793914613466917673209310748084428429005722968\\\n        793017192141795380409955666799991699289959148022175214704568592130464540312607388364493253\\\n        723917412052385978212371970837655760296862703980048192180951268784778724273895805113337007\\\n        969180948651663748784075156306849555000556482325244412198937005251522569854911156176979547\\\n        597936262979778128608632565807869600256427122883512716211355667511811366398286097102062661\\\n        987004085933620780735145290175783229207530294604040163689018212502889482841552716902994464\\\n        622701589772761508848592616221815378178825621168809075354342171331171729967694876162845855\\\n        165633660302612338378051488902189820386557708005265885759758832180632611242949859129354423\\\n        479165155152006787656064241026809518185645743735951468864590604649335187265961850303503903\\\n        217864190730793205975529343158319669049783334400150537047894425583892866653059914610501528\\\n        353604486097131693847797125433066949274741372973683576564055129474526387329759354751222749\\\n        062139112678638096194101443421338488080205374191518520409455135196867890282665321603737425\\\n        975863807099083432499671762474153503455564187215355621912257036111272444801947476819472812\\\n        861356062375607452236056901298735666909567105156768185855958394538367216083603459939861271\\\n        281120940764938203209428805433376695824380909560397119128358399700967926397151027381553218\\\n        683982946890077563774159140049542742451639172119579867795205522759443238529204483881452676\\\n        487141975021658035152845087352389925078735487370147898757807501118797098806440299653359107\\\n        147373390458471313307616745111713031159480304448737539691451299203431653102318363167973130\\\n        369611681780804193970833779031885450696039634988773027318685547489089619305655537873826551\\\n        039154220757166771910217441558883417170158734656963166862673667470926047231321921566500841\\\n        977486494367235726219989201140598918962052820377656741027223315631771139839020676332224513\\\n        941087026208626985612312668805643677851904493314425128888246604579284732115124905747472532\\\n        316308536814020571293273082879614499786597788064352255016642661955183283633661811682515129\\\n        319529031386781664846217080551470900409559147484574749366171506618580821868923802695004854\\\n        170880152068572495183414822739669537528410509231702482821591749801262754430555279343938238\\\n        356973520813312169665948930612062875057362404491732226222390276323955034695252656359461378\\\n        758162612951152089816905051362858887597531676387998308689660729243649861202990400713835373\\\n        400302500722871897137920206419601314476665175303923158863448004817093249728607156416264110\\\n        275467295416764084994019820418321475720679478742500202595534710978840777729657294361452213\\\n        494956441953304366330215121893595344813232801390916332455066940505093527500209958486324108\\\n        002073971688541608812316242396072677505902884703272662401533272003315169322445569857212373\\\n        374467379823393121478174269347143537349548498010620157824698575689098380753395591484195077\\\n        475489978007233530536604786766240377049566768726855879134252994132238062618439945349312307\\\n        701609660506820682284737955776609929552538763741062003014720180521472516194778874754998519\\\n        704003884181032207124852935515825766353917682562044492309902999110747716891975992427696205\\\n        369718786742575850157500682768944419356022056694480314832497738932426261830846603895279609\\\n        256274559964823583447289748922290564974161880553066761228411244522392225190670831690808516\\\n        064561283706843751322472988598078046110969565593556789655948457879135083240713170826709463\\\n        365624254826008107552786253818587503492502691029226479557516414348861316898230749218054769\\\n        982226364426925127199374678115656853504231055451296552442268829474031826735324589945632056\\\n        815011836446966014253675476864912881543417643443847293769078206252111088743461819911324631\\\n        563721271676451618982100544199956275185088820013227746874318974779043446951533313697375707\\\n        698011321406745068890431904440677694031492107571412769972869554641822661044199036353078429\\\n        886050024568603891167929735773773289136989525938472327101696747922582879126217465185456846\\\n        502658130404296932689402148691583741063089900249705997943778299529178190416166830890269227\\\n        477121662140224329742652491157202663913272720240562141468608255788558670337431779374927249\\\n        012772252494867493864519509857853022908724991704914661732105889392648515771676217289780233\\\n        969495198045615378770395485812088942537768306805153995114778908991471306022422255609148780\\\n        204214391698788466793472229641417779130201399820732726138969638983104947178290673125259918\\\n        119590845987621203021509241397152178636459005501413066305020173521199286173356270607549889\\\n        705496279421882363179615193995761559131300666536074626867272906481182026552832627601756846\\\n        207380117528054746232941827564537726285587500736736325035102104044452769147677502236587478\\\n        255861067623884359377720692710658743802389095703651778879946602815597829140655609801477400\\\n        027680797144000228071046199918981268646408039118873375725962115342935705596517283106937699\\\n        693770807676285724535890953944182934665443097418331290959826059121065315961196233801459955\\\n        338756163507201439142731100781703756688955010494672457474877235564423666588708512246450247\\\n        666089134825747969972735770842536880606708915399765692754793658398540277398512682265157614\\\n        991652226304525077609313080688992221835172507061887084798941767251831129248330990753586692\\\n        476663828242171837474513437362373700468467586421474262679041886123391331455487027530572420\\\n        964478547863918541605561218670035374054429905881048172347653337404165845705957716778677070\\\n        195730086517968722192605022411657864523640017069592482920104321761529261082461643870794916\\\n        181579321634690310066998981209022260655183332437463362924410333591401840960157371845325373\\\n        871640951179025371911708524821668422312046573987424764519585929266888619313666793020027379\\\n        456926951910587162255081457059346733913823448094911935428695735737346124742156935860382238\\\n        560180621562104107108082793584306088037488113652546188265654807242302358755084646267341314\\\n        816587853518725981318317513571175890382340222131555111568513917404414725830002182329634505\\\n        142615935046131012598936406804571404473680635164031944813631065721830444896688379981201208\\\n        687235349526585905940745979496756686123527280643613268729674680557086603065981224628589253\\\n        957565014452105026762990604647908700085642806953306286980397705388110722187865136327686811\\\n        078323843785141977068919662805265964384167495156540744368388162787861089064622852806923764\\\n        563233521960331704032772764912103182059951223847662202978106442579148281025926556333638288\\\n        079392898093697936738948533100157987337130391099147094010219772240502178806871520072899797\\\n        898287645142446692170572594848961992429090705904332768903036131583910939899325992646574702\\\n        121471753716388603027948607438630299896355472607354585896347537406971689928876507023430969\\\n        198842199469841435837478723687522148943378069592681128564665053656903205319087957774014470\\\n        513920335952256896514096706016537035444292435419500034889700201718140178507163573544943172\\\n        952543430753456205842325004276216972743254635195187449255382331424875545734693091902216008\\\n        722308737658829393223235959589674505673370761698869288354195027092796310291430680817406289\\\n        537265347600644263490737669203092644152017217953905977206322678925903673995669798035354590\\\n        148952542440776761037523862865116756248444212585428631084390595974540577625693870954083109\\\n        679501325406032837995084426416633608706641321032612525479336168388532538648032443138221928\\\n        593694955836775911733335626635090740699091508595102940612718995328231549147231205195467195\\\n        909328185775357693972190627429878042709099608127230568370667098852203367650680747541649724\\\n        203869602949903153314616136235673021996710459274682664112341105202181548794467607070159409\\\n        615903241162469087223068416370606111532610294209541639017426110104133643547363044959648227\\\n        252354540768634309895283792697176682316318989796872735985334489138155825862041445180872974\\\n        630992905964145854038215649360429668289529261446690580219215748894041889941284522759607321\\\n        597998375333546461876665680573584251746150396226633683569404751044828910438490635068273506\\\n        085716242207066991279813021322029706510479653639907744651248155151839769329443180398302750\\\n        747653201227903971703692191368304506281317161377040595303191032516514973766705694368960256\\\n        364354333370516522315761007877523435248967872371292908481332297043800184415293583334716799\\\n        096429745391867455289054558720153753750151428463517087985224844856679218807611823260899065\\\n        283985760619505163318604841197413783925013796592155537930436548162157339695480875365347893\\\n        578461597206401929516984217305712297772810143325019020731412759288176117654759210126171058\\\n        457437848642912567953108477478412950499758779268542882285028621461041477801853165214104711\\\n        214346204063402809995062394481031700889303597845604538404527074220194671035815069574700140\\\n        487072402319333042304434673616463681627744665935865325760298595727689598934537707559631517\\\n        519363130503844366015851062302186231516154044153737291431654132516608450769028214480687284\\\n        541791900262598257932539921751747700807829417257249689063040060885748198379499976858234674\\\n        353538353481896860361758027391227480040866284388078293376816382346505974265894439463141479\\\n        534461802609836605260892152570827563694486623718511987289485773388743420995400704530252035\\\n        127077016168967457539248994407079387421729875148805686493266144658834277809666048587885478\\\n        634317907393149717961180424292860422125603980302042346479770786894956168689666237099969700\\\n        560324713959827306043203705743705573750524417513562196550350282146213523730112311828166983\\\n        011966262450610455542866770606875639258005490173345193641257547843973408519447861642112191\\\n        065650058501406383808899923793282433726525003672437624330186205638934971838373140882121865\\\n        250320705877985199865194673679659096250940880475319849592845888396565100180893944480399715\\\n        215396185139033968698658380342845421468246418700710557508965111182249536370331910183630071\\\n        031328025982335003247929891006193176535302768712228753694757163162516801661630833413515456\\\n        944381971335393573797036554975122081183092386689651794797242995866860670530553288759763501\\\n        958602310041428220889541328146259792928885889077601183461294718983073341380487244029243679\\\n        692523855580001763911044241002045299523985644932243399689470506064984474426449939291589176\\\n        385437058574261029694673663241118082895833955283533436302563847147472906088791119198626822\\\n        855284279859475737633095611455484256311217085140980169842582386915846068700034771839149082\\\n        902171705826346363947313420445230717786169950305832507802149680402806084659021179026409648\\\n        693902022426368682215518406352633693191349305535821158617367836396793320672098236785690093\\\n        054692232013957551641199899907469094181780425567565250839357865961606056954281338156010492\\\n        358743009424082497691168658059493467385705785934914741452279645268763561196793192904150572\\\n        262084871570447783815599433418036285341131747503835714763370645275606155582950644084954469\\\n        025495632855340301199878904543050021975848634193830712088368536721854741832694959722724273\\\n        938195988977309599356009825481986118033070895482199356029248131570916086473922546756218703\\\n        041117616541081479291518115539835807457901390459227008964699548181782480793316741416810634\\\n        277611978968069644050201420966540906827593766882254926070819668499692142155414648019456250\\\n        187692598591670244524877084009625545873753950136438945975390478006805709951676059949889284\\\n        892408146469681051569135062685697676220721916574757986587019796330686086073529617542276592\\\n        169531416785046711422695086404688829533058223722316781707390427333853776800762790429387199\\\n        693395869946036371448900840362265678294579148397201966859524116432021146989474942327468631\\\n        312003213135090998833710802740428853588330956825793378334874772424072192289956358938522395\\\n        168062547009852936773727775296824118155379804145692510659065706583473529551735865773711697\\\n        115042342986306119088714276410909120754881217515115514725947403366850630526869429030781417\\\n        266086577529627274591084430809916511173535134512005542471548308752637400637199765154597450\\\n        166529973183925522372609136323562851829603683674682776173466840214720182629760405184097230\\\n        545563232373731869677260358540478302566327516930621279328186180069548242203139064557838189\\\n        579275704159812107740577929426427870870878652924536107070329545232062933472813797286831559\\\n        210208007691250786408947872258790222593613575144800851807385669185201428966865138690440510\\\n        668909221099988436352709692255592885950979735165220271388562607799225195370339405823066072\\\n        471698392171042997573850613015170130244815318041160382207614114804343886309834540889974372\\\n        887043155576731682206922846267024927794930243272347039668947944045064708696707715059869305\\\n        668921300919062621083355049278970597306211065976597802629396585939100646571840273074748194\\\n        084135539007354205496566793965177032643699010396122926298164049097422958573827432185649765\\\n        572065900293016731587696638552303360917074219228071163550305002472577098450677987685429078\\\n        807237143970928705189054625113278598713780154255030850594953536902527172371913405461584980\\\n        400244738901658192414247177556756152077672886686886823153540437031741398535773222983307582\\\n        173125126988962421461335034659905830441682803152935305966994330377543275613950566279580549\\\n        686433814539917396269386455313340144582351479993309702134977628771920244293386853782828308\\\n        887814251528640360888559456613741759894673162583939594735567058030723261581621531457623710\\\n        876053594491405323087170271017381148571250060027270601612721792084692270052117152323507509\\\n        371464239494908756095653696528639244598734176196265774309458276894360426714015699227067561\\\n        973739840749811988379948507063677739217564944803859482388852051260847901492513418555828068\\\n        007874949927539681527555516441847739829078018920620608023712499937862722272831888881605920\\\n        421345018432745120006572977264197148931164538584497646364392254581539037244491376647308356\\\n        103202798858697528604551986398612679233305209887940379207569502958682261055576323609421506\\\n        645434692575628187095526775449333260494923116369816788874985450007247186095628204836915358\\\n        934045470504026766855618652539754294033867615047368863133149957956533819405986288147551929\\\n        379534644424758490910061568981009984220817500334938574812450923390054262770402354074563655\\\n        126067031716557602022496122462294668517919156179616891220137444867020900113926218813724089\\\n        387210569281357562003313834653064114571619258565952755294917126940128864599531771577134688\\\n        595566788926634262452028113716155474974299751334856010111454894101999022277784711759044985\\\n        400711354055887491817298448108350917394851252247262446860243702297924426979772137354422254\\\n        363222202042071276276031003705049449738176752204013960419379369656012408377699795288725589\\\n        500805214413640708113675788699851200422458198820388604825530034384181965371711649830615956\\\n        754954644941767783405416985897230440428099563768119370780317690749776441337908760907492335\\\n        840636839489340821237016668543264474837120069850731907325966853713139177796077857250594014\\\n        327528460141812193851891821934456089369511410462133508440268670747929659508133896348747893\\\n        851698142400549803973534918260779294993402496425997086284694770946049564464944296155688889\\\n        752892026635843608239183636405759453307496882515264607070893423922855204198392639738090332\\\n        530415069627567358947306489365749211751091580951516719532820757792205204994955092422529221\\\n        034829261347665833333158627861086218071699756788188113193048191811328627916556063285398917\\\n        989754261482485655938537036727150683856208798848384388384642275282265781921342361794815681\\\n        595246679592156744809479353865295125156153517907505488688130078728402703079930136634493716\\\n        142756887724066819833911533096995082322028347413696442738924479464654280916018027290300018\\\n        701199797870135074380004008013162433371409292066597033094384163485009352080204977243955664\\\n        205886104057719569400451435672031034521210508787503010360919610097783384921502312958862566\\\n        849585156346158848740291670633514215536145427855513267847691073578591699557851170206342882\\\n        282179343365105945825384765136391146054430147986109086819991317985789897161898928229916391\\\n        604018571519073873521334783857079303950565906891797501264734103403030129111071578434913118\\\n        929622666196567053095767199375701003923003694766217357101240690322685005443218585808036034\\\n        319036984684091031784191793228579877128882439626754323458202402094770422586270036423879067\\\n        905222336164705123461832192408565201950170736360372941218179226733596629315787119101774489\\\n        321133278438241005638119757385281524849760855899853914162010210217569042979407584456200449\\\n        156335387684388469328802085185048100123592504089054560530624011712231811133822050579859290\\\n        823198055961807375056589772753780373773071953789591215326190609148153822360383544476248208\\\n        064265291188493383841651874898513917073184001450433795710971487089036374688103545037807281\\\n        606841755239881786276884860778646581157127614820932492451894419352365760751384330628900344\\\n        207784111450328847737090808070293695002240833455651027949395267542790268991231235111522067\\\n        313544237321627018957504424794556748692019311121613677793449543737622127802496409770935223\\\n        740223425896124749443488706756863250807961675912781989548874828708828088434821337272243442\\\n        554829083475688955656248109958091907037238720502050524062692729686300558314154496822659840\\\n        683663205436763923232008294920498509005669342804880315323948034130659976365212417124260136\\\n        459730783700606317913838709066688097722075732237757692280141363522059513935131762390019015\\\n        695719324134744646046254279109588797935916551105207665541216995764225160274533678673348963\\\n        584833904647131514445928294597620687791718712243156249974250713662270389809099936611834001\\\n        469217183896151038319665920541488836543537623316253140332133919700993535551672714914635313\\\n        238186534449024226321680973109508802472503238196050278858399294011370974725217923169670586\\\n        257767905947957288899404878251418639804106362729983237268031612530456404946236494106847173\\\n        087730172345446064189169517832366059291248910609852100671418023199067573017652069995206722\\\n        578810696339806791064173309454379876343454654550409102305247060554321706799511096056436857\\\n        460040331816807569327371888909429618758136136832987933763020860130877376037814366103561437\\\n        423011862003626698550446657507606547172356959454449667474315072254694613076262908295956001\\\n        636804443765533546707881419688306657053973733181613346856783787593857068713279389419621099\\\n        447543749527275250247535911714002471699440201826678613838654251229186243819963054804112738\\\n        134287992197624931723264896754773051345946852765209288534893228674215470068343444764439017\\\n        514983336270564959443183472012314822116482531077126738306983076006565412185517451537451055\\\n        029968580910826504239969088344546545348742085614171078660395747742482036290953468766135660\\\n        228069541233792138430510115415193958348255188417694938321746144141413317362275025042998894\\\n        830553341035117508972117820884194216771184346850557904556354195450684384703067584507778912\\\n        844656284110105130765430120955623825649914359051828906157534855494404652035882986581945569\\\n        502174125217817419998242449069266322072475680742126637525823194766533962798812130212508506\\\n        133698318489941718509432441281068725349513050723774655721448758851252734760208479023600947\\\n        943717252915751039469085774804722227090106449962217755126407656250433455814425704012041736\\\n        161993348610148899160822043609257421293997535241280382650693597953270645332514340259737903\\\n        890946665504088816937165141066376693447218246821885579586490073155492497560445001727762629\\\n        253311796330405181537777740291250442189523046363300769065725359381792643453609578257090800\\\n        425845328074104234048801553572931453316792294536029062971635582476925161961923285351327104\\\n        089776183243705031827105458445548330791384865744344083127870546885830643167105924981887314\\\n        827663632359403925078507315187619804580812287088087761442177872379864537624831167507756813\\\n        208357035928844447158457203795378746223581361165471181383100957403556916022537664448364925\\\n        386421143775184601313980219909639751577456422589857003108135815097268123078817023433214904\\\n        271634624622385201515875107914915315233324136492216333366794011213403598680624348772520658\\\n        477382541719740551087897721867747026104173622424085967505613172043620850088370360256495476\\\n        803329749307006161402424900001137969760500281322844833474335636904601480975163438599079043\\\n        466558908056223649357721507718115591829661754270273451140021816057524948693790092289847478\\\n        120567086655430146756600624621582598801874487363104892891161423430384038593626459304340522\\\n        087859495718428844414057919436796408413326668836493982459835778952526782546262707126632834\\\n        848810348815324547038569547281352241304932171207733397263083998408033258353386343114181558\\\n        100676986777197680115158470516519830292043995478957829937459291883714453487900198533834410\\\n        865241769185210675023105906535233625646549790654379663934532860753564116956611432545916540\\\n        573189629406308115305914643367857729471500312174823280943260854007511069379964751472593269\\\n        444745240808813685519340618996803149812907806503529691103361538174748374587354932599488739\\\n        886580072948859652350580145163812424117618157800740013998929529710394597119149538090499984\\\n        866353807231008738389563996275741173765545093685584884504319405017750009160520271416201631\\\n        879763412633658742378080845634193735616260716966713912007508640217721368339930940697147661\\\n        112357267373380527508723883616360302823604360554764131162274525323030333578450238209296598\\\n        673583195158534274422370165453624362415161934862778930986539990546393031136217352613336581\\\n        463581749547832233197109861510880237168163825451066964188131492530481062136754348998008214\\\n        490232744034759231530835051572739319995526900973191260864512004601915750106275231100859757\\\n        182492442266628827110065270813582084583302494737046203303405161528048579860357245318765374\\\n        516147230879053648791419602410971358308886716725568091976092278464769450509735165334020367\\\n        687618685007996167153921292461287754934997691577562982960402703640312828205836426505353846\\\n        085865677353674923331992063589224118145485042327779324588677239524942979552010787973652512\\\n        188398255069096637678075292970118580911396197071325076380436501100326756243140435391597539\\\n        992561969346574951576228855670756930562087023155894665428889926088581790690761409313339012\\\n        300717852370049696228356911342802343704090221131537099348646571579576663370981850464018210\\\n        090443775597815220078762290115861554218359622704324914461643014198708427022026207940777852\\\n        763031027091096886530444512665045584702154384127416121197993526806813885194979734705853330\\\n        938335636747848631968611804695814934199975132073816305350366831312681165565494431247461106\\\n        818094974682967956704817355016370951760259998876121892098612553307467822051668085561968534\\\n        427424220757143075924192327110290752049343998606151558587869969890633247329720646199870761\\\n        841407081251337543668204599115621564934531717604001450962086707604990298592847724322355235\\\n        349188794488168938511951222836811580195024118431386243172417976722307031283994074291614481\\\n        177867907699047087882357676863695091468174999852053373447272474563487273658013046886690249\\\n        816494865970358357899325282633161179343615810714905229996669465315308944168908053799833310\\\n        184646609457899592992767509216692273828588871874659856480655317523422382657060932853791477\\\n        456566037618374928180786878830941027479452606873613963931570343307074500345305671874555520\\\n        354690007439596474581024949933976919344538008378465243618355844987752190120518965545140587\\\n        466811864340146589931231157010145365785930541360759388429209347146245672232373773840338426\\\n        385655428195639377771889252831576845036624881646338823833126184133853639032970587658525954\\\n        698579312188861798391993249043530440823600064969643291236735980925828471823134853339429885\\\n        685504583974385091078630314651897373840401431206244825131557119357095605476833906257735896\\\n        918941895044153968303816931012886211600864302352796975853964571536249998956662123691523708\\\n        180506097808915335036562082661775314908723278457963846302503733802644667678272388250946502\\\n        097062903649871218940359360163509013107253360919983313242789740791430553259652820653870755\\\n        452465930755232558610993209683507727760385920058279077288892712778753632221066771447100948\\\n        477528550475847971673491698323932718136808210052914883985440512445642745664835212704407080\\\n        014482972823032960416808987980731338487475427931542914006201589268345196734641913711788300\\\n        593157885325871572555363725251985426250820001796427125425906180693049011527934166540340428\\\n        481356926194692009969031597397655853492075593911640244201796524174989899839706882672792778\\\n        717582333852898069003036323865705588441024380834143515499815308041433272643683501106601437\\\n        171098088186425000052159850564101788863312828167071446252254454743850619509921378307649391\\\n        486420035652641445937101633606086557499503638725624498227716068386214351617096387089288586\\\n        748252879329885091407963661410014302331207615827576233404664953440158858675107047036979957\\\n        771537072951121504147000425121389357766306278532097002529464023174485417483624011752820332\\\n        443477626078886732060544211393089161739457064161679798420366192730563933489314852106770107\\\n        472752452995477679095339195597718617586487230077310007109380299232805878593349010078118920\\\n        828645853547862282432731111789425075049189137562381629510572793687658806739971634254422466\\\n        884848051457667716865658011312203828919326524267651741102944546907529946968788894700654929\\\n        681052744513217990465943115754127798474142755951665448710089429143351724186643331008627168\\\n        723218170648015656195932493752364763456229931136844784637663182207758392843219052260999152\\\n        321787606308165205695384062005111475662880739102945783807771076632369404793894804355994431\\\n        313675736937106023148527050501994429409567005265472853073542578655756867624488613669063416\\\n        531987061483145522442878471636689061245037888430686739055204132682303475123706916060623626\\\n        845928762205509725311559290245833305887751620902284909894530532662785102299516665481940754\\\n        151702565727036558439372113625292015004454847003910441766234876436417079929781642822039111\\\n        278696616038636158040546633001607842368555434467574043092128251522373093796488054553420960\\\n        313863628858678996201649626736472951821874370776699419263570254362835033948401357356529736\\\n        937665049681177924464596458273553573443791474483485289880059975365198926245426578251874996\\\n        203294099997043534554291868956765093664238891676657901356446517100688034923520295629120233\\\n        357379327126434644537161830336868314857374933643032794250305825166616260216696441559126673\\\n        854033619271048007467832092841322738519878654430324926934273523255479072308098201345708656\\\n        772043330940710776661733581739087851242280834304715304858057603057881417473693755673570956\\\n        212569958432699539640930209332519995861142467819721672047362179366768874238443699374068787\\\n        760867634346473566787721506782152310804251890299685702367336529971810866266359743670516975\\\n        424458093982085037795325221834379501463237222263718763377079821072264069520464994327761323\\\n        647789314028388585822318480015850027327972956540207143610807838165483790191120833942993711\\\n        160917288550635579927722688684617651523845730040408082407132742183729071412073048653420825\\\n        114425147321611521530524377200364335976587871626095637451871359386790310861142035742131887\\\n        909101066426507816241030784669638325419054976235788468239446369858013066875713347011311879\\\n        127511280510628983837116392422995288775852205888397105143478604985521382285348596997473791\\\n        133388763334956661018466261692073757562234304285251952079777453071893050340200274483000719\\\n        608505352256399699472135664652523476707223454824337360390225467069818762414791378206640723\\\n        899057423056722684638431698542583443340468641287395881924710969238159319658327466855775155\\\n        489103411106685719787975201355074282264236813004483152807740957459220860463890793151995610\\\n        025138972384090709393573073011670151973070615403643564092096479646335651343071174788943312\\\n        736582432424364063212823678728697314430641761665322362883228797127564946138988275455008610\\\n        957441484939012170423200598550334425427576211596454042674386067914173691322424386782411014\\\n        247611397059495985386498554714086588234316663015171599488314799919756117319471361163673755\\\n        723491238896189879764699740769315807097785482494873503240816319774925872907008356405081536\\\n        449042455355419594147042532475483765634364040502735508015480499991562499458493011215044824\\\n        734388174723360114527691272980468895258214575829764817243404642662226620109357960028819524\\\n        621753088098324070915869418288438545374202982965435483421048388737926558835785799153996111\\\n        161420527378369611315446481280803927997260996892618838549072452142357479100553185551070488\\\n        029324078219239548112801299935506284971387539735012521926994360023636460683229566606294924\\\n        746547486210797853973318665488467481382614201467010953000757330056864377089502068025954541\\\n        909870184797294940171824206605143132784609198190209611134125378473721519692917202462687128\\\n        164304409095141893550107417395238112213331960393887026940626283175812744586208665520603444\\\n        760551266586517524664257595730359017331458027653081378300978405861231069228160285513773627\\\n        520330543557432509652971635061419672174375422335606811728741921949433951324082207524061393\\\n        945891241837314085237823278871829541190550683456561356089410664202649499016264416926621721\\\n        780422411478065606470143157542233124896073441181411381631488923319008174230627209602160721\\\n        167623451349485829514282617287429257336180490337542554355394351545878739691801313226053591\\\n        771095569690430448681589272858120260599559262352669021244629822930779808392732989379154289\\\n        108377212463135446672993283918774998859381980078932311576623345183942931335956010148341051\\\n        207972321217438446176842278358344269172706530803910538208776954756922529954965333427129918\\\n        491873092043057047088657029206232343353124401155879915646674575621749361214206991015231133\\\n        805798694011673079843733423771367847863894702609292635909179881859903709943629415958891370\\\n        941105410546628597549110596979799884413616984129012287592938253598817400314878836156839385\\\n        060159292200090128795878065542095467327820997274959913137605116949996579276241158880092165\\\n        957602055219293499432805711942208308287796237347001236397664481496545425126337635517730356\\\n        091711010307378220743141259860388549056899123589131156842925089550105090835721722163659270\\\n        745405507482728049338808823481840293949349902978265272271046743181716967297230232996824296\\\n        375605229070760557567235089177275949374332769217234151562599959370510507630492699652495689\\\n        396724320872607461638960113042054589235826672897761632943451496224710787495107532030786953\\\n        778555518908318108743813973851708286917241034372012390689016769921154218249380541909431612\\\n        559712481131542760758071463919928095825689066932384433221046471917059119813375524014817394\\\n        075103342207612917387922114756499019980712897041136810473913860458058177515486861517228963\\\n        017501012146637843787127533310477710760528818943937272251854673896213507343605582005430307\\\n        866023791346962794834352017712455842440680595849519194515065412436854054348011636717048348\\\n        825409919498329469062242822806766190530161769395404365827287482023165839639513587248209460\\\n        820365310574665791619962339625200266188801845184546490805598621773160640879461690567597922\\\n        939801969234067751943242774607792040774249617183217965123996887880656352965695340711286330\\\n        502318312622451565908821120204272312854293350016392749845817366968139516871674839580962906\\\n        987425876820495875464309703570843564116611234932312052113676617462789546897299605911441289\\\n        798007651751631373970979017557180964901665634864726408970493916103555194007527404688117690\\\n        043624343355526868463628436649333679546165415573523189926288991571274375933478754711795688\\\n        033860886817724478130344322039542502019909301152303379178308012044872077381591307089272751\\\n        393393112054634971960460384529221090850635016524941427509071057048781721498234304269678082\\\n        009009271562978216391060226561800621286746099134437566064366537377531916797448244205087022\\\n        834487502201507742277351580269447696208061883601740497659203382526912423973353439614950500\\\n        145851925631810312542171775761773724170724809111510095796067481012129415246334960408334520\\\n        905070766242078446600055061012781628837300064673897677486352145789737029523549517151260187\\\n        910362393924627509093477090740384980898479714722054655752525957935773925286216831591876567\\\n        220358392620482258806938809304667438351381053793782078151427226407580714357651483290962061\\\n        370577756723504048071305433111828663887102056477329828464010149563476551865381955104460309\\\n        938598496758083247148686529782432364230278511891044477575044903610274007265880705373414734\\\n        694951841689696432666455433789038870186689125064613026357517146187529104080061527978053556\\\n        493835192317914461571387163037080299594630469512243362325645942689635852841499831374182966\\\n        212642325804578247970218208599176966215941664456050848222615361373589730207711786387015254\\\n        581187147430518551935815038763338927768528279349046452255114455193588810074809224028598976\\\n        891996427272281771404829486538535996186998729571493113176418246209887822961098396736004559\\\n        969260174800777771162896696057874061227515933938043155501294331602918685012387757625235369\\\n        433429138916727654294119237807942074088934860070019672080355820564497235119643699562772421\\\n        883453016842394511689772088924418898477219961627196220110292710518910605860583830805696999\\\n        218237296848631393045689575740335015131713027417210031722218203302754102273739053352071086\\\n        418491821157581665075938559356517595650812035171778753407766221605276374774442922762537102\\\n        043402678962354346438282192960470862635171524559093496566414292267682725082380369278686731\\\n        160761844052996926959986968148174025689395052763019438982548528667406175108452351326939541\\\n        635210299802806727606426058636442789316780126696408803438791029496020843383357691463390419\\\n        884780351010421074672974083730942556178253422321607063730001581839039219731432458202836275\\\n        791096791274518325668018591413446828880668255754562938279975574398476976180792685551162329\\\n        985174418707309533885714088626513413413350330845236442324720075521389434784682627741862000\\\n        755329333330394639241954048350635209064790825642863453026336264054933998421034144880262949\\\n        119545205255778059321767682160654138220705655331702421509464562787046508371836767762773405\\\n        995640187026699444943737399838555746819603269905630709623152366815471591937109406536026615\\\n        086779596571000634961319774610268793286053916065124131964740917820247548150837895334890439\\\n        977256368110043566673400723212233179342716007449117884113733523791489312818195662493133600\\\n        434502329082699073628705492299548654356653665234455089163463331235577121471902380529898722\\\n        616372376313740913266878837127398782527145049164161738576827733375351468563122444556584021\\\n        221935789247994095445593491806331322928987155733960983502778849854539068097024810419422823\\\n        712573738482938219426020086003308060418857617926943803206503755870497736691304763786823972\\\n        262507072714413213772506386605027793773310862521245884944021013546735208165094414571978053\\\n        812958601688830041260548180519755515763593304148934650190208529656067323644267336055440334\\\n        113446154838788418720785170603185658097847180621129276574337567116565201562100245216715439\\\n        809764126618816236326187523870761466577574741800216851490277691651287611425814226505685078\\\n        428187621635383496710023363713569796436797668236774808256892931022387032994237099683732622\\\n        752124579254745313743899891940562599124074373538550120196368919900987057170515706410424735\\\n        098807092837277071566477994404456209360813117130807310447903307562134675662194445796043824\\\n        010953834447774862698554459291002621110926552360241659468434180612925544469221108433838475\\\n        592739862286781270241046804038180084083894798347283404258352792397941113915934800434939559\\\n        930661195856506263161753253228692619052950621353131759637545493274901256666188560449352944\\\n        039109276753780807990017773885503518458215348667765593113632706106061789004873481089750077\\\n        624277799903368265426081264674945537780275575760022766221353690357186676387628898136036596\\\n        290611552361801597732471110200442731057709726694497223596450827459750835507759211159510261\\\n        762362879205469349397976272511888732660592471102211977063319850053264314696617652945473956\\\n        367833930021736067632530991517367346053472106324194131999420901047164618347401107418795565\\\n        415017984909100095910760171165991587239703339939100549002138731040624590707628588578776343\\\n        733334835426145918406190117801468011193836150258764744810122608008572401136347189697226342\\\n        824541392739485614198052171822378659311428906236005529755946819133158333258312942319481299\\\n        881998868045338456174886829082578042420054638631460343036774752253198575270100475662333342\\\n        278042987191242697565392694523180249406747064714589808082826938388714340592913557655297266\\\n        097373353041051704513040126076742555470491180882835543841139730385620674780931803124944443\\\n        978214861700267407696609658292891873522999715034888768477599362636665363164505774496741379\\\n        823507570718646539260357846339921656146476418999489080978901915059767489291806535383264495\\\n        528473599104914567382917145125183147174098181773532323750113533915031214341679392078669629\\\n        630395811613376902281218135705353672040245344797020339508087164814877798485684017168225088\\\n        793735909658704629486367497338280762931270927382006991360961402440373974420631946736475946\\\n        110181442258122055544715645384689517178829563606268878190543894612944167891465560583725208\\\n        613528001720387691971166658585698697003664166809317986339339062600580857894823884910160731\\\n        078635971188805079084382127433592516804195372333857743398101031505689585824565772734156639\\\n        253832123740886161758058168543586610238069022172228315214305621937062660867605610510679725\\\n        732738495748641627394010599821977107433490419920197261197009233917700563087782465102192344\\\n        654737897148189386991675956704162138840033425733825525797264759303886308861793541531598645\\\n        094107105713086886729045855173157185846523859016558244428210041730156840337653865090872264\\\n        589618997509465649743996094660444988660376566015801019897068665673316667002035297955784625\\\n        428858237549590216155389584942967543196757773697868865135005282826343395369575849592590356\\\n        717941363219385336424203482070293387264178533293167922916774402728925103875572773912537919\\\n        648488833605776093523625375905676432654777299713660095771529069936305885727745210555296380\\\n        809533116751545077276121468119727569401800755559740797890808814723921604321689776415864594\\\n        045880096551338862387282370014067434054404936725608952022640589041590292296321931421983535\\\n        445052151452677209069068659047269818555948784988421699476247186084204380406157022322994288\\\n        867887193952734468851082185206384867881817419486905215828228292507824421800327550315071122\\\n        238044172700834188980089966332222295160873764557493715766612868010670618437189502315499327\\\n        526431829972571349785498584707718777765441752374646150356180872754022199542732778822593179\\\n        756990590545568608571573878717205176326569046024241884755229625767099024371697047549788159\\\n        397847410006915075568980050596985221817172596219727545555728166760437811149961456065762106\\\n        417272588074862382174949761106256321309092785337968048928467953706512871036935254246967290\\\n        652100808969845811358868513435812912322290263706847441277617413058298103308316042270846020\\\n        846318141757003551074765702540471929051528515721653446742491291233049180252289261479731258\\\n        735380136124883846665762317815231239434585403270107867914595250325056041228931155717889194\\\n        444892694867003395089442926164781624967415806689848308384963345734643490594167473672418412\\\n        854944819018443660031783933737825316906117196054680501011761942258261854156877111299271506\\\n        277544751954490570752937693743361985743139600444200112278689671722522237262862495850843493\\\n        744572510745133254853670544750741982766203178873408964910054389564496115094563064365740308\\\n        427121409739516526031751343903832269927034974621607676764416853641033877004873171528193726\\\n        935489796902416005007888802235559280705184349305942107775296744994166197401322919673870072\\\n        336430308000629546422878308319552252746346633262330360450612570884941871121060236752759282\\\n        120266772164328887612688380933984815533813709759404949368945623298938150627998053178328883\\\n        553957783415633607050711541164583915203779874065436171966951455094767869059367504880052942\\\n        440399646018982881757697748123881749332758032882024039424446107782597445836442302031828591\\\n        187941204993691099221065292469831695829215730781155150637356116122695198511927380848326966\\\n        484418766078944841561818578609321410532050671137281993038021923446317523253876598885429381\\\n        371621366112919035217414623431697262776266163901737224236924307195066292185813923642499270\\\n        115945502486205862152027745733246804379312002354464113530432081470790054124026452458112108\\\n        324460414020677271139189687240696452626749260135286267739944045565526540153484287942239418\\\n        252121287449950297120570564760006964062824850722687086140980733972543675330726051048715247\\\n        026316108536647615388279186685859622351642026036750298922945440230616681747966949386745620\\\n        579995976064213726368999271923157150908802880657852895881150900963273283388547919939540232\\\n        717635389614460047504248254683063747426295764619019051932764670945070069849982751133688412\\\n        952180779150435514005251276147287989550254507129823411407210857515839183343842353989473468\\\n        652022467717174881727518791575009418546400255763239593843815398996432848599128779294162551\\\n        490495191943095999598607895896647252620171860435700664817611313090376711778295014908558339\\\n        763407308687616662238684073471764718830802501488659359699374732880427694130569989296564001\\\n        639306780363156309914075865817363209646634815230886338566532250448845550293287736602027597\\\n        813922290376650943064277293055149736689985098104683412128188450083318531391007754204983406\\\n        525785223045914249491750734749596830823597072597250833896010159559810683905278932149140215\\\n        533714549966633958073124776363960431258670699076095718353151032665230849659258829036885672\\\n        467498737119286779912747437599495309816944988312035864916537880580897773607869744713415934\\\n        357738536371216920948936908583443700374240400603047573458238009189601190489997418822201655\\\n        135719164173859583516610970024467811724292292045684247762208107529428286517896697941736552\\\n        002379044361283231480066638960139602128941834640113017806358228851494427350890380126161014\\\n        994565446534006150824296733425627872641069722203070258440743420783683937750091615249483683\\\n        328135722676868777220904738594648401639760917869784218610167966560063023207229217510292366\\\n        067734998584903821517527910670994279831215913916843876617341087146693663302834528307104148\\\n        426437116658764726684686046347113692043719767400686847996251512816202541321225133071000980\\\n        201173719069001152302712116215313496903511513303492374686295765903507514971740771431164204\\\n        489643001088372240459502294653760796263812152403640211895297322938252223767638058017030032\\\n        257853009593936856628264927267970740962740412444357824398049948506092560495586836813028895\\\n        803837647164180195477234773388932316676494379287987060629141245380014514535778249042490980\\\n        681483540018542287673544846386603335363273383581378513450235706440210072789925724633749013\\\n        544620508244227577208355286679354777356174638741681879484517446079524345081108002379753052\\\n        820082162914033332628210845986884403301195984185355567970448780909997501514401359763753027\\\n        759816026418833627652993953797856966905510475311932991398343333449907657837517866868426433\\\n        576954014797305462583755098386514800971725433620144586127553726483553480742111907115377331\\\n        447899243209767068635621385747655369423554113148123998582811438255569753567568787982982802\\\n        151738323574434277027168644841456484844071205337532804629716533277120196995512992808471443\\\n        065462666061808582233508211997573120921017306568070321953761371937455839111076951759416872\\\n        844478730897961413657341855511780943812333505942190015582709852733799403963583274747707528\\\n        561058282538070320906285711787011544777608651071264914907636586029222976374916700521522409\\\n        071704946158181826729485345383489302775845771269052102505632973136403893491288951494470624\\\n        901625069366994400221178175213018532452211261662051599612699202540231984756480213846592560\\\n        996158776057382889021038182186543775665240748053649499521458293117221805484731868478997090\\\n        640176265367331100053986410050241291285171771340484462871368366506260873977069947621503673\\\n        750756309042983846159815606396260723672405245228536472371201784608448675588789547309846552\\\n        656339069921444116741624356929597674588454072374427557386573090599278949143596416937420519\\\n        108906056693252720545249604524446872993297697749951322748289765294851021464707124165736075\\\n        866376255641010923604969899643351828470962523490400467530957589280981730613299440056798599\\\n        001030704626778040861358512787185271618152991004725278121526439840699484968967962646995514\\\n        006381644912206561198713331577365939698287298254283742424039290531926392958365536893922650\\\n        487437170202836477472523421388764548945262732332072482708860312474819152472823547592374893\\\n        931553421743284809805129364337197271636140030204000745742350540460018976370624656982596032\\\n        515070131418347853689814875525213921997503832707025953605432192780225332327202697459632553\\\n        351625935571488840421604418453536875890489861185250982421838170881792623059649479665371162\\\n        204400986137987459941264690141771558898499748559780406932877444326581870677483764195085842\\\n        175529304711368552115947565591955188890195716695863005102336651790012908689500467515448342\\\n        540820388492355417443042219904505364102084156622545477877545100912150565004633106874884825\\\n        689837113086378222711689150523240976386950645132352344940150509902000629691556650670477748\\\n        765384013112144158757522866108727002186789952785478718778288696594562137310905240228835458\\\n        402804877796782514869166015310563177271136034983220657397168217227209176473260276736014749\\\n        535294209993424083073250309949241061605062022481941095343982858792088017507096660682750112\\\n        193465121687850361349614490287764928868746279134298274504283529583637342859066360016739752\\\n        063942183798321291028642488236252697047342156095319579215069670865078447247089512855667237\\\n        102807854519640187729935554794724061035675110525666586094250868933817410560572614193720758\\\n        654623353392379049836511312625303803997268208491005258731521059704625138930929371849616819\\\n        355428008490869954617863760711710473722157819052742934983406109673119155754140862882130580\\\n        143136260446329651649401817787210700865289331661766305735040337422088042279399482455873747\\\n        277041758208889565734400625592215195425669936912072034861678060807714392343312038320898623\\\n        469313026439899142246404652908550827567379338390767239640136271586118779990992503086862255\\\n        432300144242330472965110492896086716408452344354439978087511674672834988629269879850803657\\\n        742648673150885509366282453196409632516822188608208560149979843395014517714546817898219252\\\n        417303552413992485106221515657007539578910033715684048227317398771527535857085576902110396\\\n        450647103274614859385913593343278261248402329599414053072103377858485615433238076071392289\\\n        573208327996574219661309493211468211082003959265043635217232782557461000371573406712137382\\\n        037713265004196344418942288310764883135273925728247943179086211172302309142070514852152783\\\n        041285046772268660986852966057840272658884302457000633101383779318544500615310715827314081\\\n        685162881735901405856473481603707212043826682063470576372505922867629540520491679843406132\\\n        142581945251341527153386043989031763956070152749663012805279819444647272766449174804721539\\\n        346089805362438094546494869257532718938588797341668941597587129382154433054352298839097381\\\n        296294635968292896715120742048885545421363764527956528590915567919189253639106238493238450\\\n        558956388791522505632716912121881274411763165076392682827540950444869299163421916840203786\\\n        767769138590217271542778375201948318441510028481351884770548460034122325358701662223576769\\\n        420704683053935334658978618785285649282440518149914034243241327081342802037083191545906827\\\n        566435451060310453546722640136480467746431960515539646144880796176635050106715788326953368\\\n        979825637230310259148071496936688317009533848136555547157995652333519804673692758421222679\\\n        986336853902507426533105137725535177546338846290549021151865393187139922057836314388363715\\\n        633983700068004293008515472335223976624021271085616963368378313629225962290184589270173175\\\n        966612004366659753236723479395557584857985555558670537223243893341231570014936716048953742\\\n        620589261653455842041606453872527353290102266074368983972845377318994679274735803510983239\\\n        554544822374883424867341835631511359943699386930728570381049247555991164933076844570896158\\\n        343427281167617483602353334854439283334631230177007924961724787066816268470824083461272157\\\n        541645418246904196029091067337576271329113060085197678415104808796527140433028135435092810\\\n        329937037686514453758521583247132384720257771027620323632595322937795536889864023033051091\\\n        937351731007925705888048147369293767292341598239420013725712424023441678366580677848875151\\\n        949640279208290489511947465205440115213129622668434321338031762134582716160196633323405378\\\n        728682858662216269201979886585721923760815647074397852845481280467308959999586448930371953\\\n        362297691896705644282585864186805879606481346937901887862911465768246528079032330176225684\\\n        032740877954932846825643764717307718539935720624562357479872140608747932907669776430957923\\\n        602690659252253227147114405526109491823282490484235499708559816158634401261958770416055187\\\n        646542809284053912922746808701302096797733807033705756687323448661630216372554149889127721\\\n        028590079994660677296753637813162536684684584038169571293263351494683033044798351870370519\\\n        523524492809077346991027872249934329112990163333805300815663981832775980297551851967390100\\\n        451419525487133408263871272782993325167629982495428340641704235398413055876524853501152343\\\n        281280763790784578281759090954133399439441732015983226268265495195832281894247227486499579\\\n        136692265459093446790035555245482334322245004903991853060951100945503123498982216587530523\\\n        557673270232058389411061722379119943256427484503782801369163037380488659504305677193609671\\\n        204207470638065847780610161340117231609755694422939400232772078584896809411061604276224290\\\n        996742997419322094715585139046856585886162919519307753074054826601901092329585787887910483\\\n        782307147959246581641357258090508151703299843848297508598337753181055980790792944072728968\\\n        142103645391334012909448591718751994680843162032277055090071136592966771751543975412833840\\\n        806454199510643824922114100638854284192870285611002706815111480028772085162767826883875219\\\n        867270968706585016045978535203387776110596867264199408672673721337326247901863692272755646\\\n        992689055064083999847975580143256042536403654673091300164945677792780164496434659824257933\\\n        776023059970331358353412030670276374975757181777586853662899888725641344808362455933948773\\\n        917919420058759990656567672829902281817083999096690491068493728349767759334786539380680750\\\n        102946093141628625247486106420801967153113423988700574919135764691478956084649912954820761\\\n        394751723366177203517192599156112483666982037782913070573550741862950718112419677426638723\\\n        403213667008761266498444704733024293916086257320279790324318951250048328931804509665377087\\\n        198351026933795398415128964780542337999119293979450272539498408461226125116903546757390881\\\n        605317726654762749581550627399591025244854884908657243593116872479423247874880479923889872\\\n        073299182534292517947606793544178016859812998333252964307844397539002811743235145103104524\\\n        370646348127138090366332320504403899460889199099301857077739121772605163487886490693048348\\\n        746035595691041318568290095424032403230233521559720220819494686881135548579919657068166357\\\n        367868424482827508467349562192969076811921913453804312761701484923391749206411642088248675\\\n        894737531294358269507100431565318048714540180953678154997623218221032038079264756674346212\\\n        092519063493737749119583203952022432314121892332826345875685096962209186475589478586527731\\\n        759691084260057209366867854259957293348973851371597783509196779604343159940825560654169297\\\n        397495021690828006856553426301146005057214488518073258382695990573201077223234937930406713\\\n        182694830824723632631249805190443571902197635735764333998954053982726642217446559906404789\\\n        658648216642400693291042339410859540409266166491110522069884200190134864238827932437745911\\\n        106792461125896057528944719389748992071579611010655271188211094649687932347930946699168321\\\n        484493736967534765769428113880271698095183929473579035751208944280799279979813539247545647\\\n        768896400895014185587904514330266822049202347970574042732435720039889221566438393810005544\\\n        041241448099562471420029149305477519526224172613292407578485167879631277234745485674521559\\\n        246946562215035257854409706175075305362518133546753563562795558233105749031051941791955536\\\n        242278562283740875115966529831788679649486779340353433127665223155157950944735703645650734\\\n        740108652799572531535261595956819606440079583041073275698997765626939420695353855897035515\\\n        488948847718827037783906907135646820854208383721754765428585310822385918341511851292782168\\\n        305489497539345514076712878449395679023223702781285287077811038383842381320257729145381777\\\n        718946252371457409800339249702709153636433445338637599422020808397146848091154447544508809\\\n        048921270176019981246211630063341317275923216532931611152121381772495628900918773196051960\\\n        097523090419331791074661852550126464775268742202376132364997153632060367740418934533420610\\\n        069408591570487828514465142234957808820196389135375473595443891790686117395802274782910338\\\n        819497453244915525966475200155723610555691967188665787334420479302227276460195995055904908\\\n        612384773100085615512538248241199589934180375673868590910074140908441652649905922237595281\\\n        445787333631791769443036327961883222721221785490191194232454136473954438527225819759036077\\\n        345830367704197842680034425147422427464862632016223046832434371323023985035280674313791317\\\n        575793021965969377269166396380165981607572120573246660239390541541471633964275244332805513\\\n        716248069904614160045028591766073477082813906485948627411208202386329974234766168255523533\\\n        044233236525354085334353563686418732212812633100522948051249809159009138860225173722192142\\\n        479862255905832762454484845160836509560524363101352254524940965946116322688537197409337202\\\n        968928824552786617586451644317743502049993877787699347326789263715109826959070277216010082\\\n        654762939458479760713892537199884647575878227679223470538114759218027357821968701473504285\\\n        328149514410095392376870680403186916893784627603130214450338762219283854535652575582287049\\\n        115416929014444983451237097343031157943777651928135857138668438971095259146054509221348539\\\n        538175625077526962765221763623547806952055849841814997643987440791515192303981998110663897\\\n        572876536787688148081246126145357128016828020369479514811774893566549329417840357235617408\\\n        947848307283400381197640372714309633873004080433326949901144911709120107355783855969264802\\\n        461902130871390401145786774594624845484226807289257012271448917428168458307202657854728137\\\n        455576906630798024255961185749422576920944629532592414181444845779959253088205828727426811\\\n        753255024805922608615640116356071327276821788890826919591622602283618659975094161501784861\\\n        521824617231150531683640224945112244239670101860505774266750711705392069282788112020413429\\\n        366768670199145774172674115110170995038593176750217156407965551238710884033572923967843065\\\n        769645539847113995561745649786430313422459550996126502323877093706242868566743711501259051\\\n        656976552907211621194779044201136089671028569336437880198913770002080557043545278881536548\\\n        607552781414790917901690893923685927997447581677044852232984726117924851339511847289397398\\\n        111453149908989533833229734310982442301550184908245435407014293381151769991485031190580744\\\n        383734433788060659705397878697137003942299894454121796649099041522189118983272948234956896\\\n        859065464802940434027273152939571674701974817575322462298916358348072612784504610462190402\\\n        878018217358052770082169594990481594631542211670607377528477134526075229036521559300658410\\\n        831880014475120165118309350361242411017359126844670043017912976788192632258358880011031978\\\n        013446287219098997083894631104651001379739374796640445117424214424191327345384969235060348\\\n        451089711107773573579445412013988479679450074462077688356575935850503777514696010471722136\\\n        110135575976542752318334324359240757290547997721374199529757136111980310691218723683522660\\\n        409918819370745175705692215615981792525361829137421442952168991761059107951377457689811607\\\n        058019959930775321690049662391492098995893002558289643219181800023811062783464453275776669\\\n        529775873190718192930917774810927822279963614028152993455034062842029855864054849030471131\\\n        022326930302153014774812171883994944049148743344798978604623926702933000823587939017737671\\\n        992885571492605060783922510175511209337248448558300443799106910758032061552825809497472184\\\n        680960029902721017754426756235833877173143342593962453761610570069684073524163249550192571\\\n        680320190962760496261709318811883922168479572598850301679526711540098695085100281489521390\\\n        534202824006511059295014226871548505240428570932135836409461012132803165949416228251802541\\\n        972809865692239591294790278103975661756115571058327312609537996524099886421610321714430236\\\n        863812587796379307627242548743979802893248239224243760540586256577027225622144982833344249\\\n        318546480039425888370068292564854058360736922080691764537928789176141193948214730359172457\\\n        988525024859338820586608672840090828288712012480099001173800075571324705954942763214899970\\\n        445422519252920457702804132759695064794728030181595385352112004290361793590489669511867751\\\n        084586626688116863126165478988561412542959335612989559811214200258798331704611030469626458\\\n        651599204335269387355080282011624692926195708811137455915769316262628066429070717522168959\\\n        830758107193596082270442378693889273191462867370633517228121636920020837601974177170791422\\\n        073383653300433393008009267295164003609163886409291815492942469595672766078959366754599716\\\n        179804581784152347670609800427293003471182021596253245456907427190543892956996375867633970\\\n        634388363988426743603164246371888948817870372398196369643426856488075219072467417215398974\\\n        660536780074128400384415713338832456252792073998419141605672989633136856058350707499896415\\\n        134479349255345662692400918143303243540108010414895343153475966704530612745528871025585569\\\n        519803479535077213586368130231401468845342135338026693438014925110722434180893016244411567\\\n        937808179956083072995180891815202869741203595823243515711554404935448649283884890940032072\\\n        512675920581692003463263530408552076372218241071651073240242226175804150760191809729505834\\\n        914361482246365395871800169266543686360399852570495376123047124622855326231890839815839311\\\n        337582869837241767011404509971307094523404403139446495487002466419898080976707268487267819\\\n        921229235511557912406633641036300967570853274216715976403387444245121972487939080623527219\\\n        233094282999951721232457404473718321359194145660528298352848360872796083691212043818324583\\\n        917090632336169053615065303671635639317670482134470154292322735583410412749166498247315937\\\n        346154957821636537507833838394506954403730046530482625963293764487324280251069553952505467\\\n        096950099729438927461099600688991232257504331800627844446964716973875272474191119668715755\\\n        725759718047991340019286365215347272646246132151332831252365605480431813803906832598279384\\\n        858500581235808776186995904989687706996479241723252322035140184299384353449008958129653789\\\n        863829350182697744906084675798634921000284857145548994121159040780631097503696330743420244\\\n        298130732924631785063251260294887315871775422165247140950532534579987724992686777184790491\\\n        773866948750164655429270207202415681722620624273038668712892082683447932982517927633654406\\\n        912672477616035255565237099753345954423316858726238393192490342844724094764678773266461478\\\n        489588588643610222061197266275616690051713761928158802870175233606836986285494226110169637\\\n        519132101751183463487560031606597426968651216562897538827488592149404825329162999453875243\\\n        073234085250687988704815307142975204632016103914777181025774599934444831305235962829340889\\\n        815246052517769657258655650439034462786978520763710568994943728477361254391341981931804505\\\n        417866416421064975334133383719606006764003593711004247084150397301272854345948892947523593\\\n        658152897808510967206495891263281595184009482079049513332178537935353039703027941689740238\\\n        712289371188732499601193591933113464014892462898041232735505222089553361372107763243961423\\\n        563121764653185116833565760254588857521725693634376344146571662611955018939436798291516690\\\n        731579798519270236439450715390968836133529787029858432282725303298472449970144902633457779\\\n        478413772735088025027831776658250414223864027663316812267201162798725985156480360256083689\\\n        103641073543729734231000932872933660291791942360723231489913479841892332148448608467454800\\\n        176298777737680630995382309858900745261250373990488480528512013187397638432373178296897970\\\n        704430785554364550165770815777074165206258503070712442690380388954721453810421070724244408\\\n        533918192041493524540165591865799384238622493860925523532816181256658930919593181696357792\\\n        050001431026007132801217022411374721738924476653191582019067133362798244493857795949803072\\\n        033006705382860583048201826966067933038203252277369301234577059136060213981912944866330863\\\n        168140003555355279051300231591413107694872170685718580142195612323486590514156028628661419\\\n        944375815297619776625374875147615387049455401145096854877589955820763333866095774526586912\\\n        897028686294746594342780960190433319178924594427040650098735367597114101492280127717272709\\\n        923212019669156723305812825458022983951143492083487445895768312988139420875638351365940399\\\n        730270917892859291709455482317515575242078978347638357129540538876175758291705810540953144\\\n        122912092015325074807988925165493191241911223144337551141402532163953282254421105219328498\\\n        951673778987829892271035542816456814214967078012913792763522945850152063969529115756844123\\\n        679419254169220470608768662884038650590045335558273689018956326142971970329115151510808639\\\n        945945358144062037281285136111073135702198306258841603104440590782188244842440457847404254\\\n        592644639168009377884097304139857393760709099472921453371121226758696141131836955097336736\\\n        842493468968741350152130584627249194400588532546716096875169941674416611497312346139234771\\\n        704109092033583018359834890935276359036467365043430915821888687659814734793218362803669599\\\n        268417831419099011848188485696730403006105962023250569156313257161238360548587642492638466\\\n        262528130190051759856257988915451887230526550393886266312931707114879800722980629062508856\\\n        618067655991113207189900194140681145495834039728227430153488339663700640623058096123986452\\\n        251011385430501571290041145705768430641000539050073214365689270935178067840987964409769895\\\n        267206662008546120504791157096421930196957570403610738282514165324802022419768083014526505\\\n        642390729522820279289547672604684535219497140884118816477389071748725486053620971962108426\\\n        851367048696264324451660506077242935921753043566831028639535567952470128723069736098259142\\\n        879806242527865361960103923021214791246022017287155835275864497251172867495234101923669477\\\n        301853487433478045669521470558905245236604635846805755059560250437816338626083634174728556\\\n        907560529879900813388880312259258077275137393899828047467214539096391642741342772898562523\\\n        326704656285486643929231322832427378408520042765272785893932505307195035847077205281725501\\\n        590019725957072867956403509018807508515383872140867961630431794586593728537941255213734890\\\n        510181263864910511864022719357290443693380551945753167789230851378353178691355680566608181\\\n        476632722892807948687956901780757504045290398648292619890361651680945500741625404709042535\\\n        270046984234264961846207376600914720145939923072128203574744925021444910542899433347091045\\\n        683183399902286340694995011899765629900341206899028349537839137273949336570920772096200135\\\n        031058391466533456114806749003604519779644341474446813708064190261580034233410368700300351\\\n        834094133069732180960623282926741243349218104263646537513997297939268944930982988631439861\\\n        474073193093285447571625701863059631098185741101218856967416780887419350984886014172243735\\\n        178652845436248180226255413005600973301920674367551021595047797351517687316956959286103945\\\n        356161661092103829150491218472194447446812609114513172889836684817046259103034555383412984\\\n        056748147011494964552629368039698806828109877389933615717807177789019940199209347825071923\\\n        188848589006451713722399641023310908349091046508391943879902032001428504133832619776938626\\\n        956322627694367585692397375779629129156991073136250344669368209499355942770037672984213409\\\n        862360771668861369760421660644251249959119285088347828725367972699883993123155586354521249\\\n        890075360845319958918892183824762084290518320125065206565891631701578460927222401820908919\\\n        794303098141470627602641532384849886004173871156094361438391145705386243002555778794556325\\\n        654760559770310255949520309181494027973705270089956970737497767500252737128548409523748210\\\n        985074663527090647552382298871224031990426001462951735347712107800876077591122022226035792\\\n        685171443911392711397319451793667751145670030493968151330625247057240377306966141937842425\\\n        294410160785479274557827496434134038643386897484477437617217926462441175495756144398220607\\\n        782939369507927681817746076931616431698795147404051253854843197163819853853307710112955395\\\n        930959427435174576479847092230783160331266951094535721230487994470453236856979011828873134\\\n        904108399840195948825999265580770919755618779546307279853143887522531858642953583029684534\\\n        738448689887831840031496299243257284215990543576164103836949685227457827921783855390235618\\\n        638505218736177566400564873078009049023341487362906583828435400510357170007395708050381900\\\n        343034105543703943623138732864657478914074498613553479524051006887372827638381383871610648\\\n        835117970706172867795144496137497452916164961998909356869069356895317833335895641637032508\\\n        800704276243881546864390596554613748541561090039719646712937685485951064077711108822841655\\\n        014994203224734316222874066711029908602164432778596294406935217997978077182967521964689701\\\n        592306313649755397149958911563288741990769340077957213070195325812765197439747198392006938\\\n        804970327738305727495066679140437869599480848442807154438322836087594609850051541215435462\\\n        156496791774337827304458458859135954520026002303417442210625943686965528353129712196363921\\\n        752356216367783024273794730381214204719471655325552067559423145633544909390718588443319217\\\n        572281680374091186065054878528923998589280877114284754170607985919641820147972439673826002\\\n        920359692377502871296520934427899136227511082662748469429929830026881899657613033225301402\\\n        741075193083018987819567990203397612556238334625070701241107549132034167596993277695988403\\\n        579336178011082298100425635664180780546580109150727059033807767464117063322973630662622001\\\n        392902271358684207880324402222440645956790229076214823229301347912397322871681953171563539\\\n        666273811899047123558850174013901902160013623556728887763681224793910748836110323037971222\\\n        077648499052527726322587309240597772560761663124991753903989249920631505242012841249230318\\\n        627468246205226566629977191962355395532163011020454452224559906420550165599741437232642339\\\n        259467675613429334947856721028097135028961162831572373618928865462203336530011714110451969\\\n        164059180983602311082772912949235568374072612109883808602754450460142612480618002594491164\\\n        037328433898029083628192703705747701230803661363917906878481961780221040659365766508043951\\\n        168547041457131744579221068918602492230387201886498706807399671308101983347620424594581134\\\n        839539832261500206827799881190140942548119032244786048797115606846521799584343377645617791\\\n        379910590015701452072457339969466436652301132934232119706422959226404401218412921599589257\\\n        830491722140640567190642995177739075731806621524464088735848124681881846477910924425469233\\\n        968913998361610004176257445595434228303316681861639029421890966383487945387402784382947165\\\n        913460114870623283928098241383417907812750829417101612126825336796659971162182617089727307\\\n        087057947818483708209539422546701775592768867394520198177059859172998997181919056259371733\\\n        469619396786909693740179386786688940307534079328383389476622786414889690511395151841674074\\\n        235098185406722278413246718104949777669279736596293729295281877756025620197378595471537660\\\n        775709720020716166178753023717639871279251106375636163687221420086919438531176089503428064\\\n        014498873540740654590074587765144258092707366628427497193712773750474136376154494840777482\\\n        758089350255110425901891716266976178412367301517575599368193121268656807120978976572382856\\\n        556961799501653637477445461870816586069559594420288900061972034468981563884324289068512684\\\n        767950669113540401633583170091435657164784489553120622707738863068654057673365693974076794\\\n        644386720064796621256205952586512203533865122521904192042927109295077915324352472540285821\\\n        172357572012987341515169029004332047658657502025966613331590614839599566558607583561361220\\\n        880259216605243697406787897900789905220080932541963581791457919311642222017291138354048380\\\n        386043680274999591494194464564039415502965332753457323430737758929290361871233698760076181\\\n        158013904824498681752139121562731844682999454357979977946102096000021428624549330702739410\\\n        669596146580697142239898981386893048914494625930641552789681631206637215199450391442177763\\\n        398811985285487271326496997736482027487514085728728574376637835370858374642309756107634312\\\n        611451965852674848594822208555224665923533002760778540411330942977092781782398388931081948\\\n        364352789110464772660058571662119470035194610483652855130380226030164638776322978727271581\\\n        319423042370629467330139827860890012526488390684951068365303785445131051095482093575304709\\\n        317698889173266455468652673106930223789849032031612675161982473038028497895555106195446549\\\n        627529478619172619901277659834431015599813126172681754858486142529110235327602414962764679\\\n        256416402459490588102270191506051330498030007033059455936853646213590907845868730447136452\\\n        285160275502920152033938870368800361481468109429836409401789211742042786315069210454337595\\\n        687005992421401541090581201990990856063611511206036457753011604717742015261370917781337869\\\n        496565052623068802107892838653783470918169566635629382872484253391671195951519853171532139\\\n        115274159884720412770457066884382247120094074126848036580202863333816821084368302038353985\\\n        154483163721409728469949343846687765889761974162604490011989060476676168034668636215629024\\\n        790614104456327506209293702800457618265442089881127278026815377707730083001859853702464212\\\n        665521209700918599891406096931599740364100879909354150741561131132472358582796818378135044\\\n        524283257859119301592606190970534675399301703932756606739666571298854141310025739506664309\\\n        918466639742230239926214462895844138107852423678595193039163339649623880231582694355241709\\\n        404512296843097126933351953784145149475097957384590009142541467608972483488350881709981581\\\n        821207351391128575138650730014900132602638218220764208217759471592603615565647662001829477\\\n        980813210980815728158757272089331817911907547207903437227506824593084605337613800044554221\\\n        025816388188317936870395057681788434105338858931841858276340076367689484100230443168811439\\\n        577524365551084931925978937567776920498330998287317267664934776131975526160758281587414408\\\n        902232366145964169778857508249184811718833449318909230289731174015410604856813218807210380\\\n        144655666789209001295548698884209496388764942495626061495307821875989169768190409454133284\\\n        160277798080374931146686205504404302257268868808271535848874624986118911546594942802279988\\\n        498535273779579100917440389521986428668225822372061173910933273014587306247875195445867040\\\n        939963264605980648828711408801858355708800625247425278829021029849287966785011400361533313\\\n        512756935769165294887317443704771855260022501031638941021183802848725856725808175073652348\\\n        568404557571055128023190781300999371788576722891709823463545888882994696831286659014348659\\\n        304722881266353460658332652569616940737483829659290675398812556352481700986350927076705789\\\n        494332361255355592602265369087461235469519109954184333287462432942305446834989127450585509\\\n        057035172490254012231373302041940096905096924379179057916457771205205210404349462726178460\\\n        237610310060433230757802494316749141849646886728810464039084497963778858193365291757344769\\\n        883851951352671823261426231043009614614758268772900801762941460878388037868259313216252243\\\n        724370876967183783633338168528978987387850139513315988082142190195153594024564162322184199\\\n        428133796527904858706238482554888469252350572515886056980836034737588223676720590126104378\\\n        840776306166333561320781926877323606606306072549839619003471817747068820999930041423093538\\\n        827034615209011847314349282014069434284970597546138362825425161311629042544593907494297294\\\n        085682681496407389521612399802349400433651288640788450044069205077656925923329161176971085\\\n        669756261708340039241253111011790210123899712899376542961207506699626917097595649066143509\\\n        326222795099846699563559336109141325203018818134070551156980573448745630524565481769804600\\\n        078447581522529374314808979181928709246097280942443933049425217668127812944328956119422803\\\n        512028525115245271790078736616654573900673921564796930226068507203744016025724374674159756\\\n        607135243448742485710193306848678073543478633717709428783686031291399383173104472077179184\\\n        886535456021119674559015659334686582953364016753826656911996409174522126832974919503136289\\\n        933364856754732418412192079950126340928159196408414360757375971062087631536193952692779491\\\n        047542731695934316939222886364705277855752930464013796025701009374201302846370285685260571\\\n        479291414922406871977080345864102992876062351199244017289975407712017907738284616130562597\\\n        114680962351201106370012897610608063328537341758041097926158549191842258133799889270705632\\\n        852442962750931712267305401289905428988956142479213177905400492577900857674946605082136137\\\n        525987323521597832792744169673776349157314919261385951610703089406118363010102227859866336\\\n        569044674503293265192147936367666737625969053617121945342701582194101909464070216648838090\\\n        677642930101835866321512370519008027360708994580409865639031549760220964220226379788787689\\\n        143579639618810890244130861746057887322545255177467585667722403689285522033371466091680983\\\n        197630693218796192103118264664378980542860550933808338043766426397706830392200245690578839\\\n        233062311541659799471990021149030178469942869837887367511955061941542856935185051025758032\\\n        427912389544479190806493620668725013820400584589968526838091944476861801029691475165700698\\\n        517152945168116048321937307146892957984900047680475536170570484405334427592729382484605976\\\n        545466566535884805084438721538353661599463469803500057705621695081379300891369683576586793\\\n        904772174261801675548696576709248538229721322643265304056614632366113587503061522227926010\\\n        958784918854396761414727435602364202919511826412344235156519072450811535199534542241885074\\\n        153958698503911718895078107080509116215904195078059753998661484643243177110118656892850783\\\n        442211811695930269403297422469597672207768356426028044223425152241368225476776994935008689\\\n        656086065249495443249371589924585564004855319454789708674398456756877465324848195656755873\\\n        244462794804886035158908294578771581096602994516498444645409877880569545643492747818951059\\\n        028961035436235053189651745179680444408358817467214600939660252902333498150965252036157591\\\n        902979245627704812243582857143551897711588161263717332081622570575613404981211963802870471\\\n        336291893288494585760206806490344748055849652151254832907618351640685594042924128427784510\\\n        181604558593506092869532690388762616539293735081749482601075832116979015397104228828934666\\\n        396218132974860409170477062873967635313216687651028370172008235851718647027055926223388307\\\n        336059366903279329965904348686170498525279011326799499731678058212420976862506564540490618\\\n        267536553088840523623334946458282652712153747417832368117486672397579422641589980549198309\\\n        317700805308636608572716231543463108844210051683928340261522911811249278548278326972320360\\\n        934981352046091198631820917557904859547273769604706272698012471738328607622941047728399423\\\n        450324155680092373426763453666029240497479097176047844169544360280741491850711161465114505\\\n        819240223558251765486962581151884814014621810719266528164627155369679215126004539892241900\\\n        626083175504259230920813914514416533896758029032275355237930979402726895258168880782303017\\\n        204505150353163165423823114337851233007733817840804361471501391880694207607432003634874849\\\n        315903412714425573071638830620431690101710625775135694650569876967601940581105289099893114\\\n        371117599259328185216127543676488911270885750548321218660991685296513211670582314320801961\\\n        191128577869773736159838460311722030781284754163898465992625512072080777257488974731023383\\\n        294173752554938920529454762128414606714020600957874901148354533342485706018619559602983005\\\n        578762322208184860306160311692619062637503959495066957227831630767595632160134146350360181\\\n        869774006332366073913575791259189077140009903336408396438513696866846994570822819096452444\\\n        107901963546223584024930396493463881480353425291648271166661270517169308463246378078245535\\\n        324244772594697337990498955197157837543110107426132009354778017975896510396200323589559188\\\n        189152711560842845247467301597192815532230052385887579917432904900062019269197477720731674\\\n        560234175101026927969017008596429050177978663583004738079672944834802417843703596315442019\\\n        553786321408156892232451712880710244650349751541018331597553334691143906523015181818467112\\\n        340265412467803038687413513013256096428580617152100760692601361348261343623238179347956725\\\n        982322497102559552332240717794180265028655639470568452065290831529571264824290024802176715\\\n        756159056642983326302541227987365028416903989479179755699748112265303758800968949043677435\\\n        856563357546643546432106029860690683429527892845536018625699388250116316701506120472925394\\\n        607950252300633063508396057259118206718658553513509487523105914621634251653432245477247366\\\n        846143787908966283399632161310121410468720076976969013194142353472927957814803599476423700\\\n        624665605875534276964310534521347603945466740363025385585211403334668590920994150210885990\\\n        171293786224372655275038826976475817574367017429341588866348655036052745085438470771581483\\\n        793170962971307078017861337824393628826109724654561305060243438168312136765050571557168883\\\n        396514218416983231651157556336333716624547877283696203721790898826363587593439823757390275\\\n        393921528760523338145874222057269755701336000264903385935204401807920526871939067642412941\\\n        713119263425185485850937163701999845112343197450327698274830338061821285248794546073259823\\\n        731372737549306725246374674786624904924150987390752408772753012248109119408261516463218406\\\n        034603355718751032058251532819901750701371087836955081524995439056925542293159572072798821\\\n        421824907154977220438723936495901014429900791735930488766562889488461332699749952101133919\\\n        136857853084470640224701031469667939864838228104602650631439497178296727664526793301890560\\\n        544097513839761178120678280043335142713311663144174641471697633133861155198610421193508600\\\n        930740998248170361256319898227139845883496832441708198093047991933262207778289642127679752\\\n        951675886460583748767404748146752777073287570504838681723593679882102600952550590932607747\\\n        306617721965200690361487421199442782141265419708256376979025858379842499289875941640367392\\\n        389053100728058144403192143473606696034929338131214771630889625136208516193385414622223537\\\n        946389013091788077439033063842172792692710191258182088447460767990895321474137443139729313\\\n        159841868129541300016023412142452779920082610674625947433273561565956699489604641550646678\\\n        694083324001222933101704229546480695365732519995352027569434991436129053206675468097591085\\\n        811716777461142783730921398282861318379649226058495599510161937009158765942645802263321605\\\n        511920817340931940855111062476817387065373915435672194882316902162367535454500232452793657\\\n        079279807535125575957312112058303346129069488580820230466239782242748024575930399427475221\\\n        037140268929925692583058481935648992971661719383934194687983034269590857800764424779549973\\\n        417413617837959971049168054538655823023748717569568190095751477438273097312624911663627085\\\n        320277147873657392210803257524029504907950219224413755795904278738735286594348928121945376\\\n        197021963543970894274463642952002318601485349156744729595726147599494276274143042433796341\\\n        218547554263276822340547033181007364597576614562545630461670142612317842731885602379778476\\\n        799361170226417673569949319634066002934207289065927064634384714937706457829874814568308031\\\n        056697717659170921348331669421578921240410075415144435220998298723588432909346661185978318\\\n        319085177353278924291593419356044526010605881386214589924368058949668804019346411158852834\\\n        129559965299114478083998879656961892753746999515347055809447456231851384549617828576262817\\\n        079076627783055510515549733616061188755311361483047681813880863412260089433964360813196261\\\n        268131116788907507023599773943571669743452429831368209460617079641209571057221991684573482\\\n        053232096865994649996795393536115119921241624458076057441323034511483048398155990574301572\\\n        802284741282501999063448916077721403141655872385847818034331234750110190701294410079217401\\\n        668805693260166145991682562696098518494942225329121700225143173761551010438635455592406750\\\n        651382906234392176099513755456759285068221103041980453267426192588887401794279915871911524\\\n        684476635510247160688105273312816328479754190974789509373041080861209248017333421900530309\\\n        657374788828936446109172890425977725059692749619015555285055778124492215455320654443105918\\\n        828180538945800356023094523588255267308278404445449798748527161362662040263673841119773179\\\n        564702927443435314827930215959736307295459749443532414603154177851398338181376878063627077\\\n        530696844104304439638496555460815569853642677987600616612818829429647745376422754831901188\\\n        521752002269314374468989960204985877574809214492573586609350162351655092864283998207835625\\\n        335499941145102599757724965989267433129617389733389417834345357992249168911286199331423411\\\n        284210407458432926756260175286453821611210995439816162997450775388620493788751336622490206\\\n        414027173907891662313414949431782400071786413604258416495025970942266273281248195661195067\\\n        388731344054539220858837507023861428174911244461159377513740988217710036243349796378205109\\\n        921271812807539241828529628115700091541009050835405973060419322904613427518969890162564834\\\n        352644834736318319821425200816385226296146031007542996134386839214806332348234668831911633\\\n        998387586294656644656839888578789681742858051327256282424899181169280170888797308943504746\\\n        009543642312054770251572097937395137552287016612542287150368071540341501949004559776796757\\\n        282653893425366443173831921644756582311467946341086878001535703514147443573928858537740428\\\n        292127114305966306452580167846515128779823771369058916114346688092543753702251188897782796\\\n        807550764370196085451664361821364316063480819477924351643960093644745191724521271915909690\\\n        552376431093325400280023678466670712159493075802006146253663868226345649104358915881932852\\\n        761335285379529646132866921989207362425384482904000937650134773445049354853132198067656598\\\n        698727405008320253761201742549435875775764486721447683725243136547182477027129343491406212\\\n        240772181269861417471613356146764764151876680922448902599828262491140650835908381854495492\\\n        338628128954261806050820113755104631019532671768885257961170508154971680407597056215903736\\\n        489127580672591212055324835654209789779576771456896110893415882109450111971919145100022524\\\n        597028066099913739570953788334672395642957089132569498606694997277969669148689796071045098\\\n        074541943958199518597341661907174870822637136937554492885825264199680677454879942622398488\\\n        787746666513788796515438312502148854793427470719154282795100757058454143095192606262380721\\\n        738213029317283610286284307507573679729526173435001235087776887932870331089015001903344968\\\n        251055880736424481253040418517612995789856916343265836795894547395699355086005211052744693\\\n        144388569971342873473458475429121048341099315706244574044446418903031614630406272972646074\\\n        710196659350919254352692509862723817386290899479698375553924772100725116927597708004442124\\\n        405140376159143620109916581459672070264034702854191237680443756745882892470902728578915992\\\n        614815685959423582935454200811822358366898566625877120369738408615398372010039191578682058\\\n        422146180748226776442893212136287521002797826970822393931342863436318529292419194576144943\\\n        757620923985263735522648362305216424122417740364082996332920542107392678476481010196197908\\\n        021271850340265494849880490517008089931846598629606244364184005145761442948726574667777036\\\n        530636628258992413791300461509201621248511142658566085911034512825594351097697138576345387\\\n        697109332397747567045041077364542545065372689532925079559299436810391846390548749144163474\\\n        930614662788562896506396367543500975079542662304550823570221621858754545199718685418533524\\\n        252363843859008372812173924257694486668122038295065910337240987573186567618134670026696163\\\n        208104523527228251726043499779005980215735982954434878743534708917673344834034553886715773\\\n        599062253800606191712179756889532151061354221388818587609400572611543271095191347262668663\\\n        705128976609573125547406680639067862933513831513989334359000507105631057790180432302862392\\\n        273566866742189584725874906975353078297359428443635642563787648510266605271591971047817311\\\n        177255348780357768725357231772535907746853053415483544252799492158171853643456186605229221\\\n        032721799221730063271041585912609589517706332339890364321263778179617740151158642571690395\\\n        147200935004945034311298544965087580165076571182837412909509480463250895561842304032662482\\\n        963282048087886542392064906064483027216616876822915700018176513006370759334087277048205116\\\n        063955740859431993979016036204798613774477664905366666316074120139205156219891362574442445\\\n        370550541767303584272562582856454696039440673592737205376671731070852027229178157111638449\\\n        722777756607361546495264976274532040335232912577206460891489004876607153852025218792835341\\\n        382218611774230044608338762971143335675178502916970926955159494204545552443314140714032704\\\n        431925041354333655176071220710504436643531857821123283422816261699708969661310046237295250\\\n        511123172532834862411773812621307282401317145873195589850816188088475315519158213508872798\\\n        997422228725764718210489675896435148620844307616896684119385967045656711082264238576938518\\\n        384801942602588261560111394048359439774648867116916809134657651949445819991049952609340783\\\n        364714860643270331688447714221186002467332906799725364339440538648831846097004936077227866\\\n        106437116009241583247228697743447282521075822930789550860025019564305250224189736342842462\\\n        366641207856071599888260626400580621718245249692221644595186238729630617827226672800198422\\\n        656899408972893875160640285551240831149022472734156194355177004630076718399841789718834305\\\n        094987298375080029946573578890122276834516809443252118978225938466450906613649213071511916\\\n        494107017812506900869541229695700637492923913619549568629200836308748879666735821780803134\\\n        282391093705296794753131608961444204070350707008094577206761694455892673257963042255548134\\\n        751000857831749267747358088433381677471853283734728652489795523850035725995068369426907049\\\n        523495975013094562357752765413878491248342326051396460408105687685188859628190855827545893\\\n        920018606306118991354415037847605309736746328565800917768304267531074780665695553023582486\\\n        705171149438948554103301688629651606141880882095977511021018742631193379383823505908384280\\\n        702575550879559073468441344981897698191152086710385471294423082586818087894481716571383577\\\n        679731054668420118088584896274972346353978050805156915998444865951900528240909565008716423\\\n        336194766616009221398195969325239187054674523437104823078143337898083329562258819452576964\\\n        312719769516046622279106160144847453438360248952314398982266794881310118672780014169419050\\\n        776160815147659090675658137386946237175040344487020912757045151779086321697096726415298326\\\n        712782507675797106577427718702541822651475161744421039795430855167386546078138392320057803\\\n        570653585049880033094110884708466433849033467612735561873980778346508910742982760157954002\\\n        236624566866809821613043140664031049496036286065992917276386850637714113923545884983167815\\\n        652907864830112643197861692291516793789605260660661232116801087208156959976572830436885582\\\n        845117612582626169617295796298566178971093489394348689779718596114850553509619622122418729\\\n        702240577266266677683138257039799842291250618878517256443687327444246417667477707572572063\\\n        391626737054250274813129317264834710204241735337358218008385460245805343685977136972208301\\\n        879705055912110583151904081209667431953887610246539443952747131454843607597716486468398898\\\n        359617921534899258814867376931255906227113006988736172997354567893896897071613501747004449\\\n        928827650406412635190337552499136186148930714067708698560084099907013999728219464966272649\\\n        003771521321181662470692098247282363862952575066944847240231743342818914945024124735858882\\\n        402862163118244687716968432963380199971846189912431160296511484512325013459456451081924049\\\n        375104490074889946248342632033043286786457130261094944934265126492359915712181408575033439\\\n        117337958597053268018363086807345077101045058116216546621378993456576825704154439561040053\\\n        974379162385566349957596498928463964702092285820018948152698666577545870361320958467685990\\\n        526680001768988517883606905767374226965175309125679816355284970214477336316572849524007024\\\n        180855772553316643521460066301877146632755469103604934372747399911029499041227337596775507\\\n        122768135744889239825357769072582115726807666414555372452364134838707810546251135624495471\\\n        680529078905637436947005971235349957405614880165143494250275798276186298890688094566508412\\\n        787080233040560926024620020571919262848702287976920295383213487182174231184091484721344569\\\n        403126363110340879579334722287272550152213647493951891259327023027375404069690632943782795\\\n        269126133441843892907245451561806102417332745061519944147527192022834104759422936565847833\\\n        699871564896025522719089971250264044562801899810750647085746630357599061269961659085351598\\\n        533122074455447154605955489119136343505179852050112355785475415840306722799521443086434180\\\n        193600205332598156248383961444134529811214948776646297329715400350732119614738323967849381\\\n        672172524311212851320869358804052910307883080604552294509005305947666568225924640755107801\\\n        550230876180090849093334932440373598268647719273404588781360661902627866657349306037685256\\\n        205801037493603330230926201672033853837595446529107263522560202037328726773324834422832233\\\n        587182422008913571326735751291333604263957094254249843287986929024430301135071791562044764\\\n        810171707259347769314151093709708951490763212226325988025634657102611308467509302349152949\\\n        237234410260937578374711191854221505337016568085821820702180049157032358131264276837630589\\\n        332344651188436623345034567009629756230488974250263472669088694642559922096871456546176652\\\n        309310107194887963915412001451361424816841180189001836708347390876061149456250302749044339\\\n        849815435499211722912846836566951559866002757585345149729187586201747220329824371591356168\\\n        397184575391927021334203912230448648491080047684257094468078920518380467290122938245518075\\\n        509718056445584598968595757552394917419383669105388255131305146508927659000058433002051139\\\n        273058402293556617600445605604058480327217382420126945576812700527439146484129187636539407\\\n        001552742116130702273151325069311983555537912205542121658064005424279993255895267855493628\\\n        492911656645184070876318177940699644758092136403954285850648591583226178738530133847336255\\\n        537921914873296592236339291837132781075852931642375451999163897244591049509176989849199565\\\n        679658472393403395143392970138922907162457793387017193259631433806587377665318977448056243\\\n        369854346554291807569250234267246283751853473698715727194839830044086321988194151069515810\\\n        313561886779022529111736446778372690431731200545804935383309248711732192258306702575543717\\\n        165820356253030316971537814678360693675431449290833972148942236619756706950696516167728235\\\n        463509087872805727413352392452886870340604562906520722239250754741028563210942759333722509\\\n        650426082863390555393851067319667429300085174194600515130046579385844563602875309532344522\\\n        873690399814940510921300869418575210611964839395438981342183470189921744938144427735059566\\\n        934163445292075797952650691040358027115395762778337364147244350833006523399242621245037378\\\n        758062037327219781453378341906665300606966655193348201238458926830126281940097887566499325\\\n        574190455724051315911734497183420288755292671709030012196250561747441302659016075245625599\\\n        936132241320959667126354194501917191157589279221009679007282018393194546562000294363577871\\\n        491909803616658657650489167953531767605443256759393095198984961406764456559705765526498906\\\n        231339921626804040051456027428805150700850243154238874690019338272315980482647707049426166\\\n        399257352666934347593336324427407969718816488833387788288344067148533061382835294761568418\\\n        389034797574866398470378353928971067809193040096136180676013692544260524088820485535751559\\\n        556499378159047064721566132294877751374425218262836451959383613389686502765867773525774825\\\n        848960820214433691895898042968781135045302747100781659186622646442090914706813389268861775\\\n        173978736839106597371934588147793293851131983673955758388148323080824295841441631271385855\\\n        917789085064493464590081816690735356258772845651307569960798811630203316444573883232909837\\\n        319721779994181019802826872528508603183121960862462900670245711957343566244854774026998674\\\n        596819003575382881685522273190131763033723266436015277103898786952029305704066639866141337\\\n        626320351319345567592350219969803610857287647634746913652499608156950131746040404710541753\\\n        392927889157235880891058530471061276862897768824178211382719738056283245472693102092061119\\\n        917592853238281015600793094741777737017646019964614449316198816060247134819655414308867937\\\n        757283609994036705227076603048512085573858111240933754861150141884241171460971748015599595\\\n        003877539830825340620315874411523372577327854664080278540715866650805028855308234698945336\\\n        656255341291268103580385262654214072501793065341623471704481656090883087619695756097047309\\\n        996228495584815486509956444664891122464352218095327717792811697155956602737819787265622964\\\n        454464429933824256516403439820352777524853990489567475425761237353410835885338292713090103\\\n        902256448536000723136640176063119001148812410424385303737706602260255982046109130252094283\\\n        505737912205596953753566984398946595731081588998791565969702777839497984786078477978629563\\\n        453913077804911010567742112047897557699922270830333766601117956128734300339923192522833411\\\n        977049844959098503364600824305816091868805894604155085874158177190453632101519277998357474\\\n        040801794336186094691775353507907875877415383450255511577449957940456947268049960097035743\\\n        569986212805027571276675351193073394863886378730307732966730843023767467041643825239197726\\\n        202728031264278889275733287206994205364593860664818991502845618257016775995443801818113751\\\n        312643342364223408129120090001373247821715367686443843220229347043549277037013777241431266\\\n        365405608641418970795561150280821080815953430418278780148208222519530524584985545714810617\\\n        899969475504006430884234316693894694854252086406149824815484605921239809564694084898367645\\\n        350416995605934723566975681467252728049734114805518518162627282041728380109295991461001811\\\n        792796504299504396321662138422781459703298685436483519430929869107606915330053270561135015\\\n        200199449329292599686302134707260105649715163050540961735372209516219382072637707878111322\\\n        558032921773765440624952700677936217719716986549062680435802246689969872046547718862130044\\\n        372671756370437393564577282447032678507320246560739644931180502858484183632360281997598713\\\n        231015011703253315472218370200857791580091793516179982048422577878387517475601606934221405\\\n        592579675586982226706023699515794479427175976571633567094860866259106862551186518258689221\\\n        515965811720516354641482892265059096106130144755719163699403966144352642836757091317404185\\\n        767318664184261987775845295736816116350543902133129856810682101402882398169127566380898638\\\n        877061236180335474602070347087953595906270623154591225159972097070319175344771657083186150\\\n        654035685225016364626824617185051541199983814295034540184008384607097224200222874808005186\\\n        787138472028975114619820504296351210332916032377192211595012189806310050758259422555861300\\\n        270595769687568130373238335937168684214832104340690094758921774314166000104411468555856232\\\n        763421938498186121799083110385816311215856496687372766870746740227458466959364530193717718\\\n        917462194092542123711688119110372006481328337841571911548511638699884238623131864919596071\\\n        140447959044118691982406717883039264654407414349241100962577897224857760624559492542318049\\\n        833462518953180451730076321173567624964084314746717021643229159708644339285036294277572711\\\n        819047407114006348125896185844023458646837758031755718396098765058339289711033362465669601\\\n        167202042898850344349494287017202312765300142194206978918737784815087113216722779833208313\\\n        478126457653158859005379502510429197092639648954910190044219438700594779260632017141361245\\\n        432465741902769872839796848384189683761088559896540699375988760461875484242227994316658178\\\n        861886557406566644395739664660133840577449582789404483475806628885362937589806758194323851\\\n        422601423726670283957538501412687244449776551462000241939252922622167816213964158657436163\\\n        040486272385543188407361456711776429988608098779239368396074868786211248594059688233084119\\\n        917781197309620307461437130078764124598689024486757040317774188136620410690259736682519356\\\n        673850989976286983201269401836117273783233148745603159794432959316041177733145123160366644\\\n        120775211830203673853607462124148354289191848458736485488648291548981154739096146169125967\\\n        875921821161702875069766807757002325875440288411567023781484807840250912480453465162728851\\\n        367175433023563944912355507869850051027027408885642127302422846015096772335264381347830775\\\n        098344306007351956768425942567794552549384907902317973547816136418513611278789470816344819\\\n        364272240013517554929759603175418533003149013710032459403180350982090950959641653175855114\\\n        937662712898771150841925685968451706456681020489500774892840866959465564232591744149810197\\\n        905682329185569748540700793090217332199756317623130428261627425849336365628949259465961482\\\n        927159692117842139889148023790021073243779938152586492817958228136404231330295542360201901\\\n        553762160244338417362499158850390358936152282212158210217795780409228106939494474844917056\\\n        331878299547962231112270897403157072192599382523402926463890317313670936708614219895699314\\\n        235847899690949804934372276057013507342513151210217240598122185618345007622797569892770351\\\n        462318316885273406567377480489758766147249412816131762334315543381790664076823806742127703\\\n        316448017583581366831452955807319039901154522094192609202327416877811680836681256340742725\\\n        702293604366964128525422604322112388390738318442537511788396284206959884225549948286603878\\\n        237740518596859768003776637872424092223554655739050833196966907969605727770664279569471015\\\n        224821793073778368277733175750292675406713875079263798714289304580937084457930590196376964\\\n        222793037386011761092884095554486917238405492519115759009220707330756375693160585797344502\\\n        131200382016398541605742930700995092426347180175009460885731839950928728554707867164533289\\\n        922609271976197029362789681815567143257710643811071531868127448029944412168826280870546744\\\n        903565175734976779404439384127055944639123129136636760699783120612451015684427705230116829\\\n        784464871555444183800845357450768553919514371275374590191207392012984868305391235627565711\\\n        584040240688911241600475986876504057813389228654244361765477124312789893282546179445930108\\\n        264437162837527047258828752373234187151851040857539402412744328544872706119547429957061854\\\n        684263555633451692221839807369575289024246978189469252925025219880154065807892137244776036\\\n        423842700980968962759674488551167704631394190150662359127015737111260394696820430581926733\\\n        256318393466113988342289536747485380041716180186349956830377143653022893671292167636165100\\\n        223486497661764900329222014033953856632790699003111180442325786684173287902049458537224690\\\n        521231940709674140088895027563720760296889553262262988281965012043185574196526966810611356\\\n        485600791977222272257273494002928202733688265349456583476301243399737176717688239660879268\\\n        995736248751901378075038988160933076945327182685308278818998953699606363539740071345786945\\\n        704681736811392358117446298614386931464519210203484506910895321421190305852424804889588549\\\n        674830835447968471712119453733644845352205920611552853509094721659058788563289453195895394\\\n        748252143447218922917918649017750312277970595518905252233402597061549421724048654323622993\\\n        216096334952621851349182876800867291081023606339921547021559047318583847178782877434218847\\\n        949623931210855919643553983401089624973746379026710108192628624030351546635592378648321618\\\n        568005638280878942628313379747163030802302300780866082921486458742916647162156551101021356\\\n        187819360466509515331062627356235302027539965833758897718015391340744559154309353188677372\\\n        833574169171838290564081102769051513052371807284659795182713091595097814286521189174606384\\\n        631792118172596855291711480713196728202259370004813177729597801712872337484900407004680237\\\n        904455220423788109698499399216382606493407845668277154204294817536936992932318990381671067\\\n        334155397421651903807414560551293248622759401360833428527870386852409376835906293804114887\\\n        018268506818487349335147567216329862158909746704645905076811500583795578083647691717992660\\\n        603057985340273553902538048975245524786699707019397318421799388851228665902302980107875928\\\n        456766103157058560315059605264029270366438710014485610089781338681219820049553403709659882\\\n        424102288076788642126499206444161387906626235011925305047986363762112769314279208699025482\\\n        351718840191663907436025303855768474961283020530158175628441745059761153397724693954338766\\\n        535644580585058695042789114797257918079657294687686956199093830471127359444178836385796294\\\n        375279045917144647700085248908051998056697404480481424387678822506918939410015485981885634\\\n        277750709941107959533900293613751781618204792072749359859969185750575782120419201263579884\\\n        708930918548266801442486263195567266434392821998238797625179917528708198954852505058588916\\\n        295239612664494779285148849665773042438467880174588252236930776474279960719994231595848400\\\n        497196291783100023559471440152531708350213511753504787976957751666556276476476551327482732\\\n        666027173210346867628710982694247340680508025244279939734854589764374251390320423170232499\\\n        849480989217364403569103231100177899845049941941902263511627264495112613656674464371885254\\\n        342467003193195426054545415270733338754423501536679387657197659454551814449431616325777914\\\n        149474348038118493416204790740917873665456910119905388710211890671068495269518848332825176\\\n        911052015406897806192739671163234961512846274389945203335334992824362124092374459316512435\\\n        913184775996663104000989894830824606985783207455737130764564652333540445890924226428080374\\\n        602513235546093655724652401873720845995304138901496663630801072347457321145695857402692973\\\n        621209309791949897207359410970557419415265771297024299630301562708979094512142654206107472\\\n        759799898233955649980626996801335885898819402776821730204705346310780659580549436195404154\\\n        060174148240622817757214684665517114991546686881304000287082278569397853923649272962223860\\\n        015859091188138226667904535982875824528366384424841932076272025485267982651479440999764422\\\n        015767295818930296659186214987801948949326147726718272643774142448721132350221016939321247\\\n        105951305168483194939941079932087278547502928031174083960751254870741602494852089227734215\\\n        886213321595746380769756649620783977820467821265521235506632321035302789161860832640533901\\\n        198993455369552094683219899775601220559878435939220633732792603806737511936885237073469769\\\n        684125746617059163232415279072526376867720318611405220312221311574916487798398862151803250\\\n        092896259313844879077068325744877833205255276932958627863400937636888428825355543536721290\\\n        302340722360541087832736685010280202944103236679883626704744391074009553954398469956914971\\\n        673341984561041908994273635306724458020293079173480081498307469673250285557197313099250507\\\n        249931761284675625474540465959330843269298116967059857106396612516068964776055432117361858\\\n        256270827071263226914839281894107509879567721066544834485468843563643124658593828649888436\\\n        107587805085526627913555232705004963660697362242047152460679127360883361784660087637250635\\\n        187041682368638741466317571307672119858968742406773180361872163655520831896016019638558539\\\n        292601226268193133075818687605732894232392727648656578585177997546452265376546159208795245\\\n        193260342489413121040172817785066065371959108244328472345023026194615076363397423844874358\\\n        399782748566430033032469720113453618423410065955425820063998893459311349253299742524912078\\\n        903590228535422010334009369696159619009253574159512268496145703389951572421944131103149253\\\n        304664403652253819007274653812671644762783441805884835468517077108145219124162007481679355\\\n        724100806880478872550023577540362276770538334711445994876029526655823679288938127666005098\\\n        049816855337125482214314431536251518385176920174042217250329445342261315427439187491920086\\\n        059387824451758769453704103093470039807606052602094522982290229039200376058485228466301348\\\n        207198723730491274229758591360438878650727836437712543266467251415077831982689603947854276\\\n        509535685374070241842081244911196328258385529392643800155934911760290932501760379552799343\\\n        762412481957830288059594639580312655787403801308481721182542821280156649650920821422186682\\\n        461799571716513620879243834968139124172724543474364662856552268741640065483418511949770107\\\n        408992703343562821272601287426884729719690791069528434065844564874271144060092335928613056\\\n        016485828207962160657559035333586959452232422744935519608371918402030642747706180638648961\\\n        949960146091645561858531083789580565762788161004768595630941035497775209860894080959024799\\\n        473766387163103612118666756906602351629629893710188012702407643885233531382440225187091015\\\n        501488391506482313683297689527419365806484160147178399228842033458594540537799295930824070\\\n        718839628246780787022161611743961500563969417278616700120041803543509095677353332609200816\\\n        863528754301643281053811680845204129709498373534442647817648634143945552463418339562064046\\\n        066957285158198523025022680330812173155812069046160454021487226364929484509374453520888532\\\n        723459371298913236866769111924814033441603085721525028330537101362416089296310100477920580\\\n        694903905554466900528354374662678283841487795483219167589552955198556732559390005340000065\\\n        934508975945835501469419085151832722440370663406992773069261345635476309013283923276491870\\\n        217079671190938621082816446990458523349076496892500161067031010981248051691075464315965692\\\n        566868756422683322827108364707694275257075066925173844085554155751509520402435611316220181\\\n        088342525331092038245809778830174778031951288896869362498020229478087127281658975468931895\\\n        643211092972768588561930172750681755450094849218730209594128573739330740060095524404499681\\\n        236633852266563348251322600679289940899671625890035620485640354802932173086614288648233393\\\n        659514379584415213329893543493795860445093195351016547591597517684249407355553374293857652\\\n        289410120240278277300017399998270500577576177565545131427367222322714157747548790857679103\\\n        080375945956779602741022893285019452239615925328671027145397577072989309659271014091468067\\\n        400187475664428536181061055366412919961362451759859486306589212698915122292846735609249200\\\n        828177140174562688083411364463285526744914800497533867214948971085753286161448342225417743\\\n        575780230174573449149922612971293166120212772165437618439703331978991909659484732063567366\\\n        559611917095717452819241669407212055917110866949373168667767890639569248348937949030442378\\\n        571044533137796131286328318935844225359288801947174330500564297511738794377047336201148470\\\n        512769516567118643091960868612848331421480217901159788120865488767240183878082864974643732\\\n        246200222096733550461352034595627339075344597948856586511591935545814721876603525726867860\\\n        065213732524807652046118864579313656829304259006011793071862595403691225589531818131900372\\\n        931057928638017614518476668949744250670850278123227450121475765493459196554969443599270707\\\n        084335359081511761556995693474118882577325858102915459578823734242769662966256118830631503\\\n        829181879466008912808572875247358984949383675075864175759427595871507935038398908660793500\\\n        203007761085648407996446134924867828147567703630865463755844284505829541887086954692077018\\\n        218159055292876913039320563324564517424713341436242671375367373181067137414220199287426233\\\n        580803044569066320253366490846319161319335301403009540456731803156306144720659642682647874\\\n        660069812180630492879514503342999687545771644365498053426979482556428705248267079690167513\\\n        441509144144131618617805712196583153090407080534113362420310416730802213498324515973022264\\\n        373790527174217338863059530594381390804543544478131768180082356448077709763007029421141119\\\n        338844607693108517476045355991721535040987781506787079076967278596363513147143655593691757\\\n        185450540141982272063506236953563488870351362781757756465036624715666558961869266828788552\\\n        671682860330039796319691921578428699983491524072610358491326508085550464177573950192541846\\\n        303901458069485451535339847511826349492039603140999348754462816910500771871838466538979536\\\n        873667666251980174194425896744286859652647426152078379452305241103819166120549260471034086\\\n        283164835599873512665146813999227393287963166232138672440062455418969459903350715899895475\\\n        915389640427047989744649138719427950500245234301846573418189193575345952179821039411171739\\\n        029469990466364835389189686291453764321336692306313729594174779148504374339989183746243681\\\n        397900835904480908754814315963675129943148349911221875619454425063882679545726737167394534\\\n        086627131597426207576561043366990259052475251612183028907021967725540511049489483889972901\\\n        198799872395060302741583814560472019174019884833115330376992431559647082339281951126697085\\\n        724232748071282739584618665628878360354435456162854044828738621089203202540106778723880992\\\n        790638014979436173533241954807625274107655176220331778441627788902967275062721893175135182\\\n        762766099756629957843900686659898303208965787530408844659221280744064997165334124148471046\\\n        320147667890429570606974785958859911900813306146978312151881988379372571255973425594320123\\\n        199287940302041590527753164999276366961138907061422419975523621994140198944119539334729302\\\n        457484469884519353283361007798303595981804512040598226873689687754069109997977437561889754\\\n        736552353913488246092867595537813069821600506677990535011073151876833901548302445448421088\\\n        023721971347774876130759774341571398733082020735546859723805375846472730949863038494206926\\\n        807068836448828040676977527628323252580466545511726731537237003618616774498731744045666136\\\n        421956273647892820524256915739595719438272772610077630502304170154948778466617937856174054\\\n        968692262232926567014929917892403840642894949723485266411480303172151732573764309001788427\\\n        178999501359700292281393779866553972302206506141330854134288363857600587640372519852706903\\\n        602069307183226508788867472920089819663852986286369007160258347900956319513747168881321181\\\n        833038678376918385203467244407642929586317702145321514469417798094799958356725046384751363\\\n        692651879190774733949165754498890637427420358728770708600946177784372733444631095229909526\\\n        987527819854740124491042255894239831622890985249208587904811524579085765944088735391410000\\\n        059402657158300935972603158553073259581448389153617684735656561454894351663170852644122171\\\n        633069199061477518683151947668920581373622759088790945739731962443896461615605787490188397\\\n        286972657585324416719387836539477567199013504451556898361276883791950085179176446095186356\\\n        971922730002408106767341005087045631433425448437673302288410454327525975331744117364662359\\\n        993527409435500385577956931038084535522191536242211444408051675927431862132981810464259560\\\n        835999737663371352273010779395322730038333361223565723580438758190192977114965592592030411\\\n        547163297654591830516636713771377888458648948454423175270614172165704284619377238044379629\\\n        715495322785666942730612292880726569173672489598019437776266515066095309639595856671534915\\\n        791463046274298554081979343276941501107305537246764631350395244306454173393493617160622414\\\n        033002045262988423833266183258222538733879550081091978094694725506704971097457845946999486\\\n        568830815091314034716070764843418468372119267806947319833418564767610637176800764367577809\\\n        919652232141450579142275079154277924189033563290060045346267048863077296680614536374506345\\\n        595867910859020402491504567641761912685892442918102627588398480394191899575527091809108350\\\n        689451231119495045185174002131707109950541864281833036123980553827622309400415899969287917\\\n        699315057293618493610635645322004748985839410808932598710502679488950141500588567595930837\\\n        067627463671311138232106276609305755914362619581154343804670860157418927634851367271285452\\\n        332059883035085234113990284289977320374509387398529166011565661528512618809959116133589911\\\n        008787651273929010232832551098431815277251072309996913070129799280795648052515809128005020\\\n        506660399820171851864330713758948083591462450594712062782554009609058283935213237065762608\\\n        576603040379875639365401072590284082968566162870106421447994717160512906865811939899977222\\\n        119536548935876525579314337006287749603013626895430185480330639859523163535156815489300389\\\n        765698836747305564938480136702328819302786610867185609574313002417437979283293973440961764\\\n        094141848932553521555596697217385977576930593047223955514190442894515916394524836086697659\\\n        430293033464306182860226463367204504874989100078204750660268370680927627521777254571622844\\\n        712889313775048688631472515715116476258568672349547167304780610782126363603561627459445022\\\n        560312857460284691863974802744205736318336370445795184429791187987216621694030412426213274\\\n        936201982689696705966365302306301775082250323250479994061268042190917553458386792451738387\\\n        433902510009183663943408447736996975945974878456606908656176397089978969778337916404129604\\\n        889092027235586136944876773802791883662401459105907721567940976924386234898693889489426227\\\n        934299234594979750007899146792174232737642526337132808595983167689863202809921497552579775\\\n        152730986090750426326199733681498910127587086183709257767832912354359609309958367117277455\\\n        727626452984091272545431859566855572622921043160901560811015356095111091648046504583697210\\\n        753803098389601186763079256854050900376407952995757866199573224249557489195180190104801811\\\n        722285328366843279223892671409420503840109169153994025605883234564740211858958956996891847\\\n        869298563653047850577899228396309583463327768832678069788481326160755144167976731907650752\\\n        180794562970382621314611284740041338799277942560752801823205918555864926271600808517046740\\\n        150391568420379982890663541842723839065453884739618322060616180338487816438826668798524035\\\n        352720048057069417796868308091287322336025317924562202954093865056407231309740326585538117\\\n        590546874367342264783089665318824227208552535330671389155348645745117815063283442264138948\\\n        952863424881004349229375447462677482427298382700091195887346567899225451008307329578211218\\\n        494164987845852734199966543947799461083400531473863834659027123319469911494842740200758648\\\n        692741711354722177468765157470966302093677777731555752192891365992044849435581210315262353\\\n        476536633517136687072881433785091752350407696750734163560780993683196654684075894097188635\\\n        337495089434274737968182011586884477054608614011908969775828000062409248887489146852275585\\\n        871826138307050142074209656989838599528974631257579539992829028502798839657800633339563672\\\n        111731693014523214662992984259025178829044519782053972699787510946453908318005401639609124\\\n        057307632540007790044241587691655857532644821181506088188666410443256937227532592273094158\\\n        788687521785579003768798212750805010725185377752575033260725288311602831217360565192226629\\\n        085908606605944320301027378370637242356624425885798497172462089377201790118387859733419400\\\n        470221941023040204645496810559847854946692973781289921551104685950217982880548417556681015\\\n        445702668838714994987010164642267114652782039292649741143205681604160756447223587780077456\\\n        305888708412515609125902137794056817289516048950918755459717095912075582062409512571408407\\\n        842525407884415987162334441088187883149916854334935508874378290007653788433593579185140427\\\n        326614287994536581955052087268601781428725065667132112100533957538728884683144846071141377\\\n        605915558524464900792906139219369202106444105457825245581518145643063400167908227089997880\\\n        764579410546744196734457670041176753196728678797927019349503785889382720239313272575726848\\\n        020449980451802540282651400894051856357239453978339814523272753878753470679900290038598697\\\n        346180360277318789379993245552467159018565321744550816971650123351650262808361280162583405\\\n        892947035320658980513354612372113009504844327220377635473138245956977687580972271355056714\\\n        474833352591582220317255775140558150665349501231695473779784672480698290150550245148263667\\\n        610178795512319215619494655809404326049033556828205960779780571799217196591053227582275732\\\n        016505473460905931288517838977169234443635386290665179792920497442850390650604336184541919\\\n        983081927210479563606124173396033347258382275981301309455193743479935603276665895899382497\\\n        888220343241862582533567611656777638331573470578420880097928528023744505919053502324205218\\\n        528184977869517591554886937285099720642128357783996441509810559802289367023337699532122592\\\n        934832939093439893042567562500174527724324962181821628829530193876616979432371936448977416\\\n        698493572835040020424505394770950247412656244231530232599786059314693899267682684556620912\\\n        788550070092238513517116173295232445924369260395303869878166487410844256456161835217607723\\\n        338868431238234631545039931830111555045499315792477495489359307100035027773825106369389762\\\n        395641528416413226769003879512982215289296190362709393094857396480364558962826074785328608\\\n        153341394346265149499439216980447807526169787079022938756630430265769209162924379814986509\\\n        369976820790628233298996602606118845016959642101602782580296095139759725601646666340334886\\\n        248112042308481921331196377110074445428096091390616144858331576170239237943302516653539461\\\n        385081994567695236140683313533516012649893851571173938200774775158047812840363023573247176\\\n        701509815231135667794386234070439335252118574309198115331339389907674570375088937573694772\\\n        931496474717490052352139070177886174238745497270726062583736263833577567820881515652007585\\\n        649746917560797504027604860145414005966434182128141755606141195404578563850392558340191310\\\n        791798373360041841605270639087926117538503938253131600842868349528155592080408542118977424\\\n        687620985237771303779118739640102916726070136702760448931473825094046794219501439465349621\\\n        236368675904205131710455509715936512449513468090284826215983350671926333606862462802848340\\\n        980557260940008064387177758359569588682106673842478703239432359624641413837671298092279245\\\n        991094479604890936783548162263448665550698242326744740484761332762084928700600890379842281\\\n        983101197599977103116887905597233538604541388720360765510805183368669201338499298744456830\\\n        606335035205850147391459989008977587994807984962676501277796159152934501102587866906515740\\\n        192794181184433591900356044446130251275609883149633016104371833002034678904776216115988005\\\n        186238938477143820443533370911683968020739568578357796457680211552691054986648254464288361\\\n        484950700169920838640652540317603835673701817615064521745975331871447346804174274856153605\\\n        601766372694474179649548278109254734621699981812599093457021010349719747799104423047701019\\\n        230970140004705732474287013956337177840109395896901518324482666103388837563694876307113875\\\n        911164282286480991761426078675532009560065186177168990526705559896118391467868177371774686\\\n        585699599116102026653262875887180814608209892942049893327077807055645101091212570986903662\\\n        644192382241884787771384718780091163839002154843097414377746584447646671104512224830763683\\\n        484032281026174852092423747146373001751725793955708924337577776734543329727595007417900682\\\n        826377921002892679190396378283673332762550337441697536580963323099005745505842518197138816\\\n        512868451964589177543379337810159824428924085644434512388836438175928036280648421674279253\\\n        686486680368609963051196713660674415729221764786051794755831214879515200295844477975993300\\\n        693868893584821737750815855622311825710636936864346796401513342299403196395036536984733764\\\n        782721813103268670623375558950108024382692150946450686870435857791085010055599526359873423\\\n        569212629042132850820500109224629530274796682518655597490242090403452297494595791693974113\\\n        379348197854019911256205643152606344239633239099744866996626604843987602576159228363929733\\\n        362397102657798463663781665183976723226773288951496528761072778901915022876846405672919340\\\n        247620887930253788171102063291705679081199203305809010430688174873745182618705183532562367\\\n        032976616839039529680325872272007946606687093897948360814636773581520039494228217720710281\\\n        102464203692667747088279863151100088924419925307763930519347796305406973289565566185428166\\\n        307813891828546746558257993303210277436461042301091534234347845580270062859554804362992900\\\n        730467134883542972837979683969699520077211755023125679756092164443443471932566164976641876\\\n        717614541569666937552772637154519096652647597977716681293415794504997600507677243463042187\\\n        960293929949649992417643791605352102931998909248565791448314301048482774913734268895977015\\\n        162540710233604895787698371050517560598342151869264264205911166450912386048156991306238275\\\n        918867766559410065691471606138495805569745809950126488384851114367108203056713025386481857\\\n        162345716605532117330689615144211182560946883159251204262970054727177431691186876012428740\\\n        551902718584297808365847286186926870643273302955283044088845752649406197070336790598880793\\\n        513091779217993078347164762359935076148598538140504388209120736112925975058409206962456558\\\n        460705868012827871569483698462643323145552758906632518343021499630398774979696718522496868\\\n        913538333334834922789716828143928773171008634765834120593914685453446439165845794329914363\\\n        231075292318230729845913956177350763031071212664808708939557902954273654854520255804805446\\\n        145826289583153766205699394128720751644590222457851624910825071750782647531322714808490345\\\n        324634028062193793688705695184284874460297095281030772986248035642302857156713512939731234\\\n        165770030888439043852059656839038409614947187026562983371653976936192718745607466152745963\\\n        486330238109649627204662959772890411611977954337865055752413257992966165743743856365740809\\\n        450683490547798575525191432401752009317661559977862484321456338585737477634695872655378109\\\n        308174878655559288308831076960574737426923595968969875170329712215459850137817436810740126\\\n        097733416347453672631442260324520176170008805386709598705478888485547706827024051665672268\\\n        606836531782317320993428745449646930303988263027237227685809853101507060475065900625423552\\\n        851314099181982298698752523919104451233517610932062329761639009446353024162627242656832122\\\n        452997275238022594828760780711104750478137379257135912926608502873702987211665942279731879\\\n        300624173509613662971732264338704392679915273181066461559011968792793606804354973859884321\\\n        718830885502151877151235689230643304103559784082888772420886423411974160282439140639905075\\\n        028265850252264316906899951059958763102299062684811606847665718710584954869261684654888067\\\n        290118904250942332549654620706896517278005099850348426287069573719231651085778808993150712\\\n        838639738810256291633432879274399622830837522084165453212284689484590348754695891155237801\\\n        431581227907572335091525448109561734988008805835136165902772205957516830251343949601461356\\\n        879012784151319641402234809051977711760993156412508329317471749629729978660152159586918665\\\n        249632993457467782222373555215436991275435289204522563623333681552999554914484179957879224\\\n        193570002165996051280426808665161429854554056673729580724672577948541155662250725502715137\\\n        092141107785980968150174517862693370038972602891836063328482549070558098937412688447860298\\\n        882094376933157413064008393819038391402958569559934579551069803795298483546622283833310595\\\n        074523185895328334537788396181946262106917573910453713961258512966067196620386982098907311\\\n        683406649454388665497734154880171228905516230186465345424620536511202068603412298787935360\\\n        481312154430536746054023041759258311975821898625075366595358388652689488853225190389588150\\\n        172260857040013875900108620209600612644035536201021649311962270404475461263764567763822060\\\n        761617732699889556224722138294839130885378844903269869167190958384130030288786428514390921\\\n        857806026888303114899215963277069696584798918451448198542291880209045565274556866960421575\\\n        420959533534863362881206349005135126182109194805724736862327058182939734054136045166717802\\\n        482683307488856191342807542756560816880508547792478484944883170356265712660011736972783771\\\n        027381558272148659664080671596113709958307581604728701727108452053335183122892757450734579\\\n        849274465369349599805704910234656178252474834158530611026683851691516425967429503947888962\\\n        690317119305570709054504036647670676578858833295390594704882885499482205011080063150543075\\\n        627492400186619039324456703630740112441697494180592823313185522127104236785182794511674444\\\n        245558506587269815343875440170309038983313293999158936471103529842170860408396219529578208\\\n        148628503336915069476444936196011612196180547661827092249195039058791665845960519114127391\\\n        780626023598032514393531019051710964589054855005525009483643494835224185799069643568927006\\\n        630410422987197967789682129614025095540684486672692863049874938380065114074834837496869148\\\n        635205166027348360129334001566112355912395835023001854179690508866516296480869824328303263\\\n        430526071642221209026129740473602380609149360580633248191723260151090556048249333056490127\\\n        085992238193826070413557946631651081198370479607945838534640832995584909219269405704129872\\\n        407470944542125145446255376179284682448861747126108200719719250079882150391423191586095544\\\n        825155756179207828386871060405223093962993793113002088739524824192007967782509213367608924\\\n        576810074723920509908730977307829694888627889628964207834979132780438926251247999106007617\\\n        023000544096289620749113399844274540425019240605666218584400150992274157591002065998652891\\\n        022149024855020895040464997791739306714394459461585402754053583338142772467378310848667176\\\n        303475893285343245283852333781707843500218559341348171775098740171714530748924859931460466\\\n        082506134638696962988473514721989551146001678237378729472499995342497706086975585960106070\\\n        117871268594996686959072727620193586315844585293466196350954780823434367832245212619315171\\\n        587215963561782615633763190779867568879440267138541653821336191348938612724418148045239660\\\n        975581410186826880178327509320171068879698434661001270282050613422119873796085786786403688\\\n        844152717542309289267375873539700749937918968564932832108955660912779115510762448433027441\\\n        062874905442552469363705406303025789454934830864654813203119408537101874382353213570139115\\\n        868453707933384290454985147598505795844646669481521890055050891359479504364284585346178395\\\n        971868455538460423455093563968428869276315733108184545177912090717917235385949807479854486\\\n        328386512127662217975362304105199974019471390340626647481243770355604620414107220793123307\\\n        514058504337090262469078031223794765607491772491482996578497418415188840001509057313814740\\\n        052310046759520993412760037938873009538374969672314637701021205585859630052554935790035237\\\n        831739355596689695727659887206190881772302907889692660032904787501324843549763599575918989\\\n        281682876379759290887090212571553314552732643759004935581060225405765456129543341672771690\\\n        929025167365530624852774400554961656682164100246290130575074796581943463455720801817814579\\\n        076067542793324095060466005021766594770302847395815926460394928059269137644952298441829427\\\n        599309123814540071935155907836201452666726301436039279323486811400401146513980163665919798\\\n        759947456702418038108151266877657636257879439016182952744519188891438270707276801528437007\\\n        863022825319600160617855624611011904352555616654053911482531219538889233960572157418634939\\\n        316531937921899566654002568591565637727902306988301614579187008312750368130338978562829926\\\n        435072758551479071304664692898382139544419789786215456946841771883518832360525068968211047\\\n        008469781850628793085478344567942163190855768743369282131088089178692923369954141221536431\\\n        873950379525593486276493067911381602061014819030336301361902055033788012781442594020494547\\\n        716546699730482585617167998867029521471133210446775106737377691239966347587214957492812254\\\n        720191664525002383073723669041224611163045569434788589832281407349982456229749968621508009\\\n        842893929472631562485203683418817728060454979631655294326926863205147176311446141862163653\\\n        921604881934470022371687060600860202488467633651046555060988942396251829481468700848849731\\\n        252127938056123721889746059755918250037593717201302964589533704929263264202302086633819848\\\n        033139658088261114579590195049007340970766116080338013449422621561450806024191504522724173\\\n        563174679770717062466205705769305302157901595416749090693422769001468224698946594006653981\\\n        188938743723751274677028793274329953593894413439390544933116631315117119299278492171884298\\\n        458567677340032008113886409848791347018597687550979758296121038270767356293675504635134271\\\n        922487732023154321266704055924317174195181017043609745619057001709591082824338989268115925\\\n        077950231219824603493786160675546280948546755381848008550988710119781518871248479967010975\\\n        268731646138428154066846318680101716035450649576417892196110358598683497366017894279659635\\\n        452399924697891207895292481816148047882537626893363192290655082005435214690943521103098574\\\n        076110364161126010469863904772696652403594612726107178382938380948069888730560156199704883\\\n        029269607832423061226913612128298923719076535716456242587568418064276122348411910051243247\\\n        420167085819458743016088250440157302364293875455661092628699583810036973758695825066867577\\\n        966014531223781048502189859959483390861432076717703126781750469184346765844695616576124315\\\n        812826857625214022239362146747519339149362275017419471632498620282114711668222910069437271\\\n        204576381919156995504491738817651344661406544050266494269944197888677890479767864008356955\\\n        154394853022168122400100149669252143847338226364386927633503063926119042854724209873156127\\\n        870225916521693672291991337207056041332802137352643062942093239532971316019912693352790514\\\n        425176800198683550231761596897005173644574495482723909146518026595516052924845374862414388\\\n        485950661635448516552004632212751096168862562667173083517589720808538959495736728372102926\\\n        362041965867418195366870489159254230320416767872117439770571533738518873830296159918627098\\\n        908015179450681200490105788048553215453986507703635234905787586953412871964903488137627534\\\n        425516776913284017747496806498224263915846561298042490768275958852007702647892167153701993\\\n        693785396548163681147515567090821669359842498549209314183501416261446689874787938645967867\\\n        992141172375826397097703859053397778449720944424390862490871823881247594242551919872587439\\\n        479097558081533416045655891626093994452564898698376851763931367742252259259534527613093129\\\n        774449791015294571462959816821523662497500700025830458617409593547393240934761030051738332\\\n        575379102134508425576739655442774096118013056562004104177221155181462495045422344245464452\\\n        976318611043204664463765288716221014459974539882011563564956851909170309320675351964852847\\\n        695446326411299298660891453950549528229545038936336852892858700337507878061949391321580651\\\n        859040613605243040100014667182669049147569541460834475799352725047243844582859676781689838\\\n        594527803257326593097127739703345432460492479172823308183140814632581110537693044312663826\\\n        173732959777287880373781460755229479412656933226930666373207438091771952430407786209933424\\\n        417786862665064302901050906305875356445533452186001823355784923062261111774833686903641177\\\n        683407282489308281604159740064057224540919099599681721699475177004971117992864883354720354\\\n        214781205077558801041344739998570229624914116588220115062894161459706595727451085896528631\\\n        735790859973333244943816194907757022908602907755845920315340273244601286770758024645759555\\\n        345568997495378437192132259351672578844858221431084219802397517462610841126027538467720244\\\n        507927953068396522131413774152049242470402744267914348837752077369738537608634309660209488\\\n        328121007418395529017750358170373261154035307701397425423473820867591499984714827283760600\\\n        666495087746445902089517781864562717109933183412223033314061996144585084061361358371016892\\\n        028799151575353743224552208836962379568330167476302517162918084931888966027129145276996851\\\n        475176890263397384270906504398297198225297843858802218245533513787386064994499434104543146\\\n        316101587133963070492102298429897156151923992592146728334129149532223302206185120718534125\\\n        929182570032147203806634112864861502104823508044634198576110371455671414571818742918694743\\\n        658669175091653061739503805717024450039626387496184401725541610858371822080472358145749945\\\n        485413405885720530335185323796842003818041459058560414512854327543650996382103926766995074\\\n        192126090239611389838900043187277403263788688716205198782180904492184580938177392665698415\\\n        541349832219381600213912833007396403549284696893304672408568245063898675692581126120695425\\\n        553090524095616555500448989388230340693194368206176558793796414488788370114186923056838681\\\n        237697802215961853216288520542778112205390855829478063609048393754146736251113813040905583\\\n        231919164748789628532967746699549604133129993446583180704997946075573481560592670574223556\\\n        416497774715819577458074177819193699597245457100158288245256029659702833062181140991825751\\\n        750688905323733018424448789668225305374035911176157497060829544743566680219671037570243489\\\n        335023685973584058996670590149052943224489224388627006085948811019993558103403499743971295\\\n        973371184847956332499348933995761469708669204770577357858297275034462725883460084931238210\\\n        073957312295348377814407735944498933247996601395883608409801225945175432162457503545046013\\\n        737701497174451652245395343592146259625178011731023736862162192744097403055564095394474165\\\n        695643208785988103171941367526283545068168722749567165191567485252222886427266207126421258\\\n        295459242227682848114482209358176580089968010135656720868279250888695257128906696807636525\\\n        356344823348611549711432116332033805430821232530143179688130640376479620530610890524237904\\\n        470860345176145754398249366352404672164235863667821353370435739949100401924110749989482218\\\n        077814129173977710096953855015229106993826632448245147255021836110130706862931227650535627\\\n        669303186750078291579007340330843483812559386616626036769020840836681328594160768566234415\\\n        979511172891435002551075017374602029527218132441725153964135752767159951368651001219445624\\\n        885541006684838861457060967898151752614094517189601457525714937474336712652716556722018850\\\n        799494575952134166495271322253096986998039053569203038000302285844776434726795295755884592\\\n        175795181725481588974475165201681881886449017660343687002183825067910119207259453250121338\\\n        788485162855673425569963589107464639146610411839037064436739895418333832602509403881353676\\\n        543966482257449010761408860999461395181565054512024420198142005766197578034415984838227426\\\n        272191603185482990859551012479152161147475534376584467792961231489531270970619696292609415\\\n        279646345111640998487249405751630892834046429783426035811935209882036044470498553313347095\\\n        452835527267344405520013109116290289305435006561641999876269918976079070599817632243354413\\\n        304735133406414643639112327483197682589207255396859949826721084297805410815400980452954514\\\n        004182808062352138860491938258922035280453872374938488045014783630587770473141428222052524\\\n        683839000795336468214681516406643938642203696353778799532131380855190321259055402501886845\\\n        626537170979942159794436137924510377651326191626736962235872296378219677534217455828444328\\\n        996443207185031807339787734697747429630566903559719525837267261199430303382581638639453771\\\n        148614344350777850198750599082903748501978340037445919638170977030428464970584132555141844\\\n        009960816651929630402188101601030351001979263183836943746039205146079168076692960348968716\\\n        556910020536223036369529705253354044310367875905386643962491988007422206753402978846435173\\\n        305284033539641865046557206325474545051371259295032929933671010765158681058172410721673090\\\n        672433857794893381330721655274255295286908979681945412864056019721478152758816457592925622\\\n        412748428692251091144119826417569787967930044850922110060998496038000923193006259791052747\\\n        483526622636681831012497423010784265629720314837094391287737752916531071612655628170565744\\\n        007667369318062038387634654609245819819758791214758610103901831186539819131566583511300093\\\n        365322777794535743672706471695270781807582122790704237992673589907870794469881066289431513\\\n        282419589926868237376360818623973230684166114695122209599935258903021811299579870833173524\\\n        766051310531746984300676972053719285706969151205310332602041988415698883122614071596981827\\\n        641059855904683605800615396148229310614003295274169893025413008072901434048390000751610485\\\n        347031683615631478275958132578379273356360065562146438006674408391234930805096831841270118\\\n        922123582949859730380867862507518758502541859958584625864577909354902622742823701103331389\\\n        901935568326710895937825453156529656084337279961566843195119157480511275063573241397960328\\\n        037685481245690392805498781161263288670954746174222583991459063586043624125346014731193125\\\n        071477656793789643820169080743766892533538085121685024189030596055277630263879498426530766\\\n        078117599008019244311388594634655347023686938223660032858717458170340764184958839308401069\\\n        864879577404532972752947557266972577339598261573405921789496413906452534922293247500094530\\\n        171013323308787444597522738192272790383196195613722550718117493824383458124953066947751422\\\n        307718299777577392602432553464311254460258141016122492820970147940096208468139440066516920\\\n        913798551523986120275039236377217952331582577421276165153656436655938106428557602680976119\\\n        777951587770746207717020663003247538097102469822656852884936065848402095280932750505184867\\\n        534330644716450089437642657506893909349238722574358190808502635784787668880429083542389040\\\n        279077476227644544279006695927342980532797489309672846051760305515108552353684714416947295\\\n        163222397965046671664525202917101152901910499426312782096079799561319434987230655024932523\\\n        135811891376119312579081790376866878248928718792766946336533403557012605238546406497266158\\\n        046243949658093522888704855386863058098770006319015389051104743462332823686713869390596621\\\n        199381115995186646881505385508065894036267930781148173218385597430428822713367268162788244\\\n        858427706912137569308569869364680755661378950250870802044574375165895112215876276153250142\\\n        166013115451800474541463345271647185551602913132642317520173460819175741335135519578205615\\\n        460075858497568539969179814040109931038887152787872142494556565152835199911264175940892243\\\n        220390078109614126867108015827837616282417380612954423209413599822768974758705885981458683\\\n        826589735031189343813380730115576806486116101776751834664856479657300084965613961331248603\\\n        147178954287858132330463190384285745342038461762991600960624349587714104861534129568597706\\\n        360120093557093063799939985779440693859493263629611383132312039496850428064618987711633447\\\n        720468985923062841399667899898998150721978033854517642288655309351549277662323687682584355\\\n        692664926849560867290953833315833043164559025141184816628333024740003221491050790695398568\\\n        910374332151592420856373609083102345712186678093537086967168765409413934488876243711896849\\\n        726163792812806548391318035593769002895535087400465875441645137360915059009456475754660563\\\n        520943202244500881036158025313014932450477614930380619549500825953293908440041325880363330\\\n        899340355751093765416869130206901644637425742621045956915425430388598869494290463604129897\\\n        891993055304458371203367430058686384071373688201625671562360808950375490340469279513387469\\\n        527106842170559290957090572898876150897330303580228443108713143241357528325916533849863552\\\n        638456814950487771555103781460558368594336447265887655251654050375650715515903059142570842\\\n        234191181337325319630868136301013686994332170281891156875329912149449815678541192993424847\\\n        577094528976486348360107169509149654587950683733175831681704326453529775390777219018423343\\\n        831168630589760167008500049298872422246792000407420715722010445802199023352131285736367708\\\n        552124636460784653497845190446634294598710251343307402925371519647031805101107785299914324\\\n        590085984791679938267171205183616034951758243628755885347484751421922490477593231820046695\\\n        519321820245775482284288209463863827037654385454073338061700618308269613984189706720072207\\\n        325104920720460601129862576850766088736856596564215961241445366571126964805792116067341113\\\n        064325293483777421550180569017315139616521469964589097898086073939216301053696805723115881\\\n        648755536675670997645432290626585084866025999347609040019764696666174052931284747909883647\\\n        321120651824862606541346384892132388262632770606323287829308709496712345760007124724739430\\\n        580227486064095867771913147147937939915209094286450521256728962813211223882173427608261122\\\n        157362019699531753034638712596286657058348328674019692853676593119547279269108142774585239\\\n        547155186127169724247289015487017541726484110595007681206014549698790854745986069910513815\\\n        961061682288767545842856522772431274274498947591581579305977207701253637679663721178075327\\\n        963034844049391995404024846030857969665458004548614290255919057709967279435588130978222994\\\n        086050462683601595605854027747751769354538119442079009093969153160525252744136363075002826\\\n        031500647797330965683998886464739705057783080643697229304920334674739403896818798306397961\\\n        657125138280115463000539828734113200127084541554482133130148478193143261531216516036641857\\\n        421698043534354845020742311506936266178474318235849254439675980347573176547054549456384310\\\n        089711903680888610260484825541360252456272638975163357757814888151479743991288430952897681\\\n        561610508940614979589853304896732493225375665055990810322225924587448644295732561935411625\\\n        017153855718270968724375219067036610213034361239093643092873346185274407193098289872647572\\\n        436494654242270989347272157977573655991818146587536699662762912502103010236494399231545699\\\n        280725783279384517246168433254231485589722111886507644207977294316996512285619624917341176\\\n        917688455959073995346759241499441844177955629188461392672839987987638929685737985302555016\\\n        121587668136307253542909158794763581262163628564489656699113107400185004523338882232406330\\\n        419261847122328670257695521440098489877269941055951927880233259834769589162196150977525049\\\n        531323881289990979504779934936809956723051121125765761028496301124902020050478252875786674\\\n        819711641027879975627271115867313649552246953264975466477108635588673900481465929912450850\\\n        733175003227830557194691910181483433314340157917429404624395749207721659474220782762265794\\\n        262695392731012332334508297176613634975425188780038956845083278814415945243097738513427704\\\n        376725169876323368190729649994219495720917864531816829814055507529067625370695552708452431\\\n        196900060689272272343455833975210925441632590990968732381473624082861780225322388366997391\\\n        937131821972265520129432080300614758690426191043744282117461526507912953171169584934549527\\\n        416378354883720098146891262416424018970021323534785480612648528925075678916705764381465285\\\n        034080358781387961631433874758771234420709353505222839363871284015129117772235986286241265\\\n        190593844986101875260945212434971501605159212450523299590521548623890060441536446887105676\\\n        350090884857094296523870564291882002490580617355565941788539332408961735987145703505003829\\\n        160268208327935476338293000243735595128712266322904342161105693447728476524456342256880077\\\n        233272407199754845090499689492438713080737386639440538189336763961914618326757158314264504\\\n        015575608037761440993316469419708224237773803467806790313582799242213257729257011910619624\\\n        466358633225583017841045772135266446836699906618851403351798132426384443746514409023807876\\\n        319007188814972532056877928304367133337095755010713715095580773050539234388823651595429367\\\n        787241236643132798468644556935655249861487988987791661406607998137716153021333084641324771\\\n        075755195629795702877191290303689723550431973504384454659354913631429654341018765667201759\\\n        319511095750882463855132890493096596076427922547499630226868078393056414466967450077052245\\\n        480496350912093525997007110010124739417653507375194997671425343762233513927618902872556000\\\n        502795073561532567817707118179806220616798170476830058795594114246752667737465276823651255\\\n        673106463868517277858117558800926684006089892777552790975508871058627703082041869082090197\\\n        043470623116425975325475968976648706686888571777551764845088630114986028864500650697450588\\\n        112303426383367022491269218554081991330762868400350331712811358972087710671685372411920481\\\n        087601935801299718870100291113277060469458594720307237373847202760298266658154800147449343\\\n        089227829623947652987721507825481424100168282517489166123187007283229950763867796006046584\\\n        138563335530846649105057292986501407253731234466401597737397644218641646559972639855512867\\\n        738408212827607885762384856025080905633403570317297078155197387091950956827401723433765414\\\n        673390477118506265749544366214261170963005210598733196493884102447440440972680344908385338\\\n        048938667256415905708687898934906718636461458976383047087228921594389647606590566056590840\\\n        213951883463853124507792962443257447240270686175761151147139717909108559009255902464661894\\\n        546721764710459762092471629777391539773328534285075523690831146363658306589953336463502991\\\n        052267127395336149634149287984090218623314691197882348150953548117003299264370874968068300\\\n        189380540091998015422994912991534331262660053264597544675742386498900098511639578942584849\\\n        830354923956201947240611024504061612125451071553866723517518932179466904639689541003705073\\\n        483113421196547991946831692948192878978619333304504879711534498072439368999088798651847739\\\n        956819857778671614290588093999766936039840059931931777889618943316962530843437111703024808\\\n        485087038147104103073955423374621371974767861779635290330404107109664859511430175497632936\\\n        085704199635887562879516603579503699630085090952398715139197494307685895400215798576596735\\\n        879710047022218027882263173014062145680436349948433124438256086535174971802771529557225199\\\n        390735644899274265286739747554947400084393137091162007156885508157507221432047909114371384\\\n        167383888844913670052944634224355600344015283552675216595393930535669076621409163144223422\\\n        905985276553580823095479630779900166260940267372313457134300670116936500145335122600102019\\\n        951940334389856308938260578444697798521323175119690869533540886504343902796924041398246993\\\n        993911573651108488589990499630101912512836748950577961438556407982974653427018012251300936\\\n        034021007148218161405528886776098548803171786435773304640051732246363998099545537098445290\\\n        176149252405892226082982930761265353276521106872394295299022442688984513421155365962474378\\\n        189742478476756175383649979558994759435061359758989557847853148352359597721419966447172137\\\n        734186057635329997633264014357471639672241188235204546902923516450555257855727259189367337\\\n        251988546755828846255599969145167383507644174763694038943689203054871921659307637015356321\\\n        638866838815103804626040588224355348774952861541030586209462804841259483874550588312919455\\\n        019944264840236027770154061248819549191262540898461854909964761068151816129628500971303120\\\n        516410339802418073507689232036758314090432894440784416298162865884588948321231369875552823\\\n        592702905203372408215128197147676558818884968329984001279062978887506011686578436488497368\\\n        984323079193659754473851672022757467068122462280605064359953227379235873793267223656982934\\\n        812022002808568725987084797691533655959132894301873323519082426985609952116256670518574518\\\n        672143466007050144009661938429756469546236190883577365009748891306035138528631683002952615\\\n        378634964813460447123349581248378212911329091068863109661726482569910163950901424134428871\\\n        358609759870117973525860392106481135736725190422944270352902244822902524986465442286976067\\\n        089247669112212745069255440145980445971627097976959859532203571609816634759925150660144530\\\n        095650413580155229511229547955308148984689930376967858395338509623791805871524221553105354\\\n        282094310187164650809505271550042661197428042936823381598523850772479684341262401623317874\\\n        823886813664314264815142119492767593588998600027792159430011104925533834328125543127086536\\\n        649017169225211849327094904032268654426756215223527903175635042693425091812955327101502655\\\n        844669764169670271733615532715112167389374167771242006904075286965185145282204504615556037\\\n        461950379484353238586031432716605488045652854541100767790766835825985561501178539619337787\\\n        540482523609795661084948320482198204803235096656995130047294523418658379311984119417024700\\\n        758081859594763755001017955572186722702885578654732141152456399612774985197438304112942642\\\n        969222944920198822115150455117330844618978279810642866837852153045219616747591204847089248\\\n        472219668634419101005715728310979620178265494909136823377019427382761449215407402832697047\\\n        577494416587552934944680455122672591431440485460806144469186911441001300430013781653272156\\\n        403336480692353029432596844093432003138148363394479542371337216510420778433713555616306554\\\n        615831678876861750988377643459622566149113754422794057391876195328426340026014691663552189\\\n        374045658676707639569847756485441627044722850950202574164091659040442501672628635893519935\\\n        139751535954484772610951127683871489137580421031350745300187151347020347211731578984411384\\\n        741152152326466671405099781251157602372100123878527064014889151055821318617336607548523641\\\n        474188524945681286985919789369913410906992811578265526641195063605341708929454742345884334\\\n        011471295016121012210097524442368090257425682611255159404758133278816998404466974862135631\\\n        014390622944536146483507703702385338337429240632925557378229401278233925167541191181601009\\\n        922688200651666491972850716160564416348308044472202429024684586884075884430252511912621853\\\n        386545062311838026323629437578614534322984329183868494179634294378550698068576735430539232\\\n        938681972108583318529404670804445627301275065194645216673780743921951378831072085781850247\\\n        304020541110736116181512315693034469313684433919767005193076541133238865975408962070671910\\\n        900453014496065053335074005707955496616470327043816211776380379438581221813928878373830617\\\n        791780586136341161876246630610588516734661454738789860246128131088588859762467453578033326\\\n        975853848615211532541322143267544205223875517227460454280701060997227736538950580289755301\\\n        437837497823640409566027106832142489435773927334221937062446992728011486159032729527074659\\\n        109872981093033500915806942421926967441275733465235159221086576777516519166362056392228701\\\n        088426081672823944005569226267096095238938925739420115228324203930445051829866594377730779\\\n        273204002804923562987643146553683579921297776788494644961346461656713144556150013870487251\\\n        043400758883010454756618012171703013307393162342056442116421111669179293699934294135797736\\\n        419459649542603297670602902369319023600007483682412873760689678959579762907951291256240792\\\n        342350295237594030242017669608167707650267510320221816711468178252369054422888338723298613\\\n        450309178189880396666586101835438578209507629723737131716554961199176857508703027566503278\\\n        632508740464011046190288428441969718960628616031277888170620180121327810413131966111718005\\\n        621919775027070709886695644087273023769634612634495310169111950549400281153819488786801552\\\n        630698768590227845493756360536166227980966532199913456013004095995584043957156420232928133\\\n        543608458900744187503683867742599036552871734427549936969172663680816043200373974249458602\\\n        616932373469190947419542222405546707073904041118054559147928399601322635801735290000776617\\\n        884435194130409460539399561226456723500638918753316654684017913603918936529834737049811609\\\n        798275285393537195319760473521523756472747322685903713666463496246358303844599745553160562\\\n        957161259905560115762013668262847358362230399411843389803387847467490190268626007193709779\\\n        947992528296031186454963899610609758596395324370400965724499008036449024369131585247156170\\\n        207282146831098888943689079672705970230519770239884907029315800965811911994903653087832605\\\n        561358772113102642697384297310514533752365354696613331923691612691074871047367695756268941\\\n        129609997289054049608534181347902726995238450254094858459698709706466811172601904823531593\\\n        426269925743859939475931826527897706432638178314962033746537817552211717804152495081634492\\\n        277822147186898339320367648912624268840449729059665059504371599896869824968790641701465972\\\n        971183733602518019579807544844630666044149510874748527889274901571319543698660738390158411\\\n        239959123260819911493405368576093265202694959767195528323044569231967470504928905889129731\\\n        735957224904000544254064001448549323571034176606834591177354417602919886055545625432291273\\\n        908581909505579451783115994193603417508956446073617415336674091881763757969421469165183250\\\n        563806240102374027688005150621536598723077190192524995743454421975969781921412000479604785\\\n        601189348878884860658971736998739432448428964338759312242184892632202524103381953976430586\\\n        066934044455229045280008116097846818721054317021562420986034176264834701703584769690393393\\\n        696772813648550930766774858497947662533789634911644361261251866768605430297230571360827644\\\n        751218358355602172010490419979379637685366976799534782071795713108206823429992068619854769\\\n        742119462469267793952008321309087133234683460919101676422711086803262843078005952247607853\\\n        945022459040212414390928199333185591463713863301435244089804550547191718363853540584613704\\\n        047407249775797606979551673065028723843153505471183571567158933007551803999445243174931017\\\n        763183250498735487057003363601411147996843858015793714220492514712853948719920234416124335\\\n        572261823748419550048830168163002623025040003490572879955413031925734938707353651020000368\\\n        493268676837679059214491272479048237833184189000670354879586428085166218823625624567198306\\\n        017266244977667514530773235399918986045730774411709312301129121324483681922939098009004783\\\n        742205002897648776655450372683157742768592913052135891612339973409109037317918777837401495\\\n        837085869288096912791886122546294978389932030348659322138528255377986199906814121428987786\\\n        902990599819938997663761623396578059424466941813209502962679791845212564370449414676683203\\\n        106591713289371920260573340713440198973377766384109219294664371558881783314339018206276372\\\n        593111958972038420057647551263693631523086376675847028242162650084035413797052773913724621\\\n        757658324438364381670407467382045257015560167962239365764392373400509854188344643904408885\\\n        252749686497022405462034010607540468081075985835439506930822867296691191905022006946351517\\\n        44\",\n        \"34451483850411324823299430931169825968353107817116655268140899833040107629259951380223572\\\n        346805665993997204038599656222697979717564355544533826322128675652053912683465387966603458\\\n        994443053409694531635415580521538953353312746684823332351004817493272491521960166258913342\\\n        342373180252664024157667462375982539104108105341172864611410232496378513419115781507940808\\\n        170527468432318146868077087124120157902271264364223331896928777149891067633690191535656820\\\n        897091205178130592547090371963167767708229555068458979421107996836428058017460538748496908\\\n        111207323867182114805273143991970655106629214755843110375514587544809778703303551388210653\\\n        559676928255518022127417846024607354647675627462663009134103421330366897594118915183233338\\\n        405418371410818031976930549485087349287592927111057194910345861966773962551956076839916605\\\n        668667571737424974557464960284509988107381126905270493288482834765309133784184652590356401\\\n        885928053781807444837597092350928183031420516270577246632088535963759792739825290341892421\\\n        210314840661065352975092908709398180986384993273218950527276814604805629374478626627764772\\\n        485188935806396216976047862875216962448871415075782986955268499047042000101197676464074038\\\n        396567510184966877967849012312867671990240503189201884868007230804072275898505936078253927\\\n        805844759204707222468062168195989666730218055824398237481605959167838191560401865967701507\\\n        253000529407234815298651681997199461379447600411104701857261733466465597053062670063935164\\\n        093412070118156654329146112330052280589648492001225444013857258298334732616978281389777816\\\n        679308814556707411905732395516800190900777730393630710654041906698171400970508755242402075\\\n        804997159314250556333980779296545158052451707345400758844216022975179271910866773004064998\\\n        293889847099612403751532471065400844401150789218016789810982710701891467096769774096155973\\\n        076662058008263626743779258134662723923810447638738228784875330801369043111387004496370207\\\n        023023480567498948009769072811296577926772625470944016499846497851232989174805033735426704\\\n        401754345772361740710305398981602432839858392281907893784987773958395305162061012125108677\\\n        358918304359515045782440344223451256206024933058418071421147095085925385566511010708875505\\\n        143391759359699712902902855649125046462521053067527088443130985913095674557998886417190194\\\n        091817087543204610477089421791735191155711725548961031690984947623500779592937068388046836\\\n        952927657338820645541082391241962186370260674181129073198386769387757690220757812450255987\\\n        398830275102239759157863554446439131341258688347353596958641730487161625947948579244870323\\\n        305947308450417267095819036918796189679098400984195813313422316742491207583655787440490886\\\n        298007284424967175626090399957925093538355574872082555471440431008634050086848419623105050\\\n        979963883882227940850536301168002005227090933609287179859051338370266721367192856034841634\\\n        380462252724877875952791600209162014400851786947390095090491967032550467103457449770366623\\\n        241863189316478415536830923266592346544620722406161993792578283425696720645052311925488820\\\n        308429105619077508194898825046655662839767551839714996882367849263706159358845116298006618\\\n        727844680016449800282241995219720100761245745067038667709282664203811883409708225042838966\\\n        538631042260150150599168704362289450260729089999691982810242188027505136501099736647940033\\\n        593800478292421390974480603146375867165454961479693286995465035591674300623426586535107210\\\n        388932332372787026577938415078605090354422340032687824008099024604363938703357023027630364\\\n        292871249826808894293080856462209028659282624979331235546731980166352695144759454030963272\\\n        502296622756481170706560851592503832402105105757980845870985976783153388274593523749727972\\\n        040401793713966358887812939386130829019444456960795930555938402991444909456092984987149402\\\n        428151701692246846687416797688029689905513442522159190326687691608616299564915455628284680\\\n        372137358088442376873928349003460953941598581356975758600184767608702613380051642851909161\\\n        247987152945546841111522516319533862237514132116947991455401641234013363516847421112754934\\\n        607514877300805678805316851265294770508967422698728398461379538341592951145475544427551959\\\n        067400743840670142301150071428448155955776203674198795177237553657995978052331819456883381\\\n        455099723351421571878460264927415704629035394978820856756976591731972517186008947371452139\\\n        263263975551702018392139329446808455229621276307059552941976038257007442776765362811348650\\\n        905138766563753932841618854558825661762743714682756672518270320160690491558838693394720350\\\n        477976924420520989075125317438902645743454395195714434578544555102933670421949387729107784\\\n        974976458035272732960769462692182488657200658550153476719246974948210233007558345016660556\\\n        970253996117378131586858412420784199265977175643054911033536900475623633318240917416141041\\\n        831985077735136206314006717191879376511106165189409587036115718362166895102926680397638022\\\n        836128019813125575861160435615933076815239675366208264769162539926968207906570379303342082\\\n        515437980671128734042106497668997405571911078326235951448632699595787249260304334693702218\\\n        393996031745608620051381056325695234435904682147685177887327467336063031606977413652534055\\\n        510908715388100418636738012794529883204246462500184385289188912169632132527093061936361338\\\n        877189491156905025625124866895287629311249111665425093030466099439132552416376588785046575\\\n        445898699930562965024221336812658561937309400706959884257436526882650523519277349666681420\\\n        764376513513445413823157925840485389490735652994018619351676317811528866626459266101666810\\\n        506013220558580821283823790173513660077715569315869701364936771288242955486977190348614722\\\n        824297125308989188541801253123660164413441391712004725654381997332882966172251981286325611\\\n        680932850180864180098717997111976053193195357127883516969286725799790197027271714543878652\\\n        318089114605794377454173258755305035298054737378206371852048343277831454660474564902185611\\\n        954981569288359582857878546238631713015699017988928493761633725944495504282922834189025551\\\n        034955997321833565025656904567697385151170281369030889181778353434671719121313120861836167\\\n        032514757939985716206633267937585689173565456116628684124397824900658149487697028933163151\\\n        082834337439644982975293742010073151499748401890776648805747286521322191969279668583109977\\\n        330149180887721815953037618263467789121921382319318616715943628470572242406075525215876390\\\n        944724401125088513703872385280774081436888227227311507939933081235416303038341270511333961\\\n        766106984547059360159227414849198401911211904583688143280838121847294126079240040035107841\\\n        805309600923258724779173027052674703034034470269208516785532741160650241386303961348846951\\\n        365879365427942800814204063398292460722659830453474304804223976075949827423740530286328177\\\n        670507486558065242182725365612971888809269405964838116384178344273953464112978188065775230\\\n        792629764656838121320070871624087416826097620472272685701515925496522979080803302267074111\\\n        746683961832987997460419989024891610491846635134918995713766790979903252244530229633849800\\\n        683341658108193740193326716632763424481912119658049584880644421003095441414603535606649604\\\n        696387568768767301348220229501631790841280873686804110114325906797411252741668324616788629\\\n        283731066812844132164534492894033830843458710866657855090458158446987500946848952827358680\\\n        584153170305842323335682161886386022652936951100100386464722051921007918344169658219833758\\\n        866711170080835773305637188922909683201737950283313800071517502565669192369149942619515304\\\n        769957278223622971046624599539305022654711241271321881402950092379957879896686151739251847\\\n        060987478936338358531784405988998969527646767072480376710888176087254126071438298474102337\\\n        567400673041747571003432724244907605765074484537909942140483502276839139229078225025377003\\\n        227007772905351857640586480572724134859567518646054039961796009706647467440701741998427295\\\n        538381165976011731891484589068892690857689877489385375025363024730802266965427964311403153\\\n        059682976705254921992652455798080244209876120085617661914194719029606965969843749701911879\\\n        620875131786482613735039853788263889283715459233709619299066452010161530950372051663690890\\\n        012503149545894118667385574733010004109473563212015923697091310537379719232154136839312985\\\n        778906131287336059733466676561559359886927751424410723536501316433418057100068806703499543\\\n        496885626196075689054820073169178776289523993985365592344914723153628119748507494879337971\\\n        130051805952794234286439270309733638978017529772817125682688489133678491928232887434502649\\\n        217820808543462407258634360834775597062954208649631221664331992417591349195531072400077889\\\n        256007064407480132817035955085385648125242414021060199810904113403271894896763235781196288\\\n        652164924470761802380958547033200682030406961813276511011519116214486233594528827960837905\\\n        807323471783804076336564074463729044856517271487621282742548476710745239522100979080158548\\\n        498551987964273821478308964127644472844203237821055459140672365249055353827504950029178680\\\n        022821291496925950008448943451971366977558035566459900116917702164015349057452721935705158\\\n        404803531105054843062310400635678520336321624994336805114796258045554323628144728070260893\\\n        487850855368283835909559919698274340451526830285570667388105277835541894060352276582598328\\\n        751658326541242595506840544176543735901853974638162788744394423375373652048678205762612335\\\n        132065571118790389189129212782254051998064208245174984475181048639252449493529202070886583\\\n        466188181879421266041532473028768686787094284113910664982910327771617617263824202957067217\\\n        448895751570864273321125034029150136935975908450024790363652072622044223693697286659629670\\\n        929134433081144537426272951437325331049385865827278375868476890597558716459431879830301264\\\n        258862842682138305826848888799554344478258626975999511509850092517572472208039544493823245\\\n        536275868845077455899212905013893801757002974469933349422559171313073431995913254690505562\\\n        336725231802565296748198396917449406561966702728949138084482525014698608231685410973648702\\\n        984346969078312465217942951143590197487555620465399371812108558101929190195069753910407865\\\n        130870815296580504747257203705155232440961318572020390240444897304905143083001089086519515\\\n        566638569036402518528589786053757818672366434547895090769867052964475489523564212955323431\\\n        542561315932996753559434496840542802228206377995119681243972592202502741959858499197370487\\\n        707521880038293514700359795101107647234678429006379790261236163936038007792191656468677954\\\n        375167003907079597069319876759255243996608842627393215800118222477660974666312626019457998\\\n        374118857044030345588126393994626905426120385538259045507126522164900849343130472337478364\\\n        984228247298605979297932548920010028193766166491175054532638199786201751368198005607744338\\\n        428206011798707338401604719749912726435887596533474562745899702629169235117782879506038742\\\n        456103577573125900689404681235248661052449870801684559999433822338866270038741083766692124\\\n        168202419679858205205407765404224541747414070890200255245171249396361179208331586778747479\\\n        095703439032534090408608507763269348688106310040246781301987340152990266081084249603199014\\\n        068346368660867987650342431829970756681878106307037571550373988219147540507836585496820250\\\n        722370634407733349597588664354363193736205431729109301404939549416249259152109805332903996\\\n        427992136197349162655622319922410969602438078726108101098212105254845572682713707291830482\\\n        356972924251855135897621063703425123083777275585879387520777211096311536558149735272574784\\\n        537195136637654102593874695663513305990634365203629686264481322783377700662326639771034888\\\n        805514330085522172413872189636622959624310653455879586434815238981516347220832620296269964\\\n        360966544859727329415855095913815113663362856109926756052379778597171872085418750153434028\\\n        518557845551930703696466017362942862818852591131113033099295976824321827139568989626752423\\\n        690422856509892091285497670787672281252957979849838393652030906179060506628448891744306485\\\n        382100804697144115114633245200753460099682305487164867482792405008710139310592653334091585\\\n        840956008848091598133392219068226763885521429864277201471656942789040873655321439511108116\\\n        878835001147297590840466822725808875177288803992897626429359651791176802718789979753419264\\\n        397844295085682497515331173323188113801288315550516596592281085788386120506518355975606305\\\n        241866594647036248103295187982957766535773920891299217667202671698522715962229803815472723\\\n        149965998161752952422941449093329942557430866416232489916659527595433550762859703651942344\\\n        538572969239144268957392841245046831036948430945667763820531844228465553912212420018852225\\\n        225020577653926055111666069107385216670468525811777232240596132659812136140982794821935725\\\n        529530369197391808065501092722218521597443356394531691871252463773782885446805155905182271\\\n        570710844423620699214161278548574138113445531710254316161885602253948965721790116249310562\\\n        074176119353841784216686644363540302412520184749158399880038688611384071562145226236309412\\\n        025954003609096091196693549152375332728055303791557945182253393004979796043454313270109928\\\n        301308557461535674579408970352534560298364201202924459278577790189232690352003062147534120\\\n        577086795478900141660440549924925903651942464995456136682838704457563307836759049502789214\\\n        119291019249760227546213410815469122467603099122761528748528931097451997267191738686842221\\\n        227281579457907591596164599467844092814156240022623275966643581665147346072951550641745705\\\n        551696463152273555860727877607506463379231381145345847649250434860394207767765067388078010\\\n        623076389861491081441440888256588478514010046977281806287294954164246618512747972640953402\\\n        956046848252491238660191751595179797088902693712176647301516721042046822506434715329846153\\\n        778862985010999309749399997015174458288798506241421511745946381134698252816686599358395482\\\n        086399565381861876975629776451791114984782286798542735573451450332461913580462775341218877\\\n        734971942258586156428838769130181484595829472243553676600136111572612545815509866021037494\\\n        780382060627973713167222620516170844587075698048783685153882016440887999384559503243178120\\\n        868195078976756224285783465205863024253335647381962201541824132350409151595101524764886467\\\n        457505186496540101752847839483542754048844069208372465161854063150975313029103307321418818\\\n        119233704685893367710464938988334519818513177042477905036835052454672339088844918558317067\\\n        977892573729524598815397771787425048613549189809658805909956151064830252564697255207499671\\\n        574125935320453283742352712670519834578464722637921505788873086239707006367543138659438125\\\n        174502561594941187596347035957280538575047734501525127519893206532052968635865346356062493\\\n        718937198584720706002320112571635761998896216483884445354630730536227674466840227807153196\\\n        096198999572041851351140449067146152137339686115795507805042034469582023190358991329139663\\\n        974188039996546459499478074594715673706838977572838085267435026806537721184978234104459016\\\n        485409366911072651922167870282369368009663524362156019767595548424241982796418774826532354\\\n        375832241060902123458264559278055921102817108325181310110285123796324217668486211652918742\\\n        198559306475719045388751695440470017338765781879696159991789949478093762813230326543851336\\\n        696073852616561207960194541332201308828130119582823430313707585392248084260963823712293202\\\n        085275259774031889913444531570827408919192741750912150811915361495673668157918124360254685\\\n        519921027843518922603489715378521416713939288867509872379289953489426209520783880739378146\\\n        865504524488028306961189050487514264734140841554909181354475972182079211508784606146051762\\\n        339543756043573384573111247024991473539752538624994050631977741705804572697905637673185212\\\n        242800113399263090375970407125615860445869990344831212421900871406646684369187837788378818\\\n        877172924977009844835294488210238213866267630358185758660416082157058756169319362177979260\\\n        546616004837461973716388163312926926148946278758917964445296848116580309911031228869549259\\\n        412636870591769489882775092897700260126504352246043840151283399007680541346796501431674561\\\n        323059232837610317621936622461929837002216649914547363925415378909953967529937708790005766\\\n        040585957821098073563643305674256947116737562169406346876946239532769922299074253802930288\\\n        665609142808851364690519060719440761375449154896537075489000141803879935188576961796198591\\\n        544055570745648511288277715522161959520984178784871498839108487767222412949225479370984137\\\n        490189730674559921408156013122499729144279286850078756211110071212872081887531886347374079\\\n        112755288163494222573266001038127937782870297657603264285542023008835215760927833970067336\\\n        165010087826124444721616873931105411767241261650369406838904843197479962397073909232281996\\\n        522621828075720519714487331801331814757908355092931792571082350459307441844641714914787888\\\n        283478788809855265417988211347228973899855678075241312542522102686031939322547872792248286\\\n        675269482592990823733358293555904831160274011572931047298803815931915770329913822471084605\\\n        366006229894074162622783540167260720017736781550909901686155742257941113264992972394124090\\\n        318389391119821476465215392669406523445939847952021981806665770637456494614602859783573228\\\n        074648152918670903031884641321092045177929963199375433017123947771361485283163032912800592\\\n        438205927534131397682254230851877393397097594038768864513530404016857882458836166128228022\\\n        937256385917642841512639378706189731438119783502474072350646428490513156723541335416372212\\\n        315102527790678281276940631218997079244933931322012487645746736272016668362884292142516984\\\n        968647052061855624461046580440255363545371324916884033418260716924453600613330375766845701\\\n        993299116295092841218043061518544179212737948107674501099532569718048678756841420109841328\\\n        306706395299650345093904031225797433044265743360086408656736569363347839893920255251396607\\\n        060149499589042039197167351925551116394068851429343590800082136985760002214980684799613726\\\n        894042451574141464139761470212023058128902043943836512316385866499516340987717912975678628\\\n        686095823507610450222020051512914739180359490141352076687100343664130860083403877465966357\\\n        191289659877096887974699561997977502974442759413816787470524438108681942208514706111854701\\\n        337602590140798086494716622609315106637126044955399020227484105102898710878206318886827303\\\n        336980585182421525412238917679597014122287128668431294790415464220035785288478711836989723\\\n        850014333416924049314913268802753545785443107899954705507264322288241856118398617478345968\\\n        589391644436885339684899668223247138308708606315483962289563287882050591330224617709631177\\\n        778751759080806853227799125329083609323333379871196498969950663857222424722576085161805857\\\n        602406514300503128780585521703560571460445023350710010625059437079741949376053597914776021\\\n        397687516347542052760941986916258641774829458956600149609134709983917899967563474581814789\\\n        682292752808898549800077114365967054718367357591391132706725033249221512136426867955387920\\\n        209939183562027121241636937188813749462861954296280905501243789899766742681510462838980626\\\n        369345154995480729252917480001177527787563921059002955496531428565325587694485283546786813\\\n        990238769896530045090556480336854627192297026743157137155381468394890817960168407459485709\\\n        558211893080432265089498420152869751850655987848128027604126345302811863471993342719633010\\\n        849542601565548357590601849780837878651943509070868457117305020893499111449807008645059381\\\n        659688987043167284637475278626078111869161238673111728650645609422598625528070149103895199\\\n        562139436764844381663982786266277454537193593473332833368053024772648527253349723430366698\\\n        939132575256634891812740864145669564405558311563244950441299398709850593010119443943161602\\\n        701870710606864490460132357637819393370402092042542363193627687353863003930815081251670348\\\n        129851475251254448539523487878672582106125926727156094137042863702599896027704836247811910\\\n        258458823128358819786437607605329767760307036878034794828352958427659566334169204021874811\\\n        538965177344114937038003606503996998136318237834104259584037838308359927629593747063705126\\\n        858707695418211272424205782878502855402959897074192333985657556476331378586329090379651080\\\n        991695829880996555381360719265503498262297303266917376931048542613413371960609394260613606\\\n        430915059415556625702836694599441924277342202652222089075730931322328402397287022941242185\\\n        717021244517182027880690503057840929695237494069687031508226864841477140555511118153597826\\\n        471393767148572019592590589661962974943985260586380988632413850784297423932879063755049625\\\n        048655253583566188345101838156995011000227383700260295834215716843063615859489475908798620\\\n        631495640921850282304004536457125512346087009132591332433596132447398509370324102637772365\\\n        811654101441506371350657334595515686562677987371768834329412408846446903559106394935163002\\\n        416818729012823623014145824781067342062155047786652548734590317107342478714136016411854798\\\n        847252483002644558253730641528875696357855497168296844278003946177680698879853146317782513\\\n        767939821210899948098508015724218948662487451187163315005775969927502408812894359669379396\\\n        778012469048798651918759924766748415410663317531214582704284750051508043110722855105416281\\\n        210706946926765551063478977529497978013893883374638470109526084619875560401213475780155952\\\n        342662848246691086403726780314401603911220203700032090079416882756289067081542828355897856\\\n        525973039882396346771615496003050646138228908176923866644249740778854999559569737152335979\\\n        200531948958652730858881618097849371240347874788013696321236273274210419682908297421234457\\\n        707533376016861411884851348789525022955389374553761217211960759863365962152933251387475382\\\n        406161335298128894324501548832974719333105347026762496259029443264573625749862923217206166\\\n        416786688216365507514190347196140002317773154246754509004961757355489010275928109218897044\\\n        357830077490623588989978733429444763045878428091118371874961458115093452754639973682738658\\\n        211602083971189902789055679922827448563168701305366858815220103663327369941215693565045564\\\n        119750087904694379986898347043453546453790224591833549909502332445680809337608592412698084\\\n        896621254991403387388755239960047969770525760851324842289028311447423119062225953325228059\\\n        795655605211586306827387003501653747980935752229916643479126750540844943458753233064332837\\\n        075336670553429448250508389311617520142484759769417969980876847385703834060918267016830781\\\n        006847442790820080105541848405065544682795443014121075391446070781451379604288632734761458\\\n        398209716125775183920852005515849905618623946476336630304148133428587203955426476550652193\\\n        215658502873440479077368992358317958099028715294329172442220720349493411763068703812592425\\\n        333316185868216843027619361719337779771651225530835870756210526154291484781165167505782635\\\n        444123331379451028271140209035296154859933506708871027360990178168877787891249483294325573\\\n        867524211035534797729060145665525317364721194821457745282231305963349597707358191193795572\\\n        672731749476274161521333484526581239039300486068096577231143652723430953238605591909713924\\\n        422755040482530758644641884981057421222801517641771267703876053315204827718789648696638198\\\n        181274865524494168483335309659429253831067776833121621734813697751270823306528097742054744\\\n        500538566062959795081426562368532007715865253163750867900563873003740804109405242257332958\\\n        062462501274481436360441307061003750220432363619287444496745629439729354414581514488564316\\\n        451761614476489527702312389041491469638633417340497468593942917252872443087086489147800423\\\n        828505759793014622964328421955378955070559143893777032056280410308174479911956552126031240\\\n        402350063876088882229556265517435643170051733043010056341152354997614810295095046869877183\\\n        096139996607269014326945159567262567191293798305073260996562614425887425455374979891456095\\\n        229897470900312311925143464978677759466050983479154264080175638895902501142005569715374162\\\n        439745514651941602635913564127892278781517042368060683524858651633544294595464175919189546\\\n        287301249133953673786623889576437192336757501689457761778379664115967059899504468708338946\\\n        174268460667561088618903539860057689040441030537617026454305882440756890397902592175203302\\\n        078030001665121405262663941436022036973700125805489568090919709895612339333566671608023835\\\n        455527784847177527377893854967601198740733065785158136780263019698302275232365265252605174\\\n        452079901674705706649304530869662983124013928801299754345774817552409059640862390806201279\\\n        235420098307674709156399898966135683014437814014702747320523341553937700053047447504428149\\\n        533752004984630505423833214428321530005105946061401283205536997650521119081882939966879972\\\n        453962379650991352482222454387941643450551460540492064982003125742162046560577063924849530\\\n        142380194111272158866710715642719572256422950807595061247336947138123189823625116107087700\\\n        944533306182680619124575855919683931198756540598011776459628127590695397809494904846442718\\\n        649596407235655247734789877074031191565671474394025372900816948562928317555231363679733222\\\n        574164450899623296236609090004394822149153067940873278533793456899852439870940461822574747\\\n        759944501033353416935809413001556748775098231627899189501288666606594774684279654217831525\\\n        996095059859126912080006553043722923653710899543200681630411623378633967355274644192918115\\\n        805934751344808563981811237311909444235495445951998337209009241502553025904827070286436519\\\n        291473667058643593892946772761587047218204359175292481330973344149418956234492170217763374\\\n        978218153111603223037191855013912649889223800790586749220163854236535123669686039036773857\\\n        165661982687423202295031684701767176521589901360278577844739473092978236356178076026557980\\\n        589449969283369737486884564783851036005642429755824483970051138445624076916484961519911850\\\n        095046514841817169640401504443162380462164175526395522736778119522934020424664208798968129\\\n        606932122184887162402130347045879920983986850384174013865279066289421275327565875423189653\\\n        420658611274397431231290083905370234352653847832749847761436437340021911408149709215776160\\\n        175927160465115857324030880396317055770481374774873838009707428904349564300577319269124410\\\n        244607822617507177913809596171303542672151874659047848793648233858365244696291993519664437\\\n        788858700502428778828805324497844190474410993782500454236165150041212473801280741528960899\\\n        595030751921446734361874394080147764515048380576379308723419464387043768049849998069762495\\\n        150016231356941135656709085117365708148743917116796871067561841442191399511427991297345010\\\n        932591807729460899690651129003475842539915389762720417438121356836436409856958022133606908\\\n        970652554057855910264578550207999297611863734275947761521432690943272809551147773015613905\\\n        808255795195835607962107908719681116481962426756072504782197918031742843352273026853062292\\\n        769195332490957754903333458978602497326356231116792450891214770031983777371709908730398393\\\n        594852155167080960791569781719471339023312673628161200379354870963252721724368977647217077\\\n        776610786408810822693979422452771653463856549241460386637725661145982750591221008011655216\\\n        190348930397562847395964415571163054486712242584126234236145004396866479558310568286401273\\\n        073708489652058298850754674398883237113826629279392087718936426293886133450732131209301864\\\n        111969695699673733548221977940978290943582134393284191699640462089302016872356901120861524\\\n        019731328220985689194882248781905372537531668233962185171649135663432501482846700499831859\\\n        135443165051953331965258053149593064919421055652719849993993640775656891725011231094173950\\\n        644085750532115414792533549406282032875625927929798875490220593443844147447408791968149656\\\n        327634338602524377087853590689960973148210869297419504799946169666867138213005868201726199\\\n        542602384453654874562343971206403481539913243804958463318175829091190320780024349037328957\\\n        160945994880266286323667631884127967896682067485478912931937226009776156413982500702833559\\\n        292555992422947474719476915970151605776686254842564354302150687592189321529564140718070632\\\n        406189726637774206342576602034324464032191126504709982463870674362772324950651327113206132\\\n        831238431350375929785369057776628832494982803637931463012324477796295544372666057388420669\\\n        247182907265861079707381405946063671040423286221097815774358225748444109952648751545732247\\\n        988809852771731502082459590106530705261531187388707380253428887617766558383411645389547860\\\n        009298338843675500510962254607537545229412532540774514539970800946639864752768572312592670\\\n        457246516476757543442944269473723206705345328209648336274977629413931982098492458397405626\\\n        601219141551447835466625371840816297855088210473108204312520465263598822973457046492371397\\\n        049963858766696605009831137568492189015283876528769518313336876860431375874924277724849777\\\n        945537722607967758495993564510887376708682066093750155078680659932239062086066268560156015\\\n        660109487451108369978701478788100676754812169949792523375318164560064832262655572938047984\\\n        078536028158400467090801630422094438966222058959037151399115830403569725870876250495126476\\\n        390857145748977128712353091949678859469858814210687226080814371014318085888862113569201528\\\n        169290594033749141121294156299371911224895801604572157842108812079446923233296810158005436\\\n        175633123327394070699558890783959011112903376158566141838621160916458746840412213494853497\\\n        474269620212968352580138474375144820460770672719452671602908785997153922921412074452631310\\\n        131323026109178671892437147240656546783358426023036862775538816256793809660530305602729690\\\n        633377759040791331123166949287228403314514567484997433608191851213631333797106435919459875\\\n        262219713058880009786542053894669832714561745229478442734339116089132464047698244655473600\\\n        953441368743420647351145116259553959005662770386556477618215341669420629834435372399613787\\\n        296827176599744397350200601727819556759844744995256688472055949395752920298762464686271360\\\n        669725978702831702395217742251878298108861941333211229423014396530223258662807855295673479\\\n        162443310133020185131139835424775176490714373992196709127320469252259461968678663790266073\\\n        551820465994164443225177860745133955633052426021910326393369995832792346105304590671427799\\\n        534261175042713421174969227391307629176980447061168735472661254908581875030394119428236350\\\n        382991401750949969372730354612185800970098854831975947105166511743379649637242804437161285\\\n        225785305507615380799277856263997623738822698328391333166312670966627707230973963507022014\\\n        220540500422546745710596264983227166883076833356161781648477880677295905141308524026506232\\\n        866238743005869884180137150434233321904963260081555953973659378071899467106223695523671445\\\n        258397339087709972884101627712049532114390236460875864346810590996699499880173390706146372\\\n        025949273818994268245886102951335222080959208253933800007625059755559034468861748574597049\\\n        682067545742910319182584915779291822344505615217804469264515751558112659264614006487943303\\\n        717221914332078728042309509034800138934223997677521657840620470145165897181964256067193546\\\n        376315602196506142872820369571194899734262441550365063324393305472097532592579657277904329\\\n        269103243710235358678715335469810893733076363161155436911556308939583805479330223984496345\\\n        538838933652733752093891565812398317331439285438069814674670399689385643518783544657531713\\\n        781191471077656583061493206364330855917177480669878475561227419658062327860602826460754292\\\n        171721501963162512792622618339049211469985715337423740053833838664331885801939112097699017\\\n        217082137281425405379868833299145630761403697552709281714745507511560514913433021518948978\\\n        429250568514273320922080098149229761295592246812528628990439383119307270194702303629943864\\\n        758495234939427785771881577598090413583833317083245885497486730894016530011025100116930641\\\n        461739104454263750344523907633018898760453940896591484286184888046928016682988038012238788\\\n        189108608776739973014066070003498895913132462858216422697074867072642590302649669713479109\\\n        481552576289570573000532900320314036556065375832991819589675361214693200917700296687232921\\\n        813686891830928915063993979725725981320204748644836089446080091192760071712714256697928452\\\n        460326968113179861034532610299549545044483792369821601059802312435390026312964364299200874\\\n        112622278064449210405437424913377991627546048644021491367721297926722494393923238472363862\\\n        566058684851712199901873564598389189706210256088111332717133371878858178396755074976515070\\\n        222688043871647402055171112523514800211125235679455681419095884479413780834126616741914694\\\n        579929060021994202566438838207505636928272483386483094726987476358997952133382397694382876\\\n        713783750104019190383692683029396266833804813562376989985882779576914173173303588370905585\\\n        835278887965921675888780215189804574598295283770901916257283011898814659164748282388932179\\\n        570073374462538667692882787320335680170392836484044335311786499553769410238809014358115864\\\n        867948483537780209307577083788051718674155548903551063229395437469566646526407264003402093\\\n        697224263588818639499445321009180165186836001301660891094576682409647325911427789090899559\\\n        224869853837404141914379079841275739713633881536388124098485032396257606443666744838984467\\\n        649029166141913690942694749693507326362939168605469838344154085283961625642820211794709934\\\n        703145558042331068812417061473783580853047191725361160516268314845315868690627509571693697\\\n        720819583879519637768506104321394426349468512714739379929405662884844694723552158063944955\\\n        067195618245836452248284392493132360402878716966133636444280694672605584995595839181802550\\\n        345027666514246148395314635513419983674702619826972102388056253739047155829648872521297052\\\n        403746383839513706170479418987915494534120932056888252336919941760112866960059275048212077\\\n        230542993140050180013452690369912212993394083071569138986871522097372000579694912384610536\\\n        413685179375108548844519804629043097885915177510580951585633488112865975498990543783122619\\\n        192042827194374286324390110432442917536897231126372373333726293046683921760199130042879041\\\n        822893100340315844483579184733421013149152098786558046892105916687568638153175600812399930\\\n        304697289541124636143895785942481695753913259380766100940651121079216547013915669901815640\\\n        301891567050122168261602883826532658868331417205835089804158004347053764561258150540862133\\\n        489270154514865194693405286402115451722151871453699607651066333176361480613527505838394101\\\n        953576573518472897020689644038849331126421897238454580535534862867977280619765668775377461\\\n        002767465466029190942332933089617613652980902149145767806758891591583494644919571595757849\\\n        254878595659123010761883330025517366663505341739935485015487504857473180927459829732126233\\\n        662292956046529558061368359103459609973187249155639549973094221576876763726075968005559190\\\n        359547128832811895996317988902542921103834471306619855811413194776470000275477698391706718\\\n        307360192999263012448579305892275725767350587810382971675974037760583191401282677446150297\\\n        944988972934880691942849408627573230213573436452523215067877910849480818802281416164727577\\\n        528123572483991616190724775035545343445574659978213310215874824130220611792751986615580851\\\n        470497677731572176221450372100818890137345144383280412423983688010773478524044669450472082\\\n        287906597779347248554780075275471190308310150275972703552279847294640027246147854151791748\\\n        651201219333953637447694806296518322561665846501411964515318498534834233898079070641636387\\\n        995841050805453217745236817203616781559105704806251944969753927541459386518651009128799231\\\n        609489499535784546047105487447890159596926963676643848504378940387557272211950147983157594\\\n        381842826654757506690457939789055952967989120610772983903258711661300117117769277306104266\\\n        011398562330012539074489404371226566236891450734574107658351430725259222094561322457278089\\\n        347722957969273603955035067080109489625929003072625900176979313739819094223518419951117934\\\n        816118236100487607429687056339118665111475264581311869512223469808872166915271366742725151\\\n        359040057535955498995844410169025108372580556828227498943012734518791360901858916756705582\\\n        389795268301382235643309648882791147188501777493944978494569352588557506757188388511037757\\\n        665889141114236966334331447488723496934099644827291786456257912462187233750727655792057598\\\n        329426862087220688893718967715743192292379250453697860904254838060425757196729507089988304\\\n        527523071642585862598453846915879401679805158735376390810682211210715642635779795105475505\\\n        071182060929394811991454406993290064412717954252911086681058304237831822077400081178165942\\\n        965376579678816936743088697111017616800876430116711069689210404198595428599506337070235244\\\n        314938312919688993028469460540937276619198064226719164594511606413729527294294772794430035\\\n        436930317783597502495336862290976151217274784962521733168544752700665893512562775108006712\\\n        833541770442252562841300921704637564587839091847834377598505117015252740729646357121245964\\\n        101701022578023720741989952391988431838450057085629590551240750758769543961558827908292101\\\n        105124600569792261830342055100743519991782610317495999506704474579822156036092668504126917\\\n        952041631539656613219402096328190313988738208071285498595093934263071159766484211456358733\\\n        613758361446521466746087961053469530645042302362986881275445162507899108532740011574666706\\\n        461533298873738276891520878608314897316414293819908372038674515359585904031133847611472661\\\n        207878764434888656752671992965012213797804500783673392391837521046321131075845413725126475\\\n        111046549336905285903869765548563877723330428510830101617374109395655942097557162412178801\\\n        724558750728750542308726402621651502410698477075059481887505253757387900781735747399879442\\\n        465778760763985455156859260366145989415744983882382790056102528404112206686498783785060142\\\n        953942250494467635910811588601477964389777699005801967775998287157636813829735746126599835\\\n        779261967674669418334901274625361537535847168586448863576488582134151120224452475695048414\\\n        901414191253656717565146291706298156738534876291299115465598191425840295527565037965909880\\\n        949757730413006040129716446604251997079488337797894847307880586279668890057058230922198298\\\n        642320647682612627601726288449752014614974840941842344903295705543310393743728999162382816\\\n        504457769262148405093781386118219592507581740854788075959078412667555809724134485584457213\\\n        485897386006966037243225910966835040484535968205924612619104630704781260090406606585616580\\\n        709020763832499691235329841754831754009120774942822342682938270769226964095560439568257797\\\n        337185679331581070771782060625715015794963846842791232802749605942299904698958862013040206\\\n        379426632927140435055655894530505372014700551645423703150996047937194201008731906747342985\\\n        190105395615299604365508294205685060239139286672601038602451594601880432411945540602032509\\\n        075012536680672623487877787785186463873308487486946767622194650798763309136320813230688407\\\n        172359398217690052285601982945238852566339425197134878721259801907026967961206339453481113\\\n        330904236961506015262017756531925732442201445910762446132855774763472836779848468701747631\\\n        320147428345744027119152940698904792952771999383474177838084122448203532117577556731169344\\\n        615127390307441963227265091747289261406471102435905195221158461757309715104382760448511468\\\n        461721982816961967905618876364363718250048145330655364018858813372100239177076847843434500\\\n        756832698856255074591488694697052462704577965609726059744021042730620279219438435580556481\\\n        700021453256371610058428624240505636627803893166482851106091382006024284587983736896482543\\\n        212903019123182732217209059099551867353192906961404096841677504555717077298501796471108085\\\n        392455179175664311379142581128549474469384581503692799439092237369368878554954264280164290\\\n        246122095939358361276851400109045911030599702296055201264528379655120093149810022946511138\\\n        105733241581742491782413063780450759411728209475474519683179657784860844939001595568113189\\\n        946534051214732141228174707685713523204932734235050709508113259321030093258656546377389488\\\n        497878545206521490290215867317977803962707616778505334228219609618178634541648291011238737\\\n        118629459271773037184762717120035559459810902527712392366145576712598714029848948563714395\\\n        055186563959997012851238785052856507845409686171719115742668984659461609399512919460449610\\\n        501775112209596867949435840513593472279346827248966064360646385885664368653283607203164740\\\n        088388166925332732130660975944583037358410072603050015705736411981485476081586851668892220\\\n        744702311620619083395717211809104888078638534481564637713359802630224173504528768615828648\\\n        799864234972069398251526956476387573686970471269445660283144181058737200492571603035549262\\\n        741154847566452913425502202537625211442234531402454908573984275624820909011021886072461413\\\n        161034544235733680303147576128035795799121509504754671491266029334146273945476315524419263\\\n        286504782820539297127269259309212078653784961748723772554022524639662584648376069109312714\\\n        048937767413100309246659426471399815370448581718915161813889009382065724628927967110948405\\\n        226758210489022073073318038797131530762412827901726881719487468156867973978316615071737672\\\n        031468855477948988873514969339198104181145689186034249727465650182070151619775303464774755\\\n        971317805411473141964976436274057223055104911644472111485036511392636246499831818400507902\\\n        290715036122274626513527173838421299802910442217529381096534760828707166702270809216725672\\\n        780983978882642020937479086098367968716885590496225289594116545550561052887832292183490577\\\n        350247826623090552614377117264789522407957703611908185421793095992214122324861231503908446\\\n        492920315594181700232787575378324650486895258476682590833134729212814202098292933062561284\\\n        046828538187027383441438308012567818695003136563565604640168145043911834344976813961933400\\\n        060108494405803148102600371656719178534537208181419667134299482072638809730445547153502808\\\n        929911801290585720132190227938883663950294767300572811573150495180872110353467301793103376\\\n        242638622737663932322289141580375610938063453351294589845865314763296115662796827261941726\\\n        788248586508842588712779035121313328383824089606584453313298554994963972278561299095589712\\\n        312833235590245297690668733791419849573032436667351136128755959192014787655882026298339455\\\n        487565368155260013808784490088190277793931757267200087518523113718436559977577091821289678\\\n        114054743821344440737960666235204872009871554136878105554406210834838605097724435198657520\\\n        744857953697036350562326969010148660064934134026608472604011666872282185021979239938123348\\\n        513120803612829171359224979548943295770085401066992360674139672434624193066207602929572604\\\n        282770508762516137972360649375330137177377495264000553952737757723255793807006992188382874\\\n        975046743477072428429788575400325712120515521567269731880016438341329122485170349218842317\\\n        490649697594351246269315269841111835069260260422940385137858261543743220374607845396097074\\\n        700482726949025682964553344132686230159071279693376836608130134126826138399052137940579856\\\n        676391448581055468098472383507496944757430752698563013485517793799194008156443602606024671\\\n        106481922842484019610203815886870751785420684239695008955122440265984101144355015756918334\\\n        838261357838579817655646385370058043596773248241661885115986039007765327660937454299962085\\\n        391552636114836726164660851342858171376360673924558812020325064207796297262120437548218562\\\n        923730340281067486568602010814816145708246834659235588270380712828881645876655874430032291\\\n        495080503265264912628879650267840171168645639095355685086363567945399310319920157491870332\\\n        542658810461283509022859048412069534025169256501878199793197635777100349196522415605968223\\\n        934463173339210287255146931086450472009493400862954798940158247735239923371247801205064349\\\n        638025502647348492986895392666535806245419787008925122118774910985343197880968191070992142\\\n        975875294591611785806692641875795979215573132980965342259838744835669502544901379190816504\\\n        844715219908687170558767918062264715963265348492116255119804111557841550002501093505192811\\\n        623118295793732591152864643240073806495691375298763592372352098478348955892392060583773704\\\n        826689867797095566977237842719343682185382943856465423711701817313459460281907289511507593\\\n        259842471195480001434752422669247235884358477474350873482534852839532848388123258916575330\\\n        997131028501877529371488356130882341472380241437642466681991833253915439724862223769200239\\\n        286629513359641616581627312922089424074867524958296807310141211410619485194690343387477424\\\n        224916257562588047788403555206231844610036287391813204257851508188391617960813565666056729\\\n        123603181574056851765821481552841153027339226859339791910512576213876164319271072341701891\\\n        633159550767578902262337522718248506401585310424058371696723646396327827039373899886727475\\\n        349131450195002370860074044429195986371999981920247796926637645407709893245747372408216050\\\n        588870202635559280678910210195856157091506946562378280579083921964865429411856251598188685\\\n        197592113389157249638710344534110354875508417686049057107254606636836788503275748848533443\\\n        824540060600536692955964880810015770728406036492831329735055879961622910972909854151297883\\\n        999994964354523976270704343280021866498938953663981548573734006977784822140698006725650816\\\n        549593400619541583158434718437855388009561259037242129971774010716520545375664759305286966\\\n        657515871605740438573147122457848886252088528273417768425346690518775946023516691955835874\\\n        489084477916465484701423030437567999207168869242230994008908324637322544382525720452544983\\\n        266751351600861146787622903515804812397071015194800725302436622466905793991253393648999088\\\n        594671567242370642981529978316819245026454248361471325871299385121357251978810896388442706\\\n        146166502551634601482735398901631643223694522034473547210865063696930958208020888367153787\\\n        376512469136727382250909486907790540450868067502768323458566896978954758189210752070303086\\\n        251649669251401504420505817360848217901997515253616153559101017133967326697373581979546199\\\n        588714974661652785311756376520602744204093857233365653198962776656677180673353631695501156\\\n        526499237516225842775848153619275900378402906231147483012973884161607808424607945483070414\\\n        991721134722209311557065261636614612876111278939604660170796905037767932378390003322255586\\\n        058304122906249325630226923288575636745532304584492385980928953403925207793019411613437519\\\n        232099528006379230539147176628601905588778358563172150503911672861337026102471118837958202\\\n        747869400641299040637269702760352788082349038270455709323934224670207550368201362456004593\\\n        749469339528940148234326958250485118230792163777047566769810036600355296600825077018411693\\\n        493628687121627810991321603585483011967451443770435505512478076374028064001727413547853607\\\n        997344006869604098375698317884827669772759518784696240009367137238310732806540963055355084\\\n        906612982650628710025114552859612056425358592227306419477357192105645243192918809318285690\\\n        001180374586869559404875127236981380624716227115433380189195336057910706342421687425962033\\\n        283205231630627372417912151367322619843190456341269096081490370966369841829123092133053317\\\n        240145217285126230193571087519050235593989626834697914309864416274238118273119281595232381\\\n        344617248775164189511226746701911706944558380215028899330583051741040171704841842122178841\\\n        980688856302527922763886651890146646619038212310279922713781355485154657168720176653409622\\\n        083960600505602151827681388150106412708580295219806408121799968523944239293727588963664437\\\n        883001127181157615452223709165649646716087788930159164600607190995086969492700500026443622\\\n        554106944738320735285832482685347678829794140562826757381294617605988868055505951714923087\\\n        620057149303479067370460734828380714630844282870888976450595428648881210190567076898920132\\\n        107460073543449567429737538666389437010408058457765622419599962634937804212569526418076751\\\n        329175532689233752326091927287856213057188906388167182712732118714430811714288529624945102\\\n        847361791372846824390201873655090611726392439485824064322301885824809653697180448560216126\\\n        262734186636030500644073619864893646465790942400972510929794554272994639292592757027439416\\\n        883165890259257400312891460943569410129972833464416672641069711543484059216728529388994742\\\n        124257877775659253355461496157209772072077918560033935659383715536716848247673582886995664\\\n        763412646012221878463859334078479335414371059520254925521445257433097887850711392712158885\\\n        729953782612422301318699621735028842436156486467220706475718841678695911266138584049006370\\\n        205556625543380491908856104597849999869577390376470001342019174876747143264382857097312813\\\n        723219447168466494003083852663005397328409656500029031702640901273268273767309967265103602\\\n        358627177108161613418239376520908991838372612719624237566815385226347824687539416370276043\\\n        912698552877039903116789370073816491420134810194992542255007936761178340861255783798147680\\\n        767585739168792507388935054046201127415019085888317069884174685508763202013663552911873194\\\n        467589286892383514609618345005431129153574945121294585832056386156730460468520335526551477\\\n        049303494219687394404553547850790473100760949901186955004123021611837630061212195886335449\\\n        093083418195695531052540874186659734218737022093704429421074183712304897805002578025205639\\\n        958873925800891754898482778723533837978603693732312653966977660010066120336459272944476566\\\n        494923249273937403410158523810167128691172304360440303995157105825341924699287940149941786\\\n        404751742101555906478432643963220448518621564617645200735390330151631315662037947884454766\\\n        546302533345826472487165132996169996710442983846634048236434796543862087463372307387378692\\\n        057491725351185804480598824214767093379140513076055051851863304459016027351527000099658954\\\n        915496593517319163935527537520316926866212297518992659915125998316366115407993595694732580\\\n        819517996678410672157971524825843373979193689328265418884750892429739586026546943350015538\\\n        469909831987781973415758369829267820925037956141264787491362605390498312628864298962562063\\\n        291653444025548252427962804131894362346709137818379675493367600394713721998611777409254670\\\n        568677088668497596543747862969105054370625201115822049208112120759007909097150922572001966\\\n        553218783543071159888994173958103624039631958737674370642999273817967118687009663762057646\\\n        786650322864814439235481310627272732734039415039817951080695071048919564187594091307120028\\\n        562037852674303259504005834090397276151714203638963037373132395803992765668667539096822504\\\n        295882433633621631248245963537658000206348717888661481133087430927199306926752719989950632\\\n        290392214717945382968496096564417146058121196695298784141768441788903614231931127960039133\\\n        873229022252741277405692879896541123949746130911504301687418678297942258784241191543019680\\\n        048341065477821008435087780103339110547613836920821029242294554469574593973974321916232848\\\n        171271974888015338328117398677153005598697685831283260850163284773143693942425075575248047\\\n        089964584500115578361272577336368313229561734628707230981643754300014018612094335933302396\\\n        274370610768273390138763775911740470957859834495247432741718668795723375990139281296922217\\\n        055957864330251774218440060559614035700623678669857005345638444595495634325149715360006969\\\n        986801613681854531377357766571253539189040205650129853068098595419153582334511174248472713\\\n        405119794060271264640478192593878060136751230794102683018430523572438599294062189329458988\\\n        731164006115301164754319634551389136323500713151668473949675190726443753416310585183507915\\\n        444586222447669431012776643569913568736304127252694219842425973205817876936267718652295575\\\n        227629532387021277321692709941988088012697885859580896393832897690589685196668679189855261\\\n        203998260497184085141116281105961170478931485463949080005287997183988106049155751760151325\\\n        508059033474170848432883556378863063668819745519262323377306520784484328209093422306609910\\\n        732653466474969242940835460987975670745825585218615976427876485330635931169087413348438484\\\n        597904119061757056248077236926619887582103156969694055218108343393579429186615725566925785\\\n        337898303204166819398091063699605410050214426575636084954224078651840850708403046656333403\\\n        786647268065008175851914447397525310444139328560929385732510242617110382140788382004410101\\\n        688308836997466415897073241806555446545023590025195696214921885038122623441412995068222122\\\n        348640480295977595761969352621080401650736592802558504737607746791492080645349374049028704\\\n        635690628236416020897385443870545063282109508935387128032550565976228167014406833808279030\\\n        912547436223039796930047579651874681475785415609454913833489413107176472096412559725770148\\\n        596083020407904147560120890803488118770845675395140355158447601352180800573710069763563286\\\n        199759379882605964245901941036146685036803400914920897622091535052162919620160964153714551\\\n        038123889635054617980922722871090435136256606116194419818515602498001587709257160488279937\\\n        065019124710471042195256141466032130089811107330790254979510026341959782474244891548226645\\\n        625128907755199755788362904681564659023501033583652075303545969362323184086794934387364046\\\n        922489595372262275993779628648981455279178479575383145602986843002318145249045884777138866\\\n        062602506146871292967921328893870927633442254522980338459387527683619262415552103168371724\\\n        330337024462950978792522421393250080575310686931436003843018812669523810124524494931659463\\\n        558521161401196225880575256269628643619913302299101740718074196927707066023684179862004687\\\n        967656243437434126252883889237127998310715932996224413579983155174983605508308347582450890\\\n        719936042497012756580916780333467219321166758627931855377610978812500613070134777702289196\\\n        656081982942934684152520020069112920372683877565475825628200765904671541936751421392176821\\\n        347656862812576558502336925351308562209064941583452812727840176958252692710840058547291365\\\n        280421460626339448301617051122694197817263025963609123654445899762620867438529276875089866\\\n        392896206527259019636478307421900155350796457099837391033910419275055261341737040427036368\\\n        596400715095829568349276931884512470474916488754951904610646211411877356579601495005362248\\\n        346858433322512004528861314045068228949913686895336129522713500453021062975914720555480926\\\n        110167807707046729010995827123959421071902983691026543258498072295743612732868258937270682\\\n        689150435858177418586653203132832203720718445256772498064071442526699294547709525566791291\\\n        443618174033022627503111008151367470415450395023824077066076442905051266752579638093315387\\\n        803678795611082865645421291554778192302407926127859430044147603954736931755273219697642939\\\n        251037393181807967504343950873812812808655364778497738449055808225295069460963741806496370\\\n        501162331881021897171495176603467839559749141173573363392988115726220600696551452220073994\\\n        483572956167061524237463432302419543777444628183266420871910895429817332965855274950415813\\\n        044145802456577790206569815613090719168221397227390889342231921675469833141696494927661439\\\n        725982209258074467283243239473672103849013284940777114683027041092111687123053408939660252\\\n        905906025552873555707730297332375167779370465417006225880540335443839905647796929032170998\\\n        809948635905169821256433640762471636215875378209197159362823301646536119401429751894974101\\\n        529570645426809125834606466909922225170352206808622188148090893616492619461580906983790647\\\n        919428257667677042120162351820864728131865238479192102998481471542946508093555467594697617\\\n        977145155205980718756940310142753314519106795565983725992226214719217389581623681269657268\\\n        199319827913234402661857767968829519917726102242660760747134731829298011530832381753068283\\\n        176263054300217805535036417240075979824132265526221443405725506999377114311660378189035890\\\n        054651265984867809596269570587437801459664975994359650534542425648037461983056780695546639\\\n        437658726678733495982361766318652220022783199911171443205439303755986092324353300109655855\\\n        692506549891500998146173307489329199195531912480547162891556676198646080507935218264372836\\\n        385879699109961100517225165850715693776764995759813301326912187795851316659432443711257394\\\n        260655420988779924795490695283309591092968170732574431386991849488339725956939164471252027\\\n        522834971638269119286144949892567542862829704672364460237327316081241827149494893929190527\\\n        047097706768981729934938022668515395397543127687838580468430274372462175976298687387631040\\\n        603135005410233804420903620508522602853978882153587021046194759292047341243997535346980809\\\n        664175182350541334375568073696484003099163833022288076343481324931915967620342423254743889\\\n        724876154110221866707873718615927847857126422485244508478067474072571415937664506804684435\\\n        035706718073991625033745631359067099962404791012347004534257008660592177677573220886440848\\\n        061842457422781992253220807271188200850813879344178922930055916238848785041565502036698058\\\n        525435012407876719082927886438423966568100657489255424720582472672353973510508214315580515\\\n        934844402717601220447423600361782195454142829991177515607652474215124096931045385862074122\\\n        015854292359072098548301428396855951874696594941170668859655144258470258479932809167156475\\\n        379462089806390885784483244058848605358513107483516425693291440867565514581419548627742256\\\n        674435964805092594067055123264140764340421576823983493202935069684792743705464203937763182\\\n        173872225373556573186991933965992354934931002564691803500850965504950794232585521104380585\\\n        052969492778322035499069968812319412546456978593631675823874081464353414220333989604939986\\\n        311288175477703462577911385914370259645711381094426975445115755180353844116784373982036989\\\n        068250814598458393812377098601507693868108432878978997151619230877837535752922515229439230\\\n        065137931451296805879429171797389056593464539948605276367288823738060696358846516109821468\\\n        750852319234513567295685398961165485012017056307023665883560146944754378965214002570830368\\\n        250776920954141461082357051856563171825558109240073008575038986214676263242683579179197889\\\n        799609340407309230188037284304448349727833805096406016814740702375592593861001811289514146\\\n        678042780034625890289264805055829953968620426107864350681648655933989533070720569512923134\\\n        185896602172118108474174377143844498131733924905854193283720960095440136288115299767272214\\\n        187734571547040625535606172595632419292371516418080418742092142535163805336261876863670110\\\n        419898150250926163004307751643259487994763589227894093100315854607340905622960312773610622\\\n        039198920415242145170405586577964997272202983193402542022566971472924305133823613560061141\\\n        533499363284105620811254066763429592246413730979643150659951926546908099685238240739664511\\\n        093372201415777645319035761682333819809624541021111198758294293546098745782003677307274767\\\n        421508352582129162097525144955634683572121442434807352241572834749991037672280865550612283\\\n        033732992736604010436011821574526333834540730180072242401198691312440997787356724556553169\\\n        723757859323405665854322402284287920187083114162694384407881559153881858378556048451144232\\\n        183317987048036408153897678133149193644340360151887127875550285136045731856512771868121468\\\n        993509118462026691685393093823701182296129850170897125464915949530708539834550465752410605\\\n        693162877977265029758710827061288119658186586812519131042613169985962530633437187098632183\\\n        086879117328116179310021610186385164581604697404889558136628078506950807103257480131932808\\\n        264096348892944636432580380069731457519616037022914780656245584917741639131265847521269533\\\n        814609994543684716503105668531230290577822385499740607856414168320421515847359725789147342\\\n        900436726101737645366632106733552949497474631312850260776272419405020888494816338790726856\\\n        776486244139780884449457079620835848928890116072370147522093047002339786473156446037492457\\\n        692504240072394009097852753715387725681215558641921747337040408758283922868081527583308751\\\n        416753395446218549235105333089920646895652527899802363781939555917781983205554555776643047\\\n        322620520430658460390383112320781501478030905886741864989743413738290337542710427901896813\\\n        362461183268183785779616081050740942201767793473262870584346378028934730285702000161985312\\\n        183667655571116393865433871875169855002549247534221020095961917358481765928846789871462996\\\n        501782924683302505969268905764533812046036085767542541476345211274673961579189199269814261\\\n        309722811156390004439720646643350145101693769390907594948659568872192245762962026563873312\\\n        178182301398304945456179841186360934446019112283219834175451973840733800456142580267684094\\\n        969877909699618405252867785746031541558238344558432364270107541270099890990518224729039168\\\n        957339133366018487080752378478259128966374883159948156859232896264874390405519379396127290\\\n        692076585630716655598712520208187105591055852527362948668308150707631194186882304300317065\\\n        928259568377630334847132209889352809703785829472635474031425627872528136135414657738882571\\\n        283791362642464636230374730293186184697473668925029776945834548019804956045692762152514741\\\n        451585846984674971603803787345054163600099051687262481555616734848475310935152417537614820\\\n        754173765124406703616375756171053009477604712518844366195127803182487405276324420689336446\\\n        982338352673226219382693263660933131019583194623597502351817274620398615346496618074350952\\\n        778368938883845694902513813828957371361759267970859833168317779998810585556195437566431620\\\n        580289134068531508560488775268186418886154174852029090377261380684392978291493871147592282\\\n        759061644713258077273351453068102150576601616163960181457565226109723694787614786512713170\\\n        306732899647343240263830568835691670205555013160408965522538308120357229050960013882601357\\\n        851179815896831784912002274662545456947620218467595284994181944237463422478755174089171212\\\n        124106000193113432006295592998076054898137559843425150808072772030707604392787312107155712\\\n        612369806534234097143007206655864431930493842517311641052854149781431885850674736190984400\\\n        907853181904771201901514544831033707013813856814376576503310376357776052161345860678577024\\\n        556047081999064833783567592336152750087319041220289263032097112952948884504573539533473157\\\n        550418717933558451338591578872663158158736190812864389817788852121743052527795899354485046\\\n        328600735710878389007801941684411476388175507400486715829201039847253048516282199383668068\\\n        430680354070089413722735232255692197056229179642492684188752063016404741214601671978423097\\\n        101637801462482250110849163377208295109217313756942722515573625465423922146448966883470280\\\n        311140125616590488864267647683901866669894661517729642150598868302498467404041500327523935\\\n        993759844041219667995091058886946042056461118888559494581215585889982902358535951428444283\\\n        497701797436735525935733159325655580069218093105649024973326127622373025440421908095157129\\\n        414795622856110967555530182998749172534204302743000706502596189655370487160154908324874506\\\n        807524266930059926233818745998122962329280242753388293787725610833112847817887611553649106\\\n        642297563698521654571012412464202042072379632625717499455281537555092233937042572604721446\\\n        944725078819354544092588956545738677491054907370241744003709732356717851889516065176819636\\\n        127635507000918104874470991185752951985226627017889322831018188637735762074763254871453204\\\n        160569508038999083914504413515887881994568598756971759507566435327155578214995425358672273\\\n        448574406239726111309953822382019812252035012692699690427449750390478763781611573668393125\\\n        864737840180036847047110978231864709501284559093155969165457502142026517046239236054084937\\\n        744832540063554001259617989410407320041266506693712890252895069858292879741409494991247956\\\n        277056049429737633317869762010638147470042888926647173675888987877390292098950319707342038\\\n        796047853652975090285798149570984565712539569186288878003156198921506363857981661379979373\\\n        962955294517017673384528612648570759997541166233277287786537333706877860836955496437300522\\\n        969012676157411502112797816172879765186351139289042696672389028906403813325282867525249106\\\n        195167179345190024808909829500875481264404448206297271208424624523634840369121610824267710\\\n        537779881428311717987751750413597640996934761216880753963240340899557770281910433672090694\\\n        804745455026320651441502501799926194130429851372401461297366012615166378744195697268209345\\\n        196145033145648069925124294322403820953887468582614298793607341125116609117611762842671184\\\n        713441011241185209929508550900015312420092781307843871751734613796601339988303381615758790\\\n        850185465933407521114472581169835093105514765123461107359018502848462135993182658967179519\\\n        438873017254877396701308905227844519812207375960486814167032533600325981525539833004549187\\\n        918011506981982676989597627850743703563794830275123285485097040049434620984456351947805134\\\n        283712905093397088646881357307749866714529158397821362359934027094301619939488611880972671\\\n        460597457884312023883049014865960249090897911990657863135441804342405153277926572671628361\\\n        549768281867112412885322429080893030409742091788252242393526513536660046748596860272756128\\\n        079795411428795214629965558096283404108062745095628218495279865717910229265906428774188129\\\n        419773071840989330883433409466578265046614265834665082121960358121053721950211385716010318\\\n        610402557938775760178242290207472164181382136357947368210591616658165770503682752888382385\\\n        712480419382823396299427263624347914025983901956580177385685922416439397677013652369453314\\\n        471926841085972697416055389146970043119962067276433497450222439116597919614011757896929947\\\n        738078708818495566105749071343718574693513672030179384815447322455644365483108928663464836\\\n        024408552954774012226498954688874182831479539800057932307814790348696147195044345507484844\\\n        552415226839075517454818085952551745218372715531786026421376222179273732391503571391347660\\\n        235037307867460209015858443431927220368655650297468804549456270409428973648319653486596335\\\n        315022080307253030252485493188379368287818871168762648542262265211905370596070434884696918\\\n        054246417074813648475264255976716117336132868794143127520104914399687674508104556191653620\\\n        274600834959550277021557787673388933731146309549961371306312812762636491813943611872210931\\\n        845595143916296717301239875547896182587987849318913108111886380889919439093373450603084079\\\n        332672088020571452798926870801251465635713016511743254241556224525460677585042620094624654\\\n        922171783375721032142205470633943403238750437260855315002629797015923070950585688337584107\\\n        928532071947144148384742531128069763705078268663209556397687874902046109831870704532606127\\\n        001429338255081448422619738237750080140545347173915549462280009144318732287471049467375115\\\n        408656685674825353518673957321153261479182376644169631201487294368951204195698268769596289\\\n        796237188630452708254976735112987787904348045185825214315151797541550756776320831903361123\\\n        975162382361884374581328031392505642172846065752716176122401335600548397107147409887842730\\\n        051250274738988327588803467070122364683187423262043200861899004020862637841859616668344168\\\n        593653420928879062038378995666156529362636592864276116059767076576097393457375992333761928\\\n        764747771679223833855209493500207218171652882311159127846529942617771457998104386741407588\\\n        272164413904151404697506150909877138080491768421948488780385953700386339709091937772966430\\\n        600397813069094898665528948802196332336119075184066397863491188093032379862710185025862103\\\n        539291009495452547697918315149954575932133766218182046852299923835420957509115809511958620\\\n        809751092498694842651414021455193231313341687976465159150432743830230063680043184551283029\\\n        904671935969802291811103331483342736284396540329973551664889473652666846480703963947205333\\\n        749552851223034835845601771071240997841562334811531222172515623741877973440487882165907799\\\n        131847581310764753545619965310096735513778173219493485854493144225376760534999973135165334\\\n        715189094993367565841369445577541290723811023471239788314252309349694198587919171438623261\\\n        132014107022805250796505554014619872323741930556296620344026335459202089421010491641748111\\\n        966791703625311961386604971739179099595163420422582194376826687736742725146246279425965622\\\n        510179377794118676000390837167218824755956507539370245430053857270880672937371023037320147\\\n        647714179636513156775136660095468641309642329783222169011347474937181411742339373121826265\\\n        322157458919879600362430669183575643483769048433116503519666445462419448083403676684187060\\\n        169030611123762033110538147536983334260102316450017122314790915595507946651978000236581933\\\n        782789013775909202301355283806418676280485567862009143461429970376154219653365340781169493\\\n        817789853072557051170034915603717871871741874615779741216859451032305839132471820178958543\\\n        816661388658225746404437914794954427130965143198915826883731073522234435489710190629657482\\\n        771730402713887110332313429047956074436184279941568292876684408550243271142378182356072742\\\n        818368840654091198593723923470831051267170573185323354199415273447071749986542462684476571\\\n        567931248030603890685298688472551070117691520339437816429959768966890209264488488927512276\\\n        332768040222499793017669521901726911023609065380524242729450638943702559229035014213776220\\\n        678222584320957304543270554232187986366950167294760787769245530154655185407788785682270422\\\n        416910937120249534054730595567186167722497325930879462934694740422163755439058707422435378\\\n        145767482340180155941078197698134109523067219972355731295196994822549929631365154271557747\\\n        507204060686173680282364794416186631054555255375392146394052334721118739957974046872637732\\\n        408965783630229377234020153700447063334090282522930027442674010130644687004053757459590104\\\n        045363394704614694034714812324344812077507899839342402819506978262941445484899894151825787\\\n        535485307117604734060778583465486041950179153422034766486439361173098441573400965210010147\\\n        282399051021394638268389530225054670516374995942459257769734662751351950452094814596001712\\\n        490648363347033713540373776790715432890277731100665372129151087760122940198380351355684199\\\n        643290007537200156679217875263354379632609242795552412503031046448415006523796728653071231\\\n        047171113298794088849137673475315176339668715316120942202446749166510788821500952493374638\\\n        718774457579584967012334709356303606448061006392676323685728472833414547822578030004114073\\\n        342441970483013493260217864801577828932374569974970025658865278921533559941838644620250157\\\n        574728979765232087597070176366868061955573398206158075953948035996093226603927644528266601\\\n        969319395444321680253477324627050883938674827319791480706018753099179443871695476672871953\\\n        189178689019202898125164893929688446862705122893012032377691959095424904612064610022926412\\\n        645653019406618304104298572405640236124446192995352086397296379496961097384140678266262792\\\n        687162303380490459268126441194118647912487218562660990913693870738618980802913221310875987\\\n        805941073298529896824242452596980884472744996189432510742071271025910406596379169714258753\\\n        002484463920836258403116192274991734191723512762978047068919979189345515118741736475455059\\\n        124032357358514312608877630108992793316103172524249822282101499357035543465778601500189998\\\n        557219640724368076167233095622642992964219698431275540760206069583741779279192669836641478\\\n        630019625550718937334313286489204026602783369382758460658041484330351225197540740865319603\\\n        755988332229644944433622124645239713321808758272223787478472377564646557050391779105185003\\\n        678501910809953272485728764484531179940886247220967947443522976779921277807475186515992487\\\n        104429815432153236665550881408104427496288718328065607442110631319477092909089029856882128\\\n        642435277498831782733178369217675856469993064665691509674022621417917183720590023684640109\\\n        351584357600421980616421829939644995421413769443308544054256702406846538890016955269167837\\\n        186970909280013349924545447354382105238263883202857206177775025256440006259099836799543433\\\n        593267199552772106983679114929292711765006243515957750276837188658585558830967819789630748\\\n        109163001952413063288607829759117462891701146022963175088492577583456613427874943610812349\\\n        996278987134584598227678220406755706281845104206166228292582320540767517922441228143435776\\\n        069361004829290549462758823229866851029455963625507518123417375151399567304218447556967846\\\n        081683539797537516740418668759509619495431713427942752427362550307834041191811653034405840\\\n        336293068524397981231511013163002598639010409844003878226027546710404409802474435483416711\\\n        498731344796468044701322836277175398863251602476334411607755400488070880746127447924632742\\\n        419756185504922333477968294559031370539773990372753132771986320955465680050728572949375237\\\n        047781619278924982871419459553140936454692477520031824082551660905244123824407575784354667\\\n        622949064871814208602554773081452905917744005133703030829709160248655653295693779476796091\\\n        892850221140301992784366008104287432380069746588487836275957672480069738470634617293528753\\\n        303532704883665622827199715042121903016729650908367565505391584758162918374085798473009092\\\n        555924648829768198758990043994799206290107629293242080097367044862979175747607320420974205\\\n        895992625731632527914885387806241382727289579134036053835195348881637509822400702845050226\\\n        340291545720536840846866762521953383018996604016279121832504297597497026013835381766223165\\\n        840006077358629186684300305760341009270513690189060146264532944211993570899853359829839289\\\n        852528718096202876761812218640380987932439897891038155792677345448017613891761269195394685\\\n        267739455492479618691065204107399385552209915185957604697622938721490586369605638200809435\\\n        394949296733751002812949773037370624245427181003620458938327077024542814567580098532035794\\\n        305869428672182075907089684604266997302691281494244862464521782539314610765362323440734501\\\n        669623891221430203310649305547516049143185898969335402302104412901397338454899371227660047\\\n        938001084294677144352325126725697284640930300739465657064418985272614425180127892358320158\\\n        341582172413881244408772260976264089992736977070627084148563076010202135887113824762127705\\\n        826215387328945292655461954900713946040262110732621252467113318738018674355343722970398329\\\n        765667539089534555408540912782580499658453412450762884150429211287603641943131078443014132\\\n        706063915174503406506668989595106189542761782277041549784716984109512490295630393393591065\\\n        963070157439074880238199756127930514055609178456763184688643775286072615240267816970477082\\\n        355206654670886985731459507187216103077553406114974792386732606051098176302655404088398264\\\n        391249283518624527189811366043787003975259711888867863955144259119202194468956169549051941\\\n        459783988454927986149420574036851846823121722377220849168728386239431474370852270471804105\\\n        068276809531935810209926571048386689206779033362706748841414582096522498229458168167046613\\\n        724277371635506098582131127488142890056755336676912677968048233766285733070558921914609301\\\n        111787543939773869679709291798430462660548462916850705018904042958994267000792229764574692\\\n        322728066470277953294146887034327614380100052116383673723056948128739378716509620244918888\\\n        881493259652822609450115245988555564224768438198650148355252293422517723890553588255476132\\\n        686288644372509649445185201079587856555176250524326774807230659164687415762473053459260573\\\n        212385091634084981469876023225433952546671941415349531064669205914672399203361615289238230\\\n        785462073014249192224325128928298476332449776869917692912667408327523765092084851202744451\\\n        831897862972327447354970461052567660876675378574231317431864150562654864827574521707851450\\\n        496684802668399429153576913616486437750216509624491395031157724155155148382974882511699751\\\n        783849014605251484604647741213812875252615971836202588664731985622673628438819268561985917\\\n        539441580946518838971263387590053662762253260349714166096247267981202905090609830810637423\\\n        780848128798586405726526971720066701541008840810753951100168638645346885369508197042840522\\\n        428799713110536867383204604343967889947353470286230968247270803119598107889108825339003284\\\n        643442653604967951691245859122849344724846084501223046064490831906564129528882395481551418\\\n        675851544341926259360285284204936401283314006662162283590629774629510507134662391131406271\\\n        406494078862120568630066166923801555154372897202847180128041467757734330891897339824951498\\\n        552519912432010516986280215022587070484335932935491844240381762606196255690893119252066326\\\n        613182505034931669532565325217957262838823899065893473864197048572009047662774791681151055\\\n        840783361981793800698477647477624619353595619216264776149820146433640548557028389663918866\\\n        475155456905375769140429269918399692972328936043454567511745525246931691825905778291867701\\\n        498855542132044425741010960493716124297798014902478697391237645178400248094431994549512754\\\n        832431822875219974717888439698900916968943632926706035907792985666089881589026458466680208\\\n        209651351807164416154546672249818018419074808799397789520977495317904202445895820422273842\\\n        013809939598616894898224213147919995350080863168069626744352952846494150861718641496615159\\\n        633618235150982032133558039956393193877303900097742007354064818130407260664621468640569977\\\n        541201874171136970996594435227776263070685431733936303840166229403236424805907500776390721\\\n        155792936453393610530021290817883415795501821124439288532991515913470279612501311212003355\\\n        639999720390899002397647462565265447040419485015201749781846742172675009653705633884430814\\\n        769604402945217166774352267542509247999160365977485334538608970356958672183732911963843647\\\n        550182415342565119326911268184030632422360348470250949669953195512987558683501186285511375\\\n        605751760633011750118669047115542842275833118479618068468453147152193277281624328008874612\\\n        986891163553212337745635535651324597922200031221963162201382143506406052887642226077433768\\\n        661268573870899223963312974807676785311714020220382435413869194851488256169738542093039272\\\n        983796036775246795962468805702587192249319778265177583873188134881399027025401546615336539\\\n        435500731037363859812968303041599327336515179778839765493438469627533730538386251243820008\\\n        652591228261076139963591395578485529821726892209167150090262027094368569852469506557311617\\\n        203681523854515854236444525256325889487855173991187192609726799080522198381615168845716303\\\n        557094038317016612328223585986487288859316535283028294189330952976324233514344372373039722\\\n        008294407923407953087858707800378664746582532376318371623341890734810170691689165324928619\\\n        299833629039577173138573732039944158686240561013799964880637596138892838301298581717469461\\\n        904541407589155888113114103011497003490335171108137016622254379540090212728117026267126342\\\n        939866024471776153163218767737191712614417621398218503465228273344854603582371157111262572\\\n        252460697001441263027243470324540571263778463722680877409998670203043155688038307511608027\\\n        542253759506098023692317892551673402147941413962562554691914440034020963185835674588536549\\\n        286994933872696382296655844258076616457077271592720149828469726868686982515516718830240984\\\n        954166120453183055217771676906483525187693025913548390282799471614189393775088869830726171\\\n        044867908496428658344371777128817056570445627317151868482347008754935686247861386123945549\\\n        607258746386339928228804182224082603810979582131580012280307240794572363250053643386226548\\\n        246082566915428334767696287763009942113080545656719391991775699828184350184548000487749233\\\n        250080010219376907915871139562343133507585377800265239197452257271514745870858094429217333\\\n        740843659428373272934650184609409576113868783340809970631725149252952216351361639961135434\\\n        292477320867812085025107063346978836893246603620393749531079228574614218700268341296684415\\\n        134438117409692382172628053638826150485134031965402999842387838895672623880739748621377317\\\n        312893173059488175248529039057823224614617382857237806040390819613528209825331302565603173\\\n        991671710489126173213139531551285691831999953777221704964755899051326661208962880070553942\\\n        217203317926743165767711958335630913674826293921064869363608119971026989952490056916298421\\\n        580595976780406471639180919518406371338803936966015827784695866197073019668003954194364212\\\n        263563016313269088173273117085073862773161338990572434953371014029623668885086780417622508\\\n        528121118652522270148472336141636743700768328955982118737694393060685811351311837274764687\\\n        046063480419382791324529102296204397169334503688798141399624758374923918521849839806625011\\\n        858550384569578224217025456959645606071643510234533472570297644482772857333530938595406004\\\n        651979415656056713136944279579430774017877413475331280102990889613398309305705682883755896\\\n        216067754297562034959334836008385742915116211450612421083098277374611642698838801179978050\\\n        592984987779659268653267374162111538427710676726022024213846837891220705078559887704432620\\\n        008180528691791467999987223734219921031041592491603336169908661912589008444924698819563363\\\n        339965620668425741270109913740597749489998238725260290253110440122309959345922933083767597\\\n        414239309708865401153479367835706935035658384321900424592231831236904937262742223668124999\\\n        796670108992575165872641528529031468255373064300573376835208477135058052620294629993927677\\\n        569153639559743815075839724886038368879194627265232070205539563945884708589702400902071503\\\n        757122479113257667369874843488544010750861290581220291561490456949492321524601905118355451\\\n        687676176827087745027897767566131245619902808894755088586514384452260779513901897320792537\\\n        224122585203648617634990324367668554128117469382297816376430288461313806677661300057349396\\\n        294505375256676733011415482876447642206370342632940683209783775657083606376461767234555150\\\n        571004155485508175082060646635443707751561398869167535726128213648769033585701814087542389\\\n        643695811806468454359673317374962010313150247331732480424141270621499814180228699460545546\\\n        839023596122558063561792161122344566799598653083400629318145885885590961819082036127629082\\\n        392201983516366380971421359826158409465658429254147744665194413317778754840557434409438029\\\n        671220037794674235617038624619308222813959806534330128665375123373080164064017305101407170\\\n        278405755204085200047895754868022623968873459588304420138262620385181747138204476728589555\\\n        088240364274983814607160955367456768959705240285828929582906733583264589486011488120508560\\\n        323273864432142071972881293306556839531698059423032730307580444860276117546359000753015934\\\n        948984054652421250841349930333887356048252542939179611695118694806205041586124171063304058\\\n        521152796656821858483173480571169057976281323622354483279905682714573234706789172130115779\\\n        617647632999455216984196923097287272745448481444343556756777581803909525572258143809568402\\\n        737825239829504410658191363450151651570183536930309481109792015077944914458638228391877106\\\n        453909971331631832384572805193728611952756978555098098546140080696748453006208343670742700\\\n        479631035539593514600314554202915961355974742847953574885996569761149098601279358869174966\\\n        578969661034899401383086712163856991899393223089018746758521288934244816607358601962165233\\\n        824695860918863520550548145168521172943582861465382019332005615644881710812735517198837506\\\n        053537454725666975265051517412906198320559547731257282868435018473468988603280640660830191\\\n        722421322986494025729638814720316577147333765349625847241468733882729289893714633011201721\\\n        276036080735760652387293429983156426372783597749588148016785734015427939558589335186486851\\\n        768503244910925898991747815264491194752384333539276879432569076309818871991321239014188031\\\n        459386097407582356393054057696099089645790914781277324189475974684374107806705815625415452\\\n        124289255491691426212452764793501932906476688853829954813917196242641937640204042610499777\\\n        418965994716709549574954767134442207882205397300101749793784473500723959918814158856567849\\\n        818487994250569429918272451695735110886971652398949925621187888960469505936191623318680314\\\n        587770108788831793251434981384205251591658066624835698067296664686722480310619599206270180\\\n        024985046243549222610939339702880461408698120948149612145868824417636873289477931292589879\\\n        160867147683737094377063310674561461848245664723071690797081945819432646574221439033433970\\\n        654015093106298592251299376889535258523828609677916729205286089667025839998933425567397230\\\n        424061889248759466204039516676643435603267982168996571584157935482244410334715270177408184\\\n        652525113002477583587323831708703728117065580776024865302748013367081269803682669973637616\\\n        754376797782538263500579468247432941320522775789570429360987903529675676252324320637740198\\\n        874941348055701060454331965705524653618465458239362706395345807610849875264835164090366582\\\n        491782219674314636560268417570195802360872581452733723213028305357888552228536892507120307\\\n        424358979338205852935876798134124148981255558576774427704273822026120877898644923527390637\\\n        747595665593554076099803507735417596422446294428453457771322393069827954129819920831508213\\\n        154457836503020881495679938484313395390973428239169433675036842633522658703303673102832006\\\n        871433903607620234942365802720728206050934395316940780554539483405427883425785650291907621\\\n        042778672390484037827045367334345766963867029289222243474919157131772178456217129010922041\\\n        603063563264831768214423251654271214481568752851586073691347250170849004436212147904526046\\\n        933008181787818940296955995842113677693632839854700571099421831987588730481786223065058392\\\n        488674852556706612901056350376560143596696053860625985395076965332716309656116457088537670\\\n        613879959463823375304667229751380264837042134875089717353349152166778937894521284543252737\\\n        176917499124642242945763100334613961960563127135056138683070097349039484465024972702018337\\\n        029112586143729142606701655027445116089999370376558341571244704913788381289647431146443435\\\n        688142442425835659925048899860436235087979772594044033611613645366074027320653800993397050\\\n        631028528958914717841925701027025285833049482004643704097901368832636213576359560618364577\\\n        659357450611429009768016343562351263052769006901666932207166768404780501584283311683549184\\\n        217077073945939672706453398137727961089154984233359447002742563752843062372858662624042327\\\n        973974592180595649080064754254135605935244390200405265975965043261298306570318359140993419\\\n        538749895921338268575204891120969312161335031691093873319035698164293586066478602434498390\\\n        025038776519018587429088408754939406449828719401298360532758675194406324218120637419651745\\\n        812131199435766162621653549384311901208378779471024697632256737324963711737702332536024870\\\n        776630835302374572548824392311789084484173626848409055162475944395216573394176722559195699\\\n        852653504841737211220799518661440744823754672543559399940723510298799333842656271445588697\\\n        310481889366279157113269544134146828532563813705035365812131860791415760061016122105266037\\\n        955536429864609371337042840198220984156722493393823678455397932175673818559201374853721645\\\n        723650952544030155714947971327482350967440438069802431381879730671430216159898966219653934\\\n        097948944162924727386026956526301134964252251256866184608604712925367165720058556762975575\\\n        543739748915325347080458299775985493351944975307883047060106195901391253704364324900903301\\\n        223522605200002758204847093884924882110114148880626357940679468633084997697742827257597630\\\n        220820180685708247480418157697727819540731403639912997688286399764518435073954265914018926\\\n        761640374640424574861989204304886920839650189093138188497841159021901170678620916014305167\\\n        736993895033846868436059138079551072094393318124205242760261908845963451201762681815261130\\\n        637211434848885337387200838884758930913224998364540121636449379731218347618499069681588627\\\n        745879591654030876042319362410690387553767155228385118951271002866417157117142106105927356\\\n        410896867238183607084420083833344476414271334985761292447894991884253367588738194098228651\\\n        186297935246481627898941058905689796302834180300721709413536395724400083088307910671562162\\\n        761454272186549067971993205886276952662114712798427286202583469007251664256223753710877518\\\n        613773293974605396709933681703484367296730691200285138312660960125016697298709723423825617\\\n        618785821942365939459950031822205879054087026794536363749954430102590686716178313450813476\\\n        837733257224116443893496488909639142435971908337133576444002763411614029385478811600504838\\\n        237713117473770210002617758839697891836759015323496061947805453263616260692786261250131770\\\n        078098179038458684915862913803593547531054685666788300610302154844851700975655508096480368\\\n        693386301161423396465959457713919053420134145316118511549632793727043778082331163590684412\\\n        596014239555270464118249392490633852206386242316158047911539148026634027367599796207002298\\\n        818686265349304865757953521854473747889516090989897575063910390646780466458041514223736717\\\n        076020751405547316484136220062939348820815152352038063156080097354984492702667456286585677\\\n        579614571084435277563625391313560737915979375147558399583872329692338572441338133626092663\\\n        447566005221300639273067441540921368129050927675660384144799760259888162798989020747945858\\\n        560270635873244352861254008518268682702754002226109439295452398176123364883597131221006220\\\n        663451452287464845218573108632862893234873290765016518584968454576197814392961147356471577\\\n        173095865367233008584346913160186973136641350110647774244326110665201235257379224879360982\\\n        315384618760558013754677689024724249896824937296229619654657152203982175429616427430404602\\\n        355268125951454039741987386448633184900142964314471705356165408572680678860070056567024233\\\n        821142832991791285146458547793123020067204188317298766469692106853227008656501151698422787\\\n        583648203094916672847426843318626123472612128110514596631595956955649746980824869020385593\\\n        349693310821423442254678507268609581580002015414836677936322642172685053838904569829030986\\\n        523505262170292905722546369583357353519887810674466359312991095760576420028208371900926502\\\n        295439343029507817076812938567123099901915988668166264520905526363699897239159072472876777\\\n        074493203552539411559877134135703497379038953648784263301044915680474352244647737167357768\\\n        189746465521516621571382332826906423915032899782610205142861019384001804859313179267376946\\\n        296081798582461368174963537652311961514487373258511836595209121585399832908051039969524961\\\n        916432138053789380101036153720295935507487996478149064470014708925609313078765355330819488\\\n        268290547508804842565960158284650815558417796760178556011643794737963445412822770307818487\\\n        466282029847759471777468751224172906399410317965211687907169320402181205094772845882773004\\\n        100116988708358494033559084840856913060656555900240891459844638334751272898458156117897279\\\n        084291740231327369979150321941805025740623763614184898168295746918819947965668203234589660\\\n        201589772199659855678705383559822772147391340425371540713164509055068237080606487042851296\\\n        651835956957416333050100557963297080386631276867402611534520743461751093569396585742455486\\\n        849606004724758244951674873945144811402941449185719436609408432600042358155485789997260685\\\n        592860952785683844694526113946027269522654074322769473137665554993086273908291849631959155\\\n        894557691990289848169051908357140329552476134642132523845374614415874708179708441877890787\\\n        997423925231855144966019511528441622354984021729226017107017940640161336109226710942105147\\\n        917391108275647178114303381199469776654878637296043334084814480969028478646473111918443561\\\n        197741555056534999830035186976064212450415107438833616945530434039911500612223372379431962\\\n        902592167951519820876087061727578351315846607090331465178119645916269651634412199921617643\\\n        031451945743573469824144866044484728799102118033546907722816994128944621033157000054583236\\\n        471979111485215843383944892007251753743513385768558659100340500589339554335324237085302937\\\n        531094154182251666136176923914719152288383760183040420469609964771688403602048657757908923\\\n        628901105819400628562501642572862130863310449374020261139428256125857570674956538708796776\\\n        274868095170020526360814928099832459869239390300286446509114754280538994835992796115615403\\\n        587059046612633650241590750203655806152454407574650028324909163833853526994447116768780449\\\n        732539828058005590501658022690348482609869216923938336685283415633091858774650540740713116\\\n        851865841503474848653959010380219969737924589559368006722515398922338995695694770086363462\\\n        895021134105135183326367097346016047167289249392938510346923700678461913210071929656770493\\\n        701157313172165930312838203874100978211296582906677050973912695137154466062010629213871800\\\n        910905259368280472964966726878790015041626307499809709381617901071132737208596477320846672\\\n        193562813519185215354939490883532136196202820243878570252949602688743384941023634975007510\\\n        851423685902933564280506356933924307287356832180286592014349861619792757776882006527236601\\\n        186416442845568494177281022872048904779968501825448153618008204958505802771425660039837563\\\n        192420941561857098724008308514703553787249329546369590748877721133312173372640284029159034\\\n        127185589313796922313184839958117317086116153708561008979905158525067633551779732091613653\\\n        640743903664543462173402904918407195861846020781910115301454196362051517358407859912894253\\\n        445425437667447896517482551389678530860303874556513052739957058061312912636074244303261273\\\n        716353296359825685136564526790579764067342302134809110879333256513778535696288463542833511\\\n        971270992294870884258141974424649557400356419365360258135614565523261185759870753837351741\\\n        645284755393251689010099105823785404017830574654419336204824155813730355659844717413079045\\\n        765596335290152589994365655519420736773926185440651744757206047956362139690539443119105951\\\n        523337996829170822358472773130314736859701487303695742557709321664070179926374926098585880\\\n        184088823469738434213314858636832277823113417494573196001947767262312836434229150351636724\\\n        330460195421635252646877977189002171210923679952338018381231042602033229039763854852857857\\\n        400136975269866419512194740836889311610605915039293250570318533684638640998646128167250281\\\n        605798876463758333948077443491448009008012213970623174487229139636058596628257776576583535\\\n        356750029552979751184352806078767292254739690279388307850939670370241409142993134264095804\\\n        785728842784927509678678223305645944833884706809799266362818208075330890930482365456741590\\\n        694920888891367630723717379901141138271269700112334054076146900312497973306317537440836391\\\n        170939728603263022556855678632792945261629322878669666495069914810311426730681262772718330\\\n        997966706450850740322083548588860409868469735883983119712852886129369133571676642964274109\\\n        298578471870351523987964766202784094404326246943727999610607640260493335505570047561468573\\\n        098751775467884053979218441980747928372326712680269261535261265891035829104609141768508104\\\n        229037396662197566558900001383853509526105413941869212692038509143818480329142799900435502\\\n        301837087158585393266219392784576710910539326471690776595883987016083827804812566153351566\\\n        676436263302273144122265526859531341003926399249566567832149983877205653744593725789832230\\\n        601048006038930937664238813275200400966128262471442212390058162824625683676036131219200923\\\n        017779758087504872275480248130290889189432654853657850186647901598692300573061127448889134\\\n        065822513322262919587316551024076651005752327605782669659888855451837610854076996603841734\\\n        075143283287025206068071755827940155251652392000498384306854212609967843672571750813903139\\\n        717193997122614709237781633954005102850222500860522524487264961776834761035650964420645142\\\n        148173213395428192372766243792383183145396779781383743187715474656137340174078164644772995\\\n        924983553880697526272146906355175603314900355373793090196347381126893664325902969364223236\\\n        311001057049775007497426787937966414623515415614305257225860793089748981218473414784656731\\\n        095116247751088498503165676361547221822661515935568439461265203667378911762543012707529149\\\n        069672090484641641274538791756819488245529744596565729953076199037981098320272044003222627\\\n        086290770450248300731275321176914100751385695932871928702193995849995401919796369209302501\\\n        317217378124175620870026353323415793474496672524085282563344394466609737200530747231701698\\\n        200834394991050796630380819866021130147701067811966896947945168024757765986603283305829227\\\n        771723529107631975691528938303406362013960997887025054411507276866983879254734255600232327\\\n        014541745519454784191731660722630927571651323335819067697527812493651387153439438466591740\\\n        740279575749221580349111318680231589275958035487938075277996236319589955956781568149443105\\\n        058166624265667640595878313527661382031500026060875441756667191368383404631101317189089690\\\n        260847352286872097864180635957074920500875230188680481299324312130070918551844167737625406\\\n        421348027537696042822118669598737405382147637542211247010241775270645338721529419187030284\\\n        504463902594952843933778246966330618170211917798200813662206831537714001240160414767740064\\\n        908784197598457353322719788168221486143933478965280559595432346123536489660166278523787621\\\n        932764172131608114582796547214544025130448443758669581170945650508164700728187984014978648\\\n        403969878539280284278109167674216379096097210814823127436999675332593999262414925777385281\\\n        323325250754703793804699576287440230858144450611681435933431098473401566370239451967841543\\\n        808298037975301399075900179956205625005540723472787946578609019360361385152844570503959509\\\n        812717584673300989098042831195382533814097459029449143473749073578934574169721070323723977\\\n        812120964912697866876049481444853819845403215250776230696642390835234476306757472516923323\\\n        495209891010591325525616123386861044932157260527218536730787384434436979321615285198122204\\\n        583095116181020243917800486867590403975817944890008612212535731075174237030886189175258289\\\n        031743476950539264787746956674807379569991481328407890369307368334329058950662399550089330\\\n        745265859205236821074470703671784405246088606550187785151709959449060578957972472087972811\\\n        065348085003462760799613947392571578866992914045020682910511352431137318078385792501651791\\\n        971469712656649553478843171754055640123317984903726660453852397018760898196184707126932854\\\n        881079638250868458458028414918311315636693472183362992768234397784975967854896908088747493\\\n        489715064813841250640333637439205700075512751364075352005150264132750461368330395800425395\\\n        661080651399444165987601434587816918375140556051941949316604703708921729174052521055158959\\\n        239641771524939034677947867424683130662720739109800227495608469213804845013463299411648492\\\n        673643687885803136583121957919434028166305894278694953188423926827662052587550519834110813\\\n        116982391856416389168132460230622341336578048797194693921602189104922905072500511195815467\\\n        897863030879107333198516512800993207781084876905157650614211706536015180044168272624098152\\\n        249518506202241994109693247152144908486664642595096487057541107969428696437797261886121633\\\n        644160279331730997850718955006044781871453493879992773351894143018606318123520141728809381\\\n        940925224971340195892800296268230309656569867944099210746363510545204647480808083049263669\\\n        809215249355737739736529407712731427264902077149942304255181926741139534314388421606111532\\\n        794241150031492132095398664723248089468121708615852385685285992682064557713710738551132990\\\n        664988775348649287187562202030823924943562857009711293867113051515669903061165600387190317\\\n        148405653941351965578752643867421376027019658407922433726605607702226665837712547773222435\\\n        402528682387675159644962127895771590749442636033811056647968876052905144837308226866944919\\\n        728441512332261686731297623467133526035939854588275639262556782078115233670546140442849476\\\n        727731960464935169862208942587001430347569725200083608317241258777341016563931365176487297\\\n        639613202254091138620858498513939229255138003128140727593261829065362022837440258472230157\\\n        605758441068305441302927552799562655170270089655944796861218100232693593696579343727098086\\\n        555898535954360698482682052664061908347870727772286925456655735007685689059930226187215941\\\n        137978071470905687170653468823040197380070485541291187212640468768948263765350689280621049\\\n        120414715510563261699204709277878496472856149922640184728494735768739246628361663640753324\\\n        999668653622169071778561547456524015738438626857535037624269768463137914794974497799030234\\\n        916949159268867146979824283989833750695373334216507232692878506271316841955762831444115139\\\n        369219179137465279235983603753864924971353873393419599937276541945743416199131714506585472\\\n        125615559841182244298956373959937573163905256230977831098790171101608466592260398520809148\\\n        590153510985937628330705164073364706982234915917130691217188541075500888915150467700967390\\\n        238462544185128593745258437747261964575822859163999206387302836368662377651217558663747441\\\n        170880361944069803777390561963470290717701296067964225223544527820382364872884843500728276\\\n        205623172514652794644487814776148039235551221649566816400540915369649978126093603635160788\\\n        491741287462804300250420338754185894724800776970260345093405014437984952927462833372626723\\\n        493638441605835766562409520498285353232799068971729733615018871311746203704937351775596834\\\n        977416444852056522312890609391707854124936155439970970580617672160730216908290480173190176\\\n        809569037066779344943756625055403485833188573411558736220057805377929597657864642608147919\\\n        360706854290286420734056756530548249306297094471015453295003661629951644916522214499866098\\\n        182980300023735299500299517741949694984169806771037063016757285774928579309750841817117369\\\n        957956974017842711419213896540926242677639505872295156773976280750988057880622882918300907\\\n        659684449085855120015610421607991677966212286027569720835788056316784188321208758355462393\\\n        579528352036319149558048249143207510446029672904297060503056165987463245949972384783111955\\\n        017791903826150651573442163891912001222169601820852843505660502168589551256586216723684944\\\n        205971137767353614626013698614915006729875890150746095564964369070887461906617110039442096\\\n        623668151477039978463339546122648248917976939940207911766327388403535316762677460185199028\\\n        661568651836941655732808726570597828067890597604241237102621645051985102975630594886601613\\\n        801327427519975971645682436154743601494405506648516026263473196642332621316502299563273248\\\n        492139111689673089824016168288732515133184958910283830288026447796160879050768142810372489\\\n        859503363973248260418834349267717212132003293771537892117558403403463702422924857115263575\\\n        819483010018173516087132046362327953391616204492652451586495451545266114205764778140025002\\\n        048553295585164996511137936402428717371680145620058261830401595819728300110876435095539377\\\n        262391392747246380456395756673094522740189013517055190532518050436188408554829861900254534\\\n        333559343877873758428386570529445760525026789362518902146693335869692882743108577352281397\\\n        318353966022632776319993535844676007294990084301931567176112130094897588641901901348235890\\\n        154265203607079933127788681303342981028433043324745786253563305537953032164370034365897856\\\n        750214769599391944836842394801191359350028177879422147055524679867973867766438674581355509\\\n        185369459608206787651447180271301157033891062469611015830013038142985811792562787581451600\\\n        496386686734303665624233393933499873830990577099453735194778980627614721315900398599343581\\\n        365553267578962292747734697057034030817847157078387417240453128235017348818560961004633616\\\n        946897714656683036573285409248412732069660942669658073033674570698636199802039936344782561\\\n        443343402401455875753573584123904060756792055173763170185468461671677395833641332416980115\\\n        754875941288167201356704630608426878759273848948580477629328903179067355045095882779821591\\\n        314682283698126260066119636626868403283124516718399781731645952608237924162338250195154161\\\n        311297891642533389609773416928223280228039609047040602871995233451227714837876917916297170\\\n        869665712478839186102392575072260938261804522375499694489643220142811378858729911835612257\\\n        647791890287204045412570984891917889829086209441394842408353854458805458993050486967977678\\\n        115887920587988343345604594269016133598125420571462830184040103030799687768488135769794993\\\n        295348626112799130159862076070752853333069558536358518919613866495314280065251377869739921\\\n        341683603260773648772599500698088550182905031723953720495568380953348143177700809038519361\\\n        993563729013541631618628221153968161711436667323229532067516143313317049800864799503323311\\\n        959991106433007103771157830844772708253583935375306315110954241758618275666611356296472733\\\n        866872941565264151291122656528924786839464643097174041243382475529326804705941971893973589\\\n        897909334541756411130996637509030799958587051460144027720879322546634294420662034606633626\\\n        992777551143633463191715032479473816227497132945734878152615233160852525967870025656516795\\\n        977202673795052515429809962675018471780075041759007474756536611579430490683229944983385803\\\n        281260809212067265947853837636006659752819501678738516446702751450495541300899962598053656\\\n        611354256397174185660225671946938175931224978416634767763019816817643122657869450558384342\\\n        435240560682081115051283704672279662320375464535468778562314068872776048885846398138406729\\\n        124059932477233371773053129853671709244680145158971727592631616190838385571552307425581203\\\n        950309949559026219755013972138273943224784271177454091916576265210001974620951816012685083\\\n        894085688230760980456589903581607717407260141879731812667632030371608001376154451578399229\\\n        796220859825080827760265360235364605637943545189387105352117403599639176483005434573523353\\\n        586636459096144091622570409179675501204169109394837797671699376027910391324280880036883335\\\n        880064270518910713560183366568768341217819532972241418089825420394968016436935689915427062\\\n        767872713948299404423808994692303098920014208885493438031193068601588277629835877742842066\\\n        676713278076044610854299357888712640012384595810566343243683093153916438283196301855941669\\\n        568461585366114792257409054983245143731712225655548500173698512019425996748089858173826033\\\n        932177586996618727758700253128400812833026844297712498052980680501509467493335884236186213\\\n        324333352707908132865546785873676162646898535364656786556130395666771332210489364849542019\\\n        049120642521954498733788340460672438639567400159294859630836428862501604398721852577330999\\\n        972509981834580282452508625575928511101140545799352535611963087512707714980755842085370847\\\n        847326153362728326781731341066315797526537095001510366930676946270273333317639331722283534\\\n        044451599272244546839526291076510726675595206015437586015480183370520020681185733158772699\\\n        489414449070221874717514322782804509637244937308151533122140426874882050768485751282419605\\\n        721945677634264411084241508886876179560573659913592118030732412424036617120154093214950672\\\n        904718113130058583400938668424386494554833837514818131932550162442418877460735502777651934\\\n        039424961568659471898637430999635504824750016153889724379623261487988436114439888413748860\\\n        344146015185414283022062694073120374894486513506719657302674654893939665947046069625646438\\\n        260512359055664953754156938817681457395988462859287890152327461615196119032392052270551586\\\n        797806183656761180028202124383776755606145542416454938864817284147661516107547048200939767\\\n        434339749510364782903615687425282772454466235028788356041444799553367904633408402205428291\\\n        298346307749787840601006446231311043776368234787941378195688479949224918203112520968233999\\\n        380528678002271485683044037508535619186217024634423152116337024167283828458499942680713609\\\n        244702533030952520569554222379177900463024569019949071369761995656404465909426913913678005\\\n        702981605386278360159738896777904256330729911497389194075003782090040102250985721201667551\\\n        527801992921031728528955717437465019280614310090637428448361773674290303418255478941308994\\\n        414258431230417687670441988834516790365183471604234182093894274603656550235616604543905494\\\n        951947351694571602296241744385616400442324159984267583749083696700932362946360068896838235\\\n        336394617100959757527952911058421582699673640867157667777948717399463003004779099043156879\\\n        066680506899136434017106214423135700329201103349683324876378344122984467240254471832528275\\\n        096245821758473049197839789354582177315694400660836604587435725163581745929278630310567993\\\n        496875724362757834449081152401723541189228568989486914596648267668596127352930098216439804\\\n        973793556614037048775168435414582146877722761901031076213581709407539609512347064510997819\\\n        087941396742308539739887794543547127434387968561151970465294375997358603027604148649938944\\\n        143964970332721064220985981408803662007428459216302741337692420099926676295458965591532221\\\n        577498572110725047069482574377826017570827216854694537744589618813183435040671443220845384\\\n        331030707320376912828216521073494699786755318843032638917923977601326408627284922284291323\\\n        198874821944852830158023169839552062097305552303510821076964061365795919080001971864015830\\\n        437872170729849725861647586503578460410251475688864548016364808300416811556237611604862208\\\n        289869498036733260417874101245442229846962478841843489209282226934557307545727773700766978\\\n        046423166102906106084176885216815843175143843074856445101395207782189652912618962194755119\\\n        142372620943174576002916180024653950507226161952394692470683575842116396567632660351093762\\\n        628728785843229190453565206506722153250763227411265414349979828621296679050455213809704218\\\n        630902251228602854388916550202178340757219399138608663714011544545178802303343936211701208\\\n        202806996556082164126668081628817183319534913784202144738016490974563140639450542243493026\\\n        505525426512242003081132859767130108324266282647717412816357959141077188917167526848256789\\\n        175555223390473904381780085591971644285889513326796843093763879854067403258297686699715416\\\n        917166650970057629487415035399173654216166514241461553147616922876898465438494233865756803\\\n        978330004300127592772333082557811023735181152948006429899879112730746684322869601745147777\\\n        514548432029948609166409492070119713364006098420192939570349895263475399154988044877142244\\\n        860846577117190807995147462032166256191635873527406285275339745723800367647504897155448869\\\n        821124525659062358978248906920295684058194433329856047440605846146681020212219963539965525\\\n        195566371492545048742822136810514085591072555151010732386545984657077798364998073341617733\\\n        756857114260644549054037013982054125651806819026757591208484326880010973654977899696163515\\\n        054160831415605580864688098182451742793948788696659938992741111143357168755001954805971042\\\n        913431661231031862751789533141926844779726919973365296588160090717587941875744230190804568\\\n        794726500494876697078506894703726612490739619983391316800453209008470667929987918029836722\\\n        726896665585420093091286911217230644163106269554285098802313357964929999505401005559356884\\\n        926206337058386207521661854558870162312482341233531354217065237068627322093391717547286009\\\n        043737948473018112015395464798666098936958889964105864887616583387175445459789208355227405\\\n        719739233718520779642493283763092884761683489848688518801607573496222093894919993484154277\\\n        561481011539281218735810250334352986508744686002699864456792981524066325951257101219300835\\\n        627711707053402251299345336335460298270117018140726304944391628958337372998460455100357697\\\n        015193609777471186599509707716592430676103667267398148505107960771586987602420535920259859\\\n        315777201928750863304585556017118580476737938954354670754706747682119154528610131593088088\\\n        690442647278877583510859278378005859248131691557639204723939639443338386028391564703250245\\\n        274210877906095715544590699634956820939315272191086609569868030688400837400072107265505116\\\n        216365288556953566798231910276811208819937355451985401087840426104395562552878138098197569\\\n        367159056520317693952162831605601749971260174039081511551531812517308617219806182711793028\\\n        465039512408805551938928056759616837458711998039193233508539806840613982503547770226885327\\\n        561237945779502271078786844572175968149249694867824838043575501231122472094636991169523574\\\n        517023264320172564788580235435388771212686172968272338104000309239441040611156324651499594\\\n        180146884420681109240995652533723844288601578426909038073380620010403625743939492674159741\\\n        251194125676972746736199765011741317477118139538205441536907640220970524407443586953728701\\\n        762788101533531804985375549275226454139265496303069550569281377403129949023386020745116473\\\n        813825706696136574576470636932369433462019389054120721548748439871011181233651633497510578\\\n        254731085052857144164095299606435522789234161915088832610199468391229410857393122861822653\\\n        460581596921724395158624484653872165838803109493108307880478851256265907321437228272518205\\\n        673084789655763281835524483652932746339332661282176042847219946749459361553166420003248386\\\n        852850827011286139290291089789022793879349560367717865519030096146905600792797557304533708\\\n        863140075997043257957283343359177257585405042258877155388102558065385612351131637040245783\\\n        210850706649308428726542568912281197912132137915170827777118991574022253278492735374606341\\\n        638532773620463188083400845177267600862374960642818739822828443760790257447558339785970184\\\n        577341482351887749837570420387347175765273437519848872208225921918503172355188245193221362\\\n        202838742236550439218257001393840501700190104896828695092800828546480270311988486527335433\\\n        605157615480261582530028952472716725413585603484711314876825611718451382645024571070387017\\\n        706277281947315212044053274672091272178974289648993036857946337178985871243596757480343011\\\n        373727187634714101685133797974943290546753620602565604923195697953536533855573129322894135\\\n        823719470007828913383372965113597042482942840005882190617942462064785076998303894079234074\\\n        348694572270886886783002225449138060004838714342553552656274112948965547723984004346335626\\\n        025785984576467356485361761008696680011450181500290501433755443462638985563270783798571917\\\n        841159243391120516202507315584340324537059835173441792152618741739691090517436849203838792\\\n        624367088076568558401479441670473247934950410436412282664308250956245397476543823844470926\\\n        986473685223869400699092092648818879542486205012617510768959240169232658868677446514215504\\\n        277016890043576262910971938749628141325478932346593997058323739142036534136734078289055163\\\n        379170009719456799432550245278460151152289752356260428067817460650176806213736947600002638\\\n        660022008863059171419406343485007330880139913008588785202582204938409612973207716626993201\\\n        250056621927957242558592821870184401533547314840874670537903773893081010515111886657222011\\\n        218323210365938286573262632225582604768030616553966183782856420795229934539698499753673849\\\n        901064776301692850247480369834527257288135745819215524598583884547863574437942561864931941\\\n        974113477017388436290240375527258684210230264328078640465783862439852266785127087156263961\\\n        795462546888862076589740748447753312207405494409776891655425049321421952960743984173980428\\\n        117616798275593197641223489004377342402064408639211619072621574601134205540786927513808113\\\n        475304108443903623870882829942970151476178468033996410415954254270434879035561314761700329\\\n        380593188687473219812517483665739129236585273598650087695197198678301325696131683039493826\\\n        319046464636467441393996672569450002784652292393277293140407983298953628472525781480511372\\\n        082108025006762086652024118161205907069552326549553942582211943519721250370911330119710218\\\n        680436008789317255401519781818667526915907244772597632170136364444877620637176891184915694\\\n        411931288446432059101921387714358603845759681816303910245676723041180255418419779013323381\\\n        235806124771970099630522484704804304032635761588952341783756980688258673478370434713774351\\\n        777160490016642666166601353795438442722570057603778844770474346184529725392229549518006572\\\n        788195132505319621789297280788263015823240456594941494852293989718798171407814560797993635\\\n        276568778700132978576613879262046105163386320628840766063869882519254106725932317196575380\\\n        221731743639555718189964457434882343406647693244994258162817682202644054237912809726206800\\\n        505253903771296407680688821374700774133808346464856302964624637463399324255178950863176431\\\n        091271017696069201172858968829871337307718239782454795228560961655189915071545355827356903\\\n        965853799665713454873205252399342935480327509997419651813676499098767269583037645179144617\\\n        935329939614325937886554540772977494766681795262033323281627581096654977680319845319644971\\\n        441398492577853868171540214788270902757226642691670132447603710124485909162640590710381840\\\n        106359665638296259678385317323856751774978424224870220003075772068344893031944293504261940\\\n        936605977426695844667529954597841024830128259286184973679231213308280587935262826536583428\\\n        222130338005891340748009137539591670180244165106046543486209981753903367231768827635121558\\\n        248529772422502568393976390927972407102216610508550635873845712405875564068605022272326841\\\n        508719515009603449859499735202746867542780602842220784530392492266658792295753188979087943\\\n        562963947374711398457448794810989436960093875355947163713901178354828114807372562309721650\\\n        343488047680920377069157211637348931506473782464142432739948987575444992101640410280898170\\\n        621641821429556916355940392977844362526832609390439458201562676763348649451620063051561914\\\n        019829236854951481760447226165084128428392259810081105655481540890509970703622645197003289\\\n        142714701935153966841088042019853782663050605404411477974348648683451683260480805813111660\\\n        587569255688349251425340160730132370852611931374372351665993198630261394117464354524330501\\\n        658360892305801027336838712819660955919297349175993292052036333720401240677541824410054585\\\n        000287651414598888550998236643524684150019434991776289283019444268788609024591655336041452\\\n        629128653849042304536457183738837939894965529857036658752121554765886074602548941906793059\\\n        125987761076253249995097247084791185910349748853213947398479035019614618248506078535421188\\\n        946332436406049484223118516013526370124631970435471801630045300825051961730521649586574915\\\n        669366222587745864387607233271799146382293558582477558204210901882373428836096294139689855\\\n        210749447075635812087527471550697852025102348394175901417893583473132427646907620505467543\\\n        201513917780148392588068075003188390332304289634791545093848268064518327564986979251672917\\\n        779587616079979992945483054941150665517601625157159995616440455390652072297194101717824251\\\n        593820181427502206782378320055206599819867583270974830850969126220137890788152852627148737\\\n        022734401214772659373902922699688124979426080072125395343915244204357872622806707106035035\\\n        924328996099182393775728357369161314770172476532226049995678782879416675563644837742015581\\\n        598201282622763259413860004143196336873024669124711667770038230543479622375337972969364814\\\n        165352907425503687540382885253089318064717355779957473168293507291218535020708377027168652\\\n        413067418311577344441949435967329562262054910355378341396322448937253240999348814822457896\\\n        014531037480718046289094366757892650182254543941592615980379668415926171715548023607482639\\\n        370687100518069288131635664008037883558101091478093488402788299806472493976883051868291924\\\n        979306388435861438062369036878120805434341193292462049013467656406413418514148710540487354\\\n        655724059218594270447454994177539905244698704240313521279828267589679976973924733594337186\\\n        245151352750988168989382537688341146968513034619402353617034854868068058080766035928544479\\\n        387042804871258082625754849516478570650912360637615296722647559820469788641875758922980093\\\n        100945399132429705226377254593186580921039321680463334535130642163156907809324500330170698\\\n        548229736738083231612041204100500997231005656944460950563197218314931307970032260714684801\\\n        379554395098870071656953719878095144084919513596307169303988564374894808242017447127048864\\\n        506736421462303392137643541585690575666937206259315242903889030984059445794092374504778963\\\n        693705569706888963608070083146491203024568036926933230942091016112977967324116961139893386\\\n        069794470728303188488631822370482261744578099357965371253251443174888849992562354017273511\\\n        450206358571948036703839569016037259761262864977591379776690840472193762578332784420213969\\\n        342501507515506386267757044780460443803995850933018729135093595105669696322913305510345841\\\n        883841059780209369748775182892353186781919162135570014462369628725758791573365110556558065\\\n        486141770476925849750622082202604470064463338129344071579594457229798808966188245960155448\\\n        797807944564591453917027406478274603579713298497228014117780396546751997442705435177545749\\\n        559988840528324408011800912005141872404454814823947256438867392809120222334520701208990017\\\n        853799476891588826364430163873000261966377565564281518636413286945465579861243554107211271\\\n        185331741472112866571438815383614287298772243783024008770585877355682068733829054050441699\\\n        897942896832302866536941368694692725933456703931509622835836625159858893594846675127853282\\\n        312822620084894640864926346514014944538320601024067453159402549508817785000654273030233828\\\n        034388217372447264793719587400610102949133193277603430700702721451104029203497622459136392\\\n        378040875950261021829661806046844799164281114875708485341419727782543001475767222948579633\\\n        447019980601050898911783314426519762372258749263797675708636231633187185916822305388714175\\\n        869028208683191853956038490300297643474951078403612436448162934506630773646192208558626470\\\n        189000031676251995352273771184863626214123265348897069671617772352505721604740366688968074\\\n        586850037739620773179899022470521950777672504536417889900885578408687429943159947714647898\\\n        161569604313798593533320609958360379406604332918054209570520636617068848937165195061771226\\\n        731463324875384238066802002813347529071444329383485790310554996365612963628504195686619451\\\n        209854799140088524866829674931031180570782889058434765637389754113935305359998100119585655\\\n        522403352850412891399711720264512430435466101816818239757221619536894670564274329953359035\\\n        180861441986123736015254851177037774658165525587625046445305100743250022693888746486181331\\\n        630171215736401359749529132328817346826518929279299855352163271454136683314018546173784581\\\n        838140105580760347307316203406899368034435739226007501370284423939403578026363914976946446\\\n        490626375806295030012429746632128456144344400234795443544788135517483262042868275537668942\\\n        556552154118981582970809863772928104992248123035994809454468695823974050472863657090880779\\\n        384469354373667164398099375587190361001189900973967682989208893897763944524926177892911049\\\n        013500041921001687329526199935744976193687659787870182299837098747842512635075149601103274\\\n        432855680234254243174383461859945372325486965580032996264681731747060195438590083993246816\\\n        521080971706328087920221144871766985947623022935429958343803456002560353588621277023583104\\\n        730793619033496450390490065982818685785152436239683263832181706239728145101010091602378652\\\n        216600202382355934295393016247154882884507602817251921161257072323599479399498909334436232\\\n        954474288090356676046877299823699774177584076012270087057344923590937058227694561874895058\\\n        200737054512702829306856001325006371368682550733213152251934549319601924536136992047055977\\\n        887178115057126802264598781910059031878390991690259404049947355215285832918204560433756985\\\n        472604229354278548668411261618106427881291267044155694366458534293680895943020484228202957\\\n        601719936645489853302427285392709485296086715252632367989243538904823453201659966831418948\\\n        468661968377856555838511756359260502241007992574347194383823403860427406788978088447545359\\\n        028157663550580416933019629559369179630568483688621073993971292955479103577667497696552819\\\n        757919206179465047605279507096266068311271108805832828565365626045777292759114082022449136\\\n        384369575479168778369476634435278429369040243207487428153409948742198801613979071069447101\\\n        997374984695934443587234832705544269167889209019859104879149198186418172637153508837038958\\\n        356731971915749713655379492245693605207280547209427521190364017934811699234824896619720008\\\n        294558322378277666797508641529196090560141811424373678666808829906670883230302657605284494\\\n        394323239294192373696543314883400045416967716613810699493824736624889989348156080579065383\\\n        097059315833358804784778888158974248758747250878468609422813758416817117369787126093267057\\\n        511286235890503744624451649656824911248233800305052531295053702296900670432148066168177877\\\n        954588785626947385793922675848343550880428877994893423691146659021570538295881147251878694\\\n        037175540445670723058870885532726905010101010935814697201949466126140934516099530169096024\\\n        330965503333157786352463642706562571036019613298613366123619478235455474035672634218891074\\\n        419984120158634088604946437053515250113303352986168891382069098230507838872715248017235112\\\n        630590134858107810132925085711726965678956750287553096998375286815965800476072667481884868\\\n        040712081312033462951849604318457730915106631741140388734927963286709094056066581446801091\\\n        702446042048517095557361910411044016301419721183747876809434958523218582356272564475223022\\\n        477648920802323416574798911219146705302649886135472372633821378255512211377478314317838885\\\n        510514656114977688644347812557044874404070687471662950385695489823028848533109249773311091\\\n        471952065578778221945393654245888224040009479048024634146822830765975107993678946934345941\\\n        757671661873049400137823546773292521835257362413448369402999364688370551934769239818362281\\\n        665931834941998714281004330720598539671234051590972448377845258980825615156986696530741079\\\n        451696475975053811331646680476941986304221770661843105947135826929153957868836611314191166\\\n        736736962931431752838144197580670445022723597136809085048130606720523615370904674428882645\\\n        378903949938208145018885495286328941788632927852952716737480127130332466317225882544265558\\\n        628819609011161157442723475794740379641367212882956939225343509254461181102177534907417125\\\n        784514416942164891102862078183485786246686768002910773198819888648431121502578101301868714\\\n        598831182168221851912255688096576813486452413759666859626996756489900691509751230866143916\\\n        607688670329058044168909763385198951857506091530267170953105075463203744201586278950540581\\\n        374391198691189908059513796598962180258422825606275356267207191170424665830386980758444793\\\n        246806141859400874875835736961291699576079828319187952849423703704544502691865748731153463\\\n        123606816520978363719075125721492930196064601535496226709694913950871676485538942756912472\\\n        425033217538772994235646834896069310503367249121455612674355347649979424335180589411388719\\\n        063709404281669594565708155367469200412884686497226494350558677834635929121403937541461993\\\n        377671250849056636233142660709913494007925915803521537271167077478648194907915849700046660\\\n        002591641575307544370755292021208115250367888957494482999743267417226925772692313899416169\\\n        160378721406425340437468688429181036853251189888217110925038272335892406822811199145347359\\\n        575904247324220702586950333915218363104713002217897400255384391212907139450737789432604346\\\n        170348412056937070450159664579429122738322502495339462263152121350187283189180228776022021\\\n        961654014776185247573892110646775231864191927236360147567559359919639314681728777846988756\\\n        774141746991655398745536136909672464964695806239849297416477269385111528187860370050529016\\\n        918082641763603016458020483193490238819839022084484549577519978725680854251585660704409667\\\n        669681918564953953338857386834182899420298014630790706407206418254715849532216192063981697\\\n        456971892038702769465984435287993233822461438601444224043146294166211446217669108458310624\\\n        548760501890027408614437332303822466509542371436612898067448834659219892650987328170004230\\\n        081380411004189627568619963089464268380293877054749291935205571597136774613223680845217051\\\n        846637105378989974410715305975724481633360308976806013631210517275338803274058190778855166\\\n        875623284434681678845169484750845306708916192820175281072367834190572530063082155686165120\\\n        699284823710777629781940013986771945409847652713617449297956055643809140763643070685418857\\\n        843075346991436271640226025196832688220624823945657820953000141514731328038477753847996142\\\n        675299512761963996451943911711231580624196069657899863692256043862864468446464866654222216\\\n        250004087764249021242372120005132231760343661522578808491116998475330160631194531936786349\\\n        481342192506378256433600732389854724864294083645597550159208448198049182986634498833112505\\\n        554691346353681214647984594277111198987722421243282681730687413669809031486961334227727343\\\n        031873765265880934310721369131569766463531585643433435956398462574843931920217491959713507\\\n        071404366299776386643404573012720736646629344380328594807383694750360278181523207316102806\\\n        905934689220467665377672770797585087431047712097950333274715082777301063305126376006236292\\\n        298080207575550258502417500346913760074561523894109506464366100785102738905124757361144604\\\n        366493131341549576148225928830809545985658630300547378899234479495166159445471884511408242\\\n        885849192829919244611111665854603164437803790439111062026148576147537888500252953161548501\\\n        426929897657258805133407182106466206633787326770837850533991470263758766898491546879819736\\\n        371675772104003125031978669489257567693116143477010090011807533129905872767827483399913193\\\n        151336896748502911926507321942760509632817543394610188998655916074270536393182115298968565\\\n        694561500312353843039843029450648747339826975499283498056594297970288905851780988755385378\\\n        608373597092250845468799801443778977819087749963022228250962446893439185646825931194640509\\\n        234084625318912712663505391492198998880687289733777330851500394519251124099214720569317744\\\n        985288949358143387982604737463502352528363746596589669061790985135854923810870056889699208\\\n        828819745955536370938258887372089795584227708649649146170471940172155272432762807407622631\\\n        412745869741124644387618674258317620095555668605960098693545642987455789959933497524283336\\\n        544140987706004614908969751942404929658980006133144547689538110452523310913688488995468633\\\n        875661152700247214819917987572178583589079623301285595653227876776390686282314697911475522\\\n        281848706363429589683526281914042435214439858916401295428523313433034658808757606605705198\\\n        140668104858946458771807877475253577008283619277310348718033609457837251008930839671984317\\\n        318600088382993831182185003403885556475350208169416052127617565031878587783937835888274357\\\n        120634973550799452542513369483426369263579182035692294694452903684231122838054414528941760\\\n        836865669826956611210862951753316097129089437983778159493520852535398725920307475041948647\\\n        255776711278305306423890041533108724524795859655781013836520500038824965508155978709250331\\\n        591102826864368591497380038852607797935718814170032965940929399592189092138225732259886888\\\n        792014631034223897416190233030308139001599246121667539350368485966643151818921633393114331\\\n        388038389168741936587332026782044022802961362226681652815966384204550521205605534551749577\\\n        536713984074715008299194389337392662915202312468148144453606170679927533023196168939493023\\\n        978442401323996103866295615266854506622056096909081790681648768935996552497264340520114788\\\n        932090315678832817112115513154156598307462471177196283372907193721133912290862442698171471\\\n        055906285082367309944151354930875917301785713916135261496323368948715150974403837414485025\\\n        393998789945680329208916107781362021182539376636401137553062400554950777488080127012446741\\\n        657278249692057266242571525161119481899863719842132437471089473146800528476332131800031839\\\n        374109557943914231913541017179537727454424011312033542444149841561045277135186073700584103\\\n        588581808435194584111005645569646583646691261687645683790909947275907080696920173435152106\\\n        648508986579505035116477981901980821358960059077235720096838299778566325399018443235816418\\\n        801455086097636428200396215366707681989026104218260466993861601472408532364519201665188610\\\n        984078054468812048952344292799200770877655950395158254889390000648215608005824675071074047\\\n        179885280912592576175194581942973456146454816288460115535915725312933987829721595811374025\\\n        812847878043905941541710692657416901770240158576311321892781832432738015770396968587989396\\\n        268247746628982591931313513343797185924498714415886068488574337855978351115393306176914660\\\n        658308840089787148860992516550027215647295871082017393571392560259652369091372032173889184\\\n        519677057879911446736733653871457861292867195942093086627917962103780337271496619529670561\\\n        539586849915441872635242157743834486553996342130765240792794999657049731030274965643619222\\\n        096666965870372259279057695251787549875803411110043506731676793644618068119318642992590984\\\n        771732097498341893600748617317875271879865780472442954636221305097620832587867690710700006\\\n        853624244902311181036218212238813542010003107107459741368377373480385043798340879179794183\\\n        375033488663685235630284822796799217635915777502435421994739087842306358774217842374455932\\\n        643173261277311504467185535125244525295495293924098272833287674201593433131526589616497043\\\n        569088484624974448377542775264292058094374093249190015618180903756254773588810363012935122\\\n        595352885593149871592885431625137058060880742576693320618516370264652643813700048502946808\\\n        298491952593025067968273934934598892220074632041340915793342150690693121521805641654913963\\\n        025208963188202629489494356080758705001846047587530246058502586562055982195306444458351206\\\n        227738940364942942716539221388360926293623938158026562676930522477458575540778366088478371\\\n        910367409095594256518014809709948935747603429294215341327910239124826738694653144604642310\\\n        337600385130994088265831567079878641177761369470140975883299592012190125345247712990193208\\\n        533874773921022390735450090946703165969474043241351899789642150674908506100450527311577880\\\n        254900276841954834738728359742664235556358541211273687249725404535342772260626488571994659\\\n        131378462539850401315972765028829748033438854142554099806440245872629075158910836528438821\\\n        928880002927845221236188695967824714455348043044785373511432480780886919614511940826001618\\\n        325035927556325527663516522625504132698272472572784015404240955904796157672689557037871114\\\n        407859017805710450085137609006306849504507882567072169475381760062501799664360399094367705\\\n        724511858041829293753487755618132475776343504983182197499322730221902985640633848031325117\\\n        538674153301581326479467078044437451582207140263967548473549720964972458385246523620361544\\\n        309987437774095274741637280756853992430444810359594017615325311788876733480114048164770793\\\n        518257985850765333084769965327133569456015996254315691275301160496921223248648816343067167\\\n        175895288234208350769479463264107878711966554992613029017064283635108494221198502355551981\\\n        112780794324937942304527197199793711142904139650448516810408932016244952836087704912480012\\\n        442867474225162838684668807775079605189510910841442473152834557239514647855844991139484864\\\n        776911369403368526857584392930942017200941038389923929853367783820844778966904460854419674\\\n        614184200773322604909584673546194692347080868933883955742766625112226004861517059107348981\\\n        585434545841373102893041079422961004553474946292926432936318189041214261538654950273963438\\\n        478327222290187571527129021448429871199186966881109071485258902006011908354896107109627317\\\n        434684304467033823798296462769332481448831677239537780796326867888537305159456069094800644\\\n        676428628320613877181303959680450017545053557622308573264353257389059078953462561966200817\\\n        221014058447925704929866466426854953565673373230151196226675173011304150086307105238570852\\\n        337734337152130196046394979549466083110623012111982378166542122123057078454618800100645323\\\n        432948159837265272345183782832538270722402781427471269498847624121895125060444194165711134\\\n        691057918780413748581820614287871328578900381435443742949170209116776952964470303558855228\\\n        855978809317783478215274429685586835197381547840418766581409892381246346190919286451655905\\\n        153372068469716948973629584705312669685335375266952151410470673742485244507782583078835769\\\n        648726095928785481304673855959090854155377401360972817779138436388467183574918776485117997\\\n        535575509958361923246831403412013060992487820459459212690143206386874451312256736233787026\\\n        903621256865280425543542462926544952592197187403446082478506243538014010399206751974445899\\\n        659228342389825130732789591974039821501991692685835820327897298977949168581195164381147049\\\n        069225574463878399990995513671163397527441571538087041691242815238754438765483336091990137\\\n        547005375831875538743060568726230745501904371281246868133851790174617467859689651620692444\\\n        818595522413392437020641873028565002209338059673292852068302760471436051682548926193106495\\\n        156551922836799374513717217496798763484906720156196977239157731781244377905170842639422547\\\n        369943700986503421728327309802068884186611704324685212374838179784173714522002449706217511\\\n        219361989829657188939157964497432649545536469841318107730549540541640800568786071609127566\\\n        896162952104498721953356073921192754197487228855568054712008009679280042370303092669708164\\\n        179422421670003792118548182701317443083326834776600587370982068550650886041994723812851115\\\n        228984024518297357147740841977262616628639080969560444948874223776733733934931186947809189\\\n        673126688802016297238325517208884464793635001124460404187469821866392764718984192151795816\\\n        576497943567033008702700304906235282641899605835543494632874535780165344544721944168256928\\\n        474737028667616188774561337879296140575311306503048139768171218780750729055048197844464812\\\n        671920795581583502942282289755114454413668735859384168431738887011559879809920689663743047\\\n        292109766394805819606957536218180260990097458991639635529295906977113648489690982424441790\\\n        973166992682783944366917562933458876397849726735743129721682576048034124533285626693512809\\\n        349927972792511030682549654490738165325302818261115210942246423784796443488796123535813362\\\n        252398598004734141138449482911502872371122707056657537758738997799645706217734327671712754\\\n        904055387082026777862538687723936187353594247560445797517700479681319282010634330742062644\\\n        352557416168177455256185083555825858152879953637934210888363450470123645722649743583450753\\\n        127881431060979918127127665935161867099277449980073425825812804677490579093384492235949288\\\n        705923957253176445693973454170744568302023961651630949481678806634887363462989233072139279\\\n        454677823528869616017627004713284101834175199706596423120706548319217841878968864834900954\\\n        276011122919458028173660958160470986072363613795227554678728699663834451728276645064094868\\\n        459064637019291486216475976811892490445990529035298693114972940929890413678875463484757887\\\n        567672190156647717120325440427318085423236870999553401635505694123235304720577656349397231\\\n        624418350175751581758352552210783136679757943104520768400285169971535360337220529011543236\\\n        066434131116755377012500764311193265203918242511006381331297107624482681775606595305124841\\\n        929381168620707247898515888081379578290306024764743486878381322956337426338738373818002638\\\n        227847779167773690517644606216195392048737387184762731778339831090033301996359690039626774\\\n        310865001363175278601419569354293765690566087837812321971226019526966919891768624510372983\\\n        943368645907673289196362691584732763058239544140515322483169172597041993728632875681730849\\\n        601852742173355728458841831917177087176539717846849696221838550829661683754472038245627289\\\n        430920289653197610923814271103759751062727570343417240348580581361013836185109865876023851\\\n        499633554056158196016323535435081648631277990687589580472540044753003235787201219354237447\\\n        725269124652036304184312136093631795857012284421021118478145688415121910456122904892134219\\\n        431338687273442314434964911412800419589360259188598480112623788048547503419868351480336000\\\n        901703205733923695367617228065257078622694801663468924606705752410362912423613133413725572\\\n        192746998283367527375326959204606949070135376818430811181721436901045012314037199995526652\\\n        759142917842265915782198150309401048830583482138252649108734359957595256781348272385493493\\\n        430730969433454893163669698408543599403713839583795631981156854606221962515334985798414321\\\n        558570860050324745351557308080612160152690567520945298742678167806480840083420705893132001\\\n        529057886289004982084528992823457869327195417416051839159094878303892277015135112370242346\\\n        419456007979733252073311084428665730637618353389227646465987854667551628451022119576965717\\\n        628209793854603480239318257660603267324329298125764992110757386489775097312795662594415396\\\n        786166980560811602662650723701902209225914106229281534770884504333033048103406600655775670\\\n        144392741430397594274634267022242233930539603000204896054938105818427330145213493282905795\\\n        139141424550534606025115251671858188782655498937127022308066390175520348455488232883023187\\\n        537531396347759581940961635984319812222345216829774514065920376430652484907637175314744094\\\n        040467803910155587855777604472591597910778605779893376344861505509967170808228237775635609\\\n        963644877056145463631400319795768370775805581142200002202645765132292006491886263613250423\\\n        861720963987367813961891354543559033448947044511069238506506242741615606021917939191686286\\\n        887184012617264661768513027778640053296358860530175854998098607560846359436968801731562369\\\n        288042212257115224279290423367782672368620504504619950259705114851657923249519282136438495\\\n        111380071116544601688224613544533285994952023841740954859994663136897615609303434690826698\\\n        449418481160845621879583958984759437313612939267743015304727632480424198007729147591326441\\\n        273418398806310590171020711953247333268915849872183522520996661097541282516334411147320022\\\n        336243627555473684309809879048482946448391155384968440716937847979534248472293739803421702\\\n        625633836332401767135183725753538573358645289160322991927433217210552459351224536410997903\\\n        945311316279631850846085975124795033512688990390531628963060836412769216312032806529641592\\\n        616440068239019129545153112316237594054863320222703130339215808643477350750059368958799609\\\n        553700408649621925018439426059213122233019878045715315168622114024542106985951486810052188\\\n        041506421559506246088964266831514361927396866631129519406065262614299108486353915336663913\\\n        748546743468553913149733001693744560204344106787755744116370027581324758025263897186570824\\\n        702626866841796128308021889558860882615750277805285467130116277241584813580623886339866777\\\n        714815214646939589511749615548243759225103181654905423851971059722360506603295604107818564\\\n        984757677612333882077235567194037755572915845777447803120440548151174468527666151135800143\\\n        590573083774315343488094622121001681248775976137290150625250052982452002838040231374146548\\\n        364675224011234101534836142437079669005384518241805184963429245659677933035533235875839916\\\n        332264978348312226762990121001018931695613008685637555457583893736503840766894438264294005\\\n        921722298861661927507790580083386738641365250680099066901131685490022148479148913920034266\\\n        604661049873829401818200273965657000825368956894159634016498331327063990911362209203796939\\\n        594877244359345214231956960280272722811729708607624039145105092602046740323364683675495946\\\n        270802651274368638050443040673238405154490734140541979532108799172532233240035552187810931\\\n        062979968311785570606174219290457188900971404518437725131044267042295966546602123578291081\\\n        853323572722560498937798502690187686645640377399046847826072641987196041093266856735701560\\\n        019969335802694901903296125082058823814024093945817959998720651411787297429465727990449232\\\n        941698927020569820054032106549163219329051423226910691062784472466181179743253680071980354\\\n        678007191016556089142009187353794547583509100323102429329732711194603545338939363457012597\\\n        053928981895141183823847591784045719245228182986250999564003405454580140636755015738880185\\\n        876765284379154166460878696547136819277545382157518855576442628949329206656637490678993956\\\n        482835736796627024040677516606943498338188118411610459046420549875321352310477599331008774\\\n        143428717464438134906737324819278561874579090847939259350048338140884906400421654693203462\\\n        104445261645043919658894976155358625753679238831372988480865518305377219517087280057610675\\\n        447414427755897652403932151231649748846593696044695749803700006595254056851658217334421354\\\n        930834571606315670809739429852181519809969230490219011877011200461512336564223002946760099\\\n        107259521770268843068175886859559464954372794985613744654197154007589202283353354900032540\\\n        952380652191063368802131912244010981829751756497808242418833487962233046174282598494833621\\\n        550171790387485343492426525174279627119311271788207187153915125066292176829361364553144009\\\n        256284178029939688690356183885268036616094932517824244675406521441645595629139752661937163\\\n        690275355537304388512088996932551823747651639557731457446488763872974040348445709646620279\\\n        167522859492881260434242084235473152054576394597256182223411996572620190264351042188696040\\\n        938915434494315842704522273924140954111035454544461046748062938770588301763919631654091722\\\n        288931745429095811307129662572042540784523912087505438419801937323657571015439936891089928\\\n        287313957681873931144201581724457121625465582895724475981133691154573171705465977171558844\\\n        269259122377229804675459189548320930490907095773184491376150942150491542694224509995502433\\\n        695988019712701776856815941672064361994890248374704543562215868991706395264019061812270200\\\n        088329733633497234663384808656470042749430872130198511102013249897872752525455504761661537\\\n        866893347224538184942960047641268411093151176643133870154189153427670332648540144262549626\\\n        966280707940703805292338798354546790264906843089122949172445490545307053414478557906063544\\\n        823071077897620824767016504054505142444453772410486742070858084103268313809251591002132837\\\n        362881270433806439594856505367333443072645467361196227014362547358802791906199868135658114\\\n        016039881260628495758407649214636883076122375843290581044811173890473331231835630081584475\\\n        231117146032301909227436308997486423339042481383789393931305334876011978460529431024617553\\\n        483014707682648154903848409606732988050936204221089344699205078736594091501541975366727144\\\n        819492667808484312341076696630500099843237246267595079129483649332886940354552269826073494\\\n        553313616838917178453425339467323788481403416395907541032636974599093642713907909197786654\\\n        738957531362447963921281359241603926953623853730268454502832443516547185890971276490499199\\\n        254566869545973398731733506690953190097793709692392016155643548142420219206735755505122776\\\n        163859312701055529510438479551804887751201222925413686657293083775673920465361391535529833\\\n        051638753633501448390324133613170651763669464533235980463048154192315165123765419147456572\\\n        690557259735077575087451141467336000919469490795149014313562531730645490792926863644108374\\\n        037008686795492894534336118933103923084116740617690173012927217082742181153660331557461569\\\n        952924507806176883439421736941950897960520463270839967082768529656264771346139889691653889\\\n        200718000671354515652853129638170956993387256479262237598702965711009124650176224184606494\\\n        182355605626319686535299758673791184305773080200523137212718195823260282635183316289426686\\\n        295360604408201005097761624179072712836354082317540246761045527528841250924723135594376783\\\n        503008801575197572600792830633010755050395155013263617087143549806371159334623747287660633\\\n        815496780646357244731085906891453435654608989642420840604354289302962174534357053026263718\\\n        958724855388159438708989816981645338610864316153157007602699176084991633677791954552990355\\\n        186394053973368510603774057684513080155500801166237853245540780854744902648328948053896616\\\n        372245103459709984908824461713642510641066551627057583696456733815213988415531141122745367\\\n        271501497680837567840792530422459829799721566728286179263340420592167515324153591612920852\\\n        349882741656168231853893535951237765554543073391066253667251254364533091695627799245351419\\\n        117204989278964963149202476535673627171276351392130537602505636488792705380145040276041992\\\n        241836464723876636315910716869502735837205266022487458105817310189739920325277224126992535\\\n        042354962778551655478046919280540020604422336227885525746945919286681066417396976926151039\\\n        929176271599052058805730542152058722478436018427989069476244645261657324796182617410802386\\\n        284952997750613892095942187245815835093485678977584230209252632519575496700830174823534907\\\n        471144879985117303818636396353541020549616037836658748919816552603995341254954097518758781\\\n        668398585253485579592709983462793439426738885707416693175567721212953692791566542436634237\\\n        018615395864454201401351355643293791830877829282256996868635233954935268543114204006558827\\\n        725224669670305126537933327190238338521740664146186575934452409647796014963889208342646313\\\n        877060544538021443481193566310078173930110461476024351244312189465807713927489624490760901\\\n        720571126590025842913625694567924779710172311320839579864719499256446689906457647513892936\\\n        378579022073209576668093645017600120080404356439991497485764978695441950005303130443876317\\\n        815412734160795160410611831737953260549500264220502235907630852386009070820241396677497564\\\n        494445056865979083551242676452371646756328885874092211872139839453070502005889191650468822\\\n        970048307448066481411517274027477374649049662726299197853534692428471811517972022273286246\\\n        157101329073110139780175342330573455135950927075981538354601990293892315277592462115182369\\\n        799350794201956342670611389625187567280288771446266226001347748593073240979400822044576429\\\n        095434167006414638068707399384366649794268909125997230588081247815324753013673752129921948\\\n        696097698485315202893683201186912565299960659863089812350949838717100225802638223180163497\\\n        843688629629791295285668594153086900196257037778640593792435249392067912221303078469883881\\\n        055423622047047015456155042629238804054454446097557665708337335723065317445595843816808154\\\n        340338281415398904065071484114065308061976012585427361138243081012257687446931165614731240\\\n        596387033203035358606359524165908721957850025726413450499250428992098987716147003998837683\\\n        515854968056682938431142314592775736587677446400402538140527084060211412095799292750645891\\\n        605782530015994333026647548854438044704500479967594438784640998121633992018419811876502852\\\n        992899359330181934285656433729293886872166265010529520435646900002793295081504371887002141\\\n        837346936684962469159472048441210515385515646124864918035259717806754274938708369612967686\\\n        054981841548249247763773106230331766923461670615280454550952424727673535499711666138715021\\\n        593024764323136046861735953790077368681172079495603400962946602788944236581849546408920971\\\n        512877495944602577730415946234693707977439017676801172325896389362697043537435288106396920\\\n        572146132687475025616200866026529980685610316041927692458692085512223931839257958750800569\\\n        122594572606745592499633656545819002929969608515265616419117341725560501390196925968636095\\\n        404529600234088540435299241266642443905424966053306099754705482870221275887522093540230663\\\n        749878858631259674567595543574524956561923719949185538303626832333802762850908716106922554\\\n        793899351405907957481839918413657870050584823224181977440865159073961571827760651295259743\\\n        443745796832455120191067796459463220103932280285362696400304723771161094014932727408136679\\\n        247761580246491380140322524634706908257605744291328950635949981067847690977636217869114836\\\n        248720143960911559912618965928459957312505865237723188022958342289145177214862535925771300\\\n        246483490673338431349619600644314469440141640298457082249728909169584061902096168609595094\\\n        254011441677240327874780649799110031541749619473684011978042356361939965919930775189867909\\\n        703416297642062684354312945594219776262446363710196427820501644193211708107677906724593254\\\n        122048362707403369284821683248695806150224019176940834013763112815554812983878765072517143\\\n        909200178924465014690996188683316743993613142179515235233477734033992948202528424319632316\\\n        957186149838443099741784262507681606931291920180173939665997622716354338043548758323605802\\\n        988390112039438450361130833261140246809860377813984832808736509178488930330109850654571838\\\n        735709687975488180985531948814853308593947934163674873194107737831586337877518540771817952\\\n        486897756729595483554571546942876642788075747260175205393934538820504647855797412133933341\\\n        150295619368981893115606114359053745322996558791598093588333895337587779193876902125222477\\\n        202345428769206146299152055362981704974312820550685242148820252525934307247080833216366655\\\n        895489695533087162381049016626028441882188219710232122865394117834956481945242377982802880\\\n        074269519649891080341920057003675189317636762764876777297816540169431445626440807872037123\\\n        281145820198572770543301049516149674324582867841728445003487631455388135883847321974018063\\\n        631976140544018227787923428462405847675064760202476719743078655164014934086658773964779033\\\n        697155650566184025526288537427402954350382056445874360598498157839797050489076592975994831\\\n        658696457599770601600296197163989553275028229830051698506375760026996439494242468084774773\\\n        224519038968069123022081375791035229962979372983481997448043081645030047664987569102028117\\\n        067216995233803829353235622454774935703127953543224190849710558172030512721394142598017441\\\n        014610377125193698515308206500393258371594530596446535713368435662719221608484622823246168\\\n        119836405719535774611018255193583588846308891712568633375970372746760375384237785148881791\\\n        182724170203785042329752688631752874087637726061252694409262382378579189310372667969532958\\\n        964044292842859108203447055982016524451492987616755547613268909495098098506830022313528414\\\n        571851000427608220231143252243211583079237162649684633227812336390353606591640111568679470\\\n        672660004729670081587629542485324240181608629450414072312887841873475057989590885253690615\\\n        996914088343452327047361222076641056705867470952135951638988173227016852206980245245306658\\\n        163253703180975583471640598334867963477100770505425504653516733266353026860249803818195794\\\n        657716705156987413289510536732425103524885665182808811859183936431991017558780747690022776\\\n        261822707669642168020221614707238997578125172949826987620441221152261708537467610534123645\\\n        635815578797527355948927474964688403683835831752634381791769442981886984745218859081381288\\\n        391609456757302887661957155929273201639154225627769439719319574969385354252338691623466064\\\n        787158116586062221053015060723335304285554336587044122090140903819131165215427897789659931\\\n        298063774232485100349560470892897750567944061248022804595157350563226659673149085895763148\\\n        970800675838442497742282108977018109948522213101152392754479050126003575218399879379451583\\\n        044489083937213808305783056105236440267674386240599981503769189506156642131580737729245325\\\n        096367675504212875551510311767823903141704112228849998550512368026496254594097866169240373\\\n        401517716767439427490783547656590279364189081870872939895298786938642330886798639139939449\\\n        945086958900072263969446932159762484155594474898101717563125144158231563076003831363574714\\\n        284906924830587275427617664643319936281691243745914586278390820657349528157510885468798375\\\n        432338623333783997168478488378709845191316720124333770929549210774451492979803203634314737\\\n        612080709982283760357885706850525557986411946720525087953958189919739803042199611548747743\\\n        915672898259084949395009366409137962034517286105208780318203157748920518316226396495117264\\\n        731878351375242973266470841362949576624255181110119098064858541040538457518118684446355636\\\n        591572564429081779039193115729286287060662920043559371002676135438430820277679620285788867\\\n        827422226856387099125804878591616297907799860286766061202714968219822201701719585959316424\\\n        754575959038439529521597457335348804413247104017752238873709671805893945030045541366204809\\\n        982769677361578341907565406581655765794412784908554489588863685757051362057955069347653130\\\n        150864629768007836570723210405434589077135672646985706346743224102419989028412874878217910\\\n        276420173622147510278704867927789434702329973050191688768025563163569591447809339680711218\\\n        243757885897707651953178343222290476436334398907540791930320968840854104822720135878756290\\\n        574389793648411830656258399610141312910547269502412000176449059129309508973817558234255812\\\n        284733420209287151951570481435230982499548056078418160753430420382726736861015239567473486\\\n        101632902167318485859899152466893723075533299756665194331566625184707687028909429868565900\\\n        140075388054386207475274509423156596008794113354204133093439493756352419923293093236593518\\\n        562077970100508894837686691376282859842459707737504139455290629463424446460724934304697959\\\n        443622787280741941237511165281255875551103155151127323827712113301441834748068272871176536\\\n        264007762834382874419620554315549222707598407474944518958834023566243698928325185938114109\\\n        557627796397995318586161960418020224300093292281418149545729150868125563120346246770960489\\\n        181388454236083609759161781935322553667083756994769960923969310963645109898578805472267469\\\n        612508878058668479396217516570681286183509625609377372251189354414155073850227186955262400\\\n        929858309783855971869950349465225025620498878111473413076733707397669961413838680897321319\\\n        796195499838277017449882052919082582942126595788413743906807790686294746569217096127434528\\\n        584366521921196189420655599364654780997361441278100291765306456592591663247164322744752251\\\n        480931742736770802142639913783345572115540034002736282000265761578801912050716263470497014\\\n        779559382884146701216425718664709423048678359430216391478266610225861348535450075122525236\\\n        339338757253961746035191783499038393602823196829440097858539570417248033092617870422806576\\\n        652665474164241121467514923924497431521057600997721715241301873599953786540716328851570502\\\n        710321959743430685390099290964415998316750953312739477374790778640088806265330100493152072\\\n        056684627636724932000819025465373034474891532298994409459294130307055392216968674868748097\\\n        211075052689048737991434951206957562505575255815888467109668046208500728918054366256426871\\\n        221041885290115265236059467977471821182949631885153012900735929751816769328631381375750435\\\n        084377047370334663233017787334994101653126058507910051686295172359750369716921874730943108\\\n        132709436564055819085426413757109448659277063966618939388376430054436088771215386821737435\\\n        690075996433493076520532843209381857025141163218630864462190575432078634701126281475333775\\\n        594535766667142419245776155495376080892483998920511740222274436157510001431508351574495434\\\n        252638148497313579156323830882433816466501075318837389976290650949616656281319578551667489\\\n        863215026461516419550139247062830343415237360973501193052176711511636559510724430029199933\\\n        046902513946121033371279438993261212425598752569958393568397370640494934878975026343845120\\\n        074720603377163574441383509531119895700058635064877365133659788103346683628685977825437171\\\n        033575327937780707952581400804353087792048587856797533864521124320153058689359106056496447\\\n        818971216166477388428075703342203165544232342781137411051278976709383110278414771561194912\\\n        547980151346029821562686372903247337065503594784404403563297075337066649758036302993001961\\\n        776808486896248721983772414195460599522938721321202670979051754324296627200216955201376750\\\n        901882035377304768576572315002378410112777435739414908751182176817126105249017064455253910\\\n        578775174810611134041295044277453954218837746661448229396423010403063476625622571878167052\\\n        934187658981493710609327599418138565982278997476799605615957208593413403652140162550969580\\\n        931169553781714721050298972346886295014695337263366315983584752599009946391412218443091716\\\n        384539758941330274720631407488635448614642208516758849476426404171837626856127140831690760\\\n        974446495723750144848279607866035454759959119533612534020245045683264986701418980504102235\\\n        073408030654201416702312141173891906404391820316176659217003518769009698890738963598977852\\\n        245550944817667825877321771179609531911125738522507986285069868257683055070856203489232010\\\n        704725907756768696535505752752908562720698684472079702796694011508261302362993160114469180\\\n        122314261340759549772056151997044176294208530591810426092752431119568036411535437266282637\\\n        956350253846382760939159401924308292865783353786747820732519920810145743091025771152566283\\\n        470522471605254121546945279649034101417930151117007676995584056155959315468657098188998468\\\n        207877603573787994553387555642714402561286075554445656538511146197976416381929666513821398\\\n        518318401275120426479748459892198242565925319335579480097959627371754706210580405405113964\\\n        674463459396861778570471624686094463714169423138143076369764627471660258936037865753033878\\\n        601584576466022738787031294944014521268262798938372254988616151069236477634065413732165238\\\n        024880132173536172525985108259192059220778069655864353484900866797668999862661213513805305\\\n        337430201544417732188439595381268175505370534467946080386395821809204726442846303888406679\\\n        321372790541692260024915492027621776917453003626622962664318946775148218801295500139401213\\\n        216768734694958406657539787878226281994486865335672954393110267058953852229451178968850643\\\n        862429897575048330461296160496193219531840103596627960909061868285464212342257692864906360\\\n        684003615788989339014108130024349668885209674034987869741095348446672126857963876141591360\\\n        207803401267721535147457848155266176654871841382207019503031736823968127486667893985715123\\\n        822346937323265204851059241913133879189706765813942750589900250651586131889521928639827224\\\n        846667772533759694855491804982391369338372181466326782377700705222480789950962824000285887\\\n        070560091561314400900191687959896022953480437404137828658111670642467319254539555887497414\\\n        939307678214606678217482594554644877911215789277691555685639537428080275814919310660746165\\\n        511412114536471392562811405350002828544168199096282349848891098274510735730090641896918551\\\n        647577653379705584775501687672865438754449430118697815680026748350203434493137217281911123\\\n        450083459344805346954888233694792105991211267468780708141801833042504583679361454664262801\\\n        052041179494374193769420583596339573294816578067466225137432867423343340226063529502428710\\\n        090615186211739905511110973633464696930254757364012695266279578910376167059870673734414764\\\n        965189212146477137836543539798017431898429140366595021606831926756121882689910336365428719\\\n        336995704697842514027149309799394645336175255914137142866896551340489270507741574316787485\\\n        350406000302121776749740815144381872530218709554181522666824299398745939315092476782034729\\\n        224125655259979828258619137102500737350226716868487624404875450270678934185208213954029910\\\n        256717008664423237084722620831478690724794968006987972042243124060793666154670102393007588\\\n        722817667453938758993471399917713563038087104584259408977297524853068814654668663221489653\\\n        324799143015782764801283364111467333609343205819910321060869126848481468693824953323656502\\\n        287377407320602752817457438300454606834872039336452272937291703656876301636799792144795921\\\n        287579076908967071773091306954347037457060983901588683068310598609347484063876063599214730\\\n        082468082993286173302819572379791038181876528159206292399218825227294679814521719688408415\\\n        982048470618444067695186350609366166511395020564024666716772301532751353973133335176795762\\\n        848642869590898139878990872653392312848453682184044967410026468842533419910672298525940088\\\n        927689845006448005716731304691942204842288999211816810001035606074210117554605075818589863\\\n        804866033137067903223903899395622153044872411014105037600535841901519399973514484140147236\\\n        742757367957527172861116530498984609099580875321813608012228508884586401788769261752590851\\\n        876107396620551654047502251556921641393254209879620901404908411438303454063408936849490837\\\n        827389058247868231689278126116389709561394168763653130459998244029265513846391142320822340\\\n        240515759154767563192890841946249055660238548863335872914044073633359768947964211172467828\\\n        544413369047784486950133938560010847840970361096212835939307713249438184810378054832779091\\\n        713762568397102170748862361041623462911627703317076656658774605486114986048129463657557017\\\n        423656715503687074608490249070232059085433818070382697712080485545443846258076330944860377\\\n        519826444848273057457042667312745749471459929041488728279192760243702715456727591002121535\\\n        758129866696579648531353932731740226805883349623974248963632366625869625185299304980037103\\\n        522771207736943557911533448360932679354187401475824193400706612836863727391099296678099212\\\n        116235636077491140565006517659764966861525707276536807801267466258272006108282500583492291\\\n        988585739146971745504232860322592655623097947542137534386738428328557042840102938248094955\\\n        621209220737621159134597469538672389336422285360148338085371333565801200939287459194618519\\\n        136458425989261833351269750747719074036701791363215953951603337225545648456688974106679903\\\n        532048983531683722876349984594103276287177285762392564350218095967853763610296524891707952\\\n        145621130500166596348198804913082662303306103475669779582715904782847849700821449954492765\\\n        255888886173223136365274703996619283840478773622951507959945000040782961557921148115050540\\\n        808796003704733015687000336178714155545412436967601064739956920179311963361412610542649875\\\n        587370160838911498122315006441705556435842560651233203548955475527730399568845087977461583\\\n        738427973175844537942742165776052597487452293319536582038851443883694624289743807897103264\\\n        998974766133739756466489651498406590421355675325832852287089389668405001632530125768282630\\\n        214503738487735685504207002913896337663291206114754848970039227101072766322130115860161409\\\n        404148115399730576852702218512087421163525490481070550521764620679120349264320362544886313\\\n        812991222738465125783578808319939792532649140554284926781616127170317202365587685374186950\\\n        953817981429551067188559808379663317528989704059896259420831054229908328875427834511542964\\\n        116954222103339996002243038491158549604538160728944790674649239512780363003904016748143244\\\n        616917227459312486171996943692178556365364860074190255243764659929959979319130566295176092\\\n        045229857037403622028507475643854894126789328056977069390951321204615958519847450048064693\\\n        250993529326966967778976915020632089050073897856446524494952643062257790230205646352160175\\\n        684430492082168202972710120408485227575159773843359698561247142734153568013856216843450885\\\n        185600423422734385269153061712490727981108786557998245545830514480177970232278642772487295\\\n        649667097809192256663486018809921863243087885066327839947654003202463914521645203448071058\\\n        569567307868703764131932187378943647677843407999819050446162922601372979567161712422765806\\\n        989605610268936643345584545047778610459640458230563767923288391804906259485435586293764434\\\n        688254566434830527404910651054390355274247817279071605552535653282604692695075998341952172\\\n        805554932722879599935606204042406690251710273353434278200528562345390716939272311822102299\\\n        322811370146413149652942169243694400972064387623435801842895919326095705682218534771388681\\\n        743752404736790682775656627809828199647360395926664231785407487820652922800878640096232939\\\n        771903821293890400275267435357680424697989691912330078317417518730166758724006945527103778\\\n        717504280046434735560607284359049836034996462100883496173295587148651464236416573390265852\\\n        473237718005242548022477038781094543352125972915921230816793842309269505972762836582634998\\\n        052278840391814047946164887287117919162953539394896729257301767331603692703598708725047413\\\n        146777143062123142657669067728890688456454651207827664760988027658074210242506622929886694\\\n        805280715029830078882156899554442029104929138663960872347437543190881473046715170357903873\\\n        786615339602644769795162605338940286007243218119662129094440775702960343676753283188232820\\\n        227562092728438357712783940537322752183820781948863894430708672194643200830992525091583757\\\n        470992571319254242155442969985450264554720548864567392914106967041267872323770716931639236\\\n        851365023461637099021475643511108809305394279809106764577261129618348178312871817873457696\\\n        903932308538983751250138131643555411882546740029216330355811500328590313090339271455886189\\\n        041461311308907571692992685796026421068218550883670782874500629528100739682834279597862479\\\n        632949750315797498315195665997435390290992172317021443892576341101415507024938129577021006\\\n        002084988498959481032968901507484330926846643860254770297572346789307840072780215018295912\\\n        661565464442213291350760914731973315005761247139876304935036483485930752535046707111180191\\\n        447665647799844773992623815527270535108419079816332545804252246970646098481698410835569382\\\n        329162124607255050941926595945073368165166748133360942282948902111130240881669718119698340\\\n        389864296739047289307781322747066674687382954847528281234439632858276133601447595262048165\\\n        647155115944498270100775232362769828174474106706427862584873173006938364593930859305148123\\\n        718896460504836061373805833065676434425686648302373454455141753341106772530847320033137845\\\n        688082436397696227390905915594486389469586520339477521057283522556441658293947339639040840\\\n        279257012142671054779886748717085347974861901903949949656759902631926113926023270177903507\\\n        322441895704141427280933738550622287607640417475737070004954689291843442516143467093815255\\\n        148189418827500851105258255003786494682745553344531796599064923058206681437075137140650020\\\n        102180857115740386708489919815869552754711436785584562270092627542941241590966644943215183\\\n        704344784580682549588588563168234656360378427537465040068200833271175707764511855857590516\\\n        151502474098775058197278488525535690306513210742088600665578649912559975663600928054911180\\\n        458660513070251790014056228473885169662766419463049086020167821717969830013205635834883709\\\n        585179647462160780187826676098496566674983671711612877000031189575196723464709460576808692\\\n        168235038738155078455674318559124791162499057433930694864352281091202469815620738756101726\\\n        488238983591827559119791366438750500816674895809693439707483619503967005140255549282158186\\\n        456794693145797194364207551614902896992348702373287385764742570161672306750218953688851313\\\n        693576536616452011239908585566881340801134723847977541205555391298336832366130730706025121\\\n        316107242646317378049501515611091043349661266453963517697316853570679891933624240633981119\\\n        880054668938742460701075941212281762647751522812941447144803452482149675872525768019408690\\\n        189459481554922869904341764728912295221481408577766248272211487879922741115819146615903641\\\n        134183532801522434254361692615347325300891908763647079645278114872701977828319027820484443\\\n        937102763070085900687805851931979911206709044000463575439290567267513800731487543088131049\\\n        751555380213233501144328537921883066157262567533370921634836322100786510087374724447212602\\\n        873182049111066677625955682700296629518398695796682401620908164534522830880637263675317173\\\n        144858038530042947529182166630209861240336341589485292739067546690393931167953112979578862\\\n        714762026263978649706982813957202972902117899499801765930727769471522774016430121154375106\\\n        028098886036142777943768358836002168924741217552260879626918886079672257908204061722414576\\\n        399617111928281791929601075911807455719637548060626412890196528147326165790075739483171421\\\n        083697398645878209141457435338543092508698734098460748250189922323825606189751448026091119\\\n        086801944154103752737079535959369477746955835895855987679510682319303030817327947708551786\\\n        053272321279908473878179346244053762687480105722671323061810393391452184996726720527608821\\\n        254323356936664107605125559895336126758346185234928060588714218199542320467560447181090394\\\n        801398713975949329158765805685419917579698884606144627840494650517891710500749382662040785\\\n        169267779127467673612029084700500994533561834987763554296598698414235943839589643734252347\\\n        865068055821365994977421487928678081053117703164932045312444852211842680624535042994639611\\\n        844740501250677675921992526530593593752327451082554645326202898794834192818304127980736697\\\n        227122680169241257054224516188838701977087693221660348210296564602005866575062394765179828\\\n        895030548446977179596960133185177042282709540680803624105378860282223588844388051285677768\\\n        548522236442113117971623733303424691277377728748050493689323872332952923127572428319017291\\\n        140338557107264275543823211288406521844164857882666817173378547292987257630574334581422167\\\n        579005601110370909214893549093414249743913933731163106662869547146176505560555232630658185\\\n        157055365810675397697036376085186500546424924713792878571110401322040946076780234673615778\\\n        193687644538010738449744111821602849794307834442828479782205711258770041632361537578601559\\\n        409858927825982798407674817410913340780001014801687357060555748428044126714245542153328999\\\n        301314490269077805553276067458421860352888968428197319403053667402887189743588547775102641\\\n        928008626119297524678270483695602277963225677257210139184089139800240649183885555027962534\\\n        111983487253968640223935240570218802951660487842190416054536004369198129626924190839743520\\\n        585608819283383118100573236637836412028992078264980098347398702322729071163941860710482200\\\n        492593775496580654367378071996208918967654767722804124889301005265265682004577296163019137\\\n        980005081954372498106947841182579858416662358876444115286256515364841086564811464287223693\\\n        089167106406555017807896126475027003162149652557157345418072003807414517715795334434731737\\\n        411355535702190750454118957461693161841575545292944363551191848284359882461706924534834583\\\n        572809620878985592467349248877515761967342496272828654505877371037282767315567762439334209\\\n        787835109610077261304863315193271310109209520514768032225757491789249630664028466675125157\\\n        203629058305024283393138243165594141501549953296397229467836494972090060300834360365802152\\\n        120955002512477338930401502577353458493466585650585163324347638748973668075390728588155341\\\n        059541247395288285478112058062399542297607442979637433233675890825405565427996158382822667\\\n        394464997837915078169264622626824859022094780128788356919326252972216599314447930073242932\\\n        242069566077740789992003244575981886084628769362223437215700552742556181987566871850852880\\\n        920622429661729732367397778676949688455327199378597952808469849051339395661972938110951227\\\n        462267138143631545834930892837146242547725170945791611641427003821220983999830350508362359\\\n        540629169422516781939144133513560976709737303302718607063433977687406757703534901399697715\\\n        886672501435094089196263700895985582898215232921095795210079076176297306993227354180780908\\\n        991831680836177736105309180905405870747032876481405026472727109196282398772294072691838400\\\n        895619827341757709127069876931451559592785704623567297424264678673173211151523993138903363\\\n        888830371479039053494489314454711913854461790072507539627873859493198272353541888647752619\\\n        416264178275007581964972900058207668226403997836323853569738795699842524193777745028687859\\\n        210240516647578338772677642709362567280133220883704370233076559126616702293928432330268920\\\n        646915086105793292046975467076763027401906060860253929958942742949542964743590775043849579\\\n        342092224996291407358279024505480489398993480953529999737651436747864849156601248963858566\\\n        446729253417614643856932352557978815695544515918136408774883575708679466852573854109678425\\\n        914527166291939394672950993853194424774890913621861908465265294456166744483368458029114072\\\n        235916793901020082956132554222777910386641909642627789664594300940035968773419738707981840\\\n        342938876722041157016532439520820185082305602433325578154301242348173881129317370080462504\\\n        371958732739712120336224402262471202583149243837233041090000332605918992912023960067636845\\\n        519424223068192060922726472000747523259954068742865160388442925456960479799346006121252399\\\n        620119507227120064064261564135808277955536990997488285498499430314328996417333858064134567\\\n        170046701388446331713913097561805079660721050202794651268745937189798825493235997775045899\\\n        675412893672302739001502361590590506327894934975430325282227300659024844294827019688537050\\\n        150394005004594573503256523805437266863228171596096890531204710753180023214785997201644746\\\n        784070416810452707925200424069415846363744375133371059966518153202014005100335664771090542\\\n        622644047800008159988035414067763114956340914593444133457365144303865452732912966039189743\\\n        852578317986932604793893471658714912936948500293711029940622392181888407411591029838745535\\\n        504708476560109000916843985528909255881490367390344409966307271285338469259735477142011670\\\n        313859054961232421865823010040973162216101909762472821648719581884045413835202000474115507\\\n        054900519316131844115847124028583334001580561716613077776724557919155237480670470334402402\\\n        458675591151242608430921409869852881832180471644895096256332275563626262729118910193358586\\\n        381553488259815315549736229770152895469379203540405201897252184313567919525851379560373200\\\n        162386285664915327350181141896395826180438788848288422344561725298462359820578689962290303\\\n        329012784014378152005454885199949915073408414981586064032420835722207819642831227968438786\\\n        101794370232186557490546224625798179138113567408616824306475318182620479117147761952184926\\\n        148073187965887098409602658793369917682560555020886863173988983745337534235758530034722663\\\n        207357046283875316658903338783907677873631856601591307704093684448102938785123684176103221\\\n        409403520435713287394069611857282729097691739108664704036987515055146516785239073818586646\\\n        292050854332021678482426102750746409202271850326372172973115657366479961545241157319118050\\\n        512061737376174341958267013044028432061394474041289724413186116312177305548679933839312591\\\n        593033096608910129888459956110507830487647043168020141703739422963942606054061777590684271\\\n        816014568729050704542244377163192081357186848193542797088937766337080829800873673793323583\\\n        778622274948950901275410902858753646304161078494347743883243624497940382571813461814467878\\\n        724305169883290554740545401929219995659299549094734892004563157164254316676018812102211986\\\n        219653566163264486630303862472999353024530464609331332552368876527723254792023621320089848\\\n        946059121491952112874010142490391077406510295190382269251165846358926999734121261269411572\\\n        840193065399270231914126541269094987005537892888818937642009835810257878088565978887492259\\\n        883484798447584971431121736735832394092056013996221524439218843181722046751670016761418452\\\n        320337377310792834048282401157337833958392186369136602061136726347290785011673954391226916\\\n        963634330485849886383333405980372711006238391422792652129693843047570437466180952033866648\\\n        385153595748574565009116404387111799496669713742946528395227884071616470378851855306965763\\\n        790002700269233342688674737104643897757287886799645416392732318058143021579176159813134607\\\n        245116543351756985655111215269086409065646782189352066323390030360939803143133789474533546\\\n        195110833017596699567890890014493637805433591264989282704336525846802842723995034671538449\\\n        768372574458781773451719329127659467580593813194067684073714109199876355739416660357410833\\\n        143276296535611399989295586895290218562824972886948392488497904554667150269648925960073493\\\n        022945454671556460603262598222903424966711176731943192464711535952494032514352176936192852\\\n        010494834498018295100651890294249506583007626792556509618160094548850663571558741998729782\\\n        292311615340142503892718498417134758755592346896912814429875731200924974273608916238756228\\\n        837636322044927525361479631302516590883073156147086513125810144500533939633658650571708086\\\n        461956123561611315870687618197118217554819788933602104411587091522129158928366855768043344\\\n        127556147497473858734692718954812425298594213475753023815862607193140627192167873793977094\\\n        219431795869471909004611253927054698458138895640148315356010993824803844392631159032269472\\\n        838326261569545958630743119201003290744213354632339420358242527074007426476914542879023748\\\n        466346770852083527197148009166799328622543440057327375298982537457910110193314212997998944\\\n        038872007742934756769760489751623503731792651985047681455875863336093610415130019480402156\\\n        402280975039120176878153771322003171657124038305140852994138637556116911078456613463956263\\\n        073955613288308900050451851208647381343210525775491761969988725540471951798162376433556248\\\n        577039442364772761253645939002106288038175345344988461666200977876558715110115582235500317\\\n        286688223875003739015272774244079163405161198650098841695283765653414644017639017923422386\\\n        088778772839779605779269802586609807649459639446097435310804981296476320118618275407408901\\\n        463804332390793501495145309249001841904539586019325918025632175933024689859113107449873676\\\n        034025398990925186698626245877701854683913374166478641502627121577043454927451779722219817\\\n        628412378419138679575568869963638025302136702967792125743180644677065386502562930187979112\\\n        587796791484570244098542557406554190098503734958824105697684946452779058272504236818467626\\\n        916068213927955954165313214305718834315020412545233576924852700946836245989759789611203566\\\n        556452609298767155676590147077637333667930245608342503306781377960527587113854311488354707\\\n        324655832836738746173347267627915910121859895762017910472769885607197287722565763758112527\\\n        938522620411547602836460109595752955946142042142569407334749633072047944102880487217051385\\\n        008036313764897566262794285248855487091084702186098427165521273887573470897458016725680499\\\n        504331385527976546775054178646155033126903459158186548377820832036285438153952797060603656\\\n        116107921989694681004133016097731814167655967211304768859467357024641660911165387640901311\\\n        313443273875964992081792710206907725736635085758479248531679427442728742329185820823270789\\\n        625013149537146342974281700843229912254040675629761529875464075314353120889031983648533295\\\n        245120178053692465799041920610827216453223941359988213810094269658465206276604865351764578\\\n        035673736935035526886661886876425836827578292006577302533906956514702085455628327044531010\\\n        774413626897807912199683924619377851749290317697039739492170399443768358141831188601694568\\\n        457119651806548197805830615935728557001999870938926338896444863614757467179775060276822435\\\n        281347448501776177375512367281271902392264602407537133486259724139742439683529443458188246\\\n        799483450053846677119990664519578432172098564237440834291257038004390847113057077920338108\\\n        528224115897022064933621116710573224755137883553508312737541614095141420241940032840713245\\\n        094811646239851968200085089622678570887723090686789452479310108498427717961274343520821356\\\n        762177690285032464027488241884793578702193127014358782335949557525670266113746554796184533\\\n        087877794136125845368256931014636527350156449494833379543009662511334325716446968238837042\\\n        637488156586728013251186577282337239102322632163969233569206369213333217179957981626845655\\\n        610992240371781502009389308306160061248444660852929175673512871159184529196400016922453253\\\n        634846248261528493410146776628164794747974723685828783103625096962563530954186397523810912\\\n        910308188406981148835898195923787499360914587285694806734660526191226448314465398650838983\\\n        008558694169209069509595806222339277037504543129327849801920939965664235817311864340730951\\\n        179926474108559150189389549728677170130172428116238595185095939028538182750704089210699942\\\n        300118824755308207882461042155405504565634070570311635564713509014604746126359236419446716\\\n        253941391654687243392179695910328047739981744111070653781664283403439945647979387247284979\\\n        429810856819031637229446445524644078894884030485211513566937990492763419492596344266672187\\\n        162318702194836611987210520251958277117805397538961642166184232449462445958827552411175889\\\n        017126980884086748966021259727613888913047941621495510242148434511438983923654046501252798\\\n        178277055938808722848618891473687408972777100881339572137516936551945918101558157098746536\\\n        510810049973459960556056949357881184473853399664784377037232551645638994635528395879959777\\\n        720292469009942508474432150887037254034826306276885667636453419691591371714404307155455472\\\n        217116181233047500294895127248046627228263622657392473670413329826822379823637977104633051\\\n        515779284042717371924266112017648258052841937965249733791164624696463253751438263704541825\\\n        064156483336470609055077637050117979523815616524002308483144324663686768629091759872339743\\\n        813373068023707401154109495902884027293794070593582351727555142988117543143437441219229650\\\n        758600848993600298860126505791263363317057577601338626812149078706585562923752869274331032\\\n        599981952122316985038009164617108935605170112767327684914074335446299129160636982805196174\\\n        663291425069377635130955878676983185504112573840163501046065232510759026527809042305506793\\\n        956137194037652438142650026016825632036174395621755800300267808305321360369219375859534108\\\n        968643668056179676698190936207201612735590493649779814788208793617988720255278023392398459\\\n        522419172531804903790763973627510687099032903916927688997168903134194902217164960769991467\\\n        712546962897810698473036584369509051831346288737742890087910021860339925659570935013062231\\\n        642954056252295243874693514233309096702037016735728303187226534619939397986192029228017251\\\n        096392972261579230652563788127827716682305283661103454347703939707125493897060320515261107\\\n        844637202786749703361428359834330509133476737455184620734562621641175767719618336604380228\\\n        432669667918085519777940619216631199613169432675034618645777635548656672923018955899837098\\\n        074871860056997014063584962293674703556621364945731210667688024954410500262646915993106920\\\n        061699287897744801930737598712094121928514162967609432880294002840847246257830392984027381\\\n        355852241460003836770608736304396113676601925541929629938161090308623098342110506272915260\\\n        893528727639050317417523741258092048688305702249847213821925183289731046247007978021666265\\\n        605234896824766323140551631117491737090785440574967333766857467737448640352984642092596858\\\n        156534566718919986520962721650849766869701667867657672389428697739488196506967240661192772\\\n        879118079553401480823596260093318900849640020261230654581847240909898544409585810490297622\\\n        626536376685746404567855743443751181285047334256572668217819485314461037541993968312985406\\\n        968325464651439961741447874671124338983170844499141312523828315415627900101255017494214642\\\n        617033751837170322632181822955602821565851328341006990761042426288395017543141398258691835\\\n        336630671594914994490449422204354051580719396803872085870421711488561000434018315708307769\\\n        965028641325592505126690847658593510024107977907985679739408812897013947541954836298575764\\\n        260737053342213849786800290052597508793515364513544427749106930481038926136914777594284868\\\n        431611775446830470040808117066665725281937046949820103433139202395851366300877355191796948\\\n        417908719325307194204140868504649282294517394896562228117906887402806627806762925204783051\\\n        037137234031124221492006226966568139214127950752199466859857369601611691515609561509370665\\\n        701403434897106699810171183749388952365701752560533390023605921537356552752808894452057410\\\n        873125171072373813517227311745998190294810649431306054509540458973102725322043580677528291\\\n        361414476260840641428401629325413634304870124867813903192722798857125992867130851243342184\\\n        864893119231891219770689825235974190726563891536678442703106917989925940600489400270434601\\\n        453193536789887500145894306070504203203026771610705454108723887206629382805612023090995831\\\n        656399388802925476588804522119138275946340109446922313813109643930157132319417348334151146\\\n        276723868130395572486377254949835603804143304979427537150318297641522590729878094576776714\\\n        941032412961851734607749709019186780800021793561363716089360520774923925190937984072259266\\\n        979837194430224161465499279016050220124759734236316753427951864359884835542703827327155115\\\n        223263033632519870806898215009072549501115587657906653907856004805748872411049932874577912\\\n        752228869327205004546895549517238259038105079209292985580332354096404631203286224918259057\\\n        555916825015987019241090037035954902749482747017914972895109468547137825860663957767911647\\\n        850381174697761352231720784013417486700154576978563339784170245027767125587567338279217543\\\n        318816338319400635014208707688552095996782800968688002162857618175358953745095147234734429\\\n        227468392932072929367940983706919818624749138975003141069346822399076604089138533630507834\\\n        324961576156698000199082567206318501641275666104784340078169397167705891392489840052863145\\\n        672863084028966489520160319154207314595823138488941757766790236994433969130525373673069692\\\n        859645487803181542603962169797489668732953852178660615964824693234637640340318393927028920\\\n        316482997231666216833380758067964896714599406918490603571677177367970940880389519439313752\\\n        707997673138005201943748380015701520171481221195749288565697922742044509129983584479467520\\\n        729200019351878882996486855371263962434006169602531036094131051545336645353890837142686451\\\n        723736919942211652614520555971762796994890663690878260721813200582152739702216766253792833\\\n        747131351560508774759882827380487925224197636465907551101256232558063462071890634101360933\\\n        067320073045671164199746747013692098947409305197635552849809124094238892320960061005353937\\\n        033502724257758643716504845344669302978176752567138837590492307574950768757325663434749834\\\n        547526761768293037531709517130611370570276603903191973505631361358306455561156311729521484\\\n        288560348407021045540360324896087621445461959401020317507677858265749011500162165656618441\\\n        190675470042929537744839008709221290662536271349156800456227670621933183540773530322214152\\\n        787950850621366911839220361506707738428682134317449801009713855559419497784188242133550280\\\n        041680934740324955218926146522735141714880979285102586819337496249359562553939118416998699\\\n        009300573032077618745755982915603715394841858552213965510202652989616152835122307411203784\\\n        961316338320348851607785181455867666915120814823258346592643352333896455314174543108760050\\\n        995469924053707111565191426396447771712873010560122126389015693529521044104015387149697535\\\n        112243079423064348525899636890775655720528075206031594540075865254872626984535584493435198\\\n        775502717234029542983241169100485556418319251069348294728904506799644917697081461783759731\\\n        438610422440462336984245835513034657403939668888969128593388482112632254129287150226524021\\\n        496077610402417280877092482774854377923579010187953359697875536837839126433940709502151823\\\n        727475431171389355050428920953927298929893478768590366817620307906949371958276465378878009\\\n        801059712423933475097906375916791406955992900672664255600297044495714464620746074200374425\\\n        115132262481140397375239404821992708347491585686942083975540270307939914478014242732287867\\\n        552651979027557899943781949631235047792994950177191433160950050565492699056856385312781581\\\n        378729609909960206015819146766253838983369950900326274097627781904894128367359083058013429\\\n        786420538241310490143861536000097629391773535790242757257546666435051775642756095870567723\\\n        286981480696037215901869022624325943767254766199902690419324502191772294881409111899521208\\\n        041149830893937878800827609156697511918575455220972691629964664737933927594215633270554425\\\n        860833061380996165516887425706936656216229165018910835282371387481268165208166959092915370\\\n        153507943988405612322731970765244314393486620630121030362181809102216615235272894739637916\\\n        495650266801217661937679026960849383601787117949879238244370941724681871718342543381042983\\\n        638703195899224917944961289007167302403673834397359402373547417003074157638414350504711394\\\n        406803621135226991089036251033866844819675682848818908840771712546240612655668386654096868\\\n        702851240826157446955795720697948156388871271952784382718096503657976178661593653084680052\\\n        511451732551805515694704318174642980852777484967858999073648067151999708454968565753420661\\\n        625085785514303325539651176266254517127161541558393379683533522467805173932803284804961335\\\n        764114669115850105007053186698064738818502826217942290751340495884835291329169279930887146\\\n        284101266670763086520681681493436147288379945891472152053488494020636180481634963668800670\\\n        719458281213103358661506549656775505930195777196627712211414583277521060270102687960935799\\\n        027168623897266834717117906761500824934192292085562268342865531095254707895267716053530142\\\n        315778803195517996473869220685401705276840300489265337441306320358793769465862827845874608\\\n        957287045659603418406648508147021645328122843436370362188671894636060664093635348803208050\\\n        658200641824344688755066057376837327260640320737998640887974212366678675604534021639590950\\\n        565652488396922530403967938299701056077264985855348775669300453312980771590264899918777889\\\n        209790547377911995593030211525269556326137637997794352661910759734755322337051706380216613\\\n        142924820493452360047665604475725120349784535110880155702359907571300049782095557234808499\\\n        624509051885799886723687428425513396535575653212314136254347586543724868661459552021371577\\\n        960621714193000483822686678760263847282205755057564015411508017104306419499863037621788940\\\n        822539639881350350754001739094601176513805765295066416342196051500189965230367576016001920\\\n        450627629296786771723130413897301723033083735268237238273141226247756441434396867224995246\\\n        549835349482765265342624388926100865487300333082807380096265829731271954365080417419419543\\\n        953128634842411597615345229710076171625126462150639699053955664651637985031288600873610100\\\n        765221156300680394895741220147312908567347011306751291495449957653069496082366314229606246\\\n        888632101438115596949969589607195373206353359565431183101013537379032838762840534853681098\\\n        544401491550216976348066232188954722608788411739009270300443277210122638270344082769305426\\\n        612878377340553810273401409042502739611437810184286024410417495433388011107444880204813942\\\n        300614107389869926350427179158358495600760767013383225743109375285581813876871959768133448\\\n        135921650182000837462761455890360789931381631333293978421765611558742522174118506382512161\\\n        896099155779459161753248063094091069798528261602205487683561641735870290541624251066510705\\\n        720842480647818387614515260147649988781987355610423088796240883035554184676101300750549021\\\n        237563126934745269889660792383610543928064545892629381169426141541653998579273957269130304\\\n        961712636065126828546179872881125875982363049141668035691344421331494353198785677326903694\\\n        645924645117729371754638881740972197477045343201279756611172409653675338093629409189422870\\\n        969026994755340556024416360544918612042557328351134531925489242588503761635961222596541467\\\n        190408187099486976016420505911642787411683595139255181462682963780520330666977761841040262\\\n        448029894793464370448991191083026510297812316636357720615682157038322346664198970241696337\\\n        116165706919002348357037149665387415540102117231399518613309168423347949980345369697075262\\\n        178450041192257235339926569473196697226689103158103455022388969919581257957341399991262631\\\n        930779773735915911997083551596754114523628926312049528239967892577854192871260524934051067\\\n        842634501217651590299459712500581492530426963106033115954293705811207871918278172435739926\\\n        776986724809511442311511495288713002118277858513987306113786398847757978073315445463584093\\\n        521581610284998300549473169963199832049877841907659896212811733339420690973942365111496649\\\n        894878594294022184474355022503293671485429824425782193828814064058614846335690162784950550\\\n        239935075972564810187725350198523893505159217754234658546502827683112173684326020048936852\\\n        965281405759328967622432407304855049940928738225618129717847519838230750880643503027093456\\\n        696325925168231834317451612654705720871459474862139927064557559322386153859670897891359223\\\n        392086531575442615100034851029727064347197835919187554153113886383236129431731326372690214\\\n        648038331240521921589818506243028232785768413870434370355012581627028843014848092877008415\\\n        140017297533859126426301032329011079446844168070994428840015520857558073249186264230607523\\\n        007241674595604098543127111721692411682125795172305943261756692912348930081876899031530118\\\n        684095882634264265561667470822107056241597203802528426611146179141689307028246494129871686\\\n        550832670494168031612945584554090073473847905144715042008892444580916932248934629123185347\\\n        099224674639701140736244873344320947665993124671279120466771628631939415547133123763725167\\\n        947915721644702934392716025248625208420686419444800439652702313615398103863576839419028858\\\n        378828312742932191753945773019163021418162522332888020697304776250091579567084262889619672\\\n        721863640292352089181328136279273308265712687971696336436274171960127188063283889897610839\\\n        698861720759875281849131354258680104972834874876030260271509916996456554985526149590127698\\\n        786497204432484349121856952748265783402851245638627626739549590028465494215398538861871804\\\n        429557128405773139151620599790341129555920776224705602654736079381071459007240308891375029\\\n        471559977944102373565906663631415144829540937059931282261640918888891485034648293616057000\\\n        401561051330488302177554689350226577478359104930157677429802598005530256331915214974116927\\\n        047309992250933369891405332666638292720137338625492990763337406307165002053327742434094565\\\n        124745006825492895302961794175198740373133644363868273625451032325720770905459931303071249\\\n        588730549271421880297777739874743679836335079248523906527602959027863844819677988320836907\\\n        145845914491852970671216280253497730666711490746161732770775546748980613032083474792310303\\\n        552617305743121532227010818253506372144636983063758243210793392897197143810541578398997198\\\n        534745240138764712536904959521574359199987065651075592073156028222947367658849722604738246\\\n        164368341014070110743989409272331661122840811218548743604372291828967532702030880502697173\\\n        359658237082731487875934423904214098278975869373757152571304515144471963161719345330317518\\\n        172090616343338794116738418096558659710343367922630522524866409948455898153232838187270806\\\n        158185278876120039307526355646597738864889051797913745623576536587536984228769111826864110\\\n        924017818963155690037902949820853130068201879673130025287230930056898468479484754645525418\\\n        023136515133603839490572116651366166725754050275667720758729119042397244509285519558157885\\\n        686920279431962742752642663929688875059815327462371026419529892309036492442120357583647763\\\n        695867431390327458250782014174446983243635470262731044548278879714938558799938473352845017\\\n        588306162866763642427631158110237597138544728035407982434912124254756821126889303326738158\\\n        390357862524468321967764459243841829724110559400988918258486310457344324719941972507366529\\\n        080279601269821606251973418189729784630869362951250125786736018721113031400366410815242782\\\n        955313721625706838751758269961571222441602269356579383311628960172810639684480133632039440\\\n        936956648057348436575949415846034207196815880884636897222847590781733944467828356788640409\\\n        606720804345383154207162065118665077576088961051621145808366382049514715097248086505083567\\\n        851481763591878711521170578866535620552580826524811856207272211396154398679402229579079674\\\n        525517750599685649914877755911379685491175622146961489392467105481638387705869614881103607\\\n        318242082493941863416372405087097765598292541281376904768262984250857501946472912375110639\\\n        489372802503660926754365973442108881506610674209095166747950764555581763800638066064687224\\\n        226558079171474462332476344183260268238679688405792592575757286242847691878545006372392969\\\n        920147863211870000552016061814625201609752284457444063211256592482830671543339480193873436\\\n        047805932741637410421931729874786463078912114749031365797799675061581148580048893525905082\\\n        924458903715106235642790242957335654992884852804848840750401935977051049667125282129865165\\\n        812081954980343913384513601641629760603669234524991160764498958766615227062220933688332305\\\n        674510354765910541534124066756312527240433710186288319100522736957877881598124565010696506\\\n        651881234669369826372351389651358496898208229032895349891335747781469271963455883410773959\\\n        404249218389190778367056986271594548458143274214501508663292563608316787370358355010253261\\\n        764638537279245512608818119814209135193064149508961120083564393069889141223160918079277460\\\n        350795818467319429655669722575591299042140307576455948158997265769324925612101124710656537\\\n        714893887021161724127804609513392812186926164707154750957579496429475961304027820119692916\\\n        274890464231000280102620157624511062234481685915204288829775634319986908532395623713598543\\\n        298018034018047044360728241516753407313356374698492570427072998101555832466287274071932450\\\n        293505128113216704811776211772201065842603109986473925465235032582483709649021925553041769\\\n        078291116181215263666709502049687323157253211596690405021771360876544962653230880529243047\\\n        202653231892593491431734743042969318754959479760353997797886440040430251253249728330646781\\\n        904794427902429378951481625449931033802208157139476934989447132679272411551779896165258966\\\n        673042880321694441846025782045697394697532805296264210634811692041137432970815202596387892\\\n        034168063178067707361352222489071156983789244453362818356500308736025896560593074280050003\\\n        881267807494909051095222689899562203862643556154245189118686219752674361838631295287689584\\\n        582524572212749102035999306379864164993084777186111918149229904345863587729445954504595782\\\n        411458735948203258784694044487304477797121836598125846088976246049375836947437975736282093\\\n        261701608594938425044568775086986938767002739622332202140184388556925289349734055596462164\\\n        272224960339048429402418108719227635447761487518642068373978590296643706398949777977611701\\\n        676953823252102069730189273637629254401375184165966037244430001021473526210109877588378212\\\n        280669825031167035797878289846918742048818951492069827290011485111099705159572203282733102\\\n        743151227093985605004805689307204254556148129553353271883951606363637694897638734181837352\\\n        485167837207635966663487786227530099596039534061120220176478998750716023256684318283779124\\\n        204895681790391161130302852704304678628722385628915563220882804716145103818121113270991353\\\n        986492438560047539562949250838845695274191376629609210750256483699565805528931388579119684\\\n        687476909834049827182093123448533519491674850055462842525188851003196857629020598799481878\\\n        137405803883741871091291320279174194547138253660251263881966276569695320992291825480545375\\\n        790894820190459469659952546011938494828565997178970935614979397075112547947016263985585217\\\n        692628571414056449330884139865160514557126598847395304313994426862539247844502567748191497\\\n        102922231015474677834353081714941323786168610054036047194511902959690518230461591398027081\\\n        553230909857681196863857832278921464898400358793154997959547801472182729283449964942099650\\\n        930405442709546243330798602710013680848861034954558012518272474775165465036937782971013475\\\n        299977331817198565556317730258348709299277284029326104788267767903647110382513666454310712\\\n        328504219348165872353147277420508730440077722751202742788181254189967636587977963364808625\\\n        024949498122575992542374232818686141801978775373762462342199707802582404844236767348574424\\\n        812150321470133321016851934302679611830999809345370671031862013614964363171322345882513748\\\n        942515117446079555758171586384180478318682029885478675764319447861177826393477304787287240\\\n        020487193792301050482706864412334102764674174929118914976262536107587876280155769273015324\\\n        788238429289915113949605003899864978445707777547683934771795850352811383971568839586124673\\\n        497172244332971017765462730414313253000431424842410629317660462871027394584935670371312109\\\n        521810686603196239172143873132081044918015954645619109525093535745220344734979577645290593\\\n        223732183528980196201912437124214993957441769061087484277962226575020879516415372030062491\\\n        353278016371010741620313390196038630825428329847780636730011185516357017573498017045864770\\\n        407493679289346579201364888387755375075558637219937399594200344285818012955040879152212864\\\n        388263559775825390059817889609547105444537073537929153300004625780569136291448361435901406\\\n        787992602935612496306669652276542103943449285271425251837645230363402769076627007729601389\\\n        601905984612958155969615560393395636847355666546771506263412327206220696121275492312418110\\\n        625710249943238116210864880119834513670759471484598533179742891934505550928417105593196766\\\n        971853933517576267548668048754900092423512605144625302523316867728310536018611139099643148\\\n        503260734506401432299822619635850113968420271786306056813399807408108545984576440269528162\\\n        269949808432380139500356412598837645702148822157989839720886509601942166164443033099234763\\\n        253103006883111157058096834324983462143967634942144121932170423948157943367469873950258064\\\n        253810075938034255058090386594959982890293148575115957506789363088843878173848208640103712\\\n        794854684546521504287107261028774201563834096235710098029735723028662755307875244911317877\\\n        699181836497428082627027544538817479394246822361247662216430585584780965987275831672141815\\\n        394399904607282088306642721702922982709959128043642667076665803650332223040897045082203412\\\n        034373297257803613660208335008757508656992574514642588259614841208231521074652580211727976\\\n        472409928339152227271434315022678150141326769855735748742396635968485619414417295085298149\\\n        738164340690419860606332683596761384214159762730737838064542815867377134672595262572805566\\\n        988046085298062578955235608390283852468120951209593478765982246238508796094220013208253102\\\n        411690280561477453560262153378157954112852653234912577877769826269796503949810554521263264\\\n        839252983899449666943636277934044677176856177848362278417277029545706332383335587868703037\\\n        448286101373549153152131427233391621920526485444437983492607965468103898798297755006767671\\\n        472722531617901512289724331816501318714443809145360691474860269149728290912333364512278037\\\n        010714117274459500149214932555058048170704804452921786991214338048189010313437556864331509\\\n        905247938986675561145863532170738378650158245175879572225124279043503192374539529374991986\\\n        252951814868345059427801068228816800865990067335437290313953296915737941949130829421387544\\\n        405240867076117186764598775664054541130628717021153070170759586058026957556010217817546024\\\n        465227868706996165985528270313462390044833620707395494474392949857710982213809586516522757\\\n        772221452700158955139398279975853362628290219886745480751243042263021237833077617615546731\\\n        061943852876331930492895155372001885842393040639330397097900984307438396113106137558907589\\\n        065341195909567186120553754257976707328181861282916899678578859162372636404609259504877917\\\n        332385648795201353300629546136328055992072057430289877892970347126839167162467527828662808\\\n        260798134911669184020030672461564084806165510328836683247083255062829826579559477913721883\\\n        864070140668364813408576607389044292337504488385126719949672660055743481069732935249083840\\\n        946800996882110789693495993281135171513854746911817967857342924839718367451303058876297377\\\n        935607421783838376608587833157624882277493204582192503978459141212839699079298548511475418\\\n        716027992948194699798178873553411992813265719850571622558918168334748691562864164764090973\\\n        060049913518056757880529022281629105627052857752228209356161791937368234336749518502066563\\\n        527582792080539015823651473441185738522824482799916754338766184653411655535209044153203231\\\n        791451272517529814358972568753081282141845899365408177271628400884798111064947111676297793\\\n        686853374160306978011773975253836905305549277569396225039837177004054197820887176520534201\\\n        740370182482646354781744961595331836746185654070557406077067997742330849258203329437884250\\\n        916459968859433428132036121047669857707566318508433242167056939329078457302817266515967717\\\n        609188772363765332960188984086664746099588737694229819373842185944746203674283498192292471\\\n        146742935679216826477678714576598279259442376906564532262054415386661820346552441561859855\\\n        031182972148215033656624052212111615850510152724003625116976546355610040094626651082998003\\\n        857147311305133515064544344485695872831908497365654892367839697491871176239532350897587017\\\n        834061205439992990588915666016897746961747381607902834675456832857060975676892200411287511\\\n        783068460458908070136395767207886541643180394608502974152330899806380897763601163603936582\\\n        584832268624138767516098569789778623308119688863452161596280728856239632574686119484025022\\\n        936855257480076756766757668545461244157224797558885762167120838896667694035931540468586150\\\n        428096739873302762688702062780929037760879898997666036149031784451419639278598578725952777\\\n        307256467467112719864489885185531522714418221559139074001668285282731655672193152313677379\\\n        820449891567615888023571607286826889478018860670723240747549740682745835900983645331014875\\\n        715713370058761261767141023584457822318657601454583227431564561953266950689963404034033317\\\n        467078423452301057228985327111421595656597138909498448890229067026709813921457845107188712\\\n        978821477103102509415627721711620546484422508315269942186779095113319686076483683027593478\\\n        248733404371066030397800266452065947155793581230756703027782852690203630510531104862151443\\\n        368050647087254593687389136607437618311349306422429498184714262074239698588773313947176582\\\n        199121871321768182564719056186223399791325811303515388267886701545305476172743633951946057\\\n        712405384117501622866995159317219438710075849713070354215796730055677924268147471644274795\\\n        345012194905383088937265037479381903629120976006068944433387902684010290943889589283329854\\\n        309158199072191206425551361817783998338791755398648529608617896876967272219402295956044275\\\n        183104138116642943989741688832506096810730004323620537431725781136684588095988977440529517\\\n        224862290212407709833804886553766839698603013699525250586281013922922551596067169706872588\\\n        409382392660927137183156219117453856546943872656132862955436342588806975451605979448893055\\\n        806188370052808937331568317826774281553540839021768350418517398692539989262477466066179502\\\n        659712434887095236134758810011713770872032117262969502613334873581411044544437785546304728\\\n        553680198666729338663382662849020394980107948259735016938255706886014959170193656766743114\\\n        586833175843228765694841959973192109251239254674895595985879511824748578464676859684520174\\\n        127943955839487131569710845766681138670079871406173143240499690560859250603579244659748127\\\n        432250146558953973995945766522846835971286725251749718711613801487470132509677542206163938\\\n        970212514148549867549226819113722933370440381306161072467917914193588539584231900788667919\\\n        150838579344729401193056987461422756388409769893879220506726213942998036101052723031384370\\\n        399607235270965829425352383755311445737875331721091446698538965667543551187841877794951742\\\n        966106494551549067799678534605387121153592073093154700793970388829317317150019954778946221\\\n        384416858377449939241736804995976072496207843437046037312105863003827618331133512508159031\\\n        310418584037572319447605725859186973499356150122558120934535461843682893020341753362998450\\\n        841385974855299353363497909256585917384300435167208223048755534766319778357779264865172889\\\n        240845305100524596257662128622072455471388709269981804047177579309159448211525831707510374\\\n        353654785643737719267780595001693490920689362574409752634930677447717088442016057726045913\\\n        653601219239751970246388734549069527800240599101327793001018700915204952030820948200866688\\\n        258366188775140479312246478495500627050379728646367944082310080492120340666160294507243111\\\n        931037080906981009497166563005056822474483438100579450521880875983526602857638521827152829\\\n        890479094430695332835474901564155807670085489200605819579815042291682823446621822952715300\\\n        619410637133262262740808864159773082738291925234495561054949055642859645858879860338853797\\\n        840861902432963995148129505897930534350485433825320755850826671780847401218267312643763450\\\n        803786772388420724922351001299409975841498404303926145475803086580965097593893499141877752\\\n        158519405435218635717324048735644467849122341919182569568391418266675742719494064236557710\\\n        096790899621094319686015779413655453482327302954357595576294234557611119936418378883243511\\\n        229364875475868917461850968845813294649778365898106342996376676127691111993395217569922677\\\n        776925765191029998582501060117729962118657749207230579233205985112224680236115274440770161\\\n        924162784977917328356973323476433375279954740847546123713107908692512168893603236488823024\\\n        030786510169202894563152098978013939452380940673728710968621987312155734946059293958415918\\\n        363004033087132213801504030222646314643114396401564620911076416369379153743597946080021573\\\n        810089189924109671148424691163494051399326205742428090614436018902709880763461426539362340\\\n        897505050633460131874801553285642625347606591449326215151307020041150730634336693741388209\\\n        159143434288568686415619148494506849143875545905503942124788831211378790596934630106018936\\\n        487668547561910102396031980586144302147224589454296550744739302985175300752666581367966898\\\n        992960156177412193578900222377105528894611789335184969054448385769469438287280141076858537\\\n        109889193829431245944722258392910582322288034759982857434156062766001561463341128970885699\\\n        843322766544859440782606300832198492203525111141667666752903200374529855267811861314644815\\\n        344318447799051547245600843988272278463501072101313403080345767127325677206538186899111991\\\n        766582497654591949414239629368153944088179521415693791947108856146301932841088808397421584\\\n        307225989665881432522133688280089225271698590007690818236211726855523797919726787945456661\\\n        616499457494360782604456188606722314191712378646993503797167931325533501113755908017143335\\\n        673483107400479888383603508250283345224482446305457255466430323124434686175300748137039181\\\n        552667092463482683134323392835682663925358378752042470190536216049723395030571746476539827\\\n        359329420208432216188555899882119037930401727902021748581279117996289592057802820859494069\\\n        244995200207811402994248842389006598635347519096796506453352446138204570041186109783624417\\\n        771412971218111180513172344739080359964407054037207853702317114323040703801547773982102519\\\n        053503786542353278191709348232687968360149198902372736058638484820840282180279001856753357\\\n        564122322744301685289326632771219689686861466777254073209203018684674835013182843477507122\\\n        429292105206574716770287393157437115875300299286830395383047968403743028955567519163926773\\\n        743851250118847437676154163596813006526488954670678838673330525469233926731596510664564277\\\n        818187617467341734479411114268284607828515826613710108221325977206287700178715613463030821\\\n        480214036982301337178841610861346483976179699625529983485387601848715421743357341748003006\\\n        583064862412315729842056984353113688741289805820282896075093469705193582563425765193637629\\\n        584482503262327409096565876974166441239865807991929313947150425155481845390165049079574961\\\n        162813984497915370501785836753618175935849997346101494075496683730131487957918115840518040\\\n        467144372695510519320202995431783544506163738942205876141253847788275534447282824063080339\\\n        651204499345557862828989205796903591405578617778702029423665045416057510216842182173882532\\\n        040167508546983988375920597616295184695039084868834837798285437875105889472047937214444349\\\n        762790412243024701830969031707027984274405872784541489350853327061601579747695130384105761\\\n        368844505889169178882183539843368901280761404751895965387051987750898263823268864780094707\\\n        771867225159618052984191989365108333423853025435743100237026461204329978353107066572639256\\\n        793275471789630193739376678896781901400372342525096666344027506865744020872159510858561004\\\n        392356204947395278115889065866933276799433454506493199153120597519601243725035010240825971\\\n        434431266268179722945435116434589762265813163442721933482760049576712662485241485638082485\\\n        640746248132816413007406820956337788386817070078926093617185735540652591653552632120620854\\\n        907100667775220194916896443772045269736143159110138865673261571483218811759129609928577504\\\n        038350823882979714494589029714168234190184386624528085906383199325749758702074163560582941\\\n        437010583301474328088858128467221185117192274007588161843062375819690155869943785764687788\\\n        038891791065520641745061337836259311992426835327392271657030218275380232593536722802655573\\\n        881664401409151082967406255454490144969515538997674759735049507713807011421662561811093084\\\n        716159139563862205821855305946757782830306140150750121509498876375817278619529589982488853\\\n        679509800794187602107349881672381521767248113912062872041479585800290948838067261893162920\\\n        092727569114049258182323084743074519679617299047081268645817195256475495635889202906498801\\\n        397644955622726944218857951786093929573211661917516019883220689533921609073387058423826497\\\n        503582169072590897291410582821733486112761115085672070531547576728753288828399817807930441\\\n        507693767656838044384420657068640782388075554455282012120082693969046813768255082603862368\\\n        515890134325102968905398606078097738667421788290362707106683767104097893252418489888362889\\\n        605093776812846167290712018476861244746119975790175004689043717274122025376457973725510259\\\n        297549342959235908429250885032909436675160230359435686090627341198048803192062615160245103\\\n        061115261009098952548035228595529837638806877001681778675922809931885624791314167256988452\\\n        761374263817980996434409711927983036657823118325946602194123642147711349178222737060741125\\\n        444584057748401705595839488230494719175949720602356094439493992723068985938844147775859653\\\n        980934290916658311629874629580818352969365717379009667277441662561867124142856092870288013\\\n        735155832450076328502411701482337834161164006588249189343526960444418273990794668000631873\\\n        771672483976305709883200946140952253479982547768404745663046404882555678376838641565141266\\\n        134642121616558718621826901117074449184193359737989776779485995590751342306698645253128166\\\n        793319248166187258436987656467913953790532312924280280027418912161666431166608952052072372\\\n        906066712946041133051352483529301682655154149492921563055473343729295227647342514357477803\\\n        221779810656579663018749547873561693868098726681490816382146511067812096160617829559463912\\\n        606564500076420646616142896555491892248208529761851545744912881627996017758491539608222717\\\n        361264586406994894926923241298852014562928294746146592187969574270181504976880387584431621\\\n        057601001186853410333918358063508257721534279578937214328362618851932215712368752763924462\\\n        696037040368878653364371339565132127667979646014107929008475242270574372033317731082828013\\\n        282719694649587930840367220043076257742862557023943709975123690115245919411923672020457166\\\n        494901021947380864333302950411526059675155514596006544498044827404502477636664731094796800\\\n        772934558765389534297688312733088004070438454481631430859977609725030210199812379772372439\\\n        390267689921635298631575453365029295599281752954614812523470526350512412402541528147738412\\\n        535302119659621905416414873440120148572714085557520959448528544607171427333150691967214507\\\n        948386400004033894883051899033041388447147244912251092411837334849345939620659447636152847\\\n        035985591847700797914460779596980092942331975871466807592812148414763298653240493530286208\\\n        900021429732476693612986873736607049393839979191559646982998921502737286627332850680992349\\\n        165068876116408769105021693878234599654999276123180886208377962162309180625736364607993935\\\n        407647895889752104795098530842862635261420330894608736945688267060901903993651858622364522\\\n        657904051978128358914901960271182823298524923987950675993063594423861994441098428657151102\\\n        646830815130426402875049532856537577631150879310150998389045894257455484697295722005264898\\\n        736771782244385503550520965779575199252368090018566444987033492856716394133289614844039420\\\n        098797378248356921506702892006636337738439713328083025312878175623128927957964779861206156\\\n        020917072418309674484148045112711705733893312057070693454709629586668408821797943786108489\\\n        852925922313617924970492424689930094977534969226090987441275817993615843711159943487784851\\\n        882851527838456993019212118177746988988825192831148899477899730122642003340549150823910510\\\n        834605491418095681533305645337563526728352845193804029180594633851642321885894466170446035\\\n        835853450446331492659052133502442325946760679790503432686481498185493428352027375039392181\\\n        016108969709830105920827519291158915307778426320360573365167533639199454175460054636330433\\\n        298988995924134314277170081245836864484920983765358870935800346049764293683878341481309054\\\n        462475659307277760771059190470418795451667230002124852295698363052591653027245706659869806\\\n        566856667440905078506006092303827348357074580348381902146388766120789941048217149386991004\\\n        952322475271419299843467934638393580502590938928382035408208073012566326803551208744613378\\\n        690674539935507307752733981410348201235354193543429508256600857844314799733392107849040198\\\n        462463439146681601014795780171719611736776661949683473500745152724605155910946156332584629\\\n        646809345678615492942372235369689255426041303684015787970330874465081861551770877643893985\\\n        040646172974931310900518057545071053099657952673315204944640841706823431149868665929975424\\\n        536923652958212923877934844492897397552630151986689745908941141383915539882231626131882715\\\n        584211710078968922895199702273266442982382409720102451499909810418393800866442474021550474\\\n        988480850682541319948250979723644174564924305530324964925865922671074588854602728752504639\\\n        112778744924027360118655306690401627476461560716219695229156758289401569114394852275807742\\\n        249491147844204376476099964019013588828631404806048566598595065031453921428103373738820741\\\n        076159408775689308438076235766525530199924059911032486750729533518376283284823841367207293\\\n        522643601183267972464594777844190590091481235496183087601771963328079709717344650362124263\\\n        846324215281312498541361361449664570722361332001605577392847671370780115263784555726322036\\\n        867826108615861146125481158492065198192029848771094851305002977464920427162834869070661176\\\n        385338599987894920306693614687260882530681877700048027335068969791539053629854993553619281\\\n        173011008611573642500595905512022048115364847541572398819234292681321186326188088027571695\\\n        718187633592970107581055544557818686316660833222467371897683463128272267037012347521509169\\\n        739220597814250307671176234650131248893171618899752442788583985587688639308165102420902769\\\n        577818200346627840657809549505306182789627090551936062736329451728071091109851994770782703\\\n        694579637690047400176087186630196081146159793180661304547319021029648514673581894961950396\\\n        333064636762965210919075935083020830271971400124208849912350452307645308241802213582511289\\\n        929311734114456395020661748893439595935559424516465598195229227495274956043027667299489723\\\n        671806762970858072460030251511465071529103387123392922874109204798374839125866128978376012\\\n        753682898050052960650743925593230483485616302943829530689632532849762804789310608323254667\\\n        069579102408324801836241963158613572896496903640915523485721165256996863203244622421968352\\\n        340618379634104434650342365272327233173672956202706067419791952994424334950378743645415190\\\n        773580932768988060703598258176334035713464683112361403787627943686105149560752110880630702\\\n        515185033214652941828182876985276072011549587992395438635576059806279326148873699803347807\\\n        870182829042956200909857304361113890232767626463026519052335561315931744757646344822651905\\\n        145696584231626107764715330668637554555262080463768950613845924623301565546372547554291774\\\n        664413519174253796854502179224509462999739271458308219120169065145193943986380177766237884\\\n        832031716818513036253272634362683716121562653419748950929460795704654100517513298585887706\\\n        192882725235562945701233821765130846080067570839130432290956048335931286039116268654342025\\\n        619900757936912042889523530750248065241055826242093250967076303380180913818965456305525673\\\n        402710555264902859458900967538688255927353347203045209316148715850027509169525014847985832\\\n        993534048994830095492969107282657627901050813433817800987037631918551412420261735286667192\\\n        518173383244007486778539866021475621695076703206837695214043875050503314664992729268789156\\\n        260382362382747323663381559328123400555031274686037354895653141465542822470751439017833337\\\n        380184144829583645786311648163998891046956494270966942409056703784253197675737357371193332\\\n        541195381794055378949695961374050330707152718166789543931667264635171409271882483649793663\\\n        721128031870428165444545333460609798310588115220034144145610567559355774452913106205483117\\\n        265039748842897615142413790281237509906893869930923179875025547738075674813515987004359623\\\n        385148458421460278353522306288656391288273132991496503726792530098217666752462873663965073\\\n        328505690578585671315373093191567003114207823170433599953233616695944253780449230263879442\\\n        832509011736928765574846772457235596236559351317242512984975997670082462273618095100537295\\\n        764506938439849997947488224482423092524758248985210671766107455871677394642485916128509651\\\n        874490373153134932688313687757268177923986115949185866308370833757815653507971263959381055\\\n        801656258532205137900131426267875767925202062913657415884021839591959882362093145786240096\\\n        989725371429108002796266157047652246407559739512170928298120744669946113708948451413255958\\\n        740911589855473722110256919193879179368462175135606344721117177139550412327943704123120181\\\n        966946028844934794836409708906619077374321908162008779525664711883873122000125994710202383\\\n        043600958487570033998574480103348143967186598811050555015535555952704361071690521217305691\\\n        683446673090344608783545988044058665744530666797728415015643932212805480164752370321416465\\\n        412926852562034017946220924840718316893539962457462054769236547162788604636500183277716260\\\n        312735828981695652917200722174222928876715755217001703215248374615206483595650559988076966\\\n        395166494194431500119351631225317620151143157636759671131209039051916854215122479528352859\\\n        507676642240968392159288370321605435527318860012154563292795074854044325209749710920890522\\\n        678486884689774132216914691338248686186183674703636548344728234468900670485994334265205637\\\n        431956697397690044263035490589065952394395852367030240739524838274185248587539854512149221\\\n        174431921899348538647686663149226124175135971335118923800063412824033766234233092865909221\\\n        142863748433401456169098143353305487366534254679310576115303741310570710687823845911530701\\\n        101495401834668545004029984246438527556612617300079149277380285823938871573025216184050005\\\n        973578003747936162751244213420762818518280827494456087119455742453160786524229148045968936\\\n        519105198162921728500505283419662249813456931158940683480901278168777031523776870015011347\\\n        727570252878860173155649081797460025699807168865017159915695052220588730996851089600816705\\\n        467753460177326154121315847743124107464058613226591534554700061635806423061112972630732678\\\n        006312727149715234273698288231974164634794649620486837408150149717197456840707992997169580\\\n        646622879536635189624029113611577420509833334569837413547518436804244120262969605205242469\\\n        263293839571789882661036308578588415610817338401459331258154706929217435660570895525673526\\\n        330255309589416901030485655017444376265390742345276900032626361643117925330277048015005736\\\n        600461386309923566786281859818430207901873451057808041197253108757775564756279478023997884\\\n        771013932061623337767294123211674600724670030186968402257792078572289847901747890348042951\\\n        116204508878433634879088827136652089364358594946125019418033751512050756254772738179086563\\\n        693229740334472363662099876234931240447846287389196331843516639018719397105134078461468096\\\n        621387151826105434169244138115005017717684539205178378027624780971960161229171739656631116\\\n        893252785259047850709944921749262753650887096721021713117017418737592600964218466915009676\\\n        112629795113142752576069626806228095665129678373861825497152714004040946658265009551573040\\\n        185354433954604460133068249235339263001583885719174927706903462486918162171807889879513997\\\n        625919264988051902711472834409886382854534728597229874271122986143581522074134726671350214\\\n        536622498136121446951131609904314613591931474094021476079975121933696795703715827875298102\\\n        816621627690164989258247461264969784063552947368819509276239854743136171039686442559842750\\\n        632037220649377433548653278989624182398669030436090085130959000549149665231356576358901222\\\n        109589692797371627647672277443677421516767781441929960686988051920974112908235016114960263\\\n        742234937473281497833950098681188212886033011283528339612647270795390814137732001843851170\\\n        293239619147477341161102966853600305071320113195800039182755797149894088174038797931553928\\\n        481072887798617273728086312700507108972991102300834031979720182553346447446418386657306112\\\n        669313119723597695642985184487813533131576430408294380018472419780377023668597842666750614\\\n        102096549811124494194734809369197505025156118836263288396574088715051416772241427552393031\\\n        960688765295206547029623615177345172387858299761714195820585692447678839951235660322097123\\\n        160919655851012756705245663777524763175371378553071581812995131667881993220854943561903718\\\n        110014776978921560844796785222629216063456537525616634477309462199186606530969774959795104\\\n        268735854952274391898516301860885812881473324086544128573547557041679699928301782345602083\\\n        569480057868152641062654763473382113504246945095460417016852946974495192422934254892274531\\\n        425007222413121021502343212067054915684474801539238331984585009620214858674779914475598147\\\n        731242950429435699610908625542041093811219187035924830178468082176766943785303910926224824\\\n        252067435846097006753623211493234772859967009017648156764513969917160606549239326715156915\\\n        187570300074754338389025812947600262830258881152450410674252464202949710935188111825373865\\\n        688245430470350013895132977979789035377050218886441137508171002052126267591557222979234794\\\n        557214939722240923112521143245494176274426135175723819793696600708083247369709365165191549\\\n        819296122973824469992028078575184910776467242958675685675214909088313492584426111764231567\\\n        724413917006846945124403272890327062145150239539080765099956760298891355946277362299194781\\\n        362044392900946913707055230880816424965328943442915033714171813160312387275976927586639422\\\n        145419714636416122736898323270531785146250630137490139525476366402940339285210897625814741\\\n        201477159788678379235818016016068759942035449486817011394091526219423920958985676623897450\\\n        143584704788990580298792209816280808575448482745467410062425801814477237638023951884105786\\\n        071765575947064290343737618072073050123796171690432428525090760749957748249846887067925895\\\n        545999887479659231915332058738440151243404724648285802926447371994680834661706296790562172\\\n        891558229062577255048842703548174409528922487252254924152514689302053014228146932316625513\\\n        925749133058607316388815175585003793451151374128761775135301322057426175108348887635759204\\\n        466658587534738860240227313513804905095926382698773369104467627160464842434294543954624326\\\n        682077807758191984463569747651314074392575477177196324474371645144021836008041580659410082\\\n        351886691536610627357721228499763150805653128690946143745919835917072180549322757173204860\\\n        411953848419604818885525886573320733175957944437938955345377224990349713647354131831953298\\\n        570494033036524806862303743871141919767925469368541591869290521988838566334649474119264050\\\n        553841541796297461084734366807183496272270257303356819949183293568874035710683447800749324\\\n        457606033744647934177354517001068860720864682906147752149132117595826868785253236673704130\\\n        934179207886862786190614237595502559090003990329332081178684546793200806721770642645930667\\\n        499533805477618237563339529981518451243393127865211478272644466883436743484774549648779895\\\n        760679418354139412654368093728700135336397302975802249875428001147252736043023161573690394\\\n        434255406081050658562495411436717986662853713815346586838753221174422900605241698734999707\\\n        712016356894690020265045256105031997448376651562669634401428823999813862659578717583301248\\\n        444853823494369801996824630387440761524155709947724458307718126350443639309375292879825030\\\n        490513849617392846955955252018930959259777483791072804969654637966966028823008041491534714\\\n        508666585521353641507531013816290362843684985376368357752491747739219505221381123470155138\\\n        966456727925196995629315951098811726883834953165510901119526510541641093117439292642635637\\\n        481854685346015028404874268648664336452216855508612318247199646193424932056854621399326031\\\n        319745759427641534212504229576971676585069584597384482843841965992799867215122062030019510\\\n        890377587718655948740409064665787122293990618629605769056036255252381133049274082239045860\\\n        723987744287573426469071439667337732275946091539929476395643760302551969068441026197555480\\\n        836530006943863679603592141403289053955157441353751872195054042368584885238769618493714933\\\n        985834830905400777345784080644728837831730399512592918980374180030073186347808934639773412\\\n        781702299872076906793284375252101863627059146926131374694246333371384283595302789803872738\\\n        887059508374766794935643540147104395471348565257972801749517764402217071467394798400786269\\\n        084515691722069463529460303532324206664285516126809207137181172276927421408430097051505372\\\n        018265758235665727167880725904017749896239170541975018389848881238269275849243152012944984\\\n        889814055138043487602290072756452192726991669526684257084820059940088799069438157449133982\\\n        971796299404324946728192059519384269438496751332211928665139061925218776164611246309949370\\\n        427759671413608152615717583863742311540941975477733453042008506964356675322312073296127701\\\n        549667112273\",\n    );\n}\n\n#[test]\nfn limbs_extended_gcd_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_11().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let a = Natural::from_limbs_asc(&xs);\n        let b = Natural::from_limbs_asc(&ys);\n        let mut gs = vec![0; ys.len()];\n        let mut ss = vec![0; ys.len() + 1];\n        let (g_len, ss_sign) = limbs_extended_gcd(&mut gs, &mut ss, &mut xs, &mut ys);\n        gs.truncate(g_len);\n        let result = (&a).extended_gcd(&b);\n        let (gcd, x, _) = result;\n        assert_eq!(Natural::from_owned_limbs_asc(gs), gcd);\n        assert_eq!(\n            Integer::from_sign_and_abs(ss_sign, Natural::from_owned_limbs_asc(ss)),\n            x\n        );\n    });\n}\n\nfn extended_gcd_properties_helper(a: Natural, b: Natural) {\n    let result_val_val = a.clone().extended_gcd(b.clone());\n    let result_val_ref = a.clone().extended_gcd(&b);\n    let result_ref_val = (&a).extended_gcd(b.clone());\n    let result = (&a).extended_gcd(&b);\n    assert!(result_val_val.0.is_valid());\n    assert!(result_val_val.1.is_valid());\n    assert!(result_val_val.2.is_valid());\n    assert!(result_val_ref.0.is_valid());\n    assert!(result_val_ref.1.is_valid());\n    assert!(result_val_ref.2.is_valid());\n    assert!(result_ref_val.0.is_valid());\n    assert!(result_ref_val.1.is_valid());\n    assert!(result_ref_val.2.is_valid());\n    assert!(result.0.is_valid());\n    assert!(result.1.is_valid());\n    assert!(result.2.is_valid());\n    assert_eq!(result_val_val, result);\n    assert_eq!(result_val_ref, result);\n    assert_eq!(result_ref_val, result);\n\n    let (gcd, x, y) = result;\n\n    let (rug_gcd, rug_x, rug_y) =\n        rug::Integer::from(&a).extended_gcd(rug::Integer::from(&b), rug::Integer::new());\n    assert_eq!(Natural::exact_from(&rug_gcd), gcd);\n    assert_eq!(Integer::from(&rug_x), x);\n    assert_eq!(Integer::from(&rug_y), y);\n\n    assert_eq!((&a).gcd(&b), gcd);\n    assert_eq!(\n        Integer::from(&a) * &x + Integer::from(&b) * &y,\n        Integer::from(&gcd)\n    );\n\n    // uniqueness\n    if a != 0u32 && b != 0u32 && &gcd != min(&a, &b) {\n        assert!(x.le_abs(&((&b).div_exact(&gcd) >> 1)));\n        assert!(y.le_abs(&((&a).div_exact(&gcd) >> 1)));\n    }\n\n    let result = extended_gcd_euclidean_natural(a.clone(), b.clone());\n    assert_eq!(result.0, gcd);\n    assert_eq!(result.1, x);\n    assert_eq!(result.2, y);\n\n    let result = extended_gcd_binary_natural(a.clone(), b.clone());\n    assert_eq!(result.0, gcd);\n    assert_eq!(result.1, x);\n    assert_eq!(result.2, y);\n\n    let eq = a == b;\n    let reverse = (b).extended_gcd(a);\n    if eq {\n        assert_eq!(reverse, (gcd, x, y));\n    } else {\n        assert_eq!(reverse, (gcd, y, x));\n    }\n}\n\n#[test]\nfn extended_gcd_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 512 << Limb::LOG_WIDTH);\n    natural_pair_gen().test_properties_with_config(&config, |(a, b)| {\n        extended_gcd_properties_helper(a, b);\n    });\n\n    natural_pair_gen_var_4().test_properties_with_config(&config, |(a, b)| {\n        extended_gcd_properties_helper(a, b);\n    });\n\n    natural_gen().test_properties(|x| {\n        if x != 0u32 {\n            let result = (&x).extended_gcd(&x);\n            assert_eq!(result.0, x);\n            assert_eq!(result.1, 0u32);\n            assert_eq!(result.2, 1u32);\n            let result = (&x).extended_gcd(Natural::ZERO);\n            assert_eq!(result.0, x);\n            assert_eq!(result.1, 1u32);\n            assert_eq!(result.2, 0u32);\n            let result = Natural::ZERO.extended_gcd(&x);\n            assert_eq!(result.0, x);\n            assert_eq!(result.1, 0u32);\n            assert_eq!(result.2, 1u32);\n        }\n        if x != 1u32 {\n            assert_eq!(\n                Natural::ONE.extended_gcd(&x),\n                (Natural::ONE, Integer::ONE, Integer::ZERO)\n            );\n        }\n        assert_eq!(\n            (&x).extended_gcd(Natural::ONE),\n            (Natural::ONE, Integer::ZERO, Integer::ONE)\n        );\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(a, b)| {\n        let (u_gcd, u_x, u_y) = a.extended_gcd(b);\n        let (gcd, x, y) = Natural::from(a).extended_gcd(Natural::from(b));\n        assert_eq!(gcd, u_gcd);\n        assert_eq!(x, u_x);\n        assert_eq!(y, u_y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/factorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    DivRound, DoubleFactorial, Factorial, Multifactorial, Parity, Subfactorial,\n};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_5, unsigned_gen_var_23, unsigned_gen_var_24, unsigned_gen_var_25,\n    unsigned_pair_gen_var_18, unsigned_pair_gen_var_43,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::factorial::{limbs_odd_factorial, subfactorial_naive};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::unsigned_bool_pair_gen_var_1;\nuse malachite_nz::test_util::natural::arithmetic::factorial::{\n    double_factorial_naive, factorial_naive, multifactorial_naive,\n};\nuse rug::Complete;\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_odd_factorial() {\n    fn test(n: usize, double: bool, out: &[Limb]) {\n        assert_eq!(limbs_odd_factorial(n, double), out);\n        let x = Natural::from_limbs_asc(out);\n        let n = u64::exact_from(n);\n        let f = if double {\n            double_factorial_naive(if n.odd() { n } else { n - 1 })\n        } else {\n            factorial_naive(n)\n        };\n        let zeros = f.trailing_zeros().unwrap_or(0);\n        assert_eq!(x, f >> zeros);\n    }\n    // - n <= ODD_FACTORIAL_TABLE_LIMIT\n    test(0, false, &[1]);\n    test(1, false, &[1]);\n    test(2, false, &[1]);\n    test(3, false, &[3]);\n    test(4, false, &[3]);\n    test(5, false, &[15]);\n    // - n > ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1\n    // - tn >= FAC_DSC_THRESHOLD\n    // - prod <= max_prod\n    // - i <= tn\n    // - prod > max_prod\n    // - i > tn\n    // - tn > ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1\n    // - tn <= ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1\n    // - s != 0 first time\n    // - limbs_2_multiswing_odd: prod <= max_prod for prime == 3\n    // - limbs_2_multiswing_odd: q.even() for prime == 3\n    // - limbs_2_multiswing_odd: q >= 3\n    // - limbs_2_multiswing_odd: q < 3\n    // - limbs_2_multiswing_odd: sieve[index] & mask == 0 first time\n    // - limbs_2_multiswing_odd: prod <= max_prod\n    // - limbs_2_multiswing_odd: q.odd()\n    // - limbs_2_multiswing_odd: q >= prime\n    // - limbs_2_multiswing_odd: q < prime\n    // - limbs_2_multiswing_odd: i <= max_i first time\n    // - limbs_2_multiswing_odd: q.even()\n    // - limbs_2_multiswing_odd: i > max_i first time\n    // - limbs_2_multiswing_odd: sieve[index] & mask == 0 second time\n    // - limbs_2_multiswing_odd: (n / prime).odd()\n    // - limbs_2_multiswing_odd: prod <= l_max_prod\n    // - limbs_2_multiswing_odd: i <= max_i second time\n    // - limbs_2_multiswing_odd: (n / prime).even()\n    // - limbs_2_multiswing_odd: sieve[index] & mask != 0 second time\n    // - limbs_2_multiswing_odd: prod > l_max_prod\n    // - limbs_2_multiswing_odd: i > max_i second time\n    // - limbs_2_multiswing_odd: sieve[index] & mask != 0 third time\n    // - limbs_2_multiswing_odd: i <= max_i third time\n    // - limbs_2_multiswing_odd: sieve[index] & mask == 0 third time\n    // - limbs_2_multiswing_odd: prod <= max_prod during store\n    // - limbs_2_multiswing_odd: prod > max_prod during store\n    // - limbs_2_multiswing_odd: i > max_i third time\n    // - limbs_2_multiswing_odd: j != 0\n    // - s != double\n    // - s == 0 second time\n    // - *out.last().unwrap() != 0\n    test(\n        236,\n        false,\n        &[\n            10618490636539735421,\n            4729263067195600518,\n            12186030463696251555,\n            7142237826843540900,\n            16119581746492108114,\n            5482041831095653408,\n            12729359642514511788,\n            3861260445332999633,\n            17654643046781915017,\n            2948639619901500831,\n            4828424310736619826,\n            1606991017570978140,\n            14449535564474352339,\n            9583999911344645019,\n            8526753984697305947,\n            1483125246843554788,\n            1239190358257616768,\n            14274595842916600689,\n            8578099838285951726,\n            17196912285743182036,\n            17502,\n        ],\n    );\n    // - limbs_2_multiswing_odd: q.odd() for prime == 3\n    test(\n        253,\n        false,\n        &[\n            13440159167366384907,\n            17464845158472189078,\n            2826161362940216017,\n            8037578185636069543,\n            13742255038126785696,\n            4563220256937210164,\n            972898594381496298,\n            12935003271289472483,\n            92134269506540108,\n            1576249685989390350,\n            9293957639462726276,\n            13219082968020015738,\n            14036467266653166020,\n            5999133297790892927,\n            7879089681869446232,\n            2166730567576588847,\n            17427398953314831214,\n            15373827890147248358,\n            3930181242506798982,\n            16625114769217038348,\n            16998219128482634557,\n            10891990883556867133,\n            64,\n        ],\n    );\n    // - s != 0 second time\n    // - limbs_2_multiswing_odd: sieve[index] & mask != 0 first time\n    // - limbs_2_multiswing_odd: prod > max_prod\n    // - *out.last().unwrap() == 0\n    test(\n        2225,\n        false,\n        &[\n            1017787374069377867,\n            12845616420474236155,\n            14793541814949268171,\n            10336267089029193949,\n            17681045444610962234,\n            12241025939672520011,\n            1647783948166186005,\n            17853335081138702500,\n            5765698469319069076,\n            5704200848184839352,\n            16256105179485582433,\n            17734124028926156842,\n            492655904033205979,\n            11085849896016490658,\n            3067192438194807154,\n            11837646166112740505,\n            10992580052412267512,\n            1773657253076351848,\n            17041387235381257635,\n            15421578608188334756,\n            4615954739499965896,\n            13499729159452430001,\n            414946168188809488,\n            5319757607719939053,\n            14636961330979174035,\n            11228840029340991417,\n            2679650868790992799,\n            6523494380304249905,\n            15240167682641278207,\n            16817584289869342383,\n            1314876650236886671,\n            17986738819629100058,\n            633572152189350719,\n            1068154426686527634,\n            14065257391447683248,\n            14043628340189386248,\n            2520373228683116453,\n            8613302832793040941,\n            5920151864571800853,\n            6631973414231062372,\n            2805822256823597153,\n            8266805345818108603,\n            14961584013940036942,\n            3521359229908934002,\n            12440093989655599608,\n            13132030287112341405,\n            1135400476705565545,\n            13470237633228184820,\n            11041193975860352280,\n            13077192932837691259,\n            17293836581638404804,\n            2171592479756569901,\n            8391859231746033908,\n            13233250271168303683,\n            2885150469181476635,\n            12827004644907825951,\n            4414861260039887031,\n            2934847053891069518,\n            17933902203427299124,\n            13612729539900541744,\n            9092564372087223834,\n            16826850061886832697,\n            4235092271172303688,\n            15237133411303617967,\n            2524372566060934554,\n            10438528715364626770,\n            3931468119754873441,\n            8873546397604882128,\n            3022623706864869622,\n            7597020790388111878,\n            10943741155846665560,\n            14197476647010604491,\n            9989007778547549825,\n            8026201480421198518,\n            13607446335263109565,\n            16903088772085727428,\n            15808374554425019668,\n            6105563595459012989,\n            4013715839388158058,\n            15900509513105858779,\n            3930550334470266139,\n            3012225684372399152,\n            3555814020193574494,\n            16008860678570397127,\n            15641857373385284341,\n            15630999159384499531,\n            14194771320251995975,\n            420469150284887121,\n            13013286608344133197,\n            8528545810586239597,\n            5970238577029242260,\n            2388798772187671996,\n            7239099684932389496,\n            15198440189583552216,\n            11371225490310014286,\n            15452238839118434215,\n            5822580676472517141,\n            13899215192394129457,\n            17158467603319793152,\n            10977162731484357791,\n            6619469008814683154,\n            11754410156367698938,\n            2978824074240909961,\n            273537313978929004,\n            7247845064959191752,\n            14411883344186220714,\n            784118077426499313,\n            12871601200579333074,\n            8028216077204519736,\n            11850247931840500366,\n            3779495200526023485,\n            5929422344052886193,\n            2800123978803955913,\n            15699871195759344930,\n            3086311510046848853,\n            7356496574230285725,\n            6320159507583018055,\n            18115938954181399640,\n            6284941634674233267,\n            9549047133838384915,\n            9377608933266367603,\n            5075665075684086144,\n            690014617562733994,\n            4759772792411992244,\n            6111964336140423243,\n            16256222171952118355,\n            6259909518175821262,\n            3521565945796344197,\n            17834735129730212580,\n            9239590528624641975,\n            2672544178748226145,\n            12588486577096010536,\n            1899856248989413045,\n            12414729356008040141,\n            673936303178532624,\n            12049353462684429624,\n            18170970390317199364,\n            3895323652602044690,\n            6247176993757894998,\n            14018764694053309664,\n            12148460064737427051,\n            12519272021732992903,\n            4265286318973514000,\n            13246207213367864932,\n            8092301291433872754,\n            18157183851941858474,\n            13632398639372993593,\n            15041229054496823587,\n            17438882071637825679,\n            16897762262634509480,\n            5985915708134883861,\n            17069291239962633754,\n            4604617849471294129,\n            7404601016313800462,\n            18032855475618560618,\n            17278074032422674715,\n            860111812404472121,\n            7676514517933742397,\n            12645077157634386901,\n            6253760177721599414,\n            9582459955741222618,\n            6555031122495818025,\n            9109772022144641002,\n            10312926431630695967,\n            15174450307054914476,\n            13667236735660909752,\n            8408881821411653704,\n            11716946339587432929,\n            1922786935178624187,\n            12807837642974514636,\n            2473722894595905227,\n            5458426645784377815,\n            17442014199053342412,\n            8890119087458894100,\n            14425743191525790241,\n            16991179320870950910,\n            13035467074473694191,\n            5787345193441130361,\n            4705313533091031873,\n            15331508321092401972,\n            16030846562817685004,\n            3052481183062108791,\n            10562728949964566718,\n            13010480725459192018,\n            11461359799240800435,\n            2183835189889431750,\n            1589077507581674225,\n            209493893234690824,\n            17275528419958179992,\n            13786253520218962997,\n            8418527685430488832,\n            4277383631769243150,\n            553728001632835698,\n            9744726741627180359,\n            9472249747805929122,\n            2320471217112438768,\n            10501323670386497816,\n            7960518975670364695,\n            18361982008650146784,\n            13597146968161371494,\n            15048282371199457431,\n            11721290689994903139,\n            10236837511513990756,\n            9365853519324508062,\n            9624359956681910024,\n            6464188517998707741,\n            1613104032762890885,\n            8208472167568412592,\n            12800200029551711758,\n            3442648414208252067,\n            13536931097714636227,\n            13680099157307486964,\n            14296431146446833136,\n            9490494350514148171,\n            9088818047483723317,\n            3574838510805215040,\n            17710736595066585329,\n            18387087888522354666,\n            15545394289660342510,\n            1906938938574314263,\n            4795399658629299655,\n            5999021877917630376,\n            18186518198482153992,\n            15325896453672651048,\n            10288450437885059914,\n            10416325383170154040,\n            15252545550781802698,\n            11203850167434393557,\n            10930649003967455247,\n            4205680756002312162,\n            6052457706079534658,\n            8809248482758461337,\n            17439291973136036686,\n            14540031682752633228,\n            2866851932511598749,\n            7403683280133267157,\n            4543483651640135231,\n            10836604478698343545,\n            16677730720541412608,\n            10783834510772171652,\n            686367541545890040,\n            3945636644088204461,\n            16492288623082307055,\n            11410592877514597108,\n            4262454581966561376,\n            3226936869596190506,\n            2269258247007518459,\n            12712674876690317000,\n            715200030416229478,\n            4476123276882470939,\n            11651367928687373644,\n            7647140969145544226,\n            7054163724695468332,\n            9303767112281912798,\n            2511756170805945536,\n            767695948141735127,\n            16013838828931689852,\n            1660339257018204036,\n            17879387842407650206,\n            7329246204095148284,\n            12230296804697810396,\n            12554402033302195954,\n            143442532799357566,\n            278975221130083403,\n            704260913362329426,\n            16783414591993586867,\n            6420395195518570400,\n            1242530744355731932,\n            7229248055319127476,\n            7329179342212070204,\n            8801422143729346915,\n            7202896809469888435,\n            2740513910203208596,\n            1605583283743774906,\n            18133844077322829538,\n            12114669632852319147,\n            3777413896736836346,\n            10534763338306711186,\n            14271006494232962493,\n            2194873499284659165,\n            15408899770262126114,\n            9187831456838158154,\n            9493725892599084642,\n            2706928395034605310,\n            12457405692640371251,\n            17219883563575417931,\n            11342733020178340937,\n            8953543935614589549,\n            1650319869406153528,\n            1699668215805423570,\n            4658796056608814785,\n            10191145295455593970,\n            13899311420360969158,\n            14471878845989945578,\n            11625414899748956593,\n            16598163026893516823,\n            8574589836055525845,\n            7512292358343960576,\n            17973744362666546698,\n            4748081966508603098,\n            13114442497466532636,\n            17717653663975693,\n        ],\n    );\n    // - s == double\n    test(\n        2225,\n        true,\n        &[\n            18273847592806914913,\n            14916661124009772473,\n            13753012507801233945,\n            2177017738569174816,\n            16127046055767688953,\n            861596526990070502,\n            900331037467932077,\n            16419285249480787078,\n            16218119651779998807,\n            4449144590778508396,\n            5797432146873167292,\n            3658745141936919754,\n            545168142452805825,\n            17148224939070044052,\n            12094519636288888482,\n            1860524967909680000,\n            11944377795202454761,\n            450998278972528990,\n            6229559984764978492,\n            692524976150108183,\n            9064236318526181538,\n            6065732669816418385,\n            11346079520098762673,\n            14920005359765058322,\n            2824584984376391340,\n            16938886314725057563,\n            17162544784568094730,\n            2586797791946541382,\n            14296668031704924113,\n            9646825613588464263,\n            7079812537211058309,\n            11120058236852537534,\n            12100085017675020879,\n            14964503322387943506,\n            1317980653840108650,\n            778234578243207603,\n            596521671354538262,\n            5006607580276807142,\n            15407271393272502488,\n            15573500044631135983,\n            7935314468229974933,\n            5125906969614837712,\n            16281633070145926026,\n            10841335053186957525,\n            17450307718756727023,\n            12333034550501581052,\n            10335633642357417840,\n            2658401353173590381,\n            9928967891637445302,\n            346433133502823118,\n            1125969053347945942,\n            12869295090499245086,\n            7161688279795242985,\n            8102170348534423246,\n            11501976328143442721,\n            3139756684381179246,\n            272140454388501101,\n            17653947300704655935,\n            18170419175440044364,\n            11620223751270977055,\n            15199737729791407954,\n            7388408950276186267,\n            9421939597451630319,\n            2597904459804208335,\n            6415494893523120358,\n            11278503427630235513,\n            17087603759736271563,\n            8499727139718896059,\n            13078202821805789519,\n            6267232287377047314,\n            12745328769944065239,\n            633458985557193041,\n            10591869002113750048,\n            11717141398383033199,\n            10182159168145114245,\n            15297338266339549376,\n            7675716384162360916,\n            14044976791404615146,\n            4826327060564654494,\n            13824111753357577432,\n            1900118510953347559,\n            8934435809233468295,\n            16936724118164099477,\n            6715750096675555516,\n            15742093305101977345,\n            6770550399746614438,\n            16893816526813516547,\n            3972985572344553776,\n            14352636830428013583,\n            7235300939595407519,\n            6482168811103125826,\n            8529869224520362482,\n            275752241061888521,\n            1657885970020523479,\n            16055229676929243472,\n            1329626840527245712,\n            11652057338991275044,\n            2200299065278759357,\n            15923824600667998353,\n            14452285691076415854,\n            981741195753309331,\n            7201095575238789005,\n            13340345121085282794,\n            2680287044054356020,\n            9408615051995915315,\n            10441077296581096820,\n            14712361458266681524,\n            8124482655364073111,\n            14222323278853437602,\n            17070664871184295932,\n            17474138478542725542,\n            15177656584895433414,\n            2526272351085273991,\n            6899922232335160103,\n            4319287874022868518,\n            15816851634040015111,\n            12112152024215446224,\n            3606792321694648705,\n            9429172934661010546,\n            16821618974076073653,\n            12119323924085732779,\n            9269996314367783608,\n            11677711150311827044,\n            14826179744550864313,\n            14311566973567724922,\n            11690766935901640332,\n            17692848354524494381,\n            11471034271597096968,\n            1783135434038615748,\n            14881574202813672930,\n            15830300711784462210,\n            630062474555626774,\n            17060519393404392624,\n            14757894127409047620,\n            12461523429328038945,\n            5445397329406998939,\n            17884801583819720842,\n            1818977548627787018,\n            9113900825703689420,\n            16915916658972784066,\n            15622182061515094917,\n            16920477467185064686,\n            11826213325249074339,\n            5465014424784826852,\n            7335719503225494900,\n            15841161992748631086,\n            1299642982951657968,\n            197715083125423811,\n            14284377913572972912,\n            789668823628960978,\n            81036771547499486,\n            1988737592120412916,\n            13618394416444865222,\n            9426939251263437583,\n            16147835905603573032,\n            14670138126638825807,\n            13365861818007883916,\n            187274109266309872,\n            15584591815633641607,\n            7468625031687560535,\n            6620786124781371382,\n            13074327572766063757,\n            8811083685803335562,\n            14556428240003445098,\n            15168607761515723842,\n            8228373127931581991,\n            4449537695769626872,\n            16189599284483220268,\n            797498,\n        ],\n    );\n    test(\n        4070,\n        false,\n        &[\n            8108005815282335195,\n            9146844186444094918,\n            8660083345757410800,\n            8098332886796284485,\n            18327436189098520241,\n            3444039843702503689,\n            4140780547010543813,\n            14037137740150481503,\n            1778663445558401359,\n            8801570388752073452,\n            2100918768041211855,\n            524703799362959113,\n            12962247820844726992,\n            14701744186225035810,\n            7313567667433951704,\n            10050831291847253075,\n            6522212258387665281,\n            9713357079840432969,\n            15650953094464421347,\n            1209849253782734984,\n            4490688349070706208,\n            3139050496689458569,\n            12245827531446440255,\n            7885981168676004558,\n            14154661077321356322,\n            5349852652757407610,\n            16092452000899791090,\n            5332211751874201060,\n            2010166260630364055,\n            9798313122251961485,\n            218932147329958256,\n            9022218650847797161,\n            9247716414481763471,\n            14400589478286751493,\n            155515641352761450,\n            16090683018468668029,\n            18438337824921230249,\n            16750617951041927284,\n            4466848102871550334,\n            17245130053737553841,\n            5684920055966011256,\n            17485566453638379463,\n            3876098111780047824,\n            16170758650201105177,\n            3329608698571465239,\n            11098790367425582117,\n            6479997293989211563,\n            9589433605206440133,\n            1627857831675420300,\n            1732996071343246956,\n            13677549908265537781,\n            13009227383550369090,\n            10961856472489506886,\n            14877397326320187840,\n            16507486074381907645,\n            14585352423433247440,\n            4772857464862032589,\n            12016886091453855080,\n            7931222225152140551,\n            13652152998550600083,\n            16998629316990967973,\n            526526529893597072,\n            12092338051210294623,\n            6819207438863426635,\n            11198129540720007747,\n            2941664361484076111,\n            11290270564500831896,\n            7141368769790257178,\n            4310192286254467973,\n            8626208125424982752,\n            6486300810327348993,\n            16817813221529065857,\n            1665451483178444523,\n            526626375466106821,\n            1558004989071692770,\n            17197912381461676471,\n            2028020400876381294,\n            6632176584976099417,\n            15853871790538747381,\n            12244096904102365064,\n            7885917276665675411,\n            15005896934276204010,\n            10004696875159009950,\n            564876699456822610,\n            10276340856888745756,\n            16929103490933678961,\n            11766003323021850140,\n            13379448244674233012,\n            1700622392771761597,\n            12998026843356148399,\n            14386135549950737873,\n            17103249986604805696,\n            16786552926533509269,\n            15192402249011372416,\n            3682655530759859389,\n            6438705993413043824,\n            13321028524215423815,\n            1823597566198742888,\n            4362292623191872397,\n            8810115919852355307,\n            6024401878081901215,\n            6718375548708698908,\n            65836699280473345,\n            5459920132720522842,\n            17611518624765606886,\n            13413230224953721533,\n            18269011901647493745,\n            11482220135864365751,\n            2391276440752141958,\n            7953372639070979047,\n            7719335541802590983,\n            1578078632861068430,\n            11450608370291117368,\n            17345790563481277271,\n            2471612067088960322,\n            9509634917954887016,\n            15790984357169346054,\n            3068287571882149714,\n            471828767153656274,\n            13989984920988442927,\n            7509949839462576562,\n            10968664464658574290,\n            6077107907583745923,\n            14180003222908660504,\n            785997593410843284,\n            15346199982210062573,\n            2127241843253405780,\n            14106663760181537824,\n            1816989325079298256,\n            13585984481704676966,\n            16775201233882366395,\n            15894543543338446770,\n            1107757662154265429,\n            8343871796706615587,\n            4004079488409770502,\n            13897369022267696941,\n            1900082861214911602,\n            716522355498280832,\n            10878671752431301621,\n            10824325209201257147,\n            11326396537153935107,\n            3449811571484933271,\n            13282337890784915268,\n            7114243324086389360,\n            12077364721569316700,\n            16806236645113874712,\n            3976467828062833535,\n            14892561338874070677,\n            730742184143676508,\n            8041199874795643530,\n            10588477393010195205,\n            8741684265023787402,\n            9323226257963451657,\n            12383914466097937740,\n            5459183481775283109,\n            8713085987825614917,\n            13599525973515812615,\n            18412620200699133025,\n            6654671808175209159,\n            15512514585286904591,\n            3418160363584141286,\n            5329252877044658765,\n            1773517879281305085,\n            6751907522769980960,\n            5595071891327138711,\n            15092986339807365771,\n            2637668950041653368,\n            9120481822278454853,\n            6888869033907116052,\n            2355630305042933816,\n            15643204059310730325,\n            14189972604337948712,\n            15973742050610849695,\n            6242065490899143192,\n            10363937503100539096,\n            11070337623129049141,\n            8371320746562326912,\n            12695119021290132172,\n            10946420405222747694,\n            11793689207562115243,\n            9738441606075555748,\n            4055649477600335048,\n            3880331981234421156,\n            13347438816701426930,\n            17047267217526913425,\n            14743067117062752918,\n            7500680963739160488,\n            3488447525771141371,\n            9324555149161510174,\n            7264600294919436405,\n            9007784967508818611,\n            6103106720642023698,\n            10517676694084426843,\n            15560433103569708967,\n            2746068979338915377,\n            4985185996082465965,\n            16952688848835623971,\n            5109870761485173378,\n            8634678600073803408,\n            2319185650670298791,\n            12712939795386441047,\n            12844727668639157639,\n            18206839820669131705,\n            13819514640691885271,\n            4818348659491619709,\n            6617480138343747641,\n            15213182099370869167,\n            14637440613867531472,\n            9652794545650675745,\n            6662269855919686728,\n            15464527851536273824,\n            6948300103349899268,\n            753008641517257019,\n            18423686888802874368,\n            8667176541059774446,\n            7099552216889810617,\n            5097390314227011257,\n            11164163665133923676,\n            16601595315094089072,\n            934251793604345199,\n            7561790558864090771,\n            978936761586367389,\n            17101343332617286825,\n            18235594016090146675,\n            8892479711303127261,\n            9809871209460262551,\n            2394882822052699187,\n            17253801929346615689,\n            11866062736428885642,\n            16437653361862401491,\n            7486219130830357614,\n            13720638887748552989,\n            3021364063186030632,\n            4790724598986510238,\n            14359903221320647419,\n            15701149522880886933,\n            5746571782218451762,\n            7210169400177123347,\n            10042203436933651963,\n            12677504245079166833,\n            18175151564707403074,\n            9425061978030509015,\n            5758590662601337386,\n            15348859264339969047,\n            84847087193038207,\n            9111274560170647524,\n            4278081610518772774,\n            12529339272615071307,\n            12409855992802623412,\n            9523579083364964737,\n            10131834173738880007,\n            13754924237593988998,\n            621522042857583856,\n            7464325591076653888,\n            7830537412804901743,\n            6521359168347430210,\n            16894039362572777376,\n            5413242484644566268,\n            14890107208076170436,\n            12980026768650320887,\n            11398310152701007006,\n            4453768301766954152,\n            2532536434582483661,\n            8315666704783771480,\n            13461364238018113773,\n            2367277318932022237,\n            17591329597188385026,\n            11375623002647255287,\n            14912925391917134409,\n            17574598362054282658,\n            9404088160471690699,\n            718445096980481234,\n            12792792291239978324,\n            8006961223861908611,\n            16462573277199771867,\n            15753551978373173836,\n            1165618856952885551,\n            13488872490939284662,\n            6292751434775819077,\n            17978555343322705896,\n            11917634234603254804,\n            162840434454496298,\n            15468092375694967720,\n            10967364594358191032,\n            9314385576792743968,\n            10874257552955261204,\n            4080522163464587172,\n            775060301135710213,\n            15512539461380143991,\n            15282862206590121475,\n            11634145833295838957,\n            3729296162985408021,\n            2708304538658858121,\n            12973478170148581224,\n            8050517243904765020,\n            7652018392181115173,\n            6828100662787911762,\n            644540307178504165,\n            9834244593696654688,\n            717190824240544061,\n            7918203759694436774,\n            1381239225989678565,\n            4037837100601917635,\n            10802212765762616104,\n            15085162986324183364,\n            640803418391629184,\n            5440933420358031637,\n            7912472064612543150,\n            6022949383217060170,\n            17164562859107739409,\n            1707274268270363419,\n            16353036691579357283,\n            9896120685866007660,\n            5240055324003979103,\n            9943488260620580398,\n            2795797772511437220,\n            15728639203804433038,\n            17163352271120418930,\n            4576984692721900001,\n            9920664011545963272,\n            1162651417625311508,\n            17117469006464985573,\n            7325235138239111279,\n            18304978043412704382,\n            12887402943015993511,\n            14814534017899278196,\n            2423645702540296415,\n            3089940732951430909,\n            243463633479215389,\n            1853544701457559150,\n            16340002828745074453,\n            14353724121437826749,\n            10091976479103341782,\n            16445589728945554096,\n            12491958380500551140,\n            16956760932267439248,\n            8027499409757227236,\n            6125007472513238023,\n            9932580797249172181,\n            8500623667517585457,\n            13042021579813295620,\n            15746465657147920157,\n            4336138550822800341,\n            9810545091138121169,\n            5082389296265504858,\n            2797088738314226811,\n            1788720676657601196,\n            13852906260052809399,\n            15901487609613735742,\n            16898133139552432839,\n            9518583808608390497,\n            3135780694510726770,\n            15768959579073101320,\n            5060730587445662107,\n            13026896330095181663,\n            13406455708166664349,\n            15874938122077036419,\n            12502020629429544436,\n            3206388887230923597,\n            5335712912997776161,\n            18320472783623629896,\n            12300785747455089667,\n            13200934099356667514,\n            16185793709615010552,\n            10504644792424617533,\n            3165770672396699194,\n            9659271587384891683,\n            14071499891855926173,\n            10057304373257827497,\n            8747735409408624915,\n            7073755668073479290,\n            14289860991929203106,\n            2241519710446822187,\n            3895111632723557508,\n            2526746390679189521,\n            3116945709823411600,\n            17383197281821176783,\n            7952464668971727516,\n            6901807899244715536,\n            18040113216886148526,\n            4268131054090303895,\n            1487358751414798288,\n            7752711065051636269,\n            782881033717716437,\n            3048915553972286578,\n            17944199781198644729,\n            9389246360770923456,\n            16122431310696436556,\n            10776235947384101503,\n            11061273148200041873,\n            11376451884458646940,\n            13228985150393505898,\n            10201260035282798966,\n            10960968295486930139,\n            10150870526387620225,\n            15622960701236479318,\n            10830024109717612388,\n            11069526249991212591,\n            7177411583475908506,\n            12883497517546755586,\n            14452533555439112738,\n            2319722755462632117,\n            2707463600284124085,\n            1640962093580202224,\n            1781980281809689073,\n            15431145229979346468,\n            15450020011414281071,\n            4610352806777138140,\n            715901537448564375,\n            7906779838611334191,\n            9295186163734943091,\n            13837118237702626530,\n            10628587043038215377,\n            8173817480377720286,\n            18146513027571012760,\n            18034377209743766349,\n            12416434057720465458,\n            16863109019369808778,\n            17598425176089192373,\n            7838352420531465275,\n            6446253944183856472,\n            3217827157412015166,\n            7736416779564775474,\n            11944279093150198319,\n            1359722430089967762,\n            12944512655507306702,\n            6968226813496259100,\n            10697114723710345120,\n            12045439838989284122,\n            14360294208856859982,\n            13554544330260187416,\n            11960481134019314560,\n            16193728456024646791,\n            6788935070457860696,\n            16784253667098474942,\n            346235036471591563,\n            12579823797379718533,\n            11237106727685787594,\n            7376229368874669746,\n            2310494137345974933,\n            10699485085862861475,\n            17827376656397906407,\n            12654909010486092313,\n            12911864664898312670,\n            16753920293216445659,\n            6665140426308933113,\n            16331633263932455518,\n            10109679348425115019,\n            15893667959446481301,\n            18406325439525742133,\n            933973555678699597,\n            7168028379341447244,\n            3151961147604448767,\n            16537206733760622467,\n            5066764475441679955,\n            18142248769235084338,\n            10267108442140677091,\n            15428903838728157772,\n            817803212986250530,\n            14382377762501152229,\n            7294220161923800220,\n            7081723256077136000,\n            3334475525919947583,\n            16199270874538651756,\n            2344559218216607405,\n            11987285877097183410,\n            6271232791990646890,\n            8865933992675026303,\n            16277240149463018400,\n            1656896235599446490,\n            11150448321793527957,\n            4631896433546355206,\n            8877084437753247207,\n            7307284130241324899,\n            3898492975685743779,\n            3665446048463257912,\n            14648028503878372256,\n            4141262678851999482,\n            15769177955090495312,\n            15700478929465111924,\n            13772286815471806568,\n            16819697748793130742,\n            374816477005121133,\n            9978039585089436623,\n            5388602092448346783,\n            7599620772394967758,\n            13068216955460967229,\n            2209814478936490342,\n            11426676931961095314,\n            3575899553386457735,\n            10074556064068343208,\n            1175343165804101193,\n            2579842808821635021,\n            12160230121712404482,\n            4570123963392650145,\n            11533242066554433675,\n            8978786221712843977,\n            2519957542118309466,\n            11338180312992409210,\n            17438791722639593890,\n            235036220639090508,\n            17299731811003138346,\n            11345013161471373979,\n            6808878923112761884,\n            4906649794209058970,\n            14510541350917650537,\n            3129870112661089444,\n            6780443774321041251,\n            10383203886842753587,\n            14791651661609640635,\n            479104220414488434,\n            3308544737491745274,\n            12357304405135409837,\n            17075636268959836058,\n            10907896764439381067,\n            11643599381158439431,\n            18424980765811796263,\n            8249222402674259286,\n            9896706913692159539,\n            2152931576999706359,\n            4727177868031013262,\n            3266165952382965456,\n            9085838590190029565,\n            16643373348625444382,\n            11565678787598161058,\n            10615433009880595611,\n            2811627817244839406,\n            17919168585610158932,\n            15174362170354828474,\n            5597023051532920206,\n            3411824531765525771,\n            2887283203315816513,\n            9247340977378434321,\n            8972524604189795344,\n            3111627944095111700,\n            13483341139541609028,\n            9578789344755939896,\n            7839906735318986374,\n            5332229875909435203,\n            11793410887897771248,\n            6502944694411264103,\n            3797221239185211363,\n            2318303302786427439,\n            13589147558791336226,\n            13963887555481507589,\n            14815243147364150315,\n            2874636415001201973,\n            7791969142922524431,\n            8142478508158078750,\n            16320253976455093478,\n            11410599986950683085,\n            6941190512875461993,\n            714780298870163634,\n            12186367514332744780,\n            7396330582410885775,\n            11973894210027103516,\n            15383581181396047007,\n            16278071189583596534,\n            12216205906506175663,\n            6100928555352159602,\n            2937593753448772352,\n            14364941381544585739,\n            7143026965390827808,\n            12201653352837638909,\n            8268259781562500315,\n            17457954864467036821,\n            1325561951447557612,\n            1830250720349684188,\n            6503632833560144671,\n            8957246064803922704,\n            13184493622423870667,\n            3800624358443674755,\n            5833302624748742405,\n            5853990385357953007,\n            4303717340298687263,\n            4513758912754435790,\n            10845881821986243973,\n            18314135169801212762,\n            814247782154798077,\n            4175446608061850087,\n            14066747770756565318,\n            16223104902964522012,\n            14386221615141474583,\n            14286245335107087094,\n            4797660228332850220,\n            12494772503717947664,\n            5046526480383637489,\n            4695803558343679414,\n            15207164406494018074,\n            10746131379349268959,\n            13427849410099074058,\n            12960999646017015515,\n            10875962048958581312,\n            16380543578406679915,\n            1081549612447048742,\n            14988053947085110551,\n            4719671945245391810,\n            16089148134643534992,\n            542091408184916386,\n            17256758054232279755,\n            4139827917918018104,\n            12212703329706756000,\n            16728271907145403562,\n            2812092140620955679,\n            12743744931348422865,\n            1697950412660640926,\n            15168405896517504340,\n            600504526,\n        ],\n    );\n    test(\n        4386,\n        false,\n        &[\n            2067770789339411803,\n            13103096875436466845,\n            10775991317478993717,\n            12967380299398919437,\n            12020325680191252113,\n            17748295712695560928,\n            1429341763317489229,\n            12678340224185994909,\n            4335442947861292402,\n            5254780375536440952,\n            17074502202508083505,\n            309407234721139885,\n            13452727935428837455,\n            8651378078472139112,\n            11512513997222178700,\n            15910186442568670644,\n            12845112729418812790,\n            7897815290878156013,\n            9244723605015583552,\n            17818446835461168600,\n            9268757667201962790,\n            13518324509513650058,\n            10462750832084307848,\n            17365663074296091214,\n            3601241491427429096,\n            16011129535131124250,\n            188279845157362453,\n            11102064840933848532,\n            12976705436704377860,\n            16067635780216235799,\n            15111235286034779573,\n            16949342242668510111,\n            15198057271216638117,\n            14221135849758717397,\n            4944363911855682389,\n            3187706824974319087,\n            7338540094563526202,\n            16578881813150901018,\n            11167625661382169176,\n            517732891565245060,\n            16978960760497725346,\n            8776342161961474572,\n            7065757446489966082,\n            7633843099211849039,\n            10126092316436660909,\n            7137931307826524381,\n            10378215122356064905,\n            17259871895964295908,\n            12904171429142559149,\n            3245154771911236476,\n            14137987011116880665,\n            3313964895395428359,\n            17536273921393851251,\n            713485028257444541,\n            2504041554095751793,\n            11868371391163863223,\n            6651805351133757865,\n            6667440167584357174,\n            5410381989650680365,\n            14991818175930336399,\n            8257594786289573987,\n            5706253266337186736,\n            6124744329210826966,\n            8947309000932886151,\n            2828062293304464966,\n            2945904981118350722,\n            9340961774751783834,\n            6991179653428794675,\n            10353734651419249748,\n            9995290938924246850,\n            13748292297662222218,\n            4892960822908531583,\n            5001073284079337557,\n            13395090824536719310,\n            16748415575373971262,\n            3794277149064466315,\n            3471133925886159212,\n            18287753555606486434,\n            9672715726223475697,\n            274643140420740271,\n            5084208256841635357,\n            565582889520143382,\n            14443006075048681485,\n            15151943957630016490,\n            2415682863008959026,\n            3647193967014640950,\n            4900474299482998069,\n            7440294411928457855,\n            7555879457509324101,\n            11720033631659853173,\n            7634817390629418714,\n            5364401984816035681,\n            14274975916464347588,\n            18110903883298124645,\n            10451080161694932573,\n            17274117833138202923,\n            13092023069546038740,\n            12707287623023466476,\n            17701880209880420627,\n            2721809281104108355,\n            17847139586804083902,\n            17102921262115553190,\n            15532642833766944434,\n            1280075840001965788,\n            3761354226423057718,\n            10238421667499233931,\n            16260871926280516440,\n            9728473062383715969,\n            5953520808705507799,\n            263442908611940290,\n            12837547734028811219,\n            3287327756734946357,\n            17180396981733070497,\n            6685721691481472712,\n            4223337774056033861,\n            17203789254093256094,\n            5506147567525874801,\n            17525679577751101209,\n            10962165345191958610,\n            6263807420731253205,\n            3923945801149572338,\n            17284772696566520082,\n            2337995081818459703,\n            10159695744432522804,\n            4645991148779039189,\n            10456895348208050580,\n            9609163518931971560,\n            15343500081229831267,\n            4516517331522645741,\n            5703018699998096839,\n            9289174806651010588,\n            1907313371747641829,\n            9700205622504251902,\n            3384501760799438251,\n            5592475228402079956,\n            5699363979963530528,\n            1772165853917465545,\n            18293565878034536773,\n            13506779974076830618,\n            4433695301786679145,\n            18316157440486549103,\n            10582239038922153367,\n            37236612930183149,\n            17966150282195407897,\n            12541413422471328583,\n            3221443629988836742,\n            10375517911848610163,\n            16312415585539573309,\n            17263637399055711337,\n            12562964968987510931,\n            948248222908469656,\n            15567975209379123460,\n            8261653520686110354,\n            1999465121504211136,\n            5781047899520920323,\n            6315198745347909330,\n            2920278920380027756,\n            4345551993213715119,\n            6283657344621674559,\n            3606906764584629572,\n            3214509309748650204,\n            4421650669626111069,\n            10113279086264766781,\n            6040809634318513184,\n            10105872563177742877,\n            7530051675459302141,\n            14917228249506435637,\n            4803471693748163459,\n            15339413088591036105,\n            1138826137575079324,\n            16391062326234990346,\n            14971482629623839337,\n            12498986044767135726,\n            1758634949316069683,\n            3079336619173718801,\n            8019450776809033904,\n            11043397957650314282,\n            12422777714615135210,\n            1600737775507512235,\n            18027592484657533779,\n            3245499257818457797,\n            16997244019634782986,\n            3056694745780408313,\n            16838597974032301566,\n            4231066868194520257,\n            10562550261283056758,\n            8961231382598729157,\n            12511921298671716507,\n            1865431125930113477,\n            2907259905584584543,\n            16284546744177846395,\n            16912600838448041892,\n            5685768352085959742,\n            16073286910652494724,\n            6283460899260262733,\n            11006248608684764980,\n            12393743873088932506,\n            12391913626649357467,\n            15016416664079279639,\n            9408641421320112644,\n            4025080079418204587,\n            13515889317109760861,\n            6226634619622204428,\n            14051645394100010803,\n            6133348733808000448,\n            6549072550797710617,\n            3366502349209799505,\n            4214984042943155540,\n            13545152513431319859,\n            795203566590623457,\n            2957066876294725061,\n            14037361440208811220,\n            3567928787052247594,\n            18129592358468459211,\n            7391337147860966470,\n            9745224408810299881,\n            6273194274566822118,\n            5865744013188664203,\n            16331376339301383887,\n            12655709446461158338,\n            16058749309251802594,\n            16013590485222250734,\n            17377122665244463023,\n            1879007341157847506,\n            8175620709685639847,\n            5052075645054700814,\n            14604619995008524058,\n            8996782117651602293,\n            17751524763342629241,\n            6405720938723467480,\n            9374406085408070641,\n            10902473135566069570,\n            17299547825885109840,\n            9378213062126977886,\n            10748234354845075895,\n            16298760983383038268,\n            11912524381622117490,\n            17531579882154090089,\n            4638623466945320294,\n            9718336125194098908,\n            17748627584772750138,\n            5929383739994257604,\n            2634528888377348952,\n            7452587852059168494,\n            10479972321254713875,\n            1207579517364184495,\n            1227691654580968152,\n            12283325902343980973,\n            3630742542495239330,\n            1557735469640288318,\n            13148409011485075278,\n            11694984553024128048,\n            13853138208344888607,\n            13075028243661617397,\n            6077061419898013703,\n            10759228302707904856,\n            7134870213220203017,\n            17700670474189599567,\n            6488352687619878666,\n            14335593354894875389,\n            6344626185331917569,\n            14406699681719439442,\n            6714341065455077735,\n            4791758696562431350,\n            162497200523271921,\n            17479090938200299691,\n            2988688594805820109,\n            7777421366994092731,\n            14642692051425214172,\n            6274682819626865559,\n            5229423047741496007,\n            5654852991719816168,\n            5055395278775913297,\n            12041756526601788850,\n            6814108790911398001,\n            13599277275502247027,\n            1574731768977388996,\n            14139185185305594281,\n            10348783097165818778,\n            16356555785871812759,\n            8509205960970416974,\n            369792736551032730,\n            4928560669248384211,\n            1496296389308083367,\n            275482014864563394,\n            9515713819908090443,\n            13779279241489032499,\n            5922260955368225052,\n            1092706023383976782,\n            2360049775560684078,\n            10830508317428607424,\n            11355555062201315465,\n            8822901367110163092,\n            8360846078201768657,\n            5610591053096960621,\n            825839549030470748,\n            4354013872927963141,\n            6246140926823935603,\n            2664120007387415299,\n            11028705440560322531,\n            10625898421812353966,\n            148691473840606177,\n            8310156060530348557,\n            6684141576519691078,\n            10666277726485832508,\n            12496909850771141958,\n            12640316601276796117,\n            1625185014000874153,\n            12691818688161663560,\n            7284978345576571395,\n            13570120000390501180,\n            17258139152508325657,\n            16431051452047113788,\n            18021498085837424736,\n            147540858693017597,\n            16489503519317138018,\n            6384423972105245397,\n            17968902491833871706,\n            9389823822199644659,\n            14015616956644237252,\n            1624016862827524307,\n            1133086695225646084,\n            14210479644264771704,\n            9354045035850960349,\n            4999905551939222112,\n            127779107599803994,\n            17188565212169682757,\n            9095797152343956231,\n            7477994596817475252,\n            6929119664609167341,\n            3026229977813010602,\n            3373603747000003839,\n            402015014046664505,\n            26644720949978834,\n            16550954361894454284,\n            15537993049361919153,\n            2802848809767628844,\n            12723476677303988431,\n            1452153691672522097,\n            3434061729562431318,\n            729282772583672128,\n            7702161485333588893,\n            8717527779288695787,\n            12363485505590025970,\n            17624693189004583309,\n            14685537190335019953,\n            7702477702547611841,\n            13950049520337589373,\n            995603177974720045,\n            1908021199455081620,\n            8666881553466182833,\n            18205165727916302250,\n            9075169860963458400,\n            14214404287201285116,\n            3730790297335296211,\n            16018490608374186886,\n            3817924654967992585,\n            2594301786026675009,\n            15391635385542285594,\n            12501364696981125528,\n            15521243366566790239,\n            15115184551511400222,\n            11890281585537800925,\n            13743275121740710291,\n            18290209697475844389,\n            9452021830711120855,\n            9366033362614110364,\n            15189787976271753218,\n            13926199825258867108,\n            15495826818284245741,\n            8531249945458971662,\n            17589848977595818263,\n            5117260420662179148,\n            10609979181463468221,\n            4913348785482518086,\n            10558959588352660372,\n            8256184825576553677,\n            15328078566821422102,\n            8369548310319076057,\n            14408099923166180103,\n            12023136302419338418,\n            4185185540229752140,\n            6826802409442294703,\n            7577964011315904722,\n            5184334342724491008,\n            993509100019263200,\n            15931436829275119251,\n            1146421971146413118,\n            7457752172737922635,\n            9303468447317898804,\n            16896814437635093007,\n            2897580989878368123,\n            4607005167306394543,\n            13191995560910209108,\n            754818302289945956,\n            16550875926839443808,\n            7988613715747824244,\n            7594021839994771817,\n            13390383436084264345,\n            10818741266704850020,\n            9840567310602600933,\n            6853317455240951849,\n            3654318299357871447,\n            7165021883724890419,\n            366327955050086071,\n            14929430926370816287,\n            15929091848994821752,\n            11105903166789344918,\n            17397713166933660028,\n            940076493347828340,\n            6881587310329390584,\n            2525314747911475552,\n            16039575856899289003,\n            6590095526609987943,\n            14780829395712816729,\n            13403664212049269290,\n            7776885716456199825,\n            7327709346503253495,\n            7797242194106433773,\n            16614929396385540024,\n            5614139257682381061,\n            18047475783289703107,\n            9666137234872592914,\n            18196751923076222182,\n            1735358215136480054,\n            2825261148642530486,\n            17958215272827091532,\n            4229064305320080722,\n            8107409220128419983,\n            2659809653637122796,\n            8461071852700444712,\n            2853300478568934095,\n            12627226863684674629,\n            1725915213416318852,\n            487301172206353235,\n            4413773887930902588,\n            11380364842493382110,\n            18202450692039293805,\n            7784494480032084716,\n            12727459447363886037,\n            9477329144027792300,\n            9375946880998142541,\n            3850113885112012173,\n            11830472656413909940,\n            13939088354425096574,\n            12431341669790120564,\n            14604778789765165983,\n            15232263358213700722,\n            12591997966392050807,\n            5934537059080957325,\n            9116727594927728823,\n            831125065896912587,\n            6919754862689771483,\n            10898884224579093352,\n            10194872422166905419,\n            2240873485886821150,\n            772949527074947092,\n            722360265481154865,\n            7863960452925898308,\n            2995106245389276294,\n            6413625243236464846,\n            11417572663652050724,\n            16800248131553723377,\n            13503562407484296894,\n            13751605094817502750,\n            17009103221214602662,\n            6290212481944391998,\n            16492192720802115237,\n            3359973450786126320,\n            18399902818940892859,\n            12411848360389779577,\n            16353647163615635517,\n            14511780882165179745,\n            4167580674549721515,\n            1157978505376818537,\n            4823712731701839796,\n            15625736345573532694,\n            13451767465863821756,\n            15449238941112417676,\n            15564277366463860073,\n            17123483066444823350,\n            17728013126554602313,\n            16630084534442117029,\n            3077949725867728231,\n            16563931105160154865,\n            1246592974021224293,\n            12466022741969968785,\n            936399083803917084,\n            1508756071576207725,\n            12593257295671577526,\n            15030750707522627616,\n            13422604362668833145,\n            5988522993706110934,\n            15545744445564958732,\n            1333287819193404898,\n            374964701110478911,\n            1268449382615324030,\n            18152641639961098650,\n            13911634194020977647,\n            15751397195385234389,\n            11910107323217822218,\n            6719368906000612979,\n            539357533696613124,\n            12370714977713865320,\n            11182314386535123678,\n            8119574039901243532,\n            12179800389262010105,\n            1510115720081333085,\n            3080816336433056477,\n            7208163224523064396,\n            4484890163125768129,\n            4471197540253572019,\n            16164979284990145212,\n            1352434240322204577,\n            17709563636005322148,\n            6175465245802596932,\n            2813064733658804479,\n            3729563625698838686,\n            17030954856394461019,\n            8814338780961745521,\n            2180303021116863804,\n            10602246745335408702,\n            11278176099084345908,\n            2989599815829423813,\n            3174997621154098140,\n            6013428651509341881,\n            1056309801926189131,\n            6754803862830721714,\n            13831276002295643570,\n            1528921296308702728,\n            7027293378815715253,\n            14550621546237275727,\n            14579138781069179492,\n            16649016585856135100,\n            2169005788597798917,\n            13545574963505347448,\n            6837331033324486251,\n            7090962232927689286,\n            4662659566106165098,\n            8754777632717149483,\n            5804275858791907219,\n            788853342477740755,\n            16728861156177940737,\n            11428624619995598035,\n            14984172660064414249,\n            7586067300257715870,\n            13544922098234698859,\n            13257509618658838381,\n            2652216851092922006,\n            7861597740154527454,\n            1410202913196998970,\n            729890979789569621,\n            2143681954235555293,\n            1922907112472408969,\n            3628498397933816460,\n            7247461113839898678,\n            1912586770250857938,\n            2554218233645160534,\n            1743595205444296423,\n            8767829447546562406,\n            567862460760224080,\n            7305055418633592092,\n            16866314930981097852,\n            3795937503324310941,\n            5621962951370066494,\n            8868249692690458913,\n            721008487395008718,\n            7430091675158085829,\n            16331765483270902465,\n            7335683441619026843,\n            3257550354989871481,\n            18264160295416879866,\n            11136793850551427435,\n            10546469165077048539,\n            5550997632077748707,\n            7153389858358930639,\n            5061349939637694485,\n            3990963419914210519,\n            15864228418379343270,\n            10313411382620536299,\n            3247364825267582220,\n            16798279756492637943,\n            4799346260722321334,\n            18161385831180514221,\n            5680400420092624151,\n            10244339711594697803,\n            865876781659886278,\n            13652502876619329633,\n            15440911199202656750,\n            8821648827419111566,\n            9157488610126501397,\n            10945666626044426963,\n            6969723870784479629,\n            15622137819654655923,\n            3894460376560585304,\n            8699178934690713236,\n            11719950596492741147,\n            4303171596568431905,\n            2201336563349598335,\n            633521128747937906,\n            10783414600329714759,\n            12633157919692423052,\n            16165320295662473268,\n            15791357301220105561,\n            16707503754652450664,\n            14638594967732844399,\n            11617299177772471971,\n            7307198283537189698,\n            14701917077406390219,\n            18245496844025624337,\n            11104562001690845490,\n            6064130654076660079,\n            6513424921504926691,\n            1737851892642531957,\n            18377988941784482593,\n            8034223685660909576,\n            9983995693134438566,\n            4814979217316997434,\n            10286008916702006441,\n            18263950945303861757,\n            17727582182642068647,\n            8847975247191099221,\n            14186530850444591231,\n            848650607969070940,\n            11636660174669653982,\n            10790673005564564668,\n            14420034928065783601,\n            8938173207516609044,\n            18440352591895674931,\n            13402033683256872796,\n            18045033870573153376,\n            2237292078652826406,\n            10211782132693590673,\n            772050115413368836,\n            9260457899141949663,\n            7450174044286317401,\n            7479368663774737969,\n            9236392813906009688,\n            11260429241598988834,\n            1295346375121863256,\n            7631713597562972500,\n            6013785207649710084,\n            12504083400869715484,\n            10391675565598624561,\n            17086420331228234856,\n            14617438647774567077,\n            15964728536429688928,\n            13460421593436649766,\n            16408312779121921256,\n            6520489253483657869,\n            4730756746647128773,\n            9028350139788839089,\n            7953083747782670383,\n            5096299587699598800,\n            2951011592716102034,\n            1556959608597785858,\n            11489708918307621984,\n            12277065314059308881,\n            10220668622316585965,\n            11995324860038254033,\n            4353183691485690945,\n            427717306190904666,\n        ],\n    );\n    // - ODD_FACTORIAL_TABLE_LIMIT < n <= ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1\n    test(26, false, &[11182600415380068643, 2]);\n    // - s == 0 first time\n    test(35, false, &[13586117418673889649, 130422663336]);\n}\n\n#[test]\nfn test_factorial() {\n    fn test(n: u64, out: &str) {\n        let f = Natural::factorial(n);\n        assert!(f.is_valid());\n        assert_eq!(f.to_string(), out);\n        assert_eq!(factorial_naive(n), f);\n        assert_eq!(\n            rug::Integer::factorial(u32::exact_from(n))\n                .complete()\n                .to_string(),\n            out\n        );\n    }\n    // - n < limit first time\n    test(0, \"1\");\n    // - n.odd()\n    test(1, \"1\");\n    test(2, \"2\");\n    test(3, \"6\");\n    test(4, \"24\");\n    test(5, \"120\");\n    test(10, \"3628800\");\n    // - 32 bits: prod > max_prod\n    test(20, \"2432902008176640000\");\n    // - limit <= n < FAC_ODD_THRESHOLD\n    // - n < limit second time\n    test(21, \"51090942171709440000\");\n    // - n >= limit second time\n    // - prod <= max_prod\n    test(22, \"1124000727777607680000\");\n    // - n >= FAC_ODD_THRESHOLD\n    // - n <= TABLE_LIMIT_2N_MINUS_POPC_2N\n    test(24, \"620448401733239439360000\");\n    // - n > TABLE_LIMIT_2N_MINUS_POPC_2N\n    test(\n        82,\n        \"47536433370128417484213820698940494664381329406799332861716093407674399473489914861300713\\\n        1808479167119360000000000000000000\",\n    );\n    test(\n        100,\n        \"93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463\\\n        976156518286253697920827223758251185210916864000000000000000000000000\",\n    );\n\n    fn big_test(n: u64) {\n        let f = Natural::factorial(n);\n        assert!(f.is_valid());\n        assert_eq!(factorial_naive(n), f);\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::factorial(u32::exact_from(n)).complete()),\n            f\n        );\n    }\n    big_test(162501);\n    big_test(162502);\n    big_test(263338);\n    big_test(263353);\n    big_test(263354);\n    big_test(1000000);\n}\n\n#[test]\nfn test_double_factorial() {\n    fn test(n: u64, out: &str) {\n        let f = Natural::double_factorial(n);\n        assert!(f.is_valid());\n        assert_eq!(f.to_string(), out);\n        assert_eq!(double_factorial_naive(n), f);\n        assert_eq!(\n            rug::Integer::factorial_2(u32::exact_from(n))\n                .complete()\n                .to_string(),\n            out\n        );\n    }\n    // - n.even()\n    // - n > TABLE_LIMIT_2N_MINUS_POPC_2N || n == 0\n    test(0, \"1\");\n    // - n.odd()\n    // - n <= ODD_DOUBLEFACTORIAL_TABLE_LIMIT first time\n    test(1, \"1\");\n    // - n <= TABLE_LIMIT_2N_MINUS_POPC_2N && n != 0\n    test(2, \"2\");\n    test(3, \"3\");\n    test(4, \"8\");\n    test(5, \"15\");\n    test(6, \"48\");\n    test(7, \"105\");\n    test(19, \"654729075\");\n    test(20, \"3715891200\");\n    // - ODD_DOUBLEFACTORIAL_TABLE_LIMIT < n < FAC_2DSC_THRESHOLD\n    // - n <= ODD_DOUBLEFACTORIAL_TABLE_LIMIT second time\n    test(35, \"221643095476699771875\");\n    // - n > ODD_DOUBLEFACTORIAL_TABLE_LIMIT second time\n    // - prod <= max_prod\n    test(37, \"8200794532637891559375\");\n    // - prod > max_prod\n    test(55, \"8687364368561751199826958100282265625\");\n    test(\n        99,\n        \"2725392139750729502980713245400918633290796330545803413734328823443106201171875\",\n    );\n    test(\n        100,\n        \"34243224702511976248246432895208185975118675053719198827915654463488000000000000\",\n    );\n    // - n >= FAC_2DSC_THRESHOLD\n    test(\n        473,\n        \"24105348290207984100197317421171182490921899413623319647593979414961419154254094380115999\\\n        189301460161039406301206658065847305231769123134642895607903467624412688193137891638118329\\\n        605237994774653987740749807295557291435144240110313449108135603699200932257584350374350787\\\n        323659752996357699013258512218790061191470897010499751650188156859142205866225173540759120\\\n        884362743953738057721709446884608434913698856509684431470876923079372190040412643076525278\\\n        35572579953211852767587427960391216326823983495675207677777507342398166656494140625\",\n    );\n    fn big_test(n: u64) {\n        let f = Natural::double_factorial(n);\n        assert!(f.is_valid());\n        assert_eq!(double_factorial_naive(n), f);\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::factorial_2(u32::exact_from(n)).complete()),\n            f\n        );\n    }\n    // - prod > max_prod for prime == 3 in limbs_2_multiswing_odd\n    big_test(65539);\n}\n\n#[test]\nfn test_multifactorial() {\n    fn test(n: u64, m: u64, out: &str) {\n        let f = Natural::multifactorial(n, m);\n        assert!(f.is_valid());\n        assert_eq!(f.to_string(), out);\n        assert_eq!(multifactorial_naive(n, m), f);\n        assert_eq!(\n            rug::Integer::factorial_m(u32::exact_from(n), u32::exact_from(m))\n                .complete()\n                .to_string(),\n            out,\n        );\n    }\n    // - n < 3 || n - 3 < m - 1\n    // - n == 0\n    test(0, 1, \"1\");\n    // - n != 0\n    test(1, 1, \"1\");\n    test(2, 1, \"2\");\n    // - n >= 3 && n - 3 >= m - 1\n    // - g <= 1 first time\n    // - m <= 2\n    // - m == 1\n    // - g <= 2\n    // - g != 2\n    test(3, 1, \"6\");\n    test(4, 1, \"24\");\n    test(5, 1, \"120\");\n\n    test(0, 2, \"1\");\n    test(1, 2, \"1\");\n    test(2, 2, \"2\");\n    test(3, 2, \"3\");\n    // - g > 1 first time\n    // - g == 2\n    test(4, 2, \"8\");\n    // - m != 1\n    // - g <= 1 second time\n    test(5, 2, \"15\");\n    test(6, 2, \"48\");\n    test(7, 2, \"105\");\n\n    test(0, 3, \"1\");\n    test(1, 3, \"1\");\n    test(2, 3, \"2\");\n    test(3, 3, \"3\");\n    test(4, 3, \"4\");\n    // - m > 2\n    // - g <= 1 third time\n    test(5, 3, \"10\");\n    // - g > 2\n    test(6, 3, \"18\");\n    // - prod <= max_prod\n    test(7, 3, \"28\");\n    test(8, 3, \"80\");\n    test(9, 3, \"162\");\n\n    // - g > 1 second time\n    test(6, 4, \"12\");\n    // - g > 1 third time\n    test(8, 6, \"16\");\n\n    test(10, 1, \"3628800\");\n    test(20, 2, \"3715891200\");\n    test(25, 3, \"608608000\");\n    // - prod > max_prod\n    test(44, 3, \"5577337931669504000\");\n\n    test(\n        100,\n        1,\n        \"93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463\\\n        976156518286253697920827223758251185210916864000000000000000000000000\",\n    );\n    test(\n        100,\n        2,\n        \"34243224702511976248246432895208185975118675053719198827915654463488000000000000\",\n    );\n    test(\n        100,\n        3,\n        \"174548867015437739741494347897360069928419328000000000\",\n    );\n\n    test(8, 6, \"16\");\n}\n\n#[test]\nfn test_subfactorial() {\n    fn test(n: u64, out: &str) {\n        let f = Natural::subfactorial(n);\n        assert!(f.is_valid());\n        assert_eq!(f.to_string(), out);\n        assert_eq!(subfactorial_naive(n), f);\n    }\n    test(0, \"1\");\n    test(1, \"0\");\n    test(2, \"1\");\n    test(3, \"2\");\n    test(4, \"9\");\n    test(5, \"44\");\n    test(10, \"1334961\");\n    test(\n        100,\n        \"34332795984163804765195977526776142032365783805375784983543400282685180793327632432791396\\\n        429850988990237345920155783984828001486412574060553756854137069878601\",\n    );\n}\n\n#[test]\nfn limbs_odd_factorial_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_n\", 4096);\n    unsigned_bool_pair_gen_var_1().test_properties_with_config(&config, |(n, double)| {\n        let xs = limbs_odd_factorial(n, double);\n        let x = Natural::from_owned_limbs_asc(xs);\n        let n = u64::exact_from(n);\n        let f = if double {\n            double_factorial_naive(if n.odd() { n } else { n - 1 })\n        } else {\n            factorial_naive(n)\n        };\n        let zeros = f.trailing_zeros().unwrap_or(0);\n        assert_eq!(x, f >> zeros);\n    });\n}\n\n#[test]\nfn factorial_properties() {\n    unsigned_gen_var_5().test_properties(|n| {\n        let f = Natural::factorial(n);\n        assert!(f.is_valid());\n        assert_eq!(factorial_naive(n), f);\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::factorial(u32::exact_from(n)).complete()),\n            f\n        );\n        assert_eq!(Natural::multifactorial(n, 1), f);\n        assert_ne!(f, 0u32);\n        if n != 0 {\n            assert_eq!(f.div_round(Natural::factorial(n - 1), Exact).0, n);\n        }\n    });\n\n    unsigned_gen_var_23::<Limb>().test_properties(|n| {\n        assert_eq!(Natural::factorial(n), Limb::factorial(n));\n    });\n}\n\n#[test]\nfn double_factorial_properties() {\n    unsigned_gen_var_5().test_properties(|n| {\n        let f = Natural::double_factorial(n);\n        assert!(f.is_valid());\n        assert_eq!(double_factorial_naive(n), f);\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::factorial_2(u32::exact_from(n)).complete()),\n            f\n        );\n        assert_eq!(Natural::multifactorial(n, 2), f);\n        assert_ne!(f, 0);\n        if n > 1 {\n            assert_eq!(f.div_round(Natural::double_factorial(n - 2), Exact).0, n);\n        }\n    });\n\n    unsigned_gen_var_24::<Limb>().test_properties(|n| {\n        assert_eq!(Natural::double_factorial(n), Limb::double_factorial(n));\n    });\n}\n\n#[test]\nfn multifactorial_properties() {\n    unsigned_pair_gen_var_18().test_properties(|(n, m)| {\n        let f = Natural::multifactorial(n, m);\n        assert!(f.is_valid());\n        assert_eq!(\n            Natural::exact_from(\n                &rug::Integer::factorial_m(u32::exact_from(n), u32::exact_from(m)).complete()\n            ),\n            f,\n        );\n        assert_eq!(multifactorial_naive(n, m), f);\n        assert_ne!(f, 0u32);\n        if n >= m {\n            assert_eq!(f.div_round(Natural::multifactorial(n - m, m), Exact).0, n);\n        }\n    });\n\n    unsigned_pair_gen_var_43::<Limb>().test_properties(|(n, m)| {\n        assert_eq!(Natural::multifactorial(n, m), Limb::multifactorial(n, m));\n    });\n}\n\n#[test]\nfn subfactorial_properties() {\n    unsigned_gen_var_5().test_properties(|n| {\n        let f = Natural::subfactorial(n);\n        assert!(f.is_valid());\n        assert_eq!(subfactorial_naive(n), f);\n        if n != 1 {\n            assert_ne!(f, 0u32);\n        }\n        if n != 0 && n != 2 {\n            let g = if n.even() {\n                f - Natural::ONE\n            } else {\n                f + Natural::ONE\n            };\n            assert_eq!(g.div_round(Natural::subfactorial(n - 1), Exact).0, n);\n        }\n    });\n\n    unsigned_gen_var_25::<Limb>().test_properties(|n| {\n        assert_eq!(Natural::subfactorial(n), Limb::subfactorial(n));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/gcd.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CoprimeWith, DivExact, DivisibleBy, Gcd, GcdAssign, Lcm, ModPowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::{GenConfig, TINY_LIMIT};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_pair_gen_var_27, unsigned_quadruple_gen_var_11,\n    unsigned_vec_unsigned_pair_gen_var_23,\n};\nuse malachite_nz::natural::arithmetic::gcd::half_gcd::{\n    HalfGcdMatrix, limbs_gcd_div, limbs_gcd_reduced, limbs_half_gcd_matrix_1_mul_vector,\n};\nuse malachite_nz::natural::arithmetic::gcd::limbs_gcd_limb;\nuse malachite_nz::natural::arithmetic::gcd::matrix_2_2::{\n    limbs_matrix_2_2_mul, limbs_matrix_mul_2_2_scratch_len,\n};\nuse malachite_nz::natural::{Natural, limb_to_bit_count};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_5, large_type_gen_var_6, large_type_gen_var_7, large_type_gen_var_8,\n    natural_gen, natural_pair_gen, natural_pair_gen_var_4, natural_triple_gen,\n    unsigned_vec_pair_gen_var_10,\n};\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_nz::test_util::natural::arithmetic::gcd::half_gcd_matrix_create;\nuse malachite_nz::test_util::natural::arithmetic::gcd::{\n    OwnedHalfGcdMatrix, gcd_binary_nz, gcd_euclidean_nz, half_gcd_matrix_1_to_naturals,\n    half_gcd_matrix_to_naturals, limbs_gcd_div_alt, limbs_gcd_div_naive,\n};\nuse num::BigUint;\nuse num::Integer as rug_integer;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_gcd_limb() {\n    let test = |xs, y, out| {\n        assert_eq!(limbs_gcd_limb(xs, y), out);\n    };\n    test(&[0, 1], 3, 1);\n    test(&[0, 1], 4, 4);\n    test(&[3744702173, 1327092413], 1932313754, 7);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_half_gcd_matrix_init() {\n    let test = |n, out| {\n        let scratch_len = HalfGcdMatrix::min_init_scratch(n);\n        assert_eq!(OwnedHalfGcdMatrix::init(n, vec![0; scratch_len]), out);\n    };\n    test(\n        1,\n        OwnedHalfGcdMatrix {\n            data: vec![1, 0, 0, 0, 0, 0, 1, 0],\n            s: 2,\n            two_s: 4,\n            three_s: 6,\n            n: 1,\n        },\n    );\n    test(\n        3,\n        OwnedHalfGcdMatrix {\n            data: vec![1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n            s: 3,\n            two_s: 6,\n            three_s: 9,\n            n: 1,\n        },\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_half_gcd_matrix_update_q() {\n    let test = |mut m: OwnedHalfGcdMatrix, qs: &[Limb], column, m_after| {\n        let mut scratch = vec![0; m.update_q_scratch_len(qs.len())];\n        m.update_q(qs, column, &mut scratch);\n        assert_eq!(m, m_after);\n    };\n    // - qs_len > 1\n    // - n + qs_len > self.n\n    // - reached nonzero limb\n    // - zero carry\n    test(\n        half_gcd_matrix_create(\n            16,\n            8,\n            vec![\n                3364358997, 3754657515, 2983848742, 3936755874, 1784338974, 2546784265, 1325228501,\n                2948540251, 0, 0, 0, 0, 0, 0, 0, 0, 48883882, 3336115747, 2904559986, 3732488562,\n                2492471725, 1228174159, 2572912965, 1596092594, 0, 0, 0, 0, 0, 0, 0, 0, 2193991530,\n                2899278504, 3717617329, 1249076698, 879590153, 4210532297, 3303769392, 1147691304,\n                0, 0, 0, 0, 0, 0, 0, 0, 3624392894, 1881877405, 1728780505, 931615955, 1096404509,\n                1326003135, 370549396, 1987183422, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        ),\n        &[851586836, 2796582944, 2985872407],\n        0,\n        half_gcd_matrix_create(\n            16,\n            11,\n            vec![\n                2035904157, 337140004, 3757354024, 670541357, 1156551026, 2954076405, 2306281186,\n                901391702, 26359260, 3840226876, 1109607712, 0, 0, 0, 0, 0, 48883882, 3336115747,\n                2904559986, 3732488562, 2492471725, 1228174159, 2572912965, 1596092594, 0, 0, 0, 0,\n                0, 0, 0, 0, 808024130, 607404974, 3634401411, 320381711, 4246353409, 2141048780,\n                3541800429, 3925651923, 2116051089, 3713928088, 1381495070, 0, 0, 0, 0, 0,\n                3624392894, 1881877405, 1728780505, 931615955, 1096404509, 1326003135, 370549396,\n                1987183422, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        ),\n    );\n    // - qs_len == 1\n    test(\n        half_gcd_matrix_create(\n            3,\n            1,\n            vec![1918546714, 0, 0, 3992705367, 0, 0, 4279371403, 0, 0, 3759197804, 0, 0],\n        ),\n        &[3543156725],\n        1,\n        half_gcd_matrix_create(\n            3,\n            2,\n            vec![\n                1918546714, 0, 0, 2304079673, 1582715589, 0, 4279371403, 0, 0, 3341917811,\n                3530290808, 0,\n            ],\n        ),\n    );\n    // - didn't reach nonzero limb\n    test(\n        half_gcd_matrix_create(\n            11,\n            5,\n            vec![\n                0, 4293918720, 4294967295, 134217727, 0, 0, 0, 0, 0, 0, 0, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 0, 0, 0, 0, 0, 0, 268435455, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 4294967295, 4294967295, 134217727, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        ),\n        &[4294967295, 4294967295],\n        1,\n        half_gcd_matrix_create(\n            11,\n            6,\n            vec![\n                0, 4293918720, 4294967295, 134217727, 0, 0, 0, 0, 0, 0, 0, 4294967295, 1048575, 0,\n                4159700992, 4294967295, 134217728, 0, 0, 0, 0, 0, 268435455, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 4026531840, 4294967295, 402653182, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        ),\n    );\n    // - nonzero carry\n    test(\n        half_gcd_matrix_create(\n            26,\n            14,\n            vec![\n                4294967295, 536870911, 0, 0, 0, 3758096384, 4294967295, 4294967295, 4294967295,\n                4294967295, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 524287, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 4294967288, 4294967295, 4294967295, 4294967295, 4294967295, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        ),\n        &[4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295],\n        1,\n        half_gcd_matrix_create(\n            26,\n            18,\n            vec![\n                4294967295, 536870911, 0, 0, 0, 3758096384, 4294967295, 4294967295, 4294967295,\n                4294967295, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3758096384,\n                4294967295, 4294967295, 4294967295, 536870911, 0, 4294967295, 536870911, 0,\n                4294967295, 4294967295, 3758096383, 4294967295, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                524287, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,\n                4294443007, 4294967295, 4294967287, 4294967295, 4294967295, 4294967295, 4294967295,\n                524288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n        ),\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_matrix_2_2_mul() {\n    let test = |xs_len,\n                xs00: &[Limb],\n                xs01: &[Limb],\n                xs10: &[Limb],\n                xs11: &[Limb],\n                ys00: &[Limb],\n                ys01: &[Limb],\n                ys10: &[Limb],\n                ys11: &[Limb],\n                xs00_out: &[Limb],\n                xs01_out: &[Limb],\n                xs10_out: &[Limb],\n                xs11_out: &[Limb]| {\n        let x00 = Natural::from_limbs_asc(&xs00[..xs_len]);\n        let x01 = Natural::from_limbs_asc(&xs01[..xs_len]);\n        let x10 = Natural::from_limbs_asc(&xs10[..xs_len]);\n        let x11 = Natural::from_limbs_asc(&xs11[..xs_len]);\n        let mut xs00 = xs00.to_vec();\n        let mut xs01 = xs01.to_vec();\n        let mut xs10 = xs10.to_vec();\n        let mut xs11 = xs11.to_vec();\n        let mut scratch = vec![0; limbs_matrix_mul_2_2_scratch_len(xs_len, ys00.len())];\n        limbs_matrix_2_2_mul(\n            &mut xs00,\n            &mut xs01,\n            &mut xs10,\n            &mut xs11,\n            xs_len,\n            ys00,\n            ys01,\n            ys10,\n            ys11,\n            &mut scratch,\n        );\n        assert_eq!(xs00, xs00_out);\n        assert_eq!(xs01, xs01_out);\n        assert_eq!(xs10, xs10_out);\n        assert_eq!(xs11, xs11_out);\n\n        let y00 = Natural::from_limbs_asc(ys00);\n        let y01 = Natural::from_limbs_asc(ys01);\n        let y10 = Natural::from_limbs_asc(ys10);\n        let y11 = Natural::from_limbs_asc(ys11);\n        let z00 = Natural::from_limbs_asc(&xs00);\n        let z01 = Natural::from_limbs_asc(&xs01);\n        let z10 = Natural::from_limbs_asc(&xs10);\n        let z11 = Natural::from_limbs_asc(&xs11);\n        assert_eq!(z00, &x00 * &y00 + &x01 * &y10);\n        assert_eq!(z01, x00 * &y01 + x01 * &y11);\n        assert_eq!(z10, &x10 * y00 + &x11 * y10);\n        assert_eq!(z11, x10 * y01 + x11 * y11);\n    };\n    // - small arguments\n    // - small arguments, xs_len >= ys_len\n    test(\n        6,\n        &[\n            1824026683, 855383832, 2690657440, 2097392823, 1744856106, 145210032, 2603321546,\n            3714268226, 2572752468, 3552024211, 2105680113, 94008293, 3599160935,\n        ],\n        &[\n            2100861089, 4058927494, 3716614958, 1374886937, 1422228766, 4125067565, 2659645894,\n            3516145724, 333198217, 178588388, 4107267309, 1484604263, 2137933301,\n        ],\n        &[\n            1307794677, 4133495830, 1895462954, 3236069911, 3579790936, 2823361555, 1496151737,\n            2535182824, 534572820, 3734537343, 1327464147, 146259718, 609826618,\n        ],\n        &[\n            2641001264, 3832561802, 3044312402, 2136702112, 2248874160, 4213317499, 3447231898,\n            3536677714, 1313296525, 2266853686, 2052041169, 347717049, 3434352423,\n        ],\n        &[17796630, 1709267377, 3881785007, 955800997, 1047963095, 1178960613],\n        &[3543460331, 2385517496, 2086915063, 4055235164, 948436119, 2870150085],\n        &[773552019, 2621197289, 344580017, 3644778487, 274842105, 3931875648],\n        &[3510151397, 4026412532, 4195503381, 682501213, 1600717006, 4252677869],\n        &[\n            2986138245, 1099838926, 919425337, 2682286770, 2754856871, 2818192521, 1654309759,\n            3195744726, 1787512677, 270014583, 3333887406, 3816198933, 0,\n        ],\n        &[\n            343075118, 2459980459, 1480149398, 379857868, 2605135184, 4087866241, 313289235,\n            2201953346, 57359095, 3003278162, 1714985241, 4181488913, 0,\n        ],\n        &[\n            2571956126, 963369470, 3125970281, 2288117049, 561041416, 923295190, 2931384231,\n            3709683058, 128286972, 2292494833, 488801956, 337168684, 1,\n        ],\n        &[\n            2992440279, 2112449146, 2902973305, 109063322, 1501017829, 475736264, 25775141,\n            3410631721, 3956905026, 3154770531, 1888093339, 1763601187, 1,\n        ],\n    );\n    // - small arguments, xs_len < ys_len\n    test(\n        2,\n        &[\n            342664039, 3864205283, 1256491723, 1548927821, 721895559, 1910261306, 1235301118,\n            799978473, 549823983, 2512819824, 2068299963, 2595078570, 2035992824, 1064296193,\n            3249660883,\n        ],\n        &[\n            3453614628, 3979759903, 3415299769, 13499660, 1318795951, 4144584485, 2603705982,\n            1273366949, 1110716009, 4026346288, 4104893234, 1485704330, 993867679, 3893686890,\n            3439773462,\n        ],\n        &[\n            1413063068, 1416612149, 250032189, 2057599093, 512591148, 2867423455, 157645789,\n            33515858, 259890804, 2083013527, 2993123902, 3443423003, 2587947916, 2060570216,\n            358183429,\n        ],\n        &[\n            3771316904, 1123102423, 3617951287, 3593485506, 3547215643, 4279031677, 3253560754,\n            4217820186, 342159470, 3956944812, 4058756711, 3961349923, 734903752, 3497757471,\n            2783111581,\n        ],\n        &[\n            560210975, 3955544118, 1525693335, 2423056590, 1672468134, 1425293729, 3576282506,\n            2808604793, 2173831628, 3419991459, 1679121946, 1623263180,\n        ],\n        &[\n            269931918, 1859534151, 1418011147, 3930467901, 3120401510, 2878732263, 2440621113,\n            3698526898, 1960607269, 766485754, 1276737094, 1400250704,\n        ],\n        &[\n            31094149, 3099789406, 924340153, 1040795176, 864813453, 1273500430, 1433881359,\n            3857073234, 725256613, 302279104, 1991322247, 3304275709,\n        ],\n        &[\n            1816819354, 1423518943, 1640383514, 2897037119, 3299791289, 2007192829, 3211337188,\n            141201204, 2347531699, 2806328153, 4130308450, 1398383850,\n        ],\n        &[\n            2476191277, 2109850628, 475699680, 1695888498, 997959785, 3844200037, 3615832345,\n            3189739607, 4090633814, 4172440182, 2429164332, 1687921897, 3000987025, 227266471, 1,\n        ],\n        &[\n            4293289930, 3312097786, 3225023610, 1814982734, 4123961773, 3202664630, 3288402967,\n            3423618017, 2648236802, 1235962392, 3785214889, 4142071340, 2656497128, 2555569668, 0,\n        ],\n        &[\n            550585132, 1958217637, 1079695233, 2070051690, 1642769243, 2223520962, 2790719352,\n            1102872554, 1250178031, 2079404531, 2578751592, 3643898046, 2569241678, 1399445906, 0,\n        ],\n        &[\n            1489643928, 2454326491, 2000310088, 504396801, 1710204547, 859777848, 2758305889,\n            1268262193, 931603943, 2447640352, 2661054782, 1778884540, 664908352, 827512809, 0,\n        ],\n    );\n    // - large arguments\n    // - !x11_sign first\n    // - !x01_sign first && *xs01_lo_last == 0\n    // - t0_sign first\n    // - *t0_last == 0\n    // - x01_sign == t0_sign\n    // - !t0_sign second && *t0_last == 0\n    // - !x01_sign second\n    // - !x11_sign second\n    // - !t0_sign third\n    test(\n        13,\n        &[\n            2327266888, 159606339, 3865198656, 559105571, 2679446641, 3007100930, 1196374243,\n            2596728943, 1430648584, 25111289, 3084098662, 482968659, 31861624, 1410839754,\n            2868430508, 2675304181, 2820971697, 8433363, 356205126, 104388181, 4288829918,\n            3309134473, 419097037, 2074236894, 2540543830, 4244884836, 1103759092,\n        ],\n        &[\n            2582817524, 4164383668, 1706646291, 1800000652, 1666270692, 2628289120, 568570643,\n            1583069261, 439682583, 3837085850, 247464905, 3856266079, 200842326, 965872188,\n            2600055254, 1543566961, 1164241353, 2239343733, 1797130797, 3623500339, 1808008532,\n            2868955656, 564142102, 1020590314, 4158719441, 3395391357, 181182939,\n        ],\n        &[\n            2210310100, 69043551, 2823304128, 859345289, 809080897, 120879541, 848904185,\n            3835017916, 4066448129, 827700778, 641878366, 728444321, 22823142, 834400226,\n            2533421831, 507928329, 398885658, 2332167275, 2030642299, 2377794489, 4277961295,\n            2703891174, 3551408972, 450706094, 3991414091, 2973081680, 2714910760,\n        ],\n        &[\n            3640661014, 3206858101, 1737126835, 2106218066, 1425703988, 2338047020, 712809585,\n            1420991435, 802147205, 1773895924, 2923903580, 4180731388, 625628901, 81750990,\n            3245267790, 2492995722, 457141292, 1264357942, 2610553127, 4085223468, 2725553562,\n            3215595517, 3513268137, 4258341409, 1316871298, 2379198914, 1468344750,\n        ],\n        &[\n            3008762500, 1175160375, 2716597715, 2933871453, 475199659, 3313171252, 201726752,\n            3994474734, 3542696350, 475569587, 3061861352, 2795963138, 283981201,\n        ],\n        &[\n            4169211551, 1045673686, 3266173725, 1121123371, 2838095204, 3904211332, 2018560297,\n            1147750373, 444496996, 2142529574, 3971639805, 3751979387, 2535175321,\n        ],\n        &[\n            1047770371, 1327165786, 2797828578, 2685696909, 3147360099, 2201558235, 1866861337,\n            3761155252, 1834270154, 2215232253, 3198169502, 1924553977, 1837870685,\n        ],\n        &[\n            2114181245, 3857180605, 3554288771, 865294166, 1626355571, 408295120, 177441714,\n            1458573842, 2220915043, 163377253, 1218043108, 2602503433, 528893379,\n        ],\n        &[\n            2717110780, 986237674, 4250650056, 1544812173, 3986397690, 3836431188, 1613821249,\n            2248597207, 2448784182, 2786929074, 1893569847, 1881917363, 2790152996, 3179057496,\n            3799013333, 237221218, 3475954500, 4281253174, 3125290097, 2813956421, 1855289745,\n            377172866, 3911404025, 3636398044, 3080186791, 88049640, 0,\n        ],\n        &[\n            3505418204, 565465608, 1097112481, 3850268278, 2024670176, 2587290050, 3411014407,\n            245345981, 2788535930, 2809261912, 2745706761, 556134486, 3944352700, 2638013922,\n            4093507304, 1504147190, 2989086350, 3911331623, 2934713592, 3270681569, 2138704930,\n            3059900964, 978968136, 2445899049, 3968088878, 43539092, 0,\n        ],\n        &[\n            3865656210, 3194879205, 414139316, 177501159, 2684513621, 1999012183, 2643222146,\n            294716300, 4274795829, 1085676658, 3215144153, 1601970312, 3171535086, 643673394,\n            3946671909, 4065144781, 215713465, 172238316, 2724659711, 799017611, 153635789,\n            429414755, 1974259637, 1237183745, 2501881650, 269223554, 0,\n        ],\n        &[\n            858223466, 4042145127, 1530910355, 223572531, 3154483634, 1177157565, 2140895357,\n            1246913012, 2944555982, 1472007124, 1255831930, 1641310063, 2184842279, 2314841816,\n            3300111001, 1618884985, 908327583, 2089112945, 1411422173, 2387337957, 3072912755,\n            3289360053, 2808553404, 730378617, 671725420, 90513297, 0,\n        ],\n    );\n    // - x11_sign first\n    // - !t0_sign first\n    // - *t0_last != 0\n    // - *xs01_lo_last == 0\n    // - !t0_sign second && *t0_last != 0\n    test(\n        15,\n        &[\n            1698534354, 3051849227, 453937331, 3597744389, 4188491352, 1540429554, 1541686219,\n            53413474, 2449460985, 2817396669, 2111985345, 2509026402, 1809740433, 3289293410,\n            2617592565, 2791033656, 2892380542, 4279121468, 1127688708, 1053029299, 916223848,\n            2015034641, 342194872, 1618165570, 3500431510, 192527413, 2131355967, 3029734551,\n            2974882323, 1660068342, 2973244676,\n        ],\n        &[\n            1838750278, 66304311, 2535657427, 2850224201, 698579880, 1262199901, 3281530768,\n            2112263091, 2707934779, 1567684797, 1075812175, 3518220523, 1324578919, 2267335289,\n            3456142629, 3821323209, 1326553164, 564294454, 4194035902, 1211624633, 4195909292,\n            2658461285, 789623662, 2974487150, 1275698083, 2125737295, 4192486278, 3187284022,\n            88896961, 2297316271, 3463163938,\n        ],\n        &[\n            3818564698, 3079932038, 3482135970, 684071506, 1279597152, 608056186, 4111845555,\n            4244378225, 1830629760, 3169670996, 2225259632, 2264284180, 3411037700, 2316989665,\n            4067022578, 3527348537, 1977664147, 2506129832, 2221226065, 1330889781, 1701021791,\n            644923460, 1849689221, 2715236311, 2773306484, 239859281, 3230697771, 19267319,\n            558009472, 1404018120, 3728834892,\n        ],\n        &[\n            1670192276, 1652365370, 735393172, 511768757, 2457280859, 3609810335, 3935660653,\n            1797012973, 2672222932, 1933650427, 649516978, 512827590, 782690911, 2062492600,\n            2388214063, 3703253089, 904911621, 3390829428, 3844496615, 3067716449, 2596709309,\n            1917646504, 1265079680, 3900449910, 367095064, 999066040, 1909678899, 1128678763,\n            1656559628, 4266623984, 3645416988,\n        ],\n        &[\n            1921432021, 3518700209, 2079139530, 1137029652, 2300568548, 1222502019, 4223478985,\n            2972106290, 3031541529, 2100809044, 1022823954, 194891273, 3689971092, 3296679225,\n            4094754776,\n        ],\n        &[\n            948939782, 2806265501, 2304000452, 2075826159, 909827325, 768415732, 2455484163,\n            1934928621, 980278935, 2767893850, 1683388302, 1684144848, 3942412863, 331912133,\n            3187438755,\n        ],\n        &[\n            1356019384, 2887360290, 1007932454, 3678465615, 2580178110, 3043732489, 3324841406,\n            937504067, 386593536, 1673041889, 3131783437, 1641423898, 4040080328, 3081806329,\n            1375763815,\n        ],\n        &[\n            1047656638, 2177659443, 4241187176, 2747048355, 1596389859, 4248315455, 3794436052,\n            415309719, 1967342941, 3004037899, 374134042, 1698070105, 2693572544, 3158142963,\n            4229995607,\n        ],\n        &[\n            960652810, 221555597, 2254803219, 2541562745, 754445106, 359755753, 480947080,\n            1224152909, 4273400475, 2309775298, 69810482, 2561255677, 3113057442, 3555394132,\n            2689777384, 3342925543, 3147365260, 135644488, 3684637040, 3040946646, 1628023293,\n            4023411971, 908469819, 409304848, 3324164633, 1421103084, 368154340, 3701822194,\n            274487004, 3602643412, 0,\n        ],\n        &[\n            1997266656, 4144548866, 3822293605, 3926602038, 1609713691, 2892681355, 3749833208,\n            2219312564, 1687251603, 1588930279, 710521538, 1644589528, 4054199977, 1672634472,\n            3997104967, 956657984, 1345800224, 3871498877, 1120533029, 4151694583, 3146989749,\n            3919396264, 3231441052, 3162857783, 2091524393, 124782745, 1890937176, 4230835488,\n            2323009602, 1051495796, 1,\n        ],\n        &[\n            2429170498, 799964546, 2388325391, 317823710, 1840557881, 1282801560, 3546799442,\n            457834840, 566997058, 2439965867, 3515007146, 3574214064, 4144082196, 3712070930,\n            4088900464, 931383261, 170089945, 3405025888, 3812686020, 3504707725, 3656419747,\n            3267430265, 3757212521, 606804174, 1643444794, 1555142733, 2148558239, 3200013733,\n            3246813347, 347461213, 1,\n        ],\n        &[\n            1131485172, 3765288921, 453666926, 1551065789, 1216395236, 2385231809, 2742879582,\n            2426027378, 4167822390, 2229883144, 4228139351, 1293005830, 2665193524, 202666761,\n            3531978819, 2231355982, 1235148096, 3915389935, 1798246474, 1563880136, 2945683561,\n            1359457669, 1027112316, 3946769090, 4219178471, 794179363, 621594377, 2736938672,\n            401053543, 1075392661, 1,\n        ],\n    );\n    // - x01_sign first\n    // - t0_sign second\n    // - x01_sign second\n    // - x11_sign second\n    // - t0_sign third\n    test(\n        13,\n        &[\n            1025572927, 4037308532, 206447616, 1333004461, 2310395791, 2869951650, 3992227745,\n            2130697188, 3157273254, 1749550525, 2868602361, 3060642701, 2426631225, 1974455379,\n            2987014830, 3508635696, 4024076244, 1755792892, 787921452, 4166340149, 3450397006,\n            1108082683, 457400481, 879113144, 70830365, 2916933914, 2341310905, 851535845,\n            216319323,\n        ],\n        &[\n            69731978, 32563822, 946916236, 4016159116, 1224868021, 1718595702, 3605404890,\n            1865781628, 1881971935, 1029571366, 841091130, 1677586018, 810666231, 2272746683,\n            422109939, 1896472571, 3472541307, 1431848293, 116371044, 608472959, 213411238,\n            4154745720, 3801332950, 4224350156, 448206049, 1568183327, 3637228341, 3718344479,\n            2263647818,\n        ],\n        &[\n            3460082903, 1733690143, 3780228761, 375677842, 1691069946, 689934922, 2437077094,\n            3214349377, 2429121920, 653102152, 649867420, 921104070, 4125433869, 2564034244,\n            2631897297, 1501813458, 3052965366, 2782742208, 4166256185, 995218213, 2136996300,\n            710550319, 2748268062, 846266401, 385079156, 4270529993, 3575888617, 1142776416,\n            876703144,\n        ],\n        &[\n            3175747111, 594393429, 2604257881, 3289051141, 2317754576, 2939871916, 3748706204,\n            1013852187, 3343723329, 930022353, 505449760, 486033689, 320591743, 2258238434,\n            731770059, 3003208735, 1775573735, 3729639165, 3460733502, 3012496005, 1974364986,\n            642896119, 3342553315, 3822794210, 229391052, 1989115715, 2908530532, 1629235212,\n            297906894,\n        ],\n        &[\n            2771639655, 2551822689, 1209354903, 2178693592, 1193377488, 793947593, 1366547443,\n            2939017203, 963848668, 851106223, 1557851261, 997940551, 2665723642, 1647387186,\n            2335120168,\n        ],\n        &[\n            500011960, 1984266544, 857628644, 2215374614, 1925463875, 3051446098, 614991784,\n            3952563722, 3226462656, 3978687345, 2589261427, 3942462520, 1207531315, 1120805743,\n            1003360645,\n        ],\n        &[\n            451008257, 2688612018, 4236929273, 890846394, 3566713276, 489065477, 715681827,\n            3122623659, 3596792199, 1985137091, 2004754993, 1883145970, 1355971815, 187148563,\n            3883316291,\n        ],\n        &[\n            1364526373, 1859255461, 3407839641, 1532219679, 3952961366, 1871608475, 4041336906,\n            3915677605, 4046491136, 2645312057, 1120032684, 1046405474, 1502799372, 4217018138,\n            1023990345,\n        ],\n        &[\n            570058979, 1182257372, 2005332174, 4070895605, 782477793, 360549018, 4128785555,\n            3018190268, 2520343653, 2142831802, 2730358685, 1347549043, 898050628, 2236297907,\n            3902264192, 3422936759, 3756013281, 352639804, 1061655526, 1986719339, 1128230524,\n            2860027389, 1088162212, 2410209429, 3802902058, 2977799885, 3237963571, 2052297093, 0,\n        ],\n        &[\n            1879768634, 2114652211, 1774713818, 554539813, 3731694105, 2702797297, 2844034165,\n            2300392570, 1941578090, 3901846543, 983591421, 898885286, 822227747, 3851095686,\n            2719131109, 3757259511, 2102411795, 1640921620, 3665191858, 2874213628, 2733705524,\n            3691904983, 3823452407, 1169915867, 1621234879, 3630743707, 3478309891, 760168923, 0,\n        ],\n        &[\n            3001545896, 250983613, 389728947, 3814529625, 1132206990, 1065795545, 2212114490,\n            2023039590, 3597610210, 1780520334, 3734977828, 2468915322, 4140659688, 115504217,\n            819490125, 2708811829, 3384020868, 1515546393, 3633787370, 1821986409, 2218993449,\n            3207510568, 3670555307, 3845772841, 3486603021, 1022756175, 2686130697, 2532811595, 0,\n        ],\n        &[\n            2918481451, 3610609934, 2847451215, 2220769302, 2338571396, 2165440207, 147236177,\n            3730198517, 3208724339, 649659344, 1519241706, 1867099736, 1460711278, 2220689669,\n            3279748484, 1549511341, 227389699, 855766629, 3771440986, 3432825737, 1053106079,\n            1117588071, 1313153141, 571072082, 2914006120, 3516294505, 1320473469, 1040189722, 0,\n        ],\n    );\n    // - !x01_sign first && *xs01_lo_last != 0\n    test(\n        10,\n        &[\n            2010512066, 3816652533, 3172500500, 565989349, 3299472792, 2270934281, 1434273491,\n            2883068162, 1560071521, 2704546576, 4072612274, 1051271061, 3502419446, 355770508,\n            10573273, 270934222, 2810553666, 2643486939, 744991576, 1870415987, 2808955936,\n        ],\n        &[\n            465514465, 2659174522, 3761352398, 3377965188, 1124434853, 3313355157, 619366950,\n            3258308994, 2397177830, 4225454449, 3612285332, 2249675933, 913650729, 1455947505,\n            2849031252, 3527524335, 2078373570, 3478300565, 3188941397, 3478789236, 3675330696,\n        ],\n        &[\n            1404705627, 2788199838, 3229806456, 2206730708, 2050218206, 2991653989, 3066690310,\n            3453635714, 3845109791, 627857052, 3843810702, 1520846308, 2495828552, 1637354383,\n            2549944931, 3600368060, 108395402, 3341126373, 947408628, 2185962205, 1308735610,\n        ],\n        &[\n            1053200638, 3763337935, 4268597333, 3193422669, 3607631108, 3846186640, 1111342197,\n            552132609, 1307213459, 4257590159, 1367177524, 4201506028, 476759064, 680921272,\n            2519538412, 238268545, 631677622, 549510100, 771370867, 3109499678, 1448324944,\n        ],\n        &[\n            3267186431, 1424299202, 1039441915, 934588642, 50593817, 2147729982, 1547157070,\n            1504136284, 1637263862, 4122900145,\n        ],\n        &[\n            3236915806, 1590507024, 3040977659, 1225520269, 2190057676, 3504088852, 3648192167,\n            1810940202, 83552157, 2321737355,\n        ],\n        &[\n            4225004158, 590791745, 643591931, 3221398002, 1827972871, 1242243388, 2513726409,\n            1495850896, 4192093161, 50221236,\n        ],\n        &[\n            2036607814, 1957760917, 1453625187, 3689677164, 3487789049, 491100324, 1044724096,\n            3399811921, 4055989690, 1295009692,\n        ],\n        &[\n            3263538684, 120256485, 4060593063, 3438619735, 3929215534, 2588618000, 2277735492,\n            1072816982, 3840198566, 1043147899, 1235395843, 4200415399, 3035243806, 1304983761,\n            3872141601, 1404040725, 4044445427, 429312851, 3176929590, 2645604084, 0,\n        ],\n        &[\n            4122626498, 107203592, 3628216803, 2047112948, 2210020383, 4096415682, 1367835443,\n            2351498305, 4206740014, 996512353, 1147432853, 2660487268, 2975278601, 828643899,\n            3534602756, 3189739581, 1167342346, 2278425545, 830131806, 2736051400, 0,\n        ],\n        &[\n            2978640553, 1655222107, 3504154601, 1909395468, 3162278697, 2260916194, 3267701344,\n            1089677643, 751892566, 4225581520, 2977844572, 882459562, 3829381149, 4213372565,\n            1864175453, 3748132665, 2980365850, 1250882260, 3505860930, 652487710, 0,\n        ],\n        &[\n            3447523550, 464011238, 1942725626, 1838669852, 3904733671, 258179587, 3703737903,\n            1567067340, 3691418914, 1104958587, 1817293529, 2218949245, 4009018118, 2970219724,\n            3485275615, 2079452863, 3685497725, 785093512, 267920582, 1623141509, 0,\n        ],\n    );\n    // - x01_sign != t0_sign\n    test(\n        11,\n        &[\n            105108810, 2939008753, 43370164, 1242908972, 1159070628, 84952645, 4165954274,\n            906659711, 1019556239, 2534013318, 721285587, 1325925355, 1632336316, 4096108923,\n            1763507067, 3809084118, 2331120351, 2754738494, 2103185448, 1244905580, 1907939448,\n            2609958778, 730167872,\n        ],\n        &[\n            2265464388, 1834541318, 2372682679, 3313972430, 3918258678, 2394770661, 1037415216,\n            274650728, 3739985994, 2108171684, 2199795287, 566429532, 1157864107, 2882221652,\n            910859296, 451698206, 2649007716, 1415208273, 2646592820, 3034704049, 2120666349,\n            979747662, 322674205,\n        ],\n        &[\n            3874939837, 1233304929, 106185835, 37158351, 2802916915, 3304535373, 696577680,\n            3544731437, 3157476288, 1443616905, 3457867645, 4024841761, 4062836214, 2279777825,\n            1482825076, 4078337234, 3264521275, 3344925347, 3161366177, 2196844487, 898054831,\n            1438581672, 3352145698,\n        ],\n        &[\n            1849881721, 2092152070, 2177899750, 288752532, 3618364405, 4141821358, 4158419895,\n            2146161307, 3308429556, 282226456, 2214705611, 146486422, 1226466729, 2012446110,\n            390251911, 3095301941, 1935278338, 1226998912, 102355086, 2004958092, 1379648599,\n            833731447, 3784213054,\n        ],\n        &[\n            1615644044, 2866597055, 1417092926, 358845179, 3417066108, 3643757328, 143514487,\n            3323797767, 2638762718, 3254012295, 3018153021,\n        ],\n        &[\n            344398095, 226628832, 764911662, 2701340611, 2699247769, 4219726262, 242800476,\n            2930885037, 990361216, 3569632382, 93961188,\n        ],\n        &[\n            129918839, 2214278271, 1283256165, 2817801381, 2615176815, 4126216685, 3082478432,\n            3280512502, 1853758032, 2634521780, 4223054084,\n        ],\n        &[\n            2590519092, 2716288017, 4272214574, 3155523983, 4104711693, 2762266943, 2745407059,\n            2324276365, 326739968, 523560569, 396448235,\n        ],\n        &[\n            3666666516, 547769313, 592311112, 2965277691, 3689426122, 853080706, 1356550839,\n            4168566128, 1148520078, 939171181, 4015917617, 683222651, 4090232802, 3632973858,\n            1439963708, 1600913535, 187292997, 1577612527, 1212140599, 1900670851, 2445225960,\n            2669823530, 0,\n        ],\n        &[\n            1687083814, 3698143323, 3751827194, 3866919242, 2549527161, 4010635967, 461515118,\n            2688244606, 3320207170, 3619767327, 434459238, 4066444037, 3805779605, 3312610610,\n            735569613, 11746680, 3083700477, 155975832, 1514885535, 1758738984, 2620267716,\n            218832355, 0,\n        ],\n        &[\n            3131789211, 3199129533, 2920949518, 53796216, 2859826242, 1820398479, 3973031721,\n            2637151743, 3165657662, 2168050566, 1715646418, 2044422416, 1930311216, 3380875453,\n            183533660, 2431952327, 2641905274, 4032322429, 1801301919, 3668108775, 2977500729,\n            312563773, 1,\n        ],\n        &[\n            1292086439, 3252628865, 3795724813, 3949296317, 3955675466, 2439424685, 4209245455,\n            521673263, 3357923169, 728386653, 1761881489, 2103645314, 4058013613, 1659506293,\n            3599632745, 96485170, 2801208662, 1691699790, 2077775599, 2126298157, 3250670933,\n            280076983, 0,\n        ],\n    );\n    // - *xs01_lo_last != 0\n    test(\n        14,\n        &[\n            3187643652, 689861248, 4104971615, 2655959233, 1806333930, 2946646526, 716445782,\n            1855643090, 2911585605, 2840897284, 772165124, 4249869367, 2223216112, 535376700,\n            620340444, 1645897591, 1333985741, 730570397, 4160730534, 1246271990, 1725573135,\n            352253863, 1262570932, 1984889896, 2956051954,\n        ],\n        &[\n            3195311878, 3038033431, 2773970346, 1168697958, 2813281967, 746268626, 2691595086,\n            4097287295, 93455850, 492512747, 2710035977, 1223679950, 3946316915, 3578566691,\n            2992317089, 3174913905, 2131559101, 1331916743, 3949213449, 80715282, 158737627,\n            2988488283, 2028980419, 3830004661, 250424958,\n        ],\n        &[\n            2536403826, 384848984, 1774521292, 2718320818, 310873769, 2046298166, 3228810082,\n            1178726899, 1925709392, 178731159, 2832365355, 2836635324, 193074416, 728452613,\n            3469205214, 1514937172, 3814853496, 2161355055, 886569678, 4161288761, 2889870661,\n            76946453, 1878702060, 1850975782, 1627735969,\n        ],\n        &[\n            1725052145, 898802704, 776971836, 1219924401, 4224517976, 84598208, 2148547128,\n            3866703857, 1192216635, 3270964370, 3470989137, 4065537602, 3771846191, 3811480941,\n            4062031618, 3552276638, 1926982962, 297558461, 1000365546, 1422440944, 3161036166,\n            519129014, 2412823237, 2742512283, 1294289799,\n        ],\n        &[\n            2124565348, 1850594425, 684081640, 3059091438, 3756365771, 3723911794, 1430887131,\n            2186106443, 1678377466, 1963700876,\n        ],\n        &[\n            1786516080, 1799763022, 3244164991, 2583605118, 2016537122, 396228546, 1776124622,\n            3149228799, 3618737851, 3722388678,\n        ],\n        &[\n            2119342743, 2442803683, 2913523155, 2290813344, 2341544084, 2607906759, 3903931010,\n            1623427068, 200668227, 866036225,\n        ],\n        &[\n            154537600, 2783369274, 2784871905, 2923414066, 238748138, 894157397, 425890999,\n            2023402367, 2708989084, 1773914772,\n        ],\n        &[\n            714150426, 747474047, 711763591, 2505815901, 1931970168, 1830915645, 132011662,\n            1641495062, 3649937934, 1578564850, 2879358541, 2256534044, 375624512, 402134451,\n            124437205, 2656206024, 3918226432, 2934327023, 2861387419, 1259632526, 168082530,\n            1906995676, 1276986866, 966360812, 0,\n        ],\n        &[\n            2584563904, 501423603, 3179309343, 2650015179, 1354929902, 930009290, 4239032359,\n            315773096, 1219190592, 1141774901, 2074216575, 279450192, 2450874439, 247131610,\n            26955632, 3117135685, 2632739337, 2367699203, 1269501214, 837130129, 824399760,\n            1192414122, 2569424753, 1942029336, 0,\n        ],\n        &[\n            2166600367, 3206417308, 2873245177, 3181806685, 47762280, 4077132431, 3414741771,\n            595567128, 1650380454, 3351739639, 1204748131, 4239748557, 4216796226, 1580325602,\n            2295006359, 928145182, 2501406243, 2685614796, 1481907821, 3500619179, 3653788019,\n            2099044319, 251730683, 1101601776, 0,\n        ],\n        &[\n            327036000, 3129689357, 722252402, 3256719743, 762583270, 1730383711, 2418392723,\n            3837009731, 993829843, 531209884, 2056099111, 2266372736, 1988906408, 2154603398,\n            2683386624, 826004386, 3819045504, 3703296261, 2407207875, 3346505456, 2182410563,\n            1915488498, 41659158, 2205564200, 0,\n        ],\n    );\n}\n\n#[test]\nfn test_limbs_gcd_reduced() {\n    let test = |xs: &[Limb], ys: &[Limb], actual_out: &[Limb]| {\n        let x = Natural::from_limbs_asc(xs);\n        let y = Natural::from_limbs_asc(ys);\n        let mut out = vec![0; xs.len()];\n        let mut xs = xs.to_vec();\n        let mut ys = ys.to_vec();\n        let out_len = limbs_gcd_reduced(&mut out, &mut xs, &mut ys);\n        out.resize(out_len, 0);\n        assert_eq!(out, actual_out);\n        let gcd = (&x).gcd(&y);\n        assert_eq!(Natural::from_owned_limbs_asc(out), gcd);\n        assert_eq!(gcd_binary_nz(x, y), gcd);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - n < GCD_DC_THRESHOLD\n        // - xs__len > n\n        // - !slice_test_zero(&xs[..n])\n        // - !mask.get_highest_bit()\n        // - x_high >= 2 && y_high >= 2 in limbs_half_gcd_2\n        // - x_high <= y_high && (x_high != y_high || x_low <= y_low) in limbs_half_gcd_2\n        // - y_high < 2 first time in limbs_half_gcd_2\n        // - !limbs_half_gcd_2\n        // - xs_len < ys_len first time in limbs_gcd_subdivide_step\n        // - xs_len > s in limbs_gcd_subdivide_step\n        // - ys_len > s first time in limbs_gcd_subdivide_step\n        // - xs_len == ys_len second time in limbs_gcd_subdivide_step\n        // - limbs_cmp_same_length(xs_init, ys_init) == Greater second time in\n        //   limbs_gcd_subdivide_step\n        // - xs_len != 1 first time in limbs_gcd_subdivide_step\n        // - ys_len > s second time in limbs_gcd_subdivide_step\n        // - n != 0\n        // - xs[0].odd()\n        // - n != 1\n        // - y_0 == 0\n        // - y_0.odd()\n        test(&[0, 0, 0, 1], &[1, 0, 1], &[1]);\n        // - n >= GCD_DC_THRESHOLD\n        // - n > s in limbs_half_gcd\n        // - n >= HGCD_THRESHOLD in limbs_half_gcd\n        // - n < HGCD_REDUCE_THRESHOLD in limbs_half_gcd_matrix_reduce\n        // - n < HGCD_THRESHOLD in limbs_half_gcd_approx\n        // - n != s + 1 && !mask.get_highest_bit() in limbs_half_gcd_step\n        // - y_high >= 2 first time in limbs_half_gcd_2\n        // - !subtract_a in limbs_half_gcd_2\n        // - x_high != y_high first time in limbs_half_gcd_2\n        // - x_high >= HALF_LIMIT_1 in limbs_half_gcd_2\n        // - x_high >= 2 second time in limbs_half_gcd_2\n        // - x_high > y_high first time in limbs_half_gcd_2\n        // - x_high >= 2 third time in limbs_half_gcd_2\n        // - x_high != y_high second time in limbs_half_gcd_2\n        // - y_high >= HALF_LIMIT_1 in limbs_half_gcd_2\n        // - y_high >= 2 second time in limbs_half_gcd_2\n        // - x_high < y_high first time in limbs_half_gcd_2\n        // - y_high >= 2 third time in limbs_half_gcd_2\n        // - x_high <= y_high first time in limbs_half_gcd_2\n        // - x_high < HALF_LIMIT_1 in limbs_half_gcd_2\n        // - !done in limbs_half_gcd_2\n        // - !subtract_a1 in limbs_half_gcd_2\n        // - x_high >= HALF_LIMIT_2 first time in limbs_half_gcd_2\n        // - x_high > y_high second time in limbs_half_gcd_2\n        // - x_high >= HALF_LIMIT_2 second time in limbs_half_gcd_2\n        // - y_high >= HALF_LIMIT_2 first time in limbs_half_gcd_2\n        // - x_high < y_high in limbs_half_gcd_2 second time\n        // - y_high >= HALF_LIMIT_2 second time in limbs_half_gcd_2\n        // - x_high >= y_high in limbs_half_gcd_2 second time\n        // - x_high <= y_high second time in limbs_half_gcd_2\n        // - y_high < HALF_LIMIT_2 second time in limbs_half_gcd_2\n        // - !skip && limbs_half_gcd_2 in limbs_half_gcd_step\n        // - out[n - 1] | ys[n - 1] != 0 in limbs_half_gcd_matrix_1_mul_inverse_vector\n        // - n != 0 fourth time in limbs_half_gcd\n        // - x_high >= y_high in limbs_half_gcd_2 first time\n        // - y_high < HALF_LIMIT_1 in limbs_half_gcd_2\n        // - subtract_a1 in limbs_half_gcd_2\n        // - y_high < HALF_LIMIT_2 first time in limbs_half_gcd_2\n        // - out[n - 1] | ys[n - 1] == 0 in limbs_half_gcd_matrix_1_mul_inverse_vector\n        // - x_high < HALF_LIMIT_2 second time in limbs_half_gcd_2\n        // - x_high > y_high || x_high == y_high && a_low > b_low in limbs_half_gcd_2\n        // - x_high >= 2 first time in limbs_half_gcd_2\n        // - subtract_a in limbs_half_gcd_2\n        // - x_high < HALF_LIMIT_2 first time in limbs_half_gcd_2\n        // - n == s + 1 in limbs_half_gcd_step\n        // - mask >= 4 in limbs_half_gcd_step\n        // - x_high < 2 first time in limbs_half_gcd_2\n        // - !limbs_half_gcd_2 in limbs_half_gcd_step\n        // - xs_len == ys_len first time in limbs_gcd_subdivide_step\n        // - limbs_cmp_same_length(xs_init, ys_init) == Greater first time in\n        //   limbs_gcd_subdivide_step\n        // - ys_len <= s first time in limbs_gcd_subdivide_step\n        // - n == 0 fourth time in limbs_half_gcd\n        // - new_n != 0 in limbs_half_gcd_matrix_reduce\n        // - !x_high && !y_high in limbs_half_gcd_matrix_adjust\n        // - new_n != 0 first time in limbs_half_gcd\n        // - n != 0 second time in limbs_half_gcd\n        // - n > s + 2 in limbs_half_gcd\n        // - n != s + 1 && mask.get_highest_bit() in limbs_half_gcd_step\n        // - limbs_cmp_same_length(xs_init, ys_init) == Less first time in limbs_gcd_subdivide_step\n        // - n != 0 third time in limbs_half_gcd\n        // - first zero in limbs_half_gcd_matrix_mul_matrix\n        // - second zero in limbs_half_gcd_matrix_mul_matrix\n        // - ys_len <= s second time in limbs_gcd_subdivide_step\n        // - s != 0 fourth time in limbs_gcd_subdivide_step\n        // - ys_len != 0 second time in limbs_gcd_subdivide_step\n        // - mask < 4 in limbs_half_gcd_step\n        // - new_n != 0 first time\n        // - limbs_half_gcd_2\n        // - mask.get_highest_bit()\n        // - y_0 != 0\n        test(\n            &[\n                4197577227, 3663616140, 2551363557, 471855676, 1132453243, 3890478103, 3255658039,\n                924933869, 1182514876, 3443542006, 1628670028, 1920607761, 1774928803, 698481201,\n                1688346100, 3912816434, 1546494740, 295495534, 207209302, 1228953098, 3286562513,\n                2448096226, 2547931780, 2100456764, 4196096572, 2722413368, 247913388, 3316902282,\n                60763307, 2236362858, 2725594164, 774854500, 1708955617, 1129631186, 2093339374,\n                3603997370, 1314390085, 2641774231, 385916035, 2355828959, 821901122, 458162478,\n                2603441028, 1665224323, 2479737003, 325263924, 3583373830, 1314852315, 3062488937,\n                2409141051, 2802944956, 1176409253, 4206372227, 3264669278, 376728881, 3979228915,\n                789107765, 1384935912, 2580449282, 3943579021, 1561210927, 2058485109, 2277329329,\n                3961162387, 2853000821, 2810633314, 3958004542, 1042177900, 2041876084, 2531779261,\n                1110199836, 4268607687, 3910301281, 2843809243, 930485055, 309142224, 2144761027,\n                2416055325, 3266084990, 2447991430, 2443964826, 3786182453, 2724967444, 2929403702,\n                2871781906, 2093610692, 2665818776, 2885572011, 1023583045, 388434237, 3383760566,\n                3331268852, 812997613, 743229208, 707412010, 2045807268, 3029838557, 2734070773,\n                1201494085, 2013003250, 3352629986, 2121723344, 2606274703, 446904615, 1986390279,\n                777681916, 850787414, 998620529, 3430750455, 4223290015, 850807722, 3597579048,\n                1953183408, 2598401455, 4174123707, 2094682680, 3126686508, 741312051, 1249776706,\n                3394903770, 1488538657, 86039141, 1122597620, 4088204860, 1965673179, 3854858790,\n                1805056514, 712813144, 2223549448, 3340696011, 1057241621, 4123508209, 1178122500,\n                3345161830, 1643843465, 3443634290, 1183490760, 3948287560, 1351208937, 1585302010,\n                321331177, 1982899829, 4207584480, 428023286, 313173943, 1893554339, 3657870602,\n                1184563157, 2577756042, 3633915258, 4107506336, 2000538440, 3462275636, 905594775,\n                2288056884, 2174527929, 1967515771, 1889360380, 3647702195, 2766306052, 1692805723,\n                2547117089, 2806372808, 1868864235, 377724386, 2108963424, 1243470944, 3419076435,\n                215621577, 4277714044, 1847653420, 1364769655, 3409308990, 3221049591, 727661675,\n                1355876888, 477454154, 159184771, 47758267, 82226374, 173939358, 3989288267,\n                882358143, 314672149, 241143075, 1276781232, 3729530695, 4062922154, 882397039,\n                717181562, 1487490701, 2348085968, 3844176796, 3858520706, 2303777194, 1570281243,\n                701612807, 1685259689, 44118858, 2403065948, 2475839209, 4243425343, 2409356427,\n                3602873673, 2794543251, 1879804284, 986610444, 1780607155, 2709668878, 3714165156,\n                3474383994, 52876951, 2738151673, 3272452228, 157949197, 3388390384, 1867287032,\n                3397657263, 893351542, 359080279, 1867186583, 2633080366, 1691644564, 2228425159,\n                205919408, 2674325620, 408159999, 2614176370, 2954808008, 4288814065, 592989283,\n                2421568051, 3947678068, 1076048985, 2725991063, 1466932877, 47765783, 2096755893,\n                3871926112, 3067385837, 1115438999, 673485739, 4051915345, 3287777679, 3432949036,\n                712556260, 2115195072, 1163581657, 717872497, 1372142050, 1296789715, 3248464426,\n                2010337977, 1022298124, 4097244827, 3132735945, 1590029541, 1952666134, 3738758275,\n                795022630, 1022963383, 322333376, 3927893537, 1123308885, 3926676584, 110023661,\n                1847201588, 3972030290, 1877137386, 2340701232, 2680282095, 171364221, 1255189251,\n                4206413144, 3146670074, 2595432946, 2123584779, 421107554, 1661340820, 1717955211,\n                1093855779, 2562116708, 311124173, 1286538456, 784915601, 2787458377, 2909859896,\n                2079504712, 2482552290, 381311010, 4164814891, 3498767523, 1871402912, 4280107119,\n                3555212136, 4263072354, 2428360919, 4030822435, 414962043, 2110229154, 3145804625,\n                3419521350, 2300309736, 1037962840, 360477135, 2761975814, 3570812469, 2141362836,\n                3744698030, 2917828184, 1604822798, 524785135, 4123189923, 306254809, 2907418601,\n                715269380, 2880366359, 85178201, 3315366581, 1234064887, 2261417810, 740136577,\n                311877843, 916858922, 701414307, 2440960632, 2877171070, 832859154, 1906376412,\n                2470726441, 746564647, 3169727501, 3847690619, 2569989652, 4143797285, 1181804091,\n                3467101578, 1620737185, 798590631, 1102046391, 86799227, 1011686392, 2365540922,\n                1437914259, 3977803079, 2484908631, 3183729029, 770778157, 2110032689, 642819790,\n                3783384202, 2203826388, 179388270, 3069155346, 2279937873, 3949687834, 2292743729,\n                1695844312, 1519061556, 333473276, 304895978, 2399722902, 2408889893, 4198515797,\n                1815311964, 3633226566, 1221066756, 2016659596, 1969286056, 1186325182, 1718972725,\n                228738772, 2598964902, 4168009255, 2340771410, 3236251687, 3295756396, 359898616,\n                748792865, 2815036617, 2294605685, 2576581376, 3104446059, 1374922466, 3229588626,\n                1342195213, 4121614180, 1287499457, 1644513681, 2251892498, 3519911253, 3676415503,\n                3642198693, 764265217, 3084097378, 2745050223, 3246393306, 561565268, 961468834,\n                3209498589, 2760753568, 27068759, 1509048774, 1453964033, 1331717633, 2158694102,\n                1233260646, 2709419591, 177106547, 2429674784, 1301711456, 2208920832, 176199715,\n                3161955920, 3374145530, 4247833566, 4210175938, 2667521985, 2158406637, 28032585,\n                3422529443, 2403124753, 4248809640, 1432019389, 2720502195, 3698731935, 3697762717,\n                3038810720, 73235983, 1930366289, 1889267718, 1024383025, 3630767897, 2664806680,\n                1701068479, 3104152545, 3126610581, 1945171628, 2107750861, 1705151590, 1384917050,\n                1013720645, 3504778715, 3696436857, 1705707415, 2189842908, 1689236637, 1657303695,\n                544592080, 1136857424, 824561482, 2369780064, 2472849354, 2717401545, 2421800924,\n                580975041, 750461869, 3727051247, 3077843833, 18610721, 194041714, 1077076049,\n                1259434033, 1763428865, 2241079119, 2783260484, 305088684, 4127815512, 736813644,\n                540809689, 3159882452, 1825555986, 1501660759, 3053878326, 2824718405, 958691107,\n                1972676940, 501505940, 2507376271, 4221542679, 7397642, 335120812, 4137134683,\n                394428968, 867251752, 156156583, 3806282517, 3663693413, 1066638741, 3888387987,\n                3416832624, 1874236937, 1816284001, 24943821, 2444851827, 2900828566, 2539594150,\n                779015020, 2409648256, 2933935060, 3781965704, 2113602755, 1850649100, 344087483,\n                1315113853, 3810878395, 2922986247, 1124979158, 1254362509, 2961155811, 567171845,\n                1368984368, 3708291355, 3083282828, 1452928286, 2981316093, 3064523290, 1479238797,\n                2292333655, 2448998592, 3524304101, 3649979636, 68492449, 1954531957, 2750371018,\n                1841894757, 1097795246, 2048976053, 3845300136, 2399041467, 2960591765, 1149499376,\n                625651164, 2037776876, 164166162, 2380013720, 66608184, 3818619585, 2131700282,\n                502477679, 2053801901, 2925841131, 1028579949, 762321931, 3017484607, 2336518362,\n                2067352515, 3383243930, 3093911248, 1575534888, 4087803856, 1041068290, 1614488293,\n                3321708937, 1309929846, 1384017125, 1090379238, 439291539, 3162665576, 344261203,\n                3404316428, 550149101, 2430715962, 2274647103, 1656669548, 1081997280, 1328444417,\n                2031945767, 1473781932, 2837006571, 1533898454, 3338843219, 3838110065, 1262509474,\n                3527801284, 2579686530, 3569205777, 4100363249, 2105425082, 2234328532, 2748351804,\n                2673483805, 3924474224, 2636212581, 3463412678, 4098352143, 2368424540, 4175082715,\n                2039046172, 3243053164, 1220737144, 1748690383, 2080583256, 1099659816, 1135489475,\n                2884856950, 4192473639, 1947310046, 2881220399, 3944101233, 2762458465, 4110783623,\n                1673864095, 1791817121, 2629252938, 2351311744, 1835759362, 1831898034, 3637639151,\n                2781044911,\n            ],\n            &[\n                2582606328, 3907176038, 1869269403, 1460626031, 582046080, 4111410419, 2516532417,\n                146794403, 430764753, 1289757806, 833414363, 1159861655, 1855686035, 660114073,\n                2678166363, 976180952, 3948114536, 2765729676, 1405860081, 390581044, 2452693248,\n                166981518, 4119389957, 2838988971, 1280548287, 2735105611, 2230034237, 807044950,\n                2753901414, 3377733072, 1260163723, 2906031321, 1160378830, 14255505, 2306821236,\n                1827788545, 1803661748, 3344014911, 358752723, 3659821753, 1669317560, 230363172,\n                1671886371, 1424632611, 2409163050, 508495152, 2520039856, 3298638732, 1428088953,\n                2701777018, 3798098801, 1335576077, 2246521165, 3958581687, 1600454442, 3907674130,\n                3548795039, 3826552611, 3725833438, 2551041161, 2709616429, 2354699408, 3126481426,\n                3099474439, 937375512, 2352825782, 1243847506, 1747475903, 233022035, 728638168,\n                2156419178, 1739901706, 842209461, 1678526634, 4177514773, 1117076123, 2650916066,\n                3124223161, 1696818673, 1436772296, 3437185289, 261500205, 992897074, 4122050997,\n                3281707495, 437035780, 764393933, 702695215, 20994502, 1300788043, 2485247663,\n                2129017620, 1314245779, 2080540901, 3382431782, 4177690980, 496213991, 3620296923,\n                45820436, 824665660, 1249390567, 2880218577, 793755363, 2099510489, 1127291309,\n                3018724734, 4045529792, 3787034562, 2447184228, 4231165855, 2543665948, 2685844279,\n                3687498369, 2465827535, 937827718, 3493198617, 1112432160, 682701349, 2407287012,\n                261540535, 403665586, 739072430, 4114763090, 276463615, 938788455, 3393306569,\n                493459877, 2513680357, 229914576, 2765762116, 3809089681, 1975260832, 630837582,\n                512373818, 2415638589, 816524198, 926812996, 2919108012, 1777763031, 2420059151,\n                2303215774, 730440645, 2590700033, 4251535370, 4205174050, 4119494394, 960682558,\n                2886343983, 3540930563, 711941431, 1626586284, 981652789, 2327139618, 626401545,\n                612995811, 1953752764, 2899519720, 1408949156, 4290924666, 3997643096, 1422846953,\n                364233241, 2659284800, 965784531, 3136185596, 1794737991, 1004877728, 3355875944,\n                2432964630, 4193048101, 1130684469, 3045267236, 1286642177, 2756498771, 932256612,\n                961567406, 1201162315, 1773420101, 2567717098, 709597428, 452677858, 4284511418,\n                3021868094, 686834336, 268204656, 187140090, 2471076712, 144112752, 793083023,\n                3609314649, 1553540924, 1941459858, 94249970, 2264076058, 1658809682, 2185281448,\n                357602413, 2940153559, 2210448220, 1292548375, 144668819, 2795072628, 4170611652,\n                2951824217, 478980333, 77414522, 2542872381, 310035381, 3503531438, 2774626613,\n                1665526812, 1575810865, 3550598577, 2584875090, 14090765, 4084436300, 1767381238,\n                452463079, 547596654, 1305057780, 2372702234, 2823750152, 2615637338, 3915249206,\n                2017151267, 512190028, 3431028255, 1204341799, 1734623287, 965084563, 2326922875,\n                953678590, 2503809985, 1951017332, 2478332356, 3743715904, 3536776438, 2015910466,\n                583258098, 1654548120, 3876369464, 1912036404, 1854124724, 3285753258, 4239446578,\n                64896010, 3226676422, 709577570, 3605847387, 4233435166, 3578913837, 1305181609,\n                1104334009, 535007176, 3368595294, 3400831924, 2658360667, 83892703, 452925944,\n                1148434659, 3632651250, 2497302974, 4052931735, 2825332083, 4085939360, 2559084850,\n                3079544094, 4119878194, 504432022, 2083265837, 1798431512, 465950253, 2330752139,\n                1762670455, 4153406121, 171243945, 2564294901, 3457826969, 3997425378, 3322817525,\n                1219343400, 3494114736, 1472311045, 278005611, 3537646006, 1737609178, 745736375,\n                1744823525, 271949138, 3132324813, 2299821342, 2740187772, 1351381540, 3548063636,\n                1535674335, 1875773947, 1619241799, 1128793993, 1049425265, 3145446141, 3425432576,\n                2046178101, 1387398701, 1597786450, 1263128416, 34613519, 4163179935, 1798039392,\n                3111216944, 2777264082, 22483696, 1038704995, 3359344737, 3795184360, 1831084665,\n                228540483, 690048105, 2440634399, 801439700, 1953285894, 1885782072, 490462137,\n                1220610650, 87049442, 3789599385, 3845031019, 2099863453, 2821455657, 1978309953,\n                3224772848, 727874845, 120712817, 4094193244, 696826576, 408973252, 2585539339,\n                633960302,\n            ],\n            &[1],\n        );\n        // - xs_len <= n\n        test(\n            &[\n                1304645631, 3453605495, 2384770191, 4234662844, 193170837, 3507896589, 1570888072,\n                3287476780, 3273564387, 2083012415, 2738572262, 216274431,\n            ],\n            &[\n                140631447, 652003847, 539742246, 1688191151, 622459323, 2568104193, 1918906162,\n                3927704678, 3061246232, 1898154381, 2239425174, 122041517,\n            ],\n            &[1],\n        );\n        // - x_high < 2 third time in limbs_half_gcd_2\n        test(\n            &[\n                2504682851, 2582732736, 385625941, 2382204212, 314045215, 2050447634, 503267526,\n                1775048793, 3749152248, 83577313, 3954681023, 2222858364, 2002028732, 3989047480,\n                3329901642,\n            ],\n            &[2374767210, 3305948119, 2775088291, 3859016530, 6636685],\n            &[5],\n        );\n        // - slice_test_zero(&up[..n])\n        test(&[0, 1, 1], &[1, 1], &[1, 1]);\n        // - an == 1 in limbs_gcd_subdivide_step\n        // - s == 0 fourth time in limbs_gcd_subdivide_step\n        // - n == 0\n        test(&[0, 0, 0, 0, 1], &[1, 0, 1], &[1, 0, 0]);\n        // - n == 1\n        test(&[0, 1, 1], &[1, 0, 1], &[1]);\n        // - limbs_cmp_same_length(xs_init, ys_init) == Less second time in limbs_gcd_subdivide_step\n        test(&[0, 0, 0, 0, 0, 1], &[1, 0, 1], &[1]);\n        // - limbs_cmp_same_length(xs_init, ys_init) == Equal first time in limbs_gcd_subdivide_step\n        // - s == 0 first time in limbs_gcd_subdivide_step\n        test(&[1, 0, 1], &[1, 0, 1], &[1, 0, 1]);\n        // - x_high == y_high first time in limbs_half_gcd_2\n        test(&[0, 0, 2], &[1, 0, 1], &[1]);\n        // - y_high < 2 second time in limbs_half_gcd_2\n        test(&[0, 0, 2], &[1, 1, 1], &[1]);\n        // - x_high == y_high second time in limbs_half_gcd_2\n        test(&[0, 0, 0, 0, 1], &[1, 0, 3], &[1]);\n        // - xs_len > ys_len first time in limbs_gcd_subdivide_step\n        test(&[0, 1, 1, 1], &[1, 0, 0, 1], &[1]);\n        // - n == 0 second time in limbs_half_gcd\n        // - s != 0 first time in limbs_gcd_subdivide_step\n        // - new_n == 0 in limbs_half_gcd_matrix_reduce\n        // - new_n == 0 first time in limbs_half_gcd\n        // - nn == 0 first time\n        // - nn == 0 second time\n        test(\n            &[\n                104199695, 1437842355, 3026540896, 1036691142, 2895760091, 316986459, 3848493166,\n                4283163139, 1409731068, 2162161861, 3180981287, 2664973704, 3129778597, 1141759869,\n                3423483599, 3304860181, 1499458172, 2283443318, 304208206, 3898070080, 1624380249,\n                4217356185, 3984965450, 1989320468, 4046024996, 290564828, 982998126, 714749497,\n                1256133149, 1964245093, 1989969476, 2845229677, 75994139, 1534010229, 3551668582,\n                437558754, 2400783907, 1104529196, 2628109158, 767576225, 3386003603, 2589581389,\n                3197373266, 1119570806, 2388054566, 560919780, 2181214692, 895228346, 2455964730,\n                1236092704, 3460190245, 2187848751, 355369047, 1999986258, 3567727382, 1691926629,\n                2725212068, 2592492178, 797372755, 1342659622, 1706103226, 2741335822, 683303027,\n                2714389761, 3546978425, 1986412131, 762213298, 2333449774, 778670753, 97719623,\n                581978613, 3531804453, 1122531574, 1722591132, 2538512178, 1919025659, 3171826961,\n                3494777585, 3878057786, 1159079409, 1839284455, 1154718578, 2665661658, 897285327,\n                1500853657, 2633085447, 1751356374, 3270858770, 1163694943, 3330045700, 1488678831,\n                3027918693, 502928061, 1337476314, 3692361284, 2178683191, 3096849964, 970332766,\n                1824923766, 846751495, 2918346590, 70616406, 3836757211, 2684780384, 2463029602,\n                3457312899, 887456732, 3244684159, 1709425071, 1650827329, 1114331473, 2300037523,\n                47504219, 2349860938, 514226917, 2830450926, 3649882524, 3714094143, 301323195,\n                4142782943, 3785993652, 866247992, 2164534671, 2737799129, 3275770468, 215424696,\n                4257046307, 1733065842, 2434034911, 1462340609, 3642973392, 3350853644, 4199792744,\n                684333086, 217713765, 3411993450, 1792335767, 4171842881, 159579156, 2430618740,\n                3131183234, 3163246383, 2128439763, 2401347699, 2936760275, 3236944394, 2200904017,\n                2436166477, 4193014474, 3613539040, 2916219306, 4261812949, 115873482, 2180021985,\n                4055598752, 1260608904, 2416550157, 1259155018, 1431188781, 1176329051, 2299641742,\n                3980571345, 1599289272, 1782362083, 3811356761, 1974756300, 533380582, 3641430046,\n                832768712, 672407572, 1502225325, 1016817644, 14093203, 1980541787, 1908462143,\n                3913154473, 724095260, 1182316086, 719426427, 75511913, 3523894057, 3990195494,\n                2120530771, 3562485018, 1433690638, 2518584164, 1493664787, 3968793063, 3670159139,\n                157980348, 1301197374, 3305985080, 3941044403, 612257166, 3771911392, 2763453419,\n                2718688747, 3693090746, 589991197, 498197071, 2438022286, 3991964070, 377079193,\n                3099592329, 3321736969, 3902471945, 2307760142, 3013676133, 3258936160, 4011810226,\n                1053219984, 2837546691, 1856062985, 2092610837, 91102249, 406247891, 890201919,\n                2559127506, 338532027, 395154770, 3275565770, 1258530084, 2939576662, 2055294057,\n                1883048671, 3836169741, 2026424182, 3339579277, 1542609345, 417648228, 4191728149,\n                2895752032, 1515160584, 278532504, 1393858866, 1730994375, 3794676496, 1670361915,\n                1258111291, 2422641149, 2347194379, 80193494, 2358530906, 2877787771, 1965418230,\n                4205347720, 2666879163, 4215296303, 2916779693, 3935289306, 3244538076, 1632052180,\n                4176725684, 992286325, 2739073795, 2079197711, 2797905589, 2449598406, 289423436,\n                762177014, 2363661744, 772167940, 2765100761, 198147685, 572172334, 3817619946,\n                162288540, 1223981567, 540177774, 2154166987, 2653356928, 3206160568, 1862076861,\n                3133558385, 474824123, 2525460202, 3924632969, 1146129872, 1432186566, 737582770,\n                3316793636, 3709987676, 3557072993, 567470616, 1129703040, 1521364280, 3566052322,\n                916273230, 2293310523, 1377033267, 1508571570, 3382970810, 2996523808, 1581520543,\n                2618222496, 3288125825, 2313878894, 349906863, 2219317771, 3176122714, 1013378826,\n                4116023745, 1921798849, 3062375628, 2736960803, 2501959999, 1510561246, 1700569625,\n                1652836989, 3312274215, 4195830099, 1132143254, 950525497, 2316560086, 375651095,\n                2664099671, 455151019, 1159444553, 4198810519, 3127984438, 2144120008, 1969060002,\n                562539184, 1602239482, 2852481959, 2095454819, 3210933640, 3500352077, 3422305025,\n                2014869566, 2974700896, 3465912392, 2040467605, 4197300028, 3591134045, 3895974116,\n                1820422501, 1395818068, 2660152096, 1916184939, 3260276758, 53585995, 927898271,\n                2259302740, 963522240, 2856612864, 3450205940, 3367413678, 3535931570, 397649639,\n                3700183847, 1270654564, 3500464902, 3997758233, 3130672822, 2562223359, 638317405,\n                3181668171, 539650504, 2914453051, 645816251, 4007289298, 3438058969, 2770073590,\n                864060896, 2320524273, 3692263013, 3473619051, 3882200592, 499549190, 2692529571,\n                1895097838, 3793943961, 3454593367, 1512683055, 852698565, 1995890144, 865090611,\n                609912127, 2960073872, 1078887,\n            ],\n            &[\n                3965328483, 312519701, 3403268855, 3606492602, 1902761898, 851349064, 3139262646,\n                633064190, 2260801841, 3139511175, 2981429315, 570792856, 3276826258, 3740173343,\n                2258820496, 613809729, 241642072, 3441475901, 4294219823, 976984900, 2389777673,\n                4191459734, 1003327410, 1302790361, 2451013524, 2641182095, 3622343124, 2806631117,\n                3967790700, 581646251, 2019686780, 2032370136, 2076036058, 856161788, 3365012291,\n                2890451318, 2127795458, 2187590985, 4093939520, 343783955, 4242308697, 4157888926,\n                2564079477, 4260723333, 221747269, 2643548554, 3833528808, 1763870742, 825076470,\n                259966747, 1095002154, 931639969, 3831275768, 2810876375, 3231187357, 3440619698,\n                2434935986, 612813763, 1378882183, 2162485107, 1140428311, 3695900833, 3397094290,\n                4162195979, 2662618085, 3751543150, 3243820436, 3516498989, 707780244, 2079085110,\n                448686345, 1895725327, 2371954578, 512402760, 2522669399, 3692228697, 4274764985,\n                3682675544, 3852971158, 3189904769, 3141125752, 3990040037, 688067094, 4206021309,\n                1411303768, 751179620, 1438168058, 3448172742, 917372130, 1562060869, 515503757,\n                2481107086, 2276549351, 4210575064, 1210846101, 3889280108, 1149707690, 3998423549,\n                450077793, 3069409039, 1205057532, 4241449813, 4263835068, 777002153, 97116780,\n                1862501041, 4173027391, 538950023, 2024750625, 1067091172, 3975089902, 3595618138,\n                1162626458, 2892893888, 185770841, 2582369494, 3927002631, 3209126940, 3017762169,\n                3322211458, 184442973, 577978350, 564069165, 3126111172, 1558987521, 3158591140,\n                2367515315, 3627578322, 3638689514, 2197481806, 387613, 3780351852, 2801314434,\n                1919960640, 414138073, 161239652, 5955360, 4204709093, 49134550, 1616981665,\n                2152668401, 3606726895, 1857761242, 1299061544, 3099986598, 3846390597, 3355161875,\n                595322253, 2252701581, 2283337465, 675228606, 2653548638, 3430616197, 2380374646,\n                3784410660, 1379122536, 3178229817, 3972552968, 3447966842, 1961475461, 918042062,\n                1365972881, 2129295687, 2448607551, 2884167968, 3568778297, 2408690044, 469704050,\n                304852349, 2906236085, 2120391091, 606392149, 1797001614, 3658187294, 2116257019,\n                2708625014, 2498918970, 3223950057, 4105341944, 243352585, 3784332349, 522017452,\n                1593525595, 4137737627, 167793374, 4087606703, 344557611, 2032896579, 2593781680,\n                1431393249, 141052093, 2496087765, 2700336339, 516501742, 1876246139, 1822328287,\n                2252547797, 4061227450, 2006777028, 3501565120, 3466396566, 735894510, 255684379,\n                303584386, 1336037903, 1323979436, 1064067294, 3553551979, 2832942530, 1268770967,\n                1027134407, 545735300, 3866535246, 2986685637, 1613305389, 1267557025, 31509612,\n                771698397, 1878270300, 110063942, 4276370389, 3260973919, 2964940734, 1109302596,\n                1411099702, 4020146211, 3169853494, 2389480541, 556890992, 1074682663, 1708332475,\n                2658991487, 2894729410, 2296152345, 1870102242, 955236482, 2125245922, 1470432646,\n                1889719140, 3468723644, 35016220, 2579705046, 2403600204, 2455839109, 738153092,\n                361506106, 1501550475, 1570537857, 2512180427, 2079164570, 3284728752, 2525205632,\n                1765298251, 324508463, 4289185078, 3262124640, 590432268, 3609992720, 1056480497,\n                1521962672, 2902938979, 3633169769, 818640538, 3205732694, 3783707657, 1320287971,\n                3427819133, 123698783, 1954647368, 1478731664, 729732421, 3485056101, 3384149754,\n                886686555, 3524117645, 3672706053, 3467528186, 1825239229, 3605286168, 4252587265,\n                2476737792, 1468148598, 1767076404, 3098062795, 2235174734, 3938633722, 3377437243,\n                2055298570, 974103332, 1521104891, 1331281005, 3901922961, 2788866965, 1326440607,\n                3830433543, 2349058686, 1891550867, 289592648, 833149915, 4062577431, 300173440,\n                3618259462, 2437802253, 1988806398, 1196009062, 1693726935, 4261250055, 3358655485,\n                1354639338, 4217909066, 3173323323, 1256774815, 2873946595, 783721831, 3287664797,\n                1212500109, 544495281, 3943757093, 3869342488, 3580616897, 2288353173, 1381949567,\n                1954109845, 1071065683, 1907373154, 1605862239, 399825655, 1608845741, 1366351932,\n                1757744839, 2456500252, 4271660304, 2736932691, 1256196079, 654792440, 3432423047,\n                814117095, 3916828311, 1478775709, 2623979306, 3502313771, 1912113011, 826313993,\n                2137260095, 4198684443, 54736831, 380668741, 872309827, 3132896276, 1131528234,\n                1143308601, 528742460, 3890747269, 2898367605, 3531963195, 2576564587, 2690837364,\n                2676539983, 1748034501, 3722941468, 2157585074, 738387831, 161914314, 3886930899,\n                805359701, 84535132, 1019698896, 1024816471, 2120663635, 4600563,\n            ],\n            &[\n                436512665, 1372743407, 342109034, 2762999440, 1801741181, 1128075399, 536773409,\n                2462344174, 4092132461, 1413817282, 3712114490, 446843050, 2277642284, 924335942,\n                250799808, 1300467839, 3708770080, 346693759, 1462440153, 2514050355, 2607744870,\n                572189306, 18842802, 85605861, 3453161777, 65109244, 1981480639, 1036404070,\n                3325202117, 858703184, 1098140435, 137595022, 1796280951, 4121604160, 927712201,\n                2983534703, 1277109179, 1842338521, 684621561, 3003060670, 1334445980, 3716987280,\n                2509263629, 1481158588, 101476260, 2332533799, 3920104238, 1799849987, 289899178,\n                3790057285, 3090879719, 1847908743, 2289570281, 899352588, 1237257524, 3478208269,\n                2864532864, 4237285852, 2021619931, 2299181539, 2990516063, 1146232131, 1906740225,\n                365885015, 436254990, 1572217307, 2276239798, 2938321029, 3411408571, 782341583,\n                245501560, 1212705343, 3987607268, 2685812792, 3162630759, 525514772, 1738934514,\n                4026775891, 675427556, 2638310706, 1872560581, 378254209, 3521602859, 3209772533,\n                2171756894, 1916654768, 464606995, 1021746380, 1509799815, 1803124229, 1626950142,\n                1757247127, 3463260849, 2059493644, 3328028905, 714292268, 4221410307, 3024039287,\n                245477866, 4111629244, 2454388273, 2288605764, 4069258877, 2417991112, 1008037684,\n                1584471268, 480491917, 657289197, 740153804, 3304298858, 3549803564, 3389482897,\n                2285883880, 3754282415, 3452581852, 1300983995, 2563854813, 3387253149, 3144283055,\n                4223958762, 2984826191, 3538501116, 1630274809, 3571211850, 3145706384, 119892266,\n                3268130561, 2893468680, 3796377730, 1313792196, 84565900, 2317626527, 1585112821,\n                2831830124, 3879773053, 3823642743, 260829176, 113541293, 2698035069, 1162236214,\n                56045023, 2572314428, 3303774518, 786546397, 3304627813, 2532190633, 733612212,\n                3194392916, 1538645070, 871903777, 346960285, 3824030942, 991737609, 660569608,\n                25531145, 3125334834, 2019398137, 136254844, 2601227241, 3740691089, 1400597961,\n                758494376, 1289737416, 176798002, 52677595, 1282844193, 2029711214, 1154925510,\n                924664133, 2384558292, 2657323714, 3032100806, 2076618856, 3874064840, 2301862464,\n                2613824074, 2408544438, 3475871678, 4286594061, 3888658535, 1599077513, 3091123524,\n                691764425, 571533226, 643388614, 1946732585, 231085233, 3636702918, 3681581111,\n                3187061512, 1902159644, 1741637618, 761538126, 1536383210, 579538109, 2344701437,\n                1320685197, 429406282, 614226248, 3064576305, 3913009213, 1408468081, 2953160453,\n                1860909301, 1257356077, 2326226229, 512992927, 4173707647, 4227234757, 2055824003,\n                1797074658, 723531295, 1055503760, 3723048013, 1019848561, 1813977292, 2245679653,\n                4188374262, 2764314541, 3543381795, 700976608, 1790968603, 1926021909, 604162486,\n                3885171802, 886529425, 2545372123, 1099009280, 2144253074, 2286027026, 3759545247,\n                65262690, 867405492, 478202482, 3860597229, 1950145935, 2338053342, 1301482230,\n                1694465994, 665328168, 1639519384, 1246558025, 3758953070, 514219744, 1033396600,\n                2585944964, 73215891, 1407268144, 3275177322, 713201364, 1552227337, 3796620920,\n                464835142, 2341943175, 3119000857, 2088431307, 3897368907, 878918678, 1090403719,\n                3163407018, 1730981592, 3537552166, 2597674257, 4098649693, 1903525249, 274610490,\n                2448833117, 3013444547, 2285961959, 1309148292, 4284801003, 1457869563, 1131416271,\n                1048930443, 2513500006, 1482041073, 1625081763, 4053050668, 2518621166, 3969148109,\n                2761689155, 2164832372, 81475261, 3345442184, 3349299825, 2006252039, 3489857052,\n                1658875101, 691754231, 849076446, 3627267661, 317685450, 4140537807, 2104452006,\n                3534476970, 2383041805, 3170903305, 738640319, 3255529797, 1446723654, 1118811539,\n                2937204107, 1614377664, 2969444277, 2952928746, 4001684504, 1718111127, 2073038934,\n                1656108772, 3191239768, 1185532158, 562604415, 3971592886, 3000494224, 2019311576,\n                3398207772, 1017177624, 2967316419, 1650769512, 2231731784, 3739468469, 1827669898,\n                141217323, 4207733620, 2832371984, 1621792041, 4151096498, 2547492982, 308078925,\n                3687686062, 2475718624, 3561209065, 4026891835, 1696468987, 3574384454, 2592420513,\n                3300544973, 2850962487, 656760200, 2508381898, 419452052, 626276936, 285665799,\n                3657891297, 554297412, 2239031137, 2012129,\n            ],\n        );\n        // - new_n == 0 third time in limbs_half_gcd_approx\n        // - new_n == 0 fourth time in limbs_half_gcd_approx\n        // - !limbs_half_gcd_approx in limbs_half_gcd_matrix_reduce\n        test(\n            &[\n                3657711640, 998557705, 2673527526, 140583600, 3560526410, 3079349729, 1007803327,\n                208825735, 4004755247, 3170035294, 3362415892, 3152985538, 1012526106, 3432209347,\n                2014829100, 829200636, 4195462629, 886243751, 4231479532, 3989085076, 697433600,\n                4029974025, 2553256073, 2180771906, 589193852, 4067672710, 1710672160, 1276816229,\n                1543905950, 784977036, 2190950050, 3053735776, 2278807238, 3135300984, 139130646,\n                3731236261, 947882330, 397493027, 2887571315, 998281983, 3936346233, 1563553141,\n                963440454, 1318816838, 4291981145, 919167051, 2962354621, 2048072300, 777973943,\n                540037849, 3810855422, 3090640862, 821740314, 3090839706, 2989895484, 717348865,\n                669874649, 3744157584, 491278687, 2028098573, 1277141730, 808716380, 2793035676,\n                4006563562, 1685318670, 3368031079, 2624676111, 1345230900, 2205513093, 3750673160,\n                1587034889, 1439572889, 3845769461, 4280964819, 1482349371, 1079078534, 4168075013,\n                1635840911, 1957150571, 2178101877, 4115634728, 3398571758, 640182611, 1759062480,\n                1075711136, 1010428620, 2276894745, 1504571688, 2596747558, 3855398501, 2838338760,\n                2402020270, 2884702413, 1826928686, 2640885437, 2399131896, 3789994626, 4040600525,\n                1305079453, 81899822, 2191284405, 1815628758, 2609804524, 758549568, 1578952023,\n                518043841, 1501449207, 2578767272, 480891725, 2994717031, 2654624082, 527919434,\n                2238167925, 312529994, 718208527, 2007076208, 586720275, 729308642, 1465364144,\n                1706713224, 3777764105, 4134322226, 1156823710, 1507266584, 231421089, 144523751,\n                1853362091, 1463359998, 305379000, 4240641599, 2721880467, 550468546, 4074779797,\n                3504661731, 3933836974, 4064481517, 1555622614, 657068986, 2312879275, 2981257775,\n                3082895648, 3388461547, 1981146054, 547361683, 3971819850, 1412877825, 2006992814,\n                2288122621, 2206203029, 4226095933, 778245076, 1345823706, 3035370877, 389946835,\n                2749124467, 4010410686, 339262243, 1609006241, 2258477917, 3569782595, 3637101384,\n                2977823024, 426672744, 1521815787, 1263621653, 499965771, 456736400, 2492983378,\n                1224546346, 3806307160, 175211074, 1054659817, 3941472726, 1740350040, 1438650030,\n                2119348495, 2293521324, 3942515909, 614998919, 3084032385, 4144460915, 2482956785,\n                503211659, 34511204, 1681765654, 3380532341, 3242282393, 551611855, 1154795583,\n                201141450, 3394599938, 4032836190, 3946663852, 2007181123, 3278589677, 2773028926,\n                1396191139, 1093235858, 2343752245, 3726488552, 4039496728, 1711775405, 2313196824,\n                3792644308, 650938588, 2340124756, 2148862037, 1605804899, 2561768954, 4158774056,\n                1104406522, 160746998, 3547663955, 2740053054, 297320527, 2288260483, 1727465300,\n                1502488472, 191213708, 3240632447, 2763771729, 3316906616, 286363239, 427523346,\n                1834992479, 1767311733, 2323090189, 777754150, 2637436451, 3864398159, 3878482105,\n                3439516930, 3983770569, 2179596123, 3639743147, 3277930009, 132861371, 3016048414,\n                2479346124, 772138261, 103363267, 2106856453, 3363312313, 2104064722, 2211640386,\n                2790634720, 1094166731, 472640970, 3707415174, 2379763511, 3660706206, 266699090,\n                2825551202, 3816959358, 3686617390, 2405346213, 4064944758, 580087497, 3705304882,\n                804128893, 1526085410, 4259014614, 3424830723, 720534290, 546653993, 3743278090,\n                1876012283, 1494835352, 4205298074, 165588292, 3110211976, 448529551, 3332834541,\n                319442517, 580011988, 2786838094, 2921250286, 3100311441, 532629087, 3433284980,\n                2073128881, 2951256114, 2435157505, 1486539685, 2906352365, 3727836664, 162399185,\n                4051180248, 1338216875, 3019487912, 857100700, 3261403491, 3401769875, 2049869835,\n                4188966169, 1293350219, 1594676200, 3476259820, 2694785494, 45498552, 1043174148,\n                4115811420, 3167680253, 2550477339, 1707821053, 4259857856, 211137496, 198623401,\n                429308573, 1520075160, 2496533962, 2517139935, 1168536469, 3699138961, 2800251863,\n                1390306464, 1692109651, 2356645986, 774325761, 3399926958, 4110738344, 3817779241,\n                2013343760, 2250854886, 351243491, 425031366, 2479242665, 3764357544, 2713277117,\n                2512350560, 905949970, 117406898, 1332418557, 903482453, 4072632262, 1769369186,\n                3494102231, 4127403951, 4081588534, 3220287892, 2278166406, 2040914160, 4090789198,\n                1394480913, 1691201115, 1722070834, 3894412056, 1651961652, 3826548170, 3699211264,\n                3183549152, 2920880337, 182084175, 102220837, 2221619377, 1758527489, 951379287,\n                2855734431, 3213300857, 4263069418, 263677350, 3727218616, 689258763, 1971664130,\n                181797961, 326897757, 3105490726, 232500248, 2261802360, 3085707207, 1389245554,\n                3666172101, 2146196227, 1681117212, 1108350622, 441387235, 1914462616, 984521004,\n                859059782, 2826588020, 2946730104, 1218457794, 245867746, 2189555164, 2126866996,\n                1090542083, 3707825999, 2492424754, 2110587015, 9914155, 497858520, 2957494474,\n                1624327398, 490541517, 1459216649, 310263141, 933264393, 1522660397, 1285180428,\n                1470621088, 1023680737, 720481949, 4214305990, 1259717429, 3353303046, 987419142,\n                2214746907, 932909422, 1788637997, 2735466452, 436276719, 1594193462, 2568346174,\n                4146642666, 1937705165, 3620182538, 2069795783, 1080910056, 1452556953, 390339039,\n                4100737699, 3512365053, 2731125385, 4062819879, 1591306552, 3854740242, 64478911,\n                3073372522, 3345312614, 687806150, 1047499489, 2463969406, 1884499861, 2042651399,\n                10170802, 936049112, 3939636351, 1291898824, 3075319841, 1421285201, 1306154841,\n                1288723177, 2905666609, 2906581743, 4126000750, 1274137379, 2020506513, 837593817,\n                3184876278, 4228491086, 1655288190, 2689287128, 556238442, 113142447, 324605392,\n                2389209854, 2108685128, 4145207287, 3985615492, 3890009695, 3073605401, 990783580,\n                960479727, 2794641498, 1841758262, 2666851594, 2839506601, 921776375, 2622653975,\n                1051634901, 4138029960, 287681273, 2867814148, 4236186571, 3664092009, 1127349061,\n                1289370427, 1166089919, 3232826100, 1090362915, 2063320477, 324664748, 756968253,\n                2079873770, 237416454, 1960074355, 3038229413, 3265986384, 2253499694, 3259818663,\n                4216895416, 1546526391, 954740893, 359758052, 2422581369, 2008469231, 270459062,\n                2662846020, 198030360, 1699647574, 1189229658, 3064589775, 3086260774, 3492329301,\n                95140180, 3679964930, 1719240364, 3308170694, 3900158813, 1824364083, 3912229897,\n                2065183143, 1640649275, 210215170, 3595329392, 2936055969, 3380333840, 2729203827,\n                1716703032, 3346477528, 2910262660, 1448045650, 3214180907, 3765279970, 2747456398,\n                1754123031, 2253034236, 1951705358, 3487056132, 4179006228, 715674883, 1154440593,\n                1890254496, 1287645100, 2931442980, 3677760863, 3113867376, 3657457141, 3252835590,\n                1969239822, 4012698633, 3027155613, 3969623199, 2878407462, 2876709948, 2688525098,\n                3727199561, 2234381059, 3136829525, 3554705692, 1831478139, 1674107447, 2082176817,\n                670088203, 728773244, 1632752100, 1848846884, 1114000722, 775704401, 3844163200,\n                469678943, 4133910816, 3435744844, 1661656089, 3919969806, 372912331, 3925680842,\n                1366571708, 2821510836, 649494, 724284323, 505472189, 2687312723, 2405046872,\n                3125301318, 3256049289, 774087973, 3981705603, 3325439184, 2954835675, 2725563058,\n                2515754404, 3477776973, 4269454691, 2449194279, 1547625513, 1728063507, 231201570,\n                4292877797, 3495163803, 4013580537, 1837665961, 1300013543, 1241432110, 3093642896,\n                1691481026, 3921752027, 1059474853, 3218109461, 4272199222, 3090405739, 784116813,\n                4280886718, 3547794686, 119045029, 214217180, 1172298704, 272007380, 4168588819,\n                1539710510, 4048478839, 3293824373, 1932114687, 2517831124, 502648680, 1599065216,\n                235634761, 2931327099, 1806135786, 2748758605, 4286102182, 2218543471, 4159247954,\n                2851704864, 959147626, 2366564152, 3019979868, 2655370718, 281510209, 931090423,\n                499413544, 64739670, 894424336, 1818208026, 2257234516, 2624162454, 3189431803,\n                1134320613, 3166537004, 2926565501, 2669059446, 497238445, 30233754, 2620265220,\n                3558625938, 352282231, 3147660599, 1340912220, 3276802486, 3012669529, 3553537679,\n                326416777, 4279833819, 348274989, 2055151357, 2126716616, 819698272, 1389794698,\n                2264090128, 204730947, 843480400, 3957036142, 1740808497, 3403300417, 493638729,\n                3397686538, 2997162679, 4039958112, 3129102367, 4099024232, 4121783672, 3272745379,\n                1139179399, 285642431, 648122033, 2734146014, 1523103819, 4033077595, 2558609201,\n                3747324433, 2458964514, 4132460622, 1043448320, 10736,\n            ],\n            &[\n                2854126571, 3810922285, 371837910, 2847540454, 486740183, 2160285633, 2017968719,\n                1221435102, 1141701073, 1526766552, 1231337987, 1813385239, 2734884018, 235620011,\n                3665183150, 1120279822, 2382922525, 3908597230, 2767187339, 4225970635, 2058878812,\n                1054451375, 3908013355, 4090049198, 353761630, 943442885, 2028279969, 2755908669,\n                3495701523, 2274876514, 7111411, 2322147314, 3166509422, 3631852760, 1999836871,\n                650648601, 2896603946, 4278326950, 2519734766, 2042259469, 2175932534, 3377156271,\n                2708233165, 1153846353, 569980209, 716406085, 1416372219, 2491866469, 1849390979,\n                1657511720, 527987900, 312131542, 1483115611, 3019246366, 1772076445, 2597632097,\n                1806628960, 602363143, 828919543, 4054351320, 745399979, 392681753, 729942081,\n                3783820494, 958343864, 1891389523, 1916371046, 3957352530, 1940850968, 2999627271,\n                2056442667, 3600581748, 739316794, 615343381, 2991048069, 963790214, 3579897498,\n                2727465507, 1291721350, 2257779716, 189799771, 249939605, 2313870626, 3298318286,\n                2695432027, 1104216368, 858091490, 3612066070, 3242257962, 2819622739, 3621623439,\n                1645360864, 1858386419, 3690046232, 1963002266, 3365019901, 709477199, 1869694999,\n                1333459016, 3929260115, 1804302107, 1548831440, 2447603949, 3613058855, 2294343811,\n                3061585375, 1234689982, 1110502912, 1267669326, 2897966429, 1238959344, 2388962700,\n                1545916965, 4015877004, 2291501123, 1151613625, 431826202, 2784246687, 1081585466,\n                861824085, 3830712001, 4199076025, 1169739676, 1721601770, 486252424, 2456992908,\n                2367988995, 853976555, 2362625785, 847070690, 3892469091, 189183763, 983145128,\n                604862255, 1284385769, 1440014575, 1449024264, 1124161398, 992775577, 896708354,\n                1499353865, 1733133868, 2463919313, 856157696, 3778499837, 3108165894, 3335953575,\n                2577002240, 486391747, 3793776140, 4178059147, 1421326491, 2877075680, 121756272,\n                2955126461, 1185519566, 439523848, 534575395, 1560554614, 3182072951, 3886491221,\n                3273785996, 1722350380, 1102349772, 3163492322, 855840633, 749300337, 4268787245,\n                1616840129, 3057312503, 3760176742, 3207150726, 491867592, 370828011, 1123930175,\n                3909514255, 607439111, 864050721, 3004872052, 1802788201, 1624858827, 2832354028,\n                72204982, 457231306, 3454382699, 2189149463, 3840204336, 1209241202, 1978336288,\n                4169032732, 2876009661, 1082634619, 2497263384, 1326174220, 1253911629, 3737995297,\n                3263043078, 645177131, 3799451502, 325159611, 1330703088, 441891512, 4125145352,\n                149253662, 186351587, 4080844290, 2196709175, 845328519, 1100994658, 1730443741,\n                697455139, 221172934, 284568041, 3633521112, 4012942302, 2503979252, 1982165755,\n                1603237111, 3062410273, 2172526016, 3932170374, 746842837, 2685299075, 2226087030,\n                2288686577, 3833519356, 1106715479, 803191120, 2945220717, 3462665442, 1851929745,\n                3220631793, 825749594, 3850318854, 1995848704, 372995746, 2365949838, 620492561,\n                1369591225, 223709365, 1954997080, 3882190656, 136576738, 2495749432, 3002183229,\n                4087193741, 799453426, 942624435, 1615021967, 2904816939, 3821110584, 3804731230,\n                539775187, 1076068431, 1596180969, 3090422137, 2013680976, 4160179801, 1501779020,\n                3485041009, 627578448, 1687656645, 1097144289, 967159869, 1069388948, 3185056534,\n                815670796, 358149589, 682430892, 1919067351, 1080492798, 1738690879, 3469244164,\n                3048277671, 676563295, 793928921, 778744353, 1648323757, 2221906903, 2287524694,\n                1039650177, 1679972277, 449929141, 1905719297, 3917418719, 2749202465, 2635810607,\n                2907978358, 1764745285, 4092093759, 2136036160, 3823420732, 3781081204, 789220560,\n                76055428, 1068573956, 3496138402, 707619794, 699429176, 1599250365, 1226916168,\n                2953556842, 3013778359, 445642445, 3359206573, 1634979966, 32169773, 3986006899,\n                2747561339, 2534736220, 62657613, 1511121562, 2122981684, 3246037727, 3781297188,\n                1174417153, 2326429527, 2030416725, 4239201915, 1267322727, 4213670773, 3561818989,\n                2314510277, 2980523839, 1790535762, 4031301214, 3864863880, 178369327, 518325210,\n                2973773473, 1492340216, 2880227942, 1144890024, 2409210141, 3051276713, 1507874226,\n                2982534148, 4129621437, 1186413065, 760037878, 152289721, 2233567098, 3431847497,\n                2459547367, 3925952526, 1236723769, 785269549, 3929478183, 2566922363, 2036461315,\n                2787863332, 2385369768, 1903832984, 2751226282, 2966793376, 4210685335, 110217992,\n                2334089437, 832643681, 3824460110, 2884348488, 3553526804, 1696587587, 3077903646,\n                3774351568, 118586818, 2535051277, 3044137612, 611368190, 2247957170, 4151739331,\n                3032079141, 2398348531, 301800229, 2489467427, 463881677, 286741354, 919821454,\n                2514396732, 1049973971, 2885185956, 4278356569, 1106751573, 2780358912, 3165013482,\n                682728744, 156457261, 966913152, 1795511616, 1102483004, 47768694, 774401181,\n                382571797, 3418933490, 1337271451, 2553642946, 1682481208, 186752586, 402086066,\n                1253357008, 636687570, 1174558316, 3075513694, 3581054104, 1520081698, 3462279363,\n                3127642491, 3337969953, 851993452, 3859511913, 3125432584, 3565365475, 3639315630,\n                1929579809, 1245576721, 3896701628, 3934477337, 4087201647, 3275038136, 1788711123,\n                3958067369, 4089205000, 231641077, 2231523824, 2619997727, 441912559, 4072770613,\n                4240978164, 2974598062, 2924678733, 2970538057, 2736142575, 1105201139, 970816157,\n                2369699954, 1887951773, 4171767668, 4285132008, 1776816709, 3770203858, 2382945,\n                2017961118, 2832376676, 2804837768, 3274902934, 3591733883, 3691479138, 52712933,\n                2612228989, 3628704902, 3513862898, 478216119, 2726352952, 804977216, 3390084015,\n                4081495820, 1671436017, 2848400264, 3656019845, 2136393241, 431834724, 3510727226,\n                3071482565, 410753183, 1657700546, 1058987404, 489895964, 1587210753, 4111636005,\n                2918121105, 803516926, 638869931, 2234185434, 1507756257, 3908703942, 810746259,\n                2117398521, 3273771795, 2327709962, 1345338774, 2380428267, 1886210982, 3272617401,\n                2424798876, 2485064558, 3441956046, 4282650102, 1189648611, 161669993, 2174805813,\n                46186229, 3870678520, 1725393849, 2725996937, 2285861609, 2855918656, 2085727938,\n                3005980273, 1091105108, 2274905128, 3124240963, 3402918292, 3948459386, 3730327554,\n                2624673727, 1462493475, 1911926536, 1172198609, 1531781228, 2875744790, 955061915,\n                3653212440, 1316441536, 1571847879, 117813941, 724461511, 106145092, 3007920163,\n                509355349, 2361882009, 3290661803, 3009193891, 2101167937, 3236175251, 2600604339,\n                2409592198, 267656105, 28902868, 3787222075, 3910267520, 518607069, 78112248,\n                1231828511, 2237810649, 2039587423, 3258311695, 244193578, 1901807321, 1888614436,\n                724431620, 1229615953, 3602175515, 107889915, 1499981622, 915728462, 3185158200,\n                3875556208, 1422223958, 74968146, 1782255156, 3690901362, 3148861984, 285887046,\n                456047577, 1877634221, 4119417329, 2674004542, 771859946, 3841364442, 2576022811,\n                2774717438, 3707475262, 598699796, 4086485722, 2071933255, 254807101, 2713526148,\n                4015941391, 590180295, 2462439133, 893362735, 2776258951, 670583777, 3998467192,\n                4252701293, 3144240767, 929429555, 3121145790, 2186463475, 595824244, 1196211096,\n                2796145353, 2313718767, 2327057115, 2600569013, 1375960388, 2419292403, 3991920167,\n                3660567838, 3488689798, 2047799775, 2345831879, 3333113070, 1392141953, 3356864686,\n                3683415162, 30718491, 2800440004, 305780227, 2420043106, 1237507888, 1479858831,\n                3600187970, 3379229271, 1429268544, 2752590068, 2152897287, 2762740595, 3499503442,\n                1412039428, 1580413636, 4255719498, 3321537024, 978632041, 2570103234, 2866926493,\n                714621483, 2791004236, 2495536081, 343144324, 378104110, 920987435, 3182143689,\n                1200960749, 1263985718, 1422494241, 235668853, 1459938722, 2182331117, 1534070260,\n                1037022387, 2359040698, 277760467, 231493066, 4156892106, 3785706492, 1644416142,\n                279187889, 4046443858, 3644810161, 2159180570, 313719967, 4093063716, 1479097649,\n                3123510773, 2411818036, 1854765137, 6659591,\n            ],\n            &[\n                3522409411, 692426266, 4252687070, 3221722249, 2259982318, 1572230342, 2447667874,\n                582309214, 3464041890, 833370466, 2502005176, 866026260, 3434778270, 832555619,\n                577419378, 355707174, 2758409995, 539088491, 4165515733, 3525341005, 70966281,\n                4112863463, 18093477, 996208336, 2996281883, 243025039, 1724269073, 3456564031,\n                2183707540, 2623790820, 4068996778, 2003125751, 3979669707, 2092158727, 1319454084,\n                233637378, 3444775191, 2047163977, 1305370049, 4052656807, 3362300485, 2153220367,\n                3451943873, 2659951731, 310435720, 240435490, 1283149803, 3779214360, 1819576764,\n                3267732950, 2661843307, 2263394946, 1901303373, 1858196903, 798526878, 2800696617,\n                3224809646, 982174624, 559354368, 2472934158, 3806202203, 2295203592, 2945471200,\n                2663904303, 1357384963, 1650942869, 796482443, 2766778986, 1604012049, 1236473541,\n                1483190475, 1132242907, 3470424624, 3256605783, 1372433796, 2572130477, 1005422111,\n                3417699569, 1998572418, 2781008338, 131034958, 2366709018, 2158499536, 4239137506,\n                2147101299, 3836689278, 1767372944, 198678316, 3099405709, 1642856762, 1359859087,\n                1016829435, 1775642165, 3166947118, 1370994118, 3565882683, 2697435592, 2988614686,\n                700091191, 2139458915, 293125924, 1677498485, 324444909, 1956567030, 1647523339,\n                1288409259, 3433527205, 3488399404, 2692884632, 2629401949, 1865373164, 260321166,\n                2452146960, 1510030261, 3309904643, 1821006233, 4092693137, 360274707, 430743857,\n                1022845846, 768344651, 870695548, 4244607652, 2799849346, 1897317934, 907494911,\n                3494316912, 3319466364, 3831408243, 379446458, 1637847888, 761682818, 2305788385,\n                488150578, 2591607856, 3487487084, 3482200336, 3409152717, 4191475557, 2349556031,\n                1024188774, 2357767930, 3538056694, 1299385038, 863893778, 3197830576, 3620847361,\n                3734458112, 2102579497, 2299090284, 1776637937, 923893333, 3538505849, 1525313260,\n                1095090443, 1425332433, 4270279191, 3899256887, 2234522273, 3938133714, 1144096051,\n                2771405273, 4039853365, 2164168861, 2220073157, 3305905250, 3547017695, 3028576138,\n                3211205289, 2969717301, 1297821450, 3898348269, 536907576, 3526521253, 2984151429,\n                325158808, 3634226110, 254237584, 1647629802, 1213935217, 1963529116, 2864575925,\n                248508991, 1681221168, 2138605160, 3011363057, 1667991051, 2164842621, 1221146487,\n                1896090790, 3584296136, 1197643020, 520819114, 2845411935, 2882123631, 86651362,\n                2840429882, 305685636, 812868855, 4270240044, 2258043791, 3681398458, 2125157433,\n                3400174505, 52122812, 3977731352, 2960080531, 1752547412, 1789316668, 2086783129,\n                2065283260, 474350220, 1392633188, 2642559453, 2623416931, 1213699470, 431976342,\n                4191881681, 3989646787, 2555136586, 331973965, 3045351568, 1974527188, 1721946949,\n                2420304698, 3018807687, 3912284737, 2323363082, 4175374785, 3073974039, 2019051853,\n                3254436577, 4145054805, 2909559648, 1674676821, 618050625, 1701855694, 3844330576,\n                2368970459, 1142540548, 19839276, 2809741072, 1358679745, 1616340555, 1321571980,\n                4269787203, 2139498091, 1516379787, 4232094406, 1813501895, 3499360571, 108430199,\n                2969637702, 953766617, 746993329, 1798819970, 3008070664, 29506047, 3755689428,\n                1731853786, 2150972169, 3970252289, 1707195359, 150651832, 4272796881, 3214714265,\n                1289674369, 3832009122, 1863256348, 4208461628, 2928731478, 1909075615, 206649607,\n                3721679533, 1149140532, 2135144822, 2553592226, 390359104, 2664151758, 4207827335,\n                791092034, 1418111790, 3869230526, 1229201988, 3450535823, 3141749817, 4170511491,\n                1808234944, 2870573701, 1933266254, 1944630510, 541620618, 2484636520, 3899287047,\n                837911245, 318074222, 778344163, 332143424, 3148535492, 3257541807, 2584276077,\n                3752887648, 1145669314, 2724633195, 168627417, 2600193851, 2188347881, 315294329,\n                1951166123, 3631461291, 2699587438, 3705790078, 97682065, 3212849906, 1644271056,\n                2402937425, 1495234346, 2546518537, 3699134635, 1566766581, 4076379355, 1369185061,\n                1927352427, 3453847057, 2121073778, 3846264460, 3345029574, 990382258, 1093055554,\n                4020639133, 2106873871, 3558358079, 3623019498, 1126463853, 4000595941, 2326522050,\n                2496119497, 1177412487, 3737033586, 1970672443, 4124458184, 2182522865, 1950531515,\n                2217610303, 1875359075, 887126337, 4187532100, 3050435188, 1382650461, 3459929976,\n                1249535657, 4069389042, 3437440772, 2924920125, 1065376385, 3759927287, 1835638851,\n                1549066656, 2607123205, 4287679131, 1933130208, 1861085748, 3531803620, 2455707011,\n                733561985, 2945180228, 3707942192, 3580180904, 3375170391, 1690619419, 3658664211,\n                3096941018, 1587283463, 3941503860, 3163621426, 526869998, 1316208739, 3776069458,\n                3759213667, 3343111698, 3552349239, 1698745515, 529667942, 4250086784, 2328783424,\n                1942833307, 2532170555, 1407840798, 3929450154, 689766216, 603422970, 2945072222,\n                3148401239, 2154639678, 2439164182, 1799459040, 1555139265, 4024153015, 3988650657,\n                3734125279, 1894805848, 2147080077, 1860482341, 3275095036, 3629120956, 1637523200,\n                2484855322, 1006412, 650874934, 3277326964, 1186385437, 3787893694, 3384961602,\n                31727330, 1019763729, 4132753588, 3078074634, 1730195820, 1742210061, 3980710682,\n                1476247656, 1537422777, 4040062712, 1425312769, 1848918319, 4087493673, 2365974768,\n                1886134839, 3875551706, 1685012340, 41954153, 3951521761, 2564745248, 2519620712,\n                3959816490, 2560867112, 344633036, 3691137569, 1256857877, 2291066279, 2054203203,\n                1386019941, 4272539404, 3363945588, 2226687874, 3871655974, 1494082150, 1112096467,\n                2284368903, 975044169, 523309601, 2133056593, 3313692829, 904329125, 3666815061,\n                222106749, 1616520314, 2393855972, 3705259257, 860827649, 37212776, 2059317736,\n                3079163663, 932474881, 3394576876, 1706615928, 1819714696, 3820968510, 536368964,\n                2910847848, 2135453698, 1350335129, 300212611, 2633354050, 153183294, 1928772583,\n                1021126237, 573543692, 3567442837, 1409698831, 3111277745, 581910616, 1979561780,\n                396494706, 2463303563, 3166095864, 3105677740, 2400257412, 1913519467, 2416376547,\n                1957034146, 556585253, 4210367449, 2539364372, 572061442, 4289883802, 2215328126,\n                294061050, 2040995404, 2952991336, 1040316946, 720150954, 2348132965, 3885697361,\n                424223697, 3805769810, 554628633, 1894997829, 3738308930, 2890140217, 16184469,\n                2112778335, 3492087017, 1528198629, 3156309847, 1672825355, 2320695680, 1770693922,\n                4158833400, 111430926, 2523417395, 2654875625, 3108094520, 2689255279, 2038117485,\n                2616876984, 2352131353, 3150209189, 3217446658, 836678783, 2785826980, 3252708922,\n                964549716, 1140915598, 3033957610, 2356630981, 3514265925, 1278364234, 1083297932,\n                4023829085, 3614439116, 680554138, 3997456824, 2252713625, 2055817074, 1234522698,\n                3102015221, 3404334905, 112882014, 2007560807, 1487607631, 3501350871, 1111627245,\n                980132418, 3206101949, 4130779405, 2111302372, 1968609288, 4204601547, 2874374202,\n                2853878438, 2857752228, 274256864, 1817723765, 1905422451, 3363188610, 3333488106,\n                463317661, 2351076159, 1477837401, 1418561892, 1866844722, 303232671, 140367367,\n                3061206542, 1503639539, 589823218, 1918827275, 2600297211, 4277833048, 2393528802,\n                1661440636, 2339324312, 1263101253, 2873025067, 3441016568, 194170142, 2576615806,\n                233994937, 2966168464, 3087711309, 1530686231, 2308302598, 3393973525, 2467525628,\n                469950892, 4103299607, 1794837893, 1549361853, 3580558511, 12661541, 722609243,\n                965007319, 449849784, 3829064245, 3965630564, 3112166475, 3424263194, 195830868,\n                3230014161, 201295863, 1892682525, 2243429350, 678386870, 3696010396, 367065208,\n                3856657124, 3741113040, 3014123703, 739968874, 413,\n            ],\n        );\n        // - xs_len <= s in limbs_gcd_subdivide_step\n        // - s != 0 second time in limbs_gcd_subdivide_step\n        // - new_n != 0 second time\n        test(\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294966784, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294901759,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967291, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 2047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 262144,\n            ],\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294966784, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294901759,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4293918719, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 536870911, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 16,\n            ],\n            &[\n                4294967233, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 32255, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4128768, 0,\n            ],\n        );\n        // - n <= s + 2 in limbs_half_gcd\n        test(\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294959104, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294950911, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 134217727,\n            ],\n            &[\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 4294965248, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 33554431,\n            ],\n            &[\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 16383,\n            ],\n        );\n        // - ys_len == 0 second time in limbs_gcd_subdivide_step\n        test(\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                4294966272, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967293, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 2047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967232, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 65535,\n            ],\n            &[\n                1, 0, 0, 0, 0, 0, 4294967232, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967293,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 127, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967232, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4095,\n            ],\n            &[\n                4294967293, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 192,\n            ],\n        );\n        // - n == 0 third time in limbs_half_gcd\n        test(\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 4160749568, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4293918719, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967279, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 2147483647, 0, 0, 0, 0, 0, 0, 0, 0,\n                4294967232, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16777216, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67108864,\n            ],\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                4294967040, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967279, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967231, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4095, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                16384,\n            ],\n            &[\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64,\n            ],\n        );\n        // - xs[new_n - 1] == 0 && ys[new_n - 1] == 0 in limbs_half_gcd_matrix_apply\n        test(\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 4294966784, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294966783,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 262143,\n            ],\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                4294705152, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294966783, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 134217727,\n            ],\n            &[\n                4294966785, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n                4294967295, 4294967295, 4294967295, 4294967295, 261631,\n            ],\n        );\n        // - s + 1 == n || ... in limbs_half_gcd_approx\n        // - extra_bits == 0 second time in limbs_half_gcd_approx\n        // - n != 2 in limbs_half_gcd_approx\n        test(\n            &[\n                2004596728, 1848887139, 3588545405, 3004392306, 853879983, 1360524256, 1385705184,\n                3321803032, 2791968922, 3892438424, 1781322303, 3493068948, 2015405293, 4074669885,\n                2900269078, 3823683574, 89252947, 4038834041, 3432017782, 3193194315, 2816970936,\n                1259222869, 792476452, 2969025189, 2789393972, 3016742665, 757499223, 11545282,\n                3423520861, 3616113932, 3465820395, 1979030055, 2104068595, 3714106365, 1466660150,\n                1712602216, 2630941262, 610797776, 4074395197, 3701243311, 3555176782, 562321145,\n                3934144323, 2134957404, 1613994064, 2254770945, 844351745, 803798570, 2703265082,\n                3640524712, 3907579617, 1740863700, 3961951685, 2756477900, 1800563792, 4006854388,\n                1927911032, 4232194641, 2895575388, 1248300427, 324453294, 865512796, 1640531918,\n                3337883058, 4127691867, 1251838156, 3755093876, 2638444353, 2277825898, 1079070681,\n                2347582744, 4086131979, 1292025334, 1141464465, 2190524620, 3815677488, 3218393458,\n                1168612800, 544017320, 2324397425, 3767722505, 2551036255, 749770338, 3505489601,\n                3557482154, 3813020533, 446277331, 443847294, 4085812779, 842889652, 494048275,\n                2419464445, 1214470431, 1228587913, 4005029074, 1143269930, 2427231859, 2933315483,\n                2923633652, 1889084749, 2411174117, 2305971895, 2959154784, 2927615709, 3241695251,\n                682460868, 653924800, 3814161525, 2508305181, 1339320678, 3455333037, 4176128090,\n                2539010236, 2893402188, 1241794103, 3954344331, 4233454015, 3681840959, 1878852448,\n                4262815930, 166349449, 1235728789, 336877896, 1367168363, 2965431878, 3447952070,\n                1714138221, 1049768737, 1231199029, 2910381689, 307859398, 899270841, 1606345579,\n                1234775041, 189535788, 1984838421, 2087074239, 2867133699, 4209429577, 1098566748,\n                83344395, 1521074408, 1698236631, 1907863376, 1923053177, 3422780594, 787031035,\n                3522524050, 2028229229, 3031046586, 2851262763, 2888070447, 2834519912, 2885252087,\n                177502086, 3275331517, 2442998599, 470146074, 499318359, 4217123754, 3089228461,\n                1039758505, 1609847346, 1217631005, 3141899940, 1645363140, 4180648912, 1348926971,\n                2872045994, 2516596487, 70751717, 3755810719, 2844208311, 860932668, 3025234253,\n                4228898226, 1667541479, 3791359976, 430657658, 2775582388, 3472378627, 2507534646,\n                292448923, 166266046, 3517783361, 2602204453, 3143313511, 1907742516, 2093632780,\n                3391286313, 2706298791, 1700209801, 646869730, 2296768972, 3445646575, 4251992105,\n                2910039672, 2099034896, 82722938, 2958905749, 1059663844, 2996112985, 3875276435,\n                3838463324, 3607053228, 1649011648, 1013811619, 526117160, 1012433449, 885794551,\n                1704687270, 869082082, 2736112342, 1882492056, 2952317080, 4088973917, 3059951449,\n                548119577, 134193431, 4269903209, 719387298, 3039694582, 3312858765, 131546364,\n                3768977754, 1008091338, 736625, 100297344, 2441670905, 2960124427, 4187608134,\n                1281665081, 347304892, 425777148, 3815705055, 2002210752, 3158348324, 3370719815,\n                235350445, 3073024597, 2841606549, 3677106047, 627054432, 1463475055, 2306894862,\n                2004510531, 1215369345, 3796695068, 1705709666, 1910826455, 3380653290, 1669034431,\n                1326881073, 2691232035, 1345394646, 2505725768, 1643208418, 2278435319, 3975379348,\n                936580608, 3558291381, 1578739386, 3360990083, 1367648693, 2174608196, 3784418662,\n                4096285583, 1125126761, 1702879279, 2373900154, 2794269811, 892965648, 3431450476,\n                1598114090, 518942123, 3942271859, 163233596, 3635705911, 2802569655, 3902026503,\n                4172233752, 1343615033, 1443283240, 3214860685, 1830135384, 324092050, 3595506427,\n                4006369796, 3094883604, 1337811945, 1590934260, 1405064877, 1629961311, 3917976233,\n                2307585818, 1966934539, 1130062423, 1870989582, 1624138122, 363138090, 2804418650,\n                2247302844, 3205057981, 1897671604, 1838684004, 1004563089, 3421753356, 558428644,\n                1914315130, 3772633601, 2526221813, 2274129897, 877924724, 3120882592, 3985407655,\n                3151825377, 3497165637, 4225852164, 3537575972, 1378449691, 3428657854, 917817375,\n                527806996, 947800429, 136564017, 2885607105, 73317183, 265413671, 113274788,\n                3223321193, 210252458, 2455534679, 730413621, 3248846851, 904264433, 3785997086,\n                3749983772, 3451619934, 1253036056, 814792744, 1441772826, 2902751149, 1233888488,\n                3433013081, 1418759256, 924600323, 3080242546, 1505445983, 983904026, 3815022296,\n                2057785068, 3901544799, 1289567020, 3045444045, 3571691925, 2469383112, 2902682391,\n                2637073877, 2288505094, 1098867737, 941340356, 1780640923, 488687629, 3661273470,\n                2018461290, 4073895479, 4219286255, 1226075625, 1286996168, 2455678338, 544007097,\n                4088835826, 555104214, 2207823194, 3598396023, 742075093, 1931088791, 3231680922,\n                2207259058, 1054824417, 2809061923, 3659187103, 667505786, 1038625820, 2546526131,\n                100718813, 3971349256, 2689176731, 867921223, 216238397, 2926583018, 2524616945,\n                3105675814, 1929564974, 84832194, 2898985519, 1538371806, 2304769426, 3331366264,\n                3992871197, 2524313399, 2880073024, 214374078, 3087979230, 3763462972, 1492033090,\n                2745547667, 1590203017, 2220884647, 1043643074, 270180523, 3619501678, 913269760,\n                432169997, 1560222504, 3606034447, 370004374, 2242741806, 161846260, 1611153441,\n                2788329497, 221705084, 1562296329, 2602384573, 2489408324, 26752274, 1012421860,\n                2870608198, 3339203935, 461343907, 153553549, 769161583, 33015466, 185839789,\n                1238122110, 1955418650, 4034473489, 258622964, 3142360380, 1154801666, 1938695011,\n                3543768243, 3169796551, 918987546, 1837828018, 3174207376, 2490048788, 1968348654,\n                981031537, 2019290428, 2481414836, 4075697852, 2177287359, 2394194295, 2918955032,\n                3990490756, 2721846619, 4831810, 3676889722, 77410574, 89746890, 984555749,\n                1700971854, 1157576335, 2282651337, 2161988414, 200058435, 3928266699, 930309134,\n                1501872778, 2708771958, 700076188, 406467641, 3056590431, 3360765111, 4031233736,\n                3421740854, 977030487, 99478473, 1098197595, 344694600, 579238328, 3538505442,\n                2636219428, 2819718878, 1017360877, 4122930426, 1031875816, 893936384, 2187396525,\n                2651789727, 1406131552, 2442039378, 3802582287, 2558943236, 1638234317, 1996245621,\n                3369039129, 3228698584, 2117350450, 790103060, 1066928337, 2234731599, 2618583709,\n                2555385033, 1780760113, 3641524458, 4150990164, 903504072, 4053936972, 3149614166,\n                2337971588, 890882883, 356711938, 2263542728, 1364381326, 3810269234, 176857342,\n                3484849272, 545650307, 4095119697, 1070867675, 44185550, 3245052385, 512603627,\n                3259006013, 1823968935, 820533825, 1968169710, 2512600375, 3565879518, 1297163908,\n                49040429, 3182956160, 508986908, 410825498, 3306313947, 993237936, 167382405,\n                3237055914, 1596868278, 149136283, 259065124, 2117102457, 2524094604, 4026729163,\n                1740524001, 1910248499, 3900973553, 963142543, 1135340442, 1969527786, 4217058880,\n                785182291, 4104638176, 2329275390, 3800005728, 3604262878, 2318748672, 2241924274,\n                4146333651, 4280666223, 2529283140, 4007762691, 4137420426, 3087334197, 1001749081,\n                618981599, 2290019564, 1030626743, 2353440201, 3491060669, 3215041527, 2133818684,\n                733955838, 1074731940, 1013602989, 1745515239, 3242057247, 3498788174, 755386347,\n                1719467948, 329147897, 2110573052, 2651634797, 2329469633, 1756488056, 86346262,\n                3905621145, 2947376796, 3505737560, 1900253843, 2879666387, 2157905472, 1776782776,\n                199667884, 2726782520, 373441468, 1768340110, 2462560802, 507615514, 1956022588,\n                2384919250, 3412435481, 3320720595, 1941716387, 2023426521, 920190565, 3248821718,\n                2537144431, 2247676695, 2897967965, 3195719172, 895846478, 1897877802, 2598950252,\n                3385294109, 88060678, 1813045139, 1710194386, 534922353, 4115328300, 1579427575,\n                489224725, 3942695965, 336077582, 1683601440, 3996082755, 4004864353, 3956008235,\n                3160734247, 220270324, 2211225079, 1810415176, 2384394389, 3863744894, 3644215752,\n                1441189974, 3953466009, 49244730, 3292932716, 982515392, 1412561304, 2892516725,\n                2889338602, 2133629116, 333644531, 586020549, 3757651544, 3094771642, 3962017540,\n                1922803563, 2852357730, 3982002373, 4184765592, 1490335806, 644006294, 3503622441,\n                191971406, 1321085451, 2933347886, 2298585985, 3942234867, 2711863789, 4287811909,\n                1869646329, 4193678178, 2300694512, 1672898480, 686525422, 29702670, 2048484513,\n                3800848401, 1016390476, 2542462976, 1630627170, 2566172213, 3799057710, 826467738,\n                2081397119, 3825871484, 1720343261, 2134275403, 582093436, 840829215, 3070534680,\n                2452108732, 3836992562, 3614708040, 642988748, 3799027792, 4279250555, 2415353135,\n                1431887958, 2718502020, 1396816819, 1619130585, 4148081938, 1571085815, 967105049,\n                1826809732, 1669740739, 1082141732, 1397004647, 778435201, 2046386989, 104029467,\n                2259777826, 364934737, 3269047887, 2763055117, 230291892, 451391998, 1891814456,\n                831038728, 2964787176, 3635108912, 1922422114, 3925407285, 2321391206, 2465927715,\n                4166210675, 1197190708, 2294797824, 3526000914, 2502435952, 3203138648, 3372900543,\n                733841109, 3114196707, 2959722855, 3974072908, 125712163, 3949935156, 1192064193,\n                1085374669, 3982672572, 845787141, 2041667785, 1091167459, 4191929987, 1653040596,\n                488154413, 960754299, 1195687062, 1016099064, 3052206013, 1445590992, 2800180480,\n                2391011353, 2595121989, 865889910, 3530257661, 2435488454, 2218519781, 3043715764,\n                719268352, 4118610915, 2644321404, 2688437598, 3635531668, 1233398325, 421024892,\n                777080283, 364599954, 3262345441, 1278614086, 1903481893, 1108104645, 3477418707,\n                2459845146, 2161754027, 3572822544, 3213552665, 667392374, 3742233712, 1344617923,\n                3673776960, 3333792099, 4171297121, 2361470285, 2456722922, 294864113, 184980340,\n                4022019397, 1074091825, 1871736332, 874717959, 3297537109, 2857811966, 2634096492,\n                3743762943, 1543744992, 3070296783, 1414890392, 3534170596, 2874392428, 3120304495,\n                1883738483, 1248660253, 867059402, 1991084538, 2294883679, 2004356063, 920311728,\n                2402442236, 3400179891, 4246588249, 1364011692, 3510199169, 637783028, 3953751884,\n                3539712763, 1197923989, 3315532567, 1772695848, 851905130, 119859671, 2150435159,\n                709509942, 559611034, 2881395845, 2070876910, 575568326, 1904348566, 3178937360,\n                4124642603, 2770017354, 462709647, 3534605840, 1958609374, 4276935967, 377299139,\n                4184852657, 2339718928, 3948556371, 3884870239, 847308351, 1567877006, 942676575,\n                3013407713, 1391345145, 1561541328, 2032670783, 2115922540, 2840947915, 1424667973,\n                2625051425, 142557574, 3608928348, 2857192866, 1885061732, 1032209703, 1670027307,\n                619942102, 577354863, 1991193473, 4106125554, 3897353387, 731765970, 2111758919,\n                2952189172, 1128764158, 4294956501, 1552565742, 150742947, 1645656939, 2396412695,\n                1598935993, 3811058692, 4282926397, 2028513885, 3417133207, 1960806103, 2987468245,\n                1261155071, 1955858897, 2337563115, 880430719, 3940851795, 2851862439, 2837360725,\n                998053826, 1459954608, 859053755, 1064753371, 2745438489, 3442260013, 2618174,\n                3064510597, 1526197768, 1172088455, 368916865, 4081414092, 872579574, 2606125510,\n                2393005057, 3895670156, 2773169580, 2784687800, 2713793780, 824327507, 1882474218,\n                4007720140, 701440179, 2854102433, 2485031446, 69057080, 1788242193, 717689363,\n                3404715444, 2079426393, 2150736275, 2447994641, 2919217268, 3473535129, 3831746162,\n                73654495, 2724500951,\n            ],\n            &[\n                2048467029, 459202127, 4051209999, 2641158559, 2529283231, 785114584, 3478830982,\n                682417094, 4137477036, 1994886259, 3849756551, 1850485567, 1510562924, 3626191361,\n                235960481, 980403409, 1789076459, 723101310, 855767948, 2804845518, 455915126,\n                3615072101, 3090232230, 466533522, 1169083525, 1158162624, 1858763072, 3595675614,\n                1661517062, 868777641, 871705130, 2861391047, 500497205, 2878901309, 1180001451,\n                686942037, 1956533284, 1920395594, 463032751, 1775551241, 2962069853, 1379946573,\n                1204600053, 3490263166, 3319964396, 297358647, 3127096944, 2886152999, 54379252,\n                3229449581, 1810608641, 3761727243, 374040322, 1887571393, 3146210360, 3708571160,\n                2205846452, 1001286939, 4203438216, 1231239932, 1865353368, 3994983472, 1326013992,\n                1568675894, 2481470254, 3886943594, 2173153009, 2709989031, 2174267461, 646584830,\n                3616102992, 4053133949, 481146194, 650153841, 2339337832, 2740187083, 225432613,\n                589865866, 843055701, 3020975970, 265007788, 1116775520, 2919330007, 3346158850,\n                3487640422, 1169247910, 997606069, 4010912587, 578436020, 4290033930, 3633599003,\n                2580529737, 162726999, 3743750914, 1981881618, 391172274, 3576970038, 3723023159,\n                3307886769, 3395118745, 575247113, 415887104, 1534676348, 2823996659, 4269453883,\n                760173732, 2138038336, 1086521291, 3199196489, 781423556, 1357123249, 4195648284,\n                3759296877, 2958948707, 3878993388, 3483121017, 2443771071, 52664592, 4239525630,\n                804231160, 1853250793, 3941273196, 3701311485, 2618716701, 56163857, 352626830,\n                3422477586, 3132969079, 3117007699, 181228357, 1045692359, 2223063843, 2343808063,\n                3122019574, 1709080652, 1254416114, 2121822259, 2976997459, 1780344599, 272725612,\n                3902688101, 2445075321, 3015383251, 2720256116, 1965686532, 3674920947, 2017493119,\n                2443555429, 3245745772, 4284800850, 618003105, 2592784982, 3140704668, 1643367542,\n                4252514361, 3843724900, 217510595, 3357765030, 3943128900, 3880661463, 369505618,\n                4186357727, 3349936627, 1429436215, 3729602835, 3738804567, 1753791419, 405876993,\n                2800106006, 3445400414, 2334940713, 365540818, 2000813054, 3402754389, 533916330,\n                387189415, 2847853159, 66632878, 1077148, 1396928998, 4089775018, 1213790544,\n                1059352194, 2514176069, 4257435125, 1261407550, 3530893728, 2451914750, 3905023603,\n                3254919488, 2751582838, 2008398588, 3449851963, 1812431992, 3571267520, 4290833338,\n                2474346395, 3378814420, 3351611512, 1303922942, 3283346580, 1489524774, 1395585068,\n                91861671, 2943769869, 3412508982, 2507344244, 2586024774, 660828217, 522672644,\n                2554574189, 4093332175, 1125997685, 3592656249, 1036705155, 2798764932, 3441576709,\n                392339390, 3489310669, 2596866038, 1947787118, 3696312887, 226298054, 472935459,\n                505119706, 3783498850, 867650894, 1072853134, 1072568479, 248365064, 3418187906,\n                1331699784, 3000650397, 1715193485, 3810874498, 66785355, 3344423276, 1996144563,\n                2793928046, 2180574544, 3767096859, 1540549268, 2389926167, 4274062787, 4121401190,\n                442584702, 2431090696, 3507775591, 710194452, 1159458607, 2416059535, 1642122860,\n                3823480937, 2535544964, 668845548, 1661633586, 2857928640, 2314741510, 377317229,\n                2483955636, 2957445644, 3934139513, 238200907, 2969751595, 4212529507, 2281068873,\n                1301743382, 1952773150, 1192593223, 3892828784, 4037269943, 1148821772, 391839522,\n                3504559806, 4173379790, 3085121003, 1474792696, 628152284, 2698025247, 4076939937,\n                2416300665, 2652295225, 365441928, 670206063, 1553108013, 1932716485, 1558658987,\n                368881025, 2692123237, 2519631847, 3865945719, 963612609, 2001573437, 161034038,\n                1883789309, 2496653544, 1909132409, 3269239063, 510666825, 2562655909, 3241797641,\n                1506218500, 2991308436, 944858691, 2394342093, 3501775324, 3134551643, 1655397291,\n                1372472782, 1117006576, 3017788232, 568720212, 1600706831, 1262117840, 549706387,\n                2176848659, 1793986036, 3712714767, 75684922, 3737373740, 630177306, 343378978,\n                2300438472, 1144716485, 859910517, 846443936, 3312516505, 3320108534, 1661760387,\n                1112699815, 1474296780, 1964776416, 724080825, 3106608638, 1122986017, 2775133042,\n                988101895, 116278673, 4169511163, 1001735315, 487463586, 1705207220, 1191915788,\n                4098138272, 2818005531, 3023730900, 2655878164, 3026173793, 1966505099, 374525789,\n                1651006603, 3071722751, 1288077227, 2811531267, 3902509872, 356900923, 2715149970,\n                2252856041, 1766699937, 430591715, 3645482691, 4287397379, 331671751, 2921221743,\n                4164993604, 2710905723, 3151975289, 2670586646, 3232311359, 1487120535, 104450214,\n                2011996119, 1378669544, 260533527, 2931634918, 2932587506, 551998172, 2217304186,\n                3692803012, 1214595277, 2200712189, 31026051, 1314881730, 4252874943, 3922112067,\n                841640375, 2518926569, 4060391300, 4091059600, 829994243, 473526157, 2969598738,\n                1569819164, 3269273437, 1687660622, 769790079, 2939858479, 2314982026, 95679934,\n                2650280721, 1284506574, 2095382569, 3629187443, 2367705831, 2672087363, 659550851,\n                11251546, 2844951430, 4117036159, 3658960043, 3566145978, 2512143790, 2139258524,\n                86934552, 267324838, 2221780235, 710419209, 756024368, 323223865, 3778949258,\n                3816289645, 2219776149, 388834355, 1068024113, 1222179129, 580874345, 1198868104,\n                1817835984, 4094192509, 3826892475, 52655050, 287659039, 1120108646, 2058392690,\n                2104203826, 3037610895, 1029726175, 4061743149, 366112992, 346791754, 3821995524,\n                536509597, 2325629474, 2066675899, 136719370, 1695618401, 4127537516, 2452460370,\n                341169206, 3738496386, 2767987524, 3190043068, 3016991314, 1985040888, 2078594914,\n                2139671587, 3776602980, 2341476692, 2570282486, 930489583, 277160411, 1626294789,\n                3691686855, 4262789355, 1212444490, 2072677275, 3457253017, 2170703287, 666683948,\n                3333015377, 504864707, 487969583, 1288636011, 1567777164, 1530159893, 3815252539,\n                2666881166, 3965829243, 1041099897, 656342032, 1028191164, 3915206067, 3690757289,\n                1762777065, 3803846698, 1266228114, 4076868833, 2399530576, 195016210, 1445885502,\n                1995001751, 3704589774, 3772778297, 1868741945, 256483377, 467868342, 1640547407,\n                225595970, 1128094955, 14460666, 4066078010, 1531108057, 2276851512, 3961921308,\n                1169342968, 374165010, 2374552173, 1981313800, 2852786477, 4281055282, 1639781930,\n                1322826308, 3962989569, 2251429162, 3816598409, 4202374414, 4064929266, 4168284369,\n                213598332, 1878654815, 4012592889, 2331662084, 1902718261, 2647610456, 352521621,\n                220018838, 1635198976, 870981338, 1528262232, 4278709709, 2883394367, 3811471744,\n                101869306, 1737965113, 5642069, 4097501724, 1259821990, 3670562669, 1974253307,\n                3684053909, 2405311762, 2106561791, 3003266622, 3144376081, 3347409339, 3029518983,\n                1386943455, 1931470855, 2440160434, 3815143890, 1950218632, 2764905171, 2625123447,\n                1837241813, 2329259261, 481118439, 3173225256, 2962727463, 1945440488, 3710596738,\n                4277813522, 859909239, 3649480114, 3527231066, 1319170120, 2057720939, 1491180621,\n                453126850, 1871773559, 1890800972, 3318027331, 178171345, 898881946, 585192043,\n                2316224458, 320531880, 3894139506, 887621194, 1336067791, 3934764232, 2500940598,\n                753297159, 2270381915, 617165818, 3189476410, 1156481495, 2662137263, 2316205098,\n                2461186746, 1238818742, 2671302457, 3259197258, 2457707232, 2069915454, 45049564,\n                4167698335, 1201886883, 582951017, 231483990, 126335446, 3076808505, 912812759,\n                2501874082, 540273866, 547753220, 1170424177, 3189829517, 708808880, 3129622972,\n                2002579360, 1870645386, 390169448, 2894707900, 3908460579, 2350579381, 1331709602,\n                443459340, 3712574777, 1224504425, 206884931, 2378720574, 1020032309, 1560294846,\n                3882569460, 1581034183, 2420521192, 3533022079, 1115021897, 629573578, 3657301365,\n                277294527, 553080215, 3028363420, 1291561052, 1328469432, 3338312082, 1338200129,\n                1766236727, 3416356554, 2978891312, 3082654857, 606657334, 1276316260, 1068554434,\n                578254253, 1605030828, 1138302318, 1303706914, 979241233, 2741167388, 4202417433,\n                1219394772, 2054300069, 652415613, 4270613519, 2111897808, 96742901, 4165401801,\n                3285972425, 510249183, 3584775636, 2783564547, 1562245500, 2730496534, 663355262,\n                3500910819, 722790975, 1919819672, 2086954706, 253795458, 2005733999, 2970779153,\n                1467732358, 3926882554, 183736355, 2926165427, 3506297134, 1277594353, 2214151876,\n                4114889724, 1981267378, 1672821314, 1973092046, 1816211223, 3995013321, 2372975102,\n                960109327, 515631621, 1141049977, 2556287867, 1599407251, 1420644713, 2146155618,\n                483793231, 3212064205, 1747734295, 3877264223, 2699801323, 1227467313, 3524136023,\n                3700565681, 2022634486, 100193147, 976346175, 2047559949, 178497547, 659438932,\n                693783143, 1025344114, 3296189331, 4234938364, 3519391869, 741867813, 1210413520,\n                1131945841, 3748089817, 611872932, 502118182, 1727700656, 207851418, 2667971549,\n                122428996, 1451993464, 2823431360, 1457011744, 3016921746, 3133660679, 199979290,\n                2570157746, 3883523853, 2905936686, 4032889764, 1341310325, 3955219349, 3754604265,\n                2731331914, 3325586999, 450131610, 3586820947, 759246962, 3907198611, 524872115,\n                2765413843, 2883771692, 147272373, 2712175410, 1690171466, 3722496509, 2121634784,\n                1639601660, 231013188, 1337728573, 1947365408, 1956500101, 251574525, 858236174,\n                1259381993, 36329478, 1435388981, 285326643, 3274056498, 369851, 2209662002,\n                3443099831, 2062553205, 1736753981, 3579525503, 3084085035, 406796802, 1551408425,\n                4209938819, 3342796945, 653033552, 1255972233, 272582735, 516452148, 2007012629,\n                892881275, 2969869353, 3262627654, 822918090, 2317982905, 1913126099, 3381804467,\n                3143222829, 798410293, 1697756544, 4038741424, 3291804708, 78220767, 1148496187,\n                1458398142, 4048000884, 4101585984, 3148543887, 244432076, 882179301, 720217242,\n                2211718549, 531560575, 2338154942, 3742711210, 3961239456, 1640123469, 790017482,\n                748840499, 1853629994, 3073906634, 2530890447, 2206461015, 4030211025, 606026839,\n                4148432480, 3022974668, 1825681328, 1123927944, 2425759081, 863745138, 3994200333,\n                1662692962, 2415180855, 2354782292, 808261716, 4050305196, 216852620, 358006854,\n                1426415913, 1552547999, 4131825801,\n            ],\n            &[1],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(&[0, 0, 0, 1], &[1, 0, 1], &[1]);\n        // - xs[0].even()\n        // - y_0.even()\n        test(\n            &[\n                7642088996549441618,\n                16939115288814344947,\n                4158423030205990745,\n                8781531266919626472,\n                4536426036746990718,\n                2759142628546321348,\n                2227485206975570894,\n                4571191084929603686,\n                9433785736036925989,\n                1551184301255450043,\n                6411840578125486860,\n                12800352943910688520,\n                17181013235616069321,\n                685975652320320677,\n                16307888956108230656,\n                8336973718541306978,\n                8755082279744089483,\n                16569752005561764973,\n                13002378357019963033,\n                6860220932393655015,\n                3560357731840892678,\n                7070244414620499337,\n                8840693397681308044,\n                16290086784750574360,\n                11733147242613009414,\n                6107879515762280778,\n                9376837729905597698,\n                17040637707038025639,\n                5177768201776762198,\n                8518342977048446763,\n                8898881218619802887,\n                10329787183129644470,\n                1526673743209372789,\n                10123244100180979109,\n                8726514720133331124,\n                12821051538345717782,\n                10882156112794604029,\n                14910284544698069484,\n                8872234416399843814,\n                15937194738982521740,\n                8503006142727912361,\n                3966017325452025377,\n                14700847728548934808,\n                14256889243292689986,\n                2528249268802686972,\n                7286745106660315912,\n                1439847309446662533,\n                15901896417657589110,\n                10477568383848354894,\n                4553356972647272600,\n                5529939210774917581,\n                14963188060984128980,\n                5375019716695641294,\n                2457481744426644222,\n                10485361437428266879,\n                5046590988101961772,\n                13198446382534172453,\n                15426785494942087681,\n                16124585910119816388,\n                3012068926694215709,\n                12864270021749924937,\n                11383059477645299313,\n                4320116732205951673,\n                15221500672825687515,\n                2665939181257259992,\n                10163551729206894715,\n                13893415558679363380,\n                5611079099597163943,\n                11092151207759951299,\n                3992411646432712733,\n                7869118229635958729,\n                11130808158108336850,\n                16931021319887020092,\n                10589484424862129300,\n                131590704017469183,\n                3810734318365068802,\n                1788964661632163921,\n                5738706636053906772,\n                16881608116606909233,\n                3243306516763190472,\n                12976245142731989716,\n                5499515806711091741,\n                4710317151847171167,\n                6683556421601504929,\n                2662551646050148338,\n                13562673622930528535,\n                9707043649639400158,\n                12788296700706707088,\n                12642829810299517252,\n                5102876644822332232,\n                7646892190996074311,\n                8078207877741285205,\n                14186421431011741661,\n                80547895349629461,\n                14862011566017513150,\n                77115327325659604,\n                12406562955874830673,\n                17375475859238808323,\n                7716894176906818727,\n                2802055520431677536,\n                2762761117974868489,\n                8210654419852490583,\n                8128381653654809882,\n                14172453553140328425,\n                11087897451444868103,\n                4396135003820796101,\n                14219611943052523516,\n                13587332761182504345,\n                17711266467744329635,\n                14950205666228843352,\n                9666645683806989543,\n                13020084189388475608,\n                7037840100396284962,\n                18373412346854186941,\n                11498753076197464725,\n                469550867963885335,\n                15259714004312508653,\n                10050610823962070335,\n                15262036116174229631,\n                7354344829290616378,\n                16006636465759715169,\n                6784457910192993929,\n                12937757685409325171,\n                7348103207566204581,\n                3244695992856053257,\n                3640146490035082661,\n                3037244987945809586,\n                14532227798128191783,\n                12631736369162945929,\n                7229210180128729119,\n                1338706890404586547,\n                4471472703522570809,\n                15106263865480071304,\n                11243988291566356467,\n                13331144267559269179,\n                10751519539999242267,\n                16921431036638007632,\n                6340810572216327297,\n                16133593180565445752,\n                14463917288006420312,\n                15840542126788846182,\n                13181419073605341229,\n                3946982966135895193,\n                10759326015518767201,\n                8447608418599844129,\n                4353759043775104853,\n                6237067423655196872,\n                9599085561312857028,\n                5365643417931112910,\n                8257457675273138042,\n                13475654552193991900,\n                17137537000886946596,\n                9313010620863889699,\n                17623954250315027559,\n                9114405119196504360,\n                5242451382075890968,\n                4211561857798749424,\n                1420640002606510731,\n                9161162479506033523,\n                483617176601131098,\n                5086158402623829536,\n                8760073747436331817,\n                5494506533277800577,\n                9008744669113942127,\n                7906886502348947807,\n                460316122106335334,\n                11348410017111087645,\n                17743092384644894320,\n                4543625687376029100,\n                17638867588777995538,\n                9728026851704705749,\n                5787008173309872443,\n                3036894650402650039,\n                67106435017645771,\n                17925489681419424557,\n                6389173597207372250,\n                7144011805433357127,\n                9295381454741344964,\n                14053113438378634953,\n                12217843843723167499,\n                9140869435106275798,\n                7517027790294614588,\n                3777825091021737118,\n                9367707355787166504,\n                2718655376583649956,\n                17560908054609622633,\n                9438653603987629385,\n                6976020052495124145,\n                14469978948800476053,\n                14607968393097793942,\n                8465948641441613082,\n                8829499402923220026,\n                15526274211406668344,\n                13263426691391304866,\n                13513707111700176688,\n                7058023659658993100,\n                12343251749665219733,\n                8922907808653322519,\n                7970367952666929730,\n                15924847143147976357,\n                3013336538735001280,\n                15754712827326735634,\n                810163294268081647,\n                11862926494972533447,\n                17142226521130689167,\n                16045131138370367308,\n                7810014550740933303,\n                11113360618561317801,\n                4146999428967559431,\n                13627063951311659386,\n                14101121524317207001,\n                17935556847685451236,\n                12893002441589054692,\n                4908175619932706667,\n                8148134223567687298,\n                2797861052729079969,\n                14252667124539620702,\n                3335552068649661178,\n                706647811473458791,\n                18284923027330686228,\n                1353092748991658850,\n                365920444454436210,\n                1178722791964549570,\n                14053600116413155723,\n                4250093264582203735,\n                17814207958723924485,\n                11616162427315300984,\n                7445813626020939704,\n                15051244446850726990,\n                7657749036148962641,\n                17550408898208013781,\n                16543784538024296766,\n                2175464478760404540,\n                17382259944663939998,\n                7085519492527115621,\n                1948795784424831543,\n                10153333277365682256,\n                2691142888904508555,\n                13042656130996531455,\n                3184232577077893193,\n                2321647310467391299,\n                16266534428918597602,\n                10813170547829807049,\n                1175296704970889954,\n                1336221003418894830,\n                6552922275158000133,\n                5879504718196828979,\n                13617292288202891737,\n                9159008209770128895,\n                2004574424000467977,\n                2728245432858568837,\n                17787384979230748037,\n                9410299200382955923,\n                16609139716214733389,\n                8268702623607434688,\n                6088812551270982604,\n                6106049667290975360,\n                7607520078701557430,\n                12472853613137360196,\n                10887056384527664263,\n                5597819467365735087,\n                10585294901756958311,\n                10513460596082524709,\n                4393150075765782543,\n                2683577406985854704,\n                10995282969723658182,\n                11867305236638382656,\n                2547454398707374572,\n                17029951353545530980,\n                6779642703694514142,\n                4391116384641001059,\n                3196785568538169495,\n                14807958476666083273,\n                1763112366273599517,\n                17875511915567196132,\n                18293280485747533701,\n                12994911180160214048,\n                17806815555469749177,\n                2603276529594432585,\n                6451629044374772788,\n                5131789756208165076,\n                6368584533107989340,\n                1442599467663039247,\n                16334140366206405769,\n                953757322567328280,\n                7611656048707188221,\n                16623430410377913689,\n                16263978152439933144,\n                1098065150329876092,\n                8375896578927982994,\n                7235501216156156538,\n                10872521053367378484,\n                1384698101043873340,\n                7546487270974101281,\n                16129196974871143949,\n                6523889198981083995,\n                3955763266387866205,\n                223786943533297226,\n                14312359200553508909,\n                166525052874074138,\n                17540833294310979085,\n                8682296429517930658,\n                11898411716692651263,\n                14647731107592123290,\n                11418813950965759480,\n                16276766779066588942,\n                9109613189145192743,\n                14365061852139334701,\n                2637416103257879045,\n                12683017840408065458,\n                17251784137128610303,\n                9857440911685680274,\n                16899637908997360539,\n                11676396516728162961,\n                12445807799710831976,\n                16409119217540007670,\n                344530427846566793,\n                10122735096389448235,\n                2236083202975860367,\n                7239130410771478229,\n                10419077940654134530,\n                3417466820844546773,\n                14103102709363050632,\n                8515412940073771511,\n                16793797293941006006,\n                2344964963606541868,\n                1770709333553370373,\n                11715027939900566010,\n                6724317159215710203,\n                13382766807638929554,\n                6643722639139813184,\n                1561112814735278829,\n                15883495724862322390,\n                16352011717026042684,\n                11080163213412729696,\n                2601285403880727060,\n                17539809965809036336,\n                11674296212933365440,\n                6987308431764628640,\n                8334299117659294638,\n                8401136336706455,\n                798056208147687026,\n                7585403371491023835,\n                2768563877851444820,\n                18160865562203294879,\n                11088989971128700023,\n                7958399735371734621,\n                905009938091789825,\n                3077994674694137685,\n                17781743814574321612,\n                9696234199814814695,\n                14424204686884620898,\n                12364803790224779557,\n                3680446812855063956,\n                10607012459674795622,\n                14354213044601441446,\n                7201960041306030417,\n                2820537475693014763,\n                6483412063024289487,\n                8894703326452336808,\n                6972597094957544888,\n                3089113953641583877,\n                14077274888152871698,\n                11143284357837217212,\n                6121624755399734066,\n                14754677241106442954,\n                14679578243226120309,\n                18187552762841862364,\n                7408374060988262333,\n                17543224593823838775,\n                9146972686354667307,\n                11578511243258357402,\n                7291446516637915248,\n                4910731754496429968,\n                6446378869968255622,\n                5665946125539935002,\n                14591605513868934991,\n                7360982275667630490,\n                12489166270353119720,\n                652942929868639081,\n                6195275995865002712,\n                8128775784532283838,\n                3387861524647988828,\n                10206768616721991356,\n                8310654759157370255,\n                12396521032462580315,\n                8378642939179207200,\n                8913611503978571346,\n                8964509316769391998,\n                6983721973747822525,\n                1620627079682485170,\n                3550888596803878384,\n                16764327882472918320,\n                12418434124596730949,\n                6492074094596751971,\n                14522169762543900271,\n                9643692256647897071,\n                10018141547919756836,\n                18119186792532188547,\n                17605638757524994218,\n                15110565499291832585,\n                3859111113510276634,\n                3608639569011774205,\n                16841921385542843558,\n                6333586318389785071,\n                17712249436612631968,\n                13651143305566236494,\n                6282590680802993984,\n                16962925672131291608,\n                17070033603299913704,\n                343263679484429433,\n                13960595387387109171,\n                6824567182512993890,\n                16643055854234833912,\n                13368136582061640129,\n                13407186988250747721,\n                12067851383097839439,\n                8734440357301460743,\n                184374602510479264,\n                1980281157180345466,\n                18235178046950429926,\n                12314150621953387389,\n                235240640756161895,\n                17191061665928515024,\n                1450328693825849226,\n                11658139939358930335,\n                9661242385016654415,\n                6544047620238274887,\n                10076084993639475413,\n                5484644773132718155,\n                8122848295214676448,\n                11451997792866817327,\n                8014772838878095834,\n                6738239678981409331,\n                7524197632536086494,\n                4887712629149768445,\n                12755950013597708083,\n                9072347758799333428,\n                9892994336906109770,\n                6658664089339267041,\n                17010445991373202740,\n                4749493607011870912,\n                15469799747835715648,\n                1410642028794185315,\n                9678426427615195040,\n                14603513578231268629,\n                10144994305300497927,\n                13627001390827901004,\n                3410387289467486309,\n                4969353610007528056,\n                6899086728498695416,\n                15840849162291468831,\n                794809021087797410,\n                4128395609120946267,\n                14603570710676978752,\n                18014301493566032939,\n                14554900403738652088,\n                15417180431811963767,\n                8123851550316828449,\n                701668417489927407,\n                7765872186237343224,\n                3766544625359426110,\n                11788559991379689715,\n                4186838184370360996,\n                184810421200681700,\n                9708014331923050854,\n                2038789855438533791,\n                12063495557069443857,\n                13840086852848556400,\n                13600250597329615331,\n                2088286198469966080,\n                5800997251215440284,\n                16245994826244567566,\n                12426146991432044569,\n                14174963417820155909,\n                15950886475654709571,\n                9625392305352933399,\n                4560214803933408223,\n                1220673912062550801,\n                5315118346179673010,\n                15305147243304018100,\n                8860293966649254041,\n                9878806918352789226,\n                9948881370845519892,\n                8051249634924644385,\n                9524148673689679734,\n                12489881836910498385,\n                9483374649969419117,\n                2429047588791105172,\n                15948533481260088039,\n                6658948169399436464,\n                7055385462316586853,\n                6444492735173712353,\n                12554099647303616570,\n                9411408437418751476,\n                3119186149878145385,\n                11561271469129136960,\n                4699043282095308564,\n                13664860088579707042,\n                11942040945216924956,\n                14938303604593577988,\n                6584398232469323882,\n                12615016316841274906,\n                17607035342042230816,\n                16299371719180977481,\n                9410230100515705546,\n                468652639351146679,\n                3099794389553133390,\n                7426463649192631643,\n                17220440064639262443,\n                249838037562419695,\n                12394557669144716810,\n                11891068226864790195,\n                6815470691731709960,\n                17050323216000491320,\n                17149156625587840029,\n                2840995912779779709,\n                16453929939061252876,\n                10865711713754680427,\n                17257962606206172361,\n                17324377803464599290,\n                9988049752693630171,\n                5145541150836693762,\n                18187548404778944247,\n                9897108837353120002,\n                17915722858353969777,\n                11223487437202128974,\n                3382309055960184808,\n                4470363898167775120,\n                15118823731598210162,\n                12451723255995030474,\n                12124942937255563460,\n                7883323618797267364,\n                11734899536152960444,\n                10899101530358100831,\n                14568463402558702580,\n                3589575239343156021,\n                9506082963977245397,\n                6269914352444216904,\n                9641949985442899274,\n                9484754331399933603,\n                7969595927070810042,\n                13794981515289100280,\n                9170567771554076837,\n                2138421182270581614,\n                788654717547257666,\n                7557048352969552118,\n                10073066668613087627,\n                18136047902767483818,\n                4883457934069327911,\n                6904157286973811264,\n                480950235088373409,\n                2214051188032927994,\n                8438459334885401002,\n                3359421640238953931,\n                18193289130141312662,\n                211796784365007412,\n                16550107280222789371,\n                9368274586857413302,\n                4080579477676412391,\n                3903589165729627543,\n                14601294347577892827,\n                17880615106796162585,\n                8399371980131050682,\n                17125581143302260392,\n                5236347897105180310,\n                373897691749512425,\n                13424896419381837167,\n                7230320496289832265,\n                9814225131983506715,\n                3257434254689569664,\n                15321426119731656450,\n                248987497038801136,\n                9132125928890530860,\n                18068784670509956259,\n                3834280479551637249,\n                12658772951095410532,\n                17093119016378053719,\n                14830343788339267922,\n                13054493939738291239,\n                7771905415521456170,\n                1347652221288704059,\n                2017715827457192133,\n                12475851911823933261,\n                5352012646013352728,\n                1878283153860510081,\n                9615556940143309330,\n                15598414798481854843,\n                9895563858845368344,\n                4068766894729575171,\n                13899464982406282747,\n                5859039026557422063,\n                17961018624926257461,\n                11439432659782104572,\n                10132383873951727022,\n                5668113599918475821,\n                5618863243783853619,\n                5296033916369028410,\n                8363560482197001010,\n                17475747004498994800,\n                8474583485147508303,\n                15911459900369709149,\n                12741330330991532249,\n                11847973179510376732,\n                16000211930346393780,\n                4738554376721879132,\n                11907835399609080296,\n                12646339508581669507,\n                12828924555217992033,\n                2386658548311295777,\n                4342638340328301062,\n                2558348042546117915,\n                1515754464721209816,\n                785688177042406742,\n                3053211873647924192,\n                14014331870834149810,\n                264938968394967629,\n                5983753879589540684,\n                267963444144320487,\n                1239629907294807005,\n                12062955612488831436,\n                17308841949048522703,\n                330482381584177401,\n                9514664837122696614,\n                6020475790972444309,\n                10895879821954360044,\n                17337803144194880578,\n                924273726463533426,\n                16535207821268418094,\n                8946410913169111340,\n                16060878889863712458,\n                15976666724330243304,\n                15895420185200619297,\n                10599438926533659781,\n                16395937774576899123,\n                1515688300207881192,\n                17269912862206470571,\n                4692813434396761996,\n                9815072710015129472,\n                8355648274808220440,\n                13388537609750517047,\n                17672336807467300633,\n                6893196003223183422,\n                1850026996207184577,\n                9739088825020961086,\n                10065083987816724431,\n                4941592917350004042,\n                7273197156716880397,\n                11764185831933564101,\n                3813114017041525493,\n                3604220821878800267,\n                8830614448851343613,\n                15764272711157879112,\n                15343520873072014909,\n                17833333986739184436,\n                11899253527412743432,\n                6319626654591461445,\n                8345841242755999512,\n                13969872924667267068,\n                14689808446598116235,\n                5690698738679570394,\n                16232574524853907406,\n                16476305072233006134,\n                3837644082952742591,\n                18371118811121083512,\n                6370089221943156975,\n                3758433368774128127,\n                12598095657509455351,\n                15041255601684463158,\n                219849898456894054,\n                16347148290535489696,\n                2952439398365618718,\n                6463887126673004054,\n                18006657361418901576,\n                15554865575024552259,\n                244493720680004046,\n                246212287818939397,\n                8391531415221668572,\n                17158996591507713973,\n                1574344884166927127,\n                2139609011514148330,\n                15894388729950489361,\n                14150049620712128466,\n                13649351261368190439,\n                12818010881632991653,\n                15846311295084438832,\n                18136287659718690601,\n                17778892669314265107,\n                17919810337867516752,\n                14238683656303095043,\n                9767662762617787421,\n                8792587365945756712,\n                16289324204380888977,\n                12145397565479495717,\n                13131505318922744869,\n                3537402907198034169,\n                15773157789160883228,\n                13080220658691776576,\n                14801888581508580861,\n                4455998795552535017,\n                11468446901913315682,\n                8764904591192407340,\n                16992093112328572788,\n                14539148855227682162,\n                9062932246611746862,\n                12092139254667251241,\n                16973622956249392518,\n                2330107601262713612,\n                14104249685295227139,\n                7802927139367928835,\n                17015267038524278700,\n                8076057374240890515,\n                15166827418715942805,\n                12316102967608917038,\n                5048442745443715233,\n                14352260581070172244,\n                18429764753411235196,\n                290907609897930421,\n                12832680942495754212,\n                17691084325410578048,\n                996179388827615558,\n                15796651271292023703,\n                18430169649438059546,\n                12951979241393380884,\n                694335279970980851,\n                6638967085265053633,\n                17595649263141354482,\n                4234846945003198207,\n                8367354156647080658,\n                17456583496028677793,\n                17835204410247184698,\n                13301357937590556083,\n                6786278664181009598,\n                3297223935318868177,\n                16554057669712072231,\n                12522453888866796248,\n                1975238565343362470,\n                10528848975094257154,\n                10553418118214937237,\n                13409190148243583780,\n                5006922367367242363,\n                13556726007351092492,\n                7783632275488805468,\n                9183676289046305416,\n                15469154331779684343,\n                13423499673227845431,\n                7837948571314497011,\n                2029560205070039291,\n                16649457177034615332,\n                13491227518645198090,\n                9993378618273883553,\n                8487159310535624111,\n                2809530522983207601,\n                13575910212973157992,\n                2171679949756077498,\n                1660890720446202624,\n                15646142722510171608,\n                16932531575310315514,\n                13775138986080338436,\n                10735540465035236537,\n                7604129283442046332,\n                12444305356219135513,\n                18201551442306471158,\n                11120131523005131855,\n                2798231246691818759,\n                15317641731597026057,\n                8499616562041083838,\n                6017032731278071224,\n                1273341979567250231,\n                6519997694567640478,\n                2435912850700538815,\n                169204604573595693,\n                18269270505596175452,\n                17459024018388721732,\n                8266385672999361049,\n                10680903187132175198,\n                17375563191275197987,\n                337068133283788118,\n                16239907884128954657,\n                17641011679183022712,\n                2366475531220210250,\n                10755304562557576337,\n                1869838694309764714,\n                8258555369397490418,\n                962287818495402559,\n                4995654753554910199,\n                11059451160990599794,\n                10810204279841400750,\n                1456068596599679097,\n                7305003907755693862,\n                14988290547736996217,\n                6795308809242518240,\n                8763020957272447790,\n                3308001334228530973,\n                16974667325340586198,\n                991537759276291502,\n                18008237326885742575,\n                7753905923063895580,\n                17512543097224696770,\n                3595225617413761186,\n                15058630498302531631,\n                6622110332814961401,\n                12488257875553353319,\n                9044137245617220882,\n                10271290501572288378,\n                5585777756799704531,\n                8295396987659231737,\n                9215167333658814611,\n                11104586326674499796,\n                3810019579782011422,\n                6888760568785282460,\n                14532837177301113100,\n                977805367496486072,\n                14965851872869659150,\n                11134550780907874822,\n                8067904641271727206,\n                16240490643234968341,\n                10640644051933721969,\n                12823704007775718263,\n                13210674225658496740,\n                17421304180276102080,\n                8863993590195462492,\n                5419546058165868071,\n                14184558657599665798,\n                12923876509266120971,\n                6685006207471871309,\n                7704595961550622452,\n                17285923828421938855,\n                3505207992795309843,\n                4532252029642664133,\n                726816466976184004,\n                10742313034328351171,\n                15565587799659267510,\n                6490375145545887919,\n                17152573783466503447,\n                15997997319822869691,\n                10153243598033053836,\n                9623317771768820586,\n                15946877188272739767,\n                6079621748092093763,\n                4005237073110529685,\n                10324349804736126549,\n                2979775683162494848,\n                12357491130084004088,\n                6870626476679302958,\n                15875069688841775050,\n                7544803566766537053,\n                6558561331652540514,\n                11395728505159480348,\n                15150381432396177515,\n                1619752167122893719,\n                9372894574032628757,\n                4772175913517010825,\n                16565939614554921583,\n                15177791327910370589,\n                4034037178193525662,\n                14253679894187996439,\n                4373435865471950380,\n                9110620573126725481,\n                15888647814967051075,\n                15867477839426284043,\n                18263083430840355206,\n                3572721603558989476,\n                18033901510983288634,\n                11740707689919057494,\n                1919396080344872985,\n                4785878236873911753,\n                9518697307553186252,\n                2196912231764078547,\n                16859172788282672634,\n                1294478177294091838,\n                3853855925306587869,\n                5712176474426944553,\n                10655739333433675017,\n                16864687770354405683,\n                479733567774176546,\n                4002525199861551470,\n                17884530730667206604,\n                13118987544304899067,\n                16693510145083648654,\n                4348762192364479250,\n                15651674952754110111,\n                12941615268132778668,\n                3413954408450272001,\n                6437132444235811404,\n                5911780604883628493,\n                7027061191226541890,\n                4541332504662688699,\n                15278256850661601886,\n                8783983716478722525,\n                6762972941032427523,\n                109436002367794738,\n                4964075549363170179,\n                13998615704165248071,\n                15840448835251983621,\n                17124026628251673729,\n                451007725533524973,\n                8689993352441934927,\n                8085937255579820677,\n                15895079089926267008,\n                9033950962733316797,\n                16460182791232706419,\n                11706751917248926231,\n                1518070523274778714,\n                12841484353662177921,\n                1106444835771962416,\n                3781633741335232752,\n                7295048037310303538,\n                3078350382473633321,\n                5513880551571688035,\n                14511804401958832310,\n                14686668965111665491,\n                1334848572346842714,\n                13785608726613289908,\n                5484295527088560108,\n                4677427364593276486,\n                10739032089578444339,\n                9118829737688197133,\n                2599009188037666293,\n                6541018502379686045,\n                15124406767918971296,\n                13898029149245587181,\n                7049797326321056181,\n                7676359806921760851,\n                9359455871357711051,\n                13721511461701704493,\n                4337948462861507669,\n                12182314864880410336,\n                18115088039222630086,\n                13611666747148849963,\n                16979677843375636930,\n                13976122741306049418,\n                15131996055772953287,\n                5019533830870398293,\n                17994426892860907985,\n                12238472482719268447,\n                8485137745688214163,\n                10046713214813218322,\n                9981765980097884884,\n                5203049149404803705,\n                5509439206475409607,\n                16646013403333676735,\n                5721376623514557165,\n                17895610288116512634,\n                4146710226708894505,\n                4180329068470310700,\n                15333932579841565344,\n                14578826506899561228,\n                11125461119487324145,\n                7828598169855633640,\n                13016918249925390910,\n                11596786187817182424,\n                3070363472909089566,\n                13372064806216785587,\n                16483915751021484392,\n                3209300474080959275,\n                9744396152477868876,\n                5286486708506722214,\n                13334231276589469146,\n                1703296437445864549,\n                6990559773807735786,\n                4323851084064743622,\n                8258191458458530560,\n                5487559074143580665,\n                14530068425901775586,\n                13125628672642465590,\n                7919522946763693741,\n                11383708583361967263,\n                8699024886208260276,\n                5911243921359438557,\n                2976618942061378858,\n                101882160229833275,\n                14947300507963600168,\n                2624952948637079445,\n                13110311834336189786,\n                6328067748328586264,\n                8026502157595153247,\n                13077832359361647005,\n                18034926555389756245,\n                10932060114415829114,\n                8921112613501153906,\n                5010993000512607919,\n                15729519684045200720,\n                4230394140032073806,\n                18249470456439233157,\n                16698231796621617025,\n                4922479776459643659,\n                7326057194769023839,\n                16485955343145773710,\n                9357885960145954762,\n                4908643074768640635,\n                9426875174076058663,\n                6269667367780881933,\n                16372434513892687866,\n                8166317811376426944,\n                14210102553507463054,\n            ],\n            &[\n                1979867317777782919,\n                458803043038589105,\n                14807455935956247393,\n                102755393029177892,\n                13661879760043023426,\n                12743502586850908641,\n                6485502394763823003,\n                7006537482591563738,\n                13464897952724427622,\n                110941783775954905,\n                664806907968747258,\n                13976172522383104680,\n                7081409417990232579,\n                11782066704046559999,\n                15078720815504238982,\n                2791066361698645774,\n                1957006820108785098,\n                7661621907711528521,\n                7129856627939149071,\n                12464578713097949843,\n                12568595944828213000,\n                5103092420263283198,\n                15856125363599807684,\n                12992729636796940656,\n                10878188187148816380,\n                2850172728651555239,\n                5248002320936640091,\n                6759153103556744157,\n                14339593489124645610,\n                18317489909052141708,\n                15949249147341703950,\n                9001038595758313121,\n                11504712957931727005,\n                8187691649773049259,\n                12626028481208875277,\n                12844051055584824684,\n                9111532080412358373,\n                11481281377490778456,\n                9905077354469164626,\n                10848129645301488797,\n                12407190902965064104,\n                3004380005013311524,\n                7260177637980150880,\n                6465761219435617351,\n                11687902913416861598,\n                11582630797299992145,\n                5052207193612544256,\n                10619895585106656895,\n                3782849494513349232,\n                1696521729205924429,\n                205289556233949352,\n                2309142630958879699,\n                18013220874964165818,\n                8780365515667787572,\n                10777210546602678450,\n                16689458940952011084,\n                8786023929671818084,\n                2959945332887060564,\n                12595094201729105975,\n                10555858515424418250,\n                17838802570355306753,\n                9768848979007259380,\n                6400634551878490492,\n                9350070212380397383,\n                10825325059459528805,\n                16240713222773986945,\n                6773516716020300636,\n                18379586867066835204,\n                13392009122775849047,\n                17446114650305191430,\n                3443249317411513199,\n                16590433388663762614,\n                3592506842077891585,\n                2547605864889189098,\n                8921931064104759283,\n                3745288943697428348,\n                6683293017020997233,\n                7599775167852553507,\n                11479579422714965337,\n                12242916146470334290,\n                15886988537674743805,\n                8027185433862293631,\n                5037238148478185925,\n                10545897273866342364,\n                3749333810592645893,\n                7567899208857364441,\n                17332217733795476186,\n                14570089467947298319,\n                10687712370800535186,\n                8398127082315689224,\n                18138318481654121301,\n                2550529540627040228,\n                174434346470095983,\n                6335843839776953618,\n                2142199594346057908,\n                7492814286032687084,\n                4581612999630224238,\n                17362182859125741557,\n                15332694635712824041,\n                305820774489411582,\n                11087741421794954545,\n                8166298207140013628,\n                13663827369108026131,\n                11609249890319933551,\n                4708689618714214726,\n                31696613282352588,\n                6229354554698145266,\n                4430381785479249873,\n                9093084456389745185,\n                8620628652860035454,\n                11032119279655454850,\n                7436388409999188798,\n                4508581046303828766,\n                9266330334354028474,\n                4654094790776695762,\n                10477920368471986136,\n                3040546382665779497,\n                13578021419513941070,\n                10874037816916517318,\n                209250739982139053,\n                5513314962388268387,\n                2276087999654805974,\n                14116993918737387242,\n                10215096397828559307,\n                4706886349596564784,\n                9496675948395405688,\n                2592786526073230109,\n                12032023929905220888,\n                11439071011556767245,\n                8896841450411382115,\n                812528333048514747,\n                4857507773721570306,\n                2346347769853663620,\n                893640476967692732,\n                6002646205477400496,\n                1258104196359799910,\n                3298555154777830453,\n                9831348292240867254,\n                2983777286176645688,\n                14012697848669764867,\n                3281297577197824417,\n                4818243357287928570,\n                7599542312723359299,\n                16303740951463015372,\n                9530417675969610545,\n                14307310939799846427,\n                9411915044625670774,\n                3098269527533968285,\n                16636400423591714570,\n                13575763948252176199,\n                5311264796988234687,\n                12230662710526328293,\n                15591605225575960535,\n                16170866454635856185,\n                7154393582831771624,\n                9746836435275228439,\n                13154372386985050769,\n                13955058214451317887,\n                468470833133904286,\n                719628130899837785,\n                14167898993266425767,\n                10492242376823879424,\n                4695877358022833681,\n                14415659841083920049,\n                2128453387083764523,\n                17254215071478848692,\n                3464552401256088318,\n                5473802745477872406,\n                12278908178174546508,\n                10917423561691292478,\n                8269556840984708513,\n                15451525009059595276,\n                14506788958072783738,\n                10120241313842466204,\n                897911062165781450,\n                10413013565287912000,\n                5183133159721680857,\n                15306474298436567422,\n                2072549059193978699,\n                4803937018033002282,\n                4902316829203079235,\n                17182047496719608796,\n                16148451990121486069,\n                14460165826013687805,\n                10861828715214694182,\n                12852802503672044251,\n                17897814519242488317,\n                12830584456010343195,\n                5025833892983477930,\n                15171169537313884434,\n                904875646680899456,\n                3891209230657191180,\n                4459567895597613958,\n                10213064404613271715,\n                14464647608623247371,\n                16076880745118924462,\n                5651027014515376452,\n                6845292042507662562,\n                4700263749108232739,\n                11912023508343584677,\n                15164089726347867289,\n                7435959069204688586,\n                3673845585791184955,\n                9008233584340774048,\n                623672340235969578,\n                15952660561845258442,\n                15255827823417955924,\n                403762546093465841,\n                9023129674293106279,\n                15962739700493341062,\n                6108426038775323673,\n                11423092137795750189,\n                1431075448616656956,\n                17640578768263514852,\n                9182353610308928359,\n                17753229409310170357,\n                13898814437210093610,\n                12126245547088496216,\n                10888527319957075641,\n                16039715754410307348,\n                628180706859646675,\n                11343014058184488762,\n                13075222209229766794,\n                9658840972156173472,\n                14805748267851325307,\n                5640565628362124114,\n                8813449713167462710,\n                14750431340071075257,\n                7341247484352499222,\n                4105134027480979119,\n                5063597277155075543,\n                10245719632899271147,\n                17417102409056111607,\n                12327200750635056279,\n                11257956633392412563,\n                15654204403173941169,\n                16887277320373649913,\n                17293310148654704869,\n                2931320393510833429,\n                18265112369378689230,\n                16177931273491220730,\n                7148441830138947268,\n                2542111810786801658,\n                13075348024340421114,\n                15045402682302144848,\n                17729484015706193097,\n                14849701582062849098,\n                4494999822131844988,\n                13853067439918054754,\n                11104593802418852948,\n                6272834726309696758,\n                8176562272197586716,\n                11136460055946228459,\n                2249625026165448849,\n                15192391646155487262,\n                16462654425479085870,\n                12438135124930472309,\n                4231754137003607533,\n                7025530078224271576,\n                1902066619924498430,\n                16798677464948394620,\n                16103591627987069524,\n                6073783480651248517,\n                2301126056878392650,\n                525873165339288975,\n                3654812541302834250,\n                4237734633374880968,\n                7013648087246440503,\n                2708020996911432507,\n                410030825299234570,\n                11409023582536021944,\n                807125820884538678,\n                17085267726135611778,\n                9547871053479185317,\n                11213262078356721077,\n                9638233998727018009,\n                6181404851731546121,\n                13509648795699246119,\n                11626561711623336962,\n                2367028127797295412,\n                14408238933122914429,\n                9501259205390120800,\n                5388820411015324736,\n                17908911641461106076,\n                423710192565734379,\n                9911666373654831039,\n                7296600371969340330,\n                16104674231020469855,\n                17273935562508193984,\n                13386092434346383645,\n                10904128763248841619,\n                15660801723929131082,\n                1802676326982826038,\n                16314898646999153588,\n                11051772565381291670,\n                9582949690895199194,\n                16665669325627731401,\n                1675659856826747750,\n                13282418735625888151,\n                7647864912575263910,\n                414802336339416341,\n                7456128243593571890,\n                7401454041271044889,\n                7259681585053156654,\n                10297473634673620153,\n                6291331063601368350,\n                6858202795057797026,\n                2331669818605326975,\n                12264404420708345107,\n                12089542543065457441,\n                3633020299658155421,\n                18428329446154081698,\n                16353160654361289944,\n                5081398862696143362,\n                6121111800778820791,\n                14309612314653801386,\n                13306300382927317704,\n                3064838612410500446,\n                14989006580151485936,\n                12725645885424440632,\n                5569344928439882604,\n                11093264756688684425,\n                2529531794792252742,\n                7787364529152520016,\n                12100725195740947792,\n                11015410010827498630,\n                12770939750081523925,\n                16423905424192297733,\n                11305841527114312073,\n                16891896558850432433,\n                3225706379047965263,\n                14166563803489592930,\n                2355248555503091815,\n                5476494996858779102,\n                15360364114708065353,\n                2946255509562408083,\n                6223737602577045649,\n                785528028405825827,\n                7297867173505941067,\n                4724393265215111794,\n                14532649034725999985,\n                4217904748666774400,\n                11309973650332868442,\n                4820265912884088727,\n                14053660458609997460,\n                3483460907245444911,\n                4888448412579236860,\n                8902978947161354892,\n                1161291241547718844,\n                4827742954141797453,\n                17959154045662307166,\n                12471977193177859473,\n                8286419873042983353,\n                7559677115080818717,\n                6009725396648616438,\n                7950724447316580461,\n                12082875173598285235,\n                3123141200374415061,\n                7736739371326140224,\n                9033893194019001400,\n                17119540472038591893,\n                6838993250758979381,\n                1756627985014158028,\n                11540944119317576836,\n                7167619835597129390,\n                6344439141314015967,\n                2159381790958961231,\n                8723275234827128314,\n                14671976335382244081,\n                7492612374298612857,\n                16983115979216019630,\n                1137928104103949457,\n                17705437622823562319,\n                13213748898063588558,\n                11565618477779377046,\n                4479222060769626300,\n                12657805467897134295,\n                8578789730380785090,\n                3568050214652067765,\n                17264603982687227099,\n                7554571839983616835,\n                1648213353577773226,\n                12805556496169022728,\n                12400854649388722924,\n                12743032680153521053,\n                18027191329575892747,\n                9029998509699231947,\n            ],\n            &[3],\n        );\n        test(\n            &[\n                7798496952823407824,\n                4811470598592046480,\n                16634149002718209756,\n                2816485763131163737,\n                6764931459572097898,\n                12135396153038963217,\n                4726251464409773649,\n                8573439160265568957,\n                14269672704267810519,\n                7649448254104194910,\n                12613439096551355375,\n                6638659391603712256,\n                9240011195460328922,\n                12704753717311876709,\n                7176884384156072417,\n                13235015177754973669,\n                14756487689013468042,\n                9212292110542328191,\n                2882513161370093736,\n                64849663354449995,\n                4532026566849740479,\n                407205524552954739,\n                16398190979531467263,\n                5875928748346174530,\n                10796369575411951617,\n                14293424794963768678,\n                9366522120560533977,\n                4213967089717524150,\n                13763075659281951487,\n                13464968737596420936,\n                6549141323160628420,\n                110915844406990687,\n                18075287808720180110,\n                16664063901861004820,\n                9897000415442332787,\n                1486075656392074792,\n                7382904500810297215,\n                3592293622273342942,\n                10008125746032292648,\n                18321114734333840332,\n                17920212203847604612,\n                11217657766511696793,\n                11281083380440747080,\n                7892713234117558634,\n                8902471323128328235,\n                11892365124252837749,\n                12611508814807140936,\n                11815551321438701427,\n                18110749687253320811,\n                11715728409437156086,\n                3339319126985623378,\n                6325617411041006209,\n                14096883611650388622,\n                17687808067973538964,\n                168019485471086672,\n                15693590891786235960,\n                2786725115760255375,\n                9052512570921605652,\n                14177547685319586247,\n                15370386165587184937,\n                5970865523433924174,\n                8584955417200346406,\n                17233739694187471127,\n                3635034994393071086,\n                12922974184613453425,\n                283176399532113592,\n                9116715092600674482,\n                533178685039585111,\n                5221528600415982001,\n                16669037965261793667,\n                9659393188345721976,\n                1619537891333142145,\n                13016156940489086061,\n                5348093554893488672,\n                4125157131954041036,\n                17147602453512343883,\n                12283659650945459472,\n                6073750737922483302,\n                4112966256314115607,\n                12848281534595730436,\n                11698310578341605232,\n                12515024339763963627,\n                16720191980955784273,\n                16331343356415214175,\n                55095711946944202,\n                470353114021282512,\n                18440424164986645711,\n                7119069413231791773,\n                7496499681661981147,\n                8033047773523053512,\n                964312760862509573,\n                3077830922660773095,\n                155832606423296496,\n                13447886967389293275,\n                8559367474278812445,\n                17998261191861118766,\n                9631655612257511488,\n                4223841702086601452,\n                15213562135345686189,\n                13421535853495283983,\n                14214420071333045458,\n                4946777332360956414,\n                4831925713285482008,\n                11760595051618114799,\n                1418683958686722085,\n                10071047199952333941,\n                9860212880469572414,\n                5658526438682259927,\n                3208658863323316983,\n                13572249994839707422,\n                10858577727713550259,\n                3187235617013222032,\n                5876918919503422475,\n                5078114263735950174,\n                1124267584430625852,\n                12765353279431679058,\n                11774222431813768840,\n                17690097956396545959,\n                11327308747698708585,\n                3866755026407601622,\n                4133257169702318528,\n                10187715330446905330,\n                2618131060603979377,\n                14909622824179687974,\n                3131981152941396860,\n                15758444864200993797,\n                15877508051463207022,\n                17810056601280430664,\n                13308597888743200162,\n                14765083240575543194,\n                8389207789402457515,\n                16638724707073855749,\n                17831200813330442342,\n                885536911921616113,\n                15627100060180098369,\n                13529643776104497044,\n                13063738574432590840,\n                3409549155326214534,\n                13384107634300554710,\n                14621110597375575515,\n                10454034361196971254,\n                8866597122119704829,\n                7214280631032588417,\n                2321851294623259950,\n                2664600902577903557,\n                8206930671630553011,\n                11637903730276320737,\n                6120862895588039690,\n                10119555767934669183,\n                15072606566681932076,\n                9196021740659767391,\n                17668381905754714807,\n                14113831610785889688,\n                2274519386441753024,\n                16941927109776392899,\n                8855427208083419550,\n                8707706292745593239,\n                6509438127169345769,\n                7049981796161059741,\n                14351405462508747882,\n                8739674628274889331,\n                17773549691926711863,\n                16108213739701189254,\n                46349353234791966,\n                16335307352245544894,\n                3372116134019651210,\n                2026650829541426733,\n                14482558945555858306,\n                12178227313839428552,\n                379954005080389912,\n                11703446819120251215,\n                13961335387977718269,\n                13253644918378197554,\n                8389008141245407942,\n                3757779100833278863,\n                16977903525629057562,\n                8706100545828799795,\n                4980644394686364078,\n                16602809003881382792,\n                4704649122813882219,\n                397591639474341233,\n                5691615138943748269,\n                11603908706905475525,\n                7830467758888891027,\n                752954507775914877,\n                13742220678588369779,\n                5512709449415473472,\n                6602314973830649238,\n                17294329281209674921,\n                16353762684852197024,\n                5198076929899652796,\n                2451984573929623323,\n                971255382782649783,\n                1825437488761527279,\n                13282135031519430271,\n                15671289983850977417,\n                3215788959201267209,\n                11367230670788525763,\n                15158322487047971358,\n                16383227556481842658,\n                9272710553939316379,\n                6940559952311103297,\n                8058002679263304409,\n                9200541971370090762,\n                13026270051739823047,\n                14703602147590614957,\n                12270036121815530821,\n                10856837658238904154,\n                13457513436452657022,\n                7752098762039414070,\n                5159679976569317358,\n                7346882116989161530,\n                17098000856751349286,\n                7528478613810311492,\n                14595271732066598782,\n                14345174012514521088,\n                8917561215963658071,\n                12444774771012436781,\n                18003493577034559128,\n                7401267539893108958,\n                10703654441621295266,\n                3928975917156990612,\n                12068658501017100188,\n                14247190926978777640,\n                11887379833560086066,\n                16388813962188846581,\n                381956448283854400,\n                14770881628537066339,\n                12486489047707489763,\n                6358578569341757564,\n                14298750548968079945,\n                2056466734423394877,\n                6368203595950482405,\n                3223554386699468954,\n                4227760395094299567,\n                8534762536962691709,\n                12548903028463843885,\n                4967345662728519086,\n                16943637153763582029,\n                14715091124220815237,\n                12141001306263104014,\n                12175816912849205543,\n                1803108872161511343,\n                13641105341345940724,\n                4467984689873651089,\n                1855564851398276223,\n                9806860208915759902,\n                15434907399817341842,\n                6414202967398339339,\n                1952032742127311977,\n                11903471585924758516,\n                1684708809058774974,\n                9584411782518918504,\n                10773185872250646792,\n                8181377602390776035,\n                8122154254362200238,\n                12902500799759276861,\n                6582720162263342292,\n                16706580731489248920,\n                2000050292502342191,\n                13921749765600186584,\n                15656774592958567364,\n                13515604429385540270,\n                12553127158817424021,\n                7759293979203731105,\n                11524585147783123654,\n                2416828035660522180,\n                3815782196161663623,\n                12068235656126232794,\n                9641578300488516781,\n                9227047490937534043,\n                12288329318600678892,\n                14357764900702876515,\n                6643728818780923790,\n                9169952627439601524,\n                16190860163944860685,\n                7224449977289312853,\n                2426010657612704988,\n                7097348057731348819,\n                13428085588675193837,\n                2243566205788137318,\n                3521617463718109980,\n                10311601150383225693,\n                18028456914623038645,\n                10958023041184848012,\n                4863849643405996604,\n                13982944808354970647,\n                5078862720378429165,\n                6995084509678946294,\n                7623261163534034449,\n                7251391284527626801,\n                6642144335648839474,\n                889957175812482926,\n                14115678510823527946,\n                10943283669987163106,\n                18022097549698166076,\n                1064779896422972216,\n                260976419678710154,\n                11706337798784823402,\n                7339908486105356132,\n                8990824151888743890,\n                5645262432865657530,\n                1657496751968765591,\n                3530038441891535071,\n                11181694072782782766,\n                10650389332231278211,\n                15390473409517527604,\n                13153289830091656667,\n                12038556920917300027,\n                18066231150944097445,\n                1618038226618345054,\n                3389192047673882355,\n                11082945276561617384,\n                6705349877566422413,\n                9781054992335109493,\n                12253545225617312403,\n                16999500068120091746,\n                8769791004306726764,\n                4768271990176342717,\n                16794616123670513863,\n                3996402883485570523,\n                9211678469009515216,\n                14027728220422542365,\n                10496749002692321926,\n                11703646058430893877,\n                12334209370443949878,\n                11449604462076360388,\n                4396255705900668331,\n                14533140968852883773,\n                3491798162892333300,\n                3038311448490854168,\n                13013057516520639140,\n                5160377804146514933,\n                14399436147471941106,\n                11193864615898836432,\n                8531481285844220199,\n                3654104119756094460,\n                14734961005960740209,\n                3654191345397549727,\n                8388858864047403816,\n                17927724813621687727,\n                13429016298799125048,\n                5367750080313919027,\n                6393224854041665242,\n                4821520064553474661,\n                8442502022517558844,\n                7752658698916624934,\n                9550072160911665752,\n                4540818189505722827,\n                5059997612305268209,\n                7060253925263482470,\n                5083054112761819250,\n                5803398198426211912,\n                1380106897985489402,\n                18071437738740065909,\n                1345071843572391414,\n                15710434610483386531,\n                11071377898640965589,\n                17641605384866702714,\n                14870360628358138696,\n                9827129489073260439,\n                8450415892983753145,\n                15666761634961775100,\n                7270545221532941060,\n                12053279433290804257,\n                1622313886640544491,\n                5340667040115210848,\n                926087624946022227,\n                7935611017520266364,\n                14642870615373560695,\n                3125283099898630391,\n                2050649978125224472,\n                205120195037820803,\n                747063854179462342,\n                3789699371533579595,\n                1035701621096547349,\n                16018212365729931952,\n                3789866428655158698,\n                6388723914616296058,\n                16510613621210149584,\n                9894647709359168130,\n                3013404062090041115,\n                189489053932127657,\n                10633648435212574812,\n                10348107062615836735,\n                12002471873905392969,\n                4237459592751843708,\n                11637939215779621043,\n                14922365631690025380,\n                11760271887075563159,\n                678386638816913540,\n                8019936738073295856,\n                3836915660118827695,\n                8019505309874069847,\n                7265558081469259310,\n                884417125200105927,\n                1753033849914718324,\n                12690803762933082738,\n                2546869581652302833,\n                16955148199618032179,\n                11708042465849324633,\n                205152477319765645,\n                16629796025665189045,\n                4790774024455362541,\n                17402843893609042859,\n                14744403841742504335,\n                9084693659612921572,\n                3083238898476439769,\n                5569669417086302690,\n                8634335868370264618,\n                17597532536692475916,\n                6829124881401627081,\n                16057844520727040534,\n                4393594275785544998,\n                16870174283907099328,\n                16864947511372305749,\n                7933670409689289709,\n                8062243686940958546,\n                11511723944420066352,\n                5390996783507099517,\n                13514845063338313048,\n                9120727178683820530,\n                7135404489830930274,\n                4698074799063558795,\n                1336268150592162916,\n                3371186837701723352,\n                12497753092049419593,\n                10662480898239412552,\n                17887743751120115746,\n                8037614308177933475,\n                15269519858742411375,\n                10429730734252577378,\n                1782248407797168163,\n                13511127986090773154,\n                9879755090209915206,\n                1548237506818739800,\n                15336522777265989638,\n                16083355574386989716,\n                6892661436203042392,\n                17708965875006543343,\n                12487267807383327705,\n                12371079313118864644,\n                14239391039731513177,\n                9712715537776006647,\n                1339505136772159105,\n                3012551510428362794,\n                12357355653088287352,\n                8187824344238681106,\n                3206470745685510953,\n                16525705376900723725,\n                17797473822898581012,\n                14891087890601797179,\n                3429920644657740961,\n                372799842385126583,\n                10159920898351373304,\n                17084534135671018643,\n                13674012061365744215,\n                9062521393516717101,\n                16249511416435877582,\n                770466755139844308,\n                9792258604515956754,\n                9847259338113774618,\n                6524319705326716888,\n                1309518254525408764,\n                10346103312499662230,\n                7796705521616045141,\n                5244441786886038342,\n                8458019209005484172,\n                7382931637777326782,\n                11162469257770583764,\n                10053536657529816615,\n                14155165939639076903,\n                3216040867013041656,\n                9855256377105714377,\n                13333494298177667840,\n                13870977529578497762,\n                17702198111172052493,\n                7063132479007076033,\n                15117903718709274386,\n                15643124275645359631,\n                13246097376953615105,\n                13943153081968370799,\n                4129477198714818132,\n                11857346290084810717,\n                6481315132425963863,\n                5719683682695494401,\n                5296814144172527318,\n                760666829981906503,\n                5590808134778217760,\n                756772015698441472,\n                14491844706456542800,\n                18082567968363957214,\n                9270285920051865537,\n                14699652027310128713,\n                18248498453132658193,\n                11684467957653234109,\n                15881769941581835167,\n                314546154914222688,\n                8114343064128916817,\n                15594029378006079537,\n                7306033488226269464,\n                13428690195826711521,\n                9052721018056013484,\n                5948173439127948390,\n                15052909961655625285,\n                7325957567666136697,\n                7255216113309866460,\n                2339005174917919375,\n                3541464599868150096,\n                10620807105734506848,\n                10401555768719983049,\n                3223209184831011265,\n                13219238608657336815,\n                833402815708396065,\n                5409227984281460817,\n                9625361525616921089,\n                1310345922942938948,\n                3164590508354402136,\n                13571591791085099481,\n                6449583851417093650,\n                12132073172938161206,\n                8472582943832045347,\n                10769099083212939156,\n                31772634679058711,\n                17768858162967447980,\n                3724817912633131560,\n                16347858930007720615,\n                4581178512905307749,\n                14675184379874252691,\n                7800880386417268233,\n                10500558640555793613,\n                10907473822263746966,\n                10349360455162450796,\n                16243419016207551444,\n                7948477362985436355,\n                5648370989495638971,\n                12554130341333656507,\n                5387445954608484822,\n                2435984528448136931,\n                15926990095133510448,\n                6240279474886617484,\n                13162027311361639933,\n                9845498081224385677,\n                15136770857402679488,\n                294172832127927540,\n                11812753576130759285,\n                4714994681116169573,\n                16515438329473328309,\n                12715644809880958907,\n                2687151289233831920,\n                705088298937614828,\n                286079974305964184,\n                9155582999882597057,\n                8821011997760107375,\n                4417717245202189035,\n                12959997704010734603,\n                8879211443564867802,\n                13288247630269789338,\n                17556983875558228264,\n                6934174419250934018,\n                5626105851946025353,\n                4683143168831417573,\n                13583545217544294035,\n                14621427723839799891,\n                10439845563205327853,\n                7115341531213749311,\n                5705625326650783712,\n                6329845201407641639,\n                6588043698151966955,\n                16484557210962277459,\n                15151791142829317538,\n                15329622087488955522,\n                9042731875468481521,\n                11804081118316930516,\n                16855488448748462109,\n                14875244187197991269,\n                10172305946442195983,\n                8757636627949073627,\n                5243026113735495788,\n                8936037042873886159,\n                4876890161176869416,\n                18006537171731967094,\n                12374747388220381150,\n                11864668767677461873,\n                7189191550084420743,\n                11292555383413732769,\n                7884526425467136896,\n                15623541190026103730,\n                11092209719983693999,\n                8028450957205620326,\n                2499868879825625711,\n                10808424434450244851,\n                1850120526551312291,\n                3579487434391430254,\n                7970110833128773015,\n                11502636942992378521,\n                16957022813958395608,\n                6038123073412640652,\n                10534237287670598452,\n                17692645144952827790,\n                5499913016452810923,\n                9577924119610418763,\n                11827916510345201494,\n                5412361981268336080,\n                4983789128726775001,\n                9907721766352553361,\n                7746668222533981953,\n                1540831215979961919,\n                7169664330498339513,\n                7180697286303485988,\n                10347276511906245411,\n                10823488766645044528,\n                6133595352212519820,\n                16312710139973589114,\n                9648734934782395917,\n                6873899491086510519,\n                15241958636619718674,\n                16002332770379796259,\n                11637713949810347145,\n                13428135478576143504,\n                4025997171210729991,\n                5342284361833989558,\n                1000822021319843263,\n                9261749846705840856,\n                3617262093116689162,\n                17942289330270390442,\n                11385597809028053659,\n                7287780710901341369,\n                14762598407984080840,\n                4264460461385592109,\n                14094826370185134517,\n                3283046943932850948,\n                90170700188501807,\n                10674057436346217291,\n                5644642641840061204,\n                14527433886721542373,\n                2131222867340329316,\n                196797277728757979,\n                5366091626020562492,\n                3409153327989827025,\n                4841679307319540953,\n                17375418154652407166,\n                10510576230334042050,\n                10924962062840002463,\n                15837684901594184503,\n                4027939380558138063,\n                4777859749711837977,\n                10339218989308260901,\n                1733730490652215991,\n                17672772903076977070,\n                4032065712363831295,\n                2119394036996489161,\n                987475587307386853,\n                16359915610191834692,\n                2709426785752979104,\n                10375088739222959162,\n                3980631508144303014,\n                7635434081101942188,\n                9892236427381386255,\n                11126971916211561413,\n                18061085022989404170,\n                4126100172567117562,\n                15208180968378211631,\n                6986134894614109495,\n                9994988553517585717,\n                2632796961456398601,\n                12453342373460829884,\n                18429381111478672292,\n                6111081134345892184,\n                11421541247114134041,\n                13469814569972052947,\n            ],\n            &[\n                4315916980033521479,\n                10449503521530616424,\n                4856252820643173925,\n                5526086074914510628,\n                4004011662776259923,\n                5158952861074217646,\n                11028260963063447109,\n                1944236596442929396,\n                12978824640840365242,\n                1151930226841764512,\n                10613193664134350842,\n                3406265646941928560,\n                6672407465186936153,\n                404800540740440978,\n                7124533336742235930,\n                1535890670990966696,\n                9493802817341566679,\n                621347847648491799,\n                17912640652451605620,\n                2057204868614013785,\n                10921553714374066298,\n                15047552947027887029,\n                7153383190925766965,\n                15249704771014948657,\n                60519377435496530,\n                7590844620858428748,\n                2351909720781490663,\n                10190678499481197044,\n                11234076827730248200,\n                8663598726765213238,\n                14736154147389138508,\n                7450150289749363751,\n                9994057649404380563,\n                10753782001926929150,\n                10644356419589646708,\n                15190339138217087552,\n                2505074458053073474,\n                16648880076747597464,\n                7963405054197062708,\n                18208284408934866346,\n                13858469707329190922,\n                15486996602241633122,\n                15371317889350309918,\n                4743078453820751273,\n                14468006621724512200,\n                11417572129138578356,\n                1945302117073820127,\n                15602118317671954659,\n                17407209257242841534,\n                17548975927464502643,\n                13226541172879034674,\n                2166519041665030706,\n                7724204530219097389,\n                10010504212552996397,\n                17838743458463889271,\n                11013562737265801641,\n                17168811270168264857,\n                5237040028916263925,\n                6323527791308699056,\n                15194073900873025387,\n                3202913343800201178,\n                1168012655630214373,\n                9877657453665156045,\n                5804139521458303612,\n                6595671049679611796,\n                6954590572896979451,\n                4507247193899927433,\n                14712120891718480637,\n                5958832049354060597,\n                5425095238966069586,\n                17880721668223019279,\n                13362575027039102816,\n                96566741790470098,\n                14428275782443426147,\n                7864448756177300200,\n                2963734043870314563,\n                3442157303656685599,\n                8099372328576403206,\n                5242482823389764537,\n                16276205423603762402,\n                9018844860545664107,\n                8496776552307752745,\n                3126198658080841968,\n                17584426086604861041,\n                1756526742975593168,\n                2722838766637822731,\n                10403662163231417462,\n                18139392105860519830,\n                6989823411439348939,\n                14393884001575488137,\n                1056172704485379305,\n                2679761112328917598,\n                9221013185085765008,\n                8290458915554542198,\n                8622981061497119850,\n                10021485082278739094,\n                10922752463306949341,\n                3289501128306314106,\n                17397609516531025243,\n                6547400758074542842,\n                15604289899859356945,\n                333978770812190992,\n                18218065973916833475,\n                16127810661386041132,\n                11230122129491639064,\n                6981851969231440484,\n                7558646420357403778,\n                14981775577710827750,\n                1746996883223053842,\n                13747448642231442753,\n                284062948563354937,\n                16854308500433009747,\n                4830313735216528914,\n                9674939829599862099,\n                14383486138223897061,\n                9922042067933595738,\n                12607420209760730250,\n                1163951431708057810,\n                3418701428468514056,\n                3177302917570982047,\n                3217945469089509208,\n                10238490471876301438,\n                5914047890159119576,\n                14313932311282384038,\n                7873142415009831359,\n                4600498391648960475,\n                13057538823866330734,\n                3217841119719619774,\n                14930867195971443144,\n                14900443877098569143,\n                13613747010984006363,\n                8607287334267369143,\n                16223902093134349994,\n                9855946615528227230,\n                17467986127811625595,\n                12851343650380341965,\n                5268799467297904422,\n                4860865339571653719,\n                7510950311328510427,\n                9121129615704026263,\n                9985294510085760109,\n                14647944548541534193,\n                4617350593903353212,\n                8812378543069741404,\n                14071575867988825908,\n                2197500103128929398,\n                17867729371980602795,\n                4932436132645521745,\n                7924275711546185628,\n                12144473368809175292,\n                11700647470688753729,\n                1944725794374986851,\n                17806041080297052928,\n                16379940501892332881,\n                3902394385929377917,\n                8986013537553457661,\n                1385017881577471384,\n                14464349274173417728,\n                2673059619166647089,\n                3060973120132903588,\n                2757656221899057349,\n                3067604880707584831,\n                2601234120306252174,\n                7813691230943610885,\n                13146165512554955859,\n                17640598915084737523,\n                2582363950458650017,\n                14304837210049245270,\n                12688683908862842695,\n                4386971208506064471,\n                8522626829538031462,\n                17452505302106071681,\n                10361450896110735337,\n                10033458480810018017,\n                14206004007517991051,\n                4493284979823281928,\n                9561668643117213356,\n                10841903269895892982,\n                11911984372297937793,\n                5781966583230334816,\n                9995084957311531830,\n                15667884071677615567,\n                17480826442761249432,\n                14163687943258512351,\n                12105651512320717073,\n                10102397412947964263,\n                4152524068034934712,\n                3440079042684086691,\n                16421551598963516241,\n                7663030021306742265,\n                13641230882631300397,\n                16458918411371638964,\n                11750365409353937867,\n                5836777064043393355,\n                11948592356238334408,\n                14094063963862587516,\n                763866157967517588,\n                2553862217811471056,\n                4978286061786547408,\n                5951252532271028398,\n                2814480147432244251,\n                8355110176394453512,\n                955000046590858084,\n                418817683267489635,\n                2375669799293008536,\n                7741560113544470025,\n                12527540215014459606,\n                4807648140530199663,\n                1917176557989775622,\n                17997529450210348748,\n                15775937348841841853,\n                12596647388874725944,\n                13005922925492525774,\n                12825247172998644416,\n                16941346907459597295,\n                5414495758637984503,\n                17648512745626862850,\n                11441048783055867665,\n                2036278509733973065,\n                5315013389272641810,\n                7534399943553945358,\n                13985254988036165342,\n                2129886592790964187,\n                2867979934993314327,\n                13920262515085521981,\n                17918001318024984167,\n                3987525118516777291,\n                9181953991016110928,\n                6703466246932157306,\n                5900079110331853186,\n                9052887944141651668,\n                7478034775976637552,\n                3278041148445352516,\n                12130157979346423214,\n                16449898609250782176,\n                812026766466081590,\n                17656773672307181547,\n                3744388208002889360,\n                3791099528357775363,\n                4068520361909439414,\n                1959438401502413602,\n                11329035886548464086,\n                10221578524418919372,\n                12980191277097844908,\n                15691976303951341468,\n                2706299845840454932,\n                12001725521641928149,\n                10405356943915977601,\n                1550503560697397676,\n                18146165230312144992,\n                8775540381707621983,\n                11230591336406034981,\n                6228681596165483174,\n                2133581336729418768,\n                12129007378508537384,\n                12921300519235974025,\n                9375678805406296547,\n                3613435617709574498,\n                13499610044718144807,\n                4451336373698242504,\n                2534710693960094303,\n                506672095186947791,\n                4599686050411382715,\n                10283437000867486258,\n                13944373918161748057,\n                10749539207857035250,\n                3256947136842373881,\n                3968459069819041327,\n                10310512027304093296,\n                12371354326187333906,\n                9649271905569519482,\n                18149492230911698719,\n                18039253857035728470,\n                11544885873395786648,\n                13115665719718705181,\n                5883323805103076804,\n                3340581244109826221,\n                2740719998676740975,\n                14211314271529644273,\n                10971959826690424178,\n                17661039620102652400,\n                2681458501156387899,\n                5479854823106014662,\n                5974561045219278043,\n                8473215965038242639,\n                5583715930653494870,\n                3470313942834108737,\n                10304624977365929872,\n                4990026433557930610,\n                7637937049242001677,\n                10791009944394783717,\n                15219205922075360764,\n                9002830569992670547,\n                17065169854478898187,\n                12114851395722862577,\n                1902980232892183122,\n                7339703717537327983,\n                11311240986114825051,\n                8620902745551541255,\n                17653580530932288202,\n                17446311100802812161,\n                16853776905767232590,\n                13528658510971153664,\n                8133142991621414981,\n                9198712440714819892,\n                1307139024561145181,\n                5651509534538305425,\n                15500876791491139019,\n                17261865242402821483,\n                9959143234495304378,\n                11774306485096011083,\n                3518307525093596569,\n                7341017580248227715,\n                14703612145595470399,\n                13172639134670980973,\n                15947158997811220828,\n                4125585181533726245,\n                11285884221627271297,\n                12648910027228429661,\n                3451176029776968001,\n                1260658404823488448,\n                7386532199423374411,\n                6316655514361401347,\n                874446896878374135,\n                16116423058515004551,\n                16702770564150696101,\n                15010314591562646705,\n                12772639082035296672,\n                311476976636214455,\n                9575298239012600874,\n                6021099187287010095,\n                15330804127436984700,\n                7874626841370189235,\n                4317595748546784391,\n                12774690740232998893,\n                15545525633486974557,\n                6452739508938620757,\n                17947552420114643348,\n                9263225273262064697,\n                12599141493060226685,\n                5119406136789734734,\n                1051975011747189152,\n                70796958152999221,\n                8899487974683094789,\n                17856135838574362662,\n                12228587125188734252,\n                2703592016861351703,\n                3828901820603468627,\n                9226218297991283269,\n                17840028174806686402,\n                18075865263748024826,\n                1008172625769821573,\n                17053104036036352842,\n                2643037037180017789,\n                4043044186653414452,\n                704036817524553677,\n                3469270838261112340,\n                10578260962346328018,\n                10307304960872788772,\n                11100501830170637887,\n                1321067784267748201,\n                16370290911883104830,\n                7277997026279002914,\n                9194370955407098554,\n                11697789085283623477,\n                10882102725986890548,\n                879575900258556559,\n                910006071300607678,\n                6634060453928245455,\n                7018272357233154950,\n                11323085799124732661,\n                12126704870344489768,\n                8719425209364909409,\n                16077720234498492898,\n                11214722890560245831,\n                6014665085557683621,\n                16140295979403357547,\n                4017919047975150715,\n                11618339290071597454,\n                8158854164475996114,\n                1011200605525249603,\n                11363709319397659744,\n                1454324493486065313,\n                11129023648824172197,\n                13020217682594858999,\n                9576952898239586398,\n                16616477346929370162,\n                4371687970173016192,\n                3516034006703213050,\n                2937269151616655609,\n                16747880970476287063,\n                669709731153728654,\n                6519853652860201133,\n                3659032765342780810,\n                15864573400056223462,\n                6297095765997928564,\n                7110555922376283110,\n                12550039101483110657,\n                11249126606834391837,\n                950080327127089799,\n                15797663250049566938,\n                14397834648452338482,\n                1543039640649750930,\n                8341556893541845701,\n                8116982948323973962,\n                11495256912967207206,\n                14766071288504085467,\n                16705412473803765100,\n                15090506094727735986,\n                18163874144022445889,\n                3916968151577833899,\n                1879421924266860262,\n                13373480014502105640,\n                13041781611237972179,\n                4588441522074875825,\n                10845619956267400739,\n                3765600421600530679,\n                2843644382474146543,\n                15132659436045892883,\n                17171692480556923795,\n                5511726102977095602,\n                8616390053076116361,\n                287094189132243978,\n                16223004946374614921,\n                6933607314950995247,\n                9122079358883202054,\n                12052612540225242210,\n                17627899458327225659,\n                14820053630940743790,\n                13081262502511482639,\n                9047814330512425859,\n                13819374748836811348,\n                7420314415541064490,\n                14372043945426241322,\n                2870595232152592358,\n                5825108302965985850,\n                3862751306343773746,\n                8297143078061668797,\n                7623527790129832636,\n                14976108347586383938,\n                15504660286044115876,\n                2036590244330470013,\n                2396696097468395360,\n                2679032459898693923,\n                7254694992336225547,\n                14405708262513989917,\n                10988568636010211554,\n                14393755906624408223,\n                564784608828851932,\n                8920394545124086885,\n                12652866383919054316,\n                18214421540006560542,\n                12566908496483953419,\n                2267263971377502968,\n                709404620135786373,\n                12523996199173167681,\n                17951676580855933198,\n                13650747407959441932,\n                5824756462266699490,\n                2509616646477747837,\n                5107467310813142389,\n                16298586900092698229,\n                12700441253440908190,\n                8046451347626774059,\n                3010230833910681313,\n                10061781544557486512,\n                8463916499683381809,\n                8747329120239848091,\n                17820189950727523713,\n                15204506030714195945,\n                14056191164190175147,\n                5065311670562888038,\n                560164632281916303,\n                13209321978701212835,\n                4258270003760268847,\n                9871801017584276954,\n                10084189192084678352,\n                4825074015064392667,\n                9581605763592146729,\n                1918163350850726962,\n                14567773874300155163,\n                12638976926425573615,\n                3649380560217639658,\n                8018661822408339507,\n                11706665997779706276,\n                9943212030613917839,\n                15457711824935005280,\n                18428573928454707729,\n                3926330427544149380,\n                7530117517842274315,\n                10714583863650741692,\n                1570545389027504522,\n                4106262895329894829,\n                17297335240441020752,\n                15663839296267508861,\n                15407625046661333980,\n                14535107337220563598,\n                16174049732199757779,\n                18176047754016168171,\n                11399573902740750349,\n                5214080916822086211,\n                10430898001880200017,\n                8371115051436088011,\n                13474730252470615587,\n                18200790159037433152,\n                1982492498839193382,\n                18199849879554882755,\n                13198581683370037706,\n                9793735608111398723,\n                7320054643250375233,\n                16550404964849262419,\n                5735793832830119704,\n                17154806469016832501,\n                17937411786820605740,\n                10105704169377815273,\n                10847289282838740100,\n                11160609093695125779,\n                1612622088505295863,\n                6640550752178901560,\n                10559041691527414248,\n                8619667673730810344,\n                1695749010443858836,\n                1362829788780114710,\n                4786165899179147947,\n                17288418297634566832,\n                8293662777453621345,\n                8957181791504387593,\n                2223163959711304788,\n                16096735981526477251,\n                7019659893524176984,\n                9142198120820553927,\n                9989692970304817734,\n                5594683658237316423,\n                16694216368899223114,\n                2065885423694944515,\n                13511522537087683010,\n                15544029444344603365,\n                11829821522884913752,\n                13656682188207614177,\n                13642072954609141700,\n                13491639210730977338,\n            ],\n            &[1],\n        );\n        // - n >= HGCD_REDUCE_THRESHOLD in limbs_half_gcd_matrix_reduce\n        // - n > 2 in limbs_half_gcd_approx\n        // - n >= HGCD_APPR_THRESHOLD in limbs_half_gcd_approx\n        // - new_n != 0 third time in limbs_half_gcd_approx\n        // - new_n != 0 fourth time in limbs_half_gcd_approx\n        // - n > s + 2 in limbs_half_gcd_approx\n        // - n < HGCD_APPR_THRESHOLD in limbs_half_gcd_approx\n        // - new_n != 0 first time in limbs_half_gcd_approx\n        // - lhs <= rhs in limbs_half_gcd_approx\n        // - extra_bits == 0 first time in limbs_half_gcd_approx\n        // - s + 1 != n && !... in limbs_half_gcd_approx\n        // - extra_bits != 0 first time in limbs_half_gcd_approx\n        // - lhs > rhs in limbs_half_gcd_approx\n        // - new_n == 0 first time in limbs_half_gcd_approx\n        // - extra_bits != 0 second time in limbs_half_gcd_approx\n        // - new_n != 0 second time in limbs_half_gcd_approx\n        // - limbs_half_gcd_approx in limbs_half_gcd_approx\n        // - limbs_half_gcd_approx in limbs_half_gcd_matrix_reduce\n        // - m_lens[0][1] != 0 && m_lens[1][0] != 0 in limbs_half_gcd_matrix_apply\n        // - n > mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[1][1] >= mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[0][1] >= mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[1][0] >= mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[0][0] >= mod_n in limbs_half_gcd_matrix_apply\n        test(\n            &[\n                575467399379548741,\n                13839490846250736437,\n                4628353154773839253,\n                3235160437296904652,\n                17926538529589113070,\n                16254839488328114822,\n                415479271776402024,\n                701612307177551527,\n                11282731308138649969,\n                15549163798131727182,\n                9275741579154885251,\n                17195569079203512713,\n                16631195896462029517,\n                11189046172373216916,\n                11335804956694503413,\n                869753568386833458,\n                15161202273898364556,\n                1685153641796888684,\n                6519812799688796045,\n                9450660698529279434,\n                3976001355746699381,\n                8755860526328087486,\n                9379845976868252993,\n                15449115864235101519,\n                6189820805905752291,\n                1999656252072726648,\n                14614135148721558801,\n                9412442668458141131,\n                4769782526372985369,\n                12603364410326539145,\n                13266305682919253319,\n                6179093516856398542,\n                11728866005263196505,\n                591231256352012886,\n                10891822735763494610,\n                1379643190812867975,\n                17915879013573969253,\n                15654737824492381077,\n                1665878964172006292,\n                2193929907146049204,\n                3753704553030045025,\n                2643617658743102861,\n                11826899300652102169,\n                10741401269021818528,\n                16693959619336879180,\n                15822691007875207875,\n                10165667636444252806,\n                14646332733026063930,\n                14294714305812123116,\n                3675743870135516810,\n                15588872085226591434,\n                12249381630026428042,\n                14466388694354825190,\n                8226637301182652689,\n                6338248525489182911,\n                8273376484864616169,\n                12903702679068332011,\n                15684253830538215322,\n                120323452105612013,\n                15775771470841035677,\n                6517337253986486974,\n                5057172938462112267,\n                11146259301803018301,\n                14217857571428393275,\n                766104140274144406,\n                10403765575570339080,\n                15356388955716644394,\n                5960156924753840614,\n                3826246010691114683,\n                5270840977803713435,\n                17897998794972987383,\n                10234944855653803379,\n                14541987689760337937,\n                12820656189348873593,\n                17473239792591314758,\n                10637029214964504494,\n                3122622009615558433,\n                8796921122235952176,\n                15762598310456891225,\n                11517241390289576301,\n                8995337670147793236,\n                16090454643652603796,\n                10491545194936292088,\n                10581918733379812780,\n                15469777875510035481,\n                13740696746710275167,\n                17697148650091366126,\n                4516632692241420113,\n                13479012489115713946,\n                613181577666567755,\n                6543068365906077489,\n                7140413973568370039,\n                2632693564220941486,\n                6548358243833847767,\n                3580011453626046476,\n                1595786269113597220,\n                3589869122329502051,\n                7680790515161529472,\n                7672816417510866152,\n                9617378297316545875,\n                16326449292469902699,\n                3356438369767744837,\n                13626365580692467927,\n                14645408437700981054,\n                8993455766562141654,\n                17100348831087759519,\n                8482398362235761502,\n                9005320120246465195,\n                13985608369059524000,\n                4578760409329988524,\n                13471973404906324912,\n                13767793875782618021,\n                13576218399241367176,\n                8607505428292681990,\n                8640829853824545675,\n                12917106086264067348,\n                2578206011448221694,\n                3353125869856782607,\n                17577121109228709335,\n                2905314237462392356,\n                2331575639922950207,\n                4757803209372475504,\n                10407523519854888205,\n                10427101613638544570,\n                10653559167855267862,\n                15969139228571015937,\n                3229545277738910965,\n                14459186466317664575,\n                2719373534120139652,\n                2311539788396444793,\n                919197711709305677,\n                12869313012019772102,\n                4142489328916681739,\n                5563346075417511527,\n                17320278674721747488,\n                7600057562482304294,\n                137102128861993913,\n                6729510908740032907,\n                2556227730136563134,\n                11485309894508721441,\n                1975505609886762679,\n                7418018451444286248,\n                3280800891052345674,\n                11300546422663834076,\n                12023912948840777770,\n                14142233633360973935,\n                6536078661153825094,\n                6708126313364507897,\n                12979314974688288248,\n                18110797927987234453,\n                13375595970475713854,\n                4145852684577155155,\n                13282868696425541670,\n                1506114690671120983,\n                12037668219018850757,\n                9552135080245814694,\n                12689050870789160910,\n                9641464072414519358,\n                17404100951282287670,\n                584528148396378983,\n                16991192139314454706,\n                13435398806093646746,\n                1806232481237325720,\n                10525369207353922053,\n                10539096468693644137,\n                16823332166945560763,\n                13216271451931684405,\n                4272527731081782876,\n                9174012089272655562,\n                4803739085170580403,\n                18043308998760359964,\n                2466414918609999948,\n                299112418477190901,\n                9176472152403710719,\n                2100151601463253457,\n                14066759482920415398,\n                5442308713266599475,\n                7797794762570542387,\n                906654145983003262,\n                15049619616558215358,\n                13797241706831616579,\n                15969242154524883291,\n                6664585166752881617,\n                456998176808935659,\n                6372085307953904476,\n                9486438637948175687,\n                6172262737033149469,\n                15771388893063576724,\n                16211053079428108900,\n                9836380621269080797,\n                13835412758795578440,\n                13022293692163806538,\n                7291668881817289573,\n                10943660404337870608,\n                10465252139732007687,\n                13584635332527095924,\n                5217773945105333432,\n                475626079396510382,\n                10012875662407091202,\n                2294484038393548897,\n                17235255650481874514,\n                12855466329954989704,\n                7640972869677452753,\n                604066466212666838,\n                14544408987813543082,\n                2255330913952415488,\n                11487976173612122909,\n                2606969224171147592,\n                2732228719296019687,\n                4805516573329683679,\n                12510535481770618043,\n                16080547195251234240,\n                17158216987147533124,\n                16252483889283702887,\n                8566122285474978824,\n                17992433483153604641,\n                9742248099517142775,\n                11846307866686350293,\n                10183020136820942338,\n                17751314439768932469,\n                706526091974895358,\n                16112150740402760937,\n                8208604329380417289,\n                4681925112017699576,\n                16023990145260210172,\n                3147541399400389021,\n                3572534572158190145,\n                8720556900734060281,\n                14350849130427767056,\n                14103987208350104747,\n                4009902137374730692,\n                8642370345566348130,\n                1509235310089233775,\n                1803584577779548576,\n                8103474899679352369,\n                7632155887896411012,\n                6720505338030753233,\n                16056811053006708347,\n                20245868804036263,\n                7392162968739567715,\n                2667133607635776013,\n                4088935200661832474,\n                11027949378461390904,\n                1298518526076811529,\n                15048847519112317617,\n                12370787403008587786,\n                10126193873658259058,\n                16077210093715640601,\n                339546017124009341,\n                3262625473090659650,\n                155522514636863280,\n                17133870939862804712,\n                3881378537141359797,\n                3319617006815341131,\n                408938678387296349,\n                3519452531868310218,\n                9151628810034763447,\n                9069824551063458035,\n                16175438057441830093,\n                1025725608441043501,\n                5528120455681184714,\n                14962174970099838556,\n                4628262249268118080,\n                7668604952914400894,\n                14421245150669261123,\n                1475685311148681328,\n                17331200229977607,\n                7008482707614634954,\n                954865196375036588,\n                12721130434144713155,\n                17772110747932936263,\n                14883220430477114612,\n                8346701667063923797,\n                18346426769719184589,\n                511089516893085384,\n                1049490684134535594,\n                2717769095812545487,\n                9939780542757419537,\n                178653728154192874,\n                13977596259293439969,\n                16604267703708773284,\n                16824820253288999719,\n                5015044192952183202,\n                17285062680923371961,\n                8633846623132382042,\n                11767312170862342174,\n                7070173857681433256,\n                3195337349333954080,\n                10624389626802650454,\n                9952227996635558303,\n                16103075034219456497,\n                7190762260873686947,\n                7637572995251515694,\n                2880941320441182648,\n                12986992855187366282,\n                11480249557832197501,\n                10992570334494572171,\n                15293473353050840400,\n                9953353185709986649,\n                5473168766758534422,\n                2273834546925865179,\n                17481576375175014631,\n                16007610327482007771,\n                10021685763866120088,\n                15140422720183585810,\n                14599059403330408270,\n                10717864391356784188,\n                11043776937872366176,\n                17231223364983083606,\n                9444955609293032145,\n                7583866547951445190,\n                15822743417483210898,\n                12379430402523343421,\n                15499380185272809582,\n                3872771344819526970,\n                10944774603860747612,\n                11364607709396745305,\n                12930627891344540854,\n                12649577033823599142,\n                71081790476548864,\n                10661442845094180250,\n                3320677886965881318,\n                14395511939432853712,\n                7178607417614281470,\n                10608904905068105566,\n                12919112359212522946,\n                1457156061186787292,\n                2630619879897285370,\n                10619217959672149607,\n                17259595048026584368,\n                18382463142617996350,\n                18080737559467551761,\n                17900172273670393807,\n                8256196626665198496,\n                7885528354153161605,\n                12390361365175881721,\n                16121675154134812463,\n                7006162423030601567,\n                2487450624947473633,\n                9170525836949058136,\n                17199587696327682411,\n                2778440771740106085,\n                4214370535755222213,\n                10220293195635704465,\n                3494084265135192718,\n                6536254103726059629,\n                15347315270124235902,\n                3035309337163064046,\n                7593827964874002724,\n                6657250220369903762,\n                689162306084882817,\n                16988617413925292293,\n                11542800279639267463,\n                1161396193556683066,\n                1404354998405277747,\n                1863751006442991062,\n                10942498162725872124,\n                14089151747681183597,\n                12287715267573932219,\n                5639989966754469874,\n                17232323616379757319,\n                2169863596718309595,\n                15913207380900188862,\n                17154942699109451282,\n                1054068200576663493,\n                8407670488993208585,\n                8297969397912590617,\n                3923918644147518797,\n                4050822028508586151,\n                12069177518272170880,\n                5457932827045810178,\n                4319428590498199749,\n                9292628295755403796,\n                13596479411267714291,\n                18144016285235947108,\n                12061613157169340922,\n                18436504313134004880,\n                10205373579634205498,\n                8932673649062542092,\n                8602267798898562736,\n                8434725739455235221,\n                14593112102164617091,\n                17742461694491219842,\n                1082380225638646367,\n                14627119236030669240,\n                2111648930588633111,\n                474310462095504152,\n                13588341283759929919,\n                7334643839189036863,\n                12082398814720285337,\n                8117633276713593164,\n                12226067923217154647,\n                8613740435987095407,\n                1720065821455369500,\n                2278123359132376316,\n                17520489735769768440,\n                6164160529494561583,\n                15817606273461591467,\n                16954590151677190424,\n                15025003150656907625,\n                13700051717872658120,\n                18267946311324265571,\n                7224134171579686436,\n                10357746181071061772,\n                13702788007820740199,\n                10454471612142559644,\n                7972010451335281611,\n                6566222485717554672,\n                17140404477880114834,\n                18107075263792008325,\n                14436650980335290332,\n                7462985729135152620,\n                4479257078280106616,\n                4963716523662716997,\n                12351075264308888998,\n                9381613057424655832,\n                17915205681210289409,\n                1103301032493960092,\n                7390733404857910899,\n                5646956458723265003,\n                6881852031997766673,\n                11474462020537223114,\n                10074504892595096981,\n                18270265530986154110,\n                13033898379492425364,\n                11329340856110014657,\n                6846873962487852009,\n                14679284715132950511,\n                5762958206899451423,\n                16858950997373083608,\n                12658415513768184148,\n                605947486630544932,\n                6969263633905442272,\n                3234937740604341173,\n                1110148774247830933,\n                11668278583677202055,\n                10407754098687553297,\n                2417686119102800672,\n                7530424168582333814,\n                3002680222699095327,\n                15704675259272891668,\n                6690366115936985010,\n                16337949845558804413,\n                2409247934459548168,\n                5864915702415821624,\n                8338701638724044373,\n                10371049922614905160,\n                15037630168919872234,\n                16870779050531029337,\n                11956871297691917533,\n                12868211179118475395,\n                14334258502588542830,\n                13588326263831172805,\n                5710629666230160718,\n                15210061214358246229,\n                16673563803302426473,\n                4360718753401653475,\n                3446288193042059415,\n                1969211299957512841,\n                8046929029837267934,\n                15830991705791077436,\n                10834502346805259928,\n                9453135954245593947,\n                6441617549735024559,\n                9334325755693495501,\n                4869716018763257456,\n                2055831415614097075,\n                15166689527799496398,\n                7485029880680080630,\n                6151920967401870361,\n                1397222502143791728,\n                1505614305862413992,\n                1461010374171129069,\n                8184035195339364309,\n                14399586491732116557,\n                12965712207658014223,\n                15682106046619552556,\n                1797345002211603047,\n                5346629789286835515,\n                7778106305028050324,\n                1706742763731171237,\n                10724467824751483089,\n                12579419113050252513,\n                13399259254836577641,\n                11915423084091485936,\n                946678182575130804,\n                16458121607357953511,\n                6990972249370508484,\n                890502451259139532,\n                4270424368509631593,\n                8247545724300513941,\n                1801612845852339952,\n                17483758041308719540,\n                6916086592936859862,\n                2737745973138711233,\n                2417887524053243596,\n                5384664014111896333,\n                14943057063528297642,\n                12718394952034204173,\n                2446982003060425908,\n                5936547835318690226,\n                17541689392918972185,\n                3455600047399472979,\n                11462977481241656022,\n                7740652593808978357,\n                10168544572978624960,\n                11513860485512401268,\n                3032850452841422431,\n                14616088035414255613,\n                3419881191634612824,\n                1329030780492877420,\n                10207424479064655105,\n                920157290452308485,\n                18230987435407639144,\n                7055850666076657796,\n                5759861191162096611,\n                964791846480760906,\n                6298102481822543476,\n                9631778414172323400,\n                16943337751488106591,\n                3139604193492917469,\n                12954525486464279958,\n                7171879659975320847,\n                4855521043517721810,\n                17861560950998429622,\n                14439556530136032678,\n                2146560660676406638,\n                2477931805045525478,\n                18220630939687468083,\n                17480104655582276103,\n                9658906588685453758,\n                8900401944077573595,\n                4023418835120043589,\n                16832899872978339110,\n                1178686892293228748,\n                6270325765175673747,\n                8254729669168021969,\n                2574138951229186786,\n                12307389417966828562,\n                15258107791537644761,\n                6677177683840339446,\n                16181736336365239342,\n                9100009209370850781,\n                7463319891721190323,\n                1942611152231324238,\n                14939657768700897026,\n                11782521561154004074,\n                15467452972304115086,\n                4250458310696784935,\n                5671021285338647749,\n                3705241574832771219,\n                7348665909967657559,\n                53271397903297119,\n                5064947506099634152,\n                1740366402276272014,\n                17408710193712200177,\n                15448498405302092263,\n                6743466464363127079,\n                13994255903404715641,\n                4783992854853242349,\n                3539481428896870175,\n                13315689057294289634,\n                13906894805247831409,\n                12514428970190120434,\n                2383999110333252405,\n                12520070852614084840,\n                13941905089326614282,\n                3879009791548345242,\n                5979410257812776821,\n                3636697787393253030,\n                5008829046821158587,\n                7227070514537338449,\n                12200965607507694664,\n                7540152508302974608,\n                6967838404828435305,\n                17393893632848259796,\n                13461232236356481701,\n                13462754845856901516,\n                11871853053738474797,\n                17468976883674757298,\n                3137741177962244202,\n                14775774099242061613,\n                6439034393988288499,\n                18322704676228151809,\n                6195120941011064230,\n                5959979991317651909,\n                6056847048610236236,\n                17042162839256174523,\n                11417561881130884824,\n                15046047411544517103,\n                11443682701040972606,\n                8885365268842644015,\n                11048448950702337745,\n                16247143345753969584,\n                12368813636786226982,\n                15842543547151376353,\n                15534220375707255951,\n                9323544182631077818,\n                14651867219777215640,\n                9676432759358709067,\n                11349135523271337221,\n                12060786354814026861,\n                8455537878716528518,\n                2516611220455718552,\n                2834697229574266766,\n                14026724682567928496,\n                16194065834422785902,\n                3536210387556942108,\n                12326677060567301436,\n                9778401785405835160,\n                8484860443802595491,\n                5813709913322243461,\n                8582854521396621439,\n                7760384300089398842,\n                15214249845203742378,\n                13051924444243483780,\n                10084811846899799566,\n                18409493367524167584,\n                13375466455709327221,\n                6692904664653654257,\n                2974376177859028080,\n                3466412890624951601,\n                5012652013243004425,\n                11419071376621362405,\n                10316171806558216583,\n                5304122490809205486,\n                11763687800639718258,\n                16915991620777140302,\n                17449952616849033525,\n                16529039178071253953,\n                8027460945600074954,\n                8304586649338777354,\n                12754974260089353895,\n                13718817585228096432,\n                7288624726912044947,\n                16364439710625277815,\n                3691598768778868311,\n                2498599291857236321,\n                6150206881275523166,\n                879919669932726787,\n                3847940289848302727,\n                8973108085527702201,\n                8835099474718086428,\n                1775428154619381056,\n                9674646708055315901,\n                4804998374748022266,\n                15667197068183761268,\n                11671080770163037365,\n                18183825577612667035,\n                5196715115451817409,\n                15261256208797059090,\n                5927143056185064875,\n                17671549775031937034,\n                6124967124699154958,\n                13687636407913038076,\n                12821802172321286627,\n                4864176808142239921,\n                5229559739743490410,\n                6174384646073847274,\n                7112492701662019566,\n                9769272169645010501,\n                13117020385783746137,\n                14025298218438666393,\n                8279159244498971116,\n                2334429611427765108,\n                10286834819889245065,\n                176437083060235308,\n                18255037520240585085,\n                7311361854076984296,\n                11074214072414559793,\n                10912633555496661543,\n                17232209863183538075,\n                18034444892277254827,\n                10491712314983717396,\n                3133053357505241959,\n                6725182279679382786,\n                14409286461548123921,\n                11093186142603324357,\n                8906125291613303780,\n                4630236334690968087,\n                9064682117492342230,\n                14099842337035371202,\n                6795865635352330540,\n                9453610425174835156,\n                5504251706304899694,\n                10745438811936662910,\n                14010490525842433630,\n                13462566825848569025,\n                16518815534025225957,\n                2444138423121228954,\n                5677161677290594311,\n                3025414318278761996,\n                6832862260509708497,\n                10197340078921197729,\n                14469811983250567107,\n                14646056929411495838,\n                13731529545280703888,\n                16319880459285614587,\n                12262255476906895937,\n                17339208589673690773,\n                15977537099031596016,\n                17939410429932459674,\n                12993182878867114917,\n                17238534706082454727,\n                2053282981771798329,\n                17052484244277786848,\n                6511994569524351950,\n                8560880924849275780,\n                9955809746666973580,\n                17440412924022450091,\n                17993918571689756735,\n                13924657572680467944,\n                1305456412826022861,\n                5539105772156152375,\n                464733736235545179,\n                5605508855364158677,\n                12934212145390513447,\n                15031133559727375097,\n                5841364006666456088,\n                1367659995759183499,\n                42284530567339042,\n                16950527371076027928,\n                447288040070705023,\n                2086500570182007777,\n                7164047686888175900,\n                9253094623176419046,\n                9704031988894964036,\n                16219232125061732819,\n                134218840105885090,\n                15790690030012805981,\n                4913504368646859620,\n                6677364960496702314,\n                17441912887943685967,\n                6845050781100696434,\n                9944304098024264884,\n                2658333825110326706,\n                14495710831763589870,\n                16816753026986606684,\n                6108394693883656217,\n                3674825700349441172,\n                5455306879888392581,\n                11040129116055440406,\n                5939138794432433453,\n                10354992546645397455,\n                8132690955796952994,\n                4208614571757937725,\n                18389691378136656443,\n                9724927671847420016,\n                2111877634342327228,\n                11060010589057515988,\n                7413966364618415182,\n                1813137957718448210,\n                7364915359267899434,\n                5364164985059412672,\n                11301900090444374505,\n                8657891306154732866,\n                15450480317670354391,\n                6417954264199031581,\n                12414015469094402379,\n                4315624036191063136,\n                16872774353815857445,\n                17184838727437143309,\n                3265431588659804865,\n                812818791443395933,\n                10989782102893895704,\n                599436186045403275,\n                12236521865769865542,\n                5485432756957314907,\n                13060869015958528066,\n                1409406384233490669,\n                7232635343932008180,\n                5044656061617487397,\n                2740598907970496901,\n                5318021266376254330,\n                4866687283454287503,\n                2013910043464447712,\n                4064631991160546597,\n                14894022554846975453,\n                1002053896740550311,\n                1390923179817260512,\n                6747621518522632264,\n                16874591559626718282,\n                17148422615678889623,\n                7004449378946284875,\n                6029197897777350194,\n                312526901452736192,\n                8266420277206881650,\n                16202883668988805792,\n                5182030222897424979,\n                3955555814727488768,\n                13309653404546689989,\n                9715158796448409403,\n                15033855213424393775,\n                9207460156539719265,\n                13871549650556323801,\n                10311613446804515333,\n                6029742500327767946,\n                9239513459549335068,\n                5437631879089476615,\n                18257107349942274740,\n                12524770742693351803,\n                7714074761538734976,\n                16596296037668501301,\n                251038933261335040,\n                4226458194164141432,\n                9779997902902433133,\n                3030602692656943865,\n                9331391008102809870,\n                17747445712689774610,\n                2740918437486283758,\n                9665828446473412335,\n                13581408964710460718,\n                12469303281264099059,\n                8893571674672442832,\n                1379442413022712016,\n                18199326928352063107,\n                11320581769377597151,\n                14066714968631958958,\n                6105762775909832952,\n                4189227983184722066,\n                4883704839132061778,\n                9916861677661798965,\n                11462346480649342207,\n                14778409334292907777,\n                4493884456551625778,\n                5976634023115886514,\n                10089921274563850061,\n                10995886567862393002,\n                12514005106594925266,\n                13487422864108832690,\n                5949940164660002021,\n                3798824308267675643,\n                51594519353241699,\n                14042191609008111878,\n                1084198794703441457,\n                6187735363348137007,\n                2222453422075951471,\n                1977733178909367094,\n                1855687927268674141,\n                13507429231362965288,\n                4563427348875562453,\n                53052655758196469,\n                12248719414065642395,\n                4043781334046130258,\n                16594510413478092317,\n                9909324764498283904,\n                10006246414842585456,\n                6639900859435585807,\n                12538869588808265068,\n                671676141501348307,\n                154891531251131063,\n                407141030039689521,\n                14303125054294315595,\n                12519957692091445501,\n                2575047121342740832,\n                4442053191994286549,\n                7257403838939964182,\n                11301512346343729354,\n                5649479332294422836,\n                17444069867132128440,\n                15039830200779644809,\n                969922697460401557,\n                8850382822556140468,\n                17587617640514588961,\n                5792622618189642538,\n                2959871208851481004,\n                4002969457198766845,\n                14733844908986830364,\n                16619267403139166511,\n                4982510272869901766,\n                13969983195542601865,\n                6407607444387703463,\n                4503458032777136243,\n                13276938846993601029,\n                9999572350287586232,\n                6077554759008956961,\n                9914549221908685340,\n                9747419718740154953,\n                12283917679445155804,\n                12506018878600868562,\n                504483054041077175,\n                6931585527138520093,\n                2510695777487713047,\n                1217537109908330722,\n                6299518530600532997,\n                4461483227388303475,\n                345473314729953715,\n                11577208925864677728,\n                13714009284775997558,\n                9306564142261809693,\n                10493376611772360762,\n                12114735030824310442,\n                3723726520319678928,\n                13936502274367500072,\n                13361717531410065438,\n                11054299856501427866,\n                2346032701355553484,\n                16480112851446496738,\n                1716080732608071776,\n                13906214996195234076,\n                5677286823010362674,\n                5031920382916298075,\n                11682583709157560454,\n                14368427604644474820,\n                11974313857346928172,\n                7875781703666737260,\n                16031516164256186906,\n                4566375739076671625,\n                5097663793007619497,\n                12165327848553281827,\n                14159539264387775940,\n                17711785725905262208,\n                746306330982150615,\n                10618303353707428560,\n                16415694862704526911,\n                9426321299626982899,\n                203404317597163992,\n                9784341849958013566,\n                17737510091254724918,\n                16467553962565191057,\n                14963305126792873612,\n                7875246701602917591,\n                15395884754391863730,\n                7674782145333341935,\n                17779948927306734041,\n                4692271260276963472,\n                9147303984837818022,\n                11261482143084613378,\n                6771303715480347754,\n                1021253236102285456,\n                2938757268921792891,\n                8110317487741901284,\n                5629482782068783477,\n                14074967295738352943,\n                11830360745467057113,\n                16065773322812244383,\n                6799648256361227046,\n                10881530047107857944,\n                17272480164822477419,\n                14188187909112608200,\n                8492727723243508205,\n                1239958563141876800,\n                2396597814031561226,\n                6365846116588909456,\n                1747799098922280685,\n                12329761501577087761,\n                7103565661859178619,\n                12929732902203489138,\n                18130721204914820146,\n                7404709294083080877,\n                4076736505655677441,\n                13997485323848566931,\n                11355165264923013442,\n                6265382391023965751,\n                15037801805473945986,\n                16283172306662528168,\n                10784174118773201917,\n                15442466842568320074,\n                6792336536532509513,\n                6841433016666743757,\n                17062933928060878150,\n                17995161545501763874,\n                398314979814197042,\n                5371491177519133552,\n                7487291916923596074,\n                17726809651563472115,\n                4276741984609027067,\n                9063884951015483403,\n                6604298906930427610,\n                17639693268109172166,\n                3512896200182209296,\n                14176754219633674214,\n                13075641158366811356,\n                4304608617823480610,\n                6827519196509520249,\n                10991757902125467581,\n                7985198732976208765,\n                15286834137228061227,\n                58281206065522927,\n                13204561433899186751,\n                13223435687875504648,\n                2520091453248762960,\n                1336536536994438540,\n                2657040408513167000,\n                5767035770652592231,\n                17260962340791386954,\n                17641333140100333702,\n                9700277297324555168,\n                6985084747499361442,\n                2237371457239959946,\n                7946926051156145397,\n                14111197867527256838,\n                8805745012779252660,\n                6198429337106777414,\n                2615850794923160576,\n                11783140326213116396,\n                14893203149537487125,\n                9567314701273251044,\n                11695128483656617057,\n                647988395719472509,\n                11422708536691070047,\n                13239243760652390256,\n                16636779351598291051,\n                18437576843798320734,\n                13792983340413428549,\n                12074737915047871515,\n                17066180541625455492,\n                15179271581398274415,\n                8175824910139502819,\n                14714425222088264251,\n                1989693470019103578,\n                9855573943302266616,\n                6236520060938959996,\n                13109545139113435074,\n                13566528788838365110,\n                1410706471600329523,\n                17673327292701259018,\n                1282280051559055632,\n                9017178883540247720,\n                15228935123367154482,\n                1258177275149976100,\n                2018246390800272584,\n                14356985980164438273,\n                1823604866366992170,\n                17903023640589067433,\n                9347737820956061500,\n                9735146081773156261,\n                6689847293073153955,\n                11126271016334934544,\n                5994793191677038724,\n                3604730352973328532,\n                17605242569431998414,\n                10327617156260919079,\n                10682252855809435330,\n                9100234729746896760,\n                16993079188042570603,\n                11254975990606724502,\n                16242311059560795961,\n                14227003883755270012,\n                18285710061812359350,\n                7387005544448366058,\n                1145109023330252723,\n                15022228266755818179,\n                18168093935820946866,\n                8922807670716322377,\n                17623516307873116019,\n                1206890136710388934,\n                9516372380550133567,\n                10133157547696520694,\n                4294971167499340423,\n                9743061062772065165,\n                5377657584522832108,\n                14225392737899643394,\n                4157013585438895700,\n                10125549201612144267,\n                4100226799738447148,\n                2075172157465998108,\n                13195036640815520738,\n                6821431496943827604,\n                9246396951088662598,\n                9751868297178759982,\n                9700779142744360518,\n                3658815564772137188,\n                6538317493999171090,\n                11697362137005293086,\n                1923505046610352654,\n                475014807978174723,\n                3630137128781123727,\n                12150077442705041079,\n                12427124278971727290,\n                13479235332914334363,\n                5496164611508275158,\n                14936501386999605874,\n                8882652803543653011,\n                10952558904165612665,\n                6739207228856725932,\n                8456163010594333639,\n                10535813937687860141,\n                9505036768783170961,\n                11099064892618807360,\n                169745221320748492,\n                4707891234763005567,\n                7738425121897682831,\n                11404840688507500898,\n                8691505940234327527,\n                11771261818863120062,\n                14723964031553687059,\n                15287258300729004005,\n                7573783454674360892,\n                18179022528685282485,\n                13245862641188327159,\n                10588353385460229379,\n                2735402380843149021,\n                16860704493911100849,\n                9024623514323424705,\n                12333075916853020349,\n                18244278992464300971,\n                4867301239541398634,\n                1314358060529143728,\n                7666882040058016129,\n                13150073136816015157,\n                6301083950105345225,\n                13976444210903821837,\n                2060352136785153044,\n                16200698722576705758,\n                6460888606184453894,\n                16445752899318815973,\n                17179709527494545154,\n                15536997874687360034,\n                13022268941493329839,\n                2696716978218378749,\n                3362347068528182905,\n                13565362575501294811,\n                2079150969445622376,\n                4810345717233969931,\n                4472152818411820065,\n                6453260112485098774,\n                13356564228328639839,\n                17110313288592456745,\n                1435938168541586853,\n                7462678282816862243,\n                5371246349000737177,\n                8429218073787618630,\n                5346521300198079286,\n                12789353917659187733,\n                14442956055750007343,\n                15244751088029774551,\n                13297251472118828207,\n                7215676263905100435,\n                6007211881525156123,\n                9493592255758432036,\n                16602057928234062153,\n                16587917920906294320,\n                16979836431020046439,\n                13094140568345251281,\n                13916421500525839258,\n                5769668949157229760,\n                18086484472032192111,\n                15116469247160210173,\n                10732312892355549063,\n                12164027081808213486,\n                3079069950535673423,\n                12585139553289800020,\n                12875306561259226432,\n                8811443258909940002,\n                8124174848473646108,\n                15670453854511445398,\n                803566658286118334,\n                13806458323797710500,\n                4762982112857169920,\n                1859710041066580425,\n                15720087592804142456,\n                16303182845117023833,\n                855870575093385721,\n                4703327830937492490,\n                3313518290113627482,\n                1178633794722110520,\n                8354185752905946404,\n                14766290794342661211,\n                15214154729438679475,\n                13729401929312370465,\n                9011734493161906949,\n                13113532936632755704,\n                1345447462867773483,\n                6448244176056184701,\n                7012477124755342304,\n                15580038433286556688,\n                17848919842496199431,\n                10028316423612011933,\n                869027013079958907,\n                17009799055507152201,\n                18041218704541497506,\n                6045145319869314743,\n                12377421195637201983,\n                8449076291782840438,\n                1397849232559267847,\n                2187434984921684478,\n                3403378911422360969,\n                17480693808924740870,\n                982483816965115826,\n                15888731420268623003,\n                5280522824450934391,\n                18281748078592209071,\n                4719177826249662435,\n                1969348133672517676,\n                14302905663206015829,\n                3255827777415561924,\n                2578045746540552666,\n                2573896329300556567,\n                2391501373699313740,\n                4791581547865311205,\n                6247840047570325773,\n                2469705008517634438,\n                3056326695519610316,\n                14948296709540615024,\n                1062923194288577107,\n                16375392771639774947,\n                1015529378012280447,\n                10746830707201373455,\n                7715886963806302343,\n                16297406106746590647,\n                17715588202572550265,\n                13527139072558963929,\n                99211582412004024,\n                2711459600905895935,\n                8569541865276767972,\n                7613790287433305305,\n                653208029905987655,\n                1727854787208424357,\n                15748356304420272869,\n                9959409749691667969,\n                14291894407744446212,\n                503703217735428309,\n                7876851416985445297,\n                6431225480119190090,\n                449483234453843792,\n                11523298865591649623,\n                3435872863223259742,\n                9552329090845154230,\n                2896972164361149982,\n                1269310417738704553,\n                18384605444802363468,\n                1237780458899379603,\n                16910833523727563142,\n                4482981074603401198,\n                2121371960521454641,\n                7796532283059204409,\n                25790177388111233,\n                16120544267889484355,\n                6144232545049390988,\n                3521563904857210638,\n                556210369885776174,\n                8324534100827531805,\n                13516226267058770145,\n                8747429514104290165,\n                8026816217324859006,\n                15405579933448964648,\n                2482550910924013528,\n                6079310715073401336,\n                10449962361225046441,\n                5524633401100253579,\n                16053481108469650499,\n                2790101718009979348,\n                9301878289303197606,\n                997249373872362850,\n                27300315815771942,\n                17737705294943786804,\n                1424935685660120924,\n                8424798139585257768,\n                16211516871950763803,\n                12990358998177017683,\n                10249597119118506275,\n                18408586087691363166,\n                11438404066809034737,\n                11012584279891838821,\n                6696271295716018307,\n                9930416860933484049,\n                13215962566134307271,\n                15246803897725633075,\n                11387065919388119048,\n                2466603392488411175,\n                681132078373685642,\n                5130503773631633718,\n                2509149940966576933,\n                10411902793773420668,\n                3635262312863149371,\n                1603062208885790503,\n                9360721267289057530,\n                2678321596504669944,\n                249229520366360442,\n                17329668685637718997,\n                8915036515108497990,\n                490784964147667014,\n                14515392651593343599,\n                2409201985556015912,\n                1611664978682553018,\n                11850486551349563879,\n                13761189022094302350,\n                3698463909621999146,\n                12569860844893297150,\n                1227995028080714851,\n                16075767045086341788,\n                10199406988903905473,\n                17794651552362356270,\n                16092930490238021824,\n                9328723035395370944,\n                4734866727034661155,\n                2657796117079752451,\n                13923818243046619790,\n                16472136068270228914,\n                18058223245533848756,\n                15345222547995310311,\n                18050028532712597482,\n                13589945113509429199,\n                11522903866982422064,\n                17951848030650642905,\n                12633284474117061774,\n                15115880423554767983,\n                12930423604492456604,\n                13329164597703249258,\n                18338837626925469553,\n                6367228635373808510,\n                8371066919516397122,\n                2160980766020466019,\n                13425362939901273481,\n                10449588671756455076,\n                13946011226909253684,\n                6563076431328948436,\n                3467066912321557163,\n                13817709282661574385,\n                1954831874337376368,\n                13247212989673443019,\n                4305395659031332051,\n                2576959295441697293,\n                6896780844531978074,\n                4838944567483159792,\n                983435118873209304,\n                17099666216820037611,\n                7618027338181614041,\n                12740220343512004286,\n                15668003088622161839,\n                6307065336155032471,\n                12866355547695255339,\n                18105505267682088262,\n                309702548863399257,\n                11431934014429398771,\n                16337123462420112626,\n                13455974306445806251,\n                16619990986003346004,\n                7250047582443547679,\n                13575492233443252104,\n                13911871272758592885,\n                17460767687190632452,\n                15247929310408202516,\n                18331682218295863001,\n                261323487582141633,\n                7614661128980424817,\n                6422108758439359265,\n                2081056287942587161,\n                7220787374877583349,\n                717472904341595891,\n                17813723712700157238,\n                3241494416439598726,\n                12794513487028370881,\n                5358721158543461549,\n                4452065304298022398,\n                11030176201923581521,\n                9210001828401987024,\n                10912815101479991274,\n                7091546400312646488,\n                3013240817218288252,\n                8910956722230923212,\n                9054959438387840764,\n                16851843825181072249,\n                13414604809457485698,\n                12075986842954907009,\n                4658854495181538571,\n                10995225665179398310,\n                10440147773274056063,\n                3614430051441949604,\n                7271983795362664750,\n                3047687937173698630,\n                1994619618655862338,\n                13179073926046162775,\n                4202285970439440298,\n                1118379597613009280,\n                15519245009495040243,\n                4256675708756697669,\n                8238649640283351416,\n                7342244199313224551,\n                12880588809549328523,\n                1187652721118103080,\n                5424444711048922656,\n                4396267379797475032,\n                7873701471102341918,\n                15699709671604289187,\n                5918216801351035784,\n                10814352802756983884,\n                17646214522162102119,\n                16006963122846937167,\n                1430365631320738851,\n                376457101376932550,\n                8871916202315560716,\n                13011781717220903069,\n                15215597531017339743,\n                12289548108447181959,\n                7346780333055067602,\n                9224378704987626829,\n                15268931953997841814,\n                14041223036336774753,\n                8927234293163765947,\n                2897790799008400374,\n                14582010918862717675,\n                16940686021857041143,\n                17809536309397136921,\n                16537410647678046250,\n                11385770080898495399,\n                11058909064571773777,\n                902170224533021061,\n                6155050419392920377,\n                578026483489571474,\n                12192209733415829173,\n                9800697958307651530,\n                5325607519225962561,\n                5749788716129163638,\n                3339204573835152173,\n                11711084023976848626,\n                15800866735538093521,\n                11602514118015409575,\n                11845686896612751865,\n                12805561555388014296,\n                6833731309656940130,\n                1683693695029104238,\n                3252505788213114441,\n                12861064563156096686,\n                17880480561349418723,\n                7109337509100178473,\n                15672204595961079139,\n                12610706960087661501,\n                14127013368071208214,\n                17303281711208279022,\n                11071871840671280390,\n                13019666508300875107,\n                13450446740352112547,\n                5215478633835401279,\n                8173215137132965511,\n                3385959284242241690,\n                1162541066556458857,\n                3982176102869150348,\n                11033193378737041188,\n                17515896641420400261,\n                5108442075949478481,\n                7390295244279229703,\n                13200704351272018481,\n                7838787871014850842,\n                6967690604184701289,\n                17306979495731024219,\n                8091038377110761360,\n                8807486371208741534,\n                13035790401659421556,\n                18352767143317290044,\n                5794344711151456204,\n                11362614524307015732,\n                13861808480505787139,\n                10664293568977350297,\n                12429231307955906550,\n                787191891079923458,\n                10802046887566427941,\n                4479080089699981872,\n                10284905844912789930,\n                11562290707970545935,\n                10020771126265957209,\n                4492419641191856378,\n                8315733702710074653,\n                8179451464749720683,\n                11440898133834467541,\n                996731441922278873,\n                9874517357398478369,\n                3191161615687645368,\n                2749003557840473686,\n                9190738483349545066,\n                4941311214960612971,\n                7731219348943068526,\n                9841834562404157494,\n                4980436855570339065,\n                1530764681258350086,\n                699509151710528021,\n                13504108558405070318,\n                9218776911300271865,\n                194583242318484046,\n                1219401915806982494,\n                10269323235937088132,\n                16474197391285416186,\n                12429159956713323486,\n                16406837010296707669,\n                2096879123910896284,\n                9478062389402448298,\n                10390582542218348554,\n            ],\n            &[\n                5506952908463110193,\n                3806848119604616776,\n                15253829699929639786,\n                6153710766072962714,\n                7724992251147712460,\n                18274643156043175664,\n                1050131577594375425,\n                3075260137230555926,\n                527421990694193641,\n                7584901852578630990,\n                16965489008951068436,\n                6638899686914020055,\n                5548349519839988674,\n                4340131637208080214,\n                13231812794129139237,\n                5782596599117579099,\n                14707631542809621934,\n                13005413828836673107,\n                5027517060994695773,\n                2409119181385285185,\n                12072018513207904945,\n                4610121114335836886,\n                13007992267227833961,\n                10768178433595858647,\n                5655501324069419836,\n                4047945395373106430,\n                16148618693961270401,\n                14207121723132763208,\n                9303659817261703525,\n                6150302743552282248,\n                6626197242081859424,\n                14180443744733228035,\n                16111493454316570674,\n                14281519617792962564,\n                15852632623980128457,\n                843715310399868484,\n                371586007013897923,\n                10616674417688079376,\n                15194274051554944848,\n                13553160050325440579,\n                17628757169066045879,\n                5422077471618948581,\n                13336098216102409317,\n                17615444491978875175,\n                7561910121468822316,\n                16521387743687265557,\n                15893994794718565447,\n                14500498851291186914,\n                15404349041758659271,\n                1033447516621898753,\n                6046875549177986318,\n                14017892727616312226,\n                504532865625997473,\n                12327954595628496718,\n                16114003010774897368,\n                5123840833265554878,\n                12135628469575155214,\n                10148936972500311133,\n                270050642558637886,\n                4713725442176248124,\n                2061684810683917013,\n                5950651629769154975,\n                13856635522463752336,\n                3060080971213245973,\n                15505219872384321749,\n                15660711294880766518,\n                10399903341728067157,\n                6651665398472767861,\n                14008720726998708431,\n                13564382325331985222,\n                12275490277448149552,\n                1079407395917348059,\n                9571671064864316311,\n                10464498765191388869,\n                3257185038323220608,\n                16947719475258977056,\n                9041734436677629237,\n                13800437069910936773,\n                15077537963562816357,\n                8788516953891922746,\n                15832918598557989385,\n                14579847279540664520,\n                12622946476897850698,\n                5338253386688349876,\n                364868833142768548,\n                3894073811511765730,\n                10883504329458004367,\n                5694806037383475667,\n                17592653866771118524,\n                16359891716286511995,\n                11831511743093412575,\n                5346828754811097128,\n                11209687597326063736,\n                9730095457442822720,\n                10190594511925207302,\n                16828792882592167118,\n                4455664427487546597,\n                16063117532002702952,\n                9448048817668105636,\n                4972988473343674204,\n                3912110890459805268,\n                11377401507523354142,\n                11367029609143622993,\n                9108192617717426353,\n                1385875158717547342,\n                5297004339925541821,\n                159593902424474731,\n                14192871358313078323,\n                15224505595714662032,\n                6200287398085215168,\n                17286563738527915901,\n                9791571204583847414,\n                17516325043571924340,\n                14366344976190972987,\n                9435375229224263329,\n                6178661234763053743,\n                7945181496515342114,\n                9354008202308728070,\n                15540756784774251412,\n                17860277456202575278,\n                14209596746285961883,\n                9512088169794924312,\n                5267634490833581206,\n                1676119196958948766,\n                8311957173462535989,\n                439611748176266368,\n                5925545614682176396,\n                16253071308860013431,\n                12311940603650557324,\n                1541228309549358910,\n                15649818561737411196,\n                14275602707926342519,\n                13975876390445667038,\n                1479178557847854141,\n                3285270572845634784,\n                11593180894357303235,\n                1042820108092959158,\n                4253569036877676973,\n                403560233122940030,\n                9510252758318344055,\n                12102364779301891941,\n                17721965720899710575,\n                14089693913291613024,\n                11315184887553464912,\n                11126194784026669316,\n                18349021879540859921,\n                17629602484099316111,\n                11791433535374809407,\n                1403337479180362893,\n                1702732204405483129,\n                14577210696810087119,\n                10119062496336415952,\n                3215108150128546038,\n                9555329295127310367,\n                14813961943202590306,\n                3854717936189991211,\n                15305281209892145119,\n                6753116109099393644,\n                5167941309253736764,\n                4805407145840605183,\n                12052939585848547177,\n                13815002107314275347,\n                479262239434164167,\n                9984369164481245166,\n                32617941710885992,\n                3534732426571034215,\n                8949504569861129446,\n                7141129504706409563,\n                14837112786678223968,\n                12646159468354254402,\n                1634895633875002200,\n                4501516205577371448,\n                9599178568514083396,\n                6662855285932438630,\n                4249204762219666393,\n                4995345425484051611,\n                8852943034822615167,\n                14664266321575016915,\n                2189704958175050818,\n                8112056909545221404,\n                13405743490067994915,\n                12177032774091373498,\n                10374323912657667558,\n                17137017152638854266,\n                2894829133650272487,\n                3043154777910298559,\n                14556828612298618138,\n                10439272111024509541,\n                10616042914455131442,\n                15806801477164016164,\n                15930845540381766256,\n                18017643322697943023,\n                17619291702832936657,\n                9117612259919897577,\n                1044226778242844875,\n                14631310785412098609,\n                10136888858639713266,\n                14449349093679970154,\n                18069697024764971954,\n                7973459274000903425,\n                4238333360181338745,\n                1025957588977991867,\n                3591096666629647249,\n                5973242157764053501,\n                14633601316455469060,\n                16491905444740244101,\n                5258795269555777153,\n                7917683918101720763,\n                6957575575665285083,\n                12471933279161455709,\n                17374669784850184346,\n                10294948521464027513,\n                5365059148739477552,\n                7931647940471320382,\n                3732756674714358060,\n                5378482385455801316,\n                605630847399035668,\n                2662239966283783678,\n                15246382162602486789,\n                15502092928361596926,\n                14822462227958686755,\n                4355260933028095719,\n                1388811864175835035,\n                16111165341634520801,\n                3856506329330266599,\n                5480941990955834423,\n                4066690789803835796,\n                3446091266660667833,\n                4443837396874554687,\n                9382184593756836423,\n                3662513746157661468,\n                5981768571534548910,\n                7224757717208818003,\n                14120780684632575241,\n                9320634833813385940,\n                6667622706595582265,\n                16878293759452873978,\n                17088541568896866063,\n                7372626780022230514,\n                436808405518274966,\n                14252678732721446921,\n                2104869524947222071,\n                6631685410375788505,\n                2149637305151365415,\n                806417526627454955,\n                7421434493476719453,\n                1465989281562985011,\n                563947906496868418,\n                4704820607165988411,\n                8173652582005143181,\n                17819565157595430094,\n                9845347207851603114,\n                5241769880445368831,\n                16575699457001929457,\n                5985635078953360403,\n                15978649837734735596,\n                11510702129036230197,\n                5228690908831482531,\n                7526030925056215404,\n                3287154526100936638,\n                12117225562485013813,\n                16823232684363470438,\n                583977556407730332,\n                17697878485894786632,\n                3845824921059996004,\n                6726269658160672612,\n                18123920920510771001,\n                11508614555715257982,\n                5614311603142419893,\n                6606919581194165114,\n                10784854988123637320,\n                2264767800782756074,\n                7796673814299662386,\n                10902499857059539779,\n                11823788150079598671,\n                157113151127610790,\n                14352523930925726283,\n                8130167232929626062,\n                7847535894354429131,\n                11565590994444363555,\n                8077867159278395820,\n                17389179712963819345,\n                14935277299146800308,\n                14474917870682010210,\n                319588319279269778,\n                3134118488268119033,\n                9681404746624604797,\n                11814370242537451152,\n                120347778578480442,\n                11682962956864175266,\n                9032999928833956716,\n                8517160786434081542,\n                18099054458154837484,\n                6305653560187270190,\n                13238111375831798679,\n                195224219159194139,\n                10509000520281398525,\n                14440378477979315635,\n                10540539637383947317,\n                1816835103067453372,\n                12292190545991200585,\n                11929309142065466032,\n                14923664747079208466,\n                15293490320152873937,\n                9334278390697238298,\n                16215015280814728675,\n                13898634333978600541,\n                3445627973235322308,\n                17969481267516901478,\n                13335832845120597892,\n                18326371021140590109,\n                5890488708488729679,\n                4406980003802585112,\n                5344445953698019450,\n                5013673532816678285,\n                15961414409746022478,\n                18404414171806953543,\n                11468650198917792431,\n                15531825206300874617,\n                14738477539196458932,\n                8676622966697723522,\n                1368635071662477864,\n                6543668723466390118,\n                12114558566232943413,\n                2303004786445269111,\n                14170489424093999995,\n                1985671304134573656,\n                8331463571610542764,\n                3873015007715912993,\n                27894306076102606,\n                7104654970761334900,\n                5686730752548624804,\n                8233904160277754285,\n                5172053108218104416,\n                12113360256208938435,\n                10280077545660908320,\n                13821974650155757108,\n                1742749416226970211,\n                11654300655577230702,\n                14976077464467803998,\n                13890928519824763701,\n                13181570432818935900,\n                18400222548512349578,\n                4900627745620570574,\n                9237622473186007483,\n                8348806201397375307,\n                11644861466959244564,\n                7660774625358692180,\n                12640800868812968394,\n                10126105491751574188,\n                7963584681349558312,\n                996039405712308551,\n                15174300658579374594,\n                16133028349079126235,\n                15172075459306840070,\n                4754453455507644582,\n                2082474474919902411,\n                2006285022788280185,\n                2422722200295769492,\n                10019647931754062695,\n                16349712694947095249,\n                14083930401576374224,\n                615386692410750348,\n                12397858553466621141,\n                1573457883557036777,\n                4980959182073659021,\n                11443908431408514446,\n                6984262965031673234,\n                16633481031388421272,\n                4161251318834567407,\n                12821551347784643969,\n                6608155693481660229,\n                1611043482167472050,\n                15122218494830750408,\n                8839500240035607198,\n                15384724866021917283,\n                3070733572920490549,\n                8592993878808367240,\n                4271248517927408440,\n                10865144033685961973,\n                17023530530649284392,\n                3353462395956110692,\n                18120823811324392964,\n                10221129839711512089,\n                3227448551694007251,\n                1988380654856065045,\n                2242021796806927365,\n                13590775423321667198,\n                10692026012126777875,\n                11306555419118442917,\n                11316252767034863343,\n                18760321466791470,\n                1337100093785900848,\n                6492339287439306118,\n                12125411568967459196,\n                1797441814675370229,\n                1631938251008432317,\n                6985480655598205780,\n                2348176182416429294,\n                95412213746880721,\n                7175549597849762403,\n                2094795596458793654,\n                7829002790007311465,\n                14746732570765651081,\n                134877455607034691,\n                15638581748054019794,\n                7599776457298678362,\n                7986432103542221551,\n                7500529350917377326,\n                15884143360659537974,\n                9903748562237486241,\n                4664581449394265591,\n                2962548990311093356,\n                16023325614230646625,\n                10426247192951388751,\n                11003478360555882777,\n                11539013974193753851,\n                12270292209530478200,\n                7423475458257570239,\n                13100711480717389630,\n                16388389606841277356,\n                15191771423361849007,\n                18427249344570625913,\n                4348367306971908628,\n                7942807882176181032,\n                16409042118394465962,\n                863438358079742954,\n                1124736515135783861,\n                16872942745563460973,\n                5139090909118018177,\n                4669623391383642012,\n                5118057586113819116,\n                17891190081052445844,\n                14867908875153657094,\n                9390870292482891489,\n                9171235516940002341,\n                2343634198674654987,\n                10960182345705330093,\n                10619370169029979867,\n                4571519790281325513,\n                12889605798772993499,\n                15970143036917147631,\n                10001359583966733655,\n                4381102045316081715,\n                4163914690821122330,\n                6468638717365001528,\n                17479787593534552160,\n                7599949586205261816,\n                10593115230897863905,\n                10775345788560696421,\n                3838567407183537934,\n                16971529548430600403,\n                4980854155284411004,\n                5827837251392141026,\n                14830810846144815135,\n                3821271250454438306,\n                129239671811848792,\n                1581976158752737667,\n                2612788759361274201,\n                12230162761710825594,\n                10097159439277024421,\n                4401184023778243978,\n                1406084492350700231,\n                11938842502217979388,\n                7158646758876276842,\n                11154483509538442887,\n                3807887936265348548,\n                4411855765274191285,\n                14464002811165395280,\n                670130159021436363,\n                12640940208761414730,\n                7728254476113900072,\n                8282009448283823101,\n                16968891258239181965,\n                3688865346582500831,\n                1861487375161465963,\n                18109147777912453913,\n                14054735663838606991,\n                5895084269872329312,\n                3180503889143088947,\n                16735588978438822575,\n                8938486803129382823,\n                8074810307626673403,\n                9199264274209535698,\n                16453402421557915146,\n                16952664837297462870,\n                5161275365544152420,\n                3147874599125818621,\n                10656989901498080537,\n                17283970806496112517,\n                11904772904109037898,\n                10815600643737317830,\n                4190612046695163764,\n                12931964669364485889,\n                4640956854723597761,\n                12010307958665631876,\n                1817311075096228914,\n                17760293859189071748,\n                8658199478093129696,\n                5980712071282278126,\n                11751139410599894151,\n                13230413742965562522,\n                2646723965833712773,\n                13682876666838619530,\n                10800431924235403175,\n                13382436438625160191,\n                15176810074556266548,\n                14653393669910477601,\n                3089870430325875498,\n                7482067547555813276,\n                9577971917293864659,\n                6960932610226841152,\n                15130393967538609694,\n                6648313153230285085,\n                10536236724893566776,\n                1093917583121871970,\n                17300922283598420212,\n                15626332485235410632,\n                5710388017071160883,\n                16425715338132198876,\n                10099451213347819493,\n                15114188552391671070,\n                5219737568429214388,\n                10291251738376368665,\n                9999550435891258477,\n                11261758167548915441,\n                2059999575592944296,\n                4808217191002697670,\n                11144850771283015677,\n                11420508211474364970,\n                16799732563689238327,\n                3497095200015961133,\n                18400167689108815834,\n                11950366853355105307,\n                11210662566186499912,\n                7630565784488556621,\n                8708124700824936536,\n                16451883938293396059,\n                3856271038937245480,\n                5014991179538099218,\n                13960473819858174514,\n                125754478403752818,\n                6836966187910773427,\n                13398538180289167798,\n                4342012043427584780,\n                10587058069497406375,\n                14137841459960663361,\n                10659720389989370126,\n                6102546442785984287,\n                12392236227630837883,\n                8332615892803265341,\n                11617599899986402733,\n                13605114078859281596,\n                7114983647870611256,\n                12404096710235362863,\n                10847060057289621091,\n                9048460749990878785,\n                9926828906222562343,\n                517853205147118455,\n                8179968105148709421,\n                558104921847325950,\n                7022967858240775546,\n                8937761758962462261,\n                11010345473796135921,\n                15162173902777211238,\n                7737154465700094829,\n                10934536765747213009,\n                15409842658458358292,\n                5139225699322622015,\n                2424051831250781183,\n                6113891917550200290,\n                175401245396128529,\n                12650806140631886299,\n                6488833543271648807,\n                12206734304450002273,\n                15167188033176677277,\n                14723303654739655264,\n                2179622318393018228,\n                9921850291797916605,\n                1533691482276731934,\n                7193267197928543879,\n                7697000401879611136,\n                17905282013737611432,\n                195708939669136652,\n                8568890883842831118,\n                541635191945155915,\n                5909439847022830310,\n                17931009500490606267,\n                6813293046347240,\n                10373454508133137832,\n                2518969817879302450,\n                2557266502794028272,\n                11482262686846267489,\n                9426469967764905872,\n                13731315097386886251,\n                15575568313782898237,\n                13595230256649138562,\n                10024833956978279813,\n                5285361198933870158,\n                17437810250035109171,\n                15432785004507430528,\n                10310987294856413932,\n                7168389759122719634,\n                2631016883595934144,\n                17529280321808157946,\n                6962165250869702643,\n                18242038243432348673,\n                9407887776756608694,\n                17629211158466299816,\n                651801541305818097,\n                7005455043755295025,\n                3693142147562879928,\n                13937562557249975083,\n                17185080793670498070,\n                768121941451659874,\n                3094549444790063442,\n                13260257407036400094,\n                16126489432734117941,\n                10272660138986488848,\n                15438764110169806984,\n            ],\n            &[1],\n        );\n        // - xs_len > ys_len second time in limbs_gcd_subdivide_step\n        // - x_high < 2 || y_high < 2 in limbs_half_gcd_2\n        // - xs_len < ys_len second time in limbs_gcd_subdivide_step\n        // - y_high < 2 third time in limbs_half_gcd_2\n        // - done in limbs_half_gcd_2\n        // - x_high < 2 second time in limbs_half_gcd_2\n        test(\n            &[\n                18446744073701163008,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                4194303,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709550592,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                2305843009213693951,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073441116160,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                2147483647,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709550592,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n            ],\n            &[\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                9223372036854775807,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446743523953737728,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                288230376151711743,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551360,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744056529682432,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                288230376151711743,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                127,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n            ],\n            &[1],\n        );\n        // - !limbs_half_gcd_approx in limbs_half_gcd_approx\n        // - n == 0 fifth time in limbs_half_gcd_approx\n        test(\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551488,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                8589934591,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                9223372036854775808,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                8191,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073675997184,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                8388607,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073707454464,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                65535,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18374686479671623680,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n            ],\n            &[\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                576460752303423487,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709420544,\n                16383,\n                18446744072635809792,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                16777215,\n                0,\n                0,\n                18446744073705357312,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                72057594037927935,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073575333888,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                268435455,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446603336221196288,\n                18446744073709551615,\n                2251799813685247,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709518848,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                31,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446743798831644672,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                2097151,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709547520,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n            ],\n            &[1],\n        );\n        // - n <= mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[1][1] < mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[0][1] < mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[1][0] < mod_n in limbs_half_gcd_matrix_apply\n        // - n + m_lens[0][0] < mod_n in limbs_half_gcd_matrix_apply\n        test(\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073575333888,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                33554431,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709550592,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18158513697557839872,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                1099511627775,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446739675663040512,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                562949953421311,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744004990074880,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                8388607,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073701163008,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                144115188075855871,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073441116160,\n                18446744073709551615,\n                4611686018427387903,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709543424,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                70368744177663,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073705357312,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                1152921504606846975,\n                18410715276690587648,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                2305843009213693951,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551614,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                131071,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551488,\n            ],\n            &[\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                8796093022207,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709486080,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                4611686018427387903,\n                0,\n                0,\n                0,\n                18302628885633695744,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                17592186044415,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709547520,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                7,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446741874686296064,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18014398509481983,\n            ],\n            &[3],\n        );\n        // - n <= s + 2 in limbs_half_gcd_approx\n        // - m_lens[0][1] == 0 in limbs_half_gcd_matrix_apply\n        test(\n            &[\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                255,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709027328,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                1125899906842623,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551104,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551360,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                8191,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073701163008,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n            ],\n            &[\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                70368744177663,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551488,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                36028797018963967,\n                0,\n                0,\n                0,\n                17870283321406128128,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                33554431,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18437736874454810624,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                9007199254740991,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                18446744073709551612,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n                18446744073709551615,\n            ],\n            &[1],\n        );\n    }\n}\n\n#[test]\nfn test_gcd() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.gcd_assign(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.gcd_assign(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().gcd(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).gcd(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().gcd(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).gcd(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigUint::from_str(s)\n            .unwrap()\n            .gcd(&BigUint::from_str(t).unwrap());\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s)\n            .unwrap()\n            .gcd(&rug::Integer::from_str(t).unwrap());\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"6\", \"6\");\n    test(\"6\", \"0\", \"6\");\n    test(\"1\", \"6\", \"1\");\n    test(\"6\", \"1\", \"1\");\n    test(\"8\", \"12\", \"4\");\n    test(\"54\", \"24\", \"6\");\n    test(\"42\", \"56\", \"14\");\n    test(\"48\", \"18\", \"6\");\n    test(\"3\", \"5\", \"1\");\n    test(\"12\", \"60\", \"12\");\n    test(\"12\", \"90\", \"6\");\n    test(\"12345678987654321\", \"98765432123456789\", \"1\");\n    test(\"12345678987654321\", \"98765432123456827\", \"37\");\n}\n\n#[test]\nfn limbs_gcd_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_23::<Limb, Limb>().test_properties_with_config(\n        &config,\n        |(xs, y)| {\n            let gcd = Natural::from(limbs_gcd_limb(&xs, y));\n            let n = Natural::from_owned_limbs_asc(xs);\n            assert_eq!((&n).gcd(Natural::from(y)), gcd);\n            assert_eq!(gcd_binary_nz(n, Natural::from(y)), gcd);\n        },\n    );\n}\n\n#[test]\nfn half_gcd_matrix_init_properties() {\n    unsigned_gen_var_11().test_properties_with_limit(TINY_LIMIT, |n| {\n        let scratch_len = HalfGcdMatrix::min_init_scratch(n);\n        assert_eq!(\n            half_gcd_matrix_to_naturals(&OwnedHalfGcdMatrix::init(n, vec![0; scratch_len])),\n            (Natural::ONE, Natural::ZERO, Natural::ZERO, Natural::ONE)\n        );\n    });\n}\n\n#[test]\nfn half_gcd_matrix_update_q_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_5().test_properties_with_config(&config, |(mut m, qs, column)| {\n        let (x00, x01, x10, x11) = half_gcd_matrix_to_naturals(&m);\n        let mut scratch = vec![0; m.update_q_scratch_len(qs.len())];\n        m.update_q(&qs, column, &mut scratch);\n        let q = Natural::from_owned_limbs_asc(qs);\n        let (y00, y01, y10, y11) = half_gcd_matrix_to_naturals(&m);\n        if column == 0 {\n            assert_eq!(y01, x01);\n            assert_eq!(y11, x11);\n            assert_eq!(y00, &x00 + x01 * &q);\n            assert_eq!(y10, &x10 + x11 * &q);\n        } else {\n            assert_eq!(y00, x00);\n            assert_eq!(y10, x10);\n            assert_eq!(y01, &x01 + x00 * &q);\n            assert_eq!(y11, &x11 + x10 * &q);\n        }\n    });\n}\n\n#[test]\nfn half_gcd_matrix_mul_matrix_1_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_7().test_properties_with_config(&config, |(mut m, m_1)| {\n        let (x00, x01, x10, x11) = half_gcd_matrix_to_naturals(&m);\n        let (y00, y01, y10, y11) = half_gcd_matrix_1_to_naturals(&m_1);\n        let mut scratch = vec![0; m.n];\n        m.mul_matrix_1(&m_1, &mut scratch);\n        let (z00, z01, z10, z11) = half_gcd_matrix_to_naturals(&m);\n        assert_eq!(z00, &x00 * &y00 + &x01 * &y10);\n        assert_eq!(z01, x00 * &y01 + x01 * &y11);\n        assert_eq!(z10, &x10 * y00 + &x11 * y10);\n        assert_eq!(z11, x10 * y01 + x11 * y11);\n    });\n}\n\n#[test]\nfn half_gcd_matrix_1_mul_vector_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_6().test_properties_with_config(&config, |(m, mut out, xs, mut ys)| {\n        let old_out = out.to_vec();\n        let old_ys = ys.to_vec();\n        let n = xs.len();\n        let a = Natural::from_limbs_asc(&xs);\n        let b = Natural::from_limbs_asc(&ys[..n]);\n        let out_len = limbs_half_gcd_matrix_1_mul_vector(&m, &mut out, &xs, &mut ys);\n        let bits = limb_to_bit_count(n + 1);\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..out_len]),\n            (&a * Natural::from(m.data[0][0]) + &b * Natural::from(m.data[1][0]))\n                .mod_power_of_2(bits)\n        );\n        assert_eq!(\n            Natural::from_limbs_asc(&ys[..out_len]),\n            (a * Natural::from(m.data[0][1]) + b * Natural::from(m.data[1][1]))\n                .mod_power_of_2(bits)\n        );\n        if out.len() > out_len {\n            assert_eq!(&out[out_len + 1..], &old_out[out_len + 1..]);\n        }\n        if ys.len() > out_len {\n            assert_eq!(&ys[out_len + 1..], &old_ys[out_len + 1..]);\n        }\n    });\n}\n\n#[test]\nfn limbs_matrix_2_2_mul_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_8().test_properties_with_config(\n        &config,\n        |(mut xs00, mut xs01, mut xs10, mut xs11, xs_len, ys00, ys01, ys10, ys11)| {\n            let x00 = Natural::from_limbs_asc(&xs00[..xs_len]);\n            let x01 = Natural::from_limbs_asc(&xs01[..xs_len]);\n            let x10 = Natural::from_limbs_asc(&xs10[..xs_len]);\n            let x11 = Natural::from_limbs_asc(&xs11[..xs_len]);\n            let mut scratch = vec![0; limbs_matrix_mul_2_2_scratch_len(xs_len, ys00.len())];\n            limbs_matrix_2_2_mul(\n                &mut xs00,\n                &mut xs01,\n                &mut xs10,\n                &mut xs11,\n                xs_len,\n                &ys00,\n                &ys01,\n                &ys10,\n                &ys11,\n                &mut scratch,\n            );\n            let y00 = Natural::from_owned_limbs_asc(ys00);\n            let y01 = Natural::from_owned_limbs_asc(ys01);\n            let y10 = Natural::from_owned_limbs_asc(ys10);\n            let y11 = Natural::from_owned_limbs_asc(ys11);\n            let z00 = Natural::from_owned_limbs_asc(xs00);\n            let z01 = Natural::from_owned_limbs_asc(xs01);\n            let z10 = Natural::from_owned_limbs_asc(xs10);\n            let z11 = Natural::from_owned_limbs_asc(xs11);\n            assert_eq!(z00, &x00 * &y00 + &x01 * &y10);\n            assert_eq!(z01, x00 * &y01 + x01 * &y11);\n            assert_eq!(z10, &x10 * y00 + &x11 * y10);\n            assert_eq!(z11, x10 * y01 + x11 * y11);\n        },\n    );\n}\n\n#[test]\nfn limbs_gcd_div_properties() {\n    unsigned_quadruple_gen_var_11::<Limb>().test_properties(|(n1, n0, d1, d0)| {\n        let result = limbs_gcd_div_naive(n1, n0, d1, d0);\n        assert_eq!(limbs_gcd_div(n1, n0, d1, d0), result);\n        assert_eq!(limbs_gcd_div_alt(n1, n0, d1, d0), result);\n    });\n}\n\n#[test]\nfn limbs_gcd_reduced_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 256);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_10().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let mut out = vec![0; xs.len()];\n        let x = Natural::from_limbs_asc(&xs);\n        let y = Natural::from_limbs_asc(&ys);\n        let out_len = limbs_gcd_reduced(&mut out, &mut xs, &mut ys);\n        out.resize(out_len, 0);\n        let g = Natural::from_owned_limbs_asc(out);\n        assert_eq!(gcd_binary_nz(x.clone(), y.clone()), g);\n        assert_eq!(x.gcd(y), g);\n    });\n}\n\nfn gcd_properties_helper(x: Natural, y: Natural) {\n    let gcd_val_val = x.clone().gcd(y.clone());\n    let gcd_val_ref = x.clone().gcd(&y);\n    let gcd_ref_val = (&x).gcd(y.clone());\n    let gcd = (&x).gcd(&y);\n    assert!(gcd_val_val.is_valid());\n    assert!(gcd_val_ref.is_valid());\n    assert!(gcd_ref_val.is_valid());\n    assert!(gcd.is_valid());\n    assert_eq!(gcd_val_val, gcd);\n    assert_eq!(gcd_val_ref, gcd);\n    assert_eq!(gcd_ref_val, gcd);\n\n    let mut mut_x = x.clone();\n    mut_x.gcd_assign(y.clone());\n    assert!(mut_x.is_valid());\n    assert_eq!(mut_x, gcd);\n\n    let mut mut_x = x.clone();\n    mut_x.gcd_assign(&y);\n    assert_eq!(mut_x, gcd);\n    assert!(mut_x.is_valid());\n\n    assert_eq!(\n        Natural::from(&(BigUint::from(&x).gcd(&BigUint::from(&y)))),\n        gcd\n    );\n    assert_eq!(\n        Natural::exact_from(&(rug::Integer::from(&x).gcd(&rug::Integer::from(&y)))),\n        gcd\n    );\n\n    assert_eq!(gcd_euclidean_nz(x.clone(), y.clone()), gcd);\n    assert_eq!(gcd_binary_nz(x.clone(), y.clone()), gcd);\n\n    assert_eq!((&y).gcd(&x), gcd);\n    assert!((&x).divisible_by(&gcd));\n    assert!((&y).divisible_by(&gcd));\n    assert_eq!(gcd == 0, x == 0 && y == 0);\n    if gcd != 0 {\n        assert!(((&x).div_exact(&gcd)).coprime_with((&y).div_exact(&gcd)));\n    }\n    if x != 0 && y != 0 {\n        assert_eq!(&x * &y / x.lcm(y), gcd);\n    }\n}\n\n#[test]\nfn gcd_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 512 << Limb::LOG_WIDTH);\n    natural_pair_gen().test_properties_with_config(&config, |(x, y)| {\n        gcd_properties_helper(x, y);\n    });\n\n    natural_pair_gen_var_4().test_properties_with_config(&config, |(x, y)| {\n        gcd_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).gcd(&x), x);\n        assert_eq!((&x).gcd(Natural::ONE), 1);\n        assert_eq!((&x).gcd(Natural::ZERO), x);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x).gcd(&y).gcd(&z), x.gcd(y.gcd(z)));\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).gcd(Natural::from(y)), x.gcd(y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_vec_gen_var_1};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::is_power_of_2::limbs_is_power_of_2;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_gen_var_2};\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_is_power_of_2() {\n    let test = |xs, out| {\n        assert_eq!(limbs_is_power_of_2(xs), out);\n    };\n    test(&[1], true);\n    test(&[2], true);\n    test(&[3], false);\n    test(&[4], true);\n    test(&[256], true);\n    test(&[0, 0, 0, 256], true);\n    test(&[1, 0, 0, 256], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_is_power_of_2_fail() {\n    limbs_is_power_of_2(&[]);\n}\n\n#[test]\nfn test_is_power_of_2() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().is_power_of_2(), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().is_power_of_two(), out);\n    };\n    test(\"0\", false);\n    test(\"1\", true);\n    test(\"2\", true);\n    test(\"3\", false);\n    test(\"4\", true);\n    test(\"5\", false);\n    test(\"6\", false);\n    test(\"7\", false);\n    test(\"8\", true);\n    test(\"1024\", true);\n    test(\"1025\", false);\n    test(\"1000000000000\", false);\n    test(\"1099511627776\", true);\n}\n\n#[test]\nfn limbs_is_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        assert_eq!(\n            limbs_is_power_of_2(&xs),\n            Natural::from_owned_limbs_asc(xs).is_power_of_2()\n        );\n    });\n}\n\n#[allow(clippy::cmp_owned, clippy::useless_conversion)]\n#[test]\nfn is_power_of_2_properties() {\n    natural_gen().test_properties(|x| {\n        let is_power_of_2 = x.is_power_of_2();\n        assert_eq!(rug::Integer::from(&x).is_power_of_two(), is_power_of_2);\n    });\n\n    natural_gen_var_2().test_properties(|x| {\n        let is_power_of_2 = x.is_power_of_2();\n        let trailing_zeros = x.trailing_zeros().unwrap();\n        assert_eq!(trailing_zeros == x.significant_bits() - 1, is_power_of_2);\n        if trailing_zeros <= u64::from(Limb::MAX) {\n            assert_eq!(x >> trailing_zeros == 1, is_power_of_2);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.is_power_of_2(), Natural::from(u).is_power_of_2());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/kronecker_symbol.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CoprimeWith, JacobiSymbol, KroneckerSymbol, LegendreSymbol, ModPowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::WrappingInto;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_pair_gen_var_40, unsigned_vec_pair_gen_var_32,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::kronecker_symbol::{\n    limbs_jacobi_symbol_init, limbs_jacobi_symbol_same_length,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_var_8, natural_pair_gen, natural_pair_gen_var_4,\n    natural_pair_gen_var_12, natural_pair_gen_var_13, natural_pair_gen_var_14, natural_triple_gen,\n    natural_triple_gen_var_8, natural_triple_gen_var_9,\n};\nuse malachite_nz::test_util::natural::arithmetic::kronecker_symbol::jacobi_symbol_simple;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_limbs_jacobi_symbol_same_length() {\n    fn test(xs: &[Limb], ys: &[Limb], s: i8) {\n        let x = Natural::from_limbs_asc(xs);\n        let y = Natural::from_limbs_asc(ys);\n        assert_eq!((&x).jacobi_symbol(&y), s);\n        assert_eq!(jacobi_symbol_simple(x, y), s);\n        let bits = limbs_jacobi_symbol_init(xs[0], ys[0], 0);\n        let xs_orig = xs;\n        let ys_orig = ys;\n        let mut xs = xs_orig.to_vec();\n        let mut ys = ys_orig.to_vec();\n        assert_eq!(limbs_jacobi_symbol_same_length(&mut xs, &mut ys, bits), s);\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - n < JACOBI_DC_THRESHOLD\n        // - bits < 16\n        // - n == 1\n        // - y_lo == 1\n        test(&[0], &[1], 1);\n        // - y_lo != 1\n        // - bits.even() first time\n        test(&[0], &[3], 0);\n        // - n != 1\n        // - bits.even() second time\n        test(&[0, 0], &[1, 1], 0);\n        // - !mask.get_highest_bit()\n        // - x_1 < 2 || y_1 < 2 in limbs_half_gcd_2_jacobi\n        // - !limbs_half_gcd_2_jacobi\n        // - let Some(gs) = gs in JacobiContext::gcd_subdiv_step_hook\n        // - gs_len != 1 || gs[0] != 1 in JacobiContext::gcd_subdiv_step_hook\n        // - n == 0 second time\n        // - bits == BITS_FAIL second time\n        test(&[0, 0, 0], &[1, 0, 1], 0);\n        // - gs == None in JacobiContext::gcd_subdiv_step_hook\n        // - let Some(qs) = qs in JacobiContext::gcd_subdiv_step_hook\n        // - gs.len() == 1 && gp[0] == 1 in JacobiContext::gcd_subdiv_step_hook\n        // - bits != BITS_FAIL second time\n        test(&[0, 0, 1], &[1, 0, 0], 1);\n        // - x_1 >= 2 && y_1 >= 2 in limbs_half_gcd_2_jacobi\n        // - x_1 <= y_1 && (x_1 != y_1 || x_0 <= y_0) in limbs_half_gcd_2_jacobi\n        // - y_1 < 2 first time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 1], &[1, 0, 1], 1);\n        // - n != 0 second time\n        test(&[0, 0, 1], &[1, 1, 0], 1);\n        // - x_1 > y_1 || (x_1 == y_1 && x_0 > y_0) in limbs_half_gcd_2_jacobi\n        // - x_1 < 2 first time in limbs_half_gcd_2_jacobi\n        // - bits >= 16\n        test(&[0, 1, 1], &[1, 0, 1], 1);\n        // - y_1 >= 2 first time in limbs_half_gcd_2_jacobi\n        // - !subtract_a in limbs_half_gcd_2_jacobi\n        // - x_1 == y_1 first time in limbs_half_gcd_2_jacobi\n        // - limbs_half_gcd_2_jacobi\n        test(&[0, 0, 1], &[1, 0, 2], 1);\n        // - subtract_a in limbs_half_gcd_2_jacobi\n        // - x_1 != y_1 second time in limbs_half_gcd_2_jacobi\n        // - y_1 >= Limb::power_of_2(Limb::WIDTH >> 1) in limbs_half_gcd_2_jacobi\n        // - y_1 >= 2 second time in limbs_half_gcd_2_jacobi\n        // - y_1 <= x_1 first time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 1], &[1, 0, 3], 1);\n        // - x_1 != y_1 first time in limbs_half_gcd_2_jacobi\n        // - x_1 >= Limb::power_of_2(Limb::WIDTH >> 1) in limbs_half_gcd_2_jacobi\n        // - x_1 < 2 second time in limbs_half_gcd_2_jacobi\n        test(&[0, 1, 1], &[1, 0, 2], -1);\n        // - bits.odd() first time\n        test(&[1, 0, 1], &[1, 1, 3], -1);\n        // - x_1 >= 2 first time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 2], &[1, 0, 1], 1);\n        // - x_1 >= 2 second time in limbs_half_gcd_2_jacobi\n        // - x_1 <= y_1 second time in limbs_half_gcd_2_jacobi\n        // - x_1 == y_1 second time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 3], &[1, 0, 1], -1);\n        // - y_1 < 2 second time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 2], &[1, 1, 1], 1);\n        // - bits.odd() second time\n        test(&[0, 1, 2], &[1, 1, 1], 0);\n        // - y_1 > x_1 first time in limbs_half_gcd_2_jacobi\n        // - y_1 < 2 third time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 3], &[1, 1, 2], 1);\n        // - x_1 > y_1 second time in limbs_half_gcd_2_jacobi\n        // - x_1 < 2 third time in limbs_half_gcd_2_jacobi\n        test(&[0, 1, 2], &[1, 0, 3], -1);\n        // - mask.get_highest_bit()\n        test(&[0, 0, 0, 1, 1], &[1, 0, 0, 0, 1], 1);\n        // - y_1 >= 2 third time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 1, 1], &[1, 1, 0, 2], 1);\n        // - x_1 >= 2 third time in limbs_half_gcd_2_jacobi\n        // - y_1 < Limb::power_of_2(Limb::WIDTH >> 1) in limbs_half_gcd_2_jacobi\n        // - subtract_a_1 in limbs_half_gcd_2_jacobi\n        // - x_1 != y_1 fourth time in limbs_half_gcd_2_jacobi\n        // - y_1 < TWICE_TWO_POW_HALF_WIDTH first time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 0, 1, 1], &[1, 1, 1, 0, 1], 1);\n        // - x_1 < TWO_POW_HALF_WIDTH in limbs_half_gcd_2_jacobi\n        // - !subtract_a_1 in limbs_half_gcd_2_jacobi\n        // - x_1 != y_1 third time in limbs_half_gcd_2_jacobi\n        // - x_1 < TWICE_TWO_POW_HALF_WIDTH first time in limbs_half_gcd_2_jacobi\n        test(&[0, 1, 1, 0, 1], &[1, 0, 0, 1, 1], 0);\n        // - y_1 >= TWICE_TWO_POW_HALF_WIDTH first time in limbs_half_gcd_2_jacobi\n        // - y_1 <= x_1 second time in limbs_half_gcd_2_jacobi\n        // - x_1 >= TWICE_TWO_POW_HALF_WIDTH first time in limbs_half_gcd_2_jacobi\n        // - x_1 > y_1 in limbs_half_gcd_2_jacobi\n        // - x_1 < TWICE_TWO_POW_HALF_WIDTH second time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 1, 3], &[1, 1, 0, 2], 1);\n        // - y_1 > x_1 second time in limbs_half_gcd_2_jacobi\n        // - y_1 < TWICE_TWO_POW_HALF_WIDTH second time in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 0, 1, 1], &[1, 1, 1, 0, 3], 1);\n        // - x_1 <= y_1 in limbs_half_gcd_2_jacobi\n        test(&[0, 0, 1, 0, 1], &[1, 1, 0, 1, 3], 1);\n        // - x_1 == y_1 fourth time in limbs_half_gcd_2_jacobi\n        test(&[0, 1, 0, 1, 1], &[1, 0, 1, 0, 3], -1);\n        // - y_1 >= TWICE_TWO_POW_HALF_WIDTH second time in limbs_half_gcd_2_jacobi\n        test(&[0, 1, 1, 1, 1], &[1, 0, 0, 1, 3], 1);\n        // - x_1 >= TWICE_TWO_POW_HALF_WIDTH second time in limbs_half_gcd_2_jacobi\n        test(&[0, 1, 1, 1, 1], &[1, 1, 0, 0, 3], 1);\n        // - x_1 == y_1 third time in limbs_half_gcd_2_jacobi\n        test(&[0, 1, 0, 1, 2], &[1, 0, 1, 0, 1], 0);\n    }\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - n >= JACOBI_DC_THRESHOLD\n        // - dc_scratch_len > scratch_len\n        // - n >= HGCD_THRESHOLD in limbs_half_gcd_jacobi\n        // - n < HGCD_THRESHOLD in limbs_half_gcd_jacobi\n        // - n != s + 1 && !mask.get_highest_bit() in limbs_half_gcd_jacobi_step\n        // - limbs_half_gcd_2_jacobi in limbs_half_gcd_jacobi_step\n        // - nn != 0 fourth time in limbs_half_gcd_jacobi\n        // - n == s + 1 in limbs_half_gcd_jacobi_step\n        // - mask >= 4 in limbs_half_gcd_jacobi_step\n        // - mask < 4 in limbs_half_gcd_jacobi_step\n        // - nn == 0 fourth time in limbs_half_gcd_jacobi\n        // - nn != 0 first time in limbs_half_gcd_jacobi\n        // - nn != 0 second time in limbs_half_gcd_jacobi\n        // - n > s + 2 in limbs_half_gcd_jacobi\n        // - n != s + 1 && mask.get_highest_bit() in limbs_half_gcd_jacobi_step\n        // - !limbs_half_gcd_2_jacobi in limbs_half_gcd_jacobi_step\n        // - nn != 0 third time in limbs_half_gcd_jacobi\n        // - qs_len != 0 in HalfGcdJacobiContext::gcd_subdiv_step_hook\n        // - nn != 0\n        test(\n            &[\n                1873633918, 123030658, 719377342, 1504696614, 2362755734, 3961478485, 781485753,\n                1658134515, 2113542903, 2810709120, 516343343, 592412664, 389523939, 1066227422,\n                3298185546, 503562514, 201347799, 3837685524, 1791253076, 2719252242, 3220584319,\n                2228118840, 2873093023, 3277574845, 4183085011, 1024538582, 1879444551, 4131206800,\n                1120880147, 693962231, 3607359350, 2707994236, 1776336830, 1261880384, 4191042108,\n                2802674416, 1093640235, 1117222130, 4191804349, 488263639, 4196953979, 2945863127,\n                3796408273, 3918535658, 3739145025, 2025532414, 3908394825, 3730013238, 3918858199,\n                2236390519, 304075529, 588039508, 464824988, 1043329929, 4024659213, 777233325,\n                2754590310, 430183448, 2116763050, 2194568215, 3983851431, 3079663737, 3609827959,\n                3165570624, 3778786312, 2207000505, 494983090, 4061038956, 1847009994, 1374726069,\n                2216864799, 287045089, 1522632156, 3701999684, 628940848, 3777561277, 1853948570,\n                2149163542, 3146560430, 2662015036, 3673560784, 3148979133, 1498637710, 647923219,\n                512319396, 3874841555, 2725763682, 705802490, 955850189, 1466834834, 2958146031,\n                974815424, 3925846741, 3990055262, 2385857769, 1785254473, 975242909, 1640367194,\n                17679830, 2162917366, 833169313, 3823256168, 3933828973, 3314871585, 801976468,\n                3300008476, 189067881, 968522820, 701167717, 3456031850, 3807893479, 3883967676,\n                3397552960, 1177591619, 2235569799, 373301573, 874195563, 2179365380, 2119067928,\n                2720245803, 1010696918, 1442726415, 1066758009, 2565507481, 2473976884, 3393774679,\n                3952059313, 3757956916, 3261899893, 2443126808, 1361119172, 2208060333, 3775473672,\n                3653607071, 1293439175, 435448758, 3990892991, 1286144898, 2494049465, 2398440308,\n                3756264187, 4812695, 25801943, 226806926, 3042686908, 1989123535, 3254845113,\n                919895168, 4209027670, 4166349537, 148522488, 973817508, 3765422389, 2523318742,\n                579963969, 2098988831, 1365027916, 3658076322, 1733252939, 1043406512, 717910858,\n                2103188848, 3566233409, 1012130235, 1855787810, 156497531, 1958213821, 715897916,\n                4210647949, 1362164018, 3523905136, 678285695, 893316222, 4002270604, 2743748491,\n                1734398700, 4013187857, 3355679131, 3312607834, 671835519, 151753042, 3175422619,\n                2357087390, 1388249743, 3345521534, 2885692694, 3727953305, 210133499, 1091341046,\n                3272930824, 2473688375, 643815394, 2815077147, 3640266733, 1129170891, 591859561,\n                92728385, 1710489516, 2247919245, 3303371411, 2878106269, 3299382591, 6838220,\n                2207248685, 1067399745, 3227744596, 706680457, 347073425, 2315288352, 3459009392,\n                369508525, 2058436577, 723699746, 1636431631, 1393077501, 4220412446, 1818976107,\n                1429834151, 1320074954, 1810726444, 4038059510, 3467618009, 320963964, 1111140807,\n                3131364647, 1235553534, 16798724, 19240978, 2108447774, 143304067, 1703667778,\n                861127847, 1186666148, 1478800880, 1170455588, 2625617857, 488704999, 2402011494,\n                1397588188, 3587645117, 379450888, 2093883128, 1089613602, 1380578556, 3780609811,\n                2264391031, 1078858400, 2436761299, 3025683539, 4068664961, 3262585229, 710877465,\n                3189533901, 3423405972, 4226527191, 1281614997, 11582026, 4187361634, 1934508614,\n                2978905528, 3811137180, 254480797, 3957068379, 276691084, 980502794, 2333498429,\n                2402962021, 1968336748, 937179998, 328237312, 3105135306, 2708438479, 807396072,\n                4090616190, 338836192, 3493021773, 1007932634, 989046118, 475565105, 4280477458,\n                2889310878, 506168430, 2744969090, 1717140865, 180101187, 3946998676, 3256792444,\n                1651611832, 2217469837, 639375671, 3754995303, 803291429, 559260186, 3312276405,\n                1307739531, 637914444, 800094865, 1566616440, 8698228, 205523792, 1663664157,\n                4012170144, 1845279876, 414628822, 2589258003, 2046627153, 4252798243, 888708228,\n                1078803694, 2357638662, 4007813553, 2748056828, 1261654782, 3168764324, 1241689206,\n                2318873504, 376674550, 1961382315, 3250714815, 47982921, 1081086646, 2017910660,\n                3376874155, 3907817672, 3337262433, 2781215129, 700917261, 3986793763, 603713597,\n                2286652653, 2487070286, 3503515107, 3549521582, 2229840842, 106670130, 2152342444,\n                2614172954, 2980612046, 1711600105, 3367600130, 224267645, 147721273, 3762102334,\n                909656137, 2765963499, 1287501967, 3853510171, 2602535793, 687227193, 3372261235,\n                2071559967, 2243249886, 1302529466, 1536608166, 141064408, 1798146420, 1490894727,\n                4069708793, 539834647, 3483430067, 3470554577, 1125163274, 1002230975, 782459269,\n                1965180788, 1031655683, 957046550, 1927934983, 1014977728, 748904605, 1278878668,\n                3257529883, 1525236512, 3452233244, 595919552, 3284927605, 3947267553, 990044496,\n                2645462059, 3185056815, 3364504564, 2742517875, 2254394076, 256336642, 2622723662,\n                2255022161, 307535959, 2740603712, 326158350, 4134908299, 2331131321, 2268360042,\n                1661560181, 296127993, 65765671, 2991972277, 3942011917, 2155904650, 2798972906,\n                19922601, 336740766, 2370937438, 2954540796, 1662173899,\n            ],\n            &[\n                1077171533, 3384534038, 3509377481, 3012981171, 2169372009, 3568066367, 510541737,\n                360351115, 1116770051, 2058732872, 3226198045, 1078176389, 2950624729, 812262025,\n                1430083408, 61306667, 64349919, 2388720201, 2804807299, 3487065571, 1162686670,\n                2184575935, 1234374819, 3462973209, 2204618738, 1955732567, 4274764191, 487910035,\n                2794693464, 1455130957, 2647605728, 4211289912, 3386405281, 117329687, 3432428417,\n                1300225461, 3461206919, 449524200, 904979455, 3971171435, 441380375, 1283836003,\n                2682594354, 1152961793, 1318795928, 308922730, 628004645, 1003117196, 1035594263,\n                3028460626, 3737759554, 3080878651, 2013071269, 157811103, 3209212678, 1794098871,\n                1571763958, 4118994167, 3323265833, 2779923965, 1781531454, 3074442432, 1330835008,\n                231050954, 1972822306, 3779389322, 2550908177, 1122947161, 2607600449, 2966179614,\n                1165225297, 4222222976, 1020266087, 1019514006, 53769477, 62821411, 3078440286,\n                2087323177, 4209236301, 146146381, 453393163, 4244430148, 624415024, 2096395426,\n                1915435196, 3779399544, 3641826296, 4157323023, 4049792386, 1892149154, 2185863226,\n                1046224168, 3568999985, 982204298, 154455361, 2605934809, 2605177974, 1652215061,\n                3058430834, 1573346022, 3979000833, 1424146496, 758475042, 3880559465, 3331749655,\n                4009275982, 309023272, 343958017, 2544085697, 1960862631, 1082361995, 534185037,\n                331011064, 3662295811, 3280920837, 2366184597, 1029851460, 1149922348, 3242309342,\n                3498011365, 1869617138, 2033933372, 2449772239, 1769059102, 552671522, 2541136194,\n                1837261562, 3331388737, 3882095076, 2111080116, 3488393361, 3110154197, 2503543094,\n                276095820, 109038743, 3401659741, 2955647843, 3730124703, 4288579615, 2840357519,\n                433563482, 3742367408, 2287152115, 3054337338, 2305325930, 1838329967, 1117989732,\n                2731369203, 427022429, 1959348870, 107371881, 1378273431, 3969746745, 137314119,\n                3494302009, 2316521941, 1304670415, 2017956904, 3960566359, 3950960171, 2483760563,\n                3248620299, 1282201932, 2666453601, 290925463, 1315172510, 2244058356, 83064665,\n                2794575253, 2751020494, 86251099, 1497864163, 1309606664, 918139255, 2382232313,\n                3431694285, 4197334044, 3779739436, 2597050321, 4053750034, 1347898240, 2068381165,\n                530540195, 777294114, 1563424547, 714733079, 251090961, 1222614986, 409927269,\n                2552943554, 3813553790, 2619995688, 2754487462, 1001623689, 4043538191, 780110724,\n                2756539090, 2640687797, 2974350673, 1702213372, 2898669867, 232176052, 2414666354,\n                300281312, 3252747308, 2375533144, 3579260801, 3856594937, 226065085, 2855017957,\n                4106625762, 4251800319, 271717704, 796181594, 2015816818, 572129733, 1578027849,\n                208352494, 3329313861, 3272451839, 1390383564, 3754291474, 1022210892, 3402379185,\n                1055267474, 2105880379, 1377373336, 2125916506, 3713096588, 3227913500, 593660170,\n                3662162553, 948899397, 3959019656, 743736078, 561608271, 4154259253, 753202703,\n                3057879152, 4093431092, 2849520862, 1298183896, 1072767461, 3844624206, 1553109174,\n                2211737614, 2944064724, 1134344972, 2846368205, 2535247938, 1454739286, 1408186915,\n                3022639671, 2985835925, 1242350664, 856614531, 3277904750, 2435844371, 2288413570,\n                1941580081, 2330069009, 3763753263, 1617186357, 3858822820, 3899619764, 957776791,\n                2415934649, 1903499570, 362345092, 3162421697, 857308796, 2166848441, 2794392063,\n                2916482641, 547554093, 393697940, 319583576, 3206427070, 3502792667, 3979846702,\n                3580352012, 3854879140, 3646613450, 4113031775, 856333171, 1029998771, 2090645466,\n                3125086584, 2494710984, 3249027001, 3828101842, 4278721100, 2901896440, 3549366611,\n                2066085974, 3815811960, 2980213693, 2418009668, 4168963107, 1522903282, 3921187989,\n                209293309, 1026651789, 3652402308, 1723212287, 3005358245, 3972955479, 3432513818,\n                1135457591, 2609451544, 1728509125, 1610815908, 1281322374, 2308282400, 1650462965,\n                785788526, 3039230497, 1454810597, 2847801652, 868324593, 2811238675, 1592440137,\n                2837082164, 2293886194, 108023352, 1338057151, 867454780, 660204887, 2727424012,\n                3251699301, 2307270502, 3508727390, 444210859, 4112897129, 1692014843, 232384981,\n                3746950478, 2035293041, 832494472, 4167968781, 2088468820, 1082123254, 2004377194,\n                739887690, 3903970376, 3917684808, 2220241302, 1623595193, 3168893289, 1380144222,\n                3245294302, 1942246969, 1017235276, 1075796476, 1420638313, 2370978268, 3571300703,\n                2818383559, 3979048442, 4070073076, 3639658932, 2458302928, 1936855091, 1097653713,\n                2517446959, 395058431, 2490534065, 3621579656, 537422087, 820775047, 1621745064,\n                4147607605, 773085439, 150346009, 3309770346, 623052976, 223120997, 1047915001,\n                2440220896, 2701090680, 682463717, 626719149, 2752394251, 2245504316, 3599570937,\n                1008202886, 3061625147, 3833145985, 2287104975, 3419855448, 542949621, 2260871982,\n                3411141468, 1089194931, 3865896761, 1906114014, 3523746087, 3034843700, 3980408914,\n                1779312499, 2670385907, 3943945115, 3040560985, 968208310,\n            ],\n            -1,\n        );\n        // - qs_len == 0 in HalfGcdJacobiContext::gcd_subdiv_step_hook\n        test(\n            &[\n                3557994669, 445289342, 1108435216, 1656651402, 3854541936, 2345816964, 2732613883,\n                1181815769, 560246346, 2217942797, 3034747849, 2128803109, 193138609, 1787921939,\n                785846271, 690755, 4293433511, 1146911147, 4050052816, 826026913, 3182494773,\n                3156626600, 1014266169, 3323102091, 2921068424, 476686040, 7910507, 654440565,\n                3535711772, 3930398141, 4128513830, 2598121764, 4062960176, 3972780227, 855940423,\n                2256067460, 392376529, 2033808759, 3816270018, 1855458657, 2715891121, 3669089929,\n                3731047748, 1721938090, 2227294219, 3031269426, 1551726027, 3859144725, 4149437041,\n                3000994525, 3261175418, 2833753411, 4060863432, 2716969708, 4189891569, 677103308,\n                1365006263, 3293330016, 1768027889, 545258844, 2935866981, 250251281, 3680035401,\n                2700291474, 594423218, 898497607, 887621248, 3695367571, 2120585809, 1695812396,\n                645346742, 1835776782, 3264740207, 3486429797, 4208339033, 72066698, 2225784172,\n                1683577015, 3001910364, 3707465962, 1815190269, 124430948, 1869715335, 1801604000,\n                213381934, 3130033208, 3564635797, 474180177, 4240626321, 2076460830, 3656363137,\n                1132903283, 3991161472, 3821161503, 1744455617, 1045140442, 3902771928, 781148403,\n                2357356142, 3040623797, 2619406559, 195467574, 641531975, 3441001365, 114745412,\n                4134746228, 1311731821, 3461413652, 979311481, 1305256219, 977408510, 2999824757,\n                440721333, 3844175796, 1924795791, 3120129120, 532972790, 165893187, 4147094465,\n                3990693806, 2964895445, 1000735990, 331761162, 373581533, 1064345288, 1266123883,\n                2040591269, 1523811553, 2568191458, 2481902226, 2320866160, 1436736, 4008889052,\n                1280546217, 2098385450, 4119408023, 411283261, 3289104101, 3425489515, 2456862903,\n                2125542000, 1789202658, 497535957, 417045728, 3331787711, 3672146250, 1403849606,\n                1158118016, 1513052203, 1137714766, 4254706104, 2031746768, 1359724368, 3803765572,\n                422159546, 898111315, 2724325274, 1627832336, 1830223095, 4270287508, 1215166891,\n                2436306311, 907260779, 4034312884, 1698645062, 1078681555, 3198597175, 1586826465,\n                2046732632, 66062249, 3358599308, 232196012, 629981202, 935508892, 3170800564,\n                2191875696, 2503459156, 447871479, 3269004498, 2153827076, 267450909, 1520769342,\n                1163927607, 2575984589, 2978684947, 1813055270, 431843507, 226606783, 811301393,\n                2458665352, 585771839, 2841530354, 3556530842, 2435178025, 2845793940, 3637609260,\n                406241340, 144056695, 3122547306, 2101164412, 3905238054, 318269719, 3253726651,\n                1443434883, 178618945, 153042080, 2023190013, 2275803876, 2774886429, 3703342339,\n                2715860001, 1015326289, 2988607429, 1091753318, 1280790766, 779483175, 4181404689,\n                797271578, 3837324542, 965653269, 3998678544, 3707299808, 518493388, 2081242998,\n                565821490, 1370788325, 3775338190, 3238414037, 576068479, 2735674700, 1184491085,\n                4009553275, 3572635037, 1243646536, 2911509472, 2973906905, 1907167846, 1458306202,\n                2123107667, 989552556, 436261057, 605573158, 3483230043, 2880983042, 4168409866,\n                4019136255, 4253327858, 2651830192, 17400570, 109318954, 2078546974, 3534044718,\n                346014829, 3754708985, 592559018, 1742898159, 33427990, 856129692, 2342055152,\n                1941602123, 1408405136, 894595226, 2387883501, 3646482099, 3519957459, 2080906515,\n                1904107628, 3069440838, 3932421765, 3266993370, 4136525054, 4220115422, 788731893,\n                1686867215, 1519823776, 2877756565, 3793887677, 329226793, 3893797702, 3583826624,\n                1694823997, 696220909, 3611742558, 3078864649, 3766315815, 1632326088, 2654432468,\n                3981882671, 2280957273, 793625459, 1157977495, 1441316728, 197154581, 1561124715,\n                4189778267, 1333945477, 3967181114, 1421232429, 3533069272, 887767315, 2239652930,\n                1638811648, 3473233699, 1181657596, 3085652783, 1287675993, 2455078898, 1233237192,\n                2458447943, 204196519, 3524654715, 336439681, 3814153229, 3678776643, 2407863111,\n                2675325179, 2161593579, 1925372399, 675067792, 2605820490, 4256815185, 1323539594,\n                426745374, 715074163, 582328134, 2873514058, 2781239268, 466361343, 4220762639,\n                3844401378, 588421780, 899607035, 1173758884, 3529587577, 4191404586, 1689668754,\n                339535512, 11588832, 81658456, 477141048, 206734791, 3326055602, 1891545837,\n                117975561, 2547113968, 873099055, 682751521, 398130815, 2348739960, 182088623,\n                1296089616, 2510361486, 3939228547, 977564178, 3496437434, 1651453093, 2664075234,\n                4143568438, 387896255, 3402931396, 289202123, 2509994131, 385929339, 1853496317,\n                3349095771, 3744525316, 2501099484, 1571812210, 744319117, 1974272901, 862213254,\n                1175782054, 1175784197, 3493591642, 3451744657, 933240322, 2199334346, 2473006426,\n                1633463866, 448919678, 1987732235, 475336389, 2531498167, 2845909593, 672719533,\n                3917070486, 3812486327, 921951784, 935351493, 880449089, 3861127468, 2856437655,\n                1122235431, 1105796631, 1824141540, 3552996529, 1526795410, 634765135, 2225592783,\n                1934399617, 3018228838, 2932938217, 4119878576, 2645355264, 2039885213, 4107872338,\n                2577396222, 1300242611, 1610879235, 2886027894, 83647147, 1142510940, 1637400124,\n                3325978372, 1118962329, 1227985700, 4176365484, 4116884066, 93911175, 1843931255,\n                3241661048, 2946824243, 4229518060, 4153977648, 1821838858, 932057741, 3403948153,\n                681930575, 345042433, 3238398483, 3522674175, 1511145458, 2225511649, 1601323695,\n                2734513014, 2978365108, 1606989364, 946945525, 1990882013, 3195215258, 3914587165,\n                2448441155, 1748490947, 2249032459, 1619210750, 1164959769, 2865145797, 3737266053,\n                3035927303, 2962530478, 265946106, 833476822, 666127741, 3717419208, 2958451448,\n                244770831, 1823748962, 3500566168, 2067490898, 3303161181, 2858054390, 4069571771,\n                3028106864, 8735465, 3953855297, 659633477, 2990915486, 3679301885, 1463896161,\n                3797786358, 2022879581, 2799640567, 2175987369, 3245839346, 4240563036, 2551089091,\n            ],\n            &[\n                1659959583, 2904634437, 335609799, 4208083935, 2129829927, 3164938818, 1437094842,\n                4128695178, 776066331, 3206868490, 256975577, 3354430510, 2140456023, 4193571596,\n                4266016240, 1376301017, 506915445, 4013967736, 3657139290, 223860627, 3175388958,\n                599853167, 725799221, 4128800655, 1480213210, 175078040, 1886675185, 1738455879,\n                2008734389, 1737895694, 2834508091, 1703658096, 3507753057, 3993341225, 568791580,\n                1023600771, 874605814, 65887225, 30573824, 2705597852, 2665836303, 3561654523,\n                3508037727, 1392125564, 3754257083, 2020933944, 4083241095, 4072208472, 2907998249,\n                1804340494, 3200608953, 577970893, 486672367, 1814354067, 3513024420, 1138655286,\n                1536324596, 4110629631, 2808131793, 69933854, 2475345926, 2887472024, 4116014864,\n                4018460348, 608873722, 3537176373, 3911227381, 3805837398, 1420242961, 1313695988,\n                1355817019, 764772441, 1215440552, 2083287207, 642044699, 921046423, 2265142632,\n                906587028, 174772424, 4104145270, 4199953868, 717960181, 2001049957, 2366068998,\n                2336245127, 2655659318, 782347589, 3183312496, 3382146064, 4213611770, 2427981515,\n                1765643471, 3126151525, 1453973803, 3252697014, 1560005976, 855968672, 1728830740,\n                3385306541, 177162479, 1024782804, 268504726, 1300885248, 1892046392, 1894377755,\n                3334999753, 780888935, 152771001, 66154343, 753130677, 1724675242, 3416975300,\n                2011564755, 3092786038, 1173839777, 502502924, 3514522395, 3492457582, 1655067969,\n                298388618, 1507409745, 4042261481, 1925841276, 514542391, 3251704090, 1720846063,\n                1424865256, 3297538873, 1875557160, 3572248143, 3236552016, 618425118, 1198410399,\n                3256702606, 2084542045, 3780234755, 2145950572, 97693459, 544125496, 4169732002,\n                2879169387, 3259419966, 2845079327, 1681321406, 553984684, 1625241374, 3667423846,\n                3512256822, 179220058, 3368809252, 940925092, 2204117315, 911144717, 3702475909,\n                1079496526, 3502765039, 1331463976, 1674009176, 4251763704, 475983445, 3375462610,\n                2031227825, 405099033, 101760435, 2599463798, 2175561479, 253471718, 2996294940,\n                612011453, 736609471, 1270127612, 928651447, 832132468, 1202045767, 1512660791,\n                1685269400, 1866039474, 3003538147, 1306427040, 2419401400, 2727784058, 2592708024,\n                1060360987, 3688549328, 3939457653, 213067692, 1791205457, 2313629636, 2382874156,\n                2897125589, 3092816471, 1459440010, 140615575, 3161769034, 1594344003, 4022901885,\n                3044761935, 2388083845, 3637404570, 3671760657, 3492650532, 2761768206, 3954822945,\n                112327455, 3219134020, 1811940545, 1378571471, 3747780753, 2264252238, 2008656851,\n                2223880320, 858157798, 1785441029, 2737890036, 4190598099, 3967960030, 4007684525,\n                2861863392, 2650800814, 1535056048, 2444559101, 196252521, 1487672921, 1520614795,\n                3333508154, 3661606593, 629421626, 358772008, 4003360989, 2950979293, 931493453,\n                3325437104, 3144184501, 447882868, 2892677553, 3287394621, 2397328790, 2248463212,\n                1418526562, 2117014926, 3686766031, 298649829, 584205839, 3627557585, 2998315853,\n                2977920493, 726632938, 3587672184, 2031497493, 3536637527, 2147351398, 2994151365,\n                2357491055, 2685427052, 561736037, 249434731, 37851003, 2139420207, 1456949077,\n                3499596051, 2387808327, 698459036, 2829626440, 1153227452, 2967364067, 1308820861,\n                3023499589, 3279604314, 1351494432, 889784871, 236547645, 2007227680, 595443432,\n                1146281314, 3645152419, 3684480237, 1893493610, 3759196246, 1654652555, 1570985606,\n                3168763126, 1011656140, 443293510, 4075348841, 3769289235, 3178746711, 2447901158,\n                1462169783, 2059860955, 3176730687, 4250518815, 2494049638, 2842999845, 2660773548,\n                2429754290, 2910792523, 447755453, 1292065721, 1364296417, 531674748, 2193540777,\n                2412916570, 28609683, 2221611024, 3779881643, 4195316838, 743899040, 4213767553,\n                27880778, 1574053906, 1155505137, 439874260, 3750284675, 3525838570, 1095901379,\n                578703301, 3049020885, 3076480478, 600357557, 485719043, 2996666070, 969220829,\n                382916967, 4127194422, 1105131550, 1274911215, 804142925, 1973587943, 3032041047,\n                3584540133, 3351136224, 3543725084, 2962955598, 4293881521, 2425133896, 660514410,\n                3361169054, 77763049, 4229878743, 4011932021, 1090195601, 275885704, 3640421637,\n                1393243181, 1181392749, 3389311176, 2310097427, 289908933, 1711535789, 4033213111,\n                393665786, 923868932, 4018570793, 760848544, 674950332, 3344550397, 4011950991,\n                190003021, 4198189972, 3933037427, 3414307787, 3621605663, 3363592942, 2828152179,\n                644352484, 2918972032, 3175404448, 1785883817, 3697552954, 733843149, 286590854,\n                1214528285, 4166016418, 471561591, 2415332960, 1189766994, 1211081173, 4272651438,\n                3658504023, 755193424, 1817559547, 3945505192, 2450391056, 608673849, 1759503207,\n                340654448, 4134788276, 716854876, 1927628933, 3770411883, 3272236481, 3570235672,\n                326127009, 243730071, 1195661416, 3081806246, 3497515351, 2099772515, 1455307780,\n                1228408049, 4104831308, 1973834358, 4080297784, 578026510, 1512759928, 1470813128,\n                2584189047, 2637446524, 1698422615, 1284857912, 486923383, 174367540, 3702801188,\n                1161365394, 2737086689, 4265331868, 2412069202, 1870108327, 701659394, 2415165383,\n                1604722515, 2870993251, 471129547, 1280015857, 2050493217, 274565042, 2441183839,\n                3443859668, 2340505028, 1660404263, 2752768160, 560703857, 2104329624, 3452739653,\n                1013253476, 721912154, 1823929621, 3194765430, 1314309520, 4145569405, 1487647842,\n                1711679024, 1867628450, 2953439882, 1443642820, 2877245620, 2468137212, 3585016849,\n                2470055841, 2779688530, 3723417454, 2154058910, 1467213764, 3245268497, 4158596454,\n                4019385724, 2344037496, 1740779840, 4048853262, 1322676367, 2118663058, 2422287837,\n                2128664579, 2216474287, 1392815988, 747608508, 3828366939, 1008849042, 2597739640,\n                1600350391, 1209606111, 1982580858, 1492943335, 3554519928, 154739547, 1939048949,\n            ],\n            -1,\n        );\n        // - nn == 0 first time in limbs_half_gcd_jacobi\n        test(\n            &[\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967168,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                3,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294950912,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7,\n                0,\n                0,\n                0,\n                0,\n                3758096384,\n                524287,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2147483648,\n                16777215,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4290772992,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                32767,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967232,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                31,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3758096384,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294934528,\n                u32::MAX,\n                u32::MAX,\n                536870911,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4286578688,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                3758096384,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                2047,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                65535,\n                4227858432,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                15,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            -1,\n        );\n        // - n <= s + 2 in limbs_half_gcd_jacobi\n        test(\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                262143,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4026531840,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16383,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3758096384,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                131071,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4293918720,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                2147483648,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16777215,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4160749568,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                7,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967264,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                134217727,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                3758096384,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                536870911,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294836224,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                15,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n            ],\n            1,\n        );\n        // - nn == 0 second time in limbs_half_gcd_jacobi\n        // - nn == 0\n        // - n == 0 first time\n        // - bits == BITS_FAIL first time\n        test(\n            &[\n                1077171533, 3384534038, 3509377481, 3012981171, 2169372009, 3568066367, 510541737,\n                360351115, 1116770051, 2058732872, 3226198045, 1078176389, 2950624729, 812262025,\n                1430083408, 61306667, 64349919, 2388720201, 2804807299, 3487065571, 1162686670,\n                2184575935, 1234374819, 3462973209, 2204618738, 1955732567, 4274764191, 487910035,\n                2794693464, 1455130957, 2647605728, 4211289912, 3386405281, 117329687, 3432428417,\n                1300225461, 3461206919, 449524200, 904979455, 3971171435, 441380375, 1283836003,\n                2682594354, 1152961793, 1318795928, 308922730, 628004645, 1003117196, 1035594263,\n                3028460626, 3737759554, 3080878651, 2013071269, 157811103, 3209212678, 1794098871,\n                1571763958, 4118994167, 3323265833, 2779923965, 1781531454, 3074442432, 1330835008,\n                231050954, 1972822306, 3779389322, 2550908177, 1122947161, 2607600449, 2966179614,\n                1165225297, 4222222976, 1020266087, 1019514006, 53769477, 62821411, 3078440286,\n                2087323177, 4209236301, 146146381, 453393163, 4244430148, 624415024, 2096395426,\n                1915435196, 3779399544, 3641826296, 4157323023, 4049792386, 1892149154, 2185863226,\n                1046224168, 3568999985, 982204298, 154455361, 2605934809, 2605177974, 1652215061,\n                3058430834, 1573346022, 3979000833, 1424146496, 758475042, 3880559465, 3331749655,\n                4009275982, 309023272, 343958017, 2544085697, 1960862631, 1082361995, 534185037,\n                331011064, 3662295811, 3280920837, 2366184597, 1029851460, 1149922348, 3242309342,\n                3498011365, 1869617138, 2033933372, 2449772239, 1769059102, 552671522, 2541136194,\n                1837261562, 3331388737, 3882095076, 2111080116, 3488393361, 3110154197, 2503543094,\n                276095820, 109038743, 3401659741, 2955647843, 3730124703, 4288579615, 2840357519,\n                433563482, 3742367408, 2287152115, 3054337338, 2305325930, 1838329967, 1117989732,\n                2731369203, 427022429, 1959348870, 107371881, 1378273431, 3969746745, 137314119,\n                3494302009, 2316521941, 1304670415, 2017956904, 3960566359, 3950960171, 2483760563,\n                3248620299, 1282201932, 2666453601, 290925463, 1315172510, 2244058356, 83064665,\n                2794575253, 2751020494, 86251099, 1497864163, 1309606664, 918139255, 2382232313,\n                3431694285, 4197334044, 3779739436, 2597050321, 4053750034, 1347898240, 2068381165,\n                530540195, 777294114, 1563424547, 714733079, 251090961, 1222614986, 409927269,\n                2552943554, 3813553790, 2619995688, 2754487462, 1001623689, 4043538191, 780110724,\n                2756539090, 2640687797, 2974350673, 1702213372, 2898669867, 232176052, 2414666354,\n                300281312, 3252747308, 2375533144, 3579260801, 3856594937, 226065085, 2855017957,\n                4106625762, 4251800319, 271717704, 796181594, 2015816818, 572129733, 1578027849,\n                208352494, 3329313861, 3272451839, 1390383564, 3754291474, 1022210892, 3402379185,\n                1055267474, 2105880379, 1377373336, 2125916506, 3713096588, 3227913500, 593660170,\n                3662162553, 948899397, 3959019656, 743736078, 561608271, 4154259253, 753202703,\n                3057879152, 4093431092, 2849520862, 1298183896, 1072767461, 3844624206, 1553109174,\n                2211737614, 2944064724, 1134344972, 2846368205, 2535247938, 1454739286, 1408186915,\n                3022639671, 2985835925, 1242350664, 856614531, 3277904750, 2435844371, 2288413570,\n                1941580081, 2330069009, 3763753263, 1617186357, 3858822820, 3899619764, 957776791,\n                2415934649, 1903499570, 362345092, 3162421697, 857308796, 2166848441, 2794392063,\n                2916482641, 547554093, 393697940, 319583576, 3206427070, 3502792667, 3979846702,\n                3580352012, 3854879140, 3646613450, 4113031775, 856333171, 1029998771, 2090645466,\n                3125086584, 2494710984, 3249027001, 3828101842, 4278721100, 2901896440, 3549366611,\n                2066085974, 3815811960, 2980213693, 2418009668, 4168963107, 1522903282, 3921187989,\n                209293309, 1026651789, 3652402308, 1723212287, 3005358245, 3972955479, 3432513818,\n                1135457591, 2609451544, 1728509125, 1610815908, 1281322374, 2308282400, 1650462965,\n                785788526, 3039230497, 1454810597, 2847801652, 868324593, 2811238675, 1592440137,\n                2837082164, 2293886194, 108023352, 1338057151, 867454780, 660204887, 2727424012,\n                3251699301, 2307270502, 3508727390, 444210859, 4112897129, 1692014843, 232384981,\n                3746950478, 2035293041, 832494472, 4167968781, 2088468820, 1082123254, 2004377194,\n                739887690, 3903970376, 3917684808, 2220241302, 1623595193, 3168893289, 1380144222,\n                3245294302, 1942246969, 1017235276, 1075796476, 1420638313, 2370978268, 3571300703,\n                2818383559, 3979048442, 4070073076, 3639658932, 2458302928, 1936855091, 1097653713,\n                2517446959, 395058431, 2490534065, 3621579656, 537422087, 820775047, 1621745064,\n                4147607605, 773085439, 150346009, 3309770346, 623052976, 223120997, 1047915001,\n                2440220896, 2701090680, 682463717, 626719149, 2752394251, 2245504316, 3599570937,\n                1008202886, 3061625147, 3833145985, 2287104975, 3419855448, 542949621, 2260871982,\n                3411141468, 1089194931, 3865896761, 1906114014, 3523746087, 3034843700, 3980408914,\n                1779312499, 2670385907, 3943945115, 3040560985, 968208310,\n            ],\n            &[\n                1077171533, 3384534038, 3509377481, 3012981171, 2169372009, 3568066367, 510541737,\n                360351115, 1116770051, 2058732872, 3226198045, 1078176389, 2950624729, 812262025,\n                1430083408, 61306667, 64349919, 2388720201, 2804807299, 3487065571, 1162686670,\n                2184575935, 1234374819, 3462973209, 2204618738, 1955732567, 4274764191, 487910035,\n                2794693464, 1455130957, 2647605728, 4211289912, 3386405281, 117329687, 3432428417,\n                1300225461, 3461206919, 449524200, 904979455, 3971171435, 441380375, 1283836003,\n                2682594354, 1152961793, 1318795928, 308922730, 628004645, 1003117196, 1035594263,\n                3028460626, 3737759554, 3080878651, 2013071269, 157811103, 3209212678, 1794098871,\n                1571763958, 4118994167, 3323265833, 2779923965, 1781531454, 3074442432, 1330835008,\n                231050954, 1972822306, 3779389322, 2550908177, 1122947161, 2607600449, 2966179614,\n                1165225297, 4222222976, 1020266087, 1019514006, 53769477, 62821411, 3078440286,\n                2087323177, 4209236301, 146146381, 453393163, 4244430148, 624415024, 2096395426,\n                1915435196, 3779399544, 3641826296, 4157323023, 4049792386, 1892149154, 2185863226,\n                1046224168, 3568999985, 982204298, 154455361, 2605934809, 2605177974, 1652215061,\n                3058430834, 1573346022, 3979000833, 1424146496, 758475042, 3880559465, 3331749655,\n                4009275982, 309023272, 343958017, 2544085697, 1960862631, 1082361995, 534185037,\n                331011064, 3662295811, 3280920837, 2366184597, 1029851460, 1149922348, 3242309342,\n                3498011365, 1869617138, 2033933372, 2449772239, 1769059102, 552671522, 2541136194,\n                1837261562, 3331388737, 3882095076, 2111080116, 3488393361, 3110154197, 2503543094,\n                276095820, 109038743, 3401659741, 2955647843, 3730124703, 4288579615, 2840357519,\n                433563482, 3742367408, 2287152115, 3054337338, 2305325930, 1838329967, 1117989732,\n                2731369203, 427022429, 1959348870, 107371881, 1378273431, 3969746745, 137314119,\n                3494302009, 2316521941, 1304670415, 2017956904, 3960566359, 3950960171, 2483760563,\n                3248620299, 1282201932, 2666453601, 290925463, 1315172510, 2244058356, 83064665,\n                2794575253, 2751020494, 86251099, 1497864163, 1309606664, 918139255, 2382232313,\n                3431694285, 4197334044, 3779739436, 2597050321, 4053750034, 1347898240, 2068381165,\n                530540195, 777294114, 1563424547, 714733079, 251090961, 1222614986, 409927269,\n                2552943554, 3813553790, 2619995688, 2754487462, 1001623689, 4043538191, 780110724,\n                2756539090, 2640687797, 2974350673, 1702213372, 2898669867, 232176052, 2414666354,\n                300281312, 3252747308, 2375533144, 3579260801, 3856594937, 226065085, 2855017957,\n                4106625762, 4251800319, 271717704, 796181594, 2015816818, 572129733, 1578027849,\n                208352494, 3329313861, 3272451839, 1390383564, 3754291474, 1022210892, 3402379185,\n                1055267474, 2105880379, 1377373336, 2125916506, 3713096588, 3227913500, 593660170,\n                3662162553, 948899397, 3959019656, 743736078, 561608271, 4154259253, 753202703,\n                3057879152, 4093431092, 2849520862, 1298183896, 1072767461, 3844624206, 1553109174,\n                2211737614, 2944064724, 1134344972, 2846368205, 2535247938, 1454739286, 1408186915,\n                3022639671, 2985835925, 1242350664, 856614531, 3277904750, 2435844371, 2288413570,\n                1941580081, 2330069009, 3763753263, 1617186357, 3858822820, 3899619764, 957776791,\n                2415934649, 1903499570, 362345092, 3162421697, 857308796, 2166848441, 2794392063,\n                2916482641, 547554093, 393697940, 319583576, 3206427070, 3502792667, 3979846702,\n                3580352012, 3854879140, 3646613450, 4113031775, 856333171, 1029998771, 2090645466,\n                3125086584, 2494710984, 3249027001, 3828101842, 4278721100, 2901896440, 3549366611,\n                2066085974, 3815811960, 2980213693, 2418009668, 4168963107, 1522903282, 3921187989,\n                209293309, 1026651789, 3652402308, 1723212287, 3005358245, 3972955479, 3432513818,\n                1135457591, 2609451544, 1728509125, 1610815908, 1281322374, 2308282400, 1650462965,\n                785788526, 3039230497, 1454810597, 2847801652, 868324593, 2811238675, 1592440137,\n                2837082164, 2293886194, 108023352, 1338057151, 867454780, 660204887, 2727424012,\n                3251699301, 2307270502, 3508727390, 444210859, 4112897129, 1692014843, 232384981,\n                3746950478, 2035293041, 832494472, 4167968781, 2088468820, 1082123254, 2004377194,\n                739887690, 3903970376, 3917684808, 2220241302, 1623595193, 3168893289, 1380144222,\n                3245294302, 1942246969, 1017235276, 1075796476, 1420638313, 2370978268, 3571300703,\n                2818383559, 3979048442, 4070073076, 3639658932, 2458302928, 1936855091, 1097653713,\n                2517446959, 395058431, 2490534065, 3621579656, 537422087, 820775047, 1621745064,\n                4147607605, 773085439, 150346009, 3309770346, 623052976, 223120997, 1047915001,\n                2440220896, 2701090680, 682463717, 626719149, 2752394251, 2245504316, 3599570937,\n                1008202886, 3061625147, 3833145985, 2287104975, 3419855448, 542949621, 2260871982,\n                3411141468, 1089194931, 3865896761, 1906114014, 3523746087, 3034843700, 3980408914,\n                1779312499, 2670385907, 3943945115, 3040560985, 968208310,\n            ],\n            0,\n        );\n        // - n != 0 first time\n        test(\n            &[\n                2527776570, 1096068921, 3262306218, 1320735475, 3585033863, 837181718, 1434028202,\n                101347753, 1225665622, 67225439, 876392417, 2005928391, 1055641927, 2192872866,\n                2819789958, 730215470, 1621800044, 4036225587, 3556548105, 3110943208, 3185668368,\n                2027089067, 2101840218, 4225448827, 3021189927, 4280012260, 3622060673, 2596479319,\n                2588713825, 1028636336, 3005767087, 1249021277, 4164898722, 731420324, 1545357905,\n                1990024360, 2640852447, 2424127910, 1870854337, 1406415699, 2196092126, 1310967564,\n                232318981, 3146607976, 4083502397, 22174679, 3737886384, 3144967018, 4263470608,\n                3780127714, 2165861131, 3336828897, 1694667359, 1492938371, 494778850, 3046154974,\n                1157896728, 3074135421, 2504833163, 810655235, 1557262964, 1363420755, 2702433995,\n                1177464584, 3371204921, 3586238385, 281106173, 1653503734, 2385994192, 3794586631,\n                3194300174, 847482886, 2910519739, 3968032513, 1772081491, 2782405946, 4234346611,\n                3594663949, 2600834058, 1201913439, 3836544822, 2596924324, 3356614882, 1073086697,\n                4071118647, 1627306041, 25361421, 5025, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0,\n            ],\n            &[\n                5737393, 656355346, 2428436877, 1659347327, 1816624877, 3040364388, 1159326770,\n                4206559661, 3092296489, 1558251555, 1049236200, 2222235583, 2014235172, 3291004209,\n                934339935, 985867991, 762407537, 1409401405, 778491764, 3564656357, 128109175,\n                2460849082, 1890568470, 461692287, 817897242, 602238225, 920048131, 3418406322,\n                708192111, 2567463295, 1875671904, 1148800469, 3212120696, 566830399, 1427401847,\n                3369501422, 3485886037, 2817269664, 2227802377, 4283410186, 2703903094, 936664805,\n                4157101885, 2263955722, 2647106937, 537917125, 4056960194, 3912645532, 354245311,\n                2717804064, 1109582468, 2727640815, 425052729, 2611473321, 3879075705, 716899167,\n                1914192905, 2601501681, 462694240, 205229129, 1093878128, 410346932, 3439980661,\n                667954709, 1052656728, 2148601811, 2379731442, 2268999665, 3706142073, 1456579358,\n                3757504240, 463695214, 1436957313, 2049267296, 3303570927, 1864647396, 900688508,\n                1835551150, 71395285, 1425899737, 2287259914, 962161837, 2938663406, 2857261272,\n                1146595809, 3764487743, 3300056528, 3137301789, 250445987, 1997329543, 192312160,\n                3417776853, 3623584574, 2403647678, 3849791382, 3065151486, 2112108309, 2184865682,\n                2147711161, 3337243558, 2646696137, 3744234210, 3469704297, 804280152, 2812030004,\n                283967646, 1530700123, 2959520978, 133999661, 1311943460, 2409420442, 1378063817,\n                1306691126, 2795816917, 175853898, 3436153597, 4094879999, 4061387058, 3142348235,\n                3450122749, 997635528, 2383423341, 946776870, 1390313886, 4272495253, 1329111605,\n                1783381058, 1235280956, 878145167, 1050060880, 4215806346, 986268144, 2398596766,\n                1847782969, 2662963332, 320753973, 961489657, 643166461, 3665561600, 903526756,\n                861869280, 1582519883, 1724972430, 3647434888, 922278554, 1608919692, 3498480811,\n                606385525, 1264439673, 1258996822, 3155308373, 1047873974, 2173644429, 1417008977,\n                935021011, 722697374, 3318510778, 638992840, 1692733318, 1533146701, 2599254955,\n                3256732986, 11478574, 3245879834, 3651129160, 890914331, 1936401914, 4269069338,\n                652796490, 1855438614, 3711917465, 2231167869, 965528216, 4083742438, 3888862032,\n                4027832595, 3194731005, 3855267812, 1331497794, 1036129210, 2454849236, 3936763814,\n                2166230922, 2221233340, 3494633119, 2135677604, 1957161469, 3441858755, 3165789630,\n                3502273733, 3935502624, 935473926, 951630970, 3241427305, 3626833422, 3344353486,\n                384196385, 2893969144, 371257580, 1895300995, 1538534547, 4247925735, 3906194642,\n                3278920998, 190467029, 660834078, 3047471694, 3139110501, 2945327231, 2791821139,\n                3787430397, 11897902, 3071804998, 2906353083, 3986347125, 728226352, 1721418756,\n                3790033644, 2543845828, 4201817595, 1241190909, 2172638407, 3176874190, 212681671,\n                2217059787, 2568436099, 4160058240, 1550824349, 1589798596, 2384281069, 4106120578,\n                1772814852, 2711184704, 1753902606, 3147375646, 3197706153, 4069187110, 2497336677,\n                682542752, 3631288002, 1821492432, 4111201809, 3496083848, 488832033, 1487521654,\n                1028323258, 2626975117, 3820273648, 4203958355, 1957204165, 692251647, 751713885,\n                2869803205, 699099042, 287040513, 1256261134, 1435317843, 2516495821, 2172617698,\n                2350001365, 3127743304, 4210222956, 2394254147, 1395276753, 2466938438, 1054538356,\n                145981627, 152373092, 2285902580, 534742531, 2919481209, 1870713895, 800843175,\n                3498230341, 29966677, 1374519390, 1746138239, 90290568, 2136928464, 1012080534,\n                4220785618, 2331149605, 3177894074, 4194250977, 1793677512, 1812254290, 755277024,\n                1050843937, 1441079766, 4177809358, 2569374720, 2516736232, 1486921399, 666656868,\n                1100619139, 2587149122, 2221024508, 2951375366, 2349454937, 4266896936, 4091705443,\n                4244036995, 3327195836, 2611529411, 538404573, 3970374943, 3102287318, 1164998997,\n                521166464, 3125925988, 360672675, 3568959356, 1328059403, 2778221822, 347086039,\n                3797350591, 3600929164, 849738110, 3879666101, 2751748132, 3317854867, 2059575942,\n                3146620321, 1367551383, 2518113922, 2136751883, 4171468116, 4267631229, 3031791643,\n                2334887552, 2773212213, 480854415, 482867572, 8189,\n            ],\n            1,\n        );\n        // - nn == 0 third time in limbs_half_gcd_jacobi\n        test(\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1023,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967280,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                8191,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967288,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                8388607,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4278190080,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16383,\n                0,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                134217727,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294965248,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                511,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4290772992,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                262143,\n                0,\n                0,\n                4292870144,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                524287,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967294,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                1,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4278190080,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                16777215,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967292,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                65535,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                0,\n                4294967168,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            0,\n        );\n        // - bits != BITS_FAIL first time\n        test(\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0,\n            ],\n            &[\n                1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n                0, 1,\n            ],\n            1,\n        );\n    }\n}\n\n#[test]\nfn test_legendre_symbol() {\n    fn test(u: &str, v: &str, s: i8) {\n        let a = Natural::from_str(u).unwrap();\n        let n = Natural::from_str(v).unwrap();\n\n        assert_eq!(a.clone().legendre_symbol(n.clone()), s);\n        assert_eq!(a.clone().legendre_symbol(&n), s);\n        assert_eq!((&a).legendre_symbol(n.clone()), s);\n        assert_eq!((&a).legendre_symbol(&n), s);\n\n        assert_eq!(a.clone().jacobi_symbol(n.clone()), s);\n        assert_eq!(a.clone().jacobi_symbol(&n), s);\n        assert_eq!((&a).jacobi_symbol(n.clone()), s);\n        assert_eq!((&a).jacobi_symbol(&n), s);\n\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!((&a).kronecker_symbol(&n), s);\n\n        assert_eq!(jacobi_symbol_simple(a, n), s);\n        assert_eq!(\n            rug::Integer::from_str(u)\n                .unwrap()\n                .legendre(&rug::Integer::from_str(v).unwrap()),\n            i32::from(s)\n        );\n    }\n    test(\"0\", \"3\", 0);\n    test(\"1\", \"3\", 1);\n    test(\"2\", \"3\", -1);\n    test(\"0\", \"5\", 0);\n    test(\"1\", \"5\", 1);\n    test(\"2\", \"5\", -1);\n    test(\"3\", \"5\", -1);\n    test(\"4\", \"5\", 1);\n    test(\"0\", \"7\", 0);\n    test(\"1\", \"7\", 1);\n    test(\"2\", \"7\", 1);\n    test(\"3\", \"7\", -1);\n    test(\"4\", \"7\", 1);\n    test(\"5\", \"7\", -1);\n    test(\"6\", \"7\", -1);\n\n    test(\"7\", \"7\", 0);\n    test(\"8\", \"7\", 1);\n    test(\"9\", \"7\", 1);\n    test(\"10\", \"7\", -1);\n    test(\"11\", \"7\", 1);\n    test(\"12\", \"7\", -1);\n    test(\"13\", \"7\", -1);\n\n    test(\"1001\", \"9907\", -1);\n    test(\"10908\", \"9907\", -1);\n}\n\n#[test]\nfn legendre_symbol_fail() {\n    assert_panic!(Natural::ONE.legendre_symbol(Natural::TWO));\n    assert_panic!(Natural::ONE.legendre_symbol(&Natural::TWO));\n    assert_panic!((&Natural::ONE).legendre_symbol(Natural::TWO));\n    assert_panic!((&Natural::ONE).legendre_symbol(&Natural::TWO));\n}\n\n#[test]\nfn test_jacobi_symbol() {\n    fn test(u: &str, v: &str, s: i8) {\n        let a = Natural::from_str(u).unwrap();\n        let n = Natural::from_str(v).unwrap();\n\n        assert_eq!(a.clone().jacobi_symbol(n.clone()), s);\n        assert_eq!(a.clone().jacobi_symbol(&n), s);\n        assert_eq!((&a).jacobi_symbol(n.clone()), s);\n        assert_eq!((&a).jacobi_symbol(&n), s);\n\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!((&a).kronecker_symbol(&n), s);\n\n        assert_eq!(jacobi_symbol_simple(a, n), s);\n        assert_eq!(\n            rug::Integer::from_str(u)\n                .unwrap()\n                .jacobi(&rug::Integer::from_str(v).unwrap()),\n            i32::from(s)\n        );\n    }\n    test(\"0\", \"1\", 1);\n    test(\"0\", \"9\", 0);\n    test(\"1\", \"9\", 1);\n    test(\"2\", \"9\", 1);\n    test(\"3\", \"9\", 0);\n    test(\"4\", \"9\", 1);\n    test(\"5\", \"9\", 1);\n    test(\"6\", \"9\", 0);\n    test(\"7\", \"9\", 1);\n    test(\"8\", \"9\", 1);\n\n    test(\"9\", \"9\", 0);\n    test(\"10\", \"9\", 1);\n    test(\"11\", \"9\", 1);\n    test(\"12\", \"9\", 0);\n    test(\"13\", \"9\", 1);\n    test(\"14\", \"9\", 1);\n    test(\"15\", \"9\", 0);\n    test(\"16\", \"9\", 1);\n    test(\"17\", \"9\", 1);\n}\n\n#[test]\nfn jacobi_symbol_fail() {\n    assert_panic!(Natural::ONE.jacobi_symbol(Natural::TWO));\n    assert_panic!(Natural::ONE.jacobi_symbol(&Natural::TWO));\n    assert_panic!((&Natural::ONE).jacobi_symbol(Natural::TWO));\n    assert_panic!((&Natural::ONE).jacobi_symbol(&Natural::TWO));\n}\n\n// Odd n is already tested in test_jacobi_symbol, so here we just test even n\n#[test]\nfn test_kronecker_symbol() {\n    fn test(u: &str, v: &str, s: i8) {\n        let a = Natural::from_str(u).unwrap();\n        let n = Natural::from_str(v).unwrap();\n\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!((&a).kronecker_symbol(&n), s);\n        assert_eq!(\n            rug::Integer::from_str(u)\n                .unwrap()\n                .kronecker(&rug::Integer::from_str(v).unwrap()),\n            i32::from(s)\n        );\n    }\n    test(\"0\", \"2\", 0);\n    test(\"1\", \"2\", 1);\n    test(\"2\", \"2\", 0);\n    test(\"3\", \"2\", -1);\n    test(\"4\", \"2\", 0);\n    test(\"5\", \"2\", -1);\n    test(\"6\", \"2\", 0);\n    test(\"7\", \"2\", 1);\n    test(\"0\", \"4\", 0);\n    test(\"1\", \"4\", 1);\n    test(\"2\", \"4\", 0);\n    test(\"3\", \"4\", 1);\n    test(\"0\", \"6\", 0);\n    test(\"1\", \"6\", 1);\n    test(\"2\", \"6\", 0);\n    test(\"3\", \"6\", 0);\n    test(\"4\", \"6\", 0);\n    test(\"5\", \"6\", 1);\n    test(\"6\", \"6\", 0);\n    test(\"7\", \"6\", 1);\n    test(\"8\", \"6\", 0);\n    test(\"9\", \"6\", 0);\n    test(\"10\", \"6\", 0);\n    test(\"11\", \"6\", 1);\n    test(\"12\", \"6\", 0);\n    test(\"13\", \"6\", -1);\n    test(\"14\", \"6\", 0);\n    test(\"15\", \"6\", 0);\n    test(\"16\", \"6\", 0);\n    test(\"17\", \"6\", -1);\n    test(\"18\", \"6\", 0);\n    test(\"19\", \"6\", -1);\n    test(\"20\", \"6\", 0);\n    test(\"21\", \"6\", 0);\n    test(\"22\", \"6\", 0);\n    test(\"23\", \"6\", -1);\n\n    test(\"1001\", \"9908\", -1);\n    test(\"10909\", \"9908\", -1);\n}\n\n#[test]\nfn limbs_jacobi_symbol_same_length_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 256);\n    config.insert(\"mean_stripe_n\", 32 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_32().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let x = Natural::from_limbs_asc(&xs);\n        let y = Natural::from_limbs_asc(&ys);\n        let s = (&x).jacobi_symbol(&y);\n        assert_eq!(jacobi_symbol_simple(x, y), s);\n        let bits = limbs_jacobi_symbol_init(xs[0], ys[0], 0);\n        assert_eq!(limbs_jacobi_symbol_same_length(&mut xs, &mut ys, bits), s);\n    });\n}\n\n#[test]\nfn jacobi_symbol_properties() {\n    natural_pair_gen_var_12().test_properties(|(a, n)| {\n        let s = (&a).jacobi_symbol(&n);\n        assert_eq!((&a).jacobi_symbol(n.clone()), s);\n        assert_eq!(a.clone().jacobi_symbol(&n), s);\n        assert_eq!(a.clone().jacobi_symbol(n.clone()), s);\n\n        // Legendre should only be called on prime n, but it still works for non-prime odd n and we\n        // can't currently test primality anyway.\n        assert_eq!((&a).legendre_symbol(&n), s);\n        assert_eq!((&a).legendre_symbol(n.clone()), s);\n        assert_eq!(a.clone().legendre_symbol(&n), s);\n        assert_eq!(a.clone().legendre_symbol(n.clone()), s);\n\n        assert_eq!((&a).kronecker_symbol(&n), s);\n        assert_eq!((&a).kronecker_symbol(n.clone()), s);\n        assert_eq!(a.clone().kronecker_symbol(&n), s);\n        assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n\n        assert_eq!(jacobi_symbol_simple(a.clone(), n.clone()), s);\n        assert_eq!(\n            rug::Integer::from(&a).jacobi(&rug::Integer::from(&n)),\n            i32::from(s)\n        );\n        assert!(s.le_abs(&1i8));\n\n        assert_eq!((&a + &n).jacobi_symbol(&n), s);\n        if a >= n {\n            assert_eq!((&a - &n).jacobi_symbol(&n), s);\n        }\n        assert_eq!(s != 0, (&a).coprime_with(&n));\n        let n_mod_8: u8 = (&(&n).mod_power_of_2(3)).wrapping_into();\n        assert_eq!(\n            (a << 1u32).jacobi_symbol(n),\n            if n_mod_8 == 1 || n_mod_8 == 7 { s } else { -s }\n        );\n    });\n\n    natural_pair_gen_var_13().test_properties(|(m, n)| {\n        let n_mod_4: u8 = (&(&n).mod_power_of_2(2)).wrapping_into();\n        let m_mod_4: u8 = (&(&m).mod_power_of_2(2)).wrapping_into();\n        assert_eq!(\n            (&m).jacobi_symbol(&n) * n.jacobi_symbol(m),\n            if n_mod_4 == 1 || m_mod_4 == 1 { 1 } else { -1 }\n        );\n    });\n\n    natural_triple_gen_var_8().test_properties(|(a, b, n)| {\n        assert_eq!(\n            (&a * &b).jacobi_symbol(&n),\n            a.jacobi_symbol(&n) * b.jacobi_symbol(n)\n        );\n    });\n\n    natural_triple_gen_var_9().test_properties(|(a, m, n)| {\n        assert_eq!(\n            (&a).jacobi_symbol(&m * &n),\n            (&a).jacobi_symbol(m) * a.jacobi_symbol(n)\n        );\n    });\n\n    natural_gen_var_8().test_properties(|n| {\n        if n != 1u32 {\n            assert_eq!(Natural::ZERO.jacobi_symbol(&n), 0);\n            assert_eq!((&n).jacobi_symbol(&n), 0);\n        }\n        assert_eq!(Natural::ONE.jacobi_symbol(&n), 1);\n        assert_eq!((&n).jacobi_symbol(Natural::ONE), 1);\n        let n_mod_4: u8 = (&(&n).mod_power_of_2(2)).wrapping_into();\n        assert_eq!(\n            (&n - Natural::ONE).jacobi_symbol(&n),\n            if n_mod_4 == 1 { 1 } else { -1 }\n        );\n        let n_mod_8: u8 = (&(&n).mod_power_of_2(3)).wrapping_into();\n        assert_eq!(\n            Natural::TWO.jacobi_symbol(&n),\n            if n_mod_8 == 1 || n_mod_8 == 7 { 1 } else { -1 }\n        );\n    });\n\n    unsigned_pair_gen_var_40::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Natural::from(x).jacobi_symbol(Natural::from(y)),\n            x.jacobi_symbol(y)\n        );\n    });\n}\n\nfn kronecker_symbol_properties_helper(a: Natural, n: Natural) {\n    let s = (&a).kronecker_symbol(&n);\n    assert_eq!((&a).kronecker_symbol(n.clone()), s);\n    assert_eq!(a.clone().kronecker_symbol(&n), s);\n    assert_eq!(a.clone().kronecker_symbol(n.clone()), s);\n\n    assert_eq!(\n        rug::Integer::from(&a).kronecker(&rug::Integer::from(&n)),\n        i32::from(s)\n    );\n    assert!(s.le_abs(&1i8));\n\n    assert_eq!(s != 0, (&a).coprime_with(&n));\n    let n_mod_4: u8 = (&(&n).mod_power_of_2(2)).wrapping_into();\n    if n_mod_4 == 2 {\n        let four_n = &n << 2u32;\n        assert_eq!((&a + &four_n).kronecker_symbol(&n), s);\n        if a >= four_n {\n            assert_eq!((&a - four_n).kronecker_symbol(&n), s);\n        }\n    } else {\n        assert_eq!((&a + &n).kronecker_symbol(&n), s);\n        if a >= n {\n            assert_eq!((&a - &n).kronecker_symbol(&n), s);\n        }\n    }\n    let a_mod_4: u8 = (&(&a).mod_power_of_2(2)).wrapping_into();\n    if a != 0u32 && a_mod_4 != 3 {\n        if a_mod_4 == 2 {\n            let four_a = &a << 2u32;\n            assert_eq!((&a).kronecker_symbol(&n + &four_a), s);\n            if n >= four_a {\n                assert_eq!((&a).kronecker_symbol(&n - four_a), s);\n            }\n        } else {\n            assert_eq!((&a).kronecker_symbol(&n + &a), s);\n            if n >= a {\n                let diff = n - &a;\n                assert_eq!((a).kronecker_symbol(diff), s);\n            }\n        }\n    }\n}\n\n#[test]\nfn kronecker_symbol_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 512 << Limb::LOG_WIDTH);\n    natural_pair_gen().test_properties_with_config(&config, |(x, y)| {\n        kronecker_symbol_properties_helper(x, y);\n    });\n\n    natural_pair_gen_var_4().test_properties_with_config(&config, |(x, y)| {\n        kronecker_symbol_properties_helper(x, y);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!(\n            (&x * &y).kronecker_symbol(&z),\n            (&x).kronecker_symbol(&z) * (&y).kronecker_symbol(&z)\n        );\n        assert_eq!(\n            (&x).kronecker_symbol(&y * &z),\n            (&x).kronecker_symbol(y) * x.kronecker_symbol(z)\n        );\n    });\n\n    natural_pair_gen_var_14().test_properties(|(m, n)| {\n        let n_odd = if n == 0u32 {\n            Natural::ONE\n        } else {\n            &n >> n.trailing_zeros().unwrap()\n        };\n        let m_odd = if m == 0u32 {\n            Natural::ONE\n        } else {\n            &m >> m.trailing_zeros().unwrap()\n        };\n        let n_odd_mod_4: u8 = (&n_odd.mod_power_of_2(2)).wrapping_into();\n        let m_odd_mod_4: u8 = (&m_odd.mod_power_of_2(2)).wrapping_into();\n        let p = if n_odd_mod_4 == 1 || m_odd_mod_4 == 1 {\n            1\n        } else {\n            -1\n        };\n        assert_eq!((&m).kronecker_symbol(&n) * n.kronecker_symbol(m), p);\n    });\n\n    natural_gen().test_properties(|n| {\n        if n != 1u32 {\n            assert_eq!(Natural::ZERO.kronecker_symbol(&n), 0);\n            assert_eq!((&n).kronecker_symbol(&n), 0);\n        }\n        assert_eq!(Natural::ONE.kronecker_symbol(&n), 1);\n        assert_eq!(n.kronecker_symbol(Natural::ONE), 1);\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Natural::from(x).kronecker_symbol(Natural::from(y)),\n            x.kronecker_symbol(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/lcm.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivExact, DivisibleBy, Gcd, Lcm, LcmAssign};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_34;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse num::BigUint;\nuse num::Integer as rug_integer;\nuse std::str::FromStr;\n\n#[test]\nfn test_lcm() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.lcm_assign(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.lcm_assign(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().lcm(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).lcm(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().lcm(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).lcm(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigUint::from_str(s)\n            .unwrap()\n            .lcm(&BigUint::from_str(t).unwrap());\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s)\n            .unwrap()\n            .lcm(&rug::Integer::from_str(t).unwrap());\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"6\", \"0\");\n    test(\"6\", \"0\", \"0\");\n    test(\"1\", \"6\", \"6\");\n    test(\"6\", \"1\", \"6\");\n    test(\"8\", \"12\", \"24\");\n    test(\"54\", \"24\", \"216\");\n    test(\"42\", \"56\", \"168\");\n    test(\"48\", \"18\", \"144\");\n    test(\"3\", \"5\", \"15\");\n    test(\"12\", \"60\", \"60\");\n    test(\"12\", \"90\", \"180\");\n    test(\n        \"12345678987654321\",\n        \"98765432123456789\",\n        \"1219326320073159566072245112635269\",\n    );\n    test(\n        \"12345678987654321\",\n        \"98765432123456827\",\n        \"32954765407382703654271530905391\",\n    );\n}\n\n#[test]\nfn lcm_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let lcm_val_val = x.clone().lcm(y.clone());\n        let lcm_val_ref = x.clone().lcm(&y);\n        let lcm_ref_val = (&x).lcm(y.clone());\n        let lcm = (&x).lcm(&y);\n        assert!(lcm_val_val.is_valid());\n        assert!(lcm_val_ref.is_valid());\n        assert!(lcm_ref_val.is_valid());\n        assert!(lcm.is_valid());\n        assert_eq!(lcm_val_val, lcm);\n        assert_eq!(lcm_val_ref, lcm);\n        assert_eq!(lcm_ref_val, lcm);\n\n        let mut mut_x = x.clone();\n        mut_x.lcm_assign(y.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, lcm);\n\n        let mut mut_x = x.clone();\n        mut_x.lcm_assign(&y);\n        assert_eq!(mut_x, lcm);\n        assert!(mut_x.is_valid());\n\n        assert_eq!(\n            Natural::from(&(BigUint::from(&x).lcm(&BigUint::from(&y)))),\n            lcm\n        );\n        assert_eq!(\n            Natural::exact_from(&(rug::Integer::from(&x).lcm(&rug::Integer::from(&y)))),\n            lcm\n        );\n\n        assert_eq!((&y).lcm(&x), lcm);\n        assert!((&lcm).divisible_by(&x));\n        assert!((&lcm).divisible_by(&y));\n        let gcd = (&x).gcd(&y);\n        if x != 0 {\n            assert_eq!((&lcm).div_exact(&x) * &gcd, y);\n        }\n        if y != 0 {\n            assert_eq!((&lcm).div_exact(&y) * &gcd, x);\n        }\n        if gcd != 0 {\n            assert_eq!(x.div_exact(gcd) * y, lcm);\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).lcm(&x), x);\n        assert_eq!((&x).lcm(Natural::ONE), x);\n        assert_eq!(x.lcm(Natural::ZERO), 0);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x).lcm(&y).lcm(&z), x.lcm(y.lcm(z)));\n    });\n\n    unsigned_pair_gen_var_34::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).lcm(Natural::from(y)), x.lcm(y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase, CeilingLogBase2, CheckedLogBase, CheckedLogBase2, DivExact, FloorLogBase,\n    FloorLogBase2, Pow,\n};\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_24;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen_var_1, natural_gen_var_2, natural_pair_gen_var_3,\n};\nuse malachite_nz::test_util::natural::arithmetic::log_base::{\n    ceiling_log_base_by_squaring, ceiling_log_base_naive, checked_log_base_by_squaring,\n    checked_log_base_naive, floor_log_base_by_squaring, floor_log_base_naive,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_approx_ln() {\n    let test = |s, out| {\n        assert_eq!(\n            NiceFloat(Natural::from_str(s).unwrap().approx_ln()),\n            NiceFloat(out)\n        );\n    };\n    test(\"1\", 0.0);\n    test(\"2\", std::f64::consts::LN_2);\n    test(\"3\", 1.0986122886681096);\n    test(\"10\", 2.3025850929940455);\n    test(\"100\", 4.605170185988091);\n    test(\"1000\", 6.907755278982137);\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        138.15510557964274,\n    );\n}\n\n#[test]\n#[should_panic]\nfn approx_ln_fail() {\n    Natural::ZERO.approx_ln();\n}\n\n#[test]\nfn test_floor_log_base() {\n    let test = |n, base, out| {\n        assert_eq!(\n            Natural::from_str(n)\n                .unwrap()\n                .floor_log_base(&Natural::from_str(base).unwrap()),\n            out\n        );\n    };\n    test(\"1\", \"2\", 0);\n    test(\"1\", \"5\", 0);\n    test(\"2\", \"2\", 1);\n    test(\"2\", \"3\", 0);\n    test(\"3\", \"2\", 1);\n    test(\"3\", \"3\", 1);\n    test(\"3\", \"4\", 0);\n    test(\"100\", \"2\", 6);\n    test(\"100\", \"3\", 4);\n    test(\"100\", \"4\", 3);\n    test(\"100\", \"5\", 2);\n    test(\"100\", \"10\", 2);\n    test(\"100\", \"11\", 1);\n    test(\n        \"999999999999999999999999999999999999999999999999999999999999\",\n        \"10\",\n        59,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"10\",\n        60,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000001\",\n        \"10\",\n        60,\n    );\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_fail_1() {\n    Natural::ZERO.floor_log_base(&Natural::TWO);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_fail_2() {\n    Natural::ONE.floor_log_base(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_fail_3() {\n    Natural::ONE.floor_log_base(&Natural::ONE);\n}\n\n#[test]\nfn test_ceiling_log_base() {\n    let test = |n, base, out| {\n        assert_eq!(\n            Natural::from_str(n)\n                .unwrap()\n                .ceiling_log_base(&Natural::from_str(base).unwrap()),\n            out\n        );\n    };\n    test(\"1\", \"2\", 0);\n    test(\"1\", \"5\", 0);\n    test(\"2\", \"2\", 1);\n    test(\"2\", \"3\", 1);\n    test(\"3\", \"2\", 2);\n    test(\"3\", \"3\", 1);\n    test(\"3\", \"4\", 1);\n    test(\"100\", \"2\", 7);\n    test(\"100\", \"3\", 5);\n    test(\"100\", \"4\", 4);\n    test(\"100\", \"5\", 3);\n    test(\"100\", \"10\", 2);\n    test(\"100\", \"11\", 2);\n    test(\n        \"999999999999999999999999999999999999999999999999999999999999\",\n        \"10\",\n        60,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"10\",\n        60,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000001\",\n        \"10\",\n        61,\n    );\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_fail_1() {\n    Natural::ZERO.ceiling_log_base(&Natural::TWO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_fail_2() {\n    Natural::ONE.ceiling_log_base(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_fail_3() {\n    Natural::ONE.ceiling_log_base(&Natural::ONE);\n}\n\n#[test]\nfn test_checked_log_base() {\n    let test = |n, base, out| {\n        assert_eq!(\n            Natural::from_str(n)\n                .unwrap()\n                .checked_log_base(&Natural::from_str(base).unwrap()),\n            out\n        );\n    };\n    test(\"1\", \"2\", Some(0));\n    test(\"1\", \"5\", Some(0));\n    test(\"2\", \"2\", Some(1));\n    test(\"2\", \"3\", None);\n    test(\"3\", \"2\", None);\n    test(\"3\", \"3\", Some(1));\n    test(\"3\", \"4\", None);\n    test(\"100\", \"2\", None);\n    test(\"100\", \"3\", None);\n    test(\"100\", \"4\", None);\n    test(\"100\", \"5\", None);\n    test(\"100\", \"10\", Some(2));\n    test(\"100\", \"11\", None);\n    test(\n        \"999999999999999999999999999999999999999999999999999999999999\",\n        \"10\",\n        None,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"10\",\n        Some(60),\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000001\",\n        \"10\",\n        None,\n    );\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_fail_1() {\n    Natural::ZERO.checked_log_base(&Natural::TWO);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_fail_2() {\n    Natural::ONE.checked_log_base(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_fail_3() {\n    Natural::ONE.checked_log_base(&Natural::ONE);\n}\n\n#[test]\nfn approx_ln_properties() {\n    natural_gen_var_2().test_properties(|n| {\n        let log = n.approx_ln();\n        assert!(log.is_sign_positive());\n        assert!(log.is_finite());\n        assert!(!log.is_nan());\n    });\n}\n\n#[test]\nfn floor_log_base_properties() {\n    natural_pair_gen_var_3().test_properties(|(n, base)| {\n        let floor_log = n.floor_log_base(&base);\n        assert_eq!(floor_log_base_naive(&n, &base), floor_log);\n        assert_eq!(floor_log_base_by_squaring(&n, &base), floor_log);\n        assert_eq!(floor_log == 0, n < base);\n\n        let power = (&base).pow(floor_log);\n        assert!(power <= n);\n        assert!(&power * &base > n);\n\n        let ceiling_log = n.ceiling_log_base(&base);\n        if power == n {\n            assert_eq!(ceiling_log, floor_log);\n        } else {\n            assert_eq!(ceiling_log, floor_log + 1);\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(n.floor_log_base(&Natural::TWO), n.floor_log_base_2());\n    });\n\n    natural_gen_var_1().test_properties(|base| {\n        assert_eq!(Natural::ONE.floor_log_base(&base), 0);\n    });\n\n    unsigned_pair_gen_var_24::<Limb, Limb>().test_properties(|(n, base)| {\n        assert_eq!(\n            n.floor_log_base(base),\n            Natural::from(n).floor_log_base(&Natural::from(base))\n        );\n    });\n}\n\n#[test]\nfn ceiling_log_base_properties() {\n    natural_pair_gen_var_3().test_properties(|(n, base)| {\n        let ceiling_log = n.ceiling_log_base(&base);\n        assert_eq!(ceiling_log_base_naive(&n, &base), ceiling_log);\n        assert_eq!(ceiling_log_base_by_squaring(&n, &base), ceiling_log);\n        assert_eq!(ceiling_log == 0, n == Natural::ONE);\n\n        let power = (&base).pow(ceiling_log);\n        assert!(power >= n);\n        if power != 1 {\n            assert!((&power).div_exact(&base) < n);\n        }\n\n        let floor_log = n.floor_log_base(&base);\n        if power == n {\n            assert_eq!(floor_log, ceiling_log);\n        } else {\n            assert_eq!(floor_log, ceiling_log - 1);\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(n.ceiling_log_base(&Natural::TWO), n.ceiling_log_base_2());\n    });\n\n    natural_gen_var_1().test_properties(|base| {\n        assert_eq!(Natural::ONE.ceiling_log_base(&base), 0);\n    });\n\n    unsigned_pair_gen_var_24::<Limb, Limb>().test_properties(|(n, base)| {\n        assert_eq!(\n            n.ceiling_log_base(base),\n            Natural::from(n).ceiling_log_base(&Natural::from(base))\n        );\n    });\n}\n\n#[test]\nfn checked_log_base_properties() {\n    natural_pair_gen_var_3().test_properties(|(n, base)| {\n        let checked_log = n.checked_log_base(&base);\n        assert_eq!(checked_log_base_naive(&n, &base), checked_log);\n        assert_eq!(checked_log_base_by_squaring(&n, &base), checked_log);\n        if let Some(log) = checked_log {\n            assert_eq!((&base).pow(log), n);\n            assert_eq!(log == 0, n == Natural::ONE);\n            assert_eq!(n.floor_log_base(&base), log);\n            assert_eq!(n.ceiling_log_base(&base), log);\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(n.checked_log_base(&Natural::TWO), n.checked_log_base_2());\n    });\n\n    natural_gen_var_1().test_properties(|base| {\n        assert_eq!(Natural::ONE.checked_log_base(&base), Some(0));\n    });\n\n    unsigned_pair_gen_var_24::<Limb, Limb>().test_properties(|(n, base)| {\n        assert_eq!(\n            n.checked_log_base(base),\n            Natural::from(n).checked_log_base(&Natural::from(base))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, CheckedLogBase2, FloorLogBase2, IsPowerOf2, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_gen_var_1, unsigned_vec_gen_var_1};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::log_base_2::{\n    limbs_ceiling_log_base_2, limbs_checked_log_base_2, limbs_floor_log_base_2,\n};\nuse malachite_nz::natural::logic::significant_bits::limbs_significant_bits;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen_var_2;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_floor_log_base_2() {\n    let test = |xs, out| {\n        assert_eq!(limbs_floor_log_base_2(xs), out);\n    };\n    test(&[0b1], 0);\n    test(&[0b10], 1);\n    test(&[0b11], 1);\n    test(&[0b100], 2);\n    test(&[0, 0b1], 32);\n    test(&[0, 0b1101], 35);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_floor_log_base_2_fail() {\n    limbs_floor_log_base_2(&[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_ceiling_log_base_2() {\n    let test = |xs, out| {\n        assert_eq!(limbs_ceiling_log_base_2(xs), out);\n    };\n    test(&[0b1], 0);\n    test(&[0b10], 1);\n    test(&[0b11], 2);\n    test(&[0b100], 2);\n    test(&[0, 0b1], 32);\n    test(&[0, 0b1101], 36);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_ceiling_log_base_2_fail() {\n    limbs_ceiling_log_base_2(&[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_checked_log_base_2() {\n    let test = |xs, out| {\n        assert_eq!(limbs_checked_log_base_2(xs), out);\n    };\n    test(&[0b1], Some(0));\n    test(&[0b10], Some(1));\n    test(&[0b11], None);\n    test(&[0b100], Some(2));\n    test(&[0, 0b1], Some(32));\n    test(&[0, 0b1101], None);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_checked_log_base_2_fail() {\n    limbs_checked_log_base_2(&[]);\n}\n\n#[test]\nfn limbs_floor_log_base_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let floor_log_base_2 = limbs_floor_log_base_2(&xs);\n        assert_eq!(xs.len() == 1, floor_log_base_2 < Limb::WIDTH);\n        assert_eq!(floor_log_base_2, limbs_significant_bits(&xs) - 1);\n        assert_eq!(\n            floor_log_base_2,\n            Natural::from_limbs_asc(&xs).floor_log_base_2()\n        );\n    });\n}\n\n#[test]\nfn limbs_ceiling_log_base_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let ceiling_log_base_2 = limbs_ceiling_log_base_2(&xs);\n        assert_eq!(\n            xs.len() == 1 || xs == [0, 1],\n            ceiling_log_base_2 <= Limb::WIDTH\n        );\n        assert_eq!(\n            ceiling_log_base_2,\n            Natural::from_limbs_asc(&xs).ceiling_log_base_2()\n        );\n    });\n}\n\n#[test]\nfn limbs_checked_log_base_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let checked_log_base_2 = limbs_checked_log_base_2(&xs);\n        assert_eq!(\n            checked_log_base_2,\n            Natural::from_limbs_asc(&xs).checked_log_base_2()\n        );\n    });\n}\n\n#[test]\nfn test_floor_log_base_2() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().floor_log_base_2(), out);\n    };\n    test(\"1\", 0);\n    test(\"100\", 6);\n    test(\"1000000000000\", 39);\n    test(\"4294967295\", 31);\n    test(\"4294967296\", 32);\n    test(\"18446744073709551615\", 63);\n    test(\"18446744073709551616\", 64);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_2_fail() {\n    Natural::ZERO.floor_log_base_2();\n}\n\n#[test]\nfn test_ceiling_log_base_2() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().ceiling_log_base_2(), out);\n    };\n    test(\"1\", 0);\n    test(\"100\", 7);\n    test(\"1000000000000\", 40);\n    test(\"4294967295\", 32);\n    test(\"4294967296\", 32);\n    test(\"4294967297\", 33);\n    test(\"18446744073709551615\", 64);\n    test(\"18446744073709551616\", 64);\n    test(\"18446744073709551617\", 65);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_2_fail() {\n    Natural::ZERO.ceiling_log_base_2();\n}\n\n#[test]\nfn test_checked_log_base_2() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().checked_log_base_2(), out);\n    };\n    test(\"1\", Some(0));\n    test(\"100\", None);\n    test(\"1000000000000\", None);\n    test(\"4294967295\", None);\n    test(\"4294967296\", Some(32));\n    test(\"4294967297\", None);\n    test(\"18446744073709551615\", None);\n    test(\"18446744073709551616\", Some(64));\n    test(\"18446744073709551617\", None);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_2_fail() {\n    Natural::ZERO.checked_log_base_2();\n}\n\n#[test]\nfn floor_log_base_2_properties() {\n    natural_gen_var_2().test_properties(|x| {\n        let floor_log_base_2 = x.floor_log_base_2();\n        assert_eq!(x <= Limb::MAX, floor_log_base_2 < Limb::WIDTH);\n        assert_eq!(floor_log_base_2, x.significant_bits() - 1);\n        assert_eq!(floor_log_base_2, limbs_floor_log_base_2(x.as_limbs_asc()));\n        assert!(Natural::power_of_2(floor_log_base_2) <= x);\n        assert!(x < Natural::power_of_2(floor_log_base_2 + 1));\n    });\n\n    unsigned_gen_var_1::<Limb>().test_properties(|u| {\n        assert_eq!(u.floor_log_base_2(), Natural::from(u).floor_log_base_2());\n    });\n}\n\n#[test]\nfn ceiling_log_base_2_properties() {\n    natural_gen_var_2().test_properties(|x| {\n        let ceiling_log_base_2 = x.ceiling_log_base_2();\n        assert_eq!(\n            x <= Natural::power_of_2(Limb::WIDTH),\n            ceiling_log_base_2 <= Limb::WIDTH\n        );\n        assert_eq!(\n            ceiling_log_base_2,\n            limbs_ceiling_log_base_2(x.as_limbs_asc())\n        );\n        if ceiling_log_base_2 != 0 {\n            assert!(Natural::power_of_2(ceiling_log_base_2 - 1) < x);\n        }\n        assert!(x <= Natural::power_of_2(ceiling_log_base_2));\n    });\n\n    unsigned_gen_var_1::<Limb>().test_properties(|u| {\n        assert_eq!(\n            u.ceiling_log_base_2(),\n            Natural::from(u).ceiling_log_base_2()\n        );\n    });\n}\n\n#[test]\nfn checked_log_base_2_properties() {\n    natural_gen_var_2().test_properties(|x| {\n        let checked_log_base_2 = x.checked_log_base_2();\n        assert_eq!(\n            checked_log_base_2,\n            limbs_checked_log_base_2(x.as_limbs_asc())\n        );\n        assert_eq!(checked_log_base_2.is_some(), x.is_power_of_2());\n        if let Some(log_base_2) = checked_log_base_2 {\n            assert_eq!(x.floor_log_base_2(), log_base_2);\n            assert_eq!(x.ceiling_log_base_2(), log_base_2);\n            assert_eq!(x <= Limb::MAX, log_base_2 < Limb::WIDTH);\n            assert_eq!(log_base_2, x.significant_bits() - 1);\n            assert_eq!(Natural::power_of_2(log_base_2), x);\n        }\n    });\n\n    unsigned_gen_var_1::<Limb>().test_properties(|u| {\n        assert_eq!(\n            u.checked_log_base_2(),\n            Natural::from(u).checked_log_base_2()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase, CeilingLogBase2, CeilingLogBasePowerOf2, CheckedLogBase, CheckedLogBase2,\n    CheckedLogBasePowerOf2, DivisibleBy, FloorLogBase, FloorLogBase2, FloorLogBasePowerOf2,\n    IsPowerOf2, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_11, unsigned_pair_gen_var_21, unsigned_vec_unsigned_pair_gen_var_13,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::log_base_power_of_2::{\n    limbs_ceiling_log_base_power_of_2, limbs_checked_log_base_power_of_2,\n    limbs_floor_log_base_power_of_2,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen_var_2, natural_unsigned_pair_gen_var_8};\nuse malachite_nz::test_util::natural::arithmetic::log_base_power_of_2::*;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_floor_log_base_power_of_2() {\n    let test = |xs: &[Limb], pow, out| {\n        assert_eq!(limbs_floor_log_base_power_of_2(xs, pow), out);\n    };\n    test(&[0b1], 1, 0);\n    test(&[0b1], 5, 0);\n    test(&[0b10], 1, 1);\n    test(&[0b10], 2, 0);\n    test(&[0b10], 5, 0);\n    test(&[0b11], 1, 1);\n    test(&[0b11], 2, 0);\n    test(&[0b11], 5, 0);\n    test(&[0b100], 1, 2);\n    test(&[0b100], 2, 1);\n    test(&[0b100], 5, 0);\n    test(&[0, 0b1], 1, 32);\n    test(&[0, 0b1], 2, 16);\n    test(&[0, 0b1], 3, 10);\n    test(&[0, 0b1], 4, 8);\n    test(&[0, 0b1], 32, 1);\n    test(&[0, 0b1], 33, 0);\n    test(&[0, 0b1101], 1, 35);\n    test(&[0, 0b1101], 2, 17);\n    test(&[0, 0b1101], 5, 7);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_floor_log_base_power_of_2_fail() {\n    limbs_floor_log_base_power_of_2(&[1], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_ceiling_log_base_power_of_2() {\n    let test = |xs: &[Limb], pow, out| {\n        assert_eq!(limbs_ceiling_log_base_power_of_2(xs, pow), out);\n    };\n    test(&[0b1], 1, 0);\n    test(&[0b1], 5, 0);\n    test(&[0b10], 1, 1);\n    test(&[0b10], 2, 1);\n    test(&[0b10], 5, 1);\n    test(&[0b11], 1, 2);\n    test(&[0b11], 2, 1);\n    test(&[0b11], 5, 1);\n    test(&[0b100], 1, 2);\n    test(&[0b100], 2, 1);\n    test(&[0b100], 5, 1);\n    test(&[0, 0b1], 1, 32);\n    test(&[0, 0b1], 2, 16);\n    test(&[0, 0b1], 3, 11);\n    test(&[0, 0b1], 4, 8);\n    test(&[0, 0b1], 32, 1);\n    test(&[0, 0b1], 33, 1);\n    test(&[0, 0b1101], 1, 36);\n    test(&[0, 0b1101], 2, 18);\n    test(&[0, 0b1101], 5, 8);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_ceiling_log_base_power_of_2_fail() {\n    limbs_ceiling_log_base_power_of_2(&[1], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_checked_log_base_power_of_2() {\n    let test = |xs: &[Limb], pow, out| {\n        assert_eq!(limbs_checked_log_base_power_of_2(xs, pow), out);\n    };\n    test(&[0b1], 1, Some(0));\n    test(&[0b1], 5, Some(0));\n    test(&[0b10], 1, Some(1));\n    test(&[0b10], 2, None);\n    test(&[0b10], 5, None);\n    test(&[0b11], 1, None);\n    test(&[0b11], 2, None);\n    test(&[0b11], 5, None);\n    test(&[0b100], 1, Some(2));\n    test(&[0b100], 2, Some(1));\n    test(&[0b100], 5, None);\n    test(&[0, 0b1], 1, Some(32));\n    test(&[0, 0b1], 2, Some(16));\n    test(&[0, 0b1], 3, None);\n    test(&[0, 0b1], 4, Some(8));\n    test(&[0, 0b1], 32, Some(1));\n    test(&[0, 0b1], 33, None);\n    test(&[0, 0b1101], 1, None);\n    test(&[0, 0b1101], 2, None);\n    test(&[0, 0b1101], 5, None);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_checked_log_base_power_of_2_fail() {\n    limbs_checked_log_base_power_of_2(&[1], 0);\n}\n\n#[test]\nfn test_floor_log_base_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Natural::from_str(n).unwrap().floor_log_base_power_of_2(pow),\n            out\n        );\n    };\n    test(\"1\", 1, 0);\n    test(\"1\", 2, 0);\n    test(\"1\", 5, 0);\n    test(\"100\", 1, 6);\n    test(\"100\", 2, 3);\n    test(\"100\", 5, 1);\n    test(\"1000000000000\", 1, 39);\n    test(\"1000000000000\", 2, 19);\n    test(\"1000000000000\", 5, 7);\n    test(\"4294967295\", 1, 31);\n    test(\"4294967295\", 2, 15);\n    test(\"4294967295\", 5, 6);\n    test(\"4294967296\", 1, 32);\n    test(\"4294967296\", 2, 16);\n    test(\"4294967296\", 8, 4);\n    test(\"4294967296\", 5, 6);\n    test(\"18446744073709551615\", 1, 63);\n    test(\"18446744073709551615\", 2, 31);\n    test(\"18446744073709551615\", 5, 12);\n    test(\"18446744073709551616\", 1, 64);\n    test(\"18446744073709551616\", 2, 32);\n    test(\"18446744073709551616\", 8, 8);\n    test(\"18446744073709551616\", 20, 3);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_power_of_2_fail_1() {\n    Natural::ZERO.floor_log_base_power_of_2(1);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_power_of_2_fail_2() {\n    Natural::ONE.floor_log_base_power_of_2(0);\n}\n\n#[test]\nfn test_ceiling_log_base_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Natural::from_str(n)\n                .unwrap()\n                .ceiling_log_base_power_of_2(pow),\n            out\n        );\n    };\n    test(\"1\", 1, 0);\n    test(\"1\", 2, 0);\n    test(\"1\", 5, 0);\n    test(\"100\", 1, 7);\n    test(\"100\", 2, 4);\n    test(\"100\", 5, 2);\n    test(\"1000000000000\", 1, 40);\n    test(\"1000000000000\", 2, 20);\n    test(\"1000000000000\", 5, 8);\n    test(\"4294967295\", 1, 32);\n    test(\"4294967295\", 2, 16);\n    test(\"4294967295\", 5, 7);\n    test(\"4294967296\", 1, 32);\n    test(\"4294967296\", 2, 16);\n    test(\"4294967296\", 8, 4);\n    test(\"4294967296\", 5, 7);\n    test(\"18446744073709551615\", 1, 64);\n    test(\"18446744073709551615\", 2, 32);\n    test(\"18446744073709551615\", 5, 13);\n    test(\"18446744073709551616\", 1, 64);\n    test(\"18446744073709551616\", 2, 32);\n    test(\"18446744073709551616\", 8, 8);\n    test(\"18446744073709551616\", 20, 4);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_power_of_2_fail_1() {\n    Natural::ZERO.ceiling_log_base_power_of_2(1);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_power_of_2_fail_2() {\n    Natural::ONE.ceiling_log_base_power_of_2(0);\n}\n\n#[test]\nfn test_checked_log_base_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Natural::from_str(n)\n                .unwrap()\n                .checked_log_base_power_of_2(pow),\n            out\n        );\n    };\n    test(\"1\", 1, Some(0));\n    test(\"1\", 2, Some(0));\n    test(\"1\", 5, Some(0));\n    test(\"100\", 1, None);\n    test(\"100\", 2, None);\n    test(\"100\", 5, None);\n    test(\"1000000000000\", 1, None);\n    test(\"1000000000000\", 2, None);\n    test(\"1000000000000\", 5, None);\n    test(\"4294967295\", 1, None);\n    test(\"4294967295\", 2, None);\n    test(\"4294967295\", 5, None);\n    test(\"4294967296\", 1, Some(32));\n    test(\"4294967296\", 2, Some(16));\n    test(\"4294967296\", 8, Some(4));\n    test(\"4294967296\", 5, None);\n    test(\"18446744073709551615\", 1, None);\n    test(\"18446744073709551615\", 2, None);\n    test(\"18446744073709551615\", 5, None);\n    test(\"18446744073709551616\", 1, Some(64));\n    test(\"18446744073709551616\", 2, Some(32));\n    test(\"18446744073709551616\", 8, Some(8));\n    test(\"18446744073709551616\", 20, None);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_power_of_2_fail_1() {\n    Natural::ZERO.checked_log_base_power_of_2(1);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_power_of_2_fail_2() {\n    Natural::ONE.checked_log_base_power_of_2(0);\n}\n\n#[test]\nfn limbs_floor_log_base_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_13().test_properties_with_config(&config, |(xs, pow)| {\n        assert_eq!(\n            limbs_floor_log_base_power_of_2(&xs, pow),\n            Natural::from_limbs_asc(&xs).floor_log_base_power_of_2(pow),\n        );\n    });\n}\n\n#[test]\nfn limbs_ceiling_log_base_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_13().test_properties_with_config(&config, |(xs, pow)| {\n        assert_eq!(\n            limbs_ceiling_log_base_power_of_2(&xs, pow),\n            Natural::from_limbs_asc(&xs).ceiling_log_base_power_of_2(pow)\n        );\n    });\n}\n\n#[test]\nfn limbs_checked_log_base_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_13().test_properties_with_config(&config, |(xs, pow)| {\n        assert_eq!(\n            limbs_checked_log_base_power_of_2(&xs, pow),\n            Natural::from_limbs_asc(&xs).checked_log_base_power_of_2(pow)\n        );\n    });\n}\n\n#[test]\nfn floor_log_base_power_of_2_properties() {\n    natural_unsigned_pair_gen_var_8().test_properties(|(n, pow)| {\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        assert_eq!(floor_log == 0, n.significant_bits() - 1 < pow);\n        assert_eq!(n.floor_log_base(&Natural::power_of_2(pow)), floor_log);\n\n        let product = floor_log * pow;\n        assert!(Natural::power_of_2(product) <= n);\n        assert!(Natural::power_of_2(product + pow) > n);\n\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        if n.is_power_of_2() && (n.significant_bits() - 1).divisible_by(pow) {\n            assert_eq!(ceiling_log, floor_log);\n        } else {\n            assert_eq!(ceiling_log, floor_log + 1);\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(n.floor_log_base_power_of_2(1), n.floor_log_base_2());\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(Natural::ONE.floor_log_base_power_of_2(pow), 0);\n    });\n\n    unsigned_pair_gen_var_21::<Limb, u64>().test_properties(|(n, pow)| {\n        assert_eq!(\n            n.floor_log_base_power_of_2(pow),\n            Natural::from(n).floor_log_base_power_of_2(pow)\n        );\n    });\n}\n\n#[test]\nfn ceiling_log_base_power_of_2_properties() {\n    natural_unsigned_pair_gen_var_8().test_properties(|(n, pow)| {\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        assert_eq!(ceiling_log, ceiling_log_base_power_of_2_naive_nz(&n, pow));\n        assert_eq!(ceiling_log == 0, n == Natural::ONE);\n        assert_eq!(n.ceiling_log_base(&Natural::power_of_2(pow)), ceiling_log);\n\n        let product = ceiling_log * pow;\n        assert!(Natural::power_of_2(product) >= n);\n        if product != 0 {\n            assert!(Natural::power_of_2(product - pow) < n);\n        }\n\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        if n.is_power_of_2() && (n.significant_bits() - 1).divisible_by(pow) {\n            assert_eq!(floor_log, ceiling_log);\n        } else {\n            assert_eq!(floor_log, ceiling_log - 1);\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(n.ceiling_log_base_power_of_2(1), n.ceiling_log_base_2());\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(Natural::ONE.ceiling_log_base_power_of_2(pow), 0);\n    });\n\n    unsigned_pair_gen_var_21::<Limb, u64>().test_properties(|(n, pow)| {\n        assert_eq!(\n            n.ceiling_log_base_power_of_2(pow),\n            Natural::from(n).ceiling_log_base_power_of_2(pow)\n        );\n    });\n}\n\n#[test]\nfn checked_log_base_power_of_2_properties() {\n    natural_unsigned_pair_gen_var_8().test_properties(|(n, pow)| {\n        let checked_log = n.checked_log_base_power_of_2(pow);\n        assert_eq!(n.checked_log_base(&Natural::power_of_2(pow)), checked_log);\n        assert_eq!(\n            checked_log.is_some(),\n            n.is_power_of_2() && (n.significant_bits() - 1).divisible_by(pow)\n        );\n        if let Some(log) = checked_log {\n            assert_eq!(Natural::power_of_2(log * pow), n);\n            assert_eq!(log == 0, n == Natural::ONE);\n            assert_eq!(n.floor_log_base_power_of_2(pow), log);\n            assert_eq!(n.ceiling_log_base_power_of_2(pow), log);\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(n.checked_log_base_power_of_2(1), n.checked_log_base_2());\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(Natural::ONE.checked_log_base_power_of_2(pow), Some(0));\n    });\n\n    unsigned_pair_gen_var_21::<Limb, u64>().test_properties(|(n, pow)| {\n        assert_eq!(\n            n.checked_log_base_power_of_2(pow),\n            Natural::from(n).checked_log_base_power_of_2(pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModAdd, ModAddAssign, ModIsReduced, ModNeg, ModShl, ModSub,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_12;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen_var_8, natural_quadruple_gen_var_1, natural_triple_gen_var_3,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_add() {\n    let test = |r, s, t, out| {\n        let u = Natural::from_str(r).unwrap();\n        let v = Natural::from_str(s).unwrap();\n        let m = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_is_reduced(&m));\n        assert!(v.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_add_assign(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_add_assign(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_add_assign(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_add_assign(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_add(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_add(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_add(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_add(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_add(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_add(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_add(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_add(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!(((u + v) % m).to_string(), out);\n    };\n    test(\"0\", \"0\", \"1\", \"0\");\n    test(\"0\", \"0\", \"32\", \"0\");\n    test(\"0\", \"2\", \"32\", \"2\");\n    test(\"10\", \"14\", \"16\", \"8\");\n    test(\"0\", \"123\", \"128\", \"123\");\n    test(\"123\", \"0\", \"128\", \"123\");\n    test(\"123\", \"456\", \"512\", \"67\");\n    test(\"0\", \"3\", \"5\", \"3\");\n    test(\"7\", \"5\", \"10\", \"2\");\n}\n\n#[test]\nfn mod_add_fail() {\n    assert_panic!(Natural::ZERO.mod_add(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_add(Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_add(Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_add(Natural::ZERO, &Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_add(Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_add(Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_add(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_add(&Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_add(&Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_add(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_add(&Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_add(&Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_add(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_add(Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_add(Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_add(Natural::ZERO, &Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_add(Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_add(Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_add(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_add(&Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_add(&Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_add(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_add(&Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_add(&Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_add_assign(Natural::ZERO, Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_add_assign(Natural::from(3u8), Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_add_assign(Natural::from(30u8), Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_add_assign(Natural::ZERO, &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_add_assign(Natural::from(3u8), &Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_add_assign(Natural::from(30u8), &Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_add_assign(Natural::ZERO, Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_add_assign(&Natural::from(3u8), Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_add_assign(&Natural::from(30u8), Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_add_assign(Natural::ZERO, &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_add_assign(&Natural::from(3u8), &Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_add_assign(&Natural::from(30u8), &Natural::from(30u8));\n    });\n}\n\n#[test]\nfn mod_add_properties() {\n    natural_triple_gen_var_3().test_properties(|(x, y, m)| {\n        assert!(x.mod_is_reduced(&m));\n        assert!(y.mod_is_reduced(&m));\n        let sum_val_val_val = x.clone().mod_add(y.clone(), m.clone());\n        let sum_val_ref_val = x.clone().mod_add(&y, m.clone());\n        let sum_ref_val_val = (&x).mod_add(y.clone(), m.clone());\n        let sum_ref_ref_val = (&x).mod_add(&y, m.clone());\n        let sum_val_val_ref = x.clone().mod_add(y.clone(), &m);\n        let sum_val_ref_ref = x.clone().mod_add(&y, &m);\n        let sum_ref_val_ref = (&x).mod_add(y.clone(), &m);\n        let sum = (&x).mod_add(&y, &m);\n        assert!(sum_val_val_val.is_valid());\n        assert!(sum_val_ref_val.is_valid());\n        assert!(sum_ref_val_val.is_valid());\n        assert!(sum_val_val_ref.is_valid());\n        assert!(sum_val_val_ref.is_valid());\n        assert!(sum_val_ref_ref.is_valid());\n        assert!(sum_ref_val_ref.is_valid());\n        assert!(sum.is_valid());\n        assert!(sum.mod_is_reduced(&m));\n        assert_eq!(sum_val_val_val, sum);\n        assert_eq!(sum_val_ref_val, sum);\n        assert_eq!(sum_ref_val_val, sum);\n        assert_eq!(sum_ref_ref_val, sum);\n        assert_eq!(sum_val_val_ref, sum);\n        assert_eq!(sum_val_ref_ref, sum);\n        assert_eq!(sum_ref_val_ref, sum);\n\n        assert_eq!((&x + &y) % &m, sum);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_add_assign(y.clone(), m.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, sum);\n        let mut mut_x = x.clone();\n        mut_x.mod_add_assign(&y, m.clone());\n        assert_eq!(mut_x, sum);\n        assert!(mut_x.is_valid());\n        let mut mut_x = x.clone();\n        mut_x.mod_add_assign(y.clone(), &m);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, sum);\n        let mut mut_x = x.clone();\n        mut_x.mod_add_assign(&y, &m);\n        assert_eq!(mut_x, sum);\n        assert!(mut_x.is_valid());\n\n        assert_eq!((&y).mod_add(&x, &m), sum);\n        assert_eq!((&x).mod_sub((&y).mod_neg(&m), &m), sum);\n        assert_eq!((&sum).mod_sub(&x, &m), y);\n        assert_eq!(sum.mod_sub(y, m), x);\n    });\n\n    natural_pair_gen_var_8().test_properties(|(x, m)| {\n        assert_eq!((&x).mod_add(Natural::ZERO, &m), x);\n        assert_eq!(Natural::ZERO.mod_add(&x, &m), x);\n        assert_eq!((&x).mod_add(&x, &m), x.mod_shl(1, &m));\n    });\n\n    natural_quadruple_gen_var_1().test_properties(|(x, y, z, m)| {\n        assert_eq!(\n            (&x).mod_add(&y, &m).mod_add(&z, &m),\n            x.mod_add(y.mod_add(z, &m), m)\n        );\n    });\n\n    unsigned_triple_gen_var_12::<Limb>().test_properties(|(x, y, m)| {\n        assert_eq!(\n            x.mod_add(y, m),\n            Natural::from(x).mod_add(Natural::from(y), Natural::from(m))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CoprimeWith, ModInverse, ModIsReduced, ModMul};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_38;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen_var_1, natural_pair_gen_var_11};\nuse malachite_nz::test_util::natural::arithmetic::mod_inverse::mod_inverse_simple;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_inverse() {\n    let test = |s, t, out| {\n        let n = Natural::from_str(s).unwrap();\n        let m = Natural::from_str(t).unwrap();\n\n        let result = n.clone().mod_inverse(m.clone());\n        assert_eq!(result.to_debug_string(), out);\n        assert!(result.is_none_or(|n| n.is_valid()));\n\n        let result = n.clone().mod_inverse(&m);\n        assert_eq!(result.to_debug_string(), out);\n        assert!(result.is_none_or(|n| n.is_valid()));\n\n        let result = (&n).mod_inverse(m.clone());\n        assert_eq!(result.to_debug_string(), out);\n        assert!(result.is_none_or(|n| n.is_valid()));\n\n        let result = (&n).mod_inverse(&m);\n        assert_eq!(result.to_debug_string(), out);\n        assert!(result.is_none_or(|n| n.is_valid()));\n\n        assert_eq!(mod_inverse_simple(n, m).to_debug_string(), out);\n    };\n    test(\"1\", \"6\", \"Some(1)\");\n    test(\"8\", \"12\", \"None\");\n    test(\"42\", \"56\", \"None\");\n    test(\"3\", \"5\", \"Some(2)\");\n    test(\"3\", \"10\", \"Some(7)\");\n    test(\"12345678987654321\", \"98765432123456789\", \"Some(1777777788)\");\n    test(\"12345678987654321\", \"98765432123456827\", \"None\");\n}\n\n#[test]\nfn mod_inverse_fail() {\n    assert_panic!(Natural::ZERO.mod_inverse(Natural::from(5u32)));\n    assert_panic!(Natural::from(30u8).mod_inverse(Natural::from(3u32)));\n    assert_panic!(Natural::ZERO.mod_inverse(&Natural::from(5u32)));\n    assert_panic!(Natural::from(30u8).mod_inverse(&Natural::from(3u32)));\n    assert_panic!((&Natural::ZERO).mod_inverse(Natural::from(5u32)));\n    assert_panic!((&Natural::from(30u8)).mod_inverse(Natural::from(3u32)));\n    assert_panic!((&Natural::ZERO).mod_inverse(&Natural::from(5u32)));\n    assert_panic!((&Natural::from(30u8)).mod_inverse(&Natural::from(3u32)));\n}\n\n#[test]\nfn mod_inverse_properties() {\n    natural_pair_gen_var_11().test_properties(|(n, m)| {\n        assert!(n.mod_is_reduced(&m));\n        let result_val_val = n.clone().mod_inverse(m.clone());\n        let result_val_ref = n.clone().mod_inverse(&m);\n        let result_ref_val = (&n).mod_inverse(m.clone());\n        let result = (&n).mod_inverse(&m);\n        assert!(result.as_ref().is_none_or(Natural::is_valid));\n        assert!(result_val_val.as_ref().is_none_or(Natural::is_valid));\n        assert!(result_val_ref.as_ref().is_none_or(Natural::is_valid));\n        assert!(result_ref_val.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        assert_eq!(mod_inverse_simple(n.clone(), m.clone()), result);\n        assert_eq!(result.is_some(), (&n).coprime_with(&m));\n        if let Some(inverse) = result {\n            assert!(inverse.mod_is_reduced(&m));\n            assert_eq!((&inverse).mod_inverse(&m).as_ref(), Some(&n));\n            assert_eq!((&n).mod_mul(&inverse, &m), 1u32);\n            assert_eq!((&m - n).mod_inverse(&m), Some(m - inverse));\n        }\n    });\n\n    natural_gen_var_1().test_properties(|m| {\n        assert_eq!(Natural::ONE.mod_inverse(&m), Some(Natural::ONE));\n        assert_eq!((&m - Natural::ONE).mod_inverse(&m), Some(m - Natural::ONE));\n    });\n\n    unsigned_pair_gen_var_38::<Limb>().test_properties(|(n, m)| {\n        assert_eq!(\n            Natural::from(n).mod_inverse(Natural::from(m)),\n            n.mod_inverse(m).map(Natural::from)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ModIsReduced;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_12;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_5;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_is_reduced() {\n    let test = |u, v, out| {\n        assert_eq!(\n            Natural::from_str(u)\n                .unwrap()\n                .mod_is_reduced(&Natural::from_str(v).unwrap()),\n            out\n        );\n    };\n\n    test(\"0\", \"5\", true);\n    test(\"100\", \"100\", false);\n    test(\"100\", \"101\", true);\n    test(\"1000000000000\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000001\", true);\n}\n\n#[test]\n#[should_panic]\nfn mod_is_reduced_fail() {\n    Natural::from(123u32).mod_is_reduced(&Natural::ZERO);\n}\n\n#[test]\nfn mod_is_reduced_properties() {\n    natural_pair_gen_var_5().test_properties(|(n, m)| {\n        assert_eq!(n.mod_is_reduced(&m), &n % m == n);\n    });\n\n    unsigned_pair_gen_var_12::<Limb, Limb>().test_properties(|(n, m)| {\n        assert_eq!(\n            n.mod_is_reduced(&m),\n            Natural::from(n).mod_is_reduced(&Natural::from(m))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModAdd, ModIsReduced, ModMul, ModMulAssign, ModMulPrecomputed, ModMulPrecomputedAssign, ModNeg,\n    ModSquare,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::JoinHalves;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_pair_gen_var_36, unsigned_triple_gen_var_12};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_mul::{\n    limbs_mod_mul_two_limbs, limbs_precompute_mod_mul_two_limbs,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_21, natural_pair_gen_var_8, natural_quadruple_gen_var_1,\n    natural_triple_gen_var_3,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_mul::{\n    limbs_mod_mul_two_limbs_naive, limbs_precompute_mod_mul_two_limbs_alt,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_precompute_mod_mul_two_limbs() {\n    let test = |m_1, m_0, inv_2, inv_1, inv_0| {\n        assert_eq!(\n            limbs_precompute_mod_mul_two_limbs(m_1, m_0),\n            (inv_2, inv_1, inv_0)\n        );\n        assert_eq!(\n            limbs_precompute_mod_mul_two_limbs_alt(m_1, m_0),\n            (inv_2, inv_1, inv_0)\n        );\n    };\n    test(1, 1, u32::MAX, 0, u32::MAX);\n    test(1, 2, u32::MAX - 1, 3, 0xfffffff8);\n    test(123, 456, 34918433, 1162528328, 1277088208);\n    test(u32::MAX, u32::MAX - 1, 1, 0, 2);\n    test(u32::MAX, u32::MAX, 1, 0, 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_mul_two_limbs() {\n    let test = |x_1, x_0, y_1, y_0, m_1, m_0, r_1, r_0| {\n        let (inv_2, inv_1, inv_0) = limbs_precompute_mod_mul_two_limbs(m_1, m_0);\n        assert_eq!(\n            limbs_mod_mul_two_limbs(x_1, x_0, y_1, y_0, m_1, m_0, inv_2, inv_1, inv_0),\n            (r_1, r_0)\n        );\n        assert_eq!(\n            limbs_mod_mul_two_limbs_naive(x_1, x_0, y_1, y_0, m_1, m_0),\n            (r_1, r_0)\n        );\n    };\n    test(0, 0, 0, 0, 1, 1, 0, 0);\n    test(1, 0, 0, 1, 1, 1, 1, 0);\n    test(123, 456, 654, 321, 789, 876, 213, 4164192732);\n    test(123, 456, 789, 876, u32::MAX, u32::MAX, 467532, 496503);\n}\n\n#[test]\nfn test_mod_mul() {\n    let test = |r, s, t, out| {\n        let u = Natural::from_str(r).unwrap();\n        let v = Natural::from_str(s).unwrap();\n        let m = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_is_reduced(&m));\n        assert!(v.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_mul_assign(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_mul_assign(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_mul_assign(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_mul_assign(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_mul(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_mul(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_mul(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_mul(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_mul(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_mul(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_mul(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_mul(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!((u * v % m).to_string(), out);\n    };\n    test(\"0\", \"0\", \"1\", \"0\");\n    test(\"1\", \"0\", \"32\", \"0\");\n    test(\"1\", \"2\", \"32\", \"2\");\n    test(\"3\", \"4\", \"15\", \"12\");\n    test(\"7\", \"6\", \"10\", \"2\");\n    test(\"10\", \"14\", \"16\", \"12\");\n    test(\"1\", \"123\", \"128\", \"123\");\n    test(\"123\", \"1\", \"128\", \"123\");\n    test(\"123\", \"456\", \"512\", \"280\");\n    test(\"1000000000\", \"2000000000\", \"4294967296\", \"1321730048\");\n    test(\"1000000000\", \"2000000000\", \"4294967297\", \"856068761\");\n    test(\n        \"1000000000000000\",\n        \"2000000000000000\",\n        \"1000000000000000000000001\",\n        \"999999999999999998000001\",\n    );\n}\n\n#[test]\nfn limbs_precompute_mod_mul_two_limbs_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_pair_gen_var_36().test_properties_with_config(&config, |(m_1, m_0)| {\n        let (inv_2, inv_1, inv_0) = limbs_precompute_mod_mul_two_limbs(m_1, m_0);\n        assert_eq!(\n            limbs_precompute_mod_mul_two_limbs_alt(m_1, m_0),\n            (inv_2, inv_1, inv_0)\n        );\n        assert!(inv_2 != 0 || inv_1 != 0 || inv_0 != 0);\n    });\n}\n\n#[test]\nfn limbs_mod_mul_two_limbs_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_21().test_properties_with_config(\n        &config,\n        |(x_1, x_0, y_1, y_0, m_1, m_0, inv_2, inv_1, inv_0)| {\n            let (r_1, r_0) =\n                limbs_mod_mul_two_limbs(x_1, x_0, y_1, y_0, m_1, m_0, inv_2, inv_1, inv_0);\n            assert_eq!(\n                limbs_mod_mul_two_limbs_naive(x_1, x_0, y_1, y_0, m_1, m_0),\n                (r_1, r_0)\n            );\n            let x = Natural::from(DoubleLimb::join_halves(x_1, x_0));\n            let y = Natural::from(DoubleLimb::join_halves(y_1, y_0));\n            let m = Natural::from(DoubleLimb::join_halves(m_1, m_0));\n            let q = &x * &y / &m;\n            let r = Natural::from(DoubleLimb::join_halves(r_1, r_0));\n            assert_eq!(q * m + r, x * y);\n        },\n    );\n}\n\n#[test]\nfn mod_mul_fail() {\n    assert_panic!(Natural::ZERO.mod_mul(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_mul(Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_mul(Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_mul(Natural::ZERO, &Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_mul(Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_mul(Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_mul(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_mul(&Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_mul(&Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_mul(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_mul(&Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_mul(&Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_mul(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_mul(Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_mul(Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_mul(Natural::ZERO, &Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_mul(Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_mul(Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_mul(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_mul(&Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_mul(&Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_mul(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_mul(&Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_mul(&Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_mul_assign(Natural::ZERO, Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_mul_assign(Natural::from(3u8), Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_mul_assign(Natural::from(30u8), Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_mul_assign(Natural::ZERO, &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_mul_assign(Natural::from(3u8), &Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_mul_assign(Natural::from(30u8), &Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_mul_assign(Natural::ZERO, Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_mul_assign(&Natural::from(3u8), Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_mul_assign(&Natural::from(30u8), Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_mul_assign(Natural::ZERO, &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_mul_assign(&Natural::from(3u8), &Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_mul_assign(&Natural::from(30u8), &Natural::from(30u8));\n    });\n}\n\n#[test]\nfn mod_mul_properties() {\n    natural_triple_gen_var_3().test_properties(|(x, y, m)| {\n        assert!(x.mod_is_reduced(&m));\n        assert!(y.mod_is_reduced(&m));\n        let product_val_val_val = x.clone().mod_mul(y.clone(), m.clone());\n        let product_val_ref_val = x.clone().mod_mul(&y, m.clone());\n        let product_ref_val_val = (&x).mod_mul(y.clone(), m.clone());\n        let product_ref_ref_val = (&x).mod_mul(&y, m.clone());\n        let product_val_val_ref = x.clone().mod_mul(y.clone(), &m);\n        let product_val_ref_ref = x.clone().mod_mul(&y, &m);\n        let product_ref_val_ref = (&x).mod_mul(y.clone(), &m);\n        let product = (&x).mod_mul(&y, &m);\n        assert!(product_val_val_val.is_valid());\n        assert!(product_val_ref_val.is_valid());\n        assert!(product_ref_val_val.is_valid());\n        assert!(product_val_val_ref.is_valid());\n        assert!(product_val_val_ref.is_valid());\n        assert!(product_val_ref_ref.is_valid());\n        assert!(product_ref_val_ref.is_valid());\n        assert!(product.is_valid());\n        assert!(product.mod_is_reduced(&m));\n        assert_eq!(product_val_val_val, product);\n        assert_eq!(product_val_ref_val, product);\n        assert_eq!(product_ref_val_val, product);\n        assert_eq!(product_ref_ref_val, product);\n        assert_eq!(product_val_val_ref, product);\n        assert_eq!(product_val_ref_ref, product);\n        assert_eq!(product_ref_val_ref, product);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_assign(y.clone(), m.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_assign(&y, m.clone());\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_assign(y.clone(), &m);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_assign(&y, &m);\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n\n        let data = ModMulPrecomputed::<Natural>::precompute_mod_mul_data(&m);\n\n        let product_pre_val_val_val = x.clone().mod_mul_precomputed(y.clone(), m.clone(), &data);\n        let product_pre_val_ref_val = x.clone().mod_mul_precomputed(&y, m.clone(), &data);\n        let product_pre_ref_val_val = (&x).mod_mul_precomputed(y.clone(), m.clone(), &data);\n        let product_pre_ref_ref_val = (&x).mod_mul_precomputed(&y, m.clone(), &data);\n        let product_pre_val_val_ref = x.clone().mod_mul_precomputed(y.clone(), &m, &data);\n        let product_pre_val_ref_ref = x.clone().mod_mul_precomputed(&y, &m, &data);\n        let product_pre_ref_val_ref = (&x).mod_mul_precomputed(y.clone(), &m, &data);\n        let product_pre_ref_ref_ref = (&x).mod_mul_precomputed(&y, &m, &data);\n        assert!(product_pre_val_val_val.is_valid());\n        assert!(product_pre_val_ref_val.is_valid());\n        assert!(product_pre_ref_val_val.is_valid());\n        assert!(product_pre_val_val_ref.is_valid());\n        assert!(product_pre_val_val_ref.is_valid());\n        assert!(product_pre_val_ref_ref.is_valid());\n        assert!(product_pre_ref_val_ref.is_valid());\n        assert!(product_pre_ref_ref_ref.is_valid());\n        assert_eq!(product_pre_val_val_val, product);\n        assert_eq!(product_pre_val_ref_val, product);\n        assert_eq!(product_pre_ref_val_val, product);\n        assert_eq!(product_pre_ref_ref_val, product);\n        assert_eq!(product_pre_val_val_ref, product);\n        assert_eq!(product_pre_val_ref_ref, product);\n        assert_eq!(product_pre_ref_val_ref, product);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_precomputed_assign(y.clone(), m.clone(), &data);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_precomputed_assign(&y, m.clone(), &data);\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_precomputed_assign(y.clone(), &m, &data);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n        let mut mut_x = x.clone();\n        mut_x.mod_mul_precomputed_assign(&y, &m, &data);\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n\n        assert_eq!((&x * &y) % &m, product);\n\n        assert_eq!((&y).mod_mul(&x, &m), product);\n        assert_eq!((&x).mod_mul((&y).mod_neg(&m), &m), (&product).mod_neg(&m));\n        assert_eq!(x.mod_neg(&m).mod_mul(y, &m), product.mod_neg(m));\n    });\n\n    natural_pair_gen_var_8().test_properties(|(x, m)| {\n        assert_eq!((&x).mod_mul(Natural::ZERO, &m), 0);\n        assert_eq!(Natural::ZERO.mod_mul(&x, &m), 0);\n        if m > 1 {\n            assert_eq!((&x).mod_mul(Natural::ONE, &m), x);\n            assert_eq!(Natural::ONE.mod_mul(&x, &m), x);\n        }\n        assert_eq!((&x).mod_mul(&x, &m), x.mod_square(m));\n    });\n\n    natural_quadruple_gen_var_1().test_properties(|(ref x, ref y, ref z, ref m)| {\n        assert_eq!(x.mod_mul(y, m).mod_mul(z, m), x.mod_mul(y.mod_mul(z, m), m));\n        assert_eq!(\n            x.mod_mul(y.mod_add(z, m), m),\n            x.mod_mul(y, m).mod_add(x.mod_mul(z, m), m)\n        );\n        assert_eq!(\n            x.mod_add(y, m).mod_mul(z, m),\n            x.mod_mul(z, m).mod_add(y.mod_mul(z, m), m)\n        );\n    });\n\n    unsigned_triple_gen_var_12::<Limb>().test_properties(|(x, y, m)| {\n        assert_eq!(\n            x.mod_mul(y, m),\n            Natural::from(x).mod_mul(Natural::from(y), Natural::from(m))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Mod, ModAdd, ModIsReduced, ModNeg, ModNegAssign};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_16;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_8;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_neg() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_is_reduced(&v));\n        let n = u.clone().mod_neg(v.clone());\n        assert!(n.is_valid());\n        assert!(n.mod_is_reduced(&v));\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().mod_neg(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_neg(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_neg(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_neg_assign(v.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u;\n        n.mod_neg_assign(&v);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"5\", \"0\");\n    test(\"7\", \"10\", \"3\");\n    test(\"100\", \"101\", \"1\");\n    test(\"4294967294\", \"4294967295\", \"1\");\n    test(\"1\", \"4294967295\", \"4294967294\");\n    test(\"7\", \"1000000000000\", \"999999999993\");\n    test(\"999999999993\", \"1000000000000\", \"7\");\n}\n\n#[test]\nfn mod_neg_fail() {\n    assert_panic!(Natural::ZERO.mod_neg(Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_neg(Natural::ONE));\n\n    assert_panic!(Natural::ZERO.mod_neg(&Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_neg(&Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_neg(Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_neg(Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_neg(&Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_neg(&Natural::ONE));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_neg_assign(Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_neg_assign(Natural::ONE);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_neg_assign(&Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_neg_assign(&Natural::ONE);\n    });\n}\n\n#[test]\nfn mod_neg_properties() {\n    natural_pair_gen_var_8().test_properties(|(n, m)| {\n        assert!(n.mod_is_reduced(&m));\n        let neg = (&n).mod_neg(&m);\n        assert!(neg.is_valid());\n        assert!(neg.mod_is_reduced(&m));\n\n        let neg_alt = (&n).mod_neg(m.clone());\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        let neg_alt = n.clone().mod_neg(&m);\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        let neg_alt = n.clone().mod_neg(m.clone());\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        let mut n_alt = n.clone();\n        n_alt.mod_neg_assign(&m);\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        let mut n_alt = n.clone();\n        n_alt.mod_neg_assign(m.clone());\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        assert_eq!(neg, (-&n).mod_op(Integer::from(&m)));\n        assert_eq!((&neg).mod_neg(&m), n);\n        assert_eq!((&n).mod_add(&neg, &m), 0);\n        assert_eq!(n == neg, n == Natural::ZERO || n << 1 == m);\n    });\n\n    unsigned_pair_gen_var_16::<Limb>().test_properties(|(n, m)| {\n        assert_eq!(n.mod_neg(m), Natural::from(n).mod_neg(Natural::from(m)));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingDivNegMod, DivMod, Mod, ModAssign, ModIsReduced, NegMod, NegModAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{ExactFrom, JoinHalves};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_12, unsigned_vec_pair_gen_var_11, unsigned_vec_pair_gen_var_18,\n    unsigned_vec_triple_gen_var_57, unsigned_vec_unsigned_pair_gen_var_22,\n    unsigned_vec_unsigned_pair_gen_var_26, unsigned_vec_unsigned_pair_gen_var_27,\n    unsigned_vec_unsigned_pair_gen_var_28,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::div_mod::{\n    limbs_div_mod_barrett_scratch_len, limbs_two_limb_inverse_helper,\n};\nuse malachite_nz::natural::arithmetic::mod_op::{\n    limbs_mod, limbs_mod_barrett, limbs_mod_by_two_limb_normalized, limbs_mod_divide_and_conquer,\n    limbs_mod_limb, limbs_mod_limb_alt_1, limbs_mod_limb_alt_2, limbs_mod_limb_any_leading_zeros_1,\n    limbs_mod_limb_any_leading_zeros_2, limbs_mod_limb_at_least_1_leading_zero,\n    limbs_mod_limb_at_least_2_leading_zeros, limbs_mod_limb_small_normalized,\n    limbs_mod_limb_small_unnormalized, limbs_mod_schoolbook, limbs_mod_three_limb_by_two_limb,\n    limbs_mod_to_out,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_12, natural_gen, natural_gen_var_2, natural_pair_gen_var_5,\n    natural_pair_gen_var_6, natural_triple_gen_var_4, unsigned_sextuple_gen_var_2,\n    unsigned_vec_quadruple_gen_var_5, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_17,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_op::{limbs_mod_limb_alt_3, rug_neg_mod};\nuse num::{BigUint, Integer};\nuse rug;\nuse rug::ops::RemRounding;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_limb() {\n    let test = |ns: &[Limb], d: Limb, r: Limb| {\n        assert_eq!(limbs_mod_limb::<DoubleLimb, Limb>(ns, d), r);\n        assert_eq!(\n            limbs_mod_limb_any_leading_zeros_1::<DoubleLimb, Limb>(ns, d),\n            r\n        );\n        assert_eq!(\n            limbs_mod_limb_any_leading_zeros_2::<DoubleLimb, Limb>(ns, d),\n            r\n        );\n        assert_eq!(limbs_mod_limb_alt_1::<DoubleLimb, Limb>(ns, d), r);\n        assert_eq!(limbs_mod_limb_alt_2::<DoubleLimb, Limb>(ns, d), r);\n        assert_eq!(limbs_mod_limb_alt_3(ns, d), r);\n    };\n    test(&[0, 0], 2, 0);\n    // - shift != 0 in limbs_mod_limb_any_leading_zeros_1\n    // - r_hi < b in limbs_mod_limb_any_leading_zeros_1\n    // - n == 2 in limbs_mod_limb_any_leading_zeros_1\n    // - !divisor.get_highest_bit() in limbs_mod_limb_alt_2\n    // - !divisor.get_highest_bit() && len < MOD_1U_TO_MOD_1_1_THRESHOLD in limbs_mod_limb_alt_2\n    test(&[6, 7], 1, 0);\n    test(&[6, 7], 2, 0);\n    // - n > 2 in limbs_mod_limb_any_leading_zeros_1\n    // - !divisor.get_highest_bit() && MOD_1U_TO_MOD_1_1_THRESHOLD <= len <\n    //   MOD_11_TO_MOD_1_2_THRESHOLD in limbs_mod_limb_alt_2\n    test(&[100, 101, 102], 10, 8);\n    test(&[123, 456], 789, 636);\n    test(&[0, 0], 0xa0000000, 0);\n    // - shift == 0 in limbs_mod_limb_any_leading_zeros_1\n    // - divisor.get_highest_bit() in limbs_mod_limb_alt_2\n    // - divisor.get_highest_bit() && len < MOD_1N_TO_MOD_1_1_THRESHOLD in limbs_mod_limb_alt_2\n    test(&[6, 7], 0x80000000, 6);\n    test(&[6, 7], 0xa0000000, 0x20000006);\n    // - divisor.get_highest_bit() && len >= MOD_1N_TO_MOD_1_1_THRESHOLD in limbs_mod_limb_alt_2\n    test(&[100, 101, 102], 0xabcddcba, 2152689614);\n    // - r_hi >= b in limbs_mod_limb_any_leading_zeros_1\n    test(&[u32::MAX, u32::MAX], 2, 1);\n    test(&[u32::MAX, u32::MAX], 3, 0);\n    test(&[u32::MAX, u32::MAX], u32::MAX, 0);\n    test(&[u32::MAX, u32::MAX], 0xa0000000, 1610612735);\n    test(&[100, 101, 102], u32::MAX, 303);\n    test(&[1, 2, 3, 4], 6, 1);\n    // - !divisor.get_highest_bit() && len >= MOD_11_TO_MOD_1_2_THRESHOLD && (len <\n    //   MOD_12_TO_MOD_1_4_THRESHOLD || divisor & HIGHEST_TWO_BITS_MASK != 0) in\n    //   limbs_mod_limb_alt_2\n    test(\n        &[\n            3713432036, 2475243626, 3960734766, 244755020, 3760002601, 301563516, 2499010086,\n            1451814771, 1299826235, 3628218184, 2565364972, 3729936002,\n        ],\n        565832495,\n        295492150,\n    );\n    // - !divisor.get_highest_bit() && len >= MOD_12_TO_MOD_1_4_THRESHOLD && divisor &\n    //   HIGHEST_TWO_BITS_MASK == 0 in limbs_mod_limb_alt_2\n    test(\n        &[\n            540286473, 1475101238, 1863380542, 2517905739, 81646271, 3172818884, 2759300635,\n            852345965, 3647245071, 3875987988, 4229899590, 4100778302, 1641902155, 1289745333,\n            3414845068, 119899697, 2175381145, 2490291811, 3047506964, 1815484255, 3379971995,\n            1695675424, 1418284338,\n        ],\n        436775226,\n        165213921,\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_fail_1() {\n    limbs_mod_limb::<DoubleLimb, Limb>(&[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_fail_2() {\n    limbs_mod_limb::<DoubleLimb, Limb>(&[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_any_leading_zeros_1_fail_1() {\n    limbs_mod_limb_any_leading_zeros_1::<DoubleLimb, Limb>(&[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_any_leading_zeros_1_fail_2() {\n    limbs_mod_limb_any_leading_zeros_1::<DoubleLimb, Limb>(&[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_any_leading_zeros_2_fail_1() {\n    limbs_mod_limb_any_leading_zeros_2::<DoubleLimb, Limb>(&[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_any_leading_zeros_2_fail_2() {\n    limbs_mod_limb_any_leading_zeros_2::<DoubleLimb, Limb>(&[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_limb_small_normalized() {\n    let test = |ns: &[Limb], d: Limb, r: Limb| {\n        assert_eq!(\n            limbs_mod_limb_small_normalized::<DoubleLimb, Limb>(ns, d),\n            r\n        );\n    };\n    test(&[0x80000123], 0x80000000, 0x123);\n    test(&[0, 0], 0xa0000000, 0);\n    test(&[6, 7], 0x80000000, 6);\n    test(&[6, 7], 0xa0000000, 0x20000006);\n    test(&[100, 101, 102], 0xabcddcba, 2152689614);\n    test(&[u32::MAX, u32::MAX], u32::MAX, 0);\n    test(&[u32::MAX, u32::MAX], 0xa0000000, 1610612735);\n    test(&[100, 101, 102], u32::MAX, 303);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_small_normalized_fail_1() {\n    limbs_mod_limb_small_normalized::<DoubleLimb, Limb>(&[], u32::MAX);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_small_normalized_fail_2() {\n    limbs_mod_limb_small_normalized::<DoubleLimb, Limb>(&[10, 10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_limb_small_unnormalized() {\n    let test = |ns: &[Limb], d: Limb, r: Limb| {\n        assert_eq!(\n            limbs_mod_limb_small_unnormalized::<DoubleLimb, Limb>(ns, d),\n            r\n        );\n        assert_eq!(\n            limbs_mod_limb_at_least_1_leading_zero::<DoubleLimb, Limb>(ns, d),\n            r\n        );\n    };\n    test(&[0, 0], 2, 0);\n    test(&[0], 2, 0);\n    // - remainder >= divisor in limbs_mod_limb_small_unnormalized\n    // - len.odd() in limbs_mod_limb_at_least_1_leading_zero\n    // - len == 1 in limbs_mod_limb_at_least_1_leading_zero\n    test(&[6], 2, 0);\n    test(&[6], 4, 2);\n    // - len.even() in limbs_mod_limb_at_least_1_leading_zero\n    // - len < 4 in limbs_mod_limb_at_least_1_leading_zero\n    test(&[6, 7], 1, 0);\n    test(&[6, 7], 2, 0);\n    // - len.odd() && len != 1 in limbs_mod_limb_at_least_1_leading_zero\n    test(&[100, 101, 102], 10, 8);\n    // - remainder < divisor in limbs_mod_limb_small_unnormalized\n    test(&[123, 456], 789, 636);\n    test(&[u32::MAX, u32::MAX], 2, 1);\n    test(&[u32::MAX, u32::MAX], 3, 0);\n    // - len >= 4 in limbs_mod_limb_at_least_1_leading_zero\n    test(&[1, 2, 3, 4, 5], 6, 3);\n    test(&[1, 2, 3, 4], 6, 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_small_unnormalized_fail_1() {\n    limbs_mod_limb_small_unnormalized::<DoubleLimb, Limb>(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_small_unnormalized_fail_2() {\n    limbs_mod_limb_small_unnormalized::<DoubleLimb, Limb>(&[10, 10], u32::MAX);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_at_least_1_leading_zero_fail_1() {\n    limbs_mod_limb_at_least_1_leading_zero::<DoubleLimb, Limb>(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_at_least_1_leading_zero_fail_2() {\n    limbs_mod_limb_at_least_1_leading_zero::<DoubleLimb, Limb>(&[10, 10], u32::MAX);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_limb_at_least_2_leading_zeros() {\n    let test = |ns: &[Limb], d: Limb, r: Limb| {\n        assert_eq!(\n            limbs_mod_limb_at_least_2_leading_zeros::<DoubleLimb, Limb>(ns, d),\n            r\n        );\n    };\n    test(&[0, 0], 2, 0);\n    test(&[0], 2, 0);\n    // - len ≡ 1 mod 4\n    // - len < 4\n    test(&[6], 2, 0);\n    test(&[6], 4, 2);\n    // - len ≡ 2 mod 4\n    test(&[6, 7], 1, 0);\n    test(&[6, 7], 2, 0);\n    // - len ≡ 3 mod 4\n    test(&[100, 101, 102], 10, 8);\n    test(&[123, 456], 789, 636);\n    test(&[u32::MAX, u32::MAX], 2, 1);\n    test(&[u32::MAX, u32::MAX], 3, 0);\n    // - len ≡ 0 mod 4\n    test(&[1, 2, 3, 4], 6, 1);\n    // - len >= 4\n    test(&[1, 2, 3, 4, 5], 6, 3);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_at_least_2_leading_zeros_fail_1() {\n    limbs_mod_limb_at_least_2_leading_zeros::<DoubleLimb, Limb>(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_limb_at_least_2_leading_zeros_fail_2() {\n    limbs_mod_limb_at_least_2_leading_zeros::<DoubleLimb, Limb>(&[10, 10], 0x7fffffff);\n}\n\nfn verify_limbs_mod_three_limb_by_two_limb(\n    n_2: Limb,\n    n_1: Limb,\n    n_0: Limb,\n    d_1: Limb,\n    d_0: Limb,\n    r: DoubleLimb,\n) {\n    let n = Natural::from_owned_limbs_asc(vec![n_0, n_1, n_2]);\n    let d = Natural::from(DoubleLimb::join_halves(d_1, d_0));\n    let r = Natural::from(r);\n    assert_eq!(n % &d, r);\n    assert!(r < d);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_three_limb_by_two_limb() {\n    let test = |n_2, n_1, n_0, d_1, d_0, r| {\n        assert_eq!(\n            limbs_mod_three_limb_by_two_limb(\n                n_2,\n                n_1,\n                n_0,\n                d_1,\n                d_0,\n                limbs_two_limb_inverse_helper(d_1, d_0)\n            ),\n            r\n        );\n        verify_limbs_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, r);\n    };\n    test(1, 2, 3, 0x80000004, 5, 0x7ffffffdfffffffe);\n    test(2, 0x40000000, 4, 0x80000000, 0, 0x4000000000000004);\n    test(\n        1614123406,\n        3687984980,\n        2695202596,\n        2258238141,\n        1642523191,\n        274277675918877623,\n    );\n}\n\nfn verify_limbs_mod_by_two_limb_normalized(ns: &[Limb], ds: &[Limb], r_0: Limb, r_1: Limb) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let expected_r = n % &d;\n    let r = Natural::from_owned_limbs_asc(vec![r_0, r_1]);\n    assert_eq!(r, expected_r);\n    assert!(r < d);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_by_two_limb_normalized() {\n    let test = |ns: &[Limb], ds: &[Limb], r_0: Limb, r_1: Limb| {\n        assert_eq!(limbs_mod_by_two_limb_normalized(ns, ds), (r_0, r_1));\n        verify_limbs_mod_by_two_limb_normalized(ns, ds, r_0, r_1);\n    };\n    test(&[1, 2], &[3, 0x80000000], 1, 2);\n    test(&[1, 2, 3, 4, 5], &[3, 0x80000000], 166, 2147483626);\n    test(\n        &[4142767597, 2922703399, 3921445909],\n        &[2952867570, 2530544119],\n        3037232599,\n        1218898013,\n    );\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_by_two_limb_normalized_fail_1() {\n    limbs_mod_by_two_limb_normalized(&[1, 2], &[3, 4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_by_two_limb_normalized_fail_2() {\n    limbs_mod_by_two_limb_normalized(&[1, 2], &[3, 0x80000000, 4]);\n}\n\nfn verify_limbs_mod_1(ns_in: &[Limb], ds: &[Limb], ns_out: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns_in);\n    let d = Natural::from_limbs_asc(ds);\n    let expected_r = n % &d;\n    let r = Natural::from_limbs_asc(&ns_out[..ds.len()]);\n    assert_eq!(r, expected_r);\n    assert!(r < d);\n}\n\n#[test]\nfn test_limbs_mod_schoolbook() {\n    let test = |ns_in: &[Limb], ds: &[Limb], ns_out: &[Limb]| {\n        let mut ns = ns_in.to_vec();\n        let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n        limbs_mod_schoolbook(&mut ns, ds, d_inv);\n        assert_eq!(ns, ns_out);\n        verify_limbs_mod_1(ns_in, ds, &ns);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        test(&[1, 2, 3], &[3, 4, 0x80000000], &[1, 2, 3]);\n        test(\n            &[1, 2, 3, 4, 5, 6],\n            &[3, 4, 0x80000000],\n            &[268, 328, 2147483575, 4294967251, 5, 6],\n        );\n        test(\n            &[0, 0, 0, 1],\n            &[1, 0, 0x80000000],\n            &[u32::MAX, u32::MAX, 0x7fffffff, 1],\n        );\n        test(\n            &[\n                2460989955, 642673607, 1971681331, 2338977519, 475442971, 2516527409, 3470931196,\n                4262052990,\n            ],\n            &[\n                1430162564, 1873089879, 3090281851, 2861182896, 2502166555, 2486624904, 960387080,\n                3073064701,\n            ],\n            &[\n                1030827391, 3064551024, 3176366775, 3772761918, 2268243711, 29902504, 2510544116,\n                1188988289,\n            ],\n        );\n        test(\n            &[\n                0,\n                0x4000000,\n                0xfffff000,\n                63,\n                4294443008,\n                u32::MAX,\n                u32::MAX,\n                8388575,\n                4294836224,\n                0x3fffffff,\n            ],\n            &[33554304, 4294443008, u32::MAX],\n            &[\n                0,\n                0,\n                0,\n                4294443072,\n                0xfff00000,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                4294836224,\n                0x3fffffff,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[\n                9995257893114397114,\n                9401504468144459131,\n                558615837638945228,\n                10733662027974786928,\n                18295107704289976677,\n                1814706268673753787,\n                12474943759854623335,\n                8814778832826774208,\n                9159057654048965906,\n                4451260977376821357,\n                18241701617364042056,\n                6169989192350218482,\n                15071965537117101028,\n                13509168527678537782,\n                12224278653171635329,\n                16077066393714953826,\n                1433938684868066489,\n                13014970036232570373,\n                899282336249563956,\n                3089487642230339536,\n                3787737519477527148,\n                16667686214395942740,\n                8787122953224574943,\n                7841835218775877827,\n                9693303502025838409,\n                16122224776459879427,\n                144327425397945219,\n            ],\n            &[\n                2350654041004706911,\n                7834348511584604247,\n                12756796070221345724,\n                3842923787777653903,\n                12373799197090248752,\n                9712029403347085570,\n                1426676505264168302,\n                10586232903332693517,\n                8387833601131974459,\n                6290888746273553243,\n                9503969704425173615,\n            ],\n            &[\n                12688955427180652274,\n                7641660693922643933,\n                8789985477567049482,\n                5698832637416200787,\n                14684840547760545685,\n                2822100467869581421,\n                3557573565928866957,\n                4409631974409684922,\n                16994214656621423610,\n                4513108841166793667,\n                9009005527785483287,\n                4330767427200269309,\n                11409205475757922767,\n                12430752173702915207,\n                11990819624778098799,\n                4145020291153594556,\n                7099200056207569977,\n                3510167930325480168,\n                4731667122118327121,\n                10720310942075546738,\n                5799804483118787221,\n                17268037247251138479,\n                13305947798457087249,\n                1405091439325174594,\n                13072181651983436371,\n                16122224776459879427,\n                144327425397945219,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_schoolbook_fail_1() {\n    let ds = &[3, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_mod_schoolbook(&mut [1, 2, 3], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_schoolbook_fail_2() {\n    let ds = &[3, 4, 5, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_mod_schoolbook(&mut [1, 2, 3], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_schoolbook_fail_3() {\n    let ds = &[3, 4, 5];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_mod_schoolbook(&mut [1, 2, 3], ds, d_inv);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_divide_and_conquer() {\n    let test = |qs_in: &[Limb], ns_in: &[Limb], ds: &[Limb], ns_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut ns = ns_in.to_vec();\n        let ds_len = ds.len();\n        let d_inv = limbs_two_limb_inverse_helper(ds[ds_len - 1], ds[ds_len - 2]);\n        limbs_mod_divide_and_conquer(&mut qs, &mut ns, ds, d_inv);\n        assert_eq!(&ns[..ds_len], ns_out);\n        verify_limbs_mod_1(ns_in, ds, &ns);\n    };\n    test(\n        &[10; 4],\n        &[1, 2, 3, 4, 5, 6, 7, 8, 9],\n        &[3, 4, 5, 6, 7, 0x80000000],\n        &[718, 910, 1080, 1286, 1492, 2147483434],\n    );\n    test(\n        &[0; 3],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n        &[0, 0, 0, 0, 1, 0, 0, 0x80000000],\n        &[0, 0, 0, 0, u32::MAX, u32::MAX, u32::MAX, 0x7fffffff],\n    );\n    test(\n        &[\n            1341443830, 680228019, 2358294753, 4240552485, 4220791420, 3445360969, 1267691556,\n            3340881424, 992535572, 1421700486, 4136881179,\n        ],\n        &[\n            342694080, 2041952014, 1126110022, 386493367, 2712278177, 1646877232, 868323005,\n            1128141558, 2508964077, 2270408768, 413397861, 276293957, 2413870149, 3904853505,\n            1276303079, 2556190902, 3967785388, 2803311564, 1963309088, 2281251697, 108392083,\n            3821172642, 2048710986, 445614759, 2901896991, 3601903082, 1748962330, 658337341,\n            3756770944, 2926642090, 7482898, 2241569433, 3381544088, 3275875595, 3036252835,\n            2075586864, 1267727773, 221607050, 3946214050, 921175728, 655433083, 3594825352,\n            1857831165, 3460211778, 2710641188, 1271591399, 263125866, 3619333728, 1041602820,\n            3231202083, 259949419, 4156557841, 3419638674, 3270070813, 2084018311, 2951772182,\n            860428573, 1138531819, 71044931, 3406637788, 3662652535, 3741808197, 86584983,\n            1543795459, 160951322, 1039367499, 2428548772, 3604743617, 1138310711, 2881638514,\n            2899388867, 3501166651, 161644747, 2395978477, 2682256494, 3417971200, 624066885,\n            1772236754, 48275686, 3979745914, 2458268763, 2470110876, 3143857674, 3359279240,\n            46246098, 2912257532, 2916568936,\n        ],\n        &[\n            4267671814, 3181376526, 4204274026, 2772982826, 171341955, 3239339748, 83269891,\n            2325049318, 746305994, 1290717192, 1805639230, 1856363646, 3445599715, 1388597950,\n            2699498310, 246990054, 1396771726, 265087723, 3372840761, 3260397695, 2010115470,\n            2211074582, 1883962263, 256363687, 4012920099, 2367091978, 1485341992, 1836339208,\n            1434180757, 2616877872, 1145425491, 1261399773, 3926766027, 3115015865, 1741783714,\n            3802513218, 4081750672, 3856503286, 2137512595, 1192985123, 1863041957, 700637154,\n            2503934926, 2021744810, 157763047, 453501781, 1898727251, 3741166728, 105996483,\n            3390681922, 1127471458, 4229032301, 254843851, 2729237155, 1707011850, 1756734415,\n            1864969309, 96539023, 220456923, 3061776324, 1741151628, 1199010536, 2099212259,\n            3095715999, 1369052975, 2575251120, 1821995904, 4169452262, 3299830336, 666854626,\n            3647011057, 3965571435, 1551218489, 726151433, 1730753749, 750433250, 2084548637,\n            475638490, 3209308986, 1536371286, 3458731894, 451976715, 1463077982, 2401462738,\n        ],\n        &[\n            50882392, 3543059939, 2606418187, 171797978, 3702339267, 3400795540, 1675838746,\n            3131956910, 3246773095, 2366066134, 1942572319, 200951604, 2751524401, 2229461380,\n            953596498, 2149080321, 992246008, 2665146762, 3598754770, 101403369, 2364937647,\n            3687287854, 3518388658, 3773344884, 2952272227, 2179289728, 3985568008, 2985468384,\n            1733586261, 4006520661, 592636589, 1738983882, 3771432433, 334405279, 30528997,\n            3353300809, 3694124666, 1257341879, 1142716002, 3178475445, 1431232435, 2733787829,\n            2350134046, 162973337, 604966704, 1355497537, 2006066960, 1053669332, 2166548589,\n            1297102232, 878976420, 1030095675, 3202690801, 955256572, 1487108550, 2945568597,\n            3875785235, 1390419282, 1216776596, 786261001, 3784540042, 1845909951, 1777517834,\n            12237310, 475982412, 3059699536, 4125207911, 2924612871, 3238196381, 2479221661,\n            1483884124, 433754513, 447002430, 2684532044, 3494064078, 619277683, 2680056541,\n            538552294, 1984267024, 700348592, 1278341418, 1614761367, 3944408375, 1269851701,\n        ],\n    );\n    test(\n        &[\n            3656551823, 3383257247, 550091805, 1932339117, 3279901067, 2864941409, 3440756420,\n            466783416, 651341619, 2318022162, 1201487629, 3064175522, 2345469826, 3581748650,\n            2606599593, 3742095121,\n        ],\n        &[\n            3689695988, 3117118992, 1237207334, 1180101208, 2947083336, 2827697081, 221923985,\n            2507264800, 619323315, 1516562901, 3186068769, 1013769776, 1271582351, 1669896397,\n            2497959088, 3504047880, 4212568439, 1608150067, 4150555892, 374787916, 889323122,\n            3833122938, 4262272989,\n        ],\n        &[\n            3226059476, 722714803, 1915993039, 2160412527, 1484228011, 1715426198, 1611850737,\n            3097214810,\n        ],\n        &[\n            1074470868, 2174113464, 1715956530, 3963027838, 1871758691, 1809783936, 3173233408,\n            1926929270,\n        ],\n    );\n    test(\n        &[\n            2108009976, 2838126990, 827008974, 4157613011, 3782799311, 839921672, 879731301,\n            1926496935, 3712149888, 2363043408, 3863476261, 1703718215, 499165670, 2993223230,\n            4279694017, 2976095205, 2193242813, 3593708162, 586354096, 296757650, 242624274,\n            199363552, 2802933005, 2759687879, 3925865458, 4217980786, 621040829, 4008464542,\n            3795907109, 270168250, 3625538473, 759155103, 3959828159, 1835721901, 1818377089,\n            114690984, 2967220963, 2377698568, 2241245638, 2252300906, 3116551983, 3644576818,\n            2608501946, 2181270779, 1815210824, 1268283136, 484429506, 1180516809, 559610343,\n            2543044915, 3719740023, 558939794, 3989231279, 1089033996, 3509826828, 3545449066,\n            3353643945, 2822587915, 2300900020, 309191900, 2371088678, 1169317833, 2688462322,\n            704882387, 1429447898, 2514029776, 1955158460, 3862686818, 1584130288, 482000750,\n            4224830364, 2104097699, 1183456674, 2270729014, 2607655660, 2966545947, 2931252595,\n            759652385, 3970839358, 2487392344, 1507124762, 758697388, 3840603988, 1293583672,\n            252424514, 646352064, 1756992845, 2309291248, 3392597937, 2946557682, 3659552460,\n            1720311830, 3395887210, 2674135679, 3196424053, 2895118562, 1256983146, 2482795730,\n            1922474903, 2105232035, 3692384401, 2891711374, 3496171341, 515080177, 4073860792,\n            2051799135, 2279442367, 3258846627, 70977295, 1937954703, 2800340027, 1760719187,\n            646417623, 3158839049, 3176203007, 213391749, 869819866, 3906922929, 1586646665,\n            1614123406, 3687984980, 1177302158, 272342927, 1441818617, 2083855650, 1541781406,\n            3311904586, 106907162, 4108429222, 662974012, 4140594255, 1984524179, 3259771450,\n            3863443649, 3307256449, 3597197635, 3771753969, 3551628070, 3550518548, 2546464879,\n            3812123817, 2299164636, 2258249267, 815945886, 3725185601, 738801212, 3862546442,\n            207778311, 1535617953, 2150997157, 729581295, 143725958, 1410055499, 4204574368,\n            2185442793, 3653861199, 1767186378, 3537808267, 1766021033, 2239408696, 1986025224,\n            3625288948, 4046347844, 2490523057, 3491861717, 1312039469, 597857291, 206880668,\n            1812928615, 3684502664, 3820772609, 1327777451, 1237379465, 764273090, 3594853086,\n            2859643842, 1243019386, 3444655918, 1596721727, 2221238575, 2483346164, 2064518283,\n            2282844430, 1960424205, 4028198846, 2342293800, 1645322170, 3508868511, 2376856302,\n            1764497492, 2461899059, 3430260828, 1083983032, 1448541077, 2081767380, 1131293272,\n            2121152826, 4212689224, 2039367869, 2193844060, 1864700761, 1182989130, 1481869846,\n            969270162, 3997775597, 1483663077, 394034269, 1586435653, 2281434261, 1937512315,\n            836935557, 59742568, 1854699653, 2116629465, 328821302, 1999851100, 604863759,\n            556389113, 2057620108, 1992554416, 427465103, 813735424, 487055225, 402647361,\n            3006998394, 2146302389, 2308517156, 1063328348, 2382344201, 2665908320, 481118926,\n            2376219143, 1164055989, 128362737, 2711666601, 1898018298, 2928344090, 3862251511,\n            749517272, 2790599579, 3506539103, 2592038317, 1682088920, 1332639030, 3053921374,\n            3066891587, 242466377, 3536065834, 2016487096, 1321862427, 2409873623, 3088797737,\n            2840818323, 2052021858, 4079299898, 452968540, 3880575723, 2680668784, 1502544423,\n            1619882634, 1068420458, 3236073318, 1740351058, 1183565882, 2761799103, 246817911,\n            2967032269, 4003972840, 969974269, 3193561842, 1002645557, 2347161653, 4272895273,\n            1522072178, 972383725, 3026624523, 434293193, 2855690795, 2455822196, 2413168892,\n            2999634230, 784531194, 249556803, 2559695464, 3131798530, 668810109, 2114036394,\n            2861740558, 370716909, 2126014070, 3913884200, 1577476936, 855642956, 2074597201,\n            3461659621, 3292762038, 2153122643, 1658901071, 1562860969, 501980289, 1611843440,\n            2433026108, 3791871978,\n        ],\n        &[\n            2325147333, 1406197332, 1502532645, 137754493, 1488912421, 1014222449, 1678300831,\n            2078887154, 2311629707, 3855402290, 1904906031, 1350026944, 314061674, 919972212,\n            1429252796, 544807358, 2607111216, 3001219316, 160533550, 2875169678, 1402474615,\n            3234840532, 1662112023, 1943050521, 4132256985, 2915369430, 699620367, 59590583,\n            2461837586, 3986106860, 2659659366, 3589796255, 4168995860, 2337625655, 4292546333,\n            1793085295, 2647770730, 2871508164, 2660729400, 3630964395, 3874212033, 1240042620,\n            1713051992, 2105061240, 968807145, 3026819276, 2442427316, 2718248469, 2572140009,\n            1793916894, 2112926236, 1058005225, 1528978151, 98430379, 3348888463, 2121431457,\n            3545708238, 3975070402, 764453596, 192861224, 2698588322, 1493819664, 2502294971,\n            3139295505, 1318649192, 1552623529, 2989328476, 1592829691, 1175278450, 182489613,\n            1858350437, 2440903999, 1622786339, 162763913, 4106583944, 609833788, 1344925844,\n            3910333895, 1369398307, 51929280, 2214052160, 78601532, 642016948, 3966440550,\n            4161875340, 3764174238, 2944905670, 832634369, 2082700552, 3444794582, 962611192,\n            38510846, 2733538376, 2141542785, 621670923, 3130866640, 1666281368, 3628581169,\n            3965100367, 2889091703, 762371524, 3752935086, 656901001, 2374421435, 3084212494,\n            1186140919, 3420046356, 775236355, 1337865306, 2051118555, 713071112, 1946850844,\n            1427068060, 3949026319, 3075128554, 438166063, 3975561046, 858907746, 26964870,\n            3843362808, 1461820702, 3090970200, 1037540471, 289966660, 2768763862, 50890120,\n            580189324, 2911422550, 3684738914, 2025034397, 414622319, 2287243961, 3268939669,\n            3547523099, 4011963324, 1768695320, 1859343614, 2123856143, 4141054481, 765801396,\n            359993985, 3668605792, 3613648266, 1778728280, 2547397231, 2456061149, 2562918666,\n            2903450513, 1994190773, 99234624, 3722083920, 4262323306, 202219441, 4201857695,\n            3988878636, 1533308334, 401400520, 1069756554, 2457773969, 2892388936, 3423117995,\n            1944069442, 492036629, 3426800580, 2282483359, 4006366620, 1695364515, 2555180845,\n            1669287836, 349290429, 778467450, 2020203604, 2218159817, 1450404019, 1278304750,\n            2412695340, 1592154884, 3868182043, 2240370481, 3859902860, 1008825116, 412233394,\n            2475457637, 3664379433, 4204584226, 2750684469, 4113507475, 2916584959, 285955744,\n            739598569, 18278051, 3768126932, 2181905109, 2612988076, 1827656088, 1160380415,\n            4160443718, 1846086671, 3050604645, 2547108010, 2828666778, 3252702258, 3885923576,\n            2331974758, 730724707, 1528859315, 4288784328, 3677151116, 445199233, 3304488688,\n            3566979465, 3541025426, 2491779846, 3112990742, 2583249486, 3403111749, 1930721237,\n            3428792463, 2896462048, 2985885576, 1819460734, 21206096, 3560441846, 987100555,\n            2844904275, 84854892, 1268249628, 3963306788, 3338670067, 2504599089, 65588657,\n            321493327, 4249673617, 4150876068, 721566898, 2186945060, 922948272, 1502464627,\n            1426914435, 2906888275, 3454987739, 2609132626, 2073366782, 1058809001, 1226951003,\n            2624503637, 282722778, 1407178266, 3304346308, 3613017687, 2397594777, 161128076,\n            1938083248, 3042822216, 3958145306, 1431161184, 4147630074, 1744618540, 3729847703,\n            2366216428, 2101731625, 2812677939, 3587016062, 1626785569, 3117017254, 3720581461,\n            4254564252, 2400911475, 750362271, 3062375802, 2182368701, 268751862, 2682134876,\n            274793576, 2417658182, 2321240923, 4200603818, 1349142841, 4066976957, 1043247680,\n            679021323, 2933095037, 1621487581, 225868669, 1030678959, 1236344244, 972640788,\n            1784301152, 578117349, 3509551550, 214420003, 3786992737, 802372148, 3562194086,\n            2187046946, 3600373521, 4275090943, 2120016813, 4177241875, 3185774231, 2397692077,\n            1015362399, 2178889151, 3433916223, 1688082118, 1971242178, 236388706, 3802829765,\n            521309115, 2299816689, 3207614143, 1053195464, 3584561145, 1178690670, 2940812254,\n            3321982035, 2754825123, 3073598062, 202404806, 547895545, 1188944547, 1056841779,\n            529463805, 204665384, 850370055, 2063320161, 3724100092, 1180272690, 1398467003,\n            2814052449, 1311768018, 659771105, 3226477227, 4230080238, 2134344405, 1461172705,\n            2728018383, 1816821358, 3231137250, 2012377728, 2206916761, 3121807673, 3037967028,\n            3653505029, 4164239058, 1337501466, 2487452346, 428839025, 3321493092, 2920064796,\n            2750126813, 3635762100, 2659829309, 1992243088, 2359420187, 861816585, 4182313312,\n            1389528266, 2890138969, 2195001695, 576635805, 1974585967, 851480113, 1896534852,\n            3143828462, 4276040597, 3921135859, 2394233682, 2692972118, 2103941456, 3931376544,\n            3790764632, 2278428793, 3381340311, 3516241824, 2923157557, 1276268033, 3471729699,\n            2370137091, 2637023305, 4027814477, 3711009696, 3667995314, 459819000, 1002878772,\n            2658190707, 1189561796, 1831813150, 2874008201,\n        ],\n        &[\n            1703326352, 1625259628, 3642322228, 911402341, 2158835226, 939248485, 3607511108,\n            2863853568, 1611642161, 1312857772, 1839433327, 567060478, 3139863681, 3642698184,\n            3744632443, 712538472, 2692932947, 576185818, 156934113, 518107105, 2803035863,\n            2284220097, 3447382922, 2400125006, 3565062840, 160044186, 3644393084, 4196433258,\n            3391883838, 1115703759, 2380388002, 962895870, 4001772616, 2311278419, 2620271020,\n            3047789793, 3229254302, 3182628087, 2718480927, 2872538422, 1963990826, 2856537226,\n            1729736384, 372544200, 1482170753, 3370665422, 305555060, 4060802437, 1456459795,\n            2848113958, 1036273297, 3245835346, 3355862097, 3242734427, 3313897419, 4230036415,\n            1425594704, 2428756491, 420147714, 3218149930, 1791217142, 2881741659, 3231612869,\n            845372829, 1635665046, 1525482197, 3779462557, 2279005731, 626908159, 2963734610,\n            215448882, 2517668355, 3294128769, 1167990371, 2344651228, 2882002195, 3350056381,\n            3749638142, 476010196, 2304276366, 1088082897, 1927672185, 3316329053, 1174989749,\n            1101596429, 3054511229, 1685228241, 2301284206, 2526016461, 684171580, 3869889559,\n            2606492401, 2114658735, 1419214215, 2779052449, 2594333668, 2225446358, 1211258458,\n            4029343999, 2816277230, 4098142949, 1987363952, 2732004911, 2516355975, 2365350298,\n            1747416524, 3951513077, 3526462790,\n        ],\n        &[\n            1707334789, 979340170, 3926273349, 2029694660, 686358037, 1260123629, 689471236,\n            4127009836, 1697317324, 3024229658, 3968952300, 2265029759, 733830093, 2234057965,\n            799627406, 1641742523, 2511563041, 678204198, 60484965, 1732955108, 1348641815,\n            1389334445, 3762643904, 3914179461, 4076462931, 3234877741, 2806715190, 3058911852,\n            3068848122, 80861952, 660210165, 2035863667, 3882844515, 2652987274, 207029959,\n            4170201248, 1224653886, 3554890284, 323203565, 969583090, 2280910221, 2548241625,\n            2048045350, 3691775573, 3750377304, 2623340073, 1726676400, 2551234664, 3420452119,\n            1785849707, 3581615935, 3521097022, 4008380099, 4200557552, 3795120169, 488463511,\n            3784467967, 2462685342, 1684084055, 1072125823, 765304928, 2900468163, 3209242917,\n            399160769, 3897765190, 3241572534, 1027203705, 4127226109, 154941175, 1755153596,\n            4225252328, 1209101989, 2906888698, 1481930532, 2884731435, 2416462752, 553651049,\n            2247421040, 3347507436, 1936621186, 3156059073, 4059864280, 3191940359, 3872902453,\n            783002816, 3711047515, 1471051688, 357992570, 1061754510, 3765779801, 4106840335,\n            3213049794, 1824410844, 2555550067, 1066295382, 3248869963, 4006861446, 3297772017,\n            3418388327, 2284151457, 766215224, 1091253635, 2070830666, 1435103841, 1408352671,\n            338399542, 2946293497, 412804347,\n        ],\n    );\n    test(\n        &[\n            3333140561, 2349469031, 666934289, 3646788197, 3373340607, 3062489357, 1781577064,\n            3971231072, 2027939726, 18149756, 461121573, 1026270057, 4154481498, 3854995191,\n            2829169318, 2604923553, 1399568275, 4214150257, 1269657447, 527209086, 559827800,\n            1978807620, 1942748659, 3544969161, 760896836, 694370989, 3323597771, 1950755821,\n            1740588707, 2716546795, 1636681281, 131422512, 2683077565, 4107286368, 3475458482,\n            1406752921, 2741526831, 625075474, 1356017187, 660778033, 4078598031, 2127023485,\n            1900179860, 2413773277, 2442990944, 850894581, 1061627184, 2255197913, 490496693,\n            400007380, 3092474488, 1228905086, 1949288324, 1866222251, 4084867584, 219026194,\n            1513678816, 2415719293, 671740632, 2331463444, 1649508273, 622524186, 36198287,\n            385821590, 3891184984, 3888867762, 823766845, 871168771, 4220135146, 3182319759,\n            3811051122, 2244319794, 1994956782, 3515960993, 3523512148, 4142104035, 11404747,\n            3407068856, 2661473296, 1343912700, 1278923149, 1319603671, 3928437020, 2678906106,\n            1133029551, 3498992572, 3960506675, 2156562886, 2180928089, 4027866586, 3363079195,\n            2699625088, 10633112, 1776348429, 2657266039, 366882369, 3755249663, 1513004482,\n            385462618, 1235118123, 2498536948, 2963795538, 373052379, 4211662453, 1125414031,\n            3132282357, 2555861787, 3949045845, 2694335672, 335933961, 2882374566, 3487775198,\n            1816750435, 3017829161, 964613564, 159555703, 1822850997, 2275865751, 4158541302,\n            2501990511, 3721844651, 2781838144, 1795741626, 377630941, 2137086277, 150771080,\n            3410699853, 2181744662, 3165518125, 156617039, 3099687100, 2159351188, 340108091,\n            2408725718, 1639869303, 1752843886, 1941447467, 2157946488, 1515895552, 3624132653,\n            3556726921, 2697391196, 3650363912, 2596921683, 3641623430, 3884964637, 4229700714,\n            1936259996, 3765315225, 4087511128, 746291101, 1752759843, 699518598, 2102672534,\n            2335948897, 4138231225, 3162828440, 2881768368, 1254885146, 2977691172, 2250072411,\n            2614007259, 2771551612, 776074685, 3162839614, 1471012556, 523323297, 1856466918,\n            4090405884, 813410161, 100155385, 1084252628, 1599609446, 139407955, 4121369443,\n            1963225032, 2735275753, 100107317, 1064061529, 50786861, 1654370440, 3334472166,\n            1385803654, 3881645932, 3538258401, 1238925138, 1307191791, 2439918414, 1853442725,\n            3584719283, 2139830944, 1008033673, 2159214266, 1728151904, 2054140804, 2246372905,\n            1296034828, 732486414, 4197166746, 2149038695, 2421556216, 2209917678, 2053724924,\n            3695308867, 2810551805, 3486105675, 979515789, 2065617241, 3321246575, 4275036932,\n            3028497318, 1883398852, 1301060583, 2486427309, 592113155, 2482121819, 53211642,\n            3067158128, 2316354328, 2457370797, 1766767168, 4130364650, 1394191393, 893956183,\n            3188688185, 1875859783, 3686866863, 3294062742, 2146834313, 2406586432, 1574602180,\n            3208002016, 1067708846, 1620126309, 593911816, 1573785767, 2208656217, 4037191927,\n            3437397556, 425721135, 3749387007, 407468749, 4203518167, 557223936, 3186718435,\n            3473504989, 2673679280, 1478635903, 4172750097, 1469776418, 2542136327, 941914936,\n            3438581078, 3116581940, 3479694655, 159558945, 3809792710, 2458053073, 945749848,\n            3386290936, 950397544, 148027778, 275178526, 1664599931, 2000347485, 3312866545,\n            4123761723, 2408292910, 4050298, 4225958969, 2745635153, 1877283873, 90573827,\n            3031684040, 2275034810, 476532317, 4006527249, 2818283214, 661127690, 2880950746,\n            3285389422, 965419004, 1273458580, 1611437669, 4165036259, 503131762, 337440890,\n            1274837150, 3486913543, 1110808141, 3573281492, 3543428578, 4165550725, 79661970,\n            1465954224, 4160343768, 3753977684, 849800837, 1568284940, 1214508489, 777072754,\n            3766232553, 4163385462, 3428999259, 906027128, 4231567110, 1070253805, 2975789822,\n            1794042990, 2937404746, 3315145973, 3978541255, 191961431, 2940436214, 614874984,\n            868388988, 4078685796, 2613877234, 3380127687, 2664922311, 3262235038, 741871774,\n            1144269180, 4258950699, 3668553647, 3162392321, 927199539, 557637561, 1114912670,\n            84346866, 4241634616, 592125931, 1914166161, 1225886409, 722682712, 2163011354,\n            2585075265, 2786722853, 1993844439, 3433052694, 3718814733, 3881165856, 1749980152,\n            2115861966, 3664836486, 1644814678, 603487648, 821270634, 3041437740, 925329308,\n            414275079, 3675481275, 583965775, 3319812843, 270816609, 1752806861, 3191564196,\n            3197116565, 2440000620, 4074382088, 3346183865, 176525856, 3011091744, 746158938,\n            1522027948, 930706422, 2574400675, 4141639266, 758742087, 1418306156, 493509688,\n            4102390641, 3757183059, 2174506350, 3715933078, 3450125642, 1345548124, 3845070193,\n            1563795423, 1304049315, 2604880108, 1998271877, 4078353958, 966179722, 3401781407,\n            1708183977, 3890171386, 698646214, 604975097, 4189977050, 1847675543, 2745048720,\n            1585177380, 3886892753, 2534712423, 1830125662, 796996186, 3789574770, 2219095884,\n            38427113, 3653683439, 1791769536, 3941686320, 2991883118, 1081207663, 3863639548,\n            3017351034, 741393256, 2333573607, 2783158305, 2015776314, 3034707152, 1871224010,\n            1795881414, 928539629, 3211747317, 461147496, 1512738445, 1178891684, 2603472964,\n            1694950214, 3121022285, 91788635, 2303571910, 3259041724, 1240577113, 827064078,\n            3847765430, 1254285617, 2609289648, 82835530, 2235563901, 2939680484, 3327268666,\n            3659752183, 1783109461, 2828509671, 3804296197, 406800911, 2037292519, 941994402,\n            3350211940, 4004870359, 1105941782, 2367553097, 2440982990, 1468367, 2369391483,\n            3613174135, 2337161925, 2600055725, 1612773644, 1037201309, 919122459, 1114016493,\n            670586694, 594109706, 113464329, 4093636009, 307208587, 3876235186, 3370598978,\n            934478190, 2843794891,\n        ],\n        &[\n            2368917411, 3160758175, 1531480588, 2746326450, 3122359045, 1995296172, 310451197,\n            1100329853, 2141732304, 3562890277, 4172526924, 4143185198, 2397101926, 620168044,\n            828452963, 3271569899, 2726758945, 1647557222, 2748652901, 1029871186, 1773072595,\n            1311795717, 2792240418, 3100733307, 298902661, 2608361440, 642743765, 3026335712,\n            1586592828, 1251923561, 2152803283, 3359308047, 3979690761, 2548031009, 2148504694,\n            2514911217, 401310800, 1418125404, 2325652800, 716233458, 422262103, 376190943,\n            1713380879, 2534508846, 2080413009, 2690193951, 2909422387, 2435837201, 176977642,\n            224472737, 1590904934, 1664979624, 1748982641, 1284257790, 2779881254, 385265989,\n            1148527382, 800142050, 3595556318, 3950265146, 3931111523, 3399894595, 4200004994,\n            3727110364, 1510525540, 429323681, 2586345405, 3441619670, 94654169, 2266545045,\n            1451808026, 286040435, 364003484, 2106693078, 1916214330, 2622096560, 3504008387,\n            1867458297, 4209615436, 2899684845, 3149003214, 2731979274, 2481557740, 234269740,\n            1239420776, 2726912636, 1844267393, 1488044058, 1587005400, 145015793, 1637696129,\n            1990069464, 3053970062, 676336554, 625771493, 1492378707, 1231018082, 3059699722,\n            4113615249, 2967103567, 3335726303, 2137774253, 273460502, 1561489611, 1227429414,\n            778315897, 3061631993, 2437789514, 2566029814, 3017507824, 3219754602, 35255136,\n            1934306764, 1655248959, 3655963814, 2821596564, 1431977748, 3114012833, 3915822059,\n            343010167, 3704265251, 2691314567, 2602475242, 2459094882, 58857240, 2230690665,\n            1357656795, 3025543277, 3488674640, 408985076, 80729036, 246851391, 1419653386,\n            530010128, 3529087076, 3980421141, 4129023783, 1630771696, 2057278583, 2501545742,\n            790764428, 3984347668, 2562445985, 2262348292, 2515967925, 1103371818, 3735595401,\n            3210477145, 3387257181, 538884374, 2695206119, 4211749041, 1006274735, 2406061865,\n            2654644297, 1268724640, 2399689302, 157759259, 564853502, 865205768, 2174783618,\n            3167863384, 1770172407, 1906775255, 3171669377, 2455086709, 1355327864, 3351895167,\n            4184858376, 2699533565, 2939169294, 1702277740, 3447680482, 3322351998, 4248517760,\n            4100425921, 1169799041, 524849931, 1743345401, 3987645088, 3022177240, 3263737545,\n            3656340460, 239445170, 4089162190, 1208712978, 1453215235, 3390225374, 3337889603,\n            717395279, 1066458381, 2162685522, 4009460245, 2575879990, 2578471337, 4218103221,\n            3046325563, 1352991515, 1561949281, 3488911174, 295633326, 1993756395, 3677304657,\n            796898320, 45622345, 2999482773, 2078651788, 1552765091, 428170722, 1748054862,\n            4158222865, 1050292437, 249107, 2651086861, 1540178674, 1275557298, 651050585,\n            1895599156, 4150309716, 2064336046, 1021257319, 2422595446, 3116755258, 2756656575,\n            2328011578, 3632905157, 2576200202, 830418644, 2430246370, 3913080080, 2371749061,\n            2683067461, 3611558701, 1603392737, 796477803, 604567756, 1376069347, 1491246154,\n            2728262664, 4138498935, 3008562381, 1061547384, 285679033, 2358943172, 1884649492,\n            1783482693, 1010268161, 176114433, 794165875, 2362278477, 3903204233, 326754905,\n            1988607850, 3187254334, 1749797209, 2986661384, 1759716588, 3137467938, 4067743599,\n            1134210801, 3799848836, 1955405545, 3881788427, 3097574490, 3844756657, 3183850151,\n            2496328910, 1468671385, 2888878911, 2306353811, 1498824361, 4152891378, 1588217107,\n            79108222, 2883552792, 2390312777, 1587172303, 2070384343, 2265280181, 4013380367,\n            2742676878, 2654283484, 1471778694, 970959698, 1006151052, 1276307400, 2874101774,\n            3169092608, 244587925, 2402787407, 1635687252, 835856534, 321407542, 2307278464,\n            2272745321, 2574317642, 729437319, 1682288870, 1482920833, 776000268, 3908963888,\n            214874919, 4233311318, 1441385448, 2358127573, 2753681514, 467574656, 4139948165,\n            1538275035, 3244920878, 2576965792, 584068468, 3054546876, 2629688518, 4253271747,\n            3723872815, 1652066683, 990821089, 2335421805, 1989570928, 240486517, 2872315587,\n            3869991906, 3870517664, 1540804424, 397183643, 3750033565, 1433260634, 1506168711,\n            3616651625, 512028445, 3746712828, 3278592880, 2611514549, 1214563129, 1259227909,\n            1067976218, 3425169051, 741795595, 893688343, 2674408703, 3694908868, 2478153735,\n            2220661625, 1022546736, 3719214155, 3161293211, 4131981986, 1473264088, 1651777063,\n            1438502715, 290022167, 59234682, 3458968160, 2552001459, 3451530289, 3800073253,\n            717882913, 845719525, 1038699111, 3058303772, 1117505279, 3682430977, 2869037104,\n            2562493618, 960519305, 4147639705, 1817463351, 3166022129, 3200769866, 789666262,\n            2654485924, 3686362402, 2179867687, 3980226915, 3671542918, 1896992204, 1514962591,\n            815867715, 3924270086, 4262628477, 3977258034,\n        ],\n        &[\n            491933121, 4095154087, 1190388341, 2123387578, 3299683037, 3840239224, 3891252433,\n            3823858915, 548023871, 3189021809, 130119335, 1406023029, 1691542279, 2101470388,\n            367145009, 521045073, 1370995123, 202251222, 2377400220, 3656022509, 2413445446,\n            3583191945, 150872893, 1253881977, 3664619565, 661519973, 672952411, 1111416155,\n            2582282747, 2253466637, 3993637585, 1023965093, 4055175549, 1721196160, 4271105372,\n            1844335262, 794907961, 3970777280, 1279126024, 3389187110, 6388771, 3557792034,\n            2503975364, 1216157736, 4081863507, 1212796362, 22717034, 3517296783, 3126258972,\n            454147562, 4182968994, 685295412, 2996150679, 840677609, 2775806132, 2555856748,\n            2855553012, 2971949846, 3057579317, 954558068, 1251032539, 2673204563, 697957636,\n            1312479140, 2686740988, 2005131101, 664387193, 2169938189, 4081160067, 3469684725,\n            123152292, 2899902365, 1142266692, 2066860665, 647803613, 3574778631, 1302596512,\n            678200322, 3509569151, 849744577, 1521760114, 3195673981, 111241164, 623461570,\n            3571445453, 200189218, 4138515602, 665845464, 4184871542, 1353865395, 2913489035,\n            3076207781, 2549062531, 3446687793, 685940105, 1430268106, 2488363196, 1172253595,\n            4151501269, 3292280286, 2025935004, 3388911026, 1080796771, 3386986959, 4175562557,\n            2440556214, 9871988, 5488492, 4179517076, 908443542, 364965294, 2303037125, 369102673,\n            1570100894, 3615415741, 3133015360, 2623933135, 211314818, 3377760249, 2285528104,\n            3096807957, 3213907502, 3633343924, 2065769028, 300167487, 1745300631, 1943126607,\n            1065862406, 2422304458, 523765517, 57630113, 520436682, 581485167, 527613705,\n            1677813796, 2698743484, 2448718551, 1681977324, 4183961145, 333724319, 2667028740,\n            3403027352, 1499647517, 2965583197, 1090547876, 1536215624, 3407325498, 1392474450,\n            3354142052, 3326326224, 1138672330, 1577104875, 235932133, 3877789753, 1822119722,\n            305251772, 3802044423, 608489509, 2727503310, 865373313, 3763994776, 3206318655,\n            88097048, 4241064408, 1171067683, 4250936686, 729121178, 763857558, 450636528,\n            2096197907, 1427186250, 1251064262, 3036762405, 2966424923, 880639864, 1995310474,\n            2023015792, 4198637421, 3996151657, 3070092174, 331733799, 2680348059, 2601390369,\n            92920881, 600583651, 1323663334, 4258529164, 2493258032, 3313489774, 2050494797,\n            1494880112, 1342788885, 2493538385, 1096813856, 27701253, 2762164402, 3934044073,\n            2289089808, 721323988, 2246162231, 2514451824, 3095057964, 1921436785, 2847276160,\n            1369952734, 4246781184, 3442030977, 3930627222, 614706399, 3051396564, 3044240928,\n            3450585985, 2120836933, 3006035710, 178202067, 736149219, 623937260, 1958379885,\n            3104814268, 3269365015, 914726129, 2951180538, 3940965189, 1869582492, 2599100173,\n            1009213592, 1410445689, 1179880005, 3583285938, 1921636631, 434725812, 735782942,\n            2548761027, 3733379485, 3466163816, 2455801926, 1673952134, 2422059957, 4005305357,\n            2795894062, 3245947918, 4171997564, 2269244989, 1975479474, 2449387935, 2550893401,\n            4033149, 3723976428, 3871853952, 3210178057, 2062131312, 1434821634, 1130065536,\n            4276609753, 41976415, 968125282, 853099726, 3675357389, 3545982836, 1237895428,\n            88970686, 4259275077,\n        ],\n        &[\n            3428605691, 3747865452, 3179948115, 2350061225, 568002466, 1150456745, 398797276,\n            1289784855, 1713342581, 1243415582, 2262476431, 2640854581, 2126611553, 279688048,\n            1750838292, 4147801215, 1090003542, 3022523567, 193306367, 3095010320, 4106129220,\n            2615828356, 2229875117, 1066352114, 1628397898, 370050060, 4157038478, 3551524420,\n            3356007005, 71309641, 801692593, 3448737794, 2187893878, 3694205688, 3993669226,\n            1704384353, 437976508, 281233142, 3685881986, 557022935, 2623696682, 3473835466,\n            2373703925, 4102552649, 3005124737, 1604665678, 2894612216, 113726438, 326916434,\n            2354584210, 2207672568, 1272863868, 1643657755, 453968751, 3873638645, 2388412558,\n            2026577065, 3555348237, 2342844423, 564662317, 3301275728, 2205414701, 1980322846,\n            2111846734, 3351655044, 3986317737, 3746472405, 4065813457, 3783710419, 2063617629,\n            3337397526, 396000532, 1367889075, 3493608147, 3502046919, 4063752078, 2026966957,\n            1730343114, 1889308216, 2064908820, 1350757250, 953211432, 3171180512, 3683852864,\n            2865517189, 9728788, 4075807873, 230559850, 3447666295, 3875782338, 2964025959,\n            3279832060, 1701408562, 1524777719, 2018628821, 877683542, 2894422993, 2842238026,\n            2368190181, 2574790540, 3301078931, 519264490, 2640226714, 1382986517, 2712031077,\n            1268830384, 2018243821, 1374899410, 1932087493, 4236194373, 2079152365, 1069353434,\n            2794047491, 3019576051, 1360117274, 3615353679, 3816194597, 563906666, 1827758233,\n            3391740972, 4039283822, 474920421, 602146150, 3520459365, 2217822485, 1815675107,\n            1257332805, 101198736, 3156910259, 1281759597, 2577040428, 1316988841, 790502779,\n            2183328888, 3514409721, 3117638288, 2751392867, 625199304, 4183171081, 810287943,\n            199775540, 2896399552, 1276626819, 3536203521, 3977249862, 1553852925, 1596788767,\n            4199876212, 4164476281, 1700598937, 4111801568, 897035781, 3318378574, 4049506305,\n            2522517679, 2296942227, 91515126, 2738354614, 3444113221, 776723413, 2322159108,\n            258188842, 4014626824, 2677530556, 2630906411, 2348643583, 2619411399, 1783064149,\n            3684137491, 4249816060, 2342260236, 4186117248, 3931377058, 283592002, 2818946531,\n            2155019855, 1212182985, 937681548, 520081464, 1686760025, 4003314294, 120323668,\n            3282730481, 1331500167, 2103184161, 453960707, 3079516933, 4193898972, 279508919,\n            2459211929, 4262295127, 1413249938, 2652447340, 1521334653, 3641279725, 1047788888,\n            2569690437, 3517124875, 527659101, 950373677, 562851515, 3518587604, 2668894245,\n            2265163836, 2975852422, 3168107907, 3219343979, 3364338005, 4122186542, 3517854206,\n            626303838, 201513242, 4042863292, 4203206994, 154681851, 1046188872, 1014035958,\n            1565481708, 783475007, 1419399714, 1439418252, 3671223860, 338436030, 2221870804,\n            275182251, 790279697, 3288665213, 3033639795, 2320556485, 1648356934, 326278183,\n            429784181, 104482651, 1051376296, 3823684587, 3057907898, 4214146560, 2770254088,\n            2132180852, 515232230, 3723417512, 3994583184, 1170935740, 565152109, 1486190861,\n            2906472005, 3154973145, 1571950735, 1391459913, 2972445791, 1670706254, 2522911431,\n            2665886703, 2875123532, 623767904, 1291947264, 3935970871, 2500309617, 3931020115,\n            3436644927, 3672390796, 2307254280,\n        ],\n    );\n    test(\n        &[\n            386353625, 2283334827, 253851108, 4279287864, 2561872983, 1000131216, 216965099,\n            1733322743, 3814906874, 520558483, 2573981410, 3011109093, 1361665859, 2981910167,\n            2501833654, 2673979284, 2696912361, 797890797, 97183495, 2324611911, 3471887001,\n            1013155374, 524729310, 3971281568, 2873934524, 1076401482, 1645093822, 423739674,\n            3400177353, 3716049850, 2858905860, 3351077705, 1478568656, 3370413874, 3966773377,\n            1660817988, 3770638166, 698194415, 92466505, 399941585, 3301477423, 2578917060,\n            3012966571, 1915213695, 3062576400, 2979801504, 3838450560, 975685759, 3154985631,\n            1986911427, 3559636850, 2134674515, 3128102806, 1097660929, 1212690783, 3611467219,\n            1232001761, 904465835, 671601217, 2829397960, 3910014855, 2035732477, 3262086074,\n            3077756473, 1064556527, 3095006074, 436186642, 3844079107, 2798261317, 3470373096,\n            218408908, 4184804463, 2826021777, 1939569756, 1452808097, 1149547097, 316749819,\n            1631475409, 4023391942, 513096309, 3730431754, 3391919570, 4153138767, 1328779762,\n            3015228258, 2487205968, 213982794, 1927310263, 897606115,\n        ],\n        &[\n            133654450, 371159391, 40768202, 2113895976, 2732923987, 3215138425, 2391931662,\n            2672734577, 195120416, 939150931, 1941696822, 2919872876, 2564539452, 3080820908,\n            2846583634, 3349568397, 3465385329, 3550405793, 1724556069, 151917586, 3772273289,\n            4156003461, 2380288065, 356475766, 4123619567, 1619017859, 3739529130, 490749645,\n            267879469, 2890847693, 3854244893, 3384266657, 115723042, 103663103, 267682519,\n            965965574, 1841386548, 2476428873, 6965648, 3347378817, 4174270937, 911558590,\n            1958087705, 1467103561, 1925556384, 607664404, 2051263137, 3092553737, 3239342455,\n            1360744647, 331798903, 938411111, 3063265275, 4144610940, 624250586,\n        ],\n        &[\n            3712980585, 4273305215, 2588121912, 1482202110, 247010829, 2649827458, 2673293530,\n            50266420, 3870816552,\n        ],\n        &[\n            3140142351, 3638334268, 927590030, 3257445174, 190628332, 423978494, 2125526010,\n            2335881748, 2011775260,\n        ],\n    );\n    test(\n        &[\n            3451729766, 1173985848, 93029266, 2489920009, 3973680219, 780152687, 1953113811,\n            856318718, 3314090115, 2569865885, 10849561, 743853677, 1946859719, 3063924404,\n            3352045106, 101532091, 429420318, 3158186124, 1342100634, 1680882573, 4042659776,\n            565667221, 989688746, 4541446, 834463803, 3523014310, 3432977627, 1818084880,\n            3544409611, 1926948225, 3663387900, 1035293697, 285923430, 3096314023, 664014848,\n            2054069437, 3124990832, 115905130, 1379323203, 2244054884, 2012040660, 1620087465,\n            1907788850, 132467852, 3020885577, 238576412, 567018667, 3426013542, 3145012002,\n            2070201540, 1421424259, 2074360440, 810615969, 153078550, 825376847, 2436604908,\n            1365021492, 288298963, 3753461462, 4215347696, 514661745, 3484458912, 4247537127,\n            1579462876, 3865189996, 1018915575, 2974009562, 3501816358, 2821759336, 2722697353,\n            517866351, 632193686, 1959130106, 2570573609, 3726681184, 1695074321, 1803440017,\n            268435105, 2059636298, 1870796488, 3616705235, 779907146, 3840642834, 3690603635,\n            889240128, 4220497978, 1506894274, 3744062951, 3031958651, 4062058444, 2309758423,\n            1411665710, 1638698058, 1784343146, 373693019, 3239595939, 1656022725, 1985062241,\n            2188775097, 395478226, 2732514978, 2804731752, 4294707867, 2796289890, 4286815139,\n            2694259304, 3400027223, 2866208426, 712658287, 3005677674, 3799280383, 333964254,\n            426632823, 1071506508, 424615774, 1216913008, 1528084851, 2440789637, 8647650,\n            1482353199, 1079815951, 1741478231, 335212928, 3230225069, 812456049, 1107265661,\n            309740350, 39813940, 1038050523, 3708554333, 2276389162, 3145208114, 286364489,\n            2078653938, 2343246544, 761958231, 2400118006, 2820784413, 91083352, 868359282,\n            2976918690, 1899156995, 2927253740, 2971404198, 955553520, 2163090892, 1779162381,\n            3706789234, 1427323973, 2892945053, 3765307938, 1888304940, 4281185143, 4063224403,\n            3895821018, 292451283, 1315405597, 1278053061, 2659048964, 1651475603, 2464063324,\n            2470117886, 885060568, 2223396118, 983203622, 2153273837, 909540554, 11662729,\n            1290088356, 3558268851, 2470462290, 3816443571, 1219777270, 1663771088, 2059674235,\n            3741754207, 918293007, 1170814255, 2592844500, 34078497, 868179007, 2916133370,\n            224466504, 1457353443, 743181292, 2045016399, 4268051489, 2582113750, 108054210,\n            1045580699, 1021681246, 4287699909, 2442965928, 2358040249, 2188665290, 2493816549,\n            1868457202, 1538714165, 3141445884, 1886427078, 2413842865, 3754082182, 1242353411,\n            837326189, 1891378866, 2004934119, 2718308820, 1293740965, 3706050263, 660923758,\n            4037329521, 1659464686, 3767070633, 2733667846, 1303579884, 720201259, 4178102594,\n            1521257108, 3676354960, 2861869547, 1694835235, 1663377877, 1033893232, 1788049008,\n            2131980496, 1380320795, 1706971693, 1547085187, 4249747381, 4022331904, 3773862935,\n            186851005, 1122661765, 2869769810, 714482846, 122240297, 1990969517, 1505355345,\n            1418846887, 2157766299, 3944099174, 752193837, 2717991695, 3106584127, 2176113460,\n            2424010054, 2202537322, 735567917, 2635174646, 57167007, 1501943516, 3981020168,\n            2264071537, 1811387936, 3230232665, 2056500724, 2470649052, 298208196, 361093257,\n            837772742,\n        ],\n        &[\n            3759203346, 4116788486, 472182301, 1657732406, 1379670583, 1302865697, 694415200,\n            281678172, 1654699562, 3014506006, 1741431230, 3860463155, 1145719988, 3566676616,\n            2320845102, 2321995000, 536415919, 2387437419, 3567575351, 89009414, 1112333426,\n            3147195251, 3149954561, 1503279897, 3064049622, 172526224, 3226367243, 4252316042,\n            2985921401, 3319920602, 2971463135, 662010514, 2716903751, 3114900209, 4294888231,\n            2302528059, 2985636330, 4227410510, 523042380, 1128527265, 2237860860, 2902190407,\n            2028066064, 43980114, 85965472, 1423570354, 370469915, 2799642260, 678694776,\n            4007712353, 1236341524, 2105667795, 1513858354, 3031596159, 3550734930, 4152331215,\n            778814882, 736616127, 1334786757, 193672910, 4005017476, 49451649, 274162308,\n            193472860, 3849716547, 1147344616, 3779102036, 636364760, 49841072, 4203872775,\n            2917594088, 2516158563, 1718950767, 2409600701, 4112139783, 968713133, 2367692503,\n            1383637739, 1447827357, 70112330, 1597216524, 1036612170, 47442040, 3535655506,\n            3217988958, 1524147015, 1542229372, 4278993048, 1177373055, 2455939135, 3977288741,\n            2323766505, 2631150922, 2494146789, 1766908673, 2014027584, 3170299898, 2200469205,\n            447095672, 3553741345, 1471247393, 1705231371, 3597764506, 2179927417, 2057038135,\n            2877684583, 4157842671, 3988568107, 136943619, 1758053719, 133243005, 1316787143,\n            3912460869, 3007503154, 673776671, 2300353234, 2544200665, 1154464703, 2377559298,\n            2085288775, 570803259, 1718587627, 1887771341, 2141823671, 812587685, 473768462,\n            3537328856, 2051785610, 1867482529, 386483431, 2102139021, 3579998391, 1082229057,\n            4197498026, 2004997074,\n        ],\n        &[3960768807, 1512612890, 3846503597, 4289005374, 3202073567, 4260281911, 4219386150],\n        &[1749675900, 83311145, 2319870768, 2301367900, 1271820700, 747192890, 2232034578],\n    );\n    test(\n        &[\n            1444823481, 1895962470, 1145820971, 951685031, 1619286897, 645659681, 3225126137,\n            1237595037, 528204561, 3332610202, 2935828481, 3511627759, 3794280700, 504366468,\n            2867551534, 432130908, 1682537913, 2112976328, 291513836, 2849031909, 3326433036,\n            1925364297, 3779561553, 487877982, 435659240, 1540143453, 3711236017, 1440132082,\n            825660149, 1624471959, 1941539144,\n        ],\n        &[\n            110690520, 2114031203, 436730283, 2624140005, 3364550071, 806172129, 2495686202,\n            3508099340, 1915440069, 3196245075, 3757278096, 786923263, 1820433641, 3283619351,\n            2326488762, 119217121, 3545365539, 3063896557, 1866040341, 3325517573, 713948948,\n            2863092530, 2356199798, 3131342786, 4122497749, 3637172320, 2586791774, 2794104974,\n            1738360752, 1591954820, 2633103962, 398797289, 30804220, 2682142316, 1858898375,\n            2406882215, 999588447, 645011646, 3469603876, 3657151690, 2477958807, 286833025,\n            1802487901, 2709688493, 2318425877, 3516543869,\n        ],\n        &[\n            3866576925, 1873138890, 1768109056, 2705255084, 4241776445, 658244374, 286815054,\n            153522406, 2020517918, 87408861, 541283899, 2327698817, 696800449, 1357243166,\n            2373189783,\n        ],\n        &[\n            1748815118, 2402822363, 2091637344, 2074482742, 2316188658, 2370992052, 3607116276,\n            2077769165, 1723590682, 2807481888, 338472032, 1807369086, 4009280963, 3941733223,\n            1094544382,\n        ],\n    );\n    test(\n        &[0; 7],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        &[0, 0, 0, 1, 0, 0x80000000],\n        &[0, 0, 0, 0xfffffff9, u32::MAX, 0x7fffffff],\n    );\n    test(\n        &[\n            2516900350, 3628420684, 45459239, 1513614219, 989392388, 453507217, 1512254264,\n            2426221826, 1233076550, 244898124, 2764583004, 3329101881, 1699874673, 3208045667,\n            2210327365, 948719692, 29636434, 309163724, 626642377, 3476255186, 2213282765,\n            3561515942, 4189534597, 950518908, 139348404, 1259661856, 694161725, 2634491186,\n            3727710582, 788362676, 3045474119, 4091304988, 2805201294, 3987583308, 1169494314,\n            1793738933, 1926962859, 143323906, 3767356737, 2736821279, 3155234958, 369913573,\n            2104538395, 1964464892, 120182245, 1607533355, 3512159772, 428709975, 3273911427,\n            1151542509, 2860816013, 1136173381, 662332459, 3578077057, 3243603823, 818341966,\n            1912641848, 3483224197, 605429894, 746864868, 3712846888, 2818736253, 462940792,\n            3732576280, 1660947800, 1011233610, 843846147, 2308498613, 1878649446, 1442264468,\n            2962205673, 2832862233, 1244894861, 1156622958, 1582973750, 1574948490, 3846938629,\n            935089728, 1705244040, 4043433438, 3114254174, 1062986960, 3905677705, 1930766407,\n            1354562200, 955778452, 2932639939, 249007379, 3763599833, 32702674, 3759419411,\n            4281057196, 1688108074, 3861261668, 444663411, 2875533494, 971084229, 1671724356,\n            681694042, 1336342690, 3989885039, 3351736702, 3656186109, 2518436399, 3272921467,\n            235621572, 641659042, 2119882595, 1983842751, 1488017726, 3187465143, 2506358055,\n            3348535321, 999852594, 4293611527, 1073384603, 250481194, 4148825621, 3839501948,\n            3818994640, 1414056232, 2701465891, 499495991, 1361504858, 1308748876, 1650859371,\n            3722040369, 223548436, 2431095012, 3829963049, 367284736, 451104830, 3192609374,\n            959276880, 2266256342, 4176815348, 3580491737, 674113379, 4084740134, 883805748,\n            892822580, 2297912891, 2348080766, 3777075710, 2743249275, 1929349295, 2464988855,\n            1327032420, 1398791640, 2085211945, 889984414, 883598216, 1429348413, 154972877,\n            3622910749, 1670306325, 2187005411, 651154286, 2688016708, 1041316505, 2776658464,\n            161390395, 3846865057, 3267383835, 1010302540, 3607316170, 1418199870, 3954492322,\n            922710287, 1323651551, 2431904946, 3054195005, 902509698, 1670133092, 1092971517,\n            1075109776,\n        ],\n        &[\n            1426636939, 2291732338, 3067548371, 1958595483, 4265832187, 1189668824, 2839754982,\n            3301139255, 530760593, 3029188645, 1298922175, 1055363550, 2070850046, 992858009,\n            1206997984, 1510007185, 2204463849, 2600547912, 3402640587, 372285673, 54684613,\n            211924658, 2690037178, 1114469505, 374316665, 319939537, 1363579227, 25099128,\n            2808696886, 2318162131, 1283473588, 4173665536, 1302236115, 2981103428, 364658024,\n            3500679214, 73401477, 2399140443, 2401409782, 974668784, 3260945138, 700031094,\n            619920306, 2267288646, 225106679, 2520705554, 760523499, 2971006600, 2155228491,\n            967349835, 2899641188, 2567983244, 1086821788, 208644014, 2327565301, 3873773388,\n            1254243651, 3371628757, 1486945462, 3153661571, 3596439034, 3448680976, 2884772533,\n            2113693162, 3571562346, 3271064301, 2352298427, 2624271304, 2147301202, 1628031526,\n            2268489536, 2460058239, 3824853526, 1114448457, 1711950597, 2805133745, 3886047152,\n            1482425544, 3015333985, 1726209429, 1945238011, 2536476005, 1974758758, 3373425305,\n            2797746190, 1649833243, 2549697741, 2772403629, 1276934258, 1197267921, 480328120,\n            3145095762, 647795990, 605209910, 1896440782, 2021024361, 4280085434, 384535302,\n            228210377, 1342562609, 550195641, 304643910, 803682708, 2640613597, 214734489,\n            3610647775, 3787633026, 3169459037, 2718345417, 1486978425, 4213419405, 2452166506,\n            2369416903, 2146131022, 3632701374, 857903632, 2077812289, 2633196639, 1727541399,\n            1445819648, 1663740433, 2573746586, 150961985, 2843003920, 2121435332, 503235641,\n            2162411412, 2641993335, 2306838455, 3013627797, 187911601, 2832638744, 3245525711,\n            4114681913, 4248626985, 892023341, 4180070411, 462293938, 2339665566, 886499165,\n            2680618581, 1275413281, 1653569893, 3506841220, 805196234, 2798162194, 2468871331,\n            3396930973, 2515921922, 897743120, 2034157178, 2373161268, 3355723218, 3914014661,\n            994426990, 2992401161, 2581503631, 697892172, 82419160, 2053001658, 3320533046,\n            3791389127, 1839288008, 270908689, 1413534997, 429338594, 997502210, 3103236226,\n            2401510054, 2663896427, 3727426794, 2724686279, 3944143754,\n        ],\n        &[\n            3845376373, 2532376922, 273377135, 3677509657, 2349096840, 865593650, 3913447585,\n            3605798835, 2383627001, 256434907, 1598943794, 582857664, 2095029213, 493203050,\n            4072709797, 2373943493, 3435129133, 3493851471, 1582101091, 2328189763, 853133742,\n            2400321806, 3544763029, 3255311766, 2487877428, 2345846021, 3540974504, 1867377852,\n            2499885368, 3386759756, 3964579463, 3290899719, 2797957335, 2863338106, 3380325251,\n            1361967176, 2820693326, 1270065483, 2316076985, 20080038, 2796142674, 1493193006,\n            3582143536, 1315905237, 884491638, 2352205614, 3522766470, 1928358187, 1698951621,\n            4079830723, 3210021170, 3465329392, 3919799352, 4222905913, 255999498, 707431500,\n            4259794201, 604859264, 3884712299, 2790776367, 3466495862, 1352500875, 1421557254,\n            3449668508, 339288181, 2600471637, 2364459698, 1593691125, 3908068568, 1590428078,\n            3967743945, 361284513, 1947639764, 2146594709, 698658216, 2934691142, 3852641925,\n            2677524346, 3136105113, 3755616420, 393422782, 4055467971, 836734774, 1342622278,\n            1842869702, 3646198604, 3250586544, 1155965487, 3143510276, 264136749, 764849704,\n            2833843864, 3628999351, 1603529516, 3414178524, 2241268229, 1653241000, 3792840587,\n        ],\n        &[\n            2033854275, 3346500754, 1026391195, 2931755468, 4132970223, 507488150, 3787819697,\n            4267307150, 2229023955, 3535124792, 2115982537, 3261552465, 1403786253, 4168838966,\n            2905077003, 3343366362, 4058434477, 3051762274, 2754465216, 2139644668, 2121257326,\n            147231635, 1411313351, 1942773925, 1518792733, 4026871852, 1608765600, 2674641821,\n            3388658059, 4045496133, 4161170911, 1328400056, 1288717066, 741487928, 2130937044,\n            3073981280, 486422437, 2174741216, 4004413829, 1284627600, 1179437164, 1177246499,\n            2634583310, 2950709339, 3500520165, 502702338, 3556716680, 3168781392, 201139498,\n            1773610178, 1336109110, 75169920, 4261358748, 3946913462, 1177416531, 1904421971,\n            529501654, 760059661, 2718436151, 1695275660, 769729199, 1160292778, 1476806846,\n            913674448, 1863234151, 2549859956, 2693241338, 2672780028, 1641057282, 3939169714,\n            1414934690, 318354912, 300864018, 400872379, 1081977009, 3047385148, 3103660917,\n            175274494, 1331622900, 1558233166, 3851938640, 205628404, 992837552, 615234521,\n            3588694980, 848421132, 513268312, 468730797, 1030322804, 1991013271, 1629772980,\n            3351179781, 2259742484, 957712992, 1217297297, 2285959262, 947300257, 3115413281,\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_divide_and_conquer_fail_1() {\n    let ds = &[3, 4, 5, 6, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_mod_divide_and_conquer(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_divide_and_conquer_fail_2() {\n    let ds = &[3, 4, 5, 6, 7, 0x80000000];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_mod_divide_and_conquer(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8], ds, d_inv);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_divide_and_conquer_fail_3() {\n    let ds = &[3, 4, 5, 6, 7, 8];\n    let d_inv = limbs_two_limb_inverse_helper(ds[ds.len() - 1], ds[ds.len() - 2]);\n    limbs_mod_divide_and_conquer(&mut [10; 4], &mut [1, 2, 3, 4, 5, 6, 7, 8, 9], ds, d_inv);\n}\n\nfn verify_limbs_mod_2(rs_in: &[Limb], ns: &[Limb], ds: &[Limb], rs_out: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let d_len = ds.len();\n    let expected_r = n % &d;\n    let r = Natural::from_limbs_asc(&rs_out[..d_len]);\n    assert_eq!(r, expected_r);\n    assert_eq!(&rs_in[d_len..], &rs_out[d_len..]);\n    assert!(r < d);\n}\n\n#[test]\nfn test_limbs_mod_barrett() {\n    let test = |qs_in: &[Limb], rs_in: &[Limb], ns: &[Limb], ds: &[Limb], rs_out: &[Limb]| {\n        let mut qs = qs_in.to_vec();\n        let mut rs = rs_in.to_vec();\n        let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n        limbs_mod_barrett(&mut qs, &mut rs, ns, ds, &mut scratch);\n        assert_eq!(rs, rs_out);\n        verify_limbs_mod_2(rs_in, ns, ds, &rs);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        test(\n            &[10, 10],\n            &[10, 10, 10],\n            &[1, 2, 3],\n            &[1, 0x80000000],\n            &[0xfffffffb, 1, 10],\n        );\n        test(\n            &[\n                3347432287, 667250836, 2974407817, 429996943, 2750501459, 981155607, 2784121354,\n                3415523349, 1074478768, 1820977205, 231390348, 1372589414, 2069009514, 2430571486,\n                1857553253, 1536218533, 3666738280, 3477095993, 1509486443, 3092180985, 1588218081,\n                2448257324, 672729993, 2374023188, 2913701567, 2541072953, 762935357, 1333399576,\n                2676378567, 2962748936, 744662462, 1379794240, 2290146289, 4080012384, 2739115667,\n                701035190, 4208500661, 2190862255, 3061320303, 3853993751, 2324138270, 2878407932,\n                3552024846, 3816909905, 3815506441, 1255343574, 1901570312, 91219029, 1399539132,\n                3118241152, 3325617992, 2881339798, 2520199899, 3667594206, 1853889834, 866669545,\n                4104229459, 2070282300, 1484152931, 3098893530, 358952500, 2164190448, 4138312509,\n                727032566, 2750086730, 3119399990, 1390731909,\n            ],\n            &[\n                1037101017, 1727794380, 1490452070, 1098486148, 4011045557, 2946764072, 697788893,\n                2534857680, 3261736561, 2991036431, 3203952375, 678147993, 1718071908, 1324397528,\n                3227412704, 2808109049, 2498489092, 1483895999, 1974627636, 774482390, 1844543122,\n                3947438938, 1357670917, 3021715202, 2044056785, 26339702, 2002972036, 2442219903,\n                3581261805, 291932047, 3070844846, 1561991523, 2591235485, 4062653222, 432295028,\n                3024980126, 3174836607, 1645982854, 968272899, 3101889669, 3996099656, 1637081358,\n                2998072999, 2235890151, 553838585, 1688691976, 4092350095, 2065416776, 3709647283,\n                1072755910, 2385936305, 2615766642, 136864038, 757727106, 2199116578, 2066024664,\n                3784388877, 896467499, 298040025, 315565009, 4174702765, 3225704704, 23210826,\n                2346706257, 1990744556, 2040289114, 1584842987, 1498510914, 2668413122, 2503096531,\n                2005961409, 2272795985, 394426800, 2285275525, 2471642108, 2784697818, 1258928804,\n                151106578, 3449120105, 169880528, 3307735530, 1735274873, 1875100806, 2033402873,\n                1707359177, 2748179285, 3611534985, 3379681783, 1722155183, 1210860589, 1583939074,\n                1413313200, 1958033089, 1382323587, 3321046184, 2567768608, 2706224116, 1925292443,\n                486456966, 33556563, 4003036360, 624876701, 2847313485, 3451353450, 3432337713,\n                1567344163, 2879538252, 624051431, 1206504435, 3713613381, 1062990555, 498008949,\n                1798769609, 3937669287, 4147083150, 2479873449, 1454286408, 665997230, 331654711,\n                1482116196, 2545259161, 1591656626, 904758973, 1600224317, 3734588228, 2386781283,\n                4212676921, 1479533912, 2157734799, 3588439224,\n            ],\n            &[\n                3380102021, 2452922302, 1962966574, 3357220828, 3890634007, 1037328979, 1799391942,\n                1004666291, 3982464365, 4257152024, 187444313, 3439720141, 1266693503, 724678963,\n                3437259008, 1572104078, 4039559445, 3285865736, 3569601379, 1308348984, 1718729371,\n                284719758, 444404442, 4151851178, 2692003849, 1055982587, 4035467383, 3921915216,\n                3487944745, 1817447325, 1542763265, 3937726417, 2223825009, 1394339428, 1214099970,\n                4192217805, 3753293552, 3811191236, 706896668, 1075933013, 3658129436, 156288657,\n                1259909922, 1889374713, 2941065257, 81950085, 649933990, 3336906952, 2183193381,\n                1175410937, 2580459452, 3904196981, 2723001189, 1789637716, 2009908016, 3170700121,\n                18873175, 2237687603, 1424198121, 980763182, 1043721413, 1070004656, 3240828354,\n                1874904174, 1859325685, 914946875, 3171367435, 891888508, 94557928, 2528939804,\n                1026794028, 412407977, 1504097351, 2321903212, 4049474173, 2376576188, 2102495452,\n                1976457360, 2692728936, 3130170922, 2123163736, 3537525633, 1557920518, 2628772698,\n                453031939, 451448604, 2142259, 3310964267, 2745320950, 2734144127, 3699687158,\n                784837860, 1503636827, 811700689, 582299446, 2429787592, 1210273821, 2702547973,\n                2699574096, 3370153605, 1236597584, 1088015704, 2939670102, 165924895, 18853284,\n                3700200624, 3220442711, 2965715000, 1488424876, 3464105223, 217616508, 315230760,\n                1429465794, 1372241659, 4248780864, 767395681, 4105247821, 1532652179, 2100932260,\n                2674903482, 484464190, 3609058420, 1471559178, 4122200129, 4198439348, 1623393770,\n                4254969136, 2270601790, 4239377868, 588832613, 2695326914, 1952240370, 2369526722,\n                669955508, 1561380904, 1661607015, 491163324, 4063133286, 339180970, 1218080293,\n                2858927543, 2211268294, 4242441810, 4166777931, 459461625, 2722830085, 1984526624,\n                2371328931, 3795073119, 313183280, 3291949415, 1843511154, 809173981, 3006056205,\n                3286577997, 74654418, 3553288229, 2169290280, 151023939, 1586116459, 3040308252,\n                4142315068, 2646953656, 4225002928, 4051564438, 1032308582, 4166856711,\n            ],\n            &[\n                2427812263, 4051563058, 1632406385, 3107965286, 2723923069, 1032718410, 1300669246,\n                1686783039, 2900234860, 381961320, 3860838802, 3653570244, 1848772343, 2404802446,\n                17732494, 2990806772, 1910668969, 3421521828, 1829199569, 2997918403, 3557175274,\n                3519619382, 740250212, 998547797, 140767728, 1892932539, 668118324, 497299250,\n                937663333, 2612689662, 4010699478, 389960621, 3786256383, 1395295829, 1276717484,\n                1869006600, 2093853956, 1555847120, 101097965, 231988325, 1792259822, 29327628,\n                408838665, 3646864419, 2451151869, 3859710466, 2245716151, 2883931737, 1198282734,\n                2659505911, 354206954, 3482662941, 3212522494, 4106878300, 1901956875, 645864641,\n                1078147214, 1797412778, 3856838800, 2428567766, 662568175, 698243503, 4146493635,\n                150220967, 3723014797, 1944885174, 2282033009, 3395489773, 473095209, 3085161317,\n                2999589203, 3878818308, 1223719023, 352990164, 249223561, 4143029861, 2622703186,\n                796827870, 1054862138, 677020780, 1289629518, 3449239587, 3541454564, 3311081075,\n                583050818, 491332673, 1997521794, 627632367, 2864835203, 2880916227, 233376741,\n                1067584403, 2454677969, 4048829167, 2955413920, 651548741, 1667224967, 659069317,\n                4019573675, 3305249558, 3965166031, 2657374006, 1899323245, 2478966232, 2865170658,\n                819362488, 2414458118, 203150817, 3555808793, 3366944226,\n            ],\n            &[\n                2882761542, 785407498, 1124133487, 572386909, 1169675686, 3567625455, 4199715839,\n                3851396630, 3274146684, 3477301663, 3302596192, 1480559142, 100842294, 3530609196,\n                4086393700, 1190308308, 4263459677, 1142007717, 2247036858, 4120633014, 2294603452,\n                2399429000, 2624162280, 1454610696, 270143073, 3957844361, 3046891288, 1549007386,\n                233535161, 3109659080, 209449866, 498073310, 2626910641, 195499996, 3976787267,\n                3922992490, 349292363, 3307104635, 365992265, 4190381097, 3755383481, 2478897620,\n                1546723896, 4001998632, 1128630761, 2676599750, 2475921888, 3233603626, 1483504432,\n                2551193799, 3557144097, 313815765, 1349744193, 1374844288, 2400211342, 2986607421,\n                3195157472, 1299836347, 1861689827, 742292964, 2823852296, 448143737, 1667945403,\n                633976860, 2902355589, 2157443145, 243118113, 2840619921, 2919500120, 2742747945,\n                845926917, 220468159, 1355718767, 2330428847, 3717678284, 1787470596, 2523167223,\n                2214932965, 2055827539, 27888400, 2211687684, 526284755, 994343204, 904008663,\n                487598580, 2347713123, 3532282785, 3549720901, 2459046510, 338578128, 1168895967,\n                3291681132, 3787087696, 1555047248, 894667165, 1085939503, 4100902874, 309142266,\n                1088553857, 2096128611, 1104848719, 3907470805, 3414980158, 3260046959, 2704772147,\n                288217831, 1781865616, 179692408, 1428188291, 2562193479, 1062990555, 498008949,\n                1798769609, 3937669287, 4147083150, 2479873449, 1454286408, 665997230, 331654711,\n                1482116196, 2545259161, 1591656626, 904758973, 1600224317, 3734588228, 2386781283,\n                4212676921, 1479533912, 2157734799, 3588439224,\n            ],\n        );\n        test(\n            &mut [10, 10],\n            &mut [10, 10],\n            &[0, 0, 0, 1],\n            &[1, 0x80000000],\n            &[1, 0x7ffffffe],\n        );\n        test(\n            &mut [10; 3],\n            &mut [10, 10],\n            &[0; 5],\n            &[0, 0x80000000],\n            &[0, 0],\n        );\n        test(\n            &mut [10; 125],\n            &mut [10; 405],\n            &[\n                2824467771, 3299124311, 2818671068, 3680778570, 981687343, 2406693669, 659467593,\n                2993414243, 45406089, 1478779191, 1711786852, 1750419133, 2909274013, 511107722,\n                3561218251, 1136025710, 993075881, 3516743656, 2114794292, 1997914, 3812643652,\n                2505455342, 1465178283, 1978590884, 2983823507, 1628362808, 1695987706, 2508198478,\n                518693670, 835288758, 1012607974, 749782274, 577737644, 2333209317, 4167594129,\n                2270730042, 3116080031, 2989072664, 3700594452, 2080277190, 1740782490, 2022893854,\n                2980102855, 751636825, 3922671264, 3391149880, 614930929, 120867901, 2567507861,\n                1524427749, 2580678371, 2199894921, 1776614185, 1166041925, 1079838738, 110556090,\n                2831653230, 2555307604, 1415160216, 250952335, 1727168666, 4114643415, 3895205129,\n                692242739, 1888273350, 3407947612, 2500185766, 2392325992, 454908683, 1510488259,\n                627605677, 2579656597, 503296566, 732883994, 1804534661, 1024632105, 2582676903,\n                2186193446, 2035546222, 1537608294, 2871563506, 1842379464, 4285710796, 1145782664,\n                2168389602, 2821015070, 3799000303, 1910989354, 2712163170, 2373188937, 94374379,\n                745462864, 1273218817, 599427865, 3025428597, 4170147632, 654664457, 999597566,\n                1301587861, 785951171, 1404519917, 226625774, 114784173, 1303174335, 1991080402,\n                953508169, 2955695351, 4272100018, 4152229685, 505603829, 1367830508, 275280730,\n                1743334800, 136640107, 543638242, 2867205034, 3205072197, 122133232, 2907110177,\n                2577983454, 4044792269, 1426164254, 3391219052, 4077004042, 60445643, 361888880,\n                1370511290, 4140611, 1545574856, 337863511, 2696753299, 882513095, 2220102704,\n                4040224968, 3895008884, 3144563393, 2298197836, 2781817257, 1704369652, 3931316078,\n                315544063, 3497851423, 3664143565, 952326443, 3938628137, 2331019960,\n            ],\n            &[\n                3222658839, 1719980949, 49002116, 576454969, 2480526346, 4090562449, 3826526799,\n                1957153338, 2225171960, 2687643162, 708981609, 3176715792, 2962973059, 2652817195,\n                1197341180, 2939993186, 3554367730, 1570613844, 2536409086, 499280456, 3247067732,\n                1595825640, 2368929206, 663346056, 3132360609, 1474802683, 2339072148, 2202454503,\n                3728785029, 3203437738, 904057293, 3413710811, 2642403758, 3344563036, 4027597111,\n                1888090288, 1863907782, 2464957062, 2688706102, 569142547, 397802070, 245946780,\n                3489512252, 2617239243, 779718731, 179625066, 4023449096, 3996006819, 953561942,\n                1127504598, 1992436862, 3073123794, 1835220635, 3142367806, 3159289192, 1927251431,\n                2830198394, 910503635, 2897643083, 2932878381, 1507827586, 3067247947, 885528755,\n                2017570727, 3134837176, 499511463, 1535166690, 1643153113, 2968177930, 3952804609,\n                3989699184, 256167900, 567717900, 3896800262, 2310644620, 2351013373, 1964719080,\n                1905779649, 3311747907, 1340733718, 2870734940, 3144732377, 1107086597, 3017452910,\n                32224803, 2995638379, 1782145516, 3064028223, 405412838, 4063680301, 3415165225,\n                1788170832, 3805938672, 1902801261, 2231309030, 1810036873, 3470233158, 2413346472,\n                3530489706, 110880408, 887205258, 3604865827, 2857625992, 3018122209, 2631997677,\n                1125977084, 2461114861, 2161802286, 273825728, 2086061888, 541221199, 1806844610,\n                1376732414, 3802142465, 3535151037, 2954021790, 2116798495, 3735046347, 1186632354,\n                2833281426, 3457883657, 3962766016, 13814577, 1650009216, 4147309188, 2302630822,\n                3980940746, 4258997501,\n            ],\n            &[\n                671156763, 3522970087, 1803674928, 705095332, 2537912304, 2452859779, 3450873050,\n                2679364048, 3526396093, 4177976105, 266611217, 1151557614, 2132817166, 3877142811,\n                507210298, 2972523503, 3073806840, 3566048488, 880991998, 3345680417, 3235170656,\n                2403723979, 1313154315, 2771932402, 1330267204, 3414255915, 1179382708, 3233207082,\n                2503609750, 249317411, 2632726993, 130324620, 2032071659, 3005726146, 3875282024,\n                887247870, 1998016163, 4254819443, 3740865454, 3553274754, 2446121384, 3275444724,\n                233325872, 539446483, 1087952312, 1835245616, 3627109091, 2510529404, 185630261,\n                3706778570, 3098183261, 1931085512, 798171652, 3040444481, 1161846676, 1038636293,\n                3421904104, 2901743603, 300733872, 3719079820, 3468813384, 2881344572, 2125343174,\n                1936937822, 598427076, 1712995528, 4084208860, 3733468538, 1669487237, 1385196430,\n                4053752992, 3005943092, 2525935674, 282240792, 4279794411, 4125983631, 2329629976,\n                2704369810, 1464421682, 1313908108, 1226002425, 1808406752, 3275768064, 3175836384,\n                931684775, 589156533, 3002460872, 2667576199, 1619914000, 3662683434, 3389418364,\n                772131109, 3768421507, 3396906380, 2736076174, 2900071166, 538472464, 373492649,\n                1143475222, 591038056, 3736209846, 856338986, 232250025, 3427987228, 159577157,\n                485970599, 624042727, 2427226926, 758605639, 309500365, 1623348751, 4085018849,\n                1073894303, 3272403714, 3990448709, 1089031712, 1648217954, 1406121363, 1462876615,\n                1399073841, 3264088864, 3357032142, 1754184006, 598504776, 2188603491, 1888083714,\n                2827226198, 3414026126, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 115],\n            &[10; 1254],\n            &[\n                2401497277, 3741262706, 691871239, 1949640889, 266070694, 3295242537, 3037066187,\n                3875417448, 1358853731, 4158125741, 737486219, 2625351318, 2205206855, 501024225,\n                2060376077, 1953521053, 3762056723, 163485007, 769999701, 2385831686, 2388009068,\n                3120433785, 609866149, 1014929431, 4255522153, 3908104955, 1296186549, 1400337892,\n                2481196402, 1530226708, 1736756203, 4267671814, 3181376526, 4204274026, 2772982826,\n                171341955, 3239339748, 83269891, 2325049318, 746305994, 1290717192, 1805639230,\n                1856363646, 3445599715, 1388597950, 2699498310, 246990054, 1396771726, 265087723,\n                3372840761, 3260397695, 2010115470, 2211074582, 1883962263, 256363687, 4012920099,\n                2367091978, 1485341992, 1836339208, 1434180757, 2616877872, 1145425491, 1261399773,\n                3926766027, 3115015865, 1741783714, 3802513218, 4081750672, 3856503286, 2137512595,\n                1192985123, 1863041957, 700637154, 2503934926, 2021744810, 157763047, 453501781,\n                1898727251, 3741166728, 105996483, 3390681922, 1127471458, 4229032301, 254843851,\n                2729237155, 1707011850, 1756734415, 1864969309, 96539023, 220456923, 3061776324,\n                1741151628, 1199010536, 2099212259, 3095715999, 1369052975, 2575251120, 1821995904,\n                4169452262, 3299830336, 666854626, 3647011057, 3965571435, 1551218489, 726151433,\n                1730753749, 750433250, 2084548637, 475638490, 3209308986, 1536371286, 3458731894,\n                451976715, 1463077982, 3275775647, 1176722184, 946473888, 295088963, 1154092407,\n                103838303, 3743650178, 4149308777, 1617840168, 3465913339, 4133656500, 186966677,\n                1624567957, 3264214229, 1285455678, 3951367256, 1685500601, 2890483019, 3692192743,\n                503129144, 3972113270, 2472468030, 3386552094, 520995657, 318761291, 3652507947,\n                876136924, 451086694, 2855321222, 557040372, 805677163, 2526778273, 2320694361,\n                1256424719, 1952008095, 4056766614, 4133706458, 3948099450, 343436346, 4192911370,\n                284826582, 674589589, 2186532130, 3868256489, 3551620239, 3301954255, 1174676675,\n                603478538, 275555563, 2405977791, 1847784099, 896249737, 2255526478, 1787445221,\n                239988612, 1297053793, 4022115314, 3399153034, 1717528213, 1660404772, 3074772866,\n                2806710693, 1643510791, 3184377187, 1540838982, 134943412, 4022881239, 1840380980,\n                3861497294, 2510066751, 1433230269, 2045075002, 2415627101, 1223566402, 3367143819,\n                612631145, 1154322627, 3247079704, 1778868389, 272795417, 933297265, 3458460741,\n                1389431679, 2907745644, 2086192882, 2684128325, 2650239535, 1784197442, 3949401651,\n                1783533373, 4288056634, 888203755, 437001866, 1407050668, 3135687315, 3463879635,\n                1702062054, 1204976730, 4177166610, 739673691, 2277342971, 3478834440, 4081300483,\n                914246861, 2121339885, 1961961557, 92095006, 2260302382, 2461228008, 3993959318,\n                2950464602, 1950783601, 1224172324, 2576903297, 576707684, 4125788986, 2560012161,\n                1956729376, 1629575657, 4036954933, 300086502, 4022406600, 3237472700, 1646970397,\n                2062807673, 1759249491, 1956866526, 2025198625, 1297980907, 2709447351, 3977405586,\n                3105592010, 4167079730, 2234262082, 3282437095, 3492171389,\n            ],\n            &[\n                414354569, 1366704839, 3104154714, 3052961192, 1917209478, 527538773, 96279538,\n                131392026, 2197344782, 2544900655, 3721689046, 1511768113, 2703760155, 1445726112,\n                1858496576, 1575565932, 3793123807, 1385830602, 411844037, 2236175811, 573323765,\n                2565409615, 2461667516, 3785284514, 4260465727, 3052818977, 1895970970, 3792821387,\n                4109605593, 1615504561, 3239716852, 1706559703, 3187779838, 3278892149, 3231274931,\n                4198044737, 1513165468, 245082668, 1270047387, 3396787938, 1940745611, 3740768753,\n                2072323188, 285189880, 644016853, 3495689253, 1168360917, 2400702434, 984958722,\n                222994595, 3006232190, 2064852513, 2152929014, 1163603446, 3191172136, 1835493220,\n                3277922296, 3636603619, 1531000264, 3057499684, 3823394467, 2647235938, 1717867123,\n                499456838, 4094707383, 2454454468, 3671059285, 3201191048, 2439390676, 3022007460,\n                4061878398, 4243531226, 3389689292, 558186288, 3777835601, 3123712634, 3503180938,\n                3691679764, 1701324443, 835309072, 3906212426, 4049064285, 1768153688, 2228746280,\n                3594304220, 2961136397, 213262897, 80889120, 4109164941, 1704207190, 149603550,\n                4140450876, 835389387, 2885880052, 439529491, 1516869648, 2050960198, 926155485,\n                475035022, 1187115633, 894340078, 343754206, 3955497730, 1344991704, 598758584,\n                4056958135, 2153619389, 2541228501, 3084209032, 689848357, 1722405264, 3359713626,\n                1572612273, 740065643, 1582253391, 4070651569, 1908850964, 495396647, 4057999777,\n                3077955309, 4157175191, 2258556901, 2113839, 3880102604, 2790333280, 2943303426,\n                3912791781, 4284145483, 1840413180, 3097912758, 1064553745, 1126983800, 2256085399,\n                2448922218, 981100464, 266358012, 1971087790, 1988527723, 237308225, 1936681335,\n                4258331432, 1348277821, 529864588, 2497818319, 4244738664, 564460927, 1832999941,\n                65438986, 1185234412, 1316363591, 1608606945, 1000964619, 1732529786, 527797972,\n                150140396, 2156815817, 4220448391, 1051855867, 4280728484, 1058663428, 4250194724,\n                1036504424, 3657621656, 189944192, 57605355, 3072751931, 752978294, 1461890065,\n                2724185615, 141061473, 1466705961, 304569847, 2188875717, 617186800, 3058558545,\n                1591798676, 88078245, 623288082, 132838333, 1534710499, 2200810995, 2857112538,\n                3863089059, 3060974440, 16773497, 1918012630, 3327340967, 3661341852, 2395761457,\n                1535964139, 746843178, 4060399981, 4287382590, 1336021602, 1599090737, 1174816250,\n                481099617, 918021470, 1173582832, 1368734491, 888221269, 510154884, 1262941262,\n                2567813829, 1077623012, 2261930141, 2307570205, 2069365574, 3586190102, 1698424580,\n                615530592, 4037104804, 1283475105, 4214495193, 3288288012, 3585802470, 261207221,\n                3506861813, 1536248070, 3151134123, 645179327, 490399820, 2479385864, 3709733877,\n                396138285, 2627168580, 4028642442, 2012757271, 1884810033, 4051927252, 2652348818,\n                2069059332, 2416554871, 28369250, 1321756354, 3314148643, 2588326180, 3141604522,\n                1974534297, 4170320959, 2683069809, 1278314467, 312763173, 1481522722, 2846196729,\n            ],\n            &[\n                3521949631, 142488398, 2558755806, 546733190, 2792635139, 1330279357, 3430917364,\n                206259042, 1647608238, 3662226174, 2677354502, 501681320, 3339919968, 736768019,\n                4258570929, 4202792087, 1651152858, 415339868, 1437647081, 1371825040, 1535867295,\n                1113678172, 4268196599, 2619516870, 4117420686, 2491883937, 1711537149, 3681498741,\n                487272454, 3249094136, 2833249206, 1984417080, 608254353, 2280645468, 3395986408,\n                3532393236, 285299266, 249977069, 1222542802, 1102282847, 2598354195, 439643199,\n                2126654464, 607909799, 2936741523, 3763227596, 4235714917, 1698786602, 1862433691,\n                2965568505, 2196568398, 3068583313, 2467355500, 2575639252, 3699104542, 1440347634,\n                2202871610, 1085633678, 2985993155, 1566387171, 2653399887, 3340197769, 2614511546,\n                565555655, 4058797643, 1841325854, 671657716, 560998985, 334170781, 85067287,\n                1935383603, 3452109092, 3454188157, 154367468, 3636444053, 3436201211, 2489786062,\n                1247734460, 4255062573, 1485745449, 2725636745, 3754874076, 4135899179, 2423709040,\n                392644331, 2072210265, 339068725, 3933463273, 4288485419, 4212008073, 3733609991,\n                4120877958, 1466616375, 2958829060, 83050688, 4089523843, 2719660596, 3345635470,\n                4218331277, 176804352, 2942885054, 1103429906, 1232548981, 3336211973, 2320933704,\n                2354076844, 2529582693, 3959342251, 1769056129, 3021361560, 1001511651, 766365010,\n                303546733, 2838329868, 696771802, 2198903959, 3831700812, 4192525926, 2867372730,\n                3200189248, 2637281548, 3606733360, 2672897488, 2624221199, 1766256987, 3059086417,\n                3482969658, 2697305862, 415920845, 1575345078, 931452186, 2064246173, 3556532318,\n                1127897667, 4176776745, 1103206019, 759429637, 3840446634, 2669415208, 4098858695,\n                3968696636, 474286523, 3603742455, 3683233930, 3910949095, 1016216353, 1693878242,\n                2936976170, 2258461087, 1543964790, 1257134506, 2705742284, 619723369, 2313052342,\n                1916338183, 3578695856, 2388468521, 1417556272, 2630850792, 2327790132, 3594026023,\n                1659979016, 477242076, 1948563308, 2803059042, 2392360966, 2007275313, 272222339,\n                264018609, 1147760126, 4131679216, 833601075, 1429546506, 3426172207, 1125974375,\n                3584187622, 1582857679, 1084294484, 2193982331, 3084073169, 892928835, 2823566821,\n                3544239939, 172135078, 2430777811, 1620416268, 1792703584, 2899867927, 3974701277,\n                1890638601, 3367278100, 4278027820, 3171315428, 3696212814, 1038269559, 2729624661,\n                173005716, 3652244541, 724827867, 3530325019, 2203073321, 2587791340, 1909841295,\n                1412031121, 1429200221, 3614105795, 3265396657, 1362525000, 1906071103, 1060149404,\n                2733619757, 2675449568, 3414488370, 210765135, 2800530139, 3014478492, 3230858260,\n                3409460781, 3411785589, 2543986390, 3934724152, 3235965806, 2053739672, 4085596199,\n                1563589410, 2817526968, 4048637993, 3055675422, 2173262993, 2970495556, 514198452,\n                1591956633, 3852865086, 124440700, 1002712372, 596340824, 3999538417, 117476573,\n                2037586050, 3291573274, 1511567035, 1614566437, 3821078763, 961133253, 2796121934,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[\n                9467139676469209549,\n                590281264913108801,\n                2444597864339828042,\n                14864081623018167053,\n                17247631583397892818,\n                14553244820490552393,\n                12829855212365838534,\n                3531466761266135925,\n                11372171159031384620,\n                5870847048926628622,\n                9193240591510160396,\n                4025304033900694645,\n                17261252553070218810,\n                1960954339685170046,\n                9689788042403522315,\n                6777781555383721706,\n                564338697137211139,\n                2236230241770389317,\n                7260612298284603217,\n                7551831827404764167,\n                14240930170717885933,\n                5403113159439788814,\n                11890192816726889700,\n                4571074562843162754,\n                6585174915018781919,\n                16820621164336832115,\n                2906428786044704407,\n                14549789283221663094,\n                8574533295629171239,\n                2554371108614275803,\n                12102140726062325305,\n                5927759880327312421,\n                1947106727211751169,\n                4243634376196439953,\n                3958901784387088795,\n                11997496505606868854,\n                8614259227764305665,\n                2851316343853334425,\n                7360014330841540867,\n                12833167596911644967,\n                16420023392297553774,\n                448987443751486030,\n                1127916262354476550,\n                998365641524414747,\n                771182118275428982,\n                3644906482543632509,\n                12008471662501141232,\n                6735530311778854203,\n                14937996347189247818,\n                10310266533399488799,\n                14173112110010990829,\n                10048196983951682150,\n                7660343487007291390,\n                5442254482173747309,\n                11894682918116055490,\n                555474340707057713,\n                5454210195350763050,\n                6335921756850263208,\n                11125242160747149811,\n                5950900297278200050,\n                4972887779003626968,\n                15099558014605218082,\n                8070946285642924813,\n                5661924633602804698,\n                4017981546647826153,\n                3298784914124356106,\n                1048634509662954303,\n            ],\n            &[\n                1601810336850541391,\n                6414377018375174391,\n                919960012376992260,\n                7432535796251013733,\n                14687204344100976419,\n                4239980047441451729,\n                3419961342059496953,\n                16241811836659790563,\n                582511433240649668,\n                246415310737356671,\n                4213289580820322712,\n                6570486144808547472,\n                649071692625916450,\n                16246395526862594705,\n                5418002168615819323,\n                8787804720479728592,\n                16606257073152622475,\n                1410262373214068670,\n                2846556520446018460,\n                12702224195603835801,\n                14824788470038136235,\n                8070823597295684045,\n                10064047777457825217,\n                12473928276513608352,\n                4502242984490214594,\n                8213242804638977717,\n                11407293275124988149,\n                15303970978422100227,\n                5734015081210218763,\n                6780255848655226189,\n                5308681743121306497,\n                3590094480707706491,\n                924657275311967241,\n                13313245703725306506,\n                13755314570936606477,\n                1722612846595274627,\n                11310713460998976321,\n                17860713973992950196,\n                4832972642835413575,\n                6159638888337886550,\n                16436259186156623772,\n                8219825892743153908,\n                12825816757113080127,\n                17576561025816321316,\n                16426316569762062979,\n                7041069634919241163,\n                14958139263401063299,\n                8541928253694453091,\n                14623281385826596559,\n                5881920493887697974,\n                2856125878289959548,\n                13138961086309035424,\n                1445182795958550281,\n                989371283719803801,\n                14414401959190662319,\n                12694741659414145902,\n                4944169755440522083,\n                4850330269090259826,\n                7263731888738583042,\n                3847985956261979907,\n                10886313908655224591,\n                16884924304355496352,\n                17434369248195376612,\n                9624045826924140661,\n                9440358242723121635,\n                44413621672380228,\n                14501853932445164832,\n                4412509400967439905,\n                4059150452772511000,\n                14121559478607349396,\n                6939247432141568945,\n                9144772592231287902,\n                9035665952014395555,\n                14897716038428818227,\n                15076823799682351749,\n                16277606343067785741,\n                1901372957955104636,\n                9089098420745572372,\n                7424125507905187829,\n                12368330388186365917,\n                12778631331588513256,\n                7648700244963873530,\n                3776028467270636181,\n                16107369772612157292,\n                9046543866366629415,\n                13251838453492673272,\n                2975138303374961664,\n                2462966081502544324,\n                814917744063498594,\n                13005222969141014201,\n                5026855542811222762,\n                2382391535955253463,\n                5899528506680208740,\n                13336141787604226636,\n                2972106516856532181,\n                14045206722662122716,\n                13361481863470745757,\n                1303122885509130861,\n                2127042842590220699,\n                6185514996199626930,\n                16622745329653187578,\n                1256533115604594696,\n                11243434057073050028,\n                9066405370642929758,\n                4552716624777987017,\n                1128092841571320177,\n                3756894170446405064,\n                3328979948330012406,\n                15049042231988504879,\n                3530903968533512703,\n                17905884378428276079,\n                3713606437359152813,\n                9370125751473669209,\n                10012381228375856292,\n                6916709082927033810,\n                17606888822444197359,\n                10818646898854586102,\n                9927520028322801489,\n                17015575684851383261,\n                15287563104761130407,\n                4246630569287612899,\n                6737522138244324583,\n                16956805675707509108,\n                10507692348129622148,\n                1144006384258648355,\n                4260138925314579646,\n                14508270375905482517,\n                3559046762122289814,\n                15199903498605585717,\n                16432575538338639756,\n            ],\n            &[\n                5592822181652430458,\n                17506309594623475426,\n                14050063092843436505,\n                7714948654849123602,\n                12960251261153655218,\n                12293354553127881932,\n                18236552269356335752,\n                8116592444680865353,\n                5788148289215893900,\n                8971586422059718981,\n                7830225577778842728,\n                16542468928391674395,\n                7685364916096821326,\n                10621040870461365797,\n                13017786142160529410,\n                15623634767986429431,\n                3570280230795725028,\n                5462496964935066825,\n                13096782281304038571,\n                1028538565298248606,\n                1306240401949593430,\n                9752885768751332733,\n                16834186448734276157,\n                7637206024963845142,\n                14347989823115406647,\n                11694534965309339857,\n                17506164867360865472,\n                18226657528377127028,\n                17113377911080849277,\n                12836900580850373696,\n                7624296086468816307,\n                3241150049341673184,\n                11432625191496196476,\n                7201112746916642381,\n                14159401858377741999,\n                13042389876849434472,\n                6539044773109830458,\n                5626612565019858620,\n                16855355146181557220,\n                2896027096805100269,\n                1749121842377065409,\n                14486576285464434664,\n                13003134176160772443,\n                4520736241988979615,\n                14386190542886985088,\n                5203873393963986621,\n                2767011034432552285,\n                6993214728799607735,\n                16219726698174042484,\n                12883752315794694947,\n                4638588568194864850,\n                13671093412063473486,\n                16507766724668892429,\n                508640878850638089,\n                10821378407060575406,\n                7345992160360704865,\n                10043908069076742056,\n                18320857698273010360,\n                2218460838923946432,\n                12515547441597943704,\n                8373193888106171069,\n                11138535537637434655,\n                2449630875466873477,\n                8767699022869197665,\n                6446940169111329267,\n                12481583138381941451,\n                18405856492243480913,\n                8856983257605794349,\n                11977198292403090397,\n                4992072464455161558,\n                1429124422280954077,\n                16695629052720642207,\n                15320583853113777709,\n                9270873446273846783,\n                9544568698292818385,\n                16150036388405871492,\n                4707553634577955164,\n                12819651092171657742,\n                6194167822526464289,\n                3302239600303656809,\n                13520149877311082646,\n                3658928982143500918,\n                6938149248133961941,\n                3561482775788486836,\n                11608588618646326460,\n                9312042305619109305,\n                7752033026671842884,\n                17638989744464665362,\n                11720586895422616384,\n                17488161719714908794,\n                14359533380966089634,\n                9112047402314539693,\n                9045007769242360827,\n                14039981061261051366,\n                12161985564133395359,\n                12552005864162233454,\n                13987473146854769743,\n                18218863257920884509,\n                527093394921779615,\n                10809320813728048297,\n                9176568449151735783,\n                16181777654712188911,\n                3708863559833042684,\n                15705373009786311560,\n                12044345266545331965,\n                15745097802473032619,\n                3448641903062070968,\n                7079863925626111888,\n                10936059842602692227,\n                3949990826310278419,\n                8781569794504977516,\n                2710649351206510739,\n                8045244454460377457,\n                16793164706992819994,\n                14171071447733414359,\n                6442975288102390424,\n                13408292761208182437,\n                18190891873633561623,\n                14416452326133420106,\n                11467995109126255854,\n                10355921853391241663,\n                3362337025912778005,\n                12828210017750944427,\n                6724529289281531448,\n                17910365619735459537,\n                18061583666579344364,\n                7385510916096038449,\n                14735084634699542626,\n                2983574817812405387,\n                1160726944282883582,\n                2119364765206141036,\n                6464791768964988391,\n                8824016806539484116,\n                8270030586906660422,\n                15002907845345901548,\n                5776511587881140498,\n                8026215921305305807,\n                4715947225014261487,\n                1386404302622265399,\n                155879991043344208,\n                7029054386547293524,\n                11220489073691424833,\n                2733588115435171341,\n                5063187558440228172,\n                14208382232307280669,\n                3376720278729662133,\n                14690710213721258877,\n                11094816467682244196,\n                13929756812886477086,\n                14698847015580325706,\n                15992372099283576304,\n                5818288394714584003,\n                5038324365106419021,\n                506432342213631013,\n                7781480413773762085,\n                2275557418573742756,\n                8703301345083257514,\n                11424227525030059244,\n                8529590924998378026,\n                5577211436885609271,\n                16859602499387351883,\n                5848360527348246100,\n                2118117857825986323,\n                3178709503818913442,\n                14068618324826971348,\n                7820101807986528976,\n                16849757836429474618,\n            ],\n            &[\n                10900792384749518304,\n                1752565570529908396,\n                3402229115647561238,\n                2472381872242532960,\n                15748089475115162936,\n                1958855681762413475,\n                12100416912810779188,\n                12256578057348862042,\n                6556831077371185734,\n                15914846823057329492,\n                17346954154793811255,\n                17566187606614467459,\n                1433606366066775495,\n                9089332045922722756,\n                10056944581186126460,\n                5324425019386643029,\n                5281765195814058625,\n                1449711238109407238,\n                5903959110668039125,\n                3336955200427408551,\n                751494194154096512,\n                15350321905800137137,\n                12407374450431165353,\n                8705815621686854350,\n                18038286270431178148,\n                11671842546699641930,\n                9343865367071815679,\n                13401838367914321671,\n                18365991333043790435,\n                17428290065100096976,\n                6040216493892400727,\n                4224515713015397505,\n                16578741590625036060,\n                11835373548777581169,\n                18413478850867685366,\n                8453265724386285209,\n                5394500720474148965,\n                1927463313122594080,\n                4177838821929605731,\n                10680620304882583021,\n                180005403771618203,\n                2256408572502279608,\n                11718426532525535626,\n                14260315287467647015,\n                4035759666841010016,\n                16259497729863184485,\n                7772704202422133476,\n                6815813069474359325,\n                11207378575459431371,\n                18308033894506293455,\n                9875145231436590806,\n                15354934628544213986,\n                761822562304640527,\n                7391550101325083295,\n                4023926600201752832,\n                922969942182092752,\n                12110946035817932140,\n                16574399923422896843,\n                7087993004495856759,\n                8299428112066197874,\n                4589434828506762129,\n                13978205413565566735,\n                15675366647238478172,\n                7819770375827015142,\n                6823625407675143456,\n                2042269662440457350,\n                11521115322912473140,\n                13703874674141705702,\n                1295561690992462505,\n                12464082489717915012,\n                11378922861990148970,\n                2076282285705918066,\n                1390689690731346588,\n                13670979351308531000,\n                12980996477862222169,\n                10496970808504864546,\n                14015388605987660396,\n                4171129107047347396,\n                1656857204469415571,\n                17492457435753920912,\n                10132937897450237781,\n                5065601177732655021,\n                17498367701449356268,\n                9552937910825811119,\n                6213399497134928078,\n                12865519292113075754,\n                8548871019474664332,\n                12973212090641168109,\n                3018095992673320728,\n                4102580256148037725,\n                11411505815957245048,\n                8044142604358855954,\n                6163064685377006161,\n                7676133172626151339,\n                15177331097378985405,\n                923128391789363540,\n                8405355494789853124,\n                8409013636286216842,\n                17519952046647436442,\n                12690425880634822079,\n                7295927951214020420,\n                5103171252065286692,\n                4531269626482776566,\n                17509133779966482098,\n                16771567673323510549,\n                9940518318209913958,\n                2566490491730418524,\n                4997841530198583881,\n                11759671980624847072,\n                12804335234851198898,\n            ],\n            &[\n                11770973102809246906,\n                5654064914644075203,\n                14154195031168297145,\n                3196816914765589663,\n                13269534898382935070,\n                6602763211194544985,\n                16018516851544910792,\n                3180625223944165224,\n                5350941027330432714,\n                6398743157953739295,\n                1906167046060045935,\n                3556291732895289080,\n                17581917949159063577,\n                11917842024560925369,\n                5513291200181693371,\n                2805207190711928628,\n                10488935147153720707,\n                9353681503295456349,\n                11923702266366452872,\n                16445534228693736707,\n                1321572029020662220,\n                2088179387423767363,\n                2940575338916006997,\n                5660751381096282465,\n                9379032325552965866,\n                6155754375040762615,\n                17757845483758379498,\n                4791726927249442785,\n                2271154604380575561,\n                2810516188026226067,\n                17085166475121940699,\n                99572451658953140,\n                5696266492111718158,\n                10862208603440047636,\n                17394577092287756526,\n                8594037627948854376,\n                15384378431083587966,\n                8688372331869182594,\n                6898185140759317855,\n                9871173932216986045,\n                12528452101456458662,\n                13557460938391962098,\n                4450262203153213242,\n                9384263431241833822,\n                9013347668307504163,\n                11311595079831956259,\n                936915772753461789,\n                8433063029106192581,\n                16896552532247465449,\n                436920621494623275,\n                17030913520242164150,\n                9892849888317096483,\n                10846215292694646349,\n                8237341484379572099,\n                16094501558496758251,\n                1945916543779639318,\n                18090461816104963907,\n                4146339453090156488,\n                16829166437621172993,\n                3078631608488886297,\n                4439257821416126689,\n                7705380192038328855,\n                3538871580337510846,\n                13746211561839200096,\n                11905905983562326697,\n                13358208869614303744,\n                5843566918809605864,\n                9427926296554685300,\n                14598289187890400060,\n                11008519655031485653,\n                8593121017807548632,\n                9396415039249055836,\n                6268435325877250293,\n                17232661262414298575,\n                72834733148045272,\n                10210620080322964005,\n                4785045324389620807,\n                12743978039683515133,\n                1532018623508178307,\n                1626858325392940984,\n                14509988664710915642,\n                11484970178386722683,\n                9637331423956040786,\n                16727570268905595418,\n                17007646468471636895,\n                11784309337440826435,\n                8264087540904628249,\n                5386650781848750246,\n                2634849477861627672,\n                13571530405202238935,\n                957020390364360749,\n                10551951282480361215,\n                5860903308359481633,\n                7956790956638521305,\n                8737258119314118945,\n                12342128112549159916,\n                16715653993533680030,\n                16954242660912593528,\n                2489318600286989195,\n                7710331526401780284,\n                14799339212986303952,\n                15607538409164651487,\n                16839239842720015730,\n                12565794445330275268,\n                11582072386774199841,\n                7158773820903321984,\n                1329934199003039189,\n                6297267245832566486,\n                6153026408185751289,\n                3259942857823462030,\n                17905884378428276079,\n                3713606437359152813,\n                9370125751473669209,\n                10012381228375856292,\n                6916709082927033810,\n                17606888822444197359,\n                10818646898854586102,\n                9927520028322801489,\n                17015575684851383261,\n                15287563104761130407,\n                4246630569287612899,\n                6737522138244324583,\n                16956805675707509108,\n                10507692348129622148,\n                1144006384258648355,\n                4260138925314579646,\n                14508270375905482517,\n                3559046762122289814,\n                15199903498605585717,\n                16432575538338639756,\n            ],\n        );\n        test(&[0], &[0, 0], &[0, 0, 1], &[0, 0x8000000000000000], &[0, 0]);\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_barrett_fail_1() {\n    let ns = &[1, 2, 3];\n    let ds = &[0x80000000];\n    let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_mod_barrett(&mut [10, 10], &mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_barrett_fail_2() {\n    let ns = &[1, 2];\n    let ds = &[1, 0x80000000];\n    let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_mod_barrett(&mut [10, 10], &mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_barrett_fail_3() {\n    let ns = &[1, 2, 3];\n    let ds = &[1, 2];\n    let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n    limbs_mod_barrett(&mut [10, 10], &mut [10, 10, 10], ns, ds, &mut scratch);\n}\n\n#[test]\nfn test_limbs_mod() {\n    let test = |rs_in: &[Limb], ns: &[Limb], ds: &[Limb], rs_out: &[Limb]| {\n        let mut rs = rs_in.to_vec();\n        limbs_mod_to_out(&mut rs, ns, ds);\n        assert_eq!(rs, rs_out);\n\n        let rs = limbs_mod(ns, ds);\n        let rs_limit = ds.len();\n        assert_eq!(rs, &rs_out[..rs_limit]);\n        assert_eq!(&rs_in[rs_limit..], &rs_out[rs_limit..]);\n\n        verify_limbs_mod_2(rs_in, ns, ds, rs_out);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        let test_only_verify = |rs_in: &[Limb], ns: &[Limb], ds: &[Limb]| {\n            let mut rs = rs_in.to_vec();\n            limbs_mod_to_out(&mut rs, ns, ds);\n            let rs_out_alt = rs;\n\n            let rs = limbs_mod(ns, ds);\n            let rs_limit = ds.len();\n            let mut rs_out = rs_in.to_vec();\n            rs_out[..rs_limit].copy_from_slice(&rs);\n\n            assert_eq!(rs_out, rs_out_alt);\n            verify_limbs_mod_2(rs_in, ns, ds, &rs_out);\n        };\n        test(&[10; 4], &[1, 2], &[3, 4], &[1, 2, 10, 10]);\n        test(&[10; 4], &[1, 2, 3], &[4, 5], &[2576980381, 2, 10, 10]);\n        test(\n            &[10; 4],\n            &[1, 2, 3],\n            &[4, 0x80000000],\n            &[4294967273, 1, 10, 10],\n        );\n        test(&[10; 3], &[0; 3], &[0, 0, 1], &[0; 3]);\n        test(&[10; 3], &[0, 0, 1], &[0, 0, 1], &[0; 3]);\n        test(&[10; 3], &[0; 4], &[0, 0, 1], &[0; 3]);\n        test(&[10; 3], &[0, 0, 1], &[0, 1, 1], &[0, 0, 1]);\n        test(\n            &[10; 30],\n            &[\n                3099176493, 2686179191, 2963763290, 1498905807, 2459138342, 883505904, 186294937,\n                1240988195, 1152000807, 3485254691, 3058980612, 4051918579, 84687528, 3474110821,\n                825051253, 2495113655, 4269053297, 531158278, 2131423786, 735959410, 1116746011,\n                2099249419, 427789428, 2182383446, 3493666451, 2086611578, 2349523902, 1865831092,\n                104597580, 720145483, 1653677313, 2449086005, 1225118075, 1458687427, 2284889737,\n                1178000580, 1204354477, 1109887135, 2302764777, 1833071533, 2749496868, 3989183692,\n                3112262804, 2143914125, 71393498, 3686808425, 568295620, 856601035, 205234115,\n                617861388, 102368116, 561132401, 733711249, 2931194848, 1371887453, 2942553563,\n                977874680, 3567773306, 2225947571, 668306082, 3150218776, 3697051793, 4272816685,\n                2926797142, 2177250555, 2840203688, 51052169, 1663516163, 3085068676, 471736374,\n                3127282104, 1358199856, 250868071, 54398826, 2107868776, 1621910930, 1677400830,\n                20889047, 4180454819, 908186988, 1625301399, 817226551, 4039437379, 261787419,\n                1484678288, 1183594253, 3154399910, 888455895, 1713982625, 2925178936, 2076694919,\n                2288237521, 620657938, 2457761902, 2906110636, 649773865, 1387981473, 1600821385,\n                3512543520, 2803028516, 1584293468, 1443490691, 2589741655, 3170284085, 1902835632,\n                1603116322, 2850443356, 60694796, 779743237, 4006039758, 3272304347, 2442366350,\n                3601524312, 720808564, 3291979084, 1675880280, 4139440559, 3672978467, 3938651783,\n                3257918674, 2077369764, 3027135446, 3940308694, 2533432781, 4105883289, 626796131,\n                608794713, 810463080, 2363401530, 2800065942, 2679046183, 4063827982, 2327835929,\n                522607612, 1660561124, 817356463, 2984129158, 146372510, 4293731514, 2558750639,\n                3948304613, 1448810261, 826590770, 2423032883, 1050524737, 2770168039, 265887860,\n                3353243705, 2674401993, 1496121248, 2053790031, 1863298286, 1068977659, 2875518960,\n                4137037281, 2888534695, 473250405, 3368783492, 3797281057, 132028186, 316202261,\n                381223941, 3366394660, 425124513, 4083952857, 2301832392, 3321645917, 509444341,\n                361894284, 3976042471, 2957832871, 250836826, 1408114735, 1614725824, 4214313885,\n                4081964203, 2663894263, 145380453, 2329325761, 2055092903, 126874014, 1000460254,\n                3910319503, 2561073113, 4231784000, 1042785346, 3511487116, 1270832223, 3456586087,\n                1210528079, 4119713948, 3299598065, 4178946856, 1623358249, 1001721969, 3964704699,\n                4133343553, 2193492316, 407893767, 2484237727, 3782842008, 2959959832, 449539588,\n                2978317444, 4008576738, 3478248618, 98697842, 3986898689, 1622966191, 3594042026,\n                3280563264, 270713233, 3999415188, 401848066, 623805281, 1710411200, 1801291443,\n                640646012, 2283134929, 1043531051,\n            ],\n            &[\n                3120245340, 1558358768, 2311090615, 3377497278, 2047683134, 1453801550, 1974940808,\n                1545066418, 2840151982, 2463969682, 2025473894, 697610529, 906262319,\n            ],\n            &[\n                4239744213, 626950715, 3916878897, 2974637695, 488695410, 1094975104, 2496621051,\n                205419221, 4192241096, 3583664917, 511224033, 2016541230, 718692763, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 215],\n            &[\n                59488434, 3053025912, 3197673861, 28499967, 919132002, 3254889605, 3510992086,\n                4155414397, 1401076337, 3663475665, 3859836963, 838452584, 1714061888, 756807500,\n                721664913, 2122189093, 190377396, 772161692, 337532878, 2801246946, 3347165247,\n                504261973, 4207433768, 3203836949, 1637702776, 3950126612, 3575550053, 630469114,\n                2468674532, 3237190898, 2699368075, 2126693510, 2005217541, 990977199, 211751826,\n                4095342386, 2390539499, 553381774, 1202910267, 3124334908, 3631027545, 3118560130,\n                3505258080, 2533393565, 3897399802, 1644233433, 2966724466, 1228506720, 4266980301,\n                1975806255, 3087455989, 430105567, 2496389669, 2559019944, 1343075842, 515604272,\n                2623722375, 3549762134, 3517683279, 3564893038, 3816995397, 21727446, 2930818039,\n                2672793843, 1589653728, 2917937865, 665591277, 1222288512, 1197537333, 2425822187,\n                3647080994, 3180811677, 3800694132, 4006852228, 1392314914, 1823809919, 3315974102,\n                2004045597, 2557007205, 532899885, 1088861606, 3969820933, 711573681, 3744617855,\n                3618206965, 3834838995, 601286347, 1494520421, 2007503431, 3672534190, 3437739925,\n                3075991743, 1108097829, 438830502, 854842946, 798336207, 2497251014, 985928236,\n                1930130581, 260199427, 3446617597,\n            ],\n            &[4005818469, 1809723722],\n            &[\n                1137651599, 55996911, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 178],\n            &[\n                3300759985, 47489222, 1596412201, 3681499224, 721942549, 2798268772, 1725678834,\n                1018213306, 278963757, 2162182910, 4238919550, 1480123217, 3550714331, 2714414047,\n                1584331762, 3790545549, 2452172382, 3823866136, 3793112677,\n            ],\n            &[\n                2532879920, 749327979, 378994598, 3512427187, 1768486327, 874381062, 3750599339,\n                1824619676, 4102262081, 3872688397, 4080392661, 1233784995, 3967512105, 536874,\n                1334357500, 533131065, 3802334171, 2688028352,\n            ],\n            &[\n                687097313, 233246948, 2670005176, 2918696316, 2059690051, 3559547370, 982825692,\n                2828616847, 3397764024, 1640472335, 1827782800, 239756415, 4169556349, 1129911247,\n                2514993175, 2469589340, 3137350801, 1512435665, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 6],\n            &[1, 2, 3, 4, 5, 6, 7, 8, 9],\n            &[3, 4, 5, 6, 7, 0x80000000],\n            &[718, 910, 1080, 1286, 1492, 2147483434],\n        );\n        test(\n            &[10; 4],\n            &[0, 0, 0, 3, u32::MAX, 0x80000000],\n            &[3, 4, u32::MAX, 0x80000000],\n            &[3, 4, 0xfffffffc, 0x7fffffff],\n        );\n        test(\n            &[10; 10],\n            &[500160962, 3482059973, 3833374734, 2382534866, 7345183],\n            &[1962915382, 2761901894, 931109938],\n            &[3497463394, 501014622, 297308821, 10, 10, 10, 10, 10, 10, 10],\n        );\n        test(\n            &[10; 20],\n            &[\n                3406830026, 653096149, 665840651, 3475733215, 2990001405, 3962996135, 1125790437,\n                510807273, 2268497988, 3801098676, 4251717337, 4009243500, 3093915781, 2221063229,\n                1145961534, 1520950302, 4156341537, 4051749345, 1887697916, 2938053362, 1317017771,\n                2551451381, 1165783725, 1692722530,\n            ],\n            &[\n                757200076, 1850648953, 1310285965, 43796838, 2811750593, 2350568971, 1162649579,\n                3588922014, 843685186, 327689313, 822131258, 632127361, 4287259347, 855554137,\n                2978907761, 2140676852,\n            ],\n            &[\n                1472562202, 467285767, 3874015352, 3774608073, 3547803297, 3252310888, 379016022,\n                3915526178, 172347662, 1424794357, 2354655682, 1763403834, 1622341466, 1527845266,\n                321699454, 1968063162, 10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 3],\n            &[3156053040, 2869923590, 2300216426, 1369503],\n            &[177914576, 1102898054, 1547778],\n            &[0, 0, 0],\n        );\n        test(\n            &[10; 255],\n            &[\n                4077004042, 60445643, 361888880, 1370511290, 4140611, 1545574856, 337863511,\n                2696753299, 882513095, 2220102704, 4040224968, 3895008884, 3144563393, 2298197836,\n                2781817257, 1704369652, 3931316078, 315544063, 3497851423, 3664143565, 952326443,\n                3938628137, 2331019960, 3709840874, 886597817, 2718223965, 2271519236, 1069952925,\n                2973484971, 694036791, 3948658826, 1091836994, 3976014345, 2590014773, 1030558914,\n                3050284515, 4064531951, 227487465, 1614818201, 2853653798, 312516670, 1131265287,\n                1079324522, 2790732553, 2857570668, 2459258033, 3676592728, 1861660079, 3846516218,\n                2487383610, 820186200, 670229005, 795815915, 4236865449, 388462685, 3530199852,\n                4067109237, 228011739, 3243897206, 2102622551, 3066279582, 2307396469, 3918457987,\n                3177100158, 1165801255, 3470877002, 730654273, 225744395, 303984647, 71923315,\n                2631641933, 642193977, 214491076, 4083126324, 1300818039, 3145270519, 3071074628,\n                533164498, 2260983885, 2398373112, 2291850622, 2549903002, 2876921663, 2087750942,\n                3012568578, 2072377257, 2300996389, 1724754966, 3663537905, 2452259556, 681943280,\n                495483009, 1806854180, 2022877157, 3545541285, 3155213185, 1520127898, 881038528,\n                2682219847, 2061051159, 4091777429, 2973569703, 2243163157, 3812478845, 2868568231,\n                538252316, 915738068, 3645567840, 557499318, 586868707, 334386881, 1009292772,\n                9683309, 1394382805, 1469121902, 3538152891, 192398621, 3298083372, 291538032,\n                454155529, 3467440904, 107593274, 2581455983, 4068643130, 1289926312, 2620830750,\n                3599696168, 845286964, 93649777, 211929373, 405469122, 2046160625, 4269019707,\n                3153165259, 3273675158, 740768718, 1724953971, 4107531497, 3669145824, 2308427932,\n                4057339865, 30691770, 4215434099, 2209368084, 3410096812, 3930010459, 4058257897,\n                1401228000, 3205298856, 919645629, 1080800085, 3531478127, 4244298042, 1920158944,\n                4150416695, 2942997287, 621554087, 2193963845, 3535984780, 1948458592, 1237268195,\n                4059838770, 4178023707, 2225635923, 1078133440, 1904752780, 1129557671, 2721601376,\n                3991770285, 2491529378, 2424674576, 4164361438, 1566434777, 3112804218, 2185237562,\n                2557399204, 967876237, 2243639679, 2436745635, 2376273731, 3848434966, 1970386149,\n                294413738, 1420657192, 694358663, 647017168, 4094657777, 3013362236, 590143693,\n                2285757920, 2393504081, 116938458, 891518480, 696284131, 2710811430, 3317562620,\n                1647436225, 1605219555, 3358343198, 2183786684, 1105785201, 248367120, 1398964063,\n                3309346508, 3273593185, 2032930327, 2675472140, 557577078, 692086759, 1588022257,\n                1734092444, 927029618, 3696557822, 3370092072, 2151067302, 2650483754, 3670460764,\n                2763985465, 1126450086, 3029345718, 1504895755, 3694166108, 578785502, 294874178,\n                110079616, 1327583117, 2661938072, 2345632606, 3722933355, 656745495, 671269721,\n                2346516327, 1169529001, 4238866211, 949351039, 3500460463, 4199863511, 2082398726,\n                1281275042, 2560151133, 1138051905, 468589983, 727511715, 2554428159, 2014177155,\n                3346720979, 1317583392, 1714879892, 4249909774, 2158352329, 3040382616, 964600510,\n                319055149, 890296957, 2071841867, 2811829970, 3945344817, 4075668231, 1336582250,\n                1632615222, 2996499016, 1247703908, 2161089989, 1757474064, 1957983140, 2427088146,\n                3819098678, 1414774317, 1685786700, 2842967660, 2434489739, 2748571761, 2393986575,\n                585646425, 733271380, 4096908487, 866235842, 1811304066, 2337315068, 4064326552,\n                2517677609, 595634311, 929413085, 2556167349, 2814648343, 3447175234, 4171314821,\n                3354462286, 2190450759, 3693163187, 817168953, 753817804, 2679932775, 2584000650,\n                511478235, 2858863655, 2320104001, 2367392444, 1724096919, 1152655320, 3131579385,\n                2076635048, 3557452129, 3931367674, 1011051727, 3910860016, 3742755232, 3977120817,\n                178461096, 1938068862, 1480470517, 2997286985, 196403685, 3581556360, 3800228840,\n                2583177118, 3801520456, 1254931401, 3392702841, 1046934176, 412728369, 2864978525,\n                970771733, 672204372, 1528132877, 2673063996, 740759188, 1840165684, 1821213771,\n                3111387733, 2386566079, 2682984985, 808050061, 4160818440, 1656303941, 2884647798,\n                3997066586, 3727980283, 4181671626, 2736389654, 1808865173, 1642983278, 875419327,\n                3960909969, 3751011271, 2807559080, 1535615269, 2321637137, 2745054513, 3020092780,\n                1359015906, 2466514344, 591997660, 2754906030, 3487658632, 3722637404, 1613546148,\n                915678357, 1842708127, 701921987, 1207101857, 1974760740, 2410755764, 3324705651,\n                3105821672, 335929431, 1887715703, 4035171395, 2815003797, 3632947325, 3664189665,\n                2211203246, 1473602679, 3802261181, 3699100807, 3964975584, 2757250875, 3240191191,\n                3824907808, 1582581356, 116402974, 2321914135, 933007824, 136161346, 2857937718,\n                1044097090, 477414473, 3966936277, 21169877, 2518410639, 1938987054, 4164953085,\n                3287593768, 96004465, 3316812094, 2635456314, 2931969475, 3535012794, 3954299175,\n                4188146823, 1054040153, 4020697192, 3043463112, 487456176, 1536604607, 2191156801,\n                2869189759, 650124563, 54254415, 910946976, 3240585021, 4240104628, 989174439,\n                3235043341, 607641178, 2910679971, 4072297259, 2664931864, 2560203429, 3992282762,\n                480443057, 3944140064, 1601223002, 3984987075, 3894479377, 1082591102, 2444518988,\n                2566734417, 1272094512, 2581007089, 3838472665, 2810473520, 1590808097, 143027202,\n                1667662742, 3686892725, 228309572, 4091365295, 1107025920, 938240502, 567559985,\n                2237721627, 1939039548, 3053102548, 3379831217, 3536253061, 1586694963, 931323468,\n                593457460, 1981974171, 443146100, 11888347, 2403661012, 2646485528, 528884126,\n                1040587284, 2828170682, 512577110, 3534338212, 1642316111, 124785841,\n            ],\n            &[\n                3924577409, 3801138880, 2554871927, 1797946680, 1773117295, 3509783608, 281892096,\n                2358224613, 4217828194, 1339769957, 439570060, 3151617679, 1384372613, 4141908033,\n                3034076248, 201556707, 1940999750, 1134129834, 1062995144, 3653931665, 1653789920,\n                2219526834, 849219893, 3448402897, 890163003, 378127096, 3324725657, 2858888153,\n                4101277783, 1736762052, 4083759525, 1398269743, 946713296, 1332088349, 1241448676,\n                820326205, 1554372778, 2902257209, 2531752530, 593903741, 283370156, 1184475111,\n                4048000423, 3262885223, 3065903568, 2181798675, 970937186, 2831985588, 3318099557,\n                125775489, 2602810229, 1265835529, 370295842, 3885440035, 332195328, 803805465,\n                2339766805, 3074827324, 176637217, 2717782694, 3228882886, 2079180306, 1985828369,\n                1451458086, 2647399511, 653380804, 2816232893, 580123271, 1284828784, 1488365849,\n                3992136885, 1712696753, 3200712671, 4019248351, 2502831049, 3353947366, 3805407296,\n                3975182552, 1255379188, 3079539536, 2754826248, 2654365805, 1932758080, 2018940849,\n                3987435655, 2107608701, 1979416324, 2553264951, 2332482333, 3854067399, 7383141,\n                2032883058, 209316404, 1509786266, 891329562, 2446773803, 981357189, 289424276,\n                1563495883, 1124421740, 4019623418, 229810471, 1293459273, 685378813, 763089605,\n                543868756, 4294383498, 4256223402, 3521141578, 1300426165, 4203249157, 2446225842,\n                3483103616, 2930204118, 3459214772, 2242535858, 2845721016, 2523036196, 1191008269,\n                1438983871, 1990994626, 1369473842, 3325530252, 2436280648, 3247037040, 1827745637,\n                1440370214, 565710731, 918521819, 3174181412, 2021188910, 1292274207, 3161583133,\n                1940037031, 1320244184, 1944735324, 1624924970, 1914256377, 1558283566, 1557557944,\n                819014915, 3477749819, 2317549528, 1815788616, 3410581584, 865672422, 3902451420,\n                47231850, 2052078859, 2128580726, 2861615294, 2875806926, 2504678981, 2922243612,\n                2567002225, 3176460060, 3501319351, 256937154, 986867411, 2877370533, 3829593455,\n                169449010, 1762966206, 126552381, 3303194639, 437611604, 2065984359, 215674808,\n                2549495983, 226202732, 19733282, 265226462, 732006741, 2011526642, 2592527346,\n                3141322109, 980881336, 4085884669, 2038689570, 3704380296, 1688979285, 1869912321,\n                1472588169, 3395855158, 2409096192, 2603014340, 2571643809, 1244430574, 2331499515,\n                234553812, 3949996932, 1906820531, 1849149876, 4204335779, 1113287279, 1165814564,\n                3834491692, 3992932111, 1545656810, 1251393152,\n            ],\n            &[\n                1301325451, 2202463531, 827674839, 2990077551, 3515177881, 1362651403, 481136630,\n                3397298241, 3518449263, 76128572, 4225087952, 1094548681, 282440964, 1243437992,\n                2536206935, 1312305087, 2350135248, 1191467757, 772049416, 1651785710, 13757971,\n                4177684085, 4225218737, 3829973687, 4224488792, 835349925, 807373018, 2003072240,\n                1998180420, 1893011542, 2772647530, 1845722545, 3927750947, 1582656468, 3929302887,\n                2309901890, 2219253077, 74452907, 3721812597, 3102504646, 1837697683, 4169869788,\n                1109227870, 1893389948, 1637025892, 401123956, 2362840033, 3249816285, 1331916977,\n                11330013, 1790389738, 4046514714, 4242300773, 386281183, 4154390602, 2907471583,\n                596332521, 1031920105, 1416982457, 936732589, 620289351, 2021344934, 4134683536,\n                254271151, 3153428294, 2775130118, 767392350, 1524517878, 1803212363, 1935475282,\n                476597337, 1665283842, 385826494, 1418089792, 1583155781, 904332458, 2167494919,\n                4213977373, 2749948942, 1366862995, 974249813, 2151831423, 2426239456, 4154619782,\n                1909704093, 82889380, 1836307000, 1860128761, 2497608852, 302875545, 2512570768,\n                3465381901, 3664521586, 2113690348, 3208498261, 211553098, 1122435807, 3989762258,\n                1790955068, 1274985561, 801567833, 206607829, 1945509947, 2689438654, 630881630,\n                3166357111, 950757161, 2525660644, 2782583030, 2082925684, 4017471838, 2770389652,\n                3152723497, 2730012549, 375610667, 331640140, 3189394626, 1169047456, 1269402316,\n                366259196, 659129976, 1835642575, 1109092533, 1409510258, 1055228915, 3865844484,\n                1951513725, 1561115766, 1535328235, 566121235, 1218990885, 2397023975, 110038834,\n                410651474, 2293988363, 1341825237, 3049031992, 1068909343, 3433095008, 226980250,\n                234888265, 3753182189, 712474545, 3392300015, 358854770, 2053632965, 2314494072,\n                3270641699, 1763895670, 4027033942, 3610557903, 1952033954, 3311300088, 2108677074,\n                2293958755, 649449413, 1137877459, 1632674803, 3368118971, 4027363661, 3533599056,\n                4112294692, 1992613374, 2157460184, 2344709644, 3126961604, 3915648450, 163946806,\n                3452706048, 3278493797, 3569418312, 619110361, 1791108219, 53432167, 1675611199,\n                3468608269, 3380246190, 3977636639, 2303818017, 2959386722, 4259696814, 2826759181,\n                1786462977, 974733518, 2879253522, 3102475706, 2731858652, 2537398244, 2096104946,\n                3000514581, 821433471, 3175348116, 2836803346, 3386301193, 400757797, 3528093517,\n                689295706, 494008951, 3664544857, 1053036864, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 1098],\n            &[\n                1563750116, 2761722522, 2234492700, 664378669, 2289696554, 166287485, 476834844,\n                2920420087, 2528304999, 1938173917, 3950825207, 4243596790, 2986888741, 3513584208,\n                1621935302, 3010962100, 97331004, 3497602837, 3156993605, 4246943277, 3773399914,\n                1791046376, 1330596670, 2066725731, 3080890361, 1411737887, 1547876370, 3080590448,\n                1532248923, 1435492412, 3448185497, 1125870178, 3236487585, 411921826, 2813696973,\n                3217407722, 3223519146, 3065092232, 2369951103, 2509352358, 926337125, 3014682136,\n                2966028824, 1505359010, 1713762975, 4092602064, 637732943, 1302647295, 2902550792,\n                889992967, 3865589903, 1419953312, 9792449, 3415320263, 564771153, 1688162383,\n                2484779041, 309493832, 218454065, 3482805065, 3854968150, 917520015, 394395502,\n                1316087688, 4013170326, 3611139371, 3969996396, 845435642, 1250928392, 3564637530,\n                3534519817, 4193257039, 1210838207, 1018604374, 1039438522, 3241956599, 283401613,\n                3791643370, 2495704071, 2807365421, 66163757, 3720427495, 929326153, 1056427022,\n                2224017890, 3983649303, 3242577483, 2252715700, 3763817420, 3945056819, 2536219802,\n                2347365037, 1332467980, 932313386, 1344905435, 1546705437, 2064541576, 1511380419,\n                3830839286, 1360902083, 3503290266, 3917441903, 1833414880, 3943874358, 1755117544,\n                2923194969, 2839238526, 1436154878, 2022570233, 2627252135, 514344885, 3629007310,\n                2734265902, 3693108522, 3208247898, 2234133971, 1972552128, 2954899309, 2020593517,\n                2046949131, 3731357545, 1937584680, 3590346900, 3944796673, 1847972007, 2243279972,\n                659814707, 354026232, 3897554349, 2861167827, 616720453, 3566033773, 667580062,\n                2925065641, 1209421025, 2590558623, 4061392256, 1200913167, 951116272, 3677973046,\n                3503505276, 3890324717, 588682794, 1822470598, 3062466072, 1622960923, 2217967478,\n                1671943310, 3797078111, 306673750, 416365363, 1127402537, 4051830565, 1295357578,\n                3597600014, 3944475003, 289083572, 792152829, 1866204223, 154676033, 1521441452,\n                3508161103, 925444108, 1492828246, 661274700, 3234551268, 2848116256, 2684114954,\n                1278505794, 1135004416, 1528837298, 903435517, 897822285, 1306717602, 1475128383,\n                1820901356, 1682104357, 2694156349, 1295051939, 3518824442, 250688398, 2216356021,\n                3513738778, 1822646861, 2230691522, 3766112863, 615919379, 1974329303, 1351423644,\n                2477642991, 1213629777, 1378792281, 2617577340, 2140073178, 2191340227, 2566413020,\n            ],\n            &[\n                3993985187, 418743558, 1313360511, 1682822200, 2190606963, 1153956890, 2732042229,\n                1286070126, 662863720, 4186279397, 540453600, 3865675059, 1267823400, 3515598059,\n                2652841176, 1202274130, 1747727592, 4024332644, 1774850346, 681999022, 3602470822,\n                2758087563, 1879963947, 3431635945, 246837220, 425774791, 1105979956, 2942553343,\n                1698889280, 2350552370, 3068812671, 3185616175, 3088938498, 878065968, 4173406915,\n                3359260462, 3381157370, 170884832, 4229318755, 2494013993, 1549083413, 4140845217,\n                4084551031, 3363271174, 234069829, 579586268, 409399673, 3823445787, 644521777,\n                2518846537, 536802144, 2920279334, 18872050, 1166062818, 330384075, 567479240,\n                242105288, 2256634487, 2099809688, 3182064703, 3455323968, 3796049588, 913224553,\n                1273986744, 1216752331, 3471953608, 4141617369, 113668956, 2271813874, 3836046471,\n                1442113087, 1985184453, 1605355495, 4002876308, 3555195054, 1327862010, 2467826608,\n                2786784068, 2229364499, 4162880057, 2362120653, 2428764072, 3253302211, 4041072194,\n                3342725375, 5091414, 4236090390, 645428080, 2998645452, 2029624491, 56740124,\n                2165228859, 3087533984, 1636492749, 2209776976, 3692581237, 607934780, 2356087899,\n                844604833, 3795358717, 1191407440, 2348446542, 2260870238, 3095317646, 2239633241,\n                1510395276, 1414456297, 1992793921, 2093060671, 3555947012, 2097207883, 2341507439,\n                1797902178, 3894103463, 589765482, 4279776370, 1462654158, 1306903445, 2072601153,\n                2881422521, 41492691, 12234573, 1317588012, 460035424, 2087095783, 1325294692,\n                639610198, 163158835, 583584804, 2753511772, 3964488699, 2486983401, 2238895215,\n                1588375790, 2681620680, 4165955199,\n            ],\n            &[\n                847465617, 4013314980, 3846912964, 910246757, 2972404216, 2762134840, 1953196515,\n                4029750073, 4055861164, 1261155057, 4100430088, 2785511074, 497236120, 1367918422,\n                3738577206, 736241263, 650868678, 2349520844, 3387563635, 741561301, 2423229549,\n                2724745547, 894805326, 2982356553, 4201925489, 3718492797, 3268940283, 1316855216,\n                535979702, 1867135512, 2894454664, 1953954059, 3331547089, 3629484636, 809197002,\n                3453878941, 2710176999, 2236099000, 2474407754, 508610082, 3021250908, 950343151,\n                2347617926, 3116087366, 387686701, 1840236979, 608794169, 80987566, 2929948001,\n                3099591933, 1498594442, 976518465, 2412591727, 4182908032, 3079365048, 2450010282,\n                2281968581, 2243779001, 309401913, 3783895152, 2093682035, 2006514294, 2836109544,\n                964684103, 1645279117, 3042605589, 3518893342, 3753614018, 3245078642, 976146102,\n                470909372, 417907929, 584991811, 4141480919, 3596625836, 3530716922, 1149488478,\n                595234233, 353336372, 638993563, 341110766, 984515266, 1262652725, 843520981,\n                594906936, 3922870845, 2571018879, 2329734185, 4233366705, 2923004114, 168356226,\n                666545721, 3625364230, 2627653737, 2717371138, 3344260869, 893744508, 407453169,\n                1376334915, 1670800848, 320471216, 2114539766, 1671037181, 886024377, 1940914459,\n                1457430737, 1427559259, 3091470472, 2856003945, 2098123517, 1418768818, 2088924969,\n                3884270171, 233325771, 2475658630, 3306400235, 1042747488, 2251057616, 288186037,\n                1069520858, 1716749834, 2851756715, 3107695069, 4055132959, 1800778936, 1250813397,\n                4225902318, 3898227912, 2436303557, 4099682647, 4014271299, 2579688947, 2474049743,\n                1793988451, 1750223744, 2886556309, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 915],\n            &[\n                685114319, 3257424506, 414393229, 2860628494, 121479429, 2579870766, 1597023839,\n                2474392621, 3223958133, 1457435159, 3048194581, 3047568591, 328216793, 3688729284,\n                1474966660, 3229714080, 1674178552, 3622356479, 2813923308, 420491140, 1181947036,\n                2552013519, 2545590339, 977030817, 1410754865, 418734423, 3219708398, 3814271579,\n                856825330, 886986018, 2340527841, 1574000724, 1326246490, 2345646501, 3649082184,\n                1757236341, 3333117097, 4191792834, 771549916, 4014890173, 1767239699, 1537408864,\n                860021926, 3301854273, 2439584990, 3450574632, 2067936331, 2217599411, 1936116337,\n                3184038132, 3501118169, 1312763670, 1815889084, 4185547518, 1921708290, 4252193163,\n                733366199, 1748333822, 3613571030, 2021878401, 674325326, 1834274504, 1974211381,\n                2155793730, 666543182, 3988638747, 719903603, 4243752700, 3417033998, 578937389,\n                1954345891, 438767411, 1067012960, 2140679028, 2616731558, 3608791372, 234168266,\n                115663374, 37715525, 3155431063, 1484074906, 2987669067, 1980354536, 201618151,\n                2443603378, 442745319, 2757914412, 1266139308, 4142086597, 1989465976, 3517367864,\n                1441253229, 1295109068, 2757883716, 1533532909, 4121897334, 3324479034, 33282683,\n                1821922930, 1002968212, 762196862, 13770263, 826603273, 4072569825, 780821896,\n                788706413, 2104768306, 1607373740, 341951230, 1675442736, 3679554432, 4040499065,\n                571466582, 467434507, 1883560688, 3831540337, 740943368, 2376257013, 1304728970,\n                917813781, 3342830532, 3374539547, 1366263565, 1830393744, 3801219913, 3174561984,\n                3973286677, 1398849159, 369072692, 656722452, 2994544393, 2007585192, 3393313477,\n                2976738602, 1184554260, 1566038994, 826752733, 477094709, 3837269061, 2769881480,\n                2709841643, 2163313442, 1223013930, 2855285371, 472880962, 695734454, 3106659328,\n                336220721, 2424316775, 1005851508, 3997249632, 3813922059, 4109122372, 1011074885,\n                44571353, 3135429322, 2678006854, 1812501650, 531726754, 684688016, 82728273,\n                2816638159, 2837354685, 3655899911, 36796549, 4088908020, 1199108102, 2363335387,\n                2702162409, 1359179115, 4038752961, 4132030616, 3472925013, 918360670, 1612076468,\n                1617334280, 3399902835, 1794719516, 1364930290, 3884047381, 1715844217, 2543581627,\n                1948226880, 3734808909, 1123962649, 6885664, 4055662667, 2036545059, 1825684950,\n                626135857, 3682021373, 2923868404, 1141437069, 301320286, 2038697946, 4203441370,\n                2625080149, 2416510088, 3453059660, 2196830401, 1003239496, 766384828, 1454135529,\n                3753927217, 289196672, 3027589815, 386319177, 4286570851, 34998813, 2808034465,\n                654631613, 2919774640, 3980646343, 3390105294, 3876707444, 342623382, 3063311246,\n                2951194817, 2409427609, 277380170, 1128962197, 512899487, 1130696384, 337608154,\n                4248250968, 2538526153, 408791364, 1355901969, 930023605, 619907788, 1270155017,\n                2669635170,\n            ],\n            &[\n                933436633, 2314417619, 1779862136, 2339830299, 3359221691, 1983848875, 2097698892,\n                1645402710, 49190984, 3806363526, 2374325643, 638588450, 3467828663, 2693267297,\n                3081019625, 2568134532, 3644457728, 2630819968, 707790566, 1984505565, 3749563552,\n                3700374589, 2579510542, 4246015133, 1527325532, 3034605869, 2134963426, 3613350443,\n                2082268909, 3145097012, 497158738, 1750605816, 1683654362, 1392048080, 2595287102,\n                1859642116, 3880370994, 773829956, 2727575776, 868421082, 910865307, 4010486592,\n                72360528, 2330397412, 2764112435, 2833247271, 1236763483, 1139702723, 3454679019,\n                3138128998, 3268622050, 3622582141, 1726130545, 2831795892, 391680447, 1964919870,\n                2937963749, 260385042, 1893950828, 1182888075, 3460030123, 2590897592, 3391091057,\n                3700415037, 1619162545, 1524016666, 1313243906, 3716478858, 1054838129, 1929422210,\n                4093970820, 1243478860, 3650034984, 3598628391, 99479112, 2103638976, 3422493162,\n                3133671222, 3540259323, 1874029880, 1634209319, 2379655185, 1946213151, 2520479253,\n            ],\n            &[\n                4135839129, 3082159379, 2808741151, 2746492478, 1317271925, 1590248590, 1871245480,\n                883232624, 3985674442, 3997584338, 2338792001, 1776575346, 2531584902, 261625854,\n                3578066182, 2058830353, 684820033, 3683099826, 1776182826, 2182228087, 919424929,\n                4095708279, 1423878550, 172604911, 255380658, 4104949687, 3178922494, 1444103543,\n                1691042525, 1011488353, 3955571774, 2253259467, 3143874569, 377143694, 2390377782,\n                1070304427, 1715840158, 2972468795, 455414172, 3300053546, 2552753048, 3276730351,\n                1581696761, 1405031742, 2503564946, 1980393840, 2686153828, 3279538716, 1074513470,\n                2389426005, 592338809, 348493719, 3669366843, 2086362650, 1888752201, 1485850549,\n                3098846363, 839653456, 2380177511, 1732519385, 1998829691, 3296699081, 2705709135,\n                2848494034, 4155180828, 1425421469, 3752183557, 2319259329, 2757221818, 1921158733,\n                3302049214, 1696454223, 3356952349, 3100878977, 324054921, 2131412976, 1078305944,\n                698318350, 4151030129, 2259288990, 762849915, 3134288938, 4090864118, 1223661238,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        test(\n            &[10; 1458],\n            &[\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n                u32::MAX,\n            ],\n            &[\n                1699768805, 1493014143, 2592376845, 190926105, 542951397, 3841252648, 1343830055,\n                2073311615, 2471501748, 1744126095, 4269392231, 3721081862, 3530443208, 1084284148,\n                467429630, 306942799, 1316059964, 2458728017, 4217570360, 2624704102, 3521450981,\n                2608224726, 3040435965, 2267671055, 471534848, 3629410298, 1363200167, 203206966,\n                3414918917, 3335382360, 1913622484, 1218762755, 3956682428, 1037359525, 5531615,\n                3407338094, 3864111971, 3057551672, 1048359741, 3074041931, 1285559492, 2147056083,\n                4091000908, 3900432305, 3556431023, 1451794634, 2393864263, 2505694122, 2968009980,\n                1048797969, 1048151529, 817832869, 2521994756, 2426006163, 3275649087, 941801312,\n                1575422758, 361314564, 722834359, 4247301247, 2186131251, 3429599060, 2212966801,\n                1219957676, 1702525945, 940680423, 333505183, 2493537355, 354760063, 274436852,\n                1639243309, 2924727204, 4285739645, 4001422648, 105606253, 3112142556, 3975066309,\n                409404932, 3040839303, 4022137216, 276092852, 3345019055, 1650156126, 169273103,\n                1920493641, 197903490, 4009771827, 838073342, 3939112618, 3406907996, 4120898973,\n                2720730518, 2834644027, 3448317034, 3673080760, 1810888516, 2181591183, 2952080694,\n                3794819074, 676604950, 3118739900, 606918192, 1316167449, 2730639798, 1815557579,\n                1808982050, 2109827633, 1671035061, 7558450, 1554665087, 520056416, 4218246290,\n                1161585267, 1878255675, 2486870832, 2088887262, 1303298097, 164712340, 2377403159,\n                525890592, 3347413040, 1697811557, 3373912443, 1800652721, 1430587466, 630390988,\n                1443110580, 572173114, 3006613569, 163802577, 3661300485, 2066285319, 3197778371,\n                1266266830, 3617690296, 4233259050, 3805452611, 2682754452, 1121170085, 4239996815,\n                2574739406, 3293943958, 589250712, 694935820, 2394149134, 3507180662, 2403010680,\n                1341157799, 688040930, 1064943055, 1576175762, 2748814503, 3365706670, 2331616371,\n                3891308187, 3625939659, 834228833, 2747861390, 4238259694, 2400594789, 1064448439,\n                1457694712, 2503273199, 848323770, 3879018391, 419366498, 2787183492, 1572178433,\n                1143352485, 4132728989, 3611364165, 2042218208, 4202715626, 4222254124, 3573214358,\n                2530238089, 3214459960, 199438106, 1990033748, 3797350881, 2039620692, 2196170141,\n                2867974320, 218349677, 2334991902, 2199173454, 2635928703, 1960733130, 3298739914,\n                1745262170, 2022670546, 1773942006, 4022957449, 3487536364, 4203797706, 321674131,\n                2963478216, 482717037, 423207073, 2529853593, 115650857, 1559406958, 2515253401,\n                4253176221, 1494891359, 54215779, 145831030, 2534290332, 722379383, 3288965822,\n                3478280697, 114345927, 438460383, 4120362834, 3417392370, 3871144709, 2774707897,\n                2662801524, 3802201761, 1044223137, 817062608, 964570171, 2627601973, 2648686193,\n                2728498120, 1589690733, 3285610776, 295629246, 3995872256, 2573726546, 231960020,\n                4274030532, 3444536058, 3882840099, 2252235022, 3959235737, 3485371602, 1365773288,\n                33313646, 1392617408, 1844121885, 993486158, 821274239, 2676605019, 3812510576,\n                3432776114, 495146668, 216967234, 3172737228, 3417198461, 1629229154, 1821830950,\n                1340735610, 3211463144, 3560398150, 1050123642, 874441227, 3169516221, 2783241998,\n                99843330, 1175436161, 2825581162, 3259620982, 3350111857, 1606464613, 1911911079,\n                4127551535, 3229370127, 3828823712, 2744685123, 2859704702, 1106636072, 369804135,\n                2989745290, 2768260583, 3275220193, 1104864623, 2290350054, 1049972093, 1592992521,\n                3598788064, 3350912109, 2954408081, 4230173468, 2901042813, 1614811380, 1930643862,\n                4235254046, 3520012632, 1160373738, 3249852125, 923106635, 2511906301, 2055083218,\n                3193170540, 843255473, 3274357481, 1069334404, 2160558830, 1247811861, 1960090087,\n                1260505746, 273679994, 628898405, 3731946987, 3821611375, 1479367897, 406962212,\n                1951524671, 151905808, 2697376333, 2827375721, 3738186384, 2398267382, 1189552516,\n                3271847863, 3695955312, 839640611, 391563549, 2851226168, 533382637, 4005632192,\n                779063015, 972248299, 4160069328, 1551848869, 2901173293, 1788886403, 7742522,\n                1152154246, 3162815742, 3933026131, 2093435260, 293643707, 537139803, 166837469,\n                1353454767, 647497063, 3056417780, 4130500121, 2563320691, 3004161478, 4266673072,\n                1525376895, 2692236203, 612090721, 3803502732, 1472545930, 1285255741, 3563385061,\n                354899818, 3985901869, 1077755288, 3764626839, 1736779714, 1388617683, 373259603,\n                406803142, 2250511459, 3661744930, 1712371282, 3755716304, 1001652736, 1437790589,\n                2722214878, 3509431789, 1045623456, 1477384299, 1529044191, 3485492831, 777726776,\n                3111945645, 87325680, 3674053827, 3777562490, 2467629264, 3920974102, 1118313420,\n                518650065, 2779852693, 3938004723, 351444334, 2301762313, 1696242659, 915234550,\n                3426770333, 2623516555, 2367502869, 1764681654, 3012087599, 2970366387, 1214823325,\n                1416807413, 1002068525, 902786108, 4219021066, 3685197343, 627261248, 275319515,\n                1048180581, 184895903, 4054317442, 1164782510, 2969271356, 448119019, 3225650628,\n                3586253056, 13844949, 4265695528, 3156376136, 2094798072, 857381027, 2996376430,\n                2313835774, 421527113, 577824604, 2027011737, 1936987926, 1716119129, 2495416975,\n                1566342556, 1974265475, 100699876, 3818621196, 864167162, 264481383, 2779691848,\n                2519054856, 356904428, 1425193402, 2029146838, 3791198981, 1181286580, 2106244436,\n                4074963191, 1156817098, 2002193018, 584536494, 1252244761, 3576951572, 2017920970,\n                1604293290, 3010503460, 1201492606, 1555982397, 2556964369, 3428819809, 4168489079,\n                4171058202, 404720822, 2480856269, 1813722898, 2093837710, 3164853594, 3430042720,\n                2545385245, 1253945679, 2067139932, 1049755734, 4162345450, 1330690410, 2567802121,\n                3494789533, 4027320953, 1359086506, 697144652, 2171860846, 1885681379, 3200348033,\n                779514913, 3892431243, 3292022849, 3206367229, 141294896, 1247341423, 1286221471,\n                2030904879, 133272354, 1441910339, 3982161305, 2696309947, 3801057775, 4053369379,\n                3233631762, 3173498696, 19486328, 3282282805, 2117833655, 416934200, 2476837107,\n                3550654071, 835595228, 2784887835, 1849982594, 1215825494, 120169702, 3628150453,\n                813273996, 3164608875, 2585886019, 3468354974, 2529654702, 3937155612, 2948360421,\n                3839784361, 3626976122, 3884938510, 2182665318, 1984077334, 3592802345, 974314095,\n                2658877268, 3320515471, 3220348329, 2057524489, 3330170042, 1859432638, 180803537,\n                1712128971, 2278567221, 2233418239, 2029256422, 183505236, 1671411329, 207176584,\n                2036148357, 2313901094, 3988184694, 2436690588, 211724920, 3032356297, 3340214696,\n                117345076, 1500403818, 1365050888, 2323945197, 2919933846, 3023641486, 599606728,\n                3628676259, 1581385213, 1427038937, 807104522, 3978940995, 3629484758, 47151915,\n                1224789415, 2759574529, 2839954032, 1315873434, 3168847820, 1610459325, 3726598118,\n                896590825, 2419742875, 3430079217, 3778931934, 3687222980, 332999836, 1043316180,\n                4189864653, 685607150, 3695627010, 196835870, 3941428183, 676485145, 986494888,\n                1049128467, 1888162207, 2801108003, 2947315222, 1894059346, 454711531, 3589935315,\n                1803051198, 3655137369, 983821858, 3081875497, 3803393764, 2428490033, 1679378736,\n                246071720, 1483050983, 1382043974, 895942294, 2442009263, 68111122, 1626094364,\n                1007851423, 4064984075, 1533309302, 3360582064, 2740180933, 883885210, 2989133634,\n                678055765, 2661431250, 92559696, 1032783565, 22899740, 2361882691, 2393385114,\n                992907787, 3373832203, 343145453, 1165167516, 290287284, 1707286378, 634939907,\n                1875541381, 1297012104, 3157634640, 1929967474, 1519414443, 3881762803, 2681995819,\n                1775206192, 2755218098, 3910825543, 1860602393, 1832806570, 415596447, 2186155905,\n                2791826564, 1816344456, 4023525966, 243382839, 748453584, 512556810, 3922005623,\n                1061467548, 276741166, 2229273612, 1738207771, 4128865796, 1984054190, 1324502121,\n                2297662740, 1222235249, 3182342363, 1665477641, 2147473685, 2421806673, 2322492629,\n                3459362839, 293710623, 3706578807, 1598383617, 3666283079, 1011133678, 2189483475,\n                938644636, 847088475, 195518118, 544927250, 1332819612, 2366720962, 3995717811,\n                1985243513, 948001598, 634366393, 3212334449, 4000960249, 3974258285, 4013403482,\n                418753555, 1101654041, 1090819318, 1675158019, 3683152713, 1204756106, 3841987860,\n                2260147808, 102023094, 238154404, 533560693, 4086126380, 642534617, 1632145671,\n                1006291121, 1435987078, 1313038313, 4186175328, 843360286, 1839639056, 1353648132,\n                2221125136, 3732368512, 3339185832, 662563454, 2744469998, 1331973650, 1343096038,\n                3251304725, 3601378173, 3422205067, 172706680, 908147887, 3728762498, 3795011129,\n                3044217576, 67031330, 2499472547, 4147725229, 2529069049, 3741434149, 4201254595,\n                3779595001, 42489268, 2053548825, 985282652, 3980674776, 3248961215, 3376433654,\n                38182659, 2602101994, 1925777855, 806407427, 2317267910, 1380652265, 3701097444,\n                1220848862, 2025812459, 3482791264, 1753046753, 598143651, 2616070898, 2479609320,\n                1868138196, 945178683, 3832269010, 2314371642, 2400732781, 2048750780, 54093670,\n                327716566, 3334970102, 28861124, 4118278855, 3714357594, 541833330, 2000911880,\n                2666752754, 499968133, 1548730866, 1814521338, 2487369228, 1138644653, 739248636,\n                126190040, 3978033791, 1817304821, 1225794794, 2871919793, 940731169, 504076316,\n                995594649, 3329757458, 2846947354, 3891292748, 3959049218, 2127628616, 810346662,\n                2271875593, 3880247584, 1164066271, 1750445267, 338639562, 1699074958, 959302743,\n                2956590033, 867798509, 627451437, 3510106002, 2473252158, 1509206912, 3352377241,\n                3802665519, 2147957812, 56184472, 1718654148, 3672624374, 3511414009, 2682054173,\n                3922316656, 2414259176, 1496250883, 3967344788, 3214918603, 1624761599, 2724006253,\n                978208159, 1113357772, 3487098045, 4270740839, 633061828, 2261921853, 3462914738,\n                1530768806, 1364864048, 2876294873, 2510835104, 4242821662, 2474987381, 3633586220,\n                979932165, 4155189874, 2525154569, 1335483880, 639760624, 1660790427, 2226690500,\n                4135706134, 150618757, 593063255, 3258479253, 3728374085, 3007800944, 3679685736,\n                694904689, 102552353, 1428747995, 1176285881, 641509845, 3270509599, 272169854,\n                3047261598, 1287492008, 3351279172, 2404469180, 459751592, 1333387953, 735177161,\n                215716037, 536597459, 3665567562, 822815388, 3602692316, 3168229037, 1054147108,\n                4146505577, 1580773238, 1088501561, 3629868530, 2978204283, 3610240644, 2223237525,\n                3153209697, 448561701, 895234984, 1592358205, 57857782, 851682344, 4181525201,\n                1988009551, 3651424110, 3655716749, 3787661870, 2925252014, 3708997912, 3309060091,\n                4188222270, 1673276025, 2192528846, 958274526, 1258766035, 3525801758, 1215614889,\n                3051826051, 2354974337, 1541657893, 1271755575, 496264166, 2626820052, 936952045,\n                3785181421, 1294902361, 1958901697, 1604821791, 218282718, 2246953449, 538193118,\n                1919817946, 1243076425, 799521120, 279827487, 2722496365, 4019574708, 990869332,\n                2181585056, 2705356597, 610157367, 4119248513, 3343890269, 3121261960, 4085000780,\n                1022014736, 4240976369, 2817889889, 4075894073, 560049242, 373205120, 334714162,\n                1892034277, 51733004, 1776487312, 1265439929, 529285398, 2048981213, 1833004632,\n                827301005, 1648393113, 4281016481, 2048185380, 784315559, 3245679058, 3513265995,\n                1369181664, 4269143782, 113931975, 1398194472, 540409306, 216516009, 2627890586,\n                3694809441, 2573974797, 1396611872, 2646365320, 988053471, 84792061, 963667070,\n                2114579379, 3564371585, 3893773169, 4197725787, 2378021272, 3273607654, 1738197474,\n                2402812179, 1278628015, 2317178895, 3160300732, 603898477, 1287079046, 392763347,\n                445875312, 318139180, 1903469143, 3585413276, 885483094, 1674549044, 3911672420,\n                1575430246, 1867282418, 2115410448, 4189894183, 3512999498, 2833930381, 4284803257,\n                2594863293, 3053172089, 442647755, 2456733276, 3207156565, 1248598530, 3135346976,\n                2511563725, 2761431370, 3552853409, 3064928230, 1668127734, 2151818142, 1573413967,\n                2528903432, 2255579949, 4086541389, 1008056620, 651544198, 4099217330, 2147059795,\n                4189054906, 3160158060, 3084688966, 1829066970, 366751766, 1086760266, 1823021570,\n                3035776668, 3725549438, 303569416, 1637955291, 3070457854, 2756834184, 1117066585,\n                2815830458, 1229154243, 978732541, 3666377420, 2646214554, 3084488532, 2757010866,\n                1756160517, 2475577838, 467860047, 3125348085, 990351000, 3303850398, 1120462919,\n                1920695807, 2980611720, 142863055, 2378648555, 2707355873, 3519612422, 3266835497,\n                2512195477, 1941306513, 365527762, 592954943, 2552580189, 2606501901, 1933724422,\n                2729691276, 28289820, 3017728757, 3650961916, 3696374759, 4228636665, 1241471494,\n                3355869165, 1455843481, 2403725149, 829901760, 2618851388, 2623034964, 2752098284,\n                962418521, 964160519, 1174284358, 2043907493, 848741317, 2520932535, 53649688,\n                4228750878, 3694987632, 2694050164, 1097113047, 1221352269, 3997202409, 2858697527,\n                2874569664, 82995009, 2474870382, 608319794, 2793235942, 1762763510, 593568738,\n                4140942494, 3399850155, 3632742015, 1495257590, 1987803076, 3040781503, 4185563847,\n                2095097137, 2984180367, 2385825018, 276655462, 2186224265, 242785858, 25971964,\n                960934651, 4259630073, 2869516035, 1099452330, 1108772812, 2208212843, 138327599,\n                3047969124, 2406962821, 3234115454, 2013090243, 1253595634, 379537518, 966627542,\n                2289594467, 3820588844, 3307962615, 2251395356, 1086612191, 2411787092, 716861072,\n                488537062, 4279016079, 1024670198, 3162868375, 2993498248, 318817475, 1204805151,\n                2917216152, 202544687, 4055006202, 2166902046, 777932120, 1954248209, 1436706075,\n                392807099, 3560992122, 3690436481, 4086456539, 1672219993, 718561908, 1329443408,\n                41759831, 3830929272, 468558885, 2850993192, 1203438200, 173099196, 3100895691,\n                3212371819, 2727223413, 265778175, 1306749738, 1945372531, 3409735664, 1829111612,\n                73857789, 1967847248, 111126146, 1941085939, 2157306354, 932967688, 1524770100,\n                3562820290, 1815865396, 618928660, 1954521715, 2791055048, 1472833149, 2745012885,\n                2590581857, 764068138, 3810864565, 2068720839, 423731968, 2781829173, 671016197,\n                3626671545, 578830019, 2263629204, 3196999908, 979097653, 3960854009, 2652280123,\n                2014180777, 3212225669, 1901793582, 791028866, 1535961645, 3425925260, 1728220859,\n                906987059, 1320441954, 103740087, 138471919, 2751991892, 3763793139, 1930252328,\n                2302777807, 4166228863, 1898736904, 2679190175, 1902812084, 3494412200, 2003091421,\n                647088593, 1275527793, 1571337951, 1296166873, 952173553, 3873665860, 2863399704,\n                1687749991, 1019315430, 262989750, 1995806398, 3977438566, 3065387570, 194327737,\n                2433254350, 3852864758, 3086016127, 1848276257, 872733825, 4293282833, 3839899541,\n                1287823073, 2617969813, 1718468275, 640897626, 2796238324, 2471345611, 3038580905,\n                1824539690, 2178312422, 3642675324, 4168141874, 4093223514, 1058804935, 1645178046,\n                3320651392, 2520046692, 1724703883, 821899232, 481110608, 2492775734, 922020621,\n                2923405792, 3392950548, 76237439, 3904683294, 256504571, 727968315, 59423766,\n                3078236506, 2465675774, 2942973709, 2930861254, 2455418902, 2986403934, 3056400696,\n                3599867309, 595501194, 2042151651, 2763604081, 65000450, 398696589, 3026108404,\n                4199385741, 3349995311, 129915120, 2486649758, 775313272, 2784093349, 1582665104,\n                2775814261, 1584569957, 2195691054, 2575677337, 3244017237, 2457054839, 3897157261,\n                3195991591, 2030342150, 3727062402, 3706029571, 1179068874, 94821848, 2230566710,\n                3669075264, 2425831169, 2438414276, 1720898289, 138216286, 3807634131, 346144588,\n                1780209932, 694722911, 297024116, 2795490416, 1836169972, 2915769303, 591959219,\n                2377921602, 4158591575, 1182337705, 231710027, 2274507465, 2241869617, 300827881,\n                4150367209, 3585840019, 4167111741, 1023965277, 1674153048, 887595527, 1601672948,\n                1765479313, 4065509701, 3915091640, 1297871355, 3479625154, 2831036720, 3785201761,\n                1221164796, 1647627464, 2551945655, 1768755122, 2079192478, 347747455, 4045445050,\n                2954562195, 3495749867, 2264323612, 3116421719, 2118887029, 432847575, 3976298717,\n                30083877, 78749340, 2656872748, 3171516677, 944561854, 202462342, 339834758,\n                1199920281, 488096540, 3380838041, 3470160182, 1755758102, 803450485, 738480354,\n                357618351, 8551902, 812925594, 3218358491, 2918846080, 3174772578, 822290689,\n                51990462, 3350891640, 2729296982, 2723805763, 3540769319, 1145905142, 1754039404,\n                4289454572, 4153901476, 1336760032, 2717506348, 2938254966, 1476941276, 3458786809,\n                2378593502, 1537570700, 476723401, 1207306095, 1092996894, 1187377294, 3666979500,\n                3948059620, 4150681293, 719413909, 1118296918, 3753268822, 905882560, 1638884713,\n                1259563753, 1063300422, 1502884288, 2285369399, 1874551590, 2040785043, 1775679918,\n                1144757520, 3854262168, 3821097323, 282903083, 197139966, 976017372, 3684024526,\n                3746169537, 108937132, 2444167905, 3366454633, 1002555971, 3961863482, 1693512346,\n                4219424106, 2731825813, 2173055658, 3589347522, 1180897582, 349307065, 132252171,\n                1286185962, 2906205536, 2843606103, 27822898, 2481699072, 2948630201, 1774092707,\n                1171123309, 3404061713, 2905420837, 2351973006, 3971568799, 3248015376, 2297549471,\n                2624549152, 2864086950, 2757145051, 284981704, 4116824485, 786416861, 455364234,\n                810567289, 1304615212, 2127708286, 3066389895, 3906659140, 1621009466, 4060905456,\n                2498550541, 2021095657, 189923381, 3015918335, 394513300, 395082750, 1997152191,\n                3900214471, 2076041515, 2762331608, 3059576182, 634566583, 2077367009, 239466771,\n                3512081528, 3492757347, 1343506243, 144657866, 1186993011, 2942254420, 3813487876,\n                640076454, 3107898063, 4057144155, 2951251839, 4059833593, 2265248880, 2051308911,\n                3838642653, 1427962716, 1138966813, 1697969541, 3885404282, 2547515947, 2006341172,\n                1338884621, 3673075887, 2250647769, 2303605646, 4029999904, 2015620651, 429025216,\n                4230380695, 3438741639,\n            ],\n            &[\n                1988498380, 3050132581, 84001963, 3445692001, 2734783387, 1774219496, 2162032114,\n                770345120, 3457703796, 3559428633, 4257360364, 1090466591, 3567817053, 2497380424,\n                3534691541, 1279435419, 2742018051, 2205075879, 641106, 1754923528, 58973331,\n                1715000559, 1117715270, 2272741525, 2115935795, 1483835360, 1296235, 1796957756,\n                3968651424, 152068196, 176938861, 570875261, 3336099773, 1193842175, 3048757774,\n                764666488, 3843941623, 1548464729, 1897867882, 2878929765, 448571520, 2406065734,\n                3568376411, 108079736, 153179622, 376615879, 462260105, 973865240, 3413391101,\n                2811718165, 3572533591, 3909460695, 3134008033, 3897396582, 1040616570, 2998174467,\n                4068999806, 2523162074, 948788147, 2600716643, 3959424266, 2966714, 526886335,\n                3296693425, 2243375988, 4143935802, 1111766991, 1144066805, 2311007495, 1010976381,\n                845073483, 1135483459, 3990880342, 294797346, 2679966602, 2533930988, 1664564718,\n                268281267, 2092673357, 469524764, 3945653712, 326073803, 2694037849, 3507600917,\n                3290201609, 121045908, 22654279, 1505718612, 551101589, 2556674091, 3163892929,\n                1910818775, 3418844366, 3372741206, 130020156, 715267628, 4274925122, 1048026555,\n                2835427841, 3505581892, 1602295761, 2414351668, 1553499591, 4229635398, 2519192505,\n                2021787900, 2301738189, 2691817702, 5305850, 1565221152, 3538706617, 3057801765,\n                2874943612, 3131932103, 2612726193, 1166707551, 2820888127, 3160538692, 3124232750,\n                481384322, 2617755783, 3630694751, 1672329146, 3497041986, 441500257, 1563794131,\n                666530710, 1149258814, 4274365529, 169180791, 4187510295, 2714548495, 3562799169,\n                2904591043, 1774457729, 800521106, 1411048330, 2663300606, 22655328, 3774883767,\n                3819965706, 3800295936, 3668492475, 1379825015, 4213938165, 1132023495, 3760304231,\n                2917225913, 189390673, 1938798483, 3140766517, 2153396970, 1928404388, 2785977327,\n                934591575, 2405323840, 3637359453, 981340132, 242310679, 981811654, 2288564752,\n                2987925303, 4031514738, 197635692, 2859303437, 2533609681, 1151769485, 2644644277,\n                2635940433, 3366453887, 4277743333, 929550085, 40133408, 1833321431, 2429701519,\n                1464545187, 3066929948, 3904082769, 373116082, 2430829492, 2571513045, 3885018135,\n                603068030, 1172828581, 4065558289, 1163895893, 2468059427, 1548489900, 1717402470,\n                4016751470, 1013738008, 1034029588, 3482329597, 3435207029, 1673410325, 397717038,\n                1500823297, 1911172810, 1420629560, 3358784452, 1312197637, 1152173034, 367120884,\n                384630941, 3440282377, 2522765605, 1597847376, 2683717257, 2561199311, 639683785,\n                3817861808, 463544224, 3991704969, 3376721583, 105154089, 1533594425, 335823085,\n                1107739913, 1452695631, 954081147, 1472744072, 109401385, 3210541127, 1847806577,\n                327707567, 2422910059, 2867854042, 1286261864, 2777291397, 2491134001, 1866376440,\n                1442628329, 1148774257, 327348168, 796722022, 1651402005, 2839518531, 707220227,\n                442580375, 614584592, 4054371638, 313021875, 3191805300, 2207878775, 3933190445,\n                2035546077, 381129617, 3161098198, 1019615010, 2743759521, 1458405016, 1891243747,\n                3502084250, 951344904, 2669441803, 966435550, 1450947158, 2445618755, 2629179958,\n                1786188217, 1157343233, 512400759, 3058846955, 1691540553, 3902487730, 53457416,\n                827127510, 109080803, 2065162700, 2595989450, 514516885, 3571421189, 1946474067,\n                3695201586, 529285628, 2120794437, 1831163308, 1518439076, 3361874260, 3805558145,\n                2288973775, 2352901588, 4206307376, 1343461937, 1115914255, 241429811, 2386351727,\n                3283851422, 1570726296, 4171557460, 2197857248, 3493510408, 2254067927, 3407035296,\n                1925479341, 3186474620, 953208782, 715061374, 1181448968, 1220358590, 1370257748,\n                2925654278, 3323438388, 1322650109, 3766704524, 3870430557, 3257441173, 2439781482,\n                1554488089, 800150735, 1514175574, 3153400949, 1583649143, 1280421056, 3882604400,\n                2181270798, 2782475677, 3148486479, 4071326639, 1764147111, 3505719068, 1862656169,\n                1261162987, 2211270974, 3217710591, 2927566184, 4232715549, 3582658271, 1363726747,\n                3233373581, 3022128605, 3193686951, 1851291940, 2618042857, 2848579530, 4293396464,\n                1928252986, 528145280, 300907511, 3891802439, 1267856769, 1165928777, 4227625628,\n                540012700, 469250948, 966533455, 2875072197, 2230103081, 2000106078, 3086794985,\n                4244235827, 3081744548, 3713073740, 2925851679, 2315339278, 2558156736, 3723155058,\n                3227292432, 2941681952, 4041413976, 2097513703, 3042683335, 3624088138, 3936977773,\n                2820887559, 1664662915, 2334141648, 4092839529, 274159708, 4055649255, 3512716978,\n                1365039076, 3916570667, 2158939813, 403036637, 942532489, 378445989, 2167306547,\n                753402418, 1193358264, 3877024670, 3743152347, 116435136, 1948333248, 569098908,\n                2922999784, 917671206, 2718173867, 1010784137, 1804409345, 2242631895, 3989814639,\n                2044343096, 723486672, 1841507274, 2333301606, 4260854855, 2763867469, 2805327422,\n                2351089720, 1719837442, 4008440919, 16200186, 1228294632, 3833322142, 151876299,\n                3340352893, 647820547, 3228338641, 3940895065, 1697980005, 2505263582, 77077868,\n                1311758352, 2346165371, 2652028800, 3480066477, 1481299332, 2948248752, 501377681,\n                3276784059, 4102724530, 1207318829, 2947644680, 3069480791, 1116349810, 3395241135,\n                3570300879, 3836110678, 23881082, 2523984619, 86893874, 2919930037, 3241130876,\n                3697730978, 1459589531, 486161579, 3036213671, 2106273230, 391770200, 1135761788,\n                3542580424, 2902564186, 4169447111, 1908429065, 498329772, 2010302804, 1930725702,\n                1614128757, 1901201146, 2340750074, 2621544559, 1554979341, 2490973900, 3039157328,\n                2525878574, 2064002895, 2981842962, 513591182, 48663763, 346106995, 1067873617,\n                1664056855, 3497080122, 2640223678, 4006771320, 1595836468, 2008498009, 1036368219,\n                238997308, 168075897, 876079826, 2934854956, 1075263443, 3803042525, 2802898866,\n                2169905202, 3377165843, 2465797619, 1978983742, 2322310751, 1590628498, 1459551643,\n                4156365433, 3054380889, 1819890111, 2928185712, 2553214234, 3066671630, 3394771139,\n                1734126526, 247246953, 3320484300, 579355057, 1177404814, 1327413352, 2035170753,\n                1052379386, 3339678481, 2430828601, 3360847369, 2961791848, 484983472, 3181472945,\n                3105431626, 1283580906, 3703197182, 1961222326, 3649286491, 2664156595, 2335129028,\n                230491131, 468504878, 3710487036, 3159611165, 3544126878, 1088644958, 2961497435,\n                2785759884, 1537524580, 563225344, 2114093362, 4212602497, 1169631938, 2088081811,\n                4006629680, 3089709789, 3749609771, 1969435408, 1786420402, 3870446123, 2169555554,\n                1571013574, 506991779, 2174983408, 2376333115, 1813451470, 2875689985, 2056697043,\n                2022446139, 828430986, 710475734, 785980495, 505758805, 3139780897, 3708680832,\n                3390307357, 2434318195, 330093210, 3019701899, 3546042185, 202048370, 3017694172,\n                3813711930, 1950710894, 2336832114, 3123649938, 3799964456, 1278675670, 1776925346,\n                23381263, 909581672, 3084101661, 1592521095, 3095643203, 1245783006, 917301336,\n                1175072489, 1493603974, 537178477, 3098462691, 848961674, 4083634813, 485866548,\n                2460787176, 1957075662, 1653349530, 193311723, 1510554197, 615759127, 3054909658,\n                3810118423, 3275067767, 2822189856, 1822027915, 641453111, 3902949794, 1707895715,\n                187255999, 1547540130, 3996925138, 3744594623, 279929032, 2815355330, 1197018567,\n                334914949, 104288985, 152451615, 2257137946, 495821725, 3891425071, 2698902656,\n                4248123041, 3994796663, 2283493355, 1792145295, 771358160, 57983054, 2699162282,\n                3252719646, 901108453, 21411013, 1214186627, 3971974103, 4284646962, 505661368,\n                2014789373, 709655680, 4019528811, 3456428712, 3896941342, 25228952, 3267679573,\n                2554048052, 1140488725, 796840032, 1008803984, 1769445882, 450164846, 183418978,\n                1557823191, 2205206958, 2186287277, 4041341207, 2277585274, 2647704834, 3299210809,\n                465486816, 81165601, 3688958209, 4134919427, 308497409, 1670228519, 1054621084,\n                3997139209, 642331675, 877436795, 3750152836, 2099953927, 2407318768, 4064392686,\n                3499776748, 2890558934, 4257002037, 409497686, 1871363314, 3488166608, 368834184,\n                683374402, 3315975032, 3919319927, 1636872711, 3746724350, 411713899, 3127168268,\n                1541472093, 481068370, 3914726958, 3809187727, 1019234471, 4257529799, 1795024406,\n                2169201644, 180192691, 3146544995, 3086567728, 1371853848, 3442647104, 1956649571,\n                3221872492, 2599010979, 3825880037, 129532942, 1962882180, 2981643769, 501519665,\n                1104150124, 3577388513, 530338682, 2379351921, 476796974, 2079075205, 523122306,\n                4175790511, 1769173929, 3684943051, 203952644, 2367960727, 2956929713, 724249999,\n                3868724734, 3128867062, 788369620, 183457300, 4030548412, 320471199, 818557389,\n                3673114423, 3427092352, 965641427, 4165737446, 546271097, 3179039741, 1968478116,\n                233505213, 3523513681, 3185397073, 1639252860, 192368536, 2476919576, 1286359266,\n                3468793964, 3927932569, 1554017778, 381977140, 2630912557, 3248408028, 1380148387,\n                434027229, 3679247941, 2320186711, 4049616334, 1306803801, 3657216807, 4072237788,\n                2409653033, 16652557, 777239076, 3435314631, 953899982, 375200832, 3240441496,\n                1403201300, 3463532889, 2152357282, 1492290956, 1756116611, 2979347831, 157726282,\n                597994889, 3571510881, 4022595441, 3689069225, 3371053456, 1105664287, 381184864,\n                3760869170, 2128986335, 4138730626, 2108903255, 3330167716, 1193420433, 4081108869,\n                2371248791, 2008259868, 329286806, 834934063, 1587339743, 3835392552, 3027794970,\n                2946227510, 2759445311, 4153403869, 3246082301, 2169502676, 4274409702, 1618245891,\n                3538641406, 2440237498, 291928949, 1309678695, 2248858018, 1259269551, 3062553916,\n                2375747923, 929738114, 3593316299, 395934754, 1240422334, 403599738, 3596058407,\n                4199195184, 708535732, 1045565478, 2985960024, 2935035441, 1902361158, 1360356647,\n                655818324, 1464367881, 1402852252, 1605910196, 1553177831, 2270937291, 3867336542,\n                1242299751, 4201495317, 1894193944, 2952284338, 2983597634, 3331327699, 2688007694,\n                1534358324, 151501193, 874435351, 113820939, 3053243228, 2461547215, 3493411866,\n                2931307581, 243458129, 2419713971, 2259098050, 4153522826, 1347753364, 789286836,\n                3723853308, 282228699, 31083181, 212832201, 3992535406, 3841973318, 3150180785,\n                966530634, 1983757001, 4224102508, 4103842551, 2315916292, 797697662, 915301841,\n                727577536, 3413485655, 917582931, 843507358, 1529131982, 1843003612, 3002449886,\n                346610535, 991891575, 2565267970, 3912371508, 2710618386, 2330075864, 2735484155,\n                2546043717, 3241769509, 2210455214, 4169254026, 1482724431, 674379398, 565771066,\n                3142137141, 515638418, 939683105, 1345730468, 2404207571, 249108973, 1883806778,\n                2156914196, 1564711040, 3370156804, 1857590348, 1147780810, 3733908955, 2181248732,\n                1904993207, 3694175594, 619779923, 3491824168, 3612713452, 1216174279, 663457690,\n                4014509322, 2569761593, 14109664, 1828397087, 2936522368, 4158885908, 657033012,\n                3173212007, 472151655, 684251460, 4075235611, 4224354174, 1004777987, 505536516,\n                1454022092, 824505586, 3067613896, 2235424889, 3665322087, 3481517352, 2363451123,\n                2771040650, 3235122422, 1154036889, 969497501, 2563704447, 3797108, 1395020021,\n                2762840789, 1908946824, 3014468569, 925225402, 1138335619, 3624023401, 14380823,\n                2839985590, 1786726385, 2046596657, 862236402, 214661254, 79111383, 1583211853,\n                1641485501, 2710635102, 4088715922, 3860998541, 1323605849, 3597942622, 1491675000,\n                1599602967, 3388494990, 3354632479, 2528582795, 215618636, 394082738, 1141528681,\n                1784788922, 1221028471, 3234711669, 904205099, 1676230442, 3127792899, 3994795553,\n                2452526892, 2165805680, 1335373003, 192721187, 4240993835, 3133423197, 1689272558,\n                3673814847, 1422539041, 3736049673, 1833170900, 282944559, 2338828666, 2779222702,\n                3327509347, 103394172, 3158363803, 1906876457, 2941521396, 4107834947, 3417951529,\n                880661309, 2072508295, 589009441, 1335393037, 4277398556, 2493403024, 3409655003,\n                3109850219, 1180552996, 2381399690, 2298638016, 3501746890, 846617313, 2905524779,\n                2707401285, 2041915730, 2296396459, 1041902038, 889847207, 1989421094, 1389388870,\n                3827587250, 1783862700, 3828138938, 1868614698, 4248902541, 3581264817, 3916285777,\n                1776264454, 2214767964, 2937276417, 1736659895, 1395637227, 280854206, 226975266,\n                3550562380, 1121092319, 159004679, 3748222278, 1260252989, 1422903228, 3336410666,\n                194417341, 2723594163, 2281242077, 1784282179, 1034680840, 1402111826, 335654645,\n                294940873, 2853511062, 378984905, 2532157416, 2195182123, 3873081897, 1625154299,\n                260395831, 3540310196, 4273320806, 2622305394, 2711543735, 200100618, 3414809217,\n                2926348222, 1329786033, 4245332557, 3574371092, 2777917577, 321179615, 3642895588,\n                1496048120, 797710555, 3671936109, 2438718323, 45015662, 2137354414, 874208938,\n                3450439142, 1916685905, 1662667234, 2856738964, 3829688032, 3404462996, 2848035045,\n                2061762938, 1260861712, 3010572066, 3394836279, 2342878342, 1271875691, 4111464444,\n                2126598368, 2380694046, 2430271490, 1145499017, 3787409979, 1555528697, 3376084869,\n                642452482, 2589187231, 1081315770, 2087941360, 3364823763, 3805619618, 486395332,\n                908395706, 2499268457, 2420556587, 474512813, 2481646657, 3492741661, 1968018988,\n                1074530387, 2014914730, 2803826225, 3220982875, 1438277839, 2775829138, 1528403642,\n                3794191286, 2608342366, 410785526, 2637600256, 3490750019, 1440381245, 814635701,\n                2260916755, 2650730282, 415890751, 2524080685, 3474570208, 2446217936, 2397550701,\n                231181743, 736834280, 1383997656, 1496783958, 623278112, 1645711091, 2659144562,\n                2936379758, 424018844, 1549465529, 2669736270, 1664977313, 1523334854, 193915346,\n                917134660, 1861003559, 2211424692, 3594457673, 521847126, 2663400187, 3341032570,\n                1640978768, 3374727890, 2984430165, 3295971473, 3727310438, 4148801904, 2931771022,\n                3471915299, 3774018978, 243266066, 719450229, 786371556, 1967721517, 3662692002,\n                2660462613, 3406551440, 3689369626, 4170908863, 927580754, 1492537107, 1444056133,\n                934562830, 964303678, 1533941876, 4122966823, 3705199737, 1112924448, 95199848,\n                343531614, 594658489, 808416147, 2905432520, 3584653211, 1387698320, 3110254075,\n                179755886, 2585492770, 826193502, 633023598, 1166009098, 1290016012, 672935203,\n                442560997, 2496163987, 4194310358, 522918013, 4222433924, 1620670288, 1584642952,\n                1110116518, 2050444989, 3738181405, 2449666200, 1322361471, 3346873860, 1704204055,\n                2765918523, 1681401174, 1734783149, 2990922980, 2845873797, 2655480068, 1134013632,\n                627992748, 2305459149, 890878648, 3702690433, 2308583593, 1647897272, 3079544696,\n                2470471677, 4040208261, 2073585273, 1793034905, 1713771355, 2220715251, 2553773388,\n                1442482611, 3113497415, 2768408881, 1270025121, 1399831313, 1630862433, 3377364946,\n                1442504714, 2789927137, 3191151633, 2578873407, 208337033, 3096561372, 3943415949,\n                3118056636, 1664092654, 533371474, 1132049460, 1378502069, 1205939688, 2646775436,\n                873517579, 3647947118, 4249353240, 1234899426, 3562671303, 1028908207, 3806236229,\n                2688126461, 2379248861, 4273316716, 1028554767, 960050373, 34458263, 2497415615,\n                2000699114, 1654490516, 3970420809, 430138864, 2839090700, 2992085491, 2048751357,\n                747829112, 2102051019, 2747342438, 3939874657, 204736053, 132477025, 2895769009,\n                4049016784, 4006488678, 3010059929, 3869487365, 820665998, 3637576575, 1400083196,\n                3176270933, 1580718861, 1862589245, 3687231820, 2811111046, 288642712, 2708675068,\n                3659920550, 1043267703, 2675211709, 2471783225, 3908671780, 1796097076, 3884725302,\n                2618455344, 2727437605, 3198512809, 77833978, 4002905580, 2475905855, 4285041054,\n                1379496519, 2810710199, 3524329171, 2422823286, 3888601537, 1921960588, 4141779429,\n                3945205304, 2680621131, 4186120628, 1952951538, 2875169441, 3303243339, 574383361,\n                2010030917, 3924461786, 1497240891, 3972138842, 3082719894, 700821923, 1225799274,\n                39941891, 1579154501, 2895091775, 2026419054, 3180814760, 1239600240, 3443816247,\n                4103641786, 1778116375, 1356356349, 3003002432, 2464906412, 3106084532, 620250446,\n                2199567717, 4285388064, 1443224417, 1183702872, 2361871288, 2889920918, 151923059,\n                3665604400, 902272748, 3673929087, 777413599, 2880183228, 3116820884, 12649513,\n                2151951398, 2517689255, 2603024997, 1540902312, 413276528, 463295145, 1270795006,\n                3197387059, 1235198896, 1591251569, 1536841283, 183104831, 1099570929, 4157586543,\n                4245916264, 1187513801, 2725120513, 2263045835, 3616676335, 1441932591, 859970322,\n                1785738074, 2632201495, 3074325275, 3739260875, 3210655551, 3115242275, 2776972168,\n                1857654859, 3388697322, 816121986, 4034608581, 3645370625, 3901309336, 3655082618,\n                694485749, 2189293828, 4003306605, 2104718709, 2248125819, 1242466666, 3425122185,\n                2526773969, 1997783773, 3366295660, 3638946293, 236310604, 3074020533, 1544508523,\n                2720105666, 4275312048, 2125511485, 2928099726, 3115904574, 1659470574, 2302631502,\n                2782437446, 3351759933, 3997936888, 2966997408, 3158966556, 2819300721, 1647111112,\n                3003598038, 2858959466, 2179510155, 2584211049, 2202151208, 3064305858, 898246753,\n                1503685985, 3011437597, 3645693595, 2240988222, 3440343576, 4238868402, 3504605984,\n                693969911, 37266154, 53849195, 240646457, 1676768678, 3078948456, 353299888,\n                3398599422, 1225876435, 3474721352, 2919885255, 1645273187, 1329251097, 63136291,\n                3744051145, 3578975497, 743346836, 2992151082, 2097992510, 2029339826, 1064760489,\n                4287623009, 690583934, 2137261889, 2523731672, 2989051237, 3080671706, 891097198,\n                705467787, 3974619780, 2507988307, 3580098689, 2900468355, 2065761093, 1093422169,\n                3699292714, 3679511724, 1376356943, 190833907, 1757023356, 2392875706, 1341718208,\n                3312756053, 1335629721, 3842952633, 1585023162, 3483717351, 1166983906, 3797224124,\n                2704194560, 3663191348, 1943345575, 2900370013, 98538425, 2337184175, 665720157,\n                3985681094, 1514818198,\n            ],\n        );\n        test_only_verify(&[10; 100], &[123; 20000], &[123; 100]);\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[10; 17],\n            &[\n                9995257893114397114,\n                9401504468144459131,\n                558615837638945228,\n                10733662027974786928,\n                18295107704289976677,\n                1814706268673753787,\n                12474943759854623335,\n                8814778832826774208,\n                9159057654048965906,\n                4451260977376821357,\n                18241701617364042056,\n                6169989192350218482,\n                15071965537117101028,\n                13509168527678537782,\n                12224278653171635329,\n                16077066393714953826,\n                1433938684868066489,\n                13014970036232570373,\n                899282336249563956,\n                3089487642230339536,\n                3787737519477527148,\n                16667686214395942740,\n                8787122953224574943,\n                7841835218775877827,\n                9693303502025838409,\n                16122224776459879427,\n                144327425397945219,\n            ],\n            &[\n                2350654041004706911,\n                7834348511584604247,\n                12756796070221345724,\n                3842923787777653903,\n                12373799197090248752,\n                9712029403347085570,\n                1426676505264168302,\n                10586232903332693517,\n                8387833601131974459,\n                6290888746273553243,\n                9503969704425173615,\n            ],\n            &[\n                12688955427180652274,\n                7641660693922643933,\n                8789985477567049482,\n                5698832637416200787,\n                14684840547760545685,\n                2822100467869581421,\n                3557573565928866957,\n                4409631974409684922,\n                16994214656621423610,\n                4513108841166793667,\n                9009005527785483287,\n                10,\n                10,\n                10,\n                10,\n                10,\n                10,\n            ],\n        );\n        test(\n            &[10; 23],\n            &[\n                748159237152854524,\n                14199895651244313572,\n                9044210482484213648,\n                3880401870711113518,\n                1694971440240542063,\n                13547801197479934494,\n                5244069077418598572,\n                17329479401291658084,\n                12613311850003558282,\n                5618071535926791206,\n                16954511293879569524,\n                8600749590433482901,\n                11708546551548237376,\n                10879843710159659952,\n                9101678715417935644,\n                12126242459863584426,\n                17259866272884195621,\n                4418382641453775715,\n                542305129955142216,\n                6563442437678466173,\n                12794875758080454756,\n                7461769876910639905,\n                17925257245127463276,\n                5137728719899113924,\n                12905981752247605071,\n            ],\n            &[\n                2654882163556630563,\n                2047318842992691178,\n                17944530594807555614,\n                17278864523505748498,\n                1160166728089482341,\n                18368953657130322418,\n                3937719995815345698,\n                12007028340444721520,\n                1496744539933999053,\n                1476923054783110845,\n                6551619938265612084,\n                16801911333947266527,\n                13986495313155597995,\n                6571595571877061463,\n                10140569634762389822,\n                16210530410764331582,\n                15172903143228403872,\n                5831780706385794192,\n                12288937301416472500,\n                16224579586702000460,\n                14545605105156691376,\n                8614987803254853144,\n                16629891239728134900,\n            ],\n            &[\n                18140975738986113396,\n                16765596268029991308,\n                14497740378349400824,\n                8834432760455669008,\n                2081502095596466916,\n                16785570606386467383,\n                5299348241512211807,\n                17503170383548190207,\n                16775442261989831354,\n                8131705923782084593,\n                266320274487676679,\n                6602256474512308593,\n                2102043233085822823,\n                11614561527212258722,\n                17915538208051341722,\n                5710195504177465517,\n                2094480568485157388,\n                14339014023087152780,\n                6947889352398323832,\n                10985139413433625547,\n                12373170520775701923,\n                9198039438688117621,\n                15475638737141339650,\n            ],\n        );\n        test(\n            &[10; 56],\n            &[\n                14660214196707223375,\n                14265972253040120215,\n                15506320303100465818,\n                17085621003033826581,\n                11203337550022453944,\n                15493204961705835371,\n                5803021083410871755,\n                8112917457002746745,\n                12663484193891261040,\n                1721048899893287199,\n                8062187621610464306,\n                13431761655884620090,\n                7331427712144411262,\n                3626934647030185267,\n                13231383914073320042,\n                11637171044660683638,\n                15189928975258171045,\n                941827519265124224,\n                2992792486091076914,\n                2044203374633195985,\n                8310380355675814732,\n                1677894573715118386,\n                1863631713396879617,\n                13750903464355877990,\n                13561054993991137710,\n                6643134394212488277,\n                9782189322903525535,\n                7987880548748269544,\n                17396502810230452231,\n                9355336424066456608,\n                6974435047841500624,\n                4695995454788932008,\n                9790410161672155866,\n                7324176676989916049,\n                14873447357313289350,\n                17933513319573948354,\n                16221633809094225356,\n                1119296061370324791,\n                13659405622992751643,\n                10536448431317839371,\n                15771892335411705715,\n                6450515195565208913,\n                12583173873673842188,\n                8943105588740166659,\n                16781237121411387206,\n                7355272525679995848,\n                8924936502454129260,\n                9464007023044637842,\n                2392086820925613645,\n                6952992660961663836,\n                15709161892606831425,\n                15961199354349516091,\n                8170938350051511007,\n                10106337242460916657,\n                4519632767875399815,\n                13966478644099829332,\n                18146666299243951179,\n                18001892575388798951,\n                17442461326088111501,\n                12996149925790510613,\n                15125238000270787220,\n                13458137050174539117,\n                7565676737178758148,\n                7820895745333505106,\n                18391820881894926862,\n                17227107494212736312,\n                16170524482788524562,\n                18292226432698054709,\n                16409124153431213414,\n                2622798522164114141,\n                2030148142272451724,\n                12631034221630749586,\n                12521714531249855181,\n                4869764655816857917,\n                18312880399388298885,\n                1881841240505020002,\n                16686085102712131293,\n                1638984612454565124,\n                5980766772519196081,\n                14473546029553426533,\n                2610255570241349719,\n                4121823778233332328,\n                15196027812344512481,\n                17634932614139407184,\n                14566629132274047837,\n                6629067916649366603,\n                39453246491293667,\n                4118307938296638515,\n                176389639877922730,\n                2385844666265721927,\n                14424300909552701177,\n                2596064544694255252,\n                9262830285738421829,\n                8366979142044016136,\n                12451088247268499723,\n                16456341544263224076,\n                405434591376297036,\n                5989071471671786526,\n                17922319711997177283,\n                12402685985480014221,\n                11440567647536028583,\n                17109382986734751589,\n                1165111999013207871,\n                9042409351611763515,\n                335396288523389342,\n                6889397323074150916,\n                13998858741906849976,\n                15927944587197048898,\n                10995067153735213576,\n                13255077995174337515,\n                11985913648073551062,\n                16606199253171990948,\n                16615211378568935152,\n                13000672060735124358,\n            ],\n            &[\n                6726150808576237754,\n                9590776370558469124,\n                4613857594775205869,\n                5605914158178321857,\n                12627075307783464761,\n                456502911636413728,\n                6201419543988208076,\n                12457367465345491402,\n                9194484469177303126,\n                14469237774454463326,\n                8872571916644400618,\n                10371861714649740250,\n                9551882050917532587,\n                1418647961867356190,\n                11742587182398063873,\n                11015016132415914044,\n                8777839015232205587,\n                11080046461630228193,\n                13740325869131645472,\n                17716201322003396844,\n                2184375889136968144,\n                2744007897878529583,\n                10107840174031679018,\n                6807210551800087042,\n                3927845063936277496,\n                4657264236265855475,\n                18202437017170404187,\n                5332422779150911238,\n                15515262280249200267,\n                248667350560422394,\n                3473467338029486524,\n                5450666559053310869,\n                9114347711968955703,\n                1001965327187909086,\n                9391480248060184246,\n                9069754537718985217,\n                6108113375902101471,\n                615335597740998377,\n                7341924484422171664,\n                7557688311245960406,\n                10629369615492290302,\n                6551022068682485711,\n                13009629572214277263,\n                9801266711191462998,\n                12475469715378400041,\n                16817728089246511388,\n                5318131496704799888,\n                14034696640350324685,\n                173195053797772988,\n                9465580662794117123,\n                9395502290798332505,\n                172507413604644051,\n                13462235362634225088,\n                9267822876689174860,\n                12978933587961252639,\n            ],\n            &[\n                16979197013852036393,\n                4534519222829727882,\n                5127955051936920534,\n                5669732551578654322,\n                13787946500638697314,\n                2666880029397285003,\n                18286001525339884787,\n                3747928243980886079,\n                5670276194023029484,\n                15201258611907138387,\n                6046915833599742673,\n                13282924752646783062,\n                18026143804639821221,\n                10186643213552896189,\n                17209309200088910354,\n                13215180252119768256,\n                1246399679408038126,\n                4186715523775575401,\n                16756959752065842207,\n                6600048850655585015,\n                4543693866439677976,\n                15594233518271892275,\n                15247811862837572166,\n                6322126320582019533,\n                649809830609098083,\n                5229876751712742127,\n                17719948521867410031,\n                10737539927122287433,\n                12476905306147178753,\n                1539850235988803702,\n                13572545877865905325,\n                11163694899331373883,\n                7882148214994127637,\n                8164419266634080608,\n                5782587821804107698,\n                12155391719814216620,\n                8020222143449740150,\n                8489927257914490530,\n                15688922762526028920,\n                207673185831465902,\n                13825819490340731785,\n                14207999229863934400,\n                10163751595898713958,\n                17777080404153962435,\n                17016927136773389232,\n                3820023214020965653,\n                1892439588667561762,\n                16909683715900311832,\n                11919385779232783009,\n                11201007117990222527,\n                8700983269916503928,\n                5034192113764375450,\n                12790439085134048151,\n                17790018876931315900,\n                5953092655978688336,\n                10,\n            ],\n        );\n        test(\n            &[0; 1031],\n            &[\n                18285600144381611747,\n                2607658718107379546,\n                9747604544742966856,\n                2960103437306950033,\n                11333576199308712527,\n                14238003202284088532,\n                16265332193148604979,\n                1379942304307770309,\n                16938783330207677640,\n                2745252988447228002,\n                6791234087903673829,\n                12518174636027607009,\n                15674280970395865818,\n                13974288954585950791,\n                14841204964098561443,\n                8748517132169388864,\n                17525897240098709564,\n                16349048229068678114,\n                17968982428715890523,\n                9358013674764648602,\n                5199229606169954727,\n                422943872008603371,\n                9250194632016078797,\n                10021555560097390790,\n                2684614891063859627,\n                7440654004485895845,\n                15497536988658560429,\n                16091759101488274182,\n                7624403524401510649,\n                10159556756468762769,\n                2567573898157529790,\n                15609657766585643253,\n                16236943306986434793,\n                5890548198293774422,\n                17362921261219419202,\n                2808858681174890249,\n                6640440299319480962,\n                4326748503634915406,\n                11456055721778818238,\n                10707187402450482341,\n                10505948868316563545,\n                18366980076276187881,\n                15068095720303300745,\n                4952650647951470154,\n                15911634980226720120,\n                10740745397838202379,\n                3200127162032008025,\n                3763543940730164508,\n                3723483274937556495,\n                17871783614248259146,\n                8786059543177366813,\n                13050056601003380055,\n                5623281846050325544,\n                8511114651096961385,\n                10891975825673952044,\n                16080052858418260073,\n                7171941023859325850,\n                2503165103241590389,\n                11967819128596062687,\n                17746426492658731021,\n                1524291256148953421,\n                2076038155471824980,\n                5880985691677435840,\n                4713693495653829540,\n                8577899432290161344,\n                11976146392187565938,\n                2529575305527670284,\n                3765314673643814808,\n                7234028569335439232,\n                12375682646064399341,\n                7101569992574162906,\n                11098657045492285566,\n                1153652218824818047,\n                1210454437960036069,\n                2694638310421669121,\n                7870059579873173861,\n                3508868899875540240,\n                13609981818610730741,\n                10703439073683625892,\n                13071420953159015459,\n                13716502475013538938,\n                10634244764110852465,\n                16403497596959564382,\n                15306415780193612609,\n                17601327182445704540,\n                18298349615021078405,\n                18111916165749794999,\n                7537294468737253688,\n                7386987937618099419,\n                10775482015504178918,\n                8525379645714838775,\n                8788609183023289620,\n                895207535126054757,\n                17118106622782691546,\n                16749800484842219686,\n                10933310771357651927,\n                17045784651422893806,\n                10055875188754575183,\n                9519498699655590213,\n                17322601174638910336,\n                12118730165352641482,\n                5930728976613565641,\n                17159697904528121051,\n                15309680603600886131,\n                2354852814839706361,\n                1866864355164982520,\n                14799678913936204761,\n                114516480202556771,\n                13374320542339641716,\n                17948849241297689882,\n                11937303202723535389,\n                8708253685264852524,\n                14784022410383824926,\n                15741150074911773529,\n                4751508515383369506,\n                6753819133127024063,\n                7615256392835158829,\n                14330334546462075477,\n                5916715905113385520,\n                16699087896061936717,\n                2161501163497237132,\n                7657705954734728178,\n                13842299391403386537,\n                6172027960597539813,\n                5307601271781038790,\n                4555363624168980660,\n                8897561972602250232,\n                492135721000809790,\n                196374542645899516,\n                14990889098212601995,\n                6381940097804056460,\n                7088456247368733765,\n                174918913838309902,\n                14001140535865588809,\n                16643163063827173806,\n                1238954875765713073,\n                13202778059857945377,\n                13892311264186089515,\n                13771970066908683469,\n                14995846051430041367,\n                17421145547571170005,\n                10821698378431695436,\n                5316647583697276386,\n                14051654090444941132,\n                18388943018780729150,\n                11259779711269878259,\n                8742581111664031470,\n                8889827116461862655,\n                17319531559654594882,\n                6500455467003400955,\n                3959184730122082747,\n                4054561166041887982,\n                17316966724931034861,\n                1607293446195331113,\n                1556357414629043861,\n                11011377910730701009,\n                13217502480646592162,\n                5556764467305459566,\n                12021589498137324260,\n                531690648537094954,\n                1038223775874752655,\n                10112707642670009067,\n                16909364180557997068,\n                13549292338140530580,\n                14089674983696767092,\n                14960833416043686252,\n                3361732906192010803,\n                15411952217752187419,\n                475547270098839964,\n                8227352829235176532,\n                4333410121135356569,\n                16974375358381043398,\n                7462799035629267008,\n                3961814110661375506,\n                3191195952723002366,\n                15267463856820101363,\n                2682345599906528119,\n                9202835087842166762,\n                5753494002443879006,\n                13496926465554347490,\n                15537050413782275199,\n                4005699994847427717,\n                13011783168070790177,\n                16932430119108925312,\n                10469912374234875027,\n                5996081763274312546,\n                13299322992254047535,\n                13566444816251120959,\n                13441242515242491906,\n                6531470165275421029,\n                6998803913624387519,\n                5190923639408924125,\n                1301326112306077751,\n                2724835656803633652,\n                14868270067404848561,\n                16428689823791581153,\n                6363562758622431773,\n                5795421246045082577,\n                13738077193279334339,\n                17818084837848061577,\n                7409215264364848571,\n                2893214122000373991,\n                4066741278513513286,\n                6208913273098798518,\n                5323770029909018782,\n                5551337708190405618,\n                10281953507639521630,\n                7674048265312145606,\n                13913805095945202464,\n                11645578449852204207,\n                5216827728522108969,\n                18149089235876418482,\n                4193193659542496963,\n                4384037638695340997,\n                6264405355262516799,\n                5923041840648053673,\n                18445416708501282570,\n                1449616427668184913,\n                17814282379016188485,\n                11394546105942760801,\n                514272123860845956,\n                5487867953647208460,\n                9765982880054791980,\n                15269612196572547812,\n                6933672683776753268,\n                10897766962490536850,\n                7963503740124897799,\n                1249067770622312125,\n                8521634516253063564,\n                15047118858576393194,\n                3052485574284313450,\n                15762145598668916146,\n                18313105704770544279,\n                6541634279146063106,\n                3775400747866844137,\n                16496810669859720010,\n                8379319521731425820,\n                10800415684660017782,\n                6142541123129235279,\n                8861768666560539302,\n                15721050291326133652,\n                11134786092605171040,\n                13017548541999335364,\n                16909509841464459084,\n                8484654924270783553,\n                15005512331960977142,\n                4074672441814183738,\n                4078543398182843194,\n                6773998236248908357,\n                631977413504183184,\n                9491750397437496755,\n                3377999220825657249,\n                3346615552296940898,\n                17604589720878522247,\n                5769086022977878966,\n                17347842858220401404,\n                11931418629108149400,\n                14490915772427782374,\n                11545152969051431084,\n                18194530049847403452,\n                14802318193842666424,\n                16217304261948074309,\n                1412773250833563909,\n                7479345161017490691,\n                14305628603682480019,\n                14047111540339531390,\n                2202019933845371318,\n                213291111871207451,\n                9537101822050445095,\n                360483935799398585,\n                15821799940301882413,\n                13587044781648265473,\n                11158232757574497759,\n                12493764616797894572,\n                12454593638118113923,\n                16175783796857016626,\n                11972175061436709392,\n                14628387199635430458,\n                5253379621963585234,\n                6809274079261887574,\n                1124840670828961539,\n                5990829238947221675,\n                16084193379498378212,\n                6869638953004510310,\n                17906409028525617365,\n                2739791577758847487,\n                480131078003075884,\n                16023370915391221306,\n                15817682603522356534,\n                12423449398808644199,\n                14130320721960901031,\n                7934273914237433979,\n                786249691033407308,\n                318299827682676802,\n                17097143809787660310,\n                17521193394806881361,\n                8643211685837497345,\n                1204030043754228035,\n                2676537878172957478,\n                1780844249865247048,\n                1857038044392024228,\n                15537174113724189402,\n                15216184620024948614,\n                18295257315773355758,\n                5049495368122551869,\n                511689711728309335,\n                16940513174832634299,\n                12104504465679211266,\n                15914220570778735059,\n                6279446781938212962,\n                601029894044123455,\n                17804281207827746870,\n                433540216199633732,\n                7944481812184613751,\n                3853777775611712418,\n                12126936213601232312,\n                7065913778676807607,\n                43238211455364752,\n                8192260579196809431,\n                8266744677261407642,\n                4334793912650253838,\n                12956232517663155469,\n                5369404211871099568,\n                3235414488456415006,\n                12567595135095181283,\n                13364037675200086203,\n                2815554933029326376,\n                6185051196142844265,\n                16989212187178652008,\n                3878956585408701458,\n                708958585074504373,\n                16920922562467588927,\n                18249699025766906652,\n                18027337540317897651,\n                2618966708286475266,\n                1113776870378384593,\n                5988471205905783011,\n                11449408349082147321,\n                6427498821108845882,\n                8757628250113942992,\n                3713195263318788838,\n                601232850676293890,\n                9498794059653193118,\n                6534298968814526870,\n                12486527138072517297,\n                15783607638066166551,\n                17817123635789116996,\n                1248377855370621035,\n                11141540237607695650,\n                11310946791190236066,\n                12846390650128150341,\n                15186900836698527641,\n                3867690890119912186,\n                4589172752928224161,\n                18406516299291763072,\n                11413251654981660385,\n                16024801440525265600,\n                4278405775100889986,\n                8755603474239908996,\n                3160069975842943114,\n                9906744402561181341,\n                9965035381218832722,\n                6752543667701180453,\n                9346639648731189767,\n                10661232594877011901,\n                14936909082854570803,\n                1969452932415658459,\n                1696145335740060250,\n                18164995195644723626,\n                5001142711409868759,\n                502680569449519136,\n                3022117952710893422,\n                10177903082752941255,\n                15652975217635236869,\n                2966845407346038740,\n                475611270044318476,\n                16066077773226714888,\n                15255919358962415817,\n                11732084421089027684,\n                4677384405854396649,\n                4610350216539332701,\n                10328878907789481841,\n                6555568935797623159,\n                3017832515483377819,\n                14707077320201566872,\n                12590581217649731730,\n                3161603588075729925,\n                2563665003397527163,\n                5979170469664323613,\n                5626012705821413010,\n                14527466196441398570,\n                9288633927607394750,\n                14475257195709120279,\n                11865264300717431518,\n                17136126069177251144,\n                1473429666850111981,\n                7510246272136643144,\n                18310164183004169194,\n                3593138027022744772,\n                6350576143506118040,\n                12773591294872180021,\n                4700465661075210908,\n                18143542497507479548,\n                7719757932210686713,\n                4338121025681527358,\n                15571485830471842974,\n                16406722845577898376,\n                5721314859539898709,\n                6589287198671761501,\n                9745964795756887415,\n                10659452091068591333,\n                6690465060747950210,\n                728586915321808599,\n                8500603684008829799,\n                6301121250492508617,\n                1984503548524816268,\n                18268190305907234300,\n                7454276134026583117,\n                8547492859943863047,\n                9499474055416732782,\n                300834181303701699,\n                6423420221300563233,\n                10906772834067949181,\n                12139236772746843296,\n                15479617127388528892,\n                7255634393137870745,\n                422813312578980582,\n                1148428423488055078,\n                2405372466822606988,\n                18202859592780650711,\n                15123472874738759666,\n                2160560009262204586,\n                1220679802754985663,\n                8755041458565252857,\n                10511683773218681884,\n                3102123453859609904,\n                2170460789136594842,\n                10540612896965819281,\n                11507452270722296921,\n                3888033478974547053,\n                2913172211662715309,\n                5819754293645132724,\n                5417423241393498910,\n                1121133064615112577,\n                8899735394209007976,\n                17939515994389118968,\n                3057735335191827376,\n                6167592388365551096,\n                7859032161115089000,\n                16392857948131842701,\n                9672772119042623246,\n                6861392074297507574,\n                10079830057029967718,\n                1610021695530123734,\n                11499290474395739628,\n                18357287834621605730,\n                7842767805813604560,\n                17595414094496571456,\n                7727166516961623663,\n                5489874195960679366,\n                16978517381214022058,\n                11807176188692933608,\n                15778362166265505627,\n                12826269652469979971,\n                7799517220815997172,\n                6941343467007860979,\n                14716681029145080878,\n                5685272761645196256,\n                13841850638623453280,\n                18117357664247936176,\n                11360524534267913074,\n                18408319184374782489,\n                7834872787814949745,\n                16527576874764684677,\n                16576008924894848236,\n                12304125447826256834,\n                18301056937365686021,\n                4783517752793787963,\n                2014695633627143026,\n                8288284640512774782,\n                14976342552024779031,\n                2436344641520555003,\n                13990286257760881060,\n                18118120610252892651,\n                8432102189510702685,\n                9013208900764457155,\n                15956895100219663594,\n                11965405775699735022,\n                11479704069694999185,\n                1315304162999565265,\n                7619720903122481473,\n                10798255112249544769,\n                9067939483463584201,\n                8242338589636256000,\n                11595456341434427053,\n                14057071507676286987,\n                13492895734414905617,\n                8167664880787891961,\n                13065353170057145433,\n                1390434145929843432,\n                15097573448811012551,\n                10002618775785350116,\n                13037941058513405166,\n                10812662834979031696,\n                7926490047107184245,\n                5399553758270644040,\n                15603376937288512903,\n                3817798784005377844,\n                12622533130989118638,\n                12217900933744511855,\n                11495811053435066455,\n                17088770095627295990,\n                6282760152901843934,\n                11339571359698956951,\n                10010250182369906159,\n                11956984034096448616,\n                230656938835165573,\n                155123462325204273,\n                16323688331673735090,\n                12405389233556129322,\n                16866268093283320126,\n                8076215192615100819,\n                17788391733691877517,\n                13738263070347903116,\n                17514698963264490076,\n                14361153193344045623,\n                10697613194968260318,\n                398797896589607036,\n                11354436663860273814,\n                3988804407101251650,\n                11718246560466989132,\n                10607955713165345856,\n                12293428353299936422,\n                2774193885283164233,\n                12111880818145942696,\n                5269109320979566091,\n                17700804638146972952,\n                13483325589659749714,\n                7018249448187819229,\n                16605502462498173206,\n                14334331196281817568,\n                17997264741331536966,\n                16942067749941194095,\n                18326105716816079857,\n                2873713554755956975,\n                89972251875212547,\n                11011206003344840167,\n                16263607631557095555,\n                3956845690962774124,\n                15843733851407790844,\n                4532327333478987933,\n                14523922448792187179,\n                671512032483507444,\n                9051952980308527779,\n                5771887136664598504,\n                7318486125138347367,\n                2056863287621362849,\n                5319340499967729915,\n                6771692072764865726,\n                4993497900077789612,\n                14846578576184294087,\n                8749976795074478239,\n                13944161778625889141,\n                13939659589211557709,\n                8674498121103871446,\n                13858955528517010167,\n                6854968788299690525,\n                9785571842093558996,\n                6616581398547260916,\n                11173134838307567854,\n                15020736287331849950,\n                213678875278769463,\n                8136043007787109258,\n                963815884865140222,\n                14383997603758711218,\n                2441395136452256841,\n                2285295004115032555,\n                14143394511135418137,\n                15622142144369079201,\n                16493347221813991820,\n                17474381401274268608,\n                936058552355041089,\n                12942246561895670820,\n                10317584384347004208,\n                11782536454405046773,\n                12350945172113506786,\n                7391214981076111463,\n                7073023377646396731,\n                4011509139909188128,\n                2257833537102580311,\n                7274600296374037369,\n                2769150843750451970,\n                9102426399850639067,\n                8214223108585585549,\n                11637757222275081002,\n                9169116734789273638,\n                13195915003973211388,\n                5475411329499291917,\n                5086118280372242975,\n                17718728186337638844,\n                16105088227769019766,\n                6209815346219807551,\n                2881314910093736440,\n                12490322405428340882,\n                12004395323760866113,\n                9968698365927837252,\n                17316938449682856319,\n                15625883316417529399,\n                12226632472013770838,\n                14161693092908388449,\n                17778030898846793856,\n                13976693691407275877,\n                3477953777282076567,\n                13740936608896808297,\n                17180555612721269478,\n                13416907629329031924,\n                5869124347540464645,\n                13384341358033251916,\n                14313718444333031397,\n                3376219002404246289,\n                339811206717616611,\n                2616093060711965335,\n                8204344482414301835,\n                9186789611379643507,\n                14338727533336579685,\n                12784860191396059227,\n                10489777731949698480,\n                14621154301243573986,\n                13692422118348399108,\n                3784610479458294357,\n                7735714461152647872,\n                12931998015666009092,\n                12887123618479150667,\n                4005389619579094200,\n                12949896351841026182,\n                4274952326880371758,\n                2252542616091249178,\n                11223191016227664360,\n                12276921256190460942,\n                9311103011248164424,\n                14618190821987444804,\n                16794211813689377361,\n                17066759525543500866,\n                7695930135720339816,\n                15636206560014700744,\n                7080595571863441999,\n                16002741097850788650,\n                7266069110373243930,\n                18266417640341330095,\n                12863061635472560818,\n                2804143153090216476,\n                5360410260257436881,\n                10259005860191386447,\n                3129239898744374569,\n                5704118451966324874,\n                2617683975038617110,\n                1419008983250810424,\n                18176995508939903574,\n                3428325565738056333,\n                15807295691769067887,\n                17098475885649833094,\n                435386771621069983,\n                3749240361804507548,\n                3484935049619675621,\n                14151734623085313892,\n                7107401439542109862,\n                9140252282652202082,\n                17139755393802157327,\n                1840890360164731160,\n                13945742659422648167,\n                2993927710006218010,\n                5123393630446195909,\n                12126601606897174993,\n                3757237441333108331,\n                13430475145736272456,\n                141286591810884028,\n                13716994059020442018,\n                16256272733681835404,\n                13021661888272553737,\n                10938682475722641190,\n                16670594791610413108,\n                7581768967654565510,\n                7258449528404661741,\n                16972464178815325271,\n                13103916238623071625,\n                14383222643604888683,\n                9134614536502072501,\n                4484749605592970811,\n                7617523826265603571,\n                286970167644433897,\n                17350844883213337166,\n                9372418001867268906,\n                11036524012081184976,\n                14599471605351296864,\n                14353873970303354160,\n                13804851709719425521,\n                12542207662034387249,\n                5455404902951618435,\n                18208534021141654431,\n                10760289922882806669,\n                10594303509090562894,\n                10523612649331418075,\n                10175165805141093468,\n                3845925331470243881,\n                9968712325133293994,\n                12632170237051093440,\n                14407500129795275129,\n                7039838041956792694,\n                8486437057635491253,\n                12990896208114377714,\n                2169038646525679305,\n                17731701498975515823,\n                12645000352324144895,\n                6940383608615873690,\n                17112601588170442293,\n                9898015000882658910,\n                14088035355956248952,\n                507013420654526970,\n                16055894587901325067,\n                17646639921892423762,\n                9750921155184562446,\n                854792204257329267,\n                1907596925043325411,\n                13186585073232938657,\n                17324756184357468589,\n                13215141704644982246,\n                9990033614756242368,\n                10703741257062175210,\n                17316690423805264994,\n                10087888281338300084,\n                1089239266776577821,\n                12176439490507890322,\n                12695856964012192215,\n                11884436036930363286,\n                16729977556989227363,\n                10923433806234038450,\n                12992592892604117864,\n                1268144030942582108,\n                10300209358150898566,\n                7832544414491392865,\n                6657397193574515418,\n                17331856360490769436,\n                6685863352121534775,\n                4872607912521754323,\n                13925034245904306548,\n                15794800294630432773,\n                4150702655832044776,\n                1922931668614047821,\n                12163445688451808604,\n                6814128619400384333,\n                1631984743731389500,\n                3778862171994919347,\n                15454466802087055901,\n                9264991358295251267,\n                9936918682375797148,\n                18157798989566244240,\n                5581635369737696387,\n                4479378944085838523,\n                1634001250673190201,\n                9492710507275012642,\n                9234172590874940829,\n                8783494515876021547,\n                10628896245581316049,\n                9175567334027325902,\n                18216027702703135409,\n                11634672812751315604,\n                5707660447334077643,\n                10202156378293455124,\n                13892983828551272913,\n                9908193203293924452,\n                17571530454157193212,\n                15072879288037447844,\n                127116006100922087,\n                11771185510908260613,\n                2445074823174851909,\n                10670868476525820983,\n                7425728342067716996,\n                2985971528087667631,\n                7395252277468977294,\n                2997333798387301672,\n                17435969755936090886,\n                2284549800776567351,\n                1549552636061955968,\n                2562232096971944509,\n                18175473291905577073,\n                2694680735549112623,\n                1791226765063856042,\n                6639691018975209776,\n                14450608736185529781,\n                776581885259523327,\n                481545710834071552,\n                17904221072369375896,\n                7658678246624118033,\n                14858939803632465766,\n                16638621759785444057,\n                7852705140401778814,\n                15504288742303235325,\n                16123480377693163548,\n                17580674642691781753,\n                2060059788952429927,\n                8044488423463356775,\n                12159915697800522747,\n                9979462535316088472,\n                11464540989399692426,\n                9723421225194612320,\n                6449580914984939699,\n                9406550367550615810,\n                5311403373873226147,\n                3066770575413693918,\n                633416401733094941,\n                11712977725629062725,\n                4883265930195070560,\n                16189146570612520152,\n                1698905934763835706,\n                950927367170890858,\n                8829376333788190736,\n                7907286046365739950,\n                3164878452294289455,\n                10511755255842705560,\n                2924155429164172446,\n                16124299828159551950,\n                6010099555943764977,\n                12724759932455911822,\n                8127212736140639283,\n                10128696763620279450,\n                18035084640302368027,\n                8781918799260800755,\n                14441294204200284647,\n                1927193541320801341,\n                17060847707989835700,\n                8195209044950545498,\n                4420757359342589946,\n                3727277256040667922,\n                385534260624886499,\n                3266025280223616765,\n                8307518494652840749,\n                10628505726158916146,\n                12481632216062021685,\n                8443059664409740255,\n                17083655987996225144,\n                730490563149619104,\n                16115455384269067104,\n                2382469211629823819,\n                15299473012699513736,\n                2545726390341274697,\n                9566636451267734313,\n                17404798143522728759,\n                12853265630229752228,\n                2172148070178466503,\n                11003520300346660378,\n                1134402141777052949,\n                11771658227786580781,\n                12088790715698048033,\n                17088312113295353834,\n                9858438140481896937,\n                4732279313243969474,\n                9302577460868509370,\n                10413475674288905591,\n                13021872760990946904,\n                9638439145954399186,\n                2342341335564065825,\n                18026701375952328694,\n                5788988813536004381,\n                6112690485750689530,\n                12277817288452946380,\n                7006316162927315897,\n                12091459534025657274,\n                2152473017451714429,\n                7117646493299604201,\n                1591263581497951670,\n                12905706257967317715,\n                9739330975167177950,\n                14245120246238342654,\n                5445126088677322792,\n                8475451974915724213,\n                16532703318231814798,\n                11346158079313546034,\n                2587775018559680831,\n                16042335036595321112,\n                2783584919636232962,\n                9477074304137314302,\n                6679970828349102077,\n                14914134423793746235,\n                8835496380779847657,\n                13649036745393349622,\n                11800533244055495841,\n                10329924636422821002,\n                12857463828194064326,\n                376873602561854006,\n                13991526512239117933,\n                4244930150917248420,\n                9377193637737929560,\n                13470983451570137106,\n                13709193869228195237,\n                873834737899882109,\n                17298475531540644799,\n                5157431525573101837,\n                15694890039292357223,\n                7263973093257735703,\n                12810611197004081294,\n                17159179774131359627,\n                16320123751204284184,\n                6659167957772819702,\n                3559977382115542403,\n                12297726256906381994,\n                10545494770323931829,\n                14423760345131502963,\n                11951650428815262297,\n                3552160721881779344,\n                3921553500551057972,\n                8827773853996085356,\n                13035185276040540279,\n                2431229196115555640,\n                8867095302754162942,\n                5824531700307273486,\n                17795693614810306555,\n                5327408766240893952,\n                16204495625665346776,\n                4520750388436708886,\n                16011790401268552431,\n                13186223796877430470,\n                5894651091707364204,\n                7349710328825984565,\n                12990495590567591633,\n                15789659485048909512,\n                8110395238510363562,\n                7157879492847706094,\n                1855521204456327951,\n                9387090323123631218,\n                6983791028671987424,\n                17264360937175821593,\n                8964335962673307125,\n                4438686713691513133,\n                4609268036048721815,\n                13573223706586323329,\n                4370839728814507274,\n                7190667190262397984,\n                10585250032143309718,\n                5262324401338557970,\n                18436298550586124762,\n                615281048933821162,\n                7892081066718287534,\n                4153026337684348988,\n                1998277297931299322,\n                9570951836837442866,\n                4214601792245837204,\n                12544321637650748092,\n                9861635514343412559,\n                5163007832201827055,\n                8357508302373244198,\n                14941521234529596324,\n                3025149840692592346,\n                1565659965409485275,\n                8113415648323406877,\n                18047137088865383715,\n                4761751436090139639,\n                410742697284005702,\n                8123281234742203725,\n                2300465198396824513,\n                7573276443955885792,\n                18354607580020177721,\n                13826724636992006395,\n                8759796250561912860,\n                15446866439938431144,\n                6466830870344794620,\n                7248618897690538684,\n                10968843377874574640,\n                4538534083565844065,\n                10463149345079834509,\n                7862094636026465434,\n                9363380870281847317,\n                17750231516234915849,\n                10605066658889662478,\n                8651524573226517322,\n                18099624785064356749,\n                9012260115980472797,\n                5112736631921184699,\n                16433387801586396924,\n                11364983784749187252,\n                4592720300056375272,\n                17400478621152089229,\n                9960304372235946193,\n                6810543488590694603,\n                9421463587360187007,\n                11110051932845796606,\n                15820198248392525417,\n                17370225890188484838,\n                5511348958827419764,\n                2047354351196049067,\n                8842128025677787612,\n                2546794526658883557,\n                9990966093285021784,\n                10968573027006701235,\n                8153649946073344163,\n                3435896373516278367,\n                8854351008479838087,\n                15172945879518770400,\n                16101272223167010392,\n                6080119325930559085,\n                18336117387797080742,\n                11495477657407490192,\n                13799378353686928991,\n                814519040394412554,\n                4055424121543431351,\n                17971320561372651,\n                3045424347018335501,\n                9144749175919467258,\n                17693139582687085722,\n                15549618811805620741,\n                10042978303090035766,\n                11250820672049577391,\n                14650606162160854310,\n                681053092156505443,\n                1467784211081816986,\n                14292070206822113207,\n                3356550259250142987,\n                8897529911380186072,\n                15774124171111764637,\n                3608035896189707114,\n                14945841364780812283,\n                13638982384303383036,\n                5615554819198447325,\n                6604755778043315386,\n                13154764512915240378,\n                15781224930202608619,\n                5254282127938948208,\n                15314350610960881010,\n                127785624547347482,\n                553562291991422824,\n                2665385793464509946,\n                11960374868185251273,\n                11044390920977985650,\n                4524189753866435423,\n                11922516208188195244,\n                7322728958220573958,\n                4566122595518047958,\n                9257927878541886507,\n                11778087706650674305,\n                12675707724087743775,\n                14040780876086782366,\n                10310608200410344735,\n                14747492163773576994,\n                14763717547881637874,\n                4519119406094329744,\n                5416745750548195790,\n                8698677371585009606,\n                10540691781438295688,\n                7621321253979898000,\n                12870309033904607776,\n                8766530226422390333,\n                14410571192410377800,\n                5017391940288233504,\n                8156621488957733235,\n                5701635921482105032,\n                8697544584237000467,\n                14463840701596743299,\n                1132393248669674482,\n                17783802461705335925,\n                3379973927717106230,\n                170233915427480249,\n                7721198001501959996,\n                5984888435057942981,\n                11741252369856674270,\n                2667584213579254971,\n                12391311788904160680,\n                6403858222659082204,\n                1706835705335237525,\n                6951651160442697621,\n                3395001754770416725,\n                16336009550495654242,\n                1588611969581977597,\n                3369833199693136814,\n                16679631221398536370,\n                17143410383401198876,\n                10718378066292328788,\n                5098802788047763943,\n                5003995899412543356,\n                7797753734199884695,\n                9804992578690571817,\n                852561252664521182,\n                676543942240459737,\n                12047623372899199507,\n                12688884395525848756,\n                2909502726897081899,\n                6031120528123066491,\n                10187664230696218588,\n                1634984456433807424,\n                13461263282968829173,\n                562535253767547543,\n                3262317265760851658,\n                10159933570831396212,\n                9610081805557490182,\n                10645180788472548796,\n                3825134762043109512,\n                11454131642474959474,\n                9401675919629678678,\n                14450914272139752267,\n                7874801920832590192,\n                18054728540681521894,\n                15303403280502540543,\n                15467520708986418749,\n                7705766485597949742,\n                204013254901132813,\n                13967733294005655167,\n                4001477583895779972,\n                5972807400755250985,\n                1217989087590450380,\n                10862887725324735466,\n                1706534929358469389,\n                13264418588578493513,\n                10626892394654962607,\n                2832066031146486501,\n                6506140673085843042,\n                14326905332890415966,\n                4447185119806812807,\n                10289677945299645724,\n                4459612687423833871,\n                10867968914888905042,\n                6485974059834599556,\n                14142727197114410913,\n                8587964753565667799,\n                8972765350531032618,\n                2292328948393940314,\n                935062418987300570,\n                6736600688398044784,\n                7931198222933701097,\n                12299736294122528410,\n                14482610418638535345,\n                14434918807907278467,\n                2439305975663118437,\n                4480608229958318339,\n                3952066067287563861,\n                14258451016047506475,\n                1231074371015334625,\n                10331248234059926878,\n                748201218435577445,\n                17462982229802307244,\n                15686869687340151573,\n                17053063210448785862,\n                3599854718778131864,\n                9301737618251045483,\n                7627446349617553731,\n                12835054936982245416,\n                6336754664191040283,\n                5870029311999289016,\n                6027766907695007223,\n                4082089270941640253,\n                10932978191544782698,\n                858542788191451824,\n                18173438258887704458,\n                15950175591359254382,\n                10496438189070905854,\n                3761196574957125185,\n                8070795822731288097,\n                14333885717356195593,\n                12907535393235068762,\n                1300746091836895017,\n                16095775835363872226,\n                5221409894943186677,\n                10801943559441670680,\n                2226518879270450694,\n                14144518871296969095,\n                8329328663632421754,\n                14151247548153947290,\n                7005388744793033852,\n                3731783672032466610,\n                5642923046890143070,\n                2243566518435928649,\n                17827722312011386647,\n                3288494091174335807,\n                12802408479052688767,\n                3941775622555625432,\n                13974527790491109973,\n                7184506709498460272,\n                11905130726430415767,\n                12898188848602614942,\n                3336329541205892765,\n                16740350675338109671,\n                335449286526469870,\n                16670399530115701446,\n                3370759555155341636,\n                13153054802454960430,\n                17020347152181004363,\n                16005180766456295251,\n                16035747705790056677,\n                1904525470716808389,\n                1362939978621142721,\n                14268989953945718594,\n                3131759537359596393,\n                12623877369046640758,\n                16034480904634718634,\n                7205849095551422163,\n                18352760423874563428,\n                9294184574071126998,\n                4855176006968938932,\n                13740659884417148386,\n                9678792914697707031,\n                17346691148499799327,\n                3661296281536466662,\n                1858171995289042067,\n                18199380542019467146,\n                18435270579529426778,\n                8792805062170870691,\n                2216926146372155391,\n                3336698928747087340,\n                15361162057883195491,\n                2230334966886787987,\n                6790919905652555693,\n                9523654540872868833,\n                2373039885555601800,\n                4493652711092482273,\n                4848735304745253118,\n                4615650132005261688,\n                7011332091469251441,\n                15051588471309214410,\n                16436499359483898767,\n                5534529923924019676,\n                8031782014972324826,\n                9587715117105518067,\n                5201232572863714631,\n                6949484852216655045,\n                11242297859309211887,\n                5445327566402416511,\n                11759527029723480062,\n                7401655792007047741,\n                12981437329323060492,\n                16627917972301844941,\n                16086064209851186236,\n                18317605428363897776,\n                5479987106722795675,\n                470044962552825995,\n                3263508437049006276,\n                8532199872517472836,\n                179963713893634086,\n                14750710828805195780,\n                8566890372208465530,\n                457434420254160615,\n                9026428119711082888,\n                5051697286542220522,\n                4066845298260571291,\n                15266943848838025449,\n                7790231715639606132,\n                18047039423184779192,\n                7097787949459808218,\n                12326346119319424869,\n                14895758855340221400,\n                270818421368673258,\n                10953991395430365501,\n                10722834322274726220,\n                7175276538034253286,\n                12293270138776886211,\n                10868230614957475384,\n                15568806031450505970,\n                2173332627995000239,\n                14888402241228040414,\n                18405500854031799916,\n                9396217995786697609,\n                8638079772902395024,\n                8700301862255582170,\n                16669714149683986916,\n                11791960995856983997,\n                6941956874526614041,\n                471913500417437253,\n                12645657659237731696,\n                7344954555441957686,\n                8576764504255171238,\n                17045229481365431866,\n                10710908163870404781,\n                11301570355963434173,\n                5971177578976838887,\n                115032958122130333,\n                16996195561179864691,\n                5303610406571283411,\n                1557215249726500571,\n                429079935597742432,\n                6007572072647948719,\n                8793841786368287656,\n                209772504980789061,\n                12514491936429933001,\n                7014555801251009174,\n                5854792368971550756,\n                867919854085761466,\n                11854155159921686895,\n                13142074624110571417,\n                7907850875814485970,\n                16861742288872511551,\n                1208590626489658408,\n                8601279929820923503,\n                2258924690462246171,\n                9585184984627008623,\n                5315828210383196353,\n                1297805663260559339,\n                7398320505542428444,\n                17073967214624996598,\n                17704120650146094638,\n                1299385581680024947,\n                1443489762904405882,\n                13518221354231615324,\n                9070126881206870042,\n                993730884724745294,\n                14081041013869681380,\n                8359943552596347499,\n                6866696380166200245,\n                3837542845849508667,\n                14602652064433499913,\n                14314340020057352466,\n                8839559535694012406,\n                14227230979046046062,\n                10298228782846904508,\n                13298718693240900028,\n                13909155817605919274,\n                8780642200132615642,\n                9412091595152829592,\n                6822145839018577251,\n                8785978531052338151,\n                4948528066049804851,\n                1172628369060862431,\n                5666685907911162463,\n                14153629140204265152,\n                10500845530057771412,\n                14608765724027887761,\n                5087095504941752721,\n                8701919577673940506,\n                17137520717957261114,\n                9199637801040704714,\n                7095886304415555902,\n                15925336741311965253,\n                13077337771490692636,\n                145710441006655783,\n                13157185292334340173,\n                13407008567503772150,\n                14215960022966892561,\n                11985156240556559472,\n                17945288516894513884,\n                14097688271959790972,\n                15505832877271523166,\n                5843174730859038007,\n                16205337090179264073,\n                17606308108912062454,\n                669419080191010051,\n                15851467430769620452,\n                4936909049694472990,\n                9426661750545745060,\n                15134074240235574428,\n                7927257239677744604,\n                13865931916371651548,\n                9055694221969554578,\n                18105938911030359772,\n                17344312477772739728,\n                7984780979580024449,\n                17946659128143746086,\n                3659014353178730517,\n                10881946920507249755,\n                9643240829875041416,\n                9979006042478131099,\n                3624673912637648606,\n                10183097162206305022,\n                14705929380474025749,\n                8560872261129163553,\n                8542571307034562924,\n                2849336599501641328,\n                1427173016960915063,\n                10561422500956348533,\n                13953646915815013961,\n                14711009426065697276,\n                17629582482698947067,\n                5068672373293663589,\n                10328236305608973133,\n                11390625625852214740,\n                16171676010227409920,\n                12007752012156277746,\n                8787339600696104751,\n                17147558071877953304,\n                6243146155416198819,\n                16781815705425825152,\n                9276534213532622927,\n                5681999116735330218,\n                16852010554258505062,\n                1705868855435043353,\n                14818213196970587370,\n                9256091199810743680,\n                10438037318676504268,\n                16794099631419865392,\n                9815261792343983998,\n                8286783569926236889,\n                337573434858179240,\n                16820096306284770618,\n                15966431763494632363,\n                6481208570789422743,\n                8429344246220730373,\n                27262454150324780,\n                9516508385964067765,\n                12876008564654096078,\n                4071754764426708210,\n                11593726207040321843,\n                10464906996437266409,\n                17795281436982488931,\n                7949644313068982658,\n                7004988298640898067,\n                12037768710549869791,\n                16790409316897618369,\n                7084103797769437957,\n                2419445775321185382,\n                8074279743518467644,\n                8069323749479463736,\n                17160974715554385442,\n                6446198417065372686,\n                909199233418090118,\n                17988046405451941411,\n                15619199660230837101,\n                8540771809211736979,\n                15004059727603767665,\n                9970067037279458294,\n                18037810830226270966,\n                7395784361237814976,\n                441608911830412969,\n                15193617525949907726,\n                8329750585903900376,\n                9232838481221040709,\n                13862722871242295122,\n                2651785001097390772,\n                13513885689469842635,\n                2916635381190975954,\n                14673366675350976320,\n                16796162449704211211,\n                15311238965453782301,\n                17048079530325153354,\n                6357896971279650981,\n                6912501188214061635,\n                15767706566209693421,\n                4950547784710662682,\n                6818275469676220067,\n                6311416403137682772,\n                14192827820659451230,\n                5519753761822532883,\n                6327790738344616319,\n                1571492847028444517,\n                519836968001291628,\n                8880684714326015791,\n                4414274058554177288,\n                6693694082558848552,\n                9180328506312734588,\n                11851754793034588133,\n                17892308745832908148,\n                12122989628255788470,\n                9813496966285232956,\n                10955347908495147392,\n                7570827623140202413,\n                12207236341183232786,\n                4777412212063025006,\n                12385252236023114447,\n                9508166476039999651,\n                114906234504385867,\n                9207258060511755437,\n                9210800729712345963,\n                5771423404639548192,\n                15194614200877751860,\n                4338352328776016735,\n                2610599495858282641,\n                16733979028371628176,\n                1929910361255473211,\n                14137591116693762330,\n                11276030669834631098,\n                8384908437274376663,\n                9932945040858512861,\n                6671057894832572720,\n                15600691762738444868,\n                1090424207156031951,\n                7633234269493162481,\n                1452672955493924651,\n                8042177265524791320,\n                5918487395429243286,\n                6071477929355428400,\n                8446553879294519239,\n                17238305490194970122,\n                8987047329207310489,\n                12398791106166157316,\n                15174911221193868718,\n                16946345338721827201,\n                10949948458544444544,\n                17318691300002579588,\n                3998415180681624527,\n                12750967780890975278,\n                288347833998723232,\n                16095212211245790724,\n                7822321122528030405,\n                1109063169170634828,\n                4652215944166612902,\n                16803163450585461189,\n                2776655336762420387,\n                15642000619067002463,\n                2018031858324511467,\n                11237756472829950832,\n                17565143038179107620,\n                16281738469740252935,\n                17600775725533342946,\n                14750124410220606835,\n                12883103971220877489,\n                15936542280450981255,\n                9714323865324229767,\n                1469778854158587075,\n                9593652974682074282,\n                11762461414294133530,\n                1404229929827068795,\n                16503900992928085410,\n                14684251465993475323,\n                17706137844161464268,\n                3909560365123413776,\n                9861484314350641439,\n                12009083324415037686,\n                18169123171153377641,\n                2393555352820887974,\n                12841835092045423984,\n                5564097118032313065,\n                12777929502410633133,\n                5078336225337553091,\n                8694020844593690446,\n                11388328638584884970,\n                13970084235020262491,\n                829772823417380360,\n                8286179729255644084,\n                957139202750627952,\n                3221879212666198953,\n                7645002751366998370,\n                16715354970243034507,\n                18304845819423800855,\n                9447343833119941047,\n                15163436489241423867,\n                2479924668890227186,\n                7818020209349584296,\n                10580682200967646169,\n                13911404593504958709,\n                8718275660345998055,\n                10124290490841409455,\n                7651303722187917624,\n                8976889705380896709,\n                11163660337280624646,\n                10388784795451265724,\n                3541771203499561964,\n                6075152751154669243,\n                2218667547472367527,\n                3995516111323252367,\n                11180655997089000245,\n                5073383660790586917,\n                13458152992621454755,\n                11676714551890338118,\n                1494799466123513971,\n                7327872328474238339,\n                2389581909384645325,\n                16687753253842922782,\n                11699615151482669193,\n                14774804959571915475,\n                947896829667145566,\n                10573954710522391072,\n                7072571908216975157,\n                1921454675444217366,\n                11232731567954977537,\n                14840397076140631292,\n                5060980672779376677,\n                12975040048834693618,\n                10752224255692434704,\n                1306885046650589222,\n                1930876755170305305,\n                8739276995254053408,\n                17062175909187112484,\n                13994219820475631601,\n                15241051299228638903,\n                13189674117437271785,\n                3224946313788614445,\n                2946953495584212148,\n                12515092889993340415,\n                8549243107224308830,\n                6555967774604787675,\n                17074340742411084655,\n                15860252206376208136,\n                2452901849982359121,\n                1217176756850333549,\n                15260442969744536089,\n                15266619117940483626,\n                3092040621234773226,\n                8592622982489602359,\n                17268283100249965729,\n                9118863795573669565,\n                5004589504450812591,\n                6062182260926951061,\n                17997691517876082652,\n                4684918577412859882,\n                15422706458772273904,\n                10373853167444581181,\n                9008368442714488639,\n                3624691764843327336,\n                1028359463583846893,\n                859230892908817598,\n                4558109131236939269,\n                9197636145007824268,\n                3397702897203024845,\n                17645318682095346025,\n                297912191657103235,\n                16707811002284900618,\n                9544713268645707384,\n                18174588433767285273,\n                14115044574398526220,\n                9550382630286578375,\n                5669098498675234593,\n                1419240760313025600,\n                2624357144105750680,\n                1883325833631791743,\n                12465653732071455581,\n                14016850785680848114,\n                10853862374929837476,\n                9213307118918963573,\n                17446748283231651532,\n                6944359057113621208,\n                4376214699313790455,\n                4272171302826636053,\n                1361571807732899930,\n                15928311517924806859,\n                10979193193168197302,\n                14315748858106823250,\n                11415251230794226377,\n                14341688199410222112,\n                13372316746789815573,\n                12205797915700991132,\n                12054245058919264469,\n                7420566807537884143,\n                5432588773028217373,\n                6350587654471565537,\n                6531829368743229731,\n                2207976572300046135,\n                12703622166413274712,\n                18356491416550058865,\n                11743861089192075323,\n                9975481076082250423,\n                5270519543247843824,\n                16596875614345327407,\n                264970638689993857,\n                12731851329939038802,\n                4100374548344342900,\n                11696626303514932259,\n                5795347109604371486,\n                4018536166291403802,\n                11605839014492166891,\n                4046122976220313619,\n                7173051512574373511,\n                10760222355399775007,\n                2397452537849365173,\n                7000689557970901078,\n                3508218483424754056,\n                11249130935335670874,\n                15485017380487364008,\n                14838383309738250533,\n                1654265944033471910,\n                6550408986795246586,\n                11574017534658799615,\n                4938545842279886871,\n                6987608227293293739,\n                8490763818451756454,\n                15553940026252549950,\n                6498239556873819401,\n                8894315085699368208,\n                1767452481216158212,\n                17391068041642225358,\n                12099770647562592260,\n                3232275359468560052,\n                9875417733360604587,\n                7344425724555447442,\n                18431729052975636742,\n                2951164042491135904,\n                15903903429564563858,\n                17834292681718510486,\n                4198460729209826867,\n                18283343945753908147,\n                13114879247072451198,\n                6308546439134988873,\n                8448793227573510403,\n                12883523838880467178,\n                12608354838733343984,\n                12284418193790956340,\n                3099459343498815410,\n                3160460005758859474,\n                17209423043124247155,\n                10299954565801063517,\n                17312198705527288316,\n                1159079074290265282,\n                13803764368072178660,\n                12357928111570535493,\n                9319226950413258817,\n                7861389264222959398,\n                4208357822974886032,\n                4724453996000826506,\n                9219506857747054473,\n                16650755835313196333,\n                4602357483273387357,\n                8421668150799174361,\n                12464268335381289971,\n                16842331782835636444,\n                2164847798539863920,\n                11848181286892607238,\n                8483204622866252940,\n                5177013341061819166,\n                6794893916803855304,\n                830729528874930746,\n                10838023688403983614,\n                2936119661394195602,\n                16749442537019148931,\n                6282125361565649956,\n                12522652324110588825,\n                706946363036865451,\n                287377191870510960,\n                4079038197618045672,\n                65600267963984525,\n                15852196146124192732,\n                7791496333170096323,\n                1197307315361468886,\n                12564376588501612052,\n                18287064409980818748,\n                16513413097113895910,\n                13772586176619885924,\n                17412579692431697526,\n                9943582674770693553,\n                18017460763820483721,\n                12774668415999817484,\n                17419661422487800791,\n                8542296650831811427,\n                11030794367359113173,\n                3091992835617551759,\n                6647390664467556203,\n                4760797422569339325,\n                15821430759187595540,\n                15905919720868415262,\n                6964495470980486330,\n                11481098497210815485,\n                13606157196874073055,\n                2545548939497776096,\n                17492549168216383449,\n                976625893298873591,\n                3307888858281262315,\n                4406331424039826265,\n                7251492960589745703,\n                1462803411594068207,\n                14615947077492017745,\n                14477853980032711958,\n                6580067844089943084,\n                8164600499091902269,\n                4672103301095852237,\n                355042099720565535,\n                11026766258596173656,\n                9849960052517135155,\n                16725670149953992537,\n                15683028676578831515,\n                10104782290810509683,\n                4905343590849641899,\n                17726532108833531580,\n                13910286230069122723,\n                9139857611408342006,\n                4873918044036171351,\n                5211230260928194081,\n                4862798578450111352,\n                8040863435679951765,\n                9157211979753234216,\n                5969001182224545740,\n                14666007377730777715,\n                746412171062253704,\n                5788296420214704699,\n                16052313287704740168,\n                15016980204491105152,\n                128634126176999080,\n                12474550947728802418,\n                17798334047543705551,\n                16546317352521543345,\n                5935130659172645630,\n                9017751516052971809,\n                8734332868677069231,\n                4489180421214586024,\n                10852153455030219222,\n                9452853792027507,\n                7518566350390737179,\n                226398539584556263,\n                11348207575144575782,\n                11286381051277848898,\n                2699324198517442237,\n                5176288375717881953,\n                7814733078102607208,\n                2870574509136744908,\n                13870395192961519685,\n                16224938596653908092,\n                1164830155402073602,\n                6289706313355675934,\n                10093838410108560175,\n                2551691589709651401,\n                15882696485463451559,\n                3395731646324122865,\n                12473003610421288231,\n                7149619960361615882,\n                9872807622306918213,\n                6663012576266477470,\n                17016549792515115205,\n                7914178572800158023,\n                17014701567637435932,\n                14346020259284370257,\n                5074365976986728463,\n                4760168726990175515,\n                9895948792206852207,\n                18273255159788978236,\n                15744547484672365588,\n                16864050091650583468,\n                7152138044891906219,\n                3133231435713995056,\n                14654289506261133725,\n                14216037513719362689,\n                6883938067921952514,\n                13637751749205284541,\n                3930907102025842836,\n                7818503413066881742,\n                16512268473175446131,\n                13618638131220285482,\n                3526560852689406895,\n                16317348279030286281,\n                5781706287563855208,\n                16877706843053345782,\n                9787389520151320440,\n                1672625892740702444,\n                17775094144895143457,\n                7284734471708236532,\n                6265912061217026214,\n                16428427284586036469,\n                7239300285490611080,\n                12257099262814629130,\n                1443098110450745157,\n                7111333716613874437,\n                10912463389630114261,\n                16046472632120791101,\n                11071308475967108461,\n                15827031925467657247,\n                8451701545861351835,\n                2032718007638091987,\n                9275305708809424137,\n                10133532607349132521,\n                62031173551766505,\n                1069668934694816298,\n                10021315903394494037,\n                18062320514241791111,\n                16614273374620642998,\n                3874528406029009574,\n                11609554407744278526,\n                6664429329059042685,\n                2466789265733227250,\n                13791862987730476433,\n                3100076428479694646,\n                1940573727807547478,\n                1717992312877296193,\n                3858278897688455120,\n                2708391244967786582,\n                5897077897033357390,\n                13903090124093303714,\n                5210172753029188249,\n                7461814148277300830,\n                9825991953137124992,\n                8749849231144845954,\n                15733619176610014569,\n                2536045915051793710,\n                2795322555877650589,\n                15164137179922407098,\n                11311210084140344802,\n                10571285191092929225,\n                4809833504711226607,\n                15053596169163492600,\n                12405664553095020547,\n                16471715640263755395,\n                3828351876877550724,\n                8499888452131579133,\n                5279727535149011805,\n                788643833745941437,\n                11012285726544455006,\n                15140257364221864448,\n                1834285009459528474,\n                6667182475201903438,\n                15294024395589453460,\n                10526482467856757788,\n                11877982762793807927,\n                16230316864465358123,\n                15723393603594181628,\n                18424513935220466565,\n                2247141586434891619,\n                9561372576131838874,\n                8725104655684175177,\n                4143398848385382705,\n                15142179196637056843,\n                17330386941741492571,\n                8185673125837710067,\n                14939737481973173962,\n                10478395787666924945,\n                2774689508274990026,\n                12451742284278860222,\n                10819437460867617255,\n                13731567691766219490,\n                2010973683387239919,\n                9908150371329956596,\n                5142510757399393995,\n                8739166923706997151,\n                16903649040425907246,\n                6887419514989237100,\n                1875697363324020800,\n                16410802797521308346,\n                135862499096678312,\n                1002710565280860416,\n                5506348106905501784,\n                11368287034717703998,\n                12947266586015982813,\n                5318254909926585664,\n                9296468205284792595,\n                8004814724160061752,\n                366393468717204226,\n                10790734687437783398,\n                4968864942084278227,\n                15798662312565535644,\n                1358717464422009379,\n                12888686466434430386,\n                370520483338984073,\n                9184642588343372758,\n                9427179068402613262,\n                10546786545869440465,\n                12655417731444306355,\n                9241957630409402290,\n                821497951821470195,\n                3197970711092278947,\n                2184424336239199737,\n                5106022623290447939,\n                16287048031456496603,\n                14037056338746814782,\n                7474000199931218562,\n                12188148167023924203,\n                4192028392289466906,\n                7847291769851591899,\n                3599561900723047299,\n                851922034760320751,\n                13587138821847499752,\n                15960408996225570897,\n                3252001517847791314,\n                794174927197992513,\n                13500786923616416327,\n                10492520307372562282,\n                17778963725733766896,\n                9940193524688369200,\n                7839429243680619309,\n                11152685327758330011,\n                4793514629906514769,\n                12571317405831554973,\n                14236764890442489777,\n                14285226682975878252,\n                4752465601541667238,\n                7069073862761309134,\n                18297621617638524964,\n                16921089529724869008,\n                15310629395363439387,\n                13959904965987734388,\n                5530325767118220975,\n                955257971161171732,\n                9249687876412175486,\n                6437014646360143974,\n                1355675591008680076,\n                14363814817404705228,\n                11444699168208672882,\n                16890344077647521215,\n                13663194688247169944,\n                9311758702620596945,\n                9111333905244008262,\n                3739308534752587737,\n                10082399017494306243,\n                14502104680453962352,\n                3240447658814963588,\n                1945616413338215240,\n                12702436196323839746,\n                15056103164643567233,\n                14232906369316952845,\n                8850081479512611348,\n                78742167026295742,\n                10346207199790592003,\n                8330318603106182342,\n                7555172829812303483,\n                9135554534047252825,\n                2213978715965424041,\n                14487841485121669529,\n                14201073224315526620,\n                12002576656710628646,\n                9216161229854384642,\n                15287364979646883311,\n                4707577895128497224,\n                14025232799632084648,\n                5317706395334588893,\n                1489525665074354154,\n                9157439364142092486,\n                7033808256892914411,\n                2856904746309353752,\n                11315255790030198921,\n                12167475608624586287,\n                14898366696798509538,\n                9918128939648387398,\n                15155651994814693417,\n                7300960472494546400,\n                2127526231515960912,\n                8923406206829661118,\n                16210393114988425815,\n                6582813395371196199,\n                15621762854392338472,\n                3789550044424910854,\n                16988798023618902953,\n                16490593537106458722,\n                14139545158028230044,\n                9923635478455782946,\n                8897217280317716469,\n                8453814653444266828,\n                7491325054712040563,\n                12316700761490127631,\n                3768457975900229126,\n                3000037930881673503,\n                16933057766750635435,\n                15031174928418481583,\n                3019987484089942716,\n                18385609936539305759,\n                17538768527945166806,\n                5447221007766299602,\n                4022798439534764827,\n                17074805847175217989,\n                9477194110020170032,\n                10200259846152838876,\n                6455055232471034376,\n                5679758327656142352,\n                7374147007380920949,\n                10200477410022066193,\n                2678287199491553725,\n                5011120062607229052,\n                7214257460239674372,\n                9631753064650306646,\n                1151983673963114572,\n                2455508156322019163,\n                13344796472161923955,\n                17003695385004214505,\n                11166307372098954131,\n                2221946328882472137,\n                7061489614039858629,\n                3790971501091116413,\n                7833733804721228481,\n                193935756315502298,\n                10256338066976304411,\n                6065749049589877362,\n                10736472690437134411,\n                10155365416269683464,\n                8189737882773858983,\n                13671211115390707327,\n                9578025336797949473,\n                4003423028251739147,\n                4500512304316856151,\n                16693811644887033093,\n                7707767344560596984,\n                5599541458797859603,\n                11592325835943024402,\n                13355669588132489385,\n                15932001697488084536,\n                9870357379952328535,\n                18310499762741838752,\n                16196774945614723862,\n                15790487345250753382,\n                11990590655367464148,\n                6718674416650039299,\n                14857329469228715563,\n                15423479737409206383,\n                17779878703537243863,\n                2210183662909405344,\n                2815540909030329829,\n                5940765014986549489,\n                16884893974961992656,\n                4351638805125702042,\n                17084353252120736247,\n                5724252085645496824,\n                17794301429798973952,\n                7949129492433028333,\n                17290229503720706399,\n                12839841549866653659,\n                14863383260888850679,\n                15788917858243172461,\n                12477975711782044218,\n                12362210923589911101,\n                12864920132785914749,\n                10860162458674426789,\n                15634366676531407135,\n                6076026769874036504,\n                12186624835981223643,\n                477838969646790588,\n                10209086843687255723,\n                4453597694185557465,\n                9792638779490749472,\n                8664773568287178159,\n                18322711946104316656,\n                5061590004040013161,\n                11611936838758532137,\n                3299611430381151917,\n                3978890638406515286,\n                5081581149863744934,\n                6181936955807580784,\n                3372188069238850634,\n                17854265102071578827,\n                1268076978660794505,\n                4722477313014336378,\n                5471980643922086499,\n                16788648796682094709,\n                13328529160256523927,\n                17816434316065398701,\n                4038311782651024619,\n                8255869964978262613,\n                8890037824421975027,\n                7319879894513022697,\n                15914698902244750946,\n                8857389029776818687,\n                441863541258666465,\n                3208037884158506723,\n                6113734693574039276,\n                264986606662698668,\n                1166237501799711319,\n                1823307447602740420,\n                5025672756710206999,\n                18278689422657324853,\n                4594507497487291210,\n                1280886041213346013,\n                11896598892872950706,\n                5576693076164380614,\n                10907097907235031727,\n                317196941106545936,\n                10598515286008372146,\n                10232665246931238263,\n                16641631582624438065,\n                1996845757059763068,\n                8450189738658666487,\n                16874433980334624325,\n                11462456373743157203,\n                17922058749640783486,\n                10312126789368172997,\n                13340565145612845891,\n                2211332034685909397,\n                6280821632118062402,\n                11495261020831147497,\n                7525751008510944548,\n                16481618138878161375,\n                17687291635686050126,\n                4726039693402439590,\n                6224312974372200845,\n                177270674822437819,\n                12844674102136119940,\n                2765095317735756740,\n                6375785787962152345,\n                4765877337254522185,\n                5699318866607950771,\n                7726266014961936643,\n                10439969907866586583,\n                11215604933445164846,\n                11144874084048847665,\n                16677507722859793772,\n                14926605406115980653,\n                11021418173114133993,\n                18143508384673173911,\n                17869384978881128193,\n                539841771736061948,\n                813906843235746774,\n                2120916504386756315,\n                17563694758070096975,\n                5807011249822640473,\n                12074412278826937750,\n                10494691749052118094,\n                4034710777981084065,\n                12945928140391853828,\n                13460531663356368909,\n                9805968628270501084,\n                8389235258735557083,\n                4653641631812286778,\n                8961436573446073348,\n                6695344158613046716,\n                16832827001219019801,\n                5227374831316662089,\n                5088308882683339576,\n                3279167959625059741,\n                10436103497832123501,\n                2797296687506317311,\n                18305760283738580632,\n                3531912382829235411,\n                8745021258521548248,\n                2062796519113317445,\n                7005506890190360164,\n                15260828944473012523,\n                11736618288708934540,\n                15523033936060000556,\n                9071328583193116055,\n                2949954518191771020,\n                9219149478710608069,\n                1788704922178497999,\n                3917123331723493156,\n                8283987826876682192,\n                3926515941902592230,\n                4576777655155350003,\n                2895291773949819710,\n                5409491793062473762,\n                7827016058731337158,\n                2360244091777092634,\n                17765210336693396066,\n                15413391993237156529,\n                9542656815625824892,\n                9430563399204843121,\n                11559365450247449510,\n                15796909749180552904,\n                62820771556683371,\n                17275496805851130274,\n                6527142162623953967,\n                4324187305635963626,\n                8775772925418898915,\n                4283973075245351015,\n                8846184539722500106,\n                2860502690824226817,\n                1240652940592194,\n                15064048316358894661,\n                15864254034666279286,\n                4098943802367114793,\n                2956682521101031793,\n                1877556925464957894,\n                9589792900125026809,\n                12161426439049578986,\n                6435540582736037161,\n                10575856639119978060,\n                14751225739652781433,\n                3642975302329400055,\n                10213336036038833464,\n                7137807512192531866,\n                15715238576819145647,\n                17891816262406767004,\n                2885759842806217828,\n                10001842985502100171,\n                16889965688337087910,\n                7192241521508241891,\n                12459052609846245573,\n                16045056395445218777,\n                14263408894637697194,\n                6319194484923808205,\n                6887168986137924562,\n                4723017923445345268,\n                8785445940747788332,\n                2221153194351157100,\n                4112058037714640844,\n                16624774310058492682,\n                18155682498135649179,\n                4932684590312312624,\n                6466580926084050461,\n                13095557293811313234,\n                5629819270691955218,\n                6705036397567572049,\n                15096504303120814344,\n                17813708390329054153,\n                2867801270346878637,\n                4428369643259246081,\n                14356128800268363075,\n                2105538175211522946,\n                8157169805154179676,\n                13281934124532911335,\n                721993975496515367,\n                9731311970803693633,\n                17408383560695508306,\n                3661032291356469843,\n                17118601234529144108,\n                14173384340046827967,\n                13956269658151533336,\n                14193288209519401944,\n                10854924829501094491,\n                9362722838007437994,\n                13139075107441548779,\n                53888779219483732,\n                9991228977857148506,\n                11866192603390104699,\n                1903043806364214756,\n                14664090553522048890,\n                94655028324146279,\n                5944941626254245313,\n                3067815658183085252,\n                10088835779690593635,\n                12586879497500128294,\n                17338285387265829132,\n                13546679410630118150,\n                4684155179104389445,\n                17373141188216408963,\n                10683275227724384825,\n                11727464505463619204,\n                16890013009763926299,\n                12256558554118856945,\n                1692369148468240661,\n                14260594858617396870,\n                8079067481737035693,\n                17302479952759473929,\n                3465288033646104738,\n                7033532051975356541,\n                5750806504528053243,\n                16142598027708695045,\n                3763071556050151375,\n                747332911728793689,\n                7125512446937882000,\n                1711762381076986594,\n                15200743445044769163,\n                567070148436076824,\n                11150986733649743405,\n                1751542514779667937,\n                14904426643112052682,\n                16243812463903474525,\n                4313436371286419450,\n                18281797249258270726,\n                13863976627696030069,\n                12604750965802575212,\n                10295616727116267978,\n                7795942372543067322,\n                6713137871239810667,\n                13830865828728404463,\n                11139257890131452244,\n                2759969414377994154,\n                151123411588221984,\n                1548247161690787301,\n                16234894685549118874,\n                13392592243844300663,\n                4341718471344294648,\n                7137644906875460827,\n                5416631993939117377,\n                11693386548832817142,\n                11851058952064231493,\n                9690204938813699131,\n                68528268163302809,\n                13565043622050152230,\n                7983220844142817842,\n                6794808910151851013,\n                2118666482985725107,\n                7247597207626321306,\n                16937693375274789158,\n                10616884815388828659,\n                11696015248644704721,\n                3352478958667054947,\n                3225871086863590754,\n                180230908445925268,\n                6654741577584823985,\n                11710009687907650028,\n                628457965752902770,\n                1735690146666342885,\n                16556237906505825388,\n                12440271636242780312,\n                8713058872068144699,\n                8975441040195700002,\n                10850963832660773043,\n                86339822673122508,\n                4000323666157343936,\n                12142567722725546249,\n                3374710818178624781,\n                6392232680788016964,\n                12790199390015157427,\n                4671003891873822839,\n                4452182512321524727,\n                3905095889403963026,\n                16726139916064776463,\n                3453332349452466770,\n                16221710379420353742,\n                4632551944540970365,\n                8387501246722919769,\n                9326344266173346561,\n                14810846036626389828,\n                7283658938651037849,\n                5813262143148998917,\n                11727805907650385268,\n                9857096480403873519,\n                6356324418997451940,\n                4218579215729792881,\n                10470999063206203293,\n                622196070040738252,\n                17021144211023071215,\n                272053703337182123,\n                1450758744433386057,\n                8397337301039096971,\n                1756739264090010567,\n                14804942979114893233,\n                12762190712783408010,\n                4486114271404551982,\n                13538690353341899530,\n                6182493449368831960,\n                2768435790455158079,\n                8491588540734758297,\n                5001428683933385935,\n                16861055012236061995,\n                10578636081126268849,\n                14449779720168257980,\n                9370646703732609468,\n                476896208068404545,\n                11604128769892258429,\n                3178840918267575500,\n                3407583825966649895,\n                17913378662961900390,\n                1138652617523020638,\n                4702124733398535376,\n                16197108716716127538,\n                16852598869081929632,\n                5020614776073585872,\n                1188708373797737364,\n                13456434315549496452,\n                3798071449732352219,\n                6593816705053129140,\n                8463318160472344568,\n                10114730768365942765,\n                2093191144313711189,\n                12720945689550243678,\n                17481264965133664645,\n                17640221870440170657,\n                3490097599238691289,\n                3624992904734580452,\n                5383687377060455481,\n                10776924742527744182,\n                15746021472289883888,\n                17925392760128571522,\n                12689005861958409137,\n                5231100489367895272,\n                14007286820825332338,\n                2397858260918981403,\n                3320067181759583430,\n                18227252228223404573,\n                18011328143837002368,\n                4798104660333169602,\n                10865877383638846865,\n                3767167656736085179,\n                13252620599128939387,\n                6636747284560413010,\n                13514887050922862847,\n                422456370340431886,\n                9612933469182009435,\n                8572209183721381907,\n                8056048067037472186,\n                16714990476240297166,\n                3520645146861432874,\n                4395550491627332110,\n                9462218612700999094,\n                6214250154185857186,\n                7628194292741759764,\n                3556878717144745691,\n                18413027616459454704,\n                10160691680912469038,\n                13717170760433051685,\n                15180833335295580609,\n                1819382907555618141,\n                13320476638466170165,\n                10422294181974936444,\n                7164181547072169074,\n                4206492057553506325,\n                12633015044784588629,\n                379171732810097117,\n                10351100759422011738,\n                3673330411049649463,\n                15927757725693044281,\n                13690250449236882125,\n                15900551197649269941,\n                18329662994600175312,\n                2110669219011944740,\n                2226752393294287183,\n                1014550150137152480,\n                9887871066385753226,\n                4568683160401484222,\n                10951431797661196524,\n                2312645127290056695,\n                16937439673591720324,\n                6396609076318661377,\n                8389300110486808887,\n                1923677274274786580,\n                3549825163974227141,\n                8566399761898493308,\n                639620030714191084,\n                768228320555967661,\n                8108418530085400912,\n                10272182341228792152,\n                16750158829727849854,\n                4444117530817286053,\n                586462195320680600,\n                4278069062735193163,\n                4273315131401359275,\n                11611787428091079232,\n                11835985289253260719,\n                3096230712379885797,\n                5322239580881209060,\n                11938666223318366819,\n                5060592382016062327,\n                109409443906808448,\n                2380457102117134635,\n                15857731461784222805,\n                6584665638956888535,\n                5947254465908568523,\n                9420786545084124002,\n                4503761263873856534,\n                6641486141146012370,\n                9121700908113990684,\n                9720958769231915561,\n                7003782806520614311,\n                16920307773004245532,\n                12763580883987437513,\n                13231043349317133789,\n                16203109836791501802,\n                698049430375939280,\n                3030494131166195541,\n                10815604140749178453,\n                13804995432448225904,\n                2055424018541357006,\n                17073648888173819706,\n                15463924428711597599,\n                13403700103090470402,\n                16763806955533746160,\n                10509071477142331263,\n                7405199613665848444,\n                1289961083639614668,\n                13019156453931533504,\n                511380020193300140,\n                15833618630547184883,\n                16532434650886462678,\n                7779349734049489490,\n                6380411322746302134,\n                9492908436973173105,\n                7167088077189974813,\n                17396059932024334263,\n                16483611260630861934,\n                9669468321319436238,\n                12712646425834594093,\n                9288405016973860570,\n                11325843021373113165,\n                11258335193384041947,\n                1997545595799365359,\n                17390606419645620788,\n                5130387948734042681,\n                3121742342628196576,\n                6099609462914905352,\n                6524840389448497409,\n                3251588966299685263,\n                12515453442966781968,\n                4351131781828315306,\n                7915089733711494046,\n                8605641240710406093,\n                11102717433954517200,\n                8816805538627940082,\n                17227753413606850602,\n                10263075023716628113,\n                7686631682618468388,\n                10330530590800536028,\n                2587341603576202527,\n                11500396296312301825,\n                13531587115648414633,\n                15808917747546864365,\n                14333112763098420691,\n                14761783111500015307,\n                53964954401492398,\n                16533467491022296104,\n                3096485428305684908,\n                6318844018415466634,\n                7132560604178571060,\n                16428604738409136626,\n                4375929108222206025,\n                10112133284375140971,\n                3256631261503314080,\n                16136845689782815155,\n                15928971771356595498,\n                14645130502697393764,\n                14481748170304871772,\n                1698922547070724229,\n                9468607121868930261,\n                11617214057068823437,\n                1382928294652688250,\n                12680084220201263431,\n                15926122141331194025,\n                7979147799621842755,\n                9803599832824191350,\n                11150566171126503035,\n                11946016594155356252,\n                8452284422264862510,\n                8621047342992105610,\n                8991106617593209637,\n                4607652189428377711,\n                312850746210123282,\n                13020253158865282886,\n                9665527964173507749,\n                18176337504665053651,\n                10689513521305445515,\n                1839607582702602917,\n                13793618456770339778,\n                12156395506174115903,\n                15230345865671590927,\n                4715973552531673115,\n                14606516029379763286,\n                17293771405588962821,\n                16175698567845501145,\n                3789965395433901756,\n                7250432289837425960,\n                2507460993020556336,\n                16416011798948565038,\n                6033312224978543324,\n                14568892906298810894,\n                9207153067892339499,\n                14537938431481818790,\n                16550516704016530385,\n                9907670198667127499,\n                11918889385815695319,\n                5981318855234384164,\n                6303359496211585544,\n                897784439258088201,\n                7533487805017595619,\n                5938457201719040924,\n                10019150195260257017,\n                12026554931880038202,\n                9224513724236448133,\n                18208973061276109233,\n                14240550756243930801,\n                15387974810151313549,\n                193781859214087276,\n                11713954174101604255,\n                1341093990140003013,\n                6012491122871297010,\n                13892530467037865965,\n                1368649256526022373,\n                7020819021722718671,\n                15787587617733723291,\n                7785870968748246057,\n                1947448600658942561,\n                16530328214840567615,\n                6317941331086952570,\n                7139842027589405175,\n                10933153414206777090,\n                9672586073744099620,\n                17228494407277874159,\n                11578033579087247602,\n                15459493510831207600,\n                8222705886823487604,\n                578413881840029844,\n                2972330100500591542,\n                7515621234174823899,\n                6704318956697481184,\n                7539293268516643247,\n                1580608997901534862,\n                1201050878740265829,\n                10170365701874480907,\n                9870363666224664306,\n                17305296184407747996,\n                4224805619364289032,\n                15085837243579345311,\n                2443632602903912157,\n                13046843267919167284,\n                12116351035376725179,\n                263232896451917215,\n                7772071638110042980,\n                16549817644785034122,\n                15257628965480096285,\n                13004189693733577363,\n                3864285740392230962,\n                3468607145721577697,\n                354566527372793754,\n                12925883576993237617,\n                12693175375557728813,\n                622461988842871628,\n                11397527121006480165,\n                12911631110359477732,\n                13101149248297235307,\n                3443924800339223639,\n                11021054325079132422,\n                5789359016899607332,\n                15670032899436160802,\n                17231336489372520758,\n                15011195019101462587,\n                17697169511730379360,\n                6214385185627447169,\n                10180011765464756731,\n                11047248145840743090,\n                2742832730133990272,\n                14029491892088421031,\n                7977004417662816272,\n                14199429721808423163,\n                18279997024327708476,\n                13359704350594785266,\n                18410294947752215697,\n                4900459096393373794,\n                17759944268317835227,\n                7514273237508120753,\n                5036409225635108741,\n                18108376710275555530,\n                2676982762515162946,\n                510220139774948017,\n                9208245069742717667,\n                10376186455595199891,\n                421637325546718875,\n                16791119924695165602,\n                5075099022211468458,\n                12517850612529158688,\n                14010730112031892170,\n                9181830456575508952,\n                8562092376348428853,\n                13106552497603917850,\n                14302339172367595976,\n                3354417171377350434,\n                11375931064094009915,\n                7367612779037974062,\n                17960646160089319914,\n                7765039110674214207,\n                11258859351125514864,\n                6790503465712539668,\n                15367600556170700044,\n                6616796092052086761,\n                12472062233228758417,\n                6844102383328993237,\n                12811249515443122455,\n                5102740036611216259,\n                15944761788498002902,\n                14694830622589958200,\n                2106296585469395117,\n                12001390986454100522,\n                3886258101634881021,\n                7626447484564536615,\n                12121778508662936673,\n                4637632611996699763,\n                284639519767470911,\n                6111767225293430109,\n                14899978058938638435,\n                9492490138059005865,\n                3457376194893217608,\n                6384991674167924954,\n                16479663265444998572,\n                2182180597909020672,\n                15349832040611960272,\n                6995769868581799282,\n                7434433066635564427,\n                7330931577518389882,\n                11026383041313003706,\n                12870325652218422628,\n                1151311929447712791,\n                9598200806509616050,\n                17161065747263888006,\n                6901765437989220429,\n                17524807833762947972,\n                7424089904607803796,\n                10169273845585922571,\n                427683750176118191,\n                16198716196396797311,\n                4234469982734082109,\n                10433113399561032205,\n                8455659057075573351,\n                5339947829324400827,\n                8994757262942082927,\n                16110373093388044843,\n                8165219755821135739,\n                11079951015921397003,\n                17913162205445436558,\n                18307573113704258140,\n                5184334744599569992,\n                8209592006521651537,\n                15233048304519008983,\n                3893904742760952245,\n                12843184579518607189,\n                16317789833580002355,\n                3932965922048250109,\n                39643566078340112,\n                14454778211007988105,\n                11325761588512978910,\n                7326308723838667358,\n                918638912645150633,\n                11749550850384896237,\n                11656774623671896072,\n                4102579533296639675,\n                1131200342214858221,\n                17002635763021940679,\n                12699501461265202766,\n                18366533628748257986,\n                4211496006430696197,\n                15592383694738584641,\n                12132073284414780422,\n                14112124548036073660,\n                640983069936058034,\n                12843837916043035998,\n                12619927090786907296,\n                14878814042191779303,\n                26802691526432636,\n                13542740387876579301,\n                3027951464265029786,\n                16531319427892075667,\n                7433366770688989904,\n                17675108936726475823,\n                12991848794171434707,\n                11308307557943773008,\n                8441361375349434971,\n                16048668185725998079,\n                6848195560782317706,\n                15732631277486546880,\n                8796031012662685103,\n                471880524013342791,\n                2847727284878021151,\n                8909402802655050731,\n                9155393982976367055,\n                5339419398360353054,\n                12394943475850749453,\n                1082481852253596422,\n                2475925758143360234,\n                16780844326338173281,\n                9955442783741736414,\n                16398521725460554238,\n                11754389093333746016,\n                9510081579192799387,\n                10740614081401142716,\n                6751836211534532930,\n                3310216743613517077,\n                4711354618706526528,\n                11761966320912417805,\n                36323519866736684,\n                2431075662700945654,\n                15771975356730131291,\n                14504980176985527547,\n                5551404397884447150,\n                7328632262405216781,\n                6659335151951442348,\n                12904376258123706403,\n                14766024566003307212,\n                2729153030346049029,\n                9776447889426450664,\n                8565088926995480737,\n                12733048698734167426,\n                16140690590167093278,\n                11999311158468044755,\n                13598288633972733571,\n                13732432400180070386,\n                15194135950298716633,\n                13160554968820068964,\n                10539080943199862762,\n                15115912129273478029,\n                17652613656477189074,\n                7952212396658049573,\n                16131569825649579263,\n                14739342068703048684,\n                2756008787672952449,\n                17980612557340090024,\n                4505357043573157185,\n                5886347178459794981,\n                13467166348185532762,\n                7542340141940109840,\n                8604473128836312462,\n                14161530301987102049,\n                7768636854450163149,\n                14487815318986749283,\n                6851630924543230233,\n                15816812718841829697,\n                13309960537373415159,\n                13533823018337269511,\n                4066246092121693604,\n                9157035362257855573,\n                412214665099375028,\n                14477789736289307578,\n                8471884807077804890,\n                5401116457851954216,\n                448871182302722508,\n                11307725734317055468,\n                10916897930231800956,\n                12320324583264666269,\n                9855253221365914708,\n                10341139850853598251,\n                473763070798790310,\n                2738091302514798630,\n                5726660080813664052,\n                4685085520987362,\n                142836371012422078,\n                12594070839012993809,\n                10074822048682622819,\n                12827059438505836814,\n                16625605990012653363,\n                5223703331085192665,\n                9833285584664723263,\n                8290425612857589870,\n                6306954960404098112,\n                9412474111491552241,\n                3143257994045884457,\n                16371722385530408059,\n                155878147658248091,\n                14824551048836933161,\n                6944511999081736143,\n                12540758531163865907,\n                11983135069038529053,\n                4545712278933588398,\n                15077557719097293644,\n                8824726955621677512,\n                9467059989026717476,\n                1832994947759543686,\n                9395963500530779164,\n                10187513723496037742,\n                9614996490866381781,\n                4074827755791565698,\n                12833908036330960194,\n                16292730478901857762,\n                17035820163674794684,\n                989273775053529110,\n                10590449105705689408,\n                2922575348536557726,\n                9097036857789013295,\n                12287791133096088844,\n                11574082336078807433,\n                16687006015927882120,\n                8596744673168310178,\n                8970905056348840750,\n                5517972678784462826,\n                881430805465529877,\n                3412610955059774968,\n                7028178389869167183,\n                5170343795610265286,\n                11012307439076817531,\n                12613254778376420629,\n                4047156878552340678,\n                14789560647177930279,\n                4218958252980142613,\n                6013379809704688444,\n                10780282427110087598,\n                3110875217681031780,\n                1760113645124538802,\n                4510301077917148010,\n                11245657134256982381,\n                3975465112728195039,\n                10147869619910151776,\n                9521542758217967325,\n                9796643369778561059,\n                18438740993593422996,\n                5755122647194246655,\n                13089871854524075038,\n                6020811568278170849,\n                2905460035802413789,\n                5770692989150859960,\n                9121733696504177003,\n                9054740045617104954,\n                6651061222026801570,\n                6979411400071458744,\n                3760933926638598638,\n                16334302020381288285,\n                2057660950359678276,\n                11293316249797872974,\n                11604535997697431331,\n                11921660539545426320,\n                9756548788646446777,\n                7269421896006778050,\n                3975439838039732758,\n                4483475473549910496,\n                11780853832789946501,\n                8179840661787229204,\n                2659883347338825753,\n                11257903019053621162,\n                9583945287877466892,\n                16363933527036814071,\n                1290785704105238692,\n                8655198258069320180,\n                12518299182873150764,\n                7361462000368712194,\n                9733702303272955573,\n                2362863984326388251,\n                14125653338074659438,\n                8452977297932581636,\n                12482787099763665262,\n                14889071888466818806,\n                13718685624353930921,\n                5045136353562987858,\n                5296643588295054890,\n                13213371806126402767,\n                3277278393660323717,\n                5669363365118437907,\n                15016463550423536857,\n                16936344489863263921,\n                2565955327304029560,\n                4796734652908453706,\n                1378655232854232950,\n                9591923038316868621,\n                16194271618909991898,\n                8523814065658657216,\n                968783876319889044,\n                11876875087504947472,\n                15343430958924511022,\n                4726016088940609325,\n                15814602580682745621,\n                17553495950903097582,\n                3845404925865098583,\n                18216981879371013309,\n                4102006890010720614,\n                15988113496959934091,\n                6019266456198657999,\n                11837451541533231967,\n                1877408958200970989,\n                11155878481768284249,\n                16966216363889316426,\n                16449662703095636488,\n                11722657415321325203,\n                8151686270422518591,\n                6829105588528021796,\n                5605072424730907975,\n                9610630778445319623,\n                12490688233524207364,\n                15924383595417258143,\n                6293909456050977691,\n                1520031459958370315,\n                16878056482786965582,\n                1567491557266512441,\n                11553059083075601436,\n                16588286805077499576,\n                2831700015193252058,\n                9291679435178297105,\n                16696183961702972685,\n                6110717331497256774,\n                3508641981673281301,\n                2888222167255453397,\n                6382434826249612462,\n                1615495003744037219,\n                3450690972855989121,\n                7373699525385823603,\n                1487214282399378665,\n                5054239246312770486,\n                6325543252810070667,\n                604916284274232643,\n                5705249803789781860,\n                1347389337137481378,\n                17341491803371701023,\n                7562092053824458983,\n                11528860291431916871,\n                10058885809804159773,\n                12028682695619691748,\n                2072309850975849144,\n                17510902039090560383,\n                10964691654809950146,\n                8557150693328114885,\n                10018287661176094357,\n                12067793619240607034,\n                12258652923874874737,\n                14315661805556678059,\n                1532344907755129707,\n                11548306890701017011,\n                9836569326549702085,\n                13196528743664879413,\n                16910466377189639446,\n                305247665277886260,\n                10234652344969601959,\n                6426209661333831948,\n                13316514153882647236,\n                320668129269757278,\n                9513807142666087825,\n                12132502292274229629,\n                7907062113630478532,\n                6769256578404078947,\n                11077216337588272062,\n                11192173094112274045,\n                8665424743913923338,\n                17273052641666860613,\n                8242738008086379196,\n                13851918804734763571,\n                7049674271488004214,\n                1410604294587433641,\n                13544384176158464923,\n                12468330754572317265,\n                1317196613823108318,\n                406832464837758362,\n                6039154084839734004,\n                1995025881371264773,\n                15399759218648596543,\n                7323767619167721842,\n                14228968351368149001,\n                14556483677198851362,\n                10822573411785744110,\n                13457687797488671733,\n                15113597365244568644,\n                5830040833200595947,\n                10782120448577939853,\n                5923233368326767564,\n                13565433709591402733,\n                7409835447323460538,\n                4942580795960776301,\n                8068857330020361381,\n                11063008871093537743,\n                6583328726807166886,\n                2194893842926463044,\n                9586490095482756942,\n                11811119386143060256,\n                3644614927094824958,\n                4762559862573353606,\n                7054841812193239255,\n                104169344287246978,\n                13956225391862408166,\n                4507288715283113798,\n                11772996098884686986,\n                12792586168475881829,\n                15798457727837504001,\n                16896795677207949298,\n                10265172010623416483,\n                14814049521182301273,\n                14251567652536773005,\n                11041033214099412656,\n                6589290323087713529,\n                17080306026857684487,\n                8536449894500168140,\n                13538904949191682258,\n                998478434926587432,\n                14670273496850215516,\n                15311327973305354729,\n                12644104051633342488,\n                12970733262467631495,\n                4625272733914046269,\n                4694472538276404068,\n                3167371560249938056,\n                12856489429820568743,\n                15490218655488023802,\n                16928081564771690940,\n                8200145788070169286,\n                3346452930233714534,\n                12795482436352374291,\n                3314315705851242852,\n                3285152211139935017,\n                11224563416094698786,\n                9705270177443534531,\n                17644295182363680941,\n                13520301373099144288,\n                3541351715009433425,\n                16020276637771846482,\n                6027464490277968416,\n                4251343941648935652,\n                17763014962498696031,\n                720132515041512177,\n                5173394266280593900,\n                15204667210087004583,\n                17335914961708883300,\n                13218634015062319702,\n                128827822406486046,\n                13559392235200971420,\n                17252636495073021415,\n                750007296061102031,\n                18254099543935170871,\n                7509241234704231102,\n                8157193578702246807,\n                10298529352072110821,\n                5298418177375924856,\n                4741852588831255524,\n                14527267204533561544,\n                9095259534397569417,\n                344527310846137539,\n                13247449783957233078,\n                2586644247732041192,\n                3100790169250176954,\n                16510173867908259851,\n                11333281937378448547,\n                10849352377567806999,\n                18082377466933472402,\n                13561723472079052715,\n                14547157815982897407,\n                9391369342410485871,\n                2348830231178979433,\n                16863733530713957956,\n                18119733445408743443,\n                13725121556809406883,\n                9229975878895702895,\n                7401016155946807916,\n                4811692959864213177,\n                6237359194264984939,\n                1904440073749912075,\n                6353600963009324869,\n                4984137724622228146,\n                1196090958128593834,\n                5119707990981594180,\n                3310978073014066771,\n                12983216966379762511,\n                6612762118768660390,\n                4003198331951059920,\n                6385796970903716569,\n                17680686381236190132,\n                7090591178254990847,\n                13123476457069922276,\n                11991645307762636710,\n                5129610078187868363,\n                5604361132348700067,\n                11043762682351635495,\n                6391120985682487625,\n                4455513730428273542,\n                3762654197950669235,\n                9310420262887992163,\n                11993439152830872164,\n                15439986350739535069,\n                1488229606606016585,\n                8189570287966130481,\n                16920767496097942040,\n                7797006069350129228,\n                17531953262576833935,\n                17024439366185018969,\n                8083356010952666614,\n                6837066330579419154,\n                6443183984423798969,\n                4776996086855661713,\n                9156255850041051387,\n                6083831993070398816,\n                14543764421371224439,\n                11977571598909514982,\n                10188060030334373973,\n                9449009160086154971,\n                1300044225109284268,\n                8825712025626564634,\n                5510762923192959602,\n                7324962531338046625,\n                11942013042939202021,\n                13598796371758253088,\n                3794998887633576199,\n                5084084225782194038,\n                15889660289095533051,\n                15428522601238467679,\n                13696067867927948600,\n                1072542240072425197,\n                9785760286300726328,\n                17624535067298229622,\n                3938570677885383673,\n                3705077412606219929,\n                5340068085943913770,\n                4210056340846145048,\n                1976665594829638831,\n                13311220586145473347,\n                6943938959824844891,\n                7268540691149845607,\n                4375885954089016506,\n                14963703931344653483,\n                2580585000938123597,\n                1068177107148635952,\n                2341910556569696351,\n                9142288039937977251,\n                8517576956327184753,\n                3376248516190748921,\n                13301443214809490744,\n                13173593921898127720,\n                17359893842944679338,\n                7047222128454518811,\n                5947406210583265494,\n                7833766002049023813,\n                18234948673625328162,\n                16320032712674678534,\n                12642441645902018157,\n                16283613144322847005,\n                7863579138098504089,\n                6035051266438089663,\n                5453172248583632847,\n                13775470103081167926,\n                1182333285767268205,\n                10495826772905540632,\n                3056962127861644896,\n                3638669906264037789,\n                11198631986907530450,\n                13541149168510941603,\n                3250675262588623536,\n                1880073565717482485,\n                11936216765079705804,\n                7530067836231811508,\n                16311420158606635425,\n                14900155531445760709,\n                9999132967166761272,\n                1476154866153451041,\n                7195014637072196640,\n                7248062023586150152,\n                12914546489578466976,\n                16344645330454865081,\n                13063707322424725098,\n                15370611307815629185,\n                2118132721549701162,\n                14789791523379164567,\n                13011177800824348207,\n                18047963884795850285,\n                13689837669785098672,\n                5906277653382226335,\n                2699555162272597747,\n                14303717239113776133,\n                3323572003892592160,\n                2809044788581830880,\n                12842135035209068787,\n                12962493426638468571,\n                7435779585695058098,\n                677266868482172083,\n                10678064418979058702,\n                10945593620822631517,\n                8023058850263770330,\n                13198960821944542699,\n                11380271889111358356,\n                8834711603621437912,\n                4878802483786297049,\n                13441769216931046849,\n                2621489868509896160,\n                2739596448875968624,\n                18316605028815878992,\n                6393166579696267066,\n                16501151485480928243,\n                5164267149115550765,\n                2594692795895679355,\n                14280335185447698254,\n                4970220064329069703,\n                12700511247281457031,\n                9357661341818532747,\n                5976227213729484842,\n                2603370613961010712,\n                12878876453986011658,\n                12614332416265768442,\n                11711218014924643648,\n                10655032017324143953,\n                17992359291438428544,\n                2028340169188763801,\n                11337597956814839013,\n                3790580704158447112,\n                15661080312640132051,\n                5990952720662828532,\n                2238062688033035456,\n                7214374085319154262,\n                6225683889287881657,\n                14352811622893565131,\n                14441940256427869428,\n                11264789359569297809,\n                13541671887968904175,\n                8127321364325418809,\n                1617127834649530192,\n                11585884571784117082,\n                3211445923374162685,\n                17806365145235708527,\n                14310538800447604307,\n                6443392190904066779,\n                12304012177210398685,\n                9644770647148205176,\n                10349883319707014538,\n                13335242320392313944,\n                11550748494455916510,\n                14451727464612357396,\n                12354315710763337118,\n                5654383747200879937,\n                12534212795765636178,\n                5562388391253840440,\n                18294236533364599656,\n                1155120808307866205,\n                7354961778452510694,\n                18411509148244472731,\n                16833067451811570610,\n                11664219918607046336,\n                1931829024033366436,\n                9466235535733377083,\n                16125981341055192255,\n                13123158579309508422,\n                2811914968022899296,\n                13666576380287885316,\n                12073873146611787542,\n                13976563976935754757,\n                16819184991876208483,\n                7126372516019046104,\n                3771351679962818186,\n                14749464410272499350,\n                1158403298912255932,\n                2704550233949493414,\n                2361919431011664920,\n                5147560855044821678,\n                316960590350675551,\n                8956506393667806523,\n                14816316691312040724,\n                5483483435418414420,\n                16492702091910529628,\n                11531197856172089811,\n                9119688446381120307,\n                9148465870444231525,\n                11348956949863877257,\n                16515747438741224650,\n                14748627773020492829,\n                6792333258618815286,\n                12745044341734710216,\n                9118601693019210121,\n                3426576167844415246,\n                4516979855142897567,\n                18383203113196616305,\n                6037335393642080610,\n                5178029553332071284,\n                120594988188384758,\n                16911068593865363851,\n                5611330513352860577,\n                3672922004740508910,\n                9348962843954154258,\n                13167081398063848866,\n                8662579917294749869,\n                7714235959241362618,\n                1992168626444259154,\n                2892890698408203389,\n                4458208962709454498,\n                16006038729069481615,\n                9254965750786898182,\n                9178915422232682008,\n                7329871300650615008,\n                3409678840041114839,\n                8437730364512235388,\n                12654053093050306243,\n                17603379767897285990,\n                11140578823362012333,\n                18400373855086378549,\n                13179220706346381456,\n                9393189516096637793,\n                7962379756613380226,\n                3887762359860195719,\n                4702005148801552936,\n                13554138609046523902,\n                16949160381904484821,\n                11391648750970778464,\n                3884921049575088732,\n                2209098818625079997,\n                17799308759029324494,\n                8498222108115834352,\n                5958053849320451390,\n                2912489977852727908,\n                9002784252893780496,\n                9103973893872873428,\n                8800570704285521553,\n                8871184059044310741,\n                16063400495158915832,\n                4031307968282193036,\n                8573254083908951390,\n                16828584717166299815,\n                6494527269040260826,\n                7249207279315565170,\n                13665554008066255134,\n                16839236341242902217,\n                4123411447375871691,\n                10234357340093040168,\n                3518390908608069874,\n                1349715014789845667,\n                4808798653471270523,\n                10095338955926329757,\n                12695489128540790910,\n                16406780457966718375,\n                9629301538534411032,\n                15498997222980997073,\n                14953211317262356769,\n                13024285896073029281,\n                14612862358802352485,\n                13035854789120349150,\n                7106552057026833281,\n                14174041880363702304,\n                10636381469539675255,\n                7187203466667480841,\n                17084717625060872520,\n                14126252750523939037,\n                15698822748718907462,\n                7397904980198721162,\n                3690934666532247692,\n                15065052457896220534,\n                18426160025856536769,\n                8825186243264577791,\n                1029026778404309644,\n                6950954458719738495,\n                8771914568967577350,\n                9728022865849579333,\n                17765239852650572501,\n                8343956648157842199,\n                6334778100080475126,\n                14664915370166297479,\n                12941375852754193937,\n                6405436436050091550,\n                9909891363532277572,\n                17675467189601777836,\n                12324897459248787941,\n                13981335142409795938,\n                17744674612593350856,\n                2757587566489447009,\n                8956578028983169012,\n                17018240562727015214,\n                16391639968111798359,\n                10795774151465209457,\n                2093281970351304070,\n                4858229909673020125,\n                9933967343419708401,\n                6016509820559456727,\n                8502253989054157587,\n                1829270427581251166,\n                15709494579608995279,\n                8568909950760020667,\n                10892820698227375197,\n                14181785622385373392,\n                1741244869916907800,\n                5584342639358924336,\n                10920058455798795209,\n                8773147161499562392,\n                17372651285045475439,\n                4317270331835178992,\n                12072221230432227872,\n                5409998193192839065,\n                5774604676764375748,\n                6270673186535390929,\n                11593578005123149455,\n                1350291030727318811,\n                1734041789149423611,\n                17594245397221493182,\n                10230281830065256754,\n                17395251244463936984,\n                6363273717700984685,\n                6898868518537597264,\n                5078809256797027276,\n                16014780232233692324,\n                12698021273486013402,\n                10034628326465398981,\n                803921083181133037,\n                15053987885932962839,\n                2543409146477711493,\n                1443575144201918042,\n                15527634810280511429,\n                4846659158470140918,\n                12183993101313012462,\n                12953651110928456969,\n                15038003468538497849,\n                16252394591537250522,\n                4193562522090296620,\n                12800591763579590396,\n                15408603400942806170,\n                17682640208554596681,\n                12409260763379977486,\n                9315397818726387830,\n                14193643034683668324,\n                16508104272720261755,\n                13905815394730317134,\n                3679293709974358468,\n                5907121386159753765,\n                5304769534414875015,\n                18444287322445993596,\n                16494909212649576365,\n                1411980536871151577,\n                16554121151776992767,\n                10463210072047518059,\n                18023249470213998238,\n                12383793606215823679,\n                800485989566329537,\n                15071139529581604306,\n                1895628018455249296,\n                1105126069974836026,\n                663584933815778847,\n                3312928249076628720,\n                16646825576352631842,\n                12151072254529924642,\n                8642785126263747138,\n                15111584853907028239,\n                2776308895820674677,\n                10812673714292641746,\n                15054903323219264732,\n                2933094921150563585,\n                17830062919092998452,\n                10432330036767081552,\n                1033494976738144353,\n                9761049718456631119,\n                2978550270506139328,\n                2266577450295768406,\n                1214959603409486419,\n                4338607014040436,\n                4115159162283844446,\n                16888561205519247430,\n                4412890126763454080,\n                85232547048588047,\n                9970948529228850752,\n                3713393126801217778,\n                10760802738778841380,\n                4895931449000106045,\n                7255762665740428559,\n                335936537100116164,\n                17662778773720603199,\n                12685690660905184006,\n                14808811012699062151,\n                10663380197090780332,\n                7067049757688041329,\n                5878922448066220307,\n                14490189620281922843,\n                14473260627169887886,\n                14832232348370447833,\n                5951438093661647765,\n                4872796166881199876,\n                10429350570401478982,\n                15251172935852223950,\n                7325621106097392986,\n                11834629549993290294,\n                11569303197879748368,\n                977753391334101798,\n                6969686311950446853,\n                7366200137172124620,\n                14212998724743560415,\n                8081354270400804456,\n                880037272912518632,\n                380852277882293501,\n                8947498467697222234,\n                12757931014561147509,\n                667810441349799809,\n                2059689120439565076,\n                4750342010666522618,\n                12492546560830555305,\n                10465223395020225996,\n                9585389043436680319,\n                16512031046174235646,\n                9200703296926083957,\n                2032951915453711444,\n                8002381174072382487,\n                2389280604724196215,\n                5721524692632905547,\n                7647110976590069211,\n                12059178411864741586,\n                11975912934455308497,\n                17753420811972470476,\n                9192795740173474360,\n                12105166740957629248,\n                1250032644270746132,\n                4765787287696278663,\n                13422669569705597563,\n                11373393845567526876,\n                9153761787497611672,\n                12030450058080806969,\n                16537144145501712177,\n                5983397454957073922,\n                2683673672010015032,\n                3861849825629132671,\n                12629475949497494729,\n                9966234113604834798,\n                8466461060632654110,\n                3335857898642241962,\n                10682117780482341111,\n                39787149161941136,\n                5109208035333406420,\n                15684027554962652735,\n                11748970404336820351,\n                4095159288133322954,\n                11402790565133565981,\n                7401785106763668233,\n                6248303083190138658,\n                8738855753439299071,\n                15339296752899687482,\n                3182643107247815384,\n                9378566535341755855,\n                14162009846460499887,\n                4109114270719890973,\n                1511416153435046138,\n                9020508522805341634,\n                7477142615652523025,\n                18385803953807265839,\n                2546195602154738889,\n                7405815335061777589,\n                669094957884330982,\n                6056073383962448124,\n                7353716808540962518,\n                4360012167404246482,\n                9748894070631625514,\n                533481526701689863,\n                10374030482918918166,\n                8591056344610511021,\n                5753611323076772742,\n                17682325790000893453,\n                17410739240868104811,\n                5651721564405833200,\n                6771155463622294161,\n                16102506172900055409,\n                3922155114242412611,\n                8047195046803908182,\n                10181935025035061310,\n                7790459581343029499,\n                12616035204180788696,\n                11350000801651108812,\n                9664257517083996508,\n                6877290837507516646,\n                2900668296021062883,\n                5478674374212655343,\n                6296162153147759087,\n                16234745308754151636,\n                7633277882818614712,\n                12843201503731712898,\n                14050083812260020416,\n                95836250787434633,\n                8997148048216279615,\n                5687865929885690952,\n                7684029056960298539,\n                17362423790832901707,\n                15489463223618769754,\n                489477444088932230,\n                17185715982289417959,\n                11823522798262762160,\n                16827938740128105724,\n                13257410922007807743,\n                4679309639860400639,\n                10164917239224603264,\n                7304922446473936277,\n                5597481581945817575,\n                3820424595621388213,\n                6884972150866725771,\n                2694324376629657414,\n                16833520400918984369,\n                10912563532735352632,\n                7352008235482304863,\n                15885791964406330114,\n                11790453162438620892,\n                7239285021069261812,\n                10125071555494474444,\n                3796211625840968848,\n                193266766691985397,\n                14792644085266904226,\n                12987152514130686235,\n                9436744123646480376,\n                8251406129814681521,\n                6271920831800751835,\n                12738844182063426283,\n                15330691163818996222,\n                1166041665727565335,\n                13315209544138143871,\n                2216677316767409466,\n                12690036582164080137,\n                3031307738126062683,\n                11944440105997765289,\n                2026188631449062025,\n                9212773879860499293,\n                3341981308024472580,\n            ],\n            &[\n                13169652012768583147,\n                11662749290968821290,\n                15540028649212863382,\n                15222191772599122928,\n                15852211273603082347,\n                2960464712590969339,\n                9805532347048503730,\n                11483156842014743008,\n                12223751000089978338,\n                2069577308821362462,\n                448020966454441311,\n                3493610387626232963,\n                5182130948708681868,\n                4456536535034921689,\n                14139535083059739910,\n                16341604127053129275,\n                8476750032358968964,\n                10942274856214572646,\n                4426573651999058804,\n                17958371714565221264,\n                4238987860855800392,\n                14450925264923938948,\n                4364481289454625563,\n                13074790925168694865,\n                17725186031491616550,\n                3252385755044260850,\n                2489691844698347065,\n                12584453984545921259,\n                16484939371755776909,\n                17591699265602016514,\n                387926126025483991,\n                2463760292646247776,\n                1563580628888369628,\n                12118979090065897855,\n                7930230430393343357,\n                8834023487181578700,\n                3705061516543521950,\n                4053176902619603587,\n                6269266280509284877,\n                5236641881717368169,\n                6899670106034156441,\n                12840225294220778634,\n                3029440279850048735,\n                9595166473221718273,\n                14550471357175468027,\n                1255830945916836371,\n                5122133954630663971,\n                1502740582962090101,\n                9086275497101221342,\n                5421916064800438697,\n                2179464833779544632,\n                8247585817871008274,\n                10322070671895980987,\n                10962237209348590213,\n                1167315820290398061,\n                4563405457798620948,\n                5324869835018392710,\n                3941515430275954463,\n                1740094742017128848,\n                6138471019874045522,\n                9176213051434147108,\n                12501904812453849864,\n                11388325168842467058,\n                17687408972570957542,\n                4497137255970523312,\n                11770269946165024215,\n                10156397926378383551,\n                2019377424484113393,\n                3590983554593693717,\n                15657928449196312716,\n                14894403732533901822,\n                14625564293418317463,\n                17710716015671252818,\n                638852277383858770,\n                13800670797826096071,\n                5519007738268375392,\n                1013914690263468265,\n                13249504241724137521,\n                12893315643913486917,\n                2437939332985629386,\n                9866735673756110580,\n                7894145839618709904,\n                7802203558085957599,\n                2394814001366981818,\n                7648858197866754106,\n                45932857419714984,\n                9659675215715090679,\n                12803466849037463477,\n                10717587339591792614,\n                15131328571226415781,\n                17805628124155724278,\n                13655343682572989974,\n                17362327502804463995,\n                1075287460052064029,\n                2626850396158965217,\n                6885136253881452991,\n                18424853270962528365,\n                17198461501972637926,\n                6379806426022159044,\n                8783653573177405838,\n                11457364326293914599,\n                4889546163609369345,\n                8345334679410921999,\n                8128212263869118047,\n                5243835377297724594,\n                13077589216209892913,\n                14947690960428829294,\n                7468326754846892750,\n                8665069680383178636,\n                17267364262089018920,\n                14794644088627434581,\n                5781944628494317535,\n                13467037542503882140,\n                5504287258083448304,\n                3101706185952735851,\n                16528687565738693574,\n                6853101285149030710,\n                958150364135525317,\n                13159192403688468400,\n                9000130047394330226,\n                12454106782612240528,\n                10410037892467703265,\n                2755063393447593674,\n                16909229563067880679,\n                14030067308250726680,\n                304063827283258286,\n                18020451823918033658,\n                4591035690657100956,\n                13162350837887011458,\n                7701399978207767086,\n                15815279200816529309,\n                15597387052720630170,\n                4740390593486726162,\n                2909712595092459460,\n                15729877265226222100,\n                12096570103612063938,\n                13702753332858235272,\n                1411835182384377603,\n                17487917594195511154,\n                996305544975114980,\n                12929066524383774152,\n                16956610067055251962,\n                13012122099231548957,\n                14395689158572846177,\n                7935429077563080059,\n                17542764935243101497,\n                18413828249925519615,\n                17271321257298840331,\n                406766324155888956,\n                14818331828215117974,\n                8187386216945380849,\n                16792638575276899182,\n                6540004189057298818,\n                465689003663102769,\n                11974785539062893556,\n                11523099967255714584,\n                14591636912283935445,\n                4871757987380755363,\n                9308130069290886865,\n                10612219179153523310,\n                5420071244571425562,\n                12724302122592532888,\n                5173545157589181140,\n                1429324130148847596,\n                18414282026575416657,\n                1721766939064217260,\n                185288146264311331,\n                8027581238524003859,\n                12629121378225318691,\n                5422022678890177669,\n                6300007666394297907,\n                13771277516427401556,\n                4461063943424152501,\n                5814271695863693557,\n                9833762282568603070,\n                5534898830643720899,\n                11414581203473717153,\n                13252208296859650317,\n                6070377927034194834,\n                468982118171070321,\n                15569817073538385644,\n                8515954578625472255,\n                17703147536676285546,\n                2713926565223832109,\n                16501613896332875878,\n                12360649233716580846,\n                6951122318765494287,\n                1255018572838364315,\n                5022530899188934293,\n                14471021290055621346,\n                3965972119993826976,\n                10914640319991729939,\n                4671893019190076511,\n                8132288757883741990,\n                7379730619550447967,\n                7082846353163966035,\n                7749284037330602929,\n                17090786448482076935,\n                3623093583024522445,\n                6775174256836032571,\n                5932859643874401763,\n                9263718069255818484,\n                11941172789559596258,\n                7505495305758940713,\n                8374557854631657796,\n                5030384219708396008,\n                3609081759463861677,\n                2444176790044307758,\n                12883357531875110193,\n                2545675590276006076,\n                1091049428613676247,\n                3001645527995991696,\n                9613284625002680960,\n                13486970893816936976,\n                11564610387350917328,\n                7838720830134816136,\n                3368189672511472263,\n                16407993343222005051,\n                3965440550685537978,\n                4708478243468404768,\n                1875742626798710446,\n                109477476572266497,\n                9185060711428219960,\n                2062557879153655855,\n                15504010890019002364,\n                1436468774610332740,\n                470895386030379118,\n                11192666441535176072,\n                7094623340817246353,\n                16041820192281853667,\n                5048179711756437977,\n                1908765243120848557,\n                10810219542319634593,\n                15971282719319513661,\n                8395180060853137311,\n                17415231760777435363,\n                10489441496511966940,\n                3213813993411776195,\n                13309643264471443871,\n                14152370013037392509,\n                9805694808649718454,\n                2991106746654603900,\n                2279780759950444362,\n                13989789024965052794,\n                11942900996372546394,\n                15051646099368945987,\n                7583267444740224154,\n                5192555551306992142,\n                13216959612015226558,\n                14397593124921798192,\n                4374707725758052604,\n                15529039788482882168,\n                16475619415913302762,\n                2649655538625316107,\n                11899566009797061232,\n                16892018353302708322,\n                12364166218684092426,\n                10372683350152669575,\n                5328477050361662527,\n                10949313792626687170,\n                11924230090558408019,\n                636095257275314085,\n                10210914536395617961,\n                6515368615710817299,\n                17001040330117317563,\n                4519581466335837391,\n                12514298524110577503,\n                1744739741016504912,\n                9689951195577973993,\n                2774540351629210180,\n                7646006525601223889,\n                7530479442266342421,\n                10538917317906671989,\n                6031253606146099659,\n                4606167752034374890,\n                17763804757970320617,\n                6871166461842469695,\n                3069238346134678776,\n                6898492556629873366,\n                18330913680324098797,\n                11469514731644700404,\n                541525751461369940,\n                18096353837092553451,\n                16390355202675291281,\n                11980660197830118439,\n                15349236833293249382,\n                1901608480726107605,\n                10754477505423276549,\n                1780265741680781169,\n                6204486525934807168,\n                2675596223932028138,\n                1082656654749778403,\n                15313246555910578407,\n                16597928615331243076,\n                9259667019969423039,\n                13966308744186245944,\n                3711817850123753976,\n                10380302371138242940,\n                1102076039759449071,\n                1796134829015781040,\n                8320143967311972799,\n                12603759772660781109,\n                9343508021191710450,\n                11833581848018650785,\n                5036078561764059265,\n                14477046704375156568,\n                17958581882146395247,\n                6312863763728381603,\n                5890775652924120757,\n                3024100139720533291,\n                15594980805126031556,\n                9929023026443104564,\n                6003618257535256748,\n                10584762467178432077,\n                8070692469310128137,\n                3448506857138757663,\n                12067250229870443464,\n                8289617863280099780,\n                7705347156484755083,\n                8239333463449775936,\n                12953560490361273923,\n                7863343728067574413,\n                15499170354027597711,\n                16789849673988523596,\n                193554686279189480,\n                9324166766841362509,\n                17865442848307712220,\n                4017570072096420828,\n                359910874540192895,\n                14283136222667718022,\n                15545842610688758167,\n                9161703351540143861,\n                10856046010222875891,\n                270665191423043189,\n                15816860058997167317,\n                10604344774996324885,\n                3421439666836669232,\n                15362489920565158049,\n                901986887674190509,\n                8102011985696643347,\n                9831189590417175739,\n                7694208525827500802,\n                17761503253302918415,\n                16843825659097088549,\n                15968418888658984723,\n                13213298841864639514,\n                10768746828601368994,\n                15843374988242905966,\n                10372481985078119452,\n                7145529267057724453,\n                588445411774656377,\n                6907651744680403237,\n                13729433346623178186,\n                7466282812151723072,\n                2397976897839660773,\n                3595288154116844222,\n                3771046205661211665,\n                18292138992930644589,\n                5076094080207419189,\n                16955129624357257007,\n                3929215337030354093,\n                11057894513779502294,\n                11863471976993485758,\n                9408615240131003867,\n                2448439901554368107,\n                7669176413900589628,\n                13955883899642443946,\n                3559761514651432863,\n                5999853120304570098,\n                2807928142993089395,\n                6880972979489023884,\n                8540438276045396759,\n                13336393887543928327,\n                14948024915319356336,\n                754486632845103448,\n                16252590658474672770,\n                11838852632524903679,\n                16841746824793599992,\n                4866584459095974245,\n                13046184814853980498,\n                8710985684981006226,\n                2355658489901240093,\n                17682251256218590491,\n                12738885399031396318,\n                3641463259326479601,\n                11573802402437143897,\n                4785854649163125380,\n                17654700608592820265,\n                7689738254866306083,\n                3911334929659733907,\n                3805687817679677472,\n                3372180752527728873,\n                12516023017017683246,\n                6541569134387572029,\n                14932792460356112158,\n                274079842264421275,\n                14741476297422044947,\n                7640237864595124592,\n                7990415001403780690,\n                14485175485850127358,\n                15701126719940798119,\n                7497786401585040464,\n                2046586308065249596,\n                4234230752844127257,\n                3490034085431124756,\n                7410205974894450493,\n                13594277608316567296,\n                13163068385450899386,\n                6911330603633557461,\n                4165273348787835236,\n                13196815825235476993,\n                15409229411685315073,\n                4238586327560550200,\n                4274172509763128574,\n                8233070080684386642,\n                1152981557203525396,\n                2258263369774438742,\n                16860590243592954334,\n                10642146327347114407,\n                16394076595581895042,\n                3547145813374894294,\n                7303429257652622247,\n                4599869911214805642,\n                1470127264048118954,\n                6553553520469198052,\n                624221776008514758,\n                16024993613079197687,\n                12072685851575104500,\n                4289561477780298769,\n                14522030035108027997,\n                10025959010474970695,\n                4338629041423254482,\n                12668451231751642706,\n                7041673834301289685,\n                1101300709714299914,\n                15830324192849592102,\n                6361267392222383309,\n                12743724653827284764,\n                13913765213720067888,\n                12472686594479717483,\n                17041667280903689118,\n                12612588174971368395,\n                4625038945277105759,\n                4288983616264520473,\n                13257170061268337928,\n                15378358854815534796,\n                1307879339751355693,\n                9045256242044980161,\n                13066137780318064542,\n                17483698129188252816,\n                5537781126683250458,\n                15814088167067959984,\n                17124111106622331645,\n                2228813159198082553,\n                12771677329276373795,\n                7473600359686104579,\n                10172401847101693206,\n                8817322474066906889,\n                10002046533039894942,\n                18350636570159627372,\n                2608194133937884904,\n                16496103406635747044,\n                3203166370447920771,\n                1416097169966651887,\n                860034031549905008,\n                15435212006888252138,\n                4982756044520683355,\n                14527835149012332766,\n                15648655845991912781,\n                15220061209366144565,\n                10713592116389348982,\n                11856331444132914701,\n                13011883287657858557,\n                18375660967945668491,\n                7611177834315648116,\n                11475292136381607303,\n                12142625427672665818,\n                1644376245508948388,\n                14986147846200059747,\n                10358191212479538383,\n                2124663276626493099,\n                15025396046176607689,\n                7566356641233415240,\n                3834259550197202335,\n                7422439917941038432,\n                14335746041650957139,\n                11010643115481291768,\n                16639917992723217687,\n                3400935192914355446,\n                6526469202356090658,\n                2911450085827434145,\n                2592450403666061908,\n                6573976403851247795,\n                4285219873414520276,\n                15329532146725863869,\n                6799347789229688901,\n                6639341479260471078,\n                5137054100466749121,\n                5102420602612942914,\n                12454937665202983967,\n                12962650067948965377,\n                17483657740097839287,\n                12223498331603994543,\n                14079145217780475833,\n                3310333423646124225,\n                8148231670879135605,\n                9541038636961784750,\n                11089617618703446533,\n                3560209342825276058,\n                2574634823119268479,\n                2588311243176990131,\n                15013509191556503430,\n                15455072885984268053,\n                13986137485131324765,\n                5720067926322634989,\n                320358790111393789,\n                15410939285136639329,\n                15697272961739331244,\n                1355846111750777085,\n                2546959351276906905,\n                14534695021313396715,\n                12100942362109396400,\n                1909839808518887758,\n                15057164163203198957,\n                10816292376571145141,\n                17932667027515587541,\n                8894763284691124395,\n                17376767493810914651,\n                1054656077023869452,\n                8186894411081110112,\n                4918609723063820894,\n                10472223930221187526,\n                8210872174259857628,\n                8260857529094096436,\n                11707883934354468821,\n                7798711246011152830,\n                12313898141945763999,\n                4092899057830195664,\n                12768752632246510730,\n                7011904089799177666,\n                18269846218072729005,\n                4472126139715717850,\n                7263280326862818361,\n                4617033187864299345,\n                16062484525314928005,\n                7764862313171817272,\n                5507098054488704246,\n                15417948890339509732,\n                3199184308759380889,\n                12873647785813929264,\n                15851634423390314715,\n                3379562369756927370,\n                2914796073219663247,\n                9453518290639493724,\n                10389507097848983202,\n                6987583823829734148,\n                5644521590882572085,\n                16385036288302112854,\n                14202037992186130818,\n                1662729350231436066,\n                16086866498209553899,\n                11668110277201388817,\n                2581723866463834707,\n                14466562150912612524,\n                18444381539786477861,\n                11792751584642451686,\n                644172128540161319,\n                15714856399314491326,\n                6336413224068482580,\n                15648040294508822482,\n                3581892413107868745,\n                2087860646799841458,\n                12928312782299116049,\n                4630539989871908829,\n                6915603518697601787,\n                14918733616941773093,\n                15087665207194981362,\n                613969264471068110,\n                3544544803540968193,\n                5220360717428049381,\n                3375260723217895506,\n                16778447987047186697,\n                11894812810172861433,\n                14542979312432827779,\n                13561316753657099179,\n                1968473618327458185,\n                5456934299993876358,\n                7469735400543018284,\n                7068657239043349097,\n                9254040800524479410,\n                5214107275553666760,\n                5001330682797736624,\n                17026132790954295091,\n                10969354337912897232,\n                869351389198733586,\n                9574587810937905907,\n                6923373747285449001,\n                12719903474522918771,\n                12250857818862900982,\n                2153256573644871951,\n                13709729097688338391,\n                2899377834668376960,\n                6841869401787596550,\n                10339715141881541659,\n                718655127116157511,\n                13741406681906111321,\n                15392288868670671619,\n                17545786767738322758,\n                11089794771839702758,\n                219094231550242583,\n                9674358307241496741,\n                4002620491443309348,\n                8012290324302967070,\n                8714326673970415123,\n                12380264119087982419,\n                11108551912665576265,\n                3708955946231240253,\n                11607264285750874901,\n                4216424611300123940,\n                8256067698160491644,\n                7506994298913059376,\n                11501100133000306066,\n                7549037119651533111,\n                5112970978157051505,\n                13518442004335850902,\n                7350008695599366666,\n                9542638447580599221,\n                2158188779042279647,\n                1604170908932337076,\n                6391929341437538244,\n                10779746559124306734,\n                12656450449103176181,\n                10121044395803332310,\n                11651522650180060700,\n                16328514328541821784,\n                10523761782294701174,\n                1822303728984452144,\n                7260452386953933551,\n                12204494523152059466,\n                17100382786462731446,\n                12548225060484474439,\n                11326872465335361323,\n                5596285187831113760,\n                5909751003547848587,\n                992306619579834385,\n                2228664329259510492,\n                15196270917670055982,\n                2131889695890586742,\n                9819776790840463517,\n                1473593931814601068,\n                14939513955417919643,\n                7685117665289355354,\n                6724244559482510387,\n                101460542568704969,\n                7352190705745517803,\n                2150669404455836808,\n                455126870518119052,\n                11553577781469330615,\n                10384536636375637150,\n                14364597940339752635,\n                2495319672618636831,\n                8180783418013670444,\n                3773765470722916252,\n                10227754258298095569,\n                4811293038656815364,\n                2304664986814074602,\n                2418992918773594204,\n                6388448639180737685,\n                6893696275605311774,\n                13851958766811817366,\n                4793074330182947851,\n                4813793152033309122,\n                1098414269347239038,\n                11751908186279088029,\n                15167430159498163699,\n                10528686090760108130,\n                17120804521852235295,\n                5538072916971524268,\n                18284870874128074659,\n                224523015148941267,\n                14496093443691170173,\n                5490655299006793623,\n                11584315652765207551,\n                3229579698633170375,\n                5527375504543907996,\n                6239324650299686862,\n                2232148196848710005,\n                9031256656667465794,\n                40023723987633148,\n                14627741678268078967,\n                11950626749898431344,\n                14785414395108523186,\n                870832948163923646,\n                13004928204786500706,\n                11732704426571300600,\n                907514934656616373,\n                11587740830029349245,\n                7583505136677874861,\n                2623787766244261370,\n                10256163025245964672,\n                7257287909572091733,\n                4812915812660879618,\n                3468364439026649335,\n                6604147596013682093,\n                16816894664989923710,\n                3964120271755066308,\n                6086548275463043980,\n                10447117175471304144,\n                12856607441078849807,\n                10592398111690221432,\n                14269275707379118835,\n                4396127772639422927,\n                10489721798852691549,\n                6681412646421684356,\n                12490106130106455109,\n                3624408102113036819,\n                17246634770535451304,\n                73750230380742720,\n                3858795004528971618,\n                18037249274864620640,\n                9013680198221453825,\n                11909298583725721915,\n                7512555591920604211,\n                17449244834240874515,\n                7793591661081767445,\n                16652407448095073621,\n                11804971167281860328,\n                16410605854679152138,\n                1713343542446776550,\n                16483548344281970818,\n                4628627981197409087,\n                9083762764219706193,\n                17065951854876058290,\n                11490185594933330698,\n                9891012968004512035,\n                368256788081374064,\n                470621950908252,\n                17956316299265730194,\n                8221822257224301188,\n                6380872247545425488,\n                9031471961851140451,\n                17956391258409007260,\n                13017604911584754606,\n                9245778199486992293,\n                8056793204522970093,\n                2531655295742236851,\n                16039488662052065607,\n                4695551407385442957,\n                16581782264738209135,\n                9457268466305801158,\n                2502271077174158302,\n                836797013558343943,\n                1224523470498102285,\n                374165187087964522,\n                10212314508075547184,\n                7669093970332858967,\n                9176723313583927295,\n                8839526249801396044,\n                9460240515540152245,\n                526138750665184089,\n                6908994573320912372,\n                12176043050383940227,\n                8431292525679019707,\n                7800865258551716648,\n                2930208417676545581,\n                12001139080437682925,\n                2848294057310329443,\n                3495763019164815081,\n                13998099468531902475,\n                2334207795701343601,\n                1265352082029868252,\n                5352951968929077427,\n                11045950825318827473,\n                17705541510574119706,\n                10388016860076689091,\n                6188336841660552180,\n                3874842388902329486,\n                3586889024655840994,\n                7577730940669490050,\n                3828324032996703471,\n                7382564057518691083,\n                18020764642442034007,\n                3255848346667024023,\n                913981917700616307,\n                6544220161742236189,\n                628453794376152858,\n                5273139986123145851,\n                12804359385937816703,\n                15490118777013724970,\n                5004956137979193113,\n                11537600208633214816,\n                6041778305931749161,\n                18021165191120757752,\n                4439552721639804321,\n                9445924893904633163,\n                6333608419766441318,\n                6265966168082228187,\n                5090746176805509189,\n                12079779788101746835,\n                3405057163683809716,\n                18176431495575685240,\n                5416316679824315388,\n                5666993498240944478,\n                9396996717121195736,\n                15077940112899068312,\n                15769845674133811095,\n                4172092555141541227,\n                10535661541737621064,\n                10760049649331328984,\n                9044328015087752668,\n                4208484814661836163,\n                4524519455413453106,\n                8416163180819044235,\n                76133776812564214,\n                8938397440798861336,\n                7699462000599225384,\n                9542247023407697767,\n                1397476485288102889,\n                12838783590422826565,\n                11111769246893411506,\n                17719085637529819037,\n                18350048131892648764,\n                647133208572620551,\n                3545832683987398107,\n                17392149180006432089,\n                4645454948531556636,\n                4638633830898005179,\n                15832113029610700219,\n                12312766094616504216,\n                11054531676785061901,\n                12882000175930708962,\n                17065292675540451547,\n                7348135285662513163,\n                10368855461513742486,\n                17213692472848349009,\n                5448237816391429929,\n                17475251701204191843,\n                12352004908893419844,\n                4421019229248084817,\n                5233890583141520327,\n                15415498665325430242,\n                8699482400205838797,\n                11081065321342975843,\n                13692414560354688711,\n                2057100631763259620,\n                1768191442150902149,\n                12463118341434320148,\n                14697940362261450576,\n                7225350934202123472,\n                9180626944525820669,\n                14817691250517499688,\n                9524098384486815580,\n                4894140555324164954,\n                2309262794362375113,\n                8645740617004046828,\n                16829903653299752341,\n                4278553392732422821,\n                16174995535301769275,\n                7274361875865992211,\n                5483861345936568593,\n                16555617280692737205,\n                2106788877369503099,\n                6355572984153420404,\n                15413046204382700864,\n                15184587830187202860,\n                17638950466015943646,\n                10142359495639047596,\n                2852278080143788489,\n                14902051473257283997,\n                12684082230048932446,\n                5127878269602498356,\n                1458833335160283623,\n                18343902965575788886,\n                15956410439937236477,\n                10143815431586875695,\n                8519328419973108156,\n                9379288137799805556,\n                11116700304696206296,\n                3269635235146511468,\n                7446145908658980471,\n                8423421258962502269,\n                2960959498368537205,\n                8029834119982365442,\n                12951331847284209016,\n                13335373530776006943,\n                2051038411438343086,\n                14988843915712852160,\n                11070472159205332532,\n                2405233098821133668,\n                12872299485466251244,\n                4146849588411590424,\n                8652997027024585292,\n                9417874732592565535,\n                2771366489480367357,\n                16381568131097774387,\n                1160190173665475303,\n                12142110843989704382,\n                17157977103678150822,\n                12240974252728213375,\n                8005232037362794911,\n                62748564819661432,\n                15562900352067429326,\n                13819933941831285726,\n                8700733640462543781,\n                17417693392111317966,\n                11195518897113567806,\n                8656545261572504126,\n                2665140739762930045,\n                2523114891549547532,\n                15947075740878853027,\n                16617762624958355772,\n                9189411410511795645,\n                9417682881040880723,\n                1220008371097876826,\n                4473435335583972063,\n                12416336276688398745,\n                9439155074539900208,\n                17599514971068491442,\n                1382978212068751289,\n                12012964446858847311,\n                13059411911626363940,\n                9000605160655962560,\n                18444429515577739106,\n                1678358883660355393,\n                5074103451266196440,\n                1108189786283239561,\n                10612698979413855931,\n                4989895863474068758,\n                653620819971957060,\n                12060263383072344947,\n                15076531277958824549,\n                10597595939754188762,\n                15724450558403473627,\n                16382650125476798913,\n                8738893762787150302,\n                9733212779214420390,\n                5558001311635500417,\n                2720376062751869999,\n                2936217033743496825,\n                3059230718610361194,\n                5589670835881847684,\n                12297086381101763222,\n                12830838307506907529,\n                7727866232017902927,\n                16978583538503170044,\n                5646531489086592542,\n                5696883024644775459,\n                1778382958859079024,\n                9219341275099378906,\n                17593963150311257769,\n                198176573650528594,\n                10425519151629874209,\n                13457055667833759545,\n                17213583299444020650,\n                14862117423842849302,\n                16906392281688863338,\n                4290302946266596427,\n                13505570400341984024,\n                2056510386911305907,\n                11571082458161054292,\n                7566281435617775832,\n                10210241606684674096,\n                10697498687651578080,\n                4947318501826974509,\n                5861434792576988890,\n                9869040491958929661,\n                5532013052186573089,\n                12416594018569715230,\n                10820734898252214278,\n                8537468997207455166,\n                439343392893541672,\n                14734630723072977466,\n                9898041261033982210,\n                17393034157801306127,\n                13758525217758656857,\n                2713096067589327874,\n                12442874178280670969,\n                14498768890161377807,\n                161967360889456606,\n                11930601082339405958,\n                11362787206913160786,\n                12545070484550723467,\n                14815095129086834610,\n                8605787829002095856,\n                12923597973881209899,\n                10587151577465292584,\n                14183134664818382968,\n                5172374334040473114,\n                9364926097792520560,\n                6171919845492918332,\n                4386231931762251578,\n                2155663571428617218,\n                7765511219465701910,\n                12061535530010910259,\n                16100330205655290696,\n                9974384126080194942,\n                9674175848724908032,\n                1687977953933677553,\n                2052842863240418404,\n                18296704913226861337,\n                4023434438910601547,\n                9899743965354682742,\n                5310198234766113901,\n                5162456985274720081,\n                8646509974119784542,\n                6113717383160009894,\n                6014191554047499022,\n                8484348411248636487,\n                2876047496375093909,\n                6660788054730924011,\n                1664197372146636482,\n                2820993293910648101,\n                11665512417100144808,\n                6502457677692154814,\n                2170150732610996776,\n                15522116097990839236,\n                15440086643427998964,\n                3675113412536301313,\n                8316358419658521853,\n                189389437052919038,\n                6981753429704993440,\n                12802645856607643857,\n                7243825699014665843,\n                12796799374814419834,\n                8068467907492367066,\n                16310382387876189712,\n                1486061732225930791,\n                382533986053029739,\n                16359148449656380800,\n                17246074348224240328,\n                11700746273206874174,\n            ],\n            &[\n                12622393184452988185,\n                6576838566809301648,\n                5775205735049728716,\n                8287278668518156534,\n                12192798229753293112,\n                13075940713888694545,\n                12454048030060066070,\n                811912065849436865,\n                14514498508890956207,\n                3718975340013031462,\n                5748599663081118833,\n                7103827618714489700,\n                1300608812711622052,\n                6273491418082608362,\n                10602503410062294488,\n                3181236738912952810,\n                11220558709822910991,\n                1757050625501318151,\n                13622421981172568598,\n                12832273400791276781,\n                5855047466166966026,\n                8265514107974512007,\n                4674109636920327418,\n                15064411300962651052,\n                10245194862302150019,\n                14697255588820327266,\n                15300902461722524376,\n                4133685444341227543,\n                10059303764976223858,\n                12025228906916712453,\n                3342699448606724702,\n                4043427178402639607,\n                8354440664524965265,\n                14685529799335576021,\n                1998565942493742826,\n                424458568212209524,\n                17175147416410219809,\n                8429313419702361615,\n                13100329766043560847,\n                16630087004934016029,\n                1975643079807205422,\n                14257249811747812832,\n                16201214544277583293,\n                10834834555324096005,\n                12974966771898232184,\n                10175033989408956356,\n                13198699716510876245,\n                12667628170354632487,\n                13500517333069730437,\n                16670408922706885903,\n                16358625308423139600,\n                3004604642549199974,\n                15303830789363557104,\n                8922231358023374966,\n                5889284410855917356,\n                14457653243881523958,\n                1394588608017240060,\n                15159743360841977286,\n                16367826019458727864,\n                13291054711118709892,\n                5739609590986339029,\n                16727185121517285485,\n                5857477526908140920,\n                7564539623883188584,\n                15028512432506130151,\n                9451165299139733038,\n                7720569164934553601,\n                12250119607377112932,\n                13838627703516838495,\n                4013168924318862931,\n                15619946084866502269,\n                4850331740702252734,\n                4489013954543776517,\n                10588792414395604443,\n                3902488335149478186,\n                5227683403359005885,\n                7076009259772820031,\n                8343084757976224303,\n                5177402640814818565,\n                2803445024434417300,\n                4085994593957453089,\n                17829839529352422672,\n                3578735210913423849,\n                2792806554222369562,\n                15534236200548977629,\n                3124727634409390443,\n                1084234245147417462,\n                1598571627717804884,\n                752329673301761003,\n                12688955135473243162,\n                3217100306345888294,\n                14566509229614296336,\n                11270786911681876633,\n                6662721337309084196,\n                12158803014774283480,\n                8518459513237421390,\n                5910661800660978266,\n                744628824726848011,\n                5469395445007916291,\n                17702754906843708743,\n                7968296670638284359,\n                7510310566936008628,\n                1793306228498108099,\n                6353661129197447108,\n                3126760188195263395,\n                18414397606186055674,\n                17486033377523869654,\n                12070987014285382902,\n                9991875370105670503,\n                16129470720148507308,\n                1039596679504335478,\n                12158960746785703045,\n                14081886766117011421,\n                8985649855006063812,\n                16817043795641114882,\n                3052278422002310841,\n                11364643265564647695,\n                5842131153676887611,\n                17671187237412914007,\n                8666277097534907268,\n                1983817527033510933,\n                3541460822071490249,\n                6007905868789893806,\n                652610536509913563,\n                11037032573713184751,\n                11009156643744878354,\n                17591018917017615621,\n                11710867183921879437,\n                12251167927128949787,\n                8974964125845019147,\n                16969705468711169632,\n                677161721939989175,\n                1648428070692386013,\n                17084411431327447982,\n                16079687398141624486,\n                2070436743667033809,\n                2763689681570019260,\n                5133447300857161972,\n                15255425835157483742,\n                5966697992253286903,\n                361687726752744332,\n                422697286210467434,\n                7041898431113518823,\n                13795043150550399420,\n                583755960417947241,\n                2875531821527607804,\n                4394534528084370577,\n                12535851821369757920,\n                7213044591651422167,\n                1000544905146371455,\n                4653559762494073142,\n                7779502532203369012,\n                16702927718605692181,\n                12982197318021037408,\n                11786209078045506353,\n                15564445991051693791,\n                168023569501370168,\n                14266568007896652015,\n                5832135998445910960,\n                5245116375679737807,\n                13311176288056325459,\n                3321928379396402727,\n                2233377424088736972,\n                16828319963915513015,\n                9909739734979137218,\n                9397081158643758651,\n                16237610644843443174,\n                12049861989729092874,\n                963173337050875289,\n                1393288980328672002,\n                8369734762526854678,\n                10087190917060030061,\n                16611332898402499111,\n                17383970934682687319,\n                1806005829620081904,\n                2572338165105796552,\n                12096685872124824149,\n                10625877836202904943,\n                3565777311969108583,\n                2012783419915002762,\n                9017825065020723376,\n                16320469478354954310,\n                11806049513756650829,\n                7727243155747891778,\n                15158785566684134320,\n                2456938594466970469,\n                7873271366166028790,\n                7686875950801483839,\n                5617367656140550179,\n                13464612212949386527,\n                14757590544232715739,\n                11128260848489879698,\n                17626653494839808091,\n                4716501168031180893,\n                564851231412074685,\n                8132887702611477369,\n                17552681344611428819,\n                3132957846371517857,\n                11213590168035816092,\n                5431508051609838979,\n                4515078710323627036,\n                13543555744861125477,\n                309309746143903518,\n                16853539194117891693,\n                12430835367581296760,\n                9255793325320254163,\n                6591016556383892120,\n                17100720673447110167,\n                6061633534359930907,\n                2424801126737847877,\n                143356278625650878,\n                13554246058973057,\n                2522638740117423042,\n                17137049738161235473,\n                13176139598975768388,\n                1166120501092890058,\n                13609465226914230670,\n                1875448353263386203,\n                11743691709994844759,\n                11061975822835649567,\n                3910967390258776729,\n                13577511757143681922,\n                13827967505806592907,\n                2051032579834721288,\n                13464396192578309450,\n                12800325352123601126,\n                5662172040792660351,\n                4668403599689432265,\n                13491732430526501935,\n                14157448317801936638,\n                9727633765236455195,\n                9719667367393442680,\n                65474725188749034,\n                541181075058713986,\n                1362959920153019155,\n                909082441655242031,\n                10411762570666372898,\n                11947296633429547042,\n                2358875224077331054,\n                18328103363666444110,\n                9866396237081281387,\n                8956667376401863125,\n                3553975952663161681,\n                14635072569697080107,\n                15544243098851103691,\n                1716867379502200816,\n                8776276410599591217,\n                15666047021340369577,\n                18147839669015605124,\n                5572968214423121059,\n                3098271794032834805,\n                9673511458079712674,\n                16010905689567823114,\n                16267201338365627673,\n                3382936832397700934,\n                14957330839370249294,\n                2642620075223240608,\n                1037193656622159510,\n                9012211029341477206,\n                11431820793941846484,\n                8851179188286979417,\n                1398798117665992200,\n                10789412881967821793,\n                9415310270308545401,\n                3878698623022480586,\n                5863277386811827416,\n                7839335917417032151,\n                2682939031547768972,\n                13397811690933306272,\n                6260148512861761963,\n                250324816893616712,\n                9085404939459661953,\n                9291403781568194640,\n                4943156069611799558,\n                4012150457352746082,\n                6743913241329187121,\n                12017429880940425975,\n                12929043722801309882,\n                10207563294594880008,\n                11011363281303738187,\n                15710481255331302269,\n                16065095211995167995,\n                7729419910130307261,\n                14687299092290139624,\n                14212774840097619295,\n                2696933303282739820,\n                18380487173546723450,\n                16340353901250449060,\n                16974439742831865800,\n                950395719691498193,\n                14294722598295985858,\n                9819629466618736444,\n                5134213478899186274,\n                15000357065088523575,\n                10866834082882265182,\n                5562209566130970606,\n                11574047289359876875,\n                14220066737185616618,\n                7779431549476206578,\n                6164322776781074672,\n                12698699879532635460,\n                9775735470622210670,\n                3418783774094779723,\n                11711261272918394032,\n                130965081793297038,\n                17951168177437733692,\n                10982891057320326220,\n                15446335221541982820,\n                3245348832258032003,\n                16936841548783354130,\n                17845797372140897632,\n                15738639878561184724,\n                8036219019342274839,\n                1452217306593250967,\n                6524640126112677080,\n                9487637664603922399,\n                9816896718276865827,\n                6660361176840108508,\n                7155686979915548241,\n                5363459444036855846,\n                14211791847250927632,\n                3758021753984352623,\n                14892848306282510880,\n                5622159652308652067,\n                3013224027720379126,\n                6593658810977588348,\n                8737392006680055212,\n                13098306207053606600,\n                10321069935686406569,\n                7922126603433897812,\n                16345323120534317859,\n                2051345375893155420,\n                2642889174797452752,\n                15490895676079176387,\n                3421728094884350553,\n                1403789733153795522,\n                18095248776246397645,\n                1141680856759996549,\n                18100437303596844925,\n                10084704427684498223,\n                6594067795036706889,\n                6973150786346631215,\n                18179961484385983667,\n                13461945752721759987,\n                11607193624374158079,\n                15870559753884484047,\n                5909010369355025391,\n                6576523373028484144,\n                16932784188428621626,\n                4532369146195665092,\n                8439234310823545929,\n                1340079530194594172,\n                14887691618471650731,\n                12957273899514368091,\n                12528827801491392116,\n                13543620352724873404,\n                15027641031340635112,\n                3497080345802388600,\n                12532486649114668085,\n                6567958427571461048,\n                15524967599943619324,\n                9687676309746098775,\n                17837290175131112775,\n                6562577965471546738,\n                15069045445640377298,\n                15845870183628003510,\n                4882896822391168376,\n                299291354580119732,\n                1253349370757830450,\n                4019946893924061554,\n                4835687088435778153,\n                560543554021366834,\n                9073367421711646017,\n                7210725233620419378,\n                1298874732344651234,\n                1572176424217571034,\n                13459119860690231055,\n                14894361022235972365,\n                12479129811186551951,\n                14014563421012570478,\n                5045150035901968604,\n                8669967307441751567,\n                1905648106987249698,\n                15427548300560765880,\n                16929690218389356941,\n                2257784955568148289,\n                16671033335294376858,\n                17747845134586030566,\n                1166533040996500790,\n                15593722083313803843,\n                9396109408892612308,\n                11499981530721896824,\n                16970499445754392592,\n                8812544874418820841,\n                8398666252211387757,\n                2704923715823740363,\n                5314497299504523542,\n                5160833323750080202,\n                4489614019342255168,\n                16950479847425158028,\n                6792145380267486390,\n                14740232145636169668,\n                621507344077794685,\n                3751460578157408141,\n                8129084486654095901,\n                10001447130583054783,\n                12074020860950174718,\n                4077799248444467034,\n                6822188364356126108,\n                600699026381065222,\n                4751815635139776884,\n                15367619962178612777,\n                5104893889903277375,\n                4661242055023047595,\n                2154923710109688891,\n                17429472085810639176,\n                15724063920670689806,\n                15216015843686884607,\n                12102731527843294992,\n                5923322163550614145,\n                578844978773347240,\n                10464767667513753088,\n                4422886088759698238,\n                16103295972923438952,\n                11952617258811913803,\n                6497649448616698694,\n                7393337205916981343,\n                18096118845330092692,\n                9417521917459925024,\n                10361801380161480586,\n                12227883220061157093,\n                12402861272457739535,\n                16959542957232270118,\n                3100109669354124792,\n                8252021294756255295,\n                6601544514524806222,\n                2299228880186395084,\n                17206687535661702962,\n                11126365220307664227,\n                14027475381759030281,\n                13930713973102273385,\n                15470781455897247423,\n                11132792425729103210,\n                12743536155285333682,\n                18404252734721007574,\n                4471349713039799575,\n                1097648964215121725,\n                3481722566194833071,\n                17004865376724342545,\n                4412003432895082804,\n                7207210335443122075,\n                11185557399280223037,\n                17791545657588716507,\n                15001384756479157715,\n                7068904123591490511,\n                15342280096772936670,\n                2962241209356984664,\n                11085614675955826760,\n                17304628576563637894,\n                13276820937207248747,\n                8496585032541849567,\n                16867719644448479323,\n                3556128556368553119,\n                4135507236401264417,\n                8300362706308478874,\n                12391805295598536754,\n                212746375693666561,\n                17668657797254926684,\n                11472227395456264735,\n                3346261809041337938,\n                10494844376481252742,\n                1039434633412734920,\n                3537248641106173003,\n                15722028107965146028,\n                3957344489070663630,\n                171520814732107885,\n                15701539439111209401,\n                16266903088897196785,\n                8162180034652464302,\n                751396451910146673,\n                6284978536639446110,\n                9475038153254288249,\n                3366181839966720435,\n                38511352552288459,\n                5091650762875915484,\n                15684434521130749089,\n                3313175693887858849,\n                3512862245616351559,\n                5836672242124333533,\n                7050189281309530509,\n                6693570573437863470,\n                1180929186779755232,\n                13670569646431885520,\n                12219171873489819591,\n                4177796076111463096,\n                12523988008299904003,\n                2573301004696669683,\n                14000913768617402515,\n                1901514323758988374,\n                15680204389035820646,\n                4057543360329026133,\n                10484558774556926484,\n                16880563214620981386,\n                9806529946108790649,\n                64858070620446021,\n                13058265791054866751,\n                14208780393297513060,\n                132444534110050230,\n                18171930401783150790,\n                3788701567251119654,\n                8068556048675251486,\n                7698349927972499523,\n                4200940425301802259,\n                5859679210997281495,\n                1196917998587841402,\n                293846739593611503,\n                742395111532740587,\n                7299921458271130779,\n                4013584019577681930,\n                13051907051578937053,\n                15460522300561557538,\n                11739346111540426460,\n                6000392060961693921,\n                2093513337710768996,\n                2971782196230136142,\n                14650675906567946197,\n                13044422653436935289,\n                5393154276677237552,\n                9414604975305044529,\n                14383902696216976975,\n                3526706571033049996,\n                10453515348838320881,\n                1300027919459661427,\n                18220108229306772305,\n                6736376168692276304,\n                14279821335279300725,\n                1137238529965897445,\n                10675553998207815811,\n                10380811037741532194,\n                8166481736795163463,\n                1781828658320585086,\n                12391009694347491828,\n                917764047682931238,\n                5513578507525454078,\n                17200064132172477743,\n                17870911035870211136,\n                14336835701074601920,\n                11250050928475332766,\n                11433063323885652386,\n                7083842474651714165,\n                2491363132897582954,\n                6822759191074732531,\n                1975703285786766592,\n                4664247346348091399,\n                6200670517431733578,\n                7625423344374743344,\n                12752241152270105853,\n                1792181265050143868,\n                9684341866777183803,\n                2519544645709853691,\n                10916780105681637442,\n                10344955420168669639,\n                9942180203006299987,\n                12084291513489188332,\n                3948266540776100311,\n                9154092837114088215,\n                5346858599403446633,\n                16526650534031004365,\n                1000379885777408481,\n                9962324609830950859,\n                17358968356608808633,\n                16077501442923026330,\n                16373391819852480638,\n                7285769258546345039,\n                9258849101785002591,\n                5742154400061770227,\n                6000603993323989058,\n                14647716329474708008,\n                9759234782041772304,\n                10140774772642173806,\n                12417308406161902675,\n                787743125041003665,\n                16505409716496421861,\n                13496346584666506754,\n                6161155548184037990,\n                6052945594671650378,\n                3943721555742518361,\n                1724411800658421894,\n                5539278770081464366,\n                15345354647968324153,\n                11115348357173195281,\n                14941897866359059705,\n                13232123053046857932,\n                10293530598380524712,\n                6785485284866633954,\n                2274573151581626897,\n                7914418682634630883,\n                9050484888129037258,\n                5596144246310386066,\n                16947403501604289983,\n                4629498933991963153,\n                12809658963208366731,\n                15794201530500048648,\n                13688081233074642819,\n                13734318539544366298,\n                17338613223770563244,\n                8949201706050038962,\n                7457293230715991355,\n                3392962986871707645,\n                2665311774547334828,\n                14769130061609548831,\n                14798608201523559143,\n                4248204495368930031,\n                2118780687916441347,\n                7587741700881576871,\n                14435287502544940055,\n                5661100765027979237,\n                16339955561566207846,\n                8140260981243250155,\n                8056431096984667176,\n                7147782631749791333,\n                2489306669890900889,\n                4475802923302768991,\n                16154685423804744738,\n                7934898789690822040,\n                6879516481280076285,\n                9089400825108258886,\n                17930990199515864021,\n                14768387486978797965,\n                18129863777024625000,\n                10818394317143489199,\n                15491447326600259816,\n                16981166881989734434,\n                16302476576745273904,\n                6518490351683715742,\n                8412288793616962739,\n                6351653340417195445,\n                13150568765377194334,\n                13805040795477806115,\n                5934147261272121494,\n                1994383077577350943,\n                16635675973993021427,\n                12605935823956703560,\n                17476993101523741670,\n                6478809187431271696,\n                2732525537481875395,\n                9879991725842211511,\n                6807932982002010721,\n                7352337837011779903,\n                2817471936912129199,\n                13262278618157850043,\n                10769791684153169602,\n                16373519399949306992,\n                2899723188139359765,\n                10536102085057036916,\n                6542494148698745845,\n                8208357062363683807,\n                7135654628053388596,\n                9239547683832094589,\n                5857943902095897523,\n                2988676895399293972,\n                10864744325417622458,\n                5315919323785706256,\n                17726255358609389283,\n                548416274855739353,\n                14341121194849694922,\n                7541833390688838500,\n                12990342594130240843,\n                18010249397570629115,\n                12270534655132211820,\n                11089591099925577121,\n                8904086294203345138,\n                360354335597452271,\n                15390384602644239058,\n                9646385913080766351,\n                7807991425432087787,\n                9178671661816533936,\n                14127492076118037414,\n                2392162322212242991,\n                14036941142798507711,\n                6502240351436565564,\n                7893899872624843337,\n                14288594129943657110,\n                14040928483141897687,\n                1592502089611546139,\n                16817286687244219231,\n                1288452307437286948,\n                14067519453346137912,\n                10075887672168075195,\n                16769912598561257346,\n                15456884559283078393,\n                8711311950138380878,\n                17440519414852901585,\n                4031578079792007763,\n                17459032506776526507,\n                6047439267180308295,\n                13036838382774047407,\n                5995888809898483332,\n                5666540365944124863,\n                9669239227306108902,\n                13524757761279567441,\n                9100467949589737947,\n                10630607884662362720,\n                7656432890734400844,\n                14587775638685276238,\n                13512825387557617884,\n                7244019832094584382,\n                14996712660826603119,\n                15920594541485478011,\n                18302888448007121275,\n                2860853013354641768,\n                16346890198034118818,\n                3995008638584894259,\n                15431133287252532218,\n                12007621448583591973,\n                12654616832949992670,\n                17218932927375784084,\n                5108339176271521031,\n                1475805094516082093,\n                12897404584908775312,\n                12902004423289195678,\n                632420305961082974,\n                3939829721363017782,\n                8159027656096857323,\n                5289724432039220494,\n                8105874082275331898,\n                7058967362148243623,\n                7084554565361601863,\n                10713529750643129586,\n                16053444010682289763,\n                16789097964014031314,\n                2561050582281530128,\n                5001739943623024256,\n                5563376828383980501,\n                7029523460044084584,\n                3734303822831180195,\n                17604507458906309331,\n                15410396100097854167,\n                12072617536058855445,\n                9343913967197010858,\n                17464576053666161449,\n                14222234943442423138,\n                3029903299346511292,\n                2439504202412922232,\n                17909602716813870812,\n                7163148054936239235,\n                1203376532559407808,\n                13308342071396905822,\n                9659238717159340331,\n                9298790467854663751,\n                13879727520175998029,\n                3540668590936352635,\n                9319928603109010852,\n                7135941863720734900,\n                4755935102616669000,\n                16186952942091333092,\n                868417045309212144,\n                4614771873250033976,\n                12695043568719791838,\n                11555375308916964213,\n                7608623603624110550,\n                2657517781272739364,\n                16275540663546067547,\n                13686833504204824152,\n                12138906647042213779,\n                10867610696309111099,\n                14724502273153125344,\n                16861685577613202946,\n                8743302596210517799,\n                14587474243501868159,\n                2572487334058012273,\n                603248717087965084,\n                5059320325228404990,\n                16238530369175832077,\n                4519037757700474392,\n                12378671739975925965,\n                12407484273586632994,\n                15313162588758450641,\n                7715370120812724109,\n                16244624049595468844,\n                16509798106801620258,\n                8670816985658531869,\n                17161563202276681629,\n                6760859082822229695,\n                6807294103798050445,\n                12102809409961330094,\n                15733867019982720404,\n                4500829814752383546,\n                276727174991039753,\n                7166981968731078898,\n                6839153022681710561,\n                9052935609363333850,\n                180023864532346968,\n                15036321241551927313,\n                8004861917338601611,\n                10433381600254688194,\n                58897018650060884,\n                12176800300096084156,\n                1677464574753824642,\n                9033479160050603494,\n                15102533506708978663,\n                14084179961157892415,\n                15862200228768947299,\n                13406816340465864482,\n                4480435244557703388,\n                9328135622344307924,\n                8569086569674090389,\n                117119659942779713,\n                53818961148559993,\n                17499848839935720391,\n                9136357190515762310,\n                9027105858395986940,\n                17989890318601901443,\n                18097540417946691193,\n                14525610539500917353,\n                2154941454922905428,\n                5904339583092243168,\n                13443891604996267,\n                17266860992297653711,\n                8744756382159865790,\n                18024305737878696983,\n                2546630949169889692,\n                14096991573794098342,\n                6037463192406505117,\n                16222309559186427347,\n                17465566247484999322,\n                12659653001889101916,\n                17145147704704336749,\n                270028953681259627,\n                10687721792402042274,\n                7909714047373529261,\n                1516466812193933964,\n                18277293846935305743,\n                16998707418464340047,\n                10456180009273456482,\n                10894339053818039134,\n                7931553102963941505,\n                5469019641482786787,\n                15559448848625861221,\n                13379845259726008039,\n                15222258432394099771,\n                9220502339943331578,\n                11041492625928826773,\n                13723142119880743788,\n                13406366780219048563,\n                16242021890137344914,\n                3242681820103600264,\n                7433022400269598514,\n                13800053899816348927,\n                10971582708599334044,\n                16780079125754812721,\n                7499355964098143157,\n                6683080229097120149,\n                4643838630497962703,\n                2452976410357582431,\n                13628797043976089046,\n                12208582264105438774,\n                10972823060808439197,\n                5834946779865455467,\n                7061987228048265540,\n                1207502404391064867,\n                4999557813060557947,\n                6110696626660879360,\n                16155026384042239167,\n                14271653985173561903,\n                15409968780617538981,\n                12583134000526518362,\n                14425350186270986364,\n                4240634153006170791,\n                15186331103475807077,\n                3441220359690995595,\n                7730377008237943835,\n                4028688972105728738,\n                2120709666343944557,\n                15275844229510750384,\n                18298631304947594122,\n                13289696428719138891,\n                12902251465979698800,\n                17784642778353395327,\n                8932078122697958597,\n                2343784433129198521,\n                2625325561581989570,\n                6226848264428179755,\n                9341106183231718139,\n                9098935814035218596,\n                7352506358300392706,\n                2344104557164367420,\n                12260380423821950355,\n                5334772679936050516,\n                4625031027053042238,\n                16182107767362335138,\n                16366374610370031102,\n                4836384899789893883,\n                7955273434480297668,\n                6911864392544134089,\n                16417538807637628387,\n                7095497393911852501,\n                13038578327075160812,\n                3237033976078933963,\n                12153345193878928470,\n                8529208509214849086,\n                3557796804144548743,\n                4802066316596054332,\n                15433632645238893171,\n                7546572980385595878,\n                11926731397057053166,\n                12459060237931625488,\n                14141685648156683211,\n                7288151748928762022,\n                4432041251568429780,\n                15563480646640553472,\n                16053290806405898796,\n                15137506699232809093,\n                8005443786172873610,\n                2583037632942587270,\n                17849394642972838924,\n                14162302110936479805,\n                2509458716192360405,\n                5356417310559321341,\n                13186254752172487693,\n                11386136498514963040,\n                17709391199907333437,\n                10287520916427793726,\n                16609632513291109233,\n                2167580474521363269,\n                12093450528168333086,\n                7863381164011802024,\n                3333719694645745323,\n                11940256871115614834,\n                15608703623597862105,\n                12353758136546081384,\n                6684006108125243153,\n                12729735272407622593,\n                5729918571797570178,\n                836259910264806143,\n                14839853436536328663,\n                3503216322132876395,\n                12081845346843956683,\n                11452606043277089033,\n                3278971557269095943,\n                14460255683089324678,\n                26212371609850095,\n                5791996297577934908,\n                11791872952518605557,\n                4303537542168010174,\n                16090584062354399534,\n                4908264648595320164,\n                7751540775663330461,\n                6257171389619325857,\n                10426410760581414335,\n                17538696865214967217,\n                7467505509612490667,\n                9596349531846363101,\n                10432645685361251072,\n                4554200269336177591,\n                14164090620513306305,\n                12703411361203184202,\n                10381679821480302262,\n                17407993808772229676,\n                13447212664492178323,\n                6368763612994722491,\n                6985317877139191413,\n                3304210073159911148,\n                11815333377693368073,\n                5807352926666783905,\n                15497939312564010706,\n                6997355376158126843,\n                8894976899204659904,\n                6062763749482474444,\n                12366982438149692528,\n                5811941270446802002,\n                1365585056061256612,\n                13475218612693439913,\n                3101226957898170052,\n                7483152820787337316,\n                11966132556998778392,\n                15847594708317668544,\n                8536570052230898519,\n                17755327099574675677,\n                4573875060013426627,\n                10571694422987443237,\n                13886938922370949941,\n                13243541345182765869,\n                2407150453734919381,\n                3504658143291885737,\n                7031357511394950972,\n                10000971933511773390,\n                13912116329153795479,\n                15031415497603451939,\n                4599320279014918550,\n                11777085389799050565,\n                10789465428143426974,\n                13380525436974205384,\n                481819144611018854,\n                5450316677878014202,\n                15246244400696673845,\n                2539248742679727539,\n                13402910818618694139,\n                17131842085718107785,\n                1254150638176089903,\n                4995981122218138624,\n                7087931693181888823,\n                15049301175005363928,\n                108059457248600792,\n                6415264753538529207,\n                8176266644263202488,\n                9913473944910878449,\n                1695436935634773000,\n                17297145186449223950,\n                12551494433741244515,\n                9893572477404506151,\n                5018441835213902689,\n                2942536196417517781,\n                16905131659211501459,\n                6905710711318770295,\n                7616899203962297179,\n                14893845862286767619,\n                9802013654239316989,\n                17646160800663090718,\n                688334719842856096,\n                2007794688466179654,\n                654395123253282904,\n                8101085388166846547,\n                129085352126721490,\n                5656513500529597182,\n                5068380157352571940,\n                16823659606299635586,\n                18201953606184755353,\n                14292322613095109457,\n                16683857805140576716,\n                2453074754987128823,\n            ],\n        );\n    }\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_fail_1() {\n    limbs_mod(&[1, 2, 3], &[4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_fail_2() {\n    limbs_mod(&[1], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_fail_3() {\n    limbs_mod(&[1, 2, 3], &[4, 0]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_to_out_fail_1() {\n    limbs_mod_to_out(&mut [10; 4], &[1, 2, 3], &[4]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_to_out_fail_2() {\n    limbs_mod_to_out(&mut [10; 4], &[1], &[4, 5]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_mod_to_out_fail_3() {\n    limbs_mod_to_out(&mut [10; 4], &[1, 2, 3], &[4, 0]);\n}\n\n#[test]\nfn test_mod() {\n    let test = |s, t, remainder| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.mod_assign(v.clone());\n        assert!(x.is_valid());\n        assert!(x.mod_is_reduced(&v));\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x.mod_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone().mod_op(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone().mod_op(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).mod_op(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).mod_op(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let mut x = u.clone();\n        x %= v.clone();\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x %= &v;\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone() % v.clone();\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone() % &v;\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = &u % v.clone();\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = &u % &v;\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let num_u = BigUint::from_str(s).unwrap();\n        let num_v = BigUint::from_str(t).unwrap();\n\n        let r = num_u.mod_floor(&num_v);\n        assert_eq!(r.to_string(), remainder);\n\n        let r = num_u % num_v;\n        assert_eq!(r.to_string(), remainder);\n\n        let rug_u = rug::Integer::from_str(s).unwrap();\n        let rug_v = rug::Integer::from_str(t).unwrap();\n\n        let r = (rug_u.clone()).rem_floor(rug_v.clone());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = rug_u % rug_v;\n        assert_eq!(r.to_string(), remainder);\n\n        assert_eq!(u.div_mod(v).1.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"123\");\n    test(\"456\", \"123\", \"87\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"3\", \"1\");\n    test(\"1000000000000\", \"123\", \"100\");\n    test(\"1000000000000\", \"4294967295\", \"3567587560\");\n    test(\"1000000000000000000000000\", \"1\", \"0\");\n    test(\"1000000000000000000000000\", \"3\", \"1\");\n    test(\"1000000000000000000000000\", \"123\", \"37\");\n    test(\"1000000000000000000000000\", \"4294967295\", \"3167723695\");\n    test(\"1000000000000000000000000\", \"1234567890987\", \"530068894399\");\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"1234567890987654321234567890987654321\",\n        \"779655053998040854338961591319296066\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0\",\n        \"316049380092839506236049380092839506176\",\n        \"37816691783627670491375998320948925696\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"1520301762334\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"3768477692975601\",\n    );\n    test(\"3356605361737854\", \"3081095617839357\", \"275509743898497\");\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"145347900158016763719\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\"123\", \"1000000000000000000000000\", \"123\");\n}\n\n#[test]\n#[should_panic]\nfn mod_assign_fail() {\n    Natural::from(10u32).mod_assign(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_assign_ref_fail() {\n    Natural::from(10u32).mod_assign(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_fail() {\n    Natural::from(10u32).mod_op(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_val_ref_fail() {\n    Natural::from(10u32).mod_op(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_ref_val_fail() {\n    (&Natural::from(10u32)).mod_op(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_ref_ref_fail() {\n    (&Natural::from(10u32)).mod_op(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn rem_assign_fail() {\n    let mut n = Natural::from(10u32);\n    n %= Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_rem_assign_ref_fail() {\n    let mut n = Natural::from(10u32);\n    n %= &Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_fail() {\n    Natural::from(10u32) % Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_val_ref_fail() {\n    Natural::from(10u32) % &Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_ref_val_fail() {\n    &Natural::from(10u32) % Natural::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_ref_ref_fail() {\n    &Natural::from(10u32) % &Natural::ZERO;\n}\n\n#[test]\nfn test_neg_mod() {\n    let test = |s, t, remainder| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.neg_mod_assign(v.clone());\n        assert!(x.is_valid());\n        assert!(x.mod_is_reduced(&v));\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x.neg_mod_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone().neg_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone().neg_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).neg_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).neg_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = rug_neg_mod(\n            rug::Integer::from_str(s).unwrap(),\n            rug::Integer::from_str(t).unwrap(),\n        );\n        assert_eq!(r.to_string(), remainder);\n\n        assert_eq!(u.ceiling_div_neg_mod(v).1.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"333\");\n    test(\"456\", \"123\", \"36\");\n    test(\"4294967295\", \"1\", \"0\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"3\", \"2\");\n    test(\"1000000000000\", \"123\", \"23\");\n    test(\"1000000000000\", \"4294967295\", \"727379735\");\n    test(\"1000000000000000000000000\", \"1\", \"0\");\n    test(\"1000000000000000000000000\", \"3\", \"2\");\n    test(\"1000000000000000000000000\", \"123\", \"86\");\n    test(\"1000000000000000000000000\", \"4294967295\", \"1127243600\");\n    test(\"1000000000000000000000000\", \"1234567890987\", \"704498996588\");\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"1234567890987654321234567890987654321\",\n        \"454912836989613466895606299668358255\",\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n         00\",\n        \"316049380092839506236049380092839506176\",\n        \"278232688309211835744673381771890580480\",\n    );\n    test(\n        \"253640751230376270397812803167\",\n        \"2669936877441\",\n        \"1149635115107\",\n    );\n    test(\n        \"3768477692975601\",\n        \"11447376614057827956\",\n        \"11443608136364852355\",\n    );\n    test(\"3356605361737854\", \"3081095617839357\", \"2805585873940860\");\n    test(\n        \"1098730198198174614195\",\n        \"953382298040157850476\",\n        \"808034397882141086757\",\n    );\n    test(\n        \"69738658860594537152875081748\",\n        \"69738658860594537152875081748\",\n        \"0\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000000000000000\",\n        \"0\",\n    );\n    test(\"0\", \"1000000000000000000000000\", \"0\");\n    test(\n        \"123\",\n        \"1000000000000000000000000\",\n        \"999999999999999999999877\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn neg_mod_assign_fail() {\n    Natural::from(10u32).neg_mod_assign(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn neg_mod_assign_ref_fail() {\n    Natural::from(10u32).neg_mod_assign(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn neg_mod_fail() {\n    Natural::from(10u32).neg_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn neg_mod_val_ref_fail() {\n    Natural::from(10u32).neg_mod(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn neg_mod_ref_val_fail() {\n    (&Natural::from(10u32)).neg_mod(Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn neg_mod_ref_ref_fail() {\n    (&Natural::from(10u32)).neg_mod(&Natural::ZERO);\n}\n\n#[test]\nfn limbs_mod_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_22().test_properties_with_config(&config, |(ns, d)| {\n        let r = limbs_mod_limb::<DoubleLimb, Limb>(&ns, d);\n        assert_eq!(Natural::from_limbs_asc(&ns) % Natural::from(d), r);\n        assert_eq!(\n            limbs_mod_limb_any_leading_zeros_1::<DoubleLimb, Limb>(&ns, d),\n            r\n        );\n        assert_eq!(\n            limbs_mod_limb_any_leading_zeros_2::<DoubleLimb, Limb>(&ns, d),\n            r\n        );\n        assert_eq!(limbs_mod_limb_alt_1::<DoubleLimb, Limb>(&ns, d), r);\n        assert_eq!(limbs_mod_limb_alt_2::<DoubleLimb, Limb>(&ns, d), r);\n        assert_eq!(limbs_mod_limb_alt_3(&ns, d), r);\n    });\n}\n\n#[test]\nfn limbs_mod_limb_small_normalized_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_26().test_properties_with_config(&config, |(ns, d)| {\n        let r = limbs_mod_limb_small_normalized::<DoubleLimb, Limb>(&ns, d);\n        assert_eq!(r, Natural::from_limbs_asc(&ns) % Natural::from(d));\n        if ns.len() == 1 {\n            assert_eq!(r, ns[0] % d);\n        } else {\n            assert_eq!(r, limbs_mod_limb::<DoubleLimb, Limb>(&ns, d));\n        }\n    });\n}\n\n#[test]\nfn limbs_mod_limb_small_unnormalized_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_27().test_properties_with_config(&config, |(ns, d)| {\n        let r = limbs_mod_limb_small_unnormalized::<DoubleLimb, Limb>(&ns, d);\n        assert_eq!(\n            r,\n            limbs_mod_limb_at_least_1_leading_zero::<DoubleLimb, Limb>(&ns, d)\n        );\n        assert_eq!(r, Natural::from_limbs_asc(&ns) % Natural::from(d));\n        if ns.len() == 1 {\n            assert_eq!(r, ns[0] % d);\n        } else {\n            assert_eq!(r, limbs_mod_limb::<DoubleLimb, Limb>(&ns, d));\n        }\n    });\n}\n\n#[test]\nfn limbs_mod_limb_at_least_2_leading_zeros_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_28().test_properties_with_config(&config, |(ns, d)| {\n        let r = limbs_mod_limb_at_least_2_leading_zeros::<DoubleLimb, Limb>(&ns, d);\n        assert_eq!(r, Natural::from_limbs_asc(&ns) % Natural::from(d));\n        if ns.len() == 1 {\n            assert_eq!(r, ns[0] % d);\n        } else {\n            assert_eq!(r, limbs_mod_limb::<DoubleLimb, Limb>(&ns, d));\n        }\n    });\n}\n\n#[test]\nfn limbs_mod_three_limb_by_two_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_sextuple_gen_var_2().test_properties_with_config(\n        &config,\n        |(n_2, n_1, n_0, d_1, d_0, inverse)| {\n            let r = limbs_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, inverse);\n            verify_limbs_mod_three_limb_by_two_limb(n_2, n_1, n_0, d_1, d_0, r);\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_by_two_limb_normalized_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_18().test_properties_with_config(&config, |(ns, ds)| {\n        let (r_0, r_1) = limbs_mod_by_two_limb_normalized(&ns, &ds);\n        verify_limbs_mod_by_two_limb_normalized(&ns, &ds, r_0, r_1);\n    });\n}\n\n#[test]\nfn limbs_mod_schoolbook_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_17().test_properties_with_config(\n        &config,\n        |(mut ns, ds, inverse)| {\n            let ns_old = ns.clone();\n            limbs_mod_schoolbook(&mut ns, &ds, inverse);\n            verify_limbs_mod_1(&ns_old, &ds, &ns);\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 128);\n    config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n    large_type_gen_var_12().test_properties_with_config(\n        &config,\n        |(mut qs, mut ns, ds, inverse)| {\n            let ns_old = ns.clone();\n            limbs_mod_divide_and_conquer(&mut qs, &mut ns, &ds, inverse);\n            verify_limbs_mod_1(&ns_old, &ds, &ns);\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_barrett_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 128 << Limb::LOG_WIDTH);\n    unsigned_vec_quadruple_gen_var_5().test_properties_with_config(\n        &config,\n        |(mut qs, mut rs, ns, ds)| {\n            let rs_old = rs.clone();\n            let mut scratch = vec![0; limbs_div_mod_barrett_scratch_len(ns.len(), ds.len())];\n            limbs_mod_barrett(&mut qs, &mut rs, &ns, &ds, &mut scratch);\n            verify_limbs_mod_2(&rs_old, &ns, &ds, &rs);\n        },\n    );\n}\n\nfn verify_limbs_mod_3(ns: &[Limb], ds: &[Limb], rs: &[Limb]) {\n    let n = Natural::from_limbs_asc(ns);\n    let d = Natural::from_limbs_asc(ds);\n    let expected_r = n % &d;\n    let r = Natural::from_limbs_asc(rs);\n    assert_eq!(r, expected_r);\n    assert!(r < d);\n    assert_eq!(rs.len(), ds.len());\n}\n\n#[test]\nfn limbs_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 128 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_11().test_properties_with_config(&config, |(ns, ds)| {\n        verify_limbs_mod_3(&ns, &ds, &limbs_mod(&ns, &ds));\n    });\n}\n\n#[test]\nfn limbs_mod_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 128 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_57().test_properties_with_config(&config, |(mut rs, ns, ds)| {\n        let rs_old = rs.clone();\n        limbs_mod_to_out(&mut rs, &ns, &ds);\n        verify_limbs_mod_2(&rs_old, &ns, &ds, &rs);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn mod_properties_helper(x: Natural, y: Natural) {\n    let mut mut_x = x.clone();\n    mut_x.mod_assign(&y);\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n    assert!(remainder.mod_is_reduced(&y));\n\n    let mut mut_x = x.clone();\n    mut_x.mod_assign(y.clone());\n    let remainder_alt = mut_x;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).mod_op(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).mod_op(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().mod_op(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().mod_op(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let mut remainder_alt = x.clone();\n    remainder_alt %= &y;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let mut remainder_alt = x.clone();\n    remainder_alt %= y.clone();\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = &x % &y;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = &x % y.clone();\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone() % &y;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone() % y.clone();\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).div_mod(&y).1;\n    assert_eq!(remainder_alt, remainder);\n\n    let num_remainder = BigUint::from(&x).mod_floor(&BigUint::from(&y));\n    assert_eq!(Natural::from(&num_remainder), remainder);\n\n    let num_remainder = BigUint::from(&x) % &BigUint::from(&y);\n    assert_eq!(Natural::from(&num_remainder), remainder);\n\n    let rug_remainder = rug::Integer::from(&x).rem_floor(rug::Integer::from(&y));\n    assert_eq!(Natural::exact_from(&rug_remainder), remainder);\n\n    let rug_remainder = rug::Integer::from(&x) % rug::Integer::from(&y);\n    assert_eq!(Natural::exact_from(&rug_remainder), remainder);\n\n    assert!(remainder < y);\n    assert_eq!(&remainder % y, remainder);\n}\n\n#[test]\nfn mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 256 << Limb::LOG_WIDTH);\n    natural_pair_gen_var_5().test_properties_with_config(&config, |(x, y)| {\n        mod_properties_helper(x, y);\n    });\n\n    natural_pair_gen_var_6().test_properties_with_config(&config, |(x, y)| {\n        mod_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(n % Natural::ONE, 0);\n    });\n\n    natural_gen_var_2().test_properties(|ref n| {\n        assert_eq!(n % n, 0);\n        assert_eq!(Natural::ZERO % n, 0);\n        if *n > 1 {\n            assert_eq!(Natural::ONE % n, 1);\n        }\n    });\n\n    natural_triple_gen_var_4().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x + y) % z, (x % z + y % z) % z);\n        assert_eq!(x * y % z, (x % z) * (y % z) % z);\n    });\n\n    unsigned_pair_gen_var_12::<Limb, Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x) % Natural::from(y), x % y);\n    });\n}\n\n#[allow(clippy::needless_pass_by_value)]\nfn neg_mod_properties_helper(x: Natural, y: Natural) {\n    let mut mut_x = x.clone();\n    mut_x.neg_mod_assign(&y);\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n    assert!(remainder.mod_is_reduced(&y));\n\n    let mut mut_x = x.clone();\n    mut_x.neg_mod_assign(y.clone());\n    let remainder_alt = mut_x;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).neg_mod(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).neg_mod(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().neg_mod(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().neg_mod(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).neg_mod(&y);\n    assert_eq!(remainder_alt, remainder);\n\n    let rug_remainder = rug_neg_mod(rug::Integer::from(&x), rug::Integer::from(&y));\n    assert_eq!(Natural::exact_from(&rug_remainder), remainder);\n\n    assert!(remainder < y);\n}\n\n#[test]\nfn neg_mod_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 256 << Limb::LOG_WIDTH);\n    natural_pair_gen_var_5().test_properties_with_config(&config, |(x, y)| {\n        neg_mod_properties_helper(x, y);\n    });\n\n    natural_pair_gen_var_6().test_properties_with_config(&config, |(x, y)| {\n        neg_mod_properties_helper(x, y);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(n.neg_mod(Natural::ONE), 0);\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!((&n).neg_mod(&n), 0);\n        assert_eq!(Natural::ZERO.neg_mod(&n), 0);\n        assert_eq!(Natural::ONE.neg_mod(&n), n - Natural::ONE);\n    });\n\n    natural_triple_gen_var_4().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x + y).neg_mod(z), (x % z + y % z).neg_mod(z));\n        assert_eq!((x * y).neg_mod(z), ((x % z) * (y % z)).neg_mod(z));\n    });\n\n    unsigned_pair_gen_var_12::<Limb, Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).neg_mod(Natural::from(y)), x.neg_mod(y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModIsReduced, ModMul, ModNeg, ModPow, ModPowAssign, Parity,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_15;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_pow::{\n    limbs_mod_pow, limbs_mod_pow_odd, limbs_mod_pow_odd_scratch_len,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_pair_gen_var_5, natural_pair_gen_var_8, natural_quadruple_gen_var_2,\n    natural_quadruple_gen_var_3, natural_triple_gen_var_5, unsigned_vec_quadruple_gen_var_6,\n    unsigned_vec_quadruple_gen_var_7,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_pow::simple_binary_mod_pow;\nuse num::BigUint;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nfn verify_limbs_mod_pow(out: &[Limb], xs: &[Limb], es: &[Limb], ms: &[Limb], out_out: &[Limb]) {\n    let exp = Natural::from_limbs_asc(es);\n    let m = Natural::from_limbs_asc(ms);\n    let x = Natural::from_limbs_asc(xs) % &m;\n    let expected = (&x).mod_pow(&exp, &m);\n    assert!(expected.mod_is_reduced(&m));\n    assert_eq!(simple_binary_mod_pow(&x, &exp, &m), expected);\n    let n = ms.len();\n    assert_eq!(Natural::from_limbs_asc(&out_out[..n]), expected);\n    assert_eq!(&out_out[n..], &out[n..]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_pow_odd() {\n    let test = |out: &[Limb], xs: &[Limb], es: &[Limb], ms: &[Limb], out_out: &[Limb]| {\n        let out_old = out;\n        let mut out = out_old.to_vec();\n        let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(ms.len())];\n        limbs_mod_pow_odd(&mut out, xs, es, ms, &mut scratch);\n        assert_eq!(out, out_out);\n        verify_limbs_mod_pow(out_old, xs, es, ms, &out);\n    };\n    // - ms_len < REDC_1_TO_REDC_N_THRESHOLD\n    // - ms_len == 1 in to_redc\n    // - end >= len in get_bits\n    // - width >= windowsize\n    // - bit_index != 0\n    // - !limbs_get_bit(es, bit_index - 1)\n    // - bit_index >= windowsize\n    // - limbs_cmp_same_length(out, ms) == Less\n    test(&[10; 3], &[3], &[20], &[105], &[51, 10, 10]);\n    // - ms_len != 1 in to_redc\n    // - end < len in get_bits\n    // - bit_index < windowsize\n    test(\n        &[10; 3],\n        &[123, 456],\n        &[789, 987],\n        &[135, 797],\n        &[2939877551, 399, 10],\n    );\n    // - limbs_cmp_same_length(out, ms) != Less\n    test(&[10; 3], &[3], &[2], &[9], &[0, 10, 10]);\n    // - ms_len >= REDC_1_TO_REDC_N_THRESHOLD\n    // - REDC_1_TO_REDC_N_THRESHOLD <= ms_len < MUL_TOOM22_THRESHOLD in select_fns\n    test(\n        &[10; 102],\n        &[\n            15231838, 2040644427, 3019562008, 1849879669, 3035273653, 1126993058, 47231998,\n            1272966966, 808826123, 2613679871, 3880209905, 533657556, 462055026, 1995462791,\n            2669440556, 964537932, 1111256412, 3618168224, 2814460867, 3500086570, 4007554324,\n            423675806, 4263852014, 939174181, 3372315870, 2404528019, 2462982568,\n        ],\n        &[4284714037, 4294504709, 3097020148, 1061316867],\n        &[\n            2895738059, 2222742945, 2200913266, 2474343961, 674884792, 3868751732, 3089689534,\n            2430632097, 2488368713, 3062061319, 4067596626, 511264582, 1407628892, 2272907418,\n            959402877, 3744259866, 3311299232, 2145791174, 43238938, 3833638835, 4110565129,\n            4008973369, 104651202, 677542079, 758926920, 1101277253, 3001021931, 998015387,\n            1742463066, 558329360, 2693367111, 3480565457, 3612553333, 1301555794, 519337581,\n            3300908468, 3530322699, 2448060428, 4064907740, 2664586778, 1523503672, 3213102458,\n            1257460118, 2076514388, 4071643827, 3592057262, 1402398574, 3017877057, 2055576849,\n            732723305, 1414294091, 4223824602, 3201010967, 1895660785, 1135353915, 2148174613,\n            4048519927, 121851082, 2198350375, 1783615559, 372909943, 614317668, 3372914919,\n            2755021756, 4017557367, 2133054830, 1948457571, 1938410224, 3325075631, 3634267258,\n            51102224, 2458277488, 3478591381, 1824685083, 3648635504, 481889501, 1100046228,\n            4153007238, 3393775448, 288899148, 1691342799, 541535815, 3936683203, 3579439411,\n            1281616696, 2097613162, 1182389689, 2985495353, 2822637621, 3933095442, 4138905254,\n            4281995886, 1468542161, 503073229, 1438766160, 1146230629, 3365322628, 594370818,\n            3970846533, 2993627984,\n        ],\n        &[\n            3220228332, 1289044619, 4090486882, 2935175502, 1036421691, 322080634, 2520677041,\n            782484792, 3367131407, 251234797, 3793043809, 2859808531, 1341835713, 1429457528,\n            2859236711, 988242793, 3516913319, 3085390135, 1767135385, 3505108006, 941241196,\n            1517169544, 581305334, 1456461198, 1628771306, 864062263, 818489872, 3761869500,\n            808518712, 1576582852, 3807006337, 2323525681, 106379360, 3251953336, 2046814458,\n            2437108016, 1297677798, 129047745, 3490510139, 1806687715, 3213874668, 139669025,\n            919576894, 2643933393, 3980690050, 2652575541, 1927756447, 2123306615, 440563656,\n            2040387516, 4243697106, 428296898, 915674737, 498045820, 3130354008, 1193458405,\n            3406781642, 3252972448, 201621523, 1862360144, 2039264045, 2329252476, 2686526115,\n            1116276280, 287363272, 4049536496, 3211163886, 2780240991, 3185623463, 3699825246,\n            260938527, 3712407400, 50158619, 4082561437, 3981632240, 1645303993, 1388449088,\n            1723061239, 1436532661, 1932705168, 3620788285, 4096149072, 2319194551, 2203579540,\n            1766526917, 783820005, 3067485228, 3442142247, 2486918849, 2955962844, 1280634082,\n            3907853014, 1337542963, 2795904203, 1989841069, 973220557, 1353182775, 2705903522,\n            3829991598, 71670781, 10, 10,\n        ],\n    );\n    // - ms_len >= MUL_TOOM22_THRESHOLD in select_fns\n    test(\n        &[10; 132],\n        &[\n            2688238368, 1370389694, 2050030377, 2515208601, 2857390881, 4197651524, 1239390266,\n            1406670778, 2579838638, 295836633, 3196840122, 3842197805, 3093150937, 3921979512,\n            3334864271, 4051787844, 1715354699, 784724006, 2641707538, 91367600, 564566325,\n            4232021563, 3303269258, 1546428796, 4081815008, 2772422919, 3080061263, 3655857709,\n            3221167157, 3188437627, 3509421900, 2117096697, 399342008, 595809629, 3677310060,\n            4115179023, 755358759, 2356175810, 1130123131, 1730880525, 295144730, 3749456557,\n        ],\n        &[\n            870678421, 2796837091, 3293178107, 1768925464, 1619766842, 2289477468, 1997089941,\n            1122217361, 1351469882, 2292919231, 1820507033, 811208831, 2962958283, 49325855,\n            904973661, 2650666234, 38738475, 1350510862, 3541603511, 1957000434, 626956257,\n            3679451040, 455567141, 2358641221, 1772224239, 663265109,\n        ],\n        &[\n            3910996289, 2816958662, 2867701269, 2489588705, 4139766686, 68347912, 3545464089,\n            186840093, 4192695275, 3384626828, 1867478774, 3430502357, 2070259035, 1818903078,\n            185487092, 1945164940, 198992488, 1340594809, 2884280378, 2659028966, 2731883802,\n            3386600963, 4226259957, 1351345124, 1596030101, 1412857735, 3371378007, 1255307044,\n            3627261742, 2728165048, 3740045608, 3893125603, 2353417837, 3173894525, 1712654005,\n            3756974619, 1870314396, 3071976119, 399143608, 2618882156, 2758650080, 1057786871,\n            2222605504, 3375739680, 696795589, 3386974205, 359484891, 309512373, 299872079,\n            2278512560, 532043407, 1466190502, 733728197, 3362102523, 2180739566, 3829805290,\n            397079472, 3354014956, 1906213944, 3156244881, 3388567106, 369361961, 264909755,\n            3405203581, 2313150087, 3156935606, 1429648656, 3898358330, 1257746430, 1594676943,\n            170660532, 2745162133, 2864414636, 2142084396, 2569588942, 3853728956, 2233612974,\n            152936585, 1575814183, 519325569, 2275674013, 1085948185, 2072284470, 3541789119,\n            4034514248, 1610140625, 3875476257, 1035874049, 3543420948, 1561693735, 966255080,\n            936126918, 2523487827, 2895401694, 1142029713, 862454352, 3620226631, 69690788,\n            3246184999, 485393839, 3514148744, 2848543979, 4007221509, 175089578, 1517243713,\n            1261753161, 3257856227, 116328541, 2289524271, 3087481870, 3446271192, 1201816042,\n            3910458324, 1249156998, 1230723249, 3753644481, 1117866811, 983288816, 2732615778,\n            743509902, 3225264110, 1171181988, 946574108, 1804691841, 3423828869, 959970900,\n            2507443216, 395931811, 1259542577, 2396067278,\n        ],\n        &[\n            1025852633, 79270077, 3301788792, 1386637604, 192346455, 1456906572, 69195851,\n            3129723136, 2519645061, 2541961631, 1794686607, 4106028394, 2701350434, 1348632655,\n            1867572334, 1249803339, 1440960895, 250478100, 2889620165, 961879123, 1291616398,\n            432573079, 867602404, 778350117, 4216286390, 4226436012, 2329382459, 2871255036,\n            2542841218, 1342004849, 1363690216, 22108213, 4073323393, 4067883423, 3008421638,\n            2102737805, 3312566592, 3539262183, 4034305910, 1392816118, 2717447275, 2310567812,\n            2894277860, 2383199219, 4103937620, 708098321, 2949556562, 4211952216, 3158171510,\n            4137870672, 3903904439, 4282380128, 855731951, 659589583, 2557106859, 576388003,\n            313616280, 331520688, 1277940989, 2708897033, 533029719, 487352515, 1949824586,\n            505072740, 4038013897, 2298668550, 1178798567, 1512613139, 4068988335, 2153062284,\n            4118780280, 597996449, 1606074452, 2335555420, 2054577350, 3045549370, 2701737868,\n            3618701098, 3636119053, 1005071332, 2303326104, 51535250, 3397405829, 3833534865,\n            2425051659, 2190540066, 4180788716, 2608530236, 1439369848, 2112154998, 2289724846,\n            2610833560, 808802563, 2996847623, 3253345649, 2123523552, 4214461433, 1492789177,\n            3467294232, 2909754357, 3226703424, 619540384, 1914094063, 1208434472, 3653698470,\n            753691175, 2501672947, 4171705775, 3829738927, 1900544129, 2509951656, 1518574100,\n            2809954004, 2621465363, 2267697036, 3991643575, 869359274, 502886394, 1517544442,\n            868396157, 2801850027, 190888001, 4244506669, 3019225248, 1504559895, 3027372440,\n            1152465509, 3085485694, 2286582782, 1487765908, 10, 10,\n        ],\n    );\n    // - xs longer than ms\n    test(&[10; 3], &[123, 456], &[20], &[105], &[36, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_odd_fail_1() {\n    let out = &mut [10];\n    let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(2)];\n    limbs_mod_pow_odd(out, &[123, 456], &[789, 987], &[135, 797], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_odd_fail_2() {\n    let out = &mut [10; 3];\n    let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(2)];\n    limbs_mod_pow_odd(out, &[], &[789, 987], &[135, 797], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_odd_fail_3() {\n    let out = &mut [10; 3];\n    let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(2)];\n    limbs_mod_pow_odd(out, &[123, 456], &[], &[135, 797], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_odd_fail_4() {\n    let out = &mut [10; 3];\n    let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(2)];\n    limbs_mod_pow_odd(out, &[123, 456], &[789, 987], &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_odd_fail_5() {\n    let out = &mut [10; 3];\n    let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(2)];\n    limbs_mod_pow_odd(out, &[123, 456], &[789, 987], &[136, 797], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_odd_fail_6() {\n    let out = &mut [10; 3];\n    let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(1)];\n    limbs_mod_pow_odd(out, &[3], &[0], &[9], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_odd_fail_7() {\n    let out = &mut [10; 3];\n    let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(1)];\n    limbs_mod_pow_odd(out, &[3], &[1], &[9], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_pow() {\n    let test = |out: &[Limb], xs: &[Limb], es: &[Limb], ms: &[Limb], out_out: &[Limb]| {\n        let out_old = out;\n        let mut out = out_old.to_vec();\n        limbs_mod_pow(&mut out, xs, es, ms);\n        assert_eq!(out, out_out);\n        verify_limbs_mod_pow(out_old, xs, es, ms, &out);\n    };\n    // - ms[0].odd()\n    // - ms_zero_len == 0\n    test(&[10; 3], &[3], &[20], &[105], &[51, 10, 10]);\n    test(&[10; 3], &[4], &[20], &[105], &[16, 10, 10]);\n    test(&[10; 3], &[4], &[1000000], &[3], &[1, 10, 10]);\n    // - ms[0].even()\n    // - ms_zero_len != 0\n    // - xs_len >= ms_zero_len\n    // - xs[0].odd()\n    // - do_pow_low\n    // - ms_nonzero_len >= ms_zero_len\n    // - ms_twos != 0\n    test(&[10; 3], &[3], &[1000000], &[4], &[1, 10, 10]);\n    // - xs[0].even()\n    // - es_len == 1\n    // - es[0].wrapping_mul(bits) >= t\n    // - !do_pow_low\n    test(&[10; 3], &[4], &[1000000], &[6], &[4, 10, 10]);\n    // - ms[ms_zero_len] == 0\n    // - xs_len < ms_zero_len\n    // - ms_nonzero_len < ms_zero_len\n    test(&[10; 3], &[4], &[1000000], &[0, 6], &[0, 4, 10]);\n    // - es_len > 1\n    test(&[10; 3], &[4], &[1, 1], &[0, 6], &[0, 4, 10]);\n    // - ms_twos == 0\n    test(&[10; 4], &[1], &[2], &[0, 1], &[1, 0, 10, 10]);\n    // - es[0].wrapping_mul(bits) < t\n    test(&[10; 4], &[2], &[2], &[0, 1], &[4, 0, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_fail_1() {\n    let out = &mut [10];\n    limbs_mod_pow(out, &[123, 456], &[789, 987], &[135, 797]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_fail_2() {\n    let out = &mut [10; 3];\n    limbs_mod_pow(out, &[], &[789, 987], &[135, 797]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_fail_3() {\n    let out = &mut [10; 3];\n    limbs_mod_pow(out, &[123, 456], &[], &[135, 797]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_fail_4() {\n    let out = &mut [10; 3];\n    limbs_mod_pow(out, &[123, 456], &[789, 987], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_fail_5() {\n    let out = &mut [10; 3];\n    limbs_mod_pow(out, &[3], &[0], &[9]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_pow_fail_6() {\n    let out = &mut [10; 3];\n    limbs_mod_pow(out, &[3], &[1], &[9]);\n}\n\n#[test]\nfn test_mod_pow() {\n    let test = |r, s, t, out| {\n        let u = Natural::from_str(r).unwrap();\n        let exp = Natural::from_str(s).unwrap();\n        let m = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_pow_assign(exp.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_pow_assign(&exp, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_pow_assign(exp.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_pow_assign(&exp, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_pow(exp.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_pow(exp.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_pow(&exp, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_pow(&exp, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_pow(exp.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_pow(exp.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_pow(&exp, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_pow(&exp, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", \"1\", \"0\");\n    test(\"0\", \"0\", \"10\", \"1\");\n    test(\"0\", \"1\", \"10\", \"0\");\n    test(\"2\", \"10\", \"10\", \"4\");\n    test(\"4\", \"13\", \"497\", \"445\");\n    test(\"10\", \"1000\", \"30\", \"10\");\n    test(\"2\", \"340\", \"341\", \"1\");\n    test(\"5\", \"216\", \"217\", \"1\");\n    test(\"2\", \"1000000\", \"1000000000\", \"747109376\");\n    test(\n        \"1234567890\",\n        \"1000000000\",\n        \"12345678987654321\",\n        \"10973935643347062\",\n    );\n}\n\n#[test]\nfn mod_pow_fail() {\n    assert_panic!(Natural::ZERO.mod_pow(Natural::from(3u32), Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_pow(Natural::from(3u32), Natural::ONE));\n\n    assert_panic!(Natural::ZERO.mod_pow(Natural::from(3u32), &Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_pow(Natural::from(3u32), &Natural::ONE));\n\n    assert_panic!(Natural::ZERO.mod_pow(&Natural::from(3u32), Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_pow(&Natural::from(3u32), Natural::ONE));\n\n    assert_panic!(Natural::ZERO.mod_pow(&Natural::from(3u32), &Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_pow(&Natural::from(3u32), &Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_pow(Natural::from(3u32), Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_pow(Natural::from(3u32), Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_pow(Natural::from(3u32), &Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_pow(Natural::from(3u32), &Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_pow(&Natural::from(3u32), Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_pow(&Natural::from(3u32), Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_pow(&Natural::from(3u32), &Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_pow(&Natural::from(3u32), &Natural::ONE));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_pow_assign(Natural::from(3u32), Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_pow_assign(Natural::from(3u32), Natural::ONE);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_pow_assign(Natural::from(3u32), &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_pow_assign(Natural::from(3u32), Natural::ONE);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_pow_assign(&Natural::from(3u32), Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_pow_assign(Natural::from(3u32), Natural::ONE);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_pow_assign(&Natural::from(3u32), &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_pow_assign(Natural::from(3u32), Natural::ONE);\n    });\n}\n\n#[test]\nfn limbs_mod_pow_odd_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_quadruple_gen_var_7().test_properties_with_config(\n        &config,\n        |(mut out, xs, es, ms)| {\n            let out_old = out.clone();\n            let mut scratch = vec![0; limbs_mod_pow_odd_scratch_len(ms.len())];\n            limbs_mod_pow_odd(&mut out, &xs, &es, &ms, &mut scratch);\n            verify_limbs_mod_pow(&out_old, &xs, &es, &ms, &out);\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_pow_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_quadruple_gen_var_6().test_properties_with_config(\n        &config,\n        |(mut out, xs, es, ms)| {\n            let out_old = out.clone();\n            limbs_mod_pow(&mut out, &xs, &es, &ms);\n            verify_limbs_mod_pow(&out_old, &xs, &es, &ms, &out);\n        },\n    );\n}\n\n#[test]\nfn mod_pow_properties() {\n    natural_triple_gen_var_5().test_properties(|(x, exp, m)| {\n        assert!(x.mod_is_reduced(&m));\n        let power_val_val_val = x.clone().mod_pow(exp.clone(), m.clone());\n        let power_val_ref_val = x.clone().mod_pow(&exp, m.clone());\n        let power_ref_val_val = (&x).mod_pow(exp.clone(), m.clone());\n        let power_ref_ref_val = (&x).mod_pow(&exp, m.clone());\n        let power_val_val_ref = x.clone().mod_pow(exp.clone(), &m);\n        let power_val_ref_ref = x.clone().mod_pow(&exp, &m);\n        let power_ref_val_ref = (&x).mod_pow(exp.clone(), &m);\n        let power = (&x).mod_pow(&exp, &m);\n        assert!(power_val_val_val.is_valid());\n        assert!(power_val_ref_val.is_valid());\n        assert!(power_ref_val_val.is_valid());\n        assert!(power_val_val_ref.is_valid());\n        assert!(power_val_val_ref.is_valid());\n        assert!(power_val_ref_ref.is_valid());\n        assert!(power_ref_val_ref.is_valid());\n        assert!(power.is_valid());\n        assert!(power.mod_is_reduced(&m));\n        assert_eq!(power_val_val_val, power);\n        assert_eq!(power_val_ref_val, power);\n        assert_eq!(power_ref_val_val, power);\n        assert_eq!(power_ref_ref_val, power);\n        assert_eq!(power_val_val_ref, power);\n        assert_eq!(power_val_ref_ref, power);\n        assert_eq!(power_ref_val_ref, power);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_pow_assign(exp.clone(), m.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, power);\n        let mut mut_x = x.clone();\n        mut_x.mod_pow_assign(&exp, m.clone());\n        assert_eq!(mut_x, power);\n        assert!(mut_x.is_valid());\n        let mut mut_x = x.clone();\n        mut_x.mod_pow_assign(exp.clone(), &m);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, power);\n        let mut mut_x = x.clone();\n        mut_x.mod_pow_assign(&exp, &m);\n        assert_eq!(mut_x, power);\n        assert!(mut_x.is_valid());\n\n        let num_power = BigUint::from(&x).modpow(&BigUint::from(&exp), &BigUint::from(&m));\n        assert_eq!(Natural::from(&num_power), power);\n        let rug_power = rug::Integer::from(&x)\n            .pow_mod(&rug::Integer::from(&exp), &rug::Integer::from(&m))\n            .unwrap();\n        assert_eq!(Natural::exact_from(&rug_power), power);\n\n        if exp.even() {\n            assert_eq!(x.mod_neg(&m).mod_pow(exp, m), power);\n        } else {\n            assert_eq!(x.mod_neg(&m).mod_pow(exp, &m), power.mod_neg(m));\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(exp, m)| {\n        assert_eq!(\n            Natural::ZERO.mod_pow(&exp, &m),\n            Natural::from(exp == 0 && m != 1),\n        );\n        if m != 1 {\n            assert_eq!(Natural::ONE.mod_pow(exp, m), 1);\n        }\n    });\n\n    natural_pair_gen_var_8().test_properties(|(ref x, ref m)| {\n        assert_eq!(x.mod_pow(Natural::ZERO, m), Natural::from(*m != 1));\n        assert_eq!(x.mod_pow(Natural::ONE, m), *x);\n        assert_eq!(x.mod_pow(Natural::TWO, m), x.mod_mul(x, m));\n    });\n\n    natural_quadruple_gen_var_2().test_properties(|(ref x, ref y, ref exp, ref m)| {\n        assert_eq!(\n            x.mod_mul(y, m).mod_pow(exp, m),\n            x.mod_pow(exp, m).mod_mul(y.mod_pow(exp, m), m)\n        );\n    });\n\n    natural_quadruple_gen_var_3().test_properties(|(ref x, ref e, ref f, ref m)| {\n        assert_eq!(\n            x.mod_pow(e + f, m),\n            x.mod_pow(e, m).mod_mul(x.mod_pow(f, m), m)\n        );\n        assert_eq!(x.mod_pow(e * f, m), x.mod_pow(e, m).mod_pow(f, m));\n    });\n\n    unsigned_triple_gen_var_15::<Limb, u64>().test_properties(|(x, exp, m)| {\n        assert_eq!(\n            x.mod_pow(exp, m),\n            Natural::from(x).mod_pow(Natural::from(exp), Natural::from(m))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    DivisibleByPowerOf2, ModPowerOf2, ModPowerOf2Assign, ModPowerOf2IsReduced, NegModPowerOf2,\n    NegModPowerOf2Assign, PowerOf2, RemPowerOf2, RemPowerOf2Assign, ShrRound,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_2, unsigned_pair_gen_var_20,\n    unsigned_vec_unsigned_pair_gen_var_16,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2::{\n    limbs_mod_power_of_2, limbs_neg_mod_power_of_2, limbs_neg_mod_power_of_2_in_place,\n    limbs_slice_mod_power_of_2_in_place, limbs_vec_mod_power_of_2_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_natural_unsigned_triple_gen_var_1, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_pair_gen_var_9, natural_unsigned_pair_gen_var_10,\n    natural_unsigned_unsigned_triple_gen_var_5,\n};\nuse std::cmp::min;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_and_limbs_vec_mod_power_of_2_in_place() {\n    let test = |xs: &[Limb], pow: u64, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2(xs, pow), out);\n\n        let mut xs = xs.to_vec();\n        limbs_vec_mod_power_of_2_in_place(&mut xs, pow);\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, &[]);\n    test(&[], 5, &[]);\n    test(&[], 100, &[]);\n    test(&[6, 7], 2, &[2]);\n    test(&[100, 101, 102], 10, &[100]);\n    test(&[123, 456], 0, &[]);\n    test(&[123, 456], 1, &[1]);\n    test(&[123, 456], 10, &[123]);\n    test(&[123, 456], 33, &[123, 0]);\n    test(&[123, 456], 40, &[123, 200]);\n    test(&[123, 456], 100, &[123, 456]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_mod_power_of_2_in_place() {\n    let test = |xs: &[Limb], pow: u64, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        limbs_slice_mod_power_of_2_in_place(&mut xs, pow);\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, &[]);\n    test(&[], 5, &[]);\n    test(&[], 100, &[]);\n    test(&[6, 7], 2, &[2, 0]);\n    test(&[100, 101, 102], 10, &[100, 0, 0]);\n    test(&[123, 456], 0, &[0, 0]);\n    test(&[123, 456], 1, &[1, 0]);\n    test(&[123, 456], 10, &[123, 0]);\n    test(&[123, 456], 33, &[123, 0]);\n    test(&[123, 456], 40, &[123, 200]);\n    test(&[123, 456], 100, &[123, 456]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_neg_mod_power_of_2_and_limbs_neg_mod_power_of_2_in_place() {\n    let test = |xs: &[Limb], pow: u64, out: &[Limb]| {\n        assert_eq!(limbs_neg_mod_power_of_2(xs, pow), out);\n\n        let mut xs = xs.to_vec();\n        limbs_neg_mod_power_of_2_in_place(&mut xs, pow);\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, &[]);\n    test(&[], 5, &[0]);\n    test(&[], 100, &[0, 0, 0, 0]);\n    test(&[6, 7], 2, &[2]);\n    test(&[100, 101, 102], 10, &[924]);\n    test(&[123, 456], 0, &[]);\n    test(&[123, 456], 1, &[1]);\n    test(&[123, 456], 10, &[901]);\n    test(&[123, 456], 33, &[4294967173, 1]);\n    test(&[123, 456], 40, &[4294967173, 55]);\n    test(&[123, 456], 100, &[4294967173, 4294966839, u32::MAX, 15]);\n}\n\n#[test]\nfn test_mod_power_of_2_and_rem_power_of_2() {\n    let test = |s, v: u64, out| {\n        let u = Natural::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        n.mod_power_of_2_assign(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_power_of_2_is_reduced(v));\n\n        let n = u.clone().mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.rem_power_of_2_assign(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().rem_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).rem_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", 0, \"0\");\n    test(\"260\", 8, \"4\");\n    test(\"1611\", 4, \"11\");\n    test(\"123\", 100, \"123\");\n    test(\"1000000000000\", 0, \"0\");\n    test(\"1000000000000\", 12, \"0\");\n    test(\"1000000000001\", 12, \"1\");\n    test(\"999999999999\", 12, \"4095\");\n    test(\"1000000000000\", 15, \"4096\");\n    test(\"1000000000000\", 100, \"1000000000000\");\n    test(\"1000000000000000000000000\", 40, \"1020608380928\");\n    test(\"1000000000000000000000000\", 64, \"2003764205206896640\");\n    test(\"4294967295\", 31, \"2147483647\");\n    test(\"4294967295\", 32, \"4294967295\");\n    test(\"4294967295\", 33, \"4294967295\");\n    test(\"4294967296\", 31, \"0\");\n    test(\"4294967296\", 32, \"0\");\n    test(\"4294967296\", 33, \"4294967296\");\n    test(\"4294967297\", 31, \"1\");\n    test(\"4294967297\", 32, \"1\");\n    test(\"4294967297\", 33, \"4294967297\");\n}\n\n#[test]\nfn test_neg_mod_power_of_2() {\n    let test = |s, v: u64, out| {\n        let u = Natural::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        n.neg_mod_power_of_2_assign(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_power_of_2_is_reduced(v));\n\n        let n = u.clone().neg_mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).neg_mod_power_of_2(v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n\n    test(\"0\", 0, \"0\");\n    test(\"260\", 8, \"252\");\n    test(\"1611\", 4, \"5\");\n    test(\"123\", 100, \"1267650600228229401496703205253\");\n    test(\"1000000000000\", 0, \"0\");\n    test(\"1000000000000\", 12, \"0\");\n    test(\"1000000000001\", 12, \"4095\");\n    test(\"999999999999\", 12, \"1\");\n    test(\"1000000000000\", 15, \"28672\");\n    test(\"1000000000000\", 100, \"1267650600228229400496703205376\");\n    test(\"1000000000000000000000000\", 40, \"78903246848\");\n    test(\"1000000000000000000000000\", 64, \"16442979868502654976\");\n    test(\"4294967295\", 31, \"1\");\n    test(\"4294967295\", 32, \"1\");\n    test(\"4294967295\", 33, \"4294967297\");\n    test(\"4294967296\", 31, \"0\");\n    test(\"4294967296\", 32, \"0\");\n    test(\"4294967296\", 33, \"4294967296\");\n    test(\"4294967297\", 31, \"2147483647\");\n    test(\"4294967297\", 32, \"4294967295\");\n    test(\"4294967297\", 33, \"4294967295\");\n}\n\n#[test]\nfn limbs_mod_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, pow)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_mod_power_of_2(&xs, pow)),\n            Natural::from_owned_limbs_asc(xs).mod_power_of_2(pow),\n        );\n    });\n}\n\nmacro_rules! limbs_slice_mod_power_of_2_in_place_helper {\n    ($f: ident, $xs: ident, $pow: ident) => {\n        let old_xs = $xs.clone();\n        $f(&mut $xs, $pow);\n        let n = Natural::from_limbs_asc(&old_xs).mod_power_of_2($pow);\n        assert_eq!(Natural::from_owned_limbs_asc($xs), n);\n    };\n}\n\n#[test]\nfn limbs_slice_mod_power_of_2_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut xs, pow)| {\n            limbs_slice_mod_power_of_2_in_place_helper!(\n                limbs_slice_mod_power_of_2_in_place,\n                xs,\n                pow\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_mod_power_of_2_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut xs, pow)| {\n            limbs_slice_mod_power_of_2_in_place_helper!(limbs_vec_mod_power_of_2_in_place, xs, pow);\n        },\n    );\n}\n\n#[test]\nfn limbs_neg_mod_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, pow)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_neg_mod_power_of_2(&xs, pow)),\n            Natural::from_owned_limbs_asc(xs).neg_mod_power_of_2(pow),\n        );\n    });\n}\n\n#[test]\nfn limbs_neg_mod_power_of_2_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut xs, pow)| {\n            let old_xs = xs.clone();\n            limbs_neg_mod_power_of_2_in_place(&mut xs, pow);\n            let n = Natural::from_limbs_asc(&old_xs).neg_mod_power_of_2(pow);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn mod_power_of_2_and_rem_power_of_2_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n.mod_power_of_2_assign(u);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n        assert!(result.mod_power_of_2_is_reduced(u));\n\n        let result_alt = (&n).mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = n.clone().mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let mut mut_n = n.clone();\n        mut_n.rem_power_of_2_assign(u);\n        assert!(mut_n.is_valid());\n        let result_alt = mut_n;\n        assert_eq!(result_alt, result);\n\n        let result_alt = (&n).rem_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = n.clone().rem_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert!(result <= n);\n        assert_eq!((&n >> u << u) + &result, n);\n        assert!(result < Natural::power_of_2(u));\n        assert_eq!(result == 0, n.divisible_by_power_of_2(u));\n        assert_eq!((&result).mod_power_of_2(u), result);\n        assert_eq!(n & Natural::low_mask(u), result);\n    });\n\n    natural_natural_unsigned_triple_gen_var_1().test_properties(|(x, y, u)| {\n        assert_eq!(\n            (&x + &y).mod_power_of_2(u),\n            ((&x).mod_power_of_2(u) + (&y).mod_power_of_2(u)).mod_power_of_2(u)\n        );\n        assert_eq!(\n            (&x * &y).mod_power_of_2(u),\n            (x.mod_power_of_2(u) * y.mod_power_of_2(u)).mod_power_of_2(u)\n        );\n    });\n\n    natural_unsigned_pair_gen_var_9().test_properties(|(n, u)| {\n        assert_eq!(n.mod_power_of_2(u), 0);\n    });\n\n    natural_unsigned_pair_gen_var_10().test_properties(|(n, u)| {\n        assert_ne!((&n).mod_power_of_2(u), 0);\n        assert_eq!(\n            (&n).mod_power_of_2(u) + n.neg_mod_power_of_2(u),\n            Natural::power_of_2(u)\n        );\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_5().test_properties(|(n, u, v)| {\n        assert_eq!(\n            (&n).mod_power_of_2(u).mod_power_of_2(v),\n            n.mod_power_of_2(min(u, v))\n        );\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(n.mod_power_of_2(0), 0);\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Natural::ZERO.mod_power_of_2(u), 0);\n    });\n\n    unsigned_pair_gen_var_2::<Limb, u64>().test_properties(|(u, pow)| {\n        assert_eq!(u.mod_power_of_2(pow), Natural::from(u).mod_power_of_2(pow));\n        assert_eq!(u.rem_power_of_2(pow), Natural::from(u).rem_power_of_2(pow));\n    });\n}\n\n#[test]\nfn neg_mod_power_of_2_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n.neg_mod_power_of_2_assign(u);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n        assert!(result.mod_power_of_2_is_reduced(u));\n\n        let result_alt = (&n).neg_mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = n.clone().neg_mod_power_of_2(u);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert_eq!(((&n).shr_round(u, Ceiling).0 << u) - &result, n);\n        assert!(result < Natural::power_of_2(u));\n        assert_eq!(result == 0, n.divisible_by_power_of_2(u));\n        assert_eq!((&result).neg_mod_power_of_2(u), (&n).mod_power_of_2(u));\n        assert_eq!((-n).mod_power_of_2(u), result);\n    });\n\n    natural_natural_unsigned_triple_gen_var_1().test_properties(|(x, y, u)| {\n        assert_eq!(\n            (&x + &y).neg_mod_power_of_2(u),\n            ((&x).mod_power_of_2(u) + (&y).mod_power_of_2(u)).neg_mod_power_of_2(u)\n        );\n        assert_eq!(\n            (&x * &y).neg_mod_power_of_2(u),\n            (x.mod_power_of_2(u) * y.mod_power_of_2(u)).neg_mod_power_of_2(u)\n        );\n    });\n\n    natural_unsigned_pair_gen_var_9().test_properties(|(n, u)| {\n        assert_eq!(n.neg_mod_power_of_2(u), 0);\n    });\n\n    natural_unsigned_pair_gen_var_10().test_properties(|(n, u)| {\n        let m = (&n).neg_mod_power_of_2(u);\n        assert_ne!(m, 0);\n        assert_eq!((((&n >> u) + Natural::ONE) << u) - &m, n);\n        assert_eq!(n.mod_power_of_2(u) + m, Natural::power_of_2(u));\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(n.neg_mod_power_of_2(0), 0);\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Natural::ZERO.neg_mod_power_of_2(u), 0);\n    });\n\n    unsigned_pair_gen_var_20::<Limb>().test_properties(|(u, pow)| {\n        assert_eq!(\n            u.neg_mod_power_of_2(pow),\n            Natural::from(u).neg_mod_power_of_2(pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModAdd, ModPowerOf2, ModPowerOf2Add, ModPowerOf2AddAssign, ModPowerOf2IsReduced,\n    ModPowerOf2Neg, ModPowerOf2Shl, ModPowerOf2Sub, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_11;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_add::{\n    limbs_mod_power_of_2_add, limbs_mod_power_of_2_add_greater,\n    limbs_mod_power_of_2_add_in_place_either, limbs_mod_power_of_2_add_limb,\n    limbs_slice_mod_power_of_2_add_greater_in_place_left,\n    limbs_slice_mod_power_of_2_add_limb_in_place, limbs_vec_mod_power_of_2_add_in_place_left,\n    limbs_vec_mod_power_of_2_add_limb_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_natural_unsigned_quadruple_gen_var_2,\n    natural_natural_unsigned_triple_gen_var_4, natural_unsigned_pair_gen_var_11,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_14,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_15,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_add_limb() {\n    let test = |xs: &[Limb], y: Limb, pow: u64, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2_add_limb(xs, y, pow), out);\n    };\n    test(&[], 0, 0, &[]);\n    test(&[], 0, 5, &[]);\n    test(&[], 5, 3, &[5]);\n    test(&[123, 456], 789, 41, &[912, 456]);\n    test(&[u32::MAX], 2, 33, &[1, 1]);\n    test(&[u32::MAX], 2, 32, &[1]);\n    test(&[u32::MAX, 3], 2, 34, &[1, 0]);\n    test(&[u32::MAX, 3], 2, 35, &[1, 4]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_mod_power_of_2_add_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, pow: u64, out: &[Limb], carry: bool| {\n        let mut xs = xs.to_vec();\n        assert_eq!(\n            limbs_slice_mod_power_of_2_add_limb_in_place(&mut xs, y, pow),\n            carry\n        );\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, 0, &[], false);\n    test(&[], 0, 5, &[], false);\n    test(&[], 5, 3, &[], true);\n    test(&[123, 456], 789, 41, &[912, 456], false);\n    test(&[u32::MAX], 2, 33, &[1], true);\n    test(&[u32::MAX], 2, 32, &[1], false);\n    test(&[u32::MAX, 3], 2, 34, &[1, 0], false);\n    test(&[u32::MAX, 3], 2, 35, &[1, 4], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_mod_power_of_2_add_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, pow: u64, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        limbs_vec_mod_power_of_2_add_limb_in_place(&mut xs, y, pow);\n        assert_eq!(xs, out);\n    };\n    test(&[123, 456], 789, 41, &[912, 456]);\n    test(&[u32::MAX], 2, 33, &[1, 1]);\n    test(&[u32::MAX], 2, 32, &[1]);\n    test(&[u32::MAX, 3], 2, 34, &[1, 0]);\n    test(&[u32::MAX, 3], 2, 35, &[1, 4]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_mod_power_of_2_add_limb_in_place_fail() {\n    limbs_vec_mod_power_of_2_add_limb_in_place(&mut vec![], 10, 4);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_add_greater() {\n    let test = |xs, ys, pow, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2_add_greater(xs, ys, pow), out);\n    };\n    test(&[], &[], 0, &[]);\n    test(&[], &[], 5, &[]);\n    test(&[2], &[], 3, &[2]);\n    test(&[2], &[3], 2, &[1]);\n    test(&[1, 2, 3], &[6, 7], 100, &[7, 9, 3]);\n    test(&[100, 101, u32::MAX], &[102, 101, 2], 97, &[202, 202, 1, 1]);\n    test(&[100, 101, u32::MAX], &[102, 101, 2], 96, &[202, 202, 1]);\n    test(&[u32::MAX], &[2], 33, &[1, 1]);\n    test(&[u32::MAX], &[2], 32, &[1]);\n    test(&[u32::MAX, 3], &[2], 34, &[1, 0]);\n    test(&[u32::MAX, 3], &[2], 35, &[1, 4]);\n    test(&[u32::MAX, u32::MAX], &[2], 65, &[1, 0, 1]);\n    test(&[u32::MAX, u32::MAX], &[2], 64, &[1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn test_limbs_mod_power_of_2_add_greater_fail() {\n    limbs_mod_power_of_2_add_greater(&[6, 7], &[1, 2, 3], 4);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_add_and_limbs_vec_mod_power_of_2_add_in_place_left() {\n    let test = |xs_before, ys, pow, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2_add(xs_before, ys, pow), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_vec_mod_power_of_2_add_in_place_left(&mut xs, ys, pow);\n        assert_eq!(xs, out);\n    };\n    test(&[], &[], 0, &[]);\n    test(&[], &[], 5, &[]);\n    test(&[2], &[], 3, &[2]);\n    test(&[], &[2], 3, &[2]);\n    test(&[2], &[3], 2, &[1]);\n    test(&[1, 2, 3], &[6, 7], 100, &[7, 9, 3]);\n    test(&[6, 7], &[1, 2, 3], 100, &[7, 9, 3]);\n    test(&[100, 101, u32::MAX], &[102, 101, 2], 97, &[202, 202, 1, 1]);\n    test(&[100, 101, u32::MAX], &[102, 101, 2], 96, &[202, 202, 1]);\n    test(&[u32::MAX], &[2], 33, &[1, 1]);\n    test(&[u32::MAX], &[2], 32, &[1]);\n    test(&[u32::MAX, 3], &[2], 34, &[1, 0]);\n    test(&[u32::MAX, 3], &[2], 35, &[1, 4]);\n    test(&[u32::MAX, u32::MAX], &[2], 65, &[1, 0, 1]);\n    test(&[u32::MAX, u32::MAX], &[2], 64, &[1, 0]);\n    test(&[2], &[u32::MAX, u32::MAX], 65, &[1, 0, 1]);\n    test(&[2], &[u32::MAX, u32::MAX], 64, &[1, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_mod_power_of_2_add_greater_in_place_left() {\n    let test = |xs_before: &[Limb], ys, pow, xs_after: &[Limb], carry| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_slice_mod_power_of_2_add_greater_in_place_left(&mut xs, ys, pow),\n            carry\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], 0, &[], false);\n    test(&[], &[], 5, &[], false);\n    test(&[2], &[], 3, &[2], false);\n    test(&[2], &[3], 2, &[1], false);\n    test(&[1, 2, 3], &[6, 7], 100, &[7, 9, 3], false);\n    test(\n        &[100, 101, u32::MAX],\n        &[102, 101, 2],\n        97,\n        &[202, 202, 1],\n        true,\n    );\n    test(\n        &[100, 101, u32::MAX],\n        &[102, 101, 2],\n        96,\n        &[202, 202, 1],\n        false,\n    );\n    test(&[u32::MAX], &[2], 33, &[1], true);\n    test(&[u32::MAX], &[2], 32, &[1], false);\n    test(&[u32::MAX, 3], &[2], 34, &[1, 0], false);\n    test(&[u32::MAX, 3], &[2], 35, &[1, 4], false);\n    test(&[u32::MAX, u32::MAX], &[2], 65, &[1, 0], true);\n    test(&[u32::MAX, u32::MAX], &[2], 64, &[1, 0], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_mod_power_of_2_add_greater_in_place_left_fail() {\n    let mut xs = vec![6, 7];\n    limbs_slice_mod_power_of_2_add_greater_in_place_left(&mut xs, &[1, 2, 3], 4);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_add_in_place_either() {\n    let test = |xs_before: &[Limb],\n                ys_before: &[Limb],\n                pow,\n                right,\n                xs_after: &[Limb],\n                ys_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_mod_power_of_2_add_in_place_either(&mut xs, &mut ys, pow),\n            right\n        );\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], 0, false, &[], &[]);\n    test(&[], &[], 5, false, &[], &[]);\n    test(&[2], &[], 3, false, &[2], &[]);\n    test(&[], &[2], 3, true, &[], &[2]);\n    test(&[2], &[3], 2, false, &[1], &[3]);\n    test(&[1, 2, 3], &[6, 7], 100, false, &[7, 9, 3], &[6, 7]);\n    test(&[6, 7], &[1, 2, 3], 100, true, &[6, 7], &[7, 9, 3]);\n    test(\n        &[100, 101, u32::MAX],\n        &[102, 101, 2],\n        97,\n        false,\n        &[202, 202, 1, 1],\n        &[102, 101, 2],\n    );\n    test(\n        &[100, 101, u32::MAX],\n        &[102, 101, 2],\n        96,\n        false,\n        &[202, 202, 1],\n        &[102, 101, 2],\n    );\n    test(&[u32::MAX], &[2], 33, false, &[1, 1], &[2]);\n    test(&[u32::MAX], &[2], 32, false, &[1], &[2]);\n    test(&[u32::MAX, 3], &[2], 34, false, &[1, 0], &[2]);\n    test(&[u32::MAX, 3], &[2], 35, false, &[1, 4], &[2]);\n    test(&[u32::MAX, u32::MAX], &[2], 65, false, &[1, 0, 1], &[2]);\n    test(&[u32::MAX, u32::MAX], &[2], 64, false, &[1, 0], &[2]);\n    test(&[2], &[u32::MAX, u32::MAX], 65, true, &[2], &[1, 0, 1]);\n    test(&[2], &[u32::MAX, u32::MAX], 64, true, &[2], &[1, 0]);\n}\n\n#[test]\nfn test_mod_power_of_2_add() {\n    let test = |s, t, pow, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_power_of_2_is_reduced(pow));\n        assert!(v.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_add_assign(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_add_assign(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_add(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_add(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_add(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_add(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", 0, \"0\");\n    test(\"0\", \"0\", 5, \"0\");\n    test(\"0\", \"2\", 5, \"2\");\n    test(\"10\", \"14\", 4, \"8\");\n    test(\"0\", \"123\", 7, \"123\");\n    test(\"123\", \"0\", 7, \"123\");\n    test(\"123\", \"456\", 9, \"67\");\n    test(\"1267650600228229401496703205375\", \"3\", 100, \"2\");\n    test(\"3\", \"1267650600228229401496703205375\", 100, \"2\");\n}\n\n#[test]\nfn mod_power_of_2_add_fail() {\n    assert_panic!(Natural::ZERO.mod_power_of_2_add(Natural::ONE, 0));\n    assert_panic!(Natural::ONE.mod_power_of_2_add(Natural::ZERO, 0));\n\n    assert_panic!(Natural::ZERO.mod_power_of_2_add(&Natural::ONE, 0));\n    assert_panic!(Natural::ONE.mod_power_of_2_add(&Natural::ZERO, 0));\n\n    assert_panic!((&Natural::ZERO).mod_power_of_2_add(Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_add(Natural::ZERO, 0));\n\n    assert_panic!((&Natural::ZERO).mod_power_of_2_add(Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_add(Natural::ZERO, 0));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_power_of_2_add_assign(Natural::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_add_assign(Natural::ZERO, 0);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_power_of_2_add_assign(&Natural::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_add_assign(&Natural::ZERO, 0);\n    });\n}\n\n#[test]\nfn limbs_mod_power_of_2_add_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_14().test_properties_with_config(\n        &config,\n        |(xs, y, pow)| {\n            assert_eq!(\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_add_limb(&xs, y, pow)),\n                Natural::from_owned_limbs_asc(xs).mod_power_of_2_add(Natural::from(y), pow),\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_mod_power_of_2_add_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_14().test_properties_with_config(\n        &config,\n        |(mut xs, y, pow)| {\n            let old_xs = xs.clone();\n            let carry = limbs_slice_mod_power_of_2_add_limb_in_place(&mut xs, y, pow);\n            let n = Natural::from_limbs_asc(&old_xs).mod_power_of_2_add(Natural::from(y), pow);\n            let mut expected_limbs = n.into_limbs_asc();\n            assert_eq!(carry, expected_limbs.len() == xs.len() + 1);\n            expected_limbs.resize(xs.len(), 0);\n            assert_eq!(xs, expected_limbs);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_mod_power_of_2_add_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_15().test_properties_with_config(\n        &config,\n        |(mut xs, y, pow)| {\n            let old_xs = xs.clone();\n            limbs_vec_mod_power_of_2_add_limb_in_place(&mut xs, y, pow);\n            let n = Natural::from_owned_limbs_asc(old_xs).mod_power_of_2_add(Natural::from(y), pow);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\nfn limbs_mod_power_of_2_add_helper(\n    f: &dyn Fn(&[Limb], &[Limb], u64) -> Vec<Limb>,\n    xs: Vec<Limb>,\n    ys: Vec<Limb>,\n    pow: u64,\n) {\n    assert_eq!(\n        Natural::from_owned_limbs_asc(f(&xs, &ys, pow)),\n        Natural::from_owned_limbs_asc(xs)\n            .mod_power_of_2_add(Natural::from_owned_limbs_asc(ys), pow)\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_add_greater_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19().test_properties_with_config(\n        &config,\n        |(xs, ys, pow)| {\n            limbs_mod_power_of_2_add_helper(&limbs_mod_power_of_2_add_greater, xs, ys, pow);\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_add_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().test_properties_with_config(\n        &config,\n        |(xs, ys, pow)| {\n            limbs_mod_power_of_2_add_helper(&limbs_mod_power_of_2_add, xs, ys, pow);\n        },\n    );\n}\n\n#[test]\nfn limbs_slice_mod_power_of_2_add_greater_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_19().test_properties_with_config(\n        &config,\n        |(mut xs, ys, pow)| {\n            let xs_old = xs.clone();\n            let carry = limbs_slice_mod_power_of_2_add_greater_in_place_left(&mut xs, &ys, pow);\n            let n = Natural::from_owned_limbs_asc(xs_old)\n                .mod_power_of_2_add(Natural::from_owned_limbs_asc(ys), pow);\n            let len = xs.len();\n            let mut limbs = n.into_limbs_asc();\n            assert_eq!(carry, limbs.len() == len + 1);\n            limbs.resize(len, 0);\n            assert_eq!(limbs, xs);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_mod_power_of_2_add_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().test_properties_with_config(\n        &config,\n        |(mut xs, ys, pow)| {\n            let xs_old = xs.clone();\n            limbs_vec_mod_power_of_2_add_in_place_left(&mut xs, &ys, pow);\n            assert_eq!(\n                Natural::from_owned_limbs_asc(xs),\n                Natural::from_owned_limbs_asc(xs_old)\n                    .mod_power_of_2_add(Natural::from_owned_limbs_asc(ys), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_add_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().test_properties_with_config(\n        &config,\n        |(mut xs, mut ys, pow)| {\n            let xs_old = xs.clone();\n            let ys_old = ys.clone();\n            let right = limbs_mod_power_of_2_add_in_place_either(&mut xs, &mut ys, pow);\n            let n = Natural::from_limbs_asc(&xs_old)\n                .mod_power_of_2_add(Natural::from_limbs_asc(&ys_old), pow);\n            if right {\n                assert_eq!(xs, xs_old);\n                assert_eq!(Natural::from_owned_limbs_asc(ys), n);\n            } else {\n                assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n                assert_eq!(ys, ys_old);\n            }\n        },\n    );\n}\n\n#[test]\nfn mod_power_of_2_add_properties() {\n    natural_natural_unsigned_triple_gen_var_4().test_properties(|(x, y, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        assert!(y.mod_power_of_2_is_reduced(pow));\n        let sum_val_val = x.clone().mod_power_of_2_add(y.clone(), pow);\n        let sum_val_ref = x.clone().mod_power_of_2_add(&y, pow);\n        let sum_ref_val = (&x).mod_power_of_2_add(y.clone(), pow);\n        let sum = (&x).mod_power_of_2_add(&y, pow);\n        assert!(sum_val_val.is_valid());\n        assert!(sum_val_ref.is_valid());\n        assert!(sum_ref_val.is_valid());\n        assert!(sum.is_valid());\n        assert!(sum.mod_power_of_2_is_reduced(pow));\n        assert_eq!(sum_val_val, sum);\n        assert_eq!(sum_val_ref, sum);\n        assert_eq!(sum_ref_val, sum);\n\n        assert_eq!((&x + &y).mod_power_of_2(pow), sum);\n        let mut sum_alt = &x + &y;\n        sum_alt.clear_bit(pow);\n        assert_eq!(sum_alt, sum);\n        assert_eq!((&x).mod_add(&y, Natural::power_of_2(pow)), sum);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_add_assign(y.clone(), pow);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, sum);\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_add_assign(&y, pow);\n        assert_eq!(mut_x, sum);\n        assert!(mut_x.is_valid());\n\n        assert_eq!((&y).mod_power_of_2_add(&x, pow), sum);\n        assert_eq!(\n            (&x).mod_power_of_2_sub((&y).mod_power_of_2_neg(pow), pow),\n            sum\n        );\n        assert_eq!((&sum).mod_power_of_2_sub(&x, pow), y);\n        assert_eq!(sum.mod_power_of_2_sub(y, pow), x);\n    });\n\n    natural_unsigned_pair_gen_var_11().test_properties(|(x, pow)| {\n        assert_eq!((&x).mod_power_of_2_add(Natural::ZERO, pow), x);\n        assert_eq!(Natural::ZERO.mod_power_of_2_add(&x, pow), x);\n        assert_eq!(\n            (&x).mod_power_of_2_add(&x, pow),\n            x.mod_power_of_2_shl(1, pow)\n        );\n    });\n\n    natural_natural_natural_unsigned_quadruple_gen_var_2().test_properties(|(x, y, z, pow)| {\n        assert_eq!(\n            (&x).mod_power_of_2_add(&y, pow).mod_power_of_2_add(&z, pow),\n            x.mod_power_of_2_add(y.mod_power_of_2_add(z, pow), pow)\n        );\n    });\n\n    unsigned_triple_gen_var_11::<Limb>().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_add(y, pow),\n            Natural::from(x).mod_power_of_2_add(Natural::from(y), pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_inverse.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModInverse, ModPowerOf2Inverse, ModPowerOf2IsReduced, ModPowerOf2Mul, ModPowerOf2Neg, Parity,\n    PowerOf2,\n};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::{unsigned_gen_var_11, unsigned_pair_gen_var_39};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_14;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_power_of_2_inverse() {\n    let test = |s, pow, out| {\n        let n = Natural::from_str(s).unwrap();\n\n        let result = n.clone().mod_power_of_2_inverse(pow);\n        assert_eq!(result.to_debug_string(), out);\n        assert!(result.is_none_or(|n| n.is_valid()));\n\n        let result = (&n).mod_power_of_2_inverse(pow);\n        assert_eq!(result.to_debug_string(), out);\n        assert!(result.is_none_or(|n| n.is_valid()));\n\n        assert_eq!(\n            n.mod_inverse(Natural::power_of_2(pow)).to_debug_string(),\n            out\n        );\n    };\n    test(\"1\", 6, \"Some(1)\");\n    test(\"8\", 12, \"None\");\n    test(\"3\", 5, \"Some(11)\");\n    test(\"3\", 10, \"Some(683)\");\n    test(\"12345678987654321\", 60, \"Some(454333680368735313)\");\n    test(\"12345678987654322\", 60, \"None\");\n}\n\n#[test]\nfn mod_power_of_2_inverse() {\n    assert_panic!(Natural::ZERO.mod_power_of_2_inverse(5));\n    assert_panic!(Natural::from(30u8).mod_power_of_2_inverse(3));\n    assert_panic!((&Natural::ZERO).mod_power_of_2_inverse(5));\n    assert_panic!((&Natural::from(30u8)).mod_power_of_2_inverse(3));\n}\n\n#[test]\nfn mod_power_of_2_inverse_properties() {\n    natural_unsigned_pair_gen_var_14().test_properties(|(n, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let result = n.clone().mod_power_of_2_inverse(pow);\n        let result_ref = (&n).mod_power_of_2_inverse(pow);\n        assert!(result.as_ref().is_none_or(Natural::is_valid));\n        assert!(result_ref.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(result_ref, result);\n\n        assert_eq!((&n).mod_inverse(Natural::power_of_2(pow)), result);\n        assert_eq!(result.is_some(), n.odd());\n        if let Some(inverse) = result {\n            assert!(inverse.mod_power_of_2_is_reduced(pow));\n            assert_eq!((&inverse).mod_power_of_2_inverse(pow).as_ref(), Some(&n));\n            assert_eq!((&n).mod_power_of_2_mul(&inverse, pow), 1u32);\n            assert_eq!(\n                n.mod_power_of_2_neg(pow).mod_power_of_2_inverse(pow),\n                Some(inverse.mod_power_of_2_neg(pow))\n            );\n        }\n    });\n\n    unsigned_gen_var_11().test_properties(|pow| {\n        assert_eq!(Natural::ONE.mod_power_of_2_inverse(pow), Some(Natural::ONE));\n        assert_eq!(\n            Natural::low_mask(pow).mod_power_of_2_inverse(pow),\n            Some(Natural::low_mask(pow))\n        );\n    });\n\n    unsigned_pair_gen_var_39::<Limb>().test_properties(|(n, pow)| {\n        assert_eq!(\n            Natural::from(n).mod_power_of_2_inverse(pow),\n            n.mod_power_of_2_inverse(pow).map(Natural::from)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_is_reduced.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModIsReduced, ModPowerOf2, ModPowerOf2IsReduced, PowerOf2,\n};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_2;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_power_of_2_is_reduced() {\n    let test = |u, pow, out| {\n        assert_eq!(\n            Natural::from_str(u).unwrap().mod_power_of_2_is_reduced(pow),\n            out\n        );\n    };\n\n    test(\"0\", 5, true);\n    test(\"100\", 5, false);\n    test(\"100\", 8, true);\n    test(\"1000000000000\", 39, false);\n    test(\"1000000000000\", 40, true);\n}\n\n#[test]\nfn mod_power_of_2_is_reduced_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, pow)| {\n        let is_reduced = n.mod_power_of_2_is_reduced(pow);\n        assert_eq!(is_reduced, (&n).mod_power_of_2(pow) == n);\n        assert_eq!(is_reduced, n.mod_is_reduced(&Natural::power_of_2(pow)));\n    });\n\n    unsigned_pair_gen_var_2::<Limb, u64>().test_properties(|(n, pow)| {\n        assert_eq!(\n            n.mod_power_of_2_is_reduced(pow),\n            Natural::from(n).mod_power_of_2_is_reduced(pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModMul, ModPowerOf2, ModPowerOf2Add, ModPowerOf2IsReduced, ModPowerOf2Mul,\n    ModPowerOf2MulAssign, ModPowerOf2Neg, ModPowerOf2Square, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_11;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_mul::{\n    limbs_mod_power_of_2_mul, limbs_mod_power_of_2_mul_ref_ref, limbs_mod_power_of_2_mul_val_ref,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_natural_unsigned_quadruple_gen_var_2,\n    natural_natural_unsigned_triple_gen_var_4, natural_unsigned_pair_gen_var_11,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_mul() {\n    let test = |xs, ys, pow, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2_mul_ref_ref(xs, ys, pow), out);\n\n        let mut mut_xs = xs.to_vec();\n        assert_eq!(limbs_mod_power_of_2_mul_val_ref(&mut mut_xs, ys, pow), out);\n\n        let mut mut_xs = xs.to_vec();\n        let mut mut_ys = ys.to_vec();\n        assert_eq!(limbs_mod_power_of_2_mul(&mut mut_xs, &mut mut_ys, pow), out);\n\n        let product = Natural::from_limbs_asc(out);\n        assert_eq!(\n            Natural::from_limbs_asc(xs).mod_power_of_2_mul(Natural::from_limbs_asc(ys), pow),\n            product\n        );\n        assert_eq!(\n            (Natural::from_limbs_asc(xs) * Natural::from_limbs_asc(ys)).mod_power_of_2(pow),\n            product\n        );\n    };\n    // - max_len <= xs_len + ys_len + 1\n    // - xs_len >= limit && ys_len >= limit\n    // - xs_len == max_len\n    // - ys_len == max_len\n    test(&[1], &[1], 1, &[1]);\n    test(&[1], &[1], 5, &[1]);\n    // - xs_len < max_len\n    // - ys_len < max_len\n    test(&[1], &[1], 33, &[1, 0]);\n    test(&[2], &[1], 3, &[2]);\n    test(&[1], &[2], 3, &[2]);\n    test(&[2], &[3], 2, &[2]);\n    // - xs_len < limit || ys_len < limit\n    test(&[1, 2, 3], &[6, 7], 100, &[6, 19, 32, 5]);\n    test(&[6, 7], &[1, 2, 3], 100, &[6, 19, 32, 5]);\n    // - max_len > xs_len + ys_len + 1\n    test(&[3255925883], &[3653042335], 131, &[2997571685, 2769295845]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_mul_fail_1() {\n    limbs_mod_power_of_2_mul(&mut vec![1], &mut vec![], 2);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_mul_fail_2() {\n    limbs_mod_power_of_2_mul(&mut vec![], &mut vec![1], 2);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_mul_val_ref_fail_1() {\n    limbs_mod_power_of_2_mul_val_ref(&mut vec![1], &[], 2);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_mul_val_ref_fail_2() {\n    limbs_mod_power_of_2_mul_val_ref(&mut vec![], &[1], 2);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_mul_ref_ref_fail_1() {\n    limbs_mod_power_of_2_mul_ref_ref(&[1], &[], 2);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_mul_ref_ref_fail_2() {\n    limbs_mod_power_of_2_mul_ref_ref(&[], &[1], 2);\n}\n\n#[test]\nfn test_mod_power_of_2_mul() {\n    let test = |s, t, pow, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_power_of_2_is_reduced(pow));\n        assert!(v.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_mul_assign(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_mul_assign(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_mul(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_mul(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_mul(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_mul(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", 0, \"0\");\n    test(\"1\", \"1\", 5, \"1\");\n    test(\"1\", \"1\", 33, \"1\");\n    test(\"1\", \"2\", 5, \"2\");\n    test(\"3\", \"2\", 5, \"6\");\n    test(\"10\", \"14\", 4, \"12\");\n    test(\"123\", \"456\", 9, \"280\");\n    test(\"123456789\", \"987654321\", 60, \"121932631112635269\");\n}\n\n#[test]\nfn mod_power_of_2_mul_fail() {\n    assert_panic!(Natural::ZERO.mod_power_of_2_mul(Natural::ONE, 0));\n    assert_panic!(Natural::ONE.mod_power_of_2_mul(Natural::ZERO, 0));\n\n    assert_panic!(Natural::ZERO.mod_power_of_2_mul(&Natural::ONE, 0));\n    assert_panic!(Natural::ONE.mod_power_of_2_mul(&Natural::ZERO, 0));\n\n    assert_panic!((&Natural::ZERO).mod_power_of_2_mul(Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_mul(Natural::ZERO, 0));\n\n    assert_panic!((&Natural::ZERO).mod_power_of_2_mul(Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_mul(Natural::ZERO, 0));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_power_of_2_mul_assign(Natural::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_mul_assign(Natural::ZERO, 0);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_power_of_2_mul_assign(&Natural::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_mul_assign(&Natural::ZERO, 0);\n    });\n}\n\n#[test]\nfn limbs_mod_power_of_2_mul_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20().test_properties_with_config(\n        &config,\n        |(mut xs, mut ys, pow)| {\n            let old_xs = xs.clone();\n            let old_ys = ys.clone();\n            let product =\n                Natural::from_limbs_asc(&xs).mod_power_of_2_mul(Natural::from_limbs_asc(&ys), pow);\n            assert_eq!(\n                (Natural::from_limbs_asc(&xs) * Natural::from_limbs_asc(&ys)).mod_power_of_2(pow),\n                product\n            );\n            assert_eq!(\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_mul(&mut xs, &mut ys, pow)),\n                product,\n            );\n            let mut xs = old_xs.clone();\n            assert_eq!(\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_mul_val_ref(&mut xs, &ys, pow)),\n                product,\n            );\n            assert_eq!(\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_mul_ref_ref(\n                    &old_xs, &old_ys, pow\n                )),\n                product,\n            );\n        },\n    );\n}\n\n#[test]\nfn mod_power_of_2_mul_properties() {\n    natural_natural_unsigned_triple_gen_var_4().test_properties(|(x, y, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        assert!(y.mod_power_of_2_is_reduced(pow));\n        let product_val_val = x.clone().mod_power_of_2_mul(y.clone(), pow);\n        let product_val_ref = x.clone().mod_power_of_2_mul(&y, pow);\n        let product_ref_val = (&x).mod_power_of_2_mul(y.clone(), pow);\n        let product = (&x).mod_power_of_2_mul(&y, pow);\n        assert!(product_val_val.is_valid());\n        assert!(product_val_ref.is_valid());\n        assert!(product_ref_val.is_valid());\n        assert!(product.is_valid());\n        assert!(product.mod_power_of_2_is_reduced(pow));\n        assert_eq!(product_val_val, product);\n        assert_eq!(product_val_ref, product);\n        assert_eq!(product_ref_val, product);\n\n        assert_eq!((&x * &y).mod_power_of_2(pow), product);\n        assert_eq!((&x).mod_mul(&y, Natural::power_of_2(pow)), product);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_mul_assign(y.clone(), pow);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_mul_assign(&y, pow);\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n\n        assert_eq!((&y).mod_power_of_2_mul(&x, pow), product);\n        assert_eq!(\n            (&x).mod_power_of_2_mul((&y).mod_power_of_2_neg(pow), pow),\n            (&product).mod_power_of_2_neg(pow)\n        );\n        assert_eq!(\n            x.mod_power_of_2_neg(pow).mod_power_of_2_mul(y, pow),\n            product.mod_power_of_2_neg(pow)\n        );\n    });\n\n    natural_unsigned_pair_gen_var_11().test_properties(|(ref x, pow)| {\n        assert_eq!(x.mod_power_of_2_mul(Natural::ZERO, pow), 0);\n        assert_eq!(Natural::ZERO.mod_power_of_2_mul(x, pow), 0);\n        if pow != 0 {\n            assert_eq!(x.mod_power_of_2_mul(Natural::ONE, pow), *x);\n            assert_eq!(Natural::ONE.mod_power_of_2_mul(x, pow), *x);\n        }\n        assert_eq!(x.mod_power_of_2_mul(x, pow), x.mod_power_of_2_square(pow));\n    });\n\n    natural_natural_natural_unsigned_quadruple_gen_var_2().test_properties(\n        |(ref x, ref y, ref z, pow)| {\n            assert_eq!(\n                x.mod_power_of_2_mul(y, pow).mod_power_of_2_mul(z, pow),\n                x.mod_power_of_2_mul(y.mod_power_of_2_mul(z, pow), pow)\n            );\n            assert_eq!(\n                x.mod_power_of_2_mul(y.mod_power_of_2_add(z, pow), pow),\n                x.mod_power_of_2_mul(y, pow)\n                    .mod_power_of_2_add(x.mod_power_of_2_mul(z, pow), pow)\n            );\n            assert_eq!(\n                x.mod_power_of_2_add(y, pow).mod_power_of_2_mul(z, pow),\n                x.mod_power_of_2_mul(z, pow)\n                    .mod_power_of_2_add(y.mod_power_of_2_mul(z, pow), pow)\n            );\n        },\n    );\n\n    unsigned_triple_gen_var_11::<Limb>().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_mul(y, pow),\n            Natural::from(x).mod_power_of_2_mul(Natural::from(y), pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModNeg, ModPowerOf2, ModPowerOf2Add, ModPowerOf2IsReduced, ModPowerOf2Neg,\n    ModPowerOf2NegAssign, PowerOf2,\n};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_17;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_11;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_power_of_2_neg() {\n    let test = |s, pow, out| {\n        let u = Natural::from_str(s).unwrap();\n\n        assert!(u.mod_power_of_2_is_reduced(pow));\n        let n = u.clone().mod_power_of_2_neg(pow);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n        assert!(n.mod_power_of_2_is_reduced(pow));\n\n        let n = (&u).mod_power_of_2_neg(pow);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u;\n        n.mod_power_of_2_neg_assign(pow);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 5, \"0\");\n    test(\"10\", 4, \"6\");\n    test(\"100\", 8, \"156\");\n    test(\"1\", 32, \"4294967295\");\n    test(\"100\", 100, \"1267650600228229401496703205276\");\n    test(\"1267650600228229401496703205276\", 100, \"100\");\n}\n\n#[test]\nfn mod_power_of_2_neg_fail() {\n    assert_panic!(Natural::ONE.mod_power_of_2_neg(0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_neg(0));\n\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_neg_assign(0);\n    });\n}\n\n#[test]\nfn mod_power_of_2_neg_properties() {\n    natural_unsigned_pair_gen_var_11().test_properties(|(n, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let neg = (&n).mod_power_of_2_neg(pow);\n        assert!(neg.is_valid());\n        assert!(neg.mod_power_of_2_is_reduced(pow));\n\n        let neg_alt = n.clone().mod_power_of_2_neg(pow);\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        let mut n_alt = n.clone();\n        n_alt.mod_power_of_2_neg_assign(pow);\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        assert_eq!(neg, (-&n).mod_power_of_2(pow));\n        assert_eq!(neg, (&n).mod_neg(Natural::power_of_2(pow)));\n        assert_eq!((&neg).mod_power_of_2_neg(pow), n);\n        assert_eq!((&n).mod_power_of_2_add(&neg, pow), 0);\n        assert_eq!(\n            n == neg,\n            n == Natural::ZERO || n == Natural::power_of_2(pow - 1)\n        );\n    });\n\n    unsigned_pair_gen_var_17::<Limb>().test_properties(|(n, pow)| {\n        assert_eq!(\n            n.mod_power_of_2_neg(pow),\n            Natural::from(n).mod_power_of_2_neg(pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2IsReduced, ModPowerOf2Mul, ModPowerOf2Neg, ModPowerOf2Pow,\n    ModPowerOf2PowAssign, Parity,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_16, unsigned_vec_pair_gen_var_3,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_pow::{\n    limbs_mod_power_of_2_pow, limbs_pow_low,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_natural_unsigned_quadruple_gen_var_3,\n    natural_natural_natural_unsigned_quadruple_gen_var_4,\n    natural_natural_unsigned_triple_gen_var_5, natural_unsigned_pair_gen,\n    natural_unsigned_pair_gen_var_11, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_power_of_2_pow::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nfn verify_limbs_pow_low(xs: &[Limb], es: &[Limb], out: &[Limb]) {\n    let exp = Natural::from_limbs_asc(es);\n    let n = xs.len();\n    let pow = u64::exact_from(n) << Limb::LOG_WIDTH;\n    let x = Natural::from_limbs_asc(xs).mod_power_of_2(pow);\n    let expected = x.mod_power_of_2_pow(exp, pow);\n    assert!(expected.mod_power_of_2_is_reduced(pow));\n    assert_eq!(Natural::from_limbs_asc(&out[..n]), expected);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pow_low() {\n    let test = |xs: &[Limb], es: &[Limb], out: &[Limb]| {\n        let xs_old = xs;\n        let mut xs = xs_old.to_vec();\n        let mut scratch = vec![0; xs.len()];\n        limbs_pow_low(&mut xs, es, &mut scratch);\n        assert_eq!(xs, out);\n        verify_limbs_pow_low(xs_old, es, out);\n    };\n    // - bit_index != 0 && !limbs_get_bit(es, bit_index - 1)\n    // - bit_index != 0 first time\n    // - bit_index >= window_size\n    // - this_windowsize == 1\n    // - bit_index != 0 second time\n    // - bit_index == 0 first time\n    test(&[3], &[20], &[3486784401]);\n    // - bit_index < window_size\n    // - bit_index == 0 second time\n    test(&[123, 456], &[789], &[426102667, 1687864191]);\n    // - this_windowsize > 1\n    test(\n        &[55455610, 1786865634],\n        &[\n            597666165, 1946668956, 2861877195, 1004122685, 3052222557, 4193145938, 1332420253,\n            4049695026, 536465941, 13401346, 206750422, 2547236772, 718474167, 1253952310,\n            4175135275, 3923178820, 3877868744,\n        ],\n        &[0, 0],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_low_fail_1() {\n    let mut scratch = vec![];\n    limbs_pow_low(&mut [], &[2], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_low_fail_2() {\n    let mut scratch = vec![1];\n    limbs_pow_low(&mut [1], &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_low_fail_3() {\n    let mut scratch = vec![1];\n    limbs_pow_low(&mut [1], &[2, 0], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_low_fail_4() {\n    let mut scratch = vec![1];\n    limbs_pow_low(&mut [1], &[1], &mut scratch);\n}\n\nfn verify_limbs_mod_power_of_2_pow(xs: &[Limb], es: &[Limb], pow: u64, out: &[Limb]) {\n    let exp = Natural::from_limbs_asc(es);\n    let x = Natural::from_limbs_asc(xs);\n    assert!(x.mod_power_of_2_is_reduced(pow));\n    let expected = (&x).mod_power_of_2_pow(&exp, pow);\n    assert!(expected.mod_power_of_2_is_reduced(pow));\n    assert_eq!(simple_binary_mod_power_of_2_pow(&x, &exp, pow), expected);\n    assert_eq!(Natural::from_limbs_asc(out), expected);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_pow() {\n    let test = |xs: &[Limb], es: &[Limb], pow: u64, out: &[Limb]| {\n        let xs_old = xs;\n        let mut xs = xs_old.to_vec();\n        limbs_mod_power_of_2_pow(&mut xs, es, pow);\n        assert_eq!(xs, out);\n        verify_limbs_mod_power_of_2_pow(xs_old, es, pow, out);\n    };\n    test(&[1], &[2], 2, &[1]);\n    test(&[3], &[2], 2, &[1]);\n    test(&[3], &[3], 4, &[11]);\n    test(&[25], &[10, 10], 5, &[17]);\n    test(&[123, 456], &[789, 987], 42, &[426102667, 987]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_pow_fail_1() {\n    limbs_mod_power_of_2_pow(&mut vec![2], &[2, 0], 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_pow_fail_2() {\n    limbs_mod_power_of_2_pow(&mut vec![2], &[1], 5);\n}\n\n#[test]\nfn test_mod_power_of_2_pow() {\n    let test = |s, t, pow, out| {\n        let u = Natural::from_str(s).unwrap();\n        let exp = Natural::from_str(t).unwrap();\n        assert!(u.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_pow_assign(exp.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_pow_assign(&exp, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_pow(exp.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_pow(exp.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_pow(&exp, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_pow(&exp, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", 0, \"0\");\n    test(\"0\", \"0\", 10, \"1\");\n    test(\"0\", \"1\", 10, \"0\");\n    test(\"2\", \"10\", 8, \"0\");\n    test(\"3\", \"10\", 8, \"169\");\n    test(\"10\", \"1000\", 30, \"0\");\n    test(\"11\", \"1000\", 30, \"289109473\");\n    test(\"3\", \"1000000\", 100, \"1176684907284103408190379631873\");\n    test(\n        \"123456789\",\n        \"1000000000\",\n        100,\n        \"1180978940853570377595087681537\",\n    );\n}\n\n#[test]\nfn mod_power_of_2_pow_fail() {\n    assert_panic!(Natural::ONE.mod_power_of_2_pow(Natural::ONE, 0));\n    assert_panic!(Natural::ONE.mod_power_of_2_pow(&Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_pow(Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_pow(&Natural::ONE, 0));\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_pow_assign(Natural::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_pow_assign(&Natural::ONE, 0);\n    });\n}\n\n#[test]\nfn limbs_pow_low_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_3().test_properties_with_config(&config, |(mut xs, es)| {\n        let xs_old = xs.clone();\n        let mut scratch = vec![0; xs.len()];\n        limbs_pow_low(&mut xs, &es, &mut scratch);\n        verify_limbs_pow_low(&xs_old, &es, &xs);\n    });\n}\n\n#[test]\nfn limbs_mod_power_of_2_pow_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_21().test_properties_with_config(\n        &config,\n        |(mut xs, es, pow)| {\n            let xs_old = xs.clone();\n            limbs_mod_power_of_2_pow(&mut xs, &es, pow);\n            verify_limbs_mod_power_of_2_pow(&xs_old, &es, pow, &xs);\n        },\n    );\n}\n\n#[test]\nfn mod_power_of_2_pow_properties() {\n    natural_natural_unsigned_triple_gen_var_5().test_properties(|(x, exp, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        let power_val_val = x.clone().mod_power_of_2_pow(exp.clone(), pow);\n        let power_val_ref = x.clone().mod_power_of_2_pow(&exp, pow);\n        let power_ref_val = (&x).mod_power_of_2_pow(exp.clone(), pow);\n        let power = (&x).mod_power_of_2_pow(&exp, pow);\n        assert!(power_val_val.is_valid());\n        assert!(power_val_ref.is_valid());\n        assert!(power_ref_val.is_valid());\n        assert!(power.is_valid());\n        assert!(power.mod_power_of_2_is_reduced(pow));\n        assert_eq!(power_val_val, power);\n        assert_eq!(power_val_ref, power);\n        assert_eq!(power_ref_val, power);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_pow_assign(exp.clone(), pow);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, power);\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_pow_assign(&exp, pow);\n        assert_eq!(mut_x, power);\n        assert!(mut_x.is_valid());\n\n        if exp.even() {\n            assert_eq!(\n                x.mod_power_of_2_neg(pow).mod_power_of_2_pow(exp, pow),\n                power\n            );\n        } else {\n            assert_eq!(\n                x.mod_power_of_2_neg(pow).mod_power_of_2_pow(exp, pow),\n                power.mod_power_of_2_neg(pow)\n            );\n        }\n    });\n\n    natural_unsigned_pair_gen().test_properties(|(exp, pow)| {\n        assert_eq!(\n            Natural::ZERO.mod_power_of_2_pow(&exp, pow),\n            Natural::from(exp == 0 && pow != 0),\n        );\n        if pow != 0 {\n            assert_eq!(Natural::ONE.mod_power_of_2_pow(exp, pow), 1);\n        }\n    });\n\n    natural_unsigned_pair_gen_var_11().test_properties(|(x, pow)| {\n        assert_eq!(\n            (&x).mod_power_of_2_pow(Natural::ZERO, pow),\n            Natural::from(pow != 0)\n        );\n        assert_eq!((&x).mod_power_of_2_pow(Natural::ONE, pow), x);\n        assert_eq!(\n            (&x).mod_power_of_2_pow(Natural::TWO, pow),\n            (&x).mod_power_of_2_mul(&x, pow)\n        );\n    });\n\n    natural_natural_natural_unsigned_quadruple_gen_var_3().test_properties(|(x, y, exp, pow)| {\n        assert_eq!(\n            (&x).mod_power_of_2_mul(&y, pow)\n                .mod_power_of_2_pow(&exp, pow),\n            x.mod_power_of_2_pow(&exp, pow)\n                .mod_power_of_2_mul(y.mod_power_of_2_pow(exp, pow), pow)\n        );\n    });\n\n    natural_natural_natural_unsigned_quadruple_gen_var_4().test_properties(|(x, e, f, pow)| {\n        assert_eq!(\n            (&x).mod_power_of_2_pow(&e + &f, pow),\n            (&x).mod_power_of_2_pow(&e, pow)\n                .mod_power_of_2_mul((&x).mod_power_of_2_pow(&f, pow), pow)\n        );\n        assert_eq!(\n            (&x).mod_power_of_2_pow(&e * &f, pow),\n            x.mod_power_of_2_pow(e, pow).mod_power_of_2_pow(f, pow)\n        );\n    });\n\n    unsigned_triple_gen_var_16::<Limb, u64>().test_properties(|(x, exp, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_pow(exp, pow),\n            Natural::from(x).mod_power_of_2_pow(Natural::from(exp), pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    IsPowerOf2, ModPowerOf2, ModPowerOf2IsReduced, ModPowerOf2Neg, ModPowerOf2Shl,\n    ModPowerOf2ShlAssign, ModPowerOf2Shr,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_14, unsigned_pair_gen_var_28,\n    unsigned_signed_unsigned_triple_gen_var_1, unsigned_triple_gen_var_17,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_signed_unsigned_triple_gen_var_1, natural_unsigned_pair_gen_var_11,\n    natural_unsigned_unsigned_triple_gen_var_6,\n};\nuse std::ops::Shl;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nmacro_rules! test_mod_power_of_2_shl_unsigned {\n    ($t:ident) => {\n        let test = |s, v: $t, pow, out| {\n            let u = Natural::from_str(s).unwrap();\n\n            let mut n = u.clone();\n            assert!(n.mod_power_of_2_is_reduced(pow));\n            n.mod_power_of_2_shl_assign(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n            assert!(n.mod_power_of_2_is_reduced(pow));\n\n            let n = u.clone().mod_power_of_2_shl(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_power_of_2_shl(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            assert_eq!((u << v).mod_power_of_2(pow).to_string(), out);\n        };\n        test(\"0\", 10, 0, \"0\");\n        test(\"0\", 10, 8, \"0\");\n        test(\"123\", 5, 8, \"96\");\n        test(\"123\", 100, 80, \"0\");\n    };\n}\n\nmacro_rules! test_mod_power_of_2_shl_signed {\n    ($t:ident) => {\n        let test = |s, v: $t, pow, out| {\n            let u = Natural::from_str(s).unwrap();\n\n            let mut n = u.clone();\n            assert!(n.mod_power_of_2_is_reduced(pow));\n            n.mod_power_of_2_shl_assign(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n            assert!(n.mod_power_of_2_is_reduced(pow));\n\n            let n = u.clone().mod_power_of_2_shl(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_power_of_2_shl(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            assert_eq!((u << v).mod_power_of_2(pow).to_string(), out);\n        };\n        test(\"0\", 10, 0, \"0\");\n        test(\"0\", 10, 8, \"0\");\n        test(\"123\", 5, 8, \"96\");\n        test(\"123\", 100, 80, \"0\");\n        test(\"123\", -2, 8, \"30\");\n        test(\"123\", -10, 8, \"0\");\n    };\n}\n\n#[test]\nfn test_mod_power_of_2_shl() {\n    apply_to_unsigneds!(test_mod_power_of_2_shl_unsigned);\n    apply_to_signeds!(test_mod_power_of_2_shl_signed);\n}\n\nfn mod_power_of_2_shl_fail_helper<T: PrimitiveInt>()\nwhere\n    Natural: ModPowerOf2Shl<T, Output = Natural> + ModPowerOf2ShlAssign<T>,\n    for<'a> &'a Natural: ModPowerOf2Shl<T, Output = Natural>,\n{\n    assert_panic!(Natural::ONE.mod_power_of_2_shl(T::exact_from(3u8), 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_shl(T::exact_from(3u8), 0));\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_shl_assign(T::exact_from(3u8), 0);\n    });\n}\n\n#[test]\nfn mod_power_of_2_shl_fail() {\n    apply_fn_to_primitive_ints!(mod_power_of_2_shl_fail_helper);\n}\n\nfn unsigned_properties<T: PrimitiveUnsigned>()\nwhere\n    Natural: ModPowerOf2Shl<T, Output = Natural> + ModPowerOf2ShlAssign<T>,\n    for<'a> &'a Natural: ModPowerOf2Shl<T, Output = Natural> + Shl<T, Output = Natural>,\n    Limb: ModPowerOf2Shl<T, Output = Limb>,\n{\n    natural_unsigned_unsigned_triple_gen_var_6::<T>().test_properties(|(n, u, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let mut mut_n = n.clone();\n        mut_n.mod_power_of_2_shl_assign(u, pow);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n        assert!(shifted.mod_power_of_2_is_reduced(pow));\n\n        let shifted_alt = (&n).mod_power_of_2_shl(u, pow);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_power_of_2_shl(u, pow);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!((&n << u).mod_power_of_2(pow), shifted);\n        assert_eq!(\n            (&n).mod_power_of_2_neg(pow).mod_power_of_2_shl(u, pow),\n            n.mod_power_of_2_shl(u, pow).mod_power_of_2_neg(pow)\n        );\n    });\n\n    natural_unsigned_pair_gen_var_11().test_properties(|(n, pow)| {\n        assert_eq!((&n).mod_power_of_2_shl(T::ZERO, pow), n);\n    });\n\n    unsigned_pair_gen_var_28::<T, u64>().test_properties(|(u, pow)| {\n        assert_eq!(Natural::ZERO.mod_power_of_2_shl(u, pow), 0);\n        if pow != 0 {\n            let shifted = Natural::ONE.mod_power_of_2_shl(u, pow);\n            assert!(shifted == 0 || shifted.is_power_of_2());\n        }\n    });\n\n    unsigned_triple_gen_var_17::<Limb, T>().test_properties(|(n, u, pow)| {\n        assert_eq!(\n            Natural::from(n).mod_power_of_2_shl(u, pow),\n            n.mod_power_of_2_shl(u, pow)\n        );\n    });\n}\n\nfn signed_properties<T: PrimitiveSigned>()\nwhere\n    Natural: ModPowerOf2Shl<T, Output = Natural>\n        + ModPowerOf2Shr<T, Output = Natural>\n        + ModPowerOf2ShlAssign<T>,\n    for<'a> &'a Natural: ModPowerOf2Shl<T, Output = Natural>\n        + ModPowerOf2Shr<T, Output = Natural>\n        + Shl<T, Output = Natural>,\n    Limb: ModPowerOf2Shl<T, Output = Limb>,\n{\n    natural_signed_unsigned_triple_gen_var_1::<T>().test_properties(|(n, i, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let mut mut_n = n.clone();\n        mut_n.mod_power_of_2_shl_assign(i, pow);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n        assert!(shifted.mod_power_of_2_is_reduced(pow));\n\n        let shifted_alt = (&n).mod_power_of_2_shl(i, pow);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_power_of_2_shl(i, pow);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!((&n << i).mod_power_of_2(pow), shifted);\n\n        if i != T::MIN {\n            assert_eq!(n.mod_power_of_2_shr(-i, pow), shifted);\n        }\n    });\n\n    natural_unsigned_pair_gen_var_11().test_properties(|(n, pow)| {\n        assert_eq!((&n).mod_power_of_2_shl(T::ZERO, pow), n);\n    });\n\n    signed_unsigned_pair_gen_var_14::<T, u64>().test_properties(|(i, pow)| {\n        assert_eq!(Natural::ZERO.mod_power_of_2_shl(i, pow), 0);\n        if pow != 0 {\n            let shifted = Natural::ONE.mod_power_of_2_shl(i, pow);\n            assert!(shifted == 0 || shifted.is_power_of_2());\n        }\n    });\n\n    unsigned_signed_unsigned_triple_gen_var_1::<Limb, T>().test_properties(|(n, i, pow)| {\n        assert_eq!(\n            Natural::from(n).mod_power_of_2_shl(i, pow),\n            n.mod_power_of_2_shl(i, pow)\n        );\n    });\n}\n\n#[test]\nfn mod_power_of_2_shl_properties() {\n    apply_fn_to_unsigneds!(unsigned_properties);\n    apply_fn_to_signeds!(signed_properties);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    IsPowerOf2, ModPowerOf2, ModPowerOf2IsReduced, ModPowerOf2Shl, ModPowerOf2Shr,\n    ModPowerOf2ShrAssign,\n};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::{\n    signed_unsigned_pair_gen_var_14, unsigned_signed_unsigned_triple_gen_var_1,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_signed_unsigned_triple_gen_var_1, natural_unsigned_pair_gen_var_11,\n};\nuse std::ops::Shr;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nmacro_rules! test_mod_power_of_2_shr {\n    ($t:ident) => {\n        let test = |s, v: $t, pow, out| {\n            let u = Natural::from_str(s).unwrap();\n\n            let mut n = u.clone();\n            assert!(n.mod_power_of_2_is_reduced(pow));\n            n.mod_power_of_2_shr_assign(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n            assert!(n.mod_power_of_2_is_reduced(pow));\n\n            let n = u.clone().mod_power_of_2_shr(v, pow);\n            assert!(n.is_valid());\n\n            let n = (&u).mod_power_of_2_shr(v, pow);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            assert_eq!((u >> v).mod_power_of_2(pow).to_string(), out);\n        };\n        test(\"0\", -10, 0, \"0\");\n        test(\"0\", -10, 8, \"0\");\n        test(\"123\", -5, 8, \"96\");\n        test(\"123\", -100, 80, \"0\");\n        test(\"123\", 2, 8, \"30\");\n        test(\"123\", 10, 8, \"0\");\n    };\n}\n\n#[test]\nfn test_mod_power_of_2_shr() {\n    apply_to_signeds!(test_mod_power_of_2_shr);\n}\n\nfn mod_power_of_2_shr_fail_helper<T: PrimitiveSigned>()\nwhere\n    Natural: ModPowerOf2Shr<T, Output = Natural> + ModPowerOf2ShrAssign<T>,\n    for<'a> &'a Natural: ModPowerOf2Shr<T, Output = Natural>,\n{\n    assert_panic!(Natural::ONE.mod_power_of_2_shr(T::exact_from(3u8), 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_shr(T::exact_from(3u8), 0));\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_shr_assign(T::exact_from(3u8), 0);\n    });\n}\n\n#[test]\nfn mod_power_of_2_shr_fail() {\n    apply_fn_to_signeds!(mod_power_of_2_shr_fail_helper);\n}\n\nfn properties_helper<T: PrimitiveSigned>()\nwhere\n    Natural: ModPowerOf2Shr<T, Output = Natural>\n        + ModPowerOf2Shl<T, Output = Natural>\n        + ModPowerOf2ShrAssign<T>,\n    for<'a> &'a Natural: ModPowerOf2Shr<T, Output = Natural>\n        + ModPowerOf2Shl<T, Output = Natural>\n        + Shr<T, Output = Natural>,\n    Limb: ModPowerOf2Shr<T, Output = Limb>,\n{\n    natural_signed_unsigned_triple_gen_var_1::<T>().test_properties(|(n, i, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let mut mut_n = n.clone();\n        mut_n.mod_power_of_2_shr_assign(i, pow);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n        assert!(shifted.mod_power_of_2_is_reduced(pow));\n\n        let shifted_alt = (&n).mod_power_of_2_shr(i, pow);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_power_of_2_shr(i, pow);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!((&n >> i).mod_power_of_2(pow), shifted);\n\n        if i != T::MIN {\n            assert_eq!(n.mod_power_of_2_shl(-i, pow), shifted);\n        }\n    });\n\n    natural_unsigned_pair_gen_var_11().test_properties(|(n, pow)| {\n        assert_eq!((&n).mod_power_of_2_shr(T::ZERO, pow), n);\n    });\n\n    signed_unsigned_pair_gen_var_14::<T, u64>().test_properties(|(i, pow)| {\n        assert_eq!(Natural::ZERO.mod_power_of_2_shr(i, pow), 0);\n        if pow != 0 {\n            let shifted = Natural::ONE.mod_power_of_2_shr(i, pow);\n            assert!(shifted == 0 || shifted.is_power_of_2());\n        }\n    });\n\n    unsigned_signed_unsigned_triple_gen_var_1::<Limb, T>().test_properties(|(n, i, pow)| {\n        assert_eq!(\n            Natural::from(n).mod_power_of_2_shr(i, pow),\n            n.mod_power_of_2_shr(i, pow)\n        );\n    });\n}\n\n#[test]\nfn mod_power_of_2_shr_properties() {\n    apply_fn_to_signeds!(properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2IsReduced, ModPowerOf2Mul, ModPowerOf2Neg, ModPowerOf2Square,\n    ModPowerOf2SquareAssign, ModSquare, PowerOf2, Square,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_5, unsigned_pair_gen_var_17, unsigned_vec_pair_gen_var_1,\n    unsigned_vec_pair_gen_var_20,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_square::{\n    limbs_mod_power_of_2_square, limbs_mod_power_of_2_square_ref, limbs_square_low,\n    limbs_square_low_basecase, limbs_square_low_divide_and_conquer, limbs_square_low_scratch_len,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_unsigned_triple_gen_var_4, natural_unsigned_pair_gen_var_11,\n    unsigned_vec_pair_gen_var_21, unsigned_vec_unsigned_pair_gen_var_30,\n};\nuse malachite_nz::test_util::natural::arithmetic::mod_power_of_2_square::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_square_low_basecase() {\n    let test = |out_before: &[Limb], xs: &[Limb], out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_square_low_basecase(&mut out, xs);\n        assert_eq!(out, out_after);\n\n        let len = xs.len();\n        let x = Natural::from_limbs_asc(xs);\n        let pow = u64::exact_from(len) << Limb::LOG_WIDTH;\n        let expected_square = (&x).square().mod_power_of_2(pow);\n        assert_eq!(x.mod_power_of_2_square(pow), expected_square);\n        let square = Natural::from_limbs_asc(&out_after[..len]);\n        assert_eq!(square, expected_square);\n        assert_eq!(&out_before[len..], &out_after[len..]);\n    };\n    // - n == 1\n    test(&[10; 3], &[1], &[1, 10, 10]);\n    // - n == 2\n    test(&[10; 3], &[123, 456], &[15129, 112176, 10]);\n    // - n > 2\n    // - n.odd() in limbs_square_low_diagonal\n    test(&[10; 4], &[123, 456, 789], &[15129, 112176, 402030, 10]);\n    // - n.even() in limbs_square_low_diagonal\n    test(\n        &[10; 5],\n        &[123, 456, 789, 987],\n        &[15129, 112176, 402030, 962370, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_low_basecase_fail_1() {\n    limbs_square_low_basecase(&mut [10], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_low_basecase_fail_2() {\n    limbs_square_low_basecase(&mut [10, 10], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_square_low_divide_and_conquer() {\n    let test = |out_before: &[Limb], xs: &[Limb], out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_square_low_scratch_len(xs.len())];\n        limbs_square_low_divide_and_conquer(&mut out, xs, &mut scratch);\n        assert_eq!(out, out_after);\n\n        let len = xs.len();\n        let x = Natural::from_limbs_asc(xs);\n        let pow = u64::exact_from(len) << Limb::LOG_WIDTH;\n        let expected_square = (&x).square().mod_power_of_2(pow);\n        assert_eq!(x.mod_power_of_2_square(pow), expected_square);\n        let square = Natural::from_limbs_asc(&out_after[..len]);\n        assert_eq!(square, expected_square);\n        assert_eq!(&out_before[len..], &out_after[len..]);\n    };\n    test(&[10; 3], &[123, 456], &[15129, 112176, 10]);\n    test(&[10; 4], &[123, 456, 789], &[15129, 112176, 402030, 10]);\n    test(\n        &[10; 5],\n        &[123, 456, 789, 987],\n        &[15129, 112176, 402030, 962370, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_low_divide_and_conquer_fail_1() {\n    let mut scratch = vec![0; limbs_square_low_scratch_len(2)];\n    limbs_square_low_divide_and_conquer(&mut [10], &[10, 10], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_low_divide_and_conquer_fail_2() {\n    let mut scratch = vec![0; limbs_square_low_scratch_len(0)];\n    limbs_square_low_divide_and_conquer(&mut [10, 10], &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_low_divide_and_conquer_fail_3() {\n    let mut scratch = vec![0; limbs_square_low_scratch_len(1)];\n    limbs_square_low_divide_and_conquer(&mut [10, 10], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_square_low() {\n    let test = |out_before: &[Limb], xs: &[Limb], out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_square_low(&mut out, xs);\n        assert_eq!(out, out_after);\n\n        let len = xs.len();\n        let x = Natural::from_limbs_asc(xs);\n        let pow = u64::exact_from(len) << Limb::LOG_WIDTH;\n        let expected_square = (&x).square().mod_power_of_2(pow);\n        assert_eq!(x.mod_power_of_2_square(pow), expected_square);\n        let square = Natural::from_limbs_asc(&out_after[..len]);\n        assert_eq!(square, expected_square);\n        assert_eq!(&out_before[len..], &out_after[len..]);\n    };\n    test(&[10; 3], &[1], &[1, 10, 10]);\n    test(&[10; 3], &[123, 456], &[15129, 112176, 10]);\n    test(&[10; 4], &[123, 456, 789], &[15129, 112176, 402030, 10]);\n    test(\n        &[10; 5],\n        &[123, 456, 789, 987],\n        &[15129, 112176, 402030, 962370, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_low_fail_1() {\n    limbs_square_low(&mut [10], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_low_fail_2() {\n    limbs_square_low(&mut [10, 10], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_square() {\n    let test = |xs, pow, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2_square_ref(xs, pow), out);\n\n        let mut mut_xs = xs.to_vec();\n        assert_eq!(limbs_mod_power_of_2_square(&mut mut_xs, pow), out);\n\n        let square = Natural::from_limbs_asc(out);\n        assert_eq!(\n            Natural::from_limbs_asc(xs).mod_power_of_2_square(pow),\n            square\n        );\n        assert_eq!(\n            Natural::from_limbs_asc(xs).square().mod_power_of_2(pow),\n            square\n        );\n    };\n    test(&[1], 1, &[1]);\n    test(&[1], 1, &[1]);\n    test(&[3], 2, &[1]);\n    test(&[25], 5, &[17]);\n    test(&[123, 456], 42, &[15129, 560]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_square_fail() {\n    limbs_mod_power_of_2_square(&mut vec![], 2);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_square_ref_fail() {\n    limbs_mod_power_of_2_square_ref(&[], 2);\n}\n\n#[test]\nfn test_mod_power_of_2_square() {\n    let test = |s, pow, out| {\n        let u = Natural::from_str(s).unwrap();\n\n        assert!(u.mod_power_of_2_is_reduced(pow));\n        let n = u.clone().mod_power_of_2_square(pow);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n        assert!(n.mod_power_of_2_is_reduced(pow));\n\n        let n = (&u).mod_power_of_2_square(pow);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u;\n        n.mod_power_of_2_square_assign(pow);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"0\");\n    test(\"2\", 3, \"4\");\n    test(\"5\", 3, \"1\");\n    test(\"100\", 8, \"16\");\n    test(\"12345678987654321\", 64, \"16556040056090124897\");\n}\n\n#[test]\nfn mod_power_of_2_square_fail() {\n    assert_panic!(Natural::ONE.mod_power_of_2_square(0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_square(0));\n\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_square_assign(0);\n    });\n}\n\nfn verify_limbs_square_low(out_before: &[Limb], xs: &[Limb], out_after: &[Limb]) {\n    let len = xs.len();\n    let x = Natural::from_limbs_asc(xs);\n    let pow = u64::exact_from(len) << Limb::LOG_WIDTH;\n    let expected_square = (&x).square().mod_power_of_2(pow);\n    assert_eq!(x.mod_power_of_2_square(pow), expected_square);\n    let square = Natural::from_limbs_asc(&out_after[..len]);\n    assert_eq!(square, expected_square);\n    assert_eq!(&out_before[len..], &out_after[len..]);\n}\n\n#[test]\nfn limbs_square_low_basecase_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_21().test_properties_with_config(&config, |(mut out, xs)| {\n        let out_old = out.clone();\n        limbs_square_low_basecase(&mut out, &xs);\n        verify_limbs_square_low(&out_old, &xs, &out);\n        let expected_out = out;\n\n        let mut out = out_old;\n        limbs_square_low_basecase_unrestricted(&mut out, &xs);\n        assert_eq!(out, expected_out);\n    });\n}\n\n#[test]\nfn limbs_square_low_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_20().test_properties_with_config(&config, |(mut out, xs)| {\n        let out_old = out.clone();\n        let mut scratch = vec![0; limbs_square_low_scratch_len(xs.len())];\n        limbs_square_low_divide_and_conquer(&mut out, &xs, &mut scratch);\n        verify_limbs_square_low(&out_old, &xs, &out);\n    });\n}\n\n#[test]\nfn limbs_square_low_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_1().test_properties_with_config(&config, |(mut out, xs)| {\n        let out_old = out.clone();\n        limbs_square_low(&mut out, &xs);\n        verify_limbs_square_low(&out_old, &xs, &out);\n    });\n}\n\n#[test]\nfn limbs_mod_power_of_2_square_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_30().test_properties_with_config(\n        &config,\n        |(mut xs, pow)| {\n            let xs_old = xs.clone();\n            let out = limbs_mod_power_of_2_square(&mut xs, pow);\n            assert_eq!(limbs_mod_power_of_2_square_ref(&xs_old, pow), out);\n            let expected_square = Natural::from_owned_limbs_asc(xs_old).mod_power_of_2_square(pow);\n            assert_eq!(Natural::from_owned_limbs_asc(out), expected_square);\n        },\n    );\n}\n\n#[test]\nfn mod_power_of_2_square_properties() {\n    natural_unsigned_pair_gen_var_11().test_properties(|(n, pow)| {\n        assert!(n.mod_power_of_2_is_reduced(pow));\n        let square = (&n).mod_power_of_2_square(pow);\n        assert!(square.is_valid());\n        assert!(square.mod_power_of_2_is_reduced(pow));\n\n        let square_alt = n.clone().mod_power_of_2_square(pow);\n        assert!(square_alt.is_valid());\n        assert_eq!(square_alt, square);\n\n        let mut n_alt = n.clone();\n        n_alt.mod_power_of_2_square_assign(pow);\n        assert!(square_alt.is_valid());\n        assert_eq!(square_alt, square);\n\n        assert_eq!(square, (&n).square().mod_power_of_2(pow));\n        assert_eq!(square, (&n).mod_square(Natural::power_of_2(pow)));\n        assert_eq!(n.mod_power_of_2_neg(pow).mod_power_of_2_square(pow), square);\n    });\n\n    unsigned_gen_var_5().test_properties(|pow| {\n        assert_eq!(Natural::ZERO.mod_power_of_2_square(pow), 0);\n        if pow != 0 {\n            assert_eq!(Natural::ONE.mod_power_of_2_square(pow), 1);\n        }\n    });\n\n    natural_natural_unsigned_triple_gen_var_4().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            (&x).mod_power_of_2_mul(&y, pow).mod_power_of_2_square(pow),\n            x.mod_power_of_2_square(pow)\n                .mod_power_of_2_mul(y.mod_power_of_2_square(pow), pow)\n        );\n    });\n\n    unsigned_pair_gen_var_17::<Limb>().test_properties(|(n, pow)| {\n        assert_eq!(\n            n.mod_power_of_2_square(pow),\n            Natural::from(n).mod_power_of_2_square(pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_power_of_2_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModPowerOf2, ModPowerOf2Add, ModPowerOf2IsReduced, ModPowerOf2Neg, ModPowerOf2Sub,\n    ModPowerOf2SubAssign, ModSub, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_11;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mod_power_of_2_sub::{\n    limbs_mod_power_of_2_limb_sub_limbs, limbs_mod_power_of_2_limb_sub_limbs_in_place,\n    limbs_mod_power_of_2_sub, limbs_mod_power_of_2_sub_in_place_either,\n    limbs_mod_power_of_2_sub_in_place_left, limbs_mod_power_of_2_sub_in_place_right,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_unsigned_triple_gen_var_4, natural_unsigned_pair_gen_var_11,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_16,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_limb_sub_limbs_and_limbs_mod_power_of_2_limb_sub_limbs_in_place() {\n    let test = |x: Limb, ys: &[Limb], pow: u64, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2_limb_sub_limbs(x, ys, pow), out);\n\n        let mut ys = ys.to_vec();\n        limbs_mod_power_of_2_limb_sub_limbs_in_place(x, &mut ys, pow);\n        assert_eq!(ys, out);\n    };\n    test(3, &[2], 4, &[1]);\n    test(3, &[10], 4, &[9]);\n    test(3, &[1, 2, 3], 70, &[2, u32::MAX - 1, 60]);\n    test(\n        3,\n        &[1, 2, 3],\n        200,\n        &[2, u32::MAX - 1, 0xfffffffc, u32::MAX, u32::MAX, u32::MAX, 255],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_limb_sub_limbs_fail() {\n    limbs_mod_power_of_2_limb_sub_limbs(3, &[10], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mod_power_of_2_limb_sub_limbs_in_place_fail() {\n    let mut ys = vec![10];\n    limbs_mod_power_of_2_limb_sub_limbs_in_place(3, &mut ys, 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_sub() {\n    let test = |xs_before, ys, pow, out: &[Limb]| {\n        assert_eq!(limbs_mod_power_of_2_sub(xs_before, ys, pow), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_mod_power_of_2_sub_in_place_left(&mut xs, ys, pow);\n        assert_eq!(xs, out);\n    };\n    test(&[], &[], 0, &[]);\n    test(&[], &[], 5, &[]);\n    test(&[2], &[], 3, &[2]);\n    test(&[], &[2], 3, &[6]);\n    test(&[2], &[3], 2, &[3]);\n    test(&[1, 2, 3], &[6, 7], 100, &[0xfffffffb, 0xfffffffa, 2]);\n    test(&[6, 7], &[1, 2, 3], 100, &[5, 5, 0xfffffffd, 15]);\n    test(&[6, 7], &[1, 2], 100, &[5, 5]);\n    test(\n        &[1, 2],\n        &[6, 7],\n        100,\n        &[0xfffffffb, 0xfffffffa, u32::MAX, 15],\n    );\n    test(&[6, 7], &[2, 3, 0], 100, &[4, 4, 0]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_sub_in_place_right() {\n    let test = |xs, ys_before: &[Limb], pow, out: &[Limb]| {\n        let mut ys = ys_before.to_vec();\n        limbs_mod_power_of_2_sub_in_place_right(xs, &mut ys, pow);\n        assert_eq!(ys, out);\n    };\n    test(&[], &[], 0, &[]);\n    test(&[], &[], 5, &[]);\n    test(&[2], &[], 3, &[2]);\n    test(&[], &[2], 3, &[6]);\n    test(&[2], &[3], 2, &[3]);\n    test(&[1, 2, 3], &[6, 7], 100, &[0xfffffffb, 0xfffffffa, 2]);\n    test(&[6, 7], &[1, 2, 3], 100, &[5, 5, 0xfffffffd, 15]);\n    test(&[6, 7], &[1, 2], 100, &[5, 5]);\n    test(\n        &[1, 2],\n        &[6, 7],\n        100,\n        &[0xfffffffb, 0xfffffffa, u32::MAX, 15],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mod_power_of_2_sub_in_place_either() {\n    let test = |xs_before: &[Limb],\n                ys_before: &[Limb],\n                pow,\n                right,\n                xs_after: &[Limb],\n                ys_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_mod_power_of_2_sub_in_place_either(&mut xs, &mut ys, pow),\n            right\n        );\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], 0, false, &[], &[]);\n    test(&[], &[], 5, false, &[], &[]);\n    test(&[2], &[], 3, false, &[2], &[]);\n    test(&[], &[2], 3, true, &[], &[6]);\n    test(&[2], &[3], 2, false, &[3], &[3]);\n    test(\n        &[1, 2, 3],\n        &[6, 7],\n        100,\n        false,\n        &[0xfffffffb, 0xfffffffa, 2],\n        &[6, 7],\n    );\n    test(\n        &[6, 7],\n        &[1, 2, 3],\n        100,\n        true,\n        &[6, 7],\n        &[5, 5, 0xfffffffd, 15],\n    );\n    test(&[6, 7], &[1, 2], 100, false, &[5, 5], &[1, 2]);\n    test(\n        &[1, 2],\n        &[6, 7],\n        100,\n        false,\n        &[0xfffffffb, 0xfffffffa, u32::MAX, 15],\n        &[6, 7],\n    );\n}\n\n#[test]\nfn test_mod_power_of_2_sub() {\n    let test = |s, t, pow, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_power_of_2_is_reduced(pow));\n        assert!(v.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_sub_assign(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_power_of_2_is_reduced(pow));\n\n        let mut n = u.clone();\n        n.mod_power_of_2_sub_assign(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_sub(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_sub(v.clone(), pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_power_of_2_sub(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_power_of_2_sub(&v, pow);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", 0, \"0\");\n    test(\"0\", \"0\", 5, \"0\");\n    test(\"0\", \"27\", 5, \"5\");\n    test(\"10\", \"2\", 4, \"8\");\n    test(\"2\", \"10\", 4, \"8\");\n    test(\"0\", \"5\", 7, \"123\");\n    test(\"123\", \"0\", 7, \"123\");\n    test(\"123\", \"56\", 9, \"67\");\n    test(\"56\", \"123\", 9, \"445\");\n    test(\"3\", \"1267650600228229401496703205375\", 100, \"4\");\n    test(\n        \"10970645355953595821\",\n        \"19870830162202579837\",\n        65,\n        \"27993303341170119216\",\n    );\n    test(\n        \"14424295573283161220\",\n        \"2247489031103704789\",\n        66,\n        \"12176806542179456431\",\n    );\n    test(\n        \"2247489031103704789\",\n        \"14424295573283161220\",\n        66,\n        \"61610169752658750033\",\n    );\n    test(\n        \"340279770772528537691305857201098194975\",\n        \"5708990430541473157891818604560539975629668416\",\n        165,\n        \"46762343404498631680132551366007801946215309901791\",\n    );\n}\n\n#[test]\nfn mod_power_of_2_sub_fail() {\n    assert_panic!(Natural::ZERO.mod_power_of_2_sub(Natural::ONE, 0));\n    assert_panic!(Natural::ONE.mod_power_of_2_sub(Natural::ZERO, 0));\n\n    assert_panic!(Natural::ZERO.mod_power_of_2_sub(&Natural::ONE, 0));\n    assert_panic!(Natural::ONE.mod_power_of_2_sub(&Natural::ZERO, 0));\n\n    assert_panic!((&Natural::ZERO).mod_power_of_2_sub(Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_sub(Natural::ZERO, 0));\n\n    assert_panic!((&Natural::ZERO).mod_power_of_2_sub(Natural::ONE, 0));\n    assert_panic!((&Natural::ONE).mod_power_of_2_sub(Natural::ZERO, 0));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_power_of_2_sub_assign(Natural::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_sub_assign(Natural::ZERO, 0);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_power_of_2_sub_assign(&Natural::ONE, 0);\n    });\n    assert_panic!({\n        let mut x = Natural::ONE;\n        x.mod_power_of_2_sub_assign(&Natural::ZERO, 0);\n    });\n}\n\n#[test]\nfn limbs_mod_power_of_2_limb_sub_limbs_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_16().test_properties_with_config(\n        &config,\n        |(ys, x, pow)| {\n            assert_eq!(\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_limb_sub_limbs(x, &ys, pow)),\n                Natural::from(x).mod_power_of_2_sub(Natural::from_owned_limbs_asc(ys), pow),\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_limb_sub_limbs_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut ys, x, pow)| {\n            let old_ys = ys.clone();\n            limbs_mod_power_of_2_limb_sub_limbs_in_place(x, &mut ys, pow);\n            let n = Natural::from(x).mod_power_of_2_sub(Natural::from_owned_limbs_asc(old_ys), pow);\n            let mut expected_limbs = n.into_limbs_asc();\n            expected_limbs.resize(ys.len(), 0);\n            assert_eq!(ys, expected_limbs);\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_sub_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().test_properties_with_config(\n        &config,\n        |(xs, ys, pow)| {\n            assert_eq!(\n                Natural::from_owned_limbs_asc(limbs_mod_power_of_2_sub(&xs, &ys, pow)),\n                Natural::from_owned_limbs_asc(xs)\n                    .mod_power_of_2_sub(Natural::from_owned_limbs_asc(ys), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_sub_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_18().test_properties_with_config(\n        &config,\n        |(mut xs, ys, pow)| {\n            let xs_old = xs.clone();\n            limbs_mod_power_of_2_sub_in_place_left(&mut xs, &ys, pow);\n            assert_eq!(\n                Natural::from_owned_limbs_asc(xs),\n                Natural::from_owned_limbs_asc(xs_old)\n                    .mod_power_of_2_sub(Natural::from_owned_limbs_asc(ys), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_sub_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20().test_properties_with_config(\n        &config,\n        |(xs, mut ys, pow)| {\n            let ys_old = ys.clone();\n            limbs_mod_power_of_2_sub_in_place_right(&xs, &mut ys, pow);\n            assert_eq!(\n                Natural::from_owned_limbs_asc(ys),\n                Natural::from_owned_limbs_asc(xs)\n                    .mod_power_of_2_sub(Natural::from_owned_limbs_asc(ys_old), pow)\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_mod_power_of_2_sub_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_20().test_properties_with_config(\n        &config,\n        |(mut xs, mut ys, pow)| {\n            let xs_old = xs.clone();\n            let ys_old = ys.clone();\n            let right = limbs_mod_power_of_2_sub_in_place_either(&mut xs, &mut ys, pow);\n            let n = Natural::from_limbs_asc(&xs_old)\n                .mod_power_of_2_sub(Natural::from_limbs_asc(&ys_old), pow);\n            if right {\n                assert_eq!(xs, xs_old);\n                assert_eq!(Natural::from_owned_limbs_asc(ys), n);\n            } else {\n                assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n                assert_eq!(ys, ys_old);\n            }\n        },\n    );\n}\n\n#[test]\nfn mod_power_of_2_sub_properties() {\n    natural_natural_unsigned_triple_gen_var_4().test_properties(|(x, y, pow)| {\n        assert!(x.mod_power_of_2_is_reduced(pow));\n        assert!(y.mod_power_of_2_is_reduced(pow));\n        let diff_val_val = x.clone().mod_power_of_2_sub(y.clone(), pow);\n        let diff_val_ref = x.clone().mod_power_of_2_sub(&y, pow);\n        let diff_ref_val = (&x).mod_power_of_2_sub(y.clone(), pow);\n        let diff = (&x).mod_power_of_2_sub(&y, pow);\n        assert!(diff_val_val.is_valid());\n        assert!(diff_val_ref.is_valid());\n        assert!(diff_ref_val.is_valid());\n        assert!(diff.is_valid());\n        assert!(diff.mod_power_of_2_is_reduced(pow));\n        assert_eq!(diff_val_val, diff);\n        assert_eq!(diff_val_ref, diff);\n        assert_eq!(diff_ref_val, diff);\n\n        assert_eq!(\n            (Integer::from(&x) - Integer::from(&y)).mod_power_of_2(pow),\n            diff\n        );\n        let diff_alt = if x >= y {\n            &x - &y\n        } else {\n            let mut x = x.clone();\n            x.set_bit(pow);\n            &x - &y\n        };\n        assert_eq!(diff_alt, diff);\n        assert_eq!((&x).mod_sub(&y, Natural::power_of_2(pow)), diff);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_sub_assign(y.clone(), pow);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n        let mut mut_x = x.clone();\n        mut_x.mod_power_of_2_sub_assign(&y, pow);\n        assert_eq!(mut_x, diff);\n        assert!(mut_x.is_valid());\n\n        assert_eq!(\n            (&y).mod_power_of_2_sub(&x, pow),\n            (&diff).mod_power_of_2_neg(pow),\n        );\n        assert_eq!(\n            (&x).mod_power_of_2_add((&y).mod_power_of_2_neg(pow), pow),\n            diff\n        );\n        assert_eq!((&diff).mod_power_of_2_add(&y, pow), x);\n        assert_eq!(diff.mod_power_of_2_sub(x, pow), y.mod_power_of_2_neg(pow));\n    });\n\n    natural_unsigned_pair_gen_var_11().test_properties(|(x, pow)| {\n        assert_eq!((&x).mod_power_of_2_sub(Natural::ZERO, pow), x);\n        assert_eq!(\n            Natural::ZERO.mod_power_of_2_sub(&x, pow),\n            (&x).mod_power_of_2_neg(pow)\n        );\n        assert_eq!((&x).mod_power_of_2_sub(&x, pow), 0);\n    });\n\n    unsigned_triple_gen_var_11::<Limb>().test_properties(|(x, y, pow)| {\n        assert_eq!(\n            x.mod_power_of_2_sub(y, pow),\n            Natural::from(x).mod_power_of_2_sub(Natural::from(y), pow)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModIsReduced, ModNeg, ModShl, ModShlAssign, ModShr};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::test_util::generators::{\n    signed_gen_var_5, unsigned_gen_var_5, unsigned_signed_unsigned_triple_gen_var_2,\n    unsigned_triple_gen_var_18,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_signed_triple_gen_var_1, natural_natural_unsigned_triple_gen_var_6,\n    natural_pair_gen_var_8, natural_signed_pair_gen_var_3, natural_unsigned_pair_gen_var_12,\n};\nuse std::ops::Shl;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nmacro_rules! test_mod_shl_unsigned {\n    ($t:ident) => {\n        let test = |s, v: $t, t, out| {\n            let u = Natural::from_str(s).unwrap();\n            let m = Natural::from_str(t).unwrap();\n\n            let mut n = u.clone();\n            assert!(n.mod_is_reduced(&m));\n            n.mod_shl_assign(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n            assert!(n.mod_is_reduced(&m));\n\n            let mut n = u.clone();\n            n.mod_shl_assign(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = u.clone().mod_shl(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = u.clone().mod_shl(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_shl(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_shl(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            assert_eq!(((u << v) % m).to_string(), out);\n        };\n        test(\"0\", 0, \"1\", \"0\");\n        test(\"0\", 0, \"5\", \"0\");\n        test(\"8\", 2, \"10\", \"2\");\n        test(\"10\", 100, \"17\", \"7\");\n        test(\"123456\", 100, \"12345678987654321\", \"7436663564915145\");\n    };\n}\n\nmacro_rules! test_mod_shl_signed {\n    ($t:ident) => {\n        let test = |s, v: $t, t, out| {\n            let u = Natural::from_str(s).unwrap();\n            let m = Natural::from_str(t).unwrap();\n\n            let mut n = u.clone();\n            assert!(n.mod_is_reduced(&m));\n            n.mod_shl_assign(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n            assert!(n.mod_is_reduced(&m));\n\n            let mut n = u.clone();\n            n.mod_shl_assign(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = u.clone().mod_shl(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = u.clone().mod_shl(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_shl(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_shl(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            assert_eq!(((u << v) % m).to_string(), out);\n        };\n        test(\"0\", 0, \"1\", \"0\");\n        test(\"0\", 0, \"5\", \"0\");\n        test(\"8\", 2, \"10\", \"2\");\n        test(\"10\", 100, \"17\", \"7\");\n        test(\"10\", -100, \"19\", \"0\");\n        test(\"123456\", 100, \"12345678987654321\", \"7436663564915145\");\n    };\n}\n\n#[test]\nfn test_mod_shl() {\n    apply_to_unsigneds!(test_mod_shl_unsigned);\n    apply_to_signeds!(test_mod_shl_signed);\n}\n\nfn mod_shl_fail_helper<T: PrimitiveInt>()\nwhere\n    for<'a> Natural: ModShlAssign<T, Natural>\n        + ModShlAssign<T, &'a Natural>\n        + ModShl<T, Natural, Output = Natural>\n        + ModShl<T, &'a Natural, Output = Natural>,\n    for<'a, 'b> &'a Natural:\n        ModShl<T, Natural, Output = Natural> + ModShl<T, &'b Natural, Output = Natural>,\n{\n    assert_panic!(Natural::ZERO.mod_shl(T::exact_from(3u8), Natural::ZERO));\n    assert_panic!(Natural::exact_from(30).mod_shl(T::exact_from(3u8), Natural::ONE));\n\n    assert_panic!(Natural::ZERO.mod_shl(T::exact_from(3u8), &Natural::ZERO));\n    assert_panic!(Natural::exact_from(30).mod_shl(T::exact_from(3u8), &Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_shl(T::exact_from(3u8), Natural::ZERO));\n    assert_panic!((&Natural::exact_from(30)).mod_shl(T::exact_from(3u8), Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_shl(T::exact_from(3u8), &Natural::ZERO));\n    assert_panic!((&Natural::exact_from(30)).mod_shl(T::exact_from(3u8), &Natural::ONE));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_shl_assign(T::exact_from(3u8), Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::exact_from(30);\n        x.mod_shl_assign(T::exact_from(3u8), Natural::ONE);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_shl_assign(T::exact_from(3u8), &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::exact_from(30);\n        x.mod_shl_assign(T::exact_from(3u8), &Natural::ONE);\n    });\n}\n\n#[test]\nfn mod_shl_fail() {\n    apply_fn_to_primitive_ints!(mod_shl_fail_helper);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn unsigned_properties<T: PrimitiveUnsigned>()\nwhere\n    for<'a> Natural: ModShlAssign<T>\n        + ModShlAssign<T, &'a Natural>\n        + ModShl<T, Output = Natural>\n        + ModShl<T, &'a Natural, Output = Natural>,\n    for<'a, 'b> &'a Natural: ModShl<T, Natural, Output = Natural>\n        + ModShl<T, &'b Natural, Output = Natural>\n        + Shl<T, Output = Natural>,\n    Limb: ModShl<T, Output = Limb>,\n{\n    natural_natural_unsigned_triple_gen_var_6::<T>().test_properties(|(n, m, u)| {\n        assert!(n.mod_is_reduced(&m));\n        let mut mut_n = n.clone();\n        mut_n.mod_shl_assign(u, &m);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n        assert!(shifted.mod_is_reduced(&m));\n\n        let mut mut_n = n.clone();\n        mut_n.mod_shl_assign(u, m.clone());\n        let shifted_alt = mut_n;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        let shifted_alt = (&n).mod_shl(u, &m);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = (&n).mod_shl(u, m.clone());\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_shl(u, &m);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_shl(u, m.clone());\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!((&n << u) % &m, shifted);\n        assert_eq!(\n            (&n).mod_neg(&m).mod_shl(u, &m),\n            n.mod_shl(u, &m).mod_neg(&m)\n        );\n    });\n\n    natural_pair_gen_var_8().test_properties(|(n, m)| {\n        assert_eq!((&n).mod_shl(T::ZERO, m), n);\n    });\n\n    natural_unsigned_pair_gen_var_12::<T>().test_properties(|(m, u)| {\n        assert_eq!(Natural::ZERO.mod_shl(u, m), 0);\n    });\n\n    unsigned_gen_var_5::<T>().test_properties(|u| {\n        assert_eq!(Natural::ZERO.mod_shl(u, Natural::ONE), 0);\n    });\n\n    unsigned_triple_gen_var_18::<Limb, T>().test_properties(|(n, u, m)| {\n        assert_eq!(\n            Natural::from(n).mod_shl(u, Natural::from(m)),\n            n.mod_shl(u, m)\n        );\n    });\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn signed_properties<U: PrimitiveUnsigned + WrappingFrom<T>, T: PrimitiveSigned + WrappingFrom<U>>()\nwhere\n    for<'a> Natural: ModShlAssign<T>\n        + ModShlAssign<T, &'a Natural>\n        + ModShl<T, Output = Natural>\n        + ModShl<T, &'a Natural, Output = Natural>\n        + ModShr<T, Output = Natural>,\n    for<'a, 'b> &'a Natural: ModShl<T, Natural, Output = Natural>\n        + ModShl<T, &'b Natural, Output = Natural>\n        + Shl<T, Output = Natural>,\n    Limb: ModShl<T, Output = Limb>,\n{\n    natural_natural_signed_triple_gen_var_1::<T>().test_properties(|(n, m, i)| {\n        assert!(n.mod_is_reduced(&m));\n        let mut mut_n = n.clone();\n        mut_n.mod_shl_assign(i, &m);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n        assert!(shifted.mod_is_reduced(&m));\n\n        let mut mut_n = n.clone();\n        mut_n.mod_shl_assign(i, m.clone());\n        let shifted_alt = mut_n;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        let shifted_alt = (&n).mod_shl(i, &m);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = (&n).mod_shl(i, m.clone());\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_shl(i, &m);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_shl(i, m.clone());\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!((&n << i) % &m, shifted);\n\n        if i != T::MIN {\n            assert_eq!(n.mod_shr(-i, m), shifted);\n        }\n    });\n\n    natural_pair_gen_var_8().test_properties(|(n, m)| {\n        assert_eq!((&n).mod_shl(T::ZERO, m), n);\n    });\n\n    natural_signed_pair_gen_var_3::<T>().test_properties(|(m, i)| {\n        assert_eq!(Natural::ZERO.mod_shl(i, m), 0);\n    });\n\n    signed_gen_var_5::<T>().test_properties(|i| {\n        assert_eq!(Natural::ZERO.mod_shl(i, Natural::ONE), 0);\n    });\n\n    unsigned_signed_unsigned_triple_gen_var_2::<Limb, U, T>().test_properties(|(n, i, m)| {\n        assert_eq!(\n            Natural::from(n).mod_shl(i, Natural::from(m)),\n            n.mod_shl(i, m)\n        );\n    });\n}\n\n#[test]\nfn mod_shl_properties() {\n    apply_fn_to_unsigneds!(unsigned_properties);\n    apply_fn_to_unsigned_signed_pairs!(signed_properties);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Mod, ModShl};\nuse malachite_base::num::arithmetic::traits::{ModIsReduced, ModShr, ModShrAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::test_util::generators::{\n    signed_gen_var_5, unsigned_signed_unsigned_triple_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_signed_triple_gen_var_1, natural_pair_gen_var_8, natural_signed_pair_gen_var_3,\n};\nuse std::ops::Shr;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nmacro_rules! test_mod_shr_signed {\n    ($t:ident) => {\n        let test = |s, v: $t, t, out| {\n            let u = Natural::from_str(s).unwrap();\n            let m = Natural::from_str(t).unwrap();\n\n            let mut n = u.clone();\n            assert!(n.mod_is_reduced(&m));\n            n.mod_shr_assign(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n            assert!(n.mod_is_reduced(&m));\n\n            let mut n = u.clone();\n            n.mod_shr_assign(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = u.clone().mod_shr(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = u.clone().mod_shr(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_shr(v, m.clone());\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            let n = (&u).mod_shr(v, &m);\n            assert!(n.is_valid());\n            assert_eq!(n.to_string(), out);\n\n            assert_eq!(((u >> v) % m).to_string(), out);\n        };\n        test(\"0\", 0, \"1\", \"0\");\n        test(\"0\", 0, \"5\", \"0\");\n        test(\"8\", -2, \"10\", \"2\");\n        test(\"10\", -100, \"17\", \"7\");\n        test(\"10\", 100, \"19\", \"0\");\n        test(\"123456\", -100, \"12345678987654321\", \"7436663564915145\");\n    };\n}\n\n#[test]\nfn test_mod_shr() {\n    apply_to_signeds!(test_mod_shr_signed);\n}\n\nfn mod_shr_fail_helper<T: PrimitiveSigned>()\nwhere\n    for<'a> Natural: ModShrAssign<T, Natural>\n        + ModShrAssign<T, &'a Natural>\n        + ModShr<T, Natural, Output = Natural>\n        + ModShr<T, &'a Natural, Output = Natural>,\n    for<'a, 'b> &'a Natural:\n        ModShr<T, Natural, Output = Natural> + ModShr<T, &'b Natural, Output = Natural>,\n{\n    assert_panic!(Natural::ZERO.mod_shr(T::exact_from(3u8), Natural::ZERO));\n    assert_panic!(Natural::exact_from(30).mod_shr(T::exact_from(3u8), Natural::ONE));\n\n    assert_panic!(Natural::ZERO.mod_shr(T::exact_from(3u8), &Natural::ZERO));\n    assert_panic!(Natural::exact_from(30).mod_shr(T::exact_from(3u8), &Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_shr(T::exact_from(3u8), Natural::ZERO));\n    assert_panic!((&Natural::exact_from(30)).mod_shr(T::exact_from(3u8), Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_shr(T::exact_from(3u8), &Natural::ZERO));\n    assert_panic!((&Natural::exact_from(30)).mod_shr(T::exact_from(3u8), &Natural::ONE));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_shr_assign(T::exact_from(3u8), Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::exact_from(30);\n        x.mod_shr_assign(T::exact_from(3u8), Natural::ONE);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_shr_assign(T::exact_from(3u8), &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::exact_from(30);\n        x.mod_shr_assign(T::exact_from(3u8), &Natural::ONE);\n    });\n}\n\n#[test]\nfn mod_shr_fail() {\n    apply_fn_to_signeds!(mod_shr_fail_helper);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn properties_helper<U: PrimitiveUnsigned + WrappingFrom<T>, T: PrimitiveSigned + WrappingFrom<U>>()\nwhere\n    for<'a> Natural: ModShrAssign<T>\n        + ModShrAssign<T, &'a Natural>\n        + ModShr<T, Output = Natural>\n        + ModShr<T, &'a Natural, Output = Natural>\n        + ModShl<T, Output = Natural>,\n    for<'a, 'b> &'a Natural: ModShr<T, Natural, Output = Natural>\n        + ModShr<T, &'b Natural, Output = Natural>\n        + Shr<T, Output = Natural>,\n    Limb: ModShr<T, Output = Limb>,\n{\n    natural_natural_signed_triple_gen_var_1::<T>().test_properties(|(n, m, i)| {\n        assert!(n.mod_is_reduced(&m));\n        let mut mut_n = n.clone();\n        mut_n.mod_shr_assign(i, &m);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n        assert!(shifted.mod_is_reduced(&m));\n\n        let mut mut_n = n.clone();\n        mut_n.mod_shr_assign(i, m.clone());\n        let shifted_alt = mut_n;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        let shifted_alt = (&n).mod_shr(i, &m);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = (&n).mod_shr(i, m.clone());\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_shr(i, &m);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone().mod_shr(i, m.clone());\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!((&n >> i).mod_op(&m), shifted);\n\n        if i != T::MIN {\n            assert_eq!(n.mod_shl(-i, m), shifted);\n        }\n    });\n\n    natural_pair_gen_var_8().test_properties(|(n, m)| {\n        assert_eq!((&n).mod_shr(T::ZERO, m), n);\n    });\n\n    natural_signed_pair_gen_var_3::<T>().test_properties(|(m, i)| {\n        assert_eq!(Natural::ZERO.mod_shr(i, m), 0);\n    });\n\n    signed_gen_var_5::<T>().test_properties(|i| {\n        assert_eq!(Natural::ZERO.mod_shr(i, Natural::ONE), 0);\n    });\n\n    unsigned_signed_unsigned_triple_gen_var_2::<Limb, U, T>().test_properties(|(n, i, m)| {\n        assert_eq!(\n            Natural::from(n).mod_shr(i, Natural::from(m)),\n            n.mod_shr(i, m)\n        );\n    });\n}\n\n#[test]\nfn mod_shr_properties() {\n    apply_fn_to_unsigned_signed_pairs!(properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    ModIsReduced, ModMul, ModNeg, ModSquare, ModSquareAssign, Square,\n};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_16;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen_var_2, natural_pair_gen_var_8, natural_triple_gen_var_3,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_square() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let m = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_square_assign(m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_square_assign(&m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_square(m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_square(m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_square(&m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_square(&m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"1\", \"10\", \"1\");\n    test(\"2\", \"10\", \"4\");\n    test(\"100\", \"497\", \"60\");\n    test(\"200\", \"497\", \"240\");\n    test(\"300\", \"497\", \"43\");\n    test(\"1234567890\", \"123456789876\", \"100296296172\");\n}\n\n#[test]\nfn mod_square_fail() {\n    assert_panic!(Natural::ZERO.mod_square(Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_square(Natural::ONE));\n\n    assert_panic!(Natural::ZERO.mod_square(&Natural::ZERO));\n    assert_panic!(Natural::from(30u32).mod_square(&Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_square(Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_square(Natural::ONE));\n\n    assert_panic!((&Natural::ZERO).mod_square(&Natural::ZERO));\n    assert_panic!((&Natural::from(30u32)).mod_square(&Natural::ONE));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_square_assign(Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_square_assign(Natural::ONE);\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_square_assign(&Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u32);\n        x.mod_square_assign(&Natural::ONE);\n    });\n}\n\n#[test]\nfn mod_square_properties() {\n    natural_pair_gen_var_8().test_properties(|(x, m)| {\n        assert!(x.mod_is_reduced(&m));\n        let square_val_val = x.clone().mod_square(m.clone());\n        let square_ref_val = (&x).mod_square(m.clone());\n        let square_val_ref = x.clone().mod_square(&m);\n        let square = (&x).mod_square(&m);\n        assert!(square_val_val.is_valid());\n        assert!(square_ref_val.is_valid());\n        assert!(square_val_ref.is_valid());\n        assert!(square.is_valid());\n        assert!(square.mod_is_reduced(&m));\n        assert_eq!(square_val_val, square);\n        assert_eq!(square_ref_val, square);\n        assert_eq!(square_val_ref, square);\n\n        let mut mut_x = x.clone();\n        mut_x.mod_square_assign(m.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, square);\n        let mut mut_x = x.clone();\n        mut_x.mod_square_assign(&m);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, square);\n\n        assert_eq!((&x).mod_mul(&x, &m), square);\n        assert_eq!((&x).square() % &m, square);\n        assert_eq!(x.mod_neg(&m).mod_square(&m), square);\n    });\n\n    natural_gen_var_2().test_properties(|m| {\n        assert_eq!(Natural::ZERO.mod_square(&m), 0);\n        if m != 1 {\n            assert_eq!(Natural::ONE.mod_square(m), 1);\n        }\n    });\n\n    natural_triple_gen_var_3().test_properties(|(x, y, m)| {\n        assert_eq!(\n            (&x).mod_mul(&y, &m).mod_square(&m),\n            x.mod_square(&m).mod_mul(y.mod_square(&m), &m)\n        );\n    });\n\n    unsigned_pair_gen_var_16::<Limb>().test_properties(|(x, m)| {\n        assert_eq!(\n            x.mod_square(m),\n            Natural::from(x).mod_square(Natural::from(m))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mod_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Mod, ModAdd, ModIsReduced, ModNeg, ModSub, ModSubAssign,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_12;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_pair_gen_var_8, natural_triple_gen_var_3};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod_sub() {\n    let test = |r, s, t, out| {\n        let u = Natural::from_str(r).unwrap();\n        let v = Natural::from_str(s).unwrap();\n        let m = Natural::from_str(t).unwrap();\n\n        assert!(u.mod_is_reduced(&m));\n        assert!(v.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_sub_assign(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert!(n.mod_is_reduced(&m));\n\n        let mut n = u.clone();\n        n.mod_sub_assign(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_sub_assign(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.mod_sub_assign(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_sub(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_sub(v.clone(), m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_sub(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_sub(&v, m.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_sub(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_sub(v.clone(), &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().mod_sub(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).mod_sub(&v, &m);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", \"1\", \"0\");\n    test(\"0\", \"0\", \"32\", \"0\");\n    test(\"0\", \"27\", \"32\", \"5\");\n    test(\"10\", \"2\", \"16\", \"8\");\n    test(\"2\", \"10\", \"16\", \"8\");\n    test(\"0\", \"5\", \"128\", \"123\");\n    test(\"123\", \"0\", \"128\", \"123\");\n    test(\"123\", \"56\", \"512\", \"67\");\n    test(\"56\", \"123\", \"512\", \"445\");\n    test(\"7\", \"9\", \"10\", \"8\");\n}\n\n#[test]\nfn mod_sub_fail() {\n    assert_panic!(Natural::ZERO.mod_sub(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_sub(Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_sub(Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_sub(Natural::ZERO, &Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_sub(Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_sub(Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_sub(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_sub(&Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_sub(&Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!(Natural::ZERO.mod_sub(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Natural::from(30u8).mod_sub(&Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!(Natural::from(3u8).mod_sub(&Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_sub(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_sub(Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_sub(Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_sub(Natural::ZERO, &Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_sub(Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_sub(Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_sub(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_sub(&Natural::from(3u8), Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_sub(&Natural::from(30u8), Natural::from(30u8)));\n\n    assert_panic!((&Natural::ZERO).mod_sub(Natural::ZERO, Natural::ZERO));\n    assert_panic!((&Natural::from(30u8)).mod_sub(&Natural::from(3u8), &Natural::from(30u8)));\n    assert_panic!((&Natural::from(3u8)).mod_sub(&Natural::from(30u8), &Natural::from(30u8)));\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_sub_assign(Natural::ZERO, Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_sub_assign(Natural::from(3u8), Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_sub_assign(Natural::from(30u8), Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_sub_assign(Natural::ZERO, &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_sub_assign(Natural::from(3u8), &Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_sub_assign(Natural::from(30u8), &Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_sub_assign(Natural::ZERO, Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_sub_assign(&Natural::from(3u8), Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_sub_assign(&Natural::from(30u8), Natural::from(30u8));\n    });\n\n    assert_panic!({\n        let mut x = Natural::ZERO;\n        x.mod_sub_assign(Natural::ZERO, &Natural::ZERO);\n    });\n    assert_panic!({\n        let mut x = Natural::from(30u8);\n        x.mod_sub_assign(&Natural::from(3u8), &Natural::from(30u8));\n    });\n    assert_panic!({\n        let mut x = Natural::from(3u8);\n        x.mod_sub_assign(&Natural::from(30u8), &Natural::from(30u8));\n    });\n}\n\n#[test]\nfn mod_sub_properties() {\n    natural_triple_gen_var_3().test_properties(|(x, y, m)| {\n        assert!(x.mod_is_reduced(&m));\n        assert!(y.mod_is_reduced(&m));\n        let diff_val_val_val = x.clone().mod_sub(y.clone(), m.clone());\n        let diff_val_ref_val = x.clone().mod_sub(&y, m.clone());\n        let diff_ref_val_val = (&x).mod_sub(y.clone(), m.clone());\n        let diff_ref_ref_val = (&x).mod_sub(&y, m.clone());\n        let diff_val_val_ref = x.clone().mod_sub(y.clone(), &m);\n        let diff_val_ref_ref = x.clone().mod_sub(&y, &m);\n        let diff_ref_val_ref = (&x).mod_sub(y.clone(), &m);\n        let diff = (&x).mod_sub(&y, &m);\n        assert!(diff_val_val_val.is_valid());\n        assert!(diff_val_ref_val.is_valid());\n        assert!(diff_ref_val_val.is_valid());\n        assert!(diff_val_val_ref.is_valid());\n        assert!(diff_val_val_ref.is_valid());\n        assert!(diff_val_ref_ref.is_valid());\n        assert!(diff_ref_val_ref.is_valid());\n        assert!(diff.is_valid());\n        assert!(diff.mod_is_reduced(&m));\n        assert_eq!(diff_val_val_val, diff);\n        assert_eq!(diff_val_ref_val, diff);\n        assert_eq!(diff_ref_val_val, diff);\n        assert_eq!(diff_ref_ref_val, diff);\n        assert_eq!(diff_val_val_ref, diff);\n        assert_eq!(diff_val_ref_ref, diff);\n        assert_eq!(diff_ref_val_ref, diff);\n\n        assert_eq!(\n            (Integer::from(&x) - Integer::from(&y)).mod_op(Integer::from(&m)),\n            diff\n        );\n\n        let mut mut_x = x.clone();\n        mut_x.mod_sub_assign(y.clone(), m.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n        let mut mut_x = x.clone();\n        mut_x.mod_sub_assign(&y, m.clone());\n        assert_eq!(mut_x, diff);\n        assert!(mut_x.is_valid());\n        let mut mut_x = x.clone();\n        mut_x.mod_sub_assign(y.clone(), &m);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n        let mut mut_x = x.clone();\n        mut_x.mod_sub_assign(&y, &m);\n        assert_eq!(mut_x, diff);\n        assert!(mut_x.is_valid());\n\n        assert_eq!((&y).mod_sub(&x, &m), (&diff).mod_neg(&m));\n        assert_eq!((&x).mod_add((&y).mod_neg(&m), &m), diff);\n        assert_eq!((&diff).mod_add(&y, &m), x);\n        assert_eq!(diff.mod_sub(x, &m), y.mod_neg(&m));\n    });\n\n    natural_pair_gen_var_8().test_properties(|(x, m)| {\n        assert_eq!((&x).mod_sub(Natural::ZERO, &m), x);\n        assert_eq!(Natural::ZERO.mod_sub(&x, &m), (&x).mod_neg(&m));\n        assert_eq!((&x).mod_sub(&x, m), 0);\n    });\n\n    unsigned_triple_gen_var_12::<Limb>().test_properties(|(x, y, m)| {\n        assert_eq!(\n            x.mod_sub(y, m),\n            Natural::from(x).mod_sub(Natural::from(y), Natural::from(m))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedLogBase2, DivMod, PowerOf2, Square};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::common::rle_decode;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    large_type_gen_var_1, unsigned_pair_gen_var_27, unsigned_vec_gen_var_6,\n    unsigned_vec_pair_gen_var_1, unsigned_vec_pair_gen_var_2, unsigned_vec_triple_gen_var_1,\n    unsigned_vec_triple_gen_var_2, unsigned_vec_triple_gen_var_3, unsigned_vec_triple_gen_var_24,\n    unsigned_vec_triple_gen_var_25, unsigned_vec_unsigned_pair_gen,\n    unsigned_vec_unsigned_unsigned_triple_gen, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n};\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::mul::context::CONTEXT;\nuse malachite_nz::natural::arithmetic::mul::limb::{\n    limbs_mul_limb, limbs_mul_limb_to_out, limbs_mul_limb_with_carry_to_out,\n    limbs_slice_mul_limb_in_place, limbs_slice_mul_limb_with_carry_in_place,\n    limbs_vec_mul_limb_in_place,\n};\nuse malachite_nz::natural::arithmetic::mul::mul_low::{\n    limbs_mul_low_same_length, limbs_mul_low_same_length_basecase,\n    limbs_mul_low_same_length_basecase_alt, limbs_mul_low_same_length_divide_and_conquer,\n    limbs_mul_low_same_length_divide_and_conquer_shared_scratch,\n};\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse malachite_nz::natural::arithmetic::mul::mul_mod::limbs_mul_mod_base_pow_n_minus_1;\nuse malachite_nz::natural::arithmetic::mul::product_of_limbs::limbs_product;\nuse malachite_nz::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_6h, limbs_mul_greater_to_out_toom_6h_scratch_len,\n    limbs_mul_greater_to_out_toom_8h, limbs_mul_greater_to_out_toom_8h_scratch_len,\n    limbs_mul_greater_to_out_toom_43, limbs_mul_greater_to_out_toom_43_scratch_len,\n    limbs_mul_greater_to_out_toom_44, limbs_mul_greater_to_out_toom_44_scratch_len,\n    limbs_mul_greater_to_out_toom_52, limbs_mul_greater_to_out_toom_52_scratch_len,\n    limbs_mul_greater_to_out_toom_53, limbs_mul_greater_to_out_toom_53_scratch_len,\n    limbs_mul_greater_to_out_toom_63, limbs_mul_greater_to_out_toom_63_scratch_len,\n};\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_nz::natural::arithmetic::mul::toom::{\n    limbs_mul_greater_to_out_toom_22, limbs_mul_greater_to_out_toom_22_scratch_len,\n    limbs_mul_greater_to_out_toom_32, limbs_mul_greater_to_out_toom_32_scratch_len,\n    limbs_mul_greater_to_out_toom_33, limbs_mul_greater_to_out_toom_33_scratch_len,\n    limbs_mul_greater_to_out_toom_42, limbs_mul_greater_to_out_toom_42_scratch_len,\n    limbs_mul_greater_to_out_toom_54, limbs_mul_greater_to_out_toom_54_scratch_len,\n    limbs_mul_greater_to_out_toom_62, limbs_mul_greater_to_out_toom_62_scratch_len,\n};\nuse malachite_nz::natural::arithmetic::mul::{\n    limbs_mul, limbs_mul_greater, limbs_mul_greater_to_out, limbs_mul_greater_to_out_basecase,\n    limbs_mul_greater_to_out_scratch_len, limbs_mul_same_length_to_out,\n    limbs_mul_same_length_to_out_scratch_len, limbs_mul_to_out, limbs_mul_to_out_scratch_len,\n};\nuse malachite_nz::platform::{DoubleLimb, Limb};\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_pair_gen, natural_triple_gen, natural_vec_gen,\n};\nuse malachite_nz::test_util::natural::arithmetic::mul::natural_product_naive;\nuse malachite_nz::test_util::natural::arithmetic::mul::{initialize_context, mul_slow_fft};\nuse malachite_nz::test_util::natural::arithmetic::mul::{\n    limbs_mul_greater_to_out_basecase_mem_opt, limbs_product_naive,\n};\nuse num::BigUint;\nuse rug;\nuse std::iter::{Product, once};\nuse std::str::FromStr;\n\nfn series(start: Limb, len: usize) -> Vec<Limb> {\n    (start..start + Limb::exact_from(len)).collect()\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_limb_and_limbs_vec_mul_limb_in_place() {\n    let test = |limbs: &[Limb], limb: Limb, out: &[Limb]| {\n        assert_eq!(limbs_mul_limb(limbs, limb), out);\n\n        let mut limbs = limbs.to_vec();\n        limbs_vec_mul_limb_in_place(&mut limbs, limb);\n        assert_eq!(limbs, out);\n    };\n    test(&[], 0, &[]);\n    test(&[], 5, &[]);\n    test(&[6, 7], 2, &[12, 14]);\n    test(&[100, 101, 102], 10, &[1000, 1010, 1020]);\n    test(&[123, 456], 789, &[97047, 359784]);\n    test(&[u32::MAX, 5], 2, &[u32::MAX - 1, 11]);\n    test(&[u32::MAX], 2, &[u32::MAX - 1, 1]);\n    test(&[u32::MAX], u32::MAX, &[1, u32::MAX - 1]);\n}\n\n#[test]\nfn test_product() {\n    let test = |xs, out| {\n        let xs = vec_from_str(xs).unwrap();\n        let product = Natural::product(xs.iter().cloned());\n        assert!(product.is_valid());\n        assert_eq!(product.to_string(), out);\n\n        let product_alt = Natural::product(xs.iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n\n        let product_alt = natural_product_naive(xs.into_iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n    };\n    test(\"[]\", \"1\");\n    test(\"[10]\", \"10\");\n    test(\"[6, 2]\", \"12\");\n    test(\"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\", \"0\");\n    test(\"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\", \"3628800\");\n    test(\n        \"[123456, 789012, 345678, 9012345]\",\n        \"303462729062737285547520\",\n    );\n}\n\n#[test]\nfn limbs_mul_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_mul_limb(&xs, y)),\n            Natural::from_limbs_asc(&xs) * Natural::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_vec_mul_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_vec_mul_limb_in_place(&mut xs, y);\n        let n = Natural::from_limbs_asc(&old_xs) * Natural::from(y);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_limb_with_carry_to_out() {\n    let test = |out_before: &[Limb],\n                xs: &[Limb],\n                y: Limb,\n                carry: Limb,\n                carry_out: Limb,\n                out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(\n            limbs_mul_limb_with_carry_to_out::<DoubleLimb, Limb>(&mut out, xs, y, carry),\n            carry_out\n        );\n        assert_eq!(out, out_after);\n    };\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        789,\n        10,\n        0,\n        &[97057, 359784, 10, 10],\n    );\n    test(&[10, 10, 10, 10], &[u32::MAX], 2, 3, 2, &[1, 10, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_limb_with_carry_to_out_fail() {\n    limbs_mul_limb_with_carry_to_out::<DoubleLimb, Limb>(&mut [10], &[10, 10], 10, 2);\n}\n\n#[test]\nfn limbs_mul_limb_with_carry_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_1().test_properties_with_config(&config, |(mut out, xs, y, carry)| {\n        let old_out = out.clone();\n        let carry_out =\n            limbs_mul_limb_with_carry_to_out::<DoubleLimb, Limb>(&mut out, &xs, y, carry);\n        let len = xs.len();\n        let n = Natural::from_owned_limbs_asc(xs) * Natural::from(y) + Natural::from(carry);\n        let mut xs_out = n.into_limbs_asc();\n        assert_eq!(carry_out != 0, xs_out.len() == len + 1);\n        if carry_out != 0 {\n            assert_eq!(*xs_out.last().unwrap(), carry_out);\n        }\n        xs_out.resize(len, 0);\n        assert_eq!(xs_out, &out[..len]);\n        assert_eq!(&out[len..], &old_out[len..]);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_limb_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, carry: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(\n            limbs_mul_limb_to_out::<DoubleLimb, Limb>(&mut out, xs, y),\n            carry\n        );\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[], 0, 0, &[10, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[], 5, 0, &[10, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, 0, &[12, 14, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        0,\n        &[1000, 1010, 1020, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        789,\n        0,\n        &[97047, 359784, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, 5],\n        2,\n        0,\n        &[u32::MAX - 1, 11, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX],\n        2,\n        1,\n        &[u32::MAX - 1, 10, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX],\n        u32::MAX,\n        u32::MAX - 1,\n        &[1, 10, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_limb_to_out_fail() {\n    limbs_mul_limb_to_out::<DoubleLimb, Limb>(&mut [10], &[10, 10], 10);\n}\n\n#[test]\nfn limbs_mul_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            let carry = limbs_mul_limb_to_out::<DoubleLimb, Limb>(&mut out, &xs, y);\n            let len = xs.len();\n            let n = Natural::from_owned_limbs_asc(xs) * Natural::from(y);\n            let mut limbs = n.into_limbs_asc();\n            assert_eq!(carry != 0, limbs.len() == len + 1);\n            if carry != 0 {\n                assert_eq!(*limbs.last().unwrap(), carry);\n            }\n            limbs.resize(len, 0);\n            assert_eq!(limbs, &out[..len]);\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_limb_with_carry_in_place() {\n    let test = |xs_before: &[Limb], y: Limb, carry: Limb, carry_out: Limb, xs_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_slice_mul_limb_with_carry_in_place(&mut xs, y, carry),\n            carry_out\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[123, 456], 789, 10, 0, &[97057, 359784]);\n    test(&[u32::MAX], 2, 3, 2, &[1]);\n}\n\n#[test]\nfn limbs_slice_mul_limb_with_carry_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen().test_properties_with_config(\n        &config,\n        |(mut xs, y, carry)| {\n            let n = Natural::from_limbs_asc(&xs) * Natural::from(y) + Natural::from(carry);\n            let carry_out = limbs_slice_mul_limb_with_carry_in_place(&mut xs, y, carry);\n            let mut expected_limbs = n.into_limbs_asc();\n            assert_eq!(carry_out != 0, expected_limbs.len() == xs.len() + 1);\n            if carry_out != 0 {\n                assert_eq!(*expected_limbs.last().unwrap(), carry_out);\n            }\n            expected_limbs.resize(xs.len(), 0);\n            assert_eq!(xs, expected_limbs);\n        },\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_mul_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, carry: Limb, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        assert_eq!(limbs_slice_mul_limb_in_place(&mut xs, y), carry);\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, 0, &[]);\n    test(&[], 5, 0, &[]);\n    test(&[6, 7], 2, 0, &[12, 14]);\n    test(&[100, 101, 102], 10, 0, &[1000, 1010, 1020]);\n    test(&[123, 456], 789, 0, &[97047, 359784]);\n    test(&[u32::MAX, 5], 2, 0, &[u32::MAX - 1, 11]);\n    test(&[u32::MAX], 2, 1, &[u32::MAX - 1]);\n    test(&[u32::MAX], u32::MAX, u32::MAX - 1, &[1]);\n}\n\n#[test]\nfn limbs_slice_mul_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        let carry = limbs_slice_mul_limb_in_place(&mut xs, y);\n        let n = Natural::from_limbs_asc(&old_xs) * Natural::from(y);\n        let mut expected_limbs = n.into_limbs_asc();\n        assert_eq!(carry != 0, expected_limbs.len() == xs.len() + 1);\n        if carry != 0 {\n            assert_eq!(*expected_limbs.last().unwrap(), carry);\n        }\n        expected_limbs.resize(xs.len(), 0);\n        assert_eq!(xs, expected_limbs);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, result: Vec<Limb>| {\n        assert_eq!(limbs_mul_greater(&xs, &ys), result);\n    };\n    test(vec![2], vec![3], vec![6, 0]);\n    test(vec![1; 3], series(1, 3), vec![1, 3, 6, 5, 3, 0]);\n    test(series(1, 3), vec![6, 7], vec![6, 19, 32, 21, 0]);\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10200, 20402, 30605, 20402, 10200, 0],\n    );\n    test(vec![u32::MAX], vec![1], vec![u32::MAX, 0]);\n    test(vec![u32::MAX], vec![u32::MAX], vec![1, u32::MAX - 1]);\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![1, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn test_limbs_mul_greater_fail_1() {\n    limbs_mul_greater(&[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn test_limbs_mul_greater_fail_2() {\n    limbs_mul_greater(&[6, 7], &[]);\n}\n\nfn limbs_mul_helper(f: &dyn Fn(&[Limb], &[Limb]) -> Vec<Limb>, xs: Vec<Limb>, ys: Vec<Limb>) {\n    let result = f(&xs, &ys);\n    assert_eq!(result.len(), xs.len() + ys.len());\n    assert_eq!(\n        Natural::from_owned_limbs_asc(result),\n        Natural::from_owned_limbs_asc(xs) * Natural::from_owned_limbs_asc(ys)\n    );\n}\n\n#[test]\nfn limbs_mul_greater_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_1().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_mul_helper(&limbs_mul_greater, xs, ys);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, result: Vec<Limb>| {\n        assert_eq!(limbs_mul(&xs, &ys), result);\n    };\n    test(vec![2], vec![3], vec![6, 0]);\n    test(vec![1; 3], series(1, 3), vec![1, 3, 6, 5, 3, 0]);\n    test(series(1, 3), vec![6, 7], vec![6, 19, 32, 21, 0]);\n    test(vec![6, 7], series(1, 3), vec![6, 19, 32, 21, 0]);\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10200, 20402, 30605, 20402, 10200, 0],\n    );\n    test(vec![u32::MAX], vec![1], vec![u32::MAX, 0]);\n    test(vec![u32::MAX], vec![u32::MAX], vec![1, u32::MAX - 1]);\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![1, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn test_limbs_mul_fail() {\n    limbs_mul(&[6, 7], &[]);\n}\n\n#[test]\nfn limbs_mul_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_2().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_mul_helper(&limbs_mul, xs, ys);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_same_length_to_out() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before;\n        let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(xs.len())];\n        limbs_mul_same_length_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        assert_eq!(out, out_after);\n    };\n    test(vec![2], vec![3], vec![10; 3], vec![6, 0, 10]);\n    test(\n        vec![1; 3],\n        series(1, 3),\n        vec![5; 8],\n        vec![1, 3, 6, 5, 3, 0, 5, 5],\n    );\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10; 7],\n        vec![10200, 20402, 30605, 20402, 10200, 0, 10],\n    );\n    test(vec![u32::MAX], vec![1], vec![10; 3], vec![u32::MAX, 0, 10]);\n    test(\n        vec![u32::MAX],\n        vec![u32::MAX],\n        vec![10; 4],\n        vec![1, u32::MAX - 1, 10, 10],\n    );\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![10; 6],\n        vec![1, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_same_length_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10, 10];\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(3)];\n    limbs_mul_same_length_to_out(&mut out, &[6, 7], &[1, 2, 3], &mut mul_scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_same_length_to_out_fail_2() {\n    let mut out = vec![10, 10, 10];\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(2)];\n    limbs_mul_same_length_to_out(&mut out, &[6, 7], &[1, 2], &mut mul_scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_same_length_to_out_fail_3() {\n    let mut out = vec![10];\n    let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(1)];\n    limbs_mul_same_length_to_out(&mut out, &[], &[], &mut mul_scratch);\n}\n\n#[test]\nfn limbs_mul_same_length_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_1().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let old_out = out.clone();\n        let mut mul_scratch = vec![0; limbs_mul_same_length_to_out_scratch_len(xs.len())];\n        limbs_mul_same_length_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        let len = xs.len() << 1;\n        let n = Natural::from_owned_limbs_asc(xs) * Natural::from_owned_limbs_asc(ys);\n        let mut expected_out = n.into_limbs_asc();\n        expected_out.resize(len, 0);\n        assert_eq!(expected_out, &out[..len]);\n        assert_eq!(&out[len..], &old_out[len..]);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out() {\n    let test =\n        |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, highest_result_limb, out_after| {\n            let mut out = out_before.clone();\n            limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n            assert_eq!(out, out_after);\n            let mut out = out_before;\n            let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs.len(), ys.len())];\n            assert_eq!(\n                limbs_mul_greater_to_out(&mut out, &xs, &ys, &mut mul_scratch),\n                highest_result_limb\n            );\n            assert_eq!(out, out_after);\n        };\n    test(vec![2], vec![3], vec![10; 3], 0, vec![6, 0, 10]);\n    test(\n        vec![1; 3],\n        series(1, 3),\n        vec![5; 8],\n        0,\n        vec![1, 3, 6, 5, 3, 0, 5, 5],\n    );\n    test(\n        series(1, 3),\n        vec![6, 7],\n        vec![0; 5],\n        0,\n        vec![6, 19, 32, 21, 0],\n    );\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10; 7],\n        0,\n        vec![10200, 20402, 30605, 20402, 10200, 0, 10],\n    );\n    test(\n        vec![u32::MAX],\n        vec![1],\n        vec![10; 3],\n        0,\n        vec![u32::MAX, 0, 10],\n    );\n    test(\n        vec![u32::MAX],\n        vec![u32::MAX],\n        vec![10; 4],\n        u32::MAX - 1,\n        vec![1, u32::MAX - 1, 10, 10],\n    );\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![10; 6],\n        u32::MAX,\n        vec![1, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out() {\n    let test = |xs: Vec<Limb>,\n                ys: Vec<Limb>,\n                out_before: Vec<Limb>,\n                highest_result_limb,\n                out_after: Vec<Limb>| {\n        let mut out = out_before.clone();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before;\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs.len(), ys.len())];\n        assert_eq!(\n            limbs_mul_greater_to_out(&mut out, &xs, &ys, &mut mul_scratch),\n            highest_result_limb\n        );\n        assert_eq!(out, out_after);\n    };\n    test(\n        vec![\n            12709525342598979476,\n            11509224300783138838,\n            393964466388471327,\n            14232928317295888119,\n            13732076968605655238,\n            15707747516397285107,\n            8732499155930007762,\n            9865419549041312495,\n            1072105962419307309,\n            17879862180104468293,\n            17068561868445402638,\n            1866096115219256579,\n            6855809432664356654,\n            1393588600207482081,\n            3815615263372249309,\n            4991042746319579278,\n            15465001638246553057,\n            16087255091514657862,\n            5044736888141764583,\n            2779747905405388451,\n            583627419881315049,\n            4335440233116895431,\n            9498366494409866085,\n            8645413868323766569,\n            10728932435460960803,\n            2150088858744686298,\n            9562258835198494013,\n            17827191588813955307,\n            13784645620229731318,\n            6296382068077415813,\n            11689157886369173742,\n            17754283123435968230,\n            1461090916898201642,\n            1288610558427232175,\n            8104103888086828127,\n            8032176301470720968,\n            12200951204181999648,\n            9485404571555436368,\n            10222400990562648891,\n            7599079551870785840,\n            11203522977648266038,\n            18338050175108207759,\n            12077517359207243953,\n            1611826255828631363,\n            15837930674386751191,\n            461582836356148934,\n            16860704548252932358,\n            6041830073720446893,\n            16833467135075592988,\n            17496069201595551026,\n            10318992522772404757,\n            13524041658187206186,\n            4506190253313254923,\n            17231310439197044711,\n            13546843641632582646,\n            7651927160556964586,\n            9190936365032409113,\n            9913829309881494193,\n            12083378901909297431,\n            287809474670991447,\n            7728504523588277111,\n            16741959317437359789,\n            9529628049862654500,\n            13419553383911388725,\n            13376506161484177119,\n            8176094358898406545,\n            13190641351956097350,\n            12568817836646213483,\n            3486855157615498387,\n            14702408831781542831,\n            98979558380456360,\n            13178740567667926424,\n            17968226918253726036,\n            9245411514261104062,\n            2907160002341084957,\n            1980943369383764848,\n            6564658997896463013,\n            13002525217264158147,\n            444335199954317567,\n            16863109666887451301,\n            11108312108618761726,\n            7630498129836691848,\n            5435171385264263429,\n            10900954800466810672,\n            16615568172072435554,\n            4587778094537619469,\n            10961411668824294491,\n            17076006711925106918,\n            5351453460500307468,\n            7629258051101663482,\n            16987233075558685907,\n            7043270533100406405,\n            1951394976862135309,\n            13689790855612457174,\n            2278410054587042806,\n            17001418508549255568,\n            11660613606297735566,\n            2855471124776808043,\n            10065175989746288214,\n            5055380914672426055,\n            14126789454240780537,\n            12269074817478677711,\n            15318371572624008687,\n            17454608042943339898,\n            266175370449515926,\n            10258065246409153340,\n            7913204199005555677,\n            2015162987422567864,\n            947599677954716876,\n            4742046749175767719,\n            4638837750457895566,\n            7651567606901939182,\n            1517253577417508168,\n            10046266355925262869,\n            17517100300192594127,\n            1840911236085514585,\n            17925925769498956584,\n            649534223875437606,\n            4629497761671206138,\n            6940070820665949971,\n            11499097596331562367,\n            6066662975772729994,\n            14012285030054181,\n            15069455665359536649,\n            15693110947967738351,\n            6137496527357766025,\n            17475548660925055392,\n            7927767715587303464,\n            8531250928287116369,\n            11631019584025111086,\n            14052618820385867457,\n            3118784937861555333,\n            183376537996253187,\n            5402208906954882112,\n            4415682544496910978,\n            4679985880085587510,\n            8446593383458511654,\n            15604884470214334395,\n            1138627504082666786,\n            10518517338133402469,\n            4864527599992532396,\n            13936709675277621349,\n            564858321719103528,\n            17954444276502582707,\n            7973580172007214272,\n            5448002835725952206,\n            17643582902922581336,\n            6555152033284063414,\n            10046934352485272915,\n            13709275446788968044,\n            3781650587286942277,\n            856963687705102140,\n            14231130335064067998,\n            12012182879109532509,\n            14408852620208381144,\n            18399276894609882283,\n            8786560043544514971,\n            9040897797784271497,\n            3289492106827693022,\n            2537349882995177,\n            9547621122715901978,\n            18031028021813298205,\n            13759002194232082515,\n            8230796682226694274,\n            16497307259652601605,\n            4532459299949788115,\n            9096244343722808065,\n            15835940740299471650,\n            16962714874349511272,\n            12751247365216834654,\n            5665483802634541323,\n            5932524403187765899,\n            9724384992325030819,\n            4567260165559481416,\n            12988617208150638305,\n            3810267272444218110,\n            12215376695703433417,\n            15917770368925117452,\n            10076439022504697381,\n            15419145301042845244,\n            12520526582226591499,\n            10731090420480517823,\n            7095369748974936538,\n            7265727720840614264,\n            14328612713128953576,\n            9796482770007505116,\n            12823579117053411854,\n            5055821064893108365,\n            12630218511428402185,\n            5189066330700437332,\n            5109762584664698804,\n            10723647767885063411,\n            15665488082047274789,\n            4569259999401990745,\n            3735809282876517401,\n            7285645596632892122,\n            10962161595160119179,\n            4816357354602339409,\n            10873333778222769846,\n            8013894684430460951,\n            1877066355845544058,\n            9184544411342906577,\n            1919785302854216344,\n            11743122258369849152,\n            3429022440866576828,\n            7006536176872515230,\n            12354403703503061654,\n            16589390678996741825,\n            8567087982659180500,\n            8236943971468579104,\n            14606686909208062275,\n            4461894282559697271,\n            2623848805529273446,\n            6820927267034378486,\n            14393599619569715182,\n            5199894747923716756,\n            206321364421131251,\n            4071363758717862161,\n            11965914866997389305,\n            8109905844769656284,\n            3492539957359367736,\n            16856371139562646083,\n            4333218987558602531,\n            16089995180748288161,\n            11191427142864224026,\n            2622884336931596940,\n            16105201810330583174,\n            11381683384063743452,\n            7873797126730706201,\n            11178731223505120377,\n            16800978016652635785,\n            13461685021093913844,\n            3055116765865974959,\n            3602813646007838280,\n            829147354810404950,\n            4780507430409308744,\n            18314860632940156926,\n            6995096023652594133,\n            5759566466885931830,\n            4840076000542784388,\n        ],\n        vec![\n            15245088662193948010,\n            854969528224537163,\n            192457876290468361,\n            3156774054099849881,\n            10102117358735393641,\n            13923135497401538045,\n            15603007686998930972,\n            3707765480829539463,\n            1075990372015045994,\n            4440028045035707188,\n            779932550205535682,\n            13284596850012603887,\n            13447370325749987403,\n            10657005451799608034,\n            17344058779081327933,\n            1801131630646010099,\n            17879455113972297046,\n            1049662270419803525,\n            17887003202529550415,\n            13730724178286439296,\n            3086493866184691051,\n            7455503161286080904,\n            14945249663072669446,\n            7413071270018261565,\n            8165098975144402988,\n            15667870805615006559,\n            4534237642686726425,\n            5675059133984408369,\n            13542693529471369730,\n            4650690134857994243,\n            10593876026982724440,\n            8719234160809710444,\n            7340192483727047710,\n            2225660849988538666,\n            3260628781823840386,\n            14784063213821786553,\n            13478324037708856111,\n            6239844587086244103,\n            14508626048519473050,\n            11443816492520902359,\n            7084448144752764341,\n            11673478635762496725,\n            13444020463604694513,\n            1798574113181758005,\n            15195278749704748030,\n            3490272214933312037,\n            15632500462832370824,\n            9808665338648603851,\n            6377980234800091876,\n            11306384233660763805,\n            6392788317448223882,\n            8005181869701567455,\n            4601526777105113530,\n            9348184476999479133,\n            16105441815997897842,\n            15373735633778437011,\n            11733794529384137433,\n            769246272107807645,\n            2922899274256775805,\n            16218486247871807873,\n            10650657974127272786,\n            579665301817927565,\n            6403006378940431337,\n            10150254532952843560,\n            3736822004545760197,\n            10244207440138560761,\n            16631379436671010056,\n            17418302422321190629,\n            4844439457855539440,\n            9662799133272397874,\n            11622100630061039998,\n            11017257064923257696,\n            14025546287952884200,\n            1170766120552674008,\n            4852413824670160293,\n            18019298735978800767,\n            14042374992041286164,\n            6103187929964524269,\n            5988592592688695870,\n            5579172720281387479,\n            10738878044274955012,\n            8401646271610146442,\n            12016061916593958227,\n            14752402557741497038,\n            5053283107906893264,\n            12910662726197463795,\n            787526459034857809,\n            10304827788120361107,\n            8387521101013404665,\n            6030209567663971422,\n            7511028869236306454,\n            11105170944119024313,\n            2911699195421772292,\n            11710398806568443147,\n            7599646386487625804,\n            2146501359265516686,\n            1193294087739295886,\n            16419769173966961854,\n            14779980297792837632,\n            6286361066120350249,\n            8246126699673376536,\n            2339493649448723726,\n            12383521129608538925,\n            17459816050942292574,\n            7213741082075285427,\n            14702683527305456088,\n            17849030573001874153,\n            3273901152373442943,\n            10086273715179643444,\n            14351251935054659627,\n            3067622597087477151,\n            4241957707372911307,\n            16686513037697490920,\n            1503886102490162470,\n            4222986769290077389,\n            17209928444872897872,\n            10064374817012298812,\n            1391022681726221923,\n            3482099619102309134,\n            151151415131464647,\n            5477310851692317777,\n            8185741896741403527,\n            12297179519749775078,\n            6980896315258250234,\n            5491311995173541969,\n            10908311176531272611,\n            15140263006374103771,\n            16292302828281485620,\n            13488663273854028028,\n            17078235461511918753,\n            523009743565281503,\n            11105648925812514991,\n            13827146014280242829,\n        ],\n        vec![10; 373],\n        3627981030815073084,\n        vec![\n            10242139703917377352,\n            6869501223013262871,\n            3374240433299030218,\n            2448664517749959925,\n            12614665088252879609,\n            15275142410865499832,\n            7415514779145416012,\n            4634939093621563784,\n            14236482271744498259,\n            16987935748141823121,\n            9662195261206294164,\n            8327530275898959224,\n            17948858401312480900,\n            16590992031072707948,\n            8981557837131782478,\n            17292811815398261598,\n            10343772151713015660,\n            16403800522193054061,\n            11001578312297934300,\n            9055563331722809276,\n            6861684031441187837,\n            6179379396114830115,\n            15119399843907730738,\n            2747263417069121706,\n            12218921993633141137,\n            15314449116975726182,\n            2870623933631129133,\n            8433855307245599470,\n            9663369547205952712,\n            16656478013118492468,\n            5014296474163082063,\n            15045852603430413673,\n            9039056709562337243,\n            1775730247666171519,\n            10284009922885822735,\n            17264560580274867574,\n            8659184543116501827,\n            9757501208876960807,\n            8107556209186377816,\n            13981920571894003246,\n            8697727621393221097,\n            10111281749746035823,\n            11547580803378751509,\n            9866091897888262831,\n            6932444770006022090,\n            12886358055723945255,\n            5304800874292271788,\n            11523612872653318479,\n            3158091624397075356,\n            17376725070179056084,\n            11353224313201827872,\n            17568378701446022201,\n            7083677611886335059,\n            16630882804589833859,\n            17071293908015663903,\n            3335332823966517520,\n            4551571010812166323,\n            13956655949392024934,\n            11137278406051829526,\n            4896962372622758702,\n            11813643533502615793,\n            4581901117239147425,\n            14593775693535083700,\n            1510447605784811068,\n            5229627540215802358,\n            627282762635294446,\n            4791499629805752429,\n            10361188936025453248,\n            4774699819640096953,\n            13333081235316911046,\n            10942108924892665866,\n            16109048665458409419,\n            15314689190690266823,\n            7310144211471143550,\n            16609282512397289062,\n            4726986969285156208,\n            8190850143304789515,\n            1542721709305293842,\n            12747051062417360628,\n            10431119479932549840,\n            5201202511017795553,\n            7741819653940246707,\n            2687570019862487900,\n            6488374897263692453,\n            13582359095544274953,\n            14484022084752061384,\n            5515018660843652873,\n            8092760845580227599,\n            2766454334996797883,\n            18180569531864904251,\n            3565091373050863067,\n            12322298177624181037,\n            11958316134617603606,\n            9878952926876342598,\n            5302556749713428981,\n            8825508234500799831,\n            11910303768250068310,\n            326451074713852933,\n            396115137030276241,\n            12871099826433440706,\n            4304686608856751519,\n            13291683117058685204,\n            9284558513918029302,\n            3718112862893900571,\n            9149607979222078382,\n            16527849990011073270,\n            7727656976171348203,\n            6573616922619656711,\n            16034045732340296623,\n            5589930567903701070,\n            10683802387965352692,\n            2587318764516570107,\n            10209376077208389402,\n            17079775160514374021,\n            6530000943687323192,\n            3718180221149684880,\n            18189517521112254114,\n            5384059937475335410,\n            609609335008271023,\n            3896142000481106293,\n            16658219747219000806,\n            13778288993082074923,\n            5582595801212065024,\n            14131451705219445462,\n            359265879248692883,\n            16936956071544174710,\n            15873091614777053247,\n            2434660658463974075,\n            2592075329848798604,\n            14194422636533088807,\n            7167203043317150959,\n            11315395284250045497,\n            2099964792961604585,\n            1566230315841355073,\n            16092624371341405050,\n            11961408413498591004,\n            16535764519833385727,\n            16358286323170046012,\n            460344037919559599,\n            14169011134767857411,\n            14106023301858944314,\n            9862229088119368783,\n            3357504073133417614,\n            1102923706048286862,\n            13563108311952119833,\n            2143046275198271992,\n            3979966820061122245,\n            9996599392497104038,\n            18113381312649782606,\n            2789577810558634539,\n            2505893204182156006,\n            5459782976231228406,\n            14606983256382437526,\n            17289593816561860577,\n            18339393907946617355,\n            2258995667690444422,\n            8894197183418385086,\n            18341894792090069275,\n            11391274557331577482,\n            1810514891585419128,\n            7148289154353071487,\n            2119113819713138874,\n            10271861970912805029,\n            7676899172550981679,\n            8624446484952065684,\n            5656835932522160843,\n            16121420157925734770,\n            14082469678115799904,\n            10255722969024722343,\n            1662291548355896945,\n            6389399781869176377,\n            12541949260215847692,\n            7144384677827477175,\n            7282727395448468407,\n            12150328138548453752,\n            3472826938551266818,\n            3748717285404782518,\n            4780951876470252398,\n            16824789631565337027,\n            15839657600800222362,\n            10490421032004326835,\n            13577644447718918237,\n            6631866657761640573,\n            981988710472148081,\n            2178386723930299579,\n            4509700998976576445,\n            7085230111532242363,\n            15742412314382227975,\n            1728841640197493179,\n            9413625884895979097,\n            17011657766150783108,\n            7453240289129863943,\n            14356227040755802558,\n            8727877790598607374,\n            6442754498625288772,\n            7392839418676330133,\n            14897473376443001590,\n            6366239299333724836,\n            9325048183999746407,\n            3440007856498006275,\n            15045549040986890155,\n            14490217742673747202,\n            15278519326741232153,\n            6554990600736077400,\n            14130125167723787542,\n            13808426692316226071,\n            5353065033486249758,\n            1150929840748552011,\n            12174365818942611676,\n            8325746398590604908,\n            1113711086245528668,\n            10314080011282631969,\n            8859099728742225981,\n            17921003815641223868,\n            3105591894080053316,\n            15297241643811159913,\n            17457505649562044023,\n            2057745826478669102,\n            4884750341838598362,\n            16356083315993976675,\n            9101726946186468401,\n            14354106624548323412,\n            9370983965070459320,\n            7738440263290367492,\n            8917029115165607445,\n            2195272365194297011,\n            9558528105439905340,\n            8030625988101552152,\n            3397298078799745318,\n            9736711397155048940,\n            2460615496131263256,\n            15140262761582421804,\n            6475970420636983572,\n            15248938774827950731,\n            3601954052709238929,\n            3331181884995306372,\n            5102925218725345470,\n            3667800919502192980,\n            3004240798812901640,\n            5533280375618915829,\n            5107586811468410440,\n            10224278806003351694,\n            6476631719990351159,\n            2003572440276248817,\n            12145591924789065893,\n            12519472837420433198,\n            17782311381537397376,\n            5661681639850380779,\n            10364042884708771431,\n            1695509166589750758,\n            14618040013233272293,\n            13897753646384009557,\n            3750141258844328560,\n            2521464661853413252,\n            6278261092787958914,\n            10406656955141036872,\n            3275028812461691395,\n            12925016960899871398,\n            9841323801652199824,\n            6731798363764447936,\n            16237427233498849184,\n            18347750732935739357,\n            13607917507344538804,\n            7384152260726915035,\n            5463321849210106032,\n            16371815515677214027,\n            8832632406517327899,\n            8268519393788774229,\n            3669915584804849690,\n            1269556794163966064,\n            17809810670965530193,\n            15840056410475484689,\n            4076484974516366053,\n            9606036112446697020,\n            4868364087195523723,\n            2058736710151928793,\n            10897356652781847288,\n            465078533977740804,\n            16624721881706870960,\n            11964802914009109220,\n            16816447700891974174,\n            3690088264896558634,\n            7147174284749790878,\n            9145833698882950169,\n            8784425020769374260,\n            1861407397398056953,\n            12834090279159906525,\n            7662444631348458158,\n            14132542110004422269,\n            9328868421834468934,\n            16741858393921937122,\n            15694875428320019398,\n            14994603044491181705,\n            9746169230120941506,\n            7938113624909327958,\n            13340368850853929072,\n            7651461065837541114,\n            4476063835934825867,\n            8693815106327834329,\n            4988903731011095573,\n            4462304735549234904,\n            8428813472483033040,\n            4788353502021621362,\n            12565779699104064716,\n            3068625859269266553,\n            2676497072041684077,\n            6224517250248606913,\n            10155182336700912649,\n            4789285195609433162,\n            16223567669480014548,\n            7428311545244653529,\n            16614898660347133660,\n            18158662267123053326,\n            3623664384860961629,\n            7652479537264294496,\n            8606705184150939035,\n            8275137754514789786,\n            1964775551555279291,\n            1438900651657172959,\n            17673106577623030111,\n            6973507447558830112,\n            15423010115647882749,\n            3472057791767023426,\n            5848284772473138216,\n            2890665771216618892,\n            9314934874321984084,\n            8734072522843080836,\n            14327114341827253389,\n            4434569283869444664,\n            12983438456823218137,\n            10233784466676928341,\n            16291964559077701283,\n            9678367439362828938,\n            7822571001351685129,\n            15858728294074423230,\n            10852593355325202465,\n            12352889154252904310,\n            12472638922147628465,\n            858263613939813395,\n            12316650043304516782,\n            15905737765854758582,\n            5901848627660760442,\n            8757164316447879955,\n            1327307879496998670,\n            16419197412056777506,\n            11241454192064071141,\n            5669708276938693043,\n            3575232442870910395,\n            17428985550073658716,\n            15774059386607531181,\n            16583828728361725400,\n            2690073375909258220,\n            3913838352065921651,\n            11930346452395449553,\n            7508883471181453189,\n            1979183109855731075,\n            17205167019849574415,\n            6202127415457809639,\n            15616037631795263171,\n            13758692529633453573,\n            4703023550466089121,\n            6440538290327762255,\n            4617056828336967974,\n            1016260815990065725,\n            10542530738319933236,\n            13839074645977905740,\n            6298401080101494064,\n            18179185785092266771,\n            808757022663954675,\n            655320984483308172,\n            6492165610369841580,\n            10622849106810507658,\n            3627981030815073084,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_fail_1() {\n    let mut out = vec![10; 4];\n    let xs = series(6, 3);\n    limbs_mul_greater_to_out_basecase(&mut out, &xs, &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_fail_2() {\n    let mut out = vec![10; 5];\n    let ys = series(1, 3);\n    limbs_mul_greater_to_out_basecase(&mut out, &[6, 7], &ys);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_fail_3() {\n    let mut out = vec![10; 3];\n    limbs_mul_greater_to_out_basecase(&mut out, &[6, 7], &[]);\n}\n\nfn limbs_mul_basecase_helper(out: &[Limb], xs: &[Limb], ys: &[Limb]) -> Vec<Limb> {\n    let mut out = out.to_vec();\n    let old_out = out.clone();\n    limbs_mul_greater_to_out_basecase(&mut out, xs, ys);\n    let n = Natural::from_limbs_asc(xs) * Natural::from_limbs_asc(ys);\n    let len = xs.len() + ys.len();\n    let mut limbs = n.into_limbs_asc();\n    limbs.resize(len, 0);\n    assert_eq!(limbs, &out[..len]);\n    assert_eq!(&out[len..], &old_out[len..]);\n    out\n}\n\n#[test]\nfn limbs_mul_greater_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 1024);\n    config.insert(\"mean_stripe_n\", 512 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_2().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let old_out = out.clone();\n        let expected_out = limbs_mul_basecase_helper(&out, &xs, &ys);\n        let mut mul_scratch = vec![0; limbs_mul_greater_to_out_scratch_len(xs.len(), ys.len())];\n        let highest_result_limb = limbs_mul_greater_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        assert_eq!(highest_result_limb, out[xs.len() + ys.len() - 1]);\n        let out_len = xs.len() + ys.len();\n        assert_eq!(&out[..out_len], &expected_out[..out_len]);\n        let mut out = old_out;\n        limbs_mul_greater_to_out_basecase_mem_opt(&mut out, &xs, &ys);\n        assert_eq!(out, expected_out);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_to_out() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before;\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(xs.len(), ys.len())];\n        limbs_mul_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        assert_eq!(out, out_after);\n    };\n    test(vec![2], vec![3], vec![10; 3], vec![6, 0, 10]);\n    test(\n        vec![1; 3],\n        series(1, 3),\n        vec![5; 8],\n        vec![1, 3, 6, 5, 3, 0, 5, 5],\n    );\n    test(series(1, 3), vec![6, 7], vec![0; 5], vec![6, 19, 32, 21, 0]);\n    test(vec![6, 7], series(1, 3), vec![0; 5], vec![6, 19, 32, 21, 0]);\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10; 7],\n        vec![10200, 20402, 30605, 20402, 10200, 0, 10],\n    );\n    test(vec![u32::MAX], vec![1], vec![10; 3], vec![u32::MAX, 0, 10]);\n    test(\n        vec![u32::MAX],\n        vec![u32::MAX],\n        vec![10; 4],\n        vec![1, u32::MAX - 1, 10, 10],\n    );\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![10; 6],\n        vec![1, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_to_out_fail_1() {\n    let mut out = vec![10, 10, 10];\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(2, 2)];\n    limbs_mul_to_out(&mut out, &[6, 7], &[1, 2], &mut mul_scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_to_out_fail_2() {\n    let mut out = vec![10, 10, 10, 10];\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(1, 3)];\n    limbs_mul_to_out(&mut out, &[], &[1, 2, 3], &mut mul_scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_to_out_fail_3() {\n    let mut out = vec![10, 10, 10, 10];\n    let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(1, 1)];\n    limbs_mul_to_out(&mut out, &[1, 2, 3], &[], &mut mul_scratch);\n}\n\n#[test]\nfn limbs_mul_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_3().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let old_out = out.clone();\n        let mut mul_scratch = vec![0; limbs_mul_to_out_scratch_len(xs.len(), ys.len())];\n        let highest_result_limb = limbs_mul_to_out(&mut out, &xs, &ys, &mut mul_scratch);\n        assert_eq!(highest_result_limb, out[xs.len() + ys.len() - 1]);\n        let len = xs.len() + ys.len();\n        let n = Natural::from_owned_limbs_asc(xs) * Natural::from_owned_limbs_asc(ys);\n        let mut limbs = n.into_limbs_asc();\n        limbs.resize(len, 0);\n        assert_eq!(limbs, &out[..len]);\n        assert_eq!(&out[len..], &old_out[len..]);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_22() {\n    let test = |xs: &[Limb], ys: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_22_scratch_len(xs.len(), ys.len())];\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_toom_22(&mut out, xs, ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - s != n\n    // - !(xs0[s] == 0 && limbs_cmp_same_length(&xs0[..s], xs1) == Less)\n    // - t != n\n    // - slice_test_zero(&ys0[t..]) && limbs_cmp_same_length(&ys0[..t], ys1) != Less\n    // - s <= t\n    // - !v_neg_1_neg\n    // - carry <= 2\n    test(\n        &series(2, 3),\n        &series(3, 3),\n        &[10; 6],\n        &[6, 17, 34, 31, 20, 0],\n    );\n    // - xs0[s] == 0 && limbs_cmp_same_length(&xs0[..s], xs1) == Less\n    // - v_neg_1_neg\n    test(\n        &[2, 0, 4],\n        &[3, 4, 5],\n        &[10, 10, 10, 10, 10, 10],\n        &[6, 8, 22, 16, 20, 0],\n    );\n    test(&[1; 3], &series(1, 3), &[5; 8], &[1, 3, 6, 5, 3, 0, 5, 5]);\n    // - s == n\n    // - limbs_cmp_same_length(ys0, ys1) != Less\n    // - t == n\n    // - limbs_cmp_same_length(ys0, ys1) == Less\n    test(&[1; 4], &series(1, 4), &[5; 8], &[1, 3, 6, 10, 9, 7, 4, 0]);\n    // - limbs_cmp_same_length(&a0[..n], &a1[..n]) == Less\n    // - limbs_cmp_same_length(&b0[..n], &b1[..n]) != Less\n    test(&series(1, 4), &[1; 4], &[5; 8], &[1, 3, 6, 10, 9, 7, 4, 0]);\n    // - slice_test_zero(&ys0[t..]) && limbs_cmp_same_length(&ys0[..t], ys1) == Less\n    test(\n        &series(1, 5),\n        &[1, 0, 0, 4],\n        &[5; 9],\n        &[1, 2, 3, 8, 13, 12, 16, 20, 0],\n    );\n    // - s > t\n    test(&[1; 4], &series(1, 3), &[5; 8], &[1, 3, 6, 6, 5, 3, 0, 5]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10; 7],\n        &[10200, 20402, 30605, 20402, 10200, 0, 10],\n    );\n    let xs = rle_decode(&[(u32::MAX, 8), (4294950911, 1), (u32::MAX, 21), (536870911, 1), (0, 25)]);\n    let ys = rle_decode(&[(u32::MAX, 2), (4294963199, 1), (u32::MAX, 18), (268435455, 1), (0, 34)]);\n    let out_len = xs.len() + ys.len();\n    // - carry > 2\n    test(\n        &xs,\n        &ys,\n        &vec![10; out_len],\n        &rle_decode(&[\n            (1, 1),\n            (0, 1),\n            (4096, 1),\n            (0, 5),\n            (16384, 1),\n            (0, 1),\n            (67108864, 1),\n            (0, 10),\n            (4026531840, 1),\n            (u32::MAX, 8),\n            (3758095359, 1),\n            (u32::MAX, 2),\n            (4294966783, 1),\n            (u32::MAX, 18),\n            (33554431, 1),\n            (0, 59),\n        ]),\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_22_fail_1() {\n    let mut scratch = vec![];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_22(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_22_fail_2() {\n    let mut scratch = vec![];\n    let mut out = vec![10; 7];\n    let xs = series(6, 3);\n    let ys = series(1, 4);\n    limbs_mul_greater_to_out_toom_22(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_22_fail_3() {\n    let mut scratch = vec![];\n    let mut out = vec![10; 7];\n    let xs = series(6, 4);\n    limbs_mul_greater_to_out_toom_22(&mut out, &xs, &[1, 2], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_22_fail_4() {\n    let mut scratch = vec![];\n    let mut out = vec![10; 7];\n    let xs = series(6, 3);\n    limbs_mul_greater_to_out_toom_22(&mut out, &xs, &[1, 2], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_22_fail_5() {\n    let mut scratch = vec![];\n    let mut out = vec![10; 4];\n    let xs = series(6, 3);\n    let ys = series(1, 3);\n    limbs_mul_greater_to_out_toom_22(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_22_fail_6() {\n    let mut scratch = vec![];\n    let mut out = vec![10; 4];\n    let xs = series(6, 3);\n    limbs_mul_greater_to_out_toom_22(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_22_fail_7() {\n    let mut scratch = vec![];\n    let mut out = vec![10; 4];\n    let xs = series(6, 3);\n    let ys = series(1, 4);\n    limbs_mul_greater_to_out_toom_22(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_32() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_32(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - !(ap1hi == 0 && limbs_cmp_same_length(ap1, xs1) == Less)\n    // - t == n\n    // - limbs_cmp_same_length(ys0, ys1) == Less\n    // - ap1hi != 1 and ap1hi != 2\n    // - !bp1hi\n    // - hi == 0 first time\n    // - v_neg_1_neg\n    // - s <= t\n    // - s + t > n\n    // - hi >= 0 second time\n    test(\n        series(2, 6),\n        series(3, 4),\n        vec![10; 10],\n        vec![6, 17, 34, 58, 76, 94, 88, 71, 42, 0],\n    );\n    // - limbs_cmp_same_length(ys0, ys1) != Less\n    // - ap1hi == 2\n    // - bp1hi\n    // - !v_neg_1_neg\n    test(\n        vec![u32::MAX; 6],\n        vec![u32::MAX; 4],\n        vec![10; 10],\n        vec![1, 0, 0, 0, u32::MAX, u32::MAX, u32::MAX - 1, u32::MAX, u32::MAX, u32::MAX],\n    );\n    // - ap1hi == 0 && limbs_cmp_same_length(ap1, xs1) == Less\n    test(\n        vec![0, 0, 1, 1, 0, 1],\n        vec![0, 0, 0, 1],\n        vec![10; 10],\n        vec![0, 0, 0, 0, 0, 1, 1, 0, 1, 0],\n    );\n    // - t != n\n    // - slice_test_zero(&ys0[t..]) && limbs_cmp_same_length(&ys0[..t], ys1) == Less\n    // - s + t <= n\n    test(\n        vec![0, 0, 0, 0, 0, 0, 1],\n        vec![0, 0, 0, 0, 1],\n        vec![10; 12],\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    );\n    // - !(slice_test_zero(&ys0[t..]) && limbs_cmp_same_length(&ys0[..t], ys1) == Less)\n    test(\n        vec![0, 0, 0, 0, 0, 0, 1],\n        vec![0, 0, 1, 0, 1],\n        vec![10; 12],\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],\n    );\n    // - s > t\n    test(\n        series(1, 9),\n        vec![9, 8, 7, 6, 5],\n        vec![10; 14],\n        vec![9, 26, 50, 80, 115, 150, 185, 220, 255, 200, 146, 94, 45, 0],\n    );\n    // - ap1hi == 1\n    test(\n        vec![2543705880, 1859419010, 3343322808, 1165039137, 1872701663, 1957510151, 1589243046],\n        vec![1919189400, 1295801997, 354566481, 1212146910, 1886225431],\n        vec![10; 14],\n        vec![\n            1753714240, 1114397484, 4100081063, 2352383720, 667557204, 920036609, 2291920497,\n            3338154324, 3806846000, 1880963052, 291601955, 697949587, 10, 10,\n        ],\n    );\n    // - hi != 0 first time\n    test(\n        vec![706760835, 4153647095, 3843998199, 2077172825, 1158686949, 3157624247],\n        vec![2847735618, 2779635711, 2471732382, 2655639495],\n        vec![10; 10],\n        vec![\n            2814066374, 2022835469, 2101335047, 312674723, 2952296274, 1055977952, 590716674,\n            290888444, 3944399226, 1952404077,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_32_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_32(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_32_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(3, 4)];\n    let mut out = vec![10; 7];\n    let xs = series(6, 3);\n    let ys = series(1, 4);\n    limbs_mul_greater_to_out_toom_32(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_32_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(5, 4)];\n    let mut out = vec![10; 9];\n    let xs = series(6, 5);\n    let ys = series(1, 4);\n    limbs_mul_greater_to_out_toom_32(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_32_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(6, 3)];\n    let mut out = vec![10; 9];\n    let xs = series(6, 6);\n    let ys = series(1, 3);\n    limbs_mul_greater_to_out_toom_32(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_32_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(3, 0)];\n    let mut out = vec![10; 4];\n    let xs = series(6, 3);\n    limbs_mul_greater_to_out_toom_32(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_32_fail_6() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_32_scratch_len(6, 4)];\n    let mut out = vec![10; 9];\n    let xs = series(6, 6);\n    let ys = series(1, 4);\n    limbs_mul_greater_to_out_toom_32(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_33() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_33(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - carry == 0 && limbs_cmp_same_length(&gp[..n], xs_1) == Less\n    // - s != n\n    // - carry == 0 && limbs_cmp_same_length(&gp[..n], ys_1) == Less\n    // - t != n\n    // - s <= t\n    // - !v_neg_1\n    // - two_r <= k + 1\n    test(\n        series(2, 5),\n        series(3, 5),\n        vec![10; 10],\n        vec![6, 17, 34, 58, 90, 94, 88, 71, 42, 0],\n    );\n    // - s > t\n    test(\n        series(2, 6),\n        series(3, 5),\n        vec![10; 11],\n        vec![6, 17, 34, 58, 90, 115, 116, 106, 84, 49, 0],\n    );\n    // - v_neg_1\n    // - two_r > k + 1\n    test(\n        series(2, 9),\n        series(3, 8),\n        vec![10; 17],\n        vec![6, 17, 34, 58, 90, 131, 182, 244, 296, 315, 320, 310, 284, 241, 180, 100, 0],\n    );\n    test(\n        series(3, 5),\n        series(2, 5),\n        vec![10; 10],\n        vec![6, 17, 34, 58, 90, 94, 88, 71, 42, 0],\n    );\n    // - !(carry == 0 && limbs_cmp_same_length(&gp[..n], xs_1) == Less)\n    // - !(carry == 0 && limbs_cmp_same_length(&gp[..n], ys_1) == Less)\n    test(\n        vec![u32::MAX; 5],\n        vec![u32::MAX; 5],\n        vec![10; 10],\n        vec![1, 0, 0, 0, 0, u32::MAX - 1, u32::MAX, u32::MAX, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_33_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_33(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_33_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(5, 5)];\n    let mut out = vec![10; 11];\n    let xs = series(6, 5);\n    let ys = series(1, 6);\n    limbs_mul_greater_to_out_toom_33(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_33_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(5, 5)];\n    let mut out = vec![10; 9];\n    let xs = series(6, 5);\n    let ys = series(1, 4);\n    limbs_mul_greater_to_out_toom_33(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_33_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(5, 5)];\n    let mut out = vec![10; 5];\n    let xs = series(6, 5);\n    limbs_mul_greater_to_out_toom_33(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_33_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_33_scratch_len(6, 6)];\n    let mut out = vec![10; 9];\n    let xs = series(6, 6);\n    let ys = series(1, 5);\n    limbs_mul_greater_to_out_toom_33(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_42() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_42(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - v_neg_1_neg\n    // - t == n\n    // - limbs_cmp_same_length(ys_0, ys_1) == Less\n    // - s <= t\n    // - as1[n] not 1, 2, or 3\n    test(\n        series(2, 4),\n        vec![3, 4],\n        vec![10; 7],\n        vec![6, 17, 24, 31, 20, 0, 10],\n    );\n    // - !v_neg_1_neg\n    // - s != n\n    // - t != n\n    // - !(slice_test_zero(&ys_0[t..]) && limbs_cmp_same_length(&ys_0[..t], ys_1) == Less)\n    test(\n        series(2, 7),\n        series(3, 3),\n        vec![10; 10],\n        vec![6, 17, 34, 46, 58, 70, 82, 67, 40, 0],\n    );\n    // - s > t\n    test(\n        series(2, 8),\n        series(3, 3),\n        vec![10; 11],\n        vec![6, 17, 34, 46, 58, 70, 82, 94, 76, 45, 0],\n    );\n    // - limbs_cmp_same_length(ys_0, ys_1) != Less\n    test(\n        vec![0, 0, 0, 1],\n        vec![1, 1],\n        vec![10; 6],\n        vec![0, 0, 0, 1, 1, 0],\n    );\n    // - as1[n] == 1\n    test(\n        vec![\n            2363703565, 2011430902, 405935879, 3293866119, 79230945, 4067912411, 54522599,\n            3863530924, 2648195217, 3696638907, 2693775185, 2466180916, 2288038816, 3085875921,\n            2622914893, 3412444602, 1714899352, 1458044565, 4160795266,\n        ],\n        vec![\n            2010684769, 395852000, 1475286147, 263729287, 1827966398, 926833006, 3647866695,\n            2299638628,\n        ],\n        vec![10; 27],\n        vec![\n            2935529197, 2628679470, 2989406385, 4135607148, 3098618197, 1986483787, 2969118597,\n            4064944337, 1353361316, 3300804798, 3539475248, 1813351909, 4189109323, 1508204245,\n            3032195050, 2111172804, 2647234523, 763063403, 499753337, 484003129, 951290762,\n            31889895, 4291170933, 743974460, 931456782, 3403938046, 2227799389,\n        ],\n    );\n    // - bs1[n] != 0\n    test(\n        vec![\n            1023706198, 1055957821, 62637438, 3129002448, 1343635842, 1979891039, 2332614953,\n            820715064, 126240740, 3763174513, 874511155, 1433571832, 1799667271, 828081508,\n            1790140791, 3456862168, 182082249,\n        ],\n        vec![\n            272565221, 2271318511, 3915555663, 752672586, 2086228575, 93709012, 4089106295,\n            1296382745, 4014782836, 4084383484,\n        ],\n        vec![10; 27],\n        vec![\n            2478924526, 600853546, 3764116188, 869876026, 49911338, 2430145334, 1531060628,\n            4131353567, 2147110402, 1698823317, 3610138028, 2221603642, 2262453949, 2700908655,\n            2085097953, 1179421079, 2314185794, 3274969801, 956808943, 183640877, 769743340,\n            2499732116, 168215214, 1611459466, 1659741921, 3303732250, 173154690,\n        ],\n    );\n    // - as1[n] == 2\n    test(\n        vec![\n            0xfffff,\n            0,\n            0,\n            4294965248,\n            0x1ffffff,\n            0,\n            0,\n            0,\n            4294966784,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0,\n            0x80000000,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        vec![u32::MAX, u32::MAX, u32::MAX, 2047, 0, 0, 4294705152, u32::MAX],\n        vec![10; 27],\n        vec![\n            4293918721,\n            u32::MAX,\n            u32::MAX,\n            0x7fffffff,\n            4261412864,\n            u32::MAX,\n            4291035135,\n            4294967231,\n            1049102,\n            0x20000000,\n            0,\n            4293914624,\n            0x1fffffe,\n            0x80000000,\n            0x8000000,\n            2048,\n            4294966784,\n            4294966271,\n            4294705151,\n            u32::MAX - 1,\n            0x20000,\n            0x80000000,\n            2047,\n            0,\n            0,\n            4294705152,\n            u32::MAX,\n        ],\n    );\n    // - asm1[n] != 0\n    test(\n        vec![3338024033, 1570788701, 4067509056, 680440343],\n        vec![599772085, 925834366],\n        vec![10; 6],\n        vec![1056633749, 686831275, 2758938475, 3727232403, 1859912609, 146677497],\n    );\n    // - as1[n] == 3\n    test(\n        vec![4030415682, 3643742328, 2586387240, 3719633661],\n        vec![708497006, 797041707],\n        vec![10; 6],\n        vec![4203348572, 3202027474, 4170951291, 2012723103, 3609216593, 690273745],\n    );\n    // - slice_test_zero(&ys_0[t..]) && limbs_cmp_same_length(&ys_0[..t], ys_1) == Less\n    test(\n        vec![\n            0,\n            u32::MAX,\n            u32::MAX,\n            0xfffff,\n            0xfffffff0,\n            u32::MAX,\n            63,\n            0,\n            0x80000000,\n            u32::MAX,\n            u32::MAX,\n        ],\n        vec![0xffff, 0, 0, 4294967264],\n        vec![10; 15],\n        vec![\n            0,\n            4294901761,\n            u32::MAX,\n            4293918719,\n            4293918783,\n            u32::MAX - 1,\n            4265607103,\n            1049087,\n            0x7ffffff0,\n            4294932480,\n            63,\n            0xffff,\n            2147483664,\n            u32::MAX,\n            4294967263,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_42_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_42(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_42_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(5, 6)];\n    let mut out = vec![10; 11];\n    let xs = series(6, 5);\n    let ys = series(1, 6);\n    limbs_mul_greater_to_out_toom_42(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_42_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(3, 2)];\n    let mut out = vec![10; 9];\n    let xs = series(6, 3);\n    limbs_mul_greater_to_out_toom_42(&mut out, &xs, &[1, 2], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_42_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(5, 0)];\n    let mut out = vec![10; 5];\n    let xs = series(6, 5);\n    limbs_mul_greater_to_out_toom_42(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_42_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_42_scratch_len(4, 2)];\n    let mut out = vec![10; 4];\n    let xs = series(6, 4);\n    limbs_mul_greater_to_out_toom_42(&mut out, &xs, &[1, 2], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_43() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_43(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - n_high < n in limbs_mul_toom_evaluate_deg_3poly_in_2and_neg_2\n    // - !v_neg_2neg in limbs_mul_toom_evaluate_deg_3poly_in_2and_neg_2\n    // - limbs_cmp_same_length(small_scratch, bsm1) != Less\n    // - s <= t\n    // - !v_neg_2neg in limbs_mul_toom_interpolate_6points\n    // - !v_neg_1_neg in limbs_mul_toom_interpolate_6points\n    // - n_high > n in limbs_mul_toom_interpolate_6points\n    // - special_carry_1 <= special_carry_2\n    test(\n        series(2, 11),\n        series(3, 9),\n        vec![10; 20],\n        vec![\n            6, 17, 34, 58, 90, 131, 182, 244, 318, 381, 444, 468, 476, 467, 440, 394, 328, 241,\n            132, 0,\n        ],\n    );\n    // - n_high >= n in limbs_mul_toom_evaluate_deg_3poly_in_2and_neg_2\n    // - v_neg_2neg in limbs_mul_toom_evaluate_deg_3poly_in_2and_neg_2\n    // - t != n\n    // - limbs_cmp_same_length(small_scratch, bsm1) == Less\n    // - *bsm1last == 0 && limbs_cmp_same_length(bsm1init, ys_1) == Less\n    // - s > t\n    test(\n        series(2, 12),\n        series(3, 8),\n        vec![10; 20],\n        vec![\n            6, 17, 34, 58, 90, 131, 182, 244, 296, 348, 400, 452, 462, 455, 430, 386, 322, 237,\n            130, 0,\n        ],\n    );\n    // - v_neg_2neg in limbs_mul_toom_interpolate_6points\n    // - v_neg_1_neg in limbs_mul_toom_interpolate_6points\n    // - n_high <= n in limbs_mul_toom_interpolate_6points\n    test(\n        series(2, 19),\n        series(3, 11),\n        vec![10; 30],\n        vec![\n            6, 17, 34, 58, 90, 131, 182, 244, 318, 405, 506, 594, 682, 770, 858, 946, 1034, 1122,\n            1210, 1235, 1236, 1212, 1162, 1085, 980, 846, 682, 487, 260, 0,\n        ],\n    );\n    // - special_carry_1 > special_carry_2\n    test(\n        vec![\n            3785023459, 4249117725, 1551102690, 4239134101, 2264608302, 1455009194, 3261002629,\n            2233313730, 3807192178, 2550029068, 1259253479, 2657422450,\n        ],\n        vec![\n            2921127090, 3493254221, 1579329255, 2624469567, 1678656523, 1653055771, 493445097,\n            1702866165, 1046762910,\n        ],\n        vec![10; 21],\n        vec![\n            3169501142, 3910307595, 310092603, 1408815552, 1786334527, 2452212521, 670758829,\n            4142968613, 1110881016, 3529286248, 2119180760, 3066268191, 1902231557, 1262478906,\n            4083142666, 784312035, 3990199726, 3180402195, 1845375516, 421486236, 647662966,\n        ],\n    );\n    test(\n        vec![\n            0,\n            0,\n            0,\n            4286578688,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            7,\n            0,\n            0,\n            0,\n            0,\n            0xfffffff0,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        vec![\n            0x7fffffff,\n            0xfffff000,\n            0x1fffff,\n            0,\n            0,\n            0,\n            2147483520,\n            0,\n            0xfffffff0,\n            u32::MAX,\n            u32::MAX,\n            4290789375,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n        vec![10; 35],\n        vec![\n            0,\n            0,\n            0,\n            0x800000,\n            4290772992,\n            7,\n            0xfffff000,\n            u32::MAX,\n            u32::MAX,\n            0x3fffffff,\n            4290772984,\n            134184963,\n            0x1000000,\n            0,\n            0,\n            8176,\n            64504,\n            4261412868,\n            4294967167,\n            2139095038,\n            0xfffff000,\n            4263643135,\n            0xfffffff7,\n            255,\n            0,\n            2147483520,\n            66846728,\n            0xfffffff0,\n            u32::MAX,\n            u32::MAX,\n            4290789375,\n            4294967279,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_43() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_43(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(\n        vec![\n            18446744073701163071,\n            u64::MAX,\n            u64::MAX,\n            0xfffffffff,\n            0,\n            0,\n            0,\n            0,\n            18446743936270598144,\n            u64::MAX,\n            u64::MAX,\n            u64::MAX,\n            0x3ffff,\n            0,\n            0,\n            0,\n            0xffff000000000000,\n            0x7fff,\n            0,\n            0,\n            18446744073709518848,\n            u64::MAX,\n            u64::MAX,\n            u64::MAX,\n            u64::MAX,\n        ],\n        vec![\n            18437736874454810624,\n            0xfffff,\n            0,\n            18446744039349813248,\n            u64::MAX,\n            u64::MAX,\n            u64::MAX,\n            0x7fffffffffff,\n            0,\n            0xfffffffffffffff0,\n            u64::MAX,\n            u64::MAX,\n            0x7ffffff,\n            18446744056529682432,\n            u64::MAX,\n            u64::MAX,\n        ],\n        vec![10; 41],\n        vec![\n            17879290520660869120,\n            18446735277682593791,\n            u64::MAX,\n            288228211488194559,\n            72057594004373504,\n            0,\n            0,\n            8866461766385536,\n            18446744073709551552,\n            18302628885835021327,\n            u64::MAX,\n            0x7ffff,\n            18445617082746798336,\n            144114380622004095,\n            0,\n            9214364837600034816,\n            18446744073700114495,\n            2336462208959,\n            34359738336,\n            0x1000000000,\n            18445618173803233282,\n            18446744039345618958,\n            127,\n            0x4000000000000,\n            4611721063213039616,\n            18437736874454810624,\n            0x7ffff,\n            13835058055282163712,\n            18446744039350075391,\n            4398047033343,\n            18446181123756392448,\n            u64::MAX,\n            18446598938174685183,\n            562949953454079,\n            0xfffffffffffffff0,\n            u64::MAX,\n            18446744073709518847,\n            0x7ffffff,\n            18446744056529682432,\n            u64::MAX,\n            u64::MAX,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_43_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_43(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_43_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(11, 12)];\n    let mut out = vec![10; 23];\n    let xs = series(3, 11);\n    let ys = series(2, 12);\n    limbs_mul_greater_to_out_toom_43(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_43_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(11, 8)];\n    let mut out = vec![10; 19];\n    let xs = series(3, 11);\n    let ys = series(2, 8);\n    limbs_mul_greater_to_out_toom_43(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_43_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(12, 0)];\n    let mut out = vec![10; 12];\n    let xs = series(3, 11);\n    limbs_mul_greater_to_out_toom_43(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_43_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_43_scratch_len(4, 2)];\n    let mut out = vec![10; 5];\n    let xs = series(3, 10);\n    let ys = series(2, 10);\n    limbs_mul_greater_to_out_toom_43(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_44() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_44(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - limbs_mul_toom_evaluate_deg_3poly_in_2and_neg_2(bpx, bmx, ys, n, t, &mut scratch[..n + 1])\n    // - limbs_mul_toom_evaluate_deg_3poly_in_1and_neg_1(bpx, bmx, ys, n, t, &mut scratch[..n + 1])\n    // - s <= t\n    // - !w1_neg\n    // - !w3neg\n    // - w6n <= n + 1\n    // - limbs_mul_greater_to_out_basecase in limbs_mul_same_length_to_out_toom_44recursive\n    test(\n        series(2, 4),\n        series(3, 4),\n        vec![10; 8],\n        vec![6, 17, 34, 58, 58, 49, 30, 0],\n    );\n    // - w3neg\n    test(\n        vec![0, 0, 0, 1],\n        vec![0, 0, 1, 1],\n        vec![10; 8],\n        vec![0, 0, 0, 0, 0, 1, 1, 0],\n    );\n    // - w6n > n + 1\n    test(\n        vec![\n            1528859315, 4288784328, 3677151116, 445199233, 3304488688, 3566979465, 3541025426,\n            2491779846, 3112990742, 2583249486, 3403111749, 1930721237,\n        ],\n        vec![\n            2700212626, 3890522506, 1407330442, 2072012244, 292784856, 2848511017, 2011019434,\n            3729188240, 1314875514, 1752114201, 3480385261, 1532349465,\n        ],\n        vec![10; 24],\n        vec![\n            301610262, 3665600695, 2790869988, 562719619, 254881625, 3646308155, 2857045174,\n            4219173388, 3417896791, 458617279, 3882403287, 617740409, 3296542840, 435168928,\n            3570119313, 863483077, 2646855475, 2878510649, 4228994627, 2357119023, 2589237669,\n            2274199643, 3000367783, 688838692,\n        ],\n    );\n    // - s > t\n    test(\n        vec![\n            1588217107, 79108222, 2883552792, 2390312777, 1587172303, 2070384343, 2265280181,\n            4013380367,\n        ],\n        vec![3177381025, 2776698917, 954518943, 3785176644, 3521195169, 550485155, 1499535299],\n        vec![10; 15],\n        vec![\n            2639930611, 1074195093, 3974952249, 2825437951, 3084912647, 2589723741, 1008656003,\n            3022162475, 2305314017, 1619919364, 894905935, 3957960884, 814161571, 756465381,\n            1401222667,\n        ],\n    );\n    // - w1_neg\n    test(\n        vec![\n            1047248630, 339306853, 1100911694, 3907715577, 4281628442, 1447091409, 3425204321,\n            3871347591, 339462242, 1765234031, 3774533011, 980706746,\n        ],\n        vec![\n            1454868694, 1975460471, 2212752551, 1982786615, 983847073, 3073742136, 438698610,\n            1215648998, 2824467771, 3299124311, 2818671068,\n        ],\n        vec![10; 23],\n        vec![\n            2438877604, 4249888081, 2301349363, 1817920534, 2538709343, 1739256708, 179543633,\n            2275519806, 1688820820, 759475921, 3927834077, 2138533648, 958932069, 2429920287,\n            3858014276, 2853106604, 1837491388, 1616377262, 231659922, 680814190, 417532392,\n            428918230, 643611358,\n        ],\n    );\n    test(\n        vec![986333060, 254638637, 1577120658, 1458096412, 474582958, 4115735719, 4031007047],\n        vec![2096725444, 3871299248, 1414038108, 2617834141, 1553210626, 2669030715, 3093885541],\n        vec![10; 14],\n        vec![\n            2067797264, 3922708625, 2600678884, 825822853, 2499590824, 1035492325, 1957325707,\n            1890833276, 3433274404, 1510974136, 2269171082, 854613327, 1796482159, 2903741417,\n        ],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_44() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_44(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(\n        series(2, 4),\n        series(3, 4),\n        vec![10; 8],\n        vec![6, 17, 34, 58, 58, 49, 30, 0],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_44_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(1, 1)];\n    let mut out = vec![10; 10];\n    limbs_mul_greater_to_out_toom_44(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_44_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(4, 4)];\n    let mut out = vec![10; 9];\n    let xs = series(3, 4);\n    let ys = series(2, 5);\n    limbs_mul_greater_to_out_toom_44(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_44_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(3, 3)];\n    let mut out = vec![10; 6];\n    let xs = series(3, 3);\n    let ys = series(2, 3);\n    limbs_mul_greater_to_out_toom_44(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_44_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(11, 11)];\n    let mut out = vec![10; 11];\n    let xs = series(3, 11);\n    limbs_mul_greater_to_out_toom_44(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_44_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_44_scratch_len(4, 4)];\n    let mut out = vec![10; 7];\n    let xs = series(3, 4);\n    let ys = series(2, 4);\n    limbs_mul_greater_to_out_toom_44(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_52() {\n    let test = |xs: &[Limb], ys: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_52_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_52(&mut out, xs, ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - degree.even() in limbs_mul_toom_evaluate_poly_in_2and_neg_2\n    // - !v_neg_2neg in limbs_mul_toom_evaluate_poly_in_2and_neg_2\n    // - t != n\n    // - !(slice_test_zero(&ys_0[t..]) && limbs_cmp_same_length(&ys_0[..t], ys_1) == Less)\n    // - !v_neg_1_neg\n    // - !(slice_test_zero(&bsm1[t..]) && limbs_cmp_same_length(&bsm1[..t], ys_1) == Less)\n    // - degree.even() in limbs_mul_toom_evaluate_poly_in_1and_neg_1\n    // - !v_neg_1_neg in limbs_mul_toom_evaluate_poly_in_1and_neg_1\n    test(\n        &series(2, 15),\n        &series(3, 5),\n        &[10; 20],\n        &[\n            6, 17, 34, 58, 90, 115, 140, 165, 190, 215, 240, 265, 290, 315, 340, 314, 268, 201,\n            112, 0,\n        ],\n    );\n    test(\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        &[0, 0, 0, 0, 1, 0],\n        &[10; 20],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    );\n    // - n_high != n in limbs_mul_toom_evaluate_poly_in_2and_neg_2\n    // - t == n\n    // - limbs_cmp_same_length(ys_0, ys_1) == Less\n    // - v_neg_1_neg\n    test(\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        &[0, 0, 0, 0, 0, 1],\n        &[10; 20],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    );\n    // - slice_test_zero(&ys_0[t..]) && limbs_cmp_same_length(&ys_0[..t], ys_1) == Less\n    test(\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        &[0, 0, 0, 0, 1],\n        &[10; 20],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    );\n    // - limbs_cmp_same_length(ys_0, ys_1) != Less\n    // - limbs_cmp_same_length(bsm1, ys_1) == Less\n    test(\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        &[0, 0, 1, 0, 0, 1],\n        &[10; 20],\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0],\n    );\n    // - v_neg_2neg in limbs_mul_toom_evaluate_poly_in_2and_neg_2\n    // - v_neg_1_neg in limbs_mul_toom_evaluate_poly_in_1and_neg_1\n    // - limbs_mul_toom_evaluate_poly_in_1and_neg_1(as1, asm1, 4, xs, n, s, &mut v_neg_1[..m])\n    test(\n        &[\n            281500646, 1572406350, 108746052, 4056047843, 89307364, 1006007374, 2902260577,\n            1250995384, 1556873818, 3846421711, 280743259, 1728158805, 467926284, 2330565417,\n        ],\n        &[2509320863, 2201587434, 926371577, 1243694325, 1112023631, 2791032478],\n        &[10; 20],\n        &[\n            1191903194, 1277561191, 2672986331, 45667421, 2742410814, 2602170945, 2815699572,\n            2317624023, 952805243, 577394769, 1002744907, 4175910221, 2433548489, 2550394831,\n            3650814344, 1121996596, 3441179979, 3561879910, 1574546788, 1514489709,\n        ],\n    );\n    // - limbs_cmp_same_length(bsm1, ys_1) != Less\n    test(\n        &[\n            2331447040, 1003213663, 1873981685, 3371337621, 3796896013, 4144448610, 2569252563,\n            2859304641, 1027973602, 3158196152, 4058699545, 2002924383, 3295505824, 695758308,\n        ],\n        &[725028139, 2984864771, 2939417227, 3047223286, 3526157986, 1078000342],\n        &[10; 20],\n        &[\n            474121472, 1561322164, 715684992, 3182777436, 384530074, 3827205870, 2267366778,\n            1586160630, 3779201468, 900553139, 2867049131, 2027414411, 2054056558, 2671776484,\n            3374007062, 3091178442, 1888125000, 2974781424, 307612679, 174629431,\n        ],\n    );\n    // - slice_test_zero(&bsm1[t..]) && limbs_cmp_same_length(&bsm1[..t], ys_1) == Less\n    test(\n        &rle_decode(&[\n            (32767, 1),\n            (0, 5),\n            (4294836224, 1),\n            (u32::MAX, 5),\n            (4278206463, 1),\n            (u32::MAX, 2),\n            (31, 1),\n            (0, 2),\n            (4294443008, 1),\n            (u32::MAX, 7),\n        ]),\n        &[0, 0, u32::MAX, u32::MAX, u32::MAX, 0, 0, 4294967232, u32::MAX, 4227858559, u32::MAX],\n        &[10; 37],\n        &[\n            0,\n            0,\n            4294934529,\n            u32::MAX,\n            u32::MAX,\n            0x7ffe,\n            0,\n            4292870208,\n            0x1ffff,\n            71303040,\n            4294966784,\n            4294868990,\n            u32::MAX,\n            0x7fffff,\n            16760832,\n            0xff000000,\n            2047,\n            4278075360,\n            u32::MAX,\n            1072693247,\n            524320,\n            2149580800,\n            259839,\n            4277682176,\n            2147487743,\n            0x1ffffff,\n            32,\n            4227858432,\n            8190,\n            4294443008,\n            u32::MAX,\n            0,\n            0,\n            4294967232,\n            u32::MAX,\n            4227858559,\n            u32::MAX,\n        ],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_52() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_52_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_52(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        vec![0, 0, 0, 0, 1, 0],\n        vec![10; 20],\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_52_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_52_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_52(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_52_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_52_scratch_len(15, 16)];\n    let mut out = vec![10; 9];\n    let xs = series(3, 15);\n    let ys = series(3, 16);\n    limbs_mul_greater_to_out_toom_52(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_52_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_52_scratch_len(14, 5)];\n    let mut out = vec![10; 6];\n    let xs = series(3, 14);\n    let ys = series(3, 5);\n    limbs_mul_greater_to_out_toom_52(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_52_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_52_scratch_len(15, 4)];\n    let mut out = vec![10; 7];\n    let xs = series(3, 15);\n    let ys = series(3, 4);\n    limbs_mul_greater_to_out_toom_52(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_52_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_52_scratch_len(11, 0)];\n    let mut out = vec![10; 12];\n    let xs = series(3, 11);\n    limbs_mul_greater_to_out_toom_52(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_53() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_53(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - !(*bs1last == 0 && limbs_cmp_same_length(bs1init, ys_1) == Less)\n    // - limbs_cmp_same_length(bs2, &out[..n + 1]) != Less\n    // - *asm1last != 1 && *asm1last != 2\n    // - *as1last == 0\n    test(\n        series(2, 5),\n        series(3, 3),\n        vec![10; 8],\n        vec![6, 17, 34, 46, 58, 49, 30, 0],\n    );\n    // - *bs1last == 0 && limbs_cmp_same_length(bs1init, ys_1) == Less\n    // - *as1last == 2\n    // - *bs1last == 1\n    test(\n        vec![611094747, 2426195984, 3948451542, 3575143460, 2163084716],\n        vec![1043494367, 2432724646, 1148376235],\n        vec![10; 8],\n        vec![\n            2911651269, 2135822080, 566305911, 1285474929, 3971527858, 1120629777, 2330897846,\n            578359487,\n        ],\n    );\n    // - *as1last == 1\n    test(\n        vec![83336617, 52963853, 1461131367, 615175494, 2376138249],\n        vec![1085015601, 823246134, 3222784883],\n        vec![10; 8],\n        vec![\n            4003668825, 3129188105, 1975732797, 2019047981, 943873016, 1483316813, 305883771,\n            1782966412,\n        ],\n    );\n    // - limbs_cmp_same_length(bs2, &out[..n + 1]) == Less\n    // - *as1last > 2\n    test(\n        vec![\n            3853679659, 4236745288, 2469732913, 4265854402, 4207372271, 1754370134, 137881047,\n            1325109821, 2212043812, 3074170203,\n        ],\n        vec![1666773246, 4177391250, 4175984066, 2859904653, 3320165100, 314964734],\n        vec![10; 16],\n        vec![\n            2336719530, 919351696, 4142757378, 49781824, 1315087108, 2534950116, 2674417418,\n            1178559126, 171926136, 3132896187, 2074730624, 3561766617, 1155879861, 3985534229,\n            380101898, 225439482,\n        ],\n    );\n    // - *asm1last == 1\n    test(\n        vec![4171807709, 1363035595, 2692148345, 3728232161, 2672522097],\n        vec![178202067, 736149219, 623937260],\n        vec![10; 8],\n        vec![\n            2793195559, 2168235304, 1582195836, 18437203, 671570200, 635034059, 2378259056,\n            388241865,\n        ],\n    );\n    // - *bs1last == 2\n    test(\n        vec![361692441, 3665267779, 1770324312, 1221560416, 2810295690],\n        vec![1887715703, 4035171395, 2815003797],\n        vec![10; 8],\n        vec![\n            3298754463, 2516900264, 30373680, 909364693, 729609199, 3973437903, 3392713387,\n            1841921601,\n        ],\n    );\n    // - *bsm1last != 0\n    test(\n        vec![1542637461, 595638956, 1883922642, 2681579369, 2641006916],\n        vec![3723002977, 116606811, 2193352864],\n        vec![10; 8],\n        vec![\n            2246996853, 3232877055, 2347711939, 2476049074, 4132376421, 3855440382, 4040315714,\n            1348708775,\n        ],\n    );\n    // - *asm1last == 2\n    test(\n        vec![4043423637, 312331403, 3088235367, 41162462, 2934893364],\n        vec![2702987034, 4184574368, 2455116868],\n        vec![10; 8],\n        vec![\n            2912448546, 2297161059, 137328692, 115875329, 1975003140, 2441893159, 4034859213,\n            1677662647,\n        ],\n    );\n    test(\n        vec![0x3ffff8, 3221225472, u32::MAX, 1, 4294934528],\n        vec![0, 4294959104, u32::MAX],\n        vec![10; 8],\n        vec![0, 0x10000, 0xfffffff8, 4196343, 3221209088, 0xfffffff, 4294959106, 4294934527],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_53() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_53(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(\n        vec![u64::MAX, u64::MAX, 3, u64::MAX - 1, u64::MAX],\n        vec![u64::MAX, u64::MAX, u64::MAX],\n        vec![10; 8],\n        vec![1, 0, 0xfffffffffffffffc, 0, 0, 3, u64::MAX - 1, u64::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_53_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_53(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_53_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(5, 6)];\n    let mut out = vec![10; 11];\n    let xs = series(3, 5);\n    let ys = series(3, 6);\n    limbs_mul_greater_to_out_toom_53(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_53_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(5, 4)];\n    let mut out = vec![10; 9];\n    let xs = series(3, 5);\n    let ys = series(3, 4);\n    limbs_mul_greater_to_out_toom_53(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_53_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(4, 3)];\n    let mut out = vec![10; 6];\n    let xs = series(3, 4);\n    let ys = series(3, 3);\n    limbs_mul_greater_to_out_toom_53(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_53_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(5, 2)];\n    let mut out = vec![10; 7];\n    let xs = series(3, 5);\n    limbs_mul_greater_to_out_toom_53(&mut out, &xs, &[3, 4], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_53_fail_6() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_53_scratch_len(5, 0)];\n    let mut out = vec![10; 12];\n    let xs = series(3, 5);\n    limbs_mul_greater_to_out_toom_53(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_54() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_54_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_54(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - degree.even() in limbs_mul_toom_evaluate_poly_in_2pow_and_neg_2pow\n    // - !v_neg_2pow_neg in limbs_mul_toom_evaluate_poly_in_2pow_and_neg_2pow\n    // - degree.odd() in limbs_mul_toom_evaluate_poly_in_2pow_and_neg_2pow\n    // - !y_sign in limbs_toom_couple_handling\n    // - y_shift != 0 in limbs_toom_couple_handling\n    // - x_shift != 0 in limbs_toom_couple_handling\n    // - s > t\n    // - carry_1 && !carry_2, first time, in limbs_mul_toom_interpolate_8points\n    // - carry_1 && !carry_2, second time, in limbs_mul_toom_interpolate_8points\n    // - s_plus_t != n in limbs_mul_toom_interpolate_8points\n    test(\n        series(2, 15),\n        series(3, 11),\n        vec![10; 26],\n        vec![\n            6, 17, 34, 58, 90, 131, 182, 244, 318, 405, 506, 594, 682, 770, 858, 895, 912, 908,\n            882, 833, 760, 662, 538, 387, 208, 0,\n        ],\n    );\n    // - v_neg_2pow_neg in limbs_mul_toom_evaluate_poly_in_2pow_and_neg_2pow\n    // - y_sign in limbs_toom_couple_handling\n    // - s <= t\n    test(\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n        vec![10; 26],\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],\n    );\n    // - !carry_1 && carry_2, first time, in limbs_mul_toom_interpolate_8points\n    test(\n        vec![\n            281500646, 1572406350, 108746052, 4056047843, 89307364, 1006007374, 2902260577,\n            1250995384, 1556873818, 3846421711, 280743259, 1728158805, 467926284, 2330565417,\n        ],\n        vec![\n            1365578038, 3224231142, 4103857906, 475734936, 3828952167, 3071966456, 1450111251,\n            1166414077, 2218130537, 3324650407, 1559641024, 2423373264,\n        ],\n        vec![10; 26],\n        vec![\n            3471157380, 2179990259, 735116018, 3928626279, 2606792426, 4065628313, 3326106964,\n            1358767242, 58836620, 2388814047, 1881937395, 448453590, 699295041, 2539838591,\n            1014080982, 2627397171, 1231543630, 2956184941, 1108982880, 2083442227, 1445361702,\n            3773463966, 3902311612, 4169089467, 614631841, 1314987876,\n        ],\n    );\n    // - s_plus_t == n in limbs_mul_toom_interpolate_8points\n    test(\n        vec![\n            1372428912, 2999825770, 3824933735, 1252466299, 1644332514, 577056155, 267504800,\n            2188417248, 1146838357, 1601878440, 2555350187, 2326995902, 341200833, 3311243465,\n            3983323172, 1591023018, 498264278, 879686658, 2445286712, 3168806215, 3363960673,\n            1002293448,\n        ],\n        vec![\n            4155394173, 3251572031, 3012777338, 1405107169, 4263655764, 202386116, 2762119705,\n            1046271690, 3730474184, 1761497041, 3530189728, 452831577, 2351117985, 3074633806,\n            2337874996, 2372535352, 1907593160, 2034262144,\n        ],\n        vec![10; 40],\n        vec![\n            3438536880, 4020840252, 3753658662, 2750457729, 3984463794, 1677702279, 3627178035,\n            1938289829, 2347934241, 1059164524, 3077109858, 1455283397, 4245424824, 2265496611,\n            2507273589, 4106853892, 187386657, 3541881161, 3520589236, 977961476, 205850208,\n            3040196950, 1303835716, 3039701923, 525989195, 1042461957, 4189151284, 3358396344,\n            275215531, 2907721257, 3086020483, 2914223316, 652103889, 2430562590, 4256409533,\n            774831877, 3808631269, 3720895601, 1034939105, 474724830,\n        ],\n    );\n    // - !carry_1 && carry_2, second time, in limbs_mul_toom_interpolate_8points\n    test(\n        vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xfffffff0, u32::MAX, u32::MAX, u32::MAX],\n        vec![\n            2047,\n            0,\n            0,\n            4294966784,\n            u32::MAX,\n            127,\n            0,\n            4286578688,\n            u32::MAX,\n            0x3ffff,\n            4227858432,\n            u32::MAX,\n        ],\n        vec![10; 26],\n        vec![\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            0,\n            4294934544,\n            u32::MAX,\n            u32::MAX,\n            8191,\n            2047,\n            4294965248,\n            u32::MAX,\n            134217215,\n            0,\n            4290773120,\n            0x3fffffff,\n            4286578688,\n            4294967279,\n            0x3ffff,\n            4227858432,\n            u32::MAX,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_54_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_54_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_54(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_54_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_54_scratch_len(15, 16)];\n    let mut out = vec![10; 31];\n    let xs = series(3, 14);\n    let ys = series(3, 17);\n    limbs_mul_greater_to_out_toom_54(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_54_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_54_scratch_len(15, 10)];\n    let mut out = vec![10; 25];\n    let xs = series(3, 14);\n    let ys = series(3, 10);\n    limbs_mul_greater_to_out_toom_54(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_54_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_54_scratch_len(14, 11)];\n    let mut out = vec![10; 25];\n    let xs = series(3, 14);\n    let ys = series(3, 11);\n    limbs_mul_greater_to_out_toom_54(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_54_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_54_scratch_len(15, 11)];\n    let mut out = vec![10; 25];\n    let xs = series(3, 15);\n    let ys = series(3, 11);\n    limbs_mul_greater_to_out_toom_54(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_54_fail_6() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_54_scratch_len(15, 0)];\n    let mut out = vec![10; 15];\n    let xs = series(3, 15);\n    limbs_mul_greater_to_out_toom_54(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_62() {\n    let test = |xs: &[Limb], ys: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_62_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_62(&mut out, xs, ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - degree.odd() in limbs_mul_toom_evaluate_poly_in_1and_neg_1\n    // - degree > 4 in limbs_mul_toom_evaluate_poly_in_1and_neg_1\n    // - degree_u >= 5 in limbs_mul_toom_evaluate_poly_in_2and_neg_2\n    // - degree.odd() in limbs_mul_toom_evaluate_poly_in_2and_neg_2\n    // - t == n\n    // - limbs_cmp_same_length(ys_0, ys_1) == Less\n    // - v_neg_1_neg_b\n    // - *as1last == 0\n    test(\n        &series(2, 6),\n        &[3, 4],\n        &[10; 8],\n        &[6, 17, 24, 31, 38, 45, 28, 0],\n    );\n    // - limbs_cmp_same_length(ys_0, ys_1) != Less\n    // - !v_neg_1_neg_b\n    // - t >= n\n    // - limbs_cmp_same_length(&bsm1, ys_1) == Less\n    test(\n        &[0, 0, 0, 0, 0, 1],\n        &[1, 1],\n        &[10; 8],\n        &[0, 0, 0, 0, 0, 1, 1, 0],\n    );\n    // - limbs_cmp_same_length(&bsm1, ys_1) != Less\n    test(\n        &[0, 0, 0, 0, 0, 1],\n        &[2, 1],\n        &[10; 8],\n        &[0, 0, 0, 0, 0, 2, 1, 0],\n    );\n    // - t != n\n    // - !(slice_test_zero(&ys_0[t..]) && limbs_cmp_same_length(&ys_0[..t], ys_1) == Less)\n    // - t < n\n    // - !(slice_test_zero(&bsm1[t..]) && limbs_cmp_same_length(&bsm1[..t], ys_1) == Less)\n    // - *as1last == 2\n    test(\n        &[\n            2291585918, 1380546066, 1861205162, 1395600128, 1509813785, 1715266614, 3251195596,\n            3140058077, 1998653517, 3140019184, 2534426976,\n        ],\n        &[2477133296, 625749873, 3687467688],\n        &[10; 14],\n        &[\n            869772320, 253774892, 3270059412, 1629301906, 333315526, 1485838973, 1182872659,\n            3973435471, 3570040059, 138616924, 3845622124, 4243476600, 2488800838, 2175946157,\n        ],\n    );\n    // - *as1last > 2\n    test(\n        &[706760835, 4153647095, 3843998199, 2077172825, 1158686949, 3157624247],\n        &[708497006, 797041707],\n        &[10; 8],\n        &[\n            3596223050, 1899342498, 3768933007, 59388593, 2997914214, 150267535, 1848145862,\n            585978436,\n        ],\n    );\n    // - *as1last == 1\n    test(\n        &[\n            1817453168, 96871997, 3927306877, 3090061646, 3474317652, 437148773, 439538568,\n            324686794, 772632617, 1424328970, 580538580,\n        ],\n        &[4158498322, 3126677346, 655989538],\n        &[10; 14],\n        &[\n            4142861280, 2093741387, 1223409636, 3430701278, 154561385, 1065478559, 1434432315,\n            1709306376, 2647162930, 2288715437, 510829208, 3519993529, 1581992297, 88668250,\n        ],\n    );\n    // - *bs1last != 0\n    test(\n        &[478149678, 4026802122, 1384639138, 368837837, 183900171, 785221208],\n        &[1458158767, 4167624669],\n        &[10; 8],\n        &[\n            1921854322, 141249793, 673006993, 2183916852, 295623924, 3471440317, 3387755993,\n            761939975,\n        ],\n    );\n    // - *asm1last == 1\n    test(\n        &[760464004, 3698115579, 1282981837, 2124133062, 1943175022, 3815903204],\n        &[2302225798, 423133196],\n        &[10; 8],\n        &[\n            1718420760, 4288660832, 1043184986, 2518603664, 1668853787, 1047988481, 4101944437,\n            375936580,\n        ],\n    );\n    // - *asm1last == 2\n    test(\n        &[\n            486320673, 3488920730, 3556919186, 380261964, 1609664786, 3382076763, 3478178414,\n            1464325754, 2543330707, 3900552438, 1432199477,\n        ],\n        &[1190326122, 1081384689, 2610845505, 3919894794],\n        &[10; 15],\n        &[\n            3164946602, 4284198222, 380177155, 837655879, 3034889727, 3503063664, 3315274214,\n            3998279880, 2501466635, 3524441, 312561544, 2480833439, 3092764257, 1045878247,\n            1307127829,\n        ],\n    );\n    // - slice_test_zero(&ys_0[t..]) && limbs_cmp_same_length(&ys_0[..t], ys_1) == Less\n    test(\n        &rle_decode(&[(u32::MAX, 17), (31, 1), (0, 5), (4294967232, 1), (u32::MAX, 12)]),\n        &[u32::MAX, 63, 0, 0, 0, 0, 4227858432, u32::MAX, u32::MAX, u32::MAX, u32::MAX],\n        &[10; 47],\n        &[\n            1,\n            4294967232,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            0x3ffffff,\n            0,\n            0,\n            0,\n            0,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4294967263,\n            2047,\n            0,\n            0,\n            0,\n            0,\n            2147483712,\n            4294963199,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            31,\n            0,\n            1,\n            0,\n            0,\n            0,\n            4294967232,\n            u32::MAX,\n            u32::MAX - 1,\n            63,\n            0,\n            0,\n            0,\n            0,\n            4227858432,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n        ],\n    );\n    // - slice_test_zero(&bsm1[t..]) && limbs_cmp_same_length(&bsm1[..t], ys_1) == Less\n    test(\n        &rle_decode(&[(1073741823, 1), (0, 7), (4290772992, 1), (u32::MAX, 8)]),\n        &[0xfff00000, u32::MAX, 0, 0xffffff8, 4294443008],\n        &[10; 22],\n        &[\n            0x100000,\n            4294705152,\n            0x3ffffffe,\n            4026531848,\n            67633149,\n            1073610751,\n            0,\n            0,\n            0,\n            1024,\n            4290772992,\n            0x1ffffff,\n            4294705152,\n            4290773503,\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4293918719,\n            u32::MAX,\n            0,\n            0xffffff8,\n            4294443008,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_62_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_62_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_62(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_62_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_62_scratch_len(6, 7)];\n    let mut out = vec![10; 13];\n    let xs = series(3, 6);\n    let ys = series(3, 7);\n    limbs_mul_greater_to_out_toom_62(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_62_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_62_scratch_len(6, 1)];\n    let mut out = vec![10; 7];\n    let xs = series(3, 6);\n    limbs_mul_greater_to_out_toom_62(&mut out, &xs, &[3], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_62_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_62_scratch_len(5, 2)];\n    let mut out = vec![10; 7];\n    let xs = series(3, 5);\n    limbs_mul_greater_to_out_toom_62(&mut out, &xs, &[3, 4], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_62_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_62_scratch_len(6, 2)];\n    let mut out = vec![10; 7];\n    let xs = series(3, 6);\n    limbs_mul_greater_to_out_toom_62(&mut out, &xs, &[3, 4], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_62_fail_6() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_62_scratch_len(6, 0)];\n    let mut out = vec![10; 6];\n    let xs = series(3, 6);\n    limbs_mul_greater_to_out_toom_62(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_63() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_63(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - n == t\n    // - !(!carry && limbs_cmp_same_length(scratch2lo, ys_1) == Less)\n    // - s <= t\n    test(\n        series(2, 17),\n        series(3, 9),\n        vec![10; 26],\n        vec![\n            6, 17, 34, 58, 90, 131, 182, 244, 318, 381, 444, 507, 570, 633, 696, 759, 822, 828,\n            812, 773, 710, 622, 508, 367, 198, 0,\n        ],\n    );\n    // - n != t\n    test(\n        vec![\n            3047748962, 2284186344, 3132866461, 2331447040, 1003213663, 1873981685, 3371337621,\n            3796896013, 4144448610, 2569252563, 2859304641, 1027973602, 3158196152, 4058699545,\n            2002924383, 3295505824, 695758308, 544681384, 3452307839, 1190734708, 4232023153,\n            451772934, 673919865, 2022672425, 3493426012, 1142609332, 477542383, 1304798841,\n            461115870, 3268103575, 2243523508,\n        ],\n        vec![\n            3987208830, 1336657961, 2605546090, 1112778759, 2243645577, 3695113963, 637209276,\n            527642657, 1586863943, 2178788843, 4128924923, 574016400, 118333022, 3019059425,\n            3734056582, 3974475640, 958936732,\n        ],\n        vec![10; 48],\n        vec![\n            901282364, 4131825926, 550521101, 4239081984, 354957348, 2987335611, 2947836402,\n            1594339509, 1900787939, 3942224706, 1915750189, 2686147736, 455238733, 595779993,\n            992449470, 225135268, 4216025815, 112446550, 2736130746, 1015352940, 1166343395,\n            3559470539, 2787138552, 3128535813, 2203140859, 3479459112, 599923700, 684443693,\n            1557326194, 1699057519, 2198150417, 2196463130, 1973109458, 3642841764, 426750624,\n            1438683694, 42406461, 1444651840, 2152704621, 722727455, 3882030279, 205951250,\n            838845869, 2997862064, 779154540, 1753953589, 1791445120, 500911172,\n        ],\n    );\n    test(\n        vec![\n            2547108010, 2828666778, 3252702258, 3885923576, 2331974758, 730724707, 1528859315,\n            4288784328, 3677151116, 445199233, 3304488688, 3566979465, 3541025426, 2491779846,\n            3112990742, 2583249486, 3403111749, 1930721237, 3428792463, 2896462048, 2985885576,\n            1819460734, 21206096, 3560441846, 987100555, 2844904275, 84854892, 1268249628,\n            3963306788, 3338670067, 2504599089, 65588657, 321493327, 4249673617, 4150876068,\n            721566898,\n        ],\n        vec![\n            2339094549, 568841948, 757218994, 54206328, 2888117240, 1758638903, 3215886938,\n            2041086168, 259363425, 3740850804, 3272104239, 3101597497, 4170226346, 1487680512,\n            2997309052, 1761169487, 680164259, 104354801, 3642294827, 2001649447,\n        ],\n        vec![10; 56],\n        vec![\n            4156749298, 1238334534, 3541686335, 400023669, 3354392679, 146448234, 338562445,\n            2541647274, 3476105410, 3869729511, 2592129633, 1524174755, 2864342013, 3189404137,\n            2408966423, 1748955694, 848863232, 2061232865, 2863992687, 1780371599, 1814973544,\n            4129152748, 1067034680, 3960771432, 1978132071, 249147649, 4113633238, 3331366833,\n            103867284, 4274561406, 24372440, 1874890180, 2262704206, 4185039557, 1493676561,\n            3605651563, 184712156, 1714079946, 3695806969, 3114374817, 2698021971, 2617815992,\n            3374318018, 2710182754, 2217042831, 3166354273, 3526471084, 2282901181, 17853137,\n            2805842653, 2980411632, 2879849003, 22987084, 2408312078, 212023482, 336282883,\n        ],\n    );\n    // - !carry && limbs_cmp_same_length(scratch2lo, ys_1) == Less\n    // - s > t\n    test(\n        vec![\n            275320572, 2678313698, 1997150503, 1718206458, 3389415001, 1347098060, 423205500,\n            1228674579, 1683636524, 1761485682, 3886555164, 1343770739, 3728441996, 3386212640,\n            4218849286, 3154177905, 383775865, 685210915, 2915358388, 356527607, 1399377005,\n            2203631586, 3950305635, 4107289625,\n        ],\n        vec![\n            343872945, 2028904125, 1525417887, 867188532, 3911999830, 2139706847, 3256484706,\n            961423019, 1530068826, 3577946967,\n        ],\n        vec![10; 34],\n        vec![\n            367134780, 454511356, 740068730, 2466817027, 444007987, 2116910983, 3588258390,\n            4148666142, 241899205, 3037479671, 967522541, 1695514557, 3417684811, 1755587152,\n            57889847, 1893598444, 894827452, 1259092281, 343759711, 417669929, 4250137916,\n            2931151486, 4137704826, 1616987343, 118402896, 3476900958, 3144858924, 799089809,\n            2899882887, 413231425, 2515242049, 142267098, 1727945779, 3421601015,\n        ],\n    );\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_63() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_63(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(\n        vec![\n            6746486103788831552,\n            2922469023463657485,\n            7190781201699911122,\n            6369274278675525514,\n            11602031538822447399,\n            18146097755068799938,\n            10715195159596301824,\n            1582667531232164822,\n            17310503547119278200,\n            11108448614311336701,\n            16131384432757080248,\n            10724146198461527790,\n            17486718158725257827,\n            6011711000953739951,\n            12044019786490872751,\n            12126819472937875768,\n            11736689834584491812,\n            2624631955548590096,\n        ],\n        vec![\n            8718882040837103283,\n            12513261442998616191,\n            3363599670593686195,\n            2576001491054566526,\n            8476413363242630098,\n            11800520882738943180,\n            15256756628116724015,\n            15102633230716809194,\n            4752404995807312312,\n        ],\n        vec![10; 27],\n        vec![\n            11055708298853713344,\n            11718134630995530406,\n            1540454672309197922,\n            2461234873920328802,\n            12156343925049526190,\n            7669775936281025739,\n            5569544286309952271,\n            1251802631971472159,\n            7852335389754101252,\n            16331287242162052217,\n            16922468211499817236,\n            1090055930057904858,\n            4774304109866833132,\n            2115064630415334045,\n            3041714142401192073,\n            5249251501654981623,\n            6324653539847586925,\n            7895228639492924348,\n            13455067205957702368,\n            1142009976612635724,\n            13095096323291438869,\n            4348574203955863428,\n            8491467291307697179,\n            3535832683825156722,\n            3832291870552829557,\n            16965222076837711040,\n            676179707804463061,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_63_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_63(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_63_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(17, 18)];\n    let mut out = vec![10; 13];\n    let xs = series(3, 17);\n    let ys = series(3, 18);\n    limbs_mul_greater_to_out_toom_63(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_63_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(17, 8)];\n    let mut out = vec![10; 25];\n    let xs = series(3, 17);\n    let ys = series(3, 8);\n    limbs_mul_greater_to_out_toom_63(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_63_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(16, 9)];\n    let mut out = vec![10; 25];\n    let xs = series(3, 17);\n    let ys = series(3, 9);\n    limbs_mul_greater_to_out_toom_63(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_63_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(17, 9)];\n    let mut out = vec![10; 25];\n    let xs = series(3, 17);\n    let ys = series(3, 9);\n    limbs_mul_greater_to_out_toom_63(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_63_fail_6() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_63_scratch_len(17, 0)];\n    let mut out = vec![10; 6];\n    let xs = series(3, 17);\n    limbs_mul_greater_to_out_toom_63(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_6h() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        let out_after = out;\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - xs_len * LIMIT_DENOMINATOR < LIMIT_NUMERATOR * ys_len\n    // - degree.odd() in limbs_mul_toom_evaluate_poly_in_2pow_neg_and_neg_2pow_neg\n    // - degree > 3 in limbs_mul_toom_evaluate_poly_in_2pow_neg_and_neg_2pow_neg\n    // - !neg in limbs_mul_toom_evaluate_poly_in_2pow_neg_and_neg_2pow_neg\n    // - q != 3\n    // - !half in limbs_mul_toom_interpolate_12points\n    test(series(2, 42), series(3, 42), vec![10; 84]);\n    test(vec![0; 43], vec![0; 42], vec![10; 85]);\n    let xs = vec![\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,\n    ];\n    let ys = vec![\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - v_2pow_neg_neg in limbs_mul_toom_evaluate_poly_in_2pow_neg_and_neg_2pow_neg\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2176876728, 2496909862, 111654638, 4071443844, 1244732003, 1399710541, 3492272815,\n        2804216879, 294683567, 2823495183, 1539340600, 2732661048, 2371405604, 611094747,\n        2426195984, 3948451542, 3575143460, 2163084716, 2877537071, 1849282685, 1662381818,\n        2022577840, 552741512, 1863034519, 2109621858, 3426780715, 233006082, 2766239663,\n        1257764921, 1179443268, 3311729910, 4228711990, 3676801557, 83336617, 52963853, 1461131367,\n        615175494, 2376138249, 1373985035, 3055102427, 1823691121, 175073115, 3051957217,\n    ];\n    let ys = vec![\n        344785207, 1075768263, 3315797254, 2656376324, 160336834, 3872758991, 671370872,\n        1253701757, 217686653, 4064957864, 1185854346, 2308111201, 847669579, 195002426,\n        1955159211, 2003106801, 1041767923, 3605273739, 3153084777, 2806535311, 1401436525,\n        1148858479, 958627821, 1267879008, 4138398998, 1028065582, 3914213477, 3370118288,\n        4054975453, 1815994585, 2486521917, 995353494, 16609723, 4010498224, 1214270934, 797624362,\n        4000265982, 1287753121, 874311717, 2200865401, 21122981, 1507911002,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - r4last.leading_zeros() < 3 in limbs_mul_toom_interpolate_12points\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2327202328, 3179332026, 2188958336, 2717879675, 130062885, 140536268, 2499125438,\n        3163111280, 4259661702, 2176278885, 422519228, 2482586299, 2904549185, 656169575,\n        2052350629, 1346745024, 2132509288, 3672720658, 1036389958, 1864007789, 4247227128,\n        3920036168, 1436562554, 4261984498, 3509215437, 583752676, 3145348403, 2267709494,\n        2846186667, 95392897, 3743233716, 2210401890, 333864866, 4114644153, 3030283850,\n        2885600773, 209380485, 753945396, 719327396, 1293498320, 881901364, 2799735404, 3880748109,\n        2227099476, 2045911493, 279042015, 1825819541, 1783146691, 2256898093, 2186071881,\n    ];\n    let ys = vec![\n        4062960470, 3852836537, 2696572187, 2332897564, 3819654112, 1805852435, 2339319161,\n        3891614436, 3143079880, 3244604349, 2122448594, 1926396564, 3938383812, 51745369,\n        2731805677, 4257919711, 2550692774, 4079294279, 223709465, 1648526554, 689775843,\n        3524108772, 1404538310, 806199241, 4278266886, 2467028886, 3773289773, 3246095241,\n        2201055218, 2036154035, 3144210007, 423367788, 3883829868, 2190252193, 2069131777,\n        3027047320, 1576225469, 3459606326, 2343356582, 2658410138, 1927376994, 3129832669,\n        3772482523,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - xs_len * LIMIT_DENOMINATOR >= LIMIT_NUMERATOR * ys_len\n    // - xs_len * 5 * LIMIT_NUMERATOR < LIMIT_DENOMINATOR * 7 * ys_len\n    // - half\n    // - degree.even() in limbs_mul_toom_evaluate_poly_in_2pow_neg_and_neg_2pow_neg\n    // - degree > 5 in limbs_mul_toom_evaluate_poly_in_1and_neg_1\n    // - s <= t\n    // - half in limbs_mul_toom_interpolate_12points\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        1940830933, 3780770129, 1587254032, 832573251, 1504418072, 4247592896, 317874907,\n        949850421, 2252881736, 3574316069, 3062236166, 1396410954, 3249498785, 3495392204,\n        540855070, 1908700137, 1469179505, 4199276220, 953657385, 3056452157, 2141569526,\n        2342475731, 3746376146, 3271677606, 2770490239, 2212992129, 1758619376, 1446549455,\n        409094501, 767129031, 3284625381, 1887741449, 1134874072, 2988924415, 1641550007,\n        856704035, 80648349, 1467185629, 2753807208, 1609415681, 4087676277, 3276525355,\n        1530490532, 3475014952, 1971819359, 2190766950, 2667577576, 2404497182, 4128259693,\n        2449514447, 4199089872, 2205116036, 4089987616, 457231895, 2931469481, 3147651033,\n        2352907189,\n    ];\n    let ys = vec![\n        3461606200, 1584050797, 14355481, 3385840230, 1703326352, 1625259628, 3642322228,\n        911402341, 2158835226, 939248485, 3607511108, 2863853568, 1611642161, 1312857772,\n        1839433327, 567060478, 3139863681, 3642698184, 3744632443, 712538472, 2692932947,\n        576185818, 156934113, 518107105, 2803035863, 2284220097, 3447382922, 2400125006,\n        3565062840, 160044186, 3644393084, 4196433258, 3391883838, 1115703759, 2380388002,\n        962895870, 4001772616, 2311278419, 2620271020, 3047789793, 3229254302, 3182628087,\n        2718480927, 2872538422,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - t < 1\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        3796896013, 4144448610, 2569252563, 2859304641, 1027973602, 3158196152, 4058699545,\n        2002924383, 3295505824, 695758308, 544681384, 3452307839, 1190734708, 4232023153,\n        451772934, 673919865, 2022672425, 3493426012, 1142609332, 477542383, 1304798841, 461115870,\n        3268103575, 2243523508, 606810814, 4235312469, 1885993181, 114475077, 757688489,\n        1965769398, 260629125, 2265559181, 2568323569, 4202738507, 422918034, 1258453131,\n        3552221985, 1666914845, 4063631552, 1893061685, 1362616670, 3828572660, 3003680479,\n        119501228, 2101943449, 1119123129, 2512417484,\n    ];\n    let ys = vec![\n        610160726, 3751120540, 2655318738, 2490069121, 732352936, 1985503906, 765573690,\n        2709177647, 3058016350, 1432725430, 2213840145, 1911049343, 3116245242, 519557432,\n        1828983405, 3092431113, 3844759473, 547304293, 1609305183, 1824076406, 2409386071,\n        2970173039, 4255413180, 894750419, 90356879, 2880999631, 2157180976, 2261258057, 715581698,\n        332174009, 27958638, 2464799420, 3232925197, 1952944696, 915312443, 1464711675, 4079172443,\n        2445511584, 2092009263, 3412361485, 2354390078, 3106038172, 3481973486,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - s < 1\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2187046946, 3600373521, 4275090943, 2120016813, 4177241875, 3185774231, 2397692077,\n        1015362399, 2178889151, 3433916223, 1688082118, 1971242178, 236388706, 3802829765,\n        521309115, 2299816689, 3207614143, 1053195464, 3584561145, 1178690670, 2940812254,\n        3321982035, 2754825123, 3073598062, 202404806, 547895545, 1188944547, 1056841779,\n        529463805, 204665384, 850370055, 2063320161, 3724100092, 1180272690, 1398467003,\n        2814052449, 1311768018, 659771105, 3226477227, 4230080238, 2134344405, 1461172705,\n        2728018383, 1816821358, 3231137250, 2012377728, 2206916761, 3121807673,\n    ];\n    let ys = vec![\n        1717557648, 1819215517, 3449795284, 844168976, 1574237607, 758725457, 762624299, 533122182,\n        1201164787, 1968174784, 896982568, 3419630169, 2247559545, 3983311870, 3975342941,\n        1112833399, 2721518545, 2493587613, 3444837338, 3313000598, 751186769, 2970698395,\n        915811688, 1206259449, 1340427760, 3844346545, 3762393860, 543253569, 1197933603,\n        3734607133, 4037352821, 2263945478, 2831362781, 3363558852, 476952769, 1916745391,\n        208671986, 2395250976, 1549715018, 2746690542, 1219103496, 256305249,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - s_plus_t > n in limbs_mul_toom_interpolate_12points\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        1976230069, 2821313230, 4002048052, 2248747478, 1208640865, 1469538686, 2438066233,\n        1106183979, 1877645648, 2583513281, 904899723, 1001323826, 3134049747, 292171929,\n        1479818350, 821125410, 2017124898, 3447449059, 2073983663, 1214861045, 3270809855,\n        2826108666, 412311360, 3687943078, 157663911, 447468817, 1727023746, 1120132848, 462566659,\n        21711861, 2204912119, 631663514, 2655508903, 2912870262, 1326931248, 1409724492,\n        3912444286, 1986726296, 190162730, 675575771, 234714100, 3787240294, 3149710501,\n        1950469069, 1222949463, 218525862, 929916299, 1757577031, 3896857869, 443052809,\n        4256330379, 1106528307, 2502814887, 108409846,\n    ];\n    let ys = vec![\n        3774873792, 2622161570, 566787739, 1447674683, 1128900692, 2570098345, 3920242059,\n        2431899603, 1456341665, 269610676, 673205188, 3712878022, 3795578329, 996518376,\n        3414916195, 4167667588, 4013410429, 724257700, 698186720, 1170923258, 3652768880,\n        1373260172, 3271469225, 971070649, 1556038273, 2204702414, 673789949, 3790414001,\n        1550521405, 2173912108, 70968354, 1856452807, 2648613270, 2751500372, 1057118618,\n        3117394831, 4409774, 2422780755, 3367234488, 1080583495, 29356841, 3627216363,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - s > t\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2764481948, 3824853452, 3714446166, 1652416239, 2448871004, 3349954116, 2715554665,\n        2953094534, 2191528165, 1105735060, 407641991, 1058849514, 2583237649, 3635224830,\n        1509496009, 2360185935, 2419261549, 2433663350, 262632960, 3504095388, 2570319009,\n        2415092334, 72373859, 3953007752, 3259518037, 3401184350, 574975346, 1921349734,\n        1293058836, 2824387015, 670301824, 3449438821, 3149566748, 2370941125, 3445476733,\n        1172535390, 684380840, 4007537582, 3019960994, 3833788436, 2407231528, 532343833,\n        438092212, 830534904, 325324494, 1629611634, 3991887007, 1617691624, 3806774950,\n        2737609900, 4123817599, 1139254855, 4270594452, 3772632696, 357643096, 978439292,\n        3535266500, 1036728326, 408519941, 386395864, 986295007,\n    ];\n    let ys = vec![\n        2893157767, 2933782072, 1630695663, 765017133, 148924741, 3933388144, 2827967305,\n        1580462312, 4233997190, 2184167709, 1124313531, 1269787970, 2637050113, 1899399034,\n        458443927, 676372848, 3341236235, 2358837775, 78253712, 1308766267, 1398616295, 442007911,\n        3803960772, 2890078708, 2362278228, 452577827, 2295445770, 1281833658, 3733263779,\n        3192119570, 1465309963, 4149236735, 2550067398, 3391554453, 3763654782, 280954439,\n        4216404337, 2988297132, 1171366979, 752568358, 3832355781, 3002295862,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - xs_len * 5 * LIMIT_DENOMINATOR < LIMIT_NUMERATOR * 7 * ys_len\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        1537074800, 903591185, 3505885895, 1600301704, 2247503777, 2456507858, 354178772,\n        4264234279, 4276311343, 2137271746, 3095634214, 3503644667, 3271712752, 1235289576,\n        3972513632, 4268165027, 3304957815, 2349877036, 1814187379, 1622480961, 1887152020,\n        617829740, 2759792107, 2650325546, 3834300382, 1711067002, 16368281, 3248020475,\n        1355293366, 2500355734, 3216660200, 2844209744, 919471841, 2536405197, 286948869,\n        3207728956, 1786641001, 3909697676, 2990524533, 3373134471, 2770917041, 2941741335,\n        2275165617, 610985518, 1663622513, 780492488, 696913656, 1787332447, 1693914179,\n        2059746330, 4084862137, 1720114882, 2072770321, 2800094080, 164377327, 114079185,\n        1630830573, 866212705, 86571916, 2701570437, 1022361296, 2774191689, 1485998454,\n        1449541799,\n    ];\n    let ys = vec![\n        10887125, 840662268, 2350057862, 3489480809, 2643647461, 2120151555, 433525765, 1719122308,\n        3784715068, 3156307967, 4113669583, 607844816, 2149779595, 55766995, 3922134877,\n        1464452041, 2877070520, 3517698059, 3219767758, 138329276, 1434547315, 1010269423,\n        3836852303, 521525549, 1124005096, 128173038, 1627976147, 4217098680, 963901397,\n        4003948876, 4078383999, 3163439869, 1376461045, 1260808800, 1583549957, 3016546386,\n        601137572, 2476346948, 1057124592, 2232232546, 2939285402, 2703166574, 2566511508,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - xs_len * LIMIT_NUMERATOR < LIMIT_DENOMINATOR * 2 * ys_len\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2480817744, 2385986715, 908796583, 3725142486, 4259996640, 2324291843, 2514777689,\n        776517112, 1179390166, 2884250121, 2107025487, 1847592315, 1214792717, 581761941,\n        2035752941, 3257884740, 1011095107, 388625485, 621566511, 1878249130, 2298430809,\n        3893830507, 2516166455, 1685998768, 3349147146, 4262358486, 164529678, 1000098113,\n        1468664761, 1088142633, 2140348214, 672483433, 4236152545, 460911546, 1948312076,\n        1030937440, 3633681142, 1170002101, 2159285228, 1104198886, 1581288546, 2266152509,\n        1437951300, 3854459332, 88193405, 3804599756, 577997778, 3610194716, 2527782134,\n        4194448103, 3390832927, 863423772, 2308481008, 1764994151, 2876150765, 474256942,\n        3850214133, 2831691105, 4251752821, 80285354, 3225163007, 84390462, 1489215151, 1516077116,\n        299402893, 1093360002, 706962212, 375054336, 678692965, 2794629958, 3684518009, 1067098399,\n        3918266067, 770155119, 1400555696, 4260143847, 3420662760, 2234352998, 2627202272,\n        2396298990, 2703934662, 2975030448, 1678542783, 3962857080, 2037990778, 2350341680,\n        3690768614, 3327392397, 2374080995, 1568940040,\n    ];\n    let ys = vec![\n        2432887163, 3617411153, 4065664491, 954897002, 1958352130, 2690853400, 3170435422,\n        333223996, 1886503369, 2874118364, 2360990628, 3409169651, 14803166, 2428352279,\n        2882529293, 215157778, 3595826381, 1351666697, 3213081864, 1796627015, 138520647,\n        1446708749, 549025603, 1154696063, 951257454, 1061151557, 3578338019, 553024835,\n        1032056788, 3332695385, 1916952270, 1402847201, 418140204, 1113800470, 3311963507,\n        3579825680, 283695808, 1030062334, 2885288472, 2307021635, 1215165167, 361703549,\n        3359666682, 2960119991, 3759575408,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - xs_len * LIMIT_DENOMINATOR < LIMIT_NUMERATOR * 2 * ys_len\n    // - q == 3\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2182584668, 370736031, 944597706, 368333101, 3076089385, 4269551750, 455799119, 1640998687,\n        1332255273, 3039440200, 1094187469, 4158542740, 4241437189, 786279542, 3313987323,\n        801901648, 2460914857, 2458651362, 1161118074, 3733983107, 1911753349, 4261306583,\n        981590361, 1357088215, 210591422, 1159943023, 510963968, 2705428227, 3460159465,\n        1967595187, 703584117, 3474024702, 3343010520, 1232104952, 823854220, 4012290690,\n        3252492197, 3975386640, 1309751464, 232265040, 2026518879, 794539121, 1849747498,\n        773993567, 2415934846, 842827728, 25297943, 3952540535, 2909076393, 4183158950, 2579267900,\n        898983053, 2480815324, 1004385686, 3272214418, 2360496610, 3884948711, 3937994494,\n        1355835525, 1862072763, 4077270583, 456721854, 1202741767, 1334238573, 3202598432,\n        2518498766, 1873498914, 1155219866, 3257357513, 3381800028, 777225471, 1628571355,\n        281982096, 1238331533, 728101793, 407378640, 1088081860, 2405377044, 2080950804,\n        3105324348, 3065313268, 2776290680, 1200951260, 1789619269, 1088225065, 317598486,\n        924903972, 3504476787, 1605816151, 388266283, 1613602905, 4051481387, 2773856406,\n        3434866445, 2039264971, 1587433780, 1787644933, 2852323335,\n    ];\n    let ys = vec![\n        3040086267, 3720432305, 3025753876, 3307555779, 2232302878, 1705545587, 3746861739,\n        3551552480, 3791909589, 3559707401, 3597994914, 1201195479, 2759785652, 2538497144,\n        2628719068, 1220743906, 2592330951, 357425155, 2683446134, 369894528, 2918070813,\n        3201581079, 352827384, 2667389301, 406071886, 1478662115, 3424718337, 3498162517,\n        1851891341, 2009161130, 4175528772, 2739823403, 2691610015, 530787751, 2995441702,\n        238468207, 84087963, 2802633771, 2722772179, 1905704311, 791349630, 4036308669, 1333503772,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - p == 9, q == 4\n    test(xs, ys, vec![10; out_len]);\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_6h() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        let out_after = out;\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(series(2, 42), series(3, 42), vec![10; 84]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_6h_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_6h(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_6h_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(41, 42)];\n    let mut out = vec![10; 83];\n    let xs = series(3, 41);\n    let ys = series(3, 42);\n    limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_6h_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(42, 41)];\n    let mut out = vec![10; 83];\n    let xs = series(3, 42);\n    let ys = series(3, 41);\n    limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_6h_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(41, 41)];\n    let mut out = vec![10; 82];\n    let xs = series(3, 41);\n    let ys = series(3, 41);\n    limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_6h_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(42, 42)];\n    let mut out = vec![10; 83];\n    let xs = series(3, 42);\n    let ys = series(3, 42);\n    limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_6h_fail_6() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_6h_scratch_len(42, 0)];\n    let mut out = vec![10; 42];\n    let xs = series(3, 42);\n    limbs_mul_greater_to_out_toom_6h(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_8h() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        let out_after = out;\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - xs_len == ys_len || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1) < TOOM_8H_LIMIT_NUMERATOR *\n    //   (ys_len >> 1)\n    // - !(Limb::WIDTH > 36 && q == 3)\n    // - r6last.leading_zeros() < 3 in limbs_mul_toom_interpolate_16points\n    // - !half in limbs_mul_toom_interpolate_16points\n    test(series(2, 86), series(3, 86), vec![10; 172]);\n    let xs = vec![\n        3581553119, 2147449432, 208926434, 2037430803, 4143975728, 2356343321, 937192435,\n        1637432038, 661638621, 1801480924, 3779152128, 4243491821, 1667774376, 1715755489,\n        3661813139, 1605971891, 4030695606, 2961165054, 1368430397, 2222904896, 2817587025,\n        1714442303, 3822714979, 300305701, 1874484285, 2601340412, 2275789197, 2695461089,\n        2246464394, 1119579754, 1646098622, 3280004748, 33497272, 1940830933, 3780770129,\n        1587254032, 832573251, 1504418072, 4247592896, 317874907, 949850421, 2252881736,\n        3574316069, 3062236166, 1396410954, 3249498785, 3495392204, 540855070, 1908700137,\n        1469179505, 4199276220, 953657385, 3056452157, 2141569526, 2342475731, 3746376146,\n        3271677606, 2770490239, 2212992129, 1758619376, 1446549455, 409094501, 767129031,\n        3284625381, 1887741449, 1134874072, 2988924415, 1641550007, 856704035, 80648349,\n        1467185629, 2753807208, 1609415681, 4087676277, 3276525355, 1530490532, 3475014952,\n        1971819359, 2190766950, 2667577576, 2404497182, 4128259693, 2449514447, 4199089872,\n        2205116036, 4089987616, 457231895,\n    ];\n    let ys = vec![\n        1495737173, 3863569894, 2781409865, 2031883388, 2335263853, 2715800358, 580338429,\n        3465089273, 419683969, 372309798, 2092398197, 1587236508, 1706866472, 1926863329,\n        2427550983, 3014840641, 2591183237, 311998012, 1838159904, 2382380991, 3168560843,\n        2457672651, 1329938456, 1585986499, 32624746, 1886190156, 1819802220, 4189456784,\n        2354442118, 1007664036, 3528608675, 3607011918, 3175583218, 2103466232, 4139172560,\n        1977990249, 408055457, 1917901811, 4285926188, 2576630504, 3833124229, 664620480,\n        3594197860, 38119241, 2843152292, 1589895470, 132829200, 911163756, 3350029197, 141124331,\n        628197809, 3184483823, 2738720089, 3684675439, 2998575143, 2394913714, 2088681890,\n        2743885961, 2257026807, 2812703572, 678096205, 2964972038, 1641032123, 3238217254,\n        2452280240, 193873172, 277301379, 106064560, 2264572378, 3461606200, 1584050797, 14355481,\n        3385840230, 1703326352, 1625259628, 3642322228, 911402341, 2158835226, 939248485,\n        3607511108, 2863853568, 1611642161, 1312857772, 1839433327, 567060478, 3139863681,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - r5last.leading_zeros() < 7 in limbs_mul_toom_interpolate_16points\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        3998843185, 3237409891, 364765898, 887299373, 875693912, 790653310, 1949338310, 309040598,\n        2753929769, 1560315881, 2158749638, 124625299, 1949071109, 4293842935, 3418183766,\n        1387429696, 64843603, 1303399904, 455978049, 3724928213, 4182321093, 1342619213,\n        1692503310, 2594578249, 2811338438, 1715625698, 751013184, 1529801113, 2582454920,\n        4199343251, 3183268625, 2516721877, 1167772050, 2317983168, 1793272983, 311653702,\n        3588179354, 661601476, 2154410870, 2334965650, 4135084105, 1682699224, 47903600,\n        3273743199, 3845966395, 1357302998, 3756718174, 2451701689, 2321438159, 3211448326,\n        2377823945, 50814995, 1672303030, 4158805623, 2661886690, 1846253587, 702414278,\n        4059841129, 3727323213, 1424047747, 2939622087, 2231052374, 2013876172, 2053003398,\n        1741887596, 3509712959, 5142212, 3825464748, 3375048072, 338658021, 2655991044, 2889153792,\n        2332483687, 934832926, 3863652984, 1414099507, 2895368376, 1013122176, 2794762768,\n        2981493251, 3152252275, 1564424419, 536147906, 242465174, 3000707896, 3526733161,\n        943706939, 349997931, 1497577916, 3473622068, 1517005385, 2206423568, 1544165865,\n        3199998353,\n    ];\n    let ys = vec![\n        1562512360, 3239315566, 2225439589, 502536858, 1867965636, 618137922, 4149231651,\n        476678563, 4203415530, 4178036608, 1956783646, 4023049148, 2645084690, 270122366,\n        201340005, 4276855303, 1021151730, 916821881, 663141922, 2795604136, 3762385264, 348487994,\n        2655354829, 343872945, 2028904125, 1525417887, 867188532, 3911999830, 2139706847,\n        3256484706, 961423019, 1530068826, 3577946967, 2361035355, 337639742, 3774308229,\n        2185652798, 3532716804, 4018761888, 1357817255, 2216301712, 2861241181, 3053055924,\n        3777579308, 795689292, 3386662598, 4160296368, 2005833155, 1297354264, 2851045342,\n        954306552, 1613754854, 2227385445, 528669733, 3315107199, 3402866739, 1117279433,\n        232818134, 1490857876, 1962534623, 1227821174, 159891958, 1385848424, 4061426539,\n        647828819, 2061390815, 4239314784, 1854131914, 3258304017, 524974854, 450125309, 684998491,\n        2942294237, 4191667771, 2230185588, 1844054665, 193300986, 2652500966, 4050934267,\n        1133780381, 3709046706, 909867408, 4209959016, 4275912160, 277155368, 1775051743,\n        4190065677,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - !(an == bn || an * (TOOM_8H_LIMIT_DENOMINATOR >> 1) < TOOM_8H_LIMIT_NUMERATOR * (bn >> 1))\n    // - xs_len * 13 < 16 * ys_len\n    // - half\n    // - s <= t\n    // - half in limbs_mul_toom_interpolate_16points\n    // - s_plus_t > n in limbs_mul_toom_interpolate_16points\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2456061149, 2562918666, 2903450513, 1994190773, 99234624, 3722083920, 4262323306,\n        202219441, 4201857695, 3988878636, 1533308334, 401400520, 1069756554, 2457773969,\n        2892388936, 3423117995, 1944069442, 492036629, 3426800580, 2282483359, 4006366620,\n        1695364515, 2555180845, 1669287836, 349290429, 778467450, 2020203604, 2218159817,\n        1450404019, 1278304750, 2412695340, 1592154884, 3868182043, 2240370481, 3859902860,\n        1008825116, 412233394, 2475457637, 3664379433, 4204584226, 2750684469, 4113507475,\n        2916584959, 285955744, 739598569, 18278051, 3768126932, 2181905109, 2612988076, 1827656088,\n        1160380415, 4160443718, 1846086671, 3050604645, 2547108010, 2828666778, 3252702258,\n        3885923576, 2331974758, 730724707, 1528859315, 4288784328, 3677151116, 445199233,\n        3304488688, 3566979465, 3541025426, 2491779846, 3112990742, 2583249486, 3403111749,\n        1930721237, 3428792463, 2896462048, 2985885576, 1819460734, 21206096, 3560441846,\n        987100555, 2844904275, 84854892, 1268249628, 3963306788, 3338670067, 2504599089, 65588657,\n        321493327, 4249673617, 4150876068, 721566898, 2186945060, 922948272, 1502464627,\n        1426914435, 2906888275, 3454987739, 2609132626, 2073366782, 1058809001, 1226951003,\n        2624503637,\n    ];\n    let ys = vec![\n        3941840558, 1662743930, 1905993615, 2485835810, 3925643251, 3071436009, 851721712,\n        1325046168, 3214018378, 1465803515, 2459667310, 2361559987, 2668552637, 2425633974,\n        3200812339, 2594448814, 4170435967, 1112582678, 3198704424, 4028094030, 2482710119,\n        2990475705, 708195759, 612294539, 2794828841, 2498141427, 3805184114, 3010938369,\n        1479667740, 660767380, 1641177565, 1782849661, 1915222559, 1626388136, 1816788637,\n        1338361170, 783877621, 4003339370, 1930607900, 1259399167, 3351643097, 1641708262,\n        967800396, 1800752717, 2198926109, 1163817943, 2710351254, 451351637, 1285647338,\n        865168955, 645286276, 2685132510, 1773153387, 4273868103, 2604563645, 4105767904,\n        2556376985, 158907213, 3579937882, 3059825408, 1920542835, 528717490, 1430681949,\n        616489338, 597761261, 3760865497, 963173252, 2915089223, 1441674715, 1717557648,\n        1819215517, 3449795284, 844168976, 1574237607, 758725457, 762624299, 533122182, 1201164787,\n        1968174784, 896982568, 3419630169, 2247559545, 3983311870, 3975342941, 1112833399,\n        2721518545, 2493587613, 3444837338,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - s > t\n    // - s_plus_t <= n in limbs_mul_toom_interpolate_16points\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2166912886, 3021127478, 1088026295, 863338925, 1902617744, 2706401163, 3211745137,\n        3537828549, 2310228205, 2585051285, 3210490216, 612524924, 269492174, 83675252, 3088638931,\n        2020592214, 884676247, 2114372012, 2448236682, 3651962645, 4142890271, 3807368959,\n        3038213130, 1740849525, 1839016815, 3718350068, 1798083657, 4018300117, 2557824626,\n        1367910868, 3524299249, 2718734101, 2199735437, 2156117642, 3314330151, 91570504,\n        1763771190, 730175380, 3035959105, 930897603, 4104577491, 1545111417, 2973200358,\n        1531233892, 3216274102, 2879326700, 4043195388, 4012932329, 1225928231, 3148638781,\n        3350412374, 571148440, 42117077, 2619230436, 570695610, 3533920410, 2337569860, 2616128436,\n        1101128308, 986097032, 4127211776, 1459526104, 121723950, 1459838938, 1563443987,\n        3106615121, 2637954840, 238917822, 3086105506, 2960421944, 2937286162, 3871313970,\n        554575295, 450448609, 493464699, 3492897008, 3198787067, 2691863142, 874317820, 1804414164,\n        572281701, 2867423932, 412542374, 239109523, 4270925097, 1858402222, 3784404338, 162014339,\n        182208178, 171269941, 1556499146, 3122050585, 2070559038, 1293272336,\n    ];\n    let ys = vec![\n        131674806, 603734923, 2440163395, 2896151903, 2142986136, 3702794463, 407655836,\n        1281722924, 1990690788, 2883417209, 1106804242, 965105623, 3369860750, 2422075060,\n        1042530548, 1864787458, 1722387953, 324177444, 3169639558, 1324636283, 1394919591,\n        1382200609, 4014256585, 1943865290, 1318181231, 2753206532, 465681637, 3556126827,\n        3726586809, 2859198026, 1880611700, 2743775719, 2312093882, 2611444395, 2043850780,\n        1748249887, 1827465861, 1827026074, 3842470222, 886015214, 1202152837, 1760966154,\n        1303682364, 2141063912, 2027419958, 3046273896, 276337299, 1629565318, 3973822671,\n        3586055166, 515343743, 4150823547, 3812419028, 4047886683, 408756427, 30807697, 3839670586,\n        3241113948, 1946580966, 211283947, 1648787704, 1254977229, 324210665, 409019127, 999906525,\n        3589880779, 2652719468, 2740912614, 75319316, 3276454084, 3598090610, 225502084,\n        1039377126, 3755265351, 299690912, 2582901309, 891564570, 1062813956, 318910996,\n        2153235228, 2834278326, 130377847, 977327805, 3290994684, 2956083989, 826986477,\n        1417957671, 2007397536, 3845476521,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - s < 1\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        1012246656, 3781649075, 2144318856, 2608903399, 688555306, 1040133166, 3831584367,\n        1593112617, 1823654254, 840638304, 3109717334, 188514461, 398797195, 75875990, 1486449995,\n        4269057266, 3729965858, 1861862237, 3631015569, 3651675458, 103019792, 4115125912,\n        854107191, 437995362, 1626634580, 1556708150, 2197935825, 142443256, 2516681044, 165384798,\n        622726627, 2804275513, 3768014324, 1019999140, 1630141384, 1569491385, 2650112147,\n        404117490, 959368136, 1567892691, 3740061638, 1492035182, 2806958299, 3558543973,\n        2394278513, 193040368, 140963621, 2363913022, 521760299, 1509309827, 1222622424, 236238235,\n        148145098, 1185145642, 4050835140, 3496710859, 2912031916, 2811044753, 293786270,\n        1593967022, 3059741198, 957447590, 999733770, 3225819121, 389969264, 1617194653, 930042654,\n        2073424372, 1334988223, 2244143480, 3036433790, 314486992, 3505856530, 2253001666,\n        2732695676, 2150239253, 2058771616, 2553846568, 3156714961, 275374496, 2154639432,\n        1705499511, 2661128488, 2996751598, 1991220721, 2971546013, 947096109, 1988630082,\n        3629027637, 2894867708, 982953971, 1288656915, 3544920961, 2725968940, 2718109332,\n        1685012966, 2463009759, 1861144639, 2364403606, 3459863283, 983775524, 3466796660,\n        1976698215, 708098181, 3069387825, 3638611575, 2579187312, 632774203,\n    ];\n    let ys = vec![\n        1809516468, 2803977220, 3078159083, 486681337, 1568336896, 4117841648, 422990983,\n        2706208156, 3747890395, 2705136812, 2904348475, 1582408791, 723059442, 3021061511,\n        4080366324, 344817763, 4291264074, 846996023, 4266039848, 1034099747, 3469554547,\n        1098932136, 4197098884, 2840685725, 3598360260, 3858664271, 2988904929, 3788334949,\n        2778508367, 2862059554, 3453038230, 315104137, 659918534, 3119028578, 178870393,\n        1471088291, 908295683, 5373305, 1643272591, 1306263419, 808966614, 4084169993, 740212697,\n        4046005160, 2962244838, 2183688745, 2126344144, 2041407930, 201066579, 4119015900,\n        3263668172, 1482349211, 660638692, 596028971, 3002749394, 3127689329, 147925750,\n        1069598238, 1868876453, 1293290441, 1391999979, 1064595909, 1912901608, 751720124,\n        313663396, 2718231373, 1813378594, 1913592155, 2372166689, 312370283, 1294902637,\n        1519106439, 2159217107, 3862662328, 3650935678, 3673744494, 1365354839, 4239084491,\n        2676645359, 906655247, 2012326184, 363781147, 121405308, 3179196888, 1415338639, 788446024,\n        2165764832,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - Limb::WIDTH <= 9 * 3 || xs_len * (TOOM_8H_LIMIT_DENOMINATOR >> 1) <\n    //   (TOOM_8H_LIMIT_NUMERATOR / 7 * 9) * (ys_len >> 1)\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        4119986492, 3769784140, 1016845783, 1462133596, 4070906664, 3720888633, 4162266585,\n        357581522, 1461543577, 4176530320, 4211178471, 3101664977, 3852655570, 166352500,\n        1437797012, 3499540684, 1659293446, 4040889056, 2872135683, 3443479700, 655062062,\n        1438477128, 1251147166, 2862092792, 1899445621, 1706155530, 2740470033, 732343724,\n        3637646944, 4084594941, 2604690616, 4034800391, 3052473123, 2211244267, 947388355,\n        584537104, 4143732645, 753960748, 3490638800, 3716731483, 812984705, 1845462359, 65215620,\n        4176252687, 2616921776, 2554085123, 4119079055, 4015290385, 697509015, 234073199,\n        845662165, 1354305840, 981298174, 1565184955, 207005143, 3409837524, 1220287572, 729153595,\n        4103593694, 3696910742, 3965466426, 2266950204, 3856396952, 1764904477, 2684424799,\n        2851670593, 1238534904, 1193928568, 775873269, 1360693711, 2015831201, 4011315900,\n        3412793575, 214657369, 4288738109, 2288646350, 4016569358, 3132961648, 4045851426,\n        3660819126, 4044839853, 3089247133, 2180567261, 2646234732, 1387965746, 2657998851,\n        713566741, 3356621670, 3732665499, 1904626236, 64110644, 1408823950, 3590020345,\n        2474929782, 849015605, 44073994, 1392682200, 2899713947, 276297197, 2522590522, 3057126922,\n        2424068009, 1656987557, 1344629217, 2147192728, 3358875432, 3127883048, 1416207351,\n        2542101426, 711240683, 2104649063,\n    ];\n    let ys = vec![\n        2166824272, 3241826034, 3119928903, 4235394337, 702909009, 952063230, 3767289278,\n        3471432542, 1289423414, 4165356232, 1144080646, 1098693005, 2158644075, 3466960484,\n        107907398, 1849951849, 1697379716, 3245621651, 789557144, 3055443426, 3784862213,\n        3687293729, 3527108073, 2085509714, 2098672286, 4237955923, 1799505183, 4280924128,\n        1714047371, 679046973, 2920210487, 2630108623, 3799940507, 2820960341, 2480102998,\n        3063576036, 1124333889, 3649141414, 3766465016, 1301782752, 3365747207, 318110166,\n        1798715740, 3939897237, 1972418626, 525713989, 4204639302, 1845175119, 3066964494,\n        3197166778, 2045294098, 1778200774, 1122512884, 487879411, 3912690682, 2631572995,\n        119236796, 3659697136, 875446358, 2784882013, 724223194, 2290104863, 3553626657,\n        1049986268, 1149074120, 457683007, 342994481, 3969592954, 4124706173, 793289745, 50385201,\n        428623925, 330776585, 154172871, 652756593, 1305471058, 3295431270, 1976260297, 1729803474,\n        1132360814, 2965768226, 3482945302, 2017386623, 1093051437, 2874103717, 2882475975,\n        3735654948, 1766940801, 3723445548, 3203977826, 1788553316,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - t < 1\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        562392731, 220608607, 3016011233, 1988425644, 1753293069, 202000452, 2988281129,\n        1833355482, 2406139229, 3819843447, 3864310556, 2964129037, 3243750205, 1300008578,\n        213321522, 4162936161, 3499001762, 2548817881, 797422884, 3464557820, 3172918275,\n        3342298017, 4095467160, 1278405537, 2731045246, 1797909329, 915931552, 1234105774,\n        1721010619, 393116356, 3595672812, 246921897, 3156619416, 367413315, 835896205, 1133867872,\n        732164137, 2864249493, 4191919416, 2012484604, 2046119300, 464214194, 1309621688,\n        2133767576, 1817717936, 3210357881, 2703486295, 73128890, 3834854978, 1247202589,\n        3867658887, 743571365, 623502109, 2414902368, 4157134303, 505113368, 3563229135,\n        2326845431, 1870329856, 412186635, 643126122, 918171482, 3174437348, 992920198, 2549886607,\n        2594507263, 870344606, 3354423872, 3768408002, 1124888954, 3015715321, 3554830011,\n        153164314, 2571405898, 3088317836, 3826710038, 532463221, 2174408986, 4066384743,\n        2858347925, 3362316763, 3912725306, 1672655485, 747559434, 2494848220, 3353179599,\n        2958541661, 2754014801, 2253228000, 3548360599, 2532574632, 3609949183, 4224112455,\n        2830762232, 1638592699, 748357099, 2027377618, 2154359009, 2042715188, 2328113060,\n        2228778844, 3805284055, 3740811424, 437279916, 2305090412, 2502181871, 3285232891,\n        3972490704, 3821166397, 3272678301, 2818983671, 4257635933, 1730183078, 4193248424,\n        1863033893, 2751966968, 1985590742, 1553448103, 2731396486, 102894954, 1596356734,\n        2399109494, 326183031, 3303826610,\n    ];\n    let ys = vec![\n        1675796150, 1752707855, 2960577702, 4246206199, 1769535683, 1968809225, 2828046910,\n        2881173858, 4049894594, 690462953, 288094502, 2301238042, 171278398, 2941234911,\n        3855716963, 3569445656, 3999649666, 1033046275, 1441788099, 1121368236, 3979411258,\n        1744237927, 2218358768, 3293576320, 3290293896, 2918243870, 1271587143, 1530970846,\n        1057501000, 1208621673, 1776318661, 2630121830, 1577699073, 3947123592, 1916313897,\n        3189157970, 1684300643, 5245214, 2973935012, 1013692937, 2575458340, 1202811269,\n        2350985644, 938605227, 710807110, 3840777315, 2476378686, 1408221563, 3963538750,\n        1495981337, 345677390, 2267206171, 597425252, 3652332994, 1484311898, 395641995, 508511757,\n        1756437663, 1140313927, 4146891666, 1764315654, 3179667093, 2753886170, 2955381796,\n        1486042517, 194560773, 4113616196, 3870970045, 687965138, 970031260, 4029682995, 652798493,\n        3718790353, 2790548419, 1973920939, 1737499520, 3093968446, 4016940528, 1440510403,\n        2896783742, 3442955437, 3111677005, 4265014223, 2141411993, 177598581, 1546615872,\n        1296900550,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - xs_len * 10 < 33 * (ys_len >> 1)\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2699110155, 1597521691, 470373633, 1547603733, 1114505968, 121868046, 1203637014,\n        1508031395, 2678363006, 1428373366, 181016145, 2228522822, 3784155833, 1174663302,\n        3119880811, 3351843127, 1893166310, 2733160757, 573074872, 1444139090, 3771161592,\n        3202218806, 1184188558, 1337716051, 2651973158, 1523269291, 3416369561, 374511279,\n        2679410392, 1510022750, 228616166, 4003251265, 4290642350, 3280834410, 1463007103,\n        2311946289, 160203186, 1585276951, 3812024477, 3976220702, 3453132955, 903478724,\n        1692984648, 32969770, 393253462, 2089515635, 2580037721, 1368262724, 3975524017,\n        1095890302, 3362835893, 1467244702, 3126524190, 1558041706, 1473844963, 2931771668,\n        769941843, 1383766743, 2048229827, 3587516656, 744923988, 3114188668, 2900631137,\n        1550641047, 3971430916, 1024708451, 266103704, 1961354549, 2996989736, 96509114,\n        3209890269, 558760343, 1942895993, 3030238742, 3901981217, 1553802266, 1100766439,\n        3617908428, 2903765815, 160559154, 3223711195, 1505354960, 3400362702, 1532921847,\n        2633984159, 2547091597, 3753857128, 1603256426, 1467979288, 834683287, 883770936,\n        2091938738, 717946381, 1738927478, 4212395432, 3554713903, 2891799196, 2460462345,\n        1068611661, 1983982847, 4254702408, 2862607717, 205351503, 899537845, 4178691861,\n        2027719370, 1613590765, 1667586567, 658709687, 569869145, 2542265621, 4018309335,\n        3115945617, 1860868443, 2042873761, 2857432666, 3454761191, 644158605, 952236065,\n        1246066126, 1054146509, 820815201, 4116210106, 911797864, 980581305, 3662945636,\n        2395465042, 2988547838, 1592529958, 4123985797, 1086072833, 1344358819, 2713461665,\n        1166149285, 868088866, 120572741, 2719927699, 1609748024, 1381464015, 2371158669,\n        2027765235, 2167125167,\n    ];\n    let ys = vec![\n        1088368182, 3374520919, 2135624591, 387360487, 3348241848, 2559227752, 3399060139,\n        2714380393, 371475119, 1878664574, 3306012397, 3678253780, 2537332523, 634258529,\n        2378309044, 1907416933, 2176550942, 3624058493, 608851538, 77324946, 854257549, 2563267740,\n        1842976277, 2560652658, 1177372492, 4164431297, 2857340159, 2813781292, 3608170666,\n        289363804, 1276568988, 1858470908, 2027103570, 1210716416, 3885179582, 980951621,\n        1332461771, 2439102632, 78855299, 1535655076, 820717475, 1372739985, 4277759699,\n        1928781862, 2056547589, 2689637269, 3487926306, 1712399855, 2387894324, 1345157890,\n        420194957, 2408734980, 1088476282, 1237271902, 1570597541, 1299046081, 2179334980,\n        3757788366, 1320170918, 2220338411, 3413493273, 4047658929, 1004605073, 3758106669,\n        3623304103, 2595195415, 3392723185, 227342906, 3297612463, 1577658966, 3646845515,\n        1442494023, 1805636027, 1293916606, 1856823520, 2157779944, 1701394115, 1586957718,\n        2203990942, 3794477956, 470446365, 3294563814, 2801795027, 2712013665, 1473818504,\n        2726878536, 4276109446,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - Limb::WIDTH <= 10 * 3 || xs_len * (TOOM_8H_LIMIT_DENOMINATOR / 5) <\n    //   (TOOM_8H_LIMIT_NUMERATOR / 3) * ys_len\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        561532292, 1489901668, 253691236, 2318497628, 4251899866, 2953100123, 2461942387,\n        3249119706, 369296206, 4217598289, 2953582842, 2377320700, 2568035293, 3298340549,\n        2920237456, 546954422, 3577037488, 92033404, 145112422, 2502470868, 1400281201, 2303329463,\n        633903343, 3944799609, 57410139, 3300617501, 2988597979, 3756577241, 1111328153,\n        2315706065, 2359556880, 170569603, 1875977300, 2265470483, 1673672630, 2694260146,\n        620660163, 4086502272, 2268845329, 2531408738, 745892765, 2985301421, 641961881, 620799476,\n        1513471210, 2206613713, 895576219, 3432428917, 1326478424, 721293050, 4129832181,\n        2328492091, 790053303, 1886834609, 2560250292, 14318242, 2263105643, 3768652300,\n        3685567034, 1053183071, 4035043131, 1140590999, 1312717632, 820131789, 2381319255,\n        515196511, 2436315339, 513976227, 688721295, 2969875582, 2843970288, 567346371, 2277297382,\n        3266747935, 3125131739, 391700432, 2628083321, 779071641, 2971551059, 3314957816,\n        871191953, 3336232721, 2709555815, 918246312, 923872244, 2827827195, 2966239254,\n        1586350108, 1024706608, 3525365202, 594940169, 1872199600, 3239665333, 694926057,\n        4271587637, 3916707341, 2190558956, 2300957253, 772629754, 238192213, 4247448230,\n        3565892036, 3184365211, 2516885224, 3979985839, 1180780557, 783722885, 1061155274,\n        3798456603, 3320505371, 589311966, 1623819314, 1001947009, 4232577387, 474033387,\n        3930737007, 1729002759, 3148522805, 658463592, 1424102704, 2305467923, 552214960,\n        1642169523, 2066768192, 3794357111, 3557589618, 4204044663, 1778418301, 1181058217,\n        1612951946, 588858899, 3836952607, 2977777237, 9660119, 2962495164, 2992962211, 3923151463,\n        3345257705, 2981383558, 2363319525, 3608470059, 874691575, 2586822309, 912499640,\n        603852379, 1888867173, 2770352234, 4238262229, 3877831016, 2596074823, 3663087235,\n        542677879, 228437282, 480155344, 709141324, 782255006, 2839979153, 1271748198, 1031245745,\n        3053801112, 3462023195, 172164778, 3874269611, 3279470898, 4076666435, 3596981639,\n        810288236,\n    ];\n    let ys = vec![\n        2267307147, 2856749182, 90961593, 1052868712, 3437758783, 899762302, 2825414504,\n        3100252964, 214994098, 4262558841, 2740902902, 1743352008, 1922058509, 2975766063,\n        3399126202, 897115238, 401142729, 1715015464, 244955103, 3177992227, 405891649, 1768495060,\n        3524094602, 4080016656, 1432684874, 3397000143, 434821341, 1754546815, 4094846559,\n        4286153335, 2240106918, 2310322076, 1713831329, 1428414845, 2188185809, 2111765503,\n        1131727372, 929039425, 465389857, 2677898170, 1160632541, 3376736943, 491317513,\n        3242464822, 2045506450, 1242019843, 3965879224, 2484620055, 3447163057, 2809067396,\n        2409780789, 548871240, 2024164190, 4133800101, 105887616, 4257692355, 1942633927,\n        1532037864, 2395107706, 1815832330, 3470252735, 3388820081, 2275739186, 2499364631,\n        2076801086, 3670985009, 395675635, 4219873512, 338672631, 3757753689, 730801911, 529959909,\n        393050276, 2506914867, 349901023, 889932113, 2359995672, 2260685091, 3193258383, 993644814,\n        660499678, 4213349264, 915065087, 44382277, 1138965336, 3728412916,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - xs_len * 6 < 13 * ys_len\n    test(xs, ys, vec![10; out_len]);\n    let xs = vec![\n        2628750713, 2361938253, 4208887130, 2080756349, 672997060, 2130716095, 4212789307,\n        1848408220, 3496438901, 84923093, 3765911616, 1894564551, 1611354899, 273564832,\n        4150644671, 3064400972, 1543250045, 2858928926, 1070491873, 1579001797, 1184344436,\n        2022081087, 579467674, 3617124184, 243126922, 3969739693, 3428743965, 4195070089,\n        3234082950, 333482038, 2496442330, 894715026, 434494401, 2735937738, 194433417, 3547773069,\n        1310458322, 1092526211, 460831665, 314882384, 352225614, 2524634920, 3907974253,\n        3587596708, 90585625, 3922151265, 2706453821, 2479984430, 1899379393, 521798300,\n        3544490367, 4025847744, 520557399, 1960228079, 2440638916, 3922652110, 2874111917,\n        3780219346, 1155970954, 3101729918, 1154605497, 1641746684, 3885558155, 713658859,\n        2298415211, 1104859444, 397648670, 938276629, 2245930839, 351999985, 3962599907, 162580649,\n        4135267160, 3893533927, 708603373, 3649893874, 1549341047, 446919848, 3848748260,\n        1193215655, 1667453481, 4263900238, 3083741929, 569862864, 111540402, 371222591, 836814821,\n        2523967214, 3373518119, 288800478, 2983910658, 3822451776, 3717238299, 4103554210,\n        497321656, 1267537380, 2210886058, 393666292, 2341926460, 2993069655, 3449632275,\n        345728673, 1850135319, 1546568315, 349065480, 4148532822, 2743969263, 1135023914,\n        856540508, 710683508, 621037301, 2245404525, 1375763902, 4230256152, 1103848377,\n        4068950000, 2774111626, 4005998377, 1420452414, 142442998, 296389949, 1793483671,\n        3236856344, 1470778143, 2199111141, 1485252921, 3021831668, 3409728715, 494048497,\n        425352623, 547187992, 307378564, 1878128309, 3632431108, 3608263098, 3158948042, 268203532,\n        1889965332, 2413564070, 494017444, 4018318246, 2256416411, 2325799856, 424840978,\n        1475143253, 2578705133, 3454058108, 875893914, 3369487214, 2161583703, 2368049199,\n        3710749831, 2234731371, 2548143256, 1212646047, 775618131, 821458424, 3027168315,\n        841398247, 3991240853, 2094376383, 3587145176, 1943420573, 781156526, 2434343084,\n        2126213029, 2402207510, 4019808646, 316909832, 2750686513, 2438176721, 308346316,\n        242903105, 3531437189, 4095795963, 2087963376, 3007755141, 1683404210, 3086330285,\n        1333246101, 1581088323, 1356633529, 3666603849, 540703941, 1410918479, 2987931996,\n        2750320701, 3483743338, 2503688388, 3308034421, 3019960566, 2668657879, 2363438262,\n        1470517413,\n    ];\n    let ys = vec![\n        2312659839, 2350424241, 1787407270, 1271425122, 4187967770, 818645453, 3539315256,\n        2178962268, 2575529612, 3589703821, 2051328589, 1350506812, 1181962471, 440960359,\n        1364212437, 3414960630, 901255513, 1225743051, 2301315145, 1970642256, 2850715818,\n        3128888797, 2317420929, 2155667782, 1962983120, 2710186451, 648444928, 2272821232,\n        133989660, 3141011857, 1529770260, 802759102, 2173416392, 1305065341, 45650077, 1082105231,\n        1602486318, 3755990436, 1936896216, 2400713018, 1591016508, 4068454220, 3596573883,\n        2619324298, 33580971, 2286577695, 3083324417, 1169438566, 3225233768, 808739442,\n        2766243970, 3455083573, 1549857550, 3592398125, 2248831497, 3521856807, 1967034,\n        3078700295, 1346379862, 3820864333, 2903766704, 3884607466, 4174763992, 270916374,\n        3218398044, 3434381035, 159751999, 2768080251, 2464394277, 566049661, 442155673,\n        4112913396, 1456961327, 38309439, 1525792638, 2372197825, 1956558568, 4294769490,\n        3096019721, 2031664251, 3017984223, 1381760341, 4260655051, 2253457354, 2984264086,\n        1088854315,\n    ];\n    let out_len = xs.len() + ys.len();\n    // - Limb::WIDTH <= 11 * 3 || xs_len * 4 < 9 * ys_len\n    test(xs, ys, vec![10; out_len]);\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_greater_to_out_toom_8h() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>| {\n        let mut out = out_before.to_vec();\n        limbs_mul_greater_to_out_basecase(&mut out, &xs, &ys);\n        let out_after = out;\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(xs.len(), ys.len())];\n        limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(series(2, 86), series(3, 86), vec![10; 172]);\n    let xs = vec![\n        4161517722334671206,\n        271035878974614969,\n        8768264966582261304,\n        8206956804546718361,\n        10016740860128464264,\n        2943682457917422384,\n        10577659840261915262,\n        12098681961003341371,\n        2525073961085508373,\n        6868684266500244649,\n        509821878609210517,\n        4263249474085213536,\n        2307565444887817803,\n        12419028787241261317,\n        1281995004584322618,\n        13869993964458308221,\n        4485392892470363180,\n        3274613913599014818,\n        13075432300049036016,\n        14042578030952079199,\n        13098932791585915075,\n        10142506622182970580,\n        7251838551095799764,\n        17051632328075633635,\n        14834683551906590335,\n        18022997779550454484,\n        13851155116066438974,\n        3279920275984726839,\n        12575373964173554443,\n        15489604937489489906,\n        12630529117895897413,\n        9562379919499143009,\n        1417878505992996127,\n        2188363987094684136,\n        4744951957683006311,\n        12112952790370550632,\n        313413052918057660,\n        952838993607855174,\n        5933080761807357068,\n        5875775551766205334,\n        10228588026136726855,\n        13111641204516926240,\n        10636665232562365918,\n        11359964631071199362,\n        5929704785320756798,\n        7890881054270407934,\n        4884891330151666074,\n        11055829837821054078,\n        13707765469312479203,\n        8153558212434726394,\n        17445193585880639275,\n        6568289716541023323,\n        8041757936108402209,\n        11089742802624534358,\n        9104866424438942973,\n        3236275382520001400,\n        9213626463300221545,\n        5359296447813232573,\n        2888775200925828643,\n        1504166968227419931,\n        14327007717613163305,\n        11802896026004225094,\n        12726419078417922871,\n        13309155468447837337,\n        8586421913645886721,\n        53962250520164792,\n        10299535356260218467,\n        16946113957982976032,\n        2902460381404773190,\n        14757465720632393328,\n        4285719983639600380,\n        8437230965528545912,\n        5716398831975234496,\n        1373020012523386515,\n        3326027605041066746,\n        17656221602314109866,\n        5927567778944922379,\n        7395768072445629410,\n        11551011221061348004,\n        13862329630891761456,\n        3443745263810155735,\n        497965567194021216,\n        13073929868627981515,\n        9340721263069758697,\n        16189911797862953019,\n        17331477506134450185,\n        18441976800868209749,\n        3733349995001197864,\n        6937510789920909911,\n        10459182483341515090,\n        16282716012969111817,\n        3142838808933013004,\n        176169927348158611,\n        11447076894000834768,\n    ];\n    let ys = vec![\n        3898028307372664956,\n        17056541935478225194,\n        14004255653437064260,\n        5500365157672511509,\n        15774417221201329293,\n        3229812365626959565,\n        1542674716041014040,\n        7356251598468809943,\n        18181760582149085284,\n        6447899299954117957,\n        15228766707939040914,\n        15272444333081468110,\n        8256864946368840840,\n        15131537266446006793,\n        15615697223616434527,\n        18149135087211146951,\n        6359898540214993921,\n        11306735121000975748,\n        10447887135010383963,\n        12772438236294882417,\n        17631737056955710770,\n        8945404460793598129,\n        8945720889114856152,\n        3648711115155303988,\n        4353348842999127960,\n        2258094147328762698,\n        17154005505580115535,\n        13882701371593165208,\n        1610163839528654069,\n        15350954595089578211,\n        2071555476679360064,\n        7797386300145290156,\n        12827100752536039252,\n        9294676638100895403,\n        13194197740670114341,\n        9490868657650122292,\n        13133123495028388830,\n        12350221742051084451,\n        12424378851382358824,\n        9807292823459903392,\n        10987641767148832341,\n        10914994897211362878,\n        828242546480310184,\n        18006801931269403354,\n        3042908768715701160,\n        8117699035539485321,\n        11944855102415629844,\n        7384949013429384602,\n        11066738683960763872,\n        14686958392900209441,\n        16412025437157422416,\n        1334344044228684681,\n        1631366399820348565,\n        18062594111889109095,\n        5175299421808157128,\n        16616812968596909641,\n        797326939277169478,\n        14593183003025528412,\n        3580961852669434633,\n        2104948106588459323,\n        14322976299272137248,\n        3536903766355663369,\n        6932211742640251008,\n        17616766237027326857,\n        1477865108082927148,\n        7817082715310166375,\n        16183969129154492111,\n        18146981620947356859,\n        11618268397687338183,\n        15294321769160092821,\n        2447614867702883346,\n        15261926111061449320,\n        4029723450982123355,\n        7820711996327940306,\n        6188156586792352365,\n        15703528769184364862,\n        6698415575574578533,\n        7770946582061166480,\n        3543987370105940918,\n        8845414905041844753,\n        13110356713999163167,\n        12862812457872444435,\n        10749027774576978236,\n        17822296942008093229,\n        13898152040175560707,\n        1879212271519144526,\n        5428215269251527991,\n    ];\n    let out_len = xs.len() + ys.len();\n    test(xs, ys, vec![10; out_len]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_8h_fail_1() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(1, 1)];\n    let mut out = vec![10; 4];\n    limbs_mul_greater_to_out_toom_8h(&mut out, &[6], &[1], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_8h_fail_2() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(85, 86)];\n    let mut out = vec![10; 171];\n    let xs = series(3, 85);\n    let ys = series(3, 86);\n    limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_8h_fail_3() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(86, 85)];\n    let mut out = vec![10; 171];\n    let xs = series(3, 86);\n    let ys = series(3, 85);\n    limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_8h_fail_4() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(85, 85)];\n    let mut out = vec![10; 170];\n    let xs = series(3, 85);\n    let ys = series(3, 85);\n    limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_8h_fail_5() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(86, 86)];\n    let mut out = vec![10; 171];\n    let xs = series(3, 86);\n    let ys = series(3, 86);\n    limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &ys, &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_greater_to_out_toom_8h_fail_6() {\n    let mut scratch = vec![0; limbs_mul_greater_to_out_toom_8h_scratch_len(86, 0)];\n    let mut out = vec![10; 86];\n    let xs = series(3, 42);\n    limbs_mul_greater_to_out_toom_8h(&mut out, &xs, &[], &mut scratch);\n}\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\n#[test]\nfn test_limbs_mul_mod_base_pow_n_minus_1() {\n    let test = |out_before: Vec<Limb>,\n                rn: usize,\n                xs: Vec<Limb>,\n                ys: Vec<Limb>,\n                scratch_before: Vec<Limb>,\n                out_after: Vec<Limb>| {\n        let mut out = out_before;\n        let mut scratch = scratch_before;\n        limbs_mul_mod_base_pow_n_minus_1(&mut out, rn, &xs, &ys, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    let out = vec![10; 905];\n    let xs = vec![\n        6809535447687914471,\n        1103330005972507068,\n        372788324988356904,\n        3310988417383334329,\n        2768136713654061049,\n        17867128683005223868,\n        2238946582723710409,\n        3081056558438604150,\n        17026613024401611127,\n        1744473747933758430,\n        4884032754714318833,\n        5071706901657208751,\n        12689572021505695693,\n        10978480551041753799,\n        1800129976413451867,\n        16286820002622524539,\n        7281000574726170357,\n        4219678291438654832,\n        15700081839772688751,\n        15205907878248907247,\n        14393184334614991066,\n        14756848254875178077,\n        4793637008204029812,\n        9858797803427744303,\n        16884118866110086987,\n        2330774877124323542,\n        16233995226797389662,\n        6091870787973288330,\n        5905123672617126566,\n        6532637120046850310,\n        3781012952181700512,\n        1147955258215944149,\n        16381863291477272057,\n        13470194198585905847,\n        2807745192926696062,\n        10417338102018291024,\n        1182003379390951531,\n        10572015994470653864,\n        11256589899556451377,\n        7047560236256902575,\n        16809106838958682299,\n        8167397083217775737,\n        10405120914265859441,\n        6050515699222625782,\n        17283763639396397450,\n        12481792043865481917,\n        10515115098175408116,\n        3547231139273206009,\n        2955870806881464447,\n        81763485884574417,\n        18038197306999979657,\n        2697663113419170508,\n        13640328591104580425,\n        16380387086795482436,\n        5937997179794219672,\n        11280227770841311656,\n        15247718447550407960,\n        3356207189433327172,\n        9295483089881333487,\n        1048090603086884014,\n        17630347864859687326,\n        16292502783826501772,\n        2554058376409680235,\n        8746244974811121511,\n        13601151617020904249,\n        11424464616482878222,\n        16592787416774613845,\n        9541965809588758702,\n        10304263209519954371,\n        9718232210246640079,\n        3964199137038797179,\n        1133689222449100290,\n        11762544598027160268,\n        8892566166642784135,\n        4992855273094478682,\n        3467095579457639126,\n        17527051578764837605,\n        12788831523184320706,\n        15884832626408420422,\n        15445614371886990386,\n        4605408054811466579,\n        9468992277252416191,\n        16059556135741327423,\n        13703354904914355468,\n        12651524370372775470,\n        12076530382821868093,\n        9203720925482564499,\n        6751521177612318975,\n        14730048400600245248,\n        9583087821356332745,\n        7635737274166465491,\n        15909961927185268608,\n        15152412967792641434,\n        1117148048506231546,\n        15036765086001151283,\n        9461075977858154319,\n        283984775170615496,\n        10870934978120381565,\n        16402595751643852267,\n        13300950714409955136,\n        16269834104766854165,\n        3823800040156766433,\n        8001239710257605750,\n        8854456135465589491,\n        3559503577426585699,\n        82907824154359285,\n        10429508186090534661,\n        1795271336507026791,\n        16052612691484506490,\n        4449527904102534257,\n        6652828614119627650,\n        9436314767260323923,\n        14084834581845197080,\n        3924506166878684856,\n        4006253714000661354,\n        16835787368527074469,\n        2939573978616449941,\n        827685924983906914,\n        513438846841933201,\n        5499086145667050935,\n        5970432596053952196,\n        2357808915999726215,\n        13130152994826263557,\n        1029371010558121271,\n        9673453535289645591,\n        13630045027309361503,\n        15140438118448998733,\n        14475237670869667854,\n        646607524428232975,\n        8603154126726854477,\n        562632002079264944,\n        11132087168116199036,\n        712016548873706286,\n        1162552953778143562,\n        2720821187699295729,\n        12629405027198622023,\n        10085431077125120126,\n        11036408623217209328,\n        9412034889605831573,\n        3580947814659655797,\n        2384617485952276249,\n        11991332791506170431,\n        355732385395682650,\n        11957596579072080069,\n        7637503009753705463,\n        8641065560841157989,\n        5385185370436588141,\n        14613602605895034796,\n        16149929536213837897,\n        14926494841744326505,\n        8478550502351441150,\n        4754411934055301811,\n        8446559217491804253,\n        175563428577047295,\n        13317411913787179089,\n        1999388610388624930,\n        11997574948104529333,\n        7709394800320180604,\n        141106960118475071,\n        9185076664574888313,\n        14711830716786764563,\n        8646328906792567341,\n        6435770954980752754,\n        10889857927018380675,\n        4856598903599320278,\n        5559749328765755744,\n        55448005653193385,\n        18376290341644060781,\n        5411230779476997204,\n        3208977317832509473,\n        17939099296520163690,\n        14610289283912272679,\n        15727344360076838968,\n        17691225907664733828,\n        6277158099136871988,\n        6227268882497066304,\n        10537912046761025798,\n        4569425383713839933,\n        1540443185169512503,\n        8083699057632389568,\n        7713824171800942769,\n        8199521127345296820,\n        18024850838783811685,\n        11847360547777377558,\n        4462968389243655548,\n        3995475265600836322,\n        1735988164410255922,\n        5169863977080869823,\n        2205341702567171145,\n        2235183401932173280,\n        4237083636488253034,\n        8651273126396740151,\n        7677914001769310460,\n        2488550701988271373,\n        6362894001274871299,\n        6938141915629282617,\n        15289077957178314583,\n        11369273085874533146,\n        15146552950762343609,\n        2250130405529921684,\n        4507408042222997556,\n        12067657188384750699,\n        753594982979265248,\n        9819871477024072995,\n        8074675523776512539,\n        17863686634271613087,\n        10148559641897798765,\n        12078707926245944334,\n        16056144107847929568,\n        11477562644132166451,\n        633839849054735197,\n        1974937519863601198,\n        9431759751115500349,\n        16231263638095445675,\n        2852944099010004296,\n        10805052896366212239,\n        1090853228632071464,\n        5943661063504137996,\n        12279437176065016726,\n        6997180572817064008,\n        5167976820090909749,\n        7252605595265132660,\n        2377574067337995256,\n        898853472418766215,\n        15283250736100608687,\n        11681971203683297764,\n        15733049786589504720,\n        1874550821442898161,\n        10775751683446032879,\n        14346795044143203654,\n        7996691180178068337,\n        7988670994586391460,\n        15438536777951336029,\n        15583275281862893881,\n        1645086929138484726,\n        345744887729039216,\n        3687893952132688571,\n        10659362456954960532,\n        9602393538964870338,\n        16520689555988157334,\n        12546754178798486611,\n        8040849778898919845,\n        18425567932309437192,\n        7524804173796997825,\n        7482803818757957426,\n        2159381166607938760,\n        11953191500503254263,\n        11662381083106843270,\n        15954507061982303817,\n        2311355641538841753,\n        6262214959978467810,\n        3205610786437952171,\n        5833762588841339039,\n        9584891950834271718,\n        16431258786750754174,\n        11295777256302945260,\n        10262743010189168916,\n        6579167273633548585,\n        10655344951630924167,\n        12426159972843518796,\n        13809556914733676017,\n        10421408021758282646,\n        13742014587503715343,\n        1213383935103977733,\n        6155186430649126184,\n        180686018379637244,\n        6671736391598895649,\n        6711423272868884639,\n        10567222126096946863,\n        236255051969434496,\n        10538599139522078386,\n        1840416208489527534,\n        14920772374579070414,\n        12181583640158673672,\n        13150385378549419551,\n        2385161800547570055,\n        7427796248918503499,\n        1086611422915217495,\n        1034188908993802486,\n        17895224758095668351,\n        5605583861310416260,\n        8276090981819119594,\n        16774347628768167103,\n        4438689443393994418,\n        1445832965009646259,\n        12020209207509332983,\n        12101154623632027374,\n        15952145139262310731,\n        4569147745515423074,\n        1032438357998575006,\n        7719204784227574899,\n        7620365528941515938,\n        9134138337791325501,\n        17595820721307989341,\n        10837897611871188641,\n        3628300610284347069,\n        6056782082517998847,\n        11889121953261384595,\n        15658848261681587671,\n        760281128415892566,\n        9901843341271410215,\n        17997287540098693599,\n        11471174400256577350,\n        13773435664609284401,\n        224645455536727129,\n        3248370257584471677,\n        3402146064818516495,\n        15419892046652096835,\n        6817408051904455983,\n        13462567452174648864,\n        3865219578658340818,\n        6401692728490725482,\n        12241061753482985847,\n        18093898726091231688,\n        2085695270753393724,\n        1486152210073874278,\n        10962392580868374592,\n        18233050379629714175,\n        15440497426454102854,\n        17029248778709090701,\n        11943840019902256468,\n        1838494147415724342,\n        10624384750477063994,\n        2802400104447544796,\n        14482700272009891532,\n        7488752288284248623,\n        16689053330367821624,\n        8122258539396763672,\n        9378594940099937779,\n        1953829770254669263,\n        9095248272317331200,\n        8866691394084862202,\n        13201017990930506125,\n        5874101266603325988,\n        12758355031414108476,\n        10906401543018450367,\n        7070115242582431545,\n        8015463853343573521,\n        6337419761897564053,\n        8245569799737529081,\n        2143044650526073628,\n        10001469296387640338,\n        11129612211343148678,\n        9846592166231801208,\n        3293328206977069772,\n        8271586651454757561,\n        2516303987084978983,\n        18226852422794010543,\n        15105013013529789613,\n        18154225228636318154,\n        2013990863661732083,\n        1784747160358384741,\n        12567581004427688912,\n        12324983884662973603,\n        4935897487517618842,\n        14994876132441559883,\n        3460392282827044973,\n        178151701108469307,\n        14330685158880278679,\n        17005759398710652579,\n        12918079073431941444,\n        14737890013936547836,\n        13116140709796209375,\n        4406659418908136238,\n        12427086661031458855,\n        7492548499951595477,\n        16111633531233494957,\n        6547469955282364389,\n        10562100669850668222,\n        15418878616411295006,\n        4956757255402949102,\n        8013302230254643702,\n        528640010877453099,\n        14207088120532813066,\n        16751882716911936366,\n        7949419147113034512,\n        1638837693666608472,\n        13878268226712426549,\n        8273407385523164786,\n        11509174550235804944,\n        15966833959669295468,\n        16501367189938100697,\n        18237618137386130737,\n        12449896376279048977,\n        18110666911456042806,\n        3193062725115205782,\n        6188346541223558421,\n        8058450572610971381,\n        6102995183728564982,\n        1217219394955358461,\n        4696899915064498873,\n        3897448246350199671,\n        12662172956137287871,\n        6610124623177066401,\n        17355303367288349560,\n        2046855789488294262,\n        3211014904560014361,\n        17115241076245460723,\n        15298358927000333664,\n        9182539314691893135,\n        5164209594070862585,\n        9062044958688820752,\n        11123512834458221854,\n        2659061244791686400,\n        6806035717656270289,\n        1027290028815967628,\n        9405947735639936936,\n        2540349601344589130,\n        6895259978837037548,\n        8904474026325226434,\n        12273615493885622366,\n        8677764880724506780,\n        6002959367751808149,\n        13123965742105252412,\n        11735284964695785299,\n        2417001610052848193,\n        16769279424767143997,\n        7098399088498274096,\n        9910748236374366737,\n        11111297830299095939,\n        13640041663283902885,\n        15915174780574330612,\n        10929481089808875146,\n        4581632826936763294,\n        8581099749824253588,\n        12645736569302882821,\n        7359153121066395683,\n        114042912187761457,\n        8021867264848320576,\n        15492861144941287563,\n        17574065125533105845,\n        16374369432221228355,\n        10459169993431587286,\n        16366034776295832243,\n        2627084718398353897,\n        18099240392705942111,\n        4326916362018195403,\n        6552915731272193737,\n        4273219172539573763,\n        12682979794809012349,\n        2630341686377453497,\n        2883112777041844122,\n        17280553753834600520,\n        16523493292363775458,\n        4645653082909935710,\n        10857150457399097857,\n        16240900012104288727,\n        13936061320958754124,\n        7489056125188749067,\n        3240618672663587347,\n        4473897013556224538,\n        15959787311013455542,\n        6807910945586226902,\n        9410336371061067189,\n        6906088553149840730,\n        5605158148442495482,\n        884531864210940213,\n        1872297304786275835,\n        313522309067627421,\n        17334018801756959340,\n        1675436862731542012,\n        8842978529412038193,\n        16491099153488944340,\n        3255602365380029669,\n        4091823593236384660,\n        9059086866751700824,\n        18074592049968473162,\n        8939611511088706324,\n        2901954556715326677,\n        3168063820638083277,\n        9642457237234984168,\n        12973730047202029231,\n        12383420012085361069,\n        11980461635855055601,\n        815939574328079776,\n        14011981531029282088,\n        3819777392902083260,\n        3664266433302366398,\n        3842827072078938508,\n        11680613555445372946,\n    ];\n    let ys = vec![\n        15245088662193948010,\n        854969528224537163,\n        192457876290468361,\n        3156774054099849881,\n        10102117358735393641,\n        13923135497401538045,\n        15603007686998930972,\n        3707765480829539463,\n        1075990372015045994,\n        4440028045035707188,\n        779932550205535682,\n        13284596850012603887,\n        13447370325749987403,\n        10657005451799608034,\n        17344058779081327933,\n        1801131630646010099,\n        17879455113972297046,\n        1049662270419803525,\n        17887003202529550415,\n        13730724178286439296,\n        3086493866184691051,\n        7455503161286080904,\n        14945249663072669446,\n        7413071270018261565,\n        8165098975144402988,\n        15667870805615006559,\n        4534237642686726425,\n        5675059133984408369,\n        13542693529471369730,\n        4650690134857994243,\n        10593876026982724440,\n        8719234160809710444,\n        7340192483727047710,\n        2225660849988538666,\n        3260628781823840386,\n        14784063213821786553,\n        13478324037708856111,\n        6239844587086244103,\n        14508626048519473050,\n        11443816492520902359,\n        7084448144752764341,\n        11673478635762496725,\n        13444020463604694513,\n        1798574113181758005,\n        15195278749704748030,\n        3490272214933312037,\n        15632500462832370824,\n        9808665338648603851,\n        6377980234800091876,\n        11306384233660763805,\n        6392788317448223882,\n        8005181869701567455,\n        4601526777105113530,\n        9348184476999479133,\n        16105441815997897842,\n        15373735633778437011,\n        11733794529384137433,\n        769246272107807645,\n        2922899274256775805,\n        16218486247871807873,\n        10650657974127272786,\n        579665301817927565,\n        6403006378940431337,\n        10150254532952843560,\n        3736822004545760197,\n        10244207440138560761,\n        16631379436671010056,\n        17418302422321190629,\n        4844439457855539440,\n        9662799133272397874,\n        11622100630061039998,\n        11017257064923257696,\n        14025546287952884200,\n        1170766120552674008,\n        4852413824670160293,\n        18019298735978800767,\n        14042374992041286164,\n        6103187929964524269,\n        5988592592688695870,\n        5579172720281387479,\n        10738878044274955012,\n        8401646271610146442,\n        12016061916593958227,\n        14752402557741497038,\n        5053283107906893264,\n        12910662726197463795,\n        787526459034857809,\n        10304827788120361107,\n        8387521101013404665,\n        6030209567663971422,\n        7511028869236306454,\n        11105170944119024313,\n        2911699195421772292,\n        11710398806568443147,\n        7599646386487625804,\n        2146501359265516686,\n        1193294087739295886,\n        16419769173966961854,\n        14779980297792837632,\n        6286361066120350249,\n        8246126699673376536,\n        2339493649448723726,\n        12383521129608538925,\n        17459816050942292574,\n        7213741082075285427,\n        14702683527305456088,\n        17849030573001874153,\n        3273901152373442943,\n        10086273715179643444,\n        14351251935054659627,\n        3067622597087477151,\n        4241957707372911307,\n        16686513037697490920,\n        1503886102490162470,\n        4222986769290077389,\n        17209928444872897872,\n        10064374817012298812,\n        1391022681726221923,\n        3482099619102309134,\n        151151415131464647,\n        5477310851692317777,\n        8185741896741403527,\n        12297179519749775078,\n        6980896315258250234,\n        5491311995173541969,\n        10908311176531272611,\n        15140263006374103771,\n        16292302828281485620,\n        13488663273854028028,\n        17078235461511918753,\n        523009743565281503,\n        11105648925812514991,\n        13827146014280242829,\n    ];\n    let scratch = vec![0; 964];\n    let out_after = vec![\n        14914577666128062141,\n        12068273989972843735,\n        6116694005478833271,\n        3562611869773989286,\n        15670691724611128823,\n        7249128461000381996,\n        15151435496873338180,\n        13770931346629219578,\n        1187535282027344550,\n        16236693325430049515,\n        2991034239214163143,\n        6018061923835566187,\n        17284480928832658068,\n        14451687627520119240,\n        8458802009939241800,\n        3578663573390196265,\n        11053350197861111769,\n        10545908371462300770,\n        12247772832897108412,\n        4468839684066577960,\n        4549770468763696098,\n        17752125097317086921,\n        4544887864950226436,\n        2945143834276229802,\n        13648049166616052237,\n        12600592346334587273,\n        166409088005131745,\n        13013620684136565587,\n        676730163848086040,\n        12404388221407599051,\n        10705640677758869552,\n        4689698885735113463,\n        9700890479828306187,\n        9036861144548712951,\n        8094206411676899952,\n        17821082304555823758,\n        5054804670485674122,\n        16421357706067082536,\n        9704734314786980295,\n        13265421291054572321,\n        4619919032177510478,\n        9576547362592346883,\n        2025158308184190088,\n        4984956647828393866,\n        5567014476440543897,\n        7390123682276500529,\n        18303245037317000170,\n        4525541943295462130,\n        2509303616856320788,\n        15659980472438820675,\n        13570563127509629314,\n        13564844957739564512,\n        5956170799543933857,\n        14572147749185034353,\n        15936664264029850696,\n        3337746889684993302,\n        5339311381497232535,\n        791608983511277044,\n        8425434054207053106,\n        4098815735774818440,\n        13011885841922962026,\n        10478691500722275800,\n        288311354477678992,\n        16688724556777848799,\n        3854559944896493088,\n        4787579643539441431,\n        8914365544703418944,\n        14867687936657046038,\n        17948945926508777996,\n        17265394933400453261,\n        6520518082305967564,\n        6823369778027186436,\n        14260127132198472109,\n        5636179564496979683,\n        7510494946039669953,\n        7445089968619727375,\n        13151208295034342548,\n        15327531597402220486,\n        6165165423748958807,\n        7649301241163383867,\n        932300362699473366,\n        10332384620840363496,\n        1645779973200198914,\n        6819633096753052339,\n        8430257326959342191,\n        3365328330624946043,\n        17882376594601626429,\n        7931772344347882099,\n        12207106533717173393,\n        9553942214328281184,\n        1211963965695483236,\n        5986284857424925918,\n        1725008760284435757,\n        13885703170228952143,\n        679979762314983844,\n        2803926223916590493,\n        15129803423596480560,\n        5700355505192464858,\n        6737697386531803219,\n        11676336532156262967,\n        11219388591096271471,\n        6036126874875117221,\n        12759399619486488762,\n        1075627928411788278,\n        8986609583347352588,\n        315614912525710770,\n        2968976622267634808,\n        9398679997246989312,\n        7442449431966307944,\n        11074315772256995625,\n        13059753170473066158,\n        15516530300302448410,\n        6694913298086290552,\n        12225172653086039386,\n        14693751743728804585,\n        8946708930559907274,\n        14677397241988234315,\n        3209366617332728026,\n        6979717107269587401,\n        4941778982576664589,\n        12304520439559413990,\n        16634028143562183371,\n        8142239299779908752,\n        13355303957199352688,\n        16647311136213462709,\n        4819997788796101212,\n        2740900572266512222,\n        4917952099793992792,\n        15276502006380998408,\n        11163544344324054972,\n        4805821501449058572,\n        8031120161948062386,\n        9296985703342487576,\n        16564164538495558074,\n        4151584010060908718,\n        736580097771121849,\n        17811365526093310331,\n        3584057130812467869,\n        15343174508489570281,\n        6663904409520260794,\n        5148198311285516597,\n        5459037875257818034,\n        1732839752669203018,\n        5817171919148564506,\n        14532823584962157630,\n        17664910567425460977,\n        1606328717145502899,\n        7258676117087673712,\n        13564853056256859610,\n        15566073818913471128,\n        17505691249649149638,\n        8720681711808526345,\n        9299675336460004741,\n        12175130218583331200,\n        17275662125027429780,\n        5254636675017986768,\n        4584180635141974747,\n        17229718845518394206,\n        9903358674827047499,\n        14227884446253370289,\n        10238808006451695682,\n        15776343954783670697,\n        3568203177480129616,\n        10791516058691563224,\n        14667733988945443113,\n        4760849120471199172,\n        14824266274906749858,\n        4738766195452531583,\n        18201869520178488918,\n        7991042165868231006,\n        14001045459551827213,\n        9728825906169570644,\n        16356820821501653437,\n        4624890364800751139,\n        3202345381085270173,\n        10825323351814264733,\n        12844260821347730875,\n        17890471175274365223,\n        15983756164008599310,\n        9229389060056964014,\n        7980425933216172325,\n        14689445497065509264,\n        3947266856163410121,\n        13986662827479113948,\n        14086840354569963505,\n        13182084671726443227,\n        9173479010912744389,\n        4592278812024543534,\n        15484536985258289385,\n        12413608308331869638,\n        2694433334520487941,\n        1628652491883279350,\n        3020979365812132524,\n        4761921028454215909,\n        9912693764834406519,\n        14831540747828363756,\n        8079998785196191830,\n        11252016841358535301,\n        1583433672276669340,\n        3452712503195064151,\n        3057285240369947887,\n        2595743348455770874,\n        13596185098573058903,\n        11667772373252099988,\n        3692370881551772687,\n        14912011223264263901,\n        3289162294555844501,\n        11705734929820375948,\n        17609626782993672509,\n        18117255127345119328,\n        1604093155153663473,\n        9302755008283648290,\n        4607754412797627670,\n        2438148241672671544,\n        7767633059920523266,\n        3595119232557040143,\n        12437965844493362543,\n        5945493114625270416,\n        1881882682439839256,\n        12119104281808262978,\n        6340145747352803155,\n        13626236273901226360,\n        13270069380549785256,\n        15850889016963874457,\n        340925488865420050,\n        14028143098693299269,\n        3675481773099673886,\n        15132383794361616982,\n        12233631174234968448,\n        12037785574496977166,\n        10737440493925210255,\n        17968097042350264930,\n        17680205263988402231,\n        10859227415540706659,\n        1792989334549221826,\n        2177480830391393668,\n        10338369798118713206,\n        11542959090623521328,\n        15037173432548249812,\n        4664260954029694873,\n        9780024773679095230,\n        15423051572962932558,\n        9219085292170154212,\n        3117519792300278178,\n        15201618561147315107,\n        4493458887555315362,\n        7071488025555767928,\n        14797673892858036574,\n        15761839968701169338,\n        944266743877977151,\n        7946878991241141272,\n        11588285294320616520,\n        3085763786364505728,\n        382160258300824544,\n        5755505265595418236,\n        15139252786842523155,\n        3984606858609787503,\n        7067124810169118107,\n        11087518322251373936,\n        2145074716108216620,\n        13925513670821357445,\n        11473752360428444547,\n        3033405528387034503,\n        7582032677934023131,\n        6892449022193017132,\n        13657958745036075118,\n        6128417560891330511,\n        12848284770679740346,\n        13130020275156534634,\n        15464211076162624262,\n        5054410800851766065,\n        5483902692780184480,\n        4738318744782334997,\n        16867167009329238452,\n        2678560575986600940,\n        2615258434432884977,\n        7292976780151019583,\n        7128935031167862533,\n        18221899987307473439,\n        11248303633169678295,\n        12738639111676263555,\n        3155353877742869694,\n        16071495863264781073,\n        4264698448823081203,\n        7418994727203896067,\n        14811917097660163843,\n        7385790368475083290,\n        664373701990601810,\n        13483754102463667701,\n        7612123824094233525,\n        512453134520186948,\n        11691341684613561710,\n        13867096232148780503,\n        7687434174716142000,\n        6803483980923514751,\n        13342782916572404854,\n        8439201436522607326,\n        9757760943763629593,\n        5981970754483057908,\n        4190757094163155311,\n        5660547043969581137,\n        14325603855966161415,\n        8929633236673768270,\n        9297312576387550830,\n        1693558263949957284,\n        6836793952945831062,\n        10347383165146273428,\n        14661681337332505439,\n        17963531302478114205,\n        1709137293854005147,\n        3006720702657955228,\n        7329219772915910677,\n        17104100208631258612,\n        1949699737886797762,\n        17000436044616227003,\n        11324808183485510201,\n        13235495906244342819,\n        15749585439652205935,\n        13303759086698322754,\n        14891288338853864137,\n        2704605299240507925,\n        18013575082547999538,\n        2430267745104734440,\n        6179542971962498102,\n        16185308076341237746,\n        16642985193904420358,\n        2654686382891502775,\n        14166125840594907890,\n        13875221482589820174,\n        4356811139286595070,\n        7880657059321548510,\n        9955951238878446164,\n        17891804138739212705,\n        11829321244704294673,\n        11236151306675978093,\n        4831011344740993127,\n        15572388809599316560,\n        17846543352626240390,\n        7199845863441340373,\n        11121886749027339043,\n        4373695674384726918,\n        17093036459186744076,\n        12232005422016339414,\n        17131567018724437993,\n        16256199016182051711,\n        13475963188288260257,\n        911027923034979647,\n        6400295517498242996,\n        8837389249699670037,\n        2811700517251274120,\n        513035437159887251,\n        15619284911695136524,\n        399375572943822801,\n        7075743944967114918,\n        15672634271222934582,\n        7207711819265953469,\n        13693046740725554616,\n        4027434095315202255,\n        3539401330347027933,\n        14804329511729011870,\n        349324242806502305,\n        9296277440807870703,\n        7176700326904811702,\n        240113067969972951,\n        8383831921575151446,\n        1722116363229832243,\n        11612954111300504655,\n        2215733152712733871,\n        13493183699196154480,\n        16071186765983825953,\n        4130784068501749192,\n        7338573984508524547,\n        10825001941195956075,\n        14997934222654203001,\n        6505703712429055284,\n        7221915757982082460,\n        1275601006259924603,\n        5672514881351973473,\n        14882830470570010681,\n        10941637348461954999,\n        9488919083136123898,\n        14043552860848000866,\n        16822079753245337019,\n        4714248213100277643,\n        969715273010037797,\n        15521864292227188985,\n        16073105970793932270,\n        15708820798300121289,\n        13898215817316628619,\n        12776496008354836588,\n        14999798045466993632,\n        3260898735577297939,\n        13139436153787118831,\n        13332280475731022238,\n        17383012290790364040,\n        2995641007327542345,\n        14136727525433141277,\n        17334568127137876546,\n        16958828191205021632,\n        12417369554667951160,\n        3090518852098624195,\n        13657230135070531823,\n        11743085280276876203,\n        3114616886140581544,\n        6043287503993377429,\n        17550757261658589945,\n        17149590190690566703,\n        9103040591046283294,\n        7946146551153766574,\n        6328750617512334061,\n        7611645677682650836,\n        15633620719663274568,\n        9212436143674176261,\n        15788907043061834348,\n        9498761316246368036,\n        7352496413262997914,\n        9095543535942948357,\n        13109519298804112825,\n        17605710606152813899,\n        11836475532966293267,\n        15936748974921397105,\n        1111801049346591026,\n        15762144272111321164,\n        13004674117006965866,\n        11908453630639663926,\n        8672383672749866782,\n        2088248899380502026,\n        7296610571351867175,\n        13755695345060796205,\n        2999982423435890541,\n        4129519642079256449,\n        12622156276462967022,\n        7111496398765881581,\n        14480787311565160150,\n        3469939266209117746,\n        7438701329152033623,\n        11629269482462741856,\n        4885777542024810464,\n        10705129561986474549,\n        12704646697057875,\n        6458480273092609348,\n        6552269679491575287,\n        16764409845541378365,\n        5112781772516022587,\n        8008989787537536761,\n        1103584530948037829,\n        16382841334779146359,\n        10554805089071823936,\n        5435260964051060833,\n        9791508728754514420,\n        490382068908134805,\n        17435419070710567937,\n        14195398757764953304,\n        2963888499740999291,\n        4662041165840469949,\n        6744621662455431846,\n        13427204268640870135,\n        3887747288146601313,\n        15443876414310792510,\n        14209765039523837918,\n        15685162874875886369,\n        17718873723062454563,\n        3899085415479325935,\n        8112448753673506965,\n        9870640447409364221,\n        11832870733499002257,\n        12563697741369320162,\n        7101757806260064829,\n        8836333095435223130,\n        2301074177341928226,\n        8276824997793946999,\n        2827834280767843126,\n        11204234843351418659,\n        14057032714422307544,\n        16637779355549534512,\n        17293043019105638911,\n        5235444579393367735,\n        7875158171121328348,\n        12032932633735348172,\n        17577724652120330660,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n        10,\n    ];\n    test(out, 480, xs, ys, scratch, out_after);\n\n    let out = vec![10; 905];\n    let xs = vec![\n        12477471680342457016,\n        7439834363175998259,\n        8364531072478531307,\n        7720669117264982572,\n        13871089126608066865,\n        5538739089658515009,\n        13485862549968349516,\n        16668965138415286574,\n        12815918125584966674,\n        14984155091932260860,\n        16644766636646585123,\n        306590725006293979,\n        8429368518159297616,\n        9218529725576681069,\n        15016741949480768499,\n        1670879514738013725,\n        8417955162372577946,\n        15387720484925756369,\n        5110476884223883348,\n        1816362467650579730,\n        6344760880304946457,\n        4582050077501139760,\n        11544561500401244826,\n        17507375286136941082,\n        6780825611959218867,\n        2173592718397418409,\n        14895320899302250577,\n        1732130437372403944,\n        2652228013798656770,\n        14059887082577558829,\n        17320142963333434007,\n        14639018477416372959,\n        4436670787324500429,\n        5494397060264160564,\n        14648982379079464056,\n        4281784633461453767,\n        6798187094949642558,\n        6608877920405717218,\n        12631712797504769978,\n        8551308273612802041,\n        17246776198396440310,\n        6444397599333607623,\n        15925650298696285563,\n        10601768410796015631,\n        15000906276520941112,\n        3338797399168993953,\n        1246352375954040582,\n        11420394385271506024,\n        17068095307090480528,\n        7644631914604520606,\n        11033781661348318008,\n        11117169690184835735,\n        258761790873428567,\n        17489901188933003933,\n        14840505235785535230,\n        13227413113638715481,\n        16997698053799118525,\n        9019797589817151925,\n        4493694255366969932,\n        9725237995968980495,\n        15577413875064628551,\n        2280312394933338862,\n        225569847977698671,\n        2323301829890963353,\n        10256874123357921822,\n        12539122566148296448,\n        9989537237723725906,\n        6811992642529374338,\n        88727847633051669,\n        15695593575052197094,\n        2761202085861005143,\n        16533039048484256106,\n        9351088285086271793,\n        4055478109313752276,\n        10213434408975318081,\n        8762684020269433141,\n        5837079994402234584,\n        16514518402377369291,\n        12378208937452956180,\n        14421807887515276362,\n        3988627559762405319,\n        3918544582422029230,\n        4755956678288947720,\n        9676877814462397554,\n        224961575368542488,\n        14611489560386313010,\n        5196486534973110781,\n        14213777193365038984,\n        4602978866967803674,\n        11003619085742827120,\n        16763677630294953394,\n        1684559030448096764,\n        17767374982649848838,\n        4877949630873126245,\n        3682814944580280752,\n        2561235719818456295,\n        2364934896956055350,\n        18263613281445563076,\n        4089114060737928308,\n        1871768083735193579,\n        16678770828678552573,\n        4414846026098045432,\n        17125831209897882395,\n        3912127090800830255,\n        14011181803889192282,\n        1295043426575781791,\n        10420967703804408197,\n        6199906131836288010,\n        11807153033347357192,\n        14265899593105313257,\n        8147605267573587369,\n        3295330776500509264,\n        16732577613226211515,\n        3630606949899242603,\n        4077531443619740772,\n        11812426165247810337,\n        780989759563676061,\n        16843715221613475518,\n        520503200629457264,\n        15698734581373560858,\n        15717047446773117386,\n        11739182472950746776,\n        5508507755766772851,\n        11277744890514126849,\n        7102937323315103744,\n        15043426316219001362,\n        17264933403548961444,\n        4786858792980655802,\n        2014728966166520846,\n        13049152613696846196,\n        8986797982833879405,\n        5686978963676857351,\n        772150166774986658,\n        14517086870053753709,\n        14954116996489490375,\n        7746391697910526188,\n        4606434146793009376,\n        3009553593220536962,\n        11834331104428006940,\n        9959812709547803325,\n        9312818550721389795,\n        8167722699792448458,\n        732874657192970052,\n        698773781905867242,\n        12119405880051172902,\n        17673033350796167980,\n        13538870733321508367,\n        2664725175527539380,\n        7636536994105874784,\n        8629987496621113680,\n        2000550558774774739,\n        13628751714628702436,\n        3345724186836801042,\n        5296651644730514746,\n        15440075910536479523,\n        11566524344598274755,\n        12142530999548267726,\n        3178476168461706193,\n        11231993373182544616,\n        5535836762655782188,\n        1821857691788680579,\n        15398067123112832375,\n        2959937906512595934,\n        9894128090659796945,\n        10977676213479413606,\n        9896053141077387340,\n        4732359585478105829,\n        2782537058538126590,\n        16748650113511090469,\n        16234573623069140583,\n        13526364553240274764,\n        3472042735026885459,\n        1375504011635585658,\n        14134901088610758184,\n        5812986093773998116,\n        18343907802066284210,\n        10338195362284836496,\n        4538933452393836273,\n        7202972851508573831,\n        10663048845744919725,\n        11111095559628771539,\n        15813947556665176307,\n        3844063447234634925,\n        5652338735091822320,\n        15812061039848958137,\n        8229753298839583649,\n        802923134917039889,\n        4829163585440544772,\n        15429176731296846429,\n        8019558793413477543,\n        1452525545607666514,\n        15573790577533593753,\n        491936016981197942,\n        10062863560179613545,\n        11061384784011621889,\n        1900052214617990619,\n        7753731008479284745,\n        16019010346473083888,\n        10253841258470892164,\n        13903408453788781151,\n        10169884958783022914,\n        1771119784479465694,\n        16876761255984683913,\n        4507734336556855851,\n        1644190668914968903,\n        11524855357000701681,\n        6768296219427733234,\n        10057582861726337550,\n        9899648217778374596,\n        18140808584162437045,\n        3502136377186507090,\n        4607134693582048621,\n        13936949880580583914,\n        2596788772608678076,\n        1796713826239012327,\n        4260582063129126187,\n        5748801488885906379,\n        16694615442676144004,\n        3887305188180051618,\n        2550350767205712363,\n        18068173339311621649,\n        12758173303022710234,\n        9740862123276893551,\n        5102010307820377604,\n        10942936333209708005,\n        18421941488948996650,\n        11388637231777062032,\n        9127668535392226249,\n        6469837987038520357,\n        14193922743168722337,\n        8879463076013852218,\n        1299536255974471810,\n        11657123384643255381,\n        7261659951101262301,\n        5894363505946510117,\n        4245862285394351605,\n        5678371230350087802,\n        17178046578086915046,\n        5767351492432132301,\n        2765778331274782081,\n        5032104048099942935,\n        17629257268172754881,\n        3538476034090404567,\n        9059696921132002704,\n        10148267678588608063,\n        7431557905485244392,\n        17701219837659593435,\n        11179519028472592747,\n        4072852058212419917,\n        6998722206646617171,\n        4881588377784087158,\n        8942392135657118187,\n        12450098984983403167,\n        4877380715364130438,\n        7442425351254657978,\n        16893368119062256892,\n        4133190116578139434,\n        14033231224823505685,\n        17690698791038106309,\n        69885719555671168,\n        5451291976155541960,\n        7641909931651695485,\n        14034042004808926588,\n        12720147227862124510,\n        12957030947591398482,\n        12124026692922785247,\n        4883408107294185147,\n        3308537627824539756,\n        4406371143811003270,\n        17321810257306281660,\n        5243104860854009275,\n        16431126877381187748,\n        9754896554997520777,\n        6749101884247660127,\n        6263295512058358448,\n        8583119091158463486,\n        5555416137611535608,\n        9162144452187531823,\n        15840624178481981270,\n        6187472780701357377,\n        3164204801472770089,\n        9460961259991884760,\n        12198117330023239045,\n        9445542084090344416,\n        6826521970103491663,\n        6996442717256261847,\n        7363775912789871847,\n        1821616883363314737,\n        13718695280220668528,\n        9265991471759860428,\n        15403328465978445840,\n        10435756695146507564,\n        9134138337791325500,\n        17595820721307989341,\n        10837897611871188641,\n        3628300610284347069,\n        6056782082517998847,\n        11889121953261384595,\n        15658848261681587671,\n        760281128415892566,\n        9901843341271410215,\n        17997287540098693599,\n        11471174400256577350,\n        13773435664609284401,\n        224645455536727129,\n        3248370257584471677,\n        3402146064818516495,\n        15419892046652096835,\n        6817408051904455983,\n        13462567452174648864,\n        3865219578658340818,\n        6401692728490725482,\n        12241061753482985847,\n        18093898726091231688,\n        2085695270753393724,\n        1486152210073874278,\n        10962392580868374592,\n        18233050379629714175,\n        15440497426454102854,\n        17029248778709090701,\n        11943840019902256468,\n        1838494147415724342,\n        10624384750477063994,\n        2802400104447544796,\n        14482700272009891532,\n        7488752288284248623,\n        16689053330367821624,\n        8122258539396763672,\n        9378594940099937779,\n        1953829770254669263,\n        9095248272317331200,\n        8866691394084862202,\n        13201017990930506125,\n        5874101266603325988,\n        12758355031414108476,\n        10906401543018450367,\n        7070115242582431545,\n        8015463853343573521,\n        6337419761897564053,\n        8245569799737529081,\n        2143044650526073628,\n        10001469296387640338,\n        11129612211343148678,\n        9846592166231801208,\n        3293328206977069772,\n        8271586651454757561,\n        2516303987084978983,\n        18226852422794010543,\n        15105013013529789613,\n        18154225228636318154,\n        2013990863661732083,\n        1784747160358384741,\n        12567581004427688912,\n        12324983884662973603,\n        4935897487517618842,\n        14994876132441559883,\n        3460392282827044973,\n        178151701108469307,\n        14330685158880278679,\n        17005759398710652579,\n        12918079073431941444,\n        14737890013936547836,\n        13116140709796209375,\n        4406659418908136238,\n        12427086661031458855,\n        7492548499951595477,\n        16111633531233494957,\n        6547469955282364389,\n        10562100669850668222,\n        15418878616411295006,\n        4956757255402949102,\n        8013302230254643702,\n        528640010877453099,\n        14207088120532813066,\n        16751882716911936366,\n        7949419147113034512,\n        1638837693666608472,\n        13878268226712426549,\n        8273407385523164786,\n        11509174550235804944,\n        15966833959669295468,\n        16501367189938100697,\n        18237618137386130737,\n        12449896376279048977,\n        18110666911456042806,\n        3193062725115205782,\n        6188346541223558421,\n        8058450572610971381,\n        6102995183728564982,\n        1217219394955358461,\n        4696899915064498873,\n        3897448246350199671,\n        12662172956137287871,\n        6610124623177066401,\n        17355303367288349560,\n        2046855789488294262,\n        3211014904560014361,\n        17115241076245460723,\n        15298358927000333664,\n        9182539314691893135,\n        5164209594070862585,\n        9062044958688820752,\n        11123512834458221854,\n        2659061244791686400,\n        6806035717656270289,\n        1027290028815967628,\n        9405947735639936936,\n        2540349601344589130,\n        6895259978837037548,\n        8904474026325226434,\n        12273615493885622366,\n        8677764880724506780,\n        6002959367751808149,\n        13123965742105252412,\n        11735284964695785299,\n        2417001610052848193,\n        16769279424767143997,\n        7098399088498274096,\n        9910748236374366737,\n        11111297830299095939,\n        13640041663283902885,\n        15915174780574330612,\n        10929481089808875146,\n        4581632826936763294,\n        8581099749824253588,\n        12645736569302882821,\n        7359153121066395683,\n        114042912187761457,\n        8021867264848320576,\n        15492861144941287563,\n        17574065125533105845,\n        16374369432221228355,\n        10459169993431587286,\n        16366034776295832243,\n        2627084718398353897,\n        18099240392705942111,\n        4326916362018195403,\n        6552915731272193737,\n        4273219172539573763,\n        12682979794809012349,\n        2630341686377453497,\n        2883112777041844122,\n        17280553753834600520,\n        16523493292363775458,\n        4645653082909935710,\n        10857150457399097857,\n        16240900012104288727,\n        13936061320958754124,\n        7489056125188749067,\n        3240618672663587347,\n        4473897013556224538,\n        15959787311013455542,\n        6807910945586226902,\n        9410336371061067189,\n        6906088553149840730,\n        5605158148442495482,\n        884531864210940213,\n        1872297304786275835,\n        313522309067627421,\n        17334018801756959340,\n        1675436862731542012,\n        8842978529412038193,\n        16491099153488944340,\n        3255602365380029669,\n        4091823593236384660,\n        9059086866751700824,\n        18074592049968473162,\n        8939611511088706324,\n        2901954556715326677,\n        3168063820638083277,\n        9642457237234984168,\n        12973730047202029231,\n        12383420012085361069,\n        11980461635855055601,\n        815939574328079776,\n        14011981531029282088,\n        3819777392902083260,\n        3664266433302366398,\n        3842827072078938508,\n        11680613555445372946,\n        12778807841055009071,\n        12110239716506060424,\n        10455001326219377212,\n        14037063373827903372,\n        7343791660755545799,\n        12328389593346708858,\n        7199828106464912509,\n        4858835493732869191,\n        4210694898816644452,\n        5207062729711049186,\n        6686010191777285325,\n        4765116176650914771,\n        4260203503346398077,\n        1759950825465072730,\n        5230132100642234984,\n        14615940487884510813,\n        17309789486063144027,\n        7278701880222450078,\n        10589604955548805402,\n        13389545410598327517,\n        8048423454310044609,\n        10174798177374038317,\n        11695819581512336602,\n        10798166591000354836,\n        10103293254150868119,\n        157182158726905133,\n        1338674327495139085,\n        4359740350600884386,\n        3252895658818469796,\n        10919494111178843097,\n        4907614062557818120,\n        4955680854509122805,\n        11945192504152771627,\n        7975797138321745283,\n        6605506887556783622,\n        6135553468556837256,\n        12830560358150860589,\n        3963138074064936645,\n        17071621175761233015,\n        16942996036353652149,\n        18009074714271793604,\n        1722999483884168113,\n        12926214689279125494,\n        13895491362136161766,\n        2282857362875456337,\n        9142994644696487964,\n        9268762722221367534,\n        10573580827711251601,\n        4334519573500535534,\n        10883875644989605426,\n        7004415645651661648,\n        10027237496943886389,\n        13381566800231151857,\n        17337229971572030119,\n        9544236017718236057,\n        16499558730912147790,\n        16696764467460841050,\n        12783153673325726862,\n        4801788834514363554,\n        9769596680827455135,\n        2052933989795058774,\n        14012190388893162910,\n        2328488528431981564,\n        6422943144920158158,\n        3344277493662982427,\n        17332086124044133390,\n        6603250179050887938,\n        2729973167059384364,\n        10215535361886902702,\n        12469382708903994601,\n        1202997051177792035,\n        3047394247674395800,\n        2411456312940888474,\n        4837088057329031859,\n        13226164937828712217,\n        13151155632897757600,\n        11689971584362603020,\n        14721057194516503031,\n        3506623688955464241,\n        1023806484371714024,\n        616780495049061260,\n        5550447694830386961,\n        11303599457452379703,\n        4026477090451957914,\n        12426562795004232982,\n        15911784896145106699,\n        4007234390509453717,\n        10984488057956831607,\n        10127069533632441573,\n        17026212809323057241,\n        9318803717581063712,\n        14225402896737171843,\n        15831782058852344212,\n        14685942491342656916,\n        11353950141420870530,\n        6899840258039698024,\n        16365793951924111762,\n        11054065770384370104,\n        12313481690905923958,\n        11429182630674761557,\n        18037807349797853208,\n        17855698087768272616,\n        9322152574069274970,\n        4942329044664759235,\n        7995065847246945033,\n        17234608471288129109,\n        8540482286126463,\n        14042109278380290397,\n        4245459658137149297,\n        8630372384706772616,\n        16951967420255591896,\n        6140983990759814658,\n        15799001042328537181,\n        293899216979442252,\n        18375466344090472198,\n        5023361203279264131,\n        2158584219052773880,\n        2430714777079983012,\n        18439679719922027552,\n        8247095638003041692,\n        8700129222990386425,\n        9065370516758531054,\n        7621645239059490705,\n        8198370193753546038,\n        2570516211974541846,\n        17033362784799911757,\n        16322248788609588904,\n        9688378877889012051,\n        17078622631971263745,\n        14000745586739559896,\n        10022578092954937154,\n        5445108204439341684,\n        18386610455808271244,\n        5092210157433941468,\n        6213448264919356969,\n        4883013329288095834,\n        5478996930332110750,\n        8026855029996672366,\n        16024447858887376249,\n        12067879178821404087,\n        11518543008940438069,\n        3823610091713721972,\n        18069601801912264214,\n        11258822797166212826,\n        13964841203412084177,\n        9414776283754541624,\n        10293058710824631389,\n        11948877430367495415,\n        8513392542107963113,\n        6296507345123212825,\n        6477999943576666411,\n        9572404293136150991,\n        5100835030655003210,\n        13325655857556084165,\n        16324080076960251181,\n        8879608339499901790,\n        18301788022265813222,\n        4530918631858474410,\n        7355857660645482071,\n        3649239901919106124,\n        12889973024998083984,\n        11695005857389286582,\n        3475833048468156819,\n        995729836358583730,\n        12325666763829458288,\n        14110440261397920019,\n        13769832493884639171,\n        15593753283105934190,\n        7109324739675458351,\n        5421147768472920505,\n        4412734743279888925,\n        11138246548885387220,\n        14351840348441253310,\n        3556324819053975644,\n        464172005362873872,\n        6330105154140333710,\n        199716684476189301,\n        30491931320003660,\n        12784214407370490288,\n        15867394285597021458,\n        15049472685881722845,\n        10832317644389672128,\n        14180787391549176759,\n        6195021812685555238,\n        7097651423104249027,\n        14212466040470804288,\n        933065029493216032,\n        340700391640325051,\n        5222909044979876332,\n        12662368682228247352,\n        2784558090880586519,\n        11524226622572698014,\n        7185977984788112517,\n        10872431215518209444,\n        13748253290972801025,\n        5038089701011291997,\n        7535346948699029838,\n        13797006813111000874,\n        4892711692291451444,\n        6793466025450692149,\n        12784267157149526257,\n        10296537403905285004,\n        2323577800704132951,\n        5312137140467217143,\n        6430484854861543636,\n        6338831277270911406,\n        3380263422470065531,\n        2021125064519606784,\n        6156495890069554972,\n        11783498133679281022,\n        15578447545577779722,\n        15814546899991104192,\n        13941553944244468050,\n        13634474865486767598,\n        1056230272770991969,\n        6544470833237086052,\n        13788795813455716701,\n        7695789694537545607,\n        8392131987884965107,\n        4446829805611351645,\n        5546547554488839716,\n        12941176365951974041,\n        11083456017770653320,\n        14243587238307940226,\n        4340314402890900681,\n        11706773788443852730,\n        4344412554812442687,\n        11193626359760223528,\n        4305913696407512521,\n        152872300974481317,\n        17563972177873767735,\n        6689134738611919649,\n        3781413393308080648,\n        8321615330761631580,\n        14197467496901526225,\n        14546626676044239226,\n        16456266795492152384,\n        11928059952577597101,\n        3835042046532738036,\n        13754911224713375253,\n        7514650130698543676,\n        8858336584435716580,\n        14887091898219032624,\n        16911851326374546737,\n        15781280213878900978,\n        13174567334832245983,\n        12698715736553212443,\n        482862054634250522,\n        11881655003769883900,\n        13759377508601776198,\n        1380626582194380651,\n        12709962724490385600,\n        11830407677567487487,\n        4707511235470141279,\n        8988833435496096196,\n        12849153210950239984,\n        6129552893611029481,\n        10992680122519594516,\n        11411390234302369473,\n        12356274253287847627,\n        8358264938578134057,\n        2779498090106587161,\n        18154716656404340371,\n        6939980780951404838,\n        11644899556767279317,\n        6503403399166403612,\n        1788328284304710501,\n        3402885645044344883,\n        6160850982285943593,\n        1361188868372704452,\n        5295494278668069110,\n        3856033404817891402,\n        5165875819581549636,\n        5432481755911013545,\n        6887089866491061103,\n        12248786783098658185,\n        1872380111306967890,\n        10371211044437237288,\n        3640308804221372831,\n        11707751977394310973,\n        2441379059837646171,\n        17261873795536786450,\n        4576230298744928057,\n        13439891433013201618,\n        13066055068615706211,\n        5023766490253071135,\n        4737378710842155527,\n        14130528255898995994,\n        9297196539004306162,\n        10213190959948266193,\n        10762620391958680674,\n        15631352907504559989,\n    ];\n    let ys = vec![\n        15245088662193948010,\n        854969528224537163,\n        192457876290468361,\n        3156774054099849881,\n        10102117358735393641,\n        13923135497401538045,\n        15603007686998930972,\n        3707765480829539463,\n        1075990372015045994,\n        4440028045035707188,\n        779932550205535682,\n        13284596850012603887,\n        13447370325749987403,\n        10657005451799608034,\n        17344058779081327933,\n        1801131630646010099,\n        17879455113972297046,\n        1049662270419803525,\n        17887003202529550415,\n        13730724178286439296,\n        3086493866184691051,\n        7455503161286080904,\n        14945249663072669446,\n        7413071270018261565,\n        8165098975144402988,\n        15667870805615006559,\n        4534237642686726425,\n        5675059133984408369,\n        13542693529471369730,\n        4650690134857994243,\n        10593876026982724440,\n        8719234160809710444,\n        7340192483727047710,\n        2225660849988538666,\n        3260628781823840386,\n        14784063213821786553,\n        13478324037708856111,\n        6239844587086244103,\n        14508626048519473050,\n        11443816492520902359,\n        7084448144752764341,\n        11673478635762496725,\n        13444020463604694513,\n        1798574113181758005,\n        15195278749704748030,\n        3490272214933312037,\n        15632500462832370824,\n        9808665338648603851,\n        6377980234800091876,\n        11306384233660763805,\n        6392788317448223882,\n        8005181869701567455,\n        4601526777105113530,\n        9348184476999479133,\n        16105441815997897842,\n        15373735633778437011,\n        11733794529384137433,\n        769246272107807645,\n        2922899274256775805,\n        16218486247871807873,\n        10650657974127272786,\n        579665301817927565,\n        6403006378940431337,\n        10150254532952843560,\n        3736822004545760197,\n        10244207440138560761,\n        16631379436671010056,\n        17418302422321190629,\n        4844439457855539440,\n        9662799133272397874,\n        11622100630061039998,\n        11017257064923257696,\n        14025546287952884200,\n        1170766120552674008,\n        4852413824670160293,\n        18019298735978800767,\n        14042374992041286164,\n        6103187929964524269,\n        5988592592688695870,\n        5579172720281387479,\n        10738878044274955012,\n        8401646271610146442,\n        12016061916593958227,\n        14752402557741497038,\n        5053283107906893264,\n        12910662726197463795,\n        787526459034857809,\n        10304827788120361107,\n        8387521101013404665,\n        6030209567663971422,\n        7511028869236306454,\n        11105170944119024313,\n        2911699195421772292,\n        11710398806568443147,\n        7599646386487625804,\n        2146501359265516686,\n        1193294087739295886,\n        16419769173966961854,\n        14779980297792837632,\n        6286361066120350249,\n        8246126699673376536,\n        2339493649448723726,\n        12383521129608538925,\n        17459816050942292574,\n        7213741082075285427,\n        14702683527305456088,\n        17849030573001874153,\n        3273901152373442943,\n        10086273715179643444,\n        14351251935054659627,\n        3067622597087477151,\n        4241957707372911307,\n        16686513037697490920,\n        1503886102490162470,\n        4222986769290077389,\n        17209928444872897872,\n        10064374817012298812,\n        1391022681726221923,\n        3482099619102309134,\n        151151415131464647,\n        5477310851692317777,\n        8185741896741403527,\n        12297179519749775078,\n        6980896315258250234,\n        5491311995173541969,\n        10908311176531272611,\n        15140263006374103771,\n        16292302828281485620,\n        13488663273854028028,\n        17078235461511918753,\n        523009743565281503,\n        11105648925812514991,\n        13827146014280242829,\n    ];\n    let scratch = vec![0; 1444];\n    let out_after = vec![\n        7119213209737455664,\n        8035111372284977647,\n        4572010150225077091,\n        9836693742249819546,\n        11913987255489332987,\n        9795418934522178134,\n        12039823881052227957,\n        1703597587030553464,\n        17173440207558913559,\n        9133942906034722304,\n        9892190423857277000,\n        11450449925285493571,\n        8229203118528410575,\n        18272483595874326782,\n        12286453845032957559,\n        17397683281593428252,\n        17307726796177375265,\n        5885130845879194191,\n        1645176018776340060,\n        7680193366109147043,\n        16734119958955208667,\n        6536578624341273644,\n        5770440598266592917,\n        843542653879105004,\n        7846103239972868550,\n        17767498093293336141,\n        8852927397266500772,\n        2375241440134626999,\n        4434060166952587700,\n        2761540810749122567,\n        1453459469045559424,\n        12942116308370467698,\n        5506016901067697399,\n        11535214645442000706,\n        15126978367780356744,\n        12154399742028506377,\n        496043512841547027,\n        17912935272640820199,\n        10986022757903652151,\n        6556183826080645558,\n        14546786726747802513,\n        12005748109900862598,\n        7028659269647722317,\n        7445941872312834859,\n        17378556553372415985,\n        6579722616703715705,\n        15110932971155985188,\n        13357716021096701878,\n        14805225292079398749,\n        4846395190680470669,\n        5496704586153785876,\n        13902332896674228944,\n        2782564501691101676,\n        12874276640173358887,\n        16083587358039033190,\n        18355037119147466217,\n        17905645348986250355,\n        17336266670070672432,\n        7329875537940689357,\n        15143929848768191816,\n        2335192162346001268,\n        3675321604843848800,\n        18055470666128734882,\n        7825904415481215047,\n        5109358240684702569,\n        14285416470839730663,\n        5712671120250540046,\n        1447875149083639731,\n        16825523458715974110,\n        435887853762049989,\n        6289440856649262026,\n        5079567923272969509,\n        11992232716208537238,\n        13597285185096130255,\n        11829047305733652617,\n        4311086504067261381,\n        15175721011032302019,\n        5062112127396725677,\n        5556662484107594780,\n        16961425301235550719,\n        7249744124354557124,\n        10415169108908960370,\n        10792331692568535985,\n        14481109731941072963,\n        3493798658848957833,\n        3820132639380218489,\n        16270989634898866497,\n        12612959379075825823,\n        2261231936675595340,\n        5397727033090527090,\n        1595530071661307000,\n        8721991197262817968,\n        2097281716258616855,\n        9720159116732069000,\n        13847028604290243745,\n        1259097204603535157,\n        4488418560755904013,\n        6367333815591827979,\n        1110836537797269745,\n        737322139420954828,\n        10719862516375734296,\n        17641235722877078710,\n        4007603116973007245,\n        8186031591789355966,\n        824809602592127358,\n        15459023162084506830,\n        2781779707947579519,\n        5340603447447048495,\n        10487772282235399213,\n        139590844844775293,\n        8448523529988919651,\n        11294430762236913551,\n        7417787798712521690,\n        7898687579828307114,\n        460432324038279684,\n        17287858692967790320,\n        1003171402208274758,\n        12432863151610498290,\n        1772583694811023620,\n        2398714257155470903,\n        14638551745572956179,\n        2453888832037177615,\n        17965720127679021564,\n        3482752704874523706,\n        9460983625185291928,\n        7861173646556463420,\n        2092158584793655622,\n        7860343108590151278,\n        5798668224892394938,\n        14344358780928405264,\n        8930780312248882738,\n        2041974908151755313,\n        5267057435060043630,\n        16349241761951706605,\n        7937085583298782596,\n        1533874153792017121,\n        8977390985744119243,\n        8213952522673826258,\n        5985476232972805345,\n        1767819075525805690,\n        7890652703767299436,\n        7833570395707421953,\n        16483497150383186636,\n        3111844668913506626,\n        10592215978440849992,\n        15760470899502034545,\n        14841199295755801240,\n        13457358926996905771,\n        8495921566729048945,\n        12384251008552336501,\n        14611927430049516374,\n        10145411926842313555,\n        13313983588964854484,\n        6522555254793521962,\n        14886168792472123947,\n        16563223991574184817,\n        11970636068147089860,\n        487573490069849866,\n        14517767327925834099,\n        358889874180177533,\n        2722904686908914583,\n        9331922038722423702,\n        10427207646299323058,\n        4058944134252549339,\n        2943158119917296684,\n        10957133362022867886,\n        11807644687289257630,\n        14152770343532942991,\n        644765569764633457,\n        12835933538365183555,\n        3489836693155058202,\n        7930565595074376717,\n        10663397566559525483,\n        10415977712042153468,\n        10629891694308728614,\n        17218729211483121702,\n        12882631064819497692,\n        11823247409777216976,\n        4429760090149085341,\n        4992836119218612253,\n        16968182235411645979,\n        2833341723517409131,\n        9437468414857756700,\n        9342501551191707874,\n        5401538590112566847,\n        11565576817184943683,\n        17418902749314320121,\n        15515057935262510,\n        13023198767155479105,\n        12322345548326767749,\n        9805678358507392118,\n        15196802879249030007,\n        8590456626380559194,\n        12181129450616746226,\n        4662360147888268775,\n        7743459026687301615,\n        12227881705402238521,\n        4104871394210118957,\n        2982631795273577607,\n        17405629239503027027,\n        8575042458975896270,\n        5499669298608315445,\n        455410535869802297,\n        7801072276748452974,\n        10258654969684304036,\n        5019332302330169406,\n        13851706526542678368,\n        14388718431838510370,\n        6994627771674318027,\n        5883188522176688608,\n        6953100454027368107,\n        16730449049154094699,\n        4479760571164126224,\n        2442817149002290432,\n        2594209501779693152,\n        17000985552959046155,\n        13392630901869088171,\n        4351699921480478565,\n        830530327244063521,\n        6175340290035796626,\n        11478838337470764581,\n        4282543001913023167,\n        9749956107550685821,\n        2694451472405341333,\n        14159005131955878971,\n        188623324081031138,\n        2113957709622881014,\n        13346278264743742220,\n        1490312624045928630,\n        7257319265988714790,\n        12897840546280054308,\n        10261220359148798170,\n        11623514965826520552,\n        804176158748924112,\n        17254294564975652336,\n        14961613837993764505,\n        17022609814041542140,\n        5050795566934959858,\n        3133859061844734723,\n        16471861622774443737,\n        12873904550161604219,\n        8955720228538638459,\n        6705947195280088455,\n        3312252979433304494,\n        13064308724359909641,\n        17877454778920390520,\n        13974626528815595051,\n        5830057811107410067,\n        1680557938316663873,\n        5360522541537691866,\n        16002353064982324832,\n        10193786265901148495,\n        5965825498900060524,\n        14004637605477595175,\n        13444980433515313059,\n        17123381832713041503,\n        395654489392928755,\n        17905210858022857309,\n        11695619457011399410,\n        2050293660264041357,\n        13214005508111947011,\n        13721733314071779620,\n        6957322551477640013,\n        17200941870372170988,\n        10377268746838169434,\n        17697877660887283146,\n        13909454659468606094,\n        12263365692987306251,\n        444868280971136448,\n        2249487486097442707,\n        10287367344673627295,\n        15227830943213591291,\n        11384605430871297252,\n        18114267789275369190,\n        9609419984349670064,\n        7173216608425317330,\n        3785723985326055000,\n        2525275194754047614,\n        13535151049834722889,\n        17273215075095328812,\n        9379065185520973134,\n        13156080046058576550,\n        13809311185533464020,\n        9698193583022285357,\n        11293045682332858022,\n        3789086099334034431,\n        17423609786192009535,\n        8700938259391751384,\n        6754612211313466065,\n        15592171130416925401,\n        16281409111498332713,\n        3330243176102830812,\n        12431102122589837326,\n        16006104650687086798,\n        5881832849234936462,\n        9558494019188617372,\n        5910373903796225502,\n        7012489078165397708,\n        1678461096818873552,\n        14039349728684147747,\n        16767452777528123993,\n        10223391806015696982,\n        15346818030164147356,\n        1162766693101697053,\n        18234451668077951680,\n        8347242572094928214,\n        6666731739952625453,\n        1062103725054959015,\n        2916817885872081012,\n        1252775340062153472,\n        16701352066718298728,\n        9660144340038428104,\n        14959287155729434404,\n        3349821657014683971,\n        14124329647242713467,\n        16768224457728633355,\n        15245206340382728113,\n        13349975818727705647,\n        7060168455288126345,\n        14358009543123557047,\n        1671493412977635062,\n        13147000836819401629,\n        18412981554162763098,\n        11420833773021925355,\n        4462121868113237202,\n        3673613052681393780,\n        7933932278185611848,\n        2994094088837084031,\n        617851389487072906,\n        936087254346174626,\n        6282395350939998602,\n        5564739907135838574,\n        357676340385459789,\n        4488114251655788009,\n        15267875158424192348,\n        2784291869179885450,\n        11312568718856999737,\n        8569642291350942890,\n        2238202569818012692,\n        11656862683686826121,\n        15262363620109289295,\n        16524990113573459437,\n        5562790604256723201,\n        3345369486980494832,\n        12006274934570630789,\n        9946114845665174629,\n        13671323181231836463,\n        3970220369626629149,\n        7776022796090455195,\n        9590755788237311534,\n        8142856981292265441,\n        321465156536801162,\n        5953069648150855351,\n        16986574134926902837,\n        9332812118546582409,\n        10453305700229109136,\n        6745273322860959577,\n        2992371413743712642,\n        16607737435713483528,\n        6982491039985356345,\n        10635374366254201081,\n        5489787617426825481,\n        16512907085669471327,\n        12008394332273820459,\n        13681713057282914887,\n        1825484281011599499,\n        10265338194463676800,\n        231895184071445598,\n        8684485436743230364,\n        18314390632816293564,\n        395173997200045924,\n        3458959778923434284,\n        14875618389446705178,\n        2026228713879608348,\n        8096896632351243884,\n        11898068926472226654,\n        11401424330286284371,\n        11388179279009736427,\n        8567780769863850951,\n        5420955600339252740,\n        9557718016358557523,\n        10293539895922743855,\n        10709104391440822839,\n        15398390488930753996,\n        11609873443226591907,\n        3799303761026674488,\n        14827504231551333743,\n        5857678196927724111,\n        8450122285857845619,\n        6120869104368170858,\n        13208767594813061501,\n        17440504615103435089,\n        1352314430040358495,\n        4594662627540876693,\n        16103658665190650049,\n        4604995467068533697,\n        1965756000963933588,\n        11590357129340578915,\n        10706020607921767648,\n        435959974903581847,\n        8114156514383604689,\n        150635546028022237,\n        2046711193518988780,\n        9302159929442525204,\n        4102862072533955538,\n        10755931112512381521,\n        13759570670120566522,\n        11886492672468308648,\n        18368564319937059130,\n        9170256735689590352,\n        89744806848865555,\n        17004092425291241458,\n        13341437623654656084,\n        9602103451691077650,\n        805686450066544356,\n        2830839197815761419,\n        1956329411504418821,\n        1856751313451126046,\n        8360952867730129523,\n        2655094640585883682,\n        1812351508323318765,\n        5466452692324458722,\n        2317993471554330319,\n        8386109932957812768,\n        191643434261986870,\n        8672383672749866782,\n        2088248899380502026,\n        7296610571351867175,\n        13755695345060796205,\n        2999982423435890541,\n        4129519642079256449,\n        12622156276462967022,\n        7111496398765881581,\n        14480787311565160150,\n        3469939266209117746,\n        7438701329152033623,\n        11629269482462741856,\n        4885777542024810464,\n        10705129561986474549,\n        12704646697057875,\n        6458480273092609348,\n        6552269679491575287,\n        16764409845541378365,\n        5112781772516022587,\n        8008989787537536761,\n        1103584530948037829,\n        16382841334779146359,\n        10554805089071823936,\n        5435260964051060833,\n        9791508728754514420,\n        490382068908134805,\n        17435419070710567937,\n        14195398757764953304,\n        2963888499740999291,\n        4662041165840469949,\n        6744621662455431846,\n        13427204268640870135,\n        3887747288146601313,\n        15443876414310792510,\n        14209765039523837918,\n        15685162874875886369,\n        17718873723062454563,\n        3899085415479325935,\n        8112448753673506965,\n        9870640447409364221,\n        11832870733499002257,\n        12563697741369320162,\n        7101757806260064829,\n        8836333095435223130,\n        2301074177341928226,\n        8276824997793946999,\n        2827834280767843126,\n        11204234843351418659,\n        14057032714422307544,\n        16637779355549534512,\n        17293043019105638911,\n        5235444579393367735,\n        7875158171121328348,\n        12032932633735348172,\n        17577724652120330660,\n        7795364456390606477,\n        4033162617687866088,\n        1544683855253756180,\n        12172662201233721356,\n        3756704469121795835,\n        15900453600187755478,\n        3111611615821110222,\n        12067333759598666114,\n        2460839148177982607,\n        7102750419395327210,\n        11545587889066437759,\n        13014356072259624231,\n        9055277810304247492,\n        14625948105355344074,\n        14619092238615835856,\n        4627724365506319628,\n        12192367475393288119,\n        4660777525583106578,\n        10602596814120768352,\n        15235390391666982533,\n        6262394583518039046,\n        11215546472975813276,\n        17221191340393185135,\n        2101601180397124797,\n        5801945926643183687,\n        13279838326750802748,\n        9760225764448182588,\n        10638379244001938587,\n        14689414070605049956,\n        9642847410658476483,\n        9252181208713310128,\n        10194326651074197381,\n        4194873578760608787,\n        15948390572816263861,\n        11413972117606094823,\n        5666682562527317380,\n        4558761157644127095,\n        16955166507135813953,\n        17165455630592879759,\n        6709237464973926762,\n        8519876379139259581,\n        16017543326401035900,\n        13443243112246019386,\n        15985758849225110622,\n        6635201996777679527,\n        810401065572784823,\n        3192312066161014982,\n        9614569995908311868,\n        6150822398486473654,\n        10813585281758350005,\n        8073858541355843438,\n        18109256134774887184,\n        3173606297852832180,\n        1697871109011675466,\n        18299820979700369122,\n        3429453844247078700,\n        5880410106220533795,\n        1902086387150156227,\n        1095558516266363748,\n        7401629960716178240,\n        10676693679576960757,\n        6803369895878427000,\n        679584762058495726,\n        8862820141296633751,\n        17191945777921342135,\n        8948907246409262383,\n        3201694424452878897,\n        13419812787573406307,\n        1123422467792803886,\n        16829507079638403272,\n        231077225656705538,\n        1743801854754216927,\n        2267894415989934871,\n        10485638453110401044,\n        14128191714015568951,\n        3134003464552465993,\n        16422231357711592145,\n        10265419470005494808,\n        608502939641364027,\n        9134620013637384764,\n        12129300312054467857,\n        18363959585640954741,\n        9300192354341214544,\n        10785267438521530991,\n        4936458668110384357,\n        17991939764954279170,\n        1611386959702759931,\n        13765557038981607892,\n        9945874597041578052,\n        4156215181237754094,\n        18063177967743727852,\n        15711037733871659565,\n        18074471117735370517,\n        4165544053496883142,\n        5279695231734291715,\n        1544829019313055335,\n        10641384862840576547,\n        17779765763310188495,\n        5626860848734533473,\n        10939014392735308139,\n        499526074720537175,\n        6841635225707590127,\n        8751796502513481516,\n        11336340410331983928,\n        8161799980755225229,\n        3303335824150755556,\n        187196914320055288,\n        4058076549799940817,\n        15401421223440460347,\n        10934724927412220331,\n        4611229640484146507,\n        4222099538065534859,\n        17723869573083320478,\n        4326485073257732271,\n        14233319419690524901,\n        10105594311301668570,\n        13674225839779959556,\n        9223247539431781352,\n        5207133412458563780,\n        2543064725421193686,\n        16112712767696009427,\n        14180139311525005755,\n        8623263245810438804,\n        9872551252324828981,\n        7186327511028170781,\n        15405568215949189408,\n        648741987472856599,\n        15504353064913393130,\n        9477833781488603469,\n        15265929637105201324,\n        14321785262909727449,\n        5989145253796307072,\n        4029928268282443946,\n        214922776543851469,\n        14661242500471677738,\n        17649450017688656343,\n        8833974540349191087,\n        13816848681848193227,\n        9357698275516764935,\n        4896085333994455104,\n        15704289681227768777,\n        16072211553259947696,\n        3696086675995567997,\n        2705327250235057879,\n        3940607606521307638,\n        1904439667923426432,\n        5211873495099253275,\n        12248061263800319556,\n        5068931489527810664,\n        3181822810361134627,\n        2893763819599633264,\n        17022013858675764406,\n        14432435821204701872,\n        5652574963789809237,\n        2389493332555305833,\n        7138156757153353567,\n        11060288640704436502,\n        16742145355448544339,\n        13832335420610765016,\n        13868994572073192755,\n        7515903319542781099,\n        6444421916061246995,\n        11587739604890358174,\n        6732571924439013884,\n        11724575869028146429,\n        12250459832157882902,\n        3016621587617492227,\n        9032739925629140208,\n        17557103950413855460,\n        13601852701212599067,\n        10511208766396769010,\n        1798260311095193927,\n        5693423254942127954,\n        12655656726468149287,\n        11019197760486093174,\n        12053338214040694646,\n        18408373830237784798,\n        6067223765497148246,\n        11553996073859513969,\n        4236552940838351761,\n        9458987771514077962,\n        11856103773548100132,\n        12956542515015205037,\n        4644161276287406073,\n        8685301764457396658,\n        1616507854541499544,\n        10201320335307975884,\n        4576763754089281023,\n        2461338218102810280,\n        91262760005101889,\n        11335499049722647439,\n        4878593686343800958,\n        12877266813141124945,\n        11027535651547021298,\n        5250333616946137743,\n        7088081721141062141,\n        14298861153503504925,\n        7147145447148416343,\n        17047545950712643349,\n        4493827337401588739,\n        12928986855103603232,\n        15542818123557007044,\n        13140774562703256605,\n        3866700096503647014,\n        11880459985577020267,\n        9892678920934094494,\n        7884199841722717749,\n        15763760571691417193,\n        10614999011319354481,\n        12234066605168430720,\n        13097736774835846982,\n        11019050032839105206,\n        127993841633501445,\n        18442075166379932728,\n        5173423558140830113,\n        5040877753307545604,\n        17492079016333825987,\n        1593793193144791850,\n        1051352355195775735,\n        5943763991772466352,\n        13308051483591590190,\n        9343693271988203192,\n        3520113272999099435,\n        13156437544558533124,\n        4628664430619092695,\n        13839519774612268130,\n        1561524063476792872,\n        1786105529617874762,\n        10743318550189039818,\n        4780466308508262376,\n        16286344021354707563,\n        7706876683201466759,\n        6056690298161881679,\n        10055051256791782547,\n        2985438843283121106,\n        5662611066107180778,\n        11762504057786722681,\n        6492163523688561469,\n        11903314370703515089,\n        6639143404964802752,\n        15352864297227042626,\n        6467331344424294098,\n        2513138096890065757,\n        18252010886576525300,\n        2137309836787405465,\n        5062748182344476458,\n        11543605570449724492,\n        8967616081750626506,\n        14081282030384505465,\n        14030488276049836901,\n        10391269999968368055,\n        1394499028419468024,\n        15566682361173996820,\n        4824266726532780984,\n        10757268905789656792,\n        16462615027839033267,\n        3588952369216858747,\n        7608658025855812414,\n        17838642938949526141,\n        94781055844175262,\n        711508162709410434,\n        16198763120066216543,\n        14522827050618946105,\n        8827834881271403758,\n        14961924349064399313,\n        14406825157858343587,\n        10665706975132276032,\n        584919077692434094,\n        12685151994185398186,\n        13214723590065181555,\n        13213787529887690386,\n        8702815823276144804,\n        11800457387620589360,\n        17199643293763420877,\n        11515884665346482491,\n        13888785899717119262,\n        3507252794824964582,\n        4603659836413814919,\n        4686748937472750550,\n        12421832631783901099,\n        3359573926155290420,\n        8446017905393844760,\n        2262184677731317052,\n        13013248939510347462,\n        14572693118580589660,\n        11022830998326129411,\n        8408924655992625371,\n        10410179516308402041,\n        6729141891150201635,\n        10466696767386859740,\n        2677788096731405850,\n        8361098508510730897,\n        1435994109558943177,\n        10128073597738606818,\n        921651131688578288,\n        3784288897383787482,\n        2528827532726381824,\n        2745271865598231885,\n        4303509657664184356,\n        8598151439188559180,\n        7339838340151008759,\n        4102212049950464432,\n        12029559280219172530,\n        8134545883285853776,\n        1905850669581557220,\n        16936295454560454463,\n        3680651425193647974,\n        13599577612277546424,\n        15046713416606033193,\n        456361953791851675,\n        4752112709649208116,\n        16115819506587034188,\n        2144813052901824207,\n        17046622154581665407,\n        2876106397373513535,\n        13003327799466428462,\n        16437033639571166321,\n        2399609620924500287,\n        6243590631410196409,\n        533278795730307090,\n        1033111886262872863,\n        4866574245728597909,\n        2464030264651522958,\n        13205453272650124362,\n        11723186208228000543,\n        12969372141223026578,\n        13167498178415442543,\n        11172031751757823858,\n        13257370093102747268,\n        3420723884940420444,\n        1598261708381549908,\n        4391211331742607590,\n        17534127798353752916,\n        7341206993048506664,\n        14415020221961337361,\n        2046719475561107676,\n        4259820090742316823,\n        9276901061275297500,\n        4961643293623327681,\n        17911768139050064538,\n        7558076127984989238,\n        568046345613284638,\n        6669214817759616213,\n        13786197531743943161,\n        4249924081611420922,\n        3529848342623085628,\n        5686448815512694800,\n        2430075147871613846,\n        1061366453609214842,\n        11667688802723514202,\n        10816922529577173425,\n        15297819755158335361,\n        12893049998502519066,\n        8535913883749763696,\n        6339822152676352172,\n        15201150192746395949,\n        6947773417864595038,\n        1035062681571489613,\n        5378407968343096021,\n        7821838471743655524,\n        8160693950261852840,\n        3806489823381045221,\n        9110537314944891991,\n        6678462809405704107,\n        13148862938001788174,\n        18343376155927784359,\n        1347615916836827854,\n        1983837968641288273,\n        4808698262452924116,\n        16203540206877084005,\n        3735610071301703267,\n        3879614205585090263,\n        14396127625458802513,\n        12971705508774594652,\n        16855551153787363016,\n        13770590905219407421,\n        8320920749683191847,\n        12731079676051788661,\n        6315049700706159729,\n        5520681748122702259,\n        18377945140487117991,\n        3750012964925257010,\n        6112975361804514180,\n        7762601797879075263,\n        7806585903492997505,\n        11722560531200514496,\n        1245601739242598527,\n        9851142601372397178,\n        5448093531458783000,\n        6655626903986665730,\n        1791030450653932131,\n        4267138194183414466,\n        11787121723746760335,\n        8737617848190145545,\n        1279353625599713991,\n        16837389613968560264,\n        12170971524469207688,\n        5744210997797297631,\n        6252807583283253984,\n        11981409579764369313,\n        13423106411424571122,\n        13506594589042509585,\n        9696374086757887423,\n        12259201030407607956,\n        1940425431459421890,\n        6794826149146208424,\n        3390019520570000181,\n        15663291992287526262,\n        8024326304926259059,\n        15605237955532295324,\n        7521900870833785280,\n        17076272368081584726,\n        14317742593729071792,\n        6186803591370756697,\n        8693074866179823680,\n        4521657215447236495,\n        7139214124438529536,\n        11252767985352986779,\n        9244757738422684376,\n        9181380892380409585,\n        14124397466598078340,\n        14092092430731683920,\n        13444150800556990844,\n        4618564184049153098,\n        11716810196377677056,\n    ];\n    test(out, 960, xs, ys, scratch, out_after);\n    test(\n        vec![\n            14220278540957382380,\n            2341486122221271577,\n            7196589596013057856,\n            1551746986989660725,\n            10730116577084868866,\n            5936722303301071470,\n            10369883251536410381,\n            12850276745016711948,\n            5296892922384710655,\n            17927383456923143639,\n            4297800151447374193,\n            13092886296891104150,\n            4359313044481849916,\n            3298387784200302647,\n            16596015395483459285,\n            6430047254377585078,\n            6434371216959893287,\n            14030068303817750616,\n            17753911968053092798,\n            4279608746592328433,\n            4376377052237075099,\n            41468300827872346,\n            14769069119913127616,\n            9177168551686374492,\n            15140565915751014925,\n            924212491380315180,\n            1560999192236438812,\n            18226600332889405930,\n            13348576723395503060,\n            3609063818274619379,\n            10959876508495766635,\n            1673947094507794325,\n            8930147615298565568,\n            1510138210058461841,\n            138658670646289458,\n            12458879312664552547,\n            2808979850323582450,\n            14034036666484023484,\n            5585848372598666548,\n            4257210144363692139,\n            6338629395801650540,\n            17487850811313620991,\n            11723765031594531899,\n            12058758430990318672,\n            13113234745283246366,\n            14258831759967032298,\n            5702057171550109179,\n            13097449289463197974,\n            4956526745376824433,\n            5705156949115651685,\n            12015733702012855186,\n            8669471405965585399,\n            1905089081593904691,\n            9375413288655317408,\n            2862087246546719140,\n            1438802037360108086,\n            18188344038773760076,\n            6710952137267346735,\n            5113990331512729307,\n            1249942195157804768,\n            12370173123137454524,\n            17270573617823502592,\n            7850217070904007210,\n            15008954292697138434,\n            14323227552451257069,\n            3071194499601430769,\n            1423266339629343645,\n            17719424777360227280,\n            5817741038340475518,\n            2288688081269683349,\n            1294813101366983999,\n            11187697042332288595,\n            16383307749918316156,\n            11964485411396601998,\n            2882482593432453314,\n            9642249517934314115,\n            10542384929787952175,\n            1685709334753615213,\n            9706601754650993843,\n            1704742035456300361,\n            14513229339862334723,\n            6682003045097239025,\n            4714611199273627241,\n            10432585451230614215,\n            5273605414681358823,\n            9969985476182536371,\n            5399491654701460340,\n            13433254437284849384,\n            8737041519297820559,\n            14151041462241779583,\n            12800325041646118168,\n            1054683376318581041,\n            10442674392431772880,\n            1301805922104023475,\n            12991162900765496493,\n            14882797183035693101,\n            4301011085545481404,\n            11250534379510854507,\n            6111542722921923807,\n            16925710356305375375,\n            4650629800913345495,\n            8040250152135495246,\n            6010724734735944849,\n            704649712350181160,\n            12623719311045527320,\n            17274359723691631952,\n            12634456101984828972,\n            18130410107220630156,\n            11889003125474723933,\n            16069412996687629414,\n            14767547198599161992,\n            1104256363303539555,\n        ],\n        112,\n        vec![\n            10900792384749518304,\n            1752565570529908396,\n            3402229115647561238,\n            2472381872242532960,\n            15748089475115162936,\n            1958855681762413475,\n            12100416912810779188,\n            12256578057348862042,\n            6556831077371185734,\n            15914846823057329492,\n            17346954154793811255,\n            17566187606614467459,\n            1433606366066775495,\n            9089332045922722756,\n            10056944581186126460,\n            5324425019386643029,\n            5281765195814058625,\n            1449711238109407238,\n            5903959110668039125,\n            3336955200427408551,\n            751494194154096512,\n            15350321905800137137,\n            12407374450431165353,\n            8705815621686854350,\n            18038286270431178148,\n            11671842546699641930,\n            9343865367071815679,\n            13401838367914321671,\n            18365991333043790435,\n            17428290065100096976,\n            6040216493892400727,\n            4224515713015397505,\n            16578741590625036060,\n            11835373548777581169,\n            18413478850867685366,\n            8453265724386285209,\n            5394500720474148965,\n            1927463313122594080,\n            4177838821929605731,\n            10680620304882583021,\n            180005403771618203,\n            2256408572502279608,\n            11718426532525535626,\n            14260315287467647015,\n            4035759666841010016,\n            16259497729863184485,\n            7772704202422133476,\n            6815813069474359325,\n            11207378575459431371,\n            18308033894506293455,\n            9875145231436590806,\n            15354934628544213986,\n            761822562304640527,\n            7391550101325083295,\n            4023926600201752832,\n            922969942182092752,\n            12110946035817932140,\n            16574399923422896843,\n            7087993004495856759,\n            8299428112066197874,\n            4589434828506762129,\n            13978205413565566735,\n            15675366647238478172,\n            7819770375827015142,\n            6823625407675143456,\n            2042269662440457350,\n            11521115322912473140,\n            13703874674141705702,\n            1295561690992462505,\n            12464082489717915012,\n            11378922861990148970,\n            2076282285705918066,\n            1390689690731346588,\n            13670979351308531000,\n            12980996477862222169,\n            10496970808504864546,\n            14015388605987660396,\n            4171129107047347396,\n            1656857204469415571,\n            17492457435753920912,\n            10132937897450237781,\n            5065601177732655021,\n            17498367701449356268,\n            9552937910825811119,\n            6213399497134928078,\n            12865519292113075754,\n            8548871019474664332,\n            12973212090641168109,\n            3018095992673320728,\n            4102580256148037725,\n            11411505815957245048,\n            8044142604358855954,\n            6163064685377006161,\n            7676133172626151339,\n            15177331097378985405,\n            923128391789363540,\n            8405355494789853124,\n            8409013636286216842,\n            17519952046647436442,\n            12690425880634822079,\n            7295927951214020420,\n            5103171252065286692,\n            4531269626482776566,\n            17509133779966482098,\n            16771567673323510549,\n            9940518318209913958,\n            2566490491730418524,\n            4997841530198583881,\n            11759671980624847072,\n            12804335234851198898,\n        ],\n        vec![\n            564820221219774033,\n            4488711358679422475,\n            10020082426042197380,\n            17225157352286806558,\n            5780768250525361575,\n            1970180556702143116,\n            5857604197270789289,\n            4060596445048742789,\n            4197799076012455571,\n            7044577438443748571,\n            9865458079653433267,\n            16329626967551115891,\n            4152461199188161627,\n            13000775528850398936,\n            7619420622350160180,\n            14900279174214956337,\n            1704825421557733731,\n            47372161928033978,\n            3056759021249434255,\n            16034528189533406528,\n            6435981853629992716,\n            7347416955208902363,\n            7867885339734871956,\n            16003312811447303393,\n            11973054691848315139,\n            4061237791967812067,\n            2991418391396596002,\n            4703879799196538602,\n        ],\n        vec![\n            17578771842269238556,\n            10550562699554142644,\n            8014103604728001619,\n            7390436293466268454,\n            7100508597220429999,\n            13756539744133134331,\n            3525655558627413814,\n            170556856626573274,\n            13733802409149293411,\n            7547658189901533049,\n            10109863308220110581,\n            2718018624165645986,\n            17221869495150324628,\n            1084076247398656329,\n            9986824749465272556,\n            9281213789632200478,\n            8263835511857229414,\n            2738190782342964576,\n            4727749457903038288,\n            5193416305832697137,\n            10922073469544468796,\n            10479120898291460619,\n            16531138594227806551,\n            5669282286095321480,\n            910652003754331469,\n            7613181106845480358,\n            9797364435815597385,\n            2605791728953382133,\n            3252270662152843680,\n            14622379517499579600,\n            15478463498321531331,\n            11333349078754873211,\n            3607338878951398292,\n            13712359136800994328,\n            2877919791629132004,\n            16504311509495367657,\n            3984067008787761258,\n            12750589284505094681,\n            2943531823722430709,\n            13059724297333425458,\n            913829495058925011,\n            18148528311470701517,\n            9740722521202851845,\n            14187622249425297058,\n            18404294373540546372,\n            16126489610510541686,\n            7594528449544330894,\n            7307162781265364836,\n            18291168119091813753,\n            6207931594466286839,\n            4606167418509673090,\n            14995240148627089997,\n            15715313103810577432,\n            18105567578045566655,\n            722560899028528632,\n            7800517321196764697,\n            0,\n            11237865801974219633,\n            8495979800230117621,\n            9987880506353342706,\n            13881397368512772448,\n            16410969001089181498,\n            333374346498930988,\n            4965563385767496990,\n            672660669687292950,\n            15110765557390623369,\n            6227398366445560799,\n            10437883884413763417,\n            186853687685224617,\n            12984935070726568218,\n            17363252202577108630,\n            11014686580262231685,\n            12860125675167553971,\n            5547449898028817740,\n            1954311880857527678,\n            12081499992106861757,\n            14088922543958348561,\n            5962182563926402036,\n            5741569353545905243,\n            4210355652762257668,\n            9053751503514703697,\n            7217335315946897611,\n            6001545942842673798,\n            2462625304327945285,\n            291604632040409357,\n            2217739517798639603,\n            2459684629220685427,\n            3250634546851783096,\n            6059950473822714693,\n            582656439794855702,\n            10281608630795849151,\n            15786006397997472307,\n            16261716592524561399,\n            17594773541694900671,\n            16563607893390940119,\n            15505686658080216809,\n            2051217090370709743,\n            13908204460746584986,\n            10039065459685700894,\n            14729811272925582111,\n            2491677743278343614,\n            2841321092069312904,\n            15064468426708488588,\n            9844013577617278901,\n            15394077255564897694,\n            7846267917227712141,\n            2926235763818832770,\n            3614802673424810100,\n            9439654670958755441,\n            11228283553719081427,\n            300805303577965353,\n            137972366037263628,\n            0,\n            0,\n            17236590422641137780,\n            3624909720816563168,\n            14760980184861256094,\n            12619697833885886701,\n            11158654646608400806,\n            6427394341906398356,\n            14871794339281852631,\n            4436807681521846899,\n            18179949743405593894,\n            13872577160616872141,\n            5825838831881338115,\n            3862312932472761757,\n            138044675074312990,\n            15071993629914359360,\n            17124765792905529105,\n            3248142733680724962,\n            3891075505082712037,\n            6225475960510427854,\n            11369706706515368571,\n            11286728465632095620,\n            5182849661875987731,\n            11179192798752789740,\n            10750517245961749782,\n            9660102259642485054,\n            7905348372980940366,\n            6606241368966986909,\n            10292241739332011027,\n            3848900457088510551,\n            12152591835908862357,\n            4562770772987021222,\n            15938089548127288011,\n            9698047696083781011,\n            13560645597951715331,\n            7732793292629543444,\n            7001973034910440318,\n            409123120027429255,\n            17678180108806694420,\n            12698074214205994356,\n            7447251798260171941,\n            9757491913093219480,\n            10221393982691316695,\n            12294139009925614381,\n            12645218559587650799,\n            1569889406832824935,\n            15186575789336541212,\n            11156326477797897792,\n            3241434575939356910,\n            7753423363217428843,\n            12882554975845472437,\n            8367515576296379496,\n            7308654739706172282,\n            10357093098345630105,\n            7448894655389345071,\n            13033958940183436012,\n            4023926600201752831,\n            922969942182092752,\n            0,\n            0,\n        ],\n        vec![\n            428006685349647609,\n            7204145293518952443,\n            11791003654963925746,\n            2505792214484682253,\n            8108316487989608659,\n            13780196866264665329,\n            9953181804399070508,\n            4136674009057114789,\n            16606729965278593786,\n            17177157337945625561,\n            4837680254021048240,\n            9379658380128247416,\n            3012240265336162150,\n            10902131616911906952,\n            4485885110776748559,\n            11729287033558411069,\n            3601025811236822387,\n            16042927197309963407,\n            15195320086232266472,\n            1335053215979905641,\n            13532069890206403083,\n            18094969954718697842,\n            11554202269641514254,\n            6403207599202754602,\n            5506746445690691110,\n            15578759879114917443,\n            8851198090240221910,\n            33092233213362571,\n            3901122084110515729,\n            1066956798888524232,\n            14634384737761094242,\n            12113217349928728328,\n            9311779266239300758,\n            3954657017302988647,\n            15532948787491930233,\n            7561648003514142824,\n            3533375924863968581,\n            11403256543506170549,\n            14720984883173782359,\n            17386473882517270759,\n            13904760793036335927,\n            1743693703212112035,\n            16080759313684757024,\n            16414994735840739,\n            5271412552749845691,\n            14285133708577039222,\n            2285218927081566054,\n            4416233718641470493,\n            18000037526325532907,\n            9874370178595584823,\n            2431098204987529914,\n            16053941488194364614,\n            13953671515916339883,\n            2042478395473246676,\n            15825222700565763229,\n            215338277757125297,\n            11715801345488940860,\n            15276655380547065511,\n            18173108185582673895,\n            14702410041012894911,\n            17207703913939254166,\n            4048944409583435567,\n            9240704600129021640,\n            10746010074070008578,\n            10882274053549736437,\n            17502803382613798018,\n            17103667474686148623,\n            1210754893985321636,\n            14411333195446047958,\n            9505671694718631767,\n            17438945960504601463,\n            17181086340701682720,\n            2087061119253391199,\n            4309925416075845511,\n            15682876991754565762,\n            1083109033127246208,\n            4261779269652031267,\n            12103546078796301947,\n            11869822949907847429,\n            10776362556491885652,\n            3496260740980747565,\n            1952845492765004055,\n            3956805099328134345,\n            13449597823431522461,\n            1303096111058814577,\n            2380211731709650934,\n            18106526914056683197,\n            11484139358020791769,\n            2127792824095743993,\n            4065001616617210813,\n            16699812364763026472,\n            7039834103740457737,\n            13922378224749177434,\n            3842744781605852390,\n            2881049947442869386,\n            9197037672589549736,\n            16294658006443583090,\n            1354837441772061197,\n            6800107739861512622,\n            7157401423299319780,\n            11344094968696196811,\n            14476284546277236050,\n            5424464793786542079,\n            5963838631551795433,\n            5066844411121684619,\n            17308776236012135105,\n            4153319859448120557,\n            9810663971090332314,\n            4914337127311050195,\n            3998867848399474691,\n            5662987571533822588,\n            879647540404803095,\n        ],\n    );\n}\n\nfn verify_mul_low_1(out_before: &[Limb], xs: &[Limb], ys: &[Limb], out_after: &[Limb]) {\n    let n = Natural::from_limbs_asc(xs) * Natural::from_limbs_asc(ys);\n    let mut ns = n.into_limbs_asc();\n    let len = xs.len();\n    ns.resize(len, 0);\n    assert_eq!(ns, &out_after[..len]);\n    assert_eq!(&out_after[len..], &out_before[len..]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_low_same_length_basecase() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after: Vec<Limb>| {\n        let mut out = out_before.clone();\n        limbs_mul_low_same_length_basecase(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n\n        let mut out = out_before.clone();\n        limbs_mul_low_same_length_basecase_alt(&mut out, &xs, &ys);\n        assert_eq!(out, out_after);\n\n        verify_mul_low_1(&out_before, &xs, &ys, &out_after);\n    };\n    test(vec![2], vec![3], vec![10; 3], vec![6, 10, 10]);\n    test(\n        vec![1; 3],\n        series(1, 3),\n        vec![5; 8],\n        vec![1, 3, 6, 5, 5, 5, 5, 5],\n    );\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10; 7],\n        vec![10200, 20402, 30605, 10, 10, 10, 10],\n    );\n    test(vec![u32::MAX], vec![1], vec![10; 3], vec![u32::MAX, 10, 10]);\n    test(\n        vec![u32::MAX],\n        vec![u32::MAX],\n        vec![10; 4],\n        vec![1, 10, 10, 10],\n    );\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![10; 6],\n        vec![1, 0, 0, 10, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_basecase_fail_1() {\n    let mut out = vec![10, 10, 10, 10, 10];\n    limbs_mul_low_same_length_basecase(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_basecase_fail_2() {\n    let mut out = vec![10];\n    limbs_mul_low_same_length_basecase(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_basecase_fail_3() {\n    let mut out = vec![10];\n    limbs_mul_low_same_length_basecase(&mut out, &[], &[]);\n}\n\n#[test]\nfn limbs_mul_low_same_length_basecase_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_24().test_properties_with_config(\n        &config,\n        |(out_before, xs, ys)| {\n            let mut out = out_before.to_vec();\n            limbs_mul_low_same_length_basecase(&mut out, &xs, &ys);\n\n            let out_after = out;\n            let mut out = out_before.to_vec();\n            limbs_mul_low_same_length_basecase_alt(&mut out, &xs, &ys);\n            assert_eq!(out, out_after);\n\n            verify_mul_low_1(&out_before, &xs, &ys, &out_after);\n        },\n    );\n}\n\nfn verify_mul_low_2(xs: &[Limb], ys: &[Limb], out: &[Limb]) {\n    let n = Natural::from_limbs_asc(xs) * Natural::from_limbs_asc(ys);\n    let mut ns = n.into_limbs_asc();\n    let len = xs.len();\n    ns.resize(len, 0);\n    assert_eq!(ns, out);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_low_same_length_divide_and_conquer() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after: &[Limb]| {\n        let len = xs.len();\n        let mut out = out_before.clone();\n        limbs_mul_low_same_length_divide_and_conquer_shared_scratch(&mut out, &xs, &ys);\n        assert_eq!(&out[..len], out_after);\n\n        let mut out = out_before;\n        let mut scratch = vec![0; xs.len() << 1];\n        limbs_mul_low_same_length_divide_and_conquer(&mut out, &xs, &ys, &mut scratch);\n        assert_eq!(&out[..len], out_after);\n\n        verify_mul_low_2(&xs, &ys, out_after);\n    };\n    // - MAYBE_RANGE_BASECASE && n < MUL_TOOM22THRESHOLD * 36 / (36 - 11)\n    // - n1 < MULLO_BASECASE_THRESHOLD\n    test(vec![1; 3], series(1, 3), vec![5; 8], &[1, 3, 6]);\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10; 7],\n        &[10200, 20402, 30605],\n    );\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![10; 6],\n        &[1, 0, 0],\n    );\n    // - n < MUL_TOOM44THRESHOLD * 40 / (40 - 9)\n    // - n1 >= MULLO_BASECASE_THRESHOLD\n    test(\n        vec![\n            461989387, 2665399848, 3579300374, 878189998, 4019917942, 1906890030, 3540714906,\n            785021435, 2655957692, 3564967487, 2215671253, 2954375312, 3945786785, 2381932623,\n            570517012, 897945067, 890538555, 4176726399, 1938024252, 1214448000, 2607894539,\n            1325279234, 1564558613, 987829481, 2178327923, 4147856447, 4083057668, 785634261,\n            2167973152, 1652571464, 70145184, 217938310, 1833392838, 807859939, 1395394971,\n            2852311871, 2904303228, 3198169893, 3331434354, 735263109, 4147668831, 2611779917,\n            2853615276, 1375955505, 2451249431, 4226040869, 171021557, 1972314766, 277184426,\n            2375785672, 2222399598, 810164152, 1039489350, 2933759445, 3534834167, 1138611909,\n            672716981, 2084719089, 538544765, 3894759873, 937996537, 1412775694, 3879993313,\n            1085679676, 1967211093, 1504744432, 3666320291, 2237452530, 1826697476, 3221257357,\n            580543441, 4245347387, 4208784414, 3482952509, 1951149172, 3708033640, 586662200,\n            345242773, 2377487665, 3100161675, 3699715979, 1377295273, 2132506492, 293803895,\n            1798986191, 4197257911, 627991308, 2783841978, 3918540249, 29355619, 3412985598,\n            1519516456, 3710419939, 721212175, 3932373394, 4152619047, 2587596408, 456847065,\n            1492972877, 2878578092, 4224013690, 4183847837, 3441313194, 715397057, 4270121821,\n            1405478162, 3277147812, 3938142059, 2533309358, 1504116963, 3653366746, 2109153696,\n            2511274585, 90325377, 1647825264, 836765640, 1125067095, 3544759944, 2652860738,\n            1079540720, 1986083965, 3960406547, 349138094, 2949875969, 2733651822, 3091427333,\n            3570148981, 733070163, 4233388956, 3214072096, 3112563117, 1651509303, 2142845704,\n            1051620120, 3770606367, 4159133142, 2506712000, 1161310860, 1621911269, 2878403318,\n            206258321, 1812136445, 3881335928, 703342820, 4106909674, 3002521966, 2923723774,\n            3098805336, 1503909373, 827876722, 188113568, 342517338, 743560400, 2994196952,\n            1909518945, 4098343484, 1410898722, 1188050013, 3739587846, 1187118353, 2097511427,\n            4268272529, 3038427753, 3211203785, 4227105159, 1129593228, 2044890920, 2369860975,\n            2369399578, 1454306337, 91937919, 798293675, 163666826, 774359002, 1184861045,\n            717591688, 1661912106, 2791047481, 2777706888, 3878079014, 1418504920, 2448450319,\n            1922646614, 3068210241, 16469458, 4024185119, 1215576054, 311246292, 4059710876,\n            4265782141, 4187978245, 4278365409, 4288916077, 1305069248, 1563951794, 2960618962,\n            2009022918, 1272389839, 2439394275, 4208883918, 1504352264, 369924536, 13357077,\n            1532849248, 485135885, 2924605508, 841648515, 705817258, 954451953, 3740323831,\n            2757913511, 3424971384, 2775642081, 1876912734, 630579777, 747682898, 3056441789,\n            2407022149, 3613070805, 2027387425, 4277873093, 3802579285, 744104253, 2776789109,\n            1370095770, 1305744491, 18166236, 304885422, 2971797302, 3549745966, 741626137,\n            795961656, 1741115244, 3220360703, 4121898682, 2553071415, 3851952692, 3272833446,\n            1749035103, 3660315457, 815620200, 4112719780, 4169868140, 111675416, 572996149,\n            527650323, 3028027759, 3074169491, 3295530784, 1548029727, 410371832, 1384175276,\n            1019155445, 940733503, 3362087055, 313802022, 1997544491, 472489619, 1402431484,\n            3640929705, 203857340, 399422159, 2714826274, 1480889873, 2185368870, 2143561855,\n            837780556, 4244388174, 347736364, 183686097, 896312971, 774613537, 3413697161,\n            3233389068, 4019739363, 337295178, 1832529524, 1289908799,\n        ],\n        vec![\n            3152074368, 2609279004, 2289393871, 1484468596, 1208431774, 832849643, 288683182,\n            3006999416, 1903458849, 3111117159, 3671553126, 427622591, 3190285531, 3311271958,\n            234886006, 1671522985, 529046783, 2869877832, 2642573124, 60209762, 3035295220,\n            2511225368, 2206515646, 3850823730, 222908649, 2567682433, 2162714751, 490925601,\n            1537433919, 3002058493, 2023135946, 875430531, 4129401376, 1327326767, 752062706,\n            4112039026, 3726450563, 3167143759, 3983527603, 842382530, 3153795246, 3598914654,\n            3417317498, 3553459715, 1106685605, 2142189479, 2339845222, 2514744298, 1446296496,\n            3075359392, 317750583, 1297434773, 806470314, 3548517324, 2896883965, 1547969571,\n            2485824310, 805179503, 4202831898, 597659823, 3535591228, 855958045, 1755923867,\n            3365965707, 9682282, 3287632414, 1149281829, 964617017, 4003502184, 1850865215,\n            987376895, 22121503, 3262730353, 3067466886, 1231496573, 683689717, 2341771143,\n            2402732693, 1733447213, 492218933, 1092253813, 3015603177, 1300236300, 2607300207,\n            2327157037, 1107197558, 1862484547, 970467880, 1116477123, 1727183986, 1866387311,\n            4294876996, 2433423873, 1947645522, 3490401276, 3091887938, 2150744771, 1590400854,\n            4235775628, 2260414990, 2867210260, 1289781050, 3796740921, 1443787618, 2784677595,\n            2242443647, 2083926475, 492343557, 4143467814, 4259917315, 2370814617, 1512402965,\n            1165630944, 1172451831, 448126667, 2504642429, 2943134913, 253722272, 3930555887,\n            236043678, 2028066178, 2274670726, 2117908175, 1814596459, 1589398655, 3643981976,\n            3708172828, 2628370440, 2994406702, 3768287526, 3697661671, 72250477, 1952682906,\n            3890984670, 2335366358, 1486511900, 3932950080, 4154600910, 1641913905, 1181402070,\n            1236047930, 3178973441, 3150857560, 3584289380, 609401228, 733328893, 3965865377,\n            3698014337, 2769360864, 1034884438, 739582397, 1922193210, 1130663039, 2639094031,\n            2919470545, 3614476088, 1565067122, 120324146, 2567666261, 39022936, 4114703092,\n            165126137, 2949477884, 2405325064, 2237215558, 2498656017, 1425552926, 1121499119,\n            1406111625, 3405344040, 1219643487, 3602348463, 512125432, 1367217197, 1477847901,\n            2226582448, 1871611823, 1134590604, 3982040908, 1623284673, 1857753233, 321590484,\n            3220580378, 727231217, 983590217, 3953357093, 514378029, 3972342992, 2131575137,\n            3154014995, 1075955265, 1966241007, 3201815871, 3097020322, 3758733690, 762231963,\n            344183707, 2857398231, 3337254067, 218375481, 882367684, 2204572067, 1038287244,\n            3321266584, 2994716041, 1768291972, 3957932586, 3024157312, 621247724, 1627210559,\n            3958490863, 2281045736, 3555698779, 3902429680, 426592368, 3133450642, 4010080363,\n            1875043293, 3628899254, 2601848204, 663261663, 1664093718, 3328282988, 2238354920,\n            4012861950, 920971329, 1582693646, 3875328875, 3096546242, 2216996167, 347539721,\n            454900186, 2025219395, 1756065860, 1337774773, 1867666187, 584376262, 2443135798,\n            699177444, 2101251123, 1815621294, 1747522047, 4180260619, 2565611399, 3614008442,\n            981733561, 339547618, 1433098485, 523523039, 756060971, 432087064, 1056119297,\n            3262021204, 2309315188, 36557289, 3784506551, 3467316194, 3626135421, 2707559086,\n            895034761, 805184221, 2207233543, 2613952626, 2493110341, 1147976987, 3110836167,\n            738569324, 2424079556, 2624128221, 441916235, 2974993618, 1131709928, 1556781361,\n            2518935270, 2504025847, 61629344, 3838407260, 1506641084,\n        ],\n        vec![10; 556],\n        &[\n            4070586240, 2326530569, 2261395410, 825689729, 2475737777, 2607579621, 2779055768,\n            1031674491, 1535775813, 3799159704, 2509339137, 642496935, 1388726819, 253797856,\n            2389660485, 1933170407, 612455389, 4107963146, 1906296838, 2898497315, 2050606412,\n            3001222322, 1228059054, 2396274750, 2706199930, 3790047803, 1941351862, 1789409896,\n            1715227383, 4265202904, 256846097, 2002262811, 1019015022, 2082931322, 892118471,\n            1902650557, 1821044055, 628436942, 992944813, 2152035281, 3205031699, 3012731022,\n            640270255, 3942556100, 4180900492, 3316509849, 1950826436, 3810257818, 2224553717,\n            1511731290, 3648751071, 26431626, 4214594419, 3417633336, 1456941539, 858305585,\n            1967412985, 3623211292, 3984085024, 1384481949, 747470989, 3106003382, 1550527069,\n            3614045491, 2344422097, 373587226, 2547151647, 994917426, 2913847676, 2378129020,\n            555898239, 1108784126, 1609305655, 2815855409, 2517331928, 235971500, 4146164385,\n            513982484, 3224855761, 616267314, 3033012116, 944903736, 4143585656, 1155526042,\n            1713184683, 1067605397, 4185794190, 3837642784, 2629382351, 937694634, 807052082,\n            200210144, 925428999, 2855412451, 351040428, 3193751061, 1327138015, 1236708649,\n            762670968, 637002031, 3265514324, 1325649336, 418630090, 2004473621, 395337679,\n            1254733858, 2979245588, 2917625161, 4154932643, 333114873, 4020812672, 196942723,\n            3805667762, 1295056656, 757090141, 1581564716, 3028221550, 652769076, 2520564087,\n            1804643123, 597439055, 2022877640, 2295355063, 2554644875, 2505050304, 1251254106,\n            766564249, 736769858, 655024585, 3983536005, 2807999031, 2526649460, 3997807999,\n            1027142135, 3147220153, 2611110579, 1353792039, 96665204, 3799354781, 1169870906,\n            163280197, 1201147091, 506111450, 560981310, 2487787507, 293569384, 1660966093,\n            4172508795, 2079157727, 427559941, 2199181463, 766276398, 3590398380, 921568940,\n            1978512327, 2526895800, 155351140, 1734194686, 4286806742, 1665643514, 2910888313,\n            1105506458, 2792013812, 84803204, 2779601075, 3530726950, 2109503137, 447716492,\n            249291965, 871214282, 1950969439, 831198533, 2725086482, 1111889448, 3879479978,\n            2578937795, 2360329247, 849485221, 3118220783, 3215737700, 2629034929, 1803802428,\n            579744897, 1521586187, 3794906163, 1682984424, 2501371511, 382339060, 1548025441,\n            3993119644, 2642540168, 445700200, 973327482, 672676716, 3810693263, 3980560630,\n            633737607, 2979566412, 3035890974, 2663806368, 3077368948, 559094664, 873179537,\n            3907578303, 2898488985, 559532336, 1951693750, 3221546487, 519175878, 3817909883,\n            4143965836, 2159038430, 2155451492, 984127081, 1552180477, 3998228380, 951987999,\n            3271220480, 3991577644, 189427243, 1451593380, 2417528240, 2707909762, 2545325149,\n            4092625458, 1678828086, 65074887, 2912853674, 2298196517, 1962123671, 3156663717,\n            1809562653, 3422933930, 3543349121, 1539368201, 4132862547, 2117037713, 697944662,\n            3761970455, 3210335685, 4061395188, 1399948007, 2797740984, 523361390, 2891000343,\n            4043976998, 3948000788, 2806803391, 372268870, 3066648573, 1552197320, 1104893676,\n            1977956692, 4206072635, 1777799765, 2593085983, 909587553, 701089400, 3025031477,\n            3150914776, 3383493968, 3297968979, 2127114185, 347641566, 1133943045, 1397026960,\n            1102135376, 1790048118, 1531899702, 38573247, 86358464, 807071035, 1322974764,\n            3918796486, 2658009039, 1875612194, 2278918363, 4156398458,\n        ],\n    );\n    // - n < MUL_TOOM8H_THRESHOLD * 10 / 9\n    test(\n        vec![\n            1131150821, 2762649368, 1291624341, 1701704353, 4014105561, 3682713698, 514896869,\n            2382721993, 4199508292, 116228850, 1913167611, 2543927978, 3462810307, 2182535806,\n            3234802163, 4243621064, 4189108519, 2844896515, 265654095, 2925399216, 1942537721,\n            3688510290, 1467767823, 1331956526, 1810538674, 3416955279, 2622944711, 3883742491,\n            3716395614, 2226266870, 4231113757, 1703472377, 799710037, 3188891105, 2002885312,\n            863976785, 2197487335, 3973964671, 982134718, 3039352665, 4058841706, 3126556723,\n            1839202656, 3512286394, 1526861314, 2857382087, 1509071714, 3983699181, 4164670109,\n            3541034768, 3414363792, 3719311258, 4228436631, 418239225, 2810981500, 2839232135,\n            75036670, 349836787, 995927099, 1154560390, 1157124967, 2338833107, 3519575136,\n            3676349342, 1999912677, 1473285447, 3384834599, 3729173386, 837302670, 1824368274,\n            4080054412, 3463347047, 2292431457, 4047304953, 3186147982, 797486141, 2414391350,\n            621753596, 2992059534, 1538383233, 664053981, 3061928211, 3215272269, 266835070,\n            2414626927, 159250143, 3019791116, 3731135237, 2761751093, 3586027201, 2089419276,\n            374111952, 49970046, 2897511132, 849093074, 1002730932, 3171254030, 477351679,\n            349956886, 1571756720, 2974023410, 2229070678, 1445469779, 3125204262, 2251629977,\n            3617654578, 3758587650, 3379646707, 3221020164, 3946481152, 746980266, 445806733,\n            3092441206, 2414172109, 45651552, 3218735738, 1981382211, 3339893115, 577943370,\n            3262981881, 3145699413, 3050111476, 2776211838, 888798694, 1098018756, 2384093069,\n            137109573, 3849877919, 816321891, 733291770, 1688860823, 3776150706, 259328987,\n            1793361953, 1360633863, 2822514209, 1611568653, 3671864876, 2995705621, 1703631428,\n            2545904596, 3558099294, 339073366, 1914245190, 2248240708, 2918919078, 2367951631,\n            3244616755, 1246248837, 2724721481, 1977303106, 853273015, 609224845, 2572706277,\n            4120826908, 3132172741, 2679460826, 1731116641, 1420934603, 4095172779, 2134926401,\n            998210691, 3678534171, 2288544872, 2333609559, 3187493478, 497033878, 13547027,\n            1366761551, 3620514533, 1846847912, 3066898750, 4029310316, 1785305517, 2975988788,\n            84028222, 1604571422, 159814579, 3302598788, 1860412674, 3924970651, 3084289036,\n            299916336, 2801290202, 1879794819, 3343450230, 2673079282, 3615958442, 3162274325,\n            3102296518, 435434416, 2915209493, 1817171393, 1159766844, 574519135, 3033326838,\n            2027440653, 1457685030, 2574873438, 877258212, 1477651381, 258103620, 4236228819,\n            1480006308, 2237899379, 4229629566, 1151532728, 1869635395, 3423452052, 3699388043,\n            91696809, 1622972763, 822248470, 1515292231, 3842486533, 3927210641, 3225680067,\n            4254069260, 3886678620, 3984473786, 2759203157, 2517007583, 145365022, 1533952248,\n            3917863954, 1567125726, 3108296518, 1454586200, 2011082282, 2132338201, 3182831171,\n            1413497090, 1856759670, 1984669926, 4212692874, 1110589546, 1440032735, 3646801244,\n            3610860056, 3043101171, 3857863470, 708594714, 3801293829, 84401414, 4009945641,\n            718064348, 1782564232, 2884677460, 3817956052, 2164661851, 1032113674, 2265026833,\n            3990818483, 1979791851, 1179815111, 1179610990, 3801644913, 2951826902, 1933447922,\n            1907000683, 2045622439, 3615799713, 4178470833, 488268281, 1409188637, 1338007608,\n            3944782180, 3885373568, 3104460402, 3927888479, 471271819, 3870427647, 4196319798,\n            3583191843, 3310030186, 860772115, 2433189612, 830226736, 3738387750, 1448499320,\n            526587241, 3892532590, 3439491908, 1039036501, 2388493771, 264726903, 3966258028,\n            2505867608, 407881715, 1631490147, 2823006404, 3497117958, 646382286, 3107394453,\n            3277949521, 439910091, 309065703, 1950804341, 1808416502, 170990188, 1335198213,\n            689918674, 1582196175, 2640621496, 3498813308, 2761060243, 1678685681, 454638300,\n            4004659669, 3681198397, 3976254726, 1940449540, 212889053, 1912817590, 1301852137,\n            2300183575, 2626591779, 3662656365, 2241640523, 2073990699, 2843210521, 3907897499,\n            2127053203, 3464740089, 2517063724, 849818543, 2198029686, 1607835696, 2158656964,\n            2474427278, 3105729582, 2593228154, 3652599476, 2493295322, 4214474951, 2092751192,\n            3508872416, 4135027724, 1087631006, 3869783862, 4127959478, 3950654826, 1413528055,\n            1583176859, 3118004380, 3469658789, 166660010, 3732069246, 1165982209, 3249209142,\n            3030024737, 4209637631, 1574902930, 612943597, 3575711404, 2421873039, 3084377476,\n            826443943, 3566117097, 1367287788, 884174375, 160667863, 839942561, 124546248,\n            3443852897, 1935836700, 3578696710, 3442653707, 3106215554, 956073431, 352475044,\n            3325573670, 4056377273, 2444639044, 4059211486, 3187262860, 1232076586, 712845366,\n            2490553931, 750933277, 1200249747, 4114847099, 3132331434, 426349171, 3418210348,\n            1864124410, 3635934842, 1778322792, 1268045228, 1155805234, 3891131459, 78081971,\n            2759073032, 2990099706, 752418656, 1424173464, 2440522876, 1954352637, 3476425702,\n            1980817220, 3283383787, 3606231400, 510762389, 4244763535, 2869358935, 1727272135,\n            3522246353, 1733965890, 274429005, 1074555950, 1116810589, 2059372124, 1433737439,\n            686360791, 3524954413, 790420924, 253262937, 2490041017, 2988382494, 2680296403,\n            740237358, 638968890, 3561449712, 1270014183, 2732717194, 2652066843, 1127846686,\n            1905112070, 7000223, 2815346469, 3485672034, 4150256142, 1201712608, 782060943,\n            3850587668, 891222391, 3919270279, 2284997530, 3355185596, 853556214, 2382672975,\n            4082635614, 1975597308, 775008313, 1221881305, 318112932, 1558885629, 1659368995,\n            2737245040, 3182289543, 2865953307, 1913563745, 3407843590, 2774667399, 2006733037,\n            214221440, 2867329721, 1460609363, 1420414655, 2442726895, 2077873651, 2078741260,\n            3351565491, 2650010589, 3624853117, 2808835283, 3576673605, 3312161027, 1089529182,\n            3411999136, 3214717560, 2569067404, 1395383167, 2628670095, 2534091665, 3416849349,\n            602644653, 3868242106, 780173614, 2918196647, 1069725684, 3173740663, 3441776760,\n            1918895783, 2591986841, 2047011602, 4037432, 633731206, 2672531137, 3708159409,\n            2150429215, 954500477, 3990097385, 1947492698, 981465130, 314252035, 358539692,\n            683336340, 2361937249, 2060146559, 232682027, 87274822, 3435325468, 4227641462,\n            882380594, 231040832, 3746812704, 502289657, 830742778, 3389856631, 2652175412,\n            3688357856, 3281892315, 1707485812, 227398450, 531784725, 1476141529, 2868884010,\n            1656814989, 2816953357, 1091559808, 1917641087, 1677755142, 548205597, 175354774,\n            3985092082, 3309818895, 464474156, 4204834984, 3761500115, 2438523503, 1732610689,\n            1486464139, 3967200098, 3929926820, 2339786049, 3907108412, 2199568695, 1134103910,\n            2216911633, 2182031298, 2579739862, 570100824, 3289356324, 3458481331, 611877571,\n            1507859299, 2274314160, 1548661374, 903468480, 264167483, 2119844238, 1038239445,\n            2988435265, 2038849220, 2021865993, 666366893, 1683542644, 663579226, 2516381838,\n            1452293108, 2860570530, 4048880023, 4066088025, 3363037289, 2542443950, 2325290119,\n            4126749311, 3549516466, 2259054696, 1124113431, 2596211298, 926851034, 4100110238,\n            619577504, 465050718, 921970188, 3443237807, 3185995153, 2512437958, 3138724608,\n            3421198187, 1215660513, 2802265359, 3639819408, 698058093, 4005388493, 701032232,\n            1900034464, 1258990473, 1384847467, 47742046, 2533738470, 4033217779, 193441436,\n            1167926881, 563345579, 1064730454, 1028831057, 2118889296, 1922177050, 3759770599,\n            762133197, 3305899630, 1774669125, 2184377046, 3697369449, 4032191246, 3613695996,\n            2714184171, 672093641, 2806515914, 754799026, 2811057556, 3677282514, 1644648375,\n            519012895, 2947700042, 1068870929, 1749850446, 2745609943, 3915641236, 1473746566,\n            245175508, 464459969, 2300554864, 452081255, 3542824159, 3984931523, 4038093048,\n            811698203, 3990065017, 1843168045, 102873045, 1872945131, 1381891297, 2689743436,\n            156330831, 3030944325, 2925864612, 868161142, 1955093372, 2271793313, 1293536600,\n            3877989118, 4085300196, 20015595, 1524783113, 3220067646, 1128665882, 1605056207,\n            3769938324, 3278249586, 865516226, 2018942727, 4285193298, 4136394815, 18140432,\n            1298007913, 619558910, 1468345138, 3640156579, 3844459024, 4251273955, 1279325353,\n            1490675071, 3812253034, 1588374415, 1408352173, 1856222658, 3479408648, 2553632750,\n            539602295, 2953721539, 3550404522, 2987339861, 3573803000, 2985536505, 3408426662,\n            394679673, 2338150855, 233169574, 2666618942, 885970658, 1261112849, 3026593914,\n            1941961461, 3178744470, 3418317636, 2483060546, 247068105, 3869710296, 2601474183,\n            1861230264, 466844147, 365421277, 1647470055, 2545886518, 3344491344, 2743895143,\n            2612409420, 3015491275, 2263288257, 3788192586, 3621947232, 3632971491, 2590893591,\n            3078266930, 837964625, 1062932151, 2387310193, 4263324106, 3590937645, 2690575361,\n            3471028939, 3052123108, 1287391629, 2780458428, 2899985132, 3768032123, 593582914,\n            1049982970, 3417846725, 2745208959, 2638635678, 2782226812, 723243488, 2883204599,\n            1861655363, 2193262251, 460750285, 408576776, 3151751571, 2348465332, 1090324024,\n            2080133910, 1884601095, 1792700738, 1586206119, 588433151, 1694897587, 3243922990,\n            3147195067, 704523940, 715280464, 2859196369, 2818686408, 3845709444, 388946443,\n            3822371361, 1083710054, 3973525343, 890875638, 336962766, 879786542, 3372880597,\n            4017818517, 4022694260, 1246618400, 3272410744, 2932065660, 3037109199, 1994060649,\n            934925733, 2550662182, 3369254727, 3300198891, 1222413593, 364996956, 2915355551,\n            2528303182, 1340653763, 6095745, 430607376, 2462322073, 82876788, 1168959908,\n            1417636305, 1265099813, 274745957, 167508621, 3915190887, 4169873122, 2699401240,\n            349817411, 1083358516, 378109903, 1137415528, 2610418640, 133616096, 1079889395,\n            1596538242, 1340572700, 3806709899, 2995810782, 196324185, 2670063802, 2058666273,\n            2243102740, 2109579437, 3319920398, 388799298, 1644474748, 3835051237, 2938119592,\n            857157002, 3904318910, 3191603530, 4005173949, 2864727253, 1049195541, 1431710706,\n            2394529501, 314388331, 3586260934, 1413117985, 1378439215, 90290944, 1187129087,\n            2806417408, 2252578657, 731737960, 3976349288, 2835651723, 3336636332, 1381984503,\n            1669124519, 3410912262, 3447243564, 222368697, 1603262029, 195964253, 1003881737,\n            3008564716, 3332124267, 3723209179, 48076559, 3962702541, 3175563645, 3613059603,\n            170958653, 1413948782, 2426947383, 1103046276, 3139837644, 502007526, 877737020,\n            407264876, 765859135, 1474201609, 2991446344, 3468949411, 3551131726, 560361863,\n            3036580569, 3430955843, 1011987611, 3299206602, 1953068741, 1760110431, 1246003603,\n            1099977647, 39794154, 389004595, 3989513261, 2907906071, 1622738740, 458000748,\n            1389814785, 699501716, 2230559, 2553609548, 1451109816, 3441722227, 3416954130,\n            2885301526, 1740199906, 1803806248, 1403790177, 3516185322, 457833177, 1470646316,\n            3450277077, 2082948067, 2481239364, 722376046, 2758592798, 2482526812, 4010504381,\n            3378951917, 1539096335, 1599687582, 2811560884, 2435502051, 2900235322, 3627166120,\n            32186692, 701703510, 2447124866, 1509277763, 2326977874, 1288896304, 230630067,\n            4134237779, 2960340409, 2917586567, 1164733926, 24754896, 2143494083, 3622160753,\n            1940106076, 3135397968, 3020065317, 1748012748, 1014590694, 162297287, 1327741722,\n            746744365, 3185502087, 158350155,\n        ],\n        vec![\n            603622954, 2186113344, 2211632492, 2411520388, 3589635543, 4086364596, 3581723392,\n            2612098311, 2096044537, 1640167886, 3342490559, 2125968601, 1990634435, 312775010,\n            1802349863, 1309411103, 3200864131, 1358335036, 1912893833, 1596337323, 2247665998,\n            2443116949, 2420155681, 841076086, 377456615, 1237592486, 3216360690, 1624285201,\n            3654260727, 2790733511, 204168525, 4052634612, 2854194678, 3030697959, 948115195,\n            3826905149, 1976102477, 1784393101, 2995452496, 3261601101, 2842141116, 191128211,\n            1816171240, 2015310936, 2049251282, 613801401, 3835986911, 2470139377, 1942210663,\n            3899898568, 2985108866, 466048082, 1427695846, 860088895, 1905116312, 17072967,\n            3747648444, 4050068534, 1235378754, 3463008343, 2901169501, 3732797830, 3827542306,\n            1442668438, 2553056440, 3128009710, 2361840470, 2945391897, 2844092880, 1669579593,\n            285906550, 271337390, 3550080313, 1550684000, 761190775, 1986821670, 2760227175,\n            3755739359, 3195863504, 1506193392, 102572887, 3429355396, 2738466594, 2588290861,\n            921241140, 4000693169, 4200573367, 494632512, 3030208655, 4097675912, 3273014929,\n            1507497783, 1426537214, 1292494848, 737012202, 840807439, 4173254089, 2614555500,\n            2112014072, 524226642, 4134209698, 3019212395, 1098411347, 1127762058, 2520698217,\n            3618515874, 2710325152, 608562040, 3514989488, 4158363396, 306180876, 1211447956,\n            507700449, 911736750, 920771768, 3055911518, 2660700314, 3162062346, 460147980,\n            3893374896, 3335254211, 1730373325, 1769502379, 328248258, 3605468276, 839999978,\n            2617035765, 3256832677, 4166868036, 3034242873, 866786060, 1439047189, 1075047697,\n            3791824427, 2428657149, 1942106734, 3406726485, 1061929031, 1911794305, 2055938947,\n            4130327586, 3752449664, 1741794117, 2088328119, 625641627, 315760669, 2840762267,\n            327041843, 2880804433, 3266656983, 2181853630, 349055847, 1614300853, 3026780591,\n            3723351880, 4108567046, 2344446900, 2195753474, 1660780233, 2121691315, 102176310,\n            2695465705, 3089322092, 2775472883, 2630273841, 2862312016, 2071059637, 1584923974,\n            609930669, 631828585, 1504369275, 892077659, 3793274532, 111247066, 576379360,\n            3257765683, 2389261674, 2210132561, 623967505, 3475583657, 4078514517, 2696227314,\n            423351810, 219536780, 1292034857, 3134390109, 2644943026, 2175174277, 854381939,\n            1615329948, 1003209984, 1497561541, 1581742618, 3453870211, 1697610716, 1386823953,\n            1754275998, 1049523617, 319480181, 52790852, 1843711621, 1677461984, 2268587847,\n            1467575383, 809390384, 3208538160, 1710678484, 3852975493, 3491099676, 2208895838,\n            67474001, 1909240027, 552833552, 1068516200, 797958994, 1336265228, 52799811,\n            3497387824, 2615050498, 2306496091, 1509488357, 3175308944, 1400875928, 2613915127,\n            4014015840, 3770610211, 4050294544, 1133059937, 1931794550, 609394840, 730823155,\n            2274984932, 856801557, 2940954445, 1507833826, 3361523681, 4114500875, 4016167065,\n            4145941303, 3897868338, 2892060643, 2413714784, 254604231, 966264223, 3162224073,\n            4257953665, 1775093780, 4059868817, 229216133, 3095801819, 2780776724, 4197103660,\n            3945827647, 3590005880, 3385750965, 588116955, 933606134, 2954149398, 3136897257,\n            3742737011, 1904500440, 201319529, 1627670998, 1436294506, 2391068109, 2754913831,\n            617553192, 1237348537, 155331642, 666659293, 2505670832, 589051162, 1617401511,\n            778060751, 2180910952, 4141824369, 600328318, 4045490772, 4118525083, 916092943,\n            3026682184, 2750156732, 1451420324, 1940219622, 2451125563, 1894319083, 712954796,\n            1241142933, 1547315725, 2191677486, 3213688112, 3550409294, 1708221443, 295690779,\n            4139342911, 4044286844, 2827851250, 3745891811, 1142267160, 1568307568, 4187843675,\n            2744250115, 3543324184, 3231805406, 844623162, 552365416, 2085517327, 2950237187,\n            3595863774, 1726025744, 3066980951, 2635434821, 3786966597, 3778968631, 2367918512,\n            1544339264, 3675143945, 2263950208, 256073448, 570000958, 2196435922, 3645119110,\n            1544421656, 3665474053, 2710076922, 3456896575, 1661288153, 798098177, 3205290044,\n            3267217028, 2164126201, 991695109, 2360577181, 736096951, 580335383, 440415808,\n            2970181697, 1174793452, 2790186381, 154139411, 682753359, 1362922244, 3445269063,\n            3850397629, 3630608237, 999211182, 4270325568, 2222213569, 1671798056, 898355980,\n            1426188949, 3343654679, 2919951295, 3693477162, 3895401157, 3560721913, 1888596458,\n            181288724, 3829829389, 1579972422, 3144117276, 199801876, 4054633683, 525925388,\n            3648577609, 286807073, 4061577217, 3752567147, 1201522573, 3610440980, 3336089737,\n            4143647920, 1346119142, 356944187, 3589071297, 331350548, 443179702, 4287676723,\n            3902224692, 670781524, 1151314689, 2224154332, 2643145761, 2418685337, 2754610868,\n            1367435799, 989379597, 3280309063, 664367389, 3695457682, 2932182363, 1637715984,\n            3078239282, 3890423242, 694186670, 1022735416, 3766855053, 96343600, 2950575721,\n            3694574064, 2063490620, 628896960, 3009419511, 650278649, 217113522, 4054867950,\n            4085775949, 2253647601, 1323118326, 2776229090, 387312318, 3830031367, 2855934165,\n            1727237588, 3168211450, 985024091, 4065976202, 4100263284, 920460504, 1019722484,\n            736802555, 1091160058, 3986567293, 3909716414, 2117717711, 1378801332, 3582605439,\n            3974837927, 1975607076, 341568791, 772919682, 1404531926, 2319942259, 2541979115,\n            1537431363, 3469010753, 2351635824, 2574168815, 471490424, 429652049, 1888748017,\n            256119513, 2622167989, 3890927619, 734423772, 2108123100, 2720692858, 3149485041,\n            3738523581, 2699573275, 2549388345, 2521302893, 2530474986, 3520669288, 417822002,\n            3240327386, 1661401307, 882983082, 1924087083, 4263722671, 154785737, 2892272366,\n            2096794030, 3065733707, 1274676481, 3173744694, 3170057336, 2560528531, 1992114189,\n            763608132, 886242142, 2381935549, 2696870385, 1183400652, 632435857, 1114549236,\n            792694237, 1050118375, 3043570987, 408243821, 3246069230, 3595014201, 4242308859,\n            2732256078, 417888811, 157189594, 1578645677, 979394949, 2715618148, 2084946492,\n            2779545872, 2746594737, 3600471957, 3690418809, 80909094, 479165038, 1299019782,\n            4248583974, 2122215085, 4100895072, 1510073775, 4108853940, 21876970, 3804082593,\n            1194473031, 1013294843, 797533856, 3555511188, 712992910, 3147433210, 230132027,\n            1173487980, 4269226972, 3090952473, 1190923232, 1679528279, 769279893, 1422455341,\n            1485744354, 391718383, 376237997, 2772702841, 3412931239, 3901610169, 2108304638,\n            2830169940, 3849960095, 3043501233, 3973846143, 1627749584, 2509012508, 2993028673,\n            3443779088, 2629553481, 3345770078, 417661904, 299926134, 4221411771, 4277090614,\n            1911866219, 1551326585, 93131922, 2142950833, 998841580, 2131273819, 264704024,\n            72761473, 311706753, 2773201027, 1819604430, 1325781384, 1828296785, 475315722,\n            2752215033, 140320306, 1043096704, 855365740, 2476726857, 2581734598, 3861106067,\n            1436208963, 3415450549, 3570329317, 2687213974, 2613842059, 516462296, 3037378709,\n            3263570551, 1681420526, 3415302057, 3511450549, 3273504333, 494102854, 304288318,\n            3697281980, 1996479758, 1635215124, 47632440, 22355542, 906188237, 4149186094,\n            3151082744, 2531819048, 1644757840, 3101983578, 2011269244, 3866138172, 2127822384,\n            1903103074, 3932219954, 1821169710, 169278046, 653152755, 1929628869, 1986843845,\n            1656941273, 1820043656, 2237572096, 3650186585, 3171963679, 4233697440, 3755777109,\n            3448968195, 133782836, 4267699280, 2851793115, 617641793, 3256436523, 1407468314,\n            4096930119, 1868261036, 2551660459, 17209088, 1655418735, 499829078, 3115810383,\n            2942436423, 1117668901, 4054638152, 3401715738, 386251371, 1788551278, 541357881,\n            4092916714, 2788358548, 400852308, 2632328808, 3366533041, 901146853, 3250917102,\n            1993332902, 1740749354, 3817981431, 2227569979, 4241229228, 65274376, 1935767139,\n            3249336235, 3922555776, 921336913, 2814396307, 2667550257, 2055331186, 30339902,\n            845791404, 3302805554, 2378743215, 3928499493, 2035920961, 4033017204, 3562284680,\n            2948673159, 1367405928, 2477125781, 724878315, 618610843, 3464131396, 4106290593,\n            2761582218, 1911670733, 2255224976, 679995901, 1694101202, 1457350452, 2415077238,\n            3832605769, 1548512392, 3910956093, 2960448392, 235679115, 1336039703, 4056841792,\n            2704719451, 1221241812, 1530676776, 758875004, 3989933820, 2315326962, 1755061483,\n            984103973, 3552706434, 4146283304, 1900596987, 3224925366, 4289171038, 980557750,\n            2062175350, 3065172916, 108844606, 293646367, 3415841496, 152825526, 2072381275,\n            4285030108, 2847377365, 1313245709, 1976515833, 484145483, 2307919762, 1902482190,\n            1346944178, 353282945, 4113734314, 1863262682, 1245717043, 2241864885, 2280528335,\n            1019309397, 3289776976, 2376807409, 2952610417, 103415167, 3638228557, 3235194883,\n            3241161224, 2125883305, 1232190514, 3549022975, 149807933, 2961278754, 2383239375,\n            127409706, 223990857, 1600263562, 3325399391, 2741861086, 244824352, 85948473,\n            3124738586, 3484658404, 2949005416, 3110472205, 1541858124, 3817776205, 69164118,\n            2954933199, 2925668013, 162217966, 547673095, 4181924147, 3823145053, 80676848,\n            868737602, 2205414045, 2279798936, 102486197, 2587491480, 2241109714, 3451004219,\n            1101855332, 1254174284, 4162654397, 2075550533, 3279994730, 511501950, 1774750940,\n            2330903266, 2010908807, 1405100744, 2399290465, 2186798761, 859965651, 680542282,\n            2464087287, 1717488673, 1106965230, 132594854, 1192599975, 2168482389, 2337484280,\n            1431281627, 2161439863, 731837641, 753400083, 718352079, 2920193564, 4014452495,\n            2840575861, 850092154, 4013385863, 2889779981, 1887731992, 877392739, 3501145229,\n            1077314268, 1838346422, 1325751328, 2289785549, 1040644978, 3430927961, 2641937927,\n            2285310825, 2723705356, 3969476694, 193167645, 2688798767, 1812500605, 693030278,\n            3173921056, 2188596291, 2180502082, 2208231604, 1512410467, 2765076968, 3989339249,\n            2744873321, 422780839, 2753112367, 861241423, 905851909, 1219406342, 3083085811,\n            2111384879, 2487677895, 362839625, 2300647559, 2252314956, 38471328, 3558718806,\n            1713409176, 708493886, 2645700082, 2196532746, 1397262287, 612919750, 1411685900,\n            1134021085, 3675861851, 2168510458, 173154823, 2489748386, 2499456938, 2828871069,\n            3373056478, 2660114090, 2270829594, 3459032228, 1357929287, 1162183927, 1097818577,\n            1542913661, 1981968930, 2944755083, 579671294, 147480949, 1988196545, 777407838,\n            2354930885, 2534601251, 2766511651, 68413970, 3533296816, 2575956638, 1355214150,\n            2719147503, 850624539, 3284264812, 3928845488, 594971150, 549980540, 1796991397,\n            776876250, 1460934050, 2463458608, 1640602524, 2160282188, 381030894, 2276755467,\n            3897004968, 1525634949, 2084303318, 4038502302, 650730684, 3893039590, 2120711163,\n            1075785968, 642329759, 4286493776, 298483904, 576520111, 670640982, 501843005,\n            2317149359, 1723210307, 2714699821, 2647759513, 3372861558, 3302356979, 1135050697,\n            1794914040, 2501115240, 1473307986, 4055431991, 386019549, 1642338927, 817175303,\n            63704969, 1918346370, 1060455488, 3296205488, 2611534290, 319202585, 3589598600,\n            1061424333, 256294593, 2086764847, 1889683341, 324402820, 4230133797, 971777609,\n            2913835299, 567526498, 3967034861, 2199121094, 2595932876, 3882641499, 3024547071,\n            2251608750, 1562313747, 3646762714,\n        ],\n        vec![10; 1840],\n        &[\n            925805970, 771512525, 1321505884, 4093572597, 758716614, 1377765832, 1278203380,\n            1001888643, 1355158095, 201085215, 4149044771, 2521855414, 4152533261, 3002132831,\n            4155360674, 1795934109, 2247306354, 2834452223, 3656644513, 2792060749, 3230919138,\n            483669446, 3693350164, 2766501057, 329182922, 2273808186, 1047344319, 3115798204,\n            3566682772, 2408293239, 2794877731, 698720575, 327005792, 1558338384, 1008199867,\n            2492809980, 2810143023, 1784882162, 524641759, 928770560, 1130801733, 4222233720,\n            195758472, 1891783101, 413324813, 3563105984, 4225585084, 205810396, 2545279346,\n            3861389278, 2373143813, 4024119708, 780120208, 3432178227, 1555529931, 2554973234,\n            2502444226, 3344683717, 1641184112, 98587931, 637912572, 1021943377, 4037505911,\n            614639139, 4194497843, 3049554202, 637648248, 2123348064, 2634366226, 3207837322,\n            3066784253, 2994933327, 1976651548, 2366296173, 1641868749, 82351438, 3355135280,\n            1553860281, 1605364581, 4075743977, 2941712013, 3386363575, 161305709, 3498025167,\n            3591439792, 3723487074, 1286356811, 2869673859, 3058493670, 1421607538, 550853035,\n            912260189, 555605432, 2564864712, 2716459709, 3225217761, 1778511468, 3587420558,\n            1207869481, 2862990086, 4126739672, 3193798621, 3165324498, 76671852, 3202055203,\n            3698858085, 2586219907, 2247010126, 3962725977, 2619019864, 2122584571, 2759072926,\n            2355594856, 2680875986, 3809288380, 3113157553, 2998504932, 1438335802, 4042229352,\n            3236956253, 415640042, 2304719113, 476088551, 1007695371, 2386089176, 2181311976,\n            736590680, 89015838, 391491629, 638291307, 2877449105, 2962906061, 3979685552,\n            3627063001, 492677310, 2231326821, 743398531, 1133825751, 1719921083, 1840883029,\n            1166898759, 1601037521, 2409186612, 1623857150, 2793429784, 1436913897, 4140973832,\n            582129472, 4207088238, 3200623818, 1475586379, 3384915939, 743709146, 2191495369,\n            3563177671, 728383298, 3754965841, 3795767466, 4009441303, 406982577, 3135143383,\n            1456106797, 4160967347, 2816553701, 3256668188, 1014590891, 728446496, 2331482373,\n            2184086986, 2476758117, 815465765, 1957139615, 93446988, 3589331411, 3457536764,\n            1745564725, 244069742, 3319690805, 819795556, 1486648551, 402515678, 1904027145,\n            2183046265, 1437045043, 3646826056, 3694590855, 3691191903, 912588953, 2869059243,\n            915090531, 1308341773, 1914740545, 1372995357, 1821589353, 1750436980, 3326691416,\n            1030623833, 1495253922, 34912358, 1499274973, 998994535, 2935614243, 1565643646,\n            3474712008, 2524137404, 3968547971, 732339375, 3134376500, 3712532227, 1085750881,\n            2607575268, 1414329062, 583507621, 2489115057, 1425727804, 624607973, 3077024829,\n            2685992057, 3682897129, 4071136447, 1727489833, 21203108, 3392758652, 509383349,\n            3119006823, 3045101600, 4129122439, 976347783, 750957340, 3621119842, 119059944,\n            3926834627, 3278710060, 3524620828, 2053225005, 1628028369, 1741363163, 4055830757,\n            877491867, 1503296989, 3349399277, 348921314, 2220238102, 2327127101, 371334052,\n            3730431190, 4254998900, 3276010967, 884857325, 2799001549, 551761767, 3358096790,\n            2020737989, 2913273611, 795353920, 995285043, 1255353878, 1081464851, 1485661898,\n            248227391, 2646461730, 288845121, 990971374, 4151523546, 850493727, 427991127,\n            2225569843, 1598181146, 924478291, 1006667974, 1424598842, 2544076586, 3839052630,\n            2039302967, 1751844817, 4119169517, 1378503947, 2112648581, 486800876, 1589075140,\n            1774624325, 3380949714, 942159303, 1934386105, 1853027873, 1625283567, 1798870407,\n            945414724, 1916704482, 1076254981, 3546161383, 2299585539, 3247652613, 731481822,\n            1011891129, 2768863308, 1813803045, 3860051875, 1174964707, 1324160940, 2574847612,\n            3513978083, 2554787041, 68699746, 1212730198, 996237523, 2736940550, 508920579,\n            174371335, 1886271926, 3087461373, 2201998413, 385737266, 2695461851, 3309543132,\n            1687035998, 692717227, 569529002, 642730495, 1998450569, 2877673596, 782260981,\n            714386348, 3796153446, 3810357608, 1220822655, 37559611, 3062930083, 1952046909,\n            2938302747, 1937200848, 139230150, 3652241605, 3385303728, 3427356966, 2415007129,\n            2062827063, 3399013574, 1412210998, 3780689301, 3309010376, 2776522750, 788159042,\n            2338674637, 3597251270, 1111645430, 2344936207, 987533024, 312063196, 2164245832,\n            2981634349, 4146252745, 509985595, 473738885, 4080179792, 767682002, 742937862,\n            3390341429, 1201520568, 2705803790, 1096534023, 396035895, 3045556830, 262555759,\n            2223158076, 2460071430, 537129776, 2525318176, 2465664490, 1718928604, 1677204238,\n            3488426978, 3891524565, 2842016557, 2193145485, 978116097, 1615400737, 2757085537,\n            2962918904, 2163577224, 4068394581, 3963381668, 3027498111, 413627370, 3985257787,\n            1911780465, 1431948560, 899666734, 3073534561, 3931614071, 59372171, 123789420,\n            1311815775, 1600081512, 3500852529, 482022179, 1349872136, 2023099554, 1623971264,\n            2385783366, 335038849, 4237603646, 1512003698, 1626113404, 3863467432, 503775132,\n            185919438, 3413070813, 769549664, 277742984, 1457016660, 3916310980, 3679543908,\n            428500520, 291415144, 382143301, 3479675016, 1558773305, 3828015203, 740311290,\n            1658202239, 1352230160, 2929801762, 1144182359, 4260518531, 3904249580, 38453053,\n            519928994, 611178254, 1815173805, 2687791381, 3576348672, 2210369382, 3101623249,\n            98144578, 4159402306, 2478115488, 3668828837, 1846949400, 4015333955, 1478301555,\n            2864273669, 2676396505, 2824169479, 2008756433, 871452488, 197076407, 493093639,\n            3590505476, 3419603591, 1983646327, 4172389974, 1331126951, 2749313151, 3914363144,\n            838421991, 3713866955, 66943799, 3022889908, 905930887, 3450837393, 3122388323,\n            3601001575, 1461966185, 1217535252, 862426054, 3891322611, 4057584483, 4137459924,\n            3050986698, 3775562735, 2206917997, 1326425299, 2177316293, 665366502, 1789591450,\n            3869393426, 4111791353, 2042667844, 3888104816, 477695341, 1400818483, 391421351,\n            2511869577, 1543099376, 522205537, 3741717060, 3983781829, 1450661430, 1952049614,\n            4059193972, 69169697, 3733732140, 2178094107, 3638192198, 2483181869, 4237963289,\n            2635888235, 625414314, 2309845963, 3133618224, 1030061929, 2628713359, 147776022,\n            3665551893, 2606716720, 450703348, 1433078851, 665870068, 4274367632, 2346780289,\n            34636636, 3570617418, 2610375041, 1570695957, 3235022132, 650696914, 1579637045,\n            3924586750, 4122461112, 3973884299, 3203913749, 1074902525, 2038914363, 1313155224,\n            280192559, 2654627254, 3904119153, 4289367389, 3931774924, 4088574946, 2110508780,\n            1965188425, 3870415513, 3028849533, 2643890058, 3118914716, 4132754639, 2063814685,\n            2477010069, 742144369, 3675862178, 1638220213, 1788413389, 3612081483, 2827592335,\n            4269582882, 3849921609, 1214642500, 3132507662, 460322913, 3555344490, 2582789072,\n            2773409763, 3731720324, 725828860, 4142291526, 1289918833, 2376436341, 2080195956,\n            3652068261, 2052975451, 1056381829, 1504404622, 3530088199, 2543774820, 3588528773,\n            1181550632, 4134199347, 3106435739, 2666774217, 3422590531, 3887880807, 4070997105,\n            1394848137, 701703628, 3061521160, 2887272490, 2229516066, 1310837786, 3154190631,\n            711892595, 2435668654, 4100746898, 366709793, 2800825180, 3469579669, 1872527030,\n            558351001, 1574511606, 3461209655, 1498408413, 1726832352, 1807209931, 1051547963,\n            2514355744, 3694086296, 3693097900, 169040251, 1625096327, 247216005, 1690358091,\n            1853931622, 2241580553, 2665852926, 378855913, 2849826467, 2882598381, 1966643823,\n            3863600372, 570512458, 89553660, 1580933547, 1670795700, 1701383225, 239477568,\n            663996049, 1663598319, 1774418754, 2745157344, 3324324155, 3068121254, 2019212774,\n            3363185868, 1017744423, 1422898847, 3076406441, 3863671242, 2045305657, 2537743046,\n            3610837965, 956029186, 1782391421, 1492413923, 3211086299, 165767576, 2846934457,\n            3007723858, 1141836320, 728275693, 376616587, 2573940874, 2162417375, 2260336910,\n            503501143, 165113603, 3530206110, 2914422259, 1430643811, 769845616, 4213816224,\n            3629319288, 4239130817, 2081610750, 625758813, 3255558354, 3479654242, 2472621110,\n            3007522636, 2750717810, 3286123194, 731654699, 2774722656, 3054704647, 3343723513,\n            3353349653, 3916558188, 4002272233, 2120337200, 413996446, 2630363679, 2841712842,\n            2347010620, 1903664219, 2118706367, 4121870331, 4262431689, 3571095308, 4041525390,\n            3390066445, 927914151, 2343554013, 1134637778, 3558586975, 18737389, 2499628916,\n            1647908776, 3587615205, 1651636386, 3701620970, 3344465418, 406209565, 1774097768,\n            638612711, 1894889044, 975120431, 1901267275, 3825095883, 3013288190, 1213152309,\n            4081208841, 2283263447, 3257861369, 566807683, 766774226, 3630232255, 2719893472,\n            2539687707, 3216385587, 2660398423, 654074066, 1010432189, 3431364371, 4163956052,\n            3832935048, 156489928, 4188655690, 1306690249, 98975214, 2421098560, 4163230789,\n            4156164818, 4443391, 617931997, 4154608614, 100420976, 2222597381, 2417575506,\n            2990762034, 204752919, 3415006628, 3522988641, 835715926, 156827736, 2308716058,\n            1572542144, 184997832, 157493958, 940407358, 3759427593, 2158763575, 1564687549,\n            3909269978, 1283986657, 2367598132, 1568363717, 1710227345, 2793907548, 2427230705,\n            2893825635, 3768618922, 4124795081, 810037070, 4125345353, 3607694888, 770621562,\n            632370000, 674117742, 765128043, 1173992895, 3674396824, 2526304384, 3829190715,\n            775137268, 3029466301, 2820944962, 3085195001, 2621306925, 2125299873, 2214882737,\n            513034349, 908126002, 3167919913, 1027217000, 1178561950, 511143524, 985493719,\n            1655744880, 2033154762, 1280998575, 3453548532, 1570014775, 2222753891, 3327333588,\n            2154641854, 1735888068, 1817079241, 2722314559, 1762274850, 1167853659, 2392945518,\n            196410344, 2937981909, 1154226053, 4232721914, 700255979, 2415771290, 1791869427,\n            2898400848, 792514249, 3599536910, 3227896255, 1529237487, 2400490460, 1826096927,\n            3142666937, 2785566731, 2723268878, 2079318688, 4034165354, 958450787, 1749435564,\n            3977035150, 3576602733, 729666328, 72221437, 1176330488, 3920869422, 3994801636,\n            2732985628, 1490190123, 1354581325, 568851886, 2669564985, 1060093818, 3170119834,\n            3226579436, 764079092, 1913198946, 1083783781, 3261947326, 380306393, 4209390001,\n            2158391567, 1689298052, 1046236714, 442820313, 2757723527, 3143120919, 4267903837,\n            3015944922, 1574598807, 2206549514, 4259852673, 442217304, 1830366479, 813570743,\n            365463383, 3543466921, 3138253410, 2683541076, 638143597, 995642363, 2769878603,\n            4107223702, 3481953453, 3133262725, 3674261732, 1033288545, 3669732737, 3503245892,\n            1530461030, 213751298, 1629050977, 375601856, 3395574573, 1885945502, 1714265586,\n            97662695, 2156915149, 148240149, 2725333961, 1842005317, 2670201827, 3018625279,\n            2036280580, 2241502128, 2888719467, 472203886, 1658540185, 3258448659, 2760284408,\n            3494196803, 3420499172, 2950901152, 4276940915, 2202303771, 1096785836, 1693282825,\n            1017323714, 954195871, 659807759, 2833714030, 2600259137, 2719988621, 1351376955,\n            889846153, 1588673264, 1457310902, 3149228705, 1509379998, 904691368, 3109598917,\n            2820147688, 2098775601, 556249763, 2898076541, 1003774548, 3470807399, 552610489,\n            3623150789, 2629316482, 1385503428, 3451073512, 997009862, 3235185265, 2184096609,\n            3290579922, 171379862, 3550817154,\n        ],\n    );\n    // - n >= MUL_TOOM8H_THRESHOLD * 10 / 9\n    test(\n        vec![\n            3325828688, 2222275271, 2251341024, 536425450, 4031282462, 1974932579, 2802802687,\n            2494652102, 4097509118, 3929993760, 2523272424, 3991617974, 1383705144, 964369450,\n            4021179190, 2350994587, 3952940920, 2309645523, 4239355231, 2251911575, 101330509,\n            33531098, 3923438820, 3326248612, 3928986797, 3712073953, 656648130, 3992081850,\n            2462208525, 1232308887, 3597612252, 355901660, 210877106, 2675099515, 3078639028,\n            3753546437, 2179616483, 3320544043, 4275906121, 925959266, 3421489454, 4036352291,\n            3528964180, 1961636686, 4029362615, 4282725968, 1508419584, 454322447, 1001429999,\n            2787320225, 2760755036, 1794472322, 532278069, 1568975823, 813350455, 1179027655,\n            3449886418, 2662435721, 327795406, 75354904, 1665124401, 3382081813, 3780617120,\n            608468859, 363983678, 3351287669, 172973237, 4290451185, 1931365909, 1235521618,\n            2978614510, 2419031024, 1057701246, 1493733706, 2567636367, 1775786991, 977238213,\n            375184150, 2098442552, 3863490194, 20320547, 2460513991, 3622662467, 3550564454,\n            866710499, 1402820025, 2079884728, 3083812684, 200095309, 3509895595, 2058450016,\n            802356608, 3193234061, 2967885003, 3592035474, 2888252198, 1738389872, 2122697745,\n            2521126706, 3044563659, 4010640449, 1357672322, 1713997889, 2361412719, 1177264933,\n            1279061404, 4226778687, 2234083457, 1990126293, 3249778747, 2856364385, 2539332735,\n            819602532, 1941236090, 148789327, 489490234, 3063005023, 3823539446, 2078730493,\n            2897346932, 377341414, 3559412328, 2789507932, 2744784480, 2083318692, 473338846,\n            1592405981, 3262908934, 3803857538, 2113012145, 4218812261, 2611838077, 2967681456,\n            394117396, 891428411, 94508804, 2461818431, 2882613800, 408794286, 1367921120,\n            3936232028, 3371928555, 13284201, 2693865930, 1445840494, 62166267, 1950431070,\n            903939097, 3181498906, 2135209486, 2379836866, 3164065611, 3089382166, 335815175,\n            4115282369, 2843606362, 3030658374, 1981636253, 1913879380, 2497243978, 1058325216,\n            1962967322, 2964668797, 316843966, 787872107, 3686059070, 3432414174, 2952226003,\n            3159358517, 3532762764, 1103507717, 3261418139, 2938324789, 1645903335, 2648573661,\n            4131792913, 2593029209, 466073693, 1785143940, 671647647, 3138504192, 2192173137,\n            2335379487, 2298646507, 686675623, 3214302238, 950130948, 2421785284, 41585098,\n            3553768120, 3417442608, 3058443407, 4154557833, 1412178160, 341659142, 1776579622,\n            1881568208, 3733601960, 964911720, 3954636144, 2069281179, 3720759380, 3881878556,\n            3401603350, 2025509639, 3992322872, 3417427856, 2078371992, 3655861835, 249491133,\n            897420882, 1663580203, 4250858290, 3783171030, 1618859415, 3059683957, 757177328,\n            2284779051, 1397702306, 1846926211, 1628089495, 1310971676, 638095836, 1920389982,\n            1228576446, 672122730, 1853316843, 991512951, 777308841, 184904686, 1065934342,\n            904702614, 2120865508, 3991071908, 3089750336, 2087140090, 2698642164, 2746911990,\n            463823593, 2169525572, 3914335068, 3895138434, 1167324714, 1405364247, 408435330,\n            1048149429, 1549143044, 4160291749, 2958661271, 135472469, 1664575385, 2395824355,\n            2799959090, 2058237486, 1885870506, 1018852433, 2464874288, 1472031882, 1920049008,\n            2124900114, 1894970634, 718935470, 4135614331, 2870932762, 3046996347, 1175241218,\n            3337056067, 2823776676, 3880099332, 317500197, 2412894185, 2360582270, 1748097135,\n            1117101645, 3999621027, 2508769432, 1134413571, 297583666, 315312277, 445840313,\n            835956286, 652883235, 3449607625, 3112977447, 3858652947, 242783714, 3248680155,\n            3743017765, 3771708806, 2121953660, 169624798, 3334753694, 1024518980, 2123582216,\n            3512992458, 181383076, 388250535, 2264863429, 559757274, 136676916, 3010225408,\n            3261874572, 3254590586, 2353758191, 1769226054, 2574994323, 1412248375, 2194959705,\n            3161480726, 1173862339, 3060136500, 2067215193, 1559995937, 4097665144, 2227105594,\n            57455397, 2781855816, 413139676, 1262905949, 3710184455, 4204785080, 3841061262,\n            2600467865, 756074612, 1833352799, 414287525, 2487131325, 225976232, 2868255206,\n            3149420271, 2893863898, 2674087497, 4201275735, 3557697552, 2539732703, 2075871670,\n            3238490486, 3281311242, 4105032293, 1061668000, 3948441870, 2632408910, 3965993308,\n            2773976056, 3997099675, 1044008934, 643256924, 3662238906, 2364413528, 1890816109,\n            653190236, 1449201495, 830290176, 1608991933, 1977703847, 3177041981, 41644776,\n            1806748422, 46749183, 1969966265, 650370247, 2860464309, 2000093407, 678041782,\n            3053985966, 4126712541, 4206913677, 1804281861, 2562943781, 402107792, 3743850770,\n            1880600543, 2284692048, 3402413270, 1372820757, 410822514, 365444773, 1581271018,\n            1311294256, 2098281541, 3795689061, 2741077395, 1671858646, 779953232, 1441988536,\n            4122756260, 3219142143, 2003131209, 3186044612, 3862216190, 2906214392, 2843498419,\n            1258517655, 2377662254, 3165185832, 3743620644, 3149688047, 1175443948, 1119755292,\n            2586039430, 3583379409, 100277700, 2686178939, 3718199786, 144906097, 893565260,\n            2837950407, 3324016696, 682674679, 31411133, 1272850441, 784780622, 3423224341,\n            488352871, 4077116759, 26700931, 3657423384, 143033774, 3228467568, 32720232,\n            2721507038, 1816011700, 2818467222, 1533431835, 1268665537, 475079949, 3341112122,\n            2698588771, 2611521940, 1972051120, 3510532417, 1731958257, 1183168565, 2931876429,\n            434380301, 1295823, 1351376380, 3803168520, 92207634, 3345836213, 549845616,\n            3480463245, 2630703140, 4194446958, 1396974448, 2365711823, 784004900, 3467957992,\n            3284726834, 1131138204, 4158973228, 2854147296, 594452704, 1221140243, 3732311917,\n            4211451998, 4201866268, 538219794, 228992404, 463147167, 697753586, 3806158550,\n            1256983333, 3561565763, 456221521, 2524923884, 2331508852, 3915487198, 2219329827,\n            1899461941, 1568614606, 3436289344, 4105213304, 2685855293, 1185390866, 2047983481,\n            1781737500, 832012199, 3513225593, 3319838870, 1020767641, 198457781, 2727609160,\n            3813889481, 1016920097, 666935018, 2505214320, 3346073559, 2415444335, 488746607,\n            2468423301, 1532367906, 244477084, 2784080007, 3392011412, 3296350838, 3408789716,\n            2601539997, 65837806, 3808173608, 2740909858, 313044653, 976945537, 695283633,\n            3903895508, 1256467142, 1796137849, 2299402928, 1030847133, 491304484, 1618179568,\n            3575375798, 4084273125, 842560443, 860483107, 1477578512, 463362438, 4047759459,\n            4170469452, 837933293, 1510207028, 1002537167, 1913407491, 484611587, 72194857,\n            3758699609, 1038836152, 3702790723, 1602454353, 3156992372, 555460491, 3102910892,\n            4107831420, 1379557424, 109354775, 324500806, 1309470828, 973263813, 2913644320,\n            2556229913, 20916645, 3990007622, 1827025683, 894739570, 286790026, 257745524,\n            2888654551, 2829856014, 4024894743, 2592875773, 3482365150, 2197208367, 2008450133,\n            1021127724, 252619891, 2171006932, 907971982, 3664509602, 1585606268, 3112067844,\n            1006461549, 3762990233, 801101738, 2502145896, 1780081016, 2853239568, 366864228,\n            2569203482, 376803343, 6955716, 2316603781, 1631421558, 3996270452, 2436912056,\n            479717229, 2577014660, 3814374282, 2295304310, 2205472042, 1941857703, 3835035113,\n            1672360810, 1473045908, 1338619978, 3516219559, 3903963113, 1518163632, 75200618,\n            1452199469, 1006778265, 2872308953, 2526575667, 3217010709, 2082180265, 3503205635,\n            1689527017, 1366271253, 2419427984, 3090351720, 758562413, 2893201179, 433319737,\n            289828739, 2697292032, 3319507333, 376413377, 1856268054, 1102691038, 406692403,\n            4199659161, 1030925701, 2852188477, 2282715864, 1222230217, 3204793449, 906571587,\n            4246852852, 2109467439, 2758293720, 2590683410, 426954830, 923580140, 1720968355,\n            2177884542, 2700069460, 3414003144, 882029796, 673015972, 925314297, 394315706,\n            2405566770, 1356681458, 3704192657, 2420160690, 105120919, 4135620617, 1146779249,\n            4215347588, 3808058087, 848912652, 3166226285, 2673900140, 2633829134, 4227829168,\n            2976863082, 2756181703, 3969932852, 2310706349, 2623195640, 2975200819, 2683387458,\n            3670713004, 2711197327, 1005309237, 2656065409, 3585314671, 1067912540, 3244103997,\n            1167067071, 1147905270, 3508458421, 4173233272, 3528308485, 2229102062, 438675126,\n            482013728, 933288742, 772078253, 1545301066, 2048214401, 313457524, 1830857166,\n            4210633504, 4033732262, 1784314122, 1876717626, 2898790181, 1714304237, 1513498365,\n            466291039, 2125921729, 1375952994, 1759597111, 3485421103, 988486613, 447644730,\n            2659753292, 800671165, 2297304303, 983566542, 706647696, 2025875912, 750248929,\n            3818471532, 1823442438, 797944894, 113229111, 881004126, 3388066422, 3504793499,\n            2531563354, 776681039, 1855992120, 3089939582, 3975063378, 2197425240, 1859908221,\n            1050864539, 3696699978, 2797794284, 67143977, 1476449198, 425254009, 258997293,\n            1600017642, 3718913920, 2057245496, 376988171, 3765611739, 1761878897, 851389543,\n            2221681000, 173564387, 543006829, 4033266201, 3495318826, 4944235, 77704986,\n            2003516763, 2947938566, 246616380, 3811434913, 1498883939, 2662747924, 3098460145,\n            2789081063, 2011354011, 3559521162, 2222938111, 3518312618, 2907191527, 510822818,\n            236641464, 2906121970, 2726617494, 1403621963, 2506337633, 1393649778, 749094150,\n            2141211894, 2997803954, 3536825181, 125817965, 2928546113, 3962138194, 3488998295,\n            2977774519, 870261554, 3145088767, 33204035, 417892208, 82457330, 3761918526,\n            3185089606, 3717474816, 3759935038, 718221041, 2584890356, 3125768610, 3128296046,\n            3921989069, 628371462, 2854153931, 2322749823, 3560748642, 3598001904, 1525423357,\n            3489200883, 557488134, 67075987, 215443365, 3960989574, 3610937359, 1994915328,\n            1322852160, 3224593059, 681359565, 1428522926, 1509511379, 2910418227, 2950733843,\n            2264582595, 1066502645, 1270894973, 1982059326, 3466419533, 1247820141, 2814957983,\n            3674243179, 359593364, 2852856092, 4250958308, 4209800488, 3182992525, 744053024,\n            954527614, 1920812186, 3420696600, 3538429076, 1174859849, 1575837064, 2476180617,\n            23409444, 2303547985, 3866558298, 3511588040, 2073420498, 2694981488, 3634968032,\n            3148001223, 373812485, 3760234630, 1989707843, 553246242, 2798142055, 402011062,\n            2572428035, 3149472471, 2641777212, 2341709250, 659173885, 2636588362, 465418139,\n            2855449653, 168901226, 3411187454, 3648538254, 1914534945, 2021809126, 1765630658,\n            4210072200, 672743231, 237435144, 1466943252, 3665058313, 1360883147, 1208845855,\n            4000190916, 3503509301, 1932609745, 2525291982, 3149954146, 2863621568, 4103714853,\n            376631824, 2290852702, 2496109340, 1639920015, 3769422630, 1510557202, 3513608516,\n            2550439168, 3553460045, 525038818, 4129480327, 1125484353, 2835875384, 4179933318,\n            2509396027, 1732889211, 2751886266, 2147307212, 387970481, 695149207, 2541343790,\n            2839783121, 1160657192, 3963440385, 2789882800, 2391592284, 2916503838, 3282735897,\n            913624563, 3175831231, 3466284576, 46459397, 3590165825, 1395008049, 54895546,\n            4114843666, 75582093, 1715376849, 2361175117, 2492505326, 473253401, 3209625236,\n            1910683327, 2303707709, 1595992099, 1067727453, 2175266120, 1187538095, 3338022275,\n            3861034887, 3646604070, 3901278763, 1297481444, 1740087966, 1713911231, 3579924993,\n            438772896, 2847030160, 1091694853, 1462997245, 223788055, 378112136, 3379831769,\n            1612071297, 1026371651, 3588586410, 3550643691, 3517421864, 108677329, 1708329683,\n            2705550295, 536532842, 1609412940, 2350366954, 3999999603, 3009090634, 3009405637,\n            108513089, 433572330, 630309072, 768308286, 3130148610, 696549190, 567069842,\n            2991858807, 3544523483, 3196876723, 392972829, 3810464826, 712888215, 4116891580,\n            2898306195, 3552494747, 2628398237, 4210499108, 103633346, 2236449210, 3834327177,\n            3420048764, 1756265114, 15054403, 4040225317, 1594762873, 3042414357, 2480439624,\n            4223576462, 2518287349, 1400158860, 3257170441, 1299629753, 592407606, 183091721,\n            3221878045, 312797076, 3985484678, 3630279986, 18819047, 441536758, 2381837163,\n            4169471868, 2170394338, 2181312095, 2448805236, 3378100655, 2844803458, 1168647372,\n            383072198, 1590554568, 2280721135, 4116487539, 3850200505, 289261506, 3357742687,\n            1915184525, 2779238680, 1251240337, 4273338571, 2883259275, 233548562, 4271818632,\n            733727140, 228666724, 2488848008, 2996503489, 1445047215, 43172552, 3015066792,\n            4234864747, 2683528981, 2327797015, 142567097, 1677432447, 2182227962, 3561493714,\n            616143851, 1146197188, 4043856658, 1532480004, 3914042242, 384129295, 1027270960,\n            3759841559, 3306756270, 280945974, 2272666526, 1787905496, 1356479606, 1003577488,\n            3182186379, 2080620780, 489613844, 2145748221, 3602256409, 4039936254, 4230034790,\n            1041216417, 2869721346, 1061058447, 4187665645, 2056653701, 293593624, 1671090495,\n            3743958178, 221756712, 669423751, 873593705, 1984521258, 596253067, 1854401523,\n            3641730818, 1795122963, 3434366685, 144714542, 612800121, 625529195, 2115632120,\n            2458286503, 2991075249, 4294925998, 3484272210, 413395376, 2841974813, 2198382581,\n            153452909, 2362633408, 1029933732, 365559147, 954593410, 2340863943, 4224478519,\n            1711517777, 2382640557, 1471136977, 1243256182, 577943866, 2877182972, 3120699107,\n            2099481569, 4027415860, 972360440, 328292954, 2580374611, 1126114830, 2447790959,\n            3167058778, 52949279, 1503347494, 3102470619, 2850741785, 1440074775, 2983184898,\n            2958779770, 1423341775, 2638966039, 3414709326, 1746843145, 1962096213, 1231942872,\n            322282459, 2520802915, 1397156397, 1136524931, 1077984387, 1082573606, 1369475996,\n            1343216443, 2853222460, 459314534, 2082494332, 1868894956, 2863227388, 1267699732,\n            3838811811, 2085654049, 3478261558, 801390064, 3020980804, 1592039288, 2043252793,\n            658119035, 351482607, 365151551, 2321964000, 3105703149, 2651451296, 1332089903,\n            203189386, 4065665344, 2087988078, 3509982235, 3663789691, 640321038, 126379371,\n            758704611, 2976133119, 338240358, 2847694981, 3405531815, 3501389852, 365915081,\n            1893710987, 1017798137, 1329052770, 900124839, 593520276, 1673088115, 2837108009,\n            2725846942, 2370117674, 2364056627, 1588943446, 3447621374, 4188928348, 3651554937,\n            3256606153, 3302425960, 3080093332, 265589115, 4231992887, 2117604928, 2355480969,\n            1006273543, 2284486530, 4056290811, 4091031679, 4079416675, 2288531059, 786357019,\n            3958013190, 3469028967, 2618870759, 2582243721, 3134347005, 1897624527, 295895331,\n            3299510488, 287519621, 1532582663, 3409797611, 2683376466, 4283418958, 1877809103,\n            2723998791, 3144672840, 3727310197, 4009525850, 889434429, 771869475, 3566747894,\n            2738193100, 813849012, 3911388965, 1279847132, 1685856902, 3082912514, 2067299920,\n            1405185595, 2885740666, 2118178130, 2496932272, 4158468024, 2915749138, 649483477,\n            4206421293, 2757754394, 3314522431, 2269462235, 3993183136, 3700765328, 1068976941,\n            4261401847, 1124755401, 3801610743, 1969610114, 3664892243, 1112960775, 1912361842,\n            1030225346, 967360681, 3986502374, 2169456113, 3758060719, 1480705586, 492248116,\n            4222874616, 3319928478, 2992291382, 2450502117, 3949036192, 1815871387, 3254185821,\n            711097033, 3511389055, 2820383871, 3171069864,\n        ],\n        vec![\n            219605684, 3733847704, 3016635823, 3294762792, 3944405696, 1769872727, 832659846,\n            484088999, 3505517372, 665090353, 981244631, 1379204518, 2636388743, 2646535623,\n            4245306143, 194502210, 883787587, 458392293, 1851531468, 3012939792, 3916075164,\n            2268609087, 1167270783, 4176306316, 3743775706, 2950832151, 3594959653, 2285984635,\n            52893824, 2172982965, 1248959379, 1470557476, 1201448597, 3375520425, 3748208049,\n            1257559380, 837239835, 4133304044, 1858466116, 560253153, 3678427423, 455815704,\n            2048555203, 3908746885, 255785748, 3209187195, 3421604835, 2632159689, 316833694,\n            4281401440, 102090580, 3721736010, 266287611, 3373488642, 594309134, 2738851237,\n            1684934520, 1276732189, 2903617658, 3296557081, 3563767242, 2176348197, 2313418457,\n            3233080717, 2735279615, 394359834, 623713995, 140049212, 498519169, 1402029947,\n            1678680803, 3015892739, 427600690, 1125893168, 2179497262, 4057603178, 3496071310,\n            2899325724, 3677322280, 3804953038, 278886520, 645458896, 2486879584, 2394473074,\n            3850599181, 792951084, 663635668, 2927466603, 3639001969, 3606253415, 508580584,\n            396794482, 2985523809, 1445903235, 3313779349, 1676477042, 103850445, 229595348,\n            703720916, 2578553830, 2458841523, 1933251296, 363644571, 645442292, 2557064683,\n            962374614, 1700508145, 3794324048, 2584976073, 236173708, 3764420274, 279923540,\n            4075757279, 2235622749, 3191608858, 4006438835, 1908504238, 1404730391, 2893611100,\n            3418919975, 2761500606, 2538142606, 3656578307, 919774545, 1445376035, 3424913709,\n            554731787, 2870801108, 3893878559, 2515735309, 4049168009, 2736235180, 4046071341,\n            2836164363, 3926498800, 3814849323, 934280090, 89568632, 2294387373, 3912402110,\n            2118681178, 1351750387, 2447640447, 574461143, 3931298943, 1794049409, 825791603,\n            3855614361, 3804227287, 1483097620, 4259972568, 2252285343, 123276475, 3161686393,\n            3218037245, 256027861, 809544208, 2486313226, 1050383855, 4237284978, 2694106279,\n            3038308664, 3410660322, 515412998, 3869866599, 2994392437, 3269069042, 3947466847,\n            2883348919, 4052591666, 1863977555, 188271850, 4149287894, 3890111279, 397365955,\n            2163011790, 3701205263, 2638690803, 3839607326, 914036595, 4046887696, 1336652496,\n            822203045, 2784897683, 1265234986, 1784732027, 1447844299, 625275839, 82219488,\n            2987602621, 3044052434, 1181776664, 1530351091, 1110986421, 2060624013, 339066774,\n            1590502368, 2317588177, 2244585652, 3492887264, 2212680022, 2640475326, 348926579,\n            3246343174, 2561437332, 581962653, 2221706178, 4069194219, 2284871124, 3048622008,\n            373685125, 4025211847, 1292047419, 3120672305, 790731263, 274475368, 15199343,\n            1922359621, 1749773031, 4241521715, 2479848827, 743662349, 2151293746, 49164230,\n            344935070, 89801179, 142306069, 2327816182, 3527604729, 861275048, 3754133025,\n            105007617, 1606758768, 3411783480, 3900766726, 229816895, 968892827, 603676768,\n            3067574405, 508084800, 4163966682, 2520459787, 815626761, 3750642090, 4109045197,\n            4021986339, 1510247485, 3001110466, 2167226521, 3591300424, 1416732703, 910590371,\n            3408174912, 3155039041, 1139149626, 447404795, 2716484878, 4070167463, 308857448,\n            4282968848, 3099451490, 2414982180, 316232599, 642439731, 1545686574, 666961383,\n            897959935, 3374635967, 1881209465, 1374103300, 642609814, 502781940, 3682373645,\n            2489773845, 1283267440, 3894229942, 1941929986, 3934687928, 3333644753, 2997423793,\n            837943158, 67336216, 3255568419, 190224485, 2837663345, 4207768659, 1708933825,\n            2772287530, 1154500232, 1693433014, 292641434, 1754396219, 2542674547, 1190079584,\n            2269894063, 2721853439, 663916801, 2362454970, 731922427, 3742164411, 707311168,\n            3046591691, 1748326630, 1845653289, 1016681698, 2994353806, 2735719342, 2704445240,\n            2854070151, 1607062766, 3744430615, 3544224665, 1886417222, 3425058873, 1609422240,\n            542845843, 3147109760, 1424468935, 2839056308, 2918717971, 2811887991, 2790495639,\n            2132641907, 792891625, 3102872968, 1651448144, 998081822, 979132706, 720547406,\n            4025787009, 2735580435, 2457487375, 1065238981, 3412254354, 215131432, 3048596830,\n            1669254548, 2090345212, 509499351, 3615558193, 4162117786, 1536698846, 1534147203,\n            1923724108, 3528335633, 3395028864, 404544658, 4167466929, 1214045063, 3598864251,\n            1326576655, 855338193, 3368941689, 1401909859, 3124328704, 67082155, 1595352370,\n            2689198649, 770470257, 3065267028, 1211541561, 422514087, 536466990, 995741725,\n            2502422928, 137873536, 442872337, 2288928710, 477168639, 2527159632, 2500546045,\n            1397043975, 2205863722, 2911856171, 3714388841, 1549554282, 3753612677, 1890046352,\n            4039530596, 4146084646, 1706325322, 2454110812, 211090074, 3163995441, 1637968681,\n            365653242, 4282639641, 20611554, 3054560222, 1999188492, 3488521981, 2868372811,\n            2973275585, 796515146, 822994172, 1030297677, 1588520622, 4228102402, 2708306471,\n            1208006335, 2078217033, 2586553571, 303653553, 2132325166, 747687456, 1747825014,\n            2837410885, 438830471, 1600784035, 4134092721, 1506389233, 2127970290, 2668085318,\n            4089024642, 2575734777, 327185130, 2469533410, 3597704057, 462560760, 3152215881,\n            661472818, 1938255716, 356786526, 3439418576, 6826038, 4187428395, 60261767,\n            3087172989, 1450929937, 3651563872, 1589078139, 1677344341, 1470806427, 903804397,\n            441015765, 1272755045, 814260009, 2653285733, 3860945219, 1455674283, 1096658320,\n            3516576877, 3023176095, 3479966062, 3407627614, 144957111, 2468468573, 133078933,\n            860997956, 3491202246, 1622521278, 1232931671, 1342648914, 1925040885, 4195720141,\n            3799076149, 320357412, 1260627691, 1901795898, 4006861680, 2967730799, 1348760243,\n            1207763786, 3372249393, 3370014578, 2928367142, 1013740101, 3800825723, 3853764948,\n            2540691600, 4288140609, 85729198, 2054750317, 975078435, 1603168880, 752297715,\n            676265726, 3745588378, 1190456489, 3199796255, 2568311924, 1636039660, 4172418324,\n            451873022, 1488096996, 3888837104, 2380625095, 1503612236, 1174254768, 3690690154,\n            796118737, 950243347, 870818727, 3575441985, 2933836937, 4012643254, 4154690232,\n            313943165, 1194823142, 112872260, 1583856748, 3091518525, 3848126856, 2316319296,\n            1177342115, 1834090, 1312844134, 562564763, 968697255, 2625292379, 1560369157,\n            3793042995, 1360344305, 1561892888, 2561644342, 2880487899, 1329308678, 991881816,\n            408459653, 2048208943, 798151371, 3438869282, 3477838848, 1731589585, 2405599989,\n            996289971, 2339728423, 2712816129, 3199519522, 102417245, 3737926264, 2499734949,\n            4289682039, 2043689414, 2819686077, 1679268219, 222221440, 4008029847, 1560387789,\n            1298710311, 1243123895, 158514034, 3873321117, 3004642495, 3872001585, 1663566476,\n            1107233170, 293716059, 275162247, 936579960, 2990240463, 1926069351, 3296513110,\n            554621834, 4144199052, 1392609836, 1034899022, 1208790097, 2807112109, 3964061416,\n            1653167562, 3742290159, 2346753191, 3650591545, 522876039, 3945783347, 3065661379,\n            760781159, 2219622460, 82469461, 2887087892, 2552061061, 3838920437, 1162671243,\n            2030025601, 81626876, 1751905726, 2166036662, 1557608721, 546818324, 1585093311,\n            3667292391, 3522898667, 2321723183, 1047786840, 2621628330, 2989416129, 1420910156,\n            2819893717, 41408882, 1090794692, 254861895, 1531947943, 409858928, 2688575425,\n            638494402, 1137167657, 1407867246, 1512173911, 1408432723, 1473209607, 774943403,\n            1286624130, 3425873895, 3620263656, 1909123130, 2551706705, 1549113484, 1091256254,\n            2885486188, 761917899, 1632560671, 3199850510, 3435108107, 3984491598, 2758162447,\n            3408358152, 3614032341, 960132339, 3328987609, 1661534291, 3165532505, 2611312032,\n            3366533473, 1979920417, 1312551138, 117282700, 691866345, 4139053046, 3105013808,\n            2777561811, 2635054512, 497784664, 3126213089, 2216274215, 530791472, 4066290432,\n            2800488077, 636174841, 3629392743, 1077206808, 616054960, 3838079466, 2365491331,\n            4280387869, 4085608937, 2387284685, 2905568474, 3687210908, 2676786135, 2880576182,\n            2272479710, 1199932595, 2261850657, 3804274819, 3762551932, 1458028870, 2897463116,\n            2416202598, 3392536019, 2870202002, 3613666863, 2249394797, 2992036599, 728534566,\n            1120088649, 3979378545, 935693277, 1031467147, 84108903, 746798643, 627228099,\n            2800690251, 2173469180, 2830223765, 3137722777, 4178739722, 411466414, 859751380,\n            1559439628, 3694498090, 3260343774, 535054266, 117084126, 3399243337, 2495976075,\n            4076251817, 2926801036, 436287733, 3705696306, 3667196595, 96134495, 3729370692,\n            1515068169, 264787485, 2798154317, 175985133, 1313840608, 760864127, 3967639961,\n            3959432295, 1635932259, 3331385869, 1070261894, 246190898, 982482783, 3854791453,\n            2982674210, 502540469, 1076671794, 3188598990, 1279447641, 3784328740, 2394101763,\n            3346901062, 537444017, 1055795404, 3549995587, 1164547440, 1373235322, 371022910,\n            2435082373, 3557245778, 171522386, 1140771969, 3265269810, 2780244587, 1553185664,\n            1890478317, 3220213095, 1312302522, 2431923700, 1223485266, 2282493771, 921148941,\n            3067060161, 324175533, 170250519, 570500159, 1035903244, 2479701867, 255677361,\n            2023064938, 1790936466, 473377155, 1918210065, 2072725791, 616083034, 3885053377,\n            662826718, 1434245870, 1910220894, 2309848114, 525544021, 356039132, 2359013744,\n            4239245004, 4026803267, 194151528, 795233412, 305493034, 3267801916, 4080918986,\n            329727861, 2899234059, 1357709403, 3251519907, 1938363589, 4131025749, 2594354892,\n            1660726670, 271386306, 499198400, 1339562618, 1867450859, 3440407368, 1403232131,\n            1272086132, 2465102747, 1633075747, 2461437511, 635308997, 681776567, 3489150051,\n            220625570, 2311229261, 4200050354, 4050773484, 370413512, 931753989, 3307172724,\n            183245723, 1765157394, 47788463, 3937773236, 2598232722, 3424882189, 1276600447,\n            1644552616, 2626308042, 3268722786, 3810874590, 1058205206, 2654249153, 3483559388,\n            1838428373, 3023229213, 2148907687, 259958622, 2710064692, 277383554, 1415212012,\n            4053351646, 1877209663, 3049048356, 2164707394, 811696118, 3639050029, 2733433970,\n            3499435557, 84856309, 946720455, 2593206349, 1653444547, 628472620, 2602758976,\n            989666944, 1666426206, 4093401526, 2013618092, 20022648, 3142131018, 2920750232,\n            3012941536, 713849141, 217371192, 2291693390, 3420908933, 840008593, 509521091,\n            2216030985, 762663986, 1144893566, 1669626401, 3553089528, 3848788572, 1322528707,\n            1139160791, 3245062559, 354845554, 3395160786, 3002919588, 2479702839, 289294866,\n            1247980658, 1768709894, 38829267, 2796896988, 3280594127, 597391183, 1674125,\n            154337128, 1219465231, 1594491341, 215253014, 3941260773, 530738196, 1659968693,\n            1997144375, 2363494810, 1887727442, 2372279514, 3569468084, 704702032, 3254327350,\n            3274665109, 2746129291, 2402740279, 680910327, 3196302449, 1515184422, 3018121467,\n            1533706515, 2154506929, 4271801874, 276946657, 1454657398, 2035806618, 2347369271,\n            4167466602, 846913372, 678827116, 906512673, 2989625336, 3380365559, 1817466418,\n            746879498, 4161207963, 2652566219, 3997761296, 1729126521, 1915492417, 1387691720,\n            3792948085, 591813962, 4166608463, 85460956, 2019829952, 1093520400, 2115527596,\n            917437663, 1506881666, 2919904171, 1226740800, 2827153204, 1804490316, 3305326376,\n            2228657260, 4144079407, 3834647065, 2630139426, 1540825792, 2224653587, 940767108,\n            3878245257, 1227320069, 3532608478, 2225819731, 3888521056, 2837907080, 3526288423,\n            2888635755, 241668691, 2791059392, 1425900065, 900551913, 2183647741, 256669272,\n            723956303, 1186667535, 1960634662, 438856681, 37239087, 3623703669, 2346924024,\n            4084706232, 3401696786, 1070387337, 3327464499, 2530115640, 4095803022, 1354739657,\n            1132191762, 400698935, 3582112175, 3859178123, 3682980963, 3946109014, 99291864,\n            1473874678, 872297294, 2480703905, 2587482474, 4621945, 3807688592, 1223705190,\n            3415437317, 2878715234, 179753873, 1451307698, 2351373338, 3977117882, 742110068,\n            1159308459, 3051728070, 1114874234, 4063286511, 2958632124, 1126682061, 4057528706,\n            3462397411, 3615907500, 3832358400, 1520557386, 387566035, 4181990938, 3576980813,\n            1763909198, 3546068004, 2178077355, 2942665537, 1777408679, 3972359411, 1398692519,\n            1334374308, 109850799, 3967277062, 2696558472, 3920736437, 131453960, 1927970889,\n            3285016317, 1862961941, 1740391758, 4268655537, 3710775553, 145796565, 246130446,\n            1603042751, 595310227, 2018018140, 3941725849, 2484543949, 3362738863, 1417106401,\n            1903645571, 334821664, 3294839018, 757433484, 2445590565, 1336706929, 958713100,\n            3159315785, 391507292, 2052141380, 2910107823, 1346035310, 2963367850, 2254143762,\n            2499969819, 280296612, 1528879389, 902597237, 42322638, 2748873147, 2698107871,\n            1431611471, 1665375338, 159237274, 78229197, 3026759027, 1323534075, 3917805809,\n            2391056398, 1505295912, 2068279224, 1338863823, 1696316814, 2515636746, 1277950518,\n            3450429578, 2101302290, 3205130735, 196407224, 188726922, 3038097197, 57783385,\n            2383491391, 3407259298, 2799181690, 1609954168, 4123135002, 1545697370, 3578629713,\n            3610539005, 3582171858, 1278392959, 3967450424, 1821082540, 2433887435, 2290405682,\n            4274636433, 3622463783, 1758441609, 1745493987, 1614890805, 392482483, 3736377100,\n            3290414371, 2674564964, 2735379425, 1246652091, 3449848348, 386473850, 3866749153,\n            2138760498, 2782728745, 1548369266, 3567061001, 1675699086, 2780788787, 506858834,\n            2071383164, 4047965152, 1464258966, 3695163491, 1868717279, 3813178694, 3237288978,\n            986068490, 3435148318, 2122044747, 1246656336, 3896225324, 1575964969, 4213793464,\n            1109969802, 1452144015, 3212129159, 2302557278, 1502824613, 644906755, 2914538770,\n            862243454, 20971484, 3662171943, 2417948473, 1231550572, 1646849971, 853366230,\n            1122931640, 1756293226, 179544062, 4215085567, 3606104577, 1712071933, 4088212811,\n            2878352034, 3938556619, 3688177756, 2048888802, 999798004, 2557974383, 1010120016,\n            1928428516, 3117908667, 37540987, 246311472, 3280437538, 1881918816, 967577101,\n            767831376, 76432915, 1933946275, 1880512603, 2935718302, 2245985548, 3963035840,\n            1648734611, 2660142479, 2100871578, 3438105035, 1188821535, 2922385250, 1576180774,\n            1250780564, 16622501, 1607339944, 1002015015, 1956060360, 2787486043, 2001196000,\n            79889482, 2303305799, 836938799, 2987765730, 1277324921, 2034841065, 1879315225,\n            2747596182, 3859208697, 2145327881, 3726096234, 859087533, 3800200229, 2564257259,\n            84263127, 3662504708, 3381867668, 2731347057, 2864062630, 426312130, 3193065885,\n            1387307327, 4214426077, 2162510558, 3066192340, 1444678925, 1828433112, 2030683995,\n            1082098839, 86577056, 1337431284, 2125134795, 872245494, 1176391120, 428884772,\n            3304879081, 980353105, 2336105576, 3729442548, 795317116, 4102415034, 1559419254,\n            2186254311, 1543348898, 718848601, 2040045237, 3036429816, 1652063812, 1902927644,\n            849332164, 3237344326, 1209554830, 1529964693, 3810905532, 726503750, 2332940752,\n            369345572, 2173720310, 748171910, 2703721711, 4016901944, 2494187032, 655988358,\n            2624619843, 306589730, 444322440, 1527584196,\n        ],\n        vec![10; 2458],\n        &[\n            14315584, 3896075743, 1720456290, 1860987977, 2435033617, 3283815521, 2217962614,\n            3596711492, 3391485167, 1542534513, 1934312914, 3597773264, 2544643458, 1148491463,\n            3826173723, 532566836, 2635112328, 1797080596, 774807823, 998727897, 2159932141,\n            3789188038, 2274360197, 2025617756, 3512355374, 3159634613, 2709146823, 1381235091,\n            3610000364, 1734574093, 2844675590, 4140474299, 407090994, 4164501520, 793085329,\n            4062427786, 610657511, 2840989864, 251486974, 234324123, 4278826782, 4151036614,\n            915714573, 163464758, 588848332, 1721190312, 4005707399, 2749479472, 3315373811,\n            2305992663, 3034658613, 1026628922, 3044818018, 2078949981, 1076394351, 633172928,\n            919810481, 1844153183, 47796503, 3838473951, 3914821415, 56916074, 4224374707,\n            118214008, 58206586, 182773179, 2277119069, 3833074478, 1426405443, 4012102085,\n            3842259766, 1661555376, 4173078834, 2160138718, 2641435466, 2401625776, 4135020452,\n            4261341778, 3597435941, 2878333847, 1697222430, 2479834161, 3501940583, 547428987,\n            1699694744, 1589714856, 3094092039, 3812401988, 586705178, 1771549859, 3889356571,\n            2081044636, 3915524440, 2215969097, 2785923765, 2891035393, 115204411, 3555780024,\n            120731371, 2792997289, 2604840991, 3947175716, 2504012389, 2822841753, 1071118219,\n            3845128151, 4253970477, 4253952215, 1276169564, 662601090, 2764969415, 404556610,\n            4025178844, 3248541914, 1234899686, 927203128, 2307975612, 2491917326, 3535570818,\n            963945728, 24837075, 169486507, 613376340, 1332659157, 491080348, 3160651461,\n            4114780572, 1838553440, 1987857586, 3430700602, 2158770837, 2614368496, 1084388381,\n            1858796295, 1522300999, 2839927145, 2816285905, 1707265160, 2776617220, 16197005,\n            775024741, 1662486904, 623200432, 3946294781, 4240745436, 2146661189, 3067562449,\n            1836712122, 106845872, 985435189, 739872985, 1460204407, 1119513446, 330890579,\n            3254283935, 1656228797, 43939001, 1237958976, 3472042242, 2309388228, 1106182843,\n            3555794821, 36926079, 540976529, 773787735, 1327045353, 4226128278, 193584290,\n            1239226396, 3512329876, 278414825, 3926266087, 3786237276, 3579952270, 498291988,\n            2823774255, 1688087301, 1721289947, 196581659, 83087956, 4112121408, 2559494911,\n            2199502433, 1055770183, 2819943945, 33589713, 2283678521, 286507459, 552667298,\n            1451047744, 2651022894, 2228146245, 2540846830, 1050328076, 3047039299, 2766587484,\n            3691700280, 1049254813, 857110920, 1159205473, 1941578771, 717689503, 569892065,\n            3678807637, 2220477814, 1080351362, 2806798851, 3447297122, 2221865362, 930511843,\n            3450660262, 2680179755, 2917564544, 3939325714, 3771507323, 3259386687, 1467770684,\n            3837894085, 1528988932, 2370052746, 1580760722, 2250263564, 3487457499, 3543162480,\n            911819585, 2979157164, 3598196682, 3923086759, 2653629140, 658857317, 3722939978,\n            740695757, 629152520, 2170296541, 113912870, 1694943806, 3625922241, 2631571610,\n            3862073130, 2092081805, 22919059, 1192280719, 3218239082, 669906544, 2006614820,\n            2447850554, 3276882114, 1137509778, 4023609475, 2022005152, 832009711, 1067392044,\n            2457787508, 495444281, 4057527981, 2638116211, 1032205613, 654939893, 1867393721,\n            4259720808, 3864862105, 2580711081, 2986252975, 3554203437, 2309301009, 213616538,\n            2337770026, 794663587, 553040278, 952559472, 1647697621, 1129676241, 1195552408,\n            2257179988, 4158151542, 263190063, 394788678, 304472849, 1116700229, 4164233473,\n            4138582682, 1331620795, 3961214508, 3206483671, 3619459583, 3942761684, 1127994404,\n            3795525621, 1793064957, 842585732, 4265730476, 2213297660, 1058117485, 2424506278,\n            1522441713, 3775954625, 4272294225, 4189249235, 1363414580, 3480077270, 3908998115,\n            1436206873, 2926155546, 2818708656, 221476678, 1306834349, 1783935758, 3783744354,\n            1055993798, 3867370100, 3300333089, 3110025292, 2247488535, 4015323199, 3356815720,\n            2045189358, 174230219, 1749374739, 1218246124, 1727443760, 961240189, 2297210165,\n            3075205019, 1458465736, 596183329, 883659603, 1101688800, 3102408665, 1868011842,\n            1960371344, 1643686155, 1063869191, 2969813860, 3816241530, 1760766422, 2415281333,\n            1552385643, 3433917314, 3680135132, 2620866828, 3307471651, 1980286844, 1955169126,\n            2687159626, 334855600, 117109258, 1746064251, 3376322566, 3584584566, 3601971429,\n            604861952, 2830443525, 1679490243, 36269131, 796031070, 3561439893, 4022657332,\n            2985918676, 17127477, 3761141990, 1343371600, 2767901251, 3804378567, 3191436147,\n            3852862884, 3016005135, 1779020584, 3175770274, 511808311, 1203545175, 1008529794,\n            700155497, 1917226278, 1626847419, 3459828508, 1537231, 2773424015, 388817294,\n            3515169103, 474940622, 844323074, 1246271484, 808369492, 3662858240, 3038799386,\n            837049977, 694305488, 1015863588, 2925540413, 4159464622, 3677790522, 2662594853,\n            3511496512, 2011009488, 1290229871, 641420037, 2128199318, 596608790, 4224311625,\n            2444741761, 2082021242, 105250274, 3696760907, 725737773, 444696069, 1930303327,\n            641100376, 487548132, 3502604477, 3831249409, 3112472257, 3558333009, 2068118493,\n            2883838540, 1151392095, 2621367657, 456338853, 1553499738, 1204143117, 3272252059,\n            2070211859, 1217939590, 1139521074, 1196251017, 2724271013, 414971260, 578940848,\n            3971160962, 2353021486, 428914039, 1466220029, 1196519558, 1433890287, 3488235345,\n            1745391024, 3271389992, 2189565159, 845963688, 2022888924, 1318009346, 3106363223,\n            3294116257, 3097893493, 1464480728, 1050593463, 2122671271, 1211170363, 3885668892,\n            2267117947, 863642472, 3731190320, 1733566259, 178546948, 2468292835, 2325992738,\n            1754129674, 2704515549, 3611719433, 2588929153, 1954312759, 2795607335, 279835277,\n            57394715, 2914757129, 828581834, 3849284465, 2023672381, 880214213, 1837624514,\n            3173571098, 2422433820, 3834459050, 2009223418, 4111196121, 2821937543, 792678184,\n            3501133001, 4215472170, 2198345623, 923662366, 3183651064, 1599187385, 2463494975,\n            2989458960, 1408484683, 2889663583, 3518183569, 4157181297, 2205842269, 1585684381,\n            391762939, 2611826234, 1196804558, 1572135490, 3975160311, 2275902996, 1069102622,\n            1315683334, 3852967713, 3301170698, 671161065, 128192467, 2613903289, 1009831606,\n            3749541003, 4268007757, 3092087731, 2140417700, 4096277941, 3660903771, 614384141,\n            531790068, 1909595317, 860446255, 3382696660, 1061474464, 3069773013, 3315525987,\n            3523354010, 2175878609, 3945364084, 1871031220, 1024296174, 2318503761, 3880021755,\n            3483182385, 1136511304, 1854660657, 1351215670, 665018554, 200157670, 2960727314,\n            4133284053, 545593913, 1878146619, 4080637287, 1319623815, 1371326109, 1538817431,\n            1523233024, 113264668, 129051258, 2403826474, 3690426422, 1876099463, 3478112649,\n            2967083172, 3506759557, 409569116, 303290950, 129270085, 2185938088, 1654816429,\n            1606016066, 1937302705, 2748203621, 182457345, 4251467861, 4087619332, 1455766758,\n            16900151, 965491445, 2811127049, 30198978, 3752372717, 2055927564, 274588215,\n            3391994008, 1128217088, 347809028, 3079847934, 2217407060, 425522097, 2570086835,\n            2332474322, 3806978544, 185777147, 2699474347, 3590619670, 2292054738, 2754393328,\n            1364967129, 3456367406, 3229262504, 3058183589, 3530281963, 1260299809, 2813856498,\n            1699609618, 1560668741, 3219892482, 1660863042, 2699447087, 1139225248, 1391362567,\n            2863783940, 3505675545, 177973681, 2882782098, 3651046939, 2456664276, 1206225175,\n            2580372242, 861145421, 2184732085, 2769725519, 2282301357, 293785, 2972930264,\n            2386258075, 3859546565, 1169200071, 889331732, 2826596513, 817584661, 3393024390,\n            1855368622, 1827205276, 2387127529, 2630010835, 3209679365, 418840491, 884209449,\n            2057532721, 3963456408, 2146511566, 3657939615, 3357975902, 1077069037, 724050579,\n            3103467640, 3641072139, 2311523389, 289677346, 2339409410, 593745130, 2263567727,\n            138391246, 796328585, 2755156236, 2335316903, 2840103332, 2555558267, 4191162130,\n            2041604517, 1454327959, 2762012248, 345711112, 3271322778, 251706744, 1529366113,\n            1560060753, 1273744532, 1745715986, 3472355943, 4216660608, 2700388481, 356464407,\n            3241914579, 2079624535, 2335385338, 1915268218, 1444165795, 909641004, 3058658356,\n            2994984668, 478335584, 1460779062, 3467507749, 1754767550, 1567226851, 1002377325,\n            3381130756, 267437249, 2121264436, 253481028, 936579317, 1351715032, 3705651480,\n            320805320, 2843650545, 513701327, 4215594992, 917564150, 479566665, 859669441,\n            3157609161, 1488471594, 2176388201, 3238827013, 2441825796, 4172095140, 2146136291,\n            1038154134, 2320185255, 837531952, 3680644283, 2246178890, 1376172528, 1150716697,\n            4062481636, 3411210837, 4222364616, 1565814963, 1958710568, 3912317092, 980972994,\n            878840575, 3785073185, 3184461301, 2896839434, 1329190240, 1611142107, 1066960053,\n            3030553308, 2739555728, 1219677550, 1319663819, 3807245276, 3038804156, 3975511475,\n            3474347779, 1787854544, 601721716, 2066121273, 1574211264, 2629698714, 942513094,\n            1970368862, 253914275, 2798995017, 521161377, 4169584747, 1284753624, 1230700315,\n            1384968294, 1964859012, 3291627178, 1980345114, 2549783785, 3965567049, 1871888126,\n            2413764615, 3746715727, 47085565, 3023290394, 2113006968, 2213295793, 3257150141,\n            4076997720, 1957602743, 2506897077, 3936832338, 2584432072, 3577991725, 3315218282,\n            3479103036, 1346566712, 2371604946, 2925130936, 1641375567, 2326216376, 2392362615,\n            3415032383, 1114138902, 2782317125, 3786087099, 2257642242, 3028343849, 2677315638,\n            2362678290, 1186576050, 2383638912, 508976689, 1371440287, 157924594, 578155066,\n            3045004846, 1531823852, 4127560618, 193156585, 885851934, 393568866, 2698643032,\n            1487115201, 1785690912, 1560880139, 3506823440, 2249790562, 2196069771, 1655354644,\n            1502736684, 2846902313, 3224146927, 1069425847, 1484301171, 3937349528, 3672862019,\n            27599350, 3951201728, 346872759, 3254389195, 344295907, 2578553021, 923584949,\n            3534810913, 2615758701, 638597905, 271997715, 3258597336, 3729321294, 2555257257,\n            3160826970, 2162970558, 3448099455, 4067658524, 2977860211, 711143050, 3898990729,\n            477305732, 4126099437, 2285319322, 203339387, 2313974244, 3497142096, 3829537435,\n            2373684329, 1580063789, 1630563529, 4181047728, 4251813960, 2633137079, 239130144,\n            3187401945, 2137440975, 1756486693, 835326208, 1219590260, 9685703, 2802769936,\n            2828332335, 3395480672, 159349648, 1474549022, 753761752, 1033399146, 2663571984,\n            3293328810, 1708860985, 2775321734, 1290639360, 3469415209, 1932741667, 4131857604,\n            3548751506, 3873065925, 1317695774, 3167730054, 2212798570, 963071706, 2239017839,\n            1663037918, 2024879418, 1241586100, 2977324887, 3668861062, 1460374273, 1519821695,\n            4149671041, 3603428895, 2544181925, 1881748848, 1326890903, 934934583, 4041040169,\n            1251595343, 330283292, 251256048, 2781853181, 1285941088, 3857270978, 2172118120,\n            2411830912, 4263916993, 1501520015, 1668582518, 4232592653, 879763972, 2835329802,\n            2391710926, 2956348612, 1044031187, 2315020555, 832842187, 1640823936, 3687293347,\n            3245417753, 1428535947, 3947019553, 2520875375, 1870345747, 1192441840, 3799658925,\n            3361841552, 346211097, 2455121685, 883553097, 3147539750, 3584951361, 1998974973,\n            3410409445, 1192475577, 1099659862, 3119506960, 2253622822, 1486966019, 4268179280,\n            3660479674, 3393207880, 244989765, 3307625178, 2228507794, 380460232, 3068292465,\n            4049554096, 3930654451, 2211137620, 2857990237, 2174742086, 406693768, 3903681170,\n            2502874185, 337283200, 2457367138, 2750431953, 718191090, 4292594176, 4100702015,\n            3730247801, 892058377, 4270730729, 1475580269, 1364594981, 498258814, 1627557888,\n            1445371571, 381298578, 3302152308, 1501315700, 1540275847, 1508419086, 2490558448,\n            2211045301, 1960092236, 764821667, 3011598950, 2610267528, 1305693830, 1576485405,\n            482671602, 939273544, 229216422, 1132377588, 1530307612, 2725258345, 1846376247,\n            2496250877, 2069965191, 2820337527, 1422645778, 3199513164, 399431965, 2806995769,\n            1924011870, 3052206613, 2926865488, 1616505509, 2747673810, 1857370974, 2194952150,\n            1497926871, 3238231671, 3731302543, 2809222691, 1647371626, 4292916721, 3256825234,\n            3570979652, 3007380634, 2699365431, 2248095940, 885821273, 2678808130, 3323361718,\n            1143883958, 30479033, 2004872945, 3382927648, 2168115449, 3511946758, 278718047,\n            4014380536, 1096793656, 1075537158, 2961900536, 3710219996, 2157081806, 4239096658,\n            831258008, 3208663634, 1065180774, 1716500895, 2672567069, 1232298720, 2125798236,\n            134823113, 3792486128, 3436278410, 2111754152, 942157649, 2586630610, 806131922,\n            738294633, 637501765, 1534594581, 80662048, 2778145971, 1982921733, 1684072932,\n            3372420013, 3660171935, 2135748383, 2694039659, 377728688, 700503753, 2985608912,\n            1084882191, 4151983585, 1926421903, 3882296979, 710544755, 797297863, 1874922381,\n            600821424, 3469363770, 2976113533, 3097650285, 3213892345, 4283796693, 3738314537,\n            584844598, 1238389442, 328722752, 2261560780, 1963218488, 2722962954, 1970611970,\n            3995953308, 1850769515, 3152074077, 1001957645, 2384943533, 3877044968, 1975105919,\n            1107878264, 2803250607, 3005721228, 1384517066, 2059492073, 4218640871, 880506282,\n            4072429242, 1924150062, 4080336746, 203753502, 2881428894, 1944674533, 2510372468,\n            2208936106, 160544268, 2169335406, 1295089250, 1389517169, 601874109, 3482835876,\n            995715955, 860499899, 3257518826, 1582699703, 811345812, 865361290, 3350101589,\n            2302946008, 526905664, 3463993986, 3786007662, 1461421857, 558553300, 2659196735,\n            1878306353, 2120863173, 1521235460, 1668716843, 342506011, 1304470509, 1883246634,\n            904885016, 851659242, 618465764, 62782100, 3904388641, 3401400130, 3033132634,\n            3695267353, 4184494689, 2096681402, 2136444941, 2379668661, 3570388220, 3650934881,\n            845257826, 1658386111, 216440227, 1448252242, 3867938137, 1041551940, 1271424127,\n            1694854790, 2618966358, 1212830768, 2944316262, 3255928108, 1311149209, 1634132716,\n            46015894, 1762774538, 3731249278, 3730743730, 4122659132, 4259690078, 2131268672,\n            1847903623, 2590863134, 1598577933, 2201759887, 2734226325, 3886633845, 673785124,\n            1543386385, 2392366384, 1010403234, 1157937717, 1379471091, 2428469664, 778717505,\n            2131414834, 690273672, 1633129278, 275458335, 2948558713, 3736213388, 1165582721,\n            619527248, 3580718374, 2331959084, 4015892607, 22218657, 57793748, 78895829,\n            2261931181, 2176427545, 254353123, 288354796, 1811254416, 4175221279, 1999304075,\n            2243073703, 2406263731, 3607071103, 2509308494, 4227058988, 459041177, 1288003499,\n            171257138, 1527074103, 946436740, 4096275409, 3439222084, 1039960427, 682450971,\n            624577877, 2383738920, 3781585168, 1998082771, 456216047, 4084776014, 2465435506,\n            1212194082, 2219178103, 3115504881, 782294840, 3975566931, 865020752, 3621258027,\n            19776526, 3786071932, 3553320495, 1278472279, 360299885, 101923276, 30803414,\n            705340594, 3798470694, 1725093175, 3767628802, 2745865016, 2628443054, 260876871,\n            511035750, 4013822465, 52914465, 1896658602, 1346680681, 2022488278, 1329922307,\n            3852700935, 834456360, 1442297319, 842245334,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_divide_and_conquer_shared_scratch_fail_1() {\n    let mut out = vec![10, 10, 10, 10, 10];\n    limbs_mul_low_same_length_divide_and_conquer_shared_scratch(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_divide_and_conquer_shared_scratch_fail_2() {\n    let mut out = vec![10];\n    limbs_mul_low_same_length_divide_and_conquer_shared_scratch(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_divide_and_conquer_shared_scratch_fail_3() {\n    let mut out = vec![10];\n    limbs_mul_low_same_length_divide_and_conquer_shared_scratch(&mut out, &[2], &[3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_divide_and_conquer_fail_1() {\n    let mut out = vec![10, 10, 10, 10, 10];\n    let mut scratch = vec![0; 6];\n    limbs_mul_low_same_length_divide_and_conquer(&mut out, &[6, 7], &[1, 2, 3], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_divide_and_conquer_fail_2() {\n    let mut out = vec![10];\n    let mut scratch = vec![0; 4];\n    limbs_mul_low_same_length_divide_and_conquer(&mut out, &[6, 7], &[1, 2], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_divide_and_conquer_fail_3() {\n    let mut out = vec![10];\n    let mut scratch = vec![0; 6];\n    limbs_mul_low_same_length_divide_and_conquer(&mut out, &[2], &[3], &mut scratch);\n}\n\n#[test]\nfn limbs_mul_low_same_length_divide_and_conquer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 256 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_25().test_properties_with_config(\n        &config,\n        |(out_before, xs, ys)| {\n            let mut out = out_before.to_vec();\n            limbs_mul_low_same_length_divide_and_conquer_shared_scratch(&mut out, &xs, &ys);\n\n            let len = xs.len();\n            let out_after = out[..len].to_vec();\n            let mut out = out_before.to_vec();\n            let mut scratch = vec![0; xs.len() << 1];\n            limbs_mul_low_same_length_divide_and_conquer(&mut out, &xs, &ys, &mut scratch);\n            let out_after: &[Limb] = &out_after;\n            assert_eq!(&out[..len], out_after);\n\n            verify_mul_low_2(&xs, &ys, out_after);\n        },\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_mul_low_same_length() {\n    let test = |xs: Vec<Limb>, ys: Vec<Limb>, out_before: Vec<Limb>, out_after: &[Limb]| {\n        let len = xs.len();\n        let mut out = out_before.clone();\n        limbs_mul_low_same_length(&mut out, &xs, &ys);\n        assert_eq!(&out[..len], out_after);\n        verify_mul_low_1(&out_before, &xs, &ys, &out);\n    };\n    // - MULLO_BASECASE_THRESHOLD <= n < MULLO_DC_THRESHOLD\n    test(vec![1; 3], series(1, 3), vec![5; 8], &[1, 3, 6]);\n    test(\n        vec![100, 101, 102],\n        vec![102, 101, 100],\n        vec![10; 7],\n        &[10200, 20402, 30605],\n    );\n    test(\n        vec![u32::MAX; 3],\n        vec![u32::MAX; 3],\n        vec![10; 6],\n        &[1, 0, 0],\n    );\n    // - n >= MULLO_DC_THRESHOLD\n    // - n < MULLO_MUL_N_THRESHOLD\n    test(\n        vec![\n            667555911, 2348733364, 1961106649, 1440628769, 1419633260, 3052369574, 1108620071,\n            3434026162, 3916636599, 3102975331, 3886608438, 726540295, 1959301605, 1097548123,\n            4197775113, 2426454473, 1977350598, 815012862, 2487421470, 2968184113, 3186369366,\n            2845700438, 1474463355, 3590404890, 2351730037, 3978816218, 227579243, 185502596,\n            1922772057, 2864373880, 1909608765, 307719594, 4182459185, 3812324913, 1740357086,\n            619281590, 1426834026, 2868540501, 440166317, 3324081248, 1368857307, 3133154844,\n            1142185935, 2703145826, 1436656515, 2490167985, 2881509383, 725592411, 1056415214,\n            1801603748, 1098036334, 728276877, 1517386665, 1881520126, 2784785117, 2287558410,\n            3556820397, 1380321205, 706755221, 2829962299, 3613994343, 1462484606, 3627636556,\n            490302213, 2592459816, 866144376, 609122783, 1451416993, 3785904246, 4131235963,\n            74121435, 3878638497, 588893998, 1092662611, 3469958113, 2363382228, 2678844074,\n            1733088933, 3784272536, 4005990872, 2863454468, 3205477346, 3748950603, 3944338479,\n            59852399, 3489893816, 1468407650, 596065110, 1335233230, 3643254705, 1408578383,\n            2465303822, 2349399082, 3471899735, 2696915607, 1269986424,\n        ],\n        vec![\n            2722576082, 2281236300, 3094793404, 2870225073, 1804040671, 2878250398, 737079723,\n            822732050, 655707872, 4207992704, 1851690693, 912905035, 3291778825, 2516279380,\n            636556658, 2839780581, 3193297014, 1756749995, 3651621870, 628948913, 380312917,\n            2361120672, 2262818273, 2071766395, 4162768312, 2516781023, 3406285004, 1455245572,\n            2587465945, 1378482824, 241323934, 2280756750, 242112740, 69419369, 2603755088,\n            2163412563, 1341439609, 321882770, 736087982, 2995521870, 3671192545, 1265948417,\n            548486283, 3124707078, 290930553, 742853646, 118648394, 3811259549, 2371785381,\n            2042286901, 3723558867, 783245266, 2393779385, 1940230299, 1556220091, 3235087403,\n            2441469134, 1125637818, 1712201794, 2216073164, 4175845099, 958349548, 4262398424,\n            3171987471, 363107024, 2664611701, 2971536098, 2823614641, 1683011498, 1406296445,\n            3951206397, 3996972934, 3905528336, 920273699, 1258344157, 2971218980, 1721322990,\n            1804720416, 3946193389, 1866895548, 2875334355, 2152965895, 1192611565, 3662025315,\n            3450196924, 3273347968, 3209563794, 1516062635, 679683317, 1998597190, 2857249714,\n            771410307, 3851158594, 2246899647, 1910389835, 3917001975,\n        ],\n        vec![10; 96],\n        &[\n            4002931774, 1904598186, 3234829245, 3606564796, 1306091105, 2193187486, 3152048235,\n            591394468, 3956728348, 1387100164, 1906336788, 3282287701, 520335280, 185717337,\n            2805648626, 3053703744, 140292430, 3997128531, 231327311, 15232560, 1661811744,\n            661469371, 576722126, 854577401, 4168087387, 3545117380, 2423373377, 3239419618,\n            806391738, 3880336495, 622341226, 2747181685, 1811142986, 3822894835, 1547377963,\n            661471733, 100990771, 311111243, 617447537, 2129281438, 830310054, 2479129328,\n            3642060387, 3489744434, 1954771548, 3535568842, 3876438817, 943110050, 2741340933,\n            1863625282, 3029160300, 687011149, 2856703096, 1137282724, 1230235236, 3485141654,\n            2955294074, 4088046039, 1413613081, 4175441078, 3746030422, 287749227, 1646738360,\n            1501205414, 1096064838, 1755515350, 2556528506, 238519283, 3569605126, 796573795,\n            4090746106, 4149522856, 583205784, 2821201119, 3555712047, 1090519982, 2976948004,\n            3580487377, 627104596, 1130079835, 490101583, 1570134181, 648065435, 1085439524,\n            3896882529, 2919299575, 3301848876, 1413509397, 3259269725, 2509252448, 2214096765,\n            1288915975, 2839044440, 1348673262, 916617232, 3060106377,\n        ],\n    );\n    // - n >= MULLO_MUL_N_THRESHOLD\n    // - !TUNE_PROGRAM_BUILD && MULLO_MUL_N_THRESHOLD > MUL_FFT_THRESHOLD\n    test(\n        series(1, 9000),\n        series(2, 9000),\n        vec![10; 9000],\n        &[\n            2, 7, 16, 30, 50, 77, 112, 156, 210, 275, 352, 442, 546, 665, 800, 952, 1122, 1311,\n            1520, 1750, 2002, 2277, 2576, 2900, 3250, 3627, 4032, 4466, 4930, 5425, 5952, 6512,\n            7106, 7735, 8400, 9102, 9842, 10621, 11440, 12300, 13202, 14147, 15136, 16170, 17250,\n            18377, 19552, 20776, 22050, 23375, 24752, 26182, 27666, 29205, 30800, 32452, 34162,\n            35931, 37760, 39650, 41602, 43617, 45696, 47840, 50050, 52327, 54672, 57086, 59570,\n            62125, 64752, 67452, 70226, 73075, 76000, 79002, 82082, 85241, 88480, 91800, 95202,\n            98687, 102256, 105910, 109650, 113477, 117392, 121396, 125490, 129675, 133952, 138322,\n            142786, 147345, 152000, 156752, 161602, 166551, 171600, 176750, 182002, 187357, 192816,\n            198380, 204050, 209827, 215712, 221706, 227810, 234025, 240352, 246792, 253346, 260015,\n            266800, 273702, 280722, 287861, 295120, 302500, 310002, 317627, 325376, 333250, 341250,\n            349377, 357632, 366016, 374530, 383175, 391952, 400862, 409906, 419085, 428400, 437852,\n            447442, 457171, 467040, 477050, 487202, 497497, 507936, 518520, 529250, 540127, 551152,\n            562326, 573650, 585125, 596752, 608532, 620466, 632555, 644800, 657202, 669762, 682481,\n            695360, 708400, 721602, 734967, 748496, 762190, 776050, 790077, 804272, 818636, 833170,\n            847875, 862752, 877802, 893026, 908425, 924000, 939752, 955682, 971791, 988080,\n            1004550, 1021202, 1038037, 1055056, 1072260, 1089650, 1107227, 1124992, 1142946,\n            1161090, 1179425, 1197952, 1216672, 1235586, 1254695, 1274000, 1293502, 1313202,\n            1333101, 1353200, 1373500, 1394002, 1414707, 1435616, 1456730, 1478050, 1499577,\n            1521312, 1543256, 1565410, 1587775, 1610352, 1633142, 1656146, 1679365, 1702800,\n            1726452, 1750322, 1774411, 1798720, 1823250, 1848002, 1872977, 1898176, 1923600,\n            1949250, 1975127, 2001232, 2027566, 2054130, 2080925, 2107952, 2135212, 2162706,\n            2190435, 2218400, 2246602, 2275042, 2303721, 2332640, 2361800, 2391202, 2420847,\n            2450736, 2480870, 2511250, 2541877, 2572752, 2603876, 2635250, 2666875, 2698752,\n            2730882, 2763266, 2795905, 2828800, 2861952, 2895362, 2929031, 2962960, 2997150,\n            3031602, 3066317, 3101296, 3136540, 3172050, 3207827, 3243872, 3280186, 3316770,\n            3353625, 3390752, 3428152, 3465826, 3503775, 3542000, 3580502, 3619282, 3658341,\n            3697680, 3737300, 3777202, 3817387, 3857856, 3898610, 3939650, 3980977, 4022592,\n            4064496, 4106690, 4149175, 4191952, 4235022, 4278386, 4322045, 4366000, 4410252,\n            4454802, 4499651, 4544800, 4590250, 4636002, 4682057, 4728416, 4775080, 4822050,\n            4869327, 4916912, 4964806, 5013010, 5061525, 5110352, 5159492, 5208946, 5258715,\n            5308800, 5359202, 5409922, 5460961, 5512320, 5564000, 5616002, 5668327, 5720976,\n            5773950, 5827250, 5880877, 5934832, 5989116, 6043730, 6098675, 6153952, 6209562,\n            6265506, 6321785, 6378400, 6435352, 6492642, 6550271, 6608240, 6666550, 6725202,\n            6784197, 6843536, 6903220, 6963250, 7023627, 7084352, 7145426, 7206850, 7268625,\n            7330752, 7393232, 7456066, 7519255, 7582800, 7646702, 7710962, 7775581, 7840560,\n            7905900, 7971602, 8037667, 8104096, 8170890, 8238050, 8305577, 8373472, 8441736,\n            8510370, 8579375, 8648752, 8718502, 8788626, 8859125, 8930000, 9001252, 9072882,\n            9144891, 9217280, 9290050, 9363202, 9436737, 9510656, 9584960, 9659650, 9734727,\n            9810192, 9886046, 9962290, 10038925, 10115952, 10193372, 10271186, 10349395, 10428000,\n            10507002, 10586402, 10666201, 10746400, 10827000, 10908002, 10989407, 11071216,\n            11153430, 11236050, 11319077, 11402512, 11486356, 11570610, 11655275, 11740352,\n            11825842, 11911746, 11998065, 12084800, 12171952, 12259522, 12347511, 12435920,\n            12524750, 12614002, 12703677, 12793776, 12884300, 12975250, 13066627, 13158432,\n            13250666, 13343330, 13436425, 13529952, 13623912, 13718306, 13813135, 13908400,\n            14004102, 14100242, 14196821, 14293840, 14391300, 14489202, 14587547, 14686336,\n            14785570, 14885250, 14985377, 15085952, 15186976, 15288450, 15390375, 15492752,\n            15595582, 15698866, 15802605, 15906800, 16011452, 16116562, 16222131, 16328160,\n            16434650, 16541602, 16649017, 16756896, 16865240, 16974050, 17083327, 17193072,\n            17303286, 17413970, 17525125, 17636752, 17748852, 17861426, 17974475, 18088000,\n            18202002, 18316482, 18431441, 18546880, 18662800, 18779202, 18896087, 19013456,\n            19131310, 19249650, 19368477, 19487792, 19607596, 19727890, 19848675, 19969952,\n            20091722, 20213986, 20336745, 20460000, 20583752, 20708002, 20832751, 20958000,\n            21083750, 21210002, 21336757, 21464016, 21591780, 21720050, 21848827, 21978112,\n            22107906, 22238210, 22369025, 22500352, 22632192, 22764546, 22897415, 23030800,\n            23164702, 23299122, 23434061, 23569520, 23705500, 23842002, 23979027, 24116576,\n            24254650, 24393250, 24532377, 24672032, 24812216, 24952930, 25094175, 25235952,\n            25378262, 25521106, 25664485, 25808400, 25952852, 26097842, 26243371, 26389440,\n            26536050, 26683202, 26830897, 26979136, 27127920, 27277250, 27427127, 27577552,\n            27728526, 27880050, 28032125, 28184752, 28337932, 28491666, 28645955, 28800800,\n            28956202, 29112162, 29268681, 29425760, 29583400, 29741602, 29900367, 30059696,\n            30219590, 30380050, 30541077, 30702672, 30864836, 31027570, 31190875, 31354752,\n            31519202, 31684226, 31849825, 32016000, 32182752, 32350082, 32517991, 32686480,\n            32855550, 33025202, 33195437, 33366256, 33537660, 33709650, 33882227, 34055392,\n            34229146, 34403490, 34578425, 34753952, 34930072, 35106786, 35284095, 35462000,\n            35640502, 35819602, 35999301, 36179600, 36360500, 36542002, 36724107, 36906816,\n            37090130, 37274050, 37458577, 37643712, 37829456, 38015810, 38202775, 38390352,\n            38578542, 38767346, 38956765, 39146800, 39337452, 39528722, 39720611, 39913120,\n            40106250, 40300002, 40494377, 40689376, 40885000, 41081250, 41278127, 41475632,\n            41673766, 41872530, 42071925, 42271952, 42472612, 42673906, 42875835, 43078400,\n            43281602, 43485442, 43689921, 43895040, 44100800, 44307202, 44514247, 44721936,\n            44930270, 45139250, 45348877, 45559152, 45770076, 45981650, 46193875, 46406752,\n            46620282, 46834466, 47049305, 47264800, 47480952, 47697762, 47915231, 48133360,\n            48352150, 48571602, 48791717, 49012496, 49233940, 49456050, 49678827, 49902272,\n            50126386, 50351170, 50576625, 50802752, 51029552, 51257026, 51485175, 51714000,\n            51943502, 52173682, 52404541, 52636080, 52868300, 53101202, 53334787, 53569056,\n            53804010, 54039650, 54275977, 54512992, 54750696, 54989090, 55228175, 55467952,\n            55708422, 55949586, 56191445, 56434000, 56677252, 56921202, 57165851, 57411200,\n            57657250, 57904002, 58151457, 58399616, 58648480, 58898050, 59148327, 59399312,\n            59651006, 59903410, 60156525, 60410352, 60664892, 60920146, 61176115, 61432800,\n            61690202, 61948322, 62207161, 62466720, 62727000, 62988002, 63249727, 63512176,\n            63775350, 64039250, 64303877, 64569232, 64835316, 65102130, 65369675, 65637952,\n            65906962, 66176706, 66447185, 66718400, 66990352, 67263042, 67536471, 67810640,\n            68085550, 68361202, 68637597, 68914736, 69192620, 69471250, 69750627, 70030752,\n            70311626, 70593250, 70875625, 71158752, 71442632, 71727266, 72012655, 72298800,\n            72585702, 72873362, 73161781, 73450960, 73740900, 74031602, 74323067, 74615296,\n            74908290, 75202050, 75496577, 75791872, 76087936, 76384770, 76682375, 76980752,\n            77279902, 77579826, 77880525, 78182000, 78484252, 78787282, 79091091, 79395680,\n            79701050, 80007202, 80314137, 80621856, 80930360, 81239650, 81549727, 81860592,\n            82172246, 82484690, 82797925, 83111952, 83426772, 83742386, 84058795, 84376000,\n            84694002, 85012802, 85332401, 85652800, 85974000, 86296002, 86618807, 86942416,\n            87266830, 87592050, 87918077, 88244912, 88572556, 88901010, 89230275, 89560352,\n            89891242, 90222946, 90555465, 90888800, 91222952, 91557922, 91893711, 92230320,\n            92567750, 92906002, 93245077, 93584976, 93925700, 94267250, 94609627, 94952832,\n            95296866, 95641730, 95987425, 96333952, 96681312, 97029506, 97378535, 97728400,\n            98079102, 98430642, 98783021, 99136240, 99490300, 99845202, 100200947, 100557536,\n            100914970, 101273250, 101632377, 101992352, 102353176, 102714850, 103077375, 103440752,\n            103804982, 104170066, 104536005, 104902800, 105270452, 105638962, 106008331, 106378560,\n            106749650, 107121602, 107494417, 107868096, 108242640, 108618050, 108994327, 109371472,\n            109749486, 110128370, 110508125, 110888752, 111270252, 111652626, 112035875, 112420000,\n            112805002, 113190882, 113577641, 113965280, 114353800, 114743202, 115133487, 115524656,\n            115916710, 116309650, 116703477, 117098192, 117493796, 117890290, 118287675, 118685952,\n            119085122, 119485186, 119886145, 120288000, 120690752, 121094402, 121498951, 121904400,\n            122310750, 122718002, 123126157, 123535216, 123945180, 124356050, 124767827, 125180512,\n            125594106, 126008610, 126424025, 126840352, 127257592, 127675746, 128094815, 128514800,\n            128935702, 129357522, 129780261, 130203920, 130628500, 131054002, 131480427, 131907776,\n            132336050, 132765250, 133195377, 133626432, 134058416, 134491330, 134925175, 135359952,\n            135795662, 136232306, 136669885, 137108400, 137547852, 137988242, 138429571, 138871840,\n            139315050, 139759202, 140204297, 140650336, 141097320, 141545250, 141994127, 142443952,\n            142894726, 143346450, 143799125, 144252752, 144707332, 145162866, 145619355, 146076800,\n            146535202, 146994562, 147454881, 147916160, 148378400, 148841602, 149305767, 149770896,\n            150236990, 150704050, 151172077, 151641072, 152111036, 152581970, 153053875, 153526752,\n            154000602, 154475426, 154951225, 155428000, 155905752, 156384482, 156864191, 157344880,\n            157826550, 158309202, 158792837, 159277456, 159763060, 160249650, 160737227, 161225792,\n            161715346, 162205890, 162697425, 163189952, 163683472, 164177986, 164673495, 165170000,\n            165667502, 166166002, 166665501, 167166000, 167667500, 168170002, 168673507, 169178016,\n            169683530, 170190050, 170697577, 171206112, 171715656, 172226210, 172737775, 173250352,\n            173763942, 174278546, 174794165, 175310800, 175828452, 176347122, 176866811, 177387520,\n            177909250, 178432002, 178955777, 179480576, 180006400, 180533250, 181061127, 181590032,\n            182119966, 182650930, 183182925, 183715952, 184250012, 184785106, 185321235, 185858400,\n            186396602, 186935842, 187476121, 188017440, 188559800, 189103202, 189647647, 190193136,\n            190739670, 191287250, 191835877, 192385552, 192936276, 193488050, 194040875, 194594752,\n            195149682, 195705666, 196262705, 196820800, 197379952, 197940162, 198501431, 199063760,\n            199627150, 200191602, 200757117, 201323696, 201891340, 202460050, 203029827, 203600672,\n            204172586, 204745570, 205319625, 205894752, 206470952, 207048226, 207626575, 208206000,\n            208786502, 209368082, 209950741, 210534480, 211119300, 211705202, 212292187, 212880256,\n            213469410, 214059650, 214650977, 215243392, 215836896, 216431490, 217027175, 217623952,\n            218221822, 218820786, 219420845, 220022000, 220624252, 221227602, 221832051, 222437600,\n            223044250, 223652002, 224260857, 224870816, 225481880, 226094050, 226707327, 227321712,\n            227937206, 228553810, 229171525, 229790352, 230410292, 231031346, 231653515, 232276800,\n            232901202, 233526722, 234153361, 234781120, 235410000, 236040002, 236671127, 237303376,\n            237936750, 238571250, 239206877, 239843632, 240481516, 241120530, 241760675, 242401952,\n            243044362, 243687906, 244332585, 244978400, 245625352, 246273442, 246922671, 247573040,\n            248224550, 248877202, 249530997, 250185936, 250842020, 251499250, 252157627, 252817152,\n            253477826, 254139650, 254802625, 255466752, 256132032, 256798466, 257466055, 258134800,\n            258804702, 259475762, 260147981, 260821360, 261495900, 262171602, 262848467, 263526496,\n            264205690, 264886050, 265567577, 266250272, 266934136, 267619170, 268305375, 268992752,\n            269681302, 270371026, 271061925, 271754000, 272447252, 273141682, 273837291, 274534080,\n            275232050, 275931202, 276631537, 277333056, 278035760, 278739650, 279444727, 280150992,\n            280858446, 281567090, 282276925, 282987952, 283700172, 284413586, 285128195, 285844000,\n            286561002, 287279202, 287998601, 288719200, 289441000, 290164002, 290888207, 291613616,\n            292340230, 293068050, 293797077, 294527312, 295258756, 295991410, 296725275, 297460352,\n            298196642, 298934146, 299672865, 300412800, 301153952, 301896322, 302639911, 303384720,\n            304130750, 304878002, 305626477, 306376176, 307127100, 307879250, 308632627, 309387232,\n            310143066, 310900130, 311658425, 312417952, 313178712, 313940706, 314703935, 315468400,\n            316234102, 317001042, 317769221, 318538640, 319309300, 320081202, 320854347, 321628736,\n            322404370, 323181250, 323959377, 324738752, 325519376, 326301250, 327084375, 327868752,\n            328654382, 329441266, 330229405, 331018800, 331809452, 332601362, 333394531, 334188960,\n            334984650, 335781602, 336579817, 337379296, 338180040, 338982050, 339785327, 340589872,\n            341395686, 342202770, 343011125, 343820752, 344631652, 345443826, 346257275, 347072000,\n            347888002, 348705282, 349523841, 350343680, 351164800, 351987202, 352810887, 353635856,\n            354462110, 355289650, 356118477, 356948592, 357779996, 358612690, 359446675, 360281952,\n            361118522, 361956386, 362795545, 363636000, 364477752, 365320802, 366165151, 367010800,\n            367857750, 368706002, 369555557, 370406416, 371258580, 372112050, 372966827, 373822912,\n            374680306, 375539010, 376399025, 377260352, 378122992, 378986946, 379852215, 380718800,\n            381586702, 382455922, 383326461, 384198320, 385071500, 385946002, 386821827, 387698976,\n            388577450, 389457250, 390338377, 391220832, 392104616, 392989730, 393876175, 394763952,\n            395653062, 396543506, 397435285, 398328400, 399222852, 400118642, 401015771, 401914240,\n            402814050, 403715202, 404617697, 405521536, 406426720, 407333250, 408241127, 409150352,\n            410060926, 410972850, 411886125, 412800752, 413716732, 414634066, 415552755, 416472800,\n            417394202, 418316962, 419241081, 420166560, 421093400, 422021602, 422951167, 423882096,\n            424814390, 425748050, 426683077, 427619472, 428557236, 429496370, 430436875, 431378752,\n            432322002, 433266626, 434212625, 435160000, 436108752, 437058882, 438010391, 438963280,\n            439917550, 440873202, 441830237, 442788656, 443748460, 444709650, 445672227, 446636192,\n            447601546, 448568290, 449536425, 450505952, 451476872, 452449186, 453422895, 454398000,\n            455374502, 456352402, 457331701, 458312400, 459294500, 460278002, 461262907, 462249216,\n            463236930, 464226050, 465216577, 466208512, 467201856, 468196610, 469192775, 470190352,\n            471189342, 472189746, 473191565, 474194800, 475199452, 476205522, 477213011, 478221920,\n            479232250, 480244002, 481257177, 482271776, 483287800, 484305250, 485324127, 486344432,\n            487366166, 488389330, 489413925, 490439952, 491467412, 492496306, 493526635, 494558400,\n            495591602, 496626242, 497662321, 498699840, 499738800, 500779202, 501821047, 502864336,\n            503909070, 504955250, 506002877, 507051952, 508102476, 509154450, 510207875, 511262752,\n            512319082, 513376866, 514436105, 515496800, 516558952, 517622562, 518687631, 519754160,\n            520822150, 521891602, 522962517, 524034896, 525108740, 526184050, 527260827, 528339072,\n            529418786, 530499970, 531582625, 532666752, 533752352, 534839426, 535927975, 537018000,\n            538109502, 539202482, 540296941, 541392880, 542490300, 543589202, 544689587, 545791456,\n            546894810, 547999650, 549105977, 550213792, 551323096, 552433890, 553546175, 554659952,\n            555775222, 556891986, 558010245, 559130000, 560251252, 561374002, 562498251, 563624000,\n            564751250, 565880002, 567010257, 568142016, 569275280, 570410050, 571546327, 572684112,\n            573823406, 574964210, 576106525, 577250352, 578395692, 579542546, 580690915, 581840800,\n            582992202, 584145122, 585299561, 586455520, 587613000, 588772002, 589932527, 591094576,\n            592258150, 593423250, 594589877, 595758032, 596927716, 598098930, 599271675, 600445952,\n            601621762, 602799106, 603977985, 605158400, 606340352, 607523842, 608708871, 609895440,\n            611083550, 612273202, 613464397, 614657136, 615851420, 617047250, 618244627, 619443552,\n            620644026, 621846050, 623049625, 624254752, 625461432, 626669666, 627879455, 629090800,\n            630303702, 631518162, 632734181, 633951760, 635170900, 636391602, 637613867, 638837696,\n            640063090, 641290050, 642518577, 643748672, 644980336, 646213570, 647448375, 648684752,\n            649922702, 651162226, 652403325, 653646000, 654890252, 656136082, 657383491, 658632480,\n            659883050, 661135202, 662388937, 663644256, 664901160, 666159650, 667419727, 668681392,\n            669944646, 671209490, 672475925, 673743952, 675013572, 676284786, 677557595, 678832000,\n            680108002, 681385602, 682664801, 683945600, 685228000, 686512002, 687797607, 689084816,\n            690373630, 691664050, 692956077, 694249712, 695544956, 696841810, 698140275, 699440352,\n            700742042, 702045346, 703350265, 704656800, 705964952, 707274722, 708586111, 709899120,\n            711213750, 712530002, 713847877, 715167376, 716488500, 717811250, 719135627, 720461632,\n            721789266, 723118530, 724449425, 725781952, 727116112, 728451906, 729789335, 731128400,\n            732469102, 733811442, 735155421, 736501040, 737848300, 739197202, 740547747, 741899936,\n            743253770, 744609250, 745966377, 747325152, 748685576, 750047650, 751411375, 752776752,\n            754143782, 755512466, 756882805, 758254800, 759628452, 761003762, 762380731, 763759360,\n            765139650, 766521602, 767905217, 769290496, 770677440, 772066050, 773456327, 774848272,\n            776241886, 777637170, 779034125, 780432752, 781833052, 783235026, 784638675, 786044000,\n            787451002, 788859682, 790270041, 791682080, 793095800, 794511202, 795928287, 797347056,\n            798767510, 800189650, 801613477, 803038992, 804466196, 805895090, 807325675, 808757952,\n            810191922, 811627586, 813064945, 814504000, 815944752, 817387202, 818831351, 820277200,\n            821724750, 823174002, 824624957, 826077616, 827531980, 828988050, 830445827, 831905312,\n            833366506, 834829410, 836294025, 837760352, 839228392, 840698146, 842169615, 843642800,\n            845117702, 846594322, 848072661, 849552720, 851034500, 852518002, 854003227, 855490176,\n            856978850, 858469250, 859961377, 861455232, 862950816, 864448130, 865947175, 867447952,\n            868950462, 870454706, 871960685, 873468400, 874977852, 876489042, 878001971, 879516640,\n            881033050, 882551202, 884071097, 885592736, 887116120, 888641250, 890168127, 891696752,\n            893227126, 894759250, 896293125, 897828752, 899366132, 900905266, 902446155, 903988800,\n            905533202, 907079362, 908627281, 910176960, 911728400, 913281602, 914836567, 916393296,\n            917951790, 919512050, 921074077, 922637872, 924203436, 925770770, 927339875, 928910752,\n            930483402, 932057826, 933634025, 935212000, 936791752, 938373282, 939956591, 941541680,\n            943128550, 944717202, 946307637, 947899856, 949493860, 951089650, 952687227, 954286592,\n            955887746, 957490690, 959095425, 960701952, 962310272, 963920386, 965532295, 967146000,\n            968761502, 970378802, 971997901, 973618800, 975241500, 976866002, 978492307, 980120416,\n            981750330, 983382050, 985015577, 986650912, 988288056, 989927010, 991567775, 993210352,\n            994854742, 996500946, 998148965, 999798800, 1001450452, 1003103922, 1004759211,\n            1006416320, 1008075250, 1009736002, 1011398577, 1013062976, 1014729200, 1016397250,\n            1018067127, 1019738832, 1021412366, 1023087730, 1024764925, 1026443952, 1028124812,\n            1029807506, 1031492035, 1033178400, 1034866602, 1036556642, 1038248521, 1039942240,\n            1041637800, 1043335202, 1045034447, 1046735536, 1048438470, 1050143250, 1051849877,\n            1053558352, 1055268676, 1056980850, 1058694875, 1060410752, 1062128482, 1063848066,\n            1065569505, 1067292800, 1069017952, 1070744962, 1072473831, 1074204560, 1075937150,\n            1077671602, 1079407917, 1081146096, 1082886140, 1084628050, 1086371827, 1088117472,\n            1089864986, 1091614370, 1093365625, 1095118752, 1096873752, 1098630626, 1100389375,\n            1102150000, 1103912502, 1105676882, 1107443141, 1109211280, 1110981300, 1112753202,\n            1114526987, 1116302656, 1118080210, 1119859650, 1121640977, 1123424192, 1125209296,\n            1126996290, 1128785175, 1130575952, 1132368622, 1134163186, 1135959645, 1137758000,\n            1139558252, 1141360402, 1143164451, 1144970400, 1146778250, 1148588002, 1150399657,\n            1152213216, 1154028680, 1155846050, 1157665327, 1159486512, 1161309606, 1163134610,\n            1164961525, 1166790352, 1168621092, 1170453746, 1172288315, 1174124800, 1175963202,\n            1177803522, 1179645761, 1181489920, 1183336000, 1185184002, 1187033927, 1188885776,\n            1190739550, 1192595250, 1194452877, 1196312432, 1198173916, 1200037330, 1201902675,\n            1203769952, 1205639162, 1207510306, 1209383385, 1211258400, 1213135352, 1215014242,\n            1216895071, 1218777840, 1220662550, 1222549202, 1224437797, 1226328336, 1228220820,\n            1230115250, 1232011627, 1233909952, 1235810226, 1237712450, 1239616625, 1241522752,\n            1243430832, 1245340866, 1247252855, 1249166800, 1251082702, 1253000562, 1254920381,\n            1256842160, 1258765900, 1260691602, 1262619267, 1264548896, 1266480490, 1268414050,\n            1270349577, 1272287072, 1274226536, 1276167970, 1278111375, 1280056752, 1282004102,\n            1283953426, 1285904725, 1287858000, 1289813252, 1291770482, 1293729691, 1295690880,\n            1297654050, 1299619202, 1301586337, 1303555456, 1305526560, 1307499650, 1309474727,\n            1311451792, 1313430846, 1315411890, 1317394925, 1319379952, 1321366972, 1323355986,\n            1325346995, 1327340000, 1329335002, 1331332002, 1333331001, 1335332000, 1337335000,\n            1339340002, 1341347007, 1343356016, 1345367030, 1347380050, 1349395077, 1351412112,\n            1353431156, 1355452210, 1357475275, 1359500352, 1361527442, 1363556546, 1365587665,\n            1367620800, 1369655952, 1371693122, 1373732311, 1375773520, 1377816750, 1379862002,\n            1381909277, 1383958576, 1386009900, 1388063250, 1390118627, 1392176032, 1394235466,\n            1396296930, 1398360425, 1400425952, 1402493512, 1404563106, 1406634735, 1408708400,\n            1410784102, 1412861842, 1414941621, 1417023440, 1419107300, 1421193202, 1423281147,\n            1425371136, 1427463170, 1429557250, 1431653377, 1433751552, 1435851776, 1437954050,\n            1440058375, 1442164752, 1444273182, 1446383666, 1448496205, 1450610800, 1452727452,\n            1454846162, 1456966931, 1459089760, 1461214650, 1463341602, 1465470617, 1467601696,\n            1469734840, 1471870050, 1474007327, 1476146672, 1478288086, 1480431570, 1482577125,\n            1484724752, 1486874452, 1489026226, 1491180075, 1493336000, 1495494002, 1497654082,\n            1499816241, 1501980480, 1504146800, 1506315202, 1508485687, 1510658256, 1512832910,\n            1515009650, 1517188477, 1519369392, 1521552396, 1523737490, 1525924675, 1528113952,\n            1530305322, 1532498786, 1534694345, 1536892000, 1539091752, 1541293602, 1543497551,\n            1545703600, 1547911750, 1550122002, 1552334357, 1554548816, 1556765380, 1558984050,\n            1561204827, 1563427712, 1565652706, 1567879810, 1570109025, 1572340352, 1574573792,\n            1576809346, 1579047015, 1581286800, 1583528702, 1585772722, 1588018861, 1590267120,\n            1592517500, 1594770002, 1597024627, 1599281376, 1601540250, 1603801250, 1606064377,\n            1608329632, 1610597016, 1612866530, 1615138175, 1617411952, 1619687862, 1621965906,\n            1624246085, 1626528400, 1628812852, 1631099442, 1633388171, 1635679040, 1637972050,\n            1640267202, 1642564497, 1644863936, 1647165520, 1649469250, 1651775127, 1654083152,\n            1656393326, 1658705650, 1661020125, 1663336752, 1665655532, 1667976466, 1670299555,\n            1672624800, 1674952202, 1677281762, 1679613481, 1681947360, 1684283400, 1686621602,\n            1688961967, 1691304496, 1693649190, 1695996050, 1698345077, 1700696272, 1703049636,\n            1705405170, 1707762875, 1710122752, 1712484802, 1714849026, 1717215425, 1719584000,\n            1721954752, 1724327682, 1726702791, 1729080080, 1731459550, 1733841202, 1736225037,\n            1738611056, 1740999260, 1743389650, 1745782227, 1748176992, 1750573946, 1752973090,\n            1755374425, 1757777952, 1760183672, 1762591586, 1765001695, 1767414000, 1769828502,\n            1772245202, 1774664101, 1777085200, 1779508500, 1781934002, 1784361707, 1786791616,\n            1789223730, 1791658050, 1794094577, 1796533312, 1798974256, 1801417410, 1803862775,\n            1806310352, 1808760142, 1811212146, 1813666365, 1816122800, 1818581452, 1821042322,\n            1823505411, 1825970720, 1828438250, 1830908002, 1833379977, 1835854176, 1838330600,\n            1840809250, 1843290127, 1845773232, 1848258566, 1850746130, 1853235925, 1855727952,\n            1858222212, 1860718706, 1863217435, 1865718400, 1868221602, 1870727042, 1873234721,\n            1875744640, 1878256800, 1880771202, 1883287847, 1885806736, 1888327870, 1890851250,\n            1893376877, 1895904752, 1898434876, 1900967250, 1903501875, 1906038752, 1908577882,\n            1911119266, 1913662905, 1916208800, 1918756952, 1921307362, 1923860031, 1926414960,\n            1928972150, 1931531602, 1934093317, 1936657296, 1939223540, 1941792050, 1944362827,\n            1946935872, 1949511186, 1952088770, 1954668625, 1957250752, 1959835152, 1962421826,\n            1965010775, 1967602000, 1970195502, 1972791282, 1975389341, 1977989680, 1980592300,\n            1983197202, 1985804387, 1988413856, 1991025610, 1993639650, 1996255977, 1998874592,\n            2001495496, 2004118690, 2006744175, 2009371952, 2012002022, 2014634386, 2017269045,\n            2019906000, 2022545252, 2025186802, 2027830651, 2030476800, 2033125250, 2035776002,\n            2038429057, 2041084416, 2043742080, 2046402050, 2049064327, 2051728912, 2054395806,\n            2057065010, 2059736525, 2062410352, 2065086492, 2067764946, 2070445715, 2073128800,\n            2075814202, 2078501922, 2081191961, 2083884320, 2086579000, 2089276002, 2091975327,\n            2094676976, 2097380950, 2100087250, 2102795877, 2105506832, 2108220116, 2110935730,\n            2113653675, 2116373952, 2119096562, 2121821506, 2124548785, 2127278400, 2130010352,\n            2132744642, 2135481271, 2138220240, 2140961550, 2143705202, 2146451197, 2149199536,\n            2151950220, 2154703250, 2157458627, 2160216352, 2162976426, 2165738850, 2168503625,\n            2171270752, 2174040232, 2176812066, 2179586255, 2182362800, 2185141702, 2187922962,\n            2190706581, 2193492560, 2196280900, 2199071602, 2201864667, 2204660096, 2207457890,\n            2210258050, 2213060577, 2215865472, 2218672736, 2221482370, 2224294375, 2227108752,\n            2229925502, 2232744626, 2235566125, 2238390000, 2241216252, 2244044882, 2246875891,\n            2249709280, 2252545050, 2255383202, 2258223737, 2261066656, 2263911960, 2266759650,\n            2269609727, 2272462192, 2275317046, 2278174290, 2281033925, 2283895952, 2286760372,\n            2289627186, 2292496395, 2295368000, 2298242002, 2301118402, 2303997201, 2306878400,\n            2309762000, 2312648002, 2315536407, 2318427216, 2321320430, 2324216050, 2327114077,\n            2330014512, 2332917356, 2335822610, 2338730275, 2341640352, 2344552842, 2347467746,\n            2350385065, 2353304800, 2356226952, 2359151522, 2362078511, 2365007920, 2367939750,\n            2370874002, 2373810677, 2376749776, 2379691300, 2382635250, 2385581627, 2388530432,\n            2391481666, 2394435330, 2397391425, 2400349952, 2403310912, 2406274306, 2409240135,\n            2412208400, 2415179102, 2418152242, 2421127821, 2424105840, 2427086300, 2430069202,\n            2433054547, 2436042336, 2439032570, 2442025250, 2445020377, 2448017952, 2451017976,\n            2454020450, 2457025375, 2460032752, 2463042582, 2466054866, 2469069605, 2472086800,\n            2475106452, 2478128562, 2481153131, 2484180160, 2487209650, 2490241602, 2493276017,\n            2496312896, 2499352240, 2502394050, 2505438327, 2508485072, 2511534286, 2514585970,\n            2517640125, 2520696752, 2523755852, 2526817426, 2529881475, 2532948000, 2536017002,\n            2539088482, 2542162441, 2545238880, 2548317800, 2551399202, 2554483087, 2557569456,\n            2560658310, 2563749650, 2566843477, 2569939792, 2573038596, 2576139890, 2579243675,\n            2582349952, 2585458722, 2588569986, 2591683745, 2594800000, 2597918752, 2601040002,\n            2604163751, 2607290000, 2610418750, 2613550002, 2616683757, 2619820016, 2622958780,\n            2626100050, 2629243827, 2632390112, 2635538906, 2638690210, 2641844025, 2645000352,\n            2648159192, 2651320546, 2654484415, 2657650800, 2660819702, 2663991122, 2667165061,\n            2670341520, 2673520500, 2676702002, 2679886027, 2683072576, 2686261650, 2689453250,\n            2692647377, 2695844032, 2699043216, 2702244930, 2705449175, 2708655952, 2711865262,\n            2715077106, 2718291485, 2721508400, 2724727852, 2727949842, 2731174371, 2734401440,\n            2737631050, 2740863202, 2744097897, 2747335136, 2750574920, 2753817250, 2757062127,\n            2760309552, 2763559526, 2766812050, 2770067125, 2773324752, 2776584932, 2779847666,\n            2783112955, 2786380800, 2789651202, 2792924162, 2796199681, 2799477760, 2802758400,\n            2806041602, 2809327367, 2812615696, 2815906590, 2819200050, 2822496077, 2825794672,\n            2829095836, 2832399570, 2835705875, 2839014752, 2842326202, 2845640226, 2848956825,\n            2852276000, 2855597752, 2858922082, 2862248991, 2865578480, 2868910550, 2872245202,\n            2875582437, 2878922256, 2882264660, 2885609650, 2888957227, 2892307392, 2895660146,\n            2899015490, 2902373425, 2905733952, 2909097072, 2912462786, 2915831095, 2919202000,\n            2922575502, 2925951602, 2929330301, 2932711600, 2936095500, 2939482002, 2942871107,\n            2946262816, 2949657130, 2953054050, 2956453577, 2959855712, 2963260456, 2966667810,\n            2970077775, 2973490352, 2976905542, 2980323346, 2983743765, 2987166800, 2990592452,\n            2994020722, 2997451611, 3000885120, 3004321250, 3007760002, 3011201377, 3014645376,\n            3018092000, 3021541250, 3024993127, 3028447632, 3031904766, 3035364530, 3038826925,\n            3042291952, 3045759612, 3049229906, 3052702835, 3056178400, 3059656602, 3063137442,\n            3066620921, 3070107040, 3073595800, 3077087202, 3080581247, 3084077936, 3087577270,\n            3091079250, 3094583877, 3098091152, 3101601076, 3105113650, 3108628875, 3112146752,\n            3115667282, 3119190466, 3122716305, 3126244800, 3129775952, 3133309762, 3136846231,\n            3140385360, 3143927150, 3147471602, 3151018717, 3154568496, 3158120940, 3161676050,\n            3165233827, 3168794272, 3172357386, 3175923170, 3179491625, 3183062752, 3186636552,\n            3190213026, 3193792175, 3197374000, 3200958502, 3204545682, 3208135541, 3211728080,\n            3215323300, 3218921202, 3222521787, 3226125056, 3229731010, 3233339650, 3236950977,\n            3240564992, 3244181696, 3247801090, 3251423175, 3255047952, 3258675422, 3262305586,\n            3265938445, 3269574000, 3273212252, 3276853202, 3280496851, 3284143200, 3287792250,\n            3291444002, 3295098457, 3298755616, 3302415480, 3306078050, 3309743327, 3313411312,\n            3317082006, 3320755410, 3324431525, 3328110352, 3331791892, 3335476146, 3339163115,\n            3342852800, 3346545202, 3350240322, 3353938161, 3357638720, 3361342000, 3365048002,\n            3368756727, 3372468176, 3376182350, 3379899250, 3383618877, 3387341232, 3391066316,\n            3394794130, 3398524675, 3402257952, 3405993962, 3409732706, 3413474185, 3417218400,\n            3420965352, 3424715042, 3428467471, 3432222640, 3435980550, 3439741202, 3443504597,\n            3447270736, 3451039620, 3454811250, 3458585627, 3462362752, 3466142626, 3469925250,\n            3473710625, 3477498752, 3481289632, 3485083266, 3488879655, 3492678800, 3496480702,\n            3500285362, 3504092781, 3507902960, 3511715900, 3515531602, 3519350067, 3523171296,\n            3526995290, 3530822050, 3534651577, 3538483872, 3542318936, 3546156770, 3549997375,\n            3553840752, 3557686902, 3561535826, 3565387525, 3569242000, 3573099252, 3576959282,\n            3580822091, 3584687680, 3588556050, 3592427202, 3596301137, 3600177856, 3604057360,\n            3607939650, 3611824727, 3615712592, 3619603246, 3623496690, 3627392925, 3631291952,\n            3635193772, 3639098386, 3643005795, 3646916000, 3650829002, 3654744802, 3658663401,\n            3662584800, 3666509000, 3670436002, 3674365807, 3678298416, 3682233830, 3686172050,\n            3690113077, 3694056912, 3698003556, 3701953010, 3705905275, 3709860352, 3713818242,\n            3717778946, 3721742465, 3725708800, 3729677952, 3733649922, 3737624711, 3741602320,\n            3745582750, 3749566002, 3753552077, 3757540976, 3761532700, 3765527250, 3769524627,\n            3773524832, 3777527866, 3781533730, 3785542425, 3789553952, 3793568312, 3797585506,\n            3801605535, 3805628400, 3809654102, 3813682642, 3817714021, 3821748240, 3825785300,\n            3829825202, 3833867947, 3837913536, 3841961970, 3846013250, 3850067377, 3854124352,\n            3858184176, 3862246850, 3866312375, 3870380752, 3874451982, 3878526066, 3882603005,\n            3886682800, 3890765452, 3894850962, 3898939331, 3903030560, 3907124650, 3911221602,\n            3915321417, 3919424096, 3923529640, 3927638050, 3931749327, 3935863472, 3939980486,\n            3944100370, 3948223125, 3952348752, 3956477252, 3960608626, 3964742875, 3968880000,\n            3973020002, 3977162882, 3981308641, 3985457280, 3989608800, 3993763202, 3997920487,\n            4002080656, 4006243710, 4010409650, 4014578477, 4018750192, 4022924796, 4027102290,\n            4031282675, 4035465952, 4039652122, 4043841186, 4048033145, 4052228000, 4056425752,\n            4060626402, 4064829951, 4069036400, 4073245750, 4077458002, 4081673157, 4085891216,\n            4090112180, 4094336050, 4098562827, 4102792512, 4107025106, 4111260610, 4115499025,\n            4119740352, 4123984592, 4128231746, 4132481815, 4136734800, 4140990702, 4145249522,\n            4149511261, 4153775920, 4158043500, 4162314002, 4166587427, 4170863776, 4175143050,\n            4179425250, 4183710377, 4187998432, 4192289416, 4196583330, 4200880175, 4205179952,\n            4209482662, 4213788306, 4218096885, 4222408400, 4226722852, 4231040242, 4235360571,\n            4239683840, 4244010050, 4248339202, 4252671297, 4257006336, 4261344320, 4265685250,\n            4270029127, 4274375952, 4278725726, 4283078450, 4287434125, 4291792752, 1187036,\n            5551571, 9919060, 14289505, 18662907, 23039267, 27418586, 31800865, 36186105, 40574307,\n            44965472, 49359601, 53756695, 58156755, 62559782, 66965777, 71374741, 75786675,\n            80201580, 84619457, 89040307, 93464131, 97890930, 102320705, 106753457, 111189187,\n            115627896, 120069585, 124514255, 128961907, 133412542, 137866161, 142322765, 146782355,\n            151244932, 155710497, 160179051, 164650595, 169125130, 173602657, 178083177, 182566691,\n            187053200, 191542705, 196035207, 200530707, 205029206, 209530705, 214035205, 218542707,\n            223053212, 227566721, 232083235, 236602755, 241125282, 245650817, 250179361, 254710915,\n            259245480, 263783057, 268323647, 272867251, 277413870, 281963505, 286516157, 291071827,\n            295630516, 300192225, 304756955, 309324707, 313895482, 318469281, 323046105, 327625955,\n            332208832, 336794737, 341383671, 345975635, 350570630, 355168657, 359769717, 364373811,\n            368980940, 373591105, 378204307, 382820547, 387439826, 392062145, 396687505, 401315907,\n            405947352, 410581841, 415219375, 419859955, 424503582, 429150257, 433799981, 438452755,\n            443108580, 447767457, 452429387, 457094371, 461762410, 466433505, 471107657, 475784867,\n            480465136, 485148465, 489834855, 494524307, 499216822, 503912401, 508611045, 513312755,\n            518017532, 522725377, 527436291, 532150275, 536867330, 541587457, 546310657, 551036931,\n            555766280, 560498705, 565234207, 569972787, 574714446, 579459185, 584207005, 588957907,\n            593711892, 598468961, 603229115, 607992355, 612758682, 617528097, 622300601, 627076195,\n            631854880, 636636657, 641421527, 646209491, 651000550, 655794705, 660591957, 665392307,\n            670195756, 675002305, 679811955, 684624707, 689440562, 694259521, 699081585, 703906755,\n            708735032, 713566417, 718400911, 723238515, 728079230, 732923057, 737769997, 742620051,\n            747473220, 752329505, 757188907, 762051427, 766917066, 771785825, 776657705, 781532707,\n            786410832, 791292081, 796176455, 801063955, 805954582, 810848337, 815745221, 820645235,\n            825548380, 830454657, 835364067, 840276611, 845192290, 850111105, 855033057, 859958147,\n            864886376, 869817745, 874752255, 879689907, 884630702, 889574641, 894521725, 899471955,\n            904425332, 909381857, 914341531, 919304355, 924270330, 929239457, 934211737, 939187171,\n            944165760, 949147505, 954132407, 959120467, 964111686, 969106065, 974103605, 979104307,\n            984108172, 989115201, 994125395, 999138755, 1004155282, 1009174977, 1014197841,\n            1019223875, 1024253080, 1029285457, 1034321007, 1039359731, 1044401630, 1049446705,\n            1054494957, 1059546387, 1064600996, 1069658785, 1074719755, 1079783907, 1084851242,\n            1089921761, 1094995465, 1100072355, 1105152432, 1110235697, 1115322151, 1120411795,\n            1125504630, 1130600657, 1135699877, 1140802291, 1145907900, 1151016705, 1156128707,\n            1161243907, 1166362306, 1171483905, 1176608705, 1181736707, 1186867912, 1192002321,\n            1197139935, 1202280755, 1207424782, 1212572017, 1217722461, 1222876115, 1228032980,\n            1233193057, 1238356347, 1243522851, 1248692570, 1253865505, 1259041657, 1264221027,\n            1269403616, 1274589425, 1279778455, 1284970707, 1290166182, 1295364881, 1300566805,\n            1305771955, 1310980332, 1316191937, 1321406771, 1326624835, 1331846130, 1337070657,\n            1342298417, 1347529411, 1352763640, 1358001105, 1363241807, 1368485747, 1373732926,\n            1378983345, 1384237005, 1389493907, 1394754052, 1400017441, 1405284075, 1410553955,\n            1415827082, 1421103457, 1426383081, 1431665955, 1436952080, 1442241457, 1447534087,\n            1452829971, 1458129110, 1463431505, 1468737157, 1474046067, 1479358236, 1484673665,\n            1489992355, 1495314307, 1500639522, 1505968001, 1511299745, 1516634755, 1521973032,\n            1527314577, 1532659391, 1538007475, 1543358830, 1548713457, 1554071357, 1559432531,\n            1564796980, 1570164705, 1575535707, 1580909987, 1586287546, 1591668385, 1597052505,\n            1602439907, 1607830592, 1613224561, 1618621815, 1624022355, 1629426182, 1634833297,\n            1640243701, 1645657395, 1651074380, 1656494657, 1661918227, 1667345091, 1672775250,\n            1678208705, 1683645457, 1689085507, 1694528856, 1699975505, 1705425455, 1710878707,\n            1716335262, 1721795121, 1727258285, 1732724755, 1738194532, 1743667617, 1749144011,\n            1754623715, 1760106730, 1765593057, 1771082697, 1776575651, 1782071920, 1787571505,\n            1793074407, 1798580627, 1804090166, 1809603025, 1815119205, 1820638707, 1826161532,\n            1831687681, 1837217155, 1842749955, 1848286082, 1853825537, 1859368321, 1864914435,\n            1870463880, 1876016657, 1881572767, 1887132211, 1892694990, 1898261105, 1903830557,\n            1909403347, 1914979476, 1920558945, 1926141755, 1931727907, 1937317402, 1942910241,\n            1948506425, 1954105955, 1959708832, 1965315057, 1970924631, 1976537555, 1982153830,\n            1987773457, 1993396437, 1999022771, 2004652460, 2010285505, 2015921907, 2021561667,\n            2027204786, 2032851265, 2038501105, 2044154307, 2049810872, 2055470801, 2061134095,\n            2066800755, 2072470782, 2078144177, 2083820941, 2089501075, 2095184580, 2100871457,\n            2106561707, 2112255331, 2117952330, 2123652705, 2129356457, 2135063587, 2140774096,\n            2146487985, 2152205255, 2157925907, 2163649942, 2169377361, 2175108165, 2180842355,\n            2186579932, 2192320897, 2198065251, 2203812995, 2209564130, 2215318657, 2221076577,\n            2226837891, 2232602600, 2238370705, 2244142207, 2249917107, 2255695406, 2261477105,\n            2267262205, 2273050707, 2278842612, 2284637921, 2290436635, 2296238755, 2302044282,\n            2307853217, 2313665561, 2319481315, 2325300480, 2331123057, 2336949047, 2342778451,\n            2348611270, 2354447505, 2360287157, 2366130227, 2371976716, 2377826625, 2383679955,\n            2389536707, 2395396882, 2401260481, 2407127505, 2412997955, 2418871832, 2424749137,\n            2430629871, 2436514035, 2442401630, 2448292657, 2454187117, 2460085011, 2465986340,\n            2471891105, 2477799307, 2483710947, 2489626026, 2495544545, 2501466505, 2507391907,\n            2513320752, 2519253041, 2525188775, 2531127955, 2537070582, 2543016657, 2548966181,\n            2554919155, 2560875580, 2566835457, 2572798787, 2578765571, 2584735810, 2590709505,\n            2596686657, 2602667267, 2608651336, 2614638865, 2620629855, 2626624307, 2632622222,\n            2638623601, 2644628445, 2650636755, 2656648532, 2662663777, 2668682491, 2674704675,\n            2680730330, 2686759457, 2692792057, 2698828131, 2704867680, 2710910705, 2716957207,\n            2723007187, 2729060646, 2735117585, 2741178005, 2747241907, 2753309292, 2759380161,\n            2765454515, 2771532355, 2777613682, 2783698497, 2789786801, 2795878595, 2801973880,\n            2808072657, 2814174927, 2820280691, 2826389950, 2832502705, 2838618957, 2844738707,\n            2850861956, 2856988705, 2863118955, 2869252707, 2875389962, 2881530721, 2887674985,\n            2893822755, 2899974032, 2906128817, 2912287111, 2918448915, 2924614230, 2930783057,\n            2936955397, 2943131251, 2949310620, 2955493505, 2961679907, 2967869827, 2974063266,\n            2980260225, 2986460705, 2992664707, 2998872232, 3005083281, 3011297855, 3017515955,\n            3023737582, 3029962737, 3036191421, 3042423635, 3048659380, 3054898657, 3061141467,\n            3067387811, 3073637690, 3079891105, 3086148057, 3092408547, 3098672576, 3104940145,\n            3111211255, 3117485907, 3123764102, 3130045841, 3136331125, 3142619955, 3148912332,\n            3155208257, 3161507731, 3167810755, 3174117330, 3180427457, 3186741137, 3193058371,\n            3199379160, 3205703505, 3212031407, 3218362867, 3224697886, 3231036465, 3237378605,\n            3243724307, 3250073572, 3256426401, 3262782795, 3269142755, 3275506282, 3281873377,\n            3288244041, 3294618275, 3300996080, 3307377457, 3313762407, 3320150931, 3326543030,\n            3332938705, 3339337957, 3345740787, 3352147196, 3358557185, 3364970755, 3371387907,\n            3377808642, 3384232961, 3390660865, 3397092355, 3403527432, 3409966097, 3416408351,\n            3422854195, 3429303630, 3435756657, 3442213277, 3448673491, 3455137300, 3461604705,\n            3468075707, 3474550307, 3481028506, 3487510305, 3493995705, 3500484707, 3506977312,\n            3513473521, 3519973335, 3526476755, 3532983782, 3539494417, 3546008661, 3552526515,\n            3559047980, 3565573057, 3572101747, 3578634051, 3585169970, 3591709505, 3598252657,\n            3604799427, 3611349816, 3617903825, 3624461455, 3631022707, 3637587582, 3644156081,\n            3650728205, 3657303955, 3663883332, 3670466337, 3677052971, 3683643235, 3690237130,\n            3696834657, 3703435817, 3710040611, 3716649040, 3723261105, 3729876807, 3736496147,\n            3743119126, 3749745745, 3756376005, 3763009907, 3769647452, 3776288641, 3782933475,\n            3789581955, 3796234082, 3802889857, 3809549281, 3816212355, 3822879080, 3829549457,\n            3836223487, 3842901171, 3849582510, 3856267505, 3862956157, 3869648467, 3876344436,\n            3883044065, 3889747355, 3896454307, 3903164922, 3909879201, 3916597145, 3923318755,\n            3930044032, 3936772977, 3943505591, 3950241875, 3956981830, 3963725457, 3970472757,\n            3977223731, 3983978380, 3990736705, 3997498707, 4004264387, 4011033746, 4017806785,\n            4024583505, 4031363907, 4038147992, 4044935761, 4051727215, 4058522355, 4065321182,\n            4072123697, 4078929901, 4085739795, 4092553380, 4099370657, 4106191627, 4113016291,\n            4119844650, 4126676705, 4133512457, 4140351907, 4147195056, 4154041905, 4160892455,\n            4167746707, 4174604662, 4181466321, 4188331685, 4195200755, 4202073532, 4208950017,\n            4215830211, 4222714115, 4229601730, 4236493057, 4243388097, 4250286851, 4257189320,\n            4264095505, 4271005407, 4277919027, 4284836366, 4291757425, 3714909, 10643412,\n            17575637, 24511586, 31451260, 38394660, 45341787, 52292642, 59247226, 66205540,\n            73167585, 80133362, 87102872, 94076116, 101053095, 108033810, 115018262, 122006452,\n            128998381, 135994050, 142993460, 149996612, 157003507, 164014146, 171028530, 178046660,\n            185068537, 192094162, 199123536, 206156660, 213193535, 220234162, 227278542, 234326676,\n            241378565, 248434210, 255493612, 262556772, 269623691, 276694370, 283768810, 290847012,\n            297928977, 305014706, 312104200, 319197460, 326294487, 333395282, 340499846, 347608180,\n            354720285, 361836162, 368955812, 376079236, 383206435, 390337410, 397472162, 404610692,\n            411753001, 418899090, 426048960, 433202612, 440360047, 447521266, 454686270, 461855060,\n            469027637, 476204002, 483384156, 490568100, 497755835, 504947362, 512142682, 519341796,\n            526544705, 533751410, 540961912, 548176212, 555394311, 562616210, 569841910, 577071412,\n            584304717, 591541826, 598782740, 606027460, 613275987, 620528322, 627784466, 635044420,\n            642308185, 649575762, 656847152, 664122356, 671401375, 678684210, 685970862, 693261332,\n            700555621, 707853730, 715155660, 722461412, 729770987, 737084386, 744401610, 751722660,\n            759047537, 766376242, 773708776, 781045140, 788385335, 795729362, 803077222, 810428916,\n            817784445, 825143810, 832507012, 839874052, 847244931, 854619650, 861998210, 869380612,\n            876766857, 884156946, 891550880, 898948660, 906350287, 913755762, 921165086, 928578260,\n            935995285, 943416162, 950840892, 958269476, 965701915, 973138210, 980578362, 988022372,\n            995470241, 1002921970, 1010377560, 1017837012, 1025300327, 1032767506, 1040238550,\n            1047713460, 1055192237, 1062674882, 1070161396, 1077651780, 1085146035, 1092644162,\n            1100146162, 1107652036, 1115161785, 1122675410, 1130192912, 1137714292, 1145239551,\n            1152768690, 1160301710, 1167838612, 1175379397, 1182924066, 1190472620, 1198025060,\n            1205581387, 1213141602, 1220705706, 1228273700, 1235845585, 1243421362, 1251001032,\n            1258584596, 1266172055, 1273763410, 1281358662, 1288957812, 1296560861, 1304167810,\n            1311778660, 1319393412, 1327012067, 1334634626, 1342261090, 1349891460, 1357525737,\n            1365163922, 1372806016, 1380452020, 1388101935, 1395755762, 1403413502, 1411075156,\n            1418740725, 1426410210, 1434083612, 1441760932, 1449442171, 1457127330, 1464816410,\n            1472509412, 1480206337, 1487907186, 1495611960, 1503320660, 1511033287, 1518749842,\n            1526470326, 1534194740, 1541923085, 1549655362, 1557391572, 1565131716, 1572875795,\n            1580623810, 1588375762, 1596131652, 1603891481, 1611655250, 1619422960, 1627194612,\n            1634970207, 1642749746, 1650533230, 1658320660, 1666112037, 1673907362, 1681706636,\n            1689509860, 1697317035, 1705128162, 1712943242, 1720762276, 1728585265, 1736412210,\n            1744243112, 1752077972, 1759916791, 1767759570, 1775606310, 1783457012, 1791311677,\n            1799170306, 1807032900, 1814899460, 1822769987, 1830644482, 1838522946, 1846405380,\n            1854291785, 1862182162, 1870076512, 1877974836, 1885877135, 1893783410, 1901693662,\n            1909607892, 1917526101, 1925448290, 1933374460, 1941304612, 1949238747, 1957176866,\n            1965118970, 1973065060, 1981015137, 1988969202, 1996927256, 2004889300, 2012855335,\n            2020825362, 2028799382, 2036777396, 2044759405, 2052745410, 2060735412, 2068729412,\n            2076727411, 2084729410, 2092735410, 2100745412, 2108759417, 2116777426, 2124799440,\n            2132825460, 2140855487, 2148889522, 2156927566, 2164969620, 2173015685, 2181065762,\n            2189119852, 2197177956, 2205240075, 2213306210, 2221376362, 2229450532, 2237528721,\n            2245610930, 2253697160, 2261787412, 2269881687, 2277979986, 2286082310, 2294188660,\n            2302299037, 2310413442, 2318531876, 2326654340, 2334780835, 2342911362, 2351045922,\n            2359184516, 2367327145, 2375473810, 2383624512, 2391779252, 2399938031, 2408100850,\n            2416267710, 2424438612, 2432613557, 2440792546, 2448975580, 2457162660, 2465353787,\n            2473548962, 2481748186, 2489951460, 2498158785, 2506370162, 2514585592, 2522805076,\n            2531028615, 2539256210, 2547487862, 2555723572, 2563963341, 2572207170, 2580455060,\n            2588707012, 2596963027, 2605223106, 2613487250, 2621755460, 2630027737, 2638304082,\n            2646584496, 2654868980, 2663157535, 2671450162, 2679746862, 2688047636, 2696352485,\n            2704661410, 2712974412, 2721291492, 2729612651, 2737937890, 2746267210, 2754600612,\n            2762938097, 2771279666, 2779625320, 2787975060, 2796328887, 2804686802, 2813048806,\n            2821414900, 2829785085, 2838159362, 2846537732, 2854920196, 2863306755, 2871697410,\n            2880092162, 2888491012, 2896893961, 2905301010, 2913712160, 2922127412, 2930546767,\n            2938970226, 2947397790, 2955829460, 2964265237, 2972705122, 2981149116, 2989597220,\n            2998049435, 3006505762, 3014966202, 3023430756, 3031899425, 3040372210, 3048849112,\n            3057330132, 3065815271, 3074304530, 3082797910, 3091295412, 3099797037, 3108302786,\n            3116812660, 3125326660, 3133844787, 3142367042, 3150893426, 3159423940, 3167958585,\n            3176497362, 3185040272, 3193587316, 3202138495, 3210693810, 3219253262, 3227816852,\n            3236384581, 3244956450, 3253532460, 3262112612, 3270696907, 3279285346, 3287877930,\n            3296474660, 3305075537, 3313680562, 3322289736, 3330903060, 3339520535, 3348142162,\n            3356767942, 3365397876, 3374031965, 3382670210, 3391312612, 3399959172, 3408609891,\n            3417264770, 3425923810, 3434587012, 3443254377, 3451925906, 3460601600, 3469281460,\n            3477965487, 3486653682, 3495346046, 3504042580, 3512743285, 3521448162, 3530157212,\n            3538870436, 3547587835, 3556309410, 3565035162, 3573765092, 3582499201, 3591237490,\n            3599979960, 3608726612, 3617477447, 3626232466, 3634991670, 3643755060, 3652522637,\n            3661294402, 3670070356, 3678850500, 3687634835, 3696423362, 3705216082, 3714012996,\n            3722814105, 3731619410, 3740428912, 3749242612, 3758060511, 3766882610, 3775708910,\n            3784539412, 3793374117, 3802213026, 3811056140, 3819903460, 3828754987, 3837610722,\n            3846470666, 3855334820, 3864203185, 3873075762, 3881952552, 3890833556, 3899718775,\n            3908608210, 3917501862, 3926399732, 3935301821, 3944208130, 3953118660, 3962033412,\n            3970952387, 3979875586, 3988803010, 3997734660, 4006670537, 4015610642, 4024554976,\n            4033503540, 4042456335, 4051413362, 4060374622, 4069340116, 4078309845, 4087283810,\n            4096262012, 4105244452, 4114231131, 4123222050, 4132217210, 4141216612, 4150220257,\n            4159228146, 4168240280, 4177256660, 4186277287, 4195302162, 4204331286, 4213364660,\n            4222402285, 4231444162, 4240490292, 4249540676, 4258595315, 4267654210, 4276717362,\n            4285784772, 4294856441, 8965074, 18045265, 27129717, 36218432, 45311411, 54408655,\n            63510165, 72615942, 81725987, 90840301, 99958885, 109081740, 118208867, 127340267,\n            136475941, 145615890, 154760115, 163908617, 173061397, 182218456, 191379795, 200545415,\n            209715317, 218889502, 228067971, 237250725, 246437765, 255629092, 264824707, 274024611,\n            283228805, 292437290, 301650067, 310867137, 320088501, 329314160, 338544115, 347778367,\n            357016917, 366259766, 375506915, 384758365, 394014117, 403274172, 412538531, 421807195,\n            431080165, 440357442, 449639027, 458924921, 468215125, 477509640, 486808467, 496111607,\n            505419061, 514730830, 524046915, 533367317, 542692037, 552021076, 561354435, 570692115,\n            580034117, 589380442, 598731091, 608086065, 617445365, 626808992, 636176947, 645549231,\n            654925845, 664306790, 673692067, 683081677, 692475621, 701873900, 711276515, 720683467,\n            730094757, 739510386, 748930355, 758354665, 767783317, 777216312, 786653651, 796095335,\n            805541365, 814991742, 824446467, 833905541, 843368965, 852836740, 862308867, 871785347,\n            881266181, 890751370, 900240915, 909734817, 919233077, 928735696, 938242675, 947754015,\n            957269717, 966789782, 976314211, 985843005, 995376165, 1004913692, 1014455587,\n            1024001851, 1033552485, 1043107490, 1052666867, 1062230617, 1071798741, 1081371240,\n            1090948115, 1100529367, 1110114997, 1119705006, 1129299395, 1138898165, 1148501317,\n            1158108852, 1167720771, 1177337075, 1186957765, 1196582842, 1206212307, 1215846161,\n            1225484405, 1235127040, 1244774067, 1254425487, 1264081301, 1273741510, 1283406115,\n            1293075117, 1302748517, 1312426316, 1322108515, 1331795115, 1341486117, 1351181522,\n            1360881331, 1370585545, 1380294165, 1390007192, 1399724627, 1409446471, 1419172725,\n            1428903390, 1438638467, 1448377957, 1458121861, 1467870180, 1477622915, 1487380067,\n            1497141637, 1506907626, 1516678035, 1526452865, 1536232117, 1546015792, 1555803891,\n            1565596415, 1575393365, 1585194742, 1595000547, 1604810781, 1614625445, 1624444540,\n            1634268067, 1644096027, 1653928421, 1663765250, 1673606515, 1683452217, 1693302357,\n            1703156936, 1713015955, 1722879415, 1732747317, 1742619662, 1752496451, 1762377685,\n            1772263365, 1782153492, 1792048067, 1801947091, 1811850565, 1821758490, 1831670867,\n            1841587697, 1851508981, 1861434720, 1871364915, 1881299567, 1891238677, 1901182246,\n            1911130275, 1921082765, 1931039717, 1941001132, 1950967011, 1960937355, 1970912165,\n            1980891442, 1990875187, 2000863401, 2010856085, 2020853240, 2030854867, 2040860967,\n            2050871541, 2060886590, 2070906115, 2080930117, 2090958597, 2100991556, 2111028995,\n            2121070915, 2131117317, 2141168202, 2151223571, 2161283425, 2171347765, 2181416592,\n            2191489907, 2201567711, 2211650005, 2221736790, 2231828067, 2241923837, 2252024101,\n            2262128860, 2272238115, 2282351867, 2292470117, 2302592866, 2312720115, 2322851865,\n            2332988117, 2343128872, 2353274131, 2363423895, 2373578165, 2383736942, 2393900227,\n            2404068021, 2414240325, 2424417140, 2434598467, 2444784307, 2454974661, 2465169530,\n            2475368915, 2485572817, 2495781237, 2505994176, 2516211635, 2526433615, 2536660117,\n            2546891142, 2557126691, 2567366765, 2577611365, 2587860492, 2598114147, 2608372331,\n            2618635045, 2628902290, 2639174067, 2649450377, 2659731221, 2670016600, 2680306515,\n            2690600967, 2700899957, 2711203486, 2721511555, 2731824165, 2742141317, 2752463012,\n            2762789251, 2773120035, 2783455365, 2793795242, 2804139667, 2814488641, 2824842165,\n            2835200240, 2845562867, 2855930047, 2866301781, 2876678070, 2887058915, 2897444317,\n            2907834277, 2918228796, 2928627875, 2939031515, 2949439717, 2959852482, 2970269811,\n            2980691705, 2991118165, 3001549192, 3011984787, 3022424951, 3032869685, 3043318990,\n            3053772867, 3064231317, 3074694341, 3085161940, 3095634115, 3106110867, 3116592197,\n            3127078106, 3137568595, 3148063665, 3158563317, 3169067552, 3179576371, 3190089775,\n            3200607765, 3211130342, 3221657507, 3232189261, 3242725605, 3253266540, 3263812067,\n            3274362187, 3284916901, 3295476210, 3306040115, 3316608617, 3327181717, 3337759416,\n            3348341715, 3358928615, 3369520117, 3380116222, 3390716931, 3401322245, 3411932165,\n            3422546692, 3433165827, 3443789571, 3454417925, 3465050890, 3475688467, 3486330657,\n            3496977461, 3507628880, 3518284915, 3528945567, 3539610837, 3550280726, 3560955235,\n            3571634365, 3582318117, 3593006492, 3603699491, 3614397115, 3625099365, 3635806242,\n            3646517747, 3657233881, 3667954645, 3678680040, 3689410067, 3700144727, 3710884021,\n            3721627950, 3732376515, 3743129717, 3753887557, 3764650036, 3775417155, 3786188915,\n            3796965317, 3807746362, 3818532051, 3829322385, 3840117365, 3850916992, 3861721267,\n            3872530191, 3883343765, 3894161990, 3904984867, 3915812397, 3926644581, 3937481420,\n            3948322915, 3959169067, 3970019877, 3980875346, 3991735475, 4002600265, 4013469717,\n            4024343832, 4035222611, 4046106055, 4056994165, 4067886942, 4078784387, 4089686501,\n            4100593285, 4111504740, 4122420867, 4133341667, 4144267141, 4155197290, 4166132115,\n            4177071617, 4188015797, 4198964656, 4209918195, 4220876415, 4231839317, 4242806902,\n            4253779171, 4264756125, 4275737765, 4286724092, 2747811, 13743516, 24743910, 35748995,\n            46758772, 57773242, 68792406, 79816265, 90844820, 101878072, 112916022, 123958671,\n            135006020, 146058070, 157114822, 168176277, 179242436, 190313300, 201388870, 212469147,\n            223554132, 234643826, 245738230, 256837345, 267941172, 279049712, 290162966, 301280935,\n            312403620, 323531022, 334663142, 345799981, 356941540, 368087820, 379238822, 390394547,\n            401554996, 412720170, 423890070, 435064697, 446244052, 457428136, 468616950, 479810495,\n            491008772, 502211782, 513419526, 524632005, 535849220, 547071172, 558297862, 569529291,\n            580765460, 592006370, 603252022, 614502417, 625757556, 637017440, 648282070, 659551447,\n            670825572, 682104446, 693388070, 704676445, 715969572, 727267452, 738570086, 749877475,\n            761189620, 772506522, 783828182, 795154601, 806485780, 817821720, 829162422, 840507887,\n            851858116, 863213110, 874572870, 885937397, 897306692, 908680756, 920059590, 931443195,\n            942831572, 954224722, 965622646, 977025345, 988432820, 999845072, 1011262102,\n            1022683911, 1034110500, 1045541870, 1056978022, 1068418957, 1079864676, 1091315180,\n            1102770470, 1114230547, 1125695412, 1137165066, 1148639510, 1160118745, 1171602772,\n            1183091592, 1194585206, 1206083615, 1217586820, 1229094822, 1240607622, 1252125221,\n            1263647620, 1275174820, 1286706822, 1298243627, 1309785236, 1321331650, 1332882870,\n            1344438897, 1355999732, 1367565376, 1379135830, 1390711095, 1402291172, 1413876062,\n            1425465766, 1437060285, 1448659620, 1460263772, 1471872742, 1483486531, 1495105140,\n            1506728570, 1518356822, 1529989897, 1541627796, 1553270520, 1564918070, 1576570447,\n            1588227652, 1599889686, 1611556550, 1623228245, 1634904772, 1646586132, 1658272326,\n            1669963355, 1681659220, 1693359922, 1705065462, 1716775841, 1728491060, 1740211120,\n            1751936022, 1763665767, 1775400356, 1787139790, 1798884070, 1810633197, 1822387172,\n            1834145996, 1845909670, 1857678195, 1869451572, 1881229802, 1893012886, 1904800825,\n            1916593620, 1928391272, 1940193782, 1952001151, 1963813380, 1975630470, 1987452422,\n            1999279237, 2011110916, 2022947460, 2034788870, 2046635147, 2058486292, 2070342306,\n            2082203190, 2094068945, 2105939572, 2117815072, 2129695446, 2141580695, 2153470820,\n            2165365822, 2177265702, 2189170461, 2201080100, 2212994620, 2224914022, 2236838307,\n            2248767476, 2260701530, 2272640470, 2284584297, 2296533012, 2308486616, 2320445110,\n            2332408495, 2344376772, 2356349942, 2368328006, 2380310965, 2392298820, 2404291572,\n            2416289222, 2428291771, 2440299220, 2452311570, 2464328822, 2476350977, 2488378036,\n            2500410000, 2512446870, 2524488647, 2536535332, 2548586926, 2560643430, 2572704845,\n            2584771172, 2596842412, 2608918566, 2620999635, 2633085620, 2645176522, 2657272342,\n            2669373081, 2681478740, 2693589320, 2705704822, 2717825247, 2729950596, 2742080870,\n            2754216070, 2766356197, 2778501252, 2790651236, 2802806150, 2814965995, 2827130772,\n            2839300482, 2851475126, 2863654705, 2875839220, 2888028672, 2900223062, 2912422391,\n            2924626660, 2936835870, 2949050022, 2961269117, 2973493156, 2985722140, 2997956070,\n            3010194947, 3022438772, 3034687546, 3046941270, 3059199945, 3071463572, 3083732152,\n            3096005686, 3108284175, 3120567620, 3132856022, 3145149382, 3157447701, 3169750980,\n            3182059220, 3194372422, 3206690587, 3219013716, 3231341810, 3243674870, 3256012897,\n            3268355892, 3280703856, 3293056790, 3305414695, 3317777572, 3330145422, 3342518246,\n            3354896045, 3367278820, 3379666572, 3392059302, 3404457011, 3416859700, 3429267370,\n            3441680022, 3454097657, 3466520276, 3478947880, 3491380470, 3503818047, 3516260612,\n            3528708166, 3541160710, 3553618245, 3566080772, 3578548292, 3591020806, 3603498315,\n            3615980820, 3628468322, 3640960822, 3653458321, 3665960820, 3678468320, 3690980822,\n            3703498327, 3716020836, 3728548350, 3741080870, 3753618397, 3766160932, 3778708476,\n            3791261030, 3803818595, 3816381172, 3828948762, 3841521366, 3854098985, 3866681620,\n            3879269272, 3891861942, 3904459631, 3917062340, 3929670070, 3942282822, 3954900597,\n            3967523396, 3980151220, 3992784070, 4005421947, 4018064852, 4030712786, 4043365750,\n            4056023745, 4068686772, 4081354832, 4094027926, 4106706055, 4119389220, 4132077422,\n            4144770662, 4157468941, 4170172260, 4182880620, 4195594022, 4208312467, 4221035956,\n            4233764490, 4246498070, 4259236697, 4271980372, 4284729096, 2515574, 15274400,\n            28038277, 40807207, 53581191, 66360230, 79144325, 91933477, 104727687, 117526956,\n            130331285, 143140675, 155955127, 168774642, 181599221, 194428865, 207263575, 220103352,\n            232948197, 245798111, 258653095, 271513150, 284378277, 297248477, 310123751, 323004100,\n            335889525, 348780027, 361675607, 374576266, 387482005, 400392825, 413308727, 426229712,\n            439155781, 452086935, 465023175, 477964502, 490910917, 503862421, 516819015, 529780700,\n            542747477, 555719347, 568696311, 581678370, 594665525, 607657777, 620655127, 633657576,\n            646665125, 659677775, 672695527, 685718382, 698746341, 711779405, 724817575, 737860852,\n            750909237, 763962731, 777021335, 790085050, 803153877, 816227817, 829306871, 842391040,\n            855480325, 868574727, 881674247, 894778886, 907888645, 921003525, 934123527, 947248652,\n            960378901, 973514275, 986654775, 999800402, 1012951157, 1026107041, 1039268055,\n            1052434200, 1065605477, 1078781887, 1091963431, 1105150110, 1118341925, 1131538877,\n            1144740967, 1157948196, 1171160565, 1184378075, 1197600727, 1210828522, 1224061461,\n            1237299545, 1250542775, 1263791152, 1277044677, 1290303351, 1303567175, 1316836150,\n            1330110277, 1343389557, 1356673991, 1369963580, 1383258325, 1396558227, 1409863287,\n            1423173506, 1436488885, 1449809425, 1463135127, 1476465992, 1489802021, 1503143215,\n            1516489575, 1529841102, 1543197797, 1556559661, 1569926695, 1583298900, 1596676277,\n            1610058827, 1623446551, 1636839450, 1650237525, 1663640777, 1677049207, 1690462816,\n            1703881605, 1717305575, 1730734727, 1744169062, 1757608581, 1771053285, 1784503175,\n            1797958252, 1811418517, 1824883971, 1838354615, 1851830450, 1865311477, 1878797697,\n            1892289111, 1905785720, 1919287525, 1932794527, 1946306727, 1959824126, 1973346725,\n            1986874525, 2000407527, 2013945732, 2027489141, 2041037755, 2054591575, 2068150602,\n            2081714837, 2095284281, 2108858935, 2122438800, 2136023877, 2149614167, 2163209671,\n            2176810390, 2190416325, 2204027477, 2217643847, 2231265436, 2244892245, 2258524275,\n            2272161527, 2285804002, 2299451701, 2313104625, 2326762775, 2340426152, 2354094757,\n            2367768591, 2381447655, 2395131950, 2408821477, 2422516237, 2436216231, 2449921460,\n            2463631925, 2477347627, 2491068567, 2504794746, 2518526165, 2532262825, 2546004727,\n            2559751872, 2573504261, 2587261895, 2601024775, 2614792902, 2628566277, 2642344901,\n            2656128775, 2669917900, 2683712277, 2697511907, 2711316791, 2725126930, 2738942325,\n            2752762977, 2766588887, 2780420056, 2794256485, 2808098175, 2821945127, 2835797342,\n            2849654821, 2863517565, 2877385575, 2891258852, 2905137397, 2919021211, 2932910295,\n            2946804650, 2960704277, 2974609177, 2988519351, 3002434800, 3016355525, 3030281527,\n            3044212807, 3058149366, 3072091205, 3086038325, 3099990727, 3113948412, 3127911381,\n            3141879635, 3155853175, 3169832002, 3183816117, 3197805521, 3211800215, 3225800200,\n            3239805477, 3253816047, 3267831911, 3281853070, 3295879525, 3309911277, 3323948327,\n            3337990676, 3352038325, 3366091275, 3380149527, 3394213082, 3408281941, 3422356105,\n            3436435575, 3450520352, 3464610437, 3478705831, 3492806535, 3506912550, 3521023877,\n            3535140517, 3549262471, 3563389740, 3577522325, 3591660227, 3605803447, 3619951986,\n            3634105845, 3648265025, 3662429527, 3676599352, 3690774501, 3704954975, 3719140775,\n            3733331902, 3747528357, 3761730141, 3775937255, 3790149700, 3804367477, 3818590587,\n            3832819031, 3847052810, 3861291925, 3875536377, 3889786167, 3904041296, 3918301765,\n            3932567575, 3946838727, 3961115222, 3975397061, 3989684245, 4003976775, 4018274652,\n            4032577877, 4046886451, 4061200375, 4075519650, 4089844277, 4104174257, 4118509591,\n            4132850280, 4147196325, 4161547727, 4175904487, 4190266606, 4204634085, 4219006925,\n            4233385127, 4247768692, 4262157621, 4276551915, 4290951575, 10389306, 24799702,\n            39215466, 53636600, 68063105, 82494982, 96932232, 111374856, 125822855, 140276230,\n            154734982, 169199112, 183668621, 198143510, 212623780, 227109432, 241600467, 256096886,\n            270598690, 285105880, 299618457, 314136422, 328659776, 343188520, 357722655, 372262182,\n            386807102, 401357416, 415913125, 430474230, 445040732, 459612632, 474189931, 488772630,\n            503360730, 517954232, 532553137, 547157446, 561767160, 576382280, 591002807, 605628742,\n            620260086, 634896840, 649539005, 664186582, 678839572, 693497976, 708161795, 722831030,\n            737505682, 752185752, 766871241, 781562150, 796258480, 810960232, 825667407, 840380006,\n            855098030, 869821480, 884550357, 899284662, 914024396, 928769560, 943520155, 958276182,\n            973037642, 987804536, 1002576865, 1017354630, 1032137832, 1046926472, 1061720551,\n            1076520070, 1091325030, 1106135432, 1120951277, 1135772566, 1150599300, 1165431480,\n            1180269107, 1195112182, 1209960706, 1224814680, 1239674105, 1254538982, 1269409312,\n            1284285096, 1299166335, 1314053030, 1328945182, 1343842792, 1358745861, 1373654390,\n            1388568380, 1403487832, 1418412747, 1433343126, 1448278970, 1463220280, 1478167057,\n            1493119302, 1508077016, 1523040200, 1538008855, 1552982982, 1567962582, 1582947656,\n            1597938205, 1612934230, 1627935732, 1642942712, 1657955171, 1672973110, 1687996530,\n            1703025432, 1718059817, 1733099686, 1748145040, 1763195880, 1778252207, 1793314022,\n            1808381326, 1823454120, 1838532405, 1853616182, 1868705452, 1883800216, 1898900475,\n            1914006230, 1929117482, 1944234232, 1959356481, 1974484230, 1989617480, 2004756232,\n            2019900487, 2035050246, 2050205510, 2065366280, 2080532557, 2095704342, 2110881636,\n            2126064440, 2141252755, 2156446582, 2171645922, 2186850776, 2202061145, 2217277030,\n            2232498432, 2247725352, 2262957791, 2278195750, 2293439230, 2308688232, 2323942757,\n            2339202806, 2354468380, 2369739480, 2385016107, 2400298262, 2415585946, 2430879160,\n            2446177905, 2461482182, 2476791992, 2492107336, 2507428215, 2522754630, 2538086582,\n            2553424072, 2568767101, 2584115670, 2599469780, 2614829432, 2630194627, 2645565366,\n            2660941650, 2676323480, 2691710857, 2707103782, 2722502256, 2737906280, 2753315855,\n            2768730982, 2784151662, 2799577896, 2815009685, 2830447030, 2845889932, 2861338392,\n            2876792411, 2892251990, 2907717130, 2923187832, 2938664097, 2954145926, 2969633320,\n            2985126280, 3000624807, 3016128902, 3031638566, 3047153800, 3062674605, 3078200982,\n            3093732932, 3109270456, 3124813555, 3140362230, 3155916482, 3171476312, 3187041721,\n            3202612710, 3218189280, 3233771432, 3249359167, 3264952486, 3280551390, 3296155880,\n            3311765957, 3327381622, 3343002876, 3358629720, 3374262155, 3389900182, 3405543802,\n            3421193016, 3436847825, 3452508230, 3468174232, 3483845832, 3499523031, 3515205830,\n            3530894230, 3546588232, 3562287837, 3577993046, 3593703860, 3609420280, 3625142307,\n            3640869942, 3656603186, 3672342040, 3688086505, 3703836582, 3719592272, 3735353576,\n            3751120495, 3766893030, 3782671182, 3798454952, 3814244341, 3830039350, 3845839980,\n            3861646232, 3877458107, 3893275606, 3909098730, 3924927480, 3940761857, 3956601862,\n            3972447496, 3988298760, 4004155655, 4020018182, 4035886342, 4051760136, 4067639565,\n            4083524630, 4099415332, 4115311672, 4131213651, 4147121270, 4163034530, 4178953432,\n            4194877977, 4210808166, 4226744000, 4242685480, 4258632607, 4274585382, 4290543806,\n            11540584, 27510310, 43485687, 59466717, 75453401, 91445740, 107443735, 123447387,\n            139456697, 155471666, 171492295, 187518585, 203550537, 219588152, 235631431, 251680375,\n            267734985, 283795262, 299861207, 315932821, 332010105, 348093060, 364181687, 380275987,\n            396375961, 412481610, 428592935, 444709937, 460832617, 476960976, 493095015, 509234735,\n            525380137, 541531222, 557687991, 573850445, 590018585, 606192412, 622371927, 638557131,\n            654748025, 670944610, 687146887, 703354857, 719568521, 735787880, 752012935, 768243687,\n            784480137, 800722286, 816970135, 833223685, 849482937, 865747892, 882018551, 898294915,\n            914576985, 930864762, 947158247, 963457441, 979762345, 996072960, 1012389287,\n            1028711327, 1045039081, 1061372550, 1077711735, 1094056637, 1110407257, 1126763596,\n            1143125655, 1159493435, 1175866937, 1192246162, 1208631111, 1225021785, 1241418185,\n            1257820312, 1274228167, 1290641751, 1307061065, 1323486110, 1339916887, 1356353397,\n            1372795641, 1389243620, 1405697335, 1422156787, 1438621977, 1455092906, 1471569575,\n            1488051985, 1504540137, 1521034032, 1537533671, 1554039055, 1570550185, 1587067062,\n            1603589687, 1620118061, 1636652185, 1653192060, 1669737687, 1686289067, 1702846201,\n            1719409090, 1735977735, 1752552137, 1769132297, 1785718216, 1802309895, 1818907335,\n            1835510537, 1852119502, 1868734231, 1885354725, 1901980985, 1918613012, 1935250807,\n            1951894371, 1968543705, 1985198810, 2001859687, 2018526337, 2035198761, 2051876960,\n            2068560935, 2085250687, 2101946217, 2118647526, 2135354615, 2152067485, 2168786137,\n            2185510572, 2202240791, 2218976795, 2235718585, 2252466162, 2269219527, 2285978681,\n            2302743625, 2319514360, 2336290887, 2353073207, 2369861321, 2386655230, 2403454935,\n            2420260437, 2437071737, 2453888836, 2470711735, 2487540435, 2504374937, 2521215242,\n            2538061351, 2554913265, 2571770985, 2588634512, 2605503847, 2622378991, 2639259945,\n            2656146710, 2673039287, 2689937677, 2706841881, 2723751900, 2740667735, 2757589387,\n            2774516857, 2791450146, 2808389255, 2825334185, 2842284937, 2859241512, 2876203911,\n            2893172135, 2910146185, 2927126062, 2944111767, 2961103301, 2978100665, 2995103860,\n            3012112887, 3029127747, 3046148441, 3063174970, 3080207335, 3097245537, 3114289577,\n            3131339456, 3148395175, 3165456735, 3182524137, 3199597382, 3216676471, 3233761405,\n            3250852185, 3267948812, 3285051287, 3302159611, 3319273785, 3336393810, 3353519687,\n            3370651417, 3387789001, 3404932440, 3422081735, 3439236887, 3456397897, 3473564766,\n            3490737495, 3507916085, 3525100537, 3542290852, 3559487031, 3576689075, 3593896985,\n            3611110762, 3628330407, 3645555921, 3662787305, 3680024560, 3697267687, 3714516687,\n            3731771561, 3749032310, 3766298935, 3783571437, 3800849817, 3818134076, 3835424215,\n            3852720235, 3870022137, 3887329922, 3904643591, 3921963145, 3939288585, 3956619912,\n            3973957127, 3991300231, 4008649225, 4026004110, 4043364887, 4060731557, 4078104121,\n            4095482580, 4112866935, 4130257187, 4147653337, 4165055386, 4182463335, 4199877185,\n            4217296937, 4234722592, 4252154151, 4269591615, 4287034985, 9516966, 26972152,\n            44433246, 61900250, 79373165, 96851992, 114336732, 131827386, 149323955, 166826440,\n            184334842, 201849162, 219369401, 236895560, 254427640, 271965642, 289509567, 307059416,\n            324615190, 342176890, 359744517, 377318072, 394897556, 412482970, 430074315, 447671592,\n            465274802, 482883946, 500499025, 518120040, 535746992, 553379882, 571018711, 588663480,\n            606314190, 623970842, 641633437, 659301976, 676976460, 694656890, 712343267, 730035592,\n            747733866, 765438090, 783148265, 800864392, 818586472, 836314506, 854048495, 871788440,\n            889534342, 907286202, 925044021, 942807800, 960577540, 978353242, 996134907,\n            1013922536, 1031716130, 1049515690, 1067321217, 1085132712, 1102950176, 1120773610,\n            1138603015, 1156438392, 1174279742, 1192127066, 1209980365, 1227839640, 1245704892,\n            1263576122, 1281453331, 1299336520, 1317225690, 1335120842, 1353021977, 1370929096,\n            1388842200, 1406761290, 1424686367, 1442617432, 1460554486, 1478497530, 1496446565,\n            1514401592, 1532362612, 1550329626, 1568302635, 1586281640, 1604266642, 1622257642,\n            1640254641, 1658257640, 1676266640, 1694281642, 1712302647, 1730329656, 1748362670,\n            1766401690, 1784446717, 1802497752, 1820554796, 1838617850, 1856686915, 1874761992,\n            1892843082, 1910930186, 1929023305, 1947122440, 1965227592, 1983338762, 2001455951,\n            2019579160, 2037708390, 2055843642, 2073984917, 2092132216, 2110285540, 2128444890,\n            2146610267, 2164781672, 2182959106, 2201142570, 2219332065, 2237527592, 2255729152,\n            2273936746, 2292150375, 2310370040, 2328595742, 2346827482, 2365065261, 2383309080,\n            2401558940, 2419814842, 2438076787, 2456344776, 2474618810, 2492898890, 2511185017,\n            2529477192, 2547775416, 2566079690, 2584390015, 2602706392, 2621028822, 2639357306,\n            2657691845, 2676032440, 2694379092, 2712731802, 2731090571, 2749455400, 2767826290,\n            2786203242, 2804586257, 2822975336, 2841370480, 2859771690, 2878178967, 2896592312,\n            2915011726, 2933437210, 2951868765, 2970306392, 2988750092, 3007199866, 3025655715,\n            3044117640, 3062585642, 3081059722, 3099539881, 3118026120, 3136518440, 3155016842,\n            3173521327, 3192031896, 3210548550, 3229071290, 3247600117, 3266135032, 3284676036,\n            3303223130, 3321776315, 3340335592, 3358900962, 3377472426, 3396049985, 3414633640,\n            3433223392, 3451819242, 3470421191, 3489029240, 3507643390, 3526263642, 3544889997,\n            3563522456, 3582161020, 3600805690, 3619456467, 3638113352, 3656776346, 3675445450,\n            3694120665, 3712801992, 3731489432, 3750182986, 3768882655, 3787588440, 3806300342,\n            3825018362, 3843742501, 3862472760, 3881209140, 3899951642, 3918700267, 3937455016,\n            3956215890, 3974982890, 3993756017, 4012535272, 4031320656, 4050112170, 4068909815,\n            4087713592, 4106523502, 4125339546, 4144161725, 4162990040, 4181824492, 4200665082,\n            4219511811, 4238364680, 4257223690, 4276088842, 4294960137, 18870280, 37753865,\n            56643595, 75539472, 94441497, 113349671, 132263995, 151184470, 170111097, 189043877,\n            207982811, 226927900, 245879145, 264836547, 283800107, 302769826, 321745705, 340727745,\n            359715947, 378710312, 397710841, 416717535, 435730395, 454749422, 473774617, 492805981,\n            511843515, 530887220, 549937097, 568993147, 588055371, 607123770, 626198345, 645279097,\n            664366027, 683459136, 702558425, 721663895, 740775547, 759893382, 779017401, 798147605,\n            817283995, 836426572, 855575337, 874730291, 893891435, 913058770, 932232297, 951412017,\n            970597931, 989790040, 1008988345, 1028192847, 1047403547, 1066620446, 1085843545,\n            1105072845, 1124308347, 1143550052, 1162797961, 1182052075, 1201312395, 1220578922,\n            1239851657, 1259130601, 1278415755, 1297707120, 1317004697, 1336308487, 1355618491,\n            1374934710, 1394257145, 1413585797, 1432920667, 1452261756, 1471609065, 1490962595,\n            1510322347, 1529688322, 1549060521, 1568438945, 1587823595, 1607214472, 1626611577,\n            1646014911, 1665424475, 1684840270, 1704262297, 1723690557, 1743125051, 1762565780,\n            1782012745, 1801465947, 1820925387, 1840391066, 1859862985, 1879341145, 1898825547,\n            1918316192, 1937813081, 1957316215, 1976825595, 1996341222, 2015863097, 2035391221,\n            2054925595, 2074466220, 2094013097, 2113566227, 2133125611, 2152691250, 2172263145,\n            2191841297, 2211425707, 2231016376, 2250613305, 2270216495, 2289825947, 2309441662,\n            2329063641, 2348691885, 2368326395, 2387967172, 2407614217, 2427267531, 2446927115,\n            2466592970, 2486265097, 2505943497, 2525628171, 2545319120, 2565016345, 2584719847,\n            2604429627, 2624145686, 2643868025, 2663596645, 2683331547, 2703072732, 2722820201,\n            2742573955, 2762333995, 2782100322, 2801872937, 2821651841, 2841437035, 2861228520,\n            2881026297, 2900830367, 2920640731, 2940457390, 2960280345, 2980109597, 2999945147,\n            3019786996, 3039635145, 3059489595, 3079350347, 3099217402, 3119090761, 3138970425,\n            3158856395, 3178748672, 3198647257, 3218552151, 3238463355, 3258380870, 3278304697,\n            3298234837, 3318171291, 3338114060, 3358063145, 3378018547, 3397980267, 3417948306,\n            3437922665, 3457903345, 3477890347, 3497883672, 3517883321, 3537889295, 3557901595,\n            3577920222, 3597945177, 3617976461, 3638014075, 3658058020, 3678108297, 3698164907,\n            3718227851, 3738297130, 3758372745, 3778454697, 3798542987, 3818637616, 3838738585,\n            3858845895, 3878959547, 3899079542, 3919205881, 3939338565, 3959477595, 3979622972,\n            3999774697, 4019932771, 4040097195, 4060267970, 4080445097, 4100628577, 4120818411,\n            4141014600, 4161217145, 4181426047, 4201641307, 4221862926, 4242090905, 4262325245,\n            4282565947, 7845716, 28099146, 48358940, 68625100, 88897627, 109176522, 129461786,\n            149753420, 170051425, 190355802, 210666552, 230983676, 251307175, 271637050, 291973302,\n            312315932, 332664941, 353020330, 373382100, 393750252, 414124787, 434505706, 454893010,\n            475286700, 495686777, 516093242, 536506096, 556925340, 577350975, 597783002, 618221422,\n            638666236, 659117445, 679575050, 700039052, 720509452, 740986251, 761469450, 781959050,\n            802455052, 822957457, 843466266, 863981480, 884503100, 905031127, 925565562, 946106406,\n            966653660, 987207325, 1007767402, 1028333892, 1048906796, 1069486115, 1090071850,\n            1110664002, 1131262572, 1151867561, 1172478970, 1193096800, 1213721052, 1234351727,\n            1254988826, 1275632350, 1296282300, 1316938677, 1337601482, 1358270716, 1378946380,\n            1399628475, 1420317002, 1441011962, 1461713356, 1482421185, 1503135450, 1523856152,\n            1544583292, 1565316871, 1586056890, 1606803350, 1627556252, 1648315597, 1669081386,\n            1689853620, 1710632300, 1731417427, 1752209002, 1773007026, 1793811500, 1814622425,\n            1835439802, 1856263632, 1877093916, 1897930655, 1918773850, 1939623502, 1960479612,\n            1981342181, 2002211210, 2023086700, 2043968652, 2064857067, 2085751946, 2106653290,\n            2127561100, 2148475377, 2169396122, 2190323336, 2211257020, 2232197175, 2253143802,\n            2274096902, 2295056476, 2316022525, 2336995050, 2357974052, 2378959532, 2399951491,\n            2420949930, 2441954850, 2462966252, 2483984137, 2505008506, 2526039360, 2547076700,\n            2568120527, 2589170842, 2610227646, 2631290940, 2652360725, 2673437002, 2694519772,\n            2715609036, 2736704795, 2757807050, 2778915802, 2800031052, 2821152801, 2842281050,\n            2863415800, 2884557052, 2905704807, 2926859066, 2948019830, 2969187100, 2990360877,\n            3011541162, 3032727956, 3053921260, 3075121075, 3096327402, 3117540242, 3138759596,\n            3159985465, 3181217850, 3202456752, 3223702172, 3244954111, 3266212570, 3287477550,\n            3308749052, 3330027077, 3351311626, 3372602700, 3393900300, 3415204427, 3436515082,\n            3457832266, 3479155980, 3500486225, 3521823002, 3543166312, 3564516156, 3585872535,\n            3607235450, 3628604902, 3649980892, 3671363421, 3692752490, 3714148100, 3735550252,\n            3756958947, 3778374186, 3799795970, 3821224300, 3842659177, 3864100602, 3885548576,\n            3907003100, 3928464175, 3949931802, 3971405982, 3992886716, 4014374005, 4035867850,\n            4057368252, 4078875212, 4100388731, 4121908810, 4143435450, 4164968652, 4186508417,\n            4208054746, 4229607640, 4251167100, 4272733127, 4294305722, 20917590, 42503325,\n            64095630, 85694507, 107299957, 128911981, 150530580, 172155755, 193787507, 215425837,\n            237070746, 258722235, 280380305, 302044957, 323716192, 345394011, 367078415, 388769405,\n            410466982, 432171147, 453881901, 475599245, 497323180, 519053707, 540790827, 562534541,\n            584284850, 606041755, 627805257, 649575357, 671352056, 693135355, 714925255, 736721757,\n            758524862, 780334571, 802150885, 823973805, 845803332, 867639467, 889482211, 911331565,\n            933187530, 955050107, 976919297, 998795101, 1020677520, 1042566555, 1064462207,\n            1086364477, 1108273366, 1130188875, 1152111005, 1174039757, 1195975132, 1217917131,\n            1239865755, 1261821005, 1283782882, 1305751387, 1327726521, 1349708285, 1371696680,\n            1393691707, 1415693367, 1437701661, 1459716590, 1481738155, 1503766357, 1525801197,\n            1547842676, 1569890795, 1591945555, 1614006957, 1636075002, 1658149691, 1680231025,\n            1702319005, 1724413632, 1746514907, 1768622831, 1790737405, 1812858630, 1834986507,\n            1857121037, 1879262221, 1901410060, 1923564555, 1945725707, 1967893517, 1990067986,\n            2012249115, 2034436905, 2056631357, 2078832472, 2101040251, 2123254695, 2145475805,\n            2167703582, 2189938027, 2212179141, 2234426925, 2256681380, 2278942507, 2301210307,\n            2323484781, 2345765930, 2368053755, 2390348257, 2412649437, 2434957296, 2457271835,\n            2479593055, 2501920957, 2524255542, 2546596811, 2568944765, 2591299405, 2613660732,\n            2636028747, 2658403451, 2680784845, 2703172930, 2725567707, 2747969177, 2770377341,\n            2792792200, 2815213755, 2837642007, 2860076957, 2882518606, 2904966955, 2927422005,\n            2949883757, 2972352212, 2994827371, 3017309235, 3039797805, 3062293082, 3084795067,\n            3107303761, 3129819165, 3152341280, 3174870107, 3197405647, 3219947901, 3242496870,\n            3265052555, 3287614957, 3310184077, 3332759916, 3355342475, 3377931755, 3400527757,\n            3423130482, 3445739931, 3468356105, 3490979005, 3513608632, 3536244987, 3558888071,\n            3581537885, 3604194430, 3626857707, 3649527717, 3672204461, 3694887940, 3717578155,\n            3740275107, 3762978797, 3785689226, 3808406395, 3831130305, 3853860957, 3876598352,\n            3899342491, 3922093375, 3944851005, 3967615382, 3990386507, 4013164381, 4035949005,\n            4058740380, 4081538507, 4104343387, 4127155021, 4149973410, 4172798555, 4195630457,\n            4218469117, 4241314536, 4264166715, 4287025655, 14924061, 37796527, 60675756, 83561750,\n            106454510, 129354037, 152260332, 175173396, 198093230, 221019835, 243953212, 266893362,\n            289840286, 312793985, 335754460, 358721712, 381695742, 404676551, 427664140, 450658510,\n            473659662, 496667597, 519682316, 542703820, 565732110, 588767187, 611809052, 634857706,\n            657913150, 680975385, 704044412, 727120232, 750202846, 773292255, 796388460, 819491462,\n            842601262, 865717861, 888841260, 911971460, 935108462, 958252267, 981402876,\n            1004560290, 1027724510, 1050895537, 1074073372, 1097258016, 1120449470, 1143647735,\n            1166852812, 1190064702, 1213283406, 1236508925, 1259741260, 1282980412, 1306226382,\n            1329479171, 1352738780, 1376005210, 1399278462, 1422558537, 1445845436, 1469139160,\n            1492439710, 1515747087, 1539061292, 1562382326, 1585710190, 1609044885, 1632386412,\n            1655734772, 1679089966, 1702451995, 1725820860, 1749196562, 1772579102, 1795968481,\n            1819364700, 1842767760, 1866177662, 1889594407, 1913017996, 1936448430, 1959885710,\n            1983329837, 2006780812, 2030238636, 2053703310, 2077174835, 2100653212, 2124138442,\n            2147630526, 2171129465, 2194635260, 2218147912, 2241667422, 2265193791, 2288727020,\n            2312267110, 2335814062, 2359367877, 2382928556, 2406496100, 2430070510, 2453651787,\n            2477239932, 2500834946, 2524436830, 2548045585, 2571661212, 2595283712, 2618913086,\n            2642549335, 2666192460, 2689842462, 2713499342, 2737163101, 2760833740, 2784511260,\n            2808195662, 2831886947, 2855585116, 2879290170, 2903002110, 2926720937, 2950446652,\n            2974179256, 2997918750, 3021665135, 3045418412, 3069178582, 3092945646, 3116719605,\n            3140500460, 3164288212, 3188082862, 3211884411, 3235692860, 3259508210, 3283330462,\n            3307159617, 3330995676, 3354838640, 3378688510, 3402545287, 3426408972, 3450279566,\n            3474157070, 3498041485, 3521932812, 3545831052, 3569736206, 3593648275, 3617567260,\n            3641493162, 3665425982, 3689365721, 3713312380, 3737265960, 3761226462, 3785193887,\n            3809168236, 3833149510, 3857137710, 3881132837, 3905134892, 3929143876, 3953159790,\n            3977182635, 4001212412, 4025249122, 4049292766, 4073343345, 4097400860, 4121465312,\n            4145536702, 4169615031, 4193700300, 4217792510, 4241891662, 4265997757, 4290110796,\n            19263484, 43390415, 67524292, 91665117, 115812891, 139967615, 164129290, 188297917,\n            212473497, 236656031, 260845520, 285041965, 309245367, 333455727, 357673046, 381897325,\n            406128565, 430366767, 454611932, 478864061, 503123155, 527389215, 551662242, 575942237,\n            600229201, 624523135, 648824040, 673131917, 697446767, 721768591, 746097390, 770433165,\n            794775917, 819125647, 843482356, 867846045, 892216715, 916594367, 940979002, 965370621,\n            989769225, 1014174815, 1038587392, 1063006957, 1087433511, 1111867055, 1136307590,\n            1160755117, 1185209637, 1209671151, 1234139660, 1258615165, 1283097667, 1307587167,\n            1332083666, 1356587165, 1381097665, 1405615167, 1430139672, 1454671181, 1479209695,\n            1503755215, 1528307742, 1552867277, 1577433821, 1602007375, 1626587940, 1651175517,\n            1675770107, 1700371711, 1724980330, 1749595965, 1774218617, 1798848287, 1823484976,\n            1848128685, 1872779415, 1897437167, 1922101942, 1946773741, 1971452565, 1996138415,\n            2020831292, 2045531197, 2070238131, 2094952095, 2119673090, 2144401117, 2169136177,\n            2193878271, 2218627400, 2243383565, 2268146767, 2292917007, 2317694286, 2342478605,\n            2367269965, 2392068367, 2416873812, 2441686301, 2466505835, 2491332415, 2516166042,\n            2541006717, 2565854441, 2590709215, 2615571040, 2640439917, 2665315847, 2690198831,\n            2715088870, 2739985965, 2764890117, 2789801327, 2814719596, 2839644925, 2864577315,\n            2889516767, 2914463282, 2939416861, 2964377505, 2989345215, 3014319992, 3039301837,\n            3064290751, 3089286735, 3114289790, 3139299917, 3164317117, 3189341391, 3214372740,\n            3239411165, 3264456667, 3289509247, 3314568906, 3339635645, 3364709465, 3389790367,\n            3414878352, 3439973421, 3465075575, 3490184815, 3515301142, 3540424557, 3565555061,\n            3590692655, 3615837340, 3640989117, 3666147987, 3691313951, 3716487010, 3741667165,\n            3766854417, 3792048767, 3817250216, 3842458765, 3867674415, 3892897167, 3918127022,\n            3943363981, 3968608045, 3993859215, 4019117492, 4044382877, 4069655371, 4094934975,\n            4120221690, 4145515517, 4170816457, 4196124511, 4221439680, 4246761965, 4272091367,\n            2460591, 27804231, 53154990, 78512870, 103877872, 129249997, 154629246, 180015620,\n            205409120, 230809747, 256217502, 281632386, 307054400, 332483545, 357919822, 383363232,\n            408813776, 434271455, 459736270, 485208222, 510687312, 536173541, 561666910, 587167420,\n            612675072, 638189867, 663711806, 689240890, 714777120, 740320497, 765871022, 791428696,\n            816993520, 842565495, 868144622, 893730902, 919324336, 944924925, 970532670, 996147572,\n            1021769632, 1047398851, 1073035230, 1098678770, 1124329472, 1149987337, 1175652366,\n            1201324560, 1227003920, 1252690447, 1278384142, 1304085006, 1329793040, 1355508245,\n            1381230622, 1406960172, 1432696896, 1458440795, 1484191870, 1509950122, 1535715552,\n            1561488161, 1587267950, 1613054920, 1638849072, 1664650407, 1690458926, 1716274630,\n            1742097520, 1767927597, 1793764862, 1819609316, 1845460960, 1871319795, 1897185822,\n            1923059042, 1948939456, 1974827065, 2000721870, 2026623872, 2052533072, 2078449471,\n            2104373070, 2130303870, 2156241872, 2182187077, 2208139486, 2234099100, 2260065920,\n            2286039947, 2312021182, 2338009626, 2364005280, 2390008145, 2416018222, 2442035512,\n            2468060016, 2494091735, 2520130670, 2546176822, 2572230192, 2598290781, 2624358590,\n            2650433620, 2676515872, 2702605347, 2728702046, 2754805970, 2780917120, 2807035497,\n            2833161102, 2859293936, 2885434000, 2911581295, 2937735822, 2963897582, 2990066576,\n            3016242805, 3042426270, 3068616972, 3094814912, 3121020091, 3147232510, 3173452170,\n            3199679072, 3225913217, 3252154606, 3278403240, 3304659120, 3330922247, 3357192622,\n            3383470246, 3409755120, 3436047245, 3462346622, 3488653252, 3514967136, 3541288275,\n            3567616670, 3593952322, 3620295232, 3646645401, 3673002830, 3699367520, 3725739472,\n            3752118687, 3778505166, 3804898910, 3831299920, 3857708197, 3884123742, 3910546556,\n            3936976640, 3963413995, 3989858622, 4016310522, 4042769696, 4069236145, 4095709870,\n            4122190872, 4148679152, 4175174711, 4201677550, 4228187670, 4254705072, 4281229757,\n            12794430, 39333685, 65880225, 92434052, 118995167, 145563571, 172139265, 198722250,\n            225312527, 251910097, 278514961, 305127120, 331746575, 358373327, 385007377, 411648726,\n            438297375, 464953325, 491616577, 518287132, 544964991, 571650155, 598342625, 625042402,\n            651749487, 678463881, 705185585, 731914600, 758650927, 785394567, 812145521, 838903790,\n            865669375, 892442277, 919222497, 946010036, 972804895, 999607075, 1026416577,\n            1053233402, 1080057551, 1106889025, 1133727825, 1160573952, 1187427407, 1214288191,\n            1241156305, 1268031750, 1294914527, 1321804637, 1348702081, 1375606860, 1402518975,\n            1429438427, 1456365217, 1483299346, 1510240815, 1537189625, 1564145777, 1591109272,\n            1618080111, 1645058295, 1672043825, 1699036702, 1726036927, 1753044501, 1780059425,\n            1807081700, 1834111327, 1861148307, 1888192641, 1915244330, 1942303375, 1969369777,\n            1996443537, 2023524656, 2050613135, 2077708975, 2104812177, 2131922742, 2159040671,\n            2186165965, 2213298625, 2240438652, 2267586047, 2294740811, 2321902945, 2349072450,\n            2376249327, 2403433577, 2430625201, 2457824200, 2485030575, 2512244327, 2539465457,\n            2566693966, 2593929855, 2621173125, 2648423777, 2675681812, 2702947231, 2730220035,\n            2757500225, 2784787802, 2812082767, 2839385121, 2866694865, 2894012000, 2921336527,\n            2948668447, 2976007761, 3003354470, 3030708575, 3058070077, 3085438977, 3112815276,\n            3140198975, 3167590075, 3194988577, 3222394482, 3249807791, 3277228505, 3304656625,\n            3332092152, 3359535087, 3386985431, 3414443185, 3441908350, 3469380927, 3496860917,\n            3524348321, 3551843140, 3579345375, 3606855027, 3634372097, 3661896586, 3689428495,\n            3716967825, 3744514577, 3772068752, 3799630351, 3827199375, 3854775825, 3882359702,\n            3909951007, 3937549741, 3965155905, 3992769500, 4020390527, 4048018987, 4075654881,\n            4103298210, 4130948975, 4158607177, 4186272817, 4213945896, 4241626415, 4269314375,\n            2042481, 29745327, 57455616, 85173350, 112898530, 140631157, 168371232, 196118756,\n            223873730, 251636155, 279406032, 307183362, 334968146, 362760385, 390560080, 418367232,\n            446181842, 474003911, 501833440, 529670430, 557514882, 585366797, 613226176, 641093020,\n            668967330, 696849107, 724738352, 752635066, 780539250, 808450905, 836370032, 864296632,\n            892230706, 920172255, 948121280, 976077782, 1004041762, 1032013221, 1059992160,\n            1087978580, 1115972482, 1143973867, 1171982736, 1199999090, 1228022930, 1256054257,\n            1284093072, 1312139376, 1340193170, 1368254455, 1396323232, 1424399502, 1452483266,\n            1480574525, 1508673280, 1536779532, 1564893282, 1593014531, 1621143280, 1649279530,\n            1677423282, 1705574537, 1733733296, 1761899560, 1790073330, 1818254607, 1846443392,\n            1874639686, 1902843490, 1931054805, 1959273632, 1987499972, 2015733826, 2043975195,\n            2072224080, 2100480482, 2128744402, 2157015841, 2185294800, 2213581280, 2241875282,\n            2270176807, 2298485856, 2326802430, 2355126530, 2383458157, 2411797312, 2440143996,\n            2468498210, 2496859955, 2525229232, 2553606042, 2581990386, 2610382265, 2638781680,\n            2667188632, 2695603122, 2724025151, 2752454720, 2780891830, 2809336482, 2837788677,\n            2866248416, 2894715700, 2923190530, 2951672907, 2980162832, 3008660306, 3037165330,\n            3065677905, 3094198032, 3122725712, 3151260946, 3179803735, 3208354080, 3236911982,\n            3265477442, 3294050461, 3322631040, 3351219180, 3379814882, 3408418147, 3437028976,\n            3465647370, 3494273330, 3522906857, 3551547952, 3580196616, 3608852850, 3637516655,\n            3666188032, 3694866982, 3723553506, 3752247605, 3780949280, 3809658532, 3838375362,\n            3867099771, 3895831760, 3924571330, 3953318482, 3982073217, 4010835536, 4039605440,\n            4068382930, 4097168007, 4125960672, 4154760926, 4183568770, 4212384205, 4241207232,\n            4270037852, 3908770, 32754580, 61607985, 90468987, 119337587, 148213786, 177097585,\n            205988985, 234887987, 263794592, 292708801, 321630615, 350560035, 379497062, 408441697,\n            437393941, 466353795, 495321260, 524296337, 553279027, 582269331, 611267250, 640272785,\n            669285937, 698306707, 727335096, 756371105, 785414735, 814465987, 843524862, 872591361,\n            901665485, 930747235, 959836612, 988933617, 1018038251, 1047150515, 1076270410,\n            1105397937, 1134533097, 1163675891, 1192826320, 1221984385, 1251150087, 1280323427,\n            1309504406, 1338693025, 1367889285, 1397093187, 1426304732, 1455523921, 1484750755,\n            1513985235, 1543227362, 1572477137, 1601734561, 1630999635, 1660272360, 1689552737,\n            1718840767, 1748136451, 1777439790, 1806750785, 1836069437, 1865395747, 1894729716,\n            1924071345, 1953420635, 1982777587, 2012142202, 2041514481, 2070894425, 2100282035,\n            2129677312, 2159080257, 2188490871, 2217909155, 2247335110, 2276768737, 2306210037,\n            2335659011, 2365115660, 2394579985, 2424051987, 2453531667, 2483019026, 2512514065,\n            2542016785, 2571527187, 2601045272, 2630571041, 2660104495, 2689645635, 2719194462,\n            2748750977, 2778315181, 2807887075, 2837466660, 2867053937, 2896648907, 2926251571,\n            2955861930, 2985479985, 3015105737, 3044739187, 3074380336, 3104029185, 3133685735,\n            3163349987, 3193021942, 3222701601, 3252388965, 3282084035, 3311786812, 3341497297,\n            3371215491, 3400941395, 3430675010, 3460416337, 3490165377, 3519922131, 3549686600,\n            3579458785, 3609238687, 3639026307, 3668821646, 3698624705, 3728435485, 3758253987,\n            3788080212, 3817914161, 3847755835, 3877605235, 3907462362, 3937327217, 3967199801,\n            3997080115, 4026968160, 4056863937, 4086767447, 4116678691, 4146597670, 4176524385,\n            4206458837, 4236401027, 4266350956, 1341329, 31306740, 61279892, 91260787, 121249426,\n            151245810, 181249940, 211261817, 241281442, 271308816, 301343940, 331386815, 361437442,\n            391495822, 421561956, 451635845, 481717490, 511806892, 541904052, 572008971, 602121650,\n            632242090, 662370292, 692506257, 722649986, 752801480, 782960740, 813127767, 843302562,\n            873485126, 903675460, 933873565, 964079442, 994293092, 1024514516, 1054743715,\n            1084980690, 1115225442, 1145477972, 1175738281, 1206006370, 1236282240, 1266565892,\n            1296857327, 1327156546, 1357463550, 1387778340, 1418100917, 1448431282, 1478769436,\n            1509115380, 1539469115, 1569830642, 1600199962, 1630577076, 1660961985, 1691354690,\n            1721755192, 1752163492, 1782579591, 1813003490, 1843435190, 1873874692, 1904321997,\n            1934777106, 1965240020, 1995710740, 2026189267, 2056675602, 2087169746, 2117671700,\n            2148181465, 2178699042, 2209224432, 2239757636, 2270298655, 2300847490, 2331404142,\n            2361968612, 2392540901, 2423121010, 2453708940, 2484304692, 2514908267, 2545519666,\n            2576138890, 2606765940, 2637400817, 2668043522, 2698694056, 2729352420, 2760018615,\n            2790692642, 2821374502, 2852064196, 2882761725, 2913467090, 2944180292, 2974901332,\n            3005630211, 3036366930, 3067111490, 3097863892, 3128624137, 3159392226, 3190168160,\n            3220951940, 3251743567, 3282543042, 3313350366, 3344165540, 3374988565, 3405819442,\n            3436658172, 3467504756, 3498359195, 3529221490, 3560091642, 3590969652, 3621855521,\n            3652749250, 3683650840, 3714560292, 3745477607, 3776402786, 3807335830, 3838276740,\n            3869225517, 3900182162, 3931146676, 3962119060, 3993099315, 4024087442, 4055083442,\n            4086087316, 4117099065, 4148118690, 4179146192, 4210181572, 4241224831, 4272275970,\n            8367694, 39434597, 70509382, 101592051, 132682605, 163781045, 194887372, 226001587,\n            257123691, 288253685, 319391570, 350537347, 381691017, 412852581, 444022040, 475199395,\n            506384647, 537577797, 568778846, 599987795, 631204645, 662429397, 693662052, 724902611,\n            756151075, 787407445, 818671722, 849943907, 881224001, 912512005, 943807920, 975111747,\n            1006423487, 1037743141, 1069070710, 1100406195, 1131749597, 1163100917, 1194460156,\n            1225827315, 1257202395, 1288585397, 1319976322, 1351375171, 1382781945, 1414196645,\n            1445619272, 1477049827, 1508488311, 1539934725, 1571389070, 1602851347, 1634321557,\n            1665799701, 1697285780, 1728779795, 1760281747, 1791791637, 1823309466, 1854835235,\n            1886368945, 1917910597, 1949460192, 1981017731, 2012583215, 2044156645, 2075738022,\n            2107327347, 2138924621, 2170529845, 2202143020, 2233764147, 2265393227, 2297030261,\n            2328675250, 2360328195, 2391989097, 2423657957, 2455334776, 2487019555, 2518712295,\n            2550412997, 2582121662, 2613838291, 2645562885, 2677295445, 2709035972, 2740784467,\n            2772540931, 2804305365, 2836077770, 2867858147, 2899646497, 2931442821, 2963247120,\n            2995059395, 3026879647, 3058707877, 3090544086, 3122388275, 3154240445, 3186100597,\n            3217968732, 3249844851, 3281728955, 3313621045, 3345521122, 3377429187, 3409345241,\n            3441269285, 3473201320, 3505141347, 3537089367, 3569045381, 3601009390, 3632981395,\n            3664961397, 3696949397, 3728945396, 3760949395, 3792961395, 3824981397, 3857009402,\n            3889045411, 3921089425, 3953141445, 3985201472, 4017269507, 4049345551, 4081429605,\n            4113521670, 4145621747, 4177729837, 4209845941, 4241970060, 4274102195, 11275051,\n            43423222, 75579411, 107743620, 139915850, 172096102, 204284377, 236480676, 268685000,\n            300897350, 333117727, 365346132, 397582566, 429827030, 462079525, 494340052, 526608612,\n            558885206, 591169835, 623462500, 655763202, 688071942, 720388721, 752713540, 785046400,\n            817387302, 849736247, 882093236, 914458270, 946831350, 979212477, 1011601652,\n            1043998876, 1076404150, 1108817475, 1141238852, 1173668282, 1206105766, 1238551305,\n            1271004900, 1303466552, 1335936262, 1368414031, 1400899860, 1433393750, 1465895702,\n            1498405717, 1530923796, 1563449940, 1595984150, 1628526427, 1661076772, 1693635186,\n            1726201670, 1758776225, 1791358852, 1823949552, 1856548326, 1889155175, 1921770100,\n            1954393102, 1987024182, 2019663341, 2052310580, 2084965900, 2117629302, 2150300787,\n            2182980356, 2215668010, 2248363750, 2281067577, 2313779492, 2346499496, 2379227590,\n            2411963775, 2444708052, 2477460422, 2510220886, 2542989445, 2575766100, 2608550852,\n            2641343702, 2674144651, 2706953700, 2739770850, 2772596102, 2805429457, 2838270916,\n            2871120480, 2903978150, 2936843927, 2969717812, 3002599806, 3035489910, 3068388125,\n            3101294452, 3134208892, 3167131446, 3200062115, 3233000900, 3265947802, 3298902822,\n            3331865961, 3364837220, 3397816600, 3430804102, 3463799727, 3496803476, 3529815350,\n            3562835350, 3595863477, 3628899732, 3661944116, 3694996630, 3728057275, 3761126052,\n            3794202962, 3827288006, 3860381185, 3893482500, 3926591952, 3959709542, 3992835271,\n            4025969140, 4059111150, 4092261302, 4125419597, 4158586036, 4191760620, 4224943350,\n            4258134227, 4291333252, 29573130, 62788455, 96011930, 129243557, 162483337, 195731271,\n            228987360, 262251605, 295524007, 328804567, 362093286, 395390165, 428695205, 462008407,\n            495329772, 528659301, 561996995, 595342855, 628696882, 662059077, 695429441, 728807975,\n            762194680, 795589557, 828992607, 862403831, 895823230, 929250805, 962686557, 996130487,\n            1029582596, 1063042885, 1096511355, 1129988007, 1163472842, 1196965861, 1230467065,\n            1263976455, 1297494032, 1331019797, 1364553751, 1398095895, 1431646230, 1465204757,\n            1498771477, 1532346391, 1565929500, 1599520805, 1633120307, 1666728007, 1700343906,\n            1733968005, 1767600305, 1801240807, 1834889512, 1868546421, 1902211535, 1935884855,\n            1969566382, 2003256117, 2036954061, 2070660215, 2104374580, 2138097157, 2171827947,\n            2205566951, 2239314170, 2273069605, 2306833257, 2340605127, 2374385216, 2408173525,\n            2441970055, 2475774807, 2509587782, 2543408981, 2577238405, 2611076055, 2644921932,\n            2678776037, 2712638371, 2746508935, 2780387730, 2814274757, 2848170017, 2882073511,\n            2915985240, 2949905205, 2983833407, 3017769847, 3051714526, 3085667445, 3119628605,\n            3153598007, 3187575652, 3221561541, 3255555675, 3289558055, 3323568682, 3357587557,\n            3391614681, 3425650055, 3459693680, 3493745557, 3527805687, 3561874071, 3595950710,\n            3630035605, 3664128757, 3698230167, 3732339836, 3766457765, 3800583955, 3834718407,\n            3868861122, 3903012101, 3937171345, 3971338855, 4005514632, 4039698677, 4073890991,\n            4108091575, 4142300430, 4176517557, 4210742957, 4244976631, 4279218580, 18501509,\n            52760012, 87026792, 121301851, 155585190, 189876810, 224176712, 258484897, 292801366,\n            327126120, 361459160, 395800487, 430150102, 464508006, 498874200, 533248685, 567631462,\n            602022532, 636421896, 670829555, 705245510, 739669762, 774102312, 808543161, 842992310,\n            877449760, 911915512, 946389567, 980871926, 1015362590, 1049861560, 1084368837,\n            1118884422, 1153408316, 1187940520, 1222481035, 1257029862, 1291587002, 1326152456,\n            1360726225, 1395308310, 1429898712, 1464497432, 1499104471, 1533719830, 1568343510,\n            1602975512, 1637615837, 1672264486, 1706921460, 1741586760, 1776260387, 1810942342,\n            1845632626, 1880331240, 1915038185, 1949753462, 1984477072, 2019209016, 2053949295,\n            2088697910, 2123454862, 2158220152, 2192993781, 2227775750, 2262566060, 2297364712,\n            2332171707, 2366987046, 2401810730, 2436642760, 2471483137, 2506331862, 2541188936,\n            2576054360, 2610928135, 2645810262, 2680700742, 2715599576, 2750506765, 2785422310,\n            2820346212, 2855278472, 2890219091, 2925168070, 2960125410, 2995091112, 3030065177,\n            3065047606, 3100038400, 3135037560, 3170045087, 3205060982, 3240085246, 3275117880,\n            3310158885, 3345208262, 3380266012, 3415332136, 3450406635, 3485489510, 3520580762,\n            3555680392, 3590788401, 3625904790, 3661029560, 3696162712, 3731304247, 3766454166,\n            3801612470, 3836779160, 3871954237, 3907137702, 3942329556, 3977529800, 4012738435,\n            4047955462, 4083180882, 4118414696, 4153656905, 4188907510, 4224166512, 4259433912,\n            4294709711, 35026614, 70319215, 105620217, 140929622, 176247431, 211573645, 246908265,\n            282251292, 317602727, 352962571, 388330825, 423707490, 459092567, 494486057, 529887961,\n            565298280, 600717015, 636144167, 671579737, 707023726, 742476135, 777936965, 813406217,\n            848883892, 884369991, 919864515, 955367465, 990878842, 1026398647, 1061926881,\n            1097463545, 1133008640, 1168562167, 1204124127, 1239694521, 1275273350, 1310860615,\n            1346456317, 1382060457, 1417673036, 1453294055, 1488923515, 1524561417, 1560207762,\n            1595862551, 1631525785, 1667197465, 1702877592, 1738566167, 1774263191, 1809968665,\n            1845682590, 1881404967, 1917135797, 1952875081, 1988622820, 2024379015, 2060143667,\n            2095916777, 2131698346, 2167488375, 2203286865, 2239093817, 2274909232, 2310733111,\n            2346565455, 2382406265, 2418255542, 2454113287, 2489979501, 2525854185, 2561737340,\n            2597628967, 2633529067, 2669437641, 2705354690, 2741280215, 2777214217, 2813156697,\n            2849107656, 2885067095, 2921035015, 2957011417, 2992996302, 3028989671, 3064991525,\n            3101001865, 3137020692, 3173048007, 3209083811, 3245128105, 3281180890, 3317242167,\n            3353311937, 3389390201, 3425476960, 3461572215, 3497675967, 3533788217, 3569908966,\n            3606038215, 3642175965, 3678322217, 3714476972, 3750640231, 3786811995, 3822992265,\n            3859181042, 3895378327, 3931584121, 3967798425, 4004021240, 4040252567, 4076492407,\n            4112740761, 4148997630, 4185263015, 4221536917, 4257819337, 4294110276, 35442439,\n            71750420, 108066922, 144391947, 180725496, 217067570, 253418170, 289777297, 326144952,\n            362521136, 398905850, 435299095, 471700872, 508111182, 544530026, 580957405, 617393320,\n            653837772, 690290762, 726752291, 763222360, 799700970, 836188122, 872683817, 909188056,\n            945700840, 982222170, 1018752047, 1055290472, 1091837446, 1128392970, 1164957045,\n            1201529672, 1238110852, 1274700586, 1311298875, 1347905720, 1384521122, 1421145082,\n            1457777601, 1494418680, 1531068320, 1567726522, 1604393287, 1641068616, 1677752510,\n            1714444970, 1751145997, 1787855592, 1824573756, 1861300490, 1898035795, 1934779672,\n            1971532122, 2008293146, 2045062745, 2081840920, 2118627672, 2155423002, 2192226911,\n            2229039400, 2265860470, 2302690122, 2339528357, 2376375176, 2413230580, 2450094570,\n            2486967147, 2523848312, 2560738066, 2597636410, 2634543345, 2671458872, 2708382992,\n            2745315706, 2782257015, 2819206920, 2856165422, 2893132522, 2930108221, 2967092520,\n            3004085420, 3041086922, 3078097027, 3115115736, 3152143050, 3189178970, 3226223497,\n            3263276632, 3300338376, 3337408730, 3374487695, 3411575272, 3448671462, 3485776266,\n            3522889685, 3560011720, 3597142372, 3634281642, 3671429531, 3708586040, 3745751170,\n            3782924922, 3820107297, 3857298296, 3894497920, 3931706170, 3968923047, 4006148552,\n            4043382686, 4080625450, 4117876845, 4155136872, 4192405532, 4229682826, 4266968755,\n            9296024, 46599227, 83911067, 121231546, 158560665, 195898425, 233244827, 270599872,\n            307963561, 345335895, 382716875, 420106502, 457504777, 494911701, 532327275, 569751500,\n            607184377, 644625907, 682076091, 719534930, 757002425, 794478577, 831963387, 869456856,\n            906958985, 944469775, 981989227, 1019517342, 1057054121, 1094599565, 1132153675,\n            1169716452, 1207287897, 1244868011, 1282456795, 1320054250, 1357660377, 1395275177,\n            1432898651, 1470530800, 1508171625, 1545821127, 1583479307, 1621146166, 1658821705,\n            1696505925, 1734198827, 1771900412, 1809610681, 1847329635, 1885057275, 1922793602,\n            1960538617, 1998292321, 2036054715, 2073825800, 2111605577, 2149394047, 2187191211,\n            2224997070, 2262811625, 2300634877, 2338466827, 2376307476, 2414156825, 2452014875,\n            2489881627, 2527757082, 2565641241, 2603534105, 2641435675, 2679345952, 2717264937,\n            2755192631, 2793129035, 2831074150, 2869027977, 2906990517, 2944961771, 2982941740,\n            3020930425, 3058927827, 3096933947, 3134948786, 3172972345, 3211004625, 3249045627,\n            3287095352, 3325153801, 3363220975, 3401296875, 3439381502, 3477474857, 3515576941,\n            3553687755, 3591807300, 3629935577, 3668072587, 3706218331, 3744372810, 3782536025,\n            3820707977, 3858888667, 3897078096, 3935276265, 3973483175, 4011698827, 4049923222,\n            4088156361, 4126398245, 4164648875, 4202908252, 4241176377, 4279453251, 22771579,\n            61065955, 99369082, 137680962, 176001596, 214330985, 252669130, 291016032, 329371692,\n            367736111, 406109290, 444491230, 482881932, 521281397, 559689626, 598106620, 636532380,\n            674966907, 713410202, 751862266, 790323100, 828792705, 867271082, 905758232, 944254156,\n            982758855, 1021272330, 1059794582, 1098325612, 1136865421, 1175414010, 1213971380,\n            1252537532, 1291112467, 1329696186, 1368288690, 1406889980, 1445500057, 1484118922,\n            1522746576, 1561383020, 1600028255, 1638682282, 1677345102, 1716016716, 1754697125,\n            1793386330, 1832084332, 1870791132, 1909506731, 1948231130, 1986964330, 2025706332,\n            2064457137, 2103216746, 2141985160, 2180762380, 2219548407, 2258343242, 2297146886,\n            2335959340, 2374780605, 2413610682, 2452449572, 2491297276, 2530153795, 2569019130,\n            2607893282, 2646776252, 2685668041, 2724568650, 2763478080, 2802396332, 2841323407,\n            2880259306, 2919204030, 2958157580, 2997119957, 3036091162, 3075071196, 3114060060,\n            3153057755, 3192064282, 3231079642, 3270103836, 3309136865, 3348178730, 3387229432,\n            3426288972, 3465357351, 3504434570, 3543520630, 3582615532, 3621719277, 3660831866,\n            3699953300, 3739083580, 3778222707, 3817370682, 3856527506, 3895693180, 3934867705,\n            3974051082, 4013243312, 4052444396, 4091654335, 4130873130, 4170100782, 4209337292,\n            4248582661, 4287836890, 32132684, 71404637, 110685452, 149975131, 189273675, 228581085,\n            267897362, 307222507, 346556521, 385899405, 425251160, 464611787, 503981287, 543359661,\n            582746910, 622143035, 661548037, 700961917, 740384676, 779816315, 819256835, 858706237,\n            898164522, 937631691, 977107745, 1016592685, 1056086512, 1095589227, 1135100831,\n            1174621325, 1214150710, 1253688987, 1293236157, 1332792221, 1372357180, 1411931035,\n            1451513787, 1491105437, 1530705986, 1570315435, 1609933785, 1649561037, 1689197192,\n            1728842251, 1768496215, 1808159085, 1847830862, 1887511547, 1927201141, 1966899645,\n            2006607060, 2046323387, 2086048627, 2125782781, 2165525850, 2205277835, 2245038737,\n            2284808557, 2324587296, 2364374955, 2404171535, 2443977037, 2483791462, 2523614811,\n            2563447085, 2603288285, 2643138412, 2682997467, 2722865451, 2762742365, 2802628210,\n            2842522987, 2882426697, 2922339341, 2962260920, 3002191435, 3042130887, 3082079277,\n            3122036606, 3162002875, 3201978085, 3241962237, 3281955332, 3321957371, 3361968355,\n            3401988285, 3442017162, 3482054987, 3522101761, 3562157485, 3602222160, 3642295787,\n            3682378367, 3722469901, 3762570390, 3802679835, 3842798237, 3882925597, 3923061916,\n            3963207195, 4003361435, 4043524637, 4083696802, 4123877931, 4164068025, 4204267085,\n            4244475112, 4284692107, 29950775, 70185710, 110429615, 150682492, 190944342, 231215166,\n            271494965, 311783740, 352081492, 392388222, 432703931, 473028620, 513362290, 553704942,\n            594056577, 634417196, 674786800, 715165390, 755552967, 795949532, 836355086, 876769630,\n            917193165, 957625692, 998067212, 1038517726, 1078977235, 1119445740, 1159923242,\n            1200409742, 1240905241, 1281409740, 1321923240,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_fail_1() {\n    let mut out = vec![10, 10, 10, 10, 10];\n    limbs_mul_low_same_length(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_fail_2() {\n    let mut out = vec![10];\n    limbs_mul_low_same_length(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_mul_low_same_length_fail_3() {\n    let mut out = vec![10];\n    limbs_mul_low_same_length(&mut out, &[], &[]);\n}\n\n#[test]\nfn test_limbs_product() {\n    fn test(xs: &[Limb], out: &[Limb]) {\n        let xs_old = xs;\n        let mut xs = xs_old.to_vec();\n        let mut product = Vec::new();\n        let (size, new_product) = limbs_product(&mut product, &mut xs);\n        product = new_product.unwrap();\n        product.truncate(size);\n        assert_eq!(product, out);\n\n        let xs = xs_old;\n        let mut product_alt = vec![0; xs.len()];\n        let out_len = limbs_product_naive(&mut product_alt, xs);\n        product_alt.truncate(out_len);\n\n        assert_eq!(\n            Natural::from_owned_limbs_asc(product),\n            Natural::from_owned_limbs_asc(product_alt)\n        );\n    }\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        test(&[0, 0], &[0]);\n        test(&[0, 1], &[0]);\n        test(&[1, 1], &[1]);\n        test(&[1, 2, 3, 0], &[0]);\n        test(&[1, 1, 1, 6], &[6]);\n        // - factor_len < RECURSIVE_PROD_THRESHOLD\n        // - factor_len < RECURSIVE_PROD_THRESHOLD && carry == 0\n        test(&[2, 2], &[4]);\n        // - 1 < factor_len < RECURSIVE_PROD_THRESHOLD\n        test(&[2, 2, 2], &[8]);\n        // - factor_len < RECURSIVE_PROD_THRESHOLD && carry != 0\n        test(\n            &[\n                3364358997, 3754657515, 2983848742, 3936755874, 1784338974, 2546784265, 1325228501,\n                2948540251,\n            ],\n            &[\n                2931171496, 2374327460, 1603352486, 1643105815, 3729295616, 3598234472, 675706642,\n                97731883,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(&[0, 0], &[0]);\n        // - factor_len >= RECURSIVE_PROD_THRESHOLD\n        // - factor_len >= RECURSIVE_PROD_THRESHOLD && carry != 0\n        test(\n            &[\n                10008125746032292648,\n                18321114734333840332,\n                17920212203847604612,\n                11217657766511696793,\n                11281083380440747080,\n                7892713234117558634,\n                8902471323128328235,\n                11892365124252837749,\n                12611508814807140936,\n                11815551321438701427,\n                18110749687253320811,\n                11715728409437156086,\n                3339319126985623378,\n                6325617411041006209,\n                14096883611650388622,\n                17687808067973538964,\n                168019485471086672,\n                15693590891786235960,\n                2786725115760255375,\n                9052512570921605652,\n                14177547685319586247,\n                15370386165587184937,\n                5970865523433924174,\n            ],\n            &[\n                11912117198576943104,\n                13014631084302689641,\n                13412132452197408442,\n                2451810739915146054,\n                11634661136866399370,\n                4370855263334042992,\n                15668998660816175865,\n                12986191105652374961,\n                13086723724779814479,\n                11723085021234472016,\n                11995103430870542887,\n                9025449360203176092,\n                2596804721077076476,\n                17187504964195613394,\n                3993660956642255072,\n                14652834649000131068,\n                115931129580828916,\n                5908166419484799210,\n                5266332857336541018,\n                10618265378208305889,\n                15818414605397825971,\n                1340104142930176609,\n                707009434669,\n            ],\n        );\n        // - factor_len >= RECURSIVE_PROD_THRESHOLD && carry == 0\n        test(\n            &rle_decode(&[\n                (0, 2),\n                (18446743798831644672, 1),\n                (u64::MAX, 8),\n                (131071, 1),\n                (0, 1),\n                (18446181123756130304, 1),\n                (u64::MAX, 1),\n                (0, 3),\n                (18446744073709289472, 1),\n                (18446744069414584323, 1),\n                (u64::MAX, 2),\n                (1048575, 1),\n            ]),\n            &[0],\n        );\n        test(\n            &[\n                10985406156730349404,\n                16998073653641921623,\n                17457059674168741173,\n                7286565767689019192,\n                18125356898477139174,\n                16492808515310020304,\n                3477958611236241232,\n                16292175871113024008,\n                5585730561604558759,\n                6236295300549613743,\n                10319623255002503349,\n                9463751064224151456,\n                591089135516199459,\n                2252218169318269834,\n                862892606080353458,\n                5048725452063866206,\n                8818325570889918907,\n                8659485206830156469,\n                13423243087758132387,\n                5931638651683836702,\n                726189598260086702,\n                17552568882310631283,\n                16362554893644374308,\n                2407211671412641092,\n                1658933737262819201,\n                8531670718492391711,\n                7551068411167036177,\n                1219676338169570619,\n                3249808943561478386,\n                8240095392791493806,\n                18379760227315341655,\n                15217742262236663404,\n                17914601533857880122,\n                6316977119306097487,\n                15466746727219811764,\n                3809403759956883034,\n                7752635439402559334,\n                18006879800705758675,\n                10224737295140518487,\n                8383030445894670697,\n                7272423850473130597,\n                9751703358656322718,\n                5778325638584493526,\n                8175215950976649646,\n                8581067395248196883,\n                4729909244293992358,\n                7626677144783852491,\n                15620921255634335582,\n                17768397379068248272,\n                7127187304413875110,\n            ],\n            &[\n                3631027199567462400,\n                1271721650030716672,\n                2994855603235436973,\n                17610775060915408482,\n                5067312238234780182,\n                17332419541318968246,\n                16256455013715596255,\n                8446753555477097340,\n                6176580983302425584,\n                4478791418516115226,\n                4543632153902351949,\n                8389257049215340154,\n                7312665208898130485,\n                7684632819757707617,\n                3755281952906934158,\n                13259632617670669038,\n                8815229384280433597,\n                18114656906332551194,\n                8751551051855969605,\n                3831140942508279269,\n                3191248804852725269,\n                2021644817234089610,\n                17966341018397783935,\n                17567823138927086650,\n                7667876961419931279,\n                14788070825593093177,\n                18150799194320967018,\n                10911257712565360499,\n                17179583904099919127,\n                13486844951716301158,\n                10333473285718288690,\n                11178175053564016056,\n                7882508656916287058,\n                10989425714502087490,\n                6829028223894926894,\n                810375652491815426,\n                17216794810099974028,\n                590650088582786587,\n                4701269004129928787,\n                3119542545671269984,\n                14375368104481453295,\n                124160740720125385,\n                1360655591798967164,\n                17850602821256829937,\n                6139583463573727145,\n                14578358562855390329,\n                14560675482255305936,\n                16662995492200800253,\n                666535375735877288,\n            ],\n        );\n    }\n}\n\n#[test]\nfn limbs_mul_low_same_length_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 512);\n    config.insert(\"mean_stripe_n\", 256 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_1().test_properties_with_config(&config, |(out_before, xs, ys)| {\n        let mut out = out_before.to_vec();\n        limbs_mul_low_same_length(&mut out, &xs, &ys);\n        verify_mul_low_1(&out_before, &xs, &ys, &out);\n    });\n}\n\n#[test]\nfn test_mul_context() {\n    let context = initialize_context();\n    assert_eq!(context.clone().serialize(), CONTEXT);\n    assert_eq!(context, CONTEXT.deserialize());\n}\n\n#[test]\nfn test_mul() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n *= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n *= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() * v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u * v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() * &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u * &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = mul_slow_fft(&u, &v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigUint::from_str(s).unwrap() * BigUint::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() * rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"0\");\n    test(\"1\", \"123\", \"123\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"456\", \"56088\");\n    test(\"0\", \"1000000000000\", \"0\");\n    test(\"1000000000000\", \"0\", \"0\");\n    test(\"1\", \"1000000000000\", \"1000000000000\");\n    test(\"1000000000000\", \"1\", \"1000000000000\");\n    test(\"1000000000000\", \"123\", \"123000000000000\");\n    test(\"123\", \"1000000000000\", \"123000000000000\");\n    test(\"123456789000\", \"987654321000\", \"121932631112635269000000\");\n    test(\"4294967295\", \"2\", \"8589934590\");\n    test(\"18446744073709551615\", \"2\", \"36893488147419103230\");\n    test(\"4294967295\", \"4294967295\", \"18446744065119617025\");\n    test(\n        \"147502279655636565600250358452694051893980186696958535174009956523855720107322638159749368\\\n        0808217479494744305876890972595771484769733857514529616096199394092858302265998260483416016\\\n        5763904522044264005938281072568140883513713255548643044250086110483617215935636533809248102\\\n        6926590789142079805638445494760177551776636747830014495012489743990407355232286842071418922\\\n        9921358409573480901624487977319782755422730834468673438076805532952821406024399006814390166\\\n        6949827530796971086011267864607814906313334525518102221919643040440267323688341889035864376\\\n        1377246644579088153222669672271414315240318439843720039808993886410874969340996645010795670\\\n        2133518716987668865936529827437388042190084309005369564717390726257594902619365180097509576\\\n        6240189037770619308206906414128686856349950952623970023039440323701643457411485666776354448\\\n        186307133288106956593939073729500658176632828099789\",\n        \"577397114388109712462006371470162814529304445639807296878809567953200969820156259914159240\\\n        9106139481288193067515284601342023565222679498917484131095648263181800618990427694244342686\\\n        4412105186059052689237237088193855584354278755933606296018800151986520872701706693002473648\\\n        4330061421236425747083307907706860804054565348593527605104495080560663025897787060638154303\\\n        7631781316565710346299551930891169154491973589315700505458672804104869879731391323700304\",\n        \"851673906388325341550957943071111911557800036845129556099360938813259608650267079456739978\\\n        1156959952275409185911771336067392377245918291754269000751186715279414560474882570499082990\\\n        4913122978897463970860833616251189242098804876664368441608727895141238953179204529256780277\\\n        5978105200286025161944212712977056343127682601975191673217459602567633602198262568921008081\\\n        9448556670912575287371251190800855926311768876808375177446530243635212748346921654224589861\\\n        0625170426812525829689862407515510419445335472631905610235915226032848323874067128872385291\\\n        3730739275467227364692195226129501338887049710586931141309357190341064532366013123280106098\\\n        6468151628797945455179649866890394481799639832540978091736379482964522229064478167730317490\\\n        8194108506704480750395054067032502530392147690725919399930683143510771646869931527123340650\\\n        0547649792331568913460415939722111305270588701531404490040034302102101083691706550376288655\\\n        2667382899390792494118931379237432071316543313379792218794371176529684614085109418328963817\\\n        0601432767270419229719490809539776535671938041618536196941370647945336401901450921413823163\\\n        4059991707077834107830876756821880651429748186401020760113859498185638133726165286481741014\\\n        9079906337286599226335508424466369316294442004040440528589582239717042654541745348050157252\\\n        3448224036804997350851153108395928780441635856\",\n    );\n    let big_test = |u: Natural, v: Natural| {\n        let mut n = u.clone();\n        n *= v.clone();\n        assert!(n.is_valid());\n        let product = n;\n\n        let mut n = u.clone();\n        n *= &v;\n        assert!(n.is_valid());\n        assert_eq!(n, product);\n\n        let n = u.clone() * v.clone();\n        assert!(n.is_valid());\n        assert_eq!(n, product);\n\n        let n = &u * v.clone();\n        assert!(n.is_valid());\n        assert_eq!(n, product);\n\n        let n = u.clone() * &v;\n        assert!(n.is_valid());\n        assert_eq!(n, product);\n\n        let n = &u * &v;\n        assert!(n.is_valid());\n        assert_eq!(n, product);\n\n        let n = rug::Integer::from(&u) * rug::Integer::from(&v);\n        assert!(Natural::exact_from(&n) == product);\n\n        let n = mul_slow_fft(&u, &v);\n        assert!(n.is_valid());\n        assert_eq!(n, product);\n    };\n    // - in mpn_ctx_init\n    // - i == 0 first time in mpn_ctx_init\n    // - in sd_fft_ctx_init_prime\n    // - in fft_small_mulmod_satisfies_bounds\n    // - n2hi != 0 in fft_small_mulmod_satisfies_bounds\n    // - b >= 2 in fft_small_mulmod_satisfies_bounds\n    // - in reduce_0n_to_pmhn\n    // - a > halfn in reduce_0n_to_pmhn\n    // - in f64_reduce_pm1n_to_pmhn\n    // - a <= halfn <= t in f64_reduce_pm1n_to_pmhn\n    // - i >= l in sd_fft_ctx_init_prime\n    // - i < l in sd_fft_ctx_init_prime\n    // - a > halfn in f64_reduce_pm1n_to_pmhn\n    // - a <= halfn in reduce_0n_to_pmhn\n    // - a <= halfn && t < halfn in f64_reduce_pm1n_to_pmhn\n    // - i == 0 second time in mpn_ctx_init\n    // - i != 0 first time in mpn_ctx_init\n    // - in next_fft_number\n    // - q.significant_bits() == bits in next_fft_number\n    // - q.significant_bits() != bits && l >= 5 in next_fft_number\n    // - i != 0 second time in mpn_ctx_init\n    // - in push_profile\n    // - in crt_data_find_bn_bound\n    // - q < n + 1 in crt_data_find_bn_bound\n    // - r > 0 in crt_data_find_bn_bound\n    // - !borrow in crt_data_find_bn_bound\n    // - x[i] == 0 in crt_data_find_bn_bound\n    // - r = 0 in crt_data_find_bn_bound\n    // - in mpn_ctx_mpn_mul\n    // - in mpn_ctx_best_profile\n    // - bn <= r.profiles[i].bn_bound in mpn_ctx_best_profile\n    // - score < best_score in mpn_ctx_best_profile\n    // - i < r.profiles_size in mpn_ctx_best_profile\n    // - bn <= r.profiles[i].bn_bound in mpn_ctx_best_profile\n    // - bn > r.profiles[i].bn_bound in mpn_ctx_best_profile\n    // - score >= best_score in mpn_ctx_best_profile\n    // - i >= r.profiles_size in mpn_ctx_best_profile\n    // - in flint_mpn_cmp_ui_2exp\n    // - an != 0 in flint_mpn_cmp_ui_2exp\n    // - r != 0 in flint_mpn_cmp_ui_2exp\n    // - an <= q + 2 in flint_mpn_cmp_ui_2exp\n    // - x == b1 in flint_mpn_cmp_ui_2exp\n    // - x != b0 in flint_mpn_cmp_ui_2exp\n    // - p.to_ffts != None in mpn_ctx_mpn_mul\n    // - bits % 8 != 0 in mpn_ctx_mpn_mul\n    // - in mpn_ctx_fit_buffer\n    // - n > r.buffer_alloc in mpn_ctx_fit_buffer\n    // - in mod_worker_func\n    // - in MPNToFFTFunc::apply\n    // - self.bits % 8 != 0 && self.bits % 4 == 0 in MPNToFFTFunc::apply\n    // - in code\n    // - bits - j != 0 in code\n    // - bits - j == 0 in code\n    // - in mpn_to_ffts_hard\n    // - bits - j != 0 in mpn_to_ffts_hard\n    // - in fft_worker_func\n    // - in sd_fft_trunc\n    // - l_u64 > LG_BLK_SZ in sd_fft_trunc\n    // - in sd_fft_ctx_fit_depth\n    // - tdepth >= depth in sd_fft_ctx_fit_depth\n    // - in sd_fft_trunc_internal\n    // - otrunc >= 1 in sd_fft_trunc_internal\n    // - itrunc >= 1 in sd_fft_trunc_internal\n    // - itrunc != otrunc || otrunc != usize::power_of_2(k) in sd_fft_trunc_internal\n    // - k > 2 in sd_fft_trunc_internal\n    // - in sd_fft_trunc_block\n    // - otrunc >= 1 in sd_fft_trunc_block\n    // - itrunc <= 1 in sd_fft_trunc_block\n    // - itrunc >= 1 in sd_fft_trunc_block\n    // - itrunc >= 1 && i < BLK_SZ in sd_fft_trunc_block\n    // - itrunc >= 1 && i >= BLK_SZ in sd_fft_trunc_block\n    // - itrunc == otrunc && otrunc == usize::power_of_2(k) in sd_fft_trunc_internal\n    // - in sd_fft_no_trunc_internal\n    // - k == 2 in sd_fft_no_trunc_internal\n    // - in sd_fft_no_trunc_block\n    // - k <= 4 in sd_fft_no_trunc_block\n    // - in set_j_bits_and_j_r\n    // - j == 0 in set_j_bits_and_j_r\n    // - k >= 2 in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits == 0 in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits == 0 && i < BLK_SZ in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits == 0 && i >= BLK_SZ in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits == 0 && a >= l2 in sd_fft_no_trunc_block\n    // - k >= 2 && l2 == 1 in sd_fft_no_trunc_block\n    // - in sd_fft_base_8_1\n    // - j == 0 in sd_fft_base_8_1\n    // - in sd_fft_basecase_8_1\n    // - i < l in sd_fft_basecase_8_1\n    // - i >= l in sd_fft_basecase_8_1\n    // - in sd_fft_basecase_6_1\n    // - i < l in sd_fft_basecase_6_1\n    // - i >= l in sd_fft_basecase_6_1\n    // - in sd_fft_basecase_6_0\n    // - i < l in sd_fft_basecase_6_0\n    // - i >= l in sd_fft_basecase_6_0\n    // - in sd_fft_base_8_0\n    // - j != 0 in set_j_bits_and_j_r\n    // - in sd_fft_basecase_8_0\n    // - i < l in sd_fft_basecase_8_0\n    // - i >= l in sd_fft_basecase_8_0\n    // - k == 2 in sd_fft_trunc_internal\n    // - itrunc > 1 in sd_fft_trunc_block\n    // - itrunc != otrunc || otrunc != usize::power_of_2(k) in sd_fft_trunc_block\n    // - k <= 2 in sd_fft_trunc_block\n    // - k == 2 in sd_fft_trunc_block\n    // - in sd_fft_moth_trunc_block_0\n    // - 0 < ITRUNC in sd_fft_moth_trunc_block_0\n    // - 1 < ITRUNC in sd_fft_moth_trunc_block_0\n    // - 2 < ITRUNC in sd_fft_moth_trunc_block_0\n    // - 3 < ITRUNC in sd_fft_moth_trunc_block_0\n    // - 0 < OTRUNC in sd_fft_moth_trunc_block_0\n    // - 1 < OTRUNC in sd_fft_moth_trunc_block_0\n    // - 2 < OTRUNC in sd_fft_moth_trunc_block_0\n    // - 3 >= OTRUNC in sd_fft_moth_trunc_block_0\n    // - i < BLK_SZ in sd_fft_moth_trunc_block_0\n    // - i >= BLK_SZ in sd_fft_moth_trunc_block_0\n    // - j != 0 in sd_fft_base_8_1\n    // - k == 2 && otrunc > 1 in sd_fft_trunc_internal\n    // - k == 2 && otrunc > 2 in sd_fft_trunc_internal\n    // - k == 2 && otrunc <= 3 in sd_fft_trunc_internal\n    // - in nmod_red2\n    // - r1xx > q0xx in nmod_red2\n    // - r1xx < nxx in nmod_red2\n    // - !x.squaring in fft_worker_func\n    // - in sd_fft_ctx_point_mul\n    // - in f64_reduce_0n_to_pmhn\n    // - a > halfn in f64_reduce_0n_to_pmhn\n    // - j < BLK_SZ in sd_fft_ctx_point_mul\n    // - j >= BLK_SZ in sd_fft_ctx_point_mul\n    // - in sd_ifft_trunc\n    // - l_u64 > LG_BLK_SZ in sd_ifft_trunc\n    // - in sd_ifft_trunc_internal\n    // - f != 0 || z != n || n != usize::power_of_2(k) in sd_ifft_trunc_internal\n    // - k > 2 in sd_ifft_trunc_internal\n    // - in sd_ifft_no_trunc_internal\n    // - k == 2 in sd_ifft_no_trunc_internal\n    // - in sd_ifft_base_8_1\n    // - in set_j_bits_and_j_mr\n    // - j == 0 in set_j_bits_and_j_mr\n    // - j == 0 in sd_ifft_base_8_1\n    // - in sd_ifft_basecase_8_1\n    // - in sd_ifft_basecase_6_1\n    // - i < l in sd_ifft_basecase_6_1\n    // - i >= l in sd_ifft_basecase_6_1\n    // - sd_ifft_basecase_6_0\n    // - i < l in sd_ifft_basecase_6_0\n    // - i >= l in sd_ifft_basecase_6_0\n    // - i < l in sd_ifft_basecase_8_1\n    // - i >= l in sd_ifft_basecase_8_1\n    // - in sd_ifft_base_8_0\n    // - j != 0 in set_j_bits_and_j_mr\n    // - in d_ifft_basecase_8_0\n    // - i < l in d_ifft_basecase_8_0\n    // - i >= l in d_ifft_basecase_8_0\n    // - in sd_ifft_no_trunc_block\n    // - k <= 2 in sd_ifft_no_trunc_block\n    // - k == 2 in sd_ifft_no_trunc_block\n    // - k == 2 && j_bits == 0 in sd_ifft_no_trunc_block\n    // - k == 2 && j_bits == 0 && i < BLK_SZ in sd_ifft_no_trunc_block\n    // - k == 2 && j_bits == 0 && i >= BLK_SZ in sd_ifft_no_trunc_block\n    // - in sd_ifft_trunc_block\n    // - f != 0 || z != n || n != usize::power_of_2(k) in sd_ifft_trunc_block\n    // - k != 2 in sd_ifft_trunc_block\n    // - k == 1 in sd_ifft_trunc_block\n    // - in radix_2_moth_inv_trunc_block_1_1_1\n    // - i < BLK_SZ in radix_2_moth_inv_trunc_block_1_1_1\n    // - i >= BLK_SZ in radix_2_moth_inv_trunc_block_1_1_1\n    // - k == 2 in sd_ifft_trunc_internal\n    // - j != 0 in sd_ifft_base_8_1\n    // - k == 2 && n > 1 in sd_ifft_trunc_internal\n    // - k == 2 && n > 2 in sd_ifft_trunc_internal\n    // - k == 2 && n <= 3 in sd_ifft_trunc_internal\n    // - k == 2 in sd_ifft_trunc_block\n    // - in radix_4_moth_inv_trunc_block_3_4_0\n    // - j != 0 in radix_4_moth_inv_trunc_block_3_4_0\n    // - in f64x4_reduce_pm1n_to_pmhn\n    // - ai <= hi <= ti in f64x4_reduce_pm1n_to_pmhn\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_3_4_0\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_3_4_0\n    // - k == 2 && f == 0 in sd_ifft_trunc_internal\n    // - f == 0 && z == n && n == usize::power_of_2(k) in sd_ifft_trunc_block\n    // - k == 1 in sd_ifft_no_trunc_block\n    // - k == 1 && j_bits == 0 in sd_ifft_no_trunc_block\n    // - k == 1 && j_bits == 0 && i < BLK_SZ in sd_ifft_no_trunc_block\n    // - k == 1 && j_bits == 0 && i >= BLK_SZ in sd_ifft_no_trunc_block\n    // - r1xx <= q0xx in nmod_red2\n    // - a <= halfn in f64_reduce_0n_to_pmhn\n    // - in crt_worker_func\n    // - in MPNFromFFTs::apply\n    // - overhang.is_empty() in MPNFromFFTs::apply\n    // - self.n != self.m + 1 in MPNFromFFTs::apply\n    // - in convert_block\n    // - in f64x4_reduce_to_0n\n    // - in f64x4_reduce_pm1no_to_0n\n    // - in f64_reduce_pm1no_to_0n\n    // - a >= 0.0 in f64_reduce_pm1no_to_0n\n    // - j < BLK_SZ in convert_block\n    // - j >= BLK_SZ in convert_block\n    // - in big_mul\n    // - k + 1 < n in big_mul\n    // - k + 2 < n in big_mul\n    // - n == k + 2 in big_mul\n    // - n == k + 2 && k + 1 < m in big_mul\n    // - in big_addmul\n    // - k + 1 < n in big_addmul\n    // - k + 2 < n in big_addmul\n    // - n == k + 2 in big_addmul\n    // - n == k + 2 && k + 1 < m in big_addmul\n    // - in reduce_big_sum\n    // - in multi_add\n    // - n == 3 in multi_add\n    // - r[k - 1] <= limit[k - 1] in reduce_big_sum\n    // - r[k - 1] < limit[k - 1] in reduce_big_sum\n    // - in add_to_answer_easy\n    // - tshift == 0 in add_to_answer_easy\n    // - n == 4 in multi_add\n    // - tshift != 0 in add_to_answer_easy\n    // - n == 5 in multi_add\n    // - in f64_reduce_to_0n\n    // - toff < z.len() in MPNFromFFTs::apply\n    // - in add_to_answer_hard\n    // - tshift == 0 in add_to_answer_hard\n    // - tshift == 0 && z.len() - toff >= n in add_to_answer_hard\n    // - tshift != 0 in add_to_answer_hard\n    // - tshift != 0 && z.len() - toff > n in add_to_answer_hard\n    // - tshift != 0 && z.len() - toff <= n in add_to_answer_hard\n    // - a < 0.0 in f64_reduce_pm1no_to_0n\n    // - r[k - 1] > limit[k - 1] in reduce_big_sum\n    // - goto_sub in reduce_big_sum\n    // - in multi_sub\n    // - n == 4 in multi_sub\n    // - r[k - 1] >= limit[k - 1] in reduce_big_sum\n    // - !goto_sub in reduce_big_sum\n    // - r[0] >= limit[0] in reduce_big_sum\n    // - slow_fft: in mod_fft_worker_func\n    // - slow_fft: !x.squaring in mod_fft_worker_func\n    // - slow_fft: in slow_mpn_to_fft\n    // - slow_fft: in slow_mpn_to_fft_easy\n    // - slow_fft: bits - j != 0 in slow_mpn_to_fft_easy\n    // - slow_fft: bits - j == 0 in slow_mpn_to_fft_easy\n    // - slow_fft: bits - j != 0 in slow_mpn_to_fft\n    // - slow_fft: bits - j == 0 in slow_mpn_to_fft\n    big_test(Natural::power_of_2(100_000), Natural::power_of_2(100_000));\n    // - bits % 8 == 0 in mpn_ctx_mpn_mul\n    // - self.bits % 8 == 0 in MPNToFFTFunc::apply\n    // - tdepth < depth in sd_fft_ctx_fit_depth\n    // - in sd_fft_ctx_fit_depth_with_lock\n    // - ai > hi in f64x4_reduce_pm1n_to_pmhn\n    // - i < l in sd_fft_ctx_fit_depth_with_lock\n    // - ai <= hi && ti < hi in f64x4_reduce_pm1n_to_pmhn\n    // - i >= l in sd_fft_ctx_fit_depth_with_lock\n    // - k > 2 in sd_fft_trunc_block\n    // - in sd_fft_moth_trunc_block_1\n    // - 0 < ITRUNC in sd_fft_moth_trunc_block_1\n    // - 1 < ITRUNC in sd_fft_moth_trunc_block_1\n    // - 2 >= ITRUNC in sd_fft_moth_trunc_block_1\n    // - 3 >= ITRUNC in sd_fft_moth_trunc_block_1\n    // - 0 < OTRUNC in sd_fft_moth_trunc_block_1\n    // - 1 < OTRUNC in sd_fft_moth_trunc_block_1\n    // - 2 < OTRUNC in sd_fft_moth_trunc_block_1\n    // - 3 < OTRUNC in sd_fft_moth_trunc_block_1\n    // - i < BLK_SZ in sd_fft_moth_trunc_block_1\n    // - i >= BLK_SZ in sd_fft_moth_trunc_block_1\n    // - itrunc == otrunc && otrunc == usize::power_of_2(k) in sd_fft_trunc_block\n    // - k >= 2 && j_bits != 0 in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits != 0 && i < BLK_SZ in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits != 0 && i >= BLK_SZ in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits != 0 && a >= l2 in sd_fft_no_trunc_block\n    // - n2 == 0 in sd_fft_trunc_block\n    // - k >= 2 && j_bits == 0 && a < l2 in sd_fft_no_trunc_block\n    // - k >= 2 && l2 != 1 in sd_fft_no_trunc_block\n    // - k >= 2 && b < l1 in sd_fft_no_trunc_block\n    // - k >= 2 && b >= l1 in sd_fft_no_trunc_block\n    // - k >= 2 && j_bits != 0 && a < l2 in sd_fft_no_trunc_block\n    // - n2 > 0 in sd_fft_trunc_block\n    // - 1 >= OTRUNC in sd_fft_moth_trunc_block_0\n    // - 2 >= OTRUNC in sd_fft_moth_trunc_block_0\n    // - k > 2 in sd_fft_no_trunc_internal\n    // - a < l2 in sd_fft_no_trunc_internal\n    // - a >= l2 in sd_fft_no_trunc_internal\n    // - b < l1 in sd_fft_no_trunc_internal\n    // - b >= l1 in sd_fft_no_trunc_internal\n    // - k == 2 && otrunc <= 1 in sd_fft_trunc_internal\n    // - k == 2 && otrunc <= 2 in sd_fft_trunc_internal\n    // - k > 2 in sd_ifft_no_trunc_internal\n    // - b < l1 in sd_ifft_no_trunc_internal\n    // - k == 2 && j_bits != 0 in sd_ifft_no_trunc_block\n    // - k == 2 && j_bits != 0 && i >= BLK_SZ in sd_ifft_no_trunc_block\n    // - b >= l1 in sd_ifft_no_trunc_internal\n    // - a < l2 in sd_ifft_no_trunc_internal\n    // - a >= l2 in sd_ifft_no_trunc_internal\n    // - k > 2 in sd_ifft_no_trunc_block\n    // - k > 2 && b < l1 in sd_ifft_no_trunc_block\n    // - k > 2 && b >= l1 in sd_ifft_no_trunc_block\n    // - k > 2 && a < l2 in sd_ifft_no_trunc_block\n    // - k > 2 && a >= l2 in sd_ifft_no_trunc_block\n    // - k > 1 in sd_ifft_trunc_block\n    // - in radix_4_moth_inv_trunc_block_3_3_1\n    // - j == 0 in radix_4_moth_inv_trunc_block_3_3_1\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_3_3_1\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_3_3_1\n    // - in radix_4_moth_inv_trunc_block_3_4_1\n    // - j != 0 in radix_4_moth_inv_trunc_block_3_4_1\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_3_4_1\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_3_4_1\n    // - in radix_4_moth_inv_trunc_block_0_4_1\n    // - j != 0 in radix_4_moth_inv_trunc_block_0_4_1\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_0_4_1\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_0_4_1\n    // - k == 2 && n <= 1 in sd_ifft_trunc_internal\n    // - k == 2 && n <= 2 in sd_ifft_trunc_internal\n    // - in radix_4_moth_inv_trunc_block_1_4_0\n    // - j != 0 in radix_4_moth_inv_trunc_block_1_4_0\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_1_4_0\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_1_4_0\n    // - self.n == self.m + 1 in MPNFromFFTs::apply\n    // - k + 1 >= n in big_mul\n    // - k >= m in big_mul\n    // - k + 1 >= n in big_addmul\n    // - k + 1 < n && k >= m in big_addmul\n    // - n == 6 in multi_add\n    // - n == 5 in multi_sub\n    // - tshift == 0 && z.len() - toff < n in add_to_answer_hard\n    big_test(\n        Natural::power_of_2(0x3fff_fffe),\n        Natural::power_of_2(0x4000_0000),\n    );\n    big_test(\n        Natural::from(0x3d500b05e209u64) << 0x3fffffbc,\n        Natural::power_of_2(0x4000_0028),\n    );\n    // - k == 1 in sd_fft_no_trunc_block\n    // - k == 1 && j_bits == 0 in sd_fft_no_trunc_block\n    // - k == 1 && j_bits == 0 && i < BLK_SZ in sd_fft_no_trunc_block\n    // - k == 1 && j_bits == 0 && i >= BLK_SZ in sd_fft_no_trunc_block\n    // - k == 1 && j_bits != 0 in sd_fft_no_trunc_block\n    // - k == 1 && j_bits != 0 && i < BLK_SZ in sd_fft_no_trunc_block\n    // - k == 1 && j_bits != 0 && i >= BLK_SZ in sd_fft_no_trunc_block\n    // - k == 1 in sd_fft_trunc_block\n    // - j_bits != 0 in sd_fft_trunc_block\n    // - j_bits != 0 && i < BLK_SZ in sd_fft_trunc_block\n    // - j_bits != 0 && i >= BLK_SZ in sd_fft_trunc_block\n    // - k == 1 && j_bits != 0 in sd_ifft_no_trunc_block\n    // - k == 1 && j_bits != 0 && i < BLK_SZ in sd_ifft_no_trunc_block\n    // - k == 1 && j_bits != 0 && i >= BLK_SZ in sd_ifft_no_trunc_block\n    // - in radix_2_moth_inv_trunc_block_1_2_1\n    // - i <= BLK_SZ in radix_2_moth_inv_trunc_block_1_2_1\n    // - i >= BLK_SZ in radix_2_moth_inv_trunc_block_1_2_1\n    // - in radix_4_moth_inv_trunc_block_1_4_1\n    // - j != 0 in radix_4_moth_inv_trunc_block_1_4_1\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_1_4_1\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_1_4_1\n    // - in radix_2_moth_inv_trunc_block_0_2_1\n    // - i < BLK_SZ in radix_2_moth_inv_trunc_block_0_2_1\n    // - i >= BLK_SZ in radix_2_moth_inv_trunc_block_0_2_1\n    // - in radix_4_moth_inv_trunc_block_2_4_1\n    // - j != 0 in radix_4_moth_inv_trunc_block_2_4_1\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_2_4_1\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_2_4_1\n    // - in radix_2_moth_inv_trunc_block_1_2_0\n    // - i < BLK_SZ in radix_2_moth_inv_trunc_block_1_2_0\n    // - i >= BLK_SZ in radix_2_moth_inv_trunc_block_1_2_0\n    // - in radix_4_moth_inv_trunc_block_2_4_0\n    // - j != 0 in radix_4_moth_inv_trunc_block_2_4_0\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_2_4_0\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_2_4_0\n    let p = Natural::power_of_2(33554432);\n    big_test(p.clone(), p);\n    // - bits - j == 0 in mpn_to_ffts_hard\n    big_test(\n        Natural::from(0x16fb3b96u32) << 0x3fffff34,\n        Natural::power_of_2(0x4000_0100),\n    );\n    // - 3 >= OTRUNC in sd_fft_moth_trunc_block_1\n    // - in radix_4_moth_inv_trunc_block_3_3_0\n    // - j == 0 in radix_4_moth_inv_trunc_block_3_3_0\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_3_3_0\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_3_3_0\n    // - n == k + 2 && k + 1 >= m in big_mul\n    // - n == k + 2 && k + 1 >= m in big_addmul\n    // - n == 7 in multi_add\n    // - n == 6 in multi_sub\n    big_test(Natural::power_of_2(63936), Natural::power_of_2(63936));\n    // - k == 2 && otrunc > 3 in sd_fft_trunc_internal\n    // - f == 0 && z == n && n == usize::power_of_2(k) in sd_ifft_trunc_internal\n    big_test(Natural::power_of_2(64512), Natural::power_of_2(64512));\n    // - r == 0 in flint_mpn_cmp_ui_2exp\n    // - n == 7 in multi_sub\n    big_test(Natural::power_of_2(86016), Natural::power_of_2(86016));\n    // - 2 < ITRUNC in sd_fft_moth_trunc_block_1\n    // - 3 >= ITRUNC in sd_fft_moth_trunc_block_0\n    big_test(Natural::power_of_2(103936), Natural::power_of_2(103936));\n    // - in radix_4_moth_inv_trunc_block_2_2_1\n    // - j == 0 in radix_4_moth_inv_trunc_block_2_2_1\n    // - i < BLK_SZ in radix_4_moth_inv_trunc_block_2_2_1\n    // - i >= BLK_SZ in radix_4_moth_inv_trunc_block_2_2_1\n    big_test(Natural::power_of_2(196608), Natural::power_of_2(196608));\n    // - 3 < OTRUNC in sd_fft_moth_trunc_block_0\n    big_test(Natural::power_of_2(831488), Natural::power_of_2(831488));\n    // - 2 >= ITRUNC in sd_fft_moth_trunc_block_0\n    let xss = \"24332291938350038903987086117452297484640131355471951974855407437218461662995085424\\\n    1860343418803581980657405626860254652890061074767469192047813813799932319718522304171962256525\\\n    7568055010500751693801073277207915783608062444476635234859794533294164960300047032518429869718\\\n    0052375107888369790876137797913656159503367175950921134284892262945719972924783600113662790091\\\n    7723137030730717109700031076462319946729252039277677223053596049990468731493768134267546652245\\\n    9447539562895196690291348300229856993968834050493144473459087214855851757452241695990617787853\\\n    5199110900136732650745267977111595354409876835104545902940816295224847190897196586187642185942\\\n    7115084845311162640011317079975305649053712739504852532939021059106632665478282767934276018468\\\n    3772465062808400010091575582223455939006711157609546345615881921362719919601326216561019357404\\\n    1307776016479445080199091132571997412545060655069163981698127006802628570553632609577780538500\\\n    3707180977422074551828555726659024662683193823385532498118408491723608092599551772313009613576\\\n    9202093170363335286917554623386262649548756047946587691518367947774996520656284075670983115064\\\n    1575561983250471453563242494332027835434592225708375455816732666820644708164077370144244709924\\\n    2886492316681462424687403046620621334999846710010915455227140598754811069666079446786776250465\\\n    1158391318965589187497341988747157410814695119596376070806690317808127211429138816443900046579\\\n    1713504851157547960393907525383172895098955573889994108135487994839225140144512698339040295307\\\n    4983198507370789525216254751572115706023212347379274683752751119359793048368824363371149895523\\\n    6708716721566125659384073633508318562863418191074523407590701176579663244163366170416731471042\\\n    0881494463153749413765094325829460446318165910401791976980543893866068276302268063932544653016\\\n    5446401851712336229001129440172467672330551520402075974514581592122579944576588625658770872147\\\n    3814466924989513800849277908506132844631331613100121400327222682060783945131182176703570032858\\\n    1694191759633514739449029442304916719067359422626377238687968978008224643603240938590144618019\\\n    5974470266383166442744450178377455275616015689358085839578524704077624355704288991739128107030\\\n    7944356865755249007269951629748947739853589497099489959849775244527083957050938890967276078321\\\n    7234404421413669718730038426475200271735571020287092847099289050730297264949167253932526806757\\\n    5761574850542650689403252780749160325307909643026214138555913283748651923074985778370994249224\\\n    0538100363691026775023717853871551279871815549992695845552242809187014152149852925091682826897\\\n    0100250490120849350712930590565284560396151845148609154567900261991659015189427805827613513840\\\n    2170254890548213557921865008034436480864143142943575002317883943975921600818662788252456195796\\\n    9447581468425720833225730520539264714015417324821258134938643521929335724439553850668221566620\\\n    9653372789560194862201973172518669820406209880954310599408074691560758794196569253974787849604\\\n    0774806073544962056857697166426572919998961349923037111540287606972184621706891929894655664837\\\n    7299630550611392558865110193262321196476727501877710107986226105792040010118482608036131448182\\\n    0117942605612310576811461708465035885447882695924553186493804383583383296673755075165009425413\\\n    7902911985641095285650983114630215230812593379260105786492476324242972811986138247168152651256\\\n    1657597868369438065816705013956080825126024961539665573062075205110450571733109317102657929184\\\n    5392136845155953496969869518778271324578196626603171710776025271793126614077090441609966141249\\\n    7564550738269080462472436036602779169468412236753684502462987305092434452135040410366722125314\\\n    2121092955111992583432284424064604710829455130399212898733562868981102772481600659980518115186\\\n    8941956481181061336467477352250281585781890099852282348615063663284636964073977423518637726988\\\n    1882455638952079577385262849303256253047928272821306192874241480405083194569987960280849589197\\\n    9041502642441824495701127000226367651264029302468437554790510342503980748137332892679198508283\\\n    2745785497776645520349039567530649346901888256310592138908124191299572459222799154644000700887\\\n    5493273958509265831183039516557237163741608869141769472683318845718901198903429866035439036703\\\n    1660739118209863418959025889435705192584893889664911545868560854311859470957036057997797971494\\\n    9594620952627927226895665205135051298929237955012336474516638364366879602654222749489576920140\\\n    1318979413859115848991007818030170744198159538630775848274453280720838340018046108312511173154\\\n    1188508107938930293795518178576635436138460554498353633963905882970277705168749377789845155952\\\n    4046716501223496052457375457150747483247403948712634771689237194996834184555628278768787640661\\\n    2372930326732128380641801437674515050015102288649901511810982723595351594068392716225599079089\\\n    7141248147850585347340347757078749027234015237390954477920785794414160228011889578891858827269\\\n    4508081089273025619651528529620265738787963624424963422805984686902171986907635940163516673467\\\n    1155594542959710450739107283869735164216439962843577553460754034992131140408553869374139050671\\\n    8450114951382241887892041208648008140979233339479046369051440737102608072264939682976419595968\\\n    3413896931667290581888677992785581066829903256901254436110000731831303537790270657076522229890\\\n    9754224348408990685592550990298278035179012217735194179912617357301891964389443682832716913065\\\n    5919450467625243008402724262864414724869527161380535200659835132577737473843355193862226646260\\\n    5917441484316297436589404142390177228546728707107334838679844265630396267767368973104829422596\\\n    4841863445594624523412084728039594631547587966918797170352167897829291584959443989673299826182\\\n    8176064493225754295777402784264651240473071834468650888202279832376595199290014151001790898088\\\n    8058661551199293778280650366579556501013484442751446773728015384143389787231217456258934188739\\\n    5896429594127218742822188813069161682965414824040997384010926995603056099487738813358316336237\\\n    2734428969066095632539853611968820662320319907498725771573336282476197704351509672049102759380\\\n    1044103415660565643697738457112577215858363311385328752890557311941900303869448413209818047617\\\n    2161153309772547939099075533202437403831740157362321227529471592353138031815867815519584071649\\\n    0075624207080493141540692388138745915962336493655092425288749464092167701822102541814916477264\\\n    3225692001069823029594562785625284238026849939613336498119461792246559953436606295049089119377\\\n    4141880555871541099485841865699217690368990323296714388728658411576310723412148324894713183283\\\n    4801500365755458165963393555761451023119653317501067666748424009917402509388520284485265783859\\\n    4511326665481049662430681317565668801625733953464868640523431972011024627186538495185957786882\\\n    9978407950806799105487884906168404211352484266994537079818819955059544683145533593154717193045\\\n    5690117445417170001831918307910549744284542110192258349795624756723502659770683585718793894280\\\n    2618016103430682458503045911456259958793713838831389358734769335617062903694409579189685200809\\\n    3962764608923109615152818499046008749652174640992925750313000312436473383850032668149986379348\\\n    3052059498095257336376699231032337021048693681952251198585124389201819206230457935652529344909\\\n    7032725206275909927921260089910589468718979227475505269422145304016465491141881920960641536301\\\n    9140778639285252843615315347803978849851275461130830082552705990112742076614360383648416456541\\\n    2620740441101005039101955780389522613136336610613941329477210480185426325439358233001773297660\\\n    9163306882983187966915074460848060626898018842789705866023645418113336930855359551069826565004\\\n    0921102721631559172518354921016090739304963047991219849191894350293960817841734486950376870017\\\n    0076890631341409067384852676671730509374135458737119463320500805149470712740494774765551306005\\\n    7497065504745979610060646071615547125076512272991200851098787288526656035043802369734788537676\\\n    5999527227307243709948931238288328361709198802167306871854810710240003118830094819219292506636\\\n    5177957833829982816610132430867293318027373604707422789037821690540765963683896618187295645179\\\n    1465465910620464203666009275003558490179921077930931841015356629871206543956889840135639950613\\\n    7943153152975279122303869038568618475611119099638012260534125935003687543282958757834514274329\\\n    8029540976704570219566860682432822482158902375283592902784329782496305851046570054193792219427\\\n    9485151146259777609149738244956435012404750481510259192922058659329097228841369921119338248144\\\n    5144990924670230925806613274253511654078353750986815191334361655047686458006940103554742338844\\\n    2996477697587180518909174341201833718921101902191805699329999642546038418439738974037767934139\\\n    4743240993941394237299681520300292915929157415122041138714963094923702569798082717524956709263\\\n    7469162139345324717625587072860337921223986281051880784176277686207708498055728109949736823705\\\n    7245406404338640127150902630698793282752353626567738257348054787636152150919474556424556416085\\\n    9242324913557076550403003463354315260332742839134901122827265128935344664134760590658232898313\\\n    4749297924337839102130389030256770756058101552976916312109473278623132414203960858313527050774\\\n    8416019492226068732568542682794600052262279127731494596591717964985920066225626223198223796413\\\n    1784081307061487078712109666514043915684890820934517841584866232599220848561086080433302064635\\\n    2818636241118301134711714478472109195521641030791287959152500316191060632930686770715396136911\\\n    6145212472889552306439006284375931483070640164268382500190346782914018049417391064347247556582\\\n    9413442538635109096759187010332782147239059430531857250909638754562430988011098753736861604897\\\n    8472333444845034550062549828954661268433024332114249123455785180064689320176371932182264176035\\\n    8294482591531728830671400138343351662388507919381384945834162923650554738532233248236905717208\\\n    4371458846779017274596261199191657039553147558727987908937446203014783299434908856942547391898\\\n    2927501875542627249407163335088990877365710910999693654933279772003198350572004741962455931775\\\n    7171123129267098877971493113576729981547769942560816700917696252793245955639009321078227773329\\\n    7851130748491137795432271895769808348131521593099235911758726082604043978287828511366498366272\\\n    7946332260722583996941431178344\";\n    let yss = \"49986023021671159338234958176162840952750418022066456297978552959263821471149534290\\\n    1697813271825404512098259628101645631265382807342205907557504103916359976160073306946293880698\\\n    1662074805927546804336458708253892368556595356275551333432939856763403440056846017507376179154\\\n    6130070689002887720179755066181472399803996205313588880667402355892709408877039008165376155611\\\n    8833053299304919241773521395447464574914194618709827505030318572684286207139960048221916106759\\\n    7388136957593182004515327723852486922779902882315701756480152829849481353729417070316130463012\\\n    4915620377469778282378671900319212800220341585503454020200498048551225521991137349961355639059\\\n    9045683055121749029430429913783794621627008689181999482845317945110832673932889057461313419591\\\n    7366856121415704241159870644369868436539309674069236834052704360730458108482806016773495335956\\\n    4528677611065085068374102907023639986197979487152880688132523807643407387541681699574051916707\\\n    0856611470229956834194648266355010747625653820905927618097314765243765600873978740755411521339\\\n    2343489348696429854679396160063333561928973571320460657290371523206395514385969450772655908356\\\n    3946349652553436962781388799395105657256079392649940276869323151880453779456303906669618884418\\\n    4748213872919853121921649700464759290793856659707061350368861694158357035539960829806629938765\\\n    8524059543868212074822662384543242523137785846616894644999628024338373327335670240422427532490\\\n    4976957556832131150797694352637314063419871686706121808418852137774685433345853146152737466053\\\n    9027847096902811897278891837763549141081018305350099606428686972075414535727837623589103289889\\\n    2653033906922683170983111487034653245661901683224583717438274009780766663932952889867173872216\\\n    3528834042840064974161831805467075423358308345791666657282483731621589611702692621655620635132\\\n    4647383475600294778328782760149901051783697552634983886672165494284112212226996408909260092172\\\n    1209515365523076697613793195345034249576286829616236018833516540275239929095595320728790483468\\\n    5952567115663448293467918755035112907283582981180892655910365086569310851994903995611331244083\\\n    0759101920816860006762328287625653148732441277373752651290948147078399895543658282424602680512\\\n    4450319258670159177503948997092473091634337478435841649565395552198228515220026631361038515989\\\n    6008909655674643454636534859266174227862769005497970812712788786438416933181370095915134881593\\\n    7453823784993350480816235445230899481282835134853215069171296466903952486563572719247905311627\\\n    0496670286299027705582613627110949955544857867258854710759283897123655985161413141553463266669\\\n    5284086972851941120003596474309921298102521418698713818004812560079034519833169906858085634879\\\n    8492549066845639204143632742452049096507871475616729113428720350859433409227252203624555741060\\\n    3196352280527701042841089345637124435223914874828124802748560281881681799439537320633256056580\\\n    4156026787910778438508277249005521534630639301441732364023551715928961017459736841352186138801\\\n    1337148412994518373489133794679517322318365623247353057252452496661753255047570675115957301860\\\n    9112177772566247230223009000540616912993224490975694174266633020622987721635236329911120466456\\\n    5418407900957106349110150601850739989712518415082040797557572247929861269033908150734384968110\\\n    8932455850426214452112011729709324456960260108601691062738149082220832267730898589815279434890\\\n    8731367664671689830915200543507814253666591232649680025848675839428814036938186706298556028019\\\n    8340087240686784933163060071736151475110131245549108127116529261607596945172302196135332469182\\\n    2458607332485123957028751177656722291448808792368654264327261281014154853457778969261777340559\\\n    7820944059397018304265075538641167817892288619991267263371281902098303123446276145187692893714\\\n    9519477717893540354124457356479560755692246865603374437898985061206835197663878005596126352779\\\n    8973735718985742351606661813037929337194407431390752136954074249275422986339524417693143549802\\\n    0335270164598612214223957762794369560852351531305033791198149794138338640587678243218831296244\\\n    9252352565142214912078307808513477954279768798278928482294453975202584186089232485657574888185\\\n    6031763044216088151481252369367292673988611669575689475800498206137106305998068313746955957820\\\n    0898959943715624581680437628483422508930020239888595530624411360849877220442056634888338116460\\\n    5796781702339175060718767743806961654069186864640928091912320604237499435818315873883177549731\\\n    4438904608176247944489768409828794492539633534990683608905894741058481841707656906146599397796\\\n    6768259361077203430956669648441598210464782762231903192060859166679745206592863086434524406080\\\n    5061755086355357462714581875611743718074941956885489546796755461792504837987295794891172817287\\\n    0724068070496151658738717629278041508299657508683362051771745956810759194283451521508725826963\\\n    9728920379968574843966573614659163753591890794499691092061855684094434397565281152388322750830\\\n    2936562287627323018853086396258713256975769929020698380563560822565434548344902010781581961113\\\n    6846799702142004544498000369221380175772227843670470877051624358052371815798951337768390510076\\\n    9409832265531426982386129993248366541262908912775394898991260470179640239850971572873576639146\\\n    0766023953632563710626344216028593861078092260436139150339410472941227133577975903169047261355\\\n    1286160605974435750779172103351483297148795491707834283345653811958446520751210104929605906463\\\n    8185475917883307983337605285498406960425765658701147677389858761447063612138035885880248764418\\\n    0748709518703251644755843442465444670908671645745260888437535662991793184515770447143003193711\\\n    9812800905926079799287254740538420618385578908149484836090770265514044030253609447874025119272\\\n    3480780734335681961228953453625209470164376934899598331663140871406504756470067958176602840891\\\n    3436442573858116115859927570931711479720756600147839785260298044727713113502175161458254976961\\\n    5193984435343121159688571749401128857212741047738499804621155554862904838772869693286169394915\\\n    1312799926015215198733037480015574027711692265262920774454728864910483477543058234197233693982\\\n    9854575761867426951614210435618496028943715087175509224607105302432211645050050014916735867955\\\n    8103623297355427518046543928487982692762907797960498528428131138612102741202908788346397760320\\\n    2524143378401628287662841125571954135057948368738774757969643636714767963407417162659302685512\\\n    8078751656882349980792598629587459818756718355995492110337091777094448215056286946305420952348\\\n    7907976968085868385719164309501356100989128621029393183784698027409528502198678395311126499017\\\n    5184078585187462463126390818095767355613741195752813402056469274433803969542775165270549682738\\\n    2994221189144324375616529121968065193153698977889390489529063408255321227994387793667565786248\\\n    0808528776367839679631291070375207236929445733454058666648248477769134783729050011898234448139\\\n    8993349590845032746041683821367673923688025810664386525049996592462264181990263339376525654153\\\n    4688151621726091616535727805714892825811298471657355668420402131840889243871828391480349478084\\\n    1213765438943540133044085760161534161208789357410256539569977329485151326150253004654954138455\\\n    9528722792944814364403837930363539896602600983699004042866687632353453663526069531834494269643\\\n    6624147575765331407694382297848351919166320173044864770828732883439182068060588130882501033804\\\n    0426743547448560272270992151301010517288598482787736061847035042543408941070253189852377368236\\\n    5819285727707133621429682730553395262311383860592921007748108439490439695147542072175642494720\\\n    9186868357355874856321966099953420439063924992162849756038603496112175054259539095438866582976\\\n    6448034908908817431100755042166004224252366973363571941886452859732159244757259171690567663609\\\n    7820964546827311588907206586044315551261101653299643794653053921049546419022858313716515856016\\\n    9161352282239091485605774765418891283015609612161818811141756563412398965270446850439762930727\\\n    1265075579650826465228364126253295503805755667305256326858589301862775090627315862498749476466\\\n    5428979346350682598783408400338865960837778435472824084279088177330330924438375832485050622689\\\n    1845171136765480273513707659451547470995294048552664487099071040377185268342654442566810830732\\\n    4273513559219196205203596252617697591102969064233059094243908088488693919507934017774058038965\\\n    6263477430311466323204338900688790511716430260269131263610162536382141534419239598123834721535\\\n    7844592966593264252037726111804716954810757673132330127022598731762031385743976596172355813665\\\n    8480585852428547059110495615340614682950702555357034774448527842527146113799842996037197304714\\\n    7511095490017614974885494779593205520787632249896540560961973768456316308007702563131577489302\\\n    4561823195237759568667232432027224183051859663362951333169612156464887803455625542942599160437\\\n    5624552818074522769402266855047645311091525988788806372446915533919508544950989012353064267814\\\n    8722029063631900541826014930971405994493634820662854594679957921971967269769680442274246327486\\\n    9746371794640241061632031872872053100078737421077754432648654919104914170154435065760826466975\\\n    7169377910522567372804407001292614259638626753514507271966727696261573427794915793151679539763\\\n    4989425490891894541416149446530840365758986362872467856074888391102749796306735242750309946782\\\n    7579284241115079618442310878308488366619100287557690496233096974073161139330022873310171282850\\\n    4635571065857423603544509499047009712504115889494586205527905746183195858773353311783193070505\\\n    9428691781371137736515083221254304729786933875723962919401362205138045992360794107715696913012\\\n    2363634336555761019688771513854347236745591124597977931405047860990814058116324491611973808078\\\n    8746960293563921321195150193375644913386886152791398578015232715295689691142604068424501220707\\\n    7788613749364152338025022822664609020596184735818260271093787518347711368354620419591342960229\\\n    4934671771673075601901855504491624212792968594327756267651515758730103152919533027139889964288\\\n    6292506703401688639837384652257978255734467511755799544669144610945157888358221232087883623303\\\n    7336755369954272851540923633879586178859053839517598591994009903776871896539495808824221515299\\\n    9619928149403248241048135646994567076173140201129595245173866036775948723989175231691600687146\\\n    2371427211437232442634762429962042736305968547125977281297596069746748020754875733965108044186\\\n    3763137353813976688054206726402967783171906947227503091923172924009664820220071663450524990481\\\n    1945104599860297464777237922614956378065063679948653629951460111041261464500508663182414576795\\\n    4000719678894140937974409070550812074001499406734602910143851047307308360678796014677323567818\\\n    0450168089940330290360709389098366611796682858811124857036910846797801916334077428533361491667\\\n    5845136113084514958652880145099929905918630443588356653224719499124763809124211973358004517696\\\n    8706425654805403429023865013160069207660629615239426877230724212687859465529115217627878556897\\\n    1638150738123832518092554735755792320495355998230714470444854106602427967029384193253867491473\\\n    7437146125337596900140389709103055161683821547785426150170598626093352210883309022624155459005\\\n    7023874273453933333145549786552126218329698096093321915695210032747749195700141202903866023274\\\n    0376633417085953345929177515640194608571280489382840834700778870646340564131039840486762803387\\\n    8662602815513501875838289244070743971820590656831867856198960478033876196228477483069329209006\\\n    6776885868466994131646489834529037463487506421343322355100757225755441259884596858232828982843\\\n    4651649119628632304969902774966388158308632803045338660094941692386732432017110234780880092628\\\n    3649392078388188822343673570603295943980920810074101483329113978921981993197172306955792863870\\\n    0670904292434515529343533958764853200311790341334890613459290566779335199536065037960295448113\\\n    7925935086611484850281668515785944773203170743155592727715467609268423284205942098901179664537\\\n    3404417709386817738463277133698265088091414301653009565806991377858914014096157420849022539503\\\n    7005978994395410100409901622576780438723136932658434089792158053603100876816330760350084907612\\\n    8364007449447019604977244808931089296625313671915025405830000848017458187191803647966668368091\\\n    5375491728096552655673108940550343585304244886521802832130426211912860269555074832924115409645\\\n    385085658742611904956365491830224265423778799183469243527078852296914873108660775012984921\";\n    big_test(\n        Natural::from_str(xss).unwrap(),\n        Natural::from_str(yss).unwrap(),\n    );\n    // - k == 1 in sd_fft_trunc_internal\n    // - k == 1 && otrunc > 1 in sd_fft_trunc_internal\n    // - k == 1 in sd_ifft_no_trunc_internal\n    // - in sd_ifft_base_9_1\n    // - j == 0 in sd_ifft_base_9_1\n    // - in sd_ifft_basecase_9_1\n    // - in sd_ifft_basecase_7_1\n    // - i < l in sd_ifft_basecase_7_1\n    // - in sd_ifft_basecase_7_0\n    // - i < l in sd_ifft_basecase_7_0\n    // - i < l in sd_ifft_basecase_9_1\n    // - i >= l in sd_ifft_basecase_9_1\n    let xss = \"92178880216095181211666676829145138370840306649787951361975829268163297384165754808\\\n    4756063405654098801011060930436693280675742944960017098004214801917753316815018149158787859165\\\n    9395300322111008817206410403503222862298862158402706092516171953423073235157842305744193289276\\\n    0199823879480276467262088886778607308395525062932232880604136063041439063365460112144872325877\\\n    7811437625627573820240086261266117827231674835705510157352288567620759933922883923925467129485\\\n    0814639434022945267787254298597769652760997261721274518217329594058447021665620310437095357991\\\n    5175605696860846854327832301621757698220417241976755189345968350443138036702177163804669879333\\\n    1749587961567883818459754867867584245313746514165087972856312186120232022411062835757426550707\\\n    4622170384289216212403163481519739652983828591245806571451382580470001509986746550375107141829\\\n    5041192502748258698046492665731973650404141610257237221869777201853847126201629101101256979663\\\n    4215522985230416617064181229401998214577283162762452604574976316076929257476979465101831676820\\\n    1407487941066549241059843831269982406703297048975397272372445630568821339462845327127639496465\\\n    9576066224901105931725511863239462309019409925105346234004749589849409525460428465344371928686\\\n    0219899854178944512710338988282872909796497905006394284092127080626764661241393784661494717501\\\n    9664612685452361581265902721321729281560792834146225698198834679678903863930368756204253548447\\\n    6428237547963380775849781198163880820474234887408515810717626954294464140037086445325925419546\\\n    9226360044515838714915264740444059908780715895432857870662394025378890373067951136803185216007\\\n    3267164960283497260307420569343262172781570488027068806082866923981856952745381456929132034376\\\n    9175300241163200578334333305706617719059873705842235195056271069666326205208928369404251271893\\\n    3679946274464722744915581527296637624266349680128155611492841157104585722091143836374221805531\\\n    9983693380210475132545075682573465444552559118913610843383605974999247732100246151434575077175\\\n    2324345777747697049984956782474383557955569367286883667999795201706433344171377686149604990073\\\n    1167006658978867618711730400636322091203486501669277691054842914826267934941319910773704032237\\\n    6901035670205399259609811903617317317239598548068552258882943496440422231759832082385172579673\\\n    3331969546275022130006965080924395968485228901579436785320618998984653205155824603155427127186\\\n    9640843127394901649965498579948667455013615081255964805120103800401047094561889908057163200952\\\n    1485704879293795487658072678397606334516804146599466551451609053119103475485952130347173420542\\\n    5212275039559539681798308537856842558661070023438378480938524659311644882052743234093728450377\\\n    0904737018473044412897568594028401352439121564448346666005199157182859046003456230628252461646\\\n    2711568894086127552365778510467688968662691174905311846804723311446774142560531887766216309336\\\n    3547191766862995534545173810101282955215815803628507655257102184911633402387766068877259795064\\\n    0321509419156026324303710620592463147900840578444449323728803668303265138630374806617203187939\\\n    9906449865725064523851265717887390715157466783059933912068354503772214431979866290078579445355\\\n    8311261036030403472816783125699826576008508857219508442253238585849562016110478170452653797356\\\n    6212208509721134378400928511072078679723080003929731897593219180380830579686828918716120845148\\\n    6175127225958344843950193844481292801585339136308436578596447853517992043624639728347006509853\\\n    7645007548083913941726649541874597481305636803050913189875829007224207317847021339958173233400\\\n    1712685939213407698422779479008460565279512703710259903749612358081689590389622906948233869256\\\n    0012492063107507109701774650303553632653740676976306821294715531656243033116599516349942536341\\\n    1093295657027473445688838148738744167833015407259539432581571029579904480644793185529659263176\\\n    5214500159261834752730651400287945044066099866450175911882657673457747672971994979835331469088\\\n    6761756186808135204119248623596175993310510418285026467753122760968111744956741234929794049670\\\n    5347673696159738183626721683311243235707795942817994465680764248391615160785062871842558451083\\\n    1339698690300490733834377921936270367617110035127089791814903617335372758323457766221713419774\\\n    6472792448605921707551485285461428583031592169673278783263213185912619450164367624776936642465\\\n    6273519820033037165002205826158934743920822502599592958620667050196380246628072166942635791625\\\n    0922384490346589214339776581366735557200699008501068658383639384490006927079512613289497434799\\\n    7461417696179680119649742194484780658648709021116240165383841901768276933995680531932803451677\\\n    2447215854056207524129671519115954026224280023981715172583589454751572892059637735557709314675\\\n    9614367552876651272478352620179235530014789180213278962452283157832712698082010993439068008188\\\n    9918857932694844622179284416754675467795584192049455977283167136406717372964723938937208182768\\\n    5013915564058594855936357150037519065095240454959489333829960212039617372399785804850638592188\\\n    1185636078604139805634314419412614234307685798822297347406108521092686215255734286770089882515\\\n    7923825125232165876477739927411833999162006648812432004052451946583874661334023073014089427850\\\n    8270338200972791935823864684587008940485166174868624369837127938577060779240011871830292449034\\\n    9128796331002290445091235824592283208919864702368255151420802886504733241071514413608377719259\\\n    7198960031560678408230290799222850549952463000372910229453782197060823813481495920742856040949\\\n    7477679686839921356630705779326050698559706152469704731173114624819858779789982073668503103812\\\n    9116139263689468007613564657598234720953327366346996966571186943350899797174365121222246896863\\\n    7221351940925426761264036759509345626928829972437883257644837430451542927850371310080746857069\\\n    4800477439955286688087534532390434950304131990936170409201041302784336144783741045897124986181\\\n    7334541620866082164232368178079141456696355950280346752700365855026890326851869018925993980945\\\n    1190398024697946844904047475581875749782560261287746650868841791259036261039200278782135931030\\\n    0782131174092977580699020263995105441271759555505011693918241151765887128720623241116404293610\\\n    1923292627085870867393548182007796021866852695922195275342465144379196649770459440766917386302\\\n    6776005956027991392409937269932473435933713822539166656743979553036761912815753035316276329577\\\n    0874510146987681799168986373420735204084919646712157014201805783078949291062908206747304756492\\\n    7879397124771964413717240397812305084259508141255101875179348611567144285618735656540711900949\\\n    7029001937983346923401736988902323695457290889631609533075610484926462009936704929818182704705\\\n    8017655821021066290136112935595028217940069910677671936094814910441564321522026892491234918570\\\n    8564621687485001351047337465401912169742334534779661485341751949685743634811315985698254376754\\\n    3025790786443561684835833702412315988839780478980899429408336125534480930044846763776106091769\\\n    0514823143670562542683319031611585067129161098222491599546168502744910015925610633633425675706\\\n    1066993949981678958362797543858063359037543865440014070132996477175185936440787126529924315529\\\n    4943454294093710429576747545278679922236959930892657575870089340248831082862229067209622919093\\\n    4073445691747142356696308086296039653967907619641863124834095617354055141122506921883702374793\\\n    7109303134178596140013601097991116052670307286704679250315187855735837101339266761102834044362\\\n    9303093023778163671874243749720377212970476095974737364896496380605464028704558991946533842833\\\n    9675365260521430209441760297960803535730934864497055331435491989520478327770564128276045994846\\\n    9520777291062084817263598711916719643081904490517722416950189009691734051927166097118544194905\\\n    1393312546522471137952144538483991829403692987889358362777668013850475701384826297874021966349\\\n    2141368666127198930874118380051061562324568468459954404893756398602674524285726602451929789469\\\n    9607817327896692112984377078996768713609103857368623105625257549732775905043227777179586178886\\\n    2553846355994126446820221615432282713214522203090800626070215103384442011757697813596755235172\\\n    9170131915564003672213847841292872567985677685250510477430433638890916808364576735879602462105\\\n    8986988619059094347209036156373594367071492556747985018304845427381072727888644194216874474808\\\n    8002474539202324865830757812839432952248221832182632495937656020758736436065506614095216024687\\\n    3755468924199344491382168137938162666620026291859121756933375384637822543685095224097607130638\\\n    2256493867669553916340062843739469201199065709174989531891176805035467679915871057087966252767\\\n    3825307885682391581477145504978341477808964137229447268541761194949442317984843665891711271844\\\n    6045786396262528404655592311101367364533066524720336308550453506747417774194941731095499942885\\\n    5408255870806070478469005046854416474664785183942399923759946384881611490673104810076244599024\\\n    2954328861110032039173248286117862758787175389607707457077352698015602790544545883276477818583\\\n    8316975077058488887087959578842226393372459869627513326675195048780942841174563111767424798284\\\n    0072432721697650949712793829692100232539401570436241381870852007034950568517733580827434129761\\\n    2027193817931433171784653188732875786064634307330295753504279262531072437063447213799853453300\\\n    8670505926285718232498839256736996425605106569715727088357300687295961375438686109216505880093\\\n    9191846493588711974825465549087725749140853506509967866011545230350632829065800789139904175257\\\n    7607665730530077281835939808102166168493504330911328053282537057899630209099651294982555339798\\\n    6174280526767447718403961619678780253118784055508834839675969196623243660910509260597024743878\\\n    3399548982518117300470741917819568590000541917666596121452911108556361144138702974254970861988\\\n    0816278176086358329239799052105949841651706001615453133929056862168843497683744777278859388176\\\n    1300556882918954099021980521521939477824608074039639482408729761163255533162206943512971563858\\\n    2361653253510440392367424484901792810423457799195686065902526236770682045627023782714860114863\\\n    9656665262576788651234623753158992296294440902126267293241565329022130465342457341462436816012\\\n    6135489496594888610327802655738344162066708992458789307819397797541260600282181022670716361373\\\n    7959819721372150824083678527700638740242279188874524974239900377814862814934300663909597527852\\\n    5737463709791950249849471636896555808186577642133671133810924204537378310684134725318345372422\\\n    6914397584149954068197310260368660455315809614334287298973364483663549973369146776416268869236\\\n    6056564157942658083517747717265601444988852047794375949408923235515024269379015050989523380551\\\n    5083786505576022733067029969698976479152155690199875958796333312070749464883892084395256842444\\\n    8872109742397972063089113758997640245753247124989104603946453090879950000000000000000000000000\\\n    00000000000000000000\";\n    let yss = \"10908414505912971054286609488569140565924687687245433094058547648020905598778587205\\\n    8800917601340102783279566646405229412956270860607348480697253321586425043921831743478345047346\\\n    1620612167756704235757660325826576703080825391458174158824924439376273566916427171725586252750\\\n    1135740201145208707398808419246609478468381871915273365995060747114547363636609791355017672900\\\n    8201140785708890745884659007022718348185215707899394766286151497972902968283000616696870152162\\\n    6162746788372883461620816411110712443880711195642228057093182653022326335575815190841233133154\\\n    5901983170623957734740229277533918089178781604188333617309668081763114384234809933223105723238\\\n    2175980988120314742525716865267570025262654047389794738086985999544779709382195868988972881105\\\n    6010758553679552998640915723718648168439102943931156658884682882398526699741823504320497280006\\\n    2233172072338982693697909214335376944537728610357916775549830616691045001061464613851455530681\\\n    7308539191939806478658138509922120292951164960952328660597685734370646072651479086911688862304\\\n    8875301954852916676396233885137710320297960219852527443598828696170773054985131164421008908505\\\n    3863320417453851138667430234873894787171599955890314482164675353481585980639187279213966221796\\\n    5362854604657325895421198321632027418186827123198514863665841105714406474704034591180228164014\\\n    9642956321822921088252308223918014534841857789241869742606068706996171891615174190123403219662\\\n    4694777160422452994177062670048758669388437663096069386059959441677724612434597345905683766946\\\n    1055057117676803358353474491892699413028718796396868804108014150403709112074360823885178794866\\\n    0785781288305878033552932547631853463898395521590933426651792614798049763342694458280504145140\\\n    3665748723657073979003591739560756591025818772766505732418704785362503865781294271883673261323\\\n    8244310518890045378127654157707367854319493666203793894105229571079353714855333982629786090302\\\n    7837491606132504951123941719242813218185035978434220621999879772544538748463376634367636346508\\\n    1602702528148162734659676974892864958359681301046175079633314001005611690725163396287513515288\\\n    3913279769534748341225675859384140633636338791936452232302173386906100814004098359573142396051\\\n    2661247624312379688078919444292950874768630849279644346459184541173730046172095511638612531426\\\n    9097219216661743675715333301559833797427427400745112255170583174289673187024018839000100563387\\\n    0719703750355234035408650091288610610877203832740320899874680869756323084625747379551103669190\\\n    3505324008472502629432601921885954615996411873404669472296378620842382069900579982304023036153\\\n    8123648137367394386593544688596486540220469963815141357683091871241851080033949208733040110554\\\n    1247051934233870718046700620778161164989796368301384044131797998491403133195259242819167115518\\\n    5816517529457503351254593461559001785254210897236276080828714411364793978007086569379444315193\\\n    9377500275308573034484218489554587387541686908462623901390499232968430606711226431616434521316\\\n    0284053164954588847174493425863191549299393592782815842128911091193645749088411535603155371794\\\n    4129304261364706080036780428805260606767981809574091259695762789767948001862905416437261575234\\\n    3954265321713528294798414220654911320027000477838099979500193309165189979860417585807753068976\\\n    0281061990971476228263978656980855648031088030251672499225498688104513509977731408862969394218\\\n    6386276357582152634076041568118285410386441075195995867767651149290882464625916250443969492322\\\n    5628927486455555369152293014491362015298191531222392373609267504874575559889774034926000489817\\\n    7334526861246181296845240134439620809897213746151667196619762607144020565237882575905537158634\\\n    3056054908893766595565270533152466052621846730797010667794912760319148461367888763432494033935\\\n    5770908233084550614579340756425880254606922896741720944365354373570553150827983181717626088237\\\n    9679468449439034129602017212159637115118265619492837063365788805219766122886118308676712391088\\\n    2324009989002058473353246079357784966236956727583834236773508377892013589638618125956187698984\\\n    3218483425259650845473870067046846051070702708381555436098035065316030560047619978075283136359\\\n    1219954452355538322062830035691454022290392542169743502327894299079400545580507355600786959793\\\n    9624701048378670711329960655592220917609724764842751610959942400606275938014051504230616140018\\\n    8879857896133032555293577263952648116925997705012329620620478256895448504324988771177759067797\\\n    9685926970825616654420691303155998809303438108623562246344595620487486685244575306209274563310\\\n    7303293543641811601614726641573107460829422811372172890261193401813784507634222106872343021755\\\n    8127223627217096368595505709005031678375575598517602520348491607448326383707762981243032536559\\\n    3625470197795113179542059984449403386721653734312880344083479538140623113438676899891035543956\\\n    0664089922352971148605047798328160271308209156897724820444922468937965894673531797498394142966\\\n    5857758936934390567120174052381161197241040596063882603749888839987952737678329885160229153197\\\n    3627482762117122991618207578170408102438153153261452366598098158243494465335493266945931886503\\\n    7903632842945111926728497738954208614098685611308083801899501366844644166267205140021620509734\\\n    8119955316842219810323715020900743528885943317665844308800167109679826577826108793697366801259\\\n    9081950467644628725893320857214120101376808632600359292866050987057452844302263617517906040576\\\n    5674887917985848237034070626149611228942663426325618923801045134789861474439009174710508480712\\\n    9894947335611031852610712285062172997459722763304847889730406437698498538694439638506771442247\\\n    4013481175348438524054192463564520454684118442597736403817854257772505310904724584854983989424\\\n    6273392368489356350002740521466119702121244888833208570062627308059658535546618618071475020847\\\n    6538160445315044447183564159680838145314807302681804945432318617824529984672714412766283349082\\\n    8407764907677913142630759364135717912139478554699048433046548009120622646311513936889849742005\\\n    1938417026585665195612967816256378569952519374000705346481080979656465412008908001891724511486\\\n    7640475429657981337674015944960532535501275691386076519906518480574604299315242594098005752731\\\n    4610901359392893551453521631112599200679457441857234352392720829022312219594847781134060134022\\\n    5235887458839044674409526779369062271419980932798621256026580865555413161303206785178305013445\\\n    2107159169710346185816180019959032636468139243857857588840330896418995161477668537012309811973\\\n    8294955663531293331130842946474929058168065491370658446322353288277527314175541070198181380258\\\n    5627326641228849308615217633455100949833458755735234728716629977114313043320267519024787537552\\\n    8555367407369345421631652421147888603456834809450748094823338604001218330848719666149313133233\\\n    0445623926214710486202012606270751008405873956167696089035019409843543396007380423406687466711\\\n    5232957625014826761610980527654739998859355453107419625880750871523919862469169853312492661186\\\n    9156740625756599779007148665171341208602089316522574306147186910710107485456688199733465277268\\\n    3393843865910427446792056897036338271401645263300543021899378928692066622697555508071100595666\\\n    1062215349114300910067438992756623927928016286120836042817703179688342075786600949254291750343\\\n    4750708506791204286311694404039771923099598305448092718740229873101908407957959733461551894492\\\n    1579356861293670935808137300698040600029078991154342700019287757204762318287041884091377923485\\\n    9013869981431557475619089641076646856902263659910192569696542041864420136272478708376655545551\\\n    9694802937758276476716416124793122039529318497748797935926710835530513956653980932496720195731\\\n    7863287800670097466375178866915404746844093936887901349854870947952754083626896575654244798278\\\n    5547704673589024994641144633673598532770836586690680765954828440204432314708331719061335590092\\\n    5098305594752790298805162335119615401677163849881114073460850657617030727422896736632519036392\\\n    2396421114817113186996471689857069210863649088866902911367277105114485752092310382681885586395\\\n    0557321841363516785550317383323531005761838734758410902748665143631225356098342510730339116700\\\n    4597502421978797921420130259346353389184048227417312961873358648793515851822657953530446529010\\\n    1921359266179061947464407216576883723070344846453309743546494248461538434465836728331111890678\\\n    7484360607577953793591859647377034714660500658601875268665404207814136388746945006570499607305\\\n    3912343943109777726072396255467966538286469487763984952121160856740333021560313166067636040640\\\n    4068763872735011006347765984195289456857762332379863692759538215794872957829767381599380828854\\\n    8443921951661519963100664342118118921219279515021185683158420124115882452249863439341643403614\\\n    6843677143694611514956957708817871493504199114073996635054666124076303336350879973720797542833\\\n    1697896521973131000604974199398266640485651830616668487905027012056207944523621716307696523667\\\n    3597104482223882886396000021941104793645669267397640541092898382866348761241388125840939420329\\\n    6532973581791194802847453568931481369344088975705699191689777654605119514346049437056288513498\\\n    7155592258519997246357561935326410564448361888670687962434733967023291889623448244314471808428\\\n    0196297795384611407015967995341036410237700416482276236892954314658618411182119637254165850533\\\n    4834073094907220770590906009066257259843924005632996808671009557797497167816984186567799661537\\\n    9780444732450365222591119710142165851813076664677375451651931168621254677451224008508782113496\\\n    4657512249549200288871452406908900398381042331882093417629266387252953255550505590845527881944\\\n    3110570104904927958043433168286770189478960615851176655127496333090691158707959561438394682032\\\n    5160929459708430095164135070071862512042596426249742795916444624439930350748025991581576680533\\\n    0341203235303899496900614261068923708664991316508518279778113430335835816638507476873470089783\\\n    6406780902558393821806547923053076179756975407588471246852634330682522594299832621823244274276\\\n    2274716983155299679950862020920180917945648878066432712692620308077426320341626218768578222373\\\n    2490917291430934357043048072772336865408717182113482257697207277942785802382211345454198422846\\\n    1007845402204507486797907417524150799426920895214057215895835400250840948613772715502311132351\\\n    1934442519919659248801091067532724916094212111299747251719833940498490882506561273622516955130\\\n    1430592598460273648638553585105165838859847053014167740762963441840459950884493067041229592675\\\n    7653346192027629855391471262594734312745968333924246485847967214784158400263364747001747254132\\\n    0139438345777136098540487695554612468049173310114717790707949801028382729062408344786764000130\\\n    07974072283267003978025920705373933996414576872881250000000000000000000000000000000000000000\";\n    big_test(\n        Natural::from_str(xss).unwrap(),\n        Natural::from_str(yss).unwrap(),\n    );\n    // - k == 1 in sd_fft_no_trunc_internal\n    // - in sd_fft_base_9_1\n    // - j == 0 in sd_fft_base_9_1\n    // - in sd_fft_basecase_9_1\n    // - i < l in sd_fft_basecase_9_1\n    // - i >= l in sd_fft_basecase_9_1\n    // - in sd_fft_basecase_7_1\n    // - i < l in sd_fft_basecase_7_1\n    // - i >= l in sd_fft_basecase_7_1\n    // - in sd_fft_basecase_7_0\n    // - i < l in sd_fft_basecase_7_0\n    // - i >= l in sd_fft_basecase_7_0\n    let xss = \"24801620217142871826036343153479407090126215259762287367249892345144118932702489936\\\n    5363795589499546396403673519051026819105518787067224323769279116349709420907345437632156864434\\\n    1719712090266415333143863606208648709524053891659568275087027717316930121389635764688470706597\\\n    5260238307434514511330927574432874399626586191130779511802671364838622423411286055789129948098\\\n    1178265409083662423394531391028173462050869303104169627336623271406627770919091188225928618106\\\n    4713114322277663317786276493528845775041485729411472335540726817499202367094531882398266179399\\\n    4396123199097972358415306093494701595919658308909864070872958276339824332368025541875747517955\\\n    0899020335121913751781769393281419548313186141224281866222012670740306330841714185544970277499\\\n    7949646249056294601039141509289643343708985818923998032269079309261400551966043601217975239719\\\n    6408889320846199985860655489911830005831615385224440166840984579520679211193021083123485314369\\\n    5654066547783370223020878934081204581414986655885449097842755766133888136018219565557242540726\\\n    5149373712403684852662663716434216575760780363589455906851052886649070163670814395905012848524\\\n    4242446267154335678308664419312848891987762791830981878424250015822257117004102272186632736917\\\n    9119679587348750698230120795953015381310613636951425019385198418188130147785129853747860449234\\\n    3111593352621318851953556826045146645506734114753703218105594390418926678577158352422807088775\\\n    2294185104092084009892063231523664183304785969283813134062463766512484317120364377393743390461\\\n    7422318544650418272783852547540328086475483046207595884076650062484568680142887118125740802001\\\n    1814422290022771494661379479722402142512462424259935181298667972646258965369426797145671601257\\\n    3456521213190961189225857134212433306204489198779714698241234900344161098963055902202240618376\\\n    9859668829973054610485982170521059702403944522913905969195277084459959400945830814455349634822\\\n    9514379583336225546808973914755774851896024752453243312275750967605016793833577168949111969922\\\n    1907556733307217551726415777621331521130598612920650632078403806727568767037952526679260811030\\\n    3751944137922537483270468977224977663485606368449211798925361810577737747375779407305305797428\\\n    2798253152332705802507373425809672687526986389941353946219403222120876199384802007872586787954\\\n    3697311325196500009654804240131348410347962800948264924279749965697761666401503469206406970743\\\n    8428366818045726327737929159783769117170914719089362105850626389743263054399450295811591554080\\\n    7866704302075305818706148358975826976113852522594096030427305055000951804161946861461022304989\\\n    2419920771607345334113662668454683137585429733510875327902484229103740799048128043423506760030\\\n    2963281620016317883915659767991397362369018982599615304051419212606802922909786900535895747331\\\n    5850274174048535453057467436067472601602376470305447160532146404859814335250724164139148444374\\\n    6273711713481819274612781628279689923981360515542013840617865093890122773088283535124247431995\\\n    6278074512061077876204760704155585044660127457477584271708662019950243758769785861925054225390\\\n    3414228018582814161813904023987793337002492901628562277946366602498318204677429605568916355194\\\n    9922124903907265853520495365260260616644641378401667408962281710099264689674030943933048440007\\\n    9774804881510104193426113210360088414879358106752293165686220032973225342542719050078434180185\\\n    2876767154128684802221973838015033946039851470380862592934296543873926498565961575661536309661\\\n    8485617719450532875384580304901130164237074848423225970067408533947704611471300380290324886160\\\n    1420615374930656205328913687104424509502847298886945958892993595437295580461677094798620912683\\\n    5959686935295316360139914618858258964686796340164171229162409225936142589627081116905572179317\\\n    8987080640050856431852999281897326723181251400563560560719771158181122142749359267857628353127\\\n    2196475905839201276924105027608964192651513010566218469744909171849066603999656785804745205505\\\n    1533559630336373496852631024536451792161172485586823390786287789598561652394134561137700882814\\\n    4994958269714667017225870865420984668478510922459011353495855686566713219487882014673374524750\\\n    6235449276055414278628998329186247791138201201786653714825490430774041309330234612266548796570\\\n    1558891582121302852462763559806987239277805004952044818099594071200253555384139052201037968268\\\n    0609396058166355507215613145892733846964827406809673844645141552760397635623841703098607202245\\\n    9628950185193994563125602014923027324506137588055673291810163281685018307705677977440755847878\\\n    5916277604830640254277898054605868201480668282810669100843355030953924632782394406885199531302\\\n    9343850555141955613317143511145358709825213063147220964913196258670378761061675258475965304642\\\n    4192069588637880395926581575815697288541128198691089251603619035327243368691695264021892295986\\\n    5889780966484746478395779290871875154688400185519128100216558450122245181891309207793010508303\\\n    6416857414355256318673035757621581622270794416594254177960159813429502907716713481236081448433\\\n    5167183445843846781174087267465133510937494388536466915186437288464113268982714919312370144418\\\n    5478118813752301023415966772621669096071573453729479198778763149124753526673825318149686437086\\\n    6430721201377401591984353850172840752574345765648391553975200336875117065968969717110090662659\\\n    0799325923454101045113718139506724517777981054216414936798353994664901640816953202708983427805\\\n    7913481961715995518115460075505375435320367594989130696360686409592902662627062564233683144235\\\n    3306352299952553611761999078760977422528843600754441682703049692885047251010003815883800160366\\\n    5280641527944325699017622403517549590923183930533283278529086207291192425364579604314935588585\\\n    1693519596840077770781952778109101537766725608978732632299214969888918463879848802761171950265\\\n    2398813285115692323045579373085393415838292883198244036459469673824726479066609543567049594886\\\n    2935208113075265099882566482211744719826130334433041673694056499364820677631886831328118016218\\\n    2611205570546607670772197454938016083495983113422792221646066252988843272419764722174051225648\\\n    1507195634970844024198117675858775719352197272161411525807766192873933283667941194109812233923\\\n    4334263398373019117809710855445579706185608943172670305216268869651041992025999116220318287536\\\n    0423688260665409896126529997567152348551532346969279305939977406229419529446540470805374053761\\\n    9744921601874214230978961900286172051665806923356388029991929410183503405737171343250092109344\\\n    1018200066087752813802222361379807317429558062818368473686275437801009254140036872958848355740\\\n    2158023808166868059068643274484472339252480597717238171933729169413630278779545692332602615882\\\n    5324816019394496988274403337442788641965946488732848302646563463683015530959148266655802504723\\\n    4677998225420757728274262679001829294681204262349568644240806135129346668538289966443734777148\\\n    7211742754145623950843032634798050811942614376805226907932826219830363978816270284226953255503\\\n    5132192956546677916303937883010930501219830342114926410501187312657755659868108929184945899160\\\n    8862905381082072422327449678693945378837416796328928892017232982368760300152911970187567088488\\\n    8097947167659620858700222018612285946652891622226294886056360184451943518037946918114820724400\\\n    0429198311126509366214329687970631381794063097888578616881955118004758106571366185986414256977\\\n    1545560189127902188261632692703550990312712272839510166399109501916003979918101116071382820165\\\n    3446973089768128042015712151763822886214185958989147339539935866157045125209972350947292199651\\\n    4259742057342693534491154260236292285417640325594116041571041564942102248647573573647884547511\\\n    7927255769718870091118053075433084403832946528725884272467905657778487139561464352416470291030\\\n    2427158826406118478410699528201546213130172513604601018165691033855911428137879851841789833619\\\n    9779931779172451229767533782653146679926707039058446897926139634612541382291024451194484049102\\\n    0348913898927032847202815428368696072513337467195829811548665133822009164641881251586467067224\\\n    0964321378840420780217477999530460642523083012164077627539763204174768242867227854830328954921\\\n    7981666810065286274945627556154803188195753990286753666419846739125189127009813177667668239807\\\n    9424575676331594419861212128780125361574019822615548084169716668189221832110353012860158916947\\\n    5827510211193336763368742226324664581013245906834314840457381465961932539437863097237795753280\\\n    1661941586455185014947171137236101248267786335931819609193050437761716093483101514718237405202\\\n    7479497435087476658239039539063751145149561944449333360970515488978120316059885587826030336866\\\n    2188730335673068409747996575099733869985243532001758864333332530346177681011603409119293655822\\\n    8893886929078673772413715762007967874898132314483333034476602521803484968813572856526496682146\\\n    8221586472111562832599731582793942461939560928095638102889425554429230004204077753546874138138\\\n    0764442380412951852178947461992146606850486405096319219459727741079990440468721505715754388667\\\n    4118133454983515240334943784479894247614641095638315034977297914742463950610247253497752692007\\\n    6730479586638718683611576252110583793610787347736095598359562861436880697949555023614431860514\\\n    8357314779405315475401981574515799145365987236477149342960167141069596759769629211766877333385\\\n    5407163672399332224852034723283298474204385218239662868225611612294312993851280320940883558539\\\n    8580005571505321113524087260373784519780495864927629034321722748179924380062999280878882162735\\\n    5283051076015877174230202216012277715275992738776540554935875809789509568896060386462295143434\\\n    7877590551286685086675498692452942892144752175759451106662646977672876231646732973482354621948\\\n    9277585817243118533225841329319406216059150820257932243760688523140709174083272705506157402668\\\n    5992682298721836236657489955597525585488444164365276000738884409745287210528931447311897748916\\\n    7450593470801502928938576387339485766248306067294156419272751014756065662304678931390271952620\\\n    3959013850455520419402155064233049792369143875043797623932686120817778457456585514982451826028\\\n    8789435115686272407357789290361785396395536198452116277773665642963680357095740509614359557039\\\n    7441832856177332383313605277250112357787228532743058978808882704171148969993469338822310750511\\\n    4942868847881585122066906914895879995389295937345589112036978208548496367330729758507212990828\\\n    1228030926825131401274879075771071263284119766835855851658228338891772217626087589429251134492\\\n    3500024228635210964941925743185476880268833789086585218226987988338155646982943209964788887840\\\n    5553096865337058954646790774765686373985677941724432335210764876153282287234984853472126533922\\\n    9473068686802760890054601903725571898116268020979065140463821048274659873386718101013530934541\\\n    3647545154140939552075151573395533545400331296578991110975407867994610126346288535292425511495\\\n    1624551904972797209552795049463608181258840004171045569338881308597788465681460245499949456384\\\n    4120872114017229564841935889576120783825467303833769104609799824778138395312378928231281528261\\\n    6078794045498349679661993581597613566357329368786386219239869784113833079447627832849056597725\\\n    3995215643904955403203380583558657416160722240993588532547592610142221646539649478263522350000\\\n    1952880080691371341336716288449425960123314946510423908943585507358338677082153457709236158457\\\n    2551978452710466699582086341653802603727429433993853707467652045144374492838724249066303540055\\\n    000000000000000000000000\";\n    let yss = \"12589013916460106277897858542056322488000094675856038864646344558907306049281511809\\\n    3614136473331758487033647545863565888296791844990366713538746685954428656201293778129225358841\\\n    7353863078097156371331389396993279517446187182494637469283466377460580501065673665435598840206\\\n    7142251990868317617561579410148930145591214360541256125925993641360336618423521594488521058481\\\n    1109899988306120162541408553945745351720597119378160518192449498440188780985585537647431021968\\\n    8110671180958675457849815485891061836525309239860886863961315717167721978071934857201612867766\\\n    8543767461173340378350887499166155076683685125902584892511373819988521816900192183182339280275\\\n    1482744980662742669748521682570253532711665349160344575879370522782059930077176386245541198579\\\n    3798400317650318004189313061972576676273465035043255600045494116932709242182501732769680538148\\\n    5099556686399958248166710269752554388376742485921374544193100340790114044640017730004677743890\\\n    1641647335308537912257025798264834155552412583943243046337517914751639422517260488407611185645\\\n    1730619934401959425302421172362775105944233136904439633848435635846777646375790028619032927471\\\n    2019801480514034142177189099392380741088500843010959280891017888481869335028508904437940756241\\\n    4546481877549870422936979705567193763651239836671431992799139430207382743790568467181259455857\\\n    2537982542196470615094253109736505511904177145527402473142627553430867471258204334734353007474\\\n    9340133594144542561926521439528835243422125771887951940513126216237839752399914304915379096334\\\n    3522265892037530846209019108970923475160288516251073580364734709155418377580354465277601146816\\\n    8618137357816163963169988675501838350458426103138395279925524535977657129263446890650409261593\\\n    9812895789722633350234460877451524069695112720707390486618079038153928199167931340042669103554\\\n    5105445688058063298659688780458262753196362871200273574519795726160816757036237710528906867457\\\n    4770079751625132809375536926770169830292897920513074075512111334200651273622499815832497410060\\\n    0190008935269325977350196281860238594923514357147602539474824350893668720099396394956973569888\\\n    3853743567236663702416144891850857854103839114308314238346701530127080675807942825452815860343\\\n    1453248670268604803082205448053749443877556826778448038157598886077430045570366045778733481240\\\n    5559761415354934815192157872590816386301017469878076709132405304502202976996810053062214111761\\\n    3683293987653845361693494701211475476889236212653277406394381060320481527005517041197308837677\\\n    2964509726843699281857743271686770247486726899265947978969459705007844330001093453089819744305\\\n    3372168474590060759203310510900315004763325776477399635804696939396802899102399443178760977495\\\n    5269021478676321306641542242490081984902627007643733459356437362648529356870268953499568851827\\\n    8993191062323659633666618340618744418228923927761649436448495338509381124461427047169334715974\\\n    4201578033359942262570823049846229161990018993165697683021812397482322435520314552211860320783\\\n    2855492916989369856974670766814204739558583408511834353874162893083530139959882033001480193034\\\n    7685795651651810705239982604805321646908529202721583394569320280801137417613565370089661646081\\\n    6228739874453998238272728212666348202358362664051060557411110264246742561904274054537861377304\\\n    9576198698426550098960364240338901002104466221634474935116308314280105844241072526575579864349\\\n    4425540270319371619718024964051418605541961453788836812214934860525645226168635875017599100567\\\n    8411370147729668061827209213548126409459764273182851594452853417872307326229393337098897968136\\\n    5377063330667435895234325001344831298676808194669482523446052933258820409219447130674392163326\\\n    2082975934686253351694363235158923019419140012831771442092833791515988608113442990374486413959\\\n    7300411124089411534022656455717079496022901023145121791504586285756480438733819992612620266044\\\n    4508928253870513173628509025625479831245902190565253903837333992139262402927244896189927511304\\\n    6015355971134307127532745646911229172799497031118695438155116685869392486459174954625467216829\\\n    6139914776531061459245432019683916310131096402322825617216858819953487413642252808664007370113\\\n    5130097927839211213703618643600921442853592282519207838345872683150366457709248888709812305872\\\n    0029961121795751169708850803536613732415754586541158724977017852055722636519561544321864924737\\\n    5729555942502259129241300117325778441223140558408708588127871216478851667867027641810903022393\\\n    5026279552540069634984608661141902490594861040385134045301870985868381762867745315703165705848\\\n    8741539079298928101255947801722324349147240427796708732299443729960956696665969019743856226784\\\n    1158106555297521401973061713721294415390319416824497089718721319260930153497019211032189753833\\\n    3524757752041208539454524254191530204587978267794107277313119835122104408780507106860855053432\\\n    6715989201509918081324709356266150887454766869419534319269582933416447397362562523951965586576\\\n    4831584826593399486108570617002771071336494297564163153529531520685660419677199438433441044737\\\n    2847443382173195912174417438075173315823025629475165381478134649511343243037904838787690053816\\\n    1448304859110512660315869110216207500306748016638564074983211432091239558029436864970311201013\\\n    9494204663451931447003852648629167327901026967817174517123762233469206554169502522631768779019\\\n    6574760572729599494752710165846986105206751360431814385187378977204437044390896146215317658828\\\n    5934603009271073563597032886566322116787071789139727488326970091444490126827295067012933821962\\\n    1554754332569543237304472483359184936142988429812850308417562272727104297326786153398324275574\\\n    5155518426198816509252895265227065999950375286440313834470432544665229750181021510109369574752\\\n    3356743532958194280997267115053157799138739193732065092158146615765660215610507254884871133791\\\n    1698218461062736695547742573390984523443030770645318395967518545333476901051694382928011857621\\\n    4861580709678692048640464956124881032637709917322830810929926863905737922495824338348617134831\\\n    6314749492263784807017615497731340611368142443865631703125557977215256653947164477889267069355\\\n    0721207438162105024465587381551162027875192714674519224641045938831803031008877074458359164697\\\n    7769244276944282245715425148104107693701637684140087117033308856452097048733781522061306259197\\\n    6709836700234923180916761040773082826569884302957513147799259219185565324882675590765307866712\\\n    6015769131049789691940099626992191545891474462776846187883153534302839641384655701574144237436\\\n    7769077386181999313015029561230765611767744161714772985591890471981679710399252311545198227971\\\n    1663782961179770785790224606401624161861715111784750295368007295732593525566603789022076628804\\\n    8527661256713043958604316033970981497744866983597919553507025043650842329592485811439638375310\\\n    0609906019629269586733970151806216941155151610224001113041582772445794841512626172140741919316\\\n    8802979545222635406623764116165125367944926276816354414368612714584815365795736574803755307099\\\n    6452056234794680246031135120551613425648163024369763768999062128512834773075976966796909186811\\\n    6780561202941750407809414299089100142690218458444776551938846499876353427650825949459549435343\\\n    3932692400561339061059747834789286348238882330400198769344338775274912804452941503441465759007\\\n    4602799801217437772641049936726626347294647100583535416780422440084362064239940902266909492293\\\n    4405688983447180996873076613708418605659134527663969190831327685081461214556778853732555576823\\\n    4990338599017039376114987542929273098206308364715535827638305721948012233312271810174647085529\\\n    2277684236204894820725532708344438205860758888068636734833382932466235420832510604744873850096\\\n    9282611370707354542652016812425185882217727416968621933780020111039992008016696671959153814041\\\n    4316674523809170176165664411006219334346748795389918179082831172957466870498039550283432266454\\\n    9529543420692277213789018843024164290569450635030907914447146188443173383043062919961045271561\\\n    7929668549172376815356944264330717421180960969485664114635780047634627977048629938156558500603\\\n    3921592421689134629228739721072796713746140401486141278138384689894423080154113785779029068807\\\n    1330308362597265783414518880121147171683550973428807789715720035181817986760006812853184805566\\\n    3785340220057799903883713709429081894094007883906813541431379032059433956095001119523041099601\\\n    6839788703071835426735250764828966760377489390861353034238509692213776825289155748118892852493\\\n    5637171565811661303195202467420591310963472679145339785689609953794186286443227923216652631277\\\n    3788447542393494415437088181226420410106957407522481752168712138008194374277529483239799590139\\\n    9298990645494535426228995661442278904865179613379566733737728911421044644137297947182107348820\\\n    2525787819027913151256735340221837708712039570106141436639126142561390083199792785805374415495\\\n    1022755644811179056160950054045817133229585793735694826907423502685382504565944253095448659814\\\n    4808274930441626005413799153931517381712891019978042126613521037556183391817965550385735061177\\\n    9163449653877143552562190397607785113032971003564036121765482082842404669534010182444712706294\\\n    3141958700831346145451221092417417138575079645510457430481608322647953559194816721831783859721\\\n    4151621676205166904770089938502438614169265103111833294017362898396088188896132098887610683480\\\n    2898322845387201832250138459093671963069739618350027540454891198833790835932411903674111449254\\\n    2419439905077199123214719032891959817826230728737015620259791224209531828279826710851775647355\\\n    1285617312949168800369774113761607720006799553427389688984990286591434956700614820259704779412\\\n    0872401006900523223325454594460509510390907494592159646406340918870929843130647412621697397004\\\n    1798552049735509610309462063444838111088940175802141790427562995223848783965027874749159346332\\\n    6990640333039827022607006580373414160850100543843323448046531039447253576046043436630175355397\\\n    3299289722260075024807344047612826849175942636796884646906477088720839757937044126660733071672\\\n    6925103862410468103254723758901355044069368732319544861647206735503116923764564332268824973377\\\n    2525266171983647738196072458532465538970240268893897579295277262629385586566443454845338874096\\\n    1351003127840180356377574155035064592797909407262204358484869515362222205335327978022954209337\\\n    5173159447777345124762301117968347303285073220801082812082941668952725507872054852067060598323\\\n    8633045336762278736339343240446216041436312543472033782088489115934263312317441758715321621398\\\n    2893694194507118735687348357481382982660963131067599585703851061893564997542800492382150704628\\\n    8481176839747118963671849143035732883999547117376084206648565334776978440262738559060670092448\\\n    0786099302872817568083523212549328513305277274217424197340898405157721222283929814492126885251\\\n    1412961325059061297265782609785280838720240520453470040992326233839897606285487471747003140410\\\n    0057877074406960533508202301549079492579415741980786293828443271085764094023220276789143263683\\\n    5287092293953276312654493149679934771905531087755559871059281077739977789296394659915457026295\\\n    6908735121264889427252659177584494256490080250572666745152641320167197309221519742810756902908\\\n    9298173985278772765903268833981114666803657906117584700148956974562696779322051091961792870409\\\n    1017421869683431439216634457883170152430698818565631810772094980586613656344000000000000000000\\\n    000\";\n    big_test(\n        Natural::from_str(xss).unwrap(),\n        Natural::from_str(yss).unwrap(),\n    );\n    // (large test case starting with 1093184750055110... generated by setting LARGE_LIMIT = 1000000\n    // and running Integer pow properties)\n    //\n    // - k > 4 in sd_fft_no_trunc_block\n    // - a < l2 in sd_fft_no_trunc_block\n    // - a >= l2 in sd_fft_no_trunc_block\n    // - b < l1 in sd_fft_no_trunc_block\n    // - b >= l1 in sd_fft_no_trunc_block\n\n    // This used to cause a stack overflow\n    big_test(\n        Natural::power_of_2(1073741820) * Natural::from(6u32),\n        Natural::power_of_2(1073741824),\n    );\n}\n\n#[test]\nfn test_multiplying_large_powers_of_2() {\n    for i in 0..400_000 {\n        let p = Natural::power_of_2(i);\n        let p = &p * &p;\n        assert!(p.is_valid());\n        assert_eq!(p.checked_log_base_2(), Some(i << 1));\n    }\n}\n\n#[test]\nfn limbs_product_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 64);\n    config.insert(\"mean_stripe_n\", 16);\n    unsigned_vec_gen_var_6().test_properties_with_config(&config, |mut xs| {\n        let xs_old = xs.clone();\n        let mut out = Vec::new();\n        let (out_len, new_out) = limbs_product(&mut out, &mut xs);\n        out = new_out.unwrap();\n        out.truncate(out_len);\n        let xs = xs_old;\n        let mut out_alt = vec![0; xs.len()];\n        let out_len = limbs_product_naive(&mut out_alt, &xs);\n        out_alt.truncate(out_len);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(out),\n            Natural::from_owned_limbs_asc(out_alt)\n        );\n    });\n}\n\n#[test]\nfn mul_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 2048);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    natural_pair_gen().test_properties_with_config(&config, |(x, y)| {\n        let product_val_val = x.clone() * y.clone();\n        let product_val_ref = x.clone() * &y;\n        let product_ref_val = &x * y.clone();\n        let product = &x * &y;\n        assert!(product_val_val.is_valid());\n        assert!(product_val_ref.is_valid());\n        assert!(product_ref_val.is_valid());\n        assert!(product.is_valid());\n        assert_eq!(product_val_val, product);\n        assert_eq!(product_val_ref, product);\n        assert_eq!(product_ref_val, product);\n\n        let mut mut_x = x.clone();\n        mut_x *= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n\n        let mut mut_x = x.clone();\n        mut_x *= &y;\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n\n        let product_slow = mul_slow_fft(&x, &y);\n        assert!(product_slow.is_valid());\n        assert_eq!(product_slow, product);\n\n        assert_eq!(\n            Natural::from(&(BigUint::from(&x) * BigUint::from(&y))),\n            product\n        );\n        assert_eq!(\n            Natural::exact_from(&(rug::Integer::from(&x) * rug::Integer::from(&y))),\n            product\n        );\n        assert_eq!(&y * &x, product);\n        if x != 0 {\n            let (q, r) = (&product).div_mod(&x);\n            assert_eq!(q, y);\n            assert_eq!(r, 0);\n        }\n        if y != 0 {\n            let (q, r) = (&product).div_mod(&y);\n            assert_eq!(q, x);\n            assert_eq!(r, 0);\n        }\n        if x != 0 && y != 0 {\n            assert!(product >= x);\n            assert!(product >= y);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Natural::from(DoubleLimb::from(x) * DoubleLimb::from(y)),\n            Natural::from(x) * Natural::from(y)\n        );\n    });\n\n    natural_gen().test_properties(|ref x| {\n        assert_eq!(x * Natural::ZERO, 0);\n        assert_eq!(Natural::ZERO * x, 0);\n        assert_eq!(x * Natural::ONE, *x);\n        assert_eq!(Natural::ONE * x, *x);\n        assert_eq!(x * x, x.square());\n    });\n\n    natural_triple_gen().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x * y) * z, x * (y * z));\n        assert_eq!(x * (y + z), x * y + x * z);\n        assert_eq!((x + y) * z, x * z + y * z);\n    });\n}\n\n#[test]\nfn product_properties() {\n    natural_vec_gen().test_properties(|xs| {\n        let product = Natural::product(xs.iter().cloned());\n        assert!(product.is_valid());\n\n        let product_alt = Natural::product(xs.iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n\n        let product_alt = natural_product_naive(xs.into_iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(Natural::product(once(&x)), x);\n        assert_eq!(Natural::product(once(x.clone())), x);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        let product = &x * &y;\n        assert_eq!(Natural::product([&x, &y].into_iter()), product);\n        assert_eq!(Natural::product([x, y].into_iter()), product);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::arithmetic::neg::neg_num;\nuse num::BigUint;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_neg() {\n    let test = |s, out| {\n        let u = Natural::from_str(s).unwrap();\n\n        let neg = -u.clone();\n        assert!(neg.is_valid());\n        assert_eq!(neg.to_string(), out);\n\n        let neg = -&u;\n        assert!(neg.is_valid());\n        assert_eq!(neg.to_string(), out);\n\n        assert_eq!((-rug::Integer::from_str(s).unwrap()).to_string(), out);\n        assert_eq!(neg_num(BigUint::from_str(s).unwrap()).to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"-123\");\n    test(\"1000000000000\", \"-1000000000000\");\n    test(\"2147483648\", \"-2147483648\");\n}\n\n#[test]\nfn neg_properties() {\n    natural_gen().test_properties(|x| {\n        let neg = -x.clone();\n        assert!(neg.is_valid());\n\n        let neg_alt = -&x;\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        assert_eq!(Integer::from(&(-rug::Integer::from(&x))), neg);\n        assert_eq!(Integer::from(&neg_num(BigUint::from(&x))), neg);\n\n        assert_eq!(-Integer::from(&x), neg);\n        assert_eq!(neg == x, x == 0);\n        assert_eq!(-neg, x);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, IsPowerOf2, NextPowerOf2, NextPowerOf2Assign, PowerOf2,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_vec_gen_var_1};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::next_power_of_2::{\n    limbs_next_power_of_2, limbs_slice_next_power_of_2_in_place, limbs_vec_next_power_of_2_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_next_power_of_2_and_limbs_vec_next_power_of_2_in_place() {\n    let test = |xs: &[Limb], out: &[Limb]| {\n        assert_eq!(limbs_next_power_of_2(xs), out);\n\n        let mut xs = xs.to_vec();\n        limbs_vec_next_power_of_2_in_place(&mut xs);\n        assert_eq!(xs, out);\n    };\n    test(&[3], &[4]);\n    test(&[6, 7], &[0, 8]);\n    test(&[100, 101, 102], &[0, 0, 128]);\n    test(&[123, 456], &[0, 512]);\n    test(&[123, 456, u32::MAX], &[0, 0, 0, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_next_power_of_2_fail() {\n    limbs_next_power_of_2(&[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_next_power_of_2_in_place_fail() {\n    limbs_slice_next_power_of_2_in_place(&mut []);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_next_power_of_2_in_place_fail() {\n    limbs_vec_next_power_of_2_in_place(&mut Vec::new());\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_next_power_of_2_in_place() {\n    let test = |xs: &[Limb], carry: bool, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        assert_eq!(limbs_slice_next_power_of_2_in_place(&mut xs), carry);\n        assert_eq!(xs, out);\n    };\n    test(&[3], false, &[4]);\n    test(&[6, 7], false, &[0, 8]);\n    test(&[100, 101, 102], false, &[0, 0, 128]);\n    test(&[123, 456], false, &[0, 512]);\n    test(&[123, 456, u32::MAX], true, &[0, 0, 0]);\n}\n\n#[test]\nfn test_next_power_of_2() {\n    let test = |s, out| {\n        let u = Natural::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        n.next_power_of_2_assign();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().next_power_of_2();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).next_power_of_2();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = rug::Integer::from_str(s).unwrap().next_power_of_two();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"1\");\n    test(\"1\", \"1\");\n    test(\"2\", \"2\");\n    test(\"3\", \"4\");\n    test(\"4\", \"4\");\n    test(\"5\", \"8\");\n    test(\"6\", \"8\");\n    test(\"7\", \"8\");\n    test(\"8\", \"8\");\n    test(\"9\", \"16\");\n    test(\"10\", \"16\");\n    test(\"123\", \"128\");\n    test(\"1000\", \"1024\");\n    test(\"1000000\", \"1048576\");\n    test(\"1000000000\", \"1073741824\");\n    test(\"1000000000000\", \"1099511627776\");\n    test(\"1073741823\", \"1073741824\");\n    test(\"1073741824\", \"1073741824\");\n    test(\"1073741825\", \"2147483648\");\n    test(\"2147483647\", \"2147483648\");\n    test(\"2147483648\", \"2147483648\");\n    test(\"2147483649\", \"4294967296\");\n    test(\"21344980687\", \"34359738368\");\n}\n\n#[test]\nfn limbs_next_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_next_power_of_2(&xs)),\n            Natural::from_owned_limbs_asc(xs).next_power_of_2(),\n        );\n    });\n}\n\n#[test]\nfn limbs_slice_next_power_of_2_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |mut xs| {\n        let old_xs = xs.clone();\n        let carry = limbs_slice_next_power_of_2_in_place(&mut xs);\n        let n = Natural::from_owned_limbs_asc(old_xs).next_power_of_2();\n        let mut expected_xs = n.into_limbs_asc();\n        assert_eq!(carry, expected_xs.len() == xs.len() + 1);\n        expected_xs.resize(xs.len(), 0);\n        assert_eq!(xs, expected_xs);\n    });\n}\n\n#[test]\nfn limbs_vec_next_power_of_2_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |mut xs| {\n        let old_xs = xs.clone();\n        limbs_vec_next_power_of_2_in_place(&mut xs);\n        let n = Natural::from_owned_limbs_asc(old_xs).next_power_of_2();\n        assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n    });\n}\n\n#[test]\nfn mod_power_of_2_add_properties() {\n    natural_gen().test_properties(|n| {\n        let mut mut_n = n.clone();\n        mut_n.next_power_of_2_assign();\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let result_alt = (&n).next_power_of_2();\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = n.clone().next_power_of_2();\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = Natural::exact_from(&rug::Integer::from(&n).next_power_of_two());\n        assert_eq!(result_alt, result);\n\n        assert!(result.is_power_of_2());\n        assert!(result >= n);\n        if n != 0 {\n            assert!(&result >> 1 < n);\n            assert_eq!(Natural::power_of_2(n.ceiling_log_base_2()), result);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        if let Some(power) = u.checked_next_power_of_two() {\n            assert_eq!(Natural::from(u).next_power_of_2(), u.next_power_of_2());\n            assert_eq!(power, Natural::from(u).next_power_of_2());\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/parity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivisibleBy, DivisibleByPowerOf2, Parity};\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_even() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().even(), out);\n    };\n    test(\"0\", true);\n    test(\"1\", false);\n    test(\"2\", true);\n    test(\"3\", false);\n    test(\"123\", false);\n    test(\"1000000000000\", true);\n    test(\"1000000000001\", false);\n}\n\n#[test]\nfn test_odd() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().odd(), out);\n    };\n    test(\"0\", false);\n    test(\"1\", true);\n    test(\"2\", false);\n    test(\"3\", true);\n    test(\"123\", true);\n    test(\"1000000000000\", false);\n    test(\"1000000000001\", true);\n}\n\n#[test]\nfn even_properties() {\n    natural_gen().test_properties(|x| {\n        let even = x.even();\n        assert_eq!((&x).divisible_by(Natural::TWO), even);\n        assert_eq!((&x).divisible_by_power_of_2(1), even);\n        assert_eq!(!x.odd(), even);\n        assert_eq!((x + Natural::ONE).odd(), even);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.even(), Natural::from(u).even());\n    });\n}\n\n#[test]\nfn odd_properties() {\n    natural_gen().test_properties(|x| {\n        let odd = x.odd();\n        assert_eq!(!(&x).divisible_by(Natural::TWO), odd);\n        assert_eq!(!(&x).divisible_by_power_of_2(1), odd);\n        assert_eq!(!x.even(), odd);\n        assert_eq!((x + Natural::ONE).even(), odd);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.odd(), Natural::from(u).odd());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase, CheckedRoot, Pow, PowAssign, PowerOf2, Square,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_5, unsigned_pair_gen_var_29, unsigned_vec_unsigned_pair_gen_var_31,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::pow::limbs_pow;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_natural_unsigned_triple_gen_var_1, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_unsigned_triple_gen_var_5,\n};\nuse malachite_nz::test_util::natural::arithmetic::pow::{\n    natural_pow_naive, natural_pow_simple_binary,\n};\nuse num::BigUint;\nuse num::traits::Pow as NumPow;\nuse rug::ops::Pow as RugPow;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_pow() {\n    let test = |xs: &[Limb], exp: u64, out: &[Limb]| {\n        assert_eq!(limbs_pow(xs, exp), out);\n    };\n    test(&[2], 2, &[4]);\n    test(&[2], 10, &[1024]);\n    test(&[2], 100, &[0, 0, 0, 16]);\n    test(\n        &[3],\n        100,\n        &[3476558801, 3600055637, 1531049845, 1731684438, 1514558410],\n    );\n    test(&[10], 9, &[1000000000]);\n    test(\n        &[10],\n        100,\n        &[\n            0, 0, 0, 2821623568, 2863809288, 2384534140, 4085960256, 2227490315, 2095778599,\n            2904921283, 4681,\n        ],\n    );\n    test(&[1, 1], 2, &[1, 2, 1]);\n    test(\n        &[1, 1],\n        10,\n        &[1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1],\n    );\n    test(\n        &[1, 1],\n        100,\n        &[\n            1, 100, 4950, 161700, 3921225, 75287520, 1192052400, 3122658912, 1404300575,\n            3856263611, 1591254002, 3258062030, 899556955, 803216378, 1310151248, 1499375850,\n            2332619193, 3968431524, 4085749530, 1136679331, 273489285, 3338642246, 3544105701,\n            844866219, 1175366874, 758834048, 646998201, 3049457170, 733614013, 1400647268,\n            3979434005, 2770685599, 4038926785, 264011298, 2126789533, 3205011234, 3674235589,\n            3864120130, 1717547830, 3817918906, 2976806973, 2930427077, 3798905017, 2672346699,\n            2426398649, 1834316445, 4131270269, 887459147, 1698650569, 3123194158, 2868271121,\n            3706731654, 2073725215, 570568395, 729640870, 1868322716, 3338774936, 3779458204,\n            3890882669, 1414262575, 1200805502, 3641833126, 342345696, 1286652406, 3703949518,\n            47177294, 1562872441, 3379562707, 2490682825, 640606377, 1577764504, 3545174992,\n            2808433500, 3939117033, 343741199, 2292546107, 1377056316, 1693477863, 368237605,\n            832210433, 2481934560, 2826277781, 3285796914, 2204777130, 3821989418, 1802445372,\n            1367480655, 813259882, 901179532, 3258302570, 1591286535, 3856267598, 1404301014,\n            3122658955, 1192052403, 75287520, 3921225, 161700, 4950, 100, 1,\n        ],\n    );\n    test(\n        &[1, 2, 3],\n        10,\n        &[\n            1, 20, 210, 1500, 8085, 34704, 122520, 363120, 915570, 1980440, 3692140, 5941320,\n            8240130, 9804240, 9924120, 8433072, 5893965, 3280500, 1377810, 393660, 59049,\n        ],\n    );\n    test(\n        &[u32::MAX; 3],\n        5,\n        &[\n            u32::MAX,\n            u32::MAX,\n            u32::MAX,\n            4,\n            0,\n            0,\n            0xfffffff6,\n            u32::MAX,\n            u32::MAX,\n            9,\n            0,\n            0,\n            0xfffffffb,\n            u32::MAX,\n            u32::MAX,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_fail_1() {\n    limbs_pow(&[], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_fail_2() {\n    limbs_pow(&[], 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_fail_3() {\n    limbs_pow(&[1, 1], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_pow_fail_4() {\n    limbs_pow(&[1, 1], 1);\n}\n\n#[test]\nfn test_pow() {\n    let test = |s, exp, out| {\n        let u = Natural::from_str(s).unwrap();\n\n        let mut x = u.clone();\n        x.pow_assign(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = u.clone().pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = (&u).pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = BigUint::from_str(s).unwrap().pow(exp);\n        assert_eq!(x.to_string(), out);\n\n        let x = rug::Integer::from_str(s).unwrap().pow(u32::exact_from(exp));\n        assert_eq!(x.to_string(), out);\n\n        assert_eq!(natural_pow_naive(&u, exp).to_string(), out);\n        assert_eq!(natural_pow_simple_binary(&u, exp).to_string(), out);\n        assert_eq!(u.pow_ref_alt(exp).to_string(), out);\n    };\n    test(\"0\", 0, \"1\");\n    test(\"1\", 0, \"1\");\n    test(\"2\", 0, \"1\");\n    test(\"1000\", 0, \"1\");\n    test(\"1000000000000\", 0, \"1\");\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"1000\", 1, \"1000\");\n    test(\"1000000000000\", 1, \"1000000000000\");\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"4\");\n    test(\"3\", 2, \"9\");\n    test(\"1000\", 2, \"1000000\");\n    test(\"1000000000000\", 2, \"1000000000000000000000000\");\n    // - xs.len() == 1 first time\n    // - *x <= HALF_MASK in bsize_1_helper\n    // - exp.even() in bsize_1_helper\n    // - *exp != 0 in bsize_1_helper\n    // - *trailing_zero_bits_out == 0 || *out_0 == 1 || *out_0 >> (Limb::WIDTH -\n    //   *trailing_zero_bits_out) != 0 in bsize_1_helper\n    // - exp != 0\n    // - len == 1 || exp.even()\n    // - len == 1\n    // - bits.odd()\n    // - len == 1 && bit\n    // - len == 1 && !bit\n    // - out_0 == 1\n    // - trailing_zero_bits_out == 0\n    test(\n        \"123\",\n        456,\n        \"992500687720988567008314620574696326372959408198869005198162988813828671047493990779211286\\\n        6142614463805542423693627187249280035274164990211814381967260156999810012079049675951763646\\\n        5445895625741609866209900500198407153244604778968016963028050310261417615914468729918240685\\\n        4878786176459769390634643579861657117309763994785076492286863414669671679101266533421349427\\\n        4485146389992748709248661097714611276356710167264595313219648143933987301708814041466127119\\\n        8500333255713096142335151414630651683065518784081203678487703002802082091236603519026256880\\\n        6244996817813872275740354848312715156831237421490955692604636096559777009388445806119312464\\\n        9516620869554031369814001163802732256625268978083813635182879531427216211122223117090171561\\\n        2355701347552371530013693855379834865667060014643302459100429783653966913783002290784283455\\\n        6282833554705299329560514844771293338811599302127586876027950885792304316616960102321873904\\\n        36601614145603241902386663442520160735566561\",\n    );\n    // - exp.odd() in bsize_1_helper\n    // - out_0 != 1\n    test(\n        \"123\",\n        457,\n        \"122077584589681593742022698330687648143874007208460887639374047624100926538841760865842988\\\n        2535541579048081718114316144031661444338722293796053168981972999310976631485723110142066928\\\n        5249845161966218013543817761524404079849086387813066086452450188162154366757479653779943604\\\n        3150090699704551635048061160322983825429100971358564408551284200004369616529455783610825979\\\n        5761673005969108091237585315018897186991875350573545223526016721703880438110184127100333635\\\n        7415540990452710825507223623999570157017058810441988052453987469344656097222102232840229596\\\n        3168134608591106289916063646342463964290242202843387550190370239876852572154778834152675433\\\n        1890544366955145858487122143147736067564908084304309077127494182365547593968033443402091102\\\n        0319751265748941698191684344211719688477048381801126202469352863389437930395309281766466865\\\n        0422788527228751817535943325906869080673826714161693185751437958952453430943886092585590490\\\n        23701998539909198753993559603429979770474687003\",\n    );\n    // - *trailing_zero_bits_out != 0 && *out_0 != 1 && *out_0 >> (Limb::WIDTH -\n    //   *trailing_zero_bits_out) == 0 in bsize_1_helper\n    // - bits.even()\n    test(\n        \"10\",\n        100,\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        00000000000\",\n    );\n    test(\n        \"10\",\n        101,\n        \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000\",\n    );\n    // - *exp == 0 in bsize_1_helper\n    // - exp == 0\n    // - trailing_zero_bits_out != 0\n    test(\"2\", 100, \"1267650600228229401496703205376\");\n    // - xs.len() == 2\n    // - xs.len() == 2 && trailing_zero_bits_in == 0\n    // - xs.len() == 2 && x_1 != 0\n    // - len >> 1 && exp.odd()\n    // - len != 1\n    // - !CountOnes::count_ones(exp).eq_mod_power_of_2(bits, 1)\n    // - len != 1 && !bit\n    // - len != 1 && bit\n    test(\n        \"12345678987654321\",\n        5,\n        \"286797196211272153445658333952148540084053148773966942500383143133144940612575601\",\n    );\n    test(\n        \"12345678987654321\",\n        6,\n        \"354070611898367606555445954656918550154832595750628623501854823341167403514406003590115726\\\n        6821921\",\n    );\n    // - xs.len() == 2 && trailing_zero_bits_in != 0\n    // - CountOnes::count_ones(exp).eq_mod_power_of_2(bits, 1)\n    test(\n        \"26872817533106\",\n        12,\n        \"141826844138959364185940647071896554485587687634106997683499856265150283163630969349636867\\\n        234174443605205673555107919666790176734540047683138771242870390213185536\",\n    );\n    // - xs.len() == 2 && x_1 == 0\n    test(\n        \"14823718968\",\n        5,\n        \"715790392004360489610590536764569459261039357165568\",\n    );\n    // - xs.len() > 2\n    // - xs.len() > 2 && trailing_zero_bits_in != 0\n    test(\n        \"24424421844081699326\",\n        55,\n        \"213961716190310170274088594850318375142996259342375501592273155327928007898048540877403565\\\n        3947261530991648842767731271386297041920019953715121571673691873897348960187317337771890905\\\n        1572382143119842882294517424053653145781261386562757014940642327399405478861990592953674053\\\n        5435746102693851943687705326429729387827027180615610631114411764811616316442929883964904298\\\n        3315499400867326194538467726927965720256457038271587840064522521610550522662098778092390775\\\n        1204011661884808984320689270774425563736748276177153496839435580581401399443258277883965208\\\n        0795662477157903348885713252035517047912637599810655108674777287567258783790305252352655254\\\n        9161655860569081456083564805569388857136788414537348033500867479587662770873397446881847014\\\n        6730827427892395144171556599844946073138166223624637280926661575895662911794190561258748348\\\n        7934048838204018355648003975520634897314818368802033588189644263971368238570985509229153518\\\n        4180400851608974878145053640167246336219940448713158030020593993974770074718137925127520351\\\n        9045385528768578776802376700963217886663279210963568902459805925376\",\n    );\n    // - xs.len() > 2 && trailing_zero_bits_in == 0\n    test(\n        \"762845729280891732629\",\n        6,\n        \"197069908665560609451994985160700801551868029168403239983377351218306354370509861303202043\\\n        757725875289425891538656609168767721\",\n    );\n    // - x == 0\n    test(\n        \"576460717943685120\",\n        9,\n        \"702954903302866311524348366058883550484761300374963994159100861262489870076604686210427395\\\n        8248045324225063677698694075567381512070601339698619038564352000000000\",\n    );\n}\n\n#[test]\nfn limbs_pow_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_31().test_properties_with_config(&config, |(xs, exp)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_pow(&xs, exp)),\n            Natural::from_owned_limbs_asc(xs).pow(exp)\n        );\n    });\n}\n\n#[test]\nfn pow_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, exp)| {\n        let power = (&x).pow(exp);\n        assert!(power.is_valid());\n\n        let power_alt = x.clone().pow(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        let mut power_alt = x.clone();\n        power_alt.pow_assign(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        assert_eq!(Natural::from(&BigUint::from(&x).pow(exp)), power);\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::from(&x).pow(u32::exact_from(exp))),\n            power\n        );\n\n        assert_eq!(power, natural_pow_naive(&x, exp));\n        assert_eq!(power, natural_pow_simple_binary(&x, exp));\n        assert_eq!(power, x.pow_ref_alt(exp));\n        if exp != 0 {\n            assert_eq!((&power).checked_root(exp).unwrap(), x);\n        }\n        if x > 1 {\n            assert_eq!(power.checked_log_base(&x).unwrap(), exp);\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).pow(0), 1);\n        assert_eq!((&x).pow(1), x);\n        assert_eq!((&x).pow(2), (&x).square());\n    });\n\n    unsigned_gen_var_5().test_properties(|exp| {\n        assert_eq!(Natural::ZERO.pow(exp), u64::from(exp == 0));\n        assert_eq!(Natural::ONE.pow(exp), 1);\n        assert_eq!(Natural::TWO.pow(exp), Natural::power_of_2(exp));\n    });\n\n    natural_natural_unsigned_triple_gen_var_1().test_properties(|(x, y, exp)| {\n        assert_eq!((&x * &y).pow(exp), x.pow(exp) * y.pow(exp));\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_5().test_properties(|(x, e, f)| {\n        assert_eq!((&x).pow(e + f), (&x).pow(e) * (&x).pow(f));\n        assert_eq!((&x).pow(e * f), x.pow(e).pow(f));\n    });\n\n    unsigned_pair_gen_var_29::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Pow::pow(x, y), Natural::from(x).pow(y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, CheckedRoot, IsPowerOf2, Pow, PowerOf2,\n};\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::num::logic::traits::{BitAccess, LowMask};\nuse malachite_base::test_util::generators::{unsigned_gen_var_5, unsigned_gen_var_15};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\n#[test]\nfn test_power_of_2() {\n    let test = |pow, out| assert_eq!(Natural::power_of_2(pow).to_string(), out);\n    test(0, \"1\");\n    test(1, \"2\");\n    test(2, \"4\");\n    test(3, \"8\");\n    test(32, \"4294967296\");\n    test(100, \"1267650600228229401496703205376\");\n}\n\n#[test]\nfn power_of_2_properties() {\n    unsigned_gen_var_5().test_properties(|pow| {\n        let n = Natural::power_of_2(pow);\n        assert!(n.is_valid());\n        assert_eq!(n, Natural::ONE << pow);\n        assert_eq!(n, Natural::TWO.pow(pow));\n        assert_eq!(n, Natural::low_mask(pow) + Natural::ONE);\n        assert!(n.is_power_of_2());\n        assert_eq!(n.checked_log_base_2().unwrap(), pow);\n        if pow != 0 {\n            assert_eq!((&n).checked_root(pow).unwrap(), 2);\n        }\n        let mut n = n;\n        n.clear_bit(pow);\n        assert_eq!(n, 0);\n    });\n\n    unsigned_gen_var_15::<Limb>().test_properties(|pow| {\n        assert_eq!(Limb::power_of_2(pow), Natural::power_of_2(pow));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/primorial.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Primorial;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::factorization::traits::{IsPrime, Primes};\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_5, unsigned_gen_var_27, unsigned_gen_var_28,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::natural::arithmetic::primorial::{\n    primorial_naive, product_of_first_n_primes_naive,\n};\nuse rug::Complete;\n\n#[test]\nfn test_primorial() {\n    fn test(n: u64, out: &str) {\n        let p = Natural::primorial(n);\n        assert!(p.is_valid());\n        assert_eq!(p.to_string(), out);\n        assert_eq!(primorial_naive(n).to_string(), out);\n        assert_eq!(\n            rug::Integer::primorial(u32::exact_from(n))\n                .complete()\n                .to_string(),\n            out\n        );\n    }\n    test(0, \"1\");\n    test(1, \"1\");\n    test(2, \"2\");\n    test(3, \"6\");\n    test(4, \"6\");\n    test(5, \"30\");\n    test(20, \"9699690\");\n    // - sieve[index] & mask == 0\n    // - prod <= max_prod\n    // - sieve[index] & mask != 0\n    // - prod > max_prod\n    test(53, \"32589158477190044730\");\n    test(100, \"2305567963945518424753102147331756070\");\n}\n\n#[test]\nfn test_product_of_first_n_primes() {\n    fn test(n: u64, out: &str) {\n        let p = Natural::product_of_first_n_primes(n);\n        assert!(p.is_valid());\n        assert_eq!(p.to_string(), out);\n        assert_eq!(product_of_first_n_primes_naive(n).to_string(), out);\n    }\n    test(0, \"1\");\n    test(1, \"2\");\n    test(2, \"6\");\n    test(3, \"30\");\n    test(4, \"210\");\n    test(5, \"2310\");\n    test(10, \"6469693230\");\n    test(\n        100,\n        \"47119307999061849531624878347602604220205747734096755201886348396164153358450342212052892\\\n        567055446819724391040977771579918043802842183150387194449439904925790307206359905384523125\\\n        28339864352999310398481791730017201031090\",\n    );\n}\n\n#[test]\nfn primorial_properties() {\n    unsigned_gen_var_5().test_properties(|n| {\n        let p = Natural::primorial(n);\n        assert!(p.is_valid());\n        assert_eq!(primorial_naive(n), p);\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::primorial(u32::exact_from(n)).complete()),\n            p\n        );\n        assert_ne!(p, 0u32);\n        if n != 0 {\n            let q = Natural::primorial(n - 1);\n            if n.is_prime() {\n                assert!(q < p);\n            } else {\n                assert_eq!(q, p);\n            }\n        }\n    });\n\n    unsigned_gen_var_27::<Limb>().test_properties(|n| {\n        assert_eq!(Natural::primorial(n), Limb::primorial(n));\n    });\n}\n\n#[test]\nfn product_of_first_n_primes_properties() {\n    unsigned_gen_var_5().test_properties(|n| {\n        let f = Natural::product_of_first_n_primes(n);\n        assert!(f.is_valid());\n        assert_eq!(product_of_first_n_primes_naive(n), f);\n        assert_ne!(f, 0);\n        if n != 0 {\n            let p = u64::primes().nth(usize::exact_from(n) - 1).unwrap();\n            assert_eq!(Natural::primorial(p), f);\n            assert_eq!(\n                f / Natural::product_of_first_n_primes(n - 1),\n                Natural::exact_from(p)\n            );\n        }\n    });\n\n    unsigned_gen_var_28::<Limb>().test_properties(|n| {\n        assert_eq!(\n            Natural::product_of_first_n_primes(n),\n            Limb::product_of_first_n_primes(n)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingRootAssign, CeilingSqrt, CheckedRoot, CheckedSqrt, FloorRoot,\n    FloorRootAssign, FloorSqrt, Pow, RootAssignRem, RootRem, SqrtRem,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_32, unsigned_vec_unsigned_pair_gen_var_14,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::root::{limbs_floor_root, limbs_root_rem};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_7};\nuse malachite_nz::test_util::natural::arithmetic::root::{\n    ceiling_root_binary, checked_root_binary, floor_root_binary, root_rem_binary,\n};\nuse num::BigUint;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_floor_root() {\n    let test = |xs: &[Limb], exp: u64, root: &[Limb], inexact: bool| {\n        let (actual_root, actual_inexact) = limbs_floor_root(xs, exp);\n        assert_eq!(actual_root, root);\n        assert_eq!(actual_inexact, inexact);\n        let n = Natural::from_limbs_asc(xs);\n        let r = Natural::from_limbs_asc(root);\n        let pow = (&r).pow(exp);\n        assert!(pow <= n);\n        assert!((r + Natural::ONE).pow(exp) > n);\n        assert_eq!(pow == n, !inexact);\n    };\n    // - (xs_len + 2) / 3 <= u_exp\n    // - bit_count < exp in limbs_root_to_out_internal\n    // - !out_rem_is_some in limbs_root_to_out_internal\n    test(&[1], 3, &[1], false);\n    // - bit_count >= exp in limbs_root_to_out_internal\n    // - leading_zeros != Limb::WIDTH in limbs_root_to_out_internal\n    // - bit_count.significant_bits() > LOGROOT_USED_BITS_COMP in log_based_root\n    // - !approx || ss[0] <= 1 in limbs_root_to_out_internal\n    // - need_adjust || qs_len != xs_len in limbs_root_to_out_internal\n    // - rs_len == 0 || !out_rem_is_some in limbs_root_to_out_internal\n    test(&[1000], 3, &[10], false);\n    // - root_bits > log_exp in limbs_root_to_out_internal\n    // - need_adjust || qs_len != rs_len in limbs_root_to_out_internal\n    // - pow_cmp != Equal in limbs_root_to_out_internal\n    // - carry == 0 first time in limbs_root_to_out_internal\n    // - n_len - 1 <= next_len in limbs_root_to_out_internal\n    // - carry == 0 second time in limbs_root_to_out_internal\n    // - rs_len >= ws_len in limbs_root_to_out_internal\n    // - qs_len <= b_rem in limbs_root_to_out_internal\n    // - qs_len <= b_rem && ... in limbs_root_to_out_internal\n    // - carry != 0 first time in limbs_root_to_out_internal\n    // - n_len - 1 > next_len in limbs_root_to_out_internal\n    test(&[123, 456, 789], 3, &[24415497], true);\n    // - leading_zeros == Limb::WIDTH in limbs_root_to_out_internal\n    test(&[0, 1], 3, &[1625], true);\n    // - pow_cmp == Equal in limbs_root_to_out_internal\n    // - rs_len < ws_len in limbs_root_to_out_internal\n    test(&[0, 0, 1], 4, &[65536], false);\n    // - !need_adjust && qs_len == rs_len in limbs_root_to_out_internal\n    // - !need_adjust && qs_len == xs_len in limbs_root_to_out_internal\n    // - carry != 0 second time in limbs_root_to_out_internal\n    test(&[0, 0, 1], 5, &[7131], true);\n    // - (xs_len + 2) / 3 > u_exp\n    // - approx && ss[0] > 1 in limbs_root_to_out_internal\n    test(\n        &[\n            10045114, 111940252, 2181719322, 1883679021, 2601294413, 1872079876, 578360935,\n            2248016248, 1648448409, 589499551, 573051942, 3101629567, 486103882, 3213846717,\n            2339835332, 2340868500, 3988971200,\n        ],\n        5,\n        &[2416867165, 2555201003, 3891828300, 7026],\n        true,\n    );\n    // - qs_len > b_rem || ... in limbs_root_to_out_internal\n    test(\n        &[\n            2055929154, 2630529572, 271121346, 1501542260, 1183697298, 2075827756, 4275724366,\n            1648161837, 3297263182, 4114641001, 1962106184, 3607497617, 561001103, 1137290806,\n            2335506779, 1869248612,\n        ],\n        3,\n        &[2524001878, 2377965049, 719885555, 160379071, 3624665804, 1231],\n        true,\n    );\n    // - limbs_root_to_out_internal, root_bits <= log_exp\n    test(\n        &[\n            1321882439, 1623785800, 3134073276, 2565564486, 2821610380, 2583585204, 3897897848,\n            47587649, 2888164080, 1492585590, 1855797547, 1510761479, 3993330677, 2012682921,\n            1836519625, 4236374717, 1223607044, 3596509294, 1741147226, 1412323213, 3811971203,\n            1621563690, 3665246834, 1046970441, 99078224, 420931190, 2916287708, 1336157470,\n            1469113083, 970862367, 3439357619, 2526884655, 1520990535, 3107383205, 3321150749,\n            828096485, 938849804, 164343730, 2130891622, 3754519147, 2436884346, 2736885571,\n            405986850, 1875306972, 3010233736, 3737129860, 2106807103, 419975711, 3145892129,\n            1185575287, 4062252394, 543504740, 3340440476, 4196738733, 2082551138, 1234502144,\n            3392112010, 3994477994, 1472445754, 934569550, 3244797218, 3086244200, 1419671372,\n            933654118, 1800407464, 3858653268, 180317861, 1556428454, 3366377290, 1090143530,\n            1147295140, 1271219922, 1096608888, 655592159, 1364844184, 1674114515, 1285632542,\n            2458523712, 2081876810, 3935363261, 4174442908, 2398083509, 963931968, 4194789136,\n            1729071894, 228036838, 2088259023, 2777007731, 2094146444, 888346074, 3199577164,\n            2715723581, 3607954173, 3433473090, 3678701040, 1035050400, 2036582500, 3748434538,\n            3152072052, 3413508577, 3191081341, 466218778, 4141778140, 2149717819, 2938658940,\n            2989191274, 3671957666, 727865845, 568269125, 3615953546, 2956535711, 879106809,\n            1582857293, 783679777, 604923241, 209547277, 3813482434, 1362157378, 1505311679,\n            2420123937, 4156219100, 2338704513, 1016908906, 2362401070, 125533635,\n        ],\n        189,\n        &[2306151],\n        false,\n    );\n}\n\n#[test]\nfn limbs_floor_root_fail() {\n    // - xs too short\n    assert_panic!(limbs_floor_root(&[], 3));\n    // - last element of xs zero\n    assert_panic!(limbs_floor_root(&[1, 0], 3));\n    // - exp is 0\n    assert_panic!(limbs_floor_root(&[1, 1], 0));\n    // - exp is 1\n    assert_panic!(limbs_floor_root(&[1, 1], 1));\n    // - exp is 2\n    assert_panic!(limbs_floor_root(&[1, 1], 2));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_root_rem() {\n    let test = |xs: &[Limb], exp: u64, root: &[Limb], rem: &[Limb]| {\n        let (actual_root, actual_rem) = limbs_root_rem(xs, exp);\n        assert_eq!(actual_root, root);\n        assert_eq!(actual_rem, rem);\n        let n = Natural::from_limbs_asc(xs);\n        let r_1 = Natural::from_limbs_asc(root);\n        let r_2 = Natural::from_limbs_asc(rem);\n        assert_eq!((&r_1).pow(exp) + r_2, n);\n        assert!((r_1 + Natural::ONE).pow(exp) > n);\n    };\n    // - bit_count < exp in limbs_root_to_out_internal\n    // - out_rem_is_some in limbs_root_to_out_internal\n    test(&[1], 3, &[1], &[]);\n    // - bit_count >= exp in limbs_root_to_out_internal\n    // - leading_zeros != Limb::WIDTH in limbs_root_to_out_internal\n    // - bit_count.significant_bits() <= LOGROOT_USED_BITS_COMP in log_based_root\n    // - !approx || ss[0] <= 1 in limbs_root_to_out_internal\n    // - !need_adjust && qs_len == xs_len in limbs_root_to_out_internal\n    // - rs_len == 0 || !out_rem_is_some in limbs_root_to_out_internal\n    test(&[1000], 3, &[10], &[]);\n    // - root_bits > log_exp in limbs_root_to_out_internal\n    // - need_adjust || qs_len != rs_len in limbs_root_to_out_internal\n    // - pow_cmp != Equal in limbs_root_to_out_internal\n    // - carry == 0 first time in limbs_root_to_out_internal\n    // - n_len - 1 <= next_len in limbs_root_to_out_internal\n    // - carry == 0 second time in limbs_root_to_out_internal\n    // - rs_len >= ws_len in limbs_root_to_out_internal\n    // - qs_len <= b_rem in limbs_root_to_out_internal\n    // - qs_len <= b_rem && ... in limbs_root_to_out_internal\n    // - carry != 0 first time in limbs_root_to_out_internal\n    // - n_len - 1 > next_len in limbs_root_to_out_internal\n    // - rs_len != 0 && out_rem_is_some in limbs_root_to_out_internal\n    test(&[123, 456, 789], 3, &[24415497], &[1082861218, 142292]);\n    // - leading_zeros == Limb::WIDTH in limbs_root_to_out_internal\n    test(&[0, 1], 3, &[1625], &[3951671]);\n    // - pow_cmp == Equal in limbs_root_to_out_internal\n    // - rs_len < ws_len in limbs_root_to_out_internal\n    test(&[0, 0, 1], 4, &[65536], &[]);\n    // - !need_adjust && qs_len == rs_len in limbs_root_to_out_internal\n    test(&[0, 0, 1], 5, &[7131], &[1889423061, 1656574]);\n    // - carry != 0 second time in limbs_root_to_out_internal\n    test(\n        &[\n            10045114, 111940252, 2181719322, 1883679021, 2601294413, 1872079876, 578360935,\n            2248016248, 1648448409, 589499551, 573051942, 3101629567, 486103882, 3213846717,\n            2339835332, 2340868500, 3988971200,\n        ],\n        5,\n        &[2416867165, 2555201003, 3891828300, 7026],\n        &[\n            3289703629, 3644089536, 1993609161, 1739315193, 2220455044, 1795995908, 3261364903,\n            2481515404, 3316729739, 227499169, 1205565253, 3882526697, 534818167, 1092514,\n        ],\n    );\n    test(\n        &[\n            2055929154, 2630529572, 271121346, 1501542260, 1183697298, 2075827756, 4275724366,\n            1648161837, 3297263182, 4114641001, 1962106184, 3607497617, 561001103, 1137290806,\n            2335506779, 1869248612,\n        ],\n        3,\n        &[2524001878, 2377965049, 719885555, 160379071, 3624665804, 1231],\n        &[\n            1938096298, 2492483757, 416851523, 4009456064, 358434376, 1470400066, 2808049667,\n            1641457454, 3086626670, 2101663143, 3655678,\n        ],\n    );\n    // - !need_adjust && qs_len == xs_len in limbs_root_to_out_internal\n    test(&[0, 2], 4, &[304], &[49217536]);\n    // - qs_len > b_rem || ... in limbs_root_to_out_internal\n    test(&[1002403925, 303302627], 4, &[33783], &[188673716, 30155]);\n}\n\n#[test]\nfn limbs_root_rem_fail() {\n    // - xs too short\n    assert_panic!(limbs_root_rem(&[], 3));\n    // - last element of xs zero\n    assert_panic!(limbs_root_rem(&[1, 0], 3));\n    // - exp is 0\n    assert_panic!(limbs_root_rem(&[1, 1], 0));\n    // - exp is 1\n    assert_panic!(limbs_root_rem(&[1, 1], 1));\n    // - exp is 2\n    assert_panic!(limbs_root_rem(&[1, 1], 2));\n}\n\n#[test]\nfn test_floor_root() {\n    let test = |s, exp, out| {\n        let n = Natural::from_str(s).unwrap();\n        assert_eq!(n.clone().floor_root(exp).to_string(), out);\n        assert_eq!((&n).floor_root(exp).to_string(), out);\n        assert_eq!(floor_root_binary(&n, exp).to_string(), out);\n\n        let mut n = n;\n        n.floor_root_assign(exp);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"100\", 1, \"100\");\n\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"1\");\n    test(\"3\", 2, \"1\");\n    test(\"4\", 2, \"2\");\n    test(\"5\", 2, \"2\");\n    test(\"0\", 3, \"0\");\n    test(\"1\", 3, \"1\");\n    test(\"2\", 3, \"1\");\n    test(\"7\", 3, \"1\");\n    test(\"8\", 3, \"2\");\n    test(\"9\", 3, \"2\");\n    test(\"10\", 2, \"3\");\n    test(\"100\", 2, \"10\");\n    test(\"100\", 3, \"4\");\n    test(\"1000000000\", 2, \"31622\");\n    test(\"1000000000\", 3, \"1000\");\n    test(\"1000000000\", 4, \"177\");\n    test(\"1000000000\", 5, \"63\");\n    test(\"1000000000\", 6, \"31\");\n    test(\"1000000000\", 7, \"19\");\n    test(\"1000000000\", 8, \"13\");\n    test(\"1000000000\", 9, \"10\");\n    test(\"1000000000\", 10, \"7\");\n}\n\n#[test]\n#[should_panic]\nfn floor_root_fail() {\n    Natural::ONE.floor_root(0);\n}\n\n#[test]\n#[should_panic]\nfn floor_root_ref_fail() {\n    (&Natural::ONE).floor_root(0);\n}\n\n#[test]\n#[should_panic]\nfn floor_root_assign_fail() {\n    let mut x = Natural::ONE;\n    x.floor_root_assign(0);\n}\n\n#[test]\nfn test_ceiling_root() {\n    let test = |s, exp, out| {\n        let n = Natural::from_str(s).unwrap();\n        assert_eq!(n.clone().ceiling_root(exp).to_string(), out);\n        assert_eq!((&n).ceiling_root(exp).to_string(), out);\n        assert_eq!(ceiling_root_binary(&n, exp).to_string(), out);\n\n        let mut n = n;\n        n.ceiling_root_assign(exp);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"100\", 1, \"100\");\n\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"2\");\n    test(\"3\", 2, \"2\");\n    test(\"4\", 2, \"2\");\n    test(\"5\", 2, \"3\");\n    test(\"0\", 3, \"0\");\n    test(\"1\", 3, \"1\");\n    test(\"2\", 3, \"2\");\n    test(\"7\", 3, \"2\");\n    test(\"8\", 3, \"2\");\n    test(\"9\", 3, \"3\");\n    test(\"10\", 2, \"4\");\n    test(\"100\", 2, \"10\");\n    test(\"100\", 3, \"5\");\n    test(\"1000000000\", 2, \"31623\");\n    test(\"1000000000\", 3, \"1000\");\n    test(\"1000000000\", 4, \"178\");\n    test(\"1000000000\", 5, \"64\");\n    test(\"1000000000\", 6, \"32\");\n    test(\"1000000000\", 7, \"20\");\n    test(\"1000000000\", 8, \"14\");\n    test(\"1000000000\", 9, \"10\");\n    test(\"1000000000\", 10, \"8\");\n}\n\n#[test]\n#[should_panic]\nfn ceiling_root_fail() {\n    Natural::ONE.ceiling_root(0);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_root_ref_fail() {\n    (&Natural::ONE).ceiling_root(0);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_root_assign_fail() {\n    let mut x = Natural::ONE;\n    x.ceiling_root_assign(0);\n}\n\n#[allow(clippy::redundant_closure_for_method_calls)]\n#[test]\nfn test_checked_root() {\n    let test = |s, exp, out: Option<&str>| {\n        let n = Natural::from_str(s).unwrap();\n        let out = out.map(|s| s.to_string());\n\n        assert_eq!(n.clone().checked_root(exp).map(|x| x.to_string()), out);\n        assert_eq!((&n).checked_root(exp).map(|x| x.to_string()), out);\n        assert_eq!(checked_root_binary(&n, exp).map(|x| x.to_string()), out);\n    };\n    test(\"0\", 1, Some(\"0\"));\n    test(\"1\", 1, Some(\"1\"));\n    test(\"2\", 1, Some(\"2\"));\n    test(\"100\", 1, Some(\"100\"));\n\n    test(\"0\", 2, Some(\"0\"));\n    test(\"1\", 2, Some(\"1\"));\n    test(\"2\", 2, None);\n    test(\"3\", 2, None);\n    test(\"4\", 2, Some(\"2\"));\n    test(\"5\", 2, None);\n    test(\"0\", 3, Some(\"0\"));\n    test(\"1\", 3, Some(\"1\"));\n    test(\"2\", 3, None);\n    test(\"7\", 3, None);\n    test(\"8\", 3, Some(\"2\"));\n    test(\"9\", 3, None);\n    test(\"10\", 2, None);\n    test(\"100\", 2, Some(\"10\"));\n    test(\"100\", 3, None);\n    test(\"1000000000\", 2, None);\n    test(\"1000000000\", 3, Some(\"1000\"));\n    test(\"1000000000\", 4, None);\n    test(\"1000000000\", 5, None);\n    test(\"1000000000\", 6, None);\n    test(\"1000000000\", 7, None);\n    test(\"1000000000\", 8, None);\n    test(\"1000000000\", 9, Some(\"10\"));\n    test(\"1000000000\", 10, None);\n}\n\n#[test]\n#[should_panic]\nfn checked_root_fail() {\n    Natural::ONE.checked_root(0);\n}\n\n#[test]\n#[should_panic]\nfn checked_root_ref_fail() {\n    (&Natural::ONE).checked_root(0);\n}\n\n#[test]\nfn test_root_rem() {\n    let test = |s, exp, root_out, rem_out| {\n        let n = Natural::from_str(s).unwrap();\n\n        let (root, rem) = n.clone().root_rem(exp);\n        assert_eq!(root.to_string(), root_out);\n        assert_eq!(rem.to_string(), rem_out);\n\n        let (root, rem) = (&n).root_rem(exp);\n        assert_eq!(root.to_string(), root_out);\n        assert_eq!(rem.to_string(), rem_out);\n\n        let (root, rem) = root_rem_binary(&n, exp);\n        assert_eq!(root.to_string(), root_out);\n        assert_eq!(rem.to_string(), rem_out);\n\n        let mut n = n;\n        assert_eq!(n.root_assign_rem(exp).to_string(), rem_out);\n        assert_eq!(n.to_string(), root_out);\n    };\n    test(\"0\", 1, \"0\", \"0\");\n    test(\"1\", 1, \"1\", \"0\");\n    test(\"2\", 1, \"2\", \"0\");\n    test(\"100\", 1, \"100\", \"0\");\n\n    test(\"0\", 2, \"0\", \"0\");\n    test(\"1\", 2, \"1\", \"0\");\n    test(\"2\", 2, \"1\", \"1\");\n    test(\"3\", 2, \"1\", \"2\");\n    test(\"4\", 2, \"2\", \"0\");\n    test(\"5\", 2, \"2\", \"1\");\n    test(\"0\", 3, \"0\", \"0\");\n    test(\"1\", 3, \"1\", \"0\");\n    test(\"2\", 3, \"1\", \"1\");\n    test(\"7\", 3, \"1\", \"6\");\n    test(\"8\", 3, \"2\", \"0\");\n    test(\"9\", 3, \"2\", \"1\");\n    test(\"10\", 2, \"3\", \"1\");\n    test(\"100\", 2, \"10\", \"0\");\n    test(\"100\", 3, \"4\", \"36\");\n    test(\"1000000000\", 2, \"31622\", \"49116\");\n    test(\"1000000000\", 3, \"1000\", \"0\");\n    test(\"1000000000\", 4, \"177\", \"18493759\");\n    test(\"1000000000\", 5, \"63\", \"7563457\");\n    test(\"1000000000\", 6, \"31\", \"112496319\");\n    test(\"1000000000\", 7, \"19\", \"106128261\");\n    test(\"1000000000\", 8, \"13\", \"184269279\");\n    test(\"1000000000\", 9, \"10\", \"0\");\n    test(\"1000000000\", 10, \"7\", \"717524751\");\n}\n\n#[test]\n#[should_panic]\nfn root_rem_fail() {\n    Natural::ONE.root_rem(0);\n}\n\n#[test]\n#[should_panic]\nfn root_rem_ref_fail() {\n    (&Natural::ONE).root_rem(0);\n}\n\n#[test]\n#[should_panic]\nfn root_assign_rem_fail() {\n    let mut x = Natural::ONE;\n    x.root_assign_rem(0);\n}\n\n#[test]\nfn limbs_floor_root_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_14().test_properties_with_config(&config, |(xs, exp)| {\n        let n = Natural::from_limbs_asc(&xs);\n        let actual_root = (&n).floor_root(exp);\n        let (root, inexact) = limbs_floor_root(&xs, exp);\n        assert_eq!(Natural::from_owned_limbs_asc(root), actual_root);\n        let pow = (&actual_root).pow(exp);\n        assert_eq!(pow == n, !inexact);\n        assert!(pow <= n);\n        assert!((actual_root + Natural::ONE).pow(exp) > n);\n    });\n}\n\n#[test]\nfn limbs_root_rem_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_14().test_properties_with_config(&config, |(xs, exp)| {\n        let n = Natural::from_limbs_asc(&xs);\n        let (actual_root, actual_rem) = (&n).root_rem(exp);\n        let (root, rem) = limbs_root_rem(&xs, exp);\n        assert_eq!(Natural::from_owned_limbs_asc(root), actual_root);\n        assert_eq!(Natural::from_owned_limbs_asc(rem), actual_rem);\n        assert_eq!((&actual_root).pow(exp) + actual_rem, n);\n        assert!((actual_root + Natural::ONE).pow(exp) > n);\n    });\n}\n\n#[test]\nfn floor_cbrt_properties() {\n    natural_gen().test_properties(|n| {\n        let cbrt = n.clone().floor_root(3);\n        assert!(cbrt.is_valid());\n        let cbrt_alt = (&n).floor_root(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(cbrt_alt, cbrt);\n        let mut n_alt = n.clone();\n        n_alt.floor_root_assign(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(n_alt, cbrt);\n        assert_eq!(floor_root_binary(&n, 3), cbrt);\n        assert_eq!(Natural::from(&BigUint::from(&n).nth_root(3)), cbrt);\n        assert_eq!(Natural::exact_from(&rug::Integer::from(&n).root(3)), cbrt);\n\n        let cube = (&cbrt).pow(3);\n        let ceiling_cbrt = (&n).ceiling_root(3);\n        if cube == n {\n            assert_eq!(ceiling_cbrt, cbrt);\n        } else {\n            assert_eq!(ceiling_cbrt, &cbrt + Natural::ONE);\n        }\n        assert!(cube <= n);\n        assert!((cbrt + Natural::ONE).pow(3) > n);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.floor_root(3), Natural::from(u).floor_root(3));\n    });\n}\n\n#[test]\nfn ceiling_cbrt_properties() {\n    natural_gen().test_properties(|n| {\n        let cbrt = n.clone().ceiling_root(3);\n        assert!(cbrt.is_valid());\n        let cbrt_alt = (&n).ceiling_root(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(cbrt_alt, cbrt);\n        let mut n_alt = n.clone();\n        n_alt.ceiling_root_assign(3);\n        assert!(cbrt_alt.is_valid());\n        assert_eq!(n_alt, cbrt);\n        assert_eq!(ceiling_root_binary(&n, 3), cbrt);\n        let cube = (&cbrt).pow(3);\n        let floor_cbrt = (&n).floor_root(3);\n        if cube == n {\n            assert_eq!(floor_cbrt, cbrt);\n        } else {\n            assert_eq!(floor_cbrt, &cbrt - Natural::ONE);\n        }\n        assert!(cube >= n);\n        if n != 0 {\n            assert!((cbrt - Natural::ONE).pow(3) < n);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.ceiling_root(3), Natural::from(u).ceiling_root(3));\n    });\n}\n\n#[test]\nfn checked_cbrt_properties() {\n    natural_gen().test_properties(|n| {\n        let cbrt = n.clone().checked_root(3);\n        assert!(cbrt.as_ref().is_none_or(Natural::is_valid));\n        let cbrt_alt = (&n).checked_root(3);\n        assert!(cbrt_alt.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(cbrt_alt, cbrt);\n        assert_eq!(checked_root_binary(&n, 3), cbrt);\n        if let Some(cbrt) = cbrt {\n            assert_eq!((&cbrt).pow(3), n);\n            assert_eq!((&n).floor_root(3), cbrt);\n            assert_eq!(n.ceiling_root(3), cbrt);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(\n            u.checked_root(3).map(Natural::from),\n            Natural::from(u).checked_root(3)\n        );\n    });\n}\n\n#[test]\nfn cbrt_rem_properties() {\n    natural_gen().test_properties(|n| {\n        let (cbrt, rem) = n.clone().root_rem(3);\n        assert!(cbrt.is_valid());\n        assert!(rem.is_valid());\n        let (cbrt_alt, rem_alt) = (&n).root_rem(3);\n        assert!(cbrt_alt.is_valid());\n        assert!(rem_alt.is_valid());\n        assert_eq!(cbrt_alt, cbrt_alt);\n        assert_eq!(rem_alt, rem);\n        let mut n_alt = n.clone();\n        let rem_alt = n_alt.root_assign_rem(3);\n        assert!(n_alt.is_valid());\n        assert!(rem_alt.is_valid());\n        assert_eq!(n_alt, cbrt);\n        assert_eq!(rem_alt, rem);\n        assert_eq!(root_rem_binary(&n, 3), (cbrt.clone(), rem.clone()));\n        let (rug_cbrt, rug_rem) = rug::Integer::from(&n).root_rem(rug::Integer::new(), 3);\n        assert_eq!(Natural::exact_from(&rug_cbrt), cbrt);\n        assert_eq!(Natural::exact_from(&rug_rem), rem);\n\n        assert_eq!((&n).floor_root(3), cbrt);\n        assert_eq!(cbrt.pow(3) + rem, n);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        let (cbrt, rem) = u.root_rem(3);\n        assert_eq!(\n            (Natural::from(cbrt), Natural::from(rem)),\n            Natural::from(u).root_rem(3)\n        );\n    });\n}\n\n#[test]\nfn floor_root_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, exp)| {\n        let root = n.clone().floor_root(exp);\n        assert!(root.is_valid());\n        let root_alt = (&n).floor_root(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(root_alt, root);\n        let mut n_alt = n.clone();\n        n_alt.floor_root_assign(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(n_alt, root);\n        assert_eq!(floor_root_binary(&n, exp), root);\n        assert_eq!(\n            Natural::from(&BigUint::from(&n).nth_root(u32::exact_from(exp))),\n            root\n        );\n        assert_eq!(\n            Natural::exact_from(&rug::Integer::from(&n).root(u32::exact_from(exp))),\n            root\n        );\n\n        let pow = (&root).pow(exp);\n        let ceiling_root = (&n).ceiling_root(exp);\n        if pow == n {\n            assert_eq!(ceiling_root, root);\n        } else {\n            assert_eq!(ceiling_root, &root + Natural::ONE);\n        }\n        assert!(pow <= n);\n        assert!((root + Natural::ONE).pow(exp) > n);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).floor_root(2), (&n).floor_sqrt());\n        assert_eq!((&n).floor_root(1), n);\n    });\n\n    unsigned_pair_gen_var_32::<Limb, u64>().test_properties(|(u, exp)| {\n        assert_eq!(u.floor_root(exp), Natural::from(u).floor_root(exp));\n    });\n}\n\n#[test]\nfn ceiling_root_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, exp)| {\n        let root = n.clone().ceiling_root(exp);\n        assert!(root.is_valid());\n        let root_alt = (&n).ceiling_root(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(root_alt, root);\n        let mut n_alt = n.clone();\n        n_alt.ceiling_root_assign(exp);\n        assert!(root_alt.is_valid());\n        assert_eq!(n_alt, root);\n        assert_eq!(ceiling_root_binary(&n, exp), root);\n        let pow = (&root).pow(exp);\n        let floor_root = (&n).floor_root(exp);\n        if pow == n {\n            assert_eq!(floor_root, root);\n        } else {\n            assert_eq!(floor_root, &root - Natural::ONE);\n        }\n        assert!(pow >= n);\n        if n != 0 {\n            assert!((root - Natural::ONE).pow(exp) < n);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).ceiling_root(2), (&n).ceiling_sqrt());\n        assert_eq!((&n).ceiling_root(1), n);\n    });\n\n    unsigned_pair_gen_var_32::<Limb, u64>().test_properties(|(u, exp)| {\n        assert_eq!(u.ceiling_root(exp), Natural::from(u).ceiling_root(exp));\n    });\n}\n\n#[test]\nfn checked_root_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, exp)| {\n        let root = n.clone().checked_root(exp);\n        assert!(root.as_ref().is_none_or(Natural::is_valid));\n        let root_alt = (&n).checked_root(exp);\n        assert!(root_alt.as_ref().is_none_or(Natural::is_valid));\n        assert_eq!(root_alt, root);\n        assert_eq!(checked_root_binary(&n, exp), root);\n        if let Some(root) = root {\n            assert_eq!((&root).pow(exp), n);\n            assert_eq!((&n).floor_root(exp), root);\n            assert_eq!(n.ceiling_root(exp), root);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).checked_root(2), (&n).checked_sqrt());\n        assert_eq!((&n).checked_root(1), Some(n));\n    });\n\n    unsigned_pair_gen_var_32::<Limb, u64>().test_properties(|(u, exp)| {\n        assert_eq!(\n            u.checked_root(exp).map(Natural::from),\n            Natural::from(u).checked_root(exp)\n        );\n    });\n}\n\n#[test]\nfn root_rem_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, exp)| {\n        let (root, rem) = n.clone().root_rem(exp);\n        assert!(root.is_valid());\n        assert!(rem.is_valid());\n        let (root_alt, rem_alt) = (&n).root_rem(exp);\n        assert!(root_alt.is_valid());\n        assert!(rem_alt.is_valid());\n        assert_eq!(root_alt, root);\n        assert_eq!(rem_alt, rem);\n        let mut n_alt = n.clone();\n        let rem_alt = n_alt.root_assign_rem(exp);\n        assert!(root_alt.is_valid());\n        assert!(rem_alt.is_valid());\n        assert_eq!(n_alt, root);\n        assert_eq!(rem_alt, rem);\n        assert_eq!(root_rem_binary(&n, exp), (root.clone(), rem.clone()));\n        let (rug_root, rug_rem) =\n            rug::Integer::from(&n).root_rem(rug::Integer::new(), u32::exact_from(exp));\n        assert_eq!(Natural::exact_from(&rug_root), root);\n        assert_eq!(Natural::exact_from(&rug_rem), rem);\n\n        assert_eq!((&n).floor_root(exp), root);\n        assert_eq!(root.pow(exp) + rem, n);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).root_rem(2), (&n).sqrt_rem());\n        assert_eq!((&n).root_rem(1), (n, Natural::ZERO));\n    });\n\n    unsigned_pair_gen_var_32::<Limb, u64>().test_properties(|(u, exp)| {\n        let (root, rem) = u.root_rem(exp);\n        assert_eq!(\n            (Natural::from(root), Natural::from(rem)),\n            Natural::from(u).root_rem(exp)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, DivRound, DivisibleBy, Parity, RoundToMultiple, RoundToMultipleAssign,\n};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::unsigned_unsigned_rounding_mode_triple_gen_var_2;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_natural_rounding_mode_triple_gen_var_2, natural_pair_gen_var_5, natural_pair_gen_var_7,\n    natural_rounding_mode_pair_gen,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_round_to_multiple() {\n    let test = |s, t, rm, quotient, o| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        assert_eq!(x.round_to_multiple_assign(v.clone(), rm), o);\n        assert_eq!(x.to_string(), quotient);\n        assert!(x.is_valid());\n\n        let mut x = u.clone();\n        assert_eq!(x.round_to_multiple_assign(&v, rm), o);\n        assert_eq!(x.to_string(), quotient);\n        assert!(x.is_valid());\n\n        let (r, o_alt) = u.clone().round_to_multiple(v.clone(), rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = u.clone().round_to_multiple(&v, rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = (&u).round_to_multiple(v.clone(), rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = (&u).round_to_multiple(&v, rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", \"1\", Down, \"0\", Equal);\n    test(\"0\", \"1\", Floor, \"0\", Equal);\n    test(\"0\", \"1\", Up, \"0\", Equal);\n    test(\"0\", \"1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"1\", Nearest, \"0\", Equal);\n    test(\"0\", \"1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"123\", Down, \"0\", Equal);\n    test(\"0\", \"123\", Floor, \"0\", Equal);\n    test(\"0\", \"123\", Up, \"0\", Equal);\n    test(\"0\", \"123\", Ceiling, \"0\", Equal);\n    test(\"0\", \"123\", Nearest, \"0\", Equal);\n    test(\"0\", \"123\", Exact, \"0\", Equal);\n\n    test(\"1\", \"1\", Down, \"1\", Equal);\n    test(\"1\", \"1\", Floor, \"1\", Equal);\n    test(\"1\", \"1\", Up, \"1\", Equal);\n    test(\"1\", \"1\", Ceiling, \"1\", Equal);\n    test(\"1\", \"1\", Nearest, \"1\", Equal);\n    test(\"1\", \"1\", Exact, \"1\", Equal);\n\n    test(\"123\", \"1\", Down, \"123\", Equal);\n    test(\"123\", \"1\", Floor, \"123\", Equal);\n    test(\"123\", \"1\", Up, \"123\", Equal);\n    test(\"123\", \"1\", Ceiling, \"123\", Equal);\n    test(\"123\", \"1\", Nearest, \"123\", Equal);\n    test(\"123\", \"1\", Exact, \"123\", Equal);\n\n    test(\"123\", \"2\", Down, \"122\", Less);\n    test(\"123\", \"2\", Floor, \"122\", Less);\n    test(\"123\", \"2\", Up, \"124\", Greater);\n    test(\"123\", \"2\", Ceiling, \"124\", Greater);\n    test(\"123\", \"2\", Nearest, \"124\", Greater);\n\n    test(\"125\", \"2\", Down, \"124\", Less);\n    test(\"125\", \"2\", Floor, \"124\", Less);\n    test(\"125\", \"2\", Up, \"126\", Greater);\n    test(\"125\", \"2\", Ceiling, \"126\", Greater);\n    test(\"125\", \"2\", Nearest, \"124\", Less);\n\n    test(\"123\", \"123\", Down, \"123\", Equal);\n    test(\"123\", \"123\", Floor, \"123\", Equal);\n    test(\"123\", \"123\", Up, \"123\", Equal);\n    test(\"123\", \"123\", Ceiling, \"123\", Equal);\n    test(\"123\", \"123\", Nearest, \"123\", Equal);\n    test(\"123\", \"123\", Exact, \"123\", Equal);\n\n    test(\"123\", \"456\", Down, \"0\", Less);\n    test(\"123\", \"456\", Floor, \"0\", Less);\n    test(\"123\", \"456\", Up, \"456\", Greater);\n    test(\"123\", \"456\", Ceiling, \"456\", Greater);\n    test(\"123\", \"456\", Nearest, \"0\", Less);\n\n    test(\"1000000000000\", \"1\", Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", \"1\", Exact, \"1000000000000\", Equal);\n\n    test(\"1000000000000\", \"3\", Down, \"999999999999\", Less);\n    test(\"1000000000000\", \"3\", Floor, \"999999999999\", Less);\n    test(\"1000000000000\", \"3\", Up, \"1000000000002\", Greater);\n    test(\"1000000000000\", \"3\", Ceiling, \"1000000000002\", Greater);\n    test(\"1000000000000\", \"3\", Nearest, \"999999999999\", Less);\n\n    test(\"999999999999\", \"2\", Down, \"999999999998\", Less);\n    test(\"999999999999\", \"2\", Floor, \"999999999998\", Less);\n    test(\"999999999999\", \"2\", Up, \"1000000000000\", Greater);\n    test(\"999999999999\", \"2\", Ceiling, \"1000000000000\", Greater);\n    test(\"999999999999\", \"2\", Nearest, \"1000000000000\", Greater);\n\n    test(\"1000000000001\", \"2\", Down, \"1000000000000\", Less);\n    test(\"1000000000001\", \"2\", Floor, \"1000000000000\", Less);\n    test(\"1000000000001\", \"2\", Up, \"1000000000002\", Greater);\n    test(\"1000000000001\", \"2\", Ceiling, \"1000000000002\", Greater);\n    test(\"1000000000001\", \"2\", Nearest, \"1000000000000\", Less);\n\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Down,\n        \"999999999999996832276305\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Floor,\n        \"999999999999996832276305\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Up,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Ceiling,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"4294967295\",\n        Nearest,\n        \"1000000000000001127243600\",\n        Greater,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Down,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Floor,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Up,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Ceiling,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Nearest,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        Exact,\n        \"1000000000000000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Down,\n        \"999999999999999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Floor,\n        \"999999999999999999999999\",\n        Less,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Up,\n        \"1000000000001000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Ceiling,\n        \"1000000000001000000000000\",\n        Greater,\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000001\",\n        Nearest,\n        \"999999999999999999999999\",\n        Less,\n    );\n\n    test(\n        \"2999999999999999999999999\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"2000000000000000000000000\",\n        Less,\n    );\n    test(\n        \"3000000000000000000000000\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"4000000000000000000000000\",\n        Greater,\n    );\n    test(\n        \"3000000000000000000000001\",\n        \"2000000000000000000000000\",\n        Nearest,\n        \"4000000000000000000000000\",\n        Greater,\n    );\n\n    test(\"0\", \"0\", Floor, \"0\", Equal);\n    test(\"0\", \"0\", Ceiling, \"0\", Equal);\n    test(\"0\", \"0\", Down, \"0\", Equal);\n    test(\"0\", \"0\", Up, \"0\", Equal);\n    test(\"0\", \"0\", Nearest, \"0\", Equal);\n    test(\"0\", \"0\", Exact, \"0\", Equal);\n\n    test(\"2\", \"0\", Floor, \"0\", Less);\n    test(\"2\", \"0\", Down, \"0\", Less);\n    test(\"2\", \"0\", Nearest, \"0\", Less);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_1() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_2() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(Natural::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_3() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(Natural::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_4() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(Natural::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_1() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(&Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_2() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(&Natural::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_3() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(&Natural::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_4() {\n    let mut n = Natural::from(10u32);\n    n.round_to_multiple_assign(&Natural::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_1() {\n    Natural::from(10u32).round_to_multiple(Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_2() {\n    Natural::from(10u32).round_to_multiple(Natural::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_3() {\n    Natural::from(10u32).round_to_multiple(Natural::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_4() {\n    Natural::from(10u32).round_to_multiple(Natural::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_1() {\n    Natural::from(10u32).round_to_multiple(&Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_2() {\n    Natural::from(10u32).round_to_multiple(&Natural::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_3() {\n    Natural::from(10u32).round_to_multiple(&Natural::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_4() {\n    Natural::from(10u32).round_to_multiple(&Natural::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_1() {\n    (&Natural::from(10u32)).round_to_multiple(Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_2() {\n    (&Natural::from(10u32)).round_to_multiple(Natural::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_3() {\n    (&Natural::from(10u32)).round_to_multiple(Natural::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_4() {\n    (&Natural::from(10u32)).round_to_multiple(Natural::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_1() {\n    (&Natural::from(10u32)).round_to_multiple(&Natural::from(3u32), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_2() {\n    (&Natural::from(10u32)).round_to_multiple(&Natural::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_3() {\n    (&Natural::from(10u32)).round_to_multiple(&Natural::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_4() {\n    (&Natural::from(10u32)).round_to_multiple(&Natural::ZERO, Exact);\n}\n\n#[test]\nfn round_to_multiple_properties() {\n    natural_natural_rounding_mode_triple_gen_var_2().test_properties(|(x, y, rm)| {\n        let mut mut_x = x.clone();\n        let o = mut_x.round_to_multiple_assign(&y, rm);\n        assert!(mut_x.is_valid());\n        let r = mut_x;\n\n        let mut mut_x = x.clone();\n        assert_eq!(mut_x.round_to_multiple_assign(y.clone(), rm), o);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, r);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(&y, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(y.clone(), rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = x.clone().round_to_multiple(&y, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = x.clone().round_to_multiple(y.clone(), rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        assert!((&r).divisible_by(&y));\n        assert_eq!(r.cmp(&x), o);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if y == 0 {\n            assert_eq!(r, 0);\n        } else {\n            assert!((Integer::from(&r) - Integer::from(&x)).abs() <= y);\n            match rm {\n                Floor | Down => assert!(r <= x),\n                Ceiling | Up => assert!(r >= x),\n                Exact => assert_eq!(r, x),\n                Nearest => {\n                    let closest;\n                    let second_closest;\n                    if r <= x {\n                        closest = &x - &r;\n                        second_closest = &r + &y - x;\n                    } else {\n                        closest = &r - &x;\n                        second_closest = x + &y - &r;\n                    }\n                    assert!(closest <= second_closest);\n                    if closest == second_closest {\n                        assert!((&r).div_round(&y, Exact).0.even());\n                    }\n                }\n            }\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        let product = &x * &y;\n        let po = (product.clone(), Equal);\n        assert_eq!((&product).round_to_multiple(&y, Down), po);\n        assert_eq!((&product).round_to_multiple(&y, Up), po);\n        assert_eq!((&product).round_to_multiple(&y, Floor), po);\n        assert_eq!((&product).round_to_multiple(&y, Ceiling), po);\n        assert_eq!((&product).round_to_multiple(&y, Nearest), po);\n        assert_eq!((&product).round_to_multiple(y, Exact), po);\n    });\n\n    natural_pair_gen_var_7().test_properties(|(x, y)| {\n        let down = (&x).round_to_multiple(&y, Down);\n        assert_eq!(down.1, Less);\n        let up = (&down.0 + &y, Greater);\n        assert_eq!((&x).round_to_multiple(&y, Up), up);\n        assert_eq!((&x).round_to_multiple(&y, Floor), down);\n        assert_eq!((&x).round_to_multiple(&y, Ceiling), up);\n        let nearest = x.round_to_multiple(y, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    natural_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let xo = (x.clone(), Equal);\n        assert_eq!((&x).round_to_multiple(Natural::ONE, rm), xo);\n        assert_eq!(\n            Natural::ZERO.round_to_multiple(&x, rm),\n            (Natural::ZERO, Equal)\n        );\n        assert_eq!((&x).round_to_multiple(&x, rm), xo);\n    });\n\n    unsigned_unsigned_rounding_mode_triple_gen_var_2::<Limb>().test_properties(|(x, y, rm)| {\n        let (n, no) = x.round_to_multiple(y, rm);\n        let (i, io) = Natural::from(x).round_to_multiple(Natural::from(y), rm);\n        assert_eq!(n, i);\n        assert_eq!(no, io);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse core::cmp::Ordering::*;\n#[cfg(feature = \"32_bit_limbs\")]\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    Abs, DivisibleByPowerOf2, PowerOf2, RoundToMultiple, RoundToMultipleOfPowerOf2,\n    RoundToMultipleOfPowerOf2Assign, ShrRound,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_rounding_mode_pair_gen, unsigned_unsigned_rounding_mode_triple_gen_var_3,\n    unsigned_vec_unsigned_pair_gen_var_16, unsigned_vec_unsigned_pair_gen_var_20,\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::round_to_multiple_of_power_of_2::{\n    limbs_round_to_multiple_of_power_of_2, limbs_round_to_multiple_of_power_of_2_down,\n    limbs_round_to_multiple_of_power_of_2_down_in_place,\n    limbs_round_to_multiple_of_power_of_2_in_place, limbs_round_to_multiple_of_power_of_2_nearest,\n    limbs_round_to_multiple_of_power_of_2_nearest_in_place,\n    limbs_round_to_multiple_of_power_of_2_up, limbs_round_to_multiple_of_power_of_2_up_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_rounding_mode_pair_gen, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_pair_gen_var_10, natural_unsigned_pair_gen_var_13,\n    natural_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_round_to_multiple_of_power_of_2_down() {\n    let test = |xs: &[Limb], pow: u64, out: &[Limb], o: Ordering| {\n        let (r, o_alt) = limbs_round_to_multiple_of_power_of_2_down(xs, pow);\n        assert_eq!(r, out);\n        assert_eq!(o_alt, o);\n\n        let mut xs = xs.to_vec();\n        assert_eq!(\n            limbs_round_to_multiple_of_power_of_2_down_in_place(&mut xs, pow),\n            o\n        );\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, &[], Equal);\n    test(&[], 1, &[], Equal);\n    test(&[], 100, &[], Equal);\n    test(&[0, 0, 0], 0, &[0, 0, 0], Equal);\n    test(&[0, 0, 0], 1, &[0, 0, 0], Equal);\n    test(&[0, 0, 0], 100, &[], Equal);\n    test(&[1], 0, &[1], Equal);\n    test(&[1], 1, &[0], Less);\n    test(&[3], 1, &[2], Less);\n    test(&[122, 456], 1, &[122, 456], Equal);\n    test(&[123, 456], 0, &[123, 456], Equal);\n    test(&[123, 456], 1, &[122, 456], Less);\n    test(&[123, 455], 1, &[122, 455], Less);\n    test(&[123, 456], 31, &[0, 456], Less);\n    test(&[123, 456], 32, &[0, 456], Less);\n    test(&[123, 456], 100, &[], Less);\n    test(&[256, 456], 8, &[256, 456], Equal);\n    test(&[u32::MAX, 1], 1, &[u32::MAX - 1, 1], Less);\n    test(&[u32::MAX, u32::MAX], 32, &[0, u32::MAX], Less);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_round_to_multiple_of_power_of_2_up_in_place() {\n    let test = |xs: &[Limb], pow: u64, out: &[Limb], o: Ordering| {\n        let (r, o_alt) = limbs_round_to_multiple_of_power_of_2_up(xs, pow);\n        assert_eq!(r, out);\n        assert_eq!(o_alt, o);\n\n        let mut xs = xs.to_vec();\n        assert_eq!(\n            limbs_round_to_multiple_of_power_of_2_up_in_place(&mut xs, pow),\n            o\n        );\n        assert_eq!(xs, out);\n    };\n    test(&[1], 0, &[1], Equal);\n    test(&[1], 1, &[2], Greater);\n    test(&[3], 1, &[4], Greater);\n    test(&[122, 456], 1, &[122, 456], Equal);\n    test(&[123, 456], 0, &[123, 456], Equal);\n    test(&[123, 456], 1, &[124, 456], Greater);\n    test(&[123, 455], 1, &[124, 455], Greater);\n    test(&[123, 456], 31, &[0x80000000, 456], Greater);\n    test(&[123, 456], 32, &[0, 457], Greater);\n    test(&[123, 456], 100, &[0, 0, 0, 16], Greater);\n    test(&[256, 456], 8, &[256, 456], Equal);\n    test(&[u32::MAX, 1], 1, &[0, 2], Greater);\n    test(&[u32::MAX, u32::MAX], 32, &[0, 0, 1], Greater);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_round_to_multiple_of_power_of_2_nearest() {\n    let test = |xs: &[Limb], pow: u64, out: &[Limb], o: Ordering| {\n        let (r, o_alt) = limbs_round_to_multiple_of_power_of_2_nearest(xs, pow);\n        assert_eq!(r, out);\n        assert_eq!(o_alt, o);\n\n        let mut xs = xs.to_vec();\n        assert_eq!(\n            limbs_round_to_multiple_of_power_of_2_nearest_in_place(&mut xs, pow),\n            o\n        );\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, &[], Equal);\n    test(&[], 1, &[], Equal);\n    test(&[], 100, &[], Equal);\n    test(&[0, 0, 0], 0, &[0, 0, 0], Equal);\n    test(&[0, 0, 0], 1, &[0, 0, 0], Equal);\n    test(&[0, 0, 0], 100, &[], Equal);\n    test(&[1], 0, &[1], Equal);\n    test(&[1], 1, &[0], Less);\n    test(&[3], 1, &[4], Greater);\n    test(&[122, 456], 1, &[122, 456], Equal);\n    test(&[123, 456], 0, &[123, 456], Equal);\n    test(&[123, 456], 1, &[124, 456], Greater);\n    test(&[123, 455], 1, &[124, 455], Greater);\n    test(&[123, 456], 31, &[0, 456], Less);\n    test(&[123, 456], 32, &[0, 456], Less);\n    test(&[123, 456], 100, &[], Less);\n    test(&[256, 456], 8, &[256, 456], Equal);\n    test(&[u32::MAX, 1], 1, &[0, 2], Greater);\n    test(&[u32::MAX, u32::MAX], 32, &[0, 0, 1], Greater);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_round_to_multiple_of_power_of_2() {\n    let test = |xs: &[Limb], pow: u64, rm: RoundingMode, out: Option<(&[Limb], Ordering)>| {\n        let result = limbs_round_to_multiple_of_power_of_2(xs, pow, rm);\n        if let Some((r, o_alt)) = result {\n            let out = out.unwrap();\n            assert_eq!(r, out.0);\n            assert_eq!(o_alt, out.1);\n        } else {\n            assert!(out.is_none());\n        }\n\n        let mut xs = xs.to_vec();\n        limbs_round_to_multiple_of_power_of_2_in_place(&mut xs, pow, rm).map_or_else(\n            || assert!(out.is_none()),\n            |o_alt| {\n                let out = out.unwrap();\n                assert_eq!(xs, out.0);\n                assert_eq!(o_alt, out.1);\n            },\n        );\n    };\n    test(&[1], 0, Nearest, Some((&[1], Equal)));\n    test(&[1], 1, Up, Some((&[2], Greater)));\n    test(&[3], 1, Nearest, Some((&[4], Greater)));\n    test(&[122, 456], 1, Floor, Some((&[122, 456], Equal)));\n    test(&[123, 456], 0, Floor, Some((&[123, 456], Equal)));\n    test(&[123, 456], 1, Down, Some((&[122, 456], Less)));\n    test(&[123, 455], 1, Floor, Some((&[122, 455], Less)));\n    test(\n        &[123, 456],\n        31,\n        Ceiling,\n        Some((&[0x80000000, 456], Greater)),\n    );\n    test(&[123, 456], 32, Up, Some((&[0, 457], Greater)));\n    test(&[123, 456], 100, Down, Some((&[], Less)));\n    test(&[256, 456], 8, Exact, Some((&[256, 456], Equal)));\n    test(&[u32::MAX, 1], 1, Exact, None);\n    test(\n        &[u32::MAX, u32::MAX],\n        32,\n        Down,\n        Some((&[0, u32::MAX], Less)),\n    );\n}\n\n#[test]\nfn test_round_to_multiple_of_power_of_2() {\n    let test = |s, v: u64, rm: RoundingMode, out, o| {\n        let u = Natural::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        assert_eq!(n.round_to_multiple_of_power_of_2_assign(v, rm), o);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let (n, o_alt) = u.clone().round_to_multiple_of_power_of_2(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n\n        let (n, o_alt) = (&u).round_to_multiple_of_power_of_2(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n\n        let (n, o_alt) = u.shr_round(v, rm);\n        assert_eq!((n << v).to_string(), out);\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", 0, Down, \"0\", Equal);\n    test(\"0\", 0, Up, \"0\", Equal);\n    test(\"0\", 0, Floor, \"0\", Equal);\n    test(\"0\", 0, Ceiling, \"0\", Equal);\n    test(\"0\", 0, Nearest, \"0\", Equal);\n    test(\"0\", 0, Exact, \"0\", Equal);\n\n    test(\"0\", 10, Down, \"0\", Equal);\n    test(\"0\", 10, Up, \"0\", Equal);\n    test(\"0\", 10, Floor, \"0\", Equal);\n    test(\"0\", 10, Ceiling, \"0\", Equal);\n    test(\"0\", 10, Nearest, \"0\", Equal);\n    test(\"0\", 10, Exact, \"0\", Equal);\n\n    test(\"123\", 0, Down, \"123\", Equal);\n    test(\"123\", 0, Up, \"123\", Equal);\n    test(\"123\", 0, Floor, \"123\", Equal);\n    test(\"123\", 0, Ceiling, \"123\", Equal);\n    test(\"123\", 0, Nearest, \"123\", Equal);\n    test(\"123\", 0, Exact, \"123\", Equal);\n\n    test(\"245\", 1, Down, \"244\", Less);\n    test(\"245\", 1, Up, \"246\", Greater);\n    test(\"245\", 1, Floor, \"244\", Less);\n    test(\"245\", 1, Ceiling, \"246\", Greater);\n    test(\"245\", 1, Nearest, \"244\", Less);\n\n    test(\"246\", 1, Down, \"246\", Equal);\n    test(\"246\", 1, Up, \"246\", Equal);\n    test(\"246\", 1, Floor, \"246\", Equal);\n    test(\"246\", 1, Ceiling, \"246\", Equal);\n    test(\"246\", 1, Nearest, \"246\", Equal);\n    test(\"246\", 1, Exact, \"246\", Equal);\n\n    test(\"247\", 1, Down, \"246\", Less);\n    test(\"247\", 1, Up, \"248\", Greater);\n    test(\"247\", 1, Floor, \"246\", Less);\n    test(\"247\", 1, Ceiling, \"248\", Greater);\n    test(\"247\", 1, Nearest, \"248\", Greater);\n\n    test(\"491\", 2, Down, \"488\", Less);\n    test(\"491\", 2, Up, \"492\", Greater);\n    test(\"491\", 2, Floor, \"488\", Less);\n    test(\"491\", 2, Ceiling, \"492\", Greater);\n    test(\"491\", 2, Nearest, \"492\", Greater);\n\n    test(\"492\", 2, Down, \"492\", Equal);\n    test(\"492\", 2, Up, \"492\", Equal);\n    test(\"492\", 2, Floor, \"492\", Equal);\n    test(\"492\", 2, Ceiling, \"492\", Equal);\n    test(\"492\", 2, Nearest, \"492\", Equal);\n    test(\"492\", 2, Exact, \"492\", Equal);\n\n    test(\"493\", 2, Down, \"492\", Less);\n    test(\"493\", 2, Up, \"496\", Greater);\n    test(\"493\", 2, Floor, \"492\", Less);\n    test(\"493\", 2, Ceiling, \"496\", Greater);\n    test(\"493\", 2, Nearest, \"492\", Less);\n\n    test(\"4127195135\", 25, Down, \"4093640704\", Less);\n    test(\"4127195135\", 25, Up, \"4127195136\", Greater);\n    test(\"4127195135\", 25, Floor, \"4093640704\", Less);\n    test(\"4127195135\", 25, Ceiling, \"4127195136\", Greater);\n    test(\"4127195135\", 25, Nearest, \"4127195136\", Greater);\n\n    test(\"4127195136\", 25, Down, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Up, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Floor, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Ceiling, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Nearest, \"4127195136\", Equal);\n    test(\"4127195136\", 25, Exact, \"4127195136\", Equal);\n\n    test(\"4127195137\", 25, Down, \"4127195136\", Less);\n    test(\"4127195137\", 25, Up, \"4160749568\", Greater);\n    test(\"4127195137\", 25, Floor, \"4127195136\", Less);\n    test(\"4127195137\", 25, Ceiling, \"4160749568\", Greater);\n    test(\"4127195137\", 25, Nearest, \"4127195136\", Less);\n\n    test(\"8254390271\", 26, Down, \"8187281408\", Less);\n    test(\"8254390271\", 26, Up, \"8254390272\", Greater);\n    test(\"8254390271\", 26, Floor, \"8187281408\", Less);\n    test(\"8254390271\", 26, Ceiling, \"8254390272\", Greater);\n    test(\"8254390271\", 26, Nearest, \"8254390272\", Greater);\n\n    test(\"8254390272\", 26, Down, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Up, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Floor, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Ceiling, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Nearest, \"8254390272\", Equal);\n    test(\"8254390272\", 26, Exact, \"8254390272\", Equal);\n\n    test(\"8254390273\", 26, Down, \"8254390272\", Less);\n    test(\"8254390273\", 26, Up, \"8321499136\", Greater);\n    test(\"8254390273\", 26, Floor, \"8254390272\", Less);\n    test(\"8254390273\", 26, Ceiling, \"8321499136\", Greater);\n    test(\"8254390273\", 26, Nearest, \"8254390272\", Less);\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Down,\n        \"154653373227843986982597791055872\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Up,\n        \"155921023828072216384094494261248\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Floor,\n        \"154653373227843986982597791055872\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Ceiling,\n        \"155921023828072216384094494261248\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Nearest,\n        \"155921023828072216384094494261248\",\n        Greater,\n    );\n\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Down,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Up,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Floor,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Ceiling,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Nearest,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Exact,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Down,\n        \"155921023828072216384094494261248\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Up,\n        \"157188674428300445785591197466624\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Floor,\n        \"155921023828072216384094494261248\",\n        Less,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Ceiling,\n        \"157188674428300445785591197466624\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Nearest,\n        \"155921023828072216384094494261248\",\n        Less,\n    );\n\n    test(\"4294967295\", 1, Down, \"4294967294\", Less);\n    test(\"4294967295\", 1, Up, \"4294967296\", Greater);\n    test(\"4294967295\", 1, Floor, \"4294967294\", Less);\n    test(\"4294967295\", 1, Ceiling, \"4294967296\", Greater);\n    test(\"4294967295\", 1, Nearest, \"4294967296\", Greater);\n\n    test(\"4294967296\", 1, Down, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Up, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Floor, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Ceiling, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Nearest, \"4294967296\", Equal);\n    test(\"4294967296\", 1, Exact, \"4294967296\", Equal);\n\n    test(\"4294967297\", 1, Down, \"4294967296\", Less);\n    test(\"4294967297\", 1, Up, \"4294967298\", Greater);\n    test(\"4294967297\", 1, Floor, \"4294967296\", Less);\n    test(\"4294967297\", 1, Ceiling, \"4294967298\", Greater);\n    test(\"4294967297\", 1, Nearest, \"4294967296\", Less);\n\n    test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n    test(\"7999999999999\", 3, Down, \"7999999999992\", Less);\n    test(\"7999999999999\", 3, Up, \"8000000000000\", Greater);\n    test(\"7999999999999\", 3, Floor, \"7999999999992\", Less);\n    test(\"7999999999999\", 3, Ceiling, \"8000000000000\", Greater);\n    test(\"7999999999999\", 3, Nearest, \"8000000000000\", Greater);\n\n    test(\"8000000000000\", 3, Down, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Up, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Floor, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Ceiling, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Nearest, \"8000000000000\", Equal);\n    test(\"8000000000000\", 3, Exact, \"8000000000000\", Equal);\n\n    test(\"8000000000001\", 3, Down, \"8000000000000\", Less);\n    test(\"8000000000001\", 3, Up, \"8000000000008\", Greater);\n    test(\"8000000000001\", 3, Floor, \"8000000000000\", Less);\n    test(\"8000000000001\", 3, Ceiling, \"8000000000008\", Greater);\n    test(\"8000000000001\", 3, Nearest, \"8000000000000\", Less);\n\n    test(\n        \"16777216000000000000\",\n        24,\n        Down,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Up,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Floor,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Ceiling,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Nearest,\n        \"16777216000000000000\",\n        Equal,\n    );\n    test(\n        \"16777216000000000000\",\n        24,\n        Exact,\n        \"16777216000000000000\",\n        Equal,\n    );\n\n    test(\n        \"33554432000000000000\",\n        25,\n        Down,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Up,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Floor,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Ceiling,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Nearest,\n        \"33554432000000000000\",\n        Equal,\n    );\n    test(\n        \"33554432000000000000\",\n        25,\n        Exact,\n        \"33554432000000000000\",\n        Equal,\n    );\n\n    test(\n        \"2147483648000000000000\",\n        31,\n        Down,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Up,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Floor,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Ceiling,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Nearest,\n        \"2147483648000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Exact,\n        \"2147483648000000000000\",\n        Equal,\n    );\n\n    test(\n        \"4294967296000000000000\",\n        32,\n        Down,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Up,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Floor,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Ceiling,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Nearest,\n        \"4294967296000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Exact,\n        \"4294967296000000000000\",\n        Equal,\n    );\n\n    test(\n        \"8589934592000000000000\",\n        33,\n        Down,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Up,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Floor,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Ceiling,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Nearest,\n        \"8589934592000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Exact,\n        \"8589934592000000000000\",\n        Equal,\n    );\n\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Down,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Up,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Floor,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Ceiling,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Nearest,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Exact,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n\n    test(\"1000000000000\", 10, Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", 10, Exact, \"1000000000000\", Equal);\n\n    test(\"980657949\", 72, Down, \"0\", Less);\n    test(\"980657949\", 72, Up, \"4722366482869645213696\", Greater);\n    test(\"980657949\", 72, Floor, \"0\", Less);\n    test(\"980657949\", 72, Ceiling, \"4722366482869645213696\", Greater);\n    test(\"980657949\", 72, Nearest, \"0\", Less);\n\n    test(\"4294967295\", 31, Down, \"2147483648\", Less);\n    test(\"4294967295\", 31, Up, \"4294967296\", Greater);\n    test(\"4294967295\", 31, Floor, \"2147483648\", Less);\n    test(\"4294967295\", 31, Ceiling, \"4294967296\", Greater);\n    test(\"4294967295\", 31, Nearest, \"4294967296\", Greater);\n\n    test(\"4294967295\", 32, Down, \"0\", Less);\n    test(\"4294967295\", 32, Up, \"4294967296\", Greater);\n    test(\"4294967295\", 32, Floor, \"0\", Less);\n    test(\"4294967295\", 32, Ceiling, \"4294967296\", Greater);\n    test(\"4294967295\", 32, Nearest, \"4294967296\", Greater);\n\n    test(\"4294967296\", 32, Down, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Up, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Floor, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Ceiling, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Nearest, \"4294967296\", Equal);\n    test(\"4294967296\", 32, Exact, \"4294967296\", Equal);\n\n    test(\"4294967296\", 33, Down, \"0\", Less);\n    test(\"4294967296\", 33, Up, \"8589934592\", Greater);\n    test(\"4294967296\", 33, Floor, \"0\", Less);\n    test(\"4294967296\", 33, Ceiling, \"8589934592\", Greater);\n    test(\"4294967296\", 33, Nearest, \"0\", Less);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_1() {\n    Natural::from(123u32).round_to_multiple_of_power_of_2_assign(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_2() {\n    Natural::from(123u32).round_to_multiple_of_power_of_2_assign(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_3() {\n    Natural::from_str(\"1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2_assign(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_4() {\n    Natural::from_str(\"1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2_assign(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_1() {\n    Natural::from(123u32).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_2() {\n    Natural::from(123u32).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_3() {\n    Natural::from_str(\"1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_4() {\n    Natural::from_str(\"1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_1() {\n    (&Natural::from(123u32)).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_2() {\n    (&Natural::from(123u32)).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_3() {\n    (&Natural::from_str(\"1000000000001\").unwrap()).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_4() {\n    (&Natural::from_str(\"1000000000001\").unwrap()).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_down_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, pow)| {\n        let (r, o) = limbs_round_to_multiple_of_power_of_2_down(&xs, pow);\n        let x = Natural::from_owned_limbs_asc(xs);\n        let r = Natural::from_owned_limbs_asc(r);\n        assert_eq!(r, &x >> pow << pow);\n        assert_eq!(r.cmp(&x), o);\n    });\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_up_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(&config, |(xs, pow)| {\n        let (r, o) = limbs_round_to_multiple_of_power_of_2_up(&xs, pow);\n        let x = Natural::from_owned_limbs_asc(xs);\n        let r = Natural::from_owned_limbs_asc(r);\n        let (r_alt, o_alt) = (&x).round_to_multiple_of_power_of_2(pow, Up);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n        assert_eq!(r.cmp(&x), o);\n    });\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_nearest_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, pow)| {\n        let (r, o) = limbs_round_to_multiple_of_power_of_2_nearest(&xs, pow);\n        let r = Natural::from_owned_limbs_asc(r);\n        let x = Natural::from_owned_limbs_asc(xs);\n        let (r_alt, o_alt) = (&x).round_to_multiple_of_power_of_2(pow, Nearest);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n        assert_eq!(r.cmp(&x), o);\n    });\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().test_properties_with_config(\n        &config,\n        |(xs, pow, rm)| {\n            let n = Natural::from_limbs_asc(&xs);\n            limbs_round_to_multiple_of_power_of_2(&xs, pow, rm).map_or_else(\n                || {\n                    assert_eq!(rm, Exact);\n                    assert!(!n.divisible_by_power_of_2(pow));\n                },\n                |(result_limbs, o)| {\n                    let (m, o_alt) = (&n).round_to_multiple_of_power_of_2(pow, rm);\n                    assert_eq!(Natural::from_owned_limbs_asc(result_limbs), m);\n                    assert_eq!(o_alt, o);\n                    if rm == Exact {\n                        assert_eq!(m, n);\n                    }\n                },\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_down_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut xs, pow)| {\n            let old_xs = xs.clone();\n            limbs_round_to_multiple_of_power_of_2_down_in_place(&mut xs, pow);\n            let n = Natural::from_owned_limbs_asc(old_xs) >> pow << pow;\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_up_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(\n        &config,\n        |(mut xs, pow)| {\n            let old_xs = xs.clone();\n            let o = limbs_round_to_multiple_of_power_of_2_up_in_place(&mut xs, pow);\n            let (n, o_alt) =\n                Natural::from_owned_limbs_asc(old_xs).round_to_multiple_of_power_of_2(pow, Up);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(o_alt, o);\n        },\n    );\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_nearest_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut xs, pow)| {\n            let old_xs = xs.clone();\n            let o = limbs_round_to_multiple_of_power_of_2_nearest_in_place(&mut xs, pow);\n            let (n, o_alt) =\n                Natural::from_owned_limbs_asc(old_xs).round_to_multiple_of_power_of_2(pow, Nearest);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(o_alt, o);\n        },\n    );\n}\n\n#[test]\nfn limbs_round_to_multiple_of_power_of_2_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().test_properties_with_config(\n        &config,\n        |(mut xs, pow, rm)| {\n            let n = Natural::from_limbs_asc(&xs);\n            limbs_round_to_multiple_of_power_of_2_in_place(&mut xs, pow, rm).map_or_else(\n                || {\n                    assert_eq!(rm, Exact);\n                    assert!(!n.divisible_by_power_of_2(pow));\n                },\n                |o| {\n                    let (m, o_alt) = (&n).round_to_multiple_of_power_of_2(pow, rm);\n                    assert_eq!(Natural::from_owned_limbs_asc(xs), m);\n                    if rm == Exact {\n                        assert_eq!(m, n);\n                    }\n                    assert_eq!(o_alt, o);\n                },\n            );\n        },\n    );\n}\n\n#[test]\nfn round_to_multiple_of_power_of_2_properties() {\n    natural_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, pow, rm)| {\n        let (r, o) = (&n).round_to_multiple_of_power_of_2(pow, rm);\n        assert!(r.is_valid());\n\n        let (r_alt, o_alt) = n.clone().round_to_multiple_of_power_of_2(pow, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let mut mut_n = n.clone();\n        assert_eq!(mut_n.round_to_multiple_of_power_of_2_assign(pow, rm), o);\n        assert!(mut_n.is_valid());\n        assert_eq!(mut_n, r);\n\n        assert!(r.divisible_by_power_of_2(pow));\n        assert_eq!(r.cmp(&n), o);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n        let (s, o_alt) = (&n).shr_round(pow, rm);\n        assert_eq!(s << pow, r);\n        assert_eq!(o_alt, o);\n        assert!((Integer::from(&r) - Integer::from(&n)).abs() <= Natural::power_of_2(pow));\n        let (r_alt, o_alt) = (&n).round_to_multiple(Natural::power_of_2(pow), rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n        match rm {\n            Floor | Down => assert!(r <= n),\n            Ceiling | Up => assert!(r >= n),\n            Exact => assert_eq!(r, n),\n            Nearest => {\n                let k = Natural::power_of_2(pow);\n                let closest;\n                let second_closest;\n                if r <= n {\n                    closest = &n - &r;\n                    second_closest = &r + k - n;\n                } else {\n                    closest = &r - &n;\n                    second_closest = n + k - &r;\n                }\n                assert!(closest <= second_closest);\n                if closest == second_closest {\n                    assert!(!r.get_bit(pow));\n                }\n            }\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4::<u64>().test_properties(|(n, pow)| {\n        let shifted = n << pow;\n        let so = (shifted.clone(), Equal);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Down), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Up), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Floor), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Ceiling), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Nearest), so);\n        assert_eq!((&shifted).round_to_multiple_of_power_of_2(pow, Exact), so);\n    });\n\n    natural_unsigned_pair_gen_var_10().test_properties(|(n, pow)| {\n        let down = (&n).round_to_multiple_of_power_of_2(pow, Down);\n        assert_eq!(down.1, Less);\n        let up = (&down.0 + Natural::power_of_2(pow), Greater);\n        assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Up), up);\n        assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Floor), down);\n        assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Ceiling), up);\n        let nearest = n.round_to_multiple_of_power_of_2(pow, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    natural_unsigned_pair_gen_var_13::<u64>().test_properties(|(n, pow)| {\n        if let Some(shift) = pow.checked_add(n.significant_bits()) {\n            assert_eq!(\n                (&n).round_to_multiple_of_power_of_2(shift, Down),\n                (Natural::ZERO, Less)\n            );\n            assert_eq!(\n                (&n).round_to_multiple_of_power_of_2(shift, Floor),\n                (Natural::ZERO, Less)\n            );\n            if let Some(extra_shift) = shift.checked_add(1) {\n                assert_eq!(\n                    n.round_to_multiple_of_power_of_2(extra_shift, Nearest),\n                    (Natural::ZERO, Less)\n                );\n            }\n        }\n    });\n\n    natural_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).round_to_multiple_of_power_of_2(0, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen().test_properties(|(pow, rm)| {\n        assert_eq!(\n            Natural::ZERO.round_to_multiple_of_power_of_2(pow, rm),\n            (Natural::ZERO, Equal)\n        );\n    });\n\n    unsigned_unsigned_rounding_mode_triple_gen_var_3::<Limb>().test_properties(|(n, pow, rm)| {\n        let (r, o) = Natural::from(n).round_to_multiple_of_power_of_2(pow, rm);\n        let (r_alt, o_alt) = n.round_to_multiple_of_power_of_2(pow, rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/saturating_sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{SaturatingSub, SaturatingSubAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_saturating_sub_natural() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.saturating_sub_assign(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.saturating_sub_assign(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().saturating_sub(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().saturating_sub(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).saturating_sub(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).saturating_sub(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"123\");\n    test(\"456\", \"123\", \"333\");\n    test(\"1000000000000\", \"123\", \"999999999877\");\n    test(\"123\", \"1000000000000\", \"0\");\n    test(\"12345678987654321\", \"314159265358979\", \"12031519722295342\");\n    test(\"4294967296\", \"1\", \"4294967295\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"4294967296\", \"4294967295\", \"1\");\n    test(\"4294967296\", \"4294967296\", \"0\");\n    test(\"4294967295\", \"4294967296\", \"0\");\n    test(\"18446744073709551616\", \"1\", \"18446744073709551615\");\n    test(\"18446744073709551615\", \"18446744073709551615\", \"0\");\n    test(\"18446744073709551616\", \"18446744073709551615\", \"1\");\n    test(\"18446744073709551615\", \"18446744073709551616\", \"0\");\n    test(\"70734740290631708\", \"282942734368\", \"70734457347897340\");\n    test(\"282942734368\", \"70734740290631708\", \"0\");\n}\n\n#[test]\nfn saturating_sub_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.saturating_sub_assign(&y);\n        assert!(mut_x.is_valid());\n        let diff = mut_x;\n\n        let mut mut_x = x.clone();\n        mut_x.saturating_sub_assign(y.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n\n        let diff_alt = x.clone().saturating_sub(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = x.clone().saturating_sub(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).saturating_sub(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).saturating_sub(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let reverse_diff = (&y).saturating_sub(&x);\n        if diff > 0 {\n            assert_eq!(reverse_diff, 0);\n        }\n        if reverse_diff > 0 {\n            assert_eq!(diff, 0);\n        }\n\n        assert!(diff <= x);\n        assert!(diff + y >= x);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!((&x).saturating_sub(Natural::ZERO), x);\n        assert_eq!((&x).saturating_sub(&x), 0);\n        assert_eq!(Natural::ZERO.saturating_sub(x), 0);\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            x.saturating_sub(y),\n            Natural::from(x).saturating_sub(Natural::from(y))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/saturating_sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    SaturatingSub, SaturatingSubMul, SaturatingSubMulAssign,\n};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::unsigned_triple_gen_var_19;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_saturating_sub_mul() {\n    let test = |r, s, t, out: &str| {\n        let u = Natural::from_str(r).unwrap();\n        let v = Natural::from_str(s).unwrap();\n        let w = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.saturating_sub_mul_assign(v.clone(), w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u.clone();\n        n.saturating_sub_mul_assign(v.clone(), &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u.clone();\n        n.saturating_sub_mul_assign(&v, w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u.clone();\n        n.saturating_sub_mul_assign(&v, &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().saturating_sub_mul(v.clone(), w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().saturating_sub_mul(v.clone(), &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().saturating_sub_mul(&v, w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().saturating_sub_mul(&v, &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = (&u).saturating_sub_mul(&v, &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\", \"0\");\n    test(\"0\", \"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"5\", \"123\");\n    test(\"123\", \"5\", \"1\", \"118\");\n    test(\"123\", \"5\", \"100\", \"0\");\n    test(\"10\", \"3\", \"4\", \"0\");\n    test(\"15\", \"3\", \"4\", \"3\");\n    test(\"1000000000000\", \"0\", \"123\", \"1000000000000\");\n    test(\"1000000000000\", \"1\", \"123\", \"999999999877\");\n    test(\"1000000000000\", \"123\", \"1\", \"999999999877\");\n    test(\"1000000000000\", \"123\", \"100\", \"999999987700\");\n    test(\"1000000000000\", \"100\", \"123\", \"999999987700\");\n    test(\"1000000000000\", \"65536\", \"65536\", \"995705032704\");\n    test(\"1000000000000\", \"1000000000000\", \"0\", \"1000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"1\", \"0\");\n    test(\"1000000000000\", \"1000000000000\", \"100\", \"0\");\n    test(\"0\", \"1000000000000\", \"100\", \"0\");\n    test(\"4294967296\", \"1\", \"1\", \"4294967295\");\n    test(\"3902609153\", \"88817093856604\", \"1\", \"0\");\n}\n\n#[allow(clippy::useless_conversion)]\n#[test]\nfn saturating_sub_mul_properties() {\n    natural_triple_gen().test_properties(|(a, b, c)| {\n        let mut mut_a = a.clone();\n        mut_a.saturating_sub_mul_assign(&b, &c);\n        assert!(mut_a.is_valid());\n        let result = mut_a;\n\n        let mut mut_a = a.clone();\n        mut_a.saturating_sub_mul_assign(&b, c.clone());\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.saturating_sub_mul_assign(b.clone(), &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.saturating_sub_mul_assign(b.clone(), c.clone());\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let result_alt = (&a).saturating_sub_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().saturating_sub_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().saturating_sub_mul(&b, c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().saturating_sub_mul(b.clone(), &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().saturating_sub_mul(b.clone(), c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert_eq!((&a).saturating_sub(b * c), result);\n        assert!(result <= a);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).saturating_sub_mul(&n, &Natural::ONE), 0);\n    });\n\n    natural_pair_gen().test_properties(|(a, b)| {\n        assert_eq!(Natural::ZERO.saturating_sub_mul(&a, &b), 0);\n        assert_eq!((&a).saturating_sub_mul(&Natural::ZERO, &b), a);\n        assert_eq!((&a).saturating_sub_mul(&b, &Natural::ZERO), a);\n        assert_eq!((&a * &b).saturating_sub_mul(&a, &b), 0);\n        assert_eq!(\n            (&a).saturating_sub_mul(&Natural::ONE, &b),\n            (&a).saturating_sub(&b)\n        );\n        assert_eq!(\n            (&a).saturating_sub_mul(&b, &Natural::ONE),\n            a.saturating_sub(b)\n        );\n    });\n\n    unsigned_triple_gen_var_19::<Limb>().test_properties(|(x, y, z)| {\n        assert_eq!(\n            Limb::from(x).saturating_sub_mul(Limb::from(y), Limb::from(z)),\n            Natural::from(x).saturating_sub_mul(Natural::from(y), Natural::from(z))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, ShlRound};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_gen, unsigned_gen_var_5, unsigned_vec_unsigned_pair_gen_var_16,\n    unsigned_vec_unsigned_pair_gen_var_32, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::shl::{\n    limbs_shl, limbs_shl_to_out, limbs_shl_with_complement_to_out, limbs_slice_shl_in_place,\n    limbs_vec_shl_in_place,\n};\nuse malachite_nz::natural::logic::not::limbs_not_in_place;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_signed_pair_gen_var_2, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_unsigned_triple_gen_var_5,\n};\nuse num::BigUint;\nuse rug;\nuse std::ops::{Shl, ShlAssign, Shr};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shl_and_limbs_vec_shl_in_place() {\n    let test = |limbs: &[Limb], bits: u64, out: &[Limb]| {\n        assert_eq!(limbs_shl(limbs, bits), out);\n\n        let mut limbs = limbs.to_vec();\n        limbs_vec_shl_in_place(&mut limbs, bits);\n        assert_eq!(limbs, out);\n    };\n    test(&[], 0, &[]);\n    test(&[], 5, &[]);\n    test(&[], 100, &[0, 0, 0]);\n    test(&[6, 7], 2, &[24, 28]);\n    test(&[100, 101, 102], 10, &[102400, 103424, 104448]);\n    test(&[123, 456], 1, &[246, 912]);\n    test(&[123, 456], 31, &[0x80000000, 61, 228]);\n    test(&[123, 456], 32, &[0, 123, 456]);\n    test(&[123, 456], 100, &[0, 0, 0, 1968, 7296]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shl_to_out() {\n    let test =\n        |out_before: &[Limb], limbs_in: &[Limb], bits: u64, carry: Limb, out_after: &[Limb]| {\n            let mut out = out_before.to_vec();\n            assert_eq!(limbs_shl_to_out(&mut out, limbs_in, bits), carry);\n            assert_eq!(out, out_after);\n        };\n    test(&[10, 10, 10, 10], &[], 5, 0, &[10, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, 0, &[24, 28, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        0,\n        &[102400, 103424, 104448, 10],\n    );\n    test(&[10, 10, 10, 10], &[123, 456], 1, 0, &[246, 912, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        31,\n        228,\n        &[0x80000000, 61, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shl_to_out_fail_1() {\n    limbs_shl_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shl_to_out_fail_2() {\n    limbs_shl_to_out(&mut [10, 10, 10], &[123, 456], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shl_to_out_fail_3() {\n    limbs_shl_to_out(&mut [10, 10, 10], &[123, 456], 100);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_shl_in_place() {\n    let test = |limbs: &[Limb], bits: u64, carry: Limb, out: &[Limb]| {\n        let mut limbs = limbs.to_vec();\n        assert_eq!(limbs_slice_shl_in_place(&mut limbs, bits), carry);\n        assert_eq!(limbs, out);\n    };\n    test(&[], 5, 0, &[]);\n    test(&[6, 7], 2, 0, &[24, 28]);\n    test(&[100, 101, 102], 10, 0, &[102400, 103424, 104448]);\n    test(&[123, 456], 1, 0, &[246, 912]);\n    test(&[123, 456], 31, 228, &[0x80000000, 61]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_shl_in_place_fail_1() {\n    limbs_slice_shl_in_place(&mut [123, 456], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_shl_in_place_fail_2() {\n    limbs_slice_shl_in_place(&mut [123, 456], 100);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shl_with_complement_to_out() {\n    let test =\n        |out_before: &[Limb], limbs_in: &[Limb], bits: u64, carry: Limb, out_after: &[Limb]| {\n            let mut out = out_before.to_vec();\n            assert_eq!(\n                limbs_shl_with_complement_to_out(&mut out, limbs_in, bits),\n                carry\n            );\n            assert_eq!(out, out_after);\n        };\n    test(\n        &[10, 10, 10, 10],\n        &[6, 7],\n        2,\n        0,\n        &[4294967271, 4294967267, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        0,\n        &[4294864895, 4294863871, 4294862847, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        1,\n        0,\n        &[4294967049, 4294966383, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        31,\n        228,\n        &[0x7fffffff, 4294967234, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shl_with_complement_to_out_fail_1() {\n    limbs_shl_with_complement_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shl_with_complement_to_out_fail_2() {\n    limbs_shl_with_complement_to_out(&mut [10, 10, 10], &[123, 456], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shl_with_complement_to_out_fail_3() {\n    limbs_shl_with_complement_to_out(&mut [10, 10, 10], &[123, 456], 100);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shl_with_complement_to_out_fail_4() {\n    limbs_shl_with_complement_to_out(&mut [10, 10, 10], &[], 100);\n}\n\nfn test_shl_unsigned_helper<T: PrimitiveUnsigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Natural: Shl<T, Output = Natural> + ShlAssign<T>,\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    let test = |s, v: u8, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"123\", 0, \"123\");\n    test(\"123\", 1, \"246\");\n    test(\"123\", 2, \"492\");\n    test(\"123\", 25, \"4127195136\");\n    test(\"123\", 26, \"8254390272\");\n    test(\"123\", 100, \"155921023828072216384094494261248\");\n    test(\"2147483648\", 1, \"4294967296\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"1000000000000\", 3, \"8000000000000\");\n    test(\"1000000000000\", 24, \"16777216000000000000\");\n    test(\"1000000000000\", 25, \"33554432000000000000\");\n    test(\"1000000000000\", 31, \"2147483648000000000000\");\n    test(\"1000000000000\", 32, \"4294967296000000000000\");\n    test(\"1000000000000\", 33, \"8589934592000000000000\");\n    test(\n        \"1000000000000\",\n        100,\n        \"1267650600228229401496703205376000000000000\",\n    );\n}\n\n#[test]\nfn test_shl_unsigned() {\n    test_shl_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u32, _>(|u, v, out| {\n        let rug_u = rug::Integer::from_str(u).unwrap();\n        let mut n = rug_u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug_u << v;\n        assert_eq!(n.to_string(), out);\n\n        let num_u = BigUint::from_str(u).unwrap();\n        let n = num_u.clone() << usize::exact_from(v);\n        assert_eq!(n.to_string(), out);\n\n        let n = &num_u << usize::exact_from(v);\n        assert_eq!(n.to_string(), out);\n    });\n    test_shl_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shl_signed_helper<T: PrimitiveSigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Natural: Shl<T, Output = Natural> + ShlAssign<T>,\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    let test = |s, v: i8, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"123\", 0, \"123\");\n    test(\"123\", 1, \"246\");\n    test(\"123\", 2, \"492\");\n    test(\"123\", 25, \"4127195136\");\n    test(\"123\", 26, \"8254390272\");\n    test(\"123\", 100, \"155921023828072216384094494261248\");\n    test(\"2147483648\", 1, \"4294967296\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"1000000000000\", 3, \"8000000000000\");\n    test(\"1000000000000\", 24, \"16777216000000000000\");\n    test(\"1000000000000\", 25, \"33554432000000000000\");\n    test(\"1000000000000\", 31, \"2147483648000000000000\");\n    test(\"1000000000000\", 32, \"4294967296000000000000\");\n    test(\"1000000000000\", 33, \"8589934592000000000000\");\n    test(\n        \"1000000000000\",\n        100,\n        \"1267650600228229401496703205376000000000000\",\n    );\n\n    test(\"0\", -10, \"0\");\n    test(\"123\", 0, \"123\");\n    test(\"245\", -1, \"122\");\n    test(\"246\", -1, \"123\");\n    test(\"247\", -1, \"123\");\n    test(\"491\", -2, \"122\");\n    test(\"492\", -2, \"123\");\n    test(\"493\", -2, \"123\");\n    test(\"4127195135\", -25, \"122\");\n    test(\"4127195136\", -25, \"123\");\n    test(\"4127195137\", -25, \"123\");\n    test(\"8254390271\", -26, \"122\");\n    test(\"8254390272\", -26, \"123\");\n    test(\"8254390273\", -26, \"123\");\n    test(\"155921023828072216384094494261247\", -100, \"122\");\n    test(\"155921023828072216384094494261248\", -100, \"123\");\n    test(\"155921023828072216384094494261249\", -100, \"123\");\n    test(\"4294967295\", -1, \"2147483647\");\n    test(\"4294967296\", -1, \"2147483648\");\n    test(\"4294967297\", -1, \"2147483648\");\n    test(\"7999999999999\", -3, \"999999999999\");\n    test(\"8000000000000\", -3, \"1000000000000\");\n    test(\"8000000000001\", -3, \"1000000000000\");\n    test(\"16777216000000000000\", -24, \"1000000000000\");\n    test(\"33554432000000000000\", -25, \"1000000000000\");\n    test(\"2147483648000000000000\", -31, \"1000000000000\");\n    test(\"4294967296000000000000\", -32, \"1000000000000\");\n    test(\"8589934592000000000000\", -33, \"1000000000000\");\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        -100,\n        \"1000000000000\",\n    );\n    test(\"1000000000000\", -10, \"976562500\");\n    test(\"980657949\", -72, \"0\");\n    test(\"4294967295\", -31, \"1\");\n    test(\"4294967295\", -32, \"0\");\n    test(\"4294967296\", -32, \"1\");\n    test(\"4294967296\", -33, \"0\");\n}\n\n#[test]\nfn test_shl_signed() {\n    test_shl_signed_helper::<i8, _>(|_, _, _| {});\n    test_shl_signed_helper::<i16, _>(|_, _, _| {});\n    test_shl_signed_helper::<i32, _>(|u, v, out| {\n        let rug_u = rug::Integer::from_str(u).unwrap();\n        let mut n = rug_u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug_u << v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shl_signed_helper::<i64, _>(|_, _, _| {});\n    test_shl_signed_helper::<i128, _>(|_, _, _| {});\n    test_shl_signed_helper::<isize, _>(|_, _, _| {});\n}\n\n#[test]\nfn limbs_shl_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, bits)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_shl(&xs, bits)),\n            Natural::from_owned_limbs_asc(xs) << bits\n        );\n    });\n}\n\n#[test]\nfn limbs_shl_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_22::<Limb, Limb>()\n        .test_properties_with_config(&config, |(mut out, xs, bits)| {\n            let old_out = out.clone();\n            let carry = limbs_shl_to_out(&mut out, &xs, bits);\n            let len = xs.len();\n            let n = Natural::from_owned_limbs_asc(xs) << bits;\n            let mut xs = n.into_limbs_asc();\n            assert_eq!(carry != 0, xs.len() == len + 1);\n            let mut actual_xs = out[..len].to_vec();\n            if carry != 0 {\n                actual_xs.push(carry);\n            }\n            xs.resize(actual_xs.len(), 0);\n            assert_eq!(xs, actual_xs);\n            assert_eq!(&out[len..], &old_out[len..]);\n        });\n}\n\n#[test]\nfn limbs_slice_shl_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_32::<Limb, Limb>().test_properties_with_config(\n        &config,\n        |(mut xs, bits)| {\n            let old_xs = xs.clone();\n            let carry = limbs_slice_shl_in_place(&mut xs, bits);\n            let n = Natural::from_owned_limbs_asc(old_xs) << bits;\n            let mut expected_xs = n.into_limbs_asc();\n            assert_eq!(carry != 0, expected_xs.len() == xs.len() + 1);\n            if carry != 0 {\n                xs.push(carry);\n            }\n            expected_xs.resize(xs.len(), 0);\n            assert_eq!(xs, expected_xs);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_shl_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16::<Limb, u64>().test_properties_with_config(\n        &config,\n        |(mut xs, bits)| {\n            let old_xs = xs.clone();\n            limbs_vec_shl_in_place(&mut xs, bits);\n            let n = Natural::from_owned_limbs_asc(old_xs) << bits;\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn limbs_shl_with_complement_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<Limb, Limb>()\n        .test_properties_with_config(&config, |(mut out, xs, bits)| {\n            let old_out = out.clone();\n            let len = xs.len();\n            let carry = limbs_shl_with_complement_to_out(&mut out, &xs, bits);\n            limbs_not_in_place(&mut out[..len]);\n            let n = Natural::from_owned_limbs_asc(xs) << bits;\n            let mut xs = n.into_limbs_asc();\n            assert_eq!(carry != 0, xs.len() == len + 1);\n            let mut actual_xs = out[..len].to_vec();\n            if carry != 0 {\n                actual_xs.push(carry);\n            }\n            xs.resize(actual_xs.len(), 0);\n            assert_eq!(xs, actual_xs);\n            assert_eq!(&out[len..], &old_out[len..]);\n        });\n}\n\nfn unsigned_properties<U: PrimitiveUnsigned, S: PrimitiveSigned + WrappingFrom<U>>()\nwhere\n    Natural: Shl<U, Output = Natural> + ShlAssign<U> + Shr<S, Output = Natural>,\n    for<'a> &'a Natural:\n        Shl<U, Output = Natural> + Shl<S, Output = Natural> + Shr<U, Output = Natural>,\n{\n    natural_unsigned_pair_gen_var_4::<U>().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n <<= u;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n << u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        let shifted_alt = n.clone() << u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert!(shifted >= n);\n        assert_eq!(shifted, &n * (Natural::ONE << u));\n        assert_eq!(&shifted >> u, n);\n\n        if u <= U::low_mask(U::WIDTH - 1) {\n            let u = S::wrapping_from(u);\n            assert_eq!(&n << u, shifted);\n            assert_eq!(n >> -u, shifted);\n        }\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_5::<U>().test_properties(|(n, u, v)| {\n        if let Some(sum) = u.checked_add(v) {\n            assert_eq!(&n << u << v, n << sum);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(&n << U::ZERO, n);\n        assert_eq!(&n << U::ONE, n * Natural::from(2u32));\n    });\n\n    unsigned_gen_var_5::<U>().test_properties(|u| {\n        assert_eq!(Natural::ZERO << u, 0);\n        assert!((Natural::ONE << u).is_power_of_2());\n    });\n}\n\nfn signed_properties<T: PrimitiveSigned>()\nwhere\n    Natural: Shl<T, Output = Natural> + ShlAssign<T> + ShlRound<T, Output = Natural>,\n    for<'a> &'a Natural: Shl<T, Output = Natural>,\n{\n    natural_signed_pair_gen_var_2::<T>().test_properties(|(n, i)| {\n        let mut mut_n = n.clone();\n        mut_n <<= i;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n << i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        let shifted_alt = n.clone() << i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!(n.shl_round(i, Floor).0, shifted);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(&n << T::ZERO, n);\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert_eq!(Natural::ZERO << i, 0);\n    });\n}\n\n#[test]\nfn shl_properties() {\n    apply_fn_to_unsigned_signed_pairs!(unsigned_properties);\n    apply_fn_to_signeds!(signed_properties);\n\n    natural_unsigned_pair_gen_var_4::<u32>().test_properties(|(n, u)| {\n        let shifted = &n << u;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n <<= u;\n        assert_eq!(Natural::exact_from(&rug_n), shifted);\n\n        assert_eq!(\n            Natural::from(&(&BigUint::from(&n) << usize::exact_from(u))),\n            shifted\n        );\n        assert_eq!(\n            Natural::from(&(BigUint::from(&n) << usize::exact_from(u))),\n            shifted\n        );\n        assert_eq!(Natural::exact_from(&(rug::Integer::from(&n) << u)), shifted);\n    });\n\n    natural_signed_pair_gen_var_2::<i32>().test_properties(|(n, i)| {\n        let shifted = &n << i;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n <<= i;\n        assert_eq!(Natural::exact_from(&rug_n), shifted);\n\n        assert_eq!(Natural::exact_from(&(rug::Integer::from(&n) << i)), shifted);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/shl_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ArithmeticCheckedShl, ShlRound, ShlRoundAssign};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, unsigned_signed_rounding_mode_triple_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_rounding_mode_pair_gen, natural_signed_rounding_mode_triple_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::ops::Shr;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nmacro_rules! test_shl_round_signed_helper {\n    ($t:ident) => {\n        let test = |s, j: $t, rm: RoundingMode, out, o| {\n            let u = Natural::from_str(s).unwrap();\n\n            let mut n = u.clone();\n            assert_eq!(n.shl_round_assign(j, rm), o);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n\n            let (n, o_alt) = u.clone().shl_round(j, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n\n            let (n, o_alt) = (&u).shl_round(j, rm);\n            assert_eq!(n.to_string(), out);\n            assert!(n.is_valid());\n            assert_eq!(o_alt, o);\n        };\n        test(\"0\", 0, Down, \"0\", Equal);\n        test(\"0\", 0, Up, \"0\", Equal);\n        test(\"0\", 0, Floor, \"0\", Equal);\n        test(\"0\", 0, Ceiling, \"0\", Equal);\n        test(\"0\", 0, Nearest, \"0\", Equal);\n        test(\"0\", 0, Exact, \"0\", Equal);\n\n        test(\"0\", -10, Down, \"0\", Equal);\n        test(\"0\", -10, Up, \"0\", Equal);\n        test(\"0\", -10, Floor, \"0\", Equal);\n        test(\"0\", -10, Ceiling, \"0\", Equal);\n        test(\"0\", -10, Nearest, \"0\", Equal);\n        test(\"0\", -10, Exact, \"0\", Equal);\n\n        test(\"123\", 0, Down, \"123\", Equal);\n        test(\"123\", 0, Up, \"123\", Equal);\n        test(\"123\", 0, Floor, \"123\", Equal);\n        test(\"123\", 0, Ceiling, \"123\", Equal);\n        test(\"123\", 0, Nearest, \"123\", Equal);\n        test(\"123\", 0, Exact, \"123\", Equal);\n\n        test(\"245\", -1, Down, \"122\", Less);\n        test(\"245\", -1, Up, \"123\", Greater);\n        test(\"245\", -1, Floor, \"122\", Less);\n        test(\"245\", -1, Ceiling, \"123\", Greater);\n        test(\"245\", -1, Nearest, \"122\", Less);\n\n        test(\"246\", -1, Down, \"123\", Equal);\n        test(\"246\", -1, Up, \"123\", Equal);\n        test(\"246\", -1, Floor, \"123\", Equal);\n        test(\"246\", -1, Ceiling, \"123\", Equal);\n        test(\"246\", -1, Nearest, \"123\", Equal);\n        test(\"246\", -1, Exact, \"123\", Equal);\n\n        test(\"247\", -1, Down, \"123\", Less);\n        test(\"247\", -1, Up, \"124\", Greater);\n        test(\"247\", -1, Floor, \"123\", Less);\n        test(\"247\", -1, Ceiling, \"124\", Greater);\n        test(\"247\", -1, Nearest, \"124\", Greater);\n\n        test(\"491\", -2, Down, \"122\", Less);\n        test(\"491\", -2, Up, \"123\", Greater);\n        test(\"491\", -2, Floor, \"122\", Less);\n        test(\"491\", -2, Ceiling, \"123\", Greater);\n        test(\"491\", -2, Nearest, \"123\", Greater);\n\n        test(\"492\", -2, Down, \"123\", Equal);\n        test(\"492\", -2, Up, \"123\", Equal);\n        test(\"492\", -2, Floor, \"123\", Equal);\n        test(\"492\", -2, Ceiling, \"123\", Equal);\n        test(\"492\", -2, Nearest, \"123\", Equal);\n        test(\"492\", -2, Exact, \"123\", Equal);\n\n        test(\"493\", -2, Down, \"123\", Less);\n        test(\"493\", -2, Up, \"124\", Greater);\n        test(\"493\", -2, Floor, \"123\", Less);\n        test(\"493\", -2, Ceiling, \"124\", Greater);\n        test(\"493\", -2, Nearest, \"123\", Less);\n\n        test(\"4127195135\", -25, Down, \"122\", Less);\n        test(\"4127195135\", -25, Up, \"123\", Greater);\n        test(\"4127195135\", -25, Floor, \"122\", Less);\n        test(\"4127195135\", -25, Ceiling, \"123\", Greater);\n        test(\"4127195135\", -25, Nearest, \"123\", Greater);\n\n        test(\"4127195136\", -25, Down, \"123\", Equal);\n        test(\"4127195136\", -25, Up, \"123\", Equal);\n        test(\"4127195136\", -25, Floor, \"123\", Equal);\n        test(\"4127195136\", -25, Ceiling, \"123\", Equal);\n        test(\"4127195136\", -25, Nearest, \"123\", Equal);\n        test(\"4127195136\", -25, Exact, \"123\", Equal);\n\n        test(\"4127195137\", -25, Down, \"123\", Less);\n        test(\"4127195137\", -25, Up, \"124\", Greater);\n        test(\"4127195137\", -25, Floor, \"123\", Less);\n        test(\"4127195137\", -25, Ceiling, \"124\", Greater);\n        test(\"4127195137\", -25, Nearest, \"123\", Less);\n\n        test(\"8254390271\", -26, Down, \"122\", Less);\n        test(\"8254390271\", -26, Up, \"123\", Greater);\n        test(\"8254390271\", -26, Floor, \"122\", Less);\n        test(\"8254390271\", -26, Ceiling, \"123\", Greater);\n        test(\"8254390271\", -26, Nearest, \"123\", Greater);\n\n        test(\"8254390272\", -26, Down, \"123\", Equal);\n        test(\"8254390272\", -26, Up, \"123\", Equal);\n        test(\"8254390272\", -26, Floor, \"123\", Equal);\n        test(\"8254390272\", -26, Ceiling, \"123\", Equal);\n        test(\"8254390272\", -26, Nearest, \"123\", Equal);\n        test(\"8254390272\", -26, Exact, \"123\", Equal);\n\n        test(\"8254390273\", -26, Down, \"123\", Less);\n        test(\"8254390273\", -26, Up, \"124\", Greater);\n        test(\"8254390273\", -26, Floor, \"123\", Less);\n        test(\"8254390273\", -26, Ceiling, \"124\", Greater);\n        test(\"8254390273\", -26, Nearest, \"123\", Less);\n\n        test(\"155921023828072216384094494261247\", -100, Down, \"122\", Less);\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Up,\n            \"123\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Floor,\n            \"122\",\n            Less,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Ceiling,\n            \"123\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261247\",\n            -100,\n            Nearest,\n            \"123\",\n            Greater,\n        );\n\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Down,\n            \"123\",\n            Equal,\n        );\n        test(\"155921023828072216384094494261248\", -100, Up, \"123\", Equal);\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Floor,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Ceiling,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Nearest,\n            \"123\",\n            Equal,\n        );\n        test(\n            \"155921023828072216384094494261248\",\n            -100,\n            Exact,\n            \"123\",\n            Equal,\n        );\n\n        test(\"155921023828072216384094494261249\", -100, Down, \"123\", Less);\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Up,\n            \"124\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Floor,\n            \"123\",\n            Less,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Ceiling,\n            \"124\",\n            Greater,\n        );\n        test(\n            \"155921023828072216384094494261249\",\n            -100,\n            Nearest,\n            \"123\",\n            Less,\n        );\n\n        test(\"4294967295\", -1, Down, \"2147483647\", Less);\n        test(\"4294967295\", -1, Up, \"2147483648\", Greater);\n        test(\"4294967295\", -1, Floor, \"2147483647\", Less);\n        test(\"4294967295\", -1, Ceiling, \"2147483648\", Greater);\n        test(\"4294967295\", -1, Nearest, \"2147483648\", Greater);\n\n        test(\"4294967296\", -1, Down, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Up, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Floor, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Ceiling, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Nearest, \"2147483648\", Equal);\n        test(\"4294967296\", -1, Exact, \"2147483648\", Equal);\n\n        test(\"4294967297\", -1, Down, \"2147483648\", Less);\n        test(\"4294967297\", -1, Up, \"2147483649\", Greater);\n        test(\"4294967297\", -1, Floor, \"2147483648\", Less);\n        test(\"4294967297\", -1, Ceiling, \"2147483649\", Greater);\n        test(\"4294967297\", -1, Nearest, \"2147483648\", Less);\n\n        test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n        test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n        test(\"7999999999999\", -3, Down, \"999999999999\", Less);\n        test(\"7999999999999\", -3, Up, \"1000000000000\", Greater);\n        test(\"7999999999999\", -3, Floor, \"999999999999\", Less);\n        test(\"7999999999999\", -3, Ceiling, \"1000000000000\", Greater);\n        test(\"7999999999999\", -3, Nearest, \"1000000000000\", Greater);\n\n        test(\"8000000000000\", -3, Down, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Up, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Floor, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Ceiling, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Nearest, \"1000000000000\", Equal);\n        test(\"8000000000000\", -3, Exact, \"1000000000000\", Equal);\n\n        test(\"8000000000001\", -3, Down, \"1000000000000\", Less);\n        test(\"8000000000001\", -3, Up, \"1000000000001\", Greater);\n        test(\"8000000000001\", -3, Floor, \"1000000000000\", Less);\n        test(\"8000000000001\", -3, Ceiling, \"1000000000001\", Greater);\n        test(\"8000000000001\", -3, Nearest, \"1000000000000\", Less);\n\n        test(\"16777216000000000000\", -24, Down, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Up, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Floor, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Ceiling, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Nearest, \"1000000000000\", Equal);\n        test(\"16777216000000000000\", -24, Exact, \"1000000000000\", Equal);\n\n        test(\"33554432000000000000\", -25, Down, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Up, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Floor, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Ceiling, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Nearest, \"1000000000000\", Equal);\n        test(\"33554432000000000000\", -25, Exact, \"1000000000000\", Equal);\n\n        test(\"2147483648000000000000\", -31, Down, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", -31, Up, \"1000000000000\", Equal);\n        test(\"2147483648000000000000\", -31, Floor, \"1000000000000\", Equal);\n        test(\n            \"2147483648000000000000\",\n            -31,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"2147483648000000000000\",\n            -31,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"2147483648000000000000\", -31, Exact, \"1000000000000\", Equal);\n\n        test(\"4294967296000000000000\", -32, Down, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", -32, Up, \"1000000000000\", Equal);\n        test(\"4294967296000000000000\", -32, Floor, \"1000000000000\", Equal);\n        test(\n            \"4294967296000000000000\",\n            -32,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"4294967296000000000000\",\n            -32,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"4294967296000000000000\", -32, Exact, \"1000000000000\", Equal);\n\n        test(\"8589934592000000000000\", -33, Down, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", -33, Up, \"1000000000000\", Equal);\n        test(\"8589934592000000000000\", -33, Floor, \"1000000000000\", Equal);\n        test(\n            \"8589934592000000000000\",\n            -33,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"8589934592000000000000\",\n            -33,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\"8589934592000000000000\", -33, Exact, \"1000000000000\", Equal);\n\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Down,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Up,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Floor,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Ceiling,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Nearest,\n            \"1000000000000\",\n            Equal,\n        );\n        test(\n            \"1267650600228229401496703205376000000000000\",\n            -100,\n            Exact,\n            \"1000000000000\",\n            Equal,\n        );\n\n        test(\"1000000000000\", -10, Down, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Up, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Floor, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Ceiling, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Nearest, \"976562500\", Equal);\n        test(\"1000000000000\", -10, Exact, \"976562500\", Equal);\n\n        test(\"980657949\", -72, Down, \"0\", Less);\n        test(\"980657949\", -72, Up, \"1\", Greater);\n        test(\"980657949\", -72, Floor, \"0\", Less);\n        test(\"980657949\", -72, Ceiling, \"1\", Greater);\n        test(\"980657949\", -72, Nearest, \"0\", Less);\n\n        test(\"4294967295\", -31, Down, \"1\", Less);\n        test(\"4294967295\", -31, Up, \"2\", Greater);\n        test(\"4294967295\", -31, Floor, \"1\", Less);\n        test(\"4294967295\", -31, Ceiling, \"2\", Greater);\n        test(\"4294967295\", -31, Nearest, \"2\", Greater);\n\n        test(\"4294967295\", -32, Down, \"0\", Less);\n        test(\"4294967295\", -32, Up, \"1\", Greater);\n        test(\"4294967295\", -32, Floor, \"0\", Less);\n        test(\"4294967295\", -32, Ceiling, \"1\", Greater);\n        test(\"4294967295\", -32, Nearest, \"1\", Greater);\n\n        test(\"4294967296\", -32, Down, \"1\", Equal);\n        test(\"4294967296\", -32, Up, \"1\", Equal);\n        test(\"4294967296\", -32, Floor, \"1\", Equal);\n        test(\"4294967296\", -32, Ceiling, \"1\", Equal);\n        test(\"4294967296\", -32, Nearest, \"1\", Equal);\n        test(\"4294967296\", -32, Exact, \"1\", Equal);\n\n        test(\"4294967296\", -33, Down, \"0\", Less);\n        test(\"4294967296\", -33, Up, \"1\", Greater);\n        test(\"4294967296\", -33, Floor, \"0\", Less);\n        test(\"4294967296\", -33, Ceiling, \"1\", Greater);\n        test(\"4294967296\", -33, Nearest, \"0\", Less);\n\n        test(\"0\", 10, Exact, \"0\", Equal);\n        test(\"123\", 1, Exact, \"246\", Equal);\n        test(\"123\", 2, Exact, \"492\", Equal);\n        test(\"123\", 25, Exact, \"4127195136\", Equal);\n        test(\"123\", 26, Exact, \"8254390272\", Equal);\n        test(\n            \"123\",\n            100,\n            Exact,\n            \"155921023828072216384094494261248\",\n            Equal,\n        );\n        test(\"2147483648\", 1, Exact, \"4294967296\", Equal);\n        test(\"1000000000000\", 3, Exact, \"8000000000000\", Equal);\n        test(\"1000000000000\", 24, Exact, \"16777216000000000000\", Equal);\n        test(\"1000000000000\", 25, Exact, \"33554432000000000000\", Equal);\n        test(\"1000000000000\", 31, Exact, \"2147483648000000000000\", Equal);\n        test(\"1000000000000\", 32, Exact, \"4294967296000000000000\", Equal);\n        test(\"1000000000000\", 33, Exact, \"8589934592000000000000\", Equal);\n        test(\n            \"1000000000000\",\n            100,\n            Exact,\n            \"1267650600228229401496703205376000000000000\",\n            Equal,\n        );\n    };\n}\n\n#[test]\nfn test_shl_round_signed() {\n    apply_to_signeds!(test_shl_round_signed_helper);\n}\n\nmacro_rules! shl_round_signed_fail_helper {\n    ($t:ident) => {\n        assert_panic!(Natural::from(123u32).shl_round_assign($t::NEGATIVE_ONE, Exact));\n        assert_panic!(Natural::from(123u32).shl_round_assign($t::exact_from(-100), Exact));\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shl_round_assign($t::NEGATIVE_ONE, Exact)\n        );\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shl_round_assign($t::exact_from(-100), Exact)\n        );\n        assert_panic!(Natural::from(123u32).shl_round($t::NEGATIVE_ONE, Exact));\n        assert_panic!(Natural::from(123u32).shl_round($t::exact_from(-100), Exact));\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shl_round($t::NEGATIVE_ONE, Exact)\n        );\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shl_round($t::exact_from(-100), Exact)\n        );\n        assert_panic!((&Natural::from(123u32)).shl_round($t::NEGATIVE_ONE, Exact));\n        assert_panic!((&Natural::from(123u32)).shl_round($t::exact_from(-100), Exact));\n        assert_panic!(\n            (&Natural::from_str(\"1000000000001\").unwrap()).shl_round($t::NEGATIVE_ONE, Exact)\n        );\n        assert_panic!(\n            (&Natural::from_str(\"1000000000001\").unwrap()).shl_round($t::exact_from(-100), Exact)\n        );\n    };\n}\n\n#[test]\nfn shl_round_signed_fail() {\n    apply_to_signeds!(shl_round_signed_fail_helper);\n}\n\nfn properties_helper<T: PrimitiveSigned>()\nwhere\n    Natural: Shr<T, Output = Natural> + ShlRound<T, Output = Natural> + ShlRoundAssign<T>,\n    for<'a> &'a Natural: ShlRound<T, Output = Natural>,\n    Limb: ArithmeticCheckedShl<T, Output = Limb> + ShlRound<T, Output = Limb>,\n{\n    natural_signed_rounding_mode_triple_gen_var_1::<T>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n.clone();\n        let o = mut_n.shl_round_assign(i, rm);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let (shifted_alt, o_alt) = (&n).shl_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        let (shifted_alt, o_alt) = n.clone().shl_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        if i < T::ZERO {\n            assert_eq!((shifted >> i).cmp(&n), o);\n        }\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    natural_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).shl_round(T::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(i, rm)| {\n        assert_eq!(Natural::ZERO.shl_round(i, rm), (Natural::ZERO, Equal));\n    });\n\n    unsigned_signed_rounding_mode_triple_gen_var_2::<Limb, T>().test_properties(|(n, i, rm)| {\n        if n.arithmetic_checked_shl(i).is_some() {\n            let (s, o) = n.shl_round(i, rm);\n            assert_eq!((Natural::from(s), o), Natural::from(n).shl_round(i, rm));\n        }\n    });\n}\n\n#[test]\nfn shl_round_properties() {\n    apply_fn_to_signeds!(properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ShrRound;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_gen, unsigned_gen, unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_16,\n    unsigned_vec_unsigned_pair_gen_var_33, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::shr::{\n    limbs_shr, limbs_shr_to_out, limbs_slice_shr_in_place, limbs_vec_shr_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_signed_pair_gen_var_2, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_unsigned_triple_gen_var_5,\n};\nuse num::BigUint;\nuse rug;\nuse std::ops::{Shl, Shr, ShrAssign};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shr_and_limbs_vec_shr_in_place() {\n    let test = |limbs: &[Limb], bits: u64, out: &[Limb]| {\n        assert_eq!(limbs_shr(limbs, bits), out);\n\n        let mut limbs = limbs.to_vec();\n        limbs_vec_shr_in_place(&mut limbs, bits);\n        assert_eq!(limbs, out);\n    };\n    test(&[], 0, &[]);\n    test(&[], 1, &[]);\n    test(&[], 100, &[]);\n    test(&[0, 0, 0], 0, &[0, 0, 0]);\n    test(&[0, 0, 0], 1, &[0, 0, 0]);\n    test(&[0, 0, 0], 100, &[]);\n    test(&[1], 0, &[1]);\n    test(&[1], 1, &[0]);\n    test(&[3], 1, &[1]);\n    test(&[122, 456], 1, &[61, 228]);\n    test(&[123, 456], 0, &[123, 456]);\n    test(&[123, 456], 1, &[61, 228]);\n    test(&[123, 455], 1, &[2147483709, 227]);\n    test(&[123, 456], 31, &[912, 0]);\n    test(&[123, 456], 32, &[456]);\n    test(&[123, 456], 100, &[]);\n    test(&[256, 456], 8, &[3355443201, 1]);\n    test(&[u32::MAX, 1], 1, &[u32::MAX, 0]);\n    test(&[u32::MAX, u32::MAX], 32, &[u32::MAX]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shr_to_out() {\n    let test =\n        |out_before: &[Limb], limbs_in: &[Limb], bits: u64, carry: Limb, out_after: &[Limb]| {\n            let mut out = out_before.to_vec();\n            assert_eq!(limbs_shr_to_out(&mut out, limbs_in, bits), carry);\n            assert_eq!(out, out_after);\n        };\n    test(&[10, 10, 10, 10], &[0, 0, 0], 1, 0, &[0, 0, 0, 10]);\n    test(&[10, 10, 10, 10], &[1], 1, 0x80000000, &[0, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[3], 1, 0x80000000, &[1, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[122, 456], 1, 0, &[61, 228, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        1,\n        0x80000000,\n        &[61, 228, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 455],\n        1,\n        0x80000000,\n        &[2147483709, 227, 10, 10],\n    );\n    test(&[10, 10, 10, 10], &[123, 456], 31, 246, &[912, 0, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[256, 456],\n        8,\n        0,\n        &[3355443201, 1, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, 1],\n        1,\n        0x80000000,\n        &[u32::MAX, 0, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[u32::MAX, u32::MAX],\n        31,\n        u32::MAX - 1,\n        &[u32::MAX, 1, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shr_to_out_fail_1() {\n    limbs_shr_to_out(&mut [10, 10], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shr_to_out_fail_2() {\n    limbs_shr_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shr_to_out_fail_3() {\n    limbs_shr_to_out(&mut [10, 10, 10], &[123, 456], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_shr_to_out_fail_4() {\n    limbs_shr_to_out(&mut [10, 10, 10], &[123, 456], 100);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_shr_in_place() {\n    let test = |limbs: &[Limb], bits: u64, carry: Limb, out: &[Limb]| {\n        let mut limbs = limbs.to_vec();\n        assert_eq!(limbs_slice_shr_in_place(&mut limbs, bits), carry);\n        assert_eq!(limbs, out);\n    };\n    test(&[0, 0, 0], 1, 0, &[0, 0, 0]);\n    test(&[1], 1, 0x80000000, &[0]);\n    test(&[3], 1, 0x80000000, &[1]);\n    test(&[122, 456], 1, 0, &[61, 228]);\n    test(&[123, 456], 1, 0x80000000, &[61, 228]);\n    test(&[123, 455], 1, 0x80000000, &[2147483709, 227]);\n    test(&[123, 456], 31, 246, &[912, 0]);\n    test(&[256, 456], 8, 0, &[3355443201, 1]);\n    test(&[u32::MAX, 1], 1, 0x80000000, &[u32::MAX, 0]);\n    test(&[u32::MAX, u32::MAX], 31, u32::MAX - 1, &[u32::MAX, 1]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_shr_in_place_fail_1() {\n    limbs_slice_shr_in_place::<Limb>(&mut [], 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_shr_in_place_fail_2() {\n    limbs_slice_shr_in_place::<Limb>(&mut [123, 456], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_shr_in_place_fail_3() {\n    limbs_slice_shr_in_place::<Limb>(&mut [123, 456], 100);\n}\n\nfn test_shr_unsigned_helper<T: PrimitiveUnsigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Natural: Shr<T, Output = Natural> + ShrAssign<T>,\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    let test = |s, v: u8, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"123\", 0, \"123\");\n    test(\"245\", 1, \"122\");\n    test(\"246\", 1, \"123\");\n    test(\"247\", 1, \"123\");\n    test(\"491\", 2, \"122\");\n    test(\"492\", 2, \"123\");\n    test(\"493\", 2, \"123\");\n    test(\"4127195135\", 25, \"122\");\n    test(\"4127195136\", 25, \"123\");\n    test(\"4127195137\", 25, \"123\");\n    test(\"8254390271\", 26, \"122\");\n    test(\"8254390272\", 26, \"123\");\n    test(\"8254390273\", 26, \"123\");\n    test(\"155921023828072216384094494261247\", 100, \"122\");\n    test(\"155921023828072216384094494261248\", 100, \"123\");\n    test(\"155921023828072216384094494261249\", 100, \"123\");\n    test(\"4294967295\", 1, \"2147483647\");\n    test(\"4294967296\", 1, \"2147483648\");\n    test(\"4294967297\", 1, \"2147483648\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"7999999999999\", 3, \"999999999999\");\n    test(\"8000000000000\", 3, \"1000000000000\");\n    test(\"8000000000001\", 3, \"1000000000000\");\n    test(\"16777216000000000000\", 24, \"1000000000000\");\n    test(\"33554432000000000000\", 25, \"1000000000000\");\n    test(\"2147483648000000000000\", 31, \"1000000000000\");\n    test(\"4294967296000000000000\", 32, \"1000000000000\");\n    test(\"8589934592000000000000\", 33, \"1000000000000\");\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        \"1000000000000\",\n    );\n    test(\"1000000000000\", 10, \"976562500\");\n    test(\"980657949\", 72, \"0\");\n    test(\"4294967295\", 31, \"1\");\n    test(\"4294967295\", 32, \"0\");\n    test(\"4294967296\", 32, \"1\");\n    test(\"4294967296\", 33, \"0\");\n}\n\n#[test]\nfn test_shr_unsigned() {\n    test_shr_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u32, _>(|u, v, out| {\n        let rug_u = rug::Integer::from_str(u).unwrap();\n        let mut n = rug_u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug_u >> v;\n        assert_eq!(n.to_string(), out);\n\n        let num_u = BigUint::from_str(u).unwrap();\n        let n = num_u.clone() >> usize::exact_from(v);\n        assert_eq!(n.to_string(), out);\n\n        let n = &num_u >> usize::exact_from(v);\n        assert_eq!(n.to_string(), out);\n    });\n    test_shr_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shr_signed_helper<T: PrimitiveSigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Natural: Shr<T, Output = Natural> + ShrAssign<T>,\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    let test = |s, v: i8, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"123\", 0, \"123\");\n    test(\"245\", 1, \"122\");\n    test(\"246\", 1, \"123\");\n    test(\"247\", 1, \"123\");\n    test(\"491\", 2, \"122\");\n    test(\"492\", 2, \"123\");\n    test(\"493\", 2, \"123\");\n    test(\"4127195135\", 25, \"122\");\n    test(\"4127195136\", 25, \"123\");\n    test(\"4127195137\", 25, \"123\");\n    test(\"8254390271\", 26, \"122\");\n    test(\"8254390272\", 26, \"123\");\n    test(\"8254390273\", 26, \"123\");\n    test(\"155921023828072216384094494261247\", 100, \"122\");\n    test(\"155921023828072216384094494261248\", 100, \"123\");\n    test(\"155921023828072216384094494261249\", 100, \"123\");\n    test(\"4294967295\", 1, \"2147483647\");\n    test(\"4294967296\", 1, \"2147483648\");\n    test(\"4294967297\", 1, \"2147483648\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"7999999999999\", 3, \"999999999999\");\n    test(\"8000000000000\", 3, \"1000000000000\");\n    test(\"8000000000001\", 3, \"1000000000000\");\n    test(\"16777216000000000000\", 24, \"1000000000000\");\n    test(\"33554432000000000000\", 25, \"1000000000000\");\n    test(\"2147483648000000000000\", 31, \"1000000000000\");\n    test(\"4294967296000000000000\", 32, \"1000000000000\");\n    test(\"8589934592000000000000\", 33, \"1000000000000\");\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        \"1000000000000\",\n    );\n    test(\"1000000000000\", 10, \"976562500\");\n    test(\"980657949\", 72, \"0\");\n    test(\"4294967295\", 31, \"1\");\n    test(\"4294967295\", 32, \"0\");\n    test(\"4294967296\", 32, \"1\");\n    test(\"4294967296\", 33, \"0\");\n\n    test(\"0\", 0, \"0\");\n    test(\"0\", -10, \"0\");\n    test(\"123\", 0, \"123\");\n    test(\"123\", -1, \"246\");\n    test(\"123\", -2, \"492\");\n    test(\"123\", -25, \"4127195136\");\n    test(\"123\", -26, \"8254390272\");\n    test(\"123\", -100, \"155921023828072216384094494261248\");\n    test(\"2147483648\", -1, \"4294967296\");\n    test(\"1000000000000\", 0, \"1000000000000\");\n    test(\"1000000000000\", -3, \"8000000000000\");\n    test(\"1000000000000\", -24, \"16777216000000000000\");\n    test(\"1000000000000\", -25, \"33554432000000000000\");\n    test(\"1000000000000\", -31, \"2147483648000000000000\");\n    test(\"1000000000000\", -32, \"4294967296000000000000\");\n    test(\"1000000000000\", -33, \"8589934592000000000000\");\n    test(\n        \"1000000000000\",\n        -100,\n        \"1267650600228229401496703205376000000000000\",\n    );\n}\n\n#[test]\nfn test_shr_signed() {\n    test_shr_signed_helper::<i8, _>(|_, _, _| {});\n    test_shr_signed_helper::<i16, _>(|_, _, _| {});\n    test_shr_signed_helper::<i32, _>(|u, v, out| {\n        let rug_u = rug::Integer::from_str(u).unwrap();\n        let mut n = rug_u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug_u >> v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shr_signed_helper::<i64, _>(|_, _, _| {});\n    test_shr_signed_helper::<i128, _>(|_, _, _| {});\n    test_shr_signed_helper::<isize, _>(|_, _, _| {});\n}\n\n#[test]\nfn limbs_shr_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, bits)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_shr(&xs, bits)),\n            Natural::from_owned_limbs_asc(xs) >> bits\n        );\n    });\n}\n\n#[test]\nfn limbs_shr_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_23::<Limb, Limb>()\n        .test_properties_with_config(&config, |(mut out, xs, bits)| {\n            let old_out = out.clone();\n            let carry = limbs_shr_to_out(&mut out, &xs, bits);\n            let len = xs.len();\n            let n = Natural::from_owned_limbs_asc(xs);\n            let m = &n >> bits;\n            assert_eq!(carry == 0, &m << bits == n);\n            let mut xs = m.into_limbs_asc();\n            xs.resize(len, 0);\n            let actual_xs = out[..len].to_vec();\n            assert_eq!(xs, actual_xs);\n            assert_eq!(&out[len..], &old_out[len..]);\n        });\n}\n\n#[test]\nfn limbs_slice_shr_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_33::<Limb, Limb>().test_properties_with_config(\n        &config,\n        |(mut xs, bits)| {\n            let old_xs = xs.clone();\n            let carry = limbs_slice_shr_in_place(&mut xs, bits);\n            let n = Natural::from_owned_limbs_asc(old_xs);\n            let m = &n >> bits;\n            assert_eq!(carry == 0, &m << bits == n);\n            let mut expected_limbs = m.into_limbs_asc();\n            expected_limbs.resize(xs.len(), 0);\n            assert_eq!(xs, expected_limbs);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_shr_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16::<Limb, u64>().test_properties_with_config(\n        &config,\n        |(mut xs, bits)| {\n            let old_xs = xs.clone();\n            limbs_vec_shr_in_place(&mut xs, bits);\n            let n = Natural::from_owned_limbs_asc(old_xs) >> bits;\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\nfn unsigned_properties<U: PrimitiveUnsigned, S: PrimitiveSigned + WrappingFrom<U>>()\nwhere\n    Natural: Shl<S, Output = Natural> + Shr<U, Output = Natural> + ShrAssign<U>,\n    for<'a> &'a Natural: Shl<U, Output = Natural>\n        + Shr<U, Output = Natural>\n        + Shr<S, Output = Natural>\n        + ShrRound<U, Output = Natural>,\n    Limb: Shr<U, Output = Limb>,\n{\n    natural_unsigned_pair_gen_var_4::<U>().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n >>= u;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n >> u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        let shifted_alt = n.clone() >> u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert!(shifted <= n);\n        assert_eq!((&n).shr_round(u, Floor).0, shifted);\n\n        if u <= U::low_mask(U::WIDTH - 1) {\n            let u = S::wrapping_from(u);\n            assert_eq!(&n >> u, shifted);\n            assert_eq!(n << -u, shifted);\n        }\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_5::<U>().test_properties(|(n, u, v)| {\n        if let Some(sum) = u.checked_add(v) {\n            assert_eq!(&n >> u >> v, n >> sum);\n        }\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(&n >> U::ZERO, n);\n    });\n\n    unsigned_gen::<U>().test_properties(|u| {\n        assert_eq!(Natural::ZERO >> u, 0);\n    });\n\n    unsigned_pair_gen_var_2::<Limb, U>().test_properties(|(u, v)| {\n        if let Some(shift) = v.checked_add(U::exact_from(Limb::WIDTH)) {\n            assert_eq!(Natural::from(u) >> shift, 0);\n        }\n        if v < U::exact_from(Limb::WIDTH) {\n            assert_eq!(u >> v, Natural::from(u) >> v);\n        }\n    });\n}\n\nfn signed_properties<T: PrimitiveSigned>()\nwhere\n    Natural: Shr<T, Output = Natural> + ShrAssign<T> + ShrRound<T, Output = Natural>,\n    for<'a> &'a Natural: Shr<T, Output = Natural>,\n{\n    natural_signed_pair_gen_var_2::<T>().test_properties(|(n, i)| {\n        let mut mut_n = n.clone();\n        mut_n >>= i;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n >> i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        let shifted_alt = n.clone() >> i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert_eq!(n.shr_round(i, Floor).0, shifted);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(&n >> T::ZERO, n);\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert_eq!(Natural::ZERO >> i, 0);\n    });\n}\n\n#[test]\nfn shr_properties() {\n    apply_fn_to_unsigned_signed_pairs!(unsigned_properties);\n    apply_fn_to_signeds!(signed_properties);\n\n    natural_unsigned_pair_gen_var_4::<u32>().test_properties(|(n, u)| {\n        let shifted = &n >> u;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n >>= u;\n        assert_eq!(Natural::exact_from(&rug_n), shifted);\n\n        assert_eq!(\n            Natural::from(&(&BigUint::from(&n) >> usize::exact_from(u))),\n            shifted\n        );\n        assert_eq!(\n            Natural::from(&(BigUint::from(&n) >> usize::exact_from(u))),\n            shifted\n        );\n        assert_eq!(Natural::exact_from(&(rug::Integer::from(&n) >> u)), shifted);\n    });\n\n    natural_signed_pair_gen_var_2::<i32>().test_properties(|(n, i)| {\n        let shifted = &n >> i;\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n >>= i;\n        assert_eq!(Natural::exact_from(&rug_n), shifted);\n\n        assert_eq!(Natural::exact_from(&(rug::Integer::from(&n) >> i)), shifted);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/shr_round.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#[cfg(not(feature = \"32_bit_limbs\"))]\nuse core::cmp::Ordering::*;\n#[cfg(feature = \"32_bit_limbs\")]\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    ArithmeticCheckedShr, DivRound, DivisibleByPowerOf2, ShlRound, ShrRound, ShrRoundAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    signed_rounding_mode_pair_gen, unsigned_pair_gen_var_37, unsigned_rounding_mode_pair_gen,\n    unsigned_signed_rounding_mode_triple_gen_var_1,\n    unsigned_unsigned_rounding_mode_triple_gen_var_4, unsigned_vec_unsigned_pair_gen_var_16,\n    unsigned_vec_unsigned_pair_gen_var_20, unsigned_vec_unsigned_rounding_mode_triple_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::shr_round::{\n    limbs_shr_exact, limbs_shr_round, limbs_shr_round_nearest, limbs_shr_round_up,\n    limbs_vec_shr_exact_in_place, limbs_vec_shr_round_in_place,\n    limbs_vec_shr_round_nearest_in_place, limbs_vec_shr_round_up_in_place,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_rounding_mode_pair_gen, natural_signed_rounding_mode_triple_gen_var_2,\n    natural_unsigned_pair_gen_var_4, natural_unsigned_pair_gen_var_10,\n    natural_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse std::ops::Shl;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shr_round_up_and_limbs_vec_shr_round_up_in_place() {\n    let test = |limbs: &[Limb], bits: u64, out: &[Limb], o: Ordering| {\n        let (s, o_alt) = limbs_shr_round_up(limbs, bits);\n        assert_eq!(s, out);\n        assert_eq!(o_alt, o);\n\n        let mut limbs = limbs.to_vec();\n        assert_eq!(limbs_vec_shr_round_up_in_place(&mut limbs, bits), o);\n        assert_eq!(limbs, out);\n    };\n    test(&[1], 0, &[1], Equal);\n    test(&[1], 1, &[1], Greater);\n    test(&[3], 1, &[2], Greater);\n    test(&[122, 456], 1, &[61, 228], Equal);\n    test(&[123, 456], 0, &[123, 456], Equal);\n    test(&[123, 456], 1, &[62, 228], Greater);\n    test(&[123, 455], 1, &[2147483710, 227], Greater);\n    test(&[123, 456], 31, &[913, 0], Greater);\n    test(&[123, 456], 32, &[457], Greater);\n    test(&[123, 456], 100, &[1], Greater);\n    test(&[256, 456], 8, &[3355443201, 1], Equal);\n    test(&[u32::MAX, 1], 1, &[0, 1], Greater);\n    test(&[u32::MAX, u32::MAX], 32, &[0, 1], Greater);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shr_round_nearest_and_limbs_vec_shr_round_nearest_in_place() {\n    let test = |limbs: &[Limb], bits: u64, out: &[Limb], o: Ordering| {\n        let (s, o_alt) = limbs_shr_round_nearest(limbs, bits);\n        assert_eq!(s, out);\n        assert_eq!(o_alt, o);\n\n        let mut limbs = limbs.to_vec();\n        assert_eq!(limbs_vec_shr_round_nearest_in_place(&mut limbs, bits), o);\n        assert_eq!(limbs, out);\n    };\n    test(&[], 0, &[], Equal);\n    test(&[], 1, &[], Equal);\n    test(&[], 100, &[], Equal);\n    test(&[0, 0, 0], 0, &[0, 0, 0], Equal);\n    test(&[0, 0, 0], 1, &[0, 0, 0], Equal);\n    test(&[0, 0, 0], 100, &[], Equal);\n    test(&[1], 0, &[1], Equal);\n    test(&[1], 1, &[0], Less);\n    test(&[3], 1, &[2], Greater);\n    test(&[122, 456], 1, &[61, 228], Equal);\n    test(&[123, 456], 0, &[123, 456], Equal);\n    test(&[123, 456], 1, &[62, 228], Greater);\n    test(&[123, 455], 1, &[2147483710, 227], Greater);\n    test(&[123, 456], 31, &[912, 0], Less);\n    test(&[123, 456], 32, &[456], Less);\n    test(&[123, 456], 100, &[], Less);\n    test(&[256, 456], 8, &[3355443201, 1], Equal);\n    test(&[u32::MAX, 1], 1, &[0, 1], Greater);\n    test(&[u32::MAX, u32::MAX], 32, &[0, 1], Greater);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shr_exact_and_limbs_vec_shr_exact_in_place() {\n    let test = |limbs: &[Limb], bits: u64, out: Option<Vec<Limb>>| {\n        assert_eq!(limbs_shr_exact(limbs, bits), out);\n\n        let mut limbs = limbs.to_vec();\n        if limbs_vec_shr_exact_in_place(&mut limbs, bits) {\n            assert_eq!(Some(limbs), out);\n        } else {\n            assert_eq!(None, out);\n        }\n    };\n    test(&[1], 0, Some(vec![1]));\n    test(&[1], 1, None);\n    test(&[3], 1, None);\n    test(&[122, 456], 1, Some(vec![61, 228]));\n    test(&[123, 456], 0, Some(vec![123, 456]));\n    test(&[123, 456], 1, None);\n    test(&[123, 455], 1, None);\n    test(&[123, 456], 31, None);\n    test(&[123, 456], 32, None);\n    test(&[123, 456], 100, None);\n    test(&[256, 456], 8, Some(vec![3355443201, 1]));\n    test(&[u32::MAX, 1], 1, None);\n    test(&[u32::MAX, u32::MAX], 32, None);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_shr_round_and_limbs_vec_shr_round_in_place() {\n    let test = |limbs: &[Limb], bits: u64, rm: RoundingMode, out: Option<&[Limb]>, o: Ordering| {\n        if let Some((s, o_alt)) = limbs_shr_round(limbs, bits, rm) {\n            assert_eq!(Some(s.as_slice()), out);\n            assert_eq!(o_alt, o);\n        } else {\n            assert!(out.is_none());\n        }\n\n        let mut limbs = limbs.to_vec();\n        let (b, o_alt) = limbs_vec_shr_round_in_place(&mut limbs, bits, rm);\n        if b {\n            assert_eq!(Some(limbs.as_slice()), out);\n        } else {\n            assert!(out.is_none());\n        }\n        assert_eq!(o_alt, o);\n    };\n    test(&[1], 0, Nearest, Some(&[1]), Equal);\n    test(&[1], 1, Up, Some(&[1]), Greater);\n    test(&[3], 1, Nearest, Some(&[2]), Greater);\n    test(&[122, 456], 1, Floor, Some(&[61, 228]), Equal);\n    test(&[123, 456], 0, Floor, Some(&[123, 456]), Equal);\n    test(&[123, 456], 1, Down, Some(&[61, 228]), Less);\n    test(&[123, 455], 1, Floor, Some(&[2147483709, 227]), Less);\n    test(&[123, 456], 31, Ceiling, Some(&[913, 0]), Greater);\n    test(&[123, 456], 32, Up, Some(&[457]), Greater);\n    test(&[123, 456], 100, Down, Some(&[]), Less);\n    test(&[256, 456], 8, Exact, Some(&[3355443201, 1]), Equal);\n    test(&[u32::MAX, 1], 1, Exact, None, Equal);\n    test(&[u32::MAX, u32::MAX], 32, Down, Some(&[u32::MAX]), Less);\n}\n\nfn test_shr_round_unsigned_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: ShrRound<T, Output = Natural> + ShrRoundAssign<T>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n{\n    let test = |s, v: u8, rm: RoundingMode, out, o| {\n        let u = Natural::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        assert_eq!(n.shr_round_assign(v, rm), o);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let (n, o_alt) = u.clone().shr_round(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n\n        let (n, o_alt) = (&u).shr_round(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", 0, Down, \"0\", Equal);\n    test(\"0\", 0, Up, \"0\", Equal);\n    test(\"0\", 0, Floor, \"0\", Equal);\n    test(\"0\", 0, Ceiling, \"0\", Equal);\n    test(\"0\", 0, Nearest, \"0\", Equal);\n    test(\"0\", 0, Exact, \"0\", Equal);\n\n    test(\"0\", 10, Down, \"0\", Equal);\n    test(\"0\", 10, Up, \"0\", Equal);\n    test(\"0\", 10, Floor, \"0\", Equal);\n    test(\"0\", 10, Ceiling, \"0\", Equal);\n    test(\"0\", 10, Nearest, \"0\", Equal);\n    test(\"0\", 10, Exact, \"0\", Equal);\n\n    test(\"123\", 0, Down, \"123\", Equal);\n    test(\"123\", 0, Up, \"123\", Equal);\n    test(\"123\", 0, Floor, \"123\", Equal);\n    test(\"123\", 0, Ceiling, \"123\", Equal);\n    test(\"123\", 0, Nearest, \"123\", Equal);\n    test(\"123\", 0, Exact, \"123\", Equal);\n\n    test(\"245\", 1, Down, \"122\", Less);\n    test(\"245\", 1, Up, \"123\", Greater);\n    test(\"245\", 1, Floor, \"122\", Less);\n    test(\"245\", 1, Ceiling, \"123\", Greater);\n    test(\"245\", 1, Nearest, \"122\", Less);\n\n    test(\"246\", 1, Down, \"123\", Equal);\n    test(\"246\", 1, Up, \"123\", Equal);\n    test(\"246\", 1, Floor, \"123\", Equal);\n    test(\"246\", 1, Ceiling, \"123\", Equal);\n    test(\"246\", 1, Nearest, \"123\", Equal);\n    test(\"246\", 1, Exact, \"123\", Equal);\n\n    test(\"247\", 1, Down, \"123\", Less);\n    test(\"247\", 1, Up, \"124\", Greater);\n    test(\"247\", 1, Floor, \"123\", Less);\n    test(\"247\", 1, Ceiling, \"124\", Greater);\n    test(\"247\", 1, Nearest, \"124\", Greater);\n\n    test(\"491\", 2, Down, \"122\", Less);\n    test(\"491\", 2, Up, \"123\", Greater);\n    test(\"491\", 2, Floor, \"122\", Less);\n    test(\"491\", 2, Ceiling, \"123\", Greater);\n    test(\"491\", 2, Nearest, \"123\", Greater);\n\n    test(\"492\", 2, Down, \"123\", Equal);\n    test(\"492\", 2, Up, \"123\", Equal);\n    test(\"492\", 2, Floor, \"123\", Equal);\n    test(\"492\", 2, Ceiling, \"123\", Equal);\n    test(\"492\", 2, Nearest, \"123\", Equal);\n    test(\"492\", 2, Exact, \"123\", Equal);\n\n    test(\"493\", 2, Down, \"123\", Less);\n    test(\"493\", 2, Up, \"124\", Greater);\n    test(\"493\", 2, Floor, \"123\", Less);\n    test(\"493\", 2, Ceiling, \"124\", Greater);\n    test(\"493\", 2, Nearest, \"123\", Less);\n\n    test(\"4127195135\", 25, Down, \"122\", Less);\n    test(\"4127195135\", 25, Up, \"123\", Greater);\n    test(\"4127195135\", 25, Floor, \"122\", Less);\n    test(\"4127195135\", 25, Ceiling, \"123\", Greater);\n    test(\"4127195135\", 25, Nearest, \"123\", Greater);\n\n    test(\"4127195136\", 25, Down, \"123\", Equal);\n    test(\"4127195136\", 25, Up, \"123\", Equal);\n    test(\"4127195136\", 25, Floor, \"123\", Equal);\n    test(\"4127195136\", 25, Ceiling, \"123\", Equal);\n    test(\"4127195136\", 25, Nearest, \"123\", Equal);\n    test(\"4127195136\", 25, Exact, \"123\", Equal);\n\n    test(\"4127195137\", 25, Down, \"123\", Less);\n    test(\"4127195137\", 25, Up, \"124\", Greater);\n    test(\"4127195137\", 25, Floor, \"123\", Less);\n    test(\"4127195137\", 25, Ceiling, \"124\", Greater);\n    test(\"4127195137\", 25, Nearest, \"123\", Less);\n\n    test(\"8254390271\", 26, Down, \"122\", Less);\n    test(\"8254390271\", 26, Up, \"123\", Greater);\n    test(\"8254390271\", 26, Floor, \"122\", Less);\n    test(\"8254390271\", 26, Ceiling, \"123\", Greater);\n    test(\"8254390271\", 26, Nearest, \"123\", Greater);\n\n    test(\"8254390272\", 26, Down, \"123\", Equal);\n    test(\"8254390272\", 26, Up, \"123\", Equal);\n    test(\"8254390272\", 26, Floor, \"123\", Equal);\n    test(\"8254390272\", 26, Ceiling, \"123\", Equal);\n    test(\"8254390272\", 26, Nearest, \"123\", Equal);\n    test(\"8254390272\", 26, Exact, \"123\", Equal);\n\n    test(\"8254390273\", 26, Down, \"123\", Less);\n    test(\"8254390273\", 26, Up, \"124\", Greater);\n    test(\"8254390273\", 26, Floor, \"123\", Less);\n    test(\"8254390273\", 26, Ceiling, \"124\", Greater);\n    test(\"8254390273\", 26, Nearest, \"123\", Less);\n\n    test(\"155921023828072216384094494261247\", 100, Down, \"122\", Less);\n    test(\"155921023828072216384094494261247\", 100, Up, \"123\", Greater);\n    test(\"155921023828072216384094494261247\", 100, Floor, \"122\", Less);\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Ceiling,\n        \"123\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Nearest,\n        \"123\",\n        Greater,\n    );\n\n    test(\"155921023828072216384094494261248\", 100, Down, \"123\", Equal);\n    test(\"155921023828072216384094494261248\", 100, Up, \"123\", Equal);\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Floor,\n        \"123\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Ceiling,\n        \"123\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Nearest,\n        \"123\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Exact,\n        \"123\",\n        Equal,\n    );\n\n    test(\"155921023828072216384094494261249\", 100, Down, \"123\", Less);\n    test(\"155921023828072216384094494261249\", 100, Up, \"124\", Greater);\n    test(\"155921023828072216384094494261249\", 100, Floor, \"123\", Less);\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Ceiling,\n        \"124\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Nearest,\n        \"123\",\n        Less,\n    );\n\n    test(\"4294967295\", 1, Down, \"2147483647\", Less);\n    test(\"4294967295\", 1, Up, \"2147483648\", Greater);\n    test(\"4294967295\", 1, Floor, \"2147483647\", Less);\n    test(\"4294967295\", 1, Ceiling, \"2147483648\", Greater);\n    test(\"4294967295\", 1, Nearest, \"2147483648\", Greater);\n\n    test(\"4294967296\", 1, Down, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Up, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Floor, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Ceiling, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Nearest, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Exact, \"2147483648\", Equal);\n\n    test(\"4294967297\", 1, Down, \"2147483648\", Less);\n    test(\"4294967297\", 1, Up, \"2147483649\", Greater);\n    test(\"4294967297\", 1, Floor, \"2147483648\", Less);\n    test(\"4294967297\", 1, Ceiling, \"2147483649\", Greater);\n    test(\"4294967297\", 1, Nearest, \"2147483648\", Less);\n\n    test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n    test(\"7999999999999\", 3, Down, \"999999999999\", Less);\n    test(\"7999999999999\", 3, Up, \"1000000000000\", Greater);\n    test(\"7999999999999\", 3, Floor, \"999999999999\", Less);\n    test(\"7999999999999\", 3, Ceiling, \"1000000000000\", Greater);\n    test(\"7999999999999\", 3, Nearest, \"1000000000000\", Greater);\n\n    test(\"8000000000000\", 3, Down, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Up, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Floor, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Ceiling, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Nearest, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Exact, \"1000000000000\", Equal);\n\n    test(\"8000000000001\", 3, Down, \"1000000000000\", Less);\n    test(\"8000000000001\", 3, Up, \"1000000000001\", Greater);\n    test(\"8000000000001\", 3, Floor, \"1000000000000\", Less);\n    test(\"8000000000001\", 3, Ceiling, \"1000000000001\", Greater);\n    test(\"8000000000001\", 3, Nearest, \"1000000000000\", Less);\n\n    test(\"16777216000000000000\", 24, Down, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Up, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Floor, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Ceiling, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Nearest, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Exact, \"1000000000000\", Equal);\n\n    test(\"33554432000000000000\", 25, Down, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Up, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Floor, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Ceiling, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Nearest, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Exact, \"1000000000000\", Equal);\n\n    test(\"2147483648000000000000\", 31, Down, \"1000000000000\", Equal);\n    test(\"2147483648000000000000\", 31, Up, \"1000000000000\", Equal);\n    test(\"2147483648000000000000\", 31, Floor, \"1000000000000\", Equal);\n    test(\n        \"2147483648000000000000\",\n        31,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\"2147483648000000000000\", 31, Exact, \"1000000000000\", Equal);\n\n    test(\"4294967296000000000000\", 32, Down, \"1000000000000\", Equal);\n    test(\"4294967296000000000000\", 32, Up, \"1000000000000\", Equal);\n    test(\"4294967296000000000000\", 32, Floor, \"1000000000000\", Equal);\n    test(\n        \"4294967296000000000000\",\n        32,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\"4294967296000000000000\", 32, Exact, \"1000000000000\", Equal);\n\n    test(\"8589934592000000000000\", 33, Down, \"1000000000000\", Equal);\n    test(\"8589934592000000000000\", 33, Up, \"1000000000000\", Equal);\n    test(\"8589934592000000000000\", 33, Floor, \"1000000000000\", Equal);\n    test(\n        \"8589934592000000000000\",\n        33,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\"8589934592000000000000\", 33, Exact, \"1000000000000\", Equal);\n\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Down,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Up,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Floor,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Exact,\n        \"1000000000000\",\n        Equal,\n    );\n\n    test(\"1000000000000\", 10, Down, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Up, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Floor, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Ceiling, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Nearest, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Exact, \"976562500\", Equal);\n\n    test(\"980657949\", 72, Down, \"0\", Less);\n    test(\"980657949\", 72, Up, \"1\", Greater);\n    test(\"980657949\", 72, Floor, \"0\", Less);\n    test(\"980657949\", 72, Ceiling, \"1\", Greater);\n    test(\"980657949\", 72, Nearest, \"0\", Less);\n\n    test(\"4294967295\", 31, Down, \"1\", Less);\n    test(\"4294967295\", 31, Up, \"2\", Greater);\n    test(\"4294967295\", 31, Floor, \"1\", Less);\n    test(\"4294967295\", 31, Ceiling, \"2\", Greater);\n    test(\"4294967295\", 31, Nearest, \"2\", Greater);\n\n    test(\"4294967295\", 32, Down, \"0\", Less);\n    test(\"4294967295\", 32, Up, \"1\", Greater);\n    test(\"4294967295\", 32, Floor, \"0\", Less);\n    test(\"4294967295\", 32, Ceiling, \"1\", Greater);\n    test(\"4294967295\", 32, Nearest, \"1\", Greater);\n\n    test(\"4294967296\", 32, Down, \"1\", Equal);\n    test(\"4294967296\", 32, Up, \"1\", Equal);\n    test(\"4294967296\", 32, Floor, \"1\", Equal);\n    test(\"4294967296\", 32, Ceiling, \"1\", Equal);\n    test(\"4294967296\", 32, Nearest, \"1\", Equal);\n    test(\"4294967296\", 32, Exact, \"1\", Equal);\n\n    test(\"4294967296\", 33, Down, \"0\", Less);\n    test(\"4294967296\", 33, Up, \"1\", Greater);\n    test(\"4294967296\", 33, Floor, \"0\", Less);\n    test(\"4294967296\", 33, Ceiling, \"1\", Greater);\n    test(\"4294967296\", 33, Nearest, \"0\", Less);\n}\n\n#[test]\nfn test_shr_round_unsigned() {\n    apply_fn_to_unsigneds!(test_shr_round_unsigned_helper);\n}\n\nmacro_rules! shr_round_unsigned_fail_helper {\n    ($t:ident) => {\n        assert_panic!(Natural::from(123u32).shr_round_assign($t::ONE, Exact));\n        assert_panic!(Natural::from(123u32).shr_round_assign($t::exact_from(100), Exact));\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::ONE, Exact)\n        );\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::exact_from(100), Exact)\n        );\n        assert_panic!(Natural::from(123u32).shr_round($t::ONE, Exact));\n        assert_panic!(Natural::from(123u32).shr_round($t::exact_from(100), Exact));\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round($t::ONE, Exact)\n        );\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round($t::exact_from(100), Exact)\n        );\n        assert_panic!((&Natural::from(123u32)).shr_round($t::ONE, Exact));\n        assert_panic!((&Natural::from(123u32)).shr_round($t::exact_from(100), Exact));\n        assert_panic!((&Natural::from_str(\"1000000000001\").unwrap()).shr_round($t::ONE, Exact));\n        assert_panic!(\n            (&Natural::from_str(\"1000000000001\").unwrap()).shr_round($t::exact_from(100), Exact)\n        );\n    };\n}\n\n#[test]\nfn shr_round_unsigned_fail() {\n    apply_to_unsigneds!(shr_round_unsigned_fail_helper);\n}\n\nfn test_shr_round_signed_helper<T: PrimitiveSigned>()\nwhere\n    Natural: ShrRound<T, Output = Natural> + ShrRoundAssign<T>,\n    for<'a> &'a Natural: ShrRound<T, Output = Natural>,\n{\n    let test = |s, j: i8, rm: RoundingMode, out, o| {\n        let u = Natural::from_str(s).unwrap();\n        let j = T::from(j);\n\n        let mut n = u.clone();\n        assert_eq!(n.shr_round_assign(j, rm), o);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let (n, o_alt) = u.clone().shr_round(j, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n\n        let (n, o_alt) = (&u).shr_round(j, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", 0, Down, \"0\", Equal);\n    test(\"0\", 0, Up, \"0\", Equal);\n    test(\"0\", 0, Floor, \"0\", Equal);\n    test(\"0\", 0, Ceiling, \"0\", Equal);\n    test(\"0\", 0, Nearest, \"0\", Equal);\n    test(\"0\", 0, Exact, \"0\", Equal);\n\n    test(\"0\", 10, Down, \"0\", Equal);\n    test(\"0\", 10, Up, \"0\", Equal);\n    test(\"0\", 10, Floor, \"0\", Equal);\n    test(\"0\", 10, Ceiling, \"0\", Equal);\n    test(\"0\", 10, Nearest, \"0\", Equal);\n    test(\"0\", 10, Exact, \"0\", Equal);\n\n    test(\"123\", 0, Down, \"123\", Equal);\n    test(\"123\", 0, Up, \"123\", Equal);\n    test(\"123\", 0, Floor, \"123\", Equal);\n    test(\"123\", 0, Ceiling, \"123\", Equal);\n    test(\"123\", 0, Nearest, \"123\", Equal);\n    test(\"123\", 0, Exact, \"123\", Equal);\n\n    test(\"245\", 1, Down, \"122\", Less);\n    test(\"245\", 1, Up, \"123\", Greater);\n    test(\"245\", 1, Floor, \"122\", Less);\n    test(\"245\", 1, Ceiling, \"123\", Greater);\n    test(\"245\", 1, Nearest, \"122\", Less);\n\n    test(\"246\", 1, Down, \"123\", Equal);\n    test(\"246\", 1, Up, \"123\", Equal);\n    test(\"246\", 1, Floor, \"123\", Equal);\n    test(\"246\", 1, Ceiling, \"123\", Equal);\n    test(\"246\", 1, Nearest, \"123\", Equal);\n    test(\"246\", 1, Exact, \"123\", Equal);\n\n    test(\"247\", 1, Down, \"123\", Less);\n    test(\"247\", 1, Up, \"124\", Greater);\n    test(\"247\", 1, Floor, \"123\", Less);\n    test(\"247\", 1, Ceiling, \"124\", Greater);\n    test(\"247\", 1, Nearest, \"124\", Greater);\n\n    test(\"491\", 2, Down, \"122\", Less);\n    test(\"491\", 2, Up, \"123\", Greater);\n    test(\"491\", 2, Floor, \"122\", Less);\n    test(\"491\", 2, Ceiling, \"123\", Greater);\n    test(\"491\", 2, Nearest, \"123\", Greater);\n\n    test(\"492\", 2, Down, \"123\", Equal);\n    test(\"492\", 2, Up, \"123\", Equal);\n    test(\"492\", 2, Floor, \"123\", Equal);\n    test(\"492\", 2, Ceiling, \"123\", Equal);\n    test(\"492\", 2, Nearest, \"123\", Equal);\n    test(\"492\", 2, Exact, \"123\", Equal);\n\n    test(\"493\", 2, Down, \"123\", Less);\n    test(\"493\", 2, Up, \"124\", Greater);\n    test(\"493\", 2, Floor, \"123\", Less);\n    test(\"493\", 2, Ceiling, \"124\", Greater);\n    test(\"493\", 2, Nearest, \"123\", Less);\n\n    test(\"4127195135\", 25, Down, \"122\", Less);\n    test(\"4127195135\", 25, Up, \"123\", Greater);\n    test(\"4127195135\", 25, Floor, \"122\", Less);\n    test(\"4127195135\", 25, Ceiling, \"123\", Greater);\n    test(\"4127195135\", 25, Nearest, \"123\", Greater);\n\n    test(\"4127195136\", 25, Down, \"123\", Equal);\n    test(\"4127195136\", 25, Up, \"123\", Equal);\n    test(\"4127195136\", 25, Floor, \"123\", Equal);\n    test(\"4127195136\", 25, Ceiling, \"123\", Equal);\n    test(\"4127195136\", 25, Nearest, \"123\", Equal);\n    test(\"4127195136\", 25, Exact, \"123\", Equal);\n\n    test(\"4127195137\", 25, Down, \"123\", Less);\n    test(\"4127195137\", 25, Up, \"124\", Greater);\n    test(\"4127195137\", 25, Floor, \"123\", Less);\n    test(\"4127195137\", 25, Ceiling, \"124\", Greater);\n    test(\"4127195137\", 25, Nearest, \"123\", Less);\n\n    test(\"8254390271\", 26, Down, \"122\", Less);\n    test(\"8254390271\", 26, Up, \"123\", Greater);\n    test(\"8254390271\", 26, Floor, \"122\", Less);\n    test(\"8254390271\", 26, Ceiling, \"123\", Greater);\n    test(\"8254390271\", 26, Nearest, \"123\", Greater);\n\n    test(\"8254390272\", 26, Down, \"123\", Equal);\n    test(\"8254390272\", 26, Up, \"123\", Equal);\n    test(\"8254390272\", 26, Floor, \"123\", Equal);\n    test(\"8254390272\", 26, Ceiling, \"123\", Equal);\n    test(\"8254390272\", 26, Nearest, \"123\", Equal);\n    test(\"8254390272\", 26, Exact, \"123\", Equal);\n\n    test(\"8254390273\", 26, Down, \"123\", Less);\n    test(\"8254390273\", 26, Up, \"124\", Greater);\n    test(\"8254390273\", 26, Floor, \"123\", Less);\n    test(\"8254390273\", 26, Ceiling, \"124\", Greater);\n    test(\"8254390273\", 26, Nearest, \"123\", Less);\n\n    test(\"155921023828072216384094494261247\", 100, Down, \"122\", Less);\n    test(\"155921023828072216384094494261247\", 100, Up, \"123\", Greater);\n    test(\"155921023828072216384094494261247\", 100, Floor, \"122\", Less);\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Ceiling,\n        \"123\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261247\",\n        100,\n        Nearest,\n        \"123\",\n        Greater,\n    );\n\n    test(\"155921023828072216384094494261248\", 100, Down, \"123\", Equal);\n    test(\"155921023828072216384094494261248\", 100, Up, \"123\", Equal);\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Floor,\n        \"123\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Ceiling,\n        \"123\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Nearest,\n        \"123\",\n        Equal,\n    );\n    test(\n        \"155921023828072216384094494261248\",\n        100,\n        Exact,\n        \"123\",\n        Equal,\n    );\n\n    test(\"155921023828072216384094494261249\", 100, Down, \"123\", Less);\n    test(\"155921023828072216384094494261249\", 100, Up, \"124\", Greater);\n    test(\"155921023828072216384094494261249\", 100, Floor, \"123\", Less);\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Ceiling,\n        \"124\",\n        Greater,\n    );\n    test(\n        \"155921023828072216384094494261249\",\n        100,\n        Nearest,\n        \"123\",\n        Less,\n    );\n\n    test(\"4294967295\", 1, Down, \"2147483647\", Less);\n    test(\"4294967295\", 1, Up, \"2147483648\", Greater);\n    test(\"4294967295\", 1, Floor, \"2147483647\", Less);\n    test(\"4294967295\", 1, Ceiling, \"2147483648\", Greater);\n    test(\"4294967295\", 1, Nearest, \"2147483648\", Greater);\n\n    test(\"4294967296\", 1, Down, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Up, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Floor, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Ceiling, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Nearest, \"2147483648\", Equal);\n    test(\"4294967296\", 1, Exact, \"2147483648\", Equal);\n\n    test(\"4294967297\", 1, Down, \"2147483648\", Less);\n    test(\"4294967297\", 1, Up, \"2147483649\", Greater);\n    test(\"4294967297\", 1, Floor, \"2147483648\", Less);\n    test(\"4294967297\", 1, Ceiling, \"2147483649\", Greater);\n    test(\"4294967297\", 1, Nearest, \"2147483648\", Less);\n\n    test(\"1000000000000\", 0, Down, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Up, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Floor, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Ceiling, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Nearest, \"1000000000000\", Equal);\n    test(\"1000000000000\", 0, Exact, \"1000000000000\", Equal);\n\n    test(\"7999999999999\", 3, Down, \"999999999999\", Less);\n    test(\"7999999999999\", 3, Up, \"1000000000000\", Greater);\n    test(\"7999999999999\", 3, Floor, \"999999999999\", Less);\n    test(\"7999999999999\", 3, Ceiling, \"1000000000000\", Greater);\n    test(\"7999999999999\", 3, Nearest, \"1000000000000\", Greater);\n\n    test(\"8000000000000\", 3, Down, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Up, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Floor, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Ceiling, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Nearest, \"1000000000000\", Equal);\n    test(\"8000000000000\", 3, Exact, \"1000000000000\", Equal);\n\n    test(\"8000000000001\", 3, Down, \"1000000000000\", Less);\n    test(\"8000000000001\", 3, Up, \"1000000000001\", Greater);\n    test(\"8000000000001\", 3, Floor, \"1000000000000\", Less);\n    test(\"8000000000001\", 3, Ceiling, \"1000000000001\", Greater);\n    test(\"8000000000001\", 3, Nearest, \"1000000000000\", Less);\n\n    test(\"16777216000000000000\", 24, Down, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Up, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Floor, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Ceiling, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Nearest, \"1000000000000\", Equal);\n    test(\"16777216000000000000\", 24, Exact, \"1000000000000\", Equal);\n\n    test(\"33554432000000000000\", 25, Down, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Up, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Floor, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Ceiling, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Nearest, \"1000000000000\", Equal);\n    test(\"33554432000000000000\", 25, Exact, \"1000000000000\", Equal);\n\n    test(\"2147483648000000000000\", 31, Down, \"1000000000000\", Equal);\n    test(\"2147483648000000000000\", 31, Up, \"1000000000000\", Equal);\n    test(\"2147483648000000000000\", 31, Floor, \"1000000000000\", Equal);\n    test(\n        \"2147483648000000000000\",\n        31,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"2147483648000000000000\",\n        31,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\"2147483648000000000000\", 31, Exact, \"1000000000000\", Equal);\n\n    test(\"4294967296000000000000\", 32, Down, \"1000000000000\", Equal);\n    test(\"4294967296000000000000\", 32, Up, \"1000000000000\", Equal);\n    test(\"4294967296000000000000\", 32, Floor, \"1000000000000\", Equal);\n    test(\n        \"4294967296000000000000\",\n        32,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"4294967296000000000000\",\n        32,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\"4294967296000000000000\", 32, Exact, \"1000000000000\", Equal);\n\n    test(\"8589934592000000000000\", 33, Down, \"1000000000000\", Equal);\n    test(\"8589934592000000000000\", 33, Up, \"1000000000000\", Equal);\n    test(\"8589934592000000000000\", 33, Floor, \"1000000000000\", Equal);\n    test(\n        \"8589934592000000000000\",\n        33,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"8589934592000000000000\",\n        33,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\"8589934592000000000000\", 33, Exact, \"1000000000000\", Equal);\n\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Down,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Up,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Floor,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Ceiling,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Nearest,\n        \"1000000000000\",\n        Equal,\n    );\n    test(\n        \"1267650600228229401496703205376000000000000\",\n        100,\n        Exact,\n        \"1000000000000\",\n        Equal,\n    );\n\n    test(\"1000000000000\", 10, Down, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Up, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Floor, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Ceiling, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Nearest, \"976562500\", Equal);\n    test(\"1000000000000\", 10, Exact, \"976562500\", Equal);\n\n    test(\"980657949\", 72, Down, \"0\", Less);\n    test(\"980657949\", 72, Up, \"1\", Greater);\n    test(\"980657949\", 72, Floor, \"0\", Less);\n    test(\"980657949\", 72, Ceiling, \"1\", Greater);\n    test(\"980657949\", 72, Nearest, \"0\", Less);\n\n    test(\"4294967295\", 31, Down, \"1\", Less);\n    test(\"4294967295\", 31, Up, \"2\", Greater);\n    test(\"4294967295\", 31, Floor, \"1\", Less);\n    test(\"4294967295\", 31, Ceiling, \"2\", Greater);\n    test(\"4294967295\", 31, Nearest, \"2\", Greater);\n\n    test(\"4294967295\", 32, Down, \"0\", Less);\n    test(\"4294967295\", 32, Up, \"1\", Greater);\n    test(\"4294967295\", 32, Floor, \"0\", Less);\n    test(\"4294967295\", 32, Ceiling, \"1\", Greater);\n    test(\"4294967295\", 32, Nearest, \"1\", Greater);\n\n    test(\"4294967296\", 32, Down, \"1\", Equal);\n    test(\"4294967296\", 32, Up, \"1\", Equal);\n    test(\"4294967296\", 32, Floor, \"1\", Equal);\n    test(\"4294967296\", 32, Ceiling, \"1\", Equal);\n    test(\"4294967296\", 32, Nearest, \"1\", Equal);\n    test(\"4294967296\", 32, Exact, \"1\", Equal);\n\n    test(\"4294967296\", 33, Down, \"0\", Less);\n    test(\"4294967296\", 33, Up, \"1\", Greater);\n    test(\"4294967296\", 33, Floor, \"0\", Less);\n    test(\"4294967296\", 33, Ceiling, \"1\", Greater);\n    test(\"4294967296\", 33, Nearest, \"0\", Less);\n\n    test(\"0\", -10, Exact, \"0\", Equal);\n    test(\"123\", -1, Exact, \"246\", Equal);\n    test(\"123\", -2, Exact, \"492\", Equal);\n    test(\"123\", -25, Exact, \"4127195136\", Equal);\n    test(\"123\", -26, Exact, \"8254390272\", Equal);\n    test(\n        \"123\",\n        -100,\n        Exact,\n        \"155921023828072216384094494261248\",\n        Equal,\n    );\n    test(\"2147483648\", -1, Exact, \"4294967296\", Equal);\n    test(\"1000000000000\", -3, Exact, \"8000000000000\", Equal);\n    test(\"1000000000000\", -24, Exact, \"16777216000000000000\", Equal);\n    test(\"1000000000000\", -25, Exact, \"33554432000000000000\", Equal);\n    test(\"1000000000000\", -31, Exact, \"2147483648000000000000\", Equal);\n    test(\"1000000000000\", -32, Exact, \"4294967296000000000000\", Equal);\n    test(\"1000000000000\", -33, Exact, \"8589934592000000000000\", Equal);\n    test(\n        \"1000000000000\",\n        -100,\n        Exact,\n        \"1267650600228229401496703205376000000000000\",\n        Equal,\n    );\n}\n\n#[test]\nfn test_shr_round_signed() {\n    apply_fn_to_signeds!(test_shr_round_signed_helper);\n}\n\nmacro_rules! shr_round_signed_fail_helper {\n    ($t:ident) => {\n        assert_panic!(Natural::from(123u32).shr_round_assign($t::ONE, Exact));\n        assert_panic!(Natural::from(123u32).shr_round_assign($t::exact_from(100), Exact));\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::ONE, Exact)\n        );\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round_assign($t::exact_from(100), Exact)\n        );\n        assert_panic!(Natural::from(123u32).shr_round($t::ONE, Exact));\n        assert_panic!(Natural::from(123u32).shr_round($t::exact_from(100), Exact));\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round($t::ONE, Exact)\n        );\n        assert_panic!(\n            Natural::from_str(\"1000000000001\")\n                .unwrap()\n                .shr_round($t::exact_from(100), Exact)\n        );\n        assert_panic!((&Natural::from(123u32)).shr_round($t::ONE, Exact));\n        assert_panic!((&Natural::from(123u32)).shr_round($t::exact_from(100), Exact));\n        assert_panic!((&Natural::from_str(\"1000000000001\").unwrap()).shr_round($t::ONE, Exact));\n        assert_panic!(\n            (&Natural::from_str(\"1000000000001\").unwrap()).shr_round($t::exact_from(100), Exact)\n        );\n    };\n}\n\n#[test]\nfn shr_round_signed_fail() {\n    apply_to_signeds!(shr_round_signed_fail_helper);\n}\n\n#[test]\nfn limbs_shr_round_up_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(&config, |(xs, bits)| {\n        let (s, o) = limbs_shr_round_up(&xs, bits);\n        assert_eq!(\n            (Natural::from_owned_limbs_asc(s), o),\n            Natural::from_owned_limbs_asc(xs).shr_round(bits, Up),\n        );\n    });\n}\n\n#[test]\nfn limbs_shr_round_nearest_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, bits)| {\n        let (s, o) = limbs_shr_round_nearest(&xs, bits);\n        assert_eq!(\n            (Natural::from_owned_limbs_asc(s), o),\n            Natural::from_owned_limbs_asc(xs).shr_round(bits, Nearest),\n        );\n    });\n}\n\n#[test]\nfn limbs_shr_exact_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(&config, |(xs, bits)| {\n        let n = Natural::from_limbs_asc(&xs);\n        limbs_shr_exact(&xs, bits).map_or_else(\n            || {\n                assert!(!n.divisible_by_power_of_2(bits));\n            },\n            |result_xs| {\n                let (m, o) = (&n).shr_round(bits, Exact);\n                assert_eq!(Natural::from_owned_limbs_asc(result_xs), m);\n                assert_eq!(m << bits, n);\n                assert_eq!(o, Equal);\n            },\n        );\n    });\n}\n\n#[test]\nfn limbs_shr_round_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().test_properties_with_config(\n        &config,\n        |(xs, bits, rm)| {\n            let n = Natural::from_limbs_asc(&xs);\n            limbs_shr_round(&xs, bits, rm).map_or_else(\n                || {\n                    assert_eq!(rm, Exact);\n                    assert!(!n.divisible_by_power_of_2(bits));\n                },\n                |(result_xs, o)| {\n                    let (m, o_alt) = (&n).shr_round(bits, rm);\n                    assert_eq!(Natural::from_owned_limbs_asc(result_xs), m);\n                    assert_eq!(o, o_alt);\n                    if rm == Exact {\n                        assert_eq!(m << bits, n);\n                    }\n                },\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_shr_round_up_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(\n        &config,\n        |(mut xs, bits)| {\n            let old_xs = xs.clone();\n            let o = limbs_vec_shr_round_up_in_place(&mut xs, bits);\n            let (n, o_alt) = Natural::from_owned_limbs_asc(old_xs).shr_round(bits, Up);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(o, o_alt);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_shr_round_nearest_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut xs, bits)| {\n            let old_xs = xs.clone();\n            let o = limbs_vec_shr_round_nearest_in_place(&mut xs, bits);\n            let (n, o_alt) = Natural::from_owned_limbs_asc(old_xs).shr_round(bits, Nearest);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(o, o_alt);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_shr_exact_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_20().test_properties_with_config(\n        &config,\n        |(mut xs, bits)| {\n            let n = Natural::from_limbs_asc(&xs);\n            if limbs_vec_shr_exact_in_place(&mut xs, bits) {\n                let (m, o) = (&n).shr_round(bits, Exact);\n                assert_eq!(Natural::from_owned_limbs_asc(xs), m);\n                assert_eq!(m << bits, n);\n                assert_eq!(o, Equal);\n            } else {\n                assert!(!n.divisible_by_power_of_2(bits));\n            }\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_shr_round_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_rounding_mode_triple_gen_var_2().test_properties_with_config(\n        &config,\n        |(mut xs, bits, rm)| {\n            let n = Natural::from_limbs_asc(&xs);\n            let (b, o) = limbs_vec_shr_round_in_place(&mut xs, bits, rm);\n            if b {\n                let (m, o_alt) = (&n).shr_round(bits, rm);\n                assert_eq!(Natural::from_owned_limbs_asc(xs), m);\n                assert_eq!(o, o_alt);\n                if rm == Exact {\n                    assert_eq!(m << bits, n);\n                }\n            } else {\n                assert_eq!(rm, Exact);\n                assert!(!n.divisible_by_power_of_2(bits));\n            }\n        },\n    );\n}\n\nfn unsigned_properties<T: PrimitiveUnsigned>()\nwhere\n    Natural: Shl<T, Output = Natural> + ShrRound<T, Output = Natural> + ShrRoundAssign<T>,\n    for<'a> &'a Natural: Shl<T, Output = Natural> + ShrRound<T, Output = Natural>,\n    Limb: ShrRound<T, Output = Limb>,\n{\n    natural_unsigned_rounding_mode_triple_gen_var_1::<T>().test_properties(|(n, u, rm)| {\n        let mut mut_n = n.clone();\n        let o = mut_n.shr_round_assign(u, rm);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let (shifted_alt, o_alt) = (&n).shr_round(u, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o, o_alt);\n\n        let (shifted_alt, o_alt) = n.clone().shr_round(u, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o, o_alt);\n\n        assert!(shifted <= n);\n        let (shifted_alt, o_alt) = (&n).div_round(Natural::ONE << u, rm);\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n        assert_eq!(n.divisible_by_power_of_2(u.exact_into()), o == Equal);\n\n        assert_eq!((shifted << u).cmp(&n), o);\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4::<T>().test_properties(|(n, u)| {\n        let left_shifted = &n << u;\n        let no = (n, Equal);\n        assert_eq!((&left_shifted).shr_round(u, Down), no);\n        assert_eq!((&left_shifted).shr_round(u, Up), no);\n        assert_eq!((&left_shifted).shr_round(u, Floor), no);\n        assert_eq!((&left_shifted).shr_round(u, Ceiling), no);\n        assert_eq!((&left_shifted).shr_round(u, Nearest), no);\n        assert_eq!((&left_shifted).shr_round(u, Exact), no);\n    });\n\n    natural_unsigned_pair_gen_var_10::<T>().test_properties(|(n, u)| {\n        let down = (&n).shr_round(u, Down);\n        let up = (&down.0 + Natural::ONE, Greater);\n        assert_eq!((&n).shr_round(u, Up), up);\n        assert_eq!((&n).shr_round(u, Floor), down);\n        assert_eq!((&n).shr_round(u, Ceiling), up);\n        let nearest = n.shr_round(u, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    unsigned_pair_gen_var_37::<Limb, T>().test_properties(|(u, v)| {\n        if let Some(shift) = v.checked_add(T::exact_from(Limb::WIDTH)) {\n            assert_eq!(\n                Natural::from(u).shr_round(shift, Down),\n                (Natural::ZERO, Less)\n            );\n            assert_eq!(\n                Natural::from(u).shr_round(shift, Floor),\n                (Natural::ZERO, Less)\n            );\n            assert_eq!(\n                Natural::from(u).shr_round(shift, Up),\n                (Natural::ONE, Greater)\n            );\n            assert_eq!(\n                Natural::from(u).shr_round(shift, Ceiling),\n                (Natural::ONE, Greater)\n            );\n            if let Some(extra_shift) = shift.checked_add(T::ONE) {\n                assert_eq!(\n                    Natural::from(u).shr_round(extra_shift, Nearest),\n                    (Natural::ZERO, Less)\n                );\n            }\n        }\n    });\n\n    natural_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).shr_round(T::ZERO, rm), (n, Equal));\n    });\n\n    unsigned_rounding_mode_pair_gen::<T>().test_properties(|(u, rm)| {\n        assert_eq!(Natural::ZERO.shr_round(u, rm), (Natural::ZERO, Equal));\n    });\n\n    unsigned_unsigned_rounding_mode_triple_gen_var_4::<Limb, T>().test_properties(|(n, u, rm)| {\n        let (s, o) = n.shr_round(u, rm);\n        assert_eq!((Natural::from(s), o), Natural::from(n).shr_round(u, rm));\n    });\n}\n\nfn signed_properties<T: PrimitiveSigned>()\nwhere\n    Natural: Shl<T, Output = Natural>\n        + ShlRound<T, Output = Natural>\n        + ShrRound<T, Output = Natural>\n        + ShrRoundAssign<T>,\n    for<'a> &'a Natural: ShlRound<T, Output = Natural> + ShrRound<T, Output = Natural>,\n    Limb: ArithmeticCheckedShr<T, Output = Limb> + ShrRound<T, Output = Limb>,\n{\n    natural_signed_rounding_mode_triple_gen_var_2::<T>().test_properties(|(n, i, rm)| {\n        let mut mut_n = n.clone();\n        let o = mut_n.shr_round_assign(i, rm);\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let (shifted_alt, o_alt) = (&n).shr_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        let (shifted_alt, o_alt) = n.clone().shr_round(i, rm);\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        assert_eq!(o_alt, o);\n\n        if i != T::MIN {\n            let (shifted_alt, o_alt) = (&n).shl_round(-i, rm);\n            assert_eq!(shifted_alt, shifted);\n            assert_eq!(o_alt, o);\n        }\n        assert_eq!(\n            i <= T::ZERO || n.divisible_by_power_of_2(i.exact_into()),\n            o == Equal\n        );\n\n        if i >= T::ZERO {\n            assert_eq!((shifted << i).cmp(&n), o);\n        }\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    natural_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        assert_eq!((&n).shr_round(T::ZERO, rm), (n, Equal));\n    });\n\n    signed_rounding_mode_pair_gen::<T>().test_properties(|(i, rm)| {\n        assert_eq!(Natural::ZERO.shr_round(i, rm), (Natural::ZERO, Equal));\n    });\n\n    unsigned_signed_rounding_mode_triple_gen_var_1::<Limb, T>().test_properties(|(n, i, rm)| {\n        if n.arithmetic_checked_shr(i).is_some() {\n            let (s, o) = n.shr_round(i, rm);\n            assert_eq!((Natural::from(s), o), Natural::from(n).shr_round(i, rm));\n        }\n    });\n}\n\n#[test]\nfn shr_round_properties() {\n    apply_fn_to_unsigneds!(unsigned_properties);\n    apply_fn_to_signeds!(signed_properties);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_sign() {\n    let test = |s, out| {\n        assert_eq!(Natural::from_str(s).unwrap().sign(), out);\n        assert_eq!(rug::Integer::from_str(s).unwrap().cmp0(), out);\n    };\n    test(\"0\", Equal);\n    test(\"123\", Greater);\n    test(\"1000000000000\", Greater);\n}\n\n#[test]\nfn sign_properties() {\n    natural_gen().test_properties(|n| {\n        let sign = n.sign();\n        assert_eq!(rug::Integer::from(&n).cmp0(), sign);\n        assert_ne!(sign, Less);\n        assert_eq!(n.partial_cmp(&0), Some(sign));\n        assert_eq!((-n).sign(), sign.reverse());\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(Natural::from(u).sign(), u.sign());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::sqrt::sqrt_rem_2_newton;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingRoot, CeilingSqrt, CeilingSqrtAssign, CheckedRoot, CheckedSqrt, FloorRoot, FloorSqrt,\n    FloorSqrtAssign, RootRem, ShrRound, SqrtAssignRem, SqrtRem, Square,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::{ExactFrom, JoinHalves};\nuse malachite_base::num::logic::traits::BitAccess;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::logic::traits::LeadingZeros;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    large_type_gen_var_2, unsigned_gen, unsigned_pair_gen_var_31, unsigned_vec_gen_var_1,\n    unsigned_vec_pair_gen_var_4, unsigned_vec_pair_gen_var_5, unsigned_vec_triple_gen_var_28,\n};\nuse malachite_nz::natural::arithmetic::sqrt::{\n    limbs_ceiling_sqrt, limbs_checked_sqrt, limbs_floor_sqrt, limbs_sqrt_helper, limbs_sqrt_rem,\n    limbs_sqrt_rem_helper, limbs_sqrt_rem_helper_scratch_len, limbs_sqrt_rem_to_out,\n    limbs_sqrt_to_out,\n};\nuse malachite_nz::natural::{Natural, limb_to_bit_count};\nuse malachite_nz::platform::{DoubleLimb, Limb, SignedLimb};\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::arithmetic::sqrt::{\n    ceiling_sqrt_binary, checked_sqrt_binary, floor_sqrt_binary, sqrt_rem_binary,\n};\nuse num::BigUint;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_sqrt_rem_2_newton() {\n    fn test(n_hi: Limb, n_lo: Limb, sqrt: Limb, r_hi: bool, r_lo: Limb) {\n        assert_eq!(\n            sqrt_rem_2_newton::<Limb, SignedLimb>(n_hi, n_lo),\n            (sqrt, r_hi, r_lo)\n        );\n        assert_eq!(\n            DoubleLimb::from(sqrt)\n                .square()\n                .checked_add(DoubleLimb::join_halves(Limb::from(r_hi), r_lo))\n                .unwrap(),\n            DoubleLimb::join_halves(n_hi, n_lo)\n        );\n    }\n    // - no adjustment needed\n    test(2000000000, 123, 2930859019, false, 2746357762);\n    test(u32::MAX, 123, 4294967295, true, 122);\n    // - adjustment needed\n    test(1073741825, 0, 2147483648, true, 0);\n}\n\n#[test]\nfn sqrt_rem_2_newton_fail() {\n    assert_panic!(sqrt_rem_2_newton::<Limb, SignedLimb>(1, Limb::MAX));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sqrt_rem_helper() {\n    fn test(old_xs: &[Limb], n: usize, out_out: &[Limb], xs_out: &[Limb], r_hi: bool) {\n        assert!(old_xs.len() >= n << 1);\n        let mut out = vec![0; n];\n        let mut xs = old_xs.to_vec();\n        let mut scratch = vec![0; limbs_sqrt_rem_helper_scratch_len(n)];\n        assert_eq!(\n            limbs_sqrt_rem_helper(&mut out, &mut xs, 0, &mut scratch),\n            r_hi\n        );\n        assert_eq!(out, out_out);\n        assert_eq!(xs, xs_out);\n\n        let x = Natural::from_limbs_asc(&old_xs[..n << 1]);\n        let sqrt = Natural::from_limbs_asc(&out[..n]);\n        let mut rem = Natural::from_limbs_asc(&xs[..n]);\n        if r_hi {\n            rem.set_bit(u64::exact_from(n) << Limb::LOG_WIDTH);\n        }\n        assert_eq!((&x).sqrt_rem(), (sqrt.clone(), rem.clone()));\n        assert_eq!((&sqrt).square() + rem, x);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    }\n    // - h2 == 1\n    // - !q\n    // - r_hi\n    // - h1 == h2\n    // - r_hi >= 0\n    test(\n        &[123, 456, 789, 2000000000],\n        2,\n        &[2012297342, 2930859019],\n        &[1917624951, 2990305571, 2377342468, 942810576],\n        false,\n    );\n    // - !r_hi\n    test(&[0, 0, 0, 1073741824], 2, &[0, 2147483648], &[0; 4], false);\n    // - q\n    // - r_hi < 0\n    test(\n        &[0, 0, 0, 1073741825],\n        2,\n        &[4294967295, 2147483648],\n        &[4294967295, 1, 0, 0],\n        false,\n    );\n    // - h2 > 1\n    // - h1 != h2\n    test(\n        &[0, 0, 0, 0, 0, 1073741824],\n        3,\n        &[0, 0, 2147483648],\n        &[0; 6],\n        false,\n    );\n}\n\n#[test]\nfn limbs_sqrt_rem_helper_fail() {\n    // - out too short\n    assert_panic!({\n        let out = &mut [];\n        let xs = &mut [1, 2, 3];\n        let mut scratch = vec![0; limbs_sqrt_rem_helper_scratch_len(out.len())];\n        limbs_sqrt_rem_helper(out, xs, 0, &mut scratch)\n    });\n\n    // - xs too short\n    assert_panic!({\n        let out = &mut [1, 2, 3];\n        let xs = &mut [1, 2, 3, 4, Limb::MAX];\n        let mut scratch = vec![0; limbs_sqrt_rem_helper_scratch_len(out.len())];\n        limbs_sqrt_rem_helper(out, xs, 0, &mut scratch)\n    });\n\n    // - (2 * n - 1)th element of xs too small\n    assert_panic!({\n        let out = &mut [1, 2, 3];\n        let xs = &mut [1, 2, 3, 4, 5, 6];\n        let mut scratch = vec![0; limbs_sqrt_rem_helper_scratch_len(out.len())];\n        limbs_sqrt_rem_helper(out, xs, 0, &mut scratch)\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sqrt_helper() {\n    fn test(xs: &[Limb], out_out: &[Limb], has_remainder: bool) {\n        let n = xs.len().shr_round(1, Ceiling).0;\n        let odd = xs.len().odd();\n        let shift = LeadingZeros::leading_zeros(*xs.last().unwrap()) >> 1;\n        let mut out = vec![0; n];\n        assert_eq!(limbs_sqrt_helper(&mut out, xs, shift, odd), has_remainder);\n        assert_eq!(out, out_out);\n\n        let x = Natural::from_limbs_asc(xs);\n        let sqrt = Natural::from_limbs_asc(&out);\n        let (sqrt_alt, rem) = (&x).sqrt_rem();\n        assert_eq!(sqrt, sqrt_alt);\n        assert_eq!(has_remainder, rem != 0);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    }\n    // - shift != 0 first time\n    // - !q\n    // - qs_last != 0 <= 1\n    // - (*qs_head >> 3) | qs_tail[0].mod_power_of_2(Limb::WIDTH - s) != 0\n    // - odd == 1 || shift != 0\n    test(\n        &[1, 2, 3, 4, 5, 6, 7, 8, 9],\n        &[406519538, 874900746, 1431655766, 1, 3],\n        true,\n    );\n    // - q\n    test(\n        &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n        &[1984678003, 1990369149, 2938805076, 123516853, 207243],\n        true,\n    );\n    // - (*qs_head >> 3) | qs_tail[0].mod_power_of_2(Limb::WIDTH - s) == 0\n    // - cmp != Less first time\n    // - slice_test_zero(&scratch_hi[h1 + 1..h2 + 1])\n    // - cmp == Equal\n    // - shift != 0 second time\n    // - cmp != Less second time\n    test(&[0, 0, 0, 0, 0, 0, 0, 0, 1], &[0, 0, 0, 0, 1], false);\n    // - !slice_test_zero(&scratch_hi[h1 + 1..h2 + 1])\n    test(\n        &[0, 0, 0, 0, 0, 0, 0, 1, 0, 1],\n        &[4294959104, 4294967295, 32767, 0, 65536],\n        true,\n    );\n    // - cmp != Equal\n    // - cmp == Less second time\n    test(\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1],\n        &[4095, 0, 4294959104, 4294967295, 32767, 0, 65536],\n        true,\n    );\n    // - shift == 0 first time\n    // - odd == 0 && shift == 0\n    test(\n        &[\n            2193991530, 2899278504, 3717617329, 1249076698, 879590153, 4210532297, 3303769392,\n            1147691304, 3624392894, 1881877405, 1728780505, 931615955, 1096404509, 1326003135,\n            370549396, 1987183422, 851586836, 2796582944, 2985872407, 2598301166, 356639089,\n            2071312376, 1106184443, 3682669872, 1019062633, 3091583269, 502719907, 1700144765,\n            1387866140, 1704631346, 2770368441, 1350352297,\n        ],\n        &[\n            1761794912, 1811046967, 2629492573, 855368414, 1733978088, 3870361288, 2771154681,\n            1755982555, 443586875, 4077786862, 37569597, 1268220478, 2132005861, 2264846737,\n            2419409154, 2408260566,\n        ],\n        true,\n    );\n    // - qs_last != 0 > 1\n    test(\n        &[\n            4294967295, 4194303, 0, 0, 3758096384, 4294967295, 4294967295, 4294967295, 4294967295,\n            4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n            4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n        ],\n        &[\n            4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n            4294967295, 4294967295, 4294967295, 65535,\n        ],\n        true,\n    );\n    // - shift == 0 second time\n    test(\n        &[\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 4294966784, 4294967295, 4294967295, 4294967295, 4294967295,\n            4294967295, 4294967295, 4294967295,\n        ],\n        &[\n            4278190079, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n            4294967295, 65535,\n        ],\n        true,\n    );\n    // - cmp == Less first time\n    test(\n        &[\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4294967232, 4294967295, 4294967295,\n            4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n            2147483679, 16777215, 0, 0, 0, 0, 4294967040, 4294967295, 4294967295, 4294967295,\n            4294967295, 4294967295,\n        ],\n        &[\n            4293920767, 1073741791, 0, 0, 0, 0, 3221217296, 8388607, 0, 0, 0, 0, 4294967168,\n            4294967295, 4294967295, 4294967295, 4294967295, 4294967295,\n        ],\n        true,\n    );\n}\n\n#[test]\nfn limbs_sqrt_helper_fail() {\n    // - out too short\n    assert_panic!({\n        let out = &mut [1, 2, 3, 4];\n        let xs = &mut [Limb::MAX; 8];\n        limbs_sqrt_helper(out, xs, 0, false);\n    });\n    // - last element of xs is 0\n    assert_panic!({\n        let out = &mut [1, 2, 3, 4, 5];\n        let xs = &mut [10, 10, 10, 10, 10, 10, 10, 10, 10, 0];\n        limbs_sqrt_helper(out, xs, 15, false);\n    });\n    // - shift too high\n    assert_panic!({\n        let out = &mut [1, 2, 3, 4, 5];\n        let xs = &mut [Limb::MAX; 10];\n        limbs_sqrt_helper(out, xs, 16, false);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sqrt_to_out() {\n    fn test(xs: &[Limb], out_out: &[Limb]) {\n        let xs_len = xs.len();\n        let mut out = vec![0; xs_len.shr_round(1, Ceiling).0];\n        limbs_sqrt_to_out(&mut out, xs);\n        assert_eq!(out, out_out);\n        let x = Natural::from_limbs_asc(xs);\n        let sqrt = Natural::from_owned_limbs_asc(out);\n        assert_eq!((&x).floor_sqrt(), sqrt);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    }\n    // - shift != 0\n    // - xs_len == 1\n    // - xs_len == 1 && shift != 0\n    test(&[1], &[1]);\n    // - shift == 0\n    // - xs_len == 1 && shift == 0\n    test(&[4000000000], &[63245]);\n    // - xs_len == 2\n    // - xs_len == 2 && shift != 0\n    test(&[1, 2], &[92681]);\n    // - xs_len == 2 && shift == 0\n    test(&[1, 4000000000], &[4144860574]);\n    // - xs_len > 2\n    // - 2 < xs_len <= 8\n    // - xs_len.odd() || shift != 0\n    // - xs_len > 2 && shift == 0\n    // - tn > 1\n    test(&[1, 2, 3], &[3144134278, 1]);\n    // - xs_len > 2 && shift != 0\n    test(&[1, 2, 4000000000], &[2375990371, 63245]);\n    // - xs_len > 8\n    test(\n        &[\n            2572912965, 1596092594, 2193991530, 2899278504, 3717617329, 1249076698, 879590153,\n            4210532297, 3303769392, 1147691304, 3624392894,\n        ],\n        &[3491190173, 18317336, 2518787533, 3220458996, 3998374718, 60202],\n    );\n    // - xs_len.even() && shift == 0\n    test(\n        &[345016311, 2711392466, 1490697280, 1246394087],\n        &[2306404477, 2313703058],\n    );\n}\n\n#[test]\nfn limbs_sqrt_to_out_fail() {\n    // - xs empty\n    assert_panic!({\n        let out = &mut [1, 2, 3];\n        let xs = &mut [];\n        limbs_sqrt_to_out(out, xs);\n    });\n    // - out too short\n    assert_panic!({\n        let out = &mut [1, 2, 3];\n        let xs = &mut [Limb::MAX; 8];\n        limbs_sqrt_to_out(out, xs);\n    });\n    // - last element of xs is 0\n    assert_panic!({\n        let out = &mut [1, 2, 3];\n        let xs = &mut [1, 2, 3, 4, 5, 0];\n        limbs_sqrt_to_out(out, xs);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sqrt_rem_to_out() {\n    fn test(xs: &[Limb], out_out_sqrt: &[Limb], out_out_rem: &[Limb]) {\n        let xs_len = xs.len();\n        let mut out_sqrt = vec![0; xs_len.shr_round(1, Ceiling).0];\n        let mut out_rem = vec![0; xs_len];\n        let rem_len = limbs_sqrt_rem_to_out(&mut out_sqrt, &mut out_rem, xs);\n        assert_eq!(out_sqrt, out_out_sqrt);\n        assert_eq!(&out_rem[..rem_len], out_out_rem);\n        let x = Natural::from_limbs_asc(xs);\n        let sqrt = Natural::from_owned_limbs_asc(out_sqrt);\n        let rem = Natural::from_limbs_asc(&out_rem[..rem_len]);\n        let (sqrt_alt, rem_alt) = (&x).sqrt_rem();\n        assert_eq!(sqrt_alt, sqrt);\n        assert_eq!(rem_alt, rem);\n        assert_eq!((&sqrt).square() + &rem, x);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    }\n    // - shift != 0\n    // - xs_len == 1\n    // - xs_len == 1 && shift != 0\n    test(&[1], &[1], &[]);\n    // - shift == 0\n    // - xs_len == 1 && shift == 0\n    test(&[4000000000], &[63245], &[69975]);\n    // - xs_len == 2\n    // - xs_len == 2 && shift != 0\n    test(&[1, 2], &[92681], &[166832]);\n    // - xs_len == 2 && shift == 0\n    test(&[1, 4000000000], &[4144860574], &[1805423229, 1]);\n    // - xs_len > 2\n    // - xs_len.odd() || shift != 0\n    // - xs_len > 2 && shift != 0 first time\n    // - shift >= Limb::WIDTH\n    // - xs_len > 2 && shift != 0 second time\n    test(&[1, 2, 3], &[3144134278, 1], &[1429311965, 0]);\n    // - xs_len > 2 && shift == 0 first time\n    // - xs_len > 2 && shift == 0 second time\n    test(\n        &[1, 2, 4000000000],\n        &[2375990371, 63245],\n        &[3710546360, 103937],\n    );\n    // - xs_len.even() && shift == 0\n    test(\n        &[2977742827, 3919053323, 1548431690, 1948915452],\n        &[733991603, 2893186501],\n        &[2063111874, 210353161, 1],\n    );\n    // - shift < Limb::WIDTH\n    test(\n        &[\n            1347797001, 1439220470, 2750411815, 3145460224, 3430380546, 2707019846, 2327263540,\n            551116682,\n        ],\n        &[1077346225, 1488699754, 3604020692, 1538514909],\n        &[4064782248, 3993147064, 4166228975, 2172636662, 0],\n    );\n}\n\n#[test]\nfn limbs_sqrt_rem_to_out_fail() {\n    // - xs empty\n    assert_panic!({\n        let out_sqrt = &mut [1, 2, 3];\n        let out_rem = &mut [0; 8];\n        let xs = &mut [];\n        limbs_sqrt_rem_to_out(out_sqrt, out_rem, xs);\n    });\n    // - out too short\n    assert_panic!({\n        let out_sqrt = &mut [1, 2, 3];\n        let out_rem = &mut [0; 8];\n        let xs = &mut [Limb::MAX; 8];\n        limbs_sqrt_rem_to_out(out_sqrt, out_rem, xs);\n    });\n    // - rem too short\n    assert_panic!({\n        let out_sqrt = &mut [1, 2, 3, 4];\n        let out_rem = &mut [0; 7];\n        let xs = &mut [Limb::MAX; 8];\n        limbs_sqrt_rem_to_out(out_sqrt, out_rem, xs);\n    });\n    // - last element of xs is 0\n    assert_panic!({\n        let out_sqrt = &mut [1, 2, 3];\n        let out_rem = &mut [0; 6];\n        let xs = &mut [1, 2, 3, 4, 5, 0];\n        limbs_sqrt_rem_to_out(out_sqrt, out_rem, xs);\n    });\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_floor_sqrt() {\n    fn test(xs: &[Limb], out: &[Limb]) {\n        assert_eq!(limbs_floor_sqrt(xs), out);\n    }\n    test(&[1, 2, 3], &[3144134278, 1]);\n}\n\n#[test]\nfn limbs_floor_sqrt_fail() {\n    // - xs empty\n    assert_panic!(limbs_floor_sqrt(&[]));\n    // - last element of xs is 0\n    assert_panic!(limbs_floor_sqrt(&[1, 2, 0]));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_ceiling_sqrt() {\n    fn test(xs: &[Limb], out: &[Limb]) {\n        assert_eq!(limbs_ceiling_sqrt(xs), out);\n    }\n    test(&[1, 2, 3], &[3144134279, 1]);\n}\n\n#[test]\nfn limbs_ceiling_sqrt_fail() {\n    // - xs empty\n    assert_panic!(limbs_ceiling_sqrt(&[]));\n    // - last element of xs is 0\n    assert_panic!(limbs_ceiling_sqrt(&[1, 2, 0]));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_checked_sqrt() {\n    fn test(xs: &[Limb], out: Option<&[Limb]>) {\n        assert_eq!(limbs_checked_sqrt(xs), out.map(<[Limb]>::to_vec));\n    }\n    test(&[1, 2, 3], None);\n    test(&[0, 0, 1], Some(&[0, 1]));\n}\n\n#[test]\nfn limbs_checked_sqrt_fail() {\n    // - xs empty\n    assert_panic!(limbs_checked_sqrt(&[]));\n    // - last element of xs is 0\n    assert_panic!(limbs_checked_sqrt(&[1, 2, 0]));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sqrt_rem() {\n    fn test(xs: &[Limb], out_sqrt: &[Limb], out_rem: &[Limb]) {\n        let (sqrt, rem) = limbs_sqrt_rem(xs);\n        assert_eq!(sqrt, out_sqrt);\n        assert_eq!(rem, out_rem);\n    }\n    test(&[1, 2, 3], &[3144134278, 1], &[1429311965, 0]);\n}\n\n#[test]\nfn limbs_sqrt_rem_fail() {\n    // - xs empty\n    assert_panic!(limbs_sqrt_rem(&[]));\n    // - last element of xs is 0\n    assert_panic!(limbs_sqrt_rem(&[1, 2, 0]));\n}\n\n#[test]\nfn test_floor_sqrt() {\n    let test = |s, out| {\n        let n = Natural::from_str(s).unwrap();\n        assert_eq!(n.clone().floor_sqrt().to_string(), out);\n        assert_eq!((&n).floor_sqrt().to_string(), out);\n        assert_eq!(floor_sqrt_binary(&n).to_string(), out);\n\n        let mut n = n;\n        n.floor_sqrt_assign();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"2\", \"1\");\n    test(\"3\", \"1\");\n    test(\"4\", \"2\");\n    test(\"5\", \"2\");\n    test(\"10\", \"3\");\n    test(\"100\", \"10\");\n    test(\"1000000000\", \"31622\");\n    test(\"152415765279683\", \"12345677\");\n    test(\"152415765279684\", \"12345678\");\n    test(\"152415765279685\", \"12345678\");\n    test(\n        \"10000000000000000000000000000000000000000\",\n        \"100000000000000000000\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000\",\n        \"316227766016837933199\",\n    );\n}\n\n#[test]\nfn test_ceiling_sqrt() {\n    let test = |s, out| {\n        let n = Natural::from_str(s).unwrap();\n        assert_eq!(n.clone().ceiling_sqrt().to_string(), out);\n        assert_eq!((&n).ceiling_sqrt().to_string(), out);\n        assert_eq!(ceiling_sqrt_binary(&n).to_string(), out);\n\n        let mut n = n;\n        n.ceiling_sqrt_assign();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"2\", \"2\");\n    test(\"3\", \"2\");\n    test(\"4\", \"2\");\n    test(\"5\", \"3\");\n    test(\"10\", \"4\");\n    test(\"100\", \"10\");\n    test(\"1000000000\", \"31623\");\n    test(\"152415765279683\", \"12345678\");\n    test(\"152415765279684\", \"12345678\");\n    test(\"152415765279685\", \"12345679\");\n    test(\n        \"10000000000000000000000000000000000000000\",\n        \"100000000000000000000\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000\",\n        \"316227766016837933200\",\n    );\n}\n\n#[allow(clippy::redundant_closure_for_method_calls)]\n#[test]\nfn test_checked_sqrt() {\n    let test = |s, out: Option<&str>| {\n        let n = Natural::from_str(s).unwrap();\n        let out = out.map(|s| s.to_string());\n\n        assert_eq!(n.clone().checked_sqrt().map(|x| x.to_string()), out);\n        assert_eq!((&n).checked_sqrt().map(|x| x.to_string()), out);\n        assert_eq!(checked_sqrt_binary(&n).map(|x| x.to_string()), out);\n    };\n    test(\"0\", Some(\"0\"));\n    test(\"1\", Some(\"1\"));\n    test(\"2\", None);\n    test(\"3\", None);\n    test(\"4\", Some(\"2\"));\n    test(\"5\", None);\n    test(\"10\", None);\n    test(\"100\", Some(\"10\"));\n    test(\"1000000000\", None);\n    test(\"152415765279683\", None);\n    test(\"152415765279684\", Some(\"12345678\"));\n    test(\"152415765279685\", None);\n    test(\n        \"10000000000000000000000000000000000000000\",\n        Some(\"100000000000000000000\"),\n    );\n    test(\"100000000000000000000000000000000000000000\", None);\n}\n\n#[test]\nfn test_sqrt_rem() {\n    let test = |s, sqrt_out, rem_out| {\n        let n = Natural::from_str(s).unwrap();\n\n        let (sqrt, rem) = n.clone().sqrt_rem();\n        assert_eq!(sqrt.to_string(), sqrt_out);\n        assert_eq!(rem.to_string(), rem_out);\n\n        let (sqrt, rem) = (&n).sqrt_rem();\n        assert_eq!(sqrt.to_string(), sqrt_out);\n        assert_eq!(rem.to_string(), rem_out);\n\n        let (sqrt, rem) = sqrt_rem_binary(&n);\n        assert_eq!(sqrt.to_string(), sqrt_out);\n        assert_eq!(rem.to_string(), rem_out);\n\n        let mut n = n;\n        assert_eq!(n.sqrt_assign_rem().to_string(), rem_out);\n        assert_eq!(n.to_string(), sqrt_out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"2\", \"1\", \"1\");\n    test(\"3\", \"1\", \"2\");\n    test(\"4\", \"2\", \"0\");\n    test(\"5\", \"2\", \"1\");\n    test(\"10\", \"3\", \"1\");\n    test(\"100\", \"10\", \"0\");\n    test(\"1000000000\", \"31622\", \"49116\");\n    test(\"152415765279683\", \"12345677\", \"24691354\");\n    test(\"152415765279684\", \"12345678\", \"0\");\n    test(\"152415765279685\", \"12345678\", \"1\");\n    test(\n        \"10000000000000000000000000000000000000000\",\n        \"100000000000000000000\",\n        \"0\",\n    );\n    test(\n        \"100000000000000000000000000000000000000000\",\n        \"316227766016837933199\",\n        \"562477137586013626399\",\n    );\n}\n\n#[test]\nfn sqrt_rem_2_newton_properties() {\n    unsigned_pair_gen_var_31().test_properties(|(n_hi, n_lo)| {\n        let (sqrt, r_hi, r_lo) = sqrt_rem_2_newton::<Limb, SignedLimb>(n_hi, n_lo);\n        assert_eq!(\n            DoubleLimb::from(sqrt)\n                .square()\n                .checked_add(DoubleLimb::join_halves(Limb::from(r_hi), r_lo))\n                .unwrap(),\n            DoubleLimb::join_halves(n_hi, n_lo)\n        );\n    });\n}\n\n#[test]\nfn limbs_sqrt_rem_helper_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_4().test_properties_with_config(&config, |(mut out, mut xs)| {\n        let n = out.len();\n        let mut scratch = vec![0; limbs_sqrt_rem_helper_scratch_len(n)];\n        let old_xs = xs.clone();\n        let r_hi = limbs_sqrt_rem_helper(&mut out, &mut xs, 0, &mut scratch);\n        let x = Natural::from_limbs_asc(&old_xs[..n << 1]);\n        let sqrt = Natural::from_limbs_asc(&out);\n        let mut rem = Natural::from_limbs_asc(&xs[..n]);\n        if r_hi {\n            rem.set_bit(limb_to_bit_count(n));\n        }\n        assert_eq!((&x).sqrt_rem(), (sqrt.clone(), rem.clone()));\n        assert_eq!((&sqrt).square() + rem, x);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    });\n}\n\n#[test]\nfn limbs_sqrt_helper_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_2().test_properties_with_config(&config, |(mut out, xs, shift, odd)| {\n        let has_remainder = limbs_sqrt_helper(&mut out, &xs, shift, odd);\n        let x = Natural::from_limbs_asc(&xs);\n        let sqrt = Natural::from_limbs_asc(&out);\n        let (sqrt_alt, rem) = (&x).sqrt_rem();\n        assert_eq!(sqrt, sqrt_alt);\n        assert_eq!(has_remainder, rem != 0);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    });\n}\n\n#[test]\nfn limbs_sqrt_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_5().test_properties_with_config(&config, |(mut out, xs)| {\n        limbs_sqrt_to_out(&mut out, &xs);\n        let xs_len = xs.len();\n        let sqrt_len = xs_len.shr_round(1, Ceiling).0;\n        let x = Natural::from_limbs_asc(&xs);\n        let sqrt = Natural::from_limbs_asc(&out[..sqrt_len]);\n        assert_eq!((&x).floor_sqrt(), sqrt);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    });\n}\n\n#[test]\nfn limbs_sqrt_rem_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_28().test_properties_with_config(\n        &config,\n        |(mut out_sqrt, mut out_rem, xs)| {\n            let rem_len = limbs_sqrt_rem_to_out(&mut out_sqrt, &mut out_rem, &xs);\n            let xs_len = xs.len();\n            let sqrt_len = xs_len.shr_round(1, Ceiling).0;\n            let x = Natural::from_limbs_asc(&xs);\n            let sqrt = Natural::from_limbs_asc(&out_sqrt[..sqrt_len]);\n            let rem = Natural::from_limbs_asc(&out_rem[..rem_len]);\n            let (sqrt_alt, rem_alt) = (&x).sqrt_rem();\n            assert_eq!(sqrt_alt, sqrt);\n            assert_eq!(rem_alt, rem);\n            assert_eq!((&sqrt).square() + &rem, x);\n            assert!((&sqrt).square() <= x);\n            assert!((sqrt + Natural::ONE).square() > x);\n        },\n    );\n}\n\n#[test]\nfn limbs_floor_sqrt_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let sqrt = Natural::from_owned_limbs_asc(limbs_floor_sqrt(&xs));\n        let x = Natural::from_owned_limbs_asc(xs);\n        assert_eq!((&x).floor_sqrt(), sqrt);\n        assert!((&sqrt).square() <= x);\n        assert!((sqrt + Natural::ONE).square() > x);\n    });\n}\n\n#[test]\nfn limbs_ceiling_sqrt_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let sqrt = Natural::from_owned_limbs_asc(limbs_ceiling_sqrt(&xs));\n        let x = Natural::from_owned_limbs_asc(xs);\n        assert_eq!((&x).ceiling_sqrt(), sqrt);\n        assert!((&sqrt).square() >= x);\n        assert!((sqrt - Natural::ONE).square() < x);\n    });\n}\n\n#[test]\nfn limbs_checked_sqrt_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let sqrt = limbs_checked_sqrt(&xs).map(Natural::from_owned_limbs_asc);\n        let x = Natural::from_owned_limbs_asc(xs);\n        assert_eq!((&x).checked_sqrt(), sqrt);\n        if let Some(sqrt) = sqrt {\n            assert_eq!(sqrt.square(), x);\n        }\n    });\n}\n\n#[test]\nfn limbs_sqrt_rem_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let (sqrt, rem) = limbs_sqrt_rem(&xs);\n        let sqrt = Natural::from_owned_limbs_asc(sqrt);\n        let rem = Natural::from_owned_limbs_asc(rem);\n        let x = Natural::from_owned_limbs_asc(xs);\n        assert_eq!((&sqrt).square() + &rem, x);\n        assert_eq!((&x).sqrt_rem(), (sqrt, rem));\n    });\n}\n\n#[test]\nfn floor_sqrt_properties() {\n    natural_gen().test_properties(|n| {\n        let sqrt = n.clone().floor_sqrt();\n        assert_eq!((&n).floor_sqrt(), sqrt);\n        let mut n_alt = n.clone();\n        n_alt.floor_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(floor_sqrt_binary(&n), sqrt);\n        assert_eq!((&n).floor_root(2), sqrt);\n        assert_eq!(Natural::from(&BigUint::from(&n).sqrt()), sqrt);\n        assert_eq!(Natural::exact_from(&rug::Integer::from(&n).sqrt()), sqrt);\n\n        let square = (&sqrt).square();\n        let ceiling_sqrt = (&n).ceiling_sqrt();\n        if square == n {\n            assert_eq!(ceiling_sqrt, sqrt);\n        } else {\n            assert_eq!(ceiling_sqrt, &sqrt + Natural::ONE);\n        }\n        assert!(square <= n);\n        assert!((sqrt + Natural::ONE).square() > n);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.floor_sqrt(), Natural::from(u).floor_sqrt());\n    });\n}\n\n#[test]\nfn ceiling_sqrt_properties() {\n    natural_gen().test_properties(|n| {\n        let sqrt = n.clone().ceiling_sqrt();\n        assert_eq!((&n).ceiling_sqrt(), sqrt);\n        let mut n_alt = n.clone();\n        n_alt.ceiling_sqrt_assign();\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(ceiling_sqrt_binary(&n), sqrt);\n        assert_eq!((&n).ceiling_root(2), sqrt);\n        let square = (&sqrt).square();\n        let floor_sqrt = (&n).floor_sqrt();\n        if square == n {\n            assert_eq!(floor_sqrt, sqrt);\n        } else {\n            assert_eq!(floor_sqrt, &sqrt - Natural::ONE);\n        }\n        assert!(square >= n);\n        if n != 0 {\n            assert!((sqrt - Natural::ONE).square() < n);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.ceiling_sqrt(), Natural::from(u).ceiling_sqrt());\n    });\n}\n\n#[test]\nfn checked_sqrt_properties() {\n    natural_gen().test_properties(|n| {\n        let sqrt = n.clone().checked_sqrt();\n        assert_eq!((&n).checked_sqrt(), sqrt);\n        assert_eq!(checked_sqrt_binary(&n), sqrt);\n        assert_eq!((&n).checked_root(2), sqrt);\n        if let Some(sqrt) = sqrt {\n            assert_eq!((&sqrt).square(), n);\n            assert_eq!((&n).floor_sqrt(), sqrt);\n            assert_eq!(n.ceiling_sqrt(), sqrt);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(\n            u.checked_sqrt().map(Natural::from),\n            Natural::from(u).checked_sqrt()\n        );\n    });\n}\n\n#[test]\nfn sqrt_rem_properties() {\n    natural_gen().test_properties(|n| {\n        let (sqrt, rem) = n.clone().sqrt_rem();\n        assert_eq!((&n).sqrt_rem(), (sqrt.clone(), rem.clone()));\n        let mut n_alt = n.clone();\n        assert_eq!(n_alt.sqrt_assign_rem(), rem);\n        assert_eq!(n_alt, sqrt);\n        assert_eq!(sqrt_rem_binary(&n), (sqrt.clone(), rem.clone()));\n        assert_eq!((&n).root_rem(2), (sqrt.clone(), rem.clone()));\n        let (rug_sqrt, rug_rem) = rug::Integer::from(&n).sqrt_rem(rug::Integer::new());\n        assert_eq!(Natural::exact_from(&rug_sqrt), sqrt);\n        assert_eq!(Natural::exact_from(&rug_rem), rem);\n\n        assert_eq!((&n).floor_sqrt(), sqrt);\n        assert!(rem <= &sqrt << 1);\n        assert_eq!(sqrt.square() + rem, n);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        let (sqrt, rem) = u.sqrt_rem();\n        assert_eq!(\n            (Natural::from(sqrt), Natural::from(rem)),\n            Natural::from(u).sqrt_rem()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase, CheckedLogBase2, CheckedSqrt, PowerOf2, Square, SquareAssign,\n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::test_util::common::rle_decode;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_gen_var_21;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::square::{\n    limbs_square_to_out_basecase, limbs_square_to_out_toom_4,\n    limbs_square_to_out_toom_4_scratch_len, limbs_square_to_out_toom_6,\n    limbs_square_to_out_toom_6_scratch_len, limbs_square_to_out_toom_8,\n    limbs_square_to_out_toom_8_scratch_len,\n};\nuse malachite_nz::natural::arithmetic::square::{\n    limbs_square_to_out_toom_2, limbs_square_to_out_toom_2_scratch_len, limbs_square_to_out_toom_3,\n    limbs_square_to_out_toom_3_scratch_len,\n};\nuse malachite_nz::platform::Limb;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_nz::platform::SQR_TOOM2_THRESHOLD;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_pair_gen, unsigned_vec_pair_gen_var_22, unsigned_vec_pair_gen_var_23,\n    unsigned_vec_pair_gen_var_24, unsigned_vec_pair_gen_var_25, unsigned_vec_pair_gen_var_27,\n    unsigned_vec_pair_gen_var_28,\n};\nuse malachite_nz::test_util::natural::arithmetic::square::limbs_square_to_out_basecase_unrestricted;\nuse std::str::FromStr;\n\nfn limbs_square_basecase_helper_1(\n    out_before: &[Limb],\n    xs: &[Limb],\n    out_after: &[Limb],\n) -> Vec<Limb> {\n    let mut out = out_before.to_vec();\n    let old_out = out.clone();\n    limbs_square_to_out_basecase_unrestricted(&mut out, xs);\n    assert_eq!(out, out_after);\n    let n = Natural::from_limbs_asc(xs).square();\n    let len = xs.len() << 1;\n    let mut limbs = n.into_limbs_asc();\n    limbs.resize(len, 0);\n    assert_eq!(limbs, &out[..len]);\n    assert_eq!(&out[len..], &old_out[len..]);\n    out\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_square_to_out_basecase() {\n    let test = |out_before: &[Limb], xs: &[Limb], out_after: &[Limb]| {\n        limbs_square_basecase_helper_1(out_before, xs, out_after);\n        let mut out = out_before.to_vec();\n        limbs_square_to_out_basecase(&mut out, xs);\n        assert_eq!(out, out_after);\n    };\n    test(&[10; 3], &[0], &[0, 0, 10]);\n    test(&[10; 3], &[5], &[25, 0, 10]);\n    test(&[10; 6], &[1, 2, 3], &[1, 4, 10, 12, 9, 0]);\n    test(\n        &[10; 6],\n        &[u32::MAX, u32::MAX],\n        &[1, 0, u32::MAX - 1, u32::MAX, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_basecase_fail_1() {\n    let mut out = vec![10; 3];\n    limbs_square_to_out_basecase(&mut out, &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_basecase_fail_2() {\n    let mut out = vec![10; 3];\n    limbs_square_to_out_basecase(&mut out, &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_basecase_fail_3() {\n    let mut out = vec![0; (SQR_TOOM2_THRESHOLD + 1) << 1];\n    limbs_square_to_out_basecase(&mut out, &[10; SQR_TOOM2_THRESHOLD + 1]);\n}\n\n#[test]\nfn test_limbs_square_to_out_toom_2() {\n    let test = |xs: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        limbs_square_basecase_helper_1(out_before, xs, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_square_to_out_toom_2_scratch_len(xs.len())];\n        limbs_square_to_out_toom_2(&mut out, xs, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        test(&[0, 0], &[10; 5], &[0, 0, 0, 0, 10]);\n        // - s == n\n        // - limbs_cmp_same_length(&a0[..n], &a1[..n]) != Less\n        // - !TOOM2MAYBE_SQR_TOOM2 || a.len() < SQR_TOOM2_THRESHOLD in\n        //   limbs_square_to_out_toom_2recursive\n        // - cy <= 2\n        test(&[1, 1], &[10; 5], &[1, 2, 1, 0, 10]);\n        // - limbs_cmp_same_length(&a0[..n], &a1[..n]) == Less\n        test(&[123, 456], &[10; 5], &[15129, 112176, 207936, 0, 10]);\n        // - s != n\n        // - a0[s] == 0 && limbs_cmp_same_length(&a0[..s], &a1[..s]) == Less\n        test(&[0, 0, 1], &[0, 0, 0, 0, 0, 0], &[0, 0, 0, 0, 1, 0]);\n        // - !(a0[s] == 0 && limbs_cmp_same_length(&a0[..s], &a1[..s]) == Less)\n        test(&[0, 1, 1], &[0, 0, 0, 0, 0, 0], &[0, 0, 1, 2, 1, 0]);\n        // - TOOM2MAYBE_SQR_TOOM2 && a.len() >= SQR_TOOM2_THRESHOLD in\n        //   limbs_square_to_out_toom_2recursive\n        test(\n            &[\n                315937763, 473311027, 567550122, 1916950171, 4059671672, 732330624, 3931833255,\n                435611156, 3441308858, 1231108682, 571470188, 1643911325, 1855842520, 890506741,\n                4051150309, 1624118035, 4095320898, 832808382, 254544287, 367192823, 3029770132,\n                2530961358, 168199720, 556928054, 3574899773, 901884181, 3037235269, 2537532649,\n                3638603141, 3105834733, 756731319, 2666260459, 3459942852, 3113152432, 2490378291,\n                2524064262, 2837473716, 970558109, 1280992412, 3025351268, 1176324257, 3832993853,\n                2960008574, 143054238, 2025124021, 3355284231, 3700222977, 959518197, 836633203,\n                1753652842, 3863610502, 3683672960, 2678694928, 3768243585, 2643427081, 2597841461,\n                809616697, 2770459249, 938499903, 2306605358, 806972689, 462004905, 1559140947,\n                880982517, 4000827930, 1625323545, 2071445194, 3924145010, 3049042401, 3015341713,\n                2642970230, 680495934, 3572593922, 3776563282, 3584817478, 1511664158, 1048142251,\n                1261635752, 2674531050, 1166719307, 3811800408, 3532080230, 853430491, 2558475297,\n                2417944189, 3094847515, 654669385, 2934541460, 2625633289, 4100222514, 1517941214,\n                3805734203, 3486264903, 2658767168, 1176863503, 2377983813, 4010981779, 1334807591,\n                3581560372, 231495094, 2680779981, 953071754, 1140610841, 4139855852, 515631497,\n                845705671, 505532954, 1555952001, 1319192795, 523566796, 738834566, 2397343480,\n                3709100568, 2754977717, 2105634100, 2622287225, 3069665844, 1499378188, 1024995116,\n                529523547, 1573018435, 2475374120, 3949433831, 748808472, 1404353612, 3021083538,\n                1713559320, 706538487, 1788875531, 3976761851, 1912518906, 3712335343, 3425283422,\n                281500646, 1572406350, 108746052, 4056047843, 89307364, 1006007374, 2902260577,\n                1250995384, 1556873818, 3846421711, 280743259, 1728158805, 467926284, 2330565417,\n                1366395459, 474848905, 1190711031, 4146575846, 1359337485, 277106601, 611834097,\n                4135958043, 2404499652, 3266860581, 4084179847, 1694432029, 2659591080, 438254541,\n                2191377959, 2215296842, 4215722030, 1219192120, 2382641840, 3275049666, 1893229486,\n                3003341825, 1385119378, 491641953, 3636318537, 409287515, 1702143228, 3653042335,\n                2210372129, 3091759374, 3445226074, 283146383, 1663694381, 1455499100, 306155088,\n                3031133107, 30443875, 336170015, 3291741077, 1240501199, 206913137, 1160607143,\n                2885974827, 3313462225, 4194793586, 2065489618, 3883470150, 4055315445, 582773660,\n                2582421365, 1454136391, 3061250840, 3468396503, 3488155264, 3029987831, 3156489841,\n                3463417120, 290496437, 4073099736, 180400746, 2106957818, 2769052442, 108172964,\n                284413173, 3344416865, 2269676748, 1574448658, 1902898868, 2316487593, 2771218024,\n                559367309, 3806016235, 2226674034, 1387375714, 3568612053, 673940445, 953264754,\n                1654240319, 2440830479, 283579272, 3231076957, 3939738751, 1493681204, 3397390673,\n                202532089, 820322467, 3747993335, 219997922, 1605225930, 4131306261, 1601302257,\n                521986372, 2770985700, 1963676063, 1439552511, 3555657222, 2250141846, 2503842498,\n                1970558797, 4169645939, 650372536, 1069598113, 707461834, 2970635546, 4043174034,\n                1642439873, 4249605930, 453278516, 1404882141, 2914837424, 1989551821, 1391677255,\n                2183893344, 1584545759, 1373876512, 2646970263, 246551016, 1589680164, 3758709566,\n                1942743739, 3244781899, 3123447530, 327409007, 2868166556, 3076801053, 2736084122,\n                3120784427, 199119660, 2691390162, 2174609870, 3758152774, 3735826978, 379752927,\n                619293957, 1527231068, 2991592006, 2710895459, 704686889, 4267216023, 2557068229,\n                1719941939, 78238238, 2962383502, 2393733803, 1004503772, 4066720355, 2075559616,\n                4243473886, 3935513315, 1002981165, 3794209454, 1615720966, 1568227265, 1813739753,\n                3362817192, 3305123208, 396682192, 4129516924, 882778042, 2077448918, 3646338728,\n                3577300535, 2457120647, 3540612431, 1671071497, 2995114160, 2400776059, 842998576,\n                3518689093, 4224316739, 1023092271, 1070023790, 603487484, 1374775086, 3498521370,\n                1323561470, 4087319908, 2455563164, 2011118687, 495516162, 3626408376, 672930363,\n                996279995, 981700082, 3228699492, 2150767183, 519151136, 1312076022, 1336129777,\n                4010423712, 2637820943, 2292814695, 942739251, 949393103, 2458673154, 768725091,\n                1832836796, 453300228, 4261116655, 1701896567, 2144567659, 3699180161, 3087788471,\n                2755320709, 1748927126, 2706369429, 3729051121, 1295882152, 3846117499, 4120997689,\n                3272456369, 3495028726, 3839821698, 3333310547, 3768072175, 945089968, 3361639032,\n                3268636237, 2279991624, 3672799919, 1759060635, 2771604505, 1771544561, 2787457919,\n                440535646, 2504067590, 3105361213, 353200529, 2099162584, 378937981, 3561464661,\n                3915066715, 2729297678, 2088428747, 710187304, 3736425617, 1392889178, 4161612762,\n                3599125244, 2012759904, 1706559215, 1741496559, 1644051828, 3760773690, 1619711282,\n                3088530914, 828541325, 1116610363, 812269687, 1076986782, 3303686357, 1446933100,\n                4010678422, 1326813853, 2348597983, 570937405, 3521228878, 2567079846, 2753504122,\n                4168927609, 4114588897, 4058328886, 3726683252, 251974901, 1610363499, 2152010449,\n                2300844173, 2883860828, 2276005572, 2627023715, 2700844654, 2659717603, 3243052767,\n                382173215, 2253713687, 1545258562, 2782986095, 334263358, 2481258310, 2291585918,\n                1380546066, 1861205162, 1395600128, 1509813785, 1715266614, 3251195596, 3140058077,\n                1998653517, 3140019184, 2534426976, 844092771, 4270350187, 424082283, 3804651493,\n                2962777391, 32884830, 1331871085, 2047357436, 2562052720, 1663431404, 2097420816,\n                199104030, 1685999636, 2207406189, 3119926828, 654294011, 3715835629, 3855214036,\n                2460989955, 642673607, 1971681331, 2338977519, 475442971, 2516527409, 3470931196,\n                4262052990, 952637669, 1228316620, 165464703, 4219993004, 2243168861, 3690831859,\n                1956297624, 2833425905, 2707262033, 2571314297, 388071395, 1896528257, 1225824551,\n                81572020, 1409232203, 1080694913, 2547917588, 621110800, 2702861568, 2198117710,\n                1555339014, 2581264646, 138377579, 2293745610, 3914562495, 2918275417, 75829334,\n                1774985081, 2747349051, 1950994159, 394477872, 316913102, 461555308, 3548648328,\n                1617956386, 3126524770, 3123423878, 2182889796, 1568800505, 4279897761, 3333589672,\n                3792226100, 993443061, 1159842193, 2865953114, 2512277991, 1357746528, 3671513246,\n                2616265767, 1074303241, 2050907943, 268286549, 498690132, 4283094777, 2802371317,\n                3676403238, 2934500589, 281990329, 3074366974, 3387527201, 157777380, 2405204656,\n                142578723, 3660296423, 736731392, 1974042455, 1159614597, 4162674193, 1332482037,\n                1658304045, 2913005509, 481813632, 3626506485, 3221737748, 1374358866, 3827774417,\n                3308590869, 2205316972, 2619601751, 1879495531, 1688667307, 3945492802, 949715752,\n                165718259, 2529864207, 4033163217, 1627807449, 814761495, 2394041772, 163917860,\n                4137152849, 871080750, 2809100301, 126889608, 3338024033, 1570788701, 4067509056,\n                680440343, 3399634957, 1674234215, 2430678482, 1482962229, 3917262730, 2701308470,\n                3764650279, 4224967620, 509844418, 2494825785, 3803774464, 368493499, 4238556118,\n                4030415682, 3643742328, 2586387240, 3719633661, 3755880620, 2176876728, 2496909862,\n                111654638, 4071443844, 1244732003, 1399710541, 3492272815, 2804216879, 294683567,\n                2823495183, 1539340600, 2732661048, 2371405604, 611094747, 2426195984, 3948451542,\n                3575143460, 2163084716, 2877537071, 1849282685, 1662381818, 2022577840, 552741512,\n                1863034519, 2109621858, 3426780715, 233006082, 2766239663, 1257764921, 1179443268,\n                3311729910, 4228711990, 3676801557, 83336617, 52963853, 1461131367, 615175494,\n                2376138249, 1373985035, 3055102427, 1823691121, 175073115, 3051957217, 2611956643,\n                8092274, 4103495923, 2566129626, 66490664, 347807097, 730572423, 583932817,\n                2193587874, 1998219581, 3806043908, 3146127947, 3440818438, 4105053798, 806574510,\n                2647710257, 213825364, 1827399426, 3250558290, 4022072337, 2163344675, 1249293165,\n                94983795, 1430041053, 3690143296, 2906241747, 3282031769, 1948701801, 706760835,\n                4153647095, 3843998199, 2077172825, 1158686949, 3157624247, 3424621906, 4056374038,\n                3423674225, 511889851, 1745449688, 2554422250, 3004747460, 3576364631, 325806114,\n                1453902201, 1181646483, 784925267, 2018211516, 1758948179, 3236113206, 2773633419,\n                2329747557, 1612586727, 2954856193, 349470489, 4039284565, 2170178879, 641328078,\n                2932878730, 2057036386, 3758698550, 1389788861, 905696645, 322846493, 622200893,\n                2990601641, 779473385, 1637467878, 273757826, 1187850568, 3072937718, 3191465645,\n                3858350034, 2959907236, 2299744720, 2690960451, 2949783744, 1102614926, 1689432656,\n                934117703, 1940112928, 3379564708, 4199340399, 1881321211, 3929726949, 459862695,\n                1350630556, 2137584308, 1243785894, 983397001, 140271427, 1266031183, 3559919295,\n                702977622, 3883080853, 1830599918, 3030922777, 2650241556, 2807154392, 2218698435,\n                1904442293, 2992923456, 1481791037, 4079300846, 2680084216, 656285791, 3396057405,\n                272065717, 766725345, 1681255263, 1707458816, 1535744308, 3830462997, 1607479268,\n                3475252676, 933054715, 4058518411, 1139150315, 1176656025, 2657461768, 3149905151,\n                2833828072, 1407836276, 189062495, 3008111084, 3911286362, 3969377587, 520858887,\n                1921886086, 2410034665, 1853865087, 1218625232, 3157059817, 1933332942, 1324005415,\n                2613648167, 575584498, 1622716448, 2776523679,\n            ],\n            &[10; 1600],\n            &[\n                2337798985, 1719809325, 1766146956, 1432871059, 1913282470, 932051231, 2253427743,\n                3337839354, 174212766, 2418943939, 1818195854, 1795016853, 2023061831, 65726280,\n                1576822705, 2489110480, 1755680124, 1010622883, 2410047067, 2957950721, 3821505888,\n                2029055790, 919813873, 1454524914, 302707966, 2263686386, 664775132, 1441592353,\n                2668276189, 1029874670, 412976722, 3461537739, 165618775, 2805755420, 3986913245,\n                3750850515, 3911747004, 1709726859, 1430494098, 892950310, 4242511728, 500894641,\n                3512661539, 2383455966, 3902393679, 560808026, 1002183845, 3645493779, 2496237617,\n                1188317615, 1160331230, 4049090763, 2880495307, 2497687381, 756372816, 3883382263,\n                1412825102, 2798212291, 423470242, 1304918648, 2518462534, 1602052053, 3195498278,\n                1567441227, 4149369335, 3579099384, 722916608, 219424070, 3527901104, 1360861314,\n                3127386676, 1175600452, 2707542312, 2622395649, 4068363495, 3280638003, 2049563983,\n                3599786937, 1642977740, 19557413, 3844757830, 143230124, 3229601666, 1815836866,\n                2078167034, 1978389011, 4052689102, 3596571824, 2305736773, 3086821173, 2783854453,\n                3475178187, 2809907276, 56497958, 3665195047, 1855481649, 1557213590, 3186218749,\n                1579659414, 150730557, 2380493806, 1190332347, 750653467, 971803647, 4051923874,\n                2632706878, 961664618, 504169243, 3226989251, 176983832, 940067439, 3293538260,\n                2637791019, 2191083272, 3752981185, 2657937635, 4070370999, 4174783071, 419043165,\n                3539337388, 2961294405, 2250070055, 2129849842, 387044251, 570402960, 2429786867,\n                1321852772, 3796327549, 3651696376, 48730390, 660939665, 951624653, 1018250603,\n                1969566385, 3101262553, 2638971565, 1283036253, 172956163, 1683623272, 2766676731,\n                2164693596, 4149757659, 1029834025, 2691905287, 2446385107, 1005918892, 4205867169,\n                3216497085, 3428921101, 1770814161, 3015757934, 3464827848, 2494805438, 4035181431,\n                2179278559, 1424330, 1495619547, 3264150186, 3878153512, 2533738492, 138095927,\n                3968650904, 2988833739, 1178707551, 1851845851, 3283468943, 4205297379, 706168803,\n                520798040, 1611948341, 1295934146, 3768257794, 3872350135, 73022895, 2256463338,\n                1559961103, 279286159, 3232753970, 708275492, 1289339849, 2043694079, 2524360705,\n                2745749567, 1949784728, 1216039087, 3116384382, 1740530329, 3607118652, 4122786400,\n                530757090, 552544450, 4258552404, 1083733061, 1242098549, 4033981212, 204615559,\n                2161166767, 1611351590, 1176002643, 92570843, 1842133474, 650271884, 187375074,\n                1991479387, 1465587133, 1104658610, 2335293990, 214374954, 2350932521, 3814143087,\n                4138623525, 1116785125, 1647270088, 3109205647, 1522224221, 1795795952, 4049380771,\n                2003489406, 2717299085, 3865480913, 483542617, 1812810600, 976115739, 1874969238,\n                3323862135, 3433813421, 684253543, 2649590287, 1373773333, 485552995, 2472189256,\n                2945214935, 794984346, 1746460381, 1757396273, 1743887526, 298380984, 1352704452,\n                3966715730, 4113217885, 1241297473, 2453395403, 2954244651, 3774288543, 1444839196,\n                1548334790, 1122875432, 4121317990, 3947157568, 2712619444, 4223807490, 4005476489,\n                2308148699, 2684648139, 612866543, 1452041438, 2217463262, 4199719912, 3956456988,\n                1855047341, 2513694528, 4275971633, 2747007746, 557514185, 1719154861, 1529793338,\n                889576708, 3968812169, 2510679393, 803503931, 2692261222, 4080870372, 1511006235,\n                2711504643, 975058190, 4061501572, 2837215732, 2193743263, 4181374242, 2506045727,\n                2059941818, 2631701397, 4223127935, 2130862853, 142213618, 780119847, 1085548982,\n                2585032692, 1428661966, 2131060363, 667385220, 1225586380, 4242414988, 3975059186,\n                339067021, 4069839975, 4207550632, 767730479, 1439311207, 3446124465, 4246386072,\n                2908059873, 3369915408, 3255651336, 3020663495, 3546510376, 803064470, 76924606,\n                3832623942, 4020318607, 2730283796, 2953477768, 1922322168, 2956148578, 2539451553,\n                3716309785, 3125952755, 2075479202, 776522024, 2500281600, 4171655545, 2729325135,\n                34251037, 1476015613, 4199561321, 469926930, 2222437139, 4029482883, 3407168764,\n                828942664, 3994809377, 1646421728, 4162196041, 1109742320, 583773405, 932723359,\n                2529525319, 312357632, 2879219364, 1065489156, 132224124, 515226881, 2446629197,\n                171479349, 3993018508, 3278247564, 2928823997, 4231434757, 2985885115, 1806357710,\n                170081371, 2586404971, 53743121, 3915349183, 4256978965, 1282122127, 1334176954,\n                2896736246, 3168160222, 2723155581, 3801770034, 2474069641, 3914138112, 1703132960,\n                3050910113, 4000063991, 1156533771, 4197722875, 322247103, 2828309651, 1418664555,\n                3855814973, 2969749183, 670899946, 3684238847, 315272562, 1479787957, 3630248247,\n                3896795856, 2284924078, 3448742593, 2587913739, 2159727850, 4271757822, 2635451852,\n                1460173359, 514583636, 172745403, 305115099, 1158098813, 846374874, 4085016243,\n                2073661719, 3009482284, 2414138245, 3524500656, 388867611, 249517102, 3006883043,\n                4017176253, 2805544688, 3976760186, 630506689, 1780244360, 2737306104, 232231247,\n                1782076434, 387667825, 19793987, 2435181870, 2071669258, 764507081, 4155368519,\n                1451401907, 2360299858, 2330980099, 248454712, 3446078666, 2051966307, 2583383245,\n                706199696, 1890612504, 430574014, 2138787679, 2072311300, 737930085, 1521104440,\n                1585866980, 3120273, 3745204278, 3810187595, 901979488, 73759262, 3666590185,\n                875095827, 2485005683, 91444278, 997368547, 1551767372, 2677837051, 2596775070,\n                2673462320, 3055136566, 2778177188, 2822170891, 856301750, 717584730, 2775561644,\n                3235679827, 156925055, 4291892081, 938088712, 3712668621, 259963917, 188910174,\n                649460518, 1817160593, 3709183455, 2402569350, 2081244206, 1509583715, 159399436,\n                1005960034, 1584342275, 2708952291, 2083036721, 1827439806, 1920055605, 3099081841,\n                1505885624, 2705667938, 2970467008, 238736756, 680180549, 4265559140, 2686154915,\n                1275991160, 3321354017, 2666491064, 3391755967, 3136520967, 3492830782, 3080081809,\n                3240774903, 3389225939, 3016812645, 2761181256, 2165228292, 2154406921, 2542813197,\n                1465309996, 1179307147, 2930429249, 3040580106, 1976482529, 922355195, 3971063173,\n                277150860, 731857282, 3242189049, 1177214447, 3390437917, 3079667926, 1364420250,\n                1590973945, 2232278086, 232355078, 2582462161, 4037245230, 1049343960, 902676573,\n                4050492428, 1639129006, 3718138732, 3141580653, 766367797, 936894223, 1660677846,\n                628659564, 3365679999, 2561586784, 2229241133, 765418610, 782213348, 3067170394,\n                2191065093, 2774229638, 1023995363, 2412486840, 1635182131, 3748032748, 3129138020,\n                3607863873, 1174858263, 3616713190, 4187572066, 1546395074, 2027798083, 809553599,\n                1094121220, 3654162279, 1622703946, 148537568, 2385824297, 4061752858, 2543105581,\n                2622844203, 232849043, 3196673684, 2978718963, 1149528105, 2668110812, 2785402592,\n                3000100584, 1104866593, 70336191, 3432727170, 1109464777, 3746930874, 370280554,\n                3173358988, 3028594704, 2568130308, 457794435, 3383280274, 3346977517, 3484110806,\n                3153332792, 2425789545, 1474803746, 1781168328, 1989549162, 1032111952, 1331522816,\n                576372512, 1501541893, 2363428250, 1240303586, 2086180513, 3295867599, 691258190,\n                1008095124, 1776518245, 1495400690, 1519584986, 161360441, 1772372163, 4268396252,\n                2962917231, 2427675136, 2392936739, 272706848, 2620154363, 3998849772, 145937813,\n                4086621724, 1362430997, 1197771365, 4043072616, 916377810, 744218349, 1540693771,\n                2677728030, 553310668, 4229748447, 2011546593, 1970733497, 348172273, 762490238,\n                2152384213, 3411715628, 963109640, 3705793619, 3279035870, 426700692, 4278708730,\n                3586142296, 947806688, 1271342014, 715263589, 3455580436, 947104307, 1544685336,\n                2935774907, 2880317443, 3966149687, 2185422218, 2734810890, 3501513946, 2776353382,\n                4018451746, 2143808119, 736225303, 285334126, 2476018967, 3181930537, 2187294402,\n                3466164771, 2701302654, 3965790213, 2725436454, 3988416777, 3703472799, 1987980159,\n                923281388, 500013102, 74776770, 305061946, 3071827551, 486104690, 1384936530,\n                2111519171, 4124986050, 2429853625, 4015640194, 1966593586, 3123465599, 3341712852,\n                4213415239, 2396791960, 2722817611, 3004299255, 3857147942, 3516645579, 2072674201,\n                4175316375, 1683909736, 839905161, 316481248, 1683979804, 322038557, 677362982,\n                2973808772, 2596414587, 2730969268, 631888150, 1120341313, 1741270077, 3073620475,\n                1271943658, 1569862398, 3466496720, 4035716713, 2628306778, 2724723494, 1112102889,\n                3113513358, 2206163467, 2242575348, 2370657615, 3589371005, 1709622823, 2134510725,\n                3551117280, 3530138199, 922367384, 2890039831, 3559757981, 2345560704, 4221190559,\n                2332246771, 947123098, 3646442248, 488399645, 93684888, 851205014, 1145927652,\n                2376994496, 3976460398, 1154212282, 957935206, 353710365, 389412511, 1861961516,\n                3877610160, 1563516521, 1691953718, 1806258524, 4051249633, 2608084101, 1791724368,\n                4265828682, 98939002, 1131349528, 3141506279, 3747754883, 326404000, 2478362343,\n                2588680395, 2143336059, 3872805152, 720855604, 3231146872, 4275393682, 3215503747,\n                921660765, 2211457002, 29403278, 3071719374, 1901061486, 2988763100, 2195689231,\n                2111188612, 311057207, 1729785466, 339631061, 2566255664, 3558053739, 3017329992,\n                1834837913, 3911826467, 3826490857, 2838519210, 757698577, 3906322785, 4201094194,\n                828603290, 285313241, 2371084832, 3768763374, 4233968501, 2691202024, 3896400582,\n                2354807465, 1716960373, 377187758, 608315962, 612112524, 1866928118, 698937084,\n                3816198943, 980195413, 309169402, 3078719903, 3432153242, 2612946281, 3514540944,\n                1049878875, 3323542228, 3935174984, 3091793763, 2991245938, 3124186421, 2329117733,\n                4292494429, 3470963710, 1841188513, 2240113560, 996388563, 666396431, 140044984,\n                3132435687, 633020765, 385791735, 3533664654, 3369755757, 121447338, 3171287490,\n                1099415033, 3453496166, 2706291058, 2916008410, 2132445090, 3625133577, 2720560195,\n                205034264, 2411022473, 1225251622, 3873743850, 1878792569, 502287331, 2162793456,\n                4157617048, 837095026, 102278594, 4160514510, 3816646879, 1992533021, 191007446,\n                2727236802, 129396988, 613409573, 3431367662, 2099891725, 1930966876, 3122423745,\n                1075336928, 863500290, 1570806513, 3846730261, 393471418, 2624737608, 2647735688,\n                691426271, 3857369437, 1117350889, 3803433479, 1203945720, 486509596, 2702784498,\n                2971427393, 3372426095, 3448620625, 504644590, 2331180067, 1754142124, 3989228411,\n                3173048257, 2864751203, 2554761519, 3900913911, 1061646112, 3932675694, 658022597,\n                617264464, 343231796, 3115501645, 3550409916, 74722842, 1255450930, 2831976136,\n                1240738374, 1193141623, 1676518965, 262041809, 394954934, 2219224532, 1441157802,\n                2927116538, 3501791300, 4176181037, 1666097702, 4152025817, 2970386591, 1834278661,\n                207867662, 2514518143, 3049374496, 1354176149, 1820727688, 2928930650, 3260452331,\n                3926267804, 4240562748, 611877548, 4128238218, 1421140789, 1585228831, 1946949310,\n                3958532496, 812912156, 1645465057, 2509683759, 349966819, 2396774296, 2965066365,\n                3761846427, 1231196649, 409766126, 430753233, 599727165, 545964841, 3825372245,\n                3623870288, 40038191, 2884208155, 3417332481, 35141341, 680406210, 3702828808,\n                4118568845, 731073893, 3607543676, 3868323054, 4067601050, 398479428, 792773465,\n                1353851383, 1392719352, 4029808759, 4021129172, 796278946, 3939062404, 1195296489,\n                1756744309, 1001193500, 2465821931, 509185625, 3191666804, 3687287932, 1874396329,\n                1969891759, 1678441456, 2667925867, 407814354, 3603659969, 3800228642, 120101583,\n                3424508412, 1520495793, 357902760, 3271308342, 1286919855, 2382756661, 4274587703,\n                1127960573, 866377732, 3518954640, 1286199460, 661518652, 3127729633, 1529991009,\n                3425483485, 3157156519, 2726813487, 2701731704, 2083479105, 2893033595, 4240983598,\n                1299967832, 4080212138, 1905892689, 1858214875, 3672725881, 1081535884, 174040383,\n                3896862135, 3010343151, 4061479962, 3572367057, 1510459761, 3360785724, 1087858215,\n                57335744, 820510676, 530845883, 4228688641, 3696711033, 2135986325, 3913568995,\n                179524639, 3658604236, 2806792625, 2316354532, 1051562581, 3907381452, 2034461972,\n                178565993, 1284664272, 504824744, 3099567341, 2469345824, 3658913004, 992022622,\n                2786623537, 1021202198, 616895091, 2113750936, 1970082270, 3116426075, 3366259439,\n                585641047, 1328830246, 2258836941, 1322082749, 2241797667, 3399199649, 892467755,\n                2102971037, 1617097228, 4217502934, 974168861, 207492006, 2121251711, 3696018919,\n                1120006335, 1446317229, 3759235761, 3849699334, 3914866958, 626085181, 2420743789,\n                207902456, 1160796838, 790516805, 3187963410, 1515106146, 1296852237, 4089144091,\n                4241451860, 2783094488, 892183279, 338178727, 3053725583, 265766843, 623486416,\n                3796894823, 4202268968, 717565135, 2342024161, 870503465, 7128667, 1592323423,\n                3245656364, 4067369565, 1962250035, 816069811, 4232891752, 1558892228, 1888603643,\n                2666913616, 1404984687, 1433926934, 1743547609, 4112246183, 2021577654, 3544918251,\n                2020707701, 76188917, 1820900427, 2354637472, 1284257266, 3136451484, 1141115948,\n                1840829393, 4188399303, 802488874, 2059431097, 2804849229, 3775794144, 202946897,\n                765182653, 1168548737, 586672791, 3563384658, 981277056, 3279509061, 2445793196,\n                64294419, 1062640550, 2175903265, 2304846254, 2637942449, 2075197790, 3502280781,\n                3858345076, 4216378544, 2289775386, 4139983440, 4063679757, 3287916447, 1524609875,\n                997055195, 3660166441, 134003661, 3205014674, 2978476890, 966447865, 2850295105,\n                2243044897, 2061254489, 2262245077, 4083038201, 2257930427, 3015088005, 4145891046,\n                1511251913, 2595200020, 3831470358, 2985310963, 476732156, 224979971, 1156465354,\n                764683574, 4214444004, 3261415121, 3429123803, 1523213339, 4245223903, 956158970,\n                2891732999, 2765282146, 3400683065, 1587606157, 2046079544, 1389905331, 87824577,\n                1777986777, 3384203137, 4108947902, 3482879397, 77745361, 2507275334, 1986893298,\n                4022922416, 733916179, 3139522709, 2999889833, 1161829779, 3605866360, 3134683460,\n                1728850270, 101032362, 62872782, 3248731114, 3862793560, 806307801, 1524032149,\n                3064849448, 4077118848, 502698332, 2947670365, 3513995935, 1827518528, 3167131171,\n                2509065020, 4042175975, 2127503650, 3059544483, 2518990490, 2579930555, 3651523255,\n                1289189775, 4267073320, 4253053136, 1213724392, 3151111200, 590705794, 3805447266,\n                3183254479, 2646011908, 1917642749, 430090695, 2498363140, 3589876748, 2624132115,\n                862795528, 568833509, 910667954, 1592134880, 1702960475, 2406368070, 3705761960,\n                1626081901, 2311944971, 1460097114, 2239030549, 4037205008, 4273988634, 1412019747,\n                2720054955, 1955567590, 112988394, 2557385250, 3008605370, 3633217123, 2655501518,\n                3036362106, 3626585998, 3056603934, 175647684, 2736699914, 1284866439, 2063512562,\n                2760127268, 529053475, 1262482220, 2324393750, 2930386123, 506365850, 2068269090,\n                3640453693, 2392681207, 3657296390, 3557179631, 4229254256, 2832847420, 3127293618,\n                1056645988, 1784949673, 4137331301, 339663936, 2042994969, 707619349, 1267257087,\n                176084099, 204051889, 3609720855, 1203172342, 2503775670, 1897808209, 1819022477,\n                738716411, 2467366231, 1314393857, 3943102895, 560966695, 2733358928, 4155172253,\n                3318993281, 478303408, 3297724926, 1480431524, 2011292966, 4204677255, 598093968,\n                125630774, 802875169, 3174837530, 2200212794, 2531478045, 3528472075, 2409062863,\n                3624879168, 1298461038, 300487657, 921301375, 3034772385, 2870175987, 2489528255,\n                1422650999, 1959898718, 2148368644, 3530668930, 1343992028, 3420621297, 3185617672,\n                2169713229, 1381510115, 1759851866, 1671105009, 1972863997, 451922074, 2574366942,\n                2565022677, 85073139, 1400004844, 3414904623, 2991965703, 3324493380, 2662461579,\n                3371935536, 2685047962, 2084406666, 2522680379, 2216032134, 1833426925, 3564115877,\n                3629214939, 1386564296, 432334582, 3401734285, 3470776247, 3295439412, 3275391820,\n                2996027786, 3541192247, 1596293240, 1534677041, 4242524641, 3867762559, 3182515057,\n                778449780, 509849285, 1894106033, 3758007661, 3817124330, 114867286, 380293626,\n                3988986517, 2249146814, 1555156359, 862290373, 4289162394, 2797154341, 858657091,\n                2332904187, 683283785, 3310320458, 1908273940, 2996192820, 1274723594, 2256894660,\n                1011908845, 2088109931, 633224466, 776763995, 1482429362, 3311871094, 1334262064,\n                3149388402, 977459388, 3758068268, 3549396571, 3621273547, 2294655742, 2027549028,\n                882796118, 3763000843, 1211550434, 276620274, 230856654, 886280116, 819485199,\n                1395058832, 43453671, 612049046, 3593376018, 739190917, 551328093, 636688917,\n                1113589747, 1200914090, 1966124296, 388857045, 1499391582, 1096623475, 2380951002,\n                1179204203, 2425898283, 1568845412, 3305045134, 3461499409, 2929744718, 1843517946,\n                2263560109, 2614227766, 2598972927, 4211663438, 2238818808, 2123144987, 846869844,\n                1597863731, 1413784936, 942259755, 1435252365, 2763188690, 2011949466, 1724258311,\n                2878814633, 2216290126, 3890752531, 2688893713, 3467941951, 1532473463, 3726393479,\n                250588825, 2421895595, 1130251300, 2404278908, 2621227970, 1495570965, 3587745666,\n                3863085648, 3893033445, 2167432349, 2521288540, 1110696395, 3019115, 1557260537,\n                3407264044, 2647957557, 2212494188, 873933723, 1846630096, 3510283303, 416301122,\n                1671897732, 1541550351, 1498687513, 1182466031, 1497564883, 2250283938, 4174125262,\n                3058762721, 695042319, 3583491610, 1633913101, 2527176860, 3899685837, 911160283,\n                3039645347, 3348668230, 2349978768, 2310300756, 2452401376, 1521793036, 340141858,\n                3417831892, 1389692609, 2209437861, 1011293226, 3553183727, 2864651565, 2961816923,\n                1538336212, 1210400781, 937878795, 1776525302, 323549324, 2934290713, 3627165984,\n                419595827, 398867637, 2034794941, 1105787003, 1506150941, 3463860621, 3093035089,\n                2621956154, 3805051230, 1104966082, 1511537428, 3334056299, 2819684443, 1450375895,\n                3859160045, 868818555, 3021376565, 1583993024, 1655491252, 2323362595, 1623767895,\n                3277267299, 1439181227, 2210615033, 3342026791, 1303089351, 673713047, 2454990941,\n                4159020796, 3236264164, 4102788727, 836725026, 122766192, 2743591988, 4073411178,\n                3664777611, 1441783934, 1903288297, 4015225793, 2287805599, 646110839, 907079317,\n                3224989229, 3271827456, 2930105235, 2009175609, 4132152618, 3613216751, 2599489077,\n                767951771, 2330827095, 3178900160, 1672891072, 2558969779, 2413882700, 4123689082,\n                2821163535, 402922506, 2568613951, 3501945651, 931224777, 2219590700, 2669231230,\n                2761628391, 1010318635, 3912099512, 2137382107, 1740783570, 2900437537, 544334460,\n                1851950794, 2487565757, 1501873778, 493353971, 227575783, 3993627568, 2857758942,\n                1794910929, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n            ],\n        );\n        // - cy > 2\n        test(\n            &rle_decode(&[\n                (0, 29),\n                (4294967288, 1),\n                (u32::MAX, 76),\n                (4194303, 1),\n                (0, 83),\n                (4292870144, 1),\n                (u32::MAX, 12),\n                (255, 1),\n                (0, 204),\n            ]),\n            &[10; 821],\n            &rle_decode(&[\n                (0, 58),\n                (64, 1),\n                (0, 76),\n                (4227858432, 1),\n                (u32::MAX, 77),\n                (4095, 1),\n                (0, 5),\n                (33554432, 1),\n                (0, 12),\n                (4294963200, 1),\n                (u32::MAX, 64),\n                (4294963199, 1),\n                (u32::MAX, 11),\n                (2147483647, 1),\n                (0, 71),\n                (1024, 1),\n                (0, 11),\n                (3221225472, 1),\n                (u32::MAX, 12),\n                (65535, 1),\n                (0, 409),\n                (10, 5),\n            ]),\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[18446744073642442752, u64::MAX, 0],\n            &[10; 10],\n            &[0x10000000000000, 0, 18446744073575333888, u64::MAX, 0, 0, 10, 10, 10, 10],\n        );\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_2_fail_1() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_2_scratch_len(1)];\n    let mut out = vec![10; 3];\n    limbs_square_to_out_toom_2(&mut out, &[5], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_2_fail_2() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_2_scratch_len(2)];\n    let mut out = vec![10; 3];\n    limbs_square_to_out_toom_2(&mut out, &[5, 5], &mut scratch);\n}\n\n#[test]\nfn test_limbs_square_to_out_toom_3() {\n    let test = |xs: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        limbs_square_basecase_helper_1(out_before, xs, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_square_to_out_toom_3_scratch_len(xs.len())];\n        limbs_square_to_out_toom_3(&mut out, xs, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        test(&[0; 3], &[10; 7], &[0, 0, 0, 0, 0, 0, 10]);\n        // - carry != 0 || limbs_cmp_same_length(scratch_lo, xs_1) != Less\n        // - s == n\n        // - SMALLER_RECURSION_TOOM_3\n        // - TOOM3MAYBE_SQR_BASECASE && n < SQR_TOOM2_THRESHOLD in\n        //   limbs_square_to_out_toom_3recursive\n        // - SMALLER_RECURSION_TOOM_3 && *asm1last == 0\n        // - SMALLER_RECURSION_TOOM_3 && *as1last == 0\n        test(&[1; 3], &[10; 7], &[1, 2, 3, 2, 1, 0, 10]);\n        // - s != n\n        test(&[1; 5], &[10; 11], &[1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 10]);\n        test(\n            &[123, 456, 789],\n            &[10; 7],\n            &[15129, 112176, 402030, 719568, 622521, 0, 10],\n        );\n        // - carry == 0 && limbs_cmp_same_length(scratch_lo, xs_1) == Less\n        test(\n            &[0, 0, 0, 1, 1],\n            &[10; 12],\n            &[0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 10, 10],\n        );\n        // - SMALLER_RECURSION_TOOM_3 && *as1last == 1\n        test(\n            &[565087108, 3577014007, 448420006, 2768629557, 3704090824, 1883403892],\n            &[10; 14],\n            &[\n                4218985488, 4220575665, 485151065, 3638109583, 674533688, 2474892467, 3104074041,\n                1104686790, 3937806198, 3714955349, 2353052328, 825899239, 10, 10,\n            ],\n        );\n        // - SMALLER_RECURSION_TOOM_3 && *asm1last != 0\n        test(\n            &[\n                1863564690, 1421495353, 3398346856, 3502315373, 3245074461, 3371098228, 1920119175,\n                2322725516, 4131580343, 709402630, 2656476301, 228065352, 4270876554, 2188759820,\n                3809088484, 1278459410, 3688098765, 3792157672,\n            ],\n            &[10; 38],\n            &[\n                1275914052, 2813541102, 1776167565, 3816433009, 1506506355, 905535255, 3807374706,\n                1119336832, 2821426754, 1687683145, 3194676438, 3617711780, 3181480047, 2569874763,\n                63947417, 284228079, 864468110, 3049865574, 3349291193, 1069485525, 2676088498,\n                2386507281, 152204676, 977297146, 1013377091, 279563853, 1416452708, 3923795588,\n                2090135739, 1920980986, 1947396916, 2353294051, 1096614562, 656612539, 4107024100,\n                3348211714, 10, 10,\n            ],\n        );\n        // - SMALLER_RECURSION_TOOM_3 && *as1last != 1 && *as1last != 0\n        test(\n            &[\n                1340632901, 3164542962, 2229190317, 2072028339, 3600460563, 4242593376, 2627243024,\n                1009360033, 3245433778, 3317979701, 3334268713, 956862889, 1903527801, 1422003495,\n                3902138254,\n            ],\n            &[10; 32],\n            &[\n                1936517273, 2149059626, 3482772768, 751986309, 1917548379, 2845313364, 2764088089,\n                2639949097, 754924916, 2372685186, 2487592500, 3468889594, 1517341799, 2635848785,\n                2441035315, 4022727698, 668317312, 3146195097, 42876009, 69685896, 3753683781,\n                2617058485, 3637068186, 3137670920, 3218047800, 2570868414, 910498312, 614648473,\n                1455459795, 3545238393, 10, 10,\n            ],\n        );\n        // - (!TOOM3MAYBE_SQR_BASECASE || n >= SQR_TOOM2_THRESHOLD) && TOOM3MAYBE_SQR_TOOM3 && n >=\n        //   SQR_TOOM3THRESHOLD in limbs_square_to_out_toom_3recursive\n        test(\n            &[\n                315937763, 473311027, 567550122, 1916950171, 4059671672, 732330624, 3931833255,\n                435611156, 3441308858, 1231108682, 571470188, 1643911325, 1855842520, 890506741,\n                4051150309, 1624118035, 4095320898, 832808382, 254544287, 367192823, 3029770132,\n                2530961358, 168199720, 556928054, 3574899773, 901884181, 3037235269, 2537532649,\n                3638603141, 3105834733, 756731319, 2666260459, 3459942852, 3113152432, 2490378291,\n                2524064262, 2837473716, 970558109, 1280992412, 3025351268, 1176324257, 3832993853,\n                2960008574, 143054238, 2025124021, 3355284231, 3700222977, 959518197, 836633203,\n                1753652842, 3863610502, 3683672960, 2678694928, 3768243585, 2643427081, 2597841461,\n                809616697, 2770459249, 938499903, 2306605358, 806972689, 462004905, 1559140947,\n                880982517, 4000827930, 1625323545, 2071445194, 3924145010, 3049042401, 3015341713,\n                2642970230, 680495934, 3572593922, 3776563282, 3584817478, 1511664158, 1048142251,\n                1261635752, 2674531050, 1166719307, 3811800408, 3532080230, 853430491, 2558475297,\n                2417944189, 3094847515, 654669385, 2934541460, 2625633289, 4100222514, 1517941214,\n                3805734203, 3486264903, 2658767168, 1176863503, 2377983813, 4010981779, 1334807591,\n                3581560372, 231495094, 2680779981, 953071754, 1140610841, 4139855852, 515631497,\n                845705671, 505532954, 1555952001, 1319192795, 523566796, 738834566, 2397343480,\n                3709100568, 2754977717, 2105634100, 2622287225, 3069665844, 1499378188, 1024995116,\n                529523547, 1573018435, 2475374120, 3949433831, 748808472, 1404353612, 3021083538,\n                1713559320, 706538487, 1788875531, 3976761851, 1912518906, 3712335343, 3425283422,\n                281500646, 1572406350, 108746052, 4056047843, 89307364, 1006007374, 2902260577,\n                1250995384, 1556873818, 3846421711, 280743259, 1728158805, 467926284, 2330565417,\n                1366395459, 474848905, 1190711031, 4146575846, 1359337485, 277106601, 611834097,\n                4135958043, 2404499652, 3266860581, 4084179847, 1694432029, 2659591080, 438254541,\n                2191377959, 2215296842, 4215722030, 1219192120, 2382641840, 3275049666, 1893229486,\n                3003341825, 1385119378, 491641953, 3636318537, 409287515, 1702143228, 3653042335,\n                2210372129, 3091759374, 3445226074, 283146383, 1663694381, 1455499100, 306155088,\n                3031133107, 30443875, 336170015, 3291741077, 1240501199, 206913137, 1160607143,\n                2885974827, 3313462225, 4194793586, 2065489618, 3883470150, 4055315445, 582773660,\n                2582421365, 1454136391, 3061250840, 3468396503, 3488155264, 3029987831, 3156489841,\n                3463417120, 290496437, 4073099736, 180400746, 2106957818, 2769052442, 108172964,\n                284413173, 3344416865, 2269676748, 1574448658, 1902898868, 2316487593, 2771218024,\n                559367309, 3806016235, 2226674034, 1387375714, 3568612053, 673940445, 953264754,\n                1654240319, 2440830479, 283579272, 3231076957, 3939738751, 1493681204, 3397390673,\n                202532089, 820322467, 3747993335, 219997922, 1605225930, 4131306261, 1601302257,\n                521986372, 2770985700, 1963676063, 1439552511, 3555657222, 2250141846, 2503842498,\n                1970558797, 4169645939, 650372536, 1069598113, 707461834, 2970635546, 4043174034,\n                1642439873, 4249605930, 453278516, 1404882141, 2914837424, 1989551821, 1391677255,\n                2183893344, 1584545759, 1373876512, 2646970263, 246551016, 1589680164, 3758709566,\n                1942743739, 3244781899, 3123447530, 327409007, 2868166556, 3076801053, 2736084122,\n                3120784427, 199119660, 2691390162, 2174609870, 3758152774, 3735826978, 379752927,\n                619293957, 1527231068, 2991592006, 2710895459, 704686889, 4267216023, 2557068229,\n                1719941939, 78238238, 2962383502, 2393733803, 1004503772, 4066720355, 2075559616,\n                4243473886, 3935513315, 1002981165, 3794209454, 1615720966, 1568227265, 1813739753,\n                3362817192, 3305123208, 396682192, 4129516924, 882778042, 2077448918, 3646338728,\n                3577300535, 2457120647, 3540612431, 1671071497, 2995114160, 2400776059, 842998576,\n                3518689093, 4224316739, 1023092271, 1070023790, 603487484, 1374775086, 3498521370,\n                1323561470, 4087319908, 2455563164, 2011118687, 495516162, 3626408376, 672930363,\n                996279995, 981700082, 3228699492, 2150767183, 519151136, 1312076022, 1336129777,\n                4010423712, 2637820943, 2292814695, 942739251, 949393103, 2458673154, 768725091,\n                1832836796, 453300228, 4261116655, 1701896567, 2144567659, 3699180161, 3087788471,\n                2755320709, 1748927126, 2706369429, 3729051121, 1295882152, 3846117499, 4120997689,\n                3272456369, 3495028726, 3839821698, 3333310547, 3768072175, 945089968, 3361639032,\n                3268636237, 2279991624, 3672799919, 1759060635, 2771604505, 1771544561, 2787457919,\n                440535646, 2504067590, 3105361213, 353200529, 2099162584, 378937981, 3561464661,\n                3915066715, 2729297678, 2088428747, 710187304, 3736425617, 1392889178, 4161612762,\n                3599125244, 2012759904, 1706559215, 1741496559, 1644051828, 3760773690, 1619711282,\n                3088530914, 828541325, 1116610363, 812269687, 1076986782, 3303686357, 1446933100,\n                4010678422, 1326813853, 2348597983, 570937405, 3521228878, 2567079846, 2753504122,\n                4168927609, 4114588897, 4058328886, 3726683252, 251974901, 1610363499, 2152010449,\n                2300844173, 2883860828, 2276005572, 2627023715, 2700844654, 2659717603, 3243052767,\n                382173215, 2253713687, 1545258562, 2782986095, 334263358, 2481258310, 2291585918,\n                1380546066, 1861205162, 1395600128, 1509813785, 1715266614, 3251195596, 3140058077,\n                1998653517, 3140019184, 2534426976, 844092771, 4270350187, 424082283, 3804651493,\n                2962777391, 32884830, 1331871085, 2047357436, 2562052720, 1663431404, 2097420816,\n                199104030, 1685999636, 2207406189, 3119926828, 654294011, 3715835629, 3855214036,\n                2460989955, 642673607, 1971681331, 2338977519, 475442971, 2516527409, 3470931196,\n                4262052990, 952637669, 1228316620, 165464703, 4219993004, 2243168861, 3690831859,\n                1956297624, 2833425905, 2707262033, 2571314297, 388071395, 1896528257, 1225824551,\n                81572020, 1409232203, 1080694913, 2547917588, 621110800, 2702861568, 2198117710,\n                1555339014, 2581264646, 138377579, 2293745610, 3914562495, 2918275417, 75829334,\n                1774985081, 2747349051, 1950994159, 394477872, 316913102, 461555308, 3548648328,\n                1617956386, 3126524770, 3123423878, 2182889796, 1568800505, 4279897761, 3333589672,\n                3792226100, 993443061, 1159842193, 2865953114, 2512277991, 1357746528, 3671513246,\n                2616265767, 1074303241, 2050907943, 268286549, 498690132, 4283094777, 2802371317,\n                3676403238, 2934500589, 281990329, 3074366974, 3387527201, 157777380, 2405204656,\n                142578723, 3660296423, 736731392, 1974042455, 1159614597, 4162674193, 1332482037,\n                1658304045, 2913005509, 481813632, 3626506485, 3221737748, 1374358866, 3827774417,\n                3308590869, 2205316972, 2619601751, 1879495531, 1688667307, 3945492802, 949715752,\n                165718259, 2529864207, 4033163217, 1627807449, 814761495, 2394041772, 163917860,\n                4137152849, 871080750, 2809100301, 126889608, 3338024033, 1570788701, 4067509056,\n                680440343, 3399634957, 1674234215, 2430678482, 1482962229, 3917262730, 2701308470,\n                3764650279, 4224967620, 509844418, 2494825785, 3803774464, 368493499, 4238556118,\n                4030415682, 3643742328, 2586387240, 3719633661, 3755880620, 2176876728, 2496909862,\n                111654638, 4071443844, 1244732003, 1399710541, 3492272815, 2804216879, 294683567,\n                2823495183, 1539340600, 2732661048, 2371405604, 611094747, 2426195984, 3948451542,\n                3575143460, 2163084716, 2877537071, 1849282685, 1662381818, 2022577840, 552741512,\n                1863034519, 2109621858, 3426780715, 233006082, 2766239663, 1257764921, 1179443268,\n                3311729910, 4228711990, 3676801557, 83336617, 52963853, 1461131367, 615175494,\n                2376138249, 1373985035, 3055102427, 1823691121, 175073115, 3051957217, 2611956643,\n                8092274, 4103495923, 2566129626, 66490664, 347807097, 730572423, 583932817,\n                2193587874, 1998219581, 3806043908, 3146127947, 3440818438, 4105053798, 806574510,\n                2647710257, 213825364, 1827399426, 3250558290, 4022072337, 2163344675, 1249293165,\n                94983795, 1430041053, 3690143296, 2906241747, 3282031769, 1948701801, 706760835,\n                4153647095, 3843998199, 2077172825, 1158686949, 3157624247, 3424621906, 4056374038,\n                3423674225, 511889851, 1745449688, 2554422250, 3004747460, 3576364631, 325806114,\n                1453902201, 1181646483, 784925267, 2018211516, 1758948179, 3236113206, 2773633419,\n                2329747557, 1612586727, 2954856193, 349470489, 4039284565, 2170178879, 641328078,\n                2932878730, 2057036386, 3758698550, 1389788861, 905696645, 322846493, 622200893,\n                2990601641, 779473385, 1637467878, 273757826, 1187850568, 3072937718, 3191465645,\n                3858350034, 2959907236, 2299744720, 2690960451, 2949783744, 1102614926, 1689432656,\n                934117703, 1940112928, 3379564708, 4199340399, 1881321211, 3929726949, 459862695,\n                1350630556, 2137584308, 1243785894, 983397001, 140271427, 1266031183, 3559919295,\n                702977622, 3883080853, 1830599918, 3030922777, 2650241556, 2807154392, 2218698435,\n                1904442293, 2992923456, 1481791037, 4079300846, 2680084216, 656285791, 3396057405,\n                272065717, 766725345, 1681255263, 1707458816, 1535744308, 3830462997, 1607479268,\n                3475252676, 933054715, 4058518411, 1139150315, 1176656025, 2657461768, 3149905151,\n                2833828072, 1407836276, 189062495, 3008111084, 3911286362, 3969377587, 520858887,\n                1921886086, 2410034665, 1853865087, 1218625232, 3157059817, 1933332942, 1324005415,\n                2613648167, 575584498, 1622716448, 2776523679, 1406325147,\n            ],\n            &[10; 1524],\n            &[\n                2337798985, 1719809325, 1766146956, 1432871059, 1913282470, 932051231, 2253427743,\n                3337839354, 174212766, 2418943939, 1818195854, 1795016853, 2023061831, 65726280,\n                1576822705, 2489110480, 1755680124, 1010622883, 2410047067, 2957950721, 3821505888,\n                2029055790, 919813873, 1454524914, 302707966, 2263686386, 664775132, 1441592353,\n                2668276189, 1029874670, 412976722, 3461537739, 165618775, 2805755420, 3986913245,\n                3750850515, 3911747004, 1709726859, 1430494098, 892950310, 4242511728, 500894641,\n                3512661539, 2383455966, 3902393679, 560808026, 1002183845, 3645493779, 2496237617,\n                1188317615, 1160331230, 4049090763, 2880495307, 2497687381, 756372816, 3883382263,\n                1412825102, 2798212291, 423470242, 1304918648, 2518462534, 1602052053, 3195498278,\n                1567441227, 4149369335, 3579099384, 722916608, 219424070, 3527901104, 1360861314,\n                3127386676, 1175600452, 2707542312, 2622395649, 4068363495, 3280638003, 2049563983,\n                3599786937, 1642977740, 19557413, 3844757830, 143230124, 3229601666, 1815836866,\n                2078167034, 1978389011, 4052689102, 3596571824, 2305736773, 3086821173, 2783854453,\n                3475178187, 2809907276, 56497958, 3665195047, 1855481649, 1557213590, 3186218749,\n                1579659414, 150730557, 2380493806, 1190332347, 750653467, 971803647, 4051923874,\n                2632706878, 961664618, 504169243, 3226989251, 176983832, 940067439, 3293538260,\n                2637791019, 2191083272, 3752981185, 2657937635, 4070370999, 4174783071, 419043165,\n                3539337388, 2961294405, 2250070055, 2129849842, 387044251, 570402960, 2429786867,\n                1321852772, 3796327549, 3651696376, 48730390, 660939665, 951624653, 1018250603,\n                1969566385, 3101262553, 2638971565, 1283036253, 172956163, 1683623272, 2766676731,\n                2164693596, 4149757659, 1029834025, 2691905287, 2446385107, 1005918892, 4205867169,\n                3216497085, 3428921101, 1770814161, 3015757934, 3464827848, 2494805438, 4035181431,\n                2179278559, 1424330, 1495619547, 3264150186, 3878153512, 2533738492, 138095927,\n                3968650904, 2988833739, 1178707551, 1851845851, 3283468943, 4205297379, 706168803,\n                520798040, 1611948341, 1295934146, 3768257794, 3872350135, 73022895, 2256463338,\n                1559961103, 279286159, 3232753970, 708275492, 1289339849, 2043694079, 2524360705,\n                2745749567, 1949784728, 1216039087, 3116384382, 1740530329, 3607118652, 4122786400,\n                530757090, 552544450, 4258552404, 1083733061, 1242098549, 4033981212, 204615559,\n                2161166767, 1611351590, 1176002643, 92570843, 1842133474, 650271884, 187375074,\n                1991479387, 1465587133, 1104658610, 2335293990, 214374954, 2350932521, 3814143087,\n                4138623525, 1116785125, 1647270088, 3109205647, 1522224221, 1795795952, 4049380771,\n                2003489406, 2717299085, 3865480913, 483542617, 1812810600, 976115739, 1874969238,\n                3323862135, 3433813421, 684253543, 2649590287, 1373773333, 485552995, 2472189256,\n                2945214935, 794984346, 1746460381, 1757396273, 1743887526, 298380984, 1352704452,\n                3966715730, 4113217885, 1241297473, 2453395403, 2954244651, 3774288543, 1444839196,\n                1548334790, 1122875432, 4121317990, 3947157568, 2712619444, 4223807490, 4005476489,\n                2308148699, 2684648139, 612866543, 1452041438, 2217463262, 4199719912, 3956456988,\n                1855047341, 2513694528, 4275971633, 2747007746, 557514185, 1719154861, 1529793338,\n                889576708, 3968812169, 2510679393, 803503931, 2692261222, 4080870372, 1511006235,\n                2711504643, 975058190, 4061501572, 2837215732, 2193743263, 4181374242, 2506045727,\n                2059941818, 2631701397, 4223127935, 2130862853, 142213618, 780119847, 1085548982,\n                2585032692, 1428661966, 2131060363, 667385220, 1225586380, 4242414988, 3975059186,\n                339067021, 4069839975, 4207550632, 767730479, 1439311207, 3446124465, 4246386072,\n                2908059873, 3369915408, 3255651336, 3020663495, 3546510376, 803064470, 76924606,\n                3832623942, 4020318607, 2730283796, 2953477768, 1922322168, 2956148578, 2539451553,\n                3716309785, 3125952755, 2075479202, 776522024, 2500281600, 4171655545, 2729325135,\n                34251037, 1476015613, 4199561321, 469926930, 2222437139, 4029482883, 3407168764,\n                828942664, 3994809377, 1646421728, 4162196041, 1109742320, 583773405, 932723359,\n                2529525319, 312357632, 2879219364, 1065489156, 132224124, 515226881, 2446629197,\n                171479349, 3993018508, 3278247564, 2928823997, 4231434757, 2985885115, 1806357710,\n                170081371, 2586404971, 53743121, 3915349183, 4256978965, 1282122127, 1334176954,\n                2896736246, 3168160222, 2723155581, 3801770034, 2474069641, 3914138112, 1703132960,\n                3050910113, 4000063991, 1156533771, 4197722875, 322247103, 2828309651, 1418664555,\n                3855814973, 2969749183, 670899946, 3684238847, 315272562, 1479787957, 3630248247,\n                3896795856, 2284924078, 3448742593, 2587913739, 2159727850, 4271757822, 2635451852,\n                1460173359, 514583636, 172745403, 305115099, 1158098813, 846374874, 4085016243,\n                2073661719, 3009482284, 2414138245, 3524500656, 388867611, 249517102, 3006883043,\n                4017176253, 2805544688, 3976760186, 630506689, 1780244360, 2737306104, 232231247,\n                1782076434, 387667825, 19793987, 2435181870, 2071669258, 764507081, 4155368519,\n                1451401907, 2360299858, 2330980099, 248454712, 3446078666, 2051966307, 2583383245,\n                706199696, 1890612504, 430574014, 2138787679, 2072311300, 737930085, 1521104440,\n                1585866980, 3120273, 3745204278, 3810187595, 901979488, 73759262, 3666590185,\n                875095827, 2485005683, 91444278, 997368547, 1551767372, 2677837051, 2596775070,\n                2673462320, 3055136566, 2778177188, 2822170891, 856301750, 717584730, 2775561644,\n                3235679827, 156925055, 4291892081, 938088712, 3712668621, 259963917, 188910174,\n                649460518, 1817160593, 3709183455, 2402569350, 2081244206, 1509583715, 159399436,\n                1005960034, 1584342275, 2708952291, 2083036721, 1827439806, 1920055605, 3099081841,\n                1505885624, 2705667938, 2970467008, 238736756, 680180549, 4265559140, 2686154915,\n                1275991160, 3321354017, 2666491064, 3391755967, 3136520967, 3492830782, 3080081809,\n                3240774903, 3389225939, 3016812645, 2761181256, 2165228292, 2154406921, 2542813197,\n                1465309996, 1179307147, 2930429249, 3040580106, 1976482529, 922355195, 3971063173,\n                277150860, 731857282, 3242189049, 1177214447, 3390437917, 3079667926, 1364420250,\n                1590973945, 2232278086, 232355078, 2582462161, 4037245230, 1049343960, 902676573,\n                4050492428, 1639129006, 3718138732, 3141580653, 766367797, 936894223, 1660677846,\n                628659564, 3365679999, 2561586784, 2229241133, 765418610, 782213348, 3067170394,\n                2191065093, 2774229638, 1023995363, 2412486840, 1635182131, 3748032748, 3129138020,\n                3607863873, 1174858263, 3616713190, 4187572066, 1546395074, 2027798083, 809553599,\n                1094121220, 3654162279, 1622703946, 148537568, 2385824297, 4061752858, 2543105581,\n                2622844203, 232849043, 3196673684, 2978718963, 1149528105, 2668110812, 2785402592,\n                3000100584, 1104866593, 70336191, 3432727170, 1109464777, 3746930874, 370280554,\n                3173358988, 3028594704, 2568130308, 457794435, 3383280274, 3346977517, 3484110806,\n                3153332792, 2425789545, 1474803746, 1781168328, 1989549162, 1032111952, 1331522816,\n                576372512, 1501541893, 2363428250, 1240303586, 2086180513, 3295867599, 691258190,\n                1008095124, 1776518245, 1495400690, 1519584986, 161360441, 1772372163, 4268396252,\n                2962917231, 2427675136, 2392936739, 272706848, 2620154363, 3998849772, 145937813,\n                4086621724, 1362430997, 1197771365, 4043072616, 916377810, 744218349, 1540693771,\n                2677728030, 553310668, 4229748447, 2011546593, 1970733497, 348172273, 762490238,\n                2152384213, 3411715628, 963109640, 3705793619, 3279035870, 426700692, 4278708730,\n                3586142296, 947806688, 1271342014, 715263589, 3455580436, 947104307, 1544685336,\n                2935774907, 2880317443, 3966149687, 2185422218, 2734810890, 3501513946, 2776353382,\n                4018451746, 2143808119, 736225303, 285334126, 2476018967, 3181930537, 2187294402,\n                3466164771, 2701302654, 3965790213, 2725436454, 3988416777, 3703472799, 1987980159,\n                923281388, 500013102, 74776770, 305061946, 3071827551, 486104690, 1384936530,\n                2111519171, 4124986050, 2429853625, 4015640194, 1966593586, 3123465599, 3341712852,\n                4213415239, 2396791960, 2722817611, 3004299255, 3857147942, 3516645579, 2072674201,\n                4175316375, 1683909736, 839905161, 316481248, 1683979804, 322038557, 677362982,\n                2973808772, 2596414587, 2730969268, 631888150, 1120341313, 1741270077, 3073620475,\n                1271943658, 1569862398, 3466496720, 4035716713, 2628306778, 2724723494, 1112102889,\n                3113513358, 2206163467, 2242575348, 2370657615, 3589371005, 1709622823, 2134510725,\n                3551117280, 3530138199, 922367384, 2890039831, 3559757981, 2345560704, 4221190559,\n                2332246771, 947123098, 3646442248, 488399645, 93684888, 851205014, 1145927652,\n                2376994496, 3976460398, 1154212282, 957935206, 353710365, 389412511, 1861961516,\n                3877610160, 1563516521, 1691953718, 1806258524, 4051249633, 2608084101, 1791724368,\n                4265828682, 98939002, 1131349528, 3141506279, 3747754883, 326404000, 2478362343,\n                2588680395, 2143336059, 3872805152, 720855604, 3231146872, 4275393682, 3215503747,\n                921660765, 2211457002, 29403278, 3071719374, 1901061486, 2988763100, 2195689231,\n                2111188612, 311057207, 1729785466, 339631061, 2566255664, 3558053739, 3017329992,\n                1834837913, 3911826467, 3826490857, 2838519210, 757698577, 3906322785, 4201094194,\n                828603290, 285313241, 2371084832, 3768763374, 511342167, 2751348498, 567611672,\n                3901537525, 637319646, 1586443362, 4009827455, 3278659128, 1377532409, 3930965051,\n                2016750432, 3351589103, 778112140, 3371765631, 1556855495, 2344340916, 684075640,\n                1324448534, 276848285, 2687066552, 744693016, 4155765815, 4053126644, 2290562982,\n                3537232030, 2910327479, 117184916, 3754357390, 101277221, 4265748564, 237634245,\n                1512268980, 4214404190, 289404203, 860074778, 2529446104, 1189797004, 2770192524,\n                2903941734, 3102660368, 1570144478, 3804933549, 3389588359, 3001536844, 2329211683,\n                1407331884, 374375577, 615849274, 2245748633, 2486770001, 1799357670, 4178076266,\n                1730691052, 1412641489, 4079190253, 167714251, 2752796561, 2070727620, 3447368889,\n                2159992367, 444800747, 3415638783, 27624656, 3085487729, 1630578659, 1765087260,\n                2272809030, 578971753, 3739324834, 26506801, 1503547836, 679618433, 421139499,\n                897586659, 1601201904, 808638444, 347513570, 4164626224, 2090150387, 1662217048,\n                2565908593, 2258638212, 2582887050, 3049842268, 463985909, 2843964551, 4162362888,\n                2547552905, 4002549257, 576087401, 4183702585, 1675063714, 2051066642, 3803031947,\n                2090450590, 3938803751, 4049575988, 1691762818, 1183856575, 3533472587, 2933123695,\n                1151648587, 3776826260, 1976737738, 3067649231, 1952953790, 3925101821, 3114071537,\n                79952452, 2770129385, 3762518198, 423331885, 3544738199, 209503969, 154615406,\n                1342149697, 1333109660, 3903240401, 4022118150, 3243003401, 3515425193, 3260933615,\n                3935151733, 4243861151, 4004716179, 2252411142, 3479623550, 619349788, 1822112124,\n                2051960597, 1448228280, 359331793, 3493974512, 1499344774, 3571669552, 608039076,\n                779605949, 2580871072, 2251891637, 518136121, 3357386849, 65613722, 1488211247,\n                1109960833, 67264203, 3897572692, 2842883700, 2822459224, 1333894132, 3652423328,\n                1827881649, 1486551958, 1571054719, 4230029963, 702745680, 478183618, 2813365752,\n                3051672215, 1590426347, 2661100659, 55101147, 1797728425, 2199206234, 3839519875,\n                1207276266, 3036038417, 3369821540, 4101140639, 3792842778, 2183838104, 3104645351,\n                2683538102, 717718063, 353527065, 3212696538, 221589441, 2454143520, 758857780,\n                3420448097, 239590213, 23041004, 912346001, 3384986593, 1335670788, 3610216946,\n                646607297, 2605581924, 3636256200, 2749404520, 3889217397, 3394201566, 1531295181,\n                1698305780, 736640736, 750817311, 2871203445, 3452494777, 3810316319, 4076603850,\n                2526619779, 1700794355, 746419560, 1898566119, 3189889287, 3338810189, 2729295103,\n                2714969082, 2936456989, 3452671603, 2798522437, 437710940, 82894680, 616072789,\n                1015800875, 1512158212, 75197689, 476169713, 192025813, 524644193, 3794046224,\n                4244912276, 847093610, 2301381132, 1503243934, 1403928108, 158653817, 3646897441,\n                751695739, 4092438272, 3539174158, 894208709, 3715408536, 1948913594, 11782301,\n                2703823913, 2270669901, 2370842917, 79716581, 877131359, 1231152090, 1856286664,\n                2471452235, 948189203, 674655372, 2821992252, 1092374320, 1563306677, 3626103505,\n                788520296, 1680746361, 2034836927, 2145159834, 2683063452, 2325545538, 1679113114,\n                1781024218, 139230084, 2908338938, 128867250, 2773176251, 3373230127, 395443889,\n                1634814549, 167825197, 1634796464, 1947803888, 2013614903, 879558209, 3672470617,\n                2886990675, 3688303523, 2987479497, 2229348558, 587602058, 3906889763, 3854711354,\n                1112626065, 3202904797, 3617514763, 3830554002, 2623747222, 739593158, 2754233724,\n                3280368708, 3050050571, 3069966571, 102976562, 2660327223, 3154039373, 247909998,\n                1031888281, 2121369508, 1224991377, 1890973752, 821369319, 113934081, 3380255436,\n                2479287499, 1913468809, 2502572678, 42228251, 2547189732, 4192517413, 1139547766,\n                1817165040, 726033457, 698589048, 750185110, 3384778627, 3490929155, 446473745,\n                103788750, 3026909394, 1055231164, 4240688633, 3651482557, 3385090223, 1111522119,\n                1564791281, 696626826, 428086133, 3067805263, 2544546481, 125648522, 427117978,\n                2492806758, 758056653, 3815718688, 1140343992, 1358469708, 1626866970, 1240757277,\n                682728998, 1466110233, 2962773326, 1742672810, 3256580108, 4251921945, 266158792,\n                118939513, 2916956256, 636321477, 2048301669, 3939990726, 1833678549, 3760980311,\n                947426840, 3055111977, 389083530, 2929345109, 4074386053, 1207476606, 2098662696,\n                1009814293, 1721235386, 2166808996, 3676341420, 1580747174, 2420879730, 2936498003,\n                3851224601, 1756566266, 1433935651, 2163763603, 128011896, 870207060, 328814509,\n                3272836422, 417135654, 2134909145, 123087570, 143532130, 3952868764, 2264741741,\n                92272491, 451493523, 776152550, 3732787266, 2953295060, 3559556493, 2328927145,\n                1387636129, 2840288941, 3683868368, 657932935, 53274814, 3241991768, 2880314385,\n                2643648654, 193180120, 655739143, 213868419, 44322408, 2965031094, 50461007,\n                3427495871, 146323106, 366166724, 1593053501, 3891132959, 2339070049, 2542807225,\n                3524375478, 2445432623, 567789085, 2455095121, 3487838079, 324840768, 514002614,\n                3617316100, 2192827359, 2607188524, 3653260415, 2685010260, 3200131371, 3698837126,\n                1195649853, 2454441885, 1343900861, 2888532827, 2243639168, 1855497424, 2235931710,\n                3907102759, 373855366, 2533941006, 1090440978, 1130102303, 3219593164, 3894670197,\n                1205959277, 1450376615, 885945151, 4234487411, 3955662037, 604242859, 1071651950,\n                2808913673, 3415749340, 3169116955, 1904598515, 1618878962, 524110893, 1274587728,\n                1769666847, 486193268, 1225449416, 54462106, 3167517049, 1853470197, 3313746392,\n                1396507753, 4241416760, 3339458134, 3634453408, 1073796257, 1414975063, 1460370363,\n                2106622507, 1792975007, 2815127526, 2891513438, 2795682287, 2704422611, 3162025328,\n                1087203693, 543725994, 2875511524, 540827460, 1415231959, 3628537754, 1896281252,\n                454300903, 2939977473, 3238208763, 1463107559, 744269904, 4129041087, 1154286436,\n                286775081, 4150671346, 3215856039, 2586174644, 2563594889, 2196859856, 3205583567,\n                1930394162, 1139079005, 1479679530, 1140049436, 451850993, 1680818185, 3392353496,\n                5765140, 3847965440, 2278586137, 1306641523, 972265605, 463819917, 1939105652,\n                2869882851, 239574945, 2564712374, 129695980, 1735318026, 1420648022, 2123663339,\n                2027937441, 23375658, 1937902123, 1034857426, 2862590085, 3506651190, 138519821,\n                1642289401, 1815640052, 3843060468, 3937934872, 2541728666, 3647355803, 411875524,\n                2988212624, 3529096099, 3244835052, 3434038830, 935500591, 4288020208, 756725580,\n                2264629201, 706062635, 135532718, 404448949, 4217556456, 717035686, 548833827,\n                3466891038, 2856986718, 3788562080, 1679206321, 2360817878, 1887014729, 2136917320,\n                2678810492, 2318105492, 77644154, 270026670, 2469142799, 1258494672, 3303653570,\n                3251229703, 242982511, 2902818172, 2974491897, 687201130, 1937150315, 2072181359,\n                342212755, 4068202459, 3451390875, 151260748, 2225880191, 2434808522, 916359556,\n                550136815, 746825531, 765768149, 2349587579, 4072937105, 174417938, 3148530641,\n                1504175015, 3999535866, 1504529431, 1181191996, 1294428167, 4294136970, 2112623260,\n                503759728, 3056809474, 3388597346, 3849318842, 3380162945, 3559697464, 1354499564,\n                3494243064, 2645181724, 2170305933, 79889832, 3023482863, 536000382, 3651862662,\n                3670290411, 2909658138, 1894327321, 1418292472, 1216369280, 2511425638, 1050447185,\n                2988291110, 3551716466, 4097897144, 1505967739, 2613042625, 4017491189, 1912275908,\n                2258357614, 1215885768, 3858405513, 3673669938, 677857927, 2958223732, 4048898278,\n                2169301793, 707103171, 956741434, 814165925, 3107480917, 3017104307, 3800299352,\n                1918539549, 3896439938, 3554811242, 2694303574, 925177824, 3032136063, 1749291165,\n                3998280950, 70049108, 3513897898, 2588855417, 2172098802, 1051273303, 3992914166,\n                1261460493, 1213244238, 3496736059, 4225265498, 1061148097, 2074121139, 3310195209,\n                2831272871, 3233236277, 2445284097, 2450635558, 1605855513, 1131284715, 3245154368,\n                1322372270, 2869178843, 2039261099, 1645142070, 3892994082, 930236435, 218807811,\n                2708516696, 2919789769, 930030621, 3846860441, 577616256, 1404894950, 765463042,\n                3314145877, 3733206019, 124841976, 3710712329, 683923696, 1125790086, 3250988117,\n                2181832546, 971084557, 815150268, 308158225, 443224487, 362401816, 3552358764,\n                3135530439, 33121314, 2154300664, 3768676730, 4180406514, 378587418, 2431499223,\n                2994441286, 1808890752, 3869540064, 1119394536, 4246394107, 1591781751, 2468039252,\n                4073888957, 292786140, 3200606452, 1487044474, 1803005899, 2652603821, 1815522155,\n                2672502342, 3653226357, 4217143309, 2889763440, 2152398432, 3980661644, 980636278,\n                2406751312, 993261713, 1673889350, 1373487543, 272064537, 3918533839, 3803826067,\n                4142045136, 2526731415, 2509904676, 3639345361, 974151539, 2071745290, 3793653508,\n                2230238759, 1813052313, 1190657876, 3606736124, 1461775176, 3044525512, 427548577,\n                3178636804, 3979867448, 1551173298, 173766289, 659710123, 63335203, 3730225690,\n                905952458, 1672077454, 1507641131, 1469489153, 3225770126, 3203644989, 724743997,\n                1500316720, 3619698934, 609736340, 295270861, 1627587660, 3874266477, 3066185777,\n                3368074666, 1479073449, 531786015, 746257560, 989895752, 3614796517, 2035671335,\n                1419905384, 717808529, 2807381697, 2747634147, 454509787, 3261464931, 612828385,\n                4209343220, 2085288654, 460480903, 10, 10,\n            ],\n        );\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        // - (!TOOM3MAYBE_SQR_BASECASE || n >= SQR_TOOM2_THRESHOLD) && (!TOOM3MAYBE_SQR_TOOM3 || n <\n        //   SQR_TOOM3THRESHOLD) in limbs_square_to_out_toom_3recursive\n        test(\n            &[\n                9525251150715707485,\n                8587763504821516080,\n                2117747772997939438,\n                3548585473389575775,\n                4368725143826266690,\n                4151422622588495985,\n                4202765536837222381,\n                6536868548778498226,\n                8537832607905834756,\n                9336293381477767433,\n                18090648844404510506,\n                3105525971724643379,\n                12707275375611860976,\n                3317865524960562713,\n                823982841074944760,\n                12143276137407678534,\n                11718343265209945098,\n                972615260809311500,\n                4497808493385741158,\n                4284234930706130439,\n                7584650555635583701,\n                13401700804872779083,\n                13056378070380119176,\n                16204947268987935954,\n                16754422922407328446,\n                3616382235390010996,\n                12081821858664337228,\n                12298806784194631642,\n                11068381938728473266,\n                1166551759858966293,\n                5303215576037036724,\n                1459955941298517816,\n                4011807711704072033,\n                7096373155148960903,\n                16682910161941435568,\n                8024381590924490417,\n                6949947117794717851,\n                9040317863012712195,\n                4785228307667500564,\n                13067737071940529766,\n                1789161767332960961,\n                10829540163630385583,\n                7172597173152077539,\n                5503961818523919125,\n                8087706384348918471,\n                4492802132769991717,\n                1188164630850319633,\n                13164198248699467318,\n                16183338424361636779,\n                9532503617554385117,\n                12467724616830286857,\n                8664003772679010381,\n                2864953899335878328,\n                8424900728671425836,\n                9730105501383490341,\n                13243619488513115315,\n                1992085995601070126,\n                4541056932031034892,\n                10048052926002006333,\n                4149742854488410708,\n                6604581724576852902,\n                8116872836838236679,\n                12909377853889042956,\n                2618412544527404589,\n                6240717678602672320,\n                17262717497935134385,\n                8933339373489336979,\n                4555255977252543496,\n                3187455824539014469,\n                1325520967350793711,\n                17902242471445880413,\n                14791679552918179638,\n                11505616209756266048,\n                18413169815441978527,\n                17159886807923826780,\n                8658827867630023515,\n                5729773240957150070,\n                17835287398020799335,\n                6255399748948477863,\n                18317413051795712550,\n                10021633350178308396,\n                9052815322626548310,\n                6892740207763967297,\n                14104401112852513805,\n                11421574096539340635,\n            ],\n            &[10; 172],\n            &[\n                6521696094589149641,\n                4476496593920112007,\n                281309484216721907,\n                3501015758154527618,\n                6372184862122315850,\n                13688972428608086357,\n                16317656242078388643,\n                15101948131376431224,\n                5029853447670483189,\n                11857951831679478013,\n                15911717557773435334,\n                10081601695810456394,\n                1782014398144673191,\n                14288539596211323341,\n                16626396315520681674,\n                17495406981900207848,\n                3659501794893247590,\n                14880407439063352148,\n                1525506733701671488,\n                12123557288153863266,\n                4155930172230135129,\n                4600799950904277212,\n                2074105507200300978,\n                1951113240555337310,\n                3387612412432668331,\n                2623403007819134632,\n                10215465147710453219,\n                1047131846193932057,\n                2254695478731133865,\n                13171169631787598429,\n                6585033052635255371,\n                12479656688140585709,\n                17676979602274596064,\n                2391506265209764529,\n                17881709395411630221,\n                9746579689294008870,\n                13656540280781249559,\n                7229227979790181928,\n                10738687500038878332,\n                10338166995316843087,\n                18351464591211450630,\n                6545644910633268964,\n                18257631102917691063,\n                15830085040765163904,\n                9853171674704361990,\n                4352529114219728818,\n                10371228500919079735,\n                12485073622709250281,\n                15200491753279014192,\n                13246789146543897642,\n                7234816350013842534,\n                17595498453701622340,\n                16417158337244228654,\n                15114011684238968813,\n                2755589762268003783,\n                1373249593523787270,\n                14512161456400844802,\n                17568489402488073296,\n                14869330884086877990,\n                8932022192310164117,\n                8839191912876243333,\n                11198937113445572692,\n                5498890674282919428,\n                8711441066608447276,\n                9856393259542505349,\n                12059896877231420142,\n                14513435611803050697,\n                13933775272811002776,\n                10845024410875135797,\n                10964948883907295543,\n                11008031582623668960,\n                18305235824609309463,\n                13936721840960294996,\n                2044893320015902126,\n                6586201943401086906,\n                7091941077862592671,\n                6651723114251478907,\n                10079416802056897654,\n                1539419857340461721,\n                9726041209688664271,\n                1989043203520864507,\n                15243466181397237955,\n                10868460317029042323,\n                15073556725205188647,\n                1777713915616219774,\n                1475371842789103627,\n                3970746438630823745,\n                15013960969967729832,\n                14426785376130414731,\n                7401374305322657250,\n                13337358005297018111,\n                3695563535331097080,\n                3412314266436852339,\n                5460481935370382358,\n                5789922616650608658,\n                2323320016068189849,\n                4266010817511936746,\n                3361964336501286415,\n                14185575797132229991,\n                5365726025616057734,\n                2992361504309085575,\n                11012270044677505862,\n                5139796591831649499,\n                3466076567659969205,\n                16705667066832559351,\n                5158533291895496483,\n                3746616024396156784,\n                2785159065183843560,\n                394631110435288330,\n                13638544389702077257,\n                15244306966358109382,\n                18440767283552965938,\n                9602917640375617089,\n                15115704595863040058,\n                14059130653134044307,\n                10288209935028450560,\n                14443546216698200603,\n                10258953817987364134,\n                9228449901492508549,\n                13814303746571428462,\n                16548279012015496124,\n                1070860953873829429,\n                5156291658423572264,\n                7302978081219328732,\n                14240414203936719255,\n                18095404503533136331,\n                9038473668915574152,\n                1652552463718420588,\n                8063692498356788885,\n                14965328966174753198,\n                9058258371493607659,\n                15788310587268630945,\n                2538688827757657801,\n                17765893059803430559,\n                7418620390864905673,\n                12272658634918366651,\n                8323094697253518567,\n                1543060190059627517,\n                10790616911161792244,\n                15839589421315724004,\n                11590668330600693342,\n                4736357234864118945,\n                5752655573361113076,\n                15181059741781119493,\n                3336974282102801709,\n                4224895603965182820,\n                10906356334967598732,\n                936316274897213383,\n                1913155927351588139,\n                11099566112059813190,\n                5936790069913243447,\n                11148342313918998148,\n                15668128280235073164,\n                10654047073134913897,\n                3624998946013372412,\n                6006678731810089858,\n                14292046510765622790,\n                8463949827558560433,\n                3930745276585662112,\n                16423967958955090871,\n                12480778808376637277,\n                12047684158052058686,\n                9338456483853840552,\n                8423305664340603430,\n                13808682977569853100,\n                9298864371157050935,\n                11728939008585660650,\n                1313559708163679747,\n                9976580221699673100,\n                7071836326317347417,\n                10,\n                10,\n            ],\n        );\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_3_fail_1() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_3_scratch_len(2)];\n    let mut out = vec![10; 4];\n    limbs_square_to_out_toom_3(&mut out, &[5, 5], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_3_fail_2() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_3_scratch_len(2)];\n    let mut out = vec![10; 5];\n    limbs_square_to_out_toom_3(&mut out, &[5; 3], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_square_to_out_toom_4() {\n    let test = |xs: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        limbs_square_basecase_helper_1(out_before, xs, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_square_to_out_toom_4_scratch_len(xs.len())];\n        limbs_square_to_out_toom_4(&mut out, xs, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    // - basecase in limbs_square_to_out_toom_4recursive\n    test(&[0; 4], &[10; 10], &[0, 0, 0, 0, 0, 0, 0, 0, 10, 10]);\n    test(&[1; 4], &[10; 10], &[1, 2, 3, 4, 3, 2, 1, 0, 10, 10]);\n    test(\n        &[123, 456, 789, 987],\n        &[10; 10],\n        &[15129, 112176, 402030, 962370, 1522665, 1557486, 974169, 0, 10, 10],\n    );\n    // - toom_4 in limbs_square_to_out_toom_4recursive\n    test(\n        &[\n            4139948165, 1538275035, 3244920878, 2576965792, 584068468, 3054546876, 2629688518,\n            4253271747, 3723872815, 1652066683, 990821089, 2335421805, 1989570928, 240486517,\n            2872315587, 3869991906, 3870517664, 1540804424, 397183643, 3750033565, 1433260634,\n            1506168711, 3616651625, 512028445, 3746712828, 3278592880, 2611514549, 1214563129,\n            1259227909, 1067976218, 3425169051, 741795595, 893688343, 2674408703, 3694908868,\n            2478153735, 2220661625, 1022546736, 3719214155, 3161293211, 4131981986, 1473264088,\n            1651777063, 1438502715, 290022167, 59234682, 3458968160, 2552001459, 3451530289,\n            3800073253, 717882913, 845719525, 1038699111, 3058303772, 1117505279, 3682430977,\n            2869037104, 2562493618, 960519305, 4147639705, 1817463351, 3166022129, 3200769866,\n            789666262, 2654485924, 3686362402, 2179867687, 3980226915, 3671542918, 1896992204,\n            1514962591, 815867715, 3924270086, 4262628477, 3977258034, 1340257907, 6618754,\n            2720861064, 778635062, 682181834, 2891943360, 3002120306, 3399643048, 3139375492,\n            865948953, 3273305779, 388881948, 3544744413, 3963050187, 3002594763, 3339669779,\n            2722426929, 1246819181, 2786076007, 708438365, 1013683719, 3027751127, 1766272571,\n            2839608714, 2866928644, 2107420563, 4035553421, 2376700546, 621608197, 1993043072,\n            2666011084, 2265522039, 3230507984, 2869423257, 1776134078, 2413254013, 3859414865,\n            193597892, 4255395370, 168637254, 3364100552, 3883433219, 3117797624, 2738841992,\n            3052596910, 3280507008, 2860095630, 4031447725, 3454885698, 1783630119, 3036202894,\n            3585701130, 4184585287, 1329572188, 2352399996, 3076023682, 2989927975, 320530428,\n            2081170907, 933271377, 2974966675, 3452895778, 2331110373, 995864819, 1177147317,\n            4084213472, 1179430541, 361665403, 2401303908, 3027157843, 2778759588, 1031442202,\n            542151276, 4259656091, 745358488, 2580062497, 2004998882, 2066508478, 341659477,\n            958017378, 2415007725, 211645068, 3630737942, 2670158596, 3544834081, 2043760261,\n            2149621570, 1287267516, 3353570061, 3758258174, 4171807709, 1363035595, 2692148345,\n            3728232161, 2672522097, 3234166892, 1337714504, 2475062988, 902334395, 3470019951,\n            1789926953, 39991566, 1071624731, 2480238280, 2010573056, 2975909089, 2685102208,\n            1752958961, 2957725128, 2441562510, 1615057382, 2739912075, 962437876, 1445592393,\n            750430353, 2848157371, 3515397641, 2140566969, 3080139371, 3564834440, 561913271,\n            1812943111, 1349101061, 1627550717, 3467766096, 194766042, 3125120919, 3021598191,\n            2389614341, 2536207717, 3687483968, 3746428277, 1304917109, 4262793424, 1046105397,\n            103309888, 2808595193, 1896772845, 2625389818, 1425524079, 4245371665, 1376995745,\n            1906643058, 4123808395, 4010921636, 3668036324, 538106732, 429893286, 1473862381,\n            692485290, 728791765, 4006267410, 2159349173, 1146991809, 1105326804, 855626330,\n            2350214961, 3945267379, 4182769713, 1218539569, 2795526933, 508156606, 1596052577,\n            4135932990, 4009064452, 3154371819, 1789912473, 3737225773, 2339289640, 382599364,\n            2822801808, 1231473766, 3195594892, 3686689017, 2674031129, 2724276086, 4112764261,\n            79570030, 1908454621, 270118882, 3204318684, 2240304382, 1923066108, 3669840087,\n            3114917464, 57715381, 3015749933, 3183317351, 2563719945, 2409212385, 2256893938,\n            718636813, 3965735223, 1345089653, 1264444, 2296052850, 1092210950, 3468764525,\n            3967443918, 788417425, 1924956491, 3656370968, 4266402294, 389687964, 3067575949,\n            3786278950, 4368934, 3414260125, 1500941491, 4197777812, 1901284905, 2548021755,\n            1986057606, 2732888210, 3872664452, 2787539702, 3264559111, 753549553, 1048190618,\n            2900005727, 1868077400, 1284542693, 3154799998, 395567255, 2005460208, 4005052806,\n            1893310835, 3217932531, 2607307407, 3917316670, 2028218244, 3745680211, 2397481422,\n            736482987, 1916844834, 3868328610, 938512555, 1559481864, 729544587, 3690980706,\n            1759014647, 2060717833, 2250640148, 3619925046, 2153794810, 4127168634, 3259374700,\n            2051907961, 3964686808, 3841055905, 4242264783, 2314742304, 2209077724, 2577227865,\n            1487635776, 1585379583, 3475070421, 1683734827, 3363053669, 3722095029, 3857335408,\n            2852846850, 456879372, 2473892714, 2928343667, 541075767, 3595876467, 1688710352,\n            2071331730, 1142047400, 1817453168, 96871997, 3927306877, 3090061646, 3474317652,\n            437148773, 439538568, 324686794, 772632617, 1424328970, 580538580, 3999279969,\n            2022469388, 2802303848, 1147488095, 2053949131, 3046702544, 3822972379, 2920233521,\n            4031279543, 2356245098, 2951036256, 3287235943, 2760424423, 140913700, 689952328,\n            3916658401, 1694797888, 82150998, 4075118605, 1967095926, 1704543314, 3154572744,\n            408071699, 844684417, 1174429103, 3583461805, 1015646627, 861970508, 1906905868,\n            2272773809, 879277860, 2980820537, 1917774935, 247497916, 2403283458, 553129122,\n            3303057196, 4005726052, 1808761740, 1909802116, 964057278, 1586240623, 3097009405,\n            2048123311, 2481968244, 3155267854, 555253647, 4027932249, 229358586, 1015669317,\n            4112551330, 351151415, 1331401879, 1749898409, 3352469407, 710145444, 2903798473,\n            2876271745, 692844392, 2354652850, 100021926, 4212629124, 2971597719, 2697935131,\n            445511347, 1636699871, 2524940444, 1303870696, 3634945394, 2398930906, 1337769794,\n            3955409228, 2657553814, 1455809030, 701994564, 374320080, 519334058, 71402463,\n            2995013099, 1573823285, 2419768029, 4108602983, 4266125692, 3514998795, 2367509976,\n            2654621106, 562141353, 3101668250, 2753822172, 406447740, 4132920329, 3645443797,\n            4221410098, 1000631411, 2319369935, 3987192941, 609889174, 569928846, 3471449767,\n            761399938, 2925981744, 3610481831, 364846710, 2579622933, 1755359875, 3327963251,\n            2230753636, 3897751713, 3685870953, 720576993, 4008645094, 2170973511, 3057371253,\n            2362087099, 2415801497, 3804893423, 874616900, 4188156090, 2114593709, 3626784402,\n            2090293821, 1178445498, 3501583487, 3787814639, 1160994150, 3773261324, 3438864014,\n            3474697300, 3232616282, 3082635737, 3290126053, 1041836645, 1497490946, 2116412677,\n            78748560, 2610841375, 406515051, 2540982558, 1278151559, 910145724, 2942229044,\n            1412896287, 2420692111, 2829066497, 2762072644, 883699073, 4146766932, 968581437,\n            2262117978, 4102625453, 753476188, 3237270935, 2018964783, 1357948517, 655508609,\n            4163647115, 2220146134, 3618211357, 4228425409, 2053237402, 260628807, 4078275010,\n            3945722198, 3264848882, 3968277361, 1416596317, 2102516261, 833088009, 3907840277,\n            2017643605, 1067842330, 1357529659, 2472927668, 1649000973, 2222344018, 3784049396,\n            3227757245, 2898271180, 4043134215, 3862532400, 3955686618, 98246491, 3365854338,\n            947695294, 594787742, 320576666, 3333798817, 1904306436, 2975705325, 2991782885,\n            1736852103, 3844447384, 1817569919, 3224273837, 3598752781, 1577803239, 2950514537,\n            1562681940, 4068361583, 3868379584, 2088936482, 679461158, 301319738, 766873076,\n            1943559698, 2477791081, 359203531, 248689484, 1396200027, 1850343941, 1125961151,\n            3934233911, 1148111021, 3719148359, 1654482658, 1197396856, 3954632576, 2122559365,\n            197233285, 407487633, 4158181537, 3053296658, 2799166403, 2081625494, 844237749,\n            3509575975, 3964633958, 4179613577, 3338942399, 3816968642, 3007984156, 872005283,\n            1859074434, 3956327811, 56397907, 478149678, 4026802122, 1384639138, 368837837,\n            183900171, 785221208, 3231446529, 4057339631, 2617885657, 645209974, 3749331053,\n            3387891965, 3097021752, 3337686487, 207272201, 4090597826, 1337950862, 1489880288,\n            1626252138, 1844132502, 3785436754, 2455659736, 2722719185, 3556302565, 1609527187,\n            2416226913, 2766580345, 1869533642, 3531500453, 438426623, 158796542, 3488893438,\n            3084370998, 2058790923, 1154169553, 1385226416, 1509103535, 1162048903, 797370674,\n            170054390, 2752067502, 3119807393, 1923267976, 3762356971, 1978871808, 3723074764,\n            3460095249, 2837581806, 73932499, 3524773614, 2454111707, 2818213028, 3004873518,\n            864066450, 3576610451, 2315784966, 151779632, 1178401043, 3765993358, 1348598145,\n            3576623674, 3204205857, 3883955902, 2023814627, 795831378, 2827807531, 1331064687,\n            1837025931, 3540224087, 1381156075, 141174913, 1539904944, 1709050097, 22990830,\n            2938269544, 3188893513, 1701451446, 124677463, 2376122456, 3735869779, 3855792596,\n            3836459842, 3548479279, 290636702, 246664, 797902866, 2875170064, 2475070809,\n            4116284414, 1208231388, 2828093914, 3711751904, 2624075253, 758366641, 4278761943,\n            679106142, 1679478312, 4110848533, 540768264, 3004089076, 890051787, 1527108158,\n            2687541799, 1379201802, 1778300800, 3159280475, 693175137, 1706052065, 2740998490,\n            610778078, 1254469442, 555145750, 4257282365, 4088567402, 2722156643, 2973326370,\n            2580839471, 2297203610, 1325248528, 2289415165, 2027203297, 118624041, 3143737015,\n            3150787590, 2027511535, 3762291585, 2693532637, 2791300523, 2662758110, 3136152569,\n            3442748961, 1004378785, 2651776322, 2521157696, 2559348070, 3806708201, 1867376555,\n            3308198648, 792265193, 1257869334, 3432781024, 3378655514, 2353252813, 320451009,\n            3968297418, 237777247, 2490314264, 3266186675, 2255726749, 3147278539, 564923137,\n            794399730, 1624402708, 1616480718, 3606683399, 757916498, 2887385172, 2854589997,\n            3276729119, 133652525, 1045552210, 2262021731, 3248481891, 630857187, 4136667563,\n            3680583667, 2458003061, 102973943, 571665205, 4057786651, 1569357837, 1410019960,\n            1524881406, 1358182388, 785354230, 3829905260, 213334008, 2101845387, 3881098191,\n            1678603844, 2662511679, 2818265908, 3742761039, 662343317, 2881658894, 3293956365,\n            3576730814, 491183503, 2939708573, 879732964, 1424495345, 4226077578, 1724320764,\n            1649293059, 994517776, 3889024255, 3687388011, 2119938117, 2827748429, 3235814626,\n            1943795862, 982655659, 1583416575, 3637162242, 2899231071, 2356372330, 3229140115,\n            198960123, 3846475068, 1379416053, 3794102303, 4194710328, 1622023564, 2980258783,\n            1612348456, 3206356835, 2346630402, 955347169, 821327724, 4081137787, 2863165917,\n            2043355649, 448503436, 3529831118, 1098373576, 2154452300, 3915536064, 1741721503,\n            3989667375, 2498018598, 3111090221, 2451239649, 371187044, 2476450463, 2115422939,\n            3108069162, 4258140100, 2689547883, 1035006996, 290446056, 3920544792, 28092053,\n            2601721063, 4021987364, 318467100, 1559961229, 3913031650, 2150104709, 49270356,\n            3722496751, 2311386769, 1143265675, 3292662688, 3972381519, 2455100296, 1617099761,\n            2421726076, 1783080166, 2261765086, 1218624302, 2857474674, 2302060834, 3546888248,\n            1032153741, 2340941676, 328079068, 2490189793, 740867935, 3624104142, 1585037711,\n            1856136911, 1717156296, 2551956249, 370730527, 1811127937, 671199828, 1973541789,\n            806145565, 2632536732, 2824694830, 2549158326, 3875815943, 941204372, 1001702521,\n            3826400052, 4193710040, 50745642, 1293062837, 1041970744, 3817762988, 2674255278,\n            1058357022, 3904842671, 2225254087, 4291341999, 2609553612, 4143229959, 4237512560,\n            2910271684, 4066468195, 830828098, 3194488049, 2949340222, 2932945527, 2929064674,\n            1551247455, 3984924241, 4112937654, 1045724925, 2309857853, 2137885547, 2923347121,\n            4181282731, 2915373843, 1568721132, 1544506706, 2853606986, 1231383293, 2575465448,\n            3131073921, 2053909572, 2942680140, 396827888, 3916340049, 3526097716, 3106089469,\n            3522561956, 3015937009, 3739198049, 1425146641, 851135341, 3019020815, 4249482313,\n            4186849406, 3142115855, 4096457822, 1432901702, 1952216623, 2397263357, 1868450777,\n            1021098076, 367053436, 1889683424, 1528567953, 3087804116, 689228227, 2409781986,\n            2752631639, 2960393344, 2301774469, 4157044152, 730723095, 338324989, 783259147,\n            1430926216, 364208092, 2781791540, 805329298, 3841626209, 3970169746, 287294352,\n            3731446660, 704479128, 1206988970, 3298938102, 89005416, 3951683481, 835191365,\n            679211944, 949588029, 4076949094, 1529663160, 3763599166, 1992389156, 3959751596,\n            2621078932, 750118917, 882657993, 300498126, 1496181503, 3757618374, 3957243704,\n            3918083074, 1894830898, 1138422947, 3463164955, 3636023625, 257441260, 1054022983,\n            4011330770, 634925427, 1390194826, 1996961100, 3964708260, 1299498822, 4278592313,\n            1555238361, 1205023411, 311299324, 236721311, 3010275108, 773372856, 3619575032,\n            1947972130, 922773743, 1813182889, 1430693131, 1140839147, 3512260679, 2399704504,\n            2884240894, 3489240991, 3667939455, 3637582953, 3111367472, 2822381631, 703081566,\n            3036849914, 2845998620, 773679554, 526636749, 3314520937, 13776732, 796381020,\n            3189459033, 1934043296, 139616721, 2828193945, 3267247609, 589042452, 1387645753,\n            433640237, 1712804027, 1437726094, 2315749526, 27879840, 2472687972, 4005884263,\n            2644286003, 3168722815, 3959061551, 2404760593, 987990445, 2910703005, 3677874076,\n            4091231914, 4119403177, 1473482319, 1037359752, 1631420571, 2267882683, 444729973,\n            2607180061, 2466991138, 1500108829, 3858708078, 941735860, 3449116164, 1032454377,\n            1971102799, 1555909634, 1983708971, 3293773413, 2291541419, 1909009948, 3757184049,\n            1659282643, 3010427039, 2230678723, 3692534068, 1571464599, 533744779, 900521822,\n            737309762, 4215816039, 4242327287, 3884240140, 2486598498, 543513492, 2325077751,\n            1441237310, 3453763982, 1762843580, 1455435252, 3579975980, 1431912968, 3904977435,\n            3063717287, 8851622, 781126329, 3347412227, 2209219872, 2335275863, 4089034368,\n            1297331762, 2395499389, 1735909479, 1433771236, 1874079286, 2401526645, 3979584502,\n            814026601, 430924818, 2581307431, 643293685, 1092152530, 3681627832, 392138944,\n            3285203886, 1924582243, 3446213836, 3409964164, 2159521691, 3859916944, 485937737,\n            3082540537, 2628652573, 2085005488, 1570820241, 3255326214, 2324771674, 968029126,\n            551752207, 2734613650, 2519802827, 770398677, 588214604, 1769698821, 1440668325,\n            2016437193, 1333156524, 1671885991, 3833566075, 1771521418, 3300003753, 1697599567,\n            530705419, 2676238526, 2443737372, 3125150670, 321490908, 2097084981, 4189778990,\n            3647867606, 1625184465, 4268086243, 1553897575, 2306003829, 2205478208, 3688371963,\n            1133515039, 2669386733, 2223812538, 2214358594, 96593859, 4190632593, 1452197431,\n            1135606083, 2782212791, 2805304587, 2716383209, 1021017905, 1848454580, 637206058,\n            3630544172, 3327436426, 1359058780, 3757283546, 4081247529, 476986455, 2103327529,\n            261011811, 3377587780, 2208830435, 2954839100, 3294212947, 3523724980, 572494204,\n            2312304117, 2237590844, 1825143066, 3523469615, 2955256347, 2205596286, 3913732250,\n            3169279660, 211384653, 3129298603, 3451891904, 1392695925, 3936245195, 2315924122,\n            4256973470, 4208012834, 2914727856, 3790633264, 1352414024, 3268830516, 499517949,\n            174767898, 1457739315, 2708146151, 462102433, 15650350, 442999273, 3598360532,\n            3949145914, 4359748, 908554163, 2068608696, 1151136361, 3549502220, 3930154182,\n            1209162050, 2329490399, 3594864904, 1344017956, 2894570798, 1303761033, 880238473,\n            1215599665, 2238714951, 2775189345, 1440983553, 1580240888, 3808296473, 3676441154,\n            2656910063, 2780259105, 440787528, 2668696704, 3016754110, 73074429, 3699432385,\n            2168409706, 230768634, 404640783, 2512075223, 1443974378, 133144391, 3126908580,\n            1897307179, 285748108, 649198164, 3258373165, 619570044, 3705326499, 629753586,\n            2028146489, 1628060293, 1463155954, 594254860, 4203563010, 3465791513, 3768995488,\n            1179379840, 2659134767, 1087684809, 3708559675, 9397244, 3404138946, 3058055295,\n            3741047003, 900728367, 307309239, 1593283123, 3051916956, 2277186179, 2986400049,\n            2430308800, 3704675438, 3404110336, 3483462036, 66099132, 2203628450, 2586730089,\n            2420731626, 4042472356, 3655978764, 1856089837, 2068061659, 116363573, 1803321038,\n            802435566, 3965886166, 3600776237, 1563947327, 3756986210, 3427924426, 1576590362,\n            1417428898, 1027624544, 2293607126, 3716905851, 1499703715, 898967036, 2023639876,\n            45607182, 3304340202, 2558449320, 2150787328, 2110495244, 104517510, 2634417946,\n            3511927445, 2617983280, 1519839278, 2080506268, 3510088443, 3374267769, 36753302,\n            1909343363, 2722532212, 3354690838, 256523639, 1948127569, 819808246, 841164328,\n            1517898429, 1087337370, 2670414963, 179511035, 4259795329, 1457200223, 1097109826,\n            3252883568, 2453318932, 1234667752, 1093803264, 2111693083, 3511689983, 3823822344,\n            1905658711, 4144934159, 3435456888, 3949822649, 1400424939, 3976610504, 1652341050,\n            3552094049, 1465533861, 700947875, 2014956419, 1226278410, 573601914, 2391611176,\n            896583523, 3273421219, 2062693644, 2473342105, 3141025520, 14886427, 3812114714,\n            1853239414, 530505244, 2291720315, 962867072, 4243165058, 3342695710, 760937000,\n            4153054130, 2531380355, 2739976263, 469524224, 1295576354, 315429703, 1260352560,\n            2029030092, 3865675090, 3044871516, 1022845266, 1911371710, 2029537835, 561158867,\n            2174744632, 1969959061, 4102284246, 3981415584, 845291562, 664613325, 3222931218,\n            99095455, 2730475474, 2493017145, 2530889390, 3882983360, 2776234628, 427527768,\n            2075694791, 1903254438, 4039149192, 30770042, 2496262182, 1075501546, 1857577671,\n            4034387356, 1298016668, 554687483, 3783554334, 970938499, 2302276336, 2465839556,\n            2875226988, 3946025154, 1605779475, 212491074, 2039324795, 2511272148, 3923741618,\n            666705577, 2301221278, 2244215846, 480775695, 267961632, 1398864729, 3539474141,\n            2896696240, 3188210962, 4263170711, 2166709809, 4043606422, 2748308566, 2036300676,\n            3485163043, 1231312509, 2222796131, 3353346189, 691566953, 1926907588, 3143133996,\n            218024902, 3303115913, 2741933253, 3455832203, 2188548704, 330825015, 2988198047,\n            4113395594, 4274856590, 3454076086, 462612564, 3932732738, 2847173559, 94324448,\n            302685117, 2819834066, 501928546, 2918695331, 3730187626, 4047509480, 3958497929,\n            1405651323, 5198493, 1435107633, 1798603038, 1425239659, 3810371916, 202010946,\n            4127037492, 3579977862, 4105633677, 1697820216, 4098674964, 3877256724, 392149415,\n            798840279, 3279443441, 4160309648, 213003724, 240523366, 4254997725, 1194184072,\n            2242246894, 1565800018, 3099244883, 1899811749, 1295189975, 139297877, 1760389535,\n            1791623988, 2047447468, 2718025083, 478431801, 2261672798, 4163824143, 954044303,\n            166186880, 165190820, 3209346046, 1767632545, 3208218630, 2170624938, 1520217187,\n            2770731000, 31985474, 1167140123, 1247499067, 1192858555, 2000398094, 323618032,\n            2385630760, 263840016, 3630549869, 4085715997, 3305918489, 577978082, 2569352262,\n            496663850, 3244713533, 1371046284, 1053634009, 1596337603, 2530667353, 3571699092,\n            2985850617, 3506241759, 3886001202, 321142492, 3535666188, 2809260421, 2520009183,\n            505825281, 1161639420, 3107872099, 1807858866, 2661099911, 3683524084, 1968535972,\n            2137059248, 520800332, 1760245308, 3261727857, 3808954978, 1344215885, 1106658531,\n            2477902650, 3739801516, 2862406397, 3752206269, 2406717892, 852545984, 1600683943,\n            515483582, 1404164392,\n        ],\n        &[10; 3074],\n        &[\n            544355609, 2080612505, 474062054, 2868914381, 4175375943, 2284265987, 2006086926,\n            1022807704, 1191462239, 4057295077, 1742845546, 963995393, 1793330401, 1777031405,\n            3410368287, 739939995, 1041362294, 2237517990, 3085234326, 1911882398, 1000116872,\n            3212496084, 3541713881, 486343212, 1144839297, 1769684617, 1326843881, 138007851,\n            3707784046, 495830531, 1399261079, 1847139479, 2758723677, 4043629100, 1320821374,\n            4234751272, 3837875302, 3913989801, 1186691311, 838895898, 1384482259, 4283811402,\n            367047088, 3643107896, 2526085076, 649223414, 1791169839, 2849235592, 3419557243,\n            3263372986, 3370732365, 2796562442, 2444974720, 4023941956, 219991109, 2722363964,\n            1745771730, 800298616, 3768599036, 2911796707, 4207776422, 962505160, 2276283929,\n            3745370900, 878306616, 1043868890, 1598992851, 3541405234, 3585481924, 741739358,\n            768416754, 2104158416, 667188290, 94999734, 1449245983, 1304898387, 3952648610,\n            3749151338, 3907793782, 4270886514, 697343495, 462890036, 3107970742, 2832474331,\n            53068652, 1591760679, 2493047965, 2269712178, 3127212332, 1627727636, 220072933,\n            1058723788, 239782222, 615409930, 92540838, 2239440158, 3229400779, 132365712,\n            2244883029, 2717014577, 3284349185, 2715245566, 2087016028, 2149900384, 2668083770,\n            3150016178, 4104628003, 3235315111, 116298815, 2863524918, 1851896166, 454745201,\n            2517300177, 3047989747, 3119930396, 3686293348, 227886227, 3942608635, 2173702672,\n            3705534387, 1370183089, 558572653, 3069040441, 2683696611, 3880030022, 2807151772,\n            3568078249, 3853541718, 1077019831, 1531990636, 2961805760, 2610976776, 779162368,\n            823574272, 1069286399, 3289229818, 215126626, 2410932476, 2128498220, 3276432715,\n            2928896858, 503147677, 848353265, 2922884423, 1302835606, 2596230484, 2703044913,\n            1523643853, 888898125, 3158939337, 1235805909, 3942344516, 3809919793, 4237160464,\n            1727222209, 1680614061, 1319363756, 1944995002, 744276474, 3789911609, 1595380803,\n            2797067237, 3627131268, 2372510515, 3029519061, 1552562132, 104910634, 666808881,\n            3689834577, 148283381, 2667276613, 1387543237, 2874274079, 365866176, 1748800741,\n            461139348, 1430749296, 475634569, 3863794037, 2976737976, 4226341364, 861052916,\n            2875033169, 3833545214, 1848290121, 673168334, 1696741758, 1567226374, 3750857642,\n            3352956156, 3512091573, 3065375646, 1061612315, 696567469, 2311589288, 1868895607,\n            2411058075, 2448930081, 3347410796, 1698003839, 2027838925, 2090786401, 3902975685,\n            1003715587, 3624383073, 810421072, 676664439, 410073539, 1745213221, 1706439870,\n            2839758065, 396679277, 3138119414, 3201857757, 2682423198, 4121890843, 399855883,\n            2905061072, 2453953975, 2703354213, 554677285, 259183339, 2188009201, 1361539690,\n            3631921384, 2749692972, 2594065240, 852665377, 2764939748, 1376526587, 797837718,\n            1107381816, 1336266326, 3851966951, 991265584, 2684419585, 1149376886, 2399653029,\n            807442420, 3882889584, 1226935278, 2244303599, 512947831, 2947892533, 2275841879,\n            2092713823, 285115983, 1600604463, 1184575984, 2741305334, 3339710255, 3585371074,\n            4139863808, 4232952527, 1352122042, 3414599427, 487864314, 1493967975, 893714998,\n            2208073270, 3601682776, 571426814, 1729996166, 1769140101, 867892680, 248785719,\n            444128848, 1420394413, 211620358, 725005128, 3811507891, 2674064258, 1462026079,\n            2212287862, 282651282, 4067320883, 1238856730, 533900559, 2220084201, 4060944136,\n            1193456289, 4115136345, 2260451127, 444418500, 2239948572, 2187568976, 3112894026,\n            3100618629, 3477513467, 832766583, 1063501963, 1098701627, 723902089, 1440862175,\n            1758307914, 1444117721, 1945605599, 3520968071, 3918782575, 1074744480, 2617148864,\n            2479987951, 1315574524, 2243849353, 4172397503, 473326373, 1156124782, 157766890,\n            673744894, 3172150267, 1171319614, 3133792904, 3781709316, 1725956188, 2960793571,\n            831947718, 1234879482, 2243106260, 1151575826, 1619494546, 2918418271, 1032275766,\n            575484696, 1902010103, 2115212007, 3102396978, 1178091090, 128951007, 3505520912,\n            110589647, 306799550, 2923957282, 2889535970, 3892716896, 3462061802, 141240336,\n            4094303930, 2055495582, 2991144910, 57488757, 610331479, 1212049985, 1755404171,\n            4087127463, 1599682327, 108549293, 1947624328, 1598336622, 1923508724, 1899546274,\n            276013626, 1637086109, 3439572386, 2595854833, 3322277930, 3124995765, 839416381,\n            2963675606, 3415056358, 358293777, 3857023566, 3922751231, 108125165, 3372985231,\n            3721218511, 1384426460, 3064886104, 659089119, 1339971848, 3971603972, 2446343777,\n            2403454741, 2863794997, 1916677070, 2015369852, 3104590431, 3056618309, 2156827214,\n            2307905130, 488558245, 2385003556, 1292779627, 2787456671, 2909130254, 4021667611,\n            3458226840, 3595701687, 2158188879, 3127097448, 3311473188, 3919657756, 3067540899,\n            299594906, 4077196443, 537966839, 743854847, 3860094268, 3209048499, 2702918213,\n            3164248873, 317003889, 3917679498, 3799050992, 951266511, 4225991118, 4266739594,\n            2120739469, 3738621457, 1099651895, 374074539, 1265691403, 2284873652, 3646098311,\n            4071518796, 535945130, 2124137181, 3799225436, 135130867, 3172238162, 4292781580,\n            2119931866, 464178370, 3767627159, 3038212842, 1517053286, 1373709770, 3206724807,\n            2485420751, 4048155892, 2927521795, 1557446590, 2850031089, 3887281135, 3031617589,\n            27036204, 2594933381, 3658916771, 568750334, 655449437, 3989400884, 870434119,\n            2424378357, 3308556968, 2496148173, 926500626, 453310341, 3007786788, 3572176970,\n            3046431089, 70595777, 2085799171, 2034796533, 486525793, 2625764439, 4140008006,\n            2843236988, 3203487606, 1142801527, 377634806, 3336004949, 2194740748, 2517752844,\n            1749583456, 1819363747, 317702209, 998472125, 2894865062, 4009728651, 1292745578,\n            605771590, 2985770441, 529717869, 616022604, 655055107, 3769545808, 999957674,\n            2639392664, 389728170, 2432365834, 483707577, 312118155, 1833398102, 1741491866,\n            4149823795, 3365822742, 3296721134, 1639516381, 1544385625, 2514130449, 2336047201,\n            3589938788, 3496135682, 4083263061, 2561381029, 2812904127, 4108861608, 3680511663,\n            811663733, 1486852554, 3205990693, 245170915, 1447693317, 1428078991, 1963724366,\n            2590241079, 2162317267, 2989776811, 3089003008, 1353427699, 3236242526, 2772630345,\n            2586319460, 567743793, 3351249614, 1483216367, 2833043888, 502766384, 468604393,\n            4074177567, 283893874, 1885892172, 2775655802, 3268796843, 757932028, 182396962,\n            483265576, 1827630762, 1348814828, 1914599768, 1542736747, 4008837377, 3928031398,\n            3959798677, 3267417150, 1831724203, 1940628810, 1689020497, 4024291136, 3599565751,\n            1053265784, 465418337, 506963367, 2361541882, 4054921138, 2041763965, 3380272634,\n            1069313562, 2662913459, 2911073713, 2063745024, 3042615940, 2885707484, 49955617,\n            122795689, 1432659959, 3566838899, 1022912305, 3074366276, 2709235897, 779370753,\n            815074193, 3609718797, 3955653232, 1977587688, 1092726583, 3460400576, 2402412912,\n            2289905750, 2283096093, 2485302212, 2110598404, 3037676077, 617723850, 3773615999,\n            1901972354, 4085473584, 1247720697, 38284959, 1475039295, 775357884, 1230046128,\n            4022114392, 1513239213, 3466970347, 3994679267, 78794367, 4164607793, 2404524874,\n            3501817385, 3648692470, 3582023751, 1516804600, 297037858, 3301716622, 4143991070,\n            1433511023, 3636151271, 785725003, 3256947243, 2993732768, 145528213, 2882082827,\n            306287102, 892689880, 2858200468, 673572608, 1114857729, 4039728859, 3781145679,\n            3489731809, 4050294518, 1015252516, 1606235882, 3246096674, 1237150149, 2696921885,\n            1004457220, 767366998, 4082637480, 404715162, 2488959529, 2678767407, 3470904027,\n            1957522208, 680787044, 2133572802, 4287690094, 2425234665, 2319466303, 3124182319,\n            2946314551, 4118395310, 2418044788, 1641411535, 2331894759, 1115181240, 1690753245,\n            3582163090, 4114829311, 3999259349, 3932770197, 3981656983, 158734810, 2791366216,\n            3126668984, 2329125862, 79170654, 3288883194, 1116608616, 3593934678, 680174024,\n            3734292056, 991025399, 628166212, 838778775, 422270740, 2052636586, 3236693731,\n            601983914, 2569941689, 956277823, 1460769101, 2314502408, 85666892, 2983372669,\n            4106120511, 2780933363, 1326799232, 588063451, 2157573778, 2194779493, 1349171294,\n            2139192181, 1738827207, 1904136648, 2704236600, 1190895845, 2509911864, 4106505453,\n            1789804188, 4116232187, 1607726772, 1423657896, 203660459, 3556905534, 4052550667,\n            3661443020, 1156588830, 2805709187, 2184734484, 4130306836, 2927048269, 3971037292,\n            2842478405, 2781492032, 2845544971, 2405419136, 1229584051, 1704985343, 802298352,\n            1315673769, 3070548996, 336912256, 2309309114, 2488808086, 4074100102, 2980713950,\n            1883306562, 1896416460, 2685437861, 1988595995, 3482976932, 1994751201, 1054411077,\n            2247266871, 2622594946, 2557403421, 2100367020, 1639567414, 944674620, 692581566,\n            3497401683, 4012350565, 70814296, 2364269654, 3892323191, 1574657311, 3805241597,\n            2646812902, 686993135, 501417336, 390190378, 81134463, 3969793329, 4088317331,\n            1563897186, 1210055530, 2418797645, 2949631413, 1028385013, 4253532571, 3271519271,\n            2168853833, 3385633090, 294123522, 2383157911, 3736161561, 421034609, 4212341207,\n            57710600, 3169107690, 3547598164, 1686629028, 2685848946, 3944310507, 3528974931,\n            2572063697, 2375154673, 1778716843, 3528372789, 2468656618, 3071584083, 1128961192,\n            3683193636, 4264628822, 2606286479, 3683466786, 343295774, 1491201524, 1324059187,\n            1273065858, 2947022196, 949706186, 3139787517, 3027668981, 513483209, 2342866950,\n            1266538374, 693610101, 199671380, 1615539257, 443020503, 3933429452, 1401582990,\n            3367992542, 1392526946, 3888223168, 3880705051, 3649058260, 1007051372, 4107344112,\n            1760297433, 2354240414, 960825810, 921810569, 3231825378, 3059257576, 1131654349,\n            129500080, 2605388156, 1865453484, 2126231061, 2139625780, 27436657, 2742674470,\n            3553648145, 390804806, 1848660501, 279438783, 2491570135, 505315416, 325197569,\n            3548414492, 3270595689, 3671811806, 3684623752, 1478777341, 507514100, 3783080022,\n            803976630, 3386243872, 454876331, 3758085216, 3800389363, 49854907, 530276073,\n            2294324496, 540748232, 3137528263, 587679483, 241157100, 4259372319, 283145971,\n            3833436183, 1757121148, 3331836651, 1029534421, 1137051106, 1617366805, 3616255466,\n            1150694365, 1505061843, 2723097393, 469442150, 2353136647, 3180649084, 3055477050,\n            2020452838, 1847113164, 1234875175, 2918051924, 724398594, 3800245220, 3073723744,\n            1377564728, 3712594581, 142337349, 2221242370, 1822228854, 2036943806, 1283238486,\n            717982286, 2220204244, 2788518871, 4087772284, 4140881301, 336583084, 934183049,\n            4127199100, 2422142089, 4134684551, 2002084614, 1407851482, 2825561155, 473115594,\n            3804454149, 3756070324, 98277398, 2736658987, 3835540621, 1666817843, 506136422,\n            346575074, 2713055765, 54649123, 3718842846, 333996391, 1375596046, 3429343896,\n            2222155793, 307076719, 2844291252, 3170323009, 2190094191, 722584267, 680134050,\n            591286112, 1781766288, 2649541898, 805407678, 4239934253, 2802854602, 3394256891,\n            2679967939, 3968333, 2282595467, 553579031, 3256675495, 851693005, 3740760052,\n            3873978264, 1539085407, 2577644981, 3005994199, 1512823780, 233392417, 4044923329,\n            614175247, 238946405, 4151502616, 2895824639, 2892298577, 4109109568, 3448807072,\n            1820447786, 573431056, 2758023719, 2233076218, 3251538528, 2807960216, 580233560,\n            2192653133, 2533930510, 1201446917, 430846225, 2598684172, 1625389104, 4251720843,\n            658085697, 155173541, 720428389, 835068946, 1111888517, 4108792020, 3993189257,\n            2850665517, 751278615, 2004209215, 1265975261, 3335070052, 1523409381, 836145757,\n            4073164649, 2610287253, 1225343379, 801694973, 1537640195, 2775974480, 2125318804,\n            3503233119, 2203019623, 3771029544, 1379439490, 2365560747, 628400928, 1856950251,\n            1967226098, 1292166597, 156503532, 3960895865, 1869014599, 3443518432, 2169255606,\n            4201459709, 1500591038, 730743899, 3318533450, 755872014, 4121547193, 666804686,\n            3088350896, 462999997, 3278009499, 303940334, 4063551426, 608129041, 1213223861,\n            1061590490, 1512754548, 3452663696, 1217722668, 3519482218, 2418190620, 3453670568,\n            1120841384, 456418284, 3387215218, 3662706237, 1790431321, 1320586405, 1813568193,\n            2936719936, 896771582, 3927131254, 3142775285, 1557700940, 2326809706, 3275552402,\n            3581023717, 157618985, 2030885822, 3103063223, 2850318185, 797823914, 1893765086,\n            751439807, 1389213262, 3356591972, 2930199659, 3909407822, 3238228902, 2252894660,\n            3159833014, 3565354529, 1144015255, 4166316542, 3451726130, 3301755298, 92345338,\n            2110091485, 233933603, 2038950148, 3807492982, 3951911538, 679060338, 2391680161,\n            1906417047, 3494346728, 4259683905, 1053098728, 988641744, 3749343758, 3005386887,\n            1962427861, 2387760070, 126939628, 3037361186, 3735412627, 3820100034, 2877271723,\n            2827593384, 1467042632, 3554961566, 2199126491, 1474834584, 2134653916, 459572450,\n            3351483327, 1063061880, 2546994043, 959403293, 1453480783, 45023651, 4182656431,\n            1621609181, 1049162248, 2587382448, 298280334, 1160086482, 1798572995, 1324196838,\n            4213575980, 4082125512, 3659257898, 1496522682, 2669601542, 1240791449, 396787736,\n            2384741656, 2300186205, 511911782, 3022808512, 2171807370, 4181893952, 1651646200,\n            57933192, 68207219, 2305160100, 4260477147, 4262150028, 2752852327, 949687421,\n            3269112793, 452432433, 1368356411, 261337000, 2958549600, 2162649686, 3851709264,\n            4130077532, 3618268535, 3716606342, 1278243876, 482097980, 777983234, 3966135108,\n            70902155, 2457361915, 617387805, 2001651528, 496373342, 3278313308, 1649028393,\n            1574941569, 2228636013, 227524447, 3558505853, 3450551386, 4036721720, 2883739434,\n            3987908438, 276027716, 2199572845, 962950325, 463160521, 3157657410, 2545135267,\n            299986190, 2225624032, 1335091033, 1116210333, 1341749985, 1200309524, 3632337243,\n            3178244627, 2075617198, 2280834777, 3806603492, 233497405, 2845574276, 3966355075,\n            3796588723, 3789497905, 2442366521, 1137466244, 3731928636, 3909286263, 1377159164,\n            2865504518, 1868538298, 2374721835, 2341537275, 1006554548, 3773876265, 3882008299,\n            137750768, 3589400563, 16312058, 484192503, 3868107471, 1573223847, 3647124730,\n            1415086936, 724749097, 2338843504, 2361959105, 2115018391, 538057079, 362974782,\n            668678785, 2531183318, 394218310, 3386890306, 3336523293, 296517260, 3858301570,\n            1716601718, 2006160620, 2372397969, 264548388, 2512734401, 2866715736, 1538211958,\n            3505363984, 355312830, 2918157313, 3070019382, 1917401646, 3649489497, 2242874579,\n            949987212, 1064697480, 3999448529, 3828574403, 1900689197, 3083807538, 3273525671,\n            1615606943, 3222910677, 2684389644, 3585208519, 3623035487, 1629134891, 2938685351,\n            267953950, 4070365596, 4037659768, 3019560913, 807559385, 298035491, 2598163507,\n            3457982022, 944125531, 667947136, 3527192466, 2934540867, 3844971831, 1664033826,\n            4019501589, 2257507754, 381974031, 323084062, 2848925430, 2525252210, 2997747030,\n            2010446890, 4151995925, 2219016264, 635511729, 1938335558, 3262666460, 4017378474,\n            925183423, 181434660, 3416005846, 2375706535, 1893169843, 867425139, 4266560011,\n            4261001209, 1974081833, 1495783336, 3645315131, 1371952384, 2231366915, 1809283710,\n            3174162783, 3692065585, 932072189, 2143319139, 1935751070, 1389073735, 3228643052,\n            2716651400, 2008913204, 622096395, 707783747, 3856671850, 415242370, 1529820732,\n            937112442, 790265210, 3512314545, 1249764825, 983820497, 1495557988, 1049339557,\n            807750281, 2099568336, 2869908992, 2378854541, 519046482, 3623024174, 2043891665,\n            3268337415, 1523536610, 2556116012, 513967987, 317614571, 3921124626, 2688549432,\n            3163209270, 3460158834, 1676365720, 3406680830, 1895314009, 2478089264, 3994902569,\n            120933160, 3371964816, 3548031081, 4188121739, 4165669542, 4262472718, 2548169460,\n            1994026898, 3762147713, 4229144764, 2355673778, 3781193367, 4115281455, 4230995643,\n            1081916479, 449667065, 2375935285, 509312700, 1572206518, 1039467114, 33291215,\n            1736165798, 3386906161, 1403006013, 3057089388, 725608373, 832959637, 3326066952,\n            2758630720, 780306312, 1823175215, 1756482562, 3783642888, 2582262724, 2782974185,\n            96828431, 3432789810, 324379740, 2675018082, 3242192356, 3308487904, 2171079066,\n            1920850114, 347250594, 4049217084, 174334290, 2894755770, 1682660733, 3639674097,\n            3022460606, 4172589658, 116943302, 3986361534, 1422166077, 393384801, 2739155544,\n            907894212, 3551541090, 3873518725, 2744430045, 3807711638, 58201325, 343788661,\n            4226811714, 3878700816, 2311468073, 3495630203, 3565734040, 1740927154, 2246969894,\n            371220115, 2886036850, 2868234004, 3808320577, 3149189084, 1344292273, 1383218952,\n            2797016240, 13274617, 3646672567, 1715541479, 4008465882, 2746489174, 2032923305,\n            1003787730, 389106831, 1625722354, 872791047, 1163755310, 1782833457, 1122780937,\n            3674301793, 2962567527, 3027005428, 3421675397, 816528114, 2520772421, 3882265850,\n            191185211, 1915088679, 1136131632, 2917934999, 51969557, 3873182913, 3829719891,\n            3763027591, 2071822148, 2948549465, 3685647774, 3740460724, 3983815305, 228233670,\n            306748240, 2205655390, 2169840196, 57631823, 3501748332, 692415311, 3651127800,\n            4148163821, 39432986, 3699741440, 1198366749, 2669224033, 4013719886, 263487157,\n            3143931081, 1829033426, 1290237561, 4253302762, 3620861217, 3026498367, 1924278865,\n            2129615734, 1284338993, 740419088, 1476115804, 1674349471, 1373590050, 2962840532,\n            1086886015, 2948050969, 170021597, 1963009014, 2524590563, 923284704, 1535707291,\n            279837676, 1841164350, 322588089, 2750328817, 3646141378, 1024203883, 1969779698,\n            380904461, 1439698428, 211451903, 2996746791, 1790199287, 714183289, 2057885007,\n            3055483047, 3085898, 4282811050, 2202405947, 3212388463, 3791241669, 1458404120,\n            1181255669, 1163142856, 3365570634, 3840757205, 3227216263, 3218780114, 2183401479,\n            1668253988, 2521856256, 3531099575, 813705343, 3186927278, 2613309797, 977097253,\n            2838513713, 3131199744, 2159039969, 733325244, 4085628955, 3261547479, 1808066772,\n            250992165, 4027173056, 2516628679, 2485664871, 4066943892, 3885129031, 3128271561,\n            1605078579, 1412687920, 389648195, 3134571763, 2090188111, 3535196873, 3250823634,\n            1963313595, 4236639174, 3188091747, 1558647340, 1587110630, 2362648960, 847667422,\n            1818600295, 865349696, 1355021043, 2896242028, 987445793, 2259009360, 2058641378,\n            3017932902, 4263925141, 4039030529, 922140284, 678661653, 3124465806, 364324461,\n            53160573, 961854258, 262562705, 3642350584, 3187364726, 2946984520, 2337837903,\n            2577496482, 254618959, 1658071001, 445095500, 2572019250, 698759728, 3489488655,\n            660305830, 3172869360, 3008333264, 4108869853, 1480659919, 2193222371, 3164881436,\n            577842645, 396864946, 2251498887, 2783115466, 818817030, 2777540659, 3292804029,\n            2495573384, 52861550, 196516661, 4081623143, 3182305453, 3639468541, 963044873,\n            1723976782, 1743809340, 415885010, 262631269, 2541205840, 1887739701, 3537112992,\n            677373721, 3376801371, 1366605844, 2050672696, 2009821574, 3363232635, 2699378367,\n            1656613261, 1106865976, 3325917870, 3709679487, 316233653, 1099555783, 2917740812,\n            1819153436, 2758919991, 136411226, 3303510560, 1950234035, 3123211002, 1661268876,\n            3092013391, 3401906228, 804899207, 3429735604, 1119104687, 1527334549, 110162900,\n            4205306363, 2965045371, 3224282444, 1387479162, 3482021749, 641230778, 2484149227,\n            74145495, 667532876, 746632698, 615670999, 802531291, 4068450187, 559037508,\n            2410203600, 3173998761, 2414949060, 4250307478, 2677924923, 254875175, 2750491186,\n            451361625, 1490449121, 1911989075, 705273128, 2993458230, 2531413775, 221330602,\n            3607043619, 2832975328, 2785439377, 2175420602, 461343516, 2149257009, 64004519,\n            1834736566, 3526694904, 1345324, 2574179543, 2173541213, 3648164188, 2441837986,\n            2302064699, 1897950238, 2062029056, 623179729, 235835418, 3696876389, 2275547090,\n            1063491599, 2500366108, 2553421358, 516021674, 820064438, 1829558386, 2269327248,\n            641085617, 3571348267, 3414776281, 555925412, 3415049186, 4071446477, 1844604868,\n            805541049, 872648823, 3801041544, 3068396764, 3071270530, 3794865520, 4202235705,\n            2297800920, 763632754, 2083936963, 2836971110, 3995016591, 3398237394, 1203477946,\n            2507654360, 426992170, 1021567254, 4126934650, 1551918171, 1902836221, 994606291,\n            1687196968, 3302729384, 3862031719, 2323821450, 2198316563, 2540812003, 496118884,\n            3246203986, 2646253091, 1728288511, 3272115902, 4238725201, 1853048564, 2057055954,\n            2674412833, 2822025441, 3295385080, 1559234133, 3000676765, 2870421002, 1548768696,\n            3428399922, 4084596073, 1413011680, 2246354194, 221378010, 1761252139, 1162599628,\n            3513756657, 90592612, 1988494097, 1105275258, 2089567745, 2998838495, 3953491813,\n            364632274, 126200165, 1612007030, 1567790004, 846868583, 2547791738, 269855914,\n            4032384370, 3746164021, 394230659, 845662026, 3845072850, 2566488043, 2170205621,\n            3514481342, 2982439207, 4222310093, 1365580426, 1870921277, 702951042, 1487443801,\n            2206519103, 2816450438, 2084648461, 3634087131, 3370864055, 1170986620, 1307914636,\n            2464599466, 1928094516, 3449406714, 1486190614, 2804318619, 4199030156, 1372088422,\n            2721401584, 1823089391, 3589579994, 53903387, 775871039, 2148863830, 1211809608,\n            1466549974, 2932329000, 294240089, 4148011680, 2606394538, 1551595207, 18437086,\n            3870848475, 3963451133, 3858293930, 583780669, 1777740415, 1168874756, 3801614,\n            4054375944, 404916297, 3086659167, 1644039632, 155306589, 1877697577, 1819574777,\n            1655511547, 1975709851, 2155167407, 1317557508, 977888829, 387692628, 1801386365,\n            1355070840, 3779570486, 2763830935, 1814654166, 3686825878, 879580242, 3556208695,\n            1189422865, 3256473657, 2689265288, 3584464400, 1389798501, 2299654449, 1596970200,\n            1635139470, 1600912664, 1065106519, 2318834717, 4232317329, 1934733510, 2634026131,\n            2195642198, 2845879342, 2471256312, 3146307258, 1592946628, 98590245, 1040185173,\n            4164930384, 1488170192, 2059223958, 3951794327, 1156875867, 3150550335, 10771925,\n            4062792278, 621778379, 2152178624, 802155041, 1101029092, 354527136, 104311386,\n            2196011265, 1549512013, 3601741721, 458783748, 291023277, 2220275894, 3787925037,\n            3574728081, 2371901638, 3350167974, 491057564, 2040235893, 969422326, 3498791458,\n            599513800, 3876713234, 4058021633, 2197825372, 824758175, 2871127338, 1236739351,\n            1729601061, 1736072444, 2744326965, 1782185189, 285956005, 1370284895, 3879897183,\n            4093460340, 1003366293, 2067288838, 4080067907, 3219653336, 3794136183, 4213407944,\n            1650954752, 1864697860, 890337590, 2483342995, 3096470221, 3211240473, 1541081149,\n            4272180820, 1921941795, 4276868501, 2657782250, 1082867515, 1593771653, 4249740408,\n            393671700, 847016998, 4258403125, 2279321782, 3127544068, 2330799618, 3388263646,\n            1011035931, 2302492200, 3679422512, 2739454712, 2447725944, 1410204193, 1239960769,\n            2335415742, 4034628289, 217154321, 2312929490, 2847283323, 1758010662, 2798182716,\n            704650518, 1764636405, 2063450857, 38578646, 3093858691, 3167715523, 3774603764,\n            2989934348, 2012331954, 4062917415, 1735784556, 1562528417, 3078303612, 3332798558,\n            3821642404, 1112683342, 3744817608, 918262034, 370379804, 999987263, 665306315,\n            376490441, 1825664304, 754450413, 2510096664, 3789316010, 3052362459, 2687717750,\n            2218594038, 4293298946, 1788948562, 1367398961, 3870136645, 821541271, 3969748788,\n            1155451493, 1747425575, 1690656610, 1276266112, 2250260017, 2020612442, 2529425772,\n            2309227100, 2807241536, 3929922893, 1183227047, 2977259793, 1311217435, 999070078,\n            2752168524, 4223283642, 4246380954, 4123508068, 1731849455, 1134288471, 1756001130,\n            20824059, 1710254099, 1376878106, 637049007, 945651865, 72123517, 2664241016,\n            3514853577, 2713931455, 4046027446, 1955984198, 4017621545, 3041248107, 3639683889,\n            1214300370, 2218289283, 2894749054, 195827613, 133969750, 717701437, 4154927656,\n            218695447, 2738177196, 1420974119, 1002222984, 2136588504, 4175421234, 4286398959,\n            465010593, 1649044263, 1870887768, 2706060571, 2993578519, 4210257282, 352665767,\n            1626990747, 2122106151, 1991441823, 484609398, 1968108637, 267034235, 3663944477,\n            3497498817, 1298555467, 1820946055, 813976817, 973979545, 3558149570, 2052858623,\n            129423978, 813351723, 2860388596, 2874594109, 1894276258, 3875175622, 1181838780,\n            552362494, 2927906399, 680589035, 4189428995, 4100440378, 1459281238, 2696223655,\n            685225908, 557773591, 3692585034, 4095389710, 3507920903, 1100694461, 1200458755,\n            2700047360, 1010756832, 2836878993, 2599716200, 2421020345, 2525438781, 1587688915,\n            319331066, 3610048142, 3826219458, 605791648, 3609407242, 2538477707, 2460599980,\n            3036140482, 257193064, 4035967000, 2498611358, 2444041314, 2373434868, 2140306999,\n            563567659, 1159698233, 2762641126, 4154818731, 1764008133, 2952860729, 2027173579,\n            3800550668, 2682398852, 2945858522, 2356978046, 473298920, 1390211385, 1626451727,\n            3339732957, 3975656012, 963281208, 3223569785, 2186966411, 2825438410, 3066200364,\n            695250767, 2595558683, 1743100366, 748707855, 2719933058, 1020605740, 2648119052,\n            3505763871, 1875706095, 3622101865, 4038036748, 4093851036, 2691592284, 1248587369,\n            1144467957, 1921816097, 378585862, 1775800559, 938045171, 24817745, 2803294734,\n            1065147136, 2906907023, 3516494325, 1172235966, 2183375603, 1511831851, 1152614918,\n            2840253990, 1107546663, 1134755588, 536608442, 2111631275, 758552262, 2487574261,\n            3279088860, 2497117721, 1697010519, 2712455268, 2404149025, 4099555062, 3576954053,\n            4244802645, 1796996455, 2036356956, 1202823228, 54979161, 2680738268, 2788198200,\n            3210203298, 1836202712, 1137233831, 1629065704, 2804856386, 469139538, 2833170458,\n            469500302, 3325984525, 2705206009, 1967695924, 1585889929, 2146430815, 2347120626,\n            2124064426, 3965474758, 261325335, 544186624, 1690898942, 743159471, 2013266750,\n            2914223957, 3960466984, 1765154541, 983001537, 3976159631, 2683703437, 1174049322,\n            2874826165, 1262077369, 2769829886, 3531066519, 66016270, 2067537480, 3858041267,\n            2664217656, 1278779111, 1799701397, 2460646357, 279927022, 2547633840, 2971564668,\n            844621964, 2407301651, 2547958744, 4060907920, 775539021, 2273284541, 3411076307,\n            216981865, 3387791693, 4038497000, 2064678592, 223689239, 3381597575, 2785720594,\n            4028130365, 1088922312, 1428400526, 2058741956, 1938445154, 2901891415, 3533906848,\n            248391562, 1598571189, 1274277407, 2662721864, 3387940906, 2652463762, 2010354071,\n            3783520106, 179401923, 3510135610, 741510312, 3674896164, 1147072826, 384850468,\n            4177726882, 1143423694, 2632405832, 3120714386, 2337623953, 3642474663, 278717623,\n            524868652, 1668357695, 522688744, 1287850641, 2158007299, 2485773856, 316192556,\n            2808005423, 3298013517, 1709332799, 2966420037, 1594118586, 657895176, 2660878261,\n            3063768836, 2975113253, 1069435351, 4071721369, 3148504718, 2639750143, 2617415862,\n            4246948401, 2744669640, 959176102, 2879440624, 260950886, 4264677991, 890604030,\n            3943171503, 1153581582, 2648776662, 341880069, 3802271662, 2082556612, 2052482296,\n            1396470246, 1291404816, 894775492, 1870279878, 2587444056, 3220469802, 1393682137,\n            1363647579, 777022364, 1426882091, 2369790077, 997107878, 177923107, 3831198071,\n            2125001182, 3921642379, 2441779185, 1633189248, 2367759250, 4079331442, 1413642253,\n            1901177515, 1936953724, 1879598361, 755185816, 844490707, 749620419, 1858996628,\n            3372432253, 3635783608, 3291277496, 2646751941, 4275867653, 3315645015, 965526434,\n            3141557797, 3545226235, 455560691, 2910050619, 4230554591, 2514237392, 3475136309,\n            3414853019, 3439994926, 677034233, 863272265, 774851933, 3215462454, 1626257754,\n            1060195911, 3330518326, 2058735742, 4277830382, 120508857, 10349099, 2360047298,\n            1147270030, 1669346204, 3164948300, 3276712406, 1090825495, 3336858910, 1067156081,\n            811708915, 2217482785, 2187684339, 1105052253, 2899523744, 2144117806, 1182890427,\n            603527208, 400025719, 1635531955, 3184515856, 2996156197, 1109257516, 1438412469,\n            1128184215, 3835631242, 1986630841, 4215212096, 2147483812, 3296027198, 4247185794,\n            4028891232, 2992689352, 3199348010, 4166661900, 1128505410, 1818937517, 977379987,\n            559699801, 3526456143, 855066198, 3162577377, 1844016075, 420257003, 1020528439,\n            797490656, 4195410773, 2042327528, 1981205681, 1634173708, 3290076459, 1188324461,\n            2194485264, 249257667, 710780707, 3902304963, 2563721521, 121410281, 1010789176,\n            965480853, 3551582682, 1414069580, 364509720, 2618252137, 2202510871, 181090986,\n            3262751128, 3162233271, 3324791535, 3286198872, 3126251757, 2867781188, 3214600621,\n            3420241587, 1701458765, 1107110151, 1880972823, 2366736607, 3802279381, 1147706669,\n            1678354017, 2338064135, 378205819, 543458596, 4067960199, 326647146, 895182393,\n            1620615430, 3236775151, 1676297168, 2723074476, 313615280, 3458558228, 838532854,\n            3836338910, 4126720179, 447107335, 2522588986, 358162529, 3102875855, 40331308,\n            1700560944, 2619282419, 1323032831, 576655124, 2121890683, 454009455, 1611856018,\n            95321415, 3159099343, 2624793510, 139254963, 3007002967, 3046869496, 2504389944,\n            402007098, 1120401945, 2320367467, 3822028515, 2128547975, 728566168, 2720263950,\n            376370725, 671504810, 1102525681, 858802947, 2407677110, 3899865885, 3238068758,\n            928258875, 3503253617, 2496097677, 1090472781, 3769635775, 713162550, 3924147908,\n            3088019766, 2794584330, 3921762979, 4263696196, 4099925085, 1452359352, 3071060808,\n            2171402846, 1775765123, 3353726136, 693656823, 2215697894, 1581680393, 2459109874,\n            2610514747, 1636281368, 1935156617, 1518326299, 3811662146, 3052308992, 4016011731,\n            2525869209, 3199868849, 781183068, 3909124675, 1855754701, 2718011142, 1017563932,\n            3009254942, 3771127673, 1888265122, 3655046264, 2733133491, 4269920361, 3968936320,\n            1387307540, 3911304570, 1381672884, 2631100794, 889839068, 502873971, 1645726487,\n            3409353188, 4207111356, 2389633452, 3169396047, 556329990, 1275839227, 1919169103,\n            3421757222, 2063449467, 1344911918, 440063664, 575382039, 2778635596, 659279135,\n            2865737756, 1497472026, 3455082775, 2351352609, 2218315286, 862912648, 2275185045,\n            1044902041, 3742809957, 798827446, 1303950178, 1389761794, 3459284470, 1627506744,\n            2946964178, 3119156935, 985565880, 4012898742, 4254608009, 2019607596, 457517311,\n            908198848, 2391346217, 1280204952, 3186268, 2327766882, 4007742117, 268675722,\n            1508916405, 67592678, 2909233082, 2975352339, 4150088609, 845353802, 1246467789,\n            3211639510, 1598175163, 2015042287, 1159535595, 3039644640, 2024780164, 3817310144,\n            1314793916, 3931129644, 2297902041, 2744401140, 2155319197, 1274333778, 1590647569,\n            2064174726, 839581832, 3180899057, 2734604085, 250368037, 2325830975, 4021903632,\n            4209659583, 4087575978, 660545834, 676331819, 2332664139, 3915409196, 3869013874,\n            2072254366, 1489561563, 41383485, 3373077713, 2339267375, 768611244, 2111817536,\n            3308344638, 329648827, 4058123276, 3596509162, 157841641, 3025011358, 745256997,\n            751836219, 1738832488, 3104811027, 2572481274, 556241905, 143116006, 2981693323,\n            2825496962, 955861689, 3150803899, 1797906830, 3632639062, 1111189328, 1854921423,\n            1611801898, 1732904082, 2380496915, 852045714, 1582105277, 2128955243, 3610026083,\n            1842139797, 1651848148, 2184981539, 1566494807, 1023570434, 3427831203, 3318420767,\n            1891760251, 115998922, 3008231250, 936023514, 940664041, 3503816225, 238596895,\n            2415722666, 3544614197, 3992896188, 3062834010, 3584536939, 3253098143, 194333715,\n            381258355, 1983199885, 1683403067, 2218849076, 579428679, 2440305438, 1460652462,\n            3030360784, 3505984098, 1364689613, 1357944353, 3051635011, 3030326404, 1461020438,\n            1931054651, 429832151, 412640230, 1101806527, 2407972600, 1754169295, 2925930697,\n            1799944013, 2477339313, 2252685253, 1781295997, 2161398638, 984942638, 1997653908,\n            3175765172, 886822188, 2072153716, 2559904381, 2906429790, 994568336, 4137548428,\n            2165395553, 3721532569, 2791955106, 4002005849, 1795290415, 777356562, 1283796138,\n            885689301, 4200387845, 3520650868, 1793108559, 1944953438, 2519625856, 1321083559,\n            2471609790, 4154088871, 971788699, 96486902, 3917953517, 192828625, 1360773575,\n            3934994426, 2734798540, 2618623306, 2827539934, 142408573, 332353652, 1071198438,\n            3052822037, 3669652208, 3349217466, 461828931, 1955352011, 254370177, 1493951591,\n            3811317580, 954414114, 866375483, 3419445101, 2214895394, 3517054322, 4161425935,\n            3973658488, 1894053030, 2918545108, 1843644863, 2422639014, 217434620, 3471716433,\n            2175164467, 4147044804, 1399830516, 2600229730, 3230553946, 349040171, 3308181171,\n            1722528579, 1892962581, 674543130, 1359065857, 888420701, 2239693478, 3134792376,\n            2261014987, 4972872, 3972656514, 3917247995, 281467403, 2386392677, 3427533977,\n            4190760555, 861503511, 3094011736, 2544900610, 3235067355, 4281089945, 893898096,\n            623017175, 2684358541, 2982621388, 3420249402, 1836312846, 1762132747, 3524441344,\n            3694431079, 2521182822, 2689482723, 2792871670, 2075567778, 4270142052, 1117455219,\n            2245600198, 1016538829, 2546770766, 3472047555, 476718632, 4102270410, 544907404,\n            400447925, 3078669830, 228044931, 4278139634, 509097914, 748704700, 1380534690,\n            2641425727, 3989091583, 796153283, 1488887826, 619046017, 3894025574, 2789984449,\n            915402991, 352971303, 3305199704, 302470373, 2958663620, 518499443, 320714422,\n            1818844192, 4179963684, 3546212233, 4281710896, 2693300985, 1843803815, 2109594921,\n            4133092241, 2200735204, 1950193752, 1649263275, 2084626250, 3979601508, 941132824,\n            1451427563, 589459270, 3858283949, 2464707023, 3257666949, 576301490, 1408214844,\n            4148284079, 1145082510, 2106736992, 2796596950, 2734784935, 3965180937, 2507456961,\n            2179846796, 2989661423, 2394534594, 4170707335, 2543880785, 2016782127, 3784924498,\n            1537622300, 320799861, 1451798802, 3665445143, 3285671710, 500367279, 524317043,\n            1516855663, 3416184232, 3830147566, 254079675, 3570808067, 3320568378, 2199094843,\n            3510157338, 1516001239, 2660566405, 4200281643, 2033492861, 2710458394, 2729223326,\n            2914055217, 2869164325, 3832975412, 1119282624, 1614883519, 2740796061, 2350354698,\n            3165195297, 972490337, 3303052553, 3246153805, 1815033751, 1093989571, 3725330351,\n            3380415411, 4138242707, 2798484855, 1488934274, 376319971, 2514579391, 502969557,\n            2839449931, 2981245353, 3127078684, 2759028517, 1376881472, 54822087, 488974487,\n            4010000483, 790974199, 1562528726, 978852295, 3833172997, 776544691, 3327119386,\n            3897537975, 2441018003, 3448454588, 2561580089, 3001392606, 3492750996, 544985387,\n            127819369, 1548131438, 3256827686, 3575247036, 4235524680, 3362541587, 2527132384,\n            1226743504, 3766442212, 3386986119, 1229394146, 461344162, 1331451495, 1966184329,\n            2491528033, 499382589, 2363039326, 1457684120, 1604016885, 3036831259, 4163090959,\n            2088877393, 2865208752, 1780187520, 3801239798, 1479955908, 3715027132, 882761528,\n            3020106543, 2562989248, 215766281, 2877522592, 3431546771, 1934700267, 1489283044,\n            2391771743, 2778608932, 3492958770, 1334965651, 2700169807, 2797883820, 3697186486,\n            4265006073, 2307263582, 3889090615, 2570991705, 585261922, 1375634260, 129417005,\n            1472879519, 4073252018, 2553392302, 4265850970, 75767481, 3003655040, 3361343474,\n            2134392662, 2686376109, 2073937069, 32815425, 3037049210, 2035074966, 2872325821,\n            187691478, 2715568668, 2745559907, 623684504, 2894400344, 3029550303, 2363555631,\n            2631089937, 606345162, 1919753740, 2701766153, 3083385171, 1493708157, 3413450998,\n            980996156, 131411013, 3473633711, 4087723125, 3396774492, 1004362022, 3937398693,\n            1412265574, 2776644340, 1092202248, 3117392672, 156745532, 1113823512, 3731618243,\n            1610364966, 181555257, 763891692, 460747886, 3299024691, 1632086016, 1939971267,\n            1076845572, 4137057593, 2177781934, 434207944, 709542822, 1744608982, 2452746239,\n            2143386816, 364665238, 1414204650, 2904303341, 2516259832, 2634602687, 2495694518,\n            3819272975, 4163770417, 3108194507, 2373881269, 1745665511, 3707303810, 1317466643,\n            2307551462, 2907951889, 2553226050, 1750425047, 1373792353, 3807535219, 3569571047,\n            3988805730, 3429621677, 2696895991, 1904430116, 352288071, 1248001798, 2699070151,\n            3828759487, 2848844620, 2438811302, 1119522597, 1824741145, 3115800133, 1437081946,\n            2674343726, 4238203648, 2007544784, 870095964, 2565980411, 3812426992, 1363015406,\n            1503012411, 2824513491, 1743996942, 636807769, 360934985, 1080753647, 1164183179,\n            3287213084, 635077248, 3502357311, 2270792149, 3791720568, 773273062, 115844337,\n            1890641046, 2210523344, 1310502919, 299491584, 3891834665, 2856565132, 1436615862,\n            3985164389, 1847420590, 172093621, 3605036360, 2238641967, 1545522874, 2865289249,\n            2951291433, 2022052811, 2695476968, 2061897674, 2722830901, 1498945697, 1493305686,\n            314672784, 156085298, 440472968, 3157836752, 2281606826, 966611104, 3295950744,\n            2755473393, 2922508586, 2688920417, 723065331, 756048932, 742667620, 1752775923,\n            592330858, 445704881, 2143212239, 2780727399, 1670831470, 2426725859, 3109452807,\n            1301139343, 1328433398, 2780459752, 3685996476, 3634310216, 3315816012, 255771578,\n            3165776355, 818752449, 163163565, 1453259694, 860383030, 643825696, 3049373901,\n            2662874838, 526238388, 4042681677, 2142910645, 175935869, 57508530, 3075927426,\n            3414951840, 2702600015, 2812408381, 1612918658, 1767878877, 1389979148, 2532184009,\n            1722111530, 3274892408, 94104031, 459066974, 10, 10, 10, 10,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_4_fail_1() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_4_scratch_len(3)];\n    let mut out = vec![10; 6];\n    limbs_square_to_out_toom_4(&mut out, &[5; 3], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_4_fail_2() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_4_scratch_len(4)];\n    let mut out = vec![10; 7];\n    limbs_square_to_out_toom_4(&mut out, &[5; 4], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_square_to_out_toom_6() {\n    let test = |xs: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        limbs_square_basecase_helper_1(out_before, xs, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_square_to_out_toom_6_scratch_len(xs.len())];\n        limbs_square_to_out_toom_6(&mut out, xs, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(\n        &[0; 18],\n        &[10; 40],\n        &[\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10,\n        ],\n    );\n    test(\n        &[1; 18],\n        &[10; 40],\n        &[\n            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 17, 16, 15, 14, 13, 12,\n            11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 10, 10, 10,\n        ],\n    );\n    test(\n        &[\n            2869037104, 2562493618, 960519305, 4147639705, 1817463351, 3166022129, 3200769866,\n            789666262, 2654485924, 3686362402, 2179867687, 3980226915, 3671542918, 1896992204,\n            1514962591, 815867715, 3924270086, 4262628477, 3977258034, 1340257907, 6618754,\n            2720861064, 778635062, 682181834, 2891943360, 3002120306, 3399643048, 3139375492,\n            865948953, 3273305779, 388881948, 3544744413, 3963050187, 3002594763, 3339669779,\n            2722426929, 1246819181, 2786076007, 708438365, 1013683719, 3027751127, 1766272571,\n            2839608714, 2866928644, 2107420563, 4035553421, 2376700546, 621608197, 1993043072,\n            2666011084, 2265522039, 3230507984, 2869423257, 1776134078, 2413254013, 3859414865,\n            193597892, 4255395370, 168637254, 3364100552, 3883433219, 3117797624, 2738841992,\n            3052596910, 3280507008, 2860095630, 4031447725, 3454885698, 1783630119, 3036202894,\n            3585701130, 4184585287, 1329572188, 2352399996, 3076023682, 2989927975, 320530428,\n            2081170907, 933271377, 2974966675, 3452895778, 2331110373, 995864819, 1177147317,\n            4084213472, 1179430541, 361665403, 2401303908, 3027157843, 2778759588, 1031442202,\n            542151276, 4259656091, 745358488, 2580062497, 2004998882, 2066508478, 341659477,\n            958017378, 2415007725, 211645068, 3630737942, 2670158596, 3544834081, 2043760261,\n            2149621570, 1287267516, 3353570061, 3758258174, 4171807709, 1363035595, 2692148345,\n            3728232161, 2672522097, 3234166892, 1337714504, 2475062988, 902334395, 3470019951,\n            1789926953, 39991566, 1071624731, 2480238280, 2010573056, 2975909089, 2685102208,\n            1752958961, 2957725128, 2441562510, 1615057382, 2739912075, 962437876, 1445592393,\n            750430353, 2848157371, 3515397641, 2140566969, 3080139371, 3564834440, 561913271,\n            1812943111, 1349101061, 1627550717, 3467766096, 194766042, 3125120919, 3021598191,\n            2389614341, 2536207717, 3687483968, 3746428277, 1304917109, 4262793424, 1046105397,\n            103309888, 2808595193, 1896772845, 2625389818, 1425524079, 4245371665, 1376995745,\n            1906643058, 4123808395, 4010921636, 3668036324, 538106732, 429893286, 1473862381,\n            692485290, 728791765, 4006267410, 2159349173, 1146991809, 1105326804, 855626330,\n            2350214961, 3945267379, 4182769713, 1218539569, 2795526933, 508156606, 1596052577,\n            4135932990, 4009064452, 3154371819, 1789912473, 3737225773, 2339289640, 382599364,\n            2822801808, 1231473766, 3195594892, 3686689017, 2674031129, 2724276086, 4112764261,\n            79570030, 1908454621, 270118882, 3204318684, 2240304382, 1923066108, 3669840087,\n            3114917464, 57715381, 3015749933, 3183317351, 2563719945, 2409212385, 2256893938,\n            718636813, 3965735223, 1345089653, 1264444, 2296052850, 1092210950, 3468764525,\n            3967443918, 788417425, 1924956491, 3656370968, 4266402294, 389687964, 3067575949,\n            3786278950, 4368934, 3414260125, 1500941491, 4197777812, 1901284905, 2548021755,\n            1986057606, 2732888210, 3872664452, 2787539702, 3264559111, 753549553, 1048190618,\n            2900005727, 1868077400, 1284542693, 3154799998, 395567255, 2005460208, 4005052806,\n            1893310835, 3217932531, 2607307407, 3917316670, 2028218244, 3745680211, 2397481422,\n            736482987, 1916844834, 3868328610, 938512555, 1559481864, 729544587, 3690980706,\n            1759014647, 2060717833, 2250640148, 3619925046, 2153794810, 4127168634, 3259374700,\n            2051907961, 3964686808, 3841055905, 4242264783, 2314742304, 2209077724, 2577227865,\n            1487635776, 1585379583, 3475070421, 1683734827, 3363053669, 3722095029, 3857335408,\n            2852846850, 456879372, 2473892714, 2928343667, 541075767, 3595876467, 1688710352,\n            2071331730, 1142047400, 1817453168, 96871997, 3927306877, 3090061646, 3474317652,\n            437148773, 439538568, 324686794, 772632617, 1424328970, 580538580, 3999279969,\n            2022469388, 2802303848, 1147488095, 2053949131, 3046702544, 3822972379, 2920233521,\n            4031279543, 2356245098, 2951036256, 3287235943, 2760424423, 140913700, 689952328,\n            3916658401, 1694797888, 82150998, 4075118605, 1967095926, 1704543314, 3154572744,\n            408071699, 844684417, 1174429103, 3583461805, 1015646627, 861970508, 1906905868,\n            2272773809, 879277860, 2980820537, 1917774935, 247497916, 2403283458, 553129122,\n            3303057196, 4005726052, 1808761740, 1909802116, 964057278, 1586240623, 3097009405,\n            2048123311, 2481968244, 3155267854, 555253647, 4027932249, 229358586, 1015669317,\n            4112551330, 351151415, 1331401879, 1749898409, 3352469407, 710145444, 2903798473,\n            2876271745, 692844392, 2354652850, 100021926, 4212629124, 2971597719, 2697935131,\n            445511347, 1636699871, 2524940444, 1303870696, 3634945394, 2398930906, 1337769794,\n            3955409228, 2657553814, 1455809030, 701994564, 374320080, 519334058, 71402463,\n            2995013099, 1573823285, 2419768029, 4108602983, 4266125692, 3514998795, 2367509976,\n            2654621106, 562141353, 3101668250, 2753822172, 406447740, 4132920329, 3645443797,\n            4221410098, 1000631411, 2319369935, 3987192941, 609889174, 569928846, 3471449767,\n            761399938, 2925981744, 3610481831, 364846710, 2579622933, 1755359875, 3327963251,\n            2230753636, 3897751713, 3685870953, 720576993, 4008645094, 2170973511, 3057371253,\n            2362087099, 2415801497, 3804893423, 874616900, 4188156090, 2114593709, 3626784402,\n            2090293821, 1178445498, 3501583487, 3787814639, 1160994150, 3773261324, 3438864014,\n            3474697300, 3232616282, 3082635737, 3290126053, 1041836645, 1497490946, 2116412677,\n            78748560, 2610841375, 406515051, 2540982558, 1278151559, 910145724, 2942229044,\n            1412896287, 2420692111, 2829066497, 2762072644, 883699073, 4146766932, 968581437,\n            2262117978, 4102625453, 753476188, 3237270935, 2018964783, 1357948517, 655508609,\n            4163647115, 2220146134, 3618211357, 4228425409, 2053237402, 260628807, 4078275010,\n            3945722198, 3264848882, 3968277361, 1416596317, 2102516261, 833088009, 3907840277,\n            2017643605, 1067842330, 1357529659, 2472927668, 1649000973, 2222344018, 3784049396,\n            3227757245, 2898271180, 4043134215, 3862532400, 3955686618, 98246491, 3365854338,\n            947695294, 594787742, 320576666, 3333798817, 1904306436, 2975705325, 2991782885,\n            1736852103, 3844447384, 1817569919, 3224273837, 3598752781, 1577803239, 2950514537,\n            1562681940, 4068361583, 3868379584, 2088936482, 679461158, 301319738, 766873076,\n            1943559698, 2477791081, 359203531, 248689484, 1396200027, 1850343941, 1125961151,\n            3934233911, 1148111021, 3719148359, 1654482658, 1197396856, 3954632576, 2122559365,\n            197233285, 407487633, 4158181537, 3053296658, 2799166403, 2081625494, 844237749,\n            3509575975, 3964633958, 4179613577, 3338942399, 3816968642, 3007984156, 872005283,\n            1859074434, 3956327811, 56397907, 478149678, 4026802122, 1384639138, 368837837,\n            183900171, 785221208, 3231446529, 4057339631, 2617885657, 645209974, 3749331053,\n            3387891965, 3097021752, 3337686487, 207272201, 4090597826, 1337950862, 1489880288,\n            1626252138, 1844132502, 3785436754, 2455659736, 2722719185, 3556302565, 1609527187,\n            2416226913, 2766580345, 1869533642, 3531500453, 438426623, 158796542, 3488893438,\n            3084370998, 2058790923, 1154169553, 1385226416, 1509103535, 1162048903, 797370674,\n            170054390, 2752067502, 3119807393, 1923267976, 3762356971, 1978871808, 3723074764,\n            3460095249, 2837581806, 73932499, 3524773614, 2454111707, 2818213028, 3004873518,\n            864066450, 3576610451, 2315784966, 151779632, 1178401043, 3765993358, 1348598145,\n            3576623674, 3204205857, 3883955902, 2023814627, 795831378, 2827807531, 1331064687,\n            1837025931, 3540224087, 1381156075, 141174913, 1539904944, 1709050097, 22990830,\n            2938269544, 3188893513, 1701451446, 124677463, 2376122456, 3735869779, 3855792596,\n            3836459842, 3548479279, 290636702, 246664, 797902866, 2875170064, 2475070809,\n            4116284414, 1208231388, 2828093914, 3711751904, 2624075253, 758366641, 4278761943,\n            679106142, 1679478312, 4110848533, 540768264, 3004089076, 890051787, 1527108158,\n            2687541799, 1379201802, 1778300800, 3159280475, 693175137, 1706052065, 2740998490,\n            610778078, 1254469442, 555145750, 4257282365, 4088567402, 2722156643, 2973326370,\n            2580839471, 2297203610, 1325248528, 2289415165, 2027203297, 118624041, 3143737015,\n            3150787590, 2027511535, 3762291585, 2693532637, 2791300523, 2662758110, 3136152569,\n            3442748961, 1004378785, 2651776322, 2521157696, 2559348070, 3806708201, 1867376555,\n            3308198648, 792265193, 1257869334, 3432781024, 3378655514, 2353252813, 320451009,\n            3968297418, 237777247, 2490314264, 3266186675, 2255726749, 3147278539, 564923137,\n            794399730, 1624402708, 1616480718, 3606683399, 757916498, 2887385172, 2854589997,\n            3276729119, 133652525, 1045552210, 2262021731, 3248481891, 630857187, 4136667563,\n            3680583667, 2458003061, 102973943, 571665205, 4057786651, 1569357837, 1410019960,\n            1524881406, 1358182388, 785354230, 3829905260, 213334008, 2101845387, 3881098191,\n            1678603844, 2662511679, 2818265908, 3742761039, 662343317, 2881658894, 3293956365,\n            3576730814, 491183503, 2939708573, 879732964, 1424495345, 4226077578, 1724320764,\n            1649293059, 994517776, 3889024255, 3687388011, 2119938117, 2827748429, 3235814626,\n            1943795862, 982655659, 1583416575, 3637162242, 2899231071, 2356372330, 3229140115,\n            198960123, 3846475068, 1379416053, 3794102303, 4194710328, 1622023564, 2980258783,\n            1612348456, 3206356835, 2346630402, 955347169, 821327724, 4081137787, 2863165917,\n            2043355649, 448503436, 3529831118, 1098373576, 2154452300, 3915536064, 1741721503,\n            3989667375, 2498018598, 3111090221, 2451239649, 371187044, 2476450463, 2115422939,\n            3108069162, 4258140100, 2689547883, 1035006996, 290446056, 3920544792, 28092053,\n            2601721063, 4021987364, 318467100, 1559961229, 3913031650, 2150104709, 49270356,\n            3722496751, 2311386769, 1143265675, 3292662688, 3972381519, 2455100296, 1617099761,\n            2421726076, 1783080166, 2261765086, 1218624302, 2857474674, 2302060834, 3546888248,\n            1032153741, 2340941676, 328079068, 2490189793, 740867935, 3624104142, 1585037711,\n            1856136911, 1717156296, 2551956249, 370730527, 1811127937, 671199828, 1973541789,\n            806145565, 2632536732, 2824694830, 2549158326, 3875815943, 941204372, 1001702521,\n            3826400052, 4193710040, 50745642, 1293062837, 1041970744, 3817762988, 2674255278,\n            1058357022, 3904842671, 2225254087, 4291341999, 2609553612, 4143229959, 4237512560,\n            2910271684, 4066468195, 830828098, 3194488049, 2949340222, 2932945527, 2929064674,\n            1551247455, 3984924241, 4112937654, 1045724925, 2309857853, 2137885547, 2923347121,\n            4181282731, 2915373843, 1568721132, 1544506706, 2853606986, 1231383293, 2575465448,\n            3131073921, 2053909572, 2942680140, 396827888, 3916340049, 3526097716, 3106089469,\n            3522561956, 3015937009, 3739198049, 1425146641, 851135341, 3019020815, 4249482313,\n            4186849406, 3142115855, 4096457822, 1432901702, 1952216623, 2397263357, 1868450777,\n            1021098076, 367053436, 1889683424, 1528567953, 3087804116, 689228227, 2409781986,\n            2752631639, 2960393344, 2301774469, 4157044152, 730723095, 338324989, 783259147,\n            1430926216, 364208092, 2781791540, 805329298, 3841626209, 3970169746, 287294352,\n            3731446660, 704479128, 1206988970, 3298938102, 89005416, 3951683481, 835191365,\n            679211944, 949588029, 4076949094, 1529663160, 3763599166, 1992389156, 3959751596,\n            2621078932, 750118917, 882657993, 300498126, 1496181503, 3757618374, 3957243704,\n            3918083074, 1894830898, 1138422947, 3463164955, 3636023625, 257441260, 1054022983,\n            4011330770, 634925427, 1390194826, 1996961100, 3964708260, 1299498822, 4278592313,\n            1555238361, 1205023411, 311299324, 236721311, 3010275108, 773372856, 3619575032,\n            1947972130, 922773743, 1813182889, 1430693131, 1140839147, 3512260679, 2399704504,\n            2884240894, 3489240991, 3667939455, 3637582953, 3111367472, 2822381631, 703081566,\n            3036849914, 2845998620, 773679554, 526636749, 3314520937, 13776732, 796381020,\n            3189459033, 1934043296, 139616721, 2828193945, 3267247609, 589042452, 1387645753,\n            433640237, 1712804027, 1437726094, 2315749526, 27879840, 2472687972, 4005884263,\n            2644286003, 3168722815, 3959061551, 2404760593, 987990445, 2910703005, 3677874076,\n            4091231914, 4119403177, 1473482319, 1037359752, 1631420571, 2267882683, 444729973,\n            2607180061, 2466991138, 1500108829, 3858708078, 941735860, 3449116164, 1032454377,\n            1971102799, 1555909634, 1983708971, 3293773413, 2291541419, 1909009948, 3757184049,\n            1659282643, 3010427039, 2230678723, 3692534068, 1571464599, 533744779, 900521822,\n            737309762, 4215816039, 4242327287, 3884240140, 2486598498, 543513492, 2325077751,\n            1441237310, 3453763982, 1762843580, 1455435252, 3579975980, 1431912968, 3904977435,\n            3063717287, 8851622, 781126329, 3347412227, 2209219872, 2335275863, 4089034368,\n            1297331762, 2395499389, 1735909479, 1433771236, 1874079286, 2401526645, 3979584502,\n            814026601, 430924818, 2581307431, 643293685, 1092152530, 3681627832, 392138944,\n            3285203886, 1924582243, 3446213836, 3409964164, 2159521691, 3859916944, 485937737,\n            3082540537, 2628652573, 2085005488, 1570820241, 3255326214, 2324771674, 968029126,\n            551752207, 2734613650, 2519802827, 770398677, 588214604, 1769698821, 1440668325,\n            2016437193, 1333156524, 1671885991, 3833566075, 1771521418, 3300003753, 1697599567,\n            530705419, 2676238526, 2443737372, 3125150670, 321490908, 2097084981, 4189778990,\n            3647867606, 1625184465, 4268086243, 1553897575, 2306003829, 2205478208, 3688371963,\n            1133515039, 2669386733, 2223812538, 2214358594, 96593859, 4190632593, 1452197431,\n            1135606083, 2782212791, 2805304587, 2716383209, 1021017905, 1848454580, 637206058,\n            3630544172, 3327436426, 1359058780, 3757283546, 4081247529, 476986455, 2103327529,\n            261011811, 3377587780, 2208830435, 2954839100, 3294212947, 3523724980, 572494204,\n            2312304117, 2237590844, 1825143066, 3523469615, 2955256347, 2205596286, 3913732250,\n            3169279660, 211384653, 3129298603, 3451891904, 1392695925, 3936245195, 2315924122,\n            4256973470, 4208012834, 2914727856, 3790633264, 1352414024, 3268830516, 499517949,\n            174767898, 1457739315, 2708146151, 462102433, 15650350, 442999273, 3598360532,\n            3949145914, 4359748, 908554163, 2068608696, 1151136361, 3549502220, 3930154182,\n            1209162050, 2329490399, 3594864904, 1344017956, 2894570798, 1303761033, 880238473,\n            1215599665, 2238714951, 2775189345, 1440983553, 1580240888, 3808296473, 3676441154,\n            2656910063, 2780259105, 440787528, 2668696704, 3016754110, 73074429, 3699432385,\n            2168409706, 230768634, 404640783, 2512075223, 1443974378, 133144391, 3126908580,\n            1897307179, 285748108, 649198164, 3258373165, 619570044, 3705326499, 629753586,\n            2028146489, 1628060293, 1463155954, 594254860, 4203563010, 3465791513, 3768995488,\n            1179379840, 2659134767, 1087684809, 3708559675, 9397244, 3404138946, 3058055295,\n            3741047003, 900728367, 307309239, 1593283123, 3051916956, 2277186179, 2986400049,\n            2430308800, 3704675438, 3404110336, 3483462036, 66099132, 2203628450, 2586730089,\n            2420731626, 4042472356, 3655978764, 1856089837, 2068061659, 116363573, 1803321038,\n            802435566, 3965886166, 3600776237, 1563947327, 3756986210, 3427924426, 1576590362,\n            1417428898, 1027624544, 2293607126, 3716905851, 1499703715, 898967036, 2023639876,\n            45607182, 3304340202, 2558449320, 2150787328, 2110495244, 104517510, 2634417946,\n            3511927445, 2617983280, 1519839278, 2080506268, 3510088443, 3374267769, 36753302,\n            1909343363, 2722532212, 3354690838, 256523639, 1948127569, 819808246, 841164328,\n            1517898429, 1087337370, 2670414963, 179511035, 4259795329, 1457200223, 1097109826,\n            3252883568, 2453318932, 1234667752, 1093803264, 2111693083, 3511689983, 3823822344,\n            1905658711, 4144934159, 3435456888, 3949822649, 1400424939, 3976610504, 1652341050,\n            3552094049, 1465533861, 700947875, 2014956419, 1226278410, 573601914, 2391611176,\n            896583523, 3273421219, 2062693644, 2473342105, 3141025520, 14886427, 3812114714,\n            1853239414, 530505244, 2291720315, 962867072, 4243165058, 3342695710, 760937000,\n            4153054130, 2531380355, 2739976263, 469524224, 1295576354, 315429703, 1260352560,\n            2029030092, 3865675090, 3044871516, 1022845266, 1911371710, 2029537835, 561158867,\n            2174744632, 1969959061, 4102284246, 3981415584, 845291562, 664613325, 3222931218,\n            99095455, 2730475474, 2493017145, 2530889390, 3882983360, 2776234628, 427527768,\n            2075694791, 1903254438, 4039149192, 30770042, 2496262182, 1075501546, 1857577671,\n            4034387356, 1298016668, 554687483, 3783554334, 970938499, 2302276336, 2465839556,\n            2875226988, 3946025154, 1605779475, 212491074, 2039324795, 2511272148, 3923741618,\n            666705577, 2301221278, 2244215846, 480775695, 267961632, 1398864729, 3539474141,\n            2896696240, 3188210962, 4263170711, 2166709809, 4043606422, 2748308566, 2036300676,\n            3485163043, 1231312509, 2222796131, 3353346189, 691566953, 1926907588, 3143133996,\n            218024902, 3303115913, 2741933253, 3455832203, 2188548704, 330825015, 2988198047,\n            4113395594, 4274856590, 3454076086, 462612564, 3932732738, 2847173559, 94324448,\n            302685117, 2819834066, 501928546, 2918695331, 3730187626, 4047509480, 3958497929,\n            1405651323, 5198493, 1435107633, 1798603038, 1425239659, 3810371916, 202010946,\n            4127037492, 3579977862, 4105633677, 1697820216, 4098674964, 3877256724, 392149415,\n            798840279, 3279443441, 4160309648, 213003724, 240523366, 4254997725, 1194184072,\n            2242246894, 1565800018, 3099244883, 1899811749, 1295189975, 139297877, 1760389535,\n            1791623988, 2047447468, 2718025083, 478431801, 2261672798, 4163824143, 954044303,\n            166186880, 165190820, 3209346046, 1767632545, 3208218630, 2170624938, 1520217187,\n            2770731000, 31985474, 1167140123, 1247499067, 1192858555, 2000398094, 323618032,\n            2385630760, 263840016, 3630549869, 4085715997, 3305918489, 577978082, 2569352262,\n            496663850, 3244713533, 1371046284, 1053634009, 1596337603, 2530667353, 3571699092,\n            2985850617, 3506241759, 3886001202, 321142492, 3535666188, 2809260421, 2520009183,\n            505825281, 1161639420, 3107872099, 1807858866, 2661099911, 3683524084, 1968535972,\n            2137059248, 520800332, 1760245308, 3261727857, 3808954978, 1344215885, 1106658531,\n            2477902650, 3739801516, 2862406397, 3752206269, 2406717892, 852545984, 1600683943,\n            515483582, 1404164392, 2625795199, 1947658962, 2081075491, 1506117942, 2881196791,\n            1124436092, 943233079, 3830847156, 2066671345, 1714460049, 3341680517, 4122571588,\n            2566663117, 3684270833, 667555911, 2348733364, 1961106649, 1440628769, 1419633260,\n            3052369574, 1108620071, 3434026162, 3916636599, 3102975331, 3886608438, 726540295,\n            1959301605, 1097548123, 4197775113, 2426454473, 1977350598, 815012862, 2487421470,\n            2968184113, 3186369366, 2845700438, 1474463355, 3590404890, 2351730037, 3978816218,\n            227579243, 185502596, 1922772057, 2864373880, 1909608765, 307719594, 4182459185,\n            3812324913, 1740357086, 619281590, 1426834026, 2868540501, 440166317, 3324081248,\n            1368857307, 3133154844, 1142185935, 2703145826, 1436656515, 2490167985, 2881509383,\n            725592411, 1056415214, 1801603748, 1098036334, 728276877, 1517386665, 1881520126,\n            2784785117, 2287558410,\n        ],\n        &[10; 3102],\n        &[\n            1090717952, 2156108212, 350273489, 3024455201, 3838859480, 1763682042, 149424184,\n            1964532786, 2975786529, 1330105564, 825339885, 383596706, 1309738864, 3102683106,\n            1267756411, 331533132, 2276890860, 3327701870, 3922167079, 2896074883, 3076190602,\n            3663514288, 3805009976, 3294968413, 3454159952, 1433044633, 1418330474, 3359465151,\n            726279979, 1342757809, 1717772144, 1003085734, 2383148345, 3108498579, 857262627,\n            1951196781, 970979556, 3558349653, 719437007, 289934369, 2266211882, 824447611,\n            3232349724, 578075700, 1450980059, 3899374024, 3220048941, 3157852665, 1409605220,\n            4279778126, 723171133, 1113923114, 4140464683, 1264137218, 2056188435, 258995120,\n            892162965, 3829554944, 2681105510, 1583433375, 2372905114, 3063477039, 1123473845,\n            2771465128, 1571676395, 3132543233, 1955633100, 295321580, 262431222, 3909294962,\n            1234323475, 1146977857, 1180244615, 2708777032, 2757620357, 763176798, 3489960920,\n            827421850, 396692493, 863122461, 2175230819, 3275878842, 174471042, 3146862584,\n            342421814, 3357270023, 3523699447, 1545479571, 4121473980, 3235129130, 321714055,\n            2578600590, 3034329217, 4088280907, 3865395634, 2465310687, 458941873, 866729095,\n            2456475470, 337410335, 2743205123, 1612928815, 2774001661, 2444680802, 2258871830,\n            294989145, 4032430053, 4160268372, 2581206833, 337233193, 2411041307, 2210559675,\n            1320636980, 3315911595, 3275455465, 2302984096, 672110132, 3653048361, 2876650516,\n            58619071, 3097462899, 913822537, 3958759751, 218968646, 841019768, 323642580,\n            3646079085, 1025622444, 1153752989, 896362417, 3233047963, 3053144671, 555216364,\n            3984925976, 4208406960, 1290598093, 2870076640, 3997709916, 708454500, 3105972733,\n            2678703766, 4256363437, 2450765138, 2014095400, 4105425179, 2141725957, 2199910230,\n            626073960, 2865754057, 427257176, 3022160073, 748977777, 711453669, 185620628,\n            360059795, 2223254315, 1556884756, 2383089920, 3314628127, 2991750905, 1339531032,\n            2488885176, 3516500513, 507416144, 1013539888, 3457856430, 3755907081, 1921624927,\n            1369652151, 1997994368, 1850993214, 459124004, 110586114, 2684660650, 2943708645,\n            4489517, 3069666339, 2647257714, 822416462, 363903775, 2782178150, 1587688149,\n            2234131461, 3028274281, 1791850871, 221035845, 1804019576, 1116698406, 367798193,\n            1053448930, 533397614, 863734009, 3655389622, 2116781843, 1800956650, 2698452833,\n            767322912, 483461998, 2355309940, 691456151, 3678411612, 2512848231, 372079251,\n            506701987, 1632924476, 3355892148, 2737715179, 1086990673, 3418273230, 1792484018,\n            775455026, 2920706888, 4051313610, 565136534, 4187413306, 2454459484, 185646538,\n            1004207878, 1369245165, 2500961438, 3476225504, 3587974751, 1342369718, 2164703585,\n            3648159154, 1734858305, 93034281, 542413582, 440717259, 969487131, 2111774966,\n            2310936947, 2303488867, 3256353251, 4175586953, 2454152906, 1789194116, 3011411086,\n            741565289, 1498115892, 3457474742, 540380691, 455385499, 2738934502, 4210812951,\n            1783205427, 3541032100, 3134343662, 3009641213, 4026234562, 2665343131, 1063120987,\n            3884850565, 1192430939, 323970520, 559177982, 1345369739, 626751520, 2278721886,\n            2044575907, 4214314085, 219732149, 3523631645, 3754346449, 2727490575, 2376307667,\n            1853405706, 1796550525, 2321489264, 2107896542, 3370749017, 3741446121, 671566537,\n            2578490527, 3744263087, 933713676, 528348682, 1174527824, 1633600618, 1449659937,\n            1961464045, 1435261180, 3435913817, 1674813267, 740556665, 1925082839, 492222737,\n            1152842767, 1001774028, 440836527, 3036608531, 1628710758, 816418073, 1474809294,\n            3227390248, 2473395569, 3414888182, 656330010, 1479130138, 1403564030, 2205423473,\n            1247584460, 2852752376, 1655058304, 2479120219, 38826481, 1340254185, 111081908,\n            1620256762, 1749504704, 1852459215, 2510520240, 2086199461, 3994374087, 3258598584,\n            2820729717, 1611066701, 4286907151, 95624364, 1655577300, 3038162660, 3792169258,\n            1389255698, 3165831955, 1013041891, 1743225847, 3756082384, 756057249, 3740236323,\n            1795451296, 949660704, 50247423, 4079440605, 2989395115, 1289662311, 4288930487,\n            3333588594, 2615848486, 1227497733, 1656848582, 1924450768, 769521968, 3824099572,\n            2690512143, 866732272, 791334430, 3170063201, 2262692873, 2019319346, 1988855699,\n            4294430135, 3180929851, 2601513082, 1603406395, 1885990005, 406936623, 1438215835,\n            3974653918, 3787167260, 2006412026, 2528692573, 2467218254, 3650037147, 3033752051,\n            3510656300, 1271810081, 2372454283, 866402934, 2630049394, 4166224831, 4222042215,\n            1853495757, 1769261901, 203136510, 3068716734, 3556331093, 3833823460, 4009822672,\n            1117591552, 2600758025, 115168937, 2239630873, 662560619, 1009759809, 1016185325,\n            369907564, 2714888372, 2548423860, 2933324161, 1227687572, 3678548600, 3042825716,\n            4237920281, 1386892686, 800137739, 596857528, 3934884250, 2863590771, 3293648172,\n            2223633865, 1469744532, 1385852890, 2677459493, 1806385946, 2846680173, 1411276972,\n            120856454, 2703947889, 1947260480, 2346135942, 1873485442, 4151173139, 720130513,\n            636391399, 1623982495, 3511571348, 52205464, 2998575109, 3988636401, 1858864814,\n            2075342271, 3424565081, 497032190, 1560863922, 4135822115, 2092981905, 3311540620,\n            698269898, 1152018580, 1909520409, 2872237614, 24480757, 2360114419, 3727056709,\n            2450315687, 1706072395, 1363125084, 3558698214, 842373150, 3007100963, 575589645,\n            3945857620, 568147864, 1712374375, 2278524802, 2531072210, 3394971793, 3997305283,\n            998833657, 2762896540, 2604155699, 2561679888, 1502429283, 2218509049, 1921148339,\n            1519092093, 3213228029, 1426760811, 904739278, 4177682877, 433244268, 2891249341,\n            4260379469, 2639356759, 1731392423, 2649822319, 2830903281, 1565442855, 3287897195,\n            718318198, 2284432862, 2006933712, 4097550874, 13736850, 2821878762, 56426552,\n            678446210, 3753678933, 2849007117, 322553273, 2421252828, 1292094921, 3540150159,\n            1096045236, 2005002267, 2734110428, 4181867407, 380970148, 2730665136, 3608809718,\n            1558885713, 2108112789, 1305784440, 4154730813, 971831325, 845397285, 3234766202,\n            1845019061, 3973141971, 2319898554, 104962486, 1711747429, 3665718545, 163140566,\n            1806449280, 1900592958, 998178499, 718808781, 3659633411, 2190327415, 3403836612,\n            1913275374, 2847860912, 771283178, 543991354, 2586448373, 137792067, 1555519986,\n            4192340660, 1091533283, 40094006, 4223660489, 1665194480, 2105973688, 2543304158,\n            1816216675, 1621624381, 2460983951, 3973282113, 1072985609, 1564938369, 3846983434,\n            2823315144, 1402159257, 2475804142, 368277433, 2818088611, 17259334, 3968611178,\n            2260375095, 372916005, 1244823290, 2674108040, 3840991642, 2166858920, 3274751710,\n            4055119042, 1743188075, 3224809785, 298824667, 3551364331, 225111868, 180196113,\n            984373701, 1080566822, 2282104552, 873734654, 1881710617, 1957406795, 2819529053,\n            3699498999, 618406261, 1411687477, 3294142138, 4109228357, 1111709181, 3569930975,\n            3649563402, 1370505339, 957537026, 1430887326, 3375729420, 1668002127, 335031937,\n            1302213471, 1514370498, 1390927782, 257051248, 2717891633, 734437066, 3616114417,\n            1440854276, 4172452465, 2701364793, 3398370598, 1583363955, 3382697344, 2680576291,\n            2364087309, 4291593259, 2189798514, 3893095284, 633222065, 3971445386, 2677954705,\n            3531415053, 2724261077, 4285221053, 2129687493, 2000487472, 1855835954, 2928282181,\n            120966311, 4042989755, 866331527, 1123468962, 3298045818, 1530473651, 1024041639,\n            1984893129, 2159094037, 2026770150, 4185797651, 3520534549, 843974370, 3393354829,\n            320908341, 1886807044, 2973647480, 2675842038, 1637217421, 598904119, 2024029635,\n            2658505892, 3774538401, 3858157606, 1813337451, 3136106883, 2837603055, 4184201045,\n            1940623301, 759878760, 1966671788, 435061790, 3385122062, 1905704773, 3714157614,\n            3688288, 1159893594, 3153676685, 150883081, 4079967367, 821718676, 3872020012,\n            3059753072, 1402694601, 4120735845, 2607623231, 4068440388, 3189599962, 2613614363,\n            2618032086, 3926196446, 1828331864, 861167636, 2070698459, 1204088555, 2405297256,\n            1745183089, 466608482, 4223052110, 2840116968, 984003195, 1777097647, 3586028764,\n            3251800257, 2497665107, 180188399, 3126896641, 122622265, 2953497981, 4213464561,\n            359409662, 3467947387, 2765137292, 3348609502, 2858265693, 3004789546, 1269756788,\n            494948201, 695533571, 2753599690, 3076351820, 49293197, 1051805370, 3181933172,\n            3454734763, 755937365, 2254590157, 2668130189, 124478903, 830440858, 2704494129,\n            467678347, 742307954, 3320076210, 1519646818, 908766880, 2271488850, 208381207,\n            465993605, 2245579121, 2633035144, 4006178687, 898741217, 2837373528, 2220638821,\n            3393350699, 768736986, 1547408793, 2330591601, 293657158, 3599057271, 1812009558,\n            608741132, 2340820056, 432828948, 3362138705, 1779513577, 764640091, 4199816090,\n            626042994, 637848155, 4008262411, 1871364792, 1182368468, 1997552252, 4138958968,\n            706743330, 2820852489, 1421174910, 680654415, 564585995, 2379717993, 609794982,\n            3377050361, 4109006795, 693815803, 3936809934, 4210673087, 2231890421, 472108163,\n            1077965906, 1522202179, 3359781314, 257775293, 4283133175, 2205671557, 1009994332,\n            3754176374, 1713220074, 404565102, 4052218526, 2542881209, 1590444400, 2250412460,\n            2752916267, 1925025990, 3034563370, 381150924, 72207796, 1529203850, 3440350135,\n            449786087, 3057224398, 2931026809, 4126185768, 1832779724, 227349743, 3257828641,\n            2622027559, 53496088, 1386578061, 29143174, 3318504792, 4263015279, 3862476972,\n            2053287632, 2383813692, 1392710041, 3380892795, 1203449048, 3219491462, 2527771468,\n            1928066139, 2782747093, 3776664325, 118161862, 972613496, 75206914, 2466998424,\n            1114784434, 1544184426, 204356985, 2904648548, 3177980220, 1196742597, 1654051743,\n            3517300309, 1274643016, 2640753294, 49691557, 3046622357, 366932489, 469041546,\n            49806420, 626931782, 1692259333, 2477527404, 327796810, 1483597922, 2101724339,\n            209085880, 415898213, 1647132242, 3755738074, 928274496, 1980242813, 1895479875,\n            307921801, 978937472, 907914793, 1477318094, 4294477183, 3428889472, 173168981,\n            1095503453, 2228668963, 2549539931, 1805920496, 1290978426, 1833393520, 3213182098,\n            4134091325, 1919861738, 3763217622, 2484858079, 12506978, 1169905736, 1821786542,\n            3080936118, 2779223089, 1621604259, 2577844383, 3243664640, 1209156142, 1769054118,\n            21985663, 340266898, 2704604015, 3519465106, 640285774, 1363951121, 2556443906,\n            742602348, 3518175490, 3944113811, 1501116841, 703021247, 816817219, 3024244920,\n            2267970897, 2505826303, 4070809695, 303283887, 1827570052, 252725529, 1243973712,\n            1267175904, 582246720, 2585781617, 2588311835, 1377916525, 1900612480, 1207441804,\n            1660238122, 2834816049, 2104192369, 2477665501, 3367278470, 2796413335, 1773026653,\n            147981809, 1982946959, 4231593516, 580296265, 1418923635, 2537093055, 513778444,\n            2367344803, 2177583029, 3362655803, 3451631757, 4109532326, 2539927008, 1250994482,\n            3891200603, 86105003, 3058541377, 4190093248, 3084970970, 2573686253, 3673810648,\n            1244190515, 3704012891, 2239671505, 216284468, 272559052, 242082122, 2364929555,\n            2092733433, 4175166062, 1412396441, 4114858830, 2811682670, 2896056289, 2988499227,\n            2057139246, 967496767, 1605158087, 1835725667, 481013101, 4009066892, 3973153481,\n            360650401, 9673641, 1172058675, 528556840, 847141449, 719939397, 2217183389,\n            3726446785, 3537383829, 676852573, 3187467251, 3958350690, 4039017732, 1346223337,\n            1094346663, 3497436668, 302069974, 1931231492, 3398249626, 4270841307, 3765287180,\n            3024646894, 2031908674, 3446020856, 4081067913, 1373057287, 1518315822, 1321439374,\n            2274678388, 2203534338, 2077694709, 3889954809, 2691565169, 3514870949, 823524823,\n            612494827, 3081677782, 1756533912, 586779579, 2007011479, 11949231, 1709414254,\n            617070129, 110741675, 1131207946, 2022387375, 720764579, 2772437999, 1890786295,\n            371370784, 2216802804, 1277094996, 3383296822, 1554099211, 263584016, 871207305,\n            711728830, 1670583866, 1505094099, 2977812939, 3719071492, 4019779868, 2361512439,\n            2724398820, 3358209161, 76635792, 2067770060, 1919005351, 3765149890, 2344651247,\n            918395809, 169000954, 4104553001, 4012423504, 1943167921, 1994534083, 255873856,\n            3950635658, 334633561, 1665872361, 3346436189, 2305043435, 672270453, 1104556131,\n            197449005, 3318764807, 3346696173, 213679635, 1562798352, 3887250019, 2797885903,\n            4065398645, 235286644, 4213189332, 2242827500, 2188052452, 995609888, 2430405513,\n            3810523151, 2895640923, 1914975173, 2785119419, 4131596840, 1701708501, 1661661704,\n            2366597389, 3369325724, 3245037819, 1383273697, 1656215277, 3750856436, 1367025729,\n            3564417360, 2412789958, 4225228883, 4236896437, 2240915942, 2808123402, 3838053646,\n            1569872718, 4278558531, 4276284730, 1829338066, 3443489953, 3921710904, 2917043594,\n            1130555892, 3624712831, 1571788245, 4007696588, 295001472, 3768023434, 1288510992,\n            1089344678, 2299571576, 1650317650, 4132048019, 761783149, 985242260, 3205994716,\n            4280891346, 4272726879, 2084216996, 2494832090, 3255068444, 2248563077, 1158015972,\n            3873260610, 3948057787, 4111883998, 2626290680, 3248889779, 2613319216, 1697116413,\n            1548773610, 595185087, 3322718086, 3857871350, 4152897235, 4047671533, 2219020175,\n            4192126272, 1664095302, 2280956458, 904136331, 510232447, 1427249491, 1384316914,\n            1343969612, 1405104663, 1412838080, 1476707740, 983465790, 1762062407, 3363737156,\n            703158981, 1526075277, 770375910, 3568014930, 1871625831, 505558396, 1017104640,\n            2494021223, 873554772, 2312538837, 968308840, 276194724, 958905359, 228346057,\n            622614964, 2894593284, 3631833740, 4239282380, 2847443233, 1501352802, 953618502,\n            1180605596, 1353723774, 693839282, 1122299711, 77184461, 1683234463, 2281879614,\n            4121777231, 3522513017, 2049478114, 2745113460, 3632696079, 329131160, 235023372,\n            4284514543, 1898778476, 1796742997, 3536086557, 2779325362, 3524449373, 4163660793,\n            2136943826, 2396463271, 3446767937, 3132326206, 2604357400, 981079321, 4262890828,\n            515133864, 3176759850, 1406774082, 691951040, 890959523, 358451693, 4210979366,\n            3571647669, 1991124066, 3815573534, 2698390520, 465718229, 1747912439, 1022819130,\n            1181589573, 2978236388, 2676969630, 929644975, 3869558367, 3136501481, 2215312177,\n            4240502976, 2372154096, 3817126393, 3887982659, 1230240476, 482004751, 1800315429,\n            1729911876, 3787661423, 3326543309, 1303724155, 1071421675, 2680803161, 4286403669,\n            3426551850, 950418497, 2546459214, 1712894075, 1780385242, 2797706354, 656883086,\n            658627077, 405731949, 3490825447, 3629282277, 2851187329, 3303974662, 3783966209,\n            1210867902, 2910057846, 924013199, 2064510236, 588108706, 2350934006, 2721042338,\n            2248021494, 1663126823, 345965610, 196405091, 1853524882, 487839382, 3592519115,\n            4182087353, 1936152219, 1567506485, 2440099834, 3773647079, 3111662822, 1469095034,\n            60088463, 571298405, 1342514879, 2387059260, 2609978893, 2695605052, 1500695679,\n            3737563751, 2671030982, 3087242738, 1646842298, 1395645920, 4219026547, 1468460189,\n            473402276, 2416556337, 4236023635, 2053449695, 2713842570, 114714595, 2242466738,\n            1491093214, 1414923813, 490509229, 2469148401, 2940805508, 3189209581, 1147864558,\n            1254489556, 4141609417, 2762564973, 2412084773, 3201308958, 3153180883, 3803488695,\n            2885402304, 2959502779, 850343331, 3223354997, 1567976160, 2929300284, 2953604238,\n            1397946866, 1922417506, 752371599, 625666244, 2495734608, 4023531640, 2020349711,\n            918493671, 3957957161, 3763438620, 2199610945, 3489887697, 3986857188, 2065535844,\n            2378756250, 4277390505, 2773369964, 1818343729, 2423482669, 3908636840, 3078629510,\n            1244167101, 4044098654, 1959172939, 1733689283, 1583866376, 3413740736, 664020126,\n            1224172498, 990411245, 1549178739, 3629152519, 2242650388, 2250444626, 634849745,\n            3527843259, 2108135310, 3442116693, 974285693, 663652224, 3115263249, 365396304,\n            944904105, 4019092791, 3919726411, 3018566975, 3159500255, 3686651445, 3175277558,\n            922171779, 2462000472, 1259172224, 1121292435, 903437378, 3672774344, 3832051306,\n            594779593, 1987297741, 3676480663, 6274837, 1587502305, 1498165668, 1995238509,\n            2854473725, 2112467068, 743398066, 3255144759, 1703355494, 1225160060, 890700306,\n            948609091, 3849870887, 576173943, 716212019, 3994517475, 758386819, 3758908380,\n            2542843562, 738235372, 53239691, 294660356, 4147877271, 921649500, 3545910888,\n            995778640, 3088349278, 2909584602, 69702828, 3002528754, 905054529, 594966730,\n            3991421200, 3346531150, 2708808877, 518682141, 1377883437, 2811283284, 1998649211,\n            432506178, 3582090857, 1518553251, 704966865, 1152794276, 1887013814, 1606546655,\n            2320565517, 1854706060, 3492917451, 1016685248, 2483681864, 3741032493, 141821228,\n            3608375345, 1853130503, 1371936898, 1504662965, 659041904, 3170653560, 3609090220,\n            3396501567, 1315443498, 146480212, 3196730981, 1893578665, 157156336, 2959755534,\n            177913752, 3735639523, 3943319643, 1868850449, 3900298242, 967046318, 723106397,\n            3866951859, 1936369464, 275735231, 2279235939, 2546839449, 3873546747, 4166821386,\n            2744063441, 3564652067, 1764640063, 183521780, 3369633040, 3841701836, 3465123851,\n            3367453304, 3256197924, 3102854106, 2846655002, 1849894409, 2339775549, 2213818357,\n            3714526900, 2044167006, 3352934076, 3296142050, 1452861726, 554544616, 2961402676,\n            1347269459, 3272438691, 3364677600, 3569402429, 1567032362, 3983089605, 2451070925,\n            2400442159, 3827034395, 2662868458, 2511023251, 3619351425, 3848346514, 114730582,\n            3724974821, 2960418392, 2121837371, 3171187943, 967074174, 3916094096, 753095554,\n            100041453, 1885072049, 2560238217, 1031033424, 3006225480, 1813703517, 2189855798,\n            1600252638, 2604094431, 645137521, 2310043678, 1161735533, 3829093982, 163252700,\n            1418800082, 2157595605, 2830571794, 51442976, 1287917767, 2778577998, 4266383296,\n            1450100630, 3956325244, 3528166696, 4098054148, 951318213, 4096964166, 2902917401,\n            3266826735, 152519616, 1330044083, 2306910623, 1929913059, 1427154621, 1725587483,\n            3719781347, 2554687446, 2159039897, 1672822753, 357590121, 772599334, 621477550,\n            2577487631, 1456833286, 1824017186, 65454326, 1430310725, 1007554257, 255221774,\n            2188204551, 1758408610, 1160946986, 2894288687, 3620984191, 951189524, 2755450021,\n            4099420945, 891823081, 4255264434, 4243288840, 787332307, 1890387056, 3513444862,\n            896706384, 3158454173, 2469720952, 3022826122, 2611183721, 1054857002, 917646884,\n            2768035117, 454153864, 3120766455, 633549521, 1204655955, 3547479820, 2162564840,\n            2842981918, 4026548120, 3266113360, 405856795, 3682064348, 3126006800, 674032447,\n            1764963884, 438742236, 2447142230, 3021367030, 2514998789, 1705836733, 1380221336,\n            2579667377, 2970936764, 1297148982, 2782179170, 1625370043, 764959316, 4158350195,\n            4184242253, 3750959699, 3650216491, 3225748766, 3647469461, 1194669376, 3552307158,\n            3438538382, 1054824592, 176660371, 3685211071, 3670270749, 2855384617, 9252392,\n            1920385273, 2712554076, 680835555, 1053296577, 914406856, 1795998638, 2307750018,\n            2948698901, 3145311923, 521933093, 1912726100, 3784412874, 2098064263, 2623067987,\n            3796163168, 979837958, 4023799720, 3375366620, 1920292696, 792476699, 1084089143,\n            1202809667, 3357598656, 482513650, 1511366084, 2992623407, 3103016547, 2014609861,\n            1583241419, 2134081920, 2838589214, 2621048092, 4044456315, 187066713, 1368683450,\n            2424216066, 1122555665, 2510355077, 90137727, 2622045406, 4108832384, 3121348668,\n            2043157364, 3982086563, 2090723643, 2394520773, 705037344, 2143802253, 4087276882,\n            2242288088, 2475241732, 3234452249, 594913607, 734641233, 525750012, 2852738132,\n            1968495033, 3638882186, 543234264, 93792643, 4228836549, 850324946, 17108280,\n            3979354506, 851946399, 462754350, 4271566266, 1537479465, 3197388712, 201266837,\n            3381103246, 1558750422, 1285409370, 1617844183, 1039519019, 903635871, 4189886186,\n            2162565381, 2747933445, 2069332021, 4025367631, 1191397034, 1002342220, 1544722534,\n            4252588612, 2972277693, 4196170304, 2530494220, 1043573515, 2930652362, 1947531410,\n            4236990206, 1998844327, 2544287898, 1641430284, 902320686, 1896257916, 2722677955,\n            1260327212, 423335173, 93517862, 2290694376, 4293469204, 1957975652, 1486420896,\n            3229984163, 4214679783, 1518585308, 2053864860, 742898184, 2978819458, 229275214,\n            1661842236, 2678757516, 1888406463, 4085428614, 1421680217, 879251405, 3747442139,\n            2986833536, 4028746843, 1912392024, 2830010811, 1073534909, 1734569594, 3352364486,\n            4037547573, 2338368578, 177678500, 3585980747, 3269301550, 1033091801, 2584017523,\n            2965800986, 4148820471, 2107295221, 2835315859, 670873512, 1389861129, 3240020275,\n            4254842616, 1967535174, 981045842, 795039997, 2144384538, 3646450746, 2926920389,\n            2945522910, 310716807, 3171657481, 3782484158, 2804975020, 320691793, 2538630600,\n            3345140860, 3907217116, 3588798560, 2302258812, 870080377, 4291369835, 1552626327,\n            3096042415, 124363476, 1773131013, 3692965805, 3365861899, 1440753454, 3191843337,\n            2962696432, 1643478745, 2260344049, 3607121949, 1759413053, 3986873957, 2571700697,\n            2430473406, 1600575845, 1250435260, 3449710690, 1896873262, 3993858569, 1829325303,\n            3778745723, 1869764328, 247424907, 2673542813, 1633451397, 1536583182, 959172859,\n            3023933956, 3443239452, 3786779412, 2644779263, 983493006, 60836914, 3222293290,\n            419611365, 3049044539, 1208192321, 3948428355, 624555495, 1860297378, 976795529,\n            334412730, 1994993637, 2819246877, 2576458062, 1087908116, 2833894502, 2677739964,\n            2811979157, 2517954057, 1637620437, 2458393310, 3673047611, 240571064, 3210916349,\n            3312493293, 3438038688, 2150989232, 3621771756, 122828809, 3545508854, 980904068,\n            3855688819, 1237373036, 4161703203, 1893639080, 88677119, 998508480, 1489790657,\n            1975373296, 2611701077, 2939601762, 2978318366, 3813682176, 2225053558, 3231623010,\n            225533216, 3944071269, 1564635199, 2343194673, 2530207686, 2340255500, 3816901672,\n            649184789, 1121329047, 1087851888, 2874542704, 708723948, 2609890935, 3656624002,\n            535082954, 3176067461, 3442417389, 178468661, 2818052584, 3742446892, 2456023331,\n            2548297173, 2580631947, 837014222, 1567401775, 1653498571, 1923413408, 1365889663,\n            2964931174, 3792373609, 2215673693, 1786761842, 604133457, 3365238281, 647615447,\n            527376929, 814324092, 4273832745, 919246612, 566719871, 307737007, 3712365072,\n            1524061048, 1524890363, 4092313480, 357812892, 3328168844, 2949414373, 2938445048,\n            67720828, 3995463577, 1870752735, 2120315869, 538643399, 4086093125, 402131964,\n            2238597389, 999762330, 427027749, 1616120047, 1591012383, 846594556, 202955790,\n            1134267268, 3950396506, 1647097265, 3504648495, 1769374949, 153033933, 374476209,\n            788738829, 1914430731, 3479045135, 2977421979, 3501171925, 3454162751, 3246400544,\n            3324897747, 2100461800, 15110345, 3452738848, 3211481462, 20701978, 1896280106,\n            2689927937, 810040042, 2380782960, 4175999832, 4218788747, 2554924667, 2963420482,\n            3759592461, 2324175672, 2360296168, 1838860028, 852248206, 1568702062, 4157135131,\n            1498675881, 796772123, 848763645, 4122624167, 3127869000, 1447507171, 2802093629,\n            948109017, 3347335001, 676536526, 2568518559, 2560679521, 4268927159, 4145377471,\n            165505618, 3949709446, 1688814684, 2268511074, 272089127, 3955035194, 2001405835,\n            3873913486, 1576821167, 261684918, 3193199693, 4119477844, 529856174, 2101755958,\n            1650260527, 3905241885, 205252992, 2693824643, 2976972096, 273295797, 4083434052,\n            3461316693, 3442230710, 3998690634, 2636674871, 1189998180, 2171509956, 2082057288,\n            2022768325, 645984611, 2756493565, 981778672, 981279567, 3222030309, 1747828105,\n            3442464419, 2424375076, 1053573265, 1692548062, 2593452704, 1227124588, 3910979094,\n            60218500, 3393130547, 1815065370, 900666599, 2399318039, 2625976054, 2257451800,\n            169819114, 599462951, 188953128, 2274909215, 1405804440, 2540040583, 2316287854,\n            2380563279, 1367384723, 1529971027, 1413792674, 1012779143, 2283238631, 3411576953,\n            1598508626, 2824669832, 1188144502, 2130880255, 3179661299, 1166155355, 376688695,\n            1655696639, 145405343, 1870834401, 3542234305, 3431720942, 1720828281, 3313882955,\n            1854717001, 3328868161, 3324154256, 1950430133, 3625647058, 1820699380, 1546930631,\n            703592478, 839845293, 4255537706, 791203080, 2463244189, 1250836566, 1315888676,\n            4190687145, 3746092139, 357974384, 2947059052, 1617792833, 2115336259, 3789781037,\n            4102275412, 232466785, 2117636784, 3561246037, 3891171536, 2400671709, 959295915,\n            3468994326, 882558056, 995818751, 842505291, 1375865878, 884734747, 1807343546,\n            4068710301, 4275708922, 3842367136, 3327635120, 3559343941, 3897202178, 1832779951,\n            3370322615, 2551120161, 1890611584, 2553195125, 4178608716, 3327118638, 2896858239,\n            2162417957, 404937854, 1209844330, 59011523, 4274953916, 3162740132, 1404307510,\n            3641227010, 718193242, 4157967246, 18673180, 3882631874, 2063563823, 3172671728,\n            3666806220, 2721843184, 3439764862, 2622506534, 2383614293, 3270660691, 1555093174,\n            339420557, 2475108746, 3234567896, 2459856402, 758779244, 1522145773, 3088733605,\n            3223606950, 486818855, 3109975010, 201156160, 4283528790, 3448372090, 3328453383,\n            714383428, 3870535362, 3267062666, 1229012874, 3307226664, 2282699730, 3411577545,\n            3495367161, 3245914759, 2854786930, 2844907553, 3908364222, 2332836238, 3906847828,\n            836578228, 4260685242, 3661400554, 1069625777, 507842506, 2448309617, 2468478631,\n            3309541641, 3198772167, 1480745272, 4189065351, 1214355932, 1885820768, 30124027,\n            1364507667, 935429203, 318413319, 540980510, 3335435896, 3811593068, 392335562,\n            3608453729, 3270550385, 1790622107, 3501192907, 3146957015, 1447622224, 692793060,\n            1221092644, 2193608712, 1319210665, 3671568896, 919095971, 1077813191, 1135659859,\n            272015253, 3673441172, 659115740, 1893380452, 2653100874, 952959873, 3923508328,\n            1760506770, 1551515664, 1009297206, 4142944355, 2234970293, 3858209119, 2366087613,\n            3951258095, 1624277057, 665267078, 1962633094, 863137927, 3121800236, 2889332728,\n            3802215978, 3753185849, 2552558880, 3265389719, 437744040, 1853492870, 3804222377,\n            2693295668, 2632787758, 1656907875, 2143290242, 3457216477, 1451753165, 243784919,\n            2023761773, 2065250609, 9646372, 1970513220, 1312792672, 440036037, 2488357056,\n            3639213145, 2611194916, 1889531994, 3225504644, 596909661, 2152896558, 2038094556,\n            1861652613, 1018694909, 2475981091, 700897709, 2146477855, 3769379630, 3368410765,\n            4244654878, 416409473, 107818777, 105990419, 4172126075, 268176292, 159823783,\n            1823412801, 1297955325, 212684646, 330158778, 120048839, 3792210872, 3641969613,\n            1943970600, 1613650042, 4275884189, 2472239129, 11331342, 3062157963, 3212286511,\n            1103205343, 1315340436, 4132020485, 3019591722, 4194601959, 1607564095, 4129504386,\n            3426709937, 2139181342, 1378434292, 3827077065, 2663113173, 709062578, 3097108122,\n            1798417285, 2382236480, 811616442, 1324683208, 3546708534, 3807247071, 640982464,\n            3324209008, 1964450563, 4000490920, 4071170833, 4131722497, 1394339839, 2981940813,\n            1778660969, 515254052, 4028019812, 2702072097, 3460082516, 3790423972, 1562590275,\n            3101465409, 1862295751, 1582260043, 1748740302, 3681621631, 2922975488, 2961770159,\n            542936060, 1739340671, 1180333375, 1239500855, 926887387, 2406821640, 3753531316,\n            3141391563, 2259961182, 1228591410, 174823, 1381806956, 566138055, 2988175853,\n            1847393008, 3120710698, 3685278846, 3752242903, 2351962528, 1313271459, 1723591949,\n            3890970742, 2432689984, 2597394588, 2324945656, 1234261438, 1449738156, 4019842501,\n            430346341, 2951682903, 879630840, 4062129429, 562553003, 253797203, 3388149782,\n            2984362495, 3117043224, 2228577933, 506205902, 3817676085, 998121764, 2125626383,\n            3220681080, 1686680581, 16509846, 615404463, 624554411, 448057940, 3316065388,\n            3240405537, 2081588339, 30362609, 1684007187, 279962186, 3671833315, 458117527,\n            3254809987, 2942938590, 1594590517, 333342174, 1536541098, 2220689083, 2586047801,\n            1762722501, 2214456921, 1051130482, 564287951, 307008931, 1103460176, 2490005633,\n            4144286582, 3555713937, 3215428036, 1761896138, 679137448, 561037918, 1699795881,\n            2691553148, 685340483, 4080586952, 3274331518, 2770205739, 1282421707, 4121918929,\n            4985385, 1951371148, 1159075654, 2322137818, 177753850, 1434268326, 1088010561,\n            2752068702, 1511836794, 4008131577, 3479864517, 1744822207, 2913695807, 3258009367,\n            3580025204, 2965393138, 3453364576, 2844745717, 835302736, 839039831, 2781405794,\n            1211313828, 3004688333, 2595413047, 759773972, 2350229462, 344879303, 3050901125,\n            1030996325, 995511420, 2711476436, 1128357122, 456082744, 92376230, 3683366700,\n            2722846874, 1932234121, 335160721, 1351904570, 600118072, 541435748, 783832107,\n            2993459208, 3595542215, 3942419725, 2446984719, 429878035, 1893115836, 2948894203,\n            2954433219, 2079855466, 591139768, 2880173575, 64417503, 965466126, 3674400416,\n            2264200664, 3182148247, 3607752001, 16834413, 861612277, 3032639933, 2056520569,\n            1804478026, 3979615910, 2691939460, 51539456, 3631589374, 1630958116, 4026361062,\n            2572889891, 1142860281, 800243742, 3188319389, 2874524465, 2131066391, 1165150424,\n            221764370, 2086104276, 1815209496, 1565680026, 1537335378, 4097730794, 1599259210,\n            3307537268, 2823908227, 1533642679, 1908801686, 2305728426, 3094775737, 2008136290,\n            869012357, 1256653833, 4217413536, 3118658181, 2200543057, 2688925841, 452036996,\n            513601384, 722999925, 4203179368, 181147728, 864354253, 1526756638, 4052239276,\n            2863675779, 2567633284, 260724472, 4022721940, 3993630330, 310802034, 4024815047,\n            728911693, 2638130142, 68235221, 1882052451, 1890512547, 1164790737, 925191506,\n            1264638819, 3721978815, 4173325802, 821918673, 858405562, 2210711857, 1653420086,\n            430564296, 3991905241, 1833601995, 4132502168, 237428510, 938869191, 2919152192,\n            525867136, 1566225721, 2093630670, 4040865821, 2168254206, 1960676495, 1730270792,\n            3890844868, 1724493311, 3586016013, 1773227630, 3582791676, 1289814758, 3857458430,\n            1525923386, 2021352525, 479700812, 2717626279, 1581718030, 3179634604, 1365160899,\n            4185135681, 1960448370, 1809662556, 3239464395, 2074836917, 815269633, 2727994335,\n            2315955854, 3386483003, 1702296473, 2165420918, 1571285903, 860561699, 4261289241,\n            870069641, 3640150341, 1774315360, 2006457589, 3494234126, 4211016707, 394063437,\n            478303695, 1663740923, 4189597769, 3513219426, 1690203624, 979703116, 1621868768,\n            2228302822, 3121018607, 2070777040, 474313707, 964390434, 518234662, 1967154235,\n            432133417, 2239874742, 506227550, 2595369041, 3132054150, 4015392530, 2124789290,\n            2242019286, 1230943980, 1822197331, 582857410, 467088114, 2763203421, 2466430735,\n            849450791, 2794904765, 716330682, 3722471424, 3064621482, 178439072, 1076106489,\n            1255493902, 3917320170, 2775325420, 2855363987, 685669290, 196823150, 3685244946,\n            2935338840, 829265596, 2927560277, 2456521601, 3035476472, 1916575651, 2474285543,\n            3366680049, 2128574278, 2393009544, 3953608423, 493981643, 1214878889, 257202509,\n            3778130474, 4199504317, 242866090, 2252619127, 4138049927, 4030385239, 4162976044,\n            1280543060, 1260617044, 1008504039, 3709925501, 1694820371, 2442533097, 11918615,\n            4293956227, 4190080169, 2746391848, 3308229435, 1442137248, 807093091, 985281284,\n            1518148371, 1804888998, 1246676442, 675655620, 1740021031, 764650815, 3651726177,\n            347249717, 3751262952, 694784102, 2857637502, 558672315, 2601157793, 3396384241,\n            2162573632, 897395163, 2263000949, 2774919987, 1778699084, 2752679717, 828403875,\n            2559885412, 2081134411, 4169751413, 3352276240, 3881457299, 3687951378, 19898867,\n            2166699, 3833879814, 3218939133, 2902625013, 3484366082, 2181432503, 43952774,\n            450338235, 1776381616, 490735568, 2577833147, 315569781, 2122554801, 270722497,\n            53265133, 1296347928, 2751504799, 3342962376, 2013100420, 3846129199, 826974244,\n            1897924759, 2250374413, 55771204, 3633077451, 2527289848, 1588560428, 1117045629,\n            1414486401, 3994082012, 557086011, 2556433397, 2153722700, 3903795019, 3727444931,\n            2322452789, 3928613352, 2920522258, 1686657128, 3297173360, 1258675512, 411033462,\n            705858004, 1427950666, 845484968, 551668666, 1760754031, 2141652084, 1172781772,\n            2565447550, 3711650081, 2754985880, 1911726263, 1879536444, 3692877686, 516006272,\n            908623218, 520544633, 452250976, 717464903, 1625562552, 3621918142, 3649704573,\n            1482029117, 914595761, 2087104122, 1831373821, 364342028, 116407561, 1188561625,\n            2880886054, 2465025657, 2187446613, 3422355176, 2807403544, 1444564554, 1414792151,\n            2745005767, 420342188, 1946476801, 3197369828, 1364413738, 3306383751, 4052597961,\n            2486977882, 3777196203, 3951157624, 2089986205, 2056290617, 3964313814, 3104503970,\n            3200894508, 3834525025, 3144980278, 4256976943, 4134498427, 2006863293, 608488083,\n            3110296263, 155498049, 904412641, 3635239019, 3375074997, 1222338404, 3947120331,\n            1256932920, 4132657810, 564150985, 1617956858, 1201339472, 1220575749, 490094286,\n            3105423246, 3343213749, 974372115, 1048357964, 2439210106, 4108037217, 1059634268,\n            3952116021, 1863452552, 3723374272, 108963594, 860454568, 3381052191, 1530812987,\n            2329419108, 1770864833, 765389924, 2653057283, 1742993789, 854700043, 846739047,\n            4164764289, 4199874403, 2886865990, 2991120887, 537278932, 2170375127, 1911819960,\n            277995468, 258757441, 1431722326, 945902204, 814769724, 3771460369, 224240442,\n            545100864, 1386087527, 1973344301, 1924069532, 2143144953, 434634552, 3180678556,\n            3930724305, 1974861416, 454671486, 3780535492, 2502400332, 538721058, 2822401256,\n            1725208044, 3343724393, 992347781, 3594080009, 16970441, 2776099541, 549268067,\n            1954667551, 839914759, 4178655010, 3704611183, 1510561865, 1317672183, 2885477342,\n            380275029, 3650553990, 1406141939, 2649954712, 1517007530, 451658040, 3936738689,\n            344669439, 4144471857, 468857489, 978719918, 4178163232, 3044214541, 3674634820,\n            3245678177, 1186123363, 2992277175, 1364528749, 872813725, 541724829, 1573233103,\n            3336991950, 4231101501, 3290720120, 1629177276, 1957572573, 3095857698, 2438764770,\n            3231975458, 2297545915, 2589745455, 3871200411, 4123498825, 3675131738, 1696809776,\n            3575790569, 1470722314, 2424229630, 3049512525, 2460513989, 1742213257, 2723209838,\n            3377470518, 3782709641, 3881572953, 1582733309, 194208212, 2405059621, 3256534788,\n            1909225492, 316114277, 1213788028, 4013104257, 4055930611, 2527142190, 1149210155,\n            2914605223, 852269880, 4219884239, 2870707361, 754235859, 4033614569, 3041579008,\n            1938861434, 2230963354, 2780977324, 3560811745, 1866753742, 602587560, 4003549379,\n            1577201486, 1717950809, 3391079573, 484370756, 3385285575, 2180978421, 4236884316,\n            3948675744, 2700899696, 1309604450, 2975740377, 1034625179, 2267472467, 3514149425,\n            3755469467, 3768989883, 655846446, 4063418197, 3416400770, 557815481, 982462063,\n            2392592841, 530612911, 2579137983, 2675531859, 2439972768, 4182325284, 4015840729,\n            3333485239, 852131971, 3316932240, 333573712, 3293871003, 2751603416, 1581865260,\n            3592040341, 2876257072, 610913145, 2535408995, 48474847, 3637833931, 807992384,\n            990368672, 4005491236, 1382597411, 933293375, 1357586413, 767593205, 4282780699,\n            2877597092, 3335971387, 3379740745, 4089439338, 1783444819, 1108770337, 1695533733,\n            519050238, 3387487769, 2003140754, 619802326, 1272812925, 650858527, 1921372615,\n            2313839722, 2157136205, 1842249277, 1040478662, 1589932723, 1220380321, 744387749,\n            2674026385, 1067888088, 863026613, 3848803190, 2268126617, 3048074584, 759781005,\n            4229955121, 1477420498, 1379276472, 2046283327, 2813120214, 3751122200, 4012488390,\n            1102552718, 3163046400, 2380927460, 1136445998, 440019240, 4097448192, 3309797148,\n            2093272107, 3551767615, 3494186556, 1502196889, 2716931778, 3114769267, 788478695,\n            3905035157, 1507634924, 3759022520, 3090113541, 3369949254, 1052357559, 1869089406,\n            487766368, 2365186477, 3556842411, 3757558618, 25548106, 2533975663, 3068990040,\n            2385674242, 1421310030, 2717468996, 3249780987, 1546490869, 4233142166, 258358972,\n            901763923, 4238527662, 4158111361, 299123097, 3066436922, 3607014103, 1392414106,\n            269539737, 487084561, 21148978, 322955907, 682073411, 1527919326, 501257590,\n            3450267704, 2292307642, 2183698169, 3057446174, 4191080591, 3246432, 1471477988,\n            1799426585, 579132465, 3466145207, 2440568434, 3202538202, 822683443, 1151203840,\n            1314673302, 2520542479, 2694394725, 771901393, 1405434724, 614752012, 628351575,\n            668803379, 3420735386, 786247436, 1369032643, 2080324514, 3129557875, 476843199,\n            4062668113, 3899659481, 729803722, 1481521093, 1532107033, 3303872165, 2325098620,\n            3219830419, 2656419533, 3358525939, 3458682380, 3714725363, 3434469137, 1428337086,\n            940155878, 2917585577, 2271658920, 3237667404, 2854497872, 4056209146, 2474718026,\n            3749310908, 3110447533, 1372196071, 3435236848, 250475452, 1994061343, 2026076419,\n            2957092136, 2560647358, 2509203823, 1876910657, 146921968, 975853368, 3740087298,\n            3002839117, 1075232988, 733811391, 803046553, 2454902040, 1812093967, 1090420636,\n            655996017, 3329279291, 2322947212, 748567901, 2942104676, 3465351178, 2103447107,\n            3886697892, 1027801882, 1306420829, 825207095, 244977902, 2773696851, 3093407554,\n            1227404034, 3100670380, 189857925, 1453403818, 995308018, 1749746117, 10751303,\n            1552161918, 3905605880, 3725229977, 2372356793, 1047257269, 879378463, 3736161620,\n            3396121574, 2566215211, 3603276532, 2741805686, 211564186, 3809573094, 606448183,\n            252912591, 656006076, 3951493868, 597894372, 1416628820, 3762682345, 4259857151,\n            1570072777, 3960575560, 3755031012, 1109938818, 4156979565, 341066366, 2346460362,\n            3129212455, 3854091588, 2299300661, 1218384942, 10, 10, 10, 10,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_6_fail_1() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_6_scratch_len(2)];\n    let mut out = vec![10; 34];\n    limbs_square_to_out_toom_6(&mut out, &[5; 17], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_6_fail_2() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_6_scratch_len(2)];\n    let mut out = vec![10; 35];\n    limbs_square_to_out_toom_6(&mut out, &[5; 18], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_square_to_out_toom_8() {\n    let test = |xs: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        limbs_square_basecase_helper_1(out_before, xs, out_after);\n        let mut out = out_before.to_vec();\n        let mut scratch = vec![0; limbs_square_to_out_toom_8_scratch_len(xs.len())];\n        limbs_square_to_out_toom_8(&mut out, xs, &mut scratch);\n        assert_eq!(out, out_after);\n    };\n    test(\n        &[0; 40],\n        &[10; 82],\n        &[\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10,\n        ],\n    );\n    test(\n        &[1; 40],\n        &[10; 82],\n        &[\n            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\n            25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 39, 38, 37, 36, 35, 34,\n            33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12,\n            11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 10,\n        ],\n    );\n    test(\n        &[\n            2208784279, 2917482314, 1540602536, 2403282522, 3177507876, 3568390418, 2503198964,\n            4098975582, 959428927, 1848421791, 3138244039, 1769511894, 2937718665, 2012490954,\n            3221845295, 1007046661, 2166807976, 1636825832, 1944008481, 3095709286, 3511221073,\n            1407038208, 2770922765, 161532758, 1448298614, 1265783012, 338379034, 1683441961,\n            113409617, 1323550674, 1979665089, 2291057706, 4113814820, 2714933463, 1535427301,\n            2929891523, 63992461, 3135004776, 3786738844, 2632680024, 2667412795, 1360966727,\n            3362839603, 3006655596, 3260539071, 1444145379, 3409747220, 2237275473, 3174097601,\n            716285927, 1978614968, 468942927, 1738052841, 2807377443, 2101735604, 1391753243,\n            3633841872, 3742362774, 3397153211, 2486594767, 1832858939, 32128770, 1219349803,\n            776132652, 4063064247, 3946545880, 3435957924, 1773045681, 2512572133, 2748139949,\n            413389504, 4140727133, 192234101, 1304882265, 124891939, 1568548351, 550540615,\n            184249541, 3323513356, 3451542605, 498713131, 4173565981, 2912286925, 1944682204,\n            842665901, 175934507, 339425560, 531887691, 3989856760, 573597854, 2081030961,\n            3859173697, 4194200498, 3521120776, 3645192939, 841194406, 1521764848, 409716666,\n            962456872, 4266112778, 572132898, 1259140690, 1690488098, 2391102659, 2060622378,\n            2300472459, 351585093, 1183324953, 1908841714, 3322377068, 722941835, 2830281597,\n            1004902780, 2872664652, 322537088, 1791512843, 4017515142, 2146163968, 1656233949,\n            1884364542, 306445970, 3652330492, 396065313, 3852716985, 1587730681, 3101285019,\n            3740403893, 2161419587, 510565625, 753946267, 1714965880, 3587046876, 1295766051,\n            2498965643, 1325702012, 1431647324, 901386556, 2047960754, 3487840600, 1254569117,\n            40339744, 2616107038, 547609462, 1456048961, 1597978299, 2534590699, 2623463548,\n            2924931016, 3824539980, 1241754779, 2807078816, 1959517846, 1793420648, 3099529579,\n            1245372244, 1269555469, 2704143705, 1845831862, 2005962203, 403832192, 1836487508,\n            3372628044, 4117005657, 941993979, 692771149, 1567368465, 3808788560, 3371838868,\n            1431310159, 1292752938, 4116886194, 1323248504, 117286428, 882674942, 2556580751,\n            2488476497, 3028819401, 1972752317, 3945085030, 3949512183, 1581135818, 2848525168,\n            2428342027, 3306651167, 3371724128, 3339766283, 3813913124, 119594870, 2508612847,\n            2953803757, 167008047, 1804301887, 1108240771, 4239379241, 16441896, 2455828635,\n            3537715003, 3996443808, 2554165441, 3217810817, 3794783475, 49513858, 3689899898,\n            3064356999, 3496440951, 190703695, 1892022525, 3357636682, 1349153321, 3506495030,\n            2016023232, 458032748, 2207102076, 2588320789, 2422944465, 2140461881, 3116891845,\n            2782530105, 1176015888, 4038240333, 3208025332, 2887025133, 2458309917, 864777664,\n            2993890986, 3510353851, 3084590293, 124043231, 282471342, 3117519350, 208219794,\n            1735342516, 1499437868, 3601067217, 4212801592, 2812545736, 2233658738, 3199963441,\n            2055482553, 1064371620, 3066979407, 4195062909, 3565514444, 869170992, 1788898939,\n            4005423148, 61033493, 2037097301, 1944306569, 638551846, 2868693808, 1912050866,\n            2567645011, 3935679297, 1762098685, 2905977740, 3704796792, 1754878863, 3413206511,\n            3256490941, 1428825306, 3696982563, 2917432388, 85329539, 149522635, 570541346,\n            1207356892, 3801489178, 1372575796, 3220881463, 3867113380, 3715629250, 582652775,\n            3745445916, 4145201987, 1838987939, 3758141979, 3461320697, 411322170, 3595735722,\n            920178743, 3857634522, 3825785923, 218304872, 285359422, 3948666125, 2352664389,\n            1747154882, 1730683963, 3707647324, 3956885105, 848333536, 1522849970, 1998369555,\n            3520190518, 2402642000, 3026980409, 1640122597, 792809401, 511457917, 3616835355,\n            475825290, 737294517, 4060291056, 3683165567, 548159186, 1992119560, 1865982009,\n            1723693971, 1753302493, 3381199726, 1974683508, 1890412775, 1641026925, 1334190938,\n            2660075150, 77762983, 3669872228, 1224792082, 3222400510, 3263897252, 3494238165,\n            873566153, 4204420378, 3856812948, 105989063, 562255177, 4266130916, 1113999468,\n            339584161, 1858645360, 1603041743, 2479571274, 2305399676, 2373569675, 2591079565,\n            4097288709, 3266991636, 3194187297, 997157963, 3550975070, 3843381019, 2225528660,\n            3601736403, 223505403, 3392490624, 4206434869, 3344317943, 353353783, 4167600645,\n            2808728425, 3234719428, 1677973313, 2814182812, 1212851463, 2308027233, 3187325028,\n            3226622472, 730161085, 1322467845, 2053488127, 943020033, 4154579643, 4187988361,\n            694857341, 1721301049, 2692769166, 2070754373, 2778749125, 3756217004, 372909366,\n            1434770482, 757686870, 777360411, 2237386076, 1009169518, 1144146673, 577213669,\n            644990051, 539809035, 4187893177, 2777851194, 4120194532, 2647199726, 3979704400,\n            2340413190, 3440177693, 3624877063, 4247742958, 264928947, 3675639294, 857162390,\n            3421070176, 3234981589, 3628992659, 3886434764, 231401556, 968207812, 1344218760,\n            1608404085, 2306925846, 2301608525, 2502473613, 1292114060, 3317085030, 1866696884,\n            4054098927, 2454813953, 387618240, 520675113, 4272476759, 1536834588, 1302364418,\n            866979997, 3549341801, 3225944791, 1542282645, 2653393832, 3621105792, 4272895662,\n            1077344679, 2022177778, 3153056929, 3703744756, 3833275803, 38920897, 2222405636,\n            1926157497, 556170935, 2986201658, 677131536, 375578189, 687932681, 2043149400,\n            3620892751, 2914749198, 2974027923, 2932504125, 727099747, 3649852946, 2362460848,\n            3718425209, 2628058340, 1256430718, 2281676000, 3475598187, 1375067783, 659739290,\n            2924886241, 1519085881, 2121799090, 823489777, 2761452031, 689532542, 1086988319,\n            52902115, 2429537045, 138699782, 1558366393, 3854355145, 424874583, 303611432,\n            1726717753, 2895113369, 1920908658, 3631405698, 215678476, 4175872484, 4243180164,\n            3812966673, 4182374507, 3434218291, 3346269740, 3708909697, 768625224, 2671341874,\n            1481115014, 524158027, 490851555, 2565683058, 2196003149, 2059318553, 2455186518,\n            2688273996, 3380657927, 337050138, 2208679271, 324120092, 3103851531, 3675684635,\n            1942739093, 192902782, 2181840282, 3037209091, 107748570, 1799867763, 1544470445,\n            899481557, 3574203340, 992496129, 1691306757, 594120588, 55130785, 3948236640,\n            2366017337, 2332356682, 4261339803, 3495561922, 1066889961, 2483355538, 2549105674,\n            382477549, 1684218866, 3179143300, 2115767175, 1477682777, 2404584277, 1508933427,\n            1079336347, 1260205517, 451523794, 302136644, 2205319263, 2332211187, 435482503,\n            2181643799, 861659376, 4173063642, 4177757588, 1991206489, 2126982104, 1746764084,\n            2110629749, 28755331, 274389360, 2325228784, 903173711, 2667794870, 3234841692,\n            372044653, 1101818495, 1830539842, 157622659, 2813335571, 2418219371, 1781705394,\n            3545284119, 116430215, 3917281080, 1163312583, 4077000899, 3560352603, 1529980053,\n            147658472, 2806321933, 2409294381, 1401901685, 25756065, 3235130080, 52971194,\n            3555689967, 720701685, 2753411419, 1915995649, 4084376336, 1886404857, 3282391420,\n            3689618917, 1647397786, 4253979137, 10312899, 2753539655, 1687053631, 3692805500,\n            3993614409, 3160043908, 2206895430, 3473461088, 1268398000, 4187760109, 2510114302,\n            99249479, 153265006, 1560476225, 4253804017, 4135139486, 1777500622, 1210814030,\n            2790690151, 2927531451, 3700995836, 1182346854, 3482669161, 953954861, 3201731324,\n            2502044358, 4170301767, 2241382906, 2270553989, 823184791, 86181548, 2227199159,\n            1425393472, 2002161207, 1335155557, 3722077212, 3185842059, 3361021373, 3718385416,\n            2960194495, 1410306613, 1336602151, 3868250088, 3852775200, 3671651883, 3595610890,\n            3879654447, 3740609494, 3251169960, 733009204, 2683981814, 3053043462, 2744847944,\n            3800177150, 2138411333, 4217614018, 2608312502, 2415560573, 3843669535, 1145687109,\n            673955819, 3783054822, 3577373451, 3896153086, 544023980, 1361119525, 1515635606,\n            2569181589, 1082902602, 1175605356, 11666898, 1249712808, 620029252, 4244992311,\n            3309183056, 3733927807, 3286813711, 2391137179, 1370037877, 1885533562, 1799712249,\n            3650961319, 3329689005, 1667704282, 1165070994, 666343217, 3096079301, 3335446925,\n            838739188, 2016879384, 2932687893, 2211867129, 782981385, 382783736, 2916698207,\n            2330900310, 34774866, 198258018, 440993902, 2707559911, 2705439512, 3585937910,\n            2050052686, 976019697, 4019030687, 2308424646, 2011004295, 365211687, 2445434254,\n            562670390, 148804797, 553128146, 837133067, 3912537192, 2317629340, 3035245763,\n            2380229490, 2626950229, 191274969, 2610487441, 3582910240, 3311155592, 2958867418,\n            1170213450, 1121481867, 2164744667, 855295685, 293584176, 3535547991, 896027254,\n            3151737672, 446316243, 3398926143, 1487526475, 3859821507, 3888044230, 2912541642,\n            4200996888, 1844240177, 1985758237, 2467185057, 306505837, 1618640295, 2300538248,\n            1237599289, 3252353589, 2663563949, 6609793, 1855830249, 3102008143, 843816122,\n            4244891683, 2597137034, 496037769, 598572108, 4101489775, 149332750, 2768661725,\n            3269228717, 2874201280, 635382695, 3809849274, 985790869, 3514952614, 2346966757,\n            1082306099, 2303159063, 3101682478, 622060689, 87737751, 3770334723, 1916337620,\n            198019398, 4156112198, 1971126184, 2844823044, 2231209991, 608565398, 2683168775,\n            3762824483, 282223687, 474446399, 1282650254, 783878888, 912161761, 2647590029,\n            476100694, 1833615559, 877400814, 1143318809, 1044305214, 3464407272, 1758024618,\n            3439710711, 2746979168, 4050593671, 3645248342, 3120906100, 3197909098, 108360054,\n            750307312, 4052730711, 1094680734, 3815071626, 505637591, 2194599792, 3669546981,\n            3965877294, 757706288, 1687251959, 2243209320, 610178335, 2222146034, 3066108199,\n            358065378, 3649999798, 1104042781, 1155599547, 487100701, 155435292, 3253330215,\n            309344256, 1394080536, 68067987, 3485978844, 1164779252, 64012659, 1957399785,\n            1768137866, 4111772919, 2903748276, 1997724393, 3590965606, 3351321711, 367478601,\n            2901671882, 2811175561, 1831368469, 37226423, 2549394739, 3908509004, 3441252901,\n            3368356812, 3158173106, 1982634083, 168113402, 205412531, 1757445074, 3846077342,\n            1054916653, 871505255, 950574314, 2339482640, 1810618196, 2576199998, 2228705853,\n            2039707896, 2730693829, 709433529, 3258773332, 1479501012, 4251201523, 3250056802,\n            3841243465, 467330021, 1648791516, 3860034449, 3315902346, 192703287, 1375227648,\n            157365651, 2887824516, 1199147028, 2666807397, 1864630330, 611827605, 2210095636,\n            3455555159, 2896731514, 2201913044, 2270549816, 1559846320, 2363678436, 3881266828,\n            2491558724, 2205067377, 2537764365, 1273766953, 3512578935, 2755079279, 1601988718,\n            635246697, 3339833926, 851014482, 2631169753, 3874048946, 2185188712, 1632479780,\n            1412475166, 2134443192, 3166187705, 916204599, 1740128938, 2928637868, 3729374296,\n            1941247992, 282215320, 1881961933, 3545012769, 44013821, 3462052825, 4012152566,\n            2782318148, 3325475182, 1164565687, 1426995196, 2817841661, 3382660012, 3600519598,\n            103228229, 3055674000, 894525568, 3918313708, 232222959, 2973624297, 2064371759,\n            1462237723, 4220017388, 129175762, 173476391, 3218281720, 2114599921, 2743802447,\n            2401678148, 2375230604, 728853890, 3499018139, 2251927835, 597813589, 3027094542,\n            18644508, 962718316, 653518484, 2600931635, 1751582989, 581773069, 2075127089,\n            3061492115, 291713112, 711113212, 3886411257, 145935140, 2620711838, 1463857026,\n            4009447712, 1436719717, 4113548617, 1916316479, 1459884216, 1407211063, 2411956172,\n            1620836811, 741617186, 3780170422, 718465650, 904165649, 1795800930, 2879673786,\n            3040754253, 817754274, 2477881291, 1388942998, 3164684738, 4280399147, 1010043651,\n            3720993142, 912273008, 1578944784, 390968590, 715739714, 3630234462, 3499579393,\n            120828829, 180928797, 3971313268, 109998102, 3921894457, 3239454247, 1080946542,\n            1835673541, 4212575143, 3948965153, 3799046381, 652057606, 1314740386, 4052313496,\n            3467451145, 646076896, 245129392, 3016775061, 2328785169, 960487245, 1796031809,\n            460949678, 3236903207, 1178674059, 1210665850, 1193844599, 4271374872, 567904721,\n            2025467077, 2472512897, 1859313255, 2645120321, 512119874, 4089157359, 2501339142,\n            914099863, 1411293436, 3981480830, 3778665606, 2885773596, 3571264765, 1527182779,\n            2937865021, 923962279, 1945373513, 2400145110, 3093632880, 803965487, 4259799788,\n            868852494, 523239642, 212026662, 1348277205, 2033954931, 2671853683, 2992155294,\n            2404118752, 3262441671, 2358245043, 1998726385, 1856962421, 2820111324, 3944154915,\n            967097160, 2805097360, 4033390412, 3111763238, 2237914714, 1908890884, 3455767886,\n            3896277122, 3582480465, 3866847358, 1574406586, 2972733765, 1896156916, 1258929454,\n            3805663232, 1533224016, 2929414752, 3149590529, 88187458, 2460596126, 1558314108,\n            433783522, 1630044588, 2339107597, 2798668894, 1428360625, 3557302061, 1637886616,\n            3231181211, 794089928, 2405733483, 3988234469, 2807396944, 2337372191, 4249190897,\n            3879737130, 1321256620, 1006408359, 3429892900, 3077599139, 3084526511, 2997756926,\n            2900724574, 427269455, 1580590500, 2424041645, 131659419, 2201432336, 3778030441,\n            1428304948, 829214496, 884953543, 1844095209, 733095970, 653918424, 3819676715,\n            3057668763, 3565066760, 1555388443, 2165553291, 2914622082, 2963084576, 3354717690,\n            4026182713, 143181484, 3729896588, 2688455400, 517110709, 1897690925, 3496744705,\n            2378325974, 3973997476, 4095655687, 3507137541, 1661752595, 622243029, 1830684675,\n            918924646, 1481970012, 2507864370, 2365391063, 3097880134, 3555498195, 1755254860,\n            3930383669, 847229114, 612986996, 2368763877, 1838609612, 1503917373, 3677547659,\n            1939998627, 2715845452, 465660991, 2898504512, 618023938, 2015425202, 97947889,\n            2507353594, 720170483, 1358962790, 3913982533, 2458716793, 114906654, 3999024990,\n            1602785653, 1921315674, 625011248, 2278721817, 2040412697, 2787497529, 4138485117,\n            3000743648, 3434785413, 2336734220, 364662893, 2940803710, 559551722, 1910189207,\n            903950621, 2019508009, 776406310, 3654821919, 2706405638, 357404964, 2464445130,\n            1578186555, 3263961674, 3822735326, 2528772706, 1777579469, 1337968661, 2586309509,\n            2434099989, 349193692, 4110889470, 4118137503, 849184446, 3681650163, 2550944864,\n            2813598863, 3691010755, 250045178, 3659363571, 1272113098, 3603625184, 1827553711,\n            882516419, 1684663435, 2497226884, 3732829395, 4199638565, 2824533881, 2950639217,\n            2727198684, 1403430676, 2240042622, 3910098491, 229558683, 712576203, 1103892989,\n            4229384718, 3877080792, 3381436031, 942554112, 1476033974, 2877490315, 697119873,\n            266866670, 3678113072, 1540428017, 1229779521, 2351358390, 665147347, 2304732707,\n            3094803794, 2375833352, 982432305, 2581691697, 2941803891, 3588755278, 3179495857,\n            117197450, 4088689685, 1417974990, 2897428031, 4092907174, 3531117732, 1734239461,\n            1433102123, 2281332037, 849160020, 3612140551, 3438533198, 1645435281, 181786796,\n            2890331065, 419030224, 899006549, 709350914, 3555564755, 1330179330, 4103281272,\n            124103149, 1724766869, 1457674901, 190539956, 1180447852, 587006978, 236562474,\n            4070809481, 2480018795, 1819379258, 2409296313, 3679773767, 105244242, 1570549025,\n            3922353198, 1849426002, 4264045073, 1672859272, 3551516232, 331873626, 633164225,\n            2515240316, 2312561291, 664889581, 1829614400, 2369683650, 1107401767, 572524146,\n            1597721066, 519433799, 264645, 2872957856, 2759402796, 3003957439, 748149095,\n            3188554379, 2386125323, 1849446903, 406588509, 2673520905, 3275474803, 1463555154,\n            1904755678, 418458444, 3824928632, 1032505713, 1646057065, 740076291, 2048854068,\n            2472310810, 1458805748, 3496276460, 1002901812, 4232041355, 2497927343, 1941784309,\n            2367135662, 3696245408, 1121954729, 370307920, 3418751543, 2703762668, 398632139,\n            2202769671, 1594862631, 50175652, 3250183014, 2771612032, 4107550857, 2003785814,\n            2681126737, 3046686349, 2064054562, 976129296, 2916897424, 612385634, 2124001896,\n            176317758, 120254479, 947864126, 470050807, 3705126703, 1484042456, 636896650,\n            3444011938, 1786425117, 1955911564, 904249773, 167672871, 2783985377, 1450994601,\n            767109187, 2846797806, 3598682817, 965446295, 2787946278, 3017761851, 3782717627,\n            2020641727, 3387052838, 3151721739, 416200856, 2604211199, 2221750166, 4276448083,\n            1865093279, 3323583242, 2499829337, 1472571460, 3019798861, 1619367608, 2665785104,\n            2526109781, 2415813803, 1971417217, 2168315771, 2251130193, 3074039354, 2253181775,\n            146608751, 460880302, 4202211516, 3639989754, 2207072265, 3627306367, 2838643311,\n            3143146237, 382139454, 3215955489, 3780378205, 2972372844, 2576925576, 1874035811,\n            788385224, 1047032968, 3643363543, 420139440, 4137494742, 1396832765, 1912613937,\n            80944320, 2606768003, 2865851030, 786402135, 1323826113, 2881470994, 754561541,\n            2038385795, 2239121958, 3710053237, 3157551721, 3771662576, 1982966842, 3574225739,\n            3982348487, 3458718663, 2826455911, 2269384134, 142164337, 1549195392, 1082915277,\n            1856488336, 328847100, 1212372695, 1482883066, 3110169830, 158612414, 4200770807,\n            1880462602, 3077303142, 1447950946, 2211310010, 1015183588, 1479771761, 482219684,\n            2398380946, 3929425906, 4220173591, 43108679, 678684660, 2834720733, 3145356539,\n            451572857, 680598723, 3865391278, 994603415, 3470620999, 673962053, 3910258173,\n            3199464352, 393227350, 3397874558, 3340387149, 3949796634, 382428197, 1206353417,\n            401457558, 2544516446, 574119387, 1285672394, 3583098318, 214208070, 1523936274,\n            772887512, 4171689778, 1824856913, 2413564333, 1549748904, 4152892839, 2906454732,\n            1090762117, 2431277774, 167622288, 3064847800, 1458633976, 1225335082, 3150128424,\n            2166852981, 2185899970, 660470883, 609092458, 3021517883, 1678961441, 4181857413,\n            421510420, 1317189193, 101896141, 2236582587, 1318297493, 2780205185, 2860537933,\n            3260782217, 3759404083, 1088711857, 1830654534, 2702735840, 1159987790, 1645108481,\n            4077459678, 2136247442, 3429367236, 2390409199, 2466015914, 886132397, 2524894129,\n            2614918256, 601796631, 1277092878, 874731029, 1944818692, 636784514, 2237389672,\n            4100434311, 1187262766, 4124867136, 3285614912, 1596621151, 191417416, 2841705449,\n            2146369048, 156085081, 2379446487, 3919962238, 47394345, 1263681455, 2247166294,\n            3007467768, 925438688, 2771269088, 2359016534, 5347116, 3397097254, 2464722227,\n            4071047259, 2978393992, 4145704224, 23083008, 2780252389, 155462704, 1813720213,\n            3689032388, 249602355, 2942206368, 3246481010, 3454561620, 2696971913, 3664427208,\n            1943952478, 1958985807, 984037433, 3438916415, 2082297431, 3857476934, 2627020547,\n            3393914677, 1368477057, 2474331804, 1320710005, 3432316500, 3155046413, 3435661395,\n            1632152192, 2450448357, 2279326868, 41133290, 363644754, 1292305864, 3887169714,\n            463260533, 2102068583, 3848001924, 3445460435, 639069451, 1910366283, 3511720510,\n            4011470290, 145508597, 309070081, 3904980580, 1022981671, 1802347616, 1107531687,\n            3817701828, 2186553382, 3012228893, 2787755917, 4204074545, 700721769, 3543889424,\n            60016059, 343814681, 4064758543, 1876314447, 1766656069, 852712848, 3401352430,\n            949357577, 2933534528, 984195568, 336010225, 212635917, 2418858375, 2417075801,\n            744914132, 4019136601, 3763314831, 3267744206, 3847787244, 3492644271, 77063559,\n            1866482909, 1725523753, 1855513878, 1470420975, 1568979853, 452303744, 648129746,\n            3902833876, 3465479188, 2549697000, 3915943704, 1102256431, 1139532367, 247124117,\n            3441162879, 2715413814, 3499085014, 3245161538, 3046164381, 1537664764, 781373547,\n            1159401544, 1138886841, 3162893383, 43768212, 1711332912, 3478794404, 2932562276,\n            1079826421, 3097209204, 1971142968, 50490582, 2344975517, 3888627052, 751440299,\n            1898349657, 3464659774, 1965725622, 1079219945, 3424011904, 2557910409, 3450709268,\n            1062763619, 3688932453, 546866669, 79147227, 2766016743, 2252593348, 2201723140,\n            783925597, 1229604025, 2184234813, 2900491613, 1002742679, 4193477090, 430653153,\n            1632649591, 4161092195, 3036650674, 1023958621, 2483714092, 4294524978, 2519716129,\n            2644830451, 3402354736, 4166319894, 1032140134, 2396318776, 3541228906, 397434479,\n            1435711167, 3172127057, 429665541, 2065172821, 2229977019, 3280825368, 2396499440,\n            4163140945, 2343456276, 2432733775, 3593240190, 3414363239, 175709404, 830386589,\n            1936417183, 3334463782, 3832048307, 2307093741, 507837791, 3350977711, 1165253221,\n            2942233360, 3647952216, 2842899964, 1813748197, 1562321857, 3915134801, 3503984227,\n            2067794634, 732362852, 3193139406, 4008764521, 3894497800, 4199555310, 2589913497,\n            2245388630, 2957719900, 724500531, 2420582759, 1987894074, 350967036, 290813050,\n            921507662, 2486129274, 992387594, 551956194, 1387588925, 1754338721, 130413781,\n            1369204550, 1835887875, 1256533652, 1546491662, 821411390, 2794985674, 3358733394,\n            3653274779, 2038598923, 95611052, 1732138892, 461928438, 986541664, 4099947837,\n            1889842213, 2525639306, 410533753, 1020900093, 3907577771, 1253677383, 626473519,\n            2464700888, 3377897813, 2093475677, 3479272206, 1515697283, 166456980, 3807925827,\n            2010002696, 2930902489, 3043122535, 3107114262, 2626168668, 2609077643, 3241374507,\n            3741650446, 957357299, 1728065297, 3993409525, 4274739848, 2218816574, 3813136883,\n            4034994558, 2639521692, 2117610693, 860767662, 709933672, 1670082568, 4218493868,\n            3830520118, 1637803926, 2614804513, 280768175, 1417538952, 1044920114, 811213049,\n            877310835, 1302883537, 3390509745, 2827927128, 2303069038, 3478272008, 297811903,\n            2238230110, 2616176401, 1950813104, 2734814660, 15758437, 3321564684, 1647322961,\n            2356650769, 3865305266, 1010959276, 1021614176, 2458785165, 3153785427, 1647369146,\n            4257820945, 409092029, 2992708858, 1179414539, 1693001075, 2378421109, 4032223339,\n            1549509056, 3662410899, 3731075771, 2226257702, 854739192, 2333168376, 3831123162,\n            672459584, 2105255949, 3941486408, 3063931623, 3785513419, 2454733900, 2814451407,\n            149252521, 3850018836, 2493517320, 445200997, 3777868852, 753763226, 4021231089,\n            1034604267, 2132847427, 3137530222, 1444528826, 1568377846, 4174881449, 1688659572,\n            1734424123, 4003363111, 706779272, 2717570473, 971914323, 1469697660, 1589458359,\n            3876467411, 3555382477, 4094407876, 3045207290, 3971347263, 1446967667, 333138153,\n            2498108121, 934242766, 1394602728,\n        ],\n        &[10; 3636],\n        &[\n            1689479953, 3685371534, 4033111375, 2546236409, 1992526355, 3704353609, 2980686246,\n            1962205010, 493853510, 3330949079, 3404775486, 995963370, 2359476618, 4166337269,\n            4122885245, 3807397862, 254950871, 939656465, 1152901624, 4053891363, 403489740,\n            1785761074, 1668697582, 2067302399, 41387989, 2253039569, 3927766471, 1431410460,\n            3833461627, 415336119, 3883105936, 2410940587, 2653928229, 995634000, 2858992119,\n            2988806752, 1188927329, 771118054, 2195745265, 108976395, 845032275, 2069454932,\n            3471071335, 2060102913, 3228691171, 2308719511, 2945302523, 1820942245, 316675140,\n            1150419465, 1211232052, 1158444240, 3173670921, 1686034098, 2456947982, 2848533978,\n            1479222291, 690366707, 3370078179, 2770865607, 1233532402, 153836862, 1806019361,\n            3091045128, 874731740, 2993354220, 1266470867, 3613083638, 2885315914, 3242335441,\n            1125608752, 3515334805, 314144256, 2337633870, 1854926272, 3312630344, 3265619517,\n            3610666982, 702111969, 515972312, 4053141872, 3622471868, 809790617, 892763171,\n            2910876060, 3440091579, 4234874023, 2764367458, 3136920824, 3494605116, 1982819561,\n            167177314, 2241971921, 3887514525, 698132290, 1490198321, 3652759059, 1621787049,\n            722771688, 3595184214, 2564985420, 1178669595, 3937546813, 3317244391, 2122523467,\n            2946067119, 2189818336, 2902163966, 1141546340, 254808090, 1955202257, 951810816,\n            4081592658, 2909053488, 3208529775, 3841938874, 1497747485, 349952546, 4157578435,\n            61619680, 3889423462, 2187522521, 1198768122, 1194160079, 1050136991, 756692966,\n            1195586963, 3211099388, 1912062610, 3622069566, 2897159796, 948263532, 1532710538,\n            1802135919, 3533830169, 3856207252, 197515290, 3506670317, 1620700477, 2256517135,\n            4154090467, 3594024579, 3262925099, 3254169581, 1699842655, 847331989, 3409717419,\n            1352842262, 2828082947, 1965631295, 3273595500, 2243530439, 2938559397, 2810391252,\n            2010423336, 2002052643, 757086441, 1620578432, 3426231828, 2007498669, 2398908899,\n            115544526, 3067012604, 2668057303, 2793223364, 1743336418, 3982673394, 1654091471,\n            576892166, 4157782674, 3462254224, 2284093351, 1399551134, 1036325351, 1731219496,\n            4168117172, 272151080, 612943017, 2192619260, 115775515, 92983999, 379551810,\n            3661451825, 2769027885, 905651037, 699519503, 61886171, 2966524714, 3201099618,\n            4198150790, 594005019, 2773210292, 3469678241, 2518165259, 3302956992, 4272562297,\n            3020363744, 3447097873, 351941971, 2781830337, 2374469323, 747786029, 3875756236,\n            3399944941, 1495211859, 210486031, 2758232522, 3380808106, 3498738899, 2780757169,\n            938777406, 1214252733, 1227336750, 1193339709, 1969983025, 2158100324, 3857354319,\n            1221730229, 1794819479, 3127680485, 1905497414, 4149231578, 3615970206, 2281482001,\n            1534088517, 541767496, 3126249491, 2888409452, 1068848373, 3120384427, 2541336983,\n            4129074361, 2159428870, 3946301876, 800764413, 3715235528, 3158825006, 1025161030,\n            231986559, 951077055, 2322136482, 4286048902, 1344763649, 3892401771, 2025457891,\n            944503280, 1558437118, 3650522151, 1919645785, 1530516973, 943007339, 2450980377,\n            4041919084, 1088539733, 2757862394, 992606829, 3041819168, 1614960401, 2279582969,\n            3075199231, 129454288, 846208986, 1234625046, 660809146, 3532880429, 252628601,\n            2423696271, 1858298031, 1388778105, 3504842644, 2733630767, 2248186669, 2239896138,\n            3099657735, 190376317, 4060941430, 1245037447, 1858363105, 3374140310, 2013206587,\n            3277964190, 2584841377, 424320173, 688240262, 765738214, 2152654415, 3604646242,\n            1167364606, 3139180609, 305962507, 3278904226, 2216417259, 1732931020, 1815790309,\n            522130889, 1446263974, 2636689241, 3735678668, 41392474, 2958898515, 2132044035,\n            3992828420, 1869274208, 2235893947, 2933194004, 1650239327, 2431660513, 1569791435,\n            1682334612, 990651015, 710574561, 2273823059, 1278475386, 2434675573, 3396438082,\n            1775365481, 3610889176, 960217185, 3558882767, 1818298153, 1114764111, 3174946022,\n            3276125305, 3434492342, 943048667, 2085491824, 746060159, 1932047283, 3794215547,\n            382927920, 1986062285, 611246559, 66218118, 4123379197, 561468147, 3984284657,\n            1009668765, 1318100633, 72107280, 2189759123, 613019399, 2695021240, 3203675755,\n            1043143343, 2525551493, 3793021769, 2060684945, 4271593290, 3787213308, 1409675772,\n            2088988330, 2709094673, 1745553143, 4134186269, 2966553782, 4248927999, 1415462585,\n            2077903946, 2170555889, 2284763394, 376804117, 2120600961, 1547223081, 3156360969,\n            3506247528, 3974314253, 82614436, 686791205, 998502952, 1752036701, 3387012871,\n            3021091285, 1846925484, 1523652509, 3709746915, 2156518023, 4199210449, 3018517467,\n            3546322968, 2248925146, 4043448871, 2088132192, 4042743708, 2996208097, 1121252975,\n            2022549993, 599051074, 1226341730, 266614051, 2143284540, 312560684, 2415441639,\n            424050386, 2720730533, 4139901252, 1291360004, 1202626490, 2954417424, 2821034122,\n            4212158671, 879484766, 4183448049, 2249422276, 3280998954, 92143606, 832623402,\n            3621294127, 2830388417, 3639209588, 4207096570, 1284153145, 3905456885, 1714211191,\n            914899411, 538466307, 635569437, 3891116773, 163323364, 1443353015, 735796114,\n            3567232355, 2369238294, 1560517720, 457709958, 3903751547, 974724114, 3067312154,\n            2697003909, 893782473, 3275415433, 1926375676, 1626637046, 1639093142, 2020991854,\n            986443050, 3524164386, 1986151996, 3200666719, 3678890297, 2645218461, 1681120796,\n            1595373268, 4285950338, 2565021869, 1025685298, 2842355440, 1423518737, 3577876446,\n            346787895, 3712464676, 1393634876, 135728953, 515475296, 4013218269, 492697456,\n            3573383387, 3814290175, 138834790, 771401067, 2293921802, 2903029034, 1412060797,\n            4271694554, 3397814298, 3382109865, 2910052910, 3675314680, 920791699, 219901661,\n            3100824534, 447921565, 2555613265, 1717732013, 1726129496, 3868656814, 4087551693,\n            3280000582, 566705240, 276475299, 3143437043, 1070688008, 3820602685, 579353003,\n            56781749, 4107744534, 321202401, 2610178709, 369557547, 791953613, 3340350862,\n            213738916, 1313095032, 2358306826, 3404845027, 2499456597, 3975781611, 3019341016,\n            1359848152, 3377984398, 807849168, 3592392188, 3625287916, 3896010427, 68914522,\n            2666916100, 1398306734, 3664389462, 2285977204, 1937090277, 3769043620, 2944706208,\n            1368976735, 2929039409, 3409690847, 2466270671, 2109122630, 3689958538, 2822571144,\n            2389696162, 389660314, 1022111843, 3326801528, 1922845276, 4040134641, 1089319195,\n            642426100, 2230567323, 1010953440, 40342353, 3717399643, 3642971273, 264568430,\n            2735055235, 2169228130, 349336330, 4038959286, 3893956178, 1541518205, 846168460,\n            215763475, 2966198792, 3823464051, 2357808617, 3733849808, 2829298148, 2818349331,\n            23548460, 3908373916, 737793651, 1252570487, 4227353578, 575916627, 335142225,\n            1949576824, 2910716359, 1162643743, 1301629052, 1470679705, 2581073585, 3946593246,\n            2636260076, 1145193195, 2536915898, 2181940804, 387671990, 2198865228, 2889254819,\n            3694401161, 3743697870, 3702393901, 3877656850, 436292574, 306499740, 1932066477,\n            1222907338, 777997962, 767846189, 3422304245, 2654237098, 1691890450, 1423805919,\n            2793155311, 969086158, 608867030, 723940812, 3829434904, 3698741440, 2198252225,\n            1073862189, 1870233325, 2945313240, 1713253401, 4266219011, 62006678, 3380440119,\n            2081143161, 2628825197, 3885535614, 33965352, 3211652782, 723727386, 3132341601,\n            1177495474, 4160229077, 3186357631, 1602138390, 2075192637, 772617785, 880291822,\n            2049877410, 1168560536, 1609804482, 3208323270, 1738061301, 1986167645, 1282687244,\n            1590039983, 1369825018, 1581183582, 3791409534, 626070490, 2835186285, 1167323511,\n            2362699417, 1906302864, 3875076978, 1811254861, 1952540063, 4077593108, 2066119832,\n            1234760656, 3819355313, 2496855793, 817790761, 1323251498, 4242582140, 2811911460,\n            597309051, 2667324841, 480387058, 1864617722, 171377032, 391867307, 240309613,\n            434543863, 3720669009, 2315945600, 1155720023, 2324747354, 3593519746, 1978174723,\n            1632551714, 560466621, 2369939811, 3838110393, 1895556248, 2334676543, 3860877002,\n            4084080183, 1653427618, 2333288623, 434060673, 1950369077, 2094498326, 2403598111,\n            3319240198, 3128867376, 93575480, 1448414395, 61831623, 1707790840, 3582728318,\n            2433330126, 3121590541, 3776124939, 4042319150, 860209440, 2067934458, 1267323322,\n            3477945458, 341210736, 2636499778, 1442791938, 1030739190, 4172051003, 591312878,\n            2535261077, 1363492883, 1946779052, 2538938847, 806269788, 2170457601, 4068920607,\n            1113820442, 1320778728, 1711984915, 2844848911, 2121794146, 2093321164, 1354948731,\n            2834137272, 3168927696, 1582827389, 3417750246, 2715721587, 336975965, 53775112,\n            296809315, 1422886644, 267088944, 441826151, 1595155088, 189084532, 2007261753,\n            2011435517, 2752974820, 3611356593, 1075874443, 609678245, 1508842188, 2860450500,\n            4251587252, 1243206835, 1385789599, 717247823, 1660282032, 423844602, 629857559,\n            1032304057, 3264912268, 16784015, 1007967185, 219409269, 1854277819, 3855877583,\n            3774618047, 2594977894, 1582081213, 1323306622, 3159925504, 4059130427, 3482011214,\n            361232698, 3721986714, 173607136, 2826556138, 3232270031, 263556241, 3189969290,\n            2471918738, 4260558075, 2670248989, 3126116667, 2556499473, 2606829010, 2951541343,\n            3310065835, 2459916580, 3048829171, 3883857465, 3488692503, 4202189598, 3948941477,\n            3228702107, 1178612117, 2586525147, 3286061921, 3391923513, 2521167873, 3172508572,\n            2299431200, 2075951247, 679350794, 1833191229, 3832233440, 2606213209, 2307374344,\n            157066023, 57454904, 1555904572, 874755295, 4193506986, 3776330617, 659313975,\n            2884022987, 926134856, 407007539, 2667604746, 4144959214, 2353533390, 3651735332,\n            3912622595, 783871727, 334008272, 1596551186, 328725723, 2017002333, 2813759025,\n            479384045, 1094205407, 3460645745, 2176695263, 2031169958, 3700887403, 570794101,\n            3329978579, 442193859, 177510695, 1246907927, 4211920294, 1439116362, 644614459,\n            1370218689, 3223269073, 1540383943, 851059080, 291617017, 249987291, 646227661,\n            1999413406, 396901401, 1158325017, 2173115664, 3094509081, 2284452007, 4011870978,\n            2580272312, 2125495977, 160998839, 4038294532, 4068915708, 4008489801, 3818160950,\n            2037081837, 1897458323, 74048804, 3298940335, 2453262946, 1170804052, 3729599052,\n            793866416, 1505433495, 3210217092, 1289767743, 2427482247, 1699914534, 2309140705,\n            1392709958, 2271028884, 2975454449, 2303695092, 1947549722, 2585331171, 1564261943,\n            3122141591, 1117882323, 3823838139, 1951127733, 2618650885, 725855784, 2885778001,\n            141631296, 1012437015, 3106878342, 3734126487, 2691077783, 2708310422, 1642521959,\n            363727910, 4162659544, 3295064194, 3989870957, 2348205117, 1410306408, 3403760692,\n            2133115242, 4201323221, 223129633, 4186689976, 2783741890, 3455737161, 652143453,\n            99216126, 466125887, 3111207944, 1831061873, 4215377421, 2860354741, 2032120457,\n            209951559, 2877151846, 2610955998, 2615971729, 1820149219, 1121448703, 3918557321,\n            4145726816, 250069769, 3601824251, 2425899740, 3159017099, 2088565383, 3107254419,\n            2360222345, 3119803151, 1060116494, 2397044160, 2022997879, 4037538002, 1667834405,\n            1983034038, 3079880508, 3324007826, 246650870, 1806445885, 382011810, 4196153678,\n            2707808626, 778105883, 277293813, 405037737, 2480851369, 520365878, 383090558,\n            1859659831, 2963694384, 2519087750, 4129026943, 2887796997, 3441456932, 681605695,\n            1935908051, 4082578667, 501692944, 2586554895, 969054976, 2643666108, 3192695444,\n            3537481024, 2027791375, 3156926222, 168581455, 2498413755, 2770043936, 1779891884,\n            4038975619, 3190035594, 3462597430, 1234455375, 4098697148, 834062881, 2753543726,\n            3044846390, 2179394097, 2460818962, 374817783, 2045460491, 1618837806, 3157089736,\n            274826574, 3757185257, 811521100, 11813727, 3779922725, 492684396, 3015056497,\n            2034583118, 2565777608, 2984428118, 1632112099, 4257294791, 3625499529, 3474533559,\n            466664110, 3206241640, 288166232, 671449910, 444797800, 4291439428, 3723150568,\n            1037922235, 1442984940, 1000292861, 3436107318, 2679137855, 3383334735, 2520302591,\n            1609273129, 2857914655, 978670894, 2845899315, 2388419165, 3580281943, 3417091255,\n            2409469498, 3975334897, 2759245997, 3194255054, 1797141666, 3252922278, 1354355931,\n            2660605803, 1213536930, 3994236234, 2937076377, 2937610964, 1076596335, 437925456,\n            3125544050, 3937749237, 3409723728, 2799028557, 4196003, 3832449641, 114765079,\n            3320248373, 3459233935, 2315620109, 2438628570, 1986417128, 2743347404, 1544655871,\n            2977042407, 1084572644, 2021448125, 3614331394, 1046031004, 970111583, 2171915217,\n            527339301, 3762746313, 783974921, 223854801, 567316104, 294880921, 2149052493,\n            245390330, 2278660889, 687725930, 551762183, 2317545332, 3219299323, 2918212026,\n            1649523093, 1507822979, 4081404014, 3334156272, 2129074111, 3087309631, 4089663886,\n            2072999253, 454289181, 1637178038, 3176235130, 983793591, 2442522220, 1799416024,\n            517489419, 2468868262, 621903281, 3945097547, 2836978758, 3201503255, 1258516991,\n            2861695304, 1209464854, 2422574488, 3671154363, 2543876385, 4189253095, 3365633529,\n            840184461, 3655439800, 3981292932, 995972756, 2179662181, 1498227827, 1365764941,\n            2539583345, 987266807, 951279142, 2690569250, 836866894, 2803186995, 3142361029,\n            2480108172, 322063224, 138513086, 3307682392, 210064865, 4004572151, 3914740899,\n            1902475798, 2444675151, 786777820, 3891858223, 46833343, 867537823, 4032212075,\n            3864493779, 2274176340, 4269403709, 1664272702, 3148987672, 211515203, 3213183135,\n            1064477451, 1886619939, 119907588, 1763695580, 1137788010, 1070848636, 2380340717,\n            2008753869, 2243310038, 2254452168, 420507278, 4238737558, 476544486, 1027946082,\n            4098497244, 2987773020, 2594971986, 3933543751, 4128433629, 3220979532, 2943736716,\n            369135285, 255363967, 1484001861, 744498182, 1782217456, 1337148224, 4036991417,\n            743169988, 1309721404, 2273491320, 2123096396, 2137418246, 1197976413, 487719177,\n            3486628676, 1740236865, 293554311, 1241237266, 242071315, 1022831640, 3704597480,\n            2429997384, 432113667, 82097287, 2254662456, 3940734887, 3475591576, 3137105254,\n            3991358983, 490002339, 3684106298, 3520847937, 3051366766, 180168041, 1519172738,\n            1779013739, 390964089, 3977190717, 1798884350, 3452012853, 3032553213, 987642496,\n            2451677707, 2708299902, 3475129220, 2702396337, 2316707082, 4120730953, 3827302854,\n            720672011, 3059924458, 1611668599, 4271987380, 3334962081, 2845220490, 2288381264,\n            1774544509, 2351525548, 2897807760, 973879886, 713264799, 3283893303, 1318656705,\n            291934618, 3603245708, 1822680205, 702162980, 209419299, 4141222812, 750506921,\n            4172646803, 3751702496, 2302071777, 2134343419, 481830090, 297394254, 2268030553,\n            4250599826, 2400026812, 3848063806, 98645017, 1905605167, 1656848264, 3635405750,\n            1349007121, 3665147685, 616196239, 2465135417, 2962732899, 1864187602, 2718887139,\n            16886570, 2246634204, 3326512044, 2571667935, 1160007357, 3071223515, 3246054390,\n            998465839, 1629678212, 101861913, 2984807746, 2495017805, 3497256251, 3199319442,\n            1125347888, 1360242257, 4167976807, 498743683, 4026681588, 2973980091, 2236624635,\n            828852129, 1294447829, 2231113860, 4032820622, 2477494850, 51373745, 2077300376,\n            1228698983, 602193592, 1080190881, 2341885886, 3252125538, 3698523622, 3197797056,\n            3887445074, 1816709009, 603827916, 3131542078, 2445055597, 2747259926, 2674003923,\n            404166043, 1258415914, 4081926360, 3708672880, 1307270581, 130515698, 1232689370,\n            844184447, 2125229292, 811439099, 2381195141, 606058317, 1595640123, 2873016787,\n            2288347624, 1768267576, 1140986292, 2806921510, 2330260149, 3555319291, 1040154033,\n            4071652159, 3667323109, 3843957045, 3629965830, 3425297516, 4011060252, 1428220755,\n            2395447002, 4148749813, 976260738, 4045911573, 3768993353, 1566874554, 790487894,\n            422535921, 3633624722, 3084935659, 3530348184, 1522858025, 3930970317, 757456642,\n            2764125394, 1271606702, 2043643656, 4167445856, 2875300050, 2334977507, 3666063607,\n            2062225439, 3415997854, 2570087929, 1872393864, 3058937106, 1478242396, 3311261031,\n            3327328058, 2968064976, 2027315412, 3051301341, 4240853773, 3721533880, 3417998346,\n            3256497279, 4105998587, 2801629523, 3816575480, 2097322942, 1877201309, 1423279412,\n            2966108575, 2707662913, 2208951536, 3155700397, 920421538, 2474155241, 282129529,\n            246270957, 2942900650, 2382865603, 145426821, 4026932016, 2119600746, 4115426848,\n            2451802377, 1795129560, 1857644645, 1363053522, 934343575, 1607399511, 3837946432,\n            1661942208, 2460809148, 146081762, 539145451, 3994413144, 1186020281, 3746267118,\n            791874622, 116689076, 1678197037, 1081204606, 802674785, 1821529384, 1599874656,\n            642992505, 3828343440, 118250081, 1547197371, 300482688, 3498923598, 2024147409,\n            2225551926, 2784186719, 3590853554, 2444211159, 1910708895, 3328161159, 2960509663,\n            261693067, 659391140, 1477907049, 2475545284, 609125167, 3708576651, 128566817,\n            2700022256, 3772319662, 3205402417, 607867778, 35765470, 3664750492, 923160230,\n            3512625207, 1526189031, 630567214, 312225845, 2863233060, 1454918057, 1836229030,\n            2263747440, 4220210180, 4041495293, 2286442296, 3297704827, 3681472880, 2571651409,\n            1231492678, 3310495257, 1759963235, 2017102488, 483028560, 3477067958, 3779556007,\n            1037991751, 1488253132, 1626120205, 3965838232, 642076510, 2772001672, 3352907626,\n            967946209, 1329426959, 904407395, 4287761476, 2117807348, 346501549, 2017467790,\n            1712248496, 3090003832, 2740727976, 1175602056, 2704116504, 2228546392, 2001963876,\n            2829399891, 3218378007, 4231063139, 243022702, 3241631802, 4189274453, 3803958756,\n            3576735623, 1917548369, 1025900170, 4123245418, 2265346420, 3936555459, 3498521772,\n            1479507035, 868619187, 1142241680, 3097571890, 1349848159, 2065481968, 375485612,\n            1631946130, 6606562, 274275763, 49667592, 1487086660, 1845842391, 2357242575,\n            467259241, 125869839, 559708189, 291488197, 770373353, 825488061, 528595254,\n            2517694918, 3884661747, 1797499647, 1057298306, 3983764498, 805346698, 3058617732,\n            249320339, 515324764, 2612033966, 627814198, 2366225823, 1276656413, 1249673518,\n            766412003, 1663221119, 4155392841, 3942002780, 2097042486, 3123053624, 3954336954,\n            3252770750, 2974430297, 1960686632, 3790329968, 1997188153, 1998914803, 2594873727,\n            2693091253, 1227140324, 1213873209, 1651729488, 350449328, 947558271, 2419068624,\n            2391366241, 4275323171, 1609113602, 2823728377, 66529505, 744148532, 1609823852,\n            1906921648, 2271564188, 4186254187, 1178040066, 4023115514, 1305792228, 1690613212,\n            3458113244, 496460370, 2618476375, 1190544066, 2176560202, 2276473837, 2522161430,\n            2610000464, 440518595, 1001658010, 3324204442, 1263928225, 1485293695, 3446137087,\n            3909570758, 2127019243, 3695260755, 3359349906, 3141098292, 2541398172, 3575448726,\n            3222721978, 165253206, 3135199663, 460110423, 2385179813, 1631504080, 517516259,\n            1564055745, 486059524, 1418925436, 3059270125, 3210293303, 414855607, 4202927121,\n            3837221574, 533361178, 2712745385, 3290088534, 948639616, 298484197, 926218206,\n            1442074810, 1064020282, 642968472, 2908976133, 92856881, 3867366389, 2363221869,\n            4054296546, 2589468845, 1187867253, 2760375067, 3885177157, 2053648391, 4117621494,\n            3080758166, 2690978782, 901728841, 3281893688, 4227520312, 3812007653, 578797819,\n            1029878447, 2914247689, 886586584, 1248147975, 4210992818, 561199869, 3270867934,\n            308839339, 3895262405, 192385229, 3772159951, 3396462893, 2514226586, 4185157789,\n            2022448536, 2514786928, 1848675048, 3597534632, 3386922450, 1443705113, 274003774,\n            3803570996, 3529374128, 2618211788, 2553692266, 3226363672, 826462207, 2780892770,\n            102431722, 4108068467, 1514449499, 16916063, 790468106, 737455902, 388909337,\n            1060871246, 1980294792, 4020694397, 3421707652, 3558247153, 3868241436, 3650372822,\n            454870313, 3190861269, 1121056466, 2160709840, 1487447127, 531375459, 4006552618,\n            1367526003, 2049953384, 4242984695, 591782438, 3620499955, 3484689592, 3195066728,\n            2227109051, 2224733666, 3064559967, 1002850564, 1741551474, 200038933, 236231763,\n            241608448, 1125647989, 1733945828, 2748977838, 4245341740, 3973165452, 3692968986,\n            266033770, 4031581082, 4176579206, 4176011405, 1635921130, 4246049839, 1378901965,\n            2582237341, 3897386600, 2020921730, 3812280911, 4112479160, 2965028984, 4270899054,\n            1144134566, 1030809753, 103237802, 1976575698, 3291391509, 3987713093, 1752261770,\n            1224606301, 3019364112, 1594514740, 1846241836, 3520740283, 1106436435, 3762747664,\n            1664894769, 3202570996, 2736584864, 4065973429, 1497702943, 460904489, 3419319493,\n            3663664671, 157299306, 294467156, 3053318226, 1954453123, 2902024272, 3954099364,\n            1435891455, 1200952825, 462363771, 4072271634, 2320864436, 213783610, 719834276,\n            2353049209, 2385102228, 3689591523, 1668822365, 3862038087, 3226479764, 150925708,\n            1404619162, 3258264053, 1333417229, 1578105238, 233886220, 2959191636, 624793378,\n            1747005891, 3014971815, 2772914499, 3582324477, 1698139368, 4135587991, 468564861,\n            3469855870, 3840371606, 3368607970, 81247725, 2513246148, 1908078625, 3543563617,\n            2845092613, 2537091921, 3281313322, 1164265431, 810332022, 2955114644, 62816586,\n            2792318884, 2636062838, 935519120, 686525478, 1240254896, 2820221328, 3668051423,\n            2047287614, 747732773, 977739916, 3119771059, 3438223878, 2110947565, 2295365445,\n            3700651115, 1594930835, 1326328115, 3522403990, 1581047373, 3642258254, 3643833459,\n            1442203680, 3985817160, 3359497845, 3567742088, 2703933881, 3286503035, 2716577830,\n            2455212492, 2944340719, 1744687635, 4201727787, 746359664, 2309400684, 1443319803,\n            2822497091, 3952225358, 1266751291, 1552262601, 2664857167, 738558864, 918193930,\n            3233432628, 3883227720, 408624322, 4224897587, 2920895445, 3574204814, 60481955,\n            1557884522, 1756716917, 916909101, 3661455996, 2861736733, 1335145748, 3162280916,\n            84878597, 3775068288, 1369947025, 1105445783, 3133745215, 3118158526, 1219630817,\n            409706604, 101744074, 1974571608, 3991681153, 608799768, 2425583796, 3121594464,\n            2868366050, 1290542011, 3826018622, 1052859250, 346669398, 3252761547, 1752812895,\n            2116190764, 1368270810, 809767833, 907751840, 3235605061, 3921003263, 2785209237,\n            3472207248, 4282859029, 444948076, 2309068816, 47377213, 55235131, 4151310506,\n            797428759, 1280116312, 3949643772, 1523687038, 502974093, 1374335610, 2016063664,\n            672538456, 3855027382, 2642939730, 3920110085, 1431378911, 3182719501, 3226314076,\n            3550233008, 2843936526, 1844531037, 1461312622, 1341306514, 1735290609, 2395141662,\n            74650360, 2213667353, 2372419588, 2514285293, 4165332515, 1069041235, 18240510,\n            3009105031, 4247238665, 1358739270, 3742754122, 3101555340, 3257719306, 3973455129,\n            3763335030, 496222953, 2931805409, 584178382, 4205230521, 2406412778, 543292816,\n            1556087588, 91201694, 1004907209, 3998304829, 2669022995, 1024110775, 855737062,\n            2934693606, 4086665390, 217474758, 4185692391, 3630606523, 4260974327, 1064624969,\n            3979549033, 4117631371, 2560854802, 1873572115, 3477939028, 84454657, 4158311865,\n            947577724, 1981667660, 954073202, 2530779598, 1906604658, 2581265848, 161799394,\n            2539843422, 3374973153, 3281766109, 2708538328, 2496184317, 946045554, 3923271365,\n            3003624942, 44367286, 526430955, 2379276524, 2628065138, 2054070052, 2835653082,\n            2408767093, 2200542235, 3133166590, 3103533911, 1618827108, 2337578618, 554779330,\n            1877587927, 805925111, 4083532900, 4119063607, 4094145462, 3800247708, 3097776190,\n            3828122568, 328856056, 2087701413, 3507308880, 3295544625, 2558779233, 2415437903,\n            2734011836, 2482408771, 1446479447, 561714919, 101350506, 3868078636, 1939417956,\n            3724743531, 502213291, 321477517, 1091134027, 1374936116, 2601120184, 1082085776,\n            2218405402, 2593749478, 4014470084, 2547858922, 3945522028, 1789900808, 1309653762,\n            698211039, 4262093683, 2994540354, 2932194625, 2512009314, 3516090705, 3433773106,\n            765214719, 3954254778, 4274743875, 2586062537, 48725311, 2318175537, 2966026065,\n            1998156091, 3604337015, 2589164236, 1479833572, 1276704396, 1558933223, 1777724570,\n            1464319686, 1618776366, 3178012457, 1491987603, 2036107848, 3479801899, 569571166,\n            74211236, 660351793, 551899518, 63632211, 1650073300, 3835378904, 591005946,\n            3671060744, 2108971615, 3896431581, 2167756512, 689307396, 52941191, 1798314696,\n            113046222, 3990303672, 296491437, 1136355576, 2802375123, 926185509, 3119566734,\n            48260029, 3353012417, 1055524799, 1094796423, 2464468009, 3005975624, 777936673,\n            2851287717, 2025527642, 1589454470, 473046103, 4291371754, 1411361884, 3136946679,\n            1752457439, 2406543962, 3782736499, 173562397, 1135476471, 3417785482, 1913281654,\n            2004058482, 854085513, 2274358926, 2006316150, 845969262, 1363650305, 767423334,\n            4219043013, 2108203495, 1391321388, 92614808, 2638397579, 1625105828, 3199303404,\n            424744970, 4055540445, 1950463844, 1615106969, 3594450298, 2160514369, 3287049922,\n            549721170, 2819316519, 700345342, 1829032754, 3909073800, 843756052, 3943348323,\n            1182935117, 952651084, 2244934408, 2200348674, 1977011522, 2444186657, 2142916255,\n            2147345310, 2434135627, 3052046286, 2254117922, 1822579677, 1567825379, 1919065971,\n            349114077, 113358004, 609194458, 138808635, 1995061228, 1302815309, 2878779823,\n            3415266902, 2869660799, 1016025931, 3335856096, 883527774, 409652170, 4203782183,\n            1855526550, 40212257, 3525134238, 3678763465, 74131589, 3826372638, 3970369882,\n            3482037176, 4179430299, 965319189, 394262916, 2462172558, 3925263781, 4133777999,\n            3188738267, 587031879, 3454471188, 3982289199, 440544328, 476792674, 3345660659,\n            1895005972, 2053792458, 4134858390, 2429890414, 3304083305, 2392604182, 3395163690,\n            2605833369, 1666281741, 3228552126, 3979068584, 2527460000, 2347138934, 3123976326,\n            846077745, 1878780364, 3265560682, 1403833441, 890912218, 1380482915, 2465711556,\n            3647092006, 3370796849, 4236615940, 3586267443, 373728198, 5731137, 1243905856,\n            3470858780, 2796818161, 1238908162, 1584148758, 221770729, 3700200051, 1499779925,\n            3117049016, 2327976210, 4136532828, 965956791, 1680323133, 3215683204, 2178759560,\n            1732184813, 2755885165, 3823403799, 1902450762, 456020793, 3663422204, 3811589041,\n            1857954995, 2771097813, 177543012, 2569158780, 3708456423, 2528175033, 2080927043,\n            3680699272, 4023854803, 3809799093, 2371544632, 198202999, 1497390699, 890250824,\n            2769881560, 3194865750, 1684145181, 452145694, 2991889421, 4144843353, 3617207764,\n            3936271187, 1888135133, 3570340477, 3235145096, 1623855795, 2156134139, 4024884924,\n            2178204752, 2483127118, 916349188, 2554473700, 1443854317, 233737404, 1476198027,\n            515142283, 219340509, 3903163154, 1036861316, 1751209967, 2608587693, 2099772214,\n            1665732469, 3640692940, 1207393516, 1894081469, 3785834247, 887800476, 1682942477,\n            2048898909, 4222500608, 4276211921, 1373682636, 3791996368, 41716502, 2124422739,\n            1908458226, 3822116606, 743748407, 3145479211, 2452722417, 3733950629, 3162660014,\n            3622735657, 3497841429, 489897133, 2942665159, 2044804733, 223574165, 3776817195,\n            4082509983, 293862276, 1468912429, 103056195, 889161041, 1966953849, 3609876707,\n            2638065928, 1047905493, 3398519294, 1459149575, 3653946708, 775904631, 3344325826,\n            3854925531, 3146591215, 1543400143, 1286305299, 1097831620, 3814556351, 1594687103,\n            2113488526, 1483526237, 3807813211, 1175223255, 371540392, 3577846351, 3656743164,\n            2990923805, 4163557475, 1184662610, 1562684052, 3875455396, 530201974, 3563735536,\n            2924370187, 3802067413, 493795622, 3302108264, 3959076190, 991809575, 3790738454,\n            2200910384, 3470166339, 439053460, 3463112738, 1601747871, 3492602097, 1831054492,\n            2159047155, 683788148, 2417360498, 957441114, 3609045281, 3877704898, 785019165,\n            2054440276, 3353013277, 3418718269, 2746047459, 4026183656, 350438566, 184040812,\n            2052350906, 3967553243, 4017912439, 3023412728, 3981147025, 2561779615, 904031255,\n            1467577417, 3069914862, 4142230394, 2665876235, 4186456195, 598937839, 129946526,\n            3336739268, 3454671035, 4058349830, 2325596322, 1384293515, 3417683270, 1148857156,\n            398134011, 995116192, 4009371398, 1190266862, 356079055, 3395729282, 516920498,\n            3773319277, 2224415508, 1364285773, 4241870984, 1929215048, 1982917207, 1060681561,\n            1385177924, 2093856238, 1157884680, 1523090084, 2440720483, 785742014, 2344457397,\n            2451934062, 181495597, 2838865450, 455103850, 1847462635, 1857129816, 617726251,\n            533706755, 2323829199, 887492253, 3669678334, 766422621, 2551377116, 3769626589,\n            3052478013, 1272334214, 3370684650, 1238471614, 1283888404, 1093592931, 3971239378,\n            4183695633, 221423754, 1311480232, 4284291584, 1065660787, 2997149504, 2021597782,\n            1260499852, 1862303473, 2217798464, 4132482698, 3991747985, 2803154616, 1689402801,\n            741635457, 1586623886, 23968392, 2917945969, 3704724021, 1986593466, 1025079427,\n            163946901, 2614765396, 3829334814, 157726426, 304865048, 3889433559, 3988860896,\n            1233717994, 142420932, 1881719095, 537691535, 136246017, 994812518, 3796224388,\n            4045415767, 220351354, 674375440, 2998040855, 120450481, 226329006, 1904563614,\n            3237210881, 2027356413, 1913138530, 3044811367, 728913106, 1882651485, 874480565,\n            1374079012, 1745572834, 1322314392, 3232099910, 2827984607, 4215028467, 2143330077,\n            3742910733, 770738485, 2586508431, 2534440519, 4262086070, 1538337478, 925337160,\n            1397248459, 2835793954, 807501809, 1088863792, 1062604194, 4006484491, 874173023,\n            216305838, 198446709, 3229792024, 3229634861, 108433180, 2369055698, 3074696468,\n            39957286, 922106346, 3969368463, 1251206350, 4254324701, 1617965310, 3674752218,\n            2059215825, 2389702629, 1480268914, 256473984, 3939192840, 1026369386, 2084973527,\n            3154088165, 2751420649, 2771299049, 3303682443, 647635940, 861713349, 4054257968,\n            2644785711, 974864213, 1391305458, 796623050, 542009228, 2418575427, 1272626747,\n            354685077, 3531332167, 4048228268, 913350633, 944902477, 670411593, 3815770329,\n            2977477017, 1933705649, 2179465175, 1321626596, 3524651628, 3647479831, 3184951104,\n            3934770931, 3759354566, 1300200998, 146528926, 2514715252, 2038725791, 3603246392,\n            804639451, 927985280, 2605466503, 926968751, 1650620111, 243404233, 3880687324,\n            649985879, 3763728004, 3128971332, 1163963763, 2270481655, 1680842455, 3817842888,\n            372617912, 2367770416, 1521078009, 244172464, 3849098759, 17213868, 3683347717,\n            3667803373, 664776799, 627463253, 3965720804, 2678723605, 3947486986, 3604393079,\n            169215751, 3415040937, 2956402237, 2516352387, 2961241821, 3002752765, 1674635482,\n            1418275283, 3679981873, 3168190528, 1552912051, 2881775950, 349603732, 1998010250,\n            1643694071, 2230183983, 1208716578, 3487212087, 3185208593, 3306534729, 3775045140,\n            1661678170, 2436469105, 996816068, 4144171051, 2001836944, 5143238, 2662872030,\n            1114224303, 943645357, 2631400103, 1306570990, 3012447212, 3337497501, 2792281632,\n            945046401, 753119848, 1748673315, 490411348, 3831769979, 809682968, 1230679525,\n            3152591256, 2293609806, 3178622941, 1939835562, 1285634605, 2018307184, 3865772136,\n            2836503039, 1611136160, 4206035666, 951054753, 2773947666, 2871150909, 3117316476,\n            852775100, 1629450391, 1866062404, 3914188345, 633227979, 2209839847, 3769583182,\n            3276201938, 781985901, 907853783, 254660179, 2459795416, 1153992447, 1340828206,\n            3875202342, 3692780610, 4146633463, 2995551331, 4064483051, 3633336277, 3166949516,\n            1895018799, 1213176499, 3807740849, 4243665322, 2068831805, 35308613, 182839257,\n            3765266983, 457069208, 3146140372, 2047859687, 2425657613, 4070347510, 246630712,\n            3916610787, 1411026053, 1220761679, 3809749314, 2278309569, 2033459538, 3646988066,\n            448882456, 393448551, 4068290188, 4007045718, 2086086506, 1511536294, 1884227698,\n            3570325017, 836698716, 1830587520, 2278607230, 3709637320, 889145912, 361149653,\n            3037892398, 2349362704, 3720035488, 3930480736, 804598022, 4218700745, 1493408173,\n            162094858, 936663144, 3772859229, 3331137555, 1237082854, 2169615063, 366884571,\n            3557471134, 2281510298, 1429043064, 2666224918, 1373059234, 2972483471, 1991504395,\n            3431520491, 310755855, 1528073141, 1031105567, 224295805, 3424368174, 3150971464,\n            2305024143, 1228144108, 4014845246, 630413828, 2733742672, 3062587703, 341998745,\n            2960897358, 1850792298, 2338620067, 3217035035, 611710038, 597879084, 371658931,\n            1372059629, 1570101919, 232519862, 3150578760, 3993887192, 3045844719, 2849070546,\n            3349219867, 216832346, 2830103332, 340214898, 1974175280, 3831608232, 2908923236,\n            1314492805, 138089778, 1121354546, 2359042253, 1075516604, 1809603427, 2615964539,\n            656847733, 818142496, 686360761, 2504800877, 1712087343, 3207256785, 3676407803,\n            1617818504, 4068141722, 371522199, 1314806895, 3510183437, 2342405661, 3291155119,\n            2872122866, 1368588283, 2071123966, 3145894046, 3579869358, 1763887316, 3189756248,\n            3417949087, 572557458, 4263138265, 3066838495, 92990668, 2592368372, 1660723640,\n            1356119881, 3964730869, 741520441, 2065320302, 1530448020, 2458363175, 2619888805,\n            2674400490, 3472517629, 982503561, 4190020652, 1507233762, 852476202, 3110605057,\n            2059460948, 2784583304, 2279798041, 4255875574, 1285286879, 3885946290, 591729172,\n            2894365955, 2225184312, 1955326411, 2739502251, 452598289, 2335856360, 1880792954,\n            1362849872, 3908988398, 2419865633, 1027653817, 537841437, 924184405, 843918297,\n            3414422045, 3353072269, 1150303989, 448736065, 148315163, 3321325923, 1053550534,\n            4164378279, 3035227477, 3631102566, 1032112828, 2654432312, 3024592760, 242076594,\n            4028719359, 418406890, 2143389645, 2031532841, 3374578463, 3195583439, 1899730870,\n            2211084963, 1043062681, 3898196322, 3570591556, 3014402959, 1058542324, 3982931298,\n            3225118542, 3604472840, 2623187602, 2842769080, 3673798708, 2320983080, 1503232208,\n            568529821, 2595869355, 2032804190, 2272688330, 3980332019, 2641795133, 2988176828,\n            134507432, 4241721584, 3818435189, 4137355511, 1247830223, 1540166618, 398566715,\n            82945547, 3520871022, 3037864944, 2355612038, 2922815715, 1380952336, 1377440990,\n            3291630710, 2593192206, 2840982225, 1381454852, 4247382976, 2730153619, 1371886177,\n            2187792535, 3720941471, 1584608929, 1907112417, 3165529489, 788838219, 2392094719,\n            2757512848, 1490237241, 3446377867, 1953251083, 2966067679, 2649047343, 4015865685,\n            934788106, 2721418606, 2645175788, 2146440877, 3607717247, 2027478612, 3331164292,\n            2424939111, 231093199, 1928064611, 1889189031, 1996484024, 2462578397, 911391499,\n            2839332138, 163585026, 3216853820, 889447435, 2925890744, 3974842063, 3861984373,\n            37152326, 2371538867, 2851217234, 422797641, 1566886508, 4013456353, 2419384199,\n            1820317090, 900766000, 118293793, 677768296, 454666009, 1821152324, 1206919790,\n            1665156067, 665840213, 2415489724, 1662813609, 1605024391, 2455746991, 2415978633,\n            3228424226, 1170681887, 4209416263, 372421722, 1367236194, 1582475107, 2534855529,\n            4225119737, 1733839847, 3035349979, 2017373481, 3541817080, 385649444, 4053965046,\n            923745909, 3909753404, 1708758694, 2970726850, 3653995769, 2490628201, 3039101053,\n            1429972501, 594123445, 792127498, 2653775795, 24163512, 2159019427, 1447633967,\n            3788353734, 2530224048, 1535376847, 3637529541, 475737890, 1480354663, 2033042310,\n            1063661, 1960643507, 4231965784, 3777061289, 1589178837, 1370750524, 583972425,\n            1858145954, 1396655253, 1424769143, 1740074414, 733007009, 366220186, 2615602388,\n            3628366359, 3725371152, 2734902959, 3840576465, 3169707518, 2331576541, 172639875,\n            1335045968, 1242995077, 3535273387, 1348006215, 3327977440, 2252861586, 1819516327,\n            2697492906, 3536060972, 364354085, 2128099587, 1097669609, 2369539262, 1899308232,\n            2826027076, 251610714, 1833366456, 2498004327, 4209925928, 3083802268, 757770687,\n            1493785567, 3963538538, 3992191871, 3395635674, 3915089747, 1587752483, 2076692304,\n            239175639, 1181624781, 4072705845, 1585336863, 3730655922, 3098725949, 4160909147,\n            1386306068, 1230885936, 1161941648, 2081458729, 3335663614, 2681845720, 1525266294,\n            878004624, 1982738846, 1493492914, 3869755414, 3558460894, 3318620625, 1211153278,\n            2923817154, 2134666173, 90206626, 3774147601, 3159242217, 211850634, 1683920975,\n            3419509433, 561248501, 2219201393, 2704473464, 2109930370, 1966590295, 3763961321,\n            3710255434, 4111083708, 3669630234, 3613482874, 4227197028, 3200913345, 3176949944,\n            2570851313, 3007437836, 181922762, 3355997794, 3613776821, 2494660250, 2991177118,\n            1722445340, 335420791, 1822004217, 1020647226, 4216435952, 554872562, 2714512558,\n            678375918, 792717391, 1184324912, 3699517264, 1387222798, 715681960, 1762504673,\n            494737474, 2430735845, 1294960793, 563625208, 2521249590, 1359399068, 1529030962,\n            161693920, 3692550682, 4261806889, 3911140268, 1796777798, 1560560503, 3253954915,\n            1478993322, 4059118339, 2218697307, 4228806326, 2922262283, 1389385047, 1520245031,\n            120421632, 215017916, 941957196, 537434329, 285532838, 1319019517, 2260588795,\n            4246464086, 2513401292, 1255780628, 582555104, 3776819498, 1964386863, 198549809,\n            691527119, 1455336753, 2718376963, 430317133, 534234672, 3963888184, 2939870602,\n            1013503572, 4251027930, 351032584, 2506780282, 155322293, 1603457426, 629221313,\n            940929669, 2140168814, 3118526863, 2975043414, 2542950348, 1672189235, 2091819583,\n            156791564, 801424438, 1579481769, 606448367, 2676797638, 1095660494, 999737097,\n            1180771007, 2705415919, 41171434, 3973781203, 1140191691, 3872339385, 2174068911,\n            1171782493, 3162791523, 4016408468, 1505797535, 4230233395, 1472675231, 3877988453,\n            2256455964, 2213131637, 290987424, 2419314882, 3938908490, 1876277179, 2206256766,\n            2462184605, 571242904, 2804624265, 2537742358, 1512930954, 20443981, 406585626,\n            4159045829, 3743334477, 2720271699, 1327186622, 2282715474, 856172708, 3358599987,\n            3908731226, 1473501203, 1040125791, 1013411175, 2178428342, 179178690, 3299338066,\n            657503960, 1545374802, 1426666903, 3837024697, 2807513087, 3191662271, 2929270892,\n            2837727006, 1178843414, 902457495, 1503862797, 4128316640, 505227925, 402394707,\n            1239082017, 2532495641, 2213659649, 2453021542, 2833770939, 4075060441, 737288063,\n            3196564671, 3347031354, 1128774756, 759830554, 367496832, 1845668500, 1022723613,\n            2125318989, 3193171564, 1296593784, 2100962794, 928469721, 3513786287, 3254304913,\n            2471056685, 323600219, 3708437214, 1494329704, 1323222619, 1037364325, 605738342,\n            749879495, 2580477944, 1541792255, 3578355076, 1583200785, 3705915572, 4189346050,\n            316968268, 3066282807, 2057963356, 1504061835, 224110056, 1232523877, 1756186392,\n            1481507640, 4193355243, 1739426324, 2577102061, 3897674924, 3493979988, 3504168938,\n            587951092, 2483301859, 2158160898, 2500450333, 545127629, 1640229616, 725035055,\n            2587931433, 4113473744, 4013037468, 2959986602, 2768797776, 323074624, 3890671630,\n            2627301401, 129761041, 901881866, 2355775310, 183903732, 1304973560, 2325771699,\n            2604899306, 2712839713, 3314617282, 2383066369, 3939162262, 2358804150, 2413816673,\n            3870280269, 3333721889, 761424285, 1621662176, 3737972215, 3797133469, 2927249190,\n            311560447, 2983529496, 1645662697, 2815579772, 1384605226, 1975569750, 3438896430,\n            2153425055, 1933394184, 666699680, 1896630748, 3037753431, 3058622420, 3123120096,\n            3276515450, 1056251605, 1132159421, 1773572347, 741172336, 4199407673, 4292517641,\n            1258588807, 2359189321, 1890989499, 1436616678, 3725810143, 1344959, 3169383524,\n            1846476021, 3620567306, 3964415846, 2584023408, 1788946809, 2432113874, 3021455913,\n            1025198631, 1375330149, 1734026140, 2112521040, 234854014, 837796525, 3469588005,\n            3558565274, 4181968885, 2254419984, 3688734642, 2849215967, 2082915962, 628793510,\n            2668077688, 2671658432, 1960044042, 2297993582, 1677267956, 4015811883, 2957427505,\n            1711985518, 1967619462, 2363307899, 3229014012, 413632917, 802674958, 4188881074,\n            1001001610, 1178059427, 3086148039, 763569311, 2473147016, 796453303, 1992026949,\n            2986634059, 3708112546, 2217334304, 393217384, 2409040458, 3294661042, 2008477371,\n            1983407099, 1535775309, 2253074183, 2365159699, 25041784, 969938953, 919813306,\n            3255007835, 4126849006, 1149295401, 1616961575, 4049610625, 3714928640, 31167510,\n            4029635202, 1593639277, 674210358, 2407087181, 2082038934, 1540952457, 335427986,\n            3365342309, 3437864350, 1717068274, 3174196744, 1422250091, 510506978, 1544552477,\n            4176789708, 4166623697, 407519622, 1691350559, 3244576628, 829324152, 136672835,\n            3258593955, 46194264, 117115285, 3643458495, 776722375, 3434492653, 3692988566,\n            1323992511, 2957036283, 2564967609, 207000418, 1612202275, 938281365, 3500670015,\n            2514147455, 3619943885, 2420380525, 1766106326, 230055465, 590347524, 3819437181,\n            1536699885, 1459966380, 887109960, 3761856421, 326207459, 1198114966, 2352746750,\n            846264182, 4087651522, 4260980083, 3692531527, 1224333971, 3026948934, 2848503003,\n            31151839, 1677236216, 1070803401, 3213905770, 2956179232, 2304979954, 3554966962,\n            736917059, 711943740, 1085866479, 2424094464, 1071927164, 1569764952, 1199810187,\n            1253877148, 3493654865, 1628631752, 473149744, 19967766, 2211455156, 1652785765,\n            1154981846, 2774085682, 2612294675, 1679324998, 2671156232, 2452932446, 904349261,\n            2138112251, 2095345180, 1863338470, 3301354610, 3353141736, 2363343186, 3026364498,\n            1026177201, 1760516901, 4143092446, 3035764696, 2907752387, 4168883524, 2741880350,\n            1087390243, 135260592, 3472841234, 840102962, 3177200036, 72163601, 611139117,\n            3870133867, 4121596405, 2505403848, 2896610046, 1072017518, 194138634, 871843203,\n            2946005084, 1429997613, 2813236145, 3628760953, 592821787, 2169431099, 1233289234,\n            326972645, 2432580133, 252411516, 2017334732, 1076658184, 791291644, 4027958541,\n            1141025814, 3852232131, 613290295, 3966875164, 2105931102, 2923888127, 3209191925,\n            1880563412, 3321080014, 413557757, 2344104686, 1575721926, 4277920045, 1076013736,\n            4105760337, 3621812886, 933169454, 1186603493, 3510283027, 1915413223, 2200544669,\n            2432233674, 4082056572, 922115840, 1689213262, 2377389201, 1814721075, 3855682276,\n            2000264314, 541395077, 2968926312, 3025525181, 2914038586, 4291299266, 2535225757,\n            3837563224, 803339381, 2017564654, 286531342, 3066511824, 3998396363, 1039972840,\n            1380844035, 2503093716, 3716231825, 895232486, 2294846888, 532581067, 3206382725,\n            3449924423, 2087226435, 666272241, 1896734046, 1140696422, 1508691072, 2180232380,\n            1428701432, 824643080, 2280104877, 3193488674, 4090367226, 580731921, 2333351837,\n            1895188244, 1008211486, 3517726308, 852465789, 1648818849, 2388943747, 1586854372,\n            2691387894, 3275879436, 3164792947, 66258512, 1196105716, 3676932754, 781697518,\n            1080202479, 958201596, 2162422236, 3364770007, 1515375142, 1589722636, 3631817432,\n            1366228945, 1469994991, 1276073576, 1597950139, 3355976269, 2725693850, 2376110416,\n            3059497687, 102703797, 3888416268, 1470515832, 3796069020, 584659380, 977198149,\n            196400770, 3037884708, 3181078823, 722050075, 2373531064, 2771864628, 3538629168,\n            3672564050, 3522094929, 901823916, 4097143023, 366310736, 3418688105, 1633812143,\n            1247435996, 3668222980, 1451125043, 1252574848, 4224623388, 10671035, 1973152294,\n            4216050200, 241671052, 4160736399, 3111838663, 885192095, 3166478147, 3629428720,\n            4202015792, 3255160511, 3898689749, 2814086752, 3095285886, 3778617102, 1489822200,\n            3852275618, 2531920686, 2166576667, 2583337462, 1524875147, 3267980921, 2397031089,\n            3240526150, 2000115455, 1311787505, 3099442844, 1274817071, 1012829326, 114610774,\n            375904181, 269466199, 3772035037, 2205104815, 2830995073, 3706571547, 3677141686,\n            3490869491, 702814974, 2778579045, 2455955272, 2611360460, 656925090, 337783112,\n            1781235217, 1204115916, 3287054846, 2614466560, 3901711198, 1944357669, 1824143158,\n            1826193010, 684250230, 1652928224, 2611789693, 2507319901, 214867654, 659570618,\n            3932627009, 371231775, 2208149317, 1404862649, 2398679622, 2296858980, 1492259029,\n            399587501, 3552307575, 5156467, 972274518, 3064887182, 1574975785, 2333109332,\n            708249006, 4214315469, 2632927799, 760593395, 738911951, 3314585045, 2703384626,\n            4128070655, 4017861798, 2402659367, 3860763803, 2787243388, 2645666766, 2585208498,\n            4294336880, 1073908643, 3345719900, 850162876, 1322587908, 452836223, 10, 10, 10, 10,\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_8_fail_1() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_8_scratch_len(2)];\n    let mut out = vec![10; 78];\n    limbs_square_to_out_toom_8(&mut out, &[5; 39], &mut scratch);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_square_to_out_toom_8_fail_2() {\n    let mut scratch = vec![0; limbs_square_to_out_toom_8_scratch_len(2)];\n    let mut out = vec![10; 79];\n    limbs_square_to_out_toom_8(&mut out, &[5; 40], &mut scratch);\n}\n\n#[test]\nfn test_square() {\n    let test = |s, out| {\n        let x = Natural::from_str(s).unwrap();\n        assert_eq!(x.clone().square().to_string(), out);\n\n        let mut x = x;\n        x.square_assign();\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"2\", \"4\");\n    test(\"3\", \"9\");\n    test(\"10\", \"100\");\n    test(\"123\", \"15129\");\n    test(\"1000\", \"1000000\");\n    test(\"123456789\", \"15241578750190521\");\n    let big_test = |u: Natural| {\n        let mut n = u.clone();\n        n.square_assign();\n        assert!(n.is_valid());\n        let square = n;\n\n        let n = u.clone().square();\n        assert!(n.is_valid());\n        assert_eq!(n, square);\n\n        let n = (&u).square();\n        assert!(n.is_valid());\n        assert_eq!(n, square);\n\n        assert_eq!(&u * &u, square);\n    };\n    // - x.squaring in fft_worker_func\n    // - in sd_fft_ctx_point_sqr\n    // - j < BLK_SZ in sd_fft_ctx_point_sqr\n    // - j >= BLK_SZ in sd_fft_ctx_point_sqr\n    big_test(Natural::power_of_2(63936));\n    // - x != b1 in flint_mpn_cmp_ui_2exp\n    // - n == 8 in multi_add\n    let xss = \"25384011009295806532357690038301328678178355953143389004680558796704961731811371769\\\n    8348887554225838035390073190759696975022053239122423162346051254744840880490984341177697039394\\\n    2496357496943277061191765920774224515779467940405470702545201277606530020609086200858337557813\\\n    9932094955323117437035296373337749227037144486879327887878580264803153246332648728070722720409\\\n    8748122149130475786531555676642745076046195290007644144605436402851580347563884203630770681535\\\n    4339134562152412313231385866864609620432477673101106194143665361318643443010110310914139246281\\\n    4495900108750339496814154628497416421978520801168208029449033909250882426338036373004325931019\\\n    7906528070532009056454776199466663095524968424927657055569719442685881822819618376975628796773\\\n    3527868177798018856821550982309020750081279052471927764378814922511379061604076463607235118234\\\n    8384316873776087725943446126467665804994475669679957697182110285399045928047528825422656995045\\\n    8956301794491664284561446424981681643258755837488352663756958005055472250585622975523682821742\\\n    5840653038854964611048717103932275160172239933405239897300176009565797811948235571555901113905\\\n    1874732815468960729168615214409027131456131781126349835002781348528907385429144964609711518835\\\n    5008058187218750939209554897567356048633008722784956226083589857211299371319988453193631662551\\\n    5484498900269994184165775869251782148873698784897783347370507568614203339461261909548049759647\\\n    2918330935579645513120774610863131017686926514081163438086814799460964646115620831525831022716\\\n    8661320082717818421230039253955360442944920047738765693843427880547620279352186880579974554091\\\n    3350838625295922244488969926978740524724781507248898183556840656961784557366539635828189934252\\\n    1122813367647256569224304004607475771994181609185090164509092303014816587643910403864439469973\\\n    2686263720629419621174275942012040654958220673513208970394443999237682758900183335264384977195\\\n    3686439445857485430402768242460837593696661212772576377186247560095103803818714123355404139446\\\n    5732964026831514807876996950701171053276598465626671715848414016087007600656026811407674702365\\\n    9848495932305895568286483780044870848691514368304725672251145929943004054162654910881497587562\\\n    5416341363864193355141370683481134661213865113604215855928353054857941163955199487788782308165\\\n    5623894766595490155113595182375061933022111829192604845343656798690907820834817559722140972541\\\n    8382650561598301445526174699214976280467755148143335452757875682670478371898616441245954181370\\\n    8868144071767292349586406425219361491555000486081574037383774578330210302150118482776750063341\\\n    4194020566397686475958691180641496679063333643420822404142355165651971531840080804015572223388\\\n    1258339561030457165269538438678490155051046099690001363606141423898882695850926669919852988428\\\n    0578684124433071204019517813704847509309940921064397212741562907432256419960194867787432719318\\\n    1899135355889770170409266009332048474018778353135813269373098033178363769402489322516317661840\\\n    9820353267705488299782251468550073470541714609297592468768078243256629420265546392128067902869\\\n    0505973272111947890733165472126346735954704474435913727608806258863821718690315051451963571139\\\n    8335385241551266160493808020591826272296952205945153429907020710794628836446098862137789988364\\\n    5061370139023316556076292861481684373573306082044255549588283921693803817779486572168220366204\\\n    4018612794022551767036187935986194443733071637993828200406787926247245637976040171215025296615\\\n    9462104357615602073499028665033625449317796047666402127182821614897622573895034921399540765544\\\n    8441031239505059083196212784176901507812098458105420675901642619341302303143544645518088848596\\\n    3184597636126366577642853717224019965102347995098496247517393480419332592390561364999691202007\\\n    1185739252664638146579014680449022778373951379172826428713082103946952905370446169287541859632\\\n    2794343456553052565388340544618493006573615131036074181390312178951920287512464374485368261345\\\n    3285859271322941597763295688086522082554769078220489253988823108121642168300868654325668697535\\\n    9587853618010147449311193031347604866357248426353518640775085786811503130132389109768637826447\\\n    8323601852508403175339814410330299638970688977829545016716072157810339305725743812160164010590\\\n    0673490844622396328063435237640471189542105226205301600396475215650106363593354566827940252794\\\n    0430585216191804549638059781031446670057882657140793210354349848990160602509614207869428160963\\\n    7782349868027597342987759249888314273569473949545208129107801505999539349905455150981787279054\\\n    5346245323706556871120711064161980785324105139456583933823278158232347534171855886541924842091\\\n    1737032914068394836641794292817368148472600104289879258245450279727971327950846920868390466249\\\n    1016222359459333505939176959616412687902039156284248997626574893498615792188716287486029467150\\\n    2932500212759012140192315599398307309331875531193733932483351268906044484917359053413919621351\\\n    7272029441853699773461074454201852140908776426983487837821887706640384320160377247437893216368\\\n    6833075136247161632953013832486882529646579541065125623654805777426833427467087059007616312680\\\n    9967660645183806465200459519623881521373761018012122837506690418937977751569372480639729425849\\\n    1374260421861952456442342860198914827769703548668834723432191653397425374473058252877784472118\\\n    6920112457565465249490567248435495508179288788477040045389260509460263724021682785762214878585\\\n    7808989995442948389450838640541574020926685354586156360130753799664001965364850457997252042106\\\n    8548320682139771530488711871919673183710867449515518785561373802327090407241978461659896652913\\\n    5699124875465572855258388271096860626724298503587458626473725259256315615255855548091011872871\\\n    5286963645160042236386864659165831462867544542719499599855553068703411489762649252914556106274\\\n    1290786172537110180950625761492781878812956823402274732371854261197667391087749719071249961522\\\n    4160644862653984582664842720195942152572600432375038286056477375484561566854254375103835388425\\\n    8036474911589660346038100244508879003470776417428368297714709155334464205918816433537393341685\\\n    1147401139504040287223160449553590046881221213554223155493075558627722703847440445249762513403\\\n    1868810444388545879696053793942419008628407151610813598112538731557401446958254532742010060592\\\n    2735337959425468914029440996705454670147168495845254559961058699973773865059452667677792048416\\\n    3472028066320728793401957450785337350807218895748411362968398032018526002727212274510100012685\\\n    4367605076018476933629314070045039657618753784021130243097459306966741527339170146696561736123\\\n    8577572652305334620079355394641553262238396080544644498226701351521140722987250949694829386708\\\n    2104291735537976893161141917371623978225048341070220918139230932341774973113896232081741084984\\\n    4415519568694333375410891812563607315597369201669943455920946468259277809275781388930325818427\\\n    0146980199529055148199661003351456361099424603047626478920294791899035300884737862133262973915\\\n    9843019172172042532960784120337132451454382424300456465507273471494446083324999362290945689490\\\n    5941966302010990106705115790958717255876023094124321408100620636413032241457078352947098059536\\\n    1642135713666231160748022375399683065356590225274671241801692131917173381307377989727567818297\\\n    8826910463595500754697303243214592063971091420233456955263391169025482521188943803946575917850\\\n    1117952795221883399268282252442065588937629344571434136542419361835423984590971873750638258940\\\n    8423888198503388302227936384625030701949181494698078717265292212846415563298966861979257088255\\\n    2500847712904728662018280311091347082989117026943560749333370606210825813207481796753163127948\\\n    4814441461271154131440012144666118421248720261430675374512701974465035034637885904075985369363\\\n    3415686643166599393717080961797782568467707812455334362910353113483759516064115222185261477967\\\n    0969523733728915308182695190384478569312790075719968607804447965259923721205900208887993875984\\\n    2868069309855978805047691318387636819666080094734586905138357878418940906746019731845286523799\\\n    4271937396067729878906508029890833509284093448625385832899540649547023209536634670045863111206\\\n    3541702880123348233066467205427959302119632134915525743322759397284161743702839389644540462605\\\n    6176552456095073028642039703331873351310505526175076834667598647914144009601701706217955676420\\\n    1132678490107293678753755545001085562512784125069621257720305077951687781477335464853332632878\\\n    8156930881038543533413327378839162898523739790522761464180108214305445553749237770992422058635\\\n    2612596059372064171690621909659228399250175309894964560325578359374850114792145015584153494438\\\n    7252353021758984148913306680600019237374558790235827029411060207645871894119946680572493409662\\\n    5881042982928268060025627750225425954173122928825336836990946641071331028524499131420797581706\\\n    5238809331965940294339494916890724472231664452423677760859750713983397799332000669409467967438\\\n    8800316762033138570589257187243940910075387788756545567060111307531817347014968848893394732162\\\n    7448425737016414883971064454082712586376800310567632640551141141493652431266727552791705948387\\\n    8166950001478074577561770998321486912409551058036697600791987415279444046672619287521341306853\\\n    3464290752658976775750987495207372781570888398967312364243881778598754999321987594999522225435\\\n    3874404985621617253999219818304506136797042780278676436277899738218829963507467624652514087850\\\n    6581386489334939217133057442567188534229203448714587288955063795654469444147750523110916425852\\\n    2174283105640488071314474411337508490710319809031828758753934876005622251190592716257023290010\\\n    3291815048254796503237214580095597960156236842954959709857312425021649060958133485805287743111\\\n    9248737080127113221708515428108088215908907688452489711647594163337038805594842036378951076855\\\n    7026292367256591649056210501407315069367357671956949821448329432554193195522404127846714948148\\\n    4529929595612307998419800800493441162182075085847593081293922265108550290961868801569896232224\\\n    7565117447743726825375443938317898977214062433766452659242574618075262951715922441802290486892\\\n    8330829623460802717111858664912559088290147772544210742975927644591191030266494783580939074500\\\n    5668322720568969435506279392999853365574717182174240562011023407493609363852213491783178286666\\\n    5662129723448805530019689639938202663947437150842500251815582784329376469124616309714336419096\\\n    7681216517203903998037002064204995164577769613621480061345303257480111147489355100340528893778\\\n    9103796133732994582627823109436950753537955959188317367365729189466615977063986145546144811732\\\n    6796415889342754492635237598972292367836031256859561355613175723591450750762096950365419212359\\\n    9275191154714224299856671669667736872992072917582515246225582798843325444179831335821790853162\\\n    0319382985533282843953854107506427900502148569837565436091351443119540684768218146039013678691\\\n    4373291829246886835035824393343707639698529301453246233962438511434722441246430886328603467893\\\n    5167817334174816644287708769125945161423154255133693277076574013694842624834000767329904329706\\\n    2622206167027131115251805111422461932364100161341170031355057802421893355298742231358342605475\\\n    4433571553721395899092923258160288719521998702371897771192782011320341382862554060521880314967\\\n    2585662970557268026340856771858556909113274429599195148416224819882888413365963453606650852196\\\n    5935884927311811945359607841412720662705695418544968043134238224285401416633915603942200164186\\\n    2367237980979227984787818476518761035944269867295600752842960846811676883265052393496085273654\\\n    9217411480105573595887017864406245209769014902820778326795071324256161049189880743751674907615\\\n    1431754168848023102013007174412959126668872823596341277436844442194988441017254456099525570563\\\n    8709043166437751820753589793755105468096028660635531110432840722598043843028797254328196179165\\\n    4832767864171744531834812250109172479492988658198141131116996364128810429196392213914062307310\\\n    4941929247557847363895141888905095928515690265655587922791428181672824496650883518424004372498\\\n    4974723133777672121642534362417516618468165247783437623121090972587093372159232768444789371228\\\n    3113487805920369999462968887527077547142763375027474886504089586243463092090950364767254779081\\\n    0189112300896193300114124516709478790611511861520793690362268542564437069485068139093567770698\\\n    9550358116430099675072103114233933809491207869958612342311968111072880775146257155076875912873\\\n    5616362325461336326392341048700811778324015654839972008346835174777985516563626525729563295176\\\n    1149266406510340344664463312809157985974983620697765393144808094643070664408104702172834026219\\\n    7232358292533213505206150876204674865079227579353270631542995876263304681059417188576722568851\\\n    6947562221232889044961688679166619280889066880291426247870371347906758238393272426328737822593\\\n    7542949865212630553997338363807182415052496628281807565322180405477148948947842212138657442399\\\n    3092556320888938642303970180478701320730227959023572323642533269545729898966240243388111236388\\\n    3468617383816594255866788632898508862540477743208403455794652380615589800108974895555062352158\\\n    5166064874166957158899720893721230010965757086639527439467410577370969418657815100150506172959\\\n    8304617521780089995000483797982829476217509440124870510444419347528041254942378488709935559562\\\n    6591161961283140764930700350494562359343071925276016592109835362463925079212814489749575520540\\\n    1031938410798165128905519152012668578181794292848105904283881526279720990440869571172821007815\\\n    0645748787498416468137345046749783663888148613668420695421301662014622270408084300416240671318\\\n    6492730554744689889523023339562843195386885626843337533649590968874453732751467472149971540252\\\n    6686648345809260713911017906903026015192536865175915597500589619481845572391828552036495430419\\\n    7631064995903165408350342825183891048439930001191546383386344275748772349765030459089534583456\\\n    3793605917339229110802629693801962101092021169017634408001461101678809695719060616055769200054\\\n    0568201434229917663915997836950017202909114770410078708028106324022252271589322313482586935287\\\n    6474016067275258506271062353280310551822473097128651129904805345160290048546893447192214481400\\\n    8388133959098809873956403502056449282340633794108211102599044968283243490620821424553918757620\\\n    8858237000663708935195116872381196452696057701357496896081575628347546975102099801562468554213\\\n    3122156393383689134122291283772466424112015479402268465848433938567464298072469939240020194014\\\n    3163184533297646286371806328751815732891748228453602466605927974401080339039916995235085517666\\\n    0080177621126138539648524281432672685051316295838419336325546278742337292906642836094937249909\\\n    3683628230694799801588292805384325614126371712309613169315599426401891565334118956690677588148\\\n    5099510178002797592174196325730950510490799363196815650376080703761993076712176960496518460064\\\n    5189084784650283534991039639376149276870794416400661835331739305211215719118080816198367963693\\\n    7272904257125864726546033647796784187807146657852511831209883841855540428137644240861863727499\\\n    6971074165199927731011766976975736144131153172927812449969241977132698633144383408431279775838\\\n    3112755195938488768567544565906877476512360591689182736425096536129359180232938347116658061187\\\n    4860912344394725707273855809039085890586113931725537411826115934545607855881072370359435989431\\\n    8492738926040293119689084147960344094018481572703823039721243562926278480057873162870281344617\\\n    4355201006771399436900412325991723733873248851782316037053780567529316169075788021820561301256\\\n    3356529273623332815917681289901945419464592275859186736848496007237187137775691723271735682698\\\n    9653553503942199687887366467319320557230520299298891537331558990134045055742553241659792473308\\\n    1771513397077910180669013779824841142341962892055292302118458844985425392869167962605396204258\\\n    4352030450474903068938347211001275582635005469850097191107613315747637680735112764426837118749\\\n    6598972883252849857968552648267857420187426101958508760850007649829232922663281207839543775529\\\n    2293775486983903904382236944538901374039403833763298749609357115492715200637557622161661766662\\\n    1748171821118219596964027796602389169489979779799945745690170409851826717179717152749672031123\\\n    5141972309254741869227575985802126307892657345768515217926607539746997671825761430713558834061\\\n    8586246491369649690010511216472743140291857584082725124859266931987661038975654248562446809159\\\n    8893933170781996281579983413259838820831406670293176052334211880584271535641104434019519368524\\\n    9046378825291911849231957267634203168819513006764229544311274102222762699511008630787981672590\\\n    2329239619680715768519549091019457009738278689974421703623692951383097306818683027179669923029\\\n    2175395459930277459681334641508727008577702840467531039484888426981727204952758321685240634135\\\n    2180128950384815451339222682028862951870030014546575652348485675770296710397579649599150170735\\\n    8716771253316616632212253772365393503392423200810048046541087221291905825980652593195708691052\\\n    7223538951986216233113975725938095841144613141336569844722175533648814397498908779483326025912\\\n    9048363303768023668510037177338795904906085597741632327603630859941512315875203706449507945620\\\n    6353616466601807060918043634007246467327594216230529057123600377979048555819919103848849902881\\\n    8999047441574890288062316009416586517284801511677229027999343314631162689765116492586638873769\\\n    2014771357214803086812298318571047163942847106638171345620585333463822705198270185825822825030\\\n    3523736385455140560292620017853328171528206465970115664656800908229480489843172618430023152175\\\n    0539118118808632391983756404156569518616145843607380617032101413134086356927748819072076815746\\\n    1283210562364930548643143092236216267187497934978356871168599821050241119723360249050857302480\\\n    3075561875018184260782580535118349808264243989860110500604825075724096527059616883769370277703\\\n    6252669827586706905055086086944244684050390537152166679343437340526882480448279154555125589891\\\n    5350297782767980128816626307215829638831145214708544254623549919505153403217824354378986620568\\\n    6176620661718616062022505893545202752119903500092459702348230774745468924860192844230458601581\\\n    1304259661972403552508544600769173735036894135680932084119363519745608441888842350679587176479\\\n    6471659931790458205998622715180386112951660855702959737672288733273925772375448459755103082909\\\n    0852000682985509852445421323092918505220669176853108032182730244971211225145767245003922090266\\\n    7176127750228852204393629080006849061964749604011536607391221064325728183594592975373679704592\\\n    1045967295486997475314059978018758251228044188898871031142553034439007225425534378243670011499\\\n    5257902561701839346526269711120222564455297038736633646054000926941594496819248542165417691979\\\n    6479610232762838676162681608232442381534860618652830096704838341888255132951357197885268774182\\\n    9321899253040323152961057984707504136084890127788153373956561990482790466967453589861974887228\\\n    5833893544966692715403187577777333068118894911701033065324328065600685898926878974529930760342\\\n    5428569688359245045415232671817533438124316171548661217740386472386031047129402093175172829153\\\n    6991209594767632654915542157284901547564215235587651241560760151826147506332298638060055611058\\\n    5247275121697461687813041184799149892596983063086418851494810726375228591224446359135385008433\\\n    3642566404209472838542946423120614611635187190070759579968301335303287279582016907716678188779\\\n    7399899847371787226091650523065917078284791023095344628044878177532150886672702246055437458747\\\n    4321702369486255638665509046833250400330654401030628423218084317414518262283385148751739576260\\\n    4749000998321112922411259649010751755878954117056979167531464726913169981073449841606296457682\\\n    6765427531846185744923923102619831111602552545834571673225861435215062183573322049830976650925\\\n    0353083269809875574480941486464138080240542238325432323641985789169827052818487692851682992171\\\n    6338072265155123294435453335807679716244477621418895180550411773098261282046296649072275976963\\\n    6175611428189572320687910601294559290641174711015926843829736881082340820097667030056065486576\\\n    0182727525709931845715230635722084341818287166904944104345995253765775582023358205119853091720\\\n    6759161149258538655285691868793116684622525542751603181951935804418586566981220345111531539450\\\n    5343533003081665862439749947259370047493595051068065291737626475513773904547948521694728950780\\\n    8152152169341779372318518499665781724869738453441752220317065605145176051692687096959987260341\\\n    2756634171390284514381496654244131739767680496178136017633407256332465723694653881157772078166\\\n    8649152345944339382279223392521431435995142012781749500076820301466283040735126140245119075737\\\n    7758414735235960105559539974934506231191403842805961305649151658369578315932597431524304083386\\\n    8580397904361613211073052635217514269908652030145837617907106108150946030599691536926880250789\\\n    6714114638007481358303566044734879026461014188491633314687983880314037537252606121277396993192\\\n    6956629139830959925501116557394149191180008548189888551440447388254211334965671482700808934968\\\n    1901361986914593593924628545098425839821222083410843216289370194077867018185189076810129205336\\\n    8177002422155323046471022317075622174346535137925984133971727700708307100778255215609589531301\\\n    6037380328801398660164935472198872118088636661545947951408312026297059437462693949348900881312\\\n    0582483136238316107043517171426928239628845762756029734168935384387310896406717445447658548321\\\n    3630018921584161251670342213373613731401761485092574162273703786911483173696855991908278743734\\\n    6258659965377271536493887252109012003512861685260076585893368887873369981706406933594077143340\\\n    0142421406406226969247172972316639474850346647348899678587053537862938948608510065148401828099\\\n    3645891453899901496118543099945282207819968884038526535677335294041121607537731290090513048932\\\n    9521490683593273776976968048463323829502394983373672840015404447442856385281502368815695954684\\\n    9136447546639995475136701369077130404974872258699463368138895224835247633927241925875923681277\\\n    2187054577614089930203756004901712759691379559701812338090329309367485685112137169080380142282\\\n    2792895241238540156073438743030028529006516861642396711878059379637314818736003376477638747094\\\n    5550667771146547380476949822834952643076033063985122996208346542659019090381113130040646937150\\\n    0884949450775327613140935824709121316097394619346427497972741342722795414458996547283075887494\\\n    7256445393002873139572260430445758767949725310076015600076703197510033369124100887687046429678\\\n    0560759090742841909748258088404693496225075669515140086726253373410715059599096649234223782115\\\n    1572925003019818773149959485182718542197258743252013891172718120817277013436148600804472739351\\\n    1798705020069851160301701130238682313144930933190145568700439654385253763535428396224457510225\\\n    6907956699821145184472889510331374382476145252097123201123871066817365984917202578219157899740\\\n    6844852524942010747715069444992775476282876280284010259638431719802043757260110168619661443442\\\n    9470593541999242351836884858779840239260477633822877758957630622185898320347823096160990988232\\\n    9521159412403470805601743913525018738830616197030740343651445566694549114585388042782392278940\\\n    7973221533368776459822987931174212097217888852907308310208393823567777741963944649293356964813\\\n    4196196020236550677472645879463611901559288776482878735660870452355906392855722428548829974892\\\n    2967356701688949092354892973096469492456427669112376843726612944369430957678621352579825595684\\\n    7817736358708828035442020328745070065082296495982966719687838177878184099025577331988646603662\\\n    6227846061411008144812239085988285259987682322932417804569943145672823521915803006185653251201\\\n    9859452237419474847481111897581264138677277405669186265959851016298871800366594006525622880007\\\n    5908401394411510458487286746829091687514255456234844686701718106497710112250338220688419416429\\\n    2474286502236110437369934360255846058766283099144003298343932474248751071518074427609948467748\\\n    8462118949286067527104876956816083948716541970206291192761496250316998166668716241620577010162\\\n    3290116243666950562097499453542457516520263532197562979166448925141936004933233352708523759561\\\n    4290057748247731716764736498912473718627185978537573534320033810522168566721563419622285420526\\\n    8619969699503632989228703994209321254168320771759051073228868164519290953301858904967150170809\\\n    7269396581081317115236473912865571421591026272268341155046445747528791217627353283824931329664\\\n    7268674965921892551361035299621188169954661556419523865287985376174312761145200794375920101659\\\n    6938803339337594916094015754075726332834557416625284711261745198538435878584359623936742886602\\\n    0964514529129787120956034351830864528457405516418766938636139638208977998946520040867499357884\\\n    0200844645536434002937259727369013445947995164977069000590589458262978792030101956729210901987\\\n    4108945048681225163017631958770587330031017918499013857985129947102708463190132573861279108371\\\n    6407061004372155108716698190254214383599716749614484555752908091820212258069293963154882798012\\\n    9690252773641283800470634841422300518586814207900389159019310513727596473855626777015032259236\\\n    3872783534654588238200468758952641501685285967585806404662327779458770929113083890958644399725\\\n    3013352243964611168800918719931709628395844407757736526677318655479310777075800521682138123655\\\n    4858418187039828430915333289428645073362467328578205419635479622941562629705284745126674486754\\\n    4297754329401519814234493937892853339583135339230043378106424532814709523309080248344326865952\\\n    9563589713683163776667076039454061663883595281925071304642080038408124794564899256026386778143\\\n    7908727833850022616527743783028282051166273669675963231840817888457267017001291140220929214639\\\n    6773419925321143654010253526009815298466254805204887031101229890952833354854358627036097952878\\\n    0812622789972053782230194489265327838834633581914304516707334284259829291913918196287037485209\\\n    0569263790174998656080152898751382018120060315048674788933918548640517186958608860996859996729\\\n    4179364599102600712136199903671066180337090434256018322627398563329287936617508668152100548543\\\n    0716708796498653693389225516787523466857182109215459182832140638809862393206623471453009677023\\\n    8605907320451506804429182842304434619907047102409013565577177282952367156008216574038981759503\\\n    0718201578756541904659296546798573455184258125610581812184158911778431451854053286354970929705\\\n    9306123992912034872370972391631830956178693802641388561245637595247635112591182424499010508138\\\n    0747320473478459411971818471332673006342244224091354414514178931971296080593476880367946437987\\\n    5692981190191715441348950731617034102087411565584292802462985445630273564390339518530253964609\\\n    1525580774048567421257058538669106359258285466397689364379546508483709765834070118505264803632\\\n    5998406175518765869749812997513677765898371810895695299643488681090473353777448812553595394636\\\n    0713929607748580355557913281557443289648379818143565246814652340654451076593523843184671984660\\\n    3116168491870998924714876549815708479359515040930580425000973046232649905603625640022820563484\\\n    1388714160387534629718727744331119446325485078273983874855426110146416485335297546409469646853\\\n    4095860891414502044728602816001631133316931918929627628456877326209326454063699006788938011741\\\n    7344774223792931880594905575354484875546552615499568051332834161480070879254963327997990076902\\\n    8124737977487799253175664109630918575571386372608397033940255241680933832675540360973501331276\\\n    6335254065428459941528608628236069802125419195665104016399307017747517222924724218528375830718\\\n    0599636784270900296670462938700161317689945947625800160625746405358477456562881794596090125379\\\n    4315114421416453150073982622705135871514981072538770150613455503715272811093058188226691047664\\\n    0441595040953175861733052148424883666772996510405753902535338208036317074566401345830203141243\\\n    5798355377794955123701957400219099084445320649098160676634081709871756811646599691983924512899\\\n    8438847040006335703918866759677049326364293999771016690110973645051017123878584914506671680730\\\n    3995597946636861398980540956696405687973958725248588485631814679767072780943250363861274214674\\\n    7297242366389309146775256628575040015575685066368900971044306922505165780418749870955838297573\\\n    4886951513222591224372392259657396551768898762199478071189236156553768029597210298915680686229\\\n    9071344424084911901164805201555582864408046264167160438517610389649287993424709630140744443529\\\n    7354657041714975962886194514898158699997573857108030471238357969611697607560636670700003029167\\\n    8023392222781924890537801610324958615387319082879900273105659720725518681610597198766358557538\\\n    1231747953171601101945302926842971013111796537390976037914094199774005083416293107504370960144\\\n    9975584268733672557727371619397680756432069485272987332359887781926969040409225605386782548685\\\n    7482952693628718944874493242356238688300414576771832753955287954272413192612002079286806522775\\\n    4422923151176433305456266490797360779392129163038846211881378138430800501771775017994679493296\\\n    7062737747405318636785730824217365838245550240536549861475983428566924184504354202753241236389\\\n    1916519915527812197631016743816503038410800440838174883210548158066564942540595873349859874149\\\n    8572866345539247542605825027267529612209294456714469821615162481679077182551390465808196945561\\\n    1466892219080527862227754618312683827529557217690169537458539836586895350902230093330296243260\\\n    9915021710216737240686841475211516170292610065631640471043764219037595171607989244783541013657\\\n    7060460247590964164036811749121576835429200310373453972472452235823411464601866020199033170603\\\n    0209833462012513091869873456657220222541421936112590699693962995835029236143833849732159589140\\\n    6601196155651551541327348958077223058881914967050186767875316880973830559669752607137131404187\\\n    9402377559489383547079513566238020664138313001536756567194770254045102856759945541336613617815\\\n    9767387753344041702070773103090004392048321380688520855116582070589819429399457680037329161443\\\n    6766792556270598837272627547286224500496199398744524789148347944357738284440392164997479907221\\\n    1342954558046700697806147616384324900812782771547879427312307170300659482075289946559521759709\\\n    9694469043337528357020363583421781786472577318792659334282542052604590561031821371809361741772\\\n    3913925436233543089915140327645793873786334639526291065816676991582969503747832395307834399011\\\n    2872680929979999606818504631629293778560133933061989168103860011333009867786564365171719678405\\\n    4802442546689711365755313007010599349587776357015659093656778743639018624414139147169954622671\\\n    8591395543608289750305302424498008822964656766252699273747874957601086462034354319084102293725\\\n    8179325440472894305329925644570766475495293296378444911874243213186978647918984662740846137047\\\n    3895565503121318690908970638911945385080344397457006076760672618119014278783111904877385997378\\\n    4717673393832495968431021655646452915687102850876974875511098939274174207421851822028368260576\\\n    8140281507774085990728817959041372862127166101778334333516794836245621588607088472587620613250\\\n    9100087638823742528638155736930914818459533024059458831831072463861078601500013012777591897847\\\n    0212100642646481521946253260393962273411037868712760095059343004906058933110099332829876324054\\\n    0778915076707451022662060098364072983445583165568555550882529629722368297918929308705928302607\\\n    5655052995758844162177944247966427913403318884756568487276252976306098091842879268832824433620\\\n    8755021525661993196219458059620539251504874047430314557477858466933140274557208846870064542552\\\n    5590848059682893290385365870656019332693656932992429983769134187107344377662156981541682289459\\\n    0325692904840593899792418469522283629289701121370684408769593847583678608314484560418181520094\\\n    1833420443105975964816872427438244458946717776738545464630835197710521184803595561648787711671\\\n    3467120650712815237086739186058539672934333167908434025428422903823151128089325304617000913402\\\n    3394905171257497231151651017163580913201832902971425325701994594452436033180531916026238331725\\\n    7569508907015797863633463731618653857717879374477441096367056772455758690616782749192185593044\\\n    4203996792942755486789392884032358252727338245229868530829388366813520247032807007639583960489\\\n    1140570066822135909581038973815253853073250934254236252008803089741609717305229957052002487754\\\n    9045644690781423597186882212582490107828032055717527820162392608522732231268648440297070804744\\\n    4790796369429203559899730039233881976435883422786532802018250634899324465488840076404986633882\\\n    5231918843089623712037303555906442194990200325338463939051821275471704231971722468708142375396\\\n    2596816700999408932141938943502603587713289916499594477648125664048449927091546853042918691392\\\n    8957033921586279378442665367717294984703253843935093214307849729024579113196581206094365492002\\\n    5352897006933699971383053566386030486135712833891181444745163607943027604536599436902718298981\\\n    4098417556765191930126789156482372569236216911273301648234016641295715841434052529355870428470\\\n    8263700697063645111420353557023611045319751880205615896574582701937986175494253199547497660450\\\n    8344733453499048527184584008357502850089274408277249982060066047901304039628038719026400729314\\\n    5380150520919442221586744112663478826752004789009711205347149401788458612736895413704744380319\\\n    8773009136427206366432311115978772693071630349808080003761842341579624391331241115868328549502\\\n    0523124652284983816835029935527867945465203422151834167385707469634588615887236157670899062570\\\n    4349650889674508161879215672920982719755571860814902023182137758123606265319421475261852486792\\\n    2050778828395401163815379545189470431517309851295879214942901071176278820032170881225061808856\\\n    0788064651691683803557326226590218111259654769025548486006011022370236709601177867114029167880\\\n    7165459597218990353895480043690192894412553227732333972352770279939732242628698052341964811149\\\n    9577347795457277850573504943883464206783424420404278731014679495206551390357191427165231323325\\\n    6334789302476720943011825473081773449232646851915338081349746005296171540030084516410444575083\\\n    3418198353394198609929699815954369204298918717377677413268989572581688785332989586139622170715\\\n    7558065074431762807220083415009272146657375888271042692151846731356888334314399560033362910020\\\n    2512243997508785449199375009752955061994013493696409993477937095279793261182398914777039973900\\\n    8467961838139107802371201685652356965030082434245504313867677992376128456666452925633015278028\\\n    8935643221081362597987767269547427293250562158696862143041730147866734451357079907548063945529\\\n    4792775358696278026516279160834325306856766416325958868501559018852969330688613391472519017164\\\n    7739314433305923140162159432053858755341483618606131941142673501933717293415067813326576306042\\\n    6172706802947812229674449423485837196779680069101487732204219582498510296576427654096797858130\\\n    5818087864948052466418478352158946842178051530294271850383436179149265262486959861599029301112\\\n    9316032867292339067206625464632039564126206425552917425145794622575513722280190318068399675022\\\n    3330003870072037949562818635379200174016916959988487399870156616875742707259363005810527945749\\\n    0346079429770497881433976206496376268741162680074832031153542944538607758752115143791790481549\\\n    0781103703757806468711915620154532867858853718471746071589856557207982280842252941886935845381\\\n    9359346218395607280624319562539992852180022881096415520704599137376077603983212545698832506387\\\n    5154555417904034467128267641988456567819228959216200146586006845080484525080356888317784246323\\\n    9503104691520794167665882466504281443605160981553194263748208512457256561306210401826430906615\\\n    5834871370183373036623123527110023691265941444697705948908218255757070686146506252670208814809\\\n    6103953485173154240689447585407389851840435183985621901192970270784893510100062072004799388067\\\n    2453019216817310841384321521565711568490966018293679211262867433502554732255211512071024844123\\\n    1941153588221378132009756373274648552599977015374113155319361556155039343523604707829191904220\\\n    5165931987917232046014940492454683557332747296111457513209849566733139593839636954212795480514\\\n    4577437025282948818044435284030899540745321080095413669644451552402574768718721360317735882807\\\n    4635353931072355248025173430348861567020268709764060023317664101041927987666742524058944585858\\\n    8579564597607050023015634670423794322789323591110601504492202809488488754677155422835118113052\\\n    7662682658783734036762257073078726113028638632541196544385531533712231924488026458688998643408\\\n    9811899717878309859661264020256848392227218024366124498181866182577836176461879979639031385066\\\n    5030721164891422501650152392787535782065616767098139292347221530087713109649836881306200698815\\\n    2775432619528021536760697654221958590290469196734650624550779871429856739510396945833890173446\\\n    2680428878257054112406907121257715760285719261479815805270582039456983670621101506692230050699\\\n    7650788726309625568337446868262156308396922832991676641785462889173346703627517032822125487293\\\n    7271760628688216785963101977235403410047964899432598419232682648895074095021070922208520433323\\\n    5291780208400090375831935067105549705304091225029629853591894199723944072005928286111379559551\\\n    6071188136595617675031375584533701013778505828926374346944662177140792954372915833445145027467\\\n    5544444415153716504588426608055093304888520819482432114237605726699585357107140524793992756376\\\n    9147094024995299888175190530070468612006832989898087637951079738411959709580555510390414852897\\\n    1033542667656804349446012743127471300546652591862229683033907035141165475615279384293927453518\\\n    2273710084635720440864233948952615577012210766649293695203764389644195149046332355236557248516\\\n    0669250964622068201028089137579015370483388890931749831758683916698808747864268549760939985443\\\n    0352380283247905413671657497003431102797013026702953402822161276430590479989146118245027599098\\\n    1777525428118965979895185673377108065750272787801662449783852985324012121491628417427532503678\\\n    3374271185458638739815472114582482563066090001961827863736188096330024445096707219425328562803\\\n    0348155814658054733865849082527068942990680219866394827169688943392381665695647155443716518468\\\n    6857338283506961800839544367497654423469276166856752774008995140891531727165096001430387657612\\\n    4368746356915254569228130411544256351297228305891903750133957194690642025679801423733260427244\\\n    5220327715059912212605369494610674632196566459157503521939307019233216692428715017692302705496\\\n    2926242226340550184901229253407308579233325774945757320147870441745307127548606944700346538161\\\n    7524989621433539816855636196374359669063464081971413552682850858374203621521209713267339414055\\\n    2674850555448978760620879045922965959047166985159923391316468155458829939817850941500011541470\\\n    5028840776792498910963556286345509421366169504675945410530742051036978860561733811067036608757\\\n    5462504784007649633217515377888265439258761111255945907156891381252854358604552996263363529007\\\n    9818721552633179657280064259073399571025915666937936827973372250042607016360870955766012025807\\\n    1839709392593091222619413508675331517879579071631796750737128339126382448926549580644812030733\\\n    8305698009075393381295220601636382314720823004914613281269047442767847482295882241178084302592\\\n    2862105658401937195678974998720053464785313847986996198455754005553497470320963787643200766331\\\n    4946314316041645432407806805985898816754288239966302863651745032794610225629929074863206489562\\\n    8573672880256684679265049964668064472804658665692076144955643999632537966285990323747370299903\\\n    3082943342562206433363556812869437252650022966653055107663241635946635526262187632446380498591\\\n    4911396355089993277022834694432004912777110241603899839869291170284660077684620982192236892730\\\n    3632059951627739317616400090782863677928919423137395109867996830884080997660055624549739870250\\\n    0551535764666668838764200606702573046206134414453814986926354584480196269467599813748424371391\\\n    6446849886755633971435087302768502451539775150587241960056017344614651327511237537925859828520\\\n    4432329191711258604245307424193144005342146315791016821726050901476044568557891333026970392437\\\n    0420826343704288121165679291567630469110037613031829081832359307059037863949170803478862279305\\\n    2127524609591623144665629578617141687850360473487551226655707598963758208807345170775334603869\\\n    8133157835731052877207820832280820613846490523477336059006134964594853034640094650346737898896\\\n    1266197792913519972989098386066896750792751746367250586591532581237759800679914179914405078820\\\n    5195671293830668536817809368820189200961922268272542409455420587114831936882235400781620595288\\\n    6372274992984662798848942173636801771861203827843235294289582399517260642440623148924790821478\\\n    8110768258008233270030515091168650982688579400949431584426808237905269034439183295463276651937\\\n    0703966954489245616416606121336574375756423125395952179234408508413380103422733622256858781860\\\n    0306158946998435585503913439019610909497448236940477540043298607305060213703312911394103923580\\\n    2679544168621161806053683176952361536737200739132840161732548723892888472138166707807349444018\\\n    8310673908796462511960941802745370770148437697858231121715471935833171914645595648202988456484\\\n    1779638946721089636962577905306196392358366437345974134985243201290754994957681052725993383339\\\n    3145807992765935087579476039509226844186925847153756558469685398312257111738589884043186851112\\\n    8665600706600032113752658739170075719791270419479750876197106832785544800882619058147783920375\\\n    4350513560058778771089110538830803276161127097058500337123960759479258703446810549091019183032\\\n    6606693743340123785857769433626489553984697515427005275922270574202933750165699113932336783946\\\n    7007453490196752231928107982383493218818317845611512421273323777410849770047757098722847568645\\\n    9581138039666424442888487240882084073565700232842608348338115803945807739865569616086838269678\\\n    9856756712730220996468541014128476718952598964649510885535486231259083247318386923799366117574\\\n    5126241175841522936742730137028897602024632758641018341521795717220921497959276831171841034318\\\n    4093139631868820093624093153384071750518410399488843472784756936398821420083873719449918012014\\\n    7688412180571992641536136807370776958147189660826555846074621655121121370695295984430364366008\\\n    0344184540806378696858395710641302301113481848234619218382134954270734528349050966747184349556\\\n    0303375328510494748849072040264954284175913469357468107173984232558915378300698414902533390053\\\n    3853153946846411786568418453270138246371905493309924859599998963231260832846137600913206918398\\\n    1195351975128761221826667122045828645520350915576103402235593941358930367741894291610834376094\\\n    8747510021943185135202199238910549595889281465505602364419959175291367959566951042645661981160\\\n    2519060120858629588848823711428998296586027596118721036299646512201151308009097991093558392477\\\n    8912795347771535421991507020996449447329902794653811542658666113472003540264619386220706105387\\\n    9470902695817095262992083304640122594671957889229713689286488705442703493779167949819683401400\\\n    2719712491708219579705199235841062861807660681783580319950004932805645346644544464259919307718\\\n    4901755853313415434528812136756651876883212999764520716211518024330189373365333481664421663175\\\n    5292455210325324000560065614099830779964657501209426972386991030316312275696532283041635418399\\\n    8981137434731118769283016242864812030189451681072593460116244454369177342637799046931942581121\\\n    3350553071786468362741339902008352704655206386839171906943436576934896830354313819559367462772\\\n    7762122233965521287336175281003168309074589266764688025471053311865178675812887583929317588669\\\n    2259423527829867335169897314106834843580180191850935697296788428695939809210099078879005006529\\\n    8932184510021118522602442423197763712292118491377588660521335363175273726766370672936461120328\\\n    3544483724860698159219071943154241319827723889974300567419392035912070375402072205212139005086\\\n    8057136019232074252185823593353052803398461447038700756685927367927447804183171924750793482021\\\n    9433670226336275314274279138110760608126152705231887577359466211693401090047930606065273806297\\\n    4077620317571044475376459565599779392265080216612453101384539403639175208290617892347280234776\\\n    8421947058834451013650975113112023963672004046008872273863400178996679719718361096577618463341\\\n    8011134004710204532777921448326694379059851782429534846884351002382544925525478993536492644131\\\n    3638326093246649772307340011255170368604503668423664890336871550302585261046394299787304289327\\\n    1990555335160493767041831058041946637801770192478902971258897751088024526029758870392116784272\\\n    7020401332162125785997616070593546460378993309438757406540354350862427998929429394051033989883\\\n    7697504097937832397906254922631241374083826782051989720201345779090057977417144577131032468740\\\n    9992347098978754064831572909883411003351204016035282061732665438956161493883397792984569594153\\\n    6363715009297922675989608021607924267737640091581408036235169250264332836689569684161786895982\\\n    5857807673865711692335501259049331544896829550320483662494080111708821841047465118861040146287\\\n    5405263590884243130359030123426158949715640588437642875172697957682648987543675881158501644115\\\n    3754384599187230511216405938230277048082763016124375243547525581000114278161288896112408279292\\\n    9336596654941799725367899008149188127743728729379607189662100930839514932712937067952676441350\\\n    6621188156842370601543413135822384151703489029580324393028138561240556572761578213702743259473\\\n    4262859957877999876594648271548278554981882976298156705788755896565775303422894022342477061447\\\n    7229390290148513849058806943866462014348912992414173524907893472149197606289451964273920980074\\\n    1005952546880507034931840307764943467848950484223348319433056702615381828284139554919183288960\\\n    7655269726845688253343224209506007418516612423349801446983432607382786588084947757877453825975\\\n    2493337191176089886905272805889749196140418833362158089610685749996462534562724903248827357284\\\n    7802169010896620434779249629113463315453808635390079898632680828972643296225780593612864111895\\\n    2872965328166992021034878331538111528085012620731327135539406924470912212044896007767694946146\\\n    3607941992527472256798500592780740208124095746876013048038583505113060226726866169835698904214\\\n    4218599757697200004902016510579509029851567264506665597755635459567018566455875538221046917674\\\n    3232519326615207401742064785290069057600284892473785894673515378187496197691202871282730537501\\\n    1033700017644957320624685490704527997622977696693051169800322586424725820185451576414223366171\\\n    4005189029333400356477647803379071823386558174016900341882496730822101982009816487573961535583\\\n    9911773345981868781243979530590321308053624014441495929585037359728720546442713348018174267632\\\n    4946389544329820097748043891809587834877324921350671081530494474720513092494103083372711485062\\\n    8712473375471057605525422199045244694069264255051828983004335791054084537466799553608268146532\\\n    5001472062045302494675133142504572136246109662848388882368338661022036228122552164078140834502\\\n    6293815886285066027490868487927755681662059982779207208183646980021139721422387386519166753871\\\n    3578186352028004647199373988922654261176811929372330077895630558125132269151320277004509221775\\\n    8606020689158596595665422792102432407902891028114293997935954620948148278468355841677763208400\\\n    9327440914680159234617160251137089581317078505959121562731197920493920234880431995614128345512\\\n    8835502915015285944065386128204083697059321277125819229437797244068943918000312325327643624008\\\n    7878126915941723367874187203769416236804913081220000160045262532411059897653617381155838027643\\\n    4428644660158119860108602528331493973336803202514184079921289111958392713644592360972101958356\\\n    5032773253483689660095994872825646110380696530548175873783675811451553685509120093773160818891\\\n    2059653897538350954024853171332234066066389815651919208034329556420671232638146155328034251774\\\n    1984448190782285414769327630954797957822686449915984917504234203729499337225639903806102709754\\\n    2522339648485203541012139292820362370473872602217592250437167911441684655537464051426288605234\\\n    6502602089958677404526071428051727398375573351762796125676747255241329840574548027557936477041\\\n    4443706032056779554166437822599939539634862146928670316257167219310806138795792491917111084908\\\n    3735722744253340386116930263305438799807052811738196288855157994152986777503981138167376803014\\\n    8732416416564204154957593231891489031451893963240621268148718973420416992528003367160189811811\\\n    1097407091090268623469590384724420262123749138899646714626041501848266770013271877278041299017\\\n    3368203244877523066514180635557658482539660471843123873352798300057703505229369192610236192712\\\n    7800442244539763483055827137160649577537540931749886533819201100003743173594894746090602847864\\\n    2844111400822139495666756147412707840450529042113652765107097828493168203545904710930251986127\\\n    8910138818673544747681647423091893084619164172961680417857587587255648950657774342235623319594\\\n    4033081158252410684658085400866589844657359545886863254535373943773131520526995050831136775653\\\n    0324538628930451043187380552474878472840113979651068645603171202547035715354323933987438910652\\\n    7471326592698721626216491907226876130141432498246947761991634488998930349175393223491643337776\\\n    3163002112157169339877758027871227040232330728764306801067541679132902161534769429677524473515\\\n    0205005571479421479255265068739279527579864291802253337648521245205155683599879007916056009627\\\n    9041947938530711982075707936489890192503643361957978103469061593881789852051668137857835108227\\\n    9421307276111839376977118247675816351128438108249856935745911840806697112300085907155097865096\\\n    7982602959201685798793960500088917234473239098177584952492200263227478873068574713012299084648\\\n    6949271092481247956107042793487429314390209183477529594168098787148384288124829071826013346555\\\n    8183461236256530728282426158932692144866292994316600907377765155736446627131631167617992259480\\\n    2085640927812070082189444761518990089621225130603887256178901604982681260172717189970919491497\\\n    3640900803453639003393587581177572027673891948434763137409521831152334968795409069859556412983\\\n    1022170884383798885361305381659131111147833326080113095556984380414442356272566003246494287198\\\n    7583085764772304170399708979779588112277443624134585546595655771159157816757638083872685494140\\\n    2300988085991249215214053766336591547280343225365127412793592597524536768178713220440792413801\\\n    4858655451377200575482246348825055892062922564935207766230512677226668138764192637541480733833\\\n    5242319707235797130955281454897090870946296737882896014542982676911331657544860484399792913809\\\n    4139181441311338496779253196532310910062581164615302124201523474632256886298915417460394954710\\\n    3812640901861004618237203645857902479257614956646406102211705777946680631395531404203428858813\\\n    4460072611012585160665408841145375784962033136555623220630337435684222406404421224018092825369\\\n    0615398203185964459453838019330556552638324374361962071613722146710703445399533680479437188702\\\n    3941647711892322385424056812059263109445502178222362338011138895297720168572427395590131880229\\\n    9669674282776687396261835194828271373132399270192559286353773278974460196090430832564496526643\\\n    2615400672509749126871948869388122333532560194496563268626596019522270912026154281727940444477\\\n    7135044722979543860126220968128615582793658440514811853622958907649887774800114197426067687024\\\n    7399366341970384490918274933771854602805279050559177747467197009433784075976327142789873920241\\\n    6833674805835021069922060162090064978998119170856003456212721083160141410072943547397855485155\\\n    4022403802576524834685396761355397641279719852564244927064079646303117098193790293356066980176\\\n    1043488091169340576172081325327715900938690425199562055852842932978861758353711272586138944217\\\n    3402099805400889771878759204589844960044411103880614847621022458995383934665088279540584790124\\\n    0477149889149584417647928794175418507198846309373368870082133492754716694121480475686063486247\\\n    6720281848787169810683864077679596128832269457022223100979380426947521699920503625675253292852\\\n    7649772356077226357867087657281941878023016362368778301244876544656307107944043397721959204068\\\n    4693911913926965504924794668371915188536940886817654690059006073275174773909801704991133893838\\\n    7945991817842558646271359086834891518329227952849494258226374869224865326249831613017976664458\\\n    8164425955962731988859041872225519878818712938368855248634905094839459723926969804364093050737\\\n    5037075279451107233955003655231165920572738972400719877542114548830760689290217879357704297461\\\n    7432036474473932317319052452533985771520836213285282929147778910111574630493540746670885857181\\\n    6028874706983154742961632313044732477202810741263738745761876046962370992742225860462566048870\\\n    7072325627310731969155930119767496326223541916310163406720024154418693256027064530172789156793\\\n    5655404103723084481105842263607534282057960716967156777327602680222428698959125178313331198132\\\n    5855781363087913475945457820335689706063080119967798527122206106501640478645536265552632343817\\\n    7363492777354676268500429161040902350080995351905462269488006181705150395083162251427990752795\\\n    0753428533313876557708610554807973983397924659314952423915792264903091854116462164426996543114\\\n    1053421331420648089881868779371591045340393891739153278630715168559728309653330698158325007827\\\n    4222436142495498965761344283305205403186109127275563785056175914954280320216971799665006008095\\\n    2718209456695427230572245583805812083103209976982283746517557380253223354550729621197638881766\\\n    2963688078947488192857594522864828433537962426402109281911794141726419314676166902696225236384\\\n    5287633359658745914015563344739374857969831777380649666066771019644841293410479955424044325314\\\n    4315084737145927407608322634670879721357412302215380753325396225354004819605993725222807352482\\\n    3990985847046340178049524665938002889767399867940105512637485919810928798857449761030121647894\\\n    3447271429249053145494009542162056285314978672224274713462428116425884631954187132907523783069\\\n    2381164906909505561180844028482008573950183078892872117714035505696333232189713500410488945518\\\n    7002978625071425103590021449196515925001893735679983052302827811173678667382461384021117245042\\\n    1727197495968969055289078400675120605517040782439873039963191106559793416814648610563769067633\\\n    0911008046340826200314670205983191010996356708871441277436482287686879774085658656307903246917\\\n    5687661430930256794975566063829030114601323061909972905678545384960475289010611618851433570742\\\n    6015169506365416516337977019915513790919115292916092731900342805332705782140402751894067041490\\\n    4469997773515902992700422709993304043520157399149966654028734598974645488044558054704138117175\\\n    8724804438235810563304670595009357337075708892691532657674973619310752409492521634206632206573\\\n    0015715945090113676281103183964011616337294802012957236460400951871623180758709664695370467758\\\n    9542344575477621565817894489671545282924641557712057448007750507443636638333278632114617187343\\\n    0831026852059911165958195902057674721952496332078065670321100639282807948670753626595146052589\\\n    0478268545255397446260712672127508576315340237991838171122653053262999342674986566545738015201\\\n    9804985280467634631813725149370082405569600318532659968717578503820291267480898539533476090772\\\n    1818763375472652474453997352827788601101099405018078265302840445656487639513140923173608464127\\\n    8375288338302960046249428731339604594764834434479833167392851268845016507870780491054718794035\\\n    0963203716200613700106299934198922724754574556558498028309410995783524213370305064337574675433\\\n    9218328702386974018732746198105548324884696028879066267391045523559957714915140883717654709348\\\n    2395408662167222488451979709155828207304944832394400232614845607624755758071966929731298342230\\\n    7673386338607523745986546976335292136389667303669294236053602258951360855103089106167238871640\\\n    9077793972244662022907785308095151958717616376138794370649012788495728720033223978867672036732\\\n    4882615202490353538410807049372056197463152237650577951593452967317708955159801277314711472328\\\n    7103902344157037792268771705976204679165031675797417576216445806792949678402047032069930897939\\\n    7982240268771031142092997467855111030785213768245700480320555005327254829912717128115321391814\\\n    2786549095360467346649906477633732024606360785005188850289050447023783191408234309752593654426\\\n    3355075944043861528606732000662789146564343626586550818024264344321096570812933064530385304565\\\n    3361950447880767956327994918467710488301531534893233415455765610144259930795251596089073699352\\\n    1455780217314462436579344212653592885761379799717989229860634301422979123075990140535847010764\\\n    5888988432639836420880729750663974605497883296512938794109781325526585843811706501958502641773\\\n    8384003677614103849224537674785015956160490539357769804006353099895890865484042812917601861376\\\n    7840116957798909487811472473131454886152881061490990165185376577139538162657796880969092629725\\\n    6183545439701335023766856900639727461687131015759306539178935189349549599521513618153537679150\\\n    0804043650530913685906987440269688342103105437520859401480887589449221229020474950216870187246\\\n    1585520265870284882699257331051532044657202648787897816917406757815054138376985219041973819969\\\n    1838221214273199873774567422428982254118635204874909072908404162385613633017306841203957967046\\\n    4784498088009823206999252061633901218664860222108095756215429230373441420295162479566273831149\\\n    1263784843136247637068322837054221179983671467670593412162647992873209002504675329421006870059\\\n    4181454512231033024374508022721952734207900604216698568194332477951341638897032031756855624638\\\n    6669242164138217117840510716946343783958620780469851642633322185508407534198322484059246826182\\\n    1336922640514773814771915465541887965942267972322947243857891959667085000699595425678008015821\\\n    8097396763649742026275508890651623484504288908245023097480291867170200504465369503634319450070\\\n    0490984035364323787828506301174545798684842361269328501242481365065731121542203990301312491153\\\n    8550455990934054810422144169162332910710011301622612322044664527368520031809183775261554152853\\\n    3129968782142978861135774684435732281462400335975970911357829442954002933554931406933837420475\\\n    7673844413363656662141540750095214049535132775837362141215366298949416182433222781140965709190\\\n    8838930131689436586953906442044463834646495205177156294783463329494394704019398367866538716111\\\n    9850187113839192187193128129466056865674362076435478661160378979188213202846735473481499296738\\\n    4397238106989457117833359632699278053900755907075279999350538008065503322846629318336876980098\\\n    1135877995416658660888131889611537789163512453800817411448167763743820351447750444993582406399\\\n    5258123024295972311468672582411621223625113216141993815409221038795818015215567519304513272095\\\n    2205182873169095913960145302950799936630637502943979003796843432275302129201109500145962015915\\\n    1153240616264231369884355194997343865675725073277034526525746718763249346662826675945357738249\\\n    2181613978902701657754890874948258148864448461214589353015261683252211558194798038169934559544\\\n    6747330426643278476281397370071732193799506846955516525069554810682911542776035800375373267800\\\n    1731838539300664530163657254516961773336805712471760377631429212068043932376726136664419977955\\\n    2743574751559641041118118572681001445991692491212222776349510030526476299071023050607810140496\\\n    2456636149756442659150104549977113500578483065986299038360960493009764616584693706461126784157\\\n    1374860301777090634159213529901190279275184984142935565283656498245384390585087278130505161649\\\n    2252558416013332164562323090393151536725523105889056297475652721305571308670784245512302247255\\\n    3844367294948704342135230366403272071525909145910737605465546929906298886004700726506267280138\\\n    7684206179709494783017380672538321603726290621632621729778807150425409140260849326707129537450\\\n    0823472526176123649012848470618742486059747957728021685757184482630407950412127743137158678696\\\n    9665370241942873028902262443243952212860780666878820339316685263664250454838355886622222483094\\\n    1396760403654054869993125587219867827001319555343778654186341526332086411164928223320800138089\\\n    2252816642478336401116584172029865418983186038487568392422954090729831320373332097791257975604\\\n    3227478166690231137529904262356496476556789627309238138821102703532432752985812038665565581620\\\n    8041976553656407372261169375789083335281220355319828606699663335767068934540996241722066457527\\\n    3022771453173028271171188258284542269573297034776661754941896106477563839446964443361180752656\\\n    6778073728440018230222361899443734900589807256319231611271840737764787280768842324902174929714\\\n    4716650264072751331988098131438585120181938862967776419827369765500934159771369985817055073086\\\n    8777232999326899076453845087461563174746903830565990308848904594165734426323472241310713940995\\\n    1614274337624354234571787634990317955654844799524191026099785323819795693131479849622596433978\\\n    3095258620043573230741845563026591129780595886510906347086447220491822047132326273213754900204\\\n    8322328602889933597071180175731486874190622830167454735784488806272953690140478994705475003526\\\n    4746555819376796096058582551233642434738693868688681498739454682470843090451675086423671636080\\\n    8489711827539188063266797944760108271104931713750003351993757893244593183997607749392930953445\\\n    2001214766011737509284582780882802728940648245078576591262556554412207943455519014677962535132\\\n    7737545243645110344191932674560272681832869821684286038778512722906202483625056934637989016365\\\n    4511529559225710187792945985973824232897012868981186971297338549300341181193401256494388126733\\\n    1193644449199150835665571100172277446020043649603932515823230909381602271060069911313841304453\\\n    3542515915235267616985906695786043677738238024824673281553535300983302916692223383337798423605\\\n    0294322624571606680477339870425422853062923702935954408494715694842025399231958033215249553201\\\n    1052150123460085228468666436792944286867150517673894209843312312734459397330798583754703131838\\\n    7347240783248651174148788401268643825346009462008708508591128118906379013516853536047953068554\\\n    8246857559088886061790087264396223198554512097741809861956965753619976516768235535679173127056\\\n    5690065404393158866896679054692671677831747383247910047393196725345089419587589808890447987485\\\n    1096407806907134173508107285921554371189687653615785457266816776466947383719035083383833212553\\\n    1878300825179044878220189432663623212985970370516327847468890013227008489681684298357660560999\\\n    8653983454278828693863905079389602234217345658296605224320636355973111764476197578030669321021\\\n    2017767734079933224620134998877724604226716541102618321828600931006478076333664446231443138247\\\n    6221862072332754840473053829363261176036148136066874284929992582868355431910035542005951194319\\\n    3513941738897111045903669187502132534406140338303259106632469602840174692937878215360576485573\\\n    1070304220779949377019162250591797884343231645838512335138999405187947304301621248809146101057\\\n    8730106538518420598701447965686069443555593970860500422636942961058128083045006147225471809204\\\n    4748261041762979003975619388082627020349686286660223587140172887903541352943513666314089292276\\\n    4993614636913885508235343352954378868714845236883465027535363383085256716208885541182437855094\\\n    2446248627813806125759852561791579987081932633268609961098662270060594647678708091108325792573\\\n    6173190887673092689092287418848896960999035919034783136358094557457478678081886894628759915469\\\n    4417575663481993914403253996849995434282610446743737300711065410730014611219016333269131661932\\\n    3647993719215975191048874133225966553396655405238306192420552950803950229654266615935089157419\\\n    6748570941267643428231176652068209108612364431197657716596013578673389358243063478097383106805\\\n    1230447876309507487673613608878419459186411178177879385877102519623628106952343411589760211796\\\n    8508828387406768201033029475203464603353989050513492540102636009205844216582866386728812319479\\\n    7298201624528442648598604768729205780150665009214671820149874418977683182022831095622887865937\\\n    0118076704409862427098662857651055075325964530232101403270460460891528816506992179860097112400\\\n    3918232075389504127762905958781657082910362656388481822687818754396751374818350972720922013286\\\n    5112188639007782198038783261916662640279390241267368279113504021414193256586857659585234167173\\\n    8030129900375073061502159276664817375939822800982286277565375763237342854095450724380941049070\\\n    7119407521927559683346651454182407824345114929511753633884319381443143718512722461234617922207\\\n    7342932638448629031295610660627880247741185074776728842034250351498730613517556390605428560563\\\n    8975773063431628641893421102954939397003887646277689939166688307399758995036925500664598239656\\\n    2102790041888224640628140720163400256169061087238737037926243249830162731860916964381153667321\\\n    1291561078600283040526467304579634647102127598167087296919725222303408722411174139009823327612\\\n    9946446844263537031334735678981305065202812944296266266935879197099031025305780760030672189643\\\n    5008976089341215507015578862249287436393775145491852259332471621203734364559140060323553597215\\\n    0097451406581724246194696498138695335235746923098700255971902718677618710434300674485731419269\\\n    7966815804484760029115910649525029134347186022351592008541211613786552065583257446739245978809\\\n    6364820554393387353404933666414532089593288020779241558258127329892278325787694620094892181326\\\n    6734184245669587099070855380241423312420650370678306563989009743566684390785368249622758746587\\\n    1560022076796040422405672231048236141133083986829823329183188887162876821480830526805450134199\\\n    5111550394178822657670068568411544089249388802847438153250318158231038154267642599735105213245\\\n    2988303845112473778376494282329752336734024969470652577580199904190872416332764705078902381439\\\n    3991003371053441763085654792427530165174381857952417859073904296457210096014469600059674336555\\\n    2578321409588979439953355854131899149727845874177397182464801237454953424068216641243675319677\\\n    7000626125510834360634649378483857711910102340127634371738498017427311755800104853217716178473\\\n    4824582084226876319270914745740622959399857458868805104883716487030080830402109227388763812810\\\n    5495157448408182747491579486059742913570941772396585139017169397865490888268960819949095571090\\\n    0707836220067096217670977132897023054091346927964460624464113349776848330352018878387157761559\\\n    9613213356415060976768388095492258190189666215970011057908086253213817505549317939084792418837\\\n    1414993762716735628506289800543825133792522416584601648345780403245677807441489890415504356109\\\n    0829011964850866376525103029878368120474332167407235578460169585551286430245657086220473196362\\\n    0658213314297163781717447363655293363175422160417861577839397611595412176827431834486665080063\\\n    0601560289518362304164755993194562331378717907595471683854573084870953068289961093803768299833\\\n    2035980817639988774192029399444777547010380028245862147526104734910183935408631315634443891748\\\n    8096681599951356810859134031525723471951867694638687218975494884865310423965206897618057755722\\\n    0713650724572488520542222874111074281757142760461402400411794349491372246149457651033794838799\\\n    0612839883252836302126931086781141241555879475782057050313776418821740075241723875284520586119\\\n    2881749019359358898209200325553542044493811829589393283782679576749250318864218409475942949232\\\n    5593865186848222901441748708290600490543432378557130820226808276428995428611967534263557549606\\\n    9889938955548643252887678827139758166536773845774228160271366643303699252948751227212019506256\\\n    8688087721252625584283078428482155478751492842165876907990558254379515461320861631395524488878\\\n    8245409441159124271756288504462457578811412706815425779852147779193080009451550794637013516049\\\n    1906310535480834909327005095149132432191449275574528753268337536328797575432950664448093784343\\\n    3085063169982701386537392679324134729942672979696690284878021950876995257363765247708304171198\\\n    6731341842651046834402354097961479989289090087933374457838033382568865761543224589895798981138\\\n    5891799696026324817682157661976207758404846187751673232111673174686376285704872138831387867091\\\n    4635140146506455891008640964137048046015716178592439370756615534600199381166880121004061389205\\\n    1992322716927945711824491648753339942847846558531546718025983479809456445565056199852707432875\\\n    3475725742762873803056792592954151322869476991839033569443220573067192554725432502388374544954\\\n    4181821445410533630689099747531531319098754432889458187589129954845622261258781903886405474514\\\n    4751059998268376827521077114557373743399793887411713981652324545390633570361845175227315759696\\\n    9297479599023524301938742373226560935379188423670759662967491745248159744356182948710143869778\\\n    5062985848804480322697085982065511307785504909585003737068309193261554617288908502413731284670\\\n    8531263977467944305806603479548114749290966667424357952313311465580602822881792679592049198906\\\n    4304287887774207455633634974981975043488951726108041064053994812153421501554635515147485583499\\\n    3114220472296288713855373115313925624763073368274476130014739304878486024900387123292492178177\\\n    7085249878618135386868747800775693093976959229348718890502242663312296946636752802901952549553\\\n    2313286083576523662096361463930157507980742008202726244411278681785742557355350952027002908591\\\n    1197936954062807986421391681339299682412911311560378425277498517206058002099341995050856608067\\\n    0936229988560119952374688051604931600754630780647022831411412450551198674132553956660927980694\\\n    1470143954861491310265624790372465830912553113750371285592742907039765602200095038053718274026\\\n    6707779822382521112279096750409831582516585493927010635261359546530390373683934842811239771082\\\n    1489258754822485043937882633391241044314686070581130928823593906961130876758146593791771793763\\\n    9827004483893065191399305163250287981546412695248038094103176366568576956600011912523715994794\\\n    8440889604717690057978253205087560211199581593986359550033723296123449303955667685988492750775\\\n    4833111362623386108980907806599555949497776272733202877832157845116359946853362437152142019528\\\n    1226692073339740341853930469673164440355202090600015099426386618884041226101177961616705041538\\\n    1932877915394996303681988854683851271604024477972778015480616057338813644422250744249674536384\\\n    3655367577272026179275648315500730257422203086698938127468303716147307049038239871017104700642\\\n    4425157323137061684126050007819348491607990742937428745782885268984618757432945755184941238589\\\n    3636360426695935113288548926418567696647097430373122984246343495107101877205124452931779773014\\\n    0880546534623694698498731299653011690923144313601177196911542845354267193315049738559302814525\\\n    4088829012700821246098357103343071916632239096968152591741743170116103735445930083108123552076\\\n    6450307099622639059511527367950905894350946489964948506700470180597113734576035834216911431265\\\n    2868103622971280555782386014800160165470522858906031068049674329883533643088784372814000397887\\\n    4695311940113701552442963951516478029569311083438189618382532301542274360219719080012704724069\\\n    1598523590855346354091604827824770548119429209129561879844143807207788274076812320263173224316\\\n    8585638647186051618854298345850040600008609368505236697285741666404187793023725784177339202893\\\n    3554146809219300272752520913379032634248411571379628688462646125146105050803153681773368649991\\\n    5148028401552447284738700649778987761008713849462049672597790898179947010905671096785947728436\\\n    4030872009705755197477029636440753994304378034336207982997166745076785983357633915672913903185\\\n    2336398541885477877945872774274748458037850332874597865970854171578966641625506670173962692069\\\n    7439281290130880551887252448425428157136645063183730576215295781864594620174197842315008246121\\\n    1290587069917028976137784424522721582058537703108186214140241219400496058948572831872883187074\\\n    5316338220010848964922900149839256216448842853679285127502904708371633308172257798129723081903\\\n    0069333910527263137623641939985873738989210984703712322266330660332087077564611327074669176159\\\n    7343091701837040219158466172865921864564381142977857269857980684098961092351052095676553195494\\\n    1818564271820761232423697304520626020119965487550361573734420764425512222440428386952358874237\\\n    0102828899801480591986779788073101233083666289037288343405914901005273624655199814562237250992\\\n    7447711083360267706832907674851543695566548204588758413321034827311863796471565222280734463650\\\n    7967116210465640294497565078109807792518304816978099255474123830274833862325541740566052881785\\\n    7977230759824189687510178193000467854171046415790510097027077132983886296790096132097614950842\\\n    6983661084112677098434788101200440287894427544071067341556868518829876298152195219077646409100\\\n    9263553284313977398301624540908117984056272763695117007472272640843619005874090487533484420643\\\n    6666335479108284267020528941078205495942099615840404899746052925589612646800148313087232570068\\\n    2524890300088621489028302041194704293751111795631056798063093650489566786966169210949486264037\\\n    3099506807912568827161783849698895282351575851708754428443204903504054947125634210760365103716\\\n    0272407079217120522045000159794376979963209997925207885212937281690324400837042116903194908813\\\n    9026742085485007719342986133130912329440108292229114395259310567268669331753978547854140743408\\\n    6483161431434489781146084495271924898914706638861781686827319022426433262301807228862756144218\\\n    8996580490990995052399033600432311589004177648797329968211930166638495751761802512253798081959\\\n    0458566608720673869049784934213247397605468758316558749259617857136239762993967992650414837243\\\n    0046097423401781618529475851171640472276830254514877046921309149401663161827795987197356655078\\\n    6555169407891223207605963734370742356342993089461963139816412959102030305821367920191009582345\\\n    9234415479405738477919414657851753192864065445615385841664601476342619861590095043537979265337\\\n    7116699714278859907001378201167350871314096848923409378280357870887693517401352442819312469509\\\n    4003924618058387565523983120173873380369196112956552158388700075199566348824479848186494516062\\\n    9778984332447330382371516270194840957256382407920761559288333290795977290707450739304722950985\\\n    3253003812667506495661812272428066360729183874574386475395842245242219971339686947126596994668\\\n    9435565858234434193129496729107174658550726802243716481306257242997059105270990496618845285425\\\n    5388472350459971521240154972715329319372653045978322396304798953215562832509791640521826888927\\\n    8256036723276069786338922625685717041962697036743839132106925988523542693838850855247013884031\\\n    6853505151068301208829776266147235554197678677456941221822136783312252244214735921731101214970\\\n    9834208993274423882525133687389826176990868625400055580839284389058107572730890929466341395730\\\n    5512689881012453341129479265728382703098388154979364366283617901721777513337694608438770055850\\\n    5091640042211257842646029082716489402732812191427843549235241436802225852420946323280663655549\\\n    9041042631755768666657467655935059912005010271059768417046783507354212314735423815554713477886\\\n    8903662553871108568419283102841750841848462367513081318908002590802182066298771047848184172413\\\n    3294353241270382263506358426667722513139426649415087761986886287056110048410723552878285320088\\\n    4249056285297973257194038760373411663182986520798848284610033044364058317763951020809959878136\\\n    6039987516104986291362077187218923661349774182167187011889853411940334672966964374675800007944\\\n    5596668606272791201948267198923108374694890610469808640533381876709205716948664839026765434045\\\n    4528144861407875578670584549571786638841172728147738817596507256567549558082271135295243422287\\\n    3162292873266615284332753280601585470382405647683866802465304314168331178681379424213165351084\\\n    0509502893609322104381090650333422756262425152143344565694710175516664815412851377445225869740\\\n    6025256749662266454295243312148814980628133484287319514181739070321562944408709447117191178348\\\n    2919287437101511438473240364472048823840895200337587792583811132200840385540598006924575391710\\\n    2245895808831896032554105450302685330159471297417066252685081636542129763320411058598771914941\\\n    6819613177064222562873351855418507248073028864297336814720583695326969541895412290640232848078\\\n    6251935019891602161547528539316565597166954421743487369393220278517759023706955600342560556973\\\n    3647397278308873619085684603287389730685136672162339711513901158332751800168815425167522552195\\\n    5573925057989063985143636252894124375381500070333945450020407225868319664427793475830987138540\\\n    0449391004853503663607458426095647881624965166442913049631707838074424144027566477604426780489\\\n    1304384579583406781952237646581448316101101818515020864943148840396412130363072822775434617957\\\n    7751330794597259562864339783435610441689024044258275689457130778855554434929518224901640482154\\\n    1433197848540119255601066895419262150592847898719324815053994210002385258500047413083138539558\\\n    9322144714342940392433873294205203253713587067870446466195111741727586473524642270818040310053\\\n    5905218027305203726181709939073128028063761835756890686779284526050277403306095552397627978902\\\n    3192700829822137286285075098360313211530736275970364765346802910049508607334693478461401402887\\\n    7068553790589839013792412640015535517610931319513583630663020403189212544361786141308282015759\\\n    1571406295928317338643894037820621501630383118788308372429142752024863370536555013447884564670\\\n    8442004269320071249943409975188964009456474402452729679796878365289258718411556117910965886695\\\n    6690847646026376322664884306172379952297938506454032951277488088325388540296697602660252724944\\\n    0787760389202392247717710885973331770830990175219466014333864829275715297481877860567485325369\\\n    4949578173471085663644859620748590388464812123925069345309311926550800256384341524677296501611\\\n    9348394997340592517052474187966692442359209813722956755962471780235073898962214994725625459501\\\n    0760906516781558123116643227084845529876619215812933117218914560533994540632079978759401119515\\\n    3395694786931299339853008679779946527433324253633089312678375484888209946374481226456340077247\\\n    1777635583526350891313719253417439410775135316040956987757288887800758991734596253286194974188\\\n    8170799823171161324801866979259627406454097266811122401851157942642535512952096610135511900409\\\n    1107368686027868244061286920085785796045078974067012946022819541788779462989226188039287168926\\\n    9597604097027064004556723112810453912879424636428579397779086949472844166809190071269798919863\\\n    0656196691599718963828443212082897796214730364916216797777194276525306270671382266725208053274\\\n    3893660067949195600095475555136220802439993005332751881144628833553086034981799309017561134194\\\n    3574731246189572086125818273639906680947683230406839078017320201772459213688892626515424675791\\\n    7811512936150909092028155588242129674351841970351981503192865986647111199539059099854964834276\\\n    1676112003695538377413319007237909221412743955617460725767145663640411108028850236469263509768\\\n    5636765879688945380457996639603724274655947935829877762122623089589302765766720849683296591691\\\n    3454882595625270141236176405937909975618545443901955540257466852343545641378284017927409996695\\\n    8247338252694309730747873059116080834099031134216070492754842275532862973649343321636768385283\\\n    9150949714896873337928524674632131021549545694781580754118220208255318726594072857550267318894\\\n    0501863070331454605328754584666364994385135073091157990168400235891804791659195147334038972242\\\n    0800066814627515710060793060407570327275422550747984459068473623342078308386355115844137438691\\\n    2092853702493224762455269818365112624670531838521948584953490317594631003513761090325389015329\\\n    0648936280143184848857751535525559378728375566595412981267534717397265549763539188614875749620\\\n    4793407631690013779096875401915181985524746695747740687852091525583627887404389561499633897242\\\n    9431068832808334830903440688369352303200547558942520093642994027116480341346130943609676816024\\\n    7973436966690772872415801150346085731638224299997708679735387763421868567470745551203632381578\\\n    0056969935690473225821679394175911598758106458294235518526188794804697034983899334140143944480\\\n    5534626455383345098788723511775373283103860829300921294538960744740009374633612837718966197363\\\n    2062789082544150245486487798607768764178429227466358582579480009241165188615342824353223671950\\\n    9373629087499948844815579064138946674892205975888852544869485325001623464758950079550973589173\\\n    6058063026392742082681514918830685980783112688504984202464196878808863320990229487874397171495\\\n    9350964982760107779110793983814448200541737380548195188845291942750948138664434498067914172350\\\n    3255468253339190466728872161969390639397759505887802300762745036358599231765044868005524721959\\\n    0445670925953809762228004947514693298884775169429002200255010248500386079960355791972911801792\\\n    9318593454177299828872945751870209021776557344705966625330657986604920980415135641871451108353\\\n    2076422683513917621033546430098952474920528672901449186460849103759443111113202340023605941906\\\n    3019128754609039796954671863423701690981129445615089311988557344405500172289422743588031541901\\\n    4286609541908793975819823241057266331435478220802355817782679838598883800077131587962135628863\\\n    4593414821289738729080363845997192621384089747012325330308708932197219071894423844089495185463\\\n    7733649426874821170174749262977747352868396926623161988332118860196063521513377607854936886912\\\n    1942711386782685774118655486686181323762125150757730466590708650805213672667400954906673236421\\\n    1298095889505675229375628835210052546795717110870215750578827889125758420606987196379876444062\\\n    3209122108417027386621384319744521992484062390421001386791190345343185703185813889051082697023\\\n    8304015633603734168006124284685988580996865861591741347291552468441939911427684492906068636243\\\n    3143552951719826412965562987637691767380653115170031264436928772925940913492635734475026933535\\\n    3452525833104228877274077410741046031129237549242364778096054295448503518975568290842771586972\\\n    0843048624455214474414143940152235990711024541114352352241911100073273125562600486647203075564\\\n    0513459080822285257878071237474948047291332205313781240452632131011964188298038362456758194416\\\n    1135451426449990106958170999213441817539853866761051734879516970953856354332845327912839009817\\\n    2841713295886514014430656956756604695636030028882040979085736352267337397547715742573602436230\\\n    9815608647034678822720539931356779121831619329153852482141626524173065346937164189611499927890\\\n    9770387580718910954462183447857885030789472146886883140446083736977982197679157966967734359738\\\n    9233964175793960482165257117513522227545387173590197234516614943978609911674458107418227404628\\\n    9394786165861556302409811034916095757891622144230686545234894236214340730713668469850603433764\\\n    7914861079468194886314228364749884456939783949521377292882630017706461787620089349586642960817\\\n    3461557601283636628575191617245437917972640637466669129972822325602929971761194000161591554878\\\n    0331766810736089597725803089115551738979534821580232268478750566861556184771540174668894587755\\\n    3092874847725444054319873728239387375169819134156825708054181378636705022792258559790330398460\\\n    0384642242045534839601990475648474048491356283930392305876814704131598747147986740656558636101\\\n    3672469538476220593856864730361005924018319164793759009744851785567438256454486953527593472937\\\n    6239550056051904523502708169203774654443807721144847024555878019246626824483692286467714859321\\\n    6302768820294468208467761776367964582114307012923925090685094678900162254686296092106730078550\\\n    2337161572220741768222346753493266761951403116852334155611044822550552969932726148995738155087\\\n    4871185338614801626018288508178567577009136597815057248179622768516387830453340936832674775488\\\n    2288260288157574018795845919058167892253971737055457122732562950256254898973250550823969214271\\\n    7304996959867359756823956147988861902313133149418117625627947068069776592964781452111535607497\\\n    8874737273208205316149095284150830130246302261050091535212036731697010819040150718212417071483\\\n    2945354986429291740900604003207638450870025112577651062797647948602932341342039218351242070995\\\n    4610077833113805785668547908676776803072261543184686043458724660095234396063067558980431877468\\\n    4600678525871190495105997477230193528730977191689111856520398733941010470172910992272112678536\\\n    9932472247511541076057686494478145461958294082780830430843898068267824779037642199878327301620\\\n    1159022742525808986796825805654523738384189445115268602288624479189458186190943071012297824448\\\n    5110664177712998914941699014497482240170820476123758451984455593023642564760494254451762550649\\\n    0086832726320383616705412754679308577207772886144909167279871631046444370270545599447266973436\\\n    5664031684666080361877508142445895567702549590136324294701692869980690520845565357584629746405\\\n    4405842188672550638583841768034074575151675505532838095171168413225359044922838433827117640888\\\n    9519619402305440830805354121143523402307650845805601570045301641201922130860082322526788216609\\\n    6713158903867288183732684755430753302815301877471726754466875732957036153044309829337989051300\\\n    6538753390574205139340861495144155446473093463890904842797882118284017568576955695692908251925\\\n    9330204667662492791047174708448127117633844651438520801654944997752364548954340772897862912080\\\n    7053321116817317072854724416282012565033306019627518762431509068707599348084296007555644885734\\\n    1708051189857118579693410442433808159615574222982234348125513494118778145513877514182861847498\\\n    1798536640146430352238181974898201671026701086774232744451362569053437022760500630527817640288\\\n    2682679029355304474605911516224159357045123464818767995779198368035824794189673872197504686446\\\n    9372144471076864839621879001130722168787969938622407423317563128844394684739924080885504780076\\\n    1993313530347330361471212811948436941671454443704693387839631725066558816804563459166946193204\\\n    6436401358882044909622772657180937601202343935289833766876523485955254654651082041026695300487\\\n    0293594809008230473576589525012113013874666936566541207932293601062025473835112527870194221835\\\n    8251776664851403047474319800554300488339284228785799029732786070605222372711810488449049391345\\\n    9838286468630073054423592272876888772582673803253882594842030872750780218852661639376740750564\\\n    4796136974407232026468573561952753830211469148783182433799756029856599106420951019903268026052\\\n    6496372647522025138848902887265274249236707330687430814473909080088199857692672608880187217275\\\n    6662277264390665968365413026638970130976544720861027034493029454391093322099987259960930075335\\\n    8210298758850587810742869416255240411424165760199956505468930988112316728455816930100377848482\\\n    4211579131939550490064549637804380427318108197702513344975813444682602917423500798381314005449\\\n    7122113500234232823875422887907687794448232700808238268706433789511775083404222460540558834075\\\n    6209606949799970054861276214701435482805025600294308058686307664251023419159872703898312870195\\\n    5930148763777950587488049921386936515117676668133210675548630328368022531582773708100180576099\\\n    3618979915126682536766996745757783237734110868812891726625680549995796834461117222495850074777\\\n    5962182829944993907899286497683625489856944068423814424230268615512099878878597233410942235509\\\n    0302890953242462883818855035423980987793279590008776998329549776087192586813854656630427540028\\\n    3158734656749497317489066117387643310365888304451162478334633403806444053802131235519984795748\\\n    7531222379626904555785230035759607850993094300429250150807167625432445345735256731954259285050\\\n    4458480350032894085773076815157666491432183960993373435811503872890921354363110997583801223604\\\n    1317926246156638140807408757482247766409131163697886194656238836376553935501814697683323789851\\\n    5586477622936257442015126922003202238268616021898886851684374505552604229859159990817289655415\\\n    8121300401645188636755803431555695504028573210485806130445979561747613138958894367283957552832\\\n    9126748501106408159668729335465467073353628084491232404232433878058990572609087684282437668926\\\n    5919287889824322077076733519741449761573042454231262343479714661166425684064672976535599258212\\\n    1148725852443606991570006219745043825542642852468054527398358660134178827117758759143919513130\\\n    4033371052487035066457434237055283458284565685736542193456004132106597679379725366550078430912\\\n    9232048472221073131061257965183235527873535637686165100817895123484110621271133626704007795800\\\n    9733905059882070271093577772707171846631812387469727460626343251990195325694426246747201212961\\\n    7318214338137206835829462539022490605570128092710518725177427378414477930031370325735232612510\\\n    4565898202380154662945287446349915570990363128840817873392804410800371214853837499361422144892\\\n    1498493585925464110758083916009852497830360433015819165639657322278290711946826669159247942710\\\n    3625146086550081035429801005735057617321469312158705411348402839661751468684779002716714033098\\\n    0566366256757513408124989755803643939895737147354006581707442221528673030108776550813853707783\\\n    1405489056276392510145314890279948853448880264624072250613535576547424197342429507922598191147\\\n    6983108122845516592309484198769708377350152759182027473719690620588011118924883644427370117343\\\n    2782812799104860832517443156843315285142304592334679501798155734049769484157815913262217067897\\\n    4208822079271625703613955860716614739957446338694297217435605860924837849657830801493568932760\\\n    9318367772551871548224149579664786543952543043383958948272377201239332996041436640500417199718\\\n    2154896417702965505544887061118621555442476616981703638721018831865075624588281718758272146824\\\n    0733378513641480052924781617835884034774706378959254209793471003139421027522923114336050404709\\\n    8269950270605099533625225110516365674936037052968257633337630226239787787250383928500059338498\\\n    4471867354743908649022302207177890753948084358015946927277852642519230821584573824256672839676\\\n    8281195240348094795494086820429581038649475093764661716555904569115856808580870252509573994378\\\n    7522226051032062090281014055589098700556586142776018683421625227387692410739118169019692331123\\\n    9419780564948066689338333231861906305409149708768158950880867001596166260532254561106180033787\\\n    4417085649210044496580241223087771032303537786888745653696694006104670384159564869039558745835\\\n    5507942399768770104831203830576482273612282237431010790533562791438477686310114545934826767199\\\n    1774726085671223718044805011456331805187330277426321889267005912386811329571221113071196137550\\\n    0360825562163324643542629629950560271262254396137269384663591615280637283743417606104694776260\\\n    7778214329135502287081546623846767561626500821662279632622013858473563982568007898558578292748\\\n    1312862194797407443321888463230264289461164279147696434907272420748184543592109243542029978154\\\n    3351731326098900422568388872625041033310784874395525501998395931892012199150656912214489550125\\\n    6954563643503328186839526702327778035039731817479812376076236275099624647682547978695132419038\\\n    2261350239395986734909895944898803439261241863066948760030527761453271083064809026191636756683\\\n    9301520598094028977755697584067854210033517907386583768396066595064962545552793209167824077535\\\n    1037070635053332678334641723903439880418878443828258181061281287142450192143358733458617730018\\\n    1097004166895450304555987121285831343445133979830345669500485553541513015181760345081242547902\\\n    2923215776618108780905101304068658838472180424314194131858266803390778940391487016302409661424\\\n    8159718739442964500462925860013678736389465313988904957999097308854915936842822674457183764059\\\n    0610157904809600910402929072401036340333838753932363214287698039311230763963266051728020379422\\\n    0793129688323177728761231437979107112262520468616860993953375043655072951464665214779576950433\\\n    2794183908328747231289652486649935335495112505569011070339669402268250362915021438895966220631\\\n    4067807131978420835255968722003992479803039619348583939831922736817428165805234358626235454049\\\n    6707926980819274050798939016614627839558833718678621763557599414870191607338477385458438275641\\\n    9384845393765870735570178604360782816818651928781868540002691296476251319799814999240743537284\\\n    2107354386733260708717012500251453130984561323676978888913362481621650191636990016495148632066\\\n    0713565269244304755209676362949147278499970748599487783674034461016119366231922958595293781426\\\n    8513959892420996103393623281089998859321010522115808133352274241943800365570461473330633223438\\\n    9553586462721204938753139217903757716747127251593656649970111420023524653612402894370949087610\\\n    8487642647336383399317583666192486851783705253512022549358734781444970680708408348655936343927\\\n    6680156473110692738861594222795445407054351143455321946938022569915334031048575477042692826743\\\n    7921270132141372617190157886980855741072992068796987458007595457078604414851910626504255860776\\\n    3804797211262201720672187028684237512902006670516035225702601335958144631840100840361238488982\\\n    7731897990925133813893528323545291875213722757735536750914271450569304781313046216317279669623\\\n    0910917450438603436662167799123964812906884187724559400021190914259887354908740889812243115798\\\n    2353289113691348571238399678548447160985545354301991856306331738025171410084269137778809056565\\\n    8043991810978742315663074035735536138451887318106192314679833737814458565492133835735010422039\\\n    7962700427128356230311758503707317608374945343648366433181733960744026861751020237024924303511\\\n    9222015637184992108263116624751205624981255028294148352130975424583311763843545542426735085513\\\n    0168544705207445407087201595527109733695433156694258548536650208377975233762900080383886585971\\\n    7212150244724173318372124605814851803832409881347623684796354281708688233722765817535591703322\\\n    4978479264973755241079064828828129643807439760198624796687411820034927857679632521554838323857\\\n    6147698244485412873683109450240760538561110591540476284065176423226748189317420734027535089366\\\n    1791087363903918681567381021318463825729243772059144428565916239072961836772091460930622053060\\\n    3329835668142915471182379452231819180114516699883263949125453952871579313023129462159420769813\\\n    7286652687455522665668562822706313590011180927151513555544106059230035195257718018838455543755\\\n    5982672227419838878242796057328325759899082007838793234271657928419744640093497220195871266048\\\n    4890803989574161712666202723445994915689697506616864831567958547331631010051488523529588164812\\\n    5004193795198507182716696114576669313299470923294949015037737923874404818395381443663283980215\\\n    9485109240868519505260229513323782095256331759949594018161587251596140789971472606610308090848\\\n    6967603709347181049673564010686257868270331015615216290309334172373071124515681205249619342229\\\n    8310985456857061261075056471964214404333734116438891469934031843405322088372550804731410270981\\\n    1905044868360595595051681191827182954522816506134784986613710268817134097603069174387237582025\\\n    7740037746217740853140902401753368109995875576895496287425448105360837186607267985020193196861\\\n    5154038473882890378150768776061344253676646001434848812069344013354140331666457527490866053463\\\n    6517578526963761609203060494957802196775438006327865744064351518862497837373561178697688417730\\\n    2815035582814671458296834231181633259819363033097031206668847227729465970810871640341630996176\\\n    7406925359850282464293705991972277417251746456968860550833656512852261754641846659054258722513\\\n    5749192955551574669442606101844673671123306984839618526870562207870073656355616583888718402695\\\n    0590565711160142121078607902659652271464743187737902204942214009052937554751629611812980882049\\\n    8604373876809161385171315505241600326080392462068454508144238757408405530109735162798875193653\\\n    8967255060574722884175572056645247037004188822857258949191418537791026692768966829197722173409\\\n    6761571513732806873614683113679573359277899968485928444259725998413480429646638277628918828844\\\n    3486034100670713546278477741259077313057235102738020735572250817657424209427415598040077015169\\\n    0616981906023649270713965416397111608193509117666862912006825948669208709493431528109048695465\\\n    8698868716470568257557191695996071498668202394382503164310895564302015549846733534962313145289\\\n    4151519202069772127469229889108596566629129549662197755922525336296603504221566821453755064614\\\n    0625676802928093636722749054122445474544819003138411801831042442539098942579056011954624930719\\\n    9538743652576731537675312839547137402624290437901940491033526686769689954575899412063741317164\\\n    7115417745700026383870902477729447013781281197336210707077918969217595235149708840424414964824\\\n    2399081188977165970203423347178218042225026806185144737666248302155212207940878992854717074902\\\n    3084898523280680279027999445733437687921535259321912243892488158050691807811679996193948040686\\\n    1209889866273314950974549271643631902413463019075688559545773788914657219713220026479479904221\\\n    2379997953097211187922830993645517756452133954012371703373842350231583351625587552028455220166\\\n    1998589263816232512934461697555412531124184001314969937133086537442474678454181027841605942458\\\n    3811034295298991746609816552517338712032296463203993500964542239412981847732667559931451590549\\\n    7673163077718232383233655872278172121771913609736311060298303112569100285220187717042517133453\\\n    1640422640272994356151529490910525471503222812362742044960487537499302712584629848105183616558\\\n    4409448141390006986230221239268152609119078664011666006106489659988492227616911360296740805424\\\n    9223689769031952226921612942473838683528440618219327151209741576504336975284216881834363347946\\\n    4505194292094581467761364801003422219234520875208538399026661285996227585227728246196914023293\\\n    0146989896887731417281129246620612525798485844439158678913497624443773608771411014236656621519\\\n    1605561992516516127815784939475826540848150504627231344835831812977464063625417721404073158675\\\n    7708500212245809739377340389987395843224202123961568284273330192745965975669501997230349768512\\\n    6729066065196077925949830532317751258575104969139595255212215628725332789440521527575455539554\\\n    1983081734234420775884332513884307660311189429896114803784057122716347993534242324673281556817\\\n    0622993703103950396784239765507682230845312793653458482429364737038042323908550668296084671088\\\n    5634617961436689989878141913497800030947851309738808536254552465773979576511822491375529079695\\\n    6395885978804841817303832907998997280419652837879028884727454466314525438442264401748670095842\\\n    8857264092526856086348964216752997022775938788324825215371839956505132981583688984609456096244\\\n    0347594290411306631543593183077087828580545743469591012265229715453562674954131692303409562546\\\n    2539119873042248421022218016157939048745438298525172484438641293815624494504595175906042449886\\\n    6445990719884479904087188202515126107748231000926176039635005028351515006148757832746950644371\\\n    4351390290563880456929895718459432740192124977827445352916520809336344840061545400005779789411\\\n    3075981121666766469654650787396456873434761265394184320579862623155388291762585342940834231621\\\n    9412132435130912927125776406592171083644903273715172176188068020336786044720692082538505375701\\\n    6835798619303171048030217740086866669262643974124613977541696945713878700798211199549076263087\\\n    9463280405622252190726382444419951038139483251082228838701470479559688967945667557712738701303\\\n    9339758537452157196833184725583282008222654203732489782474707027736889608977418952718345580901\\\n    8869936784132547433820518610901298344791796323349608368109542284240196131965921073069455499695\\\n    4580684164590280183538139327716709724955646040575264440297277220911945848399572371649446507661\\\n    3040800689993766264836596699662043397192319495529218089482905808921150054251593040032946363169\\\n    9066949595171106376261792761601602443581402647004202564066283071146342800740259789452790704312\\\n    3155703790683206856867496606685517902043883730581330543951328002408984386798260211349946478672\\\n    2995105009276170462550894440483844747583003172283455212153898848290847910201958488960160909756\\\n    3053812330651137666179182775923094834272795585052253224559093820119132776062859316977058857038\\\n    5597041609486395709218482977994750420215487654284794668061141300082762246072081626653283147434\\\n    2083400386499531092236665587682425834925546094396176846727063690868162641083239226639020102319\\\n    2318782150220455108333241176550722605362098678898572029620591938124566203711220799045304008750\\\n    4059088512459701252913354607763371603257471657207194785494028866345081280419692995149421928987\\\n    2984976264962858787565626997277956811672645671215392560962535911950794622297415637258735695379\\\n    2006937114421907808544300266507261389572763957635386179010846397879007651269841289723640710630\\\n    1588418933877463479816101317772863466731427212640481622691554595766751967961417405614276380237\\\n    1449854125292619914148554314827955699096693274213840367763234190778750570946871150514512021863\\\n    7019310782149696470169670770061256467200027551055364275504707901765599160324808913450760541462\\\n    1321878662779158098573283380856583673072157949139981903874462485739855184181483924676233322747\\\n    5633127440635897918747553851627549210346666141078404477867896528873895339372079872433518214959\\\n    4960361282403299358645625226915275942312972554433201080575891462547530116676542421401967797617\\\n    5181154912864898222152282806774712989941686915996376944757746050466440355485407522727069893452\\\n    9874325719899277374358679426229719320916734095490161843792356997788284966035023927218761288312\\\n    2611686617707748045853065550436032685468992947592812751170891013890966512970044366603628514042\\\n    6460960142047897069884352855036381744937265348492971634988554873469960922732763470438060078332\\\n    7519571536660054445605836979184039281134021898849980070311972773913816339922625995300228821196\\\n    2945001790717344466440253905135941065750060505716418841706890249179699754739746042468810548108\\\n    9463480134196996212423234243705252528605297328621065325225757849885586962370777078834260400056\\\n    5084295645391847124540635443553666238023651741688944200238152688675671682236853730676889595025\\\n    6092837496460916577816450821113494381648420767279503925507089728407573920826513081521260014845\\\n    0785584942481542765646800707854053302133902342678057476697215684637312553429604392826482068551\\\n    8916847738915882903451335896905118261689054745411095147785887861218106583367922040370957720295\\\n    7815388757933408218907418788935791986535441163506055755516456960690894867629722961970287255875\\\n    9671828867737525433426192683096176090969033846621509752321886118513585227963794788543464137908\\\n    8537818847547493485493704559884819584170543763020317673669042719131470948909695448452341022253\\\n    0036899079704749293783467673361222190274012218767030771974429744394731334561386658891749830628\\\n    1082239166712459255787607189978280294793207946719985916434718406609245359469448894503408542182\\\n    5665256296181705534342185310243847715929452410736708558407865176944902637065083078888158742947\\\n    5851310270061818284711739557553902890175674996857024105277450960612034214851291660450324549878\\\n    4581942021022802256209914125451324623570112997483380223822462110103398126588669767213055678744\\\n    7282489723023294693783529907663136025909531450358007432420695404956568105764798600421041865785\\\n    3872712492525286941034508161889132167827796979254418781408712200442892273329143599656364165022\\\n    5378096415273672809447469022192213291915247930247066053862792050536208517981055338436367581879\\\n    8862911704949359061574839082145289720701845440769509431370889459595566698626617415888187879307\\\n    0734713736356506427725705228096515568748183818556627385553038951612675253679299594253518056897\\\n    8644094980075678732523939338244722314992294563388118379978333968570880069380031765129801354178\\\n    1785262568801847269969420664664784825005650876160625982398950733830654014961657366744578836113\\\n    5847891540697210214192232876747073002154110105089545095574135764109091532285339430754179597855\\\n    0348950548195601693927009399044810648151749216251410654596487937407532268693126798891607577716\\\n    3158141029056134575022139625152217560684739805524940809141583016479437549937511193900311672745\\\n    4049461471202003926669325820465823166842820544401166542600173201927636292089759388108286077282\\\n    0870493692731777858931731652452818971946920335762575800520186594318688938485989850514769340999\\\n    7625426715580985698904664174159430966726390485459619841288059782769921280564713008229033021990\\\n    5763080605969202151221935142483115060802375953737041273161944153870012245249383827729055974107\\\n    3177829367136499931571968402390575631667454804688644500626771047853834343782268972534694758664\\\n    9240474365083400734942984873528648722412952371592151671817302198638970442861305309613983287443\\\n    1847981563002445278819963549613534729226759157601013046367247819947700274195161845554024534273\\\n    2721789037138066344933177038090835574335308121878179002725289686432206042710904526144678876272\\\n    9602015515914460761714248979059637132568820537487979665284698802657700126570609271123452455236\\\n    2088241941193416542964327008122088181355367977637237071112942623340117012890335797646539747693\\\n    4868622846679284346563119807178856284760867859708394055048137988612812060005287921286648044766\\\n    4527956984131280723486088069712910548663720898301361154935075190661066573564350820630315092436\\\n    7064325415469416126790854882129196828701633359722195571863768881944589640598960961941531434451\\\n    2939339290972399676963194598957491875775878716218089407799227209656532219452755254613747575293\\\n    2267614385165009175556628241791089192581152637613108701735234885399274102702269731991825446767\\\n    8185866384520360650616018984454188775475202467031618045354545817083602774094422703970839557826\\\n    5729664996947605123502212680926163728696641724906147946330972934304471559577413374715325545952\\\n    8800673382038372225234021563868396957020322156455485918069278237358992596543585195184134945261\\\n    9425266001807496697854548367906155137018800393090504592594790851166486712180223949570859088681\\\n    6580720701752956121956079854521646529334606071998945929354106755237387368006573432482419250447\\\n    4162775563330195660401861903389390593727713321306481601128443645545192373897491872680944756482\\\n    5331250150205465379725814104283307489080103500145552383900518203357256817382584842292151110160\\\n    2844918596927868590410879670990421124123622219366030097304042384005296724341465781415327070175\\\n    1684313680583436750245732594591192512063418235359077501063404241040191532768058356356772016692\\\n    6313122875691995271382633643957830486155147292049371515462491342986346133316165070251206463588\\\n    2543429830170935844301659946719601639190197379961017634033577813447661917008957538338727688915\\\n    1330524769917105009866090210436294943045738805777966733072352031719521522555274216115633571417\\\n    3368547389120049310923770832711646375527744028463254753247971092839126971587767865993442442708\\\n    7646140119843781096653318121398634925936637758855419383628204143334372211766932325017755686408\\\n    3324095503930886406586489520567730547755672555075315353063067569015333002256289712873507982178\\\n    6207631017680770898434554698584001368244811264333956499475981887201745963938364394725036168602\\\n    4674483945504842513184770606816169402610272016158430291797667839748492627651246500242580355606\\\n    3771178601448086757480213358119113370164762123877484991970555809441370742176749959618467134789\\\n    7590689285463256044787241425241717258819017922168207165059262236955990865305741795109402049417\\\n    4556845159645652160131114493692190252476065581463508509534737699772634298097068044482332378845\\\n    3203881927871537073201862968843236510849162107400602724810487686919620200212979118806786837671\\\n    6525376026795666047679395234631384473650215122803919642122856753335624971936441804899161755318\\\n    1808874143252656957280808694427796956232652303343191409691261257277578132833415480838557392561\\\n    6991691897475725538811358886367537324130778458276336594505215154561987759365731683891349997623\\\n    9365044122408250544720009114343859741997359199633588816167975678510723901912096519083313335933\\\n    8445810837825920096127564687896128438190407339365375720232891138576757789817681881181861089712\\\n    9027916867227747522010317135277311480570914655805402957261325504052063576018513534747336843688\\\n    2121792630188462392031743257773074047017104960602256538853591158601895022883848406455349546159\\\n    6693543355236835333948673610066639127556198714477029668460214346167578930826187576076605400800\\\n    9405404502544414919116903293087151262080728464590083261772938760822502714075428820453558114637\\\n    2038788788117533517182319067102837614587182790327143004905904368892110783047372690321618314083\\\n    6489057777011395574709169046746839774224016251858639654028094506679375345930081660884214178009\\\n    0784366002900884113303620749343537965426708526679223233187826908327818771266183468601570067271\\\n    6641205541989313407116884828385290768130111993617894535547481289158144288668741129409822321880\\\n    8538892199440220731275531917479594778965199894444816614142196878793097746980791923863151828040\\\n    1491363526788311033538805858008776544628241993872866533396951488761012170238301196741318244534\\\n    1239432917123311655425001946466838196033510237431247620112308274100068645298027976629893080788\\\n    0709618634165186546748988624837918768396823887013817111260002720357831555471158771441763266990\\\n    9802566658949567175656909765117589243303234229084828129444665948750114484289361781931125041133\\\n    0145244234911292305944338807304483905102994624795273013762048183771955922215347351730731333405\\\n    9076540123035207777116011936346073348361362814924679506755749586562173261551395220267151039096\\\n    6190228307634789493072902383332930645494574020158223394210291637676073959163368823685677260875\\\n    8413302006959928920137585302074252310485516869917050992640628992901949710852580810025689671685\\\n    5540174313703397539619030005395154827525630493405156922783238450572194121632778657626505815425\\\n    0863824677880488712196786000634700940767546634917394296281794926864855038271802249953047658406\\\n    0850054645145895536799683886979934976805382809777877548155335792156851558876912694864707064865\\\n    0657865632892432900696252468597553810063984332794995902547870170031919722728396813529929539546\\\n    4264900652470424513029231161510113470688496180330303430170665316053166833678294920636193747978\\\n    9410979021108997594675030922190258734365415037852332699026738931925646093833501506316989926239\\\n    6680478011350902786692292649376703052038408362703138785902866016701686191983925689929408077377\\\n    7155188615509286740540726496116494320583833218037964979183232929362312674114405148399753371582\\\n    1435343706735544301859703292378090204720568938284786332916942348236058092256220484190424948874\\\n    8442255147592547809538718474877368493919243866267899518966158269775137618772130267647352302796\\\n    3300540473340895851325370116762347090712323689006771405113735411864650799415814926294700506837\\\n    9071064410757289843201060042467646746122900367447570683517760918907963380903283082903160869262\\\n    0799627455731528087904628392882573211033145812639221095674838259570004764474643324371911379822\\\n    4095856971806648737609666909090241868044633832047613791299288556060441005825158943183005798733\\\n    1719415044921766766345839657953849448999863501515075485704848992457927170183941143594249695040\\\n    1554653615788150676883086925282681737675227183011679541836680991874175860334340090109403794432\\\n    5753476800615327703398980348094005193088221664361668360915147505213222438051707163933897771770\\\n    3812651634243556604220160885796845765833820142000876787880602498253486612023351604509758596546\\\n    8828622555188244196688367807931412683650445839735729976584353642815244973107982737389555572123\\\n    3972017319158104659107093863155009178125249080352377836685074437088606674728536679774918014548\\\n    4636134593910080680602898692295811718215979598137100595311268325153894848627567516555426086249\\\n    5836169117340652872819092508183105949329358135639401750716384039434531052939028785954398164610\\\n    7432977783059774555152973375730281736568098760773187419782689372833193394065433504128317240785\\\n    7034235767128796310832296565787914461239777568383736817029572546477017619918696999892013490260\\\n    4943446036157470247387208927865359365787270147633949663709056103335710446669760051531283015106\\\n    8421822172603915974863774970605643426413234176627616638405529998330768268541119834011902001019\\\n    0307236052344873016529597533471129121520267746713246211576748381789983613693026887263321575409\\\n    3207727134263982071028931601521642906175520981875098952373936355972229079358070457347068385450\\\n    3849910489708161251980719764115518488218526205788959563753397943700672582897391848405169672159\\\n    3634312064223994051035735739879333055884553364322299253991732036096044261628484038927126213115\\\n    2436150947923087077613352040789534117376340152534437229879176882365587093292106552586292120281\\\n    7169836160212241389573084124475359245545429367921612346020844210349607549498209465131641236562\\\n    0314463403452844635398780322672090425149746187645857639572462547734628483516854662652972441197\\\n    2962993642614054867573931724634358610502867130938334821007138818021366491512945345054001416198\\\n    7834691063885800575406221360728018708278145754014705854724817693995488035831332533600476364935\\\n    3568523686780202023379651153204217199382721073894881428355107014006128278556851843295408454243\\\n    4126617649859274674186631843935177011489001477513980827338028732868053894767697839262600957620\\\n    6948542059912273624579526810931724875665856147867155467646213813020920457281661165199288336024\\\n    1773410198223097287092513858947140853731869494886578290703763367337105898978244061116774471494\\\n    0903354303008217360179921682539986469125581304275470040548079278540184816835980514626235923189\\\n    6800529877168364470038952576287654802542084951800831676273236638749933817623654388836269530954\\\n    2432416951154504918391879190603727446440352871545277761044395459691935874023118448969117525132\\\n    7115022981192453960186912382450610197849577953191574847306856449901351605671955499402416310853\\\n    1131281234766766774237411525577547289614252734535121956531577529746988214510331526213202397321\\\n    1629989473298004894339291574536986333409447156287271063962869477176087400356479941401688082468\\\n    1637728332354227590242899079942411578208682635040714945811777075869268347329590377852893411138\\\n    3667902941046692969778937886403930894167098113183055630913394990408472065492573953808169849835\\\n    4520197892748228948000265141338702262585088462729788047216130839479550025912812505378443922202\\\n    0052816283612015521884981713394017080563710522470963949843086408187036375129078127078044532868\\\n    1755499918007508698658757391469503219030129971571508534001835968472698248157616230565948967149\\\n    8133354440726263894639839331128205167923672014676324137133509092077720164121649932146536666596\\\n    8594833454427402236774665567661752174957093948121333500227304409556813510492963344213310439517\\\n    6309197446056327488527807993079054139435414067498946048231634548169991240044129560635559042215\\\n    2877956959332636712430747378024052485741530488654193821960064094973131050678111089694948267370\\\n    6716300389958860637373890900587394014381578871869373040445640715144802921919266324217302160615\\\n    7125126271361408442442308096894083436717497836831669106325823531665486489607989195651776654671\\\n    4817775387988444163791223590304902071387427741999219603597449158370619150505355165888119171344\\\n    6474923546158362353837096077852534988653363709953465858686776774431772969470765199362695381138\\\n    6807211483249164127723893102451091382980212498848143391876181675847481962964716657090762722543\\\n    4181025020258578115057974134248636599891105515008118362113513499276539963427476671692101363689\\\n    0608053066131749620413748334667502314765225078480440137844466926922397217546973847369969512621\\\n    0313902293917240033451304471419042366474232565323320382050618576889533123050513095408170471539\\\n    7596627027971170920210783926116488881567743077339646801745170703391109184644555628075982563859\\\n    3937937441935530999115042534857253958202444954898118758705387351924749366614442324655352420202\\\n    5928444620922627804509686926902419655997095667180237490775748270008912008555339437778761769381\\\n    3381804578040494913186756659034753832253260567215039301097783197242623347325462714944845361740\\\n    6955844031435851833429643276495352185270920651514352128983616753771860950406680730563538009400\\\n    3797695084843830933566640697545035496274118508873040622965863462665984336426323492859881102598\\\n    7915748139600822475457884087672531219615318675625912656793324212543629640176839986391394479559\\\n    2618107429615462015911767403348106574617358391668714109348648830410056402116846364508041365907\\\n    1022736400918208127171733054233403070668554519429588115515126030717401243972641722666565714992\\\n    0405450627060037224268238581869679825453589053863746043288512276008315248917729262691025033803\\\n    9867933337700760799981566024253516511956458154392939603524414705546010606857022403786395382276\\\n    7149995135779846142041748421788901989614919608724465493931033027384623653145940529810079089965\\\n    0774274473052668698118216765028913187078843696743586343485190689392539853857891191174828419219\\\n    8277820132706779398950439342333785089447393611750844957903096721464054271606573691307857341596\\\n    1502081792709913766918915678599489428479822411179657363040520349560786098368719129525551918972\\\n    1723588637294013046000389881523727224981181850611112257876978559176756924305227045554364932988\\\n    5614389148957282937068708924236336530358197507044910249212869501736477762471338073522209563869\\\n    4117314963793900264212468283061405598561040727828063351351203880105028824070820367662038169689\\\n    4752915085397960721759773020872865463644932807864747275049541308511730865644090107485725879032\\\n    7075809313297017062405682684841671106764256144420724002503760157816652927733260533691896825825\\\n    8985426337759354735260168915172919900692506856909597226331338908066069464446229465717430052020\\\n    7541751784649178596745736676195717575734815687283855964036379958358073688889005983879797204184\\\n    4793893358400342063551475272266292885386232665879530739595348204319888398265284562995283156595\\\n    3833672222264136813983502669387096260785503212895545314325350428103049415104380569768617096107\\\n    0138348417006275418648418426713389436990923928063037376368714903032005117786457344785348079978\\\n    7635367631708034971827524762139581097779926866006099919547151136601540205294342683205449777782\\\n    9329065415496454259242664045797633861419208949841966890035386434047628810721799782892826862027\\\n    5817521468507809746178263880498999842441747509226756259968678927485802488106890065296715926499\\\n    3522050366556332163019951196167861728434692975964927447318292109764918810982888388275655060870\\\n    2130058919397838210889665541875094956431553253292756404597161737899475065107349222395782870155\\\n    9559657094016421303507652979136800650905595033968385599907751792888597510114541943822265219659\\\n    0309300696109000099408849775814744463137664368930927638855820326480503482808503499624001415702\\\n    8225276816670693465873918810609298278276549242579208358599020836350089685275556648597897263531\\\n    5402088402241420852391740962007928627840303117189660108718172248874988817994060434403125550796\\\n    5460220782802236151100365276355487638906589617567405079847142264727715951513275148073117674774\\\n    9097194949437161997022969723790557807035733538079511574078790007764059258248995153616262418245\\\n    6842036289226236983358160379325116649737746329135260933568618922961612122514836308237735390604\\\n    6793651210222512282081114131357078080590419252259811492259197206236164466697764987179756650355\\\n    9056616919895774227817660047007379129529832710446057416135285915046510688063287869879612560063\\\n    2558547702457519096153709539917451144426910656629791998421519443297551287712754018122850287905\\\n    6405867309010472762318346095333936139430514863756443632773538852589959844147884171556222243586\\\n    5290425831517078398609280550746004897165672221324473406834150992641270060637631720693690722554\\\n    5762856126348680074936984252264144911051497619671253401801375616311133709612339517866936699623\\\n    7350387096012534936525709461233289491847577141096330680614559348044357554354942775176517107988\\\n    7153672085392829896139979484564439906220322453013434209527983025296374733958734404054848107140\\\n    2708137160987670363243707245945059825387387153302632163092295908069475729916052432997958232711\\\n    6654654074816120073825095867970276361918863967650316555837379992156845947449960391984647116235\\\n    7346092307023609195179500557621761307294665293814710362671772354324835235571525891644718207298\\\n    0914201620856816469619598410855103925638930421841224091440978601882681693431322468109723201100\\\n    6407428262188288957147049420418562464036627697176030391245335633122197913828568095846855821080\\\n    6539785984692408950289075600469305576160283222624281552039544355065598093642572297309269247677\\\n    0320913466146654573857028725187517306550957303516196228860266461976461358883479644099277609548\\\n    1573157190129017412161237918240327500851329518825979839946346435346125625876901967451257956523\\\n    3695287249423312936527439460156783537155944044221123904073511969586888299603584354885782320846\\\n    2900534403615673127939440504857180752294123919460277150175552192049667628305619688667627246426\\\n    3941333775628574125921357655271120330675466360546231332784688408491541513512880234131538641848\\\n    1253698541579397563148236152115121223564047209289750810270981731759546246459605460077902501606\\\n    3752617886346415451526561239240458687261183146656623944076085283431224974387079455653269650398\\\n    0104743637333540537776457161518116857296049075724877315149848708678325029422140906180132503479\\\n    5606935264142810211406222322327328903701510046716784304190269483272399570150753460972475318365\\\n    4531403019116660224741335978149278388977640802198046668484938203907237890566625943112483300034\\\n    9968390231445767305048770955632826603089323972555045536668564958436273918887501771685346956870\\\n    9866118605137964939566562314499983947120490985336055402575207402008557314365355760662988896440\\\n    9756726816841261088154335088520997104506834734880930808416787774980831433503972693654270273322\\\n    0323014507055437532605758109692053787724663892551416101017703670360827611490201653867646052573\\\n    5821295606855125682465650705304523034135523526578883064936323377759070761410046424755836816899\\\n    2040988225316427429983217941576215401230979289720049059853320713123921710368289305328472162537\\\n    0658854962655163335222376880820688731868669213483682609361372381160164987506482424994827213800\\\n    0618958809599410768673122240741679829775544625349394384979839062970320330040042338354589618782\\\n    8916088299477998113107232593206192377152789427705066160038875349800044992065014930899433465953\\\n    3763456460074199331343427856633626214006847717746976970213422921207848355509635861808447934850\\\n    2582755440681587726082117542397193691599988092190599588548841278883381832078210320903090818769\\\n    8480606826350810580700011828806826911998019118040854644074228924198890052711089832998010253003\\\n    3780101009297960999372117594520148312623757912400460137837877741716145930651707608943323223272\\\n    1704231845618510814523536840795499506758051011265059320502239178108759798879942213615649640686\\\n    8787181127373980101278745440878737072062943643272694785995765234085547249052589457351132569021\\\n    3101295268150255340821158347389235759850760327883243789349321934342365544038221210952643415064\\\n    5865004600946725382751542029266960124700273670106635117549217298788238315659199531839758353456\\\n    0378810967948115828793121113839475225918344988610832538222266743741707570550733069936739482218\\\n    9860213987534844138782301852215644704079411707865928746274422600919160222968271592107974155705\\\n    8142229434062141143919248412774735124357905953483534272705591861285911755780230399753571264955\\\n    7555756485813714054452192175552107327130135847558152634218610411167585966710177809735904998731\\\n    1930777977777800923866079452041446565572129061543653170591053357782917901476318310453101069770\\\n    0791399802957323982013278585610119535998520636897327632901581723362558015794005334082752643517\\\n    3565355892294490983503909167132054337608891342420118012738770734403622729999134675227511589034\\\n    0794173609730407414051529058828751137221981244480071490579601177216226063422812329923121943301\\\n    8241371158206118940823980304939822060974943867784590149334030248837856827097441855806896795982\\\n    1314436594405728636697552736605498368770434054230044615589923793515381644736861537101627110292\\\n    8745155937565482060874261041386492765420013567061391392464185738816882273925985269079752141697\\\n    7544033454132353983905506318831081584673689336636587520807530757041159045167757640832060085320\\\n    8155421965173598813500372067448243759097262529113032139052905288326272339534308355640937990866\\\n    0832863484078935540379141387592716178235197446745155082402862725836586546476809932609083204449\\\n    4887574110490659353926177364992988225742327349946736416303719565385099433939997477827467203261\\\n    9389172357773781994759915907586630500380157292885712604466643500682033676600204905163868871602\\\n    8933658309417878885634537634067075675553299466783660206966772763469476439887292715117096018752\\\n    8202565848253992900201882429031845444619087580632353079643976866561608372340580311730367291434\\\n    3905519331901261704820003779713208920674461568585528144607270251138575734620832297713100279295\\\n    6125607621630756412640984152201327957755933360633565486966375542761810894307480928785134015015\\\n    1650366652711683687671262926438500946162998180232609236235132949251586802784644664154575063951\\\n    4546622217880760966625358998929485894690373062824871333704353861463392560546653723367356567866\\\n    1958621108387785604292238630290564073060487413004632233062924853770168356787598417934726256234\\\n    7208788898861605739726755693099222821194430052442302531958741271078422001084691932856676531383\\\n    5142691303959358755883863487027380604296978673224651355781086471968866197539190890451679457211\\\n    0499017365987081101174657782684404032653388963292370623210605556970298520917293978739837239333\\\n    8300146746686758898279818030209318822481230411687340956511602937409981386991094362733630367348\\\n    3898256345302329713970355275526470152083659758915506680008558004642329978373187185108476714760\\\n    4425465767056402360356401392568486609823675135811920264863904682493274590148739701696997862550\\\n    2113387259624501540474072779067986346596694808503562658785276206760406016111009577973998645903\\\n    3643915539425977512695076248415413452972726618556652480452792987113171672143324880752988915575\\\n    7791619351300484894167803616133059089070684359002230983412990041070558825469269703056663674888\\\n    1535369008593467656624193698537048172971106253752484727764573323384332212809060611613938972306\\\n    0351200950695439958119935331706856080320746964073455217921367130673551667339694638276624145463\\\n    2591533459753628890108498859345541353557974034775537312341444975583452883320370257164280871060\\\n    5827117865261676856914798437066110798873955800843868051365405405104871521822600138614064229902\\\n    5589581547788537570540942136858463434949539469435593673599603367935886935362668217754336122112\\\n    2516470132557548117360585087147050742544764567030116341386315765045406464632125187499432373250\\\n    1291731576750174765130632744284418913476925472174122527774361899329216365754376349180093632140\\\n    8234854543513889695598484740489032273078767297606846290158436094651765628984636126931024732261\\\n    9222342837635630333687058820352285622918840638834110254352626385374130047458973278314702964180\\\n    7557208787358058152202625567107063388063339900623332312117444340010128201179959554083770769069\\\n    2612694436918907310016369749417849568674294312449448662119416303168244281222910282081625080404\\\n    6816538547347522822123125814756427441061028755678633354176677501907024413470066249753897381877\\\n    4105232807137565144778303967100794595268106622771853740165084840298283688251532934068319924007\\\n    8770775332040779706924249451111074964162437486695498665810644334050067859245462325186068465343\\\n    0737070101686434441612981816817995164831539292335905147804150878156767880276006569884646993612\\\n    3264200524156937031976047040529705934433601729127500580953099764204985348774734317916850095535\\\n    1936173388487277301473519895021994289411043411018071806219337427730978366748173379209473844622\\\n    8433373006543557045004909021985092508583816387166397673512206639764621030627926019546005495706\\\n    0489748338717746729114650268711016148125937018635454938448688044303551689769682312984529131105\\\n    8252889732589369551146318532103348608426969010851700495522399728638617902001305402058431785184\\\n    3507859475194008347094895926876969713688172307588794629603325531046967876400041200211096160584\\\n    0642776282225892840036595207921289019811036679156661780022483944860182888719774281205700799422\\\n    3529797248189893035862399966737335628154999152668767680086147974954702436522514821218076915796\\\n    9529463657918688666189274666875224698852107137871864603505984703783417681435056840007027569204\\\n    5776834970473143910566328142343369941879474447176828653181976397653465524679213810515230579520\\\n    9748468922965279149019694839750918311279870220242415894552905027955606531102146479213119024445\\\n    8896080079282337903037583488488209805166547844174591289058418324983593891515691927894898038709\\\n    9366510046037023694319336501243620773173135059398951524779322451766230016698080963788871328083\\\n    2672098138554577071782132024832791877535444351811492276832368832427142631657281710920281548777\\\n    6299204553164176249512060521026839094271816035066359129713600767248594618720601872686963380210\\\n    2450711252586678378090381942809510100176013553461845415127532882302777781442436369302006663367\\\n    7254694654243460797669711399359011824670028408358970325898289853856544820222485431361330500996\\\n    1541102579057162406247111447715063243347976450845247076451644008939667505685298407801598823429\\\n    4181830881680649605095288860868399842772597772998784387367612568639816769619578173383009015011\\\n    1793432044734045703697944336883683682607214673500413606966081600450121033067640088649390967645\\\n    9765967997189435508673614849545277786892457284599394134333017188765492900388293531321942260221\\\n    8738094148556605306928811304466590253733753976668828231543190688518010021104770859169143967037\\\n    8993810861138866869911312909580025654677700011954692261161382229373041688738782618066438498719\\\n    5052132985542307402995809581987617097696055666130775910292700202421882383174422263134939132171\\\n    0993332050639054163220940771568255288222308106330644523020940332484093726481539956200837763508\\\n    4170565222507878377123781402927286256921938260953795540154222101388428058351177391717873091289\\\n    1652904452807083058365718964923611795424548383959755762230255341049063600541785333412013331836\\\n    1728148397239776083680860829504101128843359946580883613910851897089872324150558304053931023373\\\n    9790814451412051043617896173858876150464697191891082006569358634632094208016759456066503083000\\\n    0725982996601507397848661795889719163362465746842765124621554984673082925981238431310595475750\\\n    7463346661422480301597037038758268646867673382465131333569883339348669393554842332668741513675\\\n    6083961779034560799890924183968674047659779894303425431136203671020576627675372401772444836705\\\n    5682296388108128353498456696831896817086686647874365711346162140447893850501748119347216735186\\\n    7809472465109145704796615086026271218641594501991723022837186732727941016440694084242685919326\\\n    5279890907077431182696209891799034406724781183129747891769923824277462421288545337604531839047\\\n    9293511951246017775100405981230163932348487592336749919019844599477363369143427551965539045777\\\n    5303329098672069607429080715618064057096474300810740595133325729564604723288356996717791149455\\\n    4627049257380620796912619526441759005580198904716592446143635478560155625427150241890404222006\\\n    8801976711285819481662277915328214784596869094176607343006288359464096874593009781820156037068\\\n    5925116485153511280245452117257115933800486525317013236197331653716754576590416956094712896063\\\n    1146346754988713823753409517849420392875367083636729917061814666240161087221050786160445890039\\\n    8827491383583028476684831325257716512040887226851083173239895003663870975861418740378265537685\\\n    7375078479105183665692815632468384393215422817545329630046760798512477002718852361197372927590\\\n    4544940263723206933779458306519292645234422471289564069062411112410154968921860741802584310225\\\n    2168177681635443787885953699651122987648010748575543688820064692859194196013952488656897594201\\\n    2102087464884142503396295183768819415061475552246155107315442239439013287988498536918038076629\\\n    8710062391717328254462784364627309678027300924620324503070879178559728100128677123424132001351\\\n    0905038082506185828466881290907544125208825072875288409749896302489633949051310477945306069883\\\n    8386196914055943376829724115789367124490135630855388665299133958125696873641176467485599093109\\\n    0766052743380027428261486843016575572163352033690143070556246896125278535268239238951086257091\\\n    3596785407805282914139550885019921794966832750176723496866763779308688756449156114287332217961\\\n    7875764934286602982450988656033925160217601322401169680260678742377179245767956475384331143803\\\n    9013413919698772089624841561986193187868514081077754381544374046310960347602698542443795193937\\\n    6683904938328543756485737226086277654434629717240620279866023702057681134014741392774936280861\\\n    6268925208839928324688739689744929458280498986688232419818030000549369087167710234140559662245\\\n    5825580377961532240789977828366722267968459301331684420407870681692440123215848025006501186887\\\n    6327233242018736627756319711306642728781456993542586682125796701832127444897394161165182340116\\\n    6768322807990240202292126112665109510856987428760929869335947245776905772249181587446107229475\\\n    8084922252835729213294231062398354312120381087125551931174512579074234579943027344067775262161\\\n    2454227193571448419040442490642030145392518547863624390754361051268743810911585899401149108609\\\n    5358696287338109956690294963096603542260144770860750533471140568541860702099412161489387730231\\\n    2326986215391097356552395565073650049174232857410081891016030548339837079394283171491511399711\\\n    1187849196933930004481078764865636160290558400034826598972691259133072328304578480181660933095\\\n    4281983410905289207109131314122427240701364097469798524680897891013387063987184975829191500846\\\n    3025909129414228032016508354834507351569665853098966742288267672117928423597534284861151288595\\\n    1681715410988508907876396034590629305645697821071577223955339940279150320527891576915043391673\\\n    1644081214480387038218353775921091956688156962023790738797611787929999608685554366146503225422\\\n    4760113351355544172611786263838719727833677034178796409297109728125574591769665236779603755358\\\n    8118515362664930993352258410159884835678133316298278184776145950880836272495481679471711960312\\\n    1257308410436914862604521616483786521135614669641932939715808849588886306461947012875023029285\\\n    3041156945014382442208470888170618736078005838749702114396740781288852657559902139733422191733\\\n    6302783047045519837983559461091751967093689553336046291187682657340325352960867718051804894000\\\n    8839248661928930311480884189812379778792761551860842010670404500070473866334599264629843298255\\\n    6639264212818260463101799125905102400782124717085671482072101215515550929618197475743343747820\\\n    6024004874510741784780943354090159804821119965751823206838845796277273183933656415666757099936\\\n    6229837712781203074269685904644179913879846045832070274613826333658052002516909757222510520582\\\n    9024499892925791124300359111962283674350101395832843945819071485794663761236408392736476301306\\\n    5084514376146696265373796285914103577444862279870887334508334790610753837077865563778692674927\\\n    0680991396779767029369570045837175150479224926289278185635326043977917487309076617550844812162\\\n    4759310518323622376541737035892426421764491235992341187350623820292778027403475321196477109102\\\n    1096547762195140098379091283458705787836845701503175481041464800152749382449167568033839412628\\\n    2631042809051840141021274723958625440556218168704133903020191775024990047212503780643552988749\\\n    2169901751011225529560699396988315877028974158023354746036437784777284400498416442831056337173\\\n    7797821006034166243670107609989084195698598170531821232012077971261328522227877504611754417961\\\n    3461236243190489946902684531963199752165436039242136933484457528921518781832889132590406613550\\\n    8002653831395928901516242332914375911086672099214082331119959473429631914354388947186922439693\\\n    6828664278465417507171458172794097757523988303577506663253804353444377009951756624888393829691\\\n    9436225648546553169150674596431897422954372647682072599181272736664583079698900329281753234595\\\n    9266256283456740681675324021169449269545230476811819576883198068385694725573796180262074622883\\\n    3681818360320628660539201713663147975887187419907862739858081594834396103819300455233951885219\\\n    0571190736217122505876232957697021289067425485799125443514813378515533703146699553839721623282\\\n    9263428665242673106317050363200552456798934370655671995661640234924541976954759270379266320955\\\n    2960155717530677327703723573376286874668584515918019659376517572237507440880448385933941127159\\\n    4828176694691481465458051959701104177064058509306670642396993058881267242383643642616028462549\\\n    6206194541651449642184743894515343309301923992198684024568277079504754375444701316685887859042\\\n    1879603846214742204416900815083926139518258853191790463085980786375797477734887566715947078888\\\n    0494032135394764155793204981216565683756419771417517725444223564213634086017536789616665416475\\\n    9780737943350123792049264536552216480053111006236044580500663502193720087224762633010118355381\\\n    6711162285910079383450518866488516367127865034652506116087212399640343195407740665756519101569\\\n    8962752272541451422835819535105066727831165970121332463001550320419181778243601209680805897070\\\n    7449357620361343468718384726812028393224855851655856818571431056223983474604423208852015514866\\\n    1512073349179124402572728197774515322285644527824164661714300167293377827636297120981470998313\\\n    7617910959109918276576145552927191318717259615404222668315609805261753407840060853761544373163\\\n    7330776843811219745467410621182883343648193475135076599580367800346710329098987929657975160580\\\n    3410969723420434764465522550832941098947555554771677310985242461702460864813238507267082282513\\\n    0920673856080332881081309842020059103102342820058778960131769944996780941902702561780785894494\\\n    6441723274990621626800968761417603449699386714394922194427068574071897921310117737828389107151\\\n    1517743583256906107772205229812985212779055356595559873513666047189621376775370170267631419720\\\n    5832968631764306933502534229402046038345076472709023742220948581725524663603565811035096340805\\\n    5134606737796826544429178728521769083389067611003367146765776605262087862766052508892089494630\\\n    5614458492676250142255585530558639660710005116210835255065635574511358571753021804271935824781\\\n    3580776480528805828932212890815149420085820254294588208665741926324436572707950229548196883904\\\n    4146284509864169029532126281611049487220565047972381343647167665615635833471743589280590789630\\\n    7063074387638585608879522748642407498070482536927607400931592500843279029412514751219020774014\\\n    4066170323648862904622699303493981243612091840116523587410356782163270142510244165916615740423\\\n    7510683059460116620995224621961030162250401699152508297471036263278218365194950154340246959287\\\n    9948034730154073136146616576060676968449061373254220151522293059899504740532938284218483250453\\\n    2480129628529591906345054495845214296244800907082044213679782356415541493146559852235540426916\\\n    4351903947636925446421538314403927167272918579420458423849129599998052723204142646404665530268\\\n    9745706979912618972785465578856304955269953743781690225756872432115337700683547093076422875290\\\n    1726264786640283361982417811784700046919523479992217332482781981531963590029319927230292716493\\\n    8459346419994153792053493033101520825967580967004692452865674836484254606875579258602571538787\\\n    6307051935913079268637955062092780468463166616074368518581488054790690299974254457668465136024\\\n    7396200442691594879243607012599973298576940951112304442641549267306440626001898220953167585391\\\n    3363112246954582213864577243489338166713878709806405642694610730645596513979991497637535633305\\\n    3059318963790607283007856256229247503575831419452792287364105232013592993451398516593844071800\\\n    8956540649345629430183173744228708500346820847852856961910655577128074562171776747585259661582\\\n    9608498270796215563600464386500518231307974578827698604551504392970550655336999272846396751112\\\n    3364840453659907674925594331479701341976208773405742012931649081444677945726813816870607489159\\\n    8061187001789814110166236525082419271004037597012352574522360359901839811731765883198108442819\\\n    4568075474006557344392695792442232383545293233238173176959637067839315196048585802154998919797\\\n    0286569833426963345204210821283338345618603565488351259343193762888452239147243983840297457216\\\n    8674576368066407455444405477555879314461583923776943971680159211233141077363278569295214072169\\\n    3035411366355557640085095288672290623213287675403873645179886202241237355549358082619465205470\\\n    4583756850976708340451789546197031098894524997602307604293139459571479823205894654553943932472\\\n    0264786398366506558125402111023639707863015844245292822454621207128565938772163840489144814481\\\n    7642412017634400136770021485217732039128749712341040005968001478371911198180795114343869805872\\\n    2211944885670083350735560142621187121709949650176114962246943262366606938701554916449095519242\\\n    0164405270236691229839518993128996638801752854486864698598918072032595084072696773151579051152\\\n    7129598128248830043129925511107290009714291824412930843241728916135705403949181791390280921734\\\n    5010947633287888280411951046648925901958036131022479837176557505145811173463257971266651836407\\\n    2050955530640439294985963365961764266529932353803135633585401891296009707285038728472987827406\\\n    9484466521057207407255986205407865105198583000380492916096564506835222101774280189383017662838\\\n    3312263623548282149127321765312893099510703467537544779459902965490641449393310773255903792739\\\n    5327884233774686983805179178321059526295584709334024116831500254285720678295859961435988600931\\\n    9365963759570230006293769250910495078056811391781628767888372612333731406261250499312884064356\\\n    4958190252450187150340927709245366535190506618364806284883744620289028741947698898095590232842\\\n    5858302023688045405806987803873163732261330360286550111340796611913599169970695605679228846609\\\n    4199366068397213439498351391634248519600028455854084697310544920452686496136312478066653843951\\\n    1749935546980423760060467979792236103601922134170872456838147163926040249966817411928878328876\\\n    4933407175404050213896513891460491555501301882926512553481361600867027936051704403863276680545\\\n    6965052704462035768139399657180414834021546423509548251326085264167983252064542913051788247280\\\n    1260741662762212508073024921727554181230961145041318207540865322440953941905202083366916277446\\\n    7254580702967937540694151196843065832350903992800244627758842213824551392152021312865106713392\\\n    7294185586299670445666003100053117246446993176689116840934944542045612286212742353065618481946\\\n    0037750593971750879003160043520069520989587023004852456497618004337800389820963294522591892737\\\n    4802679820691342535916704167370634903399975647796932374468192474684175191597337139732178910787\\\n    5292287896134056308321263295789069662479889012917994811214523519880784075366304592878269708301\\\n    3467910134123307822610854992135631170273388467465500008476221025282759138769402018089469927257\\\n    0174215555753590277510120521115714484933866487991701217837306942715808523568608017342507731268\\\n    7693082930460764224092389999215439951881479339984633530668689991965873660779178301086592127280\\\n    6899969421361487081256795351975520204490715293622750525204764857759259819385219265718956506083\\\n    6370096569148514731633345649484956364090176452892850980093643516664306949837355010930014077362\\\n    6163020980852627687714412036537647498456897689678918792011823802912368962313224919557944689622\\\n    9121258635045424956897139965899577952502708105241498115757900584435340328095630506723426420737\\\n    9805651922147082259703346574612549088543578850067601883232412169639927777972168480247578519260\\\n    7427049732171015349765019333018708910930745202911317467678631889982102842707196195247361210564\\\n    0706692223586717723449314623630519143771295449260648982382091649243033186967794565298682016701\\\n    1601013625314936944301295066770612236249106137544523880267581515258559708402603836535576753792\\\n    0409491279520937913825325398217091113183676692436505409179341915309636866303752104779849557814\\\n    4106226229899577364891804115977898353640744654889708726993091973720026299528308543199525042504\\\n    0257060412860151040650802819105919383211238751002531956607235630619958080191586305746714651516\\\n    3977167761396675446222246072127656018938314504759753742182014457184172377996748125999848249999\\\n    5470953479064452469537774302677158311192564665698421791144064592671924014936094356183978628953\\\n    4902679013334282445501819007493621738858366894181714972465622345638243641459559612495317043707\\\n    4730605314605818446630773371362565490524639577433775603789039043589561557949716797893074327970\\\n    7158703991560196949855013478666868921755800539517266892749878721656627692620014137669154459862\\\n    3604012934702326071240412274310714958780502591101382130701431148345047274748663817763575457656\\\n    7815089599606657228401507823483876484774133398507621621560480531847181512624075391736743488484\\\n    5079914166488471417403233388691575982343177958585584784618458842158256974069960823258466067310\\\n    0699746535582284512646529350317870273347337425867166009356544929240811730071907655639433021905\\\n    5876556256039182896759420335130644216621805603126925230907756698404346094204264309974088313133\\\n    0203860498183658774858131477348216927110654482822021608347800866564035890297378061127960428059\\\n    3816442771766283591373868636935201925007024961291738737122875231683452213393195713158865452309\\\n    8302491685998210518502759690728470138994374040710632233518810351452008759308926141703279917131\\\n    0904917569230534535023077992299391888700532241267194291587907670363952228550217951417244948635\\\n    4608580915860393809369375019355678318342091448239841470642681784258952268528815849274140057283\\\n    5951720717336134131205248578205978529271081134550305917516768075884008074162954269277984014751\\\n    2223776455711611717739662807831965231035834369352427475368691740352962886076308328555790180753\\\n    5787567894246495637217190705035577695566126087781544835065659659879739805536479076764091473492\\\n    7967107216145168642120649685660567349641384307756430329480765338225646003893693169550743399639\\\n    2665791594405913052513976091862844332786885126012584229822147158170207420477417912553335953930\\\n    1288480994255069707450959281632493113442150922317137275783743682768481364476929854628122055331\\\n    8928718647801444104207706174025450656300921175612244581608491649034922582457471565451267627542\\\n    7923523001335073264431931386170683129276445884621697815660857194487792455478428431131413750508\\\n    5832131003012676539287747130125657679260322174475550177487060834493975464247623599779650644823\\\n    3862826778923698138479827076490366463633814372058151258184600999464258894985767741834237732870\\\n    1943615916893928519631786923877564989469166745995340965131109556935926082302151412628584001319\\\n    1456239493591732547669692698401374663849193468482678351775496024474926957865104116273672614764\\\n    4568437049989959716180249417312859887940561114082738319559269575031314414246516471780427141899\\\n    3796881299857501784820343062916979491085716557055670714757573566558837251632893043816459112545\\\n    7558364226563147055696933468155611931443363262242061197735233449030210982449528715427542715216\\\n    5842987478191796440152431330598645891710587129385620634406672213799117832635105027568608814894\\\n    7151064875790463715143617581300399386115098458298861612030972234715046285002596358261386153468\\\n    1930490258563138687263435519647215215016534009893820296460634968504812357468683034338056181206\\\n    5342318372204740050993275256672871820815755490931088902074454559464765342406787184924864730056\\\n    0787333873958548345579147714183283091899814009193345805882490170688481747051167870187069086835\\\n    2273049182138627084418575332075286359965367418067319694051554577806128547305497326129434027755\\\n    0708779268455476865410708461255210476085634864103300529535797555842289275535923673041262765637\\\n    7545496531217425687258013207577110468960161314774457033322531362650487881671457550850855793126\\\n    1586497955121949076484286349788828252304834367067578666809252208285225078115807123990879125031\\\n    2603638777998455051053659103307241054559299169788668434713732350345301847298427299124292845242\\\n    8794159848925488172724585394956765954326156413235585949241033640371608288521794839833446091082\\\n    0656025947363256832158656849372008375316343284469029434972625805165707428542075385149284461927\\\n    8774144484692762362974774086739617424740909950681537352708103012015606450861078352170567767172\\\n    9531060647309091227829794794514705928650600022221761379830944981653597051527344998804302967034\\\n    7194498983294739147316013633285888803212624871132170181034479463148329560153332217152484423819\\\n    4536943445952970439181670428744595453039609236655861256058052250191954630211196514978730656407\\\n    7167035186748760270812028839031205032510360595936883620350031887930767734563461588924618863026\\\n    0711760783806211335142905071990488717478543935063418082477030061573120766982700681602232985310\\\n    4703674570296760004721466321653883732700311638705227754999880916010049127738782285213415489397\\\n    8984374983140322142362582153701802737344081624870617291125331768282770588809847254382803310690\\\n    7785248727286906235877964101155681143714980033587348245612547689621052807007537638282538681266\\\n    8001920999559321467959161324567882476544232970505387985065529733461541032784822500003225883945\\\n    0774491911174512704622667178073981792216049989990966795640632936578249732248263640119443527935\\\n    9249737355686492042733745938071418208355350899720527693897488220637335966299658040011265242979\\\n    9810206620833723376543300935571947901776608972958215416144239558222521912689317321227855402451\\\n    2225521199131860672729596415288806879619428699533403995258258074013390298671888164066842289959\\\n    9519483167486437870301615889814194731879789184219649680400832253732073540330001469379443809171\\\n    7411267229003178853598714279521688336428577854121678158830133323785950908445413079947323745710\\\n    3424291469251779474563872422414009041535723537874219768766376983834760998461736912707532237199\\\n    1386051987958810317153925672665551936556909470938637906935958942594348387462477038358841994633\\\n    5795535774944533346174065613057576864216317276275128593165623077304668386050554031494287744212\\\n    7376874767131520571385745365737674384555438035953427560756451250667936881341360581748227673905\\\n    0586945080995423647663843621609568712337238681288928389733910162666710181702765835384803115500\\\n    6383004278796054355083355035798787051305967799214524406526059147590440729357266948443280577057\\\n    1436838425900911075869573685324062150207301590798701634755495066456261156373459325776332816105\\\n    4754396691326965066507039585625644673462348333975181918690142852823413700112039556745961077132\\\n    0207729147556157645673088464770557729024901883561668027137301759640650559570599734572405658680\\\n    4961859290624080649731570288783005263133047529059260617815436533912521007896972927397165576230\\\n    3335892915372844174502190348483587790012231885136030295111962679895038522338652134725676433077\\\n    9945991934982643869104362378534019192237300550782117800341753989618737716698950200093237561849\\\n    1281092011738739352412591156993894568616142466607841063976451057044229300236476461374775012342\\\n    5671865882317443887605827292640556957847144856746320759133831080201900118617021131573754630751\\\n    5647474705705849113505540682043235083466413274122056694295896946911034329582001638657323156213\\\n    5521119799551791455244095154585363595347296326282347862447706530161090138405760583650980294165\\\n    3531113607106187437193339135676897333916594560847487523569365877536816583469997948771331000053\\\n    2041679446210655663601119939716883071893903954491677518266879638099297353954180986449899262711\\\n    1122526015966369044523430654997508832519351778405242612300250688638448284396575648122719340271\\\n    1642398050866058998419602748250313019183723346388234605394677955540742023912135078395106147476\\\n    0103575014775091414630029475666782157676233696851506259500174803898221540481375514949058026817\\\n    3649934995476963799561336728595995626297625652222421776513536481171843354145579346553395570507\\\n    2294033825579612862066420926727169838773722669733947998653583900060983177448667784736445787474\\\n    7819366523115446266878796416936787059815746180604209064904953231230326032147500566790687182581\\\n    1546368248624137528796512138410129743455532274683053820325061971223306382206231189372729376659\\\n    5691948134725691253609364884882590305110573834942435247705885887737678807264996211596359621121\\\n    4903033095094202780068952496952470380983415335220574380550849642772993622167251478364286133845\\\n    4075405688768007466118639099387705758393073081759859981105123899396238932271705447599146930788\\\n    8078054176491629102105650574976959834162716278148302095364531847156818244619490042076933918354\\\n    6339728340395982050673862057594322868693802377750533673649558195345846909701087899662801101677\\\n    0909693626265213903760235383383841592211142122987032643485796703962616661607825652387720967307\\\n    4605949770347077358256921757065587317634733635531790354296927346654968736690883602974455554497\\\n    7615873821780294023163336284744504791264627458278597288014843069947034409854096077970962653023\\\n    7074711154173422144773544767514702579480853332175371662209475121103341708619155949667450705715\\\n    4062649308594081554616371721225567044657880018618224985393237973504319353120877514730885896728\\\n    5870422653511477552953627561828711558701654265352377305904500937999577254075535738868937831672\\\n    1039580486349617292314912356743264440381120909755517823261991389625307342476537933265455586738\\\n    5146604647545137822086217646651850203555106763419050977985887869058384930260307375750241025146\\\n    5916494295583878233466499302616630351345487876581151076000931256805479358626449890668921429571\\\n    2008685694025632849015743450361802627364334272707636357945120248935106215613393705800257148728\\\n    3110827843886442567621022055353114923174160014068418502986960566350639307592182210538221029647\\\n    2983731927617636508105729893030260561146952304287354510347640939348623215809133621990753049300\\\n    3098630762956623691601795937354209970213639392897587361277016701840171036681379633450956192200\\\n    1965955593266872784235659638345688512246614941712526954712682341613631591952227310694095609921\\\n    7509021928646507162521288621357415700117905801792877995185647944515664256591793362338094136105\\\n    6420476154434301548273980924259374562736748222866488118669481548035552310989383031738897540946\\\n    9015448023759646045530115236220904940021063804389661690672098630143275663976770522398840186438\\\n    3153680375724021276841359130486393340241592173245731043060439518529299513185325339548690134792\\\n    8782223325047306830882353149027489343788402656613754459607621160314090192042998725107919819406\\\n    3260602545970297217072669803293359634723038611490028877540012025116087353402713479984361823843\\\n    2831882168079739711161715854774666088047847074641169068302762390990543141109339318342149222849\\\n    5976230587485114303865417741796005401777217851412741104238268425617314351450391058170770183054\\\n    2554487246175976350855782312995198392145839121984051926346081657996038120566733326427056157582\\\n    1652140057900502151132090046397273276323885451506232224144959349542432071907128237173549601345\\\n    3317244452877169194609277272142859975349946535613457451686468128938140860117052435600679910991\\\n    3413984438707984925110033721908499278131806264670317654215765235391846555642158896258832011999\\\n    9961688635790153437909119541807428337079974997431757806134625704079169365434058979805787107059\\\n    4593585555935437686280815663881097129272960062680685712091475315150628799199325123763010228930\\\n    5712461046135169488293400149514824888731174129839106296048005576008447179645643473686856588020\\\n    6274413593261292679306547475374474538126901796814029269686548030171030109928265877813889730273\\\n    6241637158987636177456566898985921724497352303431912020291622964643959736263570444977724613945\\\n    2265227012969736657088965661008001869794073034267582297913524481345261556039037384460764472164\\\n    0457561069912982868316833041187807033679169150447978929220323540591371074297433594274526407941\\\n    3865920521576499795880166269715746227624244463477489726121918875995142707819316890570214691210\\\n    3443750692824447690252064346231815261641254971000452227584613460041979026661449346096719601718\\\n    3282938241983799965095168392183000584430246989570840256134946717586996793828627147206727335082\\\n    5567103270932025455864952273964024757812918206444389853594968036845338293789631720748369638157\\\n    0311727962177627985754362211576222809940009299399214965135086617351703817554089081279573569635\\\n    4368087840245179470651605827569869147588454596171627977240261053034674934901016671682204281676\\\n    7213357375554593416947252726370093722260591084646272013116206368448854710430800890613220505384\\\n    8774140996952864505036278404853900945914982198632667084780490293175160107160819844284165539847\\\n    2074415788622907380192824659354136466877080444853094242677421601123695737795370478991033868818\\\n    1094369886759892690961959981097507162619952000602757509277588372355572927236691701758714082033\\\n    8338332455390738972460488184872977564103292985731106072801715120744518257575296802609289708622\\\n    6843589573076421379140993080881769124519296563848474634214265627292338047414863425385279051657\\\n    8408304071004389064207481494458067993778976651436262872628056427172230395722474146094210810606\\\n    5678801951134961070883966444622999069077434376855980216446054715375412826900536382162853991731\\\n    2077428313421871026030467275688296926705829747837736639901839632533819749580348633058451522028\\\n    3449731167725698297479746949869830425213764115795709568329381510431494957744815572103230137382\\\n    8298866605231454756838433781143891152607738055179091655393831061297820116660400841790649375803\\\n    0615447650409930909249717325006563614181908479271958245193034195827540993422599909285492220932\\\n    2851748394418141432296690131784288734445487744207153216859264577980531648183504588684411924919\\\n    8015455357584333017178580471076863751500532493343891046354510281255786943412397821767121983521\\\n    6799255951021803909124949648456753339002951353560908476113503737547152719461993655639343984987\\\n    8548933274678902969789266484653715208451025654648566145662875859311462661061931885134215455934\\\n    8523166610086387078065271616508719813837439189258761526345277360787983743552878666925642028861\\\n    9129607380877441745598638146662674165698484340112990413546152369442363923024378914744128339689\\\n    4154969482099840635671011217937804580073538789158784129078555241803772131601944178266025480965\\\n    6780407096459337059748706349233978271870646323294571447437591142320363875181369575603622721087\\\n    8424470523628520855467877485123328127442609331682539782253661552878329811665635077951585739705\\\n    3998532668901504555157939900678290309073042789359488636043934670932034685751036920257465064214\\\n    1534750551195941976374523693031224278453101753565520547159110171424801369053380783272476338692\\\n    5915394704417311797748898088361318824179230939093825129420893660089037439764839047202688903729\\\n    3986233008141199119019999120176459559123111594847963579802374692717282451729171496486242127971\\\n    1429585693862552148114658538587605625094701636696312394345702037289408878524338917401640266193\\\n    9589232015872292975713396908145592083269238004144956744634597223566301863805331109688026697237\\\n    6429106129731066021730258112808789830702665739382543989599413041414259724341049034233760205143\\\n    2438371407464655386395460276943425383397002680687080570709858202306297226590498460576672653091\\\n    2381449702305074991863273347784267504919196809381745156480224658477599599641191413303963095414\\\n    6624493720109558423884171777264813314115739522352878337043115649994811820804411837701607979982\\\n    9204136604361277549562548591257170171579403398952425235357397726398371758291141717989961811204\\\n    4937012907403529298020645856170714639885418500917874684462856827649934884310677057339035677576\\\n    1043528760376601895740725801390182464279961742083187063282256768947017181372921955036287205962\\\n    6416480759361709130271624587082376349196769192183022887333248561850997978051860664884387038779\\\n    9705828246100188243670856828332409288581316765894798416274573835444284125420962277047071556005\\\n    3667659439797177652213082603974158813501837062803824978833784872621636402645291642613502593236\\\n    2662424180151027264461117596544249151702125930560186328243443775684316785831288512564691840568\\\n    8665598379381176027355950457176506082302148645504440215280461853144764633389735233662189755030\\\n    9138052818544635803918193894341345501669655084061157294436889325890362010436724481776610174262\\\n    6801179238028633058106944147271919025863951640835724793873138486939957812978736773835075690676\\\n    4056553430116266619398699556204142331741848859057159275264359877086691086708436386657869142633\\\n    5319042971885481389201822906851803489862135450779586390377090538637579397825277942330450584265\\\n    1024303227963506889391980170178377238347575171272048199453954874436338215325248525254466872442\\\n    6788350879814544903866936608053765568076297569764199656795724886810396095166445120730588477273\\\n    3289433549936404364831186285718819596392098747745906901591908609649350064250911214151725164710\\\n    5729428959093778682001117800840104694074402961540448526864800748358502593800735721334168342741\\\n    6292663575247192183357216945966867386669708264978896201607227622129669075084506921317123469427\\\n    2162792130116274388903176051396734457853826051259319308265552253516234553381814943270995507303\\\n    8188748008959363081922669241507893405158976852416577042668135786384386094431477305324595922566\\\n    0039314423443479299605368314400612798961072248833726670406248782700156681574206582128338615565\\\n    0608682758218556147690615764890743098728151359795768494603157025174163547857765085718049172892\\\n    2334257803616931539622297939903880610003506584522956333850072481545294130681068196310662563391\\\n    1688055194126636573723738082107679272895582382270813390744165004768918074193548421362992450102\\\n    2509844215293506941123732643077048243695076240079812114405118616460096406250746097176184721335\\\n    3320105549877738289450971951860617394410122127632239309585154732696375946952255942652982532357\\\n    3487131913159703299281081281974448688540775373778458760824140792848890297652794519912692553129\\\n    2107484132995730900051529004068097572207925463309976464354756968780397444093338066513705572466\\\n    5526397965956895901972949562124075873897274360135037511273525398068632718805728155027406135878\\\n    7099991566639027321753736801784251460026371821079491630115609546679507621361452959564577147502\\\n    1888906186264893319863679317692998353434731266172471007352453955052880131139739426361841839038\\\n    1675349009908212996283460390589695071453598690993538469164488231366932875696126495649418256865\\\n    3454581478406381406351653972082096545265174017273727780231283382631492704104004009981368742941\\\n    3578420419688021617178007633346914955782503224130565751741289752097136554575931310722833172176\\\n    6376769462257452667370790410133198940546951253961903131124175918521563894746861685440570382247\\\n    0667230733658444146472309289174545437209089796833553932067698645155746469664323655803977346210\\\n    0845159429360582687847752438208444968216675695790339949689958133028030358099306313571714266098\\\n    1348706875651445415070136823786942349279305749742308594927335050359593133446001765583019214000\\\n    8488427001021469114525131487507599818721174302066528595546998147389807943130093133415098743251\\\n    2989105795754596827781303601723087936541136734566813077230898766024106684176280355213394036735\\\n    8249642906067383344368515125065867508768121676267517943809810352526503528882361994588348307106\\\n    8338115563170043548920714678490889323187148787079612262566877852211083791653800970680092605270\\\n    8102010759533072252794334866353344404536435923636597486448953699871579351289913753549358751801\\\n    3799503184987794051239804983553099127311506355681765659108869949539947118079238815711347390607\\\n    1983228689803191129979958106064291499709737371574601861171947953599703987072462437335481189154\\\n    8655885862510894689682961045750960923964330665474280199946490869322993180364540662013583104913\\\n    6560502936539124453000893384700516563055468246320950086077862847130752315626282651785015458805\\\n    6774212950838901489853918672987775916911319712767945237373641850078495643815856778917482157740\\\n    3419588918549913350748477141165342800669010823782910726681048695486552010765662052138375334264\\\n    0960745756777953589232918271206971818193235446106900487041789577019276517798093846827435777050\\\n    8864273416199375282186670952867194165749784424882886588427777515869899761264115688763468766063\\\n    4290245150493617801993757184716778288906802649766587571480474032464380087641283782302089780810\\\n    9628816921164965083717801064600988403295488678450069761986687382232458322403428829161642462565\\\n    0065682309429440305889615984111735213293952329581498303861801476381007067682971287372202416123\\\n    2993483641162112639867342909814560181052415027299433877523724228126268161150547642967486813144\\\n    4921284603844258009271155360392580070344910658234864811129983246485993330749731157497890166403\\\n    0653785899197083101722689637103220526264911931022296427271734361895795366471979461927592800964\\\n    1213946211103058063840911928478132059206725510904494117672644470792295145672236906977142930693\\\n    1700506867737899867534932470830657135543050162312653047128608998187569678500503465690857630936\\\n    5572631386316453197549382823809046362384042730850655565070001657462049442271963277950798107505\\\n    6488023244100995200195441215944571170534176720986286904044702337037735743428855729466101901577\\\n    2371092881221416932550819038262562940381617578417788201192880106555000770947735197490758242156\\\n    4224577619665764060876424746819100697467041894807077722373053700851842680516206927237944228106\\\n    8573999899617798150313310508272830651135658054850856239373659999704597344862544079702849134417\\\n    2967036139490424153334986345996393009651715349865646221368469444188789770460781699274065153869\\\n    3292129544926561092947629173266082641518576753039344060395119999538808422908149492953790170964\\\n    6444123295191750312287275695912793644538284979226667556145998093413414393310250929962892982203\\\n    1109543546829583762537283692281578646373790723662189340849784969121352440209233674072962707146\\\n    9188922383750716808571527099190690973088011585982170565673513183702521777910271939151672409314\\\n    6598678206828380440558843335128180524978626974594936931512348395457617886833195403867869884364\\\n    9664665899529671516384185914629098399862422326992207101541719445545704752443457764535466051010\\\n    6629032423243654129128457193525337173126084661344053149085231694408292325197433159625647854859\\\n    6960046606749422898013967814631805382096867892889730603687470076400156458967806212529327264493\\\n    1967605185203411387049683820610438311428718551434174008529477944825369668397698782229057152823\\\n    5100603018887472342963890720986980055400856093651968267138780453332803865872662725464177809698\\\n    3180885661201440182347684173730748177825057760027746298983408612229052459484933287293845579990\\\n    1712365764010187298672550477877517157862616457583676996707107171624536140984907524103584434367\\\n    0477285495637122600971455318307959733040899955869201552671343810808225285476789071145568400678\\\n    0571294450978442085698525932601653322131858748503602140005270144367401899700155127294065056372\\\n    6910935262285363619675099698210995923780774232573745397931356237896648788704039226134602761676\\\n    3273206314863317919733125838527150708569134568084625143657354915506542142909946468742514074849\\\n    8979813773392114308600645065774587025769029715069629151625511768936214690474448975354746551578\\\n    4255595221124298447134075839411308476337300236967840724529660486669074992478015985384476008333\\\n    3163343491827041840813003978137352888679848935064327040975168682221931181479742541896612153579\\\n    7058440638595178463553216107213431970580652320070903496369631079133432199587258323269889710840\\\n    5631209838864642622566786085830762772248475118866509970325540182207504556189476898054259826877\\\n    5489796402840075122739528987003017852101792326661170946053359553217169487316831334168465122845\\\n    4953899564888395604338142796616795414763884846815992291089180012975277734225559916037467507693\\\n    5201078301127509840319737387874976231253870428712337001741918743026293996180968896499720318467\\\n    6337092039462282368883661690662027975732184874034323345282466368860783913081030957372632907861\\\n    0327251190663742157641913978727871607091738966221741603228855052980789651016490528564140092870\\\n    2600419004482647918774903480173296252963324801143284793453610360472767392135593925836258263473\\\n    2445329369133210247116583252677221977349816306069637027704763262965621430188031264584118738270\\\n    7590386071888720357712019714767613858585766798179231965045072466967297474437055160025516660338\\\n    6862137991598954720457153486843687589438061856563979382341679777641072873850892736818638761696\\\n    2779643700696995160477938681310209708552088940713041500580395665110364507581797029061891499649\\\n    6195552845614614774817929528744592804050893592960019681911424824522771487943171220633451278346\\\n    7888065217875915288075088777216111371889591048696400061292129264630454229789780288334061934313\\\n    0163939140168559416774156118657939898577251261342625224531920860597208080005934846098046947733\\\n    5120295174979268836598788915583356781875678807118158366080682138479457967448846783927603013580\\\n    2314079082674740909147856147734521152036801625263690976303547435311829823565384130860362378289\\\n    1654554285288183811568739035185891164435491555215203168801792491017857457886008725273466299133\\\n    6025026928606722681871203223295043916992992595278093235184503864591749920727937933833607681694\\\n    0497584505964481569061759185367496576133342143846848544336989611114047211747336175998663033369\\\n    2780742897639449854015701085670906570932905513297091385315384202730010478000904251933793526636\\\n    3089294073227316395051533842693884761361405696837714334604611102643429254571264933614999063541\\\n    3449113620753364808281444518268092383052771491614974036876513138313965914830063065981370829238\\\n    6310503593684865449145536491439583876643855725540045754066853265700293397375364103949699334779\\\n    9956635430494917417918105186578173734780327070301442210567759900175750816528922387329000416775\\\n    6276447776788643488167112004167874916036087972162481540639181879394353517955270019622184610513\\\n    6940809467019458157664118913285843606415160753943632618356899679504220745662567666381443540982\\\n    7533527469432999133466236718133401821223653152888686364623876383018487921772032463554427861769\\\n    7387203505389852065440160609748716034741770776615697974559970017019365345681167653607269083231\\\n    2522253639456660274201520185820491454610281124683046639040958500244911179736854368930897221223\\\n    2969183855326785808857152415080047118878430556232062512744223354437332458322357524865330110723\\\n    3092476217159618332938617126586959879192261279495755242869779219111588843494039382155819655902\\\n    5183922375111330902699475850079988570001705547069012123935321805508520779652671231197953366071\\\n    9156240811816208429977316849169002766644317169737757545234329957340477217039952736534620070624\\\n    4929723204800844761167449369126995658764531440168479915322323571274102718715297974604043674691\\\n    1474332771586701025211738094963010347601988553055710201942636505461617157324416225610559689666\\\n    7293433924018328817047533002986758994628231050237187629158768569452479918566793526818090287476\\\n    1096937276829742166331472974680292719721100822544179539550951710913177761610405963815545304674\\\n    9158952719109841601874598212598177068931505831741797347919830591158514708441179204046777751607\\\n    6651438099947063670845439974928199117961097997875575101037361694622069987150959500717355492549\\\n    6061795575900790888064967137160126553984934005721826932549420070400532517233489257648934231576\\\n    3470804179599516388060678750359081697707157493674112984761658405806553696191927671016030222196\\\n    0219512884342738742188062078010894119375666774550811570237811456288868960823118652841479732199\\\n    2074215547668359613430868576770939225034088622669121218835348151676320568389025684400735010758\\\n    7767476334280418540448717431532839270499505471656710543581791688806571628281483227272685395517\\\n    6099594226250595694923040771609478260696994404853381187273225506800290016815277308234543779710\\\n    1964555950916041035100941820005590017152356220589279390114011054131905420499231088556561317316\\\n    5927075833262794419353408056952656196039359877423803930444868187704067869380044275854134690023\\\n    9776442198859051849304321506707993539292096857582812879703099923940978530216597515604808464442\\\n    8655036385408895224106036230435390526924841311289855389426730449538254443948009595912502007726\\\n    1804120491265216528331990057037086724045232355001165628400624391771939502350683593448056895620\\\n    2046774960289467499287175085861125158371154054475848429313000536687773811015307072213130869705\\\n    8559223829027502972495215578919793543504312781008712699249485703378080304640132680909087296447\\\n    9028556554418473817224984392772438089146104753109918025514600244398154195162311971460516738927\\\n    3180160885230638642580495217386400758090549342375713737365369212600989014592997143439568649703\\\n    5770998653936814991355767617607938779829912639711185724786306009362282962292743211162516512096\\\n    2166445263895979864786632851756493012173374851266277362012623242359466445369867437165612119174\\\n    7700887387943023953347620114457254545348189955402809190124634697316474191708699676165607968592\\\n    9587363032505177437801930580402422362121106881996369583855006925849798258721880395173011336728\\\n    9888892601263761204408692022413756542306374049759089740244955487726866858892251356523698867778\\\n    2409924638830867083263182837699614316302523358118102316123066348292924532832205238249955095353\\\n    0029689793955371509469278303536087836952511269324185041556983212709293389756225824446135870147\\\n    3274003858380693691444507541437594527979703741661075214185647471210581496266583064080210948285\\\n    6358073439578712199083849587615085525968787384231951026454323049743256675300533523397770532413\\\n    1523766558047259657329421431160194875260481847197054556160011685068575784827568181754285562496\\\n    1920205878695410627982273796680373963613549218143595783087896904411778062337850567874010483917\\\n    5512709435241917429119049729299563496636533159855205226366348559847140419480867120223544725741\\\n    7013569682218784809679643428390450650237139657648766549499881987454070023844951762073494923154\\\n    7885698083919249939066302058176376987999362894970754368554903341641729174489989353554991915341\\\n    5563502522993323262512938358385654866103234117489784070713210878522436586506989680837098232956\\\n    5178841719524681846150404829508362030749514706162727641219609369166710308505610768034544569922\\\n    4846879803393859871871497826036445458378452848806574362621812449760736726948723766813066800586\\\n    1477512174771361710294791180129928347787800988545319101538262601930239740311389631903995278590\\\n    2053717296131036440380812906601562544108527585446686935188490339043042855218532982197718889777\\\n    8220881193973258705442245248481827251259699103862042682542446586266305798534363646779725324399\\\n    8918735913145630494023925024327373259845813464123230658214515627919114023900480740644078495943\\\n    4407636373381739666251101183955548389620147905726734404277843649457705505249060903240024926401\\\n    3376070687813936399250577555133644203139137685389680100462876009904297560747897571937589842724\\\n    0367766478086588915843114241983199214011507011982633836242670711964555825921527876393925493673\\\n    8748584181768251230312367790108090981754626741379396337904540937548972521326378711358114182321\\\n    5127286526405247162555438033300864883080507057903056786589408279133026180503957016846126633010\\\n    6477804487399546238948234544062870852190903982628939530592161907904826806338365676875931704405\\\n    3327372710015113116034696281100426819586939824658862566625923052160809032117585700396113700645\\\n    6278833841834887821859439531191450834311118825538194630464894251163571840485922254712587402500\\\n    5164211061403427048142750292354798243915561494274305366697026985532119940632085699602962234625\\\n    6498555741271575282399109061903017034509292814429517306602858920876256567741455991149694811445\\\n    7940041169150521677022730829016997268157534913654777488466732417604583658144355714431315875080\\\n    1065322827252666493318205473023771578346231728337485856643885445547139238145401029295996856572\\\n    7348596530591031310765913468569005603306371586782117495989615340314503860952542182738831972214\\\n    3049742151494066026144737454647062146672621132852589885351076663083184396085871992366115506107\\\n    5241330042654314274175152066271292054271435532945652168784954431503057431988418180946420763105\\\n    8137662662076434585183220290253463872477504764432325777805541119256371307820720125004604887479\\\n    6228223290835622944943543540789949426112781645055545456579715937254018183226231796291982225861\\\n    9614345522592602695924168496111134748770617287546936935526677480963236426882908859082242078391\\\n    8191918603260295135158114905739853838599450968080431419102183868041333118115912195600243475931\\\n    4520198882312571763798264133826067935615422294408508360317121517033486720276917704492275059344\\\n    8813167113869627516976291722414467194759463952909131015374028353478128350255686929190198238999\\\n    9935479559850038165794517332973074606891550581179332521224946020408705094591788149182099667469\\\n    8144579359592936512394773631471655018698234761124970562972699311072266022819857215672973957641\\\n    6349744184245475259186043125833684767326506662826461831634313310798604693470230585951376508071\\\n    7537474401339151158908135365186277011500909460680742982814407553346893685137459425059687085007\\\n    3387936813407741264159712500109593515686672060071704340517682383176600663574639843571600324539\\\n    8474908290093292174347678741035438865894024013685668285439993983996151024551885235062752497907\\\n    0819258297975726424295287173618901861186070147277919645853379176641959907695709432065294358050\\\n    2742133970388391241568479354434192704042738142291650232998581984158599214532721306326090504447\\\n    3836549717575035988575009500183412435384131668722285618774850663808436325875905905717742255228\\\n    1541436652946814567541583269105621884741337292458689340397206680408489682712713228775595152047\\\n    6226472337517889786225774067408702115893695882077345886323469768010064001734398184591058693384\\\n    8838524501272551371230046456739794139524404582057345115653933263215684720974823145331914649291\\\n    5345110433572197925961661147891690197208190784587263101713679487479546680990137349266347215165\\\n    6521471823809534552307813022856388109983518768980622160681466645088902051115386617172439758719\\\n    3783997273510320813266108926655887322822924388847509365440900814609176057584344169268142860531\\\n    5351934245427682745943147815296542501853961954637908778926418798103581846529445626012945729466\\\n    9549105086002955335599336243465607807544040863519139464299456943078065692464565511472159735236\\\n    1292804785386786123091707215153884742102842306749389350511276572059722271808299720100383002492\\\n    8474861791305974901913247278565382584730136078663333171979671915504102036534409258763243051916\\\n    0428908357798423425586737869717725428282253535435566324087941528824140994228108634766688837851\\\n    1802472214437088933773923915812387249848823114261182376689327672008570998021561632808368618265\\\n    9490779794745641954434496675256275580945300337144760132496079969324186839756153773154794527344\\\n    1304653796964390883089374609369036292973715529438786385582111766098964696465667932824408649525\\\n    0365060588860434661476881599541703155050239363924299170422173863719238323240104716028835864322\\\n    2926768933314710161773788090034794209407008572109976192695125523599160775384731944941108830788\\\n    0754122604442305826954764477005134954708673885145684013498692607330080346308838273845516019170\\\n    3432324496929310003676689235452685300403490743323821940090900206829755697379518254812831143671\\\n    6829137958663742958217337051384589577184299390705863504093943989540556746784538044450872776728\\\n    8016042438181105471569768429711549607238259558477871800039362091874750516808407999658903214854\\\n    7534822379256708817960526052863614862460759424164927971802628996066586547717469916846991895546\\\n    2036717827706001824478826040356777672426019456366587814956006638454412121597558344423506305760\\\n    4492454949411904623213871711942899553403037735995611898813304068692293843865100454520775761157\\\n    0010295926310228462396078978449145695639910867591333503855623144838060711680558258416790647514\\\n    4704826762577664733796441971555701270443940973528243983744493090290056291560887658274544228583\\\n    5948365065982708617266709675221633623463106338765999816301051735407446139197522367296995667029\\\n    0109397345383745450494415549555449896190457400930987005020756274979107878059569614844303722191\\\n    5548645387156772166772617419080593253081277818372754021930016057134476173052636704796006479560\\\n    9991931457283947448688846129647078066623556046644505832056654838996976351802839760507115175632\\\n    4067719303531267660372360365719954310961481304463234782469973242284963019829576332035543348985\\\n    7190056997544658015790722500470318162068131703475498235305658890162573752500458233939017466741\\\n    0444010789537100498217521010479356515181905542951105993819323594231214150374376793316552590307\\\n    6342508554581745513651711688330958683670851031241971069330703232174243331176602275248754383385\\\n    3578429947108999315160798326387028470411744070234754406380167462793804465600631780264809326713\\\n    9163222954218726593810502426436534578974856851482977882103629344827384580053576315539391469880\\\n    4518972859592573157549608020115989714280705390224914479019338897065452367982775683330139403113\\\n    5663108037512952856236642772632097321840133220139682496969002546321209143288416100328964073275\\\n    5673113980255069306954397092766404727544222762463002172029724457425253964761656836169542970400\\\n    6108564720952355561304900385086880049017011707414337725353366529944707128420195609213171383793\\\n    4557333451439186312815352282628223221421039887397522151617643990231101323079765761414478085503\\\n    2412430030424921681866002100559321457287676086641569745987561101226172994627840561867752295951\\\n    4673415881547171129791425327171243348847516601443940097692879628776181191105622147710885406451\\\n    7558163065286142180699613489010915103418974173608025589484955409987855083538127040379214423377\\\n    0463117095237604944008894328197682921511250159590079096463421764015691143152548528997651390899\\\n    6647074639286689643269659546952537893435580064902462537714468259063617593531704869734908901522\\\n    7180832557488855992308583552847915683917215749547819407154165950377387139821848499231332081358\\\n    6293267300902541580294962768850933649615132506886327960731444325376778995904860229022066391930\\\n    9638000104381724941063961942858066382967711506661573395287637986240601918457263172038473314838\\\n    8204742952674281583038571398086755685567167756644507485889248515916143175736304760830182743941\\\n    9818251662244774793784934598731107484812614212004792661428791714036050173312123053363807753851\\\n    1635022040912667177250777668343144129009579408818012636950480474426830076086676871544192397302\\\n    7597546356503215336236748844156792901573291484337331881160711622017644205085541931157869567393\\\n    7864807746456603001268140622371495249051365292544506338682161141916511219277107344650188026801\\\n    6480997576844566641486939878634478493787421937967870610816032012722885205279963442738832664285\\\n    4079241687723327892293505943603052149646482379461047817085806379878360754959018632475115679765\\\n    5424620777073246996862656504120856275511246599414767391091481580761427030397961274106903067568\\\n    9310734841030422965916675931413326264270969889625783654222862674927041744270514512589305692074\\\n    1390177368842742180288532207247283312542329599781084513963145683900176383088143919661906764565\\\n    5799614019761474505664832314659125062287811721360184277442479839223156861097844205393373269472\\\n    6715150436485932282270860528756007258917595404912079818498692426326753225085126044810738927110\\\n    6976135450363635828402400972737979566586890680685324649563708266598550879142072669895636381779\\\n    0977390323838017435579508462716356037400580866952273052095222147572004107316677781283619679463\\\n    6225218484681060435531753283046506684077648743455101794415563649802152756286910181312398572980\\\n    8712922854427873947061976865365307437115207904173295523945224540555685302643986800809583319386\\\n    0386864490371664878396409805450412474021070765393153627048828482947008198906379761187979061076\\\n    6159552138520669594807323953623348385400383811388590913744763125003944785449695895560583693865\\\n    6192511656037800652799203099942644243852306843470489308510754079444574598107286206608941023223\\\n    8388326110862521394291643038356164918910485685033289435400566730290697842733503826229621117195\\\n    2278903540947930170761841425321602734087812967792375329780220313034158856105556876705680146604\\\n    5789496818916038038810333753768263037297091224309244554481665882385591118131661979335986768117\\\n    4615321145921000640435738984847711087870683337830632064560428566303784490722295340562137118706\\\n    2503871412813458351262674519556384946026142956221797136589437990006798328520910094388540478485\\\n    8834284580846207096423691970216965285859856229241016558398522577871850991904722347961339123250\\\n    6051215038438643985690622380410967065884016917889155692883157168938646903132096868616738035327\\\n    1055040833642879118342737369765702218393438797612138911262816476928214256627194649606383867481\\\n    8304146247476227694597398801000647222927302434429500392125162282321138069245421748149718847440\\\n    5733968942839443779826416602041887907665112507350690926623467350059318202870385250653791024544\\\n    8783635450507554441782323029720876542647793973451586928633071022432357275894539688228800789051\\\n    7544813884537650423045254013431528798295046329296885656821275226498874192394513777641066608415\\\n    4007661630719508654487877119646177173523004800927646368284261796861495189115849000102663729751\\\n    0649957224999533689248825761867563718660078287530679794443877974366743348629001941591009316193\\\n    7770222436441225046346163185325859804631667496278407195253225623537032018485303980925681947208\\\n    4262391425064244292589495680794741579535491498471845922373875475240267697934668903196073092577\\\n    6329035203410314134680595283995923489330491371600699821572559457020847655026656240014397189339\\\n    7069441282827342371243216042908614254591384413888370847038908240613618141602100457572787475681\\\n    4810915539714033472018626868932126812186094062375095864368752531882431769526633710532654472461\\\n    6701378101286434446934635016560642108632731685171914521407929944697716916580655026974231880447\\\n    4090594905030916672357675485959664098477984528198462588328561820351914203415206249968804639493\\\n    9551972415776217461405556920790966551579585184188029607605564599854655063886938845491149827690\\\n    9653621863872011281023367978725874797473337173695738133327244344969082843118656006050962695853\\\n    1215750067161507304842415028160985183375705517718467451594726427559666668940821000616872854354\\\n    3272388946431865603764251081896199344799222904518466603889718240779989309287529733241455169855\\\n    1052547315567902847253806250749074327371881547418355281503283221822703697651421980874782349972\\\n    2508532722296127482908488738591479368685486864654591995216874342873680472100363570971019014537\\\n    4665149065227552836317005730447525749934192020995020378955582835482235817047535202583865082338\\\n    5098463739387268313300442409546604661852817358675429581140151311541348498698775888595189241678\\\n    2686006160711019447664689955096076589622035684840903294166519606271092427418786809250055246923\\\n    3281046349337183024246498038459160822191524499217794658705996605444896771920550112700221142200\\\n    9088091242956568329007570458783721517496499795694810239366242600283981411675262813714737161216\\\n    2067704186684071089096573972819373642640239143009805995343448917574771584658267014616363630373\\\n    3476160581456336916517155445363103307435102987711948503462779291107574118321968947413632510225\\\n    2133909972785766510991827178989757838863566068616594828392805231922617235390604063229109050358\\\n    8855978923791740522180792020824503376513707046805591140361096482198271786099674200125116077219\\\n    4908075175125552321333035916864709213601829837509791677911472120258010228234896400450570672464\\\n    9694532393501624580358796238474713120725846580658568214935448569378847988271305344612132727179\\\n    0455178808151756273540510497454495635232938330827303444309061086776339944794361949267632645979\\\n    7919029249223823186656764342331956958910013947308812648914565736933919381248139916265160488970\\\n    2291252866545003334049170526614882169307770185973212827384401546673459568446243084971998911100\\\n    5326792440786643138588614209266853308554992846612711426621469809402609582845501279562411017494\\\n    0147738635892016825671090069867482231681557236763435067193667001125703807107531952258943024728\\\n    3921052865828915119901358886094052176165885784360655788300462888063584423771596651725190184966\\\n    9203910215756389666340817765360881319973351941549128775909703532074301169552166214490573570525\\\n    9455030043523095150649677468465892932436417179886007070738145321017121549931537273283627338983\\\n    5037587809857877044049625445251701235997299250236550381266436190884013564496992394395416821282\\\n    8341355032434304180808265525647728404598167182866317969906623139871301638623537245001306502571\\\n    5443525504108070153824023483672800062105217757480195608084685875526998622511144442970094663123\\\n    7514777630655572875176850829198813489343396953884280110060995923413673495531547399154227676385\\\n    2555772986492275829484797833708747099236427789893292139714499664023786297864082092344609935661\\\n    2026277351743891695307786319840813920329181884297515375378144371138474135258674414265093797112\\\n    2681081997102550897033212787169223785012975040392196032407641478654591590284135907549868938183\\\n    2998566202785203136653711609341329089111345597458370887262957525217988987314930161324405129142\\\n    2439941256086245402686363037093874867758364500268311300951124586050881268382806955386807729011\\\n    8416624159802831763195490027748817870307000273655133315752415739250653706940161520879806115554\\\n    8712575134987510732460615008430654223775002415107215661783860520266712626458336070685739369304\\\n    0759355350312790304718787282560019219273955207047753584011354898804108179515911229044070099772\\\n    2389609143238998829347816879882243465944286425610593616587403532151018946796140369364080352755\\\n    6496112196689177113317569008650319084516603520460739031787211219600544883916974871367918686593\\\n    6512486208676290690849175867106232628479178603366367928104794892981361913597520853613543272163\\\n    5495642084789093915087936334420160784535976085904507402919452669635779463107482689951798656075\\\n    7285450697418916685064910402061658121750997955764094700079718369538608512305451815184200072233\\\n    0670598515609353361800447999149903970293941704606329146066237869661374285991676673277512136219\\\n    7063663546266701975814190680994165291739928729266766214173888644648163400809444693322872772124\\\n    3483116401088651205024636568749678151703342709061952309550600535803965258822045392354813000646\\\n    0292301358013369744322109206552408309486353077763090722024463346657811495534242074868579244592\\\n    4269190753856389421331964038404829041409313171336221715821468209404510356874008005265786558487\\\n    5417210071565397788449999921766594999024952111164363850093924801080026999149077555009612681039\\\n    9975294768450179317473482092648740093509532139274104278741954615438390410397690230595655261249\\\n    6953249532702837291184269875607547434764077432955767033411423459569605903850869451912777694176\\\n    5995576271235335208620872673047227249726399351390841569742848879473785491622537998738212771907\\\n    1472531490898345340873309652982204147011607954788446386256230836639674624264764171796273126929\\\n    3936561072691883205923362042553221914717372055107942205662738004854482544544846848827511732661\\\n    5877286981491091297314751794915997081173983938706851283657165992318779465224028028941703794069\\\n    0309662506011319011284525304583517284547892136370746905510203149237547992621590536617970019732\\\n    6233947548969131479345316429007526886721879999293968099448849514065696465210724216150042593739\\\n    1401873375864297865356596196202425555069423787414768203574437362688010018860413962151056043517\\\n    9045848271230520523146270324314232534707274632761079790890906128777208523408961665394709092748\\\n    5098746653866042556486972267130676177049010693858934636713655603445784707015946310076903130321\\\n    8618008750066468944057520242388842642058340648186713790668931095520084429406672100483990454356\\\n    7194875639336565589877325424508755509062663144637586976496092744949927147984288954885118254987\\\n    3109917277975392175277703990217635124538718142064664926300510225632601048379907793244767296556\\\n    8809362782768805038967500610613918272432371928985107196720643287550788375514099706088967595424\\\n    5066009545791838237533317587604346232928122903243722937009096156402381538434520088511110606342\\\n    2769281226315393623100797349751529734813041605943706259499439165470645346326289355149035412236\\\n    4873460902400980859080006158950965172313340536011396826982962567597797656761467420376403058845\\\n    3840969794516229170313461330957353602799002945397901797461204004590843756545448171823083114121\\\n    2216800241359486884436301787104720532282037557822018953689650656673176328154035622470576317934\\\n    5334166719130572433735160794615521373983659620355060940681149100312460563595532783377054412350\\\n    2515990515236677708210598961682430019237179139071472429565573162311841248580831694335777686868\\\n    4647681034818901953521799958807411969445730723076910543720565638576379091791647235229616480548\\\n    4958009686212004416619410400068481620686988190821892275438194978929200764834327223960194331414\\\n    9930751853565978137795594401409170369319454403444553172917271682704149715375943238166807126913\\\n    9502567785487545401800163189618869539165058286360998047566953050716251332921462975913802095047\\\n    6364439042211571760235992413574461669063922451369609669205302887085036536394799614851322937749\\\n    4828736718743179547802535695062811002372309595843466796966041166564826331299921767776669168594\\\n    9087944049672618976644746460602717652165200246732219016009287150535193835874513680121484717210\\\n    1065724184508534737717102919775999548991425189761752555619247245962901792769320015415590285288\\\n    0866187203938332776110902845779739191981421162382762541301352239760602153763489161736395353967\\\n    3915370135690148619031159149846927329693906969828608840801143891649538450276161006058439223311\\\n    8607009433596689285043104011276491014657346709563067997831891334732831425314954099567884717017\\\n    4270758869323404853490378536808315994423804776568301241879090560544366853791976168441852557034\\\n    4268585133340531342997101424284091760684595924774333476620510004351693423301549352383929580033\\\n    1983039830500976972488759091760674523704579849269087069907698330364664333968602070591037827347\\\n    4691998740809343372826761447554865386983455959451835046047449596759237126483873220414308875879\\\n    2827870109985104888338242961972945184487107979331228215102949425821023843753590418772531393877\\\n    6456424415163661862771460790583728528083662889503370475715696868311797128314387300310910943863\\\n    3351779209792974762989468416566009186433100765450576251340902621211290955175160889441492639575\\\n    1555719609616064095738389802725394076405527387366894118668375224933091628801439700830616063682\\\n    7341832406423108334811514557541888803504695018425420979357568935695681395660393140619751360647\\\n    6979585762221003863803109916613192368619017594045670075150704384641334374449427926042855142258\\\n    9640080852545813187603526952097475428519628999150432296312302489076408927653400610022547307668\\\n    4637662495199397676186419777146316062906846915828283650652469362352741265074740502751727482571\\\n    9055338988710784649230855304720681841140841776716630069376017839055207761471891059481157307054\\\n    2326072166479175837208779030477809572147595101688790682656020003697308068441894169755936255279\\\n    8074845505666233745103734353563240338610476882262209699992333775503670613540676321837659962050\\\n    2511457482340486704728599648489067374837468613252378875966914304838175264104829235942374661836\\\n    6290874103693943843178049422577344167709401427128691810579553558322065293394866465365951756753\\\n    9040914684841188190127005063437499205256976758333131267933375745812700716702983177370192595139\\\n    8340651249214382799964778937270688448043322934214327837219964328213319652480062303100554244705\\\n    5690794258038952153555237058017450857670989235743394741444875655424952726202694072695111336354\\\n    9339848118121381640820553226421492418869502599678314600473932264961881709605500893316729487348\\\n    0618000362706612571266631141404624214075148496376193228822233175840036855004721371126927918419\\\n    8586898095184930921196152915053899390520932743225438727158232076419792258892446134415677707795\\\n    2088962591165199651330256635911785079552673176583221768957688743629698084754610757346051955456\\\n    8751808194206971625835994520010990624903666394993625766537988058635010157579633195940464572360\\\n    4086987579297554239636839343172430691913646967803709899813632361268847715491439761457392310889\\\n    6645452336141592994558956262559749396531622082816285696728427047206194692732114666782340973256\\\n    8457761688187619939072217853875785942229563578536975858050686417277836268100501742728851074317\\\n    4185527573620236311076475730451135495056947691090638741137198575529321575883804822878548775715\\\n    9012128912742125784915728165754839622139522186811154183055014762062351293064832751803640152632\\\n    9426044936716945439392603335066920775008300123447434997283657305793060984594416138709686935835\\\n    5123662787546341718740142936473673151481111111311817236894292052181733399970935572012854914010\\\n    9540722697496620823036798613966554750400466361247272715836392072697889849534986292398962792106\\\n    3357941992218755392889759257873510296285028525925181902107762346622031029081952939430048494949\\\n    8832290138517567574910528645646686613449362537342373328693819413100612538174306703190118451978\\\n    1943659531559448517696338668256141169384567243009710419302147856519135137241862117735104794782\\\n    4675285533639721278213763959455666655766721589914447995893672765305013778103861743927774935052\\\n    3842738760562501497042239978634531512579814391934325908980604408945809791972871623409453582384\\\n    0332090438354918794112907657121132745699412676830249159139199133392831221787997947805594693555\\\n    4916941682104468951241315874757716673019515854077551172026968932828614200730235721727187393351\\\n    7901937342960877470116216462008192454650609406113758873963065799126449364356036881226737374432\\\n    9038673921872440458256132104198330816865401819096907420741336830514290141061824558834850375434\\\n    2523526316121979958704016906237376864240193432017707929954977189636617940741911705641245771407\\\n    0561351020895494260852793065772990118754948802883013941990809039699817025789526133254325410208\\\n    2608170605077961261835120433226274914042267303495652780971488651239168809541705466906692299055\\\n    7048948511861731102210606995054395892101912311088537664588757972832520670498408201276237196010\\\n    8512520110851265564153194710188932980302287091155544549879775883350762159890671189088708752965\\\n    5656001585777451612868662080761603725668785869653935955552985145277283673684947522863785141440\\\n    9487878555858982014336778260686560807640013442221851001558496035430070125031277890432477799684\\\n    0993060893337924762684543930133125010183974267823845681922080988057494360848386936201543780659\\\n    6584796880211789008122934077856529543554087045466947189174036580904080734103401980732929898491\\\n    4651355172261709103632666805916854849192270297599258727335412466569065548468822386350177617614\\\n    5797346133217205065924966148314888116269486594637277264776637014443897340594928739479271931183\\\n    9618045496125856277423401430715994477057124683851893064816137352146096913342849697924143206779\\\n    8121299705673282514560809725504114216012848825915219790140526451527500982419356018268149746755\\\n    9644421908574373703884249033468280447249107894263330218719260814394613550346333700954166539533\\\n    2829180558341383324390245518312046432087734304537796864609971845339032572633884148867628859308\\\n    2683210901602956272107176876877207836525405915088132941615007622396456551544296599879076938611\\\n    8615440654716502391369268684171582186213330878763807928574705922489178358914957171819761320355\\\n    4938420786009285456409061754332485134733596128117882771966892280242814305012579773753700923101\\\n    2503958721036342503987105508269328767085812720196705649919626775327101846237237075279784720924\\\n    2633055352003715860396049311264034311866247139937133523168875153887150023373069807245279251544\\\n    8141747408373496670111172179222767628024426895403032985579388404465199150920629458643697503288\\\n    3795913078148151901445403532560147343712658242731051809597052373669991765842549367651462311492\\\n    9862690481885744390333399453995508319771522542122005603614569969238111889363892779907778044052\\\n    6353989356954121493777175738426501327985123978994551018927234072273139950310276653126942797114\\\n    9992671979075769593300614669921440573477139042490561155364179610132684134717250905971352709557\\\n    3746368058519248941732792815242513822186061639110620977557854389579696158642131123768455755716\\\n    5420963953878588609003209348773869339647594157603534453231539131596205991450123020912675459160\\\n    7199533212931317703494991012497623684355506403523865897003875420654678815131370103652331918883\\\n    0013338967551366138780186260837815620667357794862496839699473489371304444461864472202007469615\\\n    9107286297397047634967751013372736767608900210859921722204460779577811746944878531225949149949\\\n    9731261214684142994581198107255722189637097103299003307782538749169845002299120241861252939490\\\n    0485194631300935927763498096875792178396446994140194865870988452786159030515956812127025945661\\\n    6732028846459270976846450367311283706745626311410722265020933279728949147347275424480937869928\\\n    4382881589847868919228196608903200504721229579388826567013147865286711818374425747492507483900\\\n    1147380308709057226376709098334260411819646659944698357996551038302868923162861546098912898759\\\n    3875331009869900871464290715107025197457791593915454112209596665809227278711811972939296383361\\\n    3149215371053866936956624612757216796559893200070304744924287243055045787542874960263044145085\\\n    2782366079159424974494878535853078705432589836463966730145002732813547828016461796241958222293\\\n    9910553146888551910819576780375337086035438371178102589868799099998289231196335448967286226105\\\n    9855880782346716734463639842048009774484241341978553075781165033523470789123043328353865309620\\\n    3608103701865661188537889516138530892696009461280324973213209476749130676450971734368831362617\\\n    9720699422052854646525563835397136934510053708352098078182758896958268763944533960021547407832\\\n    2728907792263695017319980081451967396172276243451445166680598417002118775501359732591133779308\\\n    7698756735904014064720463574704379742171036876199398636266122598374711711514341447894202149278\\\n    1499355472743627554501486160467969034359689000455154106837368680913202917444728714882848765930\\\n    3754279411961840906475788252402019834990642832412803190119639342662154034710122955060658897479\\\n    6760280197081650928916156355837455829836221785108407264651723679699620986019018374536049031714\\\n    5014738021633810959459920015228436475714286227451555549908007368706600224977020310359868831323\\\n    0997508679418154314234431157511733254146115024540544299253771994294897082620396562437791165770\\\n    8410832988482415796500346299401410155856081600918786905527556007936817613765617234925419361714\\\n    0640606208912486948297956406937842829919579798233412245024908571376000649646397394458408564450\\\n    2283733249601451698942926441190492380001703542675672074597526846144324931720200588807532804859\\\n    7974066850258199882101629711837873575884607468445329604086423238871105396864098771662854446934\\\n    2713025851273273712338634066452810015306673786681542632780445315873156211224932703348181182922\\\n    8578329219769817207432326289603505910116465847073045680604739585848701832110584071806266684817\\\n    0291547906859237170582115426005075272410891563003534821114404078137492603627231398256462497354\\\n    4219863724411781103016246369551580655257415791274926683256746576422310144726734227609410164153\\\n    2905779852866781219113435196588682058822707601381332214885810772051187772541466143220300051650\\\n    2486018231681825205293103395802244471366919295238300039165606181416450483686947398782378608465\\\n    6363382405969018137078394922137756067560459203149761906358014284953871953741156150421791520852\\\n    8971200862114105791527899249280719101209492784985057564088848960271166703204195167231917136373\\\n    5228319531752952243803182420233213046792613884526564971338094291919078190774229086152222328503\\\n    6363754064205758874833846291167436341388296952767136720293652246351520890644653508319186154598\\\n    5078298409997142885786372523344524727625274230711007423368592521710391612752448408999145920733\\\n    5881485202280089692388380069582040107877387509241553538585750455472214116774796591938046694204\\\n    8327102010821341797661579064064147870013368857232287045515421957262613503701180169386931596085\\\n    4841358394765696093503473232328975635377228487789628253166164360406388416523446388884939331920\\\n    4977807387885819252286500884773256079878222770369142466815763583947730130614932098440418665830\\\n    5082904672391783726267449815756007707486336206087847917223744556301485965501560294077865065646\\\n    4219914013760448094333670976368791579678477278572013661317990637385453546665670749443381960066\\\n    8217518542280776026856510209214450692790911592073361089624762034937087593167370917339716827308\\\n    9933663441650135658066553581004063247849055878815268708721239409235127815651605120800613358963\\\n    3433230974882080690382702419661669010266393993313981641119433831675567913992074255430274353615\\\n    4632939540419595797855516288921771587314425335036851072967041617414569037872741693210379052584\\\n    6832826315628609010068627840730766634379704886839725081004463250618122779373726054996921457770\\\n    4431723191837423151082584198221258693892440586180719372963173108775170408790830732868629498393\\\n    8029335288322138689023918891289835929336821332113700940991474781934312871379994269460624049782\\\n    1443393105858601873187158681238985344636912411599470666869625116586189427303147024935143058329\\\n    2346735795619656344545214816065235716431901421713718137216495736636711414650015073363422332955\\\n    0365107519054860450149242868408986685684698408908177767234886754673999772250882637189726722473\\\n    6569687034056783792643466965001353371132057580753309875344407374382265945097745706362746963311\\\n    0594835000833674061900979889697462754569677561148212458571765465395714925924194738052522852883\\\n    6542451605806476078503815427922517795315962020987297605453176916705223160045393046962436769314\\\n    2097017271707020004960355314454399005930783170319552654520197469937527050639350551034098451751\\\n    2954858878717871143400662614213094613710120407152028648576908510274634026995444979824163222377\\\n    5697582009514819989495070992613965782780776112887338283980660239728192517195043108040635252785\\\n    5426632749848451834341495429851715620918817084136349748021317296058140144134021535047911307581\\\n    3056410188631281765225940762058185081294564554759541039830420634829414153706264664071942095294\\\n    6312038236939219569133360692987447417239599597464350655135657217636149910540326610763063599200\\\n    2141917799119261610510943463268954513256107834097382024461440061774432037748560161169205643521\\\n    8272292923108410378751647649928349815640097164637698820223707000239140308736990730706619530236\\\n    3925183103197288358867501948550737687142811160227583496310931126512772842505473470272527679265\\\n    2802221669834283062395823476875430733500657149271650889957848938718370196313726351161647708252\\\n    1116466518272360816207764116724188045616956212253611591875310309800659686838103253828382078402\\\n    5964505525239043805000117589632048005513115089527368536820819273411221773039391062016713474568\\\n    0233719976564089871148085824476495284431814668498905126745806569089136269100402295752294576584\\\n    7726820294163843663191522381873660078842776236168380655028292922472462862232677969912748167535\\\n    1325113921660626693904099483268182185527674921462352749750726231945469296647550771202743904846\\\n    9728582259387386415609103159060101943321457801121867143759453796912343846122069864925049953795\\\n    9494780407979407485929254691189986243203840225446777983614690024509760845281995274354054504295\\\n    1533827391811196071259681967481694678368690573050950030010078086253806130361019163870018779993\\\n    8257573273069478864435283836431210867968649460223187703109456235034385591138304439191347680560\\\n    4312954950171253871838617302029078204543718682054248573220094900614178431289616756029511915809\\\n    2549200684043619000184272966884647590281949350566791071903378319782080213780775998822130054814\\\n    6953441367841462374336453313079634284257878717903315303297178750030328699623915864457256989532\\\n    3479254394883276381324319528822213994778096722039029406168311060761208620608134986376085349486\\\n    5340131815336372095249133680699372110214488960397765380071090647809337760360004832525253190874\\\n    1667318440722472875714950428342316723418840316751642602897960218218078827260648004480160955201\\\n    6261653903343193534947470858414396039383662740194268366051037369809570592049768514073181843761\\\n    0920779133217485567375729387735218036838401107590794472567835234201760265465755234542540370294\\\n    8378068043138579703737139454211645667977083288964478301488956333924393170128040897699453504321\\\n    6889678425479083282017849131712074133636201357762607043670517061739592185004781156622783373131\\\n    3489682061609641804414607318086152434111783627339548793787239008023212105363057930017568932447\\\n    2778066431935135799844099193033994892550967714635336583359265844437416997621113062243327597691\\\n    2114256737591767861307183428879399662328776697139714097495626515268549023690432630126782244621\\\n    5591127026832562283704141097632347053612418864948518696433530978498951412788430215989874447806\\\n    7445171098439667940593551534698219907448287223664558904138241989263092344500561548767236350238\\\n    1145893052389901604591873227349810889760319697731265997139962794801054102689140966409525922550\\\n    5294678833029264206628503502464740487495295826409454187115443152157810462103807558938533671030\\\n    6466503046588428764787430222017417300498265953974037214152810359729878021070261488287705893422\\\n    8044230069088974658105588221563790180663241361110157709734484178845792425160413560967900701638\\\n    9992685925870239707555326047542890034687881278271520157678674168559707780996928349069616103713\\\n    6990026080122921410977598565226421090832570140459328747875066571215259757679677298836342787870\\\n    7726172003191621426884208661205057439345634592904447074963493547962615947829613918789753109577\\\n    4992811404928081447083709278477609501350540551580163644227003259542713087293660532914449759107\\\n    6772532428728711582962758985257772392543810066821933281796819243675673539555440330929674854526\\\n    8206902612711570153567271896171340766325535954536810929106446434691575359622475434432329867040\\\n    1489495227375867315705578940547579777035964501958723452999100828239236099059223019340816276582\\\n    4091238541631821953869365818269612093131104278839775829565474218939964337619982845091410513018\\\n    2465912102250195994313177480360442001840327333642715546220112375979483851543468614933606465477\\\n    0799196433218352766045248645521929275469980829145174191812399425101836717223232301201050742376\\\n    0147884145502206345929423228807337222539756550162997417232363882339678585811122000691785496903\\\n    8995102017992076894712310248298325742387779824764265492218964125758832259826989909202565596172\\\n    7911549214166933190931383824772664471471879085658670543468790886102272941566737937432343848838\\\n    7768874229835785731395535745040859479379341547459309733166572433409867720059254622636897349986\\\n    6722311946422718828428744521672170760749634587927579950956976504344678945071599422556505772054\\\n    9822931343343946265220569026981548345789717740130521010569971227181132901300189322541515140731\\\n    0836111815895493661047471535019431295429691843310462626639512345916522192253766435688913265561\\\n    9583748673905785028558876057698732900530968989173471723137761512539540718927370873693946950252\\\n    1150669915304990554091808358157270791559360707491967768441649145551631302999498268009796510543\\\n    2168253263156567161559627539467931597158562796924794845417465315228605338679783225951604501673\\\n    4352332403401839924930744484679330414148338999750135001318155801119438943862308601251316577609\\\n    6304068878977508602166918428796754047705941737640544145645841495974536914147516254630197807963\\\n    6768322321963941105057189485165812796402341916138572032152351453563507836310065654050031686112\\\n    3020504607660730301945500818751248838844366824918756762720662975229099515180665621801901239176\\\n    1201782057380518738545302791939264959488545304017870004644821267794052022107373078602235660533\\\n    7380319147835492750819916023077266734672932088413893033166349663731200623021220327478063639159\\\n    2534553808486633502823145058197671819649558986392167421188319863453951447993894844305037964765\\\n    7307738644663714729898222332298974986753371500438912719758246028930738181208083259798651507963\\\n    5263989002096040455581138002479279307176155335963173638691315270634171745785254904823515097999\\\n    6582460010619845572414334481213759684426189064428448100322397507936726386346225274046860380944\\\n    7912882911935464270228771042777657863903069640503895910105372365947940566709026565002358442759\\\n    5387103811815183118297440580821703967888226994607750802525389738545458362882841099180109442399\\\n    0026665602608291969914740256209847439014955349277811509465025003362245509572791141730753476040\\\n    3120188390407855661753453205792886900082452099003646962785886759400935976798478871365389833009\\\n    9028964646156640561050823151349600282737096045149516166043681022525169019414950726775691376352\\\n    0154849529147470824647046400173828649134933581261460809816920848183147945403156723530325657555\\\n    8621761656884785190699550504561769191010387843974505540903495749063458110916564233186821969242\\\n    6283060665546706990919864826652793408965735277206555963773482975384476486615212453735841251149\\\n    5594711012551945939224997258173556183578026627199961203162525263895299400893077422140300116969\\\n    5861227035343947569908628468191913738546617885744414687718598360736221069304238683299574342241\\\n    7099921879290851057074221694915587816235882737389059026571892180783223307456152358988546527847\\\n    9779255524131859031878981099834107386073015945922820064499606000887961185926709654100789834573\\\n    4978382843036529679571839044194784643995503011668634657061216110610317493103277665469471198692\\\n    5078524590230031827899280344566298958818726186515256113384434391254775627784788201380235749709\\\n    9205419349398994093873958552046195827428894490853701361525284581993419602010981913638759673750\\\n    5808056543375959273106461354674225488655619670068611779379653807735674993519277478129119083844\\\n    2808842257029640443375693766057186774103055292540491565553681087076289514404234055793918598286\\\n    7236125417879462212907286401710013765832743548670456889248109765681353863868631832360990035186\\\n    6281599909266821593809693473073109682445688005273993258178007853008144166427660077798057542562\\\n    7163706342173586271865291183844487504548170888601133482814027948481107712440812797541385679489\\\n    8729927493315575289581677148743542641919493801107042847288918455740311830882596201123335631023\\\n    0402721484022252435224616640052994094779641900703433533170987673031245098239793823730284119007\\\n    1383135554361168657035025678942274155625733940101375711930303494082281208092652905464134384269\\\n    9317196072195017086630226246943429000984129175414627450555172782620255626262053963954802772505\\\n    9880269066182980114355627765711174985513358150868615480035565249197902151490061153032407878335\\\n    4716559228147347946017655130073864318906512273016314627954630102997743604681377918226787246005\\\n    6746146924131723323015755835571506943073456416071227204570590237191166732048434826409473724211\\\n    7846406652739419264042100569528847379044404495562856721840937463378380596233285843289523362553\\\n    9024912004591799603738274271399304522790500086067307398295599084156874887210853841955308146146\\\n    8036537524007486764299421963941865887479860095274774814152877616551301204760019543146756771378\\\n    5421041329901897489952223178336717954409249294659473081996115446474813874799523219220710689773\\\n    9525210299370134750866112012804097613662687410995293615964069452040555646543014093605850226095\\\n    5337690355988225388434114241062855544272168438874023989679411417505524287868078931771505763272\\\n    4390062457960523658327771466626078063398051059545046879505986914247850498412855163929837574892\\\n    7824326161896120894604827295100788600463078897539481670445904506134002508477106529524596716906\\\n    9144310240009436705812633966137894274198403236822500278297246511718090394992679090883058824393\\\n    3266063053812836463704963028423498931264613572452119329382644351437442204652633521975061776390\\\n    3346552994757887072191466578589462796305914806194776349527556198587767732033351555668124817608\\\n    0221485681955241980766888933049674902874274845816963375435628043324264882312663123925263330130\\\n    7081692910619302569691853830583061815779632484348540485558152530137306353609592625470425652790\\\n    4177120994295363975658381240976477090738472242000421261891325469265588043299426456507971025608\\\n    0377645346221011080542516405140525687144904211574953047199857536402353061631542876555297333409\\\n    0351169825765984258141540791344868898254876767673411486347412559649437013951814766411334789497\\\n    4101317679942735254114617564932218885755670719282861666597208279032820196112343154428881223755\\\n    0391916538457014198730533052174716631945269770466321947594816285961777069013248037283672500669\\\n    6076889514867066957593896978312669137857931499829889569011621232432934953261985041316010026536\\\n    8475397073372753817941383589217055824583616406688326306645176928354097726877404868952588360536\\\n    6394076872812134276613439969668083449352084638187146467300360141824926279838484835953798603272\\\n    3683987480309169025893109334695197715725740830698223737868606124485917165519549155207056670053\\\n    4829364282792574198754064585271308617982734013338358747675627411739375864290225080306306717929\\\n    5160502765162225463280629702491635267435037434003657248839624217064855066590778016843379232083\\\n    4274283889202758617303965866651060162973044970668281902956811369495204921749094811269407996351\\\n    5115010499027784471126440622059193056786340657695105760542095256648485275727509357452477767114\\\n    3036465864074337730613640975482705477867951398788076519400165200259999486013001245744348551688\\\n    8762111420201524496243844199915851778363546066026272430033327606136899481752369896748643333025\\\n    7613306072478827749746404049755443919723532707251729493618819885588080194996192913638883713661\\\n    8176351655111827385631448758871993620570436278759658964624629962988766150971162287009805836024\\\n    8373612972964269477355848188567188374340256819040502006586883092992707420016358173211233885744\\\n    3365613701731546218723904769505148068991958700423724177798764576798959083128560627643036575150\\\n    0423066099689758412691917232125880455445769178514373089571174804143031489379371237623406394568\\\n    3694380822491132232655343638354680986702809215267774190090655615344333390653136218609437796621\\\n    5349996700949598264746224090963383114621762502012508452062425235740786906510255412593791673330\\\n    7046245538699429697566422855597353832860850911326328021086249753786279154593346613792361308400\\\n    1080216335828764177585366208373163474173870129179038740529706695025845307912156614388512063889\\\n    8528694034987675176810432258269450385545292738424545318548829920497974846030980507637790524755\\\n    6138260191179914002970022369178775624569254113377223775248775877174460340587757905038146126750\\\n    1981055112324610763141861656648736160384502283985439794222350001535056233784508521393170647516\\\n    3503900284305496002843040431446937331325615724935407847580953036108410619761931436687573182429\\\n    3426239786539828774710245888444602552028748134131769419527800329205882510812268330077041138030\\\n    1117032226836919972097053312091543288358472719242261581433329784877006680945506526476865966940\\\n    7286986905167579384365762762633621701303881708737945460253771547730607224895532434015315256085\\\n    9788713364666718680916297661613440498064737341006401268767575616847836419237716930650632384714\\\n    9450625462913510121261585479411924317219202229859798829399117418826389365904098191323664366569\\\n    8380848896368767763788399395289304325355081810531075414788688742474486231768279449817695917039\\\n    6715339492018711739592130551379787943331398079168596694815722867940241471490260486038670972485\\\n    4454943414768113081552174733164301806339593556093053393087451963690412267049266959583773375595\\\n    6115655415232879740266386110936718650144580463511791206237472582654265584495457280426006154949\\\n    2874585920779396115394718653426832188770025285537935156897489829549207188335956710741652317824\\\n    4782882355030553989428419175854331592500150914128584188603356123940437961274391268631908527284\\\n    8298382237992707274717426329752685421766067827177428396536031749715265990115263385999546737971\\\n    6935064599015473834969618200713366761706762137387975653403380292064240998273255931438071033300\\\n    9473621828764210308387021891369522398813384750761082241809969371593376986965876296358092947538\\\n    4307148025739489433838267123109052200066096344061853908466542390698451570555765864686977971384\\\n    4738391164052557731853204602295817774215457905243831037420263616145166820623277989117050238812\\\n    7292346575125252020030901830060253197731737301376869276785273936002105204221818358233481423515\\\n    6158789169013268191455059425568822634535045213044043386291336449406623671946701178629014782683\\\n    9758550955264107591621217774572729139749734721915597511630696856698834271714230120827436667310\\\n    6367425371476287065999618789242121757883470015145002067090364349263064713866250530431658419616\\\n    0486984490682890791818562980336843784333456142740497705372795426121200441456789853297701368060\\\n    9631662203980189303800757308526599422293500468217945315487559172435299187292206276248437051076\\\n    8505008473862355713556459439777326801870852873798166761385824310780217546116245500072624442235\\\n    3180661651349266680240142201025615185267273306420854820833032707036203134826248122452124901905\\\n    6005787447885695392063972437888182811963858638164257822549531007611743641570240435121479362619\\\n    2870012209970926723335668717578789983879558632849362475623130144207393837979521816197242505593\\\n    0039176104795128309599355456298682177329575307984376517172250864204941667171396190029860024018\\\n    6763906009288625159090634965937816879606797107007085095582627648635862172514730952623042284623\\\n    0525402600681548919722933900422823655607640004610142625856573657266115828758430932716311524473\\\n    6283424271962795216504067352646647447065813584549210749497642793534134859186351205547980834541\\\n    2925874904926710129322536397490606484652802321707503364186629463809373515202850676272513003424\\\n    7561373850456604521727806526975184346286041505421681172715874231532428396014217340794252150370\\\n    9735509758922854385812421921864855591193461039563690485737377723089151416263735993856313231080\\\n    3079763890678779340335283757134363712201454769929893559350046314748430734713695888148637733325\\\n    2239913911606618152175248033303471279142406602840415538846120447424503058817309457982908551662\\\n    2117830266378952304037893424334420085591236771336996946804363399970407734404704892832377118512\\\n    5926735972229061251597439578597485017482954479957665397548504693469519280431135112834299858321\\\n    4554188323689048752945781283680624576249017164424679995649076507382673312708080569922912938181\\\n    4403439935252259151045113709078587017822467639847807370641493259816957900823541862866124047305\\\n    5591395123282876903292229762430153695695441977226165471839118199261228596130714766731914228964\\\n    2869559981561845143511730330003709687904680528430031391485084735293303606195575121928272086530\\\n    5831244749719380820885862574241756530318538772883698570840446024482219310938159651297655679749\\\n    9983391588459642252646789188270153229196989445704181543186752509934713764517041873999557576829\\\n    7784904028054126555094298875401471460121634619717371080465811043564902125604424055643998727889\\\n    7571581337981277783254222619388737561723985054309348116663181953821205144947367352792758557671\\\n    5265472259932275567103371744279098317331926780395924612077723496782539822909011021872878586987\\\n    7453802162827672483559835121232607868661416774405981882018883729967664437003280774262491411429\\\n    7720983076001626217368921318650347874671449490431716561018554790639643300531829377788411489982\\\n    0672346149472319425577791215782304214565933739628472814414489455168039578654059698173977670450\\\n    7571153397320675931163219700047322289885453725534115653774420377944616164557617874519063958180\\\n    6159741081652389710818868750830720145882486883987157792872423330192069490281783241462228935787\\\n    7063127696742447278104298060179873891202763387648752161746892936708897548146322664992386127495\\\n    1951531820887269303483316756678912102585037038267099841902285295992906067097749053250379989872\\\n    6587108844510829024607945246129018759844698587886602077894225556416163822280576023914496326549\\\n    3929108356170407119668740496396925544876272547949869522527495804272626294449176779986894795601\\\n    3754754159390356838017688698016634968734461964325848614378518679201440238454967073617660388403\\\n    6793735102919607807906908757115945712474448953978881118796221435656770910526698314772804204081\\\n    2324256233745703439776301172571103263596530973758668555903745224780901892794051929592360045153\\\n    5625147215501130423900591368525942196420979864487081345188192787598177371584166360563488892274\\\n    4936790285980959457894215642504306216919214980458037495831677343317570562486721706150805651705\\\n    3448760615550057157447715276117779480354329401235072986211619814888730557236801076192555099463\\\n    2784517936370990833393762544986819191528793304117428641312181606571171947621561586739433079825\\\n    0967815005744769346829984414360713798227656044954008768584598861842837565981766025854649437820\\\n    0767282431750471563715732208027090702327942602695640777540947241387355990294106409355177098452\\\n    0659046479088774941058807130775700834991701101766808616343512435113815719444285178065874535618\\\n    1327633720609679651047952185791980503456405129593410283035609575820124525927724230690984416885\\\n    4064510092983130879815473628915264225272822280510290749162541358281341060637533019121015318152\\\n    1179297030939671010788049315849404001055792189134512547989603248671739626125609447523479493755\\\n    9166003178252746868669709940525164090520199743363093220189615467295551867115244613946253560796\\\n    8229585356938646514451346931424574167791086190669854205903318234260579177804486379249485326683\\\n    0586358643143016604558137563224624657302371690724952157146232727972849832362965391429380525162\\\n    1497117731183313924496453940116308893290044595049457929392008892093841637248752108773043419378\\\n    6035872301890470730274686768875677788348717814981644009913802097227180569216267269628540606292\\\n    3922730815264941090596649258847221903522405850312759191956554419029454722327709408724112633394\\\n    2623195856980479010998291549049743897377052386229168045886299259253651434523366298885225685786\\\n    5897619422708635652629476401258989313710462895148820619498335624646680952878225238694795567783\\\n    0312771336941117185628692723980451411313990112702802648916854058237642651164527971314678733263\\\n    3145543444399639252979269255851735265534234166157332487101747484205738231719162802766612094326\\\n    4414677987030336112762101544620087864792507942863359216480890210277943210263232778691872907355\\\n    7421834355632185478884217033440151054944914916073561488696757767662377459349494224669472904565\\\n    5600651040031656698959841402541812872465907832877773381419631902572175202353369764249244871748\\\n    1997358931634133869971892419894872516834608138690571268200822014031395023319493962134212411019\\\n    8354363702070125249904036496687757815038457430021303971266946663396855542158607068694315820547\\\n    9577826302629448207717747911660405221844267422640730608259866866516679212620588668527998178550\\\n    5623926477282737216143247702640303282995114556932108502511372358767166980724994376753874531267\\\n    0563268802182287574320473932330469595960282640566430223394558951505829201543785923242694861520\\\n    0039188427740481018803463584078366518273655972187385080616408000181465362526428026889896802799\\\n    4112500444992596369095005591603533935509040367206097579783547043083022417692659560203474449848\\\n    7218782449801870037641881289897596371148247282686389594027964186444754142486505066742362814056\\\n    5025747113629662581497963129581961225597544143705780724156143095258755101707640700882311627830\\\n    0437484545568683698297882041677634497525865192772907406839420924974469194639184604635404112113\\\n    3371917987938452497743539649856829632002440238547834048393929866287798979502151853187229511263\\\n    7857089376947508121648779513243910311398038131923737441031910236597498924403188044152991223393\\\n    8955472408995906024875342983844054843518672743230215081865628919697693136856246200005424583928\\\n    3538269518697261933924167102495736781655715042823475344923258745036291618705806514591829362849\\\n    0464533201095931017495053837545898902513131494154700747194871261466894010230732075625073015000\\\n    1967970786171295368641018691319735761710732608534486367773992816893786257684044396577037980283\\\n    3616174728487238930544253911795800344672619062443969379509351858264319095034950823479912101339\\\n    2858713363584819200801785342844606138051835208772938971094900822595991523005317927292748431128\\\n    0668655896158147077069545741639696914213216411548138302276016092550355893967049506645452775811\\\n    0736620206195785951830734558521147967219024634013973844050831381189653244884313865227300252190\\\n    4613012959193684147218252203122619757960524607681220150379802930402954348644208576249075310056\\\n    6567290406057601386255046079398111000571007118176055265449482447798075279131926630890953038862\\\n    3430244582893383002189305535802887573801880159593136679210425677118209183020257361902577430286\\\n    7656731511530788895355366784810056787280238747348222295389405615049879549348049456964222391409\\\n    1302624154653519778881511983417297550049151306442466796925286857409231017257773749362150855478\\\n    2171355255630019877982930377420337888537156800905353409814506432449117666403696037610923281324\\\n    3302897636708163086724167162929849573859194557045001214439851251131584499489450873109687128653\\\n    5951110837834100669958213026735121550092983012223463942153173144805305901986370141151840535623\\\n    1143147020411115291386919307027770084887374079049782007081309885591021744839345717944264208361\\\n    4747623830458892088445870837914420195988243642199720611229283434832863437534105133138555164233\\\n    4065812334150146976393424513868514742112359056645313887385641894522046368904243188407327405448\\\n    6037608021484223320756042557584994627383409289525291710074575793609784753453756995283790880793\\\n    0112357710225129479013903631342876995746508167893128715322272571360872869085226440606733121356\\\n    7665826350182216419222179682543294072421873315625672376328769246603698607895826585140301108579\\\n    7369409946527704937075558095388619253038856297432540498593946192631118185351734895794028656672\\\n    3416982807185209136227275892810441477150935097677653814643490974453013464847268552081903239220\\\n    9238523606638574001965370471587269470912619986385256636270966923964089772319896622438508312645\\\n    1151383905884523628258318935345476244738483570919244042634088732186982248397092701300321120700\\\n    3237935095789401706750021463855282835661060395632160176214848651107889698271553506491878526252\\\n    7405781946766024192949423164262081152690322715461383000205495184297292434178198693596907758308\\\n    0800352971507593056407786388982851151289560605743788709702062354992624611447262259985372638526\\\n    1827424359165597007126934017230979402759971495293164454014540033284770264468204826081848527700\\\n    5704964598569295075284293742989474597903631443639152666725884041355826959899910548620469958813\\\n    0831378073441636785351559207855010647649022654768361770306968638013244768982493909146543780252\\\n    6940155841879622607294685155674953744413871125201521412604541530704323736238810940068785159327\\\n    3445474335257463342053762942055182459103326246295387520213966811071659627625705954187543179780\\\n    3222988729406990762341152068805636573216303445192748211826242226905626849225409610022261302572\\\n    1617413661219531188651691078930393741575108147912015769085022932570198229339456373770925199549\\\n    1061173001665663988463720108925904655583559933684784624675347006100029260872859721533887657617\\\n    4560930470895224681061454759298272305069925656470889127036780297211125744458101441196168183171\\\n    7768573866980123377600117302361584847395003006025128242533119574165051008773574463666013723570\\\n    1525856330529544873254492378678354872546820588449981564228262437601408927556766385420881129327\\\n    1927962328670626255410823822228559801660868925620874089681545786195527472087654563039144918344\\\n    2149069103489072500528569945688595813377521647375583791779366861590178212564016919804208037337\\\n    1905644945964829878176967191000021272036464781679390243496490671525621610285528693572573013956\\\n    3300261114103793162264886858587443294680563469627245653461350372108701382457957758651598054131\\\n    8845550828794178430811509762356840094972677397571272729485856201982553604922077053957315876718\\\n    4594708132605848642764217898250722605990856446585089275886078238847331256649561209774111272554\\\n    8352903534501123024339595889110296805848302363326846418032448936988654727989880824076941804864\\\n    9078892626053677602411350912273555807131913993306979932655113467304735749716828761007427894692\\\n    0603847461425100803561453900717460651399262493541131384041898343050775998698605196404966339777\\\n    2298422982602569572339110048259234731714752477935790386394893816534364231211762073293418557177\\\n    6250620072145119709830772518346032175827902549113525596618643712322756517008445330542963911354\\\n    6256551231165889140045721865285741583316204809336011213837356926173864360307741239263145126127\\\n    4449483133470929564541754436155305845062830577942904488073798264870399853367377838689831816953\\\n    0812372528016286193411494424092958051400277397065647542387515301035893028828199845464270739675\\\n    8107132128377393247445202401097529067462764783276287407503077706290062178915419364659481659309\\\n    0057098697322648016521264477159694504667368254166456012251044620641734752503121202599521246028\\\n    3660856715283183702096100581826466355127390385414085709578680365538036779260770879230737271712\\\n    6152428000461024183893262170826667724983459139162425496789386049924754798777493965057712773482\\\n    6300506558635449148428381007019048975417074761222383172674906055315009477584955328596205203654\\\n    6910241782466346361263072789385549682685150156005534954384329899532301527717001256578133716361\\\n    5043215773804862555693748124074935223130577741573518987398694228679362701285155289222960201010\\\n    0892647408893405466506164598192149345292168107645429857362007641382153574429662270724693789740\\\n    6332728504330626833034013775547685203382256757348659374670649460052933937316831397015339027541\\\n    8226505152744210893837462141008082874337642806099235005954205232073535345384368306597048990598\\\n    1569044850344914106886701593829291825697078501346351870217821968727411566380722799089468382378\\\n    5718832640256104378581591837042646681889095373674889173913909056949737714532124002844629961885\\\n    1065016715004721012759435057719277856120565870663306562446411838570286747571963897693572380973\\\n    3083021986875292103491797983916685250597100335948165539097017708837243653962728703155525688052\\\n    6989880062429539809608125152313948939991695764009724472367180174695653206536693334549324331307\\\n    7620616594759017585770359265987006825955346505450522882672407461572444826955188675896596153783\\\n    0077335018545479752335063734174339276768445811719115967506674573752205248409366305500337204689\\\n    3147039824880869351387765484726634196834173568456511850107101493993607017582831332880703168575\\\n    2492034741857892379242573600584502539163823677474553607704335823585724908225849241394756995258\\\n    6736768512378545868865793055304866246422092271414009977795964665593862999346776199429430278724\\\n    9145218235429212467736497098139012515723631895962865617864951880690112453850755835686968144021\\\n    9351163447412683467180885868619126193814859421151096950286262092569968212967297049443801591351\\\n    9760413592369508431568312394712324828495364899486023383020525904259672037985136361280650053035\\\n    0920190921006502061567932185998624713087326465116988379606496348675085759806314440868335391742\\\n    2656732524370643969270368393417902471285618917510834526067988967625574591064050498885458672254\\\n    6572265478684901534275449724164891605051542515681453969559232478727055869677431237701965811136\\\n    2719676349107475692492626944844607259358653310842968228964055107934622796271399007833040126617\\\n    9221699945697590910634108854769500697657120491987530859525591773702902546417094689462213459786\\\n    2292373987509312460753889986322366013576904551732146234221864864394715633239357975426844895932\\\n    3172010355186097452721933677237555933519612521453380247681611055287973565236376883045473707338\\\n    6408157679691626929255972383226757566462454593031818298821837032082388673695862160188190107585\\\n    0568071828634171067280294374083883262389299579426341985094188819202220923132344399926877896062\\\n    8457210418484028071319626598360978322915009039967481353368973564020030504673027085116007132341\\\n    7453854579845320926038682916145193066145916314471354340639960305948967686024491648896104046012\\\n    1955019890827415582744849096771729802101263565778223246890141142464669829778344980209868781475\\\n    4806510079142114305352634941764148119182942056166791112191251043765720923434288492830357228341\\\n    3413272827068087565371717405080511987035139057121162638669130391353302307056380602148873549661\\\n    3496125528460357688025681731207540945103594968613875446690162490510899259158294352680796293239\\\n    1937581817143632338026872382946403514569634226505950399256379980189833077621290827354196715253\\\n    7150883997035843917251684280478669157078581455611893323000609208805588677360884475711657232753\\\n    8619229717463563582889211456753585947295574287909803689687394375805048362267771264130700183523\\\n    4375999201102749016663770149231210988226327830188073811410559130638761234352033520960163756547\\\n    3790131681280984142968634325082529375273300589159936158236239060773177603257774842212935278732\\\n    0076460270365412630483887618835451809115911538320584593742555734636561753292064689552068982558\\\n    0761473650525310739789360229623744851832392575262484006521607629482586991276734049311726557457\\\n    4376270970094680827929455043159459438889945106194527417715986943582150045197124103982908128974\\\n    5614365974321565950508824044979641030646753875494781598505740503065270584173848256440152090166\\\n    8233414147655139931173703204818963470639736491956940133368151828271829119302606800418008275611\\\n    6197021985501192582090915514904960258197387590052113724691664275465569397356161673572994648499\\\n    9790596545862797423672417086552528058613290962802932878927096846685523126650468122590806839601\\\n    1476412044213912842499652356760121195519707279207905874535240170823172287136603060656616759682\\\n    1593026210721285675907273366759980022603244819815545336477398269949453443088294542643078605288\\\n    8107524617012009732205151819995940360772124417342418122937651110368275157305626573197002022334\\\n    4579687081452620382266571434033816013158575935435108268200997830888585666075040335274406433291\\\n    9053106266389394762145483665157823572119146412601918856391145119970482960229208533988699215981\\\n    0431915034463729853104086073683415707127745741442106821653878608703143214670612029734896604738\\\n    0141650701520419057593730941698036762486136702337360976128342260080416459255913248721978424722\\\n    3401613861218274004746772983911224160021262996849118822187190755087451346286003160486822109668\\\n    0329213637716299445123148314628851940974143733846346969640012867662211614991745960699758817757\\\n    6138097123412063557268892610732558742860529991097522361409620149279258752141494687227760994857\\\n    3093391603516660549070658886094655549626631240490339540557530332526334634183123725462762424675\\\n    6666228772091174866778726192884548317646428717065004529703912847123203778183200500841564544819\\\n    6895074149963061776718915867592164549569396252570844810516967779719027034229167022450559169794\\\n    1937198336526938706461409876228210666560758502990947264094616659120667985484213162549450771186\\\n    5554362699684055958846466208729853428121854466091492225815979975860386945194447761134484622585\\\n    5329874748554466834768695342217023181518682808487636888962377643840923375708407363089365269338\\\n    1574110238854823553617885342629648501587959561680194460460449154297842667487762352723448549267\\\n    4548265666102854523546434059937084975480401161534036334558351465215629508716155649668679142327\\\n    1300583186554850747476504356704545335167766958098871656385897548944504698861675106489942191275\\\n    8748712520552982250357176591872640863881356749286656880933345518637476049988813869481578430055\\\n    4485213871608083173115056014574379873934666426303135580301063701746714949142002661311213969737\\\n    6702648231707756872643998859281217933333027680760271753048784222134305028596542622674996570886\\\n    7675983746884585527570076276706685452558624688545405843696429548672403992877187688685699380620\\\n    0274121141027023495379479762007713224399764650609476410711658062877888296092618388900069349903\\\n    5408654437899812186026244638270874240801765987512334999386606247739521396016319289056092027020\\\n    1928308829950059285445425965675980428403121241364441659905392589282121047152264506445656418014\\\n    3210041021761785504293213952061908275203288177112107409022601686375197514452641256482051370716\\\n    0368590786210741506217911939016071450745172980022164672795719173420508584140496026141419845802\\\n    1216401246343006874818359449551834137822438214872685016906188958646228377258135070544434935457\\\n    3022867126630602576991680573015640907560483896013334349705580570548602536595349662751778371150\\\n    9867258181021812240723528200860994024615292495786134552065697359731867991229213375292560350216\\\n    6423763484295104918381406141986728826503055521864159773506378115670601030299129043277392671947\\\n    3368338597701583629180278268598585077413541706467873211406159501189029245395644407383139213173\\\n    7970477645697705690504371266272074432501078211216211020037845320729469460844554740930870359532\\\n    1972102962315687403223651980036994232870107342831659151229057459034190267621432000935543946296\\\n    5948371430845982004427576923738214791653084016836860711908991180216871329457064175791727018949\\\n    3122018808718962382993985476705178953374193719199506637752727368137339246325012962744943815230\\\n    6290421464027727522321727388823715947365131545145337139684655321876565590405528287247073013418\\\n    0671398232633660965505997684956231719379034973370327360225386228813969628423520233882024674648\\\n    6456439291872168934716093844101930074516454599746778867042108994722175185522459101825092621492\\\n    2110890141926323019513869867244410902019216032791343629676389546281558104194854990117187686707\\\n    6243624923002186207110298370918503438697478360872693488992539097091823083139713206297951425596\\\n    8467440117077233681437208515422872881243514020017003768035851612408276903609939306279968471087\\\n    7783582374309922812499022373674040182436798796323444895238362089909254867704529867665769842621\\\n    7210377237608753501526040081244736051905905064014866123549536026982615330293391038682295221668\\\n    2910127516914921583792803402164228970782980809523214662259220352809191565577367474906340005864\\\n    0330988597241883774047172960509836727845177621271950664189862523040679201594671505129311925494\\\n    0694370871893089734429029315249222730021768942785729695579897710980859736693014780263168053460\\\n    1343768769827978005004779426891511377299694512332773992139700080338943327013308488702795837070\\\n    9107591273199405934463565906237221096616218145205256179538913066024789859835535363067678604269\\\n    1513060793045269790987048586087065295374116142143226969726895516592414803815763496441906778653\\\n    0486756378067639931505451665238237789119963945167955126944329961238808674756730597546335625450\\\n    6963558071370080766720959741113092215445946165529910099992283393568013632384166370219392068719\\\n    1117225059113628458238566541516995908903063866949942747385311994752007024231317342130112165257\\\n    7108897028933681697214800620693633190257489543941655595016263504101472041823010417121542516044\\\n    0238220790529663095466385304851138284762446495031652664393121460500158596458955928363597299339\\\n    6770200241129745110364011832593831221713568445270313350189980264730807651159154300310833921245\\\n    7303756189906139403056834654053140637430893249111736143718741019477817881421079590489964617108\\\n    6916429051727182962271125612902855480842645205767471218920660070744559963653848248317203906592\\\n    6249452667285213938931778708002370168090789276450313450451624295086821336884749952489212114075\\\n    6320462575734963871891816969837858916916443642542060819339955756862184613100561876139443408467\\\n    8607027684437658060318011295712135183054362283691448821347158028753802692346033073801213501084\\\n    1227934660139937419723593064878162589344987807299352925653393096484881938835074806773539725894\\\n    6425339608252147035242695673491431356492051570239488962131652108991544162643508770296433465530\\\n    5165222522448285132630221217821524816942368984274422766327316800312403194440543004533091544639\\\n    9073230080690353125459638755353954811767292273049581592079573346100353449403993636666772995070\\\n    5910645505874812300131222572217954593038243652972093534019905890286440454687273546542420893949\\\n    2610108117722981077973411362443254492525875300756765585515566162725574194584924459543091031351\\\n    3872622636190833931686779104743610036393556401233624211266438636197838147946873091768663083528\\\n    8580125683169083788197738165892491002490494056752070217641935644921771662713462688705310983918\\\n    6547101173688824504540114783781773532396573216793520642019397713057955571570690637349520509551\\\n    8791976412180230424070392098418911680407925546319021584967499393072119804286378625104442274289\\\n    1833178416638981975176350587653885248488187618664363986813487465155777288651058847208459316605\\\n    7110142881159128891592473025025923407516195150437242321457142079939896758422255996358991115286\\\n    9302615926196019441038709590513555272710042124077911238420466420210673274485904446234081346740\\\n    4084594838142943919749204023651770935777859765122248023636660788955477103435748531061215811334\\\n    8770880226215449994451717850644436694452171624264889179068322956343371215677497456119119790486\\\n    8175995141104176649464319454531885275258354362172051943011213348193246817489577532897805696721\\\n    8492029549400491737699046055963722382553625519736898541997105616655891298765368729761670459362\\\n    1211024917737579748720217950722367345752845599816419292084436029340296946269798353145829969163\\\n    9493947650026928368062684496867056374806323489934262168600705118011691655790348325391177339248\\\n    7245397577412297318107099024024882718896447319840944772772515967585665834698428683073019011443\\\n    7893839921571088797127610631259275766807701173437398957240285746948244197422625219800543516199\\\n    8413001492977631712267498402068756766793183783551853508299459888773172217307653422426891276367\\\n    7343041105000558466812049955132228992338776194484998145413748684214867257803543822692013984559\\\n    1197646015616968655488974420654483938007442802190931003993019999456118115556278353637069865314\\\n    2047944432051514307105935787584482327025103891634219761274831030216796994286943345984834381689\\\n    0441069867522825019590782911579382291809012795242988116056019596854124401758004527224696098703\\\n    7259345143768788954234582961877658693873944996611246433649786662984839907320211755076860634740\\\n    1023647044310484716998628334983248292593265355255141708160789083813752801447738308487196398762\\\n    7569692897679121024812579201576922283034894986203311138112647342525584229972653187013929566801\\\n    7198638017039960291711693233154802814899031768848563352733129467398957075088787053674356624559\\\n    7428275082488999999327402092724922310405239186311715589447154547199808754399468274945519833040\\\n    0073888622882263386619841272540369838364491779392245701867285521983860811815284693069223221721\\\n    0947593494567137813547154995892990925229072661781070238034702660164068652089269188317899455363\\\n    6802523177554638823160162630876784891482280791790478158181944113867547178397831828067540234576\\\n    8928380618332783781050831547830710377236991815722150967454065017440319738698768346717186381399\\\n    9287588139069072055663986322079973867034258864058461467313008152068575898166445812004494184095\\\n    5945123430988798956309540598220207198200747063924706448552105229199740100082999094773040248263\\\n    1172252120539650533124372228362832018984265253693359856663173285247265861807097837406540769965\\\n    1583894185146997033002884930012700397472548491011619902856285735246937071208240840760019113678\\\n    7898500381993492710290091731521495188201876243607753944554644531399785354775829338090486531319\\\n    4725730529275443267636580017796309451023396496703887274557626480859002166086404182887352751813\\\n    5310938949072006851273878403943149330947288925781605230347401434534867044725313643298410556910\\\n    3402959684182323466758505488881093230315807677924693008696151672045668766387796671104496013999\\\n    6796955739368443022931713797018965664882152672408946101690277022005412231219218492425330839301\\\n    2319751071265897538197145128730285629189943219531593731906582967509949775904523370381868708473\\\n    4516016114435884609323560484254611185394973210579176267849409680910569361109234404385738664711\\\n    0284252232528355231600691671151133412491562255108212011841635882315239279224310470460395241546\\\n    9681017621266080607917827115065920075408133991866163084590502821918366054457849406799998034007\\\n    2576481197809627339914668643034084200371789338649334651885919126814503774575752321150076964274\\\n    8133602309570766459260035552107431919156130627985072243470460931663391278841828876443723790379\\\n    5742197460711557244047993921610844819598394804914240502461634326828448683554278572096749571832\\\n    9656214739253645230193473672372389798730185789871337661093670171225066124438913023966421609073\\\n    1491495940133831476999162399717666411454321438157354633819321349510317307575109965806008923538\\\n    3111131776475660778757116689212449970647324279755375416002199390354613546355749817637729171820\\\n    5846317609729714521923833852384040218515354807681026729188421046980938142768409004620489009524\\\n    2618214205606430542526070955755243826131458951628318819493177619175330028521221979377453017059\\\n    3374866878017692253597386364246529914097042264824504170908283589275449629246590083919247506606\\\n    4521586180359978537625359409600320327754845852161680374244582070775648449131148811850939749377\\\n    5247323600672151556192057083303574832155078828395809561279526235847843765466630538811718601296\\\n    9974300587549453270518978367273562060120802827480468660814535444688130408256849754148967548642\\\n    0654722688905478615717468806182237702176633976927357250505090034180296962967062902420630544233\\\n    3598857313936136334221840449155617813369881202111374989312717488064077583122524662737663549313\\\n    7253436281513385358933867801269490172084328560751318312784608927176844578343905351310684379681\\\n    9070578956727011965382171832416446071338617440002228029708440943210207719695747897137169115619\\\n    0424046599644997499625751834997286023265148995786338272872660363041253279223850638504663763710\\\n    2640061920073847867917166855774374989484457853970873894924097113056729910042280510068300285320\\\n    0984229559891779319982711408022177799069092327253468608943561614326516212424155341652852920699\\\n    6828198322817670838742598534848560206838581374874359625530423130032853654825544997501847841013\\\n    7870575916371665152155929805844201686622894244667816042069948550063242547736013269287699450563\\\n    3900006294230298910388336468992637768985508153439186948171694126704915216703207323615444199003\\\n    9544262183579430744549510733983717109866097421457663159949072795771996542657379438667103707086\\\n    9148161657566205340598899279227957108993067118190827996766490304280806152975939352203506994767\\\n    2378097591618459289383649102856973374980940140101442995313773540057338405167159158494420809313\\\n    4138426064521772009491624268243298862707586125544318154762433510316426882133610145381969804838\\\n    7820425447665197498892989054983962685728001343973156712313168052388157742992199219410744345625\\\n    7427997957183512175108526815707462662081475858488656884024333688064449647100724203067968493501\\\n    1096016479912905036832412735214944322710489831493809089449015939964015974152170167929719773650\\\n    7464193232442990813992482278895639884781401912623835091138643848853935852861153026623500117330\\\n    8905157945404020355567708989437965209760075524608568421875960799997534235505360769652159686945\\\n    8810232409667565556838092371417868895724906344471217387156671028237849195284743431702724289570\\\n    9024369685791987263683099943891484809376993821934945407986219978498505945049694452216807745443\\\n    5765441505944665516187981995551936319967003470848116265040925422827517237124035044113649362427\\\n    7163081837597178690889114512753644078973421011064109113688040056530723909151832691730804580561\\\n    7816446132262973576869284800122627497391604733011847114327759140484632326021528718448873146577\\\n    1572580133245297503203085313213351702563045548530383089210268024604616835486858413454462958837\\\n    7808128219949574023144617023271765536936123534044833652350201373318076118307176922001535769002\\\n    1756274046098680152261106895256679960962441519370712536642124467066288904920991365323774951957\\\n    4594893208312288971854218593717560829480117810008783447382962798038091817978476980567878604562\\\n    4887729954865437428848031661872402136668305597163741203153435157170495291091738310954520425547\\\n    5651944111118465376735328569749897840716719308270377046010822389634534182164880399886104089371\\\n    4756816646182634517231984200453971105454338860249390023070859987734630701442496172060771534442\\\n    7737669410295620491466807438521907420919992054214963522124047040759576329213856065049562933295\\\n    2083344336103314564601708322044568502968893311957855817428663282737938969177810070275909816446\\\n    1457125426642250530123922975359247467628637662505366354057149352334004852794503760315539775646\\\n    0269614748474720998546607800629356048523974649990907204027533977406299498681169411869419751271\\\n    8686830818242442781955702882576805590200576612389102433169033341123579414040418024567297961804\\\n    9446108819539198121676558839849566367006932571687418681746296429800490752000600055813705139882\\\n    2317416152369595597523517665658004085062510839276644817275379413262653711733464270794921010973\\\n    3088322742492648370183393200111443586048273904701015873698489438308452286823053912885063243401\\\n    5942784532626516895230393723401134373150054118787541321517607651973081586216190151389339139371\\\n    9841947081206896456865200503456444080112904342590424812345409265000883231988349405922967588581\\\n    3402506035927685720602322023282586450198429101180290622236413625405899949328438207736181415857\\\n    4355870863535615625358930098511956455573359621774402203501385550424641355544554984249923077226\\\n    2116136318233896082655185683890992750351581900095499106045590638268416406059413842264886291538\\\n    3344324044904999555762245036057548970034350827718218857039549405713722855763821074721457414877\\\n    4004357683224289822402205942118567940148338332885881953916643067308069526396178297184997736541\\\n    1866789473370751049038852490962708893963893195108852804100607972671792417785379317385265623494\\\n    9308892938657993562168508438072581360275999753720252774056751292129528142441018571075788047092\\\n    1802446308101889739344681241499635260756568136732099864343571699265082515335176227172259660041\\\n    9472082889414378246868227853535257356172169291816268850510130614414024745597416435158548610564\\\n    3481763551375869743053129282129463428804974435888851442711737677930440721281473437803100892452\\\n    6567589365775968465726315388169165607448043132491289398767810085216561431374462603628054131009\\\n    7462449481993205113796560073605671293262589565486642943259992370075305134736125775169794489863\\\n    0836667614177809972808397884779242068829149941200980979925209031725222019888644294753897066548\\\n    1678580674206741809965622700215357111869203241338696870493985610016577609225839778265830191515\\\n    0752240864667709454934124727560151380157223866383295722008618667546060523870343766455749733741\\\n    3611060088561799386478051465145027898113881199850379664628435888599186461562175378522313673804\\\n    8546113786386403362719974108221233299218582564964339249096134009020119448705122584948597060430\\\n    4643374611625562295266971474357687208989834525537835478912535463254976660203533705359290193170\\\n    6338453200971991292482592981562966635095850196833877883799845225989422085162484902187882697924\\\n    9388080469600067820836353647324672202034562610551901725296000216296380127849334236552900012851\\\n    0518746579429674111748364321719685757599100972598238470778906099040764342132859112570359159309\\\n    4309412135709085594596047428194586900619279672628882027386362825811581174874733093336561946994\\\n    5445527080178800641594895499744877153923860032076873489968567567021154573591625673966945757242\\\n    2555192158034399446220529930239281104271977632656600526106609862983639785025854683873229481534\\\n    7553200478977697493419990441395302824900587730644070819751890642993699963133446025425228969888\\\n    0090273378430530132440530587926928353335259625123102094966402992139401451290609582101059008391\\\n    1388376239017673421908542045707043932146434403569926967666351082119518940281094827370735944592\\\n    8569934007948926991014689781466350700654994733220548601622332966414495588793910569380596506335\\\n    4561729632362357117691678665402616510269551458086402180275166172353089391556144004056983154080\\\n    3228441535544267116851067295412505562160671315057146902403553937794146715284694028980387804642\\\n    5952110237495828616473569882829731181647082342194944099473828633832205428778950809582678596363\\\n    6463847240813866860817451199771834131932642865312589133761064132104924196581476622542632215519\\\n    4635874734287782264713215858342552847205433242519842883809666681968527927975078583078497587726\\\n    0683699357393851821452810077186296620266155086121896153098769165446220358401594495144212623858\\\n    8763456950134714661594242116441104439288959513871135463954758003420822915162303360000920160231\\\n    5760620165405242417167776640904117690368781276653732630583082744361361050043805232515250122663\\\n    5630833437686638810423982886965388533282633982177574635319795920407584762513860731271563331591\\\n    8005038330754702084049222387089542688032135594022263139963698400609742507300385964687550143325\\\n    0167178035394547380970945046977465980532167610797020363505384511327940668254294936398019200615\\\n    9736101797379734710152961299435848639238555758993394164403328508143829699013769089637752872326\\\n    5192390016373008700527790305418331603058440367616513086816384432822807304224672093302069087961\\\n    4919342381900155196523140998778374206044795036505956423309496177975487163619853721218460984630\\\n    8582531420880272494106785378161711030307605921608921610488594752781429873674999308137356212716\\\n    4859233833757494813184678106661213831301392894210095220540624007007089376342664947250224391559\\\n    7280514031609135978983024170597774071127721465103689846376379622119340817782078713870149084036\\\n    9926392987561888971339209946126233877332657272591269877412475067557874858417061834942792039607\\\n    6552588972693359005371997298034342524126801478131361175834225801108925555513240766544519911010\\\n    0422223196735555855975409955275828336996931610653577180682632334058312997977531434251685625134\\\n    5694632981447865381469284098913039797156147448950194267416902524747007585621919156415372411932\\\n    5165690304885621315378214124774735948390567384282086701355470581713108701634487173766786449007\\\n    8183155959343149375406284383001450102515540466841528628055892918474648248451918846754412136464\\\n    2319206863441133083255782785595562462888133712001741902749605754442626155050350947412794345099\\\n    5029677597704654038705113288019335589266247133216517153113945220309374623869663879146931207133\\\n    1104132921266971538763188695607168397022609851690796852242730001758494206107256397645360886245\\\n    1358881344528682436253895755968151554349285708605973183826631413715247667013545036914651753067\\\n    4070971513057600190807513944509283572430652250166954100468504530371168289059586773359784493450\\\n    5597515179186040312996823550431829980791924515559203843779946146918293948440539321270578606510\\\n    0857445095738889619847526720292210788166063030134803954787008868092209346622461521427383097163\\\n    8130609602761798019062976648582635182585540483436611876809497831743324291539714468012350323255\\\n    6684669803740345721846482505846748174906879829719201718119767052761224689744475360133257046220\\\n    6049527908634880834170128746291208754967131082389892126952672658481939886709235886444128293670\\\n    2002866426063638599341886924150301556289038122375670436949515932708476220441682397274490144668\\\n    9721513174127939713977103654440043467005054536505597310424530728301082247013913280507038493381\\\n    9662436236137339504139762574225452064030243080119361653790348689358729005804499628011544998350\\\n    6530905684367570110584735694287343497651348234957566913035076550023187800589019791711103579986\\\n    9738773537100008144482061452868490861597404778104966394928426532106139386666759835707437720631\\\n    8226206870629742525689707313499800604029141664831180617803001233719144391655591780834961919479\\\n    0841717904607755993097041081714963011273320047002362363348807891544946002451096290225677671297\\\n    1053478480407251022542178864696674826232976115787979703890068127761121024140483531378717888607\\\n    7496266071604013017065094504003961055675503301625561104336579792885614990962656626535695850779\\\n    5665657479824217263906620913617879548526438222189836218576991374093020985714218424200425154195\\\n    7289776434237594888036681239979169490316748736224409607557135925952584706786222405926135297745\\\n    0942307398230689365795428778115188195101939333568942501762357332509417480094434408877879749516\\\n    7921144497278874658228890427704038253126727634964325941291631107182410830497408046475681192256\\\n    6412645890199481929468669328724981288143206048729400411722909848597103705266745173842613390618\\\n    2645974261715317313080207438321115395262650211951055001236849217447935228877477542772815628394\\\n    3860588134330455851487249731889920407916534272593307629930291202869215913233742573904860529990\\\n    1698548106285981351273138707097175758788534676397484851991425424437104187816788657333015913686\\\n    9581218165837792139195586848422158691037512167912778860740860965548002960932256060183193052337\\\n    5203389115236604417918430968521093155525204209824847110618518638670464179576604466671347150012\\\n    8408418962706124062998296397112185264432858579019312476071322687466069753584422469003952844752\\\n    4172468698942462215481054650189332528611711607948774099055732046710424588983168616757587379901\\\n    6227664273662783415660535059926220353970071467331830024797713047607652341717725655065608566138\\\n    6800811410304029190541452603803561590411920159026886178704411681470380331193785474599536134037\\\n    7994521298799242597507239739257447269151791557487775309002402417080920430749433781761020219693\\\n    0659284148336912940952739372669970263200721479092658858818806556482543086118449514121464165440\\\n    8725165139804907616816291613872398523948766326318657291319297590287836221010040647926845797349\\\n    3679235464093322110382059981821233874491508565372739350873339781493052793787170869558242872223\\\n    7636894776039080948328798607906577444024502290629469487294271372854203676391051152152502617191\\\n    0783044403504570144607729318333426376691904369573812823946352422271790760904697285698568401169\\\n    1751421998572693494914050067084392971746193251269696550108859233844932279337156766747221263135\\\n    1109248784620864592632430473325138058377607187766491730971926959596013517849933686480502535276\\\n    2420489168905055482555040839295692860674735625604190476709107849027408464965324644773465097556\\\n    6031572003965108518725395731091929255044568141305682931024533264721860296745517171931102897556\\\n    4285123640288549043496853694155534551438295466994673726574402751815064049567480533571810760437\\\n    7174446505869928488822833903000533717720153871587173637053174880093415632930224719955863282659\\\n    9774742209566017915456926158678204932556501065895866083451911885282848081542800016363874469577\\\n    2312250081114398242506614831667956729192534316679228909689395019930398998423756547402046523399\\\n    0056730520799038507321301256035038393307792272212131485249526326599097763808454436320573575055\\\n    2945983647521108937402695637889218105188585192281378381530957511599233037318458878739277757459\\\n    7721464470800899532358929867312010719586582309302833287714702089578099802559674380233790801193\\\n    7946027147844097717207898982891624094225182740270888903153717543466672452271903485867238699166\\\n    1074457459389292517519391186813518547657532468624510140787290401741193206189232720732574570560\\\n    2796701500340651458393341950429656239007181863379988431222853046241472046065929850988468150938\\\n    5779990546381348020333389475301642042314267137699419995242507873821954763722948836352769014531\\\n    8839036599733091046248682638170189408460952891407282549215372045508919287746494560302452166579\\\n    6756275913372543951013718192854023178055429828656848748162787833726989468790410161345619205998\\\n    9324386595789982677505140365727508888051502603487264280598880263683377505712126873473920886657\\\n    2473232464627749915832410759077184086825859818080906974211455234090971944847357392380416910322\\\n    7681330913393267928817256009902135395560254098483282845888394497174322081862086118232087144686\\\n    6783324635834917318302503242286010630775640298598674520153756628815409612056497785868468789993\\\n    6015555031060116652943383298846949217920864549043470806067328112530437783086583105505420272573\\\n    0082510908055711447338058688938599623233510621323233062010576776919238218714119872061172928469\\\n    1256404033469820497060904572979593637759703200619215657927244528862248582601852227316221888557\\\n    0129135754201886388988532007276742484843498254342116868398375475983816098317915345466432231211\\\n    2913099371130315958357824417388862754925609695242769439571943605991099681733000368368112140505\\\n    0633567263393325618443691175998224309655698220336231359708680962885670088431002484139430222768\\\n    6511233091231210669508540426068114297120281942854825177334377919730865846343158347530760521558\\\n    5350602501493249584750952243314629273921136996983518738621034892729678486414759859220977305674\\\n    8617812825068028611162314290987234807799376574884937301004191243453521050315743111898822512989\\\n    7222722417121455523093769794206225513806393949878612763214560341886808498684729043339232248279\\\n    1070186689651355576156389674254714464266154262790482587562277818146462631384775616814236258733\\\n    0004645302992976588911804399483451874922493408378858780302774988915780287028023037017968085944\\\n    1465122704542531183107566746868465979005360437202777892882725181583465002209346514814769973105\\\n    5078440629624486596895209929160201760909552554581200678737620172959486346510588091481460560114\\\n    7753132184967950590755105272225157524032312270934072296610489539887938353642775308115224251079\\\n    6531392837334885650330417344394872638823181743425089859713402808412061847032338365874157510670\\\n    4742531582072033026151765831735766611344842364978306435080004371641078327056706952675002552213\\\n    5095676153055922102553357999048027615622909539993733920325275888734819112386391010783875702165\\\n    7926188414510663012065484100815745123949048316232166851298500447067071520081548245336983757981\\\n    1638194814855898100375476175992971961317132793280048551102949640292719860996014889278486005784\\\n    9219601937815340701203219572015531417493229459237373339672885052210850558229933102101476876861\\\n    3773582894088166087117975427097732979163603684951032646095721913047023651384853488591618563944\\\n    0560611848916195938952289220119875484612299948011684081955391613282403121356320993261747772864\\\n    5819295330954775274017405827983137282052570940487017819187116542068148156021764837988412365363\\\n    9525966501615437924095701702711673216503412369140745050587578173811744477063646069402240695411\\\n    0634415974761683502215955807370638067824738090542610098121123213414391103899475173994344234464\\\n    9108052757119837049045791259978303662969925696473366227027276834869518039905409029350446784873\\\n    1119070191475704053746624778946660350229215132870484174134040114642435541201147382836141579957\\\n    3092978665808642629180562198262491265723419630930823971293808330898884429830910986788247066486\\\n    4045826906300894489064800435815290505177824760362303693354046880281490260764308246383396815068\\\n    7426477866377436136432638457965501130463001433746882769078983846611615817394708686232527703419\\\n    5536998178685682629554334086444928752137947289177696286006847319282217661108119487584145391283\\\n    4774080843451347329763846398423030979810325583624234666415479900947005785602663888513423450208\\\n    6290529648715519179742747741977090370849892516505106742745824335634404058636027022524144094350\\\n    0421230316311866939796921705642821063763637125011986268816609838905441116018746737418380523944\\\n    5079822210980884593598652075745607941488907376017705219012268196554563221960357570756904728922\\\n    7151745033586255091065084836283265572389422033931922407938215633857837074612624180606551397555\\\n    0034770198937085892313520286255461978524429818731438917592909486778075470468199432334862009457\\\n    3433279900386963843701699303521405882827652572199780520460397923814566007824517103442359501493\\\n    6306595077153288548317747075984337550272528005765282414769816126136303950885193010728609512440\\\n    9377881220984451923917564198229182944117655455180414754514873694780268094268131432105305221935\\\n    6469795539854638585789623781086825646052457518160078172843930345630195572863697803958275477532\\\n    0445983554014219055882960201341425428676298832042917612573123491038435899784959819538303247132\\\n    1486678273036157360603732227150111577816635732832727696174088375131518100173142844740398222969\\\n    1919394945239768615195445211589712366520458601968047127590069142210349345485562292750329571689\\\n    9441746034784079737771240553443926271923475255530806223350665933406761848874970392708738118068\\\n    8420042343762662622408227622847285974032866406164023194287800049246909011658082553650482078217\\\n    6984657581272741502732900421554385067262354191729655047430396224822952237223509131366750303561\\\n    7049182686466370719607632004055397061627041130130784136516189534176063503643933931242971619216\\\n    4436630179523239992753149139753815756605545893534515088766257798530053952215116816539637256205\\\n    7137037174062891633576567388004555606838204241823619891595194371191446112490029180302040785192\\\n    6325810646682986016330167924392628105538027485761116329147819533648400678086740785430149119883\\\n    9513959527100014294778393944377161354244958191573961993273095104653102310523883361896564224722\\\n    4753631711509106739187521664843366306839619182635132630815261563797968484233210428661144702126\\\n    9195588401458261545783444902571377891761299433700051758824301694473085747859121011900458149542\\\n    7716869321219423725683226584921683496227442434819083622228603752421618100247752199061690005434\\\n    7133298209226064652884433812407746950158891804622459209238204291637550294259640255277855542500\\\n    1873867009402080456939382165944755538190890443199629112473988097487903594313725345186541214029\\\n    0853680596164481146205265625904464896494190097536388590996801389458426014926854273553515642722\\\n    8656374777059965595471237820334542992982858229670515242821465701382538014231996263174228933365\\\n    1518698873132018797300878683413804291041923189757431259815194422117984178739304485079328101402\\\n    7482589133112146785410736513279321703255489485450891720857311269593089175524724704162434658083\\\n    1304956037664417328718179028812882867161659117344863738281581686360447981809774728521803445677\\\n    1605580713888760725203505590192960039473421055841651819498651055970520162339396811235862308373\\\n    7161525709163981695788756270327733173380936104274433955636956096929886840910653231461491506793\\\n    7699886344393164010687501000632237451188709409122247855235617765453690463226690267715099572909\\\n    5594500695970857293209627369464798111978370852526857473316978708632039386842486494762494554782\\\n    4331695590792783679408166491884259714293660459704447142894024905302567360059450971610952188746\\\n    0643146301631131521207644816006485857072200215398311113758117532550403762740323868742075825748\\\n    4066683707050297563098007608202682927703224945588827975165320931954203590747241829672676517459\\\n    5042256211258164296082988958602774526583161791677207873607956156198701707494062374808685638468\\\n    2689430271761661218018771762528285912513233309867169310077941550937679114669950667158294686429\\\n    3533284277641915133146680828234028961807377686574853083006819673845650111747657485595913379190\\\n    9254833309175210037350962778517606209423015121458044390200998369429612465360030124484463542734\\\n    6309635881246547480042413493112894609438942279754735275480742183395952933714800657786571710812\\\n    1594761171964214066913181042012324029533951896864538948229428007391087471022936476211743504456\\\n    1046186761082280534031665409095279413486721603381951918062272086638639709669273863519862454761\\\n    8084378377323145444794680874348888359995190485647705810844652958786776037919683674060340039252\\\n    3819294343970610124390947978682243897913997947543458336459499789955736186588902879541192366864\\\n    8511080036008818641612130313093601271970512517854926710237581918566041394822287324311704856206\\\n    9503480942472711415964252859570117192423295933415567029133039737373407397960792923592909277268\\\n    0163080754544438633281783559454127272593056703285375222856630329841288311127679551254032468209\\\n    9294168280331398998695625794463395139113314811422129609097365873099333508479831375487608465635\\\n    8432871572680663225432081747646310156946007268211657759520841945290470128362250685366124734342\\\n    1478892371378552827648793620309168052329125728798606036205441982004557798766864159788902437468\\\n    1236033238071204504467316383112552759196228205354203668919507757072346821289206242254861623382\\\n    9602926300838409912053988865609817257480747341032706555687861174872272925972480546125256243463\\\n    3269449881256137555715972334250997072654958256192676040662817986640529210200714700579499966894\\\n    9136044698962783430857934644873527001915321107179323514515407856563723403171844434287753036116\\\n    3024309938388170294237454135779933764193732783574260144657674016690847114994903506721521369046\\\n    3374131824425345568097875951496441716903105888172261537942368189134931387261325161071641357449\\\n    5115822489169772942825559371680141142157333864921265655265854427986449398374506800010953314597\\\n    0273454127848380537201266446447972380407682139117295460725621201013909078806435084124587250674\\\n    0961879163798735996608898179558920070704136209607657337803828286714565466508437434848119738780\\\n    2914283416822139877501089701670393535913613716287901167560519460036979872037094888200703875045\\\n    2596539215859459929149816307950929305271833246066153442086667038274744881498484498169348685845\\\n    5455917951266349035340483362973107281366805669827669295349542030441063731731044204683076063627\\\n    5433387315133433538312915013315128149887922643665917298460286239888228371401568396261386308309\\\n    6012166871239741623081668871624751027698031871519270250640074400792488653989713215323517325957\\\n    9710286841456537605063742178601228831810177542480604202237287407417761392728157657296055021825\\\n    8440001222638199906126481062682286248230797205187378929498705213350049105905266334863378046393\\\n    3664725555765807844022657642688645077611522594893147346952268490098205858416746088648883579548\\\n    1871795814462515469155800973267742685464181532760144011658380777381950395703647890618072894102\\\n    8799450772904896943426555662092026226008637546353684981071763597124018619095622030971948376767\\\n    3848558606828016979054091562450220121677884443944427433054294898387017900438125922005052750084\\\n    6003247320533101474335532355483246343380735161924193695750876198829338857995455189623518748747\\\n    7677129349430381760136261011379229310194656716329530766888997971051030166084881189811903202672\\\n    9990795153365580424092119891425348985043815716429845871022315775087869684413001177925056654985\\\n    9791394801665846483150021415129366659136141244636985675221823889301484653669219897814726024295\\\n    6312862594505668347588350845490712999506130022371235298190182087287683769481380662472622434980\\\n    0250597906325104760647737241453108518526001944499096761224740422504211173507616663084287138640\\\n    8870451233335261879703569556355066528583564475780168061275325867563956636068932248553182877746\\\n    3163508083217676046096593973028505912134707032329985902325935790491852665784215416781550745013\\\n    5845841597398355423770719879709999422727643934158992906920209549032030340194365538849769703702\\\n    2384669473841121097281549446285875761077919920078593966984688723067495278750276282796398162621\\\n    8631603578004765532372375648520644597969766229277143295512574600949576779219559680212561482123\\\n    8154474553736935639601026650629098963497082574337765759299813786429648802255409225808323174636\\\n    3048901317575254157191322054711150584741657773108845884304205465404902797628522011015779347869\\\n    1741592535901567468913318847243107359311143921210213144705795867176326529335229351204242888169\\\n    5633022801393307922747372581157701063895933768530832665722836833036116004153500682191112142764\\\n    4632250231478976077615796124773325063656486169728355932716462074833075055201857660659307341688\\\n    2718625694396191591414603036995637645642299833617894181248873010379626329354973732771016846544\\\n    0173231672866178878530854390904217698853151897385153147893007390281424882858798284041928010757\\\n    9198104030045521220750794045673073322927459626838284883816907820261747327620782048152029348883\\\n    2167556948157678183337424486602027444620237318866678581760207403674513569691308886717604839952\\\n    2996282901721804186364973051774429497587590413012084800353344859072960418132004763986849141971\\\n    4657578933018576785710470179644825425822606463063603220636921432578054588126100399038584342734\\\n    2101053349330952310132084901854386062577796228674444669666328653767590609728691394340200001547\\\n    7471726552567112641665755311895798467990240565355615643898713185074610775984127716116868472552\\\n    5532271085116885072900372239074945939421460306665831972054658688596184499456174474582870596927\\\n    4457571006281117447111081899574776394888917778244429896396502114058852976793567842975731689128\\\n    4293629361176711645697204655535560868749236397969128933761105253394498899628282183973733752653\\\n    0324683424464727191957542925681835878309374932194138892743095536726434892528974422552393252065\\\n    4512560389719109129632820862504718871599009545760413944663741488612374395050768927268751595817\\\n    6214266141093719800134401654655369689747904408244584556828222363401049935183744260797045475068\\\n    4051249282475903312792566710799420809210284016518046609601809231787461616392414011764965413660\\\n    6747391234813550130436176363470182710003753676388779127103759639709508650242208319301160851534\\\n    1143602795067898991130010002475293729588241016681579161137612670473824242147065705296267581884\\\n    1209657864706020470976039480999124688971521529002411156873358650625932489412881086194727269739\\\n    7786513215377193100117891757623183760800049005375103195456455115314433727046981920749064190221\\\n    9783928205756967973677449360277856277917354287885646257486225885860023868414941175633799620667\\\n    6480635835658497607567696358810735594625733059298222763287491045996394149397104051506675940700\\\n    9258867824002815872060596525100539868655250661438734927239744547461132015859819788771136654301\\\n    3458492820882066656395557386079484866325196338235406081623461077284908439724354469880760781243\\\n    1797382215323881555927727844933485701562202076654682416689440298268478510059187578476029367048\\\n    5782314104222952016135691410504925588405502815856881733527761496446861998836060994451947489194\\\n    8460022452367322070074005248342739161846785623770126297519550432516790546279601080109534418139\\\n    4997261718506159571780758192098476149568044707759756845389563290867737507954221788531261727759\\\n    4560424214797587333358892114693121477051350010895573739562838886237185110057633218713212489710\\\n    8702622100164440488625506829182958407302525330400038741980617290171382033873695815999403007033\\\n    6341201546544022082577968375939208549882243550974440383461618290727455505603998628988834580075\\\n    3278469282548945122281765154970041650105828150775044646122132470702114362492344668808869767112\\\n    2540712958795281193629275417487272764657698126850686718222843141439746013775282370789140152632\\\n    3526776201463863594788904529022603315900531247913384330737410771150367783860576837737282992182\\\n    8508990722587282339332848920632240739344930681956514265952839273535460651991794916544123317344\\\n    4350254934937710894820519927774313955628235857372110319974108955219430312157526267356701771786\\\n    3362967291825195391061093500791411125018065547521808708340357091707749116172285749140413138290\\\n    4371920189872680131202328381334171161675982482770941940550750205311312562027870187280639527166\\\n    7597978779023902060895312694163059155422791716324539953204164993362798410488047002304151228318\\\n    5357500438001310601603572548161438759966486578623713023781916442085399135383388140668633164472\\\n    2801354899827827824869383355593093026138470671683287447749537310141740507457893756964498519637\\\n    5577122909307269818219884891189075152867467784726948993882411037164337690411543269991412101885\\\n    6318858247108362539097459374738588140526177174421416126389046040237920822393270202095553836816\\\n    1146966309276069019413079463432872624989349325354063944765106402468743637081819062452013893075\\\n    9360932867277520265922522346015900645544408438390527353208631926831783779160169165855467620691\\\n    8712547755623388016262166082815812165590196141177393503850936441891319190510469993867437617100\\\n    3699911008561950570930485361828892179648391423542385172622700331033684492846462902275752895585\\\n    9638086937830345563363075348496755507160619540899370730698596032786003736974719689245865497022\\\n    5474769243479921033743917572262341428388338318682709330964418034487816737032023495607340191426\\\n    4686234693605158161366818030129317687890345694204644077022012086697145290527082780132206457406\\\n    1556357642397360729543257004001572178387379326647050623290855033386056039003801897018811847365\\\n    4617127591988827556540642063088117146607054047919435389028416329646043049688819934259598749951\\\n    5219897825915967269842352978206727585466899064574695010559104239178176175283298744071645925053\\\n    5535537537274773059044764491397664109650121703656533247632389808820902237395809673145766074103\\\n    1243143835484232907127118173243143552791042270314301367993394857212444656094923749249661349196\\\n    7525119444365466415336973141457112772526802558988452423465579322244384023975296799655623791683\\\n    2505959053876994218655705117387351653908424671020459275676417617649716190691866866649928709636\\\n    2221566212487472454647969291468807072429071551566205980597700363049254388895913716319329106083\\\n    1859279506551364669916412559188069463460971883332552197507197861683957413227128744293138243436\\\n    2323214426746871778116829064023509651164993067226996200926924712569295380815921226408200212500\\\n    3482697839601273075749580914757330993043235728539497677822607532348513369730002601024164436570\\\n    3346628112696073741649013082952082142839075946039476298909540411994413094528017334658124744629\\\n    4769118085670858654563236940347313209884732620309564268126789296450308503957025584717959449996\\\n    2382180417978305932364144993741905791703759967691587166054804640560850076824342129378978144954\\\n    7284032469238060043952778570686334678988747331159874005583227585702064499587075603726125375744\\\n    3334757442487383142700755870683588465200632670808359139470243806806242716061908248389449343723\\\n    8009540494765015689661959194975640245488210270728719920654761299852219124070655427323010751603\\\n    1336454477728024559391022854088928821766828468740425865369533544028806579158722219874868942578\\\n    6194798789504892854812485376203122762373397742129429568112901607901899954671953438821877002615\\\n    3261530791309587523061926076794495517348655886913668036446888251917726154745946037038352805966\\\n    3498867147379390168339759421432131190233148739545888347683922431713993076653908865572708439599\\\n    6274248041228770702709652076466012080386648386266895705911639615101934627909468101923035099848\\\n    1071576000421292555396195182606758930121104322569199686168662182824938759157767622158081728316\\\n    2331994428455723049249297948123338128477540535905324709770321447793546911759749680138644188283\\\n    5540379241277947492512597667104213123926776635637095678362568619481283551822188959939383683258\\\n    2862223342855415989986734272894636518302128273322960397067532005967582687668186845550341839772\\\n    6435703101971997358078934071852320834325961003508287392679418674350617060031179450135996215531\\\n    7764135580669243812379980980056146997741810121993474895455275450706406004509366436697885171206\\\n    2610443919996535617254037695180986386052892596861437652473807776641391430871544883246207175684\\\n    5493463277901548973086202293754854472870753721283093932932050137914938888467205236602961452447\\\n    7817664008623531835262144732585408468863070689225233372242352413136611150814522525026283757186\\\n    9247676184487552412495123929203447341746139067229753471669263868739277040681163542776972760338\\\n    5590503273152176743394805600621275745076810270679276750595378075284934155834453411627157638532\\\n    1655122852737654987638231991704167924667674492836892718870011298298982081256206946966319984525\\\n    0949080539093058625017365117715317862019889522266817298914279165263443111482136597165192527451\\\n    2747174074794837061353491951846888407851989471441432102986866807885105294453243258501730501484\\\n    0016511527572675350193833079835269395337630759475000686594733256440167294416105214598290131618\\\n    9182624741013281465182880639588994730641372589737856187683557826777400789167496671074500419906\\\n    6030836418106927540596117086466824794745776408019073316666053168526264929985762229105999296794\\\n    9102150073012007167161996936471004613418031012715755695144956043444127814019860232482168621651\\\n    0994050190912032744726147319992739321635642515596929481046585873505253637790818492189028508398\\\n    3902885256659717132455679315185676577730949983852544345741443226012293454399752515537722127710\\\n    8912013697369760102321288723164965456509788636433606201317056130219436045182096253481325089138\\\n    4638982530117056358022907076377364520565241848859483641694111134766144797729643025373647356626\\\n    2516599926733996417853920490458268221156861994435475073113643842229481416611114619759898118564\\\n    0025743832498362671414115674138052660398087753485667098759342980707282630699414074131840784910\\\n    3393952201244888528853439558031697658623571115149231670089846803452280465914234374607698085775\\\n    6966095309117645046061151542511894207810566428534992701625416054589074276442939273246757839096\\\n    2304851637595529387343214380121405117474590580947990647147528584887676256872145924952314938159\\\n    9021698525076481400293186834743045094074791782128268105880851397718765960854749598660072534132\\\n    5182333493299899660936199184889255499232852286115575992365519042898259746138243389308409785104\\\n    5906063360578179521925307322315414747832683540931162614008004631524542122870119907065545672896\\\n    0527250841376315463899084903423418960536999180117544896840040296089959312254197700658699013706\\\n    2585982509487784542521457659471820537431676160376375162738764555165969321554868555588916466204\\\n    0821851666891820597454591725972812854163274828277253943473552194066412802931098713339812832438\\\n    7129453728360619274894959907167284746946722210223206880031799449483438671500440806643291176656\\\n    7715029580475013144198932217599308456423343504355025951309831662798345690082741237234816301174\\\n    4652913077404344358882095417602718864401716461009346261577423872668396392042564235203446776333\\\n    1052562628957098203968944665194446763879736301703824361242075566611688967675987231722905593912\\\n    6510538406997146527585542022453332781721539660791570767390917943961310666993288780231351409022\\\n    8373147644002585912049963845281510694285093964477736242502199058827926662953278315990335497904\\\n    4957572366223184065219765537112631176632845278322164852306530920138099122209215309249219936165\\\n    3296992762248162426793620857957594853585687239892623714800342800170042309620311443255360633181\\\n    3964615798506874634544416949697990204689351557463858169900185301984164356163905618237822569989\\\n    9804487693719301200502647110007712616198413550313659483333670963701762107684136775410403256166\\\n    7782627794221278750801953294910010877324994983785950867566935572163849168644546738565208911744\\\n    0805728829074711949288882244771101925874749531107009000584632843076787438229422114744871481866\\\n    4660923186955428520935858260984121751654618308198171665043401752870573316643552326847943391329\\\n    3630781717786677438098510623883474022694387391757253732278639363993569909259619325186517984753\\\n    7713922195933590457509397783173149028852891866365519199490961567141219853934645994379662182369\\\n    8909621598506085873098110581212557026478052707540744089328945643846625900154860219683089717592\\\n    0689980102997122773293844616408576220077587452481008084946984718936463596694020892465628936120\\\n    8920436487702929626050911136683209303265186385116675783831948551643538172797646178930980185245\\\n    6743637679539885962827078344010072135588416114176150795859882135568641285514355294327220752079\\\n    2766640316983914456965167186047934799209806517718298233746378487529162769427143783918333906861\\\n    6574583092556546723341135871427658617767262894005899030901242494811495926567992424196773409323\\\n    1450159559634395043123680208992796253676565849801880795891836649647836355504257136115889567974\\\n    3687509021600078036948850421411571372077019530309088897093538501163624929497464425055293321410\\\n    8527071261632481875988531299113732988287628038866152129241018852260897526821968898895234680982\\\n    5186391752564926063192423866607200271127789684679966090915866987140921128560377043566565699866\\\n    9994897482201572919113005560485467378320797622099053412680370629890849846411244706011389885659\\\n    6074271131786386783515289428712493719136558049295172253814854793118397416771632956450668324322\\\n    7690482187242889150768477481598484146086073750082502415706459605676831752871512269598877966564\\\n    7536753244335243730952650109680724424378765346257132347488622473720295369693533153812381433788\\\n    7658508747404129588200987466598159290232283068303744107292806012361365003956855339369927931695\\\n    6942558453480291310133147001362673771265050483080724903525056643940841080062642038636238290772\\\n    0278037226114290004749779142519968676280794469059168383789400771520911063640173239744226201603\\\n    7331655004616226106352014524961301008012834548049702141272570924062705429007329595812500757658\\\n    5060636591682158552985340913902797754880983307096571233494024789167072169943589199158596652083\\\n    5377918902840820157892903185114565355308895171283106652883158000224286088797424003498486153419\\\n    8838543804176330725085057847909648668328319143486986334336121885712118084625058665057303558014\\\n    9508371129139428504978804852319517857591040317667025913067457704975001642422353043875046882605\\\n    8684458946486661581178127454564807161307152866261993065807523764578497266909171034006529663682\\\n    7025252485753320502860648840673900715519596714470941010045903941037872314608114388324639713964\\\n    2940251479038570740912213502189985870026593572680357383049631596198286894413821734993147466508\\\n    4976132012125539107715411774149300191531461209767652572528659928020044122153336079798032934147\\\n    6870052861463239860657897885564475207817541985288426395404718053977974441516556719612778520649\\\n    8493556405658070159782838993032540886845248032716302745117213873748136727919450400326755418638\\\n    9739981714526739863573351051217876494581238020959156931725768562924573199978187114376621947896\\\n    2894946747563759129726874387813246757994506049989832906342079695465399212952945280687262853103\\\n    3025216549121318652453806230255629545780721690237281993627136356439069542493310765739108993173\\\n    7744206882117588379667447931734796171088187334856189428738195005469974949936657190306020077684\\\n    8747688014066160301054764832486892699349300874763252332415738080376967957033981070874084979650\\\n    4140800458403385229908461946100326112184211060513764206209939718939227118540679905548302220350\\\n    9075105259967573036151933724884191159114906456802196261540281712887986331295864264125990736940\\\n    9679026438719490209612809475096660591134008508711224691206749345667800214185189860017087726033\\\n    1841828589970767462606398486541919633079607804640072799381259462606297990609576613770794273443\\\n    1713895091591364412349108593483054829266709621776814249163139408277485231717061866282839952488\\\n    7755286042233618460105188432021246588988682165045182325358252260876487090141003416088225163742\\\n    5592198509256511116248231987795074762613583180549895705877349138532809458384284847539399140502\\\n    2590509323538940481191359977313075111369753405506410967620626059186289197078195239846160122103\\\n    8186416641149915727382453067050163149387883849771383234938946416941003556780949769253837743410\\\n    1151053972225532143825466603172601159313149612905649858552824810351131510560165107475581339341\\\n    5501997540748485316705471496625647869011347885167441508935781091154524988397895577680146158388\\\n    0143280083876689652028094845987239330878114978449976218320322666338046526788219581787444065557\\\n    4681266349081883371471599333675010765415272399437659467791772057829497557412104374180452462358\\\n    2944911861786571866629864437357349262872958215193945565732487922864259220494573808518985170507\\\n    9078015822644254480976901530404972460419216098782756485784632355951329068869600383544149124259\\\n    7701847992921619090628561064276679155284347982030085339255242999520867223824350075326644099354\\\n    0009664462930822704593037957825667984292779580355881427852364513267623738139319179901700465761\\\n    0851274230938767563414306613748738707322115422660843014356204158429907646513160215239591267917\\\n    4799690861846083105340886698527164756173835983063638456707066301970001560157982290537617675808\\\n    2932925814828280849945016308553486973289954525216713505825202022050323443872260876252508106065\\\n    4110905564874092620132845696900602614372023555561136501888448708858617695380947525374046134568\\\n    5079145206729552493117314933219669172058450538123954572980783432960703782907016149918300020346\\\n    5842793846560296111818214220305325812561935699065619547955721470644331335928920827045909873717\\\n    1727493131157088314436392290863556499106207327045956560977922653751074409668902333929428328061\\\n    3042862397308540137548671065985622489985758809413762210948918227274808466114957182573925524261\\\n    3545324255415242037414184167693395858847339257513338911595473622705910978458113820631167023530\\\n    4854399636596344563919783747072132510806047840303674039209051425931036470821565523785542996400\\\n    0720858493449464211706313987878389047582508770405846967592367514926757246509491408131282308923\\\n    2525178763731794997298711338926674309241343195756748182285390801855067404074572642667011935287\\\n    5310650775188533879305192677540576366387770050639466590655211856384313873443802215714780473895\\\n    2661573185032423857213286941570839422124067272224858612440174273990527884845834348267978189802\\\n    5813912118653940956663832453309916944360429451042143752521390935122858184354861326743799583305\\\n    5810409106348105513800937265501362495641719635934578275204605441041783326352706641731402189922\\\n    6123329597795695514024592788331857771510187023356820386555752121115960997175894824463224782705\\\n    0957787953647102192017604938139758708031090402911109741306085573569319134074933367602792116201\\\n    2376169980577187408391509623617076461053225127980178722184685110087896371343901626279134382607\\\n    2414385915348545652700442266963089175565305742704302065155780922147565145495008431715693138630\\\n    5990362378933394884217359744919763750108418481407476146652436712610665806101118245203310385745\\\n    3947819749476401778186789250869868272024782224142143143282598915058285009364809007514128660700\\\n    5896923997482850983319332365768025559005688257017388126366855442653368085955349495285814235239\\\n    6866156018817756634828363930974106803160478045119467529897109601475695099246619949758758576846\\\n    1913905664735988252860289634688529299915444702412399514182182476970925312178283476412468781365\\\n    4483682281583318731678329254788069568223390515398811674960071909994646669994671920056467756520\\\n    7864396375197383836257708593055301101630059983423010218063777748549809030217387235867570622528\\\n    7520799497085508967948239172379206069780142990593854329156396011431430796743657937645668430858\\\n    5768367677263297896196546327364972050227592099214013523065554959744922439180143806910538069308\\\n    4999214126889688011685494527885951664699071796979281427276028527287882040134038812144975229867\\\n    6222978939487138553553782860234879449615876744198310033857236244573074146558265024480788099544\\\n    8187824682266430714167070548874626275686552109139097055846999162090458914761917765994957918172\\\n    1568198229982116631501820255775637537514433631002853053635282951300860742507194954906708822936\\\n    7241767155096832712103874480529506783300493895569104829825347189985503356643915370380907109754\\\n    5363091530768018961331096898306147751753589603343107764236056177766305911998311269538235027572\\\n    4449939592838233129316733224152819393810225407238384387992648168502931710446321795091669265528\\\n    2234624381343913419601118204109569869597480540747979421646149755879402230859974149863874860243\\\n    7347519808015928303271444570116713517760697462734111464791471354341037109773539317399936123310\\\n    7988477013685038783934488413866251960281115975467282695482558164734853698312383727586459961823\\\n    0579389848821276533896918005054212705936082850374850070282625218334265323720987564532906516907\\\n    4871175720775949364391705341218959933635092299503230490199753091889105694200304305951213487903\\\n    2236157852730250236415826661506720791963188134812128407541089460664858144159069470260752125527\\\n    0350573089697593422703953178271077582177257527746044829650613200847630000709925116883120674506\\\n    5332957978166127732175668004233161471870958433859054600368871899576916414821481786799669423856\\\n    5210292554242166065482892831221025509789503791917667643627575975381906975196078953103988402695\\\n    9867369009925321523501457500544622939065173129652474333458864736075916570676179991634167778657\\\n    8207459714053217518728506105219897213464045830718952471930107024089753066249341325745238179491\\\n    8667088770289931394112247473444053076971600587014524757649429972940916629628175787974300707389\\\n    8993579156888063131128345145871661613620265274321723456302903312777949810147644115918095944366\\\n    2004536662140602832302922557780731245574193862822439243298105689246585957806828838477834377393\\\n    9359758993318639512359798255454049234957484350223660627425482995200700115707632485853324053339\\\n    8406523642685231245463031438384696899299918944288055225846413164769337947500245477757147687642\\\n    3492148449726949186651788037994126660806270816315192402897163369946874684754503259967055501677\\\n    4091502677992484253861379057853881557523779180215169544091271083448357315027672103474334642985\\\n    1008997595417895694097668261141335917651875859920002853907309261495600532469808774179330092191\\\n    5471229547312704454839280193541513121208987670130145935353877924444553847863319271514902422243\\\n    2283273171327640540872767570519128293211150015799152371303764629330173008825961315045874665892\\\n    4712138018815070904583849927528316107246050575712528695744711516642599970750126788687338013177\\\n    5255730388580342515841554387415589604410434482204707981009918889171518917027106826191311892354\\\n    3155873325934704080894373031054812801813693698093953449009533420391946421642377609024843439008\\\n    4432397202408440444636323826705326900119653155534346088851158129981344943862418569485540651427\\\n    1008257403967446039476527077428458645992078998427928037474977738314771198880054237213457733683\\\n    1369195741799008609651674971777706677489588549370277626073610020142454570564149303210896356956\\\n    5219353005792031110275115640068713664941689127650235137458625207883633463973140720915549275293\\\n    6133853243069973608221705621226155115371941258970765101034468449386521538626525477875091833470\\\n    7299594151099724628115913230585234990357734261217752886448334478776545452310832564152534376521\\\n    3070566077978009174792533100392707237178011322883681903073355691501858012437355192459362909857\\\n    9915124578855030619637907411420784491132327426550437489644711167218578525803535542043269617441\\\n    5788494638303787129235214992934966549165662715163533134489590741897804787293600019497554301057\\\n    2242110278628325455374760145514029197463904739513028818643777027709929371047595414381182646002\\\n    1184782321743337794984485769984207970228267677682240127451616620780548163049939093057975267162\\\n    2543413606323576162863617607758160196233251581477982957059712255595103382270980019407458443156\\\n    7925111493091653057831563438490805881395956908626062164542910157112071426454066108045331778948\\\n    2563679246112897010644839903699084695852968929301133419881090056758960986360444921933737926317\\\n    6743713063556755142345207178922333676311455927853642224232681283878176630520493254008217539509\\\n    2968388305260264020331336142549067006592167069148532694257666936417935512592084506106655405790\\\n    2505376261366596722887283286371854270326257099160176004945087046454513081994300218198702596824\\\n    4337145312695256193482408208048400742033870884746299337030378338377145061357246306100473720291\\\n    4571756150694156899947164128124197248790740325755149881032805338950439311499817853438087864728\\\n    6143082512590808870928412554008555886894471990252729199539163568104690003277822863839856109480\\\n    5323425206004215653824258044988618186531333646685135777267818549202224027730294299599155398297\\\n    9889852327733955677843659560024823102314301922223676842187050390914927286193644760437652671941\\\n    2511311417000635298676902816468662353017198096539966079862895657789909521600366041635880664834\\\n    9187616691867829071724669035967222772978418219262246413594332335537333391040201644678819309732\\\n    1615471053260859252171779021162904368691020825175843588675731065977458852896661753170610209353\\\n    6086836922412111344227562653098103596893422361680118045669670745974217904303981443842332430144\\\n    9364380805354794097391961689697434756595552642400039831968137547381323366631473130595146728390\\\n    5971595751110320261610028339113136326569078526578198079251111656900595402526531793047667286562\\\n    9429266858318791244501089411813366542714234253182454163906709046300793790108908209991524648338\\\n    5782613135457888528500988094674349961432030224150963988816149288573640048893508183019628645052\\\n    3028192656612139959320571838548680109408293585446564331481529039233812490104088018675592145455\\\n    5739442669052200493794033425651571826478085956854978711052217485617162456141548526590777985823\\\n    0705435290498866348331853302331196590928406802063734550885584668561758947213729750926920258629\\\n    8899454786494433851071538968346361304330348259434129102305176245384638866503085368612257642267\\\n    6932114911632597426907817304015051789122855671742825114765949201306837843194310964306957411827\\\n    9873817590589878668640380602858465908002823505173469499131036023833935350805944054202082879875\\\n    4480215139893841434741965456370628572743095670620446122358849422816670603545764731885107808267\\\n    6542815575376749993500869899057117388592264997561834231065637565293081599964856821346151069975\\\n    2840569839706033693537473090519225222793869304648130500376454322118259845153438491361411166310\\\n    8197457482438579664106189070409007237572797345637613687966758563318479535200596608884649514447\\\n    0567908984066422235096089280020052518362429984898718882770003109897267933506202477790690410564\\\n    9423863822360068592731920248341290707272080599017357856259091565596580858617264519794703266810\\\n    5429021609271148340305547807187958688088479597312823378563507794256158365493190628411692435369\\\n    5434920381297487478503765847625041269281734898409546931155339902323382358274579190062327540467\\\n    0550463373039322387660869406931221594217494592299953775230561871179026503787993366012674629453\\\n    4673501246384013989689625441115669043234075930264306388141614772205907268107747543267906438127\\\n    7009309095474898509316507881451540828406999131650612970688430830088810943645743101522092269562\\\n    1122964616340096758962165942087116597087095026083089575552953547086344586680560874686904556814\\\n    4522310857911362257392520556644614710285798242137528290234602894494926574700027138028840864992\\\n    4390669256935703886999361447828574476082676358397511952406584311794444968068054054535890532683\\\n    2028145228443744001746112746987801777381216463100293833252924777806939398057463200143430090981\\\n    1185485929774053388878866502491140312588794284456083217017382685137497648898708351375579711727\\\n    2650220887233359205158213442582629969222654331603016350914584938567167262153635571937506052615\\\n    1745513638094900049266202096043394871382448276372852356484864830281406520146549932895292528396\\\n    2996222957337602022307171471757298316533088289790493746418043639923165946262120752062987553650\\\n    9795409739276001610593994442848652271305359549257964516446125132113474645477016597871172321334\\\n    8828684989676168146737509776212373722831105753277144826094307613886652343212877012867072988594\\\n    1872473901065755256180171617715030558193729563939704281679004007693296847582156223586563634382\\\n    2826390365463940724205334663603080281991477677821054752782065281881008862427622948948782577432\\\n    4297965175623111799732915929796910599748307217379857800323159213007440788907051312748118864592\\\n    9551098209527182152441600572549079240200291729673452999767880645874352885953871855776305366505\\\n    5254788704680905368859299456379357149607320031969419996439250066628165251602250485536595676392\\\n    6248353129622980223429008649959551278591703418315111956802136957257608765901001251260627225939\\\n    4432274536675472759255693327228734259236208778024386465619426703301931188777850004846321981361\\\n    0414908395358971049385802573704430723722609725498240422560459667449869238505009577193586327139\\\n    0644104725697762313345539459525377545653145041294328445073764185446501164692003190207898126506\\\n    3800502603234812696335486892293157999208129070852886435971745995701303847083312274514815912141\\\n    2797133235819674266710557019860321327916716982777256805546521749775402563327941713292135739481\\\n    6907397229179277050534471134875244417858411180868124733569279108157101023092302358431793300750\\\n    3815544385897890387270629316325654694393783829656818081554628668343474247749641979190285904575\\\n    4421929433302975942357824061448839491851566801184438019920245216935188782685231920931594929706\\\n    6646439897915169150094068136251236136304737882667576398609684271455314379047896963486969097412\\\n    2186922854764140588259753876180719189710633371122633155678314632174911934641044187031105996433\\\n    6328677393689662790458421450834689015474882754693030240727885842258215867401765792678650233260\\\n    2040431231648985330787508002147966169887879654153824760973562205829187452247250035693029342296\\\n    0057229397033879007203749239208230983114761398996943844383398948673919981964790861943101048989\\\n    2686120476159084604557439420091981026562579318783045441980631873043434626583723670655328761396\\\n    9863571515635944614087328978763013228875622729761434092831399021199182611354008977322080675655\\\n    4607634014195051967948706501984086677845928051493773315842069885422640879732391588452206606074\\\n    6821116830367694686270103202249032858099288957187556122840105110647532168636717933411129373851\\\n    7348914573875476101490482265669830719178666464207511880675432283345595784884503750129025157883\\\n    1301410457763225304389533251566760991342128155228250463035935209711321543039012967810242938466\\\n    4084957223481669806861557343477687861929315409102994095383008545673619490738857417723389317210\\\n    6489222639254788818832844255739310493469549056055351160926728459832204899618543601404983781217\\\n    4740896661963059976120351126573675405853909320485711518983184953106923738435480125963376776399\\\n    6473008631952060508606863486179025155516875253010223959291524028929935147448228664408639193636\\\n    0471276096939781310662181413941054400813341859329006076958682334985380271133729842396553460928\\\n    5659096449733205259256091928666624235623495905756144170979045148557031331618775585199124136864\\\n    3513981248990516887221519851062004559807947938988488260171978155405357416542870200440741436528\\\n    9682657868619301715673083930490288334170273244857936773912408842832100400525306956654617926617\\\n    0178295923214600557281845895566600695602315166090326607368371785049282953569842942672336339511\\\n    1361779312351420435273048358428916497219788252844277930411596659478511837184905026419515187042\\\n    8365489369813397504394194493720134267762387342488769732852766351164223478774974580366678348864\\\n    6984335594971465669211785792968299694338093118228526437234289660055763477177445088830386656253\\\n    2662207959213544553553664372039719137171448847735297301872759525438014613640589994538048613560\\\n    6252018471673099599793560555714481627266577759227057971606253439981928729432044912784869882866\\\n    3597435893528175259767199757719816429567820382995991563197101926408666826492239945995904619633\\\n    7153756861800189713876696798224736847167312944792166384275653177179050506546985756215141669558\\\n    3002687731932532149872440548538891726396087053583861271151462797615740514461806926068226533330\\\n    4873904405731319797771148875088259290673102717079204973168602288449618973134667161642102760256\\\n    3508647411976932668645284811931538519479761026105260682082252697721929679745097567058514891992\\\n    1436864096680150975178917742993571463987085051621429183802292600828624037094088089884817087679\\\n    8904125677954708198339999368577306153485151536821067569618825448939170888502495711247884139255\\\n    0564431688185902732400428632185763858099017119000139187568323535178862744217059292656985505843\\\n    5177097915374786314623565785723373691892604163055670756204809700290420999071022050422034416285\\\n    0387190319596410011118827651536187625564265595832623978702513469821641774788743228099357500399\\\n    8455476005275645877579474176946438887597739253752915679829073593805282956998240244838620111219\\\n    3225105420624727242382559262733245562741733192026156006902268656563812937693611530510632385794\\\n    2209119293339793538960005699160180002058417719353603360252724521971081889349365849263246579800\\\n    1356261421057747225453063194909354468613049077235718866481593149592601441552266369040300991822\\\n    0462359413201013897124487491521197935923529763152910617644899611383622453191528536537782144336\\\n    9283121489167362011632896606585936107132636209972794816019347107700063519748863464804693713793\\\n    2944874204772591648199330014043888345748610310662876991946116492390242870106139494582583327680\\\n    6994127741858670244673462406522777745738964267208834396705454075745761716597894998303969066359\\\n    4414954906381648963201539825067285523354458910582838018644910733063513030215272356548266777496\\\n    9567756941038881401760227047709416719641544226535481936960554172484550139006731641284585401635\\\n    1417034263012858276709248229109246237350805758550215601284344351403495562346242669568808415917\\\n    9966798218006507633001057247623757921380611579339108190186131590806878103479365745664259025635\\\n    5512458684214620165072190205851311412044838878841932630644566584617222155331673178906189927650\\\n    8134424165675091868329079944760440325063930028413237567099236771447297578791015628690774957427\\\n    2016382920296092015192035688218716179396620566917073890550480889239725441652153131111165898694\\\n    9735643709220269873038506182451703890582500362959177530252896116901880532514864601369965314511\\\n    2058695963554450923635153674081576425815558495202903546476838510374189963748978911340046705320\\\n    1611615847337329402241913154903055612280887594464936447565244837917803574304435513684536613064\\\n    8288097364949904378534773145813927156098634298520425400639347051541486152736821008448536722742\\\n    8913986188201089427391325754086181131419887267595822618520139159766794011833306209633923182680\\\n    6479689622550133631655313404906299524167834912307859220277083705060886561561745226496207957841\\\n    9060450662552061970685087441065781810672899752142451337280922447698363049050069802355847075629\\\n    2366582875113654216154179753047185419348580756557229112135184567415471604126671826893536898340\\\n    7127889353663421974390128176193401826190890672289220634097672614197245510644809361151631811762\\\n    5644521659280557733317710441397243092184620513879584463976280824373606343351626556153506431325\\\n    3458308678184806661614066741592167007847132645778637641743401119105283892613722924725724601428\\\n    3467152489455848020712722883762138111868769349317451668421548672238457130497524318143655918709\\\n    3535812547346871410043521435185383605438042234895776898380399438157944973347556729438308846381\\\n    7674414116941786124932742076365188037574038085415979433885648396918030754303032668691337953598\\\n    4511180103322240661273435895538670725763257940192515839638009222850739893311851152124357257012\\\n    5740772313637034176713691912368188465602534707363437828759755689806613691479633887611491975123\\\n    2282381607042775386533499015589475721673651983427430585037832151602866898477154256579739477225\\\n    2827508115936536101178640695319289047528806260227465022954764926405496821638001128266954075350\\\n    7231520422586428003997503105117815021957501094380826210901342101298576226112379104112848276567\\\n    2348037462618544502779554402710754495958826071243265781951333754864699455023434506838821000987\\\n    4672447537963036397124842685892045778992853184390454147858818801869947229211514487495234974905\\\n    5467932248113328164496163972328023350899782186673956941156062438735136863475349804940551544875\\\n    9344579183251778195723966576801645108634256354582354833812062931161159956523638566475258399961\\\n    1966690357788296363402947406332716530701155248346807286384622016814585305678983981539373464540\\\n    4085265629468102117856978366605848218188372276371806138353574250465573883435245690674885439424\\\n    5837789069087118820408558605390831864029569346733554912251998928479437792839933628701695043322\\\n    1662081550045907598507604736714970564319956324638958932411293948339639065243918319888059001073\\\n    1385207170744006922474626083290874394416299613888357564178060929651550892566514638045369304669\\\n    0665466414047083795405746717674604062470268609676053872089853680705778446790485912223859200502\\\n    9480936553004178544035006178171896646508676793426551484466939124323858051634018458336026089564\\\n    0205238799637572409249150924484835941600458822742333490688883504544909078291764822792789105945\\\n    7737700223341250334833895608230728583002941015372063146636682772857010765133676585066203932756\\\n    2246357835690237443139828279697216805149537442557801345847744156577999484982829965396750156241\\\n    1850590878127195823692798927362905984777039001252577681434395287723973342449319895124524724431\\\n    4279990129674608069739592974143421852834630021325881098073923970654424305691678580190512373679\\\n    3993401537542675089469427664366201361736929983575403291938526558674145044424648125807425918569\\\n    1337215589736066111018310084111519623290187087821989978007477012673346038047769968720084878265\\\n    6767001220474239133435888045263501583307982199400396478573020312097160093373121695586431413481\\\n    2873893136988140415905320253220238291270404381928027413542872687890550802445375869453511722945\\\n    6667847613770920902940060363855718964716965457050869710626910968614020818341154504441236734955\\\n    3041031979484932434868959199206311018864211454380108276399855341122744183817506404130564595195\\\n    2213600260911351123118313263482300586338268038995124050934609588032208072791165118421643087312\\\n    7741947970699128835861223326007393737087317733196769287787477450425237759713566812833373084094\\\n    7804437520091946536042742565179096516204480744492238686219436283502819074069305588929807390117\\\n    2343961301699622502805819602494111047531235890133501825844375073557969800975765505601028620279\\\n    9395482118028243599598900249417702561430844089113013083223401694540606939654053087957158397595\\\n    6730680730165430775161229056091414943223200154157507279709254540399902348926733897477134274123\\\n    9677775413537205957189050222045639664942742974256544241400388369409655898653279612476768245090\\\n    8176923714240735903595472508660050537895708975105447392472505882192988900468666321671064651531\\\n    9958064034533442652343873487993060793793683219296530999719139191404990405850024201204635137019\\\n    7426273069588793338867803356104490240394551587116622423376859201506123276833926280284088549995\\\n    2188903119070834698365146208844663527548995910350352409565111363049326245620128314569148607313\\\n    0404738954196164810168981485764998201041341770275774686831902657026711628677481884233942231653\\\n    1126653049849977559671094295626750874081490570584119834039994668509365291043304459727152597677\\\n    2394509160102401976915946714594121914791578865912979907008026099934447591158102048171030892153\\\n    7197669623072394499874856026236217509985698228443383377896926031516148580629283807337610167768\\\n    0639218010259301012324188329606187028019359951164560431291293130688719794647836990751218122404\\\n    8006710781683982698591786994559527655820384108079962082608672637246975389007428237829060773520\\\n    5625397827290868067097481181188129229067230156654111912168256657777355777378003576471489649985\\\n    0529009032016463134003049654308123821957422703972678722696746574139738240102252572409002937755\\\n    2170062078099872126658509965058286713102678054112578785180630705795035508223286472186797765097\\\n    3992199594714325216707641081482147788319608025373019360950452083680351422248325049572351272609\\\n    4880607808500773802286096355926495134138461381220207216847202156207506315161692144929762298547\\\n    8305929339219622915552749087373726825124213185223644350124446447497247670734422379240588264104\\\n    6161192426247838499062370220056432208277195127569199775571550287264819659103551571544341620591\\\n    4940913532756635590441179197892534425556125339128359574953994307523477428097657991273789865250\\\n    3093075599290532770238868782555271320578066735361037128469040238250031689860721990535708272986\\\n    8440015031454772103485484804523699989795262304823695188352951385677497909054982695469474038555\\\n    4562178115201269196937723833844455498123863803284587087079491444756797979816294385070811723197\\\n    9938773184668684850361319247374517449218006140789063632314427834818282868358064958656332485199\\\n    5797214606184930151998347423395972844729949981517676314821222091543056843269092102867198638514\\\n    1001005835772259266076494798549342904584876505929037430234582327648321141138924912882939380639\\\n    9151443671217895860439180457767393695234250712408312922202414177498088157872877302054626326136\\\n    6503650930281113347379715705428005694170644268465983971272700894383447092855547253454220574686\\\n    2818249969388704384624882025303644865160595072013711257838824281669848216345521705207815418989\\\n    6483064470857849474370616119042490260841589340556884520605462959338476818989809767247709248892\\\n    5786193039015335146318932442552479215610947994652617672937877434056772350562695129498234581717\\\n    9520452495709861547995607401229206521040413585027304172654113601046723589880874602662467952265\\\n    9861577731754665996040070383783041376708090559707167449034925182887701624437754902072703910816\\\n    2507696483531431362804161201608013285950570803366631229930737611781216535338552103525963943896\\\n    9206798808344770338034895477644700623209585454436707131941199967743334958942036415464278672362\\\n    2771678804683011053333777518303780291491656473383863545592723975347303410028187393151459503998\\\n    5734870111384738474858035581567262457186776327540138738887987377847423069273527502703022868171\\\n    9576214255358603720161344832954973241275694899784470619246574879483459452572872236661988503610\\\n    2594594534673223448987093818005455951330497052322701680243339607220222563561575290737490496918\\\n    3869567243438913338787464303321716100819818108851320878118964311803447323605656285364029332735\\\n    6130944491837340467872948321790462045581330395356592714062848659785821967649549568901100036898\\\n    1310466839542364193690002578790314529824809217140431882285014437223480299139310687401560545310\\\n    0838668893066694153261839154042684087862909484448238313591083296912905144330930961647004877564\\\n    2111268056905908739200582342108266751861775984759864437500132447644644654342972824127208421473\\\n    8149343307630013710815996053286050598690416584968027984196806636731822007078783208096577670684\\\n    7793983125996338075405332056004692227235721606723245112990106752227388969454626808276341830516\\\n    7645026502790558335731231917116343529935391015670073529275040073916030691657465363243171188529\\\n    2968469035041602538886820504033709039393510710930998437850802153494834075352966021367331058101\\\n    1172449226976871268492537873523351112292021155324090317844403163015317276120078878634396985779\\\n    0764263341114805168087208835092429062639348995875394729109216320382373357763492831898663431587\\\n    4354018468485173238527115484219054312059287952898238026454591357914501373654179497468117688282\\\n    3760240072178619810528770764972860038827126414539653864788843494944368478276857799590750942492\\\n    6145932057362296009959720313839175263170235480322585716624172269560473773214826845714172014374\\\n    8102301951882721334981371323005346557044521521567773636870934391516118698325199313382728801078\\\n    0467984364698202980945027550380365211463645679127175980291477681832507494227540030335337935440\\\n    1645218970582699088442545845586402393937213660920622830841175046450773864563440697202575933166\\\n    5310433795095401880399396686512056703754991344377508005649415261035634397417760450850908929406\\\n    0698841251373716975251097014569331436163633373675040693629097131611322475704334363433080067191\\\n    1176510559881739759182602586427847376273268995388482356643764282513461971865398484902185339502\\\n    2454613364710039520119525952332786061510936302326719199535842757012713020247420595558637867629\\\n    4017217646985447854236898672603122190527836070532756341899415628277336958942083170079321047803\\\n    1005262793801115722158215255500831439554815186681893156442116503903820305936166039110319458623\\\n    3752656279776040889455354310345478297355771145981877254695404705038731985254215749653760603425\\\n    4956294077665210967369160450414041110281657206301203367526368444950351028294438084323387073476\\\n    2430939358553074457375061973537519955456558428536697685346902502932437449506853172516370233602\\\n    0835258083286462811468262931923257208382049862584044452061597405574296680971093945496427663214\\\n    1985647018184436061519705609143028291598915436333066464822955594451039227842205546892576892223\\\n    8849946947759136052617851511295889886662231806293161239428279961055338223307521335919503460456\\\n    3778916185391527882807567542180389751024147259223279316053160729089423830382519084235715269826\\\n    1325574851359818264046760789418752238187383181404655764785985911120731851643960016275215328772\\\n    0608846564100926330579906026056924581861589215785276839209568122067876919114537684732593384817\\\n    6071180848241493453056562897171893183538544934603814408293170055788810887215497839974944257428\\\n    9293183198349238381450370108680826221343098816251356292903071422818732269593863212880749389509\\\n    1962593890314479381349589460513805896487501609320992476313995635600126279981017964633331179318\\\n    7171239096705749871437018807695917455656485241952982385922276403423745951285910737818716458615\\\n    7328310017352493815059885607242059892778938879400308019826883749362295239053635693946877464069\\\n    5537308098455600630121812830658367272037000140085016804349226325540419729131165930171769998388\\\n    9681749398283520329228067750412653305950228268030156457619678310519616073008416494695193873663\\\n    1726755147599728903567844375041606193731006912495036859997712139230251759541232359647205517077\\\n    9680159220724331021586100683837304879722612136093080756811625247328467827227640511315714173841\\\n    5166266964982605574848215077034945313398686166002703634868753621878738626614638791524454124540\\\n    0801728633260796855489623288678509473978579499211460519192629646940839007598055658140038022808\\\n    4324416245466216265568335765751592408280120317201629074007912964992925665576214633209437292402\\\n    4533024113168277324421278735940612478014623602149380350755544350349090287267045614359412718030\\\n    3812351364053468698543983358934805217184378788814555629601821692219283796098626755349825285793\\\n    8447464936650897561429198098361458331851462524644088949487439625986432324446535931561604917866\\\n    8577183422772201318510444680349732995439484541266886618833799446191973306860421746900938910409\\\n    6686051459761363520788287944809901333536765750082892098823125756726271963970106881462688027182\\\n    6372318025154458959383367175741095130354850673762366763155904601741271115133591887082237579926\\\n    7786874887870050051469798726723718251732495958903283230718444315036473724366284862957642883073\\\n    0134470061949677288883513784629124851035017636764090385909938753348730682990240199835505406908\\\n    5599393778312881298068877766920181334642705231492825841866286671260124584566120036143460913948\\\n    6055620036750955085159644486440293986745531309509961662915541506097012646418533181389973085181\\\n    8746525666309595270655206589832189757885996201290626094784645181353418221145990166745974215257\\\n    6206104309108806005437897025842756804828657874854886559293643663614547604107935124319692147633\\\n    4933788563581539311568260173396866240335283715030180830331783231929738027666056038997996595994\\\n    8652508669164495416231625605014228513224511695275166054624727823818047351674684169177337237748\\\n    0127633340139864059701780029245511380753800021386523425624067065932607815268155724976979074708\\\n    2726255549321067113951568833641910444747351957269101241580968386527101719252613043274784237604\\\n    3376282054241024323468651217264315286486015491380864127169440887133396238129796141146505330632\\\n    0045718918585922413464665177499405103682872069897951185457462256674724932349947233921031534825\\\n    9583710195694142366254775074923043443959994848376177546087189566034364380751871657799197340990\\\n    9864790696350321219406616858083280169968247488079087436509244923241058172275302612728156300367\\\n    2221276216619267149969016188930116617186400911286968738236479803924642402408624756679007202941\\\n    0844573534856819341108764161869992364561145711692268977628969524571930393528376894978011115503\\\n    0620078512410888063049789533566602046163881447164967694187196186792563037554016439361001513702\\\n    9948771095175304721893846119925166672071992276612581771460988328372857460106057145467458926142\\\n    3314063196081216099326868705267498216779490564823859241607404818169214113356160228585326980594\\\n    2251192602320777385556958936007311631170021810962001013444033210243450227920300027242863999996\\\n    9447186109428687924357667450624507691041375051492214977425066236842800071859927810047522176063\\\n    7832842581856713255795557441929605297250268143482902498290129097234740684333078486295524921420\\\n    6398313604738150956441534868221592028355483831601933146268468915349716401759326920896701364053\\\n    4609422893909007574570876501046492516908732746153908485432803930386465784572747949430233566627\\\n    8013317145680955156022804852412224976114902740533030263142805638476757837349600963609892347917\\\n    0375635627830460447136969342310742010257748875499398962901239191901973987482231180104129569355\\\n    4170056459916048505294896973120776432257589509560855416836129979112961150320332996099447752776\\\n    3490761522323521223348250801299410203842715038973675766310067709716576719130748529210129499552\\\n    7206432116229985164848190099202559606274535071904685356177084796119788973841666956453883654437\\\n    4506305939021123003154903641375918786757589365669604949499385615143248513606740700713209606212\\\n    0505869746189103150161695253195804049332284085064087142687032405006588113725210368839222592366\\\n    9657375543477101354657310467371761673396809838393742960600613271983583782544266893166897965130\\\n    9713583607152681631673929004467306414850010403989509901129925235025960079687829406336836339820\\\n    5285199388753512994699386664850750548047334253479071761366999018902586773163735413823106234610\\\n    1309233031476868360744291856511738817859122466949250479072280625595755404072883575309216243079\\\n    1567961434112707478924663261332071279172137854825248088834484872389676842401902927575780652973\\\n    3458991619748847911231262850038913343813740479690687473840028378814530227231345678154340887637\\\n    9780164353161083701160458579856936782174728958710076477283537432778340755354096514536607342704\\\n    4919596002833531526752225106467867391440056776947760632887001104164366829244899602195148790010\\\n    1510330424351792802334874102075951661330102017439400589975469109891641636965237829774255813178\\\n    2179169909427123922249807500615819166728768782722126275859950363878530700791336089350618065956\\\n    4283842532118134041715485850827426079911856352837289782786472343558944761575954936658410040442\\\n    6916354368204898073048665117684646728572159992398953258219409433812625337320824664518331739472\\\n    4664109768510652358018005681038485825595081361744274419697414843835520267545943416250308770627\\\n    0825932204646233537126784357320817626887441883096484144628616176331513038088989962636345172800\\\n    0572424382062601801805480759194764653532280123920345247524075956916942500838996153991619177705\\\n    8228022422410383281171211405295852060591248102892412137912474310430723067589472306239729712401\\\n    7241866239657271765753178853023769601738658010395259330864973181742973655124978721171627391870\\\n    3081278494820356161480458729801708094469747289446494257540519157588203941343039020287459935469\\\n    3784515726481348996497930598830657684027881859567339754665328988261399720782504601749573217526\\\n    7386762992063479275092395349322984197988395123858250086506072498579664268928634402082877884164\\\n    9093692711003402220925592591517942289216554994402856945150786863999285361043386865550041716203\\\n    1881089064797467020787418115240953808693326953934351932354389364432271857587499000993523421346\\\n    8572540800498986144346370480226659694339630133142090626260448759004326682123508777039162148694\\\n    9094408931458918612738099762460710654431271518394339209014670051063410464239483189181274793515\\\n    4472632853207293944458361388935253288883074828715502355131227462559679427038467891676139342661\\\n    2758218922608877541137915570994272080105881568072572871838320741592633096897388799474344365426\\\n    3866453646992323292297305949010974153450311928429859321029005167486276006344834951149833342250\\\n    6235626098073511518232048988627276021187399366233894128121026006223241194026977082904739961562\\\n    8270927901035570842817096962840369203403979738262419395014652822579803736817964060073424169747\\\n    3485174487021211402487147276798740111087666002353388103718809643242878979101956145398055460097\\\n    6858546436446361776747730113097832313929465435873871501374303983572111065608023027014787700750\\\n    4568600120644467562135133396789185289747493749167048463861838660682082211741058369712393632673\\\n    8300987795451942243955994989391085131980453603784384380398915638524479373336841527627215288237\\\n    1086277836162713777669494890086680310243637151790992017476226119268140836218648372498738945653\\\n    5525260346409879084427269201483780250005975123590449338548727111229424575634938662060331160315\\\n    5222715962030302112491249244692336626768665326390302647862244750989212874766118437087814120259\\\n    6173482390621142351431381919057088481470746850481655364118688498758016560383853061183860355150\\\n    0569817319081156939507855211159364231330322145141399663913542534770886779441098644539168340289\\\n    5010276327785150220243844226759379345105555177381729433242611320942793084460881038855396778407\\\n    8141785008260304120225824808011500692505588854156565365006629345254271716464241227574550474674\\\n    0480890694110362623804787011550309189987412414639987917979421879731401341570777479311396061653\\\n    5325975844401939589968731851105599530644845087050018585918664414560378930346152502084500546824\\\n    9576962998769159968102094359549060504240937895277573800489287965852381164411486238499425960635\\\n    4616673807691935841732245541922020591001686744439146343422769843441648055152928359010683590492\\\n    4822820884962215724086960939474455952217544257389810949018857012709983363997782145049994162443\\\n    6564251977908608069907313047168131713411084262766915531833106896396574333306707977374163624780\\\n    8291371914059710254457809725242775366127268765794509966653296768746541649398344511071136107711\\\n    9590761532932903540348175962796960400453491860163008712706994299446047058931021876749461877881\\\n    2534251340002157665421435835006109255088272308199804449188353519223203683856617059458828374020\\\n    1552534164725721013755117704808135445706973434023258170300008239394078120830277163459923118424\\\n    6764255626194805673199706632539635089758622671629519900448386112110747398175796364848148948105\\\n    4436247538166854917559468773731122976522770431595243343822965802990558868039885491727646784455\\\n    3923920134678789859952436832353038388890746727442173496278402654842347243102315844306504189999\\\n    2159744118627007856350172722562395337650347936962294952837620278817449427867970849652664864945\\\n    4596934113499184916166571684879822531559768878608057823246103939118887468938239566657546475744\\\n    0419369259519526997812489811893855293731936879653161774015991511988280851869357708264813176361\\\n    0068481271511593301393083988413575898279876997918872425871406970610327180704786550675828427418\\\n    8014071786425836675891434134062013819178658218016814670363380780309451572858211489012815852748\\\n    9109890827906698860825511183738451122729550925693345321316060253863782482604664510825206394199\\\n    8870666565821273977858225179708979697938101967308370012777058632582836437109334550971052949621\\\n    3590456093439035011974259927848260640980435299495679245135019869607587234728648251217046447985\\\n    9983494114146688961288077780380264885904043023697755041773612068608253644896791872002145003023\\\n    5603449078042962091484950141797703024508862436958269667038069928013263375968651294790479601384\\\n    3239909738345764153377531742731003916634366320546104717745207586852751336044795382549067845074\\\n    9596663139757364223853588766191992273273905812409132938750368155330017061675325849027540434616\\\n    7952540820738018575617854798336784221422212646427976392594088988120766316252092953780820556296\\\n    0214269017596284038803494492043244951360807265589358694440206889307048360838113039006960033860\\\n    4025531710582907208307156413671392115861357252356342843036135681735393838432135925124631207431\\\n    1043196689952992488237390478157955705443639399881899936904719573332803931106711679747274790925\\\n    5790007758003458812809292699454029921833639697888105600881361862127177125252593052992869058585\\\n    0705663154333371044265527767342381241384284791022763602784827029342008484639444946828262292671\\\n    0003427439820335164244621500500179124002657378534788563756063422938755869623129457098933035119\\\n    0063896220697661270686612852181336459846239653290769947750709702307976361427045883844851086627\\\n    7839018199491189832629619492478131106580990385682195026707742833351403532451814911419938599107\\\n    8379404343354612960085421644763220044935286461608185221623604272368423895184520722754943148406\\\n    2050612401026310121134861913551513945620031589810670167757672588554997450453326111853952799961\\\n    0177007098044980459563939552085186347215577594205881653936411590666698735648029568600490084047\\\n    2409246071653451172343339494955039979316868128232692797658340910800044051824959923737078413807\\\n    0659393422693878377228304911372779161392364075904361959093743192210676374212954904693324802452\\\n    9376848464993761436301471153775040425279293253287141321565461315571990255630009970393851211543\\\n    1802949592719741501951817513980380202911108543998051927362656782375387141258290123689734604352\\\n    6107569254760419419288533711595342182197448624095281405091553165364237925331752063440005475610\\\n    3584394968957408107505871061781848629029861390727418965204042942378345240162573937228131955169\\\n    8328336436061184354319452447782436360163526875730768121211799953866614673890708773036259793812\\\n    6669859613899801867265347836440098503639855078765081900458098515747746236995801378499805702497\\\n    4507909201709082454544171397320675486709114078235159456256670924356520648652553898951785886799\\\n    7490821113831701468736026467125865249482435500362337874438922308603810513175630713091218100931\\\n    6486976836471328121132008424747776162702194259051122296613621549414837756251057451347401470852\\\n    1636195555912929476997810095122297743809414734691712356395528135855098595756545445409691269431\\\n    3663669239742744423852839495976585805702315566873258585841937678375161588091463878792587414859\\\n    7040940096928476618540590255078458725058743801704552297373397653126267423323771904187987413735\\\n    7762182907917941526419664081410682817232227335462765037759769600404542054245965642003962627017\\\n    0182315395098148252452171045440385237265436077302837279080558726289199639108587843640167384441\\\n    9110696994667406921368733584702321692206563692692867137642237380658243411581881422537641548440\\\n    4881731331858191313976970007472177123526871376673377746332839027571018368022710723032837587975\\\n    8961663821678072370091925429493586699116343089447073571825469069448101814960058750317093677964\\\n    5861778734943208534816903894964699167130663313736360790804304906404835782982213293686095935863\\\n    7760428251982541955808698750879949299446659648807140876003817871709409066740602369917935162446\\\n    4693316084356579973580736239855312987344104335025402718204503856153937629567319151294055857305\\\n    4305185122483180711177133527230720733152582925338393741145949925318323405165439333911946433448\\\n    0785809642605378819054784887877367824519255462284790471157255555911679642767835953149729440494\\\n    7767598503570686404586709158105883092538043372995196442351186434427550822085097172372195807939\\\n    1225926445521065995324664254519775188585456613066692226629615235354907318620576165248167477703\\\n    8325848249787201142330632055336175902885843513603987778670269948566453817501091465479193442831\\\n    0027700069649153255952741190953857575634690710218280502348627437259574589419484063741330289978\\\n    0681610695250578757957514522657473668239255737640555800091025015651671679064455070159539796720\\\n    5524174326749312222494977347364376107886370390580439756576690225209817268065581424133051444349\\\n    2003393640302286484709044070328222613049147174896143500862661443951939842723783126698016800845\\\n    8970148204330679356134732518413350286884813382853932044938490643812126600194853126748524916201\\\n    7855376683711488037701417360000015252606938039787410234655961526376542616002679692033431757689\\\n    3472438833375698939673345293301845829365099188898673106185590015920475185776316502574466455619\\\n    1234998247328789719632915564787032075857467240351760462718591678283381324503943695324786465753\\\n    7485671700558599688824065127879015845129048855746488397748995980063348918799343910574622103400\\\n    8958119326200099193073135092578592666957914709070955311861082148973364971802441389833259930382\\\n    7596270481930593182055019002454595682892346794722127722147945142352331802750518505491313558263\\\n    1401248233134990734598445936790359327676894574796062667978190937469867681200039957816053888426\\\n    8425899318546252932100434530727211869172765370669198521553511607759480378578804925152699299246\\\n    2578740428740824398900079482840352104450013317440750007435046930672945213449458374617916898257\\\n    7049033978308009243832058514475735486723102956838626770691676978138783387369871405587471004011\\\n    3849538052850656391884492854181900260674174545435634337741942110626174089201913845646742306791\\\n    5967113987997295802861474653736810682712461878781690011006253503518950329042732796111010373159\\\n    0776211508386105245316433736936494686835466566151958743003585766272906635499573543770114407431\\\n    1699167804644643203127924298797820044856594067904268001842852875162513246823848758846396900602\\\n    8953325687822606779157266994460455770398781848648782842466945864564411208305127493204592572922\\\n    4501238104660734821093275809828363708679907939358213295735660113687552811485041125859160420435\\\n    0277221262016217549431215563914624387513052878593968626674124357455225373580501094640609153317\\\n    5789965865733571276611981414898996827056628592592310144930242815199479954450694392138934144042\\\n    9898334434848565982816905591227504975397658173649894595323321384671215785557971463968517735428\\\n    5020272188733167549512215518299342922192781648632625689303837328931827205717624235895664671355\\\n    8335256316929839068542045392080914190099913737864773430155751958726311716817172891918455920482\\\n    3709922674109916198851633258662335532500708919124406958706702298304230340515360865869287224570\\\n    9278744293341106692053944383331091185377390807915098339679504029334476621049821295892498303380\\\n    6237751422794208579317661358268661359232454203839076516414541359711511052233517231837224288946\\\n    1017466676473977562751990293859121291042913951661309992470232589660265314683256150068698457406\\\n    4591904849213442599196608208025193169654441688445694522391707826166966116059712629727864899954\\\n    0306250438289204909263651259100539785747463865427414148762773495965848095114126962822604900165\\\n    5215157224643259781077328067773647504277653744393796971211325232211352432660178425290617287572\\\n    6781766841951734115691296325966370214571610143084501690759370699839918309865818842377067809852\\\n    1147405296157264125060219401261513874059017020635284091282345396742276918036631374839180408330\\\n    4786309828628146187776631990653243631174261783870569942586887786766609967319761778237270920139\\\n    8739799205470563469118737637016903717592353384661799898101325785281681373419772300175487618241\\\n    4669309794202576463752972739272603140500161949780058858829332424077442895792405528045160477765\\\n    0074985638947066865871749320083488439607237272412707997190443634448534442883875731362572618482\\\n    3974440594026816548918469287602190335024490988543231860656468234966983816129193456982601843085\\\n    1203282102962708067866607421201172160053816515907227324083854797563318335346476659051425350735\\\n    6895788447914745401715102222467900297640934968054945818744955676848778891834073446076092175033\\\n    4807139354616151271016859103258459118338971454999259440476406761024621253066568275588947379364\\\n    6419788416507018630124640481623654980074046086044421364842798140424286181386819240762674387815\\\n    1928221577331933929560259908926859198503888408683291386654918088811665269445454170443646344193\\\n    1466800158700545097767144053906199752674259090305283570568443483248934475284808183590511507846\\\n    5642903136282706050568264574637181939984306575924450328377517194763291301894673641115126088355\\\n    3162440475678982813904625599713942698056005097103925183144078816802210002607272876017106897906\\\n    8825274590479613682709982759341635218625312336883799479774727758399073020212011695396535253090\\\n    0612764212018200903229268275929740701517741063004038704850406232769031680353198861719515255327\\\n    5601704668049558480984440144457418509673629462554444470904277775353375874813483050555559294190\\\n    8563342601962265314017494962153966737308208944729736436625043479641621243108698440971781541084\\\n    6278207184983715876023281017839864973617178863462629623584195782807426106341594754087315002910\\\n    5265464206614093828100242426079256207491940867550518807874841553819589285442148971296336572212\\\n    6039288882826971653352103610633306323259228440497591980454631986444617580982358330433028002385\\\n    5876680728241836073792064035669491034632823727022881498619200140806984701259457281007099430902\\\n    5146564112251387909536649068490379918408781249065678561253403809861032075925851629218478397551\\\n    6306208724961771065800213610200310606040276549595521705726593573723900669505044545440455467757\\\n    2304216824185217317797740101218652487054682415179983033836059397147923026475323643804422095699\\\n    6667701802364166996317209356319718134782776358655599947417817194454992769771435589099891767416\\\n    6405227073517912964817132908091354204741746217292673452044150275752870737005565968598231361764\\\n    4316661960101529854136097420939173542172765124392870723411213948316791982237727258033539541532\\\n    1048037496409726303282172752590536527041995767607237735349388759336752826177895622652234868124\\\n    7217580353440388884488377723104257959201966538703231862324221557558666205477893025118675561289\\\n    0464452961589975214284900663861765957919549214648985317251303885957494944160798565456189236617\\\n    2767095607479657387570171657088911399345568787663336530430542633941490161129771506928592607719\\\n    8071121840503144708646170821298237008503548535498621073619222599950107038118837955522996780801\\\n    8965445625408510741668252967620835318997378186939014966447451925744738018673121562155989905096\\\n    2212837754505147413813522646600595191633222843692337066499563879872147450798264087396685102992\\\n    2623016743757310819163445180740995231967580383231379515066891428364910365436511560128465306865\\\n    6739725910393613697381187485259004663425802120748681637589788455268376298230865028983462935263\\\n    7400692425034672386854533671661339875797587910621272640563361838563746287921592391695147767499\\\n    0804676628996825989400504354514674324582694661087663695757860787417371073479684217693595055715\\\n    0447805282032264542466470832123837537547881039569670271763828365925866302779325544148343236529\\\n    4457793878778150448332026804974341897874855969127131512061328680954682920601831994336518623648\\\n    9507976968983200315389249933321185964943025993520982005629611055847016750348153014448589832282\\\n    2767733218338816491694905785417297099396960273205747516449336690159467971821811158163298395821\\\n    1456546748738414210138204442675184539921832045144950460940482916404088253670499271599688762096\\\n    8684071323916296105662761712662011556245599785642086728552228779805489084769881568348146436564\\\n    8715066578609268318365894542435847653088122566467147879045665156237430775634474352650662558865\\\n    2677909368019223873222751692758181504663720338082803471954486464353944604762803560752915558167\\\n    0314769762054969763641402581696652569804929121627053926549255591514458408315006809825963417556\\\n    2297998121701518778439792735270930945666531277776367496849178788646338408519815426835544289487\\\n    8263289236353091943949096520962894433764935264416736497837986801910200210069177917111947982984\\\n    1905345651589137079374087226345948178203179682214301447658673985269038988480032782087014265211\\\n    6807558408912072893838717053168004005290352514566890164928625926099396014128714657510365860679\\\n    3049516769816174916251093533648705099071378549876032599310195133581869188101342419517958610073\\\n    5095810630386794730043151850701631873261857689324418045735376677857258952005682014307099751273\\\n    9318035103551059740319978456855313639140829676610023970546278741060530300305461601476759292209\\\n    7934688555798272125947277099348353522731905449317496430605558456643324020034343142065059970766\\\n    3177192412270032681402558861678839898665667265836830157028891087164776715592332936220260392874\\\n    7223974670363114250068639304069767718607813690137633373835311671663706934042798117075971704450\\\n    2254056922498402371410129659412462091336993721871322437258130186631978297049137132920347128130\\\n    3219075632880689453127369002777696859625805534454001462614571928741175512707310844408786366138\\\n    3820886557220357569675320890066798937528777017298100073432748166860104192718265591722535449141\\\n    5272849315444236320724474612851928108505524386924029533835645774538355759097660710601114706871\\\n    3712902951873790378893645240937262293139674813366581157832741273789213400044385114704448525264\\\n    8738055772462498163646133585665008175207684469540692884989677921092424095651500814766020587793\\\n    2349112376924391240341358536112184216925170750881662736172480129141220072949517654461108129933\\\n    3081191649921610872249521724031391329645461279390735171373347087473993157692829355597253575447\\\n    5957912779724606469213714879722656128881644499484802786230115917531017320484153659541312635692\\\n    4511000808296257240722746146764655594806308413323854532367786309013418172660510976048199649489\\\n    1326043070746266892724817770714544644578859455232239899752951115911545090154670796811744606613\\\n    3763032336138047212813833879469396163186456917618689181416253577367791262648066853150702283653\\\n    2527038974109242971739930423704150309868016551330621765814438157400561810487263974911767818935\\\n    0805931772597988992439611367329479164831938204297931093593042949132408738591804540449355725849\\\n    0086968932171424580797983905276728012786996140928780804143701595835408925401399973648828642630\\\n    7765940275171959109110862325322827267664755882957810066315532549008410094872406322453908817905\\\n    9826408083357138111881737375889342311309363352298275417515788826702045464354167129774243926892\\\n    4419782237572765179895338169371511116690654234242003670362848135152627518211037375630531598451\\\n    4183232182844195842775173440149397962293763901747849324335767511696778056513422183837649348759\\\n    1968924291497171486725023548335505344658926087957136683223706500058043696872263552860862678778\\\n    7412128591669404256497873967468432647645007498194795833253854000144012795709124928332760369595\\\n    1625992040494448120338984366014615116142730604520101980675728143925708602075304794388216648202\\\n    9082775001056778435935325908873268648725208873506111324839770522506744109632563331958872971571\\\n    9643707048693678725472884515621085332972896036582202867308825589051265524984552328753693214356\\\n    3413200413694584944204334869592285026059151698131832294405744172069575113365277407651876910829\\\n    1466792198612488781962525722823665755456579900843598067754919866920213207911353793205254819246\\\n    9380420455910917151461481978011491365243528730356227366800011038280965615007240176153186532844\\\n    4496411275960929132196653880506660720127744917734275452942916540342094709318500264491475449995\\\n    5288846928494720790002666235985457753543721845026067239635923823332031791291639462160389311657\\\n    4964495319999743283555902501851842599524564457351263445160556340636778416023106603001734920858\\\n    7322399663660850331539572840111142267758263337557129618308060383500126294325547289744159256944\\\n    8130396808975657309608838421716143538817984813219688571572189099647488099923987300969118543500\\\n    7409105387573244932739023153930418196983711294613768746610433677833394532138326188775771459796\\\n    0797119304719400837216984434536894710062065859978593788170186912522848142952683106753035519447\\\n    1715610245888119318504287237415686984845670504288408491212059829952055377764104209050338953438\\\n    0203341222892782003268988370351237198310049818171718801826683964889609400561394180269351460251\\\n    0848340873828986860183034889054814652964563133228545193391612419369192556097020860236592823922\\\n    5684708756336378939036161397509539394320363629209912649871102717512903538159989868155791474897\\\n    7625082615794552558601094442986740483835893656551324675736758148359511564362604083063415008554\\\n    5862980226455364400652207070055101836983881727122733494599006201620292269233238004052786275892\\\n    6134107214078491008476313623650106934644346295788600624985400216851821848753698683238763517008\\\n    1615599411876777836154144074301344144889165319097549442090449519058172992641935377560394240378\\\n    4431538522055342968158808761901115157570619885736215361387272916892574609786817140965415648280\\\n    7401184864325047186512789117247332270867605835855701933329713796947335468532419770056101664857\\\n    1996847956847392643899404307379027515911501065656796167343882804113528130763758447581604064007\\\n    8914934048025471695603672470594751356229717127563279505146819717569255232941622273072306486853\\\n    9097992688097101028813927441616466337120661353227026331099131133006930397530338781353340780145\\\n    3128960791596447270537130283758547029913446079055587833938964967902680002273983959057145390856\\\n    3794600760077120837184164638166013009655183181110848513982665114400655650116586589589314813659\\\n    5976910524189441753278943865498369449373098429536233103019632844595705171077398239396230593249\\\n    1194299611284364620453305758624240542530124670769231736617209515331028255808343570780975747584\\\n    3569012920061362738310303539525011287119776800224913027520391151508234371981047289995488227319\\\n    8988905277166088155882306937482455139159859668592634873493485176093494750007911745482250962389\\\n    2474684866436577214117763117473684542035554650047312357805516287823368601328859554706592276144\\\n    8428568630150304553005781819811217261123920599956177311291570538249184713104645421513563520525\\\n    8965495984164237930274898015072863875350287577637685389212553202650631335364016090252945313968\\\n    7505438680249411127798602373822736428296570329856462676948524035679257580614041199716228245287\\\n    8114441088227138071848393621425592863177871044308962965070506733847849841888504162748398246634\\\n    9996186871481498213603143629115690052751989962714195673346039323624044195063525748654972953587\\\n    4188175119964022991656608984641296689768745989467510921902470310811529688338182803771529009461\\\n    0440394637436607861644889157372346092107881235439076381245224768380327168069748584915174975600\\\n    2714265475888292893221069299767498662854434078353981152839796319584354540783826732560120547896\\\n    3443442023926602422747636252366220501623867019703758147652469786832827016135020581050758428703\\\n    9383174219099317267319344437458955765864189911510840578728549189985642990872005500793569324220\\\n    9248402102625929278727992324142068924112804859526207896611089149113202862024131340904274036058\\\n    1475546702274661108734049393201960576542060289926852839998496688820914419062184067412616253740\\\n    9272764094423205602107866742670470037208391553895286294743606295900940349833208980386713997988\\\n    5616233816864836701749905357263003587715773211852946052076676301903815946042359770302932193066\\\n    7139752024320406517980086247723771012182131129721116010132854174020484933670130050524155905812\\\n    3589153846204711346504726355565656558566486835656731485980165020609173397575714726358135913159\\\n    4594068476241608365582461981347446026247340156623598040817465419566102712425672104680647975073\\\n    3019975328541433924706222815263548071276475478026194737471072842941221956271358952553686004566\\\n    0274669143779846719197616368188828788200147040500763941317150182443552331308881675704573726583\\\n    9243540611761905003917374231770404310440662982006811585942863404535722529313771616693620221242\\\n    5705541955449104708253393158952823495170036828974624454237582811882205831474725497821253696952\\\n    2113163015006375795665708099872910766184504177414706233986336475204330265561614463070056748946\\\n    9743131839013085464016525650385329329096669685048784710952802102032859230775862575142729579559\\\n    9359537673908775854069398974753809317477317911696785819450984418319925976288020904542339012718\\\n    9773645497385846392000936288765340615115304833900962543742193130200362597445946457165796570536\\\n    7885571240689608807459517051571397413362547113560105417671977124449982321347327335402109155004\\\n    9859248336580630144575442292857874397129277420994747939767987659482599698667408323241232629828\\\n    8174101767385552313926994808351460727708470612457864734647914017908013487356079872609485523097\\\n    6564557604804707809163004439684265487765922169084449160594381144974697913501785687785111799948\\\n    2141681309164865911853956023703572424948319481126093174480943265338117153731668720547467217195\\\n    9210467953182363994346392831801466129099239811017531285707557163780430675848278115429900137445\\\n    0258977390647935628043077175756565675578123148809451043552038068057628214306427187155437366956\\\n    0848620872245465409660809430527314823320473402146972388454192721030230221989643641458946477011\\\n    0337258127358411426047223111903439312164899897801619636918078886621456856873791718615516128212\\\n    9752913083639411894692457936021083864324996138631005537989683066244458971347085109893205119174\\\n    8400654268683759507493547640558440467441778809637737472833798900882197906883743605150758594912\\\n    0820411816656601761727167344616407872448398781906844396319390095998571326121138053179130544513\\\n    8568295356357820616561084952487691406114661558672064870833809267822540969991295302669234641584\\\n    7373695660880172862724243345712379515794589662251174052220184550639099033970658337759409699875\\\n    5467291006935834670051807640114017387004508440112036581001344691378180891536147407018950284037\\\n    5520851423344476414692351040298545920505230581229342007668525833601787847673388526598333407921\\\n    7515160453488894360025800005416963668825706620031715300727433166222989526097472825315478352720\\\n    0543441769268231385790302185834604401449035370506949867960081133068773446210476442992811080929\\\n    5443568618513721728743495030874389446154527815512398655955472768193267149426050129483605902031\\\n    1086475263211523114229621169447475100454049538932960778904723862437069197595384043652097373683\\\n    6489812517074027618341564448424584390573542128197107485397078182072704173982464521145015630200\\\n    9654440734497730983361437860277468922614335275258742800451337562021101419299048283764162270221\\\n    5169864771383312990721826196439311937315089512373974573334816968867920075971450963080424225153\\\n    9399269465329798111108323665136896978262683227162873880601059055618168824273838706160878871820\\\n    5457949531528492157479819567667189668882020536916597069811802344883234046924676725182151187590\\\n    0433695403604545928568802516475019245965618602420983311692128125276436463792095281405118801592\\\n    8429557186931163864281975798920768576545996194948119094291715682432711024989825769585247459958\\\n    8976060437131132189188770222846364333224040587414891083007547064787539783752336760379372265153\\\n    1626194448900460852275595864239051210771385497731484561789968141250621315414194100183384489958\\\n    5066988341723694211872304165679533807197701782022110095491295778596302012625114514057703401524\\\n    3870284428166964205341601609625725570508053054480044388247222042609591051996828938078809712917\\\n    1507461825657497343850187646595526460550487631437119981709604855001115380659836475458534174117\\\n    8348177764925323700574584115407212601358022671652762936627440264152643790068973945187304461572\\\n    0872945021948112901285160553754061689974025258081265756149424002601685549124873212219853726981\\\n    4784069155270925629107691659060560867928830797553368410509591169242043463685373212819284187679\\\n    7755264073173998866321592262019509496109721925003845646944015241985437831498738469188847546561\\\n    2134908022335823593620811060042752451673745828226416383744632267477810523602160290027515826007\\\n    6440379319934874687375712978387053048257596838489925550586888012528566451465554179071078986696\\\n    0837434104643589756782090010214893675752182265286904325751217094731048850667151159826487091374\\\n    0551643785231066035415360966516002103598456451603266103384054048786162861220590835482509666629\\\n    0599608338593445841267758182305327290756164747771861445284737772776459216127680550477518569093\\\n    2831624887164220396064122881392329686307388373313370469030832889587875385422036565953138258445\\\n    1564717452241912386794679431728518720304446430131127347287631079215480162765440576838722477299\\\n    2572853712831960588629610532522056676695135445903648391184094054555972594248977907987455739057\\\n    7953297194722701251905118229493431213819997937082995231329666533551932257008451835156374264467\\\n    6787796701593898208809356026818109379736714126725294297809314611389653751315560939570864128222\\\n    7097874615205885738030467885645343659047094164383361818714276975442219997216401873108418392484\\\n    1086205821647411191641480018055535937070910612880801681882497674500925086406475046006723570179\\\n    4435375391924275976506121687284871013572652349976978861426243203503624780691759894711855357174\\\n    7918339410748919716620107150467042154281136428800121736695388018456233764108700530439871922873\\\n    0333467249079825916512614534448196562250330936916729024278045447658742321599759215860079015092\\\n    4819082104319641317916958238556128899603553146813687837561198236696207303522999143268939403925\\\n    6640819339229534151108874294084429037903681795705987611629987909365896762872864630578781775598\\\n    6793116098038777510287703912361225442954824784525628002376351824916641196252595565255310408081\\\n    5391384699889198646755989311079481233669635485312525428311527631788341671419450735776113788443\\\n    5812681300276984161668198043048775025458757144820642928348554826048413571822228074441375285921\\\n    1599705341244862178804288069741180859324829124854758858686983983253472509134623632817869937497\\\n    3845785260306522742582976905053564210866680448136144789371221963074759163671243566809200111155\\\n    9175372741900003369634121265174692774047043322404097977773377411483921562667037302282358200271\\\n    5310979034611122376231157691383412785699070333301342671262978925953265489560462332046547936172\\\n    3394305817570561355447166216759714126744999112331456173591440664574749470752995036616819597580\\\n    6310443280491095259396074400962897513593925653549843411748790567950390162721169287920143812103\\\n    3225605907794997401865941727802364217007990630107791816977190215325549710271945127389557291174\\\n    7160731689825425456112179316632185260652848084825559296998951199622137162806469605322480785289\\\n    1991440781729754181074428205616713655230925515272263691520279554484791633095088213685536859995\\\n    3866271278407987492457188019030082899463722110579113759361715552411040808983935587446419714524\\\n    1420899503103740425325231764996678871883200783062690689600987995730363055198548326650831091459\\\n    5926955244535298341573175648868566076243702093552414479831211713546091890255180853893366190442\\\n    8771741678073156733465826377647892829735321447378576336472344681787139113974157926855097626017\\\n    8168369265342246441340608879660126662887440851254740133820722852517411214896143344933901147815\\\n    3184782314562391531904671670584046100503167376056364914906676180858311443957399441426733381229\\\n    9760338705956398116441604858320689630200848768670450473294653342665456044788668851654377338902\\\n    0582698645914588325262615440012302909181657151018216817501074231648923369540202545767495135842\\\n    6504943467648683749673903122064364160489846913250877927029001077473366574603414438419054517328\\\n    6731434371624219677866668768520105393609177661606789477638712870134647044393573133039959256383\\\n    0091782773343593689948227762665763779176132596586726882085162474427452949899627695159475726197\\\n    5844937995447199150969292208632060688402117982038147863003361238817019538223672371668684785771\\\n    3005676363259826950492166769696421514684339787828330856473092045467418814353229967123478029072\\\n    9418731884642890446771617177167569072354972004979871231511514391989534914068101594824113613101\\\n    6728218188237037982827689068377646142333794257573852620682745943737723212540210823199393401688\\\n    2137781374031753485895986700328278288768572832380475656788101123488194706460944661507127459731\\\n    0927736632922765853651381827956176225795815452521286548621127894772144032809923494217537683685\\\n    8223306395357867776194308508000361157239409082526327122513775449804116861826295564204084968833\\\n    1509923208483661782181861872168197590918497812876357526162373078353396399914703586188197416185\\\n    7368128699633263173381614044578317640747450404896405108620011852638614414844275727958112767777\\\n    3434784655187278122710292703781308012362207458715780194998321355916798231152019447456620496561\\\n    9993913271582536173281191099266283590648734468455847818830887944942526648772755848913218294836\\\n    4311068570476546508425558867745355838465838796594229066698790044223433268680705660843442992156\\\n    3673036442876919838054682128558046762203811253927553135018503539836002146978373273886031955634\\\n    7020211279952441943424917143557974828225266906468885408536593715407182693743597494707049465646\\\n    2190672957139330670786689531244368849360340847522196362492754962005058358023516970975406133123\\\n    8074875231184185310853980871208639556224704289761938405484059054031899996496580226919010719417\\\n    6165210047737897817810383429066403819679144902307284721040045789270130453594983896138983767914\\\n    1587910624562335138270673610943557859511915823633940914084588728503935178217602754547222707360\\\n    9301794094254808743450199253107258027502795422715642613594615439443959955897045056353346172749\\\n    6838390788466235320888562708232690702582985744081492324790882730084291602111268445631181532460\\\n    8259652249833871994572858485139157260277080011492625873157677732338996799683449824563932139528\\\n    9853077990754168224740665365358604476665123111984486953478009743650547357030484517275172216459\\\n    7178958762418495853650087627576720199724658528987061546921254619427481698162608154384802162018\\\n    0861921017262310690772257406172064793996765024066666107375493368303969429488057255568316644059\\\n    2891146502488736208252260605772362200099144048391639439105257141123015011054696299840656710070\\\n    3580275282393146842189774767302579564193809874485428821402824611052693781795002352449321189873\\\n    0174667989463058549776416075384086899538160716409739212578707933912140415531118335559130614554\\\n    7841336191513845252720113153085685102823108379948278402071735626997055516996859179921053706883\\\n    0343629649149196684703008807716573129365639452088403052781246775262954897576519951346213875192\\\n    2806883762152596225441566914780597505383467666088773271679450465579529596482251139841554677092\\\n    1717659257492323503041343437824994241259338602253717315594523605685228818946990701685124867636\\\n    2487087957468920301551483868692914220139167883693567688480842806463865659731126074039378370817\\\n    3908041744497901706507803442096483195695150675401958339335711862341971265630338747248629153559\\\n    5275205604258201944511269521410441974696622876258395799834705294164393217011029849118274114028\\\n    0398031834915041669919284697215853576708330078418033608181228002499714820179075086457008629996\\\n    7088394053236914687728742375961201164479628956230632298315400992157535395514906473828824499918\\\n    8307469671901621087089081306941643644543985602829001570014890827665776644293646339768517026235\\\n    7222934248261601997514644267866069532137740970523498620180852237781581872472543003836073296700\\\n    0714635250285455730948689906220842926520100398449820544729940775245346076114067866508334687483\\\n    6968291509460487554493858392700824745284450681058408745300005226074480933154218335539217639023\\\n    7935353243420963756226464859017403730283462129812428990601529899737077078735643571833340436229\\\n    9159912555340246943383991733808162275957975334270675328157355356126603667493255212161874513141\\\n    2505860900684045250198784989973643798604636233400023207413535888110349547679964697425283266913\\\n    7494696271178514288678399951344073570413350207815693388621335061566255652863283909997951364568\\\n    8805878892308646263982660485836937447650222108821577661784407334662244336015265355251208660748\\\n    1236605399050733107490070774020555853606713193563486165618130491291825785988601699863229798936\\\n    5959246657923624187570576847712119723750996550172535962852647863097711984060766779629932743435\\\n    8564732129912484661478790458661225310812610366846265612370398615039300400288506899920231102836\\\n    2231015936314085799291760448749468640310294980726903887820704315353726926427650453610655199705\\\n    2903101772135571050615010133129335662260428594989023010304876030244471598095185528185085999126\\\n    2060804215703075036644298676592438967503172156167077554647557444574211443821604810458572666423\\\n    4875419216977155301757267042977596855094997076138518755121441336984982251996512845110159923352\\\n    8882598429950160242010332032388758727683968360546913239750079837480558272037602156348609277994\\\n    5005997894835860713158909220149631342725139444238292549038940438810001767895650086050372303658\\\n    2740092020552533213027000806967675670454410217858005635401534193458594667260581100448991477163\\\n    0830742617706290972271991086532358089334872423653270088268236969321215291469327824074167183661\\\n    0235411360303988578792194452279566611916905896271422883857069345247807247220098838474373016815\\\n    0813365075268186353146716799457530776336488320909791194000407307692390509270682207185846125891\\\n    9381612260613743170328903855079049890979577917090604093982909479868948545566948799161113347482\\\n    1759378722706418673722364426861143188152647357265289186128886240415771394214209887242795750923\\\n    4264438541292127182837325454452756227964859902804771154681307268060790131337122344436813426346\\\n    2437264715401680366048841745050920550912076388682822450435306575188623332055584209882026126835\\\n    5317340442335388833488658931705081063688408737283872017843349441510069462307501483634845407806\\\n    3128770801287433048795590409433259918795681420843857563697209174014717631711705062057644636201\\\n    1460479207629369636853474305443637652463000344132345052553213889784917974994159787741150286407\\\n    5149266364107985222396889432938980686057192680949666689994182250508080224508226097924509156373\\\n    0346940260981842540759604843470140859008650295594531022309110033777113779425795314381148979639\\\n    1408110147714500914840990339561162932497021109552021679745759845494563353982427427974847608780\\\n    2949160273387321307854936424093620258906126688890545728529024246483415083077991980343210637644\\\n    2850095466738551359210149969846705955081697035823266950175204391470669426297216333848715598466\\\n    5156078732086706768169753899516003426337833218335605508065497073519542608155549248539166775946\\\n    1136274104193617839292368456922540581632915618383737753356343387470214179584655309542512285980\\\n    2385206753900875281489194728360905190406625449398510391178822882423066776028145758770118545087\\\n    4995193156663759540037524089485200422091807417090941091913857932645518615366023035399844071084\\\n    1236110151798208778084472094047067117219448831499563988253226873728016503115215518964067985606\\\n    2489968349762987340853308021938828621486243220944159023525148598005437067096738758544700678040\\\n    1206853684381322747048176151201781546773807391963430727247135171203741180305903034329949715809\\\n    5688468045627565090866701733197155323506723985227536982913499733806006319144207826784689138109\\\n    4549017610770515612229315711787520954438165407142079224699679631804638339141768707419225675166\\\n    2676764448709899025728535175966058425716033956403745183984591990037783253076781883033778910405\\\n    7954869760641344245061687048308819333348147917205993944890243827091129539856229506056575890017\\\n    5525472027573249505319644015851625139510664752057537639745942230283088365701655220916708945166\\\n    4142260501046770499287152769241395480833315448526595943656673043228358328033463838191191634587\\\n    9066779651179710620774540300799220296921062092591276964396729521001979062916096356477197114611\\\n    5119055334906949515944274892678023706748158761552908629113674138202652420905352277963447780651\\\n    1617020821499692631454421867936392008748385185528657364619723592581456251930470124697644629706\\\n    3570368416956772187193423324570398316503427405211487114923013003180415655896541817564696487199\\\n    7143231978868350624317945956187191203181585691744788936979840019627212016788401872800087722792\\\n    7416510003357340218227201435962700179344433962086588990810697596619452154751678304912192199718\\\n    4071054895682578258689216721176017629487163714731249313304865173854230942704039706214240946217\\\n    6068308924763812218362705768873144343947301210651371007054877800151058398845830442654039752219\\\n    8639454662781948532896030143047071349799771539522915942159672856685013193361996504102209347849\\\n    8714571795831996418566863576615836444626999328360614650669183546269770060713366501896957650145\\\n    7906557400695970461590071475324590778930879715090290094247233342184851651821426145421763368000\\\n    5887651320168385398250187903903457299245917944288164462040283721736926279474611301339242561431\\\n    9706447070946273789598115948917434903070772471989702703165213871988939518282857091312318632642\\\n    0458021584251120128510500045411996171243573960603517923753128161730419524576492261340933709370\\\n    3603787224977223734405787474214064103000280323892006030961603985344823443194114958602184364697\\\n    2900720457091284731751690799686627238568036667515275706700420729128757479203954076923422624559\\\n    6811777421139251641295848322687921830676966101773201309864644469779659770445333911213617423245\\\n    1329309946660650777775445367802473319151137534190927781276173908440460807981605152632605746139\\\n    6303528059839233264578272268619120773528611061993924547386193626462700577359978869769229646919\\\n    7818594361857521551845158224461076960481789843667087347829547281406704197432707471550533509920\\\n    8842641579018144398308721828930201398361911729294837548035543906076573009233075745012993283251\\\n    4654145288504847987630606130392706525064921141250864728515185930448880916776804399708289148437\\\n    0282957416833526854151902016384494494690043451950677543745387826275186401306425512432797051258\\\n    6917478983475748533413010550909238341797911601513169713753527172466086239710694626956513264539\\\n    0617770443998195421537729352778045430131278126262118082725582063719459895621199526653389603483\\\n    7647856732619201857260028761390926998984857512382401155860365104956155304820447108864858907597\\\n    0570036279597879912567316122750992227265521469932001197924245019228954288681790365965278448003\\\n    4062467975088463308206913076618357347905793812872482840364082108219428543278956176593893131846\\\n    9703444660541705270623822335736899882361222792638650633525609269544974558886650784430934280031\\\n    3534203368287221997611727412253854181634676344304883014674437181115406032832848086856164105437\\\n    7354562896887312255383380438189946498074785110904569774812224649062233443228906250010923232239\\\n    8785667249847151355500523116071328126177529562553940684710319355872495885437712608568445523427\\\n    9405263880811318353564919911264469740427159490948908563072377108950703616934053868807789836589\\\n    4498696643314905658698201117653349094187999043580342516175235158699786815675902943745768214468\\\n    3963148262577835637069309559852901911248783802676346859203284433870438601222979028318445696121\\\n    4057707243410416622774737518970084102129597441433293054976167034265292223617238153567988813886\\\n    6845955906863111726474688241811203041363675054328120534440949410201401139781435755536994376216\\\n    6647275424791336950617885509653100572464438133151519707886230654813126098868643197552644843492\\\n    1650422181142389020475747280180501324731241270292505886798220859659473548395336708522083956870\\\n    8392587199995193593430395588996242849194536352458443459594125966208869438769549671230090630327\\\n    2579652547413446065010558461984807152567081864598389174540666908484330585558423301167482136362\\\n    5716588753094034378319174070094693533197677284601942378656430626235730466172092774527761444412\\\n    0542205570713666826543090621925109214781917699655135996967306264259346138067887358188720093982\\\n    6043358530042139032399808787920060489285109190973455685325562419848437310846837900047809482548\\\n    8763131612475903490966943666609246202265141770871729286113255061606039368353562058561290686172\\\n    2263236073818781989464955895283987399157393267536152289411484791197168981429046472600448802035\\\n    6392018219162846772346066288813083051205059646008179974952669737528549816476631619338149875565\\\n    9628381100979968507174242522650335543635710262439797284070788347261420304577405480120823297557\\\n    7240052764744389650783970353000652693580984874996030118183524935915129582363170173336392850384\\\n    3048711201531070498600097724540200505129621471148624693869468444082457467019508616954339844414\\\n    7646352850215929829525225501890845633406464638441310725967169319703352801923604204580170235291\\\n    1480661556828594333293344538130163216488715384022744287608497710844870895843465712424981304193\\\n    1571326123570318055451089167111068444873365365607727651773581140078674073070410486408083639304\\\n    4084802048668541208355192534877597681655014950085428195739556440512824441635737496928262704181\\\n    7164125508045206304527205187834975632916664071768411492779834102771933057504237544931922419386\\\n    6226396537134368589957869536605523408137110928137360826515110269085408368742654998706725567129\\\n    8752458892265188140988448305949649296914082849649362008295468587523726760868987088208830756527\\\n    3208299697630215966281539845867353711815911654046929997794995043184696336239764771510034979219\\\n    0403744015654180380552772186272498442174056278160763798806297033851504874169797090312602688359\\\n    4281612075089675542049866642174747063168833238553912619032699905528032865824194298733425682106\\\n    7162031417117685685818924182683082009833192836887406413280342304546381941126565247238061680421\\\n    2966255779073233324206035919886795665504574716781916827294478629603368664313415870193688409436\\\n    4543241192378358700360044828316721939380061090436466928993702520353971689090454783121644825612\\\n    6480747837626967821336740610692445545248446874254480502177717113286242242173903148331486635253\\\n    7321472162767147819300781411646029661512386400186082625914129886837621960989312062272338259059\\\n    6699397946504606520600390110847359683391117376510649593584770744907555396036484876857142584117\\\n    1929146845381168551152714540514383342588441755474526551773875419596711967041690262118793999822\\\n    0053275275473495021893445798161494940223630587305048064624806997715826796850247199448396427612\\\n    5758372912457826367493203616427342339017023029211863693121757287852271161978605685466195440185\\\n    9709546214979163480285728083909921850661086385326978303678990536568739814452892933934383298827\\\n    7462320113656505872875290136338048331390545108282535710008632740258231519893920265143706863036\\\n    0915681793177816973875133907874421097187623276138764068308098857204318499486624186288666713672\\\n    8657607658105060100767396025376129427212975931291103396742388072305928957100440899386094993401\\\n    0172118922893154159019505447577836645672207197974238694676430590461254457639549342433383936300\\\n    5230140673200676190006502791289140842501130941665985194064472133920313457213184683675985215707\\\n    8178332879091633297251218102267028272762458996736372155645426287856491581128798085690753185722\\\n    8819461022513312439276636990663968566760874892779742024704824186224652653227798139167350359978\\\n    3776835510767792223971285652312492529727185456010476919715436640656437306249577101705598104526\\\n    2367391011050539186589639643420902460761660191455197568534660681491251591127466022671664364285\\\n    0031277290863352310382713262687074503368331707619803939655303016697423201502526036458266546523\\\n    9443712839635845656289965574595193539941630579506030294614036423467137191391080276839171591800\\\n    3365334221269362898182486307479363759103014955796042838475893418342932928172488169538495650874\\\n    8451119515055010068882444735748527936102469422039491452920517291863098367813290878109743387610\\\n    2239769190302034512421279414149210463775868856488307713851338225589845956106061936360812090834\\\n    9302463582326237851398655479428616296074036909855576087423935789142921001679779595314712802636\\\n    4457837966932523210423355427529078344155810587571132797384915114216494828657711469385579516375\\\n    0681064194630025907314443260026343019508226393624245809862964796939796412092055390694185299836\\\n    1246683073775379013178929417746622858394032354728755235103858179478049838234465793985681098790\\\n    8565420314472284332736446263653274383754447714704673905623324911155361608879212773323988235443\\\n    4357492050813813221928134154304958681702582864091639791128384434835442708687656458679024540259\\\n    5397201315540287077953003238285553890509437401398084159646236844442683398895525772173307732267\\\n    7546340248648359723806353534298096557931158599451965538010739857005928641680696482697199087370\\\n    3392631552319583128325156740649267539927680045866892852269207117912303629044714693562966356476\\\n    4444794093574313735789425709269709611390135695525910246809642695912077476462619977490745184519\\\n    4416717289648069683880879154694285664048419196992810742955147189784626978712406657249402349285\\\n    9475439190042297808026801560848584247213779537903318308694817453571852125231814337202133244306\\\n    8239863438264682225431172744159668817737214245832240062535183495532495799044552216522865678439\\\n    9805064646645058867553959834606926934245056123625863009358306989384258799288859767356512268912\\\n    5412466876731110657958018469879369679258967027302159976040345977871422633053149936708496927953\\\n    1650504220733750958822679293854095921783264546990627980792677179789521536594914725660743349053\\\n    1640405060275029589094983718681387588690043411061153188136471505323426656203879616840653388825\\\n    2174767279860302575159124292245450592580528306546281468255340072889377297335418361307928738312\\\n    5116416688468545249725275889782137641190487654297850286178363891281692235672088061594868771220\\\n    8783578482648127967793170837736491013115071384617274241015741465940340977001433264627989674937\\\n    5783835195478382771436899023785197280564413610127153561045341239578312355530996173562936213120\\\n    5270710612837665819689854291845585275818036895253543250532730913206102122686557742505952773315\\\n    3758186144193051328927625257013458646865549881847686927225085454236176587115220587668223756628\\\n    0997330559478113574001138536619456443868693227524991735966016234344807897752974036553882397383\\\n    7242846607342205718441040816407439059109180093467576067492950329711954444308180038695059034606\\\n    4241076556453150665278258617668193671864771990706841760131615368065035596150678182606829380070\\\n    3536085874701492153986749848012120151395128219770950032831769486242503599257238290334736899214\\\n    7508057321781629281767179793996148349953541244983405503794096526599217876423775232013745303133\\\n    6834932329130998014319558240969748963383422282723519809263136535716974326323457359790512798850\\\n    2027014471843934755794005222460611639489305869816598730220686660770140540527684643111820197150\\\n    6661543902510729913638864312914680785199561993409247806578728874173298205657899543618184224669\\\n    6845069411251449865858861433211754936364709301581341267296266166929902299342092815110141973411\\\n    2705387997552268316819447638454293761747842336232139604741161509418947341494403592300552011325\\\n    4930896816223680338825492128815879289446754737459608466660502628204137423563167259984206729783\\\n    4278231521216909549389258841110497099148285832188379221578547035526115735037440156455647167029\\\n    0944288544515132654227824880871284285526520167093334672255927227305874359698758839510067588741\\\n    7849161031973375016250415996676942453079464505311891447048646067021055945240959788114244289074\\\n    0662737541317122611232825129521204876250081705138443475405320140815166510573858831270600123828\\\n    5782096648144460632478100894857950584736745074204257845468731938147041441879604544240533917494\\\n    6482044105726490436478444724138026053243627329475358689349604576281747622697797664240599749457\\\n    4985479806896434598737138343418694456867738778707544600239115202222442232266714266605716027041\\\n    4312919034622906691537630634463629226812312028657528881293738304482936674197162208806766782393\\\n    3182096434273728676440737420884304641574951689906235400947064067961038427211468189175675853457\\\n    0927292681757591366333460810367251660789380039656239093625118417229499369610253316834959559554\\\n    2001580177160086140035249529488397954102898296163203111175962316492349617439617586185490274781\\\n    8993697442044226706594992191817944740956192360688443368064949958341417598556729981461994234703\\\n    9653705357126480014628313789586065831676349105600712388622824372251709825766225226618821292870\\\n    3677811366015686963312763643841371352013360619145730252353792352888607389418466348377497836065\\\n    1769317896986107659567030646684281495862108520947899471804817962434718117526976161535314851306\\\n    4012837322202371049452114413896491451367903347716207539398952325305298106302455553904235810518\\\n    4822485068798985116756456430886691611084909619759325703317853065653799352976888990519537944735\\\n    4556612023484118485973558631842732851176240586497317122380807963363266890442806268112582849909\\\n    3929495567240165140701873913259388976375700199824054161342914572634326836452715591897738606850\\\n    6749388018653815105878394235515641830468009726314310110950211166019860530559982491886399271080\\\n    4495791440234151892621553283821667996176846485773863033002983761280301527355461230627575374485\\\n    6892208789884383255313938805259395789781029921776329908694334472645569346905957473595435817217\\\n    4619200881532883821967323087365427270832263828801286164414777331659341610665015367082250245118\\\n    0936510575065555539970740986174765419687186330966468584556854576928771808378014400047319926618\\\n    2869022769331908848256827314648422592940193422921951909804490114354095979889458514199961589443\\\n    4819986201011353013474346367479374543783966937494613931937022352382817726588584138067979395942\\\n    8664176720952446824239111342540614686402919290218965485584285508519934857848315230335870733913\\\n    7796825564172800258077351722195127953116169705206474102369765119286459345685472113085328632150\\\n    2308083794332816277142497809043153789807863300403579322548846906616478125388804400614021648240\\\n    5339060296512346284676346614351462319189866500657147209281869347850040739281523346281940912819\\\n    3183266837209543514409451353244384507936627026641657418756299334200038480099317571897963391873\\\n    7349763873180835449188580663425799777067440386818771570801627408368413395120931720927269070355\\\n    1265973593942989829608775473316314473657487627518618495450040625735895654586927890051090388908\\\n    3442606801181978922573302779716750219808136434360794084161742733179960425992112202170608994998\\\n    5499945218370637930815885922857434957907344801691488376578506302318493820367601219909007189467\\\n    6482287552923533756196184834247771452327159140976750455138161205641281273035122293439098342719\\\n    8401381687843208743528332925003640135841178932405637729113106590108181839108742745299167581297\\\n    0228790694748243088371942016862668678624947313278717694729372975248062669745482314530230618350\\\n    1998726649243861071618166260537382156826130817978097464081654255659465832781859903645690259238\\\n    0589697001852487384972877584894654264682711978755091002238027487234529809369300148684623692097\\\n    4616355148882835871742022020650763065858876494664744476458552893397232994137640883494332987794\\\n    2458063467092618338986615853252854503259210385942069079635158173147222193736043898324264945828\\\n    0022903642415618604858696605011498048751938406084757972897258021736327249385988536572723564203\\\n    8812618216994282263733168134390207563161436966177022240178426674531931191264659929894537358116\\\n    8992744591687726520293587072774514289612081383230370214601965095009785270043744485027842369615\\\n    5139919214099487178629435495038064453210659316747759528378101803248512784403180255171038560655\\\n    8589147670973642033557649065406185686024318200967729390839887206857705313210578580221239223555\\\n    7830642099520914961879125604715461514004003760946015401349321370564338366626085439181300063911\\\n    7624174193097038058513244817734894773398580497757998867046051153375370947146940615225166890721\\\n    3848128937708813446032643618004647111621491505585754249275063019717420645670394597351248760686\\\n    4535230428150231401476264146304976902799459164909241706234381814543793786242643542236330716390\\\n    6355554137647124844851084376716594552972505102420684882639643312339764661117407532656832944270\\\n    1927235935899885068193562990482503770411295023080067535296282158107338042826611940755629750380\\\n    8738984607700355321876051378734247205077644158672207222451947331807174544397714176627383298171\\\n    2439826962846029245202353249772767349894364535729955298557023487280934279170743732549211286112\\\n    2184944072342029379943358633842792492916333307256276645231478943843629164584012503884649648210\\\n    5774969954394648343122607865851091856650328903836724788904019289444556380449296134923094156496\\\n    6347744253159463282790924334944780061796618530568048857291150287504162846201138053264082419058\\\n    6802583847719888625695551338514475374727553530298460222055336152332041440214898187551530260870\\\n    4315254565846948101651228055668161405213523839486213739894943996491862859403515136678456899223\\\n    3084234988499142278373657348845093212482825747358228417174487041913398899730790357574177972767\\\n    3881298760839547545444721560451439556049471220069056178003175691472216350833159455749463056297\\\n    6675160935031799668103798639903907097973955902884660374373362832568140570670601646495115667151\\\n    6832263475351084506893859883448948545432205105390502690536025500844080185333631680830679461944\\\n    4618503977014552864292743959473404399531148799989365661488289807142539489917579174736696153846\\\n    9181943648332923945080968853612591296322063812709019439229344097884978536835863430410586003593\\\n    2379990481814206980619269766470108951221074797453906295295021084829532969691951010112801074684\\\n    9583057790193216869303139588502956464233819716721092147789971088343390016010725482577635773552\\\n    1188909441142246684925327691704831065473477230585549295406701878367637700521961828729396631170\\\n    6460688526532546331103054430202822038693566986284689429228899905882559168841102275133199543687\\\n    2053605174378462608885906322023263010290507679749258792870766512037671907041225856962592013570\\\n    8952035453777290223574353149643961855268282081333601372912107660697915140422030274919735756299\\\n    7650895211498921340067083505841049480410014209430442073787786172008591579923085401927726035420\\\n    0053792649232145506169661930630665311009667451337214669820146029802088702100815257223173848983\\\n    3238355901699526629595757204515168081520879539599859086023297592954356347363227504041651442607\\\n    0603413507307859708765895608866788930952217461237349392445455822366956370243503591435401233420\\\n    3277279612265463602177042536929857621507806518126998962997463200417119499813554459051440698928\\\n    8367713388501672580128236027371588207572181351426162099925338482165494112751767849593998067570\\\n    2963950636771749056116373224883423439845577974718863211798907699773824480952451859420226865101\\\n    6007405198524860289138263838432769562007077503720562180734782237478181185434350663118208000977\\\n    3289592956491322813615378432581210758872875330892267111899824978515658074028053314475245735186\\\n    1584622431304409672688513219619643608202214843501772750790063097082626406613519901518245177509\\\n    0869550012143884950867636870544583505176156232136540245437593715134032953478386935379901781387\\\n    3354968562320736493645944999826097994927635507802075133660350318950673463159917522820701109200\\\n    1127524913329367614301749975562320375732700991078232324977109299547504958035037438434776778247\\\n    3210508708514302397442469745135106901357128158980520433394324457919737128733442742501449504663\\\n    8285420181840296415414070270038785308057994799258440414300040587871201548239069392857897308829\\\n    2984846526884370365707774625104797899165505471835581925169193783256557139623159878785218983284\\\n    1085277912230331943436792865323625998890273409562863288898918187261158929237647802856002109809\\\n    8820819269614789710302381237943283669356143860440041822539878384862965942336639009999722281593\\\n    3734872589916731401778115562801908222260612893624292986681702693916110261119335280431592321857\\\n    0290712387987123315116125687522790197169511675662822942124844257610803781259853683727900418075\\\n    8595828808571212782834868733985729059852780551716799763105839272078253598253328908181659866328\\\n    7725674488294940477016190035842635347682350585881540296907521204275320134225823414579248271684\\\n    1899421295168422504610291444775075513203843696486344885869823447095041851371417310474239666257\\\n    6748659656865290774631608631634176771941585012867213786355628082818504969154442425017628356275\\\n    4297180233732479530930495584418398434310557590112226280854946759040553804786547525832783663338\\\n    8696953200899283513317637303036894771826681578285140771600331637927868428670849172564584801149\\\n    7447544513082387815063477384950385771769110722583399648308173039047462851617341742358785775612\\\n    4264561398922239552710512500743234608248005219492234838112142251553382222093534744742209879268\\\n    0486218578584141544089714008274636491169074940769658929452014350715291885357354007797485741311\\\n    7694661896923660395079535345627781999700883048981615694799025869385561878529014918998154167824\\\n    4252659670737678065853150675227839756126023663757206748185672375503445969490373653435941801959\\\n    9114799790725513162007161783117741683257336807796128804537998244670555168768185706234299466333\\\n    0436178972736426560899906365129027556925578791895808382103976205681462202233540371422889124701\\\n    8673473170645047577083470030327342320166552358244738399605920252973319133373321627861647342788\\\n    1828164146731869352101048384564378313020008537043659926093638230223137169001649143101938773626\\\n    0297030360106054371380245771138730192818598792887452383445972408621597777138746044553370696749\\\n    5090008075907423069466677126890205711837083466568265648316978162202307770747988938427645380339\\\n    9274073120374254043081888683267263473960457409094507542932548175149187137614682101808808186056\\\n    6664313292272161699824886541920324535458102020799389815520361065591952556905900559156570514250\\\n    0824732207832037488191144664385696635280022900504873690900823654520404940213520767935166272470\\\n    3435306127144428684759236827444883313821358318893604263495846103936764054262067265927179874799\\\n    9935211143600546458146129177554060240085750978975628565402446109116545443431134117398046050933\\\n    1110886787440942374540629275191275876012285485053657051460744604658745899786690232076412054730\\\n    3326857852609758517900424132864830340222701955568493568774814677137518446876115772848882870554\\\n    7355299840713302940726815270357990093125609320632807187415301258516094906310203138505384633880\\\n    9448850687962492207878572114633544972868450962302863327417767730485138216037748414941480572912\\\n    8773412348726694161396493720085126991184268449278098832195453692703647395396608321679373925184\\\n    7771783224658707055380784647264575659013215243453128537676357148369752755596911872277311523065\\\n    0001534457425673034498376982960044065530908294538911993251883187833908128826775989749717488096\\\n    5069107171132494218377874748406488313408596384899438396031703236448792341399532724587582416357\\\n    7848967188355668550217810158603858799229991274759504522448770321766278958207156687167075148450\\\n    3465170948442162842394927938244974200933441489917369856100830873219184010837985019527294175006\\\n    9816213896558314006179264599828055745810023335062592230594843253705765931618938389642079355967\\\n    7635810411758034691734206170756661658052123263095993854293741329723547950509925112565517258742\\\n    3963962601240380030774621966973689924926088994283671522490934286287825060120270056278405007570\\\n    8397720873627695253506402965650427602232604112766742909347432864543550836127087418374090389763\\\n    5155234097233262948789686067889473751604639975005552001399467082344745203835531016676231066849\\\n    4178966810701985336321938077884273933800838072495292639763840958758382428806777117374099547094\\\n    4966844987497420942011011260569045461623381936335182286594024984590248910365393791651817599783\\\n    6682622992965392459998403025355682958612135697136175689719902350996212770408265310740914709430\\\n    4304379627348286882701300770751160771432142663603220982426018672743881162013196239466831918890\\\n    6523376186399083486775210080863796539506895391706673306171129549252407307927832410347089961499\\\n    8267843920617256336755622684163648140136772629638766170040378964782441133025583294795973419314\\\n    1714650237608592329552690817297219143742902936013832211982493766853783689220556280897065350180\\\n    0309233367408272711953489450359014892597980094595803500013313531819287600024644385190523369768\\\n    5300585939412027487288405531136372064232776560247582738047339550055934614411696429323697486407\\\n    7613354836939073988454532126976973580014522005596806970851083416068140432224344058511186947505\\\n    6333654087146398141490081804092248287272795776481261627693782545731455860527628570895358883969\\\n    8565242615180290318946930597372024410631716829187783882466192073384240814951338597503394124482\\\n    0132627829532738553030867976276458480155410794558673542874384313461282149267393225748250993585\\\n    5406800575477276593679744788760040322141275505892777190412168700759828478407793271141752078526\\\n    3272811043181747946118896217444183062668724165446579745796467023914133653984734322500046977714\\\n    9612511190087307491216348942612406319299290597945098840635844875606403551205848793461483763314\\\n    6345333794128258759767927772600361469797172657978433385767405445241773248089723642629587873719\\\n    7287858774950954539154452094532199892295112620342083044257842557383766893232928535327965754304\\\n    6262290379667800215441513695740941667040786787960240197212209085682148222841225560887878528612\\\n    6243470141333032965506802494267706059974771388529404628760747529857043783357586424268777770892\\\n    1399974790301383430256087128302327623551368606280325371645739801811025795635454977813722525075\\\n    9866454595410568755070264058298737562676308511497196737098914048474192684286142508802528944071\\\n    8838998854905532557310271613462432441616535256333183414929490830951504541522346342883672118459\\\n    6432414444227465457660796043734417420300474581590395312480645884905604245144194189591350825682\\\n    2550537899556395066392011692512581967624866401914232791387172528094060272330495685502201618130\\\n    4324768058859464333505856293735434817145404533140890362313331331112481849800281764922887365758\\\n    7006996299230292108845250818556597279223827822452465842395107551022735372914476414151560056203\\\n    5382279270604415872236381320573598483983135358233400478770455862819646197713922579154410370176\\\n    8954560797331731706335806582298356494060409153896368964057662732175792072839680569527464703523\\\n    5800985675577709014226786250414158981311041670127978242491518911534033724691693331794917500434\\\n    6439510145357177900436922944694508438728474507758662285495545303747513821846438650007849600725\\\n    3014224504052554129396597503694725981420707741380254520912024424520194011214704701755425140994\\\n    5425468393049763158595186350762386235003032362296276097286213432941086824614439945453371730425\\\n    4667316359197649458293130435243783345101311852913573587080180155959200400793659299670350338024\\\n    7449190171757029017454850933713102234584873778311731072595931063333314807957944187554610453573\\\n    2500322269380255012584927946029902158310722053493579906253893002032892444441957327168615704286\\\n    0361706539014018738307089174339581219337238577257568969101337048535094433369299360711493976840\\\n    8917578727986359309410265319752017404966965782415129541080927158369519119857644587532589059199\\\n    5941746873303199682992577095086550179275428456188931506265862930915819773765698906196330980277\\\n    8215152791289826886715453155568474283707736570231342598435320952155568263714259223241415761717\\\n    4805540776476790095922220167155671682684021074084091916925817033528706918060630049582042742341\\\n    6035397299982541824623986825312731012335368268897074323767137624299252802093096972111604054637\\\n    9836999596769672165132011035721480166353157920788690637909291685679399654012108067306923375419\\\n    2514212799402375557514795599816590623698049504967766252500532378419048872125832632974967162539\\\n    1971787539212837903878341463835147040523951078175640485780191923720381749589601768043145689275\\\n    1019224216754522676965014760000392053844484025392508677129267406835664731730735493195698285258\\\n    2193652660349684643220636782184354874494384447988292905092863893674222733632807901379147703397\\\n    7092582737285965881273968031660902986529159876511925650698982151083485995324938138393509984556\\\n    7727663408035818783698692978341732861131790255572160283426264153194964544031281026236929766046\\\n    7327994413265339663520722631912720971521412513771178658149142668073931850113042631308257123766\\\n    5571326953024404671150065168275062294366654064474814682893382362737416344831334282660627704520\\\n    6637338765421463050634446742152959650730018785216998279998122792176288689452857874429341706174\\\n    9624311750500095195618437683226858578056656426428678104781262276197683971494203941671460414960\\\n    4386430986294218264713326367988566216275848217920620618928489537264881049971795438586682780142\\\n    8951472557084684248577530185231681294495362162116636697300949174778779486228636738473189587363\\\n    9057752305674820396262222481461615615381394350441679071220871876118521935434776332522695889827\\\n    6923948526050938988097881193964678626998776111526824326020464725773642058830244009152030957426\\\n    8565397725706894290921217222562226912075473200756989472719162752619424834513240285504494154515\\\n    7361798591362753898672050744453055950366799236171422393206883142426877199421328334005839002465\\\n    4540548610726111418326496886180986517177174414546957455115862884605845846561928351181633221472\\\n    1017288121223473065502758417748381599665964381474021999133613730573238922389328248285224367877\\\n    3728287882436748234974136645366629436219923741552705630199045502682571446888615132174172560115\\\n    5629656263370521596138534074776760073645439145852217232910987012017174737934427786542987959536\\\n    2998020206017851218518902378794106445966196306104545963946465278516728113118634485523106297108\\\n    7458712945507904745123279855348424934945570313613434777704077155750040244207208186530285780801\\\n    7401387331356859849168737275378111404251112831031051490548080002540217520341057711845877937023\\\n    4329293393703034080478403362372851842718229636085489159872542566992878733732254288989757171234\\\n    3933213969649439669651410572272155483170428099330186452320779936447659190224259724568155913117\\\n    2238324130552440925803367426409350482027678527487537439915938199524725774338803589231087895202\\\n    5197448480941476049689882972882608136813670594667069957721931405511025976383413857847803684545\\\n    7757006406113122152925541969612467875631266625195847615116012728621390340290690922028862343549\\\n    0774413541090121222302756619685280381476529044513341231511837383202844442145521823996447333322\\\n    2717340506680630287304520693776704610519029037684277675066747023523919480101410286784504406932\\\n    2094847977137112908517247167990079235861634812648246636873469192561096645046898511208738440188\\\n    5022162353961486456287375966370654572711680249014734197357953821208669721320675413716878570151\\\n    0416311998037733643949276381549828231696400237419480090431811236301866464247582207336688931578\\\n    7390443080588498737002890690849150916131588975337666677125472180196104189848821730266505730713\\\n    2812291673530747779512460602023709789018350663979886198909519598888287925501203019591588708370\\\n    7038297131294613627069106254861360044104858941369358134042553806165429287345669310313973958967\\\n    2614011238972300933757917524313259543229403433363712339691482926760335004908157911071136150965\\\n    2813242428604545128345544919510797247389553351334329077190976290464374728552601557824361787477\\\n    5624337361917431750603351055192378242752766260301550882925657972637077611441336947339639679768\\\n    7838989015657914561572100509976500076774581316933075764147603985920088990306752245289613187078\\\n    4770541932496556812895348284383279615641072119348874841614889358987305812004523751711746901574\\\n    5971067234624913698215448342706509796959933839389921656924742026450695631842853985660341190904\\\n    2430763745274601666570217268399470483495270884776765578863659977965901841519566269960334342185\\\n    9964454841174960668551445346658442100799565267775551706968317624971362841413975500697004393714\\\n    0299205642744777890857376493226184426730128009612322730486503158543546831717473566038423452498\\\n    4701070256371558514038958570742242712388567736633119635041223453967913706240998259485101729971\\\n    5956750080209671387124059287426856437372581938884962187053425416379007434281381748119046980227\\\n    4689036634689559272334851247380493848057147836340637802928920432814237745629476804949992147497\\\n    5006071940701522532646453343139956704144866093686882326476230265292761939988770623477209719045\\\n    7609750822223371473245750648864391801100916716393761104111233903186926231264043656430198307260\\\n    9247377680938538860030857577557524779451074654550253600758708464870782745587387980325743453177\\\n    9394334645572484230441818505021451413925969201468439712974363718460096764129326986540430134953\\\n    4048323002759942792501173988356987632971604294798126420811392664184511152223991859652146521094\\\n    8866484100018027518378140825902282563908638116163923517061670288304512456771912392242493011227\\\n    5753670078285552973753371852886545733945509090408203020919887184118750837215638359041121686981\\\n    6922411885363417883074313305681709038502052054714021813394159371569612877967951615393230501822\\\n    1487192690559344785654619044241011605447953972631104508785255093885582492797439764575743252265\\\n    0685058236219291445296987441965471943577896868064258265331685335211458220186401512509641018325\\\n    6297397208638721060717925320821516867164517008528790847343997405837892455292198711442590240205\\\n    4750828349111355929980790371416115356359213925836215767427569732092503828782389082263287400894\\\n    8202106753385799801601345421372029029912944209799953723518165366244689251272088864980691551043\\\n    1282537608559584169091934031945225459730181443388245949643167732371734972691776490088942027480\\\n    4761110793765713650034742443965130472996423807214266476741863844519608875956418936391435818989\\\n    6667785654468053372105690715781711583223071403447626683873107812292872522078799830595746938142\\\n    2410074390662166191293554067590858719599065903424310077444082204030280751571503470972870647738\\\n    9508905420202020685932243842739238993611416218473230699489226972793644092929995086328227243639\\\n    4177926324182602747549933919107794904709090397548645491885561819574397020346736844141368741060\\\n    3620599429676221718154339159557916667816963696925184715834285743610450163429708692665240433142\\\n    4091241188234206889121852453395544650166254260467116507445796146719311359947391670882621640011\\\n    3872625168159191300462593386657835602658640654987927281696322844373247198006639718475859845306\\\n    8974716332062160353461131928991112527126545041248307146358070975012644478883350029185623059030\\\n    3037938854403818440504425262624166185104889395108291723248660606825688524475362640389377422634\\\n    0536542661648078612707009667917452976322224343355307515119661747582500056950642540917445793848\\\n    6198220768016693046008513158001083887401745828460074188755847303228234931925270730845734267720\\\n    1634677951442131178900190898840305399181148203546149895075534695112424952943575029181870071414\\\n    7757482545587149559030827819669042374843798356626682685507169587366750545103959568921960285446\\\n    8234361641446983033585011003129003862826570027001344589597831924208031916267200782361306448577\\\n    0671093290716350855489594986407478807995690380899821250060351486795950439305349714231846247785\\\n    4680686304059206934823947410544376530737955474064817198229697480090687927627935879296711704851\\\n    0714401487387149039237565545857899069128688452014969866220310415574082134784190002261841485117\\\n    1570458036118069126652412170804991982706448010367011631234721391125962506029175198170540380635\\\n    5617429997311371897155803830142690471404025827644379615980927867039759291471666540940751931046\\\n    1068601004643262413251685112801778470264566934692125984768227169208067281533221887490099815723\\\n    3349900345921046952701993500387010341783025599267355759873774968538865808756174814194279642435\\\n    2848127761435920259970032995023586557030036967114335721304720006901161855383858403070036143520\\\n    6778457561755006738144920405490447321976464642126058908860507413380924560149776947513731742399\\\n    0583100825124756827316222486481284814846419950230232793280169715000044259857420114181927967793\\\n    3784212648906433381897710037288223667381392995843697127103175381753959960341379833561510390881\\\n    6516608313634826406769936161579304642907906393235991920570734162195879314313057045318414882073\\\n    4598203831472377365250038258254125470390815967865892513872203404341834535910584901765203710725\\\n    5767903922626742254107940543071050571926958721665826685836228028847391844713176067495925005072\\\n    0865493520762831575092438164662834778637822119964605451465400258784506305822931668928942857006\\\n    6056622814610264819134880089613443144841465586371666254477525013805625517618171035099504650488\\\n    0798858393135247083932106901491861488054462462711206742497584272960431873333370400837343335654\\\n    6298906230093713677056931643378360744692005457879670465754151372398448302446899167771501482922\\\n    5947424804693455356906256910727779709371467731089934434675310256823667296958089715417582677084\\\n    3802443111967580290619677749436310590986425520154012115610672184078318368543994464234971556011\\\n    2776805905994971867599070917245827940477031128173835852349952623896719736371500068348015628551\\\n    2816367531003873655657911293286546227290159935106756036466429974982626624386541363143289096663\\\n    2473041078561018967504910946692355540373851182175729820748965783530057132646605462573574343365\\\n    7820476333571611995250490448366852095973774761725149392991633452288536153673180493184207041920\\\n    5684823639367870205257487968722226218386683121037797992852587119836797354714614434502989886987\\\n    8328587471879012607061664595037071373920629700654095382771638882332235623998070579840017394933\\\n    3302754144181168763451825534845155985629758273045249155952637151477698449469871713875702064494\\\n    3358220518036012956155659405342030147310500408605018148733301694308834896171845620343539545090\\\n    9510389645087669979600630116309091873349308515862484919298619377559251357952217845375289110907\\\n    3150621355894983007928039093722169814863013003985207616958109147812059585369008475567203846672\\\n    5765457591000019855019076571917031036481287889205052158563228620160815221788823857331943790821\\\n    1626849730852184229106677858250041111416325429221838299588662054284921802283719578862972242021\\\n    6465027038083729370909030676821586456491009293890292487917870311116081681242424389403984287281\\\n    5543754137561282260104363699172820968101928132010742220773980373020970513532981208949653088659\\\n    4281714255898676670802158176407090254865106896667899578268786684904079671903838694168824007568\\\n    3495139115015740768683807298854336485830294406104911019190425284415927205366403557843838738815\\\n    3093808533473947245169722487335156507550335987799888590877933802492591577055436689907835630832\\\n    8853720980493587370856245961265981861366815854043363134253851075884307794939285813675038381555\\\n    6563329309940916345681640131618240060351799256866386877093455570842534096775771418654412459095\\\n    8932127624640696184252265996593484576723629424663301655143237921741898349478451005715860873593\\\n    0083405349658338964310005930235586887755992757349853886062396349266188768240817984070970192300\\\n    6345761810342896273446485614210071596681922180330197409883920691128202963115131170094577032203\\\n    7670424969461013115817321684190795429095428031382343653809466305376294158852513017669893644365\\\n    7457582507943049593803698834015817148703954383156194716127643667709552029257791127600091162716\\\n    6974894377333206897117610902461675934221042427511855389547868775525417823132903472202696535094\\\n    1960034653557223902531593974456484096131606255227178183649130772354542594915743521185424513068\\\n    1117964440438415108799896008602528254763349363024226526717873829479183522468374729622930557679\\\n    0618448906240410602284010016449910621073298005190209433376158480996452577192561829052651790228\\\n    3344199545934159318068800565281337942518844701336667467095923437890837095516540883912348787292\\\n    5181806919244573119293395647606478023822480462883293343424378236775503411243532356801083716701\\\n    9163560349586434578324677014509040063533622226505618764688545157809334831263833293011051389886\\\n    6173555941058995880115689544055620984976414284177349402570738748456936449864885839099839344016\\\n    0431362917356307321146769168923963721969875604902195846466743642032634045549468417014378918775\\\n    0409676143289096550800592827100657179402450104926459004146375270240398052086350525685256499338\\\n    2084445153122677574924012071323927844361475132651777698947881139676113753332471879790801120673\\\n    7725170958675426386363113344862879250504758898055624282160431396083573243854240948798378906981\\\n    7245763482711214507956196598696954185195012130728809691280679603324910465338807982505262866665\\\n    9348532085733064987070256464969133669759225831903013056604259662775454374659757844005790726522\\\n    5362785094628214339863770468331137151656789276627297099304724482986449054560801059731502384948\\\n    3225142117551415046295059975761679237463587236563525206794741008179752716322110312942323908934\\\n    3241289616348987955727371830932992618490193217925774685170056713091129301302686920086810049063\\\n    1009475536123873724930197814417533128160921227335292046957021861595185381042376357148761043448\\\n    2534882097632989591558347056994931925124992820015452743206556326803835776443011730361297839430\\\n    1598402708269106720293037774840480352579690727360688323660865751452529512886068649860590077724\\\n    7871601032308264743999387334443069768121711835050101691811502501685690812269342130342901817402\\\n    9145413509472523011878421163019399774255066946828341379880888600108932409667860463306760447758\\\n    4376898718116016238859053093413527727127431088068990389181602566280323664837647118910904198533\\\n    9226647422302378334161861687512335215292323378453104875931640118351087985392275595255861373795\\\n    3042941157669250869739238242970747198468802022574792590942171850235055670192543611658434214259\\\n    5857840595174032044074987595735032418348455460992550670265909979987931701529941217266865624589\\\n    9099979787391845272664217080407423983660223440572935103265974055638724167907868915178602238713\\\n    5228048426514897715552876808787576788505417999182101848109964434537685353904258481370767749686\\\n    0282116234625898714100238661409207524342524074420448176837520439456813829717936260743001081963\\\n    7011367475360867661776624232338476373524709042896254916454853779317158095003507128489381684067\\\n    8138041085065864258317577101303606163387117307065285481742523132719373925617916915275674955155\\\n    5618398245994809263498675339784819221923269698792436391830403943266581104357552060576264716638\\\n    9657295670974311091096977427669992742366706581742498032326294772515891127635533380327280126014\\\n    1505257235695224387521573376086082190533984264023573439151895636543327853736965616828229310611\\\n    9415963944703859988138816607928554400937115710924317815842137353744906940491059395996672751639\\\n    7305370292967375049951383264389984805877039930573710522816520727162905947214519233069178693654\\\n    8779744973829930916920169809762341025775722452415873135051830976500249368823752503547808937376\\\n    0981543727656826202384077886044334045591239090942592945863325257141058410047622661559291698674\\\n    5838045384533367965490288093969295428854108339503775621812774443991501197635194252151227221496\\\n    7094276760446337697076704330675882657168614805149601599707050007354923099977262126507161919116\\\n    9296069380889552602450866314846574980253964136630466881499040257315846450278525362075042604533\\\n    2563556736235436229804666436806437708332773734801199481841125750683571760836746666347150467400\\\n    7690968303553649391838129239723417629841853931057096069276543160661176571630527424150826347416\\\n    6330813959035929160735818712827395523017274988686526624143407908399976259651315413021661986132\\\n    4080920836974545340294607826573077069955789419321874196753654160503478939478415631247270928990\\\n    1930955309875722026330266301240824215801037656593634356220191752654912913784004922784659335730\\\n    8098589695300001294972891192787278836220683746648874296524093784527274797913335975106746924612\\\n    5581014457347788921717809386508575770585262583796189204622460689424791015791931048154147942181\\\n    7254135931480379058503140567980702135651246039625829930932109059545732340204467009920936717137\\\n    0856580314205707836434269723516845442505512470984127525170453242509584788305483992624510638385\\\n    2324671550816104972698819690026993607151493182521925570033372578429051161652093245241043352349\\\n    4438924640337057537996423994238947595466233888082361402606252725114425579493347366417695765709\\\n    3679388792001520631135921866097131245953833735747297699658415694766133204557803745245689620007\\\n    7549234572053971847381859396940968147019766310672266414136812008344805626016585382812172227048\\\n    2727323567701950931599250941725255656055807160121924367389596883846457994640369504511762039129\\\n    2809960809016867360865114253806047439369090769700711704587601174966676439465754672144636776021\\\n    4471445650642387062145422350035524441678650324405992036938519939660530439728104994205046016225\\\n    5755994263962679363422424931371791779673150632389160973309382035946882782943460452514579686099\\\n    8269457377583509793196174546759424134243666986067530864303830999374005657444331150428572703182\\\n    8931398638810116062717825960591914067678378941851811009247566382996988386437167167376692396970\\\n    7208067156293573051241566397457924799236022826351670176223097711214159187597163361424795814096\\\n    2233098239393794616655832437032190939574196509969124280981864721713843195438460763897625500086\\\n    7188792931522963837818536536679255454678584798360056513986569596981715405634039830286886064441\\\n    2363218083925109881792134204172952775532127633896765514921142724783507490481984804609479141610\\\n    2032881784663864288370781697135994450704243258145716282873283108817016579311704497581758987255\\\n    3251333599056580615333247531278426072902834741855811219906587266666793760551068347260791626117\\\n    5946285772604610943023148346355809930038172071165374137674720447554611271066926462540825663647\\\n    8574165142040406336347846348813594714049553996344341931180442960333882708699821732988206364925\\\n    3990300642440446820937022120896338991265572590943694227964203940911559704285264007629092074280\\\n    7157888359399806968491767630362997939636134593247535062347397267056783213374781990103221957125\\\n    5530787666384103423037478090681665281310173014284286359358321553179286138773827418634828545298\\\n    5596803388937246359095872832641067246322801844674533601615342395404310700529470149070809679162\\\n    9786749539138610096271589847653874533597001422946270183808929738339023355053732901469494945089\\\n    8857699017740185200220038435595393193935100569032424050844368957622525368552450268716152030907\\\n    3215891271497283167900058176219482102018928799989629289931275672615683771400542199451851802982\\\n    5723604709777266576069885364811927710140780488671013857041000734381565210188817937797910037953\\\n    4774751149951316903161099300871147837017120352238420720945631701428988788982274069127592171326\\\n    2560634507851939273454505713536831214736583007213478384615458423242559915837887953080447572440\\\n    2003820664861944309581076262975785376325349705554156168412364016599114908819500269263049086302\\\n    6104531940812650996172110755110747536346601314422542259717653781175971015674406069648932679128\\\n    2847217239377425662203172107299109185215035454419579274907877667271345690977579343856991008468\\\n    4306487911159019533210281129958955117185440127471830601116372797192624490764356231509833404768\\\n    2440733251348602225929141405650139780317868576490487218678055551575506034503484561661768330351\\\n    3283110859782751412905187692348635003147589186512764933338574252110055911480476073294142230998\\\n    5737662981982066447991844513154491838468641275696567880433790119384945034040506341773272106306\\\n    0928131001083451881122565071145036232852534424610082648342235293876332691611540517785851371843\\\n    0225802833442775816696498866726597777636388973872257893711197716645230873514001209623644117137\\\n    8946703745132464013215530799501996538077319100736777544891900702837644323876898475556674630586\\\n    4696725426453049670753888625110609882098049976445306416672004984374920087964465001629993363700\\\n    9363079883432617571042283490991828703109530809336254472391307368913405935910020604439328438223\\\n    6101372778179022225595177909300482692565032565666073691032879080699978638993065182898443350547\\\n    5038051214193670269457014046368428873639060667475332737705349733562378098773549233362768874842\\\n    9980436541314398980034002433936630292346211527096649167706366979609202215341978950492359604208\\\n    1648402906565229089832397677446369589088999741532556523016296041218844885601725643811814303312\\\n    4728873367766008546788696898845741397102669431335247642273754392590476646321511145846494888624\\\n    5502259234121090597006825759777272057426560717122377267164696100856224526638731373911565877712\\\n    2429824618065981188184530571353840323438197476336326892060985019739871277218605229027607645792\\\n    7670308890968507709250525403658625639675603891844117003667962635096505203683566514879020495295\\\n    4259946322788000091787595982005278025298131684619996519521725417033972644162467083969373929963\\\n    3964443157182823390234585988573472319676126085155678379780380189303946880665516645802824268325\\\n    1640312508806313890472602709317651933001145733583994473300488607262495654030575600659828628262\\\n    0963405656802028280893116937329085936454267510329741731497812891217134871895702216483806698583\\\n    8714523993897297503094199459848708988709649923083734494608208009789866316890300310686465784556\\\n    6819204082604881286919638497985917531002945432599589345936021441791107419234031831661741360455\\\n    3402030928873679357611395310899906897473824007183417789449410112072595396884649406004095233022\\\n    7373062857490159929879223258475938116834793435550705740835043701634744849852896503945093882094\\\n    0454842784325631355551667435721515378903803328488574435953589076395467646268227107193901447882\\\n    5974371487949123459552288141469306863971806263090102408708999379142774872076380439579042718917\\\n    6998467053415856056046726165177653008143662718121609267712512579070929425389879690678136189701\\\n    2088754594866015103406438645472321929457717351653224164537956616035720509806771114983889981099\\\n    1618644650932906936113125161361817279425809570083204540700553892201570573193216508089932662008\\\n    7750805901326032223857482215331586281279969363486103921019698124640548030462703615753371207144\\\n    8765966148203821167932779622045169072560085314776811402919688769090648434688240819264474420363\\\n    5470235429529215219226771766150436933781307695129629796940131267117741506713917535018009373888\\\n    5789665697177539677326371217241764158241882332149508270185151027556637763406697573245130852537\\\n    9121687750711299698521502252173543837153898263050259346736526540101301047633366541558423912108\\\n    8589590828970922055021196110971479055197234994895051253881877859485761224218250856606287910261\\\n    9790262339618698903949643507723012084724079939419174872398702530449386144629218348329795354281\\\n    9656429288421914145367595809701008356340180310735823440957080243187227251422429877854555989981\\\n    5836057982208066636454799161066732110226524388530067019114544286087851011723038788182721584109\\\n    1961389845299175535435685676688052534974576969180263003015561954581006787486399943733884427816\\\n    3072865804701136085543280836043919272435510816871828094666884176870622238766053219238996631638\\\n    9223599001669523615633881536027547509852142455816011100656469034609514222796045392045683134371\\\n    5626762676489832678361675520085284044469990575772337832337947271019151136766705989353769048310\\\n    3533329879625706131489496393868736621567878564864897819368799556658362165840328812375629898548\\\n    7433171545159879274027024196378878900856259814880525971573569375814824457061796193548680879153\\\n    0745961628150355520530615339530447469239304971517696834936849526459091689098510761171645235962\\\n    4173831344482388804870389739842822310099385068543923168846580300898322202465553148286852419509\\\n    6070258516073233738713240416012647829952210887089967281249898516371337008402791869245359698622\\\n    3069117256983404379745701206993842467415943896695255771243040796235089021346881859200635110694\\\n    8290851974539126674499508570940437688609767424981678919953170283743402321348688920554867758450\\\n    6315670558665463562638568831668125330646176304394375380306896257064790678540976064256229448580\\\n    6867138411878860064971365855411498771210596063628047986953576586958887149933760622013878703461\\\n    9599320400098191544355334392877829093161115594737312317806817551837773273017715000365859440619\\\n    8495214721828602063035357813890784803422899761833340002155671391089603536800633155206010870429\\\n    4842616477347796359198845066358366530419624696031785790016801153186882300223819446831171755908\\\n    0478295106530536607346888302994713285598671738163188770745459024096795143978957709675759790070\\\n    0570218463196634831224348600961466366377889264235163498382574590839952295488634563311088428989\\\n    1423501198763266199478346127581484278562482514712245615056070733012110427930664349625708469580\\\n    1109042659475144910524856999985021550046820231481383947699126596505754928781024048943850056222\\\n    1987872266895257575153435718017082966346657609712763847752334893726027426530135891134439081365\\\n    9827026768133919218192832742166403131938151221320413116462009384399767661452235697937668551761\\\n    4689186262301818003801167496956159565233478476577143223764041907883389232364110218319126456341\\\n    3626820550725988467855030008255122095509529017427065394037928642001564617108908925353896891649\\\n    1452641192189244907617359628263857932970146469339883737343179916465430310705169904233846217830\\\n    3936932344928438015406881463659777861591784356966421432790613488404824847810053605198058426340\\\n    3125677984790148482718913104300461727858813649538883308720369881095521754854378746044986250452\\\n    4724381782399367326934901526973213252397350028524027129635546702827594263115889228334788852741\\\n    1309099367610111291095512736537315100283718250640022873233814139294023150578727366216627942987\\\n    4026780723006338616128438378697640840377166966774258152719224496347699116179725221759985802412\\\n    5522321158614484011076523921317473813667953666737625677936586958505447120019177040196092308060\\\n    9589482126057068563914371177218144999605213227960283184524237925174564373130218662805597585615\\\n    1616215464356384106396022066203899114086111779966346618944376380148430598156481612477660574464\\\n    9490118994635340653404050837393812372199018381740550425892561173356579385783675498861384884665\\\n    2384673142069662564528003261512796098875944825107728639394093620241307713656593569198334560052\\\n    0362492207807957860859401791133008397534922113236510437068939063425345543754309886285715758323\\\n    4094675603512984727469893775662679323169820340721621872752985946023072430492348475114966003976\\\n    1511153376119086272229789559554515138481317999443629138261084001491786977277660957237696224592\\\n    5262929381433392774330505078688320428481931511017643261089022941972155336607887752730354738883\\\n    9409597880653749553749703089686834557300069499942668106625953700630240318744825123652887725538\\\n    5590445079125532591740668146708103072097761085371796605397605760938815005255848297658202170982\\\n    2072525121966491134964907491950527608155813872230173903187373582659325896696978262558701327254\\\n    6733770546756303498854537631001598541562565600062289203066570039509189092783486157995005412375\\\n    5298913789124454624420280682218451491294874957361712795686123730102140414275882229841864101861\\\n    4239440300169817161604633574250520010199189138927540876505205028527596772685663838677545171270\\\n    7338185214274787418888162075260525659137585828487794054537501483354282562641357549614879184923\\\n    5119094238178535717754413019648456652091632899457647793468620196604454166145245292687096448056\\\n    9686222827144076789855782475100033624752740448129908299779096918216978753064324885420946191274\\\n    1306161306034013686847387572653605120538221044491879166066700493764712340891467857535137680809\\\n    9812313114564530786809264139780543130069014356900349099730900068633747096375046683648241946856\\\n    7286858972284927466061724461530455444587533728586058885354613552720328147074626778148997795892\\\n    2433159704701202883720797652184666796242536777203337909379704420211030237928683339082024164871\\\n    8987044208138191108575862206813789893960343863383303100186477506501715092746533417876146491251\\\n    1847705592508940509272899105731150808314674386318675860226684569989106053002816683823103482591\\\n    2745844611067646401646730628311856888883237608194481872327612775062442245048313165132085464799\\\n    0221080547862660276707434125294212369761403551127195666686860691629024522662993335188719168063\\\n    8490583704151840639610053224500512738888191257786559041411423555604450945738877558110555650299\\\n    2143326934602290855487547509243378618888934268923578572408781849504928768154661319892352912478\\\n    4433664986351619465677060427530969192929642062505747495470723565190088231774675999290391724201\\\n    3335795428803761006796629891587788035236721049761206249737827560589799046544773383872490974340\\\n    3433310403348559420856116148247944279654604284983076314151109116444251637757382422679870971029\\\n    1969716035892848950190865155060075660667315737248350772736673189658454369069512985451017393889\\\n    2904550179365845315458407977373981249911734915776856069552251750077099657339027740651747571254\\\n    4830839881363774456081851675813655675554380632256365646271271956314633413326067710019803460509\\\n    4139473257052301001613923212745786115360298274444773308013583128495602745682523230556637613609\\\n    5202205405960199767324517759254688411391792645411106900120390147654119657040786168975814835088\\\n    1519859515536606408869785669983791580545201025004501944150065465296313612543022262301971271607\\\n    7247198641047648087525458516555522097325495153534386809515318449027207405315613345250636265617\\\n    3269396205934137229220310322671414113815157624360294218981688887634888304166039643887949941902\\\n    2601685788094063175203054349486745217842773075378724693635542413996898682027274578678363385269\\\n    3060042448630778690274909095369815134518058479132706543714400740979913976996553559716511343668\\\n    8318403748561516318781164440334827755407770420089940928408676688532552997548136363295918473382\\\n    8214712712599103262484566579266813014342842133129635632173793318988376883533121783385997696912\\\n    5824227304668350421374662903018935082575378576955770682879355635482528073048992006204137719274\\\n    8826388062871898424924778204466886995476280337955478570655197725851956041807287559856608114880\\\n    2550292725100757545618311928082509012656180036903137636979478197301774047682750548646791859474\\\n    8860849975770556360571594734765691903459426822537419137084203491259966750719744033247185804065\\\n    4159408143431018669238507448858218830575721847000334078352866928811676693706617630330336481790\\\n    1351670690578092196276919209008354955934113480587949351956482905969919436118749718260957262451\\\n    0949680016253621019688009916411122350616040847012162092097389897680663241722365262155934525600\\\n    7621341677375945265039713430156041785952472180184845081902327490172975046522517903830140504274\\\n    9662164068031782381327526836896322079337814998875755727148090142403106349887389737911357885358\\\n    0475372478832479293026374168806158886655718158856263963011301583271468284458310068740150704377\\\n    7460420537823376286386634482230841972843812395476590416574883658032100419201213751528479592014\\\n    0834366924681291723800821906204327966051462602376168887456014505006084598396516788367225548617\\\n    0300773106863086919685038081072560641413426272382993103784888823482820814464719106564976585161\\\n    6553348192725308078420311967766746496409234544899631273301066677964384672548918105450733508485\\\n    9100864377059236830617669942173557718711178698324251500115466839334297052554461750198044748752\\\n    0318947850002650169631993476636612131562313740400887815895046814909784984340911540687289694101\\\n    5558541425886113015571263026471425810696659929373512445017480802551828588962136921236999289857\\\n    9289963139406170288836939069970917512673017847257177541445185823496107342593171139441319306932\\\n    0793383201963610398886647709403107945431732715765700663801262766648688548773103738700328839692\\\n    2768599895296731271749454404305843299808156713268012093759589153044955507839436876615317377298\\\n    3403228843250910028130954719243415025908885697005283550810904583778310012502406557972406097702\\\n    0517402916810854189887100982673129875179697084794208560162258183930384241340412997472741196197\\\n    7612245681374377143829364134087728280603784018118654699011238647925845339300394631718780741393\\\n    9260138911676279968778414920706656172830687823041904256069921202721682643961963980713734946392\\\n    2364788031406675508364921697837189496353569065913605682111223878356024398943644040122881457122\\\n    4082050706721678485858224464308998493401948892522235772851621073166462347797135630061375995074\\\n    4654389131933615478322587172592470316406532159084568022571136916725725432548215187132253894618\\\n    2238778491806788483660366126073005666887541246958049805529239633814160810616315330153227560503\\\n    6428663837351554268528008298729136524490116162110347410336940566567200381093596083243593994456\\\n    8817323298042427950829458013343650392855112867988777291010581181081559674689958294077064465837\\\n    4160453668696620376300058460854136582004096627714729164531933977842700436758544892592334457791\\\n    3166508338197359435123112047957419446802134215762854662773876009922613535131997113201085215956\\\n    1077608218719620515701468346074555131700562815922427104687955285337194788150911292321713249421\\\n    7178904766855099872245871832194878793733388560594079162176261809575043095875731346977832046795\\\n    1316874680851039995105162260230861749307773637090926061525390817899691978446206955666787665470\\\n    9408014422483864495707612648133939039329191450475928672448663587481911706496956018931680420943\\\n    8985304331992236345435723413229437933366720023416885795033035019169116505597436247168498036054\\\n    2667885260533922169556229857104279376809036111361944406402129497951410412816477272529086642353\\\n    2493734572365848120737247002625280985870530588406515067951300340999850205745009344895241451171\\\n    3657105920124069885406913327229952707983469953899409518878453324278820284007882842587257955001\\\n    3666953324661414873669448635783522635926670695088720985312031269251283923305679918924162969043\\\n    3578332872026131317995278428729739276104461858981051949451360367406818437702076641829662874366\\\n    4145517635101859915099811196375984843055531533168907975480918570463165847116650408320267392501\\\n    5604735763725018928990787255469834674933570784053991634654572336207410579640037783830041699987\\\n    7504076332679789049021449664919666802023985326747403703720380232401086155370455369894291269622\\\n    9477838293688269719838917115872523099903412569729062238225833627048618675364596565732520627404\\\n    4333058445117187282309198961333637427550745858393401489901141677391168004570714170088048082364\\\n    3814097287665624248419857419787319169975588845427166924040102788926185207745451572236029786456\\\n    0056983374267437426729724616509793983208269175400127485926290525671661746020509874287117783299\\\n    9631095133346733280000579241961568559457013690344634378794616520115588649301299524690283339197\\\n    8071301575143795775521128579600924263800102238370517720416095574027064340691095384309431248627\\\n    4981509108220397882096966536293458203737278598478900071603862463473764693700249313624595825381\\\n    4530416631427375244468102557527902678634605685764726640382236749434623427948514828791295550865\\\n    7181101639542878386759594303590339445468823466127951095083664068815040585381804981007526880235\\\n    0765278021963446701615981521644361074781607295599800636251400271174675418739430693564734226897\\\n    0886169604335341021666593867964560656422388140901993479062769436094997369583375497041150200029\\\n    7991958486404908261334998004613058161625136331983287971194291978383713588576831903326903747812\\\n    0242437180045871833085233075003521519437128073169238696103979618887002786081901968195745548607\\\n    2881366300852018277714086509390915116893581401378237895734788179222530659743648309976541937477\\\n    7884597905237836840242552679271723523989705664711438645552801442509190165334159953146420285608\\\n    8132636685543388076060409814585873849320376074972476750301882369736269372372014997037754829115\\\n    3786732119663067214587858188140977146825793885944065218544911260214487731449440776998410135539\\\n    5836905612793418019699185484321981077493304938356933286781935208839997896005076701307495027520\\\n    1619172305144723741274572370355567844526598853058123657871373225612133756708367069567970703852\\\n    2149981921324628488072630674909465404641589760651954286572842119535673061341489408254267537882\\\n    3755669345234872363348756278663522666829605379596093346904488690399066158049461291594877068565\\\n    6708789944979715273447260519781674112525125597088228135283644313240152042677513093969979246674\\\n    9570750365875794537270892436935563302938080950737021426213606694259572101988919387643601888449\\\n    5066234775911815839632365583976962973241504903491511227611414317474733218966634326792663058946\\\n    4876495985298304404577662516927012663213241275317806636327796993773114017727878024877010626785\\\n    5751295218707207931819514021076997005966669878857318593346555392816390085906574973836505784794\\\n    1388221554360811257908101937004144470517763311152720466064733570696182296662787800150362757191\\\n    3632747930082108498237540556153265138728766833647458618993508286799503917593007303893776667419\\\n    3772950093852352718637178920884930721388435797067474556494285395726610461807896290510541920971\\\n    6019776195668494948144170628764176484902514958282969267763765806114588718198261841794433114763\\\n    4960259840605747931707182527421787593890477030673810521336039029932030896199299505051064415060\\\n    2812245669787014627343634125146092975272094661077921532661344256830006173246106141682084233103\\\n    1154022740699775107584829475491413412645677240298421594044575914176377402282140904676417505784\\\n    4654013824069436626857685916416236070387214210121364576808942071810105562883069173570625111812\\\n    7830064745988522722420196074665993936738575946541393209319721065423736718634683781548989538560\\\n    5908809852829441829232336219202356271674095118163640129017054530552608374798627554179735999600\\\n    7856212885802733764724863549765058179120769608237375433518702441520724770198431828641532515539\\\n    4727278099671200053895508019783876457842027476334528502911960459882665719477375531528889593528\\\n    5015005292479948456744860356773471258913011398280162162392717226104595685137628073922222832387\\\n    7850052101010865042097721546976311802983741905790099853492575240882776211333626934143365173658\\\n    8936968535347009369003400703777201659207985633013443638673683422575641303432005389459986276867\\\n    3314044947712531986115086383158472966238589962416772084353547318380157114238639097248981826729\\\n    6792128229507364966167668728001745428570222497550319526066673267202251768010259103188453312826\\\n    8011129018706477602044083431288044925168043531089255895892694843177209227448881200947512511524\\\n    8288879284113228585156576430216324262892098735090561398291438416821557553916810007546887461406\\\n    9948779726578046953443877104496541892394005941177839314949470106245610366397468389565869942254\\\n    3063131500057890280998874311281979303546403381020451497632032888003275203777172682031789901913\\\n    8014330784267039407899130779538759044172999869713764975890297575881390889571920056975293069424\\\n    1320940105743235462986754037840538302265098306847338890231814028231227599685505487185445070365\\\n    1291837208574108514027461750371375744329538167991177460048856483497318634569478233120881647680\\\n    1718368415786171771938004981301986295563263412504158284856468764301638949513616762820947511188\\\n    3479418766646914813700227138195890816010634776705687827979892055509654210131180368760617951791\\\n    0638120256544141544926020692383438841002622523715105555618696306483740824125741844174518067283\\\n    8186732153286597963815773353802851539111171991352816586308248851103810075456844861341624030416\\\n    4492428457359406691703951517000416509590323383417625238954293571671412375166256479552589652333\\\n    4790771637604001562407336948914360231498073104278241456821971999316955471489075985936339626373\\\n    8705522906282441234033291494825473590220296593792696514021594801138501389907638492838729983713\\\n    1587124671415625938935029843372207092890809810189894384947078696504287414166928117143104003350\\\n    3578986692665753033096164986172551899314709368546663340762969399215157445088844720700541979611\\\n    2163714917824534067057628696038611027450799436091242675176802213298896859446297026960755602214\\\n    7106274145629142831757829074565775207646831013222528080113844950895212487055981224130425738321\\\n    9535732093563991172224258831524055671354589653255923530160821544154801262520785252659123953741\\\n    5024105114981961548839403313576491460333014301832157358957150874138967240112419243510884219610\\\n    0938486520307405330212776479072162145150557310649379509617204132026634141691724382532062927521\\\n    6058831628605402940982132228534198366329814829230521220368269186918149106761423932315109650436\\\n    9826023687617533477634801130651409288785963517109759290502742995452172318537175441080617713973\\\n    2836503473727336025794798691275236794869992698023592062262212221528628569995221057199149407914\\\n    1812694634785443600056352608262107241560716040234298908728156098634026489194786592658683127017\\\n    7248741320136349714807104177993260798066974612401758570442963082967831952493785541096311930574\\\n    4956321885675597865344221327519117756710979348076630022002046439678106244348138229716879111184\\\n    2594207169727636780538042999326256293273071680659286192182211348893889677519184245548605161990\\\n    7642762561854481006467456092166207715026897740512400407826332224436488099365074712453373211720\\\n    4382191275737365014435616351578057162746457851193365999252946703333738438067169582192500526479\\\n    4121418226930539842910122420965220139069226652021840730182892659208755525922309025533116851462\\\n    4080329969672811965424462622001683499965791937251628750233426728346808292030717906424286544017\\\n    3319478445565803516915248227057403670073711440524849180314567294626659734106864412310977933232\\\n    4427383927736484633298579183318989196145963322355291858893130689322606664741209194148490453174\\\n    3391626325232178920571233541034467969374954354841510755831196327530922209203174232870320943464\\\n    1041299189329634332518879344999021378699028540209981004741305725778268501911919514253815272154\\\n    4481256649477010815047655595926479474857141777363259714951435146329146952067580196841917676284\\\n    9606587192416839166843872243577366384666462361849043976736902140576835765399523869385642604158\\\n    5867790245422677607538430384304812181290705753053541251257475160526498890530647695217905740997\\\n    2974517979885509767082347478852347250215756579448920612167992274706597231913348535257396593747\\\n    5747487964373158909865958804941987225202328308227679085671193907764134065277173951534896236529\\\n    2640985721758323491290307866835696129038458959288286289665163873789348662242063553876206058990\\\n    3706044555780955489478026199647878810056643450629590778921676484502967491078318065389983422949\\\n    9144055676298741340168779283920366715460337217460651819916951911115461122696193582830400183952\\\n    0775260301081282999446058330203316627748932566896306209495675180062991388625083623516835896708\\\n    2389705309201910007998069522936516536309781098173741640657603138467628844618915596508088433652\\\n    9495231892867215096448126850772818820869811736190574375024017399792830208556429766428349690344\\\n    6463920516156239351673905722433131453430075401397720545587049568926550573947666423009621586852\\\n    0267713608619210623050412926431071624439560127093867234943473212971317105950453673834769524856\\\n    7987627531871189854742794192048931016947681319164489492590515435388665209442018299197010455922\\\n    8039694184003074818576885689781915881069025064307797694978120121514535470288967923222102721320\\\n    1204701987497993225443470748279715491428197695447162226484447878844639109802012431072015344495\\\n    0681465235775455491829756398654261926330420564154730856326022473546921437352752720830137496677\\\n    2652166906841073732124598470128574857536346454686779518292285288794518268724815649626939839821\\\n    9516606013563963029450395850511867565791715904315613156624445865899306181341490208053252069648\\\n    3734020599605596484985292861190280006266947054060126377128684849914259189756242034101413629013\\\n    4756231134175063309406515379569701225333015350882049549415750374398567101557510235816082219827\\\n    8583117666999194958132979183350870092069925208346843719855682467834946342564789054831078953323\\\n    4648523048429626231776114389590429422623676959655749779278185154235371453430943202301829131689\\\n    5011992068495062666761523301111057246059112559222920734620953278348521904979336067764369385328\\\n    4522520679941789720330278589517379965725103788334759688358820654635549935242599583528866177850\\\n    8719858136179342220252690317787545013597695715198475073693719062067424527976936496914863765257\\\n    1796969053337955502766679241656156772455074206272316836532220336607212581057997555799448174069\\\n    7764313704947367075386478949317011194925353169979899212613087679039363957268512963413785131156\\\n    3522100007902075948633097451566761359593112132265326088693328745612510791015824061265211449763\\\n    0620598490092713727805719155802358422193703170993665795445684015321197238090887311564718868884\\\n    8015143544439720227971377439730708809572303595884722102673640510336917798237105124662050249256\\\n    0125208700362418539381990362953754307856216951934740418193657917856335616001166645931118499991\\\n    9160176957814452993552734452178281150752550669300439392000968777181321952252120090488885214919\\\n    5087915912187335488887263309682583538649058050472314685898833568419549930454377469502759878203\\\n    2385413039888979237642326733380249178101760259933450051648997950825937710599485003994704143387\\\n    2048050182592970401229565776193057604268609645758938225534942119422715563020915079436640809256\\\n    9934634084071690494373041843123476967315351880134758011033020960319740521883933668310006830835\\\n    3898111876465979522608569917378863998548096756935201004865215668315072707666701913175826298054\\\n    5237491366073850030186903064299039360832488367937006524444672959481475972970385246293856510596\\\n    3313189317730902559970209034433627493672693816973823108417813432956067900897260508994591808377\\\n    5713321158596532488655674834093731117003177444256159637623751323170268552086432152510894421611\\\n    9366232984101313984371714209461272533990816361712970775213729234598834888208800020969879088703\\\n    1873208474042433834753952095165557793309435747466682645422913114140934277927605941469158525968\\\n    2017399344818411035972166332639822849025690630416244873440379134019032654730107758324414536385\\\n    5828738206769947684668136654901308204513008992318994824151605325107131479937903943802194232984\\\n    4412514293724792531572240877654805431679655003507167581685857503938927719003589261641584199961\\\n    6538242177484771856343547763895137985099261268199516033575329007496775730097819383175111850232\\\n    2201156904014777051142626526023779378373866602274751653568555058383155063684662523100987424776\\\n    0436873004418874523164390777603031207191806780095797187114798852084784330511942711770220265677\\\n    6099843557487384463745995891309866503320079517935024243987556697460578412838556440391808592720\\\n    8108811018021121522364401659125418100272150926275268546621551066903142297427669162984567784566\\\n    9124993960465139057587320470457355516505860941814093043212815170498040089105423059267869926855\\\n    0715244917452291272844786165341751006503356894893843383010010215113929498995138393978900506940\\\n    6169374505765857254669554255445782992688039450833922300620725779902933960415336762090672458711\\\n    3581830526594165454905183917500957930785987328332328779522633584545917115442675856760535831585\\\n    5540716441063079661069291461628541973783970403333445827559224136885516367677783269487614631565\\\n    2777925480236651028452495427269715890148780687218561198107934308693374127141365376215289606500\\\n    1281768753080264720375513599544626934167423525468899098668203077943225072044221256139943370821\\\n    8710511116813394459961789966642679470800715292038755005164552328538822860386683918560287324464\\\n    7185913516189493854281938312270727545354424546201777051246121451700400252627784171764297167136\\\n    4219683057454346550076736394223117360497609465321769623104968546018496647055814060651825640979\\\n    1563656123275903493180524572093255627115164940690458929336604673126627631528453828745161614272\\\n    7326819247740290110180922190846745066596530388862315657205478243545317197511305665983506645307\\\n    0749140785694779282609588974692786031928810356030300557876245574286617671251292061903003729399\\\n    1832863532655381990299910399160077912175569559419590591862734213838384801229380283728762550125\\\n    5535563867959023864185287104590505220384114243984775983769178874275413200404794267761777510072\\\n    3996801947547826288812643941925729025431759700403314678936038651349104674651605189057507952212\\\n    6064731778490152254070098249327769395683906681575609461678048313367232338785712915300588064874\\\n    1886711323159566426289523129651983323592888169564352437718226455943225902910639515538450103612\\\n    0606597498797630131400800790270232247655733608237024240104508920915360550231545228577535285957\\\n    6298027908184776546034352896838800169596436701572046112774179994023669344010441646893458848268\\\n    5071491293630719132682116807708511471083468325476274688419191828886502954554980615918665184855\\\n    1235344701880338585311712374407267176569738106940732762670896644023085816750057307067851924368\\\n    3669942475469334973191203428082466419838496582755175543209613678054916401276123879456896141472\\\n    0133317964606617768442294932182993978821941820938166935875273166764864146101270230640087320996\\\n    5411711521295459513119561476212156762982098187825608238989935247830472950344705653843838283688\\\n    5787442190924941321161142715070003365401024760603670814964076538305205530414838720836994818223\\\n    1254854534433342135820548901337813507319762819619947770226194980365922828490599032469491149428\\\n    5710683879662090453434939187746419618303464128354413912476010543497798755100075954580543608103\\\n    9722685095068127053866724367461414629274350545787538842010241943492672135233859442397306202189\\\n    8814271689140076820095125413626592715525686502085582625658047165318424348433272519387348566516\\\n    3689075684740570105832258689860544202390607142781834541834221239924535009430664149731309933769\\\n    9753756240135063782438573902773418702276429354280351556022882299706285812425092094658340046263\\\n    7852770285552351990193993310204060009612644212384125193810595727597612178599195997623494546900\\\n    8919006463077637039093426545902604543109138114335256969254216862087548133974814021865953796920\\\n    7490415350953944871207538363639543414630391158202354041021819265420017384240912904742680908974\\\n    1876478670460233061766841020222805873289091370865644640635134971956274976611758728992098892637\\\n    0233805514936796513381697797589326101312412533235473596005074574541292303775469754543913793055\\\n    4181449433712159204042257159994234738941832879585482319101926035331631189503519592456280828724\\\n    1745087575499734553437533132406813197235866901017668502860634028002725235268064017237454488351\\\n    7000217734221094412210908816749113012229004701882471700588605520377203640615046046898285232533\\\n    5764078320457117310748158703080592314908492170666936048349638243862975954099101813779688736072\\\n    1135074097691152102962547734787062887681839078353334832294868771554248483606487426634319230894\\\n    4634463339214924039210618077796547359714903923087353704128434573590583888960833969295158420168\\\n    3187955704621204860265440512842855551905215148863714597339826737154169737386340070531269320990\\\n    8995756621214911630617090867453211723868369425199436393736995767835911966958417660732147898604\\\n    2674548769872443980316305782801815077466762805426868189717530191308780639774525214145401011527\\\n    6753603091264954571148834518690869132722223633422503164507603665729005119461173445188601018429\\\n    3600328489608701736063935435324988647992926184234563241223916410904817864974700864070403093085\\\n    6737987031039613457942902751336468585297784343385852562202572324915841237155029699557513643612\\\n    2015806046825807362908687293288737373918978769057999308497957259930387125458192990745155586135\\\n    7105267020227960808094658652828476617354262041307229647604899993018863568394881815635305352602\\\n    0668926855387773303018688322496054837083151462150078319577516409031681045110661775117716932120\\\n    7718496182467610670724900468004807769327532955202354933695904660171037650632214751462624478591\\\n    9139432376578865241725167075213287095524573907169304039038226943892801014757172172477245956557\\\n    3759556090050956792766084121509269570935711600192495500921339469413532805845254578159647041047\\\n    4085551440256497682816526044494260463892989326868397943603412879014651077575415438183254916617\\\n    5032205822014579462647045132727594786381080530807015612985078655935244131118630251130587112211\\\n    7797505029978800680756992380655394450830689980943992944342063253932358333851357368333019757046\\\n    1282363190415508539746205941753057354777606122212087848509999571796316666927485004111055552354\\\n    9733249785318871733607860066715532724747863984627401069142693381087893353872313890725101519164\\\n    5355624121665801565247027727504211163137270648859789776950518645952154920755942771219312591636\\\n    5086313985003207973374763230429710166938721320687346985612232237683112242054661423408528192236\\\n    3422631765669508697074672172286095145666941166416390065099779395215590701922146163720500546238\\\n    4958733759618097619017702936625196758162352369302270127514914189809304626327054818151577994251\\\n    1410759740804975147936184427521316014928512503819359533004476904816259637599948234559194154580\\\n    3337892737835310419984135493093660251057852116134983327866837249055980535372010590126375319806\\\n    6356105008009454015421959024913220159264068473549353727889097028468567517945266367236872583152\\\n    5461733959671765287287899037764010797100187392902945204089437981118681567092927811581724329756\\\n    7491835509213900005279162579858101274466683239163873177590371989093941524661110765400984807747\\\n    1072633229817908093416844416880049156902921229489318129107464471115202617633535803786704281371\\\n    3279371592964071089690407897606746113120341340389794463669204282685341548294649106075383238896\\\n    5025103881472597686597570862216454276985825483014582900757252239582501989337645846211247192745\\\n    1519695469717922238555037768477501429004550065989781902904771763131616162289667668048321015977\\\n    6772721583102665296237217420083809448080133099790986527588028976580604985767769382916710992547\\\n    6836823051839700743205330091595606917986296996832737511491508978557812652394692012418350924557\\\n    0898535932262581665610852610024568192689405539607823068394604694039295341193580663914329658791\\\n    4701863784407518558223966989228702449726357944284689684475241331891217899779039953647914756917\\\n    1633859096380932010084340976182799122616356492523096499880005162473925682185016506210625925114\\\n    5287897678351396334972243358660008409895184733230460466838353072089393906957129167507020667545\\\n    8471683992040725134910975715365605141993749086099473292746017480647401969523288262762080844375\\\n    5698410718337108321619768581920963629051524364306353391826799567380496020409954685117977503867\\\n    6178525348776958801298015069772551099810427959282874558636814312044463468029958621042333956853\\\n    2213386437974189221109511488555121253674931898715728869371715994363261514019397788401262679622\\\n    9888310835236652197470771951194198926702512026763858775949952340256269467154516452781356112844\\\n    7694442929049812356775165441286631549050629837826959219396462202335129847150637756198016534046\\\n    0984642079252348179554783464446927961399598843571780837616561428577173651463789446909666910506\\\n    3521304619004403674854418236358617302149317659396508256164415895722034519376943729891722329906\\\n    6461658337073260375547221825313052710045323676238703899574585900145030746386191800847755791034\\\n    2754856626087130268870583535707834094464531685884379512689276203617352663903717075498113560515\\\n    2658274939363800012371812454736209196213845989631130953176189615248225315484463625178040626014\\\n    7845015860731336314512926740230624873919795032321425142934206560049086468492716789340501547573\\\n    6285752668661963887898303679254637640880150707662697566425067593198397726629516901963444019882\\\n    9180716312180714983430004458675174805336293922595927710353343875360368657542619243397821766403\\\n    6590489641877006727535145977283902102901284418194947977353446407607570093626527895314096583242\\\n    3866203799983787880173325926992721906803270299240869432397403365790229148640450291752430162735\\\n    4301586408786671696067899692087306930270995340008479408847144688435643923278533230740957625376\\\n    3197151441925886678620615996080964185372161450001052950591912902804591886723193468445323981248\\\n    9294081312080245437794503012275735223267274209519662667194251684501031691429285338035830368424\\\n    3401285730583530326220826656442039773309005136312617312685266569530856697198134237928286826756\\\n    1947315144743227865846156613769583737311617860020832840454402633840130596533426367912448467444\\\n    4728694876435779415360245476116151259354551935656839835124326268096486337407632208796219326136\\\n    0568053189596728674795802244918446097083623580703027591246190733102367690601562852305141250947\\\n    7282130213905571599687370556668251673417553414996466495822145702897712849759477814852288334955\\\n    8869331377252184550545614392335921563528146672126718518836352506098590341538649091732891315562\\\n    2797766824062193403164744864782043011650331704924147775710010344326672046363110926868477127741\\\n    0982466503340403936591653543602120216945307797009129179738934064294708551194014236113248596204\\\n    2062725600591090735065877748700133918202281428893296187097157121866163631823520833648290782306\\\n    5298342649572919308659942256006092821453590871240938144945440107508568406647707905393987794239\\\n    2486167646056399464245690933708106611689615609713343709116774070844434799366411234780224108887\\\n    5894440411872596127392328270042938882050062719724496523642747025391525722734412102973539925160\\\n    7345456113634382798135014684243686505549033966305624672870933047030686028739121760839480286808\\\n    9684134817054453083169214266125780638904227235458654881443412193689593967819232308554567940498\\\n    4670955824065332314994086616097038299169891921100374534527266437733550185387847199766569753670\\\n    2095310702739712611147077072949660600146965988422389479086724183495589588449799969268377269377\\\n    0746710707139788661872795024258077772040142240394914765264452136018152011056800385192700157577\\\n    3412595267835985652519910910038921661707539780571701060809916964425163911085224855175778134309\\\n    0786676662230001032389382909393157433354293341130231972196246350399818226345132236848649765595\\\n    5794606510054874617458491338837492726630074179544159393828144673536277606426504027372935262381\\\n    1370042195381706817206007304664429624818427711578756126054023005433004118069717965175759208199\\\n    3630405586637404765773898861402783304797980996985272812138449162008583400487763436723239295618\\\n    9165076734315113136121600460671737034043485036904258637743629940964352750990333541175354172577\\\n    0782044180946960425864210924690736050303111998066548218184974340799206541219031533424463187614\\\n    0033522303338956897218024793826587760416149359308957426970519328449133126289096777767399774642\\\n    8042781187345377710949935616245549709128116686245275580428013899309035447688335245891017024109\\\n    5638296684201964945360878047233666117061488694547898211002793563310780988470327335483089294857\\\n    5194165479342108270169504064143079363900268338512559290076644030615472083946898314321432607069\\\n    2570826282865187372090510623732194193279272163591053943295850651918891670321895734703385058471\\\n    3818423068566844371683800425383129628487982244484323430715022810730627817516035003313759470259\\\n    5601082660212434126344849365388848902212114747361992853367537702737439788939014394887747468361\\\n    2228287103417758674173863535486855931496800287658747215176397571484900145410999197177958243835\\\n    3843540553943522907665687718172719066513386608189431463994384208650256474215880086476053600552\\\n    4406953569697263130266950731231079911360306067846729240655875971581445636105948197963821755067\\\n    1617208576301174662397195516379771543477565106414167293125890200522463620248828635769318474660\\\n    0982847755407934696060559536911454975073095938109595389664984242134754929454585000124029878035\\\n    5501760660635957731058370349670089609236447771251312494314966601571417237235718173276964730991\\\n    0329287358131154654973679537756309382841905750103138172118507721243622553627338150054035221081\\\n    9199582860090346745823906065432288600759612960792952428367326849429524615601112686424662704220\\\n    3479122783739476039934468611609561588934822951189835673110110961652762199302265713397544555772\\\n    9755416295370620672276557751303899983450382026539435595357693912884851342716092270003555049641\\\n    3873715889417950680787866924715063714008779257814375718841028337046243939653313559637380944923\\\n    9339987861301167035934778962550836278969477237233992912232855666441052731953309551681362936048\\\n    2330908200814589355188605765894847707479835982269618865636298028822313730277574572469980751214\\\n    5494946206056968302516336390913767750498352860423130157395748726279047799964887251839002302366\\\n    1893111924513060361742391959359872543980249403591700962673944974184258814649071556089626375923\\\n    1130155097410713498556310881627907804841529097306918729673777593184618662716741832972952978298\\\n    2529859753467335187503146842185174161646005849766464749193745657698829422799532750436266153972\\\n    6365947987806230658465426940960566547858953471487677884650898550031542987972722965543700096113\\\n    5382438599750732954468830418375058185091182089383942485180929407802777108865432195795858996704\\\n    1719385639928981039511844790256673494067798798685005796879246914490278424013920081253322957221\\\n    2174065371259214706570051107231704908344283630079833837296896893802154758372168795747212263368\\\n    6129900823137322969692570497676189554201588407357993597996413213298094700467854892001000880108\\\n    0391070025535613004411311207887026808096905603628825412889891742260012529886675440134482291281\\\n    0939073951554009183733145514790595862222570081109292972486172673075561713747242550228244630262\\\n    8768955022266252092600506117114018204071434732367688818292076237338202976134894021656865241541\\\n    7819472413299042645253520027973324444753327159961643131306374496654709791983817427326865739529\\\n    1419790665885504258457976941859782582783705017937055285877373389003797736112896435749712695308\\\n    1464786960921199092461962556502071224970151746792427298755673581054482980295483104944669427210\\\n    4806066341016665461662925379505769125775672916687930850219093367926059052060971445745004287725\\\n    4194481610316712468377244694225613812403786559343242975140458249142395087734748227719196825159\\\n    1487072651419583975590084363958451452851304858471873719067821402426567217845288352687946439186\\\n    1962053297790827948222774655293661045404919934604560853210314162259178946549807438643366073474\\\n    7868804248198387300355413910878399420972227648491505835850832773111260143126831673959822421249\\\n    2852487883593578490576156781491768376799012817291743168096129188108280859809893806712293783567\\\n    7067728154565455203240011196319138387738329811646618705942057848308840516535314608981966630675\\\n    2440138523047478606325317555308838375374106089298829529995892224459937333024611682573543896627\\\n    0042867500798920758685535472971289399163269311435781602654266247753722353319396809805969605752\\\n    4013458275326547024517265503861429587443200741953903821835457488721210423567460858361226877020\\\n    9662921907997161928856051106440909579475216632802239945187927910184151626324357926404737344786\\\n    9236468801384200863565298635406556529446893033320130127446611147121139189297149001049571302157\\\n    4677001570270190983339399759775104661242658608686245196501179003381020258021873088572213493580\\\n    6391214045869800035728871647109570193131101247441232254061895194936835835562920817982977573961\\\n    6933187770706974475689728211686526740339929872466909069300784882820894999455461279665191666297\\\n    0782313380485821656723157351831529470919566974352819250693809477146912629873652424523960414076\\\n    3862335807776028615979353762508624960585950527823390990366198191561825973019313503249503476021\\\n    4015981542806910400362650669218082557744771640086836514975266290988112065388642547403056757008\\\n    2028259505524699660982115201689602260879829668012999972604177222348400546367851301396381317451\\\n    7358128694881293822160343200631330678606919729201477853832155757554296758465635969110386244362\\\n    2435918870528214298690084284425760162530324640804372251842027876368600791806578855436096691794\\\n    1485216729151790138674796438280814238749243084796186328771909889280940158907542513145177669310\\\n    5530007623489777358583059142971555168113533544305697442395573840617444241376824106116966446154\\\n    5833427253258371259316121269550033541907944721496374605507095454077796826420279462525997298511\\\n    9342679429034395460511871593530313974934223725114306074781840546412098001955721873654447901350\\\n    2654269451868109937686225739352436086547385524231317761108327016670369279012843594244944769873\\\n    0689473330260932091576622980605187742918227154999351426109467931585716371515465139162371906367\\\n    4774239061135426816941626727237939161706465439535737995686287844141679623559962835777100293207\\\n    5242333583292027747116908547539570542329155951390216362513277633269936111009341899395452754370\\\n    5194681897723515302147476823812537077101207753501822833186328595758774541978056487581825202658\\\n    0900853244020643921965401859813485551625099650944899304456114924468514145452199608402422121429\\\n    7205122104636540841688551788580865747817488782816573811953847715599733128898775550244303056437\\\n    1236628068290773730651471330691090946537579965121981190646327251245575673044615888273364418010\\\n    5917935130243350712087797484785990490284966521685284264454676796469627542798342292694812566249\\\n    9107795784815472022270072900171809408722197546087587599317040887260511607244894925086105980222\\\n    1694634382316405081159819186569813503118200957243666538330727772355041832655801505722236076944\\\n    8984285206476160446330669641693602744860390547573558074650666145813590890040540377759028907266\\\n    1833096738480824830202342079506445323527101706724506618310900569087312512637107445504012031219\\\n    0106124147477409506091221809232855282831776492109976082194987469778040907810066635584755182580\\\n    5934884082353680493981678324332078388817227103733161053863700283865992208619810949833563688506\\\n    5790091991694544154330109398594233480300040731625026256732372147130678957854583830484261528061\\\n    6814661979060576475931370451842912501693266080979960039503048135660980029859732597496481941645\\\n    0514933691530887127241077071628746337754308979285103074234790471514183800826555453087172562994\\\n    5770237245093265818388388034870321614220137900766977979980954752732762513014216157106023936006\\\n    9302411050704826933981050552557402438173718157487949010282659904210086074520474797252169330986\\\n    9137801953497859791923041006081461265526022617354413931603478484120660238281812110679043320316\\\n    2238802276870130475795336612358240666476354547400240173289882768548511404000853610714692065524\\\n    7643113921930308714362903821877663305047337816089166779963039377203375991719661237339311819946\\\n    8511610835112329364505284212887631958901690505138925437437905789630987134464001365514098144636\\\n    4620163349689235022600252429159455643574375031600563957891856379815355705004282277281810561186\\\n    8088573931784011340940261261458507621905786689064264735339391216841736502553850006364618231976\\\n    1669397781292173729291800991134782877417156191901257324435582407141198006952165812352604566743\\\n    7428094953458302479848705470969311184488490135934598953207945929973693253492636559245248550181\\\n    6335984044471111160615590413673241107395414560117979474600178536286299090317387254266700174662\\\n    1910597947205252949270226949123971543481069808941280038469138036326446757139682858191030951375\\\n    2434761188229290262492984539698569881224424871011231272136745868042170343219149367277895311229\\\n    0930349133565028764396454366112590732163040733591821474757362544378021433171533086818248855297\\\n    9262452279053327802249477883318426223987776322143901537935547208788805828027758882197353381606\\\n    0775282211062558160187106861133922352129128742901215463581232210390199065760946588521507992171\\\n    7072856564656482644481894956230746594990003018931148436997549991394070605298722940235858292658\\\n    2354079973765897604770689379342960950445442494688498657008097188069816529751372028416046775403\\\n    9618157631180908736916104320334070184613373572241377111492864579103350807690755274182029883501\\\n    1993020730217830361217284568471064844561540137633488221006382362216780431067086827115777938515\\\n    1335527613295585699619890418857087619707762674678595230756183528506862834841815639384376076074\\\n    8138750152328260738365234764511063163516796701923063147354009934210421826859111210698761256062\\\n    4640224291853497264288898651036906665507749157607982666263640640959803280331383098721626517648\\\n    4606176339539193398257257580600850362032746530496068190612148381077562094132889254761193551253\\\n    6023353718711478086375901326922876715872289819963210891401700189998771981845496936766279610151\\\n    2135424116222961549752481547156285259843572735091775587771517479946960769696745743079814953284\\\n    7566275842110861718701544196056299467614473338317566440696621859179270599620354414033778375314\\\n    7052471354751563524320843258892454910610941266496151168970919615676455706820177309802797092447\\\n    0181182839396180389840198966758620946573485385785604415196877034990485022975870101902813300015\\\n    2617685977839526812969060131905852745243016452371420812158558527935916396424568551149466476095\\\n    0591417371715887603210472659314320874594661896977584298462668389181890501287696113899885134457\\\n    4674882046031336716106804382041428699690083069345040410620403147085188019200819611124235644424\\\n    1262306187415258879103864131862621027573446364620044127960088459735843885466484107366660878365\\\n    7145640917595225368989180337261637805645887311811626063127274529050500098668420369840607302619\\\n    8484389159927761863629633634530215269902055523847722639575423085693743831288951926814797557248\\\n    6105895412031268491969169801590113332897025557992950294733248160228416102599100378240918952127\\\n    9326457858574503884459490492336984382135388544804676195239260004878555888136830654181136944169\\\n    4044860160251400028233142497344083080568443682849632456274608635516676388317507706320629078591\\\n    8198518583472461848846738581390753816889430477471040188276928195379064553327124001157634811724\\\n    2799496071662438809704652361253352885416911504747537458913231514216055343626195676230073393210\\\n    7455065030640196367457031664881953007963424760757594133629178000497176966212522457489054967386\\\n    3594126107780740373162065374734633412574732641307255219104969149540996720103083421299386854161\\\n    1870159294816330294425189991766088287345193715628353295516827461877799215272389424847831145471\\\n    4908189638290405278431376404638412281512184368591438055005806333093467275383119202508572709066\\\n    4409550540545301656571263096916313672650200847117158703038541244429861507094178485035326179048\\\n    0492260692762505264962376955230362746737376942501045884756162940946496715659927858490539318651\\\n    0314526444855173433191120249831769967441064548817243216320500338474041587037997687427757217952\\\n    3206763308930463313985489391952000866350510692282063022539772833188415359616452061440035476421\\\n    1193608236971721679209370982640137353886263895804590422459225681108096190729885776487423151216\\\n    6125236348657066059464462333072923474874710633004981862356571699193205501921180801608440236437\\\n    9201406512768111628390077038676745849988387035730055666047532632371848119588918717838939353190\\\n    7972259639386160928478140690032728128609480268816262918548364396926814254482594367348817783145\\\n    2220087380750641885956278793527595868102828378974996272977810312721967905296688036624932160231\\\n    4791808255607414539280789132640052584378057608851553037185649111567772286776324501108273561342\\\n    2348916460579040386238031829176087318077457360069532192254785558957207950124300546867065007014\\\n    2717538359075822097177116654400421959740788559891150203459169579492463631970447505440321540606\\\n    2571389295758518264435670947292526300719296762053780153419114028097071184640290166785317982133\\\n    8057561648847585133026896344787804233686452766057826131261221852873119190788713320839880543609\\\n    8687774312876645619689873473269041432441870452030852240510429511083150727648060961546618085155\\\n    2572294986016602685534744681168116615117267961167305572084315442016604931668718775981926858764\\\n    5702019471657066693381507446049932394553706974173972716817130694995820973646940829302090816365\\\n    8415211770625829191219971632570510309234371060277525715454858614907397988869356523330913595400\\\n    3359372394108629512446182636088008330933756669155672113826888835894254457237609549668579940843\\\n    7853637463884373695698826594061258362320651851712790880831870698780098514510514477938052549515\\\n    2236889714672864982420545941632433400329597722405042648212950568760432850190704927979496053923\\\n    1450499668703764863152483764860781631722538631511226011207485725421903717999926993408059864220\\\n    0355175234034527377309202224800169931717840690491855415092519214639751262579969449374168746725\\\n    8463950881430040518939847241543569920866719282230048261237391596703191811982765143108459488344\\\n    6423021065812220926445647450819150990029203681699733663802706629064075348576892754196841700807\\\n    9729980235135687169687227954093258547893303671073005546185845605885217956142893688469772888868\\\n    6820712504596474722629058823681903051610696488926023050743858294465011481425944628833073994953\\\n    6229030731399071174742205454451265153295168521119217101388241366898575581260222751886980378363\\\n    5972603678332083792190523815960169017029650354819642069948155005260944424217543276216355713581\\\n    9878927524090990756793660634417556405689642910060940256238574339155844292287478890792135093379\\\n    9785832512347324873453529821006731616862980213034988736817628947797857109778433884850847223404\\\n    6204892421721815411041101685700207654146393631678997094801549256135255163465245687482255791298\\\n    8990155500258350400634476203220003950173916616224486179069378015582400716012770184870795889796\\\n    4716038008209390132195022671334304748698902647750282249219201331492797329154577270435141159272\\\n    1150087493349887027791335640531041596556770870553906906039389481983865572468388193252914140817\\\n    6881872884080358936214635008522655703212312147991347251376954005083575312282331340512392616708\\\n    0478063032840146689286125176500680546281812168856347750756450024651124708009343133818574626459\\\n    8978407144137791778448942201251964502066991427556145730986682907804423790588346336446578438723\\\n    9671192163252426303360009071434573647832089497506938858525399306969539887249766325409814654312\\\n    6443164504399658501230930982112274389505351277650157323672001750533826084308487124105668446604\\\n    5753710060770705666067817780859109920889298189754701206006189722734729125714444167052524989426\\\n    8776340707945116697405658686907240072684675119877710790633475897792141502235817226407112236848\\\n    2856550182049057333727497215442037000806887193277074912089715214955138230909435764468941322688\\\n    5011798462709265667398050165518523446212918194866201719452553518957371636815959437706211551221\\\n    4572684136800858727666963960198431862340901509440598928165099677628721808473844277724722232906\\\n    8391700134982381472442346253923638241756228475435740288722377403412415818633298496172680071866\\\n    9214264899848320873526568579834908661345247278063333824278681692344063070887410509285636941049\\\n    2437760533514694880782690202335747512761950604086937060966681935850210514483552818352680901103\\\n    8104968580887373791719276944958214904542738513920343008426113940479437776498429407749104529015\\\n    2309885811956692055307463086292477205611349820677446267963756889713850513815929016278806218138\\\n    1651824689259452736547519941940342316768098587472920201705535685623645849763073287067918785789\\\n    6865368636202035640676334835777154138872749982475960978578244201722299380433053442722597305855\\\n    5567369529606201517336594639456356207845566484804560915138613825773812573694116753768247247306\\\n    1004291520862535031408665310627348496613468494928779036352361786572188541532123978448056021922\\\n    6756274767925775249005315539779855237470481361630332084265831577124048352308209277332457285227\\\n    3531807574440634056544337172460647209598725210030292178687250679374227229255129989551521996489\\\n    3194829417647113375162631668146091456901052564983348606495537736976977303390160584017870589419\\\n    4586713782760552271397097961595763284490335182686041112360198556008413489955149191595295283421\\\n    1167694166525732977989389631230905548735688225560551809559482446093844469169878497105317872883\\\n    1220413476028417684212461495571454866724140621847994279691987761638418250290840561175215600602\\\n    3157549443526919026845799984252334682288247807789589334898127642982869631861438027540572638410\\\n    1854403039210925782243384807481884488684372973976653454353572886096140410652188159428857428607\\\n    6107033794763829004215838181610063996907670015736462421504595035272841211491835837360017377720\\\n    4739407809207278460449480094296450596416393237145615812798331005733994618618982855810181060155\\\n    8099038884382842580754144674722794240420287560245095921682325008972215683096089847411414963495\\\n    6249643428209919857894458820323429288268857685361033634781643201414745939888363776959108106366\\\n    8714319924185296228749525699962912401616784764166453918890174693965962292811476234376868178108\\\n    9488810199693950273106887035332694087363056896991983450492595344468023474899724022062302495828\\\n    7387081610893863066631164591337129739663712552537954071661216002089056382693568316753655618419\\\n    7264654740315563268067284245803999128715070817312843014052311361862920118288739119745764531518\\\n    3252124935838979745585457214323467638443324488076423416544863592031289654349077818592490302323\\\n    2683440486507889455282485065619010578926557054711227000636923662706860062677093974887625549445\\\n    2972278275588405879860599906647678220717928252797630955978945261568150104303341918940525299041\\\n    7407961266469689424642650708095333671015080061033862869015148064096519220567449195930657020757\\\n    4821172201403745453140306275325349412426644627170288430068400218002167099800656897933067149214\\\n    2906963175720383700014916259186843923879711973526513700901213877192785073443060724327813420702\\\n    4404100457157880363953460334626603325765600933529719622814289820127086505352347686778125295225\\\n    0867292595832457545311377284484459393792307151621208826018692417375857446751154638514512742679\\\n    2449829219565957253090259947235383545740469386454830534465633442681260868904606008895481597347\\\n    5927211292923736584243702691744236473535775054812829271775403492233411728089876941652021714583\\\n    8754061493877148060529724339832928905855635255854545175542120198556120784687721968677917847578\\\n    8745687947360001258988202693440265871662365856808730083502263575114082741609285780160132164171\\\n    9678405304322128543208515425686074526336575695302581754185493881355832966614785003005111534174\\\n    7743570317563410007405121616874646123952383991397817329093504812151881743523744407254061439943\\\n    5607774101378806415185898677106264758640461213023032175132587323191868935967530634101099863069\\\n    2453423022354595049594702341955161255799486587974772731646549794912328628366015065281605114049\\\n    2200777999275325228763745615210044100608848194124819915023943821343419779857115425919735591012\\\n    7451895209607448525275500225696170116950213457946006269715550167812135215039312187586270277626\\\n    8123764239746925166418203627359417517131929212236240490734198516272963384669872193908177785407\\\n    6324965351863526625986866867157507614273431157898323810171562211340341664148904504719860124630\\\n    1710856814899216423006080959137658133549385189772394437516322063175401606483454164645443490568\\\n    7452594213173303982158717829683932543373888181529577054738491434375275637334671612486509191684\\\n    1088282795876277304922531208172660543149410833581539637222033463922277269507189608907172648882\\\n    6958324435114474662015447815218440266657953629040571173179228988564745491921883799503026729437\\\n    0399181349319461226678017278220449430424280856699207446003418932342496632085852048437270119887\\\n    6140787200571768645327318093299616242631619906991475399337315682259286766872240857968709201597\\\n    0585380383261354116629533320062175445843324520011564955148208955059878625004391135027214972053\\\n    8677248656590158060437606358157050466873202473312205965033204320115845050101040871271735383824\\\n    1390717725821469382213435617921030711491372925721946452793019578921839602038683441794371492460\\\n    7674137224458545035242280409676214572348318272474441826013548335363596911613960390486286400785\\\n    2695696161909752701783972396560592162543526849102402597284202398104789047430235028406104699664\\\n    7026298482081276994140991350175642097342829575671950557999917586420030037254038616964912561456\\\n    9898635985061356469669369358387854363470489239367947286815253742866749012084484730715313791289\\\n    4748324414711794414633666627021982050670430820095461677318261700388461038922528430656256604429\\\n    0832538668063262926066134215023061613209914539194134185059205335944234268382721016522019404281\\\n    9597348193337881982388384854885336670376144152613460325295190436598733665803039944668965339546\\\n    7024455859117727895018136486055816886862313179736811502606875367832805649232346890824099596796\\\n    0659649786331583879770562506973059182443902649210444149837171993071009158825237467721004520231\\\n    0952119710820133970942617197832026312747183218933432097378730661544969917592574257675185945321\\\n    1258891620035205884313296766858381460987713253593857769402294445801518121173783871255234379176\\\n    2140336656040905994274590571792146362932168238296122706836078564277846612890914893808445712702\\\n    9871009333065547553132312768797615834767289432826953823925543992834447766650215988808329430438\\\n    1715420708519235103978083713904821021399907106798937959833154429887557210014138052174922748082\\\n    9880699609382366838806284751070228442024361572806379555448576179598453273717237788909370957699\\\n    7222355995929722579282273060087071062917829843279432156249716268898048073401743701616561769303\\\n    7888543406204848014733774124146867898570519741067910853176820403301719139491609928572844304672\\\n    6867632500840641418903167504344416535126328948862403942978506258210365096965174090321542859110\\\n    5430525452899246396971818955735222421362078210682118999069688452775140521721117821844000071460\\\n    9929684876202896402796420794754236016640223372218272640186497042006176520634394906655347516307\\\n    6679113778914081628081008467067791708536769234849862929835396355488696901240994014908253844390\\\n    3641586320201199377179575784908980366160435403236162464252406073233705838873822430327947854502\\\n    1615599139900915939068211645226913565408875983948706032535642250221386127929150685545925380531\\\n    1794607971387952634894174291230707083241646823806868039536791737611437959747932665082810905451\\\n    6311340367861110347297760776382913264925895279852621541993088693176244571555624950920944175653\\\n    8351257980336720894557778012747336150377677525158275547917377936681479663710967688844117979708\\\n    1384601655354017628275894669075666215681759205914701450020859578596855118499533636361914622957\\\n    3582960735407410271262875791141515418443112835071727430466625782354142991075052878217236680409\\\n    8706655756311328250928483954345541266744481072838607954585560920875679691248936802645724640337\\\n    0036680989974947239644993033928457284918636613881265256670630050460327682511289172303860336516\\\n    5618182171005091192842980315745277951129663151784494795078807468352804289600592723583378476303\\\n    0894381496612651213623037597580853044351010064044490022534024609920963832869853227324313392351\\\n    5332752052836036946928903587587556230538011144641642250836404114394319308025211294488759715170\\\n    6927842960279598213941552315784134417761299907915527081874893603966369689211275323835614947879\\\n    9251756746475419840650474923864875879040839943894504234074162677374018765500750189257619750460\\\n    6821961151001122597148995384029472966433502730849440211043518317392712645009961563113107529286\\\n    7862075278189270272214257013813259840679364592469684096396139804529573552893412150177614938563\\\n    8480151576219698664312297721749665100381031034101523992147595960259863937883920380498039275511\\\n    7942808794402342584936956282005241513662433218093957275731816643663771397468320663930590825464\\\n    9370486805247353752731701298114667368906943367099582739403521141080475593679755121730052819057\\\n    2927707551130055025837440648930260752573040369683832330074603558435130304289636838594753169166\\\n    5447078849853496009361127513979809915340536052175868069007922860542341278849460983244366105920\\\n    4705041275698228046450911003927566696981133701887484717549355180333433173559895641464644639585\\\n    2996211788413943070501164531365835989547369346976580995951810883757474160016967423167274851379\\\n    3788490101727950103452954847354776381292997782301108423238511918139195637327788957196710704550\\\n    2610498315204977772313754980131813314478309130110951044768686741445762219604120573475923171988\\\n    8126002379972111225685742698469539809696677356475848259227610653392070246208930108576197342690\\\n    3560676857057909324456405838515923471068005442560046722719436683659328067014679388196812354551\\\n    5694035237305381202756610859509751386793944268141155060195477378355748901318125439810522663795\\\n    0031211998940021282886677757335146860324523310810881298591999993489355118164428174415447679002\\\n    1612598823778813144415999735981724478807768275107484755801400873508229909260904003411679423148\\\n    6624296615897421119682682951337693432255281128352803447167421115945202103126566242723196338104\\\n    1764615817424358885268571519732613404336587502231085675025735450271193532595464123695181746471\\\n    0751434666380462184697457143228852850929788652864022836488839713493761586652373140275566551958\\\n    7678063872458870251357993557035276713681095572830270383635172586383286771988129112365503630935\\\n    2094881805323738681275274704391153203346291610442370541184531846755725771833424354680844047911\\\n    1577474880736300036736910749572469395648912082609320631739048892605304668373494429346772027979\\\n    8221857797934588214189447120205637937837578751620789573188005542128208280063223073043341585106\\\n    6539793894958693524835431656109377667016499195646145503794700182066288298725538602019884344334\\\n    5939501054996029105693704899552570644233460642262933395711792206376071736347911511512553020323\\\n    1996246969722012606569938384270206412537591122038729349019652386647381626516167659697638493354\\\n    7982876016910152379448473182339512024312836255777622930298184960046774385959617147245935595844\\\n    4129311026518544203790337452447980128333494803869033864201294550212387270951664607667609542663\\\n    3590124983182740679132882847075188910515269615467747331049496485489895729707646679305461246669\\\n    9779485302648856172578178689174921352963030683102000856475003002645710067196205686371661268510\\\n    7033186602957344633162486774193566352116858547393068684873548827437524535902615175153973051887\\\n    9090580822694276563548331048087153146593776271222112087600253698301408268279124787946513650835\\\n    1366141112930344298252952541588728774344197749313265362678252900706429098326753920336268140943\\\n    5483922036713579010476000309179251570650240218334566199830953177770371298723294247194406820777\\\n    4364109852883175743749595043468924954257594486173747998601155410334063162858058118830001357595\\\n    0091544367414027324874102910253032587297494371297528176635417009339524571705639961366681451192\\\n    6932185083956039290092960584705257630019605896406942444036469516710571206510597212789212180017\\\n    1717814501199475276345975125970254537776160864191015863939240925105672558303864099894386652142\\\n    1401661593240095345072652144329349690324518740353659365352766132677054414648921365019667865820\\\n    9545390085146977086174731195687912646256586996395784052125503025910990627354599592082076675454\\\n    2403318346872415784156288833846723684046973944733963056146413995217650051271913576590957388414\\\n    8232069678888318243903338467640717029088545721475354797417462151136940072503526753204576611617\\\n    5772204913524440969206128447799147742001978886467826449865750189554788504396143576794100097806\\\n    4359950169959277035794667533197357883346909872785157805018176165329287737189858460646860346675\\\n    6874476148313308124763432196771151194887837075689026870831545997938116790196180051056889090369\\\n    2604186110501600478578844992374553643231683420499317573565011445829238217084909749005563968179\\\n    6977712429836275465720429948632411551740770440674660749785753505538750980320701273183866844164\\\n    7660006263956287651584177890152375958376314344068281732966616146797464631224730530296085244477\\\n    5672398898107366127983256680090795477347523961289816073118694033632474284257580937654946566972\\\n    5522603773038368281171946872188909377488931274789146405916908225126629500712016150888366960560\\\n    4182873268646889456736974716363359069701408069742763065192336747758204282546388735435638260209\\\n    2291935269702008761703242917240319498162567900212733328784979860761241621502421300403036508179\\\n    3771149613463449647472451285127940998938426004193424002385055552373966473578330481664492992643\\\n    3053408962997148752334457062191359831970050382632853571230364046856333007654450674177461026497\\\n    7381228259135541781207834935524319374090579565863669030683495083264247410416288244356054555054\\\n    0619517420754942641839761324918191785734373180034325056116228297434612071579678311181451277680\\\n    9224041272858197631468707106551546571123506671716347284037622535259480450665162812438211791619\\\n    2150258325527891935775057365967851844093873152544238842410798463392421184427839074194792266793\\\n    2226825996564397301434326603748264893410431722273227528111093004655271434328977872898811536534\\\n    7217764389900037631496500300628382878747937032838330909459519497454438362169569513172420270655\\\n    9206797238914941933763409924416555952933675295847146833232147067969518742911277674725601609880\\\n    9390398063002892741896131511260331859109747526993727506045282097811924429687174035402339050816\\\n    2544804344016715148653403613468805395040807532248420993257770942503488520173655582076591891443\\\n    5121152653725349743680623748815708645699463999304011370134160513312123485112492353649302654499\\\n    7612890696827103722771328060928639487045579282211466893656478578205481542722594091657121396932\\\n    7049378356429333959561931946641953272377371414761525830685887185937029597240697012120232818867\\\n    1758883724681907052500930628860728298979378203008125410904224181077885041830594071319645815614\\\n    6031682381014939402828960514564397791307198726553950669752003929659232167799468007993705248954\\\n    9714185892768835922972618200409985823837860371563763257612228109699592462672763012833647155855\\\n    8955535062855764200753636778657710764490361988256784766028221436039350161549368198182824220111\\\n    8911264250185341096378082239774621430866488055139131291588212431359340561079452319442580884630\\\n    4599554192760056456598824944402720828370718968121594480154256071372266315800379146754089592434\\\n    1910367406876998542625016425500257833871425828204679393626543269386378373014554642190098753863\\\n    7836738775609557759386851120128069592088305122912592127317003399235356532333893160684189854691\\\n    4098497914840772579470255774195446422811578820333248615172218236368519497639793401191509389471\\\n    6154564722061021818005291644075735465002169519283838582167900561146063129789599478058340486989\\\n    6784634181203623305507853270846636705699473754343800938562548364066562655624800923139825749721\\\n    0642605681207142837485247552784341132204885163602851795378279144642827782122419956960677402424\\\n    7461794546945854442638904254514983746647162524055123208550644675414585628554781886648434426333\\\n    5322234218490336455779061674807302978461187717669068300837180532449554762469821006507293218786\\\n    8496930232458229777835876317760920848744116822701626924028902966932871375313021049050322719028\\\n    1948109720714013196123814320299452547726239445593644680068878389226191151686733872864730889378\\\n    4885288783569999468905217048333512841491502750559497289262403316881791363347472319309512810114\\\n    2093469877926648540758163658938015089655939639561588974097703488097084071848787154234063341912\\\n    7588219327339345711887881210452971974827893611286325834499386985288536812814760972087774427114\\\n    7943065571622254745479302992775644034229192910742034570611986881991876467013714681755671430348\\\n    6490121511239694802857839344452478697504228614230277970081546455191356615931245304590318038061\\\n    5660900624981130447686515569127707131417578091421050243665974185359374536526980175378503648313\\\n    9575215892817258724667746631244047665539227583647224340996208013398045162234930335326339569299\\\n    1214512819349639457343947688583691579230902594008090106813298662135283214348224627373504992445\\\n    4402440868194535860344948022927184761819334781037154311983125670428314428369230756858156775383\\\n    5315432634983391949937824571840443558812764627236660971876930432093812283901218737426238598734\\\n    0545293889516285440803645139179086062465434790384181456286998946868940229666041882845478660898\\\n    2153389125476307866267265748025353629197711404832564433645357725936085295771852346963408290907\\\n    1155413444342533646938979353737591133669435743206572274000602829274044657809319833962933212341\\\n    4477381088424882341509682042996760485908636187405399974933323949010088171961720877161901054710\\\n    7264628330286654845418065955296929664094695210734058370008442363159767889930429339996934060145\\\n    5444840964541100486585350166773239034310538515503401602632570608578687835814662291905384717439\\\n    6142536326044441660075537323482814308039974991968068182583144298358666904197613368688313953171\\\n    8436673834231208467961662431053769439774266200583590115608497736975415528337711031927813098483\\\n    8315711640682192068607281780690613177046049842483058034466332416390213959323064880179056016470\\\n    2359032851646726068523851641633863391451786271874422352508827678210235395442876037040798872392\\\n    7044584490669568937991023921231345557001608315082550561469383287279369758638567622719934472787\\\n    6518987455806401854017690904553314277439696268564209581631824170715332006820503780127750523195\\\n    8912242520413594227025078074127768310212330001875797629724073771326221694729536085461466083690\\\n    0268422712408903516059343425930736903907738944619726799480914787266011370616421569680104630936\\\n    3220488299434661103273417435316927707924168194870836077862985874185737972019652801284711029652\\\n    3977308035021922844040691178029383223776248142639085019355923942417734209250298635751874377316\\\n    2911944120821413453289427769262367497749357866017820515178793526860433323288093455157491127972\\\n    3376187964946336299009513631959179898274640049075954327095230191384870732306346920672704080670\\\n    2965171961624580204955939068799186198924507453750727780444894050561570514738627795893952382432\\\n    6435915104860444024082369578642894581026335344789720736155352684537042994491680227826841607007\\\n    8979620172604889474257535032059436540035369212662597530865070490292789964089276579034958383729\\\n    9543764539102045944461976549099713504739938375507369331005311543818292235250634144650738001915\\\n    0082342022954210769900406093732014037566746075900581014672943213610905756237586463525027301810\\\n    5623078610012157736390236654447129803767073576805097182276633963055814506651782397956944175415\\\n    6531668721615523839339495838101278758688679932242268253646426654768453281521083253559722020626\\\n    5304220098763753534757607356246062474417510199014308932500439879945533974340378113038725154775\\\n    0507135647036818699260293611864166862993239468537638227941123794740233117100305872049290276410\\\n    4610749079246780277540154282918812302945881369987763224216091113355595594503076947861047412695\\\n    3803850196012780024444464577632814165814326434170611007550364188742303925069842993946050959421\\\n    5557539104495141057166310108119959053767960266492650355452648431666941175658243420732405001539\\\n    6961379508066776142155127835896739628057251540707540859283917054291330075276192591261344601705\\\n    2596512995828698910544609888058385931072706042618872140059475746034513370359761098929544213621\\\n    9428566452693645937638565828924149586175715284688378195488711504215356114122749079239806961218\\\n    0809353213601039090295927805482007563239961372557592447361702718142263026522312622413035346766\\\n    8421665403189553471850330246834780444914446746896981904122458302266214489634272291208410176867\\\n    0255991335920973591026689753096213892161165449860151259002104863639405168173410382732709343256\\\n    3792155547930259938818249878841188398444472356685565307527861238133252979488348299106117547861\\\n    4074812763256649604626837271317574934159792583890974148576692621944849113626063633981523284395\\\n    6339656673758371343401914235828004118692410997216710718037041947820939111646667033897715696167\\\n    9098416329335279994296901851642391529962202799527948986402277668551580354796353173881662092589\\\n    7184852964890170104491806227449588697009470425154672966393432496442991083972159386082111030779\\\n    2676383915169674503995769655065158050360993945366192452790625711288076506842362816515650374530\\\n    5025033920464939177087081388984556674214992560293393592187053135629848463351541953972208682625\\\n    6427703994729588052822093114814500964417962817818104067866433691771255581265757118188616726146\\\n    7245245810920946322692973475883983816041414185992764390686729783352074522630755620639345773372\\\n    7925901658271406721309950286627435244994284577122865429702381657641582551663139058811827569502\\\n    8322734780398036027580068620392628135827498584177211224727797086374006533698523229164978787950\\\n    1558767115558980130568752254552023089236350063300886541886524046112437569158816528812553963166\\\n    8422746657241456267252590009842987321180885196614288544342472084803557738669452478801300055384\\\n    1688647543528673059333624482499733752559744235831172836033010662691731232383770096818815349065\\\n    5934169822839799923316659022540402753906587247801882769557347203331333860763751700558976779773\\\n    5555365770509582095853619431139570876946883549398661249690703721831817632977166487609859648413\\\n    9681240095918387574120812982784326604115193263717311821615181034647009194284362092147538293658\\\n    5055090751463732120805462758737087578909864676148584005146445320844092195030924372055083687910\\\n    7774283895590229118867724562127638201008425985328248946864749162904274593552079708024373516227\\\n    6058875067455463574701580690907288875459090749910752258864695671350110944136154205945350815178\\\n    1843875084434772283258181242728485431251291011281638050779293172697315454690152671475714612998\\\n    2105443733801545852817689597980542251528369829385584929004802254404445795438349852931834892334\\\n    0914946330055747112912716055617999926957484770316432883884459871162295102532591619305664755022\\\n    5666780827540670983245209717513145146323840267033466145374479659384299357050179334991848451116\\\n    1449137759653490069752959351502350517874034196545206969502043228396825878949323075082795589283\\\n    5401819020858949003788562616695029164895463565815890256810419644992663865897239206423963266151\\\n    2052435108908890394451764306696783170211905377494518483339752679529171447917598349433086632103\\\n    5289533230166677004114496966223105979162647767417389692411543948266577938844472918163949212632\\\n    9861445745086882238196323543694169890337698309387522968317943607616176891239058191872641087613\\\n    1967668804940538630442784442520314032824196315670561302966397124745193913920471618900882302073\\\n    3132472762920265550182734184585515834617473662155960135360913107262018126214618300473780208571\\\n    7013169037554364751194395472916490793276353828967884335630011456531818185349915254903061880381\\\n    3112871068224603083398685336340755296286280342364655136862243496028038987616467925423222873251\\\n    3801812113198473904060746758901745464443656322070075833920047169082468604706388671622506166643\\\n    8868035953327101083994706793199418374165041637284121171679474540665750232399167289586684668845\\\n    9718116074911002504285375145832285757733983477780830612680951477475592966410345214418141182460\\\n    8888287309288098026737666620113008005534710397703131733038433977715267347048347387825053655383\\\n    9408343057040312178406024633228085983662449070901349730077026611354633200812030901177130000376\\\n    7832902342035677593431867549470228589055776050404760995917270562705171065431489648305398508176\\\n    1714968049763626668592892112745943483386748982438966245225300833817612644017442481607257295785\\\n    7484560642871140207496278419571975387910841558760855439769513164761194059113706186276716374566\\\n    7566025794612283721539389271999968917749186752929367925836930373952732988282681674590926508352\\\n    0973929198685966875430159638417258945397740769789804722803332163412149170235409365316932175401\\\n    5178946183664380347997226263940823575163337365601303521736614564884349736321434465031864572039\\\n    5683481314534015726561439019062783255326889168086990307301944602442479999160507928964842061736\\\n    6960847536148808810302860088323252516084826659945918764601781216199100066447004806079492957521\\\n    5094159918402662918456180113383044264685793892873106508987126883641486879950714851665550932369\\\n    7636994088460965561884946154371394293619429430024475045413284811847576546559118506845081239290\\\n    5634957003817498244829313393931880523607075986789809617717711946559656156898657874107238914923\\\n    8890986906690570400215583833590047328382598454665566390387969991874064130034609353294956303243\\\n    5957896577993503713851071915149839368753545717682911263021000234482247684679346201397353252425\\\n    7044935096949774702110581885960769642059344360853031653148983937787608271769229141649677176120\\\n    6587346161858832669344248782769167505831176804623833042229650429226172769728025508884733910630\\\n    8662017647686789651533504315878139692243510121890758242868453231399502708624847852379272766358\\\n    2391597874008603153471479470046794594964223453765721949343313032134707771392920454435693715401\\\n    9171663337736546360887793758507412744305463474933964513314500112590537503925724610662978852323\\\n    0672423865646806971973420687817844957913801146252193592540022999683239395368327092062157505444\\\n    7034055887826741484082963294340908698624262162566011703429246279613410637049989846057779072485\\\n    8823095383001437367259388681212568720267919937157307105815155769658012496069896276300213469278\\\n    7094214055946575559445891646582179779939852306307717818820266987891711487708859319330881503081\\\n    2398846908129385912641886238975889274085449529524988863643278476733193747118875162483136164718\\\n    4928246281506763232098932693223183502638832642280213067057075029804183544745141789623594132541\\\n    5687981788507003443433098256832165031986633313725581719861054693624440497294885055883335971888\\\n    1619472303218915867380389959294128418712953039487089437124208863244374011384685967334983510274\\\n    1128715184703182151833798355521178478689573939573456604148721282761562017155071588852585429965\\\n    8649808179522709386035199937243206642129831550789016204498307174195152293800690191624535819183\\\n    3544003738560766522258392079973157900157179233221768081979429881157584935456362879596535206148\\\n    8964922019646762199900877441977651903980991724889617785807390094625595081832196166857302184091\\\n    6540910674678357072980725391941644884298983085440528956868907720116981230109779422000629707069\\\n    1892994332797781756216057182118914725085884165911814752933337649935682568897377668133323855685\\\n    1293709251956415435945259496221678425923120266945228237729151547989577710238915982900891965087\\\n    7949858179273109205140030842791692991458778482295696449233150976441694203482721818372339768671\\\n    1974206638123762702465257250171533180889409392623418987138014596048513784148001200343108827500\\\n    7353140484345229418847312856843639486603970724013938823131165585733318690967570292878508127287\\\n    2998432188211223815728696455986502529685196314686253874764181508245979652011345018847368628760\\\n    4368470468314349565349309872467539129236658598169460540978056316156065746171569620640059948454\\\n    0372904641397904399919586458890762132620408559685884224196438205446616128011262487002718025101\\\n    7816385838847508221804439509190603355499756452400555253890693777695323506939920630008404079313\\\n    3777709540105860593160319288362404420620384088414842841262694638317540647692630764658418699716\\\n    2567941815327662709833760591972011576438541437491745942467986782753914470169279890911085216610\\\n    4008595228278972035319108170674299697121960644014355887495620337859249243056622342840594998744\\\n    3385901818470749617229330108520960612400995905485274710873593172149895986395062552992392210010\\\n    5188543180932144325509697171807196904958558855619250222478896321903234525194141537909607481605\\\n    6691477760717964682706953863520543417689598797932873288451655275574584960650709220992608982189\\\n    1464966264612495310257010833250502431978965966667887268673369945845265026234202626689191629245\\\n    4284800982747655185213503904601026913875804760331839132196938205807283503449148347275379755191\\\n    5720337357449749338534677816914836736526265597031079036280021877115873505080621978941103084275\\\n    9804852459076095087234787473501698364986999788602454688164208602468521421203533030488372130930\\\n    8138549394789743449289887807109341375400510632678197238341433447878918476786842391879132695679\\\n    2052446026048865690919311565688123740818071114524027669407126172585671772293211786321917119633\\\n    3355110663993440995079023532080994367569302081090295206727727359522277060110342606055736125350\\\n    0715873141621214431441487993615891958755422125917589175061121720401759323058797249454021019776\\\n    7914658461353741014479993861747298512732119399665055876811904154813518785705998869001247359359\\\n    6289381607248906904367111260684294832291843381396503012910337420649256041423935016687445261041\\\n    4142438992425368395296917040299088980236620298871802112765096990859961355153626653689160501742\\\n    9936219642747070849819125825910637308929632870335998117027218222529829735854035189231354277165\\\n    4517783755471461874684583709553445320974091828149585471786866999371800746297553015047135902157\\\n    6321326680596465729224585315655002108087020011019585364938426499237803376283758407627516588118\\\n    1249244158627089147684259422950314627262553342267882015068723017953508269061204234294203652615\\\n    6797045716697773169684454921974894153619786271267403600257108833245873475529243565034569398757\\\n    4658783177361488287488431556803151158515173338199046385076967723184071485754628171865109801036\\\n    2480047953788666103871337173346885955944290326894683382597519381408656323480527738687708104024\\\n    8686379747130896419302978179151561154265546035415710387694943736138474903413598422026845400838\\\n    6806713455926291918485092681775850323000549357322693175937497833546461471280370226410924815078\\\n    0266283743939709168731232554080263130868715979634389245459515922378339706145896274864115592652\\\n    3515939964026221024676393152574119015613633794949672310098368725021591290164701685655688376132\\\n    3506978017018347948635485923216443537457251707970515624010240967532946829304202384244189150629\\\n    9014735104392814493038231056909717543286807185682099088790153141456352983957441175263306717151\\\n    6778953263970994574303499139176408507356292956978143495081021876164201079854322927733821514505\\\n    1612157735578997774457015948819923322155082139457927026980455160125680441176769101017779127816\\\n    6206659794574699528611234446461761482185585663810084701506931918123241341228159595772681391436\\\n    2260615806628405689045001087785070978935111153726166600456125984770451345902814361389076011290\\\n    1396849770474876192348076077497558750124656182226080214952262792680208400943631678932234967129\\\n    3898891899858805185579101029522943811581052852205964577131080428374857463576547014418032060660\\\n    6010326494573773239438417316939748961407267382186886304918323606582225145815959783220619262032\\\n    0720467681260453907526759015503988440708210649631592736579384024363626193034730601075746208039\\\n    6222693369487731174325895446324921033562546917590155452347056502731885213613210053575425030140\\\n    8554208532959873325963612518457460629343720712699077526949350463470401372610169865034286826450\\\n    3276183587852643906495504916212231944451696890960791966560143309910668885019517307092969076373\\\n    3637808282606252103611400518508397960289361012052661194058383162124793168379022643080339509895\\\n    2488371755460120730870976211047195588412379289187011829679594175333607117895850252505761914005\\\n    9992655939216863133966266324047618962208896853165199886549012640628444213469010351659650702824\\\n    5786242576816246007732228768268396453281574949799490494075574542698018395414705785983369337774\\\n    6127312940846545894168902445746044239583122739411208704094623318928648612591207677129315685365\\\n    6261063446995287858277037959147807485419138611567534230006139604912592594799359766957856587891\\\n    0806785585381248609049696833099521449892958226926697788497243181712402377029068778921298131346\\\n    0031186844880702099033543204665506742731797720069411743752478227236053462375088419414238223725\\\n    2016892944825415641626543852583548428048652779684233481237131872957185483380094446410961699343\\\n    2386657801524894004616059840418084930022140055231008928863351061087218498410157397969537154165\\\n    0319005297314430860829504469450756948552591613504020021152846028773229526813580724885722042272\\\n    0629516655288658997947624359524855836267854912531488255891169701834790204208534914186402642979\\\n    9812444640013376481762743916034769558707461580032378629039407912094561991015027605608853464278\\\n    5625529166344194489003366297373952980674132133249580272705620459963518593838621101062024140113\\\n    9193257038387264151452116773217346657029147497136438283266058762777474225953308144404033492479\\\n    9900105552648682878285762522494890914731996538633096669190155596656540816997698669314333654212\\\n    9835647589452315876696949391592496510251411389823883897655631715320460879572170154591018321594\\\n    2943232975070431935398327334977790172402339758862390215862677346074776623964232022698696904916\\\n    0707811962990575652641291908619231997566090157623308136062762224961034598209905823981600113406\\\n    6528240977742294383650016278906104332699491075993943364195375123548023173821909762248141850499\\\n    2523720561951859350918008667309976127156819876970513628184192122206124031614633481128391803131\\\n    1119985284069147666099939770570645896714507678909559529687080061265245819034881989302455181898\\\n    9790049547063487666631635320251736305547328013705094265242400810868365361817109942967243418251\\\n    7229614853060707808946664000688688165177429530676656735021429050013680449288463559480955435315\\\n    2292812285181825919776423426093603705739467644146763024384277073345348630778831533038673580119\\\n    0944619426374530092707232052372202520535018121835822701533018444420712925879756872859318359385\\\n    9137988159662907374208666142120175073420530412806980500964507641722397764085916191285096226862\\\n    5741963725234258142935626018042704557440087460041952289753247178798746725251768861378424996612\\\n    7379931072940615027123093058860468888185450112713752988897200169914054144462161973591853120119\\\n    5747513377342658304376671398699357986540152310792924544028478048191331500397637583474832870857\\\n    6298007743652788050413325098948599623300025689651718811650556903746816446987631130928049261360\\\n    2999591426400807547884058319532839342082320566342065777107180175184525618170966026415356992089\\\n    2180170082949036743822961794981231987331029555884713917353224719201484984193808903084065008139\\\n    8655730352430873854746537061068969492448285088160613393674994871112191276220598889091601739675\\\n    0857341079832336137965902906518361390821553868642863452954497284052905107709197358204869662890\\\n    1823444233445795816905544542434126569145204879502551128812575594127559427016977187005884864555\\\n    0093332735871839423837619815056010265831073958359975166488060049836321006586460396314089623611\\\n    1555936657359517442273679978132344160730786423022346062527389999814907903064046910197586849672\\\n    0242868316077873303217008809341743717418178725426910667278200307703132407774466031992290780282\\\n    8063960636795506758216954079940205758283254967584199919704329906696446060885559806694827627181\\\n    8658954466096049668276676829288322319788142388259782234343480281911257055954402207939371646684\\\n    7272311677690914709140013820267760065145342288684893340514266715640600006517096821460426160856\\\n    0538235371161194957041523912460053536459000279521532299576135689513354019117403750926408920080\\\n    2565723440275595453085769247190476288615666533595245634320232010934535669650737173168971983848\\\n    7042327289250774452314683069680450060183244434158550303083141436630938051526159201942780348295\\\n    8313473680898907237113909947544184927908750269197351871109785916803632490720424234111098415467\\\n    1859630579822167648746921688751906325112590294539034154843606294622817163764843380811497255477\\\n    3057014616781259698607234270030908218880033385981218395446160407894421310346929754765533700270\\\n    4394224604332741797346797025729392900357983935940867677451403890554921808526267954917727298535\\\n    1506297590006343959971942989707884950352950776938045616407845069360801376515819343777930989937\\\n    3896244830811450766031430663591576899431506487830036136919466903670144127063959200672507286241\\\n    3303496393739377458395643055231758937451150604781038200235745869193002177888355589703163964351\\\n    2336334617503053260301138976095333712109710086125692872484803858961944914097530363151894532221\\\n    1095010903368400052733821404701468606723932945601206658601972591230647407904043571135744285347\\\n    1790374852076158841295025408822574042261979385370960750201130766436426882670788259268337548955\\\n    2917703341248805716112092132893935678259282245269649325600084827131059903246193049856664141619\\\n    2577147964047555156619731457144180294434616104674784644680953836597302286307840162766210377967\\\n    5135181593854732387701115789186177606671269897360823742366252477250514018452599411424575746280\\\n    9304701309846462876404092017874137424423798799996548680545202398541093889700734851716227344769\\\n    3316626317628940898524366867773480394686033137734375261638122757570892696581041144589836992846\\\n    6971202326552334589420112348623784988872714222904621909891417178865041830515834617383098608797\\\n    1324387993863243665685035814181875921627281813846867858402105553283344603464813315314430979976\\\n    9430099267071110652601925909759362862258829768862108997592426671026266868541541353029530517467\\\n    1629683534131643392923298094503503885583730984651069805417287635999227031149995115451664791480\\\n    7923467726573270146949069599944195681068810372969802071080231189607917718617578366113788389990\\\n    2246376638086401689599636891010207614739230811365170758155884003942832081176558592774155894260\\\n    0546102892471523828857822132206226654770559753248241089868987930793469883744269150702905349009\\\n    9010682836939222945065813798114540732018878435571896080457763198265499083229561230179043576687\\\n    4957379530875636913211887562302974043695121796086542477341192205644959315444055299158196866472\\\n    5461961689280570595796563106785769533669921222044213191346682068389011392664646922352682946363\\\n    1814845260382153202886447233889906322816334478176172270917005268507109818900854865716760916584\\\n    4114060365773638448372920206739334571870894048258633777795998112567851271057225368704528299298\\\n    5940377329493150909018023678145501372294263766802080427074275742143416916709157535290973121390\\\n    5688063141261333339704683540438899089222538901055184990196228178362911945379857461650978759933\\\n    3620052582032832384502421402209704275202774513821055384742820375601729429401925570080523038451\\\n    8744704638787413014359421557646438036047567066598716083573775398125889871562674530744772276482\\\n    0279342309783130622671431356722546741743892570642575197982873413133069884856761430024449869267\\\n    7364797340727439093687547888005761230071834405551378192610497164832382263647088880766127311145\\\n    8709104206910311997735961437779229778654494137030703367848584538508012651146727136393273025408\\\n    3579087453411685667094983013499693311250743179521345001013996879643705119101001111111103326499\\\n    7382122597464259836174635799533909590997197846566535141464910439874960053498690193915997993029\\\n    7405964432752490962311594627708580680239261227439222290280276384810090299027508711111987106626\\\n    1484419477044366084059159169855802918024948005535493421981768679282654633332936657595399559252\\\n    7283756327836370486694928382310969226023799145416217891526924108945045235520384723342588384857\\\n    9741378031216989541044250252253955128117299343713930388588775778041198731595291830419875260420\\\n    7574536768899372783614982173615177807280182366322214470780656735286257891187727197908917034831\\\n    3703593556581625152273580886509366170057400684264606097744412922694633551663224157560596320501\\\n    8945090444671510600980629013993264734681077487379351151215271341443251893294612151870477377262\\\n    8248739335519586607496223224389330886838621808514962978975890531914049434990534269887037940684\\\n    6145090380102099604081906456398758012065587518502379230224065136795428031985005350008682767618\\\n    8328822957331990594846787859439347052847519720661078377057675924510149843954336122629068906811\\\n    4687862008045243431651326548209987144209423867816500599664363779619367951467895624442310782696\\\n    0846646842926942613121499577429324195976828235085634903816918525051898151147919529787726621027\\\n    3207090351728027491225621224496143144888264847930917007111073368719180733636597450201840521265\\\n    0729108668590775799728837504625566165165217384856394557185532757894929874731407639225690835393\\\n    1535602818577962472665923251858615565435198432276877799735910440455702757552976646530621423693\\\n    0481040686249309448332824347610116373443717547844326293586212594362110692039098693113413689817\\\n    2655352340037062887591524142725475271742487264600273385827440204062351214857773345136664205246\\\n    1745038296368391797942915978855895298287900578792026850529990818391757743202126494366105523296\\\n    9247128342241809359341956127747030206699125226571582610135118125909839864810599605303574722752\\\n    8407529760773118469512868662035415823008478595049823552706369478027630133825992534721087598544\\\n    1314866349934108792402195104372618955391426277174624317792268432046772513383844359853918418149\\\n    9466752309008566419800106961163563916745412757990621466706502950177826044299284945534774848585\\\n    3576482620508662535630557051457712554825016445972547054656483171737711783903076899417040759642\\\n    1576902237942735882380235235478808109980556573480692087788852334798088456737763100998880822839\\\n    5396599232275599452328269290687427113322403041706772395939028497266980547746836975187963382610\\\n    1531759530364663768498557805155071371842903318810150249454283721522879471176645307674276724738\\\n    7197033437912044933979751862420837735444997835723174979834897016329090656540067546494636340028\\\n    8109209070748021017595572687290279808520163047549485982711813180020281111836859170112470043812\\\n    8477192045114155543212787601741675230727669102470222436372436943621748391836024469131269391858\\\n    2817435954255298160333712431444509149043145364731366646908889380162872838506025120708497918706\\\n    2781473969812352721466077565864985795409874590344524129721060987759913338838684947174676887246\\\n    6273121100288932956155557717085375277660837946110861074017386729064781069173570868977434479252\\\n    6510317296640961515161553398280302001716735067720720037808413130816893601565222081711354449105\\\n    3973393603227679713910139601578727850585442861846156283044668260272411671810879267817925467111\\\n    1788171841125738326922621630044463965054157205170492794780048252677346440960888514193219964141\\\n    5779390750372084081149942491475780059241090108238211700755144402597467326212509289803328353888\\\n    3027550624456203085520611124481322337943389990299645351391611578771473980866332811987590609275\\\n    6508080773949750733230448816262214599498765751459100522916882044257576087747184378929427331553\\\n    2688782397105963505274453006903858641666171471502325409364352411705204588749623355855832528896\\\n    3233354027893098486260958364119943801493510029034189325709818088253155627802660033962701986758\\\n    2558716226235997448777595254923650997107049773359750068550185244851433993405178038380717984545\\\n    8267049693297380927841361173033277302679153312439627094663573315371776108118793513995175744449\\\n    9822053275550253664030873456867907723730447271917249698398003227690073705988170563694035940128\\\n    8250256252090002070263313946537904469913221999861378394541599745174007615700989635604479689471\\\n    1409012131030990668380818622406845051739258632127426753587025315234141306162264312913511312132\\\n    2607307051138446113169710639891111353416717486767325019708167466830590156435287098832265237236\\\n    3566531046316945246277869103348971675294910414431390603391714409246795122760157223136463972669\\\n    8431099132652121730284294235320935892932056672112961050816055947084848346790624151972762356424\\\n    5121046482641472522163353424203616636177466764683145551463531746387954979442576662911235658301\\\n    4467044804467383038176788683126916111488327440921104267080609997925133080197079369379981881049\\\n    5206240352589350026666547916655425860861502317362677802389796975198935557504360970487079997884\\\n    9173962101399495258615078826415874030995445736180434197348163709517340119944333827748281007393\\\n    3332874591978738078896710938515676710103785355640701830081468256796153215899329722816630829593\\\n    5305095806748185759319352464052725322880027765787672595865005774823130047348205497747783636893\\\n    0827152133464724025259914564016505469403967577289938505103041942140124505322311798494194241174\\\n    0363638630211489542079304194140355272272054329455822782012540230330247977269899697112458534872\\\n    5567967401865377021369760891785290737098916195604247944544272603712580213095404070912094744294\\\n    2769353476441266318494853920514211288008020008434279536180625617350217039092127916231135272198\\\n    8458539134580217586279386647388215464086539253559817977876463187329999048412443790061410002136\\\n    0814317064736463882968538795218960060140459989107586192835238726187459462721003724184664046804\\\n    4496983598817222947334923619077470552792053017743080475054216430273718391382577853784936364272\\\n    8035822721079675296114179141761743639348940755345455983641551044116009469592861736214783030132\\\n    4928490606879770252313837781296926418638999596462971060613800417003343499882231297846177134262\\\n    1386659325380963500838961521451440658167412197208827922131356304305200925599554186848754404590\\\n    3118242860135226608636773105774294357495779435378497492230637420678020176930421524500632999759\\\n    6014341915666690634809887882004446344218844006588720371541425578528625333634505551035753930866\\\n    9003519437901899732270532201946519114434999333425575708631301118393870181548220553823714574530\\\n    6260001512644848379978802159959752437467475811108467849397139508106934990651870677694111578327\\\n    3008296510449782065996660947411634962462348185633941868124660941799792141200537511271559328057\\\n    3666827691389714774035555357878425648703788605441876644078562000623893438282542902325350869993\\\n    2134484794547439451983248884046571696245775194661646888515041757331149177745133036956961337073\\\n    8514812849396570696366609667310102240825861464648700606581131036347414318292919438300600591997\\\n    8282565044305307768393939937841346124525281067811879466950015235499071391989656187070212634860\\\n    5659620534864486509023304938068060063945886069184859592917771626985850595814184719345760594755\\\n    6762197305841047329304235456872401848821638766076920923208751421225263264422889098023362334349\\\n    8901880590884062590030967752109211008387568983691516225788316901460599976152786666819721478992\\\n    3897649641964094512313470453226081065786125747718705046378585187607245948891354394911542248327\\\n    6230606791172790917177461082403860576619733803548008786851143176709644736741112942301120197302\\\n    0498635037884701287650153389792654364912249590703065684631694935871474676697226189948694525072\\\n    9072035146395390417387795224938280613997277840310899138432450536974175812547749774482462744417\\\n    4069555856564790963121426448820142129299688059354132193611653465850324083259399375694594360056\\\n    3567577435150098352339803258727972795445136017923299644645545269882912601878395430633576813704\\\n    9876158139398133849810260814136923116902245795048278224577524996597484369038614551275801110414\\\n    0608608668362980192458161119385976384347064119651618863261805636888481839987202809874027284828\\\n    4609186103441229886206565861563821779604009296349785775848719569555437210976353831299936069878\\\n    2952336728331502712321447795397806558356189245639843983889210095042305650759839990562781498162\\\n    7610213137786743575591227629508148423238344390735716663588603998510363136065677938765889068166\\\n    0682581147806994831941087593837374406121988777422021943662595530319067407369674495423292419438\\\n    6665542007462329359509552825041536100408897817981564710651273311435667251380021815947955572375\\\n    4903013948483698294298989475840714307141807525207122422919375764543170888817587849282686829348\\\n    2110614244053374644571189498437925341230021984071696790316161429455673846553874776483539932701\\\n    2465540112136034511383383865201891422174022966786315552733581682104783381993085556541960271355\\\n    9319242474855984726178658540431497632252158917714375327353366830958663708607291174453953580208\\\n    3742005149006385409932555016981069922450436353075526436583871381093601553129218182618396748349\\\n    7134464916972220204287796074268182258168249048227696423278404159208727690743319973460932089208\\\n    9089485469526151410288651472812730674798236664225885628616310388026511379744230603327764603779\\\n    4997192289225189249307330035794887846201604414809785766543856502664015539827842562629863749690\\\n    9247065010263981075426004891073456902903341139529647279665001590382287966372317311024410611580\\\n    7390610829541062441461463636470601212585565806354636700833982575037573512229259327331256734849\\\n    3172726327083199504469594883559981248662713845657629885747766899734386185580155119202778510701\\\n    9723314440757359159408174075422717648748538948092326110406931150911796306054561936424268637522\\\n    9219054149711372127081564570315126229844938640929982262529905530700331200261034741133653522448\\\n    3904502757214893665051325310799123654674245793835356838592149569231224178673246235411354224735\\\n    6385465223902133906961919998116518832096211563478070753859021192672308526207868811159642870243\\\n    2973145780447738936029806496094417868052897558635607673465004943906121014193002496858122678838\\\n    2481097173609126948538954585260528853995492794522115348450667919486866013935048038221445358934\\\n    0392588268893204763391290021343522459237369728263744273191700847661417349764702460716326677687\\\n    3813860413322111867693167667491113587743603002578564405104017963887940354664610910746457673576\\\n    4906178913357012684841199976751756289676984939333583532218870314376784582677338718831066544609\\\n    3203503557484170221210738228143720530554084231909982408345989292382767698598353100829230179874\\\n    5781874935732324454409854949780867048300521439254823356421683512689074470149104135157151814418\\\n    0004280912692269257631209465540100470634325820361226242619882903228427429079156151107580477797\\\n    5501369019578623174853229955346285191626978100380736991847868123476360819142824341748144633302\\\n    7248263544757564508456468106057315393975114963210908869512239750045882419814577184923137556324\\\n    8978186739561283821455713168222560014829573413992650105062315529395500137363395162923517406877\\\n    4231892665047917292515447096084448398386607305647682832708118910062737114911917758509348028443\\\n    4946442417018771147959024346434327220964778311290574684133540138222341101700509806050130154029\\\n    5771436878575216705551055141776206820517141648244528209142451611909516106410933492230975708432\\\n    6799874588970426283329299943259084507145973951047837938609665920201925915875289188406125086657\\\n    5570520192498993880859802721607315334496764183056968789951329782555873265657170848781334098712\\\n    6560201946169206543387889110775511560775834909101974649114343264002174152347290926845413847692\\\n    2342560259203335840935631141484531625827161843075480799725109329203084522305366063922135264849\\\n    5880683120128311618612228862609759774024768137210353986597024273154339422129380614223098200277\\\n    8284273370164039235707521275973725256293794279934823014194023550027651760106530453251954938442\\\n    7873937945005356254221406241590045556655030560929775482181518300154544873880399550309739990691\\\n    6084938770172902280119668992618205269699498246183309686275580567150495289227458686032930406345\\\n    7769202392327149862526413209018119257017650213866222156004822531008211032164379155415813520303\\\n    6143798171411134152925641185544235159836194808221616812207495547093037771773854180423943393302\\\n    5707224829538350321944482834389897755174110504964238026161987667180945357029407707553370496249\\\n    9251097113869106585472441851169315981415963112340551786077818430560948222877167002573323325425\\\n    3613982410258560466347854192699947040003467108514643264310617351818204416131426752776811412234\\\n    7843313489152027397115772320801997270511732125736725235907402910906240641109954468961939481186\\\n    6079766461963998647714005966410063585855862065879391286018316747906280035923040569735775909775\\\n    2306221036304152826842473184833774382556489428072194968768495646983352494166035068112565371760\\\n    4533229742880876494245894708455179894975608778738517774694089465728985235010487824488668972284\\\n    5676718884227735554503421832030192857358110707536916732306523833417561848622412730103886616594\\\n    1659283465757505392849871965930782807510030340210129204678695529202609989694086047261987875565\\\n    3140042468479580831413088233728641773965712674956223822566502213934457715209578988309807615701\\\n    5380682571656132126078576801505064418516415157934115135646465912219720830425210879259176900670\\\n    7689893534221653749337020214026016331738738602945552965375278242127598357663747978932086373135\\\n    0280107418133108520621024275733620598169499977088476617839799500272578131972397495585134628592\\\n    0803312883521734235764836129814977798084977355690476324633307958172410645314922411818736196169\\\n    1661785379154553232941988770265865107544291691707742911643980399313907422300857784239096610152\\\n    9313351637658242504388771606247622163207409043719330906846626127938302882472529174233140403614\\\n    2066415058461731391832472195601675387054028609134329318062376551385771963857971811169527515473\\\n    6000297950162219094161674802104699819053305987764263322080571046463087732415300038869478605929\\\n    7222938743681559731632597757593878634915467793782684230615335908401302769360522256916439898189\\\n    7105158698630667964579131567011067979550721726977123299639184143243412358531556353986590370209\\\n    6746275631126157915096420977506862083131498682787656834649683777575300920796085867839618822939\\\n    7857152698383791315006580474593665721489376072377991983564912770029880642677815101130916838454\\\n    3946550791978016265895345302181412000098820247403766029330388604149410836003680487688099219147\\\n    7927126831260257658717926575127084360441084935746588675198906280165171158621413895393926245046\\\n    2155198331395841384430186710786577123365032861921322855818696307386244481753349904024536609484\\\n    5889715443589158502098559913956026086277299585189183073845354283470189939832376939982702255190\\\n    4458640319360723478771002898859143795899944409710186376002456755841694664504715948331655413649\\\n    6299820868555121973473453246586821860131441704810081055669270798132619975180518716162209955206\\\n    9338576387522535677425402141148494797270024635758834292282221991346442284131236114067853373758\\\n    1645271961440677614038162308309682726679385081201529269383492240968177737737052641446978300671\\\n    0582440219903424897483717353315692272473142856116745843659245635556199120891942675533594878716\\\n    0345273748526453324200201139167520714667049281732261950948908320848792861695747457806072567763\\\n    3737532134674428877896151788619708095478565305786928778570123513728769560177805123452951090768\\\n    3966610838210302958264960321355055453070835449777736582339065224036163424725324373361950792140\\\n    9910519281114851637637963331334591672120588722232205442430410889247156131366107339861974479381\\\n    8944448201861445993276133141201667069571588799079025308821537136525446365756382735628166018140\\\n    2425288454357300070259343425819870840032260127260552089065429291024126848678692105250333213522\\\n    4618241681822490017530476385715796002829177919954561353723444734400497590050936111297496994937\\\n    2938312274264429130164405239748649910044809059985458977991395959728410427698948002431002483073\\\n    6372099667772330766945127363432311627863583336780378766557975273429549389772437630632971052341\\\n    4469973896550218702405765708311398973205205209225242418862059343475718499816974116059812295674\\\n    2099422427703678185638819782323646686997032361900297276085484256096924010674508851814395844897\\\n    5543059089744088971272467529434603018964867165433757741895216422561888530335834228985411686864\\\n    3876716874894908922249216313324155073393511769176622199200702897016304136487949966265563255391\\\n    5651860325846622827334862807503664996522844612549990169292183315519148032036445539542588873612\\\n    5563189897706122140898239675001607820679925237064399991073163409602138415304852262156934379075\\\n    1088770846418309045576789238545039099835112903478319528129086500459535781430855000867263477312\\\n    0938825298265666101823172778277035171068874511916222228813412464570868255362816201036176043306\\\n    2104009188853546712767076017839405713287052429276354070212503348628455319636911014251545220108\\\n    2361922908764009987736020876491536720054673331244681445713608596834146774074065838647578823760\\\n    6222304843392077840892328351277458023106592004430195986370986485445391617859090506298566543356\\\n    2495677901192594233687154649586725124235383191341339242105601601400354846012935308632982182934\\\n    4570634132005557206394720687075801214770477522539959571026934846740702514591211998761521572912\\\n    1247824649515679401414341078246121771483277464448005540735205073463713199646514878125921920121\\\n    0476597856646048267233303061857578933723418289931542888350056307342887602917737804175360085006\\\n    0684922433160023499157040719519706557839173301739288003268735730946351050966423552230821295486\\\n    3229582708671390455456845579564416978213388136386298519895701964680849348240516301313321404866\\\n    1722458494656831960862178658310488937450723234220669587172301833269308766369664941699202899289\\\n    0206149711859487834022265555470244783166521268179646289363669714119126411004429199651046967284\\\n    2579064797683446948518492790772900411597378506071807704042325801803524950875728932475689693209\\\n    1345021063303764074104929159636322518993205151415199784575426491183427524421417641035812856914\\\n    3348772977623079577120258418092075927597512373896689064797476810675708749300781715843752108911\\\n    3428463120148172642700952302057583282955465581212317435852709739381199611363223279525941024023\\\n    8710334472804078337448077908436807916606080357249153763070097233425433521895290906268966918496\\\n    7474085119270159351274042262846161221338412734346493559405126723039711216974158072280641995985\\\n    0596472742830870843540075828415917621229953124104128477310592741926901667681989833692163096958\\\n    8441997204685227778781383482950716826418874016958224678549960201230511455839976214519620818913\\\n    9968902999379276813188197018338505117808057804124079826063186289250517251944233877118465098063\\\n    6785951641905574525205738638913206627846714024998611886018137400862944943960074003247107977170\\\n    4281293596406340172534652246014259821324294069956030398982041298965742377863579923609212960312\\\n    7463417315702325980724978898255087492354171489872284879731060528348263285249387576517430769844\\\n    0474333392442066975247291419784143882294173222662293852563177931056500072624297858203706314740\\\n    7054094953704178329910511473286665510186752350160441506695033274869307865526841053702979000303\\\n    2252254826067692175703900968715075626191127121429165391129053266509165351790617077668008693501\\\n    9028260154989788379899993249526964836565095703459062656676094776184759409501722148892133453343\\\n    6361014541079243547361217778682034759114984028769668720450131198301087014232588886875900333079\\\n    0514607554537212278895698163202908996073690053602999123496168372153209550126784920039481139077\\\n    6229811453120127229021702735266932588863553013629165315729054086916194142850423149541724253108\\\n    4934809277865264581004978938509350923388213360019298389424639045309145946479204519530855864837\\\n    0308015522782522416742679546098388243514531632743510292622542960993335436886070336522869007397\\\n    6181424747920456626204491496633359411347820736979397462855768230790101615124863041428111127082\\\n    5887362886398188657768495248532910432605376827191032112322255083515683984043220033028385602394\\\n    9664086434687034971323009638390802250346970416854169054474100867376953343680238041933581370218\\\n    4626774146303580792436300087452367397779005389987928012168626844457379150410905544003959039151\\\n    0988256402163437570866348445722107673473595291374578751496580757638628058893644181364409068461\\\n    1106147186377799377731641581244322995543633286675795408635072726141241941253539195330482688987\\\n    1958979564334646029283032378672506815228774635762970741402489279672110296371603660716150784879\\\n    1398466733551143557437966665212657533719311881252668813932324992087450152550908632506741257755\\\n    7073071551134123262213120524905242261723022664441176325313569849570812663914925347971886435843\\\n    9118513497394910458173592137816662627105736605757970761853187955385762839080702143997617108210\\\n    3155157036634372893373207793801378756914969115427688583322277745363364154891243736962070052712\\\n    3680710370061520498164814991465066187348529488916207205763295769594570912377819724898047251913\\\n    2818291135409281223240211021406403691767235770041793074083469504647956338571745485965025133382\\\n    6561468442908816216771723454121360510597398022396658243764684087234900327916172108222598871346\\\n    5653399239937707521663975928876370141377454896734684181041853131425057148045583959501432011003\\\n    0898830506200303792274367741229493344178850135397447876142765334347919832364107417404970326820\\\n    9030776191516530812904746271926725303272469704603142689086026124702288918378377583914442639575\\\n    9776406754215993138553814566943836015386377887577108347004968503664943155611830371995694802191\\\n    8432003801238727507310923433242177628763156088129605601711415324013878101460910629764030033780\\\n    0759668343855728305028734530030002177465436213203395255671451490910116657249212250534590915105\\\n    9532902451670815315524982464895540242020701255519453239318738924400339434157666794019057725244\\\n    7494208534645982084931519130445193459708839053920947220735206405867171485738644259399710770382\\\n    0076014782312042283386983685145307057253597249028946028214257154233772623439646777539262381597\\\n    7897204187276903760688337081299135381529421762587526494680597899846143634141057144957570610991\\\n    1481998530269593507677942998271916022058165802717228119546264425086846389627679261806590409670\\\n    1670778273310562580951711863304476007475935362152818882463687815779230179304328487482282790836\\\n    6251942903465483844840674910859030283782256155840999870802711006583018894179921130809841949602\\\n    3029473613359641119276795567544293639057952108148171308501186684801365868214273605762744248101\\\n    7901251981719109315575847078093143162933530741158052597043668019544979161371910026134654602209\\\n    8386023099714747817581482761918932333342780662467530175940758160631075499756763072664331828032\\\n    0033682525893687662294577122270606400827111335441662793989589049250617874945220416192006487353\\\n    9576200260919507418954886924006905832396404833987933223164539237210547126151992841466904488975\\\n    6425106049628612798707917855456052199704400434716232542430887881948552505028216527247855579965\\\n    4204191828476845379512103867293785693548908483540551506543030809141984374124168443179480147716\\\n    1292163971998536056409775559007600488686021840622970492026868993917864058973657984735141102775\\\n    6210443266490492304408466303336073924498213006080031779988745837203025729611701911149120003142\\\n    8335377888000161219958824853109474810475558063075313313822392930039843005544805456688025053242\\\n    2283302627167673912192020398941029112522458601134351661225722986726617721260400259505808020059\\\n    7415063500107652202423298897121343444647978892858168430306509112595040361610170162254634883967\\\n    9895176487408592361199110433495032570886993843922145165467966160343514701648203580606986119641\\\n    8989737479649417263958476327099933119462903016170308529966057713771079579072309844547690861274\\\n    5241283097769736157932757752752401845265050695705375377403144660679447133392468156700092207604\\\n    0040714072513640386240507080992308733289443311610109363600063300555882577015785463002963615164\\\n    0754315884187297044829559540961636736302319580198231151251765034212588025643822722685749366399\\\n    8311688993353219918579461399098188433377413234115658881552045214368941844702674108989969670728\\\n    5662133917721933021260089830468554355859090639433363156935554831888141356484474042234448768104\\\n    7718029317839821635365889433247311360604805430682495626347041865937771706839862634278916977139\\\n    4130080892729838371867462206201100116975908064885733442568338222308169590623110385626195885718\\\n    4996611572066420158605281300200205279393354148178502707907096999478412018535080836908158011060\\\n    1939085663931351610964662810899584700727421262200017309456600600102084163542324732315958247520\\\n    4165609721879955141306512140717361624004268950858745528635077686436623659830301532621286403862\\\n    5203496244618107433607524741872151805735439970371128513706664725801886880119221210063514868964\\\n    1679461047095056507779098477324633245629629379722259776414763892637464686930676274874544137312\\\n    5455688870333754733115235015133865193453774706725119055048352254220030367730062422275613250088\\\n    0130954288351601806497319843345451089591582830140337757597657509598531617445204191396293690190\\\n    8265370133804623785546500857104348291479413027319996041473223526804748345823053690267360759379\\\n    4978393784888109655227746429857957872304088549806954702047347996071438491896912316699428666939\\\n    5730417202369047072748300837290071431028831149153974707287035650914095213928325101695807745051\\\n    2522937940302594311159686719773832320740717317637452728361598941785991619560710129829135962209\\\n    3253002977296602609038595538701087429558102102567118717359664266320972314193562696942075225216\\\n    9638306934204741296732934197918213323953150109647045083710200840366360192232699907343038798524\\\n    0497297300941647073472391003851382887933955965370172334708858808433869796586737356236230477217\\\n    4743107921737192563511004303790383527039224545058977560810621202762702967232903606169036630330\\\n    7592981792569703125358963649113338304295788448062516065593637448584801614519604237471689913589\\\n    6535065239370976825528778914520466991214073067775032826555004656124507815412371280513194532448\\\n    0568315148911464171195512603649423404031685816674376382841683706642113822994575283152758508150\\\n    3675890792360190437672689959379685794788394132543537510875445024088528176246321897161745528230\\\n    0074679312588383591890595019320650301586242049895187306494177343588366693347370500609969724346\\\n    5332568914762920310829394762184384588074791413719294493291589055406159880159847346871400623102\\\n    2640740155343437926696445524666974671257181318526311870604837555104845354437145470688033624276\\\n    2920499465653910171079914390958590538219285633196372708163278516642887153269200428234381273386\\\n    7611479493896922724218504692878552884333863485799477309436223831038229729172993578311451012998\\\n    4812017731701445202655054696427028216099411254970230403747742104645335042717712719453140940335\\\n    4636226511339128119061405669287657820662926616026323816620292429846131604405136328462250318567\\\n    1244785154253298879506704449868186902131597466753321071728660184842080494200461316117712721515\\\n    6911978401476421337283486089199833888727480542328141310507084668691902941767103055021689413492\\\n    7394045349588270440054629056580493671510171517508375335812286158552563654781145741620922214110\\\n    0888429118805989523670120640445524740067449665873130786144964818741458525982957960199046501628\\\n    2396623085962432374057809382381893645959147108581823211287433433829830395000717620371837959223\\\n    8832524897490469590790727279139664801095198622961716725593782225157551159265756790058398296551\\\n    1221543529614035408355838163384223024087874907518234289480606457461912973803426862398134142950\\\n    7521306571194186780953218645532528628122175193521492097028282880202418333535850419949891172164\\\n    3590442958637066974176514867711913275296155222799482747924592658548521613684397104421043716827\\\n    8142790108603202432922698853036481715313939101618715237793246025753270964514698342516149764627\\\n    2245495386370599674501175418060972831816250254729934602811768915283706383325681336402193785585\\\n    7465517190397210685743551244740636129980213440855637796505719853731780105445491564277018433244\\\n    6086472517377911914463128805045144597965222460413023027555957132998071919687703751903942570642\\\n    4937307397004102921624372355826382745711755687892974592442775704300963755868704405667411458431\\\n    7818616907469537953037357130466559560207826577818271917262213411184403945009238658732353684277\\\n    7259799880529151059865318292115214341938957106879546342415907487857097663883277319027193023541\\\n    1287579331724001083888360221330342412969858473125073574175302942551421801614148931735290305785\\\n    7715332494274062275665847638829896439332807364764239128911382784515241166285785010053514623742\\\n    2228461440228555006469200660097650865975684510885437189079989975942101470595404954190502781164\\\n    2932269193588592855340855640119042255455664709986354520927936138309739586294192709118873549185\\\n    1723894365504910376692312074866912126881478936403243404569669932171157514360437226682494669522\\\n    4336726821744987086092608285918813961790910014316859148570239011512035892453500486796635380578\\\n    0969011199022075402830158023286682068162623933074595464376387501995311386641271872035975115250\\\n    9560721676183472050301265677602336902517410182720753495133455218507058241723223145429486287501\\\n    3526218715856972811711296406124238504941995850255294607820345999064377909522576633351917610462\\\n    1803885175433769586018907935583857545702550852531523080868739594680654816679323468935032777627\\\n    8621125229607141723576367713458523071154147214461262026861618899040271804405930996016361461600\\\n    1153854892695966579064589321335893575614772672125952109600207396481175451276996662561259930276\\\n    5734961406765469554037980757052176118772627274913077056945432379424146810219409158166921721621\\\n    9809023135904527428303817031212796968237804171027244032888758526374909165915378832706164873565\\\n    3082964066865094963021846204242545126698237561069374730029022180785168993084836785873863433155\\\n    2063316142212751796545361420307064211841211413253568918829280413430590699424134111111601349094\\\n    0673790346252973905933437419948697578974863667123179572228029040617772024175378772414915156677\\\n    3213634924065343900240394163510020360228137992071361060171179167348616963327717860078150189231\\\n    1764358363624913586921323313382559750681136291421312523672153150326813241729650197473743806217\\\n    3985408310256852707067495417441911707674782942083665819342960567432894196486510791331940536576\\\n    8294709958199582307791722046225466103050365353993756495711975966472598173596013507240688760865\\\n    5809521253593990938766306217854709750635664111524650896205558382434657036163450857442320173302\\\n    2241413554243297989855663499750845467638415444162271077032311963499666040862748825384031499167\\\n    9695974865555407709733173923758718273509557228434742082463670463185145489958325378459047388251\\\n    6803082954935992396858802449868438744793809363008067021930009524301003089209031601689321409349\\\n    7066295433668535213851888848401913158064277609640254120564286954347785540366510839068676529300\\\n    8036723481963838251818427553879718614950856876746101966658178856172752769701564936910233259947\\\n    6863227293367530536718290308779639813709669090560501406604117341616157583354185023191442018030\\\n    7331508743807588355511209777054824425503251905654037801200564609253336932096794785165996603450\\\n    6123609758016461789732986077971347804512394029490962840613478846356493092530303534398959162822\\\n    4941136235283299943719292812062265703311549950879811038775837474122983315642609470418864319936\\\n    5636508230823987427556829190723969871217508667709700779419689771360041662154416891438512375097\\\n    3545031918919859331288191940329120636853994939647744791328790366869663675001652448418958997579\\\n    9776553218331615302153935933256178938454611498104640395266720205559064618741715301874512571246\\\n    9554715075350490259782353694546412487077693429138110057660144294939211358248493334050355363212\\\n    3165630667044533085785511735508524938114837007247809901143514397720201251683919112050332815133\\\n    3952376423572933210130625424041057156558000566704494773197080176536038095240215334388660198552\\\n    9829258092207831272326045939677710748859759656997645169078678775326370962893655458652600699995\\\n    0222307443436584598593454472363055330538573820486435807888336324904632226916057860967018644565\\\n    5871215898366606718745477302373945751805365657872105197957894885504536024297924759721180268087\\\n    3120115523986332169463363291158385956601640439720176559165969382716928791412561027153425488122\\\n    7051867463795674045613638685337460424900472825631789768731241674065380853745025146995962575858\\\n    5376218934265867781024309494653385660976224051042616938034047522087755460297113777256955122448\\\n    0545441325496950362648907947773017469210737290124851727316124577547070448017427016748063015031\\\n    4230826211742452989797918689068382187494122059668966549327995698883012390575458574881053379404\\\n    2455563207952507806336446897137926674563046359394523695198576310151570132822859532720966152327\\\n    6781060370123477531781254376095702579145410920997402243235081297880268334669566051768095109216\\\n    5920646169206852717714060907590747241249895735398462976893803568900065900570403266085883832499\\\n    9607811900682957924942003103095065290707480206657107401441029235410104046939115146078560373298\\\n    5251679536822521642500163963479888610567526198806085984165866295257357646492786451239224735058\\\n    1105721598336932291182793171082099067950579513728767998751759949873007542508902531479903890231\\\n    4195247737582525578130095189723251833709033091177806631271557691186794357507314004253216662814\\\n    0779398042465082335155917489748059379152158904847403230510435748156186214084907863206724858543\\\n    9714722078196825165877503901286471431496402490343074140361506147497435329169505179694990091891\\\n    4141977986770251322892830180662548370427841706670347694407426460195874484640188011224936406911\\\n    8848891417138688961834167271266152970645677055814366033784046275907466409774093375484201602649\\\n    1086457856600114371624893812508767030334186157204202235562178506340028011404267900012800912529\\\n    6677879994792734225921777998050603854026324037610542157008192184703940004057440609444286962440\\\n    8568204898232720367379830990203900035276361138378873968762865867662085512175918910567754815117\\\n    2624825040847096960580936843017490212360028637301755165473328415913859640311768153137351632930\\\n    5579198544358224238053939019941291705772450778556104937241891244860605437989772845329486101581\\\n    8086798688091688101314290068769454874524724987944431614954750304679469460564083115979392147262\\\n    8021362527859557609872157749573309986262914187783825317605634161406007947921732230936196784081\\\n    5709542367691042101416188145266689936011843600434908540719664000728681401274702261445951271267\\\n    1264262606666294124146436304437767799354442771041927066344213439255144411983746652160959938303\\\n    2303101255878859622565426065664093734493012659802659448320387742586049140903548955469764006035\\\n    8709888991337996483279113546606357111606484207011459463892433838456154291187857536954328541139\\\n    3470641249241737729424476101746844876828369569577122299385728064835322009919256809521831662533\\\n    7330365391811628453673119534056303426137633244812557499398914420222951023138645346780619904139\\\n    2778308786053790801179576294535008931801606721504038191543387819432911851648499102026083614791\\\n    0232024165793560178195256987386820712661147633082944021341919106260617802092378943723722996658\\\n    4425964286351258646834425228680195655173085992506703997252432041061374760421290469485765052871\\\n    5339788086110260751520576300261159731228801454623867926009287670528585428777229546633580791149\\\n    5199092852364493468497154829703734588256408949457678866511361933262700791232394150662957837638\\\n    4525165108600145413550130690460765710384038825931039266954854623788079272280378269306562015862\\\n    2971336711802323831455014851584788486493411382124844518971917740312689852806772795112845578566\\\n    2914251224996499257116138871206258243121015474703387842607144143806641861090138766886178011053\\\n    2697115125810969040434314073111750041483178425356605689193720135841797633485181750895279095268\\\n    2248006118596134296250184726726560366837053566624154327557460904071303831544520306071910817417\\\n    9596258318279055278419947888220405360246960448667529376973000947503626249557647250968635355175\\\n    4962880545009706270778304853796264472363381072930045158791144035272268177911481889369808045187\\\n    9791424824127744822162372121321317920455261491336485074000575828768040278281416027548958901176\\\n    0146658608569473131967927312407593604298415989809817503537033185683880414459470028270027870576\\\n    8252046903286349340192937338131545733441609702393663511861163590061775333726540440557656379941\\\n    9301354261894716692738569636955303830488510713827359324623847702283864431312707346396649172638\\\n    6059508079601286267382313962310249556112402331785438246227750383556563452915743647197072612287\\\n    4832954751522305702330435116653118315318198300012502904080844171063925238471842814085521206947\\\n    0657949630611907200549721513511443712470155466199756195894796686798901513217626237721218208027\\\n    9380110652438919631006127792300333600758402955289258245281692109670611557394009197583542669894\\\n    1784997477607970262720238604203875732599491454415131392866025971706289211267684152795942919181\\\n    8338751326892707198611140009117939150052048552883759062199347198989977697330078081746545610778\\\n    0222297708628489133470356231812482039671440065226493667543202613454693282362131333738953697597\\\n    2605500611286462171580798574682643865362974908495473490381453873331355802974629203378867104514\\\n    9215050238678929921479474251446772732795437532517024755653067103810678512166622492939387847349\\\n    4458265204887321244479582544818301976947543895989383132939542273254300019041721530901319006308\\\n    9512041797762194619601164066369290080332891030871685076564153855820288281152774803826045098383\\\n    9286384445227131075288711123999415394885097952264037843266349932561091175276381277755677146056\\\n    8185760184343693016987663489151448663487702365785609508926165484038225245935749235392392277170\\\n    7413698454282491994439072747126101419760717859864472270149233081184148064779075088532415496113\\\n    9882670999454089276911378420426891739406691634796994655675100845811109619437958523766804958021\\\n    0758739402654663566621492977430015447631976423702549419343498363977898657378198786816895510086\\\n    8772100444582477772504119801066173387276432338285356939891437136946282080153647650449467269293\\\n    7362918673552872888104468755013437816646757540623002821136141675106135977626904069790763946689\\\n    8526816423328299601545394484236742227938415630837754266473668200899881725295139932914115278725\\\n    0090781690214011528305930240489658852284233584356845316714763444281221832515073586257406408582\\\n    5293423592191014118263256541650869690892166364493206651039949548573197153094642022277571857699\\\n    1882382060268606885571815910718326362938475225335202570640262538612244837561657925769014315451\\\n    8077268060544369807290191871865791538855642353092875313499505685516239109524488314611151713628\\\n    8493151669242192315075458677433461947748363966383400179643585485401352953885573962838273611760\\\n    0512603822740699600247231086134773274068464723698349075633655108306577685170075703798237385868\\\n    1036571567624959132035551257257294203993552403913353050673000633032529611185905480872953349287\\\n    8508110196227547343055680705670194427897100651800177322559216028437092317223196322251983642116\\\n    0468324874591723799460088770085395115055444235454175063860079662461727874361134291899713300341\\\n    5422173892822008393281621859741984279111706660149997611800068858379915621964218642880868444619\\\n    8820379547103691626003497845893893258767080285840280564169965065607848450282940719489930642929\\\n    5691879502674663742169366081359180979292153747447363963861103485908269834600671548939776089043\\\n    7499252463472173996471096740627051054624145329763053767061448565525142793646468323562382830036\\\n    1535637752937543805173822231857761871849512015612921565451884430693795515417712828723039796787\\\n    5442528527686649332353338126474872734132791480259248978454741073563850600834789049718221299930\\\n    9635598809206013259556356179765471912173068602858334949661143945752516458227407470780161636123\\\n    1768288456692689376528653444412077532107989864270527915428898693115172927313539699650833436948\\\n    7270325311718338511471825876463618609638461470933025674183668180220464357730943774497435418848\\\n    8502773136912112662921227705745031201874234928144821891985589295319785757169855294875989266132\\\n    4958849944188277938853544344986062894003457386596251095793926179131680018990989031753593729196\\\n    5046710555173471669848341148810179240909611439042184897621397706379682557833063710694465870889\\\n    8901390155170068514254331463555484110720150045235492053941542802845154932050975601975729146037\\\n    2809720816249986241117137240799136250175845265381789318740243175850642671094579911877350439141\\\n    1979314745715094725350561698515046391945941066043993234861156821711561631616025174729443147736\\\n    0854057331622206114168833836640675376411227933606357846423860223587661603343819984791048456696\\\n    9732547631787281946572046308600137686562381803970623811199133041175897920776371390537314976184\\\n    2454599564338563368253323649987432760081186644831288335233550092158512522418727661304347188936\\\n    9019986731623687092644132401372833854457630043994946583104426995597953071445476711631721694688\\\n    8884434248857250520209273317709029910823774740383784994042751553445225371859554977178754275257\\\n    2720869218806455912302149002208957377572311612260985103424646406518594541798737239467319761845\\\n    3703072905573756720160601059179081144283150371304358250270430409334914609958883526628286254739\\\n    7957806486981699879995065471275327067709614123990065910321531987722488205786939842370494662723\\\n    9733059304354494905505833992642568378838191762381696926337740839072784102119389869570325795508\\\n    4329629331988932845226526232080087627951561456315591441452493291390769794661267270439235126499\\\n    3837693049725862681993408069961086701218484212470449815330415296881725661437407908259075236959\\\n    8591778804375588596522125617192626741943147689448340038177665644227645697403149199950934995555\\\n    5428068804339663011278849726885183272835042353654089185683315845031665292646801183409328266145\\\n    2294367197899331473860596602790470664730661340976117301568414595538950637102345482981979868513\\\n    4622205718000700655596848150771301301725442444368244816411474067878531027455549820811590144777\\\n    8679390926138755548525605624100693305507082229471573941555462577472437428710537077604277517179\\\n    1920960555847602930238613991575988401582109673189419610617236292087258557423502462710380621006\\\n    8204122588927927836601395741400614756915342862098537188585004099802298485837903669011480394521\\\n    1405256871999656265673203441826421911976620555768137378740958093862683671980436051166878555159\\\n    7593017479809953113937099143351323384294004761495224723742559040277336092088262467657526202247\\\n    1750296813721288876659342818814861789499714470008154046034992887737575861163589579210984694310\\\n    0063488875425748378409545528953659907574420807411126516269565508301956285367271524662090697891\\\n    2907633939020583472192719804348308022345966300407757383416881545450883583590876828919618801774\\\n    1436764690168451410271872112375441095759336519634738418207657063690480046488961827848101169178\\\n    5534613215677664082792003549527071839699105231366041077340984097435768619392163393579495622231\\\n    8157355226543250554651904168932799788351768857451056272508827083201532181619887874882113642429\\\n    2909361639438536164006939430577710799717055325305189589816585593286471847501488484809327649194\\\n    0583641219221519110479547265601680807099811554011186879905100212453405617246824998493724221807\\\n    5826656666459075692300427671752918495747640681191125117953658221735224449037448204778891066279\\\n    5841481549031243575306110436776926713503440443814255315814247152025196166164371703841028538958\\\n    6100751332381500719764872332772561997523380228895406562134198777714074915204608319767808355064\\\n    3376148408705540530756374436491708850667833276830737653804418277021021896045775801523387717859\\\n    3080412059611189099378707212584336325573396494414480590882645109652435740802998877030488540866\\\n    5022422651713550925519511581007152175342223467057378536136564429756335890763133450963172009616\\\n    0525499876749623272356408527370685473713699624882748665075034942115121717368861715308062937612\\\n    7118945392023125246873343860053974394713816895061296656570990270498266653325042412166093010907\\\n    0633931572511654479213605281697119490134249577576058642723054791676781958467140216254871241752\\\n    3069211677943716284203259745982767670461987185105515911135431008960998658870016534089075706909\\\n    3421336433741825956230118072892439356087928737786321350625826316171074779764239889225951191490\\\n    2795526905762952306450599459441591753043656973234014535644013991552596171330317412706976192397\\\n    6879775008230682891146988905361569683004070940940745491612651470051807479833030965374214916465\\\n    2377831963458442436784700120338269051406743909919149267952480864686304477189053526363182606008\\\n    5370110440275878936666336064393688457078272197818029540750688551206554489925699310117715370308\\\n    8773015273670443211053930181855180201768644371652082153018670845519919291271342527780656977444\\\n    6386453768600770280758300536536937801464406687420252389760205827876236840697344285920094273268\\\n    4745182149650832570063352617777274132624996526043981902979605702458267729935623949877294387477\\\n    0024434207526540912109840065826172823609363787983509425236679312700985860488814554867793446440\\\n    1964751628700764756089698625252501754106663620471512631948238212151182459358328151674972509372\\\n    0378165377677184696133923741548201893321808441460857094210873935376386932484067823462504114992\\\n    3856472088724285150964349295132632360687426970222147997686892791557259647008935510893805965857\\\n    2907830144694119492431615027961783003717527078811600958179079277351980107724572415617201228622\\\n    4418061944462794479834006698852805692175875434304440226186628766127575387426073584972408247373\\\n    7105193192982452268891079288900159085446758698876805681619753867123941591021526672201229802708\\\n    8521021128824682202136382191015653823849174198756646050710001991576977015965305106868637339796\\\n    3602980725789826738953135702208993328088611806723434804365948367004951894234631667951904398623\\\n    9551829963218154310813653444236115868381736437713889118096070079417293966721726604090104022205\\\n    1354641908210473507917473459386904500993862365857210184504798172142397504472747111212127922550\\\n    6155890788105349409406117151915864245690201802662345231359895148478420721542859435558861614724\\\n    4035332676118139951890553207229653148039991522781146523413120472872051302201408880278082962212\\\n    8797676578514321072645290443790180929499766401675903743058242245579829630182062552455158565207\\\n    1941535624550047829678458016827680073365054314819647685671899588903260459866976735180000750610\\\n    1468934562446547610767538487862313198451288187246918052159910347981474676319341874687074897268\\\n    5386360471626788454586786584250266170876742583000917453019997209622367678690795679580576845495\\\n    5439239547658901049309889138225829329347173315345028515248083723767169411789254881331506093817\\\n    6758717177967061603774439179017588396207332862589205579639447609698576691319178163548229408675\\\n    0791466968817476398417773917467849255495143885921297503575110151301035937788640434302468248813\\\n    4756659131805413103767617196943258864313687966399677405420345218694565287636229965625035384031\\\n    8241126317532621786842737877900652019300105335126344225406447199142751728610142268776966123976\\\n    3692681291127648743995943731847837598870254189624247181627938697317922025812995068471331064127\\\n    3568073850362092716338214053146085975303061150009096277554375793571967832788467308648888815029\\\n    4714489190558188056857374122486164131592352511140457525395939478159205093802425063395254392625\\\n    2727765695716901158259049085558693319983855380262011955012266498451897038454935425719867736769\\\n    2941823474064136062293620247115807575660319803157473031779112770740436259629345867121405639790\\\n    5745203356484419914666121141274345863455727416757736400289740249836781497033225008112602289319\\\n    6500537580764004285667876205466042347046972786485947587228777379886131155565405636740224824193\\\n    5815477512365725169377367628747870068914454689606633514774313767228704098592139748641413392226\\\n    5909042671111276727584797685344699614125763870163790207383692242307259478150802598464846914669\\\n    4724135323692066838007305096042372155269113385822105297498894437201624605786207688371815819990\\\n    9758978028211748997206010184925501615890883873650494308103809700540673705693932108012207461129\\\n    7522550898088698703328157773776364894759951052053801526748778525593765003435940525916889907972\\\n    7817146256858470591511762542323897840496952352293985086057222555219093029042210557392691336273\\\n    9018498155078138667158000732781147250570436741036521342987279723581483778641768227942527343848\\\n    4144444294173229599976874980658200267287180806815450047166257819155613746866455302716122398035\\\n    7377533722882258457701062162223081397334314500550184725847024143599645227341999558527354356424\\\n    1631169307915216289102353532811965513073822023023006055731193154909706088254548962816708576144\\\n    9106736955347551455724380053052440932046636491292872213498536718102049082860527053501740463405\\\n    8598938377259856307250766151559700954333796386471130707890170862698709113543106903048354399015\\\n    9182495376096770180683910115638704326920799110218064615467583694517840630500003890325163909861\\\n    1251959332693599168275139972953407310709725549882027707560119598880849047026379323222353002651\\\n    6785578238509100424343278599953387223006823666032485011025989967035087393228810443335662619477\\\n    9417355285651920148802789351519507742006761266275244983812759985478867881141042103946615274032\\\n    3809020975687270309642653952645222067401286441141222011907303997290737250623601987081275550708\\\n    1165441105341441263928973090590875307594906250550690230204022712600234637031142527625145146475\\\n    4470226449704012918364894262588438925396197331801571433484068499168918934761140177572948400711\\\n    8616860646357369307784356054315150101324686095018257565201768259608469076812588681266049467981\\\n    6427571257151806530396200849164290347915857215417225482505861853410714985035469651630479384094\\\n    2740261385204884315938763237440451754610362610677334447199527713043601160548072595170008731835\\\n    5844277387189982752168168104870118107346976190265010358187945203879896662795073755148339917631\\\n    5281621011277504751021612348713520353306789576420273829787821503767157999009353426722487931459\\\n    2364899837277069066644502091646175216105749838413515706988330206546204026825822400754220680321\\\n    3672636173266407290384766753813955262013283056905942893847600205428823924148240121471423894618\\\n    6342965131490305696316351469752351308004127878888471762510563919126337131177171510544149283939\\\n    7543878945591710252416027906755708004764979221566226625110232818250421635209327860121861391347\\\n    4800354099909304857375173585335630299356457160059750330355159774935717757824242078304406673235\\\n    3813477652245925802791202157445453255518317906366814577656489675775200883532359385375306226240\\\n    5036237064628951642443589150453335636928921611344826628695554104443723779977950715975984465569\\\n    7297697441464030197678191484392159770485004901311341623826191462979724119024967356559823967631\\\n    8757700086918863482590561489486959675908095188375529720099665531457962553686303596647336467288\\\n    8423076004008281407556291433582029242926800532315781587928242428547129683900166936642008323727\\\n    5709904261559797780309419103172899100085186433650745065146877077405708794349653829072022718455\\\n    1816821994072271319782201644393663271323982709184538088519938248357998911209460396697339239361\\\n    9506991743093162140123402637590481221497638164467124458464886747546055681012272250486122328437\\\n    4220121226977020593303875384889522415540522043012667827636269129894173086730712961857995753799\\\n    0611916890215125618417755996300988989982179112460150480935112450731184525922740831921701369353\\\n    1937771382361882311425307524379391552907555049092973372741301219312378862326957187173910527176\\\n    2393668803096322633020886554249287588897444251225286665283601227354273849040518745255245587161\\\n    6608971126104854368020390191837775669611822507871337467328167697752971012510901565832402214208\\\n    9263547689559716683036180351856927730748719477293439134505566076133037403949778902095179989217\\\n    0651080477098775025463167244689340654264495543461330992927165261112302786958764503622466075041\\\n    7215013807169684613016962122622779149169359757361858148761640833251215840596342325512036042573\\\n    8551422555265161195198406207738240450751000834306504610652466271593093885234165835866405933886\\\n    4168410377850042136887677949441554048342529539049227982750449528386125852496676926045915846608\\\n    6577072933539465829313525982256769225259402333553420054178005310004601191394876657413709095220\\\n    4209537376653910582979104496303708475815384169215633271897861698453955718235235422834034596368\\\n    8885501476029538090046139930328882881524117647507427591188774581011892865552390849559698609825\\\n    4183207336484420331286429004777978948576469419452156007417103021407441198856305518009990129813\\\n    2165345695889699820562591234922785579844141610154440677846434705327755246587463440897673590167\\\n    5728525361444820623708629747585666593460988362036093942588676414932596571547754240410132552336\\\n    7307100837176363501089508060772924357595174730483988155474747980140919989912200901176605786195\\\n    1588229320846281662894325237471914578679566537927469301086026354969524289645529769346248421312\\\n    1255677124590848617575807681886834274508549834601416993734765563547642888591931553673104443730\\\n    6533774371998335524061036065484409115955092756815642476482384196626754794691120751575614570396\\\n    1859558590768902959677757857152244638486626098766372671765881906637131617007235212962099454482\\\n    1987220752803619491668851045718889704214100200990824138836579025450519079407093712526491538947\\\n    6732651211024777192213681768229060876735038116296177552338230295555241183238386494709815251108\\\n    3706497698335224002482792024212463080066590408139287015996322639743033304929782449810759658969\\\n    1099639767556561885549646174670004121467609185897643034847608822245654287749131703873418275675\\\n    6236765036848950159634357456986641404376219047943666718480112301402539432338517915649359872206\\\n    4943151573909373159012229442740092012431727169351311824573806702494038530811405252932830125784\\\n    5735307074307713197049211607986229280805885367387808592340650497959581784878374699667144406567\\\n    8034104038955840048000443927129271206897536461516466018650090750442880554659866772980888772156\\\n    2354839182062933980426431630232536743984352621837471156103999119720817023267203329734435195978\\\n    3240723228608668711756658582524702632717063886668580300663956096177567796994674622819923350239\\\n    1681703499541148499128313513310539678785226386306245739986627707763005268186172990896457806797\\\n    3036668665787353016554527822382877910533578657342887138415209061043312829451425662971648460182\\\n    6664278537073018824896246752031768286150977898754453395012957841878961192505800370915890557824\\\n    6033556799419611359127574929112701016723268733512957357250715470824421411524803654667957383995\\\n    7324263397859343649011082356264345551792936746754998803629859826676798083465351064853492249097\\\n    9272636063817594214208384064043145708726928953497550165881865614312268280145956730068374990340\\\n    9473558804369563819395132411584897702087057363729265576386643505072352607846505475364788123258\\\n    7150250477228667859213079633929067523752865447562069422947735912669058912375023367295353902417\\\n    0863050583717379071783612783081728930047866324407454919054580830126490113516854485039077225757\\\n    3128076771028630546568221465491910035579147978097324366157798060449240075950048623557468198600\\\n    1762320854488902246445698448523862230848009597727104632867193976759411672831668072588710029092\\\n    4438702666020748577392211877602235981323919001653161920155178818173823077770391632776687195166\\\n    5721678112703670093339983928267113823932018570775671904707498242961817954894278660066513759506\\\n    1451767676828283243132115672788593761733377100232372084618812844238948227026056498859018550935\\\n    1598607530982889356753514109660368704496501064486805629482663182076000225050596266840751689890\\\n    8827334819513800413522929438634619682829463883436849407686623247849660454742634489199333708514\\\n    9624176086919968834356469412133697199181980915277000117000019679727292336155366322292611192281\\\n    2210706673356430587282511537152971490023320732247522215366911333312268803220336451364109432117\\\n    5279068577833605734695841407037634896768512853691899918073671877287629375721570444315142227374\\\n    0099824778924834806138234016942012327633722842895646403925746649411105240129725453443310322339\\\n    4894886838476909457472102427756539200740353768201419193348218972746285616861814860811877241667\\\n    0307515010531795661089494511443538246172230840772857453446238831751572898259573215553194122706\\\n    7348361205957881534828202374276404984353067437910192323663272187447366468437624008681301822136\\\n    7442049326875077170933969559925117345859607827725688449969552814420512291919783391990768212653\\\n    2359845058638248420106727474393999509084847218513194241932973349312160039252810956883833686114\\\n    6980413884562892164239719612600062548078077601276670093228599518041268655223831441035702783718\\\n    1843165656962852108309738627515759689087385014825243711612891528118190007956802615221169258531\\\n    6341942147837113524360240831564728778402063584871101431409402489745110363101136866713616560316\\\n    8497637795868395606728863828264206474448762451617414016517639824383200555852272143479038886311\\\n    1957767306253331740481294548508983241084205159933461690211384532747289363677469345022413131760\\\n    4495787151802925816407961821109881217250857337257472811054009448699325258465315719399885521213\\\n    6683007964222452309714562237554451121582651673127724196315487409586174240932864544039557038279\\\n    1796546699449495052470561496565136626347930564698174705097749803753531043385876996120485276955\\\n    8871224237347568387834392866584975582274180648250362783313051717310959436064535574710355065978\\\n    9096557685095592535490279249531610159442081834026739636478568349392202709076895949516878226572\\\n    9471343505483055341574302463132516165471632640063059703528761568528873648218230485354416776266\\\n    6693992814624722151789070594422611045323191196374575665677398448539962138807232412749458600835\\\n    5770848163117853228994417116250021754745259398694399654485370617331218386284247868456600374830\\\n    6249725213239301145866634847752007354792925752787630038516695068299787148836332778344683514474\\\n    6472539383796310706873046785886787172196146387799378138542574870557471008911419591165942897529\\\n    3251370015640941528188144327362881990025522274147219219611837802653857834591061966187219085936\\\n    1173354551489264636906170136797286779319586222336048492233717932380285067533629453387071473110\\\n    8761694556841218284542300240547315811364947941006700584728897939681374759298963549986129680015\\\n    9144143243998950875881592116385246022499954054972305583804438218444856888987673006739134957351\\\n    1004398903563306236749050375830302910130275888923428713154198539540365810980306035330980179329\\\n    9839679800234661708778363485827370642846623429954448515724053053406262077212739988319290170001\\\n    5927655311574994609602813543158838938130721032429360167956108855705436994639244327273851829857\\\n    6319149477090767891231167149388922596334940849468700619973310945719377672372830887155324107550\\\n    9909256661788617516994215921785765369906670785504479507132311814870277419446379182054206268905\\\n    9177961440757060531423500275898467476280732147637807441365299315816012356583871982154861507609\\\n    3407508399291812146554002563765375534979554575111802027795099739575031388469548294498472109702\\\n    8774886073382276734730801918823188704564591645777281468069903294492659431826739543951915512579\\\n    6858401468713166969741697011513886341856171480108298863445922703865639866756970302540061803122\\\n    7262347719053470663852337390557200879265479822188320644357441244289202813063963095783395702909\\\n    8784422061270212513425077110669305128324290016335490581021835573699111006024336292889774234388\\\n    4417093495386177552966920719845506762026815691502138635970194002987821186692349801082125922624\\\n    7035417431582121761678353376486413619895428663991139584819494631449923155553462368424266396914\\\n    7161610232577244223534063544156699558275860492912368744213686001762668759788234159651102561941\\\n    8505984357222701048391272265786092913730903753830730718882922884489293182002604548763514932777\\\n    9583572297885881859331262201611480160009119645599184954960129015349768035398513834363459264450\\\n    1059317506338608829400201440367121073848854423927882725705861603545580005497741685999091340474\\\n    9899784975526022004413940876576013540773287120869208728877861608229887169091972863070190463753\\\n    2741438316866152634074104559874279670014479262098950123426010859654860606550723643823484834233\\\n    4033830269262773809253967609681781648527149030112233454182929923978383987134158848847071912376\\\n    2942763359215128142337448837369742565191915879669492147934725237599315597198439240532786725643\\\n    1681589697701071217476336611662343557481650340640241974745257920328464479274910119212057097007\\\n    9247986381611144781088053086600553163252880696516327031890504726525447252711263557526245443539\\\n    0319110189704723124223406694402936752508004989276735359510683590371314819944107317454552555760\\\n    6141669185510705112946994579338954861228308268195781597267678832777806804157277734165233087357\\\n    5498029986705183807843121865266407118177108699560244283203837514676872347939234118613368236124\\\n    4299521603198278039287750730383940636481434499391131279943837955883817453140375631189630131241\\\n    9671265929661246428256434376716853462737974766864157529818949279231441367249186886904775458596\\\n    1444046004614898114470180903950665510376070226448789232622613181986557292529565853491133887173\\\n    0093266716782248070013507358105323962371292760035855181451204601565699559242628520181834748072\\\n    6641171453844272886337708207965593540900375304195080916241427450069630697771493646630017290988\\\n    2815508241498191749711411045710087423233508298312096723302649416131775299403125378578011581800\\\n    4422867530517271682667047600875404315473218980874479281327702972034541703162339487402114572761\\\n    4311258330947108313833566371875053120997758960900337500753843698855479372331157896200424476648\\\n    4497446073763537570389891654469556342430062757295130942840372953528767366386372893817245773716\\\n    7331645282930550289058716818613254477063080273867314903338202629849128361496065648484625302836\\\n    4128875950224998497739688880741213204897390524636307861949848199003478619448711040587172081168\\\n    7034844050427428256172028427275479864306190386944694762259619483341794460444520652377303327406\\\n    0558816884872852829972737181631536570248153332303469768804453247320239381237302188654281662211\\\n    6491749578742661818469972152222609439051652554414119378115129900911986243812203022736918072192\\\n    6937244955376661129211129949698123994244589002007139928380960105413556858645613785486344168619\\\n    6433591801871397129456831605840370674849616016342925300790424938074391225202224566534071911119\\\n    9153035312039130598132745172403403671308136622062913107479516715738044230239604437969468135594\\\n    5117081187916714056325348270919737357989617948177277612660191892205875039594384515460468270296\\\n    7835856327463555254506762832987844230744624371080093019436477941890882092560362532952832231295\\\n    1037119435923144921573581016046427883855039958560482005015069971677507003427075606843353854485\\\n    6366191283530717941235618535768234065922298209598916265731895010661406225822430283125014087987\\\n    0300266005470539811127513252293876913269643695214799036252754476643119369220741214425867869775\\\n    8952285105601310442789113247018623980543186330948239912497539106386683799006869842811632848794\\\n    4396571538474391738321270312175973808023586658438674628248916737100164696330080300415341170183\\\n    1949909615793983429798989968014496618193714727896717647941624300763614475926930525996395000065\\\n    0671692586767508330124113509744432331741426930943796102644235618304789245983741577966394933904\\\n    2699868685442737386604517633105750799341486922994913014190415231234008323622271772055606708336\\\n    6124565314945769622218634736771145256437546477400507823684117240450159121588174233905911433359\\\n    7139161316511783106336294399498944957165414757005196904474372147885911862483298834817689769881\\\n    4588260426486286315309341187817325352958596212234448986546814036236410300603028990857869583092\\\n    9154253843132285421699153596600963249423750714372487339718722102330416904398928393212046647128\\\n    1018658631497268331469393791658158432204791613366979023358313933220744104125823534801036222264\\\n    8152549650837542413403465941638403572638228626556663828066346081308694983370718311332499161965\\\n    6860764519310220224741060726197730689905185445040703807791955819876903581510644667667385936150\\\n    1249612145449091616273615523551086457891535435923047953615017085345099403460950646827096462609\\\n    3743752710730072495971051970779561940020677925982008883865521609481412060222433829585020606765\\\n    7750578020759722700778965018626788078952897190837203488138741867906658718201692142096714809737\\\n    2698051371154096473854536913270932629142557085585922022928798932489426462346070708064685382528\\\n    3322203786999228349377173648192564835439111064306937771572620167912736104481327578762611382955\\\n    3199855884119194821170502191858937314633349373272291566316424026154209015044073012912912586002\\\n    2118676873065573996693383276370749077579556909276960639199819741104685326384658290036459227314\\\n    4242244436928206773157128968291810749151113183812574385428233945960391501415273999846561362227\\\n    7408059506658409330772635348364691481442124435233162070043806842277960839555600971168097772846\\\n    0174715441035155140117982155886811477067713308505101516320580485257520021480100061462722672223\\\n    7687467727262242133510051209196200746476563844897723254743405187572853402228809609518837560436\\\n    9259042278146924934947319264799365976495326315776304478316784896778620616534256995352081574326\\\n    0808700861886980703927228629054883120863286133227686530715486022993178369967015333754697166568\\\n    8002245254754915215780267115591681194616092274917699266476881124037855245689532714068537813365\\\n    9447532627932026129296195644067437103602709801256967408712031643627299234026028142634436352573\\\n    7131724306671057946060486151461768119114919195821508988972149854238530669459473046025686648043\\\n    0080731298166933513090524419066542963927065762969101092756305901558643334417105135158850495001\\\n    0374853069416822844003096844359251418667483669295991183368616341730474368190719581479114613943\\\n    4773861714566241984191777336093695812981047067056264468653949649389777032875555704251048938173\\\n    3815083191986149345698368111468384812021493383483559141030824453324246124449810427040134107009\\\n    9101342263893083888591272307116869688235128536214971088460477447293657670213808257650730661123\\\n    7105633274724584630000842923790680779968577808442643193234464768204128084344524332946588597462\\\n    0732322028648126828364037377789836852033139685040724175314295973555553206757172469001184204480\\\n    3406172658353283168362020908346765908532499747956218569018307060762300950970360766118852238478\\\n    0668635621326288061278588381858187678867486499167894488972206794549694575673538030993450095995\\\n    2480874015451428995694349319506261680054482316602679276986761719837875095765070036374191725691\\\n    3327281792044512129267905833324473131345495286099038623941286244370846805804761803872851210094\\\n    5942765383022680967540483108901892275456956175648726902264182002858490096045048607941687124725\\\n    9279954271824478064393081170281162827531977679813898803207513882624124209315944466174121236067\\\n    5582727758366237923430979833265619571369650143137377488610106530477013941169432823215830221987\\\n    9442392082231013388798478081972535563389188748948480991992434167188500301057188886248206609778\\\n    2932228848119573727573911305083000358067064348640652142577824995503592318552284967033627106256\\\n    3660005788005822474158035427184099293393184082407437806110554764295223119892987416950148220655\\\n    0798851228433345488063740011011101709894211030970015613558484745013306353251083836060057809898\\\n    8337110474509946294643041435696107444058766961459755226364298538335262001500414159063291758055\\\n    0750029456991617489353400704896032740397057460338900138071491962555141173256929728492061597549\\\n    7219698326477644657149376655790881682808081972181254517043688409304369727671308864173109897476\\\n    5162708831034183304075744072888179411896290733818718287018475540948108073446508947157939801624\\\n    0532116776392542396233560946065895334886930666665718788710156869458840024471067434486403331120\\\n    7632035400209127032785235838793751912626009599484358564255713563319992215786959867125830915151\\\n    8412175772400200338239620499451259170709976860837025124010733638600914221536844824833127513855\\\n    9770781960906546067043371289612646493487842715179164012984155908270130870433661041584711605328\\\n    1966613308188590736607788861721077644998354508830538284463091330206936690073850951314395141438\\\n    0261837635114065630982828764515489589169699835613778746842450731977090813393863398584755481245\\\n    3074594944417863303442112556376651900803375245037114053639262949936018592753883366889410004793\\\n    8710501141109322832053337377137611630920294793655629152131896738830210373434366362070180148046\\\n    9186792019323083212083787337400648266005252559984027819838360514323282772700227199295519811971\\\n    7942028086015129552913097438857125309150765339700252028528586514998944245161332001525751442054\\\n    4207749240616062037587976209149606948056402729648514455857514897046351487220327390766387693783\\\n    9363364787568563350243094211609630291540038323099773971174552252989993740000328505702216999865\\\n    6737826591653529273268862161754839400860228834331249239000521885958943850535967448114404262480\\\n    1206985099788942465309431578830377218269332916698469388859275961547663028194013255947013733121\\\n    0610256025742977948157848491212593590563131249981463698723319876813760019086831570169876930631\\\n    5114814799937815208546844546669559256126983375349492151092388946127116438638969278624766941128\\\n    0221378431909300989262567942353170147389267422922661415379015296028309310021379353924605128075\\\n    7669390873478807833037941458405381070348359901437957681007940660113266523505934264935467495704\\\n    4783600264271339515108949018912949399050894339281824049305344438755464496037288057212825091258\\\n    9356296491450671764525744719547334344896063400978696251229052234186734780826666479948664818672\\\n    7805944353872115408937857085548828422044329060877483180749773716209056873485054799559365224970\\\n    5394849041346974378201676090333303243550905178242157842282696124744541738261319310455955539814\\\n    4441390033896121043020078290010740506967302345792128521781716266936750049210157026622790309391\\\n    0314483601506428605653660697382132011241518072852469504920256482883704295856162564238762050918\\\n    1587736366024458438902136559220288560131025784256332507001540437235637423648582621928349365532\\\n    4414201698339131273757335903160306329289776563504743822986242800491780658023702660843963808422\\\n    4731122690015638928850189960701386819579128547435831231934453345734873908202623427698499926992\\\n    6493632695964837567950803013901568643166001309573268703444480883929686203226691101677264298696\\\n    4729555215587098740590446563433873387029492142635221350223644375594133167489620574623077130838\\\n    9933966615389458128276768846029782385413014849082887439995576246789162783348233720898915368460\\\n    6701620236922040650443638553587107887153280306598139356404275947470939680535370161663770429981\\\n    6398754943520109058358836992493009126011527096747160793378741938140966714776526665749159306852\\\n    9839760510927529381720641722297131924043358961947636989492474867281649826112947601801025343115\\\n    1179019821759106650321953522409973877029979624725484314962467175993669361076393052707140800524\\\n    5593362189650824344986034205266092033187474977289991252251431229228607962982811345243716066072\\\n    7463729666264261908392022373995994054235402111401948990010843215890834609165837293705924341790\\\n    7079667774756214612221482352219361449910247864102675169600716011762138930808462580697465876967\\\n    5434910023331253564614251097632931571158075106132995247690733833079796309877396836118143317125\\\n    7332669769600338650357072884937626871121679413335979183785716691448707297890132479761971619936\\\n    4101177151288303762935138901201247555596267368472461020262105556139995245979002049794112530494\\\n    8860161794057528251917791391077086174229796671330541265215422531424856652323732590761256453474\\\n    0266040598124060528732645940776933508396657336609164436944355565611979764593304622989845908421\\\n    2380389563004917284093983455321946882011962023242663131523956867429764919898968686266979945673\\\n    2212083041400819897144293617953839630015540445194469720762403979752947826308499324991887363458\\\n    5109049413050949249384479151947084687350547569242311444200963149439249314870192799209084823279\\\n    3403620176455844285708970005189428018199906769554907071872997977570017180857346799041284043539\\\n    9524649467156955805874721256844617822997274998354847683983574151358113181616493879452097548293\\\n    1127331139705627925905730269830953860093829737670496743718005831602844526101224442614020034777\\\n    6106325807036500339229549035189441628884756558801344378459471820717510663194401831231800196869\\\n    7608004730510373713754878570691320201869672049369920297038076758520822503387471086173519560800\\\n    0336232130174509874979604843599455718384820728804411287730480095116232893532280880502743082005\\\n    0653998353390873767650626078678804043323384864224261440564591599507774389208663922882010510298\\\n    0696264121821261064401519353869771400145143580991863837497819366005984175554252467701569262889\\\n    0263597546026578583770500287729017100780473359451648738585885577880433641959492078169366700536\\\n    0357695843808152938855093812577397718486138494090973226397393769701705527604384238496532410237\\\n    5208672907136660216787165545783045980149805463020494127404935510337018679552576978566402193251\\\n    7039772336451761446044799820680898888650539612988411941540023343985560710767982352980268874905\\\n    7177075069209236086517154332245776082808147901347365742427431372792018905586082847307416739759\\\n    4792112724831784058109729118975417477406878089403254508224108399252986558203616101045733139117\\\n    3019794846983156518357141607571046767894553091487627632929641275841183871270498118237280683511\\\n    3011124065188959436022836380256654754178579305423417293627439430314305563135328956171408829788\\\n    9716344784234827120623649941600370328575723659782365239359344776758473949439469665127231784305\\\n    7789865754558382049663800825101102752379797135056664696245439539459576670720270892978720954390\\\n    2172098418054201944420251936562960065150683689848619639427627815820914208716774761215450206742\\\n    8494587965392656567650563421804854282590458951150524399013686614829457433964710497946603772009\\\n    2144047488712751837556793972984090039604458827873700396423725717903409820523821481137572115880\\\n    5257490601990601627409259100592243257532358339510017079608073019719540653249165159450810034400\\\n    5697246760598755970323038180149316092154134815569396719506626141602443054739089995479007342260\\\n    8867637821707941873622057393643153476022411350705017523787836711928461853424585888597445409202\\\n    3840680240485607780274963029555224922810363124773067583290163317826867909674784241091640807596\\\n    5593457444090741602886994789284642738521601257639048487047535099075507915843459745323958378148\\\n    8525848413637335113092790250732829114593649230461765720367365511305266625153550408907417175656\\\n    2995588236710331000984205112319548266195823922483249106181781296255555781228104554622771289453\\\n    0772452743197352352833506756707594208312769472983347829450283535014797866816141276485114032472\\\n    7657223686735448911600003503131378932307156211135191461884680915478918346441725825333900604694\\\n    3381678351549894336491746292345185544494410351365055909120925157289388323466486142219739332591\\\n    9221218110876962866459465115816155560948848310118726086874280828386272092165864124272869555928\\\n    5058708614175600655720442393349675418437080797879186365934777194446786702205898567332842958383\\\n    0538460346952498049610979197834198620195278883600866637053506024256897273734868262079207965898\\\n    7025409746741688070642609972016703318231236826130374228257075583038003635122277077668646997616\\\n    4016426989771016287112483895252161543560155417001553810427949552408063700733390379079866049163\\\n    8640116252806484267857574465419565782533499332786327070354563365852406118522298597871718293751\\\n    6782385532412704052608896863949198257963532510995697651871580962722918766143864427638684469382\\\n    3914195864597783804641317945861637501094919325846648914539299559900555532641042478547438780023\\\n    8101010137802166129392299252638360956128401986921803299878367545900026078251931210053475736395\\\n    1556550399271947194014080506015557439439996496349755778516712929183078992879263036944444963979\\\n    2078754770896648034315655449958821001609952737525517889781424642555797162858482164240500353339\\\n    9932187236514161872248384146876105069171559903028418729308825975050256641835631571317124480728\\\n    8637926259761620341891775682888408116502998219843402874677077811525211509308447244880199634340\\\n    7070900389904941615798370909071997775824389919092134776000626809869602278078837512134493031375\\\n    0571840433971890785374840239433487377797707993454646792855623302873537575183769684328380300276\\\n    7098283465859439156936297724177817759525697437200421782367698707284403657421980406485744498965\\\n    0292922050599357052329109889022207237968636057229210382281753235344368512352472351481705571941\\\n    7168795782526250028404882080640601214923632185714698483099469972147306051486069653344707549135\\\n    8251203628139462278814185795611473579036237108769262225847235843741617356626309609401879820697\\\n    0879371207963904996522806308860458416885714208211972135245928281737559028792632383853299923619\\\n    9412235344272276032867984059918026550563778511513132126758815522078023658282484706162817450233\\\n    8842929402225844314408789131301957289545165531545668424367043330882058305494683419801367504630\\\n    8956812522049811356938813772325879970236208824922950563507079358477909091611129811522572366001\\\n    9739946490697192084608900013592403279850963653167799132044341962184617770809927307571970957927\\\n    4244914158038191433615548164881202308452571954665518466171168768385387917850162760609930396717\\\n    2546670406882654420861378264821291030457224088463968535866653535417069742458446128551590839276\\\n    7336023703519396764189444257497852409626106223228179681524756236013678981187869824938760285744\\\n    7171158447813378379174589843100866845042702704367563994342449394708951559236239543400998253043\\\n    0968069898383392277508030548356484303443296239496218580662106688049288480674557427816668179556\\\n    9341639073374417702798098993689743570001752968883425914041751971295018778132896486934613437250\\\n    5438833616329682733848151346709993681483956036503379244972069804340576264956898079098304368281\\\n    6203142999378881027621889652013752090832638529692244863358340253660161819202773427280742126221\\\n    6506291572635632669232334073345267572914076523044383176512046475867191608487863439567829756239\\\n    4316224464495429348660265754755160264449537491790813004923844355627701199208296924606297398909\\\n    0770713281568136169878707375475510074543964462753991418753046501628631964180751036836638561199\\\n    0731045378417904472579582967333619686760183715680721631270103843252254730808929711447646778655\\\n    0554252943068623066512016326127408680846324600725418637128035088812701308310847369868143376069\\\n    4459434390537060638478162255614295655114808789110327236182650093295636659153130791430123556711\\\n    1870832029326333673654394504882320336704143768856684528633980402964098343550083586802444942875\\\n    8367983733381252384703829581540559925084601307051171304892220541644847715620672110398423749010\\\n    0015724232836747252728238959397505783203670633225941151498112053493294312333290656941607860645\\\n    1034616922473117625269483820594278809162563355759126958802562146383183495074851005733385961062\\\n    6833074938315130735994544757923088482964620063305864503593139926601153126342623421983138210785\\\n    7222604958907316392421219055700945811100505993075529579584193101496839898748978929900912340852\\\n    0687789042353033180634556625024339616489426164440352471320630604455596077077491056431156080389\\\n    6798953031104295948273928464355447716230865910329807516210980973029134477594621598856187363949\\\n    4082159868698531909865013469530538414751935641500809514697845676338536501932366408865514052734\\\n    8423405494018365266419811339943892070656481978019545372072424412902091217036939781545508094676\\\n    1159252380006423005637554764426748774067490117445973275130696268130533387793044746194159941650\\\n    3700197490984103610243464205907255034560276133152624201725752661614256512232705174512441311982\\\n    1203993493792387562991165900230719390751304014055118525029411868951700008206651593901325301389\\\n    7245844723883586624002236846871891631210283284234882431196880521579069225893865500211366258592\\\n    8014512762894940867015625330477910854241711986710948590282545183793912162718024642909327709455\\\n    2327051803727161292507771493157499825061803394426960491301849900861388834775918458034054164277\\\n    4508884425905467425335643279858965750378656027570212777801961573978730227960958949297337659327\\\n    6945538810380383014448469406847066278028184931117650210290717729226229948325817451465537041591\\\n    8371234935268511410053492758863066114295533432110932943682970734876439231832556714256364452871\\\n    3220590834309977039841455550515112820275347342771385521254681243629170915148179521102532428140\\\n    1182534356361169520052059925146789513584487652284988011108073372291754129161663063896796187727\\\n    2535182867117299155089874138958297890156271571012889089054861616940813072823410750184204588226\\\n    7958599228866195221433949121247268615955561511864784341876429065619917320041330306197982806683\\\n    9964416866013519889891897567269872837864475217081314098899450350194363693787477177629517408786\\\n    7161409458833621771556074161810740651000559187169671793111839673966082603137349265391859577264\\\n    0879123696022318851941370121543150526861721141434149094579194134160654932166411385804936600320\\\n    1779803933494729200371755059733807069252919554224778936551070408690862855213510557030180306035\\\n    9485240164445638697258014705340697634773296320648495484569226594829363285103930983435242764978\\\n    3073093718647380580964229491168538150580859885725502223962128882271877955601920889744942612559\\\n    3246151983685394210718684375270742764474239955306785485072306880344119451467467154487167294272\\\n    9388309018348301785161361150158326966692250826441009817480629611718887286090225712952049216325\\\n    4311858653416532715946259978897951709863269761478838245366824842177947922210765643390111547577\\\n    8798134352380145329086001949831757041577945008274524562666945875612673068134410098799131619057\\\n    0855453719401196309425164198014806621093175954302613566433421917214866679348761974100351634565\\\n    9246374105050228461915551985027262555779180471732154262449306931747169822682171098333425023687\\\n    4837789703475767112543326569111117130128374638688674896464983459640467710274145579574871920877\\\n    5693980594661935804386291722232866846178103118315835727897532403778837754544476727301833867393\\\n    4355189044898094603346266316454993789630417923726958508875734385988851307477881850922097894891\\\n    1131369070394774252858094306410947294880875592126991345916089241997304577341350435976786424460\\\n    2847169164459306713729364662917358859182327676392801490921502659503754258065345652501585193696\\\n    7071551400114026297535270869276616776263012542469244428543662283784229498588991980105729600099\\\n    4494164948172397355967944985153920320419825392653848430227351579041728628543148402988364065545\\\n    1552143095332912238120185779502364072377930184341996382630860887946416323430518140555994967881\\\n    3151278499495593738282335822708688159133074029848981856107325563731365467614148551605143923340\\\n    2952694034392352410967108700339312430818668642192872361895633535096084369065333127162446697547\\\n    1159753538135033251861620559528908845672808916235561940354258189055620659464934243911291715283\\\n    0818351682758228753972164566722319661000125076052581212509207221775909945970572854812965078831\\\n    1988890105934082739426618359673295692744121191753730596005115196547217108352073170089904701186\\\n    3440252587175478644274928247217122412551375908645664317296283696226498925592679911053796025526\\\n    9117317047601501376271041219071941177967632294147782931656532053878786969718643440374563297521\\\n    2291894132613634032544139300173324306341175037947625918109256288420203329244261502884939225003\\\n    3770564763989419004860970571940006499564288610351392754614153081984532433992889365941022270580\\\n    1228839132425848276439481879047414071651876193881532493245658010029311631941366269729109609682\\\n    2476625256737863638265679415711009895189191707951855195345913516657361435113933183962714122899\\\n    2965266795316665057081406890980249032080104188394916447095010771105174675542077305993262073901\\\n    1651398236754490617333960221697986884264113623311313706381349924820659660561237483979007153328\\\n    7915489950221474696772280453501882859512859473950983601093261231181347791349063972833689925823\\\n    4665830311074900567317059718801467726561542814087041503897884144306788217356289996321526322806\\\n    9941767460022745447469883626774332953679951597354218034002387932714688260833522800122169609775\\\n    9162489483399084828678788891292709099214457526723200084621691458342451948841510896774614941177\\\n    4516871534310203191578439177547978322296728442355347680688503093037225473988758318347119961672\\\n    5953892536817037272509555034513684752118898965012892672620460908264159900379655745774620106286\\\n    1596720429799138704524662252665772395217925658693181978405739114058023479285506208494707563021\\\n    4631329330894865929737040983956811841227048556485543207014174014044566393721083021123004356644\\\n    0699146039176745563923916459492640588638856494498473239697687601083285651109616820941955998890\\\n    3698890269605357685989507202810129298020391930820606836160927497578751241988806632754097391500\\\n    8346213725161603995707968412709491505545962626550521703074816496680472521492648622785623429413\\\n    0592816938587555940852019214616123355701783405188022167604400495203854531061482122081321129755\\\n    1923189541531912090853648346841550426520788453907930886384448359277469590416349072790525702374\\\n    6709392508763932505952251346174031333045439831662130879913412282970975558521496976879897884304\\\n    7575589099875497666219961473749959842500857965550162430401156902885635912943573982354944810636\\\n    0912679358642118951865024416982345957761680264596109278938315321040679334633651450216245895095\\\n    1583026541138070242705050656720736382245157177035057094847590300486341692548449012285232379057\\\n    8646048680745693270993120486181881968679501119771575907552832211062481538235757273453126779331\\\n    1042216181229333273489547484298777663098377506255555641462758054995766113743806923262938437146\\\n    2077205255360803959157721969623295505824162534936811948577038841187593479514569091056134732301\\\n    1649716015098736611689295628070029577365249399609032135599518097672842997407977291589929214652\\\n    0147942470752751687399657384060295528273123098649620557965265822041977464139767623629217567740\\\n    6758810289157783089662983170016324942442803406693953318846823284148275202993807336459523215157\\\n    9830642677635369638599390237352488809598005395930435998591279186745194600824454785693479395408\\\n    8187988973717599258721907917375487223512882457875597283490639964132263485826747961333235668379\\\n    3414310301046065507368909916797047010173123927643487701634255198121761008921539482035289401915\\\n    2445475592175381955550658750148750549108043354828853110412652775637849193123859186276888455931\\\n    7005520656049287028148772321050612592792338713074975612147360659178671339854313141834130845104\\\n    6320170066040921105275748138989866662390291413281136182248273012578586364328326409576754838953\\\n    5073933020112135818399643312863303183188901564099581702109371713485883378131632442616862240087\\\n    9318726871925784349564809940216865311995281908956935258512084111399537442648529033495924883629\\\n    8891489635245903707550464858970142578332249319509823848923953132139183816396859572650046733944\\\n    1480824486975608389717880252022294414735243035078860300685631788137683037169838023936647161022\\\n    0153691370888888423833384576550179414824548572095365631942204505385025350025745398237810446737\\\n    7851906985266966254409367295189076596504934449605907392048279492387604833023401432351307040237\\\n    1339490872135420056596767033835907481938277939624987900035214511938540687915588548720450512816\\\n    0133236769095753678154089986122108376739573145366003743332114219284586830016505060670167041362\\\n    4138951940422911098981003522951324500309594117804082332544339071248194418198378411234089595725\\\n    7746062506739650647281160245321158692407958493191649684004520833127136824404012619124021649708\\\n    5377493949411295938253920269685119657729855082332352836805661809820357068286458770163398729935\\\n    6663795641811968640605734988525237007747827672498498518365226034307974295401029522905714569710\\\n    5899711383118438287256380419764731204658730853016316794354432868548789173153932553933489187167\\\n    7598173995487756152972132658247542184080564480969084354323632381512316774425860429117402013412\\\n    7870395299068566209897787442244511434718252460015773180281341354911765661798820228050497129733\\\n    5709713467724954428656476279141220957536021489393175456625795186387444233864891852289899235358\\\n    8870585692484657426418395957540851093209130843646549695299114466145176958260115595752530335963\\\n    5532791531674398041947843834504067349769138046906654665165335843997233450383377331249287993348\\\n    2283392416981124089664052118488660742840894880494176266795835037129868457110769421229394502261\\\n    3457762166964308334478636047242702663873088039657333305977136100448268907397093554988160891059\\\n    8807038228701760628571618647497257896991461113696152424462353846466625386358780482368982367151\\\n    3153023421124983362518639363717174191526236802722004444986410053770528847179321930305250008999\\\n    1542969775451890928827214672784856969356805864674928405335671609470205442756223625619543551339\\\n    1448138990564813561485278347268121529161969932966929072637924966635360824028893100013930643938\\\n    0654641230930893445726677614631953369254669837210359433978152809478345984398899320524415972341\\\n    9047158553225416916832282058167659734514972481940728117310656330599725279741810010591682618238\\\n    3772762141107025470222027783513991372696353780423886142655795799616222841095810790661501143412\\\n    6679693859776360377184547478644935777919083523271669510011521619296170770791747015742517639438\\\n    3744485976123416876473921158230375303120181064568454064203114035523152566259098492985255266026\\\n    4129337950562981249565812963578052429022302979734573570850749860769772234377076741641208508989\\\n    4644079123960456916281495911664166965385862351029863424086688571581960250624092019464219796055\\\n    5447839807035392135049379564556605048905130475050691889807019655056644491699581462693396263873\\\n    9741544267809172339982936495793191397104292643265484581183551112035517259837667708178842904699\\\n    6339915397410913593962131146101508626834910545108252908043204269094116122324347008591499929682\\\n    1989233789147963275669663632642746654301469076693637507625578145941028820057335862274523643520\\\n    2071844626425005943993308461578662423233990745730769721516102044491540657478875081156164826387\\\n    8067451891570578597828284135251481404601992045398056451789284302685309655556496268556313180851\\\n    3932240005880800762918975959539836672194878049245212987388990681405416580858373120772903222761\\\n    1785138762325201465133741050925824653666972948014603261547412144314031499380152851542366570336\\\n    2599745796950554159899745069172398891212805312436385704987810982709771301215269383308792205581\\\n    5425515992566613665024098328605141201672183010836029233888395544186778257466625186706129865922\\\n    4556409215955976025913298007909204021722747515248322202711024768107096835523055353196759473762\\\n    3464710988973334047514087008670092701005686692579273152934041489860205361668259713322817338081\\\n    3805453531874921732079848795849082271186309866757423193859893127551407649498954796537801923092\\\n    5812446107953837991719532881300728657726064749743445801331393649539148065624142146194213819283\\\n    5790467623968745559283269856073278330470460908531642656390766107106519652450286450988481435653\\\n    8992597412317503143924728852780213649782079395493157138168598825482699507209828498422498774271\\\n    0794300303408528609217974153965594459955962511330807987065675569817512339341263277013672816536\\\n    4731129004945207459070928758938541134663989023986365300530700867845433385475634318644288843006\\\n    9166349492713681768329806755011633965711158667313046113280968029975338917456555473522977782603\\\n    0619879951242303917171933720987087801142331571459514470364657324948040205676770396866663334742\\\n    8503203244088817856467637366050587550723461487089469787515264178333923704580476043284364423057\\\n    3783849022283040625215010445005997170319125249369894269797348548681820665711446168911882396371\\\n    0972578722859052493905252670511527923291994553438187824548954627030952913564459220987785625210\\\n    4457156330600343845841855749556764727735142022843692698944974332278504808594308609609174094137\\\n    5053962409359329172516653132144370567510037815893319967275702552395115020875873302317907208513\\\n    2035402898708561866120419786913609662593746463132791969265684281256207790819714864490154903588\\\n    1035058965125824800883031174463207756978143123007195202996517594415892827452274474372274933855\\\n    4773157022686873769038275750613133192038127972920329735986799228991751039565215681995013262266\\\n    3444698077455716865874197686421279075918066965095384435186572769072461526288879851988246665746\\\n    8586430474676627512520120570875003715219811244191137731677009030832233059014412135305191578453\\\n    4089311712678882082475368723033208480352690117265341438451925630087632596210709942226567333857\\\n    8972315308289744810820955396118668287588601089461322955117483448058279731077607997465674504530\\\n    1355104101229263487784673499334960485649082243100125031628462846131597231405525632769201989522\\\n    9635578638490976030477112928379122786620614546343878101112443641132835963677606009659712291732\\\n    7721864283361785017358827470782838783657282345488235146155669837545271479888735831349645989355\\\n    0577637210238490013839364416386443154083456490764123374677515849870028090811616418027366058829\\\n    4862763048643090968226918312510951121084253986772321015395572093686109830407518259886818268369\\\n    0800057500895892713995733118274625289594070636041824446705043367568705425484888161917743784741\\\n    6266426898490940320497606619458051779885992753570172050210000757327249899060516846756861831315\\\n    7972250910356906405294584095800052228996097320932751398975363534373074011498725619967251479259\\\n    6730291578622183268968033449839168474132038366115052470679459561280820790026802015108987550080\\\n    9371794198222589502080832692938836432085810149320566527547163807875598085223161867555919322954\\\n    5079986355760255678301276129122374974612530686999859914394272733825524804485189285291018161761\\\n    5112585307970058637054441759704579836974823538104145002876456103697311608842086859928823905543\\\n    5126137091689970627260956421238779982395789376247219049461929222194798848848963188335987246045\\\n    3293351495071700088412342401695653216906356245552524888907074622645994035580999631358089432621\\\n    3759397548507037948644281641410879834833301192579813401658331349116666452359023922253400346399\\\n    2035351943128497152241420536518794255228203721629244063420792011804341854513199852035809510550\\\n    4151768530966509673343859142456798641947138627767727655816254176143282607924367990707940796447\\\n    1680013606975135443492772118104905134896234776644409259826541023179316544925997359945035863916\\\n    5158512904372023989644796892712062975385231701560485309009439236865560594232098956572047424232\\\n    6357563590578463267285921361350094601852659504141201233886472138807618125960604480606928586742\\\n    9945875289435911290283995523943404745582424379388244112770928215988995089670288720990648273758\\\n    3779587744835670965140680988264808144357124166842418405262880360281222889122749400977352069465\\\n    7036127244075770798351852234716702441950549686232855616893405289779077407923254067351387842653\\\n    0949976314003718065939242561848280966120848446640943637034463123167061974577615127858357594643\\\n    2359229258354715329198362764678911183803246110675150018329222074219562103144084456641283893121\\\n    3128595049172610526225862832966506288469674449948701379492544064382739124961112461439688316728\\\n    9985476658197867802202030443113164384028622616850829501950311667308906563343394289418152203139\\\n    7739647525070326806306810235528044947073879522029864456066830160988095328759175915086742801501\\\n    7412425305770117744842269668389328315235732905441260711427393611084655781710671497280756600276\\\n    0306494220786388488544376599695486407021130238641354417422855466231139278093832585835021152756\\\n    9075657035118171452543725920288994176138856030510303686109781694389624792489910276095529868356\\\n    8707624066211369717168272375075079068925818288987968143833949067295001192688834546465695175460\\\n    6551802812473609631094372170292204238168506164702510647060504781417588043171462356658563457662\\\n    4282826568374053461950703926680095739694696573014233411383875752322026163794284616661567221125\\\n    9270003246047794030306872031306753445466111078795726774049121789473993812518382387769574892613\\\n    8892806402719284332213022330476087148715888962576044005766302988902587601418951691163700520101\\\n    7380664132477539779369874167263349906790462258345637010392038461073532888869097451863405924785\\\n    4896860580009370094661380501653287048781658959323378739686494698168355815864213088699603102326\\\n    1306502167660793696201502602447484168677136904215321232525536080713709595478779435638972579634\\\n    1428174718539705398563456698005547499773385634276435961931640696709253895155103251124699712047\\\n    5166968246100831151619391517008632136526520905078649673271309749637217921899124841403487140016\\\n    5887260287039159029219560704838727424831286037368937100713151936615288657225688455001270174430\\\n    3875059459042019424833417882391735607090169297854672579836247528499320577880294322209526334937\\\n    2267388154131215566149804590673903724321778048877325965115268066843557032842796418010109325656\\\n    7206437842702318590441947044267038406940022746062758510593517473214346636128349432295450747160\\\n    9078498658014118334804881096168731683961648968545146514141716875654220644144944842498122205358\\\n    8485905895769268731311073424322569258855389765108636300786812432682792887668623735295308795987\\\n    4435458341902433619253376909232736589300849415017120716461868805716702181521713841492488190403\\\n    9275865797307280326903675230149969526920733543762902562637133551394010912958197509931551323526\\\n    9797429227684497278886412649239598356980170477464933928728873413452776478729816349356324363758\\\n    1522731807291426685517581108909851169260333785958689391398316636681612420907101955180393831870\\\n    7072342036033585467652638234986087240704767231199031692025770798636451267430973337862918667653\\\n    4587469554075643681971720196024861579935868916613711100732669489726823908163724958828428052368\\\n    0317451885526877727883159537010439860755524926150866651124875029415029383416302086910720037100\\\n    1612338226083617318057947361421923964219233793660922619025601320803821082448436556280250678381\\\n    3311813041864961838187093242454130547937714863422626803383120418691439154851316858285846661769\\\n    5383457005725362213570135448219821551020819209548494118023957194719154628692788439523682494424\\\n    1065978546339075170878498919203189706841508447327179541553929951138546436990149680948478003782\\\n    1595264120462143158021059329524834895973532489512852834917696773674574804051271543115775509209\\\n    7353103126666229939521062536561608729116507694760471968306480865820355678238974480395754028934\\\n    5203062240007763298262626880140495404022290877757454789454833344523906425717009392365687207545\\\n    0676213808115467105954508113872581419629855870590587589096199872295560003340023706447520560839\\\n    4904256003478775472730977761046892124566141947309852265357813959483556787085827477804519786183\\\n    2996405406008303992917234248648104784616021057033598777176772592247434834689636776117060796793\\\n    0603204720291257014011455587236193223312848989883848995695179979020447488081590262168730140094\\\n    3457284717670391280925844864761126534254810520928756836574687810382136992164542889711681916572\\\n    6128360739799867140243235741465391106863817457054450151995889192546985787379136620434305444046\\\n    7926960069558790132346962675106803560732834650867567291272329467265189964408016791901342390944\\\n    0717198308603390843001143715455967449255623783428501633189100014619919884571078391066917322556\\\n    9353802828845727516677943641037017118788910666461116297654235823302994677003236360229552820526\\\n    6699340373596589546571301835564101988730949656415616818372743825349744824390653773834154965129\\\n    2870787806143246812981241634420052936464827793183706118146799315858371396291803958687032859171\\\n    7934516542375471801345926969783465427077197183871984656405673047852477520133990993322869131172\\\n    1004553225979730621670357597437181191461262302259650321005146589819758839960825037260305555505\\\n    9402608531761175912455641362658383802671702205038322334861648790499548383658460848894521974965\\\n    5170148495767287653544296243960845500443710713673100066068793186562760555627675375751786340707\\\n    7591045747422932434571315585860858320532688296577116420929793007389539514619264009261160993812\\\n    4470550388253228296978411612795807945651722980450850065358217048815136058703518983373892720214\\\n    6622418314132874908698486483811117922097245272303086755016448284594106748976306463723176765369\\\n    1828828533496357205479185511070230118869217302684855514676944837790964316401524367323899259342\\\n    5861607681474442053746925025277513088276900844563316743895836543342580453362229518247843068160\\\n    7275172080345264980932281129152723907779610369883760539313770828266816429336366643951099588006\\\n    4723546867501343090883300727793628240002253608973888126681006316492545821456835505779023603646\\\n    5016864680941180939689703648383489619972486323194102584155191098394550910088918371467996841052\\\n    0033739245242562481379579122811184917260441806628869599615917489481728677688880385675300779082\\\n    3223412932523272140675156731737432940047358521810245404334544723352833207348895955343454612877\\\n    9553172049991829580057362614935228337933715354860173431067586462595813048245701165380262656374\\\n    4896516737243188787435581046737718236805480957905528475821602826089608794137742086000224122175\\\n    5164290267129782092817664271767377501049563000660901487210609567545555029226905434903996618617\\\n    2494755671471372832943597076792777353191458474837986581410371983585590078919153409204508142218\\\n    9214905571645258966958878935259169006959802111325417069819050686008698969644675385659242542830\\\n    5533983843460775186446614893779896316467290577441983691039505498012029504095834461643760582286\\\n    6794533308576373269078609121643345171315928906244074716090743889232957163115421093492787118196\\\n    1495428902668800424541576255674025750499406391178112525360011270748672890552755262730916026723\\\n    3206755259186246402019819909733429164164775124221790385957899377014133201892801073851182938155\\\n    6237368747824387679004937978309156485485320210129232602415995169955550669603918729190700780133\\\n    7831450342193699058531255450177787080067083462769784733159137782413505861505592953599103624017\\\n    4028212698559866327840621365339497118437631934298643959940250284417085827045571145850997464739\\\n    3706057992567736019615732499537013677028726319512726371640404656397617016278813427527237368318\\\n    1942615740976750802739354692436755602109567373587485472497333207217755715980973854471758288779\\\n    6804330599937632125357382756931936412872854744609453564773879865128644430638443832324700705940\\\n    6064621836851733128380753150793583954980030570409188522835007061948675855942882656799457048841\\\n    1034501433459322715191737760399884584999095886360494246076275621726210352754433647941195501877\\\n    1941787220172493127129735111522943288296825900601797914405088499058980728299097493046022272700\\\n    0635954913875656643376711172234290753976858311427646901718776851708914348568399786432066605980\\\n    8148124257229539918922592242777662295000564923236044370185358698236856130738976405361059514893\\\n    7793623848583808698596525052075709056901115724967788661004527300738202643359227906563939270093\\\n    5377349832708115290851612128224931664628489247751080916001646995253763866343370728959343629653\\\n    2143075285587903498368151914537169881917837176526081835794360969508534335635278804071312087078\\\n    6334456079164338626614419569917751043523385858255546867237510145756964401314985742769570367249\\\n    9176624007080789354555033442564447789809531550264948379837036323138553407439753558046067074051\\\n    5984888700988141740241862068190504277693550095271735916434155073065464880664913251012288898860\\\n    2909455399292380878444440824632661131731676327013874987583723893438581319781717031562539934516\\\n    2973739800419448772874256456319344951604590654049704029126853382991508798316073258040538658719\\\n    1544223464512827500770896247975005741981530348131261497729301312315643963575284222746067555348\\\n    2862365184498276528748161982981146645746830275903329451654134453027041961056595962414471990837\\\n    4529967256716496751529172353858001577017397833207605871408033606920432727226161098327198589959\\\n    2058989108968950232805879575201962853999707003372243840092101158429226201394705695487613987052\\\n    0890869306271818577334643271463142469053524211442373169127644318476038742133026763360363683955\\\n    0868048630171567659893774421364501667666951392777261444197917976118561169510707044749696359576\\\n    2201919445663766637307620293083035977596204775830201772043172417885150577178924191165555773725\\\n    7015021529697876438753614215166662034907382641669784128632588396119505656747615898320985435437\\\n    0508885020958922677285432197572020248329986941033782935777286239928124435017571024642406857003\\\n    7129147728348890020706960946624313396468061833701678109488746548413888240932346338698301246597\\\n    9326854357846632831649740755927278985637361619546200617428573496116882728951174147589437386364\\\n    6763102087871345963273884672777825588531297874582979684210826091623199019075698265568435114087\\\n    0713839272349475496866663477126853929253169788597810786684043819179303512651710499874064673869\\\n    1979607745639007463304435039197759049515510356830511756971816180772459428215510950040990311324\\\n    5552488285947073282901181296568538902785043206742431440358659089549684766409060648448177747281\\\n    8642045557958900958591095255785050323663405540059583215798715374440711668726328154699652123823\\\n    5908967085307963135666481890430484412941582698461286716893348540010058993502683525032641368067\\\n    1972113420930080784069633606164613503925056196371715464664599669583626251212023643961379748639\\\n    1925316463600624907037980655330442184967748165988167030857635232596141592036292985467186086478\\\n    0415567764258301148067424176711718820565660294728648083491937684474874049756825453351793075962\\\n    8133844400955523769684147309032354589825604994994980323178264222988021700486511302368723425856\\\n    3560169064228887466712127100981425745890672208936389916572061933495440516168958493719714456671\\\n    3420678330089688129217978124883034814171627420790798216380997423477478210131799687720476772984\\\n    8852104658022700039789027131224284728685353395873415148539697989079643623807123752364249559082\\\n    7303060743781914329048287120849545732710905930995188676419469509118816509815514901577798168188\\\n    0258144629964255746211368236328442463056519003741176646861013392620973676048429271434532760172\\\n    3681728514846544354526439324824857727490886389231837051214746709857928382588975723237504316474\\\n    8536662376821228597864556879594415030083421817272423060767797909813485923860691689297744830713\\\n    0228097074889926743115187648561120392078025522372690966404293750415819508907089419398559711174\\\n    5094748032911884781565925097778177991656041684174052165212295774605649704026925209709596441690\\\n    5824232193462970611973741651508017738239940559662702713293201981537539449174357716998654151950\\\n    9925507067820956457465794164649482959506949709651146388227995360650019295798627432819220243461\\\n    4761973451307896711436930575921656849883833598031282115034511149371495363946301473744759515253\\\n    4963112023697050791409134243873588004043236204714615953188199524204658643660053088725195663358\\\n    7609616208937439853390854578004061003600762223190226959039170865021961433425140235583599669157\\\n    5001417590147707537518248318253987952586900731606008981618859521455222548116796203926487312329\\\n    5278747212376842439037968340318700965492362544790751177343966569470616227607724553651845801861\\\n    8661591241593316056283618088179164942076256419240209114409137002911852500874312051671432012249\\\n    9491929329834580406651871222402908591310037123842554803580735792144974842744261358778966877230\\\n    0482404537554087909779408683860121352033465939770582604954468405288824416741094119658446330046\\\n    8769396559258721881034592102025792906229981765382659656383297298794220764683139562911992343823\\\n    0452070869787361366733673146732002171660949381533368088384096452525846316540424176279979412897\\\n    7116284187302349891498931019696810913967378867085230503332300549934788463747072094085182688258\\\n    3764902129977026444157117598370627493168153440616078436643339259292407275192787443770244806532\\\n    7771394915328622734565497340314770663162969325770838843633156221393973645362241920163599828143\\\n    9936270635237694144213456405307005584113229853421374074762079147183016018613427896906351116996\\\n    2951170920103001504290755218699699338292411165801527398489935595964909594771352544844094271158\\\n    8092005384527978048809375850798629126077971905741932259917424606305978469614581354298374926205\\\n    2814208651286761254240854414855979805466934656493879153744840554509535207694879178414407334985\\\n    4573212034906919833379071753399488455836023512529939319632621149378361354134551037854002217828\\\n    0842422278246786264520327122681463533671025777493736529325481974542013443392617290575311590447\\\n    1944675408727538830466347477598106394740660619769015940592210465984920968765650729738899184388\\\n    9286244560195433445790707179598768199694007670466097517730963878235651469995910424858103122338\\\n    4579064944122824802236450527340159517019040906619398445114641596897845404089415301791697160235\\\n    8902064873819656376518876163634695881714060188975126078995040340499474598873786525493807185260\\\n    8633515734772081451617391603299405420096065511493909887504851841414486703432591644357242810775\\\n    6231219371122450278490823614114117929249476165001926281066961206668048848835485175699002580231\\\n    9843575041772170782259008699159334210617690812051495595539762494686564076662615179288173668500\\\n    7794684861843715953548972424732945305628544516513550385755311776625710965844426602565443128175\\\n    9986716583798490940352314438793673355877697266777971964378930537076892537627362048303512588938\\\n    8509705240450961797874122207459094375600273122502126774173730682541957124320852167128160967959\\\n    6565990502490649245328063431218103243492126959708083787039986184246323004060454746764307174645\\\n    9921448334788616253096285046680263834387202453298292084289655267253528892165235596332514308988\\\n    0824199419885150918593148057867398747661650019093328216284784342636754059048416152439584733911\\\n    7272220390596544682972397232881501413608990330119382378887465557543590088325268730124948170237\\\n    0214274018863595966356765234177894968329763007680495647588787147896010016215578549990998733192\\\n    3855631066491035349382448904219900307265399388428673783725223057488672626914334683401581407208\\\n    0906399647216688054473234394092338670306089119009799965161794220825029358346527245429971392406\\\n    2669045566072783230516835787474944343317143616131656029923747395396358037130786620758032373046\\\n    4205771650232629351743141613604302330893451124436038798924416939009246168982952144986420295305\\\n    2122517241214956405292160595182741048643248413469134596159730411034416163980289004548028708605\\\n    6172701084955671342287495336099472542422871149019344903234518381065994593924143089407266616835\\\n    7555609438748824001950902165429349431339405629851993073996998905701289755760314722866896575634\\\n    4120871841186924008105407272774206152900677438960626416802423456182772684633273325606240062888\\\n    9207844275882457619484804643304529496221937085180879289924422797053694766501582268133200488822\\\n    6791181360903896453083682633022328875214783840345961653278390802099939561887816662398422609867\\\n    2585951371400848502455316564544951983747953027405285146391839343485882922226131806926871480369\\\n    2234089275364563151851232885251310994022770692117477017524449061701103770948050022765560507357\\\n    9887782831698927111823740840471404188317631970864072433647397411596201677546960049858195017626\\\n    6549605426234744849273084384434547907360803844570406537947711559970154987728677559081909142805\\\n    2301258406655370593398499313298983101521243458384216748645730374784648027537383562607169940839\\\n    9898571493336645445089114892019792210478154764293425165807931103370611191129616182886683591650\\\n    7298303420312982555981046137050607903420536225819841982293100307160575094358644385344719733987\\\n    9251815112344270674654972090499210783337602960182860213826847914742857907886098689512952387625\\\n    5100440755584753046921787869389043074558451742120497766499077580888330417566820491925316798966\\\n    2111608315732402459451712267499586385630388894400854477070068318206172749870985605530079190250\\\n    2914859125336639054377905355029072249933217903520502535679452900164598107258344921683530054149\\\n    0573608398578814809675049925669491837046350758814769806569229064969928341619071885874947044163\\\n    4761371255830883811090109887042758657044227083072902402051458800207679872525316551779286750429\\\n    9197349297795939656084452914295459544878380209471575363421317699655264755849413379901438313476\\\n    9350631842073504785233733664680815986854966030605117095602268690730926284817945229302265395500\\\n    0634254412848393294820260515354386380665423318668401230298357281010894909294202935773007574323\\\n    9386587870998559151713490088262445401641313508837493346755092207868543527933182080200196678679\\\n    7577283211815860179684989705280997176304968902737295065995856624418238978369149327749777862238\\\n    4093651803369589860932300127638860233801977423896100845255255746131133612766141487457307003293\\\n    4015664334440119091419923549465160950237611226138947909983586901832971189906930828001107681437\\\n    2252184259309892287105784539752479406780401099074416442171729825420850412200708783280468176220\\\n    1236098992894199897981044272795171901730007896524906571076281983814092399966450231291433606937\\\n    1486989933696965415108774077050155811805159517031103273012030852218697170131754706983694205826\\\n    9453102732925786372783063331524459846273521837833951219016923233255733549685488102863465349488\\\n    0615797112467047328417959168857953688580712624553280415371207419627684696852676008277726377834\\\n    0541893603800005460074586828408010447726214291757721188510215573348302031897334854958093127659\\\n    2805466524287897471637443375521164679176178560162877540930538657715015031426872598421758107137\\\n    6154500258017753500172429036572039810873012428238789406112946506724898085492576937002050101367\\\n    7067011346033633692030704899824387212693252318112063295410683284578174100293786132609899971595\\\n    7941311978437251494883612888085604785483489912574783514703933988772863328660809731888650453615\\\n    8713896819124967306111674486445416760006366345300249670938892673026068756693388392326883162058\\\n    6999641931789737343214940028203528928504533047710058035184818530315143278334106949852340259679\\\n    5981309249055559836802957314726404464918510487563500326046322516456525325828552475636734734482\\\n    0610792656718325925866341224747517810034895409268293283495007802413171986093728663607388457589\\\n    5870753626512490621878312029132158724764424027276701320965357997580110233541035632048854110434\\\n    0626599210057798750796610541260451516416529960483592227206933012702956474868934840330738222025\\\n    5344603633984026584609800064375434933199632942030354979891194670541638686117876346276404769901\\\n    7854825571318802036112241480984034651916499254680007546854484476319348454541681092704883233271\\\n    6744650221480250130297228235381350979947875552467661672918254425316333557176936783008682887456\\\n    5300123285459270714033260290710863834600839865736917337525454496292097762608497478252930330641\\\n    3362667063916044592060446334109962705110348878651347769109527599522422209101651100173233646236\\\n    9905923979724773440063560110062461640034683905620910425755262968091127078241405844660063994968\\\n    5509516615652324081389105822732829795660576034689746739344181662412794888898467017224698589528\\\n    4394370349865920717148372676799468953088600775162567832349444214283814897647149267882494355050\\\n    9814705780399728371431348847933472840253818459914524902929135378167400578847308844523391012033\\\n    4330767371494560166121779027384823297657536512203221548964378699351429193449841965277948708879\\\n    5656477913304483359250094261805392765773157647748047487891410264460740137521766148731674505745\\\n    6522953494381177770364801536492181072928649610973121881009871268850219158842033747154124813636\\\n    8049348759910096072060766566289688697907392688351307843387695630012357975719322191668589595286\\\n    0619813556779817104138293092700238310246448391121634182519397977522875182011166889134575841498\\\n    3950292246082578356792555461646563854504675955220355226535219395625116384113165684273672135277\\\n    0710310156132043890634616767056403428553666366483026105787619186629229506087233619782069148504\\\n    8322485091540367300776904024733579831425264915275596529417963299166088923011852095839178150588\\\n    2584121158222768800947231420140931635945806137281319827499624866697534955062701560256890777084\\\n    7012113314871414833068114603428322166434267725959041886739772770975349897059245568327254028347\\\n    3695916277007376415819079250060208963812713977904544807147051858374769895327420954229028346542\\\n    1128985958130063331875857983627152601486941273543837120669004553649953646923777447770704505958\\\n    9713848245991836964919859141154362095021387889656078979445172801578620102501926505200299769624\\\n    9166009591774179597312723118375584331273263326623860685573170974735798952246281052970466121049\\\n    4243427309626307960047235590031226763863346846681143187695934482712531366135435384659210344492\\\n    4396691971414175628144703114622799386588548498072989968929911120357138113244616432341587178578\\\n    6650216272033028060349642263056564409832761663798943169947406950363717937340145516747940903282\\\n    0564554573543260218285169980979041623493208938562875935565652042595342744002892266029980060431\\\n    7807277193567323972936230223306687294207098129229488558793805629461819844678417952653337011213\\\n    2945167164339480254641592098174685818717619485053494998236249574576549184423630959242109277843\\\n    3844487570524095025259710116234646366256482719406350110936811701654429307955576457737369850348\\\n    0184708798413606948789426629763524499007069124929125853006445152708850777677497948047868270989\\\n    7542505608456477358973511923108153341485061503740781885133903106631575732649392567912886293106\\\n    7846362536131713094721176235743829515749824752869190503342595505345223905084842380380314858008\\\n    4207641584777999477587668491507333005053435154736404060158540134924620509480801181729227430916\\\n    0460838403517474417505618975198022544449740795874084433675117910090073949876590705739098650882\\\n    9913612340607821193123495932381950634070786179007487970662637577655526879348976227375804873111\\\n    9200059870957340335582424496149927356413283070372723375416108959543048962204051017629600970889\\\n    4961409654528169771405739205917080611554466563807876383125521505029166162199049209739050880327\\\n    2427849567685488668546792773150752866352979087258260481418605958439470271224337656772744218972\\\n    2516707394697038335135735462043623124500608659573532435719957674135893651258794260881594953176\\\n    3033713289260647776267774610564565902858482729748876244026162372442647804722884974456827292237\\\n    6481068093896921190693546032893914120775345828633063196847882006290013835147503679654033709213\\\n    3878435043657928692894244169632958436895727388948696769212702516804808530926635346058023483019\\\n    9585198621250576401424897707234364251047252179403056378480327009406161251599995848382549764325\\\n    1400194995855053226933931815966355425079825758843146927074549576919751897824818885751736649739\\\n    7571917750792286829850649830650087632390344469516546323281037638794421174873869794985587226350\\\n    8774168956160420796012415562544172629388204259137848469315111899820951765445603709979891072122\\\n    7850526709982274851900866160413663767268403103222333682938123096683462462293148798318390991208\\\n    6058063282331696585921933921606831628936886095966688231845808806869638568763582387190971921806\\\n    4504673238329692973541288319464035294847786808002751396477728943393715431752444296469677286563\\\n    2030349916793519405565384807306089413159471876652047883397335697215706408062147363370594819290\\\n    8479640788079765034629614401129951090485554180205885434230633076355615070812590938276039664711\\\n    2146054256291149090369344640367160642112385581478544194815393071197659528028609005990189878299\\\n    1828296813552187410131879828105431271010631041130483684672495432735506371481053556151092167696\\\n    6730911365098357925631312694164162330864673222255942579358343151816929996096198427300257014240\\\n    7908199468982909769320584785517936589517449265120836267888777611180128430703853983924166561258\\\n    9996294313584746727225886763745542103816577654830960830171924640803345372713875925502116262332\\\n    3621685485174711392265010521247762461582051544479232637643591306189298309403212581489679457709\\\n    3595299604051913963443435581865530153930967230775914818454438528219049764768806007834968391216\\\n    1484039593310871962212037445981756953905148651994531118275707578557388816468655524848846481108\\\n    4537932132834489265591290419059535210436579649452679698567188313457178162331224807451417681688\\\n    2896212695107248680447513509427677215427306464348495072422799242645665415041793031076479913140\\\n    1313808674532025658084789202782527609588875946180710727457215045958298975359044176778707135482\\\n    4076830271524595545879757852633535638581496270114964786344324387136996533322881447589219340717\\\n    1368799767976799884599118247707308548079778816334962788906416740027096826260770012816582615823\\\n    6949122516173725040232063265487569895528312174774502960411734414904022611379100186779258532907\\\n    5778694111924770201087229248998113071232047144359596985214199400976492810488850146235822501784\\\n    1888971710905622789773583095459954767076884785770215576578256464084877265674170136705864459136\\\n    6494591333624362961583857702885383164671778403742866703815334145884726217711831963303084694272\\\n    3150096681174314486441192021096246391748361050177940823246674703210840279624547687785456492663\\\n    9533183857086281587516624211128451816073012969181494109176739463708007256287734667079363759155\\\n    2008785888186453809803237007697476048640752223576756317988195256410723576479874497842331611479\\\n    7436470965761586731468673463394426613959552086953513130509452978426593548422905588305346054282\\\n    7177722746921649675602817021745968482550282263861734120975844032314245645560644474407238347387\\\n    4608247939214201097979173560489151221083112508965437757891481794171896432441431929908246955142\\\n    5163599226853733303460326453785632891568188859653093596328785370740182458302174636828739827723\\\n    0591439555029332424339835930973738313314538586416293220260602177544513378752550679026086282463\\\n    0008977216805088223010213615083935567671399301459701803883621426813898343876592152070517316935\\\n    6023750873266021135982710985467234288055219493351162006501502793469650384802014233093120184966\\\n    4987207874649149307070972170584626339647862567695057980029576464760575045280923589956525753868\\\n    1211599249607521120587314154535201925584765181699145865768290466132044695009308425134373937314\\\n    5126031972696804516637519905395688083771844433520900788957137732044472756091440885064678824462\\\n    0222038502419927818526268293757483686929469410055349181717911736266486207588076091046345040171\\\n    9807029037860367769403811885972078719382968696515825062896944795196626313704889005696018065515\\\n    4617658496519889536280334489542570814612259355407787157150325749668472993364316703717632475099\\\n    5716765035309132738783835617773418847745094305474173403152297906956937297393707969466736522538\\\n    4514811096181734760668476708414600309669101487411275322874094358597755784225881693479364210491\\\n    4761669663010924294861530447208171780369509250980801399926267718449338764354849831184511425543\\\n    8773951280078387783407019849285801742511214533451676908714707526085319835698432189101560475591\\\n    1730564178750807171268911397871104297097103490788453185332073184175378862293447914146341272188\\\n    2862947140902850317823379134557855168446055970292453862232834360323612197622465042432797963545\\\n    1900558828655531956113081766605039624542337979881804078959830629372336407019961610576182242675\\\n    3873083057899708587464704446363297956977249500148689864802276104395950477483200134514973215774\\\n    7083097422231360046790972688005356267602618560824350141481533634064018794663842328245748793038\\\n    9300308434623240427105140630111049785681780465631470359347775306459108173981249848760130657893\\\n    8093973412869565154840751460486686515727724670135961196221096300342611122306755186551762583337\\\n    0152104421401002519590679568447663273505063400433584760229115818269890538863660338137168100035\\\n    4687511393482310481082581832052807867602531510088867650208447787627128782760796292230212549729\\\n    6735583287621245402567356081222191207827926848235294294731398784541160491477449898346206344194\\\n    9682817320623746897313472013060641783927177563429788852856366829731272247652468764206999967832\\\n    8045380616454902509834217317747502470275377424351324049077799832168192417026225916689461937541\\\n    5583246246526287810340182858539677502762763932038157362963861060387866469526696474811924899525\\\n    7620581440745686842240690916546660186684904533703632087743784800255075525328085901660882456054\\\n    7269462367841655710612324067018796138649550209680141352571403843391128405113913186248625294951\\\n    5831244726421258508776169669808624219563316838423863453486994523700693937107082508686562493191\\\n    4889043319244950239643884620394130421891836009921489113494200618282539495667966378351992385317\\\n    9060097738440358738509574389390727860441152792996855899324487576005228394759100520806720437660\\\n    3784902956249235723497264167057793148871509481496944340503139064843851792013978378374028282696\\\n    5420030475011898026790721991492382250694396681055924948797385773041434662973732779762347989479\\\n    6257963987054149665534023505330275907501417507329773911403456949634988445557686152565161995142\\\n    9947168616582758726440668123371801616687483244371444968323370884327487275588903491014269713644\\\n    0488259141016110918236707865285496176178426830024619418024901671626200335601631250397199613080\\\n    8846768224231559223338900793654597723138969173823986786968881674004011154051325176511437802572\\\n    1001838716176692726925532372908109144826379324496573441314157747071230493833906118439090787793\\\n    3890960424579405037535441426076358212928880821995806930864340191859791567132934651207471302353\\\n    5302539853469134438972846190720304011079882757963503255299559271570911861446363477898810292016\\\n    5007271067811357709957137318909429654713362548925576848307939515625298438361160898155753644293\\\n    2851029722027093198067859496487539243847015054194613039853119671311790056812253391283621899813\\\n    8523876337293698349880383770935913176165800641241795060708135880203612464358450019696469073326\\\n    2822721186385112876765090457755316054899969793266829874561888833562074316152683247641700548139\\\n    3176571743018453220881575022195005171777296387943112218560462022079945675561016243932000783029\\\n    8623648779617325540213831211013606638900166510090340653405376704729619810249702341560365724600\\\n    5664880170847939043062670721225319357033361430822232484110900718959566342442292446477506770477\\\n    1712846611523776774474349145991657615451475493348938034724829135922131121870190536685462470853\\\n    2879417775482747369680487082585938458681164118136836261217475564939002074837700994638816147402\\\n    8063399707241827464210804300704656456971302620797312576638094540000235694752048434635152859260\\\n    5276711390230361601121114442238501075642471873138850529088503670274172188384952642177583489279\\\n    2739553382586126666602057304931978686706353176324641676859242380506366552237996394461186458222\\\n    7797644699209992652353936090535630296768968263377506207449507119791526850938916389096883764898\\\n    3864764152096904356789114621906622908785760736644250851577028404002332086658071738318002517495\\\n    6867780118623806672428299479646418058768916704048368562658231371495609037428613732637778548345\\\n    5821973509593585038524745765962043428139211570538756302610902213029735908251185639814622932810\\\n    8601658706998650344776554716254097825195237828231048643644601914836853361572871937121150289178\\\n    8758965646998211959487117786362938358180516124998164199106432850216384720983325269753640520422\\\n    6778271083451653162360724501788377232548121312138823135509684238685855508390193250189603334281\\\n    0141593781801637618725731243362187023155889928899611541840969144438085322320427672408697594592\\\n    8081385642287555818490116295802307365252178117236635780621328733863229119324290910823329466465\\\n    5706673672594462210476400137973048383241202518943470803237308724033025688347161240325226198337\\\n    2508223630777936199611047988199375338723425359968758547115554108523835395245089153763453109847\\\n    2981327328789430327161895665238771369406686753722167235297653887792310893417711383881643790240\\\n    5590916607256101107929508376298099321694042008224372205992504284435382665146540084612745906060\\\n    9817971587268451774650597640775971395745526516800295678473604250287663906069023178026792872366\\\n    6058929751808809363623832201993685348417048110060065135577869607527899736454352735328334242576\\\n    6079785362061270228186339004378605894075921488282462273954154169740810152168043501213915797734\\\n    1282142419451099693591968076295314942617294898961399343857801873675169327675926519081102952358\\\n    2232207445836633527958164739923822186721624815629942478821724344731221223526125601428845406032\\\n    5179969946442702927443718498405440739240394463414693046749238814402596565112400296111608485399\\\n    3790748635995254727791692943232718199126865980781213091737546160742784641205028270540913242809\\\n    3231209908022805242805843690292102373822756856841693049116806061297688017376267598132199175445\\\n    2015207600602133393387384093034014659235345839534926424175521867417010513147170687773674821139\\\n    8260571236284279216425290556349325072392712213926511693427900448549794235985128134658265408467\\\n    5603381704257966907024738858562379762608224264087739978012579076767003749746775440575880604954\\\n    4483895185787703543371855793256582270837287649980074460238489342299454472555009902696907313399\\\n    2219494115859166486088018860557176476162008547524387159572061350454381865249778036231000167056\\\n    8331618664856705346177985479753294186450203629664470368850016985882589464316939289889968014233\\\n    4984558441139276048878219836228066918718716044347201371289042202568093518227655122163277203993\\\n    6710337786695346932390635404802626137300220104096993526985064604005780473178300091191950162145\\\n    7350054523021291278226898276428540123216933145368733099169701708079919565462303906100039990549\\\n    8698718486379820264574088258180063962262313795571143482934232320594999496169130352885217642139\\\n    7638783262839735733425096229112046180248737245127557818572265082742695959160849285657902904928\\\n    6610837821615197617994381191126772430771426331834084401024581626616093568284383776773097786613\\\n    6910134159240122402652047498137845485543867330205686592715155228845144611200474992681000638587\\\n    3223058812354433545684490898991364811767927477109923609761094982171270030109118516725544783230\\\n    6133585091415348499175483685622522377190471889118443523539649532411697005349418140156744115753\\\n    2801467972171859316727314414954439931734966533697692531809115941097579125736752255033213053859\\\n    3965291089361613952791348574956070590846298567499903231468769071666763476347727551782619191814\\\n    5814155927536454495223567842048260397343045909862349289546985335310871489562423079178435901831\\\n    4266659353683541087089214751208973784570075977296522123720203375210481375319293930972429438725\\\n    4660261558652384265043982571545955398138821456847141659729286791393627150969137569973176402251\\\n    7889539205717811462612318869147845152585873846431141151784224889144960119265975464249764323669\\\n    6098541598970949133047383653376171133587181989891599413684737559693544433719039533552981860608\\\n    0830716850511077868060162773188748686490159325508366863981859935366076937264548545860101989028\\\n    6132870011133685026596525189175302126260038456091786828447104892457412846696039366815702894363\\\n    3085858152579226919473194920295194527937192448644604026065381310248006785872594839978598893724\\\n    9099691479155744041177853024209051264465280928018240821834556843278230931181658039080790689610\\\n    2644683332654644119184577964187502298546219550522977463960359412092420988795854840591980869063\\\n    1098812351303077350313403142317333439431226345650511895461056434480775029362389498100487102139\\\n    6250383703798107136487823523142754487723439191357325679710361556665131056563636805426373344950\\\n    3653516730784523625762080685792443438633005465390297569956679658428835620404930988685807389280\\\n    7042007383299267559764951239344297196723135900201212971962149496571011660911954563012652396091\\\n    1275465277586796592158408161750614500426606205693683662884058429922749745086014282638543217908\\\n    3722502747178193755658800287289252095385552875950511041977852548460047638320195521113400490126\\\n    2294804520638616544868672277772522412889009523474821644984272677867249032204194447370561012080\\\n    2740511332440001058308939851812195540999068671573157744485612336375804329227679582569776437631\\\n    4061688000992673700945516715814988791786607577971912044101146098965067593311235664000151851344\\\n    1610267432374403223991872393920938914964512761891354367197706126730590023415476305768687815049\\\n    2072852478604042817468087651709166265241454663887668334980665340967253420587517308804161595664\\\n    5752523347729051520513824221820295581349764329399420793218644713551362813049192438288691287653\\\n    4599054771720738311313641574893815748868610743158483218055317331845119329145258357098138358824\\\n    9072363583168302867443787518928490148039934769031206470418734920100203199478960165406848662617\\\n    5925645068175079483616404639772559023160693124810687859484702964803219724383064593027882770401\\\n    9985170894441992459040344445155042828325903489580595521722921353938731257593224607076715458979\\\n    4566798128601179435611979063190237774295494920593888027570584711429431975725949109652379858233\\\n    4287298608868016468442552363078842379894167901996799244225119307176838350153127725957916124840\\\n    9620899148243640054765699181172098036531044933982883019677734872490906844448393047817968723346\\\n    9297168914926024522623761883833993416095826599662015226633005723738716737597053223170417359541\\\n    6997800182295560617234999482934698267250961572390474757873193558340108319396973984617795946113\\\n    5581131599805592528695882827243747652823385639413868268134333822874877883424573187065523544506\\\n    5084075486888210564483615234795873844425750276938214616861166082412719084636261481631187669270\\\n    5085645657538397656223804668306906176909391245036572251137006801489199834473803071819182900525\\\n    9790806531734434840119621141206642919678593509867247886611746188538394090823056939341773240257\\\n    1965209268709669070543920985440159528057128750069873837067144091378647484276571950442537939356\\\n    2123421620128162102556969619457285790442692177983039202194167348216218958467645197542778198859\\\n    7381547309913823703752350447025801263644914450804934066162620227357759903024120509462478996224\\\n    1972395422643905157487856499487120876191409108840817790405945958828768753254817292440871624949\\\n    3621067902336986030587420647824610681996050495814143093649569656800957184389317279780090660672\\\n    5867947102176590509519920075633175131512310240178367948000669853020875900981968258265306080467\\\n    5882807593866070058901783247148331635503793945200868349251437720585280780129936914694791092478\\\n    2168552134403373675867721303028955151935430175594644594262215724507861498951242351326640990707\\\n    1768030004545567205922929366548687476007437956411079884241922545315735853594854143198234505586\\\n    0004133775832207032423375307512189425512914621689095597449974226074263446760503775895331593321\\\n    4788082459483312383883019564634170186813859288299210961311438857218186636868081671131338791039\\\n    4441580683869771465869651696900282183259774777352150453533214530346265832102172453357879116076\\\n    4623641973185174482679211103637371860922654674784904848932790105483295736982620066699202848264\\\n    8262043914013259803369455912288206806181943711737433329797449525544968984602841571880712549938\\\n    2737814829675357104538305357219522931069214493598673882993172461999229347098550470895780362583\\\n    3089215564155575082986261648462189038235929237640860130663546243488331784324824434809981898453\\\n    0519604918305585001151495204640732592151391813579150381466025871342992458350649851161769344010\\\n    9155911441211393924664839892588616139035917171929636153348013924345234804227074945209911525706\\\n    7854641431239490633950702827203207010628448918109337346553525902926499024018823229875175403592\\\n    1935742510931130214464690528808571435174715692857528068547411965343600470542365808132226498434\\\n    6339347601125308986876517814996694193066292481579380622445568920586299035554921376032731022485\\\n    1887219977643485401757961514491940780803929148872609041004062880579441901142559392479565141644\\\n    8951928365502885534182850040300882979120661823316927761432816630647319746223764029356569643453\\\n    1332624079262653178565091194516925926667805743474577230331828085885701513370716728837315659774\\\n    2790316740870115172759033323359318198337210756240641673254587616504087508921338758780554740838\\\n    1924125956411447051381234029043149992311787921432958452122604462926111387777424934855563914553\\\n    0453086545936304507046471456291849640284372109939651152349882422589769545522648765371870529616\\\n    8216814027972009392221801475945554634355152985919701141961837021503186282824839106025566247002\\\n    3984358921175809400759605153631953861208173038712598920374051041238816761653549171884977427938\\\n    0544905803014358713199944553262954786363717169664791099466363994527774962668391371006028229443\\\n    4844860441937095937299429472350757670151708156311328754793832297639515313061726117465756275554\\\n    8044538288493473799205495598301580026822291273844986159162424082216136723316432761086033581250\\\n    6204994434791522034844655129574205105644113894815126264610668207806354712774508791745840908566\\\n    6193203231393723394398701824555085476434695140531222077752774780947723294216790187513633598336\\\n    1482571520638783976314390323014628009749576071266530482269609767607975235264745021687427357438\\\n    1821884012600140171370457207762678976501163103645533791532970909085517418723922297913868531219\\\n    1390047048532857930917800935891989652213905622505474522478543963833385673807921769139249452517\\\n    3359988808166177346325686347107433730873594465490102885622873615466255780129537473629350037302\\\n    9214902601404955785122255689663427766063954286582822842076090638034668731110632297445929990001\\\n    9941365065182376294555661281068946048305582336901275829593519559740750041453225316342146160939\\\n    6493096539745659775283337707481743985355781106034096864348901546209139695838621085203680947629\\\n    2069346004696643548293199729281892210957014200071851129919094025848667908456432293531682407186\\\n    5425099707857269993043454932043190559140496755743425796981129630348066122809691102179330772498\\\n    9191184662184479681568394179274650855619793148769934489549077930858635496454570963127237918214\\\n    0039234712243496680058957231378966400928274075097132024278032710948976248139949661411589349909\\\n    0509878321713115086395183372957892960409070628183459763229092107663245921750772054478741239409\\\n    9049032719166392788363817570202172665063736319945968967872522398530618465994153850690821065818\\\n    2929144867489194806235295451276965298835834428508243358285856224240032361582125286073609122483\\\n    0115151801566519346630330444394732021059205156051753311111063507527489620571998361117494745267\\\n    1850577364472812746205824961949926010141494371450194588189495461376161518122942068044261081846\\\n    9799978911988696139576702295690413742900842429897896516698271588751505368437088639448058932903\\\n    6355288981643811061733008325257503971262070158566232684253580311009700704893972651587242350243\\\n    3249401373302620030850223492399820087380524851385764764150477369071309267008102499183756208684\\\n    8409213128845002275192215088000943815249929295753840380809515118889557159020876024995584924975\\\n    6675597580405231695034697963151712636764571613628715782666626008595027918647328249104013479547\\\n    4507807451911826001856045740302283727605410798106574606068892415627927975946538510265597774631\\\n    8990471233993139820027825437645852000919887926050065639510246449684067948743302628437511476123\\\n    2383356794649686924327448389713717815664809428360803905051963982504391750492115418247772134574\\\n    0358429371974371991147784807092823466398039592509839714446435835120592024001723700419687438211\\\n    3256163633792357122303751615401580133009948750610788096129218851519467854075046954619573620533\\\n    1510478101977847242325742641907594350666006049280811250913876130089442670300023981499689318031\\\n    5420984125639559552741992537149033484116519745729931743859697331890149010996564267904073890660\\\n    6996284456838755669489986005466513908759794650306387855375664313131120457058882885687024351860\\\n    3295751247164668496643315213006778092914447842623432046719639629807009777932578685365769735936\\\n    7891065838006910245893387381132995079286044198559282940503428769543248358595524186576685321963\\\n    1951078227565867590391168123841098598933850960790988991331881239711546005991601635525377052252\\\n    6589635879072037515757318362517158865162004959390368821071388719989390118643020459535601917218\\\n    1615212330379023417394025354291367787425753387940045144200121089455986329913518849836833757276\\\n    9659809609949863936328894451684870592103412180565644265406412900607985351088108493808891856295\\\n    6762575225455954085212367395588287899162303872747921135291106886259980037642692784287333247854\\\n    8360665271187841341880350910426344877993280768678238324728788972197816338161942687647486930208\\\n    4207919755458358237355333061203977414522186800390889284871632798735652191095498967609694710267\\\n    2050827856097058842360466994444981788843570143206149522585772908482293575177902575020525236647\\\n    6052518465817275375224321182829677628766150002140090834958635508626065298752537899692475738519\\\n    4366951451559354203645842016256127559237055548674416684704932221778079426051541904454950962662\\\n    3093446432729114684414060238617056838548073082793297558420574772845540530354381765053117251042\\\n    1526557681995297377816200945804562572963252505872184536721210492990448209140549589379627537139\\\n    2511932386307090853673974943038072632677312509224371028077596555297904691670586822584538286481\\\n    0682535386093482074834759745524612468434291799166234932277028353611808153879691727335591037282\\\n    1571645937069621265400458413675291858272631307642217261716656843818602400001208285806923978084\\\n    8554121828323464767103546503223846968603642699320965519119844245249548943735971125864419390679\\\n    8120944760555648690323405900530653953578443171516294351283024986431346012365002248296955176475\\\n    1888564572547888189074819215254303879903753815472273878869651479069833030953783088724982292287\\\n    2673686052831762445133872133786448414011346654136979094129944894050901939402405990096745792818\\\n    6464003486115166893009432057185471323141441638136136361461262331705302946410042986023175080123\\\n    1413228685054652717172076803520093571358152989843507156123179975067028304234245416202184017874\\\n    7355960208412972227635863758386152312751112054257779333178387205352733002966948183385520308249\\\n    8145848944933119639390631819376026985529989008172867694751328812468796862337301408128136770553\\\n    7144944830456128083365444909674406758460974453139194165594197315287502397994939910340569957695\\\n    3098495345717400912468492141125826344310992649643516754183616558540773002067990656636891737194\\\n    7188113946026251243003661771721945359228863981844767045212407324718122884658588130762140626950\\\n    4763356915093772180200760001412534886471342351447626602092943750788745612645660934465723247181\\\n    5889888446976532324732780535647054762434750271998924560774653468523287747650681425323678917747\\\n    7395249175758950430112560845701474458080373461644119062558433537139470755421021623715433529195\\\n    7293621428936446631616821357317021345514580818848575916331860295559198559371507079044721771891\\\n    4135049515746809803625155291242056562717714318802390943367668278652285943892511027343875104794\\\n    3649821239010870906453003239860400811875484723606533850746880774190185493433072694898813458186\\\n    4363879932133609460507494414336228915681156896488406176879189397415164304323220730984600543884\\\n    5739136663710641161480008334101646483262301388965130212703512019667898311140370738100817173683\\\n    8554972043325585254814603700145728843104328420190345098956483600625456599916031716333314349635\\\n    9259190417928470912671295025469781191560807408795201431499736653288341393590356735998258878104\\\n    1937098004311116907850673643031859206526480256652409192202817222720115094438097656644449736164\\\n    6847713363219255965364618602573171164529136652972355580277080126193152758872840802993572221047\\\n    1871633180479413136565660773584528635636625559870033399362215409019519180105320347840628486987\\\n    4155955181197397143578356250456351470198017325270684525919854368396083490357392577686502253642\\\n    1474515086570946637798894574838610550905081620079977902005151151591227268631374583192249469945\\\n    8904875065172504985668965092961647846309098959939850181450180374169843096895460956168600751102\\\n    7880857626540384295738689705393314412553164697749763218897643247533494520677665128413675348860\\\n    9492854398855165057491003123114059143266466533135509753209377699429094946397945050939753049271\\\n    9672462478207963255568242416045984100883085363792799416538799924300725470190015491502540176663\\\n    4498996889721624074298542650866430942951769853353953981430527752022388265108831491970974459766\\\n    3081637389192399465096477166334217943812377819392508001744743227743017159394742062651085011119\\\n    3371727967862428825170180829399227909620201291866482463191910833191309844660492262931880337599\\\n    6688932233338394559081804471412749562789961814838365029812376526379257443650251590430114508773\\\n    5448994069137779753428803301078612133361430227226427049238548633495199279187288674458826941175\\\n    1738272642560498090470045245290141882105712757346900307419296361130877059031796363647437794928\\\n    1472056794119987537395914841982285698769717347381976963180873588848921322694654158519834913268\\\n    7970773747757172045112200117643571776310854974168009434246946042715302833695685018187109733921\\\n    4879372229617356727996034544836042277071909502976727522187149391503011217842711687110439117039\\\n    2833842903347191770970464245923227137344945118009715859019373053441824206553546361308469311071\\\n    8749615182570674262776067220319955403576516061512067431633230110210094617246247538716736331354\\\n    0307867877398258031464744720761770307046894203664475719331552754520117918225618174665074689719\\\n    7928370826363794543269118135996402264893083668077430041660127797291899606814438858489582841446\\\n    6353935742056151505139960532747065140454862096984177405268053328767847924221249050697677132018\\\n    7066265033696620123450892224283284118582791406317640310559851781900420326056964339383062899621\\\n    3914070255861176935975095451174666548402541961431050082559987709834939519605001377881837309302\\\n    6421466368472954535823161210344437622575827782196838150170288828113465448017696538444131633809\\\n    1889710175979666332799557505558527967426789271458063582483163872505098301721040790239608458461\\\n    1917665839759045123588546497596640106306434616553720693554601724926050768296302190602317185953\\\n    1287298764627202280710973232675598530060439724904110840846713419939075812977392141961992209731\\\n    8087747495822335178324375306904142880705273718978041432299268481062412292922056594963539749450\\\n    5024863777475742865435782910886196932286865540351235378472179067835418134035968427018182180309\\\n    1492416007790991971163581409366997656406618836639051563494134709112031106058250505994636544874\\\n    4104711028598122598643228148403795189972121842038804343658896836991426695908231955249395900402\\\n    9807039435024380302323977382730639802202506309564334609630133190189745659541447844321808671304\\\n    1025797405221101621289392536403630813480208933925875885588978890988620366203699994941832728521\\\n    4611017297310413690917513827893050363175631422219996407228497731738258166314789683872307569810\\\n    0247993094639365759717500830229958035800180308865161576758989898891543327700904768610491006627\\\n    3267879463692486152123638571606026280528425381581604129936782602899944137471298138116595691527\\\n    5974110460298777132802561263142838202512035074576177362459607766948919032685496377001648295400\\\n    7802802559740148391612850780743879000125305957620425053387116561368758119013489859110354361011\\\n    5448390518084798135703318141575497057526858268201004319982661534584221832684334406865194697531\\\n    9592029125137495057397249911528970438001288026605865053436501322537486370234736030721965683276\\\n    3734545704525376689277225805344573880730146335756201474081350988945330496698386962423309192934\\\n    6219702114760907980432285322499895163226710920446211255173731761993205376961214055787390314563\\\n    1789790049810437521864186406967701776796980883517979400479221585414355197346881179710459623897\\\n    4607337606329054461015115991906875175222713173982759939156645420658865976284184599475029117220\\\n    3920969709141598050167329201008695847990137940535242117572838634286966350706623964406271548086\\\n    3248957821859582480057322174585209850598308610194468049217531174581611997293715597981145274940\\\n    3847926031186817383026012590285001841235056271732645808147720050005717313464903406540657529481\\\n    3143818051821625303357051475042919091492634182475786889836069055969514917101609645272626922112\\\n    6352905032789593632635684539360907840983621981953239680332759473066358346362346213636297424541\\\n    8771109299227728075089776524573819875408483311918122781932999485804532840853536143113265958560\\\n    3515695739722597881556097104935300444840455818134669247184505206407938428239820637926784660449\\\n    7374778660137665141375943957406037161305842631561566657656739090948864341968375759250804680878\\\n    4995320367748810256897123689359128361645349228342808162904006258247204560688966477883284360987\\\n    7204426500218418960501124413367304203331312730909438844567215076844419975953417074091755852734\\\n    5637626016457944006785474845243537956679407937682174214394551097216828183370512745109035663163\\\n    5715109290791715402491331476059214810214884888245005394362658036005631539430856638381659258968\\\n    2246786146095408443140394830705764728138743306601935238188484921903032098859224346541732761514\\\n    9717896277824529006161548964383240880853352666964022902175719799156886918572440742312760345994\\\n    2202117240195271386859024425042282488078281777890786540402806315607611469697574974614546964176\\\n    1372925910752837017388261072416111070283888828520175425952552753335825594592052124940810399871\\\n    5788853065414555153977099399402039771336838002653692131088427511581602231247902569456919489102\\\n    0655780443042684944006694246727183579948786489975637685842331719515241993904724729127498778698\\\n    0595697629080212743126211169282825806792923862664142594666441691825293398417761356921917170632\\\n    9791607628511783361855082901503625017275479257951507644603496948199693593100072836970388722813\\\n    3181809700023638213979270635965981189240694950773592286418662422728621886763052064810433688596\\\n    4938611037063052604917014953854396255005586660625762648565578946762130393238893876132139212174\\\n    0973541895497333644410980090835676795382239584509572922448288598901510848779792847482174213744\\\n    6223318749967462686504848131275693524645791744473404690218741534188278988126368935547906377900\\\n    1704755034512670192296065645372455734115746405096974969882782542508828239978021474000938896691\\\n    5325203823208334567963389969769650347930274677437321663238765665743472184984085352937439088039\\\n    5581087318106119239467769333827636205691201859553447523375869153500711505112498841051683215491\\\n    7306971685014730624202787067504536957752184866916212541929575988792575820978987369883261989593\\\n    8191233229397002594160602799593032518106829101178593037049754759106000974560529481280539113549\\\n    4708290733415775014543339062326188673629283700645987131806725581478186420461646341232522650649\\\n    2079296974070719167706342198570135980346273306126065926671237927640284890385809945205421947746\\\n    7161395037972570956285849528005859933049277795951586138505537688100941738667035720607787024553\\\n    7917755789791957071260441871476992678913284395966581863669787878409667652544266634613950430153\\\n    1918657272704947693323080800008981240099517868381170493790625382226836198716919522053910000849\\\n    7696506010768131792356686344344079450501021718218744023221591210471946104324850213351590285211\\\n    1893788478046375980944204424415655477208129791705329927358041642861148910715023206134473651298\\\n    5256780955593364370835119917924094122293470618422633607936066475180071071034219429608499726623\\\n    8798123735271931171335112538734487786863187966248955329506478210013526566606108409962137316561\\\n    6297737515267345783043234123840142713721608454393575754180632527635323015718654111935671375011\\\n    7294217867156679405210047901054508537257194588478163664180810144010169992740169971888080721779\\\n    6467551674298360471081710081502800926816369378936828259440492839519817953354992895349145273196\\\n    6363495546623891551930644473147316376473247105573136418593536372446809477260295951191556395264\\\n    4103518317561593405612600203804816694600989746543801640597435619792812253753222331435714975163\\\n    1031416853822383438592617310767014705924132829394247650011741393992604392074197612023308681502\\\n    5012128456695882182495873465022440334681632874069643483284584661489933637374449296351859426006\\\n    8128281557523243345601892378533043627239433656051599880792668467811463865340696877799554583740\\\n    0355856157638600139702700036684855568654781394550612797248394531636486170144854262647587843208\\\n    7420929178677185265538154804831632579320337100557194700062023633159000050181197735279377196428\\\n    0104126828824791861864777076863544643205292907090691611575981463036848359757349497778556758821\\\n    1608516067425422922064437526996909439982832387752733930356945946672011724034550436520190893764\\\n    7545121665621234214474886720563085858428270189815085390191384984971221834449318998313788178339\\\n    1064182797637248849658907498267975620918927208742938869653253603029585211792318078071950897429\\\n    7247476744201399240796816475817432575315019086951708332505805206986835647997429839195540563017\\\n    4539691695193114024340173621715248194121280752963887480351231272602559959325029399459027938752\\\n    1412260228904407442017349893838191410782321418693249480460564361908029368133121495731695621251\\\n    0231832229216270998396635784945370494246215954520076816553328177603312871302355583304494096910\\\n    2607991825854302137146926749950839625167281983125686239163785013664207300134129801337588342702\\\n    4660479260639700947565994315951737792883408687624513115362946778899771392668894334812308201887\\\n    7626833171119356332350529907095444028164130841410277388876696667114117538153144045465846396512\\\n    4953366950638573339112293085029890340753590433710226936488646804977666602954016628016340358204\\\n    7816698608592102496924818251853115287756659220639816421918665272274267162992762658907507896878\\\n    0306421501292519411359844864420274996265155539967027384082111296760887643620963287520878891637\\\n    7135457972171827372739716473103266087834371960660234281541527321340843647712672741055313568424\\\n    9828632356948094263819057271331084409220911136999971292109304800370187439372812857667373150802\\\n    0942492800536334144791314326945624840801171863587772330125418273739181408539611309715689410001\\\n    6369435687284376552000175739433846375788382832803050502926534503475559314643008790355702258159\\\n    5440718065017810841579814987420489477811197119452351741900958278439004011926289620372043374861\\\n    3019812720574684286660413280817316619335034217661447784598512386831197733979600280894873419024\\\n    8699915711758082628442214832197679800773470311318318762497050328196832151424180501706757479598\\\n    8217652354679669540127073340169946086279772599135073417282652965718114605054634998500111918289\\\n    2829340976899578677581073561439178998205340373471321135717781240668844068968646685340334826787\\\n    4230159654699845679538117482641645190088813321619965645760101211583965661009203971551369741110\\\n    4837092728812358498740158773280014216611866649833695518457940208094349113966638106528435722126\\\n    8653953218639549077485849055913350273152131513219862275647597182329938565268132815326804582726\\\n    6492458133333772102110856345655778426491164547799018051484099155060276318866120854103602461146\\\n    0490024162873171433891172140698489771521710213112135231966577502078587610385823692357692475136\\\n    1518822933755933408003262501534334918441861062204098995802247289534281697518370655952914192014\\\n    8026463338891233383944766438276431374069112481312473864498388003947894233594739683614479339165\\\n    6958468681085849834208421121308674136060749520829678471791269177646487015740475539179849297045\\\n    5138750005711129004157395655379421467410748171814862956836981684141020574856211816136504202716\\\n    7479134131604151478198960934879900878723775337172893696223743911631399442483191395270984874349\\\n    5836572004321463087298189507280438620566674441650988719338655968552382079731443962719665063698\\\n    7512500868321275754957568645366376401902464304141674717840099507900624069250241844024834858665\\\n    5241002540622447391174037425795988951545824625097433608485301262774346233910374112233483973726\\\n    2955967926772527559259713611634773941579683295187195760209820484315014205670615011276125108381\\\n    4323792416914889453013481253320682153793983887110232202070782749032706594501529969792565145156\\\n    0924952034281255638216196753594593047103889784280937810749893285588141526904505340579840763331\\\n    6602644371846323580490195572163486761698233434070615102965297976162794855529813192972686550699\\\n    4520516304941960756530694866783109969876740907906143657406041048960128536556251011528870078105\\\n    2609978968917260051833331348477045137802642964842835040146960682425898885383583837607301749401\\\n    1816584567282835335475642761999387873263985683043269256080060544488220035059816041395149296917\\\n    5607504098985898189661868316832411125846431501975072884977858616776751435750134385514372982209\\\n    4840909693356146791277507441003739968271107917187613285694798490377334681588979023658277003652\\\n    4117518760860633736018048507279176809560750388898701879534530023810250756613059334528442053379\\\n    8537485152139833785670901429765770825042373587383081793880458699078540227075362965035425944487\\\n    1832900738222857600267661633463252791462103875118244601181915973018631961288090755374452735918\\\n    4015584238452139713253108262619839724565555024681618687082369256269848945025526503934556242772\\\n    8027059122540077674459482341589724049792787830623614629306836657368703129202218279265345806717\\\n    3435098521991715257730492408091727368474325704765180052261637466427245922162215279197234361178\\\n    6404259603882515242014356306590882934595689416640787171388262244036494292512049209427139143115\\\n    8990072464738319871636802270373552567746015843064156939610409101168530510344654817155496201054\\\n    2846678374563586734661923387572647245411488405273443453901403848233208306120947847831918094112\\\n    7414919636461286897556955963773115727702918636911837461314198484005928822580196471808621095701\\\n    8738985930278131100520672167745802252096829897772402474725434603922196811470414472085367928293\\\n    0077061814696176399584337738913713638850538614061857431021305831392577444751511283602441313267\\\n    1097631461266710744828276159826122541435584651446614126886627663521289380608693178717545773898\\\n    9426271436471368271764229479367927489166933920688057912995440259502908698306956907469147353079\\\n    0889767951994011769677597238294745923961443018091345363944766620207869279316153644319911863221\\\n    1214277186062914022915091871721344992655498585420631828654077641836615956878306961973901605315\\\n    5919369276147339757650673743272800901222965735236633336734190762075929677734651681897305711050\\\n    9599830767980554164634713048600800167072848014510472076435803326300307343707516934937024587523\\\n    4583977944742408648667308620919367854617688095426846083390226576517827032238819711222544220913\\\n    7851229181585245000811806016255014674029287473818919540743774571190069116165718614886672000149\\\n    0859094754623753776648769947343840069733454950203624068395051722344689409640205739164511200765\\\n    4058979693996723830244416997713389822653651092199264368150149129036202410476298364791847379455\\\n    7964760750254272117342450601191798909007137506185631626909048821478229140695871664427352389625\\\n    0445969979121683938646889746107996552586110862937169929403471716092322010515768864437360881528\\\n    8629407037689459033858162882122982775759759097186957241988371616773772562822883514023684432094\\\n    5184082454562937796656912579621918781949228764738980982415377990631519001695017287735589099529\\\n    9294433803977623462052248159741371516618400119460959491932068918676938461191864072120240460058\\\n    7018798844418348342357132968083377162981602292665070516344600012809800648621387435837199878314\\\n    2286123149805794460403752402477497203757208961464418050097658481257171218596732101074737215090\\\n    4390796677648937306855808719311730869769755206007908562867965459090930690925731647798053012152\\\n    6244478604927706394376113421274091422067990864737642184660279959932375381535182498809293981278\\\n    2816535076990381378579326177538182236466724409357381152322333875507628749737454399729154519022\\\n    5451619761114537245133179148350840178268538348378859541168452643734928792759437025711088769789\\\n    2770544939048956794669701647798706524094423062847956245403981563421603790649731341279615270036\\\n    8105931263440865935960310081122714106713720728412402283945649093948124279513105050162504408701\\\n    9254915626735417628291225358349011054140747852936674531014522038053704012726285651943277917933\\\n    4322484544865061100017699949620432432890853201027260838615324704592631736100146378111706964059\\\n    1036673188871648093668565033935043723189380805130679372027520444890896841835905949042404649872\\\n    4677609716912134569532243204549383951716075095127335830315795734105878150895381957484631670966\\\n    1774708783002486785941501142196555674433287702901389514508949189445569530755059911576192654158\\\n    4759868007902384447522107606121879909612371536431446832043037680013487303712059873974158001773\\\n    6896958017819277038344526397652332958941794750190128117551373274139995887429365958544358007529\\\n    5775796871420250998103517666131870134481938400726325159691945844367917666053289428333380371302\\\n    4668832721703049866956825201230844460045121480897181334411665245277889652676149655857969935623\\\n    8985678890377010921520541609868372101807280382069818105246590621321133371492947235217095013299\\\n    5293027346883077036358099531700994392713985255116295855638000478689999596495790294295067532589\\\n    1807291255845311489190487066195292005530331576363018988119790193067568641471240208819607776982\\\n    0151892172585177962264141996628888685995474689736396857510511539040646715447861104379403418424\\\n    3333432448511760265175747917391381722455689246608280311673484121607958685224990524191688269174\\\n    7012473057024229850299559329354248196614394981134147003445324554531385952952368630656738081074\\\n    1581273095563885941109667525612303322382579816597895918101279633408284308038142564091746212409\\\n    9183983820967816093635848779941865881715463474409943229871060956132524975739384015097472056863\\\n    9793535604829931210444847355608444835540701040764135505449799386238629203371657656150295953836\\\n    8007543404970266403521724749732894255027781887486453096368268544740877577384005385500743085266\\\n    8721639560277170350233233709555132109043842307775902914025107320593004551861461703383427007512\\\n    8488497675362287845488395406761420168580571185532067373628834776284758540929821644525603486362\\\n    9059381816666143485248807808472935945860341364074390684155344800641391342297222455400383615079\\\n    7901297227461403328594511717623293863611746646545998924037683256775333331958168103575318873433\\\n    9768750540729901157727124669724516059468944557619231709415728802149289114524217276867144671193\\\n    9702255038279259246538060824012827980029090744751990952671273773637342791337696459178682768339\\\n    5652921684241510642702239598893737431990926065103685274026861442842919670601942608032727463452\\\n    7376775090969642362816209735757420818050073160241698275770736142854826923051250871300735323274\\\n    6569372652919466359855911993630343820565840471599282717060957028797421044162064951930829969462\\\n    9022018730062135090470525141153587448115314754837336560894281668761268554763032211976228691393\\\n    9166865608086381627563858800878338475029937566966382689031148132010934491341821904554067754327\\\n    6800582916115109910881802577350508642396280546992312371109691174940956330182349138668448678084\\\n    6579829732922597732292673951865282383111832586851276010972784883080626350225669618663760887604\\\n    3326824758301357668061608427014010057184920258240895345077803252222413865347006812988536798196\\\n    1918163818133315120280472254086595696317732603456304561080928978381634667182620432178991847388\\\n    5554840693871583350027530753422433281227387418697324958621752964169237207512243170352517259221\\\n    4499448813749374278581242357351842603598130972324786532269940932122971024756257733310905196593\\\n    1837885950761163644342922503689276531516017730466147390786524388711170915327753954027784989460\\\n    3611397536779620442238178263929093520132209708532208847080169261086520649928117263353686685181\\\n    3156749695436609068615821298261467471730304298304888293670152025781359885239728115045959862695\\\n    1308309218574724571447328613641996903916787606844261603409896641174258689396291090515656359201\\\n    2044000707318525607786841263592215414848407327630271031577751491397028586485105077359204110687\\\n    9616584594932362215023778864599146674586972550203451316973058842397633791219557802998091649134\\\n    6705626963100044125108293390183694587369907753527113099490011380791171275553072652179733357349\\\n    7139836960972351932210965799537098514030675836400809573837889098559389970817207990908025742666\\\n    7899201952970669440789315659801635433907695245057705652657675322265383153915494296629171209511\\\n    7748040881472872785149133625832666585602252202450702631301524005248297169198136297772876493348\\\n    7958577054592217339614177487059019369076037948708350459568302651704589388472642836444151360697\\\n    2129199607349423293899031756069074888587299489815491858818746331543849591423095705968159380062\\\n    5444687812365716838587986729108131488027106054259321035605909809745371580204502594914525916294\\\n    2954627339988509636574145874963251193920715577845432367258607316658752251906611062078787852756\\\n    8220490859434092115879822636863099010417641779944161670440968814902978673743541790021448100480\\\n    8224198739359578141100835582867958126978187576985285924016925567599159158919698481559762823375\\\n    5652734016285069423013268866506386079796655126650435316734224623083526084000875611917170987580\\\n    4098227782413991033894520865429180873275706243655638921402064209746035655026715410994835401648\\\n    1011134050035727824405715560181688406985817888069106458047301727836502193999656762031061020509\\\n    7150120514973985167856414495828760623921640037976627431628971244377824207624830398945391479163\\\n    1208676088914778754288986197236123185771573523086132439830372908224258275397665339366077477324\\\n    7527555515065998351838091905030382372591484640762060595338131127560909048618902310918413742237\\\n    8991872531499707102663464475330258027470846975731795918825871159240313273573339937481512199679\\\n    7233737866449047314373789036743546688338373904792577376925507717358918941335562356802304677958\\\n    4706774876120220220307117175481783956971218089787419535738980479855051567323266961895599057331\\\n    6540479450273040155431873112961216648693114612606817642747417484422227203792639048737462481423\\\n    9301032855642648636462184103966283658908009297878465351754990097180205722523594674730975843127\\\n    2499696622519369754798965623215244825059690554912939468449199156770097451514708850975704225925\\\n    8262819754654647141008496842455022194098372017925119962217294845618984178204307231840822500363\\\n    0296788996191952561851064622642118583580053949372068280129978742306491599551363246467060796879\\\n    0707822715041601849927280081444611967862044431006614190171251353239366601796241038667679533540\\\n    5442464113871391815228742992861264648503203377452210320315166847540112451219168937781912239235\\\n    4462434256636813486331250481577690002634794454238014065021389489401367633314722119079701074069\\\n    7877051036334673475764907527733048457488462833689568557831902679878315533366518476223879784761\\\n    1318245968154502460799877876289345984829277581925757566646812694198618928121728451746991976248\\\n    2040863329468581242055572132941887594291395100055929527640001470059356923583741616831613525724\\\n    5068692311415117028885848810560533562491679796511759409835905106891260584391475540807107164166\\\n    5783526870606618208283185268486499608744936437030617164584770353236721783763714492278264367277\\\n    0948831087642941085547964750247908056503780120736095744563312452005099739064364012225891460166\\\n    2445707926083204245861201348482774665662804432775826481889633984652427813654894939951589419693\\\n    1244861286361192828126320157370223713418210888403281016745134461545757135250333939731791575082\\\n    1981554195068174640975602759688757212846245392112088698848796666303268628163404065420000340761\\\n    8490714298239634723407605965585150275655245223846155227374980338700654609121051734516371003536\\\n    4256565273504917095521415359686556515893632113086095278870214363738319568053326068837537989121\\\n    8904048053113669003622921078729190248881874360035665171211524419243290059480929550053689059906\\\n    4510736501368057922127964851819974381175855134928157808171965938963443280554015790175692190200\\\n    3064229202723516444479944222009337865086077136299537349226287570791281942149766073141112092669\\\n    4659693946096494916804213464658783104811533494471610327624661331017961729923981150296303649248\\\n    4234095874565806126158812582235585880932574741424757090882459150295582326490718086562624883382\\\n    7371707994909345398342353184024035309192702724347144644981547382507221493442034492287093850807\\\n    8123410666208602445739324852688120896845046534480700073210855019020505093211955283345908508910\\\n    2103673707385993826441495554650186923944688318870655489098734628059282162309266072010241800824\\\n    0469632770816400932793167858974996767491282676559107376116150075781801259167267581921861729803\\\n    6460126467559334109291371877080163312544834939976047738291996889339242615132855733136548755302\\\n    7273054073223336643813226442538620075425080604922119349766854799993465536645912079050228255881\\\n    4844896950409882897259391931489785132787695910050398950978451207035431782897628049631624300018\\\n    3477430487777490527864078494591298449286772077415563973594049090005733844590240075902940562166\\\n    3344116380855381594681428167040614388760423409848293858573267007098598652113189101596217782212\\\n    0569549874415249635569541807234812079452145424488280057598841473004785004932135114761696589843\\\n    6870788246160583690832918068814277810737423369932956641329485960400758221369257703456287483065\\\n    5124688974931626092193309531789559341596280803857641244455470667231489460462436142793746942642\\\n    9708372730396762511010419200628444174542703776362926793825197898183371647296015815448246325882\\\n    8993935022080895686300670777271264672916182562035890949284302984589269083475588990926376957476\\\n    7047749834667039834796206122537550006596373084032351113122983591640376775525335229067739616984\\\n    4316189486374996294382199761594826175763871294883722119806281966674013190309651909183408702928\\\n    3286928547291248473769347061469842929211133735684290381468228051405772730986620424271757188628\\\n    2497919421299082067672520832273408361500086441343852102047742989476714278320317865147857782488\\\n    9624064358418272294382131787182594521734557498875537247458623885807512389228445748128442965646\\\n    8208643609183004604173992572865334926489512010654769848746201695467337725310787137711812104176\\\n    7607753324142223616646377092358654067676415839330689527843291393739866945615587932809668265613\\\n    3181014798937856577822055929031794162517909943604647086120617964521863851021892213580653123677\\\n    2887188658761457320862438210958410750078475557579212469342460903022417343328675486455795113151\\\n    0847712178951579975143586328626892574121706397876681049972672424159903072538280702855452213820\\\n    3418288880663748179762115077746588794273471593507327095610812290429618592419377853400041153724\\\n    6652734273980775750680500755807010366432160845438613429557602043773121190537681358760560701102\\\n    4486129542757589067755542541630198149444074700546528605736526635698405156853035728272698368403\\\n    7754460068302977739127713061296458419233654033855809158441118208972551765229145067809752904707\\\n    3150656760522547489632075788148326775628052399005640817992608644759524405229141756792804173965\\\n    7258845044102772298677607462864740671933300218331027672685875061835936744941881226992357450298\\\n    6291120442648851014895988160204210170681723363100506415050793509442747119739830089414932995100\\\n    4857323658970356500562770458224437040597425516908945394708136572875830713318523944424731781561\\\n    2407915770084054052282029783518784924829792470986599702346535940142525442400949213659443395218\\\n    7264178820915578917770921376547111902750988126721239264842855437472940548144160961083774713887\\\n    5635941318526988484023697798201272232301304652026136240377846119478491206203902709883163081933\\\n    8853183969037306611035937917040471195781548271952217194176257567456581258411192327277302567186\\\n    5600958158615196312546699457644706441578820250229497059470634652072855286195767061105822177209\\\n    8877684912474640272633350294945414713172775534216244052719120577014764742624095202242467412368\\\n    6716972273219419732553876094027767015265492133704650119390106133182984209830946853160177964577\\\n    9455052723181034056217071759888255070224800444551763397208610044628354305375169818501396437603\\\n    3788327131372646802812161578680817248269070065919788548989680499579711256472093901939124508528\\\n    9051945974225077170786178586406465985719381270655765746300702164918203354340204400221481388769\\\n    5067338175365336917496329622449986933440993877645599040144932219638670029793626313992625878305\\\n    0835795526097347340707499077236281486174379316028018897662280422291937000762808815165902552472\\\n    3843428607868512608291487690768616898350682635888550285317559170645348535524128335959674538372\\\n    0849814197400106318734422341721868848020895996939024783448248220627633129885315238933279167926\\\n    1339838362757835866040372616041843649904664556857417816614800862758469277388852167986627045400\\\n    9602817127861115621200737425584838824134918443472127063318845138851332993167781444286866639632\\\n    7719065889506533538833586451125603640709691457528191881531370529020490469091813512447923878467\\\n    7605654163416744784533029147310501093048863356579849948283656642091764908180456073958761228412\\\n    4721239459437341355485396449830462419941730297575276588037854374227451662328515907608869176412\\\n    0955283685443742860963310216204853095113829651893791603295881749485398652467572317134840527660\\\n    7844177301984722780661787116499777668321919828009335698025001658697190291160728931630285029141\\\n    4879506511682417913140102498265303163799634544300573448912860374149994128218670302642461799656\\\n    3975931375399024383387040517142047570017385154302239776991156756060712025297112684900452446841\\\n    0006333906611029961367825248683829587164193331137130303951032377809796936318645364788889251426\\\n    0530696351831114182369122971976924478090830973658202264816205617901756142790997397856460278417\\\n    2961195700500155347379317507478398300900158979326392892457771576430664010286433642127216373957\\\n    0586560591912691700245446573475093434884636676042756802369639099831134222170419446404452527847\\\n    7166920764658752411354879550732772679762234152981624095873746318157662427901184397766416335740\\\n    4325525689360037978845985915962840748533173964991134359141612698785491428052306567430092601236\\\n    1901588959003896986158444326960249197181369014423632156111521156729786795663680257760048510151\\\n    7021063014649748194873370080992033497338125732768600829379808681209625308093963037648485422005\\\n    4625143488101835853182935149509402232160834866875135827906340089068598364295653783900984909501\\\n    4476483669798535535447652090611229121545317818032546425551521255213619075958120879355160438553\\\n    3131378449161732862597873573682528332509549367581248681391540207090579590693064988124237798044\\\n    7416917417105916182894473400236926857554635417625779537093683956250159139290190133482930943372\\\n    7307859425854585793605600972897168812329129193597698226990294718135744944981618208680621366626\\\n    4576358315425509614801450765228916047839150585474227772585195199099634675086095775240081946162\\\n    1844453214274369570328685242267776309293706834193670771241699080797116177466459996601609141495\\\n    3719426098400825814379510991649304584949112694518858692421437582733855998161703794200266114217\\\n    4274006508182055096130895884653197518545632867450794879758096382048247596155413321132898262596\\\n    6692623954711033578794860299387645243106125366683991302067330351685089916694017272268695335635\\\n    5529673400491413894003326224933263019694276930066117799642768217202250613285446076570995700269\\\n    9716549841851745933279405042672990424464577328485532543656450057865596705890777351129520470586\\\n    2604551207002512999456596422451420976457757404205579953456137001360232979773095588858181338770\\\n    5975230792314144108272895799293857047456229737315235932621104213259877402361988106626453213967\\\n    0426320898563882827027940167291020767828435496021939538290128545220721848664002653290327163016\\\n    7599575582376033530709916487175879162260401346981209894631110703003093469441401628053343615686\\\n    6414728629732311929022874535366247654777134481963185322096444012542907829155854910377453795290\\\n    6444020759433209477339426434698573835900388224862787672828800228629256184301211371669489448192\\\n    1162697568554548270350699011653225829235847543204990948642797271533877778444626036046127443114\\\n    5829924353988669760776511256649696280578118115726250580145924817422581664780579414406962073663\\\n    5844619903304492827261024784817318397002671070250624567683458709049511227971574069987514386401\\\n    4831794880976509587272093031230153664697076477281280511346142657677875174892304200932248031987\\\n    6831320984729065344933380732257377137648293853725524461041312497432790233653338377772185541947\\\n    8076870285805717459970780192996441670035717608504814043040041236376332867642094048635221702146\\\n    6743348902569812574836393141034255458392699057840212285009921077687923241335458703996677676446\\\n    2417742301289730852421367446718543094240738855221553259568425327884529690567307755160672022437\\\n    2446942179507034577262231246107658037937521929139987509002404768376638635813912897641857122014\\\n    9828669078406514244622431604113801333570738383664262500722550745917373236917800370018973159190\\\n    6342838578869216857741847049230260058150528466445166511145292561476678690669930896195308200724\\\n    2547672377419144996422564897163465030322128136958069141489417871552658340450738577318899520732\\\n    9376433424066198642650677012068979496388335704520657930947967128638341062280977316171308701340\\\n    8904731300309412789540217215946094294179386527707202928957756335892852952850310191821248000336\\\n    0968654615122787193503324515254555891888472492735043651045725093104372723955183536234493341492\\\n    9018124157993962498653134587043501654474702212201608566952064751176476596467911069721315082459\\\n    9554420362991220261307469439699438397240544321274292867676968235397044795014176832296561366978\\\n    3321288954917582165091108996718026411312930951516687909283095236630788724696749462078660933604\\\n    4034828585100471714255147033528215349888382880377270403679121163234241352333362092106734107982\\\n    2572575669852519989468082715224970860549821824764580628964254481352845559766753077655290204106\\\n    5277995452213338764320131077945591911617876574538664009212333744867244816375565328184021668400\\\n    1399457661675029484292908133432909501790835213503450894537536393068967357313290784557024089982\\\n    8220379114211696634484908038047792556907046264778834281352327433607727356078664319395335506427\\\n    5431908996379240710354411788142980644306666188648942401207410882756894121781542180183004966097\\\n    1682338150522446089723693599101041157030578983056799540441272790355193607645437616737901494194\\\n    9846117843955162090632673222038997287700187897203244570184248843433023409183182074903558784844\\\n    8130737040173464091512143600815892152308364545954116763189448056459924811501302592555880522316\\\n    3214895055656852714343762692548251915418854047597711845430271201566465928512309905675289861623\\\n    5300224572119820928101531669711820060697645825668651812167682512968408356857770704922179551917\\\n    4287103557641488298056138506954509514157954920226917638952715500662108063642161651926213420031\\\n    0536931550883558930761618816461272883478330945470814671060502023747885069456900392050072404080\\\n    0660554477305638879910068302281385069574307172342449943371353320039800696857456386980390279013\\\n    6975825014364974459625062640686769272836774432140315790756466346755693510194814093569364178752\\\n    5608702296902214602731177963830579287355331931486551090178778757927965656034242027191400968594\\\n    6256692954344849436038143457240572006058011642774598340839791815025794813087197527919924575022\\\n    7760024396284069258935167461082428775227947070776128175563609485822779323637519192597941069380\\\n    7856822703503371021194858226308224851327855497442789983260584773984938887258790137658297498920\\\n    6717758850641604404469626072489475212483308371139930643306092381785759873617332744773248559685\\\n    3064743180100674802247373147950098996923416635730400132604246766605375204013499129772038387898\\\n    2283946489387297851657933935199973509336069980963272344860051949498680455418858204777017356715\\\n    9342178025318589064986702152297456715937405095063386382760383976420267840044040983691215368722\\\n    7587306441900658195409809927777728535987955466028653279135559051273860367804606838944351918965\\\n    8663367921244532778743414593750210953039518565582051087782022018625137654129061575989205109769\\\n    6867905805773485587322563772462468218820080965830433885644548063929558217450012008762606193246\\\n    9633842645792786328880998376661018686997194307618140006274614718653455341673817497078332862533\\\n    1477783338572771756744913901835516593012265248780582235297026749052923059900996269270816680589\\\n    8773471490843704979975237151234392679497844025344857088403130212488554715028955882625963101037\\\n    0494104032456864665995177197538602051082565509059224014731221755045349697553953717405579558496\\\n    7528461263078086290869675425075405893679134668990356458232201026797649343629659040386825811451\\\n    6794397796589973166057850891000145738646438073967152502957696475479467395301039749688971972196\\\n    4749605162004720239889406852739524015406782470221747927335563458342248591839257030319441967753\\\n    2625295081349042611924336241289544068162869140947968050029855074688358968484321136660191179368\\\n    9392776815984212512977544676150303587304697387966132755451036877585985950842088250487876621846\\\n    0811131722621240680307466594652623008249191919579481791804320540176501932948250041425773972016\\\n    6937458786370292500826921807041314244406744197292495480369698239786402694893826191032039497719\\\n    0648201548255453658491241628000811768244183567343913161253840218611924147031705034974872711301\\\n    3529490975121869300379490215079358963320122715348838698955970877264935868140390695039885944419\\\n    1978370340949474715216657302024690822921010238317267878016267234721380200616104519987832518196\\\n    8496778635403915847057699899881067768699250358446530566978748654238337062405178001248084390564\\\n    7073189854657335895804501027618092449728216883809477166961076786128750717408114789971519556376\\\n    4368202217441589446164067154925342918115241580503213144875471172840248270384903814662018895699\\\n    5060033433506403258923874116304278079874142788460036395707380754234055612448953554883163620845\\\n    9431998080733551181217690625900216375756404646235536194748269665359945566830884196656557525896\\\n    2488299820317129272957203769374798845712996611544625365348810493612259993166410410472436746546\\\n    0597185634990325833744316112168345178384966481973441805713316987244296215964898936685582841589\\\n    5547138403993343035970391986989905213512163306291124227563322745318518785606344916572451147727\\\n    8504214048535027205443369947877979964501002753316906504490362418263092188386184618575390676573\\\n    2496966917039942342252747561611663951019311574856091007612924389366588797327505872773638638821\\\n    5162243389088567824934114569105141721980201708091455708891155797679904383408643923319788530886\\\n    1131465809227251084984140289353078725187338357537920683525662046028433006082440335521384169174\\\n    6713038665116491858185827571783371615657839888926516560744251852343316334313752809749385834003\\\n    6353272105643276147816703724224453817933977213442822408229552026956492349608455627345772946397\\\n    8590515839969689828972092297721187521187199611111958760474119219306310556306494465629267323721\\\n    4947077341264517821158297607611860911176019761733186668644241480641382919898342744216227223449\\\n    0428633599122993814518186506945635110046962161642527924845393166761222245196770741387150824306\\\n    6636495395791094246800781349610637593552909413632920525732462312685393369683194032295777538684\\\n    0633506565055663518682920531547623531317867871057837728993688093469358658221631431609286559912\\\n    6137740307974004759959580758803783206647471011471046848347033793988779567929922476483341557660\\\n    5649809534974130037135839935661018828178066448887474490341363626649482471616751250518872040379\\\n    7171006242507265802860343079675547358342687460280831552091356115464750579581347510721387490605\\\n    3124919789270969481906935289015405211360952547648504892340774982251730163146416983010247831449\\\n    9229210634712209050422048932918131223555279428742320659720581281935324355797406809648119211936\\\n    6060099565808599667898333116885074478160753639853849914572321926371031406277676794913327359598\\\n    1607632989412601699493777252358541888229506254330762146833159379915523024451096715472636228582\\\n    0932363822307208748280173286410362921199371826604860454317315145870344745713471776822316819226\\\n    6452864924317178022187726459184230813558259337079642172541587896948167001400971000314991708892\\\n    2203686922790320502851317466607043627361195047742184025218331156585425647986959169548035056929\\\n    5044594238983152997411022986841995452801766564925411036464346863351132871895300143007313538966\\\n    9967844389497485935735641236894526742398607668199716497222601634348292672301292795366312924275\\\n    6532337436932712535728973679320855446209812575087982252169804457437442124242409279177426407143\\\n    1009250467898273189423684913911251216590133202211307691587980311004449308700192213961448149102\\\n    6675131035740018668868459591385881054266169022964948548031718287168956900970315621069153436220\\\n    4640440451672970304519631381741118699675829611948551031525661263402405538554066459412478487158\\\n    8780418727475294478832867622701796493761167115784778892803275726517051941854296826309611871911\\\n    9283055227905557505895895585363202014138858351179115312587411054999402947255813936599081875341\\\n    6996256286129639024638898864677774692825848160664933990932453313590418782838551751410927341560\\\n    6362196837032915399627051224220227586771973218741476133078422462305409003124440908969843350394\\\n    5836125734786040518984092420047148748334889253840485593383836408545539303426660383970145983250\\\n    7175383251415869089022334971483295199845828747987603510203501496344122508005381587465167702871\\\n    6785961278021557957433004528189794836667983744329578397050365913852143407980689888127448748747\\\n    8601247108879000319642958365705940590798735763082484105029803448752346341947309887526952773408\\\n    4051150710461816394593259759137783440797698749366652402273164896207670783196354141345837133440\\\n    1265863652608392749919235049871193596785542502180899037819728128123096493024507771887848412626\\\n    4508861294300533236536254178907493792528724196959403387391469756238001954823857966260058562602\\\n    4720301030152917038191404672614988061534465267938943670286418556898174501758023122803026242832\\\n    2592046288213467476580836559530775615121017980219352804961462849990790580776405725647053047937\\\n    8263533934444082560898407911574152457263570596546321895191420931970653789269348462670399939126\\\n    6823840359569505206028994230668565866406572495097077954375721276351496215769641571045851308384\\\n    4736914923439547267022750627484877835490529548525396248392758366635165488850796765010939557542\\\n    6403258368084222252766343927849111531909985694154007278275878458695240844942066503612293610773\\\n    7634218432627784081398472836298848972759640322486887704813131779059067624994692967191230325670\\\n    5970912364138597383464601956007998357217550321465239934358307018393322930865306777025764426316\\\n    2806943175355103090909343517152169898877508604631520630308235998811913619495012759664551375121\\\n    9658825244853672640665471068656980040248469877522546837097568074485371995934755530148562877837\\\n    0319841014099982940538805125820102142872330575549674408532265060307161841191943425805903466320\\\n    5940822098664999672790775517243876775549801242409680926467545618072048422781038418842119411386\\\n    4257519382635685287397404907265565779619078385375688529083224913091702208251165899863485459706\\\n    7221665521540477725724277021173567365370306569818564868696204302290965189686279935056161002719\\\n    8602157054465160531671860126530087116603737351647052561886211089705262335009510356018087875027\\\n    6263284997875983268200099956430628758458183630286603597973725111953727925150089372822267396914\\\n    9849546778359676232477512148348839258508295451069459255683062452032285246269410941971109452094\\\n    0206609779577778550862700330215919663913687120648170905345268756143410792499123455860054971542\\\n    0294844722813656712098012435072416049853689420611008195440352421327304847921108663325989694633\\\n    4831002138521549200458910049701895494460517029970529876948318810688041586932223051690530869671\\\n    1085221139089822389445839372903847956166019682205238800709482372523664699200881511850168040326\\\n    7119360159932905900942242391633816273730915818545940785854219171750961629003056970087562256195\\\n    3168223114625624268586070080428280710230412086209738034987084873471517381607985867918001410126\\\n    5238881624784253772923113510677450660214758721845090790036253144426299681443717306768015312794\\\n    8336717694524632536053841446166088876775921603273026534533213231787464514700820097140427196358\\\n    0110721875122054422080990762830019511329629283336117792607610472466997822451301097249717705012\\\n    1254606715888509268803323656452729309595565960573445895279090296759901948162524989095146794936\\\n    6680535341136353668207712538901225355515949945705830564611416047043520487125345477662658595560\\\n    1138449674163951717737160931968745854951328899697563232438556440873109897422599831816856066807\\\n    7090602573909263390370074949723583877506081875463678249266199907546256906648807523102908808348\\\n    3232437675775644721156740850828954370330738189542290544300220135872149353004858518897705402412\\\n    2910898412232588641308134442958238217317637667121068967353462659370737255754386711439965234922\\\n    8721743826482395759723307762016725021058767716372433541145394460272941748000416135479185564408\\\n    8603305450037562061618943485057132365059273515413097802876279483873936577004738237705267354005\\\n    4179101785917773241306572850277401209479106535157037935493084731965605126650206600352329341181\\\n    1954087572770277402732625540066536370152466949967246699048381034117839587602378373914510775868\\\n    8676412078403593938702452010466404387300805203489438816417535738532095742605142956221578580069\\\n    3548936577773328204386071160782175932588776576760838721277026539434493873666863457888855020541\\\n    5624020186987644292244580161968415991342322388034190883769226814467583900273019325423445962509\\\n    5645825749612305815706138939079004565348703085641423094944014675999158015946816865860247192446\\\n    1742244402987676891196975767501825160125775285233891341622189631406981202157866232401236941780\\\n    4119188775304631526004792713516359362129789437192746094090510423459994594764634799515277204072\\\n    2941068003056081558344156563335811799812694187435076784426180685496386452765404708050395143294\\\n    5065526185306942383779614644390496774376701908804849566145524221989255784641150707048562711114\\\n    7173006631420732616339097007176779754461594894669690554276833086853931067458613379548366770986\\\n    5090060518428409353975602626038790906074662480238939904346425663693794901014079176503554933273\\\n    1504583265430861236597895289088756926066789296997869257698057331374446274309940576625356967385\\\n    7835407940961400850043180800789768891009994703021860147348596685263898765140558345310934292195\\\n    0619343143914884686042884335280380540998482210363117295561410790707326127073198443308634418235\\\n    6925366590586162208728297878509403828944324734248410860618501216673007543549909500436815372157\\\n    0453763639611340088907606696281459920869183015336530059139835974225584704075725153059562133253\\\n    6793027667593868414258798611744238795051899948630095963161330657014281053718621526002274196637\\\n    7475343334838246222052010100486876938277543610262689687193801518451020892524388586740419860880\\\n    0078256338018885448895324698103628201849914061263678183318669724411686526755510290781494895542\\\n    6461421474929008296323459037960776716590169442840759023163900589732912192167521414048997509113\\\n    9182100301704831159091402420306404590670749456477361541485153913359854901527008379132692868478\\\n    1787533180715542605116524809463021264547408241455914963015507281810071369272939196779248310790\\\n    0553797943961412585131342676449849288317070219698295786966725021468072151286086911347655194969\\\n    7244707717739425587998348963575685300890089105582435883906132431540007048541676142620722182493\\\n    9420529748674649643439993280231951878478387145847818578351046366154563154910220750153951786650\\\n    3133376530851121031039812987611484240369504864646249136303210679145281197232761286368609959270\\\n    3286569978395367645880478318916528963949070586935053803570881833090005430867234009360118088070\\\n    7361669743848692986394904845902770587723255573122008436226953584499809739701236915280351801988\\\n    6178852545510795274524182317003289145763972591374100981460656768183101854964883208389636513443\\\n    8925226183879869941727074054912247275975929387433487756872655612647223162916425061979192205275\\\n    3695112231379891417179674502935885097325430950594663897337146414702855443504911094745523227075\\\n    2511088947853357328604985400397469344738562494950708627893981074745209941670549999509597331050\\\n    1813503449269985140870310244580994443262927580480554008501587133165169571567732739796422661588\\\n    4499396098325647807022262710951601716079707763856630444675017628545964507199751742017806487803\\\n    2518319861144369156546381475377051476564180543981484420880425108285362856749734345984366540177\\\n    1168626731179290945840116560180277991648954826146834360685195069238973399153623905837032812581\\\n    4002705234240593064273747722092619570317275411419722465405770881916598220256276091717663507166\\\n    2684477368860467207698606038381485876473479518094594705176552799943365601757584284335555847965\\\n    8799707336574831543483608027537823041978417089811228904349342898335434452597921793526291838340\\\n    7840742077061051751598362779957023162079868137510744665622664978546642276742363721284065456890\\\n    9721012972935448032636597208898574880734415398678482147051349599539469489240854500819591793079\\\n    4781802235200499247188348349423462381577777735540563419862330805828140291140535219212388640549\\\n    0851551011286683701906493450461228625181783124491277467073406542887722360515277016840062334931\\\n    5452150078700347652090984935670900836890967002266359795775113514453007459097785166061184950727\\\n    1309081648085565095418784137098441360444396740346199068838640584782304709940051418008201969635\\\n    9301225482541423595808350641816397734795055857017167332425347130973400286488705453047264065303\\\n    8077363836373748963700550025238795614515508279875831645825037494747125694989888866956337903401\\\n    5332173620823870416919497296717505007032099685841318318523625068772672582093895830873194334119\\\n    0151315345860330651962534443832406495247874366840850095840056080193648880333864707146893639467\\\n    9461389797452980318766855035399254092275752515985379606334530498983387097549753516427503573214\\\n    1885181286094236642532976475820667760919624178032726977745187359334201421668151933447361474659\\\n    3386702086983963106128195032735377703442577738850689876230304604645324986962279935823445782841\\\n    9038397668244003580831227893082233176960417859692168516929068815617083841120095519843016500298\\\n    5211141410721969558590140150163399812051992158550243430546918011267822997581368364123079600275\\\n    2036394650062619734113458751704372906943282120072839025602591207027187074392979528640039637061\\\n    4995061172871901849079449408848491168598793416429449942680654390078415156964713901819509887972\\\n    4552904691282849253422058611909834166615574264549152126565016922229712725292234622134818098977\\\n    8701998495249230159700118953921660485163229247776265518608252009696656872972501779399790924520\\\n    6392870102538689674581464171064335927349061503441297274841794135413083293461973595866988986327\\\n    6041654313414908263393395316552551165417121676757173927856836179097908328595896809948400253051\\\n    9816782703509256815198567496836779355276243569985546703364478646503031160140769301510235805739\\\n    4974793403368029581409680332967706071356325599843181712704149405054979842539143836309953984558\\\n    0806493118746006288094513104548942698350263606411341497976847423812557451805252015530906772701\\\n    6812293692547649107187447529123845638900861752083349863242568525940545882384301607415504329873\\\n    7152205840724186989832860073341676215276296011507827297514622506884757238794001175444260838198\\\n    3357121235289239495637340096043717460719305305656626730692489059840692040377599114550766551138\\\n    0221137579658005041010289031985733261161132137453790606777735572890908414298520860430664013292\\\n    6495399077607335792446137116164087981783080598022803887086558575406826509198547053214046023045\\\n    0506375805667698658651348815090814028140091807949440547751493603335914342925689582204385586130\\\n    4886664138308469088163326091446483199987460560009325905101282199749241465502621874274085523610\\\n    3551213994688374064748142947278789013245931055346728512009249899903269537000019289980092619863\\\n    6227935673349010874789746494815751667850700566291011574143844201847399052348985024062665229710\\\n    4198192526918051750167011464480323838190035897324504071749255737046748115409415153497347671047\\\n    2008707756918705450052232557496031811172708293713850464153700301518780951051973612083424687607\\\n    1767345592684138674470428754655185173382684484083355782140961178013504808347795762238893749281\\\n    9694543888715262904743825069707853806639347711211010769930723478067693731515949357682800097595\\\n    9691767927193037998217239433084051629483520098024910016061263175261665180779662619357186211604\\\n    6347217423661712167469519981165042783753437703856461877964665944854252853901152177968069683979\\\n    3470551817174091810630958530277295769805955725368226928667496435258177828224440159938030735811\\\n    0851046277556920304054319826896968092364211155172246399214200037157100133534415615464915341475\\\n    6965487481459062168460592143774676124922111577814888994848470134744707534641976547608977929351\\\n    5630018914738068763631597436575827599399374313236768028877897020141639564776426048323583325388\\\n    7867929562874464103896231893186673725123168897036847233946412246141609043115140684606509317760\\\n    7206502032686196892389233578455921485689550993843898138498637625964454878616996296750932693901\\\n    0368527046351443117007052582871987838408111520996383955357775030109224971415953063839750515619\\\n    7806243796975574585029611236957664661497674415537018432407215100482451980792574927700658389214\\\n    4523070739931402711101579594514006320950582769955246431800215585171242350291404123074091165488\\\n    6504893921344513598051751543498237079482319110372610439136913375376452060145073649654466294775\\\n    5069339062699290239211537478225787390349484014440607998060352385259393302888314562292338604101\\\n    3614135110778542441955848508923608940725930471093197437498249421097175053263158843250867793271\\\n    1199295149233567536623480923420194386554040006870275165984709332144211963683847286278217706242\\\n    5665015190656108415626067917560557597200788721500545040058792522374650630469082375145308696844\\\n    2999157592135957598144789587703485097982337427246917548474567310579411846991287516837337559450\\\n    2179405217100120419833088806690409665716127987614995716197654989369954283341445656049038456264\\\n    1470918392611628222648368663384318035220552260788048403953309572224476841534858163345076336216\\\n    0299074440426742868158998631427944103266972371061513852449660993429851884039496394081723647805\\\n    5929356076035725667678550150702951538639112317983251414368648316864139224006939402555392669752\\\n    1955165889964873545084027061876202990813958582223609488573110119638933379890059508956342272290\\\n    8225521142065447523999257371852168631895030801960119810478943573177222110724662925858909301458\\\n    8013389369533787177051093706943394694918248478452400193145513165882319492596517718965628855398\\\n    5329428997744218892440154019279982723505569571642194529448375594964214173181013975998956824124\\\n    1999637994054542232148008384863422088713006652957976004563100596377763834113554282635234190064\\\n    5741817836593744383593924602799961086219508414503018346181141371325245843341629362503087652337\\\n    8180606566429288668942325052403632111581062093469289202576770923379307119590345083775768030718\\\n    4948541661041290789549105333840410730501346964594282064586315269051625398821432106489141917997\\\n    2721935613034683359897059084241138205521789068393528004228657909972372884053895836043626720147\\\n    9083451114595552090120169015693182865551308413563205175559546008386325795847049251813259420950\\\n    1081726248119103429513763311269776335616876664034530922364740348134156829552651965871385424129\\\n    4825594276256430782539216216880537776670209599471065668143765364224044412832351161206895867748\\\n    5604778498569010506413788441555698818386642823518073825611110341917650827191653185237597461308\\\n    8094469877602868442418002694131782371520979296770235504376933267865406611619333793728192410666\\\n    4516594765973920013305043891773302765898432582052823626621096065437121378717963649874599413282\\\n    8654686024614108183181434286028780200000027354984284168252501740991042478143484752576176003492\\\n    1781315919762496273286949119022705931663182158620147474534595973521911998899317047626277071677\\\n    5925326977691715531294822966059752541492435410002212445105443827307198232952790427872279293431\\\n    1905509322686823670230529360077219069588487604805835973492520410464735544078663170209706019421\\\n    1061066641392146018733944190950621763370105903842176072643337037362235550221383224328124277701\\\n    1520354964514413008424551321455056457211734577164333570833888865122422231677449314825592094400\\\n    7751078236852598353412937910623794318319889936591119780604651480718778271729377090642162846908\\\n    5587182642498044099909309084714236588920172008804322929767423555645691635800200013709545697271\\\n    9815289647818992783509679117544541254487368224874329087408872323070786681261013460539061704313\\\n    5175818296776225453725308924770600125813229470205017728319300248229100414564664891701079266003\\\n    8436963796292078225138960887973434646683627778999301692070305842702677117156765504107011642388\\\n    1579500224152556524978705201995098974895263515243628795995007395784547000731184562030807251757\\\n    8537019308019828364889326802738167124078631924008827923582617379818592059307389105626890200706\\\n    5870479686583656974950193176999420744543496812167561311698601560775042603412624004998789058098\\\n    0121838367794941099796598252300696816742473323340547941566728544606718046311900412346009095515\\\n    4188337453886934305085031965732823898725089115463271766481254846187858813800036165033100050226\\\n    9579654307953024310329276947291348028386875950997333437560437836557100753811869733844483278995\\\n    9300495232295182196871444417684120033802374094496619792031307188148108261725010006719705438455\\\n    9029316578156943766540522434014723610674589563918088041120075950960667241769067640996955245116\\\n    2948445916771559623570249152952297650058605311070503836449393807424933039791159550337161092779\\\n    4930035474254409995443661346201546165709793188610293069452859215644989233794986330014030484393\\\n    1498380316497830001474739963824860624426726044905707416319278658237823319469251243043340981900\\\n    6902376490546824335423194980191761990675893358569494811928104599222277386010175118496852254474\\\n    8714979103954140598890606628836457762514262109446161161605633575205782846518852970966978936093\\\n    8484264616210311409856771432383930225533826418184346210603174525287304922800665120802768839729\\\n    7949519966938739021939171269220521709700628866311560876549960101912956582449976028230718058974\\\n    1565591760575466497347303643159653766258701958629309263682600479291379718971564151413301127511\\\n    0309099284072301642453682141994375402667084756172665188855694464452605077340924367495903939792\\\n    3328589098049291802368083621482402427199482725719917766701268287592668250746568793243553217151\\\n    1442403560613103632317100649689812552137900759355545183895169960269373709523440333156553894393\\\n    8455423272885112485718314507773010645453383662813914091855895607930327671910038417979282133268\\\n    8770591140808042772380923131258350058940772365157301794778916863664982147990981421893618014138\\\n    3598332525761693682688607098037920202707069115085329568926780792370909544919058262174810366619\\\n    5868210302569818401108548194080082117977749252107244683768310595640986979201506207602391690859\\\n    0984098983702523000737429811186034006488478768841314810960647175674464145584896220170866640785\\\n    4213172054284849028597797648175637277627018005603342215851342532018720509653059121099648418508\\\n    1064837908180906294534997859084304614673922842295712520982603258178793713984766368956052329744\\\n    6602317483975756643123906996064464131953533204508098329514865086734946099762109276763940740267\\\n    6088465763148929368787060093522407145409895479813864351353874281361809143745863811928814578172\\\n    5910113490352953221433463000172103011941832549922677280861676167818137101091667071199943329314\\\n    9563644346427743684948878476389862673036874778900079856914994379402773161541627610191978520396\\\n    7697732306599631941657392686123378061620280144712963764236452825192574779840505042758950792576\\\n    3528853947230987579585336442266017332066308607614715257812270024510043049003150291221120583793\\\n    3748282407695741231548836737215141090893603947785301868264672764273078438076775545209224490699\\\n    5477154383123743052614533512568710549558411381578342476253831363926338049362493335182343263730\\\n    5248037232132128110489314303928162145907239789837867762288443622181277055580907742745468430939\\\n    6685061973398439997235996338082405936652708246740509080009313777447426081034783566197182311268\\\n    0280411062177685197127826534011155773234965271738851375974129344166413879040872151105691867147\\\n    8311000068358833722710757144412488009042475713413172476343944866034259995451901954452459452945\\\n    9663832090986588631301486002932352273310308101197237540630800892485974664772982063993479094485\\\n    7592495573329919032877299135265026514018266467293446958266461420206831165618339812325458672491\\\n    8567500589208408679025911899839483220256255205877669577948743933765881364903649727787212359530\\\n    6800788824216691257691086814809228629441556740386304524696361614261222236777817660077729526691\\\n    0510364496245113223490379786131901448908754986905155530991653718028378094205743416059198488954\\\n    3168131214308941330202420912191468975884825973364631806557422919707417020705440083962696414877\\\n    6503177540194581815301431262530214599754320646354341727787985273536251628865039514865438249584\\\n    1316092004837050590968218430507908866097542399893587117175996231811813653816311260195593394987\\\n    1837245118996635401809730197699782871036970090398179411502564084212828032126483151523808390563\\\n    2660761902278701555192109667718962072812933965882022450948636435889446972561527316142148088803\\\n    6097450439864604033606273109788893821658623540591082355962214860356713584556612228240552926152\\\n    4034056300376992015423946215913958237478176987876564824404840922555172485571784444692059918908\\\n    8473846114121702926746833908878397745067003717797951335256447341446021920320345303363691856441\\\n    1126964566145613773115365452129218018635431024268102236906331404589492016164500991399743827227\\\n    6837963186900194605193311568315350453132047504550566426194850852749787285277052921262768988877\\\n    5383507198711603149232093231980113012543318344108860857759685222491496007994386471410303264341\\\n    4478964662831991525413993897435575751565246626460842878452061749835567676369221963958084203251\\\n    6842959151512782399184221011416851037162708592851245393582114462770770307857671649736850046275\\\n    1624336106708976816043810968398340795623020075023876668255484158053334542410579289982463640316\\\n    5645485532475177112144636875239297414446485963600351114188154746314965064182014821895712664417\\\n    0745893051779723258311054794291262593862245231417903022840309392425552846963029065672066043793\\\n    2535277844453245552502282495031331410211344241872700198357587433153006076236675912368280054764\\\n    7208623361143920532302289598232391259386695970581221798290753040356132595896279993271345868801\\\n    8991728567497187152087829502389361665849585927339441132821598092325575683960565677606451228519\\\n    6904620715169387044232312458837147093293120698342709966136762203657349385644096984164814771375\\\n    8289160243687797056555769567918962318071685561220845306682801593534282544920178567041349399534\\\n    1832118580045170639689488565688709113967497574773053439094354854022462392093876918064939000402\\\n    8113842158395533534008929492542185981782818692052669795753635186223335073705302163641551264004\\\n    7355798214344061893246599869503716155654742407110504874214531828050803043566603812515270690362\\\n    1379402996288471910962045633200135727814533032935260757701290633948207328063565482303568214144\\\n    7349338108352404973576181488603033646664445110529352890643284566227473327164640441877868722176\\\n    8589747072238245593772773176782511631158994381720728939499776324928170996993047554277637330887\\\n    5943800314328737059810864097185980245486437069936057020312571558606684320305547382164256001814\\\n    5581308066018445009080330866343641720423973444934323767933579843650794320085537199718255703530\\\n    5267210204832040207824185537022480407585647141040740499208962995179079919685783536702180846197\\\n    3783406755210685326547180140213408698979447863471832845547365512727660646516693763607506763612\\\n    7635664705194032128662215341413025545967285051316619338743578477795272803484884570903522706246\\\n    0688651964457635702920297298982061136946965153532707961708122012762138531181772789343653261096\\\n    2217720636435094198841408786278873214897873436579685475998019513248286585061641144943847992909\\\n    9373743025457012602039947048218213117250262836227596996863279637908858218175416017449298525351\\\n    9297255028702086573655448974222274716775370166765272834622907335679291052019910699103750286115\\\n    9239201699894185512056732979533399407392728386330462650468200004453109562863265040938046797864\\\n    9503207934869332727882760014574922966837095475938346888897689334824808888258481300399369129478\\\n    2831336119541498783652729052168478539889181538294963745955304291683427124029089527287627738648\\\n    4532153722174904835760820372422796516275970996778372881909730954590935832567272189534767584207\\\n    1878487858564219782711435387663759088272270922444480129958114470972447990249235927658122338214\\\n    6630568146003955246167262919935157666943162532201869638125178511257071511855174422273498447204\\\n    2308803385598238436844324484766449970623447834642587163466896760987237512625101642421020372886\\\n    9009574080932436397142802801059211529018342609150366984004639185507283108445132305709318198973\\\n    8687351571797768567556591649250882439615610344230942138200147490246268966325801128194480124561\\\n    9651897245955459446749471928233703367176832955914190489600985692492717512869741003607412884419\\\n    0326488922137504594239466190000844143530674645072376363212223228428919334152719980627876620012\\\n    2727538055415986175262332679584314864384098610048296464279839706938162591906055101073067269108\\\n    9148731282041942910717263753878090663375911867731493212711767209597543247593283140562503236485\\\n    5181181209187044663288683069562748549814067754259924810522534843916027390633262688224212507852\\\n    5573318932654683009433458556751239979431120132892521781393145337328216673617524989726613021888\\\n    4693942245787266686909060157865693273408140950291541993111362233446525429281422169205598239081\\\n    8450459272411674361230678257756196596678625917483446997701838495136896558657096634523723443563\\\n    5241374035977625302141239461736713148281776636575011585605383724272848088948975067164463812415\\\n    4029407370065001184691338359574840994843022998820718412849780365355744662346383825338693908349\\\n    8398071200928704391807929593929584369828278080995638223594271631932062065877792591060623170024\\\n    2507725779871058141642365735275773150849930426129753461593561061508819656451505314364048413490\\\n    6140545921783683393890131722044102079179672604585716298912865386967287341543089056756353777772\\\n    7026582744052757548696961352494669163689272676884650700775543069943458727260994955991461922208\\\n    8962094548574059746334961905804345600567265870714222447710121801074103667433506146249869674962\\\n    7288022503968158376525203311405646664266636745839799787185796325230733431012697197789695553357\\\n    6082689880721543569126221295139054796658068285099497505845106643057229339736242259215775612859\\\n    3497107335493321141702764441493526980087812837037584287128548022882307175791083994456022223021\\\n    2295514504560891873879654631872403969908414361371510464393067567157244960285269059947015420353\\\n    6133562366157156764429372592875323330556991252851941879566929008194197519151041498066555460710\\\n    0370505985762217370676559544848500721851716965506756867639250897081202645132252832586405299225\\\n    6144178898511033807218681151307098438592117643586565174947209004612437403843901391241927708146\\\n    9126693886355882562005179154650474419139946510739187415230788840626093136476134457764519828334\\\n    6333705397152559789236339397197496475053054774291442038726569042645545905021850977559467612210\\\n    9910713522102824038987279582827293371659061135541925609809611970443730439720687582114635223509\\\n    8245946100110023830650516511824781126083233438246003373541293459588285873753441035490940416192\\\n    2823926989613356352896173612135251104516942277732394999821514044556784988589698191850543267721\\\n    9644991084880986125853638591072941645928820719479109489921034896397417254051936299636082540395\\\n    8148330399148005206706154698472916461478735216145518440552164960321056744858589534309836655769\\\n    9182869239717530654227688721270891427621336409952056785767592722607221895029414545570686574265\\\n    9500188179181011685755796079995866679030964560141207703044155743341388388903893906790319140120\\\n    5926459462197375453869863448557900418559289002792241536297921567953422694236496251212117279013\\\n    0598010755970388065056845730608581706681571112840181259212609918108042369821764700715246967570\\\n    6658597291480949833279068544570136610657067938148460416020318877177583066073288643471466340730\\\n    8964980430128222922041934739368461564348701475888527132716164306447364238042772612450052888896\\\n    6583216574530734935281942178234174162803334839591303142658381497290040472337808310805346354686\\\n    6166053513137575014317241912042077450805438975881187238545635403580480411369097279959848575522\\\n    9829929862337103721684722055551307197037583897782142457721197584132456797051971529571314921252\\\n    3296089117947184385187828748595269373835121055534439457924470577325440354711976613232302446300\\\n    4756768552090070370208078969028162843027039498287878247760720558393036941422069350498429637574\\\n    5331137711374094551550594463664516365438780976025443482296095048179655711328620217443204145522\\\n    6423979030305822581823094715025260876426963728484574437932776837284861449938210338363449760205\\\n    1405106337940582813423231745474686330799115067863775723698614452936443932410976567573595752199\\\n    2795927695935943283558418145552262327155902635394859616930288278839720641918776024245976085564\\\n    1163310214620916554004460406201507794729606115653189623333359380625913300070628961629436983062\\\n    9140927219127631969906590188570427705570151717261880345085544698500720132326546501540833631236\\\n    5238201766681201917409316951276942538869158923345596464905189075109781169952905389637508238862\\\n    3122388575044852178513070437917496999046738408570644887361573115701479913981068628168559377368\\\n    7148165729638000398460694461065316851544595475659088475090050520889963896407150638402122400249\\\n    7586292153138117695825014228038141065487847779069633148604566928738296000077144411792041444107\\\n    2340354930306384330796265591815717056530422189447059238549374011206426047987813289573317245382\\\n    2698940714548100507032196089402433238936667574976556806470980175690350112589033443723658895156\\\n    7959622412217406885191518458053799791295673857324165995317324347988106767724746057427974928153\\\n    0297861294378595821898110040646525877921963783994051529252118314336797830781189854897028032863\\\n    9347335053630754828941389270975725638909922733439103377549667111523216436800566940415874385522\\\n    4897443965271089379114698772369291269280019837371857389395135913831916714609481281476574797483\\\n    7416138237606319926331960986296035757441794927143353444222748783587564072039055331019571439045\\\n    9010731786531295219024459804697324984439159294425211888082730790779965240315812979175362276791\\\n    3105238481021923758912855002445390529375414323887703958167996563312407609767646684281908770592\\\n    5622053339777305774270202412431139079425420632316564133175172975404857114151813867004281713050\\\n    5057909635749027909846897070202711314388638901692830396766845392882593172591534791808578770807\\\n    6352825256050502211363634501283323674567867421891946749350019092805769511064141468112626157237\\\n    7357062268494867026459415195884807088093985231456759958302139457773624186925343535752764458393\\\n    3313900979845809719147373768809082126066055103224500419843144581527314716165375861151228578043\\\n    0542998792285705323800066515616849527471210698981392902975954434398289612370311574335556545499\\\n    9249281041653481533891970373794486262007002104039729927060271175102024021014514408282834467887\\\n    3266931253813452988000059587027877632571229544047912196072194151619623254635311371157499389969\\\n    6805786995460745156672084406575122314475803589498615150416543961494428898782893273466324423892\\\n    9710727408950386225296492681199368378822107663153510652682068197427835811298823388519750273188\\\n    9292907215873916876557139040009929172012025073555172000368684954209805969327032384060892754090\\\n    3360559169972544471663599867248859236380163839886446724954569603542297180116974316875672221046\\\n    8316502658689204873813918674139864449228365313969981569464908522292291455516904913974716775318\\\n    5166462946208042195775967834462714398769859733360893296993369213160152565017648485982433500145\\\n    8562690181613234163701448053505378152592805043859151199918053712215273635553492721265855599987\\\n    7052065036950578957407058458743389511102922393633294499613449359241047557993548810555520654177\\\n    0849287541410836370995410162780564682284991402188959363131635126493065900980907918951966068005\\\n    4278909688865946115876947189438875979346655081447303671930303888177475481191278621070962138631\\\n    4857193284745098541742597130230246375638326888494202692534491772247772455282988942567505302458\\\n    9584718960278385802348885937676674682931226562066642212760291859838261648228545873230242087356\\\n    2331892803349938774861632882706167762308914833668685892954373145719068455620415911026196653927\\\n    3432194738349114658700183542170106168735353966080363079095167161563516488461678526240199790415\\\n    1317719209492933887973863798852218174035506684019031404786866912677863102357942441313270168012\\\n    9137284856178158104174093217676424818695020694480635117858250450410241586065461697602423335792\\\n    2577790444388014718703248462478919298345734796377396013893795231291918530735389393034785111231\\\n    4529127044907806877995101854441141482241659093133938005919515461673225968533062318050053460401\\\n    7262115054682128400611605177249833401127511555628504649929776368681383562046516878863711946771\\\n    9839474767643167059179840564552221441489602587248560609733633826446824716896297839324885393426\\\n    0244100209999266128302310877628320237318495303409714615017572271327826640638066096014106999387\\\n    8900377064532260559962402271395730300869142861763113283047366786165354518159795450413908044519\\\n    3845598719883156067524638141181251250945990814638934622405880168495138690531542240240174600680\\\n    6467547677638965724885633366257809520499465263689396568674955182142480310879983885781326228513\\\n    2907489544766838554232006213259988652265085285191953132712822523052419399161930901945233084543\\\n    7374220668634525888932745821179042499219633653416842942457751553863488152377833098253644988754\\\n    0914664341864596394167873609672172556122699177475544795114889219630020929282425613296286424053\\\n    8569912794419740690271012986823758449589367971320976075335307357055603290913742743279611291863\\\n    8083286785557533413217996493654123587390828530780797511757242798940809111758264687517689387372\\\n    0954999239949577517427941849543324326808650995712327876729150589632708818867853453816516067730\\\n    1612389308609209722942264018561842116588520709861370957500522747171461131616005476081728876836\\\n    4584186313744903637773652896683718909536039822061934058039488661810799085176283220910943798757\\\n    0120543442503889047031044225345801532466601813422741652234304534267469150128417176781767122222\\\n    1413395562899676059701108394506280336312461142585309583220257096345075552676807621642133424179\\\n    0235398170591429003739592498957977719603702137671806601040210423187461580100429673412908083521\\\n    0317428744512053524084821381146367372603020166615311605641635975806548068579432981097973789073\\\n    9887886189869730070510460952548976024527082693732301926216827804356686340259891548839826790155\\\n    8485490253379989419138498563576319883747214892968776315189499711093687335473287662906374334257\\\n    8325112903203409247232220937824980797229337902677265919130488303107146977425748886705477712267\\\n    4662319343571143493378690503215215601159516466423814573974170798554983209006343463096232245310\\\n    7080392438338086833161390303880362120245712590889446839574234167879542292606608892240844185517\\\n    5954905137575483975112532906449187876930805914208209672061712884384684961942970981171640784534\\\n    1421750873188218167987591516730350862209706516574291345081570007158736875998928012368418129068\\\n    3499313802000062054019295692533909358946992415986839408732655457168750370635150777724947962943\\\n    3408225317828120216322449206055684460288008356648914398074567974662144658829234679516202046862\\\n    6409600584507751365914213008423288270537593614501246651665218980752097488126481893226941241105\\\n    6976225517388075855555297741221854645018891792236931754157588467911448183255406590934445718990\\\n    2429668313747541512067982168543780997973769569122342410801189101780849209479271487904107976369\\\n    5556143472940311016314259907709971183496502421128340711082136401517376007100601056266939273397\\\n    4853082954979790788943836388801605520856398361677156680641201573360715525087569237469727387677\\\n    1287706955915994756032358684809451173657299960732046699668008657056601525455137268604278209603\\\n    3061978251243422076892809265328934828373798790908820617465518696086707987258537948029800950026\\\n    1088620761342465330321480127963499722456395660093841160796245239800955685545013970148040101862\\\n    7686824028363575568973169271449850994331116604174951206594452263291566142100304983460438291904\\\n    3532169111329068536220731611061612757361354481958164684629070041999768659931391227001153182750\\\n    3678266990560334223409473282937352666195227444877826305046090758885278007507394777302049875759\\\n    2256176960154989945506648389789355349343442832335348006810314635778400891960651200523554947508\\\n    3047601153799935321095675584311573087066801812422564955742383772025692553842379773025645682846\\\n    8143561588763103809336938913367092659576230902397181347727018838468302153475182009684389276303\\\n    4286430445455165889194158730834505276654878850081030805347079546820660609206849509636568579714\\\n    0850823912866223377336078194592565787135572776040190157038071278065534578664230128330264382351\\\n    0218570134053313401815098640288316176672398414207106019757398836970218263124719100181278765040\\\n    0458123121603663393416076142612741949759706618955753814985151649943441892380362271620991147104\\\n    1994991684600945100465363089365299557497235390517800305498432967943523748779690704949290271802\\\n    0194707488535642166521701669627630082280576344994672656808850735559135771678546168017561224375\\\n    9303078385833792594399085928874020671737153696539119014287384206709877323280281919736547334619\\\n    2238780742486515868587107333972868212620006551266047323814131221039482408877820377665691669847\\\n    3092173991264922386973983078567479060556577214327361320189195348138053921731021882847821200832\\\n    3438793024874921826816943491987428090234300586071680914055661188429223113851742884314832912743\\\n    4401217216886973551195337537205992969114250189682899979549945066060674197509295679446815643337\\\n    4273990495552513769326470274913058005189371180104342073304504952397503795867653361753597703297\\\n    1162323042318525627931567131659054803541539652960711290258995182999826929369185331217305028217\\\n    8780613764409382381951768986624558971342471867231086520778599021091609588665828802444457739928\\\n    8618866591950820556274784649281688750933270437895561397277053562651501735961956109917843373322\\\n    3489438036231830959454189530220921722787992487513795556865960192480187963287927481534230392658\\\n    8573207681238163043226264704746020949340258536562148685618753266344382793613926026153233184203\\\n    0401173379671511607821651163789932259714472097930395704669828443161721278194590964610162330958\\\n    0219069126537201675025957231274508684856034426649560532333902165082481724158955436500899704794\\\n    3705622441485454449838816226496221053590534277854790139356138533657703153737549170722342437595\\\n    4285653002554274914659536861673435851116792561978575031941095073862315387890020412479447221637\\\n    3638951641865777993853357836786761561629227535304024216951606471695183380252896822681252762598\\\n    4858707091302143482177671120645396134170909168416154926492922010532263094155789894620371529486\\\n    5850354936042729636492964037301076145568503536322376492172763527262806789530542754022212114210\\\n    4727319307231828494667752008721412449429402772584155546472167463209144932080120978840682026926\\\n    8686802789552621746512977249223135832955408292289077232925592407057033887244810325188083796259\\\n    6201061602143206933084047112698354695786387982228207046567089072296688713839840301466070480966\\\n    0307891291113884225816900610491782137184674082123270003474115816187578801999610478380276067063\\\n    3462769508026542362849917427077492618569490390712595808876482918058558240103298861737326381016\\\n    2969000283573011502794048142666064506578872019167703541846503130710486498681223674248476396296\\\n    4769774231674242632375543128601908464649222080792854847436179086600189429136315118842473107236\\\n    0136037615799188826352160473890649096044056885145621151818287350006475773883347525209676499536\\\n    4384934674234892083311867771683535143279997908760179563485319318242174878422411421286181930178\\\n    2934693950839246148840899712976212287883106303320302402814540792935431078017473082106387114178\\\n    3675802156665843929099252721808337529534360823320364395765733054154389572824951399956260836551\\\n    5305383590013419832201797974406075364620991009947219866575632728618364366986675203141676260629\\\n    3933795710801460461251036253169663984370300376269000655899256903918295767608699434093844097009\\\n    3909644124245104956699261947890782469630124316864063796075564859911973678729779032588953243116\\\n    2500565352966097822435746025304989188683676149272695584297445020292650375143539274820997930165\\\n    9223585392974541398275579818990646629537803062397707316554685471396214408901681769870688621014\\\n    4033204601436933989463478894535770692125030254145715272402733229777373177836398786643206457067\\\n    3018146202242169441077851692732046877412396602791746611609810437697951020949681717784084775117\\\n    0900965192127396188838336895786038052882323614668136656976636554370310384686260476012554935923\\\n    6102457002294530821763743730060523750571882714842752565164355112051803854455929660312503789409\\\n    4260087872756308964888797381766062040471310097124122651088623582659391316253351269414913093468\\\n    3774164569616692723478077921862733230783388288016045526340928475756588149127829533873758318497\\\n    4354423778760977702647284246332735135946757667381129817160102315186546896204262378353804514473\\\n    2082271255399820880830164550867986761504141675517477203279980551226322026966456418188848244803\\\n    0476597603276072145064971053853448357799724796745641081902516398147136347436267632951902037188\\\n    5459584527471416811041676794161077450191571601854283699100900677644475366735908494967100500090\\\n    2444040631280626108882048001062094766696588141920417562626342259887313878534858794667056655938\\\n    6409823981367265453648980924179836334068243073757894597321912929156866427166655037117108841518\\\n    3607220273446206413846593468656636650612192079612459378284423705709646415481908825705973411825\\\n    1927668026848786556549242687152001315146203175961820910689874751530908303062525532514289981478\\\n    3339078076468099024399877752362807269338833971617681201795731276816367035092537383375006096849\\\n    8453336506082266317052138199726263471877043055237945008357807038729895557943695307714678298933\\\n    2580213123428995094640261532879885246716089769744916539026528866970306876554310179731677992460\\\n    0293400553347751769949536249472917210454189501325847222685166610757889958262973653819954705710\\\n    0710986399483404449656488709391554632197473421601009232030085440420654548529159156707097879120\\\n    0703435947794456429612122044582851084830379487148974909601279199071655874418025974491741427438\\\n    7224724306335250985952685336191729642131142486211524645490401456470514180188188247835663762786\\\n    3302723733519804832468731954186328119397712961785846756247051151887388305088766122483466287460\\\n    0882002667839317651912868015326367135679241133868307034104619580690994228322528790490964959385\\\n    4026178417500490630725776034321846628028858422083264083696524436316750619959636658929796236609\\\n    2860732116409627206484204457246240236882349713842075057045043979977303874708519632129768933638\\\n    5069142381560473898649933993394586119629254415317271743558516302104291786255710230535066696640\\\n    0797195420042120322374642093516171631001099126435193382883890535138518431445920283916908249803\\\n    0410032994725831322126591415657189593965270197738402424569446697393322517644874530598891437162\\\n    0195205503817390974798362214317574441747143893394911453837135049124073815652238051475184726960\\\n    7644785367176955673749905004854389783461973848068740597629378325292051626123088786021592080373\\\n    3101434401682859101263694753381884725406817616824833581957090948332749894342458229039622500245\\\n    1015887558232298371257782875528365465604954466634485802177611054320435105863256055823928510673\\\n    8335593082755239527225091824381939920941415051769242822283361208312781464338018190161482862668\\\n    2223417749862521113966487015040040248040778896033260120320323110413685294310160400108981364076\\\n    9524598557860547287779355232202337152857025288995099939795510924161815978960158660415802032263\\\n    8612911811258540833833186789906360220052837063913600587824886093704890085768213982875179847174\\\n    8242144805163737936048989014087791074568626809817685883785992774452304187654232839096324883829\\\n    3681648718563865068974539848393094612901516916448699991244521619284767302402349929665963340102\\\n    3325657518755564512099342805011033313704294010640575639666089022448453074906339784378110317228\\\n    7534514257970669750881870532867022876837278169632012532450483390450443807684636342793830531338\\\n    5066782309920788023783224864272441939101930028870542993620186514578677467427376176908259877280\\\n    8869064451220200461775331151624265184771115287442751941597627298542094190945087317455438394934\\\n    9374907876621073657744841855382179725975533793183670551884894769715000615893800614233348159033\\\n    1090571418494761369243861937184518765470150091304973155388646876156616712251700961448711188402\\\n    2566179416419187983406782625793396441738217498101288646649340522954131632137178863208048281225\\\n    9979193499094972153646943128363618361202934303572385704964302312065854755462123585060714586493\\\n    7422961373972894634065232493792088874994891531352029675115869917641262599046668715856496450795\\\n    4010048071369660093258675693422418998640151017174480616359035809166710663261649802899309642800\\\n    4045389927660998108605243347237831991824906890115802417790533930508874542309486174727652651965\\\n    5922711016453815711296910683784237262517801494864633390667439194418043296698125822858469092953\\\n    3863604312834139545875848648701463589077925736963547992475991617825915189677184938135420819745\\\n    7733449154679594641361317959703517995443685190537528724646491698636796772425533880290226552709\\\n    2577050077531045174509177723815424251073498553120055997305826532225703448833873481844421650095\\\n    0006756270529410020332189743392815599806841648901986223370943170728287903531130066442521536494\\\n    8827096717485447853053559416495472201568312123630034952332058647617245470752560505775215057483\\\n    4650122976714129580868234840121913801356323208034610662976809242653335403012773362614027150314\\\n    0189530497583338649762423557554671394309118932108347324984587644772689474065087092240571490943\\\n    2502647207399456800437297767517882679110585080525222542993477803774209493637353440418399652892\\\n    0793461539502116334252361616383723442580776502887207582325200405771333244991945578668511741056\\\n    7481291825364404279995468530730647737430581676271991627901155433278317801852683933845606210327\\\n    1953966803918208464951543546273978643564229576573834137304587675661719574066834725523603880625\\\n    6091867520306813534843083287766767612916703958505216295463689473216467914540911361858465375312\\\n    0600891982240231227123499088147597177935881528327554530828263468091077685959713397105713187088\\\n    1883642354945301406781191153923548453228426010288779537521221701311527205276271206873904488792\\\n    3244726522652144544235997714832165916968406022732134478615779656087638085500988397092041478199\\\n    5984952099757074175280467160681887248325938541368934571633197897584212037493050797720400678052\\\n    4000625396673951728594827232894749403585914084382049006698192757741268698803300163600172130113\\\n    0722458917991030241234502926161378865601115700539566835592104249806967171667814241557503650819\\\n    1135620868302339495636388502929861535641035900672570061580086290883436748441586359844706242703\\\n    8868803780302256352066005355016197306386264465873299780722996809966675757574529943899616389291\\\n    3408536136413182749216624519038795016353194865899585930185513697235878885212656650282380952150\\\n    6847827380057014769041753612704160348779942665179351826879597366865858165681292610584069952485\\\n    9293682992479288210667776756106884571204158564282763219585121748193881681333219229505699312812\\\n    8510050089398865220694474247518858428403699858771210401712557142777900540522651682586911545354\\\n    0239445801679823905613247416296560609187262624125630242900542486913723234890651921514973495410\\\n    7696686458011272961765039912463918044251097070425425566510917460823662325921581141249651732600\\\n    5365080793032589745028280070764530123037476725326825693176724894261312832720788526626200651833\\\n    8873144054486143488455053652684203717029347465344616645296345293044102786477263930698362388030\\\n    6836207699846448272889875442689371818143272478978665388016476235102587340535629223348102614548\\\n    6518154810357874888666816628226309261806028414506795827986990728895654705826051594836687075349\\\n    3217541813218720232664659041623722882798535099757792106230185995017326086567832470997405849732\\\n    3631580105155843707270782832940802363970391198664945903589719359854632167049310563458874067868\\\n    1005327997652753805849403016832032573486561033269632642242597445252252307939158896928926503857\\\n    4098673062690476744458743653223597829263124841500953397911473223478800421136180784284021578870\\\n    4440726024325957679419544362723040150393766866150596643556860273361247516563942530777491298947\\\n    7363841448552464688083108487432238118431708266852978718762636761588099400290171150698811929274\\\n    7975299132714946567780079276493114916643643864599508731563740391041212728809649867587905016419\\\n    7797118035069055972277059439231566333814376000229400188175049929303006566428165893932204268765\\\n    6763494763370780236259205563694227508607379156910559409009746182617353381004653189638290288670\\\n    4400338247000769759090864251857381239835509652860624063234172982751472311766941195524023976410\\\n    8978256004281461906273974065665749921015066101838009450191552508741675974470887351362239283581\\\n    1198530237844034354166992443897092866927827162007981384505927596736239119226128934907378291412\\\n    5457851074719552148916163004842708210725423551017305095150708773842600790703812462742681145205\\\n    1265558493437099593904559144402140424439112942027818512453623699537562167633568498008893087026\\\n    6176634771606001529938800797731508839602910421673021679821926356412989312337387744448581303302\\\n    9553180087915217834285952727927951253613102772689478145067213811430481817423315854461680392127\\\n    9126741520112849766352278387010302785309226754129119316920059511979306489582442723170768413437\\\n    1042466944147623091651088748283876628044997003680702864227320156366559147733056694788409933245\\\n    4022812943526314360880201730173450981068554909591117023829288243436301768020832384096501726643\\\n    1674136342011412603547189695236606375603395823910842216211183662728169980528533579976715940252\\\n    1842471084816692827894516527037323803877660746440559748455232665083506445698269488397325379723\\\n    8279188394409551738124657147027307828592701232817843236690150661593264652727829266282762300447\\\n    2253474328704146710671030409834199278425684659573656110662378946111771153633880151208740851354\\\n    1621866075766309208645606442633342573522422897499093926044220523618608224547040081219889107560\\\n    8160782192326226480599065424442494850365427134564563173550198372281343921824688542130514774488\\\n    0742374817616627237851033226441208175384482325131651587549680345877967885787819935219841708581\\\n    2363884613806477666280565124339424498012119250048019683661230716913492362063541064806937532434\\\n    6843779778166703726431094511275947717295921881819416112839996724378766597616593494109169233098\\\n    9106725995599113183896843263747439454288753194045918750230171596285752828245199173431202567510\\\n    7475203174844647181915524012791158259118214441993447741662165971022201225044780817520699820951\\\n    5932760749937945614943965199599944946124911101463199164427600847175812413671568804380625736566\\\n    7323873305494689307607984242175845127434989620109949174802847220041730583346246993261745741800\\\n    2326893492896193037648994899157904621924166576459011896750451669274371223347680356403819550968\\\n    5457701895074693186524830983695670460416008627118607095486147499780323118188228793853581862029\\\n    2699631728173905677313233157609996429485909103657489009205417956813865462914221269068429049171\\\n    4225817968641660661859524896038759903214074841215990335172884873802221268951143179847686616812\\\n    8900069153188924875418659188967026855007396953570714908296111256919072661410193016334537873637\\\n    0322997164940653037592585596294380975305511579289676621296791578278660717647734095806700270800\\\n    6487482913498228039542322931364982624441411870844664501455420525964015919412468125847403922019\\\n    4922134376011452706939464474933802344512827396457626333755431229315917279646244309576545331906\\\n    6800758807109396121334954748070240699299510144717702645926695309057611861690191888909647223772\\\n    4528356176445647144452509089212684822016939407225067831410329396417986766630996508229949106519\\\n    4782673425179882207262283019783990007929475236919734093824431781514281073042987286124062310769\\\n    6932400273973582779548126107189705722856020140709434767287199150165717442671670923517854699588\\\n    7852154019374960071206674933864700727840378358388385195865624800121596197738352784246346537761\\\n    8171124940504442146707379921717727564911725957482619748556731645511583867284472794965201556647\\\n    8616338695575542148277202030014320400755128514444234591264611827813449094603826852497435314442\\\n    8300231086163376684474912709934578798548093766682497338133380847786032916396823171026365975137\\\n    9960653496869828789089624645284828617919923549094039729944961819778210642096611612913535638880\\\n    7705331550930962039091088225929323109894644594185281618303598690922746725078148561379562572230\\\n    2605843782431432030542888542218663805733043757004470570969632168798205047219508953442711300733\\\n    7450757933312827546936240018704873598632957181666394596651630425105412034479293439657259522758\\\n    0319517626049621728040210600998104437890237807892890211192033089384312511766028794905379368397\\\n    2561591393913657869639198667115265693661327264321290741508799963615958389124773785794605364829\\\n    5921850516307731556733660632365565152040599447017481616174369790622538839037275742690134980721\\\n    7260614889395964710647311958039126635894883028443319117664916441252862569293191858732276536448\\\n    6558472729998423049444337559299771381346806993988627886008346734044317124814772636299297428528\\\n    1616907627362435506244496577557191488171148436844385752389407968014154392186896268899620577784\\\n    1215840750446980517277754331942308864277275473019541048455873322878822959532951255667714363909\\\n    3919746067667859323138533116074317026843768692474744867887909822669133601694515175344941148272\\\n    7458085338219489321473505672685318157464558963124970393396877908894684015502908680230859693335\\\n    3076989263283858364042372611454276203229685577025378924213722951058405907603369414288270344248\\\n    3968933526119958528188403679067629316677829237424286276467621863348981961115024091880422128664\\\n    7304047895145372812006619682603283673023414257956941892201462414423046410056439743897536561240\\\n    6297568844984834345283366380186523896625467327964939098585830819222656498980048113686506559920\\\n    0125261104962390782325721736438876636409427351075556886916043063669777384838516633346007280126\\\n    5512079617796473870928844121327636680125706279787981222365113294108686016887981107772455939817\\\n    5204349663843857272515884754789976011427678836184826841422402800177333823285589693278930126711\\\n    5653058807726933608403121428370596325897376307762379237559864621423052713559103946036272148701\\\n    2777807843809255510752531106290070783695705902877371595298948435504667925073306729021305602650\\\n    2198128886650761105968845517296213210117375904640084837301922987750597969594583595237076210608\\\n    9746271620880887076239332222983470241831527208503012049299627374597526793801619741603483208148\\\n    8832235974562239730543419752093575260741160907654687031029185299857730936516359906152677310762\\\n    5384756262305912021915446885090680026802601399341364619447991830168236344263323520187932259450\\\n    7324877796365264659264136355161624044327727938667781733295435780676921903170773253783721447165\\\n    6112956822051772451338218274288002676705177704991946987636096689110622344512746685781898268474\\\n    0169188657439233556332001723841354757210638000491711028451086505775551816923647725466141598691\\\n    3893273452424615069078363481053480250372810725005633806509438135945134092126918376130010331692\\\n    9121141974910912486289256992726212404652417631276357096290264906748167412101632128919931401397\\\n    9466946605604194250099865540267120466689331017022121984692286200534815211943959395271343533838\\\n    2060433013283040982031987577754402695483638790300227176521414195540851621768059940312624295090\\\n    8997635072512271413212482013887785710819252002485867576427893343133781181425030252961995636282\\\n    7460318522301731689035935850373251371950791456866924771278340647003327645897918744980984303812\\\n    5148246377558531289156794526481310040766294970000819837264820911734221440738683040382804924346\\\n    6872914813676906766663021267890697177728979373109033221432209669289237167704471783700269985075\\\n    7671393465914495676707456325249561422983044021495511063490842953743954990455555884312463341294\\\n    7359387074081969513494000347527890294990475789376933355931602909580696638896932035953186146264\\\n    3451671944260882731944052169064141850210589029122057905943807638038318239429100992585049388752\\\n    1965549161816787479400145429965142568415860252403387623454676097859440603111031863692477504058\\\n    6326107118804380257954536419394080948173905002257733728902392556372720547168873747447885323967\\\n    7674585189862892898822143608814569544862902711223267696497418649469167526153303725980587750366\\\n    9299878639531036300222067089840039038814242116213575258760629520998474199980231603830582344752\\\n    7405864847022719949795679517536530324251071186464076128738205384037912983801046746492766707737\\\n    1765994871630697323026302528409268451865699619822476078735366582368973244520561387953005536399\\\n    5969146587482417349683154241196834506790880092787223964667298840100401499293027526932931754234\\\n    6855396290432916763392620373170492370467174663594893757318322896727748737725983778294448850100\\\n    2298900199016539372760994879396476855560054639802521540618287622944175108692234123603642870374\\\n    5491632042606555674886138273442646477183327984605261755528746883238404346598254782035577070271\\\n    9878007255154868108884720634080724777158470245073361577765337369702447645098732690184871252576\\\n    0966249716744714901794415927487286568628597474070289908752089907988962752882214795602020042125\\\n    9524520421278988582352238913855031667742401066970809741047377362434985234006639802651240757858\\\n    5909330217729729874312584882800382086689652072735609181166871684435858051264188814162651000149\\\n    4422922542644523771992359721248626212070612516729453998847886925676347740032492177212658904522\\\n    5354956435962316960006341187178912690707787576137342135541107361852712907806628751406597553700\\\n    3862685431254137318809709554196974631171659851725925222707835945411477883528438061385133984585\\\n    6753052564852269193636750583323160274025070342404567238687424375804232305906117283995237128026\\\n    4832189796978490578813275178582727053164400514236166243592304797841755464291133578152435448231\\\n    5898617199545429180529509576364756623419094877906831691590534599544813641701078181585946126780\\\n    0229770511714268615458512782534703393865435362423487752013340874936616257759065386671658983049\\\n    8744479401132432973865080371817112696626958599217786667944514722787511894044528709488717169124\\\n    4462012769439321053218469001958573070829885538403563214439796187601793460486870803565181930496\\\n    0606772662908171714977201426501853171874915030045962091807255169229700387832162496930319256806\\\n    6173576939133455003800792287969860160414277724324558359372554400616260260763300050748904894869\\\n    2992748921258897950776675447971159705371451384548669310065291317516587990044983593776838597243\\\n    8422653463350367126157438723459093587080599034278354585704020408003988875205544103392956369890\\\n    9388865498656530767073316969300784687136228307656128495680295204881132961877692921325847851920\\\n    6970515966500599015864215083235072285467678946035812788258531781321420623947520359521057771799\\\n    7378399621741975163494640445518843791430187063682492691540419155575440249095589917785545469675\\\n    6551997664091790475434547119229795894233715617760656973984210528020393207965104949740619614836\\\n    8783500525053357829641593209114113922300845257543272420005272829627092409922600865010443075977\\\n    3740790620821427566491153269660325155874224574117640100885498130403763604412838140535454437466\\\n    9908140658601587375155649851828140707686526915358651733395635504073429632068836853660816860128\\\n    8094365724305146961873369827516309296051413093345381015352172652397999800630576678901017469218\\\n    5601707000364039307218316317648742066766445631157493974086895597071936196234380218352014233230\\\n    8237511105578078178208264000409006608958134475560674056060296714487360722201155349815889205252\\\n    2623786285227872376719010683435309800390963861066866210666670276918603308961410272987695665402\\\n    4089012462972449797518986930479723240619331034841602930018711995485751083114914179598082276577\\\n    9061032645745445606243972280434722624058825297143704800093321173901981936787398696178924283819\\\n    7660200113540703548939363314545853240200461786471219899769485823598621869759538441012675363043\\\n    2184631726205840784751379752767310688176712147081666797701962416719364100398362334499397244610\\\n    4152002723413081551755641305555011011564142552211763352599942271804917250259893858952987678486\\\n    8252133271638419025525450009293451405852632747934368332903712700167984690132355241944743677129\\\n    1686583757956058524612932491479088604957151676504949782198153791115701887731557715829453783997\\\n    7147152743719431311248975800617252651318684118841805138341798624323669236884595760024227612388\\\n    8990451452269614955130495277966681360539560797989854622318213348267077474401617395679258205700\\\n    2115456164370618454146999220001104357507801154842816794312967552582003094111526141715802476063\\\n    6266983952990540038042609102580335325885312132307960003444004930804401979567798044696624901841\\\n    5530435544595521527556815427813056610070803004033621171610792514259795138123452939459126097210\\\n    0893131067757211363443886289720643110384169252278435796160753540205654313456299473540795903368\\\n    2764509582336702234783537639888878742784561723845722186703121768127144459181390521205002369139\\\n    2181529701465067413425663466858901849051766746256278249582980369233909903516007121114462246129\\\n    3095836816267456779944158562412731274358106850295232334889183568033581205640693900494184360545\\\n    7821199003398132967552741459192645311190626524224300826685444954845898276686983896666707435824\\\n    9202201432691586647902110613735542744739044330510248335135738782476803614449067130176821673972\\\n    2471920867232370397942993385506349858080414785924764385850258531838007682875397419226793451785\\\n    6379695518657983477982940683278982717498564214892547408443538587496610585975765749068631183116\\\n    7221202062285180830091278706764258287122675249162151788016318498570197307873421454339847339071\\\n    1687875501038004238786109953825735420701993506528972376582324697853266917372192529091660862809\\\n    3032368871385010983867337545977771302845648422382560655070471106695550526062427173736541245465\\\n    9437182982125819245235958695595871697155736520698507353727116214148452540119341793530765700718\\\n    6216682908274881369218781621660569051961804759447927010307830688807306969418151925038923011711\\\n    7662371926853601070168965255892084913917950907971700911257757280551148542342757309628518775309\\\n    8973318868052652000465605107773685184093425987621771670324111380416925581290389030435054706089\\\n    6346595099609006893933997188670206099471760358812938497655872855191834837584434778319761830581\\\n    2515121401424250457218503690180782689630115925804818597686904248128340826941328930205393474391\\\n    6330483461993073587191542805620044017893295199904468215251285269141174208672418864055775038597\\\n    3368375716336346334015821268471381814502702466930763837185621384319048289217065847283169946788\\\n    2948442708519929752514378601596330622247306542173744012139697499024519157790373825097077364294\\\n    2479079333350594603407208095200816882292881427296692556433920429669671295176547529366978653641\\\n    3642431634498976315750607637353301372787109868756100074387174826973284606685457567872328953509\\\n    5464810458761025189510368310874112381096971389178797621449568115876223684720888376380552498247\\\n    0587735378107636003606340717161251780417241205084399572308520424305008799797644508853177995376\\\n    2405790328290222564810253367458238341343554949285360232579329193714393841537418675844427214280\\\n    6407380085860818541095861583518667584376339745934815450230312938028931451748584344449220898016\\\n    8194067838801553784618866770362840900884435190583901561915347282534389690381320736095115674563\\\n    9607920135398690328902042207042910116495362609116882966516724859226139353311973546786995611511\\\n    1115416325455763242138735203753517037509177339212147102414954701184276848214808222536917126757\\\n    5600103846288105881335034449073896928713923564631635656184322150789878443870347752001652765649\\\n    4793414649195820748718386755516608640170937667382346246907795931637452840477666796888349502434\\\n    0322405952450269656182743863779098878181374184394664258212242675353384035513417654333409883637\\\n    9912836800547398213094543311010856620714247744708387487663176732540480620629455038859071176203\\\n    9291258185702972339368544006848364705467544709816483346649071852071734847636527038473120022487\\\n    2247058009166750798713465002705652727715071804152318646016435402744342105003352762846624211066\\\n    9894908194151922895419859552612976989287064997323236653311612067213162209312437422799611491975\\\n    6455931172020765987431823479437168959586854967907014535656458842667439657135669803665831789257\\\n    3560422858514215677991174759930948000488943309448626993808051264488536046344701670534949788948\\\n    5267850482898937445407931234439628857473098353913004946500532796235612851755885004674423297215\\\n    7304752241297696497449852657711781313395683486263704956758381232617073689270739670874643401350\\\n    1203857203284802590264385295270350533323803212861577835395812200252073045390490951588817509680\\\n    4793781970529508761345378122915184347018868812136152304172461211451066610037911506945886614455\\\n    3395618967027510391944150598216545089768687279742955450509996926017878081714498567680648562313\\\n    8003019080106469571144190022552955072810770873311182379325894209390486774337862727546673711529\\\n    5111886784986067658943292334168488961759944114847098422182577337938018267678952278367139939416\\\n    5786382969813674442850842836180787261457152893642751030814161994732687400268465248697417398378\\\n    6398315672099334563666682518860927637946101570117249200477511725177894857596971743694506359430\\\n    2514883525739054109127840782550811496360554557853436551020666313605158386164705166956001430831\\\n    4609948117165526160015895347780617594113330007291831404548082568196153805159400959367892466195\\\n    6610892018760399817608492455096541219729197535984033054416930258100385967634769398597721223141\\\n    2117468048836573831767790945321587032348098517338678324730188311649010842660255323872377009650\\\n    0698641695510093742310019849907717837735329166613581441768703739315319692285984058255117024888\\\n    4661642916923663583971061788287432832184850201696124519418698815002367255213132479277517012713\\\n    2548799329415014684352329944693553664366791526022978268249981682732472494973014018230446546024\\\n    3715941182793368465398326144315432107916345170675119333393773113652055228713606833978643231645\\\n    8492981241836385795534714556813194149965329516896515222507793677133712004461550677965947424329\\\n    7011469362152277542407901278487007509569751356163116417637460384711815370733798651793558497502\\\n    0368040001850841933085252137348832521235617617696993796461392554900514078402594641007651618602\\\n    9151717504669775062719223411618474769453939612972949463918517554030470723863559843421345542553\\\n    9304576100521202297093110439191029364282909274855958142244581098994878028112627230269455041535\\\n    3218627061753215456077134111189341913601718675630428797152510258144611370981902716611648392471\\\n    3291247895924558763936839760813546714000242843906603348697964192713884906558892659432388505548\\\n    2372441850881118009874833136714585046773443433184107563323066115998417586780684453873472372870\\\n    7101810086585512372409962016622379617485714233053772799295937816756799147381506353446529842913\\\n    4481461614289575197753771348903580734699826891567972465193893369511103525124541572794580846556\\\n    3287668116455349941635495568003914685252334167579862406348104212911827191019814553776395832280\\\n    2868025153917121936233067761999967784890505120835225635869674228045359761873433965079184935022\\\n    8137561282826170567603923605930038402536335059813085885400433442576115973037743108421553279315\\\n    1452157746205010703439330961570146288190796231638981089046211369521243888063428926791688519014\\\n    8194189864959813903901258347028395962983715425667480627604219809614953357656108121770464108030\\\n    1192852007630432249254038582133801458413050477523321807882406716231616477146184356832283224338\\\n    6980406233917938233519469133866911343112706306310558809141316361594129544464392379792116919405\\\n    1860196978231018724237572621947842033788735950233816751595864692722753610209327966658666621828\\\n    2855112788779095447954682582284932775350232066393192569220609216501037673708797466894406796716\\\n    0649371660554718762661612747811272821638379767349477117815289300096388150125645447321946946975\\\n    0811904372152781597410937140270468223553872821348460459731828969786084664360053086701136791074\\\n    3284992367355548269788329853851703262364647026294652425447453710141748474828258835948734269891\\\n    3262993626724944904665084240980427740682954490480217054404250259761547229782422146373534313764\\\n    0186930948593738346983920980036383081426308494445417425503640302338792493560406424866106783473\\\n    4848471021829477083679328909553820588078079394447844355408575953524807323755166894894450480258\\\n    4567287063980555769575937844496179984159024871143308255518262702673301080009514793699482134030\\\n    2533650909684055480210946888998869604921004104351664957867363798700810451746787716831747576881\\\n    7606999922718505031560140227640476198567337514545745192667115439604736419580932750857687726195\\\n    1408422112991068281838831190019483188813679101901109812916544507355849778041218487672079737964\\\n    3173493885123710163672973365447195303767361746445010960052624092878604927564407296295951046723\\\n    6184219903297498081651568661941908059334948679424545235187992133374675916358299115816789161552\\\n    4826499052184406238113652083198289034159658046172355090955395265827930752638469062938250233733\\\n    7060548084797017714700484481543333126259626333655975657477451552064267123364313201957581770899\\\n    8828900078173170006993052149986384695195625097120591166338724299267841817727277063190312456295\\\n    7637536905233007283673990590435116750525437198866738093027704291913394321246025137848955291407\\\n    6938722365084254481965359596523700894291504871019474559706249035309439620834907629145314296797\\\n    8974009394323082508283650249515875711568080550608449077289313347347421879004607506071766909380\\\n    1720383184412853438784141237617609441187944687573423621565224828014245603891301447740051692660\\\n    6038008378581776196043948657372095931252978613058443323221992150491993558989524726461226465225\\\n    7425868277984346021927752386035275280085781874578479083812943628246763314828533352344938859129\\\n    6133943357303055262575299095227351592527643690371607908433876497085762339364644404591745096516\\\n    0623311492176051789339455510662464286130704606503280318679678637223648170781236228376300993985\\\n    8184667480277900881360330657268427729491457781925378652691046346619141461231986195667935743617\\\n    4827966788954499520581398625806543972146373706135016509592488685619094383109873945197952157029\\\n    8708474859143123346655397552588001017086114106948124600788456652458931246272108865963905281810\\\n    4559632448552776901776848499596168908441303082703284902356041533418840198908686453438512440524\\\n    2523565168133099898169161382034063261421763208293167336897321285511095229907176797425230410008\\\n    0192821774036054245649957604943486982132276541830282104105365181350407267397512144135438079428\\\n    7168651003500926740088540381880574993332762703727050127223473425218018046307169688436574673326\\\n    1468888877567104136181623988510717921024385648574259500818172713838931553321251848254620258387\\\n    3541694469387104773303268910566859332162042185218944864919004415385422382073696476079670329134\\\n    0933995000084025091975739412974177572060319089559978959922076437332360754880733755246829546468\\\n    2081115746348591694059533582557921608222974446012836112799284613460403512731703740733625874854\\\n    9824465331192220391380227780706872843278410355265327938368780776890208378935794184423200373048\\\n    6172636855351172773195438423623755423047038904168535583732023261113519145606416141201616543282\\\n    8558526504684500215628950518464115068363926403439286154542547936838129489628374795574657163228\\\n    4949152703260468916072142613598657199358520392019119415473300177354034594416035094547584737808\\\n    1846918427522152483760841232655580658537315848505079706857124968332931736583516057068414319906\\\n    8953950940971071960886015754346753903293061371445442297157283234540271889082736572899644596962\\\n    6104905986362135384682673631417030098247398601040598427495295505044184876091242134713666080250\\\n    8387799287757771457662534526434712113652529874677749764435598696389295360336271232638226270563\\\n    8512208146183212379768628181070624181472982052016565224838549319366918958733166458035805803609\\\n    2574663636831081758531885425731579327764320527905065305809271132034842606224124651490539966331\\\n    8889985130350973812607587857217477615118305551893168151549912164213876486727516952842715315005\\\n    6283274313243839400896268534115965368030962790512042874945040964128066013091793765605574074383\\\n    0638836343328780899119313856328028927219544604353166367170303111384719872097832746612481668298\\\n    1073263852684442413714816147805187980655133123041438100629817422524596943760271894759155885847\\\n    5679829230363959788483255574075440970381714553989492739017939453799874811265516450387068707906\\\n    3313517757407843428434877772854074913908176488618718447754613910702772780343927218105868225704\\\n    7217345495835920146381484382631872533990911102092290354305416195849264633272544582310004693175\\\n    3864110740392987585304980311721368356033683348454771393349709182096401546044855740172957768838\\\n    4489299140139789241775028556062153151363070585898090526111356956851579629247539408306827683172\\\n    6725883432167577538227744375964340698278018238051700460041003724390883928923629997918542245620\\\n    6706023501755630362500496325241034641322908707331450203433401898105726167380639450687971476917\\\n    7542804571137366464510945964658266204146845263924520194950967085935561098734621731108050203240\\\n    8482380620795397192440724835663238907411719923165742485499162768450867532835509770150437051657\\\n    5707184565074442366272632369036978028321216925026150194977733686269486802996730295595170487206\\\n    6337350270401470826439176133972579717493399379857306388734875847429351823314913989172575027703\\\n    2195126155562341007634444730991478113198546877756625379735203403527223580826046978410222355821\\\n    8861020292080031160154517974264777802059317795803649868467146560147495226674113692757845644990\\\n    5984895053197210359021385661962043651617866402716275067882153501245763054596114929085289591677\\\n    4504740233513630884973768106508353515588131379405657498006347238330985430511148293500641622000\\\n    5618857271258148849262199846033564570211176571375916011851649545797612056963366607240788524860\\\n    5304489646799688443883061460918942709948308992018737256409589843998916063023844979993828527798\\\n    1999293767223385497727950763291364899941159711888861255759029154828454723160991068479660413327\\\n    5929084061381359872531254074562625271248522946803385184707096554557722090935979407827032409425\\\n    9132610368050957757563840094895561959456405947194678106967021745878193634042901082508721931429\\\n    8206510711482911042000462280858339405922334189423412063175033799839311997663221074285612247379\\\n    4396279808904056417351028920201359329730350514253249312708805251371504454864428250474020942749\\\n    7833417062858073245029601673119635835952232602934911869859153123543650700755399952252392894364\\\n    2879962821984210106202471463633113943975535462505836914402539635587092494714222025450937725082\\\n    7644800648355700966668808768593178032218685430475929037722338461832707222104673908232465444059\\\n    1024895920505958848629618613671737491927328208894848299369234545329164898610518448439692816360\\\n    8386206587183809891584738901631401968055330201910789579776724431326772146998901590623791085882\\\n    1287736975471617603793171269735889515425420545611357652137787672386846088990127394696171839506\\\n    9683134228161109093350771681308069699193919055712310485422830047481656791741842654762646339223\\\n    4852395453826828551883921947386513532764859235883414071012600057972957491218663089458789783911\\\n    8859736992386958652752966702561953957369557336531607168975506967511581283482759584071493699152\\\n    1605470198482830874232124119010015778864199656349903810705744953893801029343159424507298307106\\\n    6265505630037863479074856259338120526201339625056689256642542122316285400605777422916101015244\\\n    9542982427507645799404396542183318484622060403209121110426594396314520816210130419251527844804\\\n    8855379136865560461600087280438821376708051065138873312375413154311483728609966585686538018170\\\n    3178638584217780709141410357667745052467753073359485277117541984374776590924490559245440994525\\\n    1330877282778658568374214080477364238666477049369056146856210279361298627050974530697994429222\\\n    3997311151641757290467606964841495729782900391257724641685956767818913191667921344829057153308\\\n    3325382055231376133240959667242770294595729817147646127880394400044015221654740919148957118971\\\n    4503057638151854981316324046285336706578159792495732915330699780409399143167795818371272877384\\\n    0005238045650272436859994882200404271440148824464244564997600381109774396036645386801878697807\\\n    1268274290038945777800588714660284921749381214594659730445257127343390697160162801898767939731\\\n    2551909314599378766713726356228609137986701938127172203342295748381704916320408439107496440027\\\n    2093433979848697457547746296493495074543300215801404855998437566884985233938750476633954514845\\\n    6732172132337629796479346968140019388170180802327959608265087564950859877004844119878954499034\\\n    1944585217830944676701996811345113557715125372929373651972455260804129520494721455392070533334\\\n    5779946256999774562730166431177268580245349411494401905304712844527172979934549170922874155482\\\n    6068427537816733840444279356515265537741019795208898455771880015255281659074943107095315445326\\\n    6899920897659021675080773142800009276306043153172578447962721601158140298429543548920900507601\\\n    2685419158495580923328423129887053185889178323430098971718369809301060935838736832236427557784\\\n    9857009388134154239032903235054131368980518311799012239050340906385328157030458681705460642884\\\n    0977957260031954877317768182021607033781131815022440292652884303636499127085642586709006359619\\\n    2211196842448947518076697127312846907391729666384632339531367507703165300222612893195842912492\\\n    0454593367154513663955272482431071391702965761124091469120773383039525129387814559932957950431\\\n    1375800831287093192561247424797759891841733607885042683644300067341407251705099811881710182490\\\n    5689280643658642467014021530871735477538648117033998269804807797028767219874017329260340336394\\\n    4219113046893204628509531196890797289693848753918260211224173376944487362802071781207255273081\\\n    8122377924941533783568686669426096979680085122787078419904404710342691742910593451319711323989\\\n    4661891103971744066967140722426857316449377883846460727279719520925870613695760915402295079101\\\n    9895861243645573504010836469618622919775947326597098725918328877349768812117199500761805583561\\\n    1866941338426361346949249814064993065343858638274724475916195883307348588258725260979794728134\\\n    3451010979443363922159782091363454812850196270531325795417750379005590864231681520732827443898\\\n    4840560909481517056844985847228010596025447922709851133765071787766209969309245142668892815618\\\n    6096802839996418548974982699624340435977960496138709073404313051596510617298719286719006178749\\\n    8227798051208695360146429673545058606058439096500915732430190097529033749342304752005284987063\\\n    3133135714587726694000151933810330652630443957995292794979101121963571147095683078228635477156\\\n    3964377518564438630851020877319631571702323737550818088323942472421364236074141386189301963764\\\n    8988904940595886616701938901827061703057662804080097420486445519518666928252904076625878315360\\\n    2272426811619528989454433876165516531495437025657382082093839434319562655734797245883901400174\\\n    3843544466408628865523901219482225502532994149056923430315964243105118505990198769814076936663\\\n    6934577536936768908371062023850974191256488268698197240801978320034389843914867168237695795468\\\n    6210728484672309470653901587531947528601782068150705193590341105809537249950986515855374083071\\\n    5211191636344876733449694228730441766515005782966888595564541644041381669348455589527195264817\\\n    0174625474303283040327359040229781806022080997051457530660930253877030687528014136933395294087\\\n    0284394973153117731624245901372810250372187106338182907987013182000910246292269172765235343335\\\n    6510239439641112291987375779458726524792330486755805425181629164752068879169546149507206458882\\\n    4610237766443946072532433458001017699932365806096939932740266942272855441389216777329728034642\\\n    5577466884262840027701302874681838692839493040597858831038950282807632554635731064898594604952\\\n    5123871665551266903690144196733646972315886665692179123650729468642046222612814993414705395864\\\n    7099039857862939827481656022476725437398890351426298372171447034400943618527533851405786052601\\\n    7495221034371012038247535401093496480629395336096125239498610288640249290880617795039540012041\\\n    0660651068184156209453369137783617048609681441919934248286642528527645930520528738795586908704\\\n    6933733291352013370095958715585438946514544496084700623345501038367252612244781567929382972308\\\n    5899803817336877870090321730253141630040287455345591058741805977077910003096767831372109130408\\\n    2139054083851422051032374315578943646075054993381422762713368655736049779399749129036691548017\\\n    2689475056040540551564449636500774973682228644623400301965541482005477662273405264235111558972\\\n    5435399146976191380531293191152875608652808473300775514786149281958917454243119362630005749914\\\n    0406056654166822020102282481389884113545433092907775860704303691216663295274509619206471119051\\\n    0070740603321012013633630341158234008500170457563764730092683720510688385350215099598882414605\\\n    5869564643078146634142097470721658612755048380452185121046058418459585213999921847652609770877\\\n    0233729326059063680389910257582550570883968623315346771705151415141828386328243604976372837153\\\n    8392177564327083794015855779866040462041162170361628336203972792158380501690192633943173024383\\\n    5662848538979858005751190902384402254081509622621551330152797559409539943226800092552565060210\\\n    1998051246559302023614226861701676249519956052317215472188452463976196761050919091947005936344\\\n    0191999394986229260839611329840966045225554329051034253719165053817154645038956373592330882162\\\n    4796530424966978682756202335613667212261516642716240516751451501402640098800699781906982827047\\\n    6366253225254683213381684038033614162022983279839407671467930257579475183359363227689860722007\\\n    8182123357105308238643807822745346494964502731476244959684306486654715738928581590869097949396\\\n    5087148681533899919432361910711181837737825897427397457006957868200183686848912279493764890102\\\n    9535031701072341441773719990248017400162017257250406061560048318565749569728591464882576136327\\\n    0538003290305787019394615629905676464876057717048748428608081036336050345852607262103407008286\\\n    9412727260356402433520873111674008364200681796576214544383682530933218261479664478325964419501\\\n    0335524099110379792001278767392593845252275334247578254076467639084610511271358876058351911944\\\n    7196530392571728565466755231933717724508700199675921562144378882290736315285377066661781283214\\\n    6444409320966922215492285680700846168270056375085237352285510579411537587354623041287103471172\\\n    8921448613182581000173916878625378078205122521322282867028920074431349417143003403277550091590\\\n    5481764814884504650692776719892844857353847053750758303695618015110746368045134199536877982872\\\n    4791864924610648715587598549321943941744594749200329538737095661129936337793322159776009870070\\\n    2403047826462920914734048464211596804090383229459155204418373833571390535441956673887908833568\\\n    0906566435857923036688348091776580327658739303719339078953611057732061257833711767504615982195\\\n    3757804091686575885565359842318650487340591277486604492684346917948467457478589778827877357500\\\n    7469431779230420442723982865458538750755049242919560094026676399051819433684796042846350837297\\\n    2716765211798297940593943838660986190726204877813281758913573088893194999867189902553869896081\\\n    2631927471209847995730364558485689264814551792142190269095889096145059455001953060241871089737\\\n    6611042620962934382135225179161298265437497469724638559095548784697090319269201789117368745582\\\n    0312920571336374370203964451018149523146838125762661873598844075967119491351551047662812726645\\\n    0799261184919036277825135214448812678013180865023516947008751949471409051091100649971713440548\\\n    1355473997970568903229807599480159486939481071278938184194717617422046974933949599824313269055\\\n    7670823329789973677650036873932767358068502974665329934921683734113102193457599041634809666690\\\n    8928163883553087218947175678056024168291778703609220499700059419252288619966377595296867593059\\\n    7142273497954660577011794908342189130535809800781299291903659415739752246286219074513216694054\\\n    6867560830979283034804917636890540348965302990384934960244156540830892338773896763460215490307\\\n    1688053048070494761970323821819185970822812858058189272745478931819601511512073017771492612618\\\n    7718380158818297751861490305707010453166684456987871736474120938741163989823526213138463979343\\\n    6482132402861344728888259150014883381914533750493699056866910214995523184785237275377445217623\\\n    1724444623742528153291520882244239788737607960253013990090551792489510914376411427268257848959\\\n    8771475020079504717682128220836465877042139608930556286617083369535535560147143152694477425683\\\n    5372956562722512666651319174587839870669192402610095385308333329326455587136817320910037610382\\\n    6678660294432186072028309135610985986436523512482104271219105268243770986728436573225961954950\\\n    4890058515678887885967813274598964679989338388789514456701982665467174663139811582838531109104\\\n    5363178119269452694836823566781390671178333310448901795969694211229992912757049595055209089162\\\n    8526944858303171399019148389472127250749167640066083505131659629210725069401509434315351726338\\\n    0115919734320383469630106526158645423173073716863358141851336392633299390081288102212116432480\\\n    6539251727213047820989547053192992352782767506060047445905626238706416510001326844154019554739\\\n    4279890288384267456942909335464382139535550557495548881030703433406301320716730662325652492367\\\n    0078093482917254688527189715911228383594001311236080994727102747518978333674600092086152894910\\\n    9312666390284271714603051612210516320004820355862327533217877734420005958184608251564919033650\\\n    6440709622669848086836870670251840433866321022876170204970377382471122094402189429970113233373\\\n    4246428713141177312769862827662919964223634314920935008652054801383081023175699961956421308044\\\n    5266368158520569915532231094212926362380826440207354076056963277557700423191995040030997008502\\\n    7500124080895161950106026763356292109863323597178307887533770644482718648247359548240868430198\\\n    2562442975952133092313617547367594774349849488963932618088255199020951252390090508747468771874\\\n    7188180650088644830696674123130974082554011154775018204233627678621751306459529302219438003539\\\n    3026367304677053763701451236233225646036510172947945556846118412782730833363463765408201967669\\\n    7480472252954350738213880032470435556721908093782371716792254522063768341950646870639514085023\\\n    8194113692042347579568417938121588364690701113250382592042867348135590581339089446143405880432\\\n    7514890096647129120959323152056232968154611833327811472972897215756920821910173842333098687783\\\n    4207499584024654738217522670934996777953642240561315502573355490947437241009864716463767976577\\\n    7906910953173799339781971067691547847499402782120593128366790925208463547505595402216468925093\\\n    1673461670093671028971655866823577900677521310642051802832397382203717336873528498298950049340\\\n    1677099561669279153193078179663586162122801759596932174972689935806523231665488159691154046308\\\n    6319395382852750074878910712741684904707885619286326522386337875408506606915561074003701678157\\\n    1479233795297163900135576624863295723438457179675779098857808052775557843527555220591226729316\\\n    2747863361126444212811249133897655791073784576142046725655618176962736556040200060089707431727\\\n    6581420388970528103367821943556340424162511244714966884757638684535603638548710201425288928370\\\n    7779491217477416587312063206389167811778663482376847112550015698632102083508881373574566258722\\\n    3947231585756929220447252140683262846214323875366924985890184814254727861040531880792787746721\\\n    2662305832423805854074582673880013012848887775824699015988682678380322129218091943311278941721\\\n    2188920141936511953860891966924165029463117432495811128022137006022350661316887044952980630290\\\n    0134169740901426768012989706114383285810032377929902177161413814816225615878702769452816350630\\\n    0048492049997413080076327333008884893741480221165491345759379990498968962062040119462471193976\\\n    5290243661102547965118012803560120811106923394790641726093857445214970828329723498873178034645\\\n    4996524265261577606551150728589362369238812403602572390056131989417925786348441922833738893186\\\n    4610697680578580489887552327036907257439569837376730129388052839296287705395677512087854773907\\\n    8336809908309687531384852951765084246988422277734012690768316479756728567338166823704849826686\\\n    1002960934221349393367339946535693483952379572565474609473257627183733708614638549500865608635\\\n    0668318635088593259785054637744927770334162583081292192455501347049785882432026737394749789200\\\n    0279542377966757283885333134183643517934866401546459140820889190377846073910752647938299344360\\\n    2986807459167728792223642993128843339600605539660675761429443661652409941821714657010121840419\\\n    7931691323987329583444029874780744522983136630944300417441603643261518324451413590543148261310\\\n    1596278658168918879470025262440540151735194440353784454143950202404692511417298081781956664383\\\n    2925099813782280784004237121967657398399491950625627427396124919226776112660142693883019514290\\\n    4363117852570965422659077707454638042764785019334429195833817297932210248932227012148974101967\\\n    3609021622576576906251254391518360185058774956390160997571206459149026829780157171154416545697\\\n    9951653446720723226804522344576097618889730956905139660225183687858532402769602922966697562956\\\n    8357606133097323863496018874173968014289567447359846901423992383767066962838178001968207084069\\\n    5898106723154801194563495163460691973465898013895168264204861163244284416988037459727611090186\\\n    7770445284284471783448177030865309545064274795044963213631143272663904645598024513033510878537\\\n    1320176712453381229943645312510384344535466682079211748980684064316701567010129972279982309163\\\n    6451698269895876414281153246486325895002868768368834748683986477562270094885724281919724429354\\\n    1775923201547904225593277381142589034420119223209202057099052535455349428941569770075278563884\\\n    5487648200639831929895794596234839926585491322168943911032276759673781855917897798901742396411\\\n    0871926623825814592337097746571055021171831661538958838291668847903559349984612578650859393668\\\n    6613841811712605750528836955844582461187421974085564277514247482026242261537062450303712454473\\\n    7969237722229046702042413431746485134303565031187251870809292787897530320690116469430711839204\\\n    6785092742582238496350989632452048892121310783696380623876732569283815802544851310579000122597\\\n    5922354350880011516034836162434965464053784296189987861513888554146501183229560587873547134403\\\n    4957122649581252317362622560898055159930805294252175272726507560078522248042187283878906347319\\\n    9320654283906371547117141232513824211624318048904085970053809242758097330449658355853935196990\\\n    9175972981809793253771073449988567209992860885844953755677620791076894049250609255588895684312\\\n    6770392289846700287848310825189241938484157570501332620179989374030579866145070996698853216438\\\n    6147614476977678818620481262840152986526763559244748806786330327484688126100895828945365597522\\\n    9134709272523854688978359630624892380740772383873010773334962705446410407277686963235451330397\\\n    2771134223310544251871924914713709047394796025443869407943787006111018174084469453628588484830\\\n    7376940470680361685082495075904477395624523026830493357745500952368089176666431249024582384339\\\n    0814693956039745794229599198724448544050595575799269025934491934731016147075911944336960036528\\\n    9416755441368204254719240503424599243234151223215316523506908585980381611584517717411808531683\\\n    5012160416528621489334212906892903610503807413673321703380123492453357950866598882505403164651\\\n    7937645916067380990953251384545512874459491460013125410465754208708381871863986934961913134040\\\n    9236415230403869858461773392386171784896548981284120966015723448467107646370137971089645079552\\\n    1284926428430751012902861617897756814755270426204356803609561050668734011674798153151600607653\\\n    1677739370045495731072856533520449484541658611824715784617066101072890302700962371443379436636\\\n    4944376148568676254972174760775128056422000594456094580990931964154498724899313980025319212287\\\n    8912679789840348776890311535169443639842858892389011201132591477490340603736298932531526881643\\\n    9839249277971407489632531295943224397850429351885960190393990631837220336513906930715422346999\\\n    2568853438020337509785346541672079975249030778532020291450966089359276139887633828637967225416\\\n    4271080456495577668901814989484416880685695484925902782601935972607876839680387931898164166619\\\n    8702149359456185751385100186706832197856600651447224649681851341681406184135241060056004302781\\\n    7924057125565166565047038883518196030000831249664403684908949255213302536530965988254995773423\\\n    8315965566837597393082061564126246937758219928143758746428125720088932462096135060162709550592\\\n    9854166142549448698581815083517264266876718336095601829433150535457680474088179993011463059397\\\n    7996785815073312683401485904208156713002063660507266571449633670516632323154230711325990837485\\\n    7699700665361559438747251850952764795728379531483122900856153763546730721605124913018283903978\\\n    4824146985401873088676430499666876359412565619781635012091837973482389970751962230703216326937\\\n    1986892082329730957984978249807985109972412189117911687877533236745932581608759051680370048353\\\n    4289366249574997500063848143117416755305097016221834351682262942926715718067892668224043228339\\\n    2602061649949933343398478533821606616819442345712817214291795114255288370015444195665542366057\\\n    0365603344505265015210946691716723342632254008796530499803943761097767620660450451810737559637\\\n    2666105030884797128936282978316651308450315602467818010201629460513495091875928187900981830081\\\n    1582832026531011672835833341569689879084171515346324560335230691700381806715794350676165138949\\\n    8734735553208930891169938830600662201745840898205444669877960652787119819222179693727802198500\\\n    6669888896947535072980489183564329038727614736365236818138512278156765384785547597092680313407\\\n    2461782978426789804224548417257774392593236646015861703922296366739639960122395683264981826954\\\n    2595159119509369711533304727084351796168816267330979084751106917529203445225072690956131805602\\\n    6243107659933039706333027735839805011405089786905023848030284233489935129034743068104815107967\\\n    0194324484397734179278178506495533695704045636771310891091993727036502716801143858890329852145\\\n    3520840757319759810428071604624197913512190486986147866694551929176377162831999302173454362446\\\n    3833539857651511050653463714395466415898531109862506189012258186212171404346627839742874426418\\\n    8437094800465145467180598701530702405709232652013530817151486578113943983919861985321352572378\\\n    2214885519099969050325320942981995803210048391267848329448045007132107394502315759976665962061\\\n    1399652437825631638899546575500922677643029086074381989981298626386577419149109990695606570072\\\n    2678557329115473272100061294059011956104612253465022757823026002080525633305042481981810585337\\\n    7789174587446432408532225780945567097053199754582849638403879567021894116493962520607029536470\\\n    3164206345415169354167309064182326997042166635585599093834064921437591907512097194229011456847\\\n    9117919203699485064632752380055874896944141570890830920580072632658041146938954627096451426731\\\n    5700861097550519966342321981196913891150314916077477621101771244876396491179334793040590911925\\\n    2772745958422840752875616274570245525347944933866449306288855857387622289025542845599067396659\\\n    0088901534054384079777458298840495229686299795182465403192151836881247388408400055241234520358\\\n    4171133513771507833789891533238023730549706840670445397517961228346350102552252564378552270522\\\n    6110395098189918193146564948569727497026386978484029680713843438752479478909648032740636873624\\\n    0298425432609054733803096010277003624798152960751397692412952477336877866722487525401324369303\\\n    0930474259801722364803473621522593472612472279246143710928256851864118635310419444055869540129\\\n    2695935745533422110621347737359973888263244569544110494802298243544261594976242901792888870513\\\n    1742139912114583833097937879214367099101249735939371627254286947080629099112934104395001354535\\\n    0113151272084974254125622934391754467937982150693845178324850493024603041370609575566465349739\\\n    4056695125940709155031897046322910700439357848129268703627676732595489508815277523404371829975\\\n    7738100327658607129219015852322428246182215636116863502677419612669787953914096454295275400660\\\n    4910052905705907519633576101737324345723285307238058740301763807868175179915005578701783719486\\\n    1634126918080843568049829999949423884221719182837703370518107079248256601761848032016424578270\\\n    8964265996028227218776836919652607961285399844947357490184448514807192854864029202031815899233\\\n    9718199915111125258679214018496348323359134907992577162081535461666826449900115961967764824950\\\n    2335784218748594362894247251463022719723138046686821160092642511874693533662294261392121180366\\\n    9428557595917798800827163896646833668604914147493235869889652304176032295667999201526607984481\\\n    2094547118328866219834312993664987745533414955509694432045077617790654416269921686710620446511\\\n    6804012602395142130424551578214966318580237860229290116961244676126288838375586131763607125071\\\n    2911997717865566008515880718894815108232591818648444109256493584868799675099758629763388126605\\\n    9482346381805547524368203662553752798805693484933318070087598533736730780379597291788312366712\\\n    0507042311754997877060191711551112422261448596546903247492650688646265739273125424396218535586\\\n    8707238424971231565871340874457067136444918671515230914848763999301453593893321813058242691565\\\n    0066743823196106694172564618800909465137754742911258893222439848677826430995617493713770951110\\\n    3044022536428345217127275254226971498312903690089074342190258275382808697742093181105041420397\\\n    3862407974221680982627526197686808546449699127441107814084424593820468467156412885701509555747\\\n    9982797914724420182524309134736550523622587743892717469579957304831391296245557023653174210941\\\n    6463098139367572006913947640393290828422920754353993209658063691843717698661813021021903796169\\\n    7474254742834726678211800200044334286192958353212591602448835199194815066164351524244022918823\\\n    0933056054472523141451221374272488605675181362589260114273272323112054810197341411643736962626\\\n    6447081483398228039617874067007341050304691649035538107071046221771002423967424267015525980505\\\n    5296010165814821568722019924333749229837749734714422265217899715585249277840311896843527624879\\\n    4426753792245637693643166643437392752468963012639625457669394840822950941435965859101650757497\\\n    2970750367520041227110766154607935983662537224716559814741595915384833518151774360736161548834\\\n    5212236006136776781991383076204394799083482485492042489810024541713217392659069742252394644294\\\n    0539892578931424150770412015454260601986236150905616628416168235550323311023917769828356341598\\\n    4407304081460186608100775074018288585757250641328616783843200363117188285390910217043407832908\\\n    7150710399775425988691475514095184804793751106370790184590018337880340626373924582032401005229\\\n    5813926987987131858341852447351330151292695947962997425194276873789366263777217844159470872949\\\n    8597775597829799339682174205620607971230352596545629602930054865245205311806425824701189619897\\\n    0021764267491926633436913000852485780182253970620740450722514127779032765105249621178000342430\\\n    8749627686887392330947310615733002833211898477105169124773865056643658182819107952778137169850\\\n    0427559019680612293681167110899892479094355731720156136317270120156670342463110981025981038474\\\n    7356558543447275560760613711783755588724450707876395693046806573553502690488303184848801278044\\\n    2994134591923954159251657043509444135738638592516230204033103982521729285650636340931109249367\\\n    0143232616938086867201659770442866622273333015438757759738268709513534216120477902342847714029\\\n    5523033745257614710705127480921683427959063956207075363858961369685719392405070377381785559681\\\n    7163438555941783836460581852148322342734222560217012984059367284176784911046071719287915938219\\\n    7181602864904969272876378665259925733113359021109417692969667536362893435963088794028982333133\\\n    1292187004337353033141003217295500093205719252466417857527568552119761908776223331900715740383\\\n    7338313718126765232445328106080983149714419630260645273792217460214676563576834636224816831817\\\n    3387099101168734509626210709147159352401344680632668032227948418095658074746486209883189603645\\\n    0527669749450059008741437416975301581770613983544895443814085799499465737033827107756679843502\\\n    8027343585346716472682598465851457478828483920705083673050094614903111842499505104911435464801\\\n    7647010897523463797018310172415744042220250279888583606448150781443187941256936122138894273442\\\n    7615978870676949851988124671989501626893844433724681657868340576734974097389169966841356926989\\\n    0217386447780177077507617302589162056328685084040158094185586689660257676038650820986613037183\\\n    5933256094431468725233277500608689544550155358541843483469049367347021820417868892509396110525\\\n    5729095683435722467040444234437427498652671427847843945831782071465184601585522453034549571499\\\n    0858824219676082828835333665305796440524494931805172003015225106941537839124911162851186528736\\\n    2718654513474809970463454549147586548049895832310256333778344589106681596327634088146975286477\\\n    2359686966718062503151550118338860717585735180555828349209295331231535253737630625282228243824\\\n    6793038259109815021955100056196789227804278554098593462757311991954871907887222848795193610589\\\n    9347445928519498292892696260542562530727343108883708766060105906835286188581371332315566590139\\\n    6186435978613266802277674756417659565503678876614144712975429285712235803249350847631241886860\\\n    0583528175480287535790036084301634252188566721874136660974384690584104412754817515139278058069\\\n    1878510051262119980390771213315199797339426276491339389235970920738985168114204282400954351642\\\n    9308100054433207084219925306267059420301733181175405720220677851158892908199468987773058196757\\\n    5321983669301331781995283059722635738912353921867134039666853820012116939989674325714814493035\\\n    2535620945296108520148570328188351781151851025257882013712106656660528369803854849655029822300\\\n    9546510795456745143405887791244035595025188565946632675954698827276413194786775864983603998015\\\n    2683845890752712468131081074747010194561690850630301254745056574872002159679978340104840629520\\\n    2434177673341846843071750789895332057811414529058017247105140959730022765458520691487171673124\\\n    7880417871105149030926192901594762807894677813704209250741472127383853309684142680971919042494\\\n    8464838841758069549308146546813630855101387264249868879565951114587646811893328984416775596114\\\n    0241531901952596857979237249615783565245972253888732840022090898368944958471479905037494183368\\\n    9922702956795263851032573672879104763340739598825451947540117996545063268862874193970633954863\\\n    0070490211186551970513921646686242501229968811088387377766302262308900074727581373484592916986\\\n    8501564636462605578021010305507268147427218697300072029710420746842080022751129714790060350981\\\n    2415069655813180037950033078948182107115579315279091665079686340486295304802185551881749631055\\\n    8498252564130123923716104257920458999351105715627831549492759386167427874934809876257975493611\\\n    1632560227025193782664272268955966159433016817001922391554711369922903047998658584044808002317\\\n    6468118075226939013271134236619124928320656603501610823251918581295220640730837744329685115832\\\n    6829534949271891012039532393523623382401573839594602969708661708638635032046150937535654041501\\\n    2698745630471561086104567517038705413891152379136047243066713485726430951133367452652945495300\\\n    0236858244534851137095391044525457605937645505000865903311901867807157314398408516747361010521\\\n    2013210357101576771949884910427517139342996875395841669229586213991313418643641778347100866881\\\n    1356948779642659047840183966313051946562369076461104754846546317872746343020701302569406968104\\\n    6607884749788310516626229441015860488391924473017122900652076039789735012561870270062722332626\\\n    0005190136449784791675059932368921388327167884374889168476367212852050883592973054638861360122\\\n    3460143265265414298828909323385803094888906047306592225320888336457870817772182616172183285171\\\n    9899242017950317827175267087427230669311140522453275410973680465520956750608425512553673298194\\\n    5024063961080016757162991028631955323895863113014599430509113795021351801059159445469000246364\\\n    4543815208126790599705026676241741252406242482208977173761470318074870817691821444124798105685\\\n    4150690062138591496192866534518913527989953217111348692633747769498704952408027557051005448686\\\n    9473922589055628814711300859501277824282874583870425732501689892529802704429250371594303093115\\\n    9997934036688971141188055147176077198921880687635908710237632008511365143228818861082690001012\\\n    4483100982491024835107816182352039286480127727209940985380906919973625151676360757736862076571\\\n    6978684526096347636497579095692814421094548198239210586733048688955880989234794533609824195756\\\n    5009997741775276148850796941283066140894159561960877369263155227844721654241166887548311476535\\\n    7926870635832555517283001801120067994891325868150965430171138775808584322693794676692042543335\\\n    7623364260086825847040949125910414008075353230198108668182507302981680013196356062890402698514\\\n    3035695715704437809861826202790832240784905828327787981605330508892362839206050881685810755586\\\n    1357450537422378941241092646571846991869955652322650408161106388877704135877298036521183745886\\\n    0195922442409691602224696462371195613963779749303059294958312379423549544452066491445910891933\\\n    4670751487217611966816116698775642511588483599674638822059140056559654860926413962970290001372\\\n    7175027713194368729478327565727249129080193279934337778179102680314403375074002215459940076520\\\n    9981636303163826404112821489516883123545162128057217994896761761204730713164155815742522689993\\\n    4815781488843264681011299278834218888828075811043303077893235924710682318760359513979961489251\\\n    4991578305620418542158421689987619420614147017800825711246603995295599318271483347109424425470\\\n    9880103954485847301580718097338026011719843842829331380060453057820062652733404535297427706160\\\n    3873055148893042463840439685897003257922975697658537930383105841370285089278209253378400726530\\\n    0111126082388579573376610875397448989530743275978813001835017537319528207884855829267533085706\\\n    1474380565850439941090557047869694901659086279652664286410775545926024087944626648298077790054\\\n    8875608589607900007541691624322874510324506804189873299939576036589312455426590377458286693488\\\n    3583386065098841587324129868066488715536221878188650019024927556198302916704668499834972824327\\\n    2030024970469841892503463063158259389867367780920686913981168141888987840015958146229843353022\\\n    4108349610436844628157976464547358844909104628293957051558948244602442032208865223156120807406\\\n    0238862702687452554340692914065221971270198793603271070426032362863646040979406410010875769927\\\n    7410305049301522570424327955144364029154064587281599453522871104728303514517389449966017530519\\\n    2336167301686448518167783718102581142897169287931852478362543645745122384520781406360159679222\\\n    7290834505819876094971905989858264125595712875114263989579378544981593646327390207241703411884\\\n    7819819693142345178634077363572865644126414407450807555909367449814295263178035943286092127241\\\n    1664961066975632265253185877304669412132272312584198603572810215167175841292651949186010352226\\\n    1881038607907813979713624805159209676706007957189169882148390847046993839971316039515361496700\\\n    2714017030853863181742405459514898886274528760173174446342497021636120476829898609675629528493\\\n    6186838521663695676393478930399661327763306174031537428658241447049233528152601299295550170968\\\n    3206911210339618593237103853890453483857438848647224291093847093840239454859582545006659929449\\\n    4062292555492713325113269249534290341711817868612833549792773502180349437657558084593296217538\\\n    5094386161461530884334485002305881132264466296076038394057001583144646811370151738863938197732\\\n    4048375135027410961975920360909463701691553099590701861070429536617278927790316929431547141712\\\n    7558107592608658036380645335584399883872376246676873045679569001718030773217933389636931548709\\\n    1483545932841885847750972831912185389663030938433615964965526852158044232831840932905324113063\\\n    2520150601552510518389745508997088045004197150388125619634363996793554482315890646170936004294\\\n    8147507127126632380204806661999874053326191128925020463169797367962189535549722181465125844303\\\n    7403178978201150649358235139291675088691326821712838360026091468888046168858642779000028441108\\\n    9370342829155199441015422801933520298431069927638905513023220218854709819120039821961398771307\\\n    0122745074067758637806941509515336373339588049754447845501037975688750708581479950809945832961\\\n    1303921002006285481608322078854585925023284880078199243235401808551244602488403284881521329556\\\n    4766886514231334006382230344530024879881913454405316324180784759345855604637103457418363484544\\\n    9325945815672128680549152156527355690801069520179879639502528712153732119957522557226511800945\\\n    5433774176822280887691752801949901056422909824102408034030655045323743979588421206493991497023\\\n    1039785174081229120274453192203296503768217409514581367170556325876847321769625689674780854911\\\n    7434305492836963531147538152262447463673254725910552238414070664975947519059124186889147761591\\\n    9013098285041669728420986758514180088025448636474449924377823353549877972534112295613973542545\\\n    7890769709343990809930928745022685834303137976276383551493519886318719372816735559401049730083\\\n    3366562576237906270231780676597703147386517776925489629846541751351570316336809214973198138731\\\n    0247596472016115125992033935118455428880481889352128313308902242916449920596494967312602900407\\\n    0551676747774367880063633819570366842410314723302258685108866165690142524127551088178230836093\\\n    4386087555739010941039625265505624917496717466078439743853826670297047978421882920720083021050\\\n    6146288142930384693485676396800320084397769996894939345367510275841845377913740377340435937413\\\n    7410415403364679497374012299664535735329961819301416454203140424891454751827951190912767231292\\\n    9368491792508206247391552148606124042843189247230375466512535235524974557790089807003778153162\\\n    0568489514783945086471280558158481027761388752073525627166803103925082867886404711614975432519\\\n    5950609667199755033587019904720870957359202361255901827398828829696221465010006213010408271886\\\n    5386024140815486562757891409096761533177820671218283880155122411519515824753223916958211820438\\\n    1508668843267738619387327067455686556477756461729783984477579203249729557609837363212923610527\\\n    0232531060990110189203530407876752801024977442868225801776985534231026189506196833906290430158\\\n    0868598920136773686515280393053538410698454422177097656794210978536625023878308478114883399005\\\n    1848442829534729467485220298906614573048906953865928929336443754119927062895255768433314052113\\\n    3698955277089114622402268507603783700859770261095049454142000014456733409619086853616942664702\\\n    2113705216692833530885372509477414190967821479239393891331555683962112110028997578030898050710\\\n    9888185491245618772390685818898589496136994275190714333429332462476838399270117991728465479665\\\n    5837910555013293814317532533297820309465372016641554280961310418788416615497680286526087274032\\\n    0623187737831023840406547830724741363192759786341690190075290020147749613374565765569334780615\\\n    9847700996028966499817533041336683336636323850752361410818170429538900569357592291794606988913\\\n    8129140041751398994826148258194159681294235782595594850002670398417307513995547230899194949652\\\n    3513800414094192653491634005837481107208995261648663358282942310153989038452716722912483040656\\\n    0102102961470498991589576001081973926238567416945639951590614203976102098166886701261387246027\\\n    1573079075581119921041731871270961619347998916618631664177759458577744700760321443755435866277\\\n    0679265706464002021678416680865461239208007396830139998273854227346936136488760641642949909591\\\n    7565845040964252470838404115337058050169718256715074539755387891270382418317574936515953945187\\\n    2185519219196692274069136978645465001077479969862626993432242349363391888537854928503571544151\\\n    7788082542146340343559211052599032381576776895218454680099096678696438811452040421694214441685\\\n    8368485319590375300445474699227639967531002304447713507129039003585866234308667008965498609320\\\n    8395323826099545543888535757656241930198459948666560286258585373945512487426181971473097987612\\\n    4480947742888404187444752870326842337611634100810331083241328318058637415263675897351126719754\\\n    5036458392529715746520456501270892091648007964108607999219351539484003296454253099806880372081\\\n    5442828157639876019273673899166100827532492714425825197858556678253763984666261746429524953117\\\n    1129166711749573426958246554308588207468584633516847816243649515531962349144698280751259864813\\\n    5082100532174357121796314875077104477437123220058048698529936208962870085889028126833799599032\\\n    8455841290424883779903685840610084363251321381545406535842204694639793507181205186316705623893\\\n    7150588306252680568794677164054289745225940499056356762448090608919679517790032611631838009276\\\n    8703347077205938519914254541662961614695328172586868990855170799444110123793046242252919903885\\\n    9908867109014174631597155482156460121619962303361049232643307798151680118266723707157943944533\\\n    5108779198049351626413551944810148389646074443428367084042066317540012310100551878019917773679\\\n    8238116508384700729535016835744116377933537011136705860068998435707048281982303724052463576380\\\n    4389161343076398606786406399463251304975973198689990155450911695044404573434537712909138945313\\\n    0195583699445697744871161451055368539911017174095322814757867182348442880906783443091618671165\\\n    6312997377864281004127638037667049241837975668029369188098741992602263066306313158939867700787\\\n    1768232330290290629672807094989014120901401926815550219908703720004326641021850542310320937793\\\n    8879206773388866001959931604249956992339728210093432848489306012042441084709222844810752149150\\\n    8724211039685245534099839846816208642458422111468477640738747401057606770054803522050714304249\\\n    7616725905231060127509760385585599360510401161009048329059397829420337767600107879696529426732\\\n    3118939568187736631395024540872379459514045257381435461122942113506291502013159008411582299035\\\n    2233878726035236453775486575524057359636287022058280241738499857405320648506307923969337421763\\\n    4472182244614520982361819924122150597837355998924994021573478815982860115056536278046376960490\\\n    9874423908795214175327117123603648810635212766790315741574528660825844237620788683959548866828\\\n    2288991995570033983128756990200450163795164025390794153530809769185381734960048598622865029368\\\n    7321986645320968479487419993487914540065144173178519605082606332327721833443461026108084990523\\\n    1238700989830343553295818265539862118537029655018588435919529051741420394447779780213521447519\\\n    0205387958511553096079648925888162146224513044714491015201300394773239196035894811128141349600\\\n    9961456475183357432680649725855039095232287064407674301424628630361678460899892917105668486954\\\n    2947626848524285321100590441076805400428184378792577885194486997682931415537467437925551900703\\\n    7583867001308559733591427615607642604231220686974243102206202904488738228230615905087156144797\\\n    6310759580209164405392110274345418391608875664332592989982667509784281091098062277959181719503\\\n    3086757938079150941560726858420359448908864046361239602887047648969207201153332227097326920190\\\n    6274906338920398570448431948614341681585841462100745672207256806591672789854863363688086229136\\\n    3682199409976340411154023069411374166361562139550556059780848684494696449626245838860140105413\\\n    4134206059955907766033208748115891971900327274957040997833987682835728532978708399768856258793\\\n    2541960287252722975092020047359310946098740750323602086067894452578032231038847521501620304803\\\n    4676884480453959017247719544024377294770733183767542336042007271496245385700503082872653823480\\\n    0452653853545917426680292433923378859383882529685599319390537662400212226343961860711677997844\\\n    4154617049865264368583218529952495618293700436910334036980721377056579385813500093258125405449\\\n    9741800210918043822419585406549330448884673774229896217722531486461862480500916364620510963874\\\n    6900104789586394520659583828000346112068790862878462226953612684381937839633222803596623298348\\\n    6446973359729801705173664967787480302678376324387237929444890711973629147235345723131006983699\\\n    2727121692160694395252880979745639102907522783639722148473420522393623603488034035247160496665\\\n    3045320863215751130478304885199324487053566987355136295153942019592037754130946899412711266449\\\n    9887310209769675508137869322228405574529650164028639497973246958021762056637058570834642732406\\\n    2409041837749082457704347108862434261325739606819550011205892487936558326155452680340676048071\\\n    0444850984403222009035508218506389700916576458940943464216408838882686894113737860594028270665\\\n    4069365270745047570884494778061029654642133844647973335490555047833772602136206674172389070891\\\n    2814642934181361710846935529216068066635427765655404513730022204880164991805574816349206655047\\\n    9535463590210288157448851051534131531728974722301529543525165535520273690540746173167251831501\\\n    6864018671189656416585701848097640513388011175544700095901284234057277996251029059445142222094\\\n    3228190056925659040852804721041032862740779450408042374888182538573898471042297537852265310710\\\n    1330467491356004280734436855867087382354223564786781813808924239274589791272083917313712898953\\\n    5664089615952729822403651350998565936881320215271341414268979136490372455933770618654491633987\\\n    9156973360887854105055813737994933312097292037430677163456954925581764332532600009827038310300\\\n    5343160579370116453257819655474757877406054590372222061260196489768255656927834913610740616072\\\n    4582623542681057934294133295800036632739265516582372983891527615379615963829013563332280777990\\\n    1756358405097868451677085140675466436470218636327210731073053974929634879727850523591398189378\\\n    5264753526344966755728286199985125560644831483765254250520736659057860229952863923918140363220\\\n    6892647920485307468351148370954227845554193411209371243691586078572571755884113831495990786398\\\n    9229254308305358486669194208980284601777586731987068917366275575048616729663339886206257538518\\\n    1616301309288991886926580702403181417488835642233852901937124064711755265432838973855786255059\\\n    2973708779046773857863714607875216418757766259160802375157139146673588971479310324896402236767\\\n    1225036318891077203749264795364034024169624539791896024298051485651816450857921898141294561538\\\n    5867304522566649562182708428920417055952672216533346392349610489174276264050475550696545460071\\\n    3628213405339278516651666248359438248648710571106644316398500688641734965945328766798863526146\\\n    7402010257332957943442648766037163118188672839661712992639180714848506802354321530304121788679\\\n    1652266995906585540221103052926269990655231396069697334269319269668334489140830276209368232784\\\n    3213920338469431239875121030926885196486950426765595835817983427161892784062392403639724930028\\\n    8670726738102257311587321782064526971758132151597334395457296883229775755202520982722352177076\\\n    8627890313828350820211814078797216261078266909485678512555796885264309922363267059637078923377\\\n    0517769592667989316492277048532032814886925643937159129648348490958227319434292970026409456518\\\n    8143731159106306629661037110484731281962224295971701925853133415640962590809522098249632244906\\\n    9394991941232535999980177610089255931344085700410715774474147644933450985265611621014412836787\\\n    5804882374537302626452939013007551027278076151999135271964740072361428545417893784353414657376\\\n    7785392456835807194016092042696274457083622597918358045287164588694079445017775452970120604341\\\n    8240123315191834000048732920339302258362118401246937440081805056448347571943265230220515829935\\\n    5708298269578661825393321110810907917491106293679496609665666593741360869147325254264041084027\\\n    7273831944638602511304578067195977907056710854147651369381151887938922554527545857156123380117\\\n    9754405849347109268590330618344138444190144041349600393397594687074206027007103521309489487769\\\n    9914156567568037429561994470469629219234825307525093003066174220330100855186847481345547359085\\\n    5049889416992328923979858816970326109403500452376733651172083757585900463900160765828770154623\\\n    4328003941395507589595598371603946241152322273847148636857495948104400174950332357813151959523\\\n    0933190979490113131239636866081137635317386329639085547698280055046472399376088611150632588661\\\n    4409856925414034676349532619101219167782781523804385286621812055028046419892473011090685405951\\\n    2176052939181121068561693206828201575779913406802558379307491213963046788145261928484326502964\\\n    8531322438543345561822481121172583504577213018894928138620519479116351060473131371579973561271\\\n    7104069584562405834313779544720183091956055466475720578063880703110797933393202912018840973859\\\n    7807997836604860101765721597958882074704093023939245323893683993634983265021853597091443758424\\\n    9313360575601903552470068379890363230802392850557374562331102484671764805821773044031589650166\\\n    2825410090514041591149145292383914769747242653876760655102707235166376146950443451078217294774\\\n    0209231752125908726031712320294455461623800343353841550616331079732179204579926405213789171874\\\n    8937234120824801814604626663860585756058959237360368889944276462132678355610150145480347501188\\\n    9111571048553132063838640002649734775269772901795507611231723157019037437839605827388102585601\\\n    6808156810894477773584891623379854748624794000155255414642902890227871726924893947440569891959\\\n    0023192331339288271299910957685406631463123223416255655192950482481738438909484439826825766604\\\n    6701456171947276295661444044308313782654613034658065143018909924908772583183971574158437558310\\\n    6383402507254923589143997072050936013053213573073443049056178925506501312496990731501114423468\\\n    0673865297342264577843458199709396849618318831904483078213365899388453504918457566768040165400\\\n    1627113477024591015976171477182320004294329026655905709080024484691312677100642894017339140561\\\n    0443029636919476494643179849337748808327685892122727263180569827502341258261941980228285203938\\\n    2555940716864639210847893224425714182077752765267017370528125773567526601870433955051662934923\\\n    2565263290917343611556689701854300263431804104718887865402217856816119455789197707864577164003\\\n    1051582890627761852939050458923821105068707171790478344283328839339081898611755270231558622108\\\n    5974236594947011427917905255365430029617573804507342842454159686746275246741576723025359340639\\\n    4050328545619233352162111006822600350937287912863812264813835132182814407858293207401150664009\\\n    9032853047938728942467986155792565350604175755127968675221027432460054686663912517983649073400\\\n    4518597969287894644432845970114412556075138588674538306323245973278360551372400617657489298884\\\n    3543273502919760887769301229756612327400691502877970696597203306939176033014760011335260748837\\\n    2466517772627278017770234971273065043753252445235135430454522806915695209381384763058541553618\\\n    8682780281946174034321568653457800105614310790527073194840410685697434551369990911615877528864\\\n    4373137117888314824768827727206409875487186574389592016470123117376243852326483403754610453747\\\n    9927397843961306425344519244921431838666548350848282327589483553774662298673457985356251182278\\\n    6733858828476104006605233619677822263267676950502582934126635116381821109290670405415194967952\\\n    0709481287294419994837732885593906801718210610918618669344706083310360355823121674971591721295\\\n    7168488709054259765982716263354798873746477020767048343331593328991887918072079052973520802046\\\n    1659486776259706776620811272005738363052153069963856435687573471148115267784887062962048157681\\\n    4255416466702407287269313099510445179160325163801475787819830874331320949551048715356776249530\\\n    2248171789238098259021289216965151989076243004306145188548871482837194269893872552815837312045\\\n    0616962547889736529459434269436168344794456927757315007934513903605312455513084411254207345833\\\n    5511520231289800434363349701267285643449286007072639803103473840894630074364605372616726000009\\\n    0356498260019206575784557169470464022829984986002341174294477806875145648713937266866419732316\\\n    5119279366164992187450054809100641517366685599780947571170887759606791190065330562398361188590\\\n    9493882963510471561229905278346073563102354000181016872091379478186984181268256236286848913037\\\n    0998218484168834020403926067719988175578786556339348585252642806920343200795914595922944371100\\\n    1572185658557969556626686661445152630613600186874736313858458821143060273644828925939016221977\\\n    0312340971615192548534817677227577191527255452630504141382419735686258391920367474190785351371\\\n    5864683822060952242180215421062522953841074881441620334410155425386461402666101977889266271148\\\n    7823300975190959074650504811095833999090608317923818196788457535006377966966567611322501710508\\\n    1662928675512167195632903031037533500742154211467621970126203725518008018929892751511688978806\\\n    0683945950266465581866095019870686593521124517132675539463354750275725413999987165756240978284\\\n    4442003898724113084806022259417777291313774360365800130696663186689881401078978037762679837634\\\n    4471469112451137266800417189978726883910777462896396026171778013998135787668098918491377308104\\\n    4727108687052692066015456026975247494294156085394469580422794159755519945716907624368679313271\\\n    8645262741176864127769824469342834589643885968073529072780966116273131983503690670382317342462\\\n    3755289074157295816127340404065182551399251906723884011383356390199073471062502867472579149378\\\n    5710631111982212118468854130461650635698735010847776612240520577217713624926092277269810876296\\\n    3482182962485099164100441174507394947013299265629532188018521029454194799305938784673225868910\\\n    5780083125221804162004497153521176481312336554017183861877551013704281430179662969373594051806\\\n    7996676678358809726471984775375253794445159986048668821515697440335862980871255947186939774921\\\n    0540216844614420729015067280052221224120142048360810042171003132618612644996340987175327858751\\\n    4173182605963996395126179326760308076428379955409863326600176622079483444729437415533505701726\\\n    3286676208084002102742897715894307728360694450427229644218837675838387566891938368884060299539\\\n    9899718706907568355868890397595880590361408915540335590469699210830388796479487479362591533684\\\n    4778017405754582138326603405362128362736547313039996875042955743962721214488044169640931447998\\\n    9194873827540709747746945178284262514092894625378257696591680956446941012314560302626372656908\\\n    3693773847500834935183689250633382010327572774972846492201448490532273652253676968813375766106\\\n    4456685167507439728569021968869894150558522901315515235440388075741063349146822376495289784753\\\n    1242507222451449121628923616961446777224212916541092250566610008293774966707568168434269681324\\\n    7903799385354039064209465670255900429641620155544201794468435049687708551861520599636985392874\\\n    6073730976304086733427751912938713032094720852249519001043060067462970403952418402181788318965\\\n    3614127292282080056260936576114256024114526376173049886542755678141981524461181992740612431158\\\n    2286757763707920091609546934189512205286440051805571933470408797836228471740342185971814463136\\\n    4717522952042536732405126520196288196355117260062998405390468291612314521466309967821256797572\\\n    8050529921400249962518419550060389178090959537089279797648533329784159212840220650253570963203\\\n    9113238107416706806898866294650769083842593311443972964413649026356992716037080587163574331528\\\n    5096641437626211720781745715789176157372423775783257674335413383026302905500242485295121202724\\\n    4628269944328768363546482449795873699694278905187719564386563513201213840323970605148391745760\\\n    3525270852489132249380304618535376689379317905833635933325034087205764066036837477301452664543\\\n    5848769161174032142232610627019129600312019284686520992869136668776756526636779682489974759422\\\n    6357260053267706470388982226429007895908093736985979983349403651236388608314260480856592823537\\\n    5761650714730191711408139270630400200004195877308201657330336296730533721270667553861604434972\\\n    7662599979110304178369190715317694631992858599384819170453841938470302684024357383980628186672\\\n    2788825740311285276677164281466264693271573897913714548020118184829783956700038969943091230430\\\n    7378108035577489162269205961040612267818022663624563053152017774943908933851900581666951075446\\\n    0098809797535520304912022042719183822163408303249742175658238083753206695168766520455426185109\\\n    6585796842705786025828526420037233504538033638159973502432839724353972941369927555744256204588\\\n    1563324426695729151506310722190054691832423863732020587021816630045043955925073822120557078169\\\n    3707647688489957849944545792103815362857903390051684823891633248192436201713893789120324385221\\\n    1167198839750946397445984586649179182043730002913643998009138206726837573255246298164158002796\\\n    7544734282666017912685547154486413416099190295896583233911384839572996458766238200140561807581\\\n    0620275542104788135656935517266334368612587202705336131538771368214200366134242055825509706663\\\n    4462916873003290433821292974039651065637561853081068712638624491906482086347116589240892871811\\\n    5155400651663252437732444831406423937145326414570286924931130836517215574495407239385647298731\\\n    4851325514695617507198933901540763027736521658699028792321998099411778410334909228791763168603\\\n    5495482761816270711800852966127581902161801519403792104812526117315562311922684754111054178171\\\n    0953738269194944078450707809524582056603231614007255138966398259566605781584902646215657147715\\\n    6973829835731408021781713179893535950485527600726413763427555541111344428053259163795266186364\\\n    3662344538859595913398416273446673595970064972049467975516213009726150712549014350789266487571\\\n    7666548468476007471107721413845751789406558810830691109357224488561682181182909325769322364289\\\n    1875511223577821498825388975145250266763200463082088930875400532430816850966641964596964734130\\\n    3482725848949361516998942487148416198219017615645564169882864657248289753598633456339817823944\\\n    4547778717341397697216629321891958516489688141537800123982754638267528544245153862576612530821\\\n    5163466867464090364814251932367752688208336700656126950691279970767584853018803289268147755304\\\n    3581565038354061490554897739538846706717772226453103079822673216194259175487334572101882831498\\\n    0272970135433302252522299607850983940066581872278222291534622080259521597210718649494738858744\\\n    4623792302891538771048347343948812802124059314986668972068585602415936464989403402472389599482\\\n    1041685619723891198680455409995573492958329899411303128445089529018237582265045289880548946324\\\n    8443988201350615560562452382912892803751191894595007526019415775257842055268894706669586060824\\\n    5747985511627339365717549179562864854020298004059979484554339029889878568797156044443707711556\\\n    7681731921573550817160880380774079784303780313106878652710792340801315586482402881553077558357\\\n    1258611683724661973087823755280804743029020051987827496956679919488760373579162166313493721546\\\n    4940322755535219803929467713659620880563866589131340435330707475814459411494062553987972033338\\\n    0152261943996694277772409031875840164614415569017945578469588110770827562910083681929463868410\\\n    6601829109387173127383991812851492982570981622191527107582938324630606059101462161405973286374\\\n    7789852545788607427338737443738283783432729654372849825796608441506882184451443304499226521240\\\n    4847539416520930203433018925401367023083714256250277827357417481943657296622954405108025983648\\\n    1001540081154120065727656042564908437749368658251591896175676071091674195115609728136434792078\\\n    5210982736521156566584045980438064260254829142833697292037725844089312825978074730599424106165\\\n    3930741277894719945325022855088476826146794238154986250422706757744550241968699738500524869585\\\n    4891506517099001459226633626609387052810663980362472431672900331131088147341495594778064088679\\\n    5488617862077807660426235685349073868783319826795373583440447574635073331830415782742752393514\\\n    2562249947748858936059962504182886996336140857011289095301871755521440788906725845218433457232\\\n    5054998223477928907324553751476904510686041831792985939166736256124690708522933811640022553436\\\n    6769689693996251127558530597025367072328853680083211743165835336901169193421877465212075386137\\\n    3532429917859610527909791836875924918307908389466726681810460277454086578450728648465814478887\\\n    4432846103452691954071876804368232409866299928666149333109019171704374520870211478898473893764\\\n    7917756786127756354754212746110214690579182625049564667029575669459483403288732965467181736423\\\n    4499029581799708413702817185659673541452854888770007029816318630230084075508001868491053475831\\\n    5772222722261394377815964297302805844215230432870946085486538275389196984680692848644219711563\\\n    8903436474384355858806441142067587747865776117557116336060728604152226159309734496366307772850\\\n    8354767425767059012562834069354536682177182250332714957855664463603308801116348260413808707719\\\n    6089631944980864878655373864059802097357094552109346616866605828686255686233286287234169928977\\\n    1225853030173505391763192780446426222680513083890928409567995189902589624629614034390957331360\\\n    5750534813593297029037824611615579632976340921401199472691339101986613728880289040457662571607\\\n    3706873668528955639143544113912378231735655595058681635856781618457938689686322959877426278457\\\n    2141813747610947773316015021564264673929306089835798091561608259723500097633478741162706341735\\\n    1182620198098535799239421446483462036012167768995936148546088870748955599759086789195380869501\\\n    5149869759182413081639682348460093329210091700501970452226928139792531331421781377310667670764\\\n    3721517141965563822913919248691634884444370204372581880881357006645983802819530113697414365609\\\n    9248608624926465838849259684154525551310763554911894920965098045238617897878432472025966193310\\\n    9697681692572125433694862483068338678858468102909298785472449567640365427740590948781231507419\\\n    3441147366370332128811569910166928966956030497406881212899786861068915131671896147652623823949\\\n    0047932900385364976726742721325374211926998133464937953817802058961079920860542897449038969489\\\n    0094256843958910940616633103942414690553295717941223505106274174348605005768791027837285719029\\\n    2180472452254540932705508484487730441227012807571403154437772381218110490508098416852597248008\\\n    0291119372759200627092565973032018692422356210838573278964412080677393400884767131780381716969\\\n    4006197706885979408844784401942414410589099000793680703572032293606968744658100034404005397898\\\n    5508762598777502403567359856078464840976933241161649993804838275174562375259264772902402498744\\\n    5529108280983122144075687163821048924613639580566886528030854670120504831404756483091323585642\\\n    0784852989712832722320831745926594729295162276516715586630463974267026608954743219540067320736\\\n    0774632029291135055788119708042825175505947924085994451214371748824573968996561343863256705741\\\n    3532823097342176443820370728961682182385751445553543083702656772574792439010869430614122435097\\\n    8780891942330658532098457302810281331529122137553908724444915730404210686557733845872922065563\\\n    5137657286471298419715593381887130329057291988201142052891921248610613139659498437901714656511\\\n    2173679634496338477062615440209890510544144432303044543899643749004431675040705445066031551025\\\n    9238258622994811073105240437405753494302816266029374413731472277370071627439683971527264953153\\\n    7297911058746208176591013513719845321352575937555633502899627493889765130018304896403364564013\\\n    1423500095178345639044279529535652506034539003902984592268370789750761681189771581746031256022\\\n    8110681271640581263013723713576769499926357123303335354123944852499327703333058154703388328026\\\n    7189209350400769820459891857239886612558561329374042387175322238743164554817004948092815225226\\\n    6416933205321906084110728339927656186465781200906095546274880585691721548979751656888256390620\\\n    7467515270158430005550227945697923288222069621473359960612719718415519721922701244785036345861\\\n    6995138109895057856930979491339614144798985028573550938449075556675892610670836773552150046941\\\n    5835356536449833626816801254073976514105734995962401349183036051284918471451537504342525915383\\\n    0392729489895102377160306640789148729840381850078788848239605728083823463609806280305617464223\\\n    4235955951091554169458370785425044588437839705457538514963308539234578540404522789329146780005\\\n    4948230984767516449785796637157613760856100824191780015311361001714670143308730926774908614223\\\n    4099084552689278587115276827799549148419878593762318764997996480709731723369601576623817777742\\\n    3880959998147094674498669591749467378310489974147268655382212946188236178918491499936155633904\\\n    3880007413486510155031117952846339593061112870606252425275513198031710562080936940827517362231\\\n    5869828334530877095714721916767390817074336511034332022414552543687531844482620253551413625410\\\n    8790855810982542847002405869357477740280162471742859249459713501406841066344141108780745635022\\\n    5721881038186001425058257515251911593572765423208902663945633906347183455663601636055519402891\\\n    5089186511379962680799385965413130590027434744669736719344545423844330618382828811669757883621\\\n    2554194078806370995618314390506012313125119615711945957551337283523516941584612774055470692464\\\n    4541703223549487510536172211597292704045972465986067759111676348254687854461163311995896638336\\\n    5311679044527369565831453604375605506438369491990841171141734882956976515709516160748294030094\\\n    3568899714552350765506736085502498830719253001856563210436854101726969677345338005845952492390\\\n    1693813439545273074010778128494202484887527420508065886795920867053044896019895856966182114146\\\n    1484394182285203420714614511506499644136986579283694652223030051091626484618424376371228239463\\\n    4073057003964987067097595390401846963982456554064371404313485655458337464090162704436929582338\\\n    5723738416837897287461029673434923017750716411967259291532168935111535064428198895426064667404\\\n    5922321306901099767179863719085993973947476652560360756562759153659388994321342377856487318050\\\n    9507229526071919464681603276615198799042499091888065341152789518027537830225759307172173642571\\\n    3641421087783668453259935367893828898290151251687053585845457522854178307195749841953747967950\\\n    7634859329160122330245082405712061630830823277143848506776673554484229804530277211377928618789\\\n    8313906857608383243594729878684924390484711747191916871849324114813687457873337361895157774529\\\n    3189536491446085839367099877880353175714244964371480420093376904373579508792565788762788974246\\\n    8758709803246981810253906480031618590675928792697500673238553552296157250384259542950257747903\\\n    5794806221034786400177465643608958870396264379355425151172565555644798310879484203673753316085\\\n    2294015236191256492827733637177374867171354055716819922726116457526566020394348956961809821499\\\n    9671947169559910301194798919492535829386359089858294950115112348734850093439893145728678494231\\\n    0779557417273414942024868523521027573134485752888920467348893490060655610742919331208032886701\\\n    4188057341679780328127384458712271519861255659104030622091367691482924486821267247182089881834\\\n    1305922376976216644955834112325350468696078622134925263795678360052626889157972346004562730805\\\n    9191019896602165667219647163670055764593465389873656230923102608051665186353074617716202026855\\\n    2198072910012241999952551006770538762660757826346090511233001280238982813952260909619563021060\\\n    6449100825509169632540597249065652150893248902488580662450872380101139306311281619454983337503\\\n    6389045753128668782388248948334979084827640716151437492199188855458373865347224258021018931650\\\n    7376570225188306220778482414814952734157783094639505178542173954523620473372391816148487301809\\\n    4915847048833476752914113705349350119416486732683210799500038950441764240986299539032328377890\\\n    7549213352974344502788757050804033190812475022243410933849134726795253759154431303630618214158\\\n    5298981769198770974390838556299176297362136254613380515979580626706451431701371994588549219028\\\n    2539122959974834478692259300951125749970859566227195342040888519360364992234916724157298817481\\\n    9582878257710526380931683849502008097028711850953400769032864905725232288793524342480826210588\\\n    9848558582178428942090191964296535964725014314814574506646532548821803765607104744892320548136\\\n    1655199523162399884311333489462907833008690830130318894983276735756033003330761246042939611035\\\n    2086430884389828018426974130442213049090221690954813217718306168596290525200271258403544607135\\\n    3219445936490115337159203368231597028935000623328735901951424880836670391056142391134400549224\\\n    2566093569284479242092341535552966363690621278600346828682758397443614076218055735608065014510\\\n    7729057396473423507308128524465852664545847844957693690306877191346581364579156454891534134101\\\n    4020107970353190054344669163301468554714186721928459152034526118576727147588710898234911838673\\\n    0705972895711829372393778188639440626838387765658991985538648676077228802019843405328871409001\\\n    7952307526889326889570063784210229480500357994053137449703170444786700835756778713053605701058\\\n    7148142351203303709874490407215869353152702737103381572666974957693299672621058514774518493700\\\n    2104762441941635949397355931317414697781156596417579244191107654934699790896309637924367289145\\\n    2685365383965699081637249653957152786117433027765881527642558471114055953416114813831772253549\\\n    2009697537631152946634671326817143389268701486497416567169078156525867027787089840368362199132\\\n    9859689425117111828043744709746847587118575209256916624175635766119158449375904762825489484213\\\n    0445761544695117838676424834860200557643449690379406504441698681012195921001095343041123113856\\\n    6037139712265257042425737003883429439080931425376042718703662609113264262921814098314128164568\\\n    0248975113972136174689337829863590906500113924797197115790377010206166423848979341010942227056\\\n    3281279599277010111271670015748856682197813372225521657393440045596341081999294381869008748947\\\n    0298770104444584442862554751542233654183809013861546480131683837413537638833122525045553374868\\\n    0805266921849010905000845283957819803200189177203334088094460191408617495520951889566449842295\\\n    9592633139820635663871270406293606938817273180838821470152860661502762046325424322276360266841\\\n    5164045266034295456871137931320104853616365628588343747959484745705377986313545860588583016222\\\n    9524497905447294607847266780033491059228587821954471737553382716029421135926959895145314300409\\\n    5956931263869972037750932165368343778126475904481737937911460396014957719555761497717597399857\\\n    8057892478212435739467296253775470381399879768046142486949177146032807380889277045193807416923\\\n    3989056082063179406260013643405775463596233805091497433465887343409432019245901859812638588359\\\n    8309394871134214859828463262983329596622368504025459635553053568104875208859487151416362887162\\\n    0027919688859305746514401799815989264851245383965279035509851177493126200774373741940061332806\\\n    0849991781160928957987213196530040189172292866823364022994955225354434496281360135635488541597\\\n    9536853151384427126206048442577560520171638814055821857731755656003514929968264805263961907460\\\n    2014619012554462710342703679143046431408327078735350190608571286863223066601009950014161723778\\\n    5593803100277960692013488294530990692466162024016085922280932378088313805797059015159339999206\\\n    0821952225822867113605907934153420931106368250191129299115419673314202187424402119588418893969\\\n    0464457653872767616148735683587295385653542421736383942556608743764015604383543873045526105260\\\n    4985329753365487580354372244767739223871510347009348155642185391454173983126908824691246437719\\\n    8743408292396423531595117498572518377800902867511117913931847544667572688929706379372461736976\\\n    0446781028603899226564095683624799369013574388461896290368906724428727514799911543443192222676\\\n    4875979508764086863096872690690939920683625586850982402745765234469253541191450842468393384273\\\n    3332162598332321701106898381915049409692474072335796561866533749834219615301065342236065033153\\\n    1299860163053190461482281904414254086474098723690840883818417061983627253402215742198719374712\\\n    4326450725645245294577964092325636735503109112781258668745155583114474752160369471093153184991\\\n    0841239108573549725617487232032542633330705582863951555726402131316052432946911193295623413439\\\n    0558849775886367937957236977285707350990266072108826367397690309857444709387683268104299764193\\\n    6768656342467304606316906944226266815791051099397249840952748649561393448257650060710160572129\\\n    2966092350988433938255455354406170494262281690586224979028983615566732681590458602113691829378\\\n    2575088659755152895786673583884184982548648941055967942873809906108115091589199850624277179378\\\n    3898965547631460435524439185668858992740766973021726632432089366087310774542929774868076632300\\\n    8175543886890216196690412657995127096188580500793815480696082410371374858638299445730334961959\\\n    0059317420638703598854892284743752695111983970784254219712099594601616117042978105607048341324\\\n    5727909028319406412669795243138294671813299958773912661335317447123540989249221321027581842774\\\n    1469558694054451233549372292029944109522242179421880451763916523672340672444012443458335952122\\\n    1335852422666991452679029740840939581623701847768968118076937060159925880121020784255765773314\\\n    9864472164540526144918354674223743516458017806666320697883707134334074549542231165127829053536\\\n    3154974797260053880054678646933317848447100156788203752923743089090360324601561226128575672448\\\n    3855838653408587452000362085358692924065555132358897251083116690814043560012411116252217536129\\\n    2018708825296112824830661045591792179218157596786862245223634754704614629616928264296805473558\\\n    0461146196201393647983948409977552147592507230421334387845339428379895355408265749500679235090\\\n    7394314779967218640431213805516183874613076127322593989882716396839022489344613845959864149549\\\n    3821617382425225955409415802517277279178213046467092545359100360186206385166674160375787589803\\\n    4439482655298359872218124092466318216178938570341772615919052509707123032135786509683700823464\\\n    5768114666499461566995470513174657118588903441758735131728968904417951665214160189087987503247\\\n    4220153106882421912184490084109254820409761830977082546200004814981592550418674495709301606889\\\n    2739114626898402601267166964007887431261068314719582231071088228233012513829863342188658455751\\\n    3818717155163492077377183655104121809565421811709881524396303491920119668284629690355986663592\\\n    1884145982249144395724451623099157009641848482325658559735350375130284017007870046978777946113\\\n    1203392194214219301672324724098322628196170758202214077970501108197949569420836835719615709433\\\n    1002793059400791171582269672340484556116813406370188663129852657464841683555740249116063976081\\\n    3585551806937067273603076698840380924080977978082525650364385496155583122927480638105045283083\\\n    3720559010762641476103812967210909803024339322406579706887475531158840480308013666629133316204\\\n    8078262542404694251336295508708444203664716743038320463038552167335028157167197459798074907209\\\n    7691720742679155085811189764015250323589052874573018437525395467213366235154606516356233734265\\\n    7756597923508246224365443299562596881527828586916117816249608413751919783693022043911254032254\\\n    0737710965154677197890394365778147260374548986984936577252656267250946016958630389912624277223\\\n    5278031073591295561700837679224274720915169871961411681440303268455163705443208123325166617660\\\n    0989289109715787276155202606857176197391690404787045384223413325221607369726314782948551498438\\\n    8316922448353054925457783484706603955532284579545169968526917725007534734741679010929286726807\\\n    9196945532445919096151221668083571313967056406838369426351223455424751402694937969733484611248\\\n    9422817330303281319700647187173310059502681815397752877949961735846627010918708448745879192138\\\n    5040645365538180662207643363555919516919169091768662234926418741688087585105157471559839927643\\\n    2823940439592234742145798617435563358375138519855151049687172401694928828333640278940776104136\\\n    2603987066745158984902074408257632094946450219155691732334870554546444004303248553256823261438\\\n    4840592153907927425342126347367507666468208738339882331515719044547779176914090067800223639406\\\n    8738789283609194689336442229246469562734415662596204773395553196491172791209158817129885636652\\\n    2049623548622691742993318651285755237046854095857652557664006354463942284595323923538303385793\\\n    8930299766043297082296018397133551011517867979183088258933439694281032459222417813133959016217\\\n    1558526751041472590289201117000527823739033175535715946755014675968009502343169391261303811870\\\n    5196875376919439214735236219196333354721072106961815701413864116779854140203366520879416416767\\\n    9148670622704740993405270858881406466674542441494441698692548763090809238310014954194894545002\\\n    5768197040533411567016274390301666411251932434744263280317215773511057565496751751803182115703\\\n    4605387051580162325962395395013981496726406324974946231530666061601115936541008109080907301622\\\n    0177467698072860830401602304825380082243008872850744907295404217586372712700186817990936290052\\\n    8590327648213340250920482848089454992856924985945924984052602846005121661680810894465681704391\\\n    2021504777058095183891964670285603348411856101044805161215843239429861185524844214115665202283\\\n    8530473824855035639817358239998190139880043607152294413052661243180698984643966523157219463367\\\n    2559193869686273358059140302515896778467221603437601451054747536827624982664132104166445381600\\\n    4981697300475447031523473963108545665874189736035203570385266808952271883197251018730313171199\\\n    6267438164468562964619271017922381781330422744834627306229406079566896380477414614752237420023\\\n    4279458195554954553135052571272538209555404450326448381339749721700477484424340464657250961427\\\n    8355328971524425102294796350060492493202323459450754863270879864191192379216376038800799233947\\\n    7301057274522586983765280586758556710598235743416007731893293064378374425748864921427192563181\\\n    6022036966755922623010407659116404851771948443103353486206042065717403257409870312269413665751\\\n    1544882617638471776256728171616585941163926097472139334338802793954996374049264296731322821850\\\n    2752018392886452021903139426453549518513425419445591360934523103497526294901298122985781159114\\\n    7057095048616271483861466154670735991451208081865683661324629199412730157234161606589474539688\\\n    8745848135576795900533721587450220401221549849940067249781294404307371631362594861349423252762\\\n    6920634363653880249067733435391309434638005288956940007273893191873528709610532172391255529331\\\n    5668642173687484514202227836765153147235068950503738062112871502252706566706488854266597239930\\\n    4614905766686762436100937033368100320890197977957031630102723539646451907714871302572313760052\\\n    9468048620905724744605304529565743952650663430097323975383071627337873292784965441329767290886\\\n    5801368788766050663276547987663793862255161346251629332532109473927033912006602340113682476048\\\n    3533576789499093074770172889183852368573249314466096011192062336698248417739292816067903586100\\\n    3854426351027278676934695184371601973610444782430082247325769866164952516696919676418752859121\\\n    7735378254293386758683651848516732997080331107931203070091967263409805244501104878877469995293\\\n    9150318773917959708603833838366695281205156418154702034064392046731433079893369684612381938671\\\n    6201943497091878622272755270328700623052889924232756502965155221526995673926030108803993216925\\\n    7158574811614237186253249926292154322314764157255660484056836745162671527483890813346385244431\\\n    5180238439759705327487114088373946527451515959823070947959963958359085323716518747048523064215\\\n    5127787302749248076927806687839928256058955783492495603831436125210317206890118535699761097569\\\n    5194055170781055185542940759971470288002357526527244653208317941229112806498745225406446392557\\\n    7190465614338276463660229547408193241282879290261668549425097094203389733632688488558625784909\\\n    4569388851727582176558126256847676566505315468924326106620061180282984173385054680395049022462\\\n    3081982874439207035031459637213420727851390876630326792424638828245279193743209496272075752540\\\n    9159438160575080580727557693327791709987719495321706028180236584563783303180968954038741769003\\\n    2561715133382767352305786858497993953755030408515561430005496419751408237951472213363967811532\\\n    5024738054282441978515118770521590173282156138533003346280472614341134818112971889081167672992\\\n    2103688202968052294224082012222602158685359989161336932629328307442523993948840727105237139439\\\n    4397978204547947605381522489292586450195642999771376733306058218632637486177843788316173520007\\\n    5688745551704155063101991148446657205365206927538182133377869882817637846666755443245624869925\\\n    9743008682617008626149827570145101082689054888152689647541760715198687910243048886258345276600\\\n    1269611800552390523773000572091634684384230328045274625003123386159080270677632522374377701019\\\n    9211541599954611944906169472812989608581359618791232759007208007260784306121514254856163591209\\\n    6266369881018905970967034154387240054537860940714372648495885694344427553436185039461014367527\\\n    0764108765184430109041954327742029106817536897662650166383655754574311067389164812493027331578\\\n    1112562406111608751622155048342079390127322285777992429997359201970166005192626093212546569813\\\n    5776467757749234440406507843282500641821116294436729085839517560438212872235325720868623722278\\\n    7675547941603947933935259028009984597088685346241878679874783516286975455520127008809705085777\\\n    8066516898490373985177697467241839800442869501061903988847891366791387675210326956345619630973\\\n    7150988141915492377245583503608729990442979595654324070870186228154409171223071970108110435227\\\n    0488849313768349995018415735642208475970306109921391778166529620932346381081836659958417864278\\\n    2559929465548645460185129563490756886015452465813578516680753888607730103583212368981701756185\\\n    2485859266230239352991123626975883800120544388276854666808306831247822999191481392589256716379\\\n    0526641795792933870178074656635703388266937067315538331395116815507423579842310661349912019191\\\n    5388087229527309921062437451268797881389786291399236863037131191555744652493560265427785277762\\\n    6132561971145674858408990012288110552766701069489528024537890598583644616187904965419533683891\\\n    1928561824973648259636187038960607073451013951366392463024438040167548920016936372095608345833\\\n    2414097565223566191669206435302197657923862649932813363963801495647854621590453847111189158569\\\n    3452262367467720796596299717325409121293831595929461677158123533757903741117420948319611739221\\\n    1736871207007118184350169916458326614434892099594650458257848593883414838569207147748203997971\\\n    6163134915279215424764670944338373293026018966214629117525732020823710380996578447629740786738\\\n    0324764289432006954626480282978387894663288116042818311598381759658745144305750966853761493451\\\n    9289974224655674295359212266331318672667563639086633066483552353199373362069283867538009454318\\\n    1348197933596082861925827422428590039948287913838823281664614210505080147049024414038075492799\\\n    2039605925455922179672667452978185694197427774798379569340798865092416103204345914164140108786\\\n    4215396301622793998351531771628237303703618789754057239753860242303943677850503106025114870794\\\n    2359844866758825227272634931279124530952993215915326216421455987942522693733488363527708561664\\\n    4498033658170219414043105790390406534886521716710692072034723925044163658418681081296418481009\\\n    0913686155120202756343455664450384720587929846123430602409681104850401368435150979139825375042\\\n    5082645578110745259386129821158569612216872327280843276037808938165565429208353957318970649643\\\n    1245225179308527662513934826407485701709709398495827528739577465656875877336696654967424621628\\\n    2545637118070604478622178252406908749384112289030754872524154250814906724957109755669189406530\\\n    9237559053789930854924184890750199786187512355642684094523413603164586068008237715807482006448\\\n    9656802748041997487718700493893592571435091127954448844910870073311882210426033866200645463947\\\n    0353919665514197875657827507429266198636732040763821916914742381390834199439967853338996790535\\\n    1545390611535077775585133164348353826594899991382579581933314313633804876478216224312029730377\\\n    2573062267019397766844051003733169975362630843556142981069391937215746132499527672481524553206\\\n    3718731093544024647552839747840969482503775521913117529759577184946070863560780629407935319606\\\n    8649113838460382479418576404741072672865304124018719079852430801551836337401042792193800883919\\\n    0363616624165348728050986505810836766019605284075399025356398869253478669512634726081591933218\\\n    3299605593746199460065355459436694555388068895956905578608262709661528354855406960767116476935\\\n    2044292848232239137487398775878104148697678166764679552896320777643715879668794299797194700800\\\n    0729239793661308248067292814429648936368990183991590741903408011996223869055646554434135216981\\\n    9910784116817098553559838260710720952341222720812620353005611608924237846222838900985033525680\\\n    3533720543835253305671089946412604752723950414460621693344865956349050620426775077159985999498\\\n    1428985417258815700964703929404474140957521827743272993493695736721365383070937216154612951636\\\n    4372553926681918645085131269876189826194561632552070487142912519642052497744664929033241881338\\\n    4777408869712209324402991362017350520050328104671737792522796993106922541763026525323719523043\\\n    2112288218553638104182253708141881050861232504870314746843712694419005977558382412418045119325\\\n    5854773930276735527016258000248646052406813064672146724564376645193940461285314274961011544453\\\n    9010937999194512436384268523622796023714883274419003949369887761745662300484765705861749731189\\\n    0996718718707135568062906506472625053250099498453334818404674366483644143938488523836389657243\\\n    8371979736826418620365236180664589622026799690407079173724796751201443127410081549216968955139\\\n    9823107022511747738543877180950280043953695197769854087762022463727826360078616397614352337908\\\n    6017237375719290886013689593441117821746548526680807819243531061933798761899981263551153417149\\\n    7158835195413679420016773567342700091453090570261519026363220713872601352977804744497957982226\\\n    6817235971483594898533505181113140113827843161000345362464804080524034197481173759863384627977\\\n    7193087340431483308254657361309933580305645408592697004676785931175057146121023154516079097055\\\n    5773389087718414676079410132731348696303792512787993964270781656055753835769384431971647534929\\\n    0327352593357173640168331537915860258151487792382623223179143068002230645699092475538521282085\\\n    8248623549096506614157952897997003571968352075290441341134657267465343620881638501386547980226\\\n    1403482259111480174436886294105833918639161899116540045659027644095620810048655481058021102049\\\n    4530477705865019384103751902676230042665039215139698606874806761298613427472193039980552579097\\\n    7450626132845793453097050265606818157347293098875383875109762355342097914796694957150607557385\\\n    1121895781575885831517710118917451241166768293447030063164961322692814997143300527866292662603\\\n    3827011281669784125652356250567406961011365274142175328363141467372740050917970282111299531616\\\n    6515287691931449919545161136331307107847507570781342843197591102139280340323141110244841075955\\\n    3336486296403716239720345131532967504266168195349996866290057172930733393997875382389567599115\\\n    8060983574818061552420088676249692210021040271093684703467729164513597550463430589430265534045\\\n    1649147284748827462663212565927496426757672123654730992387508324008299506197996402798626730812\\\n    7785053702389461833005174032459168841685553968973886929283175753021313665874110124507167170493\\\n    6915114896870215142325341076356249438383494971963319194718726938771689067344744702512826946870\\\n    3658809360679046957559056799882038817235186387775144825185013166827198496572880037534024581597\\\n    5583257812588622966849987336514364483732055947726116341239398962953988447071261755135479355243\\\n    5374133554696882788974721384300340143832290570588168381057329278540966315746172249059052830975\\\n    2022624744381167325544168552221180684530860418868546527620448047359813738504003051960880883879\\\n    5366749447432435621398967483562877191491701041835210055367121689834302675951603872860194264849\\\n    3390621569844428913179602861432324670865593996337786542129808499035417818282413778973065547463\\\n    9502872394965620743679159951903575561532810654405362854091106805467543510216346168376954191037\\\n    4446943193027712219129684071688779742358919775789984332905557650911569653975672513420432281172\\\n    4630089450735983160048059920309347461758261948528323758682000015472248918602729673664053488925\\\n    5803956708588030102463571324927721843235929825998928993515672878330051491211858626030487979285\\\n    9922314595835296794700792735356683136623263437700206334713992512292328266545367515438442900486\\\n    1083297999116525172286731353964408189320315324551745557735884912005570057150147915436147689074\\\n    8246807310222712786422629060934400667927764372920720075890344270122394315213788893702239336927\\\n    5979883878885938141687456837433086877760818362177812042788927829347860039533646676251588000601\\\n    9997377094397455780946474531249405672389039689719852271430690581258970990204101328562743552897\\\n    2108451659867073560711205026447824299748289013515493738148024418584619962328466644395344593238\\\n    4833501585912313815655238774663686864100667203737214173354928014803559647082780880418865040801\\\n    1011628176517402554368690968000436977506103235583636140731704593838374095335070882696487789749\\\n    0810424337145887075169768887181683233402095429936143045360398541508062928644727423449464101300\\\n    9013580862277384648816412701692978282259034561299215172300968925437253153633682412977575261580\\\n    5417090768391482580948854449908408242554602507459039516713418545777598005074199189749456889591\\\n    1256986434140959989139847505942194084555388175368012294106618582654373489914388718370963919028\\\n    0756237637804254137889259083578183641814447432282696710822017356494473866510116463037671337655\\\n    2414693606696519960460799430883519731635383673554120099378215450264073207542305164208312816955\\\n    2057781013384605511374092329635482228075933346671104503244252616860473236451808430479273059566\\\n    6236380132206640972738792112310307774792717588901582042808288599680194446497823865683858248914\\\n    2670644690606545310869817736307818649603094448795003200811295747043475633329980301176638617619\\\n    1902734853055600825718634242045877183223897616543960254011740940853682694403093193856692133282\\\n    1453030831124193742064885123036702844754448943678545153808571435138924544300444238577380578808\\\n    7577670353412574842280908113614608552767498522966592106848643768244176129451739144308308633588\\\n    2230418457092613400375954478837003106784035221345253227082859021822553580463863271968098798619\\\n    1160540711238121971787489786818689318499797072404318526885424036614248594202026709912171257299\\\n    5827683331836030734610973986561538894307338207056058373198707785212045670142236040209830217491\\\n    1295030997061630569477293601583366152887793992078278943679890452385040906092190977368595216273\\\n    9612126249697369621716621380284452458667969285463178966222325372267824530251058094478031427370\\\n    0488308235001279612331815968949325286281042705016754967315646931128229178659431674190957237604\\\n    8874180956890397919815805974787996499493303658522877951060663828375491144114534986272933057680\\\n    1738984383766004373379528853749770489460874598926498459425733971014414601925135678992216710230\\\n    9071905348446018304850685501262184690241087154181547437456297175375480739350931234850851629762\\\n    9599501565710391898900015159137759263090105693333657399595912450546789549812073351473104522218\\\n    8482801638874202149926456103203539077276695572731012259046405743446748205474594414714062188231\\\n    2522807957568613884070752372169536682962721669783573916374668684348706488444768785836124078250\\\n    5034158448819946106550966282724171308019440326234207735604571405634062117257701334878787230640\\\n    3936774628294472540593094747865452425135820354618131580799538205441699349812307752852671483359\\\n    2912474823554636623892828338391437953432145521139122892971808790295233737681187921811681125719\\\n    8835203587818168351839567453084584805139540704312162714377331066147151239327402171671687520138\\\n    6076820508634958347442913304874804780766825071632739538849438792364912007246329497142173819997\\\n    7122889300535022037748879713309476697148446791919718018857480263210022026022876265462773225889\\\n    4785985186079576774250957589896994990055672811825643795024403164486103541515837809946492027086\\\n    1455019905063114613479599323985075450104609117649130404377223299833147764509096490309442292378\\\n    0674930946277694593168405210142159001352322825512516901581741937902293017629923830835209760271\\\n    1842951803858051187892903194980917947728092150129022929541319159918597673187445054958008093869\\\n    7673040503638304946943295945909354139819172283973348539227998041998812638730496669263919345147\\\n    9912776617365457066012839653705776484809802420113738939005871857595413276108579397183017321356\\\n    2962557661023357079806046652286921516338026894268773828558819366005914509909427699931672847975\\\n    9659566047274185674744195830316277183587221159795345111391633701811464614046212510993020512503\\\n    9844067257025556915605716388721293947147739004292282135092792036438623121223894211497364926647\\\n    7627885487616608048060095767788467606129887991656188342272335398490098968417833998185942496067\\\n    4284989211481956323294870392236671389583416263560241633556268380652722767611543362460943263314\\\n    9142306482376129685587917282937203042286428169375391230539071932879171174995255307278591870088\\\n    0037745170323581544684083222615867082822544468555384671727198410683882257842107736314153695769\\\n    4145989240025169614830924779405680523026026650736069055748009164510834619128717159537306074938\\\n    9688320765638150223826719315193313397419294639082219394210520023671029624848337243049029180557\\\n    9469871202931619140848144938173312189607216444927615719137596352092791578133553860233273369462\\\n    5531740342597743835712534989769358077872854626970529283524728580203190337028283158235520188989\\\n    5754543738823022803525586735810068158068604412512868536953992870011966982870953106547684405405\\\n    1238426204885723992588135582408491870475612878041725048113500897344565507337091762401022407128\\\n    7873169198711178759897092592568855137858427935205414813148822919641919796581190113758727787235\\\n    5342009961179286620930102107304954205336358878368920861199939818937380394784477142390036195307\\\n    9875672657799020281611943850124320688555452089288575809742520323652205602861707239437500669394\\\n    2322335817792923362794242704338466226365859057657133795972258657054224554490172743474314584083\\\n    0447393696989694515031395721462956773488078665139654822457310126261808534380539738955887467771\\\n    6781550451237346086545173203142297274138483280531987675214683890922957922162505742466400831640\\\n    6395775347276507480393931082784906987727201276673267160516924599680049540869279575383401856591\\\n    6064761025878616779111996974987921833491197274972158211976968861094570201460893335126753699066\\\n    8142176205769592894450849326194414195502551808176618561056909139945014752668151988220695154380\\\n    2688016623132871658528067717123018231750863437463210172029316495699641323119999685029197812605\\\n    3863846004282709722967628586326440409697772921372390349994773946648377541665137399511387096770\\\n    3550619918761977014217667562206478167726415551891434586058607292572829205116699992021806210505\\\n    3089917111475745902513024376155666550831499064907433136351796819151909216909873734160601810596\\\n    5883846956407131431297159666623056636464998845468569371822643986599110342340200520379715011036\\\n    5675877261608226484211984175674820903330054785478588935493243416583050753237479757171815165685\\\n    2196652143536741622044170086470423081962412427023281181543480588371904980049528358866318268813\\\n    4864371770672564944089184991000028001133161040551143756974763251907418807677546414072276064854\\\n    2550845523400746488443330674969809920221380769367419055481011976302238748670084091582633670158\\\n    6412083511653521967122815344175739408713367653805088413095150780804751272221921769050966585547\\\n    2296886858794554752762163220530319312989475266910231289785646932916359700562937694447451390557\\\n    6159823057127007441876982358715639497214383161380368570919187920934623983747000136913510855348\\\n    1641055104466457755443226906937683127886527795973019727924460989250526393884995755056493563934\\\n    1896005492005126440348149345443183480580254467236615285505210034213097090730535584306959354153\\\n    8542777383192680149142579507327280146179345193154471921343763690880500503256694830770487322751\\\n    1785025203612015515493113021033606828654705599041650061892583768832700483593973138811549499918\\\n    1817889443204712168884900376164067076315663843956615467311232831302392753794121119760418294231\\\n    3531979471763962498085625794997755347135563501059105826816783431253677183010786767652344212195\\\n    3666318052778450422208747272544063632741045106563443640533145382616142535202958254518758992952\\\n    8748069612325085761950124626504618879089231165496929393492652837996189442401644852835456061381\\\n    3153239336491944110738275520111202486764711912845858442035524850635517450446334863639053422927\\\n    9986623558283425544586733879183124349280047217119658768282795797552165147342794560124693986528\\\n    2063569778500284287616534195568660630862021958748619336631848179896346834367806213761935117090\\\n    3792225136857290245419430498628605412774109732670657305644628118956611451268502525833304474616\\\n    8552205407875327897797985764138678621089773100458457571067942719860551001790186988759306350277\\\n    0160290480308412429271655655061441675650809422440797289500087623576155611149808044919507342949\\\n    2391874607325560395984529198368172321271033991815637294168376929521688371354965867764839241298\\\n    6491062380622448703023503052744801826314163309379771827425209514011907155748293321159183496388\\\n    8936836577200419939380103096570322266956378446565969695858629142686556966925604904740404210146\\\n    2679023081963672026253343973839416052791229750026029893204688122959505564098769846789758547572\\\n    7038960313782122321562622331446510149565287162585943435415404235418449770023316095763875381777\\\n    0356666548690978862177653340364822882802577201192972476513756073579772144835489028494963181920\\\n    2686068327002244221002722925233118718370580862759326714043516574455657603570858402122157892679\\\n    3383797906963764187002082749929421684406545163495857214893695633396467910088845598331507781757\\\n    2498189561232470871036458928219097403815064851476666890434711750599038707183633471580997507396\\\n    6889209323439646449106059999206928406026801820023381048206317018082547288192797091460071113441\\\n    1815935812715661526420836682491730997285964203326580623251252546125052477934979341397610934776\\\n    0068007878998689318046254621044490723546456984819411344837688528485300222054832870202329628469\\\n    0267474685905568617307476113711744732293432391409485239052142776195614634782883019237260158062\\\n    6929912317547680055546624382271848321379598409026142246161345695504060144230022815749578460398\\\n    5628002894527102752392012626540387191730553238598207642404201109796625649034023677068145411145\\\n    7981561202610752996891907872026872365576904016936511419410476432471398696403963112832597847262\\\n    7453707219934572295196353126454786887481189138659536782446216196831466531366472651831015268999\\\n    6738081275606824831467250867117185652492291227805928034335376758435945336003934520205278288654\\\n    5632683888511104001385856771167865947405151278336904788843021760231164704867704109717040848569\\\n    3226532056121347989076985715753287063725472760225936445010788495745566593735948033262856783218\\\n    5344971123873464451448438142387633961145065553050775301648049169026163960977293843351698553254\\\n    9300968052339195884620784939074625364579229192862813153458479689200614755830770443819045585393\\\n    5019088087109184454501286761249965137132059108109729307197876950923225923844051363440285873122\\\n    9254723388322865997566009288608039432960011294355620807904641516247029880462839499710071308072\\\n    3058028975774373311864719039193939212527953360589502871494912515187577265202993478399838089842\\\n    5643902075213156095609436903681552441990185516100196651380028222837947735584473358262750939288\\\n    2383179172814463668508891056458621477756185894953740118960254188036502684399850446125867566857\\\n    8630170234014322915228640993659305794714371085866537146875565223884724476698099947929610002280\\\n    4908395479833164433116673979916275766586551744823803867640492388787123137355905961847136791881\\\n    0787495884653913394913877372650445021634330907371627510474854746819275672934689894258887287722\\\n    8468909698473205708482029933461512197869096983996475106124484189529738322580647917574988011584\\\n    9085426891242343023098042310665207392486336853963516179416478982018338737029738022148773873838\\\n    1358185748797500298163320300474647155638154654079992153311604860585122081730864559782365340839\\\n    5395767296956036070413297788226558555003314066733760481359896018182665563181037589086198407497\\\n    1551304004274426592136382312715553923287754802698920446808398033120721653420960654248238025835\\\n    5971571640002125734255251747333706219123282486901692071135196120874809422210964447871963221662\\\n    1875126237195647750730395903626608783786258148035134530845652925610796729086032956782258478126\\\n    6580950925453606148023309404487857189693919866336071825483531443685184203155463991364759691394\\\n    3939571056915632285538927535987322738839038237972679637438623717477034173835639407300322454248\\\n    1033547006641433586760004981184005389202644664531469787640757267176716364726239814248534746030\\\n    9116647444265683357962299097862470455484316323050468572088678529370327226524882261897365264869\\\n    9655196555881103046276395653516836122744290389542660919315488944728407438549730788014275930520\\\n    0777098776229621265673617474894445380329004240812794627235581103534460783653166535795759088377\\\n    9648878032905008659153576077369322593246933702654772463593127753485410973437983796166444460325\\\n    3003208906904976139845662791471774208237567210501070827521941486849330901170922289505307235201\\\n    2945289258039355610850403382103489609308862907584656822080994217633410804779207651012411534474\\\n    3355545995746669516637971604411389912850616964584095317900625109592219292178898631875426710263\\\n    7897035514335765561086133734488512975680208628529761606416675942687949169587316741214899666939\\\n    7314978469871561090188974188452145663879571183259482410428918534449423355991150143718532176278\\\n    2379076109609542464008095587573607500258440527353941296890091884716068097325878268616259216232\\\n    9076780296527309337781421066623060919906882397490984642933077896285664142696696446806757398938\\\n    7067568103542543169041762653591661148952586754201817730426869597179091241382434155289357952880\\\n    5700683584587674787561726432913059755297751671761324149686624500549798532663108469501682381751\\\n    2091814679199396385007216495859769573065315375906221263934451936788424259723246139977773537020\\\n    1944941275519328446311370621220386570223401476075129806408602391079961759008982960820290406471\\\n    6078632949522271614223290412327581285879459644725522550400958813718081065702161379945199738380\\\n    7558792286982111416585560642071466278709891464445243269773289971066308627151378151034489021722\\\n    5074056218790070207517083759818688957733394564646033962580147419526556043378130396692561618846\\\n    9098984250326906406640072405373671567826448171430488153693373747668449233077152506937972254031\\\n    2428314446244367591686731356437770125614535759071655558322465683574311588616815091722773014774\\\n    6535879997718904705863588638929528930778334765584747336879792741308835303322434029263804824253\\\n    9447886764258955034286261078603783862782288579047523300101714227269440057299559358586563255398\\\n    8604423929391162659243784652853184981404099587339150525692498089276724113522268934538641864126\\\n    5451893019297051367390610955810689383291387658129655030622902765170486332849850910527463325292\\\n    4666945719299908657817721086464399020569714016744938147708536785873895122588215676419495326969\\\n    8502166016433913159111272289266537644424758313984759239097550503869528667123865892283830231219\\\n    2166840498012270867802868463846653864689042707955845668539102995753747860042084254899709324678\\\n    4649070815985521760246005977914257518667539702570318378954469919429655480060817270868703080764\\\n    6684320762060623572460165016641571043632806951136965279909876325154952742379660673720950815335\\\n    4907667516933736303248713218218273893237484273437669227542023448058019268799735540153574001033\\\n    4631930814633024545510222157168573431209699018947007218090669675644036029007336310849227129961\\\n    2212308436611552766079523742070421326759430039769463422780140757703794416556371158046456431353\\\n    9530688505802429603953293442006650221330654218132052705144986927155948729091352952091112671544\\\n    2386600737410532150301235948673378078633862784199438459643963523792092246113396211222670344848\\\n    2209474319361067845222870633394428028080583279423382199203462863903063557920728318138091697763\\\n    0724009793721620559542628773238615787304696677346385288009634102503782788641718962899669578672\\\n    1784532080701625970307124213238222697716670384355592028261289609964103074110029278216934827288\\\n    2607397181672150101810801164904982702791944928044560554906374159240721324218317375813621911980\\\n    1441990643302670713541819334250161981088744583780651389951238431169555852198951905800323631199\\\n    3604629002209926350988532105314555985459825131639558419798271610442874582093325029113458396133\\\n    5324925474251710101453716737464426503457979328774914834198670628613364243211499537728423756591\\\n    0433182204969276084773634825105737187280914118739350644920023798012784868063905826502871733744\\\n    6227047810958737543680871919146958861934729590274744075363222622274503824684266242866053111445\\\n    7168780587078149646715196494365081824116580066801673828163022403201170688483855558757538124844\\\n    8189555839823582342289336670670579883537440712182184678288248854921303292490972849227327668066\\\n    0653114404812515851388919794015550379581092388571620362512319177676928829132858094898167291144\\\n    7342937528881518855249859176761864962008910065913807398053005002437218505088596766444463691957\\\n    7324885826657202253551592059086507587083279894911776308498973767216051222192643675014539392122\\\n    1447573260442201660377933034662081694668034869801816834425627376319870388268358989271641783167\\\n    7274308568989129704017900842472780855887551406245423096905920476374330107127765570460764842476\\\n    5771419777511075894292822826492173139823798670954430331066305824894141132809177940900632614165\\\n    1948796910238286856527431814679296142750558357137405078185166522115296697781391683705543872180\\\n    0411806279729193364975719120255023798822919531589334777025793224839121775393657544730618150009\\\n    0700797777935913513543656659634753753857388126243831470768599068819451568306585938478786113490\\\n    0762347703670778637362256436748198337759872610603921075031387270012465692625040181900002364127\\\n    2873421656036287939518851588711968092754845853427693614547598605978725822217597710609073249370\\\n    4257450113837125144941052141921967842400210407079813633566243758370571352508192142162597892795\\\n    8677095052475962992312860005799411528609407520189353465623876835081139546030849726853602611263\\\n    4713947263184515815423498338050709463110638621516529770799009544603800681013954217593528379197\\\n    3037447945916227645891945499104909989949054540895100263737449246119308872292978595228844052494\\\n    1281945770203803106887802150140961875405907542844635847607144418826858995018892261829120993407\\\n    8944135040734076280337875242012905874000458176528867072176093125433474433907902739702848044907\\\n    3262137944219644388227736270272825284098564021107515512382850308231250290278436357579357088044\\\n    0298738527869730173801007953851640555510877255528382017821585953749709610281179111619549474507\\\n    3111044783832582938616459811965608656203802667106136248541098946070890542719879928226247478733\\\n    3240917568746340593475691798775110932481165147782874079614941607599423197298453259920354562218\\\n    5249072179046289218448562005719587733998568054554161192119724961816391985640268319443879873757\\\n    6228471382162008555426367535819410190200844362997574733313213702511106209318311204690231628441\\\n    2855639015965127749285613895886746068952560760404853150593383590329869057386082877522255854673\\\n    5453420153529655368613984624515373893724599105290614419323932317689426485309670653415460396718\\\n    3730371294509703143053686373534142175411984486361390689049024655079258637854444737009166851383\\\n    2538638266896396765686680317594438099269175464029784794310127199945510286408167958283014040993\\\n    3809451513271455721309217374628927780695432465210717154476006406449251842872180550973960765859\\\n    9690912126269156161253469372669348430175682881993458052661655188830436423821628770644495095329\\\n    0473415666105106077384647844351437264733296644856325621859082119459950338538747518052896412103\\\n    9019563754398651964635328005733118902904788835674626168185096228036564981371719092710555194152\\\n    1036074399444458403222300318251094087498931784688573566353598723082643821201717665013987996037\\\n    7331488415302623221726225404925057831273017050945698193003563737797406312515111477633937977966\\\n    2833221789528353301188622812868917513013731735978511154929570100727996099585736283564506842770\\\n    9780051256654851861838654930673209088713677576738327796368371318225082695135982668220669680718\\\n    9144976855722505403423767972857026773858183077642906551365622955713458999105609252401050777462\\\n    8925459172826756312576531679008496120915135092290104317808918532904087228009608312189940066064\\\n    5883384353250748054995681474337769628205165458427772283580971815104347842060613830957733507716\\\n    6131657102397435433867977303486881032927805099000158827792849866748750531098509437848043823587\\\n    0438661158001197975590579363123804715094882300352045114302922215835179147009151549782685265262\\\n    3377142906676809456230607102438687620054946368753114535772498925216034544232798124039221120801\\\n    0045749925500284045502269346326039470578068373368675631655877543880967755147651958158815549085\\\n    751310679807449114647947395283799401\";\n    big_test(Natural::from_str(xss).unwrap());\n    // - toff >= z.len() in MPNFromFFTs::apply\n    let xss = \"37203238424405906847053379867752061720711530955358099105284136369489423915257643535\\\n    8667028900090955247690408231783917472205457731684674614821792100051297717492262897016144066614\\\n    2316521983310453940252945813268753080048213512651939423446860709132230486708866556667837115383\\\n    4364543302221868450447290203008631880746283617117084943195737048507480709082795310820160750644\\\n    3003301090425598131876007971392197934781674815514017972891069262666664904180319224046949742123\\\n    1918893404254121247440235214250228914875289471085124872316249045915738874001699918594103173240\\\n    3833100327450277855643324999258530248245112562193979789466571431705105382102169953766413057439\\\n    2593975271361451878133338945129817421034466834090415636069432322426778863652428458683089007272\\\n    8362423881881860523230567841038715135958689095189098953498187463919415407325958907739864837076\\\n    9508302583680320566631875001991056596451085195433369468680424304984937334105088464020020704492\\\n    9573092451311023349678583190056714744742968361971061990672391016449767465466836538435973183349\\\n    3419437483003721865487011523508867277818518027674573771806998361686075647188945775575058865761\\\n    0177952605545244948199849382225695220159081138830892454343229997854526905354426585869527015100\\\n    9760157565370181401581416137581506921087104785378947349767905176575033840782328925248100351310\\\n    1117433817691395944735566088404111421813888485456172535235702938304911003162402279018654882056\\\n    7792369814672402415595664952735693733545056500880403234218907924637224764577390468608395948983\\\n    6984710393618793260054349265328551276808512432125804121716556007817767521504215815027833042208\\\n    7496887364929954405645363283138955686967594264647396626025062717473500870392284408181545337222\\\n    0175983354169294693297894776530587381290436644581052815012177466237526000005061836550817389225\\\n    0535420547874483662355425165181494089192155166451805887303498674978371900436575145284884252705\\\n    5067018780630906741022756945563927101651173643971446552886390434534654109903661556564951480048\\\n    0160905959641864549070388052886674778230024934450558531497792802352653311501485392860935285756\\\n    2101221807950329391710548406043604236576563875056446601858766975127597919823422004252447863396\\\n    0334042172793946593084864839007568297879587644909088346461488211292773631390716809042553523055\\\n    8432966603364828146859026256848087528018954622436651613142072119577416762581459569514205922458\\\n    1854724286122754624557630965126453391104338282170216851769775839855799186554457339183046727228\\\n    6986444937394119292508232629211464780348789838915391958443316150109170332887061554719600413831\\\n    0051376619616307464865374876807884568320425661563703097111858313359720139061744733623704532285\\\n    1978880435215840467968956183038466247252733360463436684272497063979612316551040672017937100021\\\n    8302012112595319294698557555108585412711894744807146822467817872851140377988646497627133880016\\\n    6899720485572181928539773946436714652442931110431907091919166496318215219591289028515084638553\\\n    9033584084770500172314717918099069313270247794255084102100344443060007483330321612615341954618\\\n    7858197401755348744140826129621711117594470331219560100838621344962142355667718550779614905356\\\n    0123811406508451922988861242753944523381906269795202349663207043705925644318342281211962122874\\\n    2140330780505247700909924187256029344918505465481231094755105128313677229196438862110523258764\\\n    5777422123454120722578374784092641173225483875994293087626613554030329066687900319112521812279\\\n    6879397487613866519389017915663897239601094283836425589289065503809559419659143889474783891388\\\n    0384684600289270388283072087335990978589458533265727263736957390582014876537739215884269250468\\\n    2473693040749706714900985130293419289037070420256898521218545940773915792215746311610857982024\\\n    0274938111444211225745610173029978297425651146954685970700096164729915729053002096604867974034\\\n    5818050565777584768280807885356813602173054195575503058304774943128667570762933019056652440199\\\n    3296573275038569834775756745231971926539420303622777956474824503999568109709080379226370735330\\\n    8730772300204467190962349461788579975878230736074593283530212041976617454693114228511631334286\\\n    7596731107073069764514479353520381542579916795828763868204996960491185998871627013453500958656\\\n    8811878188008823091226664199807193215795904899635185253461979990270762889999994567563192600610\\\n    5604240384486374490821148093827956753827949970329714567935664022303204761121098550974778229464\\\n    9285534281073537170108922960868657941496709346495979125302815700939639893528550375898231625458\\\n    5767402205932021740136996171594844453967614392625684259077819218643880044843258204194297334424\\\n    2543117010945604332483766689730044641397221352229067188598433977650032613093688375532475190723\\\n    4533877534267921321025547040593336635792859339527913170082440171651156949551829593098112063520\\\n    8648547418752442754668349915365331371380355543883550084262242917874626324954358089136366369215\\\n    3557031395898258243132463040889508558112318165873219588782952176926422035910697728759306496164\\\n    5509181537241625353940750239354014935629646411903842289184638759338283512112652141541280528888\\\n    1815261057211460948204189999990613533658523369347118562662630188704311612461534616620995792907\\\n    1900509467835999607368000607269991818133609680907744023325766501793224359214277141816600126308\\\n    2745078664018422648890958982881318749680939295960634792397077329983317460920306249126761937985\\\n    0113243220623718758450538148704705687170004896120507477584503663633483736043700313445791784462\\\n    8972280802766563061876286526198326652327887060275450048673251385891967726248306924324388297004\\\n    1678070732856044120867081363097909716728332352472479236695468434573199449989767892391636207993\\\n    4239372405779221340674884621861646157544087188181914662792972546629619257720028750168692639786\\\n    1199009152839830487761181180821101349093547617708735247055094286031085381817283053714408128541\\\n    4696451953109627543033903509616730076789241952341754460655198045218234159506742255486270434365\\\n    1552065824710538244284963364664231744921724024583395567816470070341175361692265671307097750109\\\n    7815481928534250097442335175711125070283960938843909148870853583037385988884029095361294526209\\\n    7812090300824433403841120058234784140088899079532919482928905591758143439916791418952390169703\\\n    5645636380663461143687141206135468246400452197652884720117822929699319021023841076580864060715\\\n    3860683095669678775292027362251296657497013094387154258988011931416753420136374026537241874846\\\n    1871419464457723123062948953117330961657025805183277964710395265108730423097099862255719979050\\\n    3269482865317067196747451377954265433043976460858360012430491237957483155869687882973013923646\\\n    4646112708810786631185429968227344123415114724697904772306639410464852484253638936341959825322\\\n    3520860343186611713177259414518338814079619062510267387768242374164792721015284986087596099089\\\n    5906561387626107505568857044765674983582659462393315452602118312161699933408453266216765892770\\\n    4526065749494506508986993323184565394844653646052571152406596789246703498482904688277741065950\\\n    0904453696196705282351152972368169083939859978848613940533995375730859454334863610205925925262\\\n    7399643168351971299087782313256793248122164519475158708544248792177001313264894750944632930013\\\n    6670727426003657683252560397176532578304163947235497799188522686440109123303723251016849958391\\\n    6794876428975072881024635442291321214703206479712535413142189896271774655977120079611494824550\\\n    9305864150015722366890182177664337435710120646522002422023212157846019035388668028830635125331\\\n    3134272496138384036485281895811244407425434355634541878264555134410907356960605690853311474930\\\n    7223361741758033834004177777350452008682311420983394538243163634902732930635794607871585795838\\\n    3324623982342751854894166871102922202451147002130334106940543122153410920044082167474159863236\\\n    0016147642701494175723160121112734931917618555611005253034348170597802545360604756085766365859\\\n    9711013629930906411578373956105703485397753251085537332106442377647178678492724787704741594344\\\n    9856889070080951885047440819258382931978519232997560416814610022124285235554036009944514029602\\\n    6938156269935538474006651645211996020491681865940688423271819363046158308042793765698924401379\\\n    2050532559166305049967257028332589594723990843038891999479734455915328251046028832835237359298\\\n    5972388041564953971031118072053360647955069432082278864128702826828745529157951314636686828004\\\n    5939020855102724160171803242598104905839179824561833824829582452309953252830822681991457759116\\\n    3036706466848280856167736167888190259027705756802846089303539930783529454400890829155952754039\\\n    0199338704565336653048240132303477634392020576059860943972805737202235551797936866862671110658\\\n    3760149455492109309273408208654531269450553454808593897043397192472645032350332546038297205981\\\n    5843732300465282221179854903164343984404355643424031020175845243058901570376794732650559346596\\\n    9872951655337965300520962999246402474406969951821462337299483216866889348463228368029181283353\\\n    6899538143147619119916093908251200846359074521153884703445460035267062662754844498634515310378\\\n    3539680408818384249680403004513253682907686085578317829022065187175392188792941359920727830326\\\n    7366260783779906911098791115082381330289426333709955634937388860204047047836085673365888720780\\\n    3243150214408035769874054435727164406280583273703036575741753004124112631667762140017908181421\\\n    5436445247200046354246509522140136573320542988245295746277524529586532330286750225810521002714\\\n    3322046047515956038130102299077751285121016101084041531165625137303507766558487734457791578780\\\n    8729452062299804540817451944345922463143003803830702341826335220591878267265069098704460747918\\\n    5194950672718663936311062832431228245252729700993893958406730273252272899559423226683554536687\\\n    7224049109070752148686862858824836965496056776127739924156244468247899703253014234227922933739\\\n    7880126921007176509980037402091088195999455564460720065628582736032961716441278034590606676122\\\n    8454872353400000716750508043191474409711863248334138082903493851829671467411069452689659740457\\\n    8959351920442974518256668132108852639006008011257233985156391619649842610805070932708208390598\\\n    7371391954503778749424175443087099505465199304948827220263626555091483857495760215140717987927\\\n    7805863738144504307830552438315409140389370809080959882227796073876049563192315754566537822893\\\n    8823272020418182107860868231454413472318840112458904638171543103156520057031470817278329113117\\\n    3206678915712410768536490832712002243694895028669645607925656820033482337287512189720375660150\\\n    2750049683011800914856339888557412447316677933906739189714301141661059190805578414599036868777\\\n    9444539510680450661135183378122496607170143726804571599339764858532104126907665918896873415616\\\n    2817202225764475630022904826673169837237411600712790559696039472736594752413268661817959730627\\\n    4515227728680215145621995763048747729566458146021097367314226372753551469651764431889140671810\\\n    7940289278725659058498055862781689782487250668685254190564734105029854475979902010273741242155\\\n    7029648749747048537270299149580067981752759886909006423694210139392209303631437551938227392738\\\n    5768391332873561136982602394598690893823274944974487733468570936226554700953597956024580420056\\\n    5133300127714338371871946054703369521654236812907003039706376710588578775362788234983645225350\\\n    3237222837277278690349822920366237173695150037594562033472948702912788592169560018024876402701\\\n    5569673633866434896416375183634096275256415828765326582646021664950807646974856545575319687191\\\n    4703419399612567776150602619090066636659518530900878547219309674742837337982911069892721943493\\\n    0855755897616057211059348926112704207005679564050245013636048559721937817369881319326255512675\\\n    4782870828320913383670435109336902336298399487043229666353629194362235977051304560955280015917\\\n    4550098984710012319799729737232599314225262537138171454650930483517247238525685295717429110201\\\n    3875035530693028902474184113324345280339088075934304784851304002378309503463471328118631295074\\\n    0779768407714925343744739081898266430456585607261049590055505139720349444997189236081713547804\\\n    9681469386059649716300110741778762856206442476689741872706750585504986395230243510942118569440\\\n    3722481208895073568871345684923580370679192189367066868092180510742832843222345684396996851809\\\n    9587782661694942537881183443358812575776817952188202910924346330256726297164920177303395811046\\\n    1643071243535067918862356375922179381367780418954651299776627784747655659033982583340148305206\\\n    9627759176167774068937993859908282731339849901392328688456434724737743079343728966739226865566\\\n    4557684105752736501274196151590642167146080200535688344452175649168437873604085603907686909602\\\n    7926156790138674768462779826655235376057249029788746250433242833040739552691122169102631897927\\\n    4496233388395127423842726404835471977880476077060923388748355855039236494439827768749850312847\\\n    4710813640723743204261003210393301560275664019475536513062403886116223588140707183278633954521\\\n    4544521011543847989305104830495970180462342393183664187491835518561407059060233323494823644483\\\n    6453804727849442681840553513006662371686243220405318160792952673067418130189292748279012824650\\\n    2094792001284587472315075808547404188049533880992289212444191530839499178561708531932814581820\\\n    4512317141019593941176821506392403805645018019765104337519934636271825246155013199802090028133\\\n    6883157013340441536195340227219970783006893893259656828540201226226389622379323562237646704269\\\n    5927849286055216711655517887982612785485331610164298070715743991096796415847484491094541381540\\\n    1601756024977210494535136927560688306275596865122102916805205322052132793411218260805566881071\\\n    1685417585409983941797756890094759885141446634426070743915328173066794319613234057182242107342\\\n    5126627659966906017788187689026753451468573465950170364840432442909518204011681990255530111318\\\n    3881274056766226652543582407255857420119094234809803438188222523335301083158631965423197439855\\\n    2781500528637386442305990783704242819988710703562677393120178000015365788295413819956747535089\\\n    5003550363000967136769453228493005455569574524186418006221011197248590161073521044074492501032\\\n    3474663958168160772402596046031155747436538933060502147792379648709358454295271838128813173827\\\n    0778442797840445939257942437493668322218610145600220087886122070928632885492695977122311938852\\\n    9255032542592200804476303236020040344037587811301543645455080431160454541177136615442403238259\\\n    9437938612184439476626096477677266145648632249174904462700198850694837777852451575509510260307\\\n    6169380973394795071085926580452753711249735149335875160416624592789374829619072589057880015363\\\n    7918758078096726790169586012360996999506701279423370759161284056444150665384911906524597777864\\\n    0670057195856331264827382550945460092122241409404736472994333147140596007596357572864771151812\\\n    9720243216758390472851107321745257436244465492224990937558569760294962036540635430260389758708\\\n    3024934918496488250944672844278188609886773590741698429276982098078165480374611093021516853423\\\n    4999642228720954837074951394459724906390823914806550419860295387784841046096581763879865740953\\\n    3936150147983412549674216273929839010848925422949598282800475974193850736352524895963062011069\\\n    1114571713399158122547252875115074210051104095517445044455310666247016371811987199978427563646\\\n    7460734277233921653474933982625962578447205067015415571432273575319686510449289360719283953456\\\n    3622084810506660716149231704874736921773155035081666698835143342695818880351448757612959270716\\\n    9739273652966253261962998341894240950912321182706341152069903190973799834322873220446790778232\\\n    3550069263660913999408886327822969976187118721245561672863598990790716574316626318469346419708\\\n    3118066488575806174974019230116797640579162539786455511621555142889868358322597407575740968154\\\n    1020251656192819543084980893458146934502093565392968961633084430408524568187740761835333934605\\\n    7299903084103503880627460228477437725598097193469122195491942201978839225721819674128053625372\\\n    1900372005658272156084784855981685119449899009284829431511767695410683401005314710898686341711\\\n    0338598689207685560055327280725086732201380418080040825609614913625865693808617035277327577236\\\n    2869617558000553194791128258818387691054729135936099382866628299670546534144697612506577723700\\\n    2706843952202551467657689782986809823774915702842771122782966843422840206269430362719984640080\\\n    9881978916447729449011655315529144764723188991564995379368939850604442692051809889207808698234\\\n    7764628056681096547564849640584360362168974964002443269148112060319325281609130104372854716087\\\n    9756178907348581812608245660284068763529869256335062054639411672643840162843674649238014815318\\\n    3896331848978254070248114275651948649306299541996181439515808774314979881370011974313452025036\\\n    8544653327242707112047356710224182585089343019257273007922991765938282517460994012007031367820\\\n    8966693895090759645297837201447763913216139584343382434111563432183343435369089838153703238580\\\n    9497419395913385289124620430934748596492643272343646445941680423689470539838055071664662484865\\\n    7984989776513211711201229817350678348983971967214902766088263869016076706386814794646769462424\\\n    8277713107907720526194121142400684516876501024885778744889654588192839934239594220264939723426\\\n    2556635204320751462555768438369836831732232713354197052241936824411599275347427028035956890667\\\n    6103166769550361151847548100372670278284913230520155572039306018619944556386756467724047697347\\\n    9627992574683492731273430039845028912557570869015707091278698919154429010198940033197395146568\\\n    6275923133320751237253592443819500692073817355714514233269494488761906558613869761621613392427\\\n    3801739133524747805190694905791920909018898060438363842360454170639811212845969788663327448173\\\n    5090812872447443915606142717426506209271745835156335645623850366603142711983250426539402649022\\\n    8753004528767305354986188356047033626472047558106953920923120862056667848763419407781926539912\\\n    5554585622266736794562235032608327698612838044178614007369539830616204154648938358721982920298\\\n    3819275981817075984703956838723780115479349364986873234043672224550490287528575370468776912823\\\n    9051442637528958711242522063872742196032438462069511606817203269386550251662491709848806114345\\\n    5525464278540814983368045545703623266146931155732182545467769649726757444823464612795415291097\\\n    8596232532192874953222503591083709354353849980070655766567370638977836309499422957642676496770\\\n    2689778468979363362841924629280267571024058381489902331988878110839403957824318297221722125854\\\n    5774538096694885242367067257875297943871986980852174633756988797404406437826309032813345555975\\\n    5899811235648115017010590837510819718318698292291700933401381833907570293194551049079219983292\\\n    5839595315972731879778153486683922468253030498472469677537055089308881781896574912836118567440\\\n    6151354569626897705187198584517601924318372874902460260078483744572477958933772706928237740836\\\n    5938732013306796912930965990912244077498945826090859377707313347244005676205852272278540298870\\\n    5198122283788831668659949863155960510501271709951540498809087938460345317024417205036831663758\\\n    7397919094072189749816650071378862274308038733086134042094068097645081246795127438014351917701\\\n    9056269775717569485656157769615805305986002120669351204017691957650572696636646738397302252235\\\n    4446976536327279426666325453207257310476057809269202065022050569257800721459431783012633248972\\\n    3218674363849078032035066152261901756778088144513414452092721231195795691469799575779509903737\\\n    0178721782147044286758927874533329868903871746768172166310014386425532699397276671073364773678\\\n    5682673581913771236949258220177354425310319073529392172568850845616936192234993501750385883549\\\n    9747518340967854066275493079838763685798325339420926406314778506483188874729339262983018975258\\\n    3190893337710530122524087401572510138434418255226123829377677336257125874463779395796847897227\\\n    2457763118157896916138829257579059568359117640192520620848947752674737978306617080842314954655\\\n    1034027525693530331026261569230653107277980335690329438936581392001221266423840095922361733798\\\n    2472391980276262468489702147490382270657881259679445378067524219930346292367658144325079791254\\\n    5669821770082789421330876109345807345302101436958083030589440813411629586663089043296019303704\\\n    8986937867610792598427549822080017423296791322333899126996365550999397153245056448194270157024\\\n    1426133055538315069317452467454916712691385671034838874909453186212831476123643094218177466517\\\n    0339556887778856551687265004832379475407779076928430628301565450114442676642122255543916325893\\\n    1421444478830514190697186165554195580579394888757534559283867633815230897083606891283833680953\\\n    2907868846837539708618612840954325614366804105178659355145424075407775224769204552834008256659\\\n    2812787914171655238602578441672382242187752416615954178768330384955605803081588393858672613807\\\n    4471240261386943556116285100220364253530429743661702419175928078987834641353006472838329106569\\\n    4708953098842263988698459043504520626724765799801340087024962825873679324277739397178742289292\\\n    7297531243558872985129380683174918549294202284949554055380881047386078741250671617601118312441\\\n    8312575099326335787424438447303638081541406815643626981794889409937814582821916039735183440729\\\n    3723854851571606196114514439550631993564352240133153927358062650453810126844887639988288769282\\\n    7718794891004029856581641605219708442398890748392727493894849886682648524570717684549994111526\\\n    8503733711099144029343347576934360533398379210349348651760908097639833881409135430250221153305\\\n    4444025133832439061066544279393356933990792248621672200256101471496110027600198546545424762519\\\n    1039454039750697429589305236549940362535220527969708895989521648740722046083638272687210176635\\\n    2161993474025312189657084764212834692904000001914235294581922067812878818129832802414492555867\\\n    9317060686416366340259804779611363003745395892510802510307083626893514722227515732041625003770\\\n    2954558070385549072942179139476069837716615598734207577085850006643967856045783857506542135803\\\n    7980871890063668116009783380918088221172282517296721365397487046082196464297429261995957767282\\\n    1025396630279934630358425462719141582496797575333312994486678874809067968440230324890647294201\\\n    5475804027406981828223098847035903853282957890823833927984863529802301575336729444425350973687\\\n    0252839489973324040954335756550263387941661372462142556221945251240098000088848899650943974696\\\n    9561208531785468869927696458840340944389048409919204002219674482865986243296479321561576007609\\\n    3209638463156741858585795306132742804261245219668133008719574403805587361341842862518550444130\\\n    5857819308264988857346249052405883202488775750814120001364816978106970020263262566459194326803\\\n    9768212150610334089454048322716416969618571525342262435058185428362705265240339480238486102805\\\n    9669767719899390328245757249184471182951399005878939523684499017284833308132142188335775348007\\\n    0458744967811431754910400485248745246982127763255116632761936157700628276896159866327966059470\\\n    1027295667831083476438834402089699437097154882535246221214810304141316594308764233242496106176\\\n    4728275109123270372948782725472161560199812682534921712479525692608279650508095860599999848762\\\n    9589596733504363204398386979230877341259198394067130311322050708636222115636806783304127072850\\\n    8650294298040286434369199681972990087645079100625269625312637185473521076129954600671243840576\\\n    1635281668149787882692379505639208256312212216854252738833428449082677486415211448706832110018\\\n    2205938819392196361618739130106260354384901221025671972595763845746700121500651331529356641761\\\n    4991375827023155402670204148482799435092521827247442321814308611257654199306098923886769747578\\\n    9494992677843243893100391689740708049463107732899563828684597168505492419288510202161571972129\\\n    3872182571984977152265929270664349629828077572199127123236279265918438306285593961283742324384\\\n    7080490387406457723928518125593366931004163068941406113236414082367657104455645319869793505111\\\n    4067919032306112499802795180597644289141599493849035950534428810416537800005328922155494736683\\\n    1017981110965663299681339955613660644330168918682810348195331279991627494169740883125072356835\\\n    6699082142592353733794397576891018034446143767654482175820886986990806155009954609578763010248\\\n    6035275546615398205076372837844788044745390363373838906921858075148221937942494993018899042169\\\n    8441404487548765836424510545143996195309994190274540397977393758987627210617260424689406302226\\\n    9623188163951526830597786811749350886909246569931891521299930514402417924085133495386809044552\\\n    4304153957863868048941317586656323234965734067957881769730529050960200161609874396502142499504\\\n    9231970256645688894194010081978318972372117839815781611824630435192446334416078555924647477890\\\n    9407048861957876246790722012747727206648233530508541363792577874873360535339579150808308969778\\\n    3559709724585996467410168481305149830647380444131464492708882033344388129792395898371998899796\\\n    9754428098727029441000633757244104582542593753388525380333823036818950911264053488490452576126\\\n    5480359167927742840559208941244597292258252456803046377402420509113099582452412520403431617746\\\n    5170034974889639151393896073056996885305518199762437584006966651618446790952688194178142308585\\\n    6620769309831641154243432778895604135555795337125383664136452011821274244941049479223091995828\\\n    1305295946334347400817506259226830756424139236463740644243700035337929472528362870356145449264\\\n    6907265118094489422374547998750915843184277475067556019018926424519646884907894037401336636382\\\n    7819170575866150944472124193825792826600677224784039172428445050691556440142396456094594345407\\\n    9109392671380127158695094703855123249223911991437815042081638722965211785126594130903924285245\\\n    5412976894825479307632802891888962106921683714634015041289336316115452835374309024103013514289\\\n    2155211895325381973637145421297498065481720533152234648570074637479014533648065395809777189304\\\n    4137287975198664339577722343316563034290532135698674583158552842907615053148615181728050231687\\\n    0972335877322591158315899125761647575551677529379957949552608628571029358597609353436158461949\\\n    9404401162477741903671127609705823974989169661458510145677680874375523240585628124197892110930\\\n    2788780744075540727128807045224725709505926518134227891610648591507068281274403450781796158672\\\n    3808360794542619260878420207733590974298489971469216118783452495659748573959689158893659436640\\\n    6450260066158092646582790682129818861149776946547681677848377653003084987583351739245698882357\\\n    9884320079127305837556344614451984689717810225793008015089315028787590035458174604142849050839\\\n    8603510456708724253087781252777907576074744018373765996216091654647432714022787746172989097774\\\n    9094814678397304900697213889177328609578751096338035671414916279191485122477496563748829969292\\\n    3147659821590917266317589863391036813045533522662899215083154005161102308235401238719451511129\\\n    3366884784737973023290685205604521308622999332891468039975910537906997133891701919948453055470\\\n    8667844255592377432526364917078348362578662204674003896713997220044127189405781662639368143426\\\n    7043775060200910658086674152060670188239559584864527581837409162289174146641157486319283056310\\\n    6999135606809689314451555221905441876980691713505154411847809191493461533915750464721456306559\\\n    4320155329896746403371770753913096957825185075854226245945316369006785696398595489463288426041\\\n    5408450866956954364969474230356272741061278994824200937638145645057446912994098928325707716436\\\n    5522151938903448758411767566540370327729272963969825182692465447216194128436897722007703924073\\\n    2882997897438342809309284890190146020692761740484000605041219233813822958812770156577632402633\\\n    9023886720689147741712384847027670865155158342269180091962020943243707562175397530564973902857\\\n    3569404961380437096653065318033439553321143150986568676984939225050686244778403993911878594780\\\n    7315900592116143315986695456459569142287781383629989146858685118579095823494871335610640989196\\\n    4087950117318705660168768417956645608660379973273413553096548573007001729654716730914027940514\\\n    9516038546916551058607708019186099021027431225482385633097235147484733247433172616605201067856\\\n    3376395591094575326444412250095374249358736097755807026595530010636261204299828790396368175829\\\n    7062661025402424683595838213086957806160964518940157231053193568903474771817471119948178481719\\\n    2654890998278138934094095225605840384188868090009743555376827191116907746047326497728570489981\\\n    4313342935518059368715086469581214329283140780595442672967183642894679457187267912483200484023\\\n    0348379928081800911420675117990360343995776135825241025884453544544345725726017553629002075967\\\n    1969302651111102698839124618389882201351333539025151161637784413389877337062155467594116447962\\\n    0938467114458810740905721238664171350738323038614913904410627140268385167665281275974158067967\\\n    8725595044293868281728221625089744635901364119696191799468910061915465373709197574881610206445\\\n    8362061156534952966294006334799826885220576995520488298825717060164448822406587873884801277936\\\n    8256421090568543306635861635874031789472367988855610876895817581057376998560732784348964621153\\\n    0222591862754173052500430183138692511625436370247456567817368972860610966201105749698685084629\\\n    9958788510294476794914129492368232585540940303432251191368246688565967359370348823540366166226\\\n    0101975451049329419715328871731339340711120770183976099378103643618068265107437817724924927165\\\n    5860169426282997348026245825705197108404618599986119973922822771584761582023092161604829889599\\\n    4236001969903257127319017868376884489656151037566906129224118478304384374484577628364745535050\\\n    2922893523583704866615163777955065867351633907465919140777209921484715773674753443531595441250\\\n    0811269335233901505007497453203198599680241265936052058525712932871744550526345437154160415836\\\n    8068993261025502435470591455648970069379252352307614248814254098797165806814561191541205595751\\\n    6405964253716472241523188074234858092154718410322095863707365703923987458456988837213360736515\\\n    5256424966822898612646356874028940752875163098187046601515895338050957492182917082811274913176\\\n    3116194693361687979206886440971403671521734630604982364546257070741608514216211576722069955231\\\n    5308793181632642462194360317011050005878478750715896127919786070803132333328975252227656143885\\\n    6714507925765794231998655736114081434592625232016784647740011219658273626804162350912998195925\\\n    0764344942055513273487067137095763584885000728367385596531207877409006420372928586042961087181\\\n    9031751592180531570625222282453914785850824422044582153599757939220761466248806769937977454653\\\n    1567036555863027217981754010552455192751082618108443219517422696953527187402960840020202551449\\\n    4511541484531742411748814066922141398742240107833946599778353151626573619596902207021632282876\\\n    8316769510256358982741469600257370625741443445183674144618966235710017067051591244161266260198\\\n    3511561229818727560308462581450161047045066400855563602130019170628068021016762337312108900155\\\n    3865206739376173775942918673107982049837587541779233024823243607656379276243066235330556374252\\\n    0377262754356920726562390790861831381813796105919577481952826879432742478649095447714888216201\\\n    0452939130654767159229827000875411700393290185185599380566407061745642812595571633690854445298\\\n    4234036444328296841000852286375083873327899781680182032900288925899244553915160764223983542050\\\n    0551238707480159051057280301164132561461609934987734767206856460012682349851093785142186666012\\\n    1926483571858093141409629092419415333964011947747122234188224362112100461467180762579837882951\\\n    3229040862417895097312572767594606528842672071826067601652704824499388350630368792540996326718\\\n    8130045211298300600712984671926969497298130834453173354289171213250109278940768897482479384404\\\n    4752944362188033258851639254893735109360381359175732828109138092708407379627295308883358454951\\\n    2383099076030561176635493645870577321275489250850714395303509000221105318784151147853944646941\\\n    7083175636404163419128263847701336403584783583671826802485879747826044131742093987219098042486\\\n    1986231062852277946569765174563950839135439770235781038052855764869708642576873357979771327064\\\n    1784816328793134969226582980290191235078612978224887623812772310550378298365490971713904697545\\\n    9006459540571267542376738156586724152947946328086338358056383782443955507295544847224048963221\\\n    8682763652488152405945072529988753429641152616067164621429343475348736270664299146376803204981\\\n    3030197658198881597959236664109111986695320326705160718913146042376804187542523029866615905622\\\n    2258217481287463927327080501106124700005439547620032297149905094584503967480541179135933891089\\\n    6318453585109923515296534352365098419366604245366914498932475518566847630764561455695567942945\\\n    8827443509846623704595350470254076808558138920375734720961745949742830738987186912964689664457\\\n    5633488712369687357153705403300242986259976286164061247403762798746880810250636545710051688121\\\n    8702958841514905347335706797753885537906835431050114635739743933895696640194518174978106101594\\\n    7498271912107339662734280623268746520969714345433991896276431789002517910013893637393217329662\\\n    9789262263247540121868166436996073890079538878462549209747211475823230404538059083000373747535\\\n    5676942803653317334344160604458312253158926599133723983938251219874298475740348734276072809892\\\n    1626848894186788776460905762641021187051986426931249271794515709339154968633694259273769591346\\\n    4802934745772815833016389493333282793481861605692977020936945975177962800571386641457689792671\\\n    6436401155406553663328354309396396594710185795330816784111542977907452088862926987240063400592\\\n    3695441084516070947117477973251653378000962715067620733972436884312864292078235918366442201829\\\n    3712109475809681452875807884956536590968057469954409414360918868242885334650508057986619635252\\\n    8402964309640750455043724175587536897738898260091080260465388956918187558327814373511559652282\\\n    6545627353652660970901610474284082036116001257006407739686880855053374996327971673386219126712\\\n    4093737634901705349838028331937870930469922954803268594578537082084444143643981202462835025791\\\n    4801966450869428841128026790540900512167202578655522981808113004086231732638461989256467067519\\\n    1197556642812651623057856293981905974892044815927884247546582350655375915601883965541304985429\\\n    2947613749157929940642010727148147685365793026910859922674706950980832556356394318347198835986\\\n    2546979028671261517041763828396214153177455518285662057010428139624894542913681999411631454082\\\n    7267759020900629363437606198361196560376657413429542763973773159795461771876352993273287459648\\\n    5848853197228754706611495304920213605829525072926136533962713550028240211500277803191315152114\\\n    2217010005445253378660100375044933103643867412627511102770080376901851140288040803719976871920\\\n    8164844229335950175150630077511470750281513600624232843947687293428207456827671631824859201767\\\n    6723957769234755705411985969329846767095746673627877805693841299198320914926467370224371940418\\\n    1608578919372034873713968007318910383551989477033112582167976378433655946987719751049533604096\\\n    5179925033405654159801126502112850507181737922206802782953278534009089385437101281218169988735\\\n    3126051660889602172305874567249360221531292112351653250080314029962345249658933843066539317549\\\n    9892277476512094538510663251060804907462245036358819780685197374301017994868093847107219517697\\\n    7299887693075675455008331497824682219456913633024766056117580696374883456161787314532210342357\\\n    4302340731284645387944917673767582583950631845290811861241783897025228580102227914460987899079\\\n    3524276161911528379405068263615207613056042612112612107158520332320727892793790186407945144046\\\n    0011905623846496619497243670414303470021771731716728907741812141903787421535218283034070676340\\\n    7345583432284233989665427254774554361320426360515993435493153046267674752086624159831049903048\\\n    4951944337027884040540743893429596246939035744003469805532050876900685291599932189040960698250\\\n    3648639949349730411122736065903476063078053632602793907462544308066066822840928822937260411867\\\n    8061624043149235765069455555045906800147765760082877111866927711494416336877930018694637159075\\\n    2276171602520870299259341290235306346264005306248873528982587440859879753326863968683671649091\\\n    4596069831640912777713330232839372258640963703077942793013805047907034185421574412773145532318\\\n    3406373365583053857877733971933798082464226438140022393417565411126881972554391989071682275132\\\n    5663966358023492977427986728239826558208451835834914839908411256839099045698603622372259637827\\\n    0606058511195239224507705209787728928883991791327520824635963712831131357132237280761316620077\\\n    4150941923343581297382886745272795114816806287483971004413596594508103658500498843245297405771\\\n    5171681846908036937392808706641010590833735488893875543765742379840242898678772756699155931257\\\n    2526032145246600466838960123355531422425851930830261164991686461059499873546143306433755282537\\\n    3981670391835778541558322740563277021302751615487534802459200253460799975263993560662526345924\\\n    7213843393419035499113215809909587227536860810132610536538102109870343227801437961188437679332\\\n    5947348139304540731765524877935686738674550491136147013214652105589889271078568223226644814196\\\n    8889294770323276708089627965812742187959458233034574876671498910314691383148168412403087316347\\\n    5808044682964992337204633465149235024941060139247471310656171481655595873294391140458777392107\\\n    9431701581239150627511785646745681605313812023670642060454485391347452018765160898860936542161\\\n    1704157600647321768912056099657839695030905035071924176526423720553380116398336623660911323212\\\n    5193110922752675114375878966852778074512064441600010615107992462877327624086709574975208076708\\\n    0365261750688898641035305193318018541459739656826931425260833623281608455269026732209015681597\\\n    5338902139160029347603856852006267797936314477535790643700476589040979799590565856492174078223\\\n    3888303884996313429224845152097288939357677989146234617304265705428180779711738475477759032545\\\n    1922479497079711895145910872714858837415389988331504387750730857974522352714704364252164458223\\\n    0883779180504784419543297917847811460766962947574894759591364921548751846012094172570166321774\\\n    4407959979414876487518941784820052713566791847476196369973885189168073080271206767552421196789\\\n    1567043479046844367771462316633337981174537385811527024837887692632748187372421481725742961230\\\n    5266508390652331185733796984157067922567976203070835498673405713784225354750547929775171163662\\\n    5739905581504263231993993172464477534340275169447132101227627431257464861334934616467352057170\\\n    6703018442965737991014439623883362364833217790283273066690442648090840261076042635242269503272\\\n    3152634117661428141666872085590910920951968492793523529080057823508832573283299229424154520744\\\n    1939630313344057840335026971066621499310049356448775395559339991206396619870429859600080930863\\\n    8971059730438228899803469147782685541381446203855457327692317648370088295989949123791935153566\\\n    0595489681686434738582121511203959550930281339652420533651853356152444883081855207131680626247\\\n    9628041609101961091677935433659725260638616337494148576474414963616586633619977543453951961824\\\n    4775676554522945527653106654375528980740959636737215537015666626585535746179767602499673083814\\\n    8591955966793632779064247513473870829616549871833682046111373566460383725496389083986994703729\\\n    2956091256195864391524860022289893632525088929249273836898974882135440418846592399064754915956\\\n    3877567283362236162495174839183340209955363817630100725285079558352321085963137728925042417989\\\n    2479063972305149281238149255215210383278585706776600697390594676670949044853458725265160881988\\\n    2084749950992866329044372718461606717853051665720454892482365160798512119289736626147563842129\\\n    4411304102175225351454309111978859911929038099688842789037587794032841229198437324237536700892\\\n    7728489473030868320207155862182761458011320336853856827661187278843561910376653985438214526419\\\n    7102688171941079855705113680246275626745382022751172132539643159132692127687753142830796577720\\\n    1027313627031917470153841333409760417294730888972830865883594864443697900500978476690635629312\\\n    7802264598485020213552909650961418924338927045665236747543673974267120785258165994513533900281\\\n    2700943719133947065075080192847038684760270028531213516513900316512502507243186984877662935184\\\n    8253175136875303110080894898968895888556237355118836565711121513597100888613677634020705019667\\\n    9881240183513811317855171102125868496938741944776978452760334048215035900349390998736182414825\\\n    8664768253363444025694083719598814285772061830245482108488269737682131734620386133574000372672\\\n    7277789378789480453980096978023353355616990857398928064804199332585192821454985743714777806351\\\n    4254049338272382332407884528133024336150609574906489860140125259682642529994449237755714101229\\\n    5885234202203573212908362326001332373013012711545957134522789522442977595225130567195780560773\\\n    6432477246960748324054216186545984622661414048198842204937784828706363951904698167596838549413\\\n    8028594665866533150562237594091657624573535815186861096837689324419173010639746983286000779973\\\n    3205138451261199225504586268494645596694776860774288626001113291742314081810764685975378468687\\\n    0003847748123667583792263276860348443087970988051050999996894159042992131674804505424267928269\\\n    4004813610888211708315760224834499434209013265997046387269786800811198425539239682734603314312\\\n    7822020585689395324622118050391570144998225599696841225401588647806719195391359305845058995185\\\n    1404282513544713976496746667180174014813012618606142496440193036222093993267278298350151554554\\\n    5952784831204985999598787966283481106715031940856811455318790381846177934611804820349794089877\\\n    3367052409029590319964725561892114790409994020573439262942655097343138586818999356020915679351\\\n    3554956962193870193620162751205533141846733469099353718457028618904005174968239801692540188386\\\n    1984265887239732788059110336730135837497667593568992591457267948763290358200731310204020633463\\\n    9320464085586407110283095852744290661022918886196596117706354191006594063822118553593959933252\\\n    2388658649462456432232758401232130356839199437959062750931558169461428888204332895840870255696\\\n    6988413373681560548195549636654286357513097117257316851450675033480524457615721639274886210955\\\n    7237927069872835424804176307957139279082714285378742937476656012261316410085481245325292197736\\\n    0704756256672731786832806173163533066769971930525618800204703324445480022309403955110774013582\\\n    9034550205054878599937990144085006364454182261096069809398176318134672732850472362224696659699\\\n    4476533033417111317409443058560281155271307175607751199497284666768283735785072779979405259414\\\n    9685767653817766083100240551081489084235836451589343045925269287657909385587727037522644557912\\\n    1797617894822535136063108700396976832555674942700148977418593367675705841856926906075316348054\\\n    4933762400599095981464234410170930109521773310662846571762916915165122144840829489705662309841\\\n    9660700403437494188710765618382641099774612494115447254170004254195007210267775582991573679681\\\n    4207557725255279854558010093171668324531760273218605141085828018834387013682689505985435068032\\\n    8840394518710396500543920993704556989122333191377134700398080225576991462182360843367902354147\\\n    3648514517895605231126496120313650915008040980760302166541593035863061706159875265659671789935\\\n    0257801048098326722603246353464252940779675887638540341424620326565787421117257227421798583024\\\n    9580231853265159670076531834208350424367781237529405609878567726341424762467817130214447340625\\\n    7945109731592760426346913816867864026969629491172962032900969913548618382729394674465995280196\\\n    0749885425799264983267616512866178476900643687208368457755177696027201306815816322171987081156\\\n    8481534255330730121963213093452046765116532446076903786577821909969333677516238879691599377305\\\n    2053198914535426909295806402936353551764924554272714991819005804412235489613418850086343751500\\\n    5132508421423022520353112196592406116741720777134639709538192581904270697496971396664168049052\\\n    6202959311520774740231040343665653030584552824236128643091345929670228228851543752072409772201\\\n    1404520984503429872252856563275282594749477068594890022329804476947938245585707663785214622468\\\n    4866468080621303421321611090568130849286338014140280186778795891657949974627086710493672797871\\\n    8075018492794095530178735953518538166401578452512389706408613085584290931433978919679112245954\\\n    5214306701951133488826159844281264979364228221523390665679748888067241062854842746138798453978\\\n    5993715167879523708313967601388904481395738635940785544739653104287845764471182151237049906028\\\n    0226464025098721444155959305923443982499682470527227195441706042759567162320731613170484375183\\\n    1687446743485285393063895783640329267144998366852718508677784219373222881591167553907418757771\\\n    8752612686774417845905875454679841323894372781922989081180830586033369844492059016871192671401\\\n    1621166742869609991820729786777094325536911155527753212328438794061861432399772185034863167294\\\n    0271458720886554374286070373885297262982587934221069732704464871117484341778291712322674866133\\\n    7542248896854656912888440114664673346240258452617448123031659941581124849535633886299877799194\\\n    2838820711108273616965635387036718371962814939559677132377330210820670009352627660781902190217\\\n    3716016352956324009828047208240430473523995023062071815053244378709296592729197905515661012263\\\n    3181556272422015072829320388878050380905188735365207405501239797527251392935478716960609458861\\\n    4029859814090793748868733156532720103061173143976581859209656377103995488741156850754227452264\\\n    3205243497845265167280711652812394384967512364791744590110980127652997489124458572457397647925\\\n    6621159911630854921725100379038564837337805478204224721031678464379912089352404453794139206883\\\n    0193997796101689592976574325366969282354223378436361091529605423795230746211922314568332761653\\\n    3767708274043255234616341630910354492921030400394662040010876330826510360278120382987292398415\\\n    2919176523770626915364617751363341448742724676676065968340200634615966823067327607918854553308\\\n    3687812399923103520818626282464216329460303993026745735412140158956671360070951143183699146408\\\n    5408499097438057866510292832066847549257954508522018079226193960541798566855648815591996988089\\\n    1316607522006732952369874522444947247013678407518130334450045173397312240866728806426322687062\\\n    9434661730739497505750183090479444332157117822758904364288360864966071213075796623678187920480\\\n    9275923904534062474723378428571394821288625848079657180863985171144189367059421146791635697863\\\n    9986166894655407776723072250503436204824124981172203600554591670931099571913726296398576853746\\\n    7051283590455694056489979801122408528133031172230668026783106762621242763780510816394000118876\\\n    8632322663985031669053921082132781288285446788212424394291718123176004571018037101434719994394\\\n    8557225963074698705236513573633882221176983433877929256841447976007401609415686591279423398787\\\n    7354976210054509215521453822770717405878053905967705488313901869370742964692975581545967545047\\\n    8165908038619217718761644690559904342058531396554652744706507321314268068498474151937031236551\\\n    1761792729780719335363611458448918720679922006369027544575100665046279755923300208733656709767\\\n    1854131004188134318380679885007994971766481265841819321796388118544316280595517135782789313648\\\n    2237058209344461174157437932833183463776042921912563007531732907235312425958135797862170952838\\\n    5875255667192677160543047844413869896765656363258651976316159612615235729604896711626743194042\\\n    6558088574536887102310755375900833042837661921089551985011253051552519495280260450346635100269\\\n    6547187121403750292873615893140084659493420280408701461818132210401886137049049362507754024265\\\n    0887482530631606823439544304253237770576066702848747774864316023276393654970753560870766350966\\\n    5324419183136107056037223653986389914863222873900581142270002797246264492539910552022340690872\\\n    1597392912037786295482836022591220550307572234340049703137020408639526861945897748304519243895\\\n    0393585448474606388827613951054928888476448112993307695905450357925937937570569767772496802396\\\n    6270997175675368968387028320553185801242601401468208488561791111494811390146349559983977667811\\\n    7957496204529203115540341703395550497351921972949604916328838447326390042614125632207894277346\\\n    8568402626204662887198440624395423262694282371577406357950179236886620383474417747116913391027\\\n    0847854033854339132837553751700524438577410030874135430877234209250399690402542133864263078832\\\n    1257349276527445396718483545581098023105339407511062448249828703476537289426579003975001914934\\\n    8836338536520794289388876094066858977418113688923662127492443601326650885856251666316824875560\\\n    4103569697714372503947490031851976884368141710584723935944621847822884417580905313215618913339\\\n    4516586103542784862383406680967950754419203573482236559512411278786725862422631187203838666474\\\n    6159618840658707147506800261497287078086061401959714333573511062703155185838135702442260445419\\\n    1773058732126576469585201049565914907527891973137957995353521591076305302752943225421755743889\\\n    2626172939041117736601057823971935569284174874041726706607200773848616333478538880243634051611\\\n    8308459259823939549104404767797537570201408765492980935784581239781611837928214576748104049482\\\n    5817883130975956470760805809395756409441715349757792972665269063474432964655312925635202545328\\\n    1956658270527041916783192190807692785066887241485401008054044747654109210361276438297810764717\\\n    1814369717186247442759840848831068881833048198039346571488896021200622773520482250687690600334\\\n    3772979151643385857878479700312302133765860656513335605799245542957709859834267188558541968971\\\n    6704004900752459784140106625866336695347848294587442693473927664145449303619500676064414046213\\\n    2627292295623436629091801275682352173145687576596396730298245483403685270130920368947008490819\\\n    9899956876489947862529645566241985259153899412051949421021194406243171000401431708913131372094\\\n    7620635087174605583673549924192227060647515950654063560752664800335342584028538459352467370475\\\n    6123156156191956444778644358029821573069183083350376290722494380467167219525695143940019397605\\\n    6616041526233927563419603284162372718245577059575963222408917405250999107940276257570004952410\\\n    7230523620826609500770010800262620550726765017466296803688085744121900236804843972435792510850\\\n    5699479965744248497279282910629655753529500016496530175111615883878218790627673143971841828604\\\n    8000803688789461643109403064133850194486200569505992162802604961055509747481827835903566184620\\\n    0325321127195370719150213385453214637099520399218474780927704104622471588349213356511443330481\\\n    2847019874998968161166165343689676314629422227024113678188210290336457660875308433473324595686\\\n    0633409506419622410374734994508126033078473408391252808461984275521948515893798261410522052289\\\n    7668717891717352331952720499760549037581942776007005770427144389834974722018635954645207901885\\\n    4392315443576466043081637832574258631996421136052296373568389805798381409782365205063476982230\\\n    0807791682777332520747590410773353369087248012213677286038585401614208413727493750010737405300\\\n    9778686523083015489929583362695760890875437729553412213092459957515407505438272622803245648712\\\n    7593785770135323865459742032420595329742027643958057768005778693069449507597164733581663431638\\\n    6453836196411028499460704600909326547222949735364133797894575214713833582926744135313713330272\\\n    8492499414035483811576650990249157369451210068053650763079853846267537082798828754427715603859\\\n    3317720514818201764438467612085578743553354543926387468847447248428065674260415288099114049868\\\n    5770866889906346178104661918242336437798228225030445867949763193159864705585988870059724900594\\\n    9992418839477851676725202558036474435549526153074400551130173685662644994660032889519468196601\\\n    4911591707272585687580177182287873359275106131478981395051992565157759523368300309963059036295\\\n    7898601432186323404486369065384754546270165585458479452323896869573046864594145716019392337518\\\n    9103917154746664270506337784353587840372747301167695887761319463023699297448255965676083054266\\\n    3051722071587899296488294422300702663783954464277896772197102822703155658105578767628025699311\\\n    5107550566523300590415523524449681412742908651198444441044066127534622505939934929671400447789\\\n    0988979078025214907055958741455447727848949929342659431469872506206712091251584497009360063956\\\n    2234351284140441328428447140589661793357534171375437997661279485796234735648296550090370993214\\\n    9573508717197783001421963091211519005180662747530394457452443616438786943879927565811086324237\\\n    9172209669864295807761393484850475560825709816182027650787665851979704736907920181110314432896\\\n    3987353039534535982256472841234231198262977471748647891163388921661304865342263154135660438826\\\n    5443265996378200699455879116319402735894367151446899927635566922872284067900483879369217662210\\\n    7214237746014362628381252505885810404510504188356408413001072841317956301591861568066551550221\\\n    7732554036067538837458768079713940788053251246698195352277226945389481345068548774651587210539\\\n    2439359067152754596281186824962547722940695962881521939967798396637815790411738987964391323854\\\n    1636807118930579233978167193243665294328459583240620141256297010703696372765286031652141353385\\\n    0707799126076613767339373764983787122936850338501674555396072844336488181828537677594667686910\\\n    4688613259046183924596236653824500657812742799152839639701814781267878439346518514329952516793\\\n    9113905929144473590118301339239151255136563405291648718072122477312363282133501580569211056037\\\n    5415681385512258368566357173633411091445837502910630284823285497748830334786593544103983352002\\\n    6897540337803691592710850272356277265567463620483748432963722129071468668829155841477168595587\\\n    3379992418788482107198810334194559565065001914913601053517475884821794967591659806522251223532\\\n    8997603118814173754107082859216364068938056741831076406363245180545856019597367736722910618951\\\n    6922108257615784745860475472051914728150559315741695702205699780256776414907950451625183015349\\\n    3374887013848688316090854108997781091120310875736287113494871506670926324016611923697436662074\\\n    7168975008343733454348774817427435763722250779100044691082478583176875706564476388300668197817\\\n    5191756305926440536490665537274947452195960588166842907734632265509035317729017816316173096353\\\n    9501205635075409007463179394989843761117892721718472876855125846332278174098288112390112719299\\\n    7868447445737906943364645118530597601214787996500611598045520083270028004831766753987895862081\\\n    1347977576202800727513877688142714990160194224811100903111937997175275529568952631791090431860\\\n    7972555408543905876342341987810059519940275607117924671281012023216862816760298465136041213903\\\n    0186749388774474454735574641016278019716330058207305439456908203562726597528962924525997530673\\\n    0100480169371929727918742307446829587001658504536709567100623691543788959362607191393107082495\\\n    5260992418545305384575873041778517729979806961852891566906359333615626143263590092072285318044\\\n    1277001466046266826755209441917932489844268809759627500791751235435859755620114673818560792182\\\n    1350630513266328224299960118176844644782266408559294717993902956380177710584125117381720123479\\\n    5019524781161652104703590148774970179252144066607668185456067277479122024861016421822176484819\\\n    5532756776004732813913735429733949994543268790391507437094884661269168145269435637845840908416\\\n    9525070420393619326857469782080769526479404754050731604684847855874963641516814427541972143709\\\n    7832469052287531609221748070928979487768641128859863904203829924281936428396144933929443122953\\\n    9466597416127298262440667280249576460684619779846862114087172364198198027751242796983093147680\\\n    5178730838081459734906890269337818808157270563894668991913908005718727813623569124272853679104\\\n    5782523445307725103120342333915023028069320396035669098694276287959449070101937232159725795186\\\n    6915651338392338718789275029269821257080090409655876642097613530960487526029636057080814070919\\\n    9102858865135756454965826299211745307132399949239510939165496600663470421767887122683770144270\\\n    8457854025390450173703923040092194277827942358376598099574704161799381065689990521259438655694\\\n    9264935076559892235511974957798892750311304106895614370468433038253814575148670418565646752775\\\n    1564553253727709850811347656437291237418080758683947660507698577870365491932783233652957770774\\\n    4292473735244673794915658400921265759592522087026139345438339594381537388596932199887679679401\\\n    0937619327607656815804679961249784514094104697692333112529587931294015658768623302874401498644\\\n    8263452914151535605776621452900764067368095260232549665665918906454302828006563054792277161432\\\n    1314353209569241412279376916917772679199111139461262224271588074666917088540452256855345933512\\\n    1691905802654728690731674290567438756153228271416653396545843349420264352222551958468892831992\\\n    1067320928440577549303269579393911901028425631669649636562210966243665426646659229049102853171\\\n    8644773655402957959130314398210705881472371681886288543784744267718543037537673821758796485458\\\n    9519935158454112233513117098131785813400702985889549174282017533440344871443990614429838615195\\\n    3282750935927708480093025439682162954321750573599920056021165563037502960506659234507730406587\\\n    9254320101103641036271658357927664439137995958175694619737393715289621135735454351041263079148\\\n    8061626368089858031543770323703228312454640596316253981102293066573872520962517019178277220858\\\n    2192413547625462275109081449536517798947922346665326758883829645011362444367631497812636640435\\\n    8240123389432724581923978654751149849568195764213341310772092802468416905446880207138182165168\\\n    3149026203643543230833588090424778115145369296310130084254802216351261612400112759252430572442\\\n    9142441758531342473622149430421777577371326515788158462568885130434263118398761257644872213065\\\n    5572635567997317829403958119506358241293062297512217370633214810486250856218885937175167984920\\\n    2028394413495533110423434926003708066452032577337983613334450485123333663376840804548848574155\\\n    0544157519422083695232088119506604595316164560564313649333692115550572231291810754675549067876\\\n    5341973490964694409020984462400974360482391287423732655860075137412523822430452298966400023544\\\n    9336635362326886011949473382245931561187834670215695128665170841011501250638195964526040756537\\\n    6289255267538998608216815039235026910718671277194846003221411833227172404502474526999659301711\\\n    1623378167267310829007362290688440434601003789206651900472846885762869244831246448014570257010\\\n    2274565533912570333120366909542514756041443063639518652397469225536763179175400364846237357320\\\n    4319673392464232476681541177543359256347586665915619286284844983822417886505854702776952303319\\\n    1868993585986531184659981622691875495244565689861504640399014479236056898374501934175603263910\\\n    4812967352232605986379631008125558176223463373234474918630776232117329091745364578646214365696\\\n    7288888765744344072499125247148080748874189606419360006628937915515078017219269036255529806301\\\n    1533067229307145595865229814206131578753693922768409573834955660828615101358641413163705980215\\\n    3778120021536632978759107775607989681933803651768714733489401829446514687118201089069133519691\\\n    7327269523394610167640980962904774498623715883220222808201434040644871561508542809678192173565\\\n    8228360585488614202205964344720700033535824349165616886613326801235630411021163170480286303461\\\n    2952636896395891136450493725644185418562499809538271814273912096161170648246076228584659906734\\\n    1730526671323507891804911264119661555845235936944013595815853255147067212497902148929064798937\\\n    5663544155210648790099965102335815078574507646250075965649470166479484618296807206181456096322\\\n    1239337898651148840518714319049468616100143543241229350810034475459980307383316077363623047691\\\n    2980043186225941377872480839928045738360663155591567065818273440214843666101652592264378295239\\\n    5646826672514255403502546172192605104267718730298175038373518268397608953092361022169332120595\\\n    8357015964745200364928431489943210202831713693296226228539775068125697522458402521734672620537\\\n    1821301928209866599591904671719526279485180097510326795254077589121367006559221655415021850441\\\n    7033660398976797419014162177489079483515696199498503719072060911110030866682081676261643974660\\\n    6673777940300541351572995725784259276952976776748326629933468228990694422311963482608149836549\\\n    7495560617842688078823781957894917290367062500776008919455664019846511248933702114665734580450\\\n    5270283590651019908288028823825076523763370342979925859318649208981143741241557382693247515286\\\n    0892983471231649047247860545804953969546331350276518384213132324831966446059763279198658201707\\\n    4106843802142672711414350850395203952692855607065966318914766439373508430713040210547173909011\\\n    2400374277094261315266359766870042577508801867668030275324813574204708598810766736327385510247\\\n    6497909058954153538173422157220873673331914707283545556317441551940036815997172619651814545355\\\n    0647232716387157457957722784691794010984083224354879001808502608337159772891944324005422286417\\\n    9432159997201577751672753433763161651685853542528490638079681009294118599609469896562836811645\\\n    2268590358155608361667702879398636652573356394370577129822218697410557768646339622503401009703\\\n    7431982487127228646478778507769006933120413261282395035162561864773156587206526243185574999939\\\n    7082519150649550143194109022280628235632124688841941819048990519626109857929428142117233642067\\\n    8040199018114248934378004420309487398363304415953527304249978281615624118640537917208697301792\\\n    3852930638845906288822515908812033591180093414146621361243064983045530124933270433675020769291\\\n    8706182675901618745063194274884817917140084428856397899389551159613355621078431603601168863173\\\n    9773907131531145121932632654098562682517822681619729300556598426710805067928699015356981881445\\\n    0252473059553838985182944893658217557687644136142023003374541108584174815777585366770139465082\\\n    2507900113560618408214497804009578455984856361066709869813957526244398964459063943853133897800\\\n    6811728100537004468446935597870020504547087479838834337311279096036315762836431229200553223182\\\n    9617189495812537201565234172811721026363403673136818889465805664227466141580428998366657895665\\\n    773140018\";\n    big_test(Natural::from_str(xss).unwrap());\n}\n\n#[test]\nfn test_squaring_large_powers_of_2() {\n    for i in 0..400_000 {\n        let p = Natural::power_of_2(i).square();\n        assert!(p.is_valid());\n        assert_eq!(p.checked_log_base_2(), Some(i << 1));\n    }\n}\n\nfn limbs_square_basecase_helper_2(out: &[Limb], xs: &[Limb]) -> Vec<Limb> {\n    let mut out = out.to_vec();\n    let old_out = out.clone();\n    limbs_square_to_out_basecase_unrestricted(&mut out, xs);\n    let n = Natural::from_limbs_asc(xs).square();\n    let len = xs.len() << 1;\n    let mut limbs = n.into_limbs_asc();\n    limbs.resize(len, 0);\n    assert_eq!(limbs, &out[..len]);\n    assert_eq!(&out[len..], &old_out[len..]);\n    out\n}\n\n#[test]\nfn limbs_square_to_out_basecase_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_22().test_properties_with_config(&config, |(mut out, xs)| {\n        let expected_out = limbs_square_basecase_helper_2(&out, &xs);\n        limbs_square_to_out_basecase(&mut out, &xs);\n        assert_eq!(out, expected_out);\n    });\n}\n\nmacro_rules! square_properties_helper {\n    ($properties: ident, $square: ident, $scratch: ident, $gen: ident) => {\n        #[test]\n        fn $properties() {\n            let mut config = GenConfig::new();\n            config.insert(\"mean_length_n\", 2048);\n            config.insert(\"mean_stripe_n\", 64 << Limb::LOG_WIDTH);\n            $gen().test_properties_with_config(&config, |(mut out, xs)| {\n                let expected_out = limbs_square_basecase_helper_2(&out, &xs);\n                let mut scratch = vec![0; $scratch(xs.len())];\n                $square(&mut out, &xs, &mut scratch);\n                assert_eq!(out, expected_out);\n            });\n        }\n    };\n}\n\nsquare_properties_helper!(\n    limbs_square_to_out_toom_2_properties,\n    limbs_square_to_out_toom_2,\n    limbs_square_to_out_toom_2_scratch_len,\n    unsigned_vec_pair_gen_var_23\n);\nsquare_properties_helper!(\n    limbs_square_to_out_toom_3_properties,\n    limbs_square_to_out_toom_3,\n    limbs_square_to_out_toom_3_scratch_len,\n    unsigned_vec_pair_gen_var_24\n);\nsquare_properties_helper!(\n    limbs_square_to_out_toom_4_properties,\n    limbs_square_to_out_toom_4,\n    limbs_square_to_out_toom_4_scratch_len,\n    unsigned_vec_pair_gen_var_25\n);\nsquare_properties_helper!(\n    limbs_square_to_out_toom_6_properties,\n    limbs_square_to_out_toom_6,\n    limbs_square_to_out_toom_6_scratch_len,\n    unsigned_vec_pair_gen_var_27\n);\nsquare_properties_helper!(\n    limbs_square_to_out_toom_8_properties,\n    limbs_square_to_out_toom_8,\n    limbs_square_to_out_toom_8_scratch_len,\n    unsigned_vec_pair_gen_var_28\n);\n\n#[test]\nfn sign_properties() {\n    natural_gen().test_properties(|x| {\n        let square = (&x).square();\n        assert!(square.is_valid());\n\n        let mut mut_x = x.clone();\n        mut_x.square_assign();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, square);\n\n        assert_eq!(&x * &x, square);\n        assert!(square >= x);\n        assert_eq!((&square).checked_sqrt().unwrap(), x);\n        if x > 1 {\n            assert_eq!(square.checked_log_base(&x).unwrap(), 2);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        let x_squared = (&x).square();\n        let y_squared = (&y).square();\n        let xy = &x * &y;\n        assert_eq!((&x + &y).square(), &x_squared + &y_squared + (&xy << 1));\n        assert_eq!(xy.square(), x_squared * y_squared);\n    });\n\n    unsigned_gen_var_21::<Limb>().test_properties(|x| {\n        assert_eq!(x.square(), Natural::from(x).square());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, ModPowerOf2Neg, PowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::slices::slice_test_zero;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    large_type_gen_var_9, unsigned_pair_gen_var_7, unsigned_vec_gen, unsigned_vec_pair_gen_var_6,\n    unsigned_vec_pair_gen_var_31, unsigned_vec_triple_gen_var_31, unsigned_vec_triple_gen_var_40,\n    unsigned_vec_unsigned_pair_gen, unsigned_vec_unsigned_pair_gen_var_1,\n    unsigned_vec_unsigned_vec_bool_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::arithmetic::sub::{\n    limbs_slice_sub_in_place_right, limbs_sub, limbs_sub_greater_in_place_left,\n    limbs_sub_greater_to_out, limbs_sub_limb, limbs_sub_limb_in_place, limbs_sub_limb_to_out,\n    limbs_sub_same_length_in_place_left, limbs_sub_same_length_in_place_right,\n    limbs_sub_same_length_in_place_with_overlap, limbs_sub_same_length_to_out,\n    limbs_sub_same_length_to_out_with_overlap, limbs_sub_same_length_with_borrow_in_in_place_left,\n    limbs_sub_same_length_with_borrow_in_to_out, limbs_vec_sub_in_place_right,\n};\nuse malachite_nz::natural::{Natural, limb_to_bit_count};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen_var_10};\nuse malachite_nz::test_util::natural::arithmetic::sub::{\n    limbs_sub_same_length_in_place_with_overlap_naive,\n    limbs_sub_same_length_to_out_with_overlap_naive,\n};\nuse num::BigUint;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_limb() {\n    let test = |xs: &[Limb], y: Limb, out: (Vec<Limb>, bool)| {\n        assert_eq!(limbs_sub_limb(xs, y), out);\n    };\n    test(&[], 0, (vec![], false));\n    test(&[1], 2, (vec![u32::MAX], true));\n    test(&[6, 7], 2, (vec![4, 7], false));\n    test(&[100, 101, 102], 10, (vec![90, 101, 102], false));\n    test(&[123, 456], 78, (vec![45, 456], false));\n    test(&[123, 456], 789, (vec![4294966630, 455], false));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_limb_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, borrow: bool, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_sub_limb_to_out(&mut out, xs, y), borrow);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[], 0, false, &[10, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[1], 2, true, &[u32::MAX, 10, 10, 10]);\n    test(&[10, 10, 10, 10], &[6, 7], 2, false, &[4, 7, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        false,\n        &[90, 101, 102, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        78,\n        false,\n        &[45, 456, 10, 10],\n    );\n    test(\n        &[10, 10, 10, 10],\n        &[123, 456],\n        789,\n        false,\n        &[4294966630, 455, 10, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_limb_to_out_fail() {\n    limbs_sub_limb_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, borrow: bool, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        assert_eq!(limbs_sub_limb_in_place(&mut xs, y), borrow);\n        assert_eq!(xs, out);\n    };\n    test(&[], 0, false, &[]);\n    test(&[1], 2, true, &[u32::MAX]);\n    test(&[6, 7], 2, false, &[4, 7]);\n    test(&[100, 101, 102], 10, false, &[90, 101, 102]);\n    test(&[123, 456], 78, false, &[45, 456]);\n    test(&[123, 456], 789, false, &[4294966630, 455]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub() {\n    let test = |xs, ys, out| {\n        assert_eq!(limbs_sub(xs, ys), out);\n    };\n    test(&[], &[], (vec![], false));\n    test(&[2], &[], (vec![2], false));\n    test(&[3], &[2], (vec![1], false));\n    test(&[2], &[3], (vec![u32::MAX], true));\n    test(&[1, 2, 3], &[1, 1, 1], (vec![0, 1, 2], false));\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        (vec![0, u32::MAX, 0xfffffffd], true),\n    );\n    test(\n        &[1, 2, 3],\n        &[6, 7],\n        (vec![0xfffffffb, 0xfffffffa, 2], false),\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        (vec![u32::MAX - 1, u32::MAX, 1], false),\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        (vec![2, 0, u32::MAX - 1], true),\n    );\n    test(&[0, 0, 0], &[1], (vec![u32::MAX, u32::MAX, u32::MAX], true));\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_fail() {\n    limbs_sub(&[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_same_length_to_out() {\n    let test = |xs, ys, out_before: &[Limb], borrow, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_sub_same_length_to_out(&mut out, xs, ys), borrow);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], false, vec![0, 0]);\n    test(&[3], &[2], &[0, 0], false, vec![1, 0]);\n    test(&[2], &[3], &[0, 0], true, vec![u32::MAX, 0]);\n    test(\n        &[1, 2, 3],\n        &[1, 1, 1],\n        &[0, 1, 2, 5],\n        false,\n        vec![0, 1, 2, 5],\n    );\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        &[5, 5, 5, 5],\n        true,\n        vec![0, u32::MAX, 0xfffffffd, 5],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1, 10],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        &[10, 10, 10, 10],\n        true,\n        vec![2, 0, u32::MAX - 1, 10],\n    );\n    test(\n        &[0, 0, 0],\n        &[1, 0, 0],\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX, 10],\n    );\n    test(\n        &[u32::MAX, u32::MAX, 0xffffff, 0, 0],\n        &[0, 0, 0, 4294967232, u32::MAX],\n        &[10, 10, 10, 10, 10, 10],\n        true,\n        vec![u32::MAX, u32::MAX, 0xffffff, 64, 0, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_to_out_fail_1() {\n    let mut out = vec![10, 10];\n    limbs_sub_same_length_to_out(&mut out, &[6, 7, 8], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_to_out_fail_2() {\n    let mut out = vec![10, 10, 10];\n    limbs_sub_same_length_to_out(&mut out, &[6, 7, 8], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_greater_to_out() {\n    let test = |xs, ys, out_before: &[Limb], borrow, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(limbs_sub_greater_to_out(&mut out, xs, ys), borrow);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], false, vec![0, 0]);\n    test(&[2], &[], &[0, 0], false, vec![2, 0]);\n    test(&[3], &[2], &[0, 0], false, vec![1, 0]);\n    test(&[2], &[3], &[0, 0], true, vec![u32::MAX, 0]);\n    test(\n        &[1, 2, 3],\n        &[1, 1, 1],\n        &[0, 1, 2, 5],\n        false,\n        vec![0, 1, 2, 5],\n    );\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        &[5, 5, 5, 5],\n        true,\n        vec![0, u32::MAX, 0xfffffffd, 5],\n    );\n    test(\n        &[1, 2, 3],\n        &[6, 7],\n        &[0, 0, 0],\n        false,\n        vec![0xfffffffb, 0xfffffffa, 2],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1, 10],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        &[10, 10, 10, 10],\n        true,\n        vec![2, 0, u32::MAX - 1, 10],\n    );\n    test(\n        &[0, 0, 0],\n        &[1],\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_greater_to_out_fail_1() {\n    let mut out = vec![10, 10];\n    limbs_sub_greater_to_out(&mut out, &[6, 7, 8], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_greater_to_out_fail_2() {\n    let mut out = vec![10, 10, 10];\n    limbs_sub_greater_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_same_length_in_place_left() {\n    let test = |xs_before: &[Limb], ys, borrow, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_sub_same_length_in_place_left(&mut xs, ys), borrow);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], false, vec![]);\n    test(&[3], &[2], false, vec![1]);\n    test(&[2], &[3], true, vec![u32::MAX]);\n    test(&[1, 2, 3], &[1, 1, 1], false, vec![0, 1, 2]);\n    test(&[1, 1, 1], &[1, 2, 3], true, vec![0, u32::MAX, 0xfffffffd]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        true,\n        vec![2, 0, u32::MAX - 1],\n    );\n    test(\n        &[0, 0, 0],\n        &[1, 0, 0],\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_in_place_left_fail() {\n    limbs_sub_same_length_in_place_left(&mut [6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_greater_in_place_left() {\n    let test = |xs_before: &[Limb], ys, borrow, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_sub_greater_in_place_left(&mut xs, ys), borrow);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], false, vec![]);\n    test(&[2], &[], false, vec![2]);\n    test(&[3], &[2], false, vec![1]);\n    test(&[2], &[3], true, vec![u32::MAX]);\n    test(&[1, 2, 3], &[1, 1, 1], false, vec![0, 1, 2]);\n    test(&[1, 1, 1], &[1, 2, 3], true, vec![0, u32::MAX, 0xfffffffd]);\n    test(&[1, 2, 3], &[6, 7], false, vec![0xfffffffb, 0xfffffffa, 2]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        true,\n        vec![2, 0, u32::MAX - 1],\n    );\n    test(&[0, 0, 0], &[1], true, vec![u32::MAX, u32::MAX, u32::MAX]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_greater_in_place_left_fail() {\n    limbs_sub_greater_in_place_left(&mut [6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_same_length_in_place_right() {\n    let test = |xs, ys_before: &[Limb], borrow, ys_after| {\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_sub_same_length_in_place_right(xs, &mut ys), borrow);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], false, vec![]);\n    test(&[3], &[2], false, vec![1]);\n    test(&[2], &[3], true, vec![u32::MAX]);\n    test(&[1, 2, 3], &[1, 1, 1], false, vec![0, 1, 2]);\n    test(&[1, 1, 1], &[1, 2, 3], true, vec![0, u32::MAX, 0xfffffffd]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        true,\n        vec![2, 0, u32::MAX - 1],\n    );\n    test(\n        &[0, 0, 0],\n        &[1, 0, 0],\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_in_place_right_fail_1() {\n    limbs_sub_same_length_in_place_right(&[6, 7], &mut [1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_in_place_right_fail_2() {\n    limbs_sub_same_length_in_place_right(&[1, 2], &mut [6, 7, 8]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_sub_in_place_right() {\n    let test = |xs: &[Limb], ys_before: &[Limb], len: usize, borrow: bool, ys_after: &[Limb]| {\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_slice_sub_in_place_right(xs, &mut ys, len), borrow);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], 0, false, &[]);\n    test(&[123, 456], &[789, 123], 2, false, &[4294966630, 332]);\n    test(&[123, 456], &[789, 123], 1, false, &[4294966630, 455]);\n    test(&[123, 0], &[789, 123], 1, true, &[4294966630, u32::MAX]);\n    test(&[123, 456], &[789, 123], 0, false, &[123, 456]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_sub_in_place_right_fail_1() {\n    limbs_slice_sub_in_place_right(&[6, 7], &mut [1, 2, 3], 1);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_sub_in_place_right_fail_2() {\n    limbs_slice_sub_in_place_right(&[6, 7], &mut [1, 2], 3);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_sub_in_place_right() {\n    let test = |xs, ys_before: &[Limb], borrow, ys_after| {\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_vec_sub_in_place_right(xs, &mut ys), borrow);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], false, vec![]);\n    test(&[2], &[], false, vec![2]);\n    test(&[3], &[2], false, vec![1]);\n    test(&[2], &[3], true, vec![u32::MAX]);\n    test(&[1, 2, 3], &[1, 1, 1], false, vec![0, 1, 2]);\n    test(&[1, 1, 1], &[1, 2, 3], true, vec![0, u32::MAX, 0xfffffffd]);\n    test(&[1, 2, 3], &[6, 7], false, vec![0xfffffffb, 0xfffffffa, 2]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        true,\n        vec![2, 0, u32::MAX - 1],\n    );\n    test(&[0, 0, 0], &[1], true, vec![u32::MAX, u32::MAX, u32::MAX]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_vec_sub_in_place_right_fail() {\n    limbs_vec_sub_in_place_right(&[6, 7], &mut vec![1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_same_length_with_borrow_in_to_out() {\n    let test = |xs, ys, borrow_in, out_before: &[Limb], borrow, out_after| {\n        let mut out = out_before.to_vec();\n        assert_eq!(\n            limbs_sub_same_length_with_borrow_in_to_out(&mut out, xs, ys, borrow_in),\n            borrow\n        );\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], false, &[0, 0], false, vec![0, 0]);\n    test(&[], &[], true, &[0, 0], true, vec![0, 0]);\n    test(&[3], &[2], false, &[0, 0], false, vec![1, 0]);\n    test(&[3], &[2], true, &[0, 0], false, vec![0, 0]);\n    test(&[2], &[3], false, &[0, 0], true, vec![u32::MAX, 0]);\n    test(&[3], &[3], true, &[0, 0], true, vec![u32::MAX, 0]);\n    test(&[2], &[3], true, &[0, 0], true, vec![u32::MAX - 1, 0]);\n    test(\n        &[1, 2, 3],\n        &[1, 1, 1],\n        false,\n        &[0, 1, 2, 5],\n        false,\n        vec![0, 1, 2, 5],\n    );\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        false,\n        &[5, 5, 5, 5],\n        true,\n        vec![0, u32::MAX, 0xfffffffd, 5],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        &[10, 10, 10, 10],\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1, 10],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        false,\n        &[10, 10, 10, 10],\n        true,\n        vec![2, 0, u32::MAX - 1, 10],\n    );\n    test(\n        &[0, 0, 0],\n        &[1, 0, 0],\n        false,\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX, 10],\n    );\n    test(\n        &[0, 0, 0],\n        &[1, 0, 0],\n        true,\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX - 1, u32::MAX, u32::MAX, 10],\n    );\n    test(\n        &[0, 0, 0],\n        &[0, 0, 0],\n        true,\n        &[10, 10, 10, 10],\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_with_borrow_in_to_out_fail_1() {\n    let mut out = vec![10, 10];\n    limbs_sub_same_length_with_borrow_in_to_out(&mut out, &[6, 7, 8], &[1, 2, 3], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_with_borrow_in_to_out_fail_2() {\n    let mut out = vec![10, 10, 10];\n    limbs_sub_same_length_with_borrow_in_to_out(&mut out, &[6, 7, 8], &[1, 2], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_same_length_with_borrow_in_in_place_left() {\n    let test = |xs_before: &[Limb], ys, borrow_in, borrow, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_sub_same_length_with_borrow_in_in_place_left(&mut xs, ys, borrow_in),\n            borrow\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], false, false, vec![]);\n    test(&[], &[], true, true, vec![]);\n    test(&[3], &[2], false, false, vec![1]);\n    test(&[3], &[2], true, false, vec![0]);\n    test(&[2], &[3], false, true, vec![u32::MAX]);\n    test(&[2], &[2], true, true, vec![u32::MAX]);\n    test(&[2], &[3], true, true, vec![u32::MAX - 1]);\n    test(&[1, 2, 3], &[1, 1, 1], false, false, vec![0, 1, 2]);\n    test(\n        &[1, 1, 1],\n        &[1, 2, 3],\n        false,\n        true,\n        vec![0, u32::MAX, 0xfffffffd],\n    );\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        false,\n        vec![u32::MAX - 1, u32::MAX, 1],\n    );\n    test(\n        &[102, 101, 100],\n        &[100, 101, 102],\n        false,\n        true,\n        vec![2, 0, u32::MAX - 1],\n    );\n    test(\n        &[0, 0, 0],\n        &[1, 0, 0],\n        false,\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX],\n    );\n    test(\n        &[0, 0, 0],\n        &[1, 0, 0],\n        true,\n        true,\n        vec![u32::MAX - 1, u32::MAX, u32::MAX],\n    );\n    test(\n        &[0, 0, 0],\n        &[0, 0, 0],\n        true,\n        true,\n        vec![u32::MAX, u32::MAX, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_with_borrow_in_in_place_left_fail() {\n    limbs_sub_same_length_with_borrow_in_in_place_left(&mut [6, 7], &[1, 2, 3], false);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_same_length_in_place_with_overlap() {\n    let test = |xs_before: &[Limb], right_start: usize, borrow: bool, xs_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_sub_same_length_in_place_with_overlap(&mut xs, right_start),\n            borrow\n        );\n        assert_eq!(xs, xs_after);\n\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_sub_same_length_in_place_with_overlap_naive(&mut xs, right_start),\n            borrow\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], 0, false, &[]);\n\n    test(&[4, 3, 2, 1], 0, false, &[0, 0, 0, 0]);\n    test(&[4, 3, 2, 1], 1, false, &[1, 1, 1, 1]);\n    test(&[4, 3, 2, 1], 2, false, &[2, 2, 2, 1]);\n    test(&[4, 3, 2, 1], 3, false, &[3, 3, 2, 1]);\n    test(&[4, 3, 2, 1], 4, false, &[4, 3, 2, 1]);\n\n    test(&[1, 2, 3, 4], 0, false, &[0, 0, 0, 0]);\n    test(\n        &[1, 2, 3, 4],\n        1,\n        true,\n        &[u32::MAX, u32::MAX - 1, u32::MAX - 1, 4],\n    );\n    test(&[1, 2, 3, 4], 2, true, &[u32::MAX - 1, 0xfffffffd, 3, 4]);\n    test(&[1, 2, 3, 4], 3, true, &[0xfffffffd, 2, 3, 4]);\n    test(&[1, 2, 3, 4], 4, false, &[1, 2, 3, 4]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_in_place_with_overlap_fail() {\n    limbs_sub_same_length_in_place_with_overlap(&mut [1, 2, 3], 4);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_same_length_to_out_with_overlap() {\n    let test = |xs_before: &[Limb], ys: &[Limb], borrow: bool, xs_after: &[Limb]| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_sub_same_length_to_out_with_overlap(&mut xs, ys),\n            borrow\n        );\n        assert_eq!(xs, xs_after);\n\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_sub_same_length_to_out_with_overlap_naive(&mut xs, ys),\n            borrow\n        );\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], false, &[]);\n    test(&[5], &[], false, &[5]);\n    test(&[5], &[3], false, &[2]);\n    test(&[5, 5, 5], &[3, 3], false, &[2, 2, 5]);\n    test(&[1, 2, 3, 4], &[], false, &[1, 2, 3, 4]);\n    test(&[1, 2, 3, 4], &[2], false, &[2, 2, 3, 4]);\n    test(&[1, 2, 3, 4], &[2, 2], false, &[1, 2, 3, 4]);\n    test(&[1, 2, 3, 4], &[2, 2, 2], false, &[0, 1, 2, 4]);\n    test(\n        &[1, 2, 3, 4],\n        &[2, 2, 2, 2],\n        false,\n        &[u32::MAX, u32::MAX, 0, 2],\n    );\n    test(&[1, 2, 3, 4], &[], false, &[1, 2, 3, 4]);\n    test(&[1, 2, 3, 4], &[4], false, &[0, 2, 3, 4]);\n    test(&[1, 2, 3, 4], &[4, 4], true, &[u32::MAX, u32::MAX, 3, 4]);\n    test(\n        &[1, 2, 3, 4],\n        &[4, 4, 4],\n        true,\n        &[u32::MAX - 1, u32::MAX - 1, u32::MAX, 4],\n    );\n    test(\n        &[1, 2, 3, 4],\n        &[4, 4, 4, 4],\n        true,\n        &[0xfffffffd, 0xfffffffd, u32::MAX - 1, u32::MAX],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_same_length_to_out_with_overlap_fail() {\n    limbs_sub_same_length_to_out_with_overlap(&mut [1, 2, 3], &[1, 2, 3, 4]);\n}\n\n#[test]\nfn test_sub_natural() {\n    let test = |s, t, out| {\n        let u = Natural::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n -= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n -= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() - v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() - &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u - v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u - &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigUint::from_str(s).unwrap() - BigUint::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(s).unwrap() - rug::Integer::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"123\", \"0\", \"123\");\n    test(\"456\", \"123\", \"333\");\n    test(\"1000000000000\", \"123\", \"999999999877\");\n    test(\"12345678987654321\", \"314159265358979\", \"12031519722295342\");\n    test(\"4294967296\", \"1\", \"4294967295\");\n    test(\"4294967295\", \"4294967295\", \"0\");\n    test(\"4294967296\", \"4294967295\", \"1\");\n    test(\"4294967296\", \"4294967296\", \"0\");\n    test(\"18446744073709551616\", \"1\", \"18446744073709551615\");\n    test(\"18446744073709551615\", \"18446744073709551615\", \"0\");\n    test(\"18446744073709551616\", \"18446744073709551615\", \"1\");\n    test(\"70734740290631708\", \"282942734368\", \"70734457347897340\");\n}\n\n#[test]\n#[should_panic]\nfn sub_assign_fail() {\n    let mut x = Natural::from_str(\"123\").unwrap();\n    x -= Natural::from_str(\"456\").unwrap();\n}\n\n#[test]\n#[should_panic]\nfn sub_assign_ref_fail() {\n    let mut x = Natural::from_str(\"123\").unwrap();\n    x -= &Natural::from_str(\"456\").unwrap();\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn sub_fail_1() {\n    Natural::from(123u32) - Natural::from(456u32);\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn sub_fail_2() {\n    Natural::from(123u32) - &Natural::from(456u32);\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn sub_fail_3() {\n    &Natural::from(123u32) - Natural::from(456u32);\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn sub_fail_4() {\n    &Natural::from(123u32) - &Natural::from(456u32);\n}\n\n#[test]\nfn limbs_sub_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen().test_properties_with_config(&config, |(xs, y)| {\n        let (result, borrow) = limbs_sub_limb(&xs, y);\n        if borrow {\n            if xs.is_empty() {\n                assert_ne!(y, 0);\n                assert!(result.is_empty());\n            } else {\n                let mut result = result;\n                result.push(Limb::MAX);\n                assert_eq!(\n                    Integer::from_owned_twos_complement_limbs_asc(result),\n                    Integer::from(Natural::from_owned_limbs_asc(xs)) - Integer::from(y)\n                );\n            }\n        } else {\n            assert_eq!(\n                Natural::from_owned_limbs_asc(result),\n                Natural::from_owned_limbs_asc(xs) - Natural::from(y)\n            );\n        }\n    });\n}\n\n#[test]\nfn limbs_sub_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            let len = xs.len();\n            if limbs_sub_limb_to_out(&mut out, &xs, y) {\n                let n = Integer::from(Natural::from_owned_limbs_asc(xs)) - Integer::from(y);\n                let mut limbs = n.into_twos_complement_limbs_asc();\n                limbs.resize(len, Limb::MAX);\n                assert_eq!(limbs, &out[..len]);\n                assert_eq!(&out[len..], &old_out[len..]);\n            } else {\n                let n = Natural::from_owned_limbs_asc(xs) - Natural::from(y);\n                let mut xs = n.into_limbs_asc();\n                xs.resize(len, 0);\n                assert_eq!(xs, &out[..len]);\n                assert_eq!(&out[len..], &old_out[len..]);\n            }\n        },\n    );\n}\n\n#[test]\nfn limbs_sub_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        if limbs_sub_limb_in_place(&mut xs, y) {\n            let n = Integer::from(Natural::from_owned_limbs_asc(old_xs)) - Integer::from(y);\n            let mut expected_xs = n.into_twos_complement_limbs_asc();\n            expected_xs.resize(xs.len(), Limb::MAX);\n            assert_eq!(xs, expected_xs);\n        } else {\n            let n = Natural::from_owned_limbs_asc(old_xs) - Natural::from(y);\n            let mut expected_xs = n.into_limbs_asc();\n            expected_xs.resize(xs.len(), 0);\n            assert_eq!(xs, expected_xs);\n        }\n    });\n}\n\n#[test]\nfn limbs_sub_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_31().test_properties_with_config(&config, |(xs, ys)| {\n        let (out, borrow) = limbs_sub(&xs, &ys);\n        let len = out.len();\n        let n = Natural::from_owned_limbs_asc(out);\n        if borrow {\n            assert_eq!(\n                n,\n                Natural::from_owned_limbs_asc(xs)\n                    + Natural::from_owned_limbs_asc(ys).mod_power_of_2_neg(limb_to_bit_count(len))\n            );\n        } else {\n            assert_eq!(\n                n,\n                Natural::from_owned_limbs_asc(xs) - Natural::from_owned_limbs_asc(ys)\n            );\n        }\n    });\n}\n\nfn limbs_sub_greater_to_out_helper(\n    f: &mut dyn FnMut(&mut [Limb], &[Limb], &[Limb]) -> bool,\n    mut out: Vec<Limb>,\n    xs: Vec<Limb>,\n    ys: Vec<Limb>,\n) {\n    let old_out = out.clone();\n    let len = xs.len();\n    let mut result_xs = if f(&mut out, &xs, &ys) {\n        let n = Natural::from_owned_limbs_asc(xs)\n            + Natural::from_owned_limbs_asc(ys).mod_power_of_2_neg(limb_to_bit_count(len));\n        n.into_limbs_asc()\n    } else {\n        let n = Natural::from_owned_limbs_asc(xs) - Natural::from_owned_limbs_asc(ys);\n        n.into_limbs_asc()\n    };\n    result_xs.resize(len, 0);\n    assert_eq!(result_xs, &out[..len]);\n    assert_eq!(&out[len..], &old_out[len..]);\n}\n\n#[test]\nfn limbs_sub_same_length_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_31().test_properties_with_config(&config, |(out, xs, ys)| {\n        limbs_sub_greater_to_out_helper(&mut limbs_sub_same_length_to_out, out, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_sub_greater_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_40().test_properties_with_config(&config, |(out, xs, ys)| {\n        limbs_sub_greater_to_out_helper(&mut limbs_sub_greater_to_out, out, xs, ys);\n    });\n}\n\nfn limbs_sub_greater_in_place_left_helper(\n    f: &mut dyn FnMut(&mut [Limb], &[Limb]) -> bool,\n    mut xs: Vec<Limb>,\n    ys: Vec<Limb>,\n) {\n    let xs_old = xs.clone();\n    let len = xs.len();\n    let borrow = f(&mut xs, &ys);\n    let n = Natural::from_owned_limbs_asc(xs);\n    if borrow {\n        assert_eq!(\n            n,\n            Natural::from_owned_limbs_asc(xs_old)\n                + Natural::from_owned_limbs_asc(ys).mod_power_of_2_neg(limb_to_bit_count(len))\n        );\n    } else {\n        assert_eq!(\n            n,\n            Natural::from_owned_limbs_asc(xs_old) - Natural::from_owned_limbs_asc(ys)\n        );\n    }\n}\n\n#[test]\nfn limbs_sub_same_length_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_sub_greater_in_place_left_helper(&mut limbs_sub_same_length_in_place_left, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_sub_greater_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_31().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_sub_greater_in_place_left_helper(&mut limbs_sub_greater_in_place_left, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_slice_sub_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_24().test_properties_with_config(\n        &config,\n        |(xs, mut ys, len)| {\n            let mut ys_old = ys.clone();\n            let borrow = limbs_slice_sub_in_place_right(&xs, &mut ys, len);\n            let xs_len = xs.len();\n            let x = Natural::from_owned_limbs_asc(xs);\n            ys_old.truncate(len);\n            let y = Natural::from_owned_limbs_asc(ys_old);\n            ys.truncate(xs_len);\n            let n = Natural::from_owned_limbs_asc(ys);\n            if borrow {\n                assert_eq!(n, x + y.mod_power_of_2_neg(limb_to_bit_count(xs_len)));\n            } else {\n                assert_eq!(n, x - y);\n            }\n        },\n    );\n\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(xs, mut ys)| {\n        assert!(!limbs_slice_sub_in_place_right(&xs, &mut ys, 0));\n        assert_eq!(xs, ys);\n    });\n}\n\nmacro_rules! limbs_vec_sub_in_place_right_helper {\n    ($f:ident, $xs:ident, $ys:ident) => {\n        let ys_old = $ys.clone();\n        let borrow = $f(&$xs, &mut $ys);\n        let n = Natural::from_owned_limbs_asc($ys);\n        if borrow {\n            let xs_len = $xs.len();\n            assert_eq!(\n                n,\n                Natural::from_owned_limbs_asc($xs)\n                    + Natural::from_owned_limbs_asc(ys_old)\n                        .mod_power_of_2_neg(limb_to_bit_count(xs_len))\n            );\n        } else {\n            assert_eq!(\n                n,\n                Natural::from_owned_limbs_asc($xs) - Natural::from_owned_limbs_asc(ys_old)\n            );\n        }\n    };\n}\n\n#[test]\nfn limbs_sub_same_length_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(xs, mut ys)| {\n        limbs_vec_sub_in_place_right_helper!(limbs_sub_same_length_in_place_right, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_vec_sub_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_31().test_properties_with_config(&config, |(xs, mut ys)| {\n        limbs_vec_sub_in_place_right_helper!(limbs_vec_sub_in_place_right, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_sub_same_length_with_borrow_in_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_9().test_properties_with_config(&config, |(mut out, xs, ys, borrow_in)| {\n        let old_out = out.clone();\n        let len = xs.len();\n        let n = if limbs_sub_same_length_with_borrow_in_to_out(&mut out, &xs, &ys, borrow_in) {\n            let mut n = Integer::from(Natural::from_owned_limbs_asc(xs))\n                - Integer::from(Natural::from_owned_limbs_asc(ys));\n            if borrow_in {\n                n -= Integer::ONE;\n            }\n            assert!(n < 0);\n            n.mod_power_of_2(limb_to_bit_count(len))\n        } else {\n            let mut n = Natural::from_owned_limbs_asc(xs) - Natural::from_owned_limbs_asc(ys);\n            if borrow_in {\n                n -= Natural::ONE;\n            }\n            n\n        };\n        let mut limbs = n.into_limbs_asc();\n        limbs.resize(len, 0);\n        assert_eq!(limbs, &out[..len]);\n        assert_eq!(&out[len..], &old_out[len..]);\n    });\n}\n\n#[test]\nfn limbs_sub_same_length_with_borrow_in_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_bool_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(mut xs, ys, borrow_in)| {\n            let xs_old = xs.clone();\n            let len = xs.len();\n            let borrow =\n                limbs_sub_same_length_with_borrow_in_in_place_left(&mut xs, &ys, borrow_in);\n            let n = Natural::from_owned_limbs_asc(xs);\n            let mut expected_result = if borrow {\n                let bit_len = limb_to_bit_count(len);\n                let mut neg_y = Natural::from_owned_limbs_asc(ys).mod_power_of_2_neg(bit_len);\n                if neg_y == 0 {\n                    neg_y = Natural::power_of_2(bit_len);\n                }\n                Natural::from_owned_limbs_asc(xs_old) + neg_y\n            } else {\n                Natural::from_owned_limbs_asc(xs_old) - Natural::from_owned_limbs_asc(ys)\n            };\n            if borrow_in {\n                expected_result -= Natural::ONE;\n            }\n            assert_eq!(n, expected_result);\n        },\n    );\n}\n\n#[test]\nfn limbs_sub_same_length_in_place_with_overlap_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_1().test_properties_with_config(\n        &config,\n        |(mut xs, right_start)| {\n            let xs_old = xs.clone();\n            let borrow = limbs_sub_same_length_in_place_with_overlap(&mut xs, right_start);\n            let len = xs.len() - right_start;\n            let x = Natural::from_limbs_asc(&xs_old[..len]);\n            let y = Natural::from_limbs_asc(&xs_old[right_start..]);\n            let n = Natural::from_limbs_asc(&xs[..len]);\n            if borrow {\n                assert_eq!(n, x + y.mod_power_of_2_neg(limb_to_bit_count(len)));\n            } else {\n                assert_eq!(n, x - y);\n            }\n            assert_eq!(&xs[len..], &xs_old[len..]);\n            let mut xs_alt = xs_old;\n            assert_eq!(\n                limbs_sub_same_length_in_place_with_overlap_naive(&mut xs_alt, right_start),\n                borrow\n            );\n            assert_eq!(xs_alt, xs);\n        },\n    );\n\n    unsigned_vec_gen().test_properties_with_config(&config, |mut xs| {\n        let xs_old = xs.clone();\n        assert!(!limbs_sub_same_length_in_place_with_overlap(&mut xs, 0));\n        assert!(slice_test_zero(&xs));\n        let mut xs = xs_old.clone();\n        assert!(!limbs_sub_same_length_in_place_with_overlap(\n            &mut xs,\n            xs_old.len(),\n        ));\n        assert_eq!(xs, xs_old);\n    });\n}\n\n#[test]\nfn limbs_sub_same_length_to_out_with_overlap_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_31().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        let borrow = limbs_sub_same_length_to_out_with_overlap(&mut xs, &ys);\n        let len = ys.len();\n        let x = Natural::from_limbs_asc(&xs_old[xs.len() - len..]);\n        let y = Natural::from_limbs_asc(&ys);\n        let n = Natural::from_limbs_asc(&xs[..len]);\n        if borrow {\n            assert_eq!(n, x + y.mod_power_of_2_neg(limb_to_bit_count(len)));\n        } else {\n            assert_eq!(n, x - y);\n        }\n        if len <= xs.len() - len {\n            assert_eq!(&xs[len..xs.len() - len], &xs_old[len..xs.len() - len]);\n        }\n\n        let mut xs_alt = xs_old;\n        assert_eq!(\n            limbs_sub_same_length_to_out_with_overlap_naive(&mut xs_alt, &ys),\n            borrow\n        );\n        assert_eq!(xs_alt, xs);\n    });\n\n    unsigned_vec_gen().test_properties_with_config(&config, |mut xs| {\n        let xs_old = xs.clone();\n        assert!(!limbs_sub_same_length_to_out_with_overlap(&mut xs, &xs_old));\n        assert!(slice_test_zero(&xs));\n        let mut xs = xs_old.clone();\n        assert!(!limbs_sub_same_length_to_out_with_overlap(&mut xs, &[]));\n        assert_eq!(xs, xs_old);\n    });\n}\n\n#[test]\nfn sub_properties() {\n    natural_pair_gen_var_10().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x -= y.clone();\n        assert!(mut_x.is_valid());\n        let diff = mut_x;\n\n        let mut mut_x = x.clone();\n        mut_x -= &y;\n        assert!(mut_x.is_valid());\n        let diff_alt = mut_x;\n        assert_eq!(diff_alt, diff);\n\n        let mut rug_x = rug::Integer::from(&x);\n        rug_x -= rug::Integer::from(&y);\n        assert_eq!(Natural::exact_from(&rug_x), diff);\n\n        let diff_alt = x.clone() - y.clone();\n        assert!(diff_alt.is_valid());\n        assert_eq!(diff_alt, diff);\n\n        let diff_alt = x.clone() - &y;\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = &x - y.clone();\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = &x - &y;\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        assert_eq!(\n            Natural::from(&(BigUint::from(&x) - BigUint::from(&y))),\n            diff\n        );\n        assert_eq!(\n            Natural::exact_from(&(rug::Integer::from(&x) - rug::Integer::from(&y))),\n            diff\n        );\n\n        assert!(diff <= x);\n        assert_eq!(diff + y, x);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(&x - Natural::ZERO, x);\n        assert_eq!(&x - &x, Natural::ZERO);\n    });\n\n    unsigned_pair_gen_var_7::<Limb>().test_properties(|(y, x)| {\n        assert_eq!(Natural::from(x - y), Natural::from(x) - Natural::from(y));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/arithmetic/sub_mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedSub, CheckedSubMul, SubMul, SubMulAssign};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_triple_gen_var_2, unsigned_vec_triple_gen_var_59,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::sub_mul::{\n    limbs_sub_mul, limbs_sub_mul_in_place_left, limbs_sub_mul_limb_greater,\n    limbs_sub_mul_limb_greater_in_place_left, limbs_sub_mul_limb_greater_in_place_right,\n    limbs_sub_mul_limb_same_length_in_place_left, limbs_sub_mul_limb_same_length_in_place_right,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_pair_gen, natural_pair_gen_var_10, natural_triple_gen_var_7,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_mul_limb_greater() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], limb: Limb, result: &[Limb], borrow| {\n        let o_result = limbs_sub_mul_limb_greater(xs_before, ys_before, limb);\n        if borrow == 0 {\n            assert_eq!(o_result.unwrap(), result);\n        } else {\n            assert!(o_result.is_none());\n        }\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_sub_mul_limb_greater_in_place_left(&mut xs, ys_before, limb),\n            borrow\n        );\n        assert_eq!(xs, result);\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_sub_mul_limb_greater_in_place_right(xs_before, &mut ys, limb),\n            borrow\n        );\n        assert_eq!(ys, result);\n    };\n    test(&[], &[], 4, &[], 0);\n    test(&[123, 456], &[], 4, &[123, 456], 0);\n    test(&[123, 456], &[123], 0, &[123, 456], 0);\n    test(&[123, 456], &[123], 4, &[4294966927, 455], 0);\n    test(&[123, 456], &[123], u32::MAX, &[246, 333], 0);\n    test(&[123, 456], &[0, 123], u32::MAX, &[123, 579], 123);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_limb_greater_fail() {\n    limbs_sub_mul_limb_greater(&[10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_limb_greater_in_place_left_fail() {\n    limbs_sub_mul_limb_greater_in_place_left(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_limb_greater_in_place_right_fail() {\n    limbs_sub_mul_limb_greater_in_place_right(&[10], &mut vec![10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_mul_limb_same_length() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], limb: Limb, result: &[Limb], borrow| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(\n            limbs_sub_mul_limb_same_length_in_place_left(&mut xs, ys_before, limb),\n            borrow\n        );\n        assert_eq!(xs, result);\n        let mut ys = ys_before.to_vec();\n        assert_eq!(\n            limbs_sub_mul_limb_same_length_in_place_right(xs_before, &mut ys, limb),\n            borrow\n        );\n        assert_eq!(ys, result);\n    };\n    test(&[], &[], 4, &[], 0);\n    test(&[123, 456], &[0, 0], 4, &[123, 456], 0);\n    test(&[123, 456], &[123, 0], 0, &[123, 456], 0);\n    test(&[123, 456], &[123, 0], 4, &[4294966927, 455], 0);\n    test(&[123, 456], &[123, 0], u32::MAX, &[246, 333], 0);\n    test(&[123, 456], &[0, 123], u32::MAX, &[123, 579], 123);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_limb_same_length_in_place_left_fail() {\n    limbs_sub_mul_limb_same_length_in_place_left(&mut [10, 10], &[10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_limb_same_length_in_place_right_fail() {\n    limbs_sub_mul_limb_same_length_in_place_right(&[10, 10], &mut [10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_sub_mul_and_limbs_sub_mul_in_place_left() {\n    let test = |xs_before: &[Limb], ys: &[Limb], zs: &[Limb], result: Option<Vec<Limb>>| {\n        assert_eq!(limbs_sub_mul(xs_before, ys, zs), result);\n        let mut xs = xs_before.to_vec();\n        let result_alt = if limbs_sub_mul_in_place_left(&mut xs, ys, zs) {\n            None\n        } else {\n            Some(xs)\n        };\n        assert_eq!(result, result_alt);\n    };\n    test(&[123, 456, 789], &[123, 789], &[321, 654], None);\n    test(\n        &[123, 456, 789, 1],\n        &[123, 789],\n        &[321, 654],\n        Some(vec![4294927936, 4294634040, 4294452078, 0]),\n    );\n    test(\n        &[123, 456, 789, 987, 654],\n        &[123, 789],\n        &[321, 654],\n        Some(vec![4294927936, 4294634040, 4294452078, 986, 654]),\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_fail_1() {\n    limbs_sub_mul(&[10, 10, 10], &[10], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_fail_2() {\n    limbs_sub_mul(&[10, 10, 10], &[10, 10], &[10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_fail_3() {\n    limbs_sub_mul(&[10, 10], &[10, 10], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_in_place_left_fail_1() {\n    let xs = &mut [10, 10, 10];\n    limbs_sub_mul_in_place_left(xs, &[10], &[10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_in_place_left_fail_2() {\n    let xs = &mut [10, 10, 10];\n    limbs_sub_mul_in_place_left(xs, &[10, 10], &[10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_sub_mul_in_place_left_fail_3() {\n    let xs = &mut [10, 10];\n    limbs_sub_mul_in_place_left(xs, &[10, 10], &[10, 10]);\n}\n\n#[test]\nfn test_sub_mul() {\n    let test = |r, s, t, out: &str| {\n        let u = Natural::from_str(r).unwrap();\n        let v = Natural::from_str(s).unwrap();\n        let w = Natural::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.sub_mul_assign(v.clone(), w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u.clone();\n        n.sub_mul_assign(v.clone(), &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u.clone();\n        n.sub_mul_assign(&v, w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let mut n = u.clone();\n        n.sub_mul_assign(&v, &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().sub_mul(v.clone(), w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().sub_mul(v.clone(), &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().sub_mul(&v, w.clone());\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = u.clone().sub_mul(&v, &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n\n        let n = (&u).sub_mul(&v, &w);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\", \"0\");\n    test(\"0\", \"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"5\", \"123\");\n    test(\"123\", \"5\", \"1\", \"118\");\n    test(\"15\", \"3\", \"4\", \"3\");\n    test(\"1000000000000\", \"0\", \"123\", \"1000000000000\");\n    test(\"1000000000000\", \"1\", \"123\", \"999999999877\");\n    test(\"1000000000000\", \"123\", \"1\", \"999999999877\");\n    test(\"1000000000000\", \"123\", \"100\", \"999999987700\");\n    test(\"1000000000000\", \"100\", \"123\", \"999999987700\");\n    test(\"1000000000000\", \"65536\", \"65536\", \"995705032704\");\n    test(\"1000000000000\", \"1000000000000\", \"0\", \"1000000000000\");\n    test(\"1000000000000\", \"1000000000000\", \"1\", \"0\");\n    test(\"4294967296\", \"1\", \"1\", \"4294967295\");\n    test(\n        \"1000000000000000000000000\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"0\",\n    );\n    test(\n        \"1000000000001000000000000\",\n        \"1000000000000\",\n        \"1000000000000\",\n        \"1000000000000\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_fail_1() {\n    let mut x = Natural::from_str(\"123\").unwrap();\n    x.sub_mul_assign(\n        Natural::from_str(\"5\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_fail_2() {\n    let mut x = Natural::from_str(\"1000000000000\").unwrap();\n    x.sub_mul_assign(\n        Natural::from_str(\"1000000000000\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_val_ref_fail_1() {\n    let mut x = Natural::from_str(\"123\").unwrap();\n    x.sub_mul_assign(\n        Natural::from_str(\"5\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_val_ref_fail_2() {\n    let mut x = Natural::from_str(\"1000000000000\").unwrap();\n    x.sub_mul_assign(\n        Natural::from_str(\"1000000000000\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_ref_val_fail_1() {\n    let mut x = Natural::from_str(\"123\").unwrap();\n    x.sub_mul_assign(\n        &Natural::from_str(\"5\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_ref_val_fail_2() {\n    let mut x = Natural::from_str(\"1000000000000\").unwrap();\n    x.sub_mul_assign(\n        &Natural::from_str(\"1000000000000\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_ref_ref_fail_1() {\n    let mut x = Natural::from_str(\"123\").unwrap();\n    x.sub_mul_assign(\n        &Natural::from_str(\"5\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_assign_ref_ref_fail_2() {\n    let mut x = Natural::from_str(\"1000000000000\").unwrap();\n    x.sub_mul_assign(\n        &Natural::from_str(\"1000000000000\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_fail_1() {\n    Natural::from_str(\"123\").unwrap().sub_mul(\n        Natural::from_str(\"5\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_fail_2() {\n    Natural::from_str(\"1000000000000\").unwrap().sub_mul(\n        Natural::from_str(\"1000000000000\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_val_val_ref_fail_1() {\n    Natural::from_str(\"123\").unwrap().sub_mul(\n        Natural::from_str(\"5\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_val_val_ref_fail_2() {\n    Natural::from_str(\"1000000000000\").unwrap().sub_mul(\n        Natural::from_str(\"1000000000000\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_val_ref_val_fail_1() {\n    Natural::from_str(\"123\").unwrap().sub_mul(\n        &Natural::from_str(\"5\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_val_ref_val_fail_2() {\n    Natural::from_str(\"1000000000000\").unwrap().sub_mul(\n        &Natural::from_str(\"1000000000000\").unwrap(),\n        Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_val_ref_ref_fail_1() {\n    Natural::from_str(\"123\").unwrap().sub_mul(\n        &Natural::from_str(\"5\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_val_ref_ref_fail_2() {\n    Natural::from_str(\"1000000000000\").unwrap().sub_mul(\n        &Natural::from_str(\"1000000000000\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_ref_ref_ref_fail_1() {\n    (&Natural::from_str(\"123\").unwrap()).sub_mul(\n        &Natural::from_str(\"5\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn sub_mul_ref_ref_ref_fail_2() {\n    (&Natural::from_str(\"1000000000000\").unwrap()).sub_mul(\n        &Natural::from_str(\"1000000000000\").unwrap(),\n        &Natural::from_str(\"100\").unwrap(),\n    );\n}\n\n#[test]\nfn limbs_sub_mul_limb_greater_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(xs, ys, z)| {\n            assert_eq!(\n                limbs_sub_mul_limb_greater(&xs, &ys, z).map(Natural::from_owned_limbs_asc),\n                Natural::from_owned_limbs_asc(xs)\n                    .checked_sub_mul(Natural::from_owned_limbs_asc(ys), Natural::from(z))\n            );\n        },\n    );\n}\n\nfn limbs_sub_mul_limb_in_place_left_helper(\n    f: &mut dyn FnMut(&mut [Limb], &[Limb], Limb) -> Limb,\n    mut xs: Vec<Limb>,\n    ys: Vec<Limb>,\n    z: Limb,\n) {\n    let xs_old = xs.clone();\n    let borrow = f(&mut xs, &ys, z);\n    if borrow == 0 {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(xs_old)\n                .sub_mul(Natural::from_owned_limbs_asc(ys), Natural::from(z))\n        );\n    } else {\n        let mut extended_xs = xs_old;\n        extended_xs.push(0);\n        extended_xs.push(1);\n        let mut expected_xs = Natural::from_owned_limbs_asc(extended_xs)\n            .sub_mul(Natural::from_owned_limbs_asc(ys), Natural::from(z))\n            .into_limbs_asc();\n        assert_eq!(expected_xs.pop().unwrap(), borrow.wrapping_neg());\n        assert_eq!(xs, expected_xs);\n    }\n}\n\n#[test]\nfn limbs_sub_mul_limb_same_length_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().test_properties_with_config(\n        &config,\n        |(xs, ys, z)| {\n            limbs_sub_mul_limb_in_place_left_helper(\n                &mut limbs_sub_mul_limb_same_length_in_place_left,\n                xs,\n                ys,\n                z,\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_sub_mul_limb_greater_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_1().test_properties_with_config(\n        &config,\n        |(xs, ys, z)| {\n            limbs_sub_mul_limb_in_place_left_helper(\n                &mut limbs_sub_mul_limb_greater_in_place_left,\n                xs,\n                ys,\n                z,\n            );\n        },\n    );\n}\n\nmacro_rules! limbs_sub_mul_limb_in_place_right_helper {\n    ($f: ident, $xs: ident, $ys: ident, $z: ident) => {{\n        let ys_old = $ys.clone();\n        let borrow = $f(&$xs, &mut $ys, $z);\n        if borrow == 0 {\n            assert_eq!(\n                Natural::from_owned_limbs_asc($ys),\n                Natural::from_owned_limbs_asc($xs)\n                    .sub_mul(Natural::from_owned_limbs_asc(ys_old), Natural::from($z))\n            );\n        } else {\n            let mut extended_xs = $xs.clone();\n            extended_xs.push(0);\n            extended_xs.push(1);\n            let mut expected_xs = Natural::from_owned_limbs_asc(extended_xs)\n                .sub_mul(Natural::from_owned_limbs_asc(ys_old), Natural::from($z))\n                .into_limbs_asc();\n            assert_eq!(expected_xs.pop().unwrap(), borrow.wrapping_neg());\n            assert_eq!($ys, expected_xs);\n        }\n    }};\n}\n\n#[test]\nfn limbs_sub_mul_limb_same_length_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().test_properties_with_config(\n        &config,\n        |(xs, mut ys, z)| {\n            limbs_sub_mul_limb_in_place_right_helper!(\n                limbs_sub_mul_limb_same_length_in_place_right,\n                xs,\n                ys,\n                z\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_sub_mul_limb_greater_in_place_right_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_12().test_properties_with_config(\n        &config,\n        |(xs, mut ys, z)| {\n            limbs_sub_mul_limb_in_place_right_helper!(\n                limbs_sub_mul_limb_greater_in_place_right,\n                xs,\n                ys,\n                z\n            );\n        },\n    );\n}\n\n#[test]\nfn limbs_sub_mul_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_59().test_properties_with_config(&config, |(xs, ys, zs)| {\n        let expected = limbs_sub_mul(&xs, &ys, &zs).map(Natural::from_owned_limbs_asc);\n        assert_eq!(\n            expected,\n            Natural::from_owned_limbs_asc(xs).checked_sub_mul(\n                Natural::from_owned_limbs_asc(ys),\n                Natural::from_owned_limbs_asc(zs)\n            )\n        );\n    });\n}\n\n#[test]\nfn limbs_sub_mul_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_59().test_properties_with_config(&config, |(mut xs, ys, zs)| {\n        let xs_old = xs.clone();\n        let expected = if limbs_sub_mul_in_place_left(&mut xs, &ys, &zs) {\n            None\n        } else {\n            Some(Natural::from_owned_limbs_asc(xs))\n        };\n        assert_eq!(\n            expected,\n            Natural::from_owned_limbs_asc(xs_old).checked_sub_mul(\n                Natural::from_owned_limbs_asc(ys),\n                Natural::from_owned_limbs_asc(zs)\n            )\n        );\n    });\n}\n\n#[allow(clippy::useless_conversion)]\n#[test]\nfn sub_mul_properties() {\n    natural_triple_gen_var_7().test_properties(|(a, b, c)| {\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(&b, &c);\n        assert!(mut_a.is_valid());\n        let result = mut_a;\n\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(&b, c.clone());\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(b.clone(), &c);\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let mut mut_a = a.clone();\n        mut_a.sub_mul_assign(b.clone(), c.clone());\n        assert!(mut_a.is_valid());\n        assert_eq!(mut_a, result);\n\n        let result_alt = (&a).sub_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().sub_mul(&b, &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().sub_mul(&b, c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().sub_mul(b.clone(), &c);\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = a.clone().sub_mul(b.clone(), c.clone());\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert_eq!(&a - &b * &c, result);\n        assert_eq!((&a).checked_sub(&b * &c), Some(result));\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!((&n).sub_mul(&n, &Natural::ONE), 0);\n    });\n\n    natural_pair_gen().test_properties(|(a, b)| {\n        assert_eq!((&a).sub_mul(&Natural::ZERO, &b), a);\n        assert_eq!((&a).sub_mul(&b, &Natural::ZERO), a);\n        assert_eq!((&a * &b).sub_mul(a, b), 0);\n    });\n\n    natural_pair_gen_var_10().test_properties(|(a, b)| {\n        assert_eq!((&a).sub_mul(&Natural::ZERO, &b), a);\n        assert_eq!((&a).sub_mul(&b, &Natural::ZERO), a);\n        assert_eq!((&a * &b).sub_mul(a, b), 0);\n    });\n\n    unsigned_triple_gen_var_2::<Limb>().test_properties(|(x, y, z)| {\n        assert_eq!(\n            Limb::from(x).sub_mul(Limb::from(y), Limb::from(z)),\n            Natural::from(x).sub_mul(Natural::from(y), Natural::from(z))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/basic/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::comparison::traits::Min;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_nz::natural::Natural;\n\n#[test]\nfn test_min() {\n    let min = Natural::MIN;\n    assert!(min.is_valid());\n    assert_eq!(min, 0);\n    assert_eq!(min.to_string(), \"0\");\n}\n\n#[test]\nfn test_zero() {\n    let zero = Natural::ZERO;\n    assert!(zero.is_valid());\n    assert_eq!(zero, 0);\n    assert_eq!(zero.to_string(), \"0\");\n}\n\n#[test]\nfn test_one() {\n    let one = Natural::ONE;\n    assert!(one.is_valid());\n    assert_eq!(one, 1);\n    assert_eq!(one.to_string(), \"1\");\n}\n\n#[test]\nfn test_two() {\n    let two = Natural::TWO;\n    assert!(two.is_valid());\n    assert_eq!(two, 2);\n    assert_eq!(two.to_string(), \"2\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/basic/default.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::natural::Natural;\n\n#[test]\nfn test_default() {\n    let default = Natural::default();\n    assert!(default.is_valid());\n    assert_eq!(default, 0);\n    assert_eq!(default.to_string(), \"0\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/basic/named.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_nz::natural::Natural;\n\n#[test]\nfn test_named() {\n    assert_eq!(Natural::NAME, \"Natural\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/basic/size.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::natural::Natural;\nuse std::mem::size_of;\n\n#[test]\nfn test_size() {\n    if size_of::<usize>() == 8 {\n        assert_eq!(size_of::<Natural>(), 24);\n    }\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::common::test_cmp_helper;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_vec_gen, unsigned_vec_gen_var_3,\n    unsigned_vec_pair_gen_var_6, unsigned_vec_pair_gen_var_7, unsigned_vec_pair_gen_var_19,\n    unsigned_vec_triple_gen_var_29, unsigned_vec_triple_gen_var_30,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::comparison::cmp::{\n    limbs_cmp, limbs_cmp_normalized, limbs_cmp_same_length,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_var_2, natural_pair_gen, natural_pair_gen_var_9, natural_triple_gen,\n    natural_triple_gen_var_6,\n};\nuse malachite_nz::test_util::natural::comparison::cmp::natural_cmp_normalized_naive;\nuse num::BigUint;\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_cmp_same_length() {\n    let test = |xs: &[Limb], ys: &[Limb], out| {\n        assert_eq!(limbs_cmp_same_length(xs, ys), out);\n    };\n    test(&[3], &[5], Less);\n    test(&[3, 0], &[5, 0], Less);\n    test(&[1, 2], &[2, 1], Greater);\n    test(&[1, 2, 3], &[1, 2, 3], Equal);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_cmp_same_length_fail() {\n    limbs_cmp_same_length(&[1], &[2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_cmp() {\n    let test = |xs: &[Limb], ys: &[Limb], out| {\n        assert_eq!(limbs_cmp(xs, ys), out);\n    };\n    test(&[3], &[5], Less);\n    test(&[3, 1], &[5], Greater);\n    test(&[1, 2], &[2, 1, 3], Less);\n    test(&[1, 2, 3], &[1, 2, 3], Equal);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_cmp_normalized() {\n    let test = |xs: &[Limb], ys: &[Limb], out| {\n        assert_eq!(limbs_cmp_normalized(xs, ys), out);\n    };\n    test(&[5], &[6], Less);\n    test(&[1], &[8], Equal);\n    test(&[0, 0, 1], &[8], Equal);\n    test(&[17], &[3], Less);\n    test(&[1, 1, 1], &[1, 1], Greater);\n    test(&[1, 0, 1], &[1, 1], Less);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_cmp_normalized_fail_1() {\n    limbs_cmp_normalized(&[], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_cmp_normalized_fail_2() {\n    limbs_cmp_normalized(&[1, 2, 3], &[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_cmp_normalized_fail_3() {\n    limbs_cmp_normalized(&[1, 0], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_cmp_normalized_fail_4() {\n    limbs_cmp_normalized(&[1, 2, 3], &[1, 0]);\n}\n\n#[test]\nfn test_cmp() {\n    let strings = vec![\"0\", \"1\", \"2\", \"123\", \"999999999999\", \"1000000000000\", \"1000000000001\"];\n    test_cmp_helper::<Natural>(&strings);\n    test_cmp_helper::<BigUint>(&strings);\n    test_cmp_helper::<rug::Integer>(&strings);\n}\n\n#[test]\nfn test_cmp_normalized() {\n    let test = |x, y, out| {\n        let x = Natural::from_str(x).unwrap();\n        let y = Natural::from_str(y).unwrap();\n        assert_eq!(x.cmp_normalized(&y), out);\n        assert_eq!(natural_cmp_normalized_naive(&x, &y), out);\n    };\n    test(\"1\", \"4\", Equal);\n    test(\"5\", \"6\", Less);\n    test(\"3\", \"17\", Greater);\n    test(\"9\", \"36\", Equal);\n    test(\"117886223846050103296\", \"409\", Equal);\n    test(\"117886223846050103295\", \"409\", Less);\n    test(\"117886223846050103297\", \"409\", Greater);\n}\n\n#[test]\n#[should_panic]\nfn cmp_normalized_fail_1() {\n    Natural::ZERO.cmp_normalized(&Natural::ONE);\n}\n\n#[test]\n#[should_panic]\nfn cmp_normalized_fail_2() {\n    Natural::ONE.cmp_normalized(&Natural::ZERO);\n}\n\n#[test]\nfn limbs_cmp_same_length_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(xs, ys)| {\n        let cmp = limbs_cmp_same_length(&xs, &ys);\n        assert_eq!(\n            Natural::from_limbs_asc(&xs).cmp(&Natural::from_limbs_asc(&ys)),\n            cmp\n        );\n        assert_eq!(limbs_cmp_same_length(&ys, &xs).reverse(), cmp);\n    });\n\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        assert_eq!(limbs_cmp_same_length(&xs, &xs), Equal);\n    });\n\n    unsigned_vec_triple_gen_var_29().test_properties_with_config(&config, |(xs, ys, zs)| {\n        if limbs_cmp_same_length(&xs, &ys) == Less && limbs_cmp_same_length(&ys, &zs) == Less {\n            assert_eq!(limbs_cmp_same_length(&xs, &zs), Less);\n        } else if limbs_cmp_same_length(&xs, &ys) == Greater\n            && limbs_cmp_same_length(&ys, &zs) == Greater\n        {\n            assert_eq!(limbs_cmp_same_length(&xs, &zs), Greater);\n        }\n    });\n}\n\n#[test]\nfn limbs_cmp_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_7().test_properties_with_config(&config, |(xs, ys)| {\n        let cmp = limbs_cmp(&xs, &ys);\n        assert_eq!(\n            Natural::from_limbs_asc(&xs).cmp(&Natural::from_limbs_asc(&ys)),\n            cmp\n        );\n        assert_eq!(limbs_cmp(&ys, &xs).reverse(), cmp);\n    });\n\n    unsigned_vec_gen_var_3().test_properties_with_config(&config, |xs| {\n        assert_eq!(limbs_cmp(&xs, &xs), Equal);\n    });\n\n    unsigned_vec_triple_gen_var_30().test_properties_with_config(&config, |(xs, ys, zs)| {\n        if limbs_cmp(&xs, &ys) == Less && limbs_cmp(&ys, &zs) == Less {\n            assert_eq!(limbs_cmp(&xs, &zs), Less);\n        } else if limbs_cmp(&xs, &ys) == Greater && limbs_cmp(&ys, &zs) == Greater {\n            assert_eq!(limbs_cmp(&xs, &zs), Greater);\n        }\n    });\n}\n\n#[test]\nfn limbs_cmp_normalized_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_19().test_properties_with_config(&config, |(xs, ys)| {\n        let cmp = limbs_cmp_normalized(&xs, &ys);\n        assert_eq!(\n            Natural::from_limbs_asc(&xs).cmp_normalized(&Natural::from_limbs_asc(&ys)),\n            cmp\n        );\n        assert_eq!(limbs_cmp_normalized(&ys, &xs).reverse(), cmp);\n    });\n}\n\n#[test]\nfn cmp_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let cmp = x.cmp(&y);\n        assert_eq!(BigUint::from(&x).cmp(&BigUint::from(&y)), cmp);\n        assert_eq!(rug::Integer::from(&x).cmp(&rug::Integer::from(&y)), cmp);\n        assert_eq!(y.cmp(&x).reverse(), cmp);\n        assert_eq!(x == y, x.cmp(&y) == Equal);\n        assert_eq!((-y).cmp(&(-x)), cmp);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(x.cmp(&x), Equal);\n        assert!(x >= Natural::ZERO);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).cmp(&Natural::from(y)), x.cmp(&y));\n    });\n}\n\n#[test]\nfn cmp_normalized_properties() {\n    natural_pair_gen_var_9().test_properties(|(x, y)| {\n        let cmp = x.cmp_normalized(&y);\n        assert_eq!(natural_cmp_normalized_naive(&x, &y), cmp);\n        assert_eq!(y.cmp_normalized(&x).reverse(), cmp);\n    });\n\n    natural_gen_var_2().test_properties(|x| {\n        assert_eq!(x.cmp_normalized(&x), Equal);\n    });\n\n    natural_triple_gen_var_6().test_properties(|(x, y, z)| {\n        if x.cmp_normalized(&y) == Less && y.cmp_normalized(&z) == Less {\n            assert_eq!(x.cmp_normalized(&z), Less);\n        } else if x.cmp_normalized(&y) == Greater && y.cmp_normalized(&z) == Greater {\n            assert_eq!(x.cmp_normalized(&z), Greater);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::common::test_eq_helper;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse num::BigUint;\nuse rug;\n\n#[test]\nfn test_eq() {\n    let strings = vec![\"0\", \"1\", \"2\", \"123\", \"1000000000000\"];\n    test_eq_helper::<Natural>(&strings);\n    test_eq_helper::<BigUint>(&strings);\n    test_eq_helper::<rug::Integer>(&strings);\n}\n\n#[allow(clippy::cmp_owned, clippy::eq_op)]\n#[test]\nfn eq_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let eq = x == y;\n        assert_eq!(BigUint::from(&x) == BigUint::from(&y), eq);\n        assert_eq!(rug::Integer::from(&x) == rug::Integer::from(&y), eq);\n        assert_eq!(y == x, eq);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(x, x);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        if x == y && y == z {\n            assert_eq!(x, z);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x) == Natural::from(y), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_gen, natural_primitive_float_pair_gen};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_f32() {\n    let test = |u, v: f32, out| {\n        assert_eq!(Natural::from_str(u).unwrap().eq_abs(&v), out);\n        assert_eq!(!Natural::from_str(u).unwrap().ne_abs(&v), out);\n        assert_eq!(v.eq_abs(&Natural::from_str(u).unwrap()), out);\n    };\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"123\", 123.0, true);\n    test(\"123\", -123.0, true);\n    test(\"123\", 5.0, false);\n    test(\"123\", -5.0, false);\n    test(\"1000000000000\", 123.0, false);\n    test(\"1000000000000\", -123.0, false);\n    test(\"1\", 0.5, false);\n    test(\"1\", -0.5, false);\n    test(\"1\", f32::INFINITY, false);\n    test(\"1\", f32::NEGATIVE_INFINITY, false);\n    test(\"1\", f32::NAN, false);\n}\n\n#[test]\nfn test_eq_abs_f64() {\n    let test = |u, v: f64, out| {\n        assert_eq!(Natural::from_str(u).unwrap().eq_abs(&v), out);\n        assert_eq!(!Natural::from_str(u).unwrap().ne_abs(&v), out);\n        assert_eq!(v.eq_abs(&Natural::from_str(u).unwrap()), out);\n    };\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"123\", 123.0, true);\n    test(\"123\", -123.0, true);\n    test(\"123\", 5.0, false);\n    test(\"123\", -5.0, false);\n    test(\"1000000000000\", 123.0, false);\n    test(\"1000000000000\", -123.0, false);\n    test(\"1\", 0.5, false);\n    test(\"1\", -0.5, false);\n    test(\"1\", f64::INFINITY, false);\n    test(\"1\", f64::NEGATIVE_INFINITY, false);\n    test(\"1\", f64::NAN, false);\n}\n\nfn eq_abs_primitive_float_properties_helper<\n    T: EqAbs<Natural> + PartialEq<Natural> + PrimitiveFloat,\n>()\nwhere\n    Natural: EqAbs<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    natural_primitive_float_pair_gen::<T>().test_properties(|(n, x)| {\n        let eq = n.eq_abs(&x);\n        assert_ne!(n.ne_abs(&x), eq);\n\n        assert_eq!(x.eq_abs(&n), eq);\n        assert_eq!(n.partial_cmp_abs(&x) == Some(Equal), eq);\n        assert_eq!(n.eq_abs(&-x), eq);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_ne!(n, T::NAN);\n        assert_ne!(n, T::INFINITY);\n        assert_ne!(n, T::NEGATIVE_INFINITY);\n    });\n}\n\n#[test]\nfn eq_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(eq_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_pair_gen_var_7, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_signed_pair_gen, natural_unsigned_pair_gen};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_u32() {\n    let test = |u, v: u32, out| {\n        assert_eq!(Natural::from_str(u).unwrap().eq_abs(&v), out);\n        assert_eq!(!Natural::from_str(u).unwrap().ne_abs(&v), out);\n        assert_eq!(v.eq_abs(&Natural::from_str(u).unwrap()), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n}\n\n#[test]\nfn test_eq_abs_u64() {\n    let test = |u, v: u64, out| {\n        assert_eq!(Natural::from_str(u).unwrap().eq_abs(&v), out);\n        assert_eq!(!Natural::from_str(u).unwrap().ne_abs(&v), out);\n        assert_eq!(v.eq_abs(&Natural::from_str(u).unwrap()), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n}\n\n#[test]\nfn test_eq_abs_i32() {\n    let test = |u, v: i32, out| {\n        assert_eq!(Natural::from_str(u).unwrap().eq_abs(&v), out);\n        assert_eq!(!Natural::from_str(u).unwrap().ne_abs(&v), out);\n        assert_eq!(v.eq_abs(&Natural::from_str(u).unwrap()), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n}\n\n#[test]\nfn test_eq_abs_i64() {\n    let test = |u, v: i64, out| {\n        assert_eq!(Natural::from_str(u).unwrap().eq_abs(&v), out);\n        assert_eq!(!Natural::from_str(u).unwrap().ne_abs(&v), out);\n        assert_eq!(v.eq_abs(&Natural::from_str(u).unwrap()), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn eq_abs_primitive_int_properties_helper_unsigned<\n    T: EqAbs<Natural> + PartialEq<Natural> + PrimitiveUnsigned,\n>()\nwhere\n    Natural: EqAbs<T> + From<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    natural_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let eq = n.eq_abs(&u);\n        assert_ne!(n.ne_abs(&u), eq);\n        assert_eq!(n == u, eq);\n        assert_eq!(&n == &Natural::from(u), eq);\n\n        assert_eq!(u.eq_abs(&n), eq);\n        assert_eq!(u == n, eq);\n        assert_eq!(&Natural::from(u) == &n, eq);\n        assert_eq!(n.partial_cmp_abs(&u) == Some(Equal), eq);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).eq_abs(&y), x == y);\n        assert_eq!(x.eq_abs(&Natural::from(y)), x == y);\n    });\n}\n\nfn eq_abs_primitive_int_properties_helper_signed<T: EqAbs<Natural> + PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n    Natural: EqAbs<T> + TryFrom<T> + PartialOrdAbs<T>,\n{\n    natural_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let eq = n.eq_abs(&i);\n        assert_ne!(n.ne_abs(&i), eq);\n        // TODO assert_eq!(n.eq_abs(&Integer::from(i)), eq);\n\n        assert_eq!(i.eq_abs(&n), eq);\n        // TODO assert_eq!(Integer::from(i).eq_abs(&n), eq);\n        assert_eq!(n.partial_cmp_abs(&i) == Some(Equal), eq);\n        if i != T::MIN {\n            assert_eq!(n.eq_abs(&-i), eq);\n        }\n    });\n\n    signed_pair_gen_var_7::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::exact_from(x).eq_abs(&y), x.eq_abs(&y));\n        assert_eq!(x.eq_abs(&Natural::exact_from(y)), x.eq_abs(&y));\n    });\n}\n\n#[test]\nfn eq_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(eq_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(eq_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::hash::hash;\nuse malachite_nz::test_util::generators::natural_gen;\n\n#[test]\nfn hash_properties() {\n    natural_gen().test_properties(|x| {\n        assert_eq!(hash(&x), hash(&x.clone()));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_natural_primitive_float_triple_gen, natural_primitive_float_pair_gen,\n    natural_primitive_float_primitive_float_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_primitive_float() {\n    let test = |u, v: f32, out: Option<Ordering>| {\n        let out_rev = out.map(Ordering::reverse);\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp_abs(&v), out);\n        assert_eq!(v.partial_cmp_abs(&Natural::from_str(u).unwrap()), out_rev);\n\n        let v = f64::from(v);\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp_abs(&v), out);\n        assert_eq!(v.partial_cmp_abs(&Natural::from_str(u).unwrap()), out_rev);\n    };\n    test(\"5\", f32::NAN, None);\n    test(\"5\", f32::INFINITY, Some(Less));\n    test(\"5\", f32::NEGATIVE_INFINITY, Some(Less));\n\n    test(\"0\", 0.0, Some(Equal));\n    test(\"0\", -0.0, Some(Equal));\n    test(\"0\", 5.0, Some(Less));\n    test(\"0\", -5.0, Some(Less));\n    test(\"123\", 123.0, Some(Equal));\n    test(\"123\", 5.0, Some(Greater));\n    test(\"123\", -123.0, Some(Equal));\n    test(\"1000000000000\", 123.0, Some(Greater));\n\n    test(\"1208925819614629174706175\", 1.2089258e24, Some(Less));\n    test(\"1208925819614629174706176\", 1.2089258e24, Some(Equal));\n    test(\"1208925819614629174706177\", 1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706175\", -1.2089258e24, Some(Less));\n    test(\"1208925819614629174706176\", -1.2089258e24, Some(Equal));\n    test(\"1208925819614629174706177\", -1.2089258e24, Some(Greater));\n}\n\nfn partial_cmp_abs_primitive_float_properties_helper<T: PartialOrdAbs<Natural> + PrimitiveFloat>()\nwhere\n    Natural: TryFrom<T> + PartialOrd<T> + PartialOrdAbs<T>,\n{\n    natural_primitive_float_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp_abs = n.partial_cmp_abs(&u);\n        let cmp_abs_rev = cmp_abs.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp_abs(&n), cmp_abs_rev);\n\n        assert_eq!(n.partial_cmp(&u.abs()), cmp_abs);\n        assert_eq!(n.partial_cmp_abs(&-u), cmp_abs);\n    });\n\n    natural_natural_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    natural_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(u.abs() < v.abs());\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(u.abs() > v.abs());\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert!(x.ge_abs(&T::ZERO));\n        assert!(x.lt_abs(&T::NEGATIVE_INFINITY));\n        assert!(x.lt_abs(&T::INFINITY));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_pair_gen_var_7, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_natural_signed_triple_gen, natural_natural_unsigned_triple_gen,\n    natural_signed_pair_gen, natural_signed_pair_gen_var_1, natural_signed_signed_triple_gen,\n    natural_unsigned_pair_gen, natural_unsigned_unsigned_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_u32() {\n    let test = |u, v: u32, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp_abs(&v), cmp);\n        assert_eq!(\n            v.partial_cmp_abs(&Natural::from_str(u).unwrap()),\n            cmp.map(Ordering::reverse)\n        );\n        assert_eq!(lt, Natural::from_str(u).unwrap().lt_abs(&v));\n        assert_eq!(gt, Natural::from_str(u).unwrap().gt_abs(&v));\n        assert_eq!(le, Natural::from_str(u).unwrap().le_abs(&v));\n        assert_eq!(ge, Natural::from_str(u).unwrap().ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(gt, v.lt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(le, v.ge_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(ge, v.le_abs(&Natural::from_str(u).unwrap()));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n}\n\n#[test]\nfn test_partial_cmp_abs_u64() {\n    let test = |u, v: u64, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp_abs(&v), cmp);\n        assert_eq!(\n            v.partial_cmp_abs(&Natural::from_str(u).unwrap()),\n            cmp.map(Ordering::reverse)\n        );\n        assert_eq!(\n            v.partial_cmp_abs(&Natural::from_str(u).unwrap()),\n            cmp.map(Ordering::reverse)\n        );\n        assert_eq!(lt, Natural::from_str(u).unwrap().lt_abs(&v));\n        assert_eq!(gt, Natural::from_str(u).unwrap().gt_abs(&v));\n        assert_eq!(le, Natural::from_str(u).unwrap().le_abs(&v));\n        assert_eq!(ge, Natural::from_str(u).unwrap().ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(gt, v.lt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(le, v.ge_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(ge, v.le_abs(&Natural::from_str(u).unwrap()));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n}\n\n#[test]\nfn test_partial_cmp_abs_i32() {\n    let test = |u, v: i32, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp_abs(&v), cmp);\n        assert_eq!(\n            v.partial_cmp_abs(&Natural::from_str(u).unwrap()),\n            cmp.map(Ordering::reverse)\n        );\n        assert_eq!(\n            v.partial_cmp_abs(&Natural::from_str(u).unwrap()),\n            cmp.map(Ordering::reverse)\n        );\n        assert_eq!(lt, Natural::from_str(u).unwrap().lt_abs(&v));\n        assert_eq!(gt, Natural::from_str(u).unwrap().gt_abs(&v));\n        assert_eq!(le, Natural::from_str(u).unwrap().le_abs(&v));\n        assert_eq!(ge, Natural::from_str(u).unwrap().ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(gt, v.lt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(le, v.ge_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(ge, v.le_abs(&Natural::from_str(u).unwrap()));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"0\", -5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", -123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", -124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"123\", -122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n}\n\n#[test]\nfn test_partial_cmp_abs_i64() {\n    let test = |u, v: i64, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp_abs(&v), cmp);\n        assert_eq!(\n            v.partial_cmp_abs(&Natural::from_str(u).unwrap()),\n            cmp.map(Ordering::reverse)\n        );\n        assert_eq!(\n            v.partial_cmp_abs(&Natural::from_str(u).unwrap()),\n            cmp.map(Ordering::reverse)\n        );\n        assert_eq!(lt, Natural::from_str(u).unwrap().lt_abs(&v));\n        assert_eq!(gt, Natural::from_str(u).unwrap().gt_abs(&v));\n        assert_eq!(le, Natural::from_str(u).unwrap().le_abs(&v));\n        assert_eq!(ge, Natural::from_str(u).unwrap().ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(gt, v.lt_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(le, v.ge_abs(&Natural::from_str(u).unwrap()));\n        assert_eq!(ge, v.le_abs(&Natural::from_str(u).unwrap()));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"0\", -5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", -123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", -124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"123\", -122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"1000000000000\",\n        -1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n}\n\nfn partial_cmp_abs_primitive_int_properties_helper_unsigned<\n    T: PartialOrdAbs<Natural> + PrimitiveUnsigned,\n>()\nwhere\n    Natural: From<T> + PartialOrdAbs<T>,\n{\n    natural_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp = n.partial_cmp_abs(&u);\n        assert_eq!(Some(n.cmp(&Natural::from(u))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp_abs(&n), cmp_rev);\n        assert_eq!(Some(Natural::from(u).cmp(&n)), cmp_rev);\n    });\n\n    natural_natural_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    natural_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(u < v);\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(u > v);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).partial_cmp_abs(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp_abs(&Natural::from(y)), Some(x.cmp(&y)));\n    });\n}\n\nfn partial_cmp_abs_primitive_int_properties_helper_signed<\n    T: PartialOrdAbs<Natural> + PartialOrd<rug::Integer> + PrimitiveSigned,\n>()\nwhere\n    Integer: From<T>,\n    Natural: TryFrom<T> + PartialOrdAbs<T>,\n{\n    natural_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let cmp = n.partial_cmp_abs(&i);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(i.partial_cmp_abs(&n), cmp_rev);\n        if i != T::MIN {\n            assert_eq!(n.partial_cmp_abs(&-i), cmp);\n        }\n    });\n\n    natural_signed_pair_gen_var_1::<T>().test_properties(|(n, i)| {\n        let cmp = n.partial_cmp_abs(&i);\n        assert_eq!(Some(n.cmp(&Natural::exact_from(i))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(Some(Natural::exact_from(i).cmp(&n)), cmp_rev);\n    });\n\n    natural_natural_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n.lt_abs(&i) && i.lt_abs(&m) {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n.gt_abs(&i) && i.gt_abs(&m) {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    natural_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i.lt_abs(&n) && n.lt_abs(&j) {\n            assert!(i.lt_abs(&j));\n        } else if i.gt_abs(&n) && n.gt_abs(&j) {\n            assert!(i.gt_abs(&j));\n        }\n    });\n\n    signed_pair_gen_var_7::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::exact_from(x).partial_cmp_abs(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp_abs(&Natural::exact_from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_natural_primitive_float_triple_gen, natural_primitive_float_pair_gen,\n    natural_primitive_float_primitive_float_triple_gen,\n};\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_primitive_float() {\n    let test = |u, v: f32, out: Option<Ordering>| {\n        let out_rev = out.map(Ordering::reverse);\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(v.partial_cmp(&Natural::from_str(u).unwrap()), out_rev);\n        assert_eq!(v.partial_cmp(&rug::Integer::from_str(u).unwrap()), out_rev);\n\n        let v = f64::from(v);\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(v.partial_cmp(&Natural::from_str(u).unwrap()), out_rev);\n        assert_eq!(v.partial_cmp(&rug::Integer::from_str(u).unwrap()), out_rev);\n    };\n    test(\"5\", f32::NAN, None);\n    test(\"5\", f32::INFINITY, Some(Less));\n    test(\"5\", f32::NEGATIVE_INFINITY, Some(Greater));\n\n    test(\"0\", 0.0, Some(Equal));\n    test(\"0\", -0.0, Some(Equal));\n    test(\"0\", 5.0, Some(Less));\n    test(\"0\", -5.0, Some(Greater));\n    test(\"123\", 123.0, Some(Equal));\n    test(\"123\", 5.0, Some(Greater));\n    test(\"123\", -123.0, Some(Greater));\n    test(\"1000000000000\", 123.0, Some(Greater));\n\n    test(\"1208925819614629174706175\", 1.2089258e24, Some(Less));\n    test(\"1208925819614629174706176\", 1.2089258e24, Some(Equal));\n    test(\"1208925819614629174706177\", 1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706175\", -1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706176\", -1.2089258e24, Some(Greater));\n    test(\"1208925819614629174706177\", -1.2089258e24, Some(Greater));\n\n    test(\"117886223846050103296\", 1.1788622e20, Some(Equal));\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_float_properties_helper<\n    T: PartialOrd<Natural> + PartialOrd<rug::Integer> + PrimitiveFloat,\n>()\nwhere\n    Natural: TryFrom<T> + PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    natural_primitive_float_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp = n.partial_cmp(&u);\n        assert_eq!(rug::Integer::from(&n).partial_cmp(&u), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp(&n), cmp_rev);\n        assert_eq!(u.partial_cmp(&rug::Integer::from(&n)), cmp_rev);\n    });\n\n    natural_natural_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > u && u > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    natural_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert!(x >= T::ZERO);\n        assert!(x > T::NEGATIVE_INFINITY);\n        assert!(x < T::INFINITY);\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_pair_gen_var_7, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_natural_signed_triple_gen, natural_natural_unsigned_triple_gen,\n    natural_signed_pair_gen, natural_signed_pair_gen_var_1, natural_signed_signed_triple_gen,\n    natural_unsigned_pair_gen, natural_unsigned_unsigned_triple_gen,\n};\nuse malachite_nz::test_util::natural::comparison::partial_cmp_primitive_int::*;\nuse num::BigUint;\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_u32() {\n    let test = |u, v: u32, out| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(\n            num_partial_cmp_unsigned(&BigUint::from_str(u).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Natural::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", 122, Some(Greater));\n    test(\"1000000000000\", 123, Some(Greater));\n}\n\n#[test]\nfn test_partial_cmp_u64() {\n    let test = |u, v: u64, out| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(\n            num_partial_cmp_unsigned(&BigUint::from_str(u).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Natural::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", 122, Some(Greater));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"1000000000000\", 1000000000000, Some(Equal));\n    test(\"1000000000000\", 1000000000001, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_i32() {\n    let test = |u, v: i32, out| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Natural::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"0\", -5, Some(Greater));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", -123, Some(Greater));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", -124, Some(Greater));\n    test(\"123\", 122, Some(Greater));\n    test(\"123\", -122, Some(Greater));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"1000000000000\", -123, Some(Greater));\n}\n\n#[test]\nfn test_partial_cmp_i64() {\n    let test = |u, v: i64, out| {\n        assert_eq!(Natural::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Integer::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Natural::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"0\", -5, Some(Greater));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", -123, Some(Greater));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", -124, Some(Greater));\n    test(\"123\", 122, Some(Greater));\n    test(\"123\", -122, Some(Greater));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"1000000000000\", -123, Some(Greater));\n    test(\"1000000000000\", 1000000000000, Some(Equal));\n    test(\"1000000000000\", -1000000000000, Some(Greater));\n    test(\"1000000000000\", 1000000000001, Some(Less));\n    test(\"1000000000000\", -1000000000001, Some(Greater));\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_unsigned<\n    T: PartialOrd<Natural> + PartialOrd<rug::Integer> + PrimitiveUnsigned,\n>()\nwhere\n    BigUint: From<T>,\n    Natural: From<T> + PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    natural_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp = n.partial_cmp(&u);\n        assert_eq!(num_partial_cmp_unsigned(&From::from(&n), u), cmp);\n        assert_eq!(rug::Integer::from(&n).partial_cmp(&u), cmp);\n        assert_eq!(Some(n.cmp(&Natural::from(u))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp(&n), cmp_rev);\n        assert_eq!(u.partial_cmp(&rug::Integer::from(&n)), cmp_rev);\n        assert_eq!(Some(Natural::from(u).cmp(&n)), cmp_rev);\n    });\n\n    natural_natural_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > u && u > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    natural_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert!(x >= T::ZERO);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Natural::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_signed<\n    T: PartialOrd<Natural> + PartialOrd<rug::Integer> + PrimitiveSigned,\n>()\nwhere\n    Integer: From<T>,\n    Natural: TryFrom<T> + PartialOrd<T>,\n    rug::Integer: PartialOrd<T>,\n{\n    natural_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let cmp = n.partial_cmp(&i);\n        assert_eq!(rug::Integer::from(&n).partial_cmp(&i), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(i.partial_cmp(&n), cmp_rev);\n        assert_eq!(i.partial_cmp(&rug::Integer::from(&n)), cmp_rev);\n    });\n\n    natural_signed_pair_gen_var_1::<T>().test_properties(|(n, i)| {\n        let cmp = n.partial_cmp(&i);\n        assert_eq!(Some(n.cmp(&Natural::exact_from(i))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(Some(Natural::exact_from(i).cmp(&n)), cmp_rev);\n    });\n\n    natural_natural_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n < i && i < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > i && i > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    natural_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i < n && n < j {\n            assert!(i < j);\n        } else if i > n && n > j {\n            assert!(i > j);\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert!(x >= T::ZERO);\n    });\n\n    signed_pair_gen_var_7::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::exact_from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Natural::exact_from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_primitive_float_pair_gen;\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_primitive_float() {\n    let test = |u, v: f32, out| {\n        assert_eq!(Natural::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Natural::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n\n        let v = f64::from(v);\n        assert_eq!(Natural::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Natural::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n    };\n    test(\"5\", f32::NAN, false);\n    test(\"5\", f32::INFINITY, false);\n    test(\"5\", f32::NEGATIVE_INFINITY, false);\n\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"123\", 123.0, true);\n    test(\"123\", 5.0, false);\n    test(\"123\", -123.0, false);\n    test(\"1000000000000\", 123.0, false);\n\n    test(\"1208925819614629174706175\", 1.2089258e24, false);\n    test(\"1208925819614629174706176\", 1.2089258e24, true);\n    test(\"1208925819614629174706177\", 1.2089258e24, false);\n    test(\"1208925819614629174706175\", -1.2089258e24, false);\n    test(\"1208925819614629174706176\", -1.2089258e24, false);\n    test(\"1208925819614629174706177\", -1.2089258e24, false);\n}\n\n#[allow(clippy::cmp_owned, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_float_properties_helper<\n    T: PartialEq<Natural> + PartialEq<rug::Integer> + PrimitiveFloat,\n>()\nwhere\n    Natural: TryFrom<T> + PartialEq<T> + PartialOrd<T>,\n    rug::Integer: PartialEq<T>,\n{\n    natural_primitive_float_pair_gen::<T>().test_properties(|(n, f)| {\n        let eq = n == f;\n        assert_eq!(rug::Integer::from(&n) == f, eq);\n        assert_eq!(f == n, eq);\n        assert_eq!(f == rug::Integer::from(&n), eq);\n        assert_eq!(n.partial_cmp(&f) == Some(Equal), eq);\n        if eq {\n            assert!(f.is_integer());\n        }\n    });\n}\n\n#[test]\nfn partial_eq_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_eq_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_pair_gen_var_7, unsigned_pair_gen_var_27};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_signed_pair_gen, natural_unsigned_pair_gen};\nuse malachite_nz::test_util::natural::comparison::partial_eq_primitive_int::*;\nuse num::BigUint;\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_u32() {\n    let test = |u, v: u32, out| {\n        assert_eq!(Natural::from_str(u).unwrap() == v, out);\n        assert_eq!(\n            num_partial_eq_unsigned(&BigUint::from_str(u).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Natural::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n}\n\n#[test]\nfn test_partial_eq_u64() {\n    let test = |u, v: u64, out| {\n        assert_eq!(Natural::from_str(u).unwrap() == v, out);\n        assert_eq!(\n            num_partial_eq_unsigned(&BigUint::from_str(u).unwrap(), v),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Natural::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n}\n\n#[test]\nfn test_partial_eq_i32() {\n    let test = |u, v: i32, out| {\n        assert_eq!(Natural::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Natural::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, false);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n}\n\n#[test]\nfn test_partial_eq_i64() {\n    let test = |u, v: i64, out| {\n        assert_eq!(Natural::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Integer::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Natural::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Integer::from_str(u).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, false);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_int_properties_helper_unsigned<\n    T: PartialEq<Natural> + PartialEq<rug::Integer> + PrimitiveUnsigned,\n>()\nwhere\n    BigUint: From<T>,\n    Natural: From<T> + PartialEq<T> + PartialOrd<T>,\n    rug::Integer: PartialEq<T>,\n{\n    natural_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let eq = n == u;\n        assert_eq!(num_partial_eq_unsigned(&From::from(&n), u), eq);\n        assert_eq!(rug::Integer::from(&n) == u, eq);\n        assert_eq!(&n == &Natural::from(u), eq);\n\n        assert_eq!(u == n, eq);\n        assert_eq!(u == rug::Integer::from(&n), eq);\n        assert_eq!(&Natural::from(u) == &n, eq);\n        assert_eq!(n.partial_cmp(&u) == Some(Equal), eq);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x) == y, x == y);\n        assert_eq!(x == Natural::from(y), x == y);\n    });\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_int_properties_helper_signed<\n    T: PartialEq<Natural> + PartialEq<rug::Integer> + PrimitiveSigned,\n>()\nwhere\n    Integer: From<T>,\n    Natural: TryFrom<T> + PartialEq<T> + PartialOrd<T>,\n    rug::Integer: PartialEq<T>,\n{\n    natural_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let eq = n == i;\n        assert_eq!(rug::Integer::from(&n) == i, eq);\n        assert_eq!(&n == &Integer::from(i), eq);\n\n        assert_eq!(i == n, eq);\n        assert_eq!(i == rug::Integer::from(&n), eq);\n        assert_eq!(&Integer::from(i) == &n, eq);\n        assert_eq!(n.partial_cmp(&i) == Some(Equal), eq);\n    });\n\n    signed_pair_gen_var_7::<T>().test_properties(|(x, y)| {\n        assert_eq!(Natural::exact_from(x) == y, x == y);\n        assert_eq!(x == Natural::exact_from(y), x == y);\n    });\n}\n\n#[test]\nfn partial_eq_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_eq_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_eq_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_pair_gen_var_27};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen};\nuse num::BigUint;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_clone() {\n    let test = |u| {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_string(), u);\n        assert!(x.is_valid());\n\n        let x = BigUint::from_str(u).unwrap();\n        assert_eq!(x.to_string(), u);\n\n        let x = rug::Integer::from_str(u).unwrap();\n        assert_eq!(x.to_string(), u);\n    };\n    test(\"123\");\n    test(\"1000000000000\");\n}\n\n#[test]\nfn test_clone_and_clone_from() {\n    let test = |u, v| {\n        // clone_from\n        let mut x = Natural::from_str(u).unwrap();\n        x.clone_from(&Natural::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n        assert!(x.is_valid());\n\n        let mut x = BigUint::from_str(u).unwrap();\n        x.clone_from(&BigUint::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n\n        let mut x = rug::Integer::from_str(u).unwrap();\n        x.clone_from(&rug::Integer::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n    };\n    test(\"123\", \"456\");\n    test(\"123\", \"1000000000000\");\n    test(\"1000000000000\", \"123\");\n    test(\"1000000000000\", \"2000000000000\");\n}\n\n#[allow(clippy::redundant_clone)]\n#[test]\nfn clone_and_clone_from_properties() {\n    natural_gen().test_properties(|x| {\n        let mut_x = x.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, x);\n\n        assert_eq!(Natural::from(&BigUint::from(&x).clone()), x);\n        assert_eq!(Natural::exact_from(&rug::Integer::from(&x).clone()), x);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        let n = Natural::from(u);\n        let cloned_u = u;\n        let cloned_n = n.clone();\n        assert_eq!(cloned_u, cloned_n);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.clone_from(&y);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, y);\n\n        let mut num_x = BigUint::from(&x);\n        num_x.clone_from(&BigUint::from(&y));\n        assert_eq!(Natural::from(&num_x), y);\n\n        let mut rug_x = rug::Integer::from(&x);\n        rug_x.clone_from(&rug::Integer::from(&y));\n        assert_eq!(Natural::exact_from(&rug_x), y);\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(u, v)| {\n        let x = Natural::from(u);\n        let y = Natural::from(v);\n\n        let mut mut_u = u;\n        let mut mut_x = x.clone();\n        mut_u.clone_from(&v);\n        mut_x.clone_from(&y);\n        assert_eq!(mut_x, mut_u);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/digits/from_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::{Itertools, repeat_n};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, PowerOf2Digits, SaturatingFrom, WrappingFrom,\n};\nuse malachite_base::slices::{slice_leading_zeros, slice_trailing_zeros};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_10, unsigned_vec_unsigned_pair_gen_var_5,\n    unsigned_vec_unsigned_pair_gen_var_12,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::digits::general_digits::*;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen_var_5, natural_vec_natural_pair_gen_var_1,\n    natural_vec_natural_pair_gen_var_2, natural_vec_natural_pair_gen_var_3,\n    natural_vec_natural_pair_gen_var_4, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2,\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3,\n};\nuse std::iter::empty;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nfn verify_limbs_from_digits_small_base<T: PrimitiveUnsigned>(\n    original_out: &[Limb],\n    xs: &[T],\n    base: u64,\n    out_len: usize,\n    out: &[Limb],\n    preserve_unused_out: bool,\n) where\n    Natural: From<T>,\n{\n    let mut expected_limbs = from_digits_desc_naive_primitive(xs, T::exact_from(base))\n        .unwrap()\n        .into_limbs_asc();\n    assert!(expected_limbs.len() <= out_len);\n    expected_limbs.resize(out_len, 0);\n    assert_eq!(expected_limbs, &out[..out_len]);\n    if preserve_unused_out {\n        assert_eq!(&original_out[out_len..], &out[out_len..]);\n    }\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_from_digits_small_base_basecase() {\n    fn test(out_before: &[Limb], xs: &[u8], base: u64, out_after: &[Limb]) {\n        let mut out = out_before.to_vec();\n        let out_len = limbs_from_digits_small_base_basecase(&mut out, xs, base).unwrap();\n        assert_eq!(&out[..out_len], out_after);\n        verify_limbs_from_digits_small_base(out_before, xs, base, out_len, &out, true);\n    }\n    // - res_digit == 0\n    test(&[10; 2], &[0], 9, &[]);\n    // - base != 10\n    // - size == 0 second time\n    // - res_digit != 0\n    test(&[10; 2], &[1], 9, &[1]);\n    test(&[10; 2], &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, &[123456]);\n    test(&[10; 2], &[1, 2, 4, 2, 2, 3, 1, 1], 5, &[123456]);\n    test(&[10; 2], &[2, 3, 5, 1, 3, 2, 0], 6, &[123456]);\n    test(&[10; 2], &[1, 0, 2, 2, 6, 3, 4], 7, &[123456]);\n    test(&[10; 2], &[2, 0, 7, 3, 1, 3], 9, &[123456]);\n    // - base == 10\n    test(&[10; 2], &[1, 2, 3, 4, 5, 6], 10, &[123456]);\n    test(&[10; 2], &[8, 4, 8, 3, 3], 11, &[123456]);\n    test(&[10; 2], &[5, 11, 5, 4, 0], 12, &[123456]);\n    test(&[10; 2], &[4, 4, 2, 6, 8], 13, &[123456]);\n    test(&[10; 2], &[3, 2, 13, 12, 4], 14, &[123456]);\n    test(&[10; 2], &[2, 6, 8, 10, 6], 15, &[123456]);\n    test(&[10; 2], &[12, 34, 56], 100, &[123456]);\n    test(&[10; 2], &[8, 19, 87], 123, &[123456]);\n    test(&[10; 2], &[1, 229, 36], 255, &[123456]);\n    // - j < xs_len\n    // - size == 0 first time\n    // - y != 0\n    // - size != 0 second time\n    // - cy_limb != 0 second time\n    test(&[10; 4], &[27, 90, 34, 55, 72, 93], 104, &[4056409437, 78]);\n    // - size != 0 first time\n    // - cy_limb != 0 first time\n    test(\n        &[10; 13],\n        &[93, 88, 7, 58, 53, 12, 72, 49, 56, 91],\n        98,\n        &[419414959, 1047946650, 4],\n    );\n    // - cy_limb == 0 second time\n    test(\n        &[10; 7],\n        &[14, 117, 113, 119, 39, 15, 71, 111, 83, 69, 36, 65, 47, 105, 10, 57, 101],\n        121,\n        &[3340886628, 3137387930, 2143550403, 399066],\n    );\n    // - cy_limb == 0 first time\n    test(\n        &[10; 15],\n        &[\n            116, 130, 52, 119, 76, 102, 131, 43, 138, 137, 117, 78, 23, 136, 111, 20, 132, 103,\n            126, 38, 96, 23, 23, 128, 17, 123, 30, 135, 39, 114, 36, 49, 22, 90, 79, 87, 32, 21,\n            67, 55, 138, 33, 44, 84, 72, 104, 10, 118, 28, 63, 85, 36, 110, 108, 61, 16, 115, 75,\n            26,\n        ],\n        144,\n        &[\n            3776613706, 1267825649, 3972333409, 93554931, 973182892, 3884362880, 1799682409,\n            3576731056, 1717911507, 3669574309, 502648924, 825650249, 3326096263, 105,\n        ],\n    );\n    // - y == 0\n    test(&[10; 3], &[0; 8], 17, &[]);\n}\n\nfn limbs_from_digits_small_base_basecase_properties_helper<T: PrimitiveUnsigned>()\nwhere\n    Limb: WrappingFrom<T>,\n    Natural: From<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_stripe_n\", 4 << Limb::LOG_WIDTH);\n    config.insert(\"mean_digit_count_n\", 32);\n    config.insert(\"mean_excess_limb_count_n\", 32);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3::<T, Limb>().test_properties_with_config(\n        &config,\n        |(mut out, xs, base)| {\n            let t_base = T::exact_from(base);\n            assert_eq!(\n                limbs_from_digits_small_base_basecase(&mut out, &xs, base).is_some(),\n                xs.iter().all(|&x| x < t_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2::<T, Limb>().test_properties_with_config(\n        &config,\n        |(mut out, xs, base)| {\n            let old_out = out.clone();\n            let out_len = limbs_from_digits_small_base_basecase(&mut out, &xs, base).unwrap();\n            verify_limbs_from_digits_small_base(&old_out, &xs, base, out_len, &out, true);\n        },\n    );\n}\n\n#[test]\nfn limbs_from_digits_small_base_basecase_properties() {\n    apply_fn_to_unsigneds!(limbs_from_digits_small_base_basecase_properties_helper);\n}\n\n#[test]\nfn test_limbs_from_digits_small_base() {\n    fn test(out_before: &[Limb], xs: &[u8], base: u64, out_after: &[Limb]) {\n        let mut out = out_before.to_vec();\n        let out_len = limbs_from_digits_small_base(&mut out, xs, base).unwrap();\n        assert_eq!(&out[..out_len], out_after);\n        verify_limbs_from_digits_small_base(out_before, xs, base, out_len, &out, false);\n    }\n    #[cfg(feature = \"32_bit_limbs\")]\n    {\n        // - xs_len < SET_STR_PRECOMPUTE_THRESHOLD\n        test(&[10; 2], &[0], 9, &[]);\n        test(&[10; 2], &[1], 9, &[1]);\n        test(&[10; 2], &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, &[123456]);\n        // - xs_len >= SET_STR_PRECOMPUTE_THRESHOLD\n        // - xs_len > len_lo in limbs_from_digits_small_base_divide_and_conquer\n        // - len_hi < SET_STR_DC_THRESHOLD in limbs_from_digits_small_base_divide_and_conquer\n        // - out_len_hi > 0 in limbs_from_digits_small_base_divide_and_conquer\n        // - len_lo < SET_STR_DC_THRESHOLD in limbs_from_digits_small_base_divide_and_conquer\n        // - out_len_lo != 0 in limbs_from_digits_small_base_divide_and_conquer\n        test(\n            &[10; 21],\n            &[\n                73, 23, 120, 45, 108, 147, 113, 90, 129, 11, 86, 0, 102, 81, 22, 17, 32, 121, 29,\n                82, 27, 25, 39, 9, 139, 59, 51, 13, 44, 3, 37, 104, 41, 40, 87, 66, 83, 146, 40,\n                132, 15, 50, 66, 80, 73, 61, 75, 25, 78, 34, 128, 86, 68, 26, 62, 135, 21, 9, 27,\n                74, 12, 39, 67, 15, 41, 50, 144, 35, 98, 140, 124, 132, 10, 37, 101, 99, 14,\n            ],\n            150,\n            &[\n                807199004, 1221740022, 1059231306, 812955315, 3612990781, 1076930217, 4174550874,\n                1465864994, 3608544731, 124397213, 3447302311, 1159387221, 1234841936, 1231519323,\n                2930655271, 132298638, 866385569, 3068,\n            ],\n        );\n        // - len_hi >= SET_STR_DC_THRESHOLD in limbs_from_digits_small_base_divide_and_conquer\n        // - len_lo >= SET_STR_DC_THRESHOLD in limbs_from_digits_small_base_divide_and_conquer\n        test(\n            &[10; 26],\n            &[\n                93, 88, 7, 58, 53, 12, 72, 49, 56, 91, 68, 47, 3, 50, 89, 6, 66, 53, 64, 90, 97,\n                65, 54, 17, 8, 15, 9, 17, 0, 92, 68, 96, 25, 27, 74, 39, 36, 75, 93, 95, 11, 5, 8,\n                56, 32, 50, 23, 67, 15, 26, 56, 87, 92, 1, 68, 19, 55, 67, 40, 44, 29, 60, 89, 4,\n                11, 34, 46, 46, 78, 89, 47, 40, 30, 93, 57, 42, 7, 0, 75, 96, 70, 82, 10, 74, 29,\n                36, 20, 51, 86, 4, 45, 56, 29, 38, 58, 77, 34, 43, 32, 92, 38, 20, 95, 35, 7, 56,\n                87, 54, 61,\n            ],\n            98,\n            &[\n                3323139349, 754115856, 3445503528, 536428460, 3075474891, 2424049884, 1254229577,\n                3821259306, 2296236337, 3400357558, 2698888552, 1812174, 3958831496, 3237209566,\n                3557655660, 684907780, 2294464631, 693096664, 1238680639, 1345304633, 2472224180,\n                2869650732, 125880,\n            ],\n        );\n        test(\n            &[10; 1336],\n            &[\n                6, 14, 15, 18, 4, 19, 14, 2, 21, 21, 20, 4, 17, 8, 15, 12, 21, 0, 2, 8, 22, 0, 20,\n                2, 9, 2, 12, 7, 18, 21, 3, 4, 6, 0, 15, 12, 1, 1, 10, 19, 16, 8, 20, 11, 4, 2, 3,\n                9, 8, 9, 14, 18, 11, 21, 22, 22, 5, 8, 10, 14, 18, 13, 21, 14, 7, 9, 21, 17, 6, 4,\n                17, 22, 16, 16, 18, 22, 3, 5, 10, 9, 10, 0, 5, 17, 9, 14, 16, 10, 4, 5, 21, 8, 8,\n                9, 16, 7, 15, 15, 4, 11, 14, 1, 3, 20, 15, 4, 2, 6, 7, 4, 3, 21, 15, 7, 12, 9, 21,\n                15, 11, 10, 2, 8, 19, 12, 22, 15, 3, 1, 20, 14, 8, 8, 12, 11, 17, 1, 5, 22, 21, 21,\n                11, 13, 17, 0, 10, 20, 1, 14, 17, 20, 14, 3, 6, 11, 14, 9, 21, 12, 9, 12, 17, 18,\n                11, 7, 19, 5, 0, 13, 20, 12, 17, 8, 3, 5, 19, 5, 18, 10, 10, 7, 22, 20, 3, 21, 2,\n                18, 15, 15, 16, 1, 13, 15, 21, 16, 4, 15, 18, 4, 4, 7, 16, 20, 0, 7, 2, 6, 15, 10,\n                16, 0, 0, 2, 4, 21, 5, 7, 16, 8, 0, 20, 3, 12, 18, 8, 9, 8, 3, 1, 10, 8, 9, 17, 9,\n                17, 18, 17, 14, 9, 19, 22, 1, 21, 9, 22, 8, 19, 0, 5, 16, 10, 17, 2, 0, 17, 17, 6,\n                20, 3, 0, 4, 21, 0, 14, 13, 16, 12, 20, 9, 1, 18, 21, 11, 13, 18, 13, 2, 2, 12, 3,\n                0, 16, 12, 21, 22, 19, 15, 0, 8, 9, 0, 12, 6, 19, 12, 7, 4, 3, 6, 18, 17, 1, 5, 22,\n                22, 18, 3, 1, 14, 9, 1, 20, 10, 17, 11, 3, 19, 3, 16, 5, 11, 2, 17, 0, 21, 1, 14,\n                2, 22, 11, 17, 22, 3, 4, 17, 19, 3, 7, 20, 19, 17, 19, 22, 12, 15, 22, 1, 12, 6, 5,\n                4, 1, 4, 12, 13, 2, 2, 21, 5, 16, 3, 21, 15, 18, 0, 6, 11, 12, 1, 7, 14, 11, 8, 1,\n                12, 12, 18, 0, 12, 12, 6, 0, 5, 4, 18, 6, 20, 3, 18, 20, 17, 20, 22, 11, 3, 7, 15,\n                8, 11, 14, 21, 2, 11, 3, 22, 19, 2, 5, 21, 10, 11, 18, 9, 17, 18, 7, 12, 13, 1, 22,\n                11, 11, 3, 3, 21, 16, 7, 17, 3, 18, 2, 5, 4, 12, 15, 16, 22, 4, 18, 8, 20, 20, 15,\n                18, 7, 9, 18, 3, 0, 13, 15, 0, 19, 10, 10, 10, 7, 11, 10, 21, 19, 14, 20, 0, 17,\n                22, 8, 3, 19, 17, 10, 13, 14, 15, 20, 4, 10, 12, 8, 0, 14, 12, 22, 18, 1, 7, 14,\n                11, 7, 9, 13, 2, 0, 6, 17, 17, 1, 19, 14, 11, 10, 2, 17, 20, 6, 1, 22, 17, 14, 11,\n                0, 5, 14, 11, 16, 7, 0, 0, 13, 2, 12, 7, 8, 12, 3, 0, 3, 13, 20, 16, 16, 5, 8, 9,\n                22, 7, 18, 6, 10, 21, 17, 0, 8, 21, 14, 5, 6, 4, 15, 22, 22, 13, 6, 12, 13, 21, 5,\n                1, 10, 21, 12, 15, 21, 7, 6, 5, 5, 7, 11, 8, 8, 14, 8, 17, 10, 15, 14, 19, 5, 2, 5,\n                22, 19, 10, 20, 16, 11, 11, 19, 6, 20, 13, 18, 3, 9, 14, 1, 12, 2, 5, 12, 10, 6, 6,\n                4, 7, 19, 9, 18, 8, 18, 2, 7, 21, 11, 0, 2, 13, 0, 0, 9, 2, 21, 15, 20, 7, 18, 13,\n                22, 2, 11, 4, 21, 18, 10, 22, 18, 9, 4, 16, 19, 4, 16, 10, 22, 14, 8, 20, 6, 1, 1,\n                18, 18, 20, 13, 22, 19, 10, 19, 19, 21, 0, 10, 21, 15, 11, 21, 13, 1, 4, 12, 22,\n                15, 13, 20, 17, 3, 15, 14, 12, 9, 15, 20, 9, 1, 8, 18, 20, 21, 3, 17, 9, 21, 16,\n                13, 1, 20, 11, 14, 21, 13, 21, 11, 17, 5, 9, 18, 14, 11, 9, 6, 10, 16, 3, 10, 7,\n                22, 2, 1, 2, 9, 2, 8, 2, 11, 18, 18, 11, 2, 17, 20, 22, 10, 18, 16, 6, 17, 7, 9,\n                14, 16, 1, 7, 15, 13, 14, 16, 10, 4, 2, 19, 5, 2, 21, 12, 6, 9, 13, 10, 13, 5, 5,\n                20, 14, 20, 17, 15, 15, 6, 9, 11, 6, 7, 12, 1, 10, 10, 15, 3, 8, 11, 3, 17, 1, 11,\n                18, 3, 16, 5, 20, 22, 9, 10, 2, 5, 6, 6, 13, 1, 7, 9, 22, 4, 10, 4, 3, 12, 8, 16,\n                6, 8, 17, 2, 16, 19, 11, 10, 21, 8, 20, 12, 19, 1, 17, 8, 2, 8, 22, 7, 10, 11, 4,\n                5, 22, 21, 2, 20, 19, 21, 13, 16, 22, 0, 4, 16, 4, 20, 0, 11, 20, 3, 17, 13, 3, 16,\n                1, 13, 18, 18, 14, 0, 0, 14, 6, 20, 13, 14, 5, 5, 13, 0, 20, 3, 6, 2, 20, 9, 15, 7,\n                15, 3, 6, 3, 20, 6, 1, 7, 3, 13, 14, 9, 5, 11, 4, 17, 16, 3, 7, 4, 17, 13, 10, 2,\n                18, 5, 13, 21, 11, 21, 21, 19, 10, 7, 20, 4, 11, 5, 10, 18, 10, 18, 15, 12, 7, 15,\n                17, 14, 6, 17, 20, 3, 0, 5, 12, 11, 20, 6, 22, 9, 18, 6, 10, 2, 22, 21, 16, 5, 20,\n                20, 9, 3, 17, 11, 16, 20, 2, 9, 1, 9, 3, 22, 17, 10, 16, 18, 1, 11, 11, 7, 10, 14,\n                22, 18, 1, 5, 5, 21, 5, 2, 21, 16, 1, 21, 16, 11, 4, 13, 20, 1, 20, 15, 0, 21, 11,\n                5, 0, 6, 4, 8, 17, 8, 21, 20, 22, 8, 8, 2, 10, 8, 3, 18, 6, 0, 19, 15, 6, 20, 19,\n                4, 10, 10, 8, 3, 14, 15, 16, 9, 13, 7, 14, 11, 21, 4, 10, 4, 7, 11, 0, 12, 16, 11,\n                11, 1, 20, 11, 5, 0, 5, 5, 0, 20, 18, 20, 21, 0, 9, 10, 5, 8, 0, 17, 20, 16, 2, 22,\n                5, 19, 8, 18, 22, 18, 19, 5, 6, 17, 13, 9, 12, 4, 22, 17, 1, 12, 14, 22, 6, 8, 10,\n                15, 8, 4, 20, 1, 22, 6, 0, 3, 18, 2, 0, 11, 11, 12, 4, 3, 19, 20, 20, 1, 9, 10, 9,\n                1, 17, 0, 12, 6, 7, 11, 1, 9, 19, 0, 2, 10, 11, 13, 0, 9, 14, 5, 12, 1, 17, 11, 11,\n                9, 11, 8, 11, 17, 16, 14, 21, 22, 4, 0, 19, 19, 20, 10, 5, 19, 5, 14, 20, 2, 14,\n                15, 20, 19, 18, 22, 20, 11, 8, 17, 5, 11, 1, 7, 21, 22, 15, 16, 5, 12, 22, 15, 18,\n                3, 5, 9, 1, 21, 20, 9, 12, 8, 18, 13, 6, 16, 12, 11, 12, 2, 8, 11, 6, 15, 14, 17,\n                5, 4, 14, 10, 10, 16, 4, 2, 16, 16, 5, 18, 19, 20, 2, 2, 12, 14, 7, 5, 19, 18, 17,\n                9, 22, 8, 2, 13, 20, 6, 13, 5, 3, 14, 13, 4, 20, 12, 8, 12, 20, 1, 1, 3, 12, 22,\n                18, 5, 15, 9, 21, 20, 12, 15, 7, 20, 11, 7, 6, 9, 1, 20, 8, 13, 11, 4, 14, 15, 14,\n                16, 7, 19, 10, 5, 10, 9, 17, 6, 8, 20, 15, 20, 5, 16, 22, 14, 3, 4, 15, 18, 18, 6,\n                15, 1, 10, 9, 1, 5, 4, 4, 4, 16, 4, 16, 6, 14, 8, 3, 7, 21, 5, 8, 20, 2, 10, 15, 1,\n                7, 11, 7, 3, 4, 19, 3, 10, 10, 16, 20, 19, 0, 6, 10, 13, 9, 18, 17, 1, 0, 15, 2,\n                13, 22, 13, 15, 5, 17, 6, 12, 18, 2, 1, 20, 22, 4, 14, 21, 0, 21, 21, 13, 20, 8,\n                17, 16, 6, 8, 7, 8, 4, 20, 19, 0, 18, 4, 12, 19, 9, 14, 18, 19, 21, 9, 2, 11, 1,\n                21, 21, 17, 1, 6, 1, 1, 12, 0, 10, 11, 14, 7, 2, 19, 13, 5, 10, 10, 7, 7, 14, 11,\n                12, 11, 0, 18, 0, 17, 17, 3, 21, 5, 0, 7, 17, 12, 11, 16, 20, 11, 21, 16, 22, 8,\n                10, 6, 14, 3, 14, 7, 2, 0, 9, 11, 15, 13, 14, 3, 17, 13, 20, 14, 10, 16, 9, 12, 14,\n                16, 2, 10, 15, 6, 16, 21, 15, 2, 15, 11, 19, 19, 13, 9, 4, 15, 7, 16, 19, 8, 1, 3,\n                20, 9, 21, 16, 3, 8, 7, 13, 20, 6, 2, 22, 20, 4, 4, 21, 8, 16, 7, 0, 7, 18, 22, 5,\n                6, 22, 5, 0, 5, 10, 11, 3, 1, 16, 1, 5, 17, 17, 6, 11, 9, 21, 1, 3, 3, 11, 12, 21,\n                18, 15, 8, 0, 16, 13, 2, 7, 5, 19, 9, 18, 14, 15, 0, 11, 22, 4, 8, 18, 20, 9, 1, 0,\n                15, 1, 5, 0, 0, 14, 8, 3, 17, 17, 14, 9, 16, 11, 13, 20, 22, 8, 3, 10, 1, 11, 21,\n                2, 17, 5, 5, 1, 9, 0, 13, 1, 10, 9, 4, 5, 3, 14, 21, 19, 12, 6, 6, 5, 13, 13, 6,\n                19, 3, 3, 4, 8, 13, 22, 3, 19, 4, 18, 18, 16, 18, 22, 10, 10, 1, 15, 17, 18, 8, 7,\n                11, 7, 10, 5, 21, 9, 0, 15, 8, 3, 16, 7, 21, 0, 19, 13, 6, 16, 11, 12, 13, 5, 13,\n                7, 14, 15, 3, 12, 4, 4, 22, 16, 11, 4, 0, 18, 4, 14, 18, 11, 4, 18, 7, 7, 9, 14, 8,\n                3, 11, 11, 0, 1, 3, 8, 5, 11, 7, 8, 3, 0, 14, 7, 1, 3, 20, 21, 5, 3, 2, 21, 12, 0,\n                21, 5, 21, 3, 18, 10, 9, 0, 3, 13, 1, 11, 13, 10, 7, 13, 18, 15, 14, 8, 14, 6, 0,\n                15, 6, 16, 17, 10, 2, 8, 0, 2, 22, 4, 20, 15, 15, 22, 8, 2, 2, 12, 20, 20, 20, 1,\n                0, 10, 2, 12, 14, 13, 13, 8, 22, 7, 2, 9, 15, 22, 19, 9, 17, 14, 10, 1, 21, 5, 22,\n                18, 6, 18, 1, 9, 9, 12, 7, 3, 4, 13, 13, 12, 10, 1, 3, 16, 5, 22, 21, 15, 10, 22,\n                19, 10, 3, 21, 17, 3, 7, 13, 18, 18, 14, 11, 15, 16, 8, 5, 20, 12, 8, 21, 10, 22,\n                17, 7, 18, 9, 10, 19, 6, 14, 2, 22, 17, 4, 9, 9, 13, 19, 0, 21, 1, 14, 3, 19, 10,\n                7, 3, 19, 1, 12, 19, 21, 20, 13, 4, 7, 7, 18, 1, 13, 15, 3, 10, 5, 6, 16, 5, 20,\n                20, 8, 11, 14, 6, 1, 11, 0, 9, 22, 8, 14, 22, 16, 5, 19, 7, 17, 18, 7, 17, 3, 18,\n                20, 18, 12, 19, 11, 4, 8, 19, 4, 6, 19, 17, 12, 1, 10, 8, 16, 12, 4, 1, 17, 21, 12,\n                7, 22, 21, 15, 11, 13, 21, 19, 21, 9, 14, 5, 18, 10, 8, 10, 20, 5, 6, 5, 11, 11, 1,\n                1, 1, 6, 0, 21, 14, 16, 15, 20, 13, 12, 2, 9, 8, 16, 7, 10, 17, 3, 1, 3, 21, 14, 1,\n                7, 10, 19, 9, 8, 3, 9, 16, 19, 12, 6, 19, 14, 1, 2, 20, 22, 10, 9, 8, 21, 13, 9, 8,\n                7, 1, 14, 9, 17, 12, 12, 4, 3, 4, 4, 22, 12, 6, 10, 4, 20, 21, 11, 3, 17, 1, 14, 0,\n                0, 13, 2, 3, 18, 10, 14, 16, 1, 16, 22, 7, 0, 5, 12, 9, 19, 14, 22, 2, 20, 14, 15,\n                16, 0, 7, 2, 20, 11, 6, 11, 8, 18, 0, 6, 20, 8, 3, 15, 20, 22, 14, 12, 12, 0, 20,\n                6, 18, 11, 0, 9, 16, 18, 8, 9, 12, 7, 10, 16, 0, 8, 4, 8, 14, 17, 16, 17, 2, 3, 13,\n                22, 22, 1, 2, 10, 4, 2, 10, 17, 20, 9, 13, 17, 1, 18, 17, 19, 14, 13, 13, 15, 11,\n                17, 22, 17, 2, 18, 16, 0, 15, 22, 2, 6, 2, 6, 0, 10, 14, 4, 20, 17, 9, 7, 12, 22,\n                17, 11, 9, 10, 0, 22, 18, 19, 21, 7, 10, 1, 17, 19, 8, 5, 11, 4, 3, 6, 13, 6, 17,\n                17, 19, 3, 12, 4, 1, 21, 10, 13, 6, 15, 0, 8, 8, 7, 8, 9, 5, 19, 1, 2, 11, 15, 18,\n                3, 0, 3, 15, 16, 13, 9, 2, 21, 21, 10, 13, 20, 7, 16, 16, 1, 3, 11, 4, 22, 10, 10,\n                22, 8, 16, 6, 17, 5, 1, 22, 16, 11, 5, 6, 22, 14, 21, 16, 4, 7, 10, 12, 12, 1, 20,\n                18, 13, 10, 19, 17, 7, 0, 7, 3, 22, 22, 7, 9, 19, 22, 12, 6, 13, 15, 19, 16, 12, 6,\n                7, 11, 10, 15, 4, 9, 9, 11, 20, 6, 21, 9, 13, 2, 2, 10, 22, 2, 10, 2, 2, 8, 22, 4,\n                3, 9, 0, 6, 10, 10, 15, 7, 12, 7, 12, 10, 1, 4, 7, 10, 8, 21, 16, 12, 12, 8, 12,\n                22, 20, 0, 8, 1, 20, 20, 3, 6, 4, 15, 20, 3, 11, 17, 19, 8, 7, 6, 21, 15, 22, 15,\n                5, 6, 2, 16, 11, 20, 7, 8, 6, 1, 9, 6, 12, 2, 4, 4, 11, 21, 0, 7, 15, 8, 0, 6, 13,\n                6, 17, 2, 18, 10, 21, 21, 10, 4, 10, 9, 12, 8, 12, 10, 15, 5, 6, 10, 17, 15, 16, 9,\n                8, 12, 14, 10, 13, 4, 2, 8, 11, 9, 19, 14, 11, 17, 6, 5, 21, 13, 19, 21, 2, 10, 10,\n                11, 12, 13, 2, 17, 18, 9, 11, 8, 18, 9, 4, 8, 11, 9, 14, 0, 13, 3, 3, 15, 21, 15,\n                8, 6, 0, 15, 8, 10, 2, 3, 2, 21, 16, 5, 14, 20, 19, 11, 12, 10, 16, 11, 6, 12, 6,\n                7, 3, 2, 12, 15, 2, 21, 7, 7, 7, 7, 3, 10, 22, 7, 13, 16, 7, 16, 7, 18, 6, 20, 2,\n                22, 14, 19, 13, 11, 0, 2, 21, 4, 3, 14, 1, 14, 4, 2, 13, 7, 0, 10, 13, 6, 8, 22,\n                10, 13, 21, 5, 13, 1, 4, 21, 12, 16, 12, 14, 13, 16, 20, 18, 20, 8, 22, 19, 3, 2,\n                15, 16, 19, 11, 16, 6, 17, 19, 22, 13, 11, 20, 9, 20, 21, 9, 8, 22, 22, 18, 17, 13,\n                8, 18, 21, 2, 9, 13, 13, 15, 6, 14, 17, 2, 18, 3, 0, 9, 12, 11, 19, 0, 12, 0, 3,\n                14, 14, 3, 8, 9, 12, 12, 10, 3, 16, 1, 12, 15, 1, 4, 3, 19, 20, 2, 14, 4, 17, 20,\n                20, 21, 1, 22, 19, 3, 6, 21, 0, 8, 21, 20, 7, 13, 20, 14, 2, 15, 6, 5, 4, 0, 6, 10,\n                16, 22, 11, 6, 2, 21, 5, 12, 7, 20, 21, 10, 3, 0, 8, 17, 20, 22, 2, 1, 1, 15, 18,\n                9, 5, 8, 17, 18, 7, 18, 16, 1, 9, 5, 8, 15, 12, 1, 9, 11, 17, 9, 1, 4, 6, 18, 0,\n                14, 3, 20, 16, 11, 2, 11, 8, 7, 22, 13, 2, 20, 21, 15, 7, 15, 4, 5, 0, 18, 18, 13,\n                16, 17, 15, 3, 17, 11, 4, 5, 16, 13, 20, 15, 11, 17, 10, 21, 3, 11, 3, 3, 7, 4, 7,\n                19, 8, 3, 17, 7, 21, 0, 10, 1, 3, 17, 10, 13, 16, 18, 11, 10, 22, 16, 21, 6, 12, 2,\n                7, 1, 20, 3, 11, 11, 1, 1, 4, 0, 8, 17, 14, 15, 18, 1, 19, 9, 17, 20, 1, 2, 20, 9,\n                16, 15, 14, 13, 7, 18, 5, 19, 22, 10, 15, 9, 21, 16, 19, 9, 12, 5, 21, 4, 21, 12,\n                20, 6, 13, 19, 3, 2, 18, 14, 9, 21, 4, 19, 3, 9, 21, 4, 13, 14, 14, 10, 6, 13, 6,\n                0, 14, 7, 15, 2, 18, 20, 22, 0, 12, 16, 7, 15, 2, 15, 9, 17, 9, 7, 11, 12, 8, 1,\n                15, 2, 19, 0, 22, 19, 22, 14, 7, 18, 13, 9, 2, 6, 2, 15, 1, 19, 4, 9, 20, 6, 14,\n                15, 17, 3, 5, 15, 21, 19, 7, 7, 6, 12, 13, 17, 10, 3, 21, 3, 10, 14, 6, 13, 21, 10,\n                7, 15, 20, 6, 21, 7, 15, 4, 12, 20, 0, 19, 21, 14, 3, 12, 22, 3, 20, 11, 21, 3, 6,\n                0, 1, 19, 4, 6, 22, 17, 3, 6, 20, 17, 7, 3, 0, 17, 5, 18, 19, 12, 15, 9, 16, 8, 20,\n                7, 14, 2, 15, 7, 4, 3, 4, 7, 2, 21, 1, 17, 16, 5, 6, 11, 12, 22, 4, 20, 14, 13, 3,\n                1, 6, 13, 10, 9, 1, 13, 5, 2, 20, 9, 16, 20, 19, 7, 12, 9, 4, 19, 6, 18, 19, 15,\n                11, 6, 14, 16, 19, 14, 20, 11, 11, 0, 8, 12, 0, 10, 12, 0, 21, 17, 17, 11, 3, 6,\n                13, 21, 6, 16, 6, 14, 9, 14, 5, 7, 19, 10, 12, 10, 9, 16, 21, 8, 0, 20, 19, 16, 14,\n                8, 8, 13, 19, 20, 18, 7, 10, 2, 12, 4, 3, 17, 3, 15, 12, 13, 16, 4, 14, 6, 20, 9,\n                15, 12, 13, 19, 12, 19, 4, 2, 2, 18, 19, 11, 11, 20, 4, 3, 15, 7, 0, 12, 5, 8, 0,\n                2, 16, 21, 6, 4, 5, 14, 6, 5, 22, 3, 8, 1, 10, 14, 1, 19, 9, 18, 21, 20, 5, 5, 3,\n                18, 9, 21, 15, 19, 8, 22, 20, 12, 8, 19, 22, 4, 9, 5, 13, 6, 17, 5, 10, 0, 7, 9,\n                19, 22, 16, 9, 16, 9, 2, 3, 10, 13, 11, 8, 3, 22, 21, 3, 1, 20, 16, 20, 19, 21, 16,\n                0, 6, 2, 14, 12, 6, 6, 0, 0, 1, 22, 19, 12, 11, 10, 1, 15, 8, 0, 3, 21, 6, 6, 21,\n                5, 14, 15, 1, 5, 11, 8, 9, 15, 3, 9, 12, 22, 15, 19, 6, 22, 21, 21, 11, 6, 10, 0,\n                9, 9, 4, 20, 4, 21, 18, 7, 6, 9, 3, 11, 8, 17, 17, 9, 22, 12, 21, 3, 1, 16, 22, 13,\n                6, 15, 18, 4, 22, 8, 10, 7, 11, 4, 0, 13, 13, 17, 11, 7, 5, 20, 18, 3, 0, 11, 21,\n                16, 15, 19, 20, 8, 5, 1, 14, 13, 8, 18, 18, 14, 4, 22, 15, 0, 20, 22, 13, 9, 4, 3,\n                6, 8, 14, 7, 4, 8, 15, 20, 8, 15, 13, 4, 22, 2, 0, 22, 22, 14, 5, 2, 5, 11, 1, 8,\n                22, 2, 3, 11, 9, 9, 6, 9, 14, 14, 20, 18, 18, 12, 1, 18, 12, 8, 19, 7, 6, 6, 11,\n                14, 3, 16, 7, 13, 11, 17, 3, 18, 9, 2, 19, 22, 11, 20, 0, 17, 4, 14, 10, 1, 19, 3,\n                21, 4, 12, 6, 13, 4, 21, 20, 4, 2, 10, 13, 11, 21, 15, 7, 17, 13, 4, 2, 3, 1, 17,\n                8, 19, 15, 1, 6, 11, 20, 5, 4, 17, 6, 20, 15, 19, 16, 16, 16, 1, 18, 9, 22, 10, 8,\n                12, 2, 18, 14, 9, 12, 18, 9, 8, 13, 19, 16, 3, 15, 8, 2, 14, 18, 2, 12, 4, 1, 5, 3,\n                13, 6, 21, 5, 19, 20, 15, 4, 9, 18, 9, 14, 15, 19, 1, 19, 7, 11, 15, 9, 11, 22, 0,\n                6, 17, 17, 6, 1, 9, 0, 6, 5, 22, 11, 18, 13, 4, 9, 17, 3, 20, 13, 14, 6, 1, 7, 14,\n                16, 13, 22, 1, 15, 7, 2, 17, 22, 1, 22, 21, 0, 18, 9, 21, 22, 1, 22, 16, 7, 22, 4,\n                18, 2, 9, 2, 4, 16, 12, 9, 22, 18, 18, 20, 21, 8, 21, 1, 1, 7, 22, 20, 16, 5, 21,\n                14, 4, 15, 11, 19, 0, 17, 12, 12, 3, 22, 4, 22, 3, 11, 0, 7, 13, 1, 21, 0, 6, 16,\n                5, 18, 5, 5, 14, 15, 4, 0, 9, 9, 17, 3, 17, 0, 2, 14, 12, 6, 1, 17, 6, 21, 3, 15,\n                4, 2, 5, 22, 7, 6, 21, 6, 16, 3, 3, 5, 6, 9, 8, 19, 5, 9, 16, 3, 18, 19, 20, 18,\n                10, 5, 15, 17, 20, 16, 5, 1, 13, 20, 8, 18, 14, 12, 20, 18, 18, 4, 1, 0, 2, 8, 16,\n                18, 17, 15, 21, 14, 5, 13, 17, 14, 4, 10, 16, 0, 0, 22, 2, 9, 10, 13, 20, 1, 12,\n                11, 10, 22, 15, 16, 19, 10, 8, 1, 21, 13, 11, 3, 21, 7, 11, 3, 14, 8, 0, 4, 2, 6,\n                22, 22, 2, 5, 9, 19, 0, 13, 6, 1, 15, 21, 11, 11, 14, 7, 14, 4, 21, 11, 22, 4, 14,\n                6, 13, 5, 10, 19, 8, 21, 22, 2, 12, 16, 6, 2, 1, 12, 7, 6, 20, 9, 22, 7, 12, 19, 6,\n                10, 8, 10, 19, 16, 17, 9, 5, 8, 16, 14, 16, 11, 4, 2, 17, 6, 9, 5, 5, 12, 15, 15,\n                18, 12, 10, 8, 1, 7, 8, 11, 2, 21, 20, 20, 22, 10, 10, 3, 9, 5, 5, 12, 12, 11, 4,\n                7, 6, 1, 22, 7, 18, 20, 15, 12, 13, 10, 12, 17, 12, 12, 21, 0, 12, 19, 2, 8, 4, 17,\n                5, 20, 8, 7, 16, 22, 7, 18, 17, 5, 13, 21, 7, 3, 22, 20, 15, 1, 13, 3, 6, 6, 18, 8,\n                0, 16, 10, 2, 3, 8, 12, 0, 14, 1, 7, 17, 4, 17, 0, 14, 5, 22, 11, 10, 16, 19, 12,\n                11, 18, 13, 22, 19, 17, 19, 0, 6, 18, 13, 11, 17, 21, 9, 21, 10, 0, 17, 14, 10, 5,\n                13, 5, 14, 7, 6, 0, 14, 20, 16, 11, 9, 4, 3, 19, 3, 19, 16, 13, 21, 22, 21, 2, 12,\n                13, 6, 7, 19, 18, 20, 6, 2, 9, 6, 2, 14, 6, 18, 0, 0, 14, 9, 22, 3, 22, 3, 19, 5,\n                10, 2, 13, 2, 5, 15, 9, 11, 19, 10, 6, 14, 11, 9, 0, 20, 22, 17, 16, 4, 14, 7, 2,\n                20, 10, 21, 8, 19, 5, 9, 16, 4, 17, 7, 17, 3, 0, 12, 0, 7, 9, 11, 4, 9, 19, 20, 19,\n                17, 10, 19, 4, 20, 0, 9, 3, 7, 1, 19, 9, 13, 7, 15, 9, 17, 13, 21, 19, 15, 2, 11,\n                6, 4, 16, 9, 22, 22, 19, 9, 10, 21, 5, 13, 9, 4, 20, 18, 7, 1, 1, 19, 10, 3, 9, 8,\n                21, 0, 18, 7, 7, 7, 1, 8, 1, 1, 11, 16, 19, 18, 17, 10, 21, 18, 5, 5, 0, 4, 0, 0,\n                7, 9, 7, 5, 11, 18, 16, 20, 14, 19, 10, 20, 5, 20, 13, 20, 7, 15, 2, 4, 21, 14, 1,\n                15, 19, 17, 4, 21, 4, 14, 20, 14, 20, 20, 1, 6, 12, 11, 6, 7, 3, 0, 19, 2, 2, 17,\n                14, 6, 6, 16, 12, 1, 11, 6, 22, 21, 19, 22, 19, 19, 12, 22, 10, 21, 11, 19, 18, 6,\n                2, 17, 11, 11, 18, 9, 13, 0, 13, 12, 13, 6, 19, 20, 11, 11, 4, 20, 15, 22, 3, 16,\n                7, 0, 17, 0, 0, 12, 19, 1, 1, 8, 10, 4, 8, 18, 20, 17, 12, 9, 13, 21, 3, 12, 4, 21,\n                0, 1, 1, 15, 8, 22, 14, 20, 0, 6, 8, 22, 20, 3, 11, 14, 5, 11, 7, 20, 2, 1, 5, 7,\n                9, 10, 1, 19, 19, 19, 12, 12, 20, 11, 7, 14, 0, 22, 13, 9, 3, 13, 12, 9, 10, 18, 0,\n                19, 13, 6, 4, 14, 5, 15, 17, 1, 2, 18, 13, 18, 1, 22, 17, 15, 3, 2, 16, 4, 4, 21,\n                10, 6, 12, 17, 3, 11, 9, 18, 15, 9, 9, 19, 13, 19, 7, 6, 5, 19, 8, 11, 9, 12, 10,\n                14, 9, 7, 16, 12, 6, 17, 20, 16, 21, 5, 17, 16, 9, 14, 3, 9, 6, 12, 11, 18, 22, 14,\n                4, 22, 17, 4, 9, 7, 6, 2, 18, 20, 21, 10, 9, 0, 12, 11, 3, 0, 5, 8, 15, 13, 8, 17,\n                13, 20, 14, 17, 4, 8, 2, 3, 15, 15, 20, 12, 10, 11, 14, 21, 4, 22, 4, 11, 5, 20,\n                11, 10, 4, 19, 18, 8, 4, 17, 4, 12, 5, 20, 12, 22, 6, 11, 3, 4, 20, 9, 10, 20, 21,\n                9, 20, 21, 0, 9, 11, 6, 13, 16, 2, 8, 14, 7, 16, 11, 1, 14, 4, 8, 14, 14, 20, 1,\n                17, 9, 8, 15, 4, 19, 19, 1, 16, 7, 20, 18, 18, 21, 0, 1, 8, 21, 12, 9, 14, 10, 0,\n                3, 5, 5, 2, 16, 17, 14, 15, 4, 19, 4, 21, 15, 1, 21, 6, 22, 8, 6, 10, 2, 19, 20,\n                19, 13, 8, 21, 21, 9, 11, 13, 11, 10, 16, 6, 14, 20, 4, 15, 11, 22, 8, 10, 2, 14,\n                12, 4, 15, 10, 10, 8, 5, 5, 5, 17, 22, 6, 7, 17, 21, 14, 6, 10, 0, 0, 13, 15, 12,\n                11, 15, 10, 18, 5, 18, 19, 0, 11, 10, 6, 13, 0, 21, 22, 1, 6, 22, 20, 1, 21, 4, 19,\n                12, 20, 8, 7, 10, 6, 13, 21, 7, 8, 1, 1, 5, 1, 19, 15, 15, 3, 19, 11, 11, 10, 14,\n                22, 2, 3, 9, 18, 10, 22, 22, 21, 14, 4, 12, 21, 20, 12, 1, 5, 10, 14, 4, 5, 0, 1,\n                2, 13, 13, 8, 8, 16, 14, 18, 17, 9, 4, 2, 17, 6, 15, 16, 14, 15, 12, 19, 7, 15, 14,\n                7, 0, 12, 14, 5, 12, 14, 13, 21, 3, 7, 9, 13, 21, 11, 17, 1, 22, 17, 4, 10, 22, 1,\n                19, 10, 3, 20, 3, 12, 0, 21, 19, 18, 1, 4, 1, 5, 4, 17, 20, 10, 11, 18, 9, 9, 20,\n                0, 13, 4, 13, 22, 11, 9, 18, 19, 18, 10, 1, 2, 8, 11, 19, 5, 2, 19, 5, 10, 14, 18,\n                11, 18, 6, 19, 10, 16, 3, 12, 13, 13, 2, 19, 21, 15, 2, 15, 21, 11, 20, 15, 14, 5,\n                7, 7, 10, 8, 3, 9, 4, 0, 21, 17, 21, 0, 11, 11, 14, 16, 10, 14, 21, 4, 17, 8, 3,\n                10, 10, 8, 16, 13, 0, 21, 14, 8, 3, 11, 11, 3, 15, 10, 1, 1, 18, 15, 6, 2, 1, 10,\n                20, 12, 5, 4, 0, 14, 13, 3, 20, 8, 9, 16, 16, 12, 7, 2, 4, 14, 7, 16, 10, 4, 11, 4,\n                5, 9, 19, 22, 8, 15, 13, 4, 8, 10, 9, 15, 20, 16, 0, 17, 13, 1, 12, 18, 22, 10, 8,\n                14, 9, 16, 1, 6, 12, 19, 22, 3, 2, 17, 17, 13, 7, 8, 18, 15, 8, 21, 3, 14, 1, 10,\n                13, 1, 13, 3, 6, 20, 7, 21, 13, 0, 8, 13, 5, 19, 19, 11, 5, 17, 3, 13, 12, 22, 10,\n                5, 6, 10, 1, 20, 13, 11, 17, 14, 13, 7, 14, 19, 22, 12, 12, 15, 3, 11, 12, 15, 7,\n                22, 17, 4, 14, 9, 4, 18, 17, 11, 7, 5, 19, 16, 8, 4, 2, 11, 19, 3, 15, 22, 0, 3,\n                20, 0, 7, 3, 2, 6, 16, 22, 15, 19, 18, 14, 2, 17, 15, 3, 13, 10, 20, 12, 8, 21, 11,\n                5, 20, 22, 22, 11, 9, 20, 14, 12, 20, 8, 6, 9, 12, 6, 16, 16, 20, 22, 0, 20, 8, 2,\n                12, 22, 19, 16, 15, 6, 11, 7, 1, 8, 14, 21, 14, 22, 18, 1, 22, 8, 8, 14, 22, 3, 5,\n                22, 6, 9, 7, 13, 7, 12, 10, 6, 6, 22, 8, 5, 20, 12, 0, 13, 7, 2, 17, 0, 6, 20, 3,\n                18, 13, 21, 11, 21, 12, 19, 7, 21, 13, 21, 21, 6, 22, 7, 9, 20, 13, 12, 20, 2, 1,\n                12, 16, 5, 8, 5, 5, 5, 16, 13, 3, 2, 12, 5, 7, 8, 12, 4, 10, 17, 5, 17, 3, 18, 22,\n                3, 6, 3, 10, 18, 18, 3, 3, 2, 4, 18, 3, 18, 17, 2, 11, 3, 14, 4, 16, 2, 12, 4, 7,\n                18, 21, 22, 5, 18, 9, 7, 10, 17, 16, 7, 17, 7, 2, 5, 11, 12, 4, 22, 7, 21, 0, 8,\n                16, 0, 16, 1, 9, 11, 13, 11, 6, 19, 13, 0, 10, 15, 1, 3, 8, 21, 7, 6, 21, 11, 15,\n                13, 1, 10, 20, 17, 22, 7, 16, 8, 9, 9, 22, 6, 18, 12, 21, 17, 14, 10, 10, 20, 18,\n                10, 10, 7, 2, 7, 11, 21, 1, 1, 16, 3, 22, 2, 1, 6, 12, 16, 13, 1, 15, 18, 4, 2, 16,\n                15, 5, 5, 2, 4, 13, 9, 10, 1, 4, 3, 16, 9, 4, 17, 11, 10, 9, 1, 9, 1, 18, 0, 6, 6,\n                17, 14, 17, 20, 19, 7, 21, 4, 9, 17, 5, 0, 22, 19, 10, 20, 5, 13, 12, 19, 13, 21,\n                14, 14, 2, 15, 19, 2, 8, 20, 9, 11, 6, 14, 4, 12, 21, 9, 7, 10, 12, 3, 14, 1, 2, 6,\n                18, 14, 20, 11, 19, 13, 3, 21, 10, 22, 12, 4, 19, 12, 2, 12, 6, 4, 5, 2, 15, 2, 17,\n                11, 21, 3, 8, 14, 7, 3, 7, 4, 16, 9, 2, 13, 2, 13, 14, 9, 3, 6, 11, 13, 22, 8, 20,\n                11, 2, 6, 13, 22, 15, 1, 14, 7, 16, 18, 15, 2, 21, 21, 5, 19, 5, 12, 5, 14, 7, 2,\n                1, 12, 22, 8, 16, 13, 12, 15, 10, 6, 21, 8, 9, 6, 14, 11, 11, 8, 3, 1, 21, 9, 3,\n                17, 21, 6, 8, 8, 15, 20, 9, 19, 18, 16, 22, 20, 18, 4, 19, 18, 7, 20, 17, 16, 5,\n                17, 8, 22, 13, 9, 6, 13, 2, 22, 15, 1, 1, 14, 2, 11, 18, 19, 8, 10, 7, 5, 16, 5,\n                13, 19, 17, 2, 15, 14, 8, 14, 20, 6, 16, 9, 13, 16, 16, 19, 9, 2, 12, 15, 17, 19,\n                21, 4, 6, 13, 15, 18, 22, 17, 12, 20, 15, 5, 7, 18, 20, 12, 19, 14, 19, 1, 8, 20,\n                5, 18, 4, 11, 5, 10, 11, 11, 2, 20, 20, 2, 5, 4, 0, 15, 6, 7, 10, 14, 14, 0, 13,\n                20, 5, 17, 17, 0, 2, 0, 18, 0, 10, 17, 17, 2, 19, 5, 2, 21, 1, 8, 17, 16, 0, 6, 4,\n                22, 8, 0, 16, 16, 2, 20, 8, 12, 15, 17, 21, 12, 8, 21, 10, 2, 21, 13, 11, 18, 5,\n                19, 9, 2, 10, 11, 6, 4, 10, 20, 20, 9, 7, 11, 13, 20, 3, 3, 8, 7, 7, 10, 14, 10,\n                14, 10, 16, 3, 14, 0, 3, 19, 18, 21, 3, 21, 10, 17, 22, 12, 18, 21, 4, 14, 16, 2,\n                14, 15, 2, 8, 14, 17, 14, 6, 3, 0, 17, 2, 15, 4, 4, 20, 14, 14, 1, 19, 0, 12, 14,\n                6, 5, 16, 10, 8, 20, 5, 1, 10, 8, 2, 3, 22, 16, 0, 7, 0, 15, 5, 12, 9, 11, 5, 19,\n                12, 12, 14, 4, 22, 6, 9, 3, 18, 12, 9, 10, 10, 19, 19, 21, 14, 10, 5, 4, 9, 3, 22,\n                17, 10, 17, 19, 8, 6, 14, 14, 5, 5, 0, 9, 3, 11, 2, 17, 15, 7, 4, 19, 8, 21, 8, 7,\n                11, 2, 16, 3, 2, 19, 13, 19, 17, 7, 21, 4, 4, 11, 15, 3, 1, 19, 19, 22, 10, 2, 5,\n                8, 15, 17, 6, 5, 15, 15, 9, 7, 2, 0, 14, 11, 14, 1, 3, 13, 14, 4, 3, 11, 6, 14, 0,\n                0, 1, 2, 19, 8, 6, 14, 10, 9, 19, 22, 11, 12, 1, 15, 11, 10, 7, 15, 13, 8, 3, 12,\n                8, 1, 13, 13, 22, 17, 0, 15, 0, 1, 4, 13, 17, 8, 10, 20, 17, 17, 18, 3, 4, 13, 7,\n                16, 7, 17, 22, 0, 0, 13, 13, 21, 6, 4, 0, 19, 12, 9, 20, 1, 21, 20, 2, 14, 20, 19,\n                0, 18, 5, 14, 1, 12, 0, 9, 21, 8, 4, 11, 3, 22, 20, 15, 22, 5, 22, 20, 11, 21, 18,\n                8, 13, 12, 6, 10, 22, 12, 13, 7, 6, 13, 1, 13, 2, 19, 1, 13, 1, 0, 21, 5, 6, 17,\n                22, 14, 20, 3, 12, 8, 19, 6, 21, 19, 3, 2, 8, 3, 6, 2, 13, 19, 20, 8, 15, 19, 10,\n                5, 22, 16, 13, 0, 4, 4, 4, 2, 15, 13, 5, 10, 3, 21, 3, 3, 4, 1, 4, 22, 10, 2, 2, 2,\n                8, 18, 8, 13, 19, 13, 9, 7, 16, 5, 8, 6, 3, 10, 10, 5, 19, 7, 4, 5, 5, 1, 9, 4, 6,\n                12, 8, 8, 2, 3, 7, 10, 10, 22, 2, 9, 14, 14, 0, 3, 2, 12, 18, 6, 8, 8, 8, 5, 20,\n                12, 15, 3, 8, 12, 13, 21, 18, 17, 12, 18, 13, 13, 8, 10, 2, 3, 7, 15, 4, 13, 15,\n                22, 0, 6, 12, 10, 12, 3, 20, 22, 11, 15, 0, 12, 3, 16, 11, 5, 0, 6, 19, 20, 8, 15,\n                21, 10, 10, 9, 16, 3, 20, 3, 13, 2, 16, 16, 11, 20, 12, 6, 8, 0, 1, 15, 12, 9, 12,\n                18, 20, 14, 13, 17, 8, 12, 1, 10, 16, 1, 0, 7, 5, 0, 8, 17, 19, 20, 5, 15, 4, 9,\n                16, 21, 16, 2, 22, 12, 11, 2, 9, 2, 5, 7, 14, 10, 8, 14, 9, 4, 3, 12, 9, 7, 1, 4,\n                10, 22, 12, 11, 4, 5, 14, 11, 11, 22, 21, 15, 12, 17, 0, 12, 8, 6, 6, 7, 16, 3, 2,\n                4, 21, 18, 10, 15, 17, 10, 22, 9, 21, 14, 12, 15, 6, 13, 10, 5, 6, 16, 17, 1, 13,\n                12, 3, 4, 9, 3, 4, 20, 9, 4, 15, 16, 15, 22, 6, 1, 20, 12, 5, 12, 17, 17, 14, 21,\n                12, 2, 0, 11, 17, 9, 16, 4, 9, 7, 9, 10, 22, 4, 9, 21, 1, 1, 15, 16, 12, 15, 21, 1,\n                10, 19, 22, 14, 4, 17, 5, 2, 1, 13, 21, 22, 12, 5, 13, 8, 22, 15, 22, 5, 5, 11, 12,\n                9, 16, 7, 4, 0, 15, 14, 18, 15, 5, 7, 13, 10, 13, 2, 5, 19, 8, 3, 16, 6, 13, 1, 1,\n                16, 20, 22, 3, 18, 6, 9, 15, 8, 21, 2, 16, 5, 19, 11, 13, 4, 18, 4, 12, 13, 17, 4,\n                10, 7, 8, 7, 2, 22, 9, 20, 16, 10, 10, 18, 22, 22, 5, 15, 8, 10, 15, 14, 5, 12, 20,\n                21, 5, 13, 9, 10, 0, 16, 17, 20, 0, 6, 8, 11, 2, 9, 17, 22, 11, 14, 10, 10, 17, 3,\n                7, 8, 20, 1, 11, 17, 18, 1, 14, 1, 16, 14, 12, 19, 14, 15, 13, 22, 9, 18, 17, 16,\n                5, 15, 22, 7, 19, 14, 21, 12, 22, 15, 16, 9, 7, 11, 18, 6, 17, 22, 21, 15, 11, 12,\n                10, 17, 1, 1, 17, 4, 15, 3, 4, 5, 13, 9, 16, 14, 4, 19, 21, 20, 20, 2, 15, 19, 11,\n                13, 9, 1, 17, 16, 7, 5, 8, 13, 14, 5, 17, 13, 21, 19, 14, 14, 20, 7, 21, 18, 22,\n                18, 2, 9, 4, 5, 7, 10, 2, 14, 18, 12, 10, 4, 5, 15, 0, 0, 4, 6, 14, 0, 2, 0, 21,\n                19, 22, 22, 3, 15, 6, 11, 22, 15, 21, 14, 13, 0, 7, 8, 4, 20, 12, 12, 11, 15, 12,\n                15, 0, 5, 13, 6, 0, 22, 11, 10, 1, 1, 13, 11, 19, 2, 0, 12, 8, 8, 20, 9, 14, 10,\n                12, 20, 8, 20, 9, 10, 6, 21, 2, 17, 17, 11, 1, 14, 13, 5, 11, 4, 2, 13, 2, 21, 18,\n                9, 13, 14, 13, 2, 3, 19, 8, 17, 15, 8, 17, 12, 17, 8, 15, 4, 20, 22, 7, 7, 21, 5,\n                6, 14, 17, 0, 15, 16, 22, 11, 17, 17, 20, 21, 13, 0, 13, 14, 2, 5, 14, 16, 3, 14,\n                11, 15, 4, 9, 0, 6, 5, 5, 18, 7, 22, 4, 21, 17, 3, 1, 17, 18, 12, 12, 18, 14, 18,\n                0, 0, 8, 14, 1, 14, 0, 6, 21, 8, 8, 18, 6, 1, 17, 0, 0, 16, 0, 13, 12, 7, 18, 2, 6,\n                16, 13, 11, 0, 5, 1, 6, 8, 21, 22, 3, 6, 8, 21, 12, 19, 16, 11, 3, 17, 13, 15, 8,\n                1, 11, 22, 2, 8, 22, 7, 14, 14, 20, 18, 18, 20, 22, 17, 3, 20, 4, 14, 13, 17, 2, 5,\n                20, 19, 17, 16, 18, 17, 20, 6, 19, 2, 2, 9, 0, 10, 1, 11, 18, 0, 7, 19, 16, 8, 0,\n                1, 21, 14, 21, 3, 18, 0, 1, 2, 4, 0, 9, 17, 12, 1, 9, 17, 21, 7, 17, 20, 9, 10, 7,\n                6, 10, 10, 15, 14, 2, 9, 20, 20, 8, 15, 2, 6, 3, 0, 7, 11, 21, 21, 8, 6, 4, 7, 9,\n                5, 3, 15, 4, 1, 1, 10, 21, 13, 22, 5, 22, 2, 5, 11, 6, 22, 10, 11, 3, 12, 3, 20, 7,\n                22, 5, 11, 20, 0, 5, 15, 20, 10, 7, 11, 0, 21, 7, 21, 8, 0, 16, 16, 22, 12, 16, 13,\n                10, 5, 22, 13, 15, 12, 9, 12, 13, 2, 7, 0, 5, 16, 18, 0, 1, 0, 6, 7, 0, 1, 7, 22,\n                4, 4, 13, 9, 3, 11, 11, 10, 5, 20, 17, 16, 18, 15, 6, 20, 15, 1, 8, 4, 2, 3, 21,\n                19, 3, 14, 6, 16, 5, 17, 10, 20, 15, 5, 5, 20, 21, 3, 6, 14, 9, 22, 18, 11, 14, 2,\n                21, 5, 9, 16, 16, 21, 3, 4, 19, 11, 14, 19, 18, 21, 4, 0, 18, 8, 16, 21, 7, 19, 4,\n                2, 14, 10, 17, 18, 18, 11, 17, 2, 14, 22, 20, 2, 22, 6, 4, 12, 6, 6, 16, 5, 16, 3,\n                15, 12, 22, 7, 15, 19, 14, 9, 2, 10, 19, 5, 3, 0, 20, 3, 12, 6, 14, 2, 20, 20, 18,\n                22, 3, 11, 20, 10, 1, 7, 17, 18, 17, 7, 0, 20, 8, 22, 1, 21, 7, 22, 4, 18, 7, 16,\n                13, 10, 7, 13, 0, 1, 11, 7, 20, 14, 0, 5, 10, 2, 9, 17, 5, 1, 13, 14, 5, 18, 17, 9,\n                16, 12, 0, 18, 7, 16, 17, 14, 10, 9, 19, 20, 0, 15, 10, 20, 15, 22, 8, 13, 19, 4,\n                19, 6, 14, 1, 21, 3, 4, 7, 16, 5, 12, 9, 2, 4, 17, 22, 16, 18, 3, 19, 19, 21, 14,\n                22, 13, 19, 2, 18, 0, 4, 9, 12, 12, 3, 19, 5, 18, 9, 14, 9, 4, 21, 12, 18, 13, 17,\n                1, 5, 20, 5, 14, 7, 19, 16, 22, 12, 6, 2, 21, 10, 5, 12, 12, 19, 11, 0, 5, 0, 4, 4,\n                8, 22, 20, 18, 20, 17, 8, 14, 0, 3, 12, 9, 21, 17, 14, 15, 10, 13, 20, 15, 21, 10,\n                7, 2, 7, 13, 11, 1, 22, 9, 19, 14, 4, 0, 18, 9, 22, 10, 6, 11, 10, 21, 8, 1, 10,\n                13, 21, 0, 11, 6, 8, 14, 22, 6, 13, 11, 11, 18, 4, 3, 8, 10, 20, 16, 15, 16, 10,\n                14, 18, 7, 4, 16, 1, 6, 17, 4, 22, 19, 2, 9, 16, 0, 18, 15, 2, 9, 15, 5, 20, 20, 0,\n                22, 10, 2, 21, 22, 14, 11, 10, 19, 18, 10, 11, 14, 12, 5, 7, 16, 15, 5, 22, 12, 16,\n                13, 6, 11, 21, 18, 21, 15, 19, 7, 9, 2, 13, 2, 14, 6, 9, 2, 19, 2, 2, 0, 5, 19, 13,\n                12, 10, 11, 9, 6, 21, 17, 1, 16, 15, 9, 4, 5, 12, 11, 0, 21, 21, 12, 20, 11, 20, 7,\n                10, 4, 21, 20, 0, 17, 8, 14, 3, 17, 1, 7, 17, 16, 16, 3, 19, 18, 7, 13, 17, 2, 8,\n                2, 17, 4, 5, 7, 22, 2, 5, 8, 5, 8, 21, 15, 14, 17, 11, 16, 20, 8, 1, 5, 10, 8, 5,\n                7, 14, 5, 16, 6, 17, 8, 14, 4, 21, 5, 22, 6, 18, 22, 4, 16, 0, 0, 8, 22, 3, 9, 13,\n                21, 13, 5, 9, 5, 13, 17, 11, 19, 17, 15, 6, 5, 11, 12, 4, 2, 7, 13, 16, 3, 8, 0, 5,\n                20, 12, 11, 1, 15, 16, 0, 9, 7, 9, 16, 15, 21, 19, 19, 8, 3, 12, 14, 21, 18, 22, 5,\n                13, 12, 20, 11, 13, 11, 7, 16, 12, 7, 13, 15, 14, 22, 10, 17, 0, 11, 6, 20, 3, 2,\n                14, 13, 22, 21, 18, 20, 7, 18, 9, 5, 14, 22, 1, 9, 19, 3, 12, 20, 1, 15, 18, 6, 7,\n                16, 2, 20, 17, 2, 4, 11, 15, 19, 4, 14, 16, 19, 9, 2, 17, 1, 17, 5, 5, 10, 5, 20,\n                4, 22, 2, 8, 1, 12, 21, 22, 2, 4, 22, 5, 15, 18, 5, 4, 4, 22, 15, 20, 22, 19, 19,\n                8, 17, 16, 15, 1, 11, 12, 5, 0, 17, 14, 0, 10, 0, 12, 18, 16, 14, 4, 21, 16, 2, 11,\n                3, 6, 10, 12, 14, 1, 21, 10, 16, 3, 19, 11, 14, 19, 8, 4, 20, 9, 14, 6, 5, 16, 19,\n                21, 9, 7, 16, 19, 14, 19, 7, 17, 9, 11, 8, 2, 3, 21, 19, 14, 14, 0, 10, 8, 20, 13,\n                11, 18, 4, 1, 4, 9, 13, 21, 18, 12, 19, 11, 20, 16, 11, 6, 13, 15, 3, 22, 2, 5, 16,\n                11, 18, 3, 16, 6, 17, 9, 20, 9, 0, 14, 15, 13, 18, 22, 2, 14, 11, 4, 12, 18, 6, 16,\n                5, 4, 12, 5, 4, 22, 19, 4, 22, 2, 2, 16, 4, 16, 13, 4, 5, 15, 1, 3, 3, 14, 19, 20,\n                20, 3, 1, 7, 18, 6, 8, 6, 19, 4, 19, 4, 6, 2, 14, 13, 11, 2, 22, 19, 19, 13, 22,\n                12, 18, 19, 16, 11, 13, 6, 9, 0, 1, 9, 10, 22, 18, 0, 2, 22, 9, 8, 4, 20, 21, 9,\n                11, 9, 19, 21, 18, 17, 9, 0, 1, 2, 10, 6, 4, 16, 14, 8, 3, 1, 7, 3, 18, 16, 9, 14,\n                10, 4, 1, 14, 6, 7, 10, 18, 13, 13, 17, 16, 14, 14, 11, 9, 13, 6, 10, 0, 8, 14, 19,\n                6, 12, 10, 2, 9, 1, 22, 7, 11, 6, 5, 18, 9, 20, 8, 12, 10, 21, 12, 4, 22, 1, 19,\n                22, 7, 11, 18, 3, 16, 3, 19, 10, 14, 8, 10, 18, 6, 22, 5, 4, 21, 15, 13, 22, 19,\n                21, 6, 11, 9, 1, 11, 4, 1, 5, 0, 0, 16, 3, 11, 1, 10, 18, 2, 14, 12, 13, 17, 11, 3,\n                15, 10, 22, 13, 5, 19, 2, 2, 6, 17, 3, 11, 19, 17, 5, 4, 14, 18, 14, 0, 6, 17, 2,\n                13, 4, 1, 10, 17, 4, 19, 4, 3, 13, 19, 6, 19, 2, 17, 20, 10, 6, 15, 17, 4, 14, 19,\n                14, 6, 9, 16, 2, 13, 3, 9, 7, 8, 12, 16, 15, 12, 15, 1, 22, 16, 3, 21, 17, 18, 2,\n                6, 14, 16, 15, 20, 13, 19, 19, 4, 8, 10, 17, 8, 6, 19, 8, 8, 9, 22, 21, 13, 16, 16,\n                9, 20, 10, 12, 21, 4, 11, 6, 11, 18, 7, 6, 21, 21, 2, 20, 17, 12, 1, 2, 5, 2, 5, 9,\n                19, 9, 15, 4, 10, 10, 4, 22, 0, 9, 15, 0, 2, 14, 20, 21, 3, 0, 8, 13, 12, 21, 15,\n                21, 20, 9, 21, 0, 18, 0, 22, 15, 11, 11, 16, 21, 14, 19, 14, 22, 8, 1, 19, 2, 18,\n                4, 4, 9, 20, 11, 7, 20, 10, 4, 20, 20, 6, 20, 16, 22, 3, 4, 3, 18, 5, 7, 20, 3, 3,\n                4, 3, 6, 4, 15, 6, 1, 3, 9, 22, 13, 0, 5, 6, 15, 13, 3, 3, 21, 7, 3, 16, 0, 9, 1,\n                11, 22, 18, 12, 22, 6, 22, 6, 8, 14, 5, 14, 17, 19, 17, 21, 12, 8, 2, 11, 11, 17,\n                2, 11, 3, 21, 1, 7, 6, 11, 8, 17, 12, 0, 4, 10, 9, 9, 16, 13, 9, 22, 20, 1, 17, 6,\n                22, 17, 12, 2, 16, 11, 1, 6, 21, 14, 4, 16, 4, 0, 21, 4, 8, 20, 19, 15, 9, 2, 15,\n                2, 16, 7, 8, 11, 12, 19, 7, 19, 8, 11, 1, 11, 0, 13, 16, 12, 12, 3, 8, 7, 15, 5,\n                18, 4, 15, 18, 7, 12, 2, 2, 7, 7, 21, 1, 13, 19, 11, 5, 1, 15, 3, 9, 7, 2, 21, 7,\n                19, 3, 15, 1, 8, 18, 6, 16, 16, 0, 18, 3, 2, 11, 12, 7, 10, 21, 18, 18, 11, 12, 6,\n                20, 7, 1, 5, 18, 14, 8, 14, 21, 6, 15, 10, 14, 16, 5, 8, 6, 12, 22, 16, 11, 13, 1,\n                2, 19, 16, 7, 22, 14, 22, 10, 11, 16, 4, 14, 22, 16, 2, 12, 2, 8, 3, 1, 2, 13, 2,\n                17, 10, 15, 11, 15, 10, 10, 7, 4, 5, 15, 10, 18, 4, 13, 8, 6, 6, 20, 7, 0, 15, 20,\n                8, 18, 21, 5, 7, 16, 1, 16, 15, 5, 12, 20, 19, 22, 12, 14, 1, 11, 12, 5, 4, 20, 3,\n                12, 18, 21, 22, 10, 10, 16, 9, 5, 14, 22, 13, 21, 22, 2, 7, 8, 6, 3, 18, 18, 10,\n                15, 14, 15, 8, 5, 21, 3, 20, 0, 4, 6, 4, 2, 7, 17, 14, 1, 4, 13, 8, 4, 22, 19, 13,\n                20, 16, 21, 0, 2, 3, 2, 12, 19, 22, 15, 16, 19, 11, 9, 17, 8, 17, 6, 20, 4, 2, 7,\n                14, 7, 4, 5, 9, 17, 5, 1, 3, 14, 11, 16, 1, 7, 19, 12, 14, 0, 22, 13, 0, 17, 8, 13,\n                19, 11, 11, 0, 22, 19, 2, 0, 5, 9, 12, 14, 17, 22, 7, 4, 4, 15, 13, 20, 16, 16, 6,\n                3, 16, 4, 6, 11, 13, 9, 20, 6, 17, 10, 17, 22, 6, 9, 16, 0, 12, 11, 18, 10, 11, 0,\n                0, 15, 21, 7, 14, 22, 6, 6, 4, 13, 11, 6, 22, 8, 12, 19, 22, 10, 16, 14, 11, 5, 3,\n                9, 1, 8, 20, 14, 18, 4, 22, 7, 6, 13, 20, 12, 4, 1, 8, 4, 1, 16, 4, 22, 8, 20, 4,\n                11, 20, 16, 9, 12, 21, 1, 2, 3, 22, 6, 10, 16, 17, 6, 0, 7, 21, 0, 19, 14, 13, 11,\n                0, 6, 21, 12, 21, 4, 7, 22, 18, 6, 20, 5, 22, 20, 14, 13, 9, 14, 4, 2, 19, 6, 10,\n                14, 19, 22, 22, 18, 16, 1, 5, 16, 9, 18, 14, 4, 7, 5, 6, 4, 2, 3, 7, 4, 2, 11, 21,\n                14, 3, 1, 12, 14, 11, 1, 18, 13, 4, 7, 20, 8, 8, 13, 3, 14, 18, 9, 10, 1, 2, 1, 9,\n                6, 3, 5, 19, 0, 17, 18, 22, 8, 6, 10, 12, 11, 18, 16, 6, 20, 7, 7, 22, 8, 7, 16,\n                17, 14, 12, 12, 18, 13, 21, 2, 16, 2, 0, 16, 3, 21, 0, 21, 14, 3, 4, 13, 1, 8, 12,\n                20, 1, 1, 8, 3, 6, 18, 21, 3, 19, 18, 8, 3, 2, 21, 5, 9, 1, 18, 11, 19, 4, 12, 3,\n                5, 6, 3, 1, 20, 21, 18, 14, 12, 6, 14, 12, 18, 6, 22, 3, 5, 4, 22, 9, 9, 0, 7, 19,\n                1, 5, 8, 3, 20, 3, 14, 3, 19, 10, 10, 13, 17, 2, 14, 15, 7, 14, 1, 1, 20, 3, 22, 2,\n                22, 15, 5, 6, 13, 15, 22, 19, 2, 21, 1, 14, 19, 5, 18, 7, 14, 15, 17, 14, 11, 3,\n                13, 3, 10, 13, 7, 3, 11, 20, 0, 3, 8, 20, 5, 20, 14, 15, 1, 21, 11, 1, 9, 10, 14,\n                19, 13, 20, 5, 15, 7, 17, 5, 21, 0, 14, 13, 16, 15, 11, 13, 18, 1, 6, 13, 5, 7, 15,\n                16, 1, 0, 4, 10, 0, 9, 9, 5, 13, 6, 22, 1, 2, 17, 13, 17, 16, 9, 15, 1, 16, 10, 8,\n                3, 18, 19, 18, 4, 19, 7, 1, 12, 9, 16, 15, 9, 2, 0, 20, 6, 6, 14, 22, 4, 2, 17, 15,\n                13, 22, 17, 11, 5, 2, 13, 14, 22, 0, 6, 16, 15, 17, 22, 2, 9, 16, 12, 19, 15, 12,\n                1, 9, 0, 14, 13, 10, 16, 14, 10, 22, 1, 11, 15, 10, 9, 19, 13, 15, 13, 22, 11, 15,\n                11, 9, 3, 6, 18, 20, 13, 20, 1, 15, 22, 18, 18, 7, 18, 16, 22, 12, 4, 18, 9, 11, 6,\n                1, 14, 19, 19, 0, 22, 5, 18, 3, 5, 10, 13, 15, 2, 4, 6, 2, 14, 11, 21, 5, 0, 11,\n                14, 0, 19, 14, 1, 20, 4, 12, 1, 9, 5, 12, 15, 12, 3, 1, 2, 14, 22, 18, 20, 5, 1, 6,\n                0, 5, 14, 12, 3, 0, 10, 22, 6, 4, 4, 22, 20, 9, 8, 14, 0, 2, 6, 14, 13, 0, 15, 18,\n                10, 17, 8, 20, 21, 17, 3, 6, 2, 13, 4, 0, 15, 4, 22, 19, 20, 4, 3, 3, 4, 8, 5, 3,\n                10, 6, 8, 7, 9, 18, 4, 12, 9, 9, 3, 15, 21, 2, 6, 4, 7, 12, 1, 15, 0, 18, 6, 5, 10,\n                11, 12, 15, 15, 2, 12, 4, 11, 15, 3, 19, 22, 19, 22, 9, 10, 15, 17, 8, 17, 0, 15,\n                15, 18, 12, 0, 1, 4, 10, 6, 21, 16, 5, 0, 20, 21, 21, 4, 22, 7, 10, 17, 13, 10, 7,\n                7, 21, 13, 5, 3, 20, 5, 14, 5, 9, 9, 6, 3, 21, 6, 7, 15, 10, 1, 4, 15, 7, 16, 3,\n                13, 14, 4, 21, 6, 14, 11, 18, 5, 8, 13, 20, 10, 10, 13, 17, 7, 0, 9, 21, 1, 3, 4,\n                16, 16, 20, 5, 3, 5, 14, 22, 1, 20, 21, 11, 16, 13, 10, 21, 8, 8, 16, 12, 12, 8,\n                12, 9, 6, 20, 15, 15, 12, 1, 15, 7, 11, 22, 4, 2, 7, 2, 3, 0, 8, 7, 10, 16, 16, 22,\n                10, 21, 3, 13, 0, 10, 7, 17, 21, 0, 22, 4, 15, 6, 10, 14, 0, 7, 0, 22, 16, 11, 2,\n                19, 15, 5, 2, 11, 13, 3, 14, 9, 19, 19, 21, 8, 19, 1, 21, 7, 17, 12, 18, 17, 7, 5,\n                13, 6, 13, 5, 21, 14, 8, 4, 13, 21, 14, 0, 4, 15, 4, 7, 0, 11, 11, 0, 17, 1, 4, 4,\n                18, 21, 19, 15, 21, 11, 2, 6, 18, 10, 10, 21, 11, 19, 13, 7, 2, 3, 12, 7, 16, 16,\n                16, 16, 17, 22, 20, 20, 10, 13, 16, 19, 6, 1, 18, 19, 12, 3, 11, 7, 17, 16, 7, 17,\n                1, 15, 18, 16, 11, 19, 1, 16, 3, 16, 9, 11, 18, 1, 20, 1, 20, 8, 13, 11, 3, 15, 13,\n                15, 21, 13, 22, 22, 2, 6, 7, 21, 12, 6, 8, 18, 21, 11, 1, 0, 15, 21, 11, 15, 19,\n                20, 4, 0, 7, 4, 18, 5, 4, 17, 11, 1, 17, 4, 12, 11, 22, 5, 5, 21, 14, 17, 7, 12, 7,\n                17, 18, 17, 8, 3, 20, 3, 5, 1, 5, 3, 19, 6, 18, 20, 13, 17, 19, 3, 19, 17, 3, 20,\n                10, 20, 3, 8, 16, 7, 8, 3, 22, 18, 12, 21, 10, 19, 12, 12, 16, 12, 0, 5, 12, 8, 19,\n                20, 2, 5, 21, 18, 19, 1, 1, 20, 22, 20, 8, 11, 15, 17, 13, 20, 9, 16, 21, 4, 12, 2,\n                1, 5, 4, 4, 17, 19, 0, 19, 9, 14, 12, 21, 16, 16, 8, 6, 10, 12, 0, 13, 12, 22, 11,\n                1, 17, 6, 12, 19, 3, 13, 8, 13, 16, 6, 2, 6, 18, 9, 18, 17, 11, 20, 15, 2, 15, 22,\n                17, 17, 11, 22, 1, 8, 12, 13, 10, 3, 5, 12, 21, 14, 10, 17, 19, 17, 15, 11, 20, 20,\n                21, 19, 14, 6, 8, 17, 1, 18, 13, 22, 11, 3, 1, 21, 6, 10, 22, 7, 5, 0, 3, 12, 14,\n                8, 3, 4, 9, 9, 21, 11, 10, 9, 11, 9, 4, 19, 7, 10, 22, 13, 2, 2, 22, 19, 9, 16, 21,\n                1, 9, 13, 16, 11, 22, 17, 11, 12, 22, 0, 13, 6, 8, 1, 0, 0, 4, 18, 3, 1, 12, 5, 5,\n                3, 9, 6, 6, 17, 9, 4, 19, 14, 0, 9, 1, 19, 8, 0, 14, 18, 18, 9, 16, 15, 10, 10, 11,\n                12, 17, 19, 11, 15, 0, 10, 22, 5, 21, 21, 2, 20, 15, 5, 1, 7, 7, 6, 15, 12, 6, 13,\n                20, 4, 21, 10, 15, 1, 13, 13, 9, 21, 18, 0, 5, 9, 20, 21, 7, 22, 2, 4, 10, 10, 0,\n                11, 4, 3, 15, 12, 20, 9, 9, 11, 15, 15, 21, 18, 1, 4, 11, 10, 0, 6, 18, 6, 11, 20,\n                3, 11, 11, 13, 16, 9, 1, 1, 10, 6, 20, 14, 2, 7, 4, 18, 9, 12, 16, 22, 20, 9, 19,\n                2, 8, 3, 4, 15, 18, 3, 14, 7, 15, 1, 15, 8, 19, 5, 8, 2, 22, 19, 13, 18, 0, 19, 12,\n                17, 21, 22, 19, 6, 12, 2, 2, 20, 18, 21, 18, 18, 7, 19, 16, 11, 1, 21, 10, 5, 12,\n                15, 18, 17, 10, 0, 20, 20, 19, 6, 6, 15, 8, 5, 21, 11, 0, 6, 10, 13, 8, 20, 7, 2,\n                11, 11, 3, 14, 11, 9, 8, 15, 0, 3, 22, 0, 12, 6, 0, 12, 21, 11, 8, 7, 5, 0, 6, 4,\n                15, 18, 9, 21, 5, 4, 20, 14, 5, 9, 19, 3, 11, 12, 22, 7, 18, 21, 9, 17, 3, 2, 11,\n                15, 6, 19, 2, 3, 8, 10, 7, 6, 8, 13, 2, 2, 9, 20, 3, 7, 5, 13, 13, 9, 0, 18, 21, 1,\n                22, 6, 7, 18, 5, 14, 14, 19, 0, 6, 4, 3, 19, 20, 22, 20, 7, 22, 22, 2, 11, 16, 16,\n                20, 17, 13, 20, 1, 21, 17, 22, 3, 4, 6, 7, 9, 11, 21, 17, 13, 21, 8, 18, 22, 4, 19,\n                8, 7, 11, 13, 1, 10, 14, 18, 17, 14, 15, 22, 3, 14, 20, 15, 3, 22, 15, 22, 12, 12,\n                18, 14, 16, 14, 21, 17, 1, 16, 12, 8, 2, 3, 6, 4, 9, 7, 5, 3, 15, 21, 14, 0, 20, 9,\n                7, 19, 10, 4, 5, 11, 8, 19, 0, 22, 7, 3, 22, 8, 12, 5, 22, 4, 15, 11, 2, 4, 13, 2,\n                4, 9, 7, 5, 17, 14, 19, 7, 14, 4, 8, 17, 18,\n            ],\n            23,\n            &[\n                2432543987, 2276527024, 3303037865, 3040931222, 124530589, 2075117878, 373679459,\n                1719887982, 927313221, 2350422398, 2410320624, 2621140451, 898468917, 1050104246,\n                3314171259, 2202176491, 3934792658, 1945547354, 752254890, 68461992, 1501238000,\n                1916284043, 2385775512, 1516051704, 1572036976, 177218342, 4078653370, 3944978370,\n                3993325163, 35949890, 28445911, 2989181316, 3711931852, 3969713797, 853651131,\n                1048673303, 164841509, 2591275506, 2676954415, 910103144, 2881135462, 1328960554,\n                3814928621, 1570089463, 3936037561, 3706141104, 3622208665, 1736839730, 818356637,\n                903565935, 3997690004, 2013074628, 245593157, 2604723513, 2614342663, 1992293635,\n                1023889602, 2910391935, 1146365901, 3356081083, 3777393537, 2858374037, 2863919743,\n                1056257782, 809068644, 672989257, 3747695201, 2522210474, 525888082, 1848521587,\n                2468974825, 653259135, 1975306186, 2456732937, 1299155795, 1794805560, 569248853,\n                102439111, 256768309, 4037408132, 77496396, 1983342746, 2296048037, 3348374173,\n                1213807447, 1373478223, 2235179986, 1490259265, 2112796854, 2547714374, 869600236,\n                2852487281, 2064710386, 447426889, 767950649, 3612583010, 1780520436, 3627700369,\n                3905832623, 412784141, 2186300632, 1687791207, 3268878142, 2439345575, 544593515,\n                2488911021, 1860939518, 3160552347, 3520538477, 2254621553, 3817356405, 1093773391,\n                104168916, 2026826706, 3008411949, 731612881, 400526524, 1319326349, 994927338,\n                1642377367, 89069495, 4052976262, 407108435, 1706274710, 3618323759, 2999112327,\n                3472562229, 594407960, 4257849311, 1499146458, 3343189692, 3332254596, 3845543202,\n                3993385369, 1501681435, 608654406, 2482649339, 3990535200, 1449270641, 4016403422,\n                342445879, 4228145020, 4030280967, 891466632, 1454359846, 1886612732, 3712575231,\n                3934358913, 1100305416, 1249102960, 2133206589, 3528060174, 1115362965, 871488833,\n                2959657656, 1791653312, 1587540254, 1527651781, 2515721439, 2549398069, 1442586984,\n                3746591659, 1219966156, 1140399539, 3198235519, 2830212264, 3671456437, 2604181784,\n                2742431758, 3688451693, 1352937420, 2958171794, 3484353914, 1323974235, 635848732,\n                3435591916, 1147399220, 3055499602, 3459025755, 1441809200, 3288677176, 1356946570,\n                2922613843, 3435973582, 3169578850, 2010271922, 2926310610, 4220927069, 3147037801,\n                3177585452, 3767093688, 3797368144, 2993412434, 52467448, 2638704998, 500593776,\n                435767039, 75611890, 173252622, 369536399, 3001199800, 1696483020, 403435509,\n                2676770836, 135469730, 4294502870, 3467161889, 487127268, 144987877, 3830430272,\n                4176107046, 547748139, 2535372546, 3407597209, 4273742947, 3591467776, 869590956,\n                1405915818, 3698534773, 260295134, 4044017583, 4035779488, 463440960, 4200854080,\n                657217412, 3110364826, 2029115239, 2200955452, 779832230, 1588101134, 1711375700,\n                3878103627, 1709250626, 2858094475, 509701948, 717581521, 3068900665, 1481026334,\n                1218138746, 4054497212, 3753193645, 2200558797, 2971038189, 3966112697, 558197857,\n                2787894924, 744571221, 1568885442, 2788507093, 1552043446, 172898599, 1046802271,\n                845471067, 3408324900, 3882264867, 1306206395, 1165216268, 1191839803, 1527610198,\n                4188064533, 3649876341, 2133981933, 1122433329, 166725368, 2113942545, 262674194,\n                2983616752, 3664915710, 2528883697, 72691628, 1094952676, 3781397836, 2543857595,\n                1262396255, 1541616154, 695881242, 4267754168, 2929769840, 1150669979, 2444044368,\n                2085087061, 1011358281, 414070849, 1990902057, 2504781194, 762251676, 2992215331,\n                321648205, 749759701, 2683064829, 371937346, 1916620629, 3504232544, 2210693036,\n                1759776303, 1252482988, 2327728963, 855162264, 1839954590, 1657033791, 790197996,\n                232471839, 2461249283, 117939746, 560149963, 1044762152, 1013702332, 932681941,\n                1205754842, 1751214724, 860371808, 3898533721, 39404571, 1091417891, 593738330,\n                3258375503, 4277934029, 688697039, 4083389785, 1292128636, 1251798962, 235181476,\n                3030160145, 2367582304, 2609657981, 3483636249, 2810692598, 1851185576, 2778801808,\n                1690833980, 4279865527, 2021420402, 1898436492, 2626314401, 3873432257, 1672600024,\n                2803701169, 66336423, 1619175812, 1947174922, 427990001, 2831016152, 3944679881,\n                1055966210, 1089542534, 2005082069, 1971269850, 1924433077, 4217952611, 2749232796,\n                1481402693, 3203808543, 3753215487, 1988955035, 4002936550, 1944840595, 2089249464,\n                226215659, 1145745745, 2617193917, 2071905246, 2716825521, 756996862, 803384898,\n                2498333605, 3766458014, 2625315151, 1231183373, 3407435990, 2004334218, 136726326,\n                3694458272, 439206563, 1697431856, 109034171, 3129361133, 2148702911, 1603279218,\n                665749557, 2453579770, 1778010870, 3980259964, 3820850075, 423551518, 4244040519,\n                771818147, 2473197470, 2184490663, 66706499, 373610607, 2507344693, 1182035514,\n                2294279416, 348192110, 2147447089, 1429312800, 3521861641, 2941695755, 2373618812,\n                3122839309, 3164597812, 4174895272, 3446714428, 4179964099, 3369606920, 3245057821,\n                512812868, 3801957629, 3866197478, 1983232922, 1164421658, 3492043893, 4102973269,\n                3482785988, 3613848786, 994234819, 3925964490, 2520653440, 306189184, 3378720004,\n                325986226, 663667879, 2399249015, 716637187, 2390212162, 3760061962, 582012888,\n                3300637312, 3552019520, 2310968716, 1848698860, 2484373755, 729280744, 833802096,\n                3737502652, 3910738649, 2057433799, 2248378565, 268720583, 3069947043, 3763100719,\n                3510420884, 1101435572, 462921272, 3929831289, 348032532, 3764507470, 3983733230,\n                2585114124, 2116017165, 3240263985, 1205053072, 1665443971, 2423786772, 1138900192,\n                2363229724, 1887946492, 3218510326, 3268927353, 1385744919, 2498515502, 1516552001,\n                3939009406, 3701533621, 913382028, 3344976363, 3384856500, 3870149157, 1329228053,\n                1291707300, 3899335066, 3940597462, 3153019193, 2408594961, 2671044621, 3551857958,\n                2209058090, 3493940212, 222503531, 2114494914, 565799347, 1971473416, 4277831935,\n                2358519001, 490963986, 3852565277, 984935336, 1133370208, 1617043634, 2857541004,\n                832503739, 108040238, 3880146835, 2807229258, 3575769310, 2774854680, 868093555,\n                2575005082, 2956555327, 3737955779, 4249638030, 1940414434, 3753480496, 49729337,\n                1193299683, 3201089034, 420648789, 3352785498, 288688721, 1521187011, 1386674633,\n                1364869610, 885037528, 1252279155, 3649552262, 2152649024, 3204905942, 1783619473,\n                2861412105, 3540375905, 3746939744, 156102264, 3466170698, 11866214, 1012760070,\n                1958489233, 3665112630, 3509540297, 2512443114, 2128112533, 1628693203, 2042312955,\n                1656593755, 2564164318, 3270705760, 1680356097, 5025885, 2796521567, 2263503167,\n                2420040603, 3394606541, 214460118, 992057652, 3266983797, 2159688810, 1993456089,\n                4175543350, 3963528935, 2513264991, 3658064350, 156097811, 2826997767, 865018090,\n                1321677484, 2168436280, 1124406880, 3231042910, 1275491774, 9015246, 3130741698,\n                2078413139, 1824585545, 1955698270, 1768370940, 613758713, 3783594115, 2662841648,\n                3623245683, 3253698278, 4191335005, 3430738147, 3732087559, 237862677, 3240225475,\n                2509625707, 3371804946, 561137032, 2487087488, 566174513, 55477126, 1492417125,\n                3600485779, 3489229753, 1660001711, 903932105, 2666760808, 3267530948, 1804351992,\n                2931928329, 1701287766, 847625244, 2066564451, 2319056965, 2848820614, 854672647,\n                535121151, 2288435608, 2524958641, 3296694570, 1364335301, 709714126, 2360287547,\n                4106461964, 329631027, 849263407, 2311850705, 1653642573, 2959033037, 3845765450,\n                2411305922, 1012439121, 974968898, 3631461599, 777873009, 920353902, 725744567,\n                1725097098, 333882177, 3584334013, 3078291222, 3960551469, 2531623496, 1211920485,\n                2390442828, 2791068256, 1910957250, 1632728636, 3797597081, 3611429309, 1566721977,\n                2509740862, 4176296323, 590851749, 3457912421, 2303299273, 2528501850, 889922996,\n                536952148, 2891183341, 3609423256, 2878185261, 3218672709, 956031557, 1687988839,\n                920703413, 4209253359, 1815357979, 3709650040, 1017145721, 1810276897, 1020365743,\n                2313969064, 1539434460, 4255594610, 1458431491, 680535340, 1647259761, 1004107429,\n                2415667132, 31092371, 935775706, 396967039, 27911921, 2657305445, 2248738175,\n                2497727679, 1483667419, 1951176417, 2145607203, 3224667691, 2438573057, 2942868990,\n                2027000102, 2913871289, 3685393236, 2425696100, 782260165, 483022313, 3940181670,\n                3798075211, 1219099101, 203528657, 529875562, 276233372, 264759552, 51482773,\n                4105461152, 708360569, 559014934, 735004662, 2304945262, 2287817402, 1399360640,\n                4034225857, 1458299505, 1242064138, 3475741745, 2971620406, 2364951756, 1272349036,\n                2302805830, 298664638, 3662585622, 2397537734, 3026808232, 1114868390, 673264043,\n                3318150460, 1138305753, 3797784655, 2881309047, 174048567, 3800745317, 3055674757,\n                2607943906, 944193168, 2003534871, 1434769036, 458792317, 2282245931, 636767187,\n                1532218286, 724269210, 2874117375, 1439654243, 698007041, 2836800209, 1025277967,\n                1527769433, 2515862986, 1373613061, 287099492, 2691879042, 2428315581, 2367162320,\n                1217630768, 952926109, 3408276082, 3496973185, 3089422616, 1048409122, 707017659,\n                2780132225, 2844071654, 1836018831, 3441433162, 624841709, 3116228289, 1956737587,\n                3778477996, 336613926, 2937889239, 384836527, 1341826476, 3712358886, 2306774444,\n                1341535315, 1777669116, 1199737655, 266426998, 2697021776, 2817808455, 2023340729,\n                3851312363, 3980251913, 3207784360, 333886678, 689050764, 331336434, 3431528012,\n                654836012, 3282279155, 249795473, 4101667665, 994019464, 1551695192, 919619198,\n                2822963861, 1058136685, 347412103, 8043636, 548175678, 160303852, 4191967974,\n                114867036, 2223903475, 3083148884, 2624932033, 2791621092, 2277501601, 2800576686,\n                1130603172, 566089914, 1444023227, 1500498349, 150928386, 2908319814, 2257652416,\n                1193412204, 3157603623, 4288978904, 2684571944, 2504105716, 3900496848, 344319926,\n                2148470734, 3941199614, 801816176, 2970106595, 2551130561, 1139061079, 1765357801,\n                2801395705, 1452414774, 1670219825, 2423177094, 321332024, 2032854264, 2554376386,\n                537964156, 1300131358, 2011623640, 4208848750, 2877603209, 896201049, 954025445,\n                1801424491, 3220899647, 3629652945, 1882282457, 1857761982, 2758423637, 787777871,\n                225484364, 713108959, 2092789353, 2948984687, 269006096, 76419691, 569618318,\n                1650706474, 4007329961, 270502651, 708871540, 4193563743, 2210670738, 2545734314,\n                2838989169, 2119352897, 3507676809, 192990507, 447022484, 1538552337, 3536011095,\n                1971356807, 1997639220, 4240677277, 2042803185, 747190487, 690822786, 3425774253,\n                1970444075, 1519418519, 2502800132, 456092197, 3089519109, 2494760604, 1753613710,\n                3680543205, 1225101795, 2697514748, 2933361013, 4175549155, 2216849000, 3929431645,\n                4230737093, 2641643251, 4199674746, 1962717842, 3676951090, 2505693179, 850730013,\n                3866789620, 152159307, 2179605002, 687124397, 2450265390, 445267719, 1990658425,\n                2317584166, 1464123246, 2333847393, 3958580546, 589512689, 1683476060, 528323569,\n                4040487824, 1531042664, 2122382129, 3943959015, 3860235235, 1153301333, 566968208,\n                2417583538, 1103445908, 1261825307, 2550203026, 1658486984, 3038335860, 1841338780,\n                3360364021, 2660553389, 2924187195, 4241529036, 2271736721, 3765073952, 2580215584,\n                1438318228, 2787276148, 454821732, 355379320, 2482867526, 1411322874, 4211251252,\n                1898863052, 471267359, 3485276742, 1285961552, 3923197508, 3768783839, 4025502468,\n                18284057, 2673735163, 2221768523, 681186346, 88325179, 2889050541, 1256119319,\n                1858502698, 2398900641, 976659823, 2961773032, 3868539432, 2535077451, 1763974232,\n                2135036948, 1399244834, 1152496492, 2401894286, 1267776170, 2133978424, 3666460581,\n                2519353074, 2831901651, 3888910459, 1900327248, 1654981227, 1101450299, 3445846720,\n                3449825460, 3791261482, 432004847, 3066863554, 2698800432, 1641108, 707956864,\n                1870786679, 3055496006, 3728988665, 398291770, 2212074450, 2155438841, 3431922058,\n                3971811313, 1719261068, 1735009605, 4213793259, 58186599, 3855304568, 3067682717,\n                228831702, 3278881736, 4153465006, 1952694150, 3651972132, 3534641986, 1121445172,\n                169071915, 4212735773, 3505561766, 1395317315, 736925405, 3125143948, 3297296490,\n                3127331986, 3616368376, 2056503535, 788835758, 788439625, 1630085743, 2747839891,\n                2343131865, 1081156327, 3120208131, 394640347, 3903778496, 4252716449, 2283235409,\n                483957986, 83131712, 518164125, 3367314863, 3912497177, 1979817847, 2541067002,\n                3406633266, 2525836540, 2905407837, 927633307, 357014464, 1712382708, 2975844776,\n                3790058589, 1514112964, 366170767, 328664775, 4185303074, 1820638444, 2924908138,\n                2047784738, 1987583135, 2372860973, 3609968385, 3143257714, 3427362641, 3072122247,\n                1141840336, 2310485042, 368865492, 4065735384, 3981077989, 2624946734, 3489009884,\n                2263206997, 2463456412, 2712152858, 1734251492, 2655931795, 3696764806, 3404614825,\n                4011135114, 1018397103, 572166022, 2062711851, 2569156569, 3460399925, 1702645790,\n                1098604909, 2069896475, 3646476155, 820160451, 147337310, 1765191975, 60191201,\n                626121624, 2726686045, 2538949724, 187866767, 2388425781, 935215588, 871611286,\n                3906412946, 1246311689, 3306250646, 4170514946, 2323420983, 2057780630, 628784453,\n                1410213509, 372936645, 501063446, 175500703, 258466122, 62857995, 3386238628,\n                2083632783, 2605300978, 1118667897, 1446000958, 79053812, 3654798093, 1881412132,\n                4168572524, 1027075259, 1028158997, 1654169038, 2157952826, 2032022698, 1151156532,\n                1065611895, 3911407574, 2900828134, 1637425467, 2817709633, 1736551320, 3741593941,\n                3202948790, 1599337068, 3398371980, 2224875086, 1229925548, 1303814094, 3574632434,\n                3493928291, 884975947, 1246641330, 2088204280, 2837698631, 1824887371, 1450894602,\n                266444701, 3075497931, 3834303497, 3027392031, 2531258637, 2642373781, 1193002026,\n                1767288754, 1311625744, 1001761926, 3062663859, 52529591, 3745995278, 438887272,\n                700662189, 4212368956, 2107562915, 319883829, 215035253, 1488253283, 1301013358,\n                433922795, 1753607220, 794705122, 1689562210, 3154133389, 2179734736, 2971286634,\n                2392964366, 2792619323, 1432651454, 3418370805, 3131519322, 3349726128, 2474689584,\n                466365332, 811867264, 3052861325, 4097469989, 93032001, 3926176274, 2350247983,\n                1674779175, 291602062, 2846268401, 3277208194, 1497830566, 3625189672, 9072038,\n                2951339513, 1792718546, 1776258935, 1029608682, 1412608523, 3989131994, 3101063512,\n                1207282153, 2951261525, 3563115848, 1682346995, 4283726597, 3927997318, 4070406195,\n                3269446148, 2053006428, 3883337744, 2238918050, 3463951652, 3364024419, 2879606446,\n                2715677768, 3398302025, 1565164133, 3468031718, 3995385067, 2354095405, 70728059,\n                1501387287, 531457926, 4071000954, 2691373653, 130456474, 162613531, 3278227001,\n                1871081118, 2108414937, 1956838987, 3201051305, 1099789655, 2688103265, 3376545054,\n                4194764973, 3048141369, 92313010, 2714344608, 2836237280, 2306143043, 157665707,\n                4202292074, 1667642970, 2709322690, 33398946, 1993933511, 876610905, 4199861858,\n                4070029492, 4112921551, 4157395415, 1744841967, 375479353, 782950108, 3732824359,\n                3468562129, 1534389810, 3406467972, 231940487, 27701910, 379953968, 1660493409,\n                409076658, 839620823, 2991390226, 3717064548, 2195983177, 1378317571, 2131651037,\n                264521891, 107725272, 2543867771, 1340163093, 1806455525, 1349163961, 2698063614,\n                1300591146, 2489572412, 1792603038, 8170771, 1532472015, 4089778540, 1087892505,\n                4011589612, 2513998273, 2753333194, 2374394, 3072400605, 2057302330, 206942689,\n                930325233, 1494197348, 2396885015, 3519563996, 1389464877, 212652146, 3546128890,\n                1601747989, 676352508, 2556438908, 3274662607, 595702540, 3961163985, 214798108,\n                158276567, 2000671252, 1909961436, 3608100180, 1725922971, 1921296001, 3248181224,\n                2681071530, 4234758481, 3214059028, 1675447675, 2089523164, 470493498, 340308561,\n                4095769841, 3045163996, 1700180965, 1833518916, 3218401197, 3764107983, 760622304,\n                2715854634, 2566771885, 2855925414, 2596118107, 2718892126, 2919661660, 1777435166,\n                704222621, 4188226574, 1287796296, 32153441, 2088095808, 2504036947, 481481625,\n                1981638127, 2659395414, 4019699467, 3022239223, 1432279555, 3716343314, 2101658277,\n                2538588325, 2228739909, 325848107, 3728753696, 226572131, 70936434, 2326533081,\n                4197100817, 2130486321, 3647628851, 2365959588, 146012,\n            ],\n        );\n        // - out_len_hi == 0 in limbs_from_digits_small_base_divide_and_conquer\n        // - out_len_lo == 0 in limbs_from_digits_small_base_divide_and_conquer\n        test(&[10; 739], &[0; 7100], 10, &[0; 369]);\n    }\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    {\n        test(\n            &[\n                424216987022722268,\n                8103283177193628673,\n                4470414499436387861,\n                13801449255692046935,\n                9547961461378503966,\n                5606458381418993750,\n                17091516772434375724,\n                11977748006393229058,\n                6812658461074707191,\n                12015828441561040006,\n            ],\n            &[\n                51, 153, 87, 70, 104, 138, 111, 23, 85, 119, 176, 8, 65, 118, 3, 156, 55, 121, 87,\n                162,\n            ],\n            182,\n            &[4980635571795936200, 9374876857207216767, 1331096],\n        );\n        test(\n            &[\n                5518555633093191759,\n                12836059490899113620,\n                12661099089298342811,\n                1992484047621263128,\n                3777109748949388481,\n                4126346840817077875,\n                7608898082196224717,\n                6664909716221346590,\n                679023819841892642,\n            ],\n            &[41, 16, 48, 34, 6, 51, 35, 56, 47, 44, 44, 20, 51, 39, 36, 33, 4, 14, 25, 3],\n            61,\n            &[16759895520031570107, 18665423842034105],\n        );\n        // - xs_len <= len_lo in limbs_from_digits_small_base_divide_and_conquer\n        // - xs_len >= SET_STR_DC_THRESHOLD in limbs_from_digits_small_base_divide_and_conquer\n        test(\n            &[10; 10],\n            &[\n                2, 3, 0, 1, 0, 1, 0, 2, 0, 0, 1, 2, 3, 2, 0, 0, 3, 0, 3, 1, 3, 2, 4, 4, 2, 1, 0, 1,\n                1, 3, 1, 2, 2, 4, 1, 4, 1, 0, 2, 3, 1, 1, 4, 4, 0, 3, 3, 3, 0, 0, 0, 3, 1, 0, 1, 1,\n                3, 1, 1, 0, 3, 3, 2, 4, 4, 4, 3, 4, 2, 0, 1, 1, 3, 4, 4, 3, 0, 4, 3, 0, 2, 2, 3, 4,\n                3, 0, 4, 2, 2, 0, 3, 4, 0, 1, 0, 4, 3, 1, 1, 2, 1, 2, 0, 1, 3, 0, 2, 2, 1, 1, 2, 2,\n                2, 0, 4, 3, 3, 3, 1, 2, 2, 2, 2, 0, 1, 0, 2, 4, 4, 4, 1, 3, 2, 2, 0, 1, 3, 1, 1, 4,\n                1, 3, 4, 2, 3, 0, 1, 2, 2, 0, 0, 4, 1, 1, 1, 3, 1, 3, 0, 2, 0, 2, 0, 2, 1, 1, 2, 4,\n                0, 3, 2, 3, 0, 4, 3, 1, 2, 4, 4, 1, 3, 3, 3, 4, 2, 0, 3, 0, 3, 4, 3, 1, 4, 3, 3, 2,\n                2, 1, 1, 1, 0, 3, 2, 0, 4, 1, 1, 1, 0, 3, 0, 3, 4, 4, 4, 4, 4, 0, 4, 2, 1, 4, 4,\n            ],\n            5,\n            &[\n                277482782106898878,\n                8398439881293320527,\n                6237275848328729287,\n                17623578066584208310,\n                2887235280090375858,\n                8886426738771697150,\n                6137418971026265383,\n                15927966713276205188,\n                28,\n            ],\n        );\n    }\n}\n\nfn limbs_from_digits_small_base_properties_helper<T: PrimitiveUnsigned>()\nwhere\n    Limb: WrappingFrom<T>,\n    Natural: From<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_stripe_n\", 4 << Limb::LOG_WIDTH);\n    config.insert(\"mean_digit_count_n\", 2048);\n    config.insert(\"mean_excess_limb_count_n\", 32);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_3::<T, Limb>().test_properties_with_config(\n        &config,\n        |(mut out, xs, base)| {\n            let t_base = T::exact_from(base);\n            assert_eq!(\n                limbs_from_digits_small_base(&mut out, &xs, base).is_some(),\n                xs.iter().all(|&x| x < t_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_2::<T, Limb>().test_properties_with_config(\n        &config,\n        |(mut out, xs, base)| {\n            let old_out = out.clone();\n            let out_len = limbs_from_digits_small_base(&mut out, &xs, base).unwrap();\n            verify_limbs_from_digits_small_base(&old_out, &xs, base, out_len, &out, false);\n        },\n    );\n}\n\n#[test]\nfn limbs_from_digits_small_base_properties() {\n    apply_fn_to_unsigneds!(limbs_from_digits_small_base_properties_helper);\n}\n\n#[test]\nfn test_from_digits_desc_basecase() {\n    fn test_ok(xs: &[u8], base: Limb, n: &str) {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(from_digits_desc_basecase(xs, base).unwrap(), n);\n        assert_eq!(\n            from_digits_desc_naive_primitive(xs, u8::exact_from(base)).unwrap(),\n            n\n        );\n    }\n    test_ok(&[0], 9, \"0\");\n    test_ok(&[1], 9, \"1\");\n    test_ok(&[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, \"123456\");\n    test_ok(&[0, 0, 2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, \"123456\");\n    test_ok(\n        &[\n            73, 23, 120, 45, 108, 147, 113, 90, 129, 11, 86, 0, 102, 81, 22, 17, 32, 121, 29, 82,\n            27, 25, 39, 9, 139, 59, 51, 13, 44, 3, 37, 104, 41, 40, 87, 66, 83, 146, 40, 132, 15,\n            50, 66, 80, 73, 61, 75, 25, 78, 34, 128, 86, 68, 26, 62, 135, 21, 9, 27, 74, 12, 39,\n            67, 15, 41, 50, 144, 35, 98, 140, 124, 132, 10, 37, 101, 99, 14,\n        ],\n        150,\n        \"176685760608531978263731938997517835399219565848609872558191310084297042793489341607854254\\\n        709347189745346071475819587247558105442098729883999424898641968281841439662364\",\n    );\n\n    fn test_err(xs: &[u8], base: Limb) {\n        assert!(from_digits_desc_basecase(xs, base).is_none());\n        assert!(from_digits_desc_naive_primitive(xs, u8::exact_from(base)).is_none());\n    }\n    test_err(&[10, 11, 12], 10);\n}\n\nfn from_digits_desc_basecase_fail_helper<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>()\nwhere\n    Limb: WrappingFrom<T>,\n{\n    assert_panic!(from_digits_desc_basecase::<T>(&[], 0));\n    assert_panic!(from_digits_desc_basecase::<T>(&[], 1));\n}\n\n#[test]\nfn from_digits_desc_basecase_fail() {\n    apply_fn_to_unsigneds!(from_digits_desc_basecase_fail_helper);\n}\n\nfn from_digits_desc_basecase_properties_helper<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>()\nwhere\n    Limb: SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_digit_count_n\", 32);\n    config.insert(\"mean_length_n\", 32);\n    unsigned_vec_unsigned_pair_gen_var_12::<T, Limb>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let t_base = T::exact_from(base);\n            assert_eq!(\n                from_digits_desc_basecase(&xs, base).is_some(),\n                xs.iter().all(|&x| x < t_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let n = from_digits_desc_basecase(&xs, base);\n            assert_eq!(\n                from_digits_desc_naive_primitive(&xs, T::exact_from(base)),\n                n\n            );\n        },\n    );\n}\n\n#[test]\nfn from_digits_desc_basecase_properties() {\n    apply_fn_to_unsigneds!(from_digits_desc_basecase_properties_helper);\n}\n\n#[test]\nfn test_from_digits_asc_limb() {\n    fn test_ok(xs: &[u32], base: Limb, n: &str) {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(from_digits_asc_limb(xs.iter().copied(), base).unwrap(), n);\n        assert_eq!(\n            from_digits_desc_naive_primitive(\n                &xs.iter().copied().rev().collect_vec(),\n                u32::exact_from(base)\n            )\n            .unwrap(),\n            n\n        );\n    }\n    test_ok(&[], 9, \"0\");\n    test_ok(&[0], 9, \"0\");\n    test_ok(&[1], 9, \"1\");\n    test_ok(&[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2], 3, \"123456\");\n    test_ok(&[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2, 0, 0], 3, \"123456\");\n    test_ok(&[2, 4, 6, 4, 2], 8, \"10658\");\n    test_ok(&[789, 456, 123], 1000, \"123456789\");\n    test_ok(\n        &[\n            14, 99, 101, 37, 10, 132, 124, 140, 98, 35, 144, 50, 41, 15, 67, 39, 12, 74, 27, 9, 21,\n            135, 62, 26, 68, 86, 128, 34, 78, 25, 75, 61, 73, 80, 66, 50, 15, 132, 40, 146, 83, 66,\n            87, 40, 41, 104, 37, 3, 44, 13, 51, 59, 139, 9, 39, 25, 27, 82, 29, 121, 32, 17, 22,\n            81, 102, 0, 86, 11, 129, 90, 113, 147, 108, 45, 120, 23, 73,\n        ],\n        150,\n        \"176685760608531978263731938997517835399219565848609872558191310084297042793489341607854254\\\n        709347189745346071475819587247558105442098729883999424898641968281841439662364\",\n    );\n    test_ok(\n        &[302, 2359, 150, 1581, 2859, 1843, 2403, 2039, 27, 1598],\n        3543,\n        \"140578615308984594421852296827289425\",\n    );\n    test_ok(\n        &[1187762660, 83185796, 570510527, 293681571, 1518538399, 1153431348],\n        1525385058,\n        \"9525530906278526930121302445905223566866929778026945776\",\n    );\n    test_ok(\n        &[\n            1535724679, 31832127, 1494323667, 798341655, 1169948427, 1204675417, 1214721934,\n            1599722999, 1842176041, 1659733906, 824969631, 1046252719,\n        ],\n        1895460450,\n        \"118713086621740109729266002848273602283691336549480820142301294962906804654789322428658177\\\n        1782212965464227294329\",\n    );\n\n    fn test_err(xs: &[u32], base: Limb) {\n        assert!(from_digits_asc_limb(xs.iter().copied(), base).is_none());\n        assert!(\n            from_digits_desc_naive_primitive(\n                &xs.iter().copied().rev().collect_vec(),\n                u32::exact_from(base)\n            )\n            .is_none()\n        );\n    }\n    test_err(&[12, 11, 10], 10);\n}\n\nfn from_digits_asc_limb_fail_helper<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>()\nwhere\n    Limb: TryFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert_panic!(from_digits_asc_limb::<_, T>(empty(), 0));\n    assert_panic!(from_digits_asc_limb::<_, T>(empty(), 1));\n}\n\n#[test]\nfn from_digits_asc_limb_fail() {\n    apply_fn_to_unsigneds!(from_digits_asc_limb_fail_helper);\n}\n\nfn from_digits_asc_limb_properties_helper<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>()\nwhere\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_digit_count_n\", 32);\n    unsigned_vec_unsigned_pair_gen_var_12::<T, Limb>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let t_base = T::exact_from(base);\n            assert_eq!(\n                from_digits_asc_limb(xs.iter().copied(), base).is_some(),\n                xs.iter().all(|&x| x < t_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let n = from_digits_asc_limb(xs.iter().copied(), base);\n            assert_eq!(\n                from_digits_desc_naive_primitive(\n                    &xs.into_iter().rev().collect_vec(),\n                    T::exact_from(base)\n                ),\n                n\n            );\n        },\n    );\n}\n\n#[test]\nfn from_digits_asc_limb_properties() {\n    apply_fn_to_unsigneds!(from_digits_asc_limb_properties_helper);\n}\n\n#[test]\nfn test_from_digits_desc_limb() {\n    fn test_ok(xs: &[u32], base: Limb, n: &str) {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(from_digits_desc_limb(xs.iter().copied(), base).unwrap(), n);\n        assert_eq!(\n            from_digits_desc_naive_primitive(xs, u32::exact_from(base)).unwrap(),\n            n\n        );\n    }\n    test_ok(&[], 9, \"0\");\n    // - Some(log_base) != base.checked_log_base_2()\n    // - base < 256\n    test_ok(&[0], 9, \"0\");\n    test_ok(&[1], 9, \"1\");\n    test_ok(&[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, \"123456\");\n    test_ok(&[0, 0, 2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, \"123456\");\n    // - Some(log_base) = base.checked_log_base_2()\n    test_ok(&[2, 4, 6, 4, 2], 8, \"10658\");\n    // - base >= 256\n    // - from_digits_desc_divide_and_conquer_limb; power_index == 0 || b <\n    //   FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    // - from_digits_desc_divide_and_conquer_limb; base <= SQRT_MAX_LIMB\n    test_ok(&[123, 456, 789], 1000, \"123456789\");\n    test_ok(\n        &[\n            73, 23, 120, 45, 108, 147, 113, 90, 129, 11, 86, 0, 102, 81, 22, 17, 32, 121, 29, 82,\n            27, 25, 39, 9, 139, 59, 51, 13, 44, 3, 37, 104, 41, 40, 87, 66, 83, 146, 40, 132, 15,\n            50, 66, 80, 73, 61, 75, 25, 78, 34, 128, 86, 68, 26, 62, 135, 21, 9, 27, 74, 12, 39,\n            67, 15, 41, 50, 144, 35, 98, 140, 124, 132, 10, 37, 101, 99, 14,\n        ],\n        150,\n        \"176685760608531978263731938997517835399219565848609872558191310084297042793489341607854254\\\n        709347189745346071475819587247558105442098729883999424898641968281841439662364\",\n    );\n    // - power_index != 0 && b >= FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    // - from_digits_desc_divide_and_conquer_limb; xs_len > p\n    test_ok(\n        &[1598, 27, 2039, 2403, 1843, 2859, 1581, 150, 2359, 302],\n        3543,\n        \"140578615308984594421852296827289425\",\n    );\n    // - from_digits_desc_divide_and_conquer_limb; base > SQRT_MAX_LIMB\n    test_ok(\n        &[1153431348, 1518538399, 293681571, 570510527, 83185796, 1187762660],\n        1525385058,\n        \"9525530906278526930121302445905223566866929778026945776\",\n    );\n    // - from_digits_desc_divide_and_conquer_limb; xs_len <= p\n    test_ok(\n        &[\n            1046252719, 824969631, 1659733906, 1842176041, 1599722999, 1214721934, 1204675417,\n            1169948427, 798341655, 1494323667, 31832127, 1535724679,\n        ],\n        1895460450,\n        \"118713086621740109729266002848273602283691336549480820142301294962906804654789322428658177\\\n        1782212965464227294329\",\n    );\n\n    fn test_err(xs: &[u32], base: Limb) {\n        assert!(from_digits_desc_limb(xs.iter().copied(), base).is_none());\n        assert!(from_digits_desc_naive_primitive(xs, u32::exact_from(base)).is_none());\n    }\n    test_err(&[10, 11, 12], 10);\n}\n\nfn from_digits_desc_limb_fail_helper<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>()\nwhere\n    Limb: TryFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert_panic!(from_digits_desc_limb::<_, T>(empty(), 0));\n    assert_panic!(from_digits_desc_limb::<_, T>(empty(), 1));\n}\n\n#[test]\nfn from_digits_desc_limb_fail() {\n    apply_fn_to_unsigneds!(from_digits_desc_limb_fail_helper);\n}\n\nfn from_digits_desc_limb_properties_helper<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>()\nwhere\n    Limb: ExactFrom<T> + SaturatingFrom<T> + WrappingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_digit_count_n\", 32);\n    unsigned_vec_unsigned_pair_gen_var_12::<T, Limb>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let t_base = T::exact_from(base);\n            assert_eq!(\n                from_digits_desc_limb(xs.iter().copied(), base).is_some(),\n                xs.iter().all(|&x| x < t_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen_var_5::<T, Limb>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let n = from_digits_desc_limb(xs.iter().copied(), base);\n            assert_eq!(\n                from_digits_desc_naive_primitive(&xs, T::exact_from(base)),\n                n\n            );\n        },\n    );\n}\n\n#[test]\nfn from_digits_desc_limb_properties() {\n    apply_fn_to_unsigneds!(from_digits_desc_limb_properties_helper);\n}\n\n#[test]\nfn test_from_digits_asc_large() {\n    fn test_ok(xs: &[&str], base: &str, n: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(from_digits_asc_large(xs.clone(), &base).unwrap(), n);\n        assert_eq!(\n            from_digits_desc_naive(&xs.rev().collect_vec(), &base).unwrap(),\n            n\n        );\n    }\n    test_ok(&[\"0\", \"100\"], \"10000000000\", \"1000000000000\");\n    test_ok(\n        &[\"27917287424\", \"18657454436\", \"8470329472\"],\n        \"34359738368\",\n        \"10000000000000000000000000000000\",\n    );\n    test_ok(\n        &[\n            \"4373186134\",\n            \"2564485756\",\n            \"2124820161\",\n            \"4270626619\",\n            \"5254372654\",\n            \"713959034\",\n            \"4750044302\",\n            \"5833014701\",\n            \"978351288\",\n            \"4288991795\",\n            \"972424917\",\n            \"1439538405\",\n            \"5308114100\",\n            \"1115837958\",\n            \"2267585072\",\n            \"4579628351\",\n            \"3319271253\",\n            \"139021832\",\n        ],\n        \"6000000000\",\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n    );\n    test_ok(\n        &[\n            \"10459983243\",\n            \"21532249186\",\n            \"9820491776\",\n            \"2837355685\",\n            \"9767368393\",\n            \"3483032332\",\n            \"21535703589\",\n            \"11033729126\",\n            \"9179503556\",\n            \"8692905086\",\n            \"4911199976\",\n            \"15555287795\",\n            \"16865310802\",\n            \"20703615271\",\n            \"16296043356\",\n            \"2287104975\",\n            \"7356592443\",\n            \"19932263435\",\n            \"22157300197\",\n        ],\n        \"24107150480\",\n        \"167549316476609610254199818013888896761159964082484503741352784741144483211685148473082817\\\n        5855188918761759968447473283739550817700685872668984640703760436616510553858385622841396530\\\n        38089626212682923\",\n    );\n\n    fn test_err(xs: &[&str], base: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        assert!(from_digits_asc_large(xs.clone(), &base).is_none());\n        assert!(from_digits_desc_naive(&xs.rev().collect_vec(), &base).is_none());\n    }\n    test_err(\n        &[\"1000000000000000000000001\", \"1000000000000000000000002\"],\n        \"1000000000000000000000000\",\n    );\n}\n\n#[test]\nfn from_digits_asc_large_fail() {\n    assert_panic!(from_digits_asc_large(empty(), &Natural::ZERO));\n    assert_panic!(from_digits_asc_large(empty(), &Natural::ONE));\n}\n\n#[test]\nfn from_digits_asc_large_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_digit_count_n\", 32);\n    natural_vec_natural_pair_gen_var_3().test_properties_with_config(&config, |(xs, base)| {\n        assert_eq!(\n            from_digits_asc_large(xs.iter().cloned(), &base).is_some(),\n            xs.iter().all(|x| x < &base)\n        );\n    });\n\n    natural_vec_natural_pair_gen_var_1().test_properties_with_config(&config, |(xs, base)| {\n        let n = from_digits_asc_large(xs.iter().cloned(), &base);\n        assert_eq!(\n            from_digits_desc_naive(&xs.into_iter().rev().collect_vec(), &base),\n            n\n        );\n    });\n}\n\n#[test]\nfn test_from_digits_desc_large() {\n    fn test_ok(xs: &[&str], base: &str, n: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(from_digits_desc_large(xs.clone(), &base).unwrap(), n);\n        assert_eq!(from_digits_desc_naive(&xs.collect_vec(), &base).unwrap(), n);\n    }\n    // - Some(log_base) != base.checked_log_base_2()\n    // - from_digits_desc_divide_and_conquer; power_index == 0 || u64::exact_from(xs_len) *\n    //   base.significant_bits() < FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    test_ok(&[\"100\", \"0\"], \"10000000000\", \"1000000000000\");\n    // - Some(log_base) = base.checked_log_base_2()\n    test_ok(\n        &[\"8470329472\", \"18657454436\", \"27917287424\"],\n        \"34359738368\",\n        \"10000000000000000000000000000000\",\n    );\n    // - from_digits_desc_divide_and_conquer; power_index != 0 && u64::exact_from(xs_len) *\n    //   base.significant_bits() >= FROM_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    // - from_digits_desc_divide_and_conquer; xs_len > p\n    test_ok(\n        &[\n            \"139021832\",\n            \"3319271253\",\n            \"4579628351\",\n            \"2267585072\",\n            \"1115837958\",\n            \"5308114100\",\n            \"1439538405\",\n            \"972424917\",\n            \"4288991795\",\n            \"978351288\",\n            \"5833014701\",\n            \"4750044302\",\n            \"713959034\",\n            \"5254372654\",\n            \"4270626619\",\n            \"2124820161\",\n            \"2564485756\",\n            \"4373186134\",\n        ],\n        \"6000000000\",\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n    );\n    // - from_digits_desc_divide_and_conquer; xs_len <= p\n    test_ok(\n        &[\n            \"22157300197\",\n            \"19932263435\",\n            \"7356592443\",\n            \"2287104975\",\n            \"16296043356\",\n            \"20703615271\",\n            \"16865310802\",\n            \"15555287795\",\n            \"4911199976\",\n            \"8692905086\",\n            \"9179503556\",\n            \"11033729126\",\n            \"21535703589\",\n            \"3483032332\",\n            \"9767368393\",\n            \"2837355685\",\n            \"9820491776\",\n            \"21532249186\",\n            \"10459983243\",\n        ],\n        \"24107150480\",\n        \"167549316476609610254199818013888896761159964082484503741352784741144483211685148473082817\\\n        5855188918761759968447473283739550817700685872668984640703760436616510553858385622841396530\\\n        38089626212682923\",\n    );\n\n    fn test_err(xs: &[&str], base: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        assert!(from_digits_desc_large(xs.clone(), &base).is_none());\n        assert!(from_digits_desc_naive(&xs.collect_vec(), &base).is_none());\n    }\n    test_err(\n        &[\"1000000000000000000000000\", \"1000000000000000000000001\"],\n        \"1000000000000000000000000\",\n    );\n}\n\n#[test]\nfn from_digits_desc_large_fail() {\n    assert_panic!(from_digits_desc_large(empty(), &Natural::ZERO));\n    assert_panic!(from_digits_desc_large(empty(), &Natural::ONE));\n}\n\n#[test]\nfn from_digits_desc_large_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_digit_count_n\", 32);\n    natural_vec_natural_pair_gen_var_3().test_properties_with_config(&config, |(xs, base)| {\n        assert_eq!(\n            from_digits_desc_large(xs.iter().cloned(), &base).is_some(),\n            xs.iter().all(|x| x < &base)\n        );\n    });\n\n    natural_vec_natural_pair_gen_var_1().test_properties_with_config(&config, |(xs, base)| {\n        let n = from_digits_desc_large(xs.iter().cloned(), &base);\n        assert_eq!(from_digits_desc_naive(&xs, &base), n);\n    });\n}\n\n#[test]\nfn from_digits_asc_unsigned() {\n    fn test_ok(xs: &[Limb], base: Limb, n: &str) {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            Natural::from_digits_asc(&base, xs.iter().copied()).unwrap(),\n            n\n        );\n    }\n    test_ok(&[], 9, \"0\");\n    test_ok(&[0], 9, \"0\");\n    test_ok(&[1], 9, \"1\");\n    test_ok(&[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2], 3, \"123456\");\n    test_ok(&[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2, 0, 0], 3, \"123456\");\n    test_ok(&[2, 4, 6, 4, 2], 8, \"10658\");\n    test_ok(&[789, 456, 123], 1000, \"123456789\");\n    test_ok(\n        &[\n            14, 99, 101, 37, 10, 132, 124, 140, 98, 35, 144, 50, 41, 15, 67, 39, 12, 74, 27, 9, 21,\n            135, 62, 26, 68, 86, 128, 34, 78, 25, 75, 61, 73, 80, 66, 50, 15, 132, 40, 146, 83, 66,\n            87, 40, 41, 104, 37, 3, 44, 13, 51, 59, 139, 9, 39, 25, 27, 82, 29, 121, 32, 17, 22,\n            81, 102, 0, 86, 11, 129, 90, 113, 147, 108, 45, 120, 23, 73,\n        ],\n        150,\n        \"176685760608531978263731938997517835399219565848609872558191310084297042793489341607854254\\\n        709347189745346071475819587247558105442098729883999424898641968281841439662364\",\n    );\n    test_ok(\n        &[302, 2359, 150, 1581, 2859, 1843, 2403, 2039, 27, 1598],\n        3543,\n        \"140578615308984594421852296827289425\",\n    );\n    test_ok(\n        &[1187762660, 83185796, 570510527, 293681571, 1518538399, 1153431348],\n        1525385058,\n        \"9525530906278526930121302445905223566866929778026945776\",\n    );\n    test_ok(\n        &[\n            1535724679, 31832127, 1494323667, 798341655, 1169948427, 1204675417, 1214721934,\n            1599722999, 1842176041, 1659733906, 824969631, 1046252719,\n        ],\n        1895460450,\n        \"118713086621740109729266002848273602283691336549480820142301294962906804654789322428658177\\\n        1782212965464227294329\",\n    );\n\n    fn test_err(xs: &[Limb], base: Limb) {\n        assert!(Natural::from_digits_asc(&base, xs.iter().copied()).is_none());\n    }\n    test_err(&[10, 11, 12], 10);\n}\n\nfn from_digits_asc_unsigned_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: Digits<T>,\n{\n    assert_panic!(Natural::from_digits_asc(&T::ONE, empty()));\n    assert_panic!(Natural::from_digits_asc(&T::ZERO, empty()));\n}\n\n#[test]\nfn from_digits_asc_unsigned_fail() {\n    apply_fn_to_unsigneds!(from_digits_asc_unsigned_fail_helper);\n}\n\nfn from_digits_asc_unsigned_helper<T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>>()\nwhere\n    Natural: Digits<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_digit_count_n\", 32);\n    unsigned_vec_unsigned_pair_gen_var_12::<T, T>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let t_base = T::exact_from(base);\n            assert_eq!(\n                Natural::from_digits_asc(&base, xs.iter().copied()).is_some(),\n                xs.iter().all(|&x| x < t_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen_var_5::<T, T>().test_properties_with_config(\n        &config,\n        |(digits, base)| {\n            let n = Natural::from_digits_asc(&base, digits.iter().copied()).unwrap();\n            assert_eq!(\n                Natural::from_digits_desc(&base, digits.iter().rev().copied()).unwrap(),\n                n\n            );\n            let trailing_zeros = slice_trailing_zeros(&digits);\n            assert_eq!(\n                n.to_digits_asc(&base),\n                &digits[..digits.len() - trailing_zeros]\n            );\n        },\n    );\n\n    unsigned_pair_gen_var_10::<T, T, usize>().test_properties(|(base, u)| {\n        assert_eq!(\n            Natural::from_digits_asc(&base, repeat_n(T::ZERO, u)),\n            Some(Natural::ZERO)\n        );\n    });\n}\n\n#[test]\nfn from_digits_asc_unsigned_properties() {\n    apply_fn_to_unsigneds!(from_digits_asc_unsigned_helper);\n}\n\n#[test]\nfn from_digits_desc_unsigned() {\n    fn test_ok(xs: &[Limb], base: Limb, n: &str) {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            Natural::from_digits_desc(&base, xs.iter().copied()).unwrap(),\n            n\n        );\n        assert_eq!(from_digits_desc_naive_primitive(xs, base).unwrap(), n);\n    }\n    test_ok(&[], 9, \"0\");\n    test_ok(&[0], 9, \"0\");\n    test_ok(&[1], 9, \"1\");\n    test_ok(&[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, \"123456\");\n    test_ok(&[0, 0, 2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0], 3, \"123456\");\n    test_ok(&[2, 4, 6, 4, 2], 8, \"10658\");\n    test_ok(&[123, 456, 789], 1000, \"123456789\");\n    test_ok(\n        &[\n            73, 23, 120, 45, 108, 147, 113, 90, 129, 11, 86, 0, 102, 81, 22, 17, 32, 121, 29, 82,\n            27, 25, 39, 9, 139, 59, 51, 13, 44, 3, 37, 104, 41, 40, 87, 66, 83, 146, 40, 132, 15,\n            50, 66, 80, 73, 61, 75, 25, 78, 34, 128, 86, 68, 26, 62, 135, 21, 9, 27, 74, 12, 39,\n            67, 15, 41, 50, 144, 35, 98, 140, 124, 132, 10, 37, 101, 99, 14,\n        ],\n        150,\n        \"176685760608531978263731938997517835399219565848609872558191310084297042793489341607854254\\\n        709347189745346071475819587247558105442098729883999424898641968281841439662364\",\n    );\n    test_ok(\n        &[1598, 27, 2039, 2403, 1843, 2859, 1581, 150, 2359, 302],\n        3543,\n        \"140578615308984594421852296827289425\",\n    );\n    test_ok(\n        &[1153431348, 1518538399, 293681571, 570510527, 83185796, 1187762660],\n        1525385058,\n        \"9525530906278526930121302445905223566866929778026945776\",\n    );\n    test_ok(\n        &[\n            1046252719, 824969631, 1659733906, 1842176041, 1599722999, 1214721934, 1204675417,\n            1169948427, 798341655, 1494323667, 31832127, 1535724679,\n        ],\n        1895460450,\n        \"118713086621740109729266002848273602283691336549480820142301294962906804654789322428658177\\\n        1782212965464227294329\",\n    );\n\n    fn test_err(xs: &[Limb], base: Limb) {\n        assert!(Natural::from_digits_desc(&base, xs.iter().copied()).is_none());\n        assert!(from_digits_desc_naive_primitive(xs, base).is_none());\n    }\n    test_err(&[10, 11, 12], 10);\n}\n\nfn from_digits_desc_unsigned_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: Digits<T>,\n{\n    assert_panic!(Natural::from_digits_desc(&T::ONE, empty()));\n    assert_panic!(Natural::from_digits_desc(&T::ZERO, empty()));\n}\n\n#[test]\nfn from_digits_desc_unsigned_fail() {\n    apply_fn_to_unsigneds!(from_digits_desc_unsigned_fail_helper);\n}\n\nfn from_digits_desc_unsigned_helper<T: PrimitiveUnsigned + SaturatingFrom<T> + WrappingFrom<T>>()\nwhere\n    Natural: Digits<T> + From<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_digit_count_n\", 32);\n    unsigned_vec_unsigned_pair_gen_var_12::<T, T>().test_properties_with_config(\n        &config,\n        |(xs, base)| {\n            let t_base = T::exact_from(base);\n            assert_eq!(\n                Natural::from_digits_desc(&base, xs.iter().copied()).is_some(),\n                xs.iter().all(|&x| x < t_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen_var_5::<T, T>().test_properties_with_config(\n        &config,\n        |(digits, base)| {\n            let n = Natural::from_digits_desc(&base, digits.iter().copied()).unwrap();\n            assert_eq!(\n                Natural::from_digits_asc(&base, digits.iter().rev().copied()).unwrap(),\n                n\n            );\n            let leading_zeros = slice_leading_zeros(&digits);\n            assert_eq!(n.to_digits_desc(&base), &digits[leading_zeros..]);\n            assert_eq!(\n                from_digits_desc_naive_primitive(&digits, T::exact_from(base)).unwrap(),\n                n\n            );\n        },\n    );\n\n    unsigned_pair_gen_var_10::<T, T, usize>().test_properties(|(base, u)| {\n        assert_eq!(\n            Natural::from_digits_desc(&base, repeat_n(T::ZERO, u)),\n            Some(Natural::ZERO)\n        );\n    });\n}\n\n#[test]\nfn from_digits_desc_unsigned_properties() {\n    apply_fn_to_unsigneds!(from_digits_desc_unsigned_helper);\n}\n\n#[test]\nfn from_digits_asc() {\n    fn test_ok(xs: &[&str], base: &str, n: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(Natural::from_digits_asc(&base, xs.clone()).unwrap(), n);\n    }\n    test_ok(&[], \"9\", \"0\");\n    test_ok(&[\"0\"], \"9\", \"0\");\n    test_ok(&[\"1\"], \"9\", \"1\");\n    test_ok(\n        &[\"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\", \"2\", \"0\", \"0\", \"2\"],\n        \"3\",\n        \"123456\",\n    );\n    test_ok(\n        &[\"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\", \"2\", \"0\", \"0\", \"2\", \"0\", \"0\"],\n        \"3\",\n        \"123456\",\n    );\n    test_ok(&[\"2\", \"4\", \"6\", \"4\", \"2\"], \"8\", \"10658\");\n    test_ok(&[\"789\", \"456\", \"123\"], \"1000\", \"123456789\");\n    test_ok(\n        &[\n            \"14\", \"99\", \"101\", \"37\", \"10\", \"132\", \"124\", \"140\", \"98\", \"35\", \"144\", \"50\", \"41\",\n            \"15\", \"67\", \"39\", \"12\", \"74\", \"27\", \"9\", \"21\", \"135\", \"62\", \"26\", \"68\", \"86\", \"128\",\n            \"34\", \"78\", \"25\", \"75\", \"61\", \"73\", \"80\", \"66\", \"50\", \"15\", \"132\", \"40\", \"146\", \"83\",\n            \"66\", \"87\", \"40\", \"41\", \"104\", \"37\", \"3\", \"44\", \"13\", \"51\", \"59\", \"139\", \"9\", \"39\",\n            \"25\", \"27\", \"82\", \"29\", \"121\", \"32\", \"17\", \"22\", \"81\", \"102\", \"0\", \"86\", \"11\", \"129\",\n            \"90\", \"113\", \"147\", \"108\", \"45\", \"120\", \"23\", \"73\",\n        ],\n        \"150\",\n        \"176685760608531978263731938997517835399219565848609872558191310084297042793489341607854254\\\n        709347189745346071475819587247558105442098729883999424898641968281841439662364\",\n    );\n    test_ok(\n        &[\"302\", \"2359\", \"150\", \"1581\", \"2859\", \"1843\", \"2403\", \"2039\", \"27\", \"1598\"],\n        \"3543\",\n        \"140578615308984594421852296827289425\",\n    );\n    test_ok(\n        &[\"1187762660\", \"83185796\", \"570510527\", \"293681571\", \"1518538399\", \"1153431348\"],\n        \"1525385058\",\n        \"9525530906278526930121302445905223566866929778026945776\",\n    );\n    test_ok(\n        &[\n            \"1535724679\",\n            \"31832127\",\n            \"1494323667\",\n            \"798341655\",\n            \"1169948427\",\n            \"1204675417\",\n            \"1214721934\",\n            \"1599722999\",\n            \"1842176041\",\n            \"1659733906\",\n            \"824969631\",\n            \"1046252719\",\n        ],\n        \"1895460450\",\n        \"118713086621740109729266002848273602283691336549480820142301294962906804654789322428658177\\\n        1782212965464227294329\",\n    );\n    test_ok(&[\"0\", \"100\"], \"10000000000\", \"1000000000000\");\n    test_ok(\n        &[\"27917287424\", \"18657454436\", \"8470329472\"],\n        \"34359738368\",\n        \"10000000000000000000000000000000\",\n    );\n    test_ok(\n        &[\n            \"4373186134\",\n            \"2564485756\",\n            \"2124820161\",\n            \"4270626619\",\n            \"5254372654\",\n            \"713959034\",\n            \"4750044302\",\n            \"5833014701\",\n            \"978351288\",\n            \"4288991795\",\n            \"972424917\",\n            \"1439538405\",\n            \"5308114100\",\n            \"1115837958\",\n            \"2267585072\",\n            \"4579628351\",\n            \"3319271253\",\n            \"139021832\",\n        ],\n        \"6000000000\",\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n    );\n    test_ok(\n        &[\n            \"10459983243\",\n            \"21532249186\",\n            \"9820491776\",\n            \"2837355685\",\n            \"9767368393\",\n            \"3483032332\",\n            \"21535703589\",\n            \"11033729126\",\n            \"9179503556\",\n            \"8692905086\",\n            \"4911199976\",\n            \"15555287795\",\n            \"16865310802\",\n            \"20703615271\",\n            \"16296043356\",\n            \"2287104975\",\n            \"7356592443\",\n            \"19932263435\",\n            \"22157300197\",\n        ],\n        \"24107150480\",\n        \"167549316476609610254199818013888896761159964082484503741352784741144483211685148473082817\\\n        5855188918761759968447473283739550817700685872668984640703760436616510553858385622841396530\\\n        38089626212682923\",\n    );\n\n    fn test_err(xs: &[&str], base: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        assert!(Natural::from_digits_asc(&base, xs.clone()).is_none());\n    }\n    test_err(&[\"101\", \"102\"], \"100\");\n}\n\n#[test]\nfn from_digits_asc_fail() {\n    assert_panic!(Natural::from_digits_asc(&Natural::ZERO, empty()));\n    assert_panic!(Natural::from_digits_asc(&Natural::ONE, empty()));\n}\n\n#[test]\nfn from_digits_asc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 64);\n    config.insert(\"mean_digit_count_n\", 32);\n    natural_vec_natural_pair_gen_var_4().test_properties_with_config(&config, |(xs, base)| {\n        assert_eq!(\n            Natural::from_digits_asc(&base, xs.iter().cloned()).is_some(),\n            xs.iter().all(|x| x < &base)\n        );\n    });\n\n    natural_vec_natural_pair_gen_var_2().test_properties_with_config(&config, |(digits, base)| {\n        let n = Natural::from_digits_asc(&base, digits.iter().cloned()).unwrap();\n        assert_eq!(\n            Natural::from_digits_desc(&base, digits.iter().rev().cloned()).unwrap(),\n            n\n        );\n        let trailing_zeros = slice_trailing_zeros(&digits);\n        assert_eq!(\n            n.to_digits_asc(&base),\n            &digits[..digits.len() - trailing_zeros]\n        );\n    });\n\n    natural_unsigned_pair_gen_var_5().test_properties(|(base, u)| {\n        assert_eq!(\n            Natural::from_digits_asc(&base, repeat_n(Natural::ZERO, u)),\n            Some(Natural::ZERO)\n        );\n    });\n}\n\n#[test]\nfn from_digits_desc() {\n    fn test_ok(xs: &[&str], base: &str, n: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(Natural::from_digits_desc(&base, xs.clone()).unwrap(), n);\n        assert_eq!(from_digits_desc_naive(&xs.collect_vec(), &base).unwrap(), n);\n    }\n    test_ok(&[], \"9\", \"0\");\n    test_ok(&[\"0\"], \"9\", \"0\");\n    test_ok(&[\"1\"], \"9\", \"1\");\n    test_ok(\n        &[\"2\", \"0\", \"0\", \"2\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\", \"0\"],\n        \"3\",\n        \"123456\",\n    );\n    test_ok(\n        &[\"0\", \"0\", \"2\", \"0\", \"0\", \"2\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\", \"0\"],\n        \"3\",\n        \"123456\",\n    );\n    test_ok(&[\"2\", \"4\", \"6\", \"4\", \"2\"], \"8\", \"10658\");\n    test_ok(&[\"123\", \"456\", \"789\"], \"1000\", \"123456789\");\n    test_ok(\n        &[\n            \"73\", \"23\", \"120\", \"45\", \"108\", \"147\", \"113\", \"90\", \"129\", \"11\", \"86\", \"0\", \"102\",\n            \"81\", \"22\", \"17\", \"32\", \"121\", \"29\", \"82\", \"27\", \"25\", \"39\", \"9\", \"139\", \"59\", \"51\",\n            \"13\", \"44\", \"3\", \"37\", \"104\", \"41\", \"40\", \"87\", \"66\", \"83\", \"146\", \"40\", \"132\", \"15\",\n            \"50\", \"66\", \"80\", \"73\", \"61\", \"75\", \"25\", \"78\", \"34\", \"128\", \"86\", \"68\", \"26\", \"62\",\n            \"135\", \"21\", \"9\", \"27\", \"74\", \"12\", \"39\", \"67\", \"15\", \"41\", \"50\", \"144\", \"35\", \"98\",\n            \"140\", \"124\", \"132\", \"10\", \"37\", \"101\", \"99\", \"14\",\n        ],\n        \"150\",\n        \"176685760608531978263731938997517835399219565848609872558191310084297042793489341607854254\\\n        709347189745346071475819587247558105442098729883999424898641968281841439662364\",\n    );\n    test_ok(\n        &[\"1598\", \"27\", \"2039\", \"2403\", \"1843\", \"2859\", \"1581\", \"150\", \"2359\", \"302\"],\n        \"3543\",\n        \"140578615308984594421852296827289425\",\n    );\n    test_ok(\n        &[\"1153431348\", \"1518538399\", \"293681571\", \"570510527\", \"83185796\", \"1187762660\"],\n        \"1525385058\",\n        \"9525530906278526930121302445905223566866929778026945776\",\n    );\n    test_ok(\n        &[\n            \"1046252719\",\n            \"824969631\",\n            \"1659733906\",\n            \"1842176041\",\n            \"1599722999\",\n            \"1214721934\",\n            \"1204675417\",\n            \"1169948427\",\n            \"798341655\",\n            \"1494323667\",\n            \"31832127\",\n            \"1535724679\",\n        ],\n        \"1895460450\",\n        \"118713086621740109729266002848273602283691336549480820142301294962906804654789322428658177\\\n        1782212965464227294329\",\n    );\n    test_ok(&[\"100\", \"0\"], \"10000000000\", \"1000000000000\");\n    test_ok(\n        &[\"8470329472\", \"18657454436\", \"27917287424\"],\n        \"34359738368\",\n        \"10000000000000000000000000000000\",\n    );\n    test_ok(\n        &[\n            \"139021832\",\n            \"3319271253\",\n            \"4579628351\",\n            \"2267585072\",\n            \"1115837958\",\n            \"5308114100\",\n            \"1439538405\",\n            \"972424917\",\n            \"4288991795\",\n            \"978351288\",\n            \"5833014701\",\n            \"4750044302\",\n            \"713959034\",\n            \"5254372654\",\n            \"4270626619\",\n            \"2124820161\",\n            \"2564485756\",\n            \"4373186134\",\n        ],\n        \"6000000000\",\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n    );\n    test_ok(\n        &[\n            \"22157300197\",\n            \"19932263435\",\n            \"7356592443\",\n            \"2287104975\",\n            \"16296043356\",\n            \"20703615271\",\n            \"16865310802\",\n            \"15555287795\",\n            \"4911199976\",\n            \"8692905086\",\n            \"9179503556\",\n            \"11033729126\",\n            \"21535703589\",\n            \"3483032332\",\n            \"9767368393\",\n            \"2837355685\",\n            \"9820491776\",\n            \"21532249186\",\n            \"10459983243\",\n        ],\n        \"24107150480\",\n        \"167549316476609610254199818013888896761159964082484503741352784741144483211685148473082817\\\n        5855188918761759968447473283739550817700685872668984640703760436616510553858385622841396530\\\n        38089626212682923\",\n    );\n\n    fn test_err(xs: &[&str], base: &str) {\n        let xs = xs.iter().map(|x| Natural::from_str(x).unwrap());\n        let base = Natural::from_str(base).unwrap();\n        assert!(Natural::from_digits_desc(&base, xs.clone()).is_none());\n        assert!(from_digits_desc_naive(&xs.collect_vec(), &base).is_none());\n    }\n    test_err(&[\"101\", \"102\"], \"100\");\n}\n\n#[test]\nfn from_digits_desc_fail() {\n    assert_panic!(Natural::from_digits_desc(&Natural::ZERO, empty()));\n    assert_panic!(Natural::from_digits_desc(&Natural::ONE, empty()));\n}\n\n#[test]\nfn from_digits_desc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 64);\n    config.insert(\"mean_digit_count_n\", 32);\n    natural_vec_natural_pair_gen_var_4().test_properties_with_config(&config, |(xs, base)| {\n        assert_eq!(\n            Natural::from_digits_desc(&base, xs.iter().cloned()).is_some(),\n            xs.iter().all(|x| x < &base)\n        );\n    });\n\n    natural_vec_natural_pair_gen_var_2().test_properties_with_config(&config, |(digits, base)| {\n        let n = Natural::from_digits_desc(&base, digits.iter().cloned()).unwrap();\n        assert_eq!(\n            Natural::from_digits_asc(&base, digits.iter().rev().cloned()).unwrap(),\n            n\n        );\n        let leading_zeros = slice_leading_zeros(&digits);\n        assert_eq!(n.to_digits_desc(&base), &digits[leading_zeros..]);\n        assert_eq!(from_digits_desc_naive(&digits, &base).unwrap(), n);\n    });\n\n    natural_unsigned_pair_gen_var_5().test_properties(|(base, u)| {\n        assert_eq!(\n            Natural::from_digits_desc(&base, repeat_n(Natural::ZERO, u)),\n            Some(Natural::ZERO)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/digits/from_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse itertools::repeat_n;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::PowerOf2Digits;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::slices::{slice_leading_zeros, slice_trailing_zeros};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_5, unsigned_pair_gen_var_18, unsigned_vec_gen,\n    unsigned_vec_unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_3,\n    unsigned_vec_unsigned_pair_gen_var_10, unsigned_vec_unsigned_pair_gen_var_11,\n};\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_vec_unsigned_pair_gen_var_1, natural_vec_unsigned_pair_gen_var_2,\n};\nuse std::panic::catch_unwind;\n\n#[test]\nfn test_from_power_of_2_digits_asc() {\n    fn test_ok<T: PrimitiveUnsigned>(log_base: u64, digits: &[T], out: &str)\n    where\n        Natural: From<T> + PowerOf2Digits<T>,\n    {\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied())\n                .unwrap()\n                .to_string(),\n            out\n        );\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc_naive(log_base, digits.iter().copied())\n                .unwrap()\n                .to_string(),\n            out\n        );\n    }\n    test_ok::<u8>(1, &[], \"0\");\n    test_ok::<u8>(1, &[0, 0, 0], \"0\");\n    test_ok::<u16>(10, &[123], \"123\");\n    test_ok::<u16>(\n        1,\n        &[\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1,\n            0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1,\n        ],\n        \"1000000000000\",\n    );\n    test_ok::<u32>(\n        3,\n        &[0, 0, 0, 0, 1, 2, 1, 5, 4, 2, 3, 4, 6, 1, 0],\n        \"1000000000000\",\n    );\n    test_ok::<u64>(4, &[0, 0, 0, 1, 5, 10, 4, 13, 8, 14], \"1000000000000\");\n    test_ok::<u32>(32, &[3567587328, 232], \"1000000000000\");\n    test_ok::<u64>(64, &[1000000000000], \"1000000000000\");\n    test_ok::<u64>(\n        64,\n        &[2003764205206896640, 54210],\n        \"1000000000000000000000000\",\n    );\n\n    fn test_err<T: PrimitiveUnsigned>(log_base: u64, digits: &[T])\n    where\n        Natural: From<T> + PowerOf2Digits<T>,\n    {\n        assert!(Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied()).is_none());\n        assert!(\n            Natural::from_power_of_2_digits_asc_naive(log_base, digits.iter().copied()).is_none()\n        );\n    }\n    test_err::<u8>(1, &[2]);\n}\n\nfn from_power_of_2_digits_asc_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: PowerOf2Digits<T>,\n{\n    assert_panic!(Natural::from_power_of_2_digits_asc(\n        0,\n        [T::ZERO].iter().copied()\n    ));\n    assert_panic!(Natural::from_power_of_2_digits_asc(\n        T::WIDTH + 1,\n        [T::TWO].iter().copied()\n    ));\n}\n\n#[test]\nfn from_power_of_2_digits_asc_fail() {\n    apply_fn_to_unsigneds!(from_power_of_2_digits_asc_fail_helper);\n}\n\n#[test]\nfn test_from_power_of_2_digits_desc() {\n    fn test_ok<T: PrimitiveUnsigned>(log_base: u64, digits: &[T], out: &str)\n    where\n        Natural: PowerOf2Digits<T>,\n    {\n        assert_eq!(\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied())\n                .unwrap()\n                .to_string(),\n            out\n        );\n    }\n    test_ok::<u8>(1, &[], \"0\");\n    test_ok::<u8>(1, &[0, 0, 0], \"0\");\n    test_ok::<u16>(10, &[123], \"123\");\n    test_ok::<u16>(\n        1,\n        &[\n            1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0,\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n        ],\n        \"1000000000000\",\n    );\n    test_ok::<u32>(\n        3,\n        &[0, 1, 6, 4, 3, 2, 4, 5, 1, 2, 1, 0, 0, 0, 0],\n        \"1000000000000\",\n    );\n    test_ok::<u64>(4, &[14, 8, 13, 4, 10, 5, 1, 0, 0, 0], \"1000000000000\");\n    test_ok::<u32>(32, &[232, 3567587328], \"1000000000000\");\n    test_ok::<u64>(64, &[1000000000000], \"1000000000000\");\n    test_ok::<u64>(\n        64,\n        &[54210, 2003764205206896640],\n        \"1000000000000000000000000\",\n    );\n\n    fn test_err<T: PrimitiveUnsigned>(log_base: u64, digits: &[T])\n    where\n        Natural: PowerOf2Digits<T>,\n    {\n        assert!(Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied()).is_none());\n    }\n    test_err::<u8>(1, &[2]);\n}\n\nfn from_power_of_2_digits_desc_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: PowerOf2Digits<T>,\n{\n    assert_panic!(Natural::from_power_of_2_digits_desc(\n        0,\n        [T::ZERO].iter().copied()\n    ));\n    assert_panic!(Natural::from_power_of_2_digits_desc(\n        T::WIDTH + 1,\n        [T::TWO].iter().copied()\n    ));\n}\n\n#[test]\nfn from_power_of_2_digits_desc_fail() {\n    apply_fn_to_unsigneds!(from_power_of_2_digits_desc_fail_helper);\n}\n\n#[test]\nfn test_from_power_of_2_digits_asc_natural() {\n    let test_ok = |log_base, digits, out| {\n        let digits = vec_from_str(digits).unwrap();\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned())\n                .unwrap()\n                .to_string(),\n            out\n        );\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc_natural_naive(log_base, digits.iter().cloned())\n                .unwrap()\n                .to_string(),\n            out\n        );\n    };\n    test_ok(1, \"[]\", \"0\");\n    test_ok(1, \"[0, 0, 0]\", \"0\");\n    test_ok(10, \"[123]\", \"123\");\n    test_ok(\n        1,\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, \\\n        0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1]\",\n        \"1000000000000\",\n    );\n    test_ok(\n        3,\n        \"[0, 0, 0, 0, 1, 2, 1, 5, 4, 2, 3, 4, 6, 1]\",\n        \"1000000000000\",\n    );\n    test_ok(4, \"[0, 0, 0, 1, 5, 10, 4, 13, 8, 14, 0]\", \"1000000000000\");\n    test_ok(32, \"[3567587328, 232]\", \"1000000000000\");\n    test_ok(64, \"[1000000000000]\", \"1000000000000\");\n    test_ok(\n        64,\n        \"[2003764205206896640, 54210]\",\n        \"1000000000000000000000000\",\n    );\n    test_ok(\n        33,\n        \"[6996099072, 4528236150, 13552]\",\n        \"1000000000000000000000000\",\n    );\n\n    let test_err = |log_base, digits| {\n        let digits = vec_from_str(digits).unwrap();\n        assert!(Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned()).is_none());\n        assert!(\n            Natural::from_power_of_2_digits_asc_natural_naive(log_base, digits.iter().cloned())\n                .is_none()\n        );\n    };\n    test_err(1, \"[2]\");\n}\n\n#[test]\n#[should_panic]\nfn from_power_of_2_digits_asc_natural_fail() {\n    let digits: Vec<Natural> = vec_from_str(\"[0, 0, 0]\").unwrap();\n    Natural::from_power_of_2_digits_asc(0, digits.iter().cloned());\n}\n\n#[test]\nfn test_from_power_of_2_digits_desc_natural() {\n    let test_ok = |log_base, digits, out| {\n        let digits: Vec<Natural> = vec_from_str(digits).unwrap();\n        assert_eq!(\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned())\n                .unwrap()\n                .to_string(),\n            out\n        );\n    };\n    test_ok(1, \"[]\", \"0\");\n    test_ok(1, \"[0, 0, 0]\", \"0\");\n    test_ok(10, \"[123]\", \"123\");\n    test_ok(\n        1,\n        \"[1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, \\\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n        \"1000000000000\",\n    );\n    test_ok(\n        3,\n        \"[1, 6, 4, 3, 2, 4, 5, 1, 2, 1, 0, 0, 0, 0]\",\n        \"1000000000000\",\n    );\n    test_ok(4, \"[0, 14, 8, 13, 4, 10, 5, 1, 0, 0, 0]\", \"1000000000000\");\n    test_ok(32, \"[232, 3567587328]\", \"1000000000000\");\n    test_ok(64, \"[1000000000000]\", \"1000000000000\");\n    test_ok(\n        64,\n        \"[54210, 2003764205206896640]\",\n        \"1000000000000000000000000\",\n    );\n    test_ok(\n        33,\n        \"[13552, 4528236150, 6996099072]\",\n        \"1000000000000000000000000\",\n    );\n\n    let test_err = |log_base, digits| {\n        let digits: Vec<Natural> = vec_from_str(digits).unwrap();\n        assert!(Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned()).is_none());\n    };\n    test_err(1, \"[2]\");\n}\n\n#[test]\n#[should_panic]\nfn from_power_of_2_digits_desc_natural_fail() {\n    let digits: Vec<Natural> = vec_from_str(\"[0, 0, 0]\").unwrap();\n    Natural::from_power_of_2_digits_desc(0, digits.iter().cloned());\n}\n\nfn from_power_of_2_digits_asc_properties_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T> + PowerOf2Digits<T>,\n    Limb: PowerOf2Digits<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_log_base_n\", T::WIDTH >> 1);\n    config.insert(\"mean_stripe_n\", 64);\n    config.insert(\"mean_digit_count_n\", 32);\n    unsigned_vec_unsigned_pair_gen_var_11().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied());\n            assert_eq!(\n                n.is_some(),\n                digits.iter().all(|x| x.significant_bits() <= log_base),\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen_var_10().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap();\n            assert_eq!(\n                Natural::from_power_of_2_digits_asc_naive(log_base, digits.iter().copied())\n                    .unwrap(),\n                n\n            );\n            assert_eq!(\n                Natural::from_power_of_2_digits_desc(log_base, digits.iter().rev().copied())\n                    .unwrap(),\n                n\n            );\n            let trailing_zeros = slice_trailing_zeros(&digits);\n            let trimmed_digits = digits[..digits.len() - trailing_zeros].to_vec();\n            assert_eq!(\n                PowerOf2Digits::<T>::to_power_of_2_digits_asc(&n, log_base),\n                trimmed_digits\n            );\n        },\n    );\n\n    unsigned_pair_gen_var_5::<usize, T>().test_properties(|(u, log_base)| {\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(log_base, repeat_n(T::ZERO, u)).unwrap(),\n            0\n        );\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_2::<Limb, T>().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Limb::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap();\n            assert_eq!(\n                Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap(),\n                Natural::try_from(Integer::from(n)).unwrap()\n            );\n        },\n    );\n}\n\n#[test]\nfn from_power_of_2_digits_asc_properties() {\n    apply_fn_to_unsigneds!(from_power_of_2_digits_asc_properties_helper);\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_stripe_n\", 64);\n    config.insert(\"mean_length_n\", 32);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(Limb::WIDTH, xs.iter().copied()).unwrap(),\n            Natural::from_limbs_asc(&xs)\n        );\n    });\n}\n\nfn from_power_of_2_digits_desc_properties_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T> + PowerOf2Digits<T>,\n    Limb: PowerOf2Digits<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_log_base_n\", T::WIDTH >> 1);\n    config.insert(\"mean_stripe_n\", 64);\n    config.insert(\"mean_digit_count_n\", 32);\n    unsigned_vec_unsigned_pair_gen_var_11().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied());\n            assert_eq!(\n                n.is_some(),\n                digits.iter().all(|x| x.significant_bits() <= log_base)\n            );\n        },\n    );\n\n    unsigned_vec_unsigned_pair_gen_var_10().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap();\n            assert_eq!(\n                Natural::from_power_of_2_digits_asc(log_base, digits.iter().rev().copied())\n                    .unwrap(),\n                n\n            );\n            let leading_zeros = slice_leading_zeros(&digits);\n            let trimmed_digits = digits[leading_zeros..].to_vec();\n            assert_eq!(\n                PowerOf2Digits::<T>::to_power_of_2_digits_desc(&n, log_base),\n                trimmed_digits\n            );\n        },\n    );\n\n    unsigned_pair_gen_var_5::<usize, T>().test_properties(|(u, log_base)| {\n        assert_eq!(\n            Natural::from_power_of_2_digits_desc(log_base, repeat_n(T::ZERO, u)),\n            Some(Natural::ZERO)\n        );\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_3::<Limb, T>().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Limb::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap();\n            let natural_n: Natural = From::<Limb>::from(n);\n            assert_eq!(\n                Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap(),\n                natural_n\n            );\n        },\n    );\n}\n\n#[test]\nfn from_power_of_2_digits_desc_properties() {\n    apply_fn_to_unsigneds!(from_power_of_2_digits_desc_properties_helper);\n\n    let mut config = GenConfig::new();\n    config.insert(\"mean_stripe_n\", 64);\n    config.insert(\"mean_length_n\", 32);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        assert_eq!(\n            Natural::from_power_of_2_digits_desc(Limb::WIDTH, xs.iter().copied()).unwrap(),\n            Natural::from_limbs_desc(&xs)\n        );\n    });\n}\n\n#[test]\nfn from_power_of_2_digits_asc_natural_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_log_base_n\", 16);\n    config.insert(\"mean_stripe_n\", 64);\n    config.insert(\"mean_digit_count_n\", 32);\n    natural_vec_unsigned_pair_gen_var_2().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned());\n            assert_eq!(\n                n.is_some(),\n                digits.iter().all(|x| x.significant_bits() <= log_base),\n            );\n        },\n    );\n\n    natural_vec_unsigned_pair_gen_var_1().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned()).unwrap();\n            assert_eq!(\n                Natural::from_power_of_2_digits_asc_natural_naive(log_base, digits.iter().cloned())\n                    .unwrap(),\n                n\n            );\n            assert_eq!(\n                Natural::from_power_of_2_digits_desc(log_base, digits.iter().rev().cloned())\n                    .unwrap(),\n                n\n            );\n            let trailing_zeros = slice_trailing_zeros(&digits);\n            let trimmed_digits = digits[..digits.len() - trailing_zeros].to_vec();\n            assert_eq!(\n                PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, log_base),\n                trimmed_digits\n            );\n        },\n    );\n\n    unsigned_pair_gen_var_18().test_properties(|(u, log_base)| {\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(log_base, repeat_n(Natural::ZERO, u)),\n            Some(Natural::ZERO)\n        );\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_10::<Limb>().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied());\n            let digits = digits.iter().copied().map(Natural::from).collect_vec();\n            assert_eq!(\n                Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned()),\n                n\n            );\n        },\n    );\n}\n\n#[test]\nfn from_power_of_2_digits_desc_natural_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_log_base_n\", 16);\n    config.insert(\"mean_stripe_n\", 64);\n    config.insert(\"mean_digit_count_n\", 32);\n    natural_vec_unsigned_pair_gen_var_2().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned());\n            assert_eq!(\n                n.is_some(),\n                digits.iter().all(|x| x.significant_bits() <= log_base)\n            );\n        },\n    );\n\n    natural_vec_unsigned_pair_gen_var_1().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned()).unwrap();\n            assert_eq!(\n                Natural::from_power_of_2_digits_asc(log_base, digits.iter().rev().cloned())\n                    .unwrap(),\n                n\n            );\n            let leading_zeros = slice_leading_zeros(&digits);\n            let trimmed_digits = digits[leading_zeros..].to_vec();\n            assert_eq!(\n                PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&n, log_base),\n                trimmed_digits\n            );\n        },\n    );\n\n    unsigned_pair_gen_var_18().test_properties(|(u, log_base)| {\n        assert_eq!(\n            Natural::from_power_of_2_digits_desc(log_base, repeat_n(Natural::ZERO, u)),\n            Some(Natural::ZERO)\n        );\n    });\n\n    unsigned_vec_unsigned_pair_gen_var_10::<Limb>().test_properties_with_config(\n        &config,\n        |(digits, log_base)| {\n            let n = Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap();\n            let digits = digits.iter().copied().map(Natural::from).collect_vec();\n            assert_eq!(\n                Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned()).unwrap(),\n                n\n            );\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/digits/power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{DivRound, Pow, Square};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, PowerOf2DigitIterable, PowerOf2DigitIterator, PowerOf2Digits,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::common::test_double_ended_iterator_size_hint;\nuse malachite_base::test_util::generators::{unsigned_pair_gen_var_5, unsigned_pair_gen_var_18};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_bool_vec_triple_gen_var_1, natural_unsigned_bool_vec_triple_gen_var_2,\n    natural_unsigned_pair_gen_var_6, natural_unsigned_pair_gen_var_7,\n    natural_unsigned_unsigned_triple_gen_var_2, natural_unsigned_unsigned_triple_gen_var_3,\n};\nuse std::panic::catch_unwind;\n\n#[test]\npub fn test_power_of_2_digits_primitive() {\n    let n = Natural::from(107u32);\n    assert_eq!(\n        PowerOf2Digits::<u8>::to_power_of_2_digits_asc(&n, 2),\n        &[3, 2, 2, 1]\n    );\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(&n, 2);\n    assert_eq!(digits.next(), Some(3));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(2));\n    assert_eq!(digits.next(), Some(2));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 3);\n    assert_eq!(digits.get_digit(1), 2);\n    assert_eq!(digits.get_digit(2), 2);\n    assert_eq!(digits.get_digit(3), 1);\n    assert_eq!(digits.get_digit(4), 0);\n    assert_eq!(digits.get_digit(5), 0);\n\n    let n = Natural::from(107u32);\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(&n, 2);\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next(), Some(3));\n    assert_eq!(digits.next(), Some(2));\n    assert_eq!(digits.next(), Some(2));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    let n = Natural::ZERO;\n    let mut digits = PowerOf2DigitIterable::<u32>::power_of_2_digits(&n, 5);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    let n = Natural::from(105u32);\n    assert_eq!(\n        PowerOf2Digits::<u8>::to_power_of_2_digits_asc(&n, 1),\n        &[1, 0, 0, 1, 0, 1, 1]\n    );\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(&n, 1);\n    assert_eq!(digits.next(), Some(1));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(0));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next(), Some(1));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 1);\n    assert_eq!(digits.get_digit(1), 0);\n    assert_eq!(digits.get_digit(2), 0);\n    assert_eq!(digits.get_digit(3), 1);\n    assert_eq!(digits.get_digit(4), 0);\n    assert_eq!(digits.get_digit(5), 1);\n    assert_eq!(digits.get_digit(6), 1);\n    assert_eq!(digits.get_digit(7), 0);\n    assert_eq!(digits.get_digit(8), 0);\n\n    let n = Natural::from(105u32);\n    let mut digits = PowerOf2DigitIterable::<u8>::power_of_2_digits(&n, 1);\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next(), Some(1));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next(), Some(0));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next_back(), Some(0));\n    assert_eq!(digits.next_back(), Some(1));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    let n = Natural::from(10u32).pow(12);\n    assert_eq!(\n        PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&n, 16),\n        &[4096, 54437, 232]\n    );\n    let mut digits = PowerOf2DigitIterable::<u64>::power_of_2_digits(&n, 16);\n    assert_eq!(digits.next(), Some(4096));\n    assert_eq!(digits.next_back(), Some(232));\n    assert_eq!(digits.next_back(), Some(54437));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 4096);\n    assert_eq!(digits.get_digit(1), 54437);\n    assert_eq!(digits.get_digit(2), 232);\n    assert_eq!(digits.get_digit(3), 0);\n    assert_eq!(digits.get_digit(4), 0);\n\n    let n = Natural::from(10u32).pow(12);\n    assert_eq!(\n        PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&n, 17),\n        &[69632, 27218, 58]\n    );\n    let mut digits = PowerOf2DigitIterable::<u64>::power_of_2_digits(&n, 17);\n    assert_eq!(digits.next(), Some(69632));\n    assert_eq!(digits.next_back(), Some(58));\n    assert_eq!(digits.next_back(), Some(27218));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 69632);\n    assert_eq!(digits.get_digit(1), 27218);\n    assert_eq!(digits.get_digit(2), 58);\n    assert_eq!(digits.get_digit(3), 0);\n    assert_eq!(digits.get_digit(4), 0);\n\n    let n = Natural::from(10u32).pow(12).square();\n    assert_eq!(\n        PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&n, 32),\n        &[2701131776, 466537709, 54210]\n    );\n    let mut digits = PowerOf2DigitIterable::<u64>::power_of_2_digits(&n, 32);\n    assert_eq!(digits.next(), Some(2701131776));\n    assert_eq!(digits.next_back(), Some(54210));\n    assert_eq!(digits.next_back(), Some(466537709));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 2701131776);\n    assert_eq!(digits.get_digit(1), 466537709);\n    assert_eq!(digits.get_digit(2), 54210);\n    assert_eq!(digits.get_digit(3), 0);\n    assert_eq!(digits.get_digit(4), 0);\n\n    let n = Natural::from(10u32).pow(12).square();\n    assert_eq!(\n        PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&n, 64),\n        &[2003764205206896640, 54210]\n    );\n    let mut digits = PowerOf2DigitIterable::<u64>::power_of_2_digits(&n, 64);\n    assert_eq!(digits.next(), Some(2003764205206896640));\n    assert_eq!(digits.next_back(), Some(54210));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 2003764205206896640);\n    assert_eq!(digits.get_digit(1), 54210);\n    assert_eq!(digits.get_digit(2), 0);\n    assert_eq!(digits.get_digit(3), 0);\n\n    let n = Natural::from(10u32).pow(12).square();\n    assert_eq!(\n        PowerOf2Digits::<u64>::to_power_of_2_digits_asc(&n, 37),\n        &[58535706624, 129132033639, 52]\n    );\n    let mut digits = PowerOf2DigitIterable::<u64>::power_of_2_digits(&n, 37);\n    assert_eq!(digits.next(), Some(58535706624));\n    assert_eq!(digits.next_back(), Some(52));\n    assert_eq!(digits.next_back(), Some(129132033639));\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 58535706624);\n    assert_eq!(digits.get_digit(1), 129132033639);\n    assert_eq!(digits.get_digit(2), 52);\n    assert_eq!(digits.get_digit(3), 0);\n    assert_eq!(digits.get_digit(4), 0);\n}\n\nmacro_rules! power_of_2_digits_primitive_fail_helper {\n    ($t:ident) => {\n        let x = Natural::from(107u32);\n        assert_panic!(PowerOf2DigitIterable::<$t>::power_of_2_digits(&x, 0));\n        let x = Natural::from(107u32);\n        assert_panic!(PowerOf2DigitIterable::<$t>::power_of_2_digits(&x, 200));\n    };\n}\n\n#[test]\nfn power_of_2_digits_fail() {\n    apply_to_unsigneds!(power_of_2_digits_primitive_fail_helper);\n}\n\n#[test]\npub fn test_power_of_2_digits_natural() {\n    let n = Natural::from(107u32);\n    assert_eq!(\n        PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, 2).to_debug_string(),\n        \"[3, 2, 2, 1]\"\n    );\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2);\n    assert_eq!(digits.next().unwrap(), 3);\n    assert_eq!(digits.next_back().unwrap(), 1);\n    assert_eq!(digits.next_back().unwrap(), 2);\n    assert_eq!(digits.next().unwrap(), 2);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 3);\n    assert_eq!(digits.get_digit(1), 2);\n    assert_eq!(digits.get_digit(2), 2);\n    assert_eq!(digits.get_digit(3), 1);\n    assert_eq!(digits.get_digit(4), 0);\n    assert_eq!(digits.get_digit(5), 0);\n\n    let n = Natural::from(107u32);\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 2);\n    assert_eq!(digits.next_back().unwrap(), 1);\n    assert_eq!(digits.next().unwrap(), 3);\n    assert_eq!(digits.next().unwrap(), 2);\n    assert_eq!(digits.next().unwrap(), 2);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    let n = Natural::ZERO;\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 5);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    let n = Natural::from(105u32);\n    assert_eq!(\n        PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, 1).to_debug_string(),\n        \"[1, 0, 0, 1, 0, 1, 1]\"\n    );\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 1);\n    assert_eq!(digits.next().unwrap(), 1);\n    assert_eq!(digits.next_back().unwrap(), 1);\n    assert_eq!(digits.next_back().unwrap(), 1);\n    assert_eq!(digits.next_back().unwrap(), 0);\n    assert_eq!(digits.next().unwrap(), 0);\n    assert_eq!(digits.next().unwrap(), 0);\n    assert_eq!(digits.next().unwrap(), 1);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 1);\n    assert_eq!(digits.get_digit(1), 0);\n    assert_eq!(digits.get_digit(2), 0);\n    assert_eq!(digits.get_digit(3), 1);\n    assert_eq!(digits.get_digit(4), 0);\n    assert_eq!(digits.get_digit(5), 1);\n    assert_eq!(digits.get_digit(6), 1);\n    assert_eq!(digits.get_digit(7), 0);\n    assert_eq!(digits.get_digit(8), 0);\n\n    let n = Natural::from(105u32);\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 1);\n    assert_eq!(digits.next_back().unwrap(), 1);\n    assert_eq!(digits.next().unwrap(), 1);\n    assert_eq!(digits.next().unwrap(), 0);\n    assert_eq!(digits.next().unwrap(), 0);\n    assert_eq!(digits.next_back().unwrap(), 1);\n    assert_eq!(digits.next_back().unwrap(), 0);\n    assert_eq!(digits.next_back().unwrap(), 1);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    let n = Natural::from(10u32).pow(12);\n    assert_eq!(\n        PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, 16).to_debug_string(),\n        \"[4096, 54437, 232]\"\n    );\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 16);\n    assert_eq!(digits.next().unwrap(), 4096);\n    assert_eq!(digits.next_back().unwrap(), 232);\n    assert_eq!(digits.next_back().unwrap(), 54437);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 4096);\n    assert_eq!(digits.get_digit(1), 54437);\n    assert_eq!(digits.get_digit(2), 232);\n    assert_eq!(digits.get_digit(3), 0);\n    assert_eq!(digits.get_digit(4), 0);\n\n    let n = Natural::from(10u32).pow(12);\n    assert_eq!(\n        PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, 17).to_debug_string(),\n        \"[69632, 27218, 58]\"\n    );\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 17);\n    assert_eq!(digits.next().unwrap(), 69632);\n    assert_eq!(digits.next_back().unwrap(), 58);\n    assert_eq!(digits.next_back().unwrap(), 27218);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 69632);\n    assert_eq!(digits.get_digit(1), 27218);\n    assert_eq!(digits.get_digit(2), 58);\n    assert_eq!(digits.get_digit(3), 0);\n    assert_eq!(digits.get_digit(4), 0);\n\n    let n = Natural::from(10u32).pow(12).square();\n    assert_eq!(\n        PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, 32).to_debug_string(),\n        \"[2701131776, 466537709, 54210]\"\n    );\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 32);\n    assert_eq!(digits.next().unwrap(), 2701131776u32);\n    assert_eq!(digits.next_back().unwrap(), 54210u32);\n    assert_eq!(digits.next_back().unwrap(), 466537709u32);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 2701131776u32);\n    assert_eq!(digits.get_digit(1), 466537709u32);\n    assert_eq!(digits.get_digit(2), 54210u32);\n    assert_eq!(digits.get_digit(3), 0u32);\n    assert_eq!(digits.get_digit(4), 0u32);\n\n    let n = Natural::from(10u32).pow(12).square();\n    assert_eq!(\n        PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, 64).to_debug_string(),\n        \"[2003764205206896640, 54210]\"\n    );\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 64);\n    assert_eq!(digits.next().unwrap(), 2003764205206896640u64);\n    assert_eq!(digits.next_back().unwrap(), 54210u64);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 2003764205206896640u64);\n    assert_eq!(digits.get_digit(1), 54210u64);\n    assert_eq!(digits.get_digit(2), 0u64);\n    assert_eq!(digits.get_digit(3), 0u64);\n\n    let n = Natural::from(10u32).pow(12).square();\n    assert_eq!(\n        PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, 37).to_debug_string(),\n        \"[58535706624, 129132033639, 52]\"\n    );\n    let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, 37);\n    assert_eq!(digits.next().unwrap(), 58535706624u64);\n    assert_eq!(digits.next_back().unwrap(), 52u64);\n    assert_eq!(digits.next_back().unwrap(), 129132033639u64);\n    assert_eq!(digits.next(), None);\n    assert_eq!(digits.next_back(), None);\n\n    assert_eq!(digits.get_digit(0), 58535706624u64);\n    assert_eq!(digits.get_digit(1), 129132033639u64);\n    assert_eq!(digits.get_digit(2), 52u64);\n    assert_eq!(digits.get_digit(3), 0u64);\n    assert_eq!(digits.get_digit(4), 0u64);\n}\n\n#[test]\n#[should_panic]\nfn natural_power_of_2_digits_natural_fail() {\n    PowerOf2DigitIterable::<Natural>::power_of_2_digits(&Natural::from(107u32), 0);\n}\n\nfn power_of_2_digits_primitive_properties_helper<T: PrimitiveUnsigned>()\nwhere\n    for<'a> &'a Natural: PowerOf2DigitIterable<T>,\n    Natural: PowerOf2Digits<T>,\n    for<'a> <&'a Natural as PowerOf2DigitIterable<T>>::PowerOf2DigitIterator: Clone,\n{\n    natural_unsigned_pair_gen_var_6::<T>().test_properties(|(ref n, log_base)| {\n        test_double_ended_iterator_size_hint(\n            PowerOf2DigitIterable::<T>::power_of_2_digits(n, log_base),\n            usize::exact_from(n.significant_bits().div_round(log_base, Ceiling).0),\n        );\n    });\n\n    natural_unsigned_bool_vec_triple_gen_var_2::<T>().test_properties(\n        |(ref n, log_base, ref bs)| {\n            let mut digits = PowerOf2DigitIterable::<T>::power_of_2_digits(n, log_base);\n            let mut digit_vec = Vec::new();\n            let mut i = 0;\n            for &b in bs {\n                if b {\n                    digit_vec.insert(i, digits.next().unwrap());\n                    i += 1;\n                } else {\n                    digit_vec.insert(i, digits.next_back().unwrap());\n                }\n            }\n            assert!(digits.next().is_none());\n            assert!(digits.next_back().is_none());\n            assert_eq!(\n                PowerOf2Digits::<T>::to_power_of_2_digits_asc(n, log_base),\n                digit_vec\n            );\n        },\n    );\n\n    natural_unsigned_unsigned_triple_gen_var_2::<u64, T>().test_properties(\n        |(ref n, log_base, i)| {\n            let digits = PowerOf2DigitIterable::<T>::power_of_2_digits(n, log_base);\n            if i < n.significant_bits().div_round(log_base, Ceiling).0 {\n                assert_eq!(\n                    digits.get_digit(i),\n                    PowerOf2Digits::<T>::to_power_of_2_digits_asc(n, log_base)\n                        [usize::exact_from(i)],\n                );\n            } else {\n                assert_eq!(digits.get_digit(i), T::ZERO);\n            }\n        },\n    );\n\n    unsigned_pair_gen_var_5::<u64, T>().test_properties(|(i, log_base)| {\n        let n = Natural::ZERO;\n        let digits = PowerOf2DigitIterable::<T>::power_of_2_digits(&n, log_base);\n        assert_eq!(digits.get_digit(i), T::ZERO);\n    });\n}\n\n#[test]\nfn power_of_2_digits_primitive_properties() {\n    apply_fn_to_unsigneds!(power_of_2_digits_primitive_properties_helper);\n}\n\n#[test]\nfn power_of_2_digits_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(ref n, log_base)| {\n        test_double_ended_iterator_size_hint(\n            PowerOf2DigitIterable::<Natural>::power_of_2_digits(n, log_base),\n            usize::exact_from(n.significant_bits().div_round(log_base, Ceiling).0),\n        );\n    });\n\n    natural_unsigned_bool_vec_triple_gen_var_1().test_properties(|(ref n, log_base, ref bs)| {\n        let mut digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(n, log_base);\n        let mut digit_vec = Vec::new();\n        let mut i = 0;\n        for &b in bs {\n            if b {\n                digit_vec.insert(i, digits.next().unwrap());\n                i += 1;\n            } else {\n                digit_vec.insert(i, digits.next_back().unwrap());\n            }\n        }\n        assert!(digits.next().is_none());\n        assert!(digits.next_back().is_none());\n        assert_eq!(\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(n, log_base),\n            digit_vec\n        );\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_3().test_properties(|(ref n, log_base, i)| {\n        let digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(n, log_base);\n        if i < n.significant_bits().div_round(log_base, Ceiling).0 {\n            assert_eq!(\n                digits.get_digit(i),\n                PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(n, log_base)\n                    [usize::exact_from(i)],\n            );\n        } else {\n            assert_eq!(digits.get_digit(i), 0);\n        }\n    });\n\n    unsigned_pair_gen_var_18().test_properties(|(i, log_base)| {\n        let n = Natural::ZERO;\n        let digits = PowerOf2DigitIterable::<Natural>::power_of_2_digits(&n, log_base);\n        assert_eq!(digits.get_digit(i), 0);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/digits/to_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::FloorLogBase;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, Digits, ExactFrom, PowerOf2Digits, SaturatingFrom,\n};\nuse malachite_base::num::logic::traits::BitConvertible;\nuse malachite_base::slices::slice_leading_zeros;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_gen_var_6, unsigned_pair_gen_var_6};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::digits::general_digits::{\n    PowerTableAlgorithm, limbs_to_digits_basecase, limbs_to_digits_small_base,\n    limbs_to_digits_small_base_basecase, to_digits_asc_large, to_digits_asc_limb,\n    to_digits_asc_naive, to_digits_asc_naive_primitive, to_digits_desc_large, to_digits_desc_limb,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nfn verify_limbs_to_digits_small_base_basecase<\n    T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>(\n    original_out: &[T],\n    len: usize,\n    xs: &[Limb],\n    base: u64,\n    out_len: usize,\n    out: &[T],\n) {\n    if len != 0 {\n        assert_eq!(len, out_len);\n    }\n    let mut digits = Vec::new();\n    to_digits_asc_naive_primitive(&mut digits, &Natural::from_limbs_asc(xs), base);\n    let digits = digits.into_iter().map(T::exact_from).collect_vec();\n    let mut expected_digits = vec![T::ZERO; out_len];\n    expected_digits[..digits.len()].copy_from_slice(&digits);\n    expected_digits.reverse();\n    assert_eq!(&out[..out_len], expected_digits);\n    assert_eq!(&out[out_len..], &original_out[out_len..]);\n\n    let result = out;\n    let mut out = original_out.to_vec();\n    let mut xs = xs.to_vec();\n    let out_len_alt = limbs_to_digits_small_base(&mut out, base, &mut xs, None);\n    let sig_out = &result[..out_len];\n    let sig_out_alt = &out[..out_len_alt];\n    assert_eq!(\n        &sig_out[slice_leading_zeros(sig_out)..out_len],\n        &sig_out_alt[slice_leading_zeros(sig_out_alt)..out_len_alt]\n    );\n}\n\nfn verify_limbs_to_digits_small_base<T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned>(\n    original_out: &[T],\n    original_xs: &[Limb],\n    base: u64,\n    out_len: usize,\n    out: &[T],\n) {\n    let mut digits = Vec::new();\n    to_digits_asc_naive_primitive(&mut digits, &Natural::from_limbs_asc(original_xs), base);\n    let digits = digits.into_iter().map(T::exact_from).collect_vec();\n    let mut expected_digits = vec![T::ZERO; out_len];\n    expected_digits[..digits.len()].copy_from_slice(&digits);\n    expected_digits.reverse();\n    assert_eq!(&out[..out_len], expected_digits);\n    assert_eq!(&out[out_len..], &original_out[out_len..]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_to_digits_small_base_basecase() {\n    fn test(out_before: &[u8], len: usize, xs: &[Limb], base: u64, out_after: &[u8]) {\n        let mut out = out_before.to_vec();\n        let out_len = limbs_to_digits_small_base_basecase(&mut out, len, xs, base);\n        assert_eq!(&out[..out_len], out_after);\n        verify_limbs_to_digits_small_base_basecase(out_before, len, xs, base, out_len, &out);\n    }\n    test(&[0; 20], 0, &[], 9, &[]);\n    // - base != 10\n    test(&[0; 20], 0, &[1], 9, &[1]);\n    test(\n        &[0; 20],\n        0,\n        &[123456],\n        3,\n        &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0],\n    );\n    test(&[0; 20], 0, &[123456], 5, &[1, 2, 4, 2, 2, 3, 1, 1]);\n    test(&[0; 20], 0, &[123456], 6, &[2, 3, 5, 1, 3, 2, 0]);\n    test(&[0; 20], 0, &[123456], 7, &[1, 0, 2, 2, 6, 3, 4]);\n    test(&[0; 20], 0, &[123456], 9, &[2, 0, 7, 3, 1, 3]);\n    // - base == 10\n    test(&[0; 20], 0, &[123456], 10, &[1, 2, 3, 4, 5, 6]);\n    test(&[0; 20], 0, &[123456], 11, &[8, 4, 8, 3, 3]);\n    test(&[0; 20], 0, &[123456], 12, &[5, 11, 5, 4, 0]);\n    test(&[0; 20], 0, &[123456], 13, &[4, 4, 2, 6, 8]);\n    test(&[0; 20], 0, &[123456], 14, &[3, 2, 13, 12, 4]);\n    test(&[0; 20], 0, &[123456], 15, &[2, 6, 8, 10, 6]);\n    test(&[0; 20], 0, &[123456], 100, &[12, 34, 56]);\n    test(&[0; 20], 0, &[123456], 123, &[8, 19, 87]);\n    test(&[0; 20], 0, &[123456], 255, &[1, 229, 36]);\n    // - base != 10 && xs_len > 1\n    test(\n        &[0; 40],\n        0,\n        &[123456, 789012],\n        5,\n        &[1, 2, 0, 2, 3, 1, 3, 3, 2, 4, 0, 4, 2, 1, 4, 4, 1, 3, 0, 0, 0, 1, 3],\n    );\n    // - base == 10 && xs_len > 1\n    test(\n        &[0; 40],\n        0,\n        &[123456, 789012],\n        10,\n        &[3, 3, 8, 8, 7, 8, 0, 7, 3, 6, 2, 7, 5, 0, 0, 8],\n    );\n    test(\n        &[0; 40],\n        0,\n        &[123456, 789012],\n        123,\n        &[7, 117, 75, 111, 16, 62, 88, 96],\n    );\n    test(\n        &[0; 40],\n        0,\n        &[123456, 789012],\n        255,\n        &[12, 82, 251, 166, 147, 176, 78],\n    );\n\n    // - zero_len != 0\n    test(&[0; 20], 8, &[123456], 9, &[0, 0, 2, 0, 7, 3, 1, 3]);\n    test(&[0; 20], 8, &[123456], 10, &[0, 0, 1, 2, 3, 4, 5, 6]);\n}\n\nfn limbs_to_digits_small_base_basecase_properties_helper<\n    T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    unsigned_vec_unsigned_unsigned_vec_unsigned_quadruple_gen_var_1::<T>()\n        .test_properties_with_config(&config, |(mut out, len, xs, base)| {\n            let old_out = out.clone();\n            let out_len = limbs_to_digits_small_base_basecase(&mut out, len, &xs, base);\n            verify_limbs_to_digits_small_base_basecase(&old_out, len, &xs, base, out_len, &out);\n        });\n}\n\n#[test]\nfn limbs_to_digits_small_base_basecase_properties() {\n    apply_fn_to_unsigneds!(limbs_to_digits_small_base_basecase_properties_helper);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_to_digits_small_base() {\n    fn test(out_before: &[u8], xs: &[Limb], base: u64, out_after: &[u8]) {\n        let mut out = out_before.to_vec();\n        let mut mut_xs = xs.to_vec();\n        let out_len = limbs_to_digits_small_base(&mut out, base, &mut mut_xs, None);\n        assert_eq!(&out[..out_len], out_after);\n        verify_limbs_to_digits_small_base(out_before, xs, base, out_len, &out);\n    }\n    // - xs_len == 0\n    test(&[0; 20], &[], 9, &[]);\n    // - 0 < xs_len < GET_STR_PRECOMPUTE_THRESHOLD\n    test(&[0; 20], &[1], 9, &[1]);\n    test(&[0; 20], &[123456], 3, &[2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0]);\n    test(&[0; 20], &[123456], 5, &[1, 2, 4, 2, 2, 3, 1, 1]);\n    test(&[0; 20], &[123456], 6, &[2, 3, 5, 1, 3, 2, 0]);\n    test(&[0; 20], &[123456], 7, &[1, 0, 2, 2, 6, 3, 4]);\n    test(&[0; 20], &[123456], 9, &[2, 0, 7, 3, 1, 3]);\n    test(&[0; 20], &[123456], 10, &[1, 2, 3, 4, 5, 6]);\n    test(&[0; 20], &[123456], 11, &[8, 4, 8, 3, 3]);\n    test(&[0; 20], &[123456], 12, &[5, 11, 5, 4, 0]);\n    test(&[0; 20], &[123456], 13, &[4, 4, 2, 6, 8]);\n    test(&[0; 20], &[123456], 14, &[3, 2, 13, 12, 4]);\n    test(&[0; 20], &[123456], 15, &[2, 6, 8, 10, 6]);\n    test(&[0; 20], &[123456], 100, &[12, 34, 56]);\n    test(&[0; 20], &[123456], 123, &[8, 19, 87]);\n    test(&[0; 20], &[123456], 255, &[1, 229, 36]);\n    test(\n        &[0; 40],\n        &[123456, 789012],\n        5,\n        &[1, 2, 0, 2, 3, 1, 3, 3, 2, 4, 0, 4, 2, 1, 4, 4, 1, 3, 0, 0, 0, 1, 3],\n    );\n    test(\n        &[0; 40],\n        &[123456, 789012],\n        10,\n        &[3, 3, 8, 8, 7, 8, 0, 7, 3, 6, 2, 7, 5, 0, 0, 8],\n    );\n    test(\n        &[0; 40],\n        &[123456, 789012],\n        123,\n        &[7, 117, 75, 111, 16, 62, 88, 96],\n    );\n    test(\n        &[0; 40],\n        &[123456, 789012],\n        255,\n        &[12, 82, 251, 166, 147, 176, 78],\n    );\n    // - xs_len >= GET_STR_PRECOMPUTE_THRESHOLD\n    // - power != 1 in limbs_choose_power_table_algorithm\n    // - number_of_powers > 1 in limbs_choose_power_table_algorithm\n    // - pow.odd() in limbs_choose_power_table_algorithm\n    // - n != pow << (i - 1) in limbs_choose_power_table_algorithm\n    // - pow.even() in limbs_choose_power_table_algorithm\n    // - n == pow << (i - 1) in limbs_choose_power_table_algorithm\n    // - n == pow << (i - 1) && pow.odd() in limbs_choose_power_table_algorithm\n    // - mul_cost > div_cost in limbs_choose_power_table_algorithm\n    // - number_of_powers > 0 in limbs_compute_power_table_using_div\n    // - digits_in_base == exp in limbs_compute_power_table_using_div\n    // - digits_in_base != exp in limbs_compute_power_table_using_div\n    // - remainder[adjust] == 0 && remainder[adjust +\n    //   1].divisible_by_power_of_2(big_base_trailing_zeros) in limbs_compute_power_table_using_div\n    // - xs_len >= GET_STR_DC_THRESHOLD in limbs_to_digits_small_base_divide_and_conquer\n    // - xs_len > total_len || xs_len == total_len && limbs_cmp_same_length(&xs[shift..],\n    //   power.power) == Less in limbs_to_digits_small_base_divide_and_conquer\n    // - len == 0 in limbs_to_digits_small_base_divide_and_conquer\n    // - xs_len < GET_STR_DC_THRESHOLD in limbs_to_digits_small_base_divide_and_conquer\n    // - xs_len != 0 in limbs_to_digits_small_base_divide_and_conquer\n    // - xs_len >= GET_STR_DC_THRESHOLD && len != 0\n    test(\n        &[0; 180],\n        &[\n            3056215344, 3478498987, 1525628527, 2940636569, 2793889044, 628858201, 4120826843,\n            1202551139, 2048559663, 3875755114, 2364980673, 2383732604, 3991426155, 229530160,\n            2263981142, 3298086542, 1508261462, 3566023571, 3747437734, 2439671349, 1387876207,\n            4019823972, 2986550141, 1187172695, 3025136315, 1183784222, 4211004667, 564539785,\n            1644122167, 999423211, 806938404, 10860543, 3458492920, 1199271248, 1169727513,\n            2600131941, 1298866326,\n        ],\n        104,\n        &[\n            7, 102, 41, 15, 79, 28, 23, 19, 82, 89, 32, 45, 23, 94, 68, 1, 5, 96, 34, 31, 47, 91,\n            9, 77, 70, 30, 32, 44, 67, 88, 51, 17, 18, 55, 66, 74, 61, 95, 51, 9, 76, 7, 12, 75,\n            82, 103, 16, 83, 92, 84, 48, 98, 79, 55, 50, 30, 40, 36, 56, 86, 60, 54, 92, 39, 68,\n            26, 46, 76, 15, 25, 98, 43, 62, 102, 40, 94, 59, 55, 52, 77, 52, 46, 18, 28, 12, 23,\n            49, 9, 30, 64, 53, 49, 39, 51, 51, 26, 3, 68, 82, 13, 35, 58, 44, 88, 58, 85, 63, 101,\n            42, 103, 20, 55, 48, 10, 64, 21, 48, 48, 10, 58, 5, 78, 48, 69, 20, 76, 63, 67, 50, 96,\n            39, 12, 47, 23, 6, 39, 17, 95, 40, 15, 3, 32, 68, 95, 82, 10, 86, 47, 53, 59, 74, 90,\n            47, 81, 3, 45, 0, 76, 37, 42, 61, 48, 62, 82, 64, 72, 87, 37, 56, 56, 32, 88, 11, 29,\n            52, 74, 32,\n        ],\n    );\n    // - n == pow << (i - 1) && pow.even() in limbs_choose_power_table_algorithm\n    test(\n        &[0; 180],\n        &[\n            4069654318, 200234362, 1446122636, 2556884733, 1171369997, 2416514207, 1914789404,\n            1066230418, 3700758050, 369490702, 4239134808, 1298432969, 1334078642, 1406451364,\n            1566734589, 43717764, 349561564, 1067107870, 957081235, 2721095071, 134596014,\n            1764968880, 2804491477, 129578595, 3283664828, 3844511094, 823049706, 3918883322,\n            4090685182, 2698902066, 3293373129, 2585973756, 1955397356, 2047755454, 2010607731,\n            254977406,\n        ],\n        98,\n        &[\n            11, 94, 75, 18, 50, 96, 56, 88, 85, 90, 66, 93, 13, 88, 39, 25, 83, 68, 29, 41, 42, 96,\n            90, 41, 59, 94, 15, 83, 29, 33, 61, 34, 20, 3, 95, 79, 36, 55, 65, 18, 5, 32, 85, 65,\n            66, 68, 86, 97, 17, 15, 45, 77, 91, 86, 25, 25, 29, 88, 40, 49, 31, 65, 77, 32, 67, 24,\n            30, 68, 32, 71, 77, 10, 14, 33, 78, 67, 70, 79, 32, 48, 4, 13, 12, 38, 21, 72, 31, 89,\n            96, 14, 90, 76, 40, 85, 8, 42, 9, 17, 58, 88, 97, 2, 61, 27, 41, 88, 66, 96, 27, 57,\n            34, 23, 26, 29, 76, 13, 69, 17, 77, 54, 36, 42, 60, 48, 27, 66, 80, 15, 9, 10, 89, 85,\n            21, 73, 48, 15, 8, 83, 75, 42, 97, 73, 49, 81, 11, 83, 41, 65, 82, 92, 50, 81, 27, 80,\n            19, 31, 58, 11, 63, 52, 58, 89, 56, 15, 19, 1, 88, 97, 54, 92, 60, 81, 85, 64,\n        ],\n    );\n    // - mul_cost <= div_cost in limbs_choose_power_table_algorithm\n    // - exponents[0] != chars_per_limb << number_of_powers in limbs_compute_power_table_using_mul\n    // - (digits_in_base + chars_per_limb) << (power_len - 2) > exponents[0] in\n    //   limbs_compute_power_table_using_mul\n    // - (digits_in_base + chars_per_limb) << i > exponents[0] in\n    //   limbs_compute_power_table_using_mul\n    // - row.digits_in_base < exponent in limbs_compute_power_table_using_mul\n    // - (digits_in_base + chars_per_limb) << i <= exponents[0] in\n    //   limbs_compute_power_table_using_mul\n    // - row.digits_in_base >= exponent in limbs_compute_power_table_using_mul\n    test(\n        &[0; 150],\n        &[\n            2679239519, 721774729, 553558153, 2694879530, 315361326, 1002777083, 3532473858,\n            3891803964, 3091255938, 1810962291, 792542145, 3504464685, 3414416050, 3265802575,\n            165631340, 3322240994, 1491277551, 2663783343, 3865601021, 953928172, 851798883,\n            3314281119, 2412275729, 3065107875, 530046998, 3405323797, 3741488431, 151251893,\n            3569252307, 689124400, 3633309617, 1796271003, 2766831787,\n        ],\n        185,\n        &[\n            1, 177, 172, 157, 179, 24, 121, 151, 101, 53, 20, 0, 32, 16, 183, 70, 103, 158, 81, 44,\n            98, 4, 131, 48, 3, 51, 74, 4, 65, 14, 155, 158, 26, 4, 61, 41, 45, 37, 13, 181, 116,\n            160, 63, 79, 91, 62, 45, 26, 140, 138, 144, 155, 65, 152, 63, 82, 38, 110, 34, 170,\n            107, 154, 167, 88, 45, 183, 23, 18, 75, 80, 104, 181, 46, 180, 172, 14, 30, 30, 37,\n            120, 2, 108, 166, 83, 83, 28, 144, 52, 157, 117, 57, 41, 66, 130, 94, 44, 35, 108, 25,\n            119, 99, 57, 28, 18, 53, 123, 74, 124, 108, 7, 115, 165, 112, 99, 93, 20, 13, 103, 9,\n            168, 57, 104, 133, 95, 140, 54, 118, 45, 116, 40, 105, 24, 179, 184, 15, 170, 168, 145,\n            42, 134, 41,\n        ],\n    );\n    // - (digits_in_base + chars_per_limb) << (power_len - 2) <= exponents[0] in\n    //   limbs_compute_power_table_using_mul\n    test(\n        &[0; 210],\n        &[\n            3460366518, 3248332038, 2411832328, 3680172951, 1648892566, 683827580, 1099145716,\n            3806372981, 2081403902, 2042441279, 575787637, 419553684, 2052335552, 545288482,\n            448081444, 2074676634, 783644738, 65453313, 1428854749, 3138519856, 870590090,\n            1920461474, 1804692757, 2629850054, 3724483390, 2876018746, 592000573, 3317750917,\n            3395943485, 823080054, 3857418097, 892494948, 1415289101, 2374957426, 803534376,\n            3410480407, 409051133, 4152156958, 1644919284, 1302252976, 2090652159, 3065750551,\n            2916695391, 2276338541, 3864821397, 4050961189,\n        ],\n        152,\n        &[\n            1, 76, 32, 138, 63, 89, 114, 3, 9, 90, 74, 101, 16, 92, 47, 39, 0, 48, 102, 113, 15,\n            123, 139, 33, 129, 140, 4, 93, 65, 38, 108, 102, 118, 40, 45, 109, 94, 140, 133, 120,\n            43, 46, 72, 119, 10, 142, 36, 67, 80, 76, 70, 73, 12, 148, 117, 51, 24, 25, 36, 50,\n            141, 1, 38, 50, 31, 72, 115, 75, 124, 151, 113, 74, 58, 26, 126, 60, 26, 129, 25, 12,\n            94, 98, 77, 26, 32, 150, 26, 51, 141, 89, 63, 81, 15, 114, 11, 82, 3, 25, 129, 54, 111,\n            75, 75, 136, 0, 30, 145, 127, 74, 62, 149, 15, 92, 117, 142, 92, 8, 30, 20, 32, 48, 79,\n            23, 150, 144, 71, 119, 0, 107, 28, 18, 92, 53, 72, 70, 32, 146, 17, 49, 72, 134, 134,\n            31, 40, 35, 76, 15, 53, 31, 47, 93, 51, 120, 125, 49, 149, 54, 55, 26, 149, 39, 86,\n            138, 130, 64, 76, 86, 146, 64, 106, 69, 34, 97, 46, 104, 149, 114, 129, 120, 109, 124,\n            12, 111, 71, 21, 13, 42, 146, 4, 60, 98, 98, 150, 134, 7, 86, 114, 118, 84, 3, 85, 127,\n            102, 102,\n        ],\n    );\n    // - exponents[0] == chars_per_limb << number_of_powers in limbs_compute_power_table_using_mul\n    test(\n        &[0; 160],\n        &[\n            2728906224, 1449576955, 3973690369, 849270619, 586255891, 923328784, 2717698803,\n            1477432292, 3710905696, 2207709497, 4292599247, 2411645706, 177966862, 3982000026,\n            1307696936, 903442, 3277385094, 3213674759, 2739559583, 1152850273, 3029194225,\n            1704802500, 2548066116, 1747267099, 2072192542, 3912866034, 1575257763, 2717691639,\n            3897187509, 2362053000, 1191544518,\n        ],\n        80,\n        &[\n            15, 18, 69, 61, 21, 59, 53, 35, 24, 20, 38, 58, 36, 48, 27, 15, 30, 14, 30, 16, 63, 8,\n            66, 12, 57, 9, 78, 68, 12, 13, 47, 9, 77, 51, 3, 72, 15, 59, 71, 67, 20, 50, 65, 15,\n            40, 3, 72, 79, 23, 9, 65, 43, 63, 57, 26, 54, 36, 78, 51, 25, 1, 22, 56, 53, 20, 45,\n            56, 42, 69, 71, 76, 2, 53, 75, 58, 14, 24, 40, 4, 60, 6, 1, 29, 56, 50, 20, 47, 3, 63,\n            52, 45, 66, 43, 7, 58, 49, 4, 73, 35, 51, 14, 35, 37, 28, 40, 76, 12, 60, 17, 65, 67,\n            67, 79, 78, 79, 18, 24, 36, 20, 41, 79, 51, 21, 42, 38, 41, 39, 52, 68, 74, 59, 30, 15,\n            21, 48, 26, 71, 48, 33, 46, 22, 9, 2, 78, 33, 21, 76, 4, 74, 72, 18, 37, 28, 56, 64,\n            44, 48,\n        ],\n    );\n}\n\nfn limbs_to_digits_small_base_properties_helper<\n    T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    unsigned_vec_unsigned_unsigned_vec_triple_gen_var_1::<T>().test_properties_with_config(\n        &config,\n        |(mut out, base, mut xs)| {\n            let old_out = out.clone();\n            let old_xs = xs.clone();\n            let out_len = limbs_to_digits_small_base(&mut out, base, &mut xs, None);\n            let result = out.clone();\n            verify_limbs_to_digits_small_base(&old_out, &old_xs, base, out_len, &result);\n\n            let mut xs = old_xs.clone();\n            assert_eq!(\n                limbs_to_digits_small_base(&mut out, base, &mut xs, Some(PowerTableAlgorithm::Mul)),\n                out_len\n            );\n            assert_eq!(out, result);\n\n            let mut xs = old_xs;\n            assert_eq!(\n                limbs_to_digits_small_base(&mut out, base, &mut xs, Some(PowerTableAlgorithm::Div)),\n                out_len\n            );\n            assert_eq!(out, result);\n        },\n    );\n}\n\n#[test]\nfn limbs_to_digits_small_base_properties() {\n    apply_fn_to_unsigneds!(limbs_to_digits_small_base_properties_helper);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_to_digits_basecase() {\n    fn test<T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n        xs_before: &[Limb],\n        base: Limb,\n        out: &[T],\n    ) {\n        let mut xs = xs_before.to_vec();\n        let mut digits = Vec::new();\n        limbs_to_digits_basecase::<T>(&mut digits, &mut xs, base);\n        assert_eq!(digits, out);\n        let mut digits = Vec::new();\n        to_digits_asc_naive_primitive(&mut digits, &Natural::from_limbs_asc(xs_before), base);\n        assert_eq!(digits.into_iter().map(T::exact_from).collect_vec(), out);\n    }\n    test::<u64>(&[0, 0], 64, &[]);\n    test::<u64>(&[2, 0], 64, &[2]);\n    test::<u16>(&[123, 0], 8, &[3, 7, 1]);\n    test::<u16>(&[1000000, 0], 256, &[64, 66, 15]);\n    test::<u64>(&[1000000, 0], 256, &[64, 66, 15]);\n    test::<u32>(&[1000, 0], 2, &[0, 0, 0, 1, 0, 1, 1, 1, 1, 1]);\n\n    test::<u32>(&[0, 0], 3, &[]);\n    test::<u32>(&[2, 0], 3, &[2]);\n    test::<u32>(&[123456, 0], 3, &[0, 1, 1, 0, 0, 1, 1, 2, 0, 0, 2]);\n    test::<u32>(&[123456, 0], 10, &[6, 5, 4, 3, 2, 1]);\n    test::<u32>(&[123456, 0], 100, &[56, 34, 12]);\n    test::<u32>(&[123456, 0], 123, &[87, 19, 8]);\n\n    test::<u32>(\n        &[123, 456, 789],\n        2,\n        &[\n            1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,\n        ],\n    );\n    test::<u32>(\n        &[123, 456, 789],\n        3,\n        &[\n            0, 0, 2, 2, 0, 1, 0, 0, 1, 1, 1, 0, 2, 1, 1, 0, 0, 2, 0, 2, 0, 0, 2, 0, 2, 2, 0, 0, 1,\n            1, 0, 1, 2, 0, 0, 2, 2, 0, 1, 0, 0, 0, 1, 2, 2, 1, 1,\n        ],\n    );\n    test::<u32>(\n        &[123, 456, 789],\n        10,\n        &[3, 2, 1, 2, 1, 3, 1, 4, 3, 5, 1, 1, 6, 7, 0, 1, 8, 4, 4, 5, 5, 4, 1],\n    );\n    test::<u32>(\n        &[123, 456, 789],\n        100,\n        &[23, 21, 31, 41, 53, 11, 76, 10, 48, 54, 45, 1],\n    );\n    test::<u32>(\n        &[123, 456, 789],\n        128,\n        &[123, 0, 0, 0, 0, 57, 0, 0, 0, 42, 12],\n    );\n    test::<u64>(\n        &[123, 456, 789],\n        Limb::power_of_2(16),\n        &[123, 0, 456, 0, 789],\n    );\n}\n\nfn limbs_to_digits_basecase_fail_helper<T: ConvertibleFrom<Limb> + PrimitiveUnsigned>() {\n    assert_panic!(limbs_to_digits_basecase::<T>(&mut Vec::new(), &mut [1], 2));\n    assert_panic!(limbs_to_digits_basecase::<T>(\n        &mut Vec::new(),\n        &mut [123, 456],\n        0\n    ));\n    assert_panic!(limbs_to_digits_basecase::<T>(\n        &mut Vec::new(),\n        &mut [123, 456],\n        1\n    ));\n}\n\n#[test]\nfn limbs_to_digits_basecase_fail() {\n    apply_fn_to_unsigneds!(limbs_to_digits_basecase_fail_helper);\n\n    assert_panic!(limbs_to_digits_basecase::<u8>(\n        &mut Vec::new(),\n        &mut [123, 456],\n        300\n    ));\n}\n\nfn limbs_to_digits_basecase_properties_helper<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>()\nwhere\n    Limb: SaturatingFrom<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    config.insert(\"mean_stripe_d\", 1);\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_length_d\", 1);\n    unsigned_vec_unsigned_pair_gen_var_4::<Limb, T>().test_properties_with_config(\n        &config,\n        |(mut xs, base)| {\n            let xs_old = xs.clone();\n            let mut digits = Vec::new();\n            limbs_to_digits_basecase::<T>(&mut digits, &mut xs, base);\n            let mut digits_alt = Vec::new();\n            to_digits_asc_naive_primitive(&mut digits_alt, &Natural::from_limbs_asc(&xs_old), base);\n            let digits_alt = digits_alt.into_iter().map(T::exact_from).collect_vec();\n            assert_eq!(digits, digits_alt);\n        },\n    );\n}\n\n#[test]\nfn limbs_to_digits_basecase_properties() {\n    apply_fn_to_unsigneds!(limbs_to_digits_basecase_properties_helper);\n}\n\n#[test]\nfn test_to_digits_asc_limb() {\n    fn test<T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n        x: &str,\n        base: Limb,\n        out: &[T],\n    ) where\n        Limb: Digits<T>,\n        Natural: From<T> + PowerOf2Digits<T>,\n    {\n        let x = Natural::from_str(x).unwrap();\n        assert_eq!(to_digits_asc_limb::<T>(&x, base), out);\n        let mut digits_alt = Vec::new();\n        to_digits_asc_naive_primitive(&mut digits_alt, &x, T::exact_from(base));\n        assert_eq!(digits_alt, out);\n    }\n    test::<u8>(\"0\", 10, &[]);\n    test::<u8>(\"0\", 16, &[]);\n    // - base is not a power of 2\n    // - x is small\n    test::<u8>(\"123\", 10, &[3, 2, 1]);\n    // - base is a power of 2\n    test::<u8>(\"123\", 8, &[3, 7, 1]);\n    // - x is large\n    // - x is large and base < 256\n    test::<u8>(\n        \"1473250819553359898729024041508\",\n        77,\n        &[44, 55, 51, 10, 43, 13, 36, 15, 70, 15, 19, 57, 50, 10, 22, 74],\n    );\n    // - x is large and base >= 256\n    // - to_digits_asc_divide_and_conquer_limb: many digits\n    // - to_digits_asc_divide_and_conquer_limb: few digits\n    // - base <= SQRT_MAX_LIMB\n    // - to_digits_asc_divide_and_conquer_limb: base <= SQRT_MAX_LIMB and x small\n    // - to_digits_asc_divide_and_conquer_limb: q != 0\n    // - to_digits_asc_divide_and_conquer_limb: zero padding\n    // - to_digits_asc_divide_and_conquer_limb: base <= SQRT_MAX_LIMB and x large\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1000,\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1001,\n        &[\n            1, 981, 189, 862, 839, 516, 706, 596, 767, 333, 404, 392, 677, 683, 644, 550, 825, 866,\n            188, 981,\n        ],\n    );\n    // - to_digits_asc_divide_and_conquer_limb: base > SQRT_MAX_LIMB\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        123456,\n        &[115456, 7508, 27948, 11540, 30637, 92024, 26412, 41276, 18791, 86861, 49669, 9848],\n    );\n    // - to_digits_asc_divide_and_conquer_limb: q == 0\n    test::<u32>(\n        \"958147186852538842877959980138243879940342867265688956449364129\",\n        9238,\n        &[\n            1297, 1928, 2066, 7131, 5213, 6502, 1707, 1758, 138, 6317, 2051, 6308, 402, 1611, 277,\n            3146,\n        ],\n    );\n}\n\nfn to_digits_asc_limb_fail_helper<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>()\nwhere\n    Limb: Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert_panic!(to_digits_asc_limb::<T>(&Natural::exact_from(10), 0));\n    assert_panic!(to_digits_asc_limb::<T>(&Natural::exact_from(10), 1));\n}\n\n#[test]\nfn to_digits_asc_limb_fail() {\n    apply_fn_to_unsigneds!(to_digits_asc_limb_fail_helper);\n\n    assert_panic!(to_digits_asc_limb::<u8>(&Natural::from(10u32), 1000));\n}\n\nfn to_digits_asc_limb_properties_helper<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>()\nwhere\n    Limb: Digits<T> + SaturatingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    natural_unsigned_pair_gen_var_1::<Limb, T>().test_properties_with_config(\n        &config,\n        |(x, base)| {\n            let digits = to_digits_asc_limb::<T>(&x, base);\n            let mut digits_alt = Vec::new();\n            to_digits_asc_naive_primitive(&mut digits_alt, &x, T::exact_from(base));\n            assert_eq!(digits, digits_alt);\n            assert_eq!(\n                to_digits_desc_limb::<T>(&x, base)\n                    .into_iter()\n                    .rev()\n                    .collect_vec(),\n                digits\n            );\n            if !digits.is_empty() {\n                assert_ne!(*digits.last().unwrap(), T::ZERO);\n            }\n        },\n    );\n}\n\n#[test]\nfn to_digits_asc_limb_properties() {\n    apply_fn_to_unsigneds!(to_digits_asc_limb_properties_helper);\n}\n\n#[test]\nfn test_to_digits_desc_limb() {\n    fn test<T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned>(\n        x: &str,\n        base: Limb,\n        out: &[T],\n    ) where\n        Limb: Digits<T>,\n        Natural: From<T> + PowerOf2Digits<T>,\n    {\n        let x = Natural::from_str(x).unwrap();\n        assert_eq!(to_digits_desc_limb::<T>(&x, base), out);\n    }\n    test::<u8>(\"0\", 10, &[]);\n    test::<u8>(\"0\", 16, &[]);\n    test::<u8>(\"123\", 10, &[1, 2, 3]);\n    test::<u8>(\"123\", 8, &[1, 7, 3]);\n    test::<u8>(\n        \"1473250819553359898729024041508\",\n        77,\n        &[74, 22, 10, 50, 57, 19, 15, 70, 15, 36, 13, 43, 10, 51, 55, 44],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1000,\n        &[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1001,\n        &[\n            981, 188, 866, 825, 550, 644, 683, 677, 392, 404, 333, 767, 596, 706, 516, 839, 862,\n            189, 981, 1,\n        ],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        123456,\n        &[9848, 49669, 86861, 18791, 41276, 26412, 92024, 30637, 11540, 27948, 7508, 115456],\n    );\n    test::<u32>(\n        \"958147186852538842877959980138243879940342867265688956449364129\",\n        9238,\n        &[\n            3146, 277, 1611, 402, 6308, 2051, 6317, 138, 1758, 1707, 6502, 5213, 7131, 2066, 1928,\n            1297,\n        ],\n    );\n}\n\nfn to_digits_desc_limb_fail_helper<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>()\nwhere\n    Limb: Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    assert_panic!(to_digits_desc_limb::<T>(&Natural::exact_from(10), 0));\n    assert_panic!(to_digits_desc_limb::<T>(&Natural::exact_from(10), 1));\n}\n\n#[test]\nfn to_digits_desc_limb_fail() {\n    apply_fn_to_unsigneds!(to_digits_desc_limb_fail_helper);\n\n    assert_panic!(to_digits_desc_limb::<u8>(&Natural::from(10u32), 1000));\n}\n\nfn to_digits_desc_limb_properties_helper<\n    T: for<'a> TryFrom<&'a Natural> + ConvertibleFrom<Limb> + PrimitiveUnsigned,\n>()\nwhere\n    Limb: Digits<T> + SaturatingFrom<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    natural_unsigned_pair_gen_var_1::<Limb, T>().test_properties_with_config(\n        &config,\n        |(x, base)| {\n            let digits = to_digits_desc_limb::<T>(&x, base);\n            assert_eq!(\n                to_digits_asc_limb::<T>(&x, base)\n                    .into_iter()\n                    .rev()\n                    .collect_vec(),\n                digits\n            );\n            if !digits.is_empty() {\n                assert_ne!(digits[0], T::ZERO);\n            }\n        },\n    );\n}\n\n#[test]\nfn to_digits_desc_limb_properties() {\n    apply_fn_to_unsigneds!(to_digits_desc_limb_properties_helper);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_to_digits_asc_large() {\n    fn test(x: &str, base: &str, out: &[&str]) {\n        let x = Natural::from_str(x).unwrap();\n        let base = Natural::from_str(base).unwrap();\n        let out = out\n            .iter()\n            .map(|s| Natural::from_str(s).unwrap())\n            .collect_vec();\n        assert_eq!(to_digits_asc_large(&x, &base), out);\n        let mut digits_alt = Vec::new();\n        to_digits_asc_naive(&mut digits_alt, &x, &base);\n        assert_eq!(digits_alt, out);\n    }\n    // - x >= base\n    // - base is not a power of 2\n    // - bits / base.significant_bits() < TO_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    test(\n        \"1000000000000\",\n        \"10\",\n        &[\"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\"],\n    );\n    // - base is a power of 2\n    test(\n        \"1000000000000\",\n        \"16\",\n        &[\"0\", \"0\", \"0\", \"1\", \"5\", \"10\", \"4\", \"13\", \"8\", \"14\"],\n    );\n    // - x < base\n    test(\"1000000000000\", \"1000000000000000\", &[\"1000000000000\"]);\n    // - bits / base.significant_bits() >= TO_DIGITS_DIVIDE_AND_CONQUER_THRESHOLD\n    // - q != 0\n    test(\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n        \"6\",\n        &[\n            \"4\", \"1\", \"3\", \"2\", \"3\", \"2\", \"1\", \"4\", \"2\", \"5\", \"3\", \"0\", \"5\", \"1\", \"5\", \"3\", \"5\",\n            \"2\", \"4\", \"5\", \"1\", \"3\", \"1\", \"5\", \"5\", \"1\", \"5\", \"4\", \"2\", \"1\", \"2\", \"2\", \"2\", \"1\",\n            \"2\", \"4\", \"3\", \"2\", \"3\", \"2\", \"5\", \"0\", \"4\", \"5\", \"5\", \"3\", \"4\", \"1\", \"1\", \"3\", \"3\",\n            \"4\", \"5\", \"0\", \"4\", \"5\", \"0\", \"4\", \"4\", \"2\", \"2\", \"5\", \"5\", \"2\", \"1\", \"5\", \"4\", \"0\",\n            \"3\", \"4\", \"1\", \"3\", \"5\", \"0\", \"1\", \"3\", \"0\", \"1\", \"1\", \"4\", \"4\", \"5\", \"1\", \"2\", \"0\",\n            \"5\", \"3\", \"0\", \"1\", \"1\", \"4\", \"5\", \"0\", \"3\", \"2\", \"5\", \"3\", \"5\", \"0\", \"5\", \"2\", \"0\",\n            \"0\", \"4\", \"1\", \"5\", \"3\", \"1\", \"4\", \"1\", \"5\", \"5\", \"1\", \"0\", \"2\", \"5\", \"3\", \"2\", \"1\",\n            \"2\", \"3\", \"2\", \"2\", \"3\", \"0\", \"2\", \"4\", \"4\", \"0\", \"1\", \"2\", \"0\", \"3\", \"3\", \"2\", \"2\",\n            \"5\", \"4\", \"5\", \"1\", \"2\", \"2\", \"5\", \"1\", \"5\", \"3\", \"0\", \"0\", \"2\", \"5\", \"3\", \"5\", \"2\",\n            \"0\", \"1\", \"0\", \"3\", \"4\", \"0\", \"1\", \"5\", \"4\", \"1\", \"1\", \"0\", \"1\", \"1\", \"3\", \"5\", \"3\",\n            \"2\", \"3\", \"0\", \"1\", \"3\", \"0\", \"5\", \"2\", \"3\", \"5\", \"3\", \"2\", \"5\", \"2\", \"5\", \"0\", \"2\",\n            \"3\", \"3\", \"1\", \"3\", \"3\", \"0\", \"0\", \"2\", \"3\", \"0\", \"3\", \"0\", \"5\", \"3\", \"0\", \"0\", \"4\",\n            \"1\", \"5\", \"1\", \"4\", \"4\", \"1\", \"5\", \"4\", \"0\", \"0\", \"4\", \"1\", \"2\", \"1\", \"3\", \"5\", \"1\",\n            \"5\", \"5\", \"0\", \"1\",\n        ],\n    );\n    // - pad with zeros\n    test(\n        \"14974892748479131847778931724116484851265511358392776602889616274416063303\",\n        \"3\",\n        &[\n            \"0\", \"2\", \"1\", \"1\", \"1\", \"2\", \"0\", \"2\", \"1\", \"2\", \"1\", \"1\", \"2\", \"0\", \"2\", \"2\", \"2\",\n            \"0\", \"0\", \"1\", \"0\", \"1\", \"1\", \"2\", \"1\", \"1\", \"0\", \"0\", \"2\", \"1\", \"0\", \"0\", \"0\", \"0\",\n            \"1\", \"2\", \"1\", \"0\", \"1\", \"0\", \"2\", \"1\", \"1\", \"1\", \"1\", \"1\", \"0\", \"0\", \"0\", \"0\", \"2\",\n            \"1\", \"1\", \"0\", \"2\", \"1\", \"1\", \"0\", \"2\", \"0\", \"0\", \"1\", \"2\", \"0\", \"2\", \"0\", \"0\", \"0\",\n            \"1\", \"2\", \"2\", \"0\", \"0\", \"2\", \"2\", \"2\", \"2\", \"1\", \"0\", \"2\", \"0\", \"0\", \"1\", \"1\", \"1\",\n            \"0\", \"1\", \"2\", \"2\", \"0\", \"2\", \"2\", \"2\", \"0\", \"2\", \"1\", \"1\", \"1\", \"1\", \"0\", \"1\", \"2\",\n            \"1\", \"1\", \"0\", \"2\", \"0\", \"1\", \"0\", \"1\", \"0\", \"1\", \"1\", \"2\", \"0\", \"2\", \"1\", \"2\", \"2\",\n            \"0\", \"1\", \"1\", \"1\", \"2\", \"0\", \"2\", \"0\", \"0\", \"2\", \"0\", \"0\", \"1\", \"1\", \"2\", \"2\", \"0\",\n            \"2\", \"1\", \"1\", \"2\", \"1\", \"1\", \"1\", \"1\", \"0\", \"1\", \"2\", \"0\", \"1\", \"1\", \"1\", \"1\", \"1\",\n            \"1\",\n        ],\n    );\n    // - q == 0\n    test(\n        \"643945257796761196320314690988316858252541574945689186182369731847117890385280572047834937\\\n        1883212246436232738680605124294949600205450044993253033167972343988333612737978764297848348\\\n        2665822115523011210267845467229157815194234251375826930137780574470438350033031660616757791\\\n        61\",\n        \"7\",\n        &[\n            \"4\", \"5\", \"1\", \"4\", \"5\", \"6\", \"0\", \"2\", \"4\", \"6\", \"2\", \"0\", \"1\", \"0\", \"3\", \"6\", \"4\",\n            \"3\", \"1\", \"4\", \"2\", \"6\", \"4\", \"4\", \"0\", \"2\", \"1\", \"0\", \"3\", \"3\", \"2\", \"0\", \"3\", \"5\",\n            \"4\", \"1\", \"3\", \"4\", \"4\", \"3\", \"5\", \"6\", \"4\", \"1\", \"6\", \"0\", \"2\", \"2\", \"5\", \"0\", \"5\",\n            \"0\", \"5\", \"4\", \"0\", \"5\", \"3\", \"5\", \"0\", \"0\", \"3\", \"6\", \"1\", \"5\", \"4\", \"4\", \"1\", \"2\",\n            \"1\", \"4\", \"2\", \"0\", \"0\", \"1\", \"4\", \"3\", \"2\", \"0\", \"3\", \"5\", \"2\", \"6\", \"5\", \"5\", \"0\",\n            \"2\", \"1\", \"6\", \"5\", \"2\", \"5\", \"0\", \"6\", \"6\", \"4\", \"3\", \"1\", \"6\", \"0\", \"6\", \"1\", \"3\",\n            \"1\", \"5\", \"4\", \"3\", \"0\", \"5\", \"2\", \"6\", \"5\", \"2\", \"0\", \"3\", \"3\", \"1\", \"3\", \"5\", \"3\",\n            \"1\", \"1\", \"3\", \"2\", \"0\", \"1\", \"5\", \"6\", \"0\", \"1\", \"6\", \"4\", \"4\", \"5\", \"4\", \"4\", \"2\",\n            \"0\", \"2\", \"5\", \"6\", \"4\", \"5\", \"2\", \"2\", \"4\", \"4\", \"0\", \"6\", \"5\", \"4\", \"2\", \"1\", \"6\",\n            \"0\", \"2\", \"0\", \"4\", \"2\", \"5\", \"6\", \"2\", \"5\", \"1\", \"5\", \"3\", \"3\", \"5\", \"1\", \"0\", \"2\",\n            \"5\", \"4\", \"1\", \"2\", \"6\", \"6\", \"2\", \"0\", \"6\", \"1\", \"1\", \"1\", \"4\", \"0\", \"1\", \"5\", \"4\",\n            \"0\", \"6\", \"6\", \"4\", \"6\", \"1\", \"3\", \"0\", \"3\", \"3\", \"4\", \"6\", \"2\", \"3\", \"5\", \"1\", \"4\",\n            \"4\", \"6\", \"3\", \"2\", \"4\", \"3\", \"0\", \"3\", \"2\", \"6\", \"2\", \"4\", \"3\", \"6\", \"6\", \"6\", \"6\",\n            \"4\", \"4\", \"3\", \"6\", \"6\", \"3\", \"3\", \"5\", \"5\", \"1\", \"0\", \"1\", \"0\", \"3\", \"6\", \"5\", \"3\",\n            \"2\", \"1\", \"3\", \"1\", \"3\", \"2\", \"4\", \"6\", \"1\", \"5\", \"6\", \"2\", \"6\", \"2\", \"5\", \"0\", \"6\",\n            \"0\", \"0\", \"3\", \"4\", \"0\", \"6\", \"3\", \"5\", \"2\", \"5\", \"5\", \"4\", \"1\", \"3\", \"4\", \"4\", \"2\",\n            \"2\", \"3\", \"1\", \"6\", \"2\", \"1\", \"4\", \"1\", \"5\", \"5\", \"6\", \"3\", \"6\", \"3\", \"6\", \"4\", \"4\",\n            \"5\", \"2\", \"3\", \"1\", \"6\", \"2\", \"1\", \"0\", \"0\", \"5\", \"0\", \"2\", \"5\", \"5\", \"4\", \"0\", \"5\",\n            \"6\", \"5\", \"2\", \"2\", \"0\", \"3\", \"6\", \"5\", \"2\", \"4\", \"6\", \"4\", \"3\", \"6\", \"4\", \"4\", \"6\",\n            \"6\",\n        ],\n    );\n    test(\"1000000000000\", \"10000000000\", &[\"0\", \"100\"]);\n    test(\n        \"10000000000000000000000000000000\",\n        \"34359738368\",\n        &[\"27917287424\", \"18657454436\", \"8470329472\"],\n    );\n    test(\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n        \"6000000000\",\n        &[\n            \"4373186134\",\n            \"2564485756\",\n            \"2124820161\",\n            \"4270626619\",\n            \"5254372654\",\n            \"713959034\",\n            \"4750044302\",\n            \"5833014701\",\n            \"978351288\",\n            \"4288991795\",\n            \"972424917\",\n            \"1439538405\",\n            \"5308114100\",\n            \"1115837958\",\n            \"2267585072\",\n            \"4579628351\",\n            \"3319271253\",\n            \"139021832\",\n        ],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_to_digits_desc_large() {\n    fn test(x: &str, base: &str, out: &[&str]) {\n        let x = Natural::from_str(x).unwrap();\n        let base = Natural::from_str(base).unwrap();\n        let out = out\n            .iter()\n            .map(|s| Natural::from_str(s).unwrap())\n            .collect_vec();\n        assert_eq!(to_digits_desc_large(&x, &base), out);\n    }\n    test(\n        \"1000000000000\",\n        \"10\",\n        &[\"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\"],\n    );\n    test(\n        \"1000000000000\",\n        \"16\",\n        &[\"14\", \"8\", \"13\", \"4\", \"10\", \"5\", \"1\", \"0\", \"0\", \"0\"],\n    );\n    test(\"1000000000000\", \"1000000000000000\", &[\"1000000000000\"]);\n    test(\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n        \"6\",\n        &[\n            \"1\", \"0\", \"5\", \"5\", \"1\", \"5\", \"3\", \"1\", \"2\", \"1\", \"4\", \"0\", \"0\", \"4\", \"5\", \"1\", \"4\",\n            \"4\", \"1\", \"5\", \"1\", \"4\", \"0\", \"0\", \"3\", \"5\", \"0\", \"3\", \"0\", \"3\", \"2\", \"0\", \"0\", \"3\",\n            \"3\", \"1\", \"3\", \"3\", \"2\", \"0\", \"5\", \"2\", \"5\", \"2\", \"3\", \"5\", \"3\", \"2\", \"5\", \"0\", \"3\",\n            \"1\", \"0\", \"3\", \"2\", \"3\", \"5\", \"3\", \"1\", \"1\", \"0\", \"1\", \"1\", \"4\", \"5\", \"1\", \"0\", \"4\",\n            \"3\", \"0\", \"1\", \"0\", \"2\", \"5\", \"3\", \"5\", \"2\", \"0\", \"0\", \"3\", \"5\", \"1\", \"5\", \"2\", \"2\",\n            \"1\", \"5\", \"4\", \"5\", \"2\", \"2\", \"3\", \"3\", \"0\", \"2\", \"1\", \"0\", \"4\", \"4\", \"2\", \"0\", \"3\",\n            \"2\", \"2\", \"3\", \"2\", \"1\", \"2\", \"3\", \"5\", \"2\", \"0\", \"1\", \"5\", \"5\", \"1\", \"4\", \"1\", \"3\",\n            \"5\", \"1\", \"4\", \"0\", \"0\", \"2\", \"5\", \"0\", \"5\", \"3\", \"5\", \"2\", \"3\", \"0\", \"5\", \"4\", \"1\",\n            \"1\", \"0\", \"3\", \"5\", \"0\", \"2\", \"1\", \"5\", \"4\", \"4\", \"1\", \"1\", \"0\", \"3\", \"1\", \"0\", \"5\",\n            \"3\", \"1\", \"4\", \"3\", \"0\", \"4\", \"5\", \"1\", \"2\", \"5\", \"5\", \"2\", \"2\", \"4\", \"4\", \"0\", \"5\",\n            \"4\", \"0\", \"5\", \"4\", \"3\", \"3\", \"1\", \"1\", \"4\", \"3\", \"5\", \"5\", \"4\", \"0\", \"5\", \"2\", \"3\",\n            \"2\", \"3\", \"4\", \"2\", \"1\", \"2\", \"2\", \"2\", \"1\", \"2\", \"4\", \"5\", \"1\", \"5\", \"5\", \"1\", \"3\",\n            \"1\", \"5\", \"4\", \"2\", \"5\", \"3\", \"5\", \"1\", \"5\", \"0\", \"3\", \"5\", \"2\", \"4\", \"1\", \"2\", \"3\",\n            \"2\", \"3\", \"1\", \"4\",\n        ],\n    );\n    test(\n        \"14974892748479131847778931724116484851265511358392776602889616274416063303\",\n        \"3\",\n        &[\n            \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"0\", \"2\", \"1\", \"0\", \"1\", \"1\", \"1\", \"1\", \"2\", \"1\", \"1\",\n            \"2\", \"0\", \"2\", \"2\", \"1\", \"1\", \"0\", \"0\", \"2\", \"0\", \"0\", \"2\", \"0\", \"2\", \"1\", \"1\", \"1\",\n            \"0\", \"2\", \"2\", \"1\", \"2\", \"0\", \"2\", \"1\", \"1\", \"0\", \"1\", \"0\", \"1\", \"0\", \"2\", \"0\", \"1\",\n            \"1\", \"2\", \"1\", \"0\", \"1\", \"1\", \"1\", \"1\", \"2\", \"0\", \"2\", \"2\", \"2\", \"0\", \"2\", \"2\", \"1\",\n            \"0\", \"1\", \"1\", \"1\", \"0\", \"0\", \"2\", \"0\", \"1\", \"2\", \"2\", \"2\", \"2\", \"0\", \"0\", \"2\", \"2\",\n            \"1\", \"0\", \"0\", \"0\", \"2\", \"0\", \"2\", \"1\", \"0\", \"0\", \"2\", \"0\", \"1\", \"1\", \"2\", \"0\", \"1\",\n            \"1\", \"2\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"1\", \"1\", \"1\", \"2\", \"0\", \"1\", \"0\", \"1\", \"2\",\n            \"1\", \"0\", \"0\", \"0\", \"0\", \"1\", \"2\", \"0\", \"0\", \"1\", \"1\", \"2\", \"1\", \"1\", \"0\", \"1\", \"0\",\n            \"0\", \"2\", \"2\", \"2\", \"0\", \"2\", \"1\", \"1\", \"2\", \"1\", \"2\", \"0\", \"2\", \"1\", \"1\", \"1\", \"2\",\n            \"0\",\n        ],\n    );\n    test(\n        \"643945257796761196320314690988316858252541574945689186182369731847117890385280572047834937\\\n        1883212246436232738680605124294949600205450044993253033167972343988333612737978764297848348\\\n        2665822115523011210267845467229157815194234251375826930137780574470438350033031660616757791\\\n        61\",\n        \"7\",\n        &[\n            \"6\", \"6\", \"4\", \"4\", \"6\", \"3\", \"4\", \"6\", \"4\", \"2\", \"5\", \"6\", \"3\", \"0\", \"2\", \"2\", \"5\",\n            \"6\", \"5\", \"0\", \"4\", \"5\", \"5\", \"2\", \"0\", \"5\", \"0\", \"0\", \"1\", \"2\", \"6\", \"1\", \"3\", \"2\",\n            \"5\", \"4\", \"4\", \"6\", \"3\", \"6\", \"3\", \"6\", \"5\", \"5\", \"1\", \"4\", \"1\", \"2\", \"6\", \"1\", \"3\",\n            \"2\", \"2\", \"4\", \"4\", \"3\", \"1\", \"4\", \"5\", \"5\", \"2\", \"5\", \"3\", \"6\", \"0\", \"4\", \"3\", \"0\",\n            \"0\", \"6\", \"0\", \"5\", \"2\", \"6\", \"2\", \"6\", \"5\", \"1\", \"6\", \"4\", \"2\", \"3\", \"1\", \"3\", \"1\",\n            \"2\", \"3\", \"5\", \"6\", \"3\", \"0\", \"1\", \"0\", \"1\", \"5\", \"5\", \"3\", \"3\", \"6\", \"6\", \"3\", \"4\",\n            \"4\", \"6\", \"6\", \"6\", \"6\", \"3\", \"4\", \"2\", \"6\", \"2\", \"3\", \"0\", \"3\", \"4\", \"2\", \"3\", \"6\",\n            \"4\", \"4\", \"1\", \"5\", \"3\", \"2\", \"6\", \"4\", \"3\", \"3\", \"0\", \"3\", \"1\", \"6\", \"4\", \"6\", \"6\",\n            \"0\", \"4\", \"5\", \"1\", \"0\", \"4\", \"1\", \"1\", \"1\", \"6\", \"0\", \"2\", \"6\", \"6\", \"2\", \"1\", \"4\",\n            \"5\", \"2\", \"0\", \"1\", \"5\", \"3\", \"3\", \"5\", \"1\", \"5\", \"2\", \"6\", \"5\", \"2\", \"4\", \"0\", \"2\",\n            \"0\", \"6\", \"1\", \"2\", \"4\", \"5\", \"6\", \"0\", \"4\", \"4\", \"2\", \"2\", \"5\", \"4\", \"6\", \"5\", \"2\",\n            \"0\", \"2\", \"4\", \"4\", \"5\", \"4\", \"4\", \"6\", \"1\", \"0\", \"6\", \"5\", \"1\", \"0\", \"2\", \"3\", \"1\",\n            \"1\", \"3\", \"5\", \"3\", \"1\", \"3\", \"3\", \"0\", \"2\", \"5\", \"6\", \"2\", \"5\", \"0\", \"3\", \"4\", \"5\",\n            \"1\", \"3\", \"1\", \"6\", \"0\", \"6\", \"1\", \"3\", \"4\", \"6\", \"6\", \"0\", \"5\", \"2\", \"5\", \"6\", \"1\",\n            \"2\", \"0\", \"5\", \"5\", \"6\", \"2\", \"5\", \"3\", \"0\", \"2\", \"3\", \"4\", \"1\", \"0\", \"0\", \"2\", \"4\",\n            \"1\", \"2\", \"1\", \"4\", \"4\", \"5\", \"1\", \"6\", \"3\", \"0\", \"0\", \"5\", \"3\", \"5\", \"0\", \"4\", \"5\",\n            \"0\", \"5\", \"0\", \"5\", \"2\", \"2\", \"0\", \"6\", \"1\", \"4\", \"6\", \"5\", \"3\", \"4\", \"4\", \"3\", \"1\",\n            \"4\", \"5\", \"3\", \"0\", \"2\", \"3\", \"3\", \"0\", \"1\", \"2\", \"0\", \"4\", \"4\", \"6\", \"2\", \"4\", \"1\",\n            \"3\", \"4\", \"6\", \"3\", \"0\", \"1\", \"0\", \"2\", \"6\", \"4\", \"2\", \"0\", \"6\", \"5\", \"4\", \"1\", \"5\",\n            \"4\",\n        ],\n    );\n    test(\"1000000000000\", \"10000000000\", &[\"100\", \"0\"]);\n    test(\n        \"10000000000000000000000000000000\",\n        \"34359738368\",\n        &[\"8470329472\", \"18657454436\", \"27917287424\"],\n    );\n    test(\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n        \"6000000000\",\n        &[\n            \"139021832\",\n            \"3319271253\",\n            \"4579628351\",\n            \"2267585072\",\n            \"1115837958\",\n            \"5308114100\",\n            \"1439538405\",\n            \"972424917\",\n            \"4288991795\",\n            \"978351288\",\n            \"5833014701\",\n            \"4750044302\",\n            \"713959034\",\n            \"5254372654\",\n            \"4270626619\",\n            \"2124820161\",\n            \"2564485756\",\n            \"4373186134\",\n        ],\n    );\n}\n\n#[test]\nfn to_digits_asc_large_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    natural_pair_gen_var_1().test_properties_with_config(&config, |(x, base)| {\n        let digits = to_digits_asc_large(&x, &base);\n        let mut digits_alt = Vec::new();\n        to_digits_asc_naive(&mut digits_alt, &x, &base);\n        assert_eq!(digits, digits_alt);\n        assert_eq!(\n            to_digits_desc_large(&x, &base)\n                .into_iter()\n                .rev()\n                .collect_vec(),\n            digits\n        );\n        if !digits.is_empty() {\n            assert_ne!(*digits.last().unwrap(), 0);\n        }\n    });\n}\n\n#[test]\nfn to_digits_desc_large_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    natural_pair_gen_var_1().test_properties_with_config(&config, |(x, base)| {\n        let digits = to_digits_desc_large(&x, &base);\n        assert_eq!(\n            to_digits_asc_large(&x, &base)\n                .into_iter()\n                .rev()\n                .collect_vec(),\n            digits\n        );\n        if !digits.is_empty() {\n            assert_ne!(digits[0], 0);\n        }\n    });\n}\n\n#[test]\nfn test_to_digits_asc_unsigned() {\n    fn test<T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned>(x: &str, base: T, out: &[T])\n    where\n        Natural: Digits<T> + From<T>,\n    {\n        let x = Natural::from_str(x).unwrap();\n        assert_eq!(x.to_digits_asc(&base), out);\n        let mut digits_alt = Vec::new();\n        to_digits_asc_naive_primitive(&mut digits_alt, &x, base);\n        assert_eq!(digits_alt, out);\n    }\n    test::<u8>(\"0\", 10, &[]);\n    test::<u8>(\"0\", 16, &[]);\n    test::<u8>(\"123\", 10, &[3, 2, 1]);\n    test::<u8>(\"123\", 8, &[3, 7, 1]);\n    test::<u8>(\n        \"1473250819553359898729024041508\",\n        77,\n        &[44, 55, 51, 10, 43, 13, 36, 15, 70, 15, 19, 57, 50, 10, 22, 74],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1000,\n        &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1001,\n        &[\n            1, 981, 189, 862, 839, 516, 706, 596, 767, 333, 404, 392, 677, 683, 644, 550, 825, 866,\n            188, 981,\n        ],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        123456,\n        &[115456, 7508, 27948, 11540, 30637, 92024, 26412, 41276, 18791, 86861, 49669, 9848],\n    );\n    test::<u32>(\n        \"958147186852538842877959980138243879940342867265688956449364129\",\n        9238,\n        &[\n            1297, 1928, 2066, 7131, 5213, 6502, 1707, 1758, 138, 6317, 2051, 6308, 402, 1611, 277,\n            3146,\n        ],\n    );\n}\n\nfn to_digits_asc_unsigned_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: Digits<T>,\n{\n    assert_panic!(Natural::from(10u32).to_digits_asc(&T::ZERO));\n    assert_panic!(Natural::from(10u32).to_digits_asc(&T::ONE));\n}\n\n#[test]\nfn to_digits_asc_unsigned_fail() {\n    apply_fn_to_unsigneds!(to_digits_asc_unsigned_fail_helper);\n}\n\nfn to_digits_asc_properties_helper<T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned>()\nwhere\n    Limb: Digits<T>,\n    Natural: Digits<T> + From<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    natural_unsigned_pair_gen_var_2::<T>().test_properties_with_config(&config, |(x, base)| {\n        let digits = x.to_digits_asc(&base);\n        let mut digits_alt = Vec::new();\n        to_digits_asc_naive_primitive(&mut digits_alt, &x, base);\n        assert_eq!(digits_alt, digits);\n        if x != 0 {\n            assert_ne!(*digits.last().unwrap(), T::ZERO);\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                x.floor_log_base(&Natural::from(base)) + 1\n            );\n        }\n        assert_eq!(\n            digits.iter().copied().rev().collect_vec(),\n            x.to_digits_desc(&base)\n        );\n        assert!(digits.iter().all(|&digit| digit < base));\n        assert_eq!(\n            Natural::from_digits_asc(&base, digits.iter().copied()).unwrap(),\n            x\n        );\n\n        let digits_alt = Digits::<Natural>::to_digits_asc(&x, &Natural::from(base));\n        assert_eq!(\n            digits_alt\n                .into_iter()\n                .map(|n| T::exact_from(&n))\n                .collect_vec(),\n            digits\n        );\n    });\n\n    natural_gen().test_properties_with_config(&config, |x| {\n        assert_eq!(\n            x.to_digits_asc(&T::TWO)\n                .into_iter()\n                .map(|digit| digit == T::ONE)\n                .collect_vec(),\n            x.to_bits_asc()\n        );\n    });\n\n    unsigned_gen_var_6().test_properties_with_config(&config, |base| {\n        assert!(Natural::ZERO.to_digits_asc(&base).is_empty());\n    });\n\n    unsigned_pair_gen_var_6::<Limb, T>().test_properties(|(u, base)| {\n        let x: Natural = From::from(u);\n        assert_eq!(u.to_digits_asc(&base), x.to_digits_asc(&base));\n    });\n}\n\n#[test]\nfn to_digits_asc_properties() {\n    apply_fn_to_unsigneds!(to_digits_asc_properties_helper);\n}\n\n#[test]\nfn test_to_digits_desc_unsigned() {\n    fn test<T: PrimitiveUnsigned>(x: &str, base: T, out: &[T])\n    where\n        Natural: Digits<T>,\n    {\n        let x = Natural::from_str(x).unwrap();\n        assert_eq!(x.to_digits_desc(&base), out);\n    }\n    test::<u8>(\"0\", 10, &[]);\n    test::<u8>(\"0\", 16, &[]);\n    test::<u8>(\"123\", 10, &[1, 2, 3]);\n    test::<u8>(\"123\", 8, &[1, 7, 3]);\n    test::<u8>(\n        \"1473250819553359898729024041508\",\n        77,\n        &[74, 22, 10, 50, 57, 19, 15, 70, 15, 36, 13, 43, 10, 51, 55, 44],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1000,\n        &[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        1001,\n        &[\n            981, 188, 866, 825, 550, 644, 683, 677, 392, 404, 333, 767, 596, 706, 516, 839, 862,\n            189, 981, 1,\n        ],\n    );\n    test::<u32>(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        123456,\n        &[9848, 49669, 86861, 18791, 41276, 26412, 92024, 30637, 11540, 27948, 7508, 115456],\n    );\n    test::<u32>(\n        \"958147186852538842877959980138243879940342867265688956449364129\",\n        9238,\n        &[\n            3146, 277, 1611, 402, 6308, 2051, 6317, 138, 1758, 1707, 6502, 5213, 7131, 2066, 1928,\n            1297,\n        ],\n    );\n}\n\nfn to_digits_desc_unsigned_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: Digits<T>,\n{\n    assert_panic!(Natural::from(10u32).to_digits_desc(&T::ZERO));\n    assert_panic!(Natural::from(10u32).to_digits_desc(&T::ONE));\n}\n\n#[test]\nfn to_digits_desc_unsigned_fail() {\n    apply_fn_to_unsigneds!(to_digits_desc_unsigned_fail_helper);\n}\n\nfn to_digits_desc_properties_helper<T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned>()\nwhere\n    Limb: Digits<T>,\n    Natural: Digits<T> + From<T>,\n{\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    natural_unsigned_pair_gen_var_2::<T>().test_properties_with_config(&config, |(x, base)| {\n        let digits = x.to_digits_desc(&base);\n        if x != 0 {\n            assert_ne!(digits[0], T::ZERO);\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                x.floor_log_base(&Natural::from(base)) + 1\n            );\n        }\n        assert_eq!(\n            digits.iter().copied().rev().collect_vec(),\n            x.to_digits_asc(&base)\n        );\n        assert!(digits.iter().all(|&digit| digit < base));\n        assert_eq!(\n            Natural::from_digits_desc(&base, digits.iter().copied()).unwrap(),\n            x\n        );\n\n        let digits_alt = Digits::<Natural>::to_digits_desc(&x, &Natural::from(base));\n        assert_eq!(\n            digits_alt\n                .into_iter()\n                .map(|n| T::exact_from(&n))\n                .collect_vec(),\n            digits\n        );\n    });\n\n    natural_gen().test_properties_with_config(&config, |x| {\n        assert_eq!(\n            x.to_digits_desc(&T::TWO)\n                .into_iter()\n                .map(|digit| digit == T::ONE)\n                .collect_vec(),\n            x.to_bits_desc()\n        );\n    });\n\n    unsigned_gen_var_6().test_properties_with_config(&config, |base| {\n        assert!(Natural::ZERO.to_digits_desc(&base).is_empty());\n    });\n\n    unsigned_pair_gen_var_6::<Limb, T>().test_properties(|(u, base)| {\n        let x: Natural = From::from(u);\n        assert_eq!(u.to_digits_desc(&base), x.to_digits_desc(&base));\n    });\n}\n\n#[test]\nfn to_digits_desc_properties() {\n    apply_fn_to_unsigneds!(to_digits_desc_properties_helper);\n}\n\n#[test]\nfn test_to_digits_asc_natural() {\n    fn test(x: &str, base: &str, out: &[&str]) {\n        let x = Natural::from_str(x).unwrap();\n        let base = Natural::from_str(base).unwrap();\n        let out = out\n            .iter()\n            .map(|s| Natural::from_str(s).unwrap())\n            .collect_vec();\n        assert_eq!(x.to_digits_asc(&base), out);\n        let mut digits_alt = Vec::new();\n        to_digits_asc_naive(&mut digits_alt, &x, &base);\n        assert_eq!(digits_alt, out);\n    }\n    test(\"0\", \"10\", &[]);\n    test(\"0\", \"16\", &[]);\n    test(\"123\", \"10\", &[\"3\", \"2\", \"1\"]);\n    test(\"123\", \"8\", &[\"3\", \"7\", \"1\"]);\n    test(\n        \"1473250819553359898729024041508\",\n        \"77\",\n        &[\n            \"44\", \"55\", \"51\", \"10\", \"43\", \"13\", \"36\", \"15\", \"70\", \"15\", \"19\", \"57\", \"50\", \"10\",\n            \"22\", \"74\",\n        ],\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"1000\",\n        &[\n            \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\",\n            \"0\", \"0\", \"0\", \"1\",\n        ],\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"1001\",\n        &[\n            \"1\", \"981\", \"189\", \"862\", \"839\", \"516\", \"706\", \"596\", \"767\", \"333\", \"404\", \"392\",\n            \"677\", \"683\", \"644\", \"550\", \"825\", \"866\", \"188\", \"981\",\n        ],\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"123456\",\n        &[\n            \"115456\", \"7508\", \"27948\", \"11540\", \"30637\", \"92024\", \"26412\", \"41276\", \"18791\",\n            \"86861\", \"49669\", \"9848\",\n        ],\n    );\n    test(\n        \"958147186852538842877959980138243879940342867265688956449364129\",\n        \"9238\",\n        &[\n            \"1297\", \"1928\", \"2066\", \"7131\", \"5213\", \"6502\", \"1707\", \"1758\", \"138\", \"6317\", \"2051\",\n            \"6308\", \"402\", \"1611\", \"277\", \"3146\",\n        ],\n    );\n    test(\n        \"1000000000000\",\n        \"10\",\n        &[\"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\"],\n    );\n    test(\n        \"1000000000000\",\n        \"16\",\n        &[\"0\", \"0\", \"0\", \"1\", \"5\", \"10\", \"4\", \"13\", \"8\", \"14\"],\n    );\n    test(\"1000000000000\", \"1000000000000000\", &[\"1000000000000\"]);\n    test(\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n        \"6\",\n        &[\n            \"4\", \"1\", \"3\", \"2\", \"3\", \"2\", \"1\", \"4\", \"2\", \"5\", \"3\", \"0\", \"5\", \"1\", \"5\", \"3\", \"5\",\n            \"2\", \"4\", \"5\", \"1\", \"3\", \"1\", \"5\", \"5\", \"1\", \"5\", \"4\", \"2\", \"1\", \"2\", \"2\", \"2\", \"1\",\n            \"2\", \"4\", \"3\", \"2\", \"3\", \"2\", \"5\", \"0\", \"4\", \"5\", \"5\", \"3\", \"4\", \"1\", \"1\", \"3\", \"3\",\n            \"4\", \"5\", \"0\", \"4\", \"5\", \"0\", \"4\", \"4\", \"2\", \"2\", \"5\", \"5\", \"2\", \"1\", \"5\", \"4\", \"0\",\n            \"3\", \"4\", \"1\", \"3\", \"5\", \"0\", \"1\", \"3\", \"0\", \"1\", \"1\", \"4\", \"4\", \"5\", \"1\", \"2\", \"0\",\n            \"5\", \"3\", \"0\", \"1\", \"1\", \"4\", \"5\", \"0\", \"3\", \"2\", \"5\", \"3\", \"5\", \"0\", \"5\", \"2\", \"0\",\n            \"0\", \"4\", \"1\", \"5\", \"3\", \"1\", \"4\", \"1\", \"5\", \"5\", \"1\", \"0\", \"2\", \"5\", \"3\", \"2\", \"1\",\n            \"2\", \"3\", \"2\", \"2\", \"3\", \"0\", \"2\", \"4\", \"4\", \"0\", \"1\", \"2\", \"0\", \"3\", \"3\", \"2\", \"2\",\n            \"5\", \"4\", \"5\", \"1\", \"2\", \"2\", \"5\", \"1\", \"5\", \"3\", \"0\", \"0\", \"2\", \"5\", \"3\", \"5\", \"2\",\n            \"0\", \"1\", \"0\", \"3\", \"4\", \"0\", \"1\", \"5\", \"4\", \"1\", \"1\", \"0\", \"1\", \"1\", \"3\", \"5\", \"3\",\n            \"2\", \"3\", \"0\", \"1\", \"3\", \"0\", \"5\", \"2\", \"3\", \"5\", \"3\", \"2\", \"5\", \"2\", \"5\", \"0\", \"2\",\n            \"3\", \"3\", \"1\", \"3\", \"3\", \"0\", \"0\", \"2\", \"3\", \"0\", \"3\", \"0\", \"5\", \"3\", \"0\", \"0\", \"4\",\n            \"1\", \"5\", \"1\", \"4\", \"4\", \"1\", \"5\", \"4\", \"0\", \"0\", \"4\", \"1\", \"2\", \"1\", \"3\", \"5\", \"1\",\n            \"5\", \"5\", \"0\", \"1\",\n        ],\n    );\n    test(\n        \"14974892748479131847778931724116484851265511358392776602889616274416063303\",\n        \"3\",\n        &[\n            \"0\", \"2\", \"1\", \"1\", \"1\", \"2\", \"0\", \"2\", \"1\", \"2\", \"1\", \"1\", \"2\", \"0\", \"2\", \"2\", \"2\",\n            \"0\", \"0\", \"1\", \"0\", \"1\", \"1\", \"2\", \"1\", \"1\", \"0\", \"0\", \"2\", \"1\", \"0\", \"0\", \"0\", \"0\",\n            \"1\", \"2\", \"1\", \"0\", \"1\", \"0\", \"2\", \"1\", \"1\", \"1\", \"1\", \"1\", \"0\", \"0\", \"0\", \"0\", \"2\",\n            \"1\", \"1\", \"0\", \"2\", \"1\", \"1\", \"0\", \"2\", \"0\", \"0\", \"1\", \"2\", \"0\", \"2\", \"0\", \"0\", \"0\",\n            \"1\", \"2\", \"2\", \"0\", \"0\", \"2\", \"2\", \"2\", \"2\", \"1\", \"0\", \"2\", \"0\", \"0\", \"1\", \"1\", \"1\",\n            \"0\", \"1\", \"2\", \"2\", \"0\", \"2\", \"2\", \"2\", \"0\", \"2\", \"1\", \"1\", \"1\", \"1\", \"0\", \"1\", \"2\",\n            \"1\", \"1\", \"0\", \"2\", \"0\", \"1\", \"0\", \"1\", \"0\", \"1\", \"1\", \"2\", \"0\", \"2\", \"1\", \"2\", \"2\",\n            \"0\", \"1\", \"1\", \"1\", \"2\", \"0\", \"2\", \"0\", \"0\", \"2\", \"0\", \"0\", \"1\", \"1\", \"2\", \"2\", \"0\",\n            \"2\", \"1\", \"1\", \"2\", \"1\", \"1\", \"1\", \"1\", \"0\", \"1\", \"2\", \"0\", \"1\", \"1\", \"1\", \"1\", \"1\",\n            \"1\",\n        ],\n    );\n    test(\n        \"643945257796761196320314690988316858252541574945689186182369731847117890385280572047834937\\\n        1883212246436232738680605124294949600205450044993253033167972343988333612737978764297848348\\\n        2665822115523011210267845467229157815194234251375826930137780574470438350033031660616757791\\\n        61\",\n        \"7\",\n        &[\n            \"4\", \"5\", \"1\", \"4\", \"5\", \"6\", \"0\", \"2\", \"4\", \"6\", \"2\", \"0\", \"1\", \"0\", \"3\", \"6\", \"4\",\n            \"3\", \"1\", \"4\", \"2\", \"6\", \"4\", \"4\", \"0\", \"2\", \"1\", \"0\", \"3\", \"3\", \"2\", \"0\", \"3\", \"5\",\n            \"4\", \"1\", \"3\", \"4\", \"4\", \"3\", \"5\", \"6\", \"4\", \"1\", \"6\", \"0\", \"2\", \"2\", \"5\", \"0\", \"5\",\n            \"0\", \"5\", \"4\", \"0\", \"5\", \"3\", \"5\", \"0\", \"0\", \"3\", \"6\", \"1\", \"5\", \"4\", \"4\", \"1\", \"2\",\n            \"1\", \"4\", \"2\", \"0\", \"0\", \"1\", \"4\", \"3\", \"2\", \"0\", \"3\", \"5\", \"2\", \"6\", \"5\", \"5\", \"0\",\n            \"2\", \"1\", \"6\", \"5\", \"2\", \"5\", \"0\", \"6\", \"6\", \"4\", \"3\", \"1\", \"6\", \"0\", \"6\", \"1\", \"3\",\n            \"1\", \"5\", \"4\", \"3\", \"0\", \"5\", \"2\", \"6\", \"5\", \"2\", \"0\", \"3\", \"3\", \"1\", \"3\", \"5\", \"3\",\n            \"1\", \"1\", \"3\", \"2\", \"0\", \"1\", \"5\", \"6\", \"0\", \"1\", \"6\", \"4\", \"4\", \"5\", \"4\", \"4\", \"2\",\n            \"0\", \"2\", \"5\", \"6\", \"4\", \"5\", \"2\", \"2\", \"4\", \"4\", \"0\", \"6\", \"5\", \"4\", \"2\", \"1\", \"6\",\n            \"0\", \"2\", \"0\", \"4\", \"2\", \"5\", \"6\", \"2\", \"5\", \"1\", \"5\", \"3\", \"3\", \"5\", \"1\", \"0\", \"2\",\n            \"5\", \"4\", \"1\", \"2\", \"6\", \"6\", \"2\", \"0\", \"6\", \"1\", \"1\", \"1\", \"4\", \"0\", \"1\", \"5\", \"4\",\n            \"0\", \"6\", \"6\", \"4\", \"6\", \"1\", \"3\", \"0\", \"3\", \"3\", \"4\", \"6\", \"2\", \"3\", \"5\", \"1\", \"4\",\n            \"4\", \"6\", \"3\", \"2\", \"4\", \"3\", \"0\", \"3\", \"2\", \"6\", \"2\", \"4\", \"3\", \"6\", \"6\", \"6\", \"6\",\n            \"4\", \"4\", \"3\", \"6\", \"6\", \"3\", \"3\", \"5\", \"5\", \"1\", \"0\", \"1\", \"0\", \"3\", \"6\", \"5\", \"3\",\n            \"2\", \"1\", \"3\", \"1\", \"3\", \"2\", \"4\", \"6\", \"1\", \"5\", \"6\", \"2\", \"6\", \"2\", \"5\", \"0\", \"6\",\n            \"0\", \"0\", \"3\", \"4\", \"0\", \"6\", \"3\", \"5\", \"2\", \"5\", \"5\", \"4\", \"1\", \"3\", \"4\", \"4\", \"2\",\n            \"2\", \"3\", \"1\", \"6\", \"2\", \"1\", \"4\", \"1\", \"5\", \"5\", \"6\", \"3\", \"6\", \"3\", \"6\", \"4\", \"4\",\n            \"5\", \"2\", \"3\", \"1\", \"6\", \"2\", \"1\", \"0\", \"0\", \"5\", \"0\", \"2\", \"5\", \"5\", \"4\", \"0\", \"5\",\n            \"6\", \"5\", \"2\", \"2\", \"0\", \"3\", \"6\", \"5\", \"2\", \"4\", \"6\", \"4\", \"3\", \"6\", \"4\", \"4\", \"6\",\n            \"6\",\n        ],\n    );\n}\n\n#[test]\nfn to_digits_asc_natural_fail() {\n    assert_panic!(Natural::from(10u32).to_digits_asc(&Natural::ZERO));\n    assert_panic!(Natural::from(10u32).to_digits_asc(&Natural::ONE));\n}\n\n#[test]\nfn to_digits_asc_natural_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    natural_pair_gen_var_2().test_properties_with_config(&config, |(x, base)| {\n        let digits = x.to_digits_asc(&base);\n        let mut digits_alt = Vec::new();\n        to_digits_asc_naive(&mut digits_alt, &x, &base);\n        assert_eq!(digits_alt, digits);\n        if x != 0 {\n            assert_ne!(*digits.last().unwrap(), 0);\n            assert_eq!(u64::exact_from(digits.len()), x.floor_log_base(&base) + 1);\n        }\n        assert_eq!(\n            digits.iter().cloned().rev().collect_vec(),\n            x.to_digits_desc(&base)\n        );\n        assert!(digits.iter().all(|digit| *digit < base));\n        assert_eq!(\n            Natural::from_digits_asc(&base, digits.into_iter()).unwrap(),\n            x\n        );\n    });\n\n    natural_gen().test_properties_with_config(&config, |x| {\n        assert_eq!(\n            x.to_digits_asc(&Natural::TWO)\n                .into_iter()\n                .map(|digit| digit == 1)\n                .collect_vec(),\n            x.to_bits_asc()\n        );\n    });\n\n    natural_gen_var_1().test_properties_with_config(&config, |base| {\n        assert!(Natural::ZERO.to_digits_asc(&base).is_empty());\n    });\n}\n\n#[test]\nfn test_to_digits_desc_natural() {\n    fn test(x: &str, base: &str, out: &[&str]) {\n        let x = Natural::from_str(x).unwrap();\n        let base = Natural::from_str(base).unwrap();\n        let out = out\n            .iter()\n            .map(|s| Natural::from_str(s).unwrap())\n            .collect_vec();\n        assert_eq!(x.to_digits_desc(&base), out);\n    }\n    test(\"0\", \"10\", &[]);\n    test(\"0\", \"16\", &[]);\n    test(\"123\", \"10\", &[\"1\", \"2\", \"3\"]);\n    test(\"123\", \"8\", &[\"1\", \"7\", \"3\"]);\n    test(\n        \"1473250819553359898729024041508\",\n        \"77\",\n        &[\n            \"74\", \"22\", \"10\", \"50\", \"57\", \"19\", \"15\", \"70\", \"15\", \"36\", \"13\", \"43\", \"10\", \"51\",\n            \"55\", \"44\",\n        ],\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"1000\",\n        &[\n            \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\",\n            \"0\", \"0\", \"0\", \"0\",\n        ],\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"1001\",\n        &[\n            \"981\", \"188\", \"866\", \"825\", \"550\", \"644\", \"683\", \"677\", \"392\", \"404\", \"333\", \"767\",\n            \"596\", \"706\", \"516\", \"839\", \"862\", \"189\", \"981\", \"1\",\n        ],\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"123456\",\n        &[\n            \"9848\", \"49669\", \"86861\", \"18791\", \"41276\", \"26412\", \"92024\", \"30637\", \"11540\",\n            \"27948\", \"7508\", \"115456\",\n        ],\n    );\n    test(\n        \"958147186852538842877959980138243879940342867265688956449364129\",\n        \"9238\",\n        &[\n            \"3146\", \"277\", \"1611\", \"402\", \"6308\", \"2051\", \"6317\", \"138\", \"1758\", \"1707\", \"6502\",\n            \"5213\", \"7131\", \"2066\", \"1928\", \"1297\",\n        ],\n    );\n    test(\n        \"1000000000000\",\n        \"10\",\n        &[\"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\"],\n    );\n    test(\n        \"1000000000000\",\n        \"16\",\n        &[\"14\", \"8\", \"13\", \"4\", \"10\", \"5\", \"1\", \"0\", \"0\", \"0\"],\n    );\n    test(\"1000000000000\", \"1000000000000000\", &[\"1000000000000\"]);\n    test(\n        \"235317521501133049587746364812444472287442159306443086833887479789539173449622133054745814\\\n        7574478578278803560754066959663745455193666960506455349780493525811386914540373186134\",\n        \"6\",\n        &[\n            \"1\", \"0\", \"5\", \"5\", \"1\", \"5\", \"3\", \"1\", \"2\", \"1\", \"4\", \"0\", \"0\", \"4\", \"5\", \"1\", \"4\",\n            \"4\", \"1\", \"5\", \"1\", \"4\", \"0\", \"0\", \"3\", \"5\", \"0\", \"3\", \"0\", \"3\", \"2\", \"0\", \"0\", \"3\",\n            \"3\", \"1\", \"3\", \"3\", \"2\", \"0\", \"5\", \"2\", \"5\", \"2\", \"3\", \"5\", \"3\", \"2\", \"5\", \"0\", \"3\",\n            \"1\", \"0\", \"3\", \"2\", \"3\", \"5\", \"3\", \"1\", \"1\", \"0\", \"1\", \"1\", \"4\", \"5\", \"1\", \"0\", \"4\",\n            \"3\", \"0\", \"1\", \"0\", \"2\", \"5\", \"3\", \"5\", \"2\", \"0\", \"0\", \"3\", \"5\", \"1\", \"5\", \"2\", \"2\",\n            \"1\", \"5\", \"4\", \"5\", \"2\", \"2\", \"3\", \"3\", \"0\", \"2\", \"1\", \"0\", \"4\", \"4\", \"2\", \"0\", \"3\",\n            \"2\", \"2\", \"3\", \"2\", \"1\", \"2\", \"3\", \"5\", \"2\", \"0\", \"1\", \"5\", \"5\", \"1\", \"4\", \"1\", \"3\",\n            \"5\", \"1\", \"4\", \"0\", \"0\", \"2\", \"5\", \"0\", \"5\", \"3\", \"5\", \"2\", \"3\", \"0\", \"5\", \"4\", \"1\",\n            \"1\", \"0\", \"3\", \"5\", \"0\", \"2\", \"1\", \"5\", \"4\", \"4\", \"1\", \"1\", \"0\", \"3\", \"1\", \"0\", \"5\",\n            \"3\", \"1\", \"4\", \"3\", \"0\", \"4\", \"5\", \"1\", \"2\", \"5\", \"5\", \"2\", \"2\", \"4\", \"4\", \"0\", \"5\",\n            \"4\", \"0\", \"5\", \"4\", \"3\", \"3\", \"1\", \"1\", \"4\", \"3\", \"5\", \"5\", \"4\", \"0\", \"5\", \"2\", \"3\",\n            \"2\", \"3\", \"4\", \"2\", \"1\", \"2\", \"2\", \"2\", \"1\", \"2\", \"4\", \"5\", \"1\", \"5\", \"5\", \"1\", \"3\",\n            \"1\", \"5\", \"4\", \"2\", \"5\", \"3\", \"5\", \"1\", \"5\", \"0\", \"3\", \"5\", \"2\", \"4\", \"1\", \"2\", \"3\",\n            \"2\", \"3\", \"1\", \"4\",\n        ],\n    );\n    test(\n        \"14974892748479131847778931724116484851265511358392776602889616274416063303\",\n        \"3\",\n        &[\n            \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"0\", \"2\", \"1\", \"0\", \"1\", \"1\", \"1\", \"1\", \"2\", \"1\", \"1\",\n            \"2\", \"0\", \"2\", \"2\", \"1\", \"1\", \"0\", \"0\", \"2\", \"0\", \"0\", \"2\", \"0\", \"2\", \"1\", \"1\", \"1\",\n            \"0\", \"2\", \"2\", \"1\", \"2\", \"0\", \"2\", \"1\", \"1\", \"0\", \"1\", \"0\", \"1\", \"0\", \"2\", \"0\", \"1\",\n            \"1\", \"2\", \"1\", \"0\", \"1\", \"1\", \"1\", \"1\", \"2\", \"0\", \"2\", \"2\", \"2\", \"0\", \"2\", \"2\", \"1\",\n            \"0\", \"1\", \"1\", \"1\", \"0\", \"0\", \"2\", \"0\", \"1\", \"2\", \"2\", \"2\", \"2\", \"0\", \"0\", \"2\", \"2\",\n            \"1\", \"0\", \"0\", \"0\", \"2\", \"0\", \"2\", \"1\", \"0\", \"0\", \"2\", \"0\", \"1\", \"1\", \"2\", \"0\", \"1\",\n            \"1\", \"2\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"1\", \"1\", \"1\", \"2\", \"0\", \"1\", \"0\", \"1\", \"2\",\n            \"1\", \"0\", \"0\", \"0\", \"0\", \"1\", \"2\", \"0\", \"0\", \"1\", \"1\", \"2\", \"1\", \"1\", \"0\", \"1\", \"0\",\n            \"0\", \"2\", \"2\", \"2\", \"0\", \"2\", \"1\", \"1\", \"2\", \"1\", \"2\", \"0\", \"2\", \"1\", \"1\", \"1\", \"2\",\n            \"0\",\n        ],\n    );\n    test(\n        \"643945257796761196320314690988316858252541574945689186182369731847117890385280572047834937\\\n        1883212246436232738680605124294949600205450044993253033167972343988333612737978764297848348\\\n        2665822115523011210267845467229157815194234251375826930137780574470438350033031660616757791\\\n        61\",\n        \"7\",\n        &[\n            \"6\", \"6\", \"4\", \"4\", \"6\", \"3\", \"4\", \"6\", \"4\", \"2\", \"5\", \"6\", \"3\", \"0\", \"2\", \"2\", \"5\",\n            \"6\", \"5\", \"0\", \"4\", \"5\", \"5\", \"2\", \"0\", \"5\", \"0\", \"0\", \"1\", \"2\", \"6\", \"1\", \"3\", \"2\",\n            \"5\", \"4\", \"4\", \"6\", \"3\", \"6\", \"3\", \"6\", \"5\", \"5\", \"1\", \"4\", \"1\", \"2\", \"6\", \"1\", \"3\",\n            \"2\", \"2\", \"4\", \"4\", \"3\", \"1\", \"4\", \"5\", \"5\", \"2\", \"5\", \"3\", \"6\", \"0\", \"4\", \"3\", \"0\",\n            \"0\", \"6\", \"0\", \"5\", \"2\", \"6\", \"2\", \"6\", \"5\", \"1\", \"6\", \"4\", \"2\", \"3\", \"1\", \"3\", \"1\",\n            \"2\", \"3\", \"5\", \"6\", \"3\", \"0\", \"1\", \"0\", \"1\", \"5\", \"5\", \"3\", \"3\", \"6\", \"6\", \"3\", \"4\",\n            \"4\", \"6\", \"6\", \"6\", \"6\", \"3\", \"4\", \"2\", \"6\", \"2\", \"3\", \"0\", \"3\", \"4\", \"2\", \"3\", \"6\",\n            \"4\", \"4\", \"1\", \"5\", \"3\", \"2\", \"6\", \"4\", \"3\", \"3\", \"0\", \"3\", \"1\", \"6\", \"4\", \"6\", \"6\",\n            \"0\", \"4\", \"5\", \"1\", \"0\", \"4\", \"1\", \"1\", \"1\", \"6\", \"0\", \"2\", \"6\", \"6\", \"2\", \"1\", \"4\",\n            \"5\", \"2\", \"0\", \"1\", \"5\", \"3\", \"3\", \"5\", \"1\", \"5\", \"2\", \"6\", \"5\", \"2\", \"4\", \"0\", \"2\",\n            \"0\", \"6\", \"1\", \"2\", \"4\", \"5\", \"6\", \"0\", \"4\", \"4\", \"2\", \"2\", \"5\", \"4\", \"6\", \"5\", \"2\",\n            \"0\", \"2\", \"4\", \"4\", \"5\", \"4\", \"4\", \"6\", \"1\", \"0\", \"6\", \"5\", \"1\", \"0\", \"2\", \"3\", \"1\",\n            \"1\", \"3\", \"5\", \"3\", \"1\", \"3\", \"3\", \"0\", \"2\", \"5\", \"6\", \"2\", \"5\", \"0\", \"3\", \"4\", \"5\",\n            \"1\", \"3\", \"1\", \"6\", \"0\", \"6\", \"1\", \"3\", \"4\", \"6\", \"6\", \"0\", \"5\", \"2\", \"5\", \"6\", \"1\",\n            \"2\", \"0\", \"5\", \"5\", \"6\", \"2\", \"5\", \"3\", \"0\", \"2\", \"3\", \"4\", \"1\", \"0\", \"0\", \"2\", \"4\",\n            \"1\", \"2\", \"1\", \"4\", \"4\", \"5\", \"1\", \"6\", \"3\", \"0\", \"0\", \"5\", \"3\", \"5\", \"0\", \"4\", \"5\",\n            \"0\", \"5\", \"0\", \"5\", \"2\", \"2\", \"0\", \"6\", \"1\", \"4\", \"6\", \"5\", \"3\", \"4\", \"4\", \"3\", \"1\",\n            \"4\", \"5\", \"3\", \"0\", \"2\", \"3\", \"3\", \"0\", \"1\", \"2\", \"0\", \"4\", \"4\", \"6\", \"2\", \"4\", \"1\",\n            \"3\", \"4\", \"6\", \"3\", \"0\", \"1\", \"0\", \"2\", \"6\", \"4\", \"2\", \"0\", \"6\", \"5\", \"4\", \"1\", \"5\",\n            \"4\",\n        ],\n    );\n}\n\n#[test]\nfn to_digits_desc_natural_fail() {\n    assert_panic!(Natural::from(10u32).to_digits_desc(&Natural::ZERO));\n    assert_panic!(Natural::from(10u32).to_digits_desc(&Natural::ONE));\n}\n\n#[test]\nfn to_digits_desc_natural_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    natural_pair_gen_var_2().test_properties_with_config(&config, |(x, base)| {\n        let digits = x.to_digits_desc(&base);\n        if x != 0 {\n            assert_ne!(digits[0], 0);\n            assert_eq!(u64::exact_from(digits.len()), x.floor_log_base(&base) + 1);\n        }\n        assert_eq!(\n            digits.iter().cloned().rev().collect_vec(),\n            x.to_digits_asc(&base)\n        );\n        assert!(digits.iter().all(|digit| *digit < base));\n        assert_eq!(\n            Natural::from_digits_desc(&base, digits.into_iter()).unwrap(),\n            x\n        );\n    });\n\n    natural_gen().test_properties_with_config(&config, |x| {\n        assert_eq!(\n            x.to_digits_desc(&Natural::TWO)\n                .into_iter()\n                .map(|digit| digit == 1)\n                .collect_vec(),\n            x.to_bits_desc()\n        );\n    });\n\n    natural_gen_var_1().test_properties_with_config(&config, |base| {\n        assert!(Natural::ZERO.to_digits_desc(&base).is_empty());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/digits/to_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::{FloorLogBasePowerOf2, Pow};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ExactFrom, PowerOf2Digits};\nuse malachite_base::num::logic::traits::{BitConvertible, SignificantBits};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::{\n    unsigned_gen_var_3, unsigned_gen_var_11, unsigned_pair_gen_var_4,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_unsigned_pair_gen_var_6, natural_unsigned_pair_gen_var_7,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_to_power_of_2_digits_asc() {\n    fn test<T: PrimitiveUnsigned, F: Fn(&Natural, u64) -> Vec<T>>(\n        to_power_of_2_digits_asc_naive: F,\n        n: &str,\n        log_base: u64,\n        out: &[T],\n    ) where\n        Natural: PowerOf2Digits<T>,\n    {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            PowerOf2Digits::<T>::to_power_of_2_digits_asc(&n, log_base),\n            out\n        );\n        assert_eq!(to_power_of_2_digits_asc_naive(&n, log_base), out);\n    }\n    test::<u8, _>(Natural::to_power_of_2_digits_asc_naive, \"0\", 1, &[]);\n    test::<u16, _>(Natural::to_power_of_2_digits_asc_naive, \"123\", 10, &[123]);\n    test::<u16, _>(\n        Natural::to_power_of_2_digits_asc_naive,\n        \"1000000000000\",\n        1,\n        &[\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1,\n            0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1,\n        ],\n    );\n    test::<u32, _>(\n        Natural::to_power_of_2_digits_asc_naive,\n        \"1000000000000\",\n        3,\n        &[0, 0, 0, 0, 1, 2, 1, 5, 4, 2, 3, 4, 6, 1],\n    );\n    test::<u64, _>(\n        Natural::to_power_of_2_digits_asc_naive,\n        \"1000000000000\",\n        4,\n        &[0, 0, 0, 1, 5, 10, 4, 13, 8, 14],\n    );\n    test::<u32, _>(\n        Natural::to_power_of_2_digits_asc_naive,\n        \"1000000000000\",\n        32,\n        &[3567587328, 232],\n    );\n    test::<u64, _>(\n        Natural::to_power_of_2_digits_asc_naive,\n        \"1000000000000\",\n        64,\n        &[1000000000000],\n    );\n    test::<u64, _>(\n        Natural::to_power_of_2_digits_asc_naive,\n        \"1000000000000000000000000\",\n        64,\n        &[2003764205206896640, 54210],\n    );\n}\n\nfn to_power_of_2_digits_asc_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: PowerOf2Digits<T>,\n{\n    assert_panic!(PowerOf2Digits::<T>::to_power_of_2_digits_asc(\n        &Natural::from(10u32).pow(12),\n        0\n    ));\n    assert_panic!(PowerOf2Digits::<T>::to_power_of_2_digits_asc(\n        &Natural::from(10u32).pow(12),\n        T::WIDTH + 1\n    ));\n}\n\n#[test]\nfn to_power_of_2_digits_asc_fail() {\n    apply_fn_to_unsigneds!(to_power_of_2_digits_asc_fail_helper);\n}\n\n#[test]\nfn test_to_power_of_2_digits_desc() {\n    fn test<T: PrimitiveUnsigned>(n: &str, log_base: u64, out: &[T])\n    where\n        Natural: PowerOf2Digits<T>,\n    {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            PowerOf2Digits::<T>::to_power_of_2_digits_desc(&n, log_base),\n            out\n        );\n    }\n    test::<u8>(\"0\", 1, &[]);\n    test::<u16>(\"123\", 10, &[123]);\n    test::<u16>(\n        \"1000000000000\",\n        1,\n        &[\n            1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0,\n            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n        ],\n    );\n    test::<u32>(\n        \"1000000000000\",\n        3,\n        &[1, 6, 4, 3, 2, 4, 5, 1, 2, 1, 0, 0, 0, 0],\n    );\n    test::<u64>(\"1000000000000\", 4, &[14, 8, 13, 4, 10, 5, 1, 0, 0, 0]);\n    test::<u32>(\"1000000000000\", 32, &[232, 3567587328]);\n    test::<u64>(\"1000000000000\", 64, &[1000000000000]);\n    test::<u64>(\n        \"1000000000000000000000000\",\n        64,\n        &[54210, 2003764205206896640],\n    );\n}\n\nfn to_power_of_2_digits_desc_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: PowerOf2Digits<T>,\n{\n    assert_panic!(PowerOf2Digits::<T>::to_power_of_2_digits_desc(\n        &Natural::from(10u32).pow(12),\n        0\n    ));\n    assert_panic!(PowerOf2Digits::<T>::to_power_of_2_digits_desc(\n        &Natural::from(10u32).pow(12),\n        T::WIDTH + 1\n    ));\n}\n\n#[test]\nfn to_power_of_2_digits_desc_fail() {\n    apply_fn_to_unsigneds!(to_power_of_2_digits_desc_fail_helper);\n}\n\n#[test]\nfn test_to_power_of_2_digits_asc_natural() {\n    let test = |n, log_base, out| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&n, log_base).to_debug_string(),\n            out\n        );\n        assert_eq!(\n            n.to_power_of_2_digits_asc_natural_naive(log_base)\n                .to_debug_string(),\n            out\n        );\n    };\n    test(\"0\", 1, \"[]\");\n    test(\"123\", 10, \"[123]\");\n    test(\n        \"1000000000000\",\n        1,\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, \\\n        0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1]\",\n    );\n    test(\n        \"1000000000000\",\n        3,\n        \"[0, 0, 0, 0, 1, 2, 1, 5, 4, 2, 3, 4, 6, 1]\",\n    );\n    test(\"1000000000000\", 4, \"[0, 0, 0, 1, 5, 10, 4, 13, 8, 14]\");\n    test(\"1000000000000\", 32, \"[3567587328, 232]\");\n    test(\"1000000000000\", 64, \"[1000000000000]\");\n    test(\n        \"1000000000000000000000000\",\n        64,\n        \"[2003764205206896640, 54210]\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        33,\n        \"[6996099072, 4528236150, 13552]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn to_power_of_2_digits_asc_natural_fail() {\n    PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&Natural::from(10u32).pow(12), 0);\n}\n\n#[test]\nfn test_to_power_of_2_digits_desc_natural() {\n    let test = |n, log_base, out| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&n, log_base).to_debug_string(),\n            out\n        );\n    };\n    test(\"0\", 1, \"[]\");\n    test(\"123\", 10, \"[123]\");\n    test(\n        \"1000000000000\",\n        1,\n        \"[1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, \\\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    test(\n        \"1000000000000\",\n        3,\n        \"[1, 6, 4, 3, 2, 4, 5, 1, 2, 1, 0, 0, 0, 0]\",\n    );\n    test(\"1000000000000\", 4, \"[14, 8, 13, 4, 10, 5, 1, 0, 0, 0]\");\n    test(\"1000000000000\", 32, \"[232, 3567587328]\");\n    test(\"1000000000000\", 64, \"[1000000000000]\");\n    test(\n        \"1000000000000000000000000\",\n        64,\n        \"[54210, 2003764205206896640]\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        33,\n        \"[13552, 4528236150, 6996099072]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn to_power_of_2_digits_desc_natural_fail() {\n    PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&Natural::from(10u32).pow(12), 0);\n}\n\nfn to_power_of_2_digits_asc_properties_helper<T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned>()\nwhere\n    Limb: PowerOf2Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    natural_unsigned_pair_gen_var_6::<T>().test_properties(|(ref n, log_base)| {\n        let digits = n.to_power_of_2_digits_asc(log_base);\n        assert_eq!(\n            Natural::to_power_of_2_digits_asc_naive::<T>(n, log_base),\n            digits\n        );\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().copied()).unwrap(),\n            *n\n        );\n        if *n != 0 {\n            assert_ne!(*digits.last().unwrap(), T::ZERO);\n        }\n        assert_eq!(\n            digits.iter().copied().rev().collect_vec(),\n            n.to_power_of_2_digits_desc(log_base)\n        );\n        if *n != Natural::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                n.floor_log_base_power_of_2(log_base) + 1\n            );\n        }\n        assert!(\n            digits\n                .iter()\n                .all(|digit| digit.significant_bits() <= log_base)\n        );\n\n        assert_eq!(\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(n, log_base),\n            digits.iter().copied().map(Natural::from).collect_vec()\n        );\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(\n            n.to_power_of_2_digits_asc(1)\n                .into_iter()\n                .map(|digit: T| digit == T::ONE)\n                .collect_vec(),\n            n.to_bits_asc()\n        );\n    });\n\n    unsigned_gen_var_3::<T>().test_properties(|log_base| {\n        assert!(PowerOf2Digits::<T>::to_power_of_2_digits_asc(&Natural::ZERO, log_base).is_empty());\n    });\n\n    unsigned_pair_gen_var_4::<Limb, T>().test_properties(|(u, log_base)| {\n        let n: Natural = From::from(u);\n        assert_eq!(\n            PowerOf2Digits::<T>::to_power_of_2_digits_asc(&u, log_base),\n            PowerOf2Digits::<T>::to_power_of_2_digits_asc(&n, log_base)\n        );\n    });\n}\n\n#[test]\nfn to_power_of_2_digits_asc_properties() {\n    apply_fn_to_unsigneds!(to_power_of_2_digits_asc_properties_helper);\n\n    natural_gen().test_properties(|ref n| {\n        assert_eq!(\n            PowerOf2Digits::<Limb>::to_power_of_2_digits_asc(n, Limb::WIDTH),\n            n.as_limbs_asc()\n        );\n    });\n}\n\nfn to_power_of_2_digits_desc_properties_helper<\n    T: for<'a> TryFrom<&'a Natural> + PrimitiveUnsigned,\n>()\nwhere\n    Limb: PowerOf2Digits<T>,\n    Natural: From<T> + PowerOf2Digits<T>,\n{\n    natural_unsigned_pair_gen_var_6::<T>().test_properties(|(ref n, log_base)| {\n        let digits = n.to_power_of_2_digits_desc(log_base);\n        assert_eq!(\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().copied()).unwrap(),\n            *n\n        );\n        if *n != 0 {\n            assert_ne!(digits[0], T::ZERO);\n        }\n        assert_eq!(\n            digits.iter().copied().rev().collect_vec(),\n            n.to_power_of_2_digits_asc(log_base)\n        );\n        if *n != Natural::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                n.floor_log_base_power_of_2(log_base) + 1\n            );\n        }\n        assert!(\n            digits\n                .iter()\n                .all(|digit| digit.significant_bits() <= log_base)\n        );\n\n        assert_eq!(\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(n, log_base),\n            digits.iter().copied().map(Natural::from).collect_vec()\n        );\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(\n            n.to_power_of_2_digits_desc(1)\n                .into_iter()\n                .map(|digit: T| digit == T::ONE)\n                .collect_vec(),\n            n.to_bits_desc()\n        );\n    });\n\n    unsigned_gen_var_3::<T>().test_properties(|log_base| {\n        assert!(\n            PowerOf2Digits::<T>::to_power_of_2_digits_desc(&Natural::ZERO, log_base).is_empty()\n        );\n    });\n\n    unsigned_pair_gen_var_4::<Limb, T>().test_properties(|(u, log_base)| {\n        let n: Natural = From::from(u);\n        assert_eq!(\n            PowerOf2Digits::<T>::to_power_of_2_digits_desc(&u, log_base),\n            PowerOf2Digits::<T>::to_power_of_2_digits_desc(&n, log_base)\n        );\n    });\n}\n\n#[test]\nfn to_power_of_2_digits_desc_properties() {\n    apply_fn_to_unsigneds!(to_power_of_2_digits_desc_properties_helper);\n\n    natural_gen().test_properties(|ref n| {\n        assert_eq!(\n            PowerOf2Digits::<Limb>::to_power_of_2_digits_desc(n, Limb::WIDTH),\n            n.to_limbs_desc()\n        );\n    });\n}\n\n#[test]\nfn to_power_of_2_digits_asc_natural_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(ref n, log_base)| {\n        let digits: Vec<Natural> = n.to_power_of_2_digits_asc(log_base);\n        assert_eq!(n.to_power_of_2_digits_asc_natural_naive(log_base), digits);\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned()).unwrap(),\n            *n\n        );\n        if *n != 0 {\n            assert_ne!(*digits.last().unwrap(), 0);\n        }\n        assert_eq!(\n            digits.iter().cloned().rev().collect_vec(),\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(n, log_base)\n        );\n        if *n != Natural::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                n.floor_log_base_power_of_2(log_base) + 1\n            );\n        }\n        assert!(\n            digits\n                .iter()\n                .all(|digit| digit.significant_bits() <= log_base)\n        );\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(\n            n.to_power_of_2_digits_asc(1)\n                .into_iter()\n                .map(|digit: Natural| digit == 1)\n                .collect_vec(),\n            n.to_bits_asc()\n        );\n    });\n\n    unsigned_gen_var_11().test_properties(|log_base| {\n        assert!(\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(&Natural::ZERO, log_base)\n                .is_empty()\n        );\n    });\n}\n\n#[test]\nfn to_power_of_2_digits_desc_natural_properties() {\n    natural_unsigned_pair_gen_var_7().test_properties(|(ref n, log_base)| {\n        let digits: Vec<Natural> = n.to_power_of_2_digits_desc(log_base);\n        assert_eq!(\n            Natural::from_power_of_2_digits_desc(log_base, digits.iter().cloned()).unwrap(),\n            *n\n        );\n        if *n != 0 {\n            assert_ne!(digits[0], 0);\n        }\n        assert_eq!(\n            digits.iter().cloned().rev().collect_vec(),\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_asc(n, log_base)\n        );\n        if *n != Natural::ZERO {\n            assert_eq!(\n                u64::exact_from(digits.len()),\n                n.floor_log_base_power_of_2(log_base) + 1\n            );\n        }\n        assert!(\n            digits\n                .iter()\n                .all(|digit| digit.significant_bits() <= log_base)\n        );\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(\n            n.to_power_of_2_digits_desc(1)\n                .into_iter()\n                .map(|digit: Natural| digit == 1)\n                .collect_vec(),\n            n.to_bits_desc()\n        );\n    });\n\n    unsigned_gen_var_11().test_properties(|log_base| {\n        assert!(\n            PowerOf2Digits::<Natural>::to_power_of_2_digits_desc(&Natural::ZERO, log_base)\n                .is_empty()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::natural::Natural;\n\n#[test]\nfn test_from_bool() {\n    let test = |b, s| {\n        let n = Natural::from(b);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), s);\n    };\n    test(false, \"0\");\n    test(true, \"1\");\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/from_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::slices::slice_test_zero;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_from_limbs_asc() {\n    let test = |xs: &[Limb], out| {\n        let x = Natural::from_limbs_asc(xs);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = Natural::from_owned_limbs_asc(xs.to_vec());\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(&[], \"0\");\n    test(&[0], \"0\");\n    test(&[0, 0, 0], \"0\");\n    test(&[123], \"123\");\n    test(&[123, 0], \"123\");\n    test(&[123, 0, 0, 0], \"123\");\n    test(&[3567587328, 232], \"1000000000000\");\n    test(&[3567587328, 232, 0], \"1000000000000\");\n    test(&[1, 2, 3, 4, 5], \"1701411834921604967429270619762735448065\");\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_from_limbs_desc() {\n    let test = |xs: Vec<Limb>, out| {\n        let x = Natural::from_limbs_desc(&xs);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = Natural::from_owned_limbs_desc(xs.to_vec());\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(vec![], \"0\");\n    test(vec![0], \"0\");\n    test(vec![0, 0, 0], \"0\");\n    test(vec![123], \"123\");\n    test(vec![0, 123], \"123\");\n    test(vec![0, 0, 0, 123], \"123\");\n    test(vec![232, 3567587328], \"1000000000000\");\n    test(vec![0, 232, 3567587328], \"1000000000000\");\n    test(\n        vec![5, 4, 3, 2, 1],\n        \"1701411834921604967429270619762735448065\",\n    );\n}\n\n#[test]\nfn from_limbs_asc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        let x = Natural::from_limbs_asc(&xs);\n        assert!(x.is_valid());\n        assert_eq!(Natural::from_owned_limbs_asc(xs.clone()), x);\n        let mut trimmed_limbs = xs\n            .iter()\n            .copied()\n            .rev()\n            .skip_while(|&limb| limb == 0)\n            .collect_vec();\n        trimmed_limbs.reverse();\n        assert_eq!(x.as_limbs_asc(), trimmed_limbs);\n        assert_eq!(\n            Natural::from_limbs_desc(&xs.iter().copied().rev().collect_vec()),\n            x\n        );\n        if !xs.is_empty() && *xs.last().unwrap() != 0 {\n            assert_eq!(x.as_limbs_asc(), xs);\n        }\n        assert_eq!(slice_test_zero(&xs), x == 0);\n    });\n}\n\n#[test]\nfn from_limbs_desc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        let x = Natural::from_limbs_desc(&xs);\n        assert!(x.is_valid());\n        assert_eq!(Natural::from_owned_limbs_desc(xs.clone()), x);\n        assert_eq!(\n            x.to_limbs_desc(),\n            xs.iter()\n                .copied()\n                .skip_while(|&limb| limb == 0)\n                .collect_vec()\n        );\n        assert_eq!(\n            Natural::from_limbs_asc(&xs.iter().copied().rev().collect_vec()),\n            x\n        );\n        if !xs.is_empty() && xs[0] != 0 {\n            assert_eq!(x.to_limbs_desc(), xs);\n        }\n        assert_eq!(slice_test_zero(&xs), x == 0);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::{\n    primitive_float_gen, primitive_float_gen_var_2, primitive_float_gen_var_3,\n    primitive_float_gen_var_4, primitive_float_gen_var_13,\n    primitive_float_rounding_mode_pair_gen_var_1,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_rounding_from_f32() {\n    let test = |f: f32, rm: RoundingMode, out, o_out| {\n        let (x, o) = Natural::rounding_from(f, rm);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(o, o_out);\n    };\n    test(0.0, Exact, \"0\", Equal);\n    test(-0.0, Exact, \"0\", Equal);\n    test(123.0, Exact, \"123\", Equal);\n    test(1.0e9, Exact, \"1000000000\", Equal);\n    test(1.0e9, Exact, \"1000000000\", Equal);\n    test(4294967295.0, Exact, \"4294967296\", Equal);\n    test(4294967296.0, Exact, \"4294967296\", Equal);\n    test(18446744073709551615.0, Exact, \"18446744073709551616\", Equal);\n    test(18446744073709551616.0, Exact, \"18446744073709551616\", Equal);\n    test(1.0e20, Exact, \"100000002004087734272\", Equal);\n    test(1.23e20, Exact, \"122999999650278146048\", Equal);\n    test(1.6777216e7, Exact, \"16777216\", Equal);\n    test(1.6777218e7, Exact, \"16777218\", Equal);\n\n    test(123.1, Floor, \"123\", Less);\n    test(123.1, Down, \"123\", Less);\n    test(123.1, Ceiling, \"124\", Greater);\n    test(123.1, Up, \"124\", Greater);\n    test(123.1, Nearest, \"123\", Less);\n\n    test(123.9, Floor, \"123\", Less);\n    test(123.9, Down, \"123\", Less);\n    test(123.9, Ceiling, \"124\", Greater);\n    test(123.9, Up, \"124\", Greater);\n    test(123.9, Nearest, \"124\", Greater);\n\n    test(123.5, Nearest, \"124\", Greater);\n    test(124.5, Nearest, \"124\", Less);\n    test(-0.99, Ceiling, \"0\", Greater);\n    test(-0.99, Down, \"0\", Greater);\n    test(-0.499, Nearest, \"0\", Greater);\n    test(-0.5, Nearest, \"0\", Greater);\n\n    test(f32::NEGATIVE_INFINITY, Nearest, \"0\", Greater);\n    test(f32::NEGATIVE_INFINITY, Down, \"0\", Greater);\n    test(f32::NEGATIVE_INFINITY, Ceiling, \"0\", Greater);\n    test(-123.0, Nearest, \"0\", Greater);\n    test(-123.0, Down, \"0\", Greater);\n    test(-123.0, Ceiling, \"0\", Greater);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_1() {\n    Natural::rounding_from(f32::NAN, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_2() {\n    Natural::rounding_from(f32::INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_3() {\n    Natural::rounding_from(f32::NEGATIVE_INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_4() {\n    Natural::rounding_from(123.1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_5() {\n    Natural::rounding_from(-123.0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_6() {\n    Natural::rounding_from(-0.1, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f32_fail_7() {\n    Natural::rounding_from(-0.1, Up);\n}\n\n#[test]\nfn test_rounding_from_f64() {\n    let test = |f: f64, rm: RoundingMode, out, o_out| {\n        let (x, o) = Natural::rounding_from(f, rm);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(o, o_out);\n    };\n    test(0.0, Exact, \"0\", Equal);\n    test(-0.0, Exact, \"0\", Equal);\n    test(123.0, Exact, \"123\", Equal);\n    test(1.0e9, Exact, \"1000000000\", Equal);\n    test(1.0e9, Exact, \"1000000000\", Equal);\n    test(4294967295.0, Exact, \"4294967295\", Equal);\n    test(4294967296.0, Exact, \"4294967296\", Equal);\n    test(18446744073709551615.0, Exact, \"18446744073709551616\", Equal);\n    test(18446744073709551616.0, Exact, \"18446744073709551616\", Equal);\n    test(1.0e20, Exact, \"100000000000000000000\", Equal);\n    test(1.23e20, Exact, \"123000000000000000000\", Equal);\n    test(\n        1.0e100,\n        Exact,\n        \"100000000000000001590289110975991804683608085639452813897813275577478387721703810608134699\\\n        85856815104\",\n        Equal,\n    );\n    test(\n        1.23e100,\n        Exact,\n        \"123000000000000008366862950845375853795062237854139353014252897832358837028676639186389822\\\n        00322686976\",\n        Equal,\n    );\n    test(9.007199254740992e15, Exact, \"9007199254740992\", Equal);\n    test(9.007199254740994e15, Exact, \"9007199254740994\", Equal);\n\n    test(123.1, Floor, \"123\", Less);\n    test(123.1, Down, \"123\", Less);\n    test(123.1, Ceiling, \"124\", Greater);\n    test(123.1, Up, \"124\", Greater);\n    test(123.1, Nearest, \"123\", Less);\n\n    test(123.9, Floor, \"123\", Less);\n    test(123.9, Down, \"123\", Less);\n    test(123.9, Ceiling, \"124\", Greater);\n    test(123.9, Up, \"124\", Greater);\n    test(123.9, Nearest, \"124\", Greater);\n\n    test(123.5, Nearest, \"124\", Greater);\n    test(124.5, Nearest, \"124\", Less);\n    test(-0.99, Ceiling, \"0\", Greater);\n    test(-0.99, Down, \"0\", Greater);\n    test(-0.499, Nearest, \"0\", Greater);\n    test(-0.5, Nearest, \"0\", Greater);\n\n    test(f64::NEGATIVE_INFINITY, Nearest, \"0\", Greater);\n    test(f64::NEGATIVE_INFINITY, Down, \"0\", Greater);\n    test(f64::NEGATIVE_INFINITY, Ceiling, \"0\", Greater);\n\n    test(-123.0, Nearest, \"0\", Greater);\n    test(-123.0, Down, \"0\", Greater);\n    test(-123.0, Ceiling, \"0\", Greater);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_1() {\n    Natural::rounding_from(f64::NAN, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_2() {\n    Natural::rounding_from(f64::INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_3() {\n    Natural::rounding_from(f64::NEGATIVE_INFINITY, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_4() {\n    Natural::rounding_from(123.1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_5() {\n    Natural::rounding_from(-123.0, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_6() {\n    Natural::rounding_from(-0.1, Floor);\n}\n\n#[test]\n#[should_panic]\nfn rounding_from_f64_fail_7() {\n    Natural::rounding_from(-0.1, Up);\n}\n\n#[test]\nfn test_try_from_f32() {\n    let test = |f: f32, out| {\n        let on = Natural::try_from(f);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(f32::NAN, \"Err(FloatInfiniteOrNan)\");\n    test(f32::INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(f32::NEGATIVE_INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(4294967295.0, \"Ok(4294967296)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(1.0e20, \"Ok(100000002004087734272)\");\n    test(1.23e20, \"Ok(122999999650278146048)\");\n    test(123.1, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(123.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(124.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-0.99, \"Err(FloatNegative)\");\n    test(-0.499, \"Err(FloatNegative)\");\n    test(-0.5, \"Err(FloatNegative)\");\n    test(-123.0, \"Err(FloatNegative)\");\n    test(f32::MIN_POSITIVE, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f32::MAX_SUBNORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f32::MIN_POSITIVE_NORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(\n        f32::MAX_FINITE,\n        \"Ok(340282346638528859811704183484516925440)\",\n    );\n}\n\n#[test]\nfn test_try_from_f64() {\n    let test = |f: f64, out| {\n        let on = Natural::try_from(f);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(f64::NAN, \"Err(FloatInfiniteOrNan)\");\n    test(f64::INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(f64::NEGATIVE_INFINITY, \"Err(FloatInfiniteOrNan)\");\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(4294967295.0, \"Ok(4294967295)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(1.0e20, \"Ok(100000000000000000000)\");\n    test(1.23e20, \"Ok(123000000000000000000)\");\n    test(\n        1.0e100,\n        \"Ok(10000000000000000159028911097599180468360808563945281389781327557747838772170381060813\\\n        469985856815104)\",\n    );\n    test(\n        1.23e100,\n        \"Ok(12300000000000000836686295084537585379506223785413935301425289783235883702867663918638\\\n        982200322686976)\",\n    );\n    test(123.1, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(123.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(124.5, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(-0.99, \"Err(FloatNegative)\");\n    test(-0.499, \"Err(FloatNegative)\");\n    test(-0.5, \"Err(FloatNegative)\");\n    test(-123.0, \"Err(FloatNegative)\");\n    test(f64::MIN_POSITIVE, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f64::MAX_SUBNORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(f64::MIN_POSITIVE_NORMAL, \"Err(FloatNonIntegerOrOutOfRange)\");\n    test(\n        f64::MAX_FINITE,\n        \"Ok(1797693134862315708145274237317043567980705675258449965989174768031572607800285387605\\\n        8955863276687817154045895351438246423432132688946418276846754670353751698604991057655128207\\\n        6245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723\\\n        168738177180919299881250404026184124858368)\",\n    );\n}\n\n#[test]\nfn test_exact_from_f32() {\n    let test = |f: f32, out| {\n        let x = Natural::exact_from(f);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(0.0, \"0\");\n    test(-0.0, \"0\");\n    test(123.0, \"123\");\n    test(1.0e9, \"1000000000\");\n    test(4294967295.0, \"4294967296\");\n    test(4294967296.0, \"4294967296\");\n    test(18446744073709551615.0, \"18446744073709551616\");\n    test(18446744073709551616.0, \"18446744073709551616\");\n    test(1.0e20, \"100000002004087734272\");\n    test(1.23e20, \"122999999650278146048\");\n    test(f32::MAX_FINITE, \"340282346638528859811704183484516925440\");\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_1() {\n    Natural::exact_from(f32::NAN);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_2() {\n    Natural::exact_from(f32::INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_3() {\n    Natural::exact_from(f32::NEGATIVE_INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_4() {\n    Natural::exact_from(123.1);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_5() {\n    Natural::exact_from(123.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_6() {\n    Natural::exact_from(124.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_7() {\n    Natural::exact_from(-0.99);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_8() {\n    Natural::exact_from(-0.499);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_9() {\n    Natural::exact_from(-0.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_10() {\n    Natural::exact_from(-123.0);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_11() {\n    Natural::exact_from(f32::MIN_POSITIVE);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_12() {\n    Natural::exact_from(f32::MAX_SUBNORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f32_fail_13() {\n    Natural::exact_from(f32::MIN_POSITIVE_NORMAL);\n}\n\n#[test]\nfn test_exact_from_f64() {\n    let test = |f: f64, out| {\n        let x = Natural::exact_from(f);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n    };\n    test(0.0, \"0\");\n    test(-0.0, \"0\");\n    test(123.0, \"123\");\n    test(1.0e9, \"1000000000\");\n    test(4294967295.0, \"4294967295\");\n    test(4294967296.0, \"4294967296\");\n    test(18446744073709551615.0, \"18446744073709551616\");\n    test(18446744073709551616.0, \"18446744073709551616\");\n    test(1.0e20, \"100000000000000000000\");\n    test(1.23e20, \"123000000000000000000\");\n    test(\n        1.0e100,\n        \"100000000000000001590289110975991804683608085639452813897813275577478387721703810608134699\\\n        85856815104\",\n    );\n    test(\n        1.23e100,\n        \"123000000000000008366862950845375853795062237854139353014252897832358837028676639186389822\\\n        00322686976\",\n    );\n    test(\n        f64::MAX_FINITE,\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_1() {\n    Natural::exact_from(f64::NAN);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_2() {\n    Natural::exact_from(f64::INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_3() {\n    Natural::exact_from(f64::NEGATIVE_INFINITY);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_4() {\n    Natural::exact_from(123.1);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_5() {\n    Natural::exact_from(123.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_6() {\n    Natural::exact_from(124.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_7() {\n    Natural::exact_from(-0.99);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_8() {\n    Natural::exact_from(-0.499);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_9() {\n    Natural::exact_from(-0.5);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_10() {\n    Natural::exact_from(-123.0);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_11() {\n    Natural::exact_from(f64::MIN_POSITIVE);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_12() {\n    Natural::exact_from(f64::MAX_SUBNORMAL);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_f64_fail_13() {\n    Natural::exact_from(f64::MIN_POSITIVE_NORMAL);\n}\n\n#[test]\nfn test_convertible_from_f32() {\n    let test = |f: f32, out| {\n        assert_eq!(Natural::convertible_from(f), out);\n    };\n    test(f32::NAN, false);\n    test(f32::INFINITY, false);\n    test(f32::NEGATIVE_INFINITY, false);\n    test(0.0, true);\n    test(-0.0, true);\n    test(123.0, true);\n    test(1.0e9, true);\n    test(4294967295.0, true);\n    test(4294967296.0, true);\n    test(18446744073709551615.0, true);\n    test(18446744073709551616.0, true);\n    test(1.0e20, true);\n    test(1.23e20, true);\n    test(123.1, false);\n    test(123.5, false);\n    test(124.5, false);\n    test(-0.99, false);\n    test(-0.499, false);\n    test(-0.5, false);\n    test(-123.0, false);\n    test(f32::MIN_POSITIVE, false);\n    test(f32::MAX_SUBNORMAL, false);\n    test(f32::MIN_POSITIVE_NORMAL, false);\n    test(f32::MAX_FINITE, true);\n}\n\n#[test]\nfn test_convertible_from_f64() {\n    let test = |f: f64, out| {\n        assert_eq!(Natural::convertible_from(f), out);\n    };\n    test(f64::NAN, false);\n    test(f64::INFINITY, false);\n    test(f64::NEGATIVE_INFINITY, false);\n    test(0.0, true);\n    test(-0.0, true);\n    test(123.0, true);\n    test(1.0e9, true);\n    test(4294967295.0, true);\n    test(4294967296.0, true);\n    test(18446744073709551615.0, true);\n    test(18446744073709551616.0, true);\n    test(1.0e20, true);\n    test(1.23e20, true);\n    test(1.0e100, true);\n    test(1.23e100, true);\n    test(123.1, false);\n    test(123.5, false);\n    test(124.5, false);\n    test(-0.99, false);\n    test(-0.499, false);\n    test(-0.5, false);\n    test(-123.0, false);\n    test(f64::MIN_POSITIVE, false);\n    test(f64::MAX_SUBNORMAL, false);\n    test(f64::MIN_POSITIVE_NORMAL, false);\n    test(f64::MAX_FINITE, true);\n}\n\n#[test]\nfn test_convertible_from_i64() {\n    let test = |i: i64, out| {\n        assert_eq!(Natural::convertible_from(i), out);\n    };\n    test(0, true);\n    test(123, true);\n    test(-123, false);\n    test(i64::MAX, true);\n    test(i64::MIN, false);\n}\n\nfn rounding_from_float_properties_helper<T: PrimitiveFloat + for<'a> RoundingFrom<&'a Natural>>()\nwhere\n    Natural: PartialOrd<T> + RoundingFrom<T>,\n{\n    primitive_float_rounding_mode_pair_gen_var_1::<T>().test_properties(|(f, rm)| {\n        let (n, o) = Natural::rounding_from(f, rm);\n        assert!(n.is_valid());\n        assert_eq!(n.partial_cmp(&f), Some(o));\n        match (f.is_sign_positive(), rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    primitive_float_gen_var_2::<T>().test_properties(|f| {\n        let no = Natural::rounding_from(f, Exact);\n        assert!(no.0.is_valid());\n        assert_eq!(no.1, Equal);\n        assert_eq!(no, Natural::rounding_from(f, Floor));\n        assert_eq!(no, Natural::rounding_from(f, Ceiling));\n        assert_eq!(no, Natural::rounding_from(f, Down));\n        assert_eq!(no, Natural::rounding_from(f, Up));\n        assert_eq!(no, Natural::rounding_from(f, Nearest));\n        let (f_alt, o) = T::rounding_from(&no.0, Exact);\n        assert_eq!(o, Equal);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n    });\n\n    primitive_float_gen_var_3::<T>().test_properties(|f| {\n        let n_floor = Natural::rounding_from(f, Floor);\n        assert!(n_floor.0.is_valid());\n        assert_eq!(n_floor.1, Less);\n        let n_ceiling = (&n_floor.0 + Natural::ONE, Greater);\n        assert_eq!(n_ceiling, Natural::rounding_from(f, Ceiling));\n        assert_eq!(n_floor, Natural::rounding_from(f, Down));\n        assert_eq!(n_ceiling, Natural::rounding_from(f, Up));\n        let n_nearest = Natural::rounding_from(f, Nearest);\n        assert!(n_nearest == n_floor || n_nearest == n_ceiling);\n    });\n\n    primitive_float_gen_var_4::<T>().test_properties(|f| {\n        let floor = Natural::rounding_from(f, Floor);\n        let ceiling = (&floor.0 + Natural::ONE, Greater);\n        let nearest = Natural::rounding_from(f, Nearest);\n        assert_eq!(nearest, if floor.0.even() { floor } else { ceiling });\n    });\n}\n\n#[test]\nfn rounding_from_float_properties() {\n    apply_fn_to_primitive_floats!(rounding_from_float_properties_helper);\n}\n\nfn try_from_float_properties_helper<T: PrimitiveFloat + for<'a> RoundingFrom<&'a Natural>>()\nwhere\n    Limb: TryFrom<NiceFloat<T>>,\n    Natural: TryFrom<T> + RoundingFrom<T>,\n    NiceFloat<T>: TryFrom<Limb>,\n{\n    primitive_float_gen::<T>().test_properties(|f| {\n        let on = Natural::try_from(f);\n        assert!(on.map_or(true, |n| n.is_valid()));\n        if let Ok(n) = Limb::try_from(NiceFloat(f)) {\n            assert_eq!(n, Natural::exact_from(f));\n        }\n    });\n\n    primitive_float_gen_var_2::<T>().test_properties(|f| {\n        let n = Natural::exact_from(f);\n        assert!(n.is_valid());\n        assert_eq!(n, Natural::rounding_from(f, Exact).0);\n        assert_eq!(NiceFloat(T::rounding_from(&n, Exact).0), NiceFloat(f));\n    });\n\n    primitive_float_gen_var_3::<T>().test_properties(|f| {\n        assert!(Natural::try_from(f).is_err());\n    });\n\n    primitive_float_gen_var_4::<T>().test_properties(|f| {\n        assert!(Natural::try_from(f).is_err());\n    });\n\n    primitive_float_gen_var_13::<T, Limb>().test_properties(|f| {\n        assert_eq!(Limb::exact_from(NiceFloat(f)), Natural::exact_from(f));\n    });\n}\n\n#[test]\nfn try_from_float_properties() {\n    apply_fn_to_primitive_floats!(try_from_float_properties_helper);\n}\n\nfn convertible_from_float_properties_helper<T: PrimitiveFloat>()\nwhere\n    Natural: ConvertibleFrom<T>,\n    Limb: ConvertibleFrom<T>,\n{\n    primitive_float_gen::<T>().test_properties(|f| {\n        let nc = Natural::convertible_from(f);\n        if Limb::convertible_from(f) {\n            assert!(nc);\n        }\n    });\n\n    primitive_float_gen_var_2::<T>().test_properties(|f| {\n        assert!(Natural::convertible_from(f));\n    });\n\n    primitive_float_gen_var_3::<T>().test_properties(|f| {\n        assert!(!Natural::convertible_from(f));\n    });\n\n    primitive_float_gen_var_4::<T>().test_properties(|f| {\n        assert!(!Natural::convertible_from(f));\n    });\n}\n\n#[test]\nfn convertible_from_float_properties() {\n    apply_fn_to_primitive_floats!(convertible_from_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, SaturatingFrom};\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_nz::natural::Natural;\nuse num::BigUint;\nuse rug;\n\n#[test]\nfn test_from_u32() {\n    let test = |u: u32, out| {\n        let x = Natural::from(u);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(BigUint::from(u).to_string(), out);\n        assert_eq!(rug::Integer::from(u).to_string(), out);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let x_alt = Natural::const_from(u);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(u32::MAX, \"4294967295\");\n}\n\n#[test]\nfn test_from_u64() {\n    let test = |u: u64, out| {\n        let x = Natural::from(u);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(BigUint::from(u).to_string(), out);\n        assert_eq!(rug::Integer::from(u).to_string(), out);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let x_alt = Natural::const_from(u);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(u64::MAX, \"18446744073709551615\");\n}\n\n#[test]\nfn test_try_from_i32() {\n    let test = |i: i32, out| {\n        let on = Natural::try_from(i);\n        assert!(on.as_ref().map_or(true, Natural::is_valid));\n        assert_eq!(on.to_debug_string(), out);\n    };\n    test(0, \"Ok(0)\");\n    test(123, \"Ok(123)\");\n    test(-123, \"Err(NaturalFromSignedError)\");\n    test(i32::MAX, \"Ok(2147483647)\");\n    test(i32::MIN, \"Err(NaturalFromSignedError)\");\n}\n\n#[test]\nfn test_exact_from_i32() {\n    let test = |i: i32, out| {\n        let x = Natural::exact_from(i);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(i32::MAX, \"2147483647\");\n}\n\n#[test]\n#[should_panic]\nfn exact_from_i32_fail_1() {\n    Natural::exact_from(-123i32);\n}\n\n#[test]\n#[should_panic]\nfn exact_from_i32_fail_2() {\n    Natural::exact_from(i32::MIN);\n}\n\n#[test]\nfn test_saturating_from_i32() {\n    let test = |i: i32, out| {\n        let x = Natural::saturating_from(i);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(-123, \"0\");\n    test(i32::MAX, \"2147483647\");\n    test(i32::MIN, \"0\");\n}\n\n#[test]\nfn test_convertible_from_i32() {\n    let test = |i: i32, out| {\n        assert_eq!(Natural::convertible_from(i), out);\n    };\n    test(0, true);\n    test(123, true);\n    test(-123, false);\n    test(i32::MAX, true);\n    test(i32::MIN, false);\n}\n\n#[test]\nfn test_try_from_i64() {\n    let test = |i: i64, out| {\n        let on = Natural::try_from(i);\n        assert!(on.as_ref().map_or(true, Natural::is_valid));\n        assert_eq!(on.to_debug_string(), out);\n    };\n    test(0, \"Ok(0)\");\n    test(123, \"Ok(123)\");\n    test(-123, \"Err(NaturalFromSignedError)\");\n    test(i64::MAX, \"Ok(9223372036854775807)\");\n    test(i64::MIN, \"Err(NaturalFromSignedError)\");\n}\n\n#[test]\nfn test_saturating_from_i64() {\n    let test = |i: i64, out| {\n        let x = Natural::saturating_from(i);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(-123, \"0\");\n    test(i64::MAX, \"9223372036854775807\");\n    test(i64::MIN, \"0\");\n}\n\n#[test]\nfn test_convertible_from_i64() {\n    let test = |i: i64, out| {\n        assert_eq!(Natural::convertible_from(i), out);\n    };\n    test(0, true);\n    test(123, true);\n    test(-123, false);\n    test(i64::MAX, true);\n    test(i64::MIN, false);\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn unsigned_properties<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n    for<'a> T: TryFrom<&'a Natural>,\n    u128: ExactFrom<T>,\n{\n    unsigned_gen::<T>().test_properties(|u| {\n        let n = Natural::from(u);\n        assert!(n.is_valid());\n        assert_eq!(T::exact_from(&n), u);\n        let n_alt: Natural = From::from(u128::exact_from(u));\n        assert_eq!(n_alt, n);\n    });\n}\n\n#[allow(clippy::type_repetition_in_bounds)]\nfn signed_properties<T: PrimitiveSigned>()\nwhere\n    Natural: TryFrom<T> + ConvertibleFrom<T> + SaturatingFrom<T>,\n    for<'a> T: TryFrom<&'a Natural>,\n    i128: ExactFrom<T>,\n{\n    signed_gen::<T>().test_properties(|i| {\n        let on = Natural::try_from(i);\n        assert!(on.as_ref().map_or(true, Natural::is_valid));\n        assert_eq!(on.is_ok(), i >= T::ZERO);\n        assert_eq!(Natural::convertible_from(i), i >= T::ZERO);\n        let n = Natural::saturating_from(i);\n        assert!(n.is_valid());\n        on.as_ref().map_or_else(\n            |_| {\n                assert_eq!(n, 0);\n            },\n            |x| {\n                assert_eq!(*x, n);\n                assert_eq!(T::exact_from(x), i);\n                let n_alt: Natural = ExactFrom::exact_from(i128::exact_from(i));\n                assert_eq!(n_alt, n);\n            },\n        );\n    });\n}\n\n#[test]\nfn from_primitive_int_properties() {\n    unsigned_gen::<u32>().test_properties(|u| {\n        let n = Natural::from(u);\n        assert_eq!(Natural::from(&BigUint::from(u)), n);\n        assert_eq!(Natural::exact_from(&rug::Integer::from(u)), n);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let n_alt = Natural::const_from(u);\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n\n    unsigned_gen::<u64>().test_properties(|u| {\n        let n = Natural::from(u);\n        assert_eq!(Natural::from(&BigUint::from(u)), n);\n        assert_eq!(Natural::exact_from(&rug::Integer::from(u)), n);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let n_alt = Natural::const_from(u);\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n\n    apply_fn_to_unsigneds!(unsigned_properties);\n    apply_fn_to_signeds!(signed_properties);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_is_integer() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().is_integer(), out);\n    };\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"100\", true);\n}\n\n#[test]\nfn is_integer_properties() {\n    natural_gen().test_properties(|n| {\n        assert!(n.is_integer());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/mantissa_and_exponent/integer_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::IntegerMantissaAndExponent;\nuse malachite_base::test_util::generators::unsigned_gen_var_1;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen_var_2, natural_unsigned_pair_gen_var_4};\nuse std::str::FromStr;\n\n#[test]\nfn test_integer_mantissa_and_exponent() {\n    let test = |s: &str, mantissa: &str, exponent: u64| {\n        let n = Natural::from_str(s).unwrap();\n        let mantissa = Natural::from_str(mantissa).unwrap();\n        let (actual_mantissa, actual_exponent) = n.integer_mantissa_and_exponent();\n        assert_eq!(actual_mantissa, mantissa);\n        assert_eq!(actual_exponent, exponent);\n        assert_eq!(n.integer_mantissa(), mantissa);\n        assert_eq!(n.integer_exponent(), exponent);\n    };\n    test(\"1\", \"1\", 0);\n    test(\"3\", \"3\", 0);\n    test(\"100\", \"25\", 2);\n    test(\"123\", \"123\", 0);\n}\n\n#[test]\n#[should_panic]\nfn integer_mantissa_and_exponent_fail() {\n    Natural::ZERO.integer_mantissa_and_exponent();\n}\n\n#[test]\nfn test_from_integer_mantissa_and_exponent() {\n    let test = |mantissa: &str, exponent: u64, out: Option<&str>| {\n        let mantissa = Natural::from_str(mantissa).unwrap();\n        assert_eq!(\n            <&Natural as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n                mantissa, exponent\n            ),\n            out.map(|s| Natural::from_str(s).unwrap())\n        );\n    };\n    test(\"0\", 5, Some(\"0\"));\n    test(\"1\", 0, Some(\"1\"));\n    test(\"3\", 0, Some(\"3\"));\n    test(\"25\", 2, Some(\"100\"));\n}\n\n#[test]\nfn integer_mantissa_and_exponent_properties() {\n    natural_gen_var_2().test_properties(|n| {\n        let (mantissa, exponent) = n.integer_mantissa_and_exponent();\n        assert_eq!(n.integer_mantissa(), mantissa);\n        assert_eq!(n.integer_exponent(), exponent);\n        assert!(mantissa.odd());\n        let n_alt = <&Natural as IntegerMantissaAndExponent::<Natural, u64, Natural>>\n            ::from_integer_mantissa_and_exponent(mantissa, exponent);\n        assert_eq!(n_alt.unwrap(), n);\n    });\n\n    unsigned_gen_var_1::<Limb>().test_properties(|x| {\n        let (mantissa_1, exponent_1) = x.integer_mantissa_and_exponent();\n        let (mantissa_2, exponent_2) = Natural::from(x).integer_mantissa_and_exponent();\n        assert_eq!(mantissa_1, mantissa_2);\n        assert_eq!(exponent_1, exponent_2);\n    });\n}\n\n#[test]\nfn from_integer_mantissa_and_exponent_properties() {\n    natural_unsigned_pair_gen_var_4::<u64>().test_properties(|(m, e)| {\n        let n =\n            <&Natural as IntegerMantissaAndExponent<_, _, _>>::from_integer_mantissa_and_exponent(\n                m.clone(),\n                e,\n            )\n            .unwrap();\n        if m.odd() {\n            assert_eq!(n.integer_mantissa_and_exponent(), (m, e));\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/mantissa_and_exponent/sci_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::mantissa_and_exponent::sci_mantissa_and_exponent_round;\nuse malachite_base::num::conversion::traits::SciMantissaAndExponent;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    primitive_float_unsigned_pair_gen_var_1, primitive_float_unsigned_pair_gen_var_2,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_1,\n    primitive_float_unsigned_rounding_mode_triple_gen_var_2, unsigned_gen_var_1,\n    unsigned_rounding_mode_pair_gen_var_1,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen_var_2, natural_rounding_mode_pair_gen_var_2,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_sci_mantissa_and_exponent() {\n    let test = |s: &str, mantissa: f32, exponent: u64| {\n        let n = Natural::from_str(s).unwrap();\n        let (actual_mantissa, actual_exponent) = n.sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(actual_mantissa), NiceFloat(mantissa));\n        assert_eq!(actual_exponent, exponent);\n        assert_eq!(NiceFloat(n.sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(\n            SciMantissaAndExponent::<f32, u64, Natural>::sci_exponent(&n),\n            exponent\n        );\n    };\n    test(\"3\", 1.5, 1);\n    test(\"123\", 1.921875, 6);\n    test(\"1000000000\", 1.8626451, 29);\n\n    test(\"16777216\", 1.0, 24);\n    test(\"16777218\", 1.0000001, 24);\n    test(\"16777217\", 1.0, 24);\n\n    test(\"33554432\", 1.0, 25);\n    test(\"33554436\", 1.0000001, 25);\n    test(\"33554440\", 1.0000002, 25);\n\n    test(\"33554433\", 1.0, 25);\n    test(\"33554434\", 1.0, 25);\n    test(\"33554435\", 1.0000001, 25);\n    test(\"33554437\", 1.0000001, 25);\n    test(\"33554438\", 1.0000002, 25);\n    test(\"33554439\", 1.0000002, 25);\n    test(\"340282346638528859811704183484516925439\", 1.9999999, 127);\n    test(\"340282346638528859811704183484516925440\", 1.9999999, 127);\n    test(\"340282346638528859811704183484516925441\", 1.9999999, 127);\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        1.670478,\n        172,\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        1.8920966,\n        458,\n    );\n}\n\n#[test]\nfn test_sci_mantissa_and_exponent_round() {\n    let test = |n: &str, rm: RoundingMode, out: Option<(f32, u64, Ordering)>| {\n        let actual_out = Natural::from_str(n)\n            .unwrap()\n            .sci_mantissa_and_exponent_round(rm);\n        assert_eq!(\n            actual_out.map(|(m, e, o)| (NiceFloat(m), e, o)),\n            out.map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    };\n    test(\"3\", Floor, Some((1.5, 1, Equal)));\n    test(\"3\", Down, Some((1.5, 1, Equal)));\n    test(\"3\", Ceiling, Some((1.5, 1, Equal)));\n    test(\"3\", Up, Some((1.5, 1, Equal)));\n    test(\"3\", Nearest, Some((1.5, 1, Equal)));\n    test(\"3\", Exact, Some((1.5, 1, Equal)));\n\n    test(\"123\", Floor, Some((1.921875, 6, Equal)));\n    test(\"123\", Down, Some((1.921875, 6, Equal)));\n    test(\"123\", Ceiling, Some((1.921875, 6, Equal)));\n    test(\"123\", Up, Some((1.921875, 6, Equal)));\n    test(\"123\", Nearest, Some((1.921875, 6, Equal)));\n    test(\"123\", Exact, Some((1.921875, 6, Equal)));\n\n    test(\"1000000000\", Floor, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Down, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Ceiling, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Up, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Nearest, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Exact, Some((1.8626451, 29, Equal)));\n\n    test(\"16777216\", Floor, Some((1.0, 24, Equal)));\n    test(\"16777216\", Down, Some((1.0, 24, Equal)));\n    test(\"16777216\", Ceiling, Some((1.0, 24, Equal)));\n    test(\"16777216\", Up, Some((1.0, 24, Equal)));\n    test(\"16777216\", Nearest, Some((1.0, 24, Equal)));\n    test(\"16777216\", Exact, Some((1.0, 24, Equal)));\n\n    test(\"16777218\", Floor, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Down, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Ceiling, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Up, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Nearest, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Exact, Some((1.0000001, 24, Equal)));\n\n    test(\"16777217\", Floor, Some((1.0, 24, Less)));\n    test(\"16777217\", Down, Some((1.0, 24, Less)));\n    test(\"16777217\", Ceiling, Some((1.0000001, 24, Greater)));\n    test(\"16777217\", Up, Some((1.0000001, 24, Greater)));\n    test(\"16777217\", Nearest, Some((1.0, 24, Less)));\n    test(\"16777217\", Exact, None);\n\n    test(\"33554432\", Floor, Some((1.0, 25, Equal)));\n    test(\"33554432\", Down, Some((1.0, 25, Equal)));\n    test(\"33554432\", Ceiling, Some((1.0, 25, Equal)));\n    test(\"33554432\", Up, Some((1.0, 25, Equal)));\n    test(\"33554432\", Nearest, Some((1.0, 25, Equal)));\n    test(\"33554432\", Exact, Some((1.0, 25, Equal)));\n\n    test(\"33554436\", Floor, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Down, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Ceiling, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Up, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Nearest, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Exact, Some((1.0000001, 25, Equal)));\n\n    test(\"33554440\", Floor, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Down, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Ceiling, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Up, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Nearest, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Exact, Some((1.0000002, 25, Equal)));\n\n    test(\"33554433\", Floor, Some((1.0, 25, Less)));\n    test(\"33554433\", Down, Some((1.0, 25, Less)));\n    test(\"33554433\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"33554433\", Up, Some((1.0000001, 25, Greater)));\n    test(\"33554433\", Nearest, Some((1.0, 25, Less)));\n    test(\"33554433\", Exact, None);\n\n    test(\"33554434\", Floor, Some((1.0, 25, Less)));\n    test(\"33554434\", Down, Some((1.0, 25, Less)));\n    test(\"33554434\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"33554434\", Up, Some((1.0000001, 25, Greater)));\n    test(\"33554434\", Nearest, Some((1.0, 25, Less)));\n    test(\"33554434\", Exact, None);\n\n    test(\"33554435\", Floor, Some((1.0, 25, Less)));\n    test(\"33554435\", Down, Some((1.0, 25, Less)));\n    test(\"33554435\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"33554435\", Up, Some((1.0000001, 25, Greater)));\n    test(\"33554435\", Nearest, Some((1.0000001, 25, Greater)));\n    test(\"33554435\", Exact, None);\n\n    test(\"33554437\", Floor, Some((1.0000001, 25, Less)));\n    test(\"33554437\", Down, Some((1.0000001, 25, Less)));\n    test(\"33554437\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"33554437\", Up, Some((1.0000002, 25, Greater)));\n    test(\"33554437\", Nearest, Some((1.0000001, 25, Less)));\n    test(\"33554437\", Exact, None);\n\n    test(\"33554438\", Floor, Some((1.0000001, 25, Less)));\n    test(\"33554438\", Down, Some((1.0000001, 25, Less)));\n    test(\"33554438\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"33554438\", Up, Some((1.0000002, 25, Greater)));\n    test(\"33554438\", Nearest, Some((1.0000002, 25, Greater)));\n    test(\"33554438\", Exact, None);\n\n    test(\"33554439\", Floor, Some((1.0000001, 25, Less)));\n    test(\"33554439\", Down, Some((1.0000001, 25, Less)));\n    test(\"33554439\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"33554439\", Up, Some((1.0000002, 25, Greater)));\n    test(\"33554439\", Nearest, Some((1.0000002, 25, Greater)));\n    test(\"33554439\", Exact, None);\n\n    test(\n        \"340282346638528859811704183484516925439\",\n        Floor,\n        Some((1.9999998, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Down,\n        Some((1.9999998, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Ceiling,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Up,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Nearest,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\"340282346638528859811704183484516925439\", Exact, None);\n\n    test(\n        \"340282346638528859811704183484516925440\",\n        Floor,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Down,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Ceiling,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Up,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Nearest,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Exact,\n        Some((1.9999999, 127, Equal)),\n    );\n\n    test(\n        \"340282346638528859811704183484516925441\",\n        Floor,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Down,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Ceiling,\n        Some((1.0, 128, Greater)),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Up,\n        Some((1.0, 128, Greater)),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Nearest,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\"340282346638528859811704183484516925441\", Exact, None);\n\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        Some((1.6704779, 172, Less)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Down,\n        Some((1.6704779, 172, Less)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Up,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Exact,\n        None,\n    );\n\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Floor,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Down,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Ceiling,\n        Some((1.8920968, 458, Greater)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Up,\n        Some((1.8920968, 458, Greater)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Nearest,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Exact,\n        None,\n    );\n\n    test(\n        \"115792089210356248957287600559322556832945588264647333956682042358504754249728\",\n        Floor,\n        Some((1.9999999, 255, Less)),\n    );\n    test(\n        \"115792089210356248957287600559322556832945588264647333956682042358504754249728\",\n        Ceiling,\n        Some((1.0, 256, Greater)),\n    );\n}\n\n#[test]\nfn test_from_sci_mantissa_and_exponent() {\n    let test = |mantissa: f32, exponent: u64, out: Option<&str>| {\n        assert_eq!(\n            <&Natural as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n                mantissa, exponent\n            ),\n            out.map(|s| Natural::from_str(s).unwrap())\n        );\n    };\n    test(1.5, 1, Some(\"3\"));\n    test(1.51, 1, Some(\"3\"));\n    test(1.921875, 6, Some(\"123\"));\n    test(\n        1.670478,\n        172,\n        Some(\"10000000254586612611935772707803116801852191350456320\"),\n    );\n\n    test(2.0, 1, None);\n    test(10.0, 1, None);\n    test(0.5, 1, None);\n}\n\nfn from_sci_mantissa_and_exponent_fail_helper<T: PrimitiveFloat>()\nwhere\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    assert_panic!(\n        <&Natural as SciMantissaAndExponent<T, u64, _>>::from_sci_mantissa_and_exponent(T::ZERO, 0)\n    );\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_fail() {\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_fail_helper);\n}\n\n#[test]\nfn test_from_sci_mantissa_and_exponent_round() {\n    let test = |mantissa: f32, exponent: u64, rm: RoundingMode, out: Option<(&str, Ordering)>| {\n        assert_eq!(\n            Natural::from_sci_mantissa_and_exponent_round(mantissa, exponent, rm),\n            out.map(|(s, o)| (Natural::from_str(s).unwrap(), o))\n        );\n    };\n    test(1.5, 1, Floor, Some((\"3\", Equal)));\n    test(1.5, 1, Down, Some((\"3\", Equal)));\n    test(1.5, 1, Ceiling, Some((\"3\", Equal)));\n    test(1.5, 1, Up, Some((\"3\", Equal)));\n    test(1.5, 1, Nearest, Some((\"3\", Equal)));\n    test(1.5, 1, Exact, Some((\"3\", Equal)));\n\n    test(1.51, 1, Floor, Some((\"3\", Less)));\n    test(1.51, 1, Down, Some((\"3\", Less)));\n    test(1.51, 1, Ceiling, Some((\"4\", Greater)));\n    test(1.51, 1, Up, Some((\"4\", Greater)));\n    test(1.51, 1, Nearest, Some((\"3\", Less)));\n    test(1.51, 1, Exact, None);\n\n    test(1.921875, 6, Floor, Some((\"123\", Equal)));\n    test(1.921875, 6, Down, Some((\"123\", Equal)));\n    test(1.921875, 6, Ceiling, Some((\"123\", Equal)));\n    test(1.921875, 6, Up, Some((\"123\", Equal)));\n    test(1.921875, 6, Nearest, Some((\"123\", Equal)));\n    test(1.921875, 6, Exact, Some((\"123\", Equal)));\n\n    test(\n        1.670478,\n        172,\n        Floor,\n        Some((\n            \"10000000254586612611935772707803116801852191350456320\",\n            Equal,\n        )),\n    );\n    test(\n        1.670478,\n        172,\n        Down,\n        Some((\n            \"10000000254586612611935772707803116801852191350456320\",\n            Equal,\n        )),\n    );\n    test(\n        1.670478,\n        172,\n        Ceiling,\n        Some((\n            \"10000000254586612611935772707803116801852191350456320\",\n            Equal,\n        )),\n    );\n    test(\n        1.670478,\n        172,\n        Up,\n        Some((\n            \"10000000254586612611935772707803116801852191350456320\",\n            Equal,\n        )),\n    );\n    test(\n        1.670478,\n        172,\n        Nearest,\n        Some((\n            \"10000000254586612611935772707803116801852191350456320\",\n            Equal,\n        )),\n    );\n    test(\n        1.670478,\n        172,\n        Exact,\n        Some((\n            \"10000000254586612611935772707803116801852191350456320\",\n            Equal,\n        )),\n    );\n\n    test(2.0, 1, Floor, None);\n    test(2.0, 1, Down, None);\n    test(2.0, 1, Ceiling, None);\n    test(2.0, 1, Up, None);\n    test(2.0, 1, Nearest, None);\n    test(2.0, 1, Exact, None);\n\n    test(10.0, 1, Floor, None);\n    test(10.0, 1, Down, None);\n    test(10.0, 1, Ceiling, None);\n    test(10.0, 1, Up, None);\n    test(10.0, 1, Nearest, None);\n    test(10.0, 1, Exact, None);\n\n    test(0.5, 1, Floor, None);\n    test(0.5, 1, Down, None);\n    test(0.5, 1, Ceiling, None);\n    test(0.5, 1, Up, None);\n    test(0.5, 1, Nearest, None);\n    test(0.5, 1, Exact, None);\n}\n\nfn sci_mantissa_and_exponent_properties_helper<T: PrimitiveFloat>()\nwhere\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n    Limb: SciMantissaAndExponent<T, u64>,\n{\n    natural_gen_var_2().test_properties(|n| {\n        let (mantissa, exponent) = n.sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(n.sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(n.sci_exponent(), exponent);\n        assert!(mantissa >= T::ONE);\n        assert!(mantissa < T::TWO);\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round(Nearest)\n                .map(|(m, e, _): (T, u64, Ordering)| (NiceFloat(m), e)),\n            Some((NiceFloat(mantissa), exponent))\n        );\n    });\n\n    unsigned_gen_var_1::<Limb>().test_properties(|x| {\n        let (mantissa_1, exponent_1) = x.sci_mantissa_and_exponent();\n        let (mantissa_2, exponent_2) = Natural::from(x).sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(mantissa_1), NiceFloat(mantissa_2));\n        assert_eq!(exponent_1, exponent_2);\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_properties() {\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_properties_helper);\n}\n\nfn sci_mantissa_and_exponent_round_properties_helper<T: PrimitiveFloat>() {\n    natural_rounding_mode_pair_gen_var_2().test_properties(|(n, rm)| {\n        if let Some((mantissa, exponent, o)) = n.sci_mantissa_and_exponent_round::<T>(rm) {\n            assert!(mantissa >= T::ONE);\n            assert!(mantissa < T::TWO);\n            if rm == Exact {\n                let n_alt = Natural::from_sci_mantissa_and_exponent_round(mantissa, exponent, rm)\n                    .unwrap()\n                    .0;\n                assert_eq!(n_alt, n);\n            }\n            match rm {\n                Floor | Down => assert_ne!(o, Greater),\n                Ceiling | Up => assert_ne!(o, Less),\n                Exact => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        let (floor_mantissa, floor_exponent, floor_o) =\n            n.sci_mantissa_and_exponent_round::<T>(Floor).unwrap();\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round::<T>(Down).unwrap(),\n            (floor_mantissa, floor_exponent, floor_o)\n        );\n        let (ceiling_mantissa, ceiling_exponent, ceiling_o) =\n            n.sci_mantissa_and_exponent_round::<T>(Ceiling).unwrap();\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round::<T>(Up).unwrap(),\n            (ceiling_mantissa, ceiling_exponent, ceiling_o)\n        );\n        let (nearest_mantissa, nearest_exponent, nearest_o) =\n            n.sci_mantissa_and_exponent_round::<T>(Nearest).unwrap();\n        if let Some((mantissa, exponent, o)) = n.sci_mantissa_and_exponent_round::<T>(Exact) {\n            assert_eq!(floor_mantissa, mantissa);\n            assert_eq!(ceiling_mantissa, mantissa);\n            assert_eq!(nearest_mantissa, mantissa);\n            assert_eq!(floor_exponent, exponent);\n            assert_eq!(ceiling_exponent, exponent);\n            assert_eq!(nearest_exponent, exponent);\n            assert_eq!(o, Equal);\n            assert_eq!(floor_o, Equal);\n            assert_eq!(ceiling_o, Equal);\n            assert_eq!(nearest_o, Equal);\n        } else {\n            assert_eq!(floor_o, Less);\n            assert_eq!(ceiling_o, Greater);\n            assert_ne!(\n                (floor_mantissa, floor_exponent),\n                (ceiling_mantissa, ceiling_exponent)\n            );\n            assert!(\n                (nearest_mantissa, nearest_exponent) == (floor_mantissa, floor_exponent)\n                    || (nearest_mantissa, nearest_exponent) == (ceiling_mantissa, ceiling_exponent)\n            );\n            if ceiling_mantissa == T::ONE {\n                assert_eq!(floor_mantissa, T::TWO.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent - 1);\n            } else {\n                assert_eq!(floor_mantissa, ceiling_mantissa.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent);\n            }\n        }\n    });\n\n    unsigned_rounding_mode_pair_gen_var_1::<Limb>().test_properties(|(x, rm)| {\n        assert_eq!(\n            sci_mantissa_and_exponent_round::<Limb, T>(x, rm).map(|(m, e, o)| (NiceFloat(m), e, o)),\n            Natural::from(x)\n                .sci_mantissa_and_exponent_round(rm)\n                .map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_round_properties() {\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_round_properties_helper);\n}\n\nfn from_sci_mantissa_and_exponent_properties_helper<T: PrimitiveFloat>()\nwhere\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    primitive_float_unsigned_pair_gen_var_1::<T, u64>().test_properties(|(m, e)| {\n        let on =\n            <&Natural as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e);\n        assert_eq!(on.is_some(), m >= T::ONE && m < T::TWO);\n    });\n\n    primitive_float_unsigned_pair_gen_var_2::<T>().test_properties(|(m, e)| {\n        let n = <&Natural as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e)\n            .unwrap();\n        assert!(m >= T::ONE && m < T::TWO);\n        assert_eq!(\n            Natural::from_sci_mantissa_and_exponent_round(m, e, Nearest)\n                .unwrap()\n                .0,\n            n\n        );\n    });\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_properties() {\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_properties_helper);\n}\n\nfn from_sci_mantissa_and_exponent_round_properties_helper<T: PrimitiveFloat>() {\n    primitive_float_unsigned_rounding_mode_triple_gen_var_1::<T, u64>().test_properties(\n        |(m, e, rm)| {\n            let on = Natural::from_sci_mantissa_and_exponent_round(m, e, rm);\n            if let Some((_, o)) = on {\n                assert!(m >= T::ONE && m < T::TWO);\n                match rm {\n                    Floor | Down => assert_ne!(o, Greater),\n                    Ceiling | Up => assert_ne!(o, Less),\n                    Exact => assert_eq!(o, Equal),\n                    _ => {}\n                }\n            } else {\n                assert!(m < T::ONE || m >= T::TWO || rm == Exact);\n            }\n        },\n    );\n\n    primitive_float_unsigned_rounding_mode_triple_gen_var_2::<T>().test_properties(|(m, e, rm)| {\n        assert!(m >= T::ONE && m < T::TWO);\n        let on = Natural::from_sci_mantissa_and_exponent_round(m, e, rm);\n        if on.is_none() {\n            assert_eq!(rm, Exact);\n        }\n    });\n\n    primitive_float_unsigned_pair_gen_var_2::<T>().test_properties(|(m, e)| {\n        let floor_n = Natural::from_sci_mantissa_and_exponent_round(m, e, Floor).unwrap();\n        assert_eq!(\n            Natural::from_sci_mantissa_and_exponent_round(m, e, Down).unwrap(),\n            floor_n\n        );\n        let ceiling_n = Natural::from_sci_mantissa_and_exponent_round(m, e, Ceiling).unwrap();\n        assert_eq!(\n            Natural::from_sci_mantissa_and_exponent_round(m, e, Up).unwrap(),\n            ceiling_n\n        );\n        let nearest_n = Natural::from_sci_mantissa_and_exponent_round(m, e, Nearest).unwrap();\n        if let Some(n) = Natural::from_sci_mantissa_and_exponent_round(m, e, Exact) {\n            assert_eq!(floor_n, n);\n            assert_eq!(ceiling_n, n);\n            assert_eq!(nearest_n, n);\n        } else {\n            assert!(nearest_n == floor_n || nearest_n == ceiling_n);\n            assert_eq!(ceiling_n, (floor_n.0 + Natural::ONE, Greater));\n        }\n    });\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_round_properties() {\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_round_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/primitive_float_from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_18, unsigned_rounding_mode_pair_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::primitive_float_from_natural::PrimitiveFloatFromNaturalError;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_gen_var_3, natural_gen_var_4, natural_gen_var_5,\n    natural_rounding_mode_pair_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_f32_rounding_from_natural() {\n    let test = |n: &str, rm: RoundingMode, out, o_out| {\n        let (x, o) = f32::rounding_from(&Natural::from_str(n).unwrap(), rm);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n        assert_eq!(o, o_out);\n    };\n    test(\"3\", Exact, 3.0, Equal);\n    test(\"123\", Exact, 123.0, Equal);\n    test(\"0\", Exact, 0.0, Equal);\n    test(\"1000000000\", Exact, 1.0e9, Equal);\n    test(\"16777216\", Exact, 1.6777216e7, Equal);\n    test(\"16777218\", Exact, 1.6777218e7, Equal);\n\n    test(\"16777217\", Floor, 1.6777216e7, Less);\n    test(\"16777217\", Down, 1.6777216e7, Less);\n    test(\"16777217\", Ceiling, 1.6777218e7, Greater);\n    test(\"16777217\", Up, 1.6777218e7, Greater);\n    test(\"16777217\", Nearest, 1.6777216e7, Less);\n\n    test(\"33554432\", Exact, 3.3554432e7, Equal);\n    test(\"33554436\", Exact, 3.3554436e7, Equal);\n\n    test(\"33554433\", Floor, 3.3554432e7, Less);\n    test(\"33554433\", Down, 3.3554432e7, Less);\n    test(\"33554433\", Ceiling, 3.3554436e7, Greater);\n    test(\"33554433\", Up, 3.3554436e7, Greater);\n    test(\"33554433\", Nearest, 3.3554432e7, Less);\n\n    test(\"33554434\", Nearest, 3.3554432e7, Less);\n    test(\"33554435\", Nearest, 3.3554436e7, Greater);\n\n    test(\n        \"340282346638528859811704183484516925439\",\n        Floor,\n        3.4028233e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Down,\n        3.4028233e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Ceiling,\n        3.4028235e38,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Up,\n        3.4028235e38,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Nearest,\n        3.4028235e38,\n        Greater,\n    );\n\n    test(\n        \"340282346638528859811704183484516925440\",\n        Exact,\n        3.4028235e38,\n        Equal,\n    );\n\n    test(\n        \"340282346638528859811704183484516925441\",\n        Floor,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Down,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Nearest,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Ceiling,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Up,\n        f32::INFINITY,\n        Greater,\n    );\n\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Down,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Up,\n        f32::INFINITY,\n        Greater,\n    );\n\n    test(\"1125899873419263\", Floor, 1.12589984e15, Less);\n    test(\"1125899873419263\", Down, 1.12589984e15, Less);\n    test(\"1125899873419263\", Ceiling, 1.1258999e15, Greater);\n    test(\"1125899873419263\", Up, 1.1258999e15, Greater);\n    test(\"1125899873419263\", Nearest, 1.1258999e15, Greater);\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_natural_fail_1() {\n    f32::rounding_from(\n        &Natural::from_str(\"340282346638528859811704183484516925439\").unwrap(),\n        Exact,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_natural_fail_2() {\n    f32::rounding_from(\n        &Natural::from_str(\"340282346638528859811704183484516925441\").unwrap(),\n        Exact,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_natural_fail_3() {\n    f32::rounding_from(&Natural::from_str(\"16777217\").unwrap(), Exact);\n}\n\n#[test]\n#[should_panic]\nfn f32_rounding_from_natural_fail_4() {\n    f32::rounding_from(\n        &Natural::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n        Exact,\n    );\n}\n\n#[test]\nfn test_f64_rounding_from_natural() {\n    let test = |n: &str, rm: RoundingMode, out, o_out| {\n        let (x, o) = f64::rounding_from(&Natural::from_str(n).unwrap(), rm);\n        assert_eq!(NiceFloat(x), NiceFloat(out));\n        assert_eq!(o, o_out);\n    };\n    test(\"3\", Exact, 3.0, Equal);\n    test(\"123\", Exact, 123.0, Equal);\n    test(\"0\", Exact, 0.0, Equal);\n    test(\"100000000000000000000\", Exact, 1.0e20, Equal);\n    test(\"9007199254740992\", Exact, 9.007199254740992e15, Equal);\n    test(\"9007199254740994\", Exact, 9.007199254740994e15, Equal);\n    test(\"9007199254740993\", Floor, 9.007199254740992e15, Less);\n\n    test(\"9007199254740993\", Down, 9.007199254740992e15, Less);\n    test(\"9007199254740993\", Ceiling, 9.007199254740994e15, Greater);\n    test(\"9007199254740993\", Up, 9.007199254740994e15, Greater);\n    test(\"9007199254740993\", Nearest, 9.007199254740992e15, Less);\n\n    test(\"18014398509481984\", Exact, 1.8014398509481984e16, Equal);\n    test(\"18014398509481988\", Exact, 1.8014398509481988e16, Equal);\n\n    test(\"18014398509481985\", Floor, 1.8014398509481984e16, Less);\n    test(\"18014398509481985\", Down, 1.8014398509481984e16, Less);\n    test(\"18014398509481985\", Ceiling, 1.8014398509481988e16, Greater);\n    test(\"18014398509481985\", Up, 1.8014398509481988e16, Greater);\n    test(\"18014398509481985\", Nearest, 1.8014398509481984e16, Less);\n    test(\"18014398509481986\", Nearest, 1.8014398509481984e16, Less);\n    test(\"18014398509481987\", Nearest, 1.8014398509481988e16, Greater);\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Floor,\n        1.7976931348623155e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Down,\n        1.7976931348623155e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Ceiling,\n        1.7976931348623157e308,\n        Greater,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Up,\n        1.7976931348623157e308,\n        Greater,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Nearest,\n        1.7976931348623157e308,\n        Greater,\n    );\n\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        Exact,\n        1.7976931348623157e308,\n        Equal,\n    );\n\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Floor,\n        1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Down,\n        1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Nearest,\n        1.7976931348623157e308,\n        Less,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Ceiling,\n        f64::INFINITY,\n        Greater,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Up,\n        f64::INFINITY,\n        Greater,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f64_rounding_from_natural_fail_1() {\n    f64::rounding_from(&Natural::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap(),\n                       Exact);\n}\n\n#[test]\n#[should_panic]\nfn f64_rounding_from_natural_fail_2() {\n    f64::rounding_from(&Natural::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap(),\n                       Exact);\n}\n\n#[test]\n#[should_panic]\nfn f64_rounding_from_natural_fail_3() {\n    f64::rounding_from(&Natural::from_str(\"9007199254740993\").unwrap(), Exact);\n}\n\n#[test]\nfn test_f32_try_from_natural() {\n    let test = |n: &str, out: Result<f32, PrimitiveFloatFromNaturalError>| {\n        assert_eq!(\n            f32::try_from(&Natural::from_str(n).unwrap()).map(NiceFloat),\n            out.map(NiceFloat)\n        );\n    };\n    test(\"3\", Ok(3.0));\n    test(\"123\", Ok(123.0));\n    test(\"0\", Ok(0.0));\n    test(\"1000000000\", Ok(1.0e9));\n    test(\"16777216\", Ok(1.6777216e7));\n    test(\"16777218\", Ok(1.6777218e7));\n    test(\"16777217\", Err(PrimitiveFloatFromNaturalError));\n    test(\"33554432\", Ok(3.3554432e7));\n    test(\"33554436\", Ok(3.3554436e7));\n    test(\"33554433\", Err(PrimitiveFloatFromNaturalError));\n    test(\"33554434\", Err(PrimitiveFloatFromNaturalError));\n    test(\"33554435\", Err(PrimitiveFloatFromNaturalError));\n    test(\n        \"340282346638528859811704183484516925439\",\n        Err(PrimitiveFloatFromNaturalError),\n    );\n    test(\"340282346638528859811704183484516925440\", Ok(3.4028235e38));\n    test(\n        \"340282346638528859811704183484516925441\",\n        Err(PrimitiveFloatFromNaturalError),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Err(PrimitiveFloatFromNaturalError),\n    );\n}\n\n#[test]\nfn test_f64_try_from_natural() {\n    let test = |n: &str, out: Result<f64, PrimitiveFloatFromNaturalError>| {\n        assert_eq!(\n            f64::try_from(&Natural::from_str(n).unwrap()).map(NiceFloat),\n            out.map(NiceFloat)\n        );\n    };\n    test(\"3\", Ok(3.0));\n    test(\"123\", Ok(123.0));\n    test(\"0\", Ok(0.0));\n    test(\"1000000000\", Ok(1.0e9));\n    test(\"9007199254740992\", Ok(9.007199254740992e15));\n    test(\"9007199254740994\", Ok(9.007199254740994e15));\n    test(\"9007199254740993\", Err(PrimitiveFloatFromNaturalError));\n    test(\"18014398509481984\", Ok(1.8014398509481984e16));\n    test(\"18014398509481988\", Ok(1.8014398509481988e16));\n    test(\"18014398509481985\", Err(PrimitiveFloatFromNaturalError));\n    test(\"18014398509481986\", Err(PrimitiveFloatFromNaturalError));\n    test(\"18014398509481987\", Err(PrimitiveFloatFromNaturalError));\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Err(PrimitiveFloatFromNaturalError),\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        Ok(1.7976931348623157e308),\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Err(PrimitiveFloatFromNaturalError),\n    );\n}\n\n#[test]\nfn test_f32_exact_from_natural() {\n    let test = |n: &str, out| {\n        assert_eq!(\n            NiceFloat(f32::exact_from(&Natural::from_str(n).unwrap())),\n            NiceFloat(out)\n        );\n    };\n    test(\"3\", 3.0);\n    test(\"123\", 123.0);\n    test(\"0\", 0.0);\n    test(\"1000000000\", 1.0e9);\n    test(\"16777216\", 1.6777216e7);\n    test(\"16777218\", 1.6777218e7);\n    test(\"33554432\", 3.3554432e7);\n    test(\"33554436\", 3.3554436e7);\n    test(\"340282346638528859811704183484516925440\", 3.4028235e38);\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_natural_fail_1() {\n    f32::exact_from(&Natural::from_str(\"9007199254740993\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_natural_fail_2() {\n    f32::exact_from(&Natural::from_str(\"18014398509481985\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_natural_fail_3() {\n    f32::exact_from(&Natural::from_str(\"18014398509481986\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_natural_fail_4() {\n    f32::exact_from(&Natural::from_str(\"18014398509481987\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_natural_fail_5() {\n    f32::exact_from(&Natural::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f32_exact_from_natural_fail_6() {\n    f32::exact_from(&Natural::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap());\n}\n\n#[test]\nfn test_f64_exact_from_natural() {\n    let test = |n: &str, out| {\n        assert_eq!(\n            NiceFloat(f64::exact_from(&Natural::from_str(n).unwrap())),\n            NiceFloat(out)\n        );\n    };\n    test(\"3\", 3.0);\n    test(\"123\", 123.0);\n    test(\"0\", 0.0);\n    test(\"1000000000\", 1.0e9);\n    test(\"9007199254740992\", 9.007199254740992e15);\n    test(\"9007199254740994\", 9.007199254740994e15);\n    test(\"18014398509481984\", 1.8014398509481984e16);\n    test(\"18014398509481988\", 1.8014398509481988e16);\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        1.7976931348623157e308,\n    );\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_natural_fail_1() {\n    f64::exact_from(&Natural::from_str(\"9007199254740993\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_natural_fail_2() {\n    f64::exact_from(&Natural::from_str(\"18014398509481985\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_natural_fail_3() {\n    f64::exact_from(&Natural::from_str(\"18014398509481986\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_natural_fail_4() {\n    f64::exact_from(&Natural::from_str(\"18014398509481987\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_natural_fail_5() {\n    f64::exact_from(&Natural::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn f64_exact_from_natural_fail_6() {\n    f64::exact_from(&Natural::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap());\n}\n\n#[test]\nfn test_f32_convertible_from_natural() {\n    let test = |n: &str, out| {\n        assert_eq!(f32::convertible_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"3\", true);\n    test(\"123\", true);\n    test(\"0\", true);\n    test(\"1000000000\", true);\n    test(\"16777216\", true);\n    test(\"16777218\", true);\n    test(\"16777217\", false);\n    test(\"33554432\", true);\n    test(\"33554436\", true);\n    test(\"33554433\", false);\n    test(\"33554434\", false);\n    test(\"33554435\", false);\n    test(\"340282346638528859811704183484516925439\", false);\n    test(\"340282346638528859811704183484516925440\", true);\n    test(\"340282346638528859811704183484516925441\", false);\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        false,\n    );\n}\n\n#[test]\nfn test_f64_convertible_from_natural() {\n    let test = |n: &str, out| {\n        assert_eq!(f64::convertible_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"3\", true);\n    test(\"123\", true);\n    test(\"0\", true);\n    test(\"1000000000\", true);\n    test(\"9007199254740992\", true);\n    test(\"9007199254740994\", true);\n    test(\"9007199254740993\", false);\n    test(\"18014398509481984\", true);\n    test(\"18014398509481988\", true);\n    test(\"18014398509481985\", false);\n    test(\"18014398509481986\", false);\n    test(\"18014398509481987\", false);\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        false,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        true,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        false,\n    );\n}\n\nfn float_rounding_from_natural_properties_helper<\n    T: for<'a> TryFrom<&'a Natural>\n        + for<'a> ConvertibleFrom<&'a Natural>\n        + PartialOrd<Natural>\n        + PrimitiveFloat\n        + for<'a> RoundingFrom<&'a Natural>,\n>()\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError> + RoundingFrom<T>,\n{\n    natural_rounding_mode_pair_gen_var_1::<T>().test_properties(|(n, rm)| {\n        let o = T::rounding_from(&n, rm).1;\n        match rm {\n            Floor | Down => assert_ne!(o, Greater),\n            Ceiling | Up => assert_ne!(o, Less),\n            Exact => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    natural_gen_var_3::<T>().test_properties(|n| {\n        let (f, o) = T::rounding_from(&n, Exact);\n        assert_eq!(o, Equal);\n        let fo = (NiceFloat(f), o);\n        let (f_alt, o_alt) = T::rounding_from(&n, Floor);\n        assert_eq!((NiceFloat(f_alt), o_alt), fo);\n        let (f_alt, o_alt) = T::rounding_from(&n, Ceiling);\n        assert_eq!((NiceFloat(f_alt), o_alt), fo);\n        let (f_alt, o_alt) = T::rounding_from(&n, Down);\n        assert_eq!((NiceFloat(f_alt), o_alt), fo);\n        let (f_alt, o_alt) = T::rounding_from(&n, Up);\n        assert_eq!((NiceFloat(f_alt), o_alt), fo);\n        let (f_alt, o_alt) = T::rounding_from(&n, Nearest);\n        assert_eq!((NiceFloat(f_alt), o_alt), fo);\n        assert_eq!(Natural::rounding_from(f, Exact), (n, Equal));\n    });\n\n    natural_gen_var_4::<T>().test_properties(|n| {\n        let f_below = T::rounding_from(&n, Floor);\n        assert_eq!(f_below.1, Less);\n        let f_above = (NiceFloat(f_below.0.next_higher()), Greater);\n        let f_below = (NiceFloat(f_below.0), f_below.1);\n        let (f, o) = T::rounding_from(&n, Ceiling);\n        assert_eq!((NiceFloat(f), o), f_above);\n        let (f, o) = T::rounding_from(&n, Down);\n        assert_eq!((NiceFloat(f), o), f_below);\n        let (f, o) = T::rounding_from(&n, Up);\n        assert_eq!((NiceFloat(f), o), f_above);\n        let f_nearest = T::rounding_from(&n, Nearest);\n        let f_nearest = (NiceFloat(f_nearest.0), f_nearest.1);\n        assert!(f_nearest == f_below || f_nearest == f_above);\n    });\n\n    natural_gen_var_5::<T>().test_properties(|n| {\n        let floor = T::rounding_from(&n, Floor);\n        assert_eq!(floor.1, Less);\n        let ceiling = (NiceFloat(floor.0.next_higher()), Greater);\n        let floor = (NiceFloat(floor.0), floor.1);\n        let nearest = T::rounding_from(&n, Nearest);\n        let nearest = (NiceFloat(nearest.0), nearest.1);\n        assert_eq!(\n            nearest,\n            if floor.0.0.to_bits().even() {\n                floor\n            } else {\n                ceiling\n            }\n        );\n    });\n\n    unsigned_rounding_mode_pair_gen_var_2::<Limb, T>().test_properties(|(u, rm)| {\n        let n: Natural = From::from(u);\n        let (f, o) = T::rounding_from(u, rm);\n        let (f_alt, o_alt) = T::rounding_from(&n, rm);\n        assert_eq!(NiceFloat(f), NiceFloat(f_alt));\n        assert_eq!(o, o_alt);\n        assert_eq!(f.partial_cmp(&n), Some(o));\n    });\n}\n\n#[test]\nfn float_rounding_from_natural_properties() {\n    apply_fn_to_primitive_floats!(float_rounding_from_natural_properties_helper);\n}\n\nfn float_try_from_natural_properties_helper<\n    T: for<'a> TryFrom<&'a Natural>\n        + for<'a> ConvertibleFrom<&'a Natural>\n        + PrimitiveFloat\n        + for<'a> RoundingFrom<&'a Natural>,\n>()\nwhere\n    Limb: RoundingFrom<T>,\n    Natural: TryFrom<T, Error = UnsignedFromFloatError> + RoundingFrom<T>,\n    NiceFloat<T>: TryFrom<Limb>,\n{\n    natural_gen().test_properties(|n| {\n        T::try_from(&n).ok();\n    });\n\n    natural_gen_var_3::<T>().test_properties(|n| {\n        let f = T::exact_from(&n);\n        assert_eq!(NiceFloat(f), NiceFloat(T::rounding_from(&n, Exact).0));\n        assert_eq!(Natural::rounding_from(f, Exact).0, n);\n    });\n\n    natural_gen_var_4::<T>().test_properties(|n| {\n        assert!(T::try_from(&n).is_err());\n    });\n\n    natural_gen_var_5::<T>().test_properties(|n| {\n        assert!(T::try_from(&n).is_err());\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        if let Ok(f) = NiceFloat::<T>::try_from(u) {\n            let n: Natural = From::from(u);\n            assert_eq!(f, NiceFloat(T::exact_from(&n)));\n        }\n    });\n\n    unsigned_gen_var_18::<Limb, T>().test_properties(|u| {\n        let n: Natural = From::from(u);\n        assert_eq!(NiceFloat::<T>::exact_from(u), NiceFloat(T::exact_from(&n)));\n    });\n}\n\n#[test]\nfn float_try_from_natural_properties() {\n    apply_fn_to_primitive_floats!(float_try_from_natural_properties_helper);\n}\n\nfn float_convertible_from_natural_properties_helper<\n    T: for<'a> TryFrom<&'a Natural> + for<'a> ConvertibleFrom<&'a Natural> + PrimitiveFloat,\n>()\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n{\n    natural_gen().test_properties(|n| {\n        T::convertible_from(&n);\n    });\n\n    natural_gen_var_3::<T>().test_properties(|n| {\n        assert!(T::convertible_from(&n));\n    });\n\n    natural_gen_var_4::<T>().test_properties(|n| {\n        assert!(!T::convertible_from(&n));\n    });\n\n    natural_gen_var_5::<T>().test_properties(|n| {\n        assert!(!T::convertible_from(&n));\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        let n: Natural = From::from(u);\n        assert_eq!(T::convertible_from(u), T::convertible_from(&n));\n    });\n}\n\n#[test]\nfn float_convertible_from_natural_properties() {\n    apply_fn_to_primitive_floats!(float_convertible_from_natural_properties_helper);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/primitive_int_from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::ModPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, OverflowingFrom, SaturatingFrom, WrappingFrom,\n};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::primitive_int_from_natural::{\n    SignedFromNaturalError, UnsignedFromNaturalError,\n};\nuse malachite_nz::test_util::generators::natural_gen;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_u32_try_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u32::try_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .to_u32()\n                .ok_or(UnsignedFromNaturalError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000\", Err(UnsignedFromNaturalError));\n    test(\"4294967295\", Ok(u32::MAX));\n    test(\"4294967296\", Err(UnsignedFromNaturalError));\n}\n\n#[test]\nfn test_u32_exact_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u32::exact_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_u32().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"4294967295\", u32::MAX);\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_natural_fail_1() {\n    u32::exact_from(&Natural::from_str(\"1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u32_exact_from_natural_fail_2() {\n    u32::exact_from(&Natural::from_str(\"4294967296\").unwrap());\n}\n\n#[test]\nfn test_u32_wrapping_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u32::wrapping_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_u32_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", 3567587328);\n    test(\"4294967296\", 0);\n    test(\"4294967297\", 1);\n}\n\n#[test]\nfn test_u32_saturating_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u32::saturating_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", u32::MAX);\n    test(\"4294967296\", u32::MAX);\n    test(\"4294967297\", u32::MAX);\n}\n\n#[test]\nfn test_u32_overflowing_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u32::overflowing_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000\", (3567587328, true));\n    test(\"4294967296\", (0, true));\n    test(\"4294967297\", (1, true));\n}\n\n#[test]\nfn test_u32_convertible_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u32::convertible_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000\", false);\n    test(\"4294967295\", true);\n    test(\"4294967296\", false);\n}\n\n#[test]\nfn test_u64_try_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u64::try_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .to_u64()\n                .ok_or(UnsignedFromNaturalError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000\", Ok(1000000000000));\n    test(\"1000000000000000000000000\", Err(UnsignedFromNaturalError));\n    test(\"18446744073709551615\", Ok(u64::MAX));\n    test(\"18446744073709551616\", Err(UnsignedFromNaturalError));\n}\n\n#[test]\nfn test_u64_exact_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u64::exact_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_u64().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", 1000000000000);\n    test(\"18446744073709551615\", u64::MAX);\n}\n\n#[test]\n#[should_panic]\nfn u64_exact_from_natural_fail_1() {\n    u64::exact_from(&Natural::from_str(\"1000000000000000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn u64_exact_from_natural_fail_2() {\n    u64::exact_from(&Natural::from_str(\"18446744073709551616\").unwrap());\n}\n\n#[test]\nfn test_u64_wrapping_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u64::wrapping_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_u64_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", 2003764205206896640);\n    test(\"18446744073709551616\", 0);\n    test(\"18446744073709551617\", 1);\n}\n\n#[test]\nfn test_u64_saturating_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u64::saturating_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", u64::MAX);\n    test(\"18446744073709551616\", u64::MAX);\n    test(\"18446744073709551617\", u64::MAX);\n}\n\n#[test]\nfn test_u64_overflowing_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u64::overflowing_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000000000000000\", (2003764205206896640, true));\n    test(\"18446744073709551616\", (0, true));\n    test(\"18446744073709551617\", (1, true));\n}\n\n#[test]\nfn test_u64_convertible_from_natural() {\n    let test = |n, out| {\n        assert_eq!(u64::convertible_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000000000000000\", false);\n    test(\"18446744073709551615\", true);\n    test(\"18446744073709551616\", false);\n}\n\n#[test]\nfn test_i32_try_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i32::try_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .to_i32()\n                .ok_or(SignedFromNaturalError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000\", Err(SignedFromNaturalError));\n    test(\"2147483647\", Ok(i32::MAX));\n    test(\"2147483648\", Err(SignedFromNaturalError));\n}\n\n#[test]\nfn test_i32_exact_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i32::exact_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_i32().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"2147483647\", i32::MAX);\n}\n\n#[test]\n#[should_panic]\nfn i32_exact_from_natural_fail_1() {\n    i32::exact_from(&Natural::from_str(\"1000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i32_exact_from_natural_fail_2() {\n    i32::exact_from(&Natural::from_str(\"2147483648\").unwrap());\n}\n\n#[test]\nfn test_i32_wrapping_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i32::wrapping_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_i32_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", -727379968);\n    test(\"2147483648\", -0x80000000);\n    test(\"2147483649\", -0x7fffffff);\n}\n\n#[test]\nfn test_i32_saturating_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i32::saturating_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000\", 0x7fffffff);\n    test(\"2147483648\", 0x7fffffff);\n    test(\"2147483649\", 0x7fffffff);\n}\n\n#[test]\nfn test_i32_overflowing_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i32::overflowing_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000\", (-727379968, true));\n    test(\"2147483648\", (-0x80000000, true));\n    test(\"2147483649\", (-0x7fffffff, true));\n}\n\n#[test]\nfn test_i32_convertible_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i32::convertible_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000\", false);\n    test(\"2147483647\", true);\n    test(\"2147483648\", false);\n}\n\n#[test]\nfn test_i64_try_from_natural() {\n    let test = |n, out: Result<i64, SignedFromNaturalError>| {\n        assert_eq!(i64::try_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .to_i64()\n                .ok_or(SignedFromNaturalError),\n            out\n        );\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"1000000000000000000000000\", Err(SignedFromNaturalError));\n    test(\"9223372036854775807\", Ok(i64::MAX));\n    test(\"9223372036854775808\", Err(SignedFromNaturalError));\n}\n\n#[test]\nfn test_i64_exact_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i64::exact_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_i64().unwrap(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"9223372036854775807\", i64::MAX);\n}\n\n#[test]\n#[should_panic]\nfn i64_exact_from_natural_fail_1() {\n    i64::exact_from(&Natural::from_str(\"1000000000000000000000000\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn i64_exact_from_natural_fail_2() {\n    i64::exact_from(&Natural::from_str(\"9223372036854775808\").unwrap());\n}\n\n#[test]\nfn test_i64_wrapping_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i64::wrapping_from(&Natural::from_str(n).unwrap()), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().to_i64_wrapping(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", 2003764205206896640);\n    test(\"9223372036854775808\", -0x8000000000000000);\n    test(\"9223372036854775809\", -0x7fffffffffffffff);\n}\n\n#[test]\nfn test_i64_saturating_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i64::saturating_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 123);\n    test(\"1000000000000000000000000\", 0x7fffffffffffffff);\n    test(\"9223372036854775808\", 0x7fffffffffffffff);\n    test(\"9223372036854775809\", 0x7fffffffffffffff);\n}\n\n#[test]\nfn test_i64_overflowing_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i64::overflowing_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", (0, false));\n    test(\"123\", (123, false));\n    test(\"1000000000000000000000000\", (2003764205206896640, true));\n    test(\"9223372036854775808\", (-0x8000000000000000, true));\n    test(\"9223372036854775809\", (-0x7fffffffffffffff, true));\n}\n\n#[test]\nfn test_i64_convertible_from_natural() {\n    let test = |n, out| {\n        assert_eq!(i64::convertible_from(&Natural::from_str(n).unwrap()), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"1000000000000000000000000\", false);\n    test(\"9223372036854775807\", true);\n    test(\"9223372036854775808\", false);\n}\n\nfn primitive_int_properties<\n    T: for<'a> ConvertibleFrom<&'a Natural>\n        + for<'a> OverflowingFrom<&'a Natural>\n        + PartialEq<Natural>\n        + PartialOrd<Natural>\n        + PrimitiveInt\n        + for<'a> SaturatingFrom<&'a Natural>\n        + for<'a> WrappingFrom<&'a Natural>,\n>()\nwhere\n    Natural: PartialOrd<T>,\n{\n    natural_gen().test_properties(|x| {\n        let result = T::wrapping_from(&x);\n        assert_eq!(result, T::overflowing_from(&x).0);\n\n        let result = T::saturating_from(&x);\n        assert!(result <= x);\n        assert_eq!(result == x, T::convertible_from(&x));\n\n        let result = T::overflowing_from(&x);\n        assert_eq!(result, (T::wrapping_from(&x), !T::convertible_from(&x)));\n\n        let convertible = T::convertible_from(&x);\n        assert_eq!(convertible, x >= T::MIN && x <= T::MAX);\n    });\n}\n\nfn unsigned_properties<\n    T: for<'a> TryFrom<&'a Natural, Error = UnsignedFromNaturalError>\n        + for<'a> OverflowingFrom<&'a Natural>\n        + PartialEq<Natural>\n        + PrimitiveUnsigned\n        + for<'a> WrappingFrom<&'a Natural>,\n>()\nwhere\n    Natural: From<T>,\n{\n    natural_gen().test_properties(|x| {\n        let result = T::try_from(&x);\n        if x.significant_bits() <= T::WIDTH {\n            assert_eq!(Natural::from(result.unwrap()), x);\n            assert_eq!(result, Ok(T::wrapping_from(&x)));\n            assert_eq!(result, Ok(T::exact_from(&x)));\n        } else {\n            assert!(result.is_err());\n        }\n        assert_eq!(result.is_err(), T::overflowing_from(&x).1);\n\n        let result = T::wrapping_from(&x);\n        assert_eq!(result, T::exact_from(&(&x).mod_power_of_2(T::WIDTH)));\n    });\n}\n\nfn signed_properties<\n    T: for<'a> TryFrom<&'a Natural, Error = SignedFromNaturalError>\n        + for<'a> OverflowingFrom<&'a Natural>\n        + PartialEq<Natural>\n        + PrimitiveSigned\n        + for<'a> WrappingFrom<&'a Natural>,\n>()\nwhere\n    Natural: ExactFrom<T>,\n{\n    natural_gen().test_properties(|x| {\n        let result = T::try_from(&x);\n        if x >= 0 && x.significant_bits() < T::WIDTH {\n            assert_eq!(Natural::exact_from(result.unwrap()), x);\n            assert_eq!(result, Ok(T::wrapping_from(&x)));\n            assert_eq!(result, Ok(T::exact_from(&x)));\n        } else {\n            assert!(result.is_err());\n        }\n        assert_eq!(result.is_err(), T::overflowing_from(&x).1);\n    });\n}\n\n#[test]\nfn primitive_int_from_natural_properties() {\n    apply_fn_to_primitive_ints!(primitive_int_properties);\n    apply_fn_to_unsigneds!(unsigned_properties);\n    apply_fn_to_signeds!(signed_properties);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::{string_gen, string_gen_var_8};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_serde() {\n    let test = |n, out| {\n        assert_eq!(\n            serde_json::to_string(&Natural::from_str(n).unwrap()).unwrap(),\n            out\n        );\n        assert_eq!(serde_json::from_str::<Natural>(out).unwrap().to_string(), n);\n    };\n    test(\"0\", \"\\\"0x0\\\"\");\n    test(\"100\", \"\\\"0x64\\\"\");\n    test(\"1000000000000\", \"\\\"0xe8d4a51000\\\"\");\n    test(\"4294967295\", \"\\\"0xffffffff\\\"\");\n    test(\"4294967296\", \"\\\"0x100000000\\\"\");\n    test(\"18446744073709551615\", \"\\\"0xffffffffffffffff\\\"\");\n    test(\"18446744073709551616\", \"\\\"0x10000000000000000\\\"\");\n    test(\"1000000000000000000000000\", \"\\\"0xd3c21bcecceda1000000\\\"\");\n    test(\n        \"340282366920938463463374607431768211455\",\n        \"\\\"0xffffffffffffffffffffffffffffffff\\\"\",\n    );\n    test(\n        \"340282366920938463463374607431768211456\",\n        \"\\\"0x100000000000000000000000000000000\\\"\",\n    );\n}\n\n#[test]\nfn serde_properties() {\n    natural_gen().test_properties(|x| {\n        let s = serde_json::to_string(&x).unwrap();\n        assert_eq!(serde_json::from_str::<Natural>(&s).unwrap(), x);\n        assert_eq!(serde_json::from_str::<Integer>(&s).unwrap(), x);\n        assert!(string_is_subset(&s, \"\\\"0123456789abcdefx\"));\n    });\n\n    string_gen().test_properties(|s| {\n        let _n: Result<Natural, _> = serde_json::from_str(&s);\n    });\n\n    string_gen_var_8().test_properties(|s| {\n        let n: Natural = serde_json::from_str(&s).unwrap();\n        let i: Integer = serde_json::from_str(&s).unwrap();\n        assert_eq!(n, i);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::num::conversion::traits::{ExactFrom, FromSciString, ToStringBase};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{\n    string_from_sci_string_options_pair_gen_var_2, string_from_sci_string_options_pair_gen_var_3,\n    string_gen_var_14, string_gen_var_15,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse std::str::FromStr;\n\n#[test]\npub fn test_from_sci_string() {\n    fn test(s: &str, out: Option<&'static str>) {\n        let out = out.map(|s| Natural::from_str(s).unwrap());\n        assert_eq!(Natural::from_sci_string(s), out);\n        assert_eq!(\n            Natural::from_sci_string_with_options(s, FromSciStringOptions::default()),\n            out\n        );\n    }\n    test(\"0\", Some(\"0\"));\n    test(\"00\", Some(\"0\"));\n    test(\"+0\", Some(\"0\"));\n    test(\"-0\", Some(\"0\"));\n    test(\"0.00\", Some(\"0\"));\n    test(\"0e1\", Some(\"0\"));\n    test(\"0e+1\", Some(\"0\"));\n    test(\"0e-1\", Some(\"0\"));\n    test(\"+0e+1\", Some(\"0\"));\n    test(\"-0e+1\", Some(\"0\"));\n    test(\"+0.0e+1\", Some(\"0\"));\n    test(\"-0.0e+1\", Some(\"0\"));\n    test(\".0\", Some(\"0\"));\n    test(\".00\", Some(\"0\"));\n    test(\".00e0\", Some(\"0\"));\n    test(\".00e1\", Some(\"0\"));\n    test(\".00e-1\", Some(\"0\"));\n    test(\"-.0\", Some(\"0\"));\n    test(\"-.00\", Some(\"0\"));\n    test(\"-.00e0\", Some(\"0\"));\n    test(\"-.00e1\", Some(\"0\"));\n    test(\"-.00e-1\", Some(\"0\"));\n    test(\"+.0\", Some(\"0\"));\n    test(\"+.00\", Some(\"0\"));\n    test(\"+.00e0\", Some(\"0\"));\n    test(\"+.00e1\", Some(\"0\"));\n    test(\"+.00e-1\", Some(\"0\"));\n\n    test(\"123\", Some(\"123\"));\n    test(\"00123\", Some(\"123\"));\n    test(\"+123\", Some(\"123\"));\n    test(\"123.00\", Some(\"123\"));\n    test(\"123e0\", Some(\"123\"));\n    test(\"12.3e1\", Some(\"123\"));\n    test(\"1.23e2\", Some(\"123\"));\n    test(\"1.23E2\", Some(\"123\"));\n    test(\"1.23e+2\", Some(\"123\"));\n    test(\"1.23E+2\", Some(\"123\"));\n    test(\".123e3\", Some(\"123\"));\n    test(\"0.123e3\", Some(\"123\"));\n    test(\"+0.123e3\", Some(\"123\"));\n    test(\"0.0123e4\", Some(\"123\"));\n    test(\"1230e-1\", Some(\"123\"));\n    test(\"12300e-2\", Some(\"123\"));\n    test(\"12300E-2\", Some(\"123\"));\n\n    test(\"123.4\", Some(\"123\"));\n    test(\"123.8\", Some(\"124\"));\n    test(\"123.5\", Some(\"124\"));\n    test(\"124.5\", Some(\"124\"));\n    test(\"127.49\", Some(\"127\"));\n\n    test(\"\", None);\n    test(\"+\", None);\n    test(\"-\", None);\n    test(\"10e\", None);\n    test(\"++1\", None);\n    test(\"1.0.0\", None);\n    test(\"1e++1\", None);\n    test(\"1e0.1\", None);\n    test(\"--.0\", None);\n    test(\"++.0\", None);\n    test(\".+2\", None);\n    test(\".-2\", None);\n    test(\"0.000a\", None);\n    test(\"0.00ae-10\", None);\n    test(\"0e10000000000000000000000000000\", None);\n    test(\"0e-10000000000000000000000000000\", None);\n}\n\n#[test]\npub fn test_from_sci_string_with_options() {\n    fn test(s: &str, options: FromSciStringOptions, out: Option<&str>) {\n        let out = out.map(|s| Natural::from_str(s).unwrap());\n        assert_eq!(Natural::from_sci_string_with_options(s, options), out);\n    }\n    fn test_u<T: PrimitiveUnsigned>(s: &str, options: FromSciStringOptions, out: Option<T>)\n    where\n        Natural: From<T>,\n    {\n        let out = out.map(Natural::from);\n        assert_eq!(Natural::from_sci_string_with_options(s, options), out);\n    }\n    fn test_i<T: PrimitiveSigned>(s: &str, options: FromSciStringOptions, out: Option<T>)\n    where\n        Natural: TryFrom<T>,\n    {\n        let out = out.map(Natural::exact_from);\n        assert_eq!(Natural::from_sci_string_with_options(s, options), out);\n    }\n    // For tests with the default options, see `test_from_sci_string`\n\n    let mut options = FromSciStringOptions::default();\n    options.set_base(2);\n    test_u(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(3);\n    test_u(\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(4);\n    test_u(\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(5);\n    test_u(\n        \"11031110441201303134210404233413032443021130230130231310\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(8);\n    test_u(\n        \"3777777777777777777777777777777777777777777\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(16);\n    test_u(\"ffffffffffffffffffffffffffffffff\", options, Some(u128::MAX));\n    options.set_base(32);\n    test_u(\"7vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(u128::MAX));\n    options.set_base(36);\n    test_u(\"f5lxx1zz5pnorynqglhzmsp33\", options, Some(u128::MAX));\n\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(3);\n    test_i(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(4);\n    test_i(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(5);\n    test_i(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(8);\n    test_i(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(16);\n    test_i(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    options.set_base(32);\n    test_i(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    options.set_base(36);\n    test_i(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n\n    options.set_base(2);\n    test(\"1e+5\", options, Some(\"32\"));\n    test(\"1e5\", options, Some(\"32\"));\n    options.set_base(3);\n    test(\"1e+5\", options, Some(\"243\"));\n    test(\"1e5\", options, Some(\"243\"));\n    options.set_base(4);\n    test(\"1e+5\", options, Some(\"1024\"));\n    test(\"1e5\", options, Some(\"1024\"));\n    options.set_base(5);\n    test(\"1e+5\", options, Some(\"3125\"));\n    test(\"1e5\", options, Some(\"3125\"));\n    options.set_base(8);\n    test(\"1e+5\", options, Some(\"32768\"));\n    test(\"1e5\", options, Some(\"32768\"));\n    options.set_base(16);\n    test(\"1e+5\", options, Some(\"1048576\"));\n    test(\"1e5\", options, Some(\"485\"));\n    options.set_base(32);\n    test(\"1e+5\", options, Some(\"33554432\"));\n    test(\"1e5\", options, Some(\"1477\"));\n    options.set_base(36);\n    test(\"1e+5\", options, Some(\"60466176\"));\n    test(\"1E+5\", options, Some(\"60466176\"));\n    test(\"1e5\", options, Some(\"1805\"));\n\n    options.set_base(16);\n    test(\"ff\", options, Some(\"255\"));\n    test(\"fF\", options, Some(\"255\"));\n    test(\"Ff\", options, Some(\"255\"));\n    test(\"FF\", options, Some(\"255\"));\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Down);\n    test(\"123.4\", options, Some(\"123\"));\n    options.set_rounding_mode(Floor);\n    test(\"123.4\", options, Some(\"123\"));\n    options.set_rounding_mode(Up);\n    test(\"123.4\", options, Some(\"124\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"123.4\", options, Some(\"124\"));\n    options.set_rounding_mode(Nearest);\n    test(\"123.4\", options, Some(\"123\"));\n    options.set_rounding_mode(Exact);\n    test(\"123.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"123.5\", options, Some(\"123\"));\n    options.set_rounding_mode(Floor);\n    test(\"123.5\", options, Some(\"123\"));\n    options.set_rounding_mode(Up);\n    test(\"123.5\", options, Some(\"124\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"123.5\", options, Some(\"124\"));\n    options.set_rounding_mode(Nearest);\n    test(\"123.5\", options, Some(\"124\"));\n    options.set_rounding_mode(Exact);\n    test(\"123.5\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Up);\n    test(\"0.4\", options, Some(\"1\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"0.4\", options, Some(\"1\"));\n    options.set_rounding_mode(Nearest);\n    test(\"0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"0.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Up);\n    test(\"0.04\", options, Some(\"1\"));\n    options.set_rounding_mode(Ceiling);\n    test(\"0.04\", options, Some(\"1\"));\n    options.set_rounding_mode(Nearest);\n    test(\"0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"0.04\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test(\"1.01\", options, Some(\"1\"));\n    test(\"1.1\", options, Some(\"2\"));\n    test(\"1.11\", options, Some(\"2\"));\n    test(\"0.01\", options, Some(\"0\"));\n    test(\"0.1\", options, Some(\"0\"));\n    test(\"0.11\", options, Some(\"1\"));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test(\"1.1\", options, Some(\"1\"));\n    test(\"1.11\", options, Some(\"1\"));\n    test(\"1.111\", options, Some(\"1\"));\n    test(\"1.112\", options, Some(\"2\"));\n    test(\"0.1\", options, Some(\"0\"));\n    test(\"0.11\", options, Some(\"0\"));\n    test(\"0.111\", options, Some(\"0\"));\n    test(\"0.112\", options, Some(\"1\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test(\"2\", options, None);\n    test(\"102\", options, None);\n    test(\"12e4\", options, None);\n    test(\"12e-4\", options, None);\n    test(\"1.2\", options, None);\n    test(\"0.2\", options, None);\n    test(\"0.002\", options, None);\n\n    options = FromSciStringOptions::default();\n    options.set_rounding_mode(Exact);\n    test(\"1.5\", options, None);\n    test(\"1.9999999999999999999999999999\", options, None);\n\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(3);\n    test_i(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(4);\n    test_i(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(5);\n    test_i(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(8);\n    test_i(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    options.set_base(16);\n    test_i(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    options.set_base(32);\n    test_i(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    options.set_base(36);\n    test_i(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n\n    options.set_rounding_mode(Down);\n    test(\"-0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"-0.4\", options, None);\n    options.set_rounding_mode(Up);\n    test(\"-0.4\", options, None);\n    options.set_rounding_mode(Ceiling);\n    test(\"-0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Nearest);\n    test(\"-0.4\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"-0.4\", options, None);\n\n    options.set_rounding_mode(Down);\n    test(\"-0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Floor);\n    test(\"-0.04\", options, None);\n    options.set_rounding_mode(Up);\n    test(\"-0.04\", options, None);\n    options.set_rounding_mode(Ceiling);\n    test(\"-0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Nearest);\n    test(\"-0.04\", options, Some(\"0\"));\n    options.set_rounding_mode(Exact);\n    test(\"-0.04\", options, None);\n}\n\nfn from_sci_string_helper(s: &str) {\n    if let Some(x) = Natural::from_sci_string(s) {\n        assert!(x.is_valid());\n        for c in ['.', 'e', 'E', '+'] {\n            if s.contains(c) {\n                return;\n            }\n        }\n        if s.starts_with('0') || s.starts_with(\"-0\") {\n            return;\n        }\n        assert_eq!(x.to_string(), s);\n    }\n}\n\n#[test]\nfn from_sci_string_properties() {\n    string_gen_var_14().test_properties(|s| {\n        from_sci_string_helper(&s);\n    });\n\n    string_gen_var_15().test_properties(|s| {\n        from_sci_string_helper(&s);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(Natural::from_sci_string(&x.to_string()).unwrap(), x);\n    });\n}\n\nfn from_sci_string_with_options_helper(s: &str, options: FromSciStringOptions) {\n    if let Some(x) = Natural::from_sci_string_with_options(s, options) {\n        assert!(x.is_valid());\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 2);\n        for c in ['.', 'e', 'E', '+'] {\n            if s.contains(c) {\n                return;\n            }\n        }\n        if s.starts_with('0') || s.starts_with(\"-0\") {\n            return;\n        }\n        assert_eq!(x.to_string_base(options.get_base()), s.to_lowercase());\n    }\n}\n\n#[test]\nfn from_sci_string_with_options_properties() {\n    string_from_sci_string_options_pair_gen_var_2().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper(&s, options);\n    });\n\n    string_from_sci_string_options_pair_gen_var_3().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper(&s, options);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, FromStringBase, ToStringBase, WrappingFrom,\n};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::exhaustive::valid_digit_chars;\nuse malachite_base::test_util::generators::{\n    string_gen, string_gen_var_3, string_gen_var_5, string_gen_var_6, string_gen_var_7,\n    unsigned_gen, unsigned_gen_var_11, unsigned_pair_gen_var_8, unsigned_pair_gen_var_19,\n    unsigned_string_pair_gen_var_1, unsigned_string_pair_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse num::{BigUint, Num};\nuse rug;\nuse std::collections::HashMap;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_str() {\n    let test_ok = |s, n| {\n        assert_eq!(Natural::from_str(s).unwrap().to_string(), n);\n        assert_eq!(BigUint::from_str(s).unwrap().to_string(), n);\n        assert_eq!(rug::Integer::from_str(s).unwrap().to_string(), n);\n    };\n    test_ok(\"0\", \"0\");\n    test_ok(\"+0\", \"0\");\n    test_ok(\"123456\", \"123456\");\n    test_ok(\"+123456\", \"123456\");\n    test_ok(\"1000000000000000000000000\", \"1000000000000000000000000\");\n\n    let test_err = |s, rug_err| {\n        assert!(Natural::from_str(s).is_err());\n        assert!(BigUint::from_str(s).is_err());\n        let rn = rug::Integer::from_str(s);\n        assert_eq!(rn.is_err() || rn.unwrap() < 0, rug_err);\n    };\n    test_err(\"12A\", true);\n    test_err(\" 10\", false);\n    test_err(\"1.0\", true);\n    test_err(\"-5\", true);\n    test_err(\"$%^\", true);\n    test_err(\"\", true);\n    test_err(\"-\", true);\n    test_err(\"-0\", false);\n    test_err(\"--0\", true);\n    test_err(\"-+0\", true);\n    test_err(\"+-0\", true);\n    test_err(\"++0\", true);\n    test_err(\"--1\", true);\n    test_err(\"-+1\", true);\n    test_err(\"+-1\", true);\n    test_err(\"++1\", true);\n}\n\n#[test]\nfn from_str_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 64);\n    string_gen().test_properties_with_config(&config, |s| {\n        assert_eq!(\n            Natural::from_str(&s).is_ok(),\n            !s.is_empty() && s.chars().all(|c| c.is_ascii_digit()),\n        );\n    });\n\n    string_gen_var_3().test_properties(|s| {\n        let n = Natural::from_str(&s).unwrap();\n        let mut trimmed = s.trim_start_matches('0');\n        if trimmed.is_empty() {\n            trimmed = \"0\";\n        }\n        assert_eq!(n.to_string(), trimmed);\n        assert_eq!(n, Natural::from_string_base(10, &s).unwrap());\n        let with_zero = \"0\".to_string() + &s;\n        assert_eq!(Natural::from_str(&with_zero).unwrap(), n);\n\n        assert_eq!(BigUint::from_str(&s).unwrap(), BigUint::from(&n));\n        assert_eq!(rug::Integer::from_str(&s).unwrap(), rug::Integer::from(&n));\n    });\n\n    unsigned_gen_var_11().test_properties(|u| {\n        assert_eq!(\n            Natural::from_str(std::str::from_utf8(&vec![b'0'; u]).unwrap()).unwrap(),\n            0\n        );\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        let s = u.to_string();\n        assert_eq!(\n            Natural::from_str(&s).unwrap(),\n            Natural::from(Limb::from_str(&s).unwrap())\n        );\n    });\n}\n\n#[test]\nfn test_from_string_base() {\n    let test_ok = |base, s, n| {\n        assert_eq!(Natural::from_string_base(base, s).unwrap().to_string(), n);\n        assert_eq!(\n            BigUint::from_str_radix(s, u32::exact_from(base))\n                .unwrap()\n                .to_string(),\n            n\n        );\n        assert_eq!(\n            rug::Integer::from_str_radix(s, i32::exact_from(base))\n                .unwrap()\n                .to_string(),\n            n\n        );\n    };\n    test_ok(2, \"0\", \"0\");\n    test_ok(10, \"0\", \"0\");\n    test_ok(2, \"101\", \"5\");\n    test_ok(10, \"123456\", \"123456\");\n    test_ok(16, \"deadbeef\", \"3735928559\");\n    test_ok(16, \"DEADBEEF\", \"3735928559\");\n    test_ok(16, \"deAdBeEf\", \"3735928559\");\n    test_ok(10, \"1000000000000000000000000\", \"1000000000000000000000000\");\n    test_ok(2, \"1000000000000000000000000\", \"16777216\");\n    test_ok(\n        36,\n        \"1000000000000000000000000\",\n        \"22452257707354557240087211123792674816\",\n    );\n    test_ok(36, \"helloworld\", \"1767707668033969\");\n\n    let test_err = |base, s, rug_err| {\n        assert!(Natural::from_string_base(base, s).is_none());\n        assert!(BigUint::from_str_radix(s, u32::exact_from(base)).is_err());\n        let rn = rug::Integer::from_str_radix(s, i32::exact_from(base));\n        assert_eq!(rn.is_err() || rn.unwrap() < 0, rug_err);\n    };\n    test_err(2, \"123\", true);\n    test_err(10, \"12A\", true);\n    test_err(35, \" 10\", false);\n    test_err(35, \"1.0\", true);\n    test_err(35, \"-5\", true);\n    test_err(35, \"$%^\", true);\n    test_err(35, \"\", true);\n    test_err(35, \"-\", true);\n    test_err(16, \"10000000z\", true);\n    test_err(16, \"1000000000000000z\", true);\n}\n\n#[test]\n#[should_panic]\nfn from_string_base_fail_1() {\n    Natural::from_string_base(1, \"0\");\n}\n\n#[test]\n#[should_panic]\nfn from_string_base_fail_2() {\n    Natural::from_string_base(0, \"0\");\n}\n\nfn from_string_base_helper(base: u8, s: &str) {\n    let n = Natural::from_string_base(base, s).unwrap();\n    let s_lo = s.to_lowercase();\n    let mut trimmed = s_lo.trim_start_matches('0');\n    if trimmed.is_empty() {\n        trimmed = \"0\";\n    }\n    assert_eq!(n.to_string_base(base), trimmed);\n    let with_zero = \"0\".to_string() + s;\n    assert_eq!(Natural::from_string_base(base, &with_zero).unwrap(), n);\n\n    assert_eq!(\n        BigUint::from_str_radix(s, u32::from(base)).unwrap(),\n        BigUint::from(&n)\n    );\n    assert_eq!(\n        rug::Integer::from_str_radix(s, i32::from(base)).unwrap(),\n        rug::Integer::from(&n)\n    );\n}\n\n#[test]\nfn from_string_base_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 64);\n    let mut digit_map = HashMap::new();\n    unsigned_string_pair_gen_var_2().test_properties_with_config(&config, |(base, s)| {\n        let digits = digit_map\n            .entry(base)\n            .or_insert_with(|| valid_digit_chars(u8::wrapping_from(base)));\n        assert_eq!(\n            Natural::from_string_base(base, &s).is_some(),\n            !s.is_empty() && s.chars().all(|c| digits.contains(&c)),\n        );\n    });\n\n    unsigned_string_pair_gen_var_1().test_properties(|(base, s)| {\n        from_string_base_helper(base, &s);\n    });\n\n    string_gen_var_5().test_properties(|s| {\n        from_string_base_helper(2, &s);\n    });\n\n    string_gen_var_6().test_properties(|s| {\n        from_string_base_helper(8, &s);\n    });\n\n    string_gen_var_7().test_properties(|s| {\n        from_string_base_helper(16, &s);\n    });\n\n    unsigned_pair_gen_var_19().test_properties(|(u, base)| {\n        assert_eq!(\n            Natural::from_string_base(base, std::str::from_utf8(&vec![b'0'; u]).unwrap()).unwrap(),\n            0\n        );\n    });\n\n    unsigned_pair_gen_var_8::<Limb, u8>().test_properties(|(u, base)| {\n        let s = u.to_string_base(base);\n        assert_eq!(\n            Natural::from_string_base(base, &s).unwrap(),\n            Natural::from(Limb::from_string_base(base, &s).unwrap())\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{FloorLogBase, Pow, PowerOf2, RoundToMultiple};\nuse malachite_base::num::conversion::string::options::{\n    FromSciStringOptions, SciSizeOptions, ToSciOptions,\n};\nuse malachite_base::num::conversion::traits::{FromSciString, ToSci};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_to_sci_options_pair_gen_var_1};\nuse malachite_base::test_util::num::conversion::string::from_sci_string::DECIMAL_SCI_STRING_CHARS;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_to_sci_options_pair_gen_var_1};\nuse std::collections::HashMap;\nuse std::str::FromStr;\n\n#[test]\npub fn test_to_sci() {\n    assert_eq!(\n        Natural::power_of_2(1000000).to_sci().to_string(),\n        \"9.900656229295898e301029\"\n    );\n    assert_eq!(\n        (-Natural::power_of_2(1000000)).to_sci().to_string(),\n        \"-9.900656229295898e301029\"\n    );\n\n    fn test_i(x: &Natural, out: &str) {\n        assert_eq!(x.to_sci().to_string(), out);\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            out\n        );\n    }\n    fn test(s: &str, out: &str) {\n        test_i(&Natural::from_str(s).unwrap(), out);\n    }\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"10\", \"10\");\n    test(\"100\", \"100\");\n    test(\"1000\", \"1000\");\n    test(\"10000\", \"10000\");\n    test(\"100000\", \"100000\");\n    test(\"1000000\", \"1000000\");\n    test(\"10000000\", \"10000000\");\n    test(\"100000000\", \"100000000\");\n    test(\"1000000000\", \"1000000000\");\n    test(\"10000000000\", \"10000000000\");\n    test(\"100000000000\", \"100000000000\");\n    test(\"1000000000000\", \"1000000000000\");\n    test(\"10000000000000\", \"10000000000000\");\n    test(\"100000000000000\", \"100000000000000\");\n    test(\"1000000000000000\", \"1000000000000000\");\n    test(\"10000000000000000\", \"1e16\");\n    test(\"100000000000000000\", \"1e17\");\n    test_i(&Natural::from(u64::MAX), \"1.844674407370955e19\");\n    test_i(&Natural::from(u128::MAX), \"3.402823669209385e38\");\n\n    test(\"999999999999999\", \"999999999999999\");\n    test(\"9999999999999999\", \"9999999999999999\");\n    test(\"99999999999999999\", \"1e17\");\n    test(\"999999999999999999\", \"1e18\");\n}\n\n#[test]\npub fn test_to_sci_with_options() {\n    fn test_i(x: &Natural, options: ToSciOptions, out: &str) {\n        assert_eq!(x.to_sci_with_options(options).to_string(), out);\n    }\n    fn test(s: &str, options: ToSciOptions, out: &str) {\n        test_i(&Natural::from_str(s).unwrap(), options, out);\n    }\n    // For tests with the default options, see `test_to_sci`\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.000000000000000\");\n    test(\"1\", options, \"1.000000000000000\");\n    test(\"10\", options, \"10.00000000000000\");\n    test(\"100\", options, \"100.0000000000000\");\n    test(\"1000\", options, \"1000.000000000000\");\n    test(\"10000\", options, \"10000.00000000000\");\n    test(\"100000\", options, \"100000.0000000000\");\n    test(\"1000000\", options, \"1000000.000000000\");\n    test(\"10000000\", options, \"10000000.00000000\");\n    test(\"100000000\", options, \"100000000.0000000\");\n    test(\"1000000000\", options, \"1000000000.000000\");\n    test(\"10000000000\", options, \"10000000000.00000\");\n    test(\"100000000000\", options, \"100000000000.0000\");\n    test(\"1000000000000\", options, \"1000000000000.000\");\n    test(\"10000000000000\", options, \"10000000000000.00\");\n    test(\"100000000000000\", options, \"100000000000000.0\");\n    test(\"1000000000000000\", options, \"1000000000000000\");\n    test(\"10000000000000000\", options, \"1.000000000000000e16\");\n    test(\"100000000000000000\", options, \"1.000000000000000e17\");\n    test_i(&Natural::from(u64::MAX), options, \"1.844674407370955e19\");\n    test_i(&Natural::from(u128::MAX), options, \"3.402823669209385e38\");\n\n    test(\"999999999999999\", options, \"999999999999999.0\");\n    test(\"9999999999999999\", options, \"9999999999999999\");\n    test(\"99999999999999999\", options, \"1.000000000000000e17\");\n    test(\"999999999999999999\", options, \"1.000000000000000e18\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test_i(&Natural::from(u128::MAX), options, \"1e128\");\n    options.set_base(3);\n    test_i(&Natural::from(u128::MAX), options, \"2.022011021210021e80\");\n    options.set_base(4);\n    test_i(&Natural::from(u128::MAX), options, \"1e64\");\n    options.set_base(5);\n    test_i(&Natural::from(u128::MAX), options, \"1.103111044120131e55\");\n    options.set_base(8);\n    test_i(&Natural::from(u128::MAX), options, \"4e42\");\n    // When base >= 15, there is a mandatory sign after the exponent indicator \"e\", to distinguish\n    // it from the digit \"e\"\n    options.set_base(16);\n    test_i(&Natural::from(u128::MAX), options, \"1e+32\");\n    options.set_base(32);\n    test_i(&Natural::from(u128::MAX), options, \"8e+25\");\n    options.set_base(36);\n    test_i(&Natural::from(u128::MAX), options, \"f.5lxx1zz5pnorynqe+24\");\n\n    // The sign can be forced in other cases too\n    options.set_base(3);\n    options.set_force_exponent_plus_sign(true);\n    test_i(&Natural::from(u128::MAX), options, \"2.022011021210021e+80\");\n\n    // The digits can be uppercase, and so can the exponent indicator\n    options = ToSciOptions::default();\n    options.set_base(36);\n    options.set_uppercase();\n    test_i(&Natural::from(u128::MAX), options, \"F.5LXX1ZZ5PNORYNQe+24\");\n\n    options.set_lowercase();\n    options.set_e_uppercase();\n    test_i(&Natural::from(u128::MAX), options, \"f.5lxx1zz5pnorynqE+24\");\n\n    options.set_uppercase();\n    test_i(&Natural::from(u128::MAX), options, \"F.5LXX1ZZ5PNORYNQE+24\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    options.set_base(2);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n    );\n    options.set_base(3);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n    );\n    options.set_base(4);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n    );\n    options.set_base(5);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"11031110441201303134210404233413032443021130230130231310\",\n    );\n    options.set_base(8);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"3777777777777777777777777777777777777777777\",\n    );\n    options.set_base(16);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"ffffffffffffffffffffffffffffffff\",\n    );\n    options.set_base(32);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"7vvvvvvvvvvvvvvvvvvvvvvvvv\",\n    );\n    options.set_base(36);\n    test_i(\n        &Natural::from(u128::MAX),\n        options,\n        \"f5lxx1zz5pnorynqglhzmsp33\",\n    );\n\n    options = ToSciOptions::default();\n    options.set_precision(4);\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.000\");\n    test(\"1\", options, \"1.000\");\n    test(\"10\", options, \"10.00\");\n    test(\"100\", options, \"100.0\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"1.000e4\");\n    test(\"9\", options, \"9.000\");\n    test(\"99\", options, \"99.00\");\n    test(\"999\", options, \"999.0\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"1.000e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_precision(1);\n    options.set_include_trailing_zeros(true); // doesn't matter when precision is 1\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"1e1\");\n    test(\"100\", options, \"1e2\");\n    test(\"1000\", options, \"1e3\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"1e2\");\n    test(\"999\", options, \"1e3\");\n    test(\"9999\", options, \"1e4\");\n    test(\"99999\", options, \"1e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"1e1\");\n    test(\"100\", options, \"1e2\");\n    test(\"1000\", options, \"1e3\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"1e2\");\n    test(\"999\", options, \"1e3\");\n    test(\"9999\", options, \"1e4\");\n    test(\"99999\", options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.00\");\n    test(\"1\", options, \"1.00\");\n    test(\"10\", options, \"10.00\");\n    test(\"100\", options, \"100.00\");\n    test(\"1000\", options, \"1000.00\");\n    test(\"10000\", options, \"10000.00\");\n    test(\"9\", options, \"9.00\");\n    test(\"99\", options, \"99.00\");\n    test(\"999\", options, \"999.00\");\n    test(\"9999\", options, \"9999.00\");\n    test(\"99999\", options, \"99999.00\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_scale(0);\n    options.set_include_trailing_zeros(true); // doesn't matter when scale is 0\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_precision(2);\n    options.set_rounding_mode(Nearest); // This is the default\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Down);\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Floor);\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Up);\n    test(\"123\", options, \"1.3e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"123\", options, \"1.3e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"135\", options, \"1.4e2\");\n    options.set_rounding_mode(Down);\n    test(\"135\", options, \"1.3e2\");\n    options.set_rounding_mode(Floor);\n    test(\"135\", options, \"1.3e2\");\n    options.set_rounding_mode(Up);\n    test(\"135\", options, \"1.4e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"135\", options, \"1.4e2\");\n\n    options.set_rounding_mode(Exact);\n    test(\"140\", options, \"1.4e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"999\", options, \"1e3\");\n    options.set_rounding_mode(Down);\n    test(\"999\", options, \"9.9e2\");\n    options.set_rounding_mode(Floor);\n    test(\"999\", options, \"9.9e2\");\n    options.set_rounding_mode(Up);\n    test(\"999\", options, \"1e3\");\n    options.set_rounding_mode(Ceiling);\n    test(\"999\", options, \"1e3\");\n}\n\n#[test]\nfn to_sci_properties() {\n    let mut powers_of_10 = HashMap::new();\n    const TEN: Natural = Natural::const_from(10);\n    let default_p = 16;\n    natural_gen().test_properties(|x| {\n        assert!(x.fmt_sci_valid(ToSciOptions::default()));\n        let s = x.to_sci().to_string();\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            s\n        );\n        assert!(string_is_subset(&s, DECIMAL_SCI_STRING_CHARS));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains('-'));\n        assert!(!s.contains('+'));\n        assert!(!s.contains('E'));\n        let x_from = Natural::from_sci_string(&s).unwrap();\n        if x == 0u32 {\n            assert_eq!(x_from, 0u32);\n        } else {\n            let log = x.floor_log_base(&TEN);\n            if log < default_p {\n                assert_eq!(x_from, x);\n            } else {\n                let pow = powers_of_10\n                    .entry(log - default_p + 1)\n                    .or_insert_with_key(|&p| (&TEN).pow(p));\n                assert_eq!(x.round_to_multiple(&*pow, Nearest).0, x_from);\n            }\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|x| {\n        assert_eq!(\n            x.to_sci().to_string(),\n            Natural::from(x).to_sci().to_string()\n        );\n    });\n}\n\n#[test]\nfn to_sci_with_options_properties() {\n    let mut powers = HashMap::new();\n    let mut chars = HashMap::new();\n    natural_to_sci_options_pair_gen_var_1().test_properties(|(x, options)| {\n        assert!(x.fmt_sci_valid(options));\n        let s = x.to_sci_with_options(options).to_string();\n        let cs: &mut String = chars.entry(options.get_base()).or_insert_with_key(|&base| {\n            let mut cs = \"+-.0123456789\".to_string();\n            if base > 10 {\n                let limit = usize::from(base - 10);\n                for c in ('a'..='z').take(limit) {\n                    cs.push(c);\n                }\n                for c in ('A'..='Z').take(limit) {\n                    cs.push(c);\n                }\n            }\n            if base < 15 {\n                cs.push('e');\n                cs.push('E');\n            }\n            cs\n        });\n        assert!(string_is_subset(&s, cs));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 1);\n        let mut from_options = FromSciStringOptions::default();\n        from_options.set_base(options.get_base());\n        let x_from = Natural::from_sci_string_with_options(&s, from_options).unwrap();\n        if x == 0u32 {\n            assert_eq!(x_from, 0u32);\n        } else {\n            let base = Natural::from(options.get_base());\n            let neg_scale = match options.get_size_options() {\n                SciSizeOptions::Complete | SciSizeOptions::Scale(_) => None,\n                SciSizeOptions::Precision(p) => {\n                    let log = x.floor_log_base(&base);\n                    if log >= p { Some(log - p + 1) } else { None }\n                }\n            };\n            if let Some(neg_scale) = neg_scale {\n                let pow = powers\n                    .entry((base.clone(), neg_scale))\n                    .or_insert_with(|| (&base).pow(neg_scale));\n                assert_eq!(\n                    x.round_to_multiple(&*pow, options.get_rounding_mode()).0,\n                    x_from\n                );\n            } else {\n                assert_eq!(x_from, x);\n            }\n        }\n    });\n\n    unsigned_to_sci_options_pair_gen_var_1::<Limb>().test_properties(|(x, options)| {\n        assert_eq!(\n            x.to_sci_with_options(options).to_string(),\n            Natural::from(x).to_sci_with_options(options).to_string()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::repeat_n;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::string::to_string::BaseFmtWrapper as BaseBaseFmtWrapper;\nuse malachite_base::num::conversion::traits::{FromStringBase, ToStringBase};\nuse malachite_base::strings::{\n    ToBinaryString, ToDebugString, ToLowerHexString, ToOctalString, ToUpperHexString,\n    string_is_subset,\n};\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_gen_var_8, unsigned_pair_gen_var_2, unsigned_pair_gen_var_9,\n    unsigned_triple_gen_var_6,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::conversion::string::to_string::{\n    BaseFmtWrapper, NaturalAlt, NaturalAlt2,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_unsigned_pair_gen_var_3, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_unsigned_triple_gen_var_1,\n};\nuse malachite_nz::test_util::natural::conversion::string::to_string::to_string_base_naive;\nuse num::BigUint;\nuse std::cmp::max;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nfn test_padding(s: &str, s_padded: &str, width: usize) {\n    assert!(s_padded.len() >= width);\n    assert_eq!(s.len() >= width, s == s_padded);\n    if s.len() < width {\n        let diff = s_padded.len() - s.len();\n        assert!(s_padded[..diff].chars().all(|c| c == '0'));\n        assert_eq!(&s_padded[diff..], s);\n    }\n}\n\n#[test]\npub fn test_to_string() {\n    fn test(u: &str) {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_string(), u);\n        assert_eq!(x.to_debug_string(), u);\n        assert_eq!(to_string_base_naive(&x, 10), u);\n        assert_eq!(format!(\"{x:00}\"), u);\n        assert_eq!(format!(\"{x:00?}\"), u);\n    }\n    test(\"0\");\n    test(\"2\");\n    test(\"123\");\n    test(\"1000\");\n    test(\"1000000\");\n    test(\"1000000000000000\");\n\n    fn test_width(u: &str, width: usize, out: &str) {\n        let x = Natural::from_str(u).unwrap();\n        let s = x.to_string();\n        assert_eq!(format!(\"{x:0width$}\"), out);\n        assert_eq!(format!(\"{x:0width$?}\"), out);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\");\n    test_width(\"0\", 1, \"0\");\n    test_width(\"0\", 2, \"00\");\n    test_width(\"0\", 5, \"00000\");\n    test_width(\"1000000\", 0, \"1000000\");\n    test_width(\"1000000\", 1, \"1000000\");\n    test_width(\"1000000\", 2, \"1000000\");\n    test_width(\"1000000\", 3, \"1000000\");\n    test_width(\"1000000\", 4, \"1000000\");\n    test_width(\"1000000\", 5, \"1000000\");\n    test_width(\"1000000\", 6, \"1000000\");\n    test_width(\"1000000\", 7, \"1000000\");\n    test_width(\"1000000\", 8, \"01000000\");\n    test_width(\"1000000\", 10, \"0001000000\");\n    test_width(\"1000000000000000\", 0, \"1000000000000000\");\n    test_width(\"1000000000000000\", 1, \"1000000000000000\");\n    test_width(\"1000000000000000\", 16, \"1000000000000000\");\n    test_width(\"1000000000000000\", 20, \"00001000000000000000\");\n}\n\n#[test]\nfn to_string_properties() {\n    natural_gen().test_properties(|x| {\n        let s = x.to_string();\n        assert_eq!(x.to_debug_string(), s);\n        assert_eq!(x.to_string_base(10), s);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(&x, 10)), s);\n        assert_eq!(to_string_base_naive(&x, 10), s);\n        assert_eq!(BigUint::from(&x).to_string(), s);\n        assert_eq!(rug::Integer::from(&x).to_string(), s);\n        assert!(string_is_subset(&s, \"0123456789\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, width)| {\n        let s = x.to_string();\n        let s_padded = format!(\"{x:0width$}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(format!(\"{x:0width$?}\"), s_padded);\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 10), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$?}\", BaseFmtWrapper::new(&x, 10), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    unsigned_gen::<Limb>().test_properties(|x| {\n        assert_eq!(Natural::from(x).to_string(), x.to_string());\n    });\n\n    unsigned_pair_gen_var_2::<Limb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$}\", Natural::from(x), width = width),\n            format!(\"{x:0width$}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_binary_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_binary_string(), out);\n        assert_eq!(to_string_base_naive(&x, 2), out);\n        assert_eq!(format!(\"{x:00b}\"), out);\n        assert_eq!(format!(\"{x:#b}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0b0\");\n    test(\"2\", \"10\", \"0b10\");\n    test(\"123\", \"1111011\", \"0b1111011\");\n    test(\"1000\", \"1111101000\", \"0b1111101000\");\n    test(\"1000000\", \"11110100001001000000\", \"0b11110100001001000000\");\n    test(\n        \"1000000000000000\",\n        \"11100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        let s = x.to_binary_string();\n        assert_eq!(format!(\"{x:0width$b}\"), out);\n        assert_eq!(format!(\"{x:#0width$b}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0b0\");\n    test_width(\"0\", 1, \"0\", \"0b0\");\n    test_width(\"0\", 2, \"00\", \"0b0\");\n    test_width(\"0\", 5, \"00000\", \"0b000\");\n    test_width(\"1000\", 0, \"1111101000\", \"0b1111101000\");\n    test_width(\"1000\", 1, \"1111101000\", \"0b1111101000\");\n    test_width(\"1000\", 10, \"1111101000\", \"0b1111101000\");\n    test_width(\"1000\", 12, \"001111101000\", \"0b1111101000\");\n    test_width(\"1000\", 14, \"00001111101000\", \"0b001111101000\");\n    test_width(\n        \"1000000000000000\",\n        0,\n        \"11100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        1,\n        \"11100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        52,\n        \"0011100011010111111010100100110001101000000000000000\",\n        \"0b11100011010111111010100100110001101000000000000000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        54,\n        \"000011100011010111111010100100110001101000000000000000\",\n        \"0b0011100011010111111010100100110001101000000000000000\",\n    );\n}\n\n#[test]\nfn to_binary_string_properties() {\n    natural_gen().test_properties(|x| {\n        let s = x.to_binary_string();\n        let prefixed_s = \"0b\".to_owned() + &s;\n        assert_eq!(format!(\"{x:#b}\"), prefixed_s);\n        assert_eq!(format!(\"{x:00b}\"), s);\n        assert_eq!(format!(\"{x:#00b}\"), prefixed_s);\n        assert_eq!(x.to_string_base(2), s);\n        assert_eq!(to_string_base_naive(&x, 2), s);\n        assert_eq!(NaturalAlt(x.clone()).to_binary_string(), s);\n        assert_eq!(format!(\"{:#b}\", NaturalAlt(x.clone())), prefixed_s);\n        assert_eq!(NaturalAlt2(x.clone()).to_binary_string(), s);\n        assert_eq!(format!(\"{:#b}\", NaturalAlt2(x.clone())), prefixed_s);\n        let num_x = BigUint::from(&x);\n        assert_eq!(num_x.to_binary_string(), s);\n        assert_eq!(format!(\"{num_x:#b}\"), prefixed_s);\n        let rug_x = rug::Integer::from(&x);\n        assert_eq!(rug_x.to_binary_string(), s);\n        assert_eq!(format!(\"{rug_x:#b}\"), prefixed_s);\n        assert!(string_is_subset(&s, \"01\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, width)| {\n        let s = x.to_binary_string();\n        let s_padded = format!(\"{x:0width$b}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$b}\", NaturalAlt(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$b}\", NaturalAlt2(x.clone()), width = width),\n            s_padded,\n        );\n        assert_eq!(\n            format!(\"{:0width$b}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$b}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$b}\");\n        assert_eq!(\n            format!(\"{:#0width$b}\", NaturalAlt(x.clone()), width = width),\n            s_padded,\n        );\n        assert_eq!(\n            format!(\"{:#0width$b}\", NaturalAlt2(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$b}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$b}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    unsigned_gen::<Limb>().test_properties(|x| {\n        assert_eq!(Natural::from(x).to_binary_string(), x.to_binary_string());\n        assert_eq!(format!(\"{:#b}\", Natural::from(x)), format!(\"{x:#b}\"));\n    });\n\n    unsigned_pair_gen_var_2::<Limb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$b}\", Natural::from(x), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$b}\", Natural::from(x), width = width),\n            format!(\"{x:#0width$b}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_octal_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_octal_string(), out);\n        assert_eq!(to_string_base_naive(&x, 8), out);\n        assert_eq!(format!(\"{x:00o}\"), out);\n        assert_eq!(format!(\"{x:#o}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0o0\");\n    test(\"2\", \"2\", \"0o2\");\n    test(\"123\", \"173\", \"0o173\");\n    test(\"1000\", \"1750\", \"0o1750\");\n    test(\"1000000\", \"3641100\", \"0o3641100\");\n    test(\n        \"1000000000000000\",\n        \"34327724461500000\",\n        \"0o34327724461500000\",\n    );\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        let s = x.to_octal_string();\n        assert_eq!(format!(\"{x:0width$o}\"), out);\n        assert_eq!(format!(\"{x:#0width$o}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0o0\");\n    test_width(\"0\", 1, \"0\", \"0o0\");\n    test_width(\"0\", 2, \"00\", \"0o0\");\n    test_width(\"0\", 3, \"000\", \"0o0\");\n    test_width(\"0\", 4, \"0000\", \"0o00\");\n    test_width(\"0\", 5, \"00000\", \"0o000\");\n    test_width(\"1000\", 0, \"1750\", \"0o1750\");\n    test_width(\"1000\", 1, \"1750\", \"0o1750\");\n    test_width(\"1000\", 4, \"1750\", \"0o1750\");\n    test_width(\"1000\", 6, \"001750\", \"0o1750\");\n    test_width(\"1000\", 8, \"00001750\", \"0o001750\");\n    test_width(\n        \"1000000000000000\",\n        0,\n        \"34327724461500000\",\n        \"0o34327724461500000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        1,\n        \"34327724461500000\",\n        \"0o34327724461500000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        19,\n        \"0034327724461500000\",\n        \"0o34327724461500000\",\n    );\n    test_width(\n        \"1000000000000000\",\n        21,\n        \"000034327724461500000\",\n        \"0o0034327724461500000\",\n    );\n}\n\n#[test]\nfn to_octal_string_properties() {\n    natural_gen().test_properties(|x| {\n        let s = x.to_octal_string();\n        let prefixed_s = \"0o\".to_owned() + &s;\n        assert_eq!(format!(\"{x:#o}\"), prefixed_s);\n        assert_eq!(format!(\"{x:00o}\"), s);\n        assert_eq!(format!(\"{x:#00o}\"), prefixed_s);\n        assert_eq!(x.to_string_base(8), s);\n        assert_eq!(to_string_base_naive(&x, 8), s);\n        assert_eq!(NaturalAlt(x.clone()).to_octal_string(), s);\n        assert_eq!(format!(\"{:#o}\", NaturalAlt(x.clone())), prefixed_s);\n        assert_eq!(NaturalAlt2(x.clone()).to_octal_string(), s);\n        assert_eq!(format!(\"{:#o}\", NaturalAlt2(x.clone())), prefixed_s);\n        let num_x = BigUint::from(&x);\n        assert_eq!(num_x.to_octal_string(), s);\n        assert_eq!(format!(\"{num_x:#o}\"), prefixed_s);\n        let rug_x = rug::Integer::from(&x);\n        assert_eq!(rug_x.to_octal_string(), s);\n        assert_eq!(format!(\"{rug_x:#o}\"), prefixed_s);\n        assert!(string_is_subset(&s, \"01234567\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, width)| {\n        let s = x.to_octal_string();\n        let s_padded = format!(\"{x:0width$o}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$o}\", NaturalAlt(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$o}\", NaturalAlt2(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$o}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$o}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$o}\");\n        assert_eq!(\n            format!(\"{:#0width$o}\", NaturalAlt(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$o}\", NaturalAlt2(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$o}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$o}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    unsigned_gen::<Limb>().test_properties(|x| {\n        assert_eq!(Natural::from(x).to_octal_string(), x.to_octal_string());\n        assert_eq!(format!(\"{:#o}\", Natural::from(x)), format!(\"{x:#o}\"));\n    });\n\n    unsigned_pair_gen_var_2::<Limb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$o}\", Natural::from(x), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$o}\", Natural::from(x), width = width),\n            format!(\"{x:#0width$o}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_lower_hex_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_lower_hex_string(), out);\n        assert_eq!(to_string_base_naive(&x, 16), out);\n        assert_eq!(format!(\"{x:00x}\"), out);\n        assert_eq!(format!(\"{x:#x}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0x0\");\n    test(\"2\", \"2\", \"0x2\");\n    test(\"123\", \"7b\", \"0x7b\");\n    test(\"1000\", \"3e8\", \"0x3e8\");\n    test(\"1000000\", \"f4240\", \"0xf4240\");\n    test(\"1000000000000000\", \"38d7ea4c68000\", \"0x38d7ea4c68000\");\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        let s = x.to_lower_hex_string();\n        assert_eq!(format!(\"{x:0width$x}\"), out);\n        assert_eq!(format!(\"{x:#0width$x}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0x0\");\n    test_width(\"0\", 1, \"0\", \"0x0\");\n    test_width(\"0\", 2, \"00\", \"0x0\");\n    test_width(\"0\", 3, \"000\", \"0x0\");\n    test_width(\"0\", 4, \"0000\", \"0x00\");\n    test_width(\"0\", 5, \"00000\", \"0x000\");\n    test_width(\"1000\", 0, \"3e8\", \"0x3e8\");\n    test_width(\"1000\", 1, \"3e8\", \"0x3e8\");\n    test_width(\"1000\", 3, \"3e8\", \"0x3e8\");\n    test_width(\"1000\", 5, \"003e8\", \"0x3e8\");\n    test_width(\"1000\", 7, \"00003e8\", \"0x003e8\");\n    test_width(\"1000000000000000\", 0, \"38d7ea4c68000\", \"0x38d7ea4c68000\");\n    test_width(\"1000000000000000\", 1, \"38d7ea4c68000\", \"0x38d7ea4c68000\");\n    test_width(\"1000000000000000\", 15, \"0038d7ea4c68000\", \"0x38d7ea4c68000\");\n    test_width(\n        \"1000000000000000\",\n        17,\n        \"000038d7ea4c68000\",\n        \"0x0038d7ea4c68000\",\n    );\n}\n\n#[test]\npub fn test_to_upper_hex_string() {\n    fn test(u: &str, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_upper_hex_string(), out);\n        assert_eq!(to_string_base_naive(&x, 16).to_uppercase(), out);\n        assert_eq!(format!(\"{x:00X}\"), out);\n        assert_eq!(format!(\"{x:#X}\"), out_prefixed);\n    }\n    test(\"0\", \"0\", \"0x0\");\n    test(\"2\", \"2\", \"0x2\");\n    test(\"123\", \"7B\", \"0x7B\");\n    test(\"1000\", \"3E8\", \"0x3E8\");\n    test(\"1000000\", \"F4240\", \"0xF4240\");\n    test(\"1000000000000000\", \"38D7EA4C68000\", \"0x38D7EA4C68000\");\n\n    fn test_width(u: &str, width: usize, out: &str, out_prefixed: &str) {\n        let x = Natural::from_str(u).unwrap();\n        let s = x.to_upper_hex_string();\n        assert_eq!(format!(\"{x:0width$X}\"), out);\n        assert_eq!(format!(\"{x:#0width$X}\"), out_prefixed);\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 0, \"0\", \"0x0\");\n    test_width(\"0\", 1, \"0\", \"0x0\");\n    test_width(\"0\", 2, \"00\", \"0x0\");\n    test_width(\"0\", 3, \"000\", \"0x0\");\n    test_width(\"0\", 4, \"0000\", \"0x00\");\n    test_width(\"0\", 5, \"00000\", \"0x000\");\n    test_width(\"1000\", 0, \"3E8\", \"0x3E8\");\n    test_width(\"1000\", 1, \"3E8\", \"0x3E8\");\n    test_width(\"1000\", 3, \"3E8\", \"0x3E8\");\n    test_width(\"1000\", 5, \"003E8\", \"0x3E8\");\n    test_width(\"1000\", 7, \"00003E8\", \"0x003E8\");\n    test_width(\"1000000000000000\", 0, \"38D7EA4C68000\", \"0x38D7EA4C68000\");\n    test_width(\"1000000000000000\", 1, \"38D7EA4C68000\", \"0x38D7EA4C68000\");\n    test_width(\"1000000000000000\", 15, \"0038D7EA4C68000\", \"0x38D7EA4C68000\");\n    test_width(\n        \"1000000000000000\",\n        17,\n        \"000038D7EA4C68000\",\n        \"0x0038D7EA4C68000\",\n    );\n}\n\n#[test]\nfn to_hex_string_properties() {\n    natural_gen().test_properties(|x| {\n        let s = x.to_lower_hex_string();\n        let prefixed_s = \"0x\".to_owned() + &s;\n        assert_eq!(format!(\"{x:#x}\"), prefixed_s);\n        assert_eq!(x.to_upper_hex_string(), s.to_ascii_uppercase());\n        assert_eq!(format!(\"{x:#X}\"), \"0x\".to_owned() + &s.to_ascii_uppercase());\n        assert_eq!(format!(\"{x:00x}\"), s);\n        assert_eq!(format!(\"{x:#00x}\"), prefixed_s);\n        assert_eq!(format!(\"{x:00X}\"), s.to_ascii_uppercase());\n        assert_eq!(\n            format!(\"{x:#00X}\"),\n            \"0x\".to_owned() + &s.to_ascii_uppercase()\n        );\n        assert_eq!(x.to_string_base(16), s);\n        assert_eq!(to_string_base_naive(&x, 16), s);\n        assert_eq!(NaturalAlt(x.clone()).to_lower_hex_string(), s);\n        assert_eq!(format!(\"{:#x}\", NaturalAlt(x.clone())), prefixed_s);\n        assert_eq!(NaturalAlt2(x.clone()).to_lower_hex_string(), s);\n        assert_eq!(format!(\"{:#x}\", NaturalAlt2(x.clone())), prefixed_s);\n        let num_x = BigUint::from(&x);\n        assert_eq!(num_x.to_lower_hex_string(), s);\n        assert_eq!(format!(\"{num_x:#x}\"), prefixed_s);\n        let rug_x = rug::Integer::from(&x);\n        assert_eq!(rug_x.to_lower_hex_string(), s);\n        assert_eq!(format!(\"{rug_x:#x}\"), prefixed_s);\n        assert!(string_is_subset(&s, \"0123456789abcdef\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, width)| {\n        let s = x.to_lower_hex_string();\n        let s_padded = format!(\"{x:0width$x}\");\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$x}\", NaturalAlt(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$x}\", NaturalAlt2(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$x}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$x}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$x}\");\n        assert_eq!(\n            format!(\"{:#0width$x}\", NaturalAlt(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$x}\", NaturalAlt2(x.clone()), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$x}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$x}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s = x.to_upper_hex_string();\n        let s_padded_upper = format!(\"{x:0width$X}\");\n        assert_eq!(s_padded_upper, format!(\"{x:0width$x}\").to_ascii_uppercase());\n        let s_padded = s_padded_upper;\n        test_padding(&s, &s_padded, width);\n        assert_eq!(\n            format!(\"{:0width$X}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:0width$X}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n\n        let s_padded = format!(\"{x:#0width$X}\");\n        assert_eq!(\n            format!(\"{:#0width$X}\", BigUint::from(&x), width = width),\n            s_padded\n        );\n        assert_eq!(\n            format!(\"{:#0width$X}\", rug::Integer::from(&x), width = width),\n            s_padded\n        );\n    });\n\n    unsigned_gen::<Limb>().test_properties(|x| {\n        assert_eq!(\n            Natural::from(x).to_lower_hex_string(),\n            x.to_lower_hex_string()\n        );\n        assert_eq!(\n            Natural::from(x).to_upper_hex_string(),\n            x.to_upper_hex_string()\n        );\n        assert_eq!(format!(\"{:#x}\", Natural::from(x)), format!(\"{x:#x}\"));\n        assert_eq!(format!(\"{:#X}\", Natural::from(x)), format!(\"{x:#X}\"));\n    });\n\n    unsigned_pair_gen_var_2::<Limb, usize>().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$x}\", Natural::from(x), width = width),\n            format!(\"{x:0width$x}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$X}\", Natural::from(x), width = width),\n            format!(\"{x:0width$X}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$x}\", Natural::from(x), width = width),\n            format!(\"{x:#0width$x}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$X}\", Natural::from(x), width = width),\n            format!(\"{x:#0width$X}\")\n        );\n    });\n}\n\n#[test]\npub fn test_to_string_base() {\n    fn test(u: &str, base: u8, out: &str) {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_string_base(base), out);\n        assert_eq!(to_string_base_naive(&x, base), out);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(&x, base)), out);\n    }\n    test(\"0\", 2, \"0\");\n    test(\"0\", 3, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"0\", 16, \"0\");\n    test(\"0\", 17, \"0\");\n    test(\"2\", 3, \"2\");\n    test(\"2\", 10, \"2\");\n    test(\"2\", 16, \"2\");\n    test(\"2\", 17, \"2\");\n    test(\"123\", 8, \"173\");\n    test(\"1000000\", 10, \"1000000\");\n    test(\"1000000\", 20, \"65000\");\n    test(\"1000000\", 36, \"lfls\");\n    test(\"1000\", 2, \"1111101000\");\n    test(\"1000\", 3, \"1101001\");\n    test(\"1000\", 4, \"33220\");\n    test(\"1000\", 10, \"1000\");\n    test(\"1000\", 20, \"2a0\");\n    test(\"1000\", 36, \"rs\");\n    test(\n        \"1000000000000000\",\n        2,\n        \"11100011010111111010100100110001101000000000000000\",\n    );\n    test(\"1000000000000000\", 3, \"11212010201001210101011021212001\");\n    test(\"1000000000000000\", 4, \"3203113322210301220000000\");\n    test(\"1000000000000000\", 10, \"1000000000000000\");\n    test(\"1000000000000000\", 20, \"4hd2a0000000\");\n    test(\"1000000000000000\", 36, \"9ugxnorjls\");\n\n    fn test_width(u: &str, base: u8, width: usize, out: &str) {\n        let x = Natural::from_str(u).unwrap();\n        let s = x.to_string_base(base);\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:0width$?}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 2, 0, \"0\");\n    test_width(\"0\", 2, 1, \"0\");\n    test_width(\"0\", 2, 2, \"00\");\n    test_width(\"0\", 2, 5, \"00000\");\n    test_width(\"1000000\", 36, 0, \"lfls\");\n    test_width(\"1000000\", 36, 1, \"lfls\");\n    test_width(\"1000000\", 36, 2, \"lfls\");\n    test_width(\"1000000\", 36, 3, \"lfls\");\n    test_width(\"1000000\", 36, 4, \"lfls\");\n    test_width(\"1000000\", 36, 5, \"0lfls\");\n    test_width(\"1000000\", 36, 6, \"00lfls\");\n    test_width(\"1000000000000000\", 36, 0, \"9ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 1, \"9ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 10, \"9ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 11, \"09ugxnorjls\");\n    test_width(\"1000000000000000\", 36, 20, \"00000000009ugxnorjls\");\n}\n\n#[test]\nfn to_string_base_fail() {\n    assert_panic!(Natural::from(10u32).to_string_base(0));\n    assert_panic!(Natural::from(10u32).to_string_base(1));\n    assert_panic!(Natural::from(10u32).to_string_base(37));\n    assert_panic!(Natural::from(10u32).to_string_base(100));\n    assert_panic!(format!(\"{}\", BaseFmtWrapper::new(&Natural::from(10u32), 0)));\n    assert_panic!(format!(\"{}\", BaseFmtWrapper::new(&Natural::from(10u32), 1)));\n    assert_panic!(format!(\n        \"{}\",\n        BaseFmtWrapper::new(&Natural::from(10u32), 37)\n    ));\n    assert_panic!(format!(\n        \"{}\",\n        BaseFmtWrapper::new(&Natural::from(10u32), 100)\n    ));\n}\n\n#[test]\nfn to_string_base_properties() {\n    natural_unsigned_pair_gen_var_3().test_properties(|(x, base)| {\n        let s = x.to_string_base(base);\n        assert_eq!(to_string_base_naive(&x, base), s);\n        assert_eq!(format!(\"{}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:?}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:00}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:00?}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(x.to_string_base_upper(base), s.to_uppercase());\n        assert_eq!(Natural::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(&s, \"0123456789abcdefghijklmnopqrstuvwxyz\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(x.to_string_base(10), x.to_string());\n        assert_eq!(x.to_string_base(2), x.to_binary_string());\n        assert_eq!(x.to_string_base(8), x.to_octal_string());\n        assert_eq!(x.to_string_base(16), x.to_lower_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(Natural::ZERO.to_string_base(base), \"0\");\n        assert_eq!(Natural::ONE.to_string_base(base), \"1\");\n        assert_eq!(Natural::from(base).to_string_base(base), \"10\");\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_1().test_properties(|(x, base, width)| {\n        let fx = BaseFmtWrapper::new(&x, base);\n        let s = x.to_string_base(base);\n        let s_padded = format!(\"{fx:0width$}\");\n        assert_eq!(format!(\"{fx:0width$?}\"), s_padded);\n        assert_eq!(Natural::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s_padded,\n            \"0123456789abcdefghijklmnopqrstuvwxyz\"\n        ));\n        test_padding(&s, &s_padded, width);\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:0width$}\", BaseFmtWrapper::new(&x, 16), width = width),\n            format!(\"{x:0width$x}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:0width$}\",\n            BaseFmtWrapper::new(&Natural::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n\n    unsigned_triple_gen_var_6::<Limb, u8, usize>().test_properties(|(x, base, width)| {\n        assert_eq!(\n            format!(\n                \"{:0width$}\",\n                BaseFmtWrapper::new(&Natural::from(x), base),\n                width = width\n            ),\n            format!(\n                \"{:0width$}\",\n                BaseBaseFmtWrapper::new(x, base),\n                width = width\n            ),\n        );\n    });\n}\n\n#[test]\npub fn test_to_string_base_upper() {\n    fn test(u: &str, base: u8, out: &str) {\n        let x = Natural::from_str(u).unwrap();\n        assert_eq!(x.to_string_base_upper(base), out);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:#00}\", BaseFmtWrapper::new(&x, base)), out);\n        assert_eq!(format!(\"{:#00?}\", BaseFmtWrapper::new(&x, base)), out);\n    }\n    test(\"0\", 2, \"0\");\n    test(\"0\", 3, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"0\", 16, \"0\");\n    test(\"0\", 17, \"0\");\n    test(\"2\", 3, \"2\");\n    test(\"2\", 10, \"2\");\n    test(\"2\", 16, \"2\");\n    test(\"2\", 17, \"2\");\n    test(\"123\", 8, \"173\");\n    test(\"1000000\", 10, \"1000000\");\n    test(\"1000000\", 20, \"65000\");\n    test(\"1000000\", 36, \"LFLS\");\n    test(\"1000\", 2, \"1111101000\");\n    test(\"1000\", 3, \"1101001\");\n    test(\"1000\", 4, \"33220\");\n    test(\"1000\", 10, \"1000\");\n    test(\"1000\", 20, \"2A0\");\n    test(\"1000\", 36, \"RS\");\n    test(\n        \"1000000000000000\",\n        2,\n        \"11100011010111111010100100110001101000000000000000\",\n    );\n    test(\"1000000000000000\", 3, \"11212010201001210101011021212001\");\n    test(\"1000000000000000\", 4, \"3203113322210301220000000\");\n    test(\"1000000000000000\", 10, \"1000000000000000\");\n    test(\"1000000000000000\", 20, \"4HD2A0000000\");\n    test(\"1000000000000000\", 36, \"9UGXNORJLS\");\n\n    fn test_width(u: &str, base: u8, width: usize, out: &str) {\n        let x = Natural::from_str(u).unwrap();\n        let s = x.to_string_base_upper(base);\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        assert_eq!(\n            format!(\"{:#0width$?}\", BaseFmtWrapper::new(&x, base), width = width),\n            out\n        );\n        test_padding(&s, out, width);\n    }\n    test_width(\"0\", 2, 0, \"0\");\n    test_width(\"0\", 2, 1, \"0\");\n    test_width(\"0\", 2, 2, \"00\");\n    test_width(\"0\", 2, 5, \"00000\");\n    test_width(\"1000000\", 36, 0, \"LFLS\");\n    test_width(\"1000000\", 36, 1, \"LFLS\");\n    test_width(\"1000000\", 36, 2, \"LFLS\");\n    test_width(\"1000000\", 36, 3, \"LFLS\");\n    test_width(\"1000000\", 36, 4, \"LFLS\");\n    test_width(\"1000000\", 36, 5, \"0LFLS\");\n    test_width(\"1000000\", 36, 6, \"00LFLS\");\n    test_width(\"1000000000000000\", 36, 0, \"9UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 1, \"9UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 10, \"9UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 11, \"09UGXNORJLS\");\n    test_width(\"1000000000000000\", 36, 20, \"00000000009UGXNORJLS\");\n}\n\n#[test]\nfn to_string_base_upper_fail() {\n    assert_panic!(Natural::from(10u32).to_string_base_upper(0));\n    assert_panic!(Natural::from(10u32).to_string_base_upper(1));\n    assert_panic!(Natural::from(10u32).to_string_base_upper(37));\n    assert_panic!(Natural::from(10u32).to_string_base_upper(100));\n    assert_panic!(format!(\n        \"{:#}\",\n        BaseFmtWrapper::new(&Natural::from(10u32), 0)\n    ));\n    assert_panic!(format!(\n        \"{:#}\",\n        BaseFmtWrapper::new(&Natural::from(10u32), 1)\n    ));\n    assert_panic!(format!(\n        \"{:#}\",\n        BaseFmtWrapper::new(&Natural::from(10u32), 37)\n    ));\n    assert_panic!(format!(\n        \"{:#}\",\n        BaseFmtWrapper::new(&Natural::from(10u32), 100)\n    ));\n}\n\n#[test]\nfn to_string_base_upper_properties() {\n    natural_unsigned_pair_gen_var_3().test_properties(|(x, base)| {\n        let s = x.to_string_base_upper(base);\n        assert_eq!(format!(\"{:#}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:#?}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(format!(\"{:#00}\", BaseFmtWrapper::new(&x, base)), s);\n        assert_eq!(x.to_string_base(base), s.to_lowercase());\n        assert_eq!(Natural::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(&s, \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(x.to_string_base_upper(10), x.to_string());\n        assert_eq!(x.to_string_base_upper(2), x.to_binary_string());\n        assert_eq!(x.to_string_base_upper(8), x.to_octal_string());\n        assert_eq!(x.to_string_base_upper(16), x.to_upper_hex_string());\n    });\n\n    unsigned_gen_var_8().test_properties(|base| {\n        assert_eq!(Natural::ZERO.to_string_base_upper(base), \"0\");\n        assert_eq!(Natural::ONE.to_string_base_upper(base), \"1\");\n        assert_eq!(Natural::from(base).to_string_base_upper(base), \"10\");\n    });\n\n    natural_unsigned_unsigned_triple_gen_var_1().test_properties(|(x, base, width)| {\n        let fx = BaseFmtWrapper::new(&x, base);\n        let s = x.to_string_base_upper(base);\n        let s_padded = format!(\"{fx:#0width$}\");\n        assert_eq!(format!(\"{fx:#0width$?}\"), s_padded);\n        assert_eq!(Natural::from_string_base(base, &s).unwrap(), x);\n        assert!(string_is_subset(\n            &s_padded,\n            \"01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n        ));\n        test_padding(&s, &s_padded, width);\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(x, width)| {\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 10), width = width),\n            format!(\"{x:0width$}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 2), width = width),\n            format!(\"{x:0width$b}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 8), width = width),\n            format!(\"{x:0width$o}\")\n        );\n        assert_eq!(\n            format!(\"{:#0width$}\", BaseFmtWrapper::new(&x, 16), width = width),\n            format!(\"{x:0width$X}\")\n        );\n    });\n\n    unsigned_pair_gen_var_9::<usize, u8>().test_properties(|(width, base)| {\n        let s = format!(\n            \"{:#0width$}\",\n            BaseFmtWrapper::new(&Natural::ZERO, base),\n            width = width\n        );\n        assert_eq!(repeat_n('0', max(1, width)).collect::<String>(), s);\n    });\n\n    unsigned_triple_gen_var_6::<Limb, u8, usize>().test_properties(|(x, base, width)| {\n        assert_eq!(\n            format!(\n                \"{:#0width$}\",\n                BaseFmtWrapper::new(&Natural::from(x), base),\n                width = width\n            ),\n            format!(\n                \"{:#0width$}\",\n                BaseBaseFmtWrapper::new(x, base),\n                width = width\n            ),\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/conversion/to_limbs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::common::test_double_ended_iterator_size_hint;\nuse malachite_base::test_util::generators::unsigned_gen_var_5;\nuse malachite_nz::natural::Natural;\n#[cfg(feature = \"32_bit_limbs\")]\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_bool_vec_pair_gen_var_1, natural_gen, natural_unsigned_pair_gen_var_4,\n};\n#[cfg(feature = \"32_bit_limbs\")]\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_to_limbs_asc() {\n    let test = |n, out: &[Limb]| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(n.limbs().collect_vec(), out);\n        assert_eq!(n.to_limbs_asc(), out);\n        assert_eq!(n.as_limbs_asc(), out);\n        assert_eq!(n.into_limbs_asc(), out);\n    };\n    test(\"0\", &[]);\n    test(\"123\", &[123]);\n    test(\"1000000000000\", &[3567587328, 232]);\n    test(\"1701411834921604967429270619762735448065\", &[1, 2, 3, 4, 5]);\n    test(\"4294967295\", &[u32::MAX]);\n    test(\"4294967296\", &[0, 1]);\n    test(\"18446744073709551615\", &[u32::MAX, u32::MAX]);\n    test(\"18446744073709551616\", &[0, 0, 1]);\n\n    let n = Natural::from_str(\"1701411834921604967429270619762735448065\").unwrap();\n    let mut limbs = n.limbs();\n    assert_eq!(Some(1), limbs.next());\n    assert_eq!(Some(5), limbs.next_back());\n    assert_eq!(Some(4), limbs.next_back());\n    assert_eq!(Some(2), limbs.next());\n    assert_eq!(Some(3), limbs.next());\n    assert_eq!(None, limbs.next());\n    assert_eq!(None, limbs.next_back());\n\n    assert_eq!(limbs[0], 1);\n    assert_eq!(limbs[1], 2);\n    assert_eq!(limbs[2], 3);\n    assert_eq!(limbs[3], 4);\n    assert_eq!(limbs[4], 5);\n    assert_eq!(limbs[5], 0);\n\n    let mut limbs = n.limbs();\n    assert_eq!(Some(1), limbs.next());\n    assert_eq!(Some(2), limbs.next());\n    assert_eq!(Some(3), limbs.next());\n    assert_eq!(Some(5), limbs.next_back());\n    assert_eq!(Some(4), limbs.next_back());\n    assert_eq!(None, limbs.next());\n    assert_eq!(None, limbs.next_back());\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_to_limbs_desc() {\n    let test = |n, out: &[Limb]| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(n.limbs().rev().collect_vec(), out);\n        assert_eq!(n.to_limbs_desc(), out);\n        assert_eq!(n.into_limbs_desc(), out);\n    };\n    test(\"0\", &[]);\n    test(\"123\", &[123]);\n    test(\"1000000000000\", &[232, 3567587328]);\n    test(\"1701411834921604967429270619762735448065\", &[5, 4, 3, 2, 1]);\n    test(\"4294967295\", &[u32::MAX]);\n    test(\"4294967296\", &[1, 0]);\n    test(\"18446744073709551615\", &[u32::MAX, u32::MAX]);\n    test(\"18446744073709551616\", &[1, 0, 0]);\n}\n\n#[test]\nfn to_limbs_asc_properties() {\n    natural_gen().test_properties(|x| {\n        let limbs = x.to_limbs_asc();\n        assert_eq!(x.clone().into_limbs_asc(), limbs);\n        assert_eq!(x.as_limbs_asc(), limbs);\n        assert_eq!(x.limbs().collect_vec(), limbs);\n        assert_eq!(Natural::from_limbs_asc(&limbs), x);\n        if x != 0 {\n            assert_ne!(*limbs.last().unwrap(), 0);\n        }\n    });\n}\n\n#[test]\nfn to_limbs_desc_properties() {\n    natural_gen().test_properties(|x| {\n        let limbs = x.to_limbs_desc();\n        assert_eq!(x.clone().into_limbs_desc(), limbs);\n        assert_eq!(x.limbs().rev().collect_vec(), limbs);\n        assert_eq!(Natural::from_limbs_desc(&limbs), x);\n        if x != 0 {\n            assert_ne!(limbs[0], 0);\n        }\n    });\n}\n\n#[test]\nfn limbs_properties() {\n    natural_gen().test_properties(|n| {\n        test_double_ended_iterator_size_hint(n.limbs(), usize::exact_from(n.limb_count()));\n    });\n\n    natural_bool_vec_pair_gen_var_1().test_properties(|(n, bs)| {\n        let mut limbs = n.limbs();\n        let mut limb_vec = Vec::new();\n        let mut i = 0;\n        for b in bs {\n            if b {\n                limb_vec.insert(i, limbs.next().unwrap());\n                i += 1;\n            } else {\n                limb_vec.insert(i, limbs.next_back().unwrap());\n            }\n        }\n        assert!(limbs.next().is_none());\n        assert!(limbs.next_back().is_none());\n        assert_eq!(n.to_limbs_asc(), limb_vec);\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        if u < usize::exact_from(n.limb_count()) {\n            assert_eq!(n.limbs()[u], n.to_limbs_asc()[u]);\n        } else {\n            assert_eq!(n.limbs()[u], 0);\n        }\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(Natural::ZERO.limbs()[u], 0);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/exhaustive/exhaustive_natural_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_natural_inclusive_range;\n\nfn expected_range_len(a: &Natural, b: &Natural) -> usize {\n    usize::exact_from(b) - usize::exact_from(a) + 1\n}\n\nfn exhaustive_natural_inclusive_range_helper(a: Natural, b: Natural, values: &str) {\n    let xs = exhaustive_natural_inclusive_range(a.clone(), b.clone())\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n    let len = expected_range_len(&a, &b);\n    assert_eq!(\n        exhaustive_natural_inclusive_range(a.clone(), b.clone()).count(),\n        len\n    );\n    let mut init = exhaustive_natural_inclusive_range(a, b)\n        .rev()\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    init.reverse();\n    assert_eq!(xs, init.to_debug_string());\n}\n\n#[test]\nfn test_exhaustive_natural_inclusive_range() {\n    exhaustive_natural_inclusive_range_helper(Natural::ZERO, Natural::ZERO, \"[0]\");\n    exhaustive_natural_inclusive_range_helper(Natural::ZERO, Natural::ONE, \"[0, 1]\");\n    exhaustive_natural_inclusive_range_helper(\n        Natural::ZERO,\n        Natural::exact_from(10),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\",\n    );\n    exhaustive_natural_inclusive_range_helper(\n        Natural::exact_from(10),\n        Natural::exact_from(20),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\",\n    );\n    exhaustive_natural_inclusive_range_helper(\n        Natural::exact_from(10),\n        Natural::exact_from(100),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_natural_inclusive_range_fail() {\n    exhaustive_natural_inclusive_range(Natural::ONE, Natural::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/exhaustive/exhaustive_natural_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_natural_range;\n\nfn expected_range_len(a: &Natural, b: &Natural) -> usize {\n    usize::exact_from(b) - usize::exact_from(a)\n}\n\nfn exhaustive_natural_range_helper(a: Natural, b: Natural, values: &str) {\n    let xs = exhaustive_natural_range(a.clone(), b.clone())\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n    let len = expected_range_len(&a, &b);\n    assert_eq!(exhaustive_natural_range(a.clone(), b.clone()).count(), len);\n    let mut init = exhaustive_natural_range(a, b)\n        .rev()\n        .skip(len.saturating_sub(20))\n        .collect_vec();\n    init.reverse();\n    assert_eq!(xs, init.to_debug_string());\n}\n\n#[test]\nfn test_exhaustive_natural_range() {\n    exhaustive_natural_range_helper(Natural::ZERO, Natural::ZERO, \"[]\");\n    exhaustive_natural_range_helper(Natural::ZERO, Natural::ONE, \"[0]\");\n    exhaustive_natural_range_helper(\n        Natural::ZERO,\n        Natural::exact_from(10),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\",\n    );\n    exhaustive_natural_range_helper(\n        Natural::exact_from(10),\n        Natural::exact_from(20),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\",\n    );\n    exhaustive_natural_range_helper(\n        Natural::exact_from(10),\n        Natural::exact_from(100),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_natural_range_fail() {\n    exhaustive_natural_range(Natural::ONE, Natural::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/exhaustive/exhaustive_natural_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_natural_range_to_infinity;\n\nfn exhaustive_natural_range_to_infinity_helper(a: Natural, values: &str) {\n    let xs = exhaustive_natural_range_to_infinity(a)\n        .take(20)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_exhaustive_natural_range_to_infinity() {\n    exhaustive_natural_range_to_infinity_helper(\n        Natural::ZERO,\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\",\n    );\n    exhaustive_natural_range_to_infinity_helper(\n        Natural::exact_from(10),\n        \"[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/exhaustive/exhaustive_naturals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::exhaustive::exhaustive_naturals;\n\n#[test]\nfn test_exhaustive_naturals() {\n    assert_eq!(\n        exhaustive_naturals()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\"\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/exhaustive/exhaustive_positive_naturals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::exhaustive::exhaustive_positive_naturals;\n\n#[test]\nfn test_exhaustive_positive_naturals() {\n    assert_eq!(\n        exhaustive_positive_naturals()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\"\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/factorization/is_power.rs",
    "content": "// Copyright © 2026 William Youmans and Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Pow, Square};\nuse malachite_base::num::factorization::traits::{ExpressAsPower, IsPower};\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_4};\nuse std::str::FromStr;\n\n#[test]\nfn test_is_power() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().is_power(), out);\n        assert_eq!(\n            Natural::from_str(n).unwrap().express_as_power().is_some(),\n            out\n        );\n        assert_eq!(rug::Integer::from_str(n).unwrap().is_perfect_power(), out);\n    };\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"4\", true);\n    test(\"8\", true);\n    test(\"9\", true);\n    test(\"16\", true);\n    test(\"25\", true);\n    test(\"27\", true);\n    test(\"32\", true);\n    test(\"64\", true);\n    test(\"81\", true);\n    test(\"100\", true);\n    test(\"125\", true);\n    test(\"243\", true);\n    test(\"1024\", true);\n    test(\"1296\", true);\n    // - in get_perfect_power_natural\n    // - pow_2 != 1 first time in get_perfect_power_natural\n    // - !pow_2.is_prime() in get_perfect_power_natural\n    // - !(&q).divisible_by(&prime_nat) in get_perfect_power_natural\n    // - (&q).divisible_by(&prime_nat) in get_perfect_power_natural\n    // - (&q).divisible_by(&prime_squared)\n    // - pow_2 != 1 second time in get_perfect_power_natural\n    // - q == 1u32 || pow_2.is_prime() in get_perfect_power_natural\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000\",\n        true,\n    );\n    // - pow_2 == 0 in get_perfect_power_natural\n    // - nth <= bits in get_perfect_power_natural\n    // - pow_2 == 0 && let Some(root) = n.checked_root(nth) in get_perfect_power_natural\n    test(\"999898004334901741252806480882137569\", true);\n    // - pow_2 == 0 && let Some(root) != n.checked_root(nth) in get_perfect_power_natural\n    // - pow_2 == 0 && q > SMALLEST_OMITTED_PRIME in get_perfect_power_natural\n    test(\"999949000866995087\", true);\n    // - nth > bits in get_perfect_power_natural\n    test(\"999983\", false);\n    test(\"115230877647233745723406127208308085892801\", true);\n    // - !(&q).divisible_by(&prime_squared)\n    test(\"113\", false);\n\n    test(\"2\", false);\n    test(\"3\", false);\n    test(\"5\", false);\n    test(\"6\", false);\n    test(\"7\", false);\n    // - pow_2 == 1 first time in get_perfect_power_natural\n    test(\"10\", false);\n    test(\"12\", false);\n    test(\"15\", false);\n\n    // - pow_2.is_prime() in get_perfect_power_natural\n    test(\"1470862095575962348216\", false);\n    // - q != 1u32 && !pow_2.is_prime() in get_perfect_power_natural\n    test(\"242811787435972937453260179\", false);\n    // - pow_2 != 0 in get_perfect_power_natural\n    // - pow_2 % nth == 0 in get_perfect_power_natural\n    // - pow_2 != 0 && let Some(root) != n.checked_root(nth) in get_perfect_power_natural\n    // - pow_2 != 0 && q > SMALLEST_OMITTED_PRIME in get_perfect_power_natural\n    // - pow_2 % nth != 0 in get_perfect_power_natural\n    test(\"7176540100844819483539782848\", false);\n    // - pow_2 == 1 second time in get_perfect_power_natural\n    test(\n        \"23195532513672842039279098010453211078197157913306231000360318871559723303353757940843652\\\n        0540453520\",\n        false,\n    );\n    // - pow_2 != 0 && let Some(root) = n.checked_root(nth) in get_perfect_power_natural\n    test(\"4722366482869645213696\", true);\n    // - pow_2 != 0 && q <= SMALLEST_OMITTED_PRIME in get_perfect_power_natural\n    test(\"36353056192134643712\", false);\n}\n\n#[test]\nfn test_is_power_edge_cases() {\n    // Test some specific edge cases\n\n    // Powers of 2 that are perfect powers\n    let power_of_2_power: Natural = Natural::from(1u64) << 0x1000;\n    assert!(power_of_2_power.is_power());\n\n    let power_of_2_non_power = power_of_2_power + Natural::from(1u64);\n    assert!(!power_of_2_non_power.is_power());\n\n    // Large powers\n    let big_base = Natural::from_str(\"987654321098765432109876543210\").unwrap();\n    let big_power = (&big_base).pow(3);\n    assert!(big_power.is_power());\n\n    let big_non_power = &big_power + Natural::from(1u32);\n    assert!(!big_non_power.is_power());\n\n    // Test prime 1009 (SMALLEST_OMITTED_PRIME) - ensures termination\n    assert!(!Natural::from(1009u32).is_power());\n}\n\n#[test]\nfn test_express_as_power() {\n    let test = |n, out| {\n        assert_eq!(\n            Natural::from_str(n)\n                .unwrap()\n                .express_as_power()\n                .to_debug_string(),\n            out\n        );\n    };\n    test(\"0\", \"Some((0, 2))\");\n    test(\"1\", \"Some((1, 2))\");\n    test(\"4\", \"Some((2, 2))\");\n    test(\"8\", \"Some((2, 3))\");\n    test(\"9\", \"Some((3, 2))\");\n    test(\"16\", \"Some((2, 4))\");\n    test(\"25\", \"Some((5, 2))\");\n    test(\"27\", \"Some((3, 3))\");\n    test(\"32\", \"Some((2, 5))\");\n    test(\"64\", \"Some((2, 6))\");\n    test(\"81\", \"Some((3, 4))\");\n    test(\"100\", \"Some((10, 2))\");\n    test(\"125\", \"Some((5, 3))\");\n    test(\"243\", \"Some((3, 5))\");\n    test(\"1024\", \"Some((2, 10))\");\n    test(\"1296\", \"Some((6, 4))\");\n    test(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000\",\n        \"Some((10, 100))\",\n    );\n    test(\"999898004334901741252806480882137569\", \"Some((999983, 6))\");\n    test(\n        \"115230877647233745723406127208308085892801\",\n        \"Some((113, 20))\",\n    );\n\n    test(\"2\", \"None\");\n    test(\"3\", \"None\");\n    test(\"5\", \"None\");\n    test(\"6\", \"None\");\n    test(\"7\", \"None\");\n    test(\"10\", \"None\");\n    test(\"12\", \"None\");\n    test(\"15\", \"None\");\n}\n\n#[test]\nfn is_power_properties() {\n    natural_gen().test_properties(|x| {\n        let is_power = x.is_power();\n\n        // Consistency: is_power() should match express_as_power()\n        assert_eq!(\n            is_power,\n            x.express_as_power().is_some(),\n            \"is_power() and express_as_power() inconsistent for {x}\",\n        );\n        assert_eq!(rug::Integer::from(&x).is_perfect_power(), is_power);\n\n        // Any number raised to a power >= 2 should be a perfect power\n        if x > 1u32 {\n            let power_2 = (&x).square();\n            assert!(power_2.is_power(), \"{x}^2 should be a perfect power\");\n\n            let power_3 = (&x).pow(3);\n            assert!(power_3.is_power(), \"{x}^3 should be a perfect power\");\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4::<u64>().test_properties(|(x, y)| {\n        if y > 1 {\n            let power = (&x).pow(y);\n            assert!(power.is_power());\n        }\n    });\n}\n\n#[test]\nfn express_as_power_properties() {\n    natural_gen().test_properties(|x| {\n        if let Some((p, e)) = x.express_as_power() {\n            assert!(e > 1);\n            assert_eq!((&p).pow(e), x);\n            if x > 1u32 {\n                assert!(p.express_as_power().is_none());\n            }\n        }\n    });\n\n    natural_unsigned_pair_gen_var_4::<u64>().test_properties(|(x, y)| {\n        if y > 1 {\n            let power = (&x).pow(y);\n            let ope = power.express_as_power();\n            assert!(ope.is_some());\n            let (p, e) = ope.unwrap();\n            assert_eq!((&p).pow(e), power);\n            if x.express_as_power().is_none() {\n                assert_eq!(x, p);\n                assert_eq!(y, e);\n            }\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/factorization/is_square.rs",
    "content": "// Copyright © 2026 William Youmans\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedSqrt, Square};\nuse malachite_base::num::factorization::traits::IsSquare;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen_var_3};\nuse std::str::FromStr;\n\n#[test]\nfn test_is_square() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().is_square(), out);\n        assert_eq!(rug::Integer::from_str(n).unwrap().is_perfect_square(), out);\n    };\n    // Test small perfect squares\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"4\", true);\n    test(\"9\", true);\n    test(\"16\", true);\n    test(\"25\", true);\n    test(\"36\", true);\n    test(\"49\", true);\n    test(\"64\", true);\n    test(\"81\", true);\n    test(\"100\", true);\n\n    // Test small non-squares\n    test(\"2\", false);\n    test(\"3\", false);\n    test(\"5\", false);\n    test(\"6\", false);\n    test(\"7\", false);\n    test(\"8\", false);\n    test(\"10\", false);\n    test(\"11\", false);\n    test(\"12\", false);\n    test(\"13\", false);\n    test(\"14\", false);\n    test(\"15\", false);\n}\n\n#[test]\nfn test_is_square_edge_cases() {\n    // Test some specific edge cases\n\n    // Powers of 2 that are perfect squares\n    let power_of_2_square: Natural = Natural::from(1u64) << 0x1000;\n    assert!(power_of_2_square.is_square());\n\n    let power_of_2_non_square = power_of_2_square + Natural::from(1u64);\n    assert!(!power_of_2_non_square.is_square());\n\n    // Large squares\n    let big_base = Natural::from_str(\"987654321098765432109876543210\").unwrap();\n    let big_square = big_base.square();\n    assert!(big_square.is_square());\n\n    let big_non_square = &big_square + Natural::from(1u32);\n    assert!(!big_non_square.is_square());\n}\n\n#[test]\nfn is_square_properties() {\n    natural_gen().test_properties(|x| {\n        let is_square = x.is_square();\n        assert_eq!(is_square, (&x).checked_sqrt().is_some());\n        assert!((&x).square().is_square());\n        assert_eq!(rug::Integer::from(&x).is_perfect_square(), is_square);\n    });\n\n    natural_pair_gen_var_3().test_properties(|(a, b)| {\n        let sq = (&a).square();\n        // test non-square in range (a^2, (a+1)^2)\n        let non_sq = sq + (b % (Natural::from(2u64) * a)) + Natural::from(1u64);\n        assert!(!non_sq.is_square());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/factorization/primes.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::comparison::is_strictly_ascending;\nuse malachite_base::num::arithmetic::traits::SaturatingSub;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::factorization::traits::Primes;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen_var_9;\nuse std::str::FromStr;\n\n#[test]\nfn test_primes_less_than() {\n    let test = |n: &str, out: &str| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            Natural::primes_less_than(&n)\n                .collect_vec()\n                .to_debug_string(),\n            out\n        );\n        assert_eq!(\n            Natural::primes()\n                .take_while(|p| *p < n)\n                .collect_vec()\n                .to_debug_string(),\n            out\n        );\n    };\n    test(\"0\", \"[]\");\n    test(\"1\", \"[]\");\n    test(\"2\", \"[]\");\n    test(\"3\", \"[2]\");\n    test(\"4\", \"[2, 3]\");\n    test(\"5\", \"[2, 3]\");\n    test(\"6\", \"[2, 3, 5]\");\n    test(\"7\", \"[2, 3, 5]\");\n    test(\"8\", \"[2, 3, 5, 7]\");\n    test(\"9\", \"[2, 3, 5, 7]\");\n    test(\"10\", \"[2, 3, 5, 7]\");\n    test(\n        \"100\",\n        \"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, \\\n        89, 97]\",\n    );\n}\n\n#[test]\nfn test_primes_less_than_or_equal_to() {\n    let test = |n: &str, out: &str| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(\n            Natural::primes_less_than_or_equal_to(&n)\n                .collect_vec()\n                .to_debug_string(),\n            out\n        );\n        assert_eq!(\n            Natural::primes()\n                .take_while(|p| *p <= n)\n                .collect_vec()\n                .to_debug_string(),\n            out\n        );\n    };\n    test(\"0\", \"[]\");\n    test(\"1\", \"[]\");\n    test(\"2\", \"[2]\");\n    test(\"3\", \"[2, 3]\");\n    test(\"4\", \"[2, 3]\");\n    test(\"5\", \"[2, 3, 5]\");\n    test(\"6\", \"[2, 3, 5]\");\n    test(\"7\", \"[2, 3, 5, 7]\");\n    test(\"8\", \"[2, 3, 5, 7]\");\n    test(\"9\", \"[2, 3, 5, 7]\");\n    test(\"10\", \"[2, 3, 5, 7]\");\n    test(\n        \"100\",\n        \"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, \\\n        89, 97]\",\n    );\n}\n\n#[test]\nfn test_primes() {\n    let expected = \"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, \\\n    73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, \\\n    173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, \\\n    271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, \\\n    383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, \\\n    491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, \\\n    613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, \\\n    733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, \\\n    857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, \\\n    983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, \\\n    1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, \\\n    1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, \\\n    1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, \\\n    1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, \\\n    1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, \\\n    1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, \\\n    1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, \\\n    1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, \\\n    1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, \\\n    2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, \\\n    2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, \\\n    2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, \\\n    2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, \\\n    2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, \\\n    2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, \\\n    2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, \\\n    2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, \\\n    3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, \\\n    3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, \\\n    3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, \\\n    3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, \\\n    3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, \\\n    3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, \\\n    3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, \\\n    3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, \\\n    4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, \\\n    4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, \\\n    4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, \\\n    4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, \\\n    4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, \\\n    4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, \\\n    4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, \\\n    4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, \\\n    5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, \\\n    5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, \\\n    5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, \\\n    5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, \\\n    5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, \\\n    5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, \\\n    5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, \\\n    5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, \\\n    6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, \\\n    6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, \\\n    6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, \\\n    6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, \\\n    6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, \\\n    6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, \\\n    6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, \\\n    7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, \\\n    7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, \\\n    7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, \\\n    7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, \\\n    7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, \\\n    7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, \\\n    7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]\";\n    let ps = Natural::primes().take(1000).collect_vec();\n    assert!(ps.iter().all(Natural::is_valid));\n    assert_eq!(ps.to_debug_string(), expected);\n}\n\n#[test]\nfn primes_less_than_properties() {\n    natural_gen_var_9().test_properties(|n| {\n        let ps = Natural::primes_less_than(&n).collect_vec();\n        assert!(ps.iter().all(Natural::is_valid));\n        assert!(is_strictly_ascending(ps.iter()));\n        assert_eq!(\n            Natural::primes_less_than_or_equal_to(&(&n).saturating_sub(Natural::ONE)).collect_vec(),\n            ps\n        );\n        assert_eq!(Natural::primes().take_while(|p| *p < n).collect_vec(), ps);\n    });\n}\n\n#[test]\nfn primes_less_than_or_equal_to_properties() {\n    natural_gen_var_9().test_properties(|n| {\n        let ps = Natural::primes_less_than_or_equal_to(&n).collect_vec();\n        assert!(ps.iter().all(Natural::is_valid));\n        assert!(is_strictly_ascending(ps.iter()));\n        assert_eq!(\n            Natural::primes_less_than(&(&n + Natural::ONE)).collect_vec(),\n            ps\n        );\n        assert_eq!(Natural::primes().take_while(|p| *p <= n).collect_vec(), ps);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/and.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::CountOnes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_vec_pair_gen, unsigned_vec_pair_gen_var_6,\n    unsigned_vec_triple_gen_var_31, unsigned_vec_triple_gen_var_32,\n    unsigned_vec_unsigned_pair_gen_var_15,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::and::{\n    limbs_and, limbs_and_in_place_either, limbs_and_limb, limbs_and_same_length_to_out,\n    limbs_and_to_out, limbs_slice_and_in_place_left, limbs_slice_and_same_length_in_place_left,\n    limbs_vec_and_in_place_left,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse malachite_nz::test_util::natural::logic::and::{natural_and_alt_1, natural_and_alt_2};\nuse num::BigUint;\nuse rug;\nuse std::cmp::max;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_limb() {\n    let test = |xs: &[Limb], y: Limb, out: Limb| {\n        assert_eq!(limbs_and_limb(xs, y), out);\n    };\n    test(&[6, 7], 2, 2);\n    test(&[100, 101, 102], 10, 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nconst fn limbs_and_limb_fail() {\n    limbs_and_limb(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_and_limbs_vec_and_in_place_left() {\n    let test = |xs_before, ys, out| {\n        assert_eq!(limbs_and(xs_before, ys), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_vec_and_in_place_left(&mut xs, ys);\n        assert_eq!(xs, out);\n    };\n    test(&[], &[], vec![]);\n    test(&[2], &[3], vec![2]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 0, 1]);\n    test(&[6, 7], &[1, 2, 3], vec![0, 2]);\n    test(&[1, 2, 3], &[6, 7], vec![0, 2]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![100, 101, 100]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_same_length_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_and_same_length_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], vec![0, 0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[5, 5, 5, 5], vec![1, 0, 1, 5]);\n    test(&[6, 7], &[1, 2], &[0, 0], vec![0, 2]);\n    test(&[6, 7], &[1, 2], &[10, 10, 10, 10], vec![0, 2, 10, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![100, 101, 100, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_same_length_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_and_same_length_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_same_length_to_out_fail_2() {\n    let mut out = vec![10];\n    limbs_and_same_length_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_and_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], vec![0, 0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[5, 5, 5, 5], vec![1, 0, 1, 5]);\n    test(&[6, 7], &[1, 2, 3], &[10, 10, 10, 10], vec![0, 2, 0, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10, 10, 10, 10], vec![0, 2, 0, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![100, 101, 100, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_and_to_out_fail() {\n    let mut out = vec![10, 10];\n    limbs_and_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_and_same_length_in_place_left() {\n    let test = |xs_before: &[Limb], ys, xs_after| {\n        let mut xs = xs_before.to_vec();\n        limbs_slice_and_same_length_in_place_left(&mut xs, ys);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], vec![]);\n    test(&[6, 7], &[1, 2], vec![0, 2]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 0, 1]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![100, 101, 100]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_and_same_length_in_place_left_fail() {\n    let mut out = vec![6, 7];\n    limbs_slice_and_same_length_in_place_left(&mut out, &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_and_in_place_left() {\n    let test = |xs_before: &[Limb], ys, truncate_length, xs_after| {\n        let mut xs = xs_before.to_vec();\n        assert_eq!(limbs_slice_and_in_place_left(&mut xs, ys), truncate_length);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], None, vec![]);\n    test(&[6, 7], &[1, 2], None, vec![0, 2]);\n    test(&[6, 7], &[1, 2, 3], None, vec![0, 2]);\n    test(&[1, 2, 3], &[6, 7], Some(2), vec![0, 2, 3]);\n    test(&[], &[1, 2, 3], None, vec![]);\n    test(&[1, 2, 3], &[], Some(0), vec![1, 2, 3]);\n    test(&[1, 1, 1], &[1, 2, 3], None, vec![1, 0, 1]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        None,\n        vec![100, 101, 100],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_and_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], right, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_and_in_place_either(&mut xs, &mut ys), right);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], false, vec![], vec![]);\n    test(&[6, 7], &[1, 2], false, vec![0, 2], vec![1, 2]);\n    test(&[6, 7], &[1, 2, 3], false, vec![0, 2], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[6, 7], true, vec![1, 2, 3], vec![0, 2]);\n    test(&[], &[1, 2, 3], false, vec![], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[], true, vec![1, 2, 3], vec![]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![1, 0, 1], vec![1, 2, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![100, 101, 100],\n        vec![102, 101, 100],\n    );\n}\n\n#[test]\nfn test_and() {\n    let test = |u, v, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n &= Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = Natural::from_str(u).unwrap();\n        n &= &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::from_str(u).unwrap() & Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &Natural::from_str(u).unwrap() & Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::from_str(u).unwrap() & &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &Natural::from_str(u).unwrap() & &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!(\n            natural_and_alt_1(\n                &Natural::from_str(u).unwrap(),\n                &Natural::from_str(v).unwrap(),\n            )\n            .to_string(),\n            out\n        );\n        assert_eq!(\n            natural_and_alt_2(\n                &Natural::from_str(u).unwrap(),\n                &Natural::from_str(v).unwrap(),\n            )\n            .to_string(),\n            out\n        );\n\n        let n = BigUint::from_str(u).unwrap() & BigUint::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(u).unwrap() & rug::Integer::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"123\", \"0\", \"0\");\n    test(\"123\", \"456\", \"72\");\n    test(\"1000000000000\", \"123\", \"0\");\n    test(\"123\", \"1000000000000\", \"0\");\n    test(\"1000000000001\", \"123\", \"1\");\n    test(\"12345678987654321\", \"987654321\", \"579887281\");\n    test(\"1000000000000\", \"999999999999\", \"999999995904\");\n    test(\"12345678987654321\", \"314159265358979\", \"312331665941633\");\n}\n\n#[test]\nfn limbs_and_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            limbs_and_limb(&xs, y),\n            Natural::from_owned_limbs_asc(xs) & Natural::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_and_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_and(&xs, &ys)),\n            Natural::from_owned_limbs_asc(xs) & Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_and_same_length_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_31().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_and_same_length_to_out(&mut out, &xs, &ys);\n        let len = xs.len();\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Natural::from_owned_limbs_asc(xs) & Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_and_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_32().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_and_to_out(&mut out, &xs, &ys);\n        let len = max(xs.len(), ys.len());\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Natural::from_owned_limbs_asc(xs) & Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_slice_and_same_length_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_slice_and_same_length_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(xs_old) & Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_slice_and_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        let truncate_size = limbs_slice_and_in_place_left(&mut xs, &ys);\n        let n = Natural::from_limbs_asc(&xs_old) & Natural::from_owned_limbs_asc(ys);\n        if let Some(truncate_size) = truncate_size {\n            assert_eq!(Natural::from_limbs_asc(&xs[..truncate_size]), n);\n            assert_eq!(&xs[truncate_size..], &xs_old[truncate_size..]);\n        } else {\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        }\n    });\n}\n\n#[test]\nfn limbs_vec_and_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_vec_and_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(xs_old) & Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_and_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_and_in_place_either(&mut xs, &mut ys);\n        let n = Natural::from_limbs_asc(&xs_old) & Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(Natural::from_owned_limbs_asc(ys), n);\n        } else {\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn and_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let result_val_val = x.clone() & y.clone();\n        let result_val_ref = x.clone() & &y;\n        let result_ref_val = &x & y.clone();\n        let result = &x & &y;\n        assert!(result_val_val.is_valid());\n        assert!(result_val_ref.is_valid());\n        assert!(result_ref_val.is_valid());\n        assert!(result.is_valid());\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        let mut mut_x = x.clone();\n        mut_x &= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, result);\n        let mut mut_x = x.clone();\n        mut_x &= &y;\n        assert_eq!(mut_x, result);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x &= rug::Integer::from(&y);\n        assert_eq!(Natural::exact_from(&mut_x), result);\n\n        assert_eq!(\n            Natural::from(&(BigUint::from(&x) & BigUint::from(&y))),\n            result\n        );\n        assert_eq!(\n            Natural::exact_from(&(rug::Integer::from(&x) & rug::Integer::from(&y))),\n            result\n        );\n\n        assert_eq!(natural_and_alt_1(&x, &y), result);\n        assert_eq!(natural_and_alt_2(&x, &y), result);\n\n        assert_eq!(&y & &x, result);\n        assert_eq!(&result & &x, result);\n        assert_eq!(&result & &y, result);\n\n        assert!(result <= x);\n        assert!(result <= y);\n\n        let ones = result.count_ones();\n        assert!(ones <= x.count_ones());\n        assert!(ones <= y.count_ones());\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(&x & Natural::ZERO, 0);\n        assert_eq!(Natural::ZERO & &x, 0);\n        assert_eq!(&x & &x, x);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x & &y) & &z, x & (y & z));\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x) & Natural::from(y), x & y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/assign_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_unsigned_bool_triple_gen_var_1;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_assign_bit() {\n    let test = |u, index, bit, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n.assign_bit(index, bit);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n.set_bit(u32::exact_from(index), bit);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 10, true, \"1024\");\n    test(\"100\", 0, true, \"101\");\n    test(\"1000000000000\", 10, true, \"1000000001024\");\n    test(\n        \"1000000000000\",\n        100,\n        true,\n        \"1267650600228229402496703205376\",\n    );\n    test(\"5\", 100, true, \"1267650600228229401496703205381\");\n    test(\"0\", 10, false, \"0\");\n    test(\"0\", 100, false, \"0\");\n    test(\"1024\", 10, false, \"0\");\n    test(\"101\", 0, false, \"100\");\n    test(\"1000000001024\", 10, false, \"1000000000000\");\n    test(\"1000000001024\", 100, false, \"1000000001024\");\n    test(\n        \"1267650600228229402496703205376\",\n        100,\n        false,\n        \"1000000000000\",\n    );\n    test(\"1267650600228229401496703205381\", 100, false, \"5\");\n}\n\n#[test]\nfn assign_bit_properties() {\n    natural_unsigned_bool_triple_gen_var_1().test_properties(|(n, index, bit)| {\n        let mut mut_n = n.clone();\n        mut_n.assign_bit(index, bit);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n.set_bit(u32::exact_from(index), bit);\n        assert_eq!(Natural::exact_from(&rug_n), result);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/assign_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{ModPowerOf2, ModPowerOf2Sub, NegModPowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::logic::traits::{BitBlockAccess, SignificantBits};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::large_type_gen_var_3;\nuse malachite_base::test_util::num::logic::bit_block_access::assign_bits_naive;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_block_access::limbs_assign_bits;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_gen, natural_natural_unsigned_triple_gen, natural_unsigned_pair_gen_var_4,\n    natural_unsigned_unsigned_natural_quadruple_gen_var_1,\n};\nuse std::str::FromStr;\n\nfn verify_limbs_assign_bits(xs: &[Limb], start: u64, end: u64, bits: &[Limb], out: &[Limb]) {\n    let old_n = Natural::from_limbs_asc(xs);\n    let mut n = old_n.clone();\n    let bits = Natural::from_limbs_asc(bits);\n    n.assign_bits(start, end, &bits);\n    let result = n;\n    assert_eq!(Natural::from_limbs_asc(out), result);\n    let mut n = old_n;\n    assign_bits_naive::<Natural, Natural>(&mut n, start, end, &bits);\n    assert_eq!(n, result);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_assign_bits() {\n    let test = |xs: &[Limb], start: u64, end: u64, bits: &[Limb], out: &[Limb]| {\n        let xs_old = xs;\n        let mut xs = xs.to_vec();\n        limbs_assign_bits(&mut xs, start, end, bits);\n        assert_eq!(xs, out);\n        verify_limbs_assign_bits(xs_old, start, end, bits, out);\n    };\n    // - bits_limb_width >= bits.len()\n    // - end_limb <= limbs.len()\n    // - xs_len <= ys_len in copy_from_diff_len_slice\n    // - start_remainder == 0\n    // - end_remainder != 0\n    test(&[1], 0, 1, &[1], &[1]);\n    // - start_remainder != 0\n    test(&[1], 1, 2, &[1], &[3]);\n    // - bits_limb_width < bits.len()\n    test(&[1], 0, 1, &[0, 1], &[0]);\n    test(&[123], 64, 128, &[456], &[123, 0, 456, 0]);\n    test(&[123], 80, 100, &[456], &[123, 0, 29884416, 0]);\n    test(&[123, 456], 80, 100, &[789, 321], &[123, 456, 51707904, 0]);\n    // - end_limb > limbs.len()\n    test(\n        &[1619367413, 294928230],\n        73,\n        89,\n        &[4211621339, 3627566573, 1208090001, 4045783696, 2932656682, 177881999, 898588654],\n        &[1619367413, 294928230, 8107520],\n    );\n    // - end_remainder == 0\n    test(\n        &[1404969050, 495263765, 2378891263, 1299524786, 1654909014, 2724647948],\n        21,\n        32,\n        &[\n            3269073749, 1170977875, 2823122906, 144832001, 3738801070, 1107604886, 4260406413,\n            1766163855, 592730267, 484513503, 1204041536, 3664297641,\n        ],\n        &[1790845018, 495263765, 2378891263, 1299524786, 1654909014, 2724647948],\n    );\n    // - xs_len > ys_len in copy_from_diff_len_slice\n    test(\n        &[\n            4126931041, 1467617913, 1718397261, 904474857, 312429577, 2397873671, 3967827549,\n            3842236128, 3414636734, 1846949256, 1999024107, 424639176,\n        ],\n        27,\n        77,\n        &[977841009],\n        &[\n            2382100577, 30557531, 1718394880, 904474857, 312429577, 2397873671, 3967827549,\n            3842236128, 3414636734, 1846949256, 1999024107, 424639176,\n        ],\n    );\n}\n\n#[test]\n#[should_panic]\nfn limbs_assign_bits_fail_1() {\n    let mut xs = vec![123];\n    limbs_assign_bits(&mut xs, 10, 5, &[456]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_assign_bits_fail_2() {\n    let mut xs = vec![123];\n    limbs_assign_bits(&mut xs, 10, 10, &[456]);\n}\n\n#[test]\nfn test_assign_bits() {\n    let test = |u, start, end, v, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n.assign_bits(start, end, &Natural::from_str(v).unwrap());\n        assert_eq!(n, Natural::from_str(out).unwrap());\n        let mut n = Natural::from_str(u).unwrap();\n        assign_bits_naive(&mut n, start, end, &Natural::from_str(v).unwrap());\n        assert_eq!(n, Natural::from_str(out).unwrap());\n    };\n    test(\"123\", 10, 10, \"456\", \"123\");\n    test(\"123\", 5, 7, \"456\", \"27\");\n    test(\"123\", 64, 128, \"456\", \"8411715297611555537019\");\n    test(\"123\", 80, 100, \"456\", \"551270173744270903666016379\");\n    test(\n        \"1000000000000\",\n        80,\n        100,\n        \"456\",\n        \"551270173744271903666016256\",\n    );\n    test(\n        \"456\",\n        80,\n        100,\n        \"1000000000000\",\n        \"401092572728463209067316249032\",\n    );\n    test(\n        \"1000000000000\",\n        80,\n        100,\n        \"2000000000000\",\n        \"802185145456926419134632497152\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn assign_bits_fail() {\n    let mut n = Natural::from(123u32);\n    n.assign_bits(10, 5, &Natural::from(456u32));\n}\n\n#[test]\nfn limbs_assign_bits_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    large_type_gen_var_3().test_properties_with_config(&config, |(xs_in, start, end, ref bits)| {\n        let mut xs = xs_in.clone();\n        limbs_assign_bits(&mut xs, start, end, bits);\n        verify_limbs_assign_bits(&xs_in, start, end, bits, &xs);\n    });\n}\n\n#[test]\nfn assign_bits_properties() {\n    natural_unsigned_unsigned_natural_quadruple_gen_var_1().test_properties(\n        |(n, start, end, bits)| {\n            let old_n = n;\n            let mut n = old_n.clone();\n            n.assign_bits(start, end, &bits);\n            let result = n;\n            let mut n = old_n.clone();\n            assign_bits_naive(&mut n, start, end, &bits);\n            assert_eq!(n, result);\n            n.assign_bits(start, end, &bits);\n            assert_eq!(n, result);\n            let bits_width = end - start;\n            assert_eq!(n.get_bits(start, end), (&bits).mod_power_of_2(bits_width));\n            let mut n = !old_n;\n            let not_bits = bits\n                .neg_mod_power_of_2(bits_width)\n                .mod_power_of_2_sub(Natural::ONE, bits_width);\n            n.assign_bits(start, end, &not_bits);\n            assert_eq!(!n, result);\n        },\n    );\n\n    natural_natural_unsigned_triple_gen().test_properties(|(n, bits, start)| {\n        let old_n = n;\n        let mut n = old_n.clone();\n        n.assign_bits(start, start, &bits);\n        assert_eq!(n, old_n);\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(bits, start)| {\n        let mut n = Natural::ZERO;\n        n.assign_bits(start, start + bits.significant_bits(), &bits);\n        assert_eq!(n, bits << start);\n    });\n\n    natural_gen().test_properties(|n| {\n        let old_n = n;\n        let mut n = old_n.clone();\n        n.assign_bits(0, old_n.significant_bits(), &Natural::ZERO);\n        assert_eq!(n, 0);\n\n        let mut n = Natural::ZERO;\n        n.assign_bits(0, old_n.significant_bits(), &old_n);\n        assert_eq!(n, old_n);\n\n        let mut n = old_n.clone();\n        n.assign_bits(0, old_n.significant_bits(), &old_n);\n        assert_eq!(n, old_n);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable, SignificantBits};\nuse malachite_base::test_util::common::test_double_ended_iterator_size_hint;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_gen_var_5};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_bool_vec_pair_gen_var_2, natural_gen, natural_unsigned_pair_gen_var_4,\n};\n\n#[test]\nfn test_bits() {\n    let n = Natural::from(105u32);\n    let mut bits = n.bits();\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n\n    assert_eq!(bits[0], true);\n    assert_eq!(bits[1], false);\n    assert_eq!(bits[2], false);\n    assert_eq!(bits[3], true);\n    assert_eq!(bits[4], false);\n    assert_eq!(bits[5], true);\n    assert_eq!(bits[6], true);\n    assert_eq!(bits[7], false);\n    assert_eq!(bits[8], false);\n\n    let mut bits = n.bits();\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next(), Some(true));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next(), Some(false));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next_back(), Some(false));\n    assert_eq!(bits.next_back(), Some(true));\n    assert_eq!(bits.next(), None);\n    assert_eq!(bits.next_back(), None);\n}\n\n#[test]\nfn bits_properties() {\n    natural_gen().test_properties(|n| {\n        test_double_ended_iterator_size_hint(n.bits(), usize::exact_from(n.significant_bits()));\n    });\n\n    natural_bool_vec_pair_gen_var_2().test_properties(|(n, bs)| {\n        let mut bits = n.bits();\n        let mut bit_vec = Vec::new();\n        let mut i = 0;\n        for &b in &bs {\n            if b {\n                bit_vec.insert(i, bits.next().unwrap());\n                i += 1;\n            } else {\n                bit_vec.insert(i, bits.next_back().unwrap());\n            }\n        }\n        assert!(bits.next().is_none());\n        assert!(bits.next_back().is_none());\n        assert_eq!(n.to_bits_asc(), bit_vec);\n    });\n\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        if u < n.significant_bits() {\n            assert_eq!(n.bits()[u], n.to_bits_asc()[usize::exact_from(u)]);\n        } else {\n            assert_eq!(n.bits()[u], false);\n        }\n    });\n\n    unsigned_gen_var_5().test_properties(|u| {\n        assert_eq!(Natural::ZERO.bits()[u], false);\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert!(u.bits().eq(Natural::from(u).bits()));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/clear_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_16,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_access::limbs_clear_bit;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\n#[cfg(feature = \"32_bit_limbs\")]\nuse rug;\n#[cfg(feature = \"32_bit_limbs\")]\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_clear_bit() {\n    let test = |xs: &[Limb], index: u64, out: &[Limb]| {\n        let mut xs = xs.to_vec();\n        limbs_clear_bit(&mut xs, index);\n        assert_eq!(xs, out);\n    };\n    test(&[3, 3], 33, &[3, 1]);\n    test(&[3, 1], 1, &[1, 1]);\n    test(&[3, 3], 100, &[3, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_clear_bit() {\n    let test = |u, index, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n.clear_bit(index);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n.set_bit(u32::exact_from(index), false);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 10, \"0\");\n    test(\"0\", 100, \"0\");\n    test(\"1024\", 10, \"0\");\n    test(\"101\", 0, \"100\");\n    test(\"1000000001024\", 10, \"1000000000000\");\n    test(\"1000000001024\", 100, \"1000000001024\");\n    test(\"1267650600228229402496703205376\", 100, \"1000000000000\");\n    test(\"1267650600228229401496703205381\", 100, \"5\");\n}\n\n#[test]\nfn limbs_clear_bit_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, index)| {\n        let mut mut_xs = xs.clone();\n        let mut n = Natural::from_limbs_asc(&xs);\n        limbs_clear_bit(&mut mut_xs, index);\n        n.clear_bit(index);\n        assert_eq!(Natural::from_limbs_asc(&mut_xs), n);\n    });\n}\n\n#[test]\nfn clear_bit_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, index)| {\n        let mut mut_n = n.clone();\n        mut_n.clear_bit(index);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n.set_bit(u32::exact_from(index), false);\n        assert_eq!(Natural::exact_from(&rug_n), result);\n\n        let mut mut_n = n.clone();\n        mut_n.assign_bit(index, false);\n        assert_eq!(mut_n, result);\n\n        assert_eq!(Integer::from(&n) & !Natural::power_of_2(index), result);\n\n        assert!(result <= n);\n        if n.get_bit(index) {\n            assert_ne!(result, n);\n            let mut mut_result = result;\n            mut_result.set_bit(index);\n            assert_eq!(mut_result, n);\n        } else {\n            assert_eq!(result, n);\n        }\n    });\n\n    unsigned_pair_gen_var_2::<Limb, u64>().test_properties(|(u, index)| {\n        let mut mut_u = u;\n        mut_u.clear_bit(index);\n        let mut n = Natural::from(u);\n        n.clear_bit(index);\n        assert_eq!(n, mut_u);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/count_ones.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::logic::traits::CountOnes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_gen, unsigned_vec_gen};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::count_ones::limbs_count_ones;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::logic::count_ones::{\n    natural_count_ones_alt_1, natural_count_ones_alt_2,\n};\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_count_ones() {\n    let test = |xs, out| {\n        assert_eq!(limbs_count_ones(xs), out);\n    };\n    test(&[], 0);\n    test(&[0, 1, 2], 2);\n    test(&[1, u32::MAX], 33);\n}\n\n#[test]\nfn test_count_ones() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().count_ones(), out);\n        assert_eq!(\n            natural_count_ones_alt_1(&Natural::from_str(n).unwrap()),\n            out\n        );\n        assert_eq!(\n            natural_count_ones_alt_2(&Natural::from_str(n).unwrap()),\n            out\n        );\n    };\n    test(\"0\", 0);\n    test(\"105\", 4);\n    test(\"1000000000000\", 13);\n    test(\"4294967295\", 32);\n    test(\"4294967296\", 1);\n    test(\"18446744073709551615\", 64);\n    test(\"18446744073709551616\", 1);\n}\n\n#[test]\nfn limbs_count_ones_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        assert_eq!(\n            limbs_count_ones(&xs),\n            Natural::from_owned_limbs_asc(xs).count_ones()\n        );\n    });\n}\n\n#[test]\nfn count_ones_properties() {\n    natural_gen().test_properties(|x| {\n        let ones = x.count_ones();\n        assert_eq!(natural_count_ones_alt_1(&x), ones);\n        assert_eq!(natural_count_ones_alt_2(&x), ones);\n        assert_eq!(ones == 0, x == 0);\n        assert_eq!(ones == 1, x.is_power_of_2());\n        assert_eq!((!x).checked_count_zeros(), Some(ones));\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(Natural::from(u).count_ones(), CountOnes::count_ones(u));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/flip_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_flip_bit() {\n    let test = |u, index, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n.flip_bit(index);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n.toggle_bit(u32::exact_from(index));\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 10, \"1024\");\n    test(\"1024\", 10, \"0\");\n    test(\"100\", 0, \"101\");\n    test(\"101\", 0, \"100\");\n    test(\"1000000000000\", 10, \"1000000001024\");\n    test(\"1000000001024\", 10, \"1000000000000\");\n    test(\"1000000000000\", 100, \"1267650600228229402496703205376\");\n    test(\"1267650600228229402496703205376\", 100, \"1000000000000\");\n    test(\"5\", 100, \"1267650600228229401496703205381\");\n    test(\"1267650600228229401496703205381\", 100, \"5\");\n}\n\n#[test]\nfn flip_bit_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, index)| {\n        let mut mut_n = n.clone();\n        mut_n.flip_bit(index);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n        assert_ne!(result, n);\n\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n.toggle_bit(u32::exact_from(index));\n        assert_eq!(Natural::exact_from(&rug_n), result);\n\n        let mut mut_result = result.clone();\n        mut_result.flip_bit(index);\n        assert_eq!(mut_result, n);\n\n        assert_eq!(n ^ Natural::power_of_2(index), result);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/from_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::num::logic::traits::BitConvertible;\nuse malachite_base::test_util::generators::bool_vec_gen;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::num::logic::bit_convertible::{\n    from_bits_asc_alt, from_bits_desc_alt,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::natural::logic::from_bits::{\n    from_bits_asc_naive, from_bits_desc_naive,\n};\n\n#[test]\nfn test_from_bits_asc() {\n    let test = |bits: &[bool], out| {\n        let x = Natural::from_bits_asc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(&[], \"0\");\n    test(&[false], \"0\");\n    test(&[false, false, false], \"0\");\n    test(&[true], \"1\");\n    test(&[false, true, true], \"6\");\n    test(&[true, false, false, true, false, true, true], \"105\");\n    test(&[true, false, false, true, false, true, true, false], \"105\");\n    test(\n        &[true, false, false, true, false, true, true, false, false, false],\n        \"105\",\n    );\n    test(\n        &[\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, false, false, false, true, false, true, false, false, true, false, true, false,\n            false, true, false, true, false, true, true, false, false, false, true, false, true,\n            true, true,\n        ],\n        \"1000000000000\",\n    );\n    test(\n        &[\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, false, false, false, true, false, true, false, false, true, false, true, false,\n            false, true, false, true, false, true, true, false, false, false, true, false, true,\n            true, true, false,\n        ],\n        \"1000000000000\",\n    );\n}\n\n#[test]\nfn test_from_bits_desc() {\n    let test = |bits: &[bool], out| {\n        let x = Natural::from_bits_desc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(&[], \"0\");\n    test(&[false], \"0\");\n    test(&[false, false, false], \"0\");\n    test(&[true], \"1\");\n    test(&[true, true, false], \"6\");\n    test(&[true, true, false, true, false, false, true], \"105\");\n    test(&[false, true, true, false, true, false, false, true], \"105\");\n    test(\n        &[false, false, false, true, true, false, true, false, false, true],\n        \"105\",\n    );\n    test(\n        &[\n            true, true, true, false, true, false, false, false, true, true, false, true, false,\n            true, false, false, true, false, true, false, false, true, false, true, false, false,\n            false, true, false, false, false, false, false, false, false, false, false, false,\n            false, false,\n        ],\n        \"1000000000000\",\n    );\n    test(\n        &[\n            false, true, true, true, false, true, false, false, false, true, true, false, true,\n            false, true, false, false, true, false, true, false, false, true, false, true, false,\n            false, false, true, false, false, false, false, false, false, false, false, false,\n            false, false, false,\n        ],\n        \"1000000000000\",\n    );\n}\n\n#[test]\nfn from_bits_asc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 1024);\n    config.insert(\"mean_stripe_n\", 512);\n    bool_vec_gen().test_properties_with_config(&config, |bits| {\n        let x = Natural::from_bits_asc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(from_bits_asc_naive(bits.iter().copied()), x);\n        assert_eq!(from_bits_asc_alt::<Natural, _>(bits.iter().copied()), x);\n        let mut trimmed_bits = bits\n            .iter()\n            .copied()\n            .rev()\n            .skip_while(|&bit| !bit)\n            .collect_vec();\n        trimmed_bits.reverse();\n        assert_eq!(x.to_bits_asc(), trimmed_bits);\n        assert_eq!(Natural::from_bits_desc(bits.iter().copied().rev()), x);\n        if !bits.is_empty() && *bits.last().unwrap() {\n            assert_eq!(x.to_bits_asc(), *bits);\n        }\n        assert_eq!(bits.iter().all(|b| !b), x == 0);\n        if Limb::convertible_from(&x) {\n            assert_eq!(Limb::from_bits_asc(bits.into_iter()), x);\n        }\n    });\n}\n\n#[test]\nfn from_bits_desc_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 1024);\n    config.insert(\"mean_stripe_n\", 512);\n    bool_vec_gen().test_properties_with_config(&config, |bits| {\n        let x = Natural::from_bits_desc(bits.iter().copied());\n        assert!(x.is_valid());\n        assert_eq!(from_bits_desc_naive(bits.iter().copied()), x);\n        assert_eq!(from_bits_desc_alt::<Natural, _>(bits.iter().copied()), x);\n        assert_eq!(\n            x.to_bits_desc(),\n            bits.iter().copied().skip_while(|&b| !b).collect_vec()\n        );\n        assert_eq!(Natural::from_bits_asc(bits.iter().copied().rev()), x);\n        if !bits.is_empty() && bits[0] {\n            assert_eq!(x.to_bits_desc(), *bits);\n        }\n        assert_eq!(bits.iter().all(|b| !b), x == 0);\n        if Limb::convertible_from(&x) {\n            assert_eq!(Limb::from_bits_desc(bits.iter().copied()), x);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/get_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_16,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_access::limbs_get_bit;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_4};\nuse malachite_nz::test_util::natural::logic::get_bit::num_get_bit;\nuse num::BigUint;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_get_bit() {\n    let test = |xs: &[Limb], index: u64, out: bool| {\n        assert_eq!(limbs_get_bit(xs, index), out);\n    };\n    test(&[1], 0, true);\n    test(&[1], 100, false);\n    test(&[123], 2, false);\n    test(&[123], 3, true);\n    test(&[123], 100, false);\n    test(&[0, 0b1011], 0, false);\n    test(&[0, 0b1011], 32, true);\n    test(&[0, 0b1011], 33, true);\n    test(&[0, 0b1011], 34, false);\n    test(&[0, 0b1011], 35, true);\n    test(&[0, 0b1011], 100, false);\n}\n\n#[test]\nfn test_get_bit() {\n    let test = |n, index, out| {\n        assert_eq!(Natural::from_str(n).unwrap().get_bit(index), out);\n        assert_eq!(num_get_bit(&BigUint::from_str(n).unwrap(), index), out);\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .get_bit(u32::exact_from(index)),\n            out\n        );\n    };\n\n    test(\"0\", 0, false);\n    test(\"0\", 100, false);\n    test(\"123\", 2, false);\n    test(\"123\", 3, true);\n    test(\"123\", 100, false);\n    test(\"1000000000000\", 12, true);\n    test(\"1000000000000\", 100, false);\n}\n\n#[test]\nfn limbs_get_bit_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, index)| {\n        assert_eq!(\n            Natural::from_limbs_asc(&xs).get_bit(index),\n            limbs_get_bit(&xs, index)\n        );\n    });\n}\n\n#[test]\nfn get_bit_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, index)| {\n        let bit = n.get_bit(index);\n        assert_eq!(num_get_bit(&BigUint::from(&n), index), bit);\n        assert_eq!(rug::Integer::from(&n).get_bit(u32::exact_from(index)), bit);\n        assert_eq!(&n & Natural::power_of_2(index) != 0, bit);\n        assert_ne!((!n).get_bit(index), bit);\n    });\n\n    natural_gen().test_properties(|n| {\n        let significant_bits = n.significant_bits();\n        assert!(!n.get_bit(significant_bits));\n        if n != 0 {\n            assert!(n.get_bit(significant_bits - 1));\n        }\n    });\n\n    unsigned_pair_gen_var_2::<Limb, u64>().test_properties(|(u, index)| {\n        assert_eq!(Natural::from(u).get_bit(index), u.get_bit(index));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/get_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::{BitBlockAccess, LowMask, SignificantBits};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_16, unsigned_triple_gen_var_5,\n    unsigned_vec_unsigned_unsigned_triple_gen_var_3,\n};\nuse malachite_base::test_util::num::logic::bit_block_access::get_bits_naive;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_block_access::{limbs_slice_get_bits, limbs_vec_get_bits};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{\n    natural_unsigned_pair_gen, natural_unsigned_unsigned_triple_gen_var_4,\n};\nuse std::str::FromStr;\n\nfn verify_limbs_get_bits(xs: &[Limb], start: u64, end: u64, out: &[Limb]) {\n    let n = Natural::from_limbs_asc(xs);\n    let result = n.get_bits(start, end);\n    assert_eq!(get_bits_naive::<Natural, Natural>(&n, start, end), result);\n    assert_eq!(Natural::from_limbs_asc(out), result);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_get_bits() {\n    let test = |xs: &[Limb], start: u64, end: u64, out: &[Limb]| {\n        assert_eq!(limbs_slice_get_bits(xs, start, end), out);\n        verify_limbs_get_bits(xs, start, end, out);\n    };\n    // - limb_start >= len\n    test(&[], 10, 20, &[]);\n    // - limb_start < len\n    // - limb_end >= len\n    // - offset != 0\n    test(&[0x12345678, 0xabcdef01], 16, 48, &[0xef011234]);\n    // - limb_end < len\n    test(&[0x12345678, 0xabcdef01], 4, 16, &[0x567]);\n    // - offset == 0\n    test(&[0x12345678, 0xabcdef01], 0, 100, &[0x12345678, 0xabcdef01]);\n    test(&[0x12345678, 0xabcdef01], 10, 10, &[]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_slice_get_bits_fail() {\n    limbs_slice_get_bits(&[123], 10, 5);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_get_bits() {\n    let test = |xs: Vec<Limb>, start: u64, end: u64, out: &[Limb]| {\n        assert_eq!(limbs_vec_get_bits(xs, start, end), out);\n    };\n    test(vec![], 10, 20, &[]);\n    test(vec![0x12345678, 0xabcdef01], 16, 48, &[0xef011234, 0]);\n    test(vec![0x12345678, 0xabcdef01], 4, 16, &[0x567]);\n    test(\n        vec![0x12345678, 0xabcdef01],\n        0,\n        100,\n        &[0x12345678, 0xabcdef01],\n    );\n    test(vec![0x12345678, 0xabcdef01], 10, 10, &[0]);\n}\n\n#[test]\n#[should_panic]\nfn limbs_vec_get_bits_fail() {\n    limbs_vec_get_bits(vec![123], 10, 5);\n}\n\n#[test]\nfn test_get_bits() {\n    let test = |n, start, end, out| {\n        assert_eq!(\n            Natural::from_str(n).unwrap().get_bits(start, end),\n            Natural::from_str(out).unwrap()\n        );\n        assert_eq!(\n            Natural::from_str(n).unwrap().get_bits_owned(start, end),\n            Natural::from_str(out).unwrap()\n        );\n        assert_eq!(\n            get_bits_naive::<Natural, Natural>(&Natural::from_str(n).unwrap(), start, end),\n            Natural::from_str(out).unwrap()\n        );\n    };\n    test(\"12379813738590787192\", 16, 48, \"4009824820\");\n    test(\"12379813738590787192\", 4, 16, \"1383\");\n    test(\"12379813738590787192\", 0, 100, \"12379813738590787192\");\n    test(\"12379813738590787192\", 10, 10, \"0\");\n}\n\n#[test]\n#[should_panic]\nfn get_bits_fail() {\n    Natural::from(123u32).get_bits(10, 5);\n}\n\n#[test]\n#[should_panic]\nfn get_bits_owned_fail() {\n    Natural::from(123u32).get_bits_owned(10, 5);\n}\n\n#[test]\nfn limbs_get_bits_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_unsigned_triple_gen_var_3().test_properties_with_config(\n        &config,\n        |(xs, start, end)| {\n            let out = limbs_slice_get_bits(&xs, start, end);\n            verify_limbs_get_bits(&xs, start, end, &out);\n            let out = limbs_vec_get_bits(xs.to_vec(), start, end);\n            verify_limbs_get_bits(&xs, start, end, &out);\n        },\n    );\n}\n\n#[test]\nfn get_bits_properties() {\n    natural_unsigned_unsigned_triple_gen_var_4().test_properties(|(n, start, end)| {\n        let bits = n.get_bits(start, end);\n        assert_eq!(n.clone().get_bits_owned(start, end), bits);\n        assert_eq!(get_bits_naive::<Natural, Natural>(&n, start, end), bits);\n        assert!(bits <= n);\n        let significant_bits = n.significant_bits();\n        assert_eq!(\n            n.get_bits(start + significant_bits, end + significant_bits),\n            0\n        );\n        assert_eq!(\n            (!&n).get_bits(start, end),\n            Natural::low_mask(end - start) - &bits\n        );\n        let mut mut_n = n.clone();\n        mut_n.assign_bits(start, end, &bits);\n        assert_eq!(n, mut_n);\n    });\n\n    natural_unsigned_pair_gen().test_properties(|(n, start)| {\n        assert_eq!(n.get_bits(start, start), 0);\n    });\n\n    unsigned_pair_gen_var_16().test_properties(|(start, end)| {\n        assert_eq!(Natural::ZERO.get_bits(start, end), 0);\n    });\n\n    unsigned_triple_gen_var_5::<Limb, u64>().test_properties(|(n, start, end)| {\n        assert_eq!(\n            Natural::from(n).get_bits(start, end),\n            n.get_bits(start, end)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/hamming_distance.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::{CheckedHammingDistance, CountOnes, HammingDistance};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_pair_gen_var_27;\nuse malachite_base::test_util::generators::{\n    unsigned_vec_pair_gen_var_6, unsigned_vec_pair_gen_var_7, unsigned_vec_unsigned_pair_gen_var_15,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::hamming_distance::{\n    limbs_hamming_distance, limbs_hamming_distance_limb, limbs_hamming_distance_same_length,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse malachite_nz::test_util::natural::logic::hamming_distance::{\n    natural_hamming_distance_alt_1, natural_hamming_distance_alt_2, rug_hamming_distance,\n};\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_hamming_distance_limb() {\n    let test = |xs, y, out| {\n        assert_eq!(limbs_hamming_distance_limb(xs, y), out);\n    };\n    test(&[2], 3, 1);\n    test(&[1, 1, 1], 1, 2);\n    test(&[1, 1, 1], 2, 4);\n    test(&[1, 2, 3], 0, 4);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_hamming_distance_limb_fail() {\n    limbs_hamming_distance_limb(&[], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_hamming_distance_same_length() {\n    let test = |xs, ys, out| {\n        assert_eq!(limbs_hamming_distance_same_length(xs, ys), out);\n    };\n    test(&[], &[], 0);\n    test(&[2], &[3], 1);\n    test(&[1, 1, 1], &[1, 2, 3], 3);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_hamming_distance_limb_same_length_fail() {\n    limbs_hamming_distance_same_length(&[1], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_hamming_distance() {\n    let test = |xs, ys, out| {\n        assert_eq!(limbs_hamming_distance(xs, ys), out);\n    };\n    test(&[], &[], 0);\n    test(&[2], &[3], 1);\n    test(&[1, 1, 1], &[1, 2, 3], 3);\n    test(&[], &[1, 2, 3], 4);\n    test(&[1, 2, 3], &[], 4);\n    test(&[1, 1, 1], &[1, 2, 3, 4], 4);\n    test(&[1, 2, 3, 4], &[1, 1, 1], 4);\n}\n\n#[test]\nfn test_hamming_distance() {\n    let test = |x, y, out| {\n        assert_eq!(\n            Natural::from_str(x)\n                .unwrap()\n                .hamming_distance(&Natural::from_str(y).unwrap()),\n            out\n        );\n        assert_eq!(\n            natural_hamming_distance_alt_1(\n                &Natural::from_str(x).unwrap(),\n                &Natural::from_str(y).unwrap(),\n            ),\n            out\n        );\n        assert_eq!(\n            natural_hamming_distance_alt_2(\n                &Natural::from_str(x).unwrap(),\n                &Natural::from_str(y).unwrap(),\n            ),\n            out\n        );\n        assert_eq!(\n            rug_hamming_distance(\n                &rug::Integer::from_str(x).unwrap(),\n                &rug::Integer::from_str(y).unwrap(),\n            ),\n            out\n        );\n    };\n    test(\"105\", \"123\", 2);\n    test(\"1000000000000\", \"0\", 13);\n    test(\"4294967295\", \"0\", 32);\n    test(\"4294967295\", \"4294967295\", 0);\n    test(\"4294967295\", \"4294967296\", 33);\n    test(\"1000000000000\", \"1000000000001\", 1);\n}\n\n#[test]\nfn limbs_hamming_distance_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            limbs_hamming_distance_limb(&xs, y),\n            Natural::from_owned_limbs_asc(xs).hamming_distance(&Natural::from(y))\n        );\n    });\n}\n\n#[test]\nfn limbs_hamming_distance_same_length_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            limbs_hamming_distance_same_length(&xs, &ys),\n            Natural::from_owned_limbs_asc(xs).hamming_distance(&Natural::from_owned_limbs_asc(ys))\n        );\n    });\n}\n\n#[test]\nfn limbs_hamming_distance_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_7().test_properties_with_config(&config, |(xs, ys)| {\n        assert_eq!(\n            limbs_hamming_distance(&xs, &ys),\n            Natural::from_owned_limbs_asc(xs).hamming_distance(&Natural::from_owned_limbs_asc(ys))\n        );\n    });\n}\n\n#[test]\nfn hamming_distance_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let distance = x.hamming_distance(&y);\n        assert_eq!(\n            rug_hamming_distance(&rug::Integer::from(&x), &rug::Integer::from(&y)),\n            distance\n        );\n        assert_eq!(y.hamming_distance(&x), distance);\n        assert_eq!(natural_hamming_distance_alt_1(&x, &y), distance);\n        assert_eq!(natural_hamming_distance_alt_2(&x, &y), distance);\n        assert_eq!(distance == 0, x == y);\n        assert_eq!((&x ^ &y).count_ones(), distance);\n        assert_eq!((!x).checked_hamming_distance(&!y), Some(distance));\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert!(x.hamming_distance(&z) <= x.hamming_distance(&y) + y.hamming_distance(&z));\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(n.hamming_distance(&n), 0);\n        assert_eq!(n.hamming_distance(&Natural::ZERO), n.count_ones());\n        assert_eq!(Natural::ZERO.hamming_distance(&n), n.count_ones());\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(\n            Natural::from(x).hamming_distance(&Natural::from(y)),\n            x.hamming_distance(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/index_of_next_false_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, BitScan};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_16,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_scan::limbs_index_of_next_false_bit;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_4};\nuse malachite_nz::test_util::natural::logic::index_of_next_false_bit::*;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_index_of_next_false_bit() {\n    let test = |xs, u, out| {\n        assert_eq!(limbs_index_of_next_false_bit(xs, u), out);\n    };\n    test(&[], 0, 0);\n    test(&[], 100, 100);\n    test(&[0], 0, 0);\n    test(&[0], 100, 100);\n    test(&[0b100], 0, 0);\n    test(&[0b100], 1, 1);\n    test(&[0b100], 2, 3);\n    test(&[0b100], 3, 3);\n    test(&[0, 0b1011], 0, 0);\n    test(&[0, 0b1011], 20, 20);\n    test(&[0, 0b1011], 31, 31);\n    test(&[0, 0b1011], 32, 34);\n    test(&[0, 0b1011], 33, 34);\n    test(&[0, 0b1011], 34, 34);\n    test(&[0, 0b1011], 35, 36);\n    test(&[0, 0b1011], 100, 100);\n    test(&[0, 0b1011, 0xfffffff0, u32::MAX, 1], 64, 64);\n    test(&[0, 0b1011, 0xfffffff0, u32::MAX, 1], 68, 129);\n}\n\n#[test]\nfn test_index_of_next_false_bit() {\n    let test = |n, u, out| {\n        assert_eq!(\n            Natural::from_str(n).unwrap().index_of_next_false_bit(u),\n            out\n        );\n        assert_eq!(\n            natural_index_of_next_false_bit_alt(&Natural::from_str(n).unwrap(), u),\n            out\n        );\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .find_zero(u32::exact_from(u))\n                .map(u64::from),\n            out\n        );\n    };\n    test(\"0\", 0, Some(0));\n    test(\"0\", 100, Some(100));\n    test(\"47244640256\", 0, Some(0));\n    test(\"47244640256\", 20, Some(20));\n    test(\"47244640256\", 31, Some(31));\n    test(\"47244640256\", 32, Some(34));\n    test(\"47244640256\", 33, Some(34));\n    test(\"47244640256\", 34, Some(34));\n    test(\"47244640256\", 35, Some(36));\n    test(\"47244640256\", 100, Some(100));\n    test(\"680564733841876926631601309731428237312\", 64, Some(64));\n    test(\"680564733841876926631601309731428237312\", 68, Some(129));\n}\n\n#[test]\nfn limbs_index_of_next_false_bit_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, u)| {\n        assert_eq!(\n            Some(limbs_index_of_next_false_bit(&xs, u)),\n            Natural::from_owned_limbs_asc(xs).index_of_next_false_bit(u)\n        );\n    });\n}\n\n#[test]\nfn index_of_next_false_bit_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        let result = n.index_of_next_false_bit(u);\n        assert_eq!(result, natural_index_of_next_false_bit_alt(&n, u));\n        assert_eq!(\n            rug::Integer::from(&n)\n                .find_zero(u32::exact_from(u))\n                .map(u64::from),\n            result\n        );\n        let result = result.unwrap();\n        assert!(result >= u);\n        assert!(!n.get_bit(result));\n        assert_eq!(result == u, !n.get_bit(u));\n        assert_eq!((!n).index_of_next_true_bit(u), Some(result));\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(n.index_of_next_false_bit(0), (!n).trailing_zeros());\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Natural::ZERO.index_of_next_false_bit(u), Some(u));\n    });\n\n    unsigned_pair_gen_var_2::<Limb, u64>().test_properties(|(u, index)| {\n        assert_eq!(\n            Natural::from(u).index_of_next_false_bit(index),\n            u.index_of_next_false_bit(index)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/index_of_next_true_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::{BitAccess, BitScan, SignificantBits};\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_gen, unsigned_pair_gen_var_2, unsigned_vec_unsigned_pair_gen_var_16,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_scan::limbs_index_of_next_true_bit;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_unsigned_pair_gen_var_4};\nuse malachite_nz::test_util::natural::logic::index_of_next_true_bit::*;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_index_of_next_true_bit() {\n    let test = |xs, u, out| {\n        assert_eq!(limbs_index_of_next_true_bit(xs, u), out);\n    };\n    test(&[], 0, None);\n    test(&[], 100, None);\n    test(&[0], 0, None);\n    test(&[0], 100, None);\n    test(&[0b100], 0, Some(2));\n    test(&[0b100], 1, Some(2));\n    test(&[0b100], 2, Some(2));\n    test(&[0b100], 3, None);\n    test(&[0, 0b1011], 0, Some(32));\n    test(&[0, 0b1011], 20, Some(32));\n    test(&[0, 0b1011], 31, Some(32));\n    test(&[0, 0b1011], 32, Some(32));\n    test(&[0, 0b1011], 33, Some(33));\n    test(&[0, 0b1011], 34, Some(35));\n    test(&[0, 0b1011], 35, Some(35));\n    test(&[0, 0b1011], 36, None);\n    test(&[0, 0b1011], 100, None);\n    test(&[0, 0b1011, 0xfffffff, 0, 1], 91, Some(91));\n    test(&[0, 0b1011, 0xfffffff, 0, 1], 92, Some(128));\n}\n\n#[test]\nfn test_index_of_next_true_bit() {\n    let test = |n, u, out| {\n        assert_eq!(Natural::from_str(n).unwrap().index_of_next_true_bit(u), out);\n        assert_eq!(\n            natural_index_of_next_true_bit_alt(&Natural::from_str(n).unwrap(), u),\n            out\n        );\n        assert_eq!(\n            rug::Integer::from_str(n)\n                .unwrap()\n                .find_one(u32::exact_from(u))\n                .map(u64::from),\n            out\n        );\n    };\n    test(\"0\", 0, None);\n    test(\"0\", 100, None);\n    test(\"47244640256\", 0, Some(32));\n    test(\"47244640256\", 20, Some(32));\n    test(\"47244640256\", 31, Some(32));\n    test(\"47244640256\", 32, Some(32));\n    test(\"47244640256\", 33, Some(33));\n    test(\"47244640256\", 34, Some(35));\n    test(\"47244640256\", 35, Some(35));\n    test(\"47244640256\", 36, None);\n    test(\"47244640256\", 100, None);\n    test(\"340282366925890223602069384504899796992\", 91, Some(91));\n    test(\"340282366925890223602069384504899796992\", 92, Some(128));\n}\n\n#[test]\nfn limbs_index_of_next_true_bit_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(&config, |(xs, u)| {\n        assert_eq!(\n            limbs_index_of_next_true_bit(&xs, u),\n            Natural::from_owned_limbs_asc(xs).index_of_next_true_bit(u)\n        );\n    });\n}\n\n#[test]\nfn index_of_next_true_bit_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, u)| {\n        let result = n.index_of_next_true_bit(u);\n        assert_eq!(result, natural_index_of_next_true_bit_alt(&n, u));\n        assert_eq!(\n            rug::Integer::from(&n)\n                .find_one(u32::exact_from(u))\n                .map(u64::from),\n            result\n        );\n        assert_eq!(result.is_some(), u < n.significant_bits());\n        if let Some(result) = result {\n            assert!(result >= u);\n            assert!(n.get_bit(result));\n            assert_eq!(result == u, n.get_bit(u));\n        }\n        assert_eq!((!n).index_of_next_false_bit(u), result);\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(n.index_of_next_true_bit(0), n.trailing_zeros());\n    });\n\n    unsigned_gen().test_properties(|u| {\n        assert_eq!(Natural::ZERO.index_of_next_true_bit(u), None);\n    });\n\n    unsigned_pair_gen_var_2::<Limb, u64>().test_properties(|(u, index)| {\n        assert_eq!(\n            Natural::from(u).index_of_next_true_bit(index),\n            u.index_of_next_true_bit(index)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/limb_count.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\n#[cfg(feature = \"32_bit_limbs\")]\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limb_count() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().limb_count(), out);\n    };\n    test(\"0\", 0);\n    test(\"123\", 1);\n    test(\"1000000000000\", 2);\n    test(\"4294967295\", 1);\n    test(\"4294967296\", 2);\n    test(\"18446744073709551615\", 2);\n    test(\"18446744073709551616\", 3);\n}\n\n#[test]\nfn limb_count_properties() {\n    natural_gen().test_properties(|x| {\n        let n = x.limb_count();\n        assert_eq!(x <= Limb::MAX, n <= 1);\n        if x != 0 {\n            assert!(Natural::power_of_2((n - 1) << Limb::LOG_WIDTH) <= x);\n            assert!(x < Natural::power_of_2(n << Limb::LOG_WIDTH));\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert!(Natural::from(u).limb_count() <= 1);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/low_mask.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::logic::traits::{BitScan, CountOnes, LowMask};\nuse malachite_base::test_util::generators::{unsigned_gen_var_5, unsigned_gen_var_9};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::low_mask::limbs_low_mask;\nuse malachite_nz::platform::Limb;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_low_mask() {\n    let test = |bits, out: &[Limb]| assert_eq!(limbs_low_mask(bits), out);\n    test(0, &[]);\n    test(1, &[1]);\n    test(2, &[3]);\n    test(3, &[7]);\n    test(32, &[u32::MAX]);\n    test(100, &[u32::MAX, u32::MAX, u32::MAX, 15]);\n}\n\n#[test]\nfn test_low_mask() {\n    let test = |bits, out| assert_eq!(Natural::low_mask(bits).to_string(), out);\n    test(0, \"0\");\n    test(1, \"1\");\n    test(2, \"3\");\n    test(3, \"7\");\n    test(32, \"4294967295\");\n    test(100, \"1267650600228229401496703205375\");\n}\n\n#[test]\nfn limbs_low_mask_properties() {\n    unsigned_gen_var_5().test_properties(|bits| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_low_mask(bits)),\n            Natural::low_mask(bits)\n        );\n    });\n}\n\n#[test]\nfn low_mask_properties() {\n    unsigned_gen_var_5().test_properties(|bits| {\n        let n = Natural::low_mask(bits);\n        assert!(n.is_valid());\n        assert_eq!(n, Natural::power_of_2(bits) - Natural::ONE);\n        assert_eq!(n.count_ones(), bits);\n        assert_eq!(n.index_of_next_false_bit(0), Some(bits));\n    });\n\n    unsigned_gen_var_9::<Limb>().test_properties(|bits| {\n        assert_eq!(Limb::low_mask(bits), Natural::low_mask(bits));\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/not.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{unsigned_vec_gen, unsigned_vec_pair_gen_var_1};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::not::{limbs_not, limbs_not_in_place, limbs_not_to_out};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_not_and_limbs_not_in_place() {\n    let test = |xs: &[Limb], out: &[Limb]| {\n        assert_eq!(limbs_not(xs), out);\n\n        let mut mut_xs = xs.to_vec();\n        limbs_not_in_place(&mut mut_xs);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[], &[]);\n    test(&[0, 1, 2], &[u32::MAX, u32::MAX - 1, u32::MAX - 2]);\n    test(&[u32::MAX, u32::MAX - 1, u32::MAX - 2], &[0, 1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_not_to_out() {\n    let test = |xs: &[Limb], out_before: &[Limb], out_after: &[Limb]| {\n        let mut mut_out = out_before.to_vec();\n        limbs_not_to_out(&mut mut_out, xs);\n        assert_eq!(mut_out, out_after);\n    };\n    test(&[], &[], &[]);\n    test(&[0x11111111], &[5], &[0xeeeeeeee]);\n    test(\n        &[0xffff0000, 0xf0f0f0f0],\n        &[0, 1, 2],\n        &[0xffff, 0xf0f0f0f, 2],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_not_to_out_fail() {\n    let mut out = vec![1, 2];\n    limbs_not_to_out(&mut out, &[1, 2, 3]);\n}\n\n#[test]\nfn test_not() {\n    let test = |s, out| {\n        let not = !Natural::from_str(s).unwrap();\n        assert!(not.is_valid());\n        assert_eq!(not.to_string(), out);\n\n        let not = !(&Natural::from_str(s).unwrap());\n        assert!(not.is_valid());\n        assert_eq!(not.to_string(), out);\n\n        assert_eq!((!rug::Integer::from_str(s).unwrap()).to_string(), out);\n    };\n    test(\"0\", \"-1\");\n    test(\"123\", \"-124\");\n    test(\"1000000000000\", \"-1000000000001\");\n    test(\"2147483647\", \"-2147483648\");\n}\n\n#[test]\nfn limbs_not_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |xs| {\n        let not_xs = limbs_not(&xs);\n        assert_eq!(limbs_not(&not_xs), xs);\n    });\n}\n\n#[test]\nfn limbs_not_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_1().test_properties_with_config(&config, |(mut out, xs)| {\n        let out_old = out.clone();\n        limbs_not_to_out(&mut out, &xs);\n        limbs_not_in_place(&mut out[..xs.len()]);\n        assert_eq!(&out[..xs.len()], xs);\n        assert_eq!(&out[xs.len()..], &out_old[xs.len()..]);\n    });\n}\n\n#[test]\nfn limbs_not_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen().test_properties_with_config(&config, |mut xs| {\n        let xs_old = xs.clone();\n        limbs_not_in_place(&mut xs);\n        limbs_not_in_place(&mut xs);\n        assert_eq!(xs, xs_old);\n    });\n}\n\n#[test]\nfn not_properties() {\n    natural_gen().test_properties(|x| {\n        let not = !x.clone();\n        assert!(not.is_valid());\n\n        let rug_not = !rug::Integer::from(&x);\n        assert_eq!(Integer::from(&rug_not), not);\n\n        let not_alt = !&x;\n        assert!(not_alt.is_valid());\n        assert_eq!(not_alt, not);\n\n        assert!(not < 0);\n        assert_eq!(not, -(&x + Natural::ONE));\n        assert_ne!(not, x);\n        assert_eq!(!not, x);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/or.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::CountOnes;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_vec_pair_gen, unsigned_vec_pair_gen_var_6,\n    unsigned_vec_triple_gen_var_31, unsigned_vec_triple_gen_var_32,\n    unsigned_vec_unsigned_pair_gen_var_15, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::or::{\n    limbs_or, limbs_or_in_place_either, limbs_or_in_place_left, limbs_or_limb,\n    limbs_or_limb_in_place, limbs_or_limb_to_out, limbs_or_same_length,\n    limbs_or_same_length_in_place_left, limbs_or_same_length_to_out, limbs_or_to_out,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse malachite_nz::test_util::natural::logic::or::{natural_or_alt_1, natural_or_alt_2};\nuse num::BigUint;\nuse rug;\nuse std::cmp::max;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_limb_and_limbs_or_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_or_limb(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_or_limb_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[6, 7], 2, &[6, 7]);\n    test(&[100, 101, 102], 10, &[110, 101, 102]);\n    test(&[123, 456], 789, &[895, 456]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_limb_fail() {\n    limbs_or_limb(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_limb_in_place_fail() {\n    limbs_or_limb_in_place(&mut [], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_limb_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_or_limb_to_out(&mut out, xs, y);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[6, 7], 2, &[6, 7, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        &[110, 101, 102, 10],\n    );\n    test(&[10, 10, 10, 10], &[123, 456], 789, &[895, 456, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_limb_to_out_fail_1() {\n    limbs_or_limb_to_out(&mut [], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_limb_to_out_fail_2() {\n    limbs_or_limb_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_same_length_and_limbs_or_same_length_in_place_left() {\n    let test = |xs_before, ys, out| {\n        assert_eq!(limbs_or_same_length(xs_before, ys), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_or_same_length_in_place_left(&mut xs, ys);\n        assert_eq!(xs, out);\n    };\n    test(&[], &[], vec![]);\n    test(&[2], &[3], vec![3]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 3, 3]);\n    test(&[6, 7], &[1, 2], vec![7, 7]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![102, 101, 102]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_same_length_fail_1() {\n    limbs_or_same_length(&[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_same_length_in_place_left_fail() {\n    let mut out = vec![6, 7];\n    limbs_or_same_length_in_place_left(&mut out, &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or() {\n    let test = |xs, ys, out| {\n        assert_eq!(limbs_or(xs, ys), out);\n    };\n    test(&[], &[], vec![]);\n    test(&[2], &[3], vec![3]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 3, 3]);\n    test(&[6, 7], &[1, 2, 3], vec![7, 7, 3]);\n    test(&[1, 2, 3], &[6, 7], vec![7, 7, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![102, 101, 102]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_same_length_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_or_same_length_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], vec![0, 0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[5, 5, 5, 5], vec![1, 3, 3, 5]);\n    test(&[6, 7], &[1, 2], &[0, 0], vec![7, 7]);\n    test(&[6, 7], &[1, 2], &[10, 10, 10, 10], vec![7, 7, 10, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![102, 101, 102, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_same_length_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_or_same_length_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_same_length_to_out_fail_2() {\n    let mut out = vec![10];\n    limbs_or_same_length_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_or_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], vec![0, 0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[5, 5, 5, 5], vec![1, 3, 3, 5]);\n    test(&[6, 7], &[1, 2, 3], &[10, 10, 10, 10], vec![7, 7, 3, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10, 10, 10, 10], vec![7, 7, 3, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![102, 101, 102, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_or_to_out_fail() {\n    let mut out = vec![10, 10];\n    limbs_or_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_in_place_left() {\n    let test = |xs_before: &[Limb], ys, xs_after| {\n        let mut xs = xs_before.to_vec();\n        limbs_or_in_place_left(&mut xs, ys);\n        assert_eq!(xs, xs_after);\n    };\n    test(&[], &[], vec![]);\n    test(&[6, 7], &[1, 2], vec![7, 7]);\n    test(&[6, 7], &[1, 2, 3], vec![7, 7, 3]);\n    test(&[1, 2, 3], &[6, 7], vec![7, 7, 3]);\n    test(&[], &[1, 2, 3], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[], vec![1, 2, 3]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![1, 3, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![102, 101, 102]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_or_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], right, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_or_in_place_either(&mut xs, &mut ys), right);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], false, vec![], vec![]);\n    test(&[6, 7], &[1, 2], false, vec![7, 7], vec![1, 2]);\n    test(&[6, 7], &[1, 2, 3], true, vec![6, 7], vec![7, 7, 3]);\n    test(&[1, 2, 3], &[6, 7], false, vec![7, 7, 3], vec![6, 7]);\n    test(&[], &[1, 2, 3], true, vec![], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[], false, vec![1, 2, 3], vec![]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![1, 3, 3], vec![1, 2, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![102, 101, 102],\n        vec![102, 101, 100],\n    );\n}\n\n#[test]\nfn test_or() {\n    let test = |u, v, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n |= Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = Natural::from_str(u).unwrap();\n        n |= &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::from_str(u).unwrap() | Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &Natural::from_str(u).unwrap() | Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::from_str(u).unwrap() | &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &Natural::from_str(u).unwrap() | &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!(\n            natural_or_alt_1(\n                &Natural::from_str(u).unwrap(),\n                &Natural::from_str(v).unwrap(),\n            )\n            .to_string(),\n            out\n        );\n        assert_eq!(\n            natural_or_alt_2(\n                &Natural::from_str(u).unwrap(),\n                &Natural::from_str(v).unwrap(),\n            )\n            .to_string(),\n            out\n        );\n\n        let n = BigUint::from_str(u).unwrap() | BigUint::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(u).unwrap() | rug::Integer::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"456\", \"507\");\n    test(\"999999999999\", \"123\", \"999999999999\");\n    test(\"1000000000000\", \"123\", \"1000000000123\");\n    test(\"123\", \"1000000000000\", \"1000000000123\");\n    test(\"1000000000001\", \"123\", \"1000000000123\");\n    test(\"12345678987654321\", \"456\", \"12345678987654649\");\n    test(\"12345678987654321\", \"987654321\", \"12345679395421361\");\n    test(\"1000000000000\", \"999999999999\", \"1000000004095\");\n    test(\"12345678987654321\", \"314159265358979\", \"12347506587071667\");\n}\n\n#[test]\nfn limbs_or_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_or_limb(&xs, y)),\n            Natural::from_owned_limbs_asc(xs) | Natural::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_or_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_or_limb_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            assert_eq!(\n                Natural::from_limbs_asc(&out[..len]),\n                Natural::from_owned_limbs_asc(xs) | Natural::from(y)\n            );\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_or_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_or_limb_in_place(&mut xs, y);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(old_xs) | Natural::from(y)\n        );\n    });\n}\n\nfn limbs_or_helper(f: &mut dyn FnMut(&[Limb], &[Limb]) -> Vec<Limb>, xs: Vec<Limb>, ys: Vec<Limb>) {\n    assert_eq!(\n        Natural::from_owned_limbs_asc(f(&xs, &ys)),\n        Natural::from_owned_limbs_asc(xs) | Natural::from_owned_limbs_asc(ys)\n    );\n}\n\n#[test]\nfn limbs_or_same_length_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_or_helper(&mut limbs_or_same_length, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_or_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_or_helper(&mut limbs_or, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_or_same_length_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_31().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_or_same_length_to_out(&mut out, &xs, &ys);\n        let len = ys.len();\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Natural::from_owned_limbs_asc(xs) | Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_or_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_32().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_or_to_out(&mut out, &xs, &ys);\n        let len = max(xs.len(), ys.len());\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Natural::from_owned_limbs_asc(xs) | Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_or_same_length_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_or_same_length_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(xs_old) | Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_or_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_or_in_place_left(&mut xs, &ys);\n        let n = Natural::from_owned_limbs_asc(xs_old) | Natural::from_owned_limbs_asc(ys);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n    });\n}\n\n#[test]\nfn limbs_or_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_or_in_place_either(&mut xs, &mut ys);\n        let n = Natural::from_limbs_asc(&xs_old) | Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(Natural::from_owned_limbs_asc(ys), n);\n        } else {\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn or_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let result_val_val = x.clone() | y.clone();\n        let result_val_ref = x.clone() | &y;\n        let result_ref_val = &x | y.clone();\n        let result = &x | &y;\n        assert!(result_val_val.is_valid());\n        assert!(result_val_ref.is_valid());\n        assert!(result_ref_val.is_valid());\n        assert!(result.is_valid());\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        let mut mut_x = x.clone();\n        mut_x |= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, result);\n        let mut mut_x = x.clone();\n        mut_x |= &y;\n        assert_eq!(mut_x, result);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x |= rug::Integer::from(&y);\n        assert_eq!(Natural::exact_from(&mut_x), result);\n\n        assert_eq!(\n            Natural::from(&(BigUint::from(&x) | BigUint::from(&y))),\n            result\n        );\n        assert_eq!(\n            Natural::exact_from(&(rug::Integer::from(&x) | rug::Integer::from(&y))),\n            result\n        );\n\n        assert_eq!(natural_or_alt_1(&x, &y), result);\n        assert_eq!(natural_or_alt_2(&x, &y), result);\n\n        assert_eq!(&y | &x, result);\n        assert_eq!(&result | &x, result);\n        assert_eq!(&result | &y, result);\n\n        assert!(result >= x);\n        assert!(result >= y);\n\n        let ones = result.count_ones();\n        assert!(ones >= x.count_ones());\n        assert!(ones >= y.count_ones());\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(&x | Natural::ZERO, x);\n        assert_eq!(Natural::ZERO | &x, x);\n        assert_eq!(&x | &x, x);\n    });\n\n    natural_triple_gen().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x | y) | z, x | (y | z));\n        assert_eq!(x & (y | z), (x & y) | (x & z));\n        assert_eq!((x & y) | z, (x | z) & (y | z));\n        assert_eq!(x | (y & z), (x | y) & (x | z));\n        assert_eq!((x | y) & z, (x & z) | (y & z));\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x) | Natural::from(y), x | y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/set_bit.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::BitAccess;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_vec_unsigned_pair_gen_var_16, unsigned_vec_unsigned_pair_gen_var_17,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::bit_access::{limbs_slice_set_bit, limbs_vec_set_bit};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_4;\nuse malachite_nz::test_util::natural::logic::set_bit::num_set_bit;\nuse num::BigUint;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_slice_set_bit() {\n    let test = |xs: &[Limb], index: u64, out: &[Limb]| {\n        let mut mut_xs = xs.to_vec();\n        limbs_slice_set_bit(&mut mut_xs, index);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[0, 1], 0, &[1, 1]);\n    test(&[1, 1], 0, &[1, 1]);\n    test(&[1, 1], 1, &[3, 1]);\n    test(&[3, 1], 33, &[3, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_slice_set_bit_fail() {\n    let mut mut_xs = vec![1u32, 2, 3];\n    limbs_slice_set_bit(&mut mut_xs, 100);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_vec_set_bit() {\n    let test = |xs: &[Limb], index: u64, out: &[Limb]| {\n        let mut mut_xs = xs.to_vec();\n        limbs_vec_set_bit(&mut mut_xs, index);\n        assert_eq!(mut_xs, out);\n    };\n    test(&[0, 1], 0, &[1, 1]);\n    test(&[1, 1], 0, &[1, 1]);\n    test(&[1, 1], 1, &[3, 1]);\n    test(&[3, 1], 33, &[3, 3]);\n    test(&[3, 3], 100, &[3, 3, 0, 16]);\n    test(&[3, 3], 128, &[3, 3, 0, 0, 1]);\n    test(&[], 32, &[0, 1]);\n}\n\n#[test]\nfn test_set_bit() {\n    let test = |u, index, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n.set_bit(index);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = BigUint::from_str(u).unwrap();\n        num_set_bit(&mut n, index);\n        assert_eq!(n.to_string(), out);\n\n        let mut n = rug::Integer::from_str(u).unwrap();\n        n.set_bit(u32::exact_from(index), true);\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", 10, \"1024\");\n    test(\"100\", 0, \"101\");\n    test(\"1000000000000\", 10, \"1000000001024\");\n    test(\"1000000000000\", 100, \"1267650600228229402496703205376\");\n    test(\"5\", 100, \"1267650600228229401496703205381\");\n}\n\n#[test]\nfn limbs_slice_set_bit_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_17().test_properties_with_config(\n        &config,\n        |(mut xs, index)| {\n            let mut n = Natural::from_limbs_asc(&xs);\n            limbs_slice_set_bit(&mut xs, index);\n            n.set_bit(index);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn limbs_vec_set_bit_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_16().test_properties_with_config(\n        &config,\n        |(mut xs, index)| {\n            let mut n = Natural::from_limbs_asc(&xs);\n            limbs_vec_set_bit(&mut xs, index);\n            n.set_bit(index);\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n        },\n    );\n}\n\n#[test]\nfn natural_set_bit_properties() {\n    natural_unsigned_pair_gen_var_4().test_properties(|(n, index)| {\n        let mut mut_n = n.clone();\n        mut_n.set_bit(index);\n        assert!(mut_n.is_valid());\n        let result = mut_n;\n\n        let mut mut_n = n.clone();\n        mut_n.assign_bit(index, true);\n        assert_eq!(mut_n, result);\n\n        let mut num_n = BigUint::from(&n);\n        num_set_bit(&mut num_n, index);\n        assert_eq!(Natural::from(&num_n), result);\n\n        let mut rug_n = rug::Integer::from(&n);\n        rug_n.set_bit(u32::exact_from(index), true);\n        assert_eq!(Natural::exact_from(&rug_n), result);\n\n        assert_eq!(&n | Natural::power_of_2(index), result);\n\n        assert_ne!(result, 0);\n        assert!(result >= n);\n        if n.get_bit(index) {\n            assert_eq!(result, n);\n        } else {\n            assert_ne!(result, n);\n            let mut mut_result = result;\n            mut_result.clear_bit(index);\n            assert_eq!(mut_result, n);\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::WrappingFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_1;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::arithmetic::log_base_2::limbs_floor_log_base_2;\nuse malachite_nz::natural::logic::significant_bits::limbs_significant_bits;\nuse malachite_nz::platform::Limb;\nuse num::BigUint;\nuse rug;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_significant_bits() {\n    let test = |xs, out| {\n        assert_eq!(limbs_significant_bits::<Limb>(xs), out);\n    };\n    test(&[0b1], 1);\n    test(&[0b10], 2);\n    test(&[0b11], 2);\n    test(&[0b100], 3);\n    test(&[0, 0b1], 33);\n    test(&[0, 0b1101], 36);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_significant_bits_fail() {\n    limbs_significant_bits::<Limb>(&[]);\n}\n\n#[test]\nfn test_significant_bits() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().significant_bits(), out);\n        assert_eq!(\n            u64::wrapping_from(BigUint::from_str(n).unwrap().bits()),\n            out\n        );\n        assert_eq!(\n            u64::from(rug::Integer::from_str(n).unwrap().significant_bits()),\n            out\n        );\n    };\n    test(\"0\", 0);\n    test(\"100\", 7);\n    test(\"1000000000000\", 40);\n    test(\"4294967295\", 32);\n    test(\"4294967296\", 33);\n    test(\"18446744073709551615\", 64);\n    test(\"18446744073709551616\", 65);\n}\n\n#[test]\nfn limbs_significant_bits_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_1().test_properties_with_config(&config, |xs| {\n        let significant_bits = limbs_significant_bits(&xs);\n        assert_eq!(xs.len() == 1, significant_bits <= Limb::WIDTH);\n        assert_eq!(significant_bits, limbs_floor_log_base_2(&xs) + 1);\n        assert_eq!(\n            significant_bits,\n            Natural::from_owned_limbs_asc(xs).significant_bits()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::logic::traits::{BitConvertible, BitIterable};\nuse malachite_base::test_util::generators::unsigned_gen;\nuse malachite_base::test_util::num::logic::bit_convertible::{to_bits_asc_alt, to_bits_desc_alt};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::logic::to_bits::{to_bits_asc_naive, to_bits_desc_naive};\nuse std::str::FromStr;\n\n#[test]\nfn test_to_bits_asc() {\n    let test = |n, out| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(n.bits().collect_vec(), out);\n        assert_eq!(n.to_bits_asc(), out);\n        assert_eq!(to_bits_asc_naive(&n), out);\n        assert_eq!(to_bits_asc_alt(&n), out);\n    };\n    test(\"0\", vec![]);\n    test(\"1\", vec![true]);\n    test(\"6\", vec![false, true, true]);\n    test(\"105\", vec![true, false, false, true, false, true, true]);\n    test(\n        \"1000000000000\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            true, false, false, false, true, false, true, false, false, true, false, true, false,\n            false, true, false, true, false, true, true, false, false, false, true, false, true,\n            true, true,\n        ],\n    );\n    test(\n        \"4294967295\",\n        vec![\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true,\n        ],\n    );\n    test(\n        \"4294967296\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, true,\n        ],\n    );\n    test(\n        \"18446744073709551615\",\n        vec![\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true,\n        ],\n    );\n    test(\n        \"18446744073709551616\",\n        vec![\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, true,\n        ],\n    );\n}\n\n#[test]\nfn test_to_bits_desc() {\n    let test = |n, out| {\n        let n = Natural::from_str(n).unwrap();\n        assert_eq!(n.bits().rev().collect_vec(), out);\n        assert_eq!(n.to_bits_desc(), out);\n        assert_eq!(to_bits_desc_naive(&n), out);\n        assert_eq!(to_bits_desc_alt(&n), out);\n    };\n    test(\"0\", vec![]);\n    test(\"1\", vec![true]);\n    test(\"6\", vec![true, true, false]);\n    test(\"105\", vec![true, true, false, true, false, false, true]);\n    test(\n        \"1000000000000\",\n        vec![\n            true, true, true, false, true, false, false, false, true, true, false, true, false,\n            true, false, false, true, false, true, false, false, true, false, true, false, false,\n            false, true, false, false, false, false, false, false, false, false, false, false,\n            false, false,\n        ],\n    );\n    test(\n        \"4294967295\",\n        vec![\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true,\n        ],\n    );\n    test(\n        \"4294967296\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false,\n        ],\n    );\n    test(\n        \"18446744073709551615\",\n        vec![\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true, true, true, true, true, true, true,\n            true, true, true, true, true, true, true, true,\n        ],\n    );\n    test(\n        \"18446744073709551616\",\n        vec![\n            true, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false, false, false, false, false, false, false, false,\n            false, false, false, false, false,\n        ],\n    );\n}\n\n#[test]\nfn to_bits_asc_properties() {\n    natural_gen().test_properties(|x| {\n        let bits = x.to_bits_asc();\n        assert_eq!(to_bits_asc_naive(&x), bits);\n        assert_eq!(to_bits_asc_alt(&x), bits);\n        assert_eq!(x.bits().collect_vec(), bits);\n        assert_eq!(Natural::from_bits_asc(bits.iter().copied()), x);\n        if x != 0 {\n            assert_eq!(*bits.last().unwrap(), true);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.to_bits_asc(), Natural::from(u).to_bits_asc());\n    });\n}\n\n#[test]\nfn to_bits_desc_properties() {\n    natural_gen().test_properties(|x| {\n        let bits = x.to_bits_desc();\n        assert_eq!(to_bits_desc_naive(&x), bits);\n        assert_eq!(to_bits_desc_alt(&x), bits);\n        assert_eq!(x.bits().rev().collect_vec(), bits);\n        assert_eq!(Natural::from_bits_desc(bits.iter().copied()), x);\n        if x != 0 {\n            assert_eq!(bits[0], true);\n        }\n    });\n\n    unsigned_gen::<Limb>().test_properties(|u| {\n        assert_eq!(u.to_bits_desc(), Natural::from(u).to_bits_desc());\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/trailing_zeros.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::unsigned_vec_gen_var_2;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::trailing_zeros::limbs_trailing_zeros;\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_nz::test_util::natural::logic::trailing_zeros::natural_trailing_zeros_alt;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_trailing_zeros() {\n    let test = |xs, out| {\n        assert_eq!(limbs_trailing_zeros(xs), out);\n    };\n    test(&[4], 2);\n    test(&[0, 4], 34);\n    test(&[1, 2, 3], 0);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_trailing_zeros_fail_1() {\n    limbs_trailing_zeros(&[]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_trailing_zeros_fail_2() {\n    limbs_trailing_zeros(&[0, 0, 0]);\n}\n\n#[test]\nfn test_trailing_zeros() {\n    let test = |n, out| {\n        assert_eq!(Natural::from_str(n).unwrap().trailing_zeros(), out);\n        assert_eq!(\n            natural_trailing_zeros_alt(&Natural::from_str(n).unwrap()),\n            out\n        );\n    };\n    test(\"0\", None);\n    test(\"123\", Some(0));\n    test(\"1000000000000\", Some(12));\n    test(\"4294967295\", Some(0));\n    test(\"4294967296\", Some(32));\n    test(\"18446744073709551615\", Some(0));\n    test(\"18446744073709551616\", Some(64));\n}\n\n#[test]\nfn limbs_trailing_zeros_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_gen_var_2().test_properties_with_config(&config, |xs| {\n        assert_eq!(\n            Some(limbs_trailing_zeros(&xs)),\n            Natural::from_owned_limbs_asc(xs).trailing_zeros()\n        );\n    });\n}\n\n#[allow(clippy::cmp_owned, clippy::useless_conversion)]\n#[test]\nfn trailing_zeros_properties() {\n    natural_gen().test_properties(|x| {\n        let trailing_zeros = x.trailing_zeros();\n        assert_eq!(natural_trailing_zeros_alt(&x), trailing_zeros);\n        assert_eq!(trailing_zeros.is_none(), x == 0);\n        if x != 0 {\n            let trailing_zeros = trailing_zeros.unwrap();\n            if trailing_zeros <= u64::from(Limb::MAX) {\n                assert!((&x >> trailing_zeros).odd());\n                assert_eq!(&x >> trailing_zeros << trailing_zeros, x);\n            }\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/logic/xor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::{\n    unsigned_pair_gen_var_27, unsigned_vec_pair_gen, unsigned_vec_pair_gen_var_6,\n    unsigned_vec_triple_gen_var_31, unsigned_vec_triple_gen_var_32,\n    unsigned_vec_unsigned_pair_gen_var_15, unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::logic::xor::{\n    limbs_xor, limbs_xor_in_place_either, limbs_xor_in_place_left, limbs_xor_limb,\n    limbs_xor_limb_in_place, limbs_xor_limb_to_out, limbs_xor_same_length,\n    limbs_xor_same_length_in_place_left, limbs_xor_same_length_to_out, limbs_xor_to_out,\n};\nuse malachite_nz::platform::Limb;\nuse malachite_nz::test_util::generators::{natural_gen, natural_pair_gen, natural_triple_gen};\nuse malachite_nz::test_util::natural::logic::xor::{natural_xor_alt_1, natural_xor_alt_2};\nuse num::BigUint;\nuse rug;\nuse std::cmp::max;\nuse std::str::FromStr;\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_limb_and_limbs_xor_limb_in_place() {\n    let test = |xs: &[Limb], y: Limb, out: &[Limb]| {\n        assert_eq!(limbs_xor_limb(xs, y), out);\n\n        let mut xs = xs.to_vec();\n        limbs_xor_limb_in_place(&mut xs, y);\n        assert_eq!(xs, out);\n    };\n    test(&[6, 7], 2, &[4, 7]);\n    test(&[100, 101, 102], 10, &[110, 101, 102]);\n    test(&[123, 456], 789, &[878, 456]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_limb_fail() {\n    limbs_xor_limb(&[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_limb_in_place_fail() {\n    limbs_xor_limb_in_place(&mut [], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_limb_to_out() {\n    let test = |out_before: &[Limb], xs: &[Limb], y: Limb, out_after: &[Limb]| {\n        let mut out = out_before.to_vec();\n        limbs_xor_limb_to_out(&mut out, xs, y);\n        assert_eq!(out, out_after);\n    };\n    test(&[10, 10, 10, 10], &[6, 7], 2, &[4, 7, 10, 10]);\n    test(\n        &[10, 10, 10, 10],\n        &[100, 101, 102],\n        10,\n        &[110, 101, 102, 10],\n    );\n    test(&[10, 10, 10, 10], &[123, 456], 789, &[878, 456, 10, 10]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_limb_to_out_fail_1() {\n    limbs_xor_limb_to_out(&mut [], &[], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_limb_to_out_fail_2() {\n    limbs_xor_limb_to_out(&mut [10], &[10, 10], 10);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_same_length_and_limbs_xor_same_length_in_place_left() {\n    let test = |xs_before, ys, out| {\n        assert_eq!(limbs_xor_same_length(xs_before, ys), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_xor_same_length_in_place_left(&mut xs, ys);\n        assert_eq!(xs, out);\n    };\n    test(&[], &[], vec![]);\n    test(&[2], &[3], vec![1]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![0, 3, 2]);\n    test(&[6, 7], &[1, 2], vec![7, 5]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![2, 0, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_same_length_fail_1() {\n    limbs_xor_same_length(&[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_same_length_in_place_left_fail() {\n    let mut out = vec![6, 7];\n    limbs_xor_same_length_in_place_left(&mut out, &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_and_limbs_xor_in_place_left() {\n    let test = |xs_before, ys, out| {\n        assert_eq!(limbs_xor(xs_before, ys), out);\n\n        let mut xs = xs_before.to_vec();\n        limbs_xor_in_place_left(&mut xs, ys);\n        assert_eq!(xs, out);\n    };\n    test(&[], &[], vec![]);\n    test(&[2], &[3], vec![1]);\n    test(&[1, 1, 1], &[1, 2, 3], vec![0, 3, 2]);\n    test(&[6, 7], &[1, 2, 3], vec![7, 5, 3]);\n    test(&[1, 2, 3], &[6, 7], vec![7, 5, 3]);\n    test(&[100, 101, 102], &[102, 101, 100], vec![2, 0, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_same_length_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_xor_same_length_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], vec![0, 0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[5, 5, 5, 5], vec![0, 3, 2, 5]);\n    test(&[6, 7], &[1, 2], &[0, 0], vec![7, 5]);\n    test(&[6, 7], &[1, 2], &[10, 10, 10, 10], vec![7, 5, 10, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![2, 0, 2, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_same_length_to_out_fail_1() {\n    let mut out = vec![10, 10, 10, 10];\n    limbs_xor_same_length_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_same_length_to_out_fail_2() {\n    let mut out = vec![10];\n    limbs_xor_same_length_to_out(&mut out, &[6, 7], &[1, 2]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_to_out() {\n    let test = |xs, ys, out_before: &[Limb], out_after| {\n        let mut out = out_before.to_vec();\n        limbs_xor_to_out(&mut out, xs, ys);\n        assert_eq!(out, out_after);\n    };\n    test(&[], &[], &[0, 0], vec![0, 0]);\n    test(&[1, 1, 1], &[1, 2, 3], &[5, 5, 5, 5], vec![0, 3, 2, 5]);\n    test(&[6, 7], &[1, 2, 3], &[10, 10, 10, 10], vec![7, 5, 3, 10]);\n    test(&[1, 2, 3], &[6, 7], &[10, 10, 10, 10], vec![7, 5, 3, 10]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        &[10, 10, 10, 10],\n        vec![2, 0, 2, 10],\n    );\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\n#[should_panic]\nfn limbs_xor_to_out_fail() {\n    let mut out = vec![10, 10];\n    limbs_xor_to_out(&mut out, &[6, 7], &[1, 2, 3]);\n}\n\n#[cfg(feature = \"32_bit_limbs\")]\n#[test]\nfn test_limbs_xor_in_place_either() {\n    let test = |xs_before: &[Limb], ys_before: &[Limb], right, xs_after, ys_after| {\n        let mut xs = xs_before.to_vec();\n        let mut ys = ys_before.to_vec();\n        assert_eq!(limbs_xor_in_place_either(&mut xs, &mut ys), right);\n        assert_eq!(xs, xs_after);\n        assert_eq!(ys, ys_after);\n    };\n    test(&[], &[], false, vec![], vec![]);\n    test(&[6, 7], &[1, 2], false, vec![7, 5], vec![1, 2]);\n    test(&[6, 7], &[1, 2, 3], true, vec![6, 7], vec![7, 5, 3]);\n    test(&[1, 2, 3], &[6, 7], false, vec![7, 5, 3], vec![6, 7]);\n    test(&[], &[1, 2, 3], true, vec![], vec![1, 2, 3]);\n    test(&[1, 2, 3], &[], false, vec![1, 2, 3], vec![]);\n    test(&[1, 1, 1], &[1, 2, 3], false, vec![0, 3, 2], vec![1, 2, 3]);\n    test(\n        &[100, 101, 102],\n        &[102, 101, 100],\n        false,\n        vec![2, 0, 2],\n        vec![102, 101, 100],\n    );\n}\n\n#[test]\nfn test_xor() {\n    let test = |u, v, out| {\n        let mut n = Natural::from_str(u).unwrap();\n        n ^= Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = Natural::from_str(u).unwrap();\n        n ^= &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::from_str(u).unwrap() ^ Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &Natural::from_str(u).unwrap() ^ Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::from_str(u).unwrap() ^ &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &Natural::from_str(u).unwrap() ^ &Natural::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        assert_eq!(\n            natural_xor_alt_1(\n                &Natural::from_str(u).unwrap(),\n                &Natural::from_str(v).unwrap(),\n            )\n            .to_string(),\n            out\n        );\n        assert_eq!(\n            natural_xor_alt_2(\n                &Natural::from_str(u).unwrap(),\n                &Natural::from_str(v).unwrap(),\n            )\n            .to_string(),\n            out\n        );\n\n        let n = BigUint::from_str(u).unwrap() ^ BigUint::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Integer::from_str(u).unwrap() ^ rug::Integer::from_str(v).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"456\", \"435\");\n    test(\"1000000000000\", \"123\", \"1000000000123\");\n    test(\"123\", \"1000000000000\", \"1000000000123\");\n    test(\"1000000000001\", \"123\", \"1000000000122\");\n    test(\"12345678987654321\", \"0\", \"12345678987654321\");\n    test(\"12345678987654321\", \"456\", \"12345678987654521\");\n    test(\"12345678987654321\", \"987654321\", \"12345678815534080\");\n    test(\"1000000000000\", \"999999999999\", \"8191\");\n    test(\"12345678987654321\", \"314159265358979\", \"12035174921130034\");\n}\n\n#[test]\nfn limbs_xor_limb_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(xs, y)| {\n        assert_eq!(\n            Natural::from_owned_limbs_asc(limbs_xor_limb(&xs, y)),\n            Natural::from_owned_limbs_asc(xs) ^ Natural::from(y)\n        );\n    });\n}\n\n#[test]\nfn limbs_xor_limb_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_vec_unsigned_triple_gen_var_4().test_properties_with_config(\n        &config,\n        |(mut out, xs, y)| {\n            let old_out = out.clone();\n            limbs_xor_limb_to_out(&mut out, &xs, y);\n            let len = xs.len();\n            assert_eq!(\n                Natural::from_limbs_asc(&out[..len]),\n                Natural::from_owned_limbs_asc(xs) ^ Natural::from(y)\n            );\n            assert_eq!(&out[len..], &old_out[len..]);\n        },\n    );\n}\n\n#[test]\nfn limbs_xor_limb_in_place_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_unsigned_pair_gen_var_15().test_properties_with_config(&config, |(mut xs, y)| {\n        let old_xs = xs.clone();\n        limbs_xor_limb_in_place(&mut xs, y);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(old_xs) ^ Natural::from(y)\n        );\n    });\n}\n\nfn limbs_xor_helper(\n    f: &mut dyn FnMut(&[Limb], &[Limb]) -> Vec<Limb>,\n    xs: Vec<Limb>,\n    ys: Vec<Limb>,\n) {\n    assert_eq!(\n        Natural::from_owned_limbs_asc(f(&xs, &ys)),\n        Natural::from_owned_limbs_asc(xs) ^ Natural::from_owned_limbs_asc(ys)\n    );\n}\n\n#[test]\nfn limbs_xor_same_length_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_xor_helper(&mut limbs_xor_same_length, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_xor_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(xs, ys)| {\n        limbs_xor_helper(&mut limbs_xor, xs, ys);\n    });\n}\n\n#[test]\nfn limbs_xor_same_length_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_31().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_xor_same_length_to_out(&mut out, &xs, &ys);\n        let len = ys.len();\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Natural::from_owned_limbs_asc(xs) ^ Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_xor_to_out_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_triple_gen_var_32().test_properties_with_config(&config, |(mut out, xs, ys)| {\n        let out_old = out.clone();\n        limbs_xor_to_out(&mut out, &xs, &ys);\n        let len = max(xs.len(), ys.len());\n        assert_eq!(\n            Natural::from_limbs_asc(&out[..len]),\n            Natural::from_owned_limbs_asc(xs) ^ Natural::from_owned_limbs_asc(ys)\n        );\n        assert_eq!(&out[len..], &out_old[len..]);\n    });\n}\n\n#[test]\nfn limbs_xor_same_length_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen_var_6().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_xor_same_length_in_place_left(&mut xs, &ys);\n        assert_eq!(\n            Natural::from_owned_limbs_asc(xs),\n            Natural::from_owned_limbs_asc(xs_old) ^ Natural::from_owned_limbs_asc(ys)\n        );\n    });\n}\n\n#[test]\nfn limbs_xor_in_place_left_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, ys)| {\n        let xs_old = xs.clone();\n        limbs_xor_in_place_left(&mut xs, &ys);\n        let n = Natural::from_owned_limbs_asc(xs_old) ^ Natural::from_owned_limbs_asc(ys);\n        assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n    });\n}\n\n#[test]\nfn limbs_xor_in_place_either_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 32);\n    config.insert(\"mean_stripe_n\", 16 << Limb::LOG_WIDTH);\n    unsigned_vec_pair_gen().test_properties_with_config(&config, |(mut xs, mut ys)| {\n        let xs_old = xs.clone();\n        let ys_old = ys.clone();\n        let right = limbs_xor_in_place_either(&mut xs, &mut ys);\n        let n = Natural::from_limbs_asc(&xs_old) ^ Natural::from_limbs_asc(&ys_old);\n        if right {\n            assert_eq!(xs, xs_old);\n            assert_eq!(Natural::from_owned_limbs_asc(ys), n);\n        } else {\n            assert_eq!(Natural::from_owned_limbs_asc(xs), n);\n            assert_eq!(ys, ys_old);\n        }\n    });\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn or_properties() {\n    natural_pair_gen().test_properties(|(x, y)| {\n        let result_val_val = x.clone() ^ y.clone();\n        let result_val_ref = x.clone() ^ &y;\n        let result_ref_val = &x ^ y.clone();\n        let result = &x ^ &y;\n        assert!(result_val_val.is_valid());\n        assert!(result_val_ref.is_valid());\n        assert!(result_ref_val.is_valid());\n        assert!(result.is_valid());\n        assert_eq!(result_val_val, result);\n        assert_eq!(result_val_ref, result);\n        assert_eq!(result_ref_val, result);\n\n        let mut mut_x = x.clone();\n        mut_x ^= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, result);\n        let mut mut_x = x.clone();\n        mut_x ^= &y;\n        assert_eq!(mut_x, result);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Integer::from(&x);\n        mut_x ^= rug::Integer::from(&y);\n        assert_eq!(Natural::exact_from(&mut_x), result);\n\n        assert_eq!(\n            Natural::from(&(BigUint::from(&x) ^ BigUint::from(&y))),\n            result\n        );\n        assert_eq!(\n            Natural::exact_from(&(rug::Integer::from(&x) ^ rug::Integer::from(&y))),\n            result\n        );\n\n        assert_eq!(natural_xor_alt_1(&x, &y), result);\n        assert_eq!(natural_xor_alt_2(&x, &y), result);\n\n        assert_eq!(&y ^ &x, result);\n        assert_eq!(&result ^ &x, y);\n        assert_eq!(&result ^ y, x);\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(&x ^ Natural::ZERO, x);\n        assert_eq!(Natural::ZERO ^ &x, x);\n        assert_eq!(&x ^ &x, 0);\n    });\n\n    natural_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x ^ &y) ^ &z, x ^ (y ^ z));\n    });\n\n    unsigned_pair_gen_var_27::<Limb>().test_properties(|(x, y)| {\n        assert_eq!(Natural::from(x) ^ Natural::from(y), x ^ y);\n    });\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/get_random_natural_less_than.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::get_random_natural_less_than;\nuse std::str::FromStr;\n\nfn get_random_natural_less_than_helper(limit: &str, out: &str) {\n    let mut xs = random_primitive_ints(EXAMPLE_SEED);\n    let xs = (0..10)\n        .map(|_| get_random_natural_less_than(&mut xs, &Natural::from_str(limit).unwrap()))\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_random_natural_less_than() {\n    get_random_natural_less_than_helper(\"1\", \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_random_natural_less_than_helper(\"10\", \"[1, 7, 5, 7, 9, 2, 8, 2, 4, 6]\");\n    get_random_natural_less_than_helper(\"100\", \"[87, 93, 7, 84, 27, 46, 93, 22, 86, 1]\");\n    get_random_natural_less_than_helper(\"1000\", \"[881, 87, 93, 629, 519, 626, 360, 242, 491, 84]\");\n    get_random_natural_less_than_helper(\n        \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        000000000000\",\n        \"[6513696165206921204311261523739269601083760431420210295861564381205783648442563498105196\\\n        329975541617, \\\n        868400879467069938866982772480181142332366549281254507368280851531146621198387695461761814\\\n        2446877811, \\\n        454890116058063209121711848211479855802275293374032067837601343116564901989251772312271223\\\n        8643735453, \\\n        221953236727409585623978519825787712675415538807055958167887436471257145918881448806179877\\\n        2042912434, \\\n        156597062580980418852701766729202981599785596117178894442015894874216386954905163169649546\\\n        2984128417, \\\n        775809396529562140517641222093832263868653173407259880967133743504333426167140950839221651\\\n        5440206577, \\\n        194588045371630389938122892550032325836127322381120175893002672149553900804839171978848159\\\n        3900827375, \\\n        681710429818657256239982130308509711765427303233424706691965226432442255381734547395128615\\\n        696717955, \\\n        525885978270298534580002381561976404877189873292849476887431075456216366244793235854298324\\\n        5431956916, \\\n        314957843714266314102082575313210347468784454645937249947829551130804781109663224113983528\\\n        7147185026]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_random_natural_less_than_fail() {\n    get_random_natural_less_than(&mut random_primitive_ints(EXAMPLE_SEED), &Natural::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/get_random_natural_with_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::random::get_random_natural_with_bits;\n\nfn get_random_natural_with_bits_helper(bits: u64, out: &str) {\n    let mut xs = random_primitive_ints(EXAMPLE_SEED);\n    let xs = (0..10)\n        .map(|_| get_random_natural_with_bits(&mut xs, bits))\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_random_natural_with_bits() {\n    get_random_natural_with_bits_helper(0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_random_natural_with_bits_helper(1, \"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\");\n    get_random_natural_with_bits_helper(10, \"[881, 599, 605, 629, 519, 1001, 626, 872, 754, 1003]\");\n    get_random_natural_with_bits_helper(\n        100,\n        \"[976558340558744279591984426865, 1210743526759830339060468402269, \\\n        987622786528174742128034915847, 1028849241887437545987236408946, \\\n        636224214690002338734404794610, 1084022137993299669433275842644, \\\n        651260491393393331452592307118, 938596277659014096812502469654, \\\n        1027696177399334210658775892715, 1215526897097077179887043345523]\",\n    );\n    get_random_natural_with_bits_helper(\n        1000,\n        \"[9871555593311388583730668028572947972273370391584873166827867445956379776331862403614137\\\n        010240679811389700642404293916880391529744438580436267309669605743557526364970431150933385\\\n        398365619760568042866366891175418557263537757651023714048098525335447177149901286977666669\\\n        228734508013967448659203593727857, \\\n        791294226283400338116725266395415668811492351726967595517985462290683501988325067570154247\\\n        916466497696906715377685810324362572568643782805454526919199743597748426287793605950177843\\\n        400312249716517544116781742042345757038219051016833597591532327578014535369800683425719501\\\n        1222552384008059606354106024683, \\\n        603141122347678493875935496567523539943016200607299929590987513666029676151877700615600993\\\n        558206489004992870361727816768285331691513429048943961969079262017872532249009221429690429\\\n        173396464673970587747514162246269540847510994058348422653339211911977412158645139435582116\\\n        2135683154777550054864806973191, \\\n        918979157591718364955430394079794967293887473404422985188351315968507884008710649189160051\\\n        696207222829134675903387190115731463781015558345121417040971370267174581281652951730760301\\\n        188537459504910504772462880811654819707300024255167639013890736171444647445349859763886702\\\n        2577615653562903750479807977377, \\\n        647326991054871401446391652220147139977257585074930117822971968152242235080123828418477499\\\n        122643194996280709533149340353864776491291597713840972420179000074772311437377760180051433\\\n        385038047440481754027985595280436007381332471223783461841596113991149106848191431176197419\\\n        2844525526720830095389487497409, \\\n        949041077003843738114763478589507012307507968570578492234472107314902412716521187076156469\\\n        160317707751627684700609080913827492307622771744874629743335821135555462576657380263807543\\\n        487753886476772373626981873033661206968177922749550215130614548300918947578733522250796129\\\n        5744371969372939814739027796839, \\\n        989922815195092012407533508457902337326088523136116587955882587433938614841443439968917681\\\n        506531942296074930018264941258097700513177676253997511008000381073449050985414240650516825\\\n        818652374821129290720209582447241803904618161996066094314560522095909158341055892421259319\\\n        6555994763897951379745163707947, \\\n        560430875586881451021986079137268355719860392640168705312566874574524151511315309194440525\\\n        432541907755646531766496361640227195372967955930947529029583706599432734589617900554403438\\\n        972135775666804402920199247213229036374355559526777099281829864834361213138370127732279617\\\n        7830548383897263545487627313816, \\\n        607760857698629857675370920711285763610351243179869812617321508384537069997121877063755036\\\n        502176965392609298699890321897240768662430762687034745512362659852305512122877940314598630\\\n        179328920839572409651612938305899406030180626695355189902602551915007303361897784538043083\\\n        9825515983752933214916509907962, \\\n        104802773115609428879259254484528372112963320559423798212143117675970187076769475019659710\\\n        589902898294520178185617889833116138928807499798445230962192076044779146948376974924138017\\\n        275574706437699501177855375574899794972601656611168235082869924333910214914822287693744357\\\n        49828269999407972362285090280006]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/get_random_natural_with_up_to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::random_primitive_ints;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::random::get_random_natural_with_up_to_bits;\n\nfn get_random_natural_with_up_to_bits_helper(bits: u64, out: &str) {\n    let mut xs = random_primitive_ints(EXAMPLE_SEED);\n    let xs = (0..10)\n        .map(|_| get_random_natural_with_up_to_bits(&mut xs, bits))\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_random_natural_with_up_to_bits() {\n    get_random_natural_with_up_to_bits_helper(0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_random_natural_with_up_to_bits_helper(1, \"[1, 1, 1, 1, 1, 1, 0, 0, 0, 1]\");\n    get_random_natural_with_up_to_bits_helper(\n        10,\n        \"[881, 87, 93, 629, 519, 1001, 626, 360, 242, 491]\",\n    );\n    get_random_natural_with_up_to_bits_helper(\n        100,\n        \"[976558340558744279591984426865, 576918226645715638312116799581, \\\n        987622786528174742128034915847, 395023941773322845238884806258, \\\n        636224214690002338734404794610, 450196837879184968684924239956, \\\n        17435191279278630704240704430, 938596277659014096812502469654, \\\n        1027696177399334210658775892715, 581701596982962479138691742835]\",\n    );\n    get_random_natural_with_up_to_bits_helper(\n        1000,\n        \"[4514012557380051978988542783272938919466346333057205129609115504104624520707181791148145\\\n        116162200520751727277816528182754455803315977010218275020882256456155559081083019035440674\\\n        861063088574997103889275814652181065472567123951639934465326552296915719864303048134395585\\\n        398519592187655255240600759693169, \\\n        791294226283400338116725266395415668811492351726967595517985462290683501988325067570154247\\\n        916466497696906715377685810324362572568643782805454526919199743597748426287793605950177843\\\n        400312249716517544116781742042345757038219051016833597591532327578014535369800683425719501\\\n        1222552384008059606354106024683, \\\n        603141122347678493875935496567523539943016200607299929590987513666029676151877700615600993\\\n        558206489004992870361727816768285331691513429048943961969079262017872532249009221429690429\\\n        173396464673970587747514162246269540847510994058348422653339211911977412158645139435582116\\\n        2135683154777550054864806973191, \\\n        918979157591718364955430394079794967293887473404422985188351315968507884008710649189160051\\\n        696207222829134675903387190115731463781015558345121417040971370267174581281652951730760301\\\n        188537459504910504772462880811654819707300024255167639013890736171444647445349859763886702\\\n        2577615653562903750479807977377, \\\n        111572687461737740972179127690146234696555179222163314101096773967066709517655767171878309\\\n        714795265932483373074372766941271203848445440692041743541444071334575583048636548630780379\\\n        654784928883387856318877942956686828284269101285405503564398810138003378288367546849089036\\\n        2629609700408636676786653462721, \\\n        413286773410710077640550954059506107026805562717811688512596913129726887154053125829557279\\\n        752469778687830348241832507501233919664776614723075400864600892395358734187916168714536489\\\n        757500767919678475917874220709912027871114552811172256853417244447773219018909637923687746\\\n        5529456143060746396136193762151, \\\n        454168511601958351933320983927901432045386117283349784234007393248763089278975378722318492\\\n        098684013232277593559488367845504127870331519232198282129265452333252322596673029101245772\\\n        088399256264035393011101930123492624807554792057688136037363218242763429781232008094150936\\\n        6341078937585757961142329673259, \\\n        560430875586881451021986079137268355719860392640168705312566874574524151511315309194440525\\\n        432541907755646531766496361640227195372967955930947529029583706599432734589617900554403438\\\n        972135775666804402920199247213229036374355559526777099281829864834361213138370127732279617\\\n        7830548383897263545487627313816, \\\n        720065541054961972011583961812848583296488373271030088954463141993615444346538158171558470\\\n        943290363288119622411137484846471960195846056652355166336277311121087837341367287653275764\\\n        490758022824785119425052859821502269331172567569772316254052480618615748020739002109347009\\\n        610600157440739796313675873274, \\\n        512273427562960628318380020315282815848930799741471178399555982574526345205226688949997916\\\n        491181053881404445397402324918567816645228840962653080743185831707594741095028537692109119\\\n        025493945819901114069446103425248770628953196173304392551501939485956420588398992610335191\\\n        9613354173095778943682256245318]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/get_striped_random_natural_from_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::get_striped_random_natural_from_inclusive_range;\nuse std::str::FromStr;\n\nfn get_striped_random_natural_from_inclusive_range_helper(\n    m_numerator: u64,\n    m_denominator: u64,\n    a: &str,\n    b: &str,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, m_numerator, m_denominator);\n    let xs = (0..10)\n        .map(|_| {\n            get_striped_random_natural_from_inclusive_range(\n                &mut bit_source,\n                Natural::from_str(a).unwrap(),\n                Natural::from_str(b).unwrap(),\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_natural_from_inclusive_range() {\n    get_striped_random_natural_from_inclusive_range_helper(\n        2,\n        1,\n        \"0\",\n        \"0\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_natural_from_inclusive_range_helper(\n        2,\n        1,\n        \"1950\",\n        \"2023\",\n        \"[1950, 1971, 1990, 1962, 2018, 1972, 1952, 1999, 1989, 1987]\",\n    );\n    get_striped_random_natural_from_inclusive_range_helper(\n        2,\n        1,\n        \"1000000\",\n        \"2000000\",\n        \"[1002694, 1403247, 1036052, 1001215, 1170335, 1510298, 1661478, 1012673, 1005113, \\\n        1014065]\",\n    );\n\n    get_striped_random_natural_from_inclusive_range_helper(\n        10,\n        1,\n        \"0\",\n        \"0\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_natural_from_inclusive_range_helper(\n        10,\n        1,\n        \"1950\",\n        \"2023\",\n        \"[1950, 1951, 1983, 2016, 1950, 2020, 2016, 1951, 1950, 1983]\",\n    );\n    get_striped_random_natural_from_inclusive_range_helper(\n        10,\n        1,\n        \"1000000\",\n        \"2000000\",\n        \"[1001471, 1056767, 1032199, 1000432, 1998848, 1040384, 1000000, 1574911, 1981967, \\\n        1048574]\",\n    );\n\n    get_striped_random_natural_from_inclusive_range_helper(\n        11,\n        10,\n        \"0\",\n        \"0\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_natural_from_inclusive_range_helper(\n        11,\n        10,\n        \"1950\",\n        \"2023\",\n        \"[1962, 1962, 1972, 2019, 2019, 1962, 1962, 1986, 2005, 2005]\",\n    );\n    get_striped_random_natural_from_inclusive_range_helper(\n        11,\n        10,\n        \"1000000\",\n        \"2000000\",\n        \"[1004885, 1718613, 1027925, 1004874, 1485482, 1397329, 1741994, 1011029, 1004885, \\\n        1010346]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_natural_from_inclusive_range_fail_1() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 2, 1);\n    get_striped_random_natural_from_inclusive_range(\n        &mut bit_source,\n        Natural::from(10u32),\n        Natural::from(9u32),\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/get_striped_random_natural_from_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::get_striped_random_natural_from_range;\nuse std::str::FromStr;\n\nfn get_striped_random_natural_from_range_helper(\n    m_numerator: u64,\n    m_denominator: u64,\n    a: &str,\n    b: &str,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, m_numerator, m_denominator);\n    let xs = (0..10)\n        .map(|_| {\n            get_striped_random_natural_from_range(\n                &mut bit_source,\n                Natural::from_str(a).unwrap(),\n                Natural::from_str(b).unwrap(),\n            )\n        })\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_natural_from_range() {\n    get_striped_random_natural_from_range_helper(2, 1, \"0\", \"1\", \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_from_range_helper(\n        2,\n        1,\n        \"1950\",\n        \"2024\",\n        \"[1950, 1971, 1990, 1962, 2018, 1972, 1952, 1999, 1989, 1987]\",\n    );\n    get_striped_random_natural_from_range_helper(\n        2,\n        1,\n        \"1000000\",\n        \"2000001\",\n        \"[1002694, 1403247, 1036052, 1001215, 1170335, 1510298, 1661478, 1012673, 1005113, \\\n        1014065]\",\n    );\n\n    get_striped_random_natural_from_range_helper(10, 1, \"0\", \"1\", \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_from_range_helper(\n        10,\n        1,\n        \"1950\",\n        \"2024\",\n        \"[1950, 1951, 1983, 2016, 1950, 2020, 2016, 1951, 1950, 1983]\",\n    );\n    get_striped_random_natural_from_range_helper(\n        10,\n        1,\n        \"1000000\",\n        \"2000001\",\n        \"[1001471, 1056767, 1032199, 1000432, 1998848, 1040384, 1000000, 1574911, 1981967, \\\n        1048574]\",\n    );\n\n    get_striped_random_natural_from_range_helper(\n        11,\n        10,\n        \"0\",\n        \"1\",\n        \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\",\n    );\n    get_striped_random_natural_from_range_helper(\n        11,\n        10,\n        \"1950\",\n        \"2024\",\n        \"[1962, 1962, 1972, 2019, 2019, 1962, 1962, 1986, 2005, 2005]\",\n    );\n    get_striped_random_natural_from_range_helper(\n        11,\n        10,\n        \"1000000\",\n        \"2000001\",\n        \"[1004885, 1718613, 1027925, 1004874, 1485482, 1397329, 1741994, 1011029, 1004885, \\\n        1010346]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_natural_from_range_fail_1() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 2, 1);\n    get_striped_random_natural_from_range(\n        &mut bit_source,\n        Natural::from(10u32),\n        Natural::from(9u32),\n    );\n}\n\n#[test]\n#[should_panic]\nfn get_striped_random_natural_from_range_fail_2() {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, 2, 1);\n    get_striped_random_natural_from_range(\n        &mut bit_source,\n        Natural::from(10u32),\n        Natural::from(10u32),\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/get_striped_random_natural_with_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::random::get_striped_random_natural_with_bits;\n\nfn get_striped_random_natural_with_bits_helper(\n    m_numerator: u64,\n    m_denominator: u64,\n    bits: u64,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, m_numerator, m_denominator);\n    let xs = (0..10)\n        .map(|_| get_striped_random_natural_with_bits(&mut bit_source, bits))\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_natural_with_bits() {\n    get_striped_random_natural_with_bits_helper(2, 1, 0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_with_bits_helper(2, 1, 1, \"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\");\n    get_striped_random_natural_with_bits_helper(\n        2,\n        1,\n        10,\n        \"[716, 684, 662, 763, 798, 829, 768, 732, 536, 541]\",\n    );\n    get_striped_random_natural_with_bits_helper(\n        2,\n        1,\n        100,\n        \"[756308944479610176770360563916, 1145718678910746691112769802930, \\\n        1080305256857112995037586132048, 807717805879357681845918965159, \\\n        1215845349850185248466264185684, 822948728534233460050112643373, \\\n        955700757257715004518140113132, 832461439248077413553063350320, \\\n        1242643020761038901934578711610, 1122137987246906014371413743505]\",\n    );\n    get_striped_random_natural_with_bits_helper(\n        2,\n        1,\n        1000,\n        \"[1066036401822586582060831035662706457005124173369385364089512753873668954854498653201330\\\n        529188610070039476426288535963559977582497470497937854727434805905648395790056513373361685\\\n        117044701404743375692128198904783759739184161371638993268438163708872889304697920949732034\\\n        4797581420099450165301088751016140, \\\n        987176835967471470631208736450711102640000526855618567465986968908194747303665548783151326\\\n        849739186186452340671673297796771266911335225612017707433164734645560965513055402080032340\\\n        135474058189238938067890211197448581037553663122597099692488328028757994359299305393973140\\\n        7925926109130072336312534438574, \\\n        568651645319898625478110927429560819026449278119016593712297801674333004668766652853597774\\\n        772681158919761337797730830161503881200296844963400983419113636067755214296565242049691883\\\n        922630951084279967424027354828765778295400023859140245298770234805718721051701730000306553\\\n        5144184078571910290480368694380, \\\n        758830907466434071959666860937945102677771418528458236060516770128040285772163826421306107\\\n        069853863334698116336945744601463639747199523669413845254638599625980012214050809846459478\\\n        559098934176586233093238956124608709775991202493060441152475782277782012828793855484827036\\\n        1411929636489612968071552336405, \\\n        980856434133966113634431860230323947967355946268495564634504680787571319483353753543014805\\\n        474807358240303253563585951883147532327134463459185707026951902911405729653418676374715955\\\n        691096425012748194433199980744016228705422729019166704577441683479974798193714636957924636\\\n        2973260186276362799319175133568, \\\n        894303548113446750904572507746592793549624231872528102587605556722756026081514290865978856\\\n        949605256419586901475129581474267478481820707346973965338715875069463779465480362052962715\\\n        102197582459759242950488814694110771040964546445427112279563255714907257699939184423978433\\\n        0215727680884042630165644025099, \\\n        974492070270890205196098593733513997055807419178419835560661240335358848519651158952303927\\\n        871434236017718573182013896425860901259995476236242988456734111274812403199906058941973460\\\n        877801690192132645453156214170274198928980236695132799825665804217976367252593838779965803\\\n        0607916391896384659714182950628, \\\n        645130850234339503642007350857138479917399859387095109454794616985938391311231126744661800\\\n        420543794746031491748493862132931262497139684250480230073784453843645088983023718012240528\\\n        683824553139343195888019854863909746543574579361265915812174560716242126991285521565613433\\\n        2466523138255580920562084028294, \\\n        639103284871251403821872209988025331131792409726095776075819070688817857426736537831222024\\\n        179652645603869247406404689998157064676469146016517502338483799149248172262554878327272758\\\n        174240821091933100132108595935722179262833993962469175972706639648644071967476854878243149\\\n        4649776909489103783746916780024, \\\n        104643900952018601215342460716610794174551332701220396118082370352258784597041601116915384\\\n        664642853384078500349464320717455867749180262488843336424123164153150026841959758704744253\\\n        756151269545080362145067323770739682710146919991724449298137503388491656477667755306189744\\\n        24803845757396271996047726290589]\",\n    );\n\n    get_striped_random_natural_with_bits_helper(10, 1, 0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_with_bits_helper(10, 1, 1, \"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\");\n    get_striped_random_natural_with_bits_helper(\n        10,\n        1,\n        10,\n        \"[1016, 992, 1016, 767, 512, 513, 1020, 512, 1016, 1023]\",\n    );\n    get_striped_random_natural_with_bits_helper(\n        10,\n        1,\n        100,\n        \"[950737912392312175425017102328, 1109194416875305772521657204608, \\\n        648685415698526143125877948414, 1248153346840921551430087606303, \\\n        831891172891058554467585867776, 1267650600228229401359297740927, \\\n        950739156735808420047682273024, 638776758039873373851420326912, \\\n        643690285327603686643074121664, 671543785829629858305590427647]\",\n    );\n    get_striped_random_natural_with_bits_helper(\n        10,\n        1,\n        1000,\n        \"[5358165738110281147468429156665582144998881353628318343872646956815751197999946897572878\\\n        278363096783827886911589242856640635533315179867213030979090927223140806482585564866175368\\\n        333598466336603271609976534104173527941609131651006242168470752742668268779440452153819210\\\n        944528718553525957103310205894648, \\\n        539935796843008525931501938016824825731989695976128079798746287896348626759778818662810517\\\n        524977343980885794548702209431866052161353917750190601629912511180434696813340457173208570\\\n        976449234006368601336057069020362424176301595236556802947569224730136326560449690301955186\\\n        3255474664584713584582999408640, \\\n        535754303694423899076935129343771055050259990680670440133208286589122737827790634967047773\\\n        700260648071343420497642383540669384404571214562700313160956733565914399913133443167360146\\\n        252087697860065532691284023259655546679447897828373290595492357586809871031621268591800199\\\n        5164641448720709752408544641022, \\\n        535815617678664673230583609293711626429039758128419938980167626717612472897746291934554185\\\n        557830869500024824265898785919682260921341384664997061547297321382527299885697935410512118\\\n        522746192907474498033052134885264654751340612094587360238549546738016850498598238219826282\\\n        5015681391047050153768125472767, \\\n        100656671761770967200809514408313411282491427879094391861152015262204431791194203727185921\\\n        026045038825035836776620646775627513583957795766207833861462739511509698818541011638004365\\\n        409989389341031372058994101918102834059849507520841606970888386863725907172131052360271284\\\n        55992101445905914436525739998208, \\\n        107149228544600635260212788419695526657434400429968676165634060825808436991969085650247279\\\n        650596133663598434482129668133099616635115467318010721467086518060004035373781135234642383\\\n        205702114144671525516391055691812453033688242812694582953965743513229924054172419365064495\\\n        42173396641692237011907449425727, \\\n        107150860693727448661794856915575585277857852731679120989819290845002348669070050613296455\\\n        734254692011706809018756806353158106462995138380031851002523766291502961737781576247555759\\\n        035185454502873048780305065230433793569807065690804749332353542464565681262222119583879742\\\n        48405282741635132994030678311166, \\\n        107150835221766756970390016554040088032382955997319930334779105385220088376881426554895494\\\n        540316762324972302835401791427607201669829855912974990784820455466307137336628823875387612\\\n        135057991945407277136587896193153151600433435164863822917290693842788118252951172684773421\\\n        70526384435574180443755489763328, \\\n        535754329539033410731721563380478204940555300525204412489285381291927939025074977709123312\\\n        566899344374925407384165980119188647505571183538659634788083559269291976584227032503722306\\\n        929007576563288991617997079930222315375169710335488132792623698751814518487754242895518611\\\n        5084271519939681346646991441912, \\\n        535882021406206416670177596158366769032342285663637541146888579315644330411450606808875554\\\n        132489833818740595777819456634963853487245325624796744100983558326561831449646070534648278\\\n        476260874658721825904285846269922085259057263667571525921657161024153045937468235049728709\\\n        2438657975290976181526386966515]\",\n    );\n\n    get_striped_random_natural_with_bits_helper(11, 10, 0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_with_bits_helper(11, 10, 1, \"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\");\n    get_striped_random_natural_with_bits_helper(\n        11,\n        10,\n        10,\n        \"[682, 842, 668, 853, 862, 853, 850, 852, 682, 853]\",\n    );\n    get_striped_random_natural_with_bits_helper(\n        11,\n        10,\n        100,\n        \"[1063803140432100403291953916586, 739462850133133817539732346028, \\\n        1056478660679155688751767049562, 848401573590247656481079600469, \\\n        1056375500189999764883937602218, 1053067879147533365448711514965, \\\n        1056381847001601296578889995602, 1056377112103581910626871170386, \\\n        1056375600983290506811020749482, 845074597043259864052961293645]\",\n    );\n    get_striped_random_natural_with_bits_helper(\n        11,\n        10,\n        1000,\n        \"[8929237967230103262890722824433509449612079777418572793068173743542860931264379536551467\\\n        111265297962015834728928882271330897607870697615306329567845176199860105934578611877105699\\\n        420361112596704086865552677150738773328713505835358160809074402075384139431403167870451367\\\n        242430551069260362892051555117738, \\\n        848277807033155886730751542077297974149911088007915913764780956681936845102711155704193533\\\n        266937165754352296914790126319848647014472476095156708927462195514313159177074602462717519\\\n        349357763529281370152392669738095746762025827796955823134607626270938290494658223672222158\\\n        9872232895273605128836243696298, \\\n        622256279237828710101116559940449011192577108759402537346355985105564415773311644474958256\\\n        085364963664247523046669028723331763456095716282707295047182502032978485452383285604942655\\\n        047145606332906731031323587018683298574131563687284576221383367233664334964305026386536472\\\n        7120990168388537700787439359354, \\\n        893011037585013007271439602956526972024707806627477311937832595287305307343362049808812372\\\n        867697432889627779970803417048478482882370003668394928455851950345620310470241544275541047\\\n        354242013397873563064543296718018003131524951605807454956556860189105716328731797732674596\\\n        4570601733436095071743763633493, \\\n        714337697986576114077307239016734314472779437227875536493177724277496357242071140467095878\\\n        368847036684840951410204114568419486398409897184525378525275704002748768137539106304824083\\\n        362036096433222952552023855753638427465829477635653011302870027782444701974201225532101310\\\n        2549204865443174861708377533098, \\\n        717129479744396200344184597459955775324063665344347322215427784911546292557185067124997476\\\n        300110608871594211005211148242437189627028361260715625731282067311558916993444457603008618\\\n        146383526538195175746094394556394170673628321139601154519945289775172095900192878319082649\\\n        5453320605634381639129320740181, \\\n        712943875305246933549449117163766092515737565613814773068912395757448666817082911895780847\\\n        326837660502284270497684787917665238088905925731656976408461765235806743263267139181463148\\\n        004431439157535144190810911719314309577264591245575456701925751321667869578190443322813012\\\n        0138648732293712628634064954698, \\\n        892880942227156526968373917452622274287516410008666161523034951090805186930790904719943631\\\n        023279485226392520031870194759074725254789440380488049235603947036487803727696933564597255\\\n        812777037968411285945062427246430458697274335300861633278805179074880855146539152265137509\\\n        2760519788829492124624878217898, \\\n        892945641881431108631973304223007197865627901236713933938944990987439087863487393850263204\\\n        926847861908008259701418716838801341585797849737533079786960203576656895262092537802767877\\\n        046297885380150024466056272755057031975057975145576287997024449574764798500660830182847012\\\n        5379718921376291465124979747542, \\\n        712949327932932700218621033804526985196291897563252301818755627637478824989877935042325873\\\n        291167136650626866176302303072095225803612799473142905508378017958979111144644566257625076\\\n        950893722575069628745776862688326045350363911106097574031678159885821711577125514250680212\\\n        9840859041388985930050461586805]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/get_striped_random_natural_with_up_to_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::random::get_striped_random_natural_with_up_to_bits;\n\nfn get_striped_random_natural_with_up_to_bits_helper(\n    m_numerator: u64,\n    m_denominator: u64,\n    bits: u64,\n    out: &str,\n) {\n    let mut bit_source = StripedBitSource::new(EXAMPLE_SEED, m_numerator, m_denominator);\n    let xs = (0..10)\n        .map(|_| get_striped_random_natural_with_up_to_bits(&mut bit_source, bits))\n        .collect_vec();\n    assert_eq!(xs.to_debug_string(), out);\n}\n\n#[test]\nfn test_get_striped_random_natural_with_up_to_bits() {\n    get_striped_random_natural_with_up_to_bits_helper(2, 1, 0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_with_up_to_bits_helper(2, 1, 1, \"[0, 0, 0, 1, 0, 1, 0, 0, 0, 1]\");\n    get_striped_random_natural_with_up_to_bits_helper(\n        2,\n        1,\n        10,\n        \"[204, 684, 662, 251, 286, 317, 768, 732, 24, 541]\",\n    );\n    get_striped_random_natural_with_up_to_bits_helper(\n        2,\n        1,\n        100,\n        \"[756308944479610176770360563916, 511893378796631990364418200242, \\\n        446479956742998294289234529360, 173892505765242981097567362471, \\\n        1215845349850185248466264185684, 189123428420118759301761040685, \\\n        955700757257715004518140113132, 832461439248077413553063350320, \\\n        1242643020761038901934578711610, 488312687132791313623062140817]\",\n    );\n    get_striped_random_natural_with_up_to_bits_helper(\n        2,\n        1,\n        1000,\n        \"[5302820982294529215866185111327055517244217675166185603676375596884934292920305919547313\\\n        397807621409756790898297593901473840098546243409160554985560709769081990616677721618124140\\\n        633144482861862817944190912524600105600870980017006153101609664050197435761380970654049260\\\n        967366504273137971882485916981452, \\\n        451422532374337810156996211920710197359298121002851763744111774723019221741197487536552137\\\n        441891257122655004212896724384177694268489068590218478554429805905364237124314190530761286\\\n        405220939632145040358782558873699401940490293184219141415291024175612265799475421066864757\\\n        7711010282817878917709700403886, \\\n        328973417267649650038984028995599137457468722662497899904226074891574791062985916069985853\\\n        648332298559640013389542567489103085574506879416017545403787073275584859078240305004208301\\\n        923778325271860697149197025050165991983366539207622870215729309525729924918778456731981704\\\n        929268252259716871877534659692, \\\n        758830907466434071959666860937945102677771418528458236060516770128040285772163826421306107\\\n        069853863334698116336945744601463639747199523669413845254638599625980012214050809846459478\\\n        559098934176586233093238956124608709775991202493060441152475782277782012828793855484827036\\\n        1411929636489612968071552336405, \\\n        445102130540832453160219335700323042686653540415728760912629486602395793920885692296415616\\\n        066959429176505917104809378470553959684288306437386478148216974171209001264677464825444901\\\n        960843306455654296724092328420267049608359359080788746300244379626829069633890752630816253\\\n        2758344359964169380716341098880, \\\n        358549244520313090430359983216591888268921826019761298865730362537580500519046229619379667\\\n        541757327355789565016353008061673905838974550325174736459980946329267051076739150503691661\\\n        371944463902665345241381162370361591943901176507049154002365951861761529140115300096870050\\\n        0000811854571849211562809990411, \\\n        438737766677756544721886069203513091775105013325653031838786046150183322957183097705704738\\\n        463586306953921236723237323013267328617149319214443759577999182534615674811164847392702407\\\n        147548571635038747744048561846525019831916866756754841548468500364830638692769954452857420\\\n        0393000565584191241111348915940, \\\n        645130850234339503642007350857138479917399859387095109454794616985938391311231126744661800\\\n        420543794746031491748493862132931262497139684250480230073784453843645088983023718012240528\\\n        683824553139343195888019854863909746543574579361265915812174560716242126991285521565613433\\\n        2466523138255580920562084028294, \\\n        103348981278117743347659685458024425851090003873328972353943876503642331864268476584622834\\\n        771804716540071910947628116585563492033622988994718273459748870409051443873813666778001704\\\n        443987702534839202423000943611973000165770624024091217695509335795498343407652970551134766\\\n        4434861083176910365144082745336, \\\n        510684705927052351679212082636107036464810921159437157458948509337412320407947949922554657\\\n        238580604776987667035866633761965104848956467866634135362496712791303540030856375498171483\\\n        831259576893709723741565585383647648004405829978866534704177730031770836216853668734789059\\\n        4588929931084078577444892255901]\",\n    );\n\n    get_striped_random_natural_with_up_to_bits_helper(10, 1, 0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_with_up_to_bits_helper(10, 1, 1, \"[0, 0, 0, 1, 0, 1, 0, 0, 0, 1]\");\n    get_striped_random_natural_with_up_to_bits_helper(\n        10,\n        1,\n        10,\n        \"[1016, 992, 1016, 255, 0, 1, 1020, 0, 1016, 1023]\",\n    );\n    get_striped_random_natural_with_up_to_bits_helper(\n        10,\n        1,\n        100,\n        \"[316912612278197474676665499640, 1109194416875305772521657204608, \\\n        14860115584411442377526345726, 1248153346840921551430087606303, \\\n        198065872776943853719234265088, 1267650600228229401359297740927, \\\n        950739156735808420047682273024, 638776758039873373851420326912, \\\n        9864985213488985894722518976, 37718485715515157557238824959]\",\n    );\n    get_striped_random_natural_with_up_to_bits_helper(\n        10,\n        1,\n        1000,\n        \"[6227021789445427263039113655730921918572951006503066538950149639959423752662851068863842\\\n        846174931899135470014771225146998068867182969950386903035779357388391986981527506826577962\\\n        959351510323326328854575809360361506384979516224625856987797041368114938422133105481271143\\\n        13802727213763684707371859960, \\\n        418149324987486545728941348682392045128729012336127607687109371117310119731075741621132811\\\n        712941491708845808992563601927247951850776072839137275117758244023796842459924562393751724\\\n        619611544927470362694941669661324507923822529817884467037192087699059800062580597484680330\\\n        40558838272520165980165373952, \\\n        101290238602722604813770149769557584827903636411333092403947212265322573720448584292412719\\\n        007546084038865810128075811761725057540901084282221804825717671524392231618089092521834579\\\n        302971634982176370935906367582384527889995332318295053733664142471797384264691816494972562\\\n        2408516333805710606334, \\\n        613140855310127563710847637107211483373522756531352582924325324369473352782306879549961499\\\n        829404362274878071222125070886882784952276431978326685623926423305714969567238612410647924\\\n        930743503806003239444825615154756542772421562094019613522428848711219387743538927178994800\\\n        765564734856735165291438079, \\\n        100656671761770967200809514408313411282491427879094391861152015262204431791194203727185921\\\n        026045038825035836776620646775627513583957795766207833861462739511509698818541011638004365\\\n        409989389341031372058994101918102834059849507520841606970888386863725907172131052360271284\\\n        55992101445905914436525739998208, \\\n        107149228544600635260212788419695526657434400429968676165634060825808436991969085650247279\\\n        650596133663598434482129668133099616635115467318010721467086518060004035373781135234642383\\\n        205702114144671525516391055691812453033688242812694582953965743513229924054172419365064495\\\n        42173396641692237011907449425727, \\\n        107150860693727448661794856915575585277857852731679120989819290845002348669070050613296455\\\n        734254692011706809018756806353158106462995138380031851002523766291502961737781576247555759\\\n        035185454502873048780305065230433793569807065690804749332353542464565681262222119583879742\\\n        48405282741635132994030678311166, \\\n        107150835221766756970390016554040088032382955997319930334779105385220088376881426554895494\\\n        540316762324972302835401791427607201669829855912974990784820455466307137336628823875387612\\\n        135057991945407277136587896193153151600433435164863822917290693842788118252951172684773421\\\n        70526384435574180443755489763328, \\\n        259458997502575090388504772996598528946724376087674101871067524134626069164625241231590514\\\n        153111280709253894067065950748627250265168604059093486305290952481954858209544512531987544\\\n        580061950939088894276064731362781063403971101745154263948986687899279303585684102284869355\\\n        693627487928044157407224, \\\n        127717813072756195965071628365863751639879810870737425013385130468804848982545562276364724\\\n        641904754943259319042883222370280844399168602997515222248629586365103060904858985377224746\\\n        007756101627928195178193946172906161993893729193567644459857171007317377644350722620326222\\\n        3742148978782762923552931827]\",\n    );\n\n    get_striped_random_natural_with_up_to_bits_helper(11, 10, 0, \"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\");\n    get_striped_random_natural_with_up_to_bits_helper(11, 10, 1, \"[0, 0, 0, 1, 0, 1, 0, 0, 0, 1]\");\n    get_striped_random_natural_with_up_to_bits_helper(\n        11,\n        10,\n        10,\n        \"[682, 842, 668, 341, 350, 341, 338, 340, 682, 341]\",\n    );\n    get_striped_random_natural_with_up_to_bits_helper(\n        11,\n        10,\n        100,\n        \"[1063803140432100403291953916586, 739462850133133817539732346028, \\\n        422653360565040988003415446874, 848401573590247656481079600469, \\\n        422550200075885064135585999530, 419242579033418664700359912277, \\\n        422556546887486595830538392914, 422551811989467209878519567698, \\\n        422550300869175806062669146794, 845074597043259864052961293645]\",\n    );\n    get_striped_random_natural_with_up_to_bits_helper(\n        11,\n        10,\n        1000,\n        \"[3571694931298766658148597579133500396805055718890904755849421801691105675639698924085475\\\n        217186818671377861364341116537204961881442236045088337279057826912458138650691199761612988\\\n        883058581411133147888461600627501281537742872135974381226302429036852682145804929027180283\\\n        412215635242948169473448721083050, \\\n        312523503440022226256539017547297068869208682155149110042905762496761319540243094457594343\\\n        859089236690554960456013552907255074371626319073357480048727266774116430788333390913446465\\\n        619104644972187472443285017414346567664962457858577864857410322417792561934834339345113775\\\n        9657317068961411710233409661610, \\\n        865019756446950496269040354104481059118747029066357336244807909203888902108435832283590666\\\n        775170346004501865878924553107381908132495592609080661684475732927817570636420740556716013\\\n        168924877758128333222159346949341194770681937489066179441860633805186064044811420594280896\\\n        906074342076344282184605324666, \\\n        893011037585013007271439602956526972024707806627477311937832595287305307343362049808812372\\\n        867697432889627779970803417048478482882370003668394928455851950345620310470241544275541047\\\n        354242013397873563064543296718018003131524951605807454956556860189105716328731797732674596\\\n        4570601733436095071743763633493, \\\n        714337697986576114077307239016734314472779437227875536493177724277496357242071140467095878\\\n        368847036684840951410204114568419486398409897184525378525275704002748768137539106304824083\\\n        362036096433222952552023855753638427465829477635653011302870027782444701974201225532101310\\\n        2549204865443174861708377533098, \\\n        717129479744396200344184597459955775324063665344347322215427784911546292557185067124997476\\\n        300110608871594211005211148242437189627028361260715625731282067311558916993444457603008618\\\n        146383526538195175746094394556394170673628321139601154519945289775172095900192878319082649\\\n        5453320605634381639129320740181, \\\n        712943875305246933549449117163766092515737565613814773068912395757448666817082911895780847\\\n        326837660502284270497684787917665238088905925731656976408461765235806743263267139181463148\\\n        004431439157535144190810911719314309577264591245575456701925751321667869578190443322813012\\\n        0138648732293712628634064954698, \\\n        892880942227156526968373917452622274287516410008666161523034951090805186930790904719943631\\\n        023279485226392520031870194759074725254789440380488049235603947036487803727696933564597255\\\n        812777037968411285945062427246430458697274335300861633278805179074880855146539152265137509\\\n        2760519788829492124624878217898, \\\n        357191338288297448157760779693006292584925495383947130217069796802263562301019332603664015\\\n        518999932844210923242642143426207768942951692715733850908225274836460166873351326253496823\\\n        316044766823056126756948620431307852877994605207198329719827145721619069940836945855738629\\\n        5164803095064098046522145712854, \\\n        712949327932932700218621033804526985196291897563252301818755627637478824989877935042325873\\\n        291167136650626866176302303072095225803612799473142905508378017958979111144644566257625076\\\n        950893722575069628745776862688326045350363911106097574031678159885821711577125514250680212\\\n        9840859041388985930050461586805]\",\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/random_natural_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::random_natural_inclusive_range;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn random_natural_inclusive_range_helper(\n    a: &str,\n    b: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        random_natural_inclusive_range(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            Natural::from_str(b).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_natural_inclusive_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_natural_inclusive_range_helper(\n        \"0\",\n        \"0\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"14\", \"8\", \"10\", \"1\", \"1\", \"0\", \"1\", \"0\", \"8\", \"66\", \"1\", \"3\", \"2\", \"5\", \"1\", \"6\", \"1\",\n        \"2\", \"14\", \"1\",\n    ];\n    let common_values = &[\n        (\"0\", 240959),\n        (\"1\", 191819),\n        (\"2\", 76868),\n        (\"3\", 76523),\n        (\"7\", 30894),\n        (\"6\", 30881),\n        (\"4\", 30635),\n        (\"5\", 30631),\n        (\"14\", 12472),\n        (\"15\", 12457),\n    ];\n    let sample_median = (\"2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(11.335956999999699),\n        standard_deviation: NiceFloat(20.565945026967327),\n        skewness: NiceFloat(2.486687831499969),\n        excess_kurtosis: NiceFloat(5.6402145781222615),\n    };\n    random_natural_inclusive_range_helper(\n        \"0\",\n        \"99\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"14\", \"1\", \"1\", \"4\", \"6\", \"1\", \"6\", \"66\", \"10\", \"2\", \"4\", \"1\", \"7\", \"7\", \"2\", \"17\", \"3\",\n        \"2\", \"2\", \"97\",\n    ];\n    let common_values = &[\n        (\"1\", 288484),\n        (\"3\", 108475),\n        (\"2\", 108256),\n        (\"7\", 40848),\n        (\"5\", 40475),\n        (\"4\", 40324),\n        (\"6\", 40213),\n        (\"12\", 15378),\n        (\"14\", 15279),\n        (\"8\", 15268),\n    ];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(12.712097999999987),\n        standard_deviation: NiceFloat(20.543779459614104),\n        skewness: NiceFloat(2.4002783415844497),\n        excess_kurtosis: NiceFloat(5.233152563653805),\n    };\n    random_natural_inclusive_range_helper(\n        \"1\",\n        \"99\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1987\", \"1993\", \"1907\", \"1984\", \"1927\", \"1946\", \"1993\", \"1922\", \"1986\", \"1901\", \"1907\",\n        \"1929\", \"1925\", \"1956\", \"1997\", \"1938\", \"1970\", \"1906\", \"1955\", \"1929\",\n    ];\n    let common_values = &[\n        (\"1945\", 10146),\n        (\"1987\", 10096),\n        (\"1991\", 10094),\n        (\"1982\", 10056),\n        (\"1900\", 10042),\n        (\"1973\", 10033),\n        (\"1959\", 10029),\n        (\"1967\", 10026),\n        (\"1974\", 10024),\n        (\"1946\", 10023),\n    ];\n    let sample_median = (\"1950\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1949.98699899998),\n        standard_deviation: NiceFloat(29.18007161489914),\n        skewness: NiceFloat(0.000791345316435403),\n        excess_kurtosis: NiceFloat(-1.2020606886458867),\n    };\n    random_natural_inclusive_range_helper(\n        \"1900\",\n        \"2000\",\n        11,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1206\",\n        \"2200\",\n        \"32434\",\n        \"2526\",\n        \"428799138\",\n        \"12119996\",\n        \"2744\",\n        \"2065487\",\n        \"5283\",\n        \"105634\",\n        \"63523217\",\n        \"18250435\",\n        \"42716754\",\n        \"7992\",\n        \"1720\",\n        \"481774\",\n        \"7143\",\n        \"2445\",\n        \"6806\",\n        \"297908430\",\n    ];\n    let common_values = &[\n        (\"1022\", 3070),\n        (\"1006\", 3057),\n        (\"1001\", 3047),\n        (\"1014\", 3040),\n        (\"1020\", 3038),\n        (\"1003\", 3015),\n        (\"1010\", 3010),\n        (\"1012\", 3008),\n        (\"1018\", 3008),\n        (\"1008\", 3000),\n    ];\n    let sample_median = (\"148810\", Some(\"148811\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(48716724.95089779),\n        standard_deviation: NiceFloat(150453248.85048282),\n        skewness: NiceFloat(4.049374838772574),\n        excess_kurtosis: NiceFloat(17.011313559369025),\n    };\n    random_natural_inclusive_range_helper(\n        \"1000\",\n        \"999999999\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_inclusive_range_fail_1() {\n    random_natural_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_inclusive_range_fail_2() {\n    random_natural_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        4,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_inclusive_range_fail_3() {\n    random_natural_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(9u32),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/random_natural_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::random_natural_range;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn random_natural_range_helper(\n    a: &str,\n    b: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        random_natural_range(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            Natural::from_str(b).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_natural_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_natural_range_helper(\n        \"0\",\n        \"1\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"14\", \"8\", \"10\", \"1\", \"1\", \"0\", \"1\", \"0\", \"8\", \"66\", \"1\", \"3\", \"2\", \"5\", \"1\", \"6\", \"1\",\n        \"2\", \"14\", \"1\",\n    ];\n    let common_values = &[\n        (\"0\", 240959),\n        (\"1\", 191819),\n        (\"2\", 76868),\n        (\"3\", 76523),\n        (\"7\", 30894),\n        (\"6\", 30881),\n        (\"4\", 30635),\n        (\"5\", 30631),\n        (\"14\", 12472),\n        (\"15\", 12457),\n    ];\n    let sample_median = (\"2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(11.335956999999699),\n        standard_deviation: NiceFloat(20.565945026967327),\n        skewness: NiceFloat(2.486687831499969),\n        excess_kurtosis: NiceFloat(5.6402145781222615),\n    };\n    random_natural_range_helper(\n        \"0\",\n        \"100\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"14\", \"1\", \"1\", \"4\", \"6\", \"1\", \"6\", \"66\", \"10\", \"2\", \"4\", \"1\", \"7\", \"7\", \"2\", \"17\", \"3\",\n        \"2\", \"2\", \"97\",\n    ];\n    let common_values = &[\n        (\"1\", 288484),\n        (\"3\", 108475),\n        (\"2\", 108256),\n        (\"7\", 40848),\n        (\"5\", 40475),\n        (\"4\", 40324),\n        (\"6\", 40213),\n        (\"12\", 15378),\n        (\"14\", 15279),\n        (\"8\", 15268),\n    ];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(12.712097999999987),\n        standard_deviation: NiceFloat(20.543779459614104),\n        skewness: NiceFloat(2.4002783415844497),\n        excess_kurtosis: NiceFloat(5.233152563653805),\n    };\n    random_natural_range_helper(\n        \"1\",\n        \"100\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1987\", \"1993\", \"1907\", \"1984\", \"1927\", \"1946\", \"1993\", \"1922\", \"1986\", \"1901\", \"1907\",\n        \"1929\", \"1925\", \"1956\", \"1997\", \"1938\", \"1970\", \"1906\", \"1955\", \"1929\",\n    ];\n    let common_values = &[\n        (\"1945\", 10146),\n        (\"1987\", 10096),\n        (\"1991\", 10094),\n        (\"1982\", 10056),\n        (\"1900\", 10042),\n        (\"1973\", 10033),\n        (\"1959\", 10029),\n        (\"1967\", 10026),\n        (\"1974\", 10024),\n        (\"1946\", 10023),\n    ];\n    let sample_median = (\"1950\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1949.98699899998),\n        standard_deviation: NiceFloat(29.18007161489914),\n        skewness: NiceFloat(0.000791345316435403),\n        excess_kurtosis: NiceFloat(-1.2020606886458867),\n    };\n    random_natural_range_helper(\n        \"1900\",\n        \"2001\",\n        11,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1206\",\n        \"2200\",\n        \"32434\",\n        \"2526\",\n        \"428799138\",\n        \"12119996\",\n        \"2744\",\n        \"2065487\",\n        \"5283\",\n        \"105634\",\n        \"63523217\",\n        \"18250435\",\n        \"42716754\",\n        \"7992\",\n        \"1720\",\n        \"481774\",\n        \"7143\",\n        \"2445\",\n        \"6806\",\n        \"297908430\",\n    ];\n    let common_values = &[\n        (\"1022\", 3070),\n        (\"1006\", 3057),\n        (\"1001\", 3047),\n        (\"1014\", 3040),\n        (\"1020\", 3038),\n        (\"1003\", 3015),\n        (\"1010\", 3010),\n        (\"1012\", 3008),\n        (\"1018\", 3008),\n        (\"1008\", 3000),\n    ];\n    let sample_median = (\"148810\", Some(\"148811\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(48716724.95089779),\n        standard_deviation: NiceFloat(150453248.85048282),\n        skewness: NiceFloat(4.049374838772574),\n        excess_kurtosis: NiceFloat(17.011313559369025),\n    };\n    random_natural_range_helper(\n        \"1000\",\n        \"1000000000\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_range_fail_1() {\n    random_natural_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_range_fail_2() {\n    random_natural_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        4,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_range_fail_3() {\n    random_natural_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(9u32),\n        10,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_range_fail_4() {\n    random_natural_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(10u32),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/random_natural_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::random_natural_range_to_infinity;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn random_natural_range_to_infinity_helper(\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        random_natural_range_to_infinity(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_natural_range_to_infinity() {\n    let values = &[\n        \"0\", \"14\", \"0\", \"8\", \"2\", \"6\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 500248),\n        (\"1\", 249491),\n        (\"2\", 62676),\n        (\"3\", 62465),\n        (\"7\", 15819),\n        (\"5\", 15781),\n        (\"6\", 15694),\n        (\"4\", 15518),\n        (\"13\", 3945),\n        (\"8\", 3895),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.289019000000012),\n        standard_deviation: NiceFloat(811.503067487901),\n        skewness: NiceFloat(791.581366511165),\n        excess_kurtosis: NiceFloat(717047.0759703598),\n    };\n    random_natural_range_to_infinity_helper(\n        \"0\",\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"20431208470830262\",\n        \"2777240\",\n        \"114\",\n        \"12184833305054\",\n        \"1121025855008623490210\",\n        \"13478874522577592\",\n        \"115311695\",\n        \"7\",\n        \"18\",\n        \"54522366353\",\n        \"2183264193236231773387459\",\n        \"824\",\n        \"18558864232439549193912\",\n        \"15\",\n        \"110989\",\n        \"453270\",\n        \"4307150\",\n        \"45388024541\",\n        \"47\",\n        \"3345913274\",\n    ];\n    let common_values = &[\n        (\"0\", 30467),\n        (\"1\", 29379),\n        (\"3\", 14233),\n        (\"2\", 14194),\n        (\"7\", 6984),\n        (\"6\", 6980),\n        (\"4\", 6964),\n        (\"5\", 6929),\n        (\"10\", 3479),\n        (\"15\", 3431),\n    ];\n    let sample_median = (\"3201388\", Some(\"3201522\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.480305129633914e129),\n        standard_deviation: NiceFloat(2.4803051296331898e132),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_natural_range_to_infinity_helper(\n        \"0\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"11\", \"182\", \"12\", \"152\", \"50\", \"94\", \"18\", \"11\", \"13\", \"15\", \"14\", \"13\", \"28\", \"24\", \"13\",\n        \"13\", \"31\", \"19\", \"12\", \"13\",\n    ];\n    let common_values = &[\n        (\"13\", 83637),\n        (\"11\", 83622),\n        (\"15\", 83440),\n        (\"14\", 83364),\n        (\"10\", 83305),\n        (\"12\", 82880),\n        (\"20\", 15837),\n        (\"31\", 15785),\n        (\"19\", 15779),\n        (\"18\", 15776),\n    ];\n    let sample_median = (\"15\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(128.81076899999977),\n        standard_deviation: NiceFloat(15255.606035258177),\n        skewness: NiceFloat(845.8189997295934),\n        excess_kurtosis: NiceFloat(789803.2243471228),\n    };\n    random_natural_range_to_infinity_helper(\n        \"10\",\n        5,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"118\",\n        \"56\",\n        \"1714\",\n        \"55845661150\",\n        \"93254818\",\n        \"822568088563644\",\n        \"120\",\n        \"871591019599\",\n        \"99\",\n        \"1171796531603249384284396706\",\n        \"3570371\",\n        \"76271186\",\n        \"69092967935443594634663005648041578296\",\n        \"110\",\n        \"39\",\n        \"25543539470733\",\n        \"317538101910\",\n        \"206\",\n        \"14906804826461850333\",\n        \"95450125556931311\",\n    ];\n    let common_values = &[\n        (\"13\", 5882),\n        (\"14\", 5840),\n        (\"12\", 5734),\n        (\"15\", 5645),\n        (\"11\", 5644),\n        (\"10\", 5642),\n        (\"18\", 2148),\n        (\"27\", 2143),\n        (\"19\", 2134),\n        (\"23\", 2134),\n    ];\n    let sample_median = (\"7289020\", Some(\"7289286\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.8276128186777812e120),\n        standard_deviation: NiceFloat(1.8276117282901724e123),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_natural_range_to_infinity_helper(\n        \"10\",\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1032867295426\",\n        \"15476566285494\",\n        \"1005058503561\",\n        \"11872468885656\",\n        \"3085108281010\",\n        \"7786786793950\",\n        \"1848070042786\",\n        \"1008384510771\",\n        \"1035939113223\",\n        \"1034091049134\",\n        \"1097997002237\",\n        \"1066780473347\",\n        \"1232902614972\",\n        \"2160500927160\",\n        \"1039676158979\",\n        \"1075044604283\",\n        \"1421346833487\",\n        \"2100488049827\",\n        \"1090935342918\",\n        \"1033099299962\",\n    ];\n    let common_values = &[\n        (\"1012318490312\", 2),\n        (\"1020804407546\", 2),\n        (\"1040579317197\", 2),\n        (\"1041361099759\", 2),\n        (\"1099357770481\", 2),\n        (\"1000000358874\", 1),\n        (\"1000000635467\", 1),\n        (\"1000000743391\", 1),\n        (\"1000001041678\", 1),\n        (\"1000001124568\", 1),\n    ];\n    let sample_median = (\"1099468717392\", Some(\"1099468761569\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(9002084314682.418),\n        standard_deviation: NiceFloat(1175305974058995.2),\n        skewness: NiceFloat(894.6662459454856),\n        excess_kurtosis: NiceFloat(856946.924578041),\n    };\n    random_natural_range_to_infinity_helper(\n        \"1000000000000\",\n        41,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2282426752182\",\n        \"3076375863448\",\n        \"33871433858738\",\n        \"193926771358011304414\",\n        \"683117911635193788\",\n        \"95918191752968866622136\",\n        \"5399022933155\",\n        \"2679643424229893512354\",\n        \"7585953905347\",\n        \"17738519421136481929559726434799186\",\n        \"70600001019637432\",\n        \"77299482847566318\",\n        \"332646018266965594347466935183659688140188647\",\n        \"4856563742926\",\n        \"1110539913949\",\n        \"8169120771017371179759\",\n        \"142409202767618812372\",\n        \"3612730358681\",\n        \"468787385712310874935747551\",\n        \"9607440468294695468459788\",\n    ];\n    let common_values = &[\n        (\"1000006091267\", 1),\n        (\"1000006483280\", 1),\n        (\"1000008421992\", 1),\n        (\"1000009071089\", 1),\n        (\"1000011436758\", 1),\n        (\"1000013492649\", 1),\n        (\"1000014387323\", 1),\n        (\"1000020641917\", 1),\n        (\"1000020859147\", 1),\n        (\"1000020971497\", 1),\n    ];\n    let sample_median = (\"70366472614875784\", Some(\"70368772587252716\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0984547559553134e113),\n        standard_deviation: NiceFloat(1.098369190533207e116),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_natural_range_to_infinity_helper(\n        \"1000000000000\",\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_natural_range_to_infinity_fail_1() {\n    random_natural_range_to_infinity(EXAMPLE_SEED, Natural::from(10u32), 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_natural_range_to_infinity_fail_2() {\n    random_natural_range_to_infinity(EXAMPLE_SEED, Natural::from(10u32), 4, 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/random_naturals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::random::random_naturals;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\n\nfn random_naturals_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        random_naturals(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_naturals() {\n    // mean bits = 1/64\n    let values = &[\"0\"; 20];\n    let common_values = &[\n        (\"0\", 984681),\n        (\"1\", 15077),\n        (\"2\", 121),\n        (\"3\", 116),\n        (\"6\", 2),\n        (\"4\", 1),\n        (\"5\", 1),\n        (\"7\", 1),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.015695000000000257),\n        standard_deviation: NiceFloat(0.12853281096935348),\n        skewness: NiceFloat(9.11690327111834),\n        excess_kurtosis: NiceFloat(110.73931175909136),\n    };\n    random_naturals_helper(\n        1,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 1\n    let values = &[\n        \"0\", \"14\", \"0\", \"8\", \"2\", \"6\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 500248),\n        (\"1\", 249491),\n        (\"2\", 62676),\n        (\"3\", 62465),\n        (\"7\", 15819),\n        (\"5\", 15781),\n        (\"6\", 15694),\n        (\"4\", 15518),\n        (\"13\", 3945),\n        (\"8\", 3895),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.289019000000012),\n        standard_deviation: NiceFloat(811.503067487901),\n        skewness: NiceFloat(791.581366511165),\n        excess_kurtosis: NiceFloat(717047.0759703598),\n    };\n    random_naturals_helper(\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"20431208470830262\",\n        \"2777240\",\n        \"114\",\n        \"12184833305054\",\n        \"1121025855008623490210\",\n        \"13478874522577592\",\n        \"115311695\",\n        \"7\",\n        \"18\",\n        \"54522366353\",\n        \"2183264193236231773387459\",\n        \"824\",\n        \"18558864232439549193912\",\n        \"15\",\n        \"110989\",\n        \"453270\",\n        \"4307150\",\n        \"45388024541\",\n        \"47\",\n        \"3345913274\",\n    ];\n    let common_values = &[\n        (\"0\", 30467),\n        (\"1\", 29379),\n        (\"3\", 14233),\n        (\"2\", 14194),\n        (\"7\", 6984),\n        (\"6\", 6980),\n        (\"4\", 6964),\n        (\"5\", 6929),\n        (\"10\", 3479),\n        (\"15\", 3431),\n    ];\n    let sample_median = (\"3201388\", Some(\"3201522\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.480305129633914e129),\n        standard_deviation: NiceFloat(2.4803051296331898e132),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_naturals_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1049807948069596877906281043152861735368289016372406\",\n        \"1388880088667859422\",\n        \"26145954\",\n        \"3731388\",\n        \"1470862095575962348216\",\n        \"99\",\n        \"1\",\n        \"835275153\",\n        \"3892061391890507266755\",\n        \"925334710331614885833504493368\",\n        \"221414670923422190\",\n        \"11239\",\n        \"254772031885\",\n        \"1351005164080654998\",\n        \"9136414433496904064275246960259217614\",\n        \"1775\",\n        \"5562\",\n        \"8137327159764\",\n        \"19744859531291384657393101375027010425831988999\",\n        \"2078424122508695\",\n    ];\n    let common_values = &[\n        (\"0\", 15386),\n        (\"1\", 15062),\n        (\"2\", 7592),\n        (\"3\", 7459),\n        (\"4\", 3719),\n        (\"5\", 3707),\n        (\"6\", 3685),\n        (\"7\", 3508),\n        (\"12\", 1906),\n        (\"11\", 1865),\n    ];\n    let sample_median = (\"15157534309527\", Some(\"15157859817105\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.8099447055615434e263),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_naturals_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_naturals_fail_1() {\n    random_naturals(EXAMPLE_SEED, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn random_naturals_fail_2() {\n    random_naturals(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_naturals_fail_3() {\n    random_naturals(EXAMPLE_SEED, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/random_naturals_less_than.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::random_naturals_less_than;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn random_naturals_less_than_helper(\n    limit: &str,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        random_naturals_less_than(EXAMPLE_SEED, Natural::from_str(limit).unwrap()),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_naturals_less_than() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_naturals_less_than_helper(\n        \"1\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1\", \"7\", \"13\", \"5\", \"7\", \"9\", \"2\", \"8\", \"2\", \"11\", \"4\", \"11\", \"14\", \"13\", \"6\", \"6\", \"11\",\n        \"1\", \"3\", \"7\",\n    ];\n    let common_values = &[\n        (\"10\", 67077),\n        (\"7\", 67071),\n        (\"2\", 66902),\n        (\"6\", 66802),\n        (\"3\", 66769),\n        (\"9\", 66740),\n        (\"11\", 66724),\n        (\"14\", 66705),\n        (\"0\", 66612),\n        (\"13\", 66590),\n    ];\n    let sample_median = (\"7\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.002550000000202),\n        standard_deviation: NiceFloat(4.318291113986895),\n        skewness: NiceFloat(-0.0008733138647064903),\n        excess_kurtosis: NiceFloat(-1.209254148711494),\n    };\n    random_naturals_less_than_helper(\n        \"15\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1\", \"7\", \"13\", \"5\", \"7\", \"9\", \"2\", \"8\", \"2\", \"11\", \"4\", \"11\", \"14\", \"13\", \"6\", \"6\", \"11\",\n        \"1\", \"3\", \"7\",\n    ];\n    let common_values = &[\n        (\"10\", 62902),\n        (\"2\", 62837),\n        (\"7\", 62827),\n        (\"3\", 62676),\n        (\"11\", 62617),\n        (\"6\", 62613),\n        (\"14\", 62607),\n        (\"9\", 62606),\n        (\"8\", 62510),\n        (\"0\", 62466),\n    ];\n    let sample_median = (\"8\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.499876999999703),\n        standard_deviation: NiceFloat(4.606495327759524),\n        skewness: NiceFloat(-0.0003936178035348645),\n        excess_kurtosis: NiceFloat(-1.207854285765452),\n    };\n    random_naturals_less_than_helper(\n        \"16\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"7\", \"9\", \"8\", \"11\", \"14\", \"11\", \"1\", \"7\", \"1\", \"6\", \"6\", \"6\", \"7\", \"5\", \"12\", \"7\", \"15\",\n        \"7\", \"7\", \"5\",\n    ];\n    let common_values = &[\n        (\"13\", 59283),\n        (\"10\", 59171),\n        (\"3\", 59142),\n        (\"6\", 59131),\n        (\"16\", 59052),\n        (\"0\", 58906),\n        (\"9\", 58849),\n        (\"14\", 58816),\n        (\"2\", 58806),\n        (\"7\", 58744),\n    ];\n    let sample_median = (\"8\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.003521000000225),\n        standard_deviation: NiceFloat(4.899161622598552),\n        skewness: NiceFloat(-0.0010892026016323982),\n        excess_kurtosis: NiceFloat(-1.20819299609532),\n    };\n    random_naturals_less_than_helper(\n        \"17\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"388977\", \"925783\", \"378973\", \"75271\", \"945129\", \"765554\", \"271720\", \"260338\", \"21995\",\n        \"458836\", \"661659\", \"310190\", \"396637\", \"576534\", \"304342\", \"557803\", \"678529\", \"654451\",\n        \"280711\", \"928029\",\n    ];\n    let common_values = &[\n        (\"429869\", 9),\n        (\"568287\", 9),\n        (\"771880\", 9),\n        (\"890\", 8),\n        (\"18201\", 8),\n        (\"61885\", 8),\n        (\"163140\", 8),\n        (\"173104\", 8),\n        (\"214281\", 8),\n        (\"340935\", 8),\n    ];\n    let sample_median = (\"500024\", Some(\"500026\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(500269.9304960077),\n        standard_deviation: NiceFloat(288405.96360756975),\n        skewness: NiceFloat(-0.0010400381943526848),\n        excess_kurtosis: NiceFloat(-1.1981474275491453),\n    };\n    random_naturals_less_than_helper(\n        \"1000000\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"3233271796909041147200401960861496742517\",\n        \"6217357404646018754599684571795784707698\",\n        \"9438016902699487422458396847802670929387\",\n        \"7727353449345949782973180362335717735342\",\n        \"534354137356207625017431174589301695702\",\n        \"534877532602868824396077953846378055833\",\n        \"2066581267912983630335063637372720045094\",\n        \"1831715414082884162869589340142899207735\",\n        \"2619564100767325027279529873701213301661\",\n        \"6005405409180901613675532713129270331479\",\n        \"8271966495851265353624356439908105167895\",\n        \"2537046382263430904899281307939508702471\",\n        \"7202939407624515890221097211474505126578\",\n        \"5142762353061547853401995252125996224683\",\n        \"1027218951536793906738056738325216303009\",\n        \"9914727392521646960300300265785426013882\",\n        \"1459386323443095819796283591928997970915\",\n        \"5477318216232641272279240890043646394779\",\n        \"6387837972601141117504319208136943264497\",\n        \"5474635405681155657679090532822557929038\",\n    ];\n    let common_values = &[\n        (\"8768725511813114574712047169606198\", 1),\n        (\"9827974885359877076313510726004983\", 1),\n        (\"12488944552955502737286653696783298\", 1),\n        (\"22890668287803601945090476573028348\", 1),\n        (\"24602492188456115932292147454123699\", 1),\n        (\"32710913204967376519858724740864044\", 1),\n        (\"36222387069235523377031863703777427\", 1),\n        (\"49953398642815549142118724082696119\", 1),\n        (\"51712706399518805574773981541840520\", 1),\n        (\"58535354783119341230390576092841062\", 1),\n    ];\n    let sample_median = (\n        \"5001510563009032264934634274159139768440\",\n        Some(\"5001521540293100102818635713617625902813\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.001250475448614e39),\n        standard_deviation: NiceFloat(2.887524153222133e39),\n        skewness: NiceFloat(-0.0006935347805930534),\n        excess_kurtosis: NiceFloat(-1.2008620906428813),\n    };\n    random_naturals_less_than_helper(\n        \"10000000000000000000000000000000000000000\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_naturals_less_than_fail() {\n    random_naturals_less_than(EXAMPLE_SEED, Natural::ZERO);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/random_positive_naturals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::random::random_positive_naturals;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\n\nfn random_positive_naturals_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        random_positive_naturals(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_naturals() {\n    // mean bits = 65/64\n    let values = &[\"1\"; 20];\n    let common_values = &[\n        (\"1\", 984681),\n        (\"3\", 7622),\n        (\"2\", 7455),\n        (\"5\", 73),\n        (\"6\", 66),\n        (\"7\", 54),\n        (\"4\", 44),\n        (\"8\", 2),\n        (\"10\", 2),\n        (\"14\", 1),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.023822000000005),\n        standard_deviation: NiceFloat(0.20727410662829246),\n        skewness: NiceFloat(10.72004433095801),\n        excess_kurtosis: NiceFloat(159.60627558337237),\n    };\n    random_positive_naturals_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"1\", \"24\", \"1\", \"30\", \"6\", \"12\", \"2\", \"1\", \"1\", \"1\", \"1\", \"1\", \"2\", \"2\", \"1\", \"1\", \"3\",\n        \"3\", \"1\", \"1\",\n    ];\n    let common_values = &[\n        (\"1\", 500248),\n        (\"3\", 124972),\n        (\"2\", 124519),\n        (\"7\", 31554),\n        (\"5\", 31346),\n        (\"6\", 31198),\n        (\"4\", 31043),\n        (\"12\", 8033),\n        (\"11\", 7959),\n        (\"10\", 7935),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(15.68562000000007),\n        standard_deviation: NiceFloat(2088.3045530403606),\n        skewness: NiceFloat(877.2889258611025),\n        excess_kurtosis: NiceFloat(832799.3689336807),\n    };\n    random_positive_naturals_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"22\",\n        \"4\",\n        \"178\",\n        \"55845661150\",\n        \"93254818\",\n        \"7577967529619388\",\n        \"8\",\n        \"11316951483471\",\n        \"11\",\n        \"1005760138411689342464923704482\",\n        \"948931\",\n        \"42716754\",\n        \"81013760999253680590984897748479904878392\",\n        \"23\",\n        \"5\",\n        \"488225822927510\",\n        \"1558028859598\",\n        \"29\",\n        \"200127331174844881647\",\n        \"4058622214797175252\",\n    ];\n    let common_values = &[\n        (\"1\", 31094),\n        (\"2\", 15260),\n        (\"3\", 15185),\n        (\"4\", 7586),\n        (\"5\", 7376),\n        (\"7\", 7346),\n        (\"6\", 7258),\n        (\"10\", 3631),\n        (\"14\", 3607),\n        (\"11\", 3605),\n    ];\n    let sample_median = (\"3799061\", Some(\"3799067\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.312362311300544e130),\n        standard_deviation: NiceFloat(2.3122865276852406e133),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_naturals_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1030304779202860497815440824491190\",\n        \"886085025458\",\n        \"207326\",\n        \"83590267817164982586207812646050\",\n        \"142592182196136038718074156629812683467448\",\n        \"486577913627642327503939268330036386\",\n        \"5557920650918595\",\n        \"82\",\n        \"3896\",\n        \"259694111319673990840\",\n        \"38511521798151392412656616617957654586378660839\",\n        \"637134\",\n        \"2330568192653124764618470467652346596061\",\n        \"2516\",\n        \"512663303\",\n        \"39317568409\",\n        \"18536901993439\",\n        \"4959577657266999117207\",\n        \"628\",\n        \"42485719907732979\",\n    ];\n    let common_values = &[\n        (\"1\", 15720),\n        (\"2\", 7718),\n        (\"3\", 7584),\n        (\"6\", 3790),\n        (\"4\", 3739),\n        (\"7\", 3704),\n        (\"5\", 3673),\n        (\"9\", 1918),\n        (\"11\", 1916),\n        (\"10\", 1904),\n    ];\n    let sample_median = (\"18436851140261\", Some(\"18438360920148\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.519478531998525e283),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_naturals_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_positive_naturals_fail_1() {\n    random_positive_naturals(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_naturals_fail_2() {\n    random_positive_naturals(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/striped_random_natural_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::striped_random_natural_inclusive_range;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_natural_inclusive_range_helper(\n    a: &str,\n    b: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        striped_random_natural_inclusive_range(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            Natural::from_str(b).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_natural_inclusive_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_natural_inclusive_range_helper(\n        \"0\",\n        \"0\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1990\", \"1991\", \"1991\", \"2006\", \"1996\", \"1991\", \"2020\", \"1991\", \"1990\", \"2014\", \"1990\",\n        \"2020\", \"1991\", \"1990\", \"2020\", \"1991\", \"2015\", \"2020\", \"2016\", \"2016\",\n    ];\n    let common_values = &[\n        (\"1990\", 141061),\n        (\"1991\", 140282),\n        (\"2016\", 140025),\n        (\"2021\", 125104),\n        (\"2020\", 124770),\n        (\"2017\", 47126),\n        (\"2019\", 46880),\n        (\"1999\", 39864),\n        (\"2015\", 39502),\n        (\"2018\", 15866),\n    ];\n    let sample_median = (\"2015\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2007.63283599996),\n        standard_deviation: NiceFloat(12.714969927906306),\n        skewness: NiceFloat(-0.39110989081904446),\n        excess_kurtosis: NiceFloat(-1.6497443674417989),\n    };\n    striped_random_natural_inclusive_range_helper(\n        \"1990\",\n        \"2021\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1000425\", \"1036272\", \"1007600\", \"1999887\", \"1018367\", \"1000191\", \"1048387\", \"1049087\",\n        \"1007631\", \"1015792\", \"1971832\", \"1046770\", \"1023876\", \"1966085\", \"1838648\", \"1017728\",\n        \"1046662\", \"1998848\", \"1613817\", \"1982463\",\n    ];\n    let common_values = &[\n        (\"2000000\", 26405),\n        (\"1999872\", 3441),\n        (\"1048575\", 3413),\n        (\"1015807\", 3052),\n        (\"1998848\", 2966),\n        (\"1000447\", 2758),\n        (\"1000063\", 2381),\n        (\"1000000\", 2380),\n        (\"1966080\", 1441),\n        (\"1999935\", 1251),\n    ];\n    let sample_median = (\"1048576\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1371348.0426910813),\n        standard_deviation: NiceFloat(417874.3987798391),\n        skewness: NiceFloat(0.5348808065018619),\n        excess_kurtosis: NiceFloat(-1.5362497902865004),\n    };\n    striped_random_natural_inclusive_range_helper(\n        \"1000000\",\n        \"2000000\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_inclusive_range_fail_1() {\n    striped_random_natural_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_inclusive_range_fail_2() {\n    striped_random_natural_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_inclusive_range_fail_3() {\n    striped_random_natural_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(9u32),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/striped_random_natural_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::striped_random_natural_range;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_natural_range_helper(\n    a: &str,\n    b: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        striped_random_natural_range(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            Natural::from_str(b).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_natural_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_natural_range_helper(\n        \"0\",\n        \"1\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1990\", \"1991\", \"1991\", \"2006\", \"1996\", \"1991\", \"2020\", \"1991\", \"1990\", \"2014\", \"1990\",\n        \"2020\", \"1991\", \"1990\", \"2020\", \"1991\", \"2015\", \"2020\", \"2016\", \"2016\",\n    ];\n    let common_values = &[\n        (\"1990\", 141061),\n        (\"1991\", 140282),\n        (\"2016\", 140025),\n        (\"2021\", 125104),\n        (\"2020\", 124770),\n        (\"2017\", 47126),\n        (\"2019\", 46880),\n        (\"1999\", 39864),\n        (\"2015\", 39502),\n        (\"2018\", 15866),\n    ];\n    let sample_median = (\"2015\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2007.63283599996),\n        standard_deviation: NiceFloat(12.714969927906306),\n        skewness: NiceFloat(-0.39110989081904446),\n        excess_kurtosis: NiceFloat(-1.6497443674417989),\n    };\n    striped_random_natural_range_helper(\n        \"1990\",\n        \"2022\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1000425\", \"1036272\", \"1007600\", \"1999887\", \"1018367\", \"1000191\", \"1048387\", \"1049087\",\n        \"1007631\", \"1015792\", \"1971832\", \"1046770\", \"1023876\", \"1966085\", \"1838648\", \"1017728\",\n        \"1046662\", \"1998848\", \"1613817\", \"1982463\",\n    ];\n    let common_values = &[\n        (\"2000000\", 26405),\n        (\"1999872\", 3441),\n        (\"1048575\", 3413),\n        (\"1015807\", 3052),\n        (\"1998848\", 2966),\n        (\"1000447\", 2758),\n        (\"1000063\", 2381),\n        (\"1000000\", 2380),\n        (\"1966080\", 1441),\n        (\"1999935\", 1251),\n    ];\n    let sample_median = (\"1048576\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1371348.0426910813),\n        standard_deviation: NiceFloat(417874.3987798391),\n        skewness: NiceFloat(0.5348808065018619),\n        excess_kurtosis: NiceFloat(-1.5362497902865004),\n    };\n    striped_random_natural_range_helper(\n        \"1000000\",\n        \"2000001\",\n        4,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_range_fail_1() {\n    striped_random_natural_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_range_fail_2() {\n    striped_random_natural_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(100u32),\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_range_fail_3() {\n    striped_random_natural_range(\n        EXAMPLE_SEED,\n        Natural::from(10u32),\n        Natural::from(9u32),\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/striped_random_natural_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::striped_random_natural_range_to_infinity;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_natural_range_to_infinity_helper(\n    a: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        striped_random_natural_range_to_infinity(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_natural_range_to_infinity() {\n    let values = &[\n        \"2\",\n        \"4\",\n        \"128\",\n        \"1124203576\",\n        \"4\",\n        \"15\",\n        \"32\",\n        \"751\",\n        \"6400\",\n        \"8376024595\",\n        \"3\",\n        \"60\",\n        \"1\",\n        \"1\",\n        \"65045535\",\n        \"6\",\n        \"0\",\n        \"7\",\n        \"73608\",\n        \"719661083353407616\",\n    ];\n    let common_values = &[\n        (\"0\", 90859),\n        (\"1\", 82901),\n        (\"3\", 37653),\n        (\"2\", 37438),\n        (\"7\", 25786),\n        (\"4\", 25681),\n        (\"8\", 17394),\n        (\"15\", 17328),\n        (\"16\", 12055),\n        (\"31\", 11982),\n    ];\n    let sample_median = (\"71\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.068551928510147e34),\n        standard_deviation: NiceFloat(6.914607365781463e37),\n        skewness: NiceFloat(958.8924868378492),\n        excess_kurtosis: NiceFloat(939262.8054862365),\n    };\n    striped_random_natural_range_to_infinity_helper(\n        \"0\",\n        4,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"8192\", \"8312\", \"15614\", \"1984\", \"1568\", \"1023\", \"1791\", \"260174\", \"9855\", \"98176\", \"1519\",\n        \"2591\", \"3616\", \"8176\", \"1796\", \"8167\", \"262616\", \"4069\", \"12062\", \"1072\",\n    ];\n    let common_values = &[\n        (\"1023\", 31735),\n        (\"1007\", 28198),\n        (\"1000\", 28160),\n        (\"1022\", 10688),\n        (\"1008\", 10662),\n        (\"1020\", 10580),\n        (\"1016\", 10498),\n        (\"1001\", 9418),\n        (\"1003\", 9393),\n        (\"1004\", 9319),\n    ];\n    let sample_median = (\"4159\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(54201665904379.38),\n        standard_deviation: NiceFloat(2.6365321443458296e16),\n        skewness: NiceFloat(608.9470987335318),\n        excess_kurtosis: NiceFloat(388228.1677811064),\n    };\n    striped_random_natural_range_to_infinity_helper(\n        \"1000\",\n        4,\n        1,\n        14,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_range_to_infinity_fail_1() {\n    striped_random_natural_range_to_infinity(EXAMPLE_SEED, Natural::from(100u32), 1, 0, 10, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_range_to_infinity_fail_2() {\n    striped_random_natural_range_to_infinity(EXAMPLE_SEED, Natural::from(100u32), 1, 1, 10, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_range_to_infinity_fail_3() {\n    striped_random_natural_range_to_infinity(EXAMPLE_SEED, Natural::from(100u32), 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_natural_range_to_infinity_fail_4() {\n    striped_random_natural_range_to_infinity(EXAMPLE_SEED, Natural::from(100u32), 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/striped_random_naturals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::random::striped_random_naturals;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\n\nfn striped_random_naturals_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        striped_random_naturals(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_naturals() {\n    // mean bits = 1/64\n    let values = &[\"0\"; 20];\n    let common_values =\n        &[(\"0\", 984681), (\"1\", 15077), (\"3\", 120), (\"2\", 117), (\"4\", 3), (\"5\", 1), (\"7\", 1)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.015695000000000875),\n        standard_deviation: NiceFloat(0.12845498618458842),\n        skewness: NiceFloat(9.02636021695415),\n        excess_kurtosis: NiceFloat(104.38317092740806),\n    };\n    striped_random_naturals_helper(\n        4,\n        1,\n        1,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 1\n    let values = &[\n        \"0\", \"8\", \"0\", \"8\", \"2\", \"4\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 500248),\n        (\"1\", 249491),\n        (\"3\", 62636),\n        (\"2\", 62505),\n        (\"4\", 23595),\n        (\"7\", 23447),\n        (\"8\", 8713),\n        (\"15\", 8690),\n        (\"6\", 7938),\n        (\"5\", 7832),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.16843100000002),\n        standard_deviation: NiceFloat(782.5565010647151),\n        skewness: NiceFloat(800.2073401417995),\n        excess_kurtosis: NiceFloat(728738.7203924827),\n    };\n    striped_random_naturals_helper(\n        4,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"18014656207519744\",\n        \"2228160\",\n        \"64\",\n        \"17592184995840\",\n        \"1179440951012584587264\",\n        \"9007749010526207\",\n        \"67108864\",\n        \"5\",\n        \"24\",\n        \"34359738879\",\n        \"2417851639228158863474687\",\n        \"512\",\n        \"9444737328601429442560\",\n        \"8\",\n        \"131071\",\n        \"524032\",\n        \"8388607\",\n        \"34359738368\",\n        \"60\",\n        \"2147741695\",\n    ];\n    let common_values = &[\n        (\"0\", 30467),\n        (\"1\", 29379),\n        (\"3\", 14232),\n        (\"2\", 14195),\n        (\"4\", 13131),\n        (\"7\", 13019),\n        (\"8\", 11921),\n        (\"15\", 11751),\n        (\"31\", 10682),\n        (\"16\", 10555),\n    ];\n    let sample_median = (\"3670016\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.459178425232889e129),\n        standard_deviation: NiceFloat(1.459178425232619e132),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_naturals_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1473193827441715154886135497317777215948837626052608\",\n        \"1152921504606846976\",\n        \"16777216\",\n        \"4128768\",\n        \"1180591620717412351744\",\n        \"127\",\n        \"1\",\n        \"1073741823\",\n        \"4722366482869645209600\",\n        \"1267650600226049676594364547199\",\n        \"288230376151711743\",\n        \"8192\",\n        \"274869520368\",\n        \"1152921504606846976\",\n        \"5317074242107007699768820031345917967\",\n        \"1024\",\n        \"8191\",\n        \"4398046511104\",\n        \"11417981541647679048466288345891489974790914528\",\n        \"2251799813685247\",\n    ];\n    let common_values = &[\n        (\"0\", 15386),\n        (\"1\", 15062),\n        (\"2\", 7584),\n        (\"3\", 7467),\n        (\"4\", 7110),\n        (\"7\", 7017),\n        (\"8\", 6866),\n        (\"15\", 6763),\n        (\"31\", 6505),\n        (\"16\", 6460),\n    ];\n    let sample_median = (\"17592169267200\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.6414828903095017e263),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_naturals_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_naturals_fail_1() {\n    striped_random_naturals(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_naturals_fail_2() {\n    striped_random_naturals(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_naturals_fail_3() {\n    striped_random_naturals(EXAMPLE_SEED, 4, 1, 0, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_naturals_fail_4() {\n    striped_random_naturals(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_naturals_fail_5() {\n    striped_random_naturals(EXAMPLE_SEED, 4, 1, u64::MAX, u64::MAX - 1);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/striped_random_positive_naturals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::random::striped_random_positive_naturals;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\n\nfn striped_random_positive_naturals_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        striped_random_positive_naturals(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_positive_naturals() {\n    // mean bits = 65/64\n    let values = &[\"1\"; 20];\n    let common_values = &[\n        (\"1\", 984681),\n        (\"3\", 7637),\n        (\"2\", 7440),\n        (\"4\", 97),\n        (\"7\", 78),\n        (\"5\", 33),\n        (\"6\", 29),\n        (\"11\", 2),\n        (\"8\", 1),\n        (\"9\", 1),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.023796999999977),\n        standard_deviation: NiceFloat(0.20691241046333197),\n        skewness: NiceFloat(10.752762867801868),\n        excess_kurtosis: NiceFloat(162.40220891738076),\n    };\n    striped_random_positive_naturals_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"1\", \"16\", \"1\", \"16\", \"4\", \"15\", \"2\", \"1\", \"1\", \"1\", \"1\", \"1\", \"2\", \"2\", \"1\", \"1\", \"3\",\n        \"2\", \"1\", \"1\",\n    ];\n    let common_values = &[\n        (\"1\", 500248),\n        (\"2\", 124818),\n        (\"3\", 124673),\n        (\"7\", 47032),\n        (\"4\", 46853),\n        (\"8\", 17749),\n        (\"15\", 17612),\n        (\"5\", 15660),\n        (\"6\", 15596),\n        (\"16\", 6518),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(15.773014000000762),\n        standard_deviation: NiceFloat(2128.8810534178506),\n        skewness: NiceFloat(884.8410850537254),\n        excess_kurtosis: NiceFloat(843254.2507640689),\n    };\n    striped_random_positive_naturals_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"16\",\n        \"4\",\n        \"128\",\n        \"34391195648\",\n        \"75493376\",\n        \"9007199120523391\",\n        \"8\",\n        \"8796094070783\",\n        \"8\",\n        \"950737950171027935941967741439\",\n        \"1040391\",\n        \"33554432\",\n        \"84390026996392738938916902643112875376640\",\n        \"30\",\n        \"7\",\n        \"554153860399104\",\n        \"2199023255551\",\n        \"16\",\n        \"220784470296873664512\",\n        \"4611685966886694919\",\n    ];\n    let common_values = &[\n        (\"1\", 31094),\n        (\"3\", 15250),\n        (\"2\", 15195),\n        (\"7\", 13890),\n        (\"4\", 13880),\n        (\"8\", 12601),\n        (\"15\", 12519),\n        (\"31\", 11397),\n        (\"16\", 11237),\n        (\"63\", 10225),\n    ];\n    let sample_median = (\"4194272\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.1641486095650758e130),\n        standard_deviation: NiceFloat(1.1640776313097e133),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_naturals_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"649037107316853596555600210165760\",\n        \"822486237184\",\n        \"196608\",\n        \"141976867225561692967630759002112\",\n        \"174223242635524708377374895198005052307456\",\n        \"664594824829454142366461086851399679\",\n        \"4503599627370496\",\n        \"127\",\n        \"2048\",\n        \"147574233996470517759\",\n        \"45660775794157599311165096735019350831520546815\",\n        \"1048320\",\n        \"1361212544433490269424560431578983940096\",\n        \"3968\",\n        \"536870911\",\n        \"34359738368\",\n        \"35184372088831\",\n        \"9297159013149614014464\",\n        \"768\",\n        \"72040001986101247\",\n    ];\n    let common_values = &[\n        (\"1\", 15720),\n        (\"2\", 7656),\n        (\"3\", 7646),\n        (\"7\", 7219),\n        (\"4\", 7199),\n        (\"8\", 7122),\n        (\"15\", 6934),\n        (\"31\", 6799),\n        (\"16\", 6750),\n        (\"63\", 6456),\n    ];\n    let sample_median = (\"17592186044416\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.796251092974677e283),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_naturals_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_naturals_fail_1() {\n    striped_random_positive_naturals(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_naturals_fail_2() {\n    striped_random_positive_naturals(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_naturals_fail_3() {\n    striped_random_positive_naturals(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_naturals_fail_4() {\n    striped_random_positive_naturals(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/uniform_random_natural_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::uniform_random_natural_inclusive_range;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn uniform_random_natural_inclusive_range_helper(\n    a: &str,\n    b: &str,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        uniform_random_natural_inclusive_range(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            Natural::from_str(b).unwrap(),\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_uniform_random_natural_inclusive_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    uniform_random_natural_inclusive_range_helper(\n        \"0\",\n        \"0\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\", \"6\", \"6\", \"2\", \"3\", \"1\", \"3\", \"4\", \"5\", \"4\", \"6\", \"4\", \"2\", \"4\", \"6\", \"2\", \"1\", \"2\",\n        \"6\", \"6\",\n    ];\n    let common_values =\n        &[(\"3\", 167245), (\"4\", 166932), (\"1\", 166580), (\"6\", 166511), (\"5\", 166451), (\"2\", 166281)];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.499925999999989),\n        standard_deviation: NiceFloat(1.7070480100269305),\n        skewness: NiceFloat(0.00002078867947249881),\n        excess_kurtosis: NiceFloat(-1.2668800296473062),\n    };\n    uniform_random_natural_inclusive_range_helper(\n        \"1\",\n        \"6\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1987\", \"1993\", \"1907\", \"1984\", \"1927\", \"1946\", \"1993\", \"1922\", \"1986\", \"1901\", \"1907\",\n        \"1929\", \"1925\", \"1956\", \"1997\", \"1938\", \"1970\", \"1906\", \"1955\", \"1929\",\n    ];\n    let common_values = &[\n        (\"1945\", 10146),\n        (\"1987\", 10096),\n        (\"1991\", 10094),\n        (\"1982\", 10056),\n        (\"1900\", 10042),\n        (\"1973\", 10033),\n        (\"1959\", 10029),\n        (\"1967\", 10026),\n        (\"1974\", 10024),\n        (\"1946\", 10023),\n    ];\n    let sample_median = (\"1950\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1949.98699899998),\n        standard_deviation: NiceFloat(29.18007161489914),\n        skewness: NiceFloat(0.000791345316435403),\n        excess_kurtosis: NiceFloat(-1.2020606886458867),\n    };\n    uniform_random_natural_inclusive_range_helper(\n        \"1900\",\n        \"2000\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"4233271796909041147200401960861496742517\",\n        \"7217357404646018754599684571795784707698\",\n        \"8727353449345949782973180362335717735342\",\n        \"1534354137356207625017431174589301695702\",\n        \"1534877532602868824396077953846378055833\",\n        \"3066581267912983630335063637372720045094\",\n        \"2831715414082884162869589340142899207735\",\n        \"3619564100767325027279529873701213301661\",\n        \"7005405409180901613675532713129270331479\",\n        \"9271966495851265353624356439908105167895\",\n        \"3537046382263430904899281307939508702471\",\n        \"8202939407624515890221097211474505126578\",\n        \"6142762353061547853401995252125996224683\",\n        \"2027218951536793906738056738325216303009\",\n        \"2459386323443095819796283591928997970915\",\n        \"6477318216232641272279240890043646394779\",\n        \"7387837972601141117504319208136943264497\",\n        \"6474635405681155657679090532822557929038\",\n        \"9135952782573375316643238824480434324207\",\n        \"6103640323458129521087258887390847694928\",\n    ];\n    let common_values = &[\n        (\"1000008513881061280823789640490226316271\", 1),\n        (\"1000008768725511813114574712047169606198\", 1),\n        (\"1000009827974885359877076313510726004983\", 1),\n        (\"1000012488944552955502737286653696783298\", 1),\n        (\"1000022890668287803601945090476573028348\", 1),\n        (\"1000024602492188456115932292147454123699\", 1),\n        (\"1000032710913204967376519858724740864044\", 1),\n        (\"1000032757195298640822606970649697168394\", 1),\n        (\"1000036222387069235523377031863703777427\", 1),\n        (\"1000036429852801882310669972964558023474\", 1),\n    ];\n    let sample_median = (\n        \"5500511672867651605813709882516812610647\",\n        Some(\"5500520043239248270285741751344805934001\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.501866091611912e39),\n        standard_deviation: NiceFloat(2.5991591590322043e39),\n        skewness: NiceFloat(0.00028444202202606493),\n        excess_kurtosis: NiceFloat(-1.2007002735784507),\n    };\n    uniform_random_natural_inclusive_range_helper(\n        \"1000000000000000000000000000000000000000\",\n        \"9999999999999999999999999999999999999999\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn uniform_random_natural_inclusive_range_fail() {\n    uniform_random_natural_inclusive_range(EXAMPLE_SEED, Natural::from(10u32), Natural::from(9u32));\n}\n"
  },
  {
    "path": "malachite-nz/tests/natural/random/uniform_random_natural_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::uniform_random_natural_range;\nuse malachite_nz::test_util::natural::random::random_naturals_helper_helper;\nuse std::str::FromStr;\n\nfn uniform_random_natural_range_helper(\n    a: &str,\n    b: &str,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_naturals_helper_helper(\n        uniform_random_natural_range(\n            EXAMPLE_SEED,\n            Natural::from_str(a).unwrap(),\n            Natural::from_str(b).unwrap(),\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_uniform_random_natural_range() {\n    let values = &[\"0\"; 20];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    uniform_random_natural_range_helper(\n        \"0\",\n        \"1\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"2\", \"6\", \"6\", \"2\", \"3\", \"1\", \"3\", \"4\", \"5\", \"4\", \"6\", \"4\", \"2\", \"4\", \"6\", \"2\", \"1\", \"2\",\n        \"6\", \"6\",\n    ];\n    let common_values =\n        &[(\"3\", 167245), (\"4\", 166932), (\"1\", 166580), (\"6\", 166511), (\"5\", 166451), (\"2\", 166281)];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.499925999999989),\n        standard_deviation: NiceFloat(1.7070480100269305),\n        skewness: NiceFloat(0.00002078867947249881),\n        excess_kurtosis: NiceFloat(-1.2668800296473062),\n    };\n    uniform_random_natural_range_helper(\n        \"1\",\n        \"7\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"1987\", \"1993\", \"1907\", \"1984\", \"1927\", \"1946\", \"1993\", \"1922\", \"1986\", \"1901\", \"1907\",\n        \"1929\", \"1925\", \"1956\", \"1997\", \"1938\", \"1970\", \"1906\", \"1955\", \"1929\",\n    ];\n    let common_values = &[\n        (\"1945\", 10146),\n        (\"1987\", 10096),\n        (\"1991\", 10094),\n        (\"1982\", 10056),\n        (\"1900\", 10042),\n        (\"1973\", 10033),\n        (\"1959\", 10029),\n        (\"1967\", 10026),\n        (\"1974\", 10024),\n        (\"1946\", 10023),\n    ];\n    let sample_median = (\"1950\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1949.98699899998),\n        standard_deviation: NiceFloat(29.18007161489914),\n        skewness: NiceFloat(0.000791345316435403),\n        excess_kurtosis: NiceFloat(-1.2020606886458867),\n    };\n    uniform_random_natural_range_helper(\n        \"1900\",\n        \"2001\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    let values = &[\n        \"4233271796909041147200401960861496742517\",\n        \"7217357404646018754599684571795784707698\",\n        \"8727353449345949782973180362335717735342\",\n        \"1534354137356207625017431174589301695702\",\n        \"1534877532602868824396077953846378055833\",\n        \"3066581267912983630335063637372720045094\",\n        \"2831715414082884162869589340142899207735\",\n        \"3619564100767325027279529873701213301661\",\n        \"7005405409180901613675532713129270331479\",\n        \"9271966495851265353624356439908105167895\",\n        \"3537046382263430904899281307939508702471\",\n        \"8202939407624515890221097211474505126578\",\n        \"6142762353061547853401995252125996224683\",\n        \"2027218951536793906738056738325216303009\",\n        \"2459386323443095819796283591928997970915\",\n        \"6477318216232641272279240890043646394779\",\n        \"7387837972601141117504319208136943264497\",\n        \"6474635405681155657679090532822557929038\",\n        \"9135952782573375316643238824480434324207\",\n        \"6103640323458129521087258887390847694928\",\n    ];\n    let common_values = &[\n        (\"1000008513881061280823789640490226316271\", 1),\n        (\"1000008768725511813114574712047169606198\", 1),\n        (\"1000009827974885359877076313510726004983\", 1),\n        (\"1000012488944552955502737286653696783298\", 1),\n        (\"1000022890668287803601945090476573028348\", 1),\n        (\"1000024602492188456115932292147454123699\", 1),\n        (\"1000032710913204967376519858724740864044\", 1),\n        (\"1000032757195298640822606970649697168394\", 1),\n        (\"1000036222387069235523377031863703777427\", 1),\n        (\"1000036429852801882310669972964558023474\", 1),\n    ];\n    let sample_median = (\n        \"5500511672867651605813709882516812610647\",\n        Some(\"5500520043239248270285741751344805934001\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.501866091611912e39),\n        standard_deviation: NiceFloat(2.5991591590322043e39),\n        skewness: NiceFloat(0.00028444202202606493),\n        excess_kurtosis: NiceFloat(-1.2007002735784507),\n    };\n    uniform_random_natural_range_helper(\n        \"1000000000000000000000000000000000000000\",\n        \"10000000000000000000000000000000000000000\",\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn uniform_random_natural_range_fail_1() {\n    uniform_random_natural_range(EXAMPLE_SEED, Natural::from(10u32), Natural::from(9u32));\n}\n\n#[test]\n#[should_panic]\nfn uniform_random_natural_range_fail_2() {\n    uniform_random_natural_range(EXAMPLE_SEED, Natural::from(10u32), Natural::from(10u32));\n}\n"
  },
  {
    "path": "malachite-q/.gitignore",
    "content": "target\n*.bk\n.idea*\n*.iml\n\n"
  },
  {
    "path": "malachite-q/Cargo.toml",
    "content": "[package]\nname = \"malachite-q\"\nversion = \"0.9.1\"\nauthors = [\"Mikhail Hogrefe <mikhailhogrefe@gmail.com>\"]\nrust-version.workspace = true\nedition.workspace = true\ndescription = \"The arbitrary-precision type Rational, with efficient algorithms partially derived from GMP and FLINT.\"\nreadme = \"README.md\"\nhomepage = \"https://malachite.rs/\"\nrepository = \"https://github.com/mhogrefe/malachite\"\nlicense = \"LGPL-3.0-only\"\nkeywords = [\"mathematics\", \"math\", \"numerics\", \"bignum\"]\ncategories = [\"mathematics\"]\n\n[lib]\nname = \"malachite_q\"\npath = \"src/lib.rs\"\n\n[[bin]]\nname = \"malachite_q_main\"\npath = \"src/bin.rs\"\n\n[dependencies]\nitertools = { version = \"0.14.0\", default-features = false, features = [\"use_alloc\"] }\nmalachite-base = { version = \"0.9.1\", default-features = false, path = \"../malachite-base\" }\nmalachite-nz = { version = \"0.9.1\", default-features = false, path = \"../malachite-nz\" }\nserde = { version = \"1.0.188\", optional = true, default-features = false, features = [\"alloc\", \"derive\"] }\n\nserde_json = { version = \"1.0.149\", optional = true }\nnum = { version = \"0.4.3\", optional = true, features = [\"serde\"] }\nrug = { version = \"1.28.1\", default-features = false, optional = true, features = [\"rational\", \"serde\"] }\n\n[dev-dependencies]\nmalachite-q = { path = \".\", features = [\"test_build\"] }\n\n[features]\ndefault = [\"std\"]\nstd = [\"malachite-base/std\", \"malachite-nz/std\"]\nenable_serde = [\"serde\", \"malachite-nz/enable_serde\"]\nrandom = [\"malachite-base/random\", \"malachite-nz/random\"]\n32_bit_limbs = [\"malachite-nz/32_bit_limbs\"]\ntest_build = [\"malachite-base/test_build\", \"malachite-nz/test_build\", \"random\", \"serde\", \"serde_json\", \"num\", \"rug\"]\nbin_build = [\"test_build\"]\n\n[package.metadata.docs.rs]\nfeatures = [\"random\"]\nrustdoc-args = [ \"--html-in-header\", \"katex-header.html\" ]\n"
  },
  {
    "path": "malachite-q/README.md",
    "content": "- [crates.io](https://crates.io/crates/malachite-q)\n- [docs.rs](https://docs.rs/malachite-q/latest/malachite_q/)\n\nRather than using this crate directly, use the\n[`malachite`](https://crates.io/crates/malachite) meta-crate. It re-exports all of this crate's\npublic members.\n\nIn `malachite-q`'s doctests you will frequently see import paths beginning with\n`malachite_q::`. When using the `malachite` crate, replace this part of the paths with\n`malachite::`.\n\nThe import path of the `Rational` type is shortened to `malachite::Rational`.\n\n# malachite-q\nThis crate defines\n[`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s. The name of\nthis crate refers to the mathematical symbol for rational numbers, ℚ.\n- There are many functions defined on\n  [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s. These include\n  - All the ones you'd expect, like addition, subtraction, multiplication, and division;\n  - Functions related to conversion between\n    [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s and other\n    kinds of numbers, including primitive floats;\n  - Functions for Diophantine approximation;\n  - Functions for expressing\n    [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s in\n    scientific notation.\n- The numerators and denominators of\n  [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s are stored as\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s, so\n  [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s with small\n  numerators and denominators can be stored entirely on the stack.\n- Most arithmetic involving\n  [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html)s requires\n  (automatically) reducing the numerator and denominator. This is done very efficiently by using\n  the high performance GCD and exact division algorithms implemented by\n  [`Natural`](https://docs.rs/malachite-nz/latest/malachite_nz/natural/struct.Natural.html)s.\n\n# Demos and benchmarks\nThis crate comes with a `bin` target that can be used for running demos and benchmarks.\n- Almost all of the public functions in this crate have an associated demo. Running a demo\n  shows you a function's behavior on a large number of inputs. For example, to demo\n  [`Rational`](https://docs.rs/malachite-q/latest/malachite_q/struct.Rational.html) addition, you\n  can use the following command:\n  ```text\n  cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_rational_add\n  ```\n  This command uses the `exhaustive` mode, which generates every possible input, generally\n  starting with the simplest input and progressing to more complex ones. Another mode is\n  `random`. The `-l` flag specifies how many inputs should be generated.\n- You can use a similar command to run benchmarks. The following command benchmarks various\n  addition algorithms:\n  ```text\n  cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n      benchmark_rational_add_algorithms -o gcd-bench.gp\n  ```\n  or GCD implementations of other libraries:\n  ```text\n  cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n      benchmark_rational_add_assign_library_comparison -o gcd-bench.gp\n  ```\n  This creates a file called gcd-bench.gp. You can use gnuplot to create an SVG from it like\n  so:\n  ```text\n  gnuplot -e \"set terminal svg; l \\\"gcd-bench.gp\\\"\" > gcd-bench.svg\n  ```\n\nThe list of available demos and benchmarks is not documented anywhere; you must find them by\nbrowsing through\n[`bin_util/demo_and_bench`](https://github.com/mhogrefe/malachite/tree/master/malachite-q/src/bin_util/demo_and_bench).\n\n# Features\n- `32_bit_limbs`: Sets the type of `Limb` to\n  [`u32`](https://doc.rust-lang.org/nightly/std/primitive.u32.html) instead of the default,\n  [`u64`](https://doc.rust-lang.org/nightly/std/primitive.u64.html).\n- `random`: This feature provides some functions for randomly generating values. It is off by\n  default to avoid pulling in some extra dependencies.\n- `enable_serde`: Enables serialization and deserialization using [serde](`https://serde.rs/`).\n- `test_build`: A large proportion of the code in this crate is only used for testing. For a\n  typical user, building this code would result in an unnecessarily long compilation time and\n  an unnecessarily large binary. My solution is to only build this code when the `test_build`\n  feature is enabled. If you want to run unit tests, you must enable `test_build`. However,\n  doctests don't require it, since they only test the public interface. Enabling this feature also\n  enables `random`.\n- `bin_build`: This feature is used to build the code for demos and benchmarks, which also\n  takes a long time to build. Enabling this feature also enables `test_build` and `random`.\n\nMalachite is developed by Mikhail Hogrefe. Thanks to b4D8, florian1345, konstin, Rowan Hart, YunWon Jeong, Park Joon-Kyu, Antonio Mamić, OliverNChalk, shekohex, and skycloudd for additional contributions.\n\nCopyright © 2026 Mikhail Hogrefe\n"
  },
  {
    "path": "malachite-q/katex-header.html",
    "content": "<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css\" integrity=\"sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y\" crossorigin=\"anonymous\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js\"                  integrity=\"sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js\"    integrity=\"sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe\" crossorigin=\"anonymous\"></script>\n<script>\n    document.addEventListener(\"DOMContentLoaded\", function() {\n        renderMathInElement(document.body, {\n            delimiters: [\n                {left: \"$$\", right: \"$$\", display: true},\n                {left: \"\\\\(\", right: \"\\\\)\", display: false},\n                {left: \"$\", right: \"$\", display: false},\n                {left: \"\\\\[\", right: \"\\\\]\", display: true}\n            ]\n        });\n    });\n</script>\n"
  },
  {
    "path": "malachite-q/rustfmt.toml",
    "content": "max_width = 100\narray_width = 100\n\n"
  },
  {
    "path": "malachite-q/src/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign};\n\nimpl Abs for Rational {\n    type Output = Self;\n\n    /// Takes the absolute value of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Abs;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ZERO.abs(), 0);\n    /// assert_eq!(Rational::from_signeds(22, 7).abs().to_string(), \"22/7\");\n    /// assert_eq!(Rational::from_signeds(-22, 7).abs().to_string(), \"22/7\");\n    /// ```\n    fn abs(mut self) -> Self {\n        self.sign = true;\n        self\n    }\n}\n\nimpl Abs for &Rational {\n    type Output = Rational;\n\n    /// Takes the absolute value of a [`Rational`], taking the [`Rational`] by reference.\n    ///\n    /// $$\n    /// f(x) = |x|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Abs;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Rational::ZERO).abs(), 0);\n    /// assert_eq!((&Rational::from_signeds(22, 7)).abs().to_string(), \"22/7\");\n    /// assert_eq!((&Rational::from_signeds(-22, 7)).abs().to_string(), \"22/7\");\n    /// ```\n    fn abs(self) -> Rational {\n        Rational {\n            sign: true,\n            numerator: self.numerator.clone(),\n            denominator: self.denominator.clone(),\n        }\n    }\n}\n\nimpl AbsAssign for Rational {\n    /// Replaces a [`Rational`] with its absolute value.\n    ///\n    /// $$\n    /// x \\gets |x|.\n    /// $$\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ZERO;\n    /// x.abs_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.abs_assign();\n    /// assert_eq!(x.to_string(), \"22/7\");\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.abs_assign();\n    /// assert_eq!(x.to_string(), \"22/7\");\n    /// ```\n    fn abs_assign(&mut self) {\n        self.sign = true;\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991-2018, 2020 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign, AbsDiff, AbsDiffAssign};\n\nimpl AbsDiff<Self> for Rational {\n    type Output = Self;\n\n    /// Computes the absolute value of the difference between two [`Rational`]s, taking both by\n    /// value.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsDiff;\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF.abs_diff(Rational::ONE_HALF), 0);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .abs_diff(Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .abs_diff(Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: Self) -> Self {\n        (self - other).abs()\n    }\n}\n\nimpl AbsDiff<&Self> for Rational {\n    type Output = Self;\n\n    /// Computes the absolute value of the difference between two [`Rational`]s, taking the first by\n    /// value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsDiff;\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF.abs_diff(&Rational::ONE_HALF), 0);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .abs_diff(&Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .abs_diff(&Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: &Self) -> Self {\n        (self - other).abs()\n    }\n}\n\nimpl AbsDiff<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the absolute value of the difference between two [`Rational`]s, taking the first by\n    /// reference and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsDiff;\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF.abs_diff(Rational::ONE_HALF), 0);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .abs_diff(Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .abs_diff(Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: Rational) -> Rational {\n        (self - other).abs()\n    }\n}\n\nimpl AbsDiff<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the absolute value of the difference between two [`Rational`]s, taking both by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsDiff;\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF.abs_diff(Rational::ONE_HALF), 0);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .abs_diff(&Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .abs_diff(&Rational::from_signeds(99, 100))\n    ///         .to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    #[inline]\n    fn abs_diff(self, other: &Rational) -> Rational {\n        (self - other).abs()\n    }\n}\n\nimpl AbsDiffAssign<Self> for Rational {\n    /// Subtracts a [`Rational`] by another [`Rational`] in place and takes the absolute value,\n    /// taking the [`Rational`] on the right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsDiffAssign;\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x.abs_diff_assign(Rational::ONE_HALF);\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.abs_diff_assign(Rational::from_signeds(99, 100));\n    /// assert_eq!(x.to_string(), \"1507/700\");\n    ///\n    /// let mut x = Rational::from_signeds(99, 100);\n    /// x.abs_diff_assign(Rational::from_signeds(22, 7));\n    /// assert_eq!(x.to_string(), \"1507/700\");\n    /// ```\n    #[inline]\n    fn abs_diff_assign(&mut self, other: Self) {\n        *self -= other;\n        self.abs_assign();\n    }\n}\n\nimpl<'a> AbsDiffAssign<&'a Self> for Rational {\n    /// Subtracts a [`Rational`] by another [`Rational`] in place and takes the absolute value,\n    /// taking the [`Rational`] on the right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets |x - y|.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `other` is greater than `self`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::AbsDiffAssign;\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x.abs_diff_assign(&Rational::ONE_HALF);\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.abs_diff_assign(&Rational::from_signeds(99, 100));\n    /// assert_eq!(x.to_string(), \"1507/700\");\n    ///\n    /// let mut x = Rational::from_signeds(99, 100);\n    /// x.abs_diff_assign(&Rational::from_signeds(22, 7));\n    /// assert_eq!(x.to_string(), \"1507/700\");\n    /// ```\n    #[inline]\n    fn abs_diff_assign(&mut self, other: &'a Self) {\n        *self -= other;\n        self.abs_assign();\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1994-1997, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse alloc::vec::Vec;\nuse core::iter::Sum;\nuse core::ops::{Add, AddAssign};\nuse malachite_base::num::arithmetic::traits::{\n    DivExact, DivExactAssign, Gcd, GcdAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::integer::Integer;\n\nimpl Add<Self> for Rational {\n    type Output = Self;\n\n    /// Adds two [`Rational`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF + Rational::ONE_HALF, 1);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) + Rational::from_signeds(99, 100)).to_string(),\n    ///     \"2893/700\"\n    /// );\n    /// ```\n    fn add(self, other: Self) -> Self {\n        if self == 0u32 {\n            return other;\n        } else if other == 0u32 {\n            return self;\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            let sum_n = Integer::from_sign_and_abs(self.sign, self.numerator * &other.denominator)\n                + Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            let sum_d = self.denominator * other.denominator;\n            Self {\n                sign: sum_n >= 0,\n                numerator: sum_n.unsigned_abs(),\n                denominator: sum_d,\n            }\n        } else {\n            let reduced_self_d = (self.denominator).div_exact(&gcd);\n            let sum_n =\n                Integer::from_sign_and_abs(\n                    self.sign,\n                    self.numerator * (&other.denominator).div_exact(&gcd),\n                ) + Integer::from_sign_and_abs(other.sign, other.numerator * &reduced_self_d);\n            gcd.gcd_assign(sum_n.unsigned_abs_ref());\n            if gcd == 1u32 {\n                Self {\n                    sign: sum_n >= 0,\n                    numerator: sum_n.unsigned_abs(),\n                    denominator: other.denominator * reduced_self_d,\n                }\n            } else {\n                Self {\n                    sign: sum_n >= 0,\n                    numerator: sum_n.unsigned_abs().div_exact(&gcd),\n                    denominator: (other.denominator).div_exact(gcd) * reduced_self_d,\n                }\n            }\n        }\n    }\n}\n\nimpl Add<&Self> for Rational {\n    type Output = Self;\n\n    /// Adds two [`Rational`]s, taking both by the first by value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF + &Rational::ONE_HALF, 1);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) + &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"2893/700\"\n    /// );\n    /// ```\n    #[inline]\n    fn add(self, other: &Self) -> Self {\n        other + self\n    }\n}\n\nimpl Add<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Adds two [`Rational`]s, taking the first by reference and the second by value\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::ONE_HALF + Rational::ONE_HALF, 1);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) + Rational::from_signeds(99, 100)).to_string(),\n    ///     \"2893/700\"\n    /// );\n    /// ```\n    fn add(self, other: Rational) -> Rational {\n        if *self == 0u32 {\n            return other;\n        } else if other == 0u32 {\n            return self.clone();\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            let sum_n = Integer::from_sign_and_abs(self.sign, &self.numerator * &other.denominator)\n                + Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            let sum_d = &self.denominator * other.denominator;\n            Rational {\n                sign: sum_n >= 0,\n                numerator: sum_n.unsigned_abs(),\n                denominator: sum_d,\n            }\n        } else {\n            let reduced_self_d = (&self.denominator).div_exact(&gcd);\n            let sum_n =\n                Integer::from_sign_and_abs(\n                    self.sign,\n                    &self.numerator * (&other.denominator).div_exact(&gcd),\n                ) + Integer::from_sign_and_abs(other.sign, other.numerator * &reduced_self_d);\n            gcd.gcd_assign(sum_n.unsigned_abs_ref());\n            if gcd == 1u32 {\n                Rational {\n                    sign: sum_n >= 0,\n                    numerator: sum_n.unsigned_abs(),\n                    denominator: other.denominator * reduced_self_d,\n                }\n            } else {\n                Rational {\n                    sign: sum_n >= 0,\n                    numerator: sum_n.unsigned_abs().div_exact(&gcd),\n                    denominator: (other.denominator).div_exact(gcd) * reduced_self_d,\n                }\n            }\n        }\n    }\n}\n\nimpl Add<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Adds two [`Rational`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::ONE_HALF + &Rational::ONE_HALF, 1);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) + &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"2893/700\"\n    /// );\n    /// ```\n    fn add(self, other: &Rational) -> Rational {\n        if *self == 0u32 {\n            return other.clone();\n        } else if *other == 0u32 {\n            return self.clone();\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            let sum_n = Integer::from_sign_and_abs(self.sign, &self.numerator * &other.denominator)\n                + Integer::from_sign_and_abs(other.sign, &other.numerator * &self.denominator);\n            let sum_d = &self.denominator * &other.denominator;\n            Rational {\n                sign: sum_n >= 0,\n                numerator: sum_n.unsigned_abs(),\n                denominator: sum_d,\n            }\n        } else {\n            let reduced_self_d = (&self.denominator).div_exact(&gcd);\n            let sum_n =\n                Integer::from_sign_and_abs(\n                    self.sign,\n                    &self.numerator * (&other.denominator).div_exact(&gcd),\n                ) + Integer::from_sign_and_abs(other.sign, &other.numerator * &reduced_self_d);\n            gcd.gcd_assign(sum_n.unsigned_abs_ref());\n            if gcd == 1u32 {\n                Rational {\n                    sign: sum_n >= 0,\n                    numerator: sum_n.unsigned_abs(),\n                    denominator: &other.denominator * reduced_self_d,\n                }\n            } else {\n                Rational {\n                    sign: sum_n >= 0,\n                    numerator: sum_n.unsigned_abs().div_exact(&gcd),\n                    denominator: (&other.denominator).div_exact(gcd) * reduced_self_d,\n                }\n            }\n        }\n    }\n}\n\nimpl AddAssign<Self> for Rational {\n    /// Adds a [`Rational`] to a [`Rational`] in place, taking the [`Rational`] on the right-hand\n    /// side by value.\n    ///\n    /// $$\n    /// x \\gets x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x += Rational::ONE_HALF;\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x += Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"2893/700\");\n    /// ```\n    fn add_assign(&mut self, other: Self) {\n        if *self == 0u32 {\n            *self = other;\n            return;\n        } else if other == 0u32 {\n            return;\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            self.numerator *= &other.denominator;\n            let sum_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                + Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            self.sign = sum_n >= 0;\n            self.numerator = sum_n.unsigned_abs();\n            self.denominator *= other.denominator;\n        } else {\n            self.denominator.div_exact_assign(&gcd);\n            self.numerator *= (&other.denominator).div_exact(&gcd);\n            let sum_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                + Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            gcd.gcd_assign(sum_n.unsigned_abs_ref());\n            self.sign = sum_n >= 0;\n            if gcd == 1u32 {\n                self.numerator = sum_n.unsigned_abs();\n                self.denominator *= other.denominator;\n            } else {\n                self.numerator = sum_n.unsigned_abs().div_exact(&gcd);\n                self.denominator *= (other.denominator).div_exact(gcd);\n            }\n        }\n    }\n}\n\nimpl AddAssign<&Self> for Rational {\n    /// Adds a [`Rational`] to a [`Rational`] in place, taking the [`Rational`] on the right-hand\n    /// side by reference.\n    ///\n    /// $$\n    /// x \\gets x + y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x += &Rational::ONE_HALF;\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x += &Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"2893/700\");\n    /// ```\n    fn add_assign(&mut self, other: &Self) {\n        if *self == 0u32 {\n            self.clone_from(other);\n            return;\n        } else if *other == 0u32 {\n            return;\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            self.numerator *= &other.denominator;\n            let sum_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                + Integer::from_sign_and_abs(other.sign, &other.numerator * &self.denominator);\n            self.sign = sum_n >= 0;\n            self.numerator = sum_n.unsigned_abs();\n            self.denominator *= &other.denominator;\n        } else {\n            self.denominator.div_exact_assign(&gcd);\n            self.numerator *= (&other.denominator).div_exact(&gcd);\n            let sum_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                + Integer::from_sign_and_abs(other.sign, &other.numerator * &self.denominator);\n            gcd.gcd_assign(sum_n.unsigned_abs_ref());\n            self.sign = sum_n >= 0;\n            if gcd == 1u32 {\n                self.numerator = sum_n.unsigned_abs();\n                self.denominator *= &other.denominator;\n            } else {\n                self.numerator = sum_n.unsigned_abs().div_exact(&gcd);\n                self.denominator *= (&other.denominator).div_exact(gcd);\n            }\n        }\n    }\n}\n\nimpl Sum for Rational {\n    /// Adds up all the [`Rational`]s in an iterator.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\sum_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^3 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Rational::sum(xs.map(Rational::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_q::Rational;\n    /// use std::iter::Sum;\n    ///\n    /// assert_eq!(\n    ///     Rational::sum(\n    ///         vec_from_str::<Rational>(\"[0, 1, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10]\")\n    ///             .unwrap()\n    ///             .into_iter()\n    ///     )\n    ///     .to_string(),\n    ///     \"19079/2520\"\n    /// );\n    /// ```\n    fn sum<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate() {\n            let mut s = x;\n            for _ in 0..(i + 1).trailing_zeros() {\n                s += stack.pop().unwrap();\n            }\n            stack.push(s);\n        }\n        let mut s = Self::ZERO;\n        for x in stack.into_iter().rev() {\n            s += x;\n        }\n        s\n    }\n}\n\nimpl<'a> Sum<&'a Self> for Rational {\n    /// Adds up all the [`Rational`]s in an iterator of [`Rational`] references.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\sum_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^3 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Rational::sum(xs.map(Rational::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_q::Rational;\n    /// use std::iter::Sum;\n    ///\n    /// assert_eq!(\n    ///     Rational::sum(\n    ///         vec_from_str::<Rational>(\"[0, 1, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10]\")\n    ///             .unwrap()\n    ///             .iter()\n    ///     )\n    ///     .to_string(),\n    ///     \"19079/2520\"\n    /// );\n    /// ```\n    fn sum<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = &'a Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate() {\n            let mut s = x.clone();\n            for _ in 0..(i + 1).trailing_zeros() {\n                s += stack.pop().unwrap();\n            }\n            stack.push(s);\n        }\n        let mut s = Self::ZERO;\n        for x in stack.into_iter().rev() {\n            s += x;\n        }\n        s\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/approximate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::traits::{Approximate, ApproximateAssign};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{\n    AddMulAssign, DivMod, Floor, Parity, Reciprocal, ShrRound, UnsignedAbs,\n};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nfn approximate_helper(q: &Rational, max_denominator: &Natural) -> Rational {\n    let floor = q.floor();\n    let mut x = (q - Rational::from(&floor)).reciprocal();\n    let mut previous_numerator = Integer::ONE;\n    let mut previous_denominator = Natural::ZERO;\n    let mut numerator = floor;\n    let mut denominator = Natural::ONE;\n    let mut result = None;\n    loop {\n        let n;\n        (n, x.numerator) = (&x.numerator).div_mod(&x.denominator);\n        swap(&mut x.numerator, &mut x.denominator);\n        let previous_previous_numerator = previous_numerator.clone();\n        let previous_previous_denominator = previous_denominator.clone();\n        previous_numerator.add_mul_assign(&numerator, Integer::from(&n));\n        previous_denominator.add_mul_assign(&denominator, &n);\n        if previous_denominator > *max_denominator {\n            previous_numerator = previous_previous_numerator;\n            previous_denominator = previous_previous_denominator;\n            // We need a term m such that previous_denominator + denominator * m is as large as\n            // possible without exceeding max_denominator.\n            let m = (max_denominator - &previous_denominator) / &denominator;\n            let half_n = (&n).shr_round(1, Ceiling).0;\n            if m < half_n {\n            } else if m == half_n && n.even() {\n                let previous_convergent = Rational {\n                    sign: numerator >= 0u32,\n                    numerator: (&numerator).unsigned_abs(),\n                    denominator: denominator.clone(),\n                };\n                previous_numerator.add_mul_assign(&numerator, Integer::from(&m));\n                previous_denominator.add_mul_assign(&denominator, m);\n                let candidate = Rational {\n                    sign: previous_numerator >= 0u32,\n                    numerator: previous_numerator.unsigned_abs(),\n                    denominator: previous_denominator,\n                };\n                result = Some(if (q - &previous_convergent).lt_abs(&(q - &candidate)) {\n                    previous_convergent\n                } else {\n                    candidate\n                });\n            } else {\n                numerator *= Integer::from(&m);\n                numerator += previous_numerator;\n                denominator *= m;\n                denominator += previous_denominator;\n            }\n            break;\n        }\n        swap(&mut numerator, &mut previous_numerator);\n        swap(&mut denominator, &mut previous_denominator);\n    }\n    let result = if let Some(result) = result {\n        result\n    } else {\n        Rational {\n            sign: numerator >= 0u32,\n            numerator: numerator.unsigned_abs(),\n            denominator,\n        }\n    };\n    // Suppose the input is (1/4, 2). The approximations 0 and 1/2 both satisfy the denominator\n    // limit and are equidistant from 1/4, but we prefer 0 because it has the smaller denominator.\n    // Unfortunately, the code above makes the wrong choice, so we need the following code to check\n    // whether the approximation on the opposite side of `self` is better.\n    let opposite: Rational = (q << 1) - &result;\n    if result.denominator_ref() <= opposite.denominator_ref() {\n        result\n    } else {\n        opposite\n    }\n}\n\nimpl Approximate for Rational {\n    /// Finds the best approximation of a [`Rational`] using a denominator no greater than a\n    /// specified maximum, taking the [`Rational`] by value.\n    ///\n    /// Let $f(x, d) = p/q$, with $p$ and $q$ relatively prime. Then the following properties hold:\n    /// - $q \\leq d$\n    /// - For all $n \\in \\Z$ and all $m \\in \\Z$ with $0 < m \\leq d$, $|x - p/q| \\leq |x - n/m|$.\n    /// - If $|x - n/m| = |x - p/q|$, then $q \\leq m$.\n    /// - If $|x - n/q| = |x - p/q|$, then $p$ is even and $n$ is either equal to $p$ or odd.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2 \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// - If `max_denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::arithmetic::traits::Approximate;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::exact_from(std::f64::consts::PI)\n    ///         .approximate(&Natural::from(1000u32))\n    ///         .to_string(),\n    ///     \"355/113\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(333i32, 1000)\n    ///         .approximate(&Natural::from(100u32))\n    ///         .to_string(),\n    ///     \"1/3\"\n    /// );\n    /// ```\n    ///\n    /// # Implementation notes\n    /// This algorithm follows the description in\n    /// <https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations>. One part of\n    /// the algorithm not mentioned in that article is that if the last term $n$ in the continued\n    /// fraction needs to be reduced, the optimal replacement term $m$ may be found using division.\n    fn approximate(self, max_denominator: &Natural) -> Rational {\n        assert_ne!(*max_denominator, 0);\n        if self.denominator_ref() <= max_denominator {\n            return self;\n        }\n        if *max_denominator == 1u32 {\n            return Self::from(Integer::rounding_from(self, Nearest).0);\n        }\n        approximate_helper(&self, max_denominator)\n    }\n}\n\nimpl Approximate for &Rational {\n    /// Finds the best approximation of a [`Rational`] using a denominator no greater than a\n    /// specified maximum, taking the [`Rational`] by reference.\n    ///\n    /// Let $f(x, d) = p/q$, with $p$ and $q$ relatively prime. Then the following properties hold:\n    /// - $q \\leq d$\n    /// - For all $n \\in \\Z$ and all $m \\in \\Z$ with $0 < m \\leq d$, $|x - p/q| \\leq |x - n/m|$.\n    /// - If $|x - n/m| = |x - p/q|$, then $q \\leq m$.\n    /// - If $|x - n/q| = |x - p/q|$, then $p$ is even and $n$ is either equal to $p$ or odd.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2 \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// - If `max_denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::arithmetic::traits::Approximate;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::exact_from(std::f64::consts::PI))\n    ///         .approximate(&Natural::from(1000u32))\n    ///         .to_string(),\n    ///     \"355/113\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(333i32, 1000))\n    ///         .approximate(&Natural::from(100u32))\n    ///         .to_string(),\n    ///     \"1/3\"\n    /// );\n    /// ```\n    ///\n    /// # Implementation notes\n    /// This algorithm follows the description in\n    /// <https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations>. One part of\n    /// the algorithm not mentioned in that article is that if the last term $n$ in the continued\n    /// fraction needs to be reduced, the optimal replacement term $m$ may be found using division.\n    fn approximate(self, max_denominator: &Natural) -> Rational {\n        assert_ne!(*max_denominator, 0);\n        if self.denominator_ref() <= max_denominator {\n            return self.clone();\n        }\n        if *max_denominator == 1u32 {\n            return Rational::from(Integer::rounding_from(self, Nearest).0);\n        }\n        approximate_helper(self, max_denominator)\n    }\n}\n\nimpl ApproximateAssign for Rational {\n    /// Finds the best approximation of a [`Rational`] using a denominator no greater than a\n    /// specified maximum, mutating the [`Rational`] in place.\n    ///\n    /// See [`Rational::approximate`] for more information.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2 \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// - If `max_denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::arithmetic::traits::ApproximateAssign;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::exact_from(std::f64::consts::PI);\n    /// x.approximate_assign(&Natural::from(1000u32));\n    /// assert_eq!(x.to_string(), \"355/113\");\n    ///\n    /// let mut x = Rational::from_signeds(333i32, 1000);\n    /// x.approximate_assign(&Natural::from(100u32));\n    /// assert_eq!(x.to_string(), \"1/3\");\n    /// ```\n    fn approximate_assign(&mut self, max_denominator: &Natural) {\n        assert_ne!(*max_denominator, 0);\n        if self.denominator_ref() <= max_denominator {\n        } else if *max_denominator == 1u32 {\n            *self = Self::from(Integer::rounding_from(&*self, Nearest).0);\n        } else {\n            *self = approximate_helper(&*self, max_denominator);\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/ceiling.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{Ceiling, CeilingAssign, DivRound, DivRoundAssign};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nimpl Ceiling for Rational {\n    type Output = Integer;\n\n    /// Finds the ceiling of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// $$\n    /// f(x) = \\lceil x \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Ceiling;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ZERO.ceiling(), 0);\n    /// assert_eq!(Rational::from_signeds(22, 7).ceiling(), 4);\n    /// assert_eq!(Rational::from_signeds(-22, 7).ceiling(), -3);\n    /// ```\n    fn ceiling(self) -> Integer {\n        if self.sign {\n            Integer::from(self.numerator.div_round(self.denominator, Ceiling).0)\n        } else {\n            Integer::from_sign_and_abs(false, self.numerator / self.denominator)\n        }\n    }\n}\n\nimpl Ceiling for &Rational {\n    type Output = Integer;\n\n    /// Finds the ceiling of a [`Rational`], taking the [`Rational`] by reference.\n    ///\n    /// $$\n    /// f(x) = \\lceil x \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Ceiling;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Rational::ZERO).ceiling(), 0);\n    /// assert_eq!((&Rational::from_signeds(22, 7)).ceiling(), 4);\n    /// assert_eq!((&Rational::from_signeds(-22, 7)).ceiling(), -3);\n    /// ```\n    fn ceiling(self) -> Integer {\n        if self.sign {\n            Integer::from((&self.numerator).div_round(&self.denominator, Ceiling).0)\n        } else {\n            Integer::from_sign_and_abs(false, &self.numerator / &self.denominator)\n        }\n    }\n}\n\nimpl CeilingAssign for Rational {\n    /// Replaces a [`Rational`] with its ceiling.\n    ///\n    /// $$\n    /// x \\gets \\lceil x \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ZERO;\n    /// x.ceiling_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.ceiling_assign();\n    /// assert_eq!(x, 4);\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.ceiling_assign();\n    /// assert_eq!(x, -3);\n    /// ```\n    fn ceiling_assign(&mut self) {\n        let mut d = Natural::ONE;\n        swap(&mut self.denominator, &mut d);\n        if self.sign {\n            self.numerator.div_round_assign(d, Ceiling);\n        } else {\n            self.numerator /= d;\n            if !self.sign && self.numerator == 0 {\n                self.sign = true;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/denominators_in_closed_interval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::traits::{DenominatorsInClosedInterval, SimplestRationalInInterval};\nuse crate::exhaustive::{\n    exhaustive_rationals_with_denominator_inclusive_range,\n    exhaustive_rationals_with_denominator_range,\n};\nuse alloc::collections::BTreeSet;\nuse malachite_base::num::arithmetic::traits::{Ceiling, Reciprocal, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::factorization::traits::Primes;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::Limb;\n\n// Returns a k such that for all n >= k, any closed interval with the given diameter is guaranteed\n// to contain rationals with (reduced) denominator n.\nfn smallest_guaranteed_denominator(interval_diameter: &Rational) -> Natural {\n    if *interval_diameter >= 1u32 {\n        return Natural::ONE;\n    }\n    let mut primorial = Natural::TWO;\n    let mut pow = Natural::TWO;\n    for p in Limb::primes().skip(1) {\n        primorial *= Natural::from(p);\n        pow <<= 1;\n        let limit = Rational::from_naturals_ref(&pow, &primorial);\n        if *interval_diameter >= limit {\n            return primorial;\n        }\n    }\n    panic!();\n}\n\nfn smallest_likely_denominator(interval_diameter: &Rational) -> Natural {\n    interval_diameter.reciprocal().ceiling().unsigned_abs()\n}\n\n/// Returns an iterator of all denominators that appear in the [`Rational`]s contained in a closed\n/// interval.\n///\n/// This `struct` is created by [`DenominatorsInClosedInterval::denominators_in_closed_interval`];\n/// see its documentation for more.\n#[derive(Clone, Debug)]\npub struct DenominatorsInClosedRationalInterval {\n    a: Rational,\n    b: Rational,\n    low_threshold: Natural,\n    high_threshold: Natural,\n    current: Natural,\n    points: BTreeSet<Rational>,\n}\n\nimpl Iterator for DenominatorsInClosedRationalInterval {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.current >= self.high_threshold {\n            self.points.clear();\n            self.current += Natural::ONE;\n            Some(self.current.clone())\n        } else if self.current >= self.low_threshold {\n            self.points.clear();\n            loop {\n                self.current += Natural::ONE;\n                if exhaustive_rationals_with_denominator_inclusive_range(\n                    self.current.clone(),\n                    self.a.clone(),\n                    self.b.clone(),\n                )\n                .next()\n                .is_some()\n                {\n                    return Some(self.current.clone());\n                }\n            }\n        } else if self.points.is_empty() {\n            assert_eq!(self.current, 0u32);\n            self.points.insert(self.a.clone());\n            self.points.insert(self.b.clone());\n            self.points\n                .insert(Rational::simplest_rational_in_open_interval(\n                    &self.a, &self.b,\n                ));\n            let mut min_denominator = self.a.denominator_ref();\n            for p in &self.points {\n                let pd = p.denominator_ref();\n                if pd < min_denominator {\n                    min_denominator = pd;\n                }\n            }\n            self.current = min_denominator.clone();\n            for p in exhaustive_rationals_with_denominator_range(\n                self.current.clone(),\n                self.a.clone(),\n                self.b.clone(),\n            ) {\n                self.points.insert(p);\n            }\n            Some(self.current.clone())\n        } else {\n            let mut previous_point = None;\n            let mut min_interior_denominator = None;\n            for p in &self.points {\n                if let Some(previous) = previous_point {\n                    let interior_denominator =\n                        Rational::simplest_rational_in_open_interval(previous, p)\n                            .into_denominator();\n                    if let Some(previous_min) = min_interior_denominator.as_ref() {\n                        if interior_denominator < *previous_min {\n                            min_interior_denominator = Some(interior_denominator);\n                        }\n                    } else {\n                        min_interior_denominator = Some(interior_denominator);\n                    }\n                }\n                previous_point = Some(p);\n            }\n            let min_interior_denominator = min_interior_denominator.unwrap();\n            assert!(min_interior_denominator > self.current);\n            let mut min_denominator = min_interior_denominator;\n            for p in &self.points {\n                let pd = p.denominator_ref();\n                if *pd > self.current && *pd < min_denominator {\n                    min_denominator = pd.clone();\n                }\n            }\n            self.current = min_denominator;\n            for p in exhaustive_rationals_with_denominator_range(\n                self.current.clone(),\n                self.a.clone(),\n                self.b.clone(),\n            ) {\n                self.points.insert(p);\n            }\n            Some(self.current.clone())\n        }\n    }\n}\n\nimpl DenominatorsInClosedInterval for Rational {\n    type Denominators = DenominatorsInClosedRationalInterval;\n\n    /// Returns an iterator of all denominators that appear in the [`Rational`]s contained in a\n    /// closed interval.\n    ///\n    /// For example, consider the interval $[1/3, 1/2]$. It contains no integers, so no\n    /// [`Rational`]s with denominator 1. It does contain [`Rational`]s with denominators 2 and 3\n    /// (the endpoints). It contains none with denominator 4, but it does contain $2/5$. It contains\n    /// none with denominator 6 (though $1/3$ and $1/2$ are $2/6$ and $3/6$, those representations\n    /// are not reduced). It contains $3/7$, $3/8$, and $4/9$ but none with denominator 10 ($0.4$\n    /// does not count because it is $2/5$). It contains all denominators greater than 10, so the\n    /// complete list is $2, 3, 5, 7, 8, 9, 11, 12, 13, \\ldots$.\n    ///\n    /// # Worst-case complexity per iteration\n    /// $T(n, i) = O(n + \\log i)$\n    ///\n    /// $M(n, i) = O(n + \\log i)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $i$ is the iteration number, and $n$ is\n    /// `max(a.significant_bits(), b.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if $a \\geq b$.\n    ///\n    /// ```\n    /// use malachite_base::iterators::prefix_to_string;\n    /// use malachite_base::num::basic::traits::{One, Two};\n    /// use malachite_q::arithmetic::traits::DenominatorsInClosedInterval;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     prefix_to_string(\n    ///         Rational::denominators_in_closed_interval(Rational::ONE, Rational::TWO),\n    ///         20\n    ///     ),\n    ///     \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...]\"\n    /// );\n    /// assert_eq!(\n    ///     prefix_to_string(\n    ///         Rational::denominators_in_closed_interval(\n    ///             Rational::from_signeds(1, 3),\n    ///             Rational::from_signeds(1, 2)\n    ///         ),\n    ///         20\n    ///     ),\n    ///     \"[2, 3, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ...]\"\n    /// );\n    /// assert_eq!(\n    ///     prefix_to_string(\n    ///         Rational::denominators_in_closed_interval(\n    ///             Rational::from_signeds(1, 1000001),\n    ///             Rational::from_signeds(1, 1000000)\n    ///         ),\n    ///         20\n    ///     ),\n    ///     \"[1000000, 1000001, 2000001, 3000001, 3000002, 4000001, 4000003, 5000001, 5000002, \\\n    ///     5000003, 5000004, 6000001, 6000005, 7000001, 7000002, 7000003, 7000004, 7000005, \\\n    ///     7000006, 8000001, ...]\"\n    /// );\n    /// ```\n    fn denominators_in_closed_interval(\n        a: Rational,\n        b: Rational,\n    ) -> DenominatorsInClosedRationalInterval {\n        assert!(a < b);\n        let diameter = &b - &a;\n        let (mut low_threshold, high_threshold) = if diameter >= 1u32 {\n            (Natural::ZERO, Natural::ZERO)\n        } else {\n            (\n                smallest_likely_denominator(&diameter),\n                smallest_guaranteed_denominator(&diameter),\n            )\n        };\n        if low_threshold < 100u32 {\n            low_threshold = Natural::ZERO;\n        }\n        DenominatorsInClosedRationalInterval {\n            a,\n            b,\n            low_threshold,\n            high_threshold,\n            current: Natural::ZERO,\n            points: BTreeSet::new(),\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// CheckedDiv implementation by Park Joon-Kyu.\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1994-1996, 2000, 2001, 2015, 2018 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::ops::{Div, DivAssign};\nuse malachite_base::num::arithmetic::traits::{\n    CheckedDiv, DivExact, DivExactAssign, Gcd, Reciprocal,\n};\nuse malachite_base::num::basic::traits::Zero;\n\nimpl Div<Self> for Rational {\n    type Output = Self;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if the second [`Rational`] is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::TWO / Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) / Rational::from_signeds(99, 100)).to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    fn div(self, other: Self) -> Self {\n        if other == 0u32 {\n            panic!(\"division by zero\");\n        } else if self == 0u32 {\n            return Self::ZERO;\n        } else if self == 1u32 {\n            return other.reciprocal();\n        } else if other == 1u32 {\n            return self;\n        }\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        Self {\n            sign: self.sign == other.sign,\n            numerator: (self.numerator).div_exact(&g_1) * (other.denominator).div_exact(&g_2),\n            denominator: (other.numerator).div_exact(g_1) * (self.denominator).div_exact(g_2),\n        }\n    }\n}\n\nimpl Div<&Self> for Rational {\n    type Output = Self;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking the first by value and the second by\n    /// reference.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if the second [`Rational`] is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::TWO / &Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) / &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    #[inline]\n    fn div(self, other: &Self) -> Self {\n        if *other == 0u32 {\n            panic!(\"division by zero\");\n        } else if self == 0u32 {\n            Self::ZERO\n        } else {\n            (other / self).reciprocal()\n        }\n    }\n}\n\nimpl Div<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking the first by reference and the second\n    /// by value.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if the second [`Rational`] is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::TWO / Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) / Rational::from_signeds(99, 100)).to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    fn div(self, other: Rational) -> Rational {\n        if other == 0u32 {\n            panic!(\"division by zero\");\n        } else if *self == 0u32 {\n            return Rational::ZERO;\n        } else if *self == 1u32 {\n            return other.reciprocal();\n        } else if other == 1u32 {\n            return self.clone();\n        }\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        Rational {\n            sign: self.sign == other.sign,\n            numerator: (&self.numerator).div_exact(&g_1) * (other.denominator).div_exact(&g_2),\n            denominator: (other.numerator).div_exact(g_1) * (&self.denominator).div_exact(g_2),\n        }\n    }\n}\n\nimpl Div<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = \\frac{x}{y}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if the second [`Rational`] is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::TWO / &Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) / &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    fn div(self, other: &Rational) -> Rational {\n        if *other == 0u32 {\n            panic!(\"division by zero\");\n        } else if *self == 0u32 {\n            return Rational::ZERO;\n        } else if *self == 1u32 {\n            return other.reciprocal();\n        } else if *other == 1u32 {\n            return self.clone();\n        }\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        Rational {\n            sign: self.sign == other.sign,\n            numerator: (&self.numerator).div_exact(&g_1) * (&other.denominator).div_exact(&g_2),\n            denominator: (&other.numerator).div_exact(g_1) * (&self.denominator).div_exact(g_2),\n        }\n    }\n}\n\nimpl CheckedDiv<Self> for Rational {\n    type Output = Self;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking both by value. Returns `None` when\n    /// the second [`Rational`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\frac{x}{y} \\right ) & \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::TWO.checked_div(Rational::TWO).unwrap(), 1);\n    /// assert_eq!(Rational::TWO.checked_div(Rational::ZERO), None);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7).checked_div(Rational::from_signeds(99, 100)))\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    fn checked_div(self, other: Self) -> Option<Self> {\n        if other == 0u32 {\n            return None;\n        } else if self == 0u32 {\n            return Some(Self::ZERO);\n        } else if self == 1u32 {\n            return Some(other.reciprocal());\n        } else if other == 1u32 {\n            return Some(self);\n        }\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        Some(Self {\n            sign: self.sign == other.sign,\n            numerator: (self.numerator).div_exact(&g_1) * (other.denominator).div_exact(&g_2),\n            denominator: (other.numerator).div_exact(g_1) * (self.denominator).div_exact(g_2),\n        })\n    }\n}\n\nimpl CheckedDiv<&Self> for Rational {\n    type Output = Self;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking the first by value and the second by\n    /// reference. Returns `None` when the second [`Rational`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\frac{x}{y} \\right ) & \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::TWO.checked_div(&Rational::TWO).unwrap(), 1);\n    /// assert_eq!(Rational::TWO.checked_div(&Rational::ZERO), None);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7).checked_div(&Rational::from_signeds(99, 100)))\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    #[inline]\n    fn checked_div(self, other: &Self) -> Option<Self> {\n        if other == &0u32 {\n            None\n        } else if self == 0u32 {\n            Some(Self::ZERO)\n        } else {\n            (other.checked_div(self)).map(Self::reciprocal)\n        }\n    }\n}\n\nimpl CheckedDiv<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking the first by reference and the second\n    /// by value. Returns `None` when the second [`Rational`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\frac{x}{y} \\right ) & \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Rational::TWO).checked_div(Rational::TWO).unwrap(), 1);\n    /// assert_eq!((&Rational::TWO).checked_div(Rational::ZERO), None);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .checked_div(Rational::from_signeds(99, 100))\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    fn checked_div(self, other: Rational) -> Option<Rational> {\n        if other == 0u32 {\n            return None;\n        } else if *self == 0u32 {\n            return Some(Rational::ZERO);\n        } else if *self == 1u32 {\n            return Some(other.reciprocal());\n        } else if other == 1u32 {\n            return Some(self.clone());\n        }\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        Some(Rational {\n            sign: self.sign == other.sign,\n            numerator: (&self.numerator).div_exact(&g_1) * (other.denominator).div_exact(&g_2),\n            denominator: (other.numerator).div_exact(g_1) * (&self.denominator).div_exact(g_2),\n        })\n    }\n}\n\nimpl CheckedDiv<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Divides a [`Rational`] by another [`Rational`], taking both by reference. Returns `None`\n    /// when the second [`Rational`] is zero, `Some` otherwise.\n    ///\n    /// $$\n    /// f(x, y) = \\begin{cases}\n    ///     \\operatorname{Some}\\left ( \\frac{x}{y} \\right ) & \\text{if} \\\\quad y \\neq 0 \\\\\\\\\n    ///     \\text{None} & \\text{otherwise}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedDiv;\n    /// use malachite_base::num::basic::traits::{Two, Zero};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Rational::TWO).checked_div(&Rational::TWO).unwrap(), 1);\n    /// assert_eq!((&Rational::TWO).checked_div(&Rational::ZERO), None);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .checked_div(&Rational::from_signeds(99, 100))\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"200/63\"\n    /// );\n    /// ```\n    fn checked_div(self, other: &Rational) -> Option<Rational> {\n        if *other == 0u32 {\n            return None;\n        } else if *self == 0u32 {\n            return Some(Rational::ZERO);\n        } else if *self == 1u32 {\n            return Some(other.reciprocal());\n        } else if *other == 1u32 {\n            return Some(self.clone());\n        }\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        Some(Rational {\n            sign: self.sign == other.sign,\n            numerator: (&self.numerator).div_exact(&g_1) * (&other.denominator).div_exact(&g_2),\n            denominator: (&other.numerator).div_exact(g_1) * (&self.denominator).div_exact(g_2),\n        })\n    }\n}\n\nimpl DivAssign<Self> for Rational {\n    /// Divides a [`Rational`] by a [`Rational`] in place, taking the [`Rational`] on the right-hand\n    /// side by value.\n    ///\n    /// $$\n    /// x \\gets \\frac{x}{y}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if the second [`Rational`] is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::TWO;\n    /// x /= Rational::TWO;\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x /= Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"200/63\");\n    /// ```\n    fn div_assign(&mut self, other: Self) {\n        if other == 0u32 {\n            panic!(\"division by zero\");\n        } else if *self == 0u32 || other == 1u32 {\n            return;\n        } else if *self == 1u32 {\n            *self = other.reciprocal();\n            return;\n        }\n        self.sign = self.sign == other.sign;\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        self.numerator.div_exact_assign(&g_1);\n        self.denominator.div_exact_assign(&g_2);\n        self.numerator *= (other.denominator).div_exact(g_2);\n        self.denominator *= (other.numerator).div_exact(g_1);\n    }\n}\n\nimpl DivAssign<&Self> for Rational {\n    /// Divides a [`Rational`] by a [`Rational`] in place, taking the [`Rational`] on the right-hand\n    /// side by reference.\n    ///\n    /// $$\n    /// x \\gets \\frac{x}{y}.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if the second [`Rational`] is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Two;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::TWO;\n    /// x /= &Rational::TWO;\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x /= &Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"200/63\");\n    /// ```\n    fn div_assign(&mut self, other: &Self) {\n        if *other == 0u32 {\n            panic!(\"division by zero\");\n        } else if *self == 0u32 || *other == 1u32 {\n            return;\n        } else if *self == 1u32 {\n            *self = other.reciprocal();\n            return;\n        }\n        self.sign = self.sign == other.sign;\n        let g_1 = (&self.numerator).gcd(&other.numerator);\n        let g_2 = (&other.denominator).gcd(&self.denominator);\n        self.numerator.div_exact_assign(&g_1);\n        self.denominator.div_exact_assign(&g_2);\n        self.numerator *= (&other.denominator).div_exact(g_2);\n        self.denominator *= (&other.numerator).div_exact(g_1);\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/floor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{DivRound, DivRoundAssign, Floor, FloorAssign};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nimpl Floor for Rational {\n    type Output = Integer;\n\n    /// Finds the floor of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// $$\n    /// f(x) = \\lfloor x \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Floor;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ZERO.floor(), 0);\n    /// assert_eq!(Rational::from_signeds(22, 7).floor(), 3);\n    /// assert_eq!(Rational::from_signeds(-22, 7).floor(), -4);\n    /// ```\n    fn floor(self) -> Integer {\n        if self.sign {\n            Integer::from(self.numerator / self.denominator)\n        } else {\n            Integer::from_sign_and_abs(false, self.numerator.div_round(self.denominator, Ceiling).0)\n        }\n    }\n}\n\nimpl Floor for &Rational {\n    type Output = Integer;\n\n    /// Finds the floor of a [`Rational`], taking the [`Rational`] by reference.\n    ///\n    /// $$\n    /// f(x) = \\lfloor x \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Floor;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Rational::ZERO).floor(), 0);\n    /// assert_eq!((&Rational::from_signeds(22, 7)).floor(), 3);\n    /// assert_eq!((&Rational::from_signeds(-22, 7)).floor(), -4);\n    /// ```\n    fn floor(self) -> Integer {\n        if self.sign {\n            Integer::from(&self.numerator / &self.denominator)\n        } else {\n            Integer::from_sign_and_abs(\n                false,\n                (&self.numerator).div_round(&self.denominator, Ceiling).0,\n            )\n        }\n    }\n}\n\nimpl FloorAssign for Rational {\n    /// Replaces a [`Rational`] with its floor.\n    ///\n    /// $$\n    /// x \\gets \\lfloor x \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ZERO;\n    /// x.floor_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.floor_assign();\n    /// assert_eq!(x, 3);\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.floor_assign();\n    /// assert_eq!(x, -4);\n    /// ```\n    fn floor_assign(&mut self) {\n        let mut d = Natural::ONE;\n        swap(&mut self.denominator, &mut d);\n        if self.sign {\n            self.numerator /= d;\n        } else {\n            self.numerator.div_round_assign(d, Ceiling);\n            if !self.sign && self.numerator == 0 {\n                self.sign = true;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\n\nimpl IsPowerOf2 for Rational {\n    /// Determines whether a [`Rational`] is an integer power of 2.\n    ///\n    /// $f(x) = (\\exists n \\in \\Z : 2^n = x)$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::IsPowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(0x80).is_power_of_2(), true);\n    /// assert_eq!(Rational::from_signeds(1, 8).is_power_of_2(), true);\n    /// assert_eq!(Rational::from_signeds(-1, 8).is_power_of_2(), false);\n    /// assert_eq!(Rational::from_signeds(22, 7).is_power_of_2(), false);\n    /// ```\n    fn is_power_of_2(&self) -> bool {\n        self.sign\n            && (self.denominator == 1u32 && self.numerator.is_power_of_2()\n                || self.numerator == 1u32 && self.denominator.is_power_of_2())\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the FLINT Library.\n//\n//      Copyright (C) 2011 Fredrik Johansson\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase, CeilingLogBasePowerOf2, CheckedLogBase, CheckedLogBase2,\n    CheckedLogBasePowerOf2, FloorLogBase, FloorLogBasePowerOf2, Pow,\n};\nuse malachite_base::num::comparison::traits::OrdAbs;\nuse malachite_base::num::conversion::traits::{RoundingFrom, SciMantissaAndExponent};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nfn approx_log_helper(x: &Rational) -> f64 {\n    let (mantissa, exponent): (f64, i64) = x.sci_mantissa_and_exponent();\n    mantissa.ln() + (exponent as f64) * core::f64::consts::LN_2\n}\n\nimpl Rational {\n    /// Calculates the approximate natural logarithm of a positive [`Rational`].\n    ///\n    /// $f(x) = (1+\\varepsilon)(\\log x)$, where $|\\varepsilon| < 2^{-52}.$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::{Pow, PowerOf2};\n    /// use malachite_base::num::float::NiceFloat;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     NiceFloat(Rational::from(10i32).approx_log()),\n    ///     NiceFloat(2.3025850929940455)\n    /// );\n    /// assert_eq!(\n    ///     NiceFloat(Rational::from(10i32).pow(100u64).approx_log()),\n    ///     NiceFloat(230.25850929940455)\n    /// );\n    /// assert_eq!(\n    ///     NiceFloat(Rational::power_of_2(1000000u64).approx_log()),\n    ///     NiceFloat(693147.1805599453)\n    /// );\n    /// assert_eq!(\n    ///     NiceFloat(Rational::power_of_2(-1000000i64).approx_log()),\n    ///     NiceFloat(-693147.1805599453)\n    /// );\n    /// ```\n    ///\n    /// This is equivalent to `fmpz_dlog` from `fmpz/dlog.c`, FLINT 2.7.1.\n    #[inline]\n    pub fn approx_log(&self) -> f64 {\n        assert!(*self > 0u32);\n        approx_log_helper(self)\n    }\n}\n\n// # Worst-case complexity\n// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n//\n// $M(n, m) = O(nm \\log (nm))$\n//\n// where $T$ is time, $M$ is additional memory, $n$ is `base.significant_bits()`, and $m$ is\n// $|\\log_b x|$, where $b$ is `base` and $x$ is `x`.\npub(crate) fn log_base_helper(x: &Rational, base: &Rational) -> (i64, bool) {\n    assert!(*base > 0u32);\n    assert_ne!(*base, 1u32);\n    if *x == 1u32 {\n        return (0, true);\n    }\n    let mut log = i64::rounding_from(approx_log_helper(x) / approx_log_helper(base), Floor).0;\n    let mut power = base.pow(log);\n    if *base > 1u32 {\n        match power.cmp_abs(x) {\n            Equal => (log, true),\n            Less => loop {\n                power *= base;\n                match power.cmp_abs(x) {\n                    Equal => {\n                        return (log + 1, true);\n                    }\n                    Less => {\n                        log += 1;\n                    }\n                    Greater => {\n                        return (log, false);\n                    }\n                }\n            },\n            Greater => loop {\n                power /= base;\n                match power.cmp_abs(x) {\n                    Equal => {\n                        return (log - 1, true);\n                    }\n                    Less => {\n                        return (log - 1, false);\n                    }\n                    Greater => {\n                        log -= 1;\n                    }\n                }\n            },\n        }\n    } else {\n        match power.cmp_abs(x) {\n            Equal => (log, true),\n            Less => loop {\n                power /= base;\n                match power.cmp_abs(x) {\n                    Equal => {\n                        return (log - 1, true);\n                    }\n                    Less => {\n                        log -= 1;\n                    }\n                    Greater => {\n                        return (log - 1, false);\n                    }\n                }\n            },\n            Greater => loop {\n                power *= base;\n                match power.cmp_abs(x) {\n                    Equal => {\n                        return (log + 1, true);\n                    }\n                    Less => {\n                        return (log, false);\n                    }\n                    Greater => {\n                        log += 1;\n                    }\n                }\n            },\n        }\n    }\n}\n\nimpl FloorLogBase<&Rational> for &Rational {\n    type Output = i64;\n\n    /// Returns the floor of the base-$b$ logarithm of a positive [`Rational`].\n    ///\n    /// Note that this function may be slow if the base is very close to 1.\n    ///\n    /// $f(x, b) = \\lfloor\\log_b x\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `base.significant_bits()`, and $m$ is\n    /// $|\\log_b x|$, where $b$ is `base` and $x$ is `x`.\n    ///\n    /// # Panics\n    /// Panics if `self` less than or equal to zero or `base` is 1.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorLogBase;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(80u32).floor_log_base(&Rational::from(3u32)),\n    ///     3\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(81u32).floor_log_base(&Rational::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(82u32).floor_log_base(&Rational::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(4294967296u64).floor_log_base(&Rational::from(10u32)),\n    ///     9\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(936851431250i64, 1397).floor_log_base(&Rational::from(10u32)),\n    ///     8\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(5153632, 16807).floor_log_base(&Rational::from_signeds(22, 7)),\n    ///     5\n    /// );\n    /// ```\n    fn floor_log_base(self, base: &Rational) -> i64 {\n        assert!(*self > 0u32);\n        if let Some(log_base) = base.checked_log_base_2() {\n            return self.floor_log_base_power_of_2(log_base);\n        }\n        log_base_helper(self, base).0\n    }\n}\n\nimpl CeilingLogBase<&Rational> for &Rational {\n    type Output = i64;\n\n    /// Returns the ceiling of the base-$b$ logarithm of a positive [`Rational`].\n    ///\n    /// Note that this function may be slow if the base is very close to 1.\n    ///\n    /// $f(x, b) = \\lceil\\log_b x\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `base.significant_bits()`, and $m$ is\n    /// $|\\log_b x|$, where $b$ is `base` and $x$ is `x`.\n    ///\n    /// # Panics\n    /// Panics if `self` less than or equal to zero or `base` is 1.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingLogBase;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(80u32).ceiling_log_base(&Rational::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(81u32).ceiling_log_base(&Rational::from(3u32)),\n    ///     4\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(82u32).ceiling_log_base(&Rational::from(3u32)),\n    ///     5\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(4294967296u64).ceiling_log_base(&Rational::from(10u32)),\n    ///     10\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(936851431250i64, 1397).ceiling_log_base(&Rational::from(10u32)),\n    ///     9\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(5153632, 16807).ceiling_log_base(&Rational::from_signeds(22, 7)),\n    ///     5\n    /// );\n    /// ```\n    fn ceiling_log_base(self, base: &Rational) -> i64 {\n        assert!(*self > 0u32);\n        if let Some(log_base) = base.checked_log_base_2() {\n            return self.ceiling_log_base_power_of_2(log_base);\n        }\n        let (log, exact) = log_base_helper(self, base);\n        if exact { log } else { log + 1 }\n    }\n}\n\nimpl CheckedLogBase<&Rational> for &Rational {\n    type Output = i64;\n\n    /// Returns the base-$b$ logarithm of a positive [`Rational`]. If the [`Rational`] is not a\n    /// power of $b$, then `None` is returned.\n    ///\n    /// Note that this function may be slow if the base is very close to 1.\n    ///\n    /// $$\n    /// f(x, b) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\log_b x) & \\text{if} \\\\quad \\log_b x \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `base.significant_bits()`, and $m$ is\n    /// $|\\log_b x|$, where $b$ is `base` and $x$ is `x`.\n    ///\n    /// # Panics\n    /// Panics if `self` less than or equal to zero or `base` is 1.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedLogBase;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(80u32).checked_log_base(&Rational::from(3u32)),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(81u32).checked_log_base(&Rational::from(3u32)),\n    ///     Some(4)\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(82u32).checked_log_base(&Rational::from(3u32)),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(4294967296u64).checked_log_base(&Rational::from(10u32)),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(936851431250i64, 1397).checked_log_base(&Rational::from(10u32)),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(5153632, 16807).checked_log_base(&Rational::from_signeds(22, 7)),\n    ///     Some(5)\n    /// );\n    /// ```\n    fn checked_log_base(self, base: &Rational) -> Option<i64> {\n        assert!(*self > 0u32);\n        if let Some(log_base) = base.checked_log_base_2() {\n            return self.checked_log_base_power_of_2(log_base);\n        }\n        let (log, exact) = log_base_helper(self, base);\n        if exact { Some(log) } else { None }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, CheckedLogBase2, FloorLogBase2, IsPowerOf2,\n};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nimpl Rational {\n    /// Returns the floor of the base-2 logarithm of the absolute value of a nonzero [`Rational`].\n    ///\n    /// $f(x) = \\lfloor\\log_2 |x|\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(3u32).floor_log_base_2_abs(), 1);\n    /// assert_eq!(Rational::from_signeds(1, 3).floor_log_base_2_abs(), -2);\n    /// assert_eq!(Rational::from_signeds(1, 4).floor_log_base_2_abs(), -2);\n    /// assert_eq!(Rational::from_signeds(1, 5).floor_log_base_2_abs(), -3);\n    ///\n    /// assert_eq!(Rational::from(-3).floor_log_base_2_abs(), 1);\n    /// assert_eq!(Rational::from_signeds(-1, 3).floor_log_base_2_abs(), -2);\n    /// assert_eq!(Rational::from_signeds(-1, 4).floor_log_base_2_abs(), -2);\n    /// assert_eq!(Rational::from_signeds(-1, 5).floor_log_base_2_abs(), -3);\n    /// ```\n    pub fn floor_log_base_2_abs(&self) -> i64 {\n        let exponent = i64::exact_from(self.numerator.significant_bits())\n            - i64::exact_from(self.denominator.significant_bits());\n        if self.numerator.cmp_normalized(&self.denominator) == Less {\n            exponent - 1\n        } else {\n            exponent\n        }\n    }\n\n    /// Returns the ceiling of the base-2 logarithm of the absolute value of a nonzero [`Rational`].\n    ///\n    /// $f(x) = \\lfloor\\log_2 |x|\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` less than or equal to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(3u32).ceiling_log_base_2_abs(), 2);\n    /// assert_eq!(Rational::from_signeds(1, 3).ceiling_log_base_2_abs(), -1);\n    /// assert_eq!(Rational::from_signeds(1, 4).ceiling_log_base_2_abs(), -2);\n    /// assert_eq!(Rational::from_signeds(1, 5).ceiling_log_base_2_abs(), -2);\n    ///\n    /// assert_eq!(Rational::from(-3).ceiling_log_base_2_abs(), 2);\n    /// assert_eq!(Rational::from_signeds(-1, 3).ceiling_log_base_2_abs(), -1);\n    /// assert_eq!(Rational::from_signeds(-1, 4).ceiling_log_base_2_abs(), -2);\n    /// assert_eq!(Rational::from_signeds(-1, 5).ceiling_log_base_2_abs(), -2);\n    /// ```\n    pub fn ceiling_log_base_2_abs(&self) -> i64 {\n        let exponent = i64::exact_from(self.numerator.significant_bits())\n            - i64::exact_from(self.denominator.significant_bits());\n        if self.numerator.cmp_normalized(&self.denominator) == Greater {\n            exponent + 1\n        } else {\n            exponent\n        }\n    }\n}\n\nimpl FloorLogBase2 for &Rational {\n    type Output = i64;\n\n    /// Returns the floor of the base-2 logarithm of a positive [`Rational`].\n    ///\n    /// $f(x) = \\lfloor\\log_2 x\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` less than or equal to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorLogBase2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(3u32).floor_log_base_2(), 1);\n    /// assert_eq!(Rational::from_signeds(1, 3).floor_log_base_2(), -2);\n    /// assert_eq!(Rational::from_signeds(1, 4).floor_log_base_2(), -2);\n    /// assert_eq!(Rational::from_signeds(1, 5).floor_log_base_2(), -3);\n    /// ```\n    #[inline]\n    fn floor_log_base_2(self) -> i64 {\n        assert!(*self > 0u32);\n        self.floor_log_base_2_abs()\n    }\n}\n\nimpl CeilingLogBase2 for &Rational {\n    type Output = i64;\n\n    /// Returns the ceiling of the base-2 logarithm of a positive [`Rational`].\n    ///\n    /// $f(x) = \\lfloor\\log_2 x\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` less than or equal to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingLogBase2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(3u32).ceiling_log_base_2(), 2);\n    /// assert_eq!(Rational::from_signeds(1, 3).ceiling_log_base_2(), -1);\n    /// assert_eq!(Rational::from_signeds(1, 4).ceiling_log_base_2(), -2);\n    /// assert_eq!(Rational::from_signeds(1, 5).ceiling_log_base_2(), -2);\n    /// ```\n    #[inline]\n    fn ceiling_log_base_2(self) -> i64 {\n        assert!(*self > 0u32);\n        self.ceiling_log_base_2_abs()\n    }\n}\n\nimpl CheckedLogBase2 for &Rational {\n    type Output = i64;\n\n    /// Returns the base-2 logarithm of a positive [`Rational`]. If the [`Rational`] is not a power\n    /// of 2, then `None` is returned.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\log_2 x) & \\text{if} \\\\quad \\log_2 x \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is less than or equal to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedLogBase2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(3u32).checked_log_base_2(), None);\n    /// assert_eq!(Rational::from_signeds(1, 3).checked_log_base_2(), None);\n    /// assert_eq!(Rational::from_signeds(1, 4).checked_log_base_2(), Some(-2));\n    /// assert_eq!(Rational::from_signeds(1, 5).checked_log_base_2(), None);\n    /// ```\n    fn checked_log_base_2(self) -> Option<i64> {\n        assert!(*self > 0u32);\n        if self.denominator == 1u32 && self.numerator.is_power_of_2() {\n            Some(i64::exact_from(self.numerator.significant_bits()) - 1)\n        } else if self.numerator == 1u32 && self.denominator.is_power_of_2() {\n            Some(1 - i64::exact_from(self.denominator.significant_bits()))\n        } else {\n            None\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, CeilingLogBasePowerOf2, CheckedLogBase2, CheckedLogBasePowerOf2, DivMod,\n    DivRound, FloorLogBase2, FloorLogBasePowerOf2, Sign,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\n\nimpl FloorLogBasePowerOf2<i64> for &Rational {\n    type Output = i64;\n\n    /// Returns the floor of the base-$2^k$ logarithm of a positive [`Rational`].\n    ///\n    /// $k$ may be negative.\n    ///\n    /// $f(x, k) = \\lfloor\\log_{2^k} x\\rfloor$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is less than or equal to 0 or `pow` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::FloorLogBasePowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(100).floor_log_base_power_of_2(2), 3);\n    /// assert_eq!(\n    ///     Rational::from(4294967296u64).floor_log_base_power_of_2(8),\n    ///     4\n    /// );\n    ///\n    /// // 4^(-2) < 1/10 < 4^(-1)\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 10).floor_log_base_power_of_2(2),\n    ///     -2\n    /// );\n    /// // (1/4)^2 < 1/10 < (1/4)^1\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 10).floor_log_base_power_of_2(-2),\n    ///     1\n    /// );\n    /// ```\n    fn floor_log_base_power_of_2(self, pow: i64) -> i64 {\n        assert!(*self > 0u32);\n        match pow.sign() {\n            Equal => panic!(\"Cannot take base-1 logarithm\"),\n            Greater => self.floor_log_base_2().div_round(pow, Floor).0,\n            Less => -(self.ceiling_log_base_2().div_round(-pow, Ceiling).0),\n        }\n    }\n}\n\nimpl CeilingLogBasePowerOf2<i64> for &Rational {\n    type Output = i64;\n\n    /// Returns the ceiling of the base-$2^k$ logarithm of a positive [`Rational`].\n    ///\n    /// $k$ may be negative.\n    ///\n    /// $f(x, p) = \\lceil\\log_{2^p} x\\rceil$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is less than or equal to 0 or `pow` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingLogBasePowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(100).ceiling_log_base_power_of_2(2), 4);\n    /// assert_eq!(\n    ///     Rational::from(4294967296u64).ceiling_log_base_power_of_2(8),\n    ///     4\n    /// );\n    ///\n    /// // 4^(-2) < 1/10 < 4^(-1)\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 10).ceiling_log_base_power_of_2(2),\n    ///     -1\n    /// );\n    /// // (1/4)^2 < 1/10 < (1/4)^1\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 10).ceiling_log_base_power_of_2(-2),\n    ///     2\n    /// );\n    /// ```\n    fn ceiling_log_base_power_of_2(self, pow: i64) -> i64 {\n        assert!(*self > 0u32);\n        match pow.sign() {\n            Equal => panic!(\"Cannot take base-1 logarithm\"),\n            Greater => self.ceiling_log_base_2().div_round(pow, Ceiling).0,\n            Less => -self.floor_log_base_2().div_round(-pow, Floor).0,\n        }\n    }\n}\n\nimpl CheckedLogBasePowerOf2<i64> for &Rational {\n    type Output = i64;\n\n    /// Returns the base-$2^k$ logarithm of a positive [`Rational`]. If the [`Rational`] is not a\n    /// power of $2^k$, then `None` is returned.\n    ///\n    /// $k$ may be negative.\n    ///\n    /// $$\n    /// f(x, p) = \\\\begin{cases}\n    ///     \\operatorname{Some}(\\log_{2^p} x) & \\text{if} \\\\quad \\log_{2^p} x \\in \\Z, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is 0 or `pow` is 0.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedLogBasePowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(100).checked_log_base_power_of_2(2), None);\n    /// assert_eq!(\n    ///     Rational::from(4294967296u64).checked_log_base_power_of_2(8),\n    ///     Some(4)\n    /// );\n    ///\n    /// // 4^(-2) < 1/10 < 4^(-1)\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 10).checked_log_base_power_of_2(2),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 16).checked_log_base_power_of_2(2),\n    ///     Some(-2)\n    /// );\n    /// // (1/4)^2 < 1/10 < (1/4)^1\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 10).checked_log_base_power_of_2(-2),\n    ///     None\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 16).checked_log_base_power_of_2(-2),\n    ///     Some(2)\n    /// );\n    /// ```\n    fn checked_log_base_power_of_2(self, pow: i64) -> Option<i64> {\n        assert!(*self > 0u32);\n        let log_base_2 = self.checked_log_base_2()?;\n        let (pow, neg) = match pow.sign() {\n            Equal => panic!(\"Cannot take base-1 logarithm\"),\n            Greater => (pow, false),\n            Less => (-pow, true),\n        };\n        let (log, rem) = log_base_2.div_mod(pow);\n        if rem != 0 {\n            None\n        } else if neg {\n            Some(-log)\n        } else {\n            Some(log)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Absolute value of [`Rational`](super::Rational)s.\npub mod abs;\n/// Implementations of [`AbsDiff`](malachite_base::num::arithmetic::traits::AbsDiff) and\n/// [`AbsDiffAssign`](malachite_base::num::arithmetic::traits::AbsDiffAssign), traits for getting\n/// the absolute value of the difference between two numbers.\npub mod abs_diff;\n/// Addition of [`Rational`](super::Rational)s.\npub mod add;\n/// Implementations of [`Approximate`](traits::Approximate) and\n/// [`ApproximateAssign`](traits::ApproximateAssign), traits for approximating a\n/// [`Rational`](super::Rational) by a [`Rational`](super::Rational) with a bounded denominator.\npub mod approximate;\n/// Implementations of [`Ceiling`](malachite_base::num::arithmetic::traits::Ceiling) and\n/// [`CeilingAssign`](malachite_base::num::arithmetic::traits::CeilingAssign), traits for taking the\n/// ceiling of a number.\npub mod ceiling;\n/// Getting all denominators of [`Rational`](super::Rational)s that appear in a given closed\n/// interval.\npub mod denominators_in_closed_interval;\n/// Division of [`Rational`](super::Rational)s.\npub mod div;\n/// Implementations of [`Floor`](malachite_base::num::arithmetic::traits::Floor) and\n/// [`FloorAssign`](malachite_base::num::arithmetic::traits::FloorAssign), traits for taking the\n/// floor of a number.\npub mod floor;\n/// An implementation of [`IsPowerOf2`](malachite_base::num::arithmetic::traits::IsPowerOf2), a\n/// trait for determining whether a number is an integer power of 2.\npub mod is_power_of_2;\n/// Implementations of traits for taking the base-$b$ logarithm of a number.\n///\n/// The traits are [`FloorLogBase`](malachite_base::num::arithmetic::traits::FloorLogBase),\n/// [`CeilingLogBase`](malachite_base::num::arithmetic::traits::CeilingLogBase), and\n/// [`CheckedLogBase`](malachite_base::num::arithmetic::traits::CheckedLogBase).\npub mod log_base;\n/// Implementations of traits for taking the base-2 logarithm of a number.\n///\n/// The traits are [`FloorLogBase2`](malachite_base::num::arithmetic::traits::FloorLogBase2),\n/// [`CeilingLogBase2`](malachite_base::num::arithmetic::traits::CeilingLogBase2), and\n/// [`CheckedLogBase2`](malachite_base::num::arithmetic::traits::CheckedLogBase2).\npub mod log_base_2;\n/// Implementations of traits for taking the base-$2^k$ logarithm of a number.\n///\n/// The traits are\n/// [`FloorLogBasePowerOf2`](malachite_base::num::arithmetic::traits::FloorLogBasePowerOf2),\n/// [`CeilingLogBasePowerOf2`](malachite_base::num::arithmetic::traits::CeilingLogBasePowerOf2), and\n/// [`CheckedLogBasePowerOf2`](malachite_base::num::arithmetic::traits::CheckedLogBasePowerOf2).\npub mod log_base_power_of_2;\n/// Implementations of traits for finding the remainder of two numbers, subject to various rounding\n/// rules.\n///\n/// These are the traits:\n///\n/// | rounding          | by value or reference      | by mutable reference (assignment)      |\n/// |-------------------|----------------------------|----------------------------------------|\n/// | towards $-\\infty$ | [`Mod`](malachite_base::num::arithmetic::traits::Mod) | [`ModAssign`](malachite_base::num::arithmetic::traits::ModAssign)       |\n/// | towards $\\infty$ | [`CeilingMod`](malachite_base::num::arithmetic::traits::CeilingMod) | [`CeilingModAssign`](malachite_base::num::arithmetic::traits::CeilingModAssign) |\n///\n/// The [`Rem`](core::ops::Rem) trait in the standard library rounds towards 0.\npub mod mod_op;\n/// Multiplication of [`Rational`](super::Rational)s.\npub mod mul;\n/// Negation of [`Rational`](super::Rational)s.\npub mod neg;\n/// Implementations of [`NextPowerOf2`](malachite_base::num::arithmetic::traits::NextPowerOf2) and\n/// [`NextPowerOf2Assign`](malachite_base::num::arithmetic::traits::NextPowerOf2Assign), traits for\n/// getting the next-highest power of 2.\npub mod next_power_of_2;\n/// Implementations of [`Pow`](malachite_base::num::arithmetic::traits::Pow) and\n/// [`PowAssign`](malachite_base::num::arithmetic::traits::PowAssign), traits for raising a number\n/// to a power.\npub mod pow;\n/// Implementations of [`PowerOf2`](malachite_base::num::arithmetic::traits::PowerOf2), a trait for\n/// computing a power of 2.\npub mod power_of_2;\n/// Implementations of [`Reciprocal`](malachite_base::num::arithmetic::traits::Reciprocal) and\n/// [`ReciprocalAssign`](malachite_base::num::arithmetic::traits::ReciprocalAssign), traits for\n/// computing the reciprocal of a number.\npub mod reciprocal;\n/// Implementations of [`CheckedRoot`](malachite_base::num::arithmetic::traits::CheckedRoot), a\n/// trait for computing the root of a number, if the number is a perfect power.\npub mod root;\n/// Implementations of [`RoundToMultiple`](malachite_base::num::arithmetic::traits::RoundToMultiple)\n/// and [`RoundToMultipleAssign`](malachite_base::num::arithmetic::traits::RoundToMultipleAssign),\n/// traits for rounding a number to a multiple of another number.\npub mod round_to_multiple;\n/// Implementations of\n/// [`RoundToMultipleOfPowerOf2`](malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2)\n/// and\n/// [`RoundToMultipleOfPowerOf2Assign`](malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign),\n/// traits for rounding a number to a multiple of a power of 2.\npub mod round_to_multiple_of_power_of_2;\n/// Left-shifting a [`Rational`](super::Rational) (multiplying it by a power of 2).\n///\n/// # shl\n/// ```\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(Rational::ZERO << 10u8, 0);\n/// assert_eq!(Rational::from(123) << 2u16, 492);\n/// assert_eq!((Rational::from_signeds(7, 22) << 2u16).to_string(), \"14/11\");\n///\n/// assert_eq!(Rational::ZERO << 10i8, 0);\n/// assert_eq!(Rational::from(123) << 2i16, 492);\n/// assert_eq!((Rational::from(123) << -2i16).to_string(), \"123/4\");\n/// assert_eq!((Rational::from_signeds(7, 22) << 2i16).to_string(), \"14/11\");\n/// assert_eq!(\n///     (Rational::from_signeds(22, 7) << -2i16).to_string(),\n///     \"11/14\"\n/// );\n///\n/// assert_eq!(&Rational::ZERO << 10u8, 0);\n/// assert_eq!(&Rational::from(123) << 2u16, 492);\n/// assert_eq!(\n///     (&Rational::from_signeds(7, 22) << 2u16).to_string(),\n///     \"14/11\"\n/// );\n///\n/// assert_eq!(&Rational::ZERO << 10i8, 0);\n/// assert_eq!(&Rational::from(123) << 2i16, 492);\n/// assert_eq!((&Rational::from(123) << -2i16).to_string(), \"123/4\");\n/// assert_eq!(\n///     (&Rational::from_signeds(7, 22) << 2i16).to_string(),\n///     \"14/11\"\n/// );\n/// assert_eq!(\n///     (&Rational::from_signeds(22, 7) << -2i16).to_string(),\n///     \"11/14\"\n/// );\n/// ```\n///\n/// # shl_assign\n/// ```\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_q::Rational;\n///\n/// let mut x = Rational::ZERO;\n/// x <<= 10u8;\n/// assert_eq!(x, 0);\n///\n/// let mut x = Rational::from(123);\n/// x <<= 2u16;\n/// assert_eq!(x, 492);\n///\n/// let mut x = Rational::from_signeds(7, 22);\n/// x <<= 2u16;\n/// assert_eq!(x.to_string(), \"14/11\");\n///\n/// let mut x = Rational::ZERO;\n/// x <<= 10i8;\n/// assert_eq!(x, 0);\n///\n/// let mut x = Rational::from(123);\n/// x <<= 2i16;\n/// assert_eq!(x, 492);\n///\n/// let mut x = Rational::from(123);\n/// x <<= -2i16;\n/// assert_eq!(x.to_string(), \"123/4\");\n///\n/// let mut x = Rational::from_signeds(7, 22);\n/// x <<= 2i16;\n/// assert_eq!(x.to_string(), \"14/11\");\n///\n/// let mut x = Rational::from_signeds(22, 7);\n/// x <<= -2i16;\n/// assert_eq!(x.to_string(), \"11/14\");\n/// ```\npub mod shl;\n/// Right-shifting a [`Rational`](super::Rational) (dividing it by a power of 2).\n///\n/// # shr\n/// ```\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(Rational::ZERO >> 10u8, 0);\n/// assert_eq!((Rational::from(123) >> 2u16).to_string(), \"123/4\");\n/// assert_eq!((Rational::from_signeds(22, 7) >> 2u16).to_string(), \"11/14\");\n///\n/// assert_eq!(Rational::ZERO >> 10i8, 0);\n/// assert_eq!((Rational::from(123) >> 2i16).to_string(), \"123/4\");\n/// assert_eq!(Rational::from(123) >> -2i16, 492);\n/// assert_eq!((Rational::from_signeds(22, 7) >> 2i16).to_string(), \"11/14\");\n/// assert_eq!(\n///     (Rational::from_signeds(7, 22) >> -2i16).to_string(),\n///     \"14/11\"\n/// );\n///\n/// assert_eq!(&Rational::ZERO >> 10u8, 0);\n/// assert_eq!((&Rational::from(123) >> 2u16).to_string(), \"123/4\");\n/// assert_eq!(\n///     (&Rational::from_signeds(22, 7) >> 2u16).to_string(),\n///     \"11/14\"\n/// );\n///\n/// assert_eq!(&Rational::ZERO >> 10i8, 0);\n/// assert_eq!((&Rational::from(123) >> 2i16).to_string(), \"123/4\");\n/// assert_eq!(&Rational::from(123) >> -2i16, 492);\n/// assert_eq!(\n///     (&Rational::from_signeds(22, 7) >> 2i16).to_string(),\n///     \"11/14\"\n/// );\n/// assert_eq!(\n///     (&Rational::from_signeds(7, 22) >> -2i16).to_string(),\n///     \"14/11\"\n/// );\n/// ```\n///\n/// # shr_assign\n/// ```\n/// use malachite_base::num::basic::traits::Zero;\n/// use malachite_q::Rational;\n///\n/// let mut x = Rational::ZERO;\n/// x >>= 10u8;\n/// assert_eq!(x, 0);\n///\n/// let mut x = Rational::from(123);\n/// x >>= 2u16;\n/// assert_eq!(x.to_string(), \"123/4\");\n///\n/// let mut x = Rational::from_signeds(22, 7);\n/// x >>= 2u16;\n/// assert_eq!(x.to_string(), \"11/14\");\n///\n/// let mut x = Rational::ZERO;\n/// x >>= 10i8;\n/// assert_eq!(x, 0);\n///\n/// let mut x = Rational::from(123);\n/// x >>= 2i16;\n/// assert_eq!(x.to_string(), \"123/4\");\n///\n/// let mut x = Rational::from(123);\n/// x >>= -2i16;\n/// assert_eq!(x, 492);\n///\n/// let mut x = Rational::from_signeds(22, 7);\n/// x >>= 2i16;\n/// assert_eq!(x.to_string(), \"11/14\");\n///\n/// let mut x = Rational::from_signeds(7, 22);\n/// x >>= -2i16;\n/// assert_eq!(x.to_string(), \"14/11\");\n/// ```\npub mod shr;\n/// An implementation of [`Sign`](malachite_base::num::arithmetic::traits::Sign), a trait for\n/// determining the sign of a number.\npub mod sign;\n/// Functions for finding the simplest (lowest-denominator) [`Rational`](super::Rational) in an\n/// interval.\npub mod simplest_rational_in_interval;\n/// Implementations of [`CheckedSqrt`](malachite_base::num::arithmetic::traits::CheckedSqrt), a\n/// trait for computing the root of a number, if the number is a perfect square.\npub mod sqrt;\n/// Implementations of [`Square`](malachite_base::num::arithmetic::traits::Square) and\n/// [`SquareAssign`](malachite_base::num::arithmetic::traits::SquareAssign), traits for squaring a\n/// number.\npub mod square;\n/// Subtraction of [`Rational`](super::Rational)s.\npub mod sub;\n/// Various traits for performing arithmetic operations on numbers.\npub mod traits;\n"
  },
  {
    "path": "malachite-q/src/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::mem::swap;\nuse core::ops::{Rem, RemAssign};\nuse malachite_base::num::arithmetic::traits::{\n    CeilingMod, CeilingModAssign, DivRound, Mod, ModAssign, UnsignedAbs,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\n\nimpl Mod<Self> for Rational {\n    type Output = Self;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking both\n    /// by reference. The remainder has the same sign as the second [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .mod_op(Rational::ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -3 * 1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .mod_op(Rational::ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    ///\n    /// // 3 * -1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .mod_op(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .mod_op(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn mod_op(self, other: Self) -> Self {\n        let x_sign = self >= 0u32;\n        let (n1, d1) = self.into_numerator_and_denominator();\n        let y_sign = other >= 0u32;\n        let (n2, d2) = other.into_numerator_and_denominator();\n        let n1d2 = Integer::from_sign_and_abs(x_sign, n1 * &d2);\n        let n2d1 = Integer::from_sign_and_abs(y_sign, n2 * &d1);\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n = n1d2 - n2d1 * q;\n        Self::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl Mod<&Self> for Rational {\n    type Output = Self;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking the\n    /// first by value and the second by reference. The remainder has the same sign as the second\n    /// [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .mod_op(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -3 * 1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .mod_op(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    ///\n    /// // 3 * -1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .mod_op(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .mod_op(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn mod_op(self, other: &Self) -> Self {\n        let x_sign = self >= 0u32;\n        let (n1, d1) = self.into_numerator_and_denominator();\n        let (n2, d2) = other.numerator_and_denominator_ref();\n        let n1d2 = Integer::from_sign_and_abs(x_sign, n1 * d2);\n        let n2d1 = Integer::from_sign_and_abs(*other >= 0u32, n2 * &d1);\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n = n1d2 - n2d1 * q;\n        Self::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl Mod<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking the\n    /// first by reference and the second by value. The remainder has the same sign as the second\n    /// [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .mod_op(Rational::ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -3 * 1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .mod_op(Rational::ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    ///\n    /// // 3 * -1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .mod_op(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .mod_op(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    fn mod_op(self, other: Rational) -> Rational {\n        let (n1, d1) = self.numerator_and_denominator_ref();\n        let y_sign = other >= 0u32;\n        let (n2, d2) = other.into_numerator_and_denominator();\n        let n1d2 = Integer::from_sign_and_abs(*self >= 0u32, n1 * &d2);\n        let n2d1 = Integer::from_sign_and_abs(y_sign, n2 * d1);\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n = n1d2 - n2d1 * q;\n        Rational::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl Mod<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking both\n    /// by reference. The remainder has the same sign as the second [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// This function is called `mod_op` rather than `mod` because `mod` is a Rust keyword.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Mod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .mod_op(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -3 * 1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .mod_op(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    ///\n    /// // 3 * -1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .mod_op(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .mod_op(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    fn mod_op(self, other: &Rational) -> Rational {\n        let (n1, d1) = self.numerator_and_denominator_ref();\n        let (n2, d2) = other.numerator_and_denominator_ref();\n        let n1d2 = Integer::from_sign_and_abs(*self >= 0u32, n1 * d2);\n        let n2d1 = Integer::from_sign_and_abs(*other >= 0u32, n2 * d1);\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n = n1d2 - n2d1 * q;\n        Rational::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl ModAssign<Self> for Rational {\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], mutating the\n    /// first in place and taking the second by value. The remainder has the same sign as the second\n    /// [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAssign;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.mod_assign(Rational::ONE);\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // -3 * 1 + 9/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.mod_assign(Rational::ONE);\n    /// assert_eq!(x.to_string(), \"9/10\");\n    ///\n    /// // 3 * -1 - 9/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.mod_assign(Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"-9/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.mod_assign(Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    /// ```\n    fn mod_assign(&mut self, other: Self) {\n        let mut x = Self::ZERO;\n        swap(self, &mut x);\n        *self = x.mod_op(other);\n    }\n}\n\nimpl ModAssign<&Self> for Rational {\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], mutating the\n    /// first in place and taking the second by reference. The remainder has the same sign as the\n    /// second [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lfloor \\frac{x}{y} \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ModAssign;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.mod_assign(&Rational::ONE);\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // -3 * 1 + 9/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.mod_assign(&Rational::ONE);\n    /// assert_eq!(x.to_string(), \"9/10\");\n    ///\n    /// // 3 * -1 - 9/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.mod_assign(&Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"-9/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.mod_assign(&Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    /// ```\n    fn mod_assign(&mut self, other: &Self) {\n        let mut x = Self::ZERO;\n        swap(self, &mut x);\n        *self = x.mod_op(other);\n    }\n}\n\nimpl Rem<Self> for Rational {\n    type Output = Self;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking both\n    /// by value. The remainder has the same sign as the first [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (Rational::from_unsigneds(21u8, 10) % Rational::ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -1/10\n    /// assert_eq!(\n    ///     (Rational::from_signeds(-21, 10) % Rational::ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (Rational::from_unsigneds(21u8, 10) % Rational::NEGATIVE_ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (Rational::from_signeds(-21, 10) % Rational::NEGATIVE_ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn rem(self, other: Self) -> Self {\n        let x_sign = self >= 0;\n        let (n1, d1) = self.into_numerator_and_denominator();\n        let (n2, d2) = other.into_numerator_and_denominator();\n        let n1d2 = n1 * &d2;\n        let n2d1 = n2 * &d1;\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n2d1q = Integer::from_sign_and_abs(x_sign, n2d1 * q);\n        let n = Integer::from_sign_and_abs(x_sign, n1d2) - n2d1q;\n        Self::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl Rem<&Self> for Rational {\n    type Output = Self;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking the\n    /// first by value and the second by reference. The remainder has the same sign as the first\n    /// [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (Rational::from_unsigneds(21u8, 10) % &Rational::ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -1/10\n    /// assert_eq!(\n    ///     (Rational::from_signeds(-21, 10) % &Rational::ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (Rational::from_unsigneds(21u8, 10) % &Rational::NEGATIVE_ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (Rational::from_signeds(-21, 10) % &Rational::NEGATIVE_ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn rem(self, other: &Self) -> Self {\n        let x_sign = self >= 0;\n        let (n1, d1) = self.into_numerator_and_denominator();\n        let (n2, d2) = other.numerator_and_denominator_ref();\n        let n1d2 = n1 * d2;\n        let n2d1 = n2 * &d1;\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n2d1q = Integer::from_sign_and_abs(x_sign, n2d1 * q);\n        let n = Integer::from_sign_and_abs(x_sign, n1d2) - n2d1q;\n        Self::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl Rem<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking the\n    /// first by reference and the second by value. The remainder has the same sign as the first\n    /// [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10) % Rational::ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -1/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10) % Rational::ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10) % Rational::NEGATIVE_ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10) % Rational::NEGATIVE_ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn rem(self, other: Rational) -> Rational {\n        let x_sign = *self >= 0;\n        let (n1, d1) = self.numerator_and_denominator_ref();\n        let (n2, d2) = other.into_numerator_and_denominator();\n        let n1d2 = n1 * &d2;\n        let n2d1 = n2 * d1;\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n2d1q = Integer::from_sign_and_abs(x_sign, n2d1 * q);\n        let n = Integer::from_sign_and_abs(x_sign, n1d2) - n2d1q;\n        Rational::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl Rem<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking both\n    /// by reference. The remainder has the same sign as the first [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) = x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10) % &Rational::ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -1/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10) % &Rational::ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10) % &Rational::NEGATIVE_ONE).to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10) % &Rational::NEGATIVE_ONE).to_string(),\n    ///     \"-1/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn rem(self, other: &Rational) -> Rational {\n        let x_sign = *self >= 0;\n        let (n1, d1) = self.numerator_and_denominator_ref();\n        let (n2, d2) = other.numerator_and_denominator_ref();\n        let n1d2 = n1 * d2;\n        let n2d1 = n2 * d1;\n        let q = (&n1d2).div_round(&n2d1, Floor).0;\n        let n2d1q = Integer::from_sign_and_abs(x_sign, n2d1 * q);\n        let n = Integer::from_sign_and_abs(x_sign, n1d2) - n2d1q;\n        Rational::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl RemAssign<Self> for Rational {\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], mutating the\n    /// first in place and taking the second by value. The remainder has the same sign as the first\n    /// [`Rational`].\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x %= Rational::ONE;\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -1/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x %= Rational::ONE;\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x %= Rational::NEGATIVE_ONE;\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x %= Rational::NEGATIVE_ONE;\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    /// ```\n    #[inline]\n    fn rem_assign(&mut self, other: Self) {\n        let mut x = Self::ZERO;\n        swap(self, &mut x);\n        *self = x % other;\n    }\n}\n\nimpl RemAssign<&Self> for Rational {\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], mutating the\n    /// first in place and taking the second by reference. The remainder has the same sign as the\n    /// first [`Rational`].\n    ///\n    /// If the quotient were computed, he quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y \\operatorname{sgn}(xy)\n    ///     \\left \\lfloor \\left | \\frac{x}{y} \\right | \\right \\rfloor.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 2 * 1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x %= &Rational::ONE;\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -1/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x %= &Rational::ONE;\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x %= &Rational::NEGATIVE_ONE;\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x %= &Rational::NEGATIVE_ONE;\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    /// ```\n    #[inline]\n    fn rem_assign(&mut self, other: &Self) {\n        let mut x = Self::ZERO;\n        swap(self, &mut x);\n        *self = x % other;\n    }\n}\n\nimpl CeilingMod<Self> for Rational {\n    type Output = Self;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking both\n    /// by value. The remainder has the opposite sign as the second [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 3 * 1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .ceiling_mod(Rational::ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .ceiling_mod(Rational::ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .ceiling_mod(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // 3 * -1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .ceiling_mod(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn ceiling_mod(self, other: Self) -> Self {\n        let x_sign = self >= 0u32;\n        let (n1, d1) = self.into_numerator_and_denominator();\n        let y_sign = other >= 0u32;\n        let (n2, d2) = other.into_numerator_and_denominator();\n        let n1d2 = Integer::from_sign_and_abs(x_sign, n1 * &d2);\n        let n2d1 = Integer::from_sign_and_abs(y_sign, n2 * &d1);\n        let q = (&n1d2).div_round(&n2d1, Ceiling).0;\n        let n = n1d2 - n2d1 * q;\n        Self::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl CeilingMod<&Self> for Rational {\n    type Output = Self;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking the\n    /// first by value and the second by reference. The remainder has the opposite sign as the\n    /// second [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 3 * 1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .ceiling_mod(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .ceiling_mod(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     Rational::from_unsigneds(21u8, 10)\n    ///         .ceiling_mod(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // 3 * -1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     Rational::from_signeds(-21, 10)\n    ///         .ceiling_mod(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    /// ```\n    #[inline]\n    fn ceiling_mod(self, other: &Self) -> Self {\n        let x_sign = self >= 0u32;\n        let (n1, d1) = self.into_numerator_and_denominator();\n        let (n2, d2) = other.numerator_and_denominator_ref();\n        let n1d2 = Integer::from_sign_and_abs(x_sign, n1 * d2);\n        let n2d1 = Integer::from_sign_and_abs(*other > 0u32, n2 * &d1);\n        let q = (&n1d2).div_round(&n2d1, Ceiling).0;\n        let n = n1d2 - n2d1 * q;\n        Self::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl CeilingMod<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking the\n    /// first by reference and the second by value. The remainder has the opposite sign as the\n    /// second [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 3 * 1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .ceiling_mod(Rational::ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .ceiling_mod(Rational::ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .ceiling_mod(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // 3 * -1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .ceiling_mod(Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    /// ```\n    fn ceiling_mod(self, other: Rational) -> Rational {\n        let (n1, d1) = self.numerator_and_denominator_ref();\n        let y_sign = other >= 0u32;\n        let (n2, d2) = other.into_numerator_and_denominator();\n        let n1d2 = Integer::from_sign_and_abs(*self >= 0u32, n1 * &d2);\n        let n2d1 = Integer::from_sign_and_abs(y_sign, n2 * d1);\n        let q = (&n1d2).div_round(&n2d1, Ceiling).0;\n        let n = n1d2 - n2d1 * q;\n        Rational::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl CeilingMod<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], taking both\n    /// by reference. The remainder has the opposite sign as the second [`Rational`].\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// f(x, y) =  x - y\\left \\lceil \\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingMod;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 3 * 1 - 9/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .ceiling_mod(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"-9/10\"\n    /// );\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .ceiling_mod(&Rational::ONE)\n    ///         .to_string(),\n    ///     \"-1/10\"\n    /// );\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// assert_eq!(\n    ///     (&Rational::from_unsigneds(21u8, 10))\n    ///         .ceiling_mod(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    ///\n    /// // 3 * -1 + 9/10 = -21/10\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-21, 10))\n    ///         .ceiling_mod(&Rational::NEGATIVE_ONE)\n    ///         .to_string(),\n    ///     \"9/10\"\n    /// );\n    /// ```\n    fn ceiling_mod(self, other: &Rational) -> Rational {\n        let (n1, d1) = self.numerator_and_denominator_ref();\n        let (n2, d2) = other.numerator_and_denominator_ref();\n        let n1d2 = Integer::from_sign_and_abs(*self >= 0u32, n1 * d2);\n        let n2d1 = Integer::from_sign_and_abs(*other >= 0u32, n2 * d1);\n        let q = (&n1d2).div_round(&n2d1, Ceiling).0;\n        let n = n1d2 - n2d1 * q;\n        Rational::from_sign_and_naturals(n >= 0, n.unsigned_abs(), d1 * d2)\n    }\n}\n\nimpl CeilingModAssign<Self> for Rational {\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], mutating the\n    /// first in place and taking the second by value. The remainder has the opposite sign as the\n    /// second number.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lceil\\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingModAssign;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 3 * 1 - 9/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.ceiling_mod_assign(Rational::ONE);\n    /// assert_eq!(x.to_string(), \"-9/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.ceiling_mod_assign(Rational::ONE);\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.ceiling_mod_assign(Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // 3 * -1 + 9/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.ceiling_mod_assign(Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"9/10\");\n    /// ```\n    fn ceiling_mod_assign(&mut self, other: Self) {\n        let mut x = Self::ZERO;\n        swap(self, &mut x);\n        *self = x.ceiling_mod(other);\n    }\n}\n\nimpl CeilingModAssign<&Self> for Rational {\n    /// Computes the remainder when a [`Rational`] is divided by another [`Rational`], mutating the\n    /// first in place and taking the second by reference. The remainder has the opposite sign as\n    /// the second number.\n    ///\n    /// If the quotient were computed, the quotient and remainder would satisfy $x = qy + r$ and $0\n    /// \\leq |r| < |y|$.\n    ///\n    /// $$\n    /// x \\gets x - y\\left \\lceil\\frac{x}{y} \\right \\rceil.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `other` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CeilingModAssign;\n    /// use malachite_base::num::basic::traits::{NegativeOne, One};\n    /// use malachite_q::Rational;\n    ///\n    /// // 3 * 1 - 9/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.ceiling_mod_assign(&Rational::ONE);\n    /// assert_eq!(x.to_string(), \"-9/10\");\n    ///\n    /// // -2 * 1 - 1/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.ceiling_mod_assign(&Rational::ONE);\n    /// assert_eq!(x.to_string(), \"-1/10\");\n    ///\n    /// // -2 * -1 + 1/10 = 21/10\n    /// let mut x = Rational::from_unsigneds(21u8, 10);\n    /// x.ceiling_mod_assign(&Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"1/10\");\n    ///\n    /// // 3 * -1 + 9/10 = -21/10\n    /// let mut x = Rational::from_signeds(-21, 10);\n    /// x.ceiling_mod_assign(&Rational::NEGATIVE_ONE);\n    /// assert_eq!(x.to_string(), \"9/10\");\n    /// ```\n    fn ceiling_mod_assign(&mut self, other: &Self) {\n        let mut x = Self::ZERO;\n        swap(self, &mut x);\n        *self = x.ceiling_mod(other);\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1994-1996, 2000-2002 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse alloc::vec::Vec;\nuse core::iter::Product;\nuse core::ops::{Mul, MulAssign};\nuse malachite_base::num::arithmetic::traits::{DivExact, DivExactAssign, Gcd};\nuse malachite_base::num::basic::traits::{One, Zero};\n\nimpl Mul<Self> for Rational {\n    type Output = Self;\n\n    /// Multiplies two [`Rational`]s, taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{OneHalf, Two};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF * Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) * Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1089/350\"\n    /// );\n    /// ```\n    fn mul(self, other: Self) -> Self {\n        if self == 0u32 || other == 0u32 {\n            return Self::ZERO;\n        } else if self == 1u32 {\n            return other;\n        } else if other == 1u32 {\n            return self;\n        }\n        let g_1 = (&self.numerator).gcd(&other.denominator);\n        let g_2 = (&other.numerator).gcd(&self.denominator);\n        Self {\n            sign: self.sign == other.sign,\n            numerator: (self.numerator).div_exact(&g_1) * (other.numerator).div_exact(&g_2),\n            denominator: (other.denominator).div_exact(g_1) * (self.denominator).div_exact(g_2),\n        }\n    }\n}\n\nimpl Mul<&Self> for Rational {\n    type Output = Self;\n\n    /// Multiplies two [`Rational`]s, taking the first by value and the second by reference.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{OneHalf, Two};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF * &Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) * &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1089/350\"\n    /// );\n    /// ```\n    #[inline]\n    fn mul(self, other: &Self) -> Self {\n        other * self\n    }\n}\n\nimpl Mul<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Multiplies two [`Rational`]s, taking the first by reference and the second by value.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{OneHalf, Two};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::ONE_HALF * Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) * Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1089/350\"\n    /// );\n    /// ```\n    fn mul(self, other: Rational) -> Rational {\n        if *self == 0u32 || other == 0u32 {\n            return Rational::ZERO;\n        } else if *self == 1u32 {\n            return other;\n        } else if other == 1u32 {\n            return self.clone();\n        }\n        let g_1 = (&self.numerator).gcd(&other.denominator);\n        let g_2 = (&other.numerator).gcd(&self.denominator);\n        Rational {\n            sign: self.sign == other.sign,\n            numerator: (&self.numerator).div_exact(&g_1) * (other.numerator).div_exact(&g_2),\n            denominator: (other.denominator).div_exact(g_1) * (&self.denominator).div_exact(g_2),\n        }\n    }\n}\n\nimpl Mul<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Multiplies two [`Rational`]s, taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{OneHalf, Two};\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::ONE_HALF * &Rational::TWO, 1);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) * &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1089/350\"\n    /// );\n    /// ```\n    fn mul(self, other: &Rational) -> Rational {\n        if *self == 0u32 || *other == 0u32 {\n            return Rational::ZERO;\n        } else if *self == 1u32 {\n            return other.clone();\n        } else if *other == 1u32 {\n            return self.clone();\n        }\n        let g_1 = (&self.numerator).gcd(&other.denominator);\n        let g_2 = (&other.numerator).gcd(&self.denominator);\n        Rational {\n            sign: self.sign == other.sign,\n            numerator: (&self.numerator).div_exact(&g_1) * (&other.numerator).div_exact(&g_2),\n            denominator: (&other.denominator).div_exact(g_1) * (&self.denominator).div_exact(g_2),\n        }\n    }\n}\n\nimpl MulAssign<Self> for Rational {\n    /// Multiplies a [`Rational`] by a [`Rational`] in place, taking the [`Rational`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{OneHalf, Two};\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x *= Rational::TWO;\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x *= Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"1089/350\");\n    /// ```\n    fn mul_assign(&mut self, other: Self) {\n        if *self == 0u32 || other == 1u32 {\n            return;\n        } else if other == 0u32 {\n            *self = Self::ZERO;\n            return;\n        } else if *self == 1u32 {\n            *self = other;\n            return;\n        }\n        self.sign = self.sign == other.sign;\n        let g_1 = (&self.numerator).gcd(&other.denominator);\n        let g_2 = (&other.numerator).gcd(&self.denominator);\n        self.numerator.div_exact_assign(&g_1);\n        self.denominator.div_exact_assign(&g_2);\n        self.numerator *= (other.numerator).div_exact(g_2);\n        self.denominator *= (other.denominator).div_exact(g_1);\n    }\n}\n\nimpl MulAssign<&Self> for Rational {\n    /// Multiplies a [`Rational`] by a [`Rational`] in place, taking the [`Rational`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets xy.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^3 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{OneHalf, Two};\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x *= &Rational::TWO;\n    /// assert_eq!(x, 1);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x *= &Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"1089/350\");\n    /// ```\n    fn mul_assign(&mut self, other: &Self) {\n        if *self == 0u32 || *other == 1u32 {\n            return;\n        } else if *other == 0u32 {\n            *self = Self::ZERO;\n            return;\n        } else if *self == 1u32 {\n            *self = other.clone();\n            return;\n        }\n        self.sign = self.sign == other.sign;\n        let g_1 = (&self.numerator).gcd(&other.denominator);\n        let g_2 = (&other.numerator).gcd(&self.denominator);\n        self.numerator.div_exact_assign(&g_1);\n        self.denominator.div_exact_assign(&g_2);\n        self.numerator *= (&other.numerator).div_exact(g_2);\n        self.denominator *= (&other.denominator).div_exact(g_1);\n    }\n}\n\nimpl Product for Rational {\n    /// Multiplies together all the [`Rational`]s in an iterator.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\prod_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^3 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Rational::sum(xs.map(Rational::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_q::Rational;\n    /// use std::iter::Product;\n    ///\n    /// assert_eq!(\n    ///     Rational::product(\n    ///         vec_from_str::<Rational>(\"[1, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10]\")\n    ///             .unwrap()\n    ///             .into_iter()\n    ///     )\n    ///     .to_string(),\n    ///     \"1/5\"\n    /// );\n    /// ```\n    fn product<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate() {\n            if x == 0 {\n                return Self::ZERO;\n            }\n            let mut p = x;\n            for _ in 0..(i + 1).trailing_zeros() {\n                p *= stack.pop().unwrap();\n            }\n            stack.push(p);\n        }\n        let mut p = Self::ONE;\n        for x in stack.into_iter().rev() {\n            p *= x;\n        }\n        p\n    }\n}\n\nimpl<'a> Product<&'a Self> for Rational {\n    /// Multiplies together all the [`Rational`]s in an iterator of [`Rational`] references.\n    ///\n    /// $$\n    /// f((x_i)_ {i=0}^{n-1}) = \\prod_ {i=0}^{n-1} x_i.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is\n    /// `Rational::sum(xs.map(Rational::significant_bits))`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_q::Rational;\n    /// use std::iter::Product;\n    ///\n    /// assert_eq!(\n    ///     Rational::product(\n    ///         vec_from_str::<Rational>(\"[1, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10]\")\n    ///             .unwrap()\n    ///             .iter()\n    ///     )\n    ///     .to_string(),\n    ///     \"1/5\"\n    /// );\n    /// ```\n    fn product<I>(xs: I) -> Self\n    where\n        I: Iterator<Item = &'a Self>,\n    {\n        let mut stack = Vec::new();\n        for (i, x) in xs.enumerate() {\n            if *x == 0 {\n                return Self::ZERO;\n            }\n            let mut p = x.clone();\n            for _ in 0..(i + 1).trailing_zeros() {\n                p *= stack.pop().unwrap();\n            }\n            stack.push(p);\n        }\n        let mut p = Self::ONE;\n        for x in stack.into_iter().rev() {\n            p *= x;\n        }\n        p\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::ops::Neg;\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::logic::traits::NotAssign;\n\nimpl Neg for Rational {\n    type Output = Self;\n\n    /// Negates a [`Rational`], taking it by value.\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(-Rational::ZERO, 0);\n    /// assert_eq!((-Rational::from_signeds(22, 7)).to_string(), \"-22/7\");\n    /// assert_eq!((-Rational::from_signeds(-22, 7)).to_string(), \"22/7\");\n    /// ```\n    fn neg(mut self) -> Self {\n        if self.numerator != 0 {\n            self.sign.not_assign();\n        }\n        self\n    }\n}\n\nimpl Neg for &Rational {\n    type Output = Rational;\n\n    /// Negates a [`Rational`], taking it by reference.\n    ///\n    /// $$\n    /// f(x) = -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(-&Rational::ZERO, 0);\n    /// assert_eq!((-&Rational::from_signeds(22, 7)).to_string(), \"-22/7\");\n    /// assert_eq!((-&Rational::from_signeds(-22, 7)).to_string(), \"22/7\");\n    /// ```\n    fn neg(self) -> Rational {\n        if self.numerator == 0 {\n            Rational::ZERO\n        } else {\n            Rational {\n                sign: !self.sign,\n                numerator: self.numerator.clone(),\n                denominator: self.denominator.clone(),\n            }\n        }\n    }\n}\n\nimpl NegAssign for Rational {\n    /// Negates a [`Rational`] in place.\n    ///\n    /// $$\n    /// x \\gets -x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NegAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ZERO;\n    /// x.neg_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.neg_assign();\n    /// assert_eq!(x.to_string(), \"-22/7\");\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.neg_assign();\n    /// assert_eq!(x.to_string(), \"22/7\");\n    /// ```\n    fn neg_assign(&mut self) {\n        if self.numerator != 0 {\n            self.sign.not_assign();\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::{NextPowerOf2, NextPowerOf2Assign, PowerOf2};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\n\nimpl NextPowerOf2 for Rational {\n    type Output = Self;\n\n    /// Finds the smallest power of 2 greater than or equal to a [`Rational`]. The [`Rational`] is\n    /// taken by value.\n    ///\n    /// $f(x) = 2^{\\lceil \\log_2 x \\rceil}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is less than or equal to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NextPowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(123).next_power_of_2(), 128);\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 10).next_power_of_2().to_string(),\n    ///     \"1/8\"\n    /// );\n    /// ```\n    #[inline]\n    fn next_power_of_2(self) -> Self {\n        assert!(self > 0);\n        let mut exponent = i64::exact_from(self.numerator.significant_bits())\n            - i64::exact_from(self.denominator.significant_bits());\n        match self.numerator.cmp_normalized(&self.denominator) {\n            Equal => return self,\n            Greater => exponent += 1,\n            _ => {}\n        }\n        Self::power_of_2(exponent)\n    }\n}\n\nimpl NextPowerOf2 for &Rational {\n    type Output = Rational;\n\n    /// Finds the smallest power of 2 greater than or equal to a [`Rational`]. The [`Rational`] is\n    /// taken by reference.\n    ///\n    /// $f(x) = 2^{\\lceil \\log_2 x \\rceil}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is less than or equal to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NextPowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Rational::from(123)).next_power_of_2(), 128);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(1, 10))\n    ///         .next_power_of_2()\n    ///         .to_string(),\n    ///     \"1/8\"\n    /// );\n    /// ```\n    fn next_power_of_2(self) -> Rational {\n        assert!(*self > 0);\n        let mut exponent = i64::exact_from(self.numerator.significant_bits())\n            - i64::exact_from(self.denominator.significant_bits());\n        if self.numerator.cmp_normalized(&self.denominator) == Greater {\n            exponent += 1;\n        }\n        Rational::power_of_2(exponent)\n    }\n}\n\nimpl NextPowerOf2Assign for Rational {\n    /// Finds the smallest power of 2 greater than or equal to a [`Rational`]. The [`Rational`] is\n    /// taken by reference.\n    ///\n    /// $f(x) = 2^{\\lceil \\log_2 x \\rceil}$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is less than or equal to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::NextPowerOf2Assign;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::from(123);\n    /// x.next_power_of_2_assign();\n    /// assert_eq!(x, 128);\n    ///\n    /// let mut x = Rational::from_signeds(1, 10);\n    /// x.next_power_of_2_assign();\n    /// assert_eq!(x.to_string(), \"1/8\");\n    /// ```\n    #[inline]\n    fn next_power_of_2_assign(&mut self) {\n        *self = (&*self).next_power_of_2();\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{\n    Parity, Pow, PowAssign, Reciprocal, ReciprocalAssign,\n};\n\nimpl Pow<u64> for Rational {\n    type Output = Self;\n\n    /// Raises a [`Rational`] to a power, taking the [`Rational`] by value.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).pow(3u64).to_string(),\n    ///     \"10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).pow(3u64).to_string(),\n    ///     \"-10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).pow(4u64).to_string(),\n    ///     \"234256/2401\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(mut self, exp: u64) -> Self {\n        self.pow_assign(exp);\n        self\n    }\n}\n\nimpl Pow<u64> for &Rational {\n    type Output = Rational;\n\n    /// Raises a [`Rational`] to a power, taking the [`Rational`] by reference.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7)).pow(3u64).to_string(),\n    ///     \"10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-22, 7)).pow(3u64).to_string(),\n    ///     \"-10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-22, 7)).pow(4u64).to_string(),\n    ///     \"234256/2401\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(self, exp: u64) -> Rational {\n        Rational {\n            sign: self.sign || exp.even(),\n            numerator: (&self.numerator).pow(exp),\n            denominator: (&self.denominator).pow(exp),\n        }\n    }\n}\n\nimpl PowAssign<u64> for Rational {\n    /// Raises a [`Rational`] to a power in place.\n    ///\n    /// $x \\gets x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowAssign;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.pow_assign(3u64);\n    /// assert_eq!(x.to_string(), \"10648/343\");\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.pow_assign(3u64);\n    /// assert_eq!(x.to_string(), \"-10648/343\");\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.pow_assign(4u64);\n    /// assert_eq!(x.to_string(), \"234256/2401\");\n    /// ```\n    fn pow_assign(&mut self, exp: u64) {\n        self.sign |= exp.even();\n        self.numerator.pow_assign(exp);\n        self.denominator.pow_assign(exp);\n    }\n}\n\nimpl Pow<i64> for Rational {\n    type Output = Self;\n\n    /// Raises a [`Rational`] to a power, taking the [`Rational`] by value.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp.abs()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero and `exp` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).pow(3i64).to_string(),\n    ///     \"10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).pow(3i64).to_string(),\n    ///     \"-10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).pow(4i64).to_string(),\n    ///     \"234256/2401\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).pow(-3i64).to_string(),\n    ///     \"343/10648\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).pow(-3i64).to_string(),\n    ///     \"-343/10648\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).pow(-4i64).to_string(),\n    ///     \"2401/234256\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(mut self, exp: i64) -> Self {\n        self.pow_assign(exp);\n        self\n    }\n}\n\nimpl Pow<i64> for &Rational {\n    type Output = Rational;\n\n    /// Raises a [`Rational`] to a power, taking the [`Rational`] by reference.\n    ///\n    /// $f(x, n) = x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp.abs()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero and `exp` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Pow;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7)).pow(3i64).to_string(),\n    ///     \"10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-22, 7)).pow(3i64).to_string(),\n    ///     \"-10648/343\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-22, 7)).pow(4i64).to_string(),\n    ///     \"234256/2401\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7)).pow(-3i64).to_string(),\n    ///     \"343/10648\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-22, 7)).pow(-3i64).to_string(),\n    ///     \"-343/10648\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-22, 7)).pow(-4i64).to_string(),\n    ///     \"2401/234256\"\n    /// );\n    /// ```\n    #[inline]\n    fn pow(self, exp: i64) -> Rational {\n        let abs_exp = exp.unsigned_abs();\n        if exp >= 0 {\n            self.pow(abs_exp)\n        } else {\n            self.pow(abs_exp).reciprocal()\n        }\n    }\n}\n\nimpl PowAssign<i64> for Rational {\n    /// Raises a [`Rational`] to a power in place.\n    ///\n    /// $x \\gets x^n$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `exp.abs()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is zero and `exp` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowAssign;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.pow_assign(3i64);\n    /// assert_eq!(x.to_string(), \"10648/343\");\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.pow_assign(3i64);\n    /// assert_eq!(x.to_string(), \"-10648/343\");\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.pow_assign(4i64);\n    /// assert_eq!(x.to_string(), \"234256/2401\");\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.pow_assign(-3i64);\n    /// assert_eq!(x.to_string(), \"343/10648\");\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.pow_assign(-3i64);\n    /// assert_eq!(x.to_string(), \"-343/10648\");\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.pow_assign(-4i64);\n    /// assert_eq!(x.to_string(), \"2401/234256\");\n    /// ```\n    fn pow_assign(&mut self, exp: i64) {\n        let abs_exp = exp.unsigned_abs();\n        if exp >= 0 {\n            self.pow_assign(abs_exp);\n        } else {\n            self.pow_assign(abs_exp);\n            self.reciprocal_assign();\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::num::basic::traits::One;\nuse malachite_nz::natural::Natural;\n\nimpl PowerOf2<u64> for Rational {\n    /// Raises 2 to an integer power.\n    ///\n    /// $f(k) = 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::power_of_2(0u64), 1);\n    /// assert_eq!(Rational::power_of_2(3u64), 8);\n    /// assert_eq!(\n    ///     Rational::power_of_2(100u64).to_string(),\n    ///     \"1267650600228229401496703205376\"\n    /// );\n    /// ```\n    fn power_of_2(pow: u64) -> Self {\n        Self::from(Natural::power_of_2(pow))\n    }\n}\n\nimpl PowerOf2<i64> for Rational {\n    /// Raises 2 to an integer power.\n    ///\n    /// $f(k) = 2^k$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `pow.abs()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::power_of_2(0i64), 1);\n    /// assert_eq!(Rational::power_of_2(3i64), 8);\n    /// assert_eq!(\n    ///     Rational::power_of_2(100i64).to_string(),\n    ///     \"1267650600228229401496703205376\"\n    /// );\n    /// assert_eq!(Rational::power_of_2(-3i64).to_string(), \"1/8\");\n    /// assert_eq!(\n    ///     Rational::power_of_2(-100i64).to_string(),\n    ///     \"1/1267650600228229401496703205376\"\n    /// );\n    /// ```\n    fn power_of_2(pow: i64) -> Self {\n        let pow_abs = pow.unsigned_abs();\n        if pow >= 0 {\n            Self::from(Natural::power_of_2(pow_abs))\n        } else {\n            Self {\n                sign: true,\n                numerator: Natural::ONE,\n                denominator: Natural::power_of_2(pow_abs),\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{Reciprocal, ReciprocalAssign};\n\nimpl Reciprocal for Rational {\n    type Output = Self;\n\n    /// Reciprocates a [`Rational`], taking it by value.\n    ///\n    /// $$\n    /// f(x) = 1/x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Reciprocal;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).reciprocal().to_string(),\n    ///     \"7/22\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(7, 22).reciprocal().to_string(),\n    ///     \"22/7\"\n    /// );\n    /// ```\n    #[inline]\n    fn reciprocal(mut self) -> Self {\n        self.reciprocal_assign();\n        self\n    }\n}\n\nimpl Reciprocal for &Rational {\n    type Output = Rational;\n\n    /// Reciprocates a [`Rational`], taking it by reference.\n    ///\n    /// $$\n    /// f(x) = 1/x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Reciprocal;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7)).reciprocal().to_string(),\n    ///     \"7/22\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(7, 22)).reciprocal().to_string(),\n    ///     \"22/7\"\n    /// );\n    /// ```\n    fn reciprocal(self) -> Rational {\n        assert_ne!(self.numerator, 0, \"Cannot take reciprocal of zero\");\n        Rational {\n            sign: self.sign,\n            numerator: self.denominator.clone(),\n            denominator: self.numerator.clone(),\n        }\n    }\n}\n\nimpl ReciprocalAssign for Rational {\n    /// Reciprocates a [`Rational`] in place.\n    ///\n    /// $$\n    /// x \\gets 1/x.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::ReciprocalAssign;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.reciprocal_assign();\n    /// assert_eq!(x.to_string(), \"7/22\");\n    ///\n    /// let mut x = Rational::from_signeds(7, 22);\n    /// x.reciprocal_assign();\n    /// assert_eq!(x.to_string(), \"22/7\");\n    /// ```\n    fn reciprocal_assign(&mut self) {\n        assert_ne!(self.numerator, 0, \"Cannot take reciprocal of zero\");\n        swap(&mut self.numerator, &mut self.denominator);\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{CheckedRoot, Reciprocal, UnsignedAbs};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\n\nimpl CheckedRoot<u64> for Rational {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`Rational`], or `None` if the [`Rational`] is not a perfect\n    /// $n$th power. The [`Rational`] is taken by value.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\mathbb{Q}, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(999i32).checked_root(3u64).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(1000i32).checked_root(3u64).to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(1001i32).checked_root(3u64).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(-1000i32)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"Some(-10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(27, 8)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"Some(3/2)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-27, 8)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"Some(-3/2)\"\n    /// );\n    /// ```\n    fn checked_root(self, pow: u64) -> Option<Self> {\n        let sign = self >= 0;\n        let (n, d) = self.into_numerator_and_denominator();\n        let root_n;\n        let root_d;\n        if n.significant_bits() <= d.significant_bits() {\n            root_n = Integer::from_sign_and_abs(sign, n).checked_root(pow)?;\n            root_d = d.checked_root(pow)?;\n        } else {\n            root_d = d.checked_root(pow)?;\n            root_n = Integer::from_sign_and_abs(sign, n).checked_root(pow)?;\n        }\n        Some(Self {\n            sign: root_n >= 0,\n            numerator: root_n.unsigned_abs(),\n            denominator: root_d,\n        })\n    }\n}\n\nimpl CheckedRoot<u64> for &Rational {\n    type Output = Rational;\n\n    /// Returns the the $n$th root of a [`Rational`], or `None` if the [`Rational`] is not a perfect\n    /// $n$th power. The [`Rational`] is taken by reference.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\mathbb{Q}, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, or if `exp` is even and `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(999i32).checked_root(3u64).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(1000i32).checked_root(3u64).to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(1001i32).checked_root(3u64).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(-1000i32)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"Some(-10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(27, 8)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"Some(3/2)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-27, 8)\n    ///         .checked_root(3u64)\n    ///         .to_debug_string(),\n    ///     \"Some(-3/2)\"\n    /// );\n    /// ```\n    fn checked_root(self, pow: u64) -> Option<Rational> {\n        let (n, d) = self.numerator_and_denominator_ref();\n        let root_n;\n        let root_d;\n        if n.significant_bits() <= d.significant_bits() {\n            root_n = Integer::from_sign_and_abs_ref(*self >= 0, n).checked_root(pow)?;\n            root_d = d.checked_root(pow)?;\n        } else {\n            root_d = d.checked_root(pow)?;\n            root_n = Integer::from_sign_and_abs_ref(*self >= 0, n).checked_root(pow)?;\n        }\n        Some(Rational {\n            sign: root_n >= 0,\n            numerator: root_n.unsigned_abs(),\n            denominator: root_d,\n        })\n    }\n}\n\nimpl CheckedRoot<i64> for Rational {\n    type Output = Self;\n\n    /// Returns the the $n$th root of a [`Rational`], or `None` if the [`Rational`] is not a perfect\n    /// $n$th power. The [`Rational`] is taken by value.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\mathbb{Q}, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, if `exp` is even and `self` is negative, or if `self` is zero and\n    /// `exp` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(999i32).checked_root(3i64).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(1000i32).checked_root(3i64).to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(1001i32).checked_root(3i64).to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(-1000i32)\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(-10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(27, 8)\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(3/2)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-27, 8)\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(-3/2)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Rational::from(1000i32)\n    ///         .checked_root(-3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(1/10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-27, 8)\n    ///         .checked_root(-3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(-2/3)\"\n    /// );\n    /// ```\n    fn checked_root(self, pow: i64) -> Option<Self> {\n        let u_pow = pow.unsigned_abs();\n        if pow >= 0 {\n            self.checked_root(u_pow)\n        } else {\n            self.checked_root(u_pow).map(Self::reciprocal)\n        }\n    }\n}\n\nimpl CheckedRoot<i64> for &Rational {\n    type Output = Rational;\n\n    /// Returns the the $n$th root of a [`Rational`], or `None` if the [`Rational`] is not a perfect\n    /// $n$th power. The [`Rational`] is taken by reference.\n    ///\n    /// $$\n    /// f(x, n) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt\\[n\\]{x}) & \\text{if} \\\\quad \\sqrt\\[n\\]{x} \\in \\mathbb{Q}, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `exp` is zero, if `exp` is even and `self` is negative, or if `self` is zero and\n    /// `exp` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedRoot;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from(999i32))\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from(1000i32))\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from(1001i32))\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from(-1000i32))\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(-10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(27, 8))\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(3/2)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-27, 8))\n    ///         .checked_root(3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(-3/2)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from(1000i32))\n    ///         .checked_root(-3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(1/10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-27, 8))\n    ///         .checked_root(-3i64)\n    ///         .to_debug_string(),\n    ///     \"Some(-2/3)\"\n    /// );\n    /// ```\n    fn checked_root(self, pow: i64) -> Option<Rational> {\n        let u_pow = pow.unsigned_abs();\n        if pow >= 0 {\n            self.checked_root(u_pow)\n        } else {\n            self.checked_root(u_pow).map(Rational::reciprocal)\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{NegAssign, RoundToMultiple, RoundToMultipleAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\n\nimpl RoundToMultiple<Self> for Rational {\n    type Output = Self;\n\n    /// Rounds a [`Rational`] to an integer multiple of another [`Rational`], according to a\n    /// specified rounding mode. Both [`Rational`]s are taken by value. An [`Ordering`] is also\n    /// returned, indicating whether the returned value is less than, equal to, or greater than the\n    /// original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(-5)\n    ///         .round_to_multiple(Rational::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// let hundredth = Rational::from_signeds(1, 100);\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(hundredth.clone(), Down)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(hundredth.clone(), Floor)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(hundredth.clone(), Up)\n    ///         .to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(hundredth.clone(), Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(hundredth.clone(), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple(mut self, other: Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultiple<&Self> for Rational {\n    type Output = Self;\n\n    /// Rounds a [`Rational`] to an integer multiple of another [`Rational`], according to a\n    /// specified rounding mode. The first [`Rational`] is taken by value and the second by\n    /// reference. An [`Ordering`] is also returned, indicating whether the returned value is less\n    /// than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(-5)\n    ///         .round_to_multiple(&Rational::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// let hundredth = Rational::from_signeds(1, 100);\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(&hundredth, Down)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(&hundredth, Floor)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(&hundredth, Up)\n    ///         .to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(&hundredth, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple(&hundredth, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple(mut self, other: &Self, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_assign(other, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultiple<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Rounds a [`Rational`] to an integer multiple of another [`Rational`], according to a\n    /// specified rounding mode. The first [`Rational`] is taken by reference and the second by\n    /// value. An [`Ordering`] is also returned, indicating whether the returned value is less than,\n    /// equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from(-5))\n    ///         .round_to_multiple(Rational::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// let hundredth = Rational::from_signeds(1, 100);\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(hundredth.clone(), Down)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(hundredth.clone(), Floor)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(hundredth.clone(), Up)\n    ///         .to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(hundredth.clone(), Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(hundredth.clone(), Nearest)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// ```\n    fn round_to_multiple(self, other: Rational, mut rm: RoundingMode) -> (Rational, Ordering) {\n        if *self == other {\n            return (self.clone(), Equal);\n        }\n        if other == 0u32 {\n            if rm == Down || rm == Nearest || rm == if *self >= 0u32 { Floor } else { Ceiling } {\n                return (Rational::ZERO, if *self >= 0u32 { Less } else { Greater });\n            }\n            panic!(\"Cannot round {self} to zero using RoundingMode {rm}\");\n        }\n        if !other.sign {\n            rm.neg_assign();\n        }\n        let (x, mut o) = Integer::rounding_from(self / &other, rm);\n        if !other.sign {\n            o = o.reverse();\n        }\n        (Rational::from(x) * other, o)\n    }\n}\n\nimpl RoundToMultiple<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Rounds a [`Rational`] to an integer multiple of another [`Rational`], according to a\n    /// specified rounding mode. Both [`Rational`]s are taken by reference. An [`Ordering`] is also\n    /// returned, indicating whether the returned value is less than, equal to, or greater than the\n    /// original value.\n    ///\n    /// Let $q = \\frac{x}{y}$:\n    ///\n    /// $f(x, y, \\mathrm{Down}) = f(x, y, \\mathrm{Floor}) = y \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, y, \\mathrm{Up}) = f(x, y, \\mathrm{Ceiling}) = y \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, y, \\mathrm{Nearest}) = \\begin{cases}\n    ///     y \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///         q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     y \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     y \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor = \\frac{1}{2}\n    ///         \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, y, \\mathrm{Exact}) = x$, but panics if $q \\notin \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultiple;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from(-5))\n    ///         .round_to_multiple(&Rational::ZERO, Down)\n    ///         .to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// let hundredth = Rational::from_signeds(1, 100);\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(&hundredth, Down).to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(&hundredth, Floor).to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(&hundredth, Up).to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(&hundredth, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(63/20, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple(&hundredth, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(157/50, Less)\"\n    /// );\n    /// ```\n    fn round_to_multiple(self, other: &Rational, mut rm: RoundingMode) -> (Rational, Ordering) {\n        if self == other {\n            return (self.clone(), Equal);\n        }\n        if *other == 0u32 {\n            if rm == Down || rm == Nearest || rm == if *self >= 0u32 { Floor } else { Ceiling } {\n                return (Rational::ZERO, if *self >= 0 { Less } else { Greater });\n            }\n            panic!(\"Cannot round {self} to zero using RoundingMode {rm}\");\n        }\n        if !other.sign {\n            rm.neg_assign();\n        }\n        let (x, mut o) = Integer::rounding_from(self / other, rm);\n        if !other.sign {\n            o = o.reverse();\n        }\n        (Rational::from(x) * other, o)\n    }\n}\n\nimpl RoundToMultipleAssign<Self> for Rational {\n    /// Rounds a [`Rational`] to an integer multiple of another [`Rational`] in place, according to\n    /// a  specified rounding mode. The [`Rational`] on the right-hand side is taken by value. An\n    /// [`Ordering`] is returned, indicating whether the returned value is less than, equal to, or\n    /// greater than the original value.\n    ///\n    /// See the [`RoundToMultiple`] documentation for details.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Rational::from(-5);\n    /// assert_eq!(x.round_to_multiple_assign(Rational::ZERO, Down), Greater);\n    /// assert_eq!(x, 0);\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// let hundredth = Rational::from_signeds(1, 100);\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(hundredth.clone(), Down), Less);\n    /// assert_eq!(x.to_string(), \"157/50\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(hundredth.clone(), Floor), Less);\n    /// assert_eq!(x.to_string(), \"157/50\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(hundredth.clone(), Up), Greater);\n    /// assert_eq!(x.to_string(), \"63/20\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(\n    ///     x.round_to_multiple_assign(hundredth.clone(), Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"63/20\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(hundredth.clone(), Nearest), Less);\n    /// assert_eq!(x.to_string(), \"157/50\");\n    /// ```\n    fn round_to_multiple_assign(&mut self, other: Self, mut rm: RoundingMode) -> Ordering {\n        if *self == other {\n            return Equal;\n        }\n        if other == 0u32 {\n            if rm == Down || rm == Nearest || rm == if *self >= 0u32 { Floor } else { Ceiling } {\n                let o = if *self >= 0 { Less } else { Greater };\n                *self = Self::ZERO;\n                return o;\n            }\n            panic!(\"Cannot round {self} to zero using RoundingMode {rm}\");\n        }\n        if !other.sign {\n            rm.neg_assign();\n        }\n        *self /= &other;\n        let (x, o) = Integer::rounding_from(&*self, rm);\n        let other_sign = other.sign;\n        *self = Self::from(x) * other;\n        if other_sign { o } else { o.reverse() }\n    }\n}\n\nimpl RoundToMultipleAssign<&Self> for Rational {\n    /// Rounds a [`Rational`] to an integer multiple of another [`Rational`] in place, according to\n    /// a specified rounding mode. The [`Rational`] on the right-hand side is taken by reference. An\n    /// [`Ordering`] is returned, indicating whether the returned value is less than, equal to, or\n    /// greater than the original value.\n    ///\n    /// See the [`RoundToMultiple`] documentation for details.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// - If `rm` is `Exact`, but `self` is not a multiple of `other`.\n    /// - If `self` is nonzero, `other` is zero, and `rm` is trying to round away from zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let mut x = Rational::from(-5);\n    /// assert_eq!(x.round_to_multiple_assign(&Rational::ZERO, Down), Greater);\n    /// assert_eq!(x, 0);\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// let hundredth = Rational::from_signeds(1, 100);\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(&hundredth, Down), Less);\n    /// assert_eq!(x.to_string(), \"157/50\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(&hundredth, Floor), Less);\n    /// assert_eq!(x.to_string(), \"157/50\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(&hundredth, Up), Greater);\n    /// assert_eq!(x.to_string(), \"63/20\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(&hundredth, Ceiling), Greater);\n    /// assert_eq!(x.to_string(), \"63/20\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_assign(&hundredth, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"157/50\");\n    /// ```\n    fn round_to_multiple_assign(&mut self, other: &Self, mut rm: RoundingMode) -> Ordering {\n        if self == other {\n            return Equal;\n        }\n        if *other == 0u32 {\n            if rm == Down || rm == Nearest || rm == if *self >= 0u32 { Floor } else { Ceiling } {\n                let o = if *self >= 0u32 { Less } else { Greater };\n                *self = Self::ZERO;\n                return o;\n            }\n            panic!(\"Cannot round {self} to zero using RoundingMode {rm}\");\n        }\n        if !other.sign {\n            rm.neg_assign();\n        }\n        *self /= other;\n        let (x, o) = Integer::rounding_from(&*self, rm);\n        *self = Self::from(x) * other;\n        if other.sign { o } else { o.reverse() }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::{\n    RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign,\n};\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_nz::integer::Integer;\n\nimpl RoundToMultipleOfPowerOf2<i64> for Rational {\n    type Output = Self;\n\n    /// Rounds a [`Rational`] to an integer multiple of $2^k$ according to a specified rounding\n    /// mode. The [`Rational`] is taken by value. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{2^k}$:\n    ///\n    /// $f(x, k, \\mathrm{Down}) = 2^k \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Up}) = 2^k \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, k, \\mathrm{Floor}) = 2^k \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Ceiling}) = 2^k \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n    ///     2^k \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///     q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     2^k \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, k, \\mathrm{Exact}) = 2^k q$, but panics if $q \\notin \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple_of_power_of_2(-3, Floor)\n    ///         .to_debug_string(),\n    ///     \"(25/8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple_of_power_of_2(-3, Down)\n    ///         .to_debug_string(),\n    ///     \"(25/8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple_of_power_of_2(-3, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(13/4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple_of_power_of_2(-3, Up)\n    ///         .to_debug_string(),\n    ///     \"(13/4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     q.clone()\n    ///         .round_to_multiple_of_power_of_2(-3, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(25/8, Less)\"\n    /// );\n    /// ```\n    #[inline]\n    fn round_to_multiple_of_power_of_2(mut self, pow: i64, rm: RoundingMode) -> (Self, Ordering) {\n        let o = self.round_to_multiple_of_power_of_2_assign(pow, rm);\n        (self, o)\n    }\n}\n\nimpl RoundToMultipleOfPowerOf2<i64> for &Rational {\n    type Output = Rational;\n\n    /// Rounds a [`Rational`] to an integer multiple of $2^k$ according to a specified rounding\n    /// mode. The [`Rational`] is taken by reference. An [`Ordering`] is also returned, indicating\n    /// whether the returned value is less than, equal to, or greater than the original value.\n    ///\n    /// Let $q = \\frac{x}{2^k}$:\n    ///\n    /// $f(x, k, \\mathrm{Down}) = 2^k \\operatorname{sgn}(q) \\lfloor |q| \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Up}) = 2^k \\operatorname{sgn}(q) \\lceil |q| \\rceil.$\n    ///\n    /// $f(x, k, \\mathrm{Floor}) = 2^k \\lfloor q \\rfloor.$\n    ///\n    /// $f(x, k, \\mathrm{Ceiling}) = 2^k \\lceil q \\rceil.$\n    ///\n    /// $$\n    /// f(x, k, \\mathrm{Nearest}) = \\begin{cases}\n    ///     2^k \\lfloor q \\rfloor & \\text{if} \\\\quad\n    ///     q - \\lfloor q \\rfloor < \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lceil q \\rceil & \\text{if} \\\\quad q - \\lfloor q \\rfloor > \\frac{1}{2} \\\\\\\\\n    ///     2^k \\lfloor q \\rfloor &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor\n    ///     \\\\ \\text{is even} \\\\\\\\\n    ///     2^k \\lceil q \\rceil &\n    ///     \\text{if} \\\\quad q - \\lfloor q \\rfloor =\n    ///         \\frac{1}{2} \\\\ \\text{and} \\\\ \\lfloor q \\rfloor \\\\ \\text{is odd.}\n    /// \\end{cases}\n    /// $$\n    ///\n    /// $f(x, k, \\mathrm{Exact}) = 2^k q$, but panics if $q \\notin \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    /// assert_eq!(\n    ///     (&q).round_to_multiple_of_power_of_2(-3, Floor)\n    ///         .to_debug_string(),\n    ///     \"(25/8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple_of_power_of_2(-3, Down)\n    ///         .to_debug_string(),\n    ///     \"(25/8, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple_of_power_of_2(-3, Ceiling)\n    ///         .to_debug_string(),\n    ///     \"(13/4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple_of_power_of_2(-3, Up)\n    ///         .to_debug_string(),\n    ///     \"(13/4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     (&q).round_to_multiple_of_power_of_2(-3, Nearest)\n    ///         .to_debug_string(),\n    ///     \"(25/8, Less)\"\n    /// );\n    /// ```\n    fn round_to_multiple_of_power_of_2(self, pow: i64, rm: RoundingMode) -> (Rational, Ordering) {\n        let (s, o) = Integer::rounding_from(self >> pow, rm);\n        (Rational::from(s) << pow, o)\n    }\n}\n\nimpl RoundToMultipleOfPowerOf2Assign<i64> for Rational {\n    /// Rounds a [`Rational`] to a multiple of $2^k$ in place, according to a specified rounding\n    /// mode. An [`Ordering`] is returned, indicating whether the returned value is less than, equal\n    /// to, or greater than the original value.\n    ///\n    /// See the [`RoundToMultipleOfPowerOf2`] documentation for details.\n    ///\n    /// but the latter should be used as it is clearer and more efficient.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), pow /\n    /// Limb::WIDTH)`.\n    ///\n    /// # Panics\n    /// Panics if `rm` is `Exact`, but `self` is not a multiple of the power of 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign;\n    /// use malachite_base::num::conversion::traits::ExactFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// let q = Rational::exact_from(std::f64::consts::PI);\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_of_power_of_2_assign(-3, Floor), Less);\n    /// assert_eq!(x.to_string(), \"25/8\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_of_power_of_2_assign(-3, Down), Less);\n    /// assert_eq!(x.to_string(), \"25/8\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(\n    ///     x.round_to_multiple_of_power_of_2_assign(-3, Ceiling),\n    ///     Greater\n    /// );\n    /// assert_eq!(x.to_string(), \"13/4\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_of_power_of_2_assign(-3, Up), Greater);\n    /// assert_eq!(x.to_string(), \"13/4\");\n    ///\n    /// let mut x = q.clone();\n    /// assert_eq!(x.round_to_multiple_of_power_of_2_assign(-3, Nearest), Less);\n    /// assert_eq!(x.to_string(), \"25/8\");\n    /// ```\n    fn round_to_multiple_of_power_of_2_assign(&mut self, pow: i64, rm: RoundingMode) -> Ordering {\n        *self >>= pow;\n        let (s, o) = Integer::rounding_from(&*self, rm);\n        *self = Self::from(s) << pow;\n        o\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\nfn shl_unsigned_assign<T>(x: &mut Rational, bits: T)\nwhere\n    u64: TryFrom<T>,\n{\n    if *x == 0u32 {\n        return;\n    }\n    let denominator_zeros = x.denominator.trailing_zeros().unwrap();\n    let bits_64 = u64::exact_from(bits);\n    if denominator_zeros >= bits_64 {\n        x.denominator >>= bits_64;\n    } else {\n        x.denominator >>= denominator_zeros;\n        x.numerator <<= bits_64 - denominator_zeros;\n    }\n}\n\nfn shl_unsigned_ref<T>(x: &Rational, bits: T) -> Rational\nwhere\n    u64: TryFrom<T>,\n{\n    if *x == 0u32 {\n        return x.clone();\n    }\n    let denominator_zeros = x.denominator.trailing_zeros().unwrap();\n    let bits_64 = u64::exact_from(bits);\n    if denominator_zeros >= bits_64 {\n        Rational {\n            sign: x.sign,\n            numerator: x.numerator.clone(),\n            denominator: &x.denominator >> bits_64,\n        }\n    } else {\n        Rational {\n            sign: x.sign,\n            numerator: &x.numerator << (bits_64 - denominator_zeros),\n            denominator: &x.denominator >> denominator_zeros,\n        }\n    }\n}\n\nmacro_rules! impl_shl_unsigned {\n    ($t:ident) => {\n        impl Shl<$t> for Rational {\n            type Output = Rational;\n\n            /// Left-shifts a [`Rational`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(mut self, bits: $t) -> Rational {\n                self <<= bits;\n                self\n            }\n        }\n\n        impl Shl<$t> for &Rational {\n            type Output = Rational;\n\n            /// Left-shifts a [`Rational`] (multiplies it by a power of 2), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Rational {\n                shl_unsigned_ref(self, bits)\n            }\n        }\n\n        impl ShlAssign<$t> for Rational {\n            /// Left-shifts a [`Rational`] (multiplies it by a power of 2), in place.\n            ///\n            /// $$\n            /// x \\gets x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// # Examples\n            /// See [here](super::shl#shl_assign).\n            #[inline]\n            fn shl_assign(&mut self, bits: $t) {\n                shl_unsigned_assign(self, bits);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_shl_unsigned);\n\nfn shl_signed_ref<'a, U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &'a Rational,\n    bits: S,\n) -> Rational\nwhere\n    &'a Rational: Shl<U, Output = Rational> + Shr<U, Output = Rational>,\n{\n    if bits >= S::ZERO {\n        x << bits.unsigned_abs()\n    } else {\n        x >> bits.unsigned_abs()\n    }\n}\n\nfn shl_assign_signed<U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(x: &mut Rational, bits: S)\nwhere\n    Rational: ShlAssign<U> + ShrAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x <<= bits.unsigned_abs();\n    } else {\n        *x >>= bits.unsigned_abs();\n    }\n}\n\nmacro_rules! impl_shl_signed {\n    ($t:ident) => {\n        impl Shl<$t> for Rational {\n            type Output = Rational;\n\n            /// Left-shifts a [`Rational`] (multiplies it or divides it by a power of 2), taking it\n            /// by value.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(mut self, bits: $t) -> Rational {\n                self <<= bits;\n                self\n            }\n        }\n\n        impl Shl<$t> for &Rational {\n            type Output = Rational;\n\n            /// Left-shifts a [`Rational`] (multiplies or divides it by a power of 2), taking it by\n            /// reference.\n            ///\n            /// $$\n            /// f(x, k) = x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shl#shl).\n            #[inline]\n            fn shl(self, bits: $t) -> Rational {\n                shl_signed_ref(self, bits)\n            }\n        }\n\n        impl ShlAssign<$t> for Rational {\n            /// Left-shifts a [`Rational`] (multiplies or divides it by a power of 2), in place.\n            ///\n            /// $$\n            /// x \\gets x2^k.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `bits`.\n            ///\n            /// See [here](super::shl#shl_assign).\n            fn shl_assign(&mut self, bits: $t) {\n                shl_assign_signed(self, bits);\n            }\n        }\n    };\n}\napply_to_signeds!(impl_shl_signed);\n"
  },
  {
    "path": "malachite-q/src/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::ops::{Shl, ShlAssign, Shr, ShrAssign};\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\nfn shr_unsigned_assign<T>(x: &mut Rational, bits: T)\nwhere\n    u64: TryFrom<T>,\n{\n    if *x == 0u32 {\n        return;\n    }\n    let numerator_zeros = x.numerator.trailing_zeros().unwrap();\n    let bits_64 = u64::exact_from(bits);\n    if numerator_zeros >= bits_64 {\n        x.numerator >>= bits_64;\n    } else {\n        x.denominator <<= bits_64 - numerator_zeros;\n        x.numerator >>= numerator_zeros;\n    }\n}\n\nfn shr_unsigned_ref<T>(x: &Rational, bits: T) -> Rational\nwhere\n    u64: TryFrom<T>,\n{\n    if *x == 0u32 {\n        return x.clone();\n    }\n    let numerator_zeros = x.numerator.trailing_zeros().unwrap();\n    let bits_64 = u64::exact_from(bits);\n    if numerator_zeros >= bits_64 {\n        Rational {\n            sign: x.sign,\n            numerator: &x.numerator >> bits_64,\n            denominator: x.denominator.clone(),\n        }\n    } else {\n        Rational {\n            sign: x.sign,\n            numerator: &x.numerator >> numerator_zeros,\n            denominator: &x.denominator << (bits_64 - numerator_zeros),\n        }\n    }\n}\n\nmacro_rules! impl_shr_unsigned {\n    ($t:ident) => {\n        impl Shr<$t> for Rational {\n            type Output = Rational;\n\n            /// Right-shifts a [`Rational`] (divides it by a power of 2), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\frac{x}{2^k}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(mut self, bits: $t) -> Rational {\n                self >>= bits;\n                self\n            }\n        }\n\n        impl Shr<$t> for &Rational {\n            type Output = Rational;\n\n            /// Right-shifts a [`Rational`] (divides it by a power of 2), taking it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\frac{x}{2^k}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Rational {\n                shr_unsigned_ref(self, bits)\n            }\n        }\n\n        impl ShrAssign<$t> for Rational {\n            /// Right-shifts a [`Rational`] (divides it by a power of 2), in place.\n            ///\n            /// $$\n            /// f(x, k) = \\frac{x}{2^k}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shr#shr_assign).\n            #[inline]\n            fn shr_assign(&mut self, bits: $t) {\n                shr_unsigned_assign(self, bits);\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_shr_unsigned);\n\nfn shr_signed_ref<'a, U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(\n    x: &'a Rational,\n    bits: S,\n) -> Rational\nwhere\n    &'a Rational: Shl<U, Output = Rational> + Shr<U, Output = Rational>,\n{\n    if bits >= S::ZERO {\n        x >> bits.unsigned_abs()\n    } else {\n        x << bits.unsigned_abs()\n    }\n}\n\nfn shr_assign_signed<U, S: Copy + Ord + UnsignedAbs<Output = U> + Zero>(x: &mut Rational, bits: S)\nwhere\n    Rational: ShlAssign<U> + ShrAssign<U>,\n{\n    if bits >= S::ZERO {\n        *x >>= bits.unsigned_abs();\n    } else {\n        *x <<= bits.unsigned_abs();\n    }\n}\n\nmacro_rules! impl_shr_signed {\n    ($t:ident) => {\n        impl Shr<$t> for Rational {\n            type Output = Rational;\n\n            /// Right-shifts a [`Rational`] (divides it by a power of 2), taking it by value.\n            ///\n            /// $$\n            /// f(x, k) = \\frac{x}{2^k}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(mut self, bits: $t) -> Rational {\n                self >>= bits;\n                self\n            }\n        }\n\n        impl Shr<$t> for &Rational {\n            type Output = Rational;\n\n            /// Right-shifts a [`Rational`] (divides it by a power of 2), taking it by reference.\n            ///\n            /// $$\n            /// f(x, k) = \\frac{x}{2^k}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shr#shr).\n            #[inline]\n            fn shr(self, bits: $t) -> Rational {\n                shr_signed_ref(self, bits)\n            }\n        }\n\n        impl ShrAssign<$t> for Rational {\n            /// Right-shifts a [`Rational`] (divides it by a power of 2), in reference.\n            ///\n            /// $$\n            /// f(x, k) = \\frac{x}{2^k}.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n, m) = O(n + m)$\n            ///\n            /// $M(n, m) = O(n + m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and\n            /// $m$ is `max(bits, 0)`.\n            ///\n            /// See [here](super::shr#shr_assign).\n            #[inline]\n            fn shr_assign(&mut self, bits: $t) {\n                shr_assign_signed(self, bits)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_shr_signed);\n"
  },
  {
    "path": "malachite-q/src/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\n\nimpl Sign for Rational {\n    /// Compares a [`Rational`] to zero.\n    ///\n    /// Returns `Greater`, `Equal`, or `Less`, depending on whether the [`Rational`] is positive,\n    /// zero, or negative, respectively.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Sign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(Rational::ZERO.sign(), Equal);\n    /// assert_eq!(Rational::from_signeds(22, 7).sign(), Greater);\n    /// assert_eq!(Rational::from_signeds(-22, 7).sign(), Less);\n    /// ```\n    fn sign(&self) -> Ordering {\n        if self.sign {\n            if self.numerator == 0 { Equal } else { Greater }\n        } else {\n            Less\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/simplest_rational_in_interval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::traits::SimplestRationalInInterval;\nuse crate::conversion::continued_fraction::to_continued_fraction::RationalContinuedFraction;\nuse crate::conversion::traits::ContinuedFraction;\nuse core::cmp::{\n    Ordering::{self, *},\n    max, min,\n};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{AddMul, Ceiling, Floor, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Two, Zero};\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_nz::natural::Natural;\n\nfn min_helper_oo<'a>(ox: &'a Option<Natural>, oy: &'a Option<Natural>) -> &'a Natural {\n    if let Some(x) = ox.as_ref() {\n        if let Some(y) = oy.as_ref() {\n            min(x, y)\n        } else {\n            x\n        }\n    } else {\n        oy.as_ref().unwrap()\n    }\n}\n\nfn min_helper_xo<'a>(x: &'a Natural, oy: &'a Option<Natural>) -> &'a Natural {\n    if let Some(y) = oy.as_ref() {\n        min(x, y)\n    } else {\n        x\n    }\n}\n\nfn simplest_rational_one_alt_helper(\n    x: &Natural,\n    oy_n: &Option<Natural>,\n    mut cf_y: RationalContinuedFraction,\n    numerator: &Natural,\n    denominator: &Natural,\n    previous_numerator: &Natural,\n    previous_denominator: &Natural,\n) -> Rational {\n    // use [a_0; a_1, ... a_k - 1, 1] and [b_0; b_1, ... b_k]\n    let (n, d) = if oy_n.is_some() && x - Natural::ONE == *oy_n.as_ref().unwrap() {\n        let next_numerator = previous_numerator.add_mul(numerator, oy_n.as_ref().unwrap());\n        let next_denominator = previous_denominator.add_mul(denominator, oy_n.as_ref().unwrap());\n        let next_oy_n = cf_y.next();\n        if next_oy_n == Some(Natural::ONE) {\n            let next_next_numerator = numerator + &next_numerator;\n            let next_next_denominator = denominator + &next_denominator;\n            // since y_n = 1, cf_y is not exhausted yet\n            let y_n = cf_y.next().unwrap() + Natural::ONE;\n            (\n                next_numerator.add_mul(next_next_numerator, &y_n),\n                next_denominator.add_mul(next_next_denominator, y_n),\n            )\n        } else {\n            (\n                numerator + (next_numerator << 1),\n                denominator + (next_denominator << 1),\n            )\n        }\n    } else {\n        let ox_n_m_1 = x - Natural::ONE;\n        let m = min_helper_xo(&ox_n_m_1, oy_n);\n        let next_numerator = previous_numerator.add_mul(numerator, m);\n        let next_denominator = previous_denominator.add_mul(denominator, m);\n        (\n            numerator + (next_numerator << 1),\n            denominator + (next_denominator << 1),\n        )\n    };\n    Rational {\n        sign: true,\n        numerator: n,\n        denominator: d,\n    }\n}\n\nfn update_best(best: &mut Option<Rational>, x: &Rational, y: &Rational, candidate: Rational) {\n    if best.is_none() && candidate > *x && candidate < *y {\n        *best = Some(candidate);\n    }\n}\n\nimpl Rational {\n    /// Compares two [`Rational`]s according to their complexity.\n    ///\n    /// Complexity is defined as follows: If two [`Rational`]s have different denominators, then the\n    /// one with the larger denominator is more complex. If they have the same denominator, then the\n    /// one whose numerator is further from zero is more complex. Finally, if $q > 0$, then $q$ is\n    /// simpler than $-q$.\n    ///\n    /// The [`Rational`]s ordered by complexity look like this:\n    /// $$\n    /// 0, 1, -1, 2, -2, \\ldots, 1/2, -1/2, 3/2, -3/2, \\ldots, 1/3, -1/3, 2/3, -2/3, \\ldots, \\ldots.\n    /// $$\n    /// This order is a well-order, and the order type of the [`Rational`]s under this order is\n    /// $\\omega^2$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 2).cmp_complexity(&Rational::from_signeds(1, 3)),\n    ///     Less\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 2).cmp_complexity(&Rational::from_signeds(3, 2)),\n    ///     Less\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 2).cmp_complexity(&Rational::from_signeds(-1, 2)),\n    ///     Less\n    /// );\n    /// ```\n    pub fn cmp_complexity(&self, other: &Self) -> Ordering {\n        self.denominator_ref()\n            .cmp(other.denominator_ref())\n            .then_with(|| self.numerator_ref().cmp(other.numerator_ref()))\n            .then_with(|| (*self < 0u32).cmp(&(*other < 0u32)))\n    }\n}\n\nimpl SimplestRationalInInterval for Rational {\n    /// Finds the simplest [`Rational`] contained in an open interval.\n    ///\n    /// Let $f(x, y) = p/q$, with $p$ and $q$ relatively prime. Then the following properties hold:\n    /// - $x < p/q < y$\n    /// - If $x < m/n < y$, then $n \\geq q$\n    /// - If $x < m/q < y$, then $|p| \\leq |m|$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2 \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if $x \\geq y$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::arithmetic::traits::SimplestRationalInInterval;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::simplest_rational_in_open_interval(\n    ///         &Rational::from_signeds(1, 3),\n    ///         &Rational::from_signeds(1, 2)\n    ///     ),\n    ///     Rational::from_signeds(2, 5)\n    /// );\n    /// assert_eq!(\n    ///     Rational::simplest_rational_in_open_interval(\n    ///         &Rational::from_signeds(-1, 3),\n    ///         &Rational::from_signeds(1, 3)\n    ///     ),\n    ///     Rational::ZERO\n    /// );\n    /// assert_eq!(\n    ///     Rational::simplest_rational_in_open_interval(\n    ///         &Rational::from_signeds(314, 100),\n    ///         &Rational::from_signeds(315, 100)\n    ///     ),\n    ///     Rational::from_signeds(22, 7)\n    /// );\n    /// ```\n    fn simplest_rational_in_open_interval(x: &Self, y: &Self) -> Rational {\n        assert!(x < y);\n        if *x < 0u32 && *y > 0u32 {\n            return Self::ZERO;\n        }\n        let neg_x;\n        let neg_y;\n        let (neg, x, y) = if *x < 0u32 {\n            neg_x = -x;\n            neg_y = -y;\n            (true, &neg_y, &neg_x)\n        } else {\n            (false, x, y)\n        };\n        let (floor_x, mut cf_x) = x.continued_fraction();\n        let floor_x = floor_x.unsigned_abs();\n        let (floor_y, mut cf_y) = y.continued_fraction();\n        let floor_y = floor_y.unsigned_abs();\n        let mut best = None;\n        if floor_x == floor_y {\n            let floor = floor_x;\n            let mut previous_numerator = Natural::ONE;\n            let mut previous_denominator = Natural::ZERO;\n            let mut numerator = floor;\n            let mut denominator = Natural::ONE;\n            let mut ox_n = cf_x.next();\n            let mut oy_n = cf_y.next();\n            while ox_n == oy_n {\n                // They are both Some\n                swap(&mut numerator, &mut previous_numerator);\n                swap(&mut denominator, &mut previous_denominator);\n                numerator = (&numerator).add_mul(&previous_numerator, &ox_n.unwrap());\n                denominator = (&denominator).add_mul(&previous_denominator, &oy_n.unwrap());\n                ox_n = cf_x.next();\n                oy_n = cf_y.next();\n            }\n            // use [x_0; x_1, ... x_k] and [y_0; y_1, ... y_k]\n            let m = min_helper_oo(&ox_n, &oy_n) + Natural::ONE;\n            let n = (&previous_numerator).add_mul(&numerator, &m);\n            let d = (&previous_denominator).add_mul(&denominator, &m);\n            let candidate = Self {\n                sign: true,\n                numerator: n,\n                denominator: d,\n            };\n            update_best(&mut best, x, y, candidate);\n            if let Some(x_n) = ox_n.as_ref()\n                && cf_x.is_done()\n            {\n                update_best(\n                    &mut best,\n                    x,\n                    y,\n                    simplest_rational_one_alt_helper(\n                        x_n,\n                        &oy_n,\n                        cf_y.clone(),\n                        &numerator,\n                        &denominator,\n                        &previous_numerator,\n                        &previous_denominator,\n                    ),\n                );\n            }\n            if let Some(y_n) = oy_n.as_ref()\n                && cf_y.is_done()\n            {\n                update_best(\n                    &mut best,\n                    x,\n                    y,\n                    simplest_rational_one_alt_helper(\n                        y_n,\n                        &ox_n,\n                        cf_x.clone(),\n                        &numerator,\n                        &denominator,\n                        &previous_numerator,\n                        &previous_denominator,\n                    ),\n                );\n            }\n            if ox_n.is_some() && oy_n.is_some() && cf_x.is_done() != cf_y.is_done() {\n                if cf_y.is_done() {\n                    swap(&mut ox_n, &mut oy_n);\n                    swap(&mut cf_y, &mut cf_x);\n                }\n                let x_n = ox_n.unwrap();\n                let y_n = oy_n.unwrap();\n                if y_n == x_n - Natural::ONE {\n                    let next_y_n = cf_y.next().unwrap();\n                    let next_numerator = (&previous_numerator).add_mul(&numerator, &y_n);\n                    let next_denominator = (&previous_denominator).add_mul(&denominator, &y_n);\n                    let (n, d) = if cf_y.is_done() && next_y_n == 2u32 {\n                        (\n                            next_numerator * Natural::from(3u32) + (numerator << 1),\n                            next_denominator * Natural::from(3u32) + (denominator << 1),\n                        )\n                    } else {\n                        (\n                            previous_numerator + (numerator << 1),\n                            previous_denominator + (denominator << 1),\n                        )\n                    };\n                    let candidate = Self {\n                        sign: true,\n                        numerator: n,\n                        denominator: d,\n                    };\n                    update_best(&mut best, x, y, candidate);\n                }\n            }\n        } else {\n            let candidate = if floor_y - Natural::ONE != floor_x || !cf_y.is_done() {\n                Self::from(floor_x + Natural::ONE)\n            } else {\n                let floor = floor_x;\n                // [f; x_1, x_2, x_3...] and [f + 1]. But to get any good candidates, we need [f;\n                // x_1, x_2, x_3...] and [f; 1]. If x_1 does not exist, the result is [f; 2].\n                let (n, d) = if cf_x.is_done() {\n                    ((floor << 1) | Natural::ONE, Natural::TWO)\n                } else {\n                    let x_1 = cf_x.next().unwrap();\n                    if x_1 > Natural::ONE {\n                        if x_1 == 2u32 && cf_x.is_done() {\n                            // [f; 1, 1] and [f; 1], so [f; 1, 2] is a candidate.\n                            (\n                                floor * Natural::from(3u32) + Natural::TWO,\n                                Natural::from(3u32),\n                            )\n                        } else {\n                            // If x_1 > 1, we have [f; 2] as a candidate.\n                            ((floor << 1) | Natural::ONE, Natural::TWO)\n                        }\n                    } else {\n                        // x_2 exists since x_1 was 1\n                        let x_2 = cf_x.next().unwrap();\n                        // [f; 1, x_2] and [f; 1], so [f; 1, x_2 + 1] is a candidate. [f; 1, x_2 -\n                        // 1, 1] and [f; 1], but [f; 1, x_2] is not in the interval\n                        let k = &x_2 + Natural::ONE;\n                        (&floor * &k + floor + k, x_2 + Natural::TWO)\n                    }\n                };\n                Self {\n                    sign: true,\n                    numerator: n,\n                    denominator: d,\n                }\n            };\n            update_best(&mut best, x, y, candidate);\n        }\n        let best = best.unwrap();\n        if neg { -best } else { best }\n    }\n\n    /// Finds the simplest [`Rational`] contained in a closed interval.\n    ///\n    /// Let $f(x, y) = p/q$, with $p$ and $q$ relatively prime. Then the following properties hold:\n    /// - $x \\leq p/q \\leq y$\n    /// - If $x \\leq m/n \\leq y$, then $n \\geq q$\n    /// - If $x \\leq m/q \\leq y$, then $|p| \\leq |m|$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2 \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(x.significant_bits(),\n    /// y.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if $x > y$.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::arithmetic::traits::SimplestRationalInInterval;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::simplest_rational_in_closed_interval(\n    ///         &Rational::from_signeds(1, 3),\n    ///         &Rational::from_signeds(1, 2)\n    ///     ),\n    ///     Rational::from_signeds(1, 2)\n    /// );\n    /// assert_eq!(\n    ///     Rational::simplest_rational_in_closed_interval(\n    ///         &Rational::from_signeds(-1, 3),\n    ///         &Rational::from_signeds(1, 3)\n    ///     ),\n    ///     Rational::ZERO\n    /// );\n    /// assert_eq!(\n    ///     Rational::simplest_rational_in_closed_interval(\n    ///         &Rational::from_signeds(314, 100),\n    ///         &Rational::from_signeds(315, 100)\n    ///     ),\n    ///     Rational::from_signeds(22, 7)\n    /// );\n    /// ```\n    fn simplest_rational_in_closed_interval(x: &Self, y: &Self) -> Rational {\n        assert!(x <= y);\n        if x == y {\n            return x.clone();\n        } else if *x <= 0u32 && *y >= 0u32 {\n            return Self::ZERO;\n        } else if x.is_integer() {\n            return if y.is_integer() {\n                if *x >= 0u32 {\n                    min(x, y).clone()\n                } else {\n                    max(x, y).clone()\n                }\n            } else if *x >= 0u32 {\n                x.clone()\n            } else {\n                Self::from(y.floor())\n            };\n        } else if y.is_integer() {\n            return if *x >= 0u32 {\n                Self::from(x.ceiling())\n            } else {\n                y.clone()\n            };\n        }\n        let mut best = Self::simplest_rational_in_open_interval(x, y);\n        for q in [x, y] {\n            if q.cmp_complexity(&best) == Less {\n                best = q.clone();\n            }\n        }\n        best\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{CheckedSqrt, UnsignedAbs};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\n\nimpl CheckedSqrt for Rational {\n    type Output = Self;\n\n    /// Returns the the square root of a [`Rational`], or `None` if it is not a perfect square. The\n    /// [`Rational`] is taken by value.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\mathbb{Q}, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedSqrt;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from(99u8).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(100u8).checked_sqrt().to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from(101u8).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7)\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(25, 9)\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"Some(5/3)\"\n    /// );\n    /// ```\n    fn checked_sqrt(self) -> Option<Self> {\n        assert!(self >= 0);\n        let (n, d) = self.into_numerator_and_denominator();\n        let sqrt_n;\n        let sqrt_d;\n        if n.significant_bits() <= d.significant_bits() {\n            sqrt_n = n.checked_sqrt()?;\n            sqrt_d = d.checked_sqrt()?;\n        } else {\n            sqrt_d = d.checked_sqrt()?;\n            sqrt_n = n.checked_sqrt()?;\n        }\n        Some(Self {\n            sign: sqrt_n >= 0,\n            numerator: sqrt_n,\n            denominator: sqrt_d,\n        })\n    }\n}\n\nimpl CheckedSqrt for &Rational {\n    type Output = Rational;\n\n    /// Returns the the square root of a [`Rational`], or `None` if it is not a perfect square. The\n    /// [`Rational`] is taken by reference.\n    ///\n    /// $$\n    /// f(x) = \\\\begin{cases}\n    ///     \\operatorname{Some}(sqrt{x}) & \\text{if} \\\\quad \\sqrt{x} \\in \\mathbb{Q}, \\\\\\\\\n    ///     \\operatorname{None} & \\textrm{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `self` is negative.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::CheckedSqrt;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from(99u8)).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from(100u8)).checked_sqrt().to_debug_string(),\n    ///     \"Some(10)\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from(101u8)).checked_sqrt().to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7))\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"None\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(25, 9))\n    ///         .checked_sqrt()\n    ///         .to_debug_string(),\n    ///     \"Some(5/3)\"\n    /// );\n    /// ```\n    fn checked_sqrt(self) -> Option<Rational> {\n        let (n, d) = self.numerator_and_denominator_ref();\n        let sqrt_n;\n        let sqrt_d;\n        if n.significant_bits() <= d.significant_bits() {\n            sqrt_n = Integer::from_sign_and_abs_ref(*self >= 0, n).checked_sqrt()?;\n            sqrt_d = d.checked_sqrt()?;\n        } else {\n            sqrt_d = d.checked_sqrt()?;\n            sqrt_n = Integer::from_sign_and_abs_ref(*self >= 0, n).checked_sqrt()?;\n        }\n        Some(Rational {\n            sign: true,\n            numerator: sqrt_n.unsigned_abs(),\n            denominator: sqrt_d,\n        })\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{Square, SquareAssign};\n\nimpl Square for Rational {\n    type Output = Self;\n\n    /// Squares a [`Rational`], taking it by value.\n    ///\n    /// $$\n    /// f(x) = x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ZERO.square(), 0);\n    /// assert_eq!(Rational::from_signeds(22, 7).square().to_string(), \"484/49\");\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).square().to_string(),\n    ///     \"484/49\"\n    /// );\n    /// ```\n    #[inline]\n    fn square(mut self) -> Self {\n        self.square_assign();\n        self\n    }\n}\n\nimpl Square for &Rational {\n    type Output = Rational;\n\n    /// Squares a [`Rational`], taking it by reference.\n    ///\n    /// $$\n    /// f(x) = x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::Square;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!((&Rational::ZERO).square(), 0);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7)).square().to_string(),\n    ///     \"484/49\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(-22, 7)).square().to_string(),\n    ///     \"484/49\"\n    /// );\n    /// ```\n    #[inline]\n    fn square(self) -> Rational {\n        Rational {\n            sign: true,\n            numerator: (&self.numerator).square(),\n            denominator: (&self.denominator).square(),\n        }\n    }\n}\n\nimpl SquareAssign for Rational {\n    /// Squares a [`Rational`] in place.\n    ///\n    /// $$\n    /// x \\gets x^2.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::SquareAssign;\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ZERO;\n    /// x.square_assign();\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x.square_assign();\n    /// assert_eq!(x.to_string(), \"484/49\");\n    ///\n    /// let mut x = Rational::from_signeds(-22, 7);\n    /// x.square_assign();\n    /// assert_eq!(x.to_string(), \"484/49\");\n    /// ```\n    fn square_assign(&mut self) {\n        self.sign = true;\n        self.numerator.square_assign();\n        self.denominator.square_assign();\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// Uses code adopted from the GNU MP Library.\n//\n//      Copyright © 1991, 1994-1997, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::ops::{Sub, SubAssign};\nuse malachite_base::num::arithmetic::traits::{\n    DivExact, DivExactAssign, Gcd, GcdAssign, NegAssign, UnsignedAbs,\n};\nuse malachite_nz::integer::Integer;\n\nimpl Sub<Self> for Rational {\n    type Output = Self;\n\n    /// Subtracts a [`Rational`] by another [`Rational`], taking both by value.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF - Rational::ONE_HALF, 0);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) - Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    fn sub(self, other: Self) -> Self {\n        if self == 0u32 {\n            return -other;\n        } else if other == 0u32 {\n            return self;\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            let diff_n = Integer::from_sign_and_abs(self.sign, self.numerator * &other.denominator)\n                - Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            let diff_d = self.denominator * other.denominator;\n            Self {\n                sign: diff_n >= 0,\n                numerator: diff_n.unsigned_abs(),\n                denominator: diff_d,\n            }\n        } else {\n            let reduced_self_d = (self.denominator).div_exact(&gcd);\n            let diff_n =\n                Integer::from_sign_and_abs(\n                    self.sign,\n                    self.numerator * (&other.denominator).div_exact(&gcd),\n                ) - Integer::from_sign_and_abs(other.sign, other.numerator * &reduced_self_d);\n            gcd.gcd_assign(diff_n.unsigned_abs_ref());\n            if gcd == 1u32 {\n                Self {\n                    sign: diff_n >= 0,\n                    numerator: diff_n.unsigned_abs(),\n                    denominator: other.denominator * reduced_self_d,\n                }\n            } else {\n                Self {\n                    sign: diff_n >= 0,\n                    numerator: diff_n.unsigned_abs().div_exact(&gcd),\n                    denominator: (other.denominator).div_exact(gcd) * reduced_self_d,\n                }\n            }\n        }\n    }\n}\n\nimpl Sub<&Self> for Rational {\n    type Output = Self;\n\n    /// Subtracts a [`Rational`] by another [`Rational`], taking the first by value and the second\n    /// by reference.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ONE_HALF - &Rational::ONE_HALF, 0);\n    /// assert_eq!(\n    ///     (Rational::from_signeds(22, 7) - &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    #[inline]\n    fn sub(self, other: &Self) -> Self {\n        -(other - self)\n    }\n}\n\nimpl Sub<Rational> for &Rational {\n    type Output = Rational;\n\n    /// Subtracts a [`Rational`] by another [`Rational`], taking the first by reference and the\n    /// second by value.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::ONE_HALF - Rational::ONE_HALF, 0);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) - Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    fn sub(self, other: Rational) -> Rational {\n        if *self == 0u32 {\n            return -other;\n        } else if other == 0u32 {\n            return self.clone();\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            let diff_n =\n                Integer::from_sign_and_abs(self.sign, &self.numerator * &other.denominator)\n                    - Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            let diff_d = &self.denominator * other.denominator;\n            Rational {\n                sign: diff_n >= 0,\n                numerator: diff_n.unsigned_abs(),\n                denominator: diff_d,\n            }\n        } else {\n            let reduced_self_d = (&self.denominator).div_exact(&gcd);\n            let diff_n =\n                Integer::from_sign_and_abs(\n                    self.sign,\n                    &self.numerator * (&other.denominator).div_exact(&gcd),\n                ) - Integer::from_sign_and_abs(other.sign, other.numerator * &reduced_self_d);\n            gcd.gcd_assign(diff_n.unsigned_abs_ref());\n            if gcd == 1u32 {\n                Rational {\n                    sign: diff_n >= 0,\n                    numerator: diff_n.unsigned_abs(),\n                    denominator: other.denominator * reduced_self_d,\n                }\n            } else {\n                Rational {\n                    sign: diff_n >= 0,\n                    numerator: diff_n.unsigned_abs().div_exact(&gcd),\n                    denominator: (other.denominator).div_exact(gcd) * reduced_self_d,\n                }\n            }\n        }\n    }\n}\n\nimpl Sub<&Rational> for &Rational {\n    type Output = Rational;\n\n    /// Subtracts a [`Rational`] by another [`Rational`], taking both by reference.\n    ///\n    /// $$\n    /// f(x, y) = x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(&Rational::ONE_HALF - &Rational::ONE_HALF, 0);\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(22, 7) - &Rational::from_signeds(99, 100)).to_string(),\n    ///     \"1507/700\"\n    /// );\n    /// ```\n    fn sub(self, other: &Rational) -> Rational {\n        if *self == 0u32 {\n            return -other.clone();\n        } else if *other == 0u32 {\n            return self.clone();\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            let diff_n =\n                Integer::from_sign_and_abs(self.sign, &self.numerator * &other.denominator)\n                    - Integer::from_sign_and_abs(other.sign, &other.numerator * &self.denominator);\n            let diff_d = &self.denominator * &other.denominator;\n            Rational {\n                sign: diff_n >= 0,\n                numerator: diff_n.unsigned_abs(),\n                denominator: diff_d,\n            }\n        } else {\n            let reduced_self_d = (&self.denominator).div_exact(&gcd);\n            let diff_n =\n                Integer::from_sign_and_abs(\n                    self.sign,\n                    &self.numerator * (&other.denominator).div_exact(&gcd),\n                ) - Integer::from_sign_and_abs(other.sign, &other.numerator * &reduced_self_d);\n            gcd.gcd_assign(diff_n.unsigned_abs_ref());\n            if gcd == 1u32 {\n                Rational {\n                    sign: diff_n >= 0,\n                    numerator: diff_n.unsigned_abs(),\n                    denominator: &other.denominator * reduced_self_d,\n                }\n            } else {\n                Rational {\n                    sign: diff_n >= 0,\n                    numerator: diff_n.unsigned_abs().div_exact(&gcd),\n                    denominator: (&other.denominator).div_exact(gcd) * reduced_self_d,\n                }\n            }\n        }\n    }\n}\n\nimpl SubAssign<Self> for Rational {\n    /// Subtracts a [`Rational`] by another [`Rational`] in place, taking the [`Rational`] on the\n    /// right-hand side by value.\n    ///\n    /// $$\n    /// x \\gets x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x -= Rational::ONE_HALF;\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x -= Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"1507/700\");\n    /// ```\n    fn sub_assign(&mut self, other: Self) {\n        if *self == 0u32 {\n            *self = -other;\n            return;\n        } else if other == 0u32 {\n            return;\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            self.numerator *= &other.denominator;\n            let diff_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                - Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            self.sign = diff_n >= 0;\n            self.numerator = diff_n.unsigned_abs();\n            self.denominator *= other.denominator;\n        } else {\n            self.denominator.div_exact_assign(&gcd);\n            self.numerator *= (&other.denominator).div_exact(&gcd);\n            let diff_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                - Integer::from_sign_and_abs(other.sign, other.numerator * &self.denominator);\n            gcd.gcd_assign(diff_n.unsigned_abs_ref());\n            self.sign = diff_n >= 0;\n            if gcd == 1u32 {\n                self.numerator = diff_n.unsigned_abs();\n                self.denominator *= other.denominator;\n            } else {\n                self.numerator = diff_n.unsigned_abs().div_exact(&gcd);\n                self.denominator *= (other.denominator).div_exact(gcd);\n            }\n        }\n    }\n}\n\nimpl SubAssign<&Self> for Rational {\n    /// Subtracts a [`Rational`] by another [`Rational`] in place, taking the [`Rational`] on the\n    /// right-hand side by reference.\n    ///\n    /// $$\n    /// x \\gets x - y.\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut x = Rational::ONE_HALF;\n    /// x -= &Rational::ONE_HALF;\n    /// assert_eq!(x, 0);\n    ///\n    /// let mut x = Rational::from_signeds(22, 7);\n    /// x -= &Rational::from_signeds(99, 100);\n    /// assert_eq!(x.to_string(), \"1507/700\");\n    /// ```\n    fn sub_assign(&mut self, other: &Self) {\n        if *self == 0u32 {\n            self.clone_from(other);\n            self.neg_assign();\n            return;\n        } else if *other == 0u32 {\n            return;\n        }\n        let mut gcd = (&self.denominator).gcd(&other.denominator);\n        if gcd == 1u32 {\n            self.numerator *= &other.denominator;\n            let diff_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                - Integer::from_sign_and_abs(other.sign, &other.numerator * &self.denominator);\n            self.sign = diff_n >= 0;\n            self.numerator = diff_n.unsigned_abs();\n            self.denominator *= &other.denominator;\n        } else {\n            self.denominator.div_exact_assign(&gcd);\n            self.numerator *= (&other.denominator).div_exact(&gcd);\n            let diff_n = Integer::from_sign_and_abs_ref(self.sign, &self.numerator)\n                - Integer::from_sign_and_abs(other.sign, &other.numerator * &self.denominator);\n            gcd.gcd_assign(diff_n.unsigned_abs_ref());\n            self.sign = diff_n >= 0;\n            if gcd == 1u32 {\n                self.numerator = diff_n.unsigned_abs();\n                self.denominator *= &other.denominator;\n            } else {\n                self.numerator = diff_n.unsigned_abs().div_exact(&gcd);\n                self.denominator *= (&other.denominator).div_exact(gcd);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/arithmetic/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_nz::natural::Natural;\n\n/// Replaces a number with the closest [`Rational`] whose denominator does not exceed the specified\n/// maximum.\npub trait ApproximateAssign {\n    fn approximate_assign(&mut self, max_denominator: &Natural);\n}\n\n/// Returns the closest [`Rational`] whose denominator does not exceed the specified maximum.\npub trait Approximate {\n    fn approximate(self, max_denominator: &Natural) -> Rational;\n}\n\n/// Finds the simplest [`Rational`] contained in an interval.\npub trait SimplestRationalInInterval {\n    /// Finds the simplest [`Rational`] contained in an open interval.\n    ///\n    /// Simplicity is defined as follows: If two [`Rational`]s have different denominators, then the\n    /// one with the smaller denominator is simpler. If they have the same denominator, then the one\n    /// whose numerator is closer to zero is simpler. Finally, if $q > 0$, then $q$ is simpler than\n    /// $-q$.\n    fn simplest_rational_in_open_interval(x: &Self, y: &Self) -> Rational;\n\n    /// Finds the simplest [`Rational`] contained in a closed interval.\n    ///\n    /// Simplicity is defined as follows: If two [`Rational`]s have different denominators, then the\n    /// one with the smaller denominator is simpler. If they have the same denominator, then the one\n    /// whose numerator is closer to zero is simpler. Finally, if $q > 0$, then $q$ is simpler than\n    /// $-q$.\n    fn simplest_rational_in_closed_interval(x: &Self, y: &Self) -> Rational;\n}\n\n// Returns an iterator of all denominators that appear in the [`Rational`]s contained in a closed\n// interval.\npub trait DenominatorsInClosedInterval {\n    type Denominators: Iterator<Item = Natural>;\n\n    fn denominators_in_closed_interval(a: Rational, b: Rational) -> Self::Denominators;\n}\n"
  },
  {
    "path": "malachite-q/src/bin.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n\n#[cfg(feature = \"bin_build\")]\nextern crate itertools;\n#[cfg(feature = \"bin_build\")]\n#[macro_use]\nextern crate malachite_base;\n#[cfg(feature = \"bin_build\")]\nextern crate malachite_nz;\n#[cfg(feature = \"bin_build\")]\nextern crate malachite_q;\n#[cfg(feature = \"bin_build\")]\nextern crate num;\n#[cfg(feature = \"bin_build\")]\nextern crate rug;\n#[cfg(feature = \"bin_build\")]\nextern crate serde;\n#[cfg(feature = \"bin_build\")]\nextern crate serde_json;\n\n#[cfg(feature = \"bin_build\")]\nuse crate::bin_util::demo_and_bench::register;\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::Runner;\n#[cfg(feature = \"bin_build\")]\nuse malachite_base::test_util::runner::cmd::read_command_line_arguments;\n\n// Examples:\n//\n// ```\n// cargo run --release --features bin_build -- -l 10000 -m special_random -d demo_from_naturals\n//      -c \"mean_bits_n 128 mean_bits_d 1\"\n// ```\n#[cfg(feature = \"bin_build\")]\nfn main() {\n    let args = read_command_line_arguments(\"malachite-q test utils\");\n    let mut runner = Runner::new();\n    register(&mut runner);\n    if let Some(demo_key) = args.demo_key {\n        runner.run_demo(&demo_key, args.generation_mode, &args.config, args.limit);\n    } else if let Some(bench_key) = args.bench_key {\n        runner.run_bench(\n            &bench_key,\n            args.generation_mode,\n            &args.config,\n            args.limit,\n            &args.out,\n        );\n    } else {\n        panic!();\n    }\n}\n\n#[cfg(not(feature = \"bin_build\"))]\nfn main() {}\n\n#[cfg(feature = \"bin_build\")]\npub mod bin_util {\n    pub mod demo_and_bench;\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    rational_bit_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\nuse num::Signed;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_abs);\n    register_demo!(runner, demo_rational_abs_ref);\n    register_demo!(runner, demo_rational_abs_assign);\n\n    register_bench!(runner, benchmark_rational_abs_library_comparison);\n    register_bench!(runner, benchmark_rational_abs_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_abs_assign);\n}\n\nfn demo_rational_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"|{}| = {}\", n.clone(), n.abs());\n    }\n}\n\nfn demo_rational_abs_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"|&{}| = {}\", n, (&n).abs());\n    }\n}\n\nfn demo_rational_abs_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in rational_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.abs_assign();\n        println!(\"n := {n_old}; n.abs_assign(); n = {n}\");\n    }\n}\n\nfn benchmark_rational_abs_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.abs())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.abs())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.abs().cmp0())),\n        ],\n    );\n}\n\nfn benchmark_rational_abs_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.abs()\", &mut |n| no_out!(n.abs())),\n            (\"(&Rational).abs()\", &mut |n| no_out!((&n).abs())),\n        ],\n    );\n}\n\nfn benchmark_rational_abs_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.abs_assign()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.abs_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{AbsDiff, AbsDiffAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_rational_max_bit_bucketer;\nuse malachite_q::test_util::generators::rational_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_abs_diff);\n    register_demo!(runner, demo_rational_abs_diff_val_ref);\n    register_demo!(runner, demo_rational_abs_diff_ref_val);\n    register_demo!(runner, demo_rational_abs_diff_ref_ref);\n    register_demo!(runner, demo_rational_abs_diff_assign);\n    register_demo!(runner, demo_rational_abs_diff_assign_ref);\n\n    register_bench!(\n        runner,\n        benchmark_rational_abs_diff_assign_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_abs_diff_evaluation_strategy);\n}\n\nfn demo_rational_abs_diff(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"|{} - {}| = {:?}\", x_old, y_old, x.abs_diff(y));\n    }\n}\n\nfn demo_rational_abs_diff_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"|{} - &{}| = {:?}\", x_old, y, x.abs_diff(&y));\n    }\n}\n\nfn demo_rational_abs_diff_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"|&{} - {}| = {:?}\", x, y_old, (&x).abs_diff(y));\n    }\n}\n\nfn demo_rational_abs_diff_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"|&{} - &{}| = {:?}\", x, y, (&x).abs_diff(&y));\n    }\n}\n\nfn demo_rational_abs_diff_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.abs_diff_assign(y);\n        println!(\"x := {x_old}; x.abs_diff_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_rational_abs_diff_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.abs_diff_assign(&y);\n        println!(\"x := {x_old}; x.abs_diff_assign(&{y}); x = {x}\");\n    }\n}\n\nfn benchmark_rational_abs_diff_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs_diff_assign(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational.abs_diff_assign(Rational)\", &mut |(mut x, y)| {\n                x.abs_diff_assign(y);\n            }),\n            (\"Rational.abs_diff_assign(&Rational)\", &mut |(mut x, y)| {\n                x.abs_diff_assign(&y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_abs_diff_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.abs_diff(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational.abs_diff(Rational)\", &mut |(x, y)| {\n                no_out!(x.abs_diff(y));\n            }),\n            (\"Rational.abs_diff(&Rational)\", &mut |(x, y)| {\n                no_out!(x.abs_diff(&y));\n            }),\n            (\"&Rational.abs_diff(Rational)\", &mut |(x, y)| {\n                no_out!((&x).abs_diff(y));\n            }),\n            (\"&Rational.abs_diff(&Rational)\", &mut |(x, y)| {\n                no_out!((&x).abs_diff(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::add::add_naive;\nuse malachite_q::test_util::arithmetic::add::rational_sum_naive;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_2_pair_rational_max_bit_bucketer, pair_rational_max_bit_bucketer,\n    triple_3_pair_rational_max_bit_bucketer, triple_3_vec_rational_sum_bits_bucketer,\n    vec_rational_sum_bits_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_pair_gen, rational_pair_gen_nrm, rational_pair_gen_rm, rational_vec_gen,\n    rational_vec_gen_nrm,\n};\nuse num::BigRational;\nuse std::iter::Sum;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_add);\n    register_demo!(runner, demo_rational_add_val_ref);\n    register_demo!(runner, demo_rational_add_ref_val);\n    register_demo!(runner, demo_rational_add_ref_ref);\n    register_demo!(runner, demo_rational_add_assign);\n    register_demo!(runner, demo_rational_add_assign_ref);\n    register_demo!(runner, demo_rational_sum);\n    register_demo!(runner, demo_rational_ref_sum);\n\n    register_bench!(runner, benchmark_rational_add_library_comparison);\n    register_bench!(runner, benchmark_rational_add_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_add_algorithms);\n    register_bench!(runner, benchmark_rational_add_assign_library_comparison);\n    register_bench!(runner, benchmark_rational_add_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_sum_algorithms);\n    register_bench!(runner, benchmark_rational_sum_library_comparison);\n    register_bench!(runner, benchmark_rational_sum_evaluation_strategy);\n}\n\nfn demo_rational_add(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} + {} = {}\", x_old, y_old, x + y);\n    }\n}\n\nfn demo_rational_add_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} + &{} = {}\", x_old, y, x + &y);\n    }\n}\n\nfn demo_rational_add_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} + {} = {}\", x, y_old, &x + y);\n    }\n}\n\nfn demo_rational_add_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} + &{} = {}\", x, y, &x + &y);\n    }\n}\n\nfn demo_rational_add_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += y.clone();\n        println!(\"x := {x_old}; x += {y}; x = {x}\");\n    }\n}\n\nfn demo_rational_add_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x += &y;\n        println!(\"x := {x_old}; x += &{y}; x = {x}\");\n    }\n}\n\nfn demo_rational_sum(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in rational_vec_gen().get(gm, config).take(limit) {\n        println!(\"sum({:?}) = {}\", xs.clone(), Rational::sum(xs.into_iter()));\n    }\n}\n\nfn demo_rational_ref_sum(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in rational_vec_gen().get(gm, config).take(limit) {\n        println!(\"sum({:?}) = {}\", xs, Rational::sum(xs.iter()));\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_add_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational + Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x + y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x + y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x + y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_add_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational + Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational + Rational\", &mut |(x, y)| no_out!(x + y)),\n            (\"Rational + &Rational\", &mut |(x, y)| no_out!(x + &y)),\n            (\"&Rational + Rational\", &mut |(x, y)| no_out!(&x + y)),\n            (\"&Rational + &Rational\", &mut |(x, y)| no_out!(&x + &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_add_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational + Rational\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x + y)),\n            (\"naive\", &mut |(x, y)| no_out!(add_naive(x, y))),\n        ],\n    );\n}\n\nfn benchmark_rational_add_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational += Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x += y), (\"rug\", &mut |((mut x, y), _)| x += y)],\n    );\n}\n\nfn benchmark_rational_add_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational += Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational += Rational\", &mut |(mut x, y)| no_out!(x += y)),\n            (\"Rational += &Rational\", &mut |(mut x, y)| no_out!(x += &y)),\n        ],\n    );\n}\n\nfn benchmark_rational_sum_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::sum(Iterator<Item=Rational>)\",\n        BenchmarkType::LibraryComparison,\n        rational_vec_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_rational_sum_bits_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, xs)| {\n                no_out!(Rational::sum(xs.into_iter()));\n            }),\n            (\"num\", &mut |(xs, _, _)| {\n                no_out!(BigRational::sum(xs.into_iter()));\n            }),\n            (\"rug\", &mut |(_, xs, _)| {\n                no_out!(rug::Rational::sum(xs.iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_sum_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::sum(Iterator<Item=Rational>)\",\n        BenchmarkType::Algorithms,\n        rational_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_rational_sum_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |xs| no_out!(Rational::sum(xs.into_iter()))),\n            (\"naive\", &mut |xs| {\n                no_out!(rational_sum_naive(xs.into_iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_sum_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::sum(Iterator<Item=Rational>)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_rational_sum_bits_bucketer(),\n        &mut [\n            (\"Rational::sum(Iterator<Item=Rational>)\", &mut |xs| {\n                no_out!(Rational::sum(xs.into_iter()));\n            }),\n            (\"Rational::sum(Iterator<Item=&Rational>)\", &mut |xs| {\n                no_out!(Rational::sum(xs.iter()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/approximate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_natural_inclusive_range;\nuse malachite_q::arithmetic::traits::{Approximate, ApproximateAssign};\nuse malachite_q::test_util::arithmetic::approximate::approximate_naive;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_gen_var_7, rational_natural_pair_gen_var_3, rational_natural_pair_gen_var_4,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_approximate_assign);\n    register_demo!(runner, demo_rational_approximate);\n    register_demo!(runner, demo_rational_approximate_ref);\n    register_demo!(runner, demo_rational_approximate_2);\n\n    register_bench!(runner, benchmark_rational_approximate_assign);\n    register_bench!(runner, benchmark_rational_approximate_algorithms);\n    register_bench!(runner, benchmark_rational_approximate_evaluation_strategy);\n}\n\nfn demo_rational_approximate_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_natural_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        x.approximate_assign(&y);\n        println!(\"x := {x_old}; x.approximate_assign({y}); x = {x}\");\n    }\n}\n\nfn demo_rational_approximate(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"({}).approximate({}) = {}\", x.clone(), y, x.approximate(&y));\n    }\n}\n\nfn demo_rational_approximate_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen_var_3()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).approximate({}) = {}\", x, y, (&x).approximate(&y));\n    }\n}\n\nfn demo_rational_approximate_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen_var_7().get(gm, config).take(limit) {\n        println!(\"{x}\");\n        for d in exhaustive_natural_inclusive_range(Natural::ONE, x.to_denominator()) {\n            let a = (&x).approximate(&d);\n            println!(\"    {}: {} ≈ {}\", d, a, NiceFloat(f64::exact_from(&a)));\n        }\n    }\n}\n\nfn benchmark_rational_approximate_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.approximate_assign(&Natural)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut x, y)| x.approximate_assign(&y))],\n    );\n}\n\nfn benchmark_rational_approximate_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.approximate(&Natural)\",\n        BenchmarkType::Algorithms,\n        rational_natural_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.approximate(&y))),\n            (\"naive\", &mut |(x, y)| no_out!(approximate_naive(&x, &y))),\n        ],\n    );\n}\n\nfn benchmark_rational_approximate_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.approximate(&Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_natural_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Rational.approximate(&Natural)\", &mut |(x, y)| {\n                no_out!(x.approximate(&y));\n            }),\n            (\"(&Rational).approximate(&Natural)\", &mut |(x, y)| {\n                no_out!((&x).approximate(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/ceiling.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ceiling, CeilingAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    rational_bit_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_ceiling);\n    register_demo!(runner, demo_rational_ceiling_ref);\n    register_demo!(runner, demo_rational_ceiling_assign);\n\n    register_bench!(runner, benchmark_rational_ceiling_library_comparison);\n    register_bench!(runner, benchmark_rational_ceiling_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_ceiling_assign);\n}\n\nfn demo_rational_ceiling(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"ceiling({}) = {}\", n.clone(), n.ceiling());\n    }\n}\n\nfn demo_rational_ceiling_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"ceiling(&{}) = {}\", n, (&n).ceiling());\n    }\n}\n\nfn demo_rational_ceiling_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in rational_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.ceiling_assign();\n        println!(\"n := {n_old}; n.ceiling_assign(); n = {n}\");\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_ceiling_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.ceiling())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.ceil())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.ceil())),\n        ],\n    );\n}\n\nfn benchmark_rational_ceiling_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.ceiling()\", &mut |n| no_out!(n.ceiling())),\n            (\"(&Rational).ceiling()\", &mut |n| no_out!((&n).ceiling())),\n        ],\n    );\n}\n\nfn benchmark_rational_ceiling_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling_assign()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.ceiling_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/denominators_in_closed_interval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::prefix_to_string;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::arithmetic::traits::DenominatorsInClosedInterval;\nuse malachite_q::test_util::bench::bucketers::pair_2_rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_pair_gen_var_3;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_denominators_in_closed_interval);\n    register_bench!(runner, benchmark_denominators_in_closed_interval);\n}\n\nfn demo_denominators_in_closed_interval(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (a, b) in rational_pair_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"denominators_in_closed_interval({}, {}) = {}\",\n            a,\n            b,\n            prefix_to_string(\n                Rational::denominators_in_closed_interval(a.clone(), b.clone()),\n                20\n            )\n        );\n    }\n}\n\nfn benchmark_denominators_in_closed_interval(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"denominators_in_closed_interval(&Rational, &Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(a, b)| {\n            no_out!(Rational::denominators_in_closed_interval(a, b));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::CheckedDiv;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::arithmetic::div::div_naive;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_2_pair_rational_max_bit_bucketer, pair_rational_max_bit_bucketer,\n    triple_3_pair_rational_max_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_pair_gen, rational_pair_gen_nm, rational_pair_gen_var_1, rational_pair_gen_var_1_nrm,\n    rational_pair_gen_var_1_rm,\n};\nuse num::CheckedDiv as NumCheckedDiv;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_div);\n    register_demo!(runner, demo_rational_div_val_ref);\n    register_demo!(runner, demo_rational_div_ref_val);\n    register_demo!(runner, demo_rational_div_ref_ref);\n    register_demo!(runner, demo_rational_div_assign);\n    register_demo!(runner, demo_rational_div_assign_ref);\n    register_demo!(runner, demo_rational_checked_div);\n    register_demo!(runner, demo_rational_checked_div_val_ref);\n    register_demo!(runner, demo_rational_checked_div_ref_val);\n    register_demo!(runner, demo_rational_checked_div_ref_ref);\n\n    register_bench!(runner, benchmark_rational_div_library_comparison);\n    register_bench!(runner, benchmark_rational_div_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_div_algorithms);\n    register_bench!(runner, benchmark_rational_div_assign_library_comparison);\n    register_bench!(runner, benchmark_rational_div_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_checked_div_library_comparison);\n    register_bench!(runner, benchmark_rational_checked_div_evaluation_strategy);\n}\n\nfn demo_rational_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} / {} = {}\", x_old, y_old, x / y);\n    }\n}\n\nfn demo_rational_div_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} / &{} = {}\", x_old, y, x / &y);\n    }\n}\n\nfn demo_rational_div_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} / {} = {}\", x, y_old, &x / y);\n    }\n}\n\nfn demo_rational_div_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"&{} / &{} = {}\", x, y, &x / &y);\n    }\n}\n\nfn demo_rational_div_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\"x := {x_old}; x /= {y}; x = {x}\");\n    }\n}\n\nfn demo_rational_div_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\"x := {x_old}; x /= &{y}; x = {x}\");\n    }\n}\n\nfn demo_rational_checked_div(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).checked_div({}) = {:?}\",\n            x_old,\n            y_old,\n            x.checked_div(y)\n        );\n    }\n}\n\nfn demo_rational_checked_div_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"({}).checked_div(&{}) = {:?}\", x_old, y, x.checked_div(&y));\n    }\n}\n\nfn demo_rational_checked_div_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).checked_div({}) = {:?}\",\n            x,\n            y_old,\n            (&x).checked_div(y)\n        );\n    }\n}\n\nfn demo_rational_checked_div_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_div(&{}) = {:?}\", x, y, (&x).checked_div(&y));\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_div_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational / Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x / y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x / y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x / y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational / Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational / Rational\", &mut |(x, y)| no_out!(x / y)),\n            (\"Rational / &Rational\", &mut |(x, y)| no_out!(x / &y)),\n            (\"&Rational / Rational\", &mut |(x, y)| no_out!(&x / y)),\n            (\"&Rational / &Rational\", &mut |(x, y)| no_out!(&x / &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_div_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational / Rational\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x / y)),\n            (\"naive\", &mut |(x, y)| no_out!(div_naive(x, y))),\n        ],\n    );\n}\n\nfn benchmark_rational_div_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational *= Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_var_1_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x *= y), (\"rug\", &mut |((mut x, y), _)| x *= y)],\n    );\n}\n\nfn benchmark_rational_div_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational *= Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational *= Rational\", &mut |(mut x, y)| no_out!(x *= y)),\n            (\"Rational *= &Rational\", &mut |(mut x, y)| no_out!(x *= &y)),\n        ],\n    );\n}\n\nfn benchmark_rational_checked_div_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.checked_div(Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_nm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.checked_div(&y))),\n            (\"num\", &mut |((x, y), _)| no_out!(x.checked_div(&y))),\n        ],\n    );\n}\n\nfn benchmark_rational_checked_div_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.checked_div(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational.checked_div(Rational)\", &mut |(x, y)| {\n                no_out!(x.checked_div(y));\n            }),\n            (\"Rational.checked_div(&Rational)\", &mut |(x, y)| {\n                no_out!(x.checked_div(&y));\n            }),\n            (\"(&Rational).checked_div(Rational)\", &mut |(x, y)| {\n                no_out!((&x).checked_div(y));\n            }),\n            (\"(&Rational).checked_div(&Rational)\", &mut |(x, y)| {\n                no_out!((&x).checked_div(&y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/floor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Floor, FloorAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    rational_bit_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_floor);\n    register_demo!(runner, demo_rational_floor_ref);\n    register_demo!(runner, demo_rational_floor_assign);\n\n    register_bench!(runner, benchmark_rational_floor_library_comparison);\n    register_bench!(runner, benchmark_rational_floor_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_floor_assign);\n}\n\nfn demo_rational_floor(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"floor({}) = {}\", n.clone(), n.floor());\n    }\n}\n\nfn demo_rational_floor_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"floor(&{}) = {}\", n, (&n).floor());\n    }\n}\n\nfn demo_rational_floor_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in rational_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.floor_assign();\n        println!(\"n := {n_old}; n.floor_assign(); n = {n}\");\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_floor_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.floor()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.floor())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.floor())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.floor())),\n        ],\n    );\n}\n\nfn benchmark_rational_floor_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.floor()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.floor()\", &mut |n| no_out!(n.floor())),\n            (\"(&Rational).floor()\", &mut |n| no_out!((&n).floor())),\n        ],\n    );\n}\n\nfn benchmark_rational_floor_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.floor_assign()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.floor_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_is_power_of_2);\n    register_bench!(runner, benchmark_rational_is_power_of_2);\n}\n\nfn demo_rational_is_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        if x.is_power_of_2() {\n            println!(\"{x} is a power of 2\");\n        } else {\n            println!(\"{x} is not a power of 2\");\n        }\n    }\n}\n\nfn benchmark_rational_is_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.is_power_of_2()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_power_of_2()))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase, CheckedLogBase, FloorLogBase};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_rational_max_bit_bucketer, rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen_var_2, rational_pair_gen_var_7};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_approx_log);\n    register_demo!(runner, demo_rational_floor_log_base);\n    register_demo!(runner, demo_rational_ceiling_log_base);\n    register_demo!(runner, demo_rational_checked_log_base);\n    register_bench!(runner, benchmark_approx_log);\n    register_bench!(runner, benchmark_rational_floor_log_base);\n    register_bench!(runner, benchmark_rational_ceiling_log_base);\n    register_bench!(runner, benchmark_rational_checked_log_base);\n}\n\nfn demo_rational_approx_log(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_2().get(gm, config).take(limit) {\n        println!(\"log({}) ≈ {}\", n, NiceFloat(n.approx_log()));\n    }\n}\n\nfn demo_rational_floor_log_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in rational_pair_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"floor_log_base({}, {}) = {}\",\n            n,\n            base,\n            n.floor_log_base(&base)\n        );\n    }\n}\n\nfn demo_rational_ceiling_log_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in rational_pair_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"ceiling_log_base({}, {}) = {}\",\n            n,\n            base,\n            n.ceiling_log_base(&base)\n        );\n    }\n}\n\nfn demo_rational_checked_log_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in rational_pair_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"checked_log_base({}, {}) = {:?}\",\n            n,\n            base,\n            n.checked_log_base(&base)\n        );\n    }\n}\n\nfn benchmark_approx_log(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"(&Rational).approx_log()\",\n        BenchmarkType::Single,\n        rational_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"n\"),\n        &mut [(\"default\", &mut |n| no_out!(n.approx_log()))],\n    );\n}\n\nfn benchmark_rational_floor_log_base(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Rational).floor_log_base(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"n\", \"base\"),\n        &mut [(\"Malachite\", &mut |(n, base)| {\n            no_out!(n.floor_log_base(&base));\n        })],\n    );\n}\n\nfn benchmark_rational_ceiling_log_base(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Rational).ceiling_log_base(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"n\", \"base\"),\n        &mut [(\"Malachite\", &mut |(n, base)| {\n            no_out!(n.ceiling_log_base(&base));\n        })],\n    );\n}\n\nfn benchmark_rational_checked_log_base(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"(&Rational).checked_log_base(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen_var_7().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"n\", \"base\"),\n        &mut [(\"Malachite\", &mut |(n, base)| {\n            no_out!(n.checked_log_base(&base));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CeilingLogBase2, CheckedLogBase2, FloorLogBase2};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_gen_var_1, rational_gen_var_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_floor_log_base_2_abs);\n    register_demo!(runner, demo_rational_ceiling_log_base_2_abs);\n    register_demo!(runner, demo_rational_floor_log_base_2);\n    register_demo!(runner, demo_rational_ceiling_log_base_2);\n    register_demo!(runner, demo_rational_checked_log_base_2);\n\n    register_bench!(runner, benchmark_rational_floor_log_base_2_abs);\n    register_bench!(runner, benchmark_rational_ceiling_log_base_2_abs);\n    register_bench!(runner, benchmark_rational_floor_log_base_2);\n    register_bench!(runner, benchmark_rational_ceiling_log_base_2);\n    register_bench!(runner, benchmark_rational_checked_log_base_2);\n}\n\nfn demo_rational_floor_log_base_2_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        println!(\"floor_log_base_2_abs({}) = {}\", n, n.floor_log_base_2_abs());\n    }\n}\n\nfn demo_rational_ceiling_log_base_2_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"ceiling_log_base_2_abs({}) = {}\",\n            n,\n            n.ceiling_log_base_2_abs()\n        );\n    }\n}\n\nfn demo_rational_floor_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_2().get(gm, config).take(limit) {\n        println!(\"floor_log_base_2({}) = {}\", n, n.floor_log_base_2());\n    }\n}\n\nfn demo_rational_ceiling_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_2().get(gm, config).take(limit) {\n        println!(\"ceiling_log_base_2({}) = {}\", n, n.ceiling_log_base_2());\n    }\n}\n\nfn demo_rational_checked_log_base_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_2().get(gm, config).take(limit) {\n        println!(\"checked_log_base_2({}) = {:?}\", n, n.checked_log_base_2());\n    }\n}\n\nfn benchmark_rational_floor_log_base_2_abs(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.floor_log_base_2_abs()\",\n        BenchmarkType::Single,\n        rational_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.floor_log_base_2_abs()))],\n    );\n}\n\nfn benchmark_rational_ceiling_log_base_2_abs(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling_log_base_2_abs()\",\n        BenchmarkType::Single,\n        rational_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.ceiling_log_base_2_abs()))],\n    );\n}\n\nfn benchmark_rational_floor_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.floor_log_base_2()\",\n        BenchmarkType::Single,\n        rational_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.floor_log_base_2()))],\n    );\n}\n\nfn benchmark_rational_ceiling_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling_log_base_2()\",\n        BenchmarkType::Single,\n        rational_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.ceiling_log_base_2()))],\n    );\n}\n\nfn benchmark_rational_checked_log_base_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.floor_log_base_2()\",\n        BenchmarkType::Single,\n        rational_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |n| no_out!(n.checked_log_base_2()))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBasePowerOf2, CheckedLogBasePowerOf2, FloorLogBasePowerOf2,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_signed_pair_gen_var_5;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_floor_log_base_power_of_2);\n    register_demo!(runner, demo_rational_ceiling_log_base_power_of_2);\n    register_demo!(runner, demo_rational_checked_log_base_power_of_2);\n    register_bench!(runner, benchmark_rational_floor_log_base_power_of_2);\n    register_bench!(runner, benchmark_rational_ceiling_log_base_power_of_2);\n    register_bench!(runner, benchmark_rational_checked_log_base_power_of_2);\n}\n\nfn demo_rational_floor_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in rational_signed_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\n            \"floor_log_base_power_of_2({}, {}) = {}\",\n            n,\n            pow,\n            n.floor_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_rational_ceiling_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in rational_signed_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\n            \"ceiling_log_base_power_of_2({}, {}) = {}\",\n            n,\n            pow,\n            n.ceiling_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn demo_rational_checked_log_base_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow) in rational_signed_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\n            \"checked_log_base_power_of_2({}, {}) = {:?}\",\n            n,\n            pow,\n            n.checked_log_base_power_of_2(pow)\n        );\n    }\n}\n\nfn benchmark_rational_floor_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.floor_log_base_power_of_2(u64)\",\n        BenchmarkType::Single,\n        rational_signed_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.floor_log_base_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_rational_ceiling_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling_log_base_power_of_2(u64)\",\n        BenchmarkType::Single,\n        rational_signed_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.ceiling_log_base_power_of_2(pow));\n        })],\n    );\n}\n\nfn benchmark_rational_checked_log_base_power_of_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.floor_log_base_power_of_2(u64)\",\n        BenchmarkType::Single,\n        rational_signed_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(n, pow)| {\n            no_out!(n.checked_log_base_power_of_2(pow));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    abs::register(runner);\n    abs_diff::register(runner);\n    add::register(runner);\n    approximate::register(runner);\n    ceiling::register(runner);\n    denominators_in_closed_interval::register(runner);\n    div::register(runner);\n    floor::register(runner);\n    is_power_of_2::register(runner);\n    log_base::register(runner);\n    log_base_2::register(runner);\n    log_base_power_of_2::register(runner);\n    mod_op::register(runner);\n    mul::register(runner);\n    neg::register(runner);\n    next_power_of_2::register(runner);\n    pow::register(runner);\n    power_of_2::register(runner);\n    reciprocal::register(runner);\n    root::register(runner);\n    round_to_multiple::register(runner);\n    round_to_multiple_of_power_of_2::register(runner);\n    shl::register(runner);\n    shr::register(runner);\n    sign::register(runner);\n    simplest_rational_in_interval::register(runner);\n    sqrt::register(runner);\n    square::register(runner);\n    sub::register(runner);\n}\n\nmod abs;\nmod abs_diff;\nmod add;\nmod approximate;\nmod ceiling;\nmod denominators_in_closed_interval;\nmod div;\nmod floor;\nmod is_power_of_2;\nmod log_base;\nmod log_base_2;\nmod log_base_power_of_2;\nmod mod_op;\nmod mul;\nmod neg;\nmod next_power_of_2;\nmod pow;\nmod power_of_2;\nmod reciprocal;\nmod root;\nmod round_to_multiple;\nmod round_to_multiple_of_power_of_2;\nmod shl;\nmod shr;\nmod sign;\nmod simplest_rational_in_interval;\nmod sqrt;\nmod square;\nmod sub;\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CeilingMod, CeilingModAssign, Mod, ModAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::arithmetic::mod_op::{ceiling_mod_naive, mod_op_naive, rem_naive};\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, pair_2_pair_1_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_pair_gen_var_1, rational_pair_gen_var_1_nm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_mod);\n    register_demo!(runner, demo_rational_mod_val_ref);\n    register_demo!(runner, demo_rational_mod_ref_val);\n    register_demo!(runner, demo_rational_mod_ref_ref);\n    register_demo!(runner, demo_rational_mod_assign);\n    register_demo!(runner, demo_rational_mod_assign_ref);\n    register_demo!(runner, demo_rational_rem);\n    register_demo!(runner, demo_rational_rem_val_ref);\n    register_demo!(runner, demo_rational_rem_ref_val);\n    register_demo!(runner, demo_rational_rem_ref_ref);\n    register_demo!(runner, demo_rational_rem_assign);\n    register_demo!(runner, demo_rational_rem_assign_ref);\n    register_demo!(runner, demo_rational_ceiling_mod);\n    register_demo!(runner, demo_rational_ceiling_mod_val_ref);\n    register_demo!(runner, demo_rational_ceiling_mod_ref_val);\n    register_demo!(runner, demo_rational_ceiling_mod_ref_ref);\n    register_demo!(runner, demo_rational_ceiling_mod_assign);\n    register_demo!(runner, demo_rational_ceiling_mod_assign_ref);\n\n    register_bench!(runner, benchmark_rational_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_mod_algorithms);\n    register_bench!(runner, benchmark_rational_mod_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_rem_library_comparison);\n    register_bench!(runner, benchmark_rational_rem_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_rem_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_ceiling_mod_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_ceiling_mod_algorithms);\n    register_bench!(\n        runner,\n        benchmark_rational_ceiling_mod_assign_evaluation_strategy\n    );\n}\n\nfn demo_rational_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.mod_op({}) = {}\", x_old, y_old, x.mod_op(y));\n    }\n}\n\nfn demo_rational_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.mod_op(&{}) = {}\", x_old, y, x.mod_op(&y));\n    }\n}\n\nfn demo_rational_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).mod_op({}) = {:?}\", x, y_old, (&x).mod_op(y));\n    }\n}\n\nfn demo_rational_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"(&{}).mod_op(&{}) = {:?}\", x, y, (&x).mod_op(&y));\n    }\n}\n\nfn demo_rational_mod_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.mod_assign(y);\n        println!(\"x := {x_old}; x.mod_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_rational_mod_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.mod_assign(&y);\n        println!(\"x := {x_old}; x.mod_assign(&{y}); x = {x}\");\n    }\n}\n\nfn demo_rational_rem(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} % {} = {:?}\", x_old, y_old, x % y);\n    }\n}\n\nfn demo_rational_rem_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} % &{} = {:?}\", x_old, y, x % &y);\n    }\n}\n\nfn demo_rational_rem_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} % {} = {:?}\", x, y_old, &x % y);\n    }\n}\n\nfn demo_rational_rem_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"&{} % &{} = {:?}\", x, y, &x % &y);\n    }\n}\n\nfn demo_rational_rem_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x %= y;\n        println!(\"x := {x_old}; x %= {y_old}; x = {x}\");\n    }\n}\n\nfn demo_rational_rem_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x %= &y;\n        println!(\"x := {x_old}; x %= &{y}; x = {x}\");\n    }\n}\n\nfn demo_rational_ceiling_mod(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{}.ceiling_mod({}) = {}\", x_old, y_old, x.ceiling_mod(y));\n    }\n}\n\nfn demo_rational_ceiling_mod_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{}.ceiling_mod(&{}) = {}\", x_old, y, x.ceiling_mod(&y));\n    }\n}\n\nfn demo_rational_ceiling_mod_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"(&{}).ceiling_mod({}) = {}\", x, y_old, (&x).ceiling_mod(y));\n    }\n}\n\nfn demo_rational_ceiling_mod_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\"(&{}).ceiling_mod(&{}) = {}\", x, y, (&x).ceiling_mod(&y));\n    }\n}\n\nfn demo_rational_ceiling_mod_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        x.ceiling_mod_assign(y);\n        println!(\"x := {x_old}; x.ceiling_mod_assign({y_old}); x = {x}\");\n    }\n}\n\nfn demo_rational_ceiling_mod_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen_var_1().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.ceiling_mod_assign(&y);\n        println!(\"x := {x_old}; x.ceiling_mod_assign(&{y}); x = {x}\");\n    }\n}\n\nfn benchmark_rational_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.mod_op(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.mod_op(Rational)\", &mut |(x, y)| {\n                no_out!(x.mod_op(y));\n            }),\n            (\"Rational.mod_op(&Rational)\", &mut |(x, y)| {\n                no_out!(x.mod_op(&y));\n            }),\n            (\"(&Rational).mod_op(Rational)\", &mut |(x, y)| {\n                no_out!((&x).mod_op(y));\n            }),\n            (\"(&Rational).mod_op(&Rational)\", &mut |(x, y)| {\n                no_out!((&x).mod_op(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.mod_op(Rational)\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(x.mod_op(y));\n            }),\n            (\"naive\", &mut |(x, y)| {\n                no_out!(mod_op_naive(x, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_mod_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.mod_assign(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.mod_assign(Rational)\", &mut |(mut x, y)| {\n                no_out!(x.mod_assign(y));\n            }),\n            (\"Rational.mod_assign(&Rational)\", &mut |(mut x, y)| {\n                no_out!(x.mod_assign(&y));\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_rem_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.rem(Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_var_1_nm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x % y)),\n            (\"num\", &mut |((x, y), _)| no_out!(x % y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_rem_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.rem(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational % Rational\", &mut |(x, y)| no_out!(x % y)),\n            (\"Rational % &Rational\", &mut |(x, y)| no_out!(x % &y)),\n            (\"&Rational % Rational\", &mut |(x, y)| no_out!(&x % y)),\n            (\"&Rational % &Rational\", &mut |(x, y)| no_out!(&x % &y)),\n        ],\n    );\n}\n\n#[allow(unused)]\nfn benchmark_rational_rem_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational % Rational\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(x % y);\n            }),\n            (\"naive\", &mut |(x, y)| {\n                no_out!(rem_naive(x, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_rem_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.rem_assign(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational %= Rational\", &mut |(mut x, y)| x %= y),\n            (\"Rational %= &Rational\", &mut |(mut x, y)| x %= &y),\n        ],\n    );\n}\n\nfn benchmark_rational_ceiling_mod_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling_mod(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.ceiling_mod(Rational)\", &mut |(x, y)| {\n                no_out!(x.ceiling_mod(y));\n            }),\n            (\"Rational.ceiling_mod(&Rational)\", &mut |(x, y)| {\n                no_out!(x.ceiling_mod(&y));\n            }),\n            (\"(&Rational).ceiling_mod(Rational)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_mod(y));\n            }),\n            (\"(&Rational).ceiling_mod(&Rational)\", &mut |(x, y)| {\n                no_out!((&x).ceiling_mod(&y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_ceiling_mod_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling_mod(Rational)\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(x.ceiling_mod(y));\n            }),\n            (\"naive\", &mut |(x, y)| {\n                no_out!(ceiling_mod_naive(x, y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_ceiling_mod_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ceiling_mod_assign(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Rational.ceiling_mod_assign(Rational)\",\n                &mut |(mut x, y)| {\n                    no_out!(x.ceiling_mod_assign(y));\n                },\n            ),\n            (\n                \"Rational.ceiling_mod_assign(&Rational)\",\n                &mut |(mut x, y)| {\n                    no_out!(x.ceiling_mod_assign(&y));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::mul::mul_naive;\nuse malachite_q::test_util::arithmetic::mul::rational_product_naive;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_2_pair_rational_max_bit_bucketer, pair_rational_max_bit_bucketer,\n    triple_3_pair_rational_max_bit_bucketer, triple_3_vec_rational_sum_bits_bucketer,\n    vec_rational_sum_bits_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_pair_gen, rational_pair_gen_nrm, rational_pair_gen_rm, rational_vec_gen,\n    rational_vec_gen_nrm,\n};\nuse num::BigRational;\nuse std::iter::Product;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_mul);\n    register_demo!(runner, demo_rational_mul_val_ref);\n    register_demo!(runner, demo_rational_mul_ref_val);\n    register_demo!(runner, demo_rational_mul_ref_ref);\n    register_demo!(runner, demo_rational_mul_assign);\n    register_demo!(runner, demo_rational_mul_assign_ref);\n    register_demo!(runner, demo_rational_product);\n    register_demo!(runner, demo_rational_ref_product);\n\n    register_bench!(runner, benchmark_rational_mul_library_comparison);\n    register_bench!(runner, benchmark_rational_mul_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_mul_algorithms);\n    register_bench!(runner, benchmark_rational_mul_assign_library_comparison);\n    register_bench!(runner, benchmark_rational_mul_assign_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_product_algorithms);\n    register_bench!(runner, benchmark_rational_product_library_comparison);\n    register_bench!(runner, benchmark_rational_product_evaluation_strategy);\n}\n\nfn demo_rational_mul(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} * {} = {}\", x_old, y_old, x * y);\n    }\n}\n\nfn demo_rational_mul_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} * &{} = {}\", x_old, y, x * &y);\n    }\n}\n\nfn demo_rational_mul_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} * {} = {}\", x, y_old, &x * y);\n    }\n}\n\nfn demo_rational_mul_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} * &{} = {}\", x, y, &x * &y);\n    }\n}\n\nfn demo_rational_mul_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= y.clone();\n        println!(\"x := {x_old}; x *= {y}; x = {x}\");\n    }\n}\n\nfn demo_rational_mul_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x *= &y;\n        println!(\"x := {x_old}; x *= &{y}; x = {x}\");\n    }\n}\n\nfn demo_rational_product(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in rational_vec_gen().get(gm, config).take(limit) {\n        println!(\n            \"product({:?}) = {}\",\n            xs.clone(),\n            Rational::product(xs.into_iter())\n        );\n    }\n}\n\nfn demo_rational_ref_product(gm: GenMode, config: &GenConfig, limit: usize) {\n    for xs in rational_vec_gen().get(gm, config).take(limit) {\n        println!(\"product({:?}) = {}\", xs, Rational::product(xs.iter()));\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_mul_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational * Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x * y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x * y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x * y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_mul_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational * Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational * Rational\", &mut |(x, y)| no_out!(x * y)),\n            (\"Rational * &Rational\", &mut |(x, y)| no_out!(x * &y)),\n            (\"&Rational * Rational\", &mut |(x, y)| no_out!(&x * y)),\n            (\"&Rational * &Rational\", &mut |(x, y)| no_out!(&x * &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_mul_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational * Rational\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x * y)),\n            (\"naive\", &mut |(x, y)| no_out!(mul_naive(x, y))),\n        ],\n    );\n}\n\nfn benchmark_rational_mul_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational *= Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x *= y), (\"rug\", &mut |((mut x, y), _)| x *= y)],\n    );\n}\n\nfn benchmark_rational_mul_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational *= Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational *= Rational\", &mut |(mut x, y)| no_out!(x *= y)),\n            (\"Rational *= &Rational\", &mut |(mut x, y)| no_out!(x *= &y)),\n        ],\n    );\n}\n\nfn benchmark_rational_product_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::product(Iterator<Item=Rational>)\",\n        BenchmarkType::LibraryComparison,\n        rational_vec_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_vec_rational_sum_bits_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, xs)| {\n                no_out!(Rational::product(xs.into_iter()));\n            }),\n            (\"num\", &mut |(xs, _, _)| {\n                no_out!(BigRational::product(xs.into_iter()));\n            }),\n            (\"rug\", &mut |(_, xs, _)| {\n                no_out!(rug::Rational::product(xs.iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_product_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::product(Iterator<Item=Rational>)\",\n        BenchmarkType::Algorithms,\n        rational_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_rational_sum_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |xs| {\n                no_out!(Rational::product(xs.into_iter()));\n            }),\n            (\"naive\", &mut |xs| {\n                no_out!(rational_product_naive(xs.into_iter()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_product_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::product(Iterator<Item=Rational>)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_vec_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &vec_rational_sum_bits_bucketer(),\n        &mut [\n            (\"Rational::product(Iterator<Item=Rational>)\", &mut |xs| {\n                no_out!(Rational::product(xs.into_iter()));\n            }),\n            (\"Rational::product(Iterator<Item=&Rational>)\", &mut |xs| {\n                no_out!(Rational::product(xs.iter()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    rational_bit_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_neg);\n    register_demo!(runner, demo_rational_neg_ref);\n    register_demo!(runner, demo_rational_neg_assign);\n\n    register_bench!(runner, benchmark_rational_neg_library_comparison);\n    register_bench!(runner, benchmark_rational_neg_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_neg_assign);\n}\n\nfn demo_rational_neg(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"-({}) = {}\", n.clone(), -n);\n    }\n}\n\nfn demo_rational_neg_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"-(&{}) = {}\", n, -&n);\n    }\n}\n\nfn demo_rational_neg_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in rational_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.neg_assign();\n        println!(\"n := {n_old}; n.neg_assign(); n = {n}\");\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_neg_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(-n)),\n            (\"num\", &mut |(n, _, _)| no_out!(-n)),\n            (\"rug\", &mut |(_, n, _)| no_out!(-n)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_neg_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"-Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.neg()\", &mut |n| no_out!(-n)),\n            (\"(&Rational).neg()\", &mut |n| no_out!(-&n)),\n        ],\n    );\n}\n\nfn benchmark_rational_neg_assign(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.neg_assign()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.neg_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{NextPowerOf2, NextPowerOf2Assign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_gen_var_2;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_next_power_of_2);\n    register_demo!(runner, demo_rational_next_power_of_2_ref);\n    register_demo!(runner, demo_rational_next_power_of_2_assign);\n\n    register_bench!(\n        runner,\n        benchmark_rational_next_power_of_2_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_next_power_of_2_assign);\n}\n\nfn demo_rational_next_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen_var_2().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"next_power_of_2({}) = {}\", x_old, x.next_power_of_2());\n    }\n}\n\nfn demo_rational_next_power_of_2_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen_var_2().get(gm, config).take(limit) {\n        println!(\"next_power_of_2({}) = {}\", x, (&x).next_power_of_2());\n    }\n}\n\nfn demo_rational_next_power_of_2_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut x in rational_gen_var_2().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        x.next_power_of_2_assign();\n        println!(\"x := {old_x}; x.next_power_of_2_assign(); x = {x}\");\n    }\n}\n\nfn benchmark_rational_next_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.next_power_of_2()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.next_power_of_2()\", &mut |x| {\n                no_out!(x.next_power_of_2());\n            }),\n            (\"(&Rational).next_power_of_2()\", &mut |x| {\n                no_out!((&x).next_power_of_2());\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_next_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.next_power_of_2_assign()\",\n        BenchmarkType::Single,\n        rational_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut x| x.next_power_of_2_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Pow, PowAssign};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, triple_3_pair_1_rational_bits_times_abs_pair_2_bucketer,\n    triple_3_pair_1_rational_bits_times_pair_2_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_signed_pair_gen_var_2, rational_signed_pair_gen_var_2_nrm,\n    rational_unsigned_pair_gen_var_1, rational_unsigned_pair_gen_var_1_nrm,\n};\nuse rug::ops::Pow as RugPow;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_pow_u64);\n    register_demo!(runner, demo_rational_pow_u64_ref);\n    register_demo!(runner, demo_rational_pow_assign_u64);\n    register_demo!(runner, demo_rational_pow_i64);\n    register_demo!(runner, demo_rational_pow_i64_ref);\n    register_demo!(runner, demo_rational_pow_assign_i64);\n\n    register_bench!(runner, benchmark_rational_pow_u64_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_pow_u64_library_comparison);\n    register_bench!(runner, benchmark_rational_pow_u64_assign);\n    register_bench!(runner, benchmark_rational_pow_i64_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_pow_i64_library_comparison);\n    register_bench!(runner, benchmark_rational_pow_i64_assign);\n}\n\nfn demo_rational_pow_u64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in rational_unsigned_pair_gen_var_1::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"({}).pow({}) = {}\", n.clone(), exp, n.pow(exp));\n    }\n}\n\nfn demo_rational_pow_u64_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in rational_unsigned_pair_gen_var_1::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).pow({}) = {}\", n, exp, (&n).pow(exp));\n    }\n}\n\nfn demo_rational_pow_assign_u64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, exp) in rational_unsigned_pair_gen_var_1::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.pow_assign(exp);\n        println!(\"n := {n_old}; n.pow_assign({exp}); n = {n}\");\n    }\n}\n\nfn demo_rational_pow_i64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in rational_signed_pair_gen_var_2::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"({}).pow({}) = {}\", n.clone(), exp, n.pow(exp));\n    }\n}\n\nfn demo_rational_pow_i64_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, exp) in rational_signed_pair_gen_var_2::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"(&{}).pow({}) = {}\", n, exp, (&n).pow(exp));\n    }\n}\n\nfn demo_rational_pow_assign_i64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut n, exp) in rational_signed_pair_gen_var_2::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n.pow_assign(exp);\n        println!(\"n := {n_old}; n.pow_assign({exp}); n = {n}\");\n    }\n}\n\nfn benchmark_rational_pow_u64_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.pow_assign(u64)\",\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_rational_bits_times_pair_2_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, exp))| no_out!(x.pow(exp))),\n            (\"num\", &mut |((x, exp), _, _)| {\n                no_out!(x.pow(i32::exact_from(exp)));\n            }),\n            (\"rug\", &mut |(_, (x, exp), _)| {\n                no_out!(x.pow(u32::exact_from(exp)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_pow_u64_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.pow(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_1::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.pow(u64)\", &mut |(n, exp)| no_out!(n.pow(exp))),\n            (\"(&Rational).pow(u64)\", &mut |(n, exp)| {\n                no_out!((&n).pow(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_pow_u64_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.pow_assign(u64)\",\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen_var_1::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, exp)| n.pow_assign(exp))],\n    );\n}\n\nfn benchmark_rational_pow_i64_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.pow_assign(i64)\",\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_var_2_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_1_rational_bits_times_abs_pair_2_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, exp))| no_out!(x.pow(exp))),\n            (\"num\", &mut |((x, exp), _, _)| {\n                no_out!(x.pow(i32::exact_from(exp)));\n            }),\n            (\"rug\", &mut |(_, (x, exp), _)| {\n                no_out!(x.pow(i32::exact_from(exp)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_pow_i64_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.pow(i64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_signed_pair_gen_var_2::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.pow(u64)\", &mut |(n, exp)| no_out!(n.pow(exp))),\n            (\"(&Rational).pow(u64)\", &mut |(n, exp)| {\n                no_out!((&n).pow(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_pow_i64_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.pow_assign(i64)\",\n        BenchmarkType::Single,\n        rational_signed_pair_gen_var_2::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, exp)| n.pow_assign(exp))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::PowerOf2;\nuse malachite_base::test_util::bench::bucketers::{signed_abs_bucketer, unsigned_direct_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen_var_5, unsigned_gen_var_5};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_power_of_2_u64);\n    register_demo!(runner, demo_rational_power_of_2_i64);\n\n    register_bench!(runner, benchmark_rational_power_of_2_u64);\n    register_bench!(runner, benchmark_rational_power_of_2_i64);\n}\n\nfn demo_rational_power_of_2_u64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in unsigned_gen_var_5::<u64>().get(gm, config).take(limit) {\n        println!(\"Rational::power_of_2({}) = {}\", x, Rational::power_of_2(x));\n    }\n}\n\nfn demo_rational_power_of_2_i64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in signed_gen_var_5::<i64>().get(gm, config).take(limit) {\n        println!(\"Rational::power_of_2({}) = {}\", x, Rational::power_of_2(x));\n    }\n}\n\nfn benchmark_rational_power_of_2_u64(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.power_of_2(u64)\",\n        BenchmarkType::Single,\n        unsigned_gen_var_5::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_direct_bucketer(),\n        &mut [(\"Malachite\", &mut |x| no_out!(Rational::power_of_2(x)))],\n    );\n}\n\nfn benchmark_rational_power_of_2_i64(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.power_of_2(i64)\",\n        BenchmarkType::Single,\n        signed_gen_var_5::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_abs_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(Rational::power_of_2(x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Reciprocal, ReciprocalAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    rational_bit_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen_var_1, rational_gen_var_1_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_reciprocal);\n    register_demo!(runner, demo_rational_reciprocal_ref);\n    register_demo!(runner, demo_rational_reciprocal_assign);\n\n    register_bench!(runner, benchmark_rational_reciprocal_library_comparison);\n    register_bench!(runner, benchmark_rational_reciprocal_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_reciprocal_assign);\n}\n\nfn demo_rational_reciprocal(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        println!(\"reciprocal({}) = {}\", n.clone(), n.reciprocal());\n    }\n}\n\nfn demo_rational_reciprocal_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        println!(\"reciprocal(&{}) = {}\", n, (&n).reciprocal());\n    }\n}\n\nfn demo_rational_reciprocal_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in rational_gen_var_1().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.reciprocal_assign();\n        println!(\"n := {n_old}; n.reciprocal_assign(); n = {n}\");\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_reciprocal_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.reciprocal()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.reciprocal())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.recip())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.recip())),\n        ],\n    );\n}\n\nfn benchmark_rational_reciprocal_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.reciprocal()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.reciprocal()\", &mut |n| no_out!(n.reciprocal())),\n            (\"(&Rational).reciprocal()\", &mut |n| {\n                no_out!((&n).reciprocal());\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_reciprocal_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.reciprocal_assign()\",\n        BenchmarkType::Single,\n        rational_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.reciprocal_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::CheckedRoot;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_signed_pair_gen_var_4, rational_unsigned_pair_gen_var_4,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_checked_root_u64);\n    register_demo!(runner, demo_rational_checked_root_u64_ref);\n    register_demo!(runner, demo_rational_checked_root_i64);\n    register_demo!(runner, demo_rational_checked_root_i64_ref);\n\n    register_bench!(\n        runner,\n        benchmark_rational_checked_root_u64_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_checked_root_i64_evaluation_strategy\n    );\n}\n\nfn demo_rational_checked_root_u64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in rational_unsigned_pair_gen_var_4::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).checked_root({}) = {:?}\",\n            x,\n            exp,\n            x.clone().checked_root(exp)\n        );\n    }\n}\n\nfn demo_rational_checked_root_u64_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in rational_unsigned_pair_gen_var_4::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).checked_root({}) = {:?}\",\n            x,\n            exp,\n            (&x).checked_root(exp)\n        );\n    }\n}\n\nfn demo_rational_checked_root_i64(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in rational_signed_pair_gen_var_4::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).checked_root({}) = {:?}\",\n            x,\n            exp,\n            x.clone().checked_root(exp)\n        );\n    }\n}\n\nfn demo_rational_checked_root_i64_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, exp) in rational_signed_pair_gen_var_4::<i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).checked_root({}) = {:?}\",\n            x,\n            exp,\n            (&x).checked_root(exp)\n        );\n    }\n}\n\nfn benchmark_rational_checked_root_u64_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.checked_root(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_4::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.checked_root(u64)\", &mut |(x, exp)| {\n                no_out!(x.checked_root(exp));\n            }),\n            (\"(&Rational).checked_root(u64)\", &mut |(x, exp)| {\n                no_out!((&x).checked_root(exp));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_checked_root_i64_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.checked_root(i64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_signed_pair_gen_var_4::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.checked_root(i64)\", &mut |(x, exp)| {\n                no_out!(x.checked_root(exp));\n            }),\n            (\"(&Rational).checked_root(i64)\", &mut |(x, exp)| {\n                no_out!((&x).checked_root(exp));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{RoundToMultiple, RoundToMultipleAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::triple_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_rational_rounding_mode_triple_gen_var_1;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_round_to_multiple_assign);\n    register_demo!(runner, demo_rational_round_to_multiple_assign_ref);\n    register_demo!(runner, demo_rational_round_to_multiple);\n    register_demo!(runner, demo_rational_round_to_multiple_val_ref);\n    register_demo!(runner, demo_rational_round_to_multiple_ref_val);\n    register_demo!(runner, demo_rational_round_to_multiple_ref_ref);\n\n    register_bench!(\n        runner,\n        benchmark_rational_round_to_multiple_assign_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_round_to_multiple_evaluation_strategy\n    );\n}\n\nfn demo_rational_round_to_multiple_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in rational_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        let o = x.round_to_multiple_assign(y, rm);\n        println!(\"x := {x_old}; x.round_to_multiple_assign({y_old}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_rational_round_to_multiple_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y, rm) in rational_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let o = x.round_to_multiple_assign(&y, rm);\n        println!(\"x := {x_old}; x.round_to_multiple_assign(&{y}, {rm}) = {o:?}; x = {x}\");\n    }\n}\n\nfn demo_rational_round_to_multiple(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in rational_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\n            \"({}).round_to_multiple({}, {}) = {:?}\",\n            x_old,\n            y_old,\n            rm,\n            x.round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_rational_round_to_multiple_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in rational_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_old = x.clone();\n        println!(\n            \"({}).round_to_multiple(&{}, {}) = {:?}\",\n            x_old,\n            y,\n            rm,\n            x.round_to_multiple(&y, rm)\n        );\n    }\n}\n\nfn demo_rational_round_to_multiple_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in rational_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let y_old = y.clone();\n        println!(\n            \"(&{}).round_to_multiple({}, {}) = {:?}\",\n            x,\n            y_old,\n            rm,\n            (&x).round_to_multiple(y, rm)\n        );\n    }\n}\n\nfn demo_rational_round_to_multiple_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y, rm) in rational_rational_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).round_to_multiple(&{}, {}) = {:?}\",\n            x,\n            y,\n            rm,\n            (&x).round_to_multiple(&y, rm)\n        );\n    }\n}\n\nfn benchmark_rational_round_to_multiple_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.round_to_multiple_assign(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_rational_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"Rational.round_to_multiple_assign(Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.round_to_multiple_assign(y, rm)),\n            ),\n            (\n                \"Rational.round_to_multiple_assign(&Rational, RoundingMode)\",\n                &mut |(mut x, y, rm)| no_out!(x.round_to_multiple_assign(&y, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_rational_round_to_multiple_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.round_to_multiple(Rational, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_rational_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\n                \"Rational.round_to_multiple(Rational, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple(y, rm)),\n            ),\n            (\n                \"Rational.round_to_multiple(&Rational, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple(&y, rm)),\n            ),\n            (\n                \"(&Rational).round_to_multiple(Rational, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple(y, rm)),\n            ),\n            (\n                \"(&Rational).round_to_multiple(&Rational, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple(&y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    PowerOf2, RoundToMultiple, RoundToMultipleOfPowerOf2, RoundToMultipleOfPowerOf2Assign,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::triple_1_2_rational_bit_i64_max_bucketer;\nuse malachite_q::test_util::generators::rational_signed_rounding_mode_triple_gen_var_1;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_round_to_multiple_of_power_of_2_assign);\n    register_demo!(runner, demo_rational_round_to_multiple_of_power_of_2);\n    register_demo!(runner, demo_rational_round_to_multiple_of_power_of_2_ref);\n\n    register_bench!(\n        runner,\n        benchmark_rational_round_to_multiple_of_power_of_2_assign\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_round_to_multiple_of_power_of_2_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_round_to_multiple_of_power_of_2_evaluation_strategy\n    );\n}\n\nfn demo_rational_round_to_multiple_of_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (mut n, pow, rm) in rational_signed_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let o = n.round_to_multiple_of_power_of_2_assign(pow, rm);\n        println!(\n            \"x := {n_old}; x.round_to_multiple_of_power_of_2_assign({pow}, {rm}) = {o:?}; x = {n}\"\n        );\n    }\n}\n\nfn demo_rational_round_to_multiple_of_power_of_2(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, pow, rm) in rational_signed_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"({}).round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            n_old,\n            pow,\n            rm,\n            n.round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn demo_rational_round_to_multiple_of_power_of_2_ref(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, pow, rm) in rational_signed_rounding_mode_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"(&{}).round_to_multiple_of_power_of_2({}, {}) = {:?}\",\n            n,\n            pow,\n            rm,\n            (&n).round_to_multiple_of_power_of_2(pow, rm)\n        );\n    }\n}\n\nfn benchmark_rational_round_to_multiple_of_power_of_2_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.round_to_multiple_of_power_of_2_assign(u64, RoundingMode)\",\n        BenchmarkType::Single,\n        rational_signed_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_i64_max_bucketer(\"n\", \"pow\"),\n        &mut [(\"Malachite\", &mut |(mut x, y, rm)| {\n            no_out!(x.round_to_multiple_of_power_of_2_assign(y, rm));\n        })],\n    );\n}\n\n#[allow(clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_round_to_multiple_of_power_of_2_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n        BenchmarkType::Algorithms,\n        rational_signed_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_i64_max_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\"default\", &mut |(x, y, rm)| {\n                no_out!(x.round_to_multiple_of_power_of_2(y, rm));\n            }),\n            (\"using round_to_multiple\", &mut |(x, y, rm)| {\n                no_out!(x.round_to_multiple(Rational::power_of_2(y), rm));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_round_to_multiple_of_power_of_2_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_signed_rounding_mode_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_rational_bit_i64_max_bucketer(\"n\", \"pow\"),\n        &mut [\n            (\n                \"Rational.round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!(x.round_to_multiple_of_power_of_2(y, rm)),\n            ),\n            (\n                \"(&Rational).round_to_multiple_of_power_of_2(u64, RoundingMode)\",\n                &mut |(x, y, rm)| no_out!((&x).round_to_multiple_of_power_of_2(y, rm)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, pair_2_pair_1_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_signed_pair_gen_var_1, rational_signed_pair_gen_var_1_rm,\n    rational_unsigned_pair_gen_var_1, rational_unsigned_pair_gen_var_1_rm,\n};\nuse std::ops::{Shl, ShlAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rational_shl_assign_unsigned);\n    register_signed_demos!(runner, demo_rational_shl_assign_signed);\n    register_unsigned_demos!(runner, demo_rational_shl_unsigned);\n    register_signed_demos!(runner, demo_rational_shl_signed);\n    register_unsigned_demos!(runner, demo_rational_shl_unsigned_ref);\n    register_signed_demos!(runner, demo_rational_shl_signed_ref);\n\n    register_unsigned_benches!(runner, benchmark_rational_shl_assign_unsigned);\n    register_signed_benches!(runner, benchmark_rational_shl_assign_signed);\n    register_unsigned_benches!(runner, benchmark_rational_shl_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_rational_shl_signed_evaluation_strategy);\n\n    register_bench!(runner, benchmark_rational_shl_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_rational_shl_u32_library_comparison);\n    register_bench!(runner, benchmark_rational_shl_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_rational_shl_i32_library_comparison);\n}\n\nfn demo_rational_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: ShlAssign<T>,\n{\n    for (mut n, u) in rational_unsigned_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= u;\n        println!(\"x := {n_old}; x <<= {u}; x = {n}\");\n    }\n}\n\nfn demo_rational_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: ShlAssign<T>,\n{\n    for (mut n, i) in rational_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n <<= i;\n        println!(\"x := {n_old}; x <<= {i}; x = {n}\");\n    }\n}\n\nfn demo_rational_shl_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    for (n, u) in rational_unsigned_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, u, n << u);\n    }\n}\n\nfn demo_rational_shl_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: Shl<T, Output = Rational>,\n{\n    for (n, i) in rational_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} << {} = {}\", n_old, i, n << i);\n    }\n}\n\nfn demo_rational_shl_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Rational: Shl<T, Output = Rational>,\n{\n    for (n, u) in rational_unsigned_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, u, &n << u);\n    }\n}\n\nfn demo_rational_shl_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Rational: Shl<T, Output = Rational>,\n{\n    for (n, i) in rational_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} << {} = {}\", n, i, &n << i);\n    }\n}\n\nfn benchmark_rational_shl_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Rational <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n <<= u)],\n    );\n}\n\nfn benchmark_rational_shl_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: ShlAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Rational <<= {}\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, i)| n <<= i)],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_shl_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Rational: Shl<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Rational << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Rational << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Rational << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_shl_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shl<T, Output = Rational>,\n    for<'a> &'a Rational: Shl<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Rational << {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Rational << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x << y);\n            }),\n            (&format!(\"&Rational << {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x << y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_shl_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational <<= u32\",\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_var_1_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_shl_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational << u32\",\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_var_1_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n\nfn benchmark_rational_shl_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational <<= i32\",\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x <<= y),\n            (\"rug\", &mut |((mut x, y), _)| x <<= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_shl_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational << i32\",\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x << y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x << y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, pair_2_pair_1_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_signed_pair_gen_var_1, rational_signed_pair_gen_var_1_rm,\n    rational_unsigned_pair_gen_var_1, rational_unsigned_pair_gen_var_1_rm,\n};\nuse std::ops::{Shr, ShrAssign};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rational_shr_assign_unsigned);\n    register_signed_demos!(runner, demo_rational_shr_assign_signed);\n    register_unsigned_demos!(runner, demo_rational_shr_unsigned);\n    register_signed_demos!(runner, demo_rational_shr_signed);\n    register_unsigned_demos!(runner, demo_rational_shr_unsigned_ref);\n    register_signed_demos!(runner, demo_rational_shr_signed_ref);\n\n    register_unsigned_benches!(runner, benchmark_rational_shr_assign_unsigned);\n    register_signed_benches!(runner, benchmark_rational_shr_assign_signed);\n    register_unsigned_benches!(runner, benchmark_rational_shr_unsigned_evaluation_strategy);\n    register_signed_benches!(runner, benchmark_rational_shr_signed_evaluation_strategy);\n\n    register_bench!(runner, benchmark_rational_shr_assign_u32_library_comparison);\n    register_bench!(runner, benchmark_rational_shr_u32_library_comparison);\n    register_bench!(runner, benchmark_rational_shr_assign_i32_library_comparison);\n    register_bench!(runner, benchmark_rational_shr_i32_library_comparison);\n}\n\nfn demo_rational_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: ShrAssign<T>,\n{\n    for (mut n, u) in rational_unsigned_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= u;\n        println!(\"x := {n_old}; x >>= {u}; x = {n}\");\n    }\n}\n\nfn demo_rational_shr_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: ShrAssign<T>,\n{\n    for (mut n, i) in rational_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        n >>= i;\n        println!(\"x := {n_old}; x >>= {i}; x = {n}\");\n    }\n}\n\nfn demo_rational_shr_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    for (n, u) in rational_unsigned_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, u, n >> u);\n    }\n}\n\nfn demo_rational_shr_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: Shr<T, Output = Rational>,\n{\n    for (n, i) in rational_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\"{} >> {} = {}\", n_old, i, n >> i);\n    }\n}\n\nfn demo_rational_shr_unsigned_ref<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    for (n, u) in rational_unsigned_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, u, &n >> u);\n    }\n}\n\nfn demo_rational_shr_signed_ref<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    for (n, i) in rational_signed_pair_gen_var_1::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\"&{} >> {} = {}\", n, i, &n >> i);\n    }\n}\n\nfn benchmark_rational_shr_assign_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Rational >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, u)| n >>= u)],\n    );\n}\n\nfn benchmark_rational_shr_assign_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: ShrAssign<T>,\n{\n    run_benchmark(\n        &format!(\"Rational >>= {}\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(mut n, i)| n >>= i)],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_shr_unsigned_evaluation_strategy<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Rational >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Rational >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Rational >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_shr_signed_evaluation_strategy<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: Shr<T, Output = Rational>,\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    run_benchmark(\n        &format!(\"Rational >> {}\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_signed_pair_gen_var_1::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"Rational >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(x >> y);\n            }),\n            (&format!(\"&Rational >> {}\", T::NAME), &mut |(x, y)| {\n                no_out!(&x >> y);\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_shr_assign_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational >>= u32\",\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_var_1_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_shr_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational >> u32\",\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_var_1_rm::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n\nfn benchmark_rational_shr_assign_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational >>= i32\",\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (mut x, y))| x >>= y),\n            (\"rug\", &mut |((mut x, y), _)| x >>= y),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_shr_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational >> i32\",\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_var_1_rm::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x >> y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x >> y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::arithmetic::sign::num_sign;\nuse malachite_q::test_util::bench::bucketers::triple_3_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_sign);\n    register_bench!(runner, benchmark_integer_sign_library_comparison);\n}\n\nfn demo_integer_sign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        match x.sign() {\n            Less => println!(\"{x} is negative\"),\n            Equal => println!(\"{x} is zero\"),\n            Greater => println!(\"{x} is positive\"),\n        }\n    }\n}\n\nfn benchmark_integer_sign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.sign()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.sign())),\n            (\"num\", &mut |(x, _, _)| no_out!(num_sign(&x))),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.cmp0())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/simplest_rational_in_interval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::arithmetic::traits::SimplestRationalInInterval;\nuse malachite_q::test_util::arithmetic::simplest_rational_in_interval::*;\nuse malachite_q::test_util::bench::bucketers::pair_rational_max_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_pair_gen, rational_pair_gen_var_3, rational_pair_gen_var_4, rational_pair_gen_var_5,\n    rational_pair_gen_var_6,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_cmp_complexity);\n    register_demo!(runner, demo_simplest_rational_in_open_interval);\n    register_demo!(runner, demo_simplest_rational_in_closed_interval);\n\n    register_bench!(runner, benchmark_rational_cmp_complexity);\n    register_bench!(\n        runner,\n        benchmark_simplest_rational_in_open_interval_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_simplest_rational_in_open_interval_algorithms_2\n    );\n    register_bench!(runner, benchmark_simplest_rational_in_closed_interval);\n    register_bench!(\n        runner,\n        benchmark_simplest_rational_in_closed_interval_algorithms\n    );\n}\n\nfn demo_rational_cmp_complexity(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        match x.cmp_complexity(&y) {\n            Less => println!(\"{x} c< {y}\"),\n            Equal => println!(\"{x} c= {y}\"),\n            Greater => println!(\"{x} c> {y}\"),\n        }\n    }\n}\n\nfn demo_simplest_rational_in_open_interval(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_3().get(gm, config).take(limit) {\n        println!(\n            \"simplest_rational_in_open_interval({}, {}) = {}\",\n            x,\n            y,\n            Rational::simplest_rational_in_open_interval(&x, &y)\n        );\n    }\n}\n\nfn demo_simplest_rational_in_closed_interval(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen_var_4().get(gm, config).take(limit) {\n        println!(\n            \"simplest_rational_in_closed_interval({}, {}) = {}\",\n            x,\n            y,\n            Rational::simplest_rational_in_closed_interval(&x, &y)\n        );\n    }\n}\n\nfn benchmark_rational_cmp_complexity(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.cmp_complexity(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.cmp_complexity(&y)))],\n    );\n}\n\nfn benchmark_simplest_rational_in_open_interval_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"simplest_rational_in_open_interval(&Rational, &Rational)\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(Rational::simplest_rational_in_open_interval(&x, &y));\n            }),\n            (\"explicit\", &mut |(x, y)| {\n                no_out!(simplest_rational_in_open_interval_explicit(&x, &y));\n            }),\n            (\"naive\", &mut |(x, y)| {\n                no_out!(simplest_rational_in_open_interval_naive(&x, &y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_simplest_rational_in_open_interval_algorithms_2(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"simplest_rational_in_open_interval(&Rational, &Rational)\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(Rational::simplest_rational_in_open_interval(&x, &y));\n            }),\n            (\"explicit\", &mut |(x, y)| {\n                no_out!(simplest_rational_in_open_interval_explicit(&x, &y));\n            }),\n        ],\n    );\n}\n\nfn benchmark_simplest_rational_in_closed_interval(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"simplest_rational_in_closed_interval(&Rational, &Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| {\n            no_out!(Rational::simplest_rational_in_closed_interval(&x, &y));\n        })],\n    );\n}\n\nfn benchmark_simplest_rational_in_closed_interval_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"simplest_rational_in_closed_interval(&Rational, &Rational)\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen_var_6().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| {\n                no_out!(Rational::simplest_rational_in_closed_interval(&x, &y));\n            }),\n            (\"naive\", &mut |(x, y)| {\n                no_out!(simplest_rational_in_closed_interval_naive(&x, &y));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::CheckedSqrt;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_gen_var_3;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_checked_sqrt);\n    register_demo!(runner, demo_rational_checked_sqrt_ref);\n\n    register_bench!(runner, benchmark_rational_checked_sqrt_evaluation_strategy);\n}\n\nfn demo_rational_checked_sqrt(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen_var_3().get(gm, config).take(limit) {\n        println!(\"({}).checked_sqrt() = {:?}\", x, x.clone().checked_sqrt());\n    }\n}\n\nfn demo_rational_checked_sqrt_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen_var_3().get(gm, config).take(limit) {\n        println!(\"(&{}).checked_sqrt() = {:?}\", x, (&x).checked_sqrt());\n    }\n}\n\nfn benchmark_rational_checked_sqrt_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.checked_sqrt()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.checked_sqrt()\", &mut |x| {\n                no_out!(x.checked_sqrt());\n            }),\n            (\"(&Rational).checked_sqrt()\", &mut |x| {\n                no_out!((&x).checked_sqrt());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Square, SquareAssign};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_square);\n    register_demo!(runner, demo_rational_square_ref);\n    register_demo!(runner, demo_rational_square_assign);\n\n    register_bench!(runner, benchmark_rational_square_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_square_algorithms);\n    register_bench!(runner, benchmark_rational_square_assign);\n}\n\nfn demo_rational_square(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"{} ^ 2 = {}\", n.clone(), n.square());\n    }\n}\n\nfn demo_rational_square_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"&{} ^ 2 = {}\", n, (&n).square());\n    }\n}\n\nfn demo_rational_square_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for mut n in rational_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        n.square_assign();\n        println!(\"n := {n_old}; n.square_assign(); n = {n}\");\n    }\n}\n\nfn benchmark_rational_square_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.square()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.square()\", &mut |n| no_out!(n.square())),\n            (\"(&Rational).square()\", &mut |n| no_out!((&n).square())),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_square_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.square()\",\n        BenchmarkType::Algorithms,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"standard\", &mut |ref n| no_out!(n.square())),\n            (\"using *\", &mut |ref n| no_out!(n * n)),\n        ],\n    );\n}\n\nfn benchmark_rational_square_assign(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.square_assign()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |mut n| n.square_assign())],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::arithmetic::sub::sub_naive;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_2_pair_rational_max_bit_bucketer, pair_rational_max_bit_bucketer,\n    triple_3_pair_rational_max_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_pair_gen, rational_pair_gen_nrm, rational_pair_gen_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_sub);\n    register_demo!(runner, demo_rational_sub_val_ref);\n    register_demo!(runner, demo_rational_sub_ref_val);\n    register_demo!(runner, demo_rational_sub_ref_ref);\n    register_demo!(runner, demo_rational_sub_assign);\n    register_demo!(runner, demo_rational_sub_assign_ref);\n\n    register_bench!(runner, benchmark_rational_sub_library_comparison);\n    register_bench!(runner, benchmark_rational_sub_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_sub_algorithms);\n    register_bench!(runner, benchmark_rational_sub_assign_library_comparison);\n    register_bench!(runner, benchmark_rational_sub_assign_evaluation_strategy);\n}\n\nfn demo_rational_sub(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        let y_old = y.clone();\n        println!(\"{} - {} = {}\", x_old, y_old, x - y);\n    }\n}\n\nfn demo_rational_sub_val_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        println!(\"{} - &{} = {}\", x_old, y, x - &y);\n    }\n}\n\nfn demo_rational_sub_ref_val(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let y_old = y.clone();\n        println!(\"&{} - {} = {}\", x, y_old, &x - y);\n    }\n}\n\nfn demo_rational_sub_ref_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        println!(\"&{} - &{} = {}\", x, y, &x - &y);\n    }\n}\n\nfn demo_rational_sub_assign(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x -= y.clone();\n        println!(\"x := {x_old}; x -= {y}; x = {x}\");\n    }\n}\n\nfn demo_rational_sub_assign_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x -= &y;\n        println!(\"x := {x_old}; x -= &{y}; x = {x}\");\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_sub_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational - Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x - y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x - y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x - y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_sub_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational - Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational - Rational\", &mut |(x, y)| no_out!(x - y)),\n            (\"Rational - &Rational\", &mut |(x, y)| no_out!(x - &y)),\n            (\"&Rational - Rational\", &mut |(x, y)| no_out!(&x - y)),\n            (\"&Rational - &Rational\", &mut |(x, y)| no_out!(&x - &y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\nfn benchmark_rational_sub_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational - Rational\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x - y)),\n            (\"naive\", &mut |(x, y)| no_out!(sub_naive(x, y))),\n        ],\n    );\n}\n\nfn benchmark_rational_sub_assign_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational -= Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(_, (mut x, y))| x -= y), (\"rug\", &mut |((mut x, y), _)| x -= y)],\n    );\n}\n\nfn benchmark_rational_sub_assign_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational -= Rational\",\n        BenchmarkType::EvaluationStrategy,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Rational -= Rational\", &mut |(mut x, y)| no_out!(x -= y)),\n            (\"Rational -= &Rational\", &mut |(mut x, y)| no_out!(x -= &y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/basic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    significant_bits::register(runner);\n}\n\nmod significant_bits;\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/basic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_significant_bits);\n\n    register_bench!(runner, benchmark_significant_bits);\n}\n\nfn demo_significant_bits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"significant_bits({}) = {}\", x, x.significant_bits());\n    }\n}\n\nfn benchmark_significant_bits(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.significant_bits()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.significant_bits()))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::triple_3_pair_rational_max_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_pair_gen, rational_pair_gen_nrm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_cmp);\n    register_bench!(runner, benchmark_rational_cmp_library_comparison);\n}\n\nfn demo_rational_cmp(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        match x.cmp(&y) {\n            Less => println!(\"{x} < {y}\"),\n            Equal => println!(\"{x} = {y}\"),\n            Greater => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_cmp_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.cmp(&Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x.cmp(&y))),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x.cmp(&y))),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x.cmp(&y))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_2_pair_rational_max_bit_bucketer, pair_rational_max_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_pair_gen, rational_pair_gen_rm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_cmp_abs);\n    register_demo!(runner, demo_rational_lt_abs);\n    register_demo!(runner, demo_rational_gt_abs);\n    register_demo!(runner, demo_rational_le_abs);\n    register_demo!(runner, demo_rational_ge_abs);\n\n    register_bench!(runner, benchmark_rational_cmp_abs_library_comparison);\n    register_bench!(runner, benchmark_rational_cmp_abs_algorithms);\n    register_bench!(runner, benchmark_rational_lt_abs);\n    register_bench!(runner, benchmark_rational_gt_abs);\n    register_bench!(runner, benchmark_rational_le_abs);\n    register_bench!(runner, benchmark_rational_ge_abs);\n}\n\nfn demo_rational_cmp_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        match x.cmp_abs(&y) {\n            Less => println!(\"|{x}| < |{y}|\"),\n            Equal => println!(\"|{x}| = |{y}|\"),\n            Greater => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_rational_lt_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        if x.lt_abs(&y) {\n            println!(\"|{x}| < |{y}|\");\n        } else {\n            println!(\"|{x}| ≮ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_gt_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        if x.gt_abs(&y) {\n            println!(\"|{x}| > |{y}|\");\n        } else {\n            println!(\"|{x}| ≯ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_le_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        if x.le_abs(&y) {\n            println!(\"|{x}| ≤ |{y}|\");\n        } else {\n            println!(\"|{x}| ≰ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_ge_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        if x.ge_abs(&y) {\n            println!(\"|{x}| ≥ |{y}|\");\n        } else {\n            println!(\"|{x}| ≱ |{y}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_cmp_abs_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.cmp_abs(&Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.cmp_abs(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.cmp_abs(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_cmp_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.cmp_abs(&Rational)\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs().cmp(&y.abs()))),\n        ],\n    );\n}\n\nfn benchmark_rational_lt_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.lt_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_gt_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.gt_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_le_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.le_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_ge_abs(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.ge_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::triple_3_pair_rational_max_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_pair_gen, rational_pair_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_eq);\n    register_bench!(runner, benchmark_rational_eq_library_comparison);\n}\n\nfn demo_rational_eq(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_eq_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational == Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (x, y))| no_out!(x == y)),\n            (\"num\", &mut |((x, y), _, _)| no_out!(x == y)),\n            (\"rug\", &mut |(_, (x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_rational_max_bit_bucketer;\nuse malachite_q::test_util::generators::rational_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_eq_abs);\n    register_bench!(runner, benchmark_rational_eq_abs_algorithms);\n}\n\nfn demo_rational_eq_abs(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_eq_abs_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.eq_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        rational_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/eq_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_integer_max_bit_bucketer;\nuse malachite_q::test_util::generators::rational_integer_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_eq_abs_integer);\n    register_demo!(runner, demo_integer_eq_abs_rational);\n\n    register_bench!(runner, benchmark_rational_eq_abs_integer_algorithms);\n    register_bench!(runner, benchmark_integer_eq_abs_rational_algorithms);\n}\n\nfn demo_rational_eq_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_eq_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if y.eq_abs(&x) {\n            println!(\"|{y}| = |{x}|\");\n        } else {\n            println!(\"|{y}| ≠ |{x}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_eq_abs_integer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.eq_abs(&Integer)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_eq_abs_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.eq_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y.abs() == x.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_natural_max_bit_bucketer;\nuse malachite_q::test_util::generators::rational_natural_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_eq_abs_natural);\n    register_demo!(runner, demo_natural_eq_abs_rational);\n\n    register_bench!(runner, benchmark_rational_eq_abs_natural_algorithms);\n    register_bench!(runner, benchmark_natural_eq_abs_rational_algorithms);\n}\n\nfn demo_rational_eq_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if x.eq_abs(&y) {\n            println!(\"|{x}| = |{y}|\");\n        } else {\n            println!(\"|{x}| ≠ |{y}|\");\n        }\n    }\n}\n\nfn demo_natural_eq_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if y.eq_abs(&x) {\n            println!(\"|{y}| = |{x}|\");\n        } else {\n            println!(\"|{y}| ≠ |{x}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_eq_abs_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.eq_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_eq_abs_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.eq_abs(&Rational)\",\n        BenchmarkType::Algorithms,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y == x.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_primitive_float_pair_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_rational_eq_abs_primitive_float);\n    register_primitive_float_demos!(runner, demo_primitive_float_eq_abs_rational);\n\n    register_primitive_float_benches!(runner, benchmark_rational_eq_abs_primitive_float_algorithms);\n    register_primitive_float_benches!(runner, benchmark_primitive_float_eq_abs_rational_algorithms);\n}\n\nfn demo_rational_eq_abs_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: EqAbs<T>,\n{\n    for (n, x) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.eq_abs(&x) {\n            println!(\"|{}| = |{}|\", n, NiceFloat(x));\n        } else {\n            println!(\"|{}| ≠ |{}|\", n, NiceFloat(x));\n        }\n    }\n}\n\nfn demo_primitive_float_eq_abs_rational<T: EqAbs<Rational> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, x) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.eq_abs(&n) {\n            println!(\"|{}| = |{}|\", NiceFloat(x), n);\n        } else {\n            println!(\"|{}| ≠ |{}|\", NiceFloat(x), n);\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_eq_abs_primitive_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: EqAbs<T> + PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.eq_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y.abs())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_primitive_float_eq_abs_rational_algorithms<\n    T: EqAbs<Rational> + PartialEq<Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Rational)\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y.abs() == x.abs())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_signed_pair_gen, rational_unsigned_pair_gen};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rational_partial_eq_abs_unsigned);\n    register_signed_demos!(runner, demo_rational_partial_eq_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_abs_rational);\n    register_signed_demos!(runner, demo_signed_partial_eq_abs_rational);\n\n    register_unsigned_benches!(runner, benchmark_rational_eq_abs_unsigned_algorithms);\n    register_signed_benches!(runner, benchmark_rational_eq_abs_signed_algorithms);\n    register_unsigned_benches!(runner, benchmark_unsigned_eq_abs_rational_algorithms);\n    register_signed_benches!(runner, benchmark_signed_eq_abs_rational_algorithms);\n}\n\nfn demo_rational_partial_eq_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: EqAbs<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.eq_abs(&u) {\n            println!(\"|{n}| = |{u}|\");\n        } else {\n            println!(\"|{n}| ≠ |{u}|\");\n        }\n    }\n}\n\nfn demo_rational_partial_eq_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: EqAbs<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.eq_abs(&i) {\n            println!(\"|{n}| = |{i}|\");\n        } else {\n            println!(\"|{n}| ≠ |{i}|\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_abs_rational<T: EqAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if u.eq_abs(&n) {\n            println!(\"|{u}| = |{n}|\");\n        } else {\n            println!(\"|{u}| ≠ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_abs_rational<T: EqAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.eq_abs(&n) {\n            println!(\"|{i}| = |{n}|\");\n        } else {\n            println!(\"|{i}| ≠ |{n}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_eq_abs_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: EqAbs<T> + PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.eq_abs({})\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs() == y)),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_eq_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: EqAbs<T> + PartialEq<<T as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"Rational.eq_abs({})\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.eq_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs() == y.unsigned_abs());\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_eq_abs_rational_algorithms<\n    T: EqAbs<Rational> + PartialEq<Rational> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Rational)\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y == x.abs())),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_eq_abs_rational_algorithms<T: EqAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PartialEq<Rational>,\n{\n    run_benchmark(\n        &format!(\"{}.eq_abs(&Rational)\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.eq_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y.unsigned_abs() == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::hash::hash;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::triple_3_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_hash);\n    register_bench!(runner, benchmark_rational_hash_library_comparison);\n}\n\nfn demo_rational_hash(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"hash({}) = {}\", n, hash(&n));\n    }\n}\n\nfn benchmark_rational_hash_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational hash\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(hash(&n))),\n            (\"num\", &mut |(_, n, _)| no_out!(hash(&n))),\n            (\"rug\", &mut |(n, _, _)| no_out!(hash(&n))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    cmp::register(runner);\n    cmp_abs::register(runner);\n    eq::register(runner);\n    eq_abs::register(runner);\n    eq_abs_integer::register(runner);\n    eq_abs_natural::register(runner);\n    eq_abs_primitive_float::register(runner);\n    eq_abs_primitive_int::register(runner);\n    hash::register(runner);\n    partial_cmp_abs_integer::register(runner);\n    partial_cmp_abs_natural::register(runner);\n    partial_cmp_abs_primitive_float::register(runner);\n    partial_cmp_abs_primitive_int::register(runner);\n    partial_cmp_integer::register(runner);\n    partial_cmp_natural::register(runner);\n    partial_cmp_primitive_float::register(runner);\n    partial_cmp_primitive_int::register(runner);\n    partial_eq_integer::register(runner);\n    partial_eq_natural::register(runner);\n    partial_eq_primitive_float::register(runner);\n    partial_eq_primitive_int::register(runner);\n}\n\nmod cmp;\nmod cmp_abs;\nmod eq;\nmod eq_abs;\nmod eq_abs_integer;\nmod eq_abs_natural;\nmod eq_abs_primitive_float;\nmod eq_abs_primitive_int;\nmod hash;\nmod partial_cmp_abs_integer;\nmod partial_cmp_abs_natural;\nmod partial_cmp_abs_primitive_float;\nmod partial_cmp_abs_primitive_int;\nmod partial_cmp_integer;\nmod partial_cmp_natural;\nmod partial_cmp_primitive_float;\nmod partial_cmp_primitive_int;\nmod partial_eq_integer;\nmod partial_eq_natural;\nmod partial_eq_primitive_float;\nmod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_integer_max_bit_bucketer;\nuse malachite_q::test_util::generators::rational_integer_pair_gen;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_partial_cmp_abs_integer);\n    register_demo!(runner, demo_integer_partial_cmp_abs_rational);\n    register_demo!(runner, demo_rational_lt_abs_integer);\n    register_demo!(runner, demo_rational_gt_abs_integer);\n    register_demo!(runner, demo_rational_le_abs_integer);\n    register_demo!(runner, demo_rational_ge_abs_integer);\n    register_demo!(runner, demo_integer_lt_abs_rational);\n    register_demo!(runner, demo_integer_gt_abs_rational);\n    register_demo!(runner, demo_integer_le_abs_rational);\n    register_demo!(runner, demo_integer_ge_abs_rational);\n\n    register_bench!(\n        runner,\n        benchmark_rational_partial_cmp_abs_integer_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_partial_cmp_abs_rational_algorithms\n    );\n    register_bench!(runner, benchmark_rational_lt_abs_integer);\n    register_bench!(runner, benchmark_rational_gt_abs_integer);\n    register_bench!(runner, benchmark_rational_le_abs_integer);\n    register_bench!(runner, benchmark_rational_ge_abs_integer);\n    register_bench!(runner, benchmark_integer_lt_abs_rational);\n    register_bench!(runner, benchmark_integer_gt_abs_rational);\n    register_bench!(runner, benchmark_integer_le_abs_rational);\n    register_bench!(runner, benchmark_integer_ge_abs_rational);\n}\n\nfn demo_rational_partial_cmp_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y).unwrap() {\n            Less => println!(\"|{x}| < |{y}|\"),\n            Equal => println!(\"|{x}| = |{y}|\"),\n            Greater => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        match y.partial_cmp_abs(&x).unwrap() {\n            Less => println!(\"|{y}| < |{x}|\"),\n            Equal => println!(\"|{y}| = |{x}|\"),\n            Greater => println!(\"|{y}| > |{x}|\"),\n        }\n    }\n}\n\nfn demo_rational_lt_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if x.lt_abs(&y) {\n            println!(\"|{x}| < |{y}|\");\n        } else {\n            println!(\"|{x}| ≮ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_gt_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if x.gt_abs(&y) {\n            println!(\"|{x}| > |{y}|\");\n        } else {\n            println!(\"|{x}| ≯ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_le_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if x.le_abs(&y) {\n            println!(\"|{x}| ≤ |{y}|\");\n        } else {\n            println!(\"|{x}| ≰ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_ge_abs_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if x.ge_abs(&y) {\n            println!(\"|{x}| ≥ |{y}|\");\n        } else {\n            println!(\"|{x}| ≱ |{y}|\");\n        }\n    }\n}\n\nfn demo_integer_lt_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if y.lt_abs(&x) {\n            println!(\"|{y}| < |{x}|\");\n        } else {\n            println!(\"|{y}| ≮ |{x}|\");\n        }\n    }\n}\n\nfn demo_integer_gt_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if y.gt_abs(&x) {\n            println!(\"|{y}| > |{x}|\");\n        } else {\n            println!(\"|{y}| ≯ |{x}|\");\n        }\n    }\n}\n\nfn demo_integer_le_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if y.le_abs(&x) {\n            println!(\"|{y}| ≤ |{x}|\");\n        } else {\n            println!(\"|{y}| ≰ |{x}|\");\n        }\n    }\n}\n\nfn demo_integer_ge_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if y.ge_abs(&x) {\n            println!(\"|{y}| ≥ |{x}|\");\n        } else {\n            println!(\"|{y}| ≱ |{x}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_abs_integer_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.partial_cmp_abs(&Integer)\",\n        BenchmarkType::Algorithms,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_abs_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.partial_cmp_abs(&Rational)\",\n        BenchmarkType::Algorithms,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(y.abs().partial_cmp(&x.abs()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_lt_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.lt_abs(&Integer)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_gt_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.gt_abs(&Integer)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_le_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.le_abs(&Integer)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_ge_abs_integer(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ge_abs(&Integer)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_integer_lt_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.lt_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_integer_gt_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.gt_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_integer_le_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.le_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_integer_ge_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer.ge_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_integer_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_natural_max_bit_bucketer;\nuse malachite_q::test_util::generators::rational_natural_pair_gen;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_partial_cmp_abs_natural);\n    register_demo!(runner, demo_natural_partial_cmp_abs_rational);\n    register_demo!(runner, demo_rational_lt_abs_natural);\n    register_demo!(runner, demo_rational_gt_abs_natural);\n    register_demo!(runner, demo_rational_le_abs_natural);\n    register_demo!(runner, demo_rational_ge_abs_natural);\n    register_demo!(runner, demo_natural_lt_abs_rational);\n    register_demo!(runner, demo_natural_gt_abs_rational);\n    register_demo!(runner, demo_natural_le_abs_rational);\n    register_demo!(runner, demo_natural_ge_abs_rational);\n\n    register_bench!(\n        runner,\n        benchmark_rational_partial_cmp_abs_natural_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_partial_cmp_abs_rational_algorithms\n    );\n    register_bench!(runner, benchmark_rational_lt_abs_natural);\n    register_bench!(runner, benchmark_rational_gt_abs_natural);\n    register_bench!(runner, benchmark_rational_le_abs_natural);\n    register_bench!(runner, benchmark_rational_ge_abs_natural);\n    register_bench!(runner, benchmark_natural_lt_abs_rational);\n    register_bench!(runner, benchmark_natural_gt_abs_rational);\n    register_bench!(runner, benchmark_natural_le_abs_rational);\n    register_bench!(runner, benchmark_natural_ge_abs_rational);\n}\n\nfn demo_rational_partial_cmp_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp_abs(&y).unwrap() {\n            Less => println!(\"|{x}| < |{y}|\"),\n            Equal => println!(\"|{x}| = |{y}|\"),\n            Greater => println!(\"|{x}| > |{y}|\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        match y.partial_cmp_abs(&x).unwrap() {\n            Less => println!(\"|{y}| < |{x}|\"),\n            Equal => println!(\"|{y}| = |{x}|\"),\n            Greater => println!(\"|{y}| > |{x}|\"),\n        }\n    }\n}\n\nfn demo_rational_lt_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if x.lt_abs(&y) {\n            println!(\"|{x}| < |{y}|\");\n        } else {\n            println!(\"|{x}| ≮ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_gt_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if x.gt_abs(&y) {\n            println!(\"|{x}| > |{y}|\");\n        } else {\n            println!(\"|{x}| ≯ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_le_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if x.le_abs(&y) {\n            println!(\"|{x}| ≤ |{y}|\");\n        } else {\n            println!(\"|{x}| ≰ |{y}|\");\n        }\n    }\n}\n\nfn demo_rational_ge_abs_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if x.ge_abs(&y) {\n            println!(\"|{x}| ≥ |{y}|\");\n        } else {\n            println!(\"|{x}| ≱ |{y}|\");\n        }\n    }\n}\n\nfn demo_natural_lt_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if y.lt_abs(&x) {\n            println!(\"|{y}| < |{x}|\");\n        } else {\n            println!(\"|{y}| ≮ |{x}|\");\n        }\n    }\n}\n\nfn demo_natural_gt_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if y.gt_abs(&x) {\n            println!(\"|{y}| > |{x}|\");\n        } else {\n            println!(\"|{y}| ≯ |{x}|\");\n        }\n    }\n}\n\nfn demo_natural_le_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if y.le_abs(&x) {\n            println!(\"|{y}| ≤ |{x}|\");\n        } else {\n            println!(\"|{y}| ≰ |{x}|\");\n        }\n    }\n}\n\nfn demo_natural_ge_abs_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if y.ge_abs(&x) {\n            println!(\"|{y}| ≥ |{x}|\");\n        } else {\n            println!(\"|{y}| ≱ |{x}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_abs_natural_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.partial_cmp_abs(&Natural)\",\n        BenchmarkType::Algorithms,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs().partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_partial_cmp_abs_rational_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp_abs(&Rational)\",\n        BenchmarkType::Algorithms,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y.partial_cmp(&x.abs()))),\n        ],\n    );\n}\n\nfn benchmark_rational_lt_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.lt_abs(&Natural)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_gt_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.gt_abs(&Natural)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_le_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.le_abs(&Natural)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_ge_abs_natural(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.ge_abs(&Natural)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_natural_lt_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.lt_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_natural_gt_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.gt_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_natural_le_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.le_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_natural_ge_abs_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.ge_abs(&Rational)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_primitive_float_pair_gen;\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_rational_partial_cmp_abs_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_abs_rational);\n\n    register_primitive_float_benches!(runner, benchmark_rational_partial_cmp_abs_float_algorithms);\n    register_primitive_float_benches!(runner, benchmark_float_partial_cmp_abs_rational_algorithms);\n}\n\nfn demo_rational_partial_cmp_abs_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, f) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp_abs(&f) {\n            None => println!(\"{} is not comparable with {}\", n, NiceFloat(f)),\n            Some(Less) => println!(\"|{}| < |{}|\", n, NiceFloat(f)),\n            Some(Equal) => println!(\"|{}| = |{}|\", n, NiceFloat(f)),\n            Some(Greater) => println!(\"|{}| > |{}|\", n, NiceFloat(f)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match f.partial_cmp_abs(&n) {\n            None => println!(\"{} is not comparable with {}\", NiceFloat(f), n),\n            Some(Less) => println!(\"|{}| < |{}|\", NiceFloat(f), n),\n            Some(Equal) => println!(\"|{}| = |{}|\", NiceFloat(f), n),\n            Some(Greater) => println!(\"|{}| > |{}|\", NiceFloat(f), n),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_abs_float_algorithms<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T> + PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_float_partial_cmp_abs_rational_algorithms<\n    T: PartialOrdAbs<Rational> + PartialOrd<Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Rational)\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_primitive_float_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(y.abs().partial_cmp_abs(&x.abs()));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_signed_pair_gen, rational_unsigned_pair_gen};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rational_partial_cmp_abs_unsigned);\n    register_signed_demos!(runner, demo_rational_partial_cmp_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_abs_rational);\n    register_signed_demos!(runner, demo_signed_partial_cmp_abs_rational);\n    register_unsigned_demos!(runner, demo_rational_lt_abs_unsigned);\n    register_signed_demos!(runner, demo_rational_lt_abs_signed);\n    register_unsigned_demos!(runner, demo_rational_gt_abs_unsigned);\n    register_signed_demos!(runner, demo_rational_gt_abs_signed);\n    register_unsigned_demos!(runner, demo_rational_le_abs_unsigned);\n    register_signed_demos!(runner, demo_rational_le_abs_signed);\n    register_unsigned_demos!(runner, demo_rational_ge_abs_unsigned);\n    register_signed_demos!(runner, demo_rational_ge_abs_signed);\n    register_unsigned_demos!(runner, demo_unsigned_lt_abs_rational);\n    register_signed_demos!(runner, demo_signed_lt_abs_rational);\n    register_unsigned_demos!(runner, demo_unsigned_gt_abs_rational);\n    register_signed_demos!(runner, demo_signed_gt_abs_rational);\n    register_unsigned_demos!(runner, demo_unsigned_le_abs_rational);\n    register_signed_demos!(runner, demo_signed_le_abs_rational);\n    register_unsigned_demos!(runner, demo_unsigned_ge_abs_rational);\n    register_signed_demos!(runner, demo_signed_ge_abs_rational);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_rational_partial_cmp_abs_unsigned_algorithms\n    );\n    register_signed_benches!(runner, benchmark_rational_partial_cmp_abs_signed_algorithms);\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_cmp_abs_rational_algorithms\n    );\n    register_signed_benches!(runner, benchmark_signed_partial_cmp_abs_rational_algorithms);\n    register_unsigned_benches!(runner, benchmark_rational_lt_abs_unsigned);\n    register_signed_benches!(runner, benchmark_rational_lt_abs_signed);\n    register_unsigned_benches!(runner, benchmark_rational_gt_abs_unsigned);\n    register_signed_benches!(runner, benchmark_rational_gt_abs_signed);\n    register_unsigned_benches!(runner, benchmark_rational_le_abs_unsigned);\n    register_signed_benches!(runner, benchmark_rational_le_abs_signed);\n    register_unsigned_benches!(runner, benchmark_rational_ge_abs_unsigned);\n    register_signed_benches!(runner, benchmark_rational_ge_abs_signed);\n    register_unsigned_benches!(runner, benchmark_unsigned_lt_abs_rational);\n    register_signed_benches!(runner, benchmark_signed_lt_abs_rational);\n    register_unsigned_benches!(runner, benchmark_unsigned_gt_abs_rational);\n    register_signed_benches!(runner, benchmark_signed_gt_abs_rational);\n    register_unsigned_benches!(runner, benchmark_unsigned_le_abs_rational);\n    register_signed_benches!(runner, benchmark_signed_le_abs_rational);\n    register_unsigned_benches!(runner, benchmark_unsigned_ge_abs_rational);\n    register_signed_benches!(runner, benchmark_signed_ge_abs_rational);\n}\n\nfn demo_rational_partial_cmp_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp_abs(&u).unwrap() {\n            Less => println!(\"|{n}| < |{u}|\"),\n            Equal => println!(\"|{n}| = |{u}|\"),\n            Greater => println!(\"|{n}| > |{u}|\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp_abs(&i).unwrap() {\n            Less => println!(\"|{n}| < |{i}|\"),\n            Equal => println!(\"|{n}| = |{i}|\"),\n            Greater => println!(\"|{n}| > |{i}|\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match u.partial_cmp_abs(&n).unwrap() {\n            Less => println!(\"|{u}| < |{n}|\"),\n            Equal => println!(\"|{u}| = |{n}|\"),\n            Greater => println!(\"|{u}| > |{n}|\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match i.partial_cmp_abs(&n).unwrap() {\n            Less => println!(\"|{i}| < |{n}|\"),\n            Equal => println!(\"|{i}| = |{n}|\"),\n            Greater => println!(\"|{i}| > |{n}|\"),\n        }\n    }\n}\n\nfn demo_rational_lt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.lt_abs(&u) {\n            println!(\"|{n}| < |{u}|\");\n        } else {\n            println!(\"|{n}| ≮ |{u}|\");\n        }\n    }\n}\n\nfn demo_rational_lt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.lt_abs(&i) {\n            println!(\"|{n}| < |{i}|\");\n        } else {\n            println!(\"|{n}| ≮ |{i}|\");\n        }\n    }\n}\n\nfn demo_rational_gt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.gt_abs(&u) {\n            println!(\"|{n}| > |{u}|\");\n        } else {\n            println!(\"|{n}| ≯ |{u}|\");\n        }\n    }\n}\n\nfn demo_rational_gt_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.gt_abs(&i) {\n            println!(\"|{n}| > |{i}|\");\n        } else {\n            println!(\"|{n}| ≯ |{i}|\");\n        }\n    }\n}\n\nfn demo_rational_le_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.le_abs(&u) {\n            println!(\"|{n}| ≤ |{u}|\");\n        } else {\n            println!(\"|{n}| ≰ |{u}|\");\n        }\n    }\n}\n\nfn demo_rational_le_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.le_abs(&i) {\n            println!(\"|{n}| ≤ |{i}|\");\n        } else {\n            println!(\"|{n}| ≰ |{i}|\");\n        }\n    }\n}\n\nfn demo_rational_ge_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n.ge_abs(&u) {\n            println!(\"|{n}| ≥ |{u}|\");\n        } else {\n            println!(\"|{n}| ≱ |{u}|\");\n        }\n    }\n}\n\nfn demo_rational_ge_abs_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: PartialOrdAbs<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n.ge_abs(&i) {\n            println!(\"|{n}| ≥ |{i}|\");\n        } else {\n            println!(\"|{n}| ≱ |{i}|\");\n        }\n    }\n}\n\nfn demo_unsigned_lt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if u.lt_abs(&n) {\n            println!(\"|{u}| < |{n}|\");\n        } else {\n            println!(\"|{u}| ≮ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_lt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.lt_abs(&n) {\n            println!(\"|{i}| < |{n}|\");\n        } else {\n            println!(\"|{i}| ≮ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_gt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if u.gt_abs(&n) {\n            println!(\"|{u}| > |{n}|\");\n        } else {\n            println!(\"|{u}| ≯ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_gt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.gt_abs(&n) {\n            println!(\"|{i}| > |{n}|\");\n        } else {\n            println!(\"|{i}| ≯ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_le_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if u.le_abs(&n) {\n            println!(\"|{u}| ≤ |{n}|\");\n        } else {\n            println!(\"|{u}| ≰ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_le_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.le_abs(&n) {\n            println!(\"|{i}| ≤ |{n}|\");\n        } else {\n            println!(\"|{i}| ≰ |{n}|\");\n        }\n    }\n}\n\nfn demo_unsigned_ge_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if u.ge_abs(&n) {\n            println!(\"|{u}| ≥ |{n}|\");\n        } else {\n            println!(\"|{u}| ≱ |{n}|\");\n        }\n    }\n}\n\nfn demo_signed_ge_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i.ge_abs(&n) {\n            println!(\"|{i}| ≥ |{n}|\");\n        } else {\n            println!(\"|{i}| ≱ |{n}|\");\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_abs_unsigned_algorithms<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T> + PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| no_out!(x.abs().partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_abs_signed_algorithms<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T> + PartialOrd<<T as UnsignedAbs>::Output>,\n{\n    run_benchmark(\n        &format!(\"Rational.partial_cmp_abs(&{})\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(x.partial_cmp_abs(&y))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(x.abs().partial_cmp(&y.unsigned_abs()));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_partial_cmp_abs_rational_algorithms<\n    T: PartialOrdAbs<Rational> + PartialOrd<Rational> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Rational)\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| no_out!(y.partial_cmp(&x.abs()))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_partial_cmp_abs_rational_algorithms<\n    T: PartialOrdAbs<Rational> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    <T as UnsignedAbs>::Output: PartialOrd<Rational>,\n{\n    run_benchmark(\n        &format!(\"{}.partial_cmp_abs(&Rational)\", T::NAME),\n        BenchmarkType::Algorithms,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |(x, y)| no_out!(y.partial_cmp_abs(&x))),\n            (\"using abs\", &mut |(x, y)| {\n                no_out!(y.unsigned_abs().partial_cmp(&x.abs()));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_lt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.lt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_lt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.lt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.lt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_gt_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.gt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_gt_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.gt_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.gt_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_le_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.le_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_le_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.le_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.le_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_ge_abs_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.ge_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_rational_ge_abs_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrdAbs<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.ge_abs(&{})\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(x.ge_abs(&y)))],\n    );\n}\n\nfn benchmark_unsigned_lt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lt_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_lt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.lt_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.lt_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_gt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gt_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_gt_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.gt_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.gt_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_le_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.le_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_le_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.le_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.le_abs(&x)))],\n    );\n}\n\nfn benchmark_unsigned_ge_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ge_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n\nfn benchmark_signed_ge_abs_rational<T: PartialOrdAbs<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.ge_abs(&Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_signed_pair_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, y)| no_out!(y.ge_abs(&x)))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_2_rational_integer_max_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_integer_pair_gen, rational_integer_pair_gen_rm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_partial_cmp_integer);\n    register_demo!(runner, demo_integer_partial_cmp_rational);\n    register_bench!(\n        runner,\n        benchmark_rational_partial_cmp_integer_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_partial_cmp_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_cmp_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y).unwrap() {\n            Less => println!(\"{x} < {y}\"),\n            Equal => println!(\"{x} = {y}\"),\n            Greater => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_integer_partial_cmp_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        match y.partial_cmp(&x).unwrap() {\n            Less => println!(\"{y} < {x}\"),\n            Equal => println!(\"{y} = {x}\"),\n            Greater => println!(\"{y} > {x}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.partial_cmp(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        rational_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_integer_partial_cmp_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp(&Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_2_rational_natural_max_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_natural_pair_gen, rational_natural_pair_gen_rm};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_partial_cmp_natural);\n    register_demo!(runner, demo_natural_partial_cmp_rational);\n    register_bench!(\n        runner,\n        benchmark_rational_partial_cmp_natural_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_partial_cmp_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_cmp_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        match x.partial_cmp(&y).unwrap() {\n            Less => println!(\"{x} < {y}\"),\n            Equal => println!(\"{x} = {y}\"),\n            Greater => println!(\"{x} > {y}\"),\n        }\n    }\n}\n\nfn demo_natural_partial_cmp_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        match y.partial_cmp(&x).unwrap() {\n            Less => println!(\"{y} < {x}\"),\n            Equal => println!(\"{y} = {x}\"),\n            Greater => println!(\"{y} > {x}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.partial_cmp(&Natural)\",\n        BenchmarkType::LibraryComparison,\n        rational_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_natural_partial_cmp_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural.partial_cmp(&Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_2_pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_primitive_float_pair_gen, rational_primitive_float_pair_gen_rm,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_rational_partial_cmp_float);\n    register_primitive_float_demos!(runner, demo_float_partial_cmp_rational);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_rational_partial_cmp_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_cmp_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_cmp_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: PartialOrd<T>,\n{\n    for (n, f) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp(&f) {\n            None => println!(\"{} is not comparable with {}\", n, NiceFloat(f)),\n            Some(Less) => println!(\"{} < {}\", n, NiceFloat(f)),\n            Some(Equal) => println!(\"{} = {}\", n, NiceFloat(f)),\n            Some(Greater) => println!(\"{} > {}\", n, NiceFloat(f)),\n        }\n    }\n}\n\nfn demo_float_partial_cmp_rational<T: PartialOrd<Rational> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match f.partial_cmp(&n) {\n            None => println!(\"{} is not comparable with {}\", NiceFloat(f), n),\n            Some(Less) => println!(\"{} < {}\", NiceFloat(f), n),\n            Some(Equal) => println!(\"{} = {}\", NiceFloat(f), n),\n            Some(Greater) => println!(\"{} > {}\", NiceFloat(f), n),\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_partial_cmp_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrd<T>,\n    rug::Rational: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_partial_cmp_rational_library_comparison<\n    T: PartialOrd<Rational> + PartialOrd<rug::Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Rational)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_2_pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_signed_pair_gen, rational_signed_pair_gen_rm, rational_unsigned_pair_gen,\n    rational_unsigned_pair_gen_rm,\n};\nuse std::cmp::Ordering::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rational_partial_cmp_unsigned);\n    register_signed_demos!(runner, demo_rational_partial_cmp_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_cmp_rational);\n    register_signed_demos!(runner, demo_signed_partial_cmp_rational);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_rational_partial_cmp_unsigned_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_rational_partial_cmp_signed_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_cmp_rational_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_cmp_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_cmp_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrd<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match n.partial_cmp(&u).unwrap() {\n            Less => println!(\"{n} < {u}\"),\n            Equal => println!(\"{n} = {u}\"),\n            Greater => println!(\"{n} > {u}\"),\n        }\n    }\n}\n\nfn demo_rational_partial_cmp_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrd<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match n.partial_cmp(&i).unwrap() {\n            Less => println!(\"{n} < {i}\"),\n            Equal => println!(\"{n} = {i}\"),\n            Greater => println!(\"{n} > {i}\"),\n        }\n    }\n}\n\nfn demo_unsigned_partial_cmp_rational<T: PartialOrd<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        match u.partial_cmp(&n).unwrap() {\n            Less => println!(\"{u} < {n}\"),\n            Equal => println!(\"{u} = {n}\"),\n            Greater => println!(\"{u} > {n}\"),\n        }\n    }\n}\n\nfn demo_signed_partial_cmp_rational<T: PartialOrd<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        match i.partial_cmp(&n).unwrap() {\n            Less => println!(\"{i} < {n}\"),\n            Equal => println!(\"{i} = {n}\"),\n            Greater => println!(\"{i} > {n}\"),\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrd<T>,\n    rug::Rational: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_partial_cmp_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrd<T>,\n    rug::Rational: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"Rational.partial_cmp(&{})\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x.partial_cmp(&y))),\n            (\"rug\", &mut |((x, y), _)| no_out!(x.partial_cmp(&y))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_unsigned_partial_cmp_rational_library_comparison<\n    T: PartialOrd<Rational> + PartialOrd<rug::Rational> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Rational)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_signed_partial_cmp_rational_library_comparison<\n    T: PartialOrd<Rational> + PartialOrd<rug::Rational> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}.partial_cmp(&Rational)\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y.partial_cmp(&x))),\n            (\"rug\", &mut |((x, y), _)| no_out!(y.partial_cmp(&x))),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_eq_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_2_rational_integer_max_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_integer_pair_gen, rational_integer_pair_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_partial_eq_integer);\n    register_demo!(runner, demo_integer_partial_eq_rational);\n    register_bench!(\n        runner,\n        benchmark_rational_partial_eq_integer_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_integer_partial_eq_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_eq_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_integer_partial_eq_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_integer_pair_gen().get(gm, config).take(limit) {\n        if y == x {\n            println!(\"{y} = {x}\");\n        } else {\n            println!(\"{y} ≠ {x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_partial_eq_integer_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational == Integer\",\n        BenchmarkType::LibraryComparison,\n        rational_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_integer_partial_eq_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer == Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_integer_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_integer_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::pair_2_rational_natural_max_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_natural_pair_gen, rational_natural_pair_gen_rm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_partial_eq_natural);\n    register_demo!(runner, demo_natural_partial_eq_rational);\n    register_bench!(\n        runner,\n        benchmark_rational_partial_eq_natural_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_natural_partial_eq_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_eq_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if x == y {\n            println!(\"{x} = {y}\");\n        } else {\n            println!(\"{x} ≠ {y}\");\n        }\n    }\n}\n\nfn demo_natural_partial_eq_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, y) in rational_natural_pair_gen().get(gm, config).take(limit) {\n        if y == x {\n            println!(\"{y} = {x}\");\n        } else {\n            println!(\"{y} ≠ {x}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_partial_eq_natural_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational == Natural\",\n        BenchmarkType::LibraryComparison,\n        rational_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_natural_partial_eq_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural == Rational\",\n        BenchmarkType::LibraryComparison,\n        rational_natural_pair_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_natural_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_2_pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_primitive_float_pair_gen, rational_primitive_float_pair_gen_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_rational_partial_eq_float);\n    register_primitive_float_demos!(runner, demo_float_partial_eq_rational);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_rational_partial_eq_float_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_partial_eq_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_eq_float<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: PartialEq<T>,\n{\n    for (n, f) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n == f {\n            println!(\"{} = {}\", n, NiceFloat(f));\n        } else {\n            println!(\"{} ≠ {}\", n, NiceFloat(f));\n        }\n    }\n}\n\nfn demo_float_partial_eq_rational<T: PartialEq<Rational> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, f) in rational_primitive_float_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if f == n {\n            println!(\"{} = {}\", NiceFloat(f), n);\n        } else {\n            println!(\"{} ≠ {}\", NiceFloat(f), n);\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_partial_eq_float_library_comparison<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialEq<T>,\n    rug::Rational: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Rational == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_float_partial_eq_rational_library_comparison<\n    T: PartialEq<Rational> + PartialEq<rug::Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Rational\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_primitive_float_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::pair_2_pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_signed_pair_gen, rational_signed_pair_gen_rm, rational_unsigned_pair_gen,\n    rational_unsigned_pair_gen_rm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rational_partial_eq_unsigned);\n    register_signed_demos!(runner, demo_rational_partial_eq_signed);\n    register_unsigned_demos!(runner, demo_unsigned_partial_eq_rational);\n    register_signed_demos!(runner, demo_signed_partial_eq_rational);\n\n    register_unsigned_benches!(\n        runner,\n        benchmark_rational_partial_eq_unsigned_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_rational_partial_eq_signed_library_comparison\n    );\n    register_unsigned_benches!(\n        runner,\n        benchmark_unsigned_partial_eq_rational_library_comparison\n    );\n    register_signed_benches!(\n        runner,\n        benchmark_signed_partial_eq_rational_library_comparison\n    );\n}\n\nfn demo_rational_partial_eq_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialEq<T>,\n{\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if n == u {\n            println!(\"{n} = {u}\");\n        } else {\n            println!(\"{n} ≠ {u}\");\n        }\n    }\n}\n\nfn demo_rational_partial_eq_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialEq<T>,\n{\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if n == i {\n            println!(\"{n} = {i}\");\n        } else {\n            println!(\"{n} ≠ {i}\");\n        }\n    }\n}\n\nfn demo_unsigned_partial_eq_rational<T: PartialEq<Rational> + PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, u) in rational_unsigned_pair_gen::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        if u == n {\n            println!(\"{u} = {n}\");\n        } else {\n            println!(\"{u} ≠ {n}\");\n        }\n    }\n}\n\nfn demo_signed_partial_eq_rational<T: PartialEq<Rational> + PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, i) in rational_signed_pair_gen::<T>().get(gm, config).take(limit) {\n        if i == n {\n            println!(\"{i} = {n}\");\n        } else {\n            println!(\"{i} ≠ {n}\");\n        }\n    }\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_partial_eq_unsigned_library_comparison<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialEq<T>,\n    rug::Rational: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Rational == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_rational_partial_eq_signed_library_comparison<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialEq<T>,\n    rug::Rational: PartialEq<T>,\n{\n    run_benchmark(\n        &format!(\"Rational == {}\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(x == y)),\n            (\"rug\", &mut |((x, y), _)| no_out!(x == y)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_unsigned_partial_eq_rational_library_comparison<\n    T: PartialEq<Rational> + PartialEq<rug::Rational> + PrimitiveUnsigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Rational\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_unsigned_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n\n#[allow(clippy::no_effect, clippy::unnecessary_operation, unused_must_use)]\nfn benchmark_signed_partial_eq_rational_library_comparison<\n    T: PartialEq<Rational> + PartialEq<rug::Rational> + PrimitiveSigned,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{} == Rational\", T::NAME),\n        BenchmarkType::LibraryComparison,\n        rational_signed_pair_gen_rm::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, (x, y))| no_out!(y == x)),\n            (\"rug\", &mut |((x, y), _)| no_out!(y == x)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    triple_3_pair_rational_max_bit_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_nrm, rational_pair_gen, rational_pair_gen_nrm,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_clone);\n    register_demo!(runner, demo_rational_clone_from);\n    register_bench!(runner, benchmark_rational_clone_library_comparison);\n    register_bench!(runner, benchmark_rational_clone_from_library_comparison);\n}\n\nfn demo_rational_clone(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\"clone({}) = {}\", n, n.clone());\n    }\n}\n\nfn demo_rational_clone_from(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut x, y) in rational_pair_gen().get(gm, config).take(limit) {\n        let x_old = x.clone();\n        x.clone_from(&y);\n        println!(\"x := {x_old}; x.clone_from({y}); x = {x}\");\n    }\n}\n\n#[allow(clippy::redundant_clone, unused_must_use)]\nfn benchmark_rational_clone_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.clone()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, n)| no_out!(n.clone())),\n            (\"num\", &mut |(n, _, _)| no_out!(n.clone())),\n            (\"rug\", &mut |(_, n, _)| no_out!(n.clone())),\n        ],\n    );\n}\n\nfn benchmark_rational_clone_from_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.clone_from(&Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_pair_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_rational_max_bit_bucketer(\"x\", \"y\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (mut x, y))| x.clone_from(&y)),\n            (\"num\", &mut |((mut x, y), _, _)| x.clone_from(&y)),\n            (\"rug\", &mut |(_, (mut x, y), _)| x.clone_from(&y)),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/continued_fraction/convergents.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::conversion::traits::Convergents;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::conversion::continued_fraction::convergents::convergents_alt;\nuse malachite_q::test_util::generators::rational_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_convergents);\n    register_demo!(runner, demo_rational_convergents_ref);\n    register_bench!(runner, benchmark_rational_convergents_algorithms);\n    register_bench!(runner, benchmark_rational_convergents_evaluation_strategy);\n}\n\nfn demo_rational_convergents(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"convergents({}) = {:?}\",\n            x.clone(),\n            x.convergents().collect_vec()\n        );\n    }\n}\n\nfn demo_rational_convergents_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"convergents(&{}) = {:?}\",\n            x,\n            (&x).convergents().collect_vec()\n        );\n    }\n}\n\nfn benchmark_rational_convergents_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.convergents()\",\n        BenchmarkType::Algorithms,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"default\", &mut |x| no_out!(x.convergents().collect_vec())),\n            (\"naive\", &mut |x| no_out!(convergents_alt(x).collect_vec())),\n        ],\n    );\n}\n\nfn benchmark_rational_convergents_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.convergents()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.convergents()\", &mut |x| {\n                no_out!(x.convergents().collect_vec());\n            }),\n            (\"(&Rational).convergents()\", &mut |x| {\n                no_out!((&x).convergents().collect_vec());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/continued_fraction/from_continued_fraction.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::pair_1_vec_natural_sum_bits_bucketer;\nuse malachite_nz::test_util::generators::natural_vec_integer_pair_gen_var_1;\nuse malachite_q::Rational;\nuse malachite_q::test_util::conversion::continued_fraction::from_continued_fraction::*;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_continued_fraction);\n    register_demo!(runner, demo_rational_from_continued_fraction_ref);\n    register_bench!(\n        runner,\n        benchmark_rational_from_continued_fraction_algorithms\n    );\n    register_bench!(\n        runner,\n        benchmark_rational_from_continued_fraction_evaluation_strategy\n    );\n}\n\nfn demo_rational_from_continued_fraction(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, floor) in natural_vec_integer_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_continued_fraction({}, {:?}) = {}\",\n            floor.clone(),\n            xs.clone(),\n            Rational::from_continued_fraction(floor, xs.into_iter())\n        );\n    }\n}\n\nfn demo_rational_from_continued_fraction_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (xs, floor) in natural_vec_integer_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"from_continued_fraction_ref({}, {:?}) = {}\",\n            floor,\n            xs,\n            Rational::from_continued_fraction_ref(&floor, xs.iter())\n        );\n    }\n}\n\nfn benchmark_rational_from_continued_fraction_algorithms(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_continued_fraction(&Integer, &[Natural])\",\n        BenchmarkType::Algorithms,\n        natural_vec_integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\"default\", &mut |(xs, floor)| {\n                no_out!(Rational::from_continued_fraction(floor, xs.into_iter()));\n            }),\n            (\"alt\", &mut |(xs, floor)| {\n                no_out!(from_continued_fraction_alt(floor, xs));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_from_continued_fraction_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_continued_fraction(&Integer, &[Natural])\",\n        BenchmarkType::EvaluationStrategy,\n        natural_vec_integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_vec_natural_sum_bits_bucketer(),\n        &mut [\n            (\n                \"Rational::from_continued_fraction(Integer, Vec<Natural>)\",\n                &mut |(xs, floor)| {\n                    no_out!(Rational::from_continued_fraction(floor, xs.into_iter()));\n                },\n            ),\n            (\n                \"Rational::from_continued_fraction_ref(&Integer, &[Natural])\",\n                &mut |(xs, floor)| {\n                    no_out!(Rational::from_continued_fraction_ref(&floor, xs.iter()));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/continued_fraction/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    convergents::register(runner);\n    from_continued_fraction::register(runner);\n    to_continued_fraction::register(runner);\n}\n\nmod convergents;\nmod from_continued_fraction;\nmod to_continued_fraction;\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/continued_fraction/to_continued_fraction.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_q::conversion::continued_fraction::to_continued_fraction::RationalContinuedFraction;\nuse malachite_q::conversion::traits::ContinuedFraction;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_continued_fraction);\n    register_demo!(runner, demo_rational_continued_fraction_ref);\n    register_bench!(\n        runner,\n        benchmark_rational_continued_fraction_evaluation_strategy\n    );\n}\n\nfn helper(p: (Integer, RationalContinuedFraction)) -> (Integer, Vec<Natural>) {\n    (p.0, p.1.collect_vec())\n}\n\nfn demo_rational_continued_fraction(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"continued_fraction({}) = {:?}\",\n            x.clone(),\n            helper(x.continued_fraction())\n        );\n    }\n}\n\nfn demo_rational_continued_fraction_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"continued_fraction(&{}) = {:?}\",\n            x,\n            helper((&x).continued_fraction())\n        );\n    }\n}\n\nfn benchmark_rational_continued_fraction_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.continued_fraction()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.continued_fraction()\", &mut |n| {\n                no_out!(n.continued_fraction().1.collect_vec());\n            }),\n            (\"(&Rational).continued_fraction()\", &mut |n| {\n                no_out!((&n).continued_fraction().1.collect_vec());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/digits/from_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::bench::bucketers::rational_from_digits_bucketer;\nuse malachite_nz::test_util::generators::{large_type_gen_var_25, large_type_gen_var_26};\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_digits);\n    register_demo!(runner, demo_rational_from_digits_ref);\n    register_demo!(runner, demo_rational_from_digits_decimal);\n    register_bench!(runner, benchmark_rational_from_digits_evaluation_strategy);\n}\n\nfn demo_rational_from_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (base, before_point, after_point) in large_type_gen_var_25().get(gm, config).take(limit) {\n        println!(\n            \"from_digits({}, {:?}, {}) = {}\",\n            base,\n            before_point.clone(),\n            after_point.clone(),\n            Rational::from_digits(&base, before_point, after_point)\n        );\n    }\n}\n\nfn demo_rational_from_digits_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (base, before_point, after_point) in large_type_gen_var_25().get(gm, config).take(limit) {\n        println!(\n            \"from_digits_ref({}, {:?}, {:?}) = {}\",\n            base,\n            before_point,\n            after_point,\n            Rational::from_digits_ref(&base, &before_point, &after_point)\n        );\n    }\n}\n\nfn demo_rational_from_digits_decimal(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (before_point, after_point) in large_type_gen_var_26().get(gm, config).take(limit) {\n        println!(\n            \"from_digits(1, {:?}, {}) = {}\",\n            before_point.clone(),\n            after_point.clone(),\n            Rational::from_digits(&Natural::from(10u32), before_point, after_point)\n        );\n    }\n}\n\nfn benchmark_rational_from_digits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_digits(Natural, &[Natural], &RationalSequence<Natural>)\",\n        BenchmarkType::EvaluationStrategy,\n        large_type_gen_var_25().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_from_digits_bucketer(),\n        &mut [\n            (\n                \"Rational::from_digits(base, Vec<Natural>, RationalSequence<Natural>)\",\n                &mut |(base, before_point, after_point)| {\n                    no_out!(Rational::from_digits(&base, before_point, after_point));\n                },\n            ),\n            (\n                \"Rational::from_digits_ref(base, &[Natural], &RationalSequence<Natural>)\",\n                &mut |(base, before_point, after_point)| {\n                    no_out!(Rational::from_digits_ref(\n                        &base,\n                        &before_point,\n                        &after_point\n                    ));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/digits/from_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::rational_from_power_of_2_digits_bucketer;\nuse malachite_nz::test_util::generators::{large_type_gen_var_23, large_type_gen_var_24};\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_power_of_2_digits);\n    register_demo!(runner, demo_rational_from_power_of_2_digits_ref);\n    register_demo!(runner, demo_rational_from_power_of_2_digits_binary);\n    register_bench!(\n        runner,\n        benchmark_rational_from_power_of_2_digits_evaluation_strategy\n    );\n}\n\nfn demo_rational_from_power_of_2_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (log_base, before_point, after_point) in large_type_gen_var_23().get(gm, config).take(limit)\n    {\n        println!(\n            \"from_power_of_2_digits({}, {:?}, {}) = {}\",\n            log_base,\n            before_point.clone(),\n            after_point.clone(),\n            Rational::from_power_of_2_digits(log_base, before_point, after_point)\n        );\n    }\n}\n\nfn demo_rational_from_power_of_2_digits_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (log_base, before_point, after_point) in large_type_gen_var_23().get(gm, config).take(limit)\n    {\n        println!(\n            \"from_power_of_2_digits_ref({}, {:?}, {:?}) = {}\",\n            log_base,\n            before_point,\n            after_point,\n            Rational::from_power_of_2_digits_ref(log_base, &before_point, &after_point)\n        );\n    }\n}\n\nfn demo_rational_from_power_of_2_digits_binary(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (before_point, after_point) in large_type_gen_var_24().get(gm, config).take(limit) {\n        println!(\n            \"from_power_of_2_digits(1, {:?}, {}) = {}\",\n            before_point.clone(),\n            after_point.clone(),\n            Rational::from_power_of_2_digits(1, before_point, after_point)\n        );\n    }\n}\n\nfn benchmark_rational_from_power_of_2_digits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_power_of_2_digits(u64, &[Natural], &RationalSequence<Natural>)\",\n        BenchmarkType::EvaluationStrategy,\n        large_type_gen_var_23().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_from_power_of_2_digits_bucketer(),\n        &mut [\n            (\n                \"Rational::from_power_of_2_digits(u64, Vec<Natural>, RationalSequence<Natural>)\",\n                &mut |(log_base, before_point, after_point)| {\n                    no_out!(Rational::from_power_of_2_digits(\n                        log_base,\n                        before_point,\n                        after_point\n                    ));\n                },\n            ),\n            (\n                \"Rational::from_power_of_2_digits_ref(u64, &[Natural], &RationalSequence<Natural>)\",\n                &mut |(log_base, before_point, after_point)| {\n                    no_out!(Rational::from_power_of_2_digits_ref(\n                        log_base,\n                        &before_point,\n                        &after_point\n                    ));\n                },\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_digits::register(runner);\n    from_power_of_2_digits::register(runner);\n    to_digits::register(runner);\n    to_power_of_2_digits::register(runner);\n}\n\nmod from_digits;\nmod from_power_of_2_digits;\nmod to_digits;\nmod to_power_of_2_digits;\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/digits/to_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::prefix_to_string;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_7, rational_natural_pair_gen_var_1,\n    rational_natural_pair_gen_var_2,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_into_digits);\n    register_demo!(runner, demo_rational_to_digits);\n    register_demo!(runner, demo_rational_into_digits_decimal);\n    register_demo!(runner, demo_rational_digits);\n    register_demo!(runner, demo_rational_digits_decimal);\n    register_bench!(runner, benchmark_rational_to_digits_evaluation_strategy);\n    register_bench!(runner, benchmark_rational_digits);\n}\n\nfn to_string_helper(p: (Vec<Natural>, RationalSequence<Natural>)) -> String {\n    let (before, after) = p;\n    let mut s = \"(\".to_string();\n    s.push_str(&before.to_debug_string());\n    s.push_str(\", \");\n    s.push_str(&after.to_string());\n    s.push(')');\n    s\n}\n\nfn demo_rational_into_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in rational_natural_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).into_digits({}) = {}\",\n            n.clone(),\n            base,\n            to_string_helper(n.into_digits(&base))\n        );\n    }\n}\n\nfn demo_rational_to_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in rational_natural_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).to_digits({}) = {}\",\n            n,\n            base,\n            to_string_helper(n.to_digits(&base))\n        );\n    }\n}\n\nfn demo_rational_into_digits_decimal(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"({}).into_digits(10) = {}\",\n            n.clone(),\n            to_string_helper(n.into_digits(&Natural::from(10u32)))\n        );\n    }\n}\n\nfn demo_rational_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, base) in rational_natural_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (before_point, after_point) = n.digits(&base);\n        println!(\n            \"({}).digits({}) = ({:?}, {})\",\n            n,\n            base,\n            before_point,\n            prefix_to_string(after_point, 20)\n        );\n    }\n}\n\nfn demo_rational_digits_decimal(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        let (before_point, after_point) = n.digits(&Natural::from(10u32));\n        println!(\n            \"({}).digits(10) = ({:?}, {})\",\n            n,\n            before_point,\n            prefix_to_string(after_point, 20)\n        );\n    }\n}\n\nfn benchmark_rational_to_digits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_digits(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_natural_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.into_digits(&base)\", &mut |(n, base)| {\n                no_out!(n.into_digits(&base));\n            }),\n            (\"Rational.to_digits(&base)\", &mut |(n, base)| {\n                no_out!(n.to_digits(&base));\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_digits(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.digits(u64)\",\n        BenchmarkType::Single,\n        rational_natural_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\n            \"Rational.digits(&base).1.take(20).collect_vec()\",\n            &mut |(n, base)| no_out!(n.digits(&base).1.take(20).collect_vec()),\n        )],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/digits/to_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::prefix_to_string;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_q::test_util::bench::bucketers::pair_1_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_7, rational_unsigned_pair_gen_var_2,\n    rational_unsigned_pair_gen_var_3,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_into_power_of_2_digits);\n    register_demo!(runner, demo_rational_to_power_of_2_digits);\n    register_demo!(runner, demo_rational_into_power_of_2_digits_binary);\n    register_demo!(runner, demo_rational_power_of_2_digits);\n    register_demo!(runner, demo_rational_power_of_2_digits_binary);\n    register_bench!(\n        runner,\n        benchmark_rational_to_power_of_2_digits_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_rational_power_of_2_digits);\n}\n\nfn to_string_helper(p: (Vec<Natural>, RationalSequence<Natural>)) -> String {\n    let (before, after) = p;\n    let mut s = \"(\".to_string();\n    s.push_str(&before.to_debug_string());\n    s.push_str(\", \");\n    s.push_str(&after.to_string());\n    s.push(')');\n    s\n}\n\nfn demo_rational_into_power_of_2_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in rational_unsigned_pair_gen_var_2::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).into_power_of_2_digits({}) = {}\",\n            n.clone(),\n            log_base,\n            to_string_helper(n.into_power_of_2_digits(log_base))\n        );\n    }\n}\n\nfn demo_rational_to_power_of_2_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in rational_unsigned_pair_gen_var_2::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"({}).to_power_of_2_digits({}) = {}\",\n            n,\n            log_base,\n            to_string_helper(n.to_power_of_2_digits(log_base))\n        );\n    }\n}\n\nfn demo_rational_into_power_of_2_digits_binary(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen_var_7().get(gm, config).take(limit) {\n        println!(\n            \"({}).into_power_of_2_digits(1) = {}\",\n            n.clone(),\n            to_string_helper(n.into_power_of_2_digits(1))\n        );\n    }\n}\n\nfn demo_rational_power_of_2_digits(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, log_base) in rational_unsigned_pair_gen_var_3::<u64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (before_point, after_point) = n.power_of_2_digits(log_base);\n        println!(\n            \"({}).power_of_2_digits({}) = ({:?}, {})\",\n            n,\n            log_base,\n            before_point,\n            prefix_to_string(after_point, 20)\n        );\n    }\n}\n\nfn demo_rational_power_of_2_digits_binary(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        let (before_point, after_point) = n.power_of_2_digits(1);\n        println!(\n            \"({}).power_of_2_digits(1) = ({:?}, {})\",\n            n,\n            before_point,\n            prefix_to_string(after_point, 20)\n        );\n    }\n}\n\nfn benchmark_rational_to_power_of_2_digits_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_power_of_2_digits(u64)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_unsigned_pair_gen_var_2::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Rational.into_power_of_2_digits(log_base)\",\n                &mut |(n, log_base)| no_out!(n.into_power_of_2_digits(log_base)),\n            ),\n            (\n                \"Rational.to_power_of_2_digits(log_base)\",\n                &mut |(n, log_base)| no_out!(n.to_power_of_2_digits(log_base)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_rational_power_of_2_digits(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.power_of_2_digits(u64)\",\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen_var_3::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\n            \"Rational.power_of_2_digits(log_base).1.take(20).collect_vec()\",\n            &mut |(n, log_base)| no_out!(n.power_of_2_digits(log_base).1.take(20).collect_vec()),\n        )],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::bool_gen;\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_bool);\n}\n\nfn demo_rational_from_bool(gm: GenMode, config: &GenConfig, limit: usize) {\n    for b in bool_gen().get(gm, config).take(limit) {\n        println!(\"Rational::from({}) = {}\", b, Rational::from(b));\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/from_float_simplest.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen_var_8;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::conversion::from_primitive_float::RationalFromPrimitiveFloatError;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_rational_try_from_float_simplest);\n    register_primitive_float_benches!(runner, benchmark_rational_try_from_float_simplest);\n}\n\nfn demo_rational_try_from_float_simplest<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: TryFrom<T, Error = RationalFromPrimitiveFloatError>,\n{\n    for f in primitive_float_gen_var_8::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Rational::try_from_float_simplest({}) = {:?}\",\n            NiceFloat(f),\n            Rational::try_from_float_simplest(f)\n        );\n    }\n}\n\nfn benchmark_rational_try_from_float_simplest<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: TryFrom<T, Error = RationalFromPrimitiveFloatError>,\n{\n    run_benchmark(\n        &format!(\"Rational::try_from_float_simplest({})\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen_var_8::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| {\n            no_out!(Rational::try_from_float_simplest(f).ok());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::integer_bit_bucketer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_integer);\n    register_demo!(runner, demo_rational_from_integer_ref);\n    register_bench!(runner, benchmark_rational_from_integer_evaluation_strategy);\n}\n\nfn demo_rational_from_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        let n_clone = n.clone();\n        println!(\"Rational::from({}) = {}\", n_clone, Rational::from(n));\n    }\n}\n\nfn demo_rational_from_integer_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in integer_gen().get(gm, config).take(limit) {\n        println!(\"Rational::from(&{}) = {}\", n, Rational::from(&n));\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_integer_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from(Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &integer_bit_bucketer(\"n\"),\n        &mut [\n            (\"Rational::from(Integer)\", &mut |n| {\n                no_out!(Rational::from(n));\n            }),\n            (\"Rational::from(&Integer)\", &mut |n| {\n                no_out!(Rational::from(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::test_util::bench::bucketers::natural_bit_bucketer;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_natural);\n    register_demo!(runner, demo_rational_from_natural_ref);\n    register_bench!(runner, benchmark_rational_from_natural_evaluation_strategy);\n}\n\nfn demo_rational_from_natural(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        let n_clone = n.clone();\n        println!(\"Rational::from({}) = {}\", n_clone, Rational::from(n));\n    }\n}\n\nfn demo_rational_from_natural_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in natural_gen().get(gm, config).take(limit) {\n        println!(\"Rational::from(&{}) = {}\", n, Rational::from(&n));\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_natural_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from(Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &natural_bit_bucketer(\"n\"),\n        &mut [\n            (\"Rational::from(Natural)\", &mut |n| {\n                no_out!(Rational::from(n));\n            }),\n            (\"Rational::from(&Natural)\", &mut |n| {\n                no_out!(Rational::from(&n));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/from_numerator_and_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_max_bit_bucketer, triple_1_2_max_bit_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    signed_pair_gen, signed_pair_gen_var_6, unsigned_pair_gen_var_12, unsigned_pair_gen_var_27,\n    unsigned_unsigned_bool_triple_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::bench::bucketers::{\n    pair_integer_max_bit_bucketer, pair_natural_max_bit_bucketer,\n    triple_1_2_natural_max_bit_bucketer, triple_3_pair_integer_max_bit_bucketer,\n};\nuse malachite_nz::test_util::generators::{\n    integer_pair_gen_var_1, integer_pair_gen_var_1_nrm, natural_natural_bool_triple_gen_var_1,\n    natural_pair_gen_var_5,\n};\nuse malachite_q::Rational;\nuse num::BigRational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_from_naturals);\n    register_demo!(runner, demo_from_naturals_ref);\n    register_unsigned_demos!(runner, demo_from_unsigneds);\n    register_demo!(runner, demo_from_integers);\n    register_demo!(runner, demo_from_integers_ref);\n    register_signed_demos!(runner, demo_from_signeds);\n    register_demo!(runner, demo_from_sign_and_naturals);\n    register_demo!(runner, demo_from_sign_and_naturals_ref);\n    register_unsigned_demos!(runner, demo_from_sign_and_unsigneds);\n    register_demo!(runner, demo_const_from_unsigneds);\n    register_demo!(runner, demo_const_from_signeds);\n\n    register_bench!(runner, benchmark_from_naturals_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_from_unsigneds);\n    register_bench!(runner, benchmark_from_integers_evaluation_strategy);\n    register_bench!(runner, benchmark_from_integers_library_comparison);\n    register_signed_benches!(runner, benchmark_from_signeds);\n    register_bench!(runner, benchmark_from_sign_and_naturals_evaluation_strategy);\n    register_unsigned_benches!(runner, benchmark_from_sign_and_unsigneds);\n    register_bench!(runner, benchmark_const_from_unsigneds);\n    register_bench!(runner, benchmark_const_from_signeds);\n}\n\nfn demo_from_naturals(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let d_old = d.clone();\n        println!(\n            \"Rational::from_naturals({}, {}) = {}\",\n            n_old,\n            d_old,\n            Rational::from_naturals(n, d)\n        );\n    }\n}\n\nfn demo_from_naturals_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d) in natural_pair_gen_var_5().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_naturals_ref({}, {}) = {}\",\n            n,\n            d,\n            Rational::from_naturals_ref(&n, &d)\n        );\n    }\n}\n\nfn demo_from_unsigneds<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: From<T>,\n{\n    for (n, d) in unsigned_pair_gen_var_12::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Rational::from_unsigneds({}, {}) = {}\",\n            n,\n            d,\n            Rational::from_unsigneds(n, d)\n        );\n    }\n}\n\nfn demo_from_integers(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let d_old = d.clone();\n        println!(\n            \"Rational::from_integers({}, {}) = {}\",\n            n_old,\n            d_old,\n            Rational::from_integers(n, d)\n        );\n    }\n}\n\nfn demo_from_integers_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d) in integer_pair_gen_var_1().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_naturals_ref({}, {}) = {}\",\n            n,\n            d,\n            Rational::from_integers_ref(&n, &d)\n        );\n    }\n}\n\nfn demo_from_signeds<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Integer: From<T>,\n{\n    for (n, d) in signed_pair_gen_var_6::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_signeds({}, {}) = {}\",\n            n,\n            d,\n            Rational::from_signeds(n, d)\n        );\n    }\n}\n\nfn demo_from_sign_and_naturals(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d, sign) in natural_natural_bool_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        let d_old = d.clone();\n        println!(\n            \"Rational::from_sign_and_naturals({}, {}, {}) = {}\",\n            sign,\n            n_old,\n            d_old,\n            Rational::from_sign_and_naturals(sign, n, d)\n        );\n    }\n}\n\nfn demo_from_sign_and_naturals_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d, sign) in natural_natural_bool_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Rational::from_sign_and_naturals_ref({}, {}, {}) = {}\",\n            sign,\n            n,\n            d,\n            Rational::from_sign_and_naturals_ref(sign, &n, &d)\n        );\n    }\n}\n\nfn demo_from_sign_and_unsigneds<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Natural: From<T>,\n{\n    for (n, d, sign) in unsigned_unsigned_bool_triple_gen_var_2::<T, T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Rational::from_sign_and_unsigneds({}, {}, {}) = {}\",\n            sign,\n            n,\n            d,\n            Rational::from_sign_and_unsigneds(sign, n, d)\n        );\n    }\n}\n\nfn demo_const_from_unsigneds(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d) in unsigned_pair_gen_var_27().get(gm, config).take(limit) {\n        println!(\n            \"Rational::const_from_unsigneds({}, {}) = {}\",\n            n,\n            d,\n            Rational::const_from_unsigneds(n, d)\n        );\n    }\n}\n\nfn demo_const_from_signeds(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (n, d) in signed_pair_gen().get(gm, config).take(limit) {\n        println!(\n            \"Rational::const_from_signed({}, {}) = {}\",\n            n,\n            d,\n            Rational::const_from_signeds(n, d)\n        );\n    }\n}\n\nfn benchmark_from_naturals_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_naturals(Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_natural_max_bit_bucketer(\"n\", \"d\"),\n        &mut [\n            (\"from_naturals\", &mut |(n, d)| {\n                no_out!(Rational::from_naturals(n, d));\n            }),\n            (\"from_naturals_ref\", &mut |(n, d)| {\n                no_out!(Rational::from_naturals_ref(&n, &d));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_unsigneds<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: From<T>,\n{\n    run_benchmark(\n        &format!(\"Rational::from_unsigneds({}, {})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_12::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"n\", \"d\"),\n        &mut [(\"from_unsigneds\", &mut |(n, d)| {\n            no_out!(Rational::from_unsigneds(n, d));\n        })],\n    );\n}\n\nfn benchmark_from_integers_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_integers(Integer, Integer)\",\n        BenchmarkType::EvaluationStrategy,\n        integer_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_integer_max_bit_bucketer(\"n\", \"d\"),\n        &mut [\n            (\"from_integers\", &mut |(n, d)| {\n                no_out!(Rational::from_integers(n, d));\n            }),\n            (\"from_integers_ref\", &mut |(n, d)| {\n                no_out!(Rational::from_integers_ref(&n, &d));\n            }),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_from_integers_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_integers(Integer, Integer)\",\n        BenchmarkType::LibraryComparison,\n        integer_pair_gen_var_1_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_pair_integer_max_bit_bucketer(\"n\", \"d\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, (n, d))| {\n                no_out!(Rational::from_integers(n, d));\n            }),\n            (\"num\", &mut |((n, d), _, _)| no_out!(BigRational::new(n, d))),\n            (\"rug\", &mut |(_, (n, d), _)| {\n                no_out!(rug::Rational::from((n, d)));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_signeds<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Integer: From<T>,\n{\n    run_benchmark(\n        &format!(\"Rational::from_signeds({}, {})\", T::NAME, T::NAME),\n        BenchmarkType::Single,\n        signed_pair_gen_var_6::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"n\", \"d\"),\n        &mut [(\"from_unsigneds\", &mut |(n, d)| {\n            no_out!(Rational::from_signeds(n, d));\n        })],\n    );\n}\n\nfn benchmark_from_sign_and_naturals_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_sign_and_naturals(bool, Natural, Natural)\",\n        BenchmarkType::EvaluationStrategy,\n        natural_natural_bool_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_natural_max_bit_bucketer(\"n\", \"d\"),\n        &mut [\n            (\"from_sign_and_naturals\", &mut |(n, d, sign)| {\n                no_out!(Rational::from_sign_and_naturals(sign, n, d));\n            }),\n            (\"from_sign_and_naturals_ref\", &mut |(n, d, sign)| {\n                no_out!(Rational::from_sign_and_naturals_ref(sign, &n, &d));\n            }),\n        ],\n    );\n}\n\nfn benchmark_from_sign_and_unsigneds<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Natural: From<T>,\n{\n    run_benchmark(\n        &format!(\n            \"Rational::from_sign_and_unsigneds({}, {})\",\n            T::NAME,\n            T::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_unsigned_bool_triple_gen_var_2::<T, T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_2_max_bit_bucketer(\"n\", \"d\"),\n        &mut [(\"from_sign_and_unsigneds\", &mut |(n, d, sign)| {\n            no_out!(Rational::from_sign_and_unsigneds(sign, n, d));\n        })],\n    );\n}\n\nfn benchmark_const_from_unsigneds(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        &format!(\n            \"Rational::const_from_unsigneds({}, {})\",\n            Limb::NAME,\n            Limb::NAME\n        ),\n        BenchmarkType::Single,\n        unsigned_pair_gen_var_27().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"n\", \"d\"),\n        &mut [(\"const_from_unsigneds\", &mut |(n, d)| {\n            no_out!(Rational::const_from_unsigneds(n, d));\n        })],\n    );\n}\n\nfn benchmark_const_from_signeds(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        &format!(\n            \"Rational::const_from_signeds({}, {})\",\n            SignedLimb::NAME,\n            SignedLimb::NAME\n        ),\n        BenchmarkType::Single,\n        signed_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_max_bit_bucketer(\"n\", \"d\"),\n        &mut [(\"const_from_signeds\", &mut |(n, d)| {\n            no_out!(Rational::const_from_signeds(n, d));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::primitive_float_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::conversion::from_primitive_float::RationalFromPrimitiveFloatError;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_rational_convertible_from_primitive_float);\n    register_primitive_float_demos!(runner, demo_rational_try_from_primitive_float);\n\n    register_primitive_float_benches!(runner, benchmark_rational_try_from_primitive_float);\n    register_bench!(runner, benchmark_rational_try_from_f32_library_comparison);\n    register_bench!(runner, benchmark_rational_try_from_f64_library_comparison);\n    register_primitive_float_benches!(runner, benchmark_rational_convertible_from_primitive_float);\n}\n\nfn demo_rational_try_from_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: TryFrom<T, Error = RationalFromPrimitiveFloatError>,\n{\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        println!(\n            \"Rational::try_from({}) = {:?}\",\n            NiceFloat(f),\n            Rational::try_from(f)\n        );\n    }\n}\n\nfn demo_rational_convertible_from_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: ConvertibleFrom<T>,\n{\n    for f in primitive_float_gen::<T>().get(gm, config).take(limit) {\n        if Rational::convertible_from(f) {\n            println!(\"{} is convertible to a Rational\", NiceFloat(f));\n        } else {\n            println!(\"{} is not convertible to a Rational\", NiceFloat(f));\n        }\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_try_from_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Rational::try_from({})\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Rational::try_from(f)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_try_from_f32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::try_from(f32)\",\n        BenchmarkType::LibraryComparison,\n        primitive_float_gen::<f32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"Malachite\", &mut |f| no_out!(Rational::try_from(f))),\n            (\"rug\", &mut |f| no_out!(rug::Rational::from_f32(f))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_try_from_f64_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::try_from(f64)\",\n        BenchmarkType::LibraryComparison,\n        primitive_float_gen::<f64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [\n            (\"Malachite\", &mut |f| no_out!(Rational::try_from(f))),\n            (\"rug\", &mut |f| no_out!(rug::Rational::from_f64(f))),\n        ],\n    );\n}\n\nfn benchmark_rational_convertible_from_primitive_float<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: ConvertibleFrom<T>,\n{\n    run_benchmark(\n        &format!(\"Rational::convertible_from({})\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_gen::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &primitive_float_bucketer(\"f\"),\n        &mut [(\"Malachite\", &mut |f| no_out!(Rational::convertible_from(f)))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::bench::bucketers::{signed_bit_bucketer, unsigned_bit_bucketer};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_unsigned_demos!(runner, demo_rational_from_unsigned);\n    register_signed_demos!(runner, demo_rational_from_signed);\n    register_demo!(runner, demo_rational_const_from_unsigned);\n    register_demo!(runner, demo_rational_const_from_signed);\n\n    register_unsigned_benches!(runner, benchmark_rational_from_unsigned);\n    register_signed_benches!(runner, benchmark_rational_from_signed);\n    register_bench!(runner, benchmark_rational_from_u32_library_comparison);\n    register_bench!(runner, benchmark_rational_from_u64_library_comparison);\n    register_bench!(runner, benchmark_rational_from_i32_library_comparison);\n    register_bench!(runner, benchmark_rational_from_i64_library_comparison);\n    register_bench!(runner, benchmark_rational_const_from_unsigned);\n    register_bench!(runner, benchmark_rational_const_from_signed);\n}\n\nfn demo_rational_from_unsigned<T: PrimitiveUnsigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: From<T>,\n{\n    for u in unsigned_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Rational::from({}) = {}\", u, Rational::from(u));\n    }\n}\n\nfn demo_rational_from_signed<T: PrimitiveSigned>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: From<T>,\n{\n    for i in signed_gen::<T>().get(gm, config).take(limit) {\n        println!(\"Rational::from({}) = {}\", i, Rational::from(i));\n    }\n}\n\nfn demo_rational_const_from_unsigned(gm: GenMode, config: &GenConfig, limit: usize) {\n    for u in unsigned_gen().get(gm, config).take(limit) {\n        println!(\n            \"Rational::const_from_unsigned({}) = {}\",\n            u,\n            Rational::const_from_unsigned(u)\n        );\n    }\n}\n\nfn demo_rational_const_from_signed(gm: GenMode, config: &GenConfig, limit: usize) {\n    for i in signed_gen().get(gm, config).take(limit) {\n        println!(\n            \"Rational::const_from_signed({}) = {}\",\n            i,\n            Rational::const_from_signed(i)\n        );\n    }\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_unsigned<T: PrimitiveUnsigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: From<T>,\n{\n    run_benchmark(\n        &format!(\"Rational::from({})\", T::NAME),\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(Rational::from(u)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_signed<T: PrimitiveSigned>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: From<T>,\n{\n    run_benchmark(\n        &format!(\"Rational::from({})\", T::NAME),\n        BenchmarkType::Single,\n        signed_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| no_out!(Rational::from(u)))],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_u32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from(u32)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen::<u32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |u| no_out!(Rational::from(u))),\n            (\"rug\", &mut |u| no_out!(rug::Rational::from(u))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_u64_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from(u64)\",\n        BenchmarkType::LibraryComparison,\n        unsigned_gen::<u64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |u| no_out!(Rational::from(u))),\n            (\"rug\", &mut |u| no_out!(rug::Rational::from(u))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_i32_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from(i32)\",\n        BenchmarkType::LibraryComparison,\n        signed_gen::<i32>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |i| no_out!(Rational::from(i))),\n            (\"rug\", &mut |i| no_out!(rug::Rational::from(i))),\n        ],\n    );\n}\n\n#[allow(unused_must_use)]\nfn benchmark_rational_from_i64_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from(i64)\",\n        BenchmarkType::LibraryComparison,\n        signed_gen::<i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |i| no_out!(Rational::from(i))),\n            (\"rug\", &mut |i| no_out!(rug::Rational::from(i))),\n        ],\n    );\n}\n\nfn benchmark_rational_const_from_unsigned(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::const_from_unsigned(Limb)\",\n        BenchmarkType::Single,\n        unsigned_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &unsigned_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |u| {\n            no_out!(Rational::const_from_unsigned(u));\n        })],\n    );\n}\n\nfn benchmark_rational_const_from_signed(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::const_from_signed(Limb)\",\n        BenchmarkType::Single,\n        signed_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &signed_bit_bucketer(),\n        &mut [(\"Malachite\", &mut |i| {\n            no_out!(Rational::const_from_signed(i));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/integer_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::integer::Integer;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_rounding_mode_pair_gen_var_2};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_integer_try_from_rational);\n    register_demo!(runner, demo_integer_try_from_rational_ref);\n    register_demo!(runner, demo_integer_convertible_from_rational);\n    register_demo!(runner, demo_integer_rounding_from_rational);\n    register_demo!(runner, demo_integer_rounding_from_rational_ref);\n\n    register_bench!(\n        runner,\n        benchmark_integer_try_from_rational_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_integer_convertible_from_rational);\n    register_bench!(\n        runner,\n        benchmark_integer_rounding_from_rational_evaluation_strategy\n    );\n}\n\nfn demo_integer_try_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        let x_clone = x.clone();\n        println!(\n            \"Integer::try_from({}) = {:?}\",\n            x_clone,\n            Integer::try_from(x)\n        );\n    }\n}\n\nfn demo_integer_try_from_rational_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"Integer::try_from(&{}) = {:?}\", x, Integer::try_from(&x));\n    }\n}\n\nfn demo_integer_convertible_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Integer\",\n            x,\n            if Integer::convertible_from(&x) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn demo_integer_rounding_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in rational_rounding_mode_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_clone = x.clone();\n        println!(\n            \"Integer::rounding_from({}, {}) = {:?}\",\n            x_clone,\n            rm,\n            Integer::rounding_from(x, rm)\n        );\n    }\n}\n\nfn demo_integer_rounding_from_rational_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in rational_rounding_mode_pair_gen_var_2()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Integer::rounding_from(&{}, {}) = {:?}\",\n            x,\n            rm,\n            Integer::rounding_from(&x, rm)\n        );\n    }\n}\n\nfn benchmark_integer_try_from_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::try_from(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer::try_from(Rational)\", &mut |x| {\n                no_out!(Integer::try_from(x).ok());\n            }),\n            (\"Integer::try_from(&Rational)\", &mut |x| {\n                no_out!(Integer::try_from(&x).ok());\n            }),\n        ],\n    );\n}\n\nfn benchmark_integer_convertible_from_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::convertible_from(Rational)\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(Integer::convertible_from(&x)))],\n    );\n}\n\nfn benchmark_integer_rounding_from_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Integer::rounding_from(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_rounding_mode_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Integer::rounding_from(Rational)\", &mut |(x, rm)| {\n                no_out!(Integer::rounding_from(x, rm));\n            }),\n            (\"Integer::rounding_from(&Rational)\", &mut |(x, rm)| {\n                no_out!(Integer::rounding_from(&x, rm));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::rational_bit_bucketer;\nuse malachite_q::test_util::generators::rational_gen;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_is_integer);\n    register_bench!(runner, benchmark_rational_is_integer);\n}\n\nfn demo_rational_is_integer(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        if n.is_integer() {\n            println!(\"{n} is an integer\");\n        } else {\n            println!(\"{n} is not an integer\");\n        }\n    }\n}\n\nfn benchmark_rational_is_integer(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.is_integer()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(x.is_integer()))],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    clone::register(runner);\n    continued_fraction::register(runner);\n    digits::register(runner);\n    from_bool::register(runner);\n    from_float_simplest::register(runner);\n    from_integer::register(runner);\n    from_natural::register(runner);\n    from_numerator_and_denominator::register(runner);\n    from_primitive_float::register(runner);\n    from_primitive_int::register(runner);\n    integer_from_rational::register(runner);\n    is_integer::register(runner);\n    mutate_numerator_or_denominator::register(runner);\n    natural_from_rational::register(runner);\n    primitive_float_from_rational::register(runner);\n    primitive_int_from_rational::register(runner);\n    sci_mantissa_and_exponent::register(runner);\n    serde::register(runner);\n    string::register(runner);\n    to_numerator_or_denominator::register(runner);\n}\n\nmod clone;\nmod continued_fraction;\nmod digits;\nmod from_bool;\nmod from_float_simplest;\nmod from_integer;\nmod from_natural;\nmod from_numerator_and_denominator;\nmod from_primitive_float;\nmod from_primitive_int;\nmod integer_from_rational;\nmod is_integer;\nmod mutate_numerator_or_denominator;\nmod natural_from_rational;\nmod primitive_float_from_rational;\nmod primitive_int_from_rational;\nmod sci_mantissa_and_exponent;\nmod serde;\nmod string;\nmod to_numerator_or_denominator;\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/mutate_numerator_or_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    quadruple_1_rational_bit_bucketer, triple_1_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_rational_natural_natural_quadruple_gen_var_1, rational_rational_natural_triple_gen,\n    rational_rational_natural_triple_gen_var_1,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_mutate_numerator);\n    register_demo!(runner, demo_rational_mutate_denominator);\n    register_demo!(runner, demo_rational_mutate_numerator_and_denominator);\n\n    register_bench!(runner, benchmark_rational_mutate_numerator);\n    register_bench!(runner, benchmark_rational_mutate_denominator);\n    register_bench!(runner, benchmark_rational_mutate_numerator_and_denominator);\n}\n\nfn demo_rational_mutate_numerator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut q, out, new_numerator) in rational_rational_natural_triple_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_q = q.clone();\n        let old_out = out.clone();\n        let old_new_numerator = new_numerator.clone();\n        let actual_out = q.mutate_numerator(|x| {\n            *x = new_numerator;\n            out\n        });\n        println!(\n            \"q := {old_q}; \\\n            q.mutate_numerator(|x| {{ *x = {old_new_numerator}; {old_out} }}) = {actual_out}; \\\n            q = {q}\",\n        );\n    }\n}\n\nfn demo_rational_mutate_denominator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut q, out, new_denominator) in rational_rational_natural_triple_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let old_q = q.clone();\n        let old_out = out.clone();\n        let old_new_denominator = new_denominator.clone();\n        let actual_out = q.mutate_denominator(|x| {\n            *x = new_denominator;\n            out\n        });\n        println!(\n            \"q := {old_q}; \\\n            q.mutate_denominator(|x| {{ *x = {old_new_denominator}; {old_out} }}) = {actual_out}; \\\n            q = {q}\",\n        );\n    }\n}\n\nfn demo_rational_mutate_numerator_and_denominator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (mut q, out, new_numerator, new_denominator) in\n        rational_rational_natural_natural_quadruple_gen_var_1()\n            .get(gm, config)\n            .take(limit)\n    {\n        let old_q = q.clone();\n        let old_out = out.clone();\n        let old_new_numerator = new_numerator.clone();\n        let old_new_denominator = new_denominator.clone();\n        let actual_out = q.mutate_numerator_and_denominator(|x, y| {\n            *x = new_numerator;\n            *y = new_denominator;\n            out\n        });\n        println!(\n            \"q := {old_q}; \\\n            q.mutate_numerator_and_denominator(|x, y| {{ *x = {old_new_numerator}; \\\n            *y = {old_new_denominator}; {old_out} }}) = {actual_out}; \\\n            q = {q}\",\n        );\n    }\n}\n\nfn benchmark_rational_mutate_numerator(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.mutate_numerator(FnOnce(&mut Natural) -> T)\",\n        BenchmarkType::Single,\n        rational_rational_natural_triple_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, out, new_numerator)| {\n            no_out!(n.mutate_numerator(|x| {\n                *x = new_numerator;\n                out\n            }));\n        })],\n    );\n}\n\nfn benchmark_rational_mutate_denominator(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.mutate_denominator(FnOnce(&mut Natural) -> T)\",\n        BenchmarkType::Single,\n        rational_rational_natural_triple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(mut n, out, new_denominator)| {\n            no_out!(n.mutate_denominator(|x| {\n                *x = new_denominator;\n                out\n            }));\n        })],\n    );\n}\n\nfn benchmark_rational_mutate_numerator_and_denominator(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.mutate_numerator_and_denominator(FnOnce(&mut Natural, &mut Natural) -> T)\",\n        BenchmarkType::Single,\n        rational_rational_natural_natural_quadruple_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &quadruple_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(\n            mut n,\n            out,\n            new_numerator,\n            new_denominator,\n        )| {\n            no_out!(n.mutate_numerator_and_denominator(|x, y| {\n                *x = new_numerator;\n                *y = new_denominator;\n                out\n            }));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/natural_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_nz::natural::Natural;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_rounding_mode_pair_gen_var_1};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_natural_try_from_rational);\n    register_demo!(runner, demo_natural_try_from_rational_ref);\n    register_demo!(runner, demo_natural_convertible_from_rational);\n    register_demo!(runner, demo_natural_rounding_from_rational);\n    register_demo!(runner, demo_natural_rounding_from_rational_ref);\n\n    register_bench!(\n        runner,\n        benchmark_natural_try_from_rational_evaluation_strategy\n    );\n    register_bench!(runner, benchmark_natural_convertible_from_rational);\n    register_bench!(\n        runner,\n        benchmark_natural_rounding_from_rational_evaluation_strategy\n    );\n}\n\nfn demo_natural_try_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        let x_clone = x.clone();\n        println!(\n            \"Natural::try_from({}) = {:?}\",\n            x_clone,\n            Natural::try_from(x)\n        );\n    }\n}\n\nfn demo_natural_try_from_rational_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"Natural::try_from(&{}) = {:?}\", x, Natural::try_from(&x));\n    }\n}\n\nfn demo_natural_convertible_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a Natural\",\n            x,\n            if Natural::convertible_from(&x) {\n                \"\"\n            } else {\n                \"not \"\n            },\n        );\n    }\n}\n\nfn demo_natural_rounding_from_rational(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in rational_rounding_mode_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        let x_clone = x.clone();\n        println!(\n            \"Natural::rounding_from({}, {}) = {:?}\",\n            x_clone,\n            rm,\n            Natural::rounding_from(x, rm)\n        );\n    }\n}\n\nfn demo_natural_rounding_from_rational_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, rm) in rational_rounding_mode_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Natural::rounding_from(&{}, {}) = {:?}\",\n            x,\n            rm,\n            Natural::rounding_from(&x, rm)\n        );\n    }\n}\n\nfn benchmark_natural_try_from_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::try_from(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural::try_from(Rational)\", &mut |x| {\n                no_out!(Natural::try_from(x).ok());\n            }),\n            (\"Natural::try_from(&Rational)\", &mut |x| {\n                no_out!(Natural::try_from(&x).ok());\n            }),\n        ],\n    );\n}\n\nfn benchmark_natural_convertible_from_rational(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::convertible_from(Rational)\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(Natural::convertible_from(&x)))],\n    );\n}\n\nfn benchmark_natural_rounding_from_rational_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Natural::rounding_from(Rational)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_rounding_mode_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Natural::rounding_from(Rational)\", &mut |(x, rm)| {\n                no_out!(Natural::rounding_from(x, rm));\n            }),\n            (\"Natural::rounding_from(&Rational)\", &mut |(x, rm)| {\n                no_out!(Natural::rounding_from(&x, rm));\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/primitive_float_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, pair_2_rational_bit_bucketer, rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_rm, rational_gen_var_4, rational_rounding_mode_pair_gen_var_5,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_float_rounding_from_rational);\n    register_primitive_float_demos!(runner, demo_float_rounding_from_rational_ref);\n    register_primitive_float_demos!(runner, demo_float_try_from_rational);\n    register_primitive_float_demos!(runner, demo_float_try_from_rational_ref);\n    register_primitive_float_demos!(runner, demo_float_exact_from_rational);\n    register_primitive_float_demos!(runner, demo_float_exact_from_rational_ref);\n    register_primitive_float_demos!(runner, demo_float_convertible_from_rational);\n    register_primitive_float_demos!(runner, demo_float_convertible_from_rational_ref);\n\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_rounding_from_rational_evaluation_strategy\n    );\n    register_bench!(\n        runner,\n        benchmark_f32_rounding_from_down_rational_library_comparison\n    );\n    register_bench!(\n        runner,\n        benchmark_f64_rounding_from_down_rational_library_comparison\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_try_from_rational_evaluation_strategy\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_exact_from_rational_evaluation_strategy\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_float_convertible_from_rational_evaluation_strategy\n    );\n}\n\nfn demo_float_rounding_from_rational<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat + RoundingFrom<Rational>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: TryFrom<T>,\n{\n    for (n, rm) in rational_rounding_mode_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = T::rounding_from(n.clone(), rm);\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            n,\n            rm,\n            (NiceFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_rounding_from_rational_ref<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat + for<'a> RoundingFrom<&'a Rational>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: TryFrom<T>,\n{\n    for (n, rm) in rational_rounding_mode_pair_gen_var_5::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        let (f, o) = T::rounding_from(&n, rm);\n        println!(\n            \"{}::rounding_from(&{}, {}) = {:?}\",\n            T::NAME,\n            n,\n            rm,\n            (NiceFloat(f), o)\n        );\n    }\n}\n\nfn demo_float_try_from_rational<\n    T: TryFrom<Rational, Error = FloatConversionError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from({}) = {:?}\",\n            T::NAME,\n            n.clone(),\n            T::try_from(n).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_float_try_from_rational_ref<\n    T: for<'a> TryFrom<&'a Rational, Error = FloatConversionError> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"{}::try_from(&{}) = {:?}\",\n            T::NAME,\n            n,\n            T::try_from(&n).map(NiceFloat)\n        );\n    }\n}\n\nfn demo_float_exact_from_rational<T: ExactFrom<Rational> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: TryFrom<T>,\n{\n    for n in rational_gen_var_4::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::exact_from({}) = {}\",\n            T::NAME,\n            n.clone(),\n            NiceFloat(T::exact_from(n))\n        );\n    }\n}\n\nfn demo_float_exact_from_rational_ref<T: for<'a> ExactFrom<&'a Rational> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: TryFrom<T>,\n{\n    for n in rational_gen_var_4::<T>().get(gm, config).take(limit) {\n        println!(\n            \"{}::exact_from(&{}) = {}\",\n            T::NAME,\n            n,\n            NiceFloat(T::exact_from(&n))\n        );\n    }\n}\n\nfn demo_float_convertible_from_rational<T: ConvertibleFrom<Rational> + PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        if T::convertible_from(n) {\n            println!(\"{} is convertible to an {}\", n_old, T::NAME);\n        } else {\n            println!(\"{} is not convertible to an {}\", n_old, T::NAME);\n        }\n    }\n}\n\nfn demo_float_convertible_from_rational_ref<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        if T::convertible_from(&n) {\n            println!(\"{} is convertible to an {}\", n, T::NAME);\n        } else {\n            println!(\"{} is not convertible to an {}\", n, T::NAME);\n        }\n    }\n}\n\nfn benchmark_float_rounding_from_rational_evaluation_strategy<\n    T: for<'a> ConvertibleFrom<&'a Rational>\n        + PrimitiveFloat\n        + RoundingFrom<Rational>\n        + for<'a> RoundingFrom<&'a Rational>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}::rounding_from(Rational, RoundingMode)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_rounding_mode_pair_gen_var_5::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"{}::rounding_from(Rational, RoundingMode)\", T::NAME),\n                &mut |(n, rm)| no_out!(T::rounding_from(n, rm)),\n            ),\n            (\n                &format!(\"{}::rounding_from(&Rational, RoundingMode)\", T::NAME),\n                &mut |(n, rm)| no_out!(T::rounding_from(&n, rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_f32_rounding_from_down_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"f32::rounding_from(Rational, Down)\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| {\n                no_out!(f32::rounding_from(n, Down));\n            }),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_f32())),\n        ],\n    );\n}\n\nfn benchmark_f64_rounding_from_down_rational_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"f64::rounding_from(Rational, Down)\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_rm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_2_rational_bit_bucketer(\"n\"),\n        &mut [\n            (\"Malachite\", &mut |(_, n)| {\n                no_out!(f64::rounding_from(n, Down));\n            }),\n            (\"rug\", &mut |(n, _)| no_out!(n.to_f64())),\n        ],\n    );\n}\n\nfn benchmark_float_try_from_rational_evaluation_strategy<\n    T: TryFrom<Rational> + for<'a> TryFrom<&'a Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::try_from(Rational)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"{}::try_from(Rational)\", T::NAME), &mut |n| {\n                no_out!(T::try_from(n).ok());\n            }),\n            (&format!(\"{}::try_from(&Rational)\", T::NAME), &mut |n| {\n                no_out!(T::try_from(&n).ok());\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_exact_from_rational_evaluation_strategy<\n    T: ExactFrom<Rational> + for<'a> ExactFrom<&'a Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: TryFrom<T>,\n{\n    run_benchmark(\n        &format!(\"{}::exact_from(Rational)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_gen_var_4::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"n\"),\n        &mut [\n            (&format!(\"{}::exact_from(Rational)\", T::NAME), &mut |n| {\n                no_out!(T::exact_from(n));\n            }),\n            (&format!(\"{}::exact_from(&Rational)\", T::NAME), &mut |n| {\n                no_out!(T::exact_from(&n));\n            }),\n        ],\n    );\n}\n\nfn benchmark_float_convertible_from_rational_evaluation_strategy<\n    T: ConvertibleFrom<Rational> + for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::convertible_from(Rational)\", T::NAME),\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"n\"),\n        &mut [\n            (\n                &format!(\"{}::convertible_from(Rational)\", T::NAME),\n                &mut |n| no_out!(T::convertible_from(n)),\n            ),\n            (\n                &format!(\"{}::convertible_from(&Rational)\", T::NAME),\n                &mut |n| no_out!(T::convertible_from(&n)),\n            ),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/primitive_int_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_rounding_mode_pair_gen_var_3};\nuse std::fmt::Debug;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_int_demos!(runner, demo_primitive_int_try_from_rational);\n    register_primitive_int_demos!(runner, demo_primitive_int_convertible_from_rational);\n    register_primitive_int_demos!(runner, demo_primitive_int_rounding_from_rational);\n\n    register_primitive_int_benches!(runner, benchmark_primitive_int_try_from_rational);\n    register_primitive_int_benches!(runner, benchmark_primitive_int_convertible_from_rational);\n    register_primitive_int_benches!(runner, benchmark_primitive_int_rounding_from_rational);\n}\n\nfn demo_primitive_int_try_from_rational<T: for<'a> TryFrom<&'a Rational> + PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> <T as TryFrom<&'a Rational>>::Error: Debug,\n{\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"{}::try_from({}) = {:?}\", T::NAME, x, T::try_from(&x));\n    }\n}\n\nfn demo_primitive_int_convertible_from_rational<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"{} is {}convertible to a {}\",\n            x,\n            if T::convertible_from(&x) { \"\" } else { \"not \" },\n            T::NAME\n        );\n    }\n}\n\nfn demo_primitive_int_rounding_from_rational<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt + for<'a> RoundingFrom<&'a Rational>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: PartialOrd<T>,\n{\n    for (x, rm) in rational_rounding_mode_pair_gen_var_3::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"{}::rounding_from({}, {}) = {:?}\",\n            T::NAME,\n            x,\n            rm,\n            T::rounding_from(&x, rm)\n        );\n    }\n}\n\nfn benchmark_primitive_int_try_from_rational<T: for<'a> TryFrom<&'a Rational> + PrimitiveInt>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::try_from(Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(T::try_from(&x).ok()))],\n    );\n}\n\nfn benchmark_primitive_int_convertible_from_rational<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        &format!(\"{}::convertible_from(Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |x| no_out!(T::convertible_from(&x)))],\n    );\n}\n\nfn benchmark_primitive_int_rounding_from_rational<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt + for<'a> RoundingFrom<&'a Rational>,\n>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: PartialOrd<T>,\n{\n    run_benchmark(\n        &format!(\"{}::rounding_from(Rational)\", T::NAME),\n        BenchmarkType::Single,\n        rational_rounding_mode_pair_gen_var_3::<T>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(x, rm)| {\n            no_out!(T::rounding_from(&x, rm));\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/sci_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::SciMantissaAndExponent;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::test_util::bench::bucketers::pair_1_primitive_float_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    primitive_float_signed_pair_gen_var_1, primitive_float_signed_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_gen_var_1, rational_rounding_mode_pair_gen_var_4,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_primitive_float_demos!(runner, demo_rational_sci_mantissa_and_exponent);\n    register_primitive_float_demos!(runner, demo_rational_sci_mantissa_and_exponent_ref);\n    register_primitive_float_demos!(runner, demo_rational_sci_mantissa);\n    register_primitive_float_demos!(runner, demo_rational_sci_mantissa_ref);\n    register_primitive_float_demos!(runner, demo_rational_sci_exponent);\n    register_primitive_float_demos!(runner, demo_rational_sci_exponent_ref);\n    register_primitive_float_demos!(runner, demo_rational_sci_mantissa_and_exponent_round);\n    register_primitive_float_demos!(runner, demo_rational_sci_mantissa_and_exponent_round_ref);\n    register_primitive_float_demos!(runner, demo_rational_from_sci_mantissa_and_exponent);\n    register_primitive_float_demos!(\n        runner,\n        demo_rational_from_sci_mantissa_and_exponent_targeted\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_rational_sci_mantissa_and_exponent_evaluation_strategy\n    );\n    register_primitive_float_benches!(\n        runner,\n        benchmark_rational_sci_mantissa_and_exponent_round_evaluation_strategy\n    );\n    register_primitive_float_benches!(runner, benchmark_rational_from_sci_mantissa_and_exponent);\n}\n\nfn demo_rational_sci_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    Rational: SciMantissaAndExponent<T, i64>,\n{\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        let (mantissa, exponent) = n.sci_mantissa_and_exponent();\n        println!(\n            \"sci_mantissa_and_exponent({}) = {:?}\",\n            n_old,\n            (NiceFloat(mantissa), exponent)\n        );\n    }\n}\n\nfn demo_rational_sci_mantissa_and_exponent_ref<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        let (mantissa, exponent) = (&n).sci_mantissa_and_exponent();\n        println!(\n            \"sci_mantissa_and_exponent(&{}) = {:?}\",\n            n,\n            (NiceFloat(mantissa), exponent)\n        );\n    }\n}\n\nfn demo_rational_sci_mantissa<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: SciMantissaAndExponent<T, i64>,\n{\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\"sci_mantissa({}) = {}\", n_old, NiceFloat(n.sci_mantissa()));\n    }\n}\n\nfn demo_rational_sci_mantissa_ref<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        println!(\"sci_mantissa({}) = {}\", n, NiceFloat((&n).sci_mantissa()));\n    }\n}\n\nfn demo_rational_sci_exponent<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    Rational: SciMantissaAndExponent<T, i64>,\n{\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        let n_old = n.clone();\n        println!(\"sci_exponent({}) = {}\", n_old, n.sci_exponent());\n    }\n}\n\nfn demo_rational_sci_exponent_ref<T: PrimitiveFloat>(gm: GenMode, config: &GenConfig, limit: usize)\nwhere\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    for n in rational_gen_var_1().get(gm, config).take(limit) {\n        println!(\"sci_exponent({}) = {}\", n, (&n).sci_exponent());\n    }\n}\n\nfn demo_rational_sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in rational_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        let n_old = n.clone();\n        println!(\n            \"sci_mantissa_and_exponent_round({}, {}) = {:?}\",\n            n_old,\n            rm,\n            n.sci_mantissa_and_exponent_round::<T>(rm)\n                .map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    }\n}\n\nfn demo_rational_sci_mantissa_and_exponent_round_ref<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (n, rm) in rational_rounding_mode_pair_gen_var_4()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"sci_mantissa_and_exponent_round({}, {}) = {:?}\",\n            n,\n            rm,\n            n.sci_mantissa_and_exponent_round_ref::<T>(rm)\n                .map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    }\n}\n\nfn demo_rational_from_sci_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    for (m, e) in primitive_float_signed_pair_gen_var_1::<T, i64>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Rational::from_sci_mantissa_and_exponent({}, {}) = {:?}\",\n            NiceFloat(m),\n            e,\n            <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e)\n        );\n    }\n}\n\nfn demo_rational_from_sci_mantissa_and_exponent_targeted<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) where\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    for (m, e) in primitive_float_signed_pair_gen_var_2::<T>()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"Rational::from_sci_mantissa_and_exponent({}, {}) = {:?}\",\n            NiceFloat(m),\n            e,\n            <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e)\n        );\n    }\n}\n\nfn benchmark_rational_sci_mantissa_and_exponent_evaluation_strategy<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    Rational: SciMantissaAndExponent<T, i64>,\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    run_benchmark(\n        \"Rational.sci_mantissa_and_exponent()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Rational.sci_mantissa_and_exponent()\", &mut |n| {\n                no_out!(n.sci_mantissa_and_exponent());\n            }),\n            (\"(&Rational).sci_mantissa_and_exponent()\", &mut |n| {\n                no_out!((&n).sci_mantissa_and_exponent());\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_sci_mantissa_and_exponent_round_evaluation_strategy<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.sci_mantissa_and_exponent_round(RoundingMode)\",\n        BenchmarkType::EvaluationStrategy,\n        rational_rounding_mode_pair_gen_var_4().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\n                \"Rational.sci_mantissa_and_exponent_round(RoundingMode)\",\n                &mut |(n, rm)| no_out!(n.sci_mantissa_and_exponent_round::<T>(rm)),\n            ),\n            (\n                \"Rational.sci_mantissa_and_exponent_round_ref(RoundingMode)\",\n                &mut |(n, rm)| no_out!(n.sci_mantissa_and_exponent_round_ref::<T>(rm)),\n            ),\n        ],\n    );\n}\n\nfn benchmark_rational_from_sci_mantissa_and_exponent<T: PrimitiveFloat>(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) where\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    run_benchmark(\n        &format!(\"Rational::from_sci_mantissa_and_exponent({}, u64)\", T::NAME),\n        BenchmarkType::Single,\n        primitive_float_signed_pair_gen_var_1::<T, i64>().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_primitive_float_bucketer(\"mantissa\"),\n        &mut [(\"Malachite\", &mut |(m, e)| {\n            no_out!(\n                <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n                    m, e\n                )\n            );\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::string_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::bench::bucketers::{\n    rational_deserialize_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_nrm, string_gen_var_11, string_triple_gen_var_3,\n};\nuse num::BigRational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_serialize_json);\n    register_demo!(runner, demo_rational_deserialize_json);\n    register_demo!(runner, demo_rational_deserialize_json_targeted);\n\n    register_bench!(runner, benchmark_rational_serialize_json_library_comparison);\n    register_bench!(runner, benchmark_rational_deserialize_json);\n    register_bench!(\n        runner,\n        benchmark_rational_deserialize_json_library_comparison\n    );\n}\n\nfn demo_rational_serialize_json(gm: GenMode, config: &GenConfig, limit: usize) {\n    for n in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"serde_json::to_string({}) = {}\",\n            n,\n            serde_json::to_string(&n).unwrap()\n        );\n    }\n}\n\nfn demo_rational_deserialize_json(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        let n: Result<Rational, _> = serde_json::from_str(&s);\n        println!(\"serde_json::from_str({s}) = {n:?}\");\n    }\n}\n\nfn demo_rational_deserialize_json_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_11().get(gm, config).take(limit) {\n        let n: Rational = serde_json::from_str(&s).unwrap();\n        println!(\"serde_json::from_str({s}) = {n}\");\n    }\n}\n\nfn benchmark_rational_serialize_json_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::to_string(&Rational)\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n            (\"num\", &mut |(x, _, _)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n            (\"rug\", &mut |(_, x, _)| {\n                no_out!(serde_json::to_string(&x).unwrap());\n            }),\n        ],\n    );\n}\n\nfn benchmark_rational_deserialize_json(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::from_str(&str)\",\n        BenchmarkType::Single,\n        string_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| {\n            let _n: Rational = serde_json::from_str(&s).unwrap();\n        })],\n    );\n}\n\nfn benchmark_rational_deserialize_json_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"serde_json::from_str(&str)\",\n        BenchmarkType::LibraryComparison,\n        string_triple_gen_var_3().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_deserialize_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |(_, _, s)| {\n                let _n: Rational = serde_json::from_str(&s).unwrap();\n            }),\n            (\"num\", &mut |(s, _, _)| {\n                let _n: BigRational = serde_json::from_str(&s).unwrap();\n            }),\n            (\"rug\", &mut |(_, s, _)| {\n                let _n: rug::Rational = serde_json::from_str(&s).unwrap();\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::num::conversion::traits::FromSciString;\nuse malachite_base::test_util::bench::bucketers::{\n    pair_1_string_len_bucketer, string_len_bucketer,\n};\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::{\n    string_gen_var_14, string_gen_var_15, string_unsigned_pair_gen_var_1,\n    string_unsigned_pair_gen_var_2,\n};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_sci_string);\n    register_demo!(runner, demo_rational_from_sci_string_targeted);\n    register_demo!(runner, demo_rational_from_sci_string_with_options);\n    register_demo!(runner, demo_rational_from_sci_string_with_options_targeted);\n    register_demo!(runner, demo_rational_from_sci_string_simplest);\n    register_demo!(runner, demo_rational_from_sci_string_simplest_targeted);\n    register_demo!(runner, demo_rational_from_sci_string_simplest_with_options);\n    register_demo!(\n        runner,\n        demo_rational_from_sci_string_simplest_with_options_targeted\n    );\n\n    register_bench!(runner, benchmark_rational_from_sci_string);\n    register_bench!(runner, benchmark_rational_from_sci_string_with_options);\n    register_bench!(runner, benchmark_rational_from_sci_string_simplest);\n    register_bench!(\n        runner,\n        benchmark_rational_from_sci_string_simplest_with_options\n    );\n}\n\nfn demo_rational_from_sci_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_14().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_sci_string({}) = {:?}\",\n            s,\n            Rational::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_rational_from_sci_string_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_15().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_sci_string({}) = {:?}\",\n            s,\n            Rational::from_sci_string(&s)\n        );\n    }\n}\n\nfn demo_rational_from_sci_string_with_options(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (s, base) in string_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let mut options = FromSciStringOptions::default();\n        options.set_base(base);\n        println!(\n            \"Rational::from_sci_string({}, {}) = {:?}\",\n            s,\n            base,\n            Rational::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn demo_rational_from_sci_string_with_options_targeted(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (s, base) in string_unsigned_pair_gen_var_2().get(gm, config).take(limit) {\n        let mut options = FromSciStringOptions::default();\n        options.set_base(base);\n        println!(\n            \"Rational::from_sci_string({}, {}) = {:?}\",\n            s,\n            base,\n            Rational::from_sci_string_with_options(&s, options)\n        );\n    }\n}\n\nfn demo_rational_from_sci_string_simplest(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_14().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_sci_string_simplest({}) = {:?}\",\n            s,\n            Rational::from_sci_string_simplest(&s)\n        );\n    }\n}\n\nfn demo_rational_from_sci_string_simplest_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_15().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_sci_string_simplest({}) = {:?}\",\n            s,\n            Rational::from_sci_string_simplest(&s)\n        );\n    }\n}\n\nfn demo_rational_from_sci_string_simplest_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (s, base) in string_unsigned_pair_gen_var_1().get(gm, config).take(limit) {\n        let mut options = FromSciStringOptions::default();\n        options.set_base(base);\n        println!(\n            \"Rational::from_sci_string_simplest({}, {}) = {:?}\",\n            s,\n            base,\n            Rational::from_sci_string_simplest_with_options(&s, options)\n        );\n    }\n}\n\nfn demo_rational_from_sci_string_simplest_with_options_targeted(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n) {\n    for (s, base) in string_unsigned_pair_gen_var_2().get(gm, config).take(limit) {\n        let mut options = FromSciStringOptions::default();\n        options.set_base(base);\n        println!(\n            \"Rational::from_sci_string_simplest({}, {}) = {:?}\",\n            s,\n            base,\n            Rational::from_sci_string_simplest_with_options(&s, options)\n        );\n    }\n}\n\nfn benchmark_rational_from_sci_string(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_sci_string(&str)\",\n        BenchmarkType::Single,\n        string_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| no_out!(Rational::from_sci_string(&s)))],\n    );\n}\n\nfn benchmark_rational_from_sci_string_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_sci_string_with_options(&str, FromSciStrOptions)\",\n        BenchmarkType::Single,\n        string_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_string_len_bucketer(\"s\"),\n        &mut [(\"Malachite\", &mut |(s, base)| {\n            no_out!({\n                let mut options = FromSciStringOptions::default();\n                options.set_base(base);\n                Rational::from_sci_string_with_options(&s, options)\n            });\n        })],\n    );\n}\n\nfn benchmark_rational_from_sci_string_simplest(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_sci_string_simplest(&str)\",\n        BenchmarkType::Single,\n        string_gen_var_15().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [(\"Malachite\", &mut |s| {\n            no_out!(Rational::from_sci_string_simplest(&s));\n        })],\n    );\n}\n\nfn benchmark_rational_from_sci_string_simplest_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_sci_string_simplest_with_options(&str, FromSciStrOptions)\",\n        BenchmarkType::Single,\n        string_unsigned_pair_gen_var_2().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_string_len_bucketer(\"s\"),\n        &mut [(\"Malachite\", &mut |(s, base)| {\n            no_out!({\n                let mut options = FromSciStringOptions::default();\n                options.set_base(base);\n                Rational::from_sci_string_simplest_with_options(&s, options)\n            });\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::bucketers::string_len_bucketer;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::generators::string_gen;\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::string_gen_var_12;\nuse num::BigRational;\nuse std::str::FromStr;\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_from_str);\n    register_demo!(runner, demo_rational_from_str_targeted);\n    register_bench!(runner, benchmark_rational_from_str_library_comparison);\n}\n\nfn demo_rational_from_str(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen().get(gm, config).take(limit) {\n        println!(\"Rational::from_str({}) = {:?}\", s, Rational::from_str(&s));\n    }\n}\n\nfn demo_rational_from_str_targeted(gm: GenMode, config: &GenConfig, limit: usize) {\n    for s in string_gen_var_12().get(gm, config).take(limit) {\n        println!(\n            \"Rational::from_str({}) = {}\",\n            s,\n            Rational::from_str(&s).unwrap()\n        );\n    }\n}\n\nfn benchmark_rational_from_str_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational::from_str(&str)\",\n        BenchmarkType::LibraryComparison,\n        string_gen_var_12().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &string_len_bucketer(),\n        &mut [\n            (\"Malachite\", &mut |s| {\n                no_out!(Rational::from_str(&s).unwrap());\n            }),\n            (\"num\", &mut |s| no_out!(BigRational::from_str(&s).unwrap())),\n            (\"rug\", &mut |s| {\n                no_out!(rug::Rational::from_str(&s).unwrap());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    from_sci_string::register(runner);\n    from_string::register(runner);\n    to_sci::register(runner);\n    to_string::register(runner);\n}\n\nmod from_sci_string;\nmod from_string;\nmod to_sci;\nmod to_string;\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::ToSci;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    pair_1_rational_bit_bucketer, rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_to_sci_options_pair_gen, rational_to_sci_options_pair_gen_var_1,\n    rational_unsigned_pair_gen_var_5,\n};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_length_after_point_in_small_base);\n    register_demo!(runner, demo_rational_to_sci);\n    register_demo!(runner, demo_rational_fmt_sci_valid);\n    register_demo!(runner, demo_rational_to_sci_with_options);\n\n    register_bench!(runner, benchmark_length_after_point_in_small_base);\n    register_bench!(runner, benchmark_rational_to_sci);\n    register_bench!(runner, benchmark_rational_fmt_sci_valid);\n    register_bench!(runner, benchmark_rational_to_sci_with_options);\n}\n\nfn demo_length_after_point_in_small_base(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (q, base) in rational_unsigned_pair_gen_var_5()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"length_after_point_in_small_base({}, {}) = {:?}\",\n            q,\n            base,\n            q.length_after_point_in_small_base(base)\n        );\n    }\n}\n\nfn demo_rational_to_sci(gm: GenMode, config: &GenConfig, limit: usize) {\n    for q in rational_gen().get(gm, config).take(limit) {\n        println!(\"{}.to_sci() = {}\", q, q.to_sci());\n    }\n}\n\nfn demo_rational_fmt_sci_valid(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, options) in rational_to_sci_options_pair_gen()\n        .get(gm, config)\n        .take(limit)\n    {\n        if x.fmt_sci_valid(options) {\n            println!(\"{x} can be converted to sci using {options:?}\");\n        } else {\n            println!(\"{x} cannot be converted to sci using {options:?}\");\n        }\n    }\n}\n\nfn demo_rational_to_sci_with_options(gm: GenMode, config: &GenConfig, limit: usize) {\n    for (x, options) in rational_to_sci_options_pair_gen_var_1()\n        .get(gm, config)\n        .take(limit)\n    {\n        println!(\n            \"to_sci_with_options({}, {:?}) = {}\",\n            x,\n            options,\n            x.to_sci_with_options(options)\n        );\n    }\n}\n\nfn benchmark_length_after_point_in_small_base(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.length_after_point_in_small_base(u8)\",\n        BenchmarkType::Single,\n        rational_unsigned_pair_gen_var_5().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"x\"),\n        &mut [(\"Malachite\", &mut |(q, base)| {\n            no_out!(q.length_after_point_in_small_base(base));\n        })],\n    );\n}\n\nfn benchmark_rational_to_sci(gm: GenMode, config: &GenConfig, limit: usize, file_name: &str) {\n    run_benchmark(\n        \"Rational.to_sci()\",\n        BenchmarkType::Single,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"q\"),\n        &mut [(\"Malachite\", &mut |q| no_out!(q.to_sci().to_string()))],\n    );\n}\n\nfn benchmark_rational_fmt_sci_valid(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.fmt_sci_valid(ToSciOptions)\",\n        BenchmarkType::Single,\n        rational_to_sci_options_pair_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.fmt_sci_valid(options));\n        })],\n    );\n}\n\nfn benchmark_rational_to_sci_with_options(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_sci_with_options(ToSciOptions)\",\n        BenchmarkType::Single,\n        rational_to_sci_options_pair_gen_var_1().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &pair_1_rational_bit_bucketer(\"n\"),\n        &mut [(\"Malachite\", &mut |(x, options)| {\n            no_out!(x.to_sci_with_options(options).to_string());\n        })],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::triple_3_rational_bit_bucketer;\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_rational_to_string);\n    register_demo!(runner, demo_rational_to_debug_string);\n\n    register_bench!(runner, benchmark_rational_to_string_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_rational_to_debug_string_library_comparison\n    );\n}\n\nfn demo_rational_to_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for q in rational_gen().get(gm, config).take(limit) {\n        println!(\"{q}\");\n    }\n}\n\nfn demo_rational_to_debug_string(gm: GenMode, config: &GenConfig, limit: usize) {\n    for q in rational_gen().get(gm, config).take(limit) {\n        println!(\"{q:?}\");\n    }\n}\n\nfn benchmark_rational_to_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_string()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_string())),\n        ],\n    );\n}\n\nfn benchmark_rational_to_debug_string_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_debug_string()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_debug_string())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.to_debug_string())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.to_debug_string())),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/conversion/to_numerator_or_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::bench::{BenchmarkType, run_benchmark};\nuse malachite_base::test_util::generators::common::{GenConfig, GenMode};\nuse malachite_base::test_util::runner::Runner;\nuse malachite_q::test_util::bench::bucketers::{\n    rational_bit_bucketer, triple_3_rational_bit_bucketer,\n};\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_nrm};\n\npub(crate) fn register(runner: &mut Runner) {\n    register_demo!(runner, demo_to_numerator);\n    register_demo!(runner, demo_into_numerator);\n    register_demo!(runner, demo_numerator_ref);\n    register_demo!(runner, demo_to_denominator);\n    register_demo!(runner, demo_into_denominator);\n    register_demo!(runner, demo_denominator_ref);\n    register_demo!(runner, demo_to_numerator_and_denominator);\n    register_demo!(runner, demo_into_numerator_and_denominator);\n    register_demo!(runner, demo_numerator_and_denominator_ref);\n\n    register_bench!(runner, benchmark_to_numerator_evaluation_strategy);\n    register_bench!(runner, benchmark_to_numerator_library_comparison);\n    register_bench!(runner, benchmark_to_denominator_evaluation_strategy);\n    register_bench!(runner, benchmark_to_denominator_library_comparison);\n    register_bench!(\n        runner,\n        benchmark_to_numerator_and_denominator_evaluation_strategy\n    );\n}\n\nfn demo_to_numerator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"to_numerator({}) = {}\", x, x.to_numerator());\n    }\n}\n\nfn demo_into_numerator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        println!(\"into_numerator({}) = {}\", old_x, x.into_numerator());\n    }\n}\n\nfn demo_numerator_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"numerator_ref({}) = {}\", x, x.numerator_ref());\n    }\n}\n\nfn demo_to_denominator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"to_denominator({}) = {}\", x, x.to_denominator());\n    }\n}\n\nfn demo_into_denominator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        println!(\"into_denominator({}) = {}\", old_x, x.into_denominator());\n    }\n}\n\nfn demo_denominator_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\"denominator_ref({}) = {}\", x, x.denominator_ref());\n    }\n}\n\nfn demo_to_numerator_and_denominator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"to_numerator_and_denominator({}) = {:?}\",\n            x,\n            x.to_numerator_and_denominator()\n        );\n    }\n}\n\nfn demo_into_numerator_and_denominator(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        let old_x = x.clone();\n        println!(\n            \"into_numerator_and_denominator({}) = {:?}\",\n            old_x,\n            x.into_numerator_and_denominator()\n        );\n    }\n}\n\nfn demo_numerator_and_denominator_ref(gm: GenMode, config: &GenConfig, limit: usize) {\n    for x in rational_gen().get(gm, config).take(limit) {\n        println!(\n            \"numerator_and_denominator_ref({}) = {:?}\",\n            x,\n            x.numerator_and_denominator_ref()\n        );\n    }\n}\n\nfn benchmark_to_numerator_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_numerator()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_numerator\", &mut |x| no_out!(x.to_numerator())),\n            (\"into_numerator\", &mut |x| no_out!(x.into_numerator())),\n            (\"numerator_ref\", &mut |x| no_out!(x.numerator_ref())),\n        ],\n    );\n}\n\nfn benchmark_to_numerator_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_numerator()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_numerator())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.numer())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.numer())),\n        ],\n    );\n}\n\nfn benchmark_to_denominator_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_denominator()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_denominator\", &mut |x| no_out!(x.to_denominator())),\n            (\"into_denominator\", &mut |x| no_out!(x.into_denominator())),\n            (\"denominator_ref\", &mut |x| no_out!(x.denominator_ref())),\n        ],\n    );\n}\n\nfn benchmark_to_denominator_library_comparison(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_denominator()\",\n        BenchmarkType::LibraryComparison,\n        rational_gen_nrm().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &triple_3_rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"Malachite\", &mut |(_, _, x)| no_out!(x.to_denominator())),\n            (\"num\", &mut |(x, _, _)| no_out!(x.denom())),\n            (\"rug\", &mut |(_, x, _)| no_out!(x.denom())),\n        ],\n    );\n}\n\nfn benchmark_to_numerator_and_denominator_evaluation_strategy(\n    gm: GenMode,\n    config: &GenConfig,\n    limit: usize,\n    file_name: &str,\n) {\n    run_benchmark(\n        \"Rational.to_numerator_and_denominator()\",\n        BenchmarkType::EvaluationStrategy,\n        rational_gen().get(gm, config),\n        gm.name(),\n        limit,\n        file_name,\n        &rational_bit_bucketer(\"x\"),\n        &mut [\n            (\"to_numerator_and_denominator\", &mut |x| {\n                no_out!(x.to_numerator_and_denominator());\n            }),\n            (\"into_numerator_and_denominator\", &mut |x| {\n                no_out!(x.into_numerator_and_denominator());\n            }),\n            (\"numerator_and_denominator_ref\", &mut |x| {\n                no_out!(x.numerator_and_denominator_ref());\n            }),\n        ],\n    );\n}\n"
  },
  {
    "path": "malachite-q/src/bin_util/demo_and_bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::runner::Runner;\n\npub(crate) fn register(runner: &mut Runner) {\n    arithmetic::register(runner);\n    basic::register(runner);\n    comparison::register(runner);\n    conversion::register(runner);\n}\n\nmod arithmetic;\nmod basic;\nmod comparison;\nmod conversion;\n"
  },
  {
    "path": "malachite-q/src/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\n\nimpl PartialOrd for Rational {\n    /// Compares two [`Rational`]s.\n    ///\n    /// See the documentation for the [`Ord`] implementation.\n    #[inline]\n    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp(other))\n    }\n}\n\nimpl Ord for Rational {\n    /// Compares two [`Rational`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert!(Rational::from_str(\"2/3\").unwrap() > Rational::ONE_HALF);\n    /// assert!(Rational::from_str(\"-2/3\").unwrap() < Rational::ONE_HALF);\n    /// ```\n    fn cmp(&self, other: &Self) -> Ordering {\n        if core::ptr::eq(self, other) {\n            return Equal;\n        }\n        // First check signs\n        let self_sign = self.sign();\n        let other_sign = other.sign();\n        let sign_cmp = self_sign.cmp(&other_sign);\n        if sign_cmp != Equal || self_sign == Equal {\n            return sign_cmp;\n        }\n        // Then check if one is < 1 and the other is > 1\n        let self_cmp_one = self.numerator.cmp(&self.denominator);\n        let other_cmp_one = other.numerator.cmp(&other.denominator);\n        let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n        if one_cmp != Equal {\n            return if self.sign {\n                one_cmp\n            } else {\n                one_cmp.reverse()\n            };\n        }\n        // Then compare numerators and denominators\n        let n_cmp = self.numerator.cmp(&other.numerator);\n        let d_cmp = self.denominator.cmp(&other.denominator);\n        if n_cmp == Equal && d_cmp == Equal {\n            return Equal;\n        }\n        let nd_cmp = n_cmp.cmp(&d_cmp);\n        if nd_cmp != Equal {\n            return if self.sign { nd_cmp } else { nd_cmp.reverse() };\n        }\n        // Then compare floor ∘ log_2 ∘ abs\n        let log_cmp = self\n            .floor_log_base_2_abs()\n            .cmp(&other.floor_log_base_2_abs());\n        if log_cmp != Equal {\n            return if self.sign {\n                log_cmp\n            } else {\n                log_cmp.reverse()\n            };\n        }\n        // Finally, cross-multiply.\n        let prod_cmp =\n            (&self.numerator * &other.denominator).cmp(&(&self.denominator * &other.numerator));\n        if self.sign {\n            prod_cmp\n        } else {\n            prod_cmp.reverse()\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\n\nimpl PartialOrdAbs for Rational {\n    /// Compares the absolute values of two [`Rational`]s.\n    ///\n    /// See the documentation for the [`OrdAbs`] implementation.\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Self) -> Option<Ordering> {\n        Some(self.cmp_abs(other))\n    }\n}\n\nimpl OrdAbs for Rational {\n    /// Compares the absolute values of two [`Rational`]s.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::OneHalf;\n    /// use malachite_base::num::comparison::traits::OrdAbs;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_str(\"2/3\")\n    ///         .unwrap()\n    ///         .cmp_abs(&Rational::ONE_HALF),\n    ///     Greater\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_str(\"-2/3\")\n    ///         .unwrap()\n    ///         .cmp_abs(&Rational::ONE_HALF),\n    ///     Greater\n    /// );\n    /// ```\n    fn cmp_abs(&self, other: &Self) -> Ordering {\n        if core::ptr::eq(self, other) {\n            return Equal;\n        }\n        // First check if either value is zero\n        let self_sign = self.numerator_ref().sign();\n        let other_sign = other.numerator_ref().sign();\n        let sign_cmp = self_sign.cmp(&other_sign);\n        if sign_cmp != Equal || self_sign == Equal {\n            return sign_cmp;\n        }\n        // Then check if one is < 1 and the other is > 1\n        let self_cmp_one = self.numerator.cmp(&self.denominator);\n        let other_cmp_one = other.numerator.cmp(&other.denominator);\n        let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n        if one_cmp != Equal {\n            return one_cmp;\n        }\n        // Then compare numerators and denominators\n        let n_cmp = self.numerator.cmp(&other.numerator);\n        let d_cmp = self.denominator.cmp(&other.denominator);\n        if n_cmp == Equal && d_cmp == Equal {\n            return Equal;\n        }\n        let nd_cmp = n_cmp.cmp(&d_cmp);\n        if nd_cmp != Equal {\n            return nd_cmp;\n        }\n        // Then compare floor ∘ log_2 ∘ abs\n        let log_cmp = self\n            .floor_log_base_2_abs()\n            .cmp(&other.floor_log_base_2_abs());\n        if log_cmp != Equal {\n            return log_cmp;\n        }\n        // Finally, cross-multiply.\n        (&self.numerator * &other.denominator).cmp(&(&self.denominator * &other.numerator))\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nimpl EqAbs for Rational {\n    /// Determines whether the absolute values of two [`Rational`]s are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).eq_abs(&Rational::from_signeds(-23, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).eq_abs(&Rational::from_signeds(-24, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     true\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     true\n    /// );\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Self) -> bool {\n        self.numerator == other.numerator && self.denominator == other.denominator\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/eq_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_nz::integer::Integer;\n\nimpl EqAbs<Integer> for Rational {\n    /// Determines whether the absolute values of a [`Rational`] and an [`Integer`] are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(-123).eq_abs(&Integer::from(122)), false);\n    /// assert_eq!(Rational::from(-123).eq_abs(&Integer::from(124)), false);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Integer::from(123)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).eq_abs(&Integer::from(123)),\n    ///     false\n    /// );\n    /// assert_eq!(Rational::from(123).eq_abs(&Integer::from(123)), true);\n    /// assert_eq!(Rational::from(-123).eq_abs(&Integer::from(123)), true);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Integer::from(123)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Integer::from(123)),\n    ///     false\n    /// );\n    /// assert_eq!(Rational::from(-123).eq_abs(&Integer::from(-122)), false);\n    /// assert_eq!(Rational::from(-123).eq_abs(&Integer::from(-124)), false);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Integer::from(-123)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).eq_abs(&Integer::from(1 - 23)),\n    ///     false\n    /// );\n    /// assert_eq!(Rational::from(123).eq_abs(&Integer::from(-123)), true);\n    /// assert_eq!(Rational::from(-123).eq_abs(&Integer::from(-123)), true);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Integer::from(-123)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Integer::from(-123)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Integer) -> bool {\n        self.denominator == 1 && self.numerator == *other.unsigned_abs_ref()\n    }\n}\n\nimpl EqAbs<Rational> for Integer {\n    /// Determines whether the absolute values of a [`Rational`] and an [`Integer`] are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Integer::from(122).eq_abs(&Rational::from(-123)), false);\n    /// assert_eq!(Integer::from(124).eq_abs(&Rational::from(-123)), false);\n    /// assert_eq!(\n    ///     Integer::from(124).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(124).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(Integer::from(123).eq_abs(&Rational::from(123)), true);\n    /// assert_eq!(Integer::from(123).eq_abs(&Rational::from(-123)), true);\n    /// assert_eq!(\n    ///     Integer::from(123).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(123).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(Integer::from(-122).eq_abs(&Rational::from(-123)), false);\n    /// assert_eq!(Integer::from(-124).eq_abs(&Rational::from(-123)), false);\n    /// assert_eq!(\n    ///     Integer::from(-124).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-124).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(Integer::from(-123).eq_abs(&Rational::from(123)), true);\n    /// assert_eq!(Integer::from(-123).eq_abs(&Rational::from(-123)), true);\n    /// assert_eq!(\n    ///     Integer::from(-123).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-123).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Rational) -> bool {\n        other.denominator == 1 && other.numerator == *self.unsigned_abs_ref()\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_nz::natural::Natural;\n\nimpl EqAbs<Natural> for Rational {\n    /// Determines whether the absolute values of a [`Rational`] and a [`Natural`] are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(-123).eq_abs(&Natural::from(122u32)), false);\n    /// assert_eq!(Rational::from(-123).eq_abs(&Natural::from(124u32)), false);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Natural::from(123u32)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).eq_abs(&Natural::from(123u32)),\n    ///     false\n    /// );\n    /// assert_eq!(Rational::from(123).eq_abs(&Natural::from(123u32)), true);\n    /// assert_eq!(Rational::from(-123).eq_abs(&Natural::from(123u32)), true);\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Natural::from(123u32)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).eq_abs(&Natural::from(123u32)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Natural) -> bool {\n        self.denominator == 1 && self.numerator == *other\n    }\n}\n\nimpl EqAbs<Rational> for Natural {\n    /// Determines whether the absolute values of a [`Rational`] and a [`Natural`] are equal.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::EqAbs;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Natural::from(122u32).eq_abs(&Rational::from(-123)), false);\n    /// assert_eq!(Natural::from(124u32).eq_abs(&Rational::from(-123)), false);\n    /// assert_eq!(\n    ///     Natural::from(124u32).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(124u32).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(Natural::from(123u32).eq_abs(&Rational::from(123)), true);\n    /// assert_eq!(Natural::from(123u32).eq_abs(&Rational::from(-123)), true);\n    /// assert_eq!(\n    ///     Natural::from(123u32).eq_abs(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(123u32).eq_abs(&Rational::from_signeds(-22, 7)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn eq_abs(&self, other: &Rational) -> bool {\n        other.denominator == 1 && other.numerator == *self\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{FloorLogBase2, IsPowerOf2};\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\nmacro_rules! impl_eq_abs {\n    ($t: ident) => {\n        impl EqAbs<$t> for Rational {\n            /// Determines whether the absolute values of a [`Rational`] and a primitive float are\n            /// equal.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(m) = O(m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n            /// other.sci_exponent().abs())`, and $m$ is `other.sci_exponent().abs()`.\n            ///\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                if !other.is_finite() {\n                    false\n                } else if *other == 0.0 {\n                    *self == 0u32\n                } else {\n                    *self != 0u32\n                        && self.denominator.is_power_of_2()\n                        && self.floor_log_base_2_abs() == other.abs().floor_log_base_2()\n                        && self.eq_abs(&Rational::exact_from(other.abs()))\n                }\n            }\n        }\n\n        impl EqAbs<Rational> for $t {\n            /// Determines whether the absolute values of a primitive float and a [`Rational`] are\n            /// equal.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(m) = O(m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.sci_exponent().abs(),\n            /// other.significant_bits())`, and $m$ is `self.sci_exponent().abs()`.\n            ///\n            /// See [here](super::eq_abs_primitive_float#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Rational) -> bool {\n                other.eq_abs(self)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_eq_abs);\n"
  },
  {
    "path": "malachite-q/src/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::comparison::traits::EqAbs;\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl EqAbs<$t> for Rational {\n            /// Determines whether the absolute values of a [`Rational`] and a primitive unsigned\n            /// integer are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                self.denominator == 1u32 && self.numerator == *other\n            }\n        }\n\n        impl EqAbs<Rational> for $t {\n            /// Determines whether the absolute values of a primitive unsigned integer and a\n            /// [`Rational`] are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Rational) -> bool {\n                other.denominator == 1u32 && other.numerator == *self\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl EqAbs<$t> for Rational {\n            /// Determines whether the absolute values of a [`Rational`] and a primitive signed\n            /// integer are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &$t) -> bool {\n                self.denominator == 1 && self.numerator == other.unsigned_abs()\n            }\n        }\n\n        impl EqAbs<Rational> for $t {\n            /// Determines whether the absolute values of a primitive signed integer and an\n            /// [`Rational`] are equal.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// See [here](super::eq_abs_primitive_int#eq_abs).\n            #[inline]\n            fn eq_abs(&self, other: &Rational) -> bool {\n                other.denominator == 1 && other.numerator == self.unsigned_abs()\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-q/src/comparison/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Comparison of [`Rational`](crate::Rational)s.\npub mod cmp;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// and [`OrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`) (traits for comparing\n/// the absolute values of numbers by order) for [`Rational`](crate::Rational)s.\npub mod cmp_abs;\n/// Equality of the absolute values of two [`Rational`](crate::Rational)s.\npub mod eq_abs;\n/// Equality of the absolute values of a [`Rational`](crate::Rational) and an\n/// [`Integer`](malachite_nz::integer::Integer).\npub mod eq_abs_integer;\n/// Equality of the absolute values of a [`Rational`](crate::Rational) and a\n/// [`Natural`](malachite_nz::natural::Natural).\npub mod eq_abs_natural;\n/// Equality of the absolute values of a [`Rational`](crate::Rational) and a primitive float.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::basic::traits::{NegativeInfinity, Zero};\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(Rational::from(123).eq_abs(&123.0), true);\n/// assert_eq!(Rational::from(123).eq_abs(&5.0), false);\n/// assert_eq!(Rational::from(123).eq_abs(&-123.0), true);\n/// assert_eq!(Rational::from(123).eq_abs(&-5.0), false);\n/// assert_eq!(Rational::from(-123).eq_abs(&123.0), true);\n/// assert_eq!(Rational::from(-123).eq_abs(&5.0), false);\n/// assert_eq!(Rational::from(-123).eq_abs(&-123.0), true);\n/// assert_eq!(Rational::from(-123).eq_abs(&-5.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&123.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&5.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&-123.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&-5.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&123.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&5.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&-123.0), false);\n/// assert_eq!(Rational::from_signeds(22, 7).eq_abs(&-5.0), false);\n/// assert_eq!(Rational::ZERO.eq_abs(&0.0), true);\n/// assert_eq!(Rational::ZERO.eq_abs(&-0.0), true);\n/// assert_eq!(Rational::ZERO.eq_abs(&f64::NAN), false);\n/// assert_eq!(Rational::ZERO.eq_abs(&f64::INFINITY), false);\n/// assert_eq!(Rational::ZERO.eq_abs(&f64::NEGATIVE_INFINITY), false);\n///\n/// assert_eq!(123.0.eq_abs(&Rational::from(123)), true);\n/// assert_eq!(5.0.eq_abs(&Rational::from(123)), false);\n/// assert_eq!((-123.0).eq_abs(&Rational::from(123)), true);\n/// assert_eq!((-5.0).eq_abs(&Rational::from(123)), false);\n/// assert_eq!(123.0.eq_abs(&Rational::from(-123)), true);\n/// assert_eq!(5.0.eq_abs(&Rational::from(-123)), false);\n/// assert_eq!((-123.0).eq_abs(&Rational::from(-123)), true);\n/// assert_eq!((-5.0).eq_abs(&Rational::from(-123)), false);\n/// assert_eq!(123.0.eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!(5.0.eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!((-123.0).eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!((-5.0).eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!(123.0.eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!(5.0.eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!((-123.0).eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!((-5.0).eq_abs(&Rational::from_signeds(22, 7)), false);\n/// assert_eq!(0.0.eq_abs(&Rational::ZERO), true);\n/// assert_eq!((-0.0).eq_abs(&Rational::ZERO), true);\n/// assert_eq!(f64::NAN.eq_abs(&Rational::ZERO), false);\n/// assert_eq!(f64::INFINITY.eq_abs(&Rational::ZERO), false);\n/// assert_eq!(f64::NEGATIVE_INFINITY.eq_abs(&Rational::ZERO), false);\n/// ```\npub mod eq_abs_primitive_float;\n/// Equality of the absolute values of a [`Rational`](crate::Rational) and a primitive integer.\n///\n/// # eq_abs\n/// ```\n/// use malachite_base::num::comparison::traits::EqAbs;\n/// use malachite_q::Rational;\n///\n/// assert!(Rational::from(123).eq_abs(&123u64));\n/// assert!(Rational::from(-123).eq_abs(&123u64));\n/// assert!(Rational::from_signeds(22, 7).ne_abs(&123u64));\n/// assert!(Rational::from_signeds(-22, 7).ne_abs(&123u64));\n///\n/// assert!(Rational::from(123).eq_abs(&123i64));\n/// assert!(Rational::from(123).eq_abs(&-123i64));\n/// assert!(Rational::from_signeds(22, 7).ne_abs(&-123i64));\n/// assert!(Rational::from_signeds(-22, 7).ne_abs(&-123i64));\n///\n/// assert!(123u64.eq_abs(&Rational::from(123)));\n/// assert!(123u64.eq_abs(&Rational::from(-123)));\n/// assert!(123u64.ne_abs(&Rational::from_signeds(22, 7)));\n/// assert!(123u64.ne_abs(&Rational::from_signeds(-22, 7)));\n///\n/// assert!(123i64.eq_abs(&Rational::from(123)));\n/// assert!(123i64.eq_abs(&Rational::from(-123)));\n/// assert!((-123i64).ne_abs(&Rational::from_signeds(22, 7)));\n/// assert!((-123i64).ne_abs(&Rational::from_signeds(-22, 7)));\n/// ```\npub mod eq_abs_primitive_int;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Rational`](crate::Rational)s and [`Integer`](malachite_nz::integer::Integer)s.\npub mod partial_cmp_abs_integer;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Rational`](crate::Rational)s and [`Natural`](malachite_nz::natural::Natural)s.\npub mod partial_cmp_abs_natural;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Rational`](crate::Rational)s and primitive floats.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use malachite_q::Rational;\n///\n/// assert!(Rational::from_signeds(1, 3).gt_abs(&-0.33f32));\n/// assert!(Rational::from_signeds(1, 3).lt_abs(&-0.34f32));\n///\n/// assert!((-0.33f32).lt_abs(&Rational::from_signeds(1, 3)));\n/// assert!((-0.34f32).gt_abs(&Rational::from_signeds(1, 3)));\n/// ```\npub mod partial_cmp_abs_primitive_float;\n/// Implementations of [`PartialOrdAbs`](`malachite_base::num::comparison::traits::PartialOrdAbs`)\n/// (a trait for comparing the absolute values of numbers by order) for\n/// [`Rational`](crate::Rational)s and primitive integers.\n///\n/// # partial_cmp_abs\n/// ```\n/// use malachite_base::num::comparison::traits::PartialOrdAbs;\n/// use malachite_q::Rational;\n///\n/// assert!(Rational::from_signeds(22, 7).gt_abs(&3u32));\n/// assert!(Rational::from_signeds(22, 7).lt_abs(&4u32));\n/// assert!(Rational::from_signeds(-22, 7).gt_abs(&3u32));\n/// assert!(Rational::from_signeds(-22, 7).lt_abs(&4u32));\n///\n/// assert!(Rational::from_signeds(22, 7).gt_abs(&3i32));\n/// assert!(Rational::from_signeds(22, 7).lt_abs(&4i32));\n/// assert!(Rational::from_signeds(-22, 7).gt_abs(&-3i32));\n/// assert!(Rational::from_signeds(-22, 7).lt_abs(&-4i32));\n///\n/// assert!(3u32.lt_abs(&Rational::from_signeds(22, 7)));\n/// assert!(4u32.gt_abs(&Rational::from_signeds(22, 7)));\n/// assert!(3u32.lt_abs(&Rational::from_signeds(-22, 7)));\n/// assert!(4u32.gt_abs(&Rational::from_signeds(-22, 7)));\n///\n/// assert!(3i32.lt_abs(&Rational::from_signeds(22, 7)));\n/// assert!(4i32.gt_abs(&Rational::from_signeds(22, 7)));\n/// assert!((-3i32).lt_abs(&Rational::from_signeds(-22, 7)));\n/// assert!((-4i32).gt_abs(&Rational::from_signeds(-22, 7)));\n/// ```\npub mod partial_cmp_abs_primitive_int;\n/// Comparison of [`Rational`](crate::Rational)s and [`Integer`](malachite_nz::integer::Integer)s.\npub mod partial_cmp_integer;\n/// Comparison of [`Rational`](crate::Rational)s and [`Natural`](malachite_nz::natural::Natural)s.\npub mod partial_cmp_natural;\n/// Comparison of [`Rational`](crate::Rational)s and primitive floats.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_q::Rational;\n///\n/// assert!(Rational::from_signeds(1, 3) > 0.33f32);\n/// assert!(Rational::from_signeds(1, 3) < 0.34f32);\n///\n/// assert!(0.33f32 < Rational::from_signeds(1, 3));\n/// assert!(0.34f32 > Rational::from_signeds(1, 3));\n/// ```\npub mod partial_cmp_primitive_float;\n/// Comparison of [`Rational`](crate::Rational)s and primitive integers.\n///\n/// # partial_cmp\n/// ```\n/// use malachite_q::Rational;\n///\n/// assert!(Rational::from_signeds(22, 7) > 3u32);\n/// assert!(Rational::from_signeds(22, 7) < 4u32);\n/// assert!(Rational::from_signeds(-22, 7) < 3u32);\n/// assert!(Rational::from_signeds(-22, 7) < 4u32);\n///\n/// assert!(Rational::from_signeds(22, 7) > 3i32);\n/// assert!(Rational::from_signeds(22, 7) < 4i32);\n/// assert!(Rational::from_signeds(-22, 7) < -3i32);\n/// assert!(Rational::from_signeds(-22, 7) > -4i32);\n///\n/// assert!(3u32 < Rational::from_signeds(22, 7));\n/// assert!(4u32 > Rational::from_signeds(22, 7));\n/// assert!(3u32 > Rational::from_signeds(-22, 7));\n/// assert!(4u32 > Rational::from_signeds(-22, 7));\n///\n/// assert!(3i32 < Rational::from_signeds(22, 7));\n/// assert!(4i32 > Rational::from_signeds(22, 7));\n/// assert!(-3i32 > Rational::from_signeds(-22, 7));\n/// assert!(-4i32 < Rational::from_signeds(-22, 7));\n/// ```\npub mod partial_cmp_primitive_int;\n/// Equality of [`Rational`](crate::Rational)s and [`Integer`](malachite_nz::integer::Integer)s.\npub mod partial_eq_integer;\n/// Equality of [`Rational`](crate::Rational)s and [`Natural`](malachite_nz::natural::Natural)s.\npub mod partial_eq_natural;\n/// Equality of [`Rational`](crate::Rational)s and primitive floats.\n///\n/// # partial_eq\n/// ```\n/// use malachite_q::Rational;\n///\n/// assert!(Rational::from_signeds(3, 2) == 1.5f32);\n/// assert!(Rational::from_signeds(3, 2) != 1.4f32);\n///\n/// assert!(1.5f32 == Rational::from_signeds(3, 2));\n/// assert!(1.4f32 != Rational::from_signeds(3, 2));\n/// ```\npub mod partial_eq_primitive_float;\n/// Equality of [`Rational`](crate::Rational)s and primitive integers.\n///\n/// # partial_eq\n/// ```\n/// use malachite_q::Rational;\n///\n/// assert!(Rational::from(123) == 123u64);\n/// assert!(Rational::from(-123) != 123u64);\n/// assert!(Rational::from_signeds(22, 7) != 123u64);\n/// assert!(Rational::from_signeds(-22, 7) != 123u64);\n///\n/// assert!(Rational::from(123) == 123i64);\n/// assert!(Rational::from(-123) == -123i64);\n/// assert!(Rational::from_signeds(22, 7) != -123i64);\n/// assert!(Rational::from_signeds(-22, 7) != -123i64);\n///\n/// assert!(123u64 == Rational::from(123));\n/// assert!(123u64 != Rational::from(-123));\n/// assert!(123u64 != Rational::from_signeds(22, 7));\n/// assert!(123u64 != Rational::from_signeds(-22, 7));\n///\n/// assert!(123i64 == Rational::from(123));\n/// assert!(-123i64 == Rational::from(-123));\n/// assert!(-123i64 != Rational::from_signeds(22, 7));\n/// assert!(-123i64 != Rational::from_signeds(-22, 7));\n/// ```\npub mod partial_eq_primitive_int;\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nimpl PartialOrdAbs<Integer> for Rational {\n    /// Compares the absolute values of a [`Rational`] and an [`Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).partial_cmp_abs(&Integer::from(3)),\n    ///     Some(Greater)\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).partial_cmp_abs(&Integer::from(-3)),\n    ///     Some(Greater)\n    /// );\n    /// ```\n    fn partial_cmp_abs(&self, other: &Integer) -> Option<Ordering> {\n        // First check whether either value is zero\n        let self_sign = self.numerator_ref().sign();\n        let other_sign = other.unsigned_abs_ref().sign();\n        let sign_cmp = self_sign.cmp(&other_sign);\n        if sign_cmp != Equal || self_sign == Equal {\n            return Some(sign_cmp);\n        }\n        // Then check if one is < 1 and the other is > 1\n        let self_cmp_one = self.numerator.cmp(&self.denominator);\n        let other_cmp_one = other.unsigned_abs_ref().cmp(&Natural::ONE);\n        let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n        if one_cmp != Equal {\n            return Some(one_cmp);\n        }\n        // Then compare numerators and denominators\n        let n_cmp = self.numerator.cmp(other.unsigned_abs_ref());\n        let d_cmp = self.denominator.cmp(&Natural::ONE);\n        if n_cmp == Equal && d_cmp == Equal {\n            return Some(Equal);\n        }\n        let nd_cmp = n_cmp.cmp(&d_cmp);\n        if nd_cmp != Equal {\n            return Some(nd_cmp);\n        }\n        // Then compare floor ∘ log_2 ∘ abs\n        let log_cmp = self\n            .floor_log_base_2_abs()\n            .cmp(&i64::exact_from(other.significant_bits() - 1));\n        if log_cmp != Equal {\n            return Some(log_cmp);\n        }\n        // Finally, cross-multiply.\n        Some(\n            self.numerator\n                .cmp(&(&self.denominator * other.unsigned_abs_ref())),\n        )\n    }\n}\n\nimpl PartialOrdAbs<Rational> for Integer {\n    /// Compares the absolute values of an [`Integer`] and a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     Integer::from(3).partial_cmp_abs(&Rational::from_signeds(22, 7)),\n    ///     Some(Less)\n    /// );\n    /// assert_eq!(\n    ///     Integer::from(-3).partial_cmp_abs(&Rational::from_signeds(-22, 7)),\n    ///     Some(Less)\n    /// );\n    /// ```\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Rational) -> Option<Ordering> {\n        other.partial_cmp_abs(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\nimpl PartialOrdAbs<Natural> for Rational {\n    /// Compares the absolute values of a [`Rational`] and a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(22, 7).partial_cmp_abs(&Natural::from(3u32)),\n    ///     Some(Greater)\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(-22, 7).partial_cmp_abs(&Natural::from(3u32)),\n    ///     Some(Greater)\n    /// );\n    /// ```\n    fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {\n        // First check if either value is zero\n        let self_sign = self.numerator_ref().sign();\n        let other_sign = other.sign();\n        let sign_cmp = self_sign.cmp(&other_sign);\n        if sign_cmp != Equal || self_sign == Equal {\n            return Some(sign_cmp);\n        }\n        // Then check if one is < 1 and the other is > 1\n        let self_cmp_one = self.numerator.cmp(&self.denominator);\n        let other_cmp_one = other.cmp(&Natural::ONE);\n        let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n        if one_cmp != Equal {\n            return Some(one_cmp);\n        }\n        // Then compare numerators and denominators\n        let n_cmp = self.numerator.cmp(other);\n        let d_cmp = self.denominator.cmp(&Natural::ONE);\n        if n_cmp == Equal && d_cmp == Equal {\n            return Some(Equal);\n        }\n        let nd_cmp = n_cmp.cmp(&d_cmp);\n        if nd_cmp != Equal {\n            return Some(nd_cmp);\n        }\n        // Then compare floor ∘ log_2 ∘ abs\n        let log_cmp = self\n            .floor_log_base_2_abs()\n            .cmp(&i64::exact_from(other.significant_bits() - 1));\n        if log_cmp != Equal {\n            return Some(log_cmp);\n        }\n        // Finally, cross-multiply.\n        Some(self.numerator.cmp(&(&self.denominator * other)))\n    }\n}\n\nimpl PartialOrdAbs<Rational> for Natural {\n    /// Compares the absolute values of a [`Natural`] and a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::comparison::traits::PartialOrdAbs;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::*;\n    ///\n    /// assert_eq!(\n    ///     Natural::from(3u32).partial_cmp_abs(&Rational::from_signeds(22, 7)),\n    ///     Some(Less)\n    /// );\n    /// assert_eq!(\n    ///     Natural::from(3u32).partial_cmp_abs(&Rational::from_signeds(-22, 7)),\n    ///     Some(Less)\n    /// );\n    /// ```\n    #[inline]\n    fn partial_cmp_abs(&self, other: &Rational) -> Option<Ordering> {\n        other.partial_cmp_abs(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::FloorLogBase2;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::ExactFrom;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Rational {\n            /// Compares the absolute values of a [`Rational`] and a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_abs_primitive_float#partial_cmp_abs).\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                if other.is_nan() {\n                    None\n                } else if *other == 0.0 {\n                    self.partial_cmp_abs(&0u32)\n                } else if !other.is_finite() || *self == 0u32 {\n                    Some(Less)\n                } else {\n                    let ord_cmp = self\n                        .floor_log_base_2_abs()\n                        .cmp(&other.abs().floor_log_base_2());\n                    Some(if ord_cmp != Equal {\n                        ord_cmp\n                    } else {\n                        self.cmp_abs(&Rational::exact_from(*other))\n                    })\n                }\n            }\n        }\n\n        impl PartialOrdAbs<Rational> for $t {\n            /// Compares the absolute values of a primitive float and a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.sci_exponent().abs(), other.significant_bits())`.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_float#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Rational) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{Sign, UnsignedAbs};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\n#[allow(clippy::unnecessary_wraps)]\nfn partial_cmp_abs_unsigned<T: Copy + One + Ord + Sign + SignificantBits>(\n    x: &Rational,\n    other: &T,\n) -> Option<Ordering>\nwhere\n    Natural: From<T> + PartialOrd<T>,\n{\n    // First check if either value is zero\n    let self_sign = x.numerator_ref().sign();\n    let other_sign = other.sign();\n    let sign_cmp = self_sign.cmp(&other_sign);\n    if sign_cmp != Equal || self_sign == Equal {\n        return Some(sign_cmp);\n    }\n    // Then check if one is < 1 and the other is > 1\n    let self_cmp_one = x.numerator.cmp(&x.denominator);\n    let other_cmp_one = other.cmp(&T::ONE);\n    let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n    if one_cmp != Equal {\n        return Some(one_cmp);\n    }\n    // Then compare numerators and denominators\n    let n_cmp = x.numerator.partial_cmp(other).unwrap();\n    let d_cmp = x.denominator.cmp(&Natural::ONE);\n    if n_cmp == Equal && d_cmp == Equal {\n        return Some(Equal);\n    }\n    let nd_cmp = n_cmp.cmp(&d_cmp);\n    if nd_cmp != Equal {\n        return Some(nd_cmp);\n    }\n    // Then compare floor ∘ log_2 ∘ abs\n    let log_cmp = x\n        .floor_log_base_2_abs()\n        .cmp(&i64::exact_from(other.significant_bits() - 1));\n    if log_cmp != Equal {\n        return Some(log_cmp);\n    }\n    // Finally, cross-multiply.\n    Some(x.numerator.cmp(&(&x.denominator * Natural::from(*other))))\n}\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Rational {\n            /// Compares the absolute values of a [`Rational`] and an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                partial_cmp_abs_unsigned(self, other)\n            }\n        }\n\n        impl PartialOrdAbs<Rational> for $t {\n            /// Compares the absolute values of an unsigned primitive integer and a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Rational) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\n#[allow(clippy::unnecessary_wraps)]\nfn partial_cmp_abs_signed<\n    U: Copy + One + Ord + Sign + SignificantBits,\n    S: Copy + Sign + SignificantBits + UnsignedAbs<Output = U>,\n>(\n    x: &Rational,\n    other: &S,\n) -> Option<Ordering>\nwhere\n    Natural: From<U> + PartialOrd<U>,\n{\n    // First check if either value is zero\n    let self_sign = x.numerator_ref().sign();\n    let other_abs = other.unsigned_abs();\n    let other_sign = other_abs.sign();\n    let sign_cmp = self_sign.cmp(&other_sign);\n    if sign_cmp != Equal || self_sign == Equal {\n        return Some(sign_cmp);\n    }\n    // Then check if one is < 1 and the other is > 1\n    let self_cmp_one = x.numerator.cmp(&x.denominator);\n    let other_cmp_one = other_abs.cmp(&U::ONE);\n    let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n    if one_cmp != Equal {\n        return Some(one_cmp);\n    }\n    // Then compare numerators and denominators\n    let n_cmp = x.numerator.partial_cmp(&other_abs).unwrap();\n    let d_cmp = x.denominator.cmp(&Natural::ONE);\n    if n_cmp == Equal && d_cmp == Equal {\n        return Some(Equal);\n    }\n    let nd_cmp = n_cmp.cmp(&d_cmp);\n    if nd_cmp != Equal {\n        return Some(nd_cmp);\n    }\n    // Then compare floor ∘ log_2 ∘ abs\n    let log_cmp = x\n        .floor_log_base_2_abs()\n        .cmp(&i64::exact_from(other.significant_bits() - 1));\n    if log_cmp != Equal {\n        return Some(log_cmp);\n    }\n    // Finally, cross-multiply.\n    Some(\n        x.numerator\n            .cmp(&(&x.denominator * Natural::from(other_abs))),\n    )\n}\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialOrdAbs<$t> for Rational {\n            /// Compares the absolute values of a [`Rational`] and a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {\n                partial_cmp_abs_signed(self, other)\n            }\n        }\n\n        impl PartialOrdAbs<Rational> for $t {\n            /// Compares the absolute values of a signed primitive integer and a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// See [here](super::partial_cmp_abs_primitive_int#partial_cmp_abs).\n            #[inline]\n            fn partial_cmp_abs(&self, other: &Rational) -> Option<Ordering> {\n                other.partial_cmp_abs(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nimpl PartialOrd<Integer> for Rational {\n    /// Compares a [`Rational`] to an [`Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from_signeds(22, 7) > Integer::from(3));\n    /// assert!(Rational::from_signeds(22, 7) < Integer::from(4));\n    /// assert!(Rational::from_signeds(-22, 7) < Integer::from(-3));\n    /// assert!(Rational::from_signeds(-22, 7) > Integer::from(-4));\n    /// ```\n    fn partial_cmp(&self, other: &Integer) -> Option<Ordering> {\n        // First check signs\n        let self_sign = self.sign();\n        let other_sign = other.sign();\n        let sign_cmp = self_sign.cmp(&other_sign);\n        if sign_cmp != Equal || self_sign == Equal {\n            return Some(sign_cmp);\n        }\n        // Then check if one is < 1 and the other is > 1\n        let self_cmp_one = self.numerator.cmp(&self.denominator);\n        let other_cmp_one = other.unsigned_abs_ref().cmp(&Natural::ONE);\n        let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n        if one_cmp != Equal {\n            return Some(if self.sign {\n                one_cmp\n            } else {\n                one_cmp.reverse()\n            });\n        }\n        // Then compare numerators and denominators\n        let n_cmp = self.numerator.cmp(other.unsigned_abs_ref());\n        let d_cmp = self.denominator.cmp(&Natural::ONE);\n        if n_cmp == Equal && d_cmp == Equal {\n            return Some(Equal);\n        }\n        let nd_cmp = n_cmp.cmp(&d_cmp);\n        if nd_cmp != Equal {\n            return Some(if self.sign { nd_cmp } else { nd_cmp.reverse() });\n        }\n        let log_cmp = self\n            .floor_log_base_2_abs()\n            .cmp(&i64::exact_from(other.significant_bits() - 1));\n        if log_cmp != Equal {\n            return Some(if self.sign {\n                log_cmp\n            } else {\n                log_cmp.reverse()\n            });\n        }\n        // Finally, cross-multiply.\n        let prod_cmp = self\n            .numerator\n            .cmp(&(&self.denominator * other.unsigned_abs_ref()));\n        Some(if self.sign {\n            prod_cmp\n        } else {\n            prod_cmp.reverse()\n        })\n    }\n}\n\nimpl PartialOrd<Rational> for Integer {\n    /// Compares an [`Integer`] to a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Integer::from(3) < Rational::from_signeds(22, 7));\n    /// assert!(Integer::from(4) > Rational::from_signeds(22, 7));\n    /// assert!(Integer::from(-3) > Rational::from_signeds(-22, 7));\n    /// assert!(Integer::from(-4) < Rational::from_signeds(-22, 7));\n    /// ```\n    #[inline]\n    fn partial_cmp(&self, other: &Rational) -> Option<Ordering> {\n        other.partial_cmp(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\nimpl PartialOrd<Natural> for Rational {\n    /// Compares a [`Rational`] to a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from_signeds(22, 7) > Natural::from(3u32));\n    /// assert!(Rational::from_signeds(22, 7) < Natural::from(4u32));\n    /// ```\n    fn partial_cmp(&self, other: &Natural) -> Option<Ordering> {\n        // First check signs\n        let self_sign = self.sign();\n        let other_sign = other.sign();\n        let sign_cmp = self_sign.cmp(&other_sign);\n        if sign_cmp != Equal || self_sign == Equal {\n            return Some(sign_cmp);\n        }\n        // Then check if one is < 1 and the other is > 1\n        let self_cmp_one = self.numerator.cmp(&self.denominator);\n        let other_cmp_one = other.cmp(&Natural::ONE);\n        let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n        if one_cmp != Equal {\n            return Some(one_cmp);\n        }\n        // Then compare numerators and denominators\n        let n_cmp = self.numerator.cmp(other);\n        let d_cmp = self.denominator.cmp(&Natural::ONE);\n        if n_cmp == Equal && d_cmp == Equal {\n            return Some(Equal);\n        }\n        let nd_cmp = n_cmp.cmp(&d_cmp);\n        if nd_cmp != Equal {\n            return Some(nd_cmp);\n        }\n        let log_cmp = self\n            .floor_log_base_2_abs()\n            .cmp(&i64::exact_from(other.significant_bits() - 1));\n        if log_cmp != Equal {\n            return Some(if self.sign {\n                log_cmp\n            } else {\n                log_cmp.reverse()\n            });\n        }\n        // Finally, cross-multiply.\n        Some(self.numerator.cmp(&(&self.denominator * other)))\n    }\n}\n\nimpl PartialOrd<Rational> for Natural {\n    /// Compares a [`Natural`] to a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Natural::from(3u32) < Rational::from_signeds(22, 7));\n    /// assert!(Natural::from(4u32) > Rational::from_signeds(22, 7));\n    /// ```\n    #[inline]\n    fn partial_cmp(&self, other: &Rational) -> Option<Ordering> {\n        other.partial_cmp(self).map(Ordering::reverse)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::FloorLogBase2;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Rational {\n            /// Compares a [`Rational`] to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(self.significant_bits(), other.sci_exponent().abs())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                if other.is_nan() {\n                    None\n                } else if self.sign != (*other >= 0.0) {\n                    Some(if self.sign { Greater } else { Less })\n                } else if !other.is_finite() {\n                    Some(if self.sign { Less } else { Greater })\n                } else if *other == 0.0 {\n                    self.partial_cmp(&0u32)\n                } else if *self == 0u32 {\n                    0.0.partial_cmp(other)\n                } else {\n                    let ord_cmp = self\n                        .floor_log_base_2_abs()\n                        .cmp(&other.abs().floor_log_base_2());\n                    Some(if ord_cmp != Equal {\n                        if self.sign {\n                            ord_cmp\n                        } else {\n                            ord_cmp.reverse()\n                        }\n                    } else {\n                        self.cmp(&Rational::try_from(*other).unwrap())\n                    })\n                }\n            }\n        }\n\n        impl PartialOrd<Rational> for $t {\n            /// Compares a primitive float to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `max(other.sci_exponent().abs(), self.significant_bits())`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_float#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Rational) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{Sign, UnsignedAbs};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\n#[allow(clippy::unnecessary_wraps)]\nfn partial_cmp_unsigned<T: Copy + One + Ord + Sign + SignificantBits>(\n    x: &Rational,\n    other: &T,\n) -> Option<Ordering>\nwhere\n    Natural: From<T> + PartialOrd<T>,\n{\n    // First check signs\n    let self_sign = x.sign();\n    let other_sign = other.sign();\n    let sign_cmp = self_sign.cmp(&other_sign);\n    if sign_cmp != Equal || self_sign == Equal {\n        return Some(sign_cmp);\n    }\n    // Then check if one is < 1 and the other is > 1\n    let self_cmp_one = x.numerator.cmp(&x.denominator);\n    let other_cmp_one = other.cmp(&T::ONE);\n    let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n    if one_cmp != Equal {\n        return Some(one_cmp);\n    }\n    // Then compare numerators and denominators\n    let n_cmp = x.numerator.partial_cmp(other).unwrap();\n    let d_cmp = x.denominator.cmp(&Natural::ONE);\n    if n_cmp == Equal && d_cmp == Equal {\n        return Some(Equal);\n    }\n    let nd_cmp = n_cmp.cmp(&d_cmp);\n    if nd_cmp != Equal {\n        return Some(nd_cmp);\n    }\n    // Then compare floor ∘ log_2 ∘ abs\n    let log_cmp = x\n        .floor_log_base_2_abs()\n        .cmp(&i64::exact_from(other.significant_bits() - 1));\n    if log_cmp != Equal {\n        return Some(if x.sign { log_cmp } else { log_cmp.reverse() });\n    }\n    // Finally, cross-multiply.\n    Some(x.numerator.cmp(&(&x.denominator * Natural::from(*other))))\n}\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Rational {\n            /// Compares a [`Rational`] to an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                partial_cmp_unsigned(self, other)\n            }\n        }\n\n        impl PartialOrd<Rational> for $t {\n            /// Compares an unsigned primitive integer to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Rational) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\n#[allow(clippy::unnecessary_wraps)]\nfn partial_cmp_signed<\n    U: Copy + One + Ord + SignificantBits,\n    S: Copy + Sign + SignificantBits + UnsignedAbs<Output = U>,\n>(\n    x: &Rational,\n    other: &S,\n) -> Option<Ordering>\nwhere\n    Natural: From<U> + PartialOrd<U>,\n{\n    // First check signs\n    let self_sign = x.sign();\n    let other_sign = other.sign();\n    let sign_cmp = self_sign.cmp(&other_sign);\n    if sign_cmp != Equal || self_sign == Equal {\n        return Some(sign_cmp);\n    }\n    let other_abs = other.unsigned_abs();\n    // Then check if one is < 1 and the other is > 1\n    let self_cmp_one = x.numerator.cmp(&x.denominator);\n    let other_cmp_one = other_abs.cmp(&U::ONE);\n    let one_cmp = self_cmp_one.cmp(&other_cmp_one);\n    if one_cmp != Equal {\n        return Some(if x.sign { one_cmp } else { one_cmp.reverse() });\n    }\n    // Then compare numerators and denominators\n    let n_cmp = x.numerator.partial_cmp(&other_abs).unwrap();\n    let d_cmp = x.denominator.cmp(&Natural::ONE);\n    if n_cmp == Equal && d_cmp == Equal {\n        return Some(Equal);\n    }\n    let nd_cmp = n_cmp.cmp(&d_cmp);\n    if nd_cmp != Equal {\n        return Some(if x.sign { nd_cmp } else { nd_cmp.reverse() });\n    }\n    // Then compare floor ∘ log_2 ∘ abs\n    let log_cmp = x\n        .floor_log_base_2_abs()\n        .cmp(&i64::exact_from(other.significant_bits() - 1));\n    if log_cmp != Equal {\n        return Some(if x.sign { log_cmp } else { log_cmp.reverse() });\n    }\n    // Finally, cross-multiply.\n    let prod_cmp = x\n        .numerator\n        .cmp(&(&x.denominator * Natural::from(other_abs)));\n    Some(if x.sign { prod_cmp } else { prod_cmp.reverse() })\n}\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialOrd<$t> for Rational {\n            /// Compares a [`Rational`] to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &$t) -> Option<Ordering> {\n                partial_cmp_signed(self, other)\n            }\n        }\n\n        impl PartialOrd<Rational> for $t {\n            /// Compares a signed primitive integer to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_cmp_primitive_int#partial_cmp).\n            #[inline]\n            fn partial_cmp(&self, other: &Rational) -> Option<Ordering> {\n                other.partial_cmp(self).map(Ordering::reverse)\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_eq_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_nz::integer::Integer;\n\nimpl PartialEq<Integer> for Rational {\n    /// Determines whether a [`Rational`] is equal to an [`Integer`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from(-123) == Integer::from(-123));\n    /// assert!(Rational::from_signeds(22, 7) != Integer::from(5));\n    /// ```\n    fn eq(&self, other: &Integer) -> bool {\n        self.sign == (*other >= 0)\n            && self.denominator == 1\n            && self.numerator == *other.unsigned_abs_ref()\n    }\n}\n\nimpl PartialEq<Rational> for Integer {\n    /// Determines whether an [`Integer`] is equal to a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Integer::from(-123) == Rational::from(-123));\n    /// assert!(Integer::from(5) != Rational::from_signeds(22, 7));\n    /// ```\n    fn eq(&self, other: &Rational) -> bool {\n        other.sign == (*self >= 0)\n            && other.denominator == 1\n            && *self.unsigned_abs_ref() == other.numerator\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_nz::natural::Natural;\n\nimpl PartialEq<Natural> for Rational {\n    /// Determines whether a [`Rational`] is equal to a [`Natural`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Rational::from(123) == Natural::from(123u32));\n    /// assert!(Rational::from_signeds(22, 7) != Natural::from(5u32));\n    /// ```\n    fn eq(&self, other: &Natural) -> bool {\n        self.sign && self.denominator == 1 && self.numerator == *other\n    }\n}\n\nimpl PartialEq<Rational> for Natural {\n    /// Determines whether a [`Natural`] is equal to a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(1)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `min(self.significant_bits(),\n    /// other.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert!(Natural::from(123u32) == Rational::from(123));\n    /// assert!(Natural::from(5u32) != Rational::from_signeds(22, 7));\n    /// ```\n    fn eq(&self, other: &Rational) -> bool {\n        other.sign && other.denominator == 1 && *self == other.numerator\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{FloorLogBase2, IsPowerOf2};\nuse malachite_base::num::conversion::traits::ExactFrom;\n\nmacro_rules! impl_float {\n    ($t: ident) => {\n        impl PartialEq<$t> for Rational {\n            /// Determines whether a [`Rational`] is equal to a primitive float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(m) = O(m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.significant_bits(),\n            /// other.sci_exponent().abs())`, and $m$ is `other.sci_exponent().abs()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            #[allow(clippy::cmp_owned)]\n            fn eq(&self, other: &$t) -> bool {\n                if !other.is_finite() {\n                    false\n                } else if *other == 0.0 {\n                    *self == 0u32\n                } else {\n                    *self != 0u32\n                        && self.sign == (*other > 0.0)\n                        && self.denominator.is_power_of_2()\n                        && self.floor_log_base_2_abs() == other.abs().floor_log_base_2()\n                        && *self == Rational::exact_from(*other)\n                }\n            }\n        }\n\n        impl PartialEq<Rational> for $t {\n            /// Determines whether a primitive float is equal to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(m) = O(m)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, $n$ is `max(self.sci_exponent().abs(),\n            /// other.significant_bits())`, and $m$ is `self.sci_exponent().abs()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_float#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Rational) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_float);\n"
  },
  {
    "path": "malachite-q/src/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\n\nmacro_rules! impl_unsigned {\n    ($t: ident) => {\n        impl PartialEq<$t> for Rational {\n            /// Determines whether a [`Rational`] is equal to an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &$t) -> bool {\n                self.sign && self.denominator == 1u32 && self.numerator == *other\n            }\n        }\n\n        impl PartialEq<Rational> for $t {\n            /// Determines whether an unsigned primitive integer is equal to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Rational) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_unsigned);\n\nmacro_rules! impl_signed {\n    ($t: ident) => {\n        impl PartialEq<$t> for Rational {\n            /// Determines whether a [`Rational`] is equal to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            fn eq(&self, other: &$t) -> bool {\n                self.sign == (*other >= 0)\n                    && self.denominator == 1\n                    && self.numerator == other.unsigned_abs()\n            }\n        }\n\n        impl PartialEq<Rational> for $t {\n            /// Determines whether a signed primitive integer is equal to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `other.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::partial_eq_primitive_int#partial_eq).\n            #[inline]\n            fn eq(&self, other: &Rational) -> bool {\n                other == self\n            }\n        }\n    };\n}\napply_to_signeds!(impl_signed);\n"
  },
  {
    "path": "malachite-q/src/conversion/continued_fraction/convergents.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::conversion::continued_fraction::to_continued_fraction::RationalContinuedFraction;\nuse crate::conversion::traits::ContinuedFraction;\nuse crate::conversion::traits::Convergents;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{AddMulAssign, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\n/// An iterator that produces the convergents of a [`Rational`].\n///\n/// See [`convergents`](Rational::convergents) for more information.\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct RationalConvergents {\n    first: bool,\n    previous_numerator: Integer,\n    previous_denominator: Natural,\n    numerator: Integer,\n    denominator: Natural,\n    cf: RationalContinuedFraction,\n}\n\nimpl Iterator for RationalConvergents {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        if self.first {\n            self.first = false;\n            Some(Rational::from(&self.numerator))\n        } else if let Some(n) = self.cf.next() {\n            self.previous_numerator\n                .add_mul_assign(&self.numerator, Integer::from(&n));\n            self.previous_denominator\n                .add_mul_assign(&self.denominator, n);\n            swap(&mut self.numerator, &mut self.previous_numerator);\n            swap(&mut self.denominator, &mut self.previous_denominator);\n            Some(Rational {\n                sign: self.numerator >= 0,\n                numerator: (&self.numerator).unsigned_abs(),\n                denominator: self.denominator.clone(),\n            })\n        } else {\n            None\n        }\n    }\n}\n\nimpl Convergents for Rational {\n    type C = RationalConvergents;\n\n    /// Returns the convergents of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// The convergents of a number are the sequence of rational numbers whose continued fractions\n    /// are the prefixes of the number's continued fraction. The first convergent is the floor of\n    /// the number. The sequence of convergents is finite iff the number is rational, in which case\n    /// the last convergent is the number itself. Each convergent is closer to the number than the\n    /// previous convergent is. The even-indexed convergents are less than or equal to the number,\n    /// and the odd-indexed ones are greater than or equal to it.\n    ///\n    /// $f(x) = ([a_0; a_1, a_2, \\ldots, a_i])_{i=0}^{n}$, where $x = [a_0; a_1, a_2, \\ldots, a_n]$\n    /// and $a_n \\neq 1$.\n    ///\n    /// The output length is $O(n)$, where $n$ is `self.significant_bits()`.\n    ///\n    /// # Worst-case complexity per iteration\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::conversion::traits::Convergents;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_signeds(2, 3)\n    ///         .convergents()\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[0, 1, 2/3]\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_signeds(355, 113)\n    ///         .convergents()\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[3, 22/7, 355/113]\",\n    /// );\n    /// ```\n    fn convergents(self) -> RationalConvergents {\n        let (floor, cf) = self.continued_fraction();\n        RationalConvergents {\n            first: true,\n            previous_numerator: Integer::ONE,\n            previous_denominator: Natural::ZERO,\n            numerator: floor,\n            denominator: Natural::ONE,\n            cf,\n        }\n    }\n}\n\nimpl Convergents for &Rational {\n    type C = RationalConvergents;\n\n    /// Returns the convergents of a [`Rational`], taking the [`Rational`] by reference.\n    ///\n    /// The convergents of a number are the sequence of rational numbers whose continued fractions\n    /// are the prefixes of the number's continued fraction. The first convergent is the floor of\n    /// the number. The sequence of convergents is finite iff the number is rational, in which case\n    /// the last convergent is the number itself. Each convergent is closer to the number than the\n    /// previous convergent is. The even-indexed convergents are less than or equal to the number,\n    /// and the odd-indexed ones are greater than or equal to it.\n    ///\n    /// $f(x) = ([a_0; a_1, a_2, \\ldots, a_i])_{i=0}^{n}$, where $x = [a_0; a_1, a_2, \\ldots, a_n]$\n    /// and $a_n \\neq 1$.\n    ///\n    /// The output length is $O(n)$, where $n$ is `self.significant_bits()`.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::conversion::traits::Convergents;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(2, 3))\n    ///         .convergents()\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[0, 1, 2/3]\"\n    /// );\n    /// assert_eq!(\n    ///     (&Rational::from_signeds(355, 113))\n    ///         .convergents()\n    ///         .collect_vec()\n    ///         .to_debug_string(),\n    ///     \"[3, 22/7, 355/113]\",\n    /// );\n    /// ```\n    fn convergents(self) -> RationalConvergents {\n        let (floor, cf) = self.continued_fraction();\n        RationalConvergents {\n            first: true,\n            previous_numerator: Integer::ONE,\n            previous_denominator: Natural::ZERO,\n            numerator: floor,\n            denominator: Natural::ONE,\n            cf,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/continued_fraction/from_continued_fraction.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{AddMulAssign, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nimpl Rational {\n    /// Converts a finite continued fraction to a [`Rational`], taking the inputs by value.\n    ///\n    /// The input has two components. The first is the first value of the continued fraction, which\n    /// may be any [`Integer`] and is equal to the floor of the [`Rational`]. The second is an\n    /// iterator of the remaining values, which must all be positive. Using the standard notation\n    /// for continued fractions, the first value is the number before the semicolon, and the second\n    /// value contains the remaining numbers.\n    ///\n    /// Each rational number has two continued fraction representations. Either one is a valid\n    /// input.\n    ///\n    /// $f(a_0, (a_1, a_2, a_3, \\ldots)) = [a_0; a_1, a_2, a_3, \\ldots]$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O((nm)^2 \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(floor.significant_bits(),\n    /// xs.map(Natural::significant_bits).max())`, and $m$ is `xs.count()`.\n    ///\n    /// # Panics\n    /// Panics if any [`Natural`] in `xs` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// let xs = vec_from_str(\"[1, 2]\").unwrap().into_iter();\n    /// assert_eq!(\n    ///     Rational::from_continued_fraction(Integer::ZERO, xs).to_string(),\n    ///     \"2/3\"\n    /// );\n    ///\n    /// let xs = vec_from_str(\"[7, 16]\").unwrap().into_iter();\n    /// assert_eq!(\n    ///     Rational::from_continued_fraction(Integer::from(3), xs).to_string(),\n    ///     \"355/113\"\n    /// );\n    /// ```\n    pub fn from_continued_fraction<I: Iterator<Item = Natural>>(floor: Integer, xs: I) -> Self {\n        let mut previous_numerator = Integer::ONE;\n        let mut previous_denominator = Natural::ZERO;\n        let mut numerator = floor;\n        let mut denominator = Natural::ONE;\n        for n in xs {\n            assert_ne!(n, 0u32);\n            previous_numerator.add_mul_assign(&numerator, Integer::from(&n));\n            previous_denominator.add_mul_assign(&denominator, n);\n            swap(&mut numerator, &mut previous_numerator);\n            swap(&mut denominator, &mut previous_denominator);\n        }\n        Self {\n            sign: numerator >= 0,\n            numerator: numerator.unsigned_abs(),\n            denominator,\n        }\n    }\n\n    /// Converts a finite continued fraction to a [`Rational`], taking the inputs by reference.\n    ///\n    /// The input has two components. The first is the first value of the continued fraction, which\n    /// may be any [`Integer`] and is equal to the floor of the [`Rational`]. The second is an\n    /// iterator of the remaining values, which must all be positive. Using the standard notation\n    /// for continued fractions, the first value is the number before the semicolon, and the second\n    /// value contains the remaining numbers.\n    ///\n    /// Each rational number has two continued fraction representations. Either one is a valid\n    /// input.\n    ///\n    /// $f(a_0, (a_1, a_2, a_3, \\ldots)) = [a_0; a_1, a_2, a_3, \\ldots]$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O((nm)^2 \\log (nm) \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(floor.significant_bits(),\n    /// xs.map(Natural::significant_bits).max())`, and $m$ is `xs.count()`.\n    ///\n    /// # Panics\n    /// Panics if any [`Natural`] in `xs` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// let xs = vec_from_str(\"[1, 2]\").unwrap();\n    /// assert_eq!(\n    ///     Rational::from_continued_fraction_ref(&Integer::ZERO, xs.iter()).to_string(),\n    ///     \"2/3\"\n    /// );\n    ///\n    /// let xs = vec_from_str(\"[7, 16]\").unwrap();\n    /// assert_eq!(\n    ///     Rational::from_continued_fraction_ref(&Integer::from(3), xs.iter()).to_string(),\n    ///     \"355/113\"\n    /// );\n    /// ```\n    pub fn from_continued_fraction_ref<'a, I: Iterator<Item = &'a Natural>>(\n        floor: &Integer,\n        xs: I,\n    ) -> Self {\n        let mut previous_numerator = Integer::ONE;\n        let mut previous_denominator = Natural::ZERO;\n        let mut numerator = floor.clone();\n        let mut denominator = Natural::ONE;\n        for n in xs {\n            assert_ne!(*n, 0u32);\n            previous_numerator.add_mul_assign(&numerator, Integer::from(n));\n            previous_denominator.add_mul_assign(&denominator, n);\n            swap(&mut numerator, &mut previous_numerator);\n            swap(&mut denominator, &mut previous_denominator);\n        }\n        Self {\n            sign: numerator >= 0,\n            numerator: numerator.unsigned_abs(),\n            denominator,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/continued_fraction/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of [`Convergents`](super::traits::Convergents), a trait for generating the\n/// convergents of a number.\npub mod convergents;\n/// Functions for constructing a [`Rational`](crate::Rational) from a continued fraction.\npub mod from_continued_fraction;\n/// Implementations of [`ContinuedFraction`](super::traits::ContinuedFraction), a trait for\n/// generating the continued fraction of a number.\npub mod to_continued_fraction;\n"
  },
  {
    "path": "malachite-q/src/conversion/continued_fraction/to_continued_fraction.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::conversion::traits::ContinuedFraction;\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{DivMod, Floor};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\n/// An iterator that produces the continued fraction of a [`Rational`].\n///\n/// See [`continued_fraction`](Rational::continued_fraction) for more information.\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct RationalContinuedFraction {\n    numerator: Natural,\n    denominator: Natural,\n}\n\nimpl RationalContinuedFraction {\n    pub_crate_test! {is_done(&self) -> bool {\n        self.denominator == 0u32 || self.numerator == 0u32\n    }}\n}\n\nimpl Iterator for RationalContinuedFraction {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.denominator == 0u32 || self.numerator == 0u32 {\n            None\n        } else {\n            let n;\n            (n, self.numerator) = (&self.numerator).div_mod(&self.denominator);\n            swap(&mut self.numerator, &mut self.denominator);\n            Some(n)\n        }\n    }\n}\n\nimpl ContinuedFraction for Rational {\n    type CF = RationalContinuedFraction;\n\n    /// Returns the continued fraction of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// The output has two components. The first is the first value of the continued fraction, which\n    /// may be any [`Integer`] and is equal to the floor of the [`Rational`]. The second is an\n    /// iterator that produces the remaining values, which are all positive. Using the standard\n    /// notation for continued fractions, the first value is the number before the semicolon, and\n    /// the second value produces the remaining numbers.\n    ///\n    /// Each rational number has two continued fraction representations. The shorter of the two\n    /// representations (the one that does not end in 1) is returned.\n    ///\n    /// $f(x) = (a_0, (a_1, a_2, \\ldots, a_3)),$ where $x = [a_0; a_1, a_2, \\ldots, a_3]$ and $a_3\n    /// \\neq 1$.\n    ///\n    /// The output length is $O(n)$, where $n$ is `self.significant_bits()`.\n    ///\n    /// # Worst-case complexity per iteration\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::conversion::traits::ContinuedFraction;\n    /// use malachite_q::Rational;\n    ///\n    /// let (head, tail) = Rational::from_signeds(2, 3).continued_fraction();\n    /// let tail = tail.collect_vec();\n    /// assert_eq!(head, 0);\n    /// assert_eq!(tail.to_debug_string(), \"[1, 2]\");\n    ///\n    /// let (head, tail) = Rational::from_signeds(355, 113).continued_fraction();\n    /// let tail = tail.collect_vec();\n    /// assert_eq!(head, 3);\n    /// assert_eq!(tail.to_debug_string(), \"[7, 16]\");\n    /// ```\n    fn continued_fraction(mut self) -> (Integer, RationalContinuedFraction) {\n        let f = (&self).floor();\n        self -= Self::from(&f);\n        let (d, n) = self.into_numerator_and_denominator();\n        (\n            f,\n            RationalContinuedFraction {\n                numerator: n,\n                denominator: d,\n            },\n        )\n    }\n}\n\nimpl ContinuedFraction for &Rational {\n    type CF = RationalContinuedFraction;\n\n    /// Returns the continued fraction of a [`Rational`], taking the [`Rational`] by reference.\n    ///\n    /// The output has two components. The first is the first value of the continued fraction, which\n    /// may be any [`Integer`] and is equal to the floor of the [`Rational`]. The second is an\n    /// iterator that produces the remaining values, which are all positive. Using the standard\n    /// notation for continued fractions, the first value is the number before the semicolon, and\n    /// the second value produces the remaining numbers.\n    ///\n    /// Each rational number has two continued fraction representations. The shorter of the two\n    /// representations (the one that does not end in 1) is returned.\n    ///\n    /// $f(x) = (a_0, (a_1, a_2, \\ldots, a_3)),$ where $x = [a_0; a_1, a_2, \\ldots, a_3]$ and $a_3\n    /// \\neq 1$.\n    ///\n    /// The output length is $O(n)$, where $n$ is `self.significant_bits()`.\n    ///\n    /// # Worst-case complexity per iteration\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use itertools::Itertools;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::conversion::traits::ContinuedFraction;\n    /// use malachite_q::Rational;\n    ///\n    /// let (head, tail) = (&Rational::from_signeds(2, 3)).continued_fraction();\n    /// let tail = tail.collect_vec();\n    /// assert_eq!(head, 0);\n    /// assert_eq!(tail.to_debug_string(), \"[1, 2]\");\n    ///\n    /// let (head, tail) = (&Rational::from_signeds(355, 113)).continued_fraction();\n    /// let tail = tail.collect_vec();\n    /// assert_eq!(head, 3);\n    /// assert_eq!(tail.to_debug_string(), \"[7, 16]\");\n    /// ```\n    fn continued_fraction(self) -> (Integer, RationalContinuedFraction) {\n        let f = self.floor();\n        let (d, n) = (self - Rational::from(&f)).into_numerator_and_denominator();\n        (\n            f,\n            RationalContinuedFraction {\n                numerator: n,\n                denominator: d,\n            },\n        )\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/digits/digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::conversion::digits::power_of_2_digits::RationalPowerOf2Digits;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{Abs, CheckedLogBase2, Floor, UnsignedAbs};\nuse malachite_base::num::conversion::traits::Digits;\nuse malachite_nz::natural::Natural;\n\n#[doc(hidden)]\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct RationalGeneralDigits {\n    base: Rational,\n    remainder: Rational,\n}\n\nimpl Iterator for RationalGeneralDigits {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.remainder == 0u32 {\n            None\n        } else {\n            self.remainder *= &self.base;\n            let digit = (&self.remainder).floor().unsigned_abs();\n            self.remainder -= Rational::from(&digit);\n            Some(digit)\n        }\n    }\n}\n\n/// Represents the base-$b$ digits of the fractional portion of a [`Rational`] number.\n///\n/// See [`digits`](Rational::digits) for more information.\n#[derive(Clone, Debug, Eq, PartialEq)]\npub enum RationalDigits {\n    General(RationalGeneralDigits),\n    PowerOf2(RationalPowerOf2Digits),\n}\n\nimpl Iterator for RationalDigits {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        match self {\n            Self::General(xs) => xs.next(),\n            Self::PowerOf2(xs) => xs.next(),\n        }\n    }\n}\n\nimpl Rational {\n    /// Returns the base-$b$ digits of a [`Rational`].\n    ///\n    /// The output has two components. The first is a [`Vec`] of the digits of the integer portion\n    /// of the [`Rational`], least- to most-significant. The second is an iterator of the digits of\n    /// the fractional portion.\n    ///\n    /// The output is in its simplest form: the integer-portion digits do not end with a zero, and\n    /// the fractional-portion digits do not end with infinitely many zeros or $(b-1)$s.\n    ///\n    /// If the [`Rational`] has a small denominator, it may be more efficient to use\n    /// [`to_digits`](Rational::to_digits) or [`into_digits`](Rational::into_digits) instead. These\n    /// functions compute the entire repeating portion of the repeating digits.\n    ///\n    /// For example, consider these two expressions:\n    /// - `Rational::from_signeds(1, 7).digits(Natural::from(10u32)).1.nth(1000)`\n    /// - `Rational::from_signeds(1, 7).into_digits(Natural::from(10u32)).1[1000]`\n    ///\n    /// Both get the thousandth digit after the decimal point of `1/7`. The first way explicitly\n    /// calculates each digit after the decimal point, whereas the second way determines that `1/7`\n    /// is `0.(142857)`, with the `142857` repeating, and takes `1000 % 6 == 4` to determine that\n    /// the thousandth digit is 5. But when the [`Rational`] has a large denominator, the second way\n    /// is less efficient.\n    ///\n    /// # Worst-case complexity per iteration\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// base.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::prefix_to_string;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let (before_point, after_point) = Rational::from(3u32).digits(&Natural::from(10u32));\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(prefix_to_string(after_point, 10), \"[]\");\n    ///\n    /// let (before_point, after_point) =\n    ///     Rational::from_signeds(22, 7).digits(&Natural::from(10u32));\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(\n    ///     prefix_to_string(after_point, 10),\n    ///     \"[1, 4, 2, 8, 5, 7, 1, 4, 2, 8, ...]\"\n    /// );\n    /// ```\n    pub fn digits(&self, base: &Natural) -> (Vec<Natural>, RationalDigits) {\n        if let Some(log_base) = base.checked_log_base_2() {\n            let (before_point, after_point) = self.power_of_2_digits(log_base);\n            (before_point, RationalDigits::PowerOf2(after_point))\n        } else {\n            let mut remainder = self.abs();\n            let floor = (&remainder).floor().unsigned_abs();\n            remainder -= Self::from(&floor);\n            (\n                floor.to_digits_asc(base),\n                RationalDigits::General(RationalGeneralDigits {\n                    base: Self::from(base),\n                    remainder,\n                }),\n            )\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/digits/from_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{CheckedLogBase2, Pow};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::{Digits, ExactFrom};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_nz::natural::Natural;\n\nimpl Rational {\n    /// Converts base-$b$ digits to a [`Rational`]. The inputs are taken by value.\n    ///\n    /// The input consists of the digits of the integer portion of the [`Rational`] and the digits\n    /// of the fractional portion. The integer-portion digits are ordered from least- to\n    /// most-significant, and the fractional-portion digits from most- to least.\n    ///\n    /// The fractional-portion digits may end in infinitely many zeros or $(b-1)$s; these are\n    /// handled correctly.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm)^2 \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(before_point.len(),\n    /// after_point.component_len())`, and $m$ is `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let before_point = vec_from_str(\"[3]\").unwrap();\n    /// let after_point =\n    ///     RationalSequence::from_vecs(Vec::new(), vec_from_str(\"[1, 4, 2, 8, 5, 7]\").unwrap());\n    /// assert_eq!(\n    ///     Rational::from_digits(&Natural::from(10u32), before_point, after_point).to_string(),\n    ///     \"22/7\"\n    /// );\n    ///\n    /// // 21.34565656...\n    /// let before_point = vec_from_str(\"[1, 2]\").unwrap();\n    /// let after_point = RationalSequence::from_vecs(\n    ///     vec_from_str(\"[3, 4]\").unwrap(),\n    ///     vec_from_str(\"[5, 6]\").unwrap(),\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_digits(&Natural::from(10u32), before_point, after_point).to_string(),\n    ///     \"105661/4950\"\n    /// );\n    /// ```\n    pub fn from_digits(\n        base: &Natural,\n        before_point: Vec<Natural>,\n        after_point: RationalSequence<Natural>,\n    ) -> Self {\n        if let Some(log_base) = base.checked_log_base_2() {\n            return Self::from_power_of_2_digits(log_base, before_point, after_point);\n        }\n        let (non_repeating, repeating) = after_point.into_vecs();\n        let r_len = u64::exact_from(repeating.len());\n        let nr_len = u64::exact_from(non_repeating.len());\n        let nr = Natural::from_digits_asc(base, non_repeating.into_iter().rev()).unwrap();\n        let r = Natural::from_digits_asc(base, repeating.into_iter().rev()).unwrap();\n        let floor = Self::from(Natural::from_digits_asc(base, before_point.into_iter()).unwrap());\n        floor\n            + if r == 0u32 {\n                Self::from_naturals(nr, base.pow(nr_len))\n            } else {\n                (Self::from_naturals(r, base.pow(r_len) - Natural::ONE) + Self::from(nr))\n                    / Self::from(base.pow(nr_len))\n            }\n    }\n\n    /// Converts base-$b$ digits to a [`Rational`]. The inputs are taken by reference.\n    ///\n    /// The input consists of the digits of the integer portion of the [`Rational`] and the digits\n    /// of the fractional portion. The integer-portion digits are ordered from least- to\n    /// most-significant, and the fractional-portion digits from most- to least.\n    ///\n    /// The fractional-portion digits may end in infinitely many zeros or $(b-1)$s; these are\n    /// handled correctly.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm \\log (nm)^2 \\log\\log (nm))$\n    ///\n    /// $M(n, m) = O(nm \\log (nm))$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(before_point.len(),\n    /// after_point.component_len())`, and $m$ is `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let before_point = vec_from_str(\"[3]\").unwrap();\n    /// let after_point =\n    ///     RationalSequence::from_vecs(Vec::new(), vec_from_str(\"[1, 4, 2, 8, 5, 7]\").unwrap());\n    /// assert_eq!(\n    ///     Rational::from_digits_ref(&Natural::from(10u32), &before_point, &after_point)\n    ///         .to_string(),\n    ///     \"22/7\"\n    /// );\n    ///\n    /// // 21.34565656...\n    /// let before_point = vec_from_str(\"[1, 2]\").unwrap();\n    /// let after_point = RationalSequence::from_vecs(\n    ///     vec_from_str(\"[3, 4]\").unwrap(),\n    ///     vec_from_str(\"[5, 6]\").unwrap(),\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_digits_ref(&Natural::from(10u32), &before_point, &after_point)\n    ///         .to_string(),\n    ///     \"105661/4950\"\n    /// );\n    /// ```\n    pub fn from_digits_ref(\n        base: &Natural,\n        before_point: &[Natural],\n        after_point: &RationalSequence<Natural>,\n    ) -> Self {\n        if let Some(log_base) = base.checked_log_base_2() {\n            return Self::from_power_of_2_digits_ref(log_base, before_point, after_point);\n        }\n        let (non_repeating, repeating) = after_point.to_vecs();\n        let r_len = u64::exact_from(repeating.len());\n        let nr_len = u64::exact_from(non_repeating.len());\n        let nr = Natural::from_digits_asc(base, non_repeating.into_iter().rev()).unwrap();\n        let r = Natural::from_digits_asc(base, repeating.into_iter().rev()).unwrap();\n        let floor =\n            Self::from(Natural::from_digits_asc(base, before_point.iter().cloned()).unwrap());\n        floor\n            + if r == 0u32 {\n                Self::from_naturals(nr, base.pow(nr_len))\n            } else {\n                (Self::from_naturals(r, base.pow(r_len) - Natural::ONE) + Self::from(nr))\n                    / Self::from(base.pow(nr_len))\n            }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/digits/from_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse alloc::vec::Vec;\nuse malachite_base::num::conversion::traits::{ExactFrom, PowerOf2Digits};\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_nz::natural::Natural;\n\nimpl Rational {\n    /// Converts base-$2^k$ digits to a [`Rational`]. The inputs are taken by value.\n    ///\n    /// The input consists of the digits of the integer portion of the [`Rational`] and the digits\n    /// of the fractional portion. The integer-portion digits are ordered from least- to\n    /// most-significant, and the fractional-portion digits from most- to least.\n    ///\n    /// The fractional-portion digits may end in infinitely many zeros or $(2^k-1)$s; these are\n    /// handled correctly.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm)$\n    ///\n    /// $M(n, m) = O(nm)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(before_point.len(),\n    /// after_point.component_len())`, and $m$ is `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_q::Rational;\n    ///\n    /// let before_point = vec_from_str(\"[1, 1]\").unwrap();\n    /// let after_point = RationalSequence::from_vecs(\n    ///     vec_from_str(\"[0]\").unwrap(),\n    ///     vec_from_str(\"[0, 0, 1]\").unwrap(),\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_power_of_2_digits(1, before_point, after_point).to_string(),\n    ///     \"43/14\"\n    /// );\n    ///\n    /// // 21.34565656..._32\n    /// let before_point = vec_from_str(\"[1, 2]\").unwrap();\n    /// let after_point = RationalSequence::from_vecs(\n    ///     vec_from_str(\"[3, 4]\").unwrap(),\n    ///     vec_from_str(\"[5, 6]\").unwrap(),\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_power_of_2_digits(5, before_point, after_point).to_string(),\n    ///     \"34096673/523776\"\n    /// );\n    /// ```\n    pub fn from_power_of_2_digits(\n        log_base: u64,\n        before_point: Vec<Natural>,\n        after_point: RationalSequence<Natural>,\n    ) -> Self {\n        let (non_repeating, repeating) = after_point.into_vecs();\n        let r_len = u64::exact_from(repeating.len());\n        let nr_len = u64::exact_from(non_repeating.len());\n        let nr =\n            Natural::from_power_of_2_digits_asc(log_base, non_repeating.into_iter().rev()).unwrap();\n        let r = Natural::from_power_of_2_digits_asc(log_base, repeating.into_iter().rev()).unwrap();\n        let floor = Self::from(\n            Natural::from_power_of_2_digits_asc(log_base, before_point.into_iter()).unwrap(),\n        );\n        floor\n            + if r == 0u32 {\n                Self::from(nr) >> (log_base * nr_len)\n            } else {\n                (Self::from_naturals(r, Natural::low_mask(log_base * r_len)) + Self::from(nr))\n                    >> (log_base * nr_len)\n            }\n    }\n\n    /// Converts base-$2^k$ digits to a [`Rational`]. The inputs are taken by reference.\n    ///\n    /// The input consists of the digits of the integer portion of the [`Rational`] and the digits\n    /// of the fractional portion. The integer-portion digits are ordered from least- to\n    /// most-significant, and the fractional-portion digits from most- to least.\n    ///\n    /// The fractional-portion digits may end in infinitely many zeros or $(2^k-1)$s; these are\n    /// handled correctly.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(nm)$\n    ///\n    /// $M(n, m) = O(nm)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `max(before_point.len(),\n    /// after_point.component_len())`, and $m$ is `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::rational_sequences::RationalSequence;\n    /// use malachite_base::vecs::vec_from_str;\n    /// use malachite_q::Rational;\n    ///\n    /// let before_point = vec_from_str(\"[1, 1]\").unwrap();\n    /// let after_point = RationalSequence::from_vecs(\n    ///     vec_from_str(\"[0]\").unwrap(),\n    ///     vec_from_str(\"[0, 0, 1]\").unwrap(),\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_power_of_2_digits_ref(1, &before_point, &after_point).to_string(),\n    ///     \"43/14\"\n    /// );\n    ///\n    /// // 21.34565656..._32\n    /// let before_point = vec_from_str(\"[1, 2]\").unwrap();\n    /// let after_point = RationalSequence::from_vecs(\n    ///     vec_from_str(\"[3, 4]\").unwrap(),\n    ///     vec_from_str(\"[5, 6]\").unwrap(),\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_power_of_2_digits_ref(5, &before_point, &after_point).to_string(),\n    ///     \"34096673/523776\"\n    /// );\n    /// ```\n    pub fn from_power_of_2_digits_ref(\n        log_base: u64,\n        before_point: &[Natural],\n        after_point: &RationalSequence<Natural>,\n    ) -> Self {\n        let (non_repeating, repeating) = after_point.to_vecs();\n        let r_len = u64::exact_from(repeating.len());\n        let nr_len = u64::exact_from(non_repeating.len());\n        let nr =\n            Natural::from_power_of_2_digits_asc(log_base, non_repeating.into_iter().rev()).unwrap();\n        let r = Natural::from_power_of_2_digits_asc(log_base, repeating.into_iter().rev()).unwrap();\n        let floor = Self::from(\n            Natural::from_power_of_2_digits_asc(log_base, before_point.iter().cloned()).unwrap(),\n        );\n        floor\n            + if r == 0u32 {\n                Self::from(nr) >> (log_base * nr_len)\n            } else {\n                (Self::from_naturals(r, Natural::low_mask(log_base * r_len)) + Self::from(nr))\n                    >> (log_base * nr_len)\n            }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/digits/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Functions for producing iterators over the digits of a [`Rational`](crate::Rational).\n#[allow(clippy::module_inception)]\npub mod digits;\n/// Functions for constructing a [`Rational`](crate::Rational) from digits.\npub mod from_digits;\n/// Functions for constructing a [`Rational`](crate::Rational) from base-$2^k$ digits.\npub mod from_power_of_2_digits;\n/// Functions for producing iterators over the base-$2^k$ digits of a [`Rational`](crate::Rational).\npub mod power_of_2_digits;\n/// Functions for returning the digits of a [`Rational`](crate::Rational). The digits after the\n/// point are returned as a\n/// [`RationalSequence`](malachite_base::rational_sequences::RationalSequence).\npub mod to_digits;\n/// Functions for returning the base-$2^k$ digits of a [`Rational`](crate::Rational). The digits\n/// after the point are returned as a\n/// [`RationalSequence`](malachite_base::rational_sequences::RationalSequence).\npub mod to_power_of_2_digits;\n"
  },
  {
    "path": "malachite-q/src/conversion/digits/power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{Abs, Floor, UnsignedAbs};\nuse malachite_base::num::conversion::traits::PowerOf2Digits;\nuse malachite_nz::natural::Natural;\n\n/// Represents the base-$2^k$ digits of the fractional portion of a [`Rational`] number.\n///\n/// See [`power_of_2_digits`](Rational::power_of_2_digits) for more information.\n#[derive(Clone, Debug, Eq, PartialEq)]\npub struct RationalPowerOf2Digits {\n    log_base: u64,\n    remainder: Rational,\n}\n\nimpl Iterator for RationalPowerOf2Digits {\n    type Item = Natural;\n\n    fn next(&mut self) -> Option<Natural> {\n        if self.remainder == 0u32 {\n            None\n        } else {\n            self.remainder <<= self.log_base;\n            let digit = (&self.remainder).floor().unsigned_abs();\n            self.remainder -= Rational::from(&digit);\n            Some(digit)\n        }\n    }\n}\n\nimpl Rational {\n    /// Returns the base-$2^k$ digits of a [`Rational`].\n    ///\n    /// The output has two components. The first is a [`Vec`] of the digits of the integer portion\n    /// of the [`Rational`], least- to most-significant. The second is an iterator of the digits of\n    /// the fractional portion.\n    ///\n    /// The output is in its simplest form: the integer-portion digits do not end with a zero, and\n    /// the fractional-portion digits do not end with infinitely many zeros or $(2^k-1)$s.\n    ///\n    /// If the [`Rational`] has a small denominator, it may be more efficient to use\n    /// [`to_power_of_2_digits`](Rational::to_power_of_2_digits) or\n    /// [`into_power_of_2_digits`](Rational::into_power_of_2_digits) instead. These functions\n    /// compute the entire repeating portion of the repeating digits.\n    ///\n    /// For example, consider these two expressions:\n    /// - `Rational::from_signeds(1, 7).power_of_2_digits(1).1.nth(1000)`\n    /// - `Rational::from_signeds(1, 7).into_power_of_2_digits(1).1[1000]`\n    ///\n    /// Both get the thousandth digit after the binary point of `1/7`. The first way explicitly\n    /// calculates each bit after the binary point, whereas the second way determines that `1/7` is\n    /// `0.(001)`, with the `001` repeating, and takes `1000 % 3 == 1` to determine that the\n    /// thousandth bit is 0. But when the [`Rational`] has a large denominator, the second way is\n    /// less efficient.\n    ///\n    /// # Worst-case complexity per iteration\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(),\n    /// base)`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::iterators::prefix_to_string;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// let (before_point, after_point) = Rational::from(3u32).power_of_2_digits(1);\n    /// assert_eq!(before_point.to_debug_string(), \"[1, 1]\");\n    /// assert_eq!(prefix_to_string(after_point, 10), \"[]\");\n    ///\n    /// let (before_point, after_point) = Rational::from_signeds(22, 7).power_of_2_digits(1);\n    /// assert_eq!(before_point.to_debug_string(), \"[1, 1]\");\n    /// assert_eq!(\n    ///     prefix_to_string(after_point, 10),\n    ///     \"[0, 0, 1, 0, 0, 1, 0, 0, 1, 0, ...]\"\n    /// );\n    ///\n    /// let (before_point, after_point) = Rational::from_signeds(22, 7).power_of_2_digits(10);\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(\n    ///     prefix_to_string(after_point, 10),\n    ///     \"[146, 292, 585, 146, 292, 585, 146, 292, 585, 146, ...]\"\n    /// );\n    /// ```\n    pub fn power_of_2_digits(&self, log_base: u64) -> (Vec<Natural>, RationalPowerOf2Digits) {\n        let mut remainder = self.abs();\n        let floor = (&remainder).floor().unsigned_abs();\n        remainder -= Self::from(&floor);\n        (\n            floor.to_power_of_2_digits_asc(log_base),\n            RationalPowerOf2Digits {\n                log_base,\n                remainder,\n            },\n        )\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/digits/to_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::conversion::digits::to_power_of_2_digits::to_power_of_2_digits_helper;\nuse alloc::collections::BTreeMap;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{\n    Abs, AbsAssign, CheckedLogBase2, Floor, UnsignedAbs,\n};\nuse malachite_base::num::conversion::traits::Digits;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_nz::natural::Natural;\n\nfn to_digits_helper(x: Rational, base: &Natural) -> (Vec<Natural>, RationalSequence<Natural>) {\n    if let Some(log_base) = base.checked_log_base_2() {\n        return to_power_of_2_digits_helper(x, log_base);\n    }\n    let floor = (&x).floor();\n    let mut remainder = x - Rational::from(&floor);\n    let before_point = floor.unsigned_abs().to_digits_asc(base);\n    let mut state_map = BTreeMap::new();\n    let mut digits = Vec::new();\n    let base = Rational::from(base);\n    for i in 0.. {\n        if remainder == 0u32 {\n            return (before_point, RationalSequence::from_vec(digits));\n        }\n        if let Some(previous_i) = state_map.insert(remainder.clone(), i) {\n            let repeating = digits.drain(previous_i..).collect();\n            return (before_point, RationalSequence::from_vecs(digits, repeating));\n        }\n        remainder *= &base;\n        let floor = (&remainder).floor().unsigned_abs();\n        digits.push(floor.clone());\n        remainder -= Rational::from(floor);\n    }\n    unreachable!()\n}\n\nimpl Rational {\n    /// Returns the base-$b$ digits of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// The output has two components. The first is a [`Vec`] of the digits of the integer portion\n    /// of the [`Rational`], least- to most-significant. The second is a [`RationalSequence`] of the\n    /// digits of the fractional portion.\n    ///\n    /// The output is in its simplest form: the integer-portion digits do not end with a zero, and\n    /// the fractional-portion digits do not end with infinitely many zeros or $(b-1)$s.\n    ///\n    /// The fractional portion may be very large; the length of the repeating part may be almost as\n    /// large as the denominator. If the [`Rational`] has a large denominator, consider using\n    /// [`digits`](Rational::digits) instead, which returns an iterator. That function computes the\n    /// fractional digits lazily and doesn't need to compute the entire repeating part.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m2^n)$\n    ///\n    /// $M(n, m) = O(m2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let (before_point, after_point) = Rational::from(3u32).into_digits(&Natural::from(10u32));\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(after_point.to_string(), \"[]\");\n    ///\n    /// let (before_point, after_point) =\n    ///     Rational::from_signeds(22, 7).into_digits(&Natural::from(10u32));\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(after_point.to_string(), \"[[1, 4, 2, 8, 5, 7]]\");\n    /// ```\n    #[inline]\n    pub fn into_digits(mut self, base: &Natural) -> (Vec<Natural>, RationalSequence<Natural>) {\n        self.abs_assign();\n        to_digits_helper(self, base)\n    }\n\n    /// Returns the base-$b$ digits of a [`Rational`], taking the [`Rational`] by reference.\n    ///\n    /// The output has two components. The first is a [`Vec`] of the digits of the integer portion\n    /// of the [`Rational`], least- to most-significant. The second is a [`RationalSequence`] of the\n    /// digits of the fractional portion.\n    ///\n    /// The output is in its simplest form: the integer-portion digits do not end with a zero, and\n    /// the fractional-portion digits do not end with infinitely many zeros or $(b-1)$s.\n    ///\n    /// The fractional portion may be very large; the length of the repeating part may be almost as\n    /// large as the denominator. If the [`Rational`] has a large denominator, consider using\n    /// [`digits`](Rational::digits) instead, which returns an iterator. That function computes the\n    /// fractional digits lazily and doesn't need to compute the entire repeating part.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m2^n)$\n    ///\n    /// $M(n, m) = O(m2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `base.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let (before_point, after_point) = Rational::from(3u32).to_digits(&Natural::from(10u32));\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(after_point.to_string(), \"[]\");\n    ///\n    /// let (before_point, after_point) =\n    ///     Rational::from_signeds(22, 7).to_digits(&Natural::from(10u32));\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(after_point.to_string(), \"[[1, 4, 2, 8, 5, 7]]\");\n    /// ```\n    pub fn to_digits(&self, base: &Natural) -> (Vec<Natural>, RationalSequence<Natural>) {\n        to_digits_helper(self.abs(), base)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/digits/to_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse alloc::collections::BTreeMap;\nuse alloc::vec::Vec;\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign, Floor, UnsignedAbs};\nuse malachite_base::num::conversion::traits::PowerOf2Digits;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_nz::natural::Natural;\n\npub(crate) fn to_power_of_2_digits_helper(\n    x: Rational,\n    log_base: u64,\n) -> (Vec<Natural>, RationalSequence<Natural>) {\n    let floor = (&x).floor();\n    let mut remainder = x - Rational::from(&floor);\n    let before_point = floor.unsigned_abs().to_power_of_2_digits_asc(log_base);\n    let mut state_map = BTreeMap::new();\n    let mut digits = Vec::new();\n    for i in 0.. {\n        if remainder == 0u32 {\n            return (before_point, RationalSequence::from_vec(digits));\n        }\n        if let Some(previous_i) = state_map.insert(remainder.clone(), i) {\n            let repeating = digits.drain(previous_i..).collect();\n            return (before_point, RationalSequence::from_vecs(digits, repeating));\n        }\n        remainder <<= log_base;\n        let floor = (&remainder).floor().unsigned_abs();\n        digits.push(floor.clone());\n        remainder -= Rational::from(floor);\n    }\n    unreachable!()\n}\n\nimpl Rational {\n    /// Returns the base-$2^k$ digits of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// The output has two components. The first is a [`Vec`] of the digits of the integer portion\n    /// of the [`Rational`], least- to most-significant. The second is a [`RationalSequence`] of the\n    /// digits of the fractional portion.\n    ///\n    /// The output is in its simplest form: the integer-portion digits do not end with a zero, and\n    /// the fractional-portion digits do not end with infinitely many zeros or $(2^k-1)$s.\n    ///\n    /// The fractional portion may be very large; the length of the repeating part may be almost as\n    /// large as the denominator. If the [`Rational`] has a large denominator, consider using\n    /// [`power_of_2_digits`](Rational::power_of_2_digits) instead, which returns an iterator. That\n    /// function computes the fractional digits lazily and doesn't need to compute the entire\n    /// repeating part.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m2^n)$\n    ///\n    /// $M(n, m) = O(m2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `log_base`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// let (before_point, after_point) = Rational::from(3u32).into_power_of_2_digits(1);\n    /// assert_eq!(before_point.to_debug_string(), \"[1, 1]\");\n    /// assert_eq!(after_point.to_string(), \"[]\");\n    ///\n    /// let (before_point, after_point) = Rational::from_signeds(22, 7).into_power_of_2_digits(1);\n    /// assert_eq!(before_point.to_debug_string(), \"[1, 1]\");\n    /// assert_eq!(after_point.to_string(), \"[[0, 0, 1]]\");\n    ///\n    /// let (before_point, after_point) = Rational::from_signeds(22, 7).into_power_of_2_digits(10);\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(after_point.to_string(), \"[[146, 292, 585]]\");\n    /// ```\n    #[inline]\n    pub fn into_power_of_2_digits(\n        mut self,\n        log_base: u64,\n    ) -> (Vec<Natural>, RationalSequence<Natural>) {\n        self.abs_assign();\n        to_power_of_2_digits_helper(self, log_base)\n    }\n\n    /// Returns the base-$2^k$ digits of a [`Rational`], taking the [`Rational`] by reference.\n    ///\n    /// The output has two components. The first is a [`Vec`] of the digits of the integer portion\n    /// of the [`Rational`], least- to most-significant. The second is a [`RationalSequence`] of the\n    /// digits of the fractional portion.\n    ///\n    /// The output is in its simplest form: the integer-portion digits do not end with a zero, and\n    /// the fractional-portion digits do not end with infinitely many zeros or $(2^k-1)$s.\n    ///\n    /// The fractional portion may be very large; the length of the repeating part may be almost as\n    /// large as the denominator. If the [`Rational`] has a large denominator, consider using\n    /// [`power_of_2_digits`](Rational::power_of_2_digits) instead, which returns an iterator. That\n    /// function computes the fractional digits lazily and doesn't need to compute the entire\n    /// repeating part.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m2^n)$\n    ///\n    /// $M(n, m) = O(m2^n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `self.significant_bits()`, and $m$ is\n    /// `log_base`.\n    ///\n    /// # Panics\n    /// Panics if `log_base` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// let (before_point, after_point) = Rational::from(3u32).to_power_of_2_digits(1);\n    /// assert_eq!(before_point.to_debug_string(), \"[1, 1]\");\n    /// assert_eq!(after_point.to_string(), \"[]\");\n    ///\n    /// let (before_point, after_point) = Rational::from_signeds(22, 7).to_power_of_2_digits(1);\n    /// assert_eq!(before_point.to_debug_string(), \"[1, 1]\");\n    /// assert_eq!(after_point.to_string(), \"[[0, 0, 1]]\");\n    ///\n    /// let (before_point, after_point) = Rational::from_signeds(22, 7).to_power_of_2_digits(10);\n    /// assert_eq!(before_point.to_debug_string(), \"[3]\");\n    /// assert_eq!(after_point.to_string(), \"[[146, 292, 585]]\");\n    /// ```\n    pub fn to_power_of_2_digits(&self, log_base: u64) -> (Vec<Natural>, RationalSequence<Natural>) {\n        to_power_of_2_digits_helper(self.abs(), log_base)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::basic::traits::{One, Zero};\n\nimpl From<bool> for Rational {\n    /// Converts a [`bool`] to 0 or 1.\n    ///\n    /// This function is known as the [Iverson\n    /// bracket](https://en.wikipedia.org/wiki/Iverson_bracket).\n    ///\n    /// $$\n    /// f(P) = \\[P\\] = \\\\begin{cases}\n    ///     1 & \\text{if} \\\\quad P, \\\\\\\\\n    ///     0 & \\\\text{otherwise}.\n    /// \\\\end{cases}\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(false), 0);\n    /// assert_eq!(Rational::from(true), 1);\n    /// ```\n    #[inline]\n    fn from(b: bool) -> Self {\n        if b { Self::ONE } else { Self::ZERO }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/from_float_simplest.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::traits::SimplestRationalInInterval;\nuse crate::conversion::from_primitive_float::RationalFromPrimitiveFloatError;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::ExactFrom;\n\nimpl Rational {\n    /// Converts a primitive float to the simplest [`Rational`] that rounds to that value.\n    ///\n    /// To be more specific: Suppose the floating-point input is $x$. If $x$ is an integer, its\n    /// [`Rational`] equivalent is returned. Otherwise, this function finds $a$ and $b$, which are\n    /// the floating point predecessor and successor of $x$, and finds the simplest [`Rational`] in\n    /// the open interval $(\\frac{x + a}{2}, \\frac{x + b}{2})$. \"Simplicity\" refers to low\n    /// complexity. See [`Rational::cmp_complexity`] for a definition of complexity.\n    ///\n    /// For example, `0.1f32` is converted to $1/10$ rather than to the exact value of the float,\n    /// which is $13421773/134217728$. If you want the exact value, use `Rational::from` instead.\n    ///\n    /// If the floating point value is `NaN` or infinite, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2 \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.sci_exponent()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::conversion::from_primitive_float::RationalFromPrimitiveFloatError;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::try_from_float_simplest(0.0).to_debug_string(),\n    ///     \"Ok(0)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::try_from_float_simplest(1.5).to_debug_string(),\n    ///     \"Ok(3/2)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::try_from_float_simplest(-1.5).to_debug_string(),\n    ///     \"Ok(-3/2)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::try_from_float_simplest(0.1f32).to_debug_string(),\n    ///     \"Ok(1/10)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::try_from_float_simplest(0.33333334f32).to_debug_string(),\n    ///     \"Ok(1/3)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::try_from_float_simplest(f32::NAN),\n    ///     Err(RationalFromPrimitiveFloatError)\n    /// );\n    /// ```\n    pub fn try_from_float_simplest<T: PrimitiveFloat>(\n        x: T,\n    ) -> Result<Self, RationalFromPrimitiveFloatError>\n    where\n        Self: TryFrom<T, Error = RationalFromPrimitiveFloatError>,\n    {\n        let q = Self::try_from(x)?;\n        Ok(if *q.denominator_ref() <= 2u32 {\n            q\n        } else {\n            let succ_q = Self::exact_from(x.next_higher());\n            let pred_q = Self::exact_from(x.next_lower());\n            let x = (pred_q + &q) >> 1;\n            let y = (succ_q + q) >> 1;\n            Self::simplest_rational_in_open_interval(&x, &y)\n        })\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::traits::One;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nimpl From<Integer> for Rational {\n    /// Converts an [`Integer`] to a [`Rational`], taking the [`Integer`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(Integer::from(123)), 123);\n    /// assert_eq!(Rational::from(Integer::from(-123)), -123);\n    /// ```\n    fn from(value: Integer) -> Self {\n        Self {\n            sign: value >= 0,\n            numerator: value.unsigned_abs(),\n            denominator: Natural::ONE,\n        }\n    }\n}\n\nimpl From<&Integer> for Rational {\n    /// Converts an [`Integer`] to a [`Rational`], taking the [`Integer`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(&Integer::from(123)), 123);\n    /// assert_eq!(Rational::from(&Integer::from(-123)), -123);\n    /// ```\n    fn from(value: &Integer) -> Self {\n        Self {\n            sign: *value >= 0,\n            numerator: value.unsigned_abs(),\n            denominator: Natural::ONE,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::basic::traits::One;\nuse malachite_nz::natural::Natural;\n\nimpl From<Natural> for Rational {\n    /// Converts a [`Natural`] to a [`Rational`], taking the [`Natural`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(Natural::from(123u32)), 123);\n    /// ```\n    fn from(value: Natural) -> Self {\n        Self {\n            sign: true,\n            numerator: value,\n            denominator: Natural::ONE,\n        }\n    }\n}\n\nimpl From<&Natural> for Rational {\n    /// Converts a [`Natural`] to a [`Rational`], taking the [`Natural`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from(&Natural::from(123u32)), 123);\n    /// ```\n    fn from(value: &Natural) -> Self {\n        Self {\n            sign: true,\n            numerator: value.clone(),\n            denominator: Natural::ONE,\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/from_numerator_and_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{DivExact, Gcd, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\n\nmacro_rules! const_gcd_step {\n    ($x: ident, $y: ident) => {\n        let new_y = $x % $y;\n        $x = $y;\n        $y = new_y;\n        if $y == 0 {\n            return $x;\n        }\n    };\n}\n\n// Worst case when Limb = u64 is const_gcd(Fib_92, Fib_93) = const_gcd(7540113804746346429,\n// 12200160415121876738)\nconst fn const_gcd(mut x: Limb, mut y: Limb) -> Limb {\n    if y == 0 {\n        x\n    } else {\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        const_gcd_step!(x, y);\n        unreachable!()\n    }\n}\n\nimpl Rational {\n    /// Converts two[`Limb`](crate#limbs)s, representing a numerator and a denominator, to a\n    /// [`Rational`].\n    ///\n    /// If `denominator` is zero, `None` is returned.\n    ///\n    /// This function is const, so it may be used to define constants. When called at runtime, it is\n    /// slower than [`Rational::from_unsigneds`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// const TWO_THIRDS: Rational = Rational::const_from_unsigneds(2, 3);\n    /// assert_eq!(TWO_THIRDS, Rational::from_unsigneds(2u32, 3));\n    ///\n    /// const TWO_THIRDS_ALT: Rational = Rational::const_from_unsigneds(22, 33);\n    /// assert_eq!(TWO_THIRDS_ALT, Rational::from_unsigneds(2u32, 3));\n    /// ```\n    pub const fn const_from_unsigneds(numerator: Limb, denominator: Limb) -> Self {\n        assert!(denominator != 0);\n        let gcd = const_gcd(numerator, denominator);\n        Self {\n            sign: true,\n            numerator: Natural::const_from(numerator / gcd),\n            denominator: Natural::const_from(denominator / gcd),\n        }\n    }\n\n    /// Converts two[`SignedLimb`](crate#limbs)s, representing a numerator and a denominator, to a\n    /// [`Rational`].\n    ///\n    /// If `denominator` is zero, `None` is returned.\n    ///\n    /// This function is const, so it may be used to define constants. When called at runtime, it is\n    /// slower than [`Rational::from_signeds`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// const NEGATIVE_TWO_THIRDS: Rational = Rational::const_from_signeds(-2, 3);\n    /// assert_eq!(NEGATIVE_TWO_THIRDS, Rational::from_signeds(-2, 3));\n    ///\n    /// const NEGATIVE_TWO_THIRDS_ALT: Rational = Rational::const_from_signeds(-22, 33);\n    /// assert_eq!(NEGATIVE_TWO_THIRDS_ALT, Rational::from_signeds(-2, 3));\n    /// ```\n    pub const fn const_from_signeds(numerator: SignedLimb, denominator: SignedLimb) -> Self {\n        assert!(denominator != 0);\n        let sign = numerator == 0 || (numerator > 0) == (denominator > 0);\n        let numerator = numerator.unsigned_abs();\n        let denominator = denominator.unsigned_abs();\n        let gcd = const_gcd(numerator, denominator);\n        Self {\n            sign,\n            numerator: Natural::const_from(numerator / gcd),\n            denominator: Natural::const_from(denominator / gcd),\n        }\n    }\n\n    /// Converts two [`Natural`]s to a [`Rational`], taking the [`Natural`]s by value.\n    ///\n    /// The [`Natural`]s become the [`Rational`]'s numerator and denominator. Only non-negative\n    /// [`Rational`]s can be produced with this function.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input [`Natural`]s may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_naturals(Natural::from(4u32), Natural::from(6u32)).to_string(),\n    ///     \"2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_naturals(Natural::ZERO, Natural::from(6u32)),\n    ///     0\n    /// );\n    /// ```\n    pub fn from_naturals(numerator: Natural, denominator: Natural) -> Self {\n        assert_ne!(denominator, 0);\n        let gcd = (&numerator).gcd(&denominator);\n        Self {\n            sign: true,\n            numerator: numerator.div_exact(&gcd),\n            denominator: denominator.div_exact(gcd),\n        }\n    }\n\n    /// Converts two [`Natural`]s to a [`Rational`], taking the [`Natural`]s by reference.\n    ///\n    /// The [`Natural`]s become the [`Rational`]'s numerator and denominator. Only non-negative\n    /// [`Rational`]s can be produced with this function.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input [`Natural`]s may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_naturals_ref(&Natural::from(4u32), &Natural::from(6u32)).to_string(),\n    ///     \"2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_naturals_ref(&Natural::ZERO, &Natural::from(6u32)),\n    ///     0\n    /// );\n    /// ```\n    pub fn from_naturals_ref(numerator: &Natural, denominator: &Natural) -> Self {\n        assert_ne!(*denominator, 0);\n        let gcd = numerator.gcd(denominator);\n        Self {\n            sign: true,\n            numerator: numerator.div_exact(&gcd),\n            denominator: denominator.div_exact(gcd),\n        }\n    }\n\n    /// Converts two unsigned primitive integers to a [`Rational`].\n    ///\n    /// The integers become the [`Rational`]'s numerator and denominator. Only non-negative\n    /// [`Rational`]s can be produced with this function.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input integers may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from_unsigneds(4u32, 6).to_string(), \"2/3\");\n    /// assert_eq!(Rational::from_unsigneds(0u32, 6), 0);\n    /// ```\n    #[inline]\n    pub fn from_unsigneds<T: PrimitiveUnsigned>(numerator: T, denominator: T) -> Self\n    where\n        Natural: From<T>,\n    {\n        Self::from_naturals(Natural::from(numerator), Natural::from(denominator))\n    }\n\n    /// Converts two [`Integer`]s to a [`Rational`], taking the [`Integer`]s by value.\n    ///\n    /// The absolute values of the [`Integer`]s become the [`Rational`]'s numerator and denominator.\n    /// The sign of the [`Rational`] is the sign of the [`Integer`]s' quotient.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input [`Integer`]s may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_integers(Integer::from(4), Integer::from(6)).to_string(),\n    ///     \"2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_integers(Integer::from(4), Integer::from(-6)).to_string(),\n    ///     \"-2/3\"\n    /// );\n    /// assert_eq!(Rational::from_integers(Integer::ZERO, Integer::from(6)), 0);\n    /// assert_eq!(Rational::from_integers(Integer::ZERO, Integer::from(-6)), 0);\n    /// ```\n    pub fn from_integers(numerator: Integer, denominator: Integer) -> Self {\n        assert_ne!(denominator, 0);\n        let sign = numerator == 0 || ((numerator > 0) == (denominator > 0));\n        let mut q = Self::from_naturals(numerator.unsigned_abs(), denominator.unsigned_abs());\n        q.sign = sign;\n        q\n    }\n\n    /// Converts two [`Integer`]s to a [`Rational`], taking the [`Integer`]s by reference.\n    ///\n    /// The absolute values of the [`Integer`]s become the [`Rational`]'s numerator and denominator.\n    /// The sign of the [`Rational`] is the sign of the [`Integer`]s' quotient.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input [`Integer`]s may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_integers_ref(&Integer::from(4), &Integer::from(6)).to_string(),\n    ///     \"2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_integers_ref(&Integer::from(4), &Integer::from(-6)).to_string(),\n    ///     \"-2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_integers_ref(&Integer::ZERO, &Integer::from(6)),\n    ///     0\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_integers_ref(&Integer::ZERO, &Integer::from(-6)),\n    ///     0\n    /// );\n    /// ```\n    pub fn from_integers_ref(numerator: &Integer, denominator: &Integer) -> Self {\n        assert_ne!(*denominator, 0);\n        let mut q =\n            Self::from_naturals_ref(numerator.unsigned_abs_ref(), denominator.unsigned_abs_ref());\n        q.sign = *numerator == 0 || ((*numerator > 0) == (*denominator > 0));\n        q\n    }\n\n    /// Converts two signed primitive integers to a [`Rational]`.\n    ///\n    /// The absolute values of the integers become the [`Rational`]'s numerator and denominator. The\n    /// sign of the [`Rational`] is the sign of the integers' quotient.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input integers may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from_signeds(4i8, 6).to_string(), \"2/3\");\n    /// assert_eq!(Rational::from_signeds(4i8, -6).to_string(), \"-2/3\");\n    /// assert_eq!(Rational::from_signeds(0i8, 6), 0);\n    /// assert_eq!(Rational::from_signeds(0i8, -6), 0);\n    /// ```\n    #[inline]\n    pub fn from_signeds<T: PrimitiveSigned>(numerator: T, denominator: T) -> Self\n    where\n        Integer: From<T>,\n    {\n        Self::from_integers(Integer::from(numerator), Integer::from(denominator))\n    }\n\n    /// Converts a sign and two [`Natural`]s to a [`Rational`], taking the [`Natural`]s by value.\n    ///\n    /// The [`Natural`]s become the [`Rational`]'s numerator and denominator, and the sign indicates\n    /// whether the [`Rational`] should be non-negative. If the numerator is zero, then the\n    /// [`Rational`] will be non-negative regardless of the sign.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input [`Natural`]s may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_sign_and_naturals(true, Natural::from(4u32), Natural::from(6u32))\n    ///         .to_string(),\n    ///     \"2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sign_and_naturals(false, Natural::from(4u32), Natural::from(6u32))\n    ///         .to_string(),\n    ///     \"-2/3\"\n    /// );\n    /// ```\n    pub fn from_sign_and_naturals(sign: bool, numerator: Natural, denominator: Natural) -> Self {\n        assert_ne!(denominator, 0);\n        let gcd = (&numerator).gcd(&denominator);\n        Self {\n            sign: sign || numerator == 0,\n            numerator: numerator.div_exact(&gcd),\n            denominator: denominator.div_exact(gcd),\n        }\n    }\n\n    /// Converts a sign and two [`Natural`]s to a [`Rational`], taking the [`Natural`]s by\n    /// reference.\n    ///\n    /// The [`Natural`]s become the [`Rational`]'s numerator and denominator, and the sign indicates\n    /// whether the [`Rational`] should be non-negative. If the numerator is zero, then the\n    /// [`Rational`] will be non-negative regardless of the sign.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input [`Natural`]s may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_sign_and_naturals_ref(true, &Natural::from(4u32), &Natural::from(6u32))\n    ///         .to_string(),\n    ///     \"2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sign_and_naturals_ref(false, &Natural::from(4u32), &Natural::from(6u32))\n    ///         .to_string(),\n    ///     \"-2/3\"\n    /// );\n    /// ```\n    pub fn from_sign_and_naturals_ref(\n        sign: bool,\n        numerator: &Natural,\n        denominator: &Natural,\n    ) -> Self {\n        assert_ne!(*denominator, 0);\n        let gcd = numerator.gcd(denominator);\n        Self {\n            sign: sign || *numerator == 0,\n            numerator: numerator.div_exact(&gcd),\n            denominator: denominator.div_exact(gcd),\n        }\n    }\n\n    /// Converts a sign and two primitive unsigned integers to a [`Rational`].\n    ///\n    /// The integers become the [`Rational`]'s numerator and denominator, and the sign indicates\n    /// whether the [`Rational`] should be non-negative. If the numerator is zero, then the\n    /// [`Rational`] will be non-negative regardless of the sign.\n    ///\n    /// The denominator may not be zero.\n    ///\n    /// The input integers may have common factors; this function reduces them.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n^2)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(numerator.significant_bits(),\n    /// denominator.significant_bits())`.\n    ///\n    /// # Panics\n    /// Panics if `denominator` is zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_sign_and_unsigneds(true, 4u32, 6).to_string(),\n    ///     \"2/3\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sign_and_unsigneds(false, 4u32, 6).to_string(),\n    ///     \"-2/3\"\n    /// );\n    /// ```\n    pub fn from_sign_and_unsigneds<T: PrimitiveUnsigned>(\n        sign: bool,\n        numerator: T,\n        denominator: T,\n    ) -> Self\n    where\n        Natural: From<T>,\n    {\n        Self::from_sign_and_naturals(sign, Natural::from(numerator), Natural::from(denominator))\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, IntegerMantissaAndExponent};\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct RationalFromPrimitiveFloatError;\n\nmacro_rules! float_impls {\n    ($f: ident) => {\n        impl TryFrom<$f> for Rational {\n            type Error = RationalFromPrimitiveFloatError;\n\n            /// Converts a primitive float to the equivalent [`Rational`]. If the floating point\n            /// value is `NaN` or infinite, an error is returned.\n            ///\n            /// This conversion is literal. For example, `Rational::try_from(0.1f32)` evaluates to\n            /// Some($13421773/134217728$). If you want $1/10$ instead, use\n            /// [`try_from_float_simplest`](Rational::try_from_float_simplest); that function\n            /// returns the simplest [`Rational`] that rounds to the specified float.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is\n            /// `value.sci_exponent().abs()`.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#try_from).\n            fn try_from(value: $f) -> Result<Rational, Self::Error> {\n                if !value.is_finite() {\n                    Err(RationalFromPrimitiveFloatError)\n                } else if value == 0.0 {\n                    Ok(Rational::ZERO)\n                } else {\n                    let (mantissa, exponent) = value.integer_mantissa_and_exponent();\n                    let x = Rational::from(mantissa) << exponent;\n                    Ok(if value > 0.0 { x } else { -x })\n                }\n            }\n        }\n\n        impl ConvertibleFrom<$f> for Rational {\n            /// Determines whether a primitive float can be converted to a [`Rational`]. (It can if\n            /// it is finite.)\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_float#convertible_from).\n            fn convertible_from(x: $f) -> bool {\n                x.is_finite()\n            }\n        }\n    };\n}\napply_to_primitive_floats!(float_impls);\n"
  },
  {
    "path": "malachite-q/src/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::basic::traits::One;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\n\nimpl Rational {\n    /// Converts a [`Limb`](crate#limbs) to a [`Rational`].\n    ///\n    /// This function is const, so it may be used to define constants.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// const TEN: Rational = Rational::const_from_unsigned(10);\n    /// assert_eq!(TEN, 10);\n    /// ```\n    pub const fn const_from_unsigned(x: Limb) -> Self {\n        Self {\n            sign: true,\n            numerator: Natural::const_from(x),\n            denominator: Natural::ONE,\n        }\n    }\n\n    /// Converts a [`SignedLimb`](crate#limbs) to a [`Rational`].\n    ///\n    /// This function is const, so it may be used to define constants.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// const TEN: Rational = Rational::const_from_signed(10);\n    /// assert_eq!(TEN, 10);\n    ///\n    /// const NEGATIVE_TEN: Rational = Rational::const_from_signed(-10);\n    /// assert_eq!(NEGATIVE_TEN, -10);\n    /// ```\n    pub const fn const_from_signed(x: SignedLimb) -> Self {\n        Self {\n            sign: x >= 0,\n            numerator: Natural::const_from(x.unsigned_abs()),\n            denominator: Natural::ONE,\n        }\n    }\n}\n\nmacro_rules! impl_from_unsigned {\n    ($t: ident) => {\n        impl From<$t> for Rational {\n            /// Converts an unsigned primitive integer to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(u: $t) -> Rational {\n                Rational {\n                    sign: true,\n                    numerator: Natural::from(u),\n                    denominator: Natural::ONE,\n                }\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_from_unsigned);\n\nmacro_rules! impl_from_signed {\n    ($t: ident) => {\n        impl From<$t> for Rational {\n            /// Converts a signed primitive integer to a [`Rational`].\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::from_primitive_int#from).\n            #[inline]\n            fn from(i: $t) -> Rational {\n                Rational {\n                    sign: i >= 0,\n                    numerator: Natural::from(i.unsigned_abs()),\n                    denominator: Natural::ONE,\n                }\n            }\n        }\n    };\n}\napply_to_signeds!(impl_from_signed);\n"
  },
  {
    "path": "malachite-q/src/conversion/integer_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering;\nuse malachite_base::num::arithmetic::traits::DivRound;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_nz::integer::Integer;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct IntegerFromRationalError;\n\nimpl TryFrom<Rational> for Integer {\n    type Error = IntegerFromRationalError;\n\n    /// Converts a [`Rational`] to an [`Integer`], taking the [`Rational`] by value. If the\n    /// [`Rational`] is not an integer, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::conversion::integer_from_rational::IntegerFromRationalError;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Integer::try_from(Rational::from(123)).unwrap(), 123);\n    /// assert_eq!(Integer::try_from(Rational::from(-123)).unwrap(), -123);\n    /// assert_eq!(\n    ///     Integer::try_from(Rational::from_signeds(22, 7)),\n    ///     Err(IntegerFromRationalError)\n    /// );\n    /// ```\n    fn try_from(x: Rational) -> Result<Self, Self::Error> {\n        if x.denominator == 1u32 {\n            Ok(Self::from_sign_and_abs(x.sign, x.numerator))\n        } else {\n            Err(IntegerFromRationalError)\n        }\n    }\n}\n\nimpl TryFrom<&Rational> for Integer {\n    type Error = IntegerFromRationalError;\n\n    /// Converts a [`Rational`] to an [`Integer`], taking the [`Rational`] by reference. If the\n    /// [`Rational`] is not an integer, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::conversion::integer_from_rational::IntegerFromRationalError;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Integer::try_from(&Rational::from(123)).unwrap(), 123);\n    /// assert_eq!(Integer::try_from(&Rational::from(-123)).unwrap(), -123);\n    /// assert_eq!(\n    ///     Integer::try_from(&Rational::from_signeds(22, 7)),\n    ///     Err(IntegerFromRationalError)\n    /// );\n    /// ```\n    fn try_from(x: &Rational) -> Result<Self, Self::Error> {\n        if x.denominator == 1u32 {\n            Ok(Self::from_sign_and_abs_ref(x.sign, &x.numerator))\n        } else {\n            Err(IntegerFromRationalError)\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Rational> for Integer {\n    /// Determines whether a [`Rational`] can be converted to an [`Integer`], taking the\n    /// [`Rational`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Integer::convertible_from(&Rational::from(123)), true);\n    /// assert_eq!(Integer::convertible_from(&Rational::from(-123)), true);\n    /// assert_eq!(\n    ///     Integer::convertible_from(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn convertible_from(x: &Rational) -> bool {\n        x.denominator == 1u32\n    }\n}\n\nimpl RoundingFrom<Rational> for Integer {\n    /// Converts a [`Rational`] to an [`Integer`], using a specified [`RoundingMode`] and taking the\n    /// [`Rational`] by value. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Rational`] is not an integer and `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from(123), Exact).to_debug_string(),\n    ///     \"(123, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from(-123), Exact).to_debug_string(),\n    ///     \"(-123, Equal)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(22, 7), Floor).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(22, 7), Down).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(22, 7), Ceiling).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(22, 7), Up).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(22, 7), Nearest).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Floor).to_debug_string(),\n    ///     \"(-4, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Down).to_debug_string(),\n    ///     \"(-3, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Ceiling).to_debug_string(),\n    ///     \"(-3, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Up).to_debug_string(),\n    ///     \"(-4, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Nearest).to_debug_string(),\n    ///     \"(-3, Greater)\"\n    /// );\n    /// ```\n    fn rounding_from(x: Rational, rm: RoundingMode) -> (Self, Ordering) {\n        let s = x.sign;\n        let (n, o) = x\n            .numerator\n            .div_round(x.denominator, if s { rm } else { -rm });\n        (\n            Self::from_sign_and_abs(x.sign, n),\n            if s { o } else { o.reverse() },\n        )\n    }\n}\n\nimpl RoundingFrom<&Rational> for Integer {\n    /// Converts a [`Rational`] to an [`Integer`], using a specified [`RoundingMode`] and taking the\n    /// [`Rational`] by reference. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Rational`] is not an integer and `rm` is `Exact`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::integer::Integer;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Rational::from(123), Exact).to_debug_string(),\n    ///     \"(123, Equal)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Rational::from(-123), Exact).to_debug_string(),\n    ///     \"(-123, Equal)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Rational::from_signeds(22, 7), Floor).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Rational::from_signeds(22, 7), Down).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Rational::from_signeds(22, 7), Ceiling).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Rational::from_signeds(22, 7), Up).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(&Rational::from_signeds(22, 7), Nearest).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Floor).to_debug_string(),\n    ///     \"(-4, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Down).to_debug_string(),\n    ///     \"(-3, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Ceiling).to_debug_string(),\n    ///     \"(-3, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Up).to_debug_string(),\n    ///     \"(-4, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Integer::rounding_from(Rational::from_signeds(-22, 7), Nearest).to_debug_string(),\n    ///     \"(-3, Greater)\"\n    /// );\n    /// ```\n    fn rounding_from(x: &Rational, rm: RoundingMode) -> (Self, Ordering) {\n        let (n, o) = (&x.numerator).div_round(&x.denominator, if x.sign { rm } else { -rm });\n        (\n            Self::from_sign_and_abs(x.sign, n),\n            if x.sign { o } else { o.reverse() },\n        )\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::conversion::traits::IsInteger;\n\nimpl IsInteger for &Rational {\n    /// Determines whether a [`Rational`] is an integer.\n    ///\n    /// $f(x) = x \\in \\Z$.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::{One, Zero};\n    /// use malachite_base::num::conversion::traits::IsInteger;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ZERO.is_integer(), true);\n    /// assert_eq!(Rational::ONE.is_integer(), true);\n    /// assert_eq!(Rational::from(100).is_integer(), true);\n    /// assert_eq!(Rational::from(-100).is_integer(), true);\n    /// assert_eq!(Rational::from_signeds(22, 7).is_integer(), false);\n    /// assert_eq!(Rational::from_signeds(-22, 7).is_integer(), false);\n    /// ```\n    #[inline]\n    fn is_integer(self) -> bool {\n        self.denominator == 1u32\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::DivRound;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, IntegerMantissaAndExponent, SciMantissaAndExponent, WrappingFrom,\n};\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\nimpl Rational {\n    /// Returns a [`Rational`]'s scientific mantissa and exponent, taking the [`Rational`] by value.\n    /// An [`Ordering`] is also returned, indicating whether the returned mantissa and exponent\n    /// represent a value that is less than, equal to, or greater than the absolute value of the\n    /// [`Rational`].\n    ///\n    /// The [`Rational`]'s sign is ignored. This means that, for example, that rounding using\n    /// `Floor` is  equivalent to rounding using `Down`, even if the [`Rational`] is negative.\n    ///\n    /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is\n    /// a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa as a float. The\n    /// conversion might not be exact, so we round to the nearest float using the provided rounding\n    /// mode. If the rounding mode is `Exact` but the conversion is not exact, `None` is returned.\n    /// $$\n    /// f(x, r) \\approx \\left (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}},\n    ///     \\lfloor \\log_2 x \\rfloor\\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::float::NiceFloat;\n    /// use malachite_base::rounding_modes::RoundingMode::{self, *};\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::{self, *};\n    ///\n    /// let test = |n: Rational, rm: RoundingMode, out: Option<(f32, i64, Ordering)>| {\n    ///     assert_eq!(\n    ///         n.sci_mantissa_and_exponent_round(rm)\n    ///             .map(|(m, e, o)| (NiceFloat(m), e, o)),\n    ///         out.map(|(m, e, o)| (NiceFloat(m), e, o))\n    ///     );\n    /// };\n    /// test(Rational::from(3u32), Down, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Ceiling, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Up, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Nearest, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Exact, Some((1.5, 1, Equal)));\n    ///\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Floor,\n    ///     Some((1.3333333, -2, Less)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Down,\n    ///     Some((1.3333333, -2, Less)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Ceiling,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Up,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Nearest,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(Rational::from_signeds(1, 3), Exact, None);\n    ///\n    /// test(\n    ///     Rational::from_signeds(-1, 3),\n    ///     Floor,\n    ///     Some((1.3333333, -2, Less)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(-1, 3),\n    ///     Down,\n    ///     Some((1.3333333, -2, Less)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(-1, 3),\n    ///     Ceiling,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(-1, 3),\n    ///     Up,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(-1, 3),\n    ///     Nearest,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(Rational::from_signeds(-1, 3), Exact, None);\n    /// ```\n    pub fn sci_mantissa_and_exponent_round<T: PrimitiveFloat>(\n        mut self,\n        rm: RoundingMode,\n    ) -> Option<(T, i64, Ordering)> {\n        assert!(self != 0);\n        let mut exponent = i64::exact_from(self.numerator.significant_bits())\n            - i64::exact_from(self.denominator.significant_bits());\n        if self.numerator.cmp_normalized(&self.denominator) == Less {\n            exponent -= 1;\n        }\n        self >>= exponent - i64::wrapping_from(T::MANTISSA_WIDTH);\n        let (n, d) = self.into_numerator_and_denominator();\n        if rm == Exact && d != 1u32 {\n            return None;\n        }\n        let (mut mantissa, o) = n.div_round(d, rm);\n        let mut bits = mantissa.significant_bits();\n        if bits > T::MANTISSA_WIDTH + 1 {\n            bits -= 1;\n            mantissa >>= 1;\n            exponent += 1;\n        }\n        assert_eq!(bits, T::MANTISSA_WIDTH + 1);\n        mantissa.clear_bit(T::MANTISSA_WIDTH);\n        Some((\n            T::from_raw_mantissa_and_exponent(\n                u64::exact_from(&mantissa),\n                u64::wrapping_from(T::MAX_EXPONENT),\n            ),\n            exponent,\n            o,\n        ))\n    }\n\n    /// Returns a [`Rational`]'s scientific mantissa and exponent, taking the [`Rational`] by\n    /// reference. An [`Ordering`] is also returned, indicating whether the returned mantissa and\n    /// exponent represent a value that is less than, equal to, or greater than the original value.\n    ///\n    /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and $m_s$ is\n    /// a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa as a float. The\n    /// conversion might not be exact, so we round to the nearest float using the provided rounding\n    /// mode. If the rounding mode is `Exact` but the conversion is not exact, `None` is returned.\n    /// $$\n    /// f(x, r) \\approx \\left (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}},\n    ///     \\lfloor \\log_2 x \\rfloor\\right ).\n    /// $$\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::float::NiceFloat;\n    /// use malachite_base::rounding_modes::RoundingMode::{self, *};\n    /// use malachite_q::Rational;\n    /// use std::cmp::Ordering::{self, *};\n    ///\n    /// let test = |n: Rational, rm: RoundingMode, out: Option<(f32, i64, Ordering)>| {\n    ///     assert_eq!(\n    ///         n.sci_mantissa_and_exponent_round_ref(rm)\n    ///             .map(|(m, e, o)| (NiceFloat(m), e, o)),\n    ///         out.map(|(m, e, o)| (NiceFloat(m), e, o))\n    ///     );\n    /// };\n    /// test(Rational::from(3u32), Down, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Ceiling, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Up, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Nearest, Some((1.5, 1, Equal)));\n    /// test(Rational::from(3u32), Exact, Some((1.5, 1, Equal)));\n    ///\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Floor,\n    ///     Some((1.3333333, -2, Less)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Down,\n    ///     Some((1.3333333, -2, Less)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Ceiling,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Up,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(\n    ///     Rational::from_signeds(1, 3),\n    ///     Nearest,\n    ///     Some((1.3333334, -2, Greater)),\n    /// );\n    /// test(Rational::from_signeds(1, 3), Exact, None);\n    /// ```\n    pub fn sci_mantissa_and_exponent_round_ref<T: PrimitiveFloat>(\n        &self,\n        rm: RoundingMode,\n    ) -> Option<(T, i64, Ordering)> {\n        assert!(*self != 0);\n        let mut exponent = i64::exact_from(self.numerator.significant_bits())\n            - i64::exact_from(self.denominator.significant_bits());\n        if self.numerator.cmp_normalized(&self.denominator) == Less {\n            exponent -= 1;\n        }\n        let x = self >> (exponent - i64::wrapping_from(T::MANTISSA_WIDTH));\n        let (n, d) = x.into_numerator_and_denominator();\n        if rm == Exact && d != 1u32 {\n            return None;\n        }\n        let (mut mantissa, o) = n.div_round(d, rm);\n        let mut bits = mantissa.significant_bits();\n        if bits > T::MANTISSA_WIDTH + 1 {\n            bits -= 1;\n            mantissa >>= 1;\n            exponent += 1;\n        }\n        assert_eq!(bits, T::MANTISSA_WIDTH + 1);\n        mantissa.clear_bit(T::MANTISSA_WIDTH);\n        Some((\n            T::from_raw_mantissa_and_exponent(\n                u64::exact_from(&mantissa),\n                u64::wrapping_from(T::MAX_EXPONENT),\n            ),\n            exponent,\n            o,\n        ))\n    }\n}\n\nmacro_rules! impl_mantissa_and_exponent {\n    ($t:ident) => {\n        impl SciMantissaAndExponent<$t, i64> for Rational {\n            /// Returns a [`Rational`]'s scientific mantissa and exponent, taking the [`Rational`]\n            /// by value.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa\n            /// as a float. The conversion might not be exact, so we round to the nearest float\n            /// using the `Nearest` rounding mode. To use other rounding modes, use\n            /// [`sci_mantissa_and_exponent_round`](Rational::sci_mantissa_and_exponent_round).\n            /// $$\n            /// f(x) \\approx (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}, \\lfloor \\log_2 x \\rfloor).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_mantissa_and_exponent).\n            #[inline]\n            fn sci_mantissa_and_exponent(self) -> ($t, i64) {\n                let (m, e, _) = self.sci_mantissa_and_exponent_round(Nearest).unwrap();\n                (m, e)\n            }\n\n            /// Returns a [`Rational`]'s scientific exponent, taking the [`Rational`] by value.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa\n            /// as a float. The conversion might not be exact, so we round to the nearest float\n            /// using the `Nearest` rounding mode. To use other rounding modes, use\n            /// [`sci_mantissa_and_exponent_round`](Rational::sci_mantissa_and_exponent_round).\n            /// $$\n            /// f(x) \\approx \\lfloor \\log_2 x \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_exponent).\n            fn sci_exponent(mut self) -> i64 {\n                assert!(self != 0);\n                let mut exponent = i64::exact_from(self.numerator.significant_bits())\n                    - i64::exact_from(self.denominator.significant_bits());\n                if self.numerator.cmp_normalized(&self.denominator) == Less {\n                    exponent -= 1;\n                }\n                self >>= exponent - i64::wrapping_from($t::MANTISSA_WIDTH);\n                let (n, d) = self.into_numerator_and_denominator();\n                if n.div_round(d, Nearest).0.significant_bits() > $t::MANTISSA_WIDTH + 1 {\n                    exponent + 1\n                } else {\n                    exponent\n                }\n            }\n\n            /// Constructs a [`Rational`] from its scientific mantissa and exponent.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. Here, the rational mantissa is\n            /// provided as a float. If the mantissa is outside the range $[1, 2)$, `None` is\n            /// returned.\n            ///\n            /// All finite floats can be represented using [`Rational`]s, so no rounding is needed.\n            ///\n            /// $$\n            /// f(x) \\approx 2^{e_s}m_s.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `sci_exponent`.\n            #[allow(clippy::manual_range_contains)]\n            #[inline]\n            fn from_sci_mantissa_and_exponent(\n                sci_mantissa: $t,\n                sci_exponent: i64,\n            ) -> Option<Rational> {\n                assert_ne!(sci_mantissa, 0.0);\n                if sci_mantissa < 1.0 || sci_mantissa >= 2.0 {\n                    None\n                } else {\n                    let m = sci_mantissa.integer_mantissa();\n                    Some(\n                        Rational::from(m)\n                            << (sci_exponent - i64::exact_from(m.significant_bits()) + 1),\n                    )\n                }\n            }\n        }\n\n        impl SciMantissaAndExponent<$t, i64, Rational> for &Rational {\n            /// Returns a [`Rational`]'s scientific mantissa and exponent, taking the [`Rational`]\n            /// by reference.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa\n            /// as a float. The conversion might not be exact, so we round to the nearest float\n            /// using the `Nearest` rounding mode. To use other rounding modes, use\n            /// [`sci_mantissa_and_exponent_round`](Rational::sci_mantissa_and_exponent_round).\n            /// $$\n            /// f(x) \\approx (\\frac{x}{2^{\\lfloor \\log_2 x \\rfloor}}, \\lfloor \\log_2 x \\rfloor).\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::mantissa_and_exponent#sci_mantissa_and_exponent).\n            #[inline]\n            fn sci_mantissa_and_exponent(self) -> ($t, i64) {\n                let (m, e, _) = self.sci_mantissa_and_exponent_round_ref(Nearest).unwrap();\n                (m, e)\n            }\n\n            /// Returns a [`Rational`]'s scientific exponent, taking the [`Rational`] by reference.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. We represent the rational mantissa\n            /// as a float. The conversion might not be exact, so we round to the nearest float\n            /// using the `Nearest` rounding mode. To use other rounding modes, use\n            /// [`sci_mantissa_and_exponent_round`](Rational::sci_mantissa_and_exponent_round).\n            /// $$\n            /// f(x) \\approx \\lfloor \\log_2 x \\rfloor.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n            fn sci_exponent(self) -> i64 {\n                assert!(*self != 0);\n                let mut exponent = i64::exact_from(self.numerator.significant_bits())\n                    - i64::exact_from(self.denominator.significant_bits());\n                if self.numerator.cmp_normalized(&self.denominator) == Less {\n                    exponent -= 1;\n                }\n                let x = self >> exponent - i64::wrapping_from($t::MANTISSA_WIDTH);\n                let (n, d) = x.into_numerator_and_denominator();\n                if n.div_round(d, Nearest).0.significant_bits() > $t::MANTISSA_WIDTH + 1 {\n                    exponent + 1\n                } else {\n                    exponent\n                }\n            }\n\n            /// Constructs a [`Rational`] from its scientific mantissa and exponent.\n            ///\n            /// When $x$ is positive, we can write $x = 2^{e_s}m_s$, where $e_s$ is an integer and\n            /// $m_s$ is a rational number with $1 \\leq m_s < 2$. Here, the rational mantissa is\n            /// provided as a float. If the mantissa is outside the range $[1, 2)$, `None` is\n            /// returned.\n            ///\n            /// All finite floats can be represented using [`Rational`]s, so no rounding is needed.\n            ///\n            /// $$\n            /// f(x) \\approx 2^{e_s}m_s.\n            /// $$\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `sci_exponent`.\n            ///\n            /// See [here](super::mantissa_and_exponent#from_sci_mantissa_and_exponent).\n            #[inline]\n            fn from_sci_mantissa_and_exponent(\n                sci_mantissa: $t,\n                sci_exponent: i64,\n            ) -> Option<Rational> {\n                Rational::from_sci_mantissa_and_exponent(sci_mantissa, sci_exponent)\n            }\n        }\n    };\n}\napply_to_primitive_floats!(impl_mantissa_and_exponent);\n"
  },
  {
    "path": "malachite-q/src/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of traits for converting [`Rational`](crate::Rational)s to and from continued\n/// fractions.\npub mod continued_fraction;\n/// Implementations of traits for working with the digits of [`Rational`](crate::Rational)s.\npub mod digits;\n/// An implementation of the [`From`] trait for converting a [`bool`] to a\n/// [`Rational`](crate::Rational).\npub mod from_bool;\n/// Functions for converting a primitive float to a [`Rational`](crate::Rational), choosing the\n/// [`Rational`](crate::Rational) with minimal denominator that rounds to the given float.\npub mod from_float_simplest;\n/// Implementations of the [`From`] trait for converting an\n/// [`Integer`](malachite_nz::integer::Integer) to a [`Rational`](crate::Rational).\npub mod from_integer;\n/// Implementations of the [`From`] trait for converting a\n/// [`Integer`](malachite_nz::natural::Natural) to a [`Rational`](crate::Rational).\npub mod from_natural;\n/// Functions for constructing a [`Rational`](crate::Rational) from a numerator and denominator, or\n/// from a sign, numerator, and denominator.\npub mod from_numerator_and_denominator;\n/// Implementations of traits for converting a primitive float to a [`Rational`](crate::Rational).\n///\n/// The traits are [`TryFrom`] and\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom).\n///\n/// # try_from\n/// ```\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_q::conversion::from_primitive_float::RationalFromPrimitiveFloatError;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(Rational::try_from(0.0).to_debug_string(), \"Ok(0)\");\n/// assert_eq!(Rational::try_from(1.5).to_debug_string(), \"Ok(3/2)\");\n/// assert_eq!(Rational::try_from(-1.5).to_debug_string(), \"Ok(-3/2)\");\n/// assert_eq!(\n///     Rational::try_from(0.1f32).to_debug_string(),\n///     \"Ok(13421773/134217728)\"\n/// );\n/// assert_eq!(\n///     Rational::try_from(f32::NAN),\n///     Err(RationalFromPrimitiveFloatError)\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(Rational::convertible_from(0.0), true);\n/// assert_eq!(Rational::convertible_from(1.5), true);\n/// assert_eq!(Rational::convertible_from(-1.5), true);\n/// assert_eq!(Rational::convertible_from(0.1f32), true);\n///\n/// assert_eq!(Rational::convertible_from(f32::NAN), false);\n/// assert_eq!(Rational::convertible_from(f32::INFINITY), false);\n/// ```\npub mod from_primitive_float;\n/// Implementations of the [`From`] trait for converting a primitive integer to a\n/// [`Rational`](crate::Rational).\n///\n/// # from\n/// ```\n/// use malachite_q::Rational;\n///\n/// assert_eq!(Rational::from(123u32), 123);\n/// assert_eq!(Rational::from(-123i32), -123);\n/// ```\npub mod from_primitive_int;\n/// Implementations of traits for converting a [`Rational`](crate::Rational) to an\n/// [`Integer`](malachite_nz::integer::Integer).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\npub mod integer_from_rational;\n/// An implementation of [`IsInteger`](malachite_base::num::conversion::traits::IsInteger), a trait\n/// for determining whether a number is an integer.\npub mod is_integer;\n/// An implementation of\n/// [`SciMantissaAndExponent`](malachite_base::num::conversion::traits::SciMantissaAndExponent), a\n/// trait for converting numbers to and from a mantissa-and-exponent representation.\n///\n/// See [`PrimitiveFloat`](malachite_base::num::basic::floats::PrimitiveFloat) for a description of\n/// the different types of mantissas and exponents.\n///\n/// # sci_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_q::Rational;\n///\n/// let test = |n: Rational, mantissa: f32, exponent: i64| {\n///     let (m, e) = n.clone().sci_mantissa_and_exponent();\n///     assert_eq!(NiceFloat(m), NiceFloat(mantissa));\n///     assert_eq!(e, exponent);\n///\n///     let (m, e) = (&n).sci_mantissa_and_exponent();\n///     assert_eq!(NiceFloat(m), NiceFloat(mantissa));\n///     assert_eq!(e, exponent);\n/// };\n/// test(Rational::from(3u32), 1.5, 1);\n/// test(Rational::from(123u32), 1.921875, 6);\n/// test(Rational::from_signeds(1, 123), 1.0406504, -7);\n/// test(Rational::from_signeds(22, 7), 1.5714285, 1);\n/// ```\n///\n/// # from_sci_mantissa_and_exponent\n/// ```\n/// use malachite_base::num::conversion::traits::SciMantissaAndExponent;\n/// use malachite_q::Rational;\n///\n/// let test = |mantissa: f32, exponent: i64, out: Option<Rational>| {\n///     assert_eq!(\n///         <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n///             mantissa, exponent\n///         ),\n///         out\n///     );\n///\n///     assert_eq!(\n///         <Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n///             mantissa, exponent\n///         ),\n///         out\n///     );\n/// };\n/// test(1.5, 1, Some(Rational::from(3u32)));\n/// test(1.51, 1, Some(Rational::from_signeds(6333399, 2097152)));\n/// test(1.921875, 6, Some(Rational::from(123u32)));\n///\n/// test(2.0, 1, None);\n/// test(10.0, 1, None);\n/// test(0.5, 1, None);\n/// ```\npub mod mantissa_and_exponent;\n/// Functions for mutating a [`Rational`](crate::Rational)'s numerator and/or denominator in place.\npub mod mutate_numerator_and_denominator;\n/// Implementations of traits for converting a [`Rational`](crate::Rational) to a\n/// [`Natural`](malachite_nz::natural::Natural).\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\npub mod natural_from_rational;\n/// Functions and implementations of traits for converting a [`Rational`](crate::Rational) to a\n/// primitive float.\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # rounding_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::PowerOf2;\n/// use malachite_base::num::basic::floats::PrimitiveFloat;\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::num::float::NiceFloat;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_q::Rational;\n/// use std::cmp::Ordering::*;\n///\n/// let one_third = Rational::from_signeds(1i8, 3);\n/// assert_eq!(\n///     f32::rounding_from(one_third.clone(), Floor),\n///     (0.3333333, Less)\n/// );\n/// assert_eq!(\n///     f32::rounding_from(one_third, Ceiling),\n///     (0.33333334, Greater)\n/// );\n/// assert_eq!(f32::rounding_from(Rational::ONE_HALF, Exact), (0.5, Equal));\n/// let big = Rational::power_of_2(200u64);\n/// assert_eq!(\n///     f32::rounding_from(big.clone(), Down),\n///     (f32::MAX_FINITE, Less)\n/// );\n/// assert_eq!(f32::rounding_from(big, Up), (f32::INFINITY, Greater));\n/// let small = Rational::power_of_2(-200i64);\n/// let (rounded, o) = f32::rounding_from(small.clone(), Down);\n/// assert_eq!(NiceFloat(rounded), NiceFloat(0.0));\n/// assert_eq!(o, Less);\n/// assert_eq!(\n///     f32::rounding_from(small.clone(), Up),\n///     (f32::MIN_POSITIVE_SUBNORMAL, Greater)\n/// );\n/// let (rounded, o) = f32::rounding_from(-&small, Down);\n/// assert_eq!(NiceFloat(rounded), NiceFloat(-0.0));\n/// assert_eq!(o, Greater);\n/// assert_eq!(\n///     f32::rounding_from(-small, Up),\n///     (-f32::MIN_POSITIVE_SUBNORMAL, Less)\n/// );\n///\n/// let one_third = Rational::from_signeds(1i8, 3);\n/// assert_eq!(f32::rounding_from(&one_third, Floor), (0.3333333, Less));\n/// assert_eq!(\n///     f32::rounding_from(&one_third, Ceiling),\n///     (0.33333334, Greater)\n/// );\n/// assert_eq!(f32::rounding_from(&Rational::ONE_HALF, Exact), (0.5, Equal));\n/// let big = Rational::power_of_2(200u64);\n/// assert_eq!(f32::rounding_from(&big, Down), (f32::MAX_FINITE, Less));\n/// assert_eq!(f32::rounding_from(&big, Up), (f32::INFINITY, Greater));\n/// let small = Rational::power_of_2(-200i64);\n/// let (rounded, o) = f32::rounding_from(small.clone(), Down);\n/// assert_eq!(NiceFloat(rounded), NiceFloat(0.0));\n/// assert_eq!(o, Less);\n/// assert_eq!(\n///     f32::rounding_from(&small, Up),\n///     (f32::MIN_POSITIVE_SUBNORMAL, Greater)\n/// );\n/// let (rounded, o) = f32::rounding_from(-&small, Down);\n/// assert_eq!(NiceFloat(rounded), NiceFloat(-0.0));\n/// assert_eq!(o, Greater);\n/// assert_eq!(\n///     f32::rounding_from(&-small, Up),\n///     (-f32::MIN_POSITIVE_SUBNORMAL, Less)\n/// );\n/// ```\n///\n/// # try_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::PowerOf2;\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     f32::try_from(Rational::from_signeds(1i8, 3)),\n///     Err(FloatConversionError::Inexact)\n/// );\n/// assert_eq!(f32::try_from(Rational::ONE_HALF), Ok(0.5));\n/// assert_eq!(\n///     f32::try_from(Rational::power_of_2(200u64)),\n///     Err(FloatConversionError::Inexact)\n/// );\n/// assert_eq!(\n///     f32::try_from(Rational::power_of_2(-200i64)),\n///     Err(FloatConversionError::Inexact)\n/// );\n/// assert_eq!(\n///     f32::try_from(-Rational::power_of_2(-200i64)),\n///     Err(FloatConversionError::Inexact)\n/// );\n///\n/// assert_eq!(\n///     f32::try_from(&Rational::from_signeds(1i8, 3)),\n///     Err(FloatConversionError::Inexact)\n/// );\n/// assert_eq!(f32::try_from(&Rational::ONE_HALF), Ok(0.5));\n/// assert_eq!(\n///     f32::try_from(&Rational::power_of_2(200u64)),\n///     Err(FloatConversionError::Inexact)\n/// );\n/// assert_eq!(\n///     f32::try_from(&Rational::power_of_2(-200i64)),\n///     Err(FloatConversionError::Inexact)\n/// );\n/// assert_eq!(\n///     f32::try_from(&-Rational::power_of_2(-200i64)),\n///     Err(FloatConversionError::Inexact)\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::arithmetic::traits::PowerOf2;\n/// use malachite_base::num::basic::traits::OneHalf;\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(f32::convertible_from(Rational::from_signeds(1i8, 3)), false);\n/// assert_eq!(f32::convertible_from(Rational::ONE_HALF), true);\n/// assert_eq!(f32::convertible_from(Rational::power_of_2(200u64)), false);\n/// assert_eq!(f32::convertible_from(Rational::power_of_2(-200i64)), false);\n/// assert_eq!(f32::convertible_from(-Rational::power_of_2(-200i64)), false);\n///\n/// assert_eq!(\n///     f32::convertible_from(&Rational::from_signeds(1i8, 3)),\n///     false\n/// );\n/// assert_eq!(f32::convertible_from(&Rational::ONE_HALF), true);\n/// assert_eq!(f32::convertible_from(&Rational::power_of_2(200u64)), false);\n/// assert_eq!(f32::convertible_from(&Rational::power_of_2(-200i64)), false);\n/// assert_eq!(\n///     f32::convertible_from(&-Rational::power_of_2(-200i64)),\n///     false\n/// );\n/// ```\npub mod primitive_float_from_rational;\n/// Implementations of traits for converting a [`Rational`](crate::Rational) to a primitive integer.\n///\n/// The traits are [`TryFrom`],\n/// [`ConvertibleFrom`](malachite_base::num::conversion::traits::ConvertibleFrom), and\n/// [`RoundingFrom`](malachite_base::num::conversion::traits::RoundingFrom).\n///\n/// # try_from\n/// ```\n/// use malachite_q::conversion::primitive_int_from_rational::{\n///     SignedFromRationalError, UnsignedFromRationalError,\n/// };\n/// use malachite_q::Rational;\n/// use std::str::FromStr;\n///\n/// assert_eq!(u32::try_from(&Rational::from(123)).unwrap(), 123);\n/// assert_eq!(\n///     u32::try_from(&Rational::from(-123)),\n///     Err(UnsignedFromRationalError)\n/// );\n/// assert_eq!(\n///     u32::try_from(&Rational::from_str(\"1000000000000\").unwrap()),\n///     Err(UnsignedFromRationalError)\n/// );\n/// assert_eq!(\n///     u32::try_from(&Rational::from_signeds(22, 7)),\n///     Err(UnsignedFromRationalError)\n/// );\n///\n/// assert_eq!(i32::try_from(&Rational::from(123)).unwrap(), 123);\n/// assert_eq!(i32::try_from(&Rational::from(-123)).unwrap(), -123);\n/// assert_eq!(\n///     i32::try_from(&Rational::from_str(\"-1000000000000\").unwrap()),\n///     Err(SignedFromRationalError)\n/// );\n/// assert_eq!(\n///     i32::try_from(&Rational::from_str(\"1000000000000\").unwrap()),\n///     Err(SignedFromRationalError)\n/// );\n/// assert_eq!(\n///     i32::try_from(&Rational::from_signeds(22, 7)),\n///     Err(SignedFromRationalError)\n/// );\n/// ```\n///\n/// # convertible_from\n/// ```\n/// use malachite_base::num::conversion::traits::ConvertibleFrom;\n/// use malachite_q::Rational;\n/// use std::str::FromStr;\n///\n/// assert_eq!(u32::convertible_from(&Rational::from(123)), true);\n/// assert_eq!(u32::convertible_from(&Rational::from(-123)), false);\n/// assert_eq!(\n///     u32::convertible_from(&Rational::from_str(\"1000000000000\").unwrap()),\n///     false\n/// );\n/// assert_eq!(u32::convertible_from(&Rational::from_signeds(22, 7)), false);\n///\n/// assert_eq!(i32::convertible_from(&Rational::from(123)), true);\n/// assert_eq!(i32::convertible_from(&Rational::from(-123)), true);\n/// assert_eq!(\n///     i32::convertible_from(&Rational::from_str(\"-1000000000000\").unwrap()),\n///     false\n/// );\n/// assert_eq!(\n///     i32::convertible_from(&Rational::from_str(\"1000000000000\").unwrap()),\n///     false\n/// );\n/// assert_eq!(i32::convertible_from(&Rational::from_signeds(22, 7)), false);\n/// ```\n///\n/// # rounding_from\n/// ```\n/// use malachite_base::num::conversion::traits::RoundingFrom;\n/// use malachite_base::rounding_modes::RoundingMode::*;\n/// use malachite_q::Rational;\n/// use std::cmp::Ordering::*;\n///\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from(123), Exact),\n///     (123, Equal)\n/// );\n///\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from_signeds(22, 7), Floor),\n///     (3, Less)\n/// );\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from_signeds(22, 7), Down),\n///     (3, Less)\n/// );\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from_signeds(22, 7), Ceiling),\n///     (4, Greater)\n/// );\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from_signeds(22, 7), Up),\n///     (4, Greater)\n/// );\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from_signeds(22, 7), Nearest),\n///     (3, Less)\n/// );\n///\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from(-123), Down),\n///     (0, Greater)\n/// );\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from(-123), Ceiling),\n///     (0, Greater)\n/// );\n/// assert_eq!(\n///     u32::rounding_from(&Rational::from(-123), Nearest),\n///     (0, Greater)\n/// );\n///\n/// assert_eq!(u8::rounding_from(&Rational::from(1000), Down), (255, Less));\n/// assert_eq!(u8::rounding_from(&Rational::from(1000), Floor), (255, Less));\n/// assert_eq!(\n///     u8::rounding_from(&Rational::from(1000), Nearest),\n///     (255, Less)\n/// );\n///\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from(-123), Exact),\n///     (-123, Equal)\n/// );\n///\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(22, 7), Floor),\n///     (3, Less)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(22, 7), Down),\n///     (3, Less)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(22, 7), Ceiling),\n///     (4, Greater)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(22, 7), Up),\n///     (4, Greater)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(22, 7), Nearest),\n///     (3, Less)\n/// );\n///\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(-22, 7), Floor),\n///     (-4, Less)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(-22, 7), Down),\n///     (-3, Greater)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(-22, 7), Ceiling),\n///     (-3, Greater)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(-22, 7), Up),\n///     (-4, Less)\n/// );\n/// assert_eq!(\n///     i32::rounding_from(&Rational::from_signeds(-22, 7), Nearest),\n///     (-3, Greater)\n/// );\n///\n/// assert_eq!(\n///     i8::rounding_from(&Rational::from(-1000), Down),\n///     (-128, Greater)\n/// );\n/// assert_eq!(\n///     i8::rounding_from(&Rational::from(-1000), Ceiling),\n///     (-128, Greater)\n/// );\n/// assert_eq!(\n///     i8::rounding_from(&Rational::from(-1000), Nearest),\n///     (-128, Greater)\n/// );\n///\n/// assert_eq!(i8::rounding_from(&Rational::from(1000), Down), (127, Less));\n/// assert_eq!(i8::rounding_from(&Rational::from(1000), Floor), (127, Less));\n/// assert_eq!(\n///     i8::rounding_from(&Rational::from(1000), Nearest),\n///     (127, Less)\n/// );\n/// ```\npub mod primitive_int_from_rational;\n/// Implementations of traits for converting [`Rational`](crate::Rational)s to and from [`String`]s.\npub mod string;\n/// Functions for extracting or referencing the numerator and/or denominator of a\n/// [`Rational`](crate::Rational).\npub mod to_numerator_and_denominator;\n/// Various traits for performing arithmetic operations on numbers.\npub mod traits;\n"
  },
  {
    "path": "malachite-q/src/conversion/mutate_numerator_and_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{DivExactAssign, Gcd};\nuse malachite_nz::natural::Natural;\n\nimpl Rational {\n    /// Mutates the numerator of a [`Rational`] using a provided closure, and then returns whatever\n    /// the closure returns.\n    ///\n    /// After the closure executes, this function reduces the [`Rational`].\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut q = Rational::from_signeds(22, 7);\n    /// let ret = q.mutate_numerator(|x| {\n    ///     *x -= Natural::ONE;\n    ///     true\n    /// });\n    /// assert_eq!(q, 3);\n    /// assert_eq!(ret, true);\n    /// ```\n    pub fn mutate_numerator<F: FnOnce(&mut Natural) -> T, T>(&mut self, f: F) -> T {\n        let out = f(&mut self.numerator);\n        let gcd = (&self.numerator).gcd(&self.denominator);\n        self.numerator.div_exact_assign(&gcd);\n        self.denominator.div_exact_assign(gcd);\n        if !self.sign && self.numerator == 0 {\n            self.sign = true;\n        }\n        out\n    }\n\n    /// Mutates the denominator of a [`Rational`] using a provided closure, and then returns\n    /// whatever the closure returns.\n    ///\n    /// After the closure executes, this function reduces the [`Rational`].\n    ///\n    /// # Panics\n    /// Panics if the closure sets the denominator to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut q = Rational::from_signeds(22, 7);\n    /// let ret = q.mutate_denominator(|x| {\n    ///     *x -= Natural::ONE;\n    ///     true\n    /// });\n    /// assert_eq!(q.to_string(), \"11/3\");\n    /// assert_eq!(ret, true);\n    /// ```\n    pub fn mutate_denominator<F: FnOnce(&mut Natural) -> T, T>(&mut self, f: F) -> T {\n        let out = f(&mut self.denominator);\n        assert_ne!(self.denominator, 0);\n        let gcd = (&self.numerator).gcd(&self.denominator);\n        self.numerator.div_exact_assign(&gcd);\n        self.denominator.div_exact_assign(gcd);\n        out\n    }\n\n    /// Mutates the numerator and denominator of a [`Rational`] using a provided closure, and then\n    /// returns whatever the closure returns.\n    ///\n    /// After the closure executes, this function reduces the [`Rational`].\n    ///\n    /// # Panics\n    /// Panics if the closure sets the denominator to zero.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::One;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut q = Rational::from_signeds(22, 7);\n    /// let ret = q.mutate_numerator_and_denominator(|x, y| {\n    ///     *x -= Natural::ONE;\n    ///     *y -= Natural::ONE;\n    ///     true\n    /// });\n    /// assert_eq!(q.to_string(), \"7/2\");\n    /// assert_eq!(ret, true);\n    /// ```\n    pub fn mutate_numerator_and_denominator<F: FnOnce(&mut Natural, &mut Natural) -> T, T>(\n        &mut self,\n        f: F,\n    ) -> T {\n        let out = f(&mut self.numerator, &mut self.denominator);\n        assert_ne!(self.denominator, 0);\n        let gcd = (&self.numerator).gcd(&self.denominator);\n        self.numerator.div_exact_assign(&gcd);\n        self.denominator.div_exact_assign(gcd);\n        if !self.sign && self.numerator == 0 {\n            self.sign = true;\n        }\n        out\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/natural_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::DivRound;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::natural::Natural;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct NaturalFromRationalError;\n\nimpl TryFrom<Rational> for Natural {\n    type Error = NaturalFromRationalError;\n\n    /// Converts a [`Rational`] to a [`Natural`], taking the [`Rational`] by value. If the\n    /// [`Rational`] is negative or not an integer, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::conversion::natural_from_rational::NaturalFromRationalError;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Natural::try_from(Rational::from(123)).unwrap(), 123);\n    /// assert_eq!(\n    ///     Natural::try_from(Rational::from(-123)),\n    ///     Err(NaturalFromRationalError)\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(Rational::from_signeds(22, 7)),\n    ///     Err(NaturalFromRationalError)\n    /// );\n    /// ```\n    fn try_from(x: Rational) -> Result<Self, Self::Error> {\n        if x.sign && x.denominator == 1u32 {\n            Ok(x.numerator)\n        } else {\n            Err(NaturalFromRationalError)\n        }\n    }\n}\n\nimpl TryFrom<&Rational> for Natural {\n    type Error = NaturalFromRationalError;\n\n    /// Converts a [`Rational`] to a [`Natural`], taking the [`Rational`] by reference. If the\n    /// [`Rational`] is negative or not an integer, an error is returned.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::conversion::natural_from_rational::NaturalFromRationalError;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Natural::try_from(&Rational::from(123)).unwrap(), 123);\n    /// assert_eq!(\n    ///     Natural::try_from(&Rational::from(-123)),\n    ///     Err(NaturalFromRationalError)\n    /// );\n    /// assert_eq!(\n    ///     Natural::try_from(&Rational::from_signeds(22, 7)),\n    ///     Err(NaturalFromRationalError)\n    /// );\n    /// ```\n    fn try_from(x: &Rational) -> Result<Self, Self::Error> {\n        if x.sign && x.denominator == 1u32 {\n            Ok(x.numerator.clone())\n        } else {\n            Err(NaturalFromRationalError)\n        }\n    }\n}\n\nimpl ConvertibleFrom<&Rational> for Natural {\n    /// Determines whether a [`Rational`] can be converted to a [`Natural`] (when the [`Rational`]\n    /// is non-negative and an integer), taking the [`Rational`] by reference.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::ConvertibleFrom;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Natural::convertible_from(&Rational::from(123)), true);\n    /// assert_eq!(Natural::convertible_from(&Rational::from(-123)), false);\n    /// assert_eq!(\n    ///     Natural::convertible_from(&Rational::from_signeds(22, 7)),\n    ///     false\n    /// );\n    /// ```\n    #[inline]\n    fn convertible_from(x: &Rational) -> bool {\n        x.sign && x.denominator == 1u32\n    }\n}\n\nimpl RoundingFrom<Rational> for Natural {\n    /// Converts a [`Rational`] to a [`Natural`], using a specified [`RoundingMode`] and taking the\n    /// [`Rational`] by value. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// If the [`Rational`] is negative, then it will be rounded to zero when the [`RoundingMode`]\n    /// is `Ceiling`, `Down`, or `Nearest`. Otherwise, this function will panic.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Rational`] is not an integer and `rm` is `Exact`, or if the [`Rational`] is\n    /// less than zero and `rm` is not `Down`, `Ceiling`, or `Nearest`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from(123), Exact).to_debug_string(),\n    ///     \"(123, Equal)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from_signeds(22, 7), Floor).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from_signeds(22, 7), Down).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from_signeds(22, 7), Ceiling).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from_signeds(22, 7), Up).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from_signeds(22, 7), Nearest).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from(-123), Down).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from(-123), Ceiling).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(Rational::from(-123), Nearest).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// ```\n    fn rounding_from(x: Rational, rm: RoundingMode) -> (Self, Ordering) {\n        if x.sign {\n            x.numerator.div_round(x.denominator, rm)\n        } else if rm == Down || rm == Ceiling || rm == Nearest {\n            (Self::ZERO, Greater)\n        } else {\n            panic!(\"Cannot round negative Rational to Natural using RoundingMode {rm}\");\n        }\n    }\n}\n\nimpl RoundingFrom<&Rational> for Natural {\n    /// Converts a [`Rational`] to a [`Natural`], using a specified [`RoundingMode`] and taking the\n    /// [`Rational`] by reference. An [`Ordering`] is also returned, indicating whether the returned\n    /// value is less than, equal to, or greater than the original value.\n    ///\n    /// If the [`Rational`] is negative, then it will be rounded to zero when the [`RoundingMode`]\n    /// is `Ceiling`, `Down`, or `Nearest`. Otherwise, this function will panic.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `x.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if the [`Rational`] is not an integer and `rm` is `Exact`, or if the [`Rational`] is\n    /// less than zero and `rm` is not `Down`, `Ceiling`, or `Nearest`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::traits::RoundingFrom;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_nz::natural::Natural;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from(123), Exact).to_debug_string(),\n    ///     \"(123, Equal)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from_signeds(22, 7), Floor).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from_signeds(22, 7), Down).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from_signeds(22, 7), Ceiling).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from_signeds(22, 7), Up).to_debug_string(),\n    ///     \"(4, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from_signeds(22, 7), Nearest).to_debug_string(),\n    ///     \"(3, Less)\"\n    /// );\n    ///\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from(-123), Down).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from(-123), Ceiling).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// assert_eq!(\n    ///     Natural::rounding_from(&Rational::from(-123), Nearest).to_debug_string(),\n    ///     \"(0, Greater)\"\n    /// );\n    /// ```\n    fn rounding_from(x: &Rational, rm: RoundingMode) -> (Self, Ordering) {\n        if x.sign {\n            (&x.numerator).div_round(&x.denominator, rm)\n        } else if rm == Down || rm == Ceiling || rm == Nearest {\n            (Self::ZERO, Greater)\n        } else {\n            panic!(\"Cannot round negative Rational to Natural using RoundingMode {rm}\");\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/primitive_float_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse malachite_base::num::arithmetic::traits::{\n    DivRound, DivisibleByPowerOf2, IsPowerOf2, NegAssign,\n};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, RawMantissaAndExponent, RoundingFrom, SciMantissaAndExponent,\n    WrappingFrom,\n};\nuse malachite_base::num::logic::traits::{BitAccess, SignificantBits};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub enum FloatConversionError {\n    Inexact,\n    Overflow,\n    Underflow,\n}\n\nfn abs_is_neg_power_of_2(x: &Rational) -> bool {\n    x.numerator == 1u32 && x.denominator.is_power_of_2()\n}\n\nmacro_rules! float_impls {\n    ($f: ident) => {\n        impl RoundingFrom<Rational> for $f {\n            /// Converts a [`Rational`] to a value of a primitive float according to a specified\n            /// [`RoundingMode`], taking the [`Rational`] by value.\n            ///\n            /// - If the rounding mode is `Floor`, the largest float less than or equal to the\n            ///   [`Rational`] is returned. If the [`Rational`] is greater than the maximum finite\n            ///   float, then the maximum finite float is returned. If it is smaller than the\n            ///   minimum finite float, then $-\\infty$ is returned. If it is between zero and the\n            ///   minimum positive float, then positive zero is returned.\n            /// - If the rounding mode is `Ceiling`, the smallest float greater than or equal to the\n            ///   [`Rational`] is returned. If the [`Rational`] is greater than the maximum finite\n            ///   float, then $\\infty$ is returned. If it is smaller than the minimum finite float,\n            ///   then the minimum finite float is returned. If it is between zero and the maximum\n            ///   negative float, then negative zero is returned.\n            /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor` if the\n            ///   [`Rational`] is non-negative and as with `Ceiling` if the [`Rational`] is\n            ///   negative. If the [`Rational`] is between the maximum negative float and the\n            ///   minimum positive float, then positive zero is returned when the [`Rational`] is\n            ///   non-negative and negative zero otherwise.\n            /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling` if the\n            ///   [`Rational`] is non-negative and as with `Floor` if the [`Rational`] is negative.\n            ///   Positive zero is only returned when the [`Rational`] is zero, and negative zero is\n            ///   never returned.\n            /// - If the rounding mode is `Nearest`, then the nearest float is returned. If the\n            ///   [`Rational`] is exactly between two floats, the float with the zero\n            ///   least-significant bit in its representation is selected. If the [`Rational`] is\n            ///   greater than the maximum finite float, then $\\infty$ is returned. If the\n            ///   [`Rational`] is smaller than the minimum finite float, then $-\\infty$ is returned.\n            ///   If the [`Rational`] is closer to zero than to any other float (or if there is a\n            ///   tie between zero and another float), then positive or negative zero is returned,\n            ///   depending on the [`Rational`]'s sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the rounding mode is `Exact` and `value` cannot be represented exactly.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_rational#rounding_from).\n            fn rounding_from(mut value: Rational, mut rm: RoundingMode) -> ($f, Ordering) {\n                if value == 0u32 {\n                    (0.0, Equal)\n                } else {\n                    let sign = value.sign;\n                    if !sign {\n                        rm.neg_assign();\n                    }\n                    let mut exponent = value.floor_log_base_2_abs();\n                    let (f, o) = if exponent > $f::MAX_EXPONENT {\n                        match rm {\n                            Exact => {\n                                panic!(\"Value cannot be represented exactly as a float\")\n                            }\n                            Floor | Down => ($f::MAX_FINITE, Less),\n                            _ => ($f::INFINITY, Greater),\n                        }\n                    } else if exponent >= $f::MIN_NORMAL_EXPONENT {\n                        value >>= exponent - i64::wrapping_from($f::MANTISSA_WIDTH);\n                        let (n, d) = value.into_numerator_and_denominator();\n                        let (mut mantissa, o) = n.div_round(d, rm);\n                        let mut bits = mantissa.significant_bits();\n                        let mut done = false;\n                        if bits > $f::MANTISSA_WIDTH + 1 {\n                            if exponent == $f::MAX_EXPONENT {\n                                done = true;\n                            } else {\n                                bits -= 1;\n                                mantissa >>= 1; // lsb is zero\n                                exponent += 1;\n                            }\n                        }\n                        if done {\n                            match rm {\n                                Exact => {\n                                    panic!(\"Value cannot be represented exactly as a float\")\n                                }\n                                Floor | Down => ($f::MAX_FINITE, Less),\n                                _ => ($f::INFINITY, Greater),\n                            }\n                        } else {\n                            assert_eq!(bits, $f::MANTISSA_WIDTH + 1);\n                            mantissa.clear_bit($f::MANTISSA_WIDTH);\n                            (\n                                $f::from_raw_mantissa_and_exponent(\n                                    u64::exact_from(&mantissa),\n                                    u64::exact_from(exponent + $f::MAX_EXPONENT),\n                                ),\n                                o,\n                            )\n                        }\n                    } else if exponent >= $f::MIN_EXPONENT {\n                        let target_width = u64::wrapping_from(exponent - $f::MIN_EXPONENT + 1);\n                        value >>= $f::MIN_EXPONENT;\n                        let (n, d) = value.into_numerator_and_denominator();\n                        let (mantissa, o) = n.div_round(d, rm);\n                        (\n                            if mantissa.significant_bits() > target_width\n                                && exponent == $f::MIN_NORMAL_EXPONENT - 1\n                            {\n                                $f::MIN_POSITIVE_NORMAL\n                            } else {\n                                $f::from_raw_mantissa_and_exponent(u64::exact_from(&mantissa), 0)\n                            },\n                            o,\n                        )\n                    } else {\n                        match rm {\n                            Exact => {\n                                panic!(\"Value cannot be represented exactly as a float\")\n                            }\n                            Floor | Down => (0.0, Less),\n                            Nearest => {\n                                if exponent == $f::MIN_EXPONENT - 1\n                                    && !abs_is_neg_power_of_2(&value)\n                                {\n                                    ($f::MIN_POSITIVE_SUBNORMAL, Greater)\n                                } else {\n                                    (0.0, Less)\n                                }\n                            }\n                            _ => ($f::MIN_POSITIVE_SUBNORMAL, Greater),\n                        }\n                    };\n                    if sign { (f, o) } else { (-f, o.reverse()) }\n                }\n            }\n        }\n\n        impl TryFrom<Rational> for $f {\n            type Error = FloatConversionError;\n\n            /// Converts a [`Rational`] to a primitive float, taking the [`Rational`] by value. If\n            /// the input isn't exactly equal to any float, an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(1)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_rational#try_from).\n            fn try_from(value: Rational) -> Result<$f, Self::Error> {\n                if value == 0 {\n                    Ok(0.0)\n                } else {\n                    let sign = value.sign;\n                    let (mantissa, exponent, _) = value\n                        .sci_mantissa_and_exponent_round(Exact)\n                        .ok_or(FloatConversionError::Inexact)?;\n                    let f = $f::from_sci_mantissa_and_exponent(mantissa, i64::exact_from(exponent))\n                        .ok_or(FloatConversionError::Inexact);\n                    if sign { f } else { f.map(|x| -x) }\n                }\n            }\n        }\n\n        impl ConvertibleFrom<Rational> for $f {\n            /// Determines whether a [`Rational`] can be exactly converted to a primitive float,\n            /// taking the [`Rational`] by value.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_rational#convertible_from).\n            fn convertible_from(value: Rational) -> bool {\n                if value == 0 {\n                    true\n                } else {\n                    if let Some((mantissa, exponent, _)) =\n                        value.sci_mantissa_and_exponent_round::<$f>(Exact)\n                    {\n                        let exponent = i64::exact_from(exponent);\n                        if !($f::MIN_EXPONENT..=$f::MAX_EXPONENT).contains(&exponent) {\n                            return false;\n                        }\n                        let (orig_mantissa, orig_exponent) = mantissa.raw_mantissa_and_exponent();\n                        orig_exponent == u64::wrapping_from($f::MAX_EXPONENT)\n                            && exponent >= $f::MIN_NORMAL_EXPONENT\n                            || orig_mantissa.divisible_by_power_of_2(u64::wrapping_from(\n                                $f::MIN_NORMAL_EXPONENT - exponent,\n                            ))\n                    } else {\n                        false\n                    }\n                }\n            }\n        }\n\n        impl RoundingFrom<&Rational> for $f {\n            /// Converts a [`Rational`] to a value of a primitive float according to a specified\n            /// [`RoundingMode`], taking the [`Rational`] by reference.\n            ///\n            /// - If the rounding mode is `Floor`, the largest float less than or equal to the\n            ///   [`Rational`] is returned. If the [`Rational`] is greater than the maximum finite\n            ///   float, then the maximum finite float is returned. If it is smaller than the\n            ///   minimum finite float, then $-\\infty$ is returned. If it is between zero and the\n            ///   minimum positive float, then positive zero is returned.\n            /// - If the rounding mode is `Ceiling`, the smallest float greater than or equal to the\n            ///   [`Rational`] is returned. If the [`Rational`] is greater than the maximum finite\n            ///   float, then $\\infty$is returned. If it is smaller than the minimum finite float,\n            ///   then the minimum finite float is returned. If it is between zero and the maximum\n            ///   negative float, then negative zero is returned.\n            /// - If the rounding mode is `Down`, then the rounding proceeds as with `Floor` if the\n            ///   [`Rational`] is non-negative and as with `Ceiling` if the [`Rational`] is\n            ///   negative. If the [`Rational`] is between the maximum negative float and the\n            ///   minimum positive float, then positive zero is returned when the [`Rational`] is\n            ///   non-negative and negative zero otherwise.\n            /// - If the rounding mode is `Up`, then the rounding proceeds as with `Ceiling` if the\n            ///   [`Rational`] is non-negative and as with `Floor` if the [`Rational`] is negative.\n            ///   Positive zero is only returned when the [`Rational`] is zero, and negative zero is\n            ///   never returned.\n            /// - If the rounding mode is `Nearest`, then the nearest float is returned. If the\n            ///   [`Rational`] is exactly between two floats, the float with the zero\n            ///   least-significant bit in its representation is selected. If the [`Rational`] is\n            ///   greater than the maximum finite float, then $\\infty$ is returned. If the\n            ///   [`Rational`] is smaller than the minimum finite float, then $-\\infty$ is returned.\n            ///   If the [`Rational`] is closer to zero than to any float (or if there is a tie\n            ///   between zero and another float), then positive or negative zero is returned,\n            ///   depending on the [`Rational`]'s sign.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the rounding mode is `Exact` and `value` cannot be represented exactly.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_rational#rounding_from).\n            fn rounding_from(value: &Rational, mut rm: RoundingMode) -> ($f, Ordering) {\n                if *value == 0u32 {\n                    (0.0, Equal)\n                } else {\n                    if !value.sign {\n                        rm.neg_assign();\n                    }\n                    let mut exponent = value.floor_log_base_2_abs();\n                    let (f, o) = if exponent > $f::MAX_EXPONENT {\n                        match rm {\n                            Exact => {\n                                panic!(\"Value cannot be represented exactly as a float\")\n                            }\n                            Floor | Down => ($f::MAX_FINITE, Less),\n                            _ => ($f::INFINITY, Greater),\n                        }\n                    } else if exponent >= $f::MIN_NORMAL_EXPONENT {\n                        let x = value >> exponent - i64::wrapping_from($f::MANTISSA_WIDTH);\n                        let (n, d) = x.into_numerator_and_denominator();\n                        let (mut mantissa, o) = n.div_round(d, rm);\n                        let mut bits = mantissa.significant_bits();\n                        let mut done = false;\n                        if bits > $f::MANTISSA_WIDTH + 1 {\n                            if exponent == $f::MAX_EXPONENT {\n                                done = true;\n                            } else {\n                                bits -= 1;\n                                mantissa >>= 1; // lsb is zero\n                                exponent += 1;\n                            }\n                        }\n                        if done {\n                            match rm {\n                                Exact => {\n                                    panic!(\"Value cannot be represented exactly as a float\")\n                                }\n                                Floor | Down => ($f::MAX_FINITE, Less),\n                                _ => ($f::INFINITY, Greater),\n                            }\n                        } else {\n                            assert_eq!(bits, $f::MANTISSA_WIDTH + 1);\n                            mantissa.clear_bit($f::MANTISSA_WIDTH);\n                            (\n                                $f::from_raw_mantissa_and_exponent(\n                                    u64::exact_from(&mantissa),\n                                    u64::exact_from(exponent + $f::MAX_EXPONENT),\n                                ),\n                                o,\n                            )\n                        }\n                    } else if exponent >= $f::MIN_EXPONENT {\n                        let target_width = u64::wrapping_from(exponent - $f::MIN_EXPONENT + 1);\n                        let x = value >> $f::MIN_EXPONENT;\n                        let (n, d) = x.into_numerator_and_denominator();\n                        let (mantissa, o) = n.div_round(d, rm);\n                        (\n                            if mantissa.significant_bits() > target_width\n                                && exponent == $f::MIN_NORMAL_EXPONENT - 1\n                            {\n                                $f::MIN_POSITIVE_NORMAL\n                            } else {\n                                $f::from_raw_mantissa_and_exponent(u64::exact_from(&mantissa), 0)\n                            },\n                            o,\n                        )\n                    } else {\n                        match rm {\n                            Exact => {\n                                panic!(\"Value cannot be represented exactly as a float\")\n                            }\n                            Floor | Down => (0.0, Less),\n                            Nearest => {\n                                if exponent == $f::MIN_EXPONENT - 1\n                                    && !abs_is_neg_power_of_2(&value)\n                                {\n                                    ($f::MIN_POSITIVE_SUBNORMAL, Greater)\n                                } else {\n                                    (0.0, Less)\n                                }\n                            }\n                            _ => ($f::MIN_POSITIVE_SUBNORMAL, Greater),\n                        }\n                    };\n                    if value.sign {\n                        (f, o)\n                    } else {\n                        (-f, o.reverse())\n                    }\n                }\n            }\n        }\n\n        impl TryFrom<&Rational> for $f {\n            type Error = FloatConversionError;\n\n            /// Converts a [`Rational`] to a primitive float, taking the [`Rational`] by reference.\n            /// If the input isn't exactly equal to any float, an error is returned.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_rational#try_from).\n            fn try_from(value: &Rational) -> Result<$f, Self::Error> {\n                if *value == 0 {\n                    Ok(0.0)\n                } else {\n                    let (mantissa, exponent, _) = value\n                        .sci_mantissa_and_exponent_round_ref(Exact)\n                        .ok_or(FloatConversionError::Inexact)?;\n                    let f = $f::from_sci_mantissa_and_exponent(mantissa, i64::exact_from(exponent))\n                        .ok_or(FloatConversionError::Inexact);\n                    if value.sign { f } else { f.map(|x| -x) }\n                }\n            }\n        }\n\n        impl ConvertibleFrom<&Rational> for $f {\n            /// Determines whether a [`Rational`] can be exactly converted to a primitive float,\n            /// taking the [`Rational`] by reference.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n)$\n            ///\n            /// $M(n) = O(n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_float_from_rational#convertible_from).\n            fn convertible_from(value: &Rational) -> bool {\n                if *value == 0 {\n                    true\n                } else {\n                    if let Some((mantissa, exponent, _)) =\n                        value.sci_mantissa_and_exponent_round_ref::<$f>(Exact)\n                    {\n                        let exponent = i64::exact_from(exponent);\n                        if !($f::MIN_EXPONENT..=$f::MAX_EXPONENT).contains(&exponent) {\n                            return false;\n                        }\n                        let (orig_mantissa, orig_exponent) = mantissa.raw_mantissa_and_exponent();\n                        orig_exponent == u64::wrapping_from($f::MAX_EXPONENT)\n                            && exponent >= $f::MIN_NORMAL_EXPONENT\n                            || orig_mantissa.divisible_by_power_of_2(u64::wrapping_from(\n                                $f::MIN_NORMAL_EXPONENT - exponent,\n                            ))\n                    } else {\n                        false\n                    }\n                }\n            }\n        }\n    };\n}\napply_to_primitive_floats!(float_impls);\n"
  },
  {
    "path": "malachite-q/src/conversion/primitive_int_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::cmp::Ordering::{self, *};\nuse core::ops::Neg;\nuse malachite_base::comparison::traits::{Max, Min};\nuse malachite_base::named::Named;\nuse malachite_base::num::arithmetic::traits::{DivRound, DivisibleByPowerOf2};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, RoundingFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct UnsignedFromRationalError;\n\nfn try_from_unsigned<'a, T: TryFrom<&'a Natural>>(\n    x: &'a Rational,\n) -> Result<T, UnsignedFromRationalError> {\n    if x.sign && x.denominator == 1u32 {\n        T::try_from(&x.numerator).map_err(|_| UnsignedFromRationalError)\n    } else {\n        Err(UnsignedFromRationalError)\n    }\n}\n\nfn convertible_from_unsigned<T: for<'a> ConvertibleFrom<&'a Natural>>(x: &Rational) -> bool {\n    x.sign && x.denominator == 1u32 && T::convertible_from(&x.numerator)\n}\n\n#[allow(clippy::let_and_return)] // n doesn't live long enough for a direct return\nfn rounding_from_unsigned<'a, T: for<'b> TryFrom<&'b Natural> + Max + Named + Zero>(\n    x: &'a Rational,\n    rm: RoundingMode,\n) -> (T, Ordering) {\n    if x.sign {\n        let (n, o) = (&x.numerator).div_round(&x.denominator, rm);\n        let out = if let Ok(q) = T::try_from(&n) {\n            (q, o)\n        } else if rm == Down || rm == Floor || rm == Nearest {\n            (T::MAX, Less)\n        } else {\n            panic!(\n                \"Rational is too large to round to {} using RoundingMode {}\",\n                rm,\n                T::NAME\n            );\n        };\n        out\n    } else if rm == Down || rm == Ceiling || rm == Nearest {\n        (T::ZERO, Greater)\n    } else {\n        panic!(\n            \"Cannot round negative Rational to {} using RoundingMode {}\",\n            rm,\n            T::NAME\n        );\n    }\n}\n\n#[derive(Clone, Copy, Debug, Eq, PartialEq)]\npub struct SignedFromRationalError;\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn try_from_signed<\n    'a,\n    U: WrappingFrom<&'a Natural>,\n    S: Neg<Output = S> + PrimitiveInt + WrappingFrom<U> + WrappingFrom<&'a Natural>,\n>(\n    x: &'a Rational,\n) -> Result<S, SignedFromRationalError> {\n    if x.denominator != 1u32 {\n        return Err(SignedFromRationalError);\n    }\n    match *x {\n        Rational {\n            sign: true,\n            ref numerator,\n            ..\n        } => {\n            if numerator.significant_bits() < S::WIDTH {\n                Ok(S::wrapping_from(numerator))\n            } else {\n                Err(SignedFromRationalError)\n            }\n        }\n        Rational {\n            sign: false,\n            ref numerator,\n            ..\n        } => {\n            let significant_bits = numerator.significant_bits();\n            if significant_bits < S::WIDTH\n                || significant_bits == S::WIDTH && numerator.divisible_by_power_of_2(S::WIDTH - 1)\n            {\n                Ok(S::wrapping_from(U::wrapping_from(numerator)).wrapping_neg())\n            } else {\n                Err(SignedFromRationalError)\n            }\n        }\n    }\n}\n\nfn convertible_from_signed<T: PrimitiveInt>(x: &Rational) -> bool {\n    if x.denominator != 1u32 {\n        return false;\n    }\n    match *x {\n        Rational {\n            sign: true,\n            ref numerator,\n            ..\n        } => numerator.significant_bits() < T::WIDTH,\n        Rational {\n            sign: false,\n            ref numerator,\n            ..\n        } => {\n            let significant_bits = numerator.significant_bits();\n            significant_bits < T::WIDTH\n                || significant_bits == T::WIDTH && numerator.divisible_by_power_of_2(T::WIDTH - 1)\n        }\n    }\n}\n\nfn rounding_from_signed<'a, T: Max + Min + Named + for<'b> WrappingFrom<&'b Integer>>(\n    x: &'a Rational,\n    rm: RoundingMode,\n) -> (T, Ordering)\nwhere\n    Integer: PartialOrd<T>,\n{\n    let (i, o) = Integer::rounding_from(x, rm);\n    if i > T::MAX {\n        if rm == Down || rm == Floor || rm == Nearest {\n            (T::MAX, Less)\n        } else {\n            panic!(\n                \"Rational is too large to round to {} using RoundingMode {}\",\n                rm,\n                T::NAME\n            );\n        }\n    } else if i < T::MIN {\n        if rm == Down || rm == Ceiling || rm == Nearest {\n            (T::MIN, Greater)\n        } else {\n            panic!(\n                \"Rational is too small to round to {} using RoundingMode {}\",\n                rm,\n                T::NAME\n            );\n        }\n    } else {\n        (T::wrapping_from(&i), o)\n    }\n}\n\nmacro_rules! impl_from_unsigned {\n    ($u: ident) => {\n        impl<'a> TryFrom<&'a Rational> for $u {\n            type Error = UnsignedFromRationalError;\n\n            /// Converts a [`Rational`] to an unsigned primitive integer, returning an error if the\n            /// [`Rational`] cannot be represented.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_rational#try_from).\n            #[inline]\n            fn try_from(value: &Rational) -> Result<$u, UnsignedFromRationalError> {\n                try_from_unsigned(value)\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Rational> for $u {\n            /// Determines whether a [`Rational`] can be converted to an unsigned primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_rational#convertible_from).\n            #[inline]\n            fn convertible_from(value: &Rational) -> bool {\n                convertible_from_unsigned::<$u>(value)\n            }\n        }\n\n        impl<'a> RoundingFrom<&'a Rational> for $u {\n            /// Converts a [`Rational`] to an unsigned integer, using a specified [`RoundingMode`].\n            ///\n            /// If the [`Rational`] is negative, then it will be rounded to zero when `rm` is\n            /// `Ceiling`, `Down`, or `Nearest`. Otherwise, this function will panic.\n            ///\n            /// If the [`Rational`] is larger than the maximum value of the unsigned type, then it\n            /// will be rounded to the maximum value when `rm` is `Floor`, `Down`, or `Nearest`.\n            /// Otherwise, this function will panic.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the [`Rational`] is not an integer and `rm` is `Exact`, if the\n            /// [`Rational`] is less than zero and `rm` is not `Down`, `Ceiling`, or `Nearest`, or\n            /// if the [`Rational`] is greater than `T::MAX` and `rm` is not `Down`, `Floor`, or\n            /// `Nearest`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_rational#rounding_from).\n            #[inline]\n            fn rounding_from(value: &Rational, rm: RoundingMode) -> ($u, Ordering) {\n                rounding_from_unsigned(value, rm)\n            }\n        }\n    };\n}\napply_to_unsigneds!(impl_from_unsigned);\n\nmacro_rules! impl_from_signed {\n    ($u: ident, $s: ident) => {\n        impl<'a> TryFrom<&'a Rational> for $s {\n            type Error = SignedFromRationalError;\n\n            /// Converts a [`Rational`] to a signed primitive integer, returning an error if the\n            /// [`Rational`] cannot be represented.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_rational#try_from).\n            #[inline]\n            fn try_from(value: &Rational) -> Result<$s, SignedFromRationalError> {\n                try_from_signed::<$u, $s>(value)\n            }\n        }\n\n        impl<'a> ConvertibleFrom<&'a Rational> for $s {\n            /// Determines whether a [`Rational`] can be converted to a signed primitive integer.\n            ///\n            /// # Worst-case complexity\n            /// Constant time and additional memory.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_rational#convertible_from).\n            #[inline]\n            fn convertible_from(value: &Rational) -> bool {\n                convertible_from_signed::<$s>(value)\n            }\n        }\n\n        impl<'a> RoundingFrom<&'a Rational> for $s {\n            /// Converts a [`Rational`] to a signed integer, using a specified [`RoundingMode`].\n            ///\n            /// If the [`Rational`] is smaller than the minimum value of the unsigned type, then it\n            /// will be rounded to the minimum value when `rm` is `Ceiling`, `Down`, or `Nearest`.\n            /// Otherwise, this function will panic.\n            ///\n            /// If the [`Rational`] is larger than the maximum value of the unsigned type, then it\n            /// will be rounded to the maximum value when `rm` is `Floor`, `Down`, or `Nearest`.\n            /// Otherwise, this function will panic.\n            ///\n            /// # Worst-case complexity\n            /// $T(n) = O(n \\log n \\log\\log n)$\n            ///\n            /// $M(n) = O(n \\log n)$\n            ///\n            /// where $T$ is time, $M$ is additional memory, and $n$ is `value.significant_bits()`.\n            ///\n            /// # Panics\n            /// Panics if the [`Rational`] is not an integer and `rm` is `Exact`, if the\n            /// [`Rational`] is less than `T::MIN` and `rm` is not `Down`, `Ceiling`, or `Nearest`,\n            /// or if the [`Rational`] is greater than `T::MAX` and `rm` is not `Down`, `Floor`, or\n            /// `Nearest`.\n            ///\n            /// # Examples\n            /// See [here](super::primitive_int_from_rational#rounding_from).\n            #[inline]\n            fn rounding_from(value: &Rational, rm: RoundingMode) -> ($s, Ordering) {\n                rounding_from_signed(value, rm)\n            }\n        }\n    };\n}\napply_to_unsigned_signed_pairs!(impl_from_signed);\n"
  },
  {
    "path": "malachite-q/src/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::traits::SimplestRationalInInterval;\nuse malachite_base::num::arithmetic::traits::Pow;\nuse malachite_base::num::conversion::string::from_sci_string::preprocess_sci_string;\nuse malachite_base::num::conversion::string::options::FromSciStringOptions;\nuse malachite_base::num::conversion::traits::FromSciString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::conversion::string::from_sci_string::FromSciStringHelper;\n\nimpl FromSciString for Rational {\n    /// Converts a string, possibly in scientfic notation, to a [`Rational`].\n    ///\n    /// Use [`FromSciStringOptions`] to specify the base (from 2 to 36, inclusive). The rounding\n    /// mode option is ignored.\n    ///\n    /// If the base is greater than 10, the higher digits are represented by the letters `'a'`\n    /// through `'z'` or `'A'` through `'Z'`; the case doesn't matter and doesn't need to be\n    /// consistent.\n    ///\n    /// Exponents are allowed, and are indicated using the character `'e'` or `'E'`. If the base is\n    /// 15 or greater, an ambiguity arises where it may not be clear whether `'e'` is a digit or an\n    /// exponent indicator. To resolve this ambiguity, always use a `'+'` or `'-'` sign after the\n    /// exponent indicator when the base is 15 or greater.\n    ///\n    /// The exponent itself is always parsed using base 10.\n    ///\n    /// Decimal (or other-base) points are allowed.\n    ///\n    /// If the string is unparseable, `None` is returned.\n    ///\n    /// This function is very literal; given `\"0.333\"`, it will return $333/1000$ rather than $1/3$.\n    /// If you'd prefer that it return $1/3$, consider using\n    /// [`from_sci_string_simplest`](Rational::from_sci_string_simplest) instead. However, that\n    /// function has its quirks too: given `\"0.1\"`, it will not return $1/10$ (see its documentation\n    /// for an explanation of this behavior). This function _does_ return $1/10$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m^n n \\log m (\\log n + \\log\\log m))$\n    ///\n    /// $M(n, m) = O(m^n n \\log m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `s.len()`, and $m$ is `options.base`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::FromSciStringOptions;\n    /// use malachite_base::num::conversion::traits::FromSciString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from_sci_string(\"123\").unwrap(), 123);\n    /// assert_eq!(\n    ///     Rational::from_sci_string(\"0.1\").unwrap().to_string(),\n    ///     \"1/10\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sci_string(\"0.10\").unwrap().to_string(),\n    ///     \"1/10\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sci_string(\"0.333\").unwrap().to_string(),\n    ///     \"333/1000\"\n    /// );\n    /// assert_eq!(Rational::from_sci_string(\"1.2e5\").unwrap(), 120000);\n    /// assert_eq!(\n    ///     Rational::from_sci_string(\"1.2e-5\").unwrap().to_string(),\n    ///     \"3/250000\"\n    /// );\n    ///\n    /// let mut options = FromSciStringOptions::default();\n    /// options.set_base(16);\n    /// assert_eq!(\n    ///     Rational::from_sci_string_with_options(\"ff\", options).unwrap(),\n    ///     255\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sci_string_with_options(\"ffE+5\", options).unwrap(),\n    ///     267386880\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sci_string_with_options(\"ffE-5\", options)\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"255/1048576\"\n    /// );\n    /// ```\n    fn from_sci_string_with_options(s: &str, options: FromSciStringOptions) -> Option<Self> {\n        let (s, exponent) = preprocess_sci_string(s, options)?;\n        let x = Self::from(Integer::parse_int(&s, options.get_base())?);\n        Some(x * Self::from(options.get_base()).pow(exponent))\n    }\n}\n\nimpl Rational {\n    /// Converts a string, possibly in scientfic notation, to a [`Rational`]. This function finds\n    /// the simplest [`Rational`] which rounds to the target string according to the precision\n    /// implied by the string.\n    ///\n    /// Use [`FromSciStringOptions`] to specify the base (from 2 to 36, inclusive). The rounding\n    /// mode option is ignored.\n    ///\n    /// If the base is greater than 10, the higher digits are represented by the letters `'a'`\n    /// through `'z'` or `'A'` through `'Z'`; the case doesn't matter and doesn't need to be\n    /// consistent.\n    ///\n    /// Exponents are allowed, and are indicated using the character `'e'` or `'E'`. If the base is\n    /// 15 or greater, an ambiguity arises where it may not be clear whether `'e'` is a digit or an\n    /// exponent indicator. To resolve this ambiguity, always use a `'+'` or `'-'` sign after the\n    /// exponent indicator when the base is 15 or greater.\n    ///\n    /// The exponent itself is always parsed using base 10.\n    ///\n    /// Decimal (or other-base) points are allowed.\n    ///\n    /// If the string is unparseable, `None` is returned.\n    ///\n    /// Here's a more precise description of the function's behavior. Suppose we are using base $b$,\n    /// and the literal value of the string (as parsed by\n    /// [`from_sci_string`](Rational::from_sci_string)) is $q$, and the implied scale is $s$\n    /// (meaning $s$ digits are provided after the point; if the string is `\"123.456\"`, then $s$ is\n    /// 3). Then this function computes $\\varepsilon = b^{-s}/2$ and finds the simplest [`Rational`]\n    /// in the closed interval $[q - \\varepsilon, q + \\varepsilon]$. The simplest [`Rational`] is\n    /// the one with minimal denominator; if there are multiple such [`Rational`]s, the one with the\n    /// smallest absolute numerator is chosen.\n    ///\n    /// The following discussion assumes base 10.\n    ///\n    /// This method allows the function to convert `\"0.333\"` to $1/3$, since $1/3$ is the simplest\n    /// [`Rational`] in the interval $[0.3325, 0.3335]$. But note that if the scale of the input is\n    /// low, some unexpected behavior may occur. For example, `\"0.1\"` will be converted into $1/7$\n    /// rather than $1/10$, since $1/7$ is the simplest [`Rational`] in $[0.05, 0.15]$. If you'd\n    /// prefer that result be $1/10$, you have a few options:\n    /// - Use [`from_sci_string_with_options`](Rational::from_sci_string_with_options) instead. This\n    ///   function interprets its input literally; it converts `\"0.333\"` to $333/1000$.\n    /// - Increase the scale of the input; `\"0.10\"` is converted to $1/10$.\n    /// - Use [`from_sci_string_with_options`](Rational::from_sci_string_with_options), and round\n    ///   the result manually using functions like\n    ///   [`round_to_multiple`](malachite_base::num::arithmetic::traits::RoundToMultiple::round_to_multiple)\n    ///   and\n    ///   [`simplest_rational_in_closed_interval`](Rational::simplest_rational_in_closed_interval).\n    ///\n    /// # Worst-case complexity\n    /// $T(n, m) = O(m^n n \\log m (\\log n + \\log\\log m))$\n    ///\n    /// $M(n, m) = O(m^n n \\log m)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, $n$ is `s.len()`, and $m$ is `options.base`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::FromSciStringOptions;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut options = FromSciStringOptions::default();\n    /// options.set_base(16);\n    /// assert_eq!(\n    ///     Rational::from_sci_string_simplest_with_options(\"ff\", options).unwrap(),\n    ///     255\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sci_string_simplest_with_options(\"ffE+5\", options).unwrap(),\n    ///     267386880\n    /// );\n    /// // 1/4105 is 0.000ff705..._16\n    /// assert_eq!(\n    ///     Rational::from_sci_string_simplest_with_options(\"ffE-5\", options)\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"1/4105\"\n    /// );\n    /// ```\n    pub fn from_sci_string_simplest_with_options(\n        s: &str,\n        options: FromSciStringOptions,\n    ) -> Option<Self> {\n        let (s, exponent) = preprocess_sci_string(s, options)?;\n        let x = Self::from(Integer::parse_int(&s, options.get_base())?);\n        let p = Self::from(options.get_base()).pow(exponent);\n        let q = x * &p;\n        if exponent >= 0 {\n            Some(q)\n        } else {\n            let epsilon = p >> 1;\n            Some(Self::simplest_rational_in_closed_interval(\n                &(&q - &epsilon),\n                &(q + epsilon),\n            ))\n        }\n    }\n\n    /// Converts a string, possibly in scientfic notation, to a [`Rational`]. This function finds\n    /// the simplest [`Rational`] which rounds to the target string according to the precision\n    /// implied by the string.\n    ///\n    /// The string is parsed using base 10. To use other bases, try\n    /// [`from_sci_string_simplest_with_options`](Rational::from_sci_string_simplest_with_options)\n    /// instead.\n    ///\n    /// Exponents are allowed, and are indicated using the character `'e'` or `'E'`.\n    ///\n    /// The exponent itself is also parsed using base 10.\n    ///\n    /// Decimal points are allowed.\n    ///\n    /// If the string is unparseable, `None` is returned.\n    ///\n    /// Here's a more precise description of the function's behavior. Suppose that the literal value\n    /// of the string (as parsed by [`from_sci_string`](Rational::from_sci_string)) is $q$, and the\n    /// implied scale is $s$ (meaning $s$ digits are provided after the point; if the string is\n    /// `\"123.456\"`, then $s$ is 3). Then this function computes $\\varepsilon = 10^{-s}/2$ and finds\n    /// the simplest [`Rational`] in the closed interval $[q - \\varepsilon, q + \\varepsilon]$. The\n    /// simplest [`Rational`] is the one with minimal denominator; if there are multiple such\n    /// [`Rational`]s, the one with the smallest absolute numerator is chosen.\n    ///\n    /// This method allows the function to convert `\"0.333\"` to $1/3$, since $1/3$ is the simplest\n    /// [`Rational`] in the interval $[0.3325, 0.3335]$. But note that if the scale of the input is\n    /// low, some unexpected behavior may occur. For example, `\"0.1\"` will be converted into $1/7$\n    /// rather than $1/10$, since $1/7$ is the simplest [`Rational`] in $[0.05, 0.15]$. If you'd\n    /// prefer that result be $1/10$, you have a few options:\n    /// - Use [`from_sci_string`](Rational::from_sci_string) instead. This function interprets its\n    ///   input literally; it converts `\"0.333\"` to $333/1000$.\n    /// - Increase the scale of the input; `\"0.10\"` is converted to $1/10$.\n    /// - Use [`from_sci_string`](Rational::from_sci_string), and round the result manually using\n    ///   functions like\n    ///   [`round_to_multiple`](malachite_base::num::arithmetic::traits::RoundToMultiple::round_to_multiple)\n    ///   and\n    ///   [`simplest_rational_in_closed_interval`](Rational::simplest_rational_in_closed_interval).\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(10^n n \\log n)$\n    ///\n    /// $M(n) = O(10^n n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::from_sci_string_simplest(\"123\").unwrap(), 123);\n    /// assert_eq!(\n    ///     Rational::from_sci_string_simplest(\"0.1\")\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"1/7\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sci_string_simplest(\"0.10\")\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"1/10\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_sci_string_simplest(\"0.333\")\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"1/3\"\n    /// );\n    /// assert_eq!(Rational::from_sci_string_simplest(\"1.2e5\").unwrap(), 120000);\n    /// assert_eq!(\n    ///     Rational::from_sci_string_simplest(\"1.2e-5\")\n    ///         .unwrap()\n    ///         .to_string(),\n    ///     \"1/80000\"\n    /// );\n    /// ```\n    #[inline]\n    pub fn from_sci_string_simplest(s: &str) -> Option<Self> {\n        Self::from_sci_string_simplest_with_options(s, FromSciStringOptions::default())\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::str::FromStr;\nuse malachite_base::num::basic::traits::One;\nuse malachite_nz::natural::Natural;\n\nimpl FromStr for Rational {\n    type Err = ();\n\n    /// Converts an string to a [`Rational`].\n    ///\n    /// If the string does not represent a valid [`Rational`], an `Err` is returned. The numerator\n    /// and denominator do not need to be in lowest terms, but the denominator must be nonzero. A\n    /// negative sign is only allowed at the 0th position of the string.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `s.len()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Rational::from_str(\"123456\").unwrap(), 123456);\n    /// assert_eq!(Rational::from_str(\"00123456\").unwrap(), 123456);\n    /// assert_eq!(Rational::from_str(\"0\").unwrap(), 0);\n    /// assert_eq!(Rational::from_str(\"-123456\").unwrap(), -123456);\n    /// assert_eq!(Rational::from_str(\"-00123456\").unwrap(), -123456);\n    /// assert_eq!(Rational::from_str(\"-0\").unwrap(), 0);\n    /// assert_eq!(Rational::from_str(\"22/7\").unwrap().to_string(), \"22/7\");\n    /// assert_eq!(Rational::from_str(\"01/02\").unwrap().to_string(), \"1/2\");\n    /// assert_eq!(Rational::from_str(\"3/21\").unwrap().to_string(), \"1/7\");\n    /// assert_eq!(Rational::from_str(\"-22/7\").unwrap().to_string(), \"-22/7\");\n    /// assert_eq!(Rational::from_str(\"-01/02\").unwrap().to_string(), \"-1/2\");\n    /// assert_eq!(Rational::from_str(\"-3/21\").unwrap().to_string(), \"-1/7\");\n    ///\n    /// assert!(Rational::from_str(\"\").is_err());\n    /// assert!(Rational::from_str(\"a\").is_err());\n    /// assert!(Rational::from_str(\"1/0\").is_err());\n    /// assert!(Rational::from_str(\"/1\").is_err());\n    /// assert!(Rational::from_str(\"1/\").is_err());\n    /// assert!(Rational::from_str(\"--1\").is_err());\n    /// assert!(Rational::from_str(\"1/-2\").is_err());\n    /// ```\n    #[inline]\n    fn from_str(s: &str) -> Result<Self, ()> {\n        let (abs_string, sign) = if let Some(abs_string) = s.strip_prefix('-') {\n            if abs_string.starts_with('+') {\n                return Err(());\n            }\n            (abs_string, false)\n        } else {\n            (s, true)\n        };\n        let numerator;\n        let denominator;\n        if let Some(slash_index) = abs_string.find('/') {\n            numerator = Natural::from_str(&abs_string[..slash_index])?;\n            denominator = Natural::from_str(&abs_string[slash_index + 1..])?;\n            if denominator == 0u32 {\n                return Err(());\n            }\n        } else {\n            numerator = Natural::from_str(abs_string)?;\n            denominator = Natural::ONE;\n        }\n        Ok(Self::from_sign_and_naturals(sign, numerator, denominator))\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/string/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n/// Implementations of [`FromSciString`](malachite_base::num::conversion::traits::FromSciString).\n/// This is a trait for converting strings, possibly using scientific notation, to numbers.\npub mod from_sci_string;\n/// An implementation of [`FromStr`](std::str::FromStr).\npub mod from_string;\n/// Implementations of [`ToSci`](malachite_base::num::conversion::traits::ToSci), a trait for\n/// converting a number to string, possibly using scientific notation.\npub mod to_sci;\n/// Implementations of [`Display`](std::fmt::Display) and [`Debug`].\npub mod to_string;\n"
  },
  {
    "path": "malachite-q/src/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::log_base::log_base_helper;\nuse alloc::string::String;\nuse core::cmp::{Ordering::*, max};\nuse core::fmt::{Formatter, Write};\nuse malachite_base::num::arithmetic::traits::{\n    Abs, CheckedLogBase2, DivExact, DivExactAssign, DivRound, DivisibleBy, Pow, Sign,\n};\nuse malachite_base::num::conversion::string::options::{SciSizeOptions, ToSciOptions};\nuse malachite_base::num::conversion::string::to_sci::write_exponent;\nuse malachite_base::num::conversion::traits::{\n    ExactFrom, IsInteger, RoundingFrom, ToSci, ToStringBase, WrappingFrom,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\nconst BASE_PRIME_FACTORS: [[(u8, u8); 3]; 37] = [\n    [(0, 0), (0, 0), (0, 0)],\n    [(0, 0), (0, 0), (0, 0)],\n    [(2, 1), (0, 0), (0, 0)],\n    [(3, 1), (0, 0), (0, 0)],\n    [(2, 2), (0, 0), (0, 0)],\n    [(5, 1), (0, 0), (0, 0)],\n    [(2, 1), (3, 1), (0, 0)],\n    [(7, 1), (0, 0), (0, 0)],\n    [(2, 3), (0, 0), (0, 0)],\n    [(3, 2), (0, 0), (0, 0)],\n    [(2, 1), (5, 1), (0, 0)],\n    [(11, 1), (0, 0), (0, 0)],\n    [(2, 2), (3, 1), (0, 0)],\n    [(13, 1), (0, 0), (0, 0)],\n    [(2, 1), (7, 1), (0, 0)],\n    [(3, 1), (5, 1), (0, 0)],\n    [(2, 4), (0, 0), (0, 0)],\n    [(17, 1), (0, 0), (0, 0)],\n    [(2, 1), (3, 2), (0, 0)],\n    [(19, 1), (0, 0), (0, 0)],\n    [(2, 2), (5, 1), (0, 0)],\n    [(3, 1), (7, 1), (0, 0)],\n    [(2, 1), (11, 1), (0, 0)],\n    [(23, 1), (0, 0), (0, 0)],\n    [(2, 3), (3, 1), (0, 0)],\n    [(5, 2), (0, 0), (0, 0)],\n    [(2, 1), (13, 1), (0, 0)],\n    [(3, 3), (0, 0), (0, 0)],\n    [(2, 2), (7, 1), (0, 0)],\n    [(29, 1), (0, 0), (0, 0)],\n    [(2, 1), (3, 1), (5, 1)],\n    [(31, 1), (0, 0), (0, 0)],\n    [(2, 5), (0, 0), (0, 0)],\n    [(3, 1), (11, 1), (0, 0)],\n    [(2, 1), (17, 1), (0, 0)],\n    [(5, 1), (7, 1), (0, 0)],\n    [(2, 2), (3, 2), (0, 0)],\n];\n\nimpl Rational {\n    /// When expanding a [`Rational`] in a small base $b$, determines how many digits after the\n    /// decimal (or other-base) point are in the base-$b$ expansion.\n    ///\n    /// If the expansion is non-terminating, this method returns `None`. This happens iff the\n    /// [`Rational`]'s denominator has prime factors not present in $b$.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Panics\n    /// Panics if `base` is less than 2 or greater than 36.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    ///\n    /// // 3/8 is 0.375 in base 10.\n    /// assert_eq!(\n    ///     Rational::from_signeds(3, 8).length_after_point_in_small_base(10),\n    ///     Some(3)\n    /// );\n    /// // 1/20 is 0.05 in base 10.\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 20).length_after_point_in_small_base(10),\n    ///     Some(2)\n    /// );\n    /// // 1/7 is non-terminating in base 10.\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 7).length_after_point_in_small_base(10),\n    ///     None\n    /// );\n    /// // 1/7 is 0.3 in base 21.\n    /// assert_eq!(\n    ///     Rational::from_signeds(1, 7).length_after_point_in_small_base(21),\n    ///     Some(1)\n    /// );\n    /// ```\n    pub fn length_after_point_in_small_base(&self, base: u8) -> Option<u64> {\n        let d = self.denominator_ref();\n        assert!((2..=36).contains(&base));\n        if *d == 1u32 {\n            return Some(0);\n        }\n        let mut temp = None;\n        let mut length = 0;\n        for (f, m) in BASE_PRIME_FACTORS[usize::wrapping_from(base)] {\n            let count = if f == 0 {\n                break;\n            } else if f == 2 {\n                let twos = d.trailing_zeros().unwrap();\n                if twos != 0 {\n                    temp = Some(d >> twos);\n                }\n                twos\n            } else {\n                let f = Natural::from(f);\n                let mut count = 0;\n                if let Some(temp) = temp.as_mut() {\n                    while (&*temp).divisible_by(&f) {\n                        temp.div_exact_assign(&f);\n                        count += 1;\n                    }\n                } else if d.divisible_by(&f) {\n                    count = 1;\n                    let mut t = d.div_exact(&f);\n                    while (&t).divisible_by(&f) {\n                        t.div_exact_assign(&f);\n                        count += 1;\n                    }\n                    temp = Some(t);\n                }\n                count\n            };\n            length = max(length, count.div_round(u64::from(m), Ceiling).0);\n        }\n        if let Some(temp) = temp {\n            if temp == 1 { Some(length) } else { None }\n        } else {\n            None\n        }\n    }\n}\n\npub_test! {floor_log_base_of_abs(x: &Rational, base: &Rational) -> i64 {\n    if let Some(log_base) = base.checked_log_base_2() {\n        match log_base.sign() {\n            Equal => panic!(\"Cannot take base-1 logarithm\"),\n            Greater => x\n                .floor_log_base_2_abs()\n                .div_round(log_base, Floor).0,\n            Less => {\n                -(x.ceiling_log_base_2_abs()\n                    .div_round(-log_base, Ceiling).0)\n            }\n        }\n    } else {\n        log_base_helper(x, base).0\n    }\n}}\n\nfn fmt_zero(f: &mut Formatter, options: ToSciOptions) -> core::fmt::Result {\n    f.write_char('0')?;\n    let scale = if options.get_include_trailing_zeros() {\n        match options.get_size_options() {\n            SciSizeOptions::Complete => None,\n            SciSizeOptions::Scale(scale) => {\n                if scale == 0 {\n                    None\n                } else {\n                    Some(scale)\n                }\n            }\n            SciSizeOptions::Precision(precision) => {\n                if precision == 1 {\n                    None\n                } else {\n                    Some(precision - 1)\n                }\n            }\n        }\n    } else {\n        None\n    };\n    if let Some(scale) = scale {\n        f.write_char('.')?;\n        for _ in 0..scale {\n            f.write_char('0')?;\n        }\n    }\n    Ok(())\n}\n\nimpl ToSci for Rational {\n    /// Determines whether a [`Rational`] can be converted to a string using\n    /// [`to_sci`](malachite_base::num::conversion::traits::ToSci::to_sci) and a particular set of\n    /// options.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), s)`,\n    /// where `s` depends on the size type specified in `options`.\n    /// - If `options` has `scale` specified, then `s` is `options.scale`.\n    /// - If `options` has `precision` specified, then `s` is `options.precision`.\n    /// - If `options` has `size_complete` specified, then `s` is `self.denominator` (not the log of\n    ///   the denominator!). This reflects the fact that setting `size_complete` might result in a\n    ///   very long string.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::conversion::string::options::ToSciOptions;\n    /// use malachite_base::num::conversion::traits::ToSci;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_q::Rational;\n    ///\n    /// let mut options = ToSciOptions::default();\n    /// assert!(Rational::from(123u8).fmt_sci_valid(options));\n    /// assert!(Rational::from(u128::MAX).fmt_sci_valid(options));\n    /// // u128::MAX has more than 16 significant digits\n    /// options.set_rounding_mode(Exact);\n    /// assert!(!Rational::from(u128::MAX).fmt_sci_valid(options));\n    /// options.set_precision(50);\n    /// assert!(Rational::from(u128::MAX).fmt_sci_valid(options));\n    ///\n    /// let mut options = ToSciOptions::default();\n    /// options.set_size_complete();\n    /// // 1/3 is non-terminating in base 10...\n    /// assert!(!Rational::from_signeds(1, 3).fmt_sci_valid(options));\n    /// options.set_size_complete();\n    ///\n    /// // ...but is terminating in base 36\n    /// options.set_base(36);\n    /// assert!(Rational::from_signeds(1, 3).fmt_sci_valid(options));\n    /// ```\n    fn fmt_sci_valid(&self, options: ToSciOptions) -> bool {\n        if *self == 0 {\n            return true;\n        }\n        if let SciSizeOptions::Complete = options.get_size_options() {\n            return self\n                .length_after_point_in_small_base(options.get_base())\n                .is_some();\n        }\n        if options.get_rounding_mode() != Exact {\n            return true;\n        }\n        let q_base = Self::from(options.get_base());\n        let scale = match options.get_size_options() {\n            SciSizeOptions::Precision(precision) => {\n                let log = floor_log_base_of_abs(self, &q_base);\n                i64::exact_from(precision - 1) - log\n            }\n            SciSizeOptions::Scale(scale) => i64::exact_from(scale),\n            _ => unreachable!(),\n        };\n        (self * q_base.pow(scale)).is_integer()\n    }\n\n    /// Converts a [`Rational` ]to a string using a specified base, possibly formatting the number\n    /// using scientific notation.\n    ///\n    /// See [`ToSciOptions`] for details on the available options.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n \\log n \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `max(self.significant_bits(), s)`,\n    /// where `s` depends on the size type specified in `options`.\n    /// - If `options` has `scale` specified, then `s` is `options.scale`.\n    /// - If `options` has `precision` specified, then `s` is `options.precision`.\n    /// - If `options` has `size_complete` specified, then `s` is `self.denominator` (not the log of\n    ///   the denominator!). This reflects the fact that setting `size_complete` might result in a\n    ///   very long string.\n    ///\n    /// # Panics\n    /// Panics if `options.rounding_mode` is `Exact`, but the size options are such that the input\n    /// must be rounded.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::arithmetic::traits::PowerOf2;\n    /// use malachite_base::num::conversion::string::options::ToSciOptions;\n    /// use malachite_base::num::conversion::traits::ToSci;\n    /// use malachite_base::rounding_modes::RoundingMode::*;\n    /// use malachite_q::Rational;\n    ///\n    /// let q = Rational::from_signeds(22, 7);\n    /// let mut options = ToSciOptions::default();\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"3.142857142857143\"\n    /// );\n    ///\n    /// options.set_precision(3);\n    /// assert_eq!(q.to_sci_with_options(options).to_string(), \"3.14\");\n    ///\n    /// options.set_rounding_mode(Ceiling);\n    /// assert_eq!(q.to_sci_with_options(options).to_string(), \"3.15\");\n    ///\n    /// options = ToSciOptions::default();\n    /// options.set_base(20);\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"3.2h2h2h2h2h2h2h3\"\n    /// );\n    ///\n    /// options.set_uppercase();\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"3.2H2H2H2H2H2H2H3\"\n    /// );\n    ///\n    /// options.set_base(2);\n    /// options.set_rounding_mode(Floor);\n    /// options.set_precision(19);\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"11.001001001001001\"\n    /// );\n    ///\n    /// options.set_include_trailing_zeros(true);\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"11.00100100100100100\"\n    /// );\n    ///\n    /// let q = Rational::from_unsigneds(936851431250u64, 1397u64);\n    /// let mut options = ToSciOptions::default();\n    /// options.set_precision(6);\n    /// assert_eq!(q.to_sci_with_options(options).to_string(), \"6.70617e8\");\n    ///\n    /// options.set_e_uppercase();\n    /// assert_eq!(q.to_sci_with_options(options).to_string(), \"6.70617E8\");\n    ///\n    /// options.set_force_exponent_plus_sign(true);\n    /// assert_eq!(q.to_sci_with_options(options).to_string(), \"6.70617E+8\");\n    ///\n    /// let q = Rational::from_signeds(123i64, 45678909876i64);\n    /// let mut options = ToSciOptions::default();\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"2.692708743135418e-9\"\n    /// );\n    ///\n    /// options.set_neg_exp_threshold(-10);\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"0.000000002692708743135418\"\n    /// );\n    ///\n    /// let q = Rational::power_of_2(-30i64);\n    /// let mut options = ToSciOptions::default();\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"9.313225746154785e-10\"\n    /// );\n    ///\n    /// options.set_size_complete();\n    /// assert_eq!(\n    ///     q.to_sci_with_options(options).to_string(),\n    ///     \"9.31322574615478515625e-10\"\n    /// );\n    /// ```\n    fn fmt_sci(&self, f: &mut Formatter, options: ToSciOptions) -> core::fmt::Result {\n        if *self == 0u32 {\n            return fmt_zero(f, options);\n        }\n        if *self < 0u32 {\n            f.write_char('-')?;\n        }\n        let base = options.get_base();\n        let q_base = Self::from(base);\n        let mut trim_zeros = !options.get_include_trailing_zeros();\n        let mut log = floor_log_base_of_abs(self, &q_base);\n        // Here, precision 0 means that we're rounding down to zero\n        let (mut scale, mut precision) = match options.get_size_options() {\n            SciSizeOptions::Complete => {\n                trim_zeros = false;\n                let scale = self\n                    .length_after_point_in_small_base(base)\n                    .unwrap_or_else(|| {\n                        panic!(\"{self} has a non-terminating expansion in base {base}\")\n                    });\n                let precision = i64::exact_from(scale) + log + 1;\n                assert!(precision > 0);\n                (i64::exact_from(scale), precision)\n            }\n            SciSizeOptions::Scale(scale) => {\n                (i64::exact_from(scale), i64::exact_from(scale) + log + 1)\n            }\n            SciSizeOptions::Precision(precision) => (\n                i64::exact_from(precision - 1) - log,\n                i64::exact_from(precision),\n            ),\n        };\n        let n = Integer::rounding_from(self * q_base.pow(scale), options.get_rounding_mode())\n            .0\n            .abs();\n        if precision <= 0 {\n            // e.g. we're in base 10, self is 0.01 or 0.000001, but scale is 1\n            if n == 0u32 {\n                return fmt_zero(f, options);\n            } else if n == 1u32 {\n                precision = 1;\n                log = -scale;\n            } else {\n                panic!(\"Bug: precision <= 0 must mean self.abs() rounds to 0 or 1\");\n            };\n        }\n        let mut cs = if options.get_lowercase() {\n            n.to_string_base(base)\n        } else {\n            n.to_string_base_upper(base)\n        }\n        .into_bytes();\n        let mut precision = usize::exact_from(precision);\n        if cs.len() == precision + 1 {\n            // We rounded up to a power of the base, so precision is greater than we expected. If\n            // the options specify the precision, we need to adjust.\n            log += 1;\n            match options.get_size_options() {\n                SciSizeOptions::Complete => panic!(),\n                SciSizeOptions::Precision(_) => {\n                    scale -= 1;\n                    assert_eq!(cs.pop().unwrap(), b'0');\n                }\n                SciSizeOptions::Scale(_) => {\n                    precision += 1;\n                }\n            }\n        }\n        assert_eq!(cs.len(), precision);\n        if log <= options.get_neg_exp_threshold() || scale < 0 {\n            assert_ne!(log, 0);\n            // exponent\n            if trim_zeros {\n                let trailing_zeros = cs.iter().rev().take_while(|&&c| c == b'0').count();\n                precision -= trailing_zeros;\n                cs.truncate(precision);\n            }\n            if precision > 1 {\n                cs.push(0);\n                cs.copy_within(1..precision, 2);\n                cs[1] = b'.';\n            }\n            f.write_str(&String::from_utf8(cs).unwrap())?;\n            write_exponent(f, options, log)\n        } else if scale == 0 {\n            // no exponent or point\n            f.write_str(&String::from_utf8(cs).unwrap())\n        } else {\n            // no exponent\n            if trim_zeros {\n                let trailing_zeros = cs\n                    .iter()\n                    .rev()\n                    .take(usize::exact_from(scale))\n                    .take_while(|&&c| c == b'0')\n                    .count();\n                precision -= trailing_zeros;\n                cs.truncate(precision);\n            }\n            if log < 0 {\n                f.write_char('0')?;\n                f.write_char('.')?;\n                for _ in 0..-log - 1 {\n                    f.write_char('0')?;\n                }\n            } else {\n                let digits_before = usize::exact_from(log) + 1;\n                if precision > digits_before {\n                    cs.push(0);\n                    cs.copy_within(digits_before..precision, digits_before + 1);\n                    cs[digits_before] = b'.';\n                }\n            }\n            f.write_str(&String::from_utf8(cs).unwrap())\n        }\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse core::fmt::{Debug, Display, Formatter, Result, Write};\n\nimpl Display for Rational {\n    /// Converts a [`Rational`] to a [`String`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Rational::ZERO.to_string(), \"0\");\n    /// assert_eq!(Rational::from(123).to_string(), \"123\");\n    /// assert_eq!(Rational::from_str(\"22/7\").unwrap().to_string(), \"22/7\");\n    /// ```\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        if !self.sign {\n            f.write_char('-')?;\n        }\n        let result = Display::fmt(&self.numerator, f);\n        if self.denominator == 1 {\n            result\n        } else {\n            f.write_char('/')?;\n            Display::fmt(&self.denominator, f)\n        }\n    }\n}\n\nimpl Debug for Rational {\n    /// Converts a [`Rational`] to a [`String`].\n    ///\n    /// This is the same implementation as for [`Display`].\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n    ///\n    /// $M(n) = O(n \\log n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    ///\n    /// assert_eq!(Rational::ZERO.to_debug_string(), \"0\");\n    /// assert_eq!(Rational::from(123).to_debug_string(), \"123\");\n    /// assert_eq!(Rational::from_signeds(22, 7).to_debug_string(), \"22/7\");\n    /// ```\n    #[inline]\n    fn fmt(&self, f: &mut Formatter) -> Result {\n        Display::fmt(self, f)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/to_numerator_and_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_nz::natural::Natural;\n\nimpl Rational {\n    /// Extracts the numerator of a [`Rational`], taking the [`Rational`] by reference and cloning.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Rational::from_str(\"2/3\").unwrap().to_numerator(), 2);\n    /// assert_eq!(Rational::from_str(\"0\").unwrap().to_numerator(), 0);\n    /// ```\n    #[inline]\n    pub fn to_numerator(&self) -> Natural {\n        self.numerator.clone()\n    }\n\n    /// Extracts the denominator of a [`Rational`], taking the [`Rational`] by reference and\n    /// cloning.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Rational::from_str(\"2/3\").unwrap().to_denominator(), 3);\n    /// assert_eq!(Rational::from_str(\"0\").unwrap().to_denominator(), 1);\n    /// ```\n    #[inline]\n    pub fn to_denominator(&self) -> Natural {\n        self.denominator.clone()\n    }\n\n    /// Extracts the numerator and denominator of a [`Rational`], taking the [`Rational`] by\n    /// reference and cloning.\n    ///\n    /// # Worst-case complexity\n    /// $T(n) = O(n)$\n    ///\n    /// $M(n) = O(n)$\n    ///\n    /// where $T$ is time, $M$ is additional memory, and $n$ is `self.significant_bits()`.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_str(\"2/3\")\n    ///         .unwrap()\n    ///         .to_numerator_and_denominator()\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_str(\"0\")\n    ///         .unwrap()\n    ///         .to_numerator_and_denominator()\n    ///         .to_debug_string(),\n    ///     \"(0, 1)\"\n    /// );\n    /// ```\n    #[inline]\n    pub fn to_numerator_and_denominator(&self) -> (Natural, Natural) {\n        (self.numerator.clone(), self.denominator.clone())\n    }\n\n    /// Extracts the numerator of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Rational::from_str(\"2/3\").unwrap().into_numerator(), 2);\n    /// assert_eq!(Rational::from_str(\"0\").unwrap().into_numerator(), 0);\n    /// ```\n    #[inline]\n    #[allow(clippy::missing_const_for_fn)]\n    pub fn into_numerator(self) -> Natural {\n        self.numerator\n    }\n\n    /// Extracts the denominator of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Rational::from_str(\"2/3\").unwrap().into_denominator(), 3);\n    /// assert_eq!(Rational::from_str(\"0\").unwrap().into_denominator(), 1);\n    /// ```\n    #[inline]\n    #[allow(clippy::missing_const_for_fn)]\n    pub fn into_denominator(self) -> Natural {\n        self.denominator\n    }\n\n    /// Extracts the numerator and denominator of a [`Rational`], taking the [`Rational`] by value.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_str(\"2/3\")\n    ///         .unwrap()\n    ///         .into_numerator_and_denominator()\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_str(\"0\")\n    ///         .unwrap()\n    ///         .into_numerator_and_denominator()\n    ///         .to_debug_string(),\n    ///     \"(0, 1)\"\n    /// );\n    /// ```\n    #[inline]\n    #[allow(clippy::missing_const_for_fn)]\n    pub fn into_numerator_and_denominator(self) -> (Natural, Natural) {\n        (self.numerator, self.denominator)\n    }\n\n    /// Returns a reference to the numerator of a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(*Rational::from_str(\"2/3\").unwrap().numerator_ref(), 2);\n    /// assert_eq!(*Rational::from_str(\"0\").unwrap().numerator_ref(), 0);\n    /// ```\n    #[inline]\n    pub const fn numerator_ref(&self) -> &Natural {\n        &self.numerator\n    }\n\n    /// Returns a reference to the denominator of a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(*Rational::from_str(\"2/3\").unwrap().denominator_ref(), 3);\n    /// assert_eq!(*Rational::from_str(\"0\").unwrap().denominator_ref(), 1);\n    /// ```\n    #[inline]\n    pub const fn denominator_ref(&self) -> &Natural {\n        &self.denominator\n    }\n\n    /// Returns references to the numeraror and denominator of a [`Rational`].\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::strings::ToDebugString;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(\n    ///     Rational::from_str(\"2/3\")\n    ///         .unwrap()\n    ///         .numerator_and_denominator_ref()\n    ///         .to_debug_string(),\n    ///     \"(2, 3)\"\n    /// );\n    /// assert_eq!(\n    ///     Rational::from_str(\"0\")\n    ///         .unwrap()\n    ///         .numerator_and_denominator_ref()\n    ///         .to_debug_string(),\n    ///     \"(0, 1)\"\n    /// );\n    /// ```\n    #[inline]\n    pub const fn numerator_and_denominator_ref(&self) -> (&Natural, &Natural) {\n        (&self.numerator, &self.denominator)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/conversion/traits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\n/// Returns a number's continued fraction.\n///\n/// The form of a continued fraction is $[a_0; a_1, a_2, a_3\\ldots]$. The first component of the\n/// output pair is $a_0$, and the second is an iterator that produces the $a_i$ for $i > 0$.\npub trait ContinuedFraction {\n    type CF: Iterator<Item = Natural>;\n\n    fn continued_fraction(self) -> (Integer, Self::CF);\n}\n\n/// Returns a number's convergents, as an iterator of [`Rational`]s.\n///\n/// The convergents of a real number are the rational numbers whose continued fractions are the\n/// prefixes of the original number's continued fraction.\npub trait Convergents {\n    type C: Iterator<Item = Rational>;\n\n    fn convergents(self) -> Self::C;\n}\n"
  },
  {
    "path": "malachite-q/src/exhaustive/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::denominators_in_closed_interval::DenominatorsInClosedRationalInterval;\nuse crate::arithmetic::traits::DenominatorsInClosedInterval;\nuse core::iter::{Chain, Once, once};\nuse core::mem::swap;\nuse malachite_base::num::arithmetic::traits::{CoprimeWith, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::num::iterators::{RulerSequence, ruler_sequence};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::tuples::exhaustive::{\n    ExhaustiveDependentPairs, ExhaustiveDependentPairsYsGenerator, exhaustive_dependent_pairs,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::{\n    ExhaustiveIntegerRange, ExhaustiveIntegerRangeToInfinity,\n    ExhaustiveIntegerRangeToNegativeInfinity, exhaustive_integer_range,\n    exhaustive_integer_range_to_infinity, exhaustive_integer_range_to_negative_infinity,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::{\n    ExhaustiveNaturalRangeToInfinity, exhaustive_positive_naturals,\n};\n\n/// Generates all positive [`Rational`]s.\n///\n/// This `struct` is created by [`exhaustive_positive_rationals`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustivePositiveRationals {\n    pred_pred: Natural,\n    pred: Natural,\n}\n\nimpl Iterator for ExhaustivePositiveRationals {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        let mut anm1 = Natural::ZERO;\n        swap(&mut self.pred_pred, &mut anm1);\n        swap(&mut self.pred, &mut self.pred_pred);\n        let k = &anm1 / &self.pred_pred; // floor(a(n - 1) / a(n))\n        self.pred = ((k << 1u32) | Natural::ONE) * &self.pred_pred - anm1;\n        Some(Rational {\n            sign: true,\n            numerator: self.pred_pred.clone(),\n            denominator: self.pred.clone(),\n        })\n    }\n}\n\n/// Generates all positive [`Rational`]s.\n///\n/// The [`Rational`]s are ordered as in the [Calkin-Wilf\n/// sequence](https://en.wikipedia.org/wiki/Calkin%E2%80%93Wilf_tree#Breadth_first_traversal). Their\n/// numerators and denominators are given by the [Stern-Brocot\n/// sequence](https://en.wikipedia.org/wiki/Stern%E2%80%93Brocot_tree#Relation_to_Farey_sequences).\n/// To generate the latter sequence, this iterator uses the formula\n/// $$\n/// a_{n+1} = \\left ( 2 \\left \\lfloor \\frac{a_{n-1}}{a_n} \\right \\rfloor +1 \\right ) a_n - a_{n-1},\n/// $$\n/// attributed to David S. Newman at <https://oeis.org/A002487>.\n///\n/// The output length is infinite. The numerators and denominators of the $n$th element are\n/// $O(n^\\frac{\\log \\phi}{\\log 2})$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i \\log\\log i \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_q::exhaustive::exhaustive_positive_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_positive_rationals(), 20),\n///     \"[1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, 4, 1/5, 5/4, 4/7, 7/3, \\\n///     3/8, ...]\"\n/// )\n/// ```\npub const fn exhaustive_positive_rationals() -> ExhaustivePositiveRationals {\n    ExhaustivePositiveRationals {\n        pred_pred: Natural::ZERO,\n        pred: Natural::ONE,\n    }\n}\n\n/// Generates all non-positive [`Rational`]s.\n///\n/// Zero is generated first, followed by all the positive [`Rational`]s. See\n/// [`exhaustive_positive_rationals`] for details.\n///\n/// The output length is infinite. The numerators and denominators of the $n$th element are\n/// $O(n^\\frac{\\log \\phi}{\\log 2})$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i \\log\\log i \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_q::exhaustive::exhaustive_non_negative_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_non_negative_rationals(), 20),\n///     \"[0, 1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, 4, 1/5, 5/4, 4/7, \\\n///     7/3, ...]\"\n/// )\n/// ```\npub fn exhaustive_non_negative_rationals() -> Chain<Once<Rational>, ExhaustivePositiveRationals> {\n    once(Rational::ZERO).chain(exhaustive_positive_rationals())\n}\n\n/// Generates all negative [`Rational`]s.\n///\n/// This `struct` is created by [`exhaustive_negative_rationals`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveNegativeRationals {\n    xs: ExhaustivePositiveRationals,\n}\n\nimpl Iterator for ExhaustiveNegativeRationals {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        self.xs.next().map(|mut q| {\n            q.sign = false;\n            q\n        })\n    }\n}\n\n/// Generates all negative [`Rational`]s.\n///\n/// The sequence is the same as the sequence of positive [`Rational`]s, but negated. See\n/// [`exhaustive_positive_rationals`] for details.\n///\n/// The output length is infinite. The absolute values of the numerators and denominators of the\n/// $n$th element are $O(n^\\frac{\\log \\phi}{\\log 2})$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i \\log\\log i \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_q::exhaustive::exhaustive_negative_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_negative_rationals(), 20),\n///     \"[-1, -1/2, -2, -1/3, -3/2, -2/3, -3, -1/4, -4/3, -3/5, -5/2, -2/5, -5/3, -3/4, -4, -1/5, \\\n///     -5/4, -4/7, -7/3, -3/8, ...]\"\n/// )\n/// ```\npub const fn exhaustive_negative_rationals() -> ExhaustiveNegativeRationals {\n    ExhaustiveNegativeRationals {\n        xs: exhaustive_positive_rationals(),\n    }\n}\n\n/// Generates all nonzero [`Rational`]s.\n///\n/// This `struct` is created by [`exhaustive_nonzero_rationals`]; see its documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveNonzeroRationals {\n    xs: ExhaustivePositiveRationals,\n    x: Option<Rational>,\n    sign: bool,\n}\n\nimpl Iterator for ExhaustiveNonzeroRationals {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        if self.sign {\n            self.sign = false;\n            let mut x = None;\n            swap(&mut self.x, &mut x);\n            let mut x = x.unwrap();\n            x.sign = false;\n            Some(x)\n        } else {\n            self.sign = true;\n            self.x = self.xs.next();\n            Some(self.x.clone().unwrap())\n        }\n    }\n}\n\n/// Generates all nonzero [`Rational`]s.\n///\n/// The sequence is the same the sequence of positive [`Rational`]s, interleaved with its negative.\n/// See [`exhaustive_positive_rationals`] for details.\n///\n/// The output length is infinite. The absolute values of the numerators and denominators of the\n/// $n$th element are $O(n^\\frac{\\log \\phi}{\\log 2})$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i \\log\\log i \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log\\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_q::exhaustive::exhaustive_nonzero_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_nonzero_rationals(), 20),\n///     \"[1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, 3/2, -3/2, 2/3, -2/3, 3, -3, 1/4, -1/4, 4/3, -4/3, \\\n///     3/5, -3/5, ...]\"\n/// )\n/// ```\npub const fn exhaustive_nonzero_rationals() -> ExhaustiveNonzeroRationals {\n    ExhaustiveNonzeroRationals {\n        xs: exhaustive_positive_rationals(),\n        x: None,\n        sign: false,\n    }\n}\n\n/// Generates all [`Rational`]s.\n///\n/// The sequence begins with zero and is followed by the sequence of positive [`Rational`]s,\n/// interleaved with its negative. See [`exhaustive_positive_rationals`] for details.\n///\n/// The output length is infinite. The absolute values of the numerators and denominators of the\n/// $n$th element are $O(n^\\frac{\\log \\phi}{\\log 2})$.\n///\n/// # Worst-case complexity per iteration\n/// $T(n) = O(\\log n \\log\\log n \\log\\log\\log n)$\n///\n/// $M(i) = O(\\log n \\log\\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_q::exhaustive::exhaustive_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(exhaustive_rationals(), 20),\n///     \"[0, 1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, 3/2, -3/2, 2/3, -2/3, 3, -3, 1/4, -1/4, 4/3, \\\n///     -4/3, 3/5, ...]\"\n/// )\n/// ```\npub fn exhaustive_rationals() -> Chain<Once<Rational>, ExhaustiveNonzeroRationals> {\n    once(Rational::ZERO).chain(exhaustive_nonzero_rationals())\n}\n\n/// Generates all [`Rational`]s with a specific denominator and with numerators from a given\n/// iterator. Numerators that are not coprime with the denominator are skipped.\n#[derive(Clone, Debug)]\npub struct RationalsWithDenominator<I: Iterator<Item = Integer>> {\n    pub(crate) numerators: I,\n    pub(crate) denominator: Natural,\n}\n\nimpl<I: Iterator<Item = Integer>> Iterator for RationalsWithDenominator<I> {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        loop {\n            let n = self.numerators.next()?;\n            if n.unsigned_abs_ref().coprime_with(&self.denominator) {\n                return Some(Rational {\n                    sign: n >= 0u32,\n                    numerator: n.unsigned_abs(),\n                    denominator: self.denominator.clone(),\n                });\n            }\n        }\n    }\n}\n\n/// Generates all [`Rational`]s greater than or equal to some number $a$ and with a specific\n/// denominator, in order of increasing absolute value.\n///\n/// When two [`Rational`]s have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i < j$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if `d` is zero.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::exhaustive::exhaustive_rationals_with_denominator_range_to_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rationals_with_denominator_range_to_infinity(\n///             Natural::from(5u32),\n///             Rational::from_signeds(22i32, 7)\n///         ),\n///         10\n///     ),\n///     \"[16/5, 17/5, 18/5, 19/5, 21/5, 22/5, 23/5, 24/5, 26/5, 27/5, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rationals_with_denominator_range_to_infinity(\n///             Natural::from(2u32),\n///             Rational::from_signeds(-22i32, 7)\n///         ),\n///         10\n///     ),\n///     \"[1/2, -1/2, 3/2, -3/2, 5/2, -5/2, 7/2, 9/2, 11/2, 13/2, ...]\"\n/// );\n/// ```\npub fn exhaustive_rationals_with_denominator_range_to_infinity(\n    d: Natural,\n    a: Rational,\n) -> RationalsWithDenominator<ExhaustiveIntegerRangeToInfinity> {\n    assert_ne!(d, 0u32);\n    RationalsWithDenominator {\n        numerators: exhaustive_integer_range_to_infinity(\n            Integer::rounding_from(a * Rational::from(&d), Ceiling).0,\n        ),\n        denominator: d,\n    }\n}\n\n/// Generates all [`Rational`]s less than or equal to some number $a$ and with a specific\n/// denominator, in order of increasing absolute value.\n///\n/// When two [`Rational`]s have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i < j$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if `d` is zero.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::exhaustive::exhaustive_rationals_with_denominator_range_to_negative_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rationals_with_denominator_range_to_negative_infinity(\n///             Natural::from(5u32),\n///             Rational::from_signeds(-22i32, 7)\n///         ),\n///         10\n///     ),\n///     \"[-16/5, -17/5, -18/5, -19/5, -21/5, -22/5, -23/5, -24/5, -26/5, -27/5, ...]\"\n/// );\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rationals_with_denominator_range_to_negative_infinity(\n///             Natural::from(2u32),\n///             Rational::from_signeds(22i32, 7)\n///         ),\n///         10\n///     ),\n///     \"[1/2, -1/2, 3/2, -3/2, 5/2, -5/2, -7/2, -9/2, -11/2, -13/2, ...]\"\n/// );\n/// ```\npub fn exhaustive_rationals_with_denominator_range_to_negative_infinity(\n    d: Natural,\n    a: Rational,\n) -> RationalsWithDenominator<ExhaustiveIntegerRangeToNegativeInfinity> {\n    assert_ne!(d, 0u32);\n    RationalsWithDenominator {\n        numerators: exhaustive_integer_range_to_negative_infinity(\n            Integer::rounding_from(a * Rational::from(&d), Floor).0,\n        ),\n        denominator: d,\n    }\n}\n\n/// Generates all [`Rational`]s in the half-open range $[a, b)$ and with a specific denominator, in\n/// order of increasing absolute value.\n///\n/// When two [`Rational`]s have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i < j$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if `d` is zero or if $a \\geq b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::exhaustive::exhaustive_rationals_with_denominator_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     exhaustive_rationals_with_denominator_range(\n///         Natural::from(2u32),\n///         Rational::from_signeds(1i32, 3),\n///         Rational::from_signeds(5i32, 2)\n///     )\n///     .collect_vec()\n///     .to_debug_string(),\n///     \"[1/2, 3/2]\"\n/// );\n/// assert_eq!(\n///     exhaustive_rationals_with_denominator_range(\n///         Natural::from(2u32),\n///         Rational::from_signeds(-5i32, 3),\n///         Rational::from_signeds(5i32, 2)\n///     )\n///     .collect_vec()\n///     .to_debug_string(),\n///     \"[1/2, -1/2, 3/2, -3/2]\"\n/// );\n/// assert_eq!(\n///     exhaustive_rationals_with_denominator_range(\n///         Natural::from(10u32),\n///         Rational::try_from_float_simplest(std::f64::consts::E).unwrap(),\n///         Rational::try_from_float_simplest(std::f64::consts::PI).unwrap(),\n///     )\n///     .collect_vec()\n///     .to_debug_string(),\n///     \"[29/10, 31/10]\"\n/// );\n/// ```\npub fn exhaustive_rationals_with_denominator_range(\n    d: Natural,\n    a: Rational,\n    b: Rational,\n) -> RationalsWithDenominator<ExhaustiveIntegerRange> {\n    assert_ne!(d, 0u32);\n    assert!(a < b);\n    let q_d = Rational::from(&d);\n    let a_i = Integer::rounding_from(a * &q_d, Ceiling).0;\n    let upper_included = b.denominator_ref() == &d;\n    let mut b_i = Integer::rounding_from(b * q_d, Floor).0;\n    if !upper_included {\n        b_i += Integer::ONE;\n    }\n    RationalsWithDenominator {\n        numerators: exhaustive_integer_range(a_i, b_i),\n        denominator: d,\n    }\n}\n\n/// Generates all [`Rational`]s in the closed range $[a, b]$ and with a specific denominator, in\n/// order of increasing absolute value.\n///\n/// When two [`Rational`]s have the same absolute value, the positive one comes first.\n///\n/// The output satisfies $(|x_i|, \\operatorname{sgn}(-x_i)) <_\\mathrm{lex} (|x_j|,\n/// \\operatorname{sgn}(-x_j))$ whenever $i < j$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if `d` is zero or if $a > b$.\n///\n/// # Examples\n/// ```\n/// use itertools::Itertools;\n/// use malachite_base::strings::ToDebugString;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::exhaustive::exhaustive_rationals_with_denominator_inclusive_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     exhaustive_rationals_with_denominator_inclusive_range(\n///         Natural::from(2u32),\n///         Rational::from_signeds(1i32, 3),\n///         Rational::from_signeds(5i32, 2)\n///     )\n///     .collect_vec()\n///     .to_debug_string(),\n///     \"[1/2, 3/2, 5/2]\"\n/// );\n/// assert_eq!(\n///     exhaustive_rationals_with_denominator_inclusive_range(\n///         Natural::from(2u32),\n///         Rational::from_signeds(-5i32, 3),\n///         Rational::from_signeds(5i32, 2)\n///     )\n///     .collect_vec()\n///     .to_debug_string(),\n///     \"[1/2, -1/2, 3/2, -3/2, 5/2]\"\n/// );\n/// assert_eq!(\n///     exhaustive_rationals_with_denominator_inclusive_range(\n///         Natural::from(10u32),\n///         Rational::try_from_float_simplest(std::f64::consts::E).unwrap(),\n///         Rational::try_from_float_simplest(std::f64::consts::PI).unwrap(),\n///     )\n///     .collect_vec()\n///     .to_debug_string(),\n///     \"[29/10, 31/10]\"\n/// );\n/// ```\npub fn exhaustive_rationals_with_denominator_inclusive_range(\n    d: Natural,\n    a: Rational,\n    b: Rational,\n) -> RationalsWithDenominator<ExhaustiveIntegerRange> {\n    assert_ne!(d, 0u32);\n    assert!(a <= b);\n    let q_d = Rational::from(&d);\n    let a_i = Integer::rounding_from(a * &q_d, Ceiling).0;\n    let b_i = Integer::rounding_from(b * q_d, Floor).0 + Integer::ONE;\n    RationalsWithDenominator {\n        numerators: exhaustive_integer_range(a_i, b_i),\n        denominator: d,\n    }\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveRationalsWithDenominatorRangeToInfinityGenerator {\n    a: Rational,\n}\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Natural,\n        Rational,\n        RationalsWithDenominator<ExhaustiveIntegerRangeToInfinity>,\n    > for ExhaustiveRationalsWithDenominatorRangeToInfinityGenerator\n{\n    #[inline]\n    fn get_ys(&self, d: &Natural) -> RationalsWithDenominator<ExhaustiveIntegerRangeToInfinity> {\n        exhaustive_rationals_with_denominator_range_to_infinity(d.clone(), self.a.clone())\n    }\n}\n\n#[inline]\nconst fn exhaustive_rational_range_to_infinity_helper(\n    a: Rational,\n) -> ExhaustiveDependentPairs<\n    Natural,\n    Rational,\n    RulerSequence<usize>,\n    ExhaustiveRationalsWithDenominatorRangeToInfinityGenerator,\n    ExhaustiveNaturalRangeToInfinity,\n    RationalsWithDenominator<ExhaustiveIntegerRangeToInfinity>,\n> {\n    exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_positive_naturals(),\n        ExhaustiveRationalsWithDenominatorRangeToInfinityGenerator { a },\n    )\n}\n\n/// Generates all [`Rational`]s greater than or equal to some [`Rational`].\n///\n/// This `struct` is created by [`exhaustive_rational_range_to_infinity`]; see its documentation for\n/// more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveRationalRangeToInfinity(\n    ExhaustiveDependentPairs<\n        Natural,\n        Rational,\n        RulerSequence<usize>,\n        ExhaustiveRationalsWithDenominatorRangeToInfinityGenerator,\n        ExhaustiveNaturalRangeToInfinity,\n        RationalsWithDenominator<ExhaustiveIntegerRangeToInfinity>,\n    >,\n);\n\nimpl Iterator for ExhaustiveRationalRangeToInfinity {\n    type Item = Rational;\n\n    #[inline]\n    fn next(&mut self) -> Option<Rational> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all [`Rational`]s greater than or equal to some [`Rational`] $a$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::conversion::traits::ExactFrom;\n/// use malachite_q::exhaustive::exhaustive_rational_range_to_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rational_range_to_infinity(Rational::exact_from(std::f64::consts::PI)),\n///         20\n///     ),\n///     \"[4, 7/2, 5, 10/3, 6, 9/2, 7, 13/4, 8, 11/2, 9, 11/3, 10, 13/2, 11, 16/5, 12, 15/2, 13, \\\n///     13/3, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn exhaustive_rational_range_to_infinity(\n    a: Rational,\n) -> ExhaustiveRationalRangeToInfinity {\n    ExhaustiveRationalRangeToInfinity(exhaustive_rational_range_to_infinity_helper(a))\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveRationalsWithDenominatorRangeToNegativeInfinityGenerator {\n    a: Rational,\n}\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Natural,\n        Rational,\n        RationalsWithDenominator<ExhaustiveIntegerRangeToNegativeInfinity>,\n    > for ExhaustiveRationalsWithDenominatorRangeToNegativeInfinityGenerator\n{\n    #[inline]\n    fn get_ys(\n        &self,\n        d: &Natural,\n    ) -> RationalsWithDenominator<ExhaustiveIntegerRangeToNegativeInfinity> {\n        exhaustive_rationals_with_denominator_range_to_negative_infinity(d.clone(), self.a.clone())\n    }\n}\n\n#[inline]\nconst fn exhaustive_rational_range_to_negative_infinity_helper(\n    a: Rational,\n) -> ExhaustiveDependentPairs<\n    Natural,\n    Rational,\n    RulerSequence<usize>,\n    ExhaustiveRationalsWithDenominatorRangeToNegativeInfinityGenerator,\n    ExhaustiveNaturalRangeToInfinity,\n    RationalsWithDenominator<ExhaustiveIntegerRangeToNegativeInfinity>,\n> {\n    exhaustive_dependent_pairs(\n        ruler_sequence(),\n        exhaustive_positive_naturals(),\n        ExhaustiveRationalsWithDenominatorRangeToNegativeInfinityGenerator { a },\n    )\n}\n\n/// Generates all [`Rational`]s less than or equal to some [`Rational`].\n///\n/// This `struct` is created by [`exhaustive_rational_range_to_negative_infinity`]; see its\n/// documentation for more.\n#[derive(Clone, Debug)]\npub struct ExhaustiveRationalRangeToNegativeInfinity(\n    ExhaustiveDependentPairs<\n        Natural,\n        Rational,\n        RulerSequence<usize>,\n        ExhaustiveRationalsWithDenominatorRangeToNegativeInfinityGenerator,\n        ExhaustiveNaturalRangeToInfinity,\n        RationalsWithDenominator<ExhaustiveIntegerRangeToNegativeInfinity>,\n    >,\n);\n\nimpl Iterator for ExhaustiveRationalRangeToNegativeInfinity {\n    type Item = Rational;\n\n    #[inline]\n    fn next(&mut self) -> Option<Rational> {\n        self.0.next().map(|p| p.1)\n    }\n}\n\n/// Generates all [`Rational`]s less than or equal to some [`Rational`] $a$.\n///\n/// The output length is infinite.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::conversion::traits::ExactFrom;\n/// use malachite_q::exhaustive::exhaustive_rational_range_to_negative_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rational_range_to_negative_infinity(Rational::exact_from(\n///             std::f64::consts::PI\n///         )),\n///         20\n///     ),\n///     \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, 3, -1/3, -3, -3/2, -4, 1/5, -5, 5/2, -6, \\\n///     2/3, ...]\"\n/// )\n/// ```\n#[inline]\npub const fn exhaustive_rational_range_to_negative_infinity(\n    a: Rational,\n) -> ExhaustiveRationalRangeToNegativeInfinity {\n    ExhaustiveRationalRangeToNegativeInfinity(\n        exhaustive_rational_range_to_negative_infinity_helper(a),\n    )\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveRationalsWithDenominatorRangeGenerator {\n    a: Rational,\n    b: Rational,\n}\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Natural,\n        Rational,\n        RationalsWithDenominator<ExhaustiveIntegerRange>,\n    > for ExhaustiveRationalsWithDenominatorRangeGenerator\n{\n    #[inline]\n    fn get_ys(&self, d: &Natural) -> RationalsWithDenominator<ExhaustiveIntegerRange> {\n        exhaustive_rationals_with_denominator_range(d.clone(), self.a.clone(), self.b.clone())\n    }\n}\n\n#[inline]\nfn exhaustive_rational_range_helper(\n    a: Rational,\n    b: Rational,\n) -> ExhaustiveDependentPairs<\n    Natural,\n    Rational,\n    RulerSequence<usize>,\n    ExhaustiveRationalsWithDenominatorRangeGenerator,\n    DenominatorsInClosedRationalInterval,\n    RationalsWithDenominator<ExhaustiveIntegerRange>,\n> {\n    exhaustive_dependent_pairs(\n        ruler_sequence(),\n        Rational::denominators_in_closed_interval(a.clone(), b.clone()),\n        ExhaustiveRationalsWithDenominatorRangeGenerator { a, b },\n    )\n}\n\n/// Generates all [`Natural`]s in an interval of the form $[a,b)$.\n///\n/// This `struct` is created by [`exhaustive_rational_range`]; see its documentation for more.\n#[allow(private_interfaces, clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum ExhaustiveRationalRange {\n    Empty,\n    Nonempty(\n        ExhaustiveDependentPairs<\n            Natural,\n            Rational,\n            RulerSequence<usize>,\n            ExhaustiveRationalsWithDenominatorRangeGenerator,\n            DenominatorsInClosedRationalInterval,\n            RationalsWithDenominator<ExhaustiveIntegerRange>,\n        >,\n    ),\n}\n\nimpl Iterator for ExhaustiveRationalRange {\n    type Item = Rational;\n\n    #[inline]\n    fn next(&mut self) -> Option<Rational> {\n        match self {\n            Self::Empty => None,\n            Self::Nonempty(xs) => xs.next().map(|p| p.1),\n        }\n    }\n}\n\n/// Generates all [`Rational`]s in the half-open interval $[a, b)$.\n///\n/// `a` must be less than or equal to `b`. If `a` and `b` are equal, the range is empty. To generate\n/// all [`Rational`]s in an infinite interval, use [`exhaustive_rational_range_to_infinity`] or\n/// [`exhaustive_rational_range_to_negative_infinity`].\n///\n/// The output length is infinite if $a<b$ and 0 if $a=b$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if $a>b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::conversion::traits::ExactFrom;\n/// use malachite_q::exhaustive::exhaustive_rational_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rational_range(\n///             Rational::exact_from(std::f64::consts::E),\n///             Rational::exact_from(std::f64::consts::PI)\n///         ),\n///         20\n///     ),\n///     \"[3, 11/4, 14/5, 20/7, 17/6, 23/8, 25/8, 30/11, 25/9, 29/10, 26/9, 31/11, 28/9, 31/10, \\\n///     32/11, 41/15, 34/11, 35/12, 37/12, 39/14, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_rational_range(a: Rational, b: Rational) -> ExhaustiveRationalRange {\n    if a == b {\n        ExhaustiveRationalRange::Empty\n    } else {\n        ExhaustiveRationalRange::Nonempty(exhaustive_rational_range_helper(a, b))\n    }\n}\n\n#[derive(Clone, Debug)]\nstruct ExhaustiveRationalsWithDenominatorInclusiveRangeGenerator {\n    a: Rational,\n    b: Rational,\n}\n\nimpl\n    ExhaustiveDependentPairsYsGenerator<\n        Natural,\n        Rational,\n        RationalsWithDenominator<ExhaustiveIntegerRange>,\n    > for ExhaustiveRationalsWithDenominatorInclusiveRangeGenerator\n{\n    #[inline]\n    fn get_ys(&self, d: &Natural) -> RationalsWithDenominator<ExhaustiveIntegerRange> {\n        exhaustive_rationals_with_denominator_inclusive_range(\n            d.clone(),\n            self.a.clone(),\n            self.b.clone(),\n        )\n    }\n}\n\n#[inline]\nfn exhaustive_rational_inclusive_range_helper(\n    a: Rational,\n    b: Rational,\n) -> ExhaustiveDependentPairs<\n    Natural,\n    Rational,\n    RulerSequence<usize>,\n    ExhaustiveRationalsWithDenominatorInclusiveRangeGenerator,\n    DenominatorsInClosedRationalInterval,\n    RationalsWithDenominator<ExhaustiveIntegerRange>,\n> {\n    exhaustive_dependent_pairs(\n        ruler_sequence(),\n        Rational::denominators_in_closed_interval(a.clone(), b.clone()),\n        ExhaustiveRationalsWithDenominatorInclusiveRangeGenerator { a, b },\n    )\n}\n\n/// Generates all [`Rational`]s in an interval of the form $\\[a,b\\]$.\n///\n/// This `struct` is created by [`exhaustive_rational_inclusive_range`]; see its documentation for\n/// more.\n#[allow(private_interfaces, clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum ExhaustiveRationalInclusiveRange {\n    Single(bool, Rational),\n    Many(\n        ExhaustiveDependentPairs<\n            Natural,\n            Rational,\n            RulerSequence<usize>,\n            ExhaustiveRationalsWithDenominatorInclusiveRangeGenerator,\n            DenominatorsInClosedRationalInterval,\n            RationalsWithDenominator<ExhaustiveIntegerRange>,\n        >,\n    ),\n}\n\nimpl Iterator for ExhaustiveRationalInclusiveRange {\n    type Item = Rational;\n\n    #[inline]\n    fn next(&mut self) -> Option<Rational> {\n        match self {\n            Self::Single(done, x) => {\n                if *done {\n                    None\n                } else {\n                    *done = true;\n                    Some(x.clone())\n                }\n            }\n            Self::Many(xs) => xs.next().map(|p| p.1),\n        }\n    }\n}\n\n/// Generates all [`Rational`]s in the closed interval $[a, b]$.\n///\n/// `a` must be less than or equal to `b`. If `a` and `b` are equal, the range contains a single\n/// element. To generate all [`Rational`]s in an infinite interval, use\n/// [`exhaustive_rational_range_to_infinity`] or [`exhaustive_rational_range_to_negative_infinity`].\n///\n/// The output length is infinite if $a<b$ and 1 if $a=b$.\n///\n/// # Worst-case complexity per iteration\n/// $T(i) = O(\\log i (\\log \\log i)^2 \\log\\log\\log i)$\n///\n/// $M(i) = O(\\log i \\log \\log i)$\n///\n/// where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.\n///\n/// # Panics\n/// Panics if $a>b$.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::num::conversion::traits::ExactFrom;\n/// use malachite_q::exhaustive::exhaustive_rational_inclusive_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         exhaustive_rational_inclusive_range(\n///             Rational::exact_from(std::f64::consts::E),\n///             Rational::exact_from(std::f64::consts::PI)\n///         ),\n///         20\n///     ),\n///     \"[3, 11/4, 14/5, 20/7, 17/6, 23/8, 25/8, 30/11, 25/9, 29/10, 26/9, 31/11, 28/9, 31/10, \\\n///     32/11, 41/15, 34/11, 35/12, 37/12, 39/14, ...]\"\n/// )\n/// ```\n#[inline]\npub fn exhaustive_rational_inclusive_range(\n    a: Rational,\n    b: Rational,\n) -> ExhaustiveRationalInclusiveRange {\n    if a == b {\n        ExhaustiveRationalInclusiveRange::Single(false, a)\n    } else {\n        ExhaustiveRationalInclusiveRange::Many(exhaustive_rational_inclusive_range_helper(a, b))\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n//! This crate defines [`Rational`]s. The name of this crate refers to the mathematical symbol for\n//! rational numbers, $$\\mathbb{Q}$$.\n//! - There are many functions defined on [`Rational`]s.\n//!   These include\n//!   - All the ones you'd expect, like addition, subtraction, multiplication, and division;\n//!   - Functions related to conversion between [`Rational`]s and other kinds of numbers, including\n//!     primitive floats;\n//!   - Functions for Diophantine approximation;\n//!   - Functions for expressing [`Rational`]s in scientific notation.\n//! - The numerators and denominators of [`Rational`]s are stored as [`Natural`]s, so [`Rational`]s\n//!   with small numerators and denominators can be stored entirely on the stack.\n//! - Most arithmetic involving [`Rational`]s requires (automatically) reducing the numerator and\n//!   denominator. This is done very efficiently by using the high performance GCD and exact\n//!   division algorithms implemented by [`Natural`]s.\n//!\n//! # Demos and benchmarks\n//! This crate comes with a `bin` target that can be used for running demos and benchmarks.\n//! - Almost all of the public functions in this crate have an associated demo. Running a demo\n//!   shows you a function's behavior on a large number of inputs. For example, to demo\n//!   [`Rational`] addition, you can use the following command:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_rational_add\n//!   ```\n//!   This command uses the `exhaustive` mode, which generates every possible input, generally\n//!   starting with the simplest input and progressing to more complex ones. Another mode is\n//!   `random`. The `-l` flag specifies how many inputs should be generated.\n//! - You can use a similar command to run benchmarks. The following command benchmarks various\n//!   addition algorithms:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n//!       benchmark_rational_add_algorithms -o add-bench.gp\n//!   ```\n//!   or addition implementations of other libraries:\n//!   ```text\n//!   cargo run --features bin_build --release -- -l 1000000 -m random -b \\\n//!       benchmark_rational_add_assign_library_comparison -o add-bench.gp\n//!   ```\n//!   This creates a file called gcd-bench.gp. You can use gnuplot to create an SVG from it like\n//!   so:\n//!   ```text\n//!   gnuplot -e \"set terminal svg; l \\\"gcd-bench.gp\\\"\" > gcd-bench.svg\n//!   ```\n//!\n//! The list of available demos and benchmarks is not documented anywhere; you must find them by\n//! browsing through\n//! [`bin_util/demo_and_bench`](https://github.com/mhogrefe/malachite/tree/master/malachite-q/src/bin_util/demo_and_bench).\n//!\n//! # Features\n//! - `32_bit_limbs`: Sets the type of [`Limb`](malachite_nz#limbs) to [`u32`] instead of the\n//!   default, [`u64`].\n//! - `test_build`: A large proportion of the code in this crate is only used for testing. For a\n//!   typical user, building this code would result in an unnecessarily long compilation time and\n//!   an unnecessarily large binary. My solution is to only build this code when the `test_build`\n//!   feature is enabled. If you want to run unit tests, you must enable `test_build`. However,\n//!   doctests don't require it, since they only test the public interface.\n//! - `bin_build`: This feature is used to build the code for demos and benchmarks, which also\n//!   takes a long time to build. Enabling this feature also enables `test_build`.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::type_complexity,\n    clippy::upper_case_acronyms,\n    clippy::multiple_bound_locations\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::use_self,\n    clippy::trivially_copy_pass_by_ref\n)]\n#![cfg_attr(\n    not(any(feature = \"test_build\", feature = \"random\", feature = \"std\")),\n    no_std\n)]\n\nextern crate alloc;\n\n#[macro_use]\nextern crate malachite_base;\nextern crate malachite_nz;\n#[cfg(feature = \"serde\")]\n#[macro_use]\nextern crate serde;\n\n#[cfg(feature = \"test_build\")]\nextern crate itertools;\n#[cfg(feature = \"test_build\")]\nextern crate num;\n#[cfg(feature = \"test_build\")]\nextern crate rug;\n\nuse malachite_base::named::Named;\n#[cfg(feature = \"test_build\")]\nuse malachite_base::num::arithmetic::traits::CoprimeWith;\nuse malachite_base::num::basic::traits::{NegativeOne, One, OneHalf, Two, Zero};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::natural::Natural;\n\n/// A rational number.\n///\n/// `Rational`s whose numerator and denominator have 64 significant bits or fewer can be represented\n/// without any memory allocation. (Unless Malachite is compiled with `32_bit_limbs`, in which case\n/// the limit is 32).\n#[derive(Clone, Hash, Eq, PartialEq)]\n#[cfg_attr(feature = \"serde\", derive(Deserialize, Serialize))]\npub struct Rational {\n    // whether the `Rational` is non-negative\n    #[cfg_attr(feature = \"serde\", serde(rename = \"s\"))]\n    pub(crate) sign: bool,\n    #[cfg_attr(feature = \"serde\", serde(rename = \"n\"))]\n    pub(crate) numerator: Natural,\n    #[cfg_attr(feature = \"serde\", serde(rename = \"d\"))]\n    pub(crate) denominator: Natural,\n}\n\nimpl Rational {\n    // Returns true iff `self` is valid.\n    //\n    // To be valid, its denominator must be nonzero, its numerator and denominator must be\n    // relatively prime, and if its numerator is zero, then `sign` must be `true`. All `Rational`s\n    // must be valid.\n    #[cfg(feature = \"test_build\")]\n    pub fn is_valid(&self) -> bool {\n        self.denominator != 0\n            && (self.sign || self.numerator != 0)\n            && (&self.numerator).coprime_with(&self.denominator)\n    }\n}\n\nimpl SignificantBits for &Rational {\n    /// Returns the sum of the bits needed to represent the numerator and denominator.\n    ///\n    /// # Worst-case complexity\n    /// Constant time and additional memory.\n    ///\n    /// # Examples\n    /// ```\n    /// use malachite_base::num::basic::traits::Zero;\n    /// use malachite_base::num::logic::traits::SignificantBits;\n    /// use malachite_q::Rational;\n    /// use std::str::FromStr;\n    ///\n    /// assert_eq!(Rational::ZERO.significant_bits(), 1);\n    /// assert_eq!(\n    ///     Rational::from_str(\"-100/101\").unwrap().significant_bits(),\n    ///     14\n    /// );\n    /// ```\n    fn significant_bits(self) -> u64 {\n        self.numerator.significant_bits() + self.denominator.significant_bits()\n    }\n}\n\n/// The constant 0.\nimpl Zero for Rational {\n    const ZERO: Self = Self {\n        sign: true,\n        numerator: Natural::ZERO,\n        denominator: Natural::ONE,\n    };\n}\n\n/// The constant 1.\nimpl One for Rational {\n    const ONE: Self = Self {\n        sign: true,\n        numerator: Natural::ONE,\n        denominator: Natural::ONE,\n    };\n}\n\n/// The constant 2.\nimpl Two for Rational {\n    const TWO: Self = Self {\n        sign: true,\n        numerator: Natural::TWO,\n        denominator: Natural::ONE,\n    };\n}\n\n/// The constant -1.\nimpl NegativeOne for Rational {\n    const NEGATIVE_ONE: Self = Self {\n        sign: false,\n        numerator: Natural::ONE,\n        denominator: Natural::ONE,\n    };\n}\n\n/// The constant 1/2.\nimpl OneHalf for Rational {\n    const ONE_HALF: Self = Self {\n        sign: true,\n        numerator: Natural::ONE,\n        denominator: Natural::TWO,\n    };\n}\n\nimpl Default for Rational {\n    /// The default value of a [`Rational`], 0.\n    fn default() -> Self {\n        Self::ZERO\n    }\n}\n\n// Implements `Named` for `Rational`.\nimpl_named!(Rational);\n\n/// Traits for arithmetic.\npub mod arithmetic;\n/// Traits for comparing [`Rational`]s for equality or order.\npub mod comparison;\n/// Traits for converting to and from [`Rational`]s, converting to and from strings, and extracting\n/// digits and continued fractions.\npub mod conversion;\n/// Iterators that generate [`Rational`]s without repetition.\npub mod exhaustive;\n#[cfg(feature = \"random\")]\n/// Iterators that generate [`Rational`]s randomly.\npub mod random;\n\n#[cfg(feature = \"test_build\")]\npub mod test_util;\n"
  },
  {
    "path": "malachite-q/src/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::arithmetic::denominators_in_closed_interval::DenominatorsInClosedRationalInterval;\nuse crate::arithmetic::traits::DenominatorsInClosedInterval;\nuse crate::exhaustive::RationalsWithDenominator;\nuse core::cmp::min;\nuse malachite_base::bools::random::{RandomBools, random_bools};\nuse malachite_base::iterators::iterator_cache::IteratorCache;\nuse malachite_base::num::arithmetic::traits::{\n    CoprimeWith, Reciprocal, RoundToMultiple, UnsignedAbs,\n};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::{ExactFrom, RoundingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::num::random::geometric::{\n    GeometricRandomNaturalValues, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::striped::StripedBitSource;\nuse malachite_base::num::random::{\n    RandomPrimitiveInts, VariableRangeGenerator, random_primitive_ints,\n};\nuse malachite_base::random::Seed;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::{\n    RandomIntegerRange, RandomIntegerRangeToInfinity, get_random_integer_from_range_to_infinity,\n    get_random_integer_from_range_to_negative_infinity,\n    get_striped_random_integer_from_range_to_infinity,\n    get_striped_random_integer_from_range_to_negative_infinity, random_integer_range,\n    random_integer_range_to_infinity, random_integer_range_to_negative_infinity,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::{\n    RandomNaturals, StripedRandomNaturals, random_naturals, random_positive_naturals,\n    striped_random_naturals, striped_random_positive_naturals,\n};\nuse std::collections::HashMap;\n\n/// Generates random non-negative [`Rational`]s, given an iterator of random [`Natural`] numerators\n/// and denominators.\n#[derive(Clone, Debug)]\npub struct RandomRationalsFromSingle<I: Iterator<Item = Natural>> {\n    xs: I,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomRationalsFromSingle<I> {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        Some(Rational::from_naturals(\n            self.xs.next().unwrap(),\n            self.xs.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates random positive [`Rational`]s with a specified numerator and denominator mean bit\n/// length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. Then the numerator\n/// and denominator are chosen from all positive [`Natural`]s with that bit length.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_positive_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(random_positive_rationals(EXAMPLE_SEED, 32, 1), 10),\n///     \"[11/2, 89/27922830575, 46627409/3788983764809694, 8/11316951483471, \\\n///     11/1005760138411689342464923704482, 948931/42716754, \\\n///     81013760999253680590984897748479904878392/23, 1/97645164585502, 1558028859598/29, \\\n///     200127331174844881647/4058622214797175252, ...]\"\n/// )\n/// ```\npub fn random_positive_rationals(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromSingle<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomRationalsFromSingle {\n        xs: random_positive_naturals(seed, mean_bits_numerator, mean_bits_denominator),\n    }\n}\n\n/// Generates random non-negative [`Rational`]s, given an iterator of random [`Natural`] numerators\n/// and an iterator of random [`Natural`] denominators.\n#[derive(Clone, Debug)]\npub struct RandomRationalsFromDouble<I: Iterator<Item = Natural>, J: Iterator<Item = Natural>> {\n    xs: I,\n    ys: J,\n}\n\nimpl<I: Iterator<Item = Natural>, J: Iterator<Item = Natural>> Iterator\n    for RandomRationalsFromDouble<I, J>\n{\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        Some(Rational::from_naturals(\n            self.xs.next().unwrap(),\n            self.ys.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates random non-negative [`Rational`]s with a specified numerator and denominator mean bit\n/// length.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_non_negative_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(random_non_negative_rationals(EXAMPLE_SEED, 32, 1), 10),\n///     \"[7301/34, 4183103/1234731190583, 54812347098686/6195807891591254727, 812739/17841539017, \\\n///     665/908, 677/1138982845180, 166/22491855393807861245619791028129, 270142/5, \\\n///     52040856788711439301087669967/15975369961878544862054, 5718607/1953563256716085077, ...]\"\n/// )\n/// ```\npub fn random_non_negative_rationals(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromDouble<\n    RandomNaturals<GeometricRandomNaturalValues<u64>>,\n    RandomNaturals<GeometricRandomNaturalValues<u64>>,\n> {\n    RandomRationalsFromDouble {\n        xs: random_naturals(\n            seed.fork(\"numerator\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        ys: random_positive_naturals(\n            seed.fork(\"denominator\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates random negative [`Rational`]s, given an iterator of positive [`Rational`]s.\n#[derive(Clone, Debug)]\npub struct NegativeRationals<I: Iterator<Item = Rational>> {\n    xs: I,\n}\n\nimpl<I: Iterator<Item = Rational>> Iterator for NegativeRationals<I> {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        self.xs.next().map(|mut q| {\n            q.sign = false;\n            q\n        })\n    }\n}\n\n/// Generates random negative [`Rational`]s with a specified numerator and denominator mean bit\n/// length.\n///\n/// The actual bit length is chosen from a geometric distribution with mean $m$, where $m$ is\n/// `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than 1. Then the numerator\n/// and denominator are chosen from all positive [`Natural`]s with that bit length. Finally, the\n/// resulting [`Rational`] is reduced and negated.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_negative_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(random_negative_rationals(EXAMPLE_SEED, 32, 1), 10),\n///     \"[-11/2, -89/27922830575, -46627409/3788983764809694, -8/11316951483471, \\\n///     -11/1005760138411689342464923704482, -948931/42716754, \\\n///     -81013760999253680590984897748479904878392/23, -1/97645164585502, -1558028859598/29, \\\n///     -200127331174844881647/4058622214797175252, ...]\"\n/// )\n/// ```\npub fn random_negative_rationals(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> NegativeRationals<RandomRationalsFromSingle<RandomNaturals<GeometricRandomNaturalValues<u64>>>>\n{\n    NegativeRationals {\n        xs: random_positive_rationals(seed, mean_bits_numerator, mean_bits_denominator),\n    }\n}\n\n/// Generates random non-negative [`Rational`]s, given an iterator of random [`Natural`] numerators\n/// and an iterator of [`bool`] signs.\n#[derive(Clone, Debug)]\npub struct RandomRationalsFromSingleAndSign<I: Iterator<Item = Natural>> {\n    bs: RandomBools,\n    xs: I,\n}\n\nimpl<I: Iterator<Item = Natural>> Iterator for RandomRationalsFromSingleAndSign<I> {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        Some(Rational::from_sign_and_naturals(\n            self.bs.next().unwrap(),\n            self.xs.next().unwrap(),\n            self.xs.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates random nonzero [`Rational`]s with a specified numerator and denominator mean bit\n/// length.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_nonzero_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(random_nonzero_rationals(EXAMPLE_SEED, 32, 1), 10),\n///     \"[-80861953616/9687130509484985, -14557437513/313, 100721397389/392237929981, \\\n///     713431423/1285, -3887883364/889, 14185/969, 12609/11359517108746272468338071, \\\n///     3443/4354945, 1/29, 5551/892095, ...]\"\n/// )\n/// ```\npub fn random_nonzero_rationals(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromSingleAndSign<RandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomRationalsFromSingleAndSign {\n        bs: random_bools(seed.fork(\"sign\")),\n        xs: random_positive_naturals(seed.fork(\"abs\"), mean_bits_numerator, mean_bits_denominator),\n    }\n}\n\n/// Generates random non-negative [`Rational`]s, given an iterator of random [`Natural`] numerators,\n/// an iterator of random [`Natural`] denominators, and an iterator of [`bool`] signs.\n#[derive(Clone, Debug)]\npub struct RandomRationalsFromDoubleAndSign<\n    I: Iterator<Item = Natural>,\n    J: Iterator<Item = Natural>,\n> {\n    pub bs: RandomBools,\n    pub xs: I,\n    pub ys: J,\n}\n\nimpl<I: Iterator<Item = Natural>, J: Iterator<Item = Natural>> Iterator\n    for RandomRationalsFromDoubleAndSign<I, J>\n{\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        Some(Rational::from_sign_and_naturals(\n            self.bs.next().unwrap(),\n            self.xs.next().unwrap(),\n            self.ys.next().unwrap(),\n        ))\n    }\n}\n\n/// Generates random [`Rational`]s with a specified numerator and denominator mean bit length.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero or if `mean_bits_numerator\n/// <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(random_rationals(EXAMPLE_SEED, 32, 1), 10),\n///     \"[-7301/34, -4183103/1234731190583, 54812347098686/6195807891591254727, \\\n///     812739/17841539017, -665/908, 677/1138982845180, 166/22491855393807861245619791028129, \\\n///     270142/5, 52040856788711439301087669967/15975369961878544862054, \\\n///     5718607/1953563256716085077, ...]\"\n/// )\n/// ```\npub fn random_rationals(\n    seed: Seed,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromDoubleAndSign<\n    RandomNaturals<GeometricRandomNaturalValues<u64>>,\n    RandomNaturals<GeometricRandomNaturalValues<u64>>,\n> {\n    RandomRationalsFromDoubleAndSign {\n        bs: random_bools(seed.fork(\"sign\")),\n        xs: random_naturals(\n            seed.fork(\"numerator\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        ys: random_positive_naturals(\n            seed.fork(\"denominator\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates striped random positive [`Rational`]s with a specified mean numerator and denominator\n/// bit length.\n///\n/// The actual numerator and denominator bit lengths are chosen from a geometric distribution with\n/// mean $m$, where $m$ is `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than\n/// `1`. A striped bit sequence with the given stripe parameter is generated and truncated at the\n/// bit lengths to produce the numerators and denominators. The highest bits are forced to be `1`.\n/// Finally, the [`Rational`] is reduced.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::striped_random_positive_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_positive_rationals(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[4, 1/268681216, 75493376/9007199120523391, 8/8796094070783, \\\n///     8/950737950171027935941967741439, 1040391/33554432, \\\n///     2813000899879757964630563421437095845888, 1/79164837199872, 2199023255551/16, \\\n///     220784470296873664512/4611685966886694919, ...]\"\n/// )\n/// ```\npub fn striped_random_positive_rationals(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromSingle<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomRationalsFromSingle {\n        xs: striped_random_positive_naturals(\n            seed,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates striped random non-positive [`Rational`]s with a specified mean numerator and\n/// denominator bit length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::striped_random_non_negative_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_non_negative_rationals(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[8192/127, 16776704/4396972769407, 8796093005951/648518346332962816, 87381/2863267840, \\\n///     1024/2043, 51/58408828928, 85/13521606402434254795714066382848, 270335/7, \\\n///     59421159664630116152453890047/9444741445172838006656, 6291455/1154891846623166464, ...]\"\n/// )\n/// ```\npub fn striped_random_non_negative_rationals(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromDouble<\n    StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n    StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n> {\n    RandomRationalsFromDouble {\n        xs: striped_random_naturals(\n            seed.fork(\"numerator\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        ys: striped_random_positive_naturals(\n            seed.fork(\"denominator\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates striped random negative [`Rational`]s with a specified mean numerator and denominator\n/// bit length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::striped_random_negative_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_negative_rationals(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[-4, -1/268681216, -75493376/9007199120523391, -8/8796094070783, \\\n///     -8/950737950171027935941967741439, -1040391/33554432, \\\n///     -2813000899879757964630563421437095845888, -1/79164837199872, -2199023255551/16, \\\n///     -220784470296873664512/4611685966886694919, ...]\"\n/// )\n/// ```\npub fn striped_random_negative_rationals(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> NegativeRationals<\n    RandomRationalsFromSingle<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>>,\n> {\n    NegativeRationals {\n        xs: striped_random_positive_rationals(\n            seed,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates striped random nonzero [`Rational`]s with a specified mean numerator and denominator\n/// bit length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::striped_random_nonzero_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_nonzero_rationals(EXAMPLE_SEED, 16, 1, 32, 1),\n///         10\n///     ),\n///     \"[-68720000000/18006083452797439, -2545165805/29, 549754781664/1236950581247, \\\n///     1065353727/2047, -2147745791/513, 16128/575, 8192/17000482516899619632318463, \\\n///     18431/16778240, 1/31, 4096/526335, ...]\"\n/// )\n/// ```\npub fn striped_random_nonzero_rationals(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromSingleAndSign<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> {\n    RandomRationalsFromSingleAndSign {\n        bs: random_bools(seed.fork(\"sign\")),\n        xs: striped_random_positive_naturals(\n            seed.fork(\"abs\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates striped random [`Rational`]s with a specified mean numerator and denominator bit\n/// length.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, or if\n/// `mean_bits_numerator <= mean_bits_denominator`.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::striped_random_rationals;\n///\n/// assert_eq!(\n///     prefix_to_string(striped_random_rationals(EXAMPLE_SEED, 16, 1, 32, 1), 10),\n///     \"[-8192/127, -16776704/4396972769407, 8796093005951/648518346332962816, 87381/2863267840, \\\n///     -1024/2043, 51/58408828928, 85/13521606402434254795714066382848, 270335/7, \\\n///     59421159664630116152453890047/9444741445172838006656, 6291455/1154891846623166464, ...]\"\n/// )\n/// ```\npub fn striped_random_rationals(\n    seed: Seed,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalsFromDoubleAndSign<\n    StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n    StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n> {\n    RandomRationalsFromDoubleAndSign {\n        bs: random_bools(seed.fork(\"sign\")),\n        xs: striped_random_naturals(\n            seed.fork(\"numerator\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        ys: striped_random_positive_naturals(\n            seed.fork(\"denominator\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates random [`Rational`]s greater than or equal to a lower bound $a$ and with a specific\n/// denominator.\n///\n/// The mean bit length $m$ of the absolute values of the numerators of the generated values is\n/// specified. $m$ is equal to `mean_numerator_bits_numerator / mean_numerator_bits_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a > 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::random::random_rational_with_denominator_range_to_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_with_denominator_range_to_infinity(\n///             EXAMPLE_SEED,\n///             Natural::from(3u32),\n///             Rational::from_signeds(-3i32, 2),\n///             3,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[1/3, 4/3, -2/3, 94/3, 4/3, -2/3, 1/3, 145/3, 7/3, 1/3, ...]\"\n/// )\n/// ```\npub fn random_rational_with_denominator_range_to_infinity(\n    seed: Seed,\n    d: Natural,\n    a: Rational,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n) -> RationalsWithDenominator<RandomIntegerRangeToInfinity> {\n    assert_ne!(d, 0u32);\n    RationalsWithDenominator {\n        numerators: random_integer_range_to_infinity(\n            seed,\n            Integer::rounding_from(a * Rational::from(&d), Ceiling).0,\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n        ),\n        denominator: d,\n    }\n}\n\n/// Generates random [`Rational`]s less than or equal to a lower bound $a$ and with a specific\n/// denominator.\n///\n/// The mean bit length $m$ of the absolute values of the numerators of the generated values is\n/// specified. $m$ is equal to `mean_numerator_bits_numerator / mean_numerator_bits_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a < 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::random::random_rational_with_denominator_range_to_negative_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_with_denominator_range_to_negative_infinity(\n///             EXAMPLE_SEED,\n///             Natural::from(3u32),\n///             Rational::from_unsigneds(3u32, 2),\n///             3,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[1/3, 4/3, -56/3, -2/3, 2/3, -1/3, -7/3, -11/3, -17/3, 4/3, ...]\"\n/// )\n/// ```\npub fn random_rational_with_denominator_range_to_negative_infinity(\n    seed: Seed,\n    d: Natural,\n    a: Rational,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n) -> RationalsWithDenominator<RandomIntegerRangeToInfinity> {\n    assert_ne!(d, 0u32);\n    RationalsWithDenominator {\n        numerators: random_integer_range_to_negative_infinity(\n            seed,\n            Integer::rounding_from(a * Rational::from(&d), Floor).0,\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n        ),\n        denominator: d,\n    }\n}\n\n/// Generates random [`Rational`]s in the half-open interval $[a, b)$ and with a specific\n/// denominator.\n///\n/// In general, the [`Rational`]s are not generated uniformly. Instead, [`Rational`]s whose\n/// numerators have smaller bit lengths are generated more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_numerator_bits_numerator / mean_numerator_bits_denominator`. It is not actually the mean\n/// bit length of the numerators, though it approaches the mean bit length of the numerators minus\n/// $\\lceil ad \\right$ as $\\log (b/a)$ approaches infinity. $m$ cannot be 0, and must be greater\n/// than the bit length of the numerator of the generated [`Rational`] with the smallest absolute\n/// value, but it may be arbitrarily large. The smaller it is, the more quickly the probabilities\n/// decrease as bit length increases. The larger it is, the more closely the distribution approaches\n/// a uniform distribution over the bit lengths.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if $a \\geq b$, if `mean_numerator_bits_numerator` or `mean_numerator_bits_denominator`\n/// are zero, if their ratio is less than or equal to the bit length of the [`Rational`] with\n/// smallest absolute numerator in the range, or if they are too large and manipulating them leads\n/// to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::random::random_rational_with_denominator_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_with_denominator_range(\n///             EXAMPLE_SEED,\n///             Natural::from(100u32),\n///             Rational::from_unsigneds(1u32, 3),\n///             Rational::from_unsigneds(1u32, 2),\n///             3,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[41/100, 43/100, 41/100, 41/100, 39/100, 41/100, 49/100, 41/100, 41/100, 39/100, ...]\"\n/// )\n/// ```\npub fn random_rational_with_denominator_range(\n    seed: Seed,\n    d: Natural,\n    a: Rational,\n    b: Rational,\n    mut mean_numerator_bits_numerator: u64,\n    mut mean_numerator_bits_denominator: u64,\n) -> RationalsWithDenominator<RandomIntegerRange> {\n    assert_ne!(d, 0u32);\n    assert!(a < b);\n    let q_d = Rational::from(&d);\n    let a_i = Integer::rounding_from(a * &q_d, Ceiling).0;\n    let upper_included = b.denominator_ref() == &d;\n    let mut b_i = Integer::rounding_from(b * q_d, Floor).0;\n    if !upper_included {\n        b_i += Integer::ONE;\n    }\n    if (a_i >= 0) == (b_i >= 0) {\n        let (n, d) = (Rational::from_unsigneds(\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n        ) + Rational::from(min(a_i.significant_bits(), b_i.significant_bits())))\n        .into_numerator_and_denominator();\n        mean_numerator_bits_numerator = u64::exact_from(&n);\n        mean_numerator_bits_denominator = u64::exact_from(&d);\n    }\n    RationalsWithDenominator {\n        numerators: random_integer_range(\n            seed,\n            a_i,\n            b_i,\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n        ),\n        denominator: d,\n    }\n}\n\n/// Generates random [`Rational`]s in the closed interval $[a, b]$ and with a specific denominator.\n///\n/// In general, the [`Rational`]s are not generated uniformly. Instead, [`Rational`]s whose\n/// numerators have smaller bit lengths are generated more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_numerator_bits_numerator / mean_numerator_bits_denominator`. It is not actually the mean\n/// bit length of the numerators, though it approaches the mean bit length of the numerators minus\n/// $\\lceil ad \\right$ as $\\log (b/a)$ approaches infinity. $m$ cannot be 0, and must be greater\n/// than the bit length of the numerator of the generated [`Rational`] with the smallest absolute\n/// value, but it may be arbitrarily large. The smaller it is, the more quickly the probabilities\n/// decrease as bit length increases. The larger it is, the more closely the distribution approaches\n/// a uniform distribution over the bit lengths.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if $a > b$, if `mean_numerator_bits_numerator` or `mean_numerator_bits_denominator` are\n/// zero, if their ratio is less than or equal to the bit length of the [`Rational`] with smallest\n/// absolute numerator in the range, or if they are too large and manipulating them leads to\n/// arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_nz::natural::Natural;\n/// use malachite_q::random::random_rational_with_denominator_inclusive_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_with_denominator_inclusive_range(\n///             EXAMPLE_SEED,\n///             Natural::from(100u32),\n///             Rational::from_unsigneds(1u32, 3),\n///             Rational::from_unsigneds(1u32, 2),\n///             3,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[41/100, 43/100, 41/100, 41/100, 39/100, 41/100, 49/100, 41/100, 41/100, 39/100, ...]\"\n/// )\n/// ```\npub fn random_rational_with_denominator_inclusive_range(\n    seed: Seed,\n    d: Natural,\n    a: Rational,\n    b: Rational,\n    mut mean_numerator_bits_numerator: u64,\n    mut mean_numerator_bits_denominator: u64,\n) -> RationalsWithDenominator<RandomIntegerRange> {\n    assert_ne!(d, 0u32);\n    assert!(a <= b);\n    let q_d = Rational::from(&d);\n    let a_i = Integer::rounding_from(a * &q_d, Ceiling).0;\n    let b_i = Integer::rounding_from(b * q_d, Floor).0 + Integer::ONE;\n    if (a_i >= 0) == (b_i >= 0) {\n        let (n, d) = (Rational::from_unsigneds(\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n        ) + Rational::from(min(a_i.significant_bits(), b_i.significant_bits())))\n        .into_numerator_and_denominator();\n        mean_numerator_bits_numerator = u64::exact_from(&n);\n        mean_numerator_bits_denominator = u64::exact_from(&d);\n    }\n    RationalsWithDenominator {\n        numerators: random_integer_range(\n            seed,\n            a_i,\n            b_i,\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n        ),\n        denominator: d,\n    }\n}\n\n/// Generates random [`Rational`]s greater than or equal to a lower bound. See\n/// [`random_rational_range_to_infinity`] for more details.\n#[derive(Clone, Debug)]\npub struct RandomRationalRangeToInfinity {\n    a: Rational,\n    limbs: RandomPrimitiveInts<u64>,\n    range_generator: VariableRangeGenerator,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    denominators: RandomNaturals<GeometricRandomNaturalValues<u64>>,\n}\n\nimpl Iterator for RandomRationalRangeToInfinity {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        let d = self.denominators.next().unwrap();\n        let numerator_bound = Integer::rounding_from(&self.a * Rational::from(&d), Ceiling).0;\n        let (numerator, denominator) = (Rational::from(d.significant_bits())\n            + Rational::from_unsigneds(self.mean_bits_numerator, self.mean_bits_denominator))\n        .into_numerator_and_denominator();\n        let numerator = u64::exact_from(&numerator);\n        let denominator = u64::exact_from(&denominator);\n        loop {\n            let n = get_random_integer_from_range_to_infinity(\n                &mut self.limbs,\n                &mut self.range_generator,\n                numerator_bound.clone(),\n                numerator,\n                denominator,\n            );\n            if n.unsigned_abs_ref().coprime_with(&d) {\n                return Some(Rational {\n                    sign: n >= 0,\n                    numerator: n.unsigned_abs(),\n                    denominator: d,\n                });\n            }\n        }\n    }\n}\n\n/// Generates random [`Rational`]s greater than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the absolute values of the numerators of the generated values is\n/// specified. $m$ is equal to `mean_numerator_bits_numerator / mean_numerator_bits_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a > 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_rational_range_to_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_range_to_infinity(EXAMPLE_SEED, Rational::from_signeds(-3i32, 2), 3, 1),\n///         10\n///     ),\n///     \"[2/3, 56, 1/2, -1/34, -15/23, -4/5, 1/2, 5, 195, -1, ...]\"\n/// )\n/// ```\npub fn random_rational_range_to_infinity(\n    seed: Seed,\n    a: Rational,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalRangeToInfinity {\n    RandomRationalRangeToInfinity {\n        a,\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n        range_generator: VariableRangeGenerator::new(seed.fork(\"range generator\")),\n        mean_bits_numerator,\n        mean_bits_denominator,\n        denominators: random_positive_naturals(\n            seed.fork(\"denominators\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates random [`Rational`]s less than or equal to a lower bound. See\n/// [`random_rational_range_to_negative_infinity`] for more details.\n#[derive(Clone, Debug)]\npub struct RandomRationalRangeToNegativeInfinity {\n    a: Rational,\n    limbs: RandomPrimitiveInts<u64>,\n    range_generator: VariableRangeGenerator,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    denominators: RandomNaturals<GeometricRandomNaturalValues<u64>>,\n}\n\nimpl Iterator for RandomRationalRangeToNegativeInfinity {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        let d = self.denominators.next().unwrap();\n        let numerator_bound = Integer::rounding_from(&self.a * Rational::from(&d), Floor).0;\n        let (numerator, denominator) = (Rational::from(d.significant_bits())\n            + Rational::from_unsigneds(self.mean_bits_numerator, self.mean_bits_denominator))\n        .into_numerator_and_denominator();\n        let numerator = u64::exact_from(&numerator);\n        let denominator = u64::exact_from(&denominator);\n        loop {\n            let n = get_random_integer_from_range_to_negative_infinity(\n                &mut self.limbs,\n                &mut self.range_generator,\n                numerator_bound.clone(),\n                numerator,\n                denominator,\n            );\n            if n.unsigned_abs_ref().coprime_with(&d) {\n                return Some(Rational {\n                    sign: n >= 0,\n                    numerator: n.unsigned_abs(),\n                    denominator: d,\n                });\n            }\n        }\n    }\n}\n\n/// Generates random [`Rational`]s less than or equal to a lower bound $a$.\n///\n/// The mean bit length $m$ of the absolute values of the numerators of the generated values is\n/// specified. $m$ is equal to `mean_bits_numerator / mean_bits_denominator`.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_bits_numerator /\n/// mean_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a > 0$ and their ratio\n/// is less than or equal to the bit length of $a$, or if they are too large and manipulating them\n/// leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_rational_range_to_negative_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_range_to_negative_infinity(\n///             EXAMPLE_SEED,\n///             Rational::from_signeds(-3i32, 2),\n///             3,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[-8/3, -114, -31/2, -1187/34, -61/23, -81/5, -3/2, -19, -82, -312, ...]\"\n/// )\n/// ```\npub fn random_rational_range_to_negative_infinity(\n    seed: Seed,\n    a: Rational,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> RandomRationalRangeToNegativeInfinity {\n    RandomRationalRangeToNegativeInfinity {\n        a,\n        limbs: random_primitive_ints(seed.fork(\"limbs\")),\n        range_generator: VariableRangeGenerator::new(seed.fork(\"range generator\")),\n        mean_bits_numerator,\n        mean_bits_denominator,\n        denominators: random_positive_naturals(\n            seed.fork(\"denominators\"),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates random [`Rational`]s in a half-open interval $[a,b)$. See [`random_rational_range`]\n/// for more details.\n#[derive(Clone, Debug)]\npub struct RandomRationalRange {\n    seed: Seed,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n    a: Rational,\n    b: Rational,\n    denominators: IteratorCache<DenominatorsInClosedRationalInterval>,\n    denominator_map: HashMap<Natural, RationalsWithDenominator<RandomIntegerRange>>,\n    indices: GeometricRandomNaturalValues<usize>,\n}\n\nimpl Iterator for RandomRationalRange {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        loop {\n            let d = self.denominators.get(self.indices.next().unwrap()).unwrap();\n            if (&self.a)\n                .round_to_multiple(Rational::from(d).reciprocal(), Ceiling)\n                .0\n                >= self.b\n            {\n                // This can happen when d is the denominator of b\n                continue;\n            }\n            return self\n                .denominator_map\n                .entry(d.clone())\n                .or_insert_with(|| {\n                    random_rational_with_denominator_range(\n                        self.seed.fork(&d.to_string()),\n                        d.clone(),\n                        self.a.clone(),\n                        self.b.clone(),\n                        self.mean_numerator_bits_numerator,\n                        self.mean_numerator_bits_denominator,\n                    )\n                })\n                .next();\n        }\n    }\n}\n\n/// Generates random [`Rational`]s in the half-open interval $[a, b)$.\n///\n/// In general, the [`Rational`]s are not generated uniformly. Instead, [`Rational`]s whose\n/// numerators have smaller bit lengths are generated more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_numerator_bits_numerator / mean_numerator_bits_denominator`. It is not actually the mean\n/// bit length of the numerators, though it approaches the mean bit length of the numerators minus\n/// $\\lceil ad \\right$ as $\\log (b/a)$ approaches infinity. $m$ cannot be 0, and must be greater\n/// than the bit length of the numerator of the generated [`Rational`] with the smallest absolute\n/// value, but it may be arbitrarily large. The smaller it is, the more quickly the probabilities\n/// decrease as bit length increases. The larger it is, the more closely the distribution approaches\n/// a uniform distribution over the bit lengths.\n///\n/// The distribution of denominators is parametrized by `mean_denominator_index_numerator /\n/// mean_denominator_index_denominator.` The larger this value is, the larger the average\n/// denominator produced.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if $a \\geq b$, if `mean_numerator_bits_numerator`, `mean_numerator_bits_denominator`,\n/// `mean_denominator_index_numerator`, or `mean_denominator_index_denominator` are zero, if\n/// `mean_numerator_bits_numerator / mean_numerator_bits_denominator` is less than or equal to the\n/// bit length of the [`Rational`] with smallest absolute numerator in the range, or if any of these\n/// values are too are too large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_rational_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_range(\n///             EXAMPLE_SEED,\n///             Rational::from_unsigneds(1u32, 3),\n///             Rational::from_unsigneds(1u32, 2),\n///             3,\n///             1,\n///             10,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[1/3, 4/9, 7/19, 5/13, 13/28, 4/9, 5/14, 7/19, 14/33, 8/17, ...]\"\n/// )\n/// ```\npub fn random_rational_range(\n    seed: Seed,\n    a: Rational,\n    b: Rational,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n    mean_denominator_index_numerator: u64,\n    mean_denominator_index_denominator: u64,\n) -> RandomRationalRange {\n    assert!(a < b);\n    assert_ne!(mean_numerator_bits_denominator, 0);\n    assert_ne!(mean_denominator_index_denominator, 0);\n    RandomRationalRange {\n        seed: seed.fork(\"numerators\"),\n        mean_numerator_bits_numerator,\n        mean_numerator_bits_denominator,\n        a: a.clone(),\n        b: b.clone(),\n        denominators: IteratorCache::new(Rational::denominators_in_closed_interval(a, b)),\n        denominator_map: HashMap::new(),\n        indices: geometric_random_unsigneds(\n            seed.fork(\"indices\"),\n            mean_denominator_index_numerator,\n            mean_denominator_index_denominator,\n        ),\n    }\n}\n\n#[doc(hidden)]\n#[derive(Clone, Debug)]\npub struct RandomRationalInclusiveRangeInner {\n    seed: Seed,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n    a: Rational,\n    b: Rational,\n    denominators: IteratorCache<DenominatorsInClosedRationalInterval>,\n    denominator_map: HashMap<Natural, RationalsWithDenominator<RandomIntegerRange>>,\n    indices: GeometricRandomNaturalValues<usize>,\n}\n\nimpl Iterator for RandomRationalInclusiveRangeInner {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        let d = self.denominators.get(self.indices.next().unwrap()).unwrap();\n        self.denominator_map\n            .entry(d.clone())\n            .or_insert_with(|| {\n                random_rational_with_denominator_inclusive_range(\n                    self.seed.fork(&d.to_string()),\n                    d.clone(),\n                    self.a.clone(),\n                    self.b.clone(),\n                    self.mean_numerator_bits_numerator,\n                    self.mean_numerator_bits_denominator,\n                )\n            })\n            .next()\n    }\n}\n\n/// Generates random [`Rational`]s in a closed interval $\\[a,b\\]$. See\n/// [`random_rational_inclusive_range`] for more details.\n#[allow(clippy::large_enum_variant)]\n#[derive(Clone, Debug)]\npub enum RandomRationalInclusiveRange {\n    Single(Rational),\n    Multiple(RandomRationalInclusiveRangeInner),\n}\n\nimpl Iterator for RandomRationalInclusiveRange {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        match self {\n            Self::Single(x) => Some(x.clone()),\n            Self::Multiple(xs) => xs.next(),\n        }\n    }\n}\n\n/// Generates random [`Rational`]s in the closed interval $[a, b]$.\n///\n/// In general, the [`Rational`]s are not generated uniformly. Instead, [`Rational`]s whose\n/// numerators have smaller bit lengths are generated more frequently.\n///\n/// The distribution of generated values is parametrized by a number $m$, given by\n/// `mean_numerator_bits_numerator / mean_numerator_bits_denominator`. It is not actually the mean\n/// bit length of the numerators, though it approaches the mean bit length of the numerators minus\n/// $\\lceil ad \\right$ as $\\log (b/a)$ approaches infinity. $m$ cannot be 0, and must be greater\n/// than the bit length of the numerator of the generated [`Rational`] with the smallest absolute\n/// value, but it may be arbitrarily large. The smaller it is, the more quickly the probabilities\n/// decrease as bit length increases. The larger it is, the more closely the distribution approaches\n/// a uniform distribution over the bit lengths.\n///\n/// The distribution of denominators is parametrized by `mean_denominator_index_numerator /\n/// mean_denominator_index_denominator.` The larger this value is, the larger the average\n/// denominator produced.\n///\n/// The output length is infinite.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if $a>b$, if `mean_numerator_bits_numerator`, `mean_numerator_bits_denominator`,\n/// `mean_denominator_index_numerator`, or `mean_denominator_index_denominator` are zero, if\n/// `mean_numerator_bits_numerator / mean_numerator_bits_denominator` is less than or equal to the\n/// bit length of the [`Rational`] with smallest absolute numerator in the range, or if any of these\n/// values are too are too large and manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::random_rational_inclusive_range;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         random_rational_inclusive_range(\n///             EXAMPLE_SEED,\n///             Rational::from_unsigneds(1u32, 3),\n///             Rational::from_unsigneds(1u32, 2),\n///             3,\n///             1,\n///             10,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[1/3, 4/9, 1/2, 7/19, 5/13, 13/28, 1/2, 4/9, 1/2, 5/14, ...]\"\n/// )\n/// ```\npub fn random_rational_inclusive_range(\n    seed: Seed,\n    a: Rational,\n    b: Rational,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n    mean_denominator_index_numerator: u64,\n    mean_denominator_index_denominator: u64,\n) -> RandomRationalInclusiveRange {\n    assert!(a <= b);\n    if a == b {\n        return RandomRationalInclusiveRange::Single(a);\n    }\n    assert_ne!(mean_numerator_bits_denominator, 0);\n    assert_ne!(mean_denominator_index_denominator, 0);\n    RandomRationalInclusiveRange::Multiple(RandomRationalInclusiveRangeInner {\n        seed: seed.fork(\"numerators\"),\n        mean_numerator_bits_numerator,\n        mean_numerator_bits_denominator,\n        a: a.clone(),\n        b: b.clone(),\n        denominators: IteratorCache::new(Rational::denominators_in_closed_interval(a, b)),\n        denominator_map: HashMap::new(),\n        indices: geometric_random_unsigneds(\n            seed.fork(\"indices\"),\n            mean_denominator_index_numerator,\n            mean_denominator_index_denominator,\n        ),\n    })\n}\n\n/// Generates striped random [`Rational`]s greater than or equal to a lower bound. See\n/// [`striped_random_rational_range_to_infinity`] for more details.\n#[derive(Clone, Debug)]\npub struct StripedRandomRationalRangeToInfinity {\n    a: Rational,\n    xs: StripedBitSource,\n    range_generator: VariableRangeGenerator,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    denominators: StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n}\n\nimpl Iterator for StripedRandomRationalRangeToInfinity {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        let d = self.denominators.next().unwrap();\n        let numerator_bound = Integer::rounding_from(&self.a * Rational::from(&d), Ceiling).0;\n        let (numerator, denominator) = (Rational::from(d.significant_bits())\n            + Rational::from_unsigneds(self.mean_bits_numerator, self.mean_bits_denominator))\n        .into_numerator_and_denominator();\n        let numerator = u64::exact_from(&numerator);\n        let denominator = u64::exact_from(&denominator);\n        loop {\n            let n = get_striped_random_integer_from_range_to_infinity(\n                &mut self.xs,\n                &mut self.range_generator,\n                numerator_bound.clone(),\n                numerator,\n                denominator,\n            );\n            if n.unsigned_abs_ref().coprime_with(&d) {\n                return Some(Rational {\n                    sign: n >= 0,\n                    numerator: n.unsigned_abs(),\n                    denominator: d,\n                });\n            }\n        }\n    }\n}\n\n/// Generates striped random [`Rational`]s greater than or equal to a lower bound $a$.\n///\n/// The actual numerator and denominator bit lengths are chosen from a geometric distribution with\n/// mean $m$, where $m$ is `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than\n/// `1`. A striped bit sequence with the given stripe parameter is generated and truncated at the\n/// bit lengths to produce the numerators and denominators. The highest bits are forced to be `1`.\n/// Finally, the [`Rational`] is reduced.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a >\n/// 0$ and their ratio is less than or equal to the bit length of $a$, or if they are too large and\n/// manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::striped_random_rational_range_to_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_rational_range_to_infinity(\n///             EXAMPLE_SEED,\n///             Rational::from_signeds(-3i32, 2),\n///             10,\n///             1,\n///             3,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[3/2, 39, 239/2, -32/63, 127/16, 16383/4, -1/2, 1, 583664, 1, ...]\"\n/// )\n/// ```\npub fn striped_random_rational_range_to_infinity(\n    seed: Seed,\n    a: Rational,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomRationalRangeToInfinity {\n    StripedRandomRationalRangeToInfinity {\n        a,\n        xs: StripedBitSource::new(\n            seed.fork(\"xs\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        range_generator: VariableRangeGenerator::new(seed.fork(\"range generator\")),\n        mean_bits_numerator,\n        mean_bits_denominator,\n        denominators: striped_random_positive_naturals(\n            seed.fork(\"denominators\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n\n/// Generates random striped [`Rational`]s less than or equal to a lower bound. See\n/// [`striped_random_rational_range_to_negative_infinity`] for more details.\n#[derive(Clone, Debug)]\npub struct StripedRandomRationalRangeToNegativeInfinity {\n    a: Rational,\n    xs: StripedBitSource,\n    range_generator: VariableRangeGenerator,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    denominators: StripedRandomNaturals<GeometricRandomNaturalValues<u64>>,\n}\n\nimpl Iterator for StripedRandomRationalRangeToNegativeInfinity {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        let d = self.denominators.next().unwrap();\n        let numerator_bound = Integer::rounding_from(&self.a * Rational::from(&d), Floor).0;\n        let (numerator, denominator) = (Rational::from(d.significant_bits())\n            + Rational::from_unsigneds(self.mean_bits_numerator, self.mean_bits_denominator))\n        .into_numerator_and_denominator();\n        let numerator = u64::exact_from(&numerator);\n        let denominator = u64::exact_from(&denominator);\n        loop {\n            let n = get_striped_random_integer_from_range_to_negative_infinity(\n                &mut self.xs,\n                &mut self.range_generator,\n                numerator_bound.clone(),\n                numerator,\n                denominator,\n            );\n            if n.unsigned_abs_ref().coprime_with(&d) {\n                return Some(Rational {\n                    sign: n >= 0,\n                    numerator: n.unsigned_abs(),\n                    denominator: d,\n                });\n            }\n        }\n    }\n}\n\n/// Generates striped random [`Rational`]s less than or equal to a lower bound $a$.\n///\n/// The actual numerator and denominator bit lengths are chosen from a geometric distribution with\n/// mean $m$, where $m$ is `mean_bits_numerator / mean_bits_denominator`; $m$ must be greater than\n/// `1`. A striped bit sequence with the given stripe parameter is generated and truncated at the\n/// bit lengths to produce the numerators and denominators. The highest bits are forced to be `1`.\n/// Finally, the [`Rational`] is reduced.\n///\n/// The output length is infinite.\n///\n/// See [`StripedBitSource`] for information about generating striped random numbers.\n///\n/// # Expected complexity per iteration\n/// $T(n) = O(n (\\log n)^2 \\log\\log n)$\n///\n/// $M(n) = O(n \\log n)$\n///\n/// where $T$ is time, $M$ is additional memory, and $n$ is `mean_numerator_bits_numerator /\n/// mean_numerator_bits_denominator`.\n///\n/// # Panics\n/// Panics if `mean_stripe_denominator` is zero, if `mean_stripe_numerator <\n/// mean_stripe_denominator`, if `mean_bits_numerator` or `mean_bits_denominator` are zero, if $a <\n/// 0$ and their ratio is less than or equal to the bit length of $a$, or if they are too large and\n/// manipulating them leads to arithmetic overflow.\n///\n/// # Examples\n/// ```\n/// use malachite_base::iterators::prefix_to_string;\n/// use malachite_base::random::EXAMPLE_SEED;\n/// use malachite_q::random::striped_random_rational_range_to_negative_infinity;\n/// use malachite_q::Rational;\n///\n/// assert_eq!(\n///     prefix_to_string(\n///         striped_random_rational_range_to_negative_infinity(\n///             EXAMPLE_SEED,\n///             Rational::from_signeds(-3i32, 2),\n///             10,\n///             1,\n///             3,\n///             1\n///         ),\n///         10\n///     ),\n///     \"[-79/2, -7, -1051/2, -95/63, -255/16, -159/4, -3/2, -16, -2, -22, ...]\"\n/// )\n/// ```\npub fn striped_random_rational_range_to_negative_infinity(\n    seed: Seed,\n    a: Rational,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n) -> StripedRandomRationalRangeToNegativeInfinity {\n    StripedRandomRationalRangeToNegativeInfinity {\n        a,\n        xs: StripedBitSource::new(\n            seed.fork(\"xs\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n        ),\n        range_generator: VariableRangeGenerator::new(seed.fork(\"range generator\")),\n        mean_bits_numerator,\n        mean_bits_denominator,\n        denominators: striped_random_positive_naturals(\n            seed.fork(\"denominators\"),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::integer::Integer;\n\npub fn add_naive(x: Rational, y: Rational) -> Rational {\n    let x_sign = x >= 0u32;\n    let y_sign = y >= 0u32;\n    let (xn, xd) = x.into_numerator_and_denominator();\n    let (yn, yd) = y.into_numerator_and_denominator();\n    let n =\n        Integer::from_sign_and_abs(x_sign, xn * &yd) + Integer::from_sign_and_abs(y_sign, yn * &xd);\n    Rational::from_sign_and_naturals(n >= 0u32, n.unsigned_abs(), xd * yd)\n}\n\npub fn rational_sum_naive<I: Iterator<Item = Rational>>(xs: I) -> Rational {\n    let mut s = Rational::ZERO;\n    for x in xs {\n        s += x;\n    }\n    s\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/approximate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{Reciprocal, RoundToMultiple};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_natural_inclusive_range;\n\n// Slow! Only use for small `max_denominator`s\npub fn approximate_naive(x: &Rational, max_denominator: &Natural) -> Rational {\n    let mut nearest = Rational::ZERO;\n    for d in exhaustive_natural_inclusive_range(Natural::ONE, max_denominator.clone()) {\n        let q = x\n            .round_to_multiple(Rational::from(d).reciprocal(), Nearest)\n            .0;\n        if (x - &q).lt_abs(&(x - &nearest)) {\n            nearest = q;\n        }\n    }\n    nearest\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::basic::traits::Zero;\n\npub fn div_naive(x: Rational, y: Rational) -> Rational {\n    if x == 0u32 {\n        Rational::ZERO\n    } else if y == 0u32 {\n        panic!(\"division by zero\");\n    } else {\n        let sign = (x >= 0) == (y >= 0);\n        let (xn, xd) = x.into_numerator_and_denominator();\n        let (yn, yd) = y.into_numerator_and_denominator();\n        Rational::from_sign_and_naturals(sign, xn * yd, xd * yn)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod add;\npub mod approximate;\npub mod div;\npub mod mod_op;\npub mod mul;\npub mod sign;\npub mod simplest_rational_in_interval;\npub mod sub;\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::{Abs, Ceiling, Floor};\n\npub fn mod_op_naive(x: Rational, y: Rational) -> Rational {\n    let q = &x / &y;\n    x - y * Rational::from(q.floor())\n}\n\npub fn rem_naive(x: Rational, y: Rational) -> Rational {\n    let q = &x / &y;\n    let sign = (x >= 0u32) == (y >= 0u32);\n    let z = y * Rational::from(q.abs().floor());\n    if sign { x - z } else { x + z }\n}\n\npub fn ceiling_mod_naive(x: Rational, y: Rational) -> Rational {\n    let q = &x / &y;\n    x - y * Rational::from(q.ceiling())\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::basic::traits::{One, Zero};\n\npub fn mul_naive(x: Rational, y: Rational) -> Rational {\n    if x == 0u32 || y == 0u32 {\n        Rational::ZERO\n    } else {\n        let sign = (x >= 0) == (y >= 0);\n        let (xn, xd) = x.into_numerator_and_denominator();\n        let (yn, yd) = y.into_numerator_and_denominator();\n        Rational::from_sign_and_naturals(sign, xn * yn, xd * yd)\n    }\n}\n\npub fn rational_product_naive<I: Iterator<Item = Rational>>(xs: I) -> Rational {\n    let mut p = Rational::ONE;\n    for x in xs {\n        if x == 0 {\n            return Rational::ZERO;\n        }\n        p *= x;\n    }\n    p\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse num::BigRational;\nuse num::bigint::Sign;\nuse std::cmp::Ordering::{self, *};\n\npub fn num_sign(x: &BigRational) -> Ordering {\n    match x.numer().sign() {\n        Sign::NoSign => Equal,\n        Sign::Plus => Greater,\n        Sign::Minus => Less,\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/simplest_rational_in_interval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::conversion::traits::ContinuedFraction;\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::{Reciprocal, RoundToMultiple};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_positive_naturals;\nuse std::cmp::{Ordering::*, min};\n\n// Slow! Only run for rationals with small denominators\npub fn simplest_rational_in_open_interval_naive(x: &Rational, y: &Rational) -> Rational {\n    assert!(x < y);\n    if *x < 0u32 && *y > 0u32 {\n        return Rational::ZERO;\n    }\n    let neg_x;\n    let neg_y;\n    let (neg, x, y) = if *x < 0u32 {\n        neg_x = -x;\n        neg_y = -y;\n        (true, &neg_y, &neg_x)\n    } else {\n        (false, x, y)\n    };\n    for d in exhaustive_positive_naturals() {\n        let dr = Rational::from(d).reciprocal();\n        let mut q = x.round_to_multiple(&dr, Ceiling).0;\n        if q == *x {\n            q += dr;\n        }\n        if q < *y {\n            return if neg { -q } else { q };\n        }\n    }\n    unreachable!()\n}\n\nfn simplest_rational_helper(\n    floor_x: &Integer,\n    floor_y: &Integer,\n    cf_x: &[Natural],\n    cf_y: &[Natural],\n) -> Rational {\n    if floor_x != floor_y {\n        return Rational::from(min(floor_x, floor_y) + Integer::ONE);\n    }\n    let floor = floor_x;\n    for (i, (x, y)) in cf_x.iter().zip(cf_y.iter()).enumerate() {\n        if x != y {\n            let mut cf = cf_x[..i].to_vec();\n            cf.push(min(x, y) + Natural::ONE);\n            return Rational::from_continued_fraction_ref(floor, cf.iter());\n        }\n    }\n    let x_len = cf_x.len();\n    let y_len = cf_y.len();\n    Rational::from_continued_fraction(\n        floor.clone(),\n        match x_len.cmp(&y_len) {\n            Equal => panic!(),\n            Greater => {\n                let mut cf = cf_y.to_vec();\n                cf.push(cf_x[y_len].clone() + Natural::ONE);\n                cf.into_iter()\n            }\n            Less => {\n                let mut cf = cf_x.to_vec();\n                cf.push(cf_y[x_len].clone() + Natural::ONE);\n                cf.into_iter()\n            }\n        },\n    )\n}\n\nfn cf_variants(x: &Rational) -> (Integer, Integer, Vec<Natural>, Vec<Natural>) {\n    let (floor_1, cf_1) = x.continued_fraction();\n    let cf_1 = cf_1.collect_vec();\n    let mut cf_2 = cf_1.clone();\n    let mut floor_2 = floor_1.clone();\n    if let Some(last) = cf_2.last_mut() {\n        *last -= Natural::ONE;\n    } else {\n        floor_2 -= Integer::ONE;\n    }\n    cf_2.push(Natural::ONE);\n    (floor_1, floor_2, cf_1, cf_2)\n}\n\npub fn simplest_rational_in_open_interval_explicit(x: &Rational, y: &Rational) -> Rational {\n    assert!(x < y);\n    if *x < 0u32 && *y > 0u32 {\n        return Rational::ZERO;\n    }\n    let neg_x;\n    let neg_y;\n    let (neg, x, y) = if *x < 0u32 {\n        neg_x = -x;\n        neg_y = -y;\n        (true, &neg_y, &neg_x)\n    } else {\n        (false, x, y)\n    };\n    let (floor_x_1, floor_x_2, cf_x_1, cf_x_2) = cf_variants(x);\n    let (floor_y_1, floor_y_2, cf_y_1, cf_y_2) = cf_variants(y);\n    let mut best: Option<Rational> = None;\n    for (floor_x, cf_x) in [(&floor_x_1, &cf_x_1), (&floor_x_2, &cf_x_2)] {\n        for (floor_y, cf_y) in [(&floor_y_1, &cf_y_1), (&floor_y_2, &cf_y_2)] {\n            let candidate = simplest_rational_helper(floor_x, floor_y, cf_x, cf_y);\n            if candidate > *x\n                && candidate < *y\n                && (best.is_none()\n                    || candidate.denominator_ref() < best.as_ref().unwrap().denominator_ref())\n            {\n                best = Some(candidate);\n            }\n        }\n    }\n    let best = best.unwrap();\n    if neg { -best } else { best }\n}\n\n// Slow! Only run for rationals with small denominators\npub fn simplest_rational_in_closed_interval_naive(x: &Rational, y: &Rational) -> Rational {\n    assert!(x <= y);\n    if *x <= 0u32 && *y >= 0u32 {\n        return Rational::ZERO;\n    }\n    let neg_x;\n    let neg_y;\n    let (neg, x, y) = if *x < 0u32 {\n        neg_x = -x;\n        neg_y = -y;\n        (true, &neg_y, &neg_x)\n    } else {\n        (false, x, y)\n    };\n    for d in exhaustive_positive_naturals() {\n        let dr = Rational::from(d).reciprocal();\n        let q = x.round_to_multiple(&dr, Ceiling).0;\n        if q <= *y {\n            return if neg { -q } else { q };\n        }\n    }\n    unreachable!()\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::UnsignedAbs;\nuse malachite_nz::integer::Integer;\n\npub fn sub_naive(x: Rational, y: Rational) -> Rational {\n    let x_sign = x >= 0u32;\n    let y_sign = y >= 0u32;\n    let (xn, xd) = x.into_numerator_and_denominator();\n    let (yn, yd) = y.into_numerator_and_denominator();\n    let n =\n        Integer::from_sign_and_abs(x_sign, xn * &yd) - Integer::from_sign_and_abs(y_sign, yn * &xd);\n    Rational::from_sign_and_naturals(n >= 0u32, n.unsigned_abs(), xd * yd)\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/bench/bucketers.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::test_util::bench::bucketers::Bucketer;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse std::cmp::max;\n\npub fn rational_bit_bucketer(var_name: &str) -> Bucketer<'_, Rational> {\n    Bucketer {\n        bucketing_function: &|q| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_2_pair_1_rational_bit_bucketer<T, U>(\n    var_name: &str,\n) -> Bucketer<'_, (T, (Rational, U))> {\n    Bucketer {\n        bucketing_function: &|(_, (q, _))| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_pair_1_rational_bit_bucketer<T, U, V>(\n    var_name: &str,\n) -> Bucketer<'_, (T, U, (Rational, V))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (q, _))| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_1_rational_bit_bucketer<T>(var_name: &str) -> Bucketer<'_, (Rational, T)> {\n    Bucketer {\n        bucketing_function: &|(q, _)| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_2_rational_bit_bucketer<T>(var_name: &str) -> Bucketer<'_, (T, Rational)> {\n    Bucketer {\n        bucketing_function: &|(_, q)| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_1_rational_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (Rational, T, U)> {\n    Bucketer {\n        bucketing_function: &|(q, _, _)| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn triple_3_rational_bit_bucketer<T, U>(var_name: &str) -> Bucketer<'_, (T, U, Rational)> {\n    Bucketer {\n        bucketing_function: &|(_, _, q)| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn quadruple_1_rational_bit_bucketer<T, U, V>(\n    var_name: &str,\n) -> Bucketer<'_, (Rational, T, U, V)> {\n    Bucketer {\n        bucketing_function: &|(q, _, _, _)| usize::exact_from(q.significant_bits()),\n        bucketing_label: format!(\"{var_name}.significant_bits()\"),\n    }\n}\n\npub fn pair_rational_max_bit_bucketer<'a>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (Rational, Rational)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_pair_rational_max_bit_bucketer<'a, T>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, (Rational, Rational))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn triple_3_pair_rational_max_bit_bucketer<'a, T, U>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, U, (Rational, Rational))> {\n    Bucketer {\n        bucketing_function: &|(_, _, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_rational_integer_max_bit_bucketer<'a, T>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, (Rational, Integer))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn rational_natural_max_bit_bucketer<'a>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (Rational, Natural)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn rational_integer_max_bit_bucketer<'a>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (Rational, Integer)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn pair_2_rational_natural_max_bit_bucketer<'a, T>(\n    x_name: &str,\n    y_name: &str,\n) -> Bucketer<'a, (T, (Rational, Natural))> {\n    Bucketer {\n        bucketing_function: &|(_, (x, y))| {\n            usize::exact_from(max(x.significant_bits(), y.significant_bits()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.significant_bits())\"),\n    }\n}\n\npub fn rational_deserialize_bucketer<'a>() -> Bucketer<'a, (String, String, String)> {\n    Bucketer {\n        bucketing_function: &|(_, _, s)| {\n            let n: Rational = serde_json::from_str(s).unwrap();\n            usize::exact_from(n.significant_bits())\n        },\n        bucketing_label: \"n.significant_bits()\".to_string(),\n    }\n}\n\npub fn triple_3_pair_1_rational_bits_times_pair_2_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, (Rational, u64))> {\n    Bucketer {\n        bucketing_function: &|&(_, _, (ref x, y))| usize::exact_from(x.significant_bits() * y),\n        bucketing_label: format!(\"{x_name}.significant_bits() * {y_name}\"),\n    }\n}\n\npub fn triple_3_pair_1_rational_bits_times_abs_pair_2_bucketer<'a, T, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (T, U, (Rational, i64))> {\n    Bucketer {\n        bucketing_function: &|&(_, _, (ref x, y))| {\n            usize::exact_from(x.significant_bits() * y.unsigned_abs())\n        },\n        bucketing_label: format!(\"{x_name}.significant_bits() * {y_name}\"),\n    }\n}\n\npub fn triple_1_2_rational_bit_i64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Rational, i64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| {\n            usize::exact_from(max(x.significant_bits(), y.unsigned_abs()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn vec_rational_sum_bits_bucketer<'a>() -> Bucketer<'a, Vec<Rational>> {\n    Bucketer {\n        bucketing_function: &|xs| {\n            usize::exact_from(\n                xs.iter()\n                    .map(SignificantBits::significant_bits)\n                    .sum::<u64>(),\n            )\n        },\n        bucketing_label: \"xs.map(|x| x.significant_bits()).sum()\".to_string(),\n    }\n}\n\npub fn triple_3_vec_rational_sum_bits_bucketer<'a, T, U>() -> Bucketer<'a, (T, U, Vec<Rational>)> {\n    Bucketer {\n        bucketing_function: &|(_, _, xs)| {\n            usize::exact_from(\n                xs.iter()\n                    .map(SignificantBits::significant_bits)\n                    .sum::<u64>(),\n            )\n        },\n        bucketing_label: \"xs.map(|x| x.significant_bits()).sum()\".to_string(),\n    }\n}\n\npub fn pair_rational_bit_i64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Rational, i64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| {\n            usize::exact_from(max(x.significant_bits(), y.unsigned_abs()))\n        },\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.unsigned_abs())\"),\n    }\n}\n\npub fn pair_rational_bit_u64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Rational, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name}.unsigned_abs())\"),\n    }\n}\n\npub fn triple_1_2_rational_bit_u64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n) -> Bucketer<'a, (Rational, u64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, _)| usize::exact_from(max(x.significant_bits(), *y)),\n        bucketing_label: format!(\"max({x_name}.significant_bits(), {y_name})\"),\n    }\n}\n\npub fn triple_rational_bit_i64_u64_max_bucketer<'a>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Rational, i64, u64)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn quadruple_1_2_3_rational_bit_i64_u64_max_bucketer<'a, T>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Rational, i64, u64, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z, _)| {\n            usize::exact_from(max!(x.significant_bits(), y.unsigned_abs(), *z))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.unsigned_abs(), {z_name})\"\n        ),\n    }\n}\n\npub fn triple_rational_rational_primitive_int_max_bit_bucketer<'a, T: PrimitiveInt>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Rational, Rational, T)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits())\"\n        ),\n    }\n}\n\npub fn quadruple_1_2_3_rational_rational_primitive_int_max_bit_bucketer<'a, T: PrimitiveInt, U>(\n    x_name: &'a str,\n    y_name: &'a str,\n    z_name: &'a str,\n) -> Bucketer<'a, (Rational, Rational, T, U)> {\n    Bucketer {\n        bucketing_function: &|(x, y, z, _)| {\n            usize::exact_from(max!(\n                x.significant_bits(),\n                y.significant_bits(),\n                z.significant_bits()\n            ))\n        },\n        bucketing_label: format!(\n            \"max({x_name}.significant_bits(), {y_name}.significant_bits(), \\\n            {z_name}.significant_bits())\"\n        ),\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/bench/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod bucketers;\n"
  },
  {
    "path": "malachite-q/src/test_util/common/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_nz::integer::Integer;\nuse num::{BigInt, BigRational};\n\nimpl From<&BigRational> for Rational {\n    fn from(n: &BigRational) -> Self {\n        Self::from_integers(Integer::from(n.numer()), Integer::from(n.denom()))\n    }\n}\n\nimpl From<&Rational> for BigRational {\n    fn from(n: &Rational) -> Self {\n        let mut q = Self::new_raw(\n            BigInt::from(n.numerator_ref()),\n            BigInt::from(n.denominator_ref()),\n        );\n        if *n < 0 {\n            q = -q;\n        }\n        q\n    }\n}\n\nimpl From<&rug::Rational> for Rational {\n    fn from(n: &rug::Rational) -> Self {\n        Self::from_integers(Integer::from(n.numer()), Integer::from(n.denom()))\n    }\n}\n\nimpl From<&Rational> for rug::Rational {\n    fn from(n: &Rational) -> Self {\n        let mut q = Self::from((\n            rug::Integer::from(n.numerator_ref()),\n            rug::Integer::from(n.denominator_ref()),\n        ));\n        if *n < 0 {\n            q = -q;\n        }\n        q\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/conversion/continued_fraction/convergents.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::conversion::continued_fraction::to_continued_fraction::RationalContinuedFraction;\nuse crate::conversion::traits::ContinuedFraction;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\n#[derive(Clone, Debug)]\npub struct ConvergentsAlt {\n    first: bool,\n    floor: Integer,\n    xs: Vec<Natural>,\n    cf: RationalContinuedFraction,\n}\n\nimpl Iterator for ConvergentsAlt {\n    type Item = Rational;\n\n    fn next(&mut self) -> Option<Rational> {\n        if self.first {\n            self.first = false;\n            Some(Rational::from(&self.floor))\n        } else if let Some(n) = self.cf.next() {\n            self.xs.push(n);\n            Some(Rational::from_continued_fraction_ref(\n                &self.floor,\n                self.xs.iter(),\n            ))\n        } else {\n            self.xs.clear();\n            None\n        }\n    }\n}\n\npub fn convergents_alt(x: Rational) -> ConvergentsAlt {\n    let (floor, cf) = x.continued_fraction();\n    ConvergentsAlt {\n        first: true,\n        floor,\n        xs: Vec::new(),\n        cf,\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/conversion/continued_fraction/from_continued_fraction.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::num::arithmetic::traits::ReciprocalAssign;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\n\npub fn from_continued_fraction_alt(floor: Integer, xs: Vec<Natural>) -> Rational {\n    if xs.is_empty() {\n        Rational::from(floor)\n    } else {\n        let mut x = Rational::ZERO;\n        let mut first = true;\n        for n in xs.into_iter().rev() {\n            if first {\n                first = false;\n            } else {\n                x.reciprocal_assign();\n            }\n            x += Rational::from(n);\n        }\n        if !first {\n            x.reciprocal_assign();\n        }\n        x + Rational::from(floor)\n    }\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/conversion/continued_fraction/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod convergents;\npub mod from_continued_fraction;\n"
  },
  {
    "path": "malachite-q/src/test_util/conversion/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod continued_fraction;\n"
  },
  {
    "path": "malachite-q/src/test_util/extra_variadic/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::bit_distributor::{BitDistributor, BitDistributorOutputType};\nuse malachite_base::iterators::iterator_cache::IteratorCache;\nuse malachite_base::num::arithmetic::traits::CheckedPow;\nuse malachite_base::num::conversion::traits::{ExactFrom, WrappingFrom};\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_base::random::Seed;\nuse malachite_base::sets::random::{RandomBTreeSetsFixedLength, random_b_tree_sets_fixed_length};\nuse malachite_base::tuples::random::next_helper;\nuse malachite_base::vecs::exhaustive::next_bit_pattern;\nuse malachite_base::{\n    exhaustive_ordered_unique_tuples, exhaustive_tuples_1_input, random_custom_tuples,\n    random_tuples,\n};\nuse std::cmp::max;\nuse std::marker::PhantomData;\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {\n    (a.unwrap(), b.unwrap(), c.unwrap())\n}\n\n#[allow(clippy::missing_const_for_fn)]\nfn unwrap_quadruple<X, Y, Z, W>(\n    (a, b, c, d): (Option<X>, Option<Y>, Option<Z>, Option<W>),\n) -> (X, Y, Z, W) {\n    (a.unwrap(), b.unwrap(), c.unwrap(), d.unwrap())\n}\n\nexhaustive_tuples_1_input!(\n    (pub(crate)),\n    ExhaustiveTriples1Input,\n    exhaustive_triples_1_input,\n    exhaustive_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, output_type_x],\n    [1, output_type_y],\n    [2, output_type_z]\n);\n\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveTriplesXXY,\n    (X, X, Y),\n    (None, None, None),\n    unwrap_triple,\n    exhaustive_triples_xxy,\n    exhaustive_triples_xxy_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]]\n);\ncustom_tuples!(\n    (pub(crate)),\n    ExhaustiveQuadruplesXXYZ,\n    (X, X, Y, Z),\n    (None, None, None, None),\n    unwrap_quadruple,\n    exhaustive_quadruples_xxyz,\n    exhaustive_quadruples_xxyz_custom_output,\n    [X, I, xs, xs_done, [0, output_type_xs_0], [1, output_type_xs_1]],\n    [Y, J, ys, ys_done, [2, output_type_ys_2]],\n    [Z, K, zs, zs_done, [3, output_type_zs_3]]\n);\n\nexhaustive_ordered_unique_tuples!(\n    (pub(crate)),\n    ExhaustiveOrderedUniqueTriples,\n    3,\n    (I::Item, I::Item, I::Item),\n    exhaustive_ordered_unique_triples,\n    [0, 1, 2]\n);\n\nrandom_tuples!(\n    (pub(crate)),\n    RandomTriples,\n    RandomTriplesFromSingle,\n    random_triples,\n    random_triples_from_single,\n    (I::Item, I::Item, I::Item),\n    [0, X, I, xs, xs_gen],\n    [1, Y, J, ys, ys_gen],\n    [2, Z, K, zs, zs_gen]\n);\n\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXXY,\n    (X, X, Y),\n    random_triples_xxy,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n    [Y, J, ys, ys_gen, [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomTriplesXYY,\n    (X, Y, Y),\n    random_triples_xyy,\n    [X, I, xs, xs_gen, [x_0, x_0]],\n    [Y, J, ys, ys_gen, [y_1, y_1], [y_2, y_2]]\n);\nrandom_custom_tuples!(\n    (pub(crate)),\n    RandomQuadruplesXXYZ,\n    (X, X, Y, Z),\n    random_quadruples_xxyz,\n    [X, I, xs, xs_gen, [x_0, x_0], [x_1, x_1]],\n    [Y, J, ys, ys_gen, [y_2, y_2]],\n    [Z, K, zs, zs_gen, [z_3, z_3]]\n);\n\nrandom_ordered_unique_tuples!(\n    (pub(crate)),\n    RandomOrderedUniqueTriples,\n    3,\n    (I::Item, I::Item, I::Item),\n    random_ordered_unique_triples,\n    [0, 1, 2]\n);\n"
  },
  {
    "path": "malachite-q/src/test_util/generators/common.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse malachite_base::test_util::generators::common::It;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse num::BigRational;\n\npub fn rational_rm(xs: It<Rational>) -> It<(rug::Rational, Rational)> {\n    Box::new(xs.map(|x| (rug::Rational::from(&x), x)))\n}\n\npub fn rational_nrm(xs: It<Rational>) -> It<(BigRational, rug::Rational, Rational)> {\n    Box::new(xs.map(|x| (BigRational::from(&x), rug::Rational::from(&x), x)))\n}\n\npub fn rational_pair_rm(\n    ps: It<(Rational, Rational)>,\n) -> It<((rug::Rational, rug::Rational), (Rational, Rational))> {\n    Box::new(ps.map(|(x, y)| ((rug::Rational::from(&x), rug::Rational::from(&y)), (x, y))))\n}\n\npub fn rational_pair_nm(\n    ps: It<(Rational, Rational)>,\n) -> It<((BigRational, BigRational), (Rational, Rational))> {\n    Box::new(ps.map(|(x, y)| ((BigRational::from(&x), BigRational::from(&y)), (x, y))))\n}\n\n#[allow(clippy::type_complexity)]\npub fn rational_pair_nrm(\n    ps: It<(Rational, Rational)>,\n) -> It<(\n    (BigRational, BigRational),\n    (rug::Rational, rug::Rational),\n    (Rational, Rational),\n)> {\n    Box::new(ps.map(|(x, y)| {\n        (\n            (BigRational::from(&x), BigRational::from(&y)),\n            (rug::Rational::from(&x), rug::Rational::from(&y)),\n            (x, y),\n        )\n    }))\n}\n\npub fn rational_integer_pair_rm(\n    ps: It<(Rational, Integer)>,\n) -> It<((rug::Rational, rug::Integer), (Rational, Integer))> {\n    Box::new(ps.map(|(x, y)| ((rug::Rational::from(&x), rug::Integer::from(&y)), (x, y))))\n}\n\npub fn rational_natural_pair_rm(\n    ps: It<(Rational, Natural)>,\n) -> It<((rug::Rational, rug::Integer), (Rational, Natural))> {\n    Box::new(ps.map(|(x, y)| ((rug::Rational::from(&x), rug::Integer::from(&y)), (x, y))))\n}\n\npub fn rational_pair_1_rm<T: 'static + Clone>(\n    ps: It<(Rational, T)>,\n) -> It<((rug::Rational, T), (Rational, T))> {\n    Box::new(ps.map(|(x, y)| ((rug::Rational::from(&x), y.clone()), (x, y))))\n}\n\npub fn rational_pair_1_nrm<T: 'static + Clone>(\n    ps: It<(Rational, T)>,\n) -> It<((BigRational, T), (rug::Rational, T), (Rational, T))> {\n    Box::new(ps.map(|(x, y)| {\n        (\n            (BigRational::from(&x), y.clone()),\n            (rug::Rational::from(&x), y.clone()),\n            (x, y),\n        )\n    }))\n}\n\npub fn rational_vec_nrm(\n    xss: It<Vec<Rational>>,\n) -> It<(Vec<BigRational>, Vec<rug::Rational>, Vec<Rational>)> {\n    Box::new(xss.map(|xs| {\n        (\n            xs.iter().map(BigRational::from).collect(),\n            xs.iter().map(rug::Rational::from).collect(),\n            xs,\n        )\n    }))\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/generators/exhaustive.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::exhaustive::{\n    exhaustive_negative_rationals, exhaustive_non_negative_rationals, exhaustive_nonzero_rationals,\n    exhaustive_positive_rationals, exhaustive_rationals,\n};\nuse crate::test_util::extra_variadic::{\n    exhaustive_ordered_unique_triples, exhaustive_quadruples_xxyz, exhaustive_triples_from_single,\n    exhaustive_triples_xxy, exhaustive_triples_xxy_custom_output,\n};\nuse itertools::Itertools;\nuse malachite_base::iterators::bit_distributor::BitDistributorOutputType;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::string::options::exhaustive::exhaustive_to_sci_options;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, IsInteger, ToSci};\nuse malachite_base::num::exhaustive::{\n    exhaustive_finite_primitive_floats, exhaustive_nonzero_finite_primitive_floats,\n    exhaustive_nonzero_signeds, exhaustive_positive_primitive_ints, exhaustive_primitive_floats,\n    exhaustive_signeds, exhaustive_unsigneds, primitive_int_increasing_inclusive_range,\n};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::exhaustive::exhaustive_rounding_modes;\nuse malachite_base::test_util::generators::common::{It, reshape_2_1_to_3};\nuse malachite_base::test_util::generators::{\n    exhaustive_pairs_big_small, exhaustive_pairs_big_tiny,\n};\nuse malachite_base::tuples::exhaustive::{\n    exhaustive_ordered_unique_pairs, exhaustive_pairs, exhaustive_pairs_from_single,\n    exhaustive_triples_custom_output, exhaustive_triples_xyy, exhaustive_triples_xyy_custom_output,\n    lex_pairs,\n};\nuse malachite_base::vecs::exhaustive::exhaustive_vecs;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::exhaustive::exhaustive_integers;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::{\n    exhaustive_natural_range_to_infinity, exhaustive_naturals, exhaustive_positive_naturals,\n};\nuse num::BigRational;\nuse std::ops::Shr;\n\n// -- Rational --\n\npub fn exhaustive_rational_gen() -> It<Rational> {\n    Box::new(exhaustive_rationals())\n}\n\npub fn exhaustive_rational_gen_var_1() -> It<Rational> {\n    Box::new(exhaustive_nonzero_rationals())\n}\n\npub fn exhaustive_rational_gen_var_2() -> It<Rational> {\n    Box::new(exhaustive_positive_rationals())\n}\n\npub fn exhaustive_rational_gen_var_3() -> It<Rational> {\n    Box::new(exhaustive_non_negative_rationals())\n}\n\npub fn exhaustive_rational_gen_var_4<T: PrimitiveFloat>() -> It<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Box::new(\n        exhaustive_finite_primitive_floats()\n            .skip(1)\n            .map(Rational::exact_from),\n    )\n}\n\npub fn exhaustive_rational_gen_var_5<T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat>()\n-> It<Rational> {\n    Box::new(exhaustive_rationals().filter(|q| !T::convertible_from(q)))\n}\n\npub fn exhaustive_rational_gen_var_6<T: PrimitiveFloat>() -> It<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Box::new(exhaustive_nonzero_finite_primitive_floats().map(|f| {\n        let x = Rational::exact_from(f);\n        let y = Rational::exact_from(if f > T::ZERO {\n            f.next_lower()\n        } else {\n            f.next_higher()\n        });\n        (x + y) >> 1\n    }))\n}\n\npub fn exhaustive_rational_gen_var_7() -> It<Rational> {\n    Box::new(exhaustive_positive_rationals().filter(|q| *q != 1u32))\n}\n\n// -- (Rational, Integer) --\n\npub fn exhaustive_rational_integer_pair_gen() -> It<(Rational, Integer)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Rational, Integer, Integer) --\n\npub fn exhaustive_rational_integer_integer_triple_gen() -> It<(Rational, Integer, Integer)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_rationals(),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Rational, Natural) --\n\npub fn exhaustive_rational_natural_pair_gen() -> It<(Rational, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_naturals(),\n    ))\n}\n\npub fn exhaustive_rational_natural_pair_gen_var_1() -> It<(Rational, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_natural_range_to_infinity(Natural::TWO),\n    ))\n}\n\npub fn exhaustive_rational_natural_pair_gen_var_2() -> It<(Rational, Natural)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_positive_naturals(),\n    ))\n}\n\npub fn exhaustive_rational_natural_pair_gen_var_3() -> It<(Rational, Natural)> {\n    Box::new(exhaustive_pairs_big_small(\n        exhaustive_rationals(),\n        exhaustive_positive_naturals(),\n    ))\n}\n\n// -- (Rational, Natural, Natural) --\n\npub fn exhaustive_rational_natural_natural_triple_gen() -> It<(Rational, Natural, Natural)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_rationals(),\n        exhaustive_naturals(),\n    ))\n}\n\npub fn exhaustive_rational_natural_natural_triple_gen_var_1() -> It<(Rational, Natural, Natural)> {\n    Box::new(\n        exhaustive_triples_xyy(exhaustive_rationals(), exhaustive_positive_naturals())\n            .filter(|(_, x, y)| x < y),\n    )\n}\n\n// -- (Rational, PrimitiveFloat) --\n\npub fn exhaustive_rational_primitive_float_pair_gen<T: PrimitiveFloat>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Rational, PrimitiveFloat, PrimitiveFloat) --\n\npub fn exhaustive_rational_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Rational, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_rationals(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Rational, PrimitiveSigned) --\n\npub fn exhaustive_rational_signed_pair_gen<T: PrimitiveSigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_rational_signed_pair_gen_var_1<T: PrimitiveSigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_rationals(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_rational_signed_pair_gen_var_2<T: PrimitiveSigned>() -> It<(Rational, T)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_rationals(), exhaustive_signeds())\n            .filter(|(x, exp)| *exp >= T::ZERO || *x != 0u32),\n    )\n}\n\npub fn exhaustive_rational_signed_pair_gen_var_3<T: PrimitiveSigned>() -> It<(Rational, T)>\nwhere\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    Box::new(\n        exhaustive_pairs_big_tiny(exhaustive_rationals(), exhaustive_signeds::<T>())\n            .filter(|(x, pow)| !x.denominator_ref().is_power_of_2() || !(x >> *pow).is_integer()),\n    )\n}\n\npub fn exhaustive_rational_signed_pair_gen_var_4<T: PrimitiveSigned>() -> It<(Rational, T)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_non_negative_rationals(),\n            exhaustive_nonzero_signeds(),\n        )\n        .filter(|(q, i)| *i > T::ZERO || *q != 0u32)\n        .interleave(exhaustive_pairs_big_tiny(\n            exhaustive_negative_rationals(),\n            exhaustive_signeds::<T>()\n                .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE)),\n        )),\n    )\n}\n\npub fn exhaustive_rational_signed_pair_gen_var_5<T: PrimitiveSigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_positive_rationals(),\n        exhaustive_nonzero_signeds(),\n    ))\n}\n\n// -- (Rational, PrimitiveSigned, PrimitiveSigned) --\n\npub fn exhaustive_rational_signed_signed_triple_gen<T: PrimitiveSigned>() -> It<(Rational, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_rationals(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_rational_signed_signed_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Rational, T, T)> {\n    Box::new(\n        exhaustive_triples_xyy_custom_output(\n            exhaustive_rationals(),\n            exhaustive_signeds::<T>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter(|(x, e, f)| *e >= T::ZERO && *f >= T::ZERO || *x != 0),\n    )\n}\n\n// -- (Rational, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn exhaustive_rational_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>() -> It<(Rational, T, U)> {\n    Box::new(exhaustive_triples_custom_output(\n        exhaustive_rationals(),\n        exhaustive_signeds::<T>(),\n        exhaustive_positive_primitive_ints::<U>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Rational, PrimitiveSigned, RoundingMode) --\n\npub fn exhaustive_rational_signed_rounding_mode_triple_gen_var_1()\n-> It<(Rational, i64, RoundingMode)> {\n    Box::new(\n        exhaustive_triples_custom_output(\n            exhaustive_rationals(),\n            exhaustive_signeds::<i64>(),\n            exhaustive_rounding_modes(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter(|(x, i, rm)| {\n            *rm != Exact || x.denominator_ref().is_power_of_2() && (x >> *i).is_integer()\n        }),\n    )\n}\n\n// var 2 is in malachite-float.\n\n// -- (Rational, PrimitiveUnsigned) --\n\npub fn exhaustive_rational_unsigned_pair_gen<T: PrimitiveUnsigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_rational_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_rationals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_rational_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_rationals(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_rational_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> It<(Rational, T)> {\n    Box::new(\n        exhaustive_pairs_big_tiny(\n            exhaustive_non_negative_rationals(),\n            exhaustive_positive_primitive_ints(),\n        )\n        .interleave(exhaustive_pairs_big_tiny(\n            exhaustive_negative_rationals(),\n            exhaustive_unsigneds::<T>()\n                .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE)),\n        )),\n    )\n}\n\npub fn exhaustive_rational_unsigned_pair_gen_var_4() -> It<(Rational, u8)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_rationals(),\n        primitive_int_increasing_inclusive_range(2, 36),\n    ))\n}\n\npub fn exhaustive_rational_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_nonzero_rationals(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\npub fn exhaustive_rational_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>() -> It<(Rational, T)> {\n    Box::new(exhaustive_pairs_big_tiny(\n        exhaustive_non_negative_rationals(),\n        exhaustive_positive_primitive_ints(),\n    ))\n}\n\n// -- (Rational, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn exhaustive_rational_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> It<(Rational, T, T)> {\n    Box::new(exhaustive_triples_xyy(\n        exhaustive_rationals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_rational_unsigned_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Rational, T, T)> {\n    Box::new(exhaustive_triples_xyy_custom_output(\n        exhaustive_rationals(),\n        exhaustive_unsigneds::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Rational, Rational) --\n\npub fn exhaustive_rational_pair_gen() -> It<(Rational, Rational)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_rationals()))\n}\n\npub fn exhaustive_rational_pair_gen_var_1() -> It<(Rational, Rational)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_nonzero_rationals(),\n    ))\n}\n\npub fn exhaustive_rational_pair_gen_var_2() -> It<(Rational, Rational)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_rationals(), exhaustive_nonzero_rationals())\n            .filter(|(x, y)| !(x / y).is_integer()),\n    )\n}\n\npub fn exhaustive_rational_pair_gen_var_3() -> It<(Rational, Rational)> {\n    Box::new(\n        exhaustive_ordered_unique_pairs(exhaustive_rationals())\n            .map(|(x, y)| if x < y { (x, y) } else { (y, x) }),\n    )\n}\n\npub fn exhaustive_rational_pair_gen_var_4() -> It<(Rational, Rational)> {\n    // TODO\n    Box::new(exhaustive_pairs_from_single(exhaustive_rationals()).filter(|(x, y)| x <= y))\n}\n\npub fn exhaustive_rational_pair_gen_var_5() -> It<(Rational, Rational)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_positive_rationals(),\n        exhaustive_positive_rationals()\n            .filter(|q| (q - Rational::ONE).gt_abs(&Rational::from_signeds(1, 1000))),\n    ))\n}\n\npub fn exhaustive_rational_pair_gen_var_6() -> It<(Rational, Rational)> {\n    Box::new(exhaustive_pairs_from_single(exhaustive_nonzero_rationals()))\n}\n\n// -- (Rational, Rational, Integer) --\n\npub fn exhaustive_rational_rational_integer_triple_gen() -> It<(Rational, Rational, Integer)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_rationals(),\n        exhaustive_integers(),\n    ))\n}\n\n// -- (Rational, Rational, Natural) --\n\npub fn exhaustive_rational_rational_natural_triple_gen() -> It<(Rational, Rational, Natural)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_rationals(),\n        exhaustive_naturals(),\n    ))\n}\n\npub fn exhaustive_rational_rational_natural_triple_gen_var_1() -> It<(Rational, Rational, Natural)>\n{\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_rationals(),\n        exhaustive_positive_naturals(),\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveFloat) --\n\npub fn exhaustive_rational_rational_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> It<(Rational, Rational, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_rationals(),\n        exhaustive_primitive_floats(),\n    ))\n}\n\n// -- (Rational, Rational, RoundingMode) --\n\npub(crate) fn round_to_multiple_rational_filter(t: &(Rational, Rational, RoundingMode)) -> bool {\n    let &(ref x, ref y, rm) = t;\n    if x == y {\n        true\n    } else if *y == 0u32 {\n        rm == Down || rm == (if *x >= 0 { Floor } else { Ceiling }) || rm == Nearest\n    } else {\n        rm != Exact || (x / y).is_integer()\n    }\n}\n\npub fn exhaustive_rational_rational_rounding_mode_triple_gen_var_1()\n-> It<(Rational, Rational, RoundingMode)> {\n    Box::new(\n        reshape_2_1_to_3(Box::new(lex_pairs(\n            exhaustive_pairs_from_single(exhaustive_rationals()),\n            exhaustive_rounding_modes(),\n        )))\n        .filter(round_to_multiple_rational_filter),\n    )\n}\n\n// -- (Rational, Rational, Natural, Natural) --\n\npub fn exhaustive_rational_rational_natural_natural_quadruple_gen_var_1()\n-> It<(Rational, Rational, Natural, Natural)> {\n    Box::new(exhaustive_quadruples_xxyz(\n        exhaustive_rationals(),\n        exhaustive_naturals(),\n        exhaustive_positive_naturals(),\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveInt) --\n\npub fn exhaustive_rational_rational_primitive_int_triple_gen_var_1<T: PrimitiveInt>()\n-> It<(Rational, Rational, T)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_rationals(),\n        exhaustive_positive_primitive_ints::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveSigned) --\n\npub fn exhaustive_rational_rational_signed_triple_gen<T: PrimitiveSigned>()\n-> It<(Rational, Rational, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_rationals(),\n        exhaustive_signeds(),\n    ))\n}\n\npub fn exhaustive_rational_rational_signed_triple_gen_var_1<T: PrimitiveSigned>()\n-> It<(Rational, Rational, T)> {\n    Box::new(\n        exhaustive_triples_xxy_custom_output(\n            exhaustive_rationals(),\n            exhaustive_signeds::<T>(),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::normal(1),\n            BitDistributorOutputType::tiny(),\n        )\n        .filter(|(x, y, exp)| *exp >= T::ZERO || *x != 0 && *y != 0),\n    )\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned) --\n\npub fn exhaustive_rational_rational_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> It<(Rational, Rational, T)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_rationals(),\n        exhaustive_unsigneds(),\n    ))\n}\n\npub fn exhaustive_rational_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> It<(Rational, Rational, T)> {\n    Box::new(exhaustive_triples_xxy_custom_output(\n        exhaustive_rationals(),\n        exhaustive_unsigneds::<T>(),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::normal(1),\n        BitDistributorOutputType::tiny(),\n    ))\n}\n\n// -- (Rational, Rational, Rational) --\n\npub fn exhaustive_rational_triple_gen() -> It<(Rational, Rational, Rational)> {\n    Box::new(exhaustive_triples_from_single(exhaustive_rationals()))\n}\n\npub fn exhaustive_rational_triple_gen_var_1() -> It<(Rational, Rational, Rational)> {\n    Box::new(exhaustive_triples_xxy(\n        exhaustive_rationals(),\n        exhaustive_nonzero_rationals(),\n    ))\n}\n\npub fn exhaustive_rational_triple_gen_var_2() -> It<(Rational, Rational, Rational)> {\n    Box::new(\n        exhaustive_ordered_unique_triples(exhaustive_rationals()).map(|(x, y, z)| {\n            let mut xs = vec![x, y, z];\n            xs.sort_unstable();\n            let mut xs = xs.into_iter();\n            (xs.next().unwrap(), xs.next().unwrap(), xs.next().unwrap())\n        }),\n    )\n}\n\npub fn exhaustive_rational_triple_gen_var_3() -> It<(Rational, Rational, Rational)> {\n    // TODO\n    Box::new(\n        exhaustive_triples_from_single(exhaustive_rationals()).filter(|(x, y, z)| x <= y && y <= z),\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\npub fn exhaustive_rational_rounding_mode_pair_gen() -> It<(Rational, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_rationals(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_rational_rounding_mode_pair_gen_var_1() -> It<(Rational, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_rationals(), exhaustive_rounding_modes()).filter(|(x, rm)| match rm {\n            Floor | Up => *x >= 0u32,\n            Exact => Natural::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\npub fn exhaustive_rational_rounding_mode_pair_gen_var_2() -> It<(Rational, RoundingMode)> {\n    Box::new(\n        lex_pairs(exhaustive_rationals(), exhaustive_rounding_modes())\n            .filter(|(x, rm)| *rm != Exact || x.is_integer()),\n    )\n}\n\npub fn exhaustive_rational_rounding_mode_pair_gen_var_3<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>() -> It<(Rational, RoundingMode)>\nwhere\n    Rational: PartialOrd<T>,\n{\n    Box::new(\n        lex_pairs(exhaustive_rationals(), exhaustive_rounding_modes()).filter(|(x, rm)| match rm {\n            Floor => *x >= T::MIN,\n            Ceiling => *x <= T::MAX,\n            Up => *x >= T::MIN && *x <= T::MAX,\n            Exact => T::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\npub fn exhaustive_rational_rounding_mode_pair_gen_var_4() -> It<(Rational, RoundingMode)> {\n    Box::new(lex_pairs(\n        exhaustive_nonzero_rationals(),\n        exhaustive_rounding_modes(),\n    ))\n}\n\npub fn exhaustive_rational_rounding_mode_pair_gen_var_5<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat,\n>() -> It<(Rational, RoundingMode)>\nwhere\n    Rational: TryFrom<T>,\n{\n    let max = Rational::exact_from(T::MAX_FINITE);\n    let min = -&max;\n    Box::new(\n        lex_pairs(exhaustive_rationals(), exhaustive_rounding_modes()).filter(move |(x, rm)| {\n            match rm {\n                Floor => *x >= min,\n                Ceiling => *x <= max,\n                Up => *x >= min && *x <= max,\n                Exact => T::convertible_from(x),\n                _ => true,\n            }\n        }),\n    )\n}\n\n// -- (Rational, ToSciOptions) --\n\npub fn exhaustive_rational_to_sci_options_pair_gen() -> It<(Rational, ToSciOptions)> {\n    Box::new(exhaustive_pairs(\n        exhaustive_rationals(),\n        exhaustive_to_sci_options(),\n    ))\n}\n\npub fn exhaustive_rational_to_sci_options_pair_gen_var_1() -> It<(Rational, ToSciOptions)> {\n    Box::new(\n        exhaustive_pairs(exhaustive_rationals(), exhaustive_to_sci_options())\n            .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- String --\n\n// vars 1 through 10 are in malachite-base.\n\npub fn exhaustive_string_gen_var_11() -> It<String> {\n    Box::new(exhaustive_rationals().map(|r| serde_json::to_string(&r).unwrap()))\n}\n\npub fn exhaustive_string_gen_var_12() -> It<String> {\n    Box::new(exhaustive_rationals().map(|x| x.to_string()))\n}\n\n// -- (String, String, String) --\n\n// vars 1 through 2 are in malachite-nz.\n\npub fn exhaustive_string_triple_gen_var_3() -> It<(String, String, String)> {\n    Box::new(exhaustive_rationals().map(|x| {\n        (\n            serde_json::to_string(&BigRational::from(&x)).unwrap(),\n            serde_json::to_string(&rug::Rational::from(&x)).unwrap(),\n            serde_json::to_string(&x).unwrap(),\n        )\n    }))\n}\n\n// -- Vec<Rational> --\n\npub fn exhaustive_rational_vec_gen() -> It<Vec<Rational>> {\n    Box::new(exhaustive_vecs(exhaustive_rationals()))\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/generators/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::test_util::generators::common::{\n    rational_integer_pair_rm, rational_natural_pair_rm, rational_nrm, rational_pair_1_nrm,\n    rational_pair_1_rm, rational_pair_nm, rational_pair_nrm, rational_pair_rm, rational_rm,\n    rational_vec_nrm,\n};\nuse crate::test_util::generators::exhaustive::*;\nuse crate::test_util::generators::random::*;\nuse crate::test_util::generators::special_random::*;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::traits::ConvertibleFrom;\nuse malachite_base::rounding_modes::RoundingMode;\nuse malachite_base::test_util::generators::common::Generator;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse num::BigRational;\nuse std::ops::Shr;\n\n// -- Rational --\n\npub fn rational_gen() -> Generator<Rational> {\n    Generator::new(\n        &exhaustive_rational_gen,\n        &random_rational_gen,\n        &special_random_rational_gen,\n    )\n}\n\npub fn rational_gen_rm() -> Generator<(rug::Rational, Rational)> {\n    Generator::new(\n        &|| rational_rm(exhaustive_rational_gen()),\n        &|config| rational_rm(random_rational_gen(config)),\n        &|config| rational_rm(special_random_rational_gen(config)),\n    )\n}\n\npub fn rational_gen_nrm() -> Generator<(BigRational, rug::Rational, Rational)> {\n    Generator::new(\n        &|| rational_nrm(exhaustive_rational_gen()),\n        &|config| rational_nrm(random_rational_gen(config)),\n        &|config| rational_nrm(special_random_rational_gen(config)),\n    )\n}\n\n// All nonzero `Rational`s.\npub fn rational_gen_var_1() -> Generator<Rational> {\n    Generator::new(\n        &exhaustive_rational_gen_var_1,\n        &random_rational_gen_var_1,\n        &special_random_rational_gen_var_1,\n    )\n}\n\npub fn rational_gen_var_1_nrm() -> Generator<(BigRational, rug::Rational, Rational)> {\n    Generator::new(\n        &|| rational_nrm(exhaustive_rational_gen_var_1()),\n        &|config| rational_nrm(random_rational_gen_var_1(config)),\n        &|config| rational_nrm(special_random_rational_gen_var_1(config)),\n    )\n}\n\n// All positive `Rational`s.\npub fn rational_gen_var_2() -> Generator<Rational> {\n    Generator::new(\n        &exhaustive_rational_gen_var_2,\n        &random_rational_gen_var_2,\n        &special_random_rational_gen_var_2,\n    )\n}\n\n// All non-negative `Rational`s.\npub fn rational_gen_var_3() -> Generator<Rational> {\n    Generator::new(\n        &exhaustive_rational_gen_var_3,\n        &random_rational_gen_var_3,\n        &special_random_rational_gen_var_3,\n    )\n}\n\n// All `Rational`s that are equal to a primitive float of type `T`.\npub fn rational_gen_var_4<T: PrimitiveFloat>() -> Generator<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Generator::new(\n        &exhaustive_rational_gen_var_4::<T>,\n        &random_rational_gen_var_4::<T>,\n        &special_random_rational_gen_var_4::<T>,\n    )\n}\n\n// All `Rational`s that are not equal to any primitive float of type `T`.\npub fn rational_gen_var_5<T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat>()\n-> Generator<Rational> {\n    Generator::new(\n        &exhaustive_rational_gen_var_5::<T>,\n        &random_rational_gen_var_5::<T>,\n        &special_random_rational_gen_var_5::<T>,\n    )\n}\n\n// All `Rational`s that are halfway between two adjacent floats of type `T`.\npub fn rational_gen_var_6<T: PrimitiveFloat>() -> Generator<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Generator::new(\n        &exhaustive_rational_gen_var_6::<T>,\n        &random_rational_gen_var_6::<T>,\n        &special_random_rational_gen_var_6::<T>,\n    )\n}\n\n// All `Rational`s with small numerator and denominator.\npub fn rational_gen_var_7() -> Generator<Rational> {\n    Generator::new_no_special(&exhaustive_rational_gen, &random_rational_gen_var_7)\n}\n\n// All positive `Rational`s that are not equal to 1.\npub fn rational_gen_var_8() -> Generator<Rational> {\n    Generator::new(\n        &exhaustive_rational_gen_var_7,\n        &random_rational_gen_var_8,\n        &special_random_rational_gen_var_7,\n    )\n}\n\n// -- (Rational, Integer) --\n\npub fn rational_integer_pair_gen() -> Generator<(Rational, Integer)> {\n    Generator::new(\n        &exhaustive_rational_integer_pair_gen,\n        &random_rational_integer_pair_gen,\n        &special_random_rational_integer_pair_gen,\n    )\n}\n\npub fn rational_integer_pair_gen_rm()\n-> Generator<((rug::Rational, rug::Integer), (Rational, Integer))> {\n    Generator::new(\n        &|| rational_integer_pair_rm(exhaustive_rational_integer_pair_gen()),\n        &|config| rational_integer_pair_rm(random_rational_integer_pair_gen(config)),\n        &|config| rational_integer_pair_rm(random_rational_integer_pair_gen(config)),\n    )\n}\n\n// -- (Rational, Integer, Integer) --\n\npub fn rational_integer_integer_triple_gen() -> Generator<(Rational, Integer, Integer)> {\n    Generator::new(\n        &exhaustive_rational_integer_integer_triple_gen,\n        &random_rational_integer_integer_triple_gen,\n        &special_random_rational_integer_integer_triple_gen,\n    )\n}\n\n// -- (Rational, Natural) --\n\npub fn rational_natural_pair_gen() -> Generator<(Rational, Natural)> {\n    Generator::new(\n        &exhaustive_rational_natural_pair_gen,\n        &random_rational_natural_pair_gen,\n        &special_random_rational_natural_pair_gen,\n    )\n}\n\npub fn rational_natural_pair_gen_rm()\n-> Generator<((rug::Rational, rug::Integer), (Rational, Natural))> {\n    Generator::new(\n        &|| rational_natural_pair_rm(exhaustive_rational_natural_pair_gen()),\n        &|config| rational_natural_pair_rm(random_rational_natural_pair_gen(config)),\n        &|config| rational_natural_pair_rm(random_rational_natural_pair_gen(config)),\n    )\n}\n\n// All `(Rational, Natural)` where the `Natural` is greater than 1.\npub fn rational_natural_pair_gen_var_1() -> Generator<(Rational, Natural)> {\n    Generator::new(\n        &exhaustive_rational_natural_pair_gen_var_1,\n        &random_rational_natural_pair_gen_var_1,\n        &special_random_rational_natural_pair_gen_var_1,\n    )\n}\n\n// All `(Rational, Natural)` where the `Rational` has a small numerator and denominator, and the\n// `Natural` is greater than 1.\npub fn rational_natural_pair_gen_var_2() -> Generator<(Rational, Natural)> {\n    Generator::new(\n        &exhaustive_rational_natural_pair_gen_var_1,\n        &random_rational_natural_pair_gen_var_2,\n        &special_random_rational_natural_pair_gen_var_2,\n    )\n}\n\n// All `(Rational, Natural)` where the `Natural` is positive.\npub fn rational_natural_pair_gen_var_3() -> Generator<(Rational, Natural)> {\n    Generator::new(\n        &exhaustive_rational_natural_pair_gen_var_2,\n        &random_rational_natural_pair_gen_var_3,\n        &special_random_rational_natural_pair_gen_var_3,\n    )\n}\n\n// All `(Rational, Natural)` where the `Natural` is small and positive.\npub fn rational_natural_pair_gen_var_4() -> Generator<(Rational, Natural)> {\n    Generator::new(\n        &exhaustive_rational_natural_pair_gen_var_3,\n        &random_rational_natural_pair_gen_var_4,\n        &special_random_rational_natural_pair_gen_var_4,\n    )\n}\n\n// -- (Rational, Natural, Natural) --\n\npub fn rational_natural_natural_triple_gen() -> Generator<(Rational, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_rational_natural_natural_triple_gen,\n        &random_rational_natural_natural_triple_gen,\n        &special_random_rational_natural_natural_triple_gen,\n    )\n}\n\n// All `(Rational, Natural, Natural)` where the both `Natural`s are positive and the first `Natural`\n// is smaller than the second.\npub fn rational_natural_natural_triple_gen_var_1() -> Generator<(Rational, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_rational_natural_natural_triple_gen_var_1,\n        &random_rational_natural_natural_triple_gen_var_1,\n        &special_random_rational_natural_natural_triple_gen_var_1,\n    )\n}\n\n// -- (Rational, PrimitiveFloat) --\n\npub fn rational_primitive_float_pair_gen<T: PrimitiveFloat>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_primitive_float_pair_gen,\n        &random_rational_primitive_float_pair_gen,\n        &special_random_rational_primitive_float_pair_gen,\n    )\n}\n\npub fn rational_primitive_float_pair_gen_rm<T: PrimitiveFloat>()\n-> Generator<((rug::Rational, T), (Rational, T))> {\n    Generator::new(\n        &|| rational_pair_1_rm(exhaustive_rational_primitive_float_pair_gen()),\n        &|config| rational_pair_1_rm(random_rational_primitive_float_pair_gen(config)),\n        &|config| rational_pair_1_rm(special_random_rational_primitive_float_pair_gen(config)),\n    )\n}\n\n// -- (Rational, PrimitiveFloat, PrimitiveFloat) --\n\npub fn rational_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> Generator<(Rational, T, T)> {\n    Generator::new(\n        &exhaustive_rational_primitive_float_primitive_float_triple_gen,\n        &random_rational_primitive_float_primitive_float_triple_gen,\n        &special_random_rational_primitive_float_primitive_float_triple_gen,\n    )\n}\n\n// -- (Rational, PrimitiveSigned) --\n\npub fn rational_signed_pair_gen<T: PrimitiveSigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_signed_pair_gen,\n        &random_rational_primitive_int_pair_gen,\n        &special_random_rational_signed_pair_gen,\n    )\n}\n\npub fn rational_signed_pair_gen_rm<T: PrimitiveSigned>()\n-> Generator<((rug::Rational, T), (Rational, T))> {\n    Generator::new(\n        &|| rational_pair_1_rm(exhaustive_rational_signed_pair_gen()),\n        &|config| rational_pair_1_rm(random_rational_primitive_int_pair_gen(config)),\n        &|config| rational_pair_1_rm(special_random_rational_signed_pair_gen(config)),\n    )\n}\n\n// All `(Rational, T)` where `T` is small and signed.\npub fn rational_signed_pair_gen_var_1<T: PrimitiveSigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_signed_pair_gen_var_1,\n        &random_rational_signed_pair_gen_var_1,\n        &special_random_rational_signed_pair_gen_var_1,\n    )\n}\n\npub fn rational_signed_pair_gen_var_1_rm<T: PrimitiveSigned>()\n-> Generator<((rug::Rational, T), (Rational, T))> {\n    Generator::new(\n        &|| rational_pair_1_rm(exhaustive_rational_signed_pair_gen_var_1()),\n        &|config| rational_pair_1_rm(random_rational_signed_pair_gen_var_1(config)),\n        &|config| rational_pair_1_rm(special_random_rational_signed_pair_gen_var_1(config)),\n    )\n}\n\n// All `(Rational, T)` where `T` is small and signed, and if the `Rational` is zero then the `T` is\n// non-negative.\npub fn rational_signed_pair_gen_var_2<T: PrimitiveSigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_signed_pair_gen_var_2,\n        &random_rational_signed_pair_gen_var_2,\n        &special_random_rational_signed_pair_gen_var_2,\n    )\n}\n\npub fn rational_signed_pair_gen_var_2_nrm<T: PrimitiveSigned>()\n-> Generator<((BigRational, T), (rug::Rational, T), (Rational, T))> {\n    Generator::new(\n        &|| rational_pair_1_nrm(exhaustive_rational_signed_pair_gen_var_2()),\n        &|config| rational_pair_1_nrm(random_rational_signed_pair_gen_var_2(config)),\n        &|config| rational_pair_1_nrm(special_random_rational_signed_pair_gen_var_2(config)),\n    )\n}\n\n// All `(Rational, T)` where `T` is small and signed, and the `Rational` divided by 2 to the power\n// of the `T` is not an integer.\npub fn rational_signed_pair_gen_var_3<T: PrimitiveSigned>() -> Generator<(Rational, T)>\nwhere\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    Generator::new(\n        &exhaustive_rational_signed_pair_gen_var_3,\n        &random_rational_signed_pair_gen_var_3,\n        &special_random_rational_signed_pair_gen_var_3,\n    )\n}\n\n// All `(Rational, T)` where `T` is signed, small, and nonzero, and either the `Rational` is\n// non-negative or the `T` is odd, and either the `Rational` is nonzero or the `T` is positive.\npub fn rational_signed_pair_gen_var_4<T: PrimitiveSigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_signed_pair_gen_var_4,\n        &random_rational_signed_pair_gen_var_4,\n        &special_random_rational_signed_pair_gen_var_4,\n    )\n}\n\n// All `(Rational, T)` where the `Rational` is positive and the `T` is small, signed, and nonzero.\npub fn rational_signed_pair_gen_var_5<T: PrimitiveSigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_signed_pair_gen_var_5,\n        &random_rational_signed_pair_gen_var_5,\n        &special_random_rational_signed_pair_gen_var_5,\n    )\n}\n\n// -- (Rational, PrimitiveSigned, RoundingMode) --\n\n// All `(Rational, i64, RoundingMode)` where the triple is a valid input to\n// `Rational::round_to_multiple_of_power_of_2`.\npub fn rational_signed_rounding_mode_triple_gen_var_1() -> Generator<(Rational, i64, RoundingMode)>\n{\n    Generator::new(\n        &exhaustive_rational_signed_rounding_mode_triple_gen_var_1,\n        &random_rational_signed_rounding_mode_triple_gen_var_1,\n        &special_random_rational_signed_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// var 2 is in malachite-float.\n\n// -- (Rational, PrimitiveSigned, PrimitiveSigned) --\n\npub fn rational_signed_signed_triple_gen<T: PrimitiveSigned>() -> Generator<(Rational, T, T)> {\n    Generator::new(\n        &exhaustive_rational_signed_signed_triple_gen,\n        &random_rational_primitive_int_primitive_int_triple_gen,\n        &special_random_rational_signed_signed_triple_gen,\n    )\n}\n\n// All `(Rational, T, T)` where `T` is signed, both `T`s are small, and if either `T` is negative,\n// the `Rational` is nonzero.\npub fn rational_signed_signed_triple_gen_var_1<T: PrimitiveSigned>() -> Generator<(Rational, T, T)>\n{\n    Generator::new(\n        &exhaustive_rational_signed_signed_triple_gen_var_1,\n        &random_rational_signed_signed_triple_gen_var_1,\n        &special_random_rational_signed_signed_triple_gen_var_1,\n    )\n}\n\n// -- (Rational, PrimitiveSigned, PrimitiveUnsigned) --\n\n// All `(Rational, T, U)` where `T` is small and signed, and positive and `U` is small, unsigned,\n// and positive.\npub fn rational_signed_unsigned_triple_gen_var_1<T: PrimitiveSigned, U: PrimitiveUnsigned>()\n-> Generator<(Rational, T, U)> {\n    Generator::new(\n        &exhaustive_rational_signed_unsigned_triple_gen_var_1,\n        &random_rational_signed_unsigned_triple_gen_var_1,\n        &special_random_rational_signed_unsigned_triple_gen_var_1,\n    )\n}\n\n// -- (Rational, PrimitiveUnsigned) --\n\npub fn rational_unsigned_pair_gen<T: PrimitiveUnsigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_pair_gen,\n        &random_rational_primitive_int_pair_gen,\n        &special_random_rational_unsigned_pair_gen,\n    )\n}\n\npub fn rational_unsigned_pair_gen_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Rational, T), (Rational, T))> {\n    Generator::new(\n        &|| rational_pair_1_rm(exhaustive_rational_unsigned_pair_gen()),\n        &|config| rational_pair_1_rm(random_rational_primitive_int_pair_gen(config)),\n        &|config| rational_pair_1_rm(special_random_rational_unsigned_pair_gen(config)),\n    )\n}\n\n// All `(Rational, T)` where `T` is small and unsigned.\npub fn rational_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_pair_gen_var_1,\n        &random_rational_unsigned_pair_gen_var_1,\n        &special_random_rational_unsigned_pair_gen_var_1,\n    )\n}\n\npub fn rational_unsigned_pair_gen_var_1_rm<T: PrimitiveUnsigned>()\n-> Generator<((rug::Rational, T), (Rational, T))> {\n    Generator::new(\n        &|| rational_pair_1_rm(exhaustive_rational_unsigned_pair_gen_var_1()),\n        &|config| rational_pair_1_rm(random_rational_unsigned_pair_gen_var_1(config)),\n        &|config| rational_pair_1_rm(special_random_rational_unsigned_pair_gen_var_1(config)),\n    )\n}\n\npub fn rational_unsigned_pair_gen_var_1_nrm<T: PrimitiveUnsigned>()\n-> Generator<((BigRational, T), (rug::Rational, T), (Rational, T))> {\n    Generator::new(\n        &|| rational_pair_1_nrm(exhaustive_rational_unsigned_pair_gen_var_1()),\n        &|config| rational_pair_1_nrm(random_rational_unsigned_pair_gen_var_1(config)),\n        &|config| rational_pair_1_nrm(special_random_rational_unsigned_pair_gen_var_1(config)),\n    )\n}\n\n// All `(Rational, T)` where the `T` is small, unsigned, and positive, and the `Rational` has a\n// small numerator and denominator.\npub fn rational_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>() -> Generator<(Rational, T)> {\n    Generator::new_no_special(\n        &exhaustive_rational_unsigned_pair_gen_var_2,\n        &random_rational_unsigned_pair_gen_var_2,\n    )\n}\n\n// All `(Rational, T)` where the `T` is small, unsigned, and positive.\npub fn rational_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_pair_gen_var_2,\n        &random_rational_unsigned_pair_gen_var_3,\n        &special_random_rational_unsigned_pair_gen_var_2,\n    )\n}\n\n// All `(Rational, T)` where `T` is unsigned, small, and positive, and either the `Rational` is\n// non-negative or the `T` is odd.\npub fn rational_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_pair_gen_var_3,\n        &random_rational_unsigned_pair_gen_var_4,\n        &special_random_rational_unsigned_pair_gen_var_3,\n    )\n}\n\n// All `(Rational, u8)`s where the `u8` is between 2 and 36, inclusive.\npub fn rational_unsigned_pair_gen_var_5() -> Generator<(Rational, u8)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_pair_gen_var_4,\n        &random_rational_unsigned_pair_gen_var_5,\n        &special_random_rational_unsigned_pair_gen_var_4,\n    )\n}\n\n// All `(Rational, u8)`s where the numerator and denominator of the `Rational` is small and the `u8`\n// is between 2 and 36, inclusive.\npub fn rational_unsigned_pair_gen_var_6() -> Generator<(Rational, u8)> {\n    Generator::new_no_special(\n        &exhaustive_rational_unsigned_pair_gen_var_4,\n        &random_rational_unsigned_pair_gen_var_6,\n    )\n}\n\n// All `(Rational, T)` where the `Rational` is nonzero and the `T` is small, unsigned, and positive.\npub fn rational_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_pair_gen_var_5,\n        &random_rational_unsigned_pair_gen_var_7,\n        &special_random_rational_unsigned_pair_gen_var_5,\n    )\n}\n\n// All `(Rational, T)` where the `Rational` is non-negative and the `T` is small, unsigned, and\n// positive.\npub fn rational_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>() -> Generator<(Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_pair_gen_var_6,\n        &random_rational_unsigned_pair_gen_var_8,\n        &special_random_rational_unsigned_pair_gen_var_6,\n    )\n}\n\n// -- (Rational, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn rational_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>() -> Generator<(Rational, T, T)>\n{\n    Generator::new(\n        &exhaustive_rational_unsigned_unsigned_triple_gen,\n        &random_rational_primitive_int_primitive_int_triple_gen,\n        &special_random_rational_unsigned_unsigned_triple_gen,\n    )\n}\n\n// All `(Rational, T, T)` where `T` is unsigned and both `T`s are small.\npub fn rational_unsigned_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Rational, T, T)> {\n    Generator::new(\n        &exhaustive_rational_unsigned_unsigned_triple_gen_var_1,\n        &random_rational_unsigned_unsigned_triple_gen_var_1,\n        &special_random_rational_unsigned_unsigned_triple_gen_var_1,\n    )\n}\n\n// -- (Rational, Rational) --\n\npub fn rational_pair_gen() -> Generator<(Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_pair_gen,\n        &random_rational_pair_gen,\n        &special_random_rational_pair_gen,\n    )\n}\n\npub fn rational_pair_gen_rm() -> Generator<((rug::Rational, rug::Rational), (Rational, Rational))> {\n    Generator::new(\n        &|| rational_pair_rm(exhaustive_rational_pair_gen()),\n        &|config| rational_pair_rm(random_rational_pair_gen(config)),\n        &|config| rational_pair_rm(special_random_rational_pair_gen(config)),\n    )\n}\n\npub fn rational_pair_gen_nm() -> Generator<((BigRational, BigRational), (Rational, Rational))> {\n    Generator::new(\n        &|| rational_pair_nm(exhaustive_rational_pair_gen()),\n        &|config| rational_pair_nm(random_rational_pair_gen(config)),\n        &|config| rational_pair_nm(special_random_rational_pair_gen(config)),\n    )\n}\n\npub fn rational_pair_gen_nrm() -> Generator<(\n    (BigRational, BigRational),\n    (rug::Rational, rug::Rational),\n    (Rational, Rational),\n)> {\n    Generator::new(\n        &|| rational_pair_nrm(exhaustive_rational_pair_gen()),\n        &|config| rational_pair_nrm(random_rational_pair_gen(config)),\n        &|config| rational_pair_nrm(special_random_rational_pair_gen(config)),\n    )\n}\n\n// All pairs of `Rational`s where the second `Rational` is nonzero.\npub fn rational_pair_gen_var_1() -> Generator<(Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_pair_gen_var_1,\n        &random_rational_pair_gen_var_1,\n        &special_random_rational_pair_gen_var_1,\n    )\n}\n\npub fn rational_pair_gen_var_1_rm()\n-> Generator<((rug::Rational, rug::Rational), (Rational, Rational))> {\n    Generator::new(\n        &|| rational_pair_rm(exhaustive_rational_pair_gen_var_1()),\n        &|config| rational_pair_rm(random_rational_pair_gen_var_1(config)),\n        &|config| rational_pair_rm(special_random_rational_pair_gen_var_1(config)),\n    )\n}\n\npub fn rational_pair_gen_var_1_nm() -> Generator<((BigRational, BigRational), (Rational, Rational))>\n{\n    Generator::new(\n        &|| rational_pair_nm(exhaustive_rational_pair_gen_var_1()),\n        &|config| rational_pair_nm(random_rational_pair_gen_var_1(config)),\n        &|config| rational_pair_nm(special_random_rational_pair_gen_var_1(config)),\n    )\n}\n\npub fn rational_pair_gen_var_1_nrm() -> Generator<(\n    (BigRational, BigRational),\n    (rug::Rational, rug::Rational),\n    (Rational, Rational),\n)> {\n    Generator::new(\n        &|| rational_pair_nrm(exhaustive_rational_pair_gen_var_1()),\n        &|config| rational_pair_nrm(random_rational_pair_gen_var_1(config)),\n        &|config| rational_pair_nrm(special_random_rational_pair_gen_var_1(config)),\n    )\n}\n\n// All pairs of `Rational`s where the second is nonzero and the first is not an integer multiple of\n// the second.\npub fn rational_pair_gen_var_2() -> Generator<(Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_pair_gen_var_2,\n        &random_rational_pair_gen_var_2,\n        &special_random_rational_pair_gen_var_2,\n    )\n}\n\n// All pairs of `Rational`s where the first is less than the second.\npub fn rational_pair_gen_var_3() -> Generator<(Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_pair_gen_var_3,\n        &random_rational_pair_gen_var_3,\n        &special_random_rational_pair_gen_var_3,\n    )\n}\n\n// All pairs of `Rational`s where the first is less than or equal to the second.\npub fn rational_pair_gen_var_4() -> Generator<(Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_pair_gen_var_4,\n        &random_rational_pair_gen_var_4,\n        &special_random_rational_pair_gen_var_4,\n    )\n}\n\n// All pairs of `Rational`s where the first is less than the second, and the numerators and\n// denominators are small.\npub fn rational_pair_gen_var_5() -> Generator<(Rational, Rational)> {\n    Generator::new_no_special(\n        &exhaustive_rational_pair_gen_var_3,\n        &random_rational_pair_gen_var_5,\n    )\n}\n\n// All pairs of `Rational`s where the first is less than or equal to the second, and the numerators\n// and denominators are small.\npub fn rational_pair_gen_var_6() -> Generator<(Rational, Rational)> {\n    Generator::new_no_special(\n        &exhaustive_rational_pair_gen_var_4,\n        &random_rational_pair_gen_var_6,\n    )\n}\n\n// All pairs of positive `Rational`s where the second `Rational` is not within 1/1000 of 1.\npub fn rational_pair_gen_var_7() -> Generator<(Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_pair_gen_var_5,\n        &random_rational_pair_gen_var_7,\n        &special_random_rational_pair_gen_var_5,\n    )\n}\n\n// All pairs of nonzero `Rational`s.\npub fn rational_pair_gen_var_8() -> Generator<(Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_pair_gen_var_6,\n        &random_rational_pair_gen_var_8,\n        &special_random_rational_pair_gen_var_6,\n    )\n}\n\n// -- (Rational, Rational, Integer) --\n\npub fn rational_rational_integer_triple_gen() -> Generator<(Rational, Rational, Integer)> {\n    Generator::new(\n        &exhaustive_rational_rational_integer_triple_gen,\n        &random_rational_rational_integer_triple_gen,\n        &special_random_rational_rational_integer_triple_gen,\n    )\n}\n\n// -- (Rational, Rational, Natural) --\n\npub fn rational_rational_natural_triple_gen() -> Generator<(Rational, Rational, Natural)> {\n    Generator::new(\n        &exhaustive_rational_rational_natural_triple_gen,\n        &random_rational_rational_natural_triple_gen,\n        &special_random_rational_rational_natural_triple_gen,\n    )\n}\n\n// All `(Rational, Rational, Natural)` where the `Natural` is positive.\npub fn rational_rational_natural_triple_gen_var_1() -> Generator<(Rational, Rational, Natural)> {\n    Generator::new(\n        &exhaustive_rational_rational_natural_triple_gen_var_1,\n        &random_rational_rational_natural_triple_gen_var_1,\n        &special_random_rational_rational_natural_triple_gen_var_1,\n    )\n}\n\n// -- (Rational, Rational, Natural, Natural) --\n\n// All `(Rational, Rational, Natural, Natural)` where the last `Natural` is positive.\npub fn rational_rational_natural_natural_quadruple_gen_var_1()\n-> Generator<(Rational, Rational, Natural, Natural)> {\n    Generator::new(\n        &exhaustive_rational_rational_natural_natural_quadruple_gen_var_1,\n        &random_rational_rational_natural_natural_quadruple_gen_var_1,\n        &special_random_rational_rational_natural_natural_quadruple_gen_var_1,\n    )\n}\n\n// -- (Rational, Rational, PrimitiveFloat) --\n\npub fn rational_rational_primitive_float_triple_gen<T: PrimitiveFloat>()\n-> Generator<(Rational, Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_rational_primitive_float_triple_gen,\n        &random_rational_rational_primitive_float_triple_gen,\n        &special_random_rational_rational_primitive_float_triple_gen,\n    )\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned) --\n\npub fn rational_rational_unsigned_triple_gen<T: PrimitiveUnsigned>()\n-> Generator<(Rational, Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_rational_unsigned_triple_gen,\n        &random_rational_rational_primitive_int_triple_gen,\n        &special_random_rational_rational_unsigned_triple_gen,\n    )\n}\n\n// All `(Rational, Rational, T)` where `T` is unsigned and small.\npub fn rational_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>()\n-> Generator<(Rational, Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_rational_unsigned_triple_gen_var_1,\n        &random_rational_rational_unsigned_triple_gen_var_1,\n        &special_random_rational_rational_unsigned_triple_gen_var_1,\n    )\n}\n\n// All `(Rational, Rational, T)` where `T` is positive, unsigned, and small.\npub fn rational_rational_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>()\n-> Generator<(Rational, Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_rational_primitive_int_triple_gen_var_1,\n        &random_rational_rational_unsigned_triple_gen_var_2,\n        &special_random_rational_rational_unsigned_triple_gen_var_2,\n    )\n}\n\n// -- (Rational, Rational, PrimitiveSigned) --\n\npub fn rational_rational_signed_triple_gen<T: PrimitiveSigned>()\n-> Generator<(Rational, Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_rational_signed_triple_gen,\n        &random_rational_rational_primitive_int_triple_gen,\n        &special_random_rational_rational_signed_triple_gen,\n    )\n}\n\n// All `(Rational, Rational, T)` where `T` is signed and small, and if `T` is negative, neither\n// `Rational` is zero.\npub fn rational_rational_signed_triple_gen_var_1<T: PrimitiveSigned>()\n-> Generator<(Rational, Rational, T)> {\n    Generator::new(\n        &exhaustive_rational_rational_signed_triple_gen_var_1,\n        &random_rational_rational_signed_triple_gen_var_1,\n        &special_random_rational_rational_signed_triple_gen_var_1,\n    )\n}\n\n// -- (Rational, Rational, Rational) --\n\npub fn rational_triple_gen() -> Generator<(Rational, Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_triple_gen,\n        &random_rational_triple_gen,\n        &special_random_rational_triple_gen,\n    )\n}\n\n// All triples of `Rational` where the last `Rational` is nonzero.\npub fn rational_triple_gen_var_1() -> Generator<(Rational, Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_triple_gen_var_1,\n        &random_rational_triple_gen_var_1,\n        &special_random_rational_triple_gen_var_1,\n    )\n}\n\n// All triples of `Rational`s `(x, y, z)` where x < y < z.\npub fn rational_triple_gen_var_2() -> Generator<(Rational, Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_triple_gen_var_2,\n        &random_rational_triple_gen_var_2,\n        &special_random_rational_triple_gen_var_2,\n    )\n}\n\n// All triples of `Rational`s `(x, y, z)` where x <= y <= z.\npub fn rational_triple_gen_var_3() -> Generator<(Rational, Rational, Rational)> {\n    Generator::new(\n        &exhaustive_rational_triple_gen_var_3,\n        &random_rational_triple_gen_var_3,\n        &special_random_rational_triple_gen_var_3,\n    )\n}\n\n// -- (Rational, Rational, RoundingMode) --\n\n// All `(Rational, Rational, RoundingMode)` triples that are a valid input to\n// `Rational::round_to_multiple`.\npub fn rational_rational_rounding_mode_triple_gen_var_1()\n-> Generator<(Rational, Rational, RoundingMode)> {\n    Generator::new(\n        &exhaustive_rational_rational_rounding_mode_triple_gen_var_1,\n        &random_rational_rational_rounding_mode_triple_gen_var_1,\n        &special_random_rational_rational_rounding_mode_triple_gen_var_1,\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\npub fn rational_rounding_mode_pair_gen() -> Generator<(Rational, RoundingMode)> {\n    Generator::new(\n        &exhaustive_rational_rounding_mode_pair_gen,\n        &random_rational_rounding_mode_pair_gen,\n        &special_random_rational_rounding_mode_pair_gen,\n    )\n}\n\n// All `(Rational, RoundingMode)` pairs that are valid inputs to `Natural::rounding_from(Rational)`.\npub fn rational_rounding_mode_pair_gen_var_1() -> Generator<(Rational, RoundingMode)> {\n    Generator::new(\n        &exhaustive_rational_rounding_mode_pair_gen_var_1,\n        &random_rational_rounding_mode_pair_gen_var_1,\n        &special_random_rational_rounding_mode_pair_gen_var_1,\n    )\n}\n\n// All `(Rational, RoundingMode)` pairs that are valid inputs to `Integer::rounding_from(Rational)`.\npub fn rational_rounding_mode_pair_gen_var_2() -> Generator<(Rational, RoundingMode)> {\n    Generator::new(\n        &exhaustive_rational_rounding_mode_pair_gen_var_2,\n        &random_rational_rounding_mode_pair_gen_var_2,\n        &special_random_rational_rounding_mode_pair_gen_var_2,\n    )\n}\n\n// All `(Rational, RoundingMode)` pairs that are valid inputs to `T::rounding_from(Rational)` for an\n// primitive integer type `T`.\npub fn rational_rounding_mode_pair_gen_var_3<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>() -> Generator<(Rational, RoundingMode)>\nwhere\n    Rational: PartialOrd<T>,\n{\n    Generator::new(\n        &exhaustive_rational_rounding_mode_pair_gen_var_3::<T>,\n        &random_rational_rounding_mode_pair_gen_var_3::<T>,\n        &special_random_rational_rounding_mode_pair_gen_var_3::<T>,\n    )\n}\n\n// All `(Rational, RoundingMode)` pairs where the `Rational` is nonzero.\npub fn rational_rounding_mode_pair_gen_var_4() -> Generator<(Rational, RoundingMode)> {\n    Generator::new(\n        &exhaustive_rational_rounding_mode_pair_gen_var_4,\n        &random_rational_rounding_mode_pair_gen_var_4,\n        &special_random_rational_rounding_mode_pair_gen_var_4,\n    )\n}\n\n// All `(Rational, RoundingMode)` pairs that are valid inputs to `T::rounding_from(Rational)` for an\n// primitive float type `T`.\npub fn rational_rounding_mode_pair_gen_var_5<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat,\n>() -> Generator<(Rational, RoundingMode)>\nwhere\n    Rational: TryFrom<T>,\n{\n    Generator::new(\n        &exhaustive_rational_rounding_mode_pair_gen_var_5::<T>,\n        &random_rational_rounding_mode_pair_gen_var_5::<T>,\n        &special_random_rational_rounding_mode_pair_gen_var_5::<T>,\n    )\n}\n\n// var 6 is in malachite-float.\n\n// -- (Rational, ToSciOptions) --\n\npub fn rational_to_sci_options_pair_gen() -> Generator<(Rational, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_rational_to_sci_options_pair_gen,\n        &random_rational_to_sci_options_pair_gen,\n        &special_random_rational_to_sci_options_pair_gen,\n    )\n}\n\n// All `(Rational, ToSciOptions)` pairs where the `Rational` can be formatted using the options.\npub fn rational_to_sci_options_pair_gen_var_1() -> Generator<(Rational, ToSciOptions)> {\n    Generator::new(\n        &exhaustive_rational_to_sci_options_pair_gen_var_1,\n        &random_rational_to_sci_options_pair_gen_var_1,\n        &special_random_rational_to_sci_options_pair_gen_var_1,\n    )\n}\n\n// -- String --\n\n// vars 1 through 10 are in malachite-base.\n\n// All `String`s that are produced by serializing a `Rational` into json.\npub fn string_gen_var_11() -> Generator<String> {\n    Generator::new(\n        &exhaustive_string_gen_var_11,\n        &random_string_gen_var_11,\n        &special_random_string_gen_var_2,\n    )\n}\n\n// All `String`s that are produced by converting a `Rational` to a string.\npub fn string_gen_var_12() -> Generator<String> {\n    Generator::new(\n        &exhaustive_string_gen_var_12,\n        &random_string_gen_var_12,\n        &special_random_string_gen_var_3,\n    )\n}\n\n// var 13 is in malachite-base.\n\n// -- (String, String, String) --\n\n// vars 1 through 2 are in malachite-nz.\n\n// All triples of `String`s corresponding to the serialization of a `num::BigRational`, a\n// `rug::Rational`, and a `Rational`, respectively, into a JSON string. The three numbers have the\n// same value.\npub fn string_triple_gen_var_3() -> Generator<(String, String, String)> {\n    Generator::new(\n        &exhaustive_string_triple_gen_var_3,\n        &random_string_triple_gen_var_3,\n        &special_random_string_triple_gen_var_3,\n    )\n}\n\n// -- Vec<Rational> --\n\npub fn rational_vec_gen() -> Generator<Vec<Rational>> {\n    Generator::new(\n        &exhaustive_rational_vec_gen,\n        &random_rational_vec_gen,\n        &special_random_rational_vec_gen,\n    )\n}\n\npub fn rational_vec_gen_nrm() -> Generator<(Vec<BigRational>, Vec<rug::Rational>, Vec<Rational>)> {\n    Generator::new(\n        &|| rational_vec_nrm(exhaustive_rational_vec_gen()),\n        &|config| rational_vec_nrm(random_rational_vec_gen(config)),\n        &|config| rational_vec_nrm(special_random_rational_vec_gen(config)),\n    )\n}\n\npub mod common;\npub mod exhaustive;\npub mod random;\npub mod special_random;\n"
  },
  {
    "path": "malachite-q/src/test_util/generators/random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::random::{\n    RandomRationalsFromDoubleAndSign, random_negative_rationals, random_non_negative_rationals,\n    random_nonzero_rationals, random_positive_rationals, random_rationals,\n};\nuse crate::test_util::extra_variadic::{\n    random_ordered_unique_triples, random_quadruples_xxyz, random_triples,\n    random_triples_from_single, random_triples_xxy, random_triples_xyy,\n};\nuse crate::test_util::generators::round_to_multiple_rational_filter;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::string::options::random::random_to_sci_options;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, IsInteger, ToSci};\nuse malachite_base::num::random::geometric::{\n    geometric_random_nonzero_signeds, geometric_random_positive_unsigneds,\n    geometric_random_signeds, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::{\n    random_primitive_ints, random_unsigned_inclusive_range, special_random_finite_primitive_floats,\n    special_random_nonzero_finite_primitive_floats, special_random_primitive_floats,\n};\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::random::random_rounding_modes;\nuse malachite_base::test_util::generators::common::{GenConfig, It};\nuse malachite_base::tuples::random::{\n    random_ordered_unique_pairs, random_pairs, random_pairs_from_single,\n};\nuse malachite_base::unions::Union2;\nuse malachite_base::unions::random::random_union2s;\nuse malachite_base::vecs::random::random_vecs;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::random_integers;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::{\n    random_natural_range_to_infinity, random_naturals, random_positive_naturals,\n};\nuse num::BigRational;\nuse std::cmp::Ordering::*;\nuse std::ops::Shr;\n\n// -- Rational --\n\npub fn random_rational_gen(config: &GenConfig) -> It<Rational> {\n    Box::new(random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_rational_gen_var_1(config: &GenConfig) -> It<Rational> {\n    Box::new(random_nonzero_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_rational_gen_var_2(config: &GenConfig) -> It<Rational> {\n    Box::new(random_positive_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_rational_gen_var_3(config: &GenConfig) -> It<Rational> {\n    Box::new(random_non_negative_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn random_rational_gen_var_4<T: PrimitiveFloat>(config: &GenConfig) -> It<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Box::new(\n        special_random_finite_primitive_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n            config.get_or(\"special_p_mean_n\", 1),\n            config.get_or(\"special_p_mean_d\", 64),\n        )\n        .map(Rational::exact_from),\n    )\n}\n\npub fn random_rational_gen_var_5<T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<Rational> {\n    Box::new(\n        random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .filter(|q| !T::convertible_from(q)),\n    )\n}\n\npub fn random_rational_gen_var_6<T: PrimitiveFloat>(config: &GenConfig) -> It<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Box::new(\n        special_random_nonzero_finite_primitive_floats(\n            EXAMPLE_SEED,\n            config.get_or(\"exponent_mean_n\", 8),\n            config.get_or(\"exponent_mean_d\", 1),\n            config.get_or(\"precision_mean_n\", 8),\n            config.get_or(\"precision_mean_d\", 1),\n        )\n        .map(|f| {\n            let x = Rational::exact_from(f);\n            let y = Rational::exact_from(if f > T::ZERO {\n                f.next_lower()\n            } else {\n                f.next_higher()\n            });\n            (x + y) >> 1\n        }),\n    )\n}\n\npub fn random_rational_gen_var_7(config: &GenConfig) -> It<Rational> {\n    Box::new(RandomRationalsFromDoubleAndSign {\n        bs: random_bools(EXAMPLE_SEED.fork(\"sign\")),\n        xs: geometric_random_unsigneds::<u32>(\n            EXAMPLE_SEED.fork(\"numerator\"),\n            config.get_or(\"mean_small_n\", 64),\n            config.get_or(\"mean_small_d\", 1),\n        )\n        .map(Natural::from),\n        ys: geometric_random_positive_unsigneds::<u32>(\n            EXAMPLE_SEED.fork(\"denominator\"),\n            config.get_or(\"mean_small_n\", 64),\n            config.get_or(\"mean_small_d\", 1),\n        )\n        .map(Natural::from),\n    })\n}\n\npub fn random_rational_gen_var_8(config: &GenConfig) -> It<Rational> {\n    Box::new(\n        random_positive_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .filter(|x| *x != 1u32),\n    )\n}\n\n// -- (Rational, Integer) --\n\npub fn random_rational_integer_pair_gen(config: &GenConfig) -> It<(Rational, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Integer, Integer) --\n\npub fn random_rational_integer_integer_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Integer, Integer)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Natural) --\n\npub fn random_rational_natural_pair_gen(config: &GenConfig) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_natural_pair_gen_var_1(config: &GenConfig) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_natural_pair_gen_var_2(config: &GenConfig) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| RandomRationalsFromDoubleAndSign {\n            bs: random_bools(seed.fork(\"sign\")),\n            xs: geometric_random_unsigneds::<u32>(\n                seed.fork(\"numerator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n            ys: geometric_random_positive_unsigneds::<u32>(\n                seed.fork(\"denominator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n        },\n        &|seed| {\n            random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_natural_pair_gen_var_3(config: &GenConfig) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_natural_pair_gen_var_4(config: &GenConfig) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds::<u64>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from)\n        },\n    ))\n}\n\n// -- (Rational, Natural, Natural) --\n\npub fn random_rational_natural_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Natural, Natural)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_natural_natural_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Natural, Natural)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(_, x, y)| x < y),\n    )\n}\n\n// -- (Rational, PrimitiveFloat) --\n\npub fn random_rational_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveFloat, PrimitiveFloat) --\n\npub fn random_rational_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveInt) --\n\npub fn random_rational_primitive_int_pair_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Rational, PrimitiveInt, PrimitiveInt) --\n\npub fn random_rational_primitive_int_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Rational, PrimitiveSigned) --\n\npub fn random_rational_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_signed_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, exp)| *exp >= T::ZERO || *x != 0u32),\n    )\n}\n\npub fn random_rational_signed_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)>\nwhere\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, pow)| !x.denominator_ref().is_power_of_2() || !(x >> *pow).is_integer()),\n    )\n}\n\npub fn random_rational_signed_pair_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_non_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_nonzero_signeds(\n                            seed_2,\n                            config.get_or(\"small_signed_mean_n\", 32),\n                            config.get_or(\"small_signed_mean_d\", 1),\n                        )\n                    },\n                )\n                .filter(|(q, i)| *i > T::ZERO || *q != 0u32)\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_signeds::<T>(\n                            seed_2,\n                            config.get_or(\"small_signed_mean_n\", 32),\n                            config.get_or(\"small_signed_mean_d\", 1),\n                        )\n                        .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE))\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_rational_signed_pair_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_nonzero_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveSigned) --\n\npub fn random_rational_signed_signed_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, e, f)| *e >= T::ZERO && *f >= T::ZERO || *x != 0),\n    )\n}\n\n// -- (Rational, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn random_rational_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Rational, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds::<U>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveSigned, RoundingMode) --\n\npub fn random_rational_signed_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, i64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<i64>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, i, rm)| {\n            *rm != Exact || x.denominator_ref().is_power_of_2() && (x >> *i).is_integer()\n        }),\n    )\n}\n\n// var 2 is in malachite-float.\n\n// -- (Rational, PrimitiveUnsigned) --\n\npub fn random_rational_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| RandomRationalsFromDoubleAndSign {\n            bs: random_bools(seed.fork(\"sign\")),\n            xs: geometric_random_unsigneds::<u32>(\n                seed.fork(\"numerator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n            ys: geometric_random_positive_unsigneds::<u32>(\n                seed.fork(\"denominator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_unsigned_pair_gen_var_4<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_non_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        random_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds::<T>(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                        .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE))\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn random_rational_unsigned_pair_gen_var_5(config: &GenConfig) -> It<(Rational, u8)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| random_unsigned_inclusive_range(seed, 2, 36),\n    ))\n}\n\npub fn random_rational_unsigned_pair_gen_var_6(config: &GenConfig) -> It<(Rational, u8)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| RandomRationalsFromDoubleAndSign {\n            bs: random_bools(seed.fork(\"sign\")),\n            xs: geometric_random_unsigneds::<u32>(\n                seed.fork(\"numerator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n            ys: geometric_random_positive_unsigneds::<u32>(\n                seed.fork(\"denominator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n        },\n        &|seed| random_unsigned_inclusive_range(seed, 2, 36),\n    ))\n}\n\npub fn random_rational_unsigned_pair_gen_var_7<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_unsigned_pair_gen_var_8<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_non_negative_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn random_rational_unsigned_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational) --\n\npub fn random_rational_pair_gen(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs_from_single(random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_rational_pair_gen_var_1(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_pair_gen_var_2(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_nonzero_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !(x / y).is_integer()),\n    )\n}\n\npub fn random_rational_pair_gen_var_3(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_ordered_unique_pairs(random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_rational_pair_gen_var_4(config: &GenConfig) -> It<(Rational, Rational)> {\n    // TODO\n    Box::new(\n        random_pairs_from_single(random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y)| if x <= y { (x, y) } else { (y, x) }),\n    )\n}\n\npub fn random_rational_pair_gen_var_5(config: &GenConfig) -> It<(Rational, Rational)> {\n    // TODO\n    Box::new(\n        random_pairs_from_single(RandomRationalsFromDoubleAndSign {\n            bs: random_bools(EXAMPLE_SEED.fork(\"sign\")),\n            xs: geometric_random_unsigneds::<u32>(\n                EXAMPLE_SEED.fork(\"numerator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n            ys: geometric_random_positive_unsigneds::<u32>(\n                EXAMPLE_SEED.fork(\"denominator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n        })\n        .filter_map(|(x, y)| match x.cmp(&y) {\n            Equal => None,\n            Less => Some((x, y)),\n            Greater => Some((y, x)),\n        }),\n    )\n}\n\npub fn random_rational_pair_gen_var_6(config: &GenConfig) -> It<(Rational, Rational)> {\n    // TODO\n    Box::new(\n        random_pairs_from_single(RandomRationalsFromDoubleAndSign {\n            bs: random_bools(EXAMPLE_SEED.fork(\"sign\")),\n            xs: geometric_random_unsigneds::<u32>(\n                EXAMPLE_SEED.fork(\"numerator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n            ys: geometric_random_positive_unsigneds::<u32>(\n                EXAMPLE_SEED.fork(\"denominator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n        })\n        .map(|(x, y)| if x <= y { (x, y) } else { (y, x) }),\n    )\n}\n\npub fn random_rational_pair_gen_var_7(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_positive_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_positive_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n            .filter(move |q| (q - Rational::ONE).gt_abs(&Rational::from_signeds(1, 1000)))\n        },\n    ))\n}\n\npub fn random_rational_pair_gen_var_8(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs_from_single(random_nonzero_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\n// -- (Rational, Rational, Integer) --\n\npub fn random_rational_rational_integer_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Integer)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_integers(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, Natural) --\n\npub fn random_rational_rational_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_rational_natural_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, Natural, Natural) --\n\npub fn random_rational_rational_natural_natural_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Natural, Natural)> {\n    Box::new(random_quadruples_xxyz(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_positive_naturals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveFloat) --\n\npub fn random_rational_rational_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            special_random_primitive_floats(\n                seed,\n                config.get_or(\"exponent_mean_n\", 8),\n                config.get_or(\"exponent_mean_d\", 1),\n                config.get_or(\"precision_mean_n\", 8),\n                config.get_or(\"precision_mean_d\", 1),\n                config.get_or(\"special_p_mean_n\", 1),\n                config.get_or(\"special_p_mean_d\", 64),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveInt) --\n\npub fn random_rational_rational_primitive_int_triple_gen<T: PrimitiveInt>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_ints,\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveSigned) --\n\npub fn random_rational_rational_signed_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y, exp)| *exp >= T::ZERO || *x != 0 && *y != 0),\n    )\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned) --\n\npub fn random_rational_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_rational_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, Rational) --\n\npub fn random_rational_triple_gen(config: &GenConfig) -> It<(Rational, Rational, Rational)> {\n    Box::new(random_triples_from_single(random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_rational_triple_gen_var_1(config: &GenConfig) -> It<(Rational, Rational, Rational)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_triple_gen_var_2(config: &GenConfig) -> It<(Rational, Rational, Rational)> {\n    Box::new(random_ordered_unique_triples(random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn random_rational_triple_gen_var_3(config: &GenConfig) -> It<(Rational, Rational, Rational)> {\n    // TODO\n    Box::new(\n        random_triples_from_single(random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| {\n            let mut xs = vec![x, y, z];\n            xs.sort_unstable();\n            let mut xs = xs.into_iter();\n            (xs.next().unwrap(), xs.next().unwrap(), xs.next().unwrap())\n        }),\n    )\n}\n\n// -- (Rational, Rational, RoundingMode) --\n\npub fn random_rational_rational_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(round_to_multiple_rational_filter),\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\npub fn random_rational_rounding_mode_pair_gen(config: &GenConfig) -> It<(Rational, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_rational_rounding_mode_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, rm)| match rm {\n            Floor | Up => *x >= 0u32,\n            Exact => Natural::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\npub fn random_rational_rounding_mode_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, rm)| *rm != Exact || x.is_integer()),\n    )\n}\n\npub fn random_rational_rounding_mode_pair_gen_var_3<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)>\nwhere\n    Rational: PartialOrd<T>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, rm)| match rm {\n            Floor => *x >= T::MIN,\n            Ceiling => *x <= T::MAX,\n            Up => *x >= T::MIN && *x <= T::MAX,\n            Exact => T::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\npub fn random_rational_rounding_mode_pair_gen_var_4(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn random_rational_rounding_mode_pair_gen_var_5<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)>\nwhere\n    Rational: TryFrom<T>,\n{\n    let max = Rational::exact_from(T::MAX_FINITE);\n    let min = -&max;\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(move |(x, rm)| match rm {\n            Floor => *x >= min,\n            Ceiling => *x <= max,\n            Up => *x >= min && *x <= max,\n            Exact => T::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\n// -- (Rational, ToSciOptions) --\n\npub fn random_rational_to_sci_options_pair_gen(config: &GenConfig) -> It<(Rational, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"small_mean_n\", 4),\n                config.get_or(\"small_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn random_rational_to_sci_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_rationals(\n                    seed,\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"small_mean_n\", 4),\n                    config.get_or(\"small_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- String --\n\n// vars 1 through 10 are in malachite-base.\n\npub fn random_string_gen_var_11(config: &GenConfig) -> It<String> {\n    Box::new(\n        random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|r| serde_json::to_string(&r).unwrap()),\n    )\n}\n\npub fn random_string_gen_var_12(config: &GenConfig) -> It<String> {\n    Box::new(\n        random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| x.to_string()),\n    )\n}\n\n// -- (String, String, String) --\n\n// vars 1 through 2 are in malachite-nz.\n\npub fn random_string_triple_gen_var_3(config: &GenConfig) -> It<(String, String, String)> {\n    Box::new(\n        random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| {\n            (\n                serde_json::to_string(&BigRational::from(&x)).unwrap(),\n                serde_json::to_string(&rug::Rational::from(&x)).unwrap(),\n                serde_json::to_string(&x).unwrap(),\n            )\n        }),\n    )\n}\n\n// -- Vec<Rational> --\n\npub fn random_rational_vec_gen(config: &GenConfig) -> It<Vec<Rational>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &|seed| {\n            random_rationals(\n                seed,\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        config.get_or(\"mean_len_n\", 4),\n        config.get_or(\"mean_len_d\", 1),\n    ))\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/generators/special_random.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::random::RandomRationalsFromDoubleAndSign;\nuse crate::random::{\n    striped_random_negative_rationals, striped_random_non_negative_rationals,\n    striped_random_nonzero_rationals, striped_random_positive_rationals, striped_random_rationals,\n};\nuse crate::test_util::extra_variadic::{\n    random_ordered_unique_triples, random_quadruples_xxyz, random_triples,\n    random_triples_from_single, random_triples_xxy, random_triples_xyy,\n};\nuse crate::test_util::generators::round_to_multiple_rational_filter;\nuse malachite_base::bools::random::random_bools;\nuse malachite_base::num::arithmetic::traits::IsPowerOf2;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::string::options::ToSciOptions;\nuse malachite_base::num::conversion::string::options::random::random_to_sci_options;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, IsInteger, ToSci};\nuse malachite_base::num::random::geometric::{\n    geometric_random_nonzero_signeds, geometric_random_positive_unsigneds,\n    geometric_random_signeds, geometric_random_unsigneds,\n};\nuse malachite_base::num::random::striped::{\n    striped_random_signeds, striped_random_unsigned_inclusive_range, striped_random_unsigneds,\n};\nuse malachite_base::num::random::{\n    random_finite_primitive_floats, random_nonzero_finite_primitive_floats, random_primitive_floats,\n};\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::rounding_modes::random::random_rounding_modes;\nuse malachite_base::test_util::generators::common::{GenConfig, It};\nuse malachite_base::tuples::random::{\n    random_ordered_unique_pairs, random_pairs, random_pairs_from_single,\n};\nuse malachite_base::unions::Union2;\nuse malachite_base::unions::random::random_union2s;\nuse malachite_base::vecs::random::random_vecs;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::integer::random::striped_random_integers;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::random::{\n    striped_random_natural_range_to_infinity, striped_random_naturals,\n    striped_random_positive_naturals,\n};\nuse num::BigRational;\nuse std::ops::Shr;\n\n// -- Rational --\n\npub fn special_random_rational_gen(config: &GenConfig) -> It<Rational> {\n    Box::new(striped_random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_rational_gen_var_1(config: &GenConfig) -> It<Rational> {\n    Box::new(striped_random_nonzero_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_rational_gen_var_2(config: &GenConfig) -> It<Rational> {\n    Box::new(striped_random_positive_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_rational_gen_var_3(config: &GenConfig) -> It<Rational> {\n    Box::new(striped_random_non_negative_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    ))\n}\n\npub fn special_random_rational_gen_var_4<T: PrimitiveFloat>(_config: &GenConfig) -> It<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Box::new(random_finite_primitive_floats(EXAMPLE_SEED).map(Rational::exact_from))\n}\n\npub fn special_random_rational_gen_var_5<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<Rational> {\n    Box::new(\n        striped_random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .filter(|q| !T::convertible_from(q)),\n    )\n}\n\npub fn special_random_rational_gen_var_6<T: PrimitiveFloat>(_config: &GenConfig) -> It<Rational>\nwhere\n    Rational: TryFrom<T>,\n{\n    Box::new(\n        random_nonzero_finite_primitive_floats(EXAMPLE_SEED).map(|f| {\n            let x = Rational::exact_from(f);\n            let y = Rational::exact_from(if f > T::ZERO {\n                f.next_lower()\n            } else {\n                f.next_higher()\n            });\n            (x + y) >> 1\n        }),\n    )\n}\n\npub fn special_random_rational_gen_var_7(config: &GenConfig) -> It<Rational> {\n    Box::new(\n        striped_random_positive_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .filter(|x| *x != 1u32),\n    )\n}\n\n// -- (Rational, Integer) --\n\npub fn special_random_rational_integer_pair_gen(config: &GenConfig) -> It<(Rational, Integer)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Integer, Integer) --\n\npub fn special_random_rational_integer_integer_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Integer, Integer)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Natural) --\n\npub fn special_random_rational_natural_pair_gen(config: &GenConfig) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_natural_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_natural_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| RandomRationalsFromDoubleAndSign {\n            bs: random_bools(seed.fork(\"sign\")),\n            xs: geometric_random_unsigneds::<u32>(\n                seed.fork(\"numerator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n            ys: geometric_random_positive_unsigneds::<u32>(\n                seed.fork(\"denominator\"),\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from),\n        },\n        &|seed| {\n            striped_random_natural_range_to_infinity(\n                seed,\n                Natural::TWO,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_natural_pair_gen_var_3(\n    config: &GenConfig,\n) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_natural_pair_gen_var_4(\n    config: &GenConfig,\n) -> It<(Rational, Natural)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds::<u64>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n            .map(Natural::from)\n        },\n    ))\n}\n\n// -- (Rational, Natural, Natural) --\n\npub fn special_random_rational_natural_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Natural, Natural)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_natural_natural_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Natural, Natural)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_positive_naturals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(_, x, y)| x < y),\n    )\n}\n\n// -- (Rational, PrimitiveFloat) --\n\npub fn special_random_rational_primitive_float_pair_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Rational, PrimitiveFloat, PrimitiveFloat) --\n\npub fn special_random_rational_primitive_float_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Rational, PrimitiveSigned) --\n\npub fn special_random_rational_signed_pair_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_signed_pair_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_signed_pair_gen_var_2<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, exp)| *exp >= T::ZERO || *x != 0u32),\n    )\n}\n\npub fn special_random_rational_signed_pair_gen_var_3<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)>\nwhere\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, pow)| !x.denominator_ref().is_power_of_2() || !(x >> *pow).is_integer()),\n    )\n}\n\npub fn special_random_rational_signed_pair_gen_var_4<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_non_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", 32),\n                            config.get_or(\"mean_stripe_d\", 1),\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_nonzero_signeds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n                .filter(|(q, i)| *i > T::ZERO || *q != 0u32)\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", 32),\n                            config.get_or(\"mean_stripe_d\", 1),\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_signeds::<T>(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                        .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE))\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_rational_signed_pair_gen_var_5<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_nonzero_signeds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveSigned, PrimitiveSigned) --\n\npub fn special_random_rational_signed_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_signed_signed_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(\n        random_triples_xyy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<T>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, e, f)| *e >= T::ZERO && *f >= T::ZERO || *x != 0),\n    )\n}\n\n// -- (Rational, PrimitiveSigned, PrimitiveUnsigned) --\n\npub fn special_random_rational_signed_unsigned_triple_gen_var_1<\n    T: PrimitiveSigned,\n    U: PrimitiveUnsigned,\n>(\n    config: &GenConfig,\n) -> It<(Rational, T, U)> {\n    Box::new(random_triples(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_signeds::<T>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds::<U>(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveSigned, RoundingMode) --\n\npub fn special_random_rational_signed_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, i64, RoundingMode)> {\n    Box::new(\n        random_triples(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds::<i64>(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, i, rm)| {\n            *rm != Exact || x.denominator_ref().is_power_of_2() && (x >> *i).is_integer()\n        }),\n    )\n}\n\n// var 2 is in malachite-float.\n\n// -- (Rational, PrimitiveUnsigned) --\n\npub fn special_random_rational_unsigned_pair_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_unsigned_pair_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_unsigned_pair_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_unsigned_pair_gen_var_3<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(\n        random_union2s(\n            EXAMPLE_SEED,\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_non_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", 32),\n                            config.get_or(\"mean_stripe_d\", 1),\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_positive_unsigneds(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                    },\n                )\n            },\n            &|seed| {\n                random_pairs(\n                    seed,\n                    &|seed_2| {\n                        striped_random_negative_rationals(\n                            seed_2,\n                            config.get_or(\"mean_stripe_n\", 32),\n                            config.get_or(\"mean_stripe_d\", 1),\n                            config.get_or(\"mean_bits_n\", 64),\n                            config.get_or(\"mean_bits_d\", 1),\n                        )\n                    },\n                    &|seed_2| {\n                        geometric_random_unsigneds::<T>(\n                            seed_2,\n                            config.get_or(\"small_unsigned_mean_n\", 32),\n                            config.get_or(\"small_unsigned_mean_d\", 1),\n                        )\n                        .filter_map(|i| i.arithmetic_checked_shl(1).map(|j| j | T::ONE))\n                    },\n                )\n            },\n        )\n        .map(Union2::unwrap),\n    )\n}\n\npub fn special_random_rational_unsigned_pair_gen_var_4(config: &GenConfig) -> It<(Rational, u8)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigned_inclusive_range(\n                seed,\n                2,\n                36,\n                config.get_or(\"mean_stripe_n\", 4),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_unsigned_pair_gen_var_5<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_unsigned_pair_gen_var_6<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_non_negative_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, PrimitiveUnsigned, PrimitiveUnsigned) --\n\npub fn special_random_rational_unsigned_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_unsigned_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, T, T)> {\n    Box::new(random_triples_xyy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational) --\n\npub fn special_random_rational_pair_gen(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs_from_single(striped_random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_rational_pair_gen_var_1(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_pair_gen_var_2(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                striped_random_nonzero_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y)| !(x / y).is_integer()),\n    )\n}\n\npub fn special_random_rational_pair_gen_var_3(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_ordered_unique_pairs(striped_random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_rational_pair_gen_var_4(config: &GenConfig) -> It<(Rational, Rational)> {\n    // TODO\n    Box::new(\n        random_pairs_from_single(striped_random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y)| if x <= y { (x, y) } else { (y, x) }),\n    )\n}\n\npub fn special_random_rational_pair_gen_var_5(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_positive_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n            .filter(|q| (q - Rational::ONE).gt_abs(&Rational::from_signeds(1, 1000)))\n        },\n    ))\n}\n\npub fn special_random_rational_pair_gen_var_6(config: &GenConfig) -> It<(Rational, Rational)> {\n    Box::new(random_pairs_from_single(striped_random_nonzero_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\n// -- (Rational, Rational, Integer) --\n\npub fn special_random_rational_rational_integer_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Integer)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_integers(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, Natural) --\n\npub fn special_random_rational_rational_natural_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_rational_natural_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Natural)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, Natural, Natural) --\n\npub fn special_random_rational_rational_natural_natural_quadruple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Natural, Natural)> {\n    Box::new(random_quadruples_xxyz(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_positive_naturals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveFloat) --\n\npub fn special_random_rational_rational_primitive_float_triple_gen<T: PrimitiveFloat>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_primitive_floats,\n    ))\n}\n\n// -- (Rational, Rational, PrimitiveSigned) --\n\npub fn special_random_rational_rational_signed_triple_gen<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_signeds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_rational_signed_triple_gen_var_1<T: PrimitiveSigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                geometric_random_signeds(\n                    seed,\n                    config.get_or(\"mean_small_n\", 64),\n                    config.get_or(\"mean_small_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, y, exp)| *exp >= T::ZERO || *x != 0 && *y != 0),\n    )\n}\n\n// -- (Rational, Rational, PrimitiveUnsigned) --\n\npub fn special_random_rational_rational_unsigned_triple_gen<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_unsigneds(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_rational_unsigned_triple_gen_var_1<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_rational_unsigned_triple_gen_var_2<T: PrimitiveUnsigned>(\n    config: &GenConfig,\n) -> It<(Rational, Rational, T)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            geometric_random_positive_unsigneds(\n                seed,\n                config.get_or(\"mean_small_n\", 64),\n                config.get_or(\"mean_small_d\", 1),\n            )\n        },\n    ))\n}\n\n// -- (Rational, Rational, Rational) --\n\npub fn special_random_rational_triple_gen(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Rational)> {\n    Box::new(random_triples_from_single(striped_random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_rational_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Rational)> {\n    Box::new(random_triples_xxy(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            striped_random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_triple_gen_var_2(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Rational)> {\n    Box::new(random_ordered_unique_triples(striped_random_rationals(\n        EXAMPLE_SEED,\n        config.get_or(\"mean_stripe_n\", 32),\n        config.get_or(\"mean_stripe_d\", 1),\n        config.get_or(\"mean_bits_n\", 64),\n        config.get_or(\"mean_bits_d\", 1),\n    )))\n}\n\npub fn special_random_rational_triple_gen_var_3(\n    config: &GenConfig,\n) -> It<(Rational, Rational, Rational)> {\n    // TODO\n    Box::new(\n        random_triples_from_single(striped_random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        ))\n        .map(|(x, y, z)| {\n            let mut xs = vec![x, y, z];\n            xs.sort_unstable();\n            let mut xs = xs.into_iter();\n            (xs.next().unwrap(), xs.next().unwrap(), xs.next().unwrap())\n        }),\n    )\n}\n\n// -- (Rational, Rational, RoundingMode) --\n\npub fn special_random_rational_rational_rounding_mode_triple_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, Rational, RoundingMode)> {\n    Box::new(\n        random_triples_xxy(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(round_to_multiple_rational_filter),\n    )\n}\n\n// -- (Rational, RoundingMode) --\n\npub fn special_random_rational_rounding_mode_pair_gen(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_rational_rounding_mode_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, rm)| match rm {\n            Floor | Up => *x >= 0u32,\n            Exact => Natural::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\npub fn special_random_rational_rounding_mode_pair_gen_var_2(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, rm)| *rm != Exact || x.is_integer()),\n    )\n}\n\npub fn special_random_rational_rounding_mode_pair_gen_var_3<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)>\nwhere\n    Rational: PartialOrd<T>,\n{\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(|(x, rm)| match rm {\n            Floor => *x >= T::MIN,\n            Ceiling => *x <= T::MAX,\n            Up => *x >= T::MIN && *x <= T::MAX,\n            Exact => T::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\npub fn special_random_rational_rounding_mode_pair_gen_var_4(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_nonzero_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &random_rounding_modes,\n    ))\n}\n\npub fn special_random_rational_rounding_mode_pair_gen_var_5<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveFloat,\n>(\n    config: &GenConfig,\n) -> It<(Rational, RoundingMode)>\nwhere\n    Rational: TryFrom<T>,\n{\n    let max = Rational::exact_from(T::MAX_FINITE);\n    let min = -&max;\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed,\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &random_rounding_modes,\n        )\n        .filter(move |(x, rm)| match rm {\n            Floor => *x >= min,\n            Ceiling => *x <= max,\n            Up => *x >= min && *x <= max,\n            Exact => T::convertible_from(x),\n            _ => true,\n        }),\n    )\n}\n\n// -- (Rational, ToSciOptions) --\n\npub fn special_random_rational_to_sci_options_pair_gen(\n    config: &GenConfig,\n) -> It<(Rational, ToSciOptions)> {\n    Box::new(random_pairs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed.fork(\"xs\"),\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        &|seed| {\n            random_to_sci_options(\n                seed,\n                config.get_or(\"small_mean_n\", 4),\n                config.get_or(\"small_mean_d\", 1),\n            )\n        },\n    ))\n}\n\npub fn special_random_rational_to_sci_options_pair_gen_var_1(\n    config: &GenConfig,\n) -> It<(Rational, ToSciOptions)> {\n    Box::new(\n        random_pairs(\n            EXAMPLE_SEED,\n            &|seed| {\n                striped_random_rationals(\n                    seed.fork(\"xs\"),\n                    config.get_or(\"mean_stripe_n\", 32),\n                    config.get_or(\"mean_stripe_d\", 1),\n                    config.get_or(\"mean_bits_n\", 64),\n                    config.get_or(\"mean_bits_d\", 1),\n                )\n            },\n            &|seed| {\n                random_to_sci_options(\n                    seed,\n                    config.get_or(\"small_mean_n\", 4),\n                    config.get_or(\"small_mean_d\", 1),\n                )\n            },\n        )\n        .filter(|(x, options)| x.fmt_sci_valid(*options)),\n    )\n}\n\n// -- String --\n\n// var 1 is in malachite-base.\n\npub fn special_random_string_gen_var_2(config: &GenConfig) -> It<String> {\n    Box::new(\n        striped_random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|r| serde_json::to_string(&r).unwrap()),\n    )\n}\n\npub fn special_random_string_gen_var_3(config: &GenConfig) -> It<String> {\n    Box::new(\n        striped_random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| x.to_string()),\n    )\n}\n\n// -- (String, String, String) --\n\n// vars 1 through 2 are in malachite-nz.\n\npub fn special_random_string_triple_gen_var_3(config: &GenConfig) -> It<(String, String, String)> {\n    Box::new(\n        striped_random_rationals(\n            EXAMPLE_SEED,\n            config.get_or(\"mean_stripe_n\", 32),\n            config.get_or(\"mean_stripe_d\", 1),\n            config.get_or(\"mean_bits_n\", 64),\n            config.get_or(\"mean_bits_d\", 1),\n        )\n        .map(|x| {\n            (\n                serde_json::to_string(&BigRational::from(&x)).unwrap(),\n                serde_json::to_string(&rug::Rational::from(&x)).unwrap(),\n                serde_json::to_string(&x).unwrap(),\n            )\n        }),\n    )\n}\n\n// -- Vec<Rational> --\n\npub fn special_random_rational_vec_gen(config: &GenConfig) -> It<Vec<Rational>> {\n    Box::new(random_vecs(\n        EXAMPLE_SEED,\n        &|seed| {\n            striped_random_rationals(\n                seed,\n                config.get_or(\"mean_stripe_n\", 32),\n                config.get_or(\"mean_stripe_d\", 1),\n                config.get_or(\"mean_bits_n\", 64),\n                config.get_or(\"mean_bits_d\", 1),\n            )\n        },\n        config.get_or(\"mean_len_n\", 4),\n        config.get_or(\"mean_len_d\", 1),\n    ))\n}\n"
  },
  {
    "path": "malachite-q/src/test_util/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\npub mod arithmetic;\npub mod bench;\npub mod common;\npub mod conversion;\npub mod extra_variadic;\npub mod generators;\npub mod random;\n"
  },
  {
    "path": "malachite-q/src/test_util/random/mod.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse crate::Rational;\nuse crate::itertools::Itertools;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::stats::common_values_map::common_values_map;\nuse malachite_base::test_util::stats::median;\nuse malachite_base::test_util::stats::moments::{MomentStats, moment_stats};\n\npub fn random_rationals_helper_helper<I: Clone + Iterator<Item = Rational>>(\n    xs: I,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    let actual_values = xs\n        .clone()\n        .map(|x| Rational::to_string(&x))\n        .take(20)\n        .collect_vec();\n    let actual_values = actual_values.iter().map(String::as_str).collect_vec();\n    let actual_common_values = common_values_map(1000000, 10, xs.clone())\n        .into_iter()\n        .map(|(x, freq)| (x.to_string(), freq))\n        .collect_vec();\n    let actual_common_values = actual_common_values\n        .iter()\n        .map(|(x, freq)| (x.as_str(), *freq))\n        .collect_vec();\n    let (median_lo, median_hi) = median(xs.clone().take(1000000));\n    let (median_lo, median_hi) = (\n        median_lo.to_string(),\n        median_hi.map(|x| Rational::to_string(&x)),\n    );\n    let actual_sample_median = (median_lo.as_str(), median_hi.as_deref());\n    let actual_sample_moment_stats =\n        moment_stats(xs.take(1000000).map(|x| f64::rounding_from(&x, Nearest).0));\n    assert_eq!(\n        (\n            actual_values.as_slice(),\n            actual_common_values.as_slice(),\n            actual_sample_median,\n            actual_sample_moment_stats\n        ),\n        (\n            expected_values,\n            expected_common_values,\n            expected_sample_median,\n            expected_sample_moment_stats\n        )\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsAssign};\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse num::{BigRational, Signed};\nuse std::str::FromStr;\n\n#[test]\nfn test_abs() {\n    let test = |s, out| {\n        let x = Rational::from_str(s).unwrap();\n\n        let abs = x.clone().abs();\n        assert!(abs.is_valid());\n        assert_eq!(abs.to_string(), out);\n\n        let abs = (&x).abs();\n        assert!(abs.is_valid());\n        assert_eq!(abs.to_string(), out);\n\n        assert_eq!(BigRational::from_str(s).unwrap().abs().to_string(), out);\n        assert_eq!(rug::Rational::from_str(s).unwrap().abs().to_string(), out);\n\n        let mut x = x;\n        x.abs_assign();\n        assert!(abs.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"123\");\n    test(\"-123\", \"123\");\n    test(\"22/7\", \"22/7\");\n    test(\"-22/7\", \"22/7\");\n}\n\n#[test]\nfn abs_properties() {\n    rational_gen().test_properties(|x| {\n        let abs = x.clone().abs();\n        assert!(abs.is_valid());\n\n        assert_eq!(Rational::from(&BigRational::from(&x).abs()), abs);\n\n        assert_eq!(Rational::from(&rug::Rational::from(&x).abs()), abs);\n\n        let abs_alt = (&x).abs();\n        assert!(abs_alt.is_valid());\n        assert_eq!(abs_alt, abs);\n\n        let mut abs_alt = x.clone();\n        abs_alt.abs_assign();\n        assert!(abs_alt.is_valid());\n        assert_eq!(abs_alt, abs);\n\n        assert!(abs >= 0);\n        assert_eq!(abs == x, x >= 0);\n        assert_eq!((&abs).abs(), abs);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(Rational::from(&x).abs(), Rational::from(x.abs()));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/abs_diff.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, AbsDiff, AbsDiffAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen, rational_triple_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_abs_diff_rational() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n.abs_diff_assign(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n.abs_diff_assign(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().abs_diff(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone().abs_diff(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).abs_diff(v.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&u).abs_diff(&v);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"-123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"-456\", \"579\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"333\");\n    test(\"0\", \"-123\", \"123\");\n    test(\"-123\", \"0\", \"123\");\n    test(\"-123\", \"-456\", \"333\");\n    test(\"0\", \"123\", \"123\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"1/2\", \"-1/3\", \"5/6\");\n    test(\"1/2\", \"1/3\", \"1/6\");\n    test(\"-1/2\", \"-1/3\", \"1/6\");\n    test(\"-1/2\", \"1/3\", \"5/6\");\n    test(\"1/2\", \"-1/2\", \"1\");\n    test(\"1/2\", \"1/2\", \"0\");\n    test(\"-1/2\", \"-1/2\", \"0\");\n    test(\"-1/2\", \"1/2\", \"1\");\n}\n\n#[test]\nfn abs_diff_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.abs_diff_assign(&y);\n        assert!(mut_x.is_valid());\n        let diff = mut_x;\n        assert!(diff >= 0);\n\n        let mut mut_x = x.clone();\n        mut_x.abs_diff_assign(y.clone());\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n\n        let diff_alt = x.clone().abs_diff(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = x.clone().abs_diff(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).abs_diff(y.clone());\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        let diff_alt = (&x).abs_diff(&y);\n        assert_eq!(diff_alt, diff);\n        assert!(diff_alt.is_valid());\n\n        assert_eq!((&x - &y).abs(), diff);\n        assert_eq!((&y).abs_diff(&x), diff);\n        assert_eq!((-&x).abs_diff(-&y), diff);\n        assert_eq!(diff == 0, x == y);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!((&x).abs_diff(Rational::ZERO), (&x).abs());\n        assert_eq!((&x).abs_diff(&x), 0);\n        assert_eq!(Rational::ZERO.abs_diff(&x), x.abs());\n    });\n\n    rational_triple_gen().test_properties(|(x, y, z)| {\n        assert!((&x).abs_diff(&z) <= x.abs_diff(&y) + y.abs_diff(z));\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(\n            (&x).abs_diff(&y),\n            Rational::from(x).abs_diff(Rational::from(y))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/add.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_nz::test_util::generators::integer_vec_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::add::add_naive;\nuse malachite_q::test_util::arithmetic::add::rational_sum_naive;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_pair_gen, rational_triple_gen, rational_vec_gen,\n};\nuse num::BigRational;\nuse std::iter::{Sum, once};\nuse std::str::FromStr;\n\n#[test]\nfn test_add() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n += v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n += &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() + v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u + v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() + &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u + &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigRational::from_str(s).unwrap() + BigRational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() + rug::Rational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"456\", \"579\");\n    test(\"0\", \"-123\", \"-123\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"-333\");\n    test(\"0\", \"123\", \"123\");\n    test(\"-123\", \"0\", \"-123\");\n    test(\"-123\", \"456\", \"333\");\n    test(\"0\", \"-123\", \"-123\");\n    test(\"-123\", \"123\", \"0\");\n    test(\"1/2\", \"1/3\", \"5/6\");\n    test(\"1/2\", \"-1/3\", \"1/6\");\n    test(\"-1/2\", \"1/3\", \"-1/6\");\n    test(\"-1/2\", \"-1/3\", \"-5/6\");\n    test(\"1/2\", \"1/2\", \"1\");\n    test(\"1/2\", \"-1/2\", \"0\");\n    test(\"-1/2\", \"1/2\", \"0\");\n    test(\"-1/2\", \"-1/2\", \"-1\");\n}\n\n#[test]\nfn test_sum() {\n    let test = |xs, out| {\n        let xs = vec_from_str(xs).unwrap();\n        let sum = Rational::sum(xs.iter().cloned());\n        assert!(sum.is_valid());\n        assert_eq!(sum.to_string(), out);\n\n        let sum_alt = Rational::sum(xs.iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n\n        let sum_alt = rational_sum_naive(xs.into_iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n    };\n    test(\"[]\", \"0\");\n    test(\"[22/7]\", \"22/7\");\n    test(\"[22/7, 1/3]\", \"73/21\");\n    test(\n        \"[0, 1, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10]\",\n        \"19079/2520\",\n    );\n    test(\n        \"[123456/78901, 34567/890123, 45678/90123]\",\n        \"342501191973781/162294410775211\",\n    );\n}\n\n#[test]\nfn add_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let sum_val_val = x.clone() + y.clone();\n        let sum_val_ref = x.clone() + &y;\n        let sum_ref_val = &x + y.clone();\n        let sum = &x + &y;\n        assert!(sum_val_val.is_valid());\n        assert!(sum_val_ref.is_valid());\n        assert!(sum_ref_val.is_valid());\n        assert!(sum.is_valid());\n        assert_eq!(sum_val_val, sum);\n        assert_eq!(sum_val_ref, sum);\n        assert_eq!(sum_ref_val, sum);\n\n        let mut mut_x = x.clone();\n        mut_x += y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, sum);\n        let mut mut_x = x.clone();\n        mut_x += &y;\n        assert_eq!(mut_x, sum);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Rational::from(&x);\n        mut_x += rug::Rational::from(&y);\n        assert_eq!(Rational::from(&mut_x), sum);\n\n        assert_eq!(\n            Rational::from(&(BigRational::from(&x) + BigRational::from(&y))),\n            sum\n        );\n        assert_eq!(\n            Rational::from(&(rug::Rational::from(&x) + rug::Rational::from(&y))),\n            sum\n        );\n        assert_eq!(add_naive(x.clone(), y.clone()), sum);\n        assert_eq!(&y + &x, sum);\n        assert_eq!(&sum - &x, y);\n        assert_eq!(sum - y, x);\n    });\n\n    rational_gen().test_properties(|ref x| {\n        assert_eq!(x + Rational::ZERO, *x);\n        assert_eq!(Rational::ZERO + x, *x);\n        assert_eq!(x + x, x << 1);\n        assert_eq!(x + (-x), 0);\n    });\n\n    rational_triple_gen().test_properties(|(x, y, z)| {\n        assert_eq!((&x + &y) + &z, x + (y + z));\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(&x + &y, Rational::from(x) + Rational::from(y));\n    });\n}\n\n#[test]\nfn sum_properties() {\n    rational_vec_gen().test_properties(|xs| {\n        let sum = Rational::sum(xs.iter().cloned());\n        assert!(sum.is_valid());\n\n        let sum_alt = Rational::sum(xs.iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n\n        let sum_alt = rational_sum_naive(xs.into_iter());\n        assert!(sum_alt.is_valid());\n        assert_eq!(sum_alt, sum);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!(Rational::sum(once(&x)), x);\n        assert_eq!(Rational::sum(once(x.clone())), x);\n    });\n\n    rational_pair_gen().test_properties(|(x, y)| {\n        let sum = &x + &y;\n        assert_eq!(Rational::sum([&x, &y].into_iter()), sum);\n        assert_eq!(Rational::sum([x, y].into_iter()), sum);\n    });\n\n    integer_vec_gen().test_properties(|xs| {\n        assert_eq!(\n            Rational::sum(xs.iter().map(Rational::from)),\n            Rational::from(Integer::sum(xs.into_iter()))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/approximate.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Reciprocal, RoundToMultiple};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::arithmetic::traits::{Approximate, ApproximateAssign};\nuse malachite_q::test_util::arithmetic::approximate::approximate_naive;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_natural_natural_triple_gen_var_1, rational_natural_pair_gen_var_3,\n    rational_natural_pair_gen_var_4,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_approximate() {\n    let test = |x, d, out| {\n        let mut x = Rational::from_str(x).unwrap();\n        let d = Natural::from_str(d).unwrap();\n        let a = x.clone().approximate(&d);\n        assert!(a.is_valid());\n        assert_eq!(a.to_string(), out);\n        let a = (&x).approximate(&d);\n        assert!(a.is_valid());\n        assert_eq!(a.to_string(), out);\n\n        x.approximate_assign(&d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"3\", \"1\", \"3\");\n    test(\"3\", \"10\", \"3\");\n    test(\"27/32\", \"1\", \"1\");\n    test(\"27/32\", \"3\", \"1\");\n    test(\"27/32\", \"4\", \"3/4\");\n    test(\"27/32\", \"5\", \"4/5\");\n    test(\"27/32\", \"6\", \"5/6\");\n    test(\"27/32\", \"12\", \"5/6\");\n    test(\"27/32\", \"13\", \"11/13\");\n    test(\"27/32\", \"18\", \"11/13\");\n    test(\"27/32\", \"19\", \"16/19\");\n    test(\"27/32\", \"31\", \"16/19\");\n    test(\"27/32\", \"32\", \"27/32\");\n    test(\"27/32\", \"100\", \"27/32\");\n\n    test(\"6369051672525773/4503599627370496\", \"10\", \"7/5\");\n    test(\"6369051672525773/4503599627370496\", \"100\", \"140/99\");\n    test(\"6369051672525773/4503599627370496\", \"1000\", \"1393/985\");\n    test(\n        \"6369051672525773/4503599627370496\",\n        \"1000000\",\n        \"665857/470832\",\n    );\n\n    test(\"884279719003555/281474976710656\", \"10\", \"22/7\");\n    test(\"884279719003555/281474976710656\", \"100\", \"311/99\");\n    test(\"884279719003555/281474976710656\", \"1000\", \"355/113\");\n    test(\n        \"884279719003555/281474976710656\",\n        \"1000000\",\n        \"3126535/995207\",\n    );\n\n    test(\"6121026514868073/2251799813685248\", \"10\", \"19/7\");\n    test(\"6121026514868073/2251799813685248\", \"100\", \"193/71\");\n    test(\"6121026514868073/2251799813685248\", \"1000\", \"1457/536\");\n    test(\n        \"6121026514868073/2251799813685248\",\n        \"1000000\",\n        \"1084483/398959\",\n    );\n\n    test(\"7/9\", \"2\", \"1\");\n    test(\"-7/9\", \"2\", \"-1\");\n    test(\"1/2\", \"1\", \"0\");\n    test(\"-1/2\", \"1\", \"0\");\n    test(\"3/2\", \"1\", \"2\");\n    test(\"-3/2\", \"1\", \"-2\");\n    test(\"1/4\", \"2\", \"0\");\n    test(\"-1/4\", \"2\", \"0\");\n}\n\n#[test]\n#[should_panic]\nfn approximate_assign_fail() {\n    let mut x = Rational::ONE;\n    x.approximate_assign(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn approximate_fail() {\n    Rational::ONE.approximate(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn approximate_ref_fail() {\n    (&Rational::ONE).approximate(&Natural::ZERO);\n}\n\n#[test]\nfn approximate_properties() {\n    rational_natural_pair_gen_var_3().test_properties(|(x, max_denominator)| {\n        let a = x.clone().approximate(&max_denominator);\n        assert!(a.is_valid());\n\n        let a_alt = (&x).approximate(&max_denominator);\n        assert!(a_alt.is_valid());\n        assert_eq!(a, a_alt);\n\n        let mut a_alt = x.clone();\n        a_alt.approximate_assign(&max_denominator);\n        assert!(a_alt.is_valid());\n        assert_eq!(a_alt, a);\n\n        assert_eq!(\n            (&x).round_to_multiple(Rational::from(a.denominator_ref()).reciprocal(), Nearest)\n                .0,\n            a\n        );\n        assert_eq!((-x).approximate(&max_denominator), -a);\n    });\n\n    rational_natural_pair_gen_var_4().test_properties(|(x, max_denominator)| {\n        assert_eq!(\n            (&x).approximate(&max_denominator),\n            approximate_naive(&x, &max_denominator)\n        );\n    });\n\n    rational_natural_natural_triple_gen_var_1().test_properties(|(x, d, max_d)| {\n        let a = (&x).approximate(&max_d);\n        let a_alt = (&x)\n            .round_to_multiple(Rational::from(&d).reciprocal(), Nearest)\n            .0;\n        assert!((&x - a_alt).ge_abs(&(&x - &a)));\n\n        let a_worse = x.approximate(&d);\n        assert!(a_worse.denominator_ref() <= a.denominator_ref());\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!((&x).approximate(x.denominator_ref()), x);\n        assert_eq!(\n            (&x).approximate(&Natural::ONE),\n            Integer::rounding_from(x, Nearest).0\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/ceiling.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ceiling, CeilingAssign, Floor};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse num::BigRational;\nuse std::str::FromStr;\n\n#[test]\nfn test_ceiling() {\n    let test = |s, out| {\n        let x = Rational::from_str(s).unwrap();\n\n        let ceiling = x.clone().ceiling();\n        assert!(ceiling.is_valid());\n        assert_eq!(ceiling.to_string(), out);\n\n        let ceiling = (&x).ceiling();\n        assert!(ceiling.is_valid());\n        assert_eq!(ceiling.to_string(), out);\n\n        assert_eq!(BigRational::from_str(s).unwrap().ceil().to_string(), out);\n        assert_eq!(rug::Rational::from_str(s).unwrap().ceil().to_string(), out);\n\n        let mut x = x;\n        x.ceiling_assign();\n        assert!(ceiling.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"1\", \"1\");\n    test(\"-1\", \"-1\");\n    test(\"123\", \"123\");\n    test(\"22/7\", \"4\");\n    test(\"-22/7\", \"-3\");\n    test(\"936851431250/1397\", \"670616630\");\n}\n\n#[test]\nfn ceiling_properties() {\n    rational_gen().test_properties(|x| {\n        let ceiling = x.clone().ceiling();\n        assert!(ceiling.is_valid());\n\n        assert_eq!(Rational::from(&BigRational::from(&x).ceil()), ceiling);\n\n        assert_eq!(Rational::from(&rug::Rational::from(&x).ceil()), ceiling);\n\n        let ceiling_alt = (&x).ceiling();\n        assert!(ceiling_alt.is_valid());\n        assert_eq!(ceiling_alt, ceiling);\n\n        let mut ceiling_alt = x.clone();\n        ceiling_alt.ceiling_assign();\n        assert!(ceiling_alt.is_valid());\n        assert_eq!(ceiling_alt, ceiling);\n\n        assert_eq!(Integer::rounding_from(&x, Ceiling).0, ceiling);\n        assert!(ceiling >= x);\n        assert!(&ceiling - Integer::ONE < x);\n        assert_eq!(ceiling, Rational::from(&ceiling).ceiling());\n        assert_eq!(ceiling, -(-x).floor());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/denominators_in_closed_interval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::comparison::is_strictly_ascending;\nuse malachite_base::iterators::prefix_to_string;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::natural::exhaustive::exhaustive_positive_naturals;\nuse malachite_q::Rational;\nuse malachite_q::arithmetic::traits::DenominatorsInClosedInterval;\nuse malachite_q::exhaustive::exhaustive_rationals_with_denominator_inclusive_range;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen_var_3};\nuse std::str::FromStr;\n\n#[test]\nfn test_denominators_in_closed_interval() {\n    let test = |a, b, out| {\n        let a = Rational::from_str(a).unwrap();\n        let b = Rational::from_str(b).unwrap();\n        assert_eq!(\n            prefix_to_string(Rational::denominators_in_closed_interval(a, b), 20),\n            out\n        );\n    };\n    test(\n        \"0\",\n        \"2\",\n        \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...]\",\n    );\n    test(\n        \"1/3\",\n        \"1/2\",\n        \"[2, 3, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ...]\",\n    );\n    test(\n        \"99/100\",\n        \"101/100\",\n        \"[1, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, \\\n        117, 118, ...]\",\n    );\n    test(\n        \"1/1000000000001\",\n        \"1/1000000000000\",\n        \"[1000000000000, 1000000000001, 2000000000001, 3000000000001, 3000000000002, \\\n        4000000000001, 4000000000003, 5000000000001, 5000000000002, 5000000000003, 5000000000004, \\\n        6000000000001, 6000000000005, 7000000000001, 7000000000002, 7000000000003, 7000000000004, \\\n        7000000000005, 7000000000006, 8000000000001, ...]\",\n    );\n    // about e to about π\n    test(\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, ...]\",\n    );\n    test(\n        \"5/19\",\n        \"3/11\",\n        \"[11, 15, 19, 26, 34, 37, 41, 48, 49, 53, 56, 59, 63, 64, 67, 70, 71, 72, 79, 81, ...]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn denominators_in_closed_interval_fail_1() {\n    Rational::denominators_in_closed_interval(Rational::ONE, Rational::ONE);\n}\n\n#[test]\n#[should_panic]\nfn denominators_in_closed_interval_fail_2() {\n    Rational::denominators_in_closed_interval(Rational::ONE, Rational::ZERO);\n}\n\n#[test]\nfn denominators_in_closed_interval_properties() {\n    let mut i = 0;\n    rational_pair_gen_var_3().test_properties(|(a, b)| {\n        let ds = Rational::denominators_in_closed_interval(a.clone(), b.clone())\n            .take(20)\n            .collect_vec();\n        assert!(is_strictly_ascending(ds.iter()));\n        for d in &ds {\n            assert!(\n                exhaustive_rationals_with_denominator_inclusive_range(\n                    d.clone(),\n                    a.clone(),\n                    b.clone()\n                )\n                .next()\n                .is_some()\n            );\n        }\n        for d in 1u32..=20 {\n            let d = Natural::from(d);\n            if !ds.contains(&d) {\n                assert!(\n                    exhaustive_rationals_with_denominator_inclusive_range(\n                        d.clone(),\n                        a.clone(),\n                        b.clone(),\n                    )\n                    .next()\n                    .is_none(),\n                    \"{a} {b} {d} {i} {ds:?}\"\n                );\n            }\n        }\n        i += 1;\n    });\n\n    rational_gen().test_properties(|a| {\n        assert!(\n            Rational::denominators_in_closed_interval(a.clone(), a + Rational::ONE)\n                .take(20)\n                .eq(exhaustive_positive_naturals().take(20))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/div.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedDiv, Reciprocal};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::div::div_naive;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_1, rational_pair_gen, rational_pair_gen_var_1,\n    rational_triple_gen_var_1,\n};\nuse num::{BigRational, CheckedDiv as NumCheckedDiv};\nuse std::str::FromStr;\n\n#[test]\nfn test_div() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n /= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n /= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() / v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u / v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() / &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u / &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigRational::from_str(s).unwrap() / BigRational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() / rug::Rational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"1/123\", \"0\");\n    test(\"0\", \"-1/123\", \"0\");\n    test(\"1\", \"1/123\", \"123\");\n    test(\"1\", \"-1/123\", \"-123\");\n    test(\"-1\", \"1/123\", \"-123\");\n    test(\"-1\", \"-1/123\", \"123\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"-1\", \"-123\");\n    test(\"-123\", \"1\", \"-123\");\n    test(\"-123\", \"-1\", \"123\");\n    test(\"123\", \"1/456\", \"56088\");\n    test(\"123\", \"-1/456\", \"-56088\");\n    test(\"-123\", \"1/456\", \"-56088\");\n    test(\"-123\", \"-1/456\", \"56088\");\n    test(\"22/7\", \"2/3\", \"33/7\");\n    test(\"22/7\", \"-2/3\", \"-33/7\");\n    test(\"-22/7\", \"2/3\", \"-33/7\");\n    test(\"-22/7\", \"-2/3\", \"33/7\");\n    test(\"4/5\", \"4/5\", \"1\");\n    test(\"4/5\", \"-4/5\", \"-1\");\n    test(\"-4/5\", \"4/5\", \"-1\");\n    test(\"-4/5\", \"-4/5\", \"1\");\n}\n\n#[test]\nfn test_checked_div() {\n    let test = |s, t, out: Option<&'static str>| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let n = u.clone().checked_div(v.clone());\n        assert_eq!(n.as_ref().map(ToString::to_string).as_deref(), out);\n        if out.is_some() {\n            assert!(n.unwrap().is_valid());\n        }\n\n        let n = (&u).checked_div(v.clone());\n        assert_eq!(n.as_ref().map(ToString::to_string).as_deref(), out);\n        if out.is_some() {\n            assert!(n.unwrap().is_valid());\n        }\n\n        let n = u.clone().checked_div(&v);\n        assert_eq!(n.as_ref().map(ToString::to_string).as_deref(), out);\n        if out.is_some() {\n            assert!(n.unwrap().is_valid());\n        }\n\n        let n = (&u).checked_div(&v);\n        assert_eq!(n.as_ref().map(ToString::to_string).as_deref(), out);\n        if out.is_some() {\n            assert!(n.unwrap().is_valid());\n        }\n\n        let n = BigRational::from_str(s)\n            .unwrap()\n            .checked_div(&BigRational::from_str(t).unwrap());\n        assert_eq!(n.as_ref().map(ToString::to_string).as_deref(), out);\n    };\n    test(\"0\", \"1/123\", Some(\"0\"));\n    test(\"0\", \"-1/123\", Some(\"0\"));\n    test(\"0\", \"0\", None);\n    test(\"1\", \"1/123\", Some(\"123\"));\n    test(\"1\", \"-1/123\", Some(\"-123\"));\n    test(\"1\", \"0\", None);\n    test(\"-1\", \"1/123\", Some(\"-123\"));\n    test(\"-1\", \"-1/123\", Some(\"123\"));\n    test(\"-1\", \"0\", None);\n    test(\"123\", \"1\", Some(\"123\"));\n    test(\"123\", \"-1\", Some(\"-123\"));\n    test(\"123\", \"0\", None);\n    test(\"-123\", \"1\", Some(\"-123\"));\n    test(\"-123\", \"-1\", Some(\"123\"));\n    test(\"-123\", \"0\", None);\n    test(\"123\", \"1/456\", Some(\"56088\"));\n    test(\"123\", \"-1/456\", Some(\"-56088\"));\n    test(\"-123\", \"1/456\", Some(\"-56088\"));\n    test(\"-123\", \"-1/456\", Some(\"56088\"));\n    test(\"22/7\", \"2/3\", Some(\"33/7\"));\n    test(\"22/7\", \"-2/3\", Some(\"-33/7\"));\n    test(\"22/7\", \"0\", None);\n    test(\"-22/7\", \"2/3\", Some(\"-33/7\"));\n    test(\"-22/7\", \"-2/3\", Some(\"33/7\"));\n    test(\"-22/7\", \"0\", None);\n    test(\"4/5\", \"4/5\", Some(\"1\"));\n    test(\"4/5\", \"-4/5\", Some(\"-1\"));\n    test(\"4/5\", \"0\", None);\n    test(\"-4/5\", \"4/5\", Some(\"-1\"));\n    test(\"-4/5\", \"-4/5\", Some(\"1\"));\n    test(\"-4/5\", \"0\", None);\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_fail_1() {\n    Rational::ONE / Rational::ZERO;\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_fail_2() {\n    Rational::ZERO / Rational::ZERO;\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_val_ref_fail_1() {\n    Rational::ONE / &Rational::ZERO;\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_val_ref_fail_2() {\n    Rational::ZERO / &Rational::ZERO;\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_ref_val_fail_1() {\n    &Rational::ONE / Rational::ZERO;\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_ref_val_fail_2() {\n    &Rational::ZERO / Rational::ZERO;\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_ref_ref_fail_1() {\n    &Rational::ONE / &Rational::ZERO;\n}\n\n#[allow(clippy::no_effect, unused_must_use)]\n#[test]\n#[should_panic]\nfn div_ref_ref_fail_2() {\n    &Rational::ZERO / &Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_fail_1() {\n    let mut x = Rational::ONE;\n    x /= Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_fail_2() {\n    let mut x = Rational::ZERO;\n    x /= Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_ref_fail_1() {\n    let mut x = Rational::ONE;\n    x /= &Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn div_assign_ref_fail_2() {\n    let mut x = Rational::ZERO;\n    x /= &Rational::ZERO;\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn div_properties() {\n    rational_pair_gen_var_1().test_properties(|(x, y)| {\n        let quotient_val_val = x.clone() / y.clone();\n        let quotient_val_ref = x.clone() / &y;\n        let quotient_ref_val = &x / y.clone();\n        let quotient = &x / &y;\n        assert!(quotient_val_val.is_valid());\n        assert!(quotient_val_ref.is_valid());\n        assert!(quotient_ref_val.is_valid());\n        assert!(quotient.is_valid());\n        assert_eq!(quotient_val_val, quotient);\n        assert_eq!(quotient_val_ref, quotient);\n        assert_eq!(quotient_ref_val, quotient);\n\n        let mut mut_x = x.clone();\n        mut_x /= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, quotient);\n        let mut mut_x = x.clone();\n        mut_x /= &y;\n        assert_eq!(mut_x, quotient);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Rational::from(&x);\n        mut_x /= rug::Rational::from(&y);\n        assert_eq!(Rational::from(&mut_x), quotient);\n\n        assert_eq!(\n            Rational::from(&(BigRational::from(&x) / BigRational::from(&y))),\n            quotient\n        );\n        assert_eq!(\n            Rational::from(&(rug::Rational::from(&x) / rug::Rational::from(&y))),\n            quotient\n        );\n        assert_eq!(div_naive(x.clone(), y.clone()), quotient);\n        assert_eq!((&x).checked_div(y.clone()).unwrap(), quotient);\n        assert_eq!(&x * (&y).reciprocal(), quotient);\n        assert_eq!(&quotient * &y, x);\n        if quotient != 0u32 {\n            assert_eq!(&y / &x, (&quotient).reciprocal());\n            assert_eq!(&x / &quotient, y);\n        }\n        assert_eq!(-&x / &y, -&quotient);\n        assert_eq!(x / -y, -quotient);\n    });\n\n    rational_gen().test_properties(|ref x| {\n        assert_eq!(x / Rational::ONE, *x);\n        assert_eq!(x / Rational::NEGATIVE_ONE, -x);\n    });\n\n    rational_gen_var_1().test_properties(|ref x| {\n        assert_eq!(Rational::ZERO / x, 0);\n        assert_eq!(Rational::ONE / x, x.reciprocal());\n        assert_eq!(Rational::NEGATIVE_ONE / x, -x.reciprocal());\n        assert_eq!(x / x, 1);\n    });\n\n    rational_triple_gen_var_1().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x + y) / z, x / z + y / z);\n        assert_eq!((x - y) / z, x / z - y / z);\n    });\n}\n\n#[test]\nfn checked_div_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let quotient_val_val = x.clone().checked_div(y.clone());\n        let quotient_val_ref = x.clone().checked_div(&y);\n        let quotient_ref_val = (&x).checked_div(y.clone());\n        let quotient = (&x).checked_div(&y);\n        assert!(quotient_val_val.as_ref().is_none_or(Rational::is_valid));\n        assert!(quotient_val_ref.as_ref().is_none_or(Rational::is_valid));\n        assert!(quotient_ref_val.as_ref().is_none_or(Rational::is_valid));\n        assert!(quotient.as_ref().is_none_or(Rational::is_valid));\n        assert_eq!(quotient_val_val, quotient);\n        assert_eq!(quotient_val_ref, quotient);\n        assert_eq!(quotient_ref_val, quotient);\n\n        if y != 0u32 {\n            assert_eq!(quotient, Some(&x / &y));\n        }\n\n        assert_eq!(\n            BigRational::from(&x)\n                .checked_div(&BigRational::from(&y))\n                .map(|q| Rational::from(&q)),\n            quotient\n        );\n    });\n\n    rational_gen().test_properties(|ref x| {\n        assert_eq!(x.checked_div(Rational::ZERO), None);\n        assert_eq!(x.checked_div(Rational::ONE), Some(x.clone()));\n        assert_eq!(x.checked_div(Rational::NEGATIVE_ONE), Some(-x));\n    });\n\n    rational_gen_var_1().test_properties(|ref x| {\n        assert_eq!(Rational::ZERO.checked_div(x), Some(Rational::ZERO));\n        assert_eq!(Rational::ONE.checked_div(x), Some(x.reciprocal()));\n        assert_eq!(Rational::NEGATIVE_ONE.checked_div(x), Some(-x.reciprocal()));\n        assert_eq!(x.checked_div(x), Some(Rational::ONE));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/floor.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ceiling, Floor, FloorAssign};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse num::BigRational;\nuse std::str::FromStr;\n\n#[test]\nfn test_floor() {\n    let test = |s, out| {\n        let x = Rational::from_str(s).unwrap();\n\n        let floor = x.clone().floor();\n        assert!(floor.is_valid());\n        assert_eq!(floor.to_string(), out);\n\n        let floor = (&x).floor();\n        assert!(floor.is_valid());\n        assert_eq!(floor.to_string(), out);\n\n        assert_eq!(BigRational::from_str(s).unwrap().floor().to_string(), out);\n        assert_eq!(rug::Rational::from_str(s).unwrap().floor().to_string(), out);\n\n        let mut x = x;\n        x.floor_assign();\n        assert!(floor.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"1\", \"1\");\n    test(\"-1\", \"-1\");\n    test(\"123\", \"123\");\n    test(\"22/7\", \"3\");\n    test(\"-22/7\", \"-4\");\n    test(\"936851431250/1397\", \"670616629\");\n}\n\n#[test]\nfn floor_properties() {\n    rational_gen().test_properties(|x| {\n        let floor = x.clone().floor();\n        assert!(floor.is_valid());\n\n        assert_eq!(Rational::from(&BigRational::from(&x).floor()), floor);\n        assert_eq!(Rational::from(&rug::Rational::from(&x).floor()), floor);\n\n        let floor_alt = (&x).floor();\n        assert!(floor_alt.is_valid());\n        assert_eq!(floor_alt, floor);\n\n        let mut floor_alt = x.clone();\n        floor_alt.floor_assign();\n        assert!(floor_alt.is_valid());\n        assert_eq!(floor_alt, floor);\n\n        assert_eq!(Integer::rounding_from(&x, Floor).0, floor);\n        assert!(floor <= x);\n        assert!(&floor + Integer::ONE > x);\n        assert_eq!(floor, Rational::from(&floor).floor());\n        assert_eq!(floor, -(-x).ceiling());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/is_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, IsPowerOf2, NextPowerOf2, Reciprocal,\n};\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_gen_var_1, rational_gen_var_2};\nuse std::str::FromStr;\n\n#[test]\nfn test_is_power_of_2() {\n    let test = |x, out| {\n        assert_eq!(Rational::from_str(x).unwrap().is_power_of_2(), out);\n    };\n    test(\"0\", false);\n    test(\"1\", true);\n    test(\"2\", true);\n    test(\"3\", false);\n    test(\"4\", true);\n    test(\"5\", false);\n    test(\"6\", false);\n    test(\"7\", false);\n    test(\"8\", true);\n    test(\"1024\", true);\n    test(\"1025\", false);\n    test(\"1000000000000\", false);\n    test(\"1099511627776\", true);\n    test(\"1/2\", true);\n    test(\"1/3\", false);\n    test(\"1/4\", true);\n    test(\"1/5\", false);\n    test(\"1/6\", false);\n    test(\"1/7\", false);\n    test(\"1/8\", true);\n    test(\"1/1024\", true);\n    test(\"1/1025\", false);\n    test(\"1/1000000000000\", false);\n    test(\"1/1099511627776\", true);\n\n    test(\"22/7\", false);\n    test(\"-1\", false);\n}\n\n#[test]\nfn is_power_of_2_properties() {\n    rational_gen().test_properties(|x| {\n        if x.is_power_of_2() {\n            assert!(x >= 0u32);\n        }\n    });\n\n    rational_gen_var_2().test_properties(|x| {\n        let is_power = x.is_power_of_2();\n        assert_eq!((&x).next_power_of_2() == x, is_power);\n        assert_eq!(x.checked_log_base_2().is_some(), is_power);\n    });\n\n    rational_gen_var_1().test_properties(|x| {\n        assert_eq!((&x).reciprocal().is_power_of_2(), x.is_power_of_2());\n    });\n\n    natural_gen().test_properties(|x| {\n        assert_eq!(x.is_power_of_2(), Rational::from(x).is_power_of_2());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/log_base.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase, CeilingLogBase2, CheckedLogBase, CheckedLogBase2, FloorLogBase, FloorLogBase2,\n    Pow,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Two, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_3;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen_var_2, rational_gen_var_8, rational_pair_gen_var_7,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_approx_log() {\n    let test = |s, out| {\n        assert_eq!(\n            NiceFloat(Rational::from_str(s).unwrap().approx_log()),\n            NiceFloat(out)\n        );\n    };\n    test(\"1\", 0.0);\n    test(\"2\", std::f64::consts::LN_2);\n    test(\"3\", 1.0986122886681096);\n    test(\"10\", 2.3025850929940455);\n    test(\"100\", 4.605170185988091);\n    test(\"1000\", 6.907755278982137);\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        138.15510557964274,\n    );\n    test(\"1/2\", -std::f64::consts::LN_2);\n    test(\"1/3\", -1.0986122886681098);\n    test(\"22/7\", 1.1451323043030026);\n    test(\"936851431250/1397\", 20.323708189458696);\n}\n\n#[test]\n#[should_panic]\nfn approx_log_fail() {\n    Rational::ZERO.approx_log();\n}\n\n#[test]\nfn test_floor_log_base() {\n    let test = |n, base, out| {\n        assert_eq!(\n            Rational::from_str(n)\n                .unwrap()\n                .floor_log_base(&Rational::from_str(base).unwrap()),\n            out\n        );\n    };\n    test(\"1\", \"2\", 0);\n    test(\"1\", \"5\", 0);\n    test(\"2\", \"2\", 1);\n    test(\"2\", \"3\", 0);\n    test(\"3\", \"2\", 1);\n    test(\"3\", \"3\", 1);\n    test(\"3\", \"4\", 0);\n    test(\"100\", \"2\", 6);\n    test(\"100\", \"3\", 4);\n    test(\"100\", \"4\", 3);\n    test(\"100\", \"5\", 2);\n    test(\"100\", \"10\", 2);\n    test(\"100\", \"11\", 1);\n    test(\n        \"999999999999999999999999999999999999999999999999999999999999\",\n        \"10\",\n        59,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"10\",\n        60,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000001\",\n        \"10\",\n        60,\n    );\n    test(\"1/2\", \"2\", -1);\n    test(\"1/3\", \"2\", -2);\n    test(\"1/2\", \"3\", -1);\n    test(\"1/3\", \"3\", -1);\n    test(\"22/7\", \"3\", 1);\n    test(\"1/64\", \"4\", -3);\n    test(\"22/7\", \"10\", 0);\n    test(\"936851431250/1397\", \"10\", 8);\n    test(\"1/2\", \"1/2\", 1);\n    test(\"1/3\", \"1/2\", 1);\n    test(\"1/2\", \"1/3\", 0);\n    test(\"1/3\", \"1/3\", 1);\n    test(\"22/7\", \"1/3\", -2);\n    test(\"1/64\", \"1/4\", 3);\n    test(\"22/7\", \"1/10\", -1);\n    test(\"936851431250/1397\", \"1/10\", -9);\n    test(\"936851431250/1397\", \"22/7\", 17);\n    test(\"100\", \"101/100\", 462);\n    test(\"100\", \"100/101\", -463);\n    test(\"5153632/16807\", \"22/7\", 5);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_fail_1() {\n    Rational::ZERO.floor_log_base(&Rational::TWO);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_fail_2() {\n    Rational::ONE.floor_log_base(&Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_fail_3() {\n    Rational::ONE.floor_log_base(&Rational::ONE);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_fail_4() {\n    Rational::NEGATIVE_ONE.floor_log_base(&Rational::TWO);\n}\n\n#[test]\nfn test_ceiling_log_base() {\n    let test = |n, base, out| {\n        assert_eq!(\n            Rational::from_str(n)\n                .unwrap()\n                .ceiling_log_base(&Rational::from_str(base).unwrap()),\n            out\n        );\n    };\n    test(\"1\", \"2\", 0);\n    test(\"1\", \"5\", 0);\n    test(\"2\", \"2\", 1);\n    test(\"2\", \"3\", 1);\n    test(\"3\", \"2\", 2);\n    test(\"3\", \"3\", 1);\n    test(\"3\", \"4\", 1);\n    test(\"100\", \"2\", 7);\n    test(\"100\", \"3\", 5);\n    test(\"100\", \"4\", 4);\n    test(\"100\", \"5\", 3);\n    test(\"100\", \"10\", 2);\n    test(\"100\", \"11\", 2);\n    test(\n        \"999999999999999999999999999999999999999999999999999999999999\",\n        \"10\",\n        60,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"10\",\n        60,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000001\",\n        \"10\",\n        61,\n    );\n    test(\"1/2\", \"2\", -1);\n    test(\"1/3\", \"2\", -1);\n    test(\"1/2\", \"3\", 0);\n    test(\"1/3\", \"3\", -1);\n    test(\"22/7\", \"3\", 2);\n    test(\"1/64\", \"4\", -3);\n    test(\"22/7\", \"10\", 1);\n    test(\"936851431250/1397\", \"10\", 9);\n    test(\"1/2\", \"1/2\", 1);\n    test(\"1/3\", \"1/2\", 2);\n    test(\"1/2\", \"1/3\", 1);\n    test(\"1/3\", \"1/3\", 1);\n    test(\"22/7\", \"1/3\", -1);\n    test(\"1/64\", \"1/4\", 3);\n    test(\"22/7\", \"1/10\", 0);\n    test(\"936851431250/1397\", \"1/10\", -8);\n    test(\"936851431250/1397\", \"22/7\", 18);\n    test(\"100\", \"101/100\", 463);\n    test(\"100\", \"100/101\", -462);\n    test(\"5153632/16807\", \"22/7\", 5);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_fail_1() {\n    Rational::ZERO.ceiling_log_base(&Rational::TWO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_fail_2() {\n    Rational::ONE.ceiling_log_base(&Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_fail_3() {\n    Rational::ONE.ceiling_log_base(&Rational::ONE);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_fail_4() {\n    Rational::NEGATIVE_ONE.ceiling_log_base(&Rational::TWO);\n}\n\n#[test]\nfn test_checked_log_base() {\n    let test = |n, base, out| {\n        assert_eq!(\n            Rational::from_str(n)\n                .unwrap()\n                .checked_log_base(&Rational::from_str(base).unwrap()),\n            out\n        );\n    };\n    test(\"1\", \"2\", Some(0));\n    test(\"1\", \"5\", Some(0));\n    test(\"2\", \"2\", Some(1));\n    test(\"2\", \"3\", None);\n    test(\"3\", \"2\", None);\n    test(\"3\", \"3\", Some(1));\n    test(\"3\", \"4\", None);\n    test(\"100\", \"2\", None);\n    test(\"100\", \"3\", None);\n    test(\"100\", \"4\", None);\n    test(\"100\", \"5\", None);\n    test(\"100\", \"10\", Some(2));\n    test(\"100\", \"11\", None);\n    test(\n        \"999999999999999999999999999999999999999999999999999999999999\",\n        \"10\",\n        None,\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000000\",\n        \"10\",\n        Some(60),\n    );\n    test(\n        \"1000000000000000000000000000000000000000000000000000000000001\",\n        \"10\",\n        None,\n    );\n    test(\"1/2\", \"2\", Some(-1));\n    test(\"1/3\", \"2\", None);\n    test(\"1/2\", \"3\", None);\n    test(\"1/3\", \"3\", Some(-1));\n    test(\"22/7\", \"3\", None);\n    test(\"1/64\", \"4\", Some(-3));\n    test(\"22/7\", \"10\", None);\n    test(\"936851431250/1397\", \"10\", None);\n    test(\"1/2\", \"1/2\", Some(1));\n    test(\"1/3\", \"1/2\", None);\n    test(\"1/2\", \"1/3\", None);\n    test(\"1/3\", \"1/3\", Some(1));\n    test(\"22/7\", \"1/3\", None);\n    test(\"1/64\", \"1/4\", Some(3));\n    test(\"22/7\", \"1/10\", None);\n    test(\"936851431250/1397\", \"1/10\", None);\n    test(\"936851431250/1397\", \"22/7\", None);\n    test(\"100\", \"101/100\", None);\n    test(\"100\", \"100/101\", None);\n    test(\"5153632/16807\", \"22/7\", Some(5));\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_fail_1() {\n    Rational::ZERO.checked_log_base(&Rational::TWO);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_fail_2() {\n    Rational::ONE.checked_log_base(&Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_fail_3() {\n    Rational::ONE.checked_log_base(&Rational::ONE);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_fail_4() {\n    Rational::NEGATIVE_ONE.checked_log_base(&Rational::TWO);\n}\n\n#[test]\nfn approx_log_properties() {\n    rational_gen_var_2().test_properties(|n| {\n        let log = n.approx_log();\n        assert!(log.is_finite());\n        assert!(!log.is_nan());\n    });\n}\n\n#[test]\nfn floor_log_base_properties() {\n    rational_pair_gen_var_7().test_properties(|(n, base)| {\n        let floor_log = n.floor_log_base(&base);\n\n        let power = (&base).pow(floor_log);\n        if base >= 1u32 {\n            assert!(power <= n);\n            assert!(&power * &base > n);\n        } else {\n            assert!(power >= n);\n            assert!(&power * &base < n);\n        }\n\n        let ceiling_log = n.ceiling_log_base(&base);\n        if power == n {\n            assert_eq!(ceiling_log, floor_log);\n        } else {\n            assert_eq!(ceiling_log, floor_log + 1);\n        }\n    });\n\n    rational_gen_var_2().test_properties(|n| {\n        assert_eq!(n.floor_log_base(&Rational::TWO), n.floor_log_base_2());\n    });\n\n    rational_gen_var_8().test_properties(|base| {\n        assert_eq!(Rational::ONE.floor_log_base(&base), 0);\n    });\n\n    natural_pair_gen_var_3().test_properties(|(n, base)| {\n        assert_eq!(\n            n.floor_log_base(&base),\n            u64::exact_from(Rational::from(n).floor_log_base(&Rational::from(base)))\n        );\n    });\n}\n\n#[test]\nfn ceiling_log_base_properties() {\n    rational_pair_gen_var_7().test_properties(|(n, base)| {\n        let ceiling_log = n.ceiling_log_base(&base);\n\n        let power = (&base).pow(ceiling_log);\n        if base >= 1u32 {\n            assert!(power >= n);\n            assert!(&power / &base < n);\n        } else {\n            assert!(power <= n);\n            assert!(&power / &base > n);\n        }\n\n        let floor_log = n.floor_log_base(&base);\n        if power == n {\n            assert_eq!(floor_log, ceiling_log);\n        } else {\n            assert_eq!(floor_log, ceiling_log - 1);\n        }\n    });\n\n    rational_gen_var_2().test_properties(|n| {\n        assert_eq!(n.ceiling_log_base(&Rational::TWO), n.ceiling_log_base_2());\n    });\n\n    rational_gen_var_8().test_properties(|base| {\n        assert_eq!(Rational::ONE.ceiling_log_base(&base), 0);\n    });\n\n    natural_pair_gen_var_3().test_properties(|(n, base)| {\n        assert_eq!(\n            n.ceiling_log_base(&base),\n            u64::exact_from(Rational::from(n).ceiling_log_base(&Rational::from(base)))\n        );\n    });\n}\n\n#[test]\nfn checked_log_base_properties() {\n    rational_pair_gen_var_7().test_properties(|(n, base)| {\n        let checked_log = n.checked_log_base(&base);\n        if let Some(log) = checked_log {\n            assert_eq!((&base).pow(log), n);\n            assert_eq!(n.floor_log_base(&base), log);\n            assert_eq!(n.ceiling_log_base(&base), log);\n        }\n    });\n\n    rational_gen_var_2().test_properties(|n| {\n        assert_eq!(n.checked_log_base(&Rational::TWO), n.checked_log_base_2());\n    });\n\n    rational_gen_var_8().test_properties(|base| {\n        assert_eq!(Rational::ONE.checked_log_base(&base), Some(0));\n    });\n\n    natural_pair_gen_var_3().test_properties(|(n, base)| {\n        assert_eq!(\n            n.checked_log_base(&base),\n            Rational::from(n)\n                .checked_log_base(&Rational::from(base))\n                .map(u64::exact_from)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/log_base_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, CeilingLogBase2, CheckedLogBase2, FloorLogBase2, IsPowerOf2, PowerOf2,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_nz::test_util::generators::natural_gen_var_2;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen_var_1, rational_gen_var_2};\nuse std::str::FromStr;\n\n#[test]\nfn test_floor_log_base_2_abs() {\n    let test = |n, out| {\n        assert_eq!(Rational::from_str(n).unwrap().floor_log_base_2_abs(), out);\n    };\n    test(\"1\", 0);\n    test(\"100\", 6);\n    test(\"1000000000000\", 39);\n    test(\"4294967295\", 31);\n    test(\"4294967296\", 32);\n    test(\"4294967297\", 32);\n    test(\"22/7\", 1);\n    test(\"936851431250/1397\", 29);\n    test(\"1/1000000000000\", -40);\n    test(\"1/4294967295\", -32);\n    test(\"1/4294967296\", -32);\n    test(\"1/4294967297\", -33);\n    test(\"1/2\", -1);\n    test(\"1/3\", -2);\n    test(\"1/4\", -2);\n    test(\"1/5\", -3);\n    test(\"1/6\", -3);\n    test(\"1/7\", -3);\n    test(\"1/8\", -3);\n    test(\"1/9\", -4);\n\n    test(\"-1\", 0);\n    test(\"-100\", 6);\n    test(\"-1000000000000\", 39);\n    test(\"-4294967295\", 31);\n    test(\"-4294967296\", 32);\n    test(\"-4294967297\", 32);\n    test(\"-22/7\", 1);\n    test(\"-936851431250/1397\", 29);\n    test(\"-1/1000000000000\", -40);\n    test(\"-1/4294967295\", -32);\n    test(\"-1/4294967296\", -32);\n    test(\"-1/4294967297\", -33);\n    test(\"-1/2\", -1);\n    test(\"-1/3\", -2);\n    test(\"-1/4\", -2);\n    test(\"-1/5\", -3);\n    test(\"-1/6\", -3);\n    test(\"-1/7\", -3);\n    test(\"-1/8\", -3);\n    test(\"-1/9\", -4);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_2_abs_fail() {\n    Rational::ZERO.floor_log_base_2_abs();\n}\n\n#[test]\nfn test_ceiling_log_base_2_abs() {\n    let test = |n, out| {\n        assert_eq!(Rational::from_str(n).unwrap().ceiling_log_base_2_abs(), out);\n    };\n    test(\"1\", 0);\n    test(\"100\", 7);\n    test(\"1000000000000\", 40);\n    test(\"4294967295\", 32);\n    test(\"4294967296\", 32);\n    test(\"4294967297\", 33);\n    test(\"22/7\", 2);\n    test(\"936851431250/1397\", 30);\n    test(\"1/1000000000000\", -39);\n    test(\"1/4294967295\", -31);\n    test(\"1/4294967296\", -32);\n    test(\"1/4294967297\", -32);\n    test(\"1/2\", -1);\n    test(\"1/3\", -1);\n    test(\"1/4\", -2);\n    test(\"1/5\", -2);\n    test(\"1/6\", -2);\n    test(\"1/7\", -2);\n    test(\"1/8\", -3);\n    test(\"1/9\", -3);\n\n    test(\"-1\", 0);\n    test(\"-100\", 7);\n    test(\"-1000000000000\", 40);\n    test(\"-4294967295\", 32);\n    test(\"-4294967296\", 32);\n    test(\"-4294967297\", 33);\n    test(\"-22/7\", 2);\n    test(\"-936851431250/1397\", 30);\n    test(\"-1/1000000000000\", -39);\n    test(\"-1/4294967295\", -31);\n    test(\"-1/4294967296\", -32);\n    test(\"-1/4294967297\", -32);\n    test(\"-1/2\", -1);\n    test(\"-1/3\", -1);\n    test(\"-1/4\", -2);\n    test(\"-1/5\", -2);\n    test(\"-1/6\", -2);\n    test(\"-1/7\", -2);\n    test(\"-1/8\", -3);\n    test(\"-1/9\", -3);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_2_abs_fail() {\n    Rational::ZERO.ceiling_log_base_2_abs();\n}\n\n#[test]\nfn test_floor_log_base_2() {\n    let test = |n, out| {\n        assert_eq!(Rational::from_str(n).unwrap().floor_log_base_2(), out);\n    };\n    test(\"1\", 0);\n    test(\"100\", 6);\n    test(\"1000000000000\", 39);\n    test(\"4294967295\", 31);\n    test(\"4294967296\", 32);\n    test(\"4294967297\", 32);\n    test(\"22/7\", 1);\n    test(\"936851431250/1397\", 29);\n    test(\"1/1000000000000\", -40);\n    test(\"1/4294967295\", -32);\n    test(\"1/4294967296\", -32);\n    test(\"1/4294967297\", -33);\n    test(\"1/2\", -1);\n    test(\"1/3\", -2);\n    test(\"1/4\", -2);\n    test(\"1/5\", -3);\n    test(\"1/6\", -3);\n    test(\"1/7\", -3);\n    test(\"1/8\", -3);\n    test(\"1/9\", -4);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_2_fail_1() {\n    Rational::ZERO.floor_log_base_2();\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_2_fail_2() {\n    Rational::NEGATIVE_ONE.floor_log_base_2();\n}\n\n#[test]\nfn test_ceiling_log_base_2() {\n    let test = |n, out| {\n        assert_eq!(Rational::from_str(n).unwrap().ceiling_log_base_2(), out);\n    };\n    test(\"1\", 0);\n    test(\"100\", 7);\n    test(\"1000000000000\", 40);\n    test(\"4294967295\", 32);\n    test(\"4294967296\", 32);\n    test(\"4294967297\", 33);\n    test(\"22/7\", 2);\n    test(\"936851431250/1397\", 30);\n    test(\"1/1000000000000\", -39);\n    test(\"1/4294967295\", -31);\n    test(\"1/4294967296\", -32);\n    test(\"1/4294967297\", -32);\n    test(\"1/2\", -1);\n    test(\"1/3\", -1);\n    test(\"1/4\", -2);\n    test(\"1/5\", -2);\n    test(\"1/6\", -2);\n    test(\"1/7\", -2);\n    test(\"1/8\", -3);\n    test(\"1/9\", -3);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_2_fail() {\n    Rational::ZERO.ceiling_log_base_2();\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_2_fail_2() {\n    Rational::NEGATIVE_ONE.ceiling_log_base_2();\n}\n\n#[test]\nfn test_checked_log_base_2() {\n    let test = |n, out| {\n        assert_eq!(Rational::from_str(n).unwrap().checked_log_base_2(), out);\n    };\n    test(\"1\", Some(0));\n    test(\"100\", None);\n    test(\"1000000000000\", None);\n    test(\"4294967295\", None);\n    test(\"4294967296\", Some(32));\n    test(\"4294967297\", None);\n    test(\"22/7\", None);\n    test(\"936851431250/1397\", None);\n    test(\"1/1000000000000\", None);\n    test(\"1/4294967295\", None);\n    test(\"1/4294967296\", Some(-32));\n    test(\"1/4294967297\", None);\n    test(\"1/2\", Some(-1));\n    test(\"1/3\", None);\n    test(\"1/4\", Some(-2));\n    test(\"1/5\", None);\n    test(\"1/6\", None);\n    test(\"1/7\", None);\n    test(\"1/8\", Some(-3));\n    test(\"1/9\", None);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_2_fail() {\n    Rational::ZERO.checked_log_base_2();\n}\n\n#[test]\nfn floor_log_base_2_abs_properties() {\n    rational_gen_var_1().test_properties(|x| {\n        let floor_log_base_2 = x.floor_log_base_2_abs();\n        assert_eq!((&x).abs().floor_log_base_2(), floor_log_base_2);\n        assert!(Rational::power_of_2(floor_log_base_2).le_abs(&x));\n        assert!(x.lt_abs(&Rational::power_of_2(floor_log_base_2 + 1)));\n    });\n}\n\n#[test]\nfn ceiling_log_base_2_abs_properties() {\n    rational_gen_var_1().test_properties(|x| {\n        let ceiling_log_base_2 = x.ceiling_log_base_2_abs();\n        assert_eq!((&x).abs().ceiling_log_base_2(), ceiling_log_base_2);\n        assert!(Rational::power_of_2(ceiling_log_base_2 - 1).lt_abs(&x));\n        assert!(x.le_abs(&Rational::power_of_2(ceiling_log_base_2)));\n    });\n}\n\n#[test]\nfn floor_log_base_2_properties() {\n    rational_gen_var_2().test_properties(|x| {\n        let floor_log_base_2 = x.floor_log_base_2();\n        assert!(Rational::power_of_2(floor_log_base_2) <= x);\n        assert!(x < Rational::power_of_2(floor_log_base_2 + 1));\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(\n            i64::exact_from((&n).floor_log_base_2()),\n            Rational::from(n).floor_log_base_2()\n        );\n    });\n}\n\n#[test]\nfn ceiling_log_base_2_properties() {\n    rational_gen_var_2().test_properties(|x| {\n        let ceiling_log_base_2 = x.ceiling_log_base_2();\n        assert!(Rational::power_of_2(ceiling_log_base_2 - 1) < x);\n        assert!(x <= Rational::power_of_2(ceiling_log_base_2));\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(\n            i64::exact_from((&n).ceiling_log_base_2()),\n            Rational::from(n).ceiling_log_base_2()\n        );\n    });\n}\n\n#[test]\nfn checked_log_base_2_properties() {\n    rational_gen_var_2().test_properties(|x| {\n        let checked_log_base_2 = x.checked_log_base_2();\n        assert_eq!(checked_log_base_2.is_some(), x.is_power_of_2());\n        if let Some(log_base_2) = checked_log_base_2 {\n            assert_eq!(x.floor_log_base_2(), log_base_2);\n            assert_eq!(x.ceiling_log_base_2(), log_base_2);\n            assert_eq!(Rational::power_of_2(log_base_2), x);\n        }\n    });\n\n    natural_gen_var_2().test_properties(|n| {\n        assert_eq!(\n            (&n).checked_log_base_2().map(i64::exact_from),\n            Rational::from(n).checked_log_base_2()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/log_base_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase, CeilingLogBase2, CeilingLogBasePowerOf2, CheckedLogBase, CheckedLogBase2,\n    CheckedLogBasePowerOf2, DivisibleBy, FloorLogBase, FloorLogBase2, FloorLogBasePowerOf2,\n    IsPowerOf2, PowerOf2, Reciprocal,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::signed_gen_var_12;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_8;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen_var_2, rational_signed_pair_gen_var_5};\nuse std::str::FromStr;\n\n#[test]\nfn test_floor_log_base_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Rational::from_str(n)\n                .unwrap()\n                .floor_log_base_power_of_2(pow),\n            out\n        );\n    };\n    test(\"1\", 1, 0);\n    test(\"1\", 2, 0);\n    test(\"1\", 5, 0);\n    test(\"100\", 1, 6);\n    test(\"100\", 2, 3);\n    test(\"100\", 5, 1);\n    test(\"1000000000000\", 1, 39);\n    test(\"1000000000000\", 2, 19);\n    test(\"1000000000000\", 5, 7);\n    test(\"1000000000000\", 5, 7);\n    test(\"1\", -1, 0);\n    test(\"1\", -2, 0);\n    test(\"1\", -5, 0);\n    test(\"100\", -1, -7);\n    test(\"100\", -2, -4);\n    test(\"100\", -5, -2);\n    test(\"1000000000000\", -1, -40);\n    test(\"1000000000000\", -2, -20);\n    test(\"1000000000000\", -5, -8);\n    test(\"1000000000000\", -5, -8);\n    test(\"1/2\", 1, -1);\n    test(\"1/3\", 1, -2);\n    test(\"1/4\", 1, -2);\n    test(\"1/5\", 1, -3);\n    test(\"1/6\", 1, -3);\n    test(\"1/7\", 1, -3);\n    test(\"1/8\", 1, -3);\n    test(\"1/9\", 1, -4);\n    test(\"1/2\", 2, -1);\n    test(\"1/3\", 2, -1);\n    test(\"1/4\", 2, -1);\n    test(\"1/5\", 2, -2);\n    test(\"1/6\", 2, -2);\n    test(\"1/7\", 2, -2);\n    test(\"1/8\", 2, -2);\n    test(\"1/9\", 2, -2);\n    test(\"1/2\", -1, 1);\n    test(\"1/3\", -1, 1);\n    test(\"1/4\", -1, 2);\n    test(\"1/5\", -1, 2);\n    test(\"1/6\", -1, 2);\n    test(\"1/7\", -1, 2);\n    test(\"1/8\", -1, 3);\n    test(\"1/9\", -1, 3);\n    test(\"1/2\", -2, 0);\n    test(\"1/3\", -2, 0);\n    test(\"1/4\", -2, 1);\n    test(\"1/5\", -2, 1);\n    test(\"1/6\", -2, 1);\n    test(\"1/7\", -2, 1);\n    test(\"1/8\", -2, 1);\n    test(\"1/9\", -2, 1);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_power_of_2_fail_1() {\n    Rational::ZERO.floor_log_base_power_of_2(1);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_power_of_2_fail_2() {\n    Rational::ONE.floor_log_base_power_of_2(0);\n}\n\n#[test]\n#[should_panic]\nfn floor_log_base_power_of_2_fail_3() {\n    Rational::NEGATIVE_ONE.floor_log_base_power_of_2(1);\n}\n\n#[test]\nfn test_ceiling_log_base_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Rational::from_str(n)\n                .unwrap()\n                .ceiling_log_base_power_of_2(pow),\n            out\n        );\n    };\n    test(\"1\", 1, 0);\n    test(\"1\", 2, 0);\n    test(\"1\", 5, 0);\n    test(\"100\", 1, 7);\n    test(\"100\", 2, 4);\n    test(\"100\", 5, 2);\n    test(\"1000000000000\", 1, 40);\n    test(\"1000000000000\", 2, 20);\n    test(\"1000000000000\", 5, 8);\n    test(\"1000000000000\", 5, 8);\n    test(\"1\", -1, 0);\n    test(\"1\", -2, 0);\n    test(\"1\", -5, 0);\n    test(\"100\", -1, -6);\n    test(\"100\", -2, -3);\n    test(\"100\", -5, -1);\n    test(\"1000000000000\", -1, -39);\n    test(\"1000000000000\", -2, -19);\n    test(\"1000000000000\", -5, -7);\n    test(\"1000000000000\", -5, -7);\n    test(\"1/2\", 1, -1);\n    test(\"1/3\", 1, -1);\n    test(\"1/4\", 1, -2);\n    test(\"1/5\", 1, -2);\n    test(\"1/6\", 1, -2);\n    test(\"1/7\", 1, -2);\n    test(\"1/8\", 1, -3);\n    test(\"1/9\", 1, -3);\n    test(\"1/2\", 2, 0);\n    test(\"1/3\", 2, 0);\n    test(\"1/4\", 2, -1);\n    test(\"1/5\", 2, -1);\n    test(\"1/6\", 2, -1);\n    test(\"1/7\", 2, -1);\n    test(\"1/8\", 2, -1);\n    test(\"1/9\", 2, -1);\n    test(\"1/2\", -1, 1);\n    test(\"1/3\", -1, 2);\n    test(\"1/4\", -1, 2);\n    test(\"1/5\", -1, 3);\n    test(\"1/6\", -1, 3);\n    test(\"1/7\", -1, 3);\n    test(\"1/8\", -1, 3);\n    test(\"1/9\", -1, 4);\n    test(\"1/2\", -2, 1);\n    test(\"1/3\", -2, 1);\n    test(\"1/4\", -2, 1);\n    test(\"1/5\", -2, 2);\n    test(\"1/6\", -2, 2);\n    test(\"1/7\", -2, 2);\n    test(\"1/8\", -2, 2);\n    test(\"1/9\", -2, 2);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_power_of_2_fail_1() {\n    Rational::ZERO.ceiling_log_base_power_of_2(1);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_power_of_2_fail_2() {\n    Rational::ONE.ceiling_log_base_power_of_2(0);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_log_base_power_of_2_fail_3() {\n    Rational::NEGATIVE_ONE.ceiling_log_base_power_of_2(1);\n}\n\n#[test]\nfn test_checked_log_base_power_of_2() {\n    let test = |n, pow, out| {\n        assert_eq!(\n            Rational::from_str(n)\n                .unwrap()\n                .checked_log_base_power_of_2(pow),\n            out\n        );\n    };\n    test(\"1\", 1, Some(0));\n    test(\"1\", 2, Some(0));\n    test(\"1\", 5, Some(0));\n    test(\"100\", 1, None);\n    test(\"100\", 2, None);\n    test(\"100\", 5, None);\n    test(\"1000000000000\", 1, None);\n    test(\"1000000000000\", 2, None);\n    test(\"1000000000000\", 5, None);\n    test(\"1000000000000\", 5, None);\n    test(\"1\", -1, Some(0));\n    test(\"1\", -2, Some(0));\n    test(\"1\", -5, Some(0));\n    test(\"100\", -1, None);\n    test(\"100\", -2, None);\n    test(\"100\", -5, None);\n    test(\"1000000000000\", -1, None);\n    test(\"1000000000000\", -2, None);\n    test(\"1000000000000\", -5, None);\n    test(\"1000000000000\", -5, None);\n    test(\"1/2\", 1, Some(-1));\n    test(\"1/3\", 1, None);\n    test(\"1/4\", 1, Some(-2));\n    test(\"1/5\", 1, None);\n    test(\"1/6\", 1, None);\n    test(\"1/7\", 1, None);\n    test(\"1/8\", 1, Some(-3));\n    test(\"1/9\", 1, None);\n    test(\"1/2\", 2, None);\n    test(\"1/3\", 2, None);\n    test(\"1/4\", 2, Some(-1));\n    test(\"1/5\", 2, None);\n    test(\"1/6\", 2, None);\n    test(\"1/7\", 2, None);\n    test(\"1/8\", 2, None);\n    test(\"1/9\", 2, None);\n    test(\"1/2\", -1, Some(1));\n    test(\"1/3\", -1, None);\n    test(\"1/4\", -1, Some(2));\n    test(\"1/5\", -1, None);\n    test(\"1/6\", -1, None);\n    test(\"1/7\", -1, None);\n    test(\"1/8\", -1, Some(3));\n    test(\"1/9\", -1, None);\n    test(\"1/2\", -2, None);\n    test(\"1/3\", -2, None);\n    test(\"1/4\", -2, Some(1));\n    test(\"1/5\", -2, None);\n    test(\"1/6\", -2, None);\n    test(\"1/7\", -2, None);\n    test(\"1/8\", -2, None);\n    test(\"1/9\", -2, None);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_power_of_2_fail_1() {\n    Rational::ZERO.checked_log_base_power_of_2(1);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_power_of_2_fail_2() {\n    Rational::ONE.checked_log_base_power_of_2(0);\n}\n\n#[test]\n#[should_panic]\nfn checked_log_base_power_of_2_fail_3() {\n    Rational::NEGATIVE_ONE.checked_log_base_power_of_2(1);\n}\n\n#[test]\nfn floor_log_base_power_of_2_properties() {\n    rational_signed_pair_gen_var_5().test_properties(|(n, pow)| {\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        assert_eq!(n.floor_log_base(&Rational::power_of_2(pow)), floor_log);\n\n        let product = floor_log * pow;\n        if pow >= 0 {\n            assert!(Rational::power_of_2(product) <= n);\n            assert!(Rational::power_of_2(product + pow) > n);\n        } else {\n            assert!(Rational::power_of_2(product) >= n);\n            assert!(Rational::power_of_2(product + pow) < n);\n        }\n\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        if n.is_power_of_2() && n.checked_log_base_2().unwrap().divisible_by(pow) {\n            assert_eq!(ceiling_log, floor_log);\n        } else {\n            assert_eq!(ceiling_log, floor_log + 1);\n        }\n\n        assert_eq!(n.floor_log_base_power_of_2(-pow), -ceiling_log);\n        assert_eq!(n.reciprocal().floor_log_base_power_of_2(pow), -ceiling_log);\n    });\n\n    rational_gen_var_2().test_properties(|n| {\n        assert_eq!(n.floor_log_base_power_of_2(1), n.floor_log_base_2());\n    });\n\n    signed_gen_var_12().test_properties(|pow| {\n        assert_eq!(Rational::ONE.floor_log_base_power_of_2(pow), 0);\n    });\n\n    natural_unsigned_pair_gen_var_8().test_properties(|(n, pow)| {\n        assert_eq!(\n            i64::exact_from(n.floor_log_base_power_of_2(pow)),\n            Rational::from(n).floor_log_base_power_of_2(i64::exact_from(pow))\n        );\n    });\n}\n\n#[test]\nfn ceiling_log_base_power_of_2_properties() {\n    rational_signed_pair_gen_var_5().test_properties(|(n, pow)| {\n        let ceiling_log = n.ceiling_log_base_power_of_2(pow);\n        assert_eq!(n.ceiling_log_base(&Rational::power_of_2(pow)), ceiling_log);\n\n        let product = ceiling_log * pow;\n        if pow >= 0 {\n            assert!(Rational::power_of_2(product) >= n);\n            assert!(Rational::power_of_2(product - pow) < n);\n        } else {\n            assert!(Rational::power_of_2(product) <= n);\n            assert!(Rational::power_of_2(product - pow) > n);\n        }\n\n        let floor_log = n.floor_log_base_power_of_2(pow);\n        if n.is_power_of_2() && n.checked_log_base_2().unwrap().divisible_by(pow) {\n            assert_eq!(floor_log, ceiling_log);\n        } else {\n            assert_eq!(floor_log, ceiling_log - 1);\n        }\n\n        assert_eq!(n.ceiling_log_base_power_of_2(-pow), -floor_log);\n        assert_eq!(n.reciprocal().ceiling_log_base_power_of_2(pow), -floor_log);\n    });\n\n    rational_gen_var_2().test_properties(|n| {\n        assert_eq!(n.ceiling_log_base_power_of_2(1), n.ceiling_log_base_2());\n    });\n\n    signed_gen_var_12().test_properties(|pow| {\n        assert_eq!(Rational::ONE.ceiling_log_base_power_of_2(pow), 0);\n    });\n\n    natural_unsigned_pair_gen_var_8().test_properties(|(n, pow)| {\n        assert_eq!(\n            i64::exact_from(n.ceiling_log_base_power_of_2(pow)),\n            Rational::from(n).ceiling_log_base_power_of_2(i64::exact_from(pow))\n        );\n    });\n}\n\n#[test]\nfn checked_log_base_power_of_2_properties() {\n    rational_signed_pair_gen_var_5().test_properties(|(n, pow)| {\n        let checked_log = n.checked_log_base_power_of_2(pow);\n        assert_eq!(n.checked_log_base(&Rational::power_of_2(pow)), checked_log);\n        assert_eq!(\n            checked_log.is_some(),\n            n.is_power_of_2() && n.checked_log_base_2().unwrap().divisible_by(pow)\n        );\n        if let Some(log) = checked_log {\n            assert_eq!(Rational::power_of_2(log * pow), n);\n            assert_eq!(log == 0, n == Rational::ONE);\n            assert_eq!(n.floor_log_base_power_of_2(pow), log);\n            assert_eq!(n.ceiling_log_base_power_of_2(pow), log);\n            assert_eq!(n.checked_log_base_power_of_2(-pow), Some(-log));\n            assert_eq!(n.reciprocal().checked_log_base_power_of_2(pow), Some(-log));\n        }\n    });\n\n    rational_gen_var_2().test_properties(|n| {\n        assert_eq!(n.checked_log_base_power_of_2(1), n.checked_log_base_2());\n    });\n\n    signed_gen_var_12().test_properties(|pow| {\n        assert_eq!(Rational::ONE.checked_log_base_power_of_2(pow), Some(0));\n    });\n\n    natural_unsigned_pair_gen_var_8().test_properties(|(n, pow)| {\n        assert_eq!(\n            n.checked_log_base_power_of_2(pow).map(i64::exact_from),\n            Rational::from(n).checked_log_base_power_of_2(i64::exact_from(pow))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/mod_op.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingMod, CeilingModAssign, Mod, ModAssign, NegMod,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_nz::test_util::generators::{integer_pair_gen_var_1, natural_pair_gen_var_5};\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::mod_op::{ceiling_mod_naive, mod_op_naive, rem_naive};\nuse malachite_q::test_util::generators::{rational_gen_var_1, rational_pair_gen_var_1};\nuse num::BigRational;\nuse std::str::FromStr;\n\n#[test]\nfn test_mod() {\n    let test = |s, t, remainder| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.mod_assign(v.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x.mod_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone().mod_op(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone().mod_op(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).mod_op(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).mod_op(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = mod_op_naive(u, v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"123\");\n    test(\"456\", \"123\", \"87\");\n    test(\"4/3\", \"1\", \"1/3\");\n    test(\"22/7\", \"1/2\", \"1/7\");\n    test(\"10\", \"22/7\", \"4/7\");\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"0\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"-333\");\n    test(\"456\", \"-123\", \"-36\");\n    test(\"4/3\", \"-1\", \"-2/3\");\n    test(\"22/7\", \"-1/2\", \"-5/14\");\n    test(\"10\", \"-22/7\", \"-18/7\");\n    test(\"-1\", \"1\", \"0\");\n    test(\"-123\", \"1\", \"0\");\n    test(\"-123\", \"123\", \"0\");\n    test(\"-123\", \"456\", \"333\");\n    test(\"-456\", \"123\", \"36\");\n    test(\"-4/3\", \"1\", \"2/3\");\n    test(\"-22/7\", \"1/2\", \"5/14\");\n    test(\"-10\", \"22/7\", \"18/7\");\n    test(\"-1\", \"-1\", \"0\");\n    test(\"-123\", \"-1\", \"0\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"-123\", \"-456\", \"-123\");\n    test(\"-456\", \"-123\", \"-87\");\n    test(\"-4/3\", \"-1\", \"-1/3\");\n    test(\"-22/7\", \"-1/2\", \"-1/7\");\n    test(\"-10\", \"-22/7\", \"-4/7\");\n}\n\n#[test]\n#[should_panic]\nfn mod_assign_fail() {\n    Rational::from(10).mod_assign(Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_assign_ref_fail() {\n    Rational::from(10).mod_assign(&Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_fail() {\n    Rational::from(10).mod_op(Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_val_ref_fail() {\n    Rational::from(10).mod_op(&Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_ref_val_fail() {\n    (&Rational::from(10)).mod_op(Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn mod_ref_ref_fail() {\n    (&Rational::from(10)).mod_op(&Rational::ZERO);\n}\n\n#[test]\nfn test_rem() {\n    let test = |s, t, remainder| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x %= v.clone();\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x %= &v;\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone() % v.clone();\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone() % &v;\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = &u % v.clone();\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = &u % &v;\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = rem_naive(u, v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = BigRational::from_str(s).unwrap() % &BigRational::from_str(t).unwrap();\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"123\");\n    test(\"456\", \"123\", \"87\");\n    test(\"4/3\", \"1\", \"1/3\");\n    test(\"22/7\", \"1/2\", \"1/7\");\n    test(\"10\", \"22/7\", \"4/7\");\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"0\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"123\");\n    test(\"456\", \"-123\", \"87\");\n    test(\"4/3\", \"-1\", \"1/3\");\n    test(\"22/7\", \"-1/2\", \"1/7\");\n    test(\"10\", \"-22/7\", \"4/7\");\n    test(\"-1\", \"1\", \"0\");\n    test(\"-123\", \"1\", \"0\");\n    test(\"-123\", \"123\", \"0\");\n    test(\"-123\", \"456\", \"-123\");\n    test(\"-456\", \"123\", \"-87\");\n    test(\"-4/3\", \"1\", \"-1/3\");\n    test(\"-22/7\", \"1/2\", \"-1/7\");\n    test(\"-10\", \"22/7\", \"-4/7\");\n    test(\"-1\", \"-1\", \"0\");\n    test(\"-123\", \"-1\", \"0\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"-123\", \"-456\", \"-123\");\n    test(\"-456\", \"-123\", \"-87\");\n    test(\"-4/3\", \"-1\", \"-1/3\");\n    test(\"-22/7\", \"-1/2\", \"-1/7\");\n    test(\"-10\", \"-22/7\", \"-4/7\");\n}\n\n#[test]\n#[should_panic]\nfn rem_assign_fail() {\n    let mut x = Rational::from(10);\n    x %= Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\nfn rem_assign_ref_fail() {\n    let mut x = Rational::from(10);\n    x %= &Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_fail() {\n    Rational::from(10) % Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_val_ref_fail() {\n    Rational::from(10) % &Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_ref_val_fail() {\n    &Rational::from(10) % Rational::ZERO;\n}\n\n#[test]\n#[should_panic]\n#[allow(unused_must_use, clippy::unnecessary_operation)]\nfn rem_ref_ref_fail() {\n    &Rational::from(10) % &Rational::ZERO;\n}\n\n#[test]\nfn test_ceiling_mod() {\n    let test = |s, t, remainder| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut x = u.clone();\n        x.ceiling_mod_assign(v.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let mut x = u.clone();\n        x.ceiling_mod_assign(&v);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), remainder);\n\n        let r = u.clone().ceiling_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = u.clone().ceiling_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).ceiling_mod(v.clone());\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = (&u).ceiling_mod(&v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n\n        let r = ceiling_mod_naive(u, v);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), remainder);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"1\", \"1\", \"0\");\n    test(\"123\", \"1\", \"0\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"-333\");\n    test(\"456\", \"123\", \"-36\");\n    test(\"4/3\", \"1\", \"-2/3\");\n    test(\"22/7\", \"1/2\", \"-5/14\");\n    test(\"10\", \"22/7\", \"-18/7\");\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"1\", \"-1\", \"0\");\n    test(\"123\", \"-1\", \"0\");\n    test(\"123\", \"-123\", \"0\");\n    test(\"123\", \"-456\", \"123\");\n    test(\"456\", \"-123\", \"87\");\n    test(\"4/3\", \"-1\", \"1/3\");\n    test(\"22/7\", \"-1/2\", \"1/7\");\n    test(\"10\", \"-22/7\", \"4/7\");\n    test(\"-1\", \"1\", \"0\");\n    test(\"-123\", \"1\", \"0\");\n    test(\"-123\", \"123\", \"0\");\n    test(\"-123\", \"456\", \"-123\");\n    test(\"-456\", \"123\", \"-87\");\n    test(\"-4/3\", \"1\", \"-1/3\");\n    test(\"-22/7\", \"1/2\", \"-1/7\");\n    test(\"-10\", \"22/7\", \"-4/7\");\n    test(\"-1\", \"-1\", \"0\");\n    test(\"-123\", \"-1\", \"0\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"-123\", \"-456\", \"333\");\n    test(\"-456\", \"-123\", \"36\");\n    test(\"-4/3\", \"-1\", \"2/3\");\n    test(\"-22/7\", \"-1/2\", \"5/14\");\n    test(\"-10\", \"-22/7\", \"18/7\");\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_assign_fail() {\n    Rational::from(10).ceiling_mod_assign(Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_assign_ref_fail() {\n    Rational::from(10).ceiling_mod_assign(&Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_fail() {\n    Rational::from(10).ceiling_mod(Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_val_ref_fail() {\n    Rational::from(10).ceiling_mod(&Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_ref_val_fail() {\n    (&Rational::from(10)).ceiling_mod(Rational::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn ceiling_mod_ref_ref_fail() {\n    (&Rational::from(10)).ceiling_mod(&Rational::ZERO);\n}\n\nfn mod_properties_helper(x: Rational, y: Rational) {\n    let mut mut_x = x.clone();\n    mut_x.mod_assign(&y);\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x.mod_assign(y.clone());\n    let remainder_alt = mut_x;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).mod_op(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).mod_op(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().mod_op(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().mod_op(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = mod_op_naive(x.clone(), y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    assert!(remainder.lt_abs(&y));\n    assert!(remainder == 0 || (remainder > 0) == (y > 0));\n\n    assert_eq!((-&x).mod_op(&y), -(&x).ceiling_mod(&y));\n    assert_eq!((&x).mod_op(-&y), x.ceiling_mod(y));\n}\n\n#[test]\nfn mod_properties() {\n    rational_pair_gen_var_1().test_properties(|(x, y)| mod_properties_helper(x, y));\n\n    rational_gen_var_1().test_properties(|ref x| {\n        assert_eq!(x.mod_op(x), 0);\n        assert_eq!(x.mod_op(-x), 0);\n        assert_eq!(Rational::ZERO.mod_op(x), 0);\n        if *x > 1 {\n            assert_eq!(Rational::ONE.mod_op(x), 1);\n            assert_eq!(Rational::NEGATIVE_ONE.mod_op(x), x - Rational::ONE);\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).mod_op(Rational::from(&y)), x.mod_op(y));\n    });\n\n    integer_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).mod_op(Rational::from(&y)), x.mod_op(y));\n    });\n}\n\nfn rem_properties_helper(x: Rational, y: Rational) {\n    let mut mut_x = x.clone();\n    mut_x %= &y;\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x %= y.clone();\n    assert!(mut_x.is_valid());\n    assert_eq!(mut_x, remainder);\n\n    let remainder_alt = &x % &y;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = &x % y.clone();\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone() % &y;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone() % y.clone();\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = rem_naive(x.clone(), y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let num_remainder = BigRational::from(&x) % &BigRational::from(&y);\n    assert_eq!(Rational::from(&num_remainder), remainder);\n\n    assert!(remainder.lt_abs(&y));\n    assert!(remainder == 0 || (remainder > 0) == (x > 0));\n\n    assert_eq!((-&x) % &y, -&remainder);\n    assert_eq!(x % (-y), remainder);\n}\n\n#[test]\nfn rem_properties() {\n    rational_pair_gen_var_1().test_properties(|(x, y)| rem_properties_helper(x, y));\n\n    rational_gen_var_1().test_properties(|ref x| {\n        assert_eq!(x % x, 0);\n        assert_eq!(x % -x, 0);\n        assert_eq!(Rational::ZERO % x, 0);\n        if *x > 1 {\n            assert_eq!(Rational::ONE % x, 1);\n            assert_eq!(Rational::NEGATIVE_ONE % x, -1);\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x) % Rational::from(&y), x % y);\n    });\n\n    integer_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x) % Rational::from(&y), x % y);\n    });\n}\n\nfn ceiling_mod_properties_helper(x: Rational, y: Rational) {\n    let mut mut_x = x.clone();\n    mut_x.ceiling_mod_assign(&y);\n    assert!(mut_x.is_valid());\n    let remainder = mut_x;\n\n    let mut mut_x = x.clone();\n    mut_x.ceiling_mod_assign(y.clone());\n    let remainder_alt = mut_x;\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).ceiling_mod(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = (&x).ceiling_mod(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().ceiling_mod(&y);\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = x.clone().ceiling_mod(y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    let remainder_alt = ceiling_mod_naive(x.clone(), y.clone());\n    assert!(remainder_alt.is_valid());\n    assert_eq!(remainder_alt, remainder);\n\n    assert!(remainder.lt_abs(&y));\n    assert!(remainder == 0 || (remainder >= 0) != (y > 0));\n\n    assert_eq!((-&x).ceiling_mod(&y), -(&x).mod_op(&y));\n    assert_eq!((&x).ceiling_mod(-&y), x.mod_op(y));\n}\n\n#[test]\nfn ceiling_mod_properties() {\n    rational_pair_gen_var_1().test_properties(|(x, y)| ceiling_mod_properties_helper(x, y));\n\n    rational_gen_var_1().test_properties(|ref x| {\n        assert_eq!(x.ceiling_mod(x), 0);\n        assert_eq!(x.ceiling_mod(-x), 0);\n        assert_eq!(Rational::ZERO.ceiling_mod(x), 0);\n    });\n\n    natural_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::from(&x).ceiling_mod(Rational::from(&y)),\n            -x.neg_mod(y)\n        );\n    });\n\n    integer_pair_gen_var_1().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::from(&x).ceiling_mod(Rational::from(&y)),\n            x.ceiling_mod(y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/mul.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Reciprocal, Square};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_nz::test_util::generators::integer_vec_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::mul::mul_naive;\nuse malachite_q::test_util::arithmetic::mul::rational_product_naive;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_pair_gen, rational_triple_gen, rational_vec_gen,\n};\nuse num::BigRational;\nuse std::iter::{Product, once};\nuse std::str::FromStr;\n\n#[test]\nfn test_mul() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n *= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n *= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() * v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u * v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() * &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u * &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigRational::from_str(s).unwrap() * BigRational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() * rug::Rational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"123\", \"0\");\n    test(\"0\", \"-123\", \"0\");\n    test(\"123\", \"0\", \"0\");\n    test(\"-123\", \"0\", \"0\");\n    test(\"1\", \"123\", \"123\");\n    test(\"1\", \"-123\", \"-123\");\n    test(\"-1\", \"123\", \"-123\");\n    test(\"-1\", \"-123\", \"123\");\n    test(\"123\", \"1\", \"123\");\n    test(\"123\", \"-1\", \"-123\");\n    test(\"-123\", \"1\", \"-123\");\n    test(\"-123\", \"-1\", \"123\");\n    test(\"123\", \"456\", \"56088\");\n    test(\"123\", \"-456\", \"-56088\");\n    test(\"-123\", \"456\", \"-56088\");\n    test(\"-123\", \"-456\", \"56088\");\n    test(\"22/7\", \"3/2\", \"33/7\");\n    test(\"22/7\", \"-3/2\", \"-33/7\");\n    test(\"-22/7\", \"3/2\", \"-33/7\");\n    test(\"-22/7\", \"-3/2\", \"33/7\");\n    test(\"4/5\", \"5/4\", \"1\");\n    test(\"4/5\", \"-5/4\", \"-1\");\n    test(\"-4/5\", \"5/4\", \"-1\");\n    test(\"-4/5\", \"-5/4\", \"1\");\n}\n\n#[test]\nfn test_product() {\n    let test = |xs, out| {\n        let xs = vec_from_str(xs).unwrap();\n        let product = Rational::product(xs.iter().cloned());\n        assert!(product.is_valid());\n        assert_eq!(product.to_string(), out);\n\n        let product_alt = Rational::product(xs.iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n\n        let product_alt = rational_product_naive(xs.into_iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n    };\n    test(\"[]\", \"1\");\n    test(\"[22/7]\", \"22/7\");\n    test(\"[22/7, 1/3]\", \"22/21\");\n    test(\"[0, 1, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10]\", \"0\");\n    test(\"[1, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10]\", \"1/5\");\n    test(\n        \"[123456/78901, 34567/890123, 45678/90123]\",\n        \"217314411648/7056278729357\",\n    );\n}\n\n#[test]\nfn mul_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let product_val_val = x.clone() * y.clone();\n        let product_val_ref = x.clone() * &y;\n        let product_ref_val = &x * y.clone();\n        let product = &x * &y;\n        assert!(product_val_val.is_valid());\n        assert!(product_val_ref.is_valid());\n        assert!(product_ref_val.is_valid());\n        assert!(product.is_valid());\n        assert_eq!(product_val_val, product);\n        assert_eq!(product_val_ref, product);\n        assert_eq!(product_ref_val, product);\n\n        let mut mut_x = x.clone();\n        mut_x *= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, product);\n        let mut mut_x = x.clone();\n        mut_x *= &y;\n        assert_eq!(mut_x, product);\n        assert!(mut_x.is_valid());\n\n        let mut mut_x = rug::Rational::from(&x);\n        mut_x *= rug::Rational::from(&y);\n        assert_eq!(Rational::from(&mut_x), product);\n\n        assert_eq!(\n            Rational::from(&(BigRational::from(&x) * BigRational::from(&y))),\n            product\n        );\n        assert_eq!(\n            Rational::from(&(rug::Rational::from(&x) * rug::Rational::from(&y))),\n            product\n        );\n        assert_eq!(mul_naive(x.clone(), y.clone()), product);\n        assert_eq!(&y * &x, product);\n        if x != 0u32 {\n            assert_eq!(&product / &x, y);\n        }\n        if y != 0u32 {\n            assert_eq!(&product / &y, x);\n            assert_eq!(&x / (&y).reciprocal(), product);\n        }\n        if product != 0u32 {\n            assert_eq!(\n                (&x).reciprocal() * (&y).reciprocal(),\n                (&product).reciprocal()\n            );\n        }\n        assert_eq!(-&x * &y, -&product);\n        assert_eq!(x * -y, -product);\n    });\n\n    rational_gen().test_properties(|ref x| {\n        assert_eq!(x * Rational::ZERO, 0);\n        assert_eq!(Rational::ZERO * x, 0);\n        assert_eq!(x * Rational::ONE, *x);\n        assert_eq!(Rational::ONE * x, *x);\n        assert_eq!(x * Rational::NEGATIVE_ONE, -x);\n        assert_eq!(Rational::NEGATIVE_ONE * x, -x);\n        assert_eq!(x * x, x.square());\n    });\n\n    rational_triple_gen().test_properties(|(ref x, ref y, ref z)| {\n        assert_eq!((x * y) * z, x * (y * z));\n        assert_eq!(x * (y + z), x * y + x * z);\n        assert_eq!((x + y) * z, x * z + y * z);\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(&x * &y, Rational::from(x) * Rational::from(y));\n    });\n}\n\n#[test]\nfn product_properties() {\n    rational_vec_gen().test_properties(|xs| {\n        let product = Rational::product(xs.iter().cloned());\n        assert!(product.is_valid());\n\n        let product_alt = Rational::product(xs.iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n\n        let product_alt = rational_product_naive(xs.into_iter());\n        assert!(product_alt.is_valid());\n        assert_eq!(product_alt, product);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!(Rational::product(once(&x)), x);\n        assert_eq!(Rational::product(once(x.clone())), x);\n    });\n\n    rational_pair_gen().test_properties(|(x, y)| {\n        let product = &x * &y;\n        assert_eq!(Rational::product([&x, &y].into_iter()), product);\n        assert_eq!(Rational::product([x, y].into_iter()), product);\n    });\n\n    integer_vec_gen().test_properties(|xs| {\n        assert_eq!(\n            Rational::product(xs.iter().map(Rational::from)),\n            Rational::from(Integer::product(xs.into_iter()))\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/neg.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::NegAssign;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse num::BigRational;\nuse std::str::FromStr;\n\n#[test]\nfn test_neg() {\n    let test = |s, out| {\n        let x = Rational::from_str(s).unwrap();\n\n        let neg = -x.clone();\n        assert!(neg.is_valid());\n        assert_eq!(neg.to_string(), out);\n\n        let neg = -&x;\n        assert!(neg.is_valid());\n        assert_eq!(neg.to_string(), out);\n\n        assert_eq!((-BigRational::from_str(s).unwrap()).to_string(), out);\n        assert_eq!((-rug::Rational::from_str(s).unwrap()).to_string(), out);\n\n        let mut x = x;\n        x.neg_assign();\n        assert!(neg.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"-123\");\n    test(\"-123\", \"123\");\n    test(\"1000000000000\", \"-1000000000000\");\n    test(\"-1000000000000\", \"1000000000000\");\n    test(\"3000000000\", \"-3000000000\");\n    test(\"-3000000000\", \"3000000000\");\n}\n\n#[test]\nfn abs_properties() {\n    rational_gen().test_properties(|x| {\n        let neg = -x.clone();\n        assert!(neg.is_valid());\n\n        assert_eq!(Rational::from(&-BigRational::from(&x)), neg);\n\n        assert_eq!(Rational::from(&-rug::Rational::from(&x)), neg);\n\n        let neg_alt = -&x;\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        let mut neg_alt = x.clone();\n        neg_alt.neg_assign();\n        assert!(neg_alt.is_valid());\n        assert_eq!(neg_alt, neg);\n\n        assert_eq!(neg == x, x == 0);\n        assert_eq!(-&neg, x);\n        assert_eq!(x + neg, 0);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(-Rational::from(&x), Rational::from(-x));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/next_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CeilingLogBase2, IsPowerOf2, NextPowerOf2, NextPowerOf2Assign, PowerOf2,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::test_util::generators::natural_gen_var_2;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen_var_2;\nuse std::str::FromStr;\n\n#[test]\nfn test_next_power_of_2() {\n    let test = |u, out| {\n        let mut n = Rational::from_str(u).unwrap();\n        n.next_power_of_2_assign();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Rational::from_str(u).unwrap().next_power_of_2();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = (&Rational::from_str(u).unwrap()).next_power_of_2();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"1\", \"1\");\n    test(\"2\", \"2\");\n    test(\"3\", \"4\");\n    test(\"4\", \"4\");\n    test(\"5\", \"8\");\n    test(\"6\", \"8\");\n    test(\"7\", \"8\");\n    test(\"8\", \"8\");\n    test(\"9\", \"16\");\n    test(\"10\", \"16\");\n    test(\"123\", \"128\");\n    test(\"1000\", \"1024\");\n    test(\"1000000\", \"1048576\");\n    test(\"1000000000\", \"1073741824\");\n    test(\"1000000000000\", \"1099511627776\");\n    test(\"2/3\", \"1\");\n    test(\"22/7\", \"4\");\n    test(\"1/10\", \"1/8\");\n    test(\"1/100\", \"1/64\");\n    test(\"1/1000000\", \"1/524288\");\n}\n\n#[test]\n#[should_panic]\nfn next_power_of_2_fail() {\n    Rational::ZERO.next_power_of_2();\n}\n\n#[test]\n#[should_panic]\nfn next_power_of_2_ref_fail() {\n    (&Rational::ZERO).next_power_of_2();\n}\n\n#[test]\n#[should_panic]\nfn next_power_of_2_assign_fail() {\n    let mut x = Rational::ZERO;\n    x.next_power_of_2_assign();\n}\n\n#[test]\nfn next_power_of_2_properties() {\n    rational_gen_var_2().test_properties(|x| {\n        let mut mut_x = x.clone();\n        mut_x.next_power_of_2_assign();\n        assert!(mut_x.is_valid());\n        let result = mut_x;\n\n        let result_alt = (&x).next_power_of_2();\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        let result_alt = x.clone().next_power_of_2();\n        assert!(result_alt.is_valid());\n        assert_eq!(result_alt, result);\n\n        assert!(result.is_power_of_2());\n        assert!(result >= x);\n        assert!(&result >> 1 < x);\n        assert_eq!(Rational::power_of_2(x.ceiling_log_base_2()), result);\n    });\n\n    natural_gen_var_2().test_properties(|x| {\n        assert_eq!((&x).next_power_of_2(), Rational::from(x).next_power_of_2());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/pow.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedRoot, Parity, Pow, PowAssign, PowerOf2, Reciprocal, Square,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Two, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_gen_var_5, unsigned_gen_var_5};\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_2;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_1, rational_rational_signed_triple_gen_var_1,\n    rational_rational_unsigned_triple_gen_var_1, rational_signed_pair_gen_var_2,\n    rational_signed_signed_triple_gen_var_1, rational_unsigned_pair_gen_var_1,\n    rational_unsigned_unsigned_triple_gen_var_1,\n};\nuse num::BigRational;\nuse num::traits::Pow as NumPow;\nuse rug::ops::Pow as RugPow;\nuse std::str::FromStr;\n\n#[test]\nfn test_pow() {\n    let test = |s, exp: u64, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let mut x = u.clone();\n        x.pow_assign(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = u.clone().pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = (&u).pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = BigRational::from_str(s).unwrap().pow(exp);\n        assert_eq!(x.to_string(), out);\n\n        let x = rug::Rational::from_str(s)\n            .unwrap()\n            .pow(u32::exact_from(exp));\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", 0, \"1\");\n    test(\"1\", 0, \"1\");\n    test(\"2\", 0, \"1\");\n    test(\"1000\", 0, \"1\");\n    test(\"1000000000000\", 0, \"1\");\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"1000\", 1, \"1000\");\n    test(\"1000000000000\", 1, \"1000000000000\");\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"4\");\n    test(\"3\", 2, \"9\");\n    test(\"1000\", 2, \"1000000\");\n    test(\"1000000000000\", 2, \"1000000000000000000000000\");\n    test(\"1/2\", 0, \"1\");\n    test(\"1/2\", 1, \"1/2\");\n    test(\"1/2\", 2, \"1/4\");\n    test(\"1/2\", 3, \"1/8\");\n    test(\"22/7\", 0, \"1\");\n    test(\"22/7\", 1, \"22/7\");\n    test(\"22/7\", 2, \"484/49\");\n    test(\"22/7\", 3, \"10648/343\");\n\n    test(\"-1\", 0, \"1\");\n    test(\"-2\", 0, \"1\");\n    test(\"-1000\", 0, \"1\");\n    test(\"-1000000000000\", 0, \"1\");\n    test(\"-1\", 1, \"-1\");\n    test(\"-2\", 1, \"-2\");\n    test(\"-1000\", 1, \"-1000\");\n    test(\"-1000000000000\", 1, \"-1000000000000\");\n    test(\"-1\", 2, \"1\");\n    test(\"-2\", 2, \"4\");\n    test(\"-3\", 2, \"9\");\n    test(\"-1000\", 2, \"1000000\");\n    test(\"-1000000000000\", 2, \"1000000000000000000000000\");\n    test(\"-1/2\", 0, \"1\");\n    test(\"-1/2\", 1, \"-1/2\");\n    test(\"-1/2\", 2, \"1/4\");\n    test(\"-1/2\", 3, \"-1/8\");\n    test(\"-22/7\", 0, \"1\");\n    test(\"-22/7\", 1, \"-22/7\");\n    test(\"-22/7\", 2, \"484/49\");\n    test(\"-22/7\", 3, \"-10648/343\");\n\n    let test = |s, exp: i64, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let mut x = u.clone();\n        x.pow_assign(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = u.clone().pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = (&u).pow(exp);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n\n        let x = BigRational::from_str(s).unwrap().pow(exp);\n        assert_eq!(x.to_string(), out);\n\n        let x = rug::Rational::from_str(s)\n            .unwrap()\n            .pow(i32::exact_from(exp));\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", 0, \"1\");\n    test(\"1\", 0, \"1\");\n    test(\"2\", 0, \"1\");\n    test(\"1000\", 0, \"1\");\n    test(\"1000000000000\", 0, \"1\");\n    test(\"0\", 1, \"0\");\n    test(\"1\", 1, \"1\");\n    test(\"2\", 1, \"2\");\n    test(\"1000\", 1, \"1000\");\n    test(\"1000000000000\", 1, \"1000000000000\");\n    test(\"0\", 2, \"0\");\n    test(\"1\", 2, \"1\");\n    test(\"2\", 2, \"4\");\n    test(\"3\", 2, \"9\");\n    test(\"1000\", 2, \"1000000\");\n    test(\"1000000000000\", 2, \"1000000000000000000000000\");\n    test(\"1/2\", 0, \"1\");\n    test(\"1/2\", 1, \"1/2\");\n    test(\"1/2\", 2, \"1/4\");\n    test(\"1/2\", 3, \"1/8\");\n    test(\"22/7\", 0, \"1\");\n    test(\"22/7\", 1, \"22/7\");\n    test(\"22/7\", 2, \"484/49\");\n    test(\"22/7\", 3, \"10648/343\");\n\n    test(\"1\", -1, \"1\");\n    test(\"2\", -1, \"1/2\");\n    test(\"1000\", -1, \"1/1000\");\n    test(\"1000000000000\", -1, \"1/1000000000000\");\n    test(\"1\", -2, \"1\");\n    test(\"2\", -2, \"1/4\");\n    test(\"3\", -2, \"1/9\");\n    test(\"1000\", -2, \"1/1000000\");\n    test(\"1000000000000\", -2, \"1/1000000000000000000000000\");\n    test(\"1/2\", -1, \"2\");\n    test(\"1/2\", -2, \"4\");\n    test(\"1/2\", -3, \"8\");\n    test(\"22/7\", -1, \"7/22\");\n    test(\"22/7\", -2, \"49/484\");\n    test(\"22/7\", -3, \"343/10648\");\n\n    test(\"-1\", 0, \"1\");\n    test(\"-2\", 0, \"1\");\n    test(\"-1000\", 0, \"1\");\n    test(\"-1000000000000\", 0, \"1\");\n    test(\"-1\", 1, \"-1\");\n    test(\"-2\", 1, \"-2\");\n    test(\"-1000\", 1, \"-1000\");\n    test(\"-1000000000000\", 1, \"-1000000000000\");\n    test(\"-1\", 2, \"1\");\n    test(\"-2\", 2, \"4\");\n    test(\"-3\", 2, \"9\");\n    test(\"-1000\", 2, \"1000000\");\n    test(\"-1000000000000\", 2, \"1000000000000000000000000\");\n    test(\"-1/2\", 0, \"1\");\n    test(\"-1/2\", 1, \"-1/2\");\n    test(\"-1/2\", 2, \"1/4\");\n    test(\"-1/2\", 3, \"-1/8\");\n    test(\"-22/7\", 0, \"1\");\n    test(\"-22/7\", 1, \"-22/7\");\n    test(\"-22/7\", 2, \"484/49\");\n    test(\"-22/7\", 3, \"-10648/343\");\n\n    test(\"-1\", -1, \"-1\");\n    test(\"-2\", -1, \"-1/2\");\n    test(\"-1000\", -1, \"-1/1000\");\n    test(\"-1000000000000\", -1, \"-1/1000000000000\");\n    test(\"-1\", -2, \"1\");\n    test(\"-2\", -2, \"1/4\");\n    test(\"-3\", -2, \"1/9\");\n    test(\"-1000\", -2, \"1/1000000\");\n    test(\"-1000000000000\", -2, \"1/1000000000000000000000000\");\n    test(\"-1/2\", -1, \"-2\");\n    test(\"-1/2\", -2, \"4\");\n    test(\"-1/2\", -3, \"-8\");\n    test(\"-22/7\", -1, \"-7/22\");\n    test(\"-22/7\", -2, \"49/484\");\n    test(\"-22/7\", -3, \"-343/10648\");\n}\n\n#[test]\nfn pow_properties() {\n    // exponent is u64\n\n    rational_unsigned_pair_gen_var_1::<u64>().test_properties(|(x, exp)| {\n        let power = (&x).pow(exp);\n        assert!(power.is_valid());\n\n        let power_alt = x.clone().pow(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        let mut power_alt = x.clone();\n        power_alt.pow_assign(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        let power_of_neg = (-&x).pow(exp);\n        if exp.even() {\n            assert_eq!(power_of_neg, power);\n        } else {\n            assert_eq!(power_of_neg, -&power);\n        }\n        if exp > 0 && (x >= 0 || exp.odd()) {\n            assert_eq!((&power).checked_root(exp).as_ref(), Some(&x));\n        }\n\n        assert_eq!((&x).pow(i64::exact_from(exp)), power);\n\n        assert_eq!(Rational::from(&BigRational::from(&x).pow(exp)), power);\n        assert_eq!(\n            Rational::from(&rug::Rational::from(&x).pow(u32::exact_from(exp))),\n            power\n        );\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!((&x).pow(0u64), 1);\n        assert_eq!((&x).pow(1u64), x);\n        assert_eq!((&x).pow(2u64), x.square());\n    });\n\n    unsigned_gen_var_5::<u64>().test_properties(|exp| {\n        assert_eq!(Rational::ZERO.pow(exp), u64::from(exp == 0));\n        assert_eq!(Rational::ONE.pow(exp), 1);\n        assert_eq!(Rational::TWO.pow(exp), Rational::power_of_2(exp));\n\n        assert_eq!(\n            Rational::NEGATIVE_ONE.pow(exp),\n            if exp.even() { 1 } else { -1 }\n        );\n    });\n\n    rational_rational_unsigned_triple_gen_var_1::<u64>().test_properties(|(x, y, exp)| {\n        assert_eq!((&x * &y).pow(exp), x.pow(exp) * y.pow(exp));\n    });\n\n    rational_unsigned_unsigned_triple_gen_var_1::<u64>().test_properties(|(x, e, f)| {\n        assert_eq!((&x).pow(e + f), (&x).pow(e) * (&x).pow(f));\n        assert_eq!((&x).pow(e * f), x.pow(e).pow(f));\n    });\n\n    integer_unsigned_pair_gen_var_2().test_properties(|(x, exp)| {\n        assert_eq!((&x).pow(exp), Rational::from(x).pow(exp));\n    });\n\n    // exponent is i64\n\n    rational_signed_pair_gen_var_2::<i64>().test_properties(|(x, exp)| {\n        let power = (&x).pow(exp);\n        assert!(power.is_valid());\n\n        let power_alt = x.clone().pow(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        let mut power_alt = x.clone();\n        power_alt.pow_assign(exp);\n        assert!(power_alt.is_valid());\n        assert_eq!(power_alt, power);\n\n        let power_of_neg = (-&x).pow(exp);\n        if exp.even() {\n            assert_eq!(power_of_neg, power);\n        } else {\n            assert_eq!(power_of_neg, -&power);\n        }\n\n        if x != 0 {\n            assert_eq!((&x).pow(-exp), (&power).reciprocal());\n        }\n\n        if exp > 0 && (x >= 0 || exp.odd()) {\n            assert_eq!((&power).checked_root(exp).as_ref(), Some(&x));\n        }\n\n        assert_eq!(Rational::from(&BigRational::from(&x).pow(exp)), power);\n        assert_eq!(\n            Rational::from(&rug::Rational::from(&x).pow(i32::exact_from(exp))),\n            power\n        );\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!((&x).pow(0i64), 1);\n        assert_eq!((&x).pow(1i64), x);\n        assert_eq!((&x).pow(2i64), x.square());\n    });\n\n    rational_gen_var_1().test_properties(|x| {\n        assert_eq!((&x).pow(-1i64), x.reciprocal());\n    });\n\n    signed_gen_var_5::<i64>().test_properties(|exp| {\n        if exp >= 0 {\n            assert_eq!(Rational::ZERO.pow(exp), u64::from(exp == 0));\n        }\n        assert_eq!(Rational::ONE.pow(exp), 1);\n        assert_eq!(Rational::TWO.pow(exp), Rational::power_of_2(exp));\n\n        assert_eq!(\n            Rational::NEGATIVE_ONE.pow(exp),\n            if exp.even() { 1 } else { -1 }\n        );\n    });\n\n    rational_rational_signed_triple_gen_var_1::<i64>().test_properties(|(x, y, exp)| {\n        assert_eq!((&x * &y).pow(exp), x.pow(exp) * y.pow(exp));\n    });\n\n    rational_signed_signed_triple_gen_var_1::<i64>().test_properties(|(x, e, f)| {\n        assert_eq!((&x).pow(e + f), (&x).pow(e) * (&x).pow(f));\n        assert_eq!((&x).pow(e * f), x.pow(e).pow(f));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    CheckedLogBase2, NextPowerOf2, Pow, PowerOf2, Reciprocal,\n};\nuse malachite_base::num::basic::traits::{One, Two};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_gen_var_5, unsigned_gen_var_5};\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\n\n#[test]\nfn test_power_of_2() {\n    let test = |pow: u64, out| assert_eq!(Rational::power_of_2(pow).to_string(), out);\n    test(0, \"1\");\n    test(1, \"2\");\n    test(2, \"4\");\n    test(3, \"8\");\n    test(32, \"4294967296\");\n    test(100, \"1267650600228229401496703205376\");\n\n    let test = |pow: i64, out| assert_eq!(Rational::power_of_2(pow).to_string(), out);\n    test(0, \"1\");\n    test(1, \"2\");\n    test(2, \"4\");\n    test(3, \"8\");\n    test(32, \"4294967296\");\n    test(100, \"1267650600228229401496703205376\");\n    test(-1, \"1/2\");\n    test(-2, \"1/4\");\n    test(-3, \"1/8\");\n    test(-32, \"1/4294967296\");\n    test(-100, \"1/1267650600228229401496703205376\");\n}\n\n#[test]\nfn power_of_2_properties() {\n    unsigned_gen_var_5().test_properties(|pow| {\n        let x = Rational::power_of_2(pow);\n        assert!(x.is_valid());\n\n        assert_eq!(x, Rational::ONE << pow);\n        assert_eq!(x, Rational::TWO.pow(pow));\n        assert_eq!(x.checked_log_base_2(), Some(i64::exact_from(pow)));\n        assert_eq!((&x).next_power_of_2(), x);\n        assert_eq!(Natural::power_of_2(pow), x);\n    });\n\n    signed_gen_var_5::<i64>().test_properties(|pow| {\n        let x = Rational::power_of_2(pow);\n        assert!(x.is_valid());\n\n        assert_eq!(x, Rational::ONE << pow);\n        assert_eq!(x, Rational::TWO.pow(pow));\n        assert_eq!(x.checked_log_base_2(), Some(pow));\n        assert_eq!((&x).next_power_of_2(), x);\n        if pow >= 0 {\n            assert_eq!(Natural::power_of_2(pow.unsigned_abs()), x);\n        } else {\n            assert_eq!(Natural::power_of_2(pow.unsigned_abs()), x.reciprocal());\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/reciprocal.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, Reciprocal, ReciprocalAssign};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen_var_1;\nuse num::BigRational;\nuse std::str::FromStr;\n\n#[test]\nfn test_reciprocal() {\n    let test = |s, out| {\n        let x = Rational::from_str(s).unwrap();\n\n        let reciprocal = x.clone().reciprocal();\n        assert!(reciprocal.is_valid());\n        assert_eq!(reciprocal.to_string(), out);\n\n        let reciprocal = (&x).reciprocal();\n        assert!(reciprocal.is_valid());\n        assert_eq!(reciprocal.to_string(), out);\n\n        assert_eq!(BigRational::from_str(s).unwrap().recip().to_string(), out);\n        assert_eq!(rug::Rational::from_str(s).unwrap().recip().to_string(), out);\n\n        let mut x = x;\n        x.reciprocal_assign();\n        assert!(reciprocal.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"1\", \"1\");\n    test(\"-1\", \"-1\");\n    test(\"123\", \"1/123\");\n    test(\"22/7\", \"7/22\");\n    test(\"-22/7\", \"-7/22\");\n}\n\n#[test]\n#[should_panic]\nfn reciprocal_fail() {\n    Rational::ZERO.reciprocal();\n}\n\n#[test]\n#[should_panic]\nfn reciprocal_ref_fail() {\n    (&Rational::ZERO).reciprocal();\n}\n\n#[test]\n#[should_panic]\nfn reciprocal_assign_fail() {\n    let mut q = Rational::ZERO;\n    q.reciprocal_assign();\n}\n\n#[test]\nfn reciprocal_properties() {\n    rational_gen_var_1().test_properties(|x| {\n        let reciprocal = x.clone().reciprocal();\n        assert!(reciprocal.is_valid());\n\n        assert_eq!(Rational::from(&BigRational::from(&x).recip()), reciprocal);\n\n        assert_eq!(Rational::from(&rug::Rational::from(&x).recip()), reciprocal);\n\n        let reciprocal_alt = (&x).reciprocal();\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(reciprocal_alt, reciprocal);\n\n        let mut reciprocal_alt = x.clone();\n        reciprocal_alt.reciprocal_assign();\n        assert!(reciprocal_alt.is_valid());\n        assert_eq!(reciprocal_alt, reciprocal);\n\n        assert_ne!(reciprocal, 0);\n        assert_eq!(reciprocal, -(-&x).reciprocal());\n        assert_eq!(reciprocal == x, (&x).abs() == 1);\n        assert_eq!((&reciprocal).reciprocal(), x);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/root.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedRoot, CheckedSqrt, Pow, Reciprocal};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_3;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_1, rational_gen_var_3, rational_signed_pair_gen_var_4,\n    rational_unsigned_pair_gen_var_4,\n};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\nfn test_helper<T: Copy>(s: &str, exp: T, out: Option<&str>)\nwhere\n    Rational: CheckedRoot<T, Output = Rational>,\n    for<'a> &'a Rational: CheckedRoot<T, Output = Rational>,\n{\n    let n = Rational::from_str(s).unwrap();\n    let out = out.map(ToString::to_string);\n\n    assert_eq!(n.clone().checked_root(exp).map(|x| x.to_string()), out);\n    assert_eq!((&n).checked_root(exp).map(|x| x.to_string()), out);\n}\n\n#[test]\nfn test_checked_root() {\n    let test = |s, exp, out: Option<&str>| {\n        test_helper::<u64>(s, exp, out);\n        test_helper::<i64>(s, i64::exact_from(exp), out);\n    };\n    test(\"0\", 1, Some(\"0\"));\n    test(\"1\", 1, Some(\"1\"));\n    test(\"2\", 1, Some(\"2\"));\n    test(\"22/7\", 1, Some(\"22/7\"));\n\n    test(\"0\", 2, Some(\"0\"));\n    test(\"1\", 2, Some(\"1\"));\n    test(\"2\", 2, None);\n    test(\"3\", 2, None);\n    test(\"4\", 2, Some(\"2\"));\n    test(\"5\", 2, None);\n    test(\"22/7\", 2, None);\n    test(\"4/9\", 2, Some(\"2/3\"));\n\n    test(\"-1\", 1, Some(\"-1\"));\n    test(\"-2\", 1, Some(\"-2\"));\n    test(\"-100\", 1, Some(\"-100\"));\n\n    test(\"-1\", 3, Some(\"-1\"));\n    test(\"-2\", 3, None);\n    test(\"-7\", 3, None);\n    test(\"-8\", 3, Some(\"-2\"));\n    test(\"-9\", 3, None);\n    test(\"-27/8\", 3, Some(\"-3/2\"));\n    test(\"27/8\", 3, Some(\"3/2\"));\n\n    let test_i = |s, exp: i64, out: Option<&str>| {\n        test_helper::<i64>(s, exp, out);\n    };\n    test_i(\"1\", -1, Some(\"1\"));\n    test_i(\"2\", -1, Some(\"1/2\"));\n    test_i(\"22/7\", -1, Some(\"7/22\"));\n\n    test_i(\"1\", -2, Some(\"1\"));\n    test_i(\"2\", -2, None);\n    test_i(\"3\", -2, None);\n    test_i(\"4\", -2, Some(\"1/2\"));\n    test_i(\"5\", -2, None);\n    test_i(\"22/7\", -2, None);\n    test_i(\"4/9\", -2, Some(\"3/2\"));\n\n    test_i(\"-1\", -1, Some(\"-1\"));\n    test_i(\"-2\", -1, Some(\"-1/2\"));\n    test_i(\"-100\", -1, Some(\"-1/100\"));\n\n    test_i(\"-1\", -3, Some(\"-1\"));\n    test_i(\"-2\", -3, None);\n    test_i(\"-7\", -3, None);\n    test_i(\"-8\", -3, Some(\"-1/2\"));\n    test_i(\"-9\", -3, None);\n    test_i(\"-27/8\", -3, Some(\"-2/3\"));\n    test_i(\"27/8\", -3, Some(\"2/3\"));\n}\n\n#[test]\nfn checked_root_fail() {\n    assert_panic!(Rational::ONE.checked_root(0u64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(0u64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(2u64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(4u64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(100u64));\n\n    assert_panic!(Rational::ZERO.checked_root(-2i64));\n    assert_panic!(Rational::ONE.checked_root(0i64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(0i64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(2i64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(4i64));\n    assert_panic!(Rational::NEGATIVE_ONE.checked_root(100i64));\n}\n\n#[test]\nfn checked_root_ref_fail() {\n    assert_panic!((&Rational::ONE).checked_root(0u64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(0u64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(2u64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(4u64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(100u64));\n\n    assert_panic!((&Rational::ZERO).checked_root(-2i64));\n    assert_panic!((&Rational::ONE).checked_root(0i64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(0i64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(2i64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(4i64));\n    assert_panic!((&Rational::NEGATIVE_ONE).checked_root(100i64));\n}\n\n#[test]\nfn checked_root_properties() {\n    rational_unsigned_pair_gen_var_4::<u64>().test_properties(|(n, exp)| {\n        let root = n.clone().checked_root(exp);\n        assert!(root.as_ref().is_none_or(Rational::is_valid));\n        let root_alt = (&n).checked_root(exp);\n        assert!(root_alt.as_ref().is_none_or(Rational::is_valid));\n        assert_eq!(root_alt, root);\n        assert_eq!((&n).checked_root(u64::exact_from(exp)), root);\n        if n != 0 {\n            assert_eq!(\n                (&n).reciprocal().checked_root(exp),\n                root.as_ref().map(Reciprocal::reciprocal)\n            );\n        }\n        if let Some(root) = root {\n            assert_eq!((&root).pow(exp), n);\n        }\n    });\n\n    rational_signed_pair_gen_var_4::<i64>().test_properties(|(n, exp)| {\n        let root = n.clone().checked_root(exp);\n        assert!(root.as_ref().is_none_or(Rational::is_valid));\n        let root_alt = (&n).checked_root(exp);\n        assert!(root_alt.as_ref().is_none_or(Rational::is_valid));\n        assert_eq!(root_alt, root);\n        assert_eq!((&n).checked_root(exp), root);\n        if n != 0u32 {\n            assert_eq!(\n                (&n).checked_root(-exp),\n                root.as_ref().map(Reciprocal::reciprocal)\n            );\n            assert_eq!(\n                (&n).reciprocal().checked_root(exp),\n                root.as_ref().map(Reciprocal::reciprocal)\n            );\n        }\n        if let Some(root) = root {\n            assert_eq!((&root).pow(exp), n);\n        }\n    });\n\n    rational_gen().test_properties(|n| {\n        assert_eq!((&n).checked_root(1u64).unwrap(), n);\n        assert_eq!((&n).checked_root(1i64).unwrap(), n);\n    });\n\n    rational_gen_var_3().test_properties(|n| {\n        assert_eq!((&n).checked_root(2u64), (&n).checked_sqrt());\n        assert_eq!((&n).checked_root(2i64), n.checked_sqrt());\n    });\n\n    rational_gen_var_1().test_properties(|n| {\n        assert_eq!((&n).checked_root(-1i64), Some(n.reciprocal()));\n    });\n\n    integer_unsigned_pair_gen_var_3().test_properties(|(n, exp)| {\n        assert_eq!(\n            (&n).checked_root(exp).map(Rational::from),\n            Rational::from(n).checked_root(exp)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/round_to_multiple.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, Parity, RoundToMultiple, RoundToMultipleAssign,\n};\nuse malachite_base::num::basic::traits::{NegativeOne, One, Zero};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, IsInteger};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{\n    integer_integer_rounding_mode_triple_gen_var_2, integer_rounding_mode_pair_gen,\n};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_pair_gen_var_1, rational_pair_gen_var_2,\n    rational_rational_rounding_mode_triple_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_round_to_multiple() {\n    let test = |s, t, rm, quotient, o| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        assert_eq!(n.round_to_multiple_assign(v.clone(), rm), o);\n        assert_eq!(n.to_string(), quotient);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        assert_eq!(n.round_to_multiple_assign(&v, rm), o);\n        assert_eq!(n.to_string(), quotient);\n        assert!(n.is_valid());\n\n        let (r, o_alt) = u.clone().round_to_multiple(v.clone(), rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = u.clone().round_to_multiple(&v, rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = (&u).round_to_multiple(v.clone(), rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n\n        let (r, o_alt) = (&u).round_to_multiple(&v, rm);\n        assert!(r.is_valid());\n        assert_eq!(r.to_string(), quotient);\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", \"1\", Down, \"0\", Equal);\n    test(\"0\", \"1\", Floor, \"0\", Equal);\n    test(\"0\", \"1\", Up, \"0\", Equal);\n    test(\"0\", \"1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"1\", Nearest, \"0\", Equal);\n    test(\"0\", \"1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"22/7\", Down, \"0\", Equal);\n    test(\"0\", \"22/7\", Floor, \"0\", Equal);\n    test(\"0\", \"22/7\", Up, \"0\", Equal);\n    test(\"0\", \"22/7\", Ceiling, \"0\", Equal);\n    test(\"0\", \"22/7\", Nearest, \"0\", Equal);\n    test(\"0\", \"22/7\", Exact, \"0\", Equal);\n\n    test(\"1/3\", \"1\", Down, \"0\", Less);\n    test(\"1/3\", \"1\", Floor, \"0\", Less);\n    test(\"1/3\", \"1\", Up, \"1\", Greater);\n    test(\"1/3\", \"1\", Ceiling, \"1\", Greater);\n    test(\"1/3\", \"1\", Nearest, \"0\", Less);\n\n    test(\"1/3\", \"1/3\", Down, \"1/3\", Equal);\n    test(\"1/3\", \"1/3\", Floor, \"1/3\", Equal);\n    test(\"1/3\", \"1/3\", Up, \"1/3\", Equal);\n    test(\"1/3\", \"1/3\", Ceiling, \"1/3\", Equal);\n    test(\"1/3\", \"1/3\", Nearest, \"1/3\", Equal);\n    test(\"1/3\", \"1/3\", Exact, \"1/3\", Equal);\n\n    test(\"1/3\", \"1/4\", Down, \"1/4\", Less);\n    test(\"1/3\", \"1/4\", Floor, \"1/4\", Less);\n    test(\"1/3\", \"1/4\", Up, \"1/2\", Greater);\n    test(\"1/3\", \"1/4\", Ceiling, \"1/2\", Greater);\n    test(\"1/3\", \"1/4\", Nearest, \"1/4\", Less);\n\n    test(\n        \"884279719003555/281474976710656\",\n        \"1/1000000\",\n        Down,\n        \"392699/125000\",\n        Less,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"1/1000000\",\n        Floor,\n        \"392699/125000\",\n        Less,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"1/1000000\",\n        Up,\n        \"3141593/1000000\",\n        Greater,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"1/1000000\",\n        Ceiling,\n        \"3141593/1000000\",\n        Greater,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"1/1000000\",\n        Nearest,\n        \"3141593/1000000\",\n        Greater,\n    );\n\n    test(\n        \"1000000\",\n        \"884279719003555/281474976710656\",\n        Down,\n        \"281474193076302588495/281474976710656\",\n        Less,\n    );\n    test(\n        \"1000000\",\n        \"884279719003555/281474976710656\",\n        Floor,\n        \"281474193076302588495/281474976710656\",\n        Less,\n    );\n    test(\n        \"1000000\",\n        \"884279719003555/281474976710656\",\n        Up,\n        \"140737538678010796025/140737488355328\",\n        Greater,\n    );\n    test(\n        \"1000000\",\n        \"884279719003555/281474976710656\",\n        Ceiling,\n        \"140737538678010796025/140737488355328\",\n        Greater,\n    );\n    test(\n        \"1000000\",\n        \"884279719003555/281474976710656\",\n        Nearest,\n        \"140737538678010796025/140737488355328\",\n        Greater,\n    );\n\n    test(\"-1/3\", \"1\", Down, \"0\", Greater);\n    test(\"-1/3\", \"1\", Floor, \"-1\", Less);\n    test(\"-1/3\", \"1\", Up, \"-1\", Less);\n    test(\"-1/3\", \"1\", Ceiling, \"0\", Greater);\n    test(\"-1/3\", \"1\", Nearest, \"0\", Greater);\n\n    test(\"-1/3\", \"1/3\", Down, \"-1/3\", Equal);\n    test(\"-1/3\", \"1/3\", Floor, \"-1/3\", Equal);\n    test(\"-1/3\", \"1/3\", Up, \"-1/3\", Equal);\n    test(\"-1/3\", \"1/3\", Ceiling, \"-1/3\", Equal);\n    test(\"-1/3\", \"1/3\", Nearest, \"-1/3\", Equal);\n    test(\"-1/3\", \"1/3\", Exact, \"-1/3\", Equal);\n\n    test(\"-1/3\", \"1/4\", Down, \"-1/4\", Greater);\n    test(\"-1/3\", \"1/4\", Floor, \"-1/2\", Less);\n    test(\"-1/3\", \"1/4\", Up, \"-1/2\", Less);\n    test(\"-1/3\", \"1/4\", Ceiling, \"-1/4\", Greater);\n    test(\"-1/3\", \"1/4\", Nearest, \"-1/4\", Greater);\n\n    test(\n        \"-884279719003555/281474976710656\",\n        \"1/1000000\",\n        Down,\n        \"-392699/125000\",\n        Greater,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"1/1000000\",\n        Floor,\n        \"-3141593/1000000\",\n        Less,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"1/1000000\",\n        Up,\n        \"-3141593/1000000\",\n        Less,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"1/1000000\",\n        Ceiling,\n        \"-392699/125000\",\n        Greater,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"1/1000000\",\n        Nearest,\n        \"-3141593/1000000\",\n        Less,\n    );\n\n    test(\n        \"-1000000\",\n        \"884279719003555/281474976710656\",\n        Down,\n        \"-281474193076302588495/281474976710656\",\n        Greater,\n    );\n    test(\n        \"-1000000\",\n        \"884279719003555/281474976710656\",\n        Floor,\n        \"-140737538678010796025/140737488355328\",\n        Less,\n    );\n    test(\n        \"-1000000\",\n        \"884279719003555/281474976710656\",\n        Up,\n        \"-140737538678010796025/140737488355328\",\n        Less,\n    );\n    test(\n        \"-1000000\",\n        \"884279719003555/281474976710656\",\n        Ceiling,\n        \"-281474193076302588495/281474976710656\",\n        Greater,\n    );\n    test(\n        \"-1000000\",\n        \"884279719003555/281474976710656\",\n        Nearest,\n        \"-140737538678010796025/140737488355328\",\n        Less,\n    );\n\n    test(\"0\", \"-1\", Down, \"0\", Equal);\n    test(\"0\", \"-1\", Floor, \"0\", Equal);\n    test(\"0\", \"-1\", Up, \"0\", Equal);\n    test(\"0\", \"-1\", Ceiling, \"0\", Equal);\n    test(\"0\", \"-1\", Nearest, \"0\", Equal);\n    test(\"0\", \"-1\", Exact, \"0\", Equal);\n\n    test(\"0\", \"-22/7\", Down, \"0\", Equal);\n    test(\"0\", \"-22/7\", Floor, \"0\", Equal);\n    test(\"0\", \"-22/7\", Up, \"0\", Equal);\n    test(\"0\", \"-22/7\", Ceiling, \"0\", Equal);\n    test(\"0\", \"-22/7\", Nearest, \"0\", Equal);\n    test(\"0\", \"-22/7\", Exact, \"0\", Equal);\n\n    test(\"1/3\", \"-1\", Down, \"0\", Less);\n    test(\"1/3\", \"-1\", Floor, \"0\", Less);\n    test(\"1/3\", \"-1\", Up, \"1\", Greater);\n    test(\"1/3\", \"-1\", Ceiling, \"1\", Greater);\n    test(\"1/3\", \"-1\", Nearest, \"0\", Less);\n\n    test(\"1/3\", \"-1/3\", Down, \"1/3\", Equal);\n    test(\"1/3\", \"-1/3\", Floor, \"1/3\", Equal);\n    test(\"1/3\", \"-1/3\", Up, \"1/3\", Equal);\n    test(\"1/3\", \"-1/3\", Ceiling, \"1/3\", Equal);\n    test(\"1/3\", \"-1/3\", Nearest, \"1/3\", Equal);\n    test(\"1/3\", \"-1/3\", Exact, \"1/3\", Equal);\n\n    test(\"1/3\", \"-1/4\", Down, \"1/4\", Less);\n    test(\"1/3\", \"-1/4\", Floor, \"1/4\", Less);\n    test(\"1/3\", \"-1/4\", Up, \"1/2\", Greater);\n    test(\"1/3\", \"-1/4\", Ceiling, \"1/2\", Greater);\n    test(\"1/3\", \"-1/4\", Nearest, \"1/4\", Less);\n\n    test(\n        \"884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Down,\n        \"392699/125000\",\n        Less,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Floor,\n        \"392699/125000\",\n        Less,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Up,\n        \"3141593/1000000\",\n        Greater,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Ceiling,\n        \"3141593/1000000\",\n        Greater,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Nearest,\n        \"3141593/1000000\",\n        Greater,\n    );\n\n    test(\n        \"1000000\",\n        \"-884279719003555/281474976710656\",\n        Down,\n        \"281474193076302588495/281474976710656\",\n        Less,\n    );\n    test(\n        \"1000000\",\n        \"-884279719003555/281474976710656\",\n        Floor,\n        \"281474193076302588495/281474976710656\",\n        Less,\n    );\n    test(\n        \"1000000\",\n        \"-884279719003555/281474976710656\",\n        Up,\n        \"140737538678010796025/140737488355328\",\n        Greater,\n    );\n    test(\n        \"1000000\",\n        \"-884279719003555/281474976710656\",\n        Ceiling,\n        \"140737538678010796025/140737488355328\",\n        Greater,\n    );\n    test(\n        \"1000000\",\n        \"-884279719003555/281474976710656\",\n        Nearest,\n        \"140737538678010796025/140737488355328\",\n        Greater,\n    );\n\n    test(\"-1/3\", \"-1\", Down, \"0\", Greater);\n    test(\"-1/3\", \"-1\", Floor, \"-1\", Less);\n    test(\"-1/3\", \"-1\", Up, \"-1\", Less);\n    test(\"-1/3\", \"-1\", Ceiling, \"0\", Greater);\n    test(\"-1/3\", \"-1\", Nearest, \"0\", Greater);\n\n    test(\"-1/3\", \"-1/3\", Down, \"-1/3\", Equal);\n    test(\"-1/3\", \"-1/3\", Floor, \"-1/3\", Equal);\n    test(\"-1/3\", \"-1/3\", Up, \"-1/3\", Equal);\n    test(\"-1/3\", \"-1/3\", Ceiling, \"-1/3\", Equal);\n    test(\"-1/3\", \"-1/3\", Nearest, \"-1/3\", Equal);\n    test(\"-1/3\", \"-1/3\", Exact, \"-1/3\", Equal);\n\n    test(\"-1/3\", \"-1/4\", Down, \"-1/4\", Greater);\n    test(\"-1/3\", \"-1/4\", Floor, \"-1/2\", Less);\n    test(\"-1/3\", \"-1/4\", Up, \"-1/2\", Less);\n    test(\"-1/3\", \"-1/4\", Ceiling, \"-1/4\", Greater);\n    test(\"-1/3\", \"-1/4\", Nearest, \"-1/4\", Greater);\n\n    test(\n        \"-884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Down,\n        \"-392699/125000\",\n        Greater,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Floor,\n        \"-3141593/1000000\",\n        Less,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Up,\n        \"-3141593/1000000\",\n        Less,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Ceiling,\n        \"-392699/125000\",\n        Greater,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        \"-1/1000000\",\n        Nearest,\n        \"-3141593/1000000\",\n        Less,\n    );\n\n    test(\n        \"-1000000\",\n        \"-884279719003555/281474976710656\",\n        Down,\n        \"-281474193076302588495/281474976710656\",\n        Greater,\n    );\n    test(\n        \"-1000000\",\n        \"-884279719003555/281474976710656\",\n        Floor,\n        \"-140737538678010796025/140737488355328\",\n        Less,\n    );\n    test(\n        \"-1000000\",\n        \"-884279719003555/281474976710656\",\n        Up,\n        \"-140737538678010796025/140737488355328\",\n        Less,\n    );\n    test(\n        \"-1000000\",\n        \"-884279719003555/281474976710656\",\n        Ceiling,\n        \"-281474193076302588495/281474976710656\",\n        Greater,\n    );\n    test(\n        \"-1000000\",\n        \"-884279719003555/281474976710656\",\n        Nearest,\n        \"-140737538678010796025/140737488355328\",\n        Less,\n    );\n\n    test(\"1/3\", \"0\", Down, \"0\", Less);\n    test(\"1/3\", \"0\", Floor, \"0\", Less);\n    test(\"1/3\", \"0\", Nearest, \"0\", Less);\n    test(\"-1/3\", \"0\", Down, \"0\", Greater);\n    test(\"-1/3\", \"0\", Ceiling, \"0\", Greater);\n    test(\"-1/3\", \"0\", Nearest, \"0\", Greater);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_1() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(Rational::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_2() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(Rational::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_3() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(Rational::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_fail_4() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(Rational::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_1() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(&Rational::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_2() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(&Rational::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_3() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(&Rational::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_assign_ref_fail_4() {\n    let mut n = Rational::from(10);\n    n.round_to_multiple_assign(&Rational::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_1() {\n    Rational::from(10).round_to_multiple(Rational::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_2() {\n    Rational::from(10).round_to_multiple(Rational::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_3() {\n    Rational::from(10).round_to_multiple(Rational::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_fail_4() {\n    Rational::from(10).round_to_multiple(Rational::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_1() {\n    Rational::from(10).round_to_multiple(&Rational::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_2() {\n    Rational::from(10).round_to_multiple(&Rational::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_3() {\n    Rational::from(10).round_to_multiple(&Rational::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_val_ref_fail_4() {\n    Rational::from(10).round_to_multiple(&Rational::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_1() {\n    (&Rational::from(10)).round_to_multiple(Rational::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_2() {\n    (&Rational::from(10)).round_to_multiple(Rational::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_3() {\n    (&Rational::from(10)).round_to_multiple(Rational::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_val_fail_4() {\n    (&Rational::from(10)).round_to_multiple(Rational::ZERO, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_1() {\n    (&Rational::from(10)).round_to_multiple(&Rational::from(3), Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_2() {\n    (&Rational::from(10)).round_to_multiple(&Rational::ZERO, Ceiling);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_3() {\n    (&Rational::from(10)).round_to_multiple(&Rational::ZERO, Up);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_ref_ref_fail_4() {\n    (&Rational::from(10)).round_to_multiple(&Rational::ZERO, Exact);\n}\n\n#[test]\nfn round_to_multiple_properties() {\n    rational_rational_rounding_mode_triple_gen_var_1().test_properties(|(x, y, rm)| {\n        let mut mut_n = x.clone();\n        let o = mut_n.round_to_multiple_assign(&y, rm);\n        assert!(mut_n.is_valid());\n        let r = mut_n;\n\n        let mut mut_n = x.clone();\n        assert_eq!(mut_n.round_to_multiple_assign(y.clone(), rm), o);\n        assert!(mut_n.is_valid());\n        assert_eq!(mut_n, r);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(&y, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(y.clone(), rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = x.clone().round_to_multiple(&y, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = x.clone().round_to_multiple(y.clone(), rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let (r_alt, o_alt) = (-&x).round_to_multiple(&y, -rm);\n        assert_eq!(-&r_alt, r);\n        assert_eq!(o_alt.reverse(), o);\n\n        let (r_alt, o_alt) = (&x).round_to_multiple(-&y, rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        assert_eq!(r.cmp(&x), o);\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n        if y == 0 {\n            assert_eq!(r, 0);\n        } else {\n            assert!((&r / &y).is_integer());\n            assert!((&r - &x).le_abs(&y));\n            match rm {\n                Floor => assert!(r <= x),\n                Ceiling => assert!(r >= x),\n                Down => assert!(r.le_abs(&x)),\n                Up => assert!(r.ge_abs(&x)),\n                Exact => assert_eq!(r, x),\n                Nearest => {\n                    let closest;\n                    let second_closest;\n                    if r <= x {\n                        closest = &x - &r;\n                        second_closest = &r + (&y).abs() - &x;\n                    } else {\n                        closest = &r - &x;\n                        second_closest = x + (&y).abs() - &r;\n                    }\n                    assert!(closest <= second_closest);\n                    if closest == second_closest {\n                        assert!(Integer::exact_from(r / y).even());\n                    }\n                }\n            }\n        }\n    });\n\n    rational_pair_gen_var_1().test_properties(|(x, y)| {\n        let rounded = x.round_to_multiple(&y, Nearest).0;\n        let ro = (rounded.clone(), Equal);\n        assert_eq!((&rounded).round_to_multiple(&y, Down), ro);\n        assert_eq!((&rounded).round_to_multiple(&y, Up), ro);\n        assert_eq!((&rounded).round_to_multiple(&y, Floor), ro);\n        assert_eq!((&rounded).round_to_multiple(&y, Ceiling), ro);\n        assert_eq!((&rounded).round_to_multiple(&y, Nearest), ro);\n        assert_eq!((&rounded).round_to_multiple(&y, Exact), ro);\n    });\n\n    rational_pair_gen_var_2().test_properties(|(x, y)| {\n        let down = (&x).round_to_multiple(&y, Down);\n        assert_eq!(down.1, if x >= 0 { Less } else { Greater });\n        let up = if x >= 0 {\n            (&down.0 + (&y).abs(), Greater)\n        } else {\n            (&down.0 - (&y).abs(), Less)\n        };\n        let floor = (&x).round_to_multiple(&y, Floor);\n        let ceiling = (&floor.0 + (&y).abs(), Greater);\n        assert_eq!((&x).round_to_multiple(&y, Up), up);\n        assert_eq!((&x).round_to_multiple(&y, Ceiling), ceiling);\n        let nearest = x.round_to_multiple(y, Nearest);\n        assert!(nearest == down || nearest == up);\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(x, rm)| {\n        let x = Rational::from(x);\n        let x = &x;\n        let xo = (x.clone(), Equal);\n        assert_eq!(x.round_to_multiple(Rational::ONE, rm), xo);\n        assert_eq!(x.round_to_multiple(Rational::NEGATIVE_ONE, rm), xo);\n        assert_eq!(\n            Rational::ZERO.round_to_multiple(x, rm),\n            (Rational::ZERO, Equal)\n        );\n        assert_eq!(x.round_to_multiple(x, rm), xo);\n        assert_eq!(x.round_to_multiple(-x, rm), xo);\n        assert_eq!((-x).round_to_multiple(x, rm), (-x, Equal));\n    });\n\n    integer_integer_rounding_mode_triple_gen_var_2().test_properties(|(x, y, rm)| {\n        let (n, no) = (&x).round_to_multiple(&y, rm);\n        let (r, ro) = Rational::from(x).round_to_multiple(Rational::from(y), rm);\n        assert_eq!(n, r);\n        assert_eq!(no, ro);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/round_to_multiple_of_power_of_2.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{\n    Abs, Parity, PowerOf2, RoundToMultiple, RoundToMultipleOfPowerOf2,\n    RoundToMultipleOfPowerOf2Assign,\n};\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, IsInteger};\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::signed_rounding_mode_pair_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::{\n    integer_rounding_mode_pair_gen, integer_unsigned_rounding_mode_triple_gen_var_1,\n};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_signed_pair_gen_var_1, rational_signed_pair_gen_var_3,\n    rational_signed_rounding_mode_triple_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_round_to_multiple_of_power_of_2() {\n    let test = |s, v: i64, rm: RoundingMode, out, o| {\n        let u = Rational::from_str(s).unwrap();\n\n        let mut n = u.clone();\n        assert_eq!(n.round_to_multiple_of_power_of_2_assign(v, rm), o);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let (n, o_alt) = u.clone().round_to_multiple_of_power_of_2(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n\n        let (n, o_alt) = (&u).round_to_multiple_of_power_of_2(v, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o_alt, o);\n    };\n    test(\"0\", 0, Down, \"0\", Equal);\n    test(\"0\", 0, Up, \"0\", Equal);\n    test(\"0\", 0, Floor, \"0\", Equal);\n    test(\"0\", 0, Ceiling, \"0\", Equal);\n    test(\"0\", 0, Nearest, \"0\", Equal);\n    test(\"0\", 0, Exact, \"0\", Equal);\n\n    test(\"0\", 10, Down, \"0\", Equal);\n    test(\"0\", 10, Up, \"0\", Equal);\n    test(\"0\", 10, Floor, \"0\", Equal);\n    test(\"0\", 10, Ceiling, \"0\", Equal);\n    test(\"0\", 10, Nearest, \"0\", Equal);\n    test(\"0\", 10, Exact, \"0\", Equal);\n\n    test(\"123\", 0, Down, \"123\", Equal);\n    test(\"123\", 0, Up, \"123\", Equal);\n    test(\"123\", 0, Floor, \"123\", Equal);\n    test(\"123\", 0, Ceiling, \"123\", Equal);\n    test(\"123\", 0, Nearest, \"123\", Equal);\n    test(\"123\", 0, Exact, \"123\", Equal);\n\n    test(\"123\", 2, Down, \"120\", Less);\n    test(\"123\", 2, Up, \"124\", Greater);\n    test(\"123\", 2, Floor, \"120\", Less);\n    test(\"123\", 2, Ceiling, \"124\", Greater);\n    test(\"123\", 2, Nearest, \"124\", Greater);\n\n    test(\"123\", -2, Down, \"123\", Equal);\n    test(\"123\", -2, Up, \"123\", Equal);\n    test(\"123\", -2, Floor, \"123\", Equal);\n    test(\"123\", -2, Ceiling, \"123\", Equal);\n    test(\"123\", -2, Nearest, \"123\", Equal);\n    test(\"123\", -2, Exact, \"123\", Equal);\n\n    test(\"884279719003555/281474976710656\", 2, Down, \"0\", Less);\n    test(\"884279719003555/281474976710656\", 2, Up, \"4\", Greater);\n    test(\"884279719003555/281474976710656\", 2, Floor, \"0\", Less);\n    test(\"884279719003555/281474976710656\", 2, Ceiling, \"4\", Greater);\n    test(\"884279719003555/281474976710656\", 2, Nearest, \"4\", Greater);\n\n    test(\"884279719003555/281474976710656\", -4, Down, \"25/8\", Less);\n    test(\"884279719003555/281474976710656\", -4, Up, \"51/16\", Greater);\n    test(\"884279719003555/281474976710656\", -4, Floor, \"25/8\", Less);\n    test(\n        \"884279719003555/281474976710656\",\n        -4,\n        Ceiling,\n        \"51/16\",\n        Greater,\n    );\n    test(\"884279719003555/281474976710656\", -4, Nearest, \"25/8\", Less);\n\n    test(\"884279719003555/281474976710656\", -10, Down, \"201/64\", Less);\n    test(\n        \"884279719003555/281474976710656\",\n        -10,\n        Up,\n        \"3217/1024\",\n        Greater,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        -10,\n        Floor,\n        \"201/64\",\n        Less,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        -10,\n        Ceiling,\n        \"3217/1024\",\n        Greater,\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        -10,\n        Nearest,\n        \"3217/1024\",\n        Greater,\n    );\n\n    test(\"-123\", 0, Down, \"-123\", Equal);\n    test(\"-123\", 0, Up, \"-123\", Equal);\n    test(\"-123\", 0, Floor, \"-123\", Equal);\n    test(\"-123\", 0, Ceiling, \"-123\", Equal);\n    test(\"-123\", 0, Nearest, \"-123\", Equal);\n    test(\"-123\", 0, Exact, \"-123\", Equal);\n\n    test(\"-123\", 2, Down, \"-120\", Greater);\n    test(\"-123\", 2, Up, \"-124\", Less);\n    test(\"-123\", 2, Floor, \"-124\", Less);\n    test(\"-123\", 2, Ceiling, \"-120\", Greater);\n    test(\"-123\", 2, Nearest, \"-124\", Less);\n\n    test(\"-123\", -2, Down, \"-123\", Equal);\n    test(\"-123\", -2, Up, \"-123\", Equal);\n    test(\"-123\", -2, Floor, \"-123\", Equal);\n    test(\"-123\", -2, Ceiling, \"-123\", Equal);\n    test(\"-123\", -2, Nearest, \"-123\", Equal);\n    test(\"-123\", -2, Exact, \"-123\", Equal);\n\n    test(\"-884279719003555/281474976710656\", 2, Down, \"0\", Greater);\n    test(\"-884279719003555/281474976710656\", 2, Up, \"-4\", Less);\n    test(\"-884279719003555/281474976710656\", 2, Floor, \"-4\", Less);\n    test(\"-884279719003555/281474976710656\", 2, Ceiling, \"0\", Greater);\n    test(\"-884279719003555/281474976710656\", 2, Nearest, \"-4\", Less);\n\n    test(\n        \"-884279719003555/281474976710656\",\n        -4,\n        Down,\n        \"-25/8\",\n        Greater,\n    );\n    test(\"-884279719003555/281474976710656\", -4, Up, \"-51/16\", Less);\n    test(\n        \"-884279719003555/281474976710656\",\n        -4,\n        Floor,\n        \"-51/16\",\n        Less,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        -4,\n        Ceiling,\n        \"-25/8\",\n        Greater,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        -4,\n        Nearest,\n        \"-25/8\",\n        Greater,\n    );\n\n    test(\n        \"-884279719003555/281474976710656\",\n        -10,\n        Down,\n        \"-201/64\",\n        Greater,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        -10,\n        Up,\n        \"-3217/1024\",\n        Less,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        -10,\n        Floor,\n        \"-3217/1024\",\n        Less,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        -10,\n        Ceiling,\n        \"-201/64\",\n        Greater,\n    );\n    test(\n        \"-884279719003555/281474976710656\",\n        -10,\n        Nearest,\n        \"-3217/1024\",\n        Less,\n    );\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_1() {\n    Rational::from(-123).round_to_multiple_of_power_of_2_assign(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_2() {\n    Rational::from(-123).round_to_multiple_of_power_of_2_assign(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_3() {\n    Rational::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2_assign(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_assign_fail_4() {\n    Rational::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2_assign(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_1() {\n    Rational::from(-123).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_2() {\n    Rational::from(-123).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_3() {\n    Rational::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_fail_4() {\n    Rational::from_str(\"-1000000000001\")\n        .unwrap()\n        .round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_1() {\n    (&Rational::from(-123)).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_2() {\n    (&Rational::from(-123)).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_3() {\n    (&Rational::from_str(\"-1000000000001\").unwrap()).round_to_multiple_of_power_of_2(1, Exact);\n}\n\n#[test]\n#[should_panic]\nfn round_to_multiple_of_power_of_2_ref_fail_4() {\n    (&Rational::from_str(\"-1000000000001\").unwrap()).round_to_multiple_of_power_of_2(100, Exact);\n}\n\n#[test]\nfn round_to_multiple_of_power_of_2_properties() {\n    rational_signed_rounding_mode_triple_gen_var_1().test_properties(|(n, pow, rm)| {\n        let (r, o) = (&n).round_to_multiple_of_power_of_2(pow, rm);\n        assert!(r.is_valid());\n\n        let (r_alt, o_alt) = n.clone().round_to_multiple_of_power_of_2(pow, rm);\n        assert!(r_alt.is_valid());\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n\n        let mut mut_n = n.clone();\n        let o_alt = mut_n.round_to_multiple_of_power_of_2_assign(pow, rm);\n        assert!(mut_n.is_valid());\n        assert_eq!(mut_n, r);\n        assert_eq!(o_alt, o);\n\n        assert!((&r >> pow).is_integer());\n        assert_eq!(r.cmp(&n), o);\n        match (n >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n\n        let (r_alt, o_alt) = (-&n).round_to_multiple_of_power_of_2(pow, -rm);\n        assert_eq!(-r_alt, r);\n        assert_eq!(o_alt.reverse(), o);\n        assert!((&r - &n).abs() <= Rational::power_of_2(pow));\n        let (r_alt, o_alt) = (&n).round_to_multiple(Rational::power_of_2(pow), rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n        match rm {\n            Floor => assert!(r <= n),\n            Ceiling => assert!(r >= n),\n            Down => assert!(r.le_abs(&n)),\n            Up => assert!(r.ge_abs(&n)),\n            Exact => assert_eq!(r, n),\n            Nearest => {\n                let k = Rational::power_of_2(pow);\n                let closest;\n                let second_closest;\n                if r <= n {\n                    closest = &n - &r;\n                    second_closest = &r + k - n;\n                } else {\n                    closest = &r - &n;\n                    second_closest = n + k - &r;\n                }\n                assert!(closest <= second_closest);\n                if closest == second_closest {\n                    assert!(Integer::exact_from(r >> pow).even());\n                }\n            }\n        }\n    });\n\n    rational_signed_pair_gen_var_1().test_properties(|(n, pow)| {\n        let rounded = (&n).round_to_multiple_of_power_of_2(pow, Nearest).0;\n        let ro = (rounded.clone(), Equal);\n        assert_eq!((&rounded).round_to_multiple_of_power_of_2(pow, Down), ro);\n        assert_eq!((&rounded).round_to_multiple_of_power_of_2(pow, Up), ro);\n        assert_eq!((&rounded).round_to_multiple_of_power_of_2(pow, Floor), ro);\n        assert_eq!((&rounded).round_to_multiple_of_power_of_2(pow, Ceiling), ro);\n        assert_eq!((&rounded).round_to_multiple_of_power_of_2(pow, Nearest), ro);\n        assert_eq!((&rounded).round_to_multiple_of_power_of_2(pow, Exact), ro);\n    });\n\n    rational_signed_pair_gen_var_3().test_properties(|(n, pow)| {\n        let floor = (&n).round_to_multiple_of_power_of_2(pow, Floor);\n        assert_eq!(floor.1, Less);\n        let ceiling = (&floor.0 + Rational::power_of_2(pow), Greater);\n        assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Ceiling), ceiling);\n        if n >= 0 {\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Up), ceiling);\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Down), floor);\n        } else {\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Up), floor);\n            assert_eq!((&n).round_to_multiple_of_power_of_2(pow, Down), ceiling);\n        }\n        let nearest = n.round_to_multiple_of_power_of_2(pow, Nearest);\n        assert!(nearest == ceiling || nearest == floor);\n    });\n\n    integer_rounding_mode_pair_gen().test_properties(|(n, rm)| {\n        let rn = Rational::from(n);\n        assert_eq!((&rn).round_to_multiple_of_power_of_2(0, rm), (rn, Equal));\n    });\n\n    signed_rounding_mode_pair_gen().test_properties(|(pow, rm)| {\n        assert_eq!(\n            Rational::ZERO.round_to_multiple_of_power_of_2(pow, rm),\n            (Rational::ZERO, Equal)\n        );\n    });\n\n    integer_unsigned_rounding_mode_triple_gen_var_1().test_properties(|(n, pow, rm)| {\n        let (r, o) = (&n).round_to_multiple_of_power_of_2(pow, rm);\n        let (r_alt, o_alt) =\n            Rational::from(n).round_to_multiple_of_power_of_2(i64::exact_from(pow), rm);\n        assert_eq!(r_alt, r);\n        assert_eq!(o_alt, o);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/shl.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, PowerOf2, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, unsigned_gen, unsigned_gen_var_5,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_unsigned_pair_gen_var_1;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_signed_pair_gen_var_1, rational_unsigned_pair_gen_var_1,\n};\nuse std::ops::{Shl, ShlAssign, Shr};\nuse std::str::FromStr;\n\nfn test_shl_unsigned_helper<T: PrimitiveUnsigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Rational: ShlAssign<T> + Shl<T, Output = Rational>,\n    for<'a> &'a Rational: Shl<T, Output = Rational>,\n{\n    let test = |s, v: u8, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n\n    test(\"123\", 0, \"123\");\n    test(\"123\", 1, \"246\");\n    test(\"123\", 2, \"492\");\n    test(\"123\", 25, \"4127195136\");\n    test(\"123\", 26, \"8254390272\");\n    test(\"123\", 100, \"155921023828072216384094494261248\");\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-123\", 1, \"-246\");\n    test(\"-123\", 2, \"-492\");\n    test(\"-123\", 25, \"-4127195136\");\n    test(\"-123\", 26, \"-8254390272\");\n    test(\"-123\", 100, \"-155921023828072216384094494261248\");\n\n    test(\"22/7\", 0, \"22/7\");\n    test(\"22/7\", 1, \"44/7\");\n    test(\"22/7\", 2, \"88/7\");\n    test(\"22/7\", 25, \"738197504/7\");\n    test(\"22/7\", 26, \"1476395008/7\");\n    test(\"22/7\", 100, \"27888313205021046832927470518272/7\");\n\n    test(\"-22/7\", 0, \"-22/7\");\n    test(\"-22/7\", 1, \"-44/7\");\n    test(\"-22/7\", 2, \"-88/7\");\n    test(\"-22/7\", 25, \"-738197504/7\");\n    test(\"-22/7\", 26, \"-1476395008/7\");\n    test(\"-22/7\", 100, \"-27888313205021046832927470518272/7\");\n}\n\n#[test]\nfn test_shl_unsigned() {\n    test_shl_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u32, _>(|s, v, out| {\n        let mut n = rug::Rational::from_str(s).unwrap();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() << v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shl_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shl_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shl_signed_helper<T: PrimitiveSigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Rational: ShlAssign<T> + Shl<T, Output = Rational>,\n    for<'a> &'a Rational: Shl<T, Output = Rational>,\n{\n    let test = |s, v: i8, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u << v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"0\", 10, \"0\");\n    test(\"123\", 1, \"246\");\n    test(\"123\", 2, \"492\");\n    test(\"123\", 25, \"4127195136\");\n    test(\"123\", 26, \"8254390272\");\n    test(\"123\", 100, \"155921023828072216384094494261248\");\n\n    test(\"-123\", 1, \"-246\");\n    test(\"-123\", 2, \"-492\");\n    test(\"-123\", 25, \"-4127195136\");\n    test(\"-123\", 26, \"-8254390272\");\n    test(\"-123\", 100, \"-155921023828072216384094494261248\");\n\n    test(\"123\", 0, \"123\");\n    test(\"245\", -1, \"245/2\");\n    test(\"246\", -1, \"123\");\n    test(\"247\", -1, \"247/2\");\n    test(\"491\", -2, \"491/4\");\n    test(\"492\", -2, \"123\");\n    test(\"493\", -2, \"493/4\");\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-245\", -1, \"-245/2\");\n    test(\"-246\", -1, \"-123\");\n    test(\"-247\", -1, \"-247/2\");\n    test(\"-491\", -2, \"-491/4\");\n    test(\"-492\", -2, \"-123\");\n    test(\"-493\", -2, \"-493/4\");\n\n    test(\"22/7\", 0, \"22/7\");\n    test(\"22/7\", 1, \"44/7\");\n    test(\"22/7\", 2, \"88/7\");\n    test(\"22/7\", 25, \"738197504/7\");\n    test(\"22/7\", 26, \"1476395008/7\");\n    test(\"22/7\", 100, \"27888313205021046832927470518272/7\");\n\n    test(\"-22/7\", 0, \"-22/7\");\n    test(\"-22/7\", 1, \"-44/7\");\n    test(\"-22/7\", 2, \"-88/7\");\n    test(\"-22/7\", 25, \"-738197504/7\");\n    test(\"-22/7\", 26, \"-1476395008/7\");\n    test(\"-22/7\", 100, \"-27888313205021046832927470518272/7\");\n\n    test(\"22/7\", -1, \"11/7\");\n    test(\"22/7\", -2, \"11/14\");\n    test(\"22/7\", -25, \"11/117440512\");\n    test(\"22/7\", -26, \"11/234881024\");\n    test(\"22/7\", -100, \"11/4436777100798802905238461218816\");\n\n    test(\"-22/7\", -1, \"-11/7\");\n    test(\"-22/7\", -2, \"-11/14\");\n    test(\"-22/7\", -25, \"-11/117440512\");\n    test(\"-22/7\", -26, \"-11/234881024\");\n    test(\"-22/7\", -100, \"-11/4436777100798802905238461218816\");\n}\n\n#[test]\nfn test_shl_signed() {\n    test_shl_signed_helper::<i8, _>(|_, _, _| {});\n    test_shl_signed_helper::<i16, _>(|_, _, _| {});\n    test_shl_signed_helper::<i32, _>(|s, v, out| {\n        let mut n = rug::Rational::from_str(s).unwrap();\n        n <<= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() << v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shl_signed_helper::<i64, _>(|_, _, _| {});\n    test_shl_signed_helper::<i128, _>(|_, _, _| {});\n    test_shl_signed_helper::<isize, _>(|_, _, _| {});\n}\n\nfn shl_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Rational: Shl<T, Output = Rational> + ShlAssign<T> + Shr<T, Output = Rational>,\n    for<'a> &'a Rational: Shl<T, Output = Rational>,\n    u64: TryFrom<T>,\n{\n    rational_unsigned_pair_gen_var_1::<T>().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n <<= u;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n << u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone() << u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert!((&n << u).ge_abs(&n));\n        assert_eq!(-&n << u, -(&n << u));\n\n        assert_eq!(&n << u, &n * Rational::power_of_2(u64::exact_from(u)));\n        assert_eq!(&n << u >> u, n);\n    });\n\n    rational_gen().test_properties(|n| {\n        assert_eq!(&n << T::ZERO, n);\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(Rational::ZERO << u, 0);\n    });\n\n    unsigned_gen_var_5::<T>().test_properties(|u| {\n        assert!((Rational::ONE << u).is_power_of_2());\n    });\n\n    integer_unsigned_pair_gen_var_1::<T>().test_properties(|(n, u)| {\n        assert_eq!(&n << u, Rational::from(n) << u);\n    });\n}\n\nfn shl_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    for<'a> &'a Integer: Shl<T, Output = Integer>,\n    Rational: Shl<T, Output = Rational> + ShlAssign<T> + Shr<T, Output = Rational>,\n    for<'a> &'a Rational:\n        Shl<T, Output = Rational> + Shl<<T as UnsignedAbs>::Output, Output = Rational>,\n    i64: TryFrom<T>,\n{\n    rational_signed_pair_gen_var_1::<T>().test_properties(|(n, i)| {\n        let mut mut_n = n.clone();\n        mut_n <<= i;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n << i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone() << i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        if i >= T::ZERO {\n            assert_eq!(&n << i.unsigned_abs(), shifted);\n        }\n        assert_eq!(-&n << i, -(&n << i));\n\n        assert_eq!(&n << i, &n * Rational::power_of_2(i64::exact_from(i)));\n        assert_eq!(&n << i >> i, n);\n        if let Some(neg_i) = i.checked_neg() {\n            assert_eq!(&n << neg_i, n >> i);\n        }\n    });\n\n    rational_gen().test_properties(|n| {\n        assert_eq!(&n << T::ZERO, n);\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert_eq!(Rational::ZERO << i, 0);\n    });\n\n    signed_gen_var_5::<T>().test_properties(|i| {\n        assert!((Rational::ONE << i).is_power_of_2());\n    });\n}\n\n#[test]\nfn shl_properties() {\n    apply_fn_to_unsigneds!(shl_properties_helper_unsigned);\n    apply_fn_to_signeds!(shl_properties_helper_signed);\n\n    rational_unsigned_pair_gen_var_1::<u32>().test_properties(|(n, u)| {\n        let shifted = &n << u;\n        let mut rug_n = rug::Rational::from(&n);\n        rug_n <<= u;\n        assert_eq!(Rational::from(&rug_n), shifted);\n        assert_eq!(Rational::from(&(rug::Rational::from(&n) << u)), shifted);\n    });\n\n    rational_signed_pair_gen_var_1::<i32>().test_properties(|(n, i)| {\n        let shifted = &n << i;\n        let mut rug_n = rug::Rational::from(&n);\n        rug_n <<= i;\n        assert_eq!(Rational::from(&rug_n), shifted);\n        assert_eq!(Rational::from(&(rug::Rational::from(&n) << i)), shifted);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/shr.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{IsPowerOf2, PowerOf2, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_gen_var_5, unsigned_gen, unsigned_gen_var_5,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_signed_pair_gen_var_1, rational_unsigned_pair_gen_var_1,\n};\nuse std::ops::{Shl, Shr, ShrAssign};\nuse std::str::FromStr;\n\nfn test_shr_unsigned_helper<T: PrimitiveUnsigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Rational: ShrAssign<T> + Shr<T, Output = Rational>,\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    let test = |s, v: u8, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"123\", 0, \"123\");\n    test(\"245\", 1, \"245/2\");\n    test(\"246\", 1, \"123\");\n    test(\"247\", 1, \"247/2\");\n    test(\"491\", 2, \"491/4\");\n    test(\"492\", 2, \"123\");\n    test(\"493\", 2, \"493/4\");\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-245\", 1, \"-245/2\");\n    test(\"-246\", 1, \"-123\");\n    test(\"-247\", 1, \"-247/2\");\n    test(\"-491\", 2, \"-491/4\");\n    test(\"-492\", 2, \"-123\");\n    test(\"-493\", 2, \"-493/4\");\n\n    test(\"22/7\", 1, \"11/7\");\n    test(\"22/7\", 2, \"11/14\");\n    test(\"22/7\", 25, \"11/117440512\");\n    test(\"22/7\", 26, \"11/234881024\");\n    test(\"22/7\", 100, \"11/4436777100798802905238461218816\");\n\n    test(\"-22/7\", 1, \"-11/7\");\n    test(\"-22/7\", 2, \"-11/14\");\n    test(\"-22/7\", 25, \"-11/117440512\");\n    test(\"-22/7\", 26, \"-11/234881024\");\n    test(\"-22/7\", 100, \"-11/4436777100798802905238461218816\");\n}\n\n#[test]\nfn test_shr_unsigned() {\n    test_shr_unsigned_helper::<u8, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u16, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u32, _>(|s, v, out| {\n        let mut n = rug::Rational::from_str(s).unwrap();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() >> v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shr_unsigned_helper::<u64, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<u128, _>(|_, _, _| {});\n    test_shr_unsigned_helper::<usize, _>(|_, _, _| {});\n}\n\nfn test_shr_signed_helper<T: PrimitiveSigned, F: Fn(&str, T, &str)>(f: F)\nwhere\n    Rational: ShrAssign<T> + Shr<T, Output = Rational>,\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n{\n    let test = |s, v: i8, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = T::from(v);\n\n        let mut n = u.clone();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u >> v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        f(s, v, out);\n    };\n    test(\"0\", 0, \"0\");\n    test(\"0\", -10, \"0\");\n    test(\"0\", -10, \"0\");\n    test(\"123\", -1, \"246\");\n    test(\"123\", -2, \"492\");\n    test(\"123\", -25, \"4127195136\");\n    test(\"123\", -26, \"8254390272\");\n    test(\"123\", -100, \"155921023828072216384094494261248\");\n\n    test(\"-123\", -1, \"-246\");\n    test(\"-123\", -2, \"-492\");\n    test(\"-123\", -25, \"-4127195136\");\n    test(\"-123\", -26, \"-8254390272\");\n    test(\"-123\", -100, \"-155921023828072216384094494261248\");\n\n    test(\"123\", 0, \"123\");\n    test(\"245\", 1, \"245/2\");\n    test(\"246\", 1, \"123\");\n    test(\"247\", 1, \"247/2\");\n    test(\"491\", 2, \"491/4\");\n    test(\"492\", 2, \"123\");\n    test(\"493\", 2, \"493/4\");\n\n    test(\"-123\", 0, \"-123\");\n    test(\"-245\", 1, \"-245/2\");\n    test(\"-246\", 1, \"-123\");\n    test(\"-247\", 1, \"-247/2\");\n    test(\"-491\", 2, \"-491/4\");\n    test(\"-492\", 2, \"-123\");\n    test(\"-493\", 2, \"-493/4\");\n\n    test(\"22/7\", 0, \"22/7\");\n    test(\"22/7\", -1, \"44/7\");\n    test(\"22/7\", -2, \"88/7\");\n    test(\"22/7\", -25, \"738197504/7\");\n    test(\"22/7\", -26, \"1476395008/7\");\n    test(\"22/7\", -100, \"27888313205021046832927470518272/7\");\n\n    test(\"-22/7\", 0, \"-22/7\");\n    test(\"-22/7\", -1, \"-44/7\");\n    test(\"-22/7\", -2, \"-88/7\");\n    test(\"-22/7\", -25, \"-738197504/7\");\n    test(\"-22/7\", -26, \"-1476395008/7\");\n    test(\"-22/7\", -100, \"-27888313205021046832927470518272/7\");\n\n    test(\"22/7\", 1, \"11/7\");\n    test(\"22/7\", 2, \"11/14\");\n    test(\"22/7\", 25, \"11/117440512\");\n    test(\"22/7\", 26, \"11/234881024\");\n    test(\"22/7\", 100, \"11/4436777100798802905238461218816\");\n\n    test(\"-22/7\", 1, \"-11/7\");\n    test(\"-22/7\", 2, \"-11/14\");\n    test(\"-22/7\", 25, \"-11/117440512\");\n    test(\"-22/7\", 26, \"-11/234881024\");\n    test(\"-22/7\", 100, \"-11/4436777100798802905238461218816\");\n}\n\n#[test]\nfn test_shr_signed() {\n    test_shr_signed_helper::<i8, _>(|_, _, _| {});\n    test_shr_signed_helper::<i16, _>(|_, _, _| {});\n    test_shr_signed_helper::<i32, _>(|s, v, out| {\n        let mut n = rug::Rational::from_str(s).unwrap();\n        n >>= v;\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() >> v;\n        assert_eq!(n.to_string(), out);\n    });\n    test_shr_signed_helper::<i64, _>(|_, _, _| {});\n    test_shr_signed_helper::<i128, _>(|_, _, _| {});\n    test_shr_signed_helper::<isize, _>(|_, _, _| {});\n}\n\nfn shr_properties_helper_unsigned<T: PrimitiveUnsigned>()\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Rational: Shr<T, Output = Rational> + ShrAssign<T> + Shl<T, Output = Rational>,\n    for<'a> &'a Rational: Shr<T, Output = Rational>,\n    u64: TryFrom<T>,\n{\n    rational_unsigned_pair_gen_var_1::<T>().test_properties(|(n, u)| {\n        let mut mut_n = n.clone();\n        mut_n >>= u;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n >> u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone() >> u;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        assert!((&n >> u).le_abs(&n));\n        assert_eq!(-&n >> u, -(&n >> u));\n\n        assert_eq!(&n >> u, &n / Rational::power_of_2(u64::exact_from(u)));\n        assert_eq!(&n >> u << u, n);\n    });\n\n    rational_gen().test_properties(|n| {\n        assert_eq!(&n >> T::ZERO, n);\n    });\n\n    unsigned_gen::<T>().test_properties(|u| {\n        assert_eq!(Rational::ZERO >> u, 0);\n    });\n\n    unsigned_gen_var_5::<T>().test_properties(|u| {\n        assert!((Rational::ONE >> u).is_power_of_2());\n    });\n}\n\nfn shr_properties_helper_signed<T: PrimitiveSigned>()\nwhere\n    for<'a> &'a Integer: Shr<T, Output = Integer>,\n    Rational: Shr<T, Output = Rational> + ShrAssign<T> + Shl<T, Output = Rational>,\n    for<'a> &'a Rational:\n        Shr<T, Output = Rational> + Shr<<T as UnsignedAbs>::Output, Output = Rational>,\n    i64: TryFrom<T>,\n{\n    rational_signed_pair_gen_var_1::<T>().test_properties(|(n, i)| {\n        let mut mut_n = n.clone();\n        mut_n >>= i;\n        assert!(mut_n.is_valid());\n        let shifted = mut_n;\n\n        let shifted_alt = &n >> i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n        let shifted_alt = n.clone() >> i;\n        assert!(shifted_alt.is_valid());\n        assert_eq!(shifted_alt, shifted);\n\n        if i >= T::ZERO {\n            assert_eq!(&n >> i.unsigned_abs(), shifted);\n        }\n        assert_eq!(-&n >> i, -(&n >> i));\n\n        assert_eq!(&n >> i, &n / Rational::power_of_2(i64::exact_from(i)));\n        assert_eq!(&n >> i << i, n);\n        if let Some(neg_i) = i.checked_neg() {\n            assert_eq!(&n >> neg_i, n << i);\n        }\n    });\n\n    rational_gen().test_properties(|n| {\n        assert_eq!(&n >> T::ZERO, n);\n    });\n\n    signed_gen::<T>().test_properties(|i| {\n        assert_eq!(Rational::ZERO >> i, 0);\n    });\n\n    signed_gen_var_5::<T>().test_properties(|i| {\n        assert!((Rational::ONE >> i).is_power_of_2());\n    });\n}\n\n#[test]\nfn shr_properties() {\n    apply_fn_to_unsigneds!(shr_properties_helper_unsigned);\n    apply_fn_to_signeds!(shr_properties_helper_signed);\n\n    rational_unsigned_pair_gen_var_1::<u32>().test_properties(|(n, u)| {\n        let shifted = &n >> u;\n        let mut rug_n = rug::Rational::from(&n);\n        rug_n >>= u;\n        assert_eq!(Rational::from(&rug_n), shifted);\n        assert_eq!(Rational::from(&(rug::Rational::from(&n) >> u)), shifted);\n    });\n\n    rational_signed_pair_gen_var_1::<i32>().test_properties(|(n, i)| {\n        let shifted = &n >> i;\n        let mut rug_n = rug::Rational::from(&n);\n        rug_n >>= i;\n        assert_eq!(Rational::from(&rug_n), shifted);\n        assert_eq!(Rational::from(&(rug::Rational::from(&n) >> i)), shifted);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/sign.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Sign;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::sign::num_sign;\nuse malachite_q::test_util::generators::rational_gen;\nuse num::BigRational;\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_sign() {\n    let test = |s, out| {\n        assert_eq!(Rational::from_str(s).unwrap().sign(), out);\n        assert_eq!(num_sign(&BigRational::from_str(s).unwrap()), out);\n        assert_eq!(rug::Rational::from_str(s).unwrap().cmp0(), out);\n    };\n    test(\"0\", Equal);\n    test(\"123\", Greater);\n    test(\"-123\", Less);\n    test(\"1000000000000\", Greater);\n    test(\"-1000000000000\", Less);\n}\n\n#[test]\nfn sign_properties() {\n    rational_gen().test_properties(|n| {\n        let sign = n.sign();\n        assert_eq!(rug::Rational::from(&n).cmp0(), sign);\n        assert_eq!(num_sign(&BigRational::from(&n)), sign);\n        assert_eq!(n.partial_cmp(&0), Some(sign));\n        assert_eq!((-n).sign(), sign.reverse());\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(Rational::from(&n).sign(), n.sign());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/simplest_rational_in_interval.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::test_util::common::test_custom_cmp_helper;\nuse malachite_q::Rational;\nuse malachite_q::arithmetic::traits::SimplestRationalInInterval;\nuse malachite_q::test_util::arithmetic::simplest_rational_in_interval::*;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_pair_gen, rational_pair_gen_var_3, rational_pair_gen_var_4,\n    rational_pair_gen_var_5, rational_pair_gen_var_6, rational_triple_gen,\n    rational_triple_gen_var_2, rational_triple_gen_var_3,\n};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_cmp_complexity() {\n    let strings = &[\"0\", \"1\", \"-1\", \"1/2\", \"-1/2\", \"5/2\", \"1/100\", \"99/100\", \"-99/100\"];\n    test_custom_cmp_helper::<Rational, _>(strings, Rational::cmp_complexity);\n}\n\n#[test]\nfn test_simplest_rational_in_open_interval() {\n    let test = |x, y, out| {\n        let x = Rational::from_str(x).unwrap();\n        let y = Rational::from_str(y).unwrap();\n        assert_eq!(\n            Rational::simplest_rational_in_open_interval(&x, &y).to_string(),\n            out\n        );\n        assert_eq!(\n            simplest_rational_in_open_interval_explicit(&x, &y).to_string(),\n            out\n        );\n        assert_eq!(\n            simplest_rational_in_open_interval_naive(&x, &y).to_string(),\n            out\n        );\n    };\n    test(\"0\", \"2\", \"1\");\n    test(\"0\", \"1\", \"1/2\");\n    test(\"-1\", \"1\", \"0\");\n    test(\"-9\", \"10\", \"0\");\n    test(\"0\", \"1/2\", \"1/3\");\n    test(\"1/2\", \"1\", \"2/3\");\n    test(\"0\", \"1/3\", \"1/4\");\n    test(\"1/3\", \"1\", \"1/2\");\n    test(\"1/3\", \"1/2\", \"2/5\");\n    test(\"157/50\", \"63/20\", \"22/7\");\n    test(\"2/3\", \"1\", \"3/4\");\n    test(\"1/2\", \"2/3\", \"3/5\");\n    test(\"1/2\", \"3/5\", \"4/7\");\n    test(\"3/5\", \"2/3\", \"5/8\");\n    test(\"2/3\", \"3/4\", \"5/7\");\n}\n\n#[test]\n#[should_panic]\nfn simplest_rational_in_open_interval_fail_1() {\n    Rational::simplest_rational_in_open_interval(&Rational::ONE, &Rational::ONE);\n}\n\n#[test]\n#[should_panic]\nfn simplest_rational_in_open_interval_fail_2() {\n    Rational::simplest_rational_in_open_interval(&Rational::ONE, &Rational::ZERO);\n}\n\n#[test]\nfn test_simplest_rational_in_closed_interval() {\n    let test = |x, y, out| {\n        let x = Rational::from_str(x).unwrap();\n        let y = Rational::from_str(y).unwrap();\n        assert_eq!(\n            Rational::simplest_rational_in_closed_interval(&x, &y).to_string(),\n            out\n        );\n    };\n    test(\"0\", \"2\", \"0\");\n    test(\"0\", \"1\", \"0\");\n    test(\"-1\", \"1\", \"0\");\n    test(\"-9\", \"10\", \"0\");\n    test(\"0\", \"1/2\", \"0\");\n    test(\"1/2\", \"1\", \"1\");\n    test(\"0\", \"1/3\", \"0\");\n    test(\"1/3\", \"1\", \"1\");\n    test(\"1/3\", \"1/2\", \"1/2\");\n    test(\"157/50\", \"63/20\", \"22/7\");\n}\n\n#[test]\n#[should_panic]\nfn simplest_rational_in_closed_interval_fail() {\n    Rational::simplest_rational_in_closed_interval(&Rational::ONE, &Rational::ZERO);\n}\n\n#[test]\nfn cmp_complexity_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let ord = x.cmp_complexity(&y);\n        assert_eq!(y.cmp_complexity(&x).reverse(), ord);\n        assert_eq!(x == y, x.cmp_complexity(&y) == Equal);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!(x.cmp_complexity(&x), Equal);\n    });\n\n    rational_triple_gen().test_properties(|(x, y, z)| {\n        if x.cmp_complexity(&y) == Less && y.cmp_complexity(&z) == Less {\n            assert!(x.cmp_complexity(&z) == Less);\n        } else if x.cmp_complexity(&y) == Greater && y.cmp_complexity(&z) == Greater {\n            assert!(x.cmp_complexity(&z) == Greater);\n        }\n    });\n}\n\n#[test]\nfn simplest_rational_in_open_interval_properties() {\n    rational_pair_gen_var_3().test_properties(|(x, y)| {\n        let s = Rational::simplest_rational_in_open_interval(&x, &y);\n        assert!(s.is_valid());\n        assert_eq!(simplest_rational_in_open_interval_explicit(&x, &y), s);\n        assert!(s > x);\n        assert!(s < y);\n        assert_eq!(Rational::simplest_rational_in_open_interval(&-y, &-x), -s);\n    });\n\n    rational_pair_gen_var_5().test_properties(|(x, y)| {\n        assert_eq!(\n            simplest_rational_in_open_interval_naive(&x, &y),\n            Rational::simplest_rational_in_open_interval(&x, &y)\n        );\n    });\n\n    rational_triple_gen_var_2().test_properties(|(x, y, z)| {\n        let q = Rational::simplest_rational_in_open_interval(&x, &z);\n        assert!(q.cmp_complexity(&y) <= Equal);\n    });\n}\n\n#[test]\nfn simplest_rational_in_closed_interval_properties() {\n    rational_pair_gen_var_4().test_properties(|(x, y)| {\n        let s = Rational::simplest_rational_in_closed_interval(&x, &y);\n        assert!(s.is_valid());\n        assert!(s >= x);\n        assert!(s <= y);\n        assert_eq!(Rational::simplest_rational_in_closed_interval(&-y, &-x), -s);\n    });\n\n    rational_pair_gen_var_6().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::simplest_rational_in_closed_interval(&x, &y),\n            simplest_rational_in_closed_interval_naive(&x, &y)\n        );\n    });\n\n    rational_triple_gen_var_3().test_properties(|(x, y, z)| {\n        let q = Rational::simplest_rational_in_closed_interval(&x, &z);\n        assert!(q.cmp_complexity(&y) <= Equal);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!(Rational::simplest_rational_in_closed_interval(&x, &x), x);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/sqrt.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CheckedSqrt, Reciprocal, Square};\nuse malachite_base::num::basic::traits::NegativeOne;\nuse malachite_nz::test_util::generators::integer_gen_var_4;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen_var_3;\nuse std::str::FromStr;\n\n#[test]\nfn test_checked_sqrt() {\n    let test = |s, out: Option<&str>| {\n        let n = Rational::from_str(s).unwrap();\n        let out = out.map(ToString::to_string);\n        assert_eq!(n.clone().checked_sqrt().map(|x| x.to_string()), out);\n        assert_eq!((&n).checked_sqrt().map(|x| x.to_string()), out);\n    };\n    test(\"0\", Some(\"0\"));\n    test(\"1\", Some(\"1\"));\n    test(\"2\", None);\n    test(\"3\", None);\n    test(\"4\", Some(\"2\"));\n    test(\"5\", None);\n    test(\"22/7\", None);\n    test(\"4/9\", Some(\"2/3\"));\n}\n\n#[test]\n#[should_panic]\nfn checked_sqrt_fail() {\n    Rational::NEGATIVE_ONE.checked_sqrt();\n}\n\n#[test]\n#[should_panic]\nfn checked_sqrt_ref_fail() {\n    (&Rational::NEGATIVE_ONE).checked_sqrt();\n}\n\n#[test]\nfn checked_sqrt_properties() {\n    rational_gen_var_3().test_properties(|n| {\n        let sqrt = n.clone().checked_sqrt();\n        assert!(sqrt.as_ref().is_none_or(Rational::is_valid));\n        let sqrt_alt = (&n).checked_sqrt();\n        assert!(sqrt_alt.as_ref().is_none_or(Rational::is_valid));\n        assert_eq!(sqrt_alt, sqrt);\n        if n != 0 {\n            assert_eq!(\n                (&n).reciprocal().checked_sqrt(),\n                sqrt.as_ref().map(Reciprocal::reciprocal)\n            );\n        }\n        if let Some(sqrt) = sqrt {\n            assert_eq!((&sqrt).square(), n);\n        }\n    });\n\n    integer_gen_var_4().test_properties(|n| {\n        assert_eq!(\n            (&n).checked_sqrt().map(Rational::from),\n            Rational::from(n).checked_sqrt()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/square.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, CheckedSqrt, Square, SquareAssign};\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_square() {\n    let test = |x, out| {\n        let u = Rational::from_str(x).unwrap();\n\n        assert_eq!(u.clone().square().to_string(), out);\n        assert_eq!((&u).square().to_string(), out);\n\n        let mut x = u;\n        x.square_assign();\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"10\", \"100\");\n    test(\"123\", \"15129\");\n    test(\"1/2\", \"1/4\");\n    test(\"22/7\", \"484/49\");\n\n    test(\"-1\", \"1\");\n    test(\"-10\", \"100\");\n    test(\"-123\", \"15129\");\n    test(\"-1/2\", \"1/4\");\n    test(\"-22/7\", \"484/49\");\n}\n\n#[test]\nfn square_properties() {\n    rational_gen().test_properties(|x| {\n        let square = (&x).square();\n        assert!(square.is_valid());\n\n        let mut mut_x = x.clone();\n        mut_x.square_assign();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, square);\n\n        assert_eq!(&x * &x, square);\n        assert_eq!((-&x).square(), square);\n        assert!(square >= 0);\n        if x != 0 {\n            assert_eq!(square.cmp_abs(&x), x.partial_cmp_abs(&1).unwrap());\n        }\n        assert_eq!(square.checked_sqrt(), Some(x.abs()));\n    });\n\n    rational_pair_gen().test_properties(|(x, y)| {\n        let x_squared = (&x).square();\n        let y_squared = (&y).square();\n        let xy = &x * &y;\n        assert_eq!((&x + &y).square(), &x_squared + &y_squared + (&xy << 1));\n        assert_eq!((&x - &y).square(), &x_squared + &y_squared - (&xy << 1));\n        assert_eq!(xy.square(), x_squared * y_squared);\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!((&x).square(), Rational::from(x).square());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/arithmetic/sub.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::arithmetic::sub::sub_naive;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen};\nuse num::BigRational;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_sub() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n\n        let mut n = u.clone();\n        n -= v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let mut n = u.clone();\n        n -= &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() - v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u - v.clone();\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = u.clone() - &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = &u - &v;\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = BigRational::from_str(s).unwrap() - BigRational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n\n        let n = rug::Rational::from_str(s).unwrap() - rug::Rational::from_str(t).unwrap();\n        assert_eq!(n.to_string(), out);\n    };\n    test(\"0\", \"0\", \"0\");\n    test(\"0\", \"-123\", \"123\");\n    test(\"123\", \"0\", \"123\");\n    test(\"123\", \"-456\", \"579\");\n    test(\"0\", \"123\", \"-123\");\n    test(\"123\", \"123\", \"0\");\n    test(\"123\", \"456\", \"-333\");\n    test(\"0\", \"-123\", \"123\");\n    test(\"-123\", \"0\", \"-123\");\n    test(\"-123\", \"-456\", \"333\");\n    test(\"0\", \"123\", \"-123\");\n    test(\"-123\", \"-123\", \"0\");\n    test(\"1/2\", \"-1/3\", \"5/6\");\n    test(\"1/2\", \"1/3\", \"1/6\");\n    test(\"-1/2\", \"-1/3\", \"-1/6\");\n    test(\"-1/2\", \"1/3\", \"-5/6\");\n    test(\"1/2\", \"-1/2\", \"1\");\n    test(\"1/2\", \"1/2\", \"0\");\n    test(\"-1/2\", \"-1/2\", \"0\");\n    test(\"-1/2\", \"1/2\", \"-1\");\n}\n\n#[allow(clippy::eq_op)]\n#[test]\nfn sub_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let diff_val_val = x.clone() - y.clone();\n        let diff_val_ref = x.clone() - &y;\n        let diff_ref_val = &x - y.clone();\n        let diff = &x - &y;\n        assert!(diff_val_val.is_valid());\n        assert!(diff_val_ref.is_valid());\n        assert!(diff_ref_val.is_valid());\n        assert!(diff.is_valid());\n        assert_eq!(diff_val_val, diff);\n        assert_eq!(diff_val_ref, diff);\n        assert_eq!(diff_ref_val, diff);\n\n        let mut mut_x = x.clone();\n        mut_x -= y.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n        let mut mut_x = x.clone();\n        mut_x -= &y;\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, diff);\n\n        let mut mut_x = rug::Rational::from(&x);\n        mut_x -= rug::Rational::from(&y);\n        assert_eq!(Rational::from(&mut_x), diff);\n\n        assert_eq!(\n            Rational::from(&(BigRational::from(&x) - BigRational::from(&y))),\n            diff\n        );\n        assert_eq!(\n            Rational::from(&(rug::Rational::from(&x) - rug::Rational::from(&y))),\n            diff\n        );\n        assert_eq!(sub_naive(x.clone(), y.clone()), diff);\n        assert_eq!(&y - &x, -&diff);\n        assert_eq!(&diff + &y, x);\n        assert_eq!(x - diff, y);\n    });\n\n    rational_gen().test_properties(|ref x| {\n        assert_eq!(x - Rational::ZERO, *x);\n        assert_eq!(Rational::ZERO - x, -x);\n        assert_eq!(x - -x, x << 1);\n        assert_eq!(x - x, 0);\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        if x >= y {\n            assert_eq!(&x - &y, Rational::from(x) - Rational::from(y));\n        } else {\n            assert_eq!(-(&y - &x), Rational::from(x) - Rational::from(y));\n        }\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/basic/constants.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{NegativeOne, One, OneHalf, Two, Zero};\nuse malachite_q::Rational;\n\n#[test]\nfn test_zero() {\n    let zero = Rational::ZERO;\n    assert!(zero.is_valid());\n    assert_eq!(zero, 0);\n    assert_eq!(zero.to_string(), \"0\");\n}\n\n#[test]\nfn test_one() {\n    let one = Rational::ONE;\n    assert!(one.is_valid());\n    assert_eq!(one, 1);\n    assert_eq!(one.to_string(), \"1\");\n}\n\n#[test]\nfn test_two() {\n    let two = Rational::TWO;\n    assert!(two.is_valid());\n    assert_eq!(two, 2);\n    assert_eq!(two.to_string(), \"2\");\n}\n\n#[test]\nfn test_negative_one() {\n    let negative_one = Rational::NEGATIVE_ONE;\n    assert!(negative_one.is_valid());\n    assert_eq!(negative_one, -1);\n    assert_eq!(negative_one.to_string(), \"-1\");\n}\n\n#[test]\nfn test_one_half() {\n    let one_half = Rational::ONE_HALF;\n    assert!(one_half.is_valid());\n    assert_eq!(one_half.to_string(), \"1/2\");\n}\n"
  },
  {
    "path": "malachite-q/tests/basic/default.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_q::Rational;\n\n#[test]\nfn test_default() {\n    let default = Rational::default();\n    assert!(default.is_valid());\n    assert_eq!(default, 0);\n    assert_eq!(default.to_string(), \"0\");\n}\n"
  },
  {
    "path": "malachite-q/tests/basic/named.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::named::Named;\nuse malachite_q::Rational;\n\n#[test]\nfn test_named() {\n    assert_eq!(Rational::NAME, \"Rational\");\n}\n"
  },
  {
    "path": "malachite-q/tests/basic/significant_bits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::logic::traits::SignificantBits;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_significant_bits() {\n    let test = |n, out| {\n        assert_eq!(Rational::from_str(n).unwrap().significant_bits(), out);\n    };\n    test(\"0\", 1);\n    test(\"1\", 2);\n    test(\"-1\", 2);\n    test(\"2/3\", 4);\n    test(\"-2/3\", 4);\n    test(\"100/101\", 14);\n    test(\"-100/101\", 14);\n    test(\"22/7\", 8);\n    test(\"-22/7\", 8);\n}\n\n#[test]\nfn significant_bits_properties() {\n    rational_gen().test_properties(|x| {\n        let bits = x.significant_bits();\n        assert!(bits > 0);\n        assert_eq!((-x).significant_bits(), bits);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(\n            Rational::from(&n).significant_bits(),\n            n.significant_bits() + 1\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/basic/size.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_q::Rational;\nuse std::mem::size_of;\n\n#[test]\nfn test_size() {\n    if size_of::<usize>() == 8 {\n        assert_eq!(size_of::<Rational>(), 56);\n    }\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/cmp.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::common::test_cmp_helper;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen, rational_triple_gen};\nuse num::BigRational;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_cmp() {\n    let strings = &[\n        \"-1000000000001\",\n        \"-1000000000000\",\n        \"-999999999999\",\n        \"-123\",\n        \"-2\",\n        \"-7/5\",\n        \"-1\",\n        \"-5/7\",\n        \"-3/8\",\n        \"-123/1000000\",\n        \"-1237/1000000000000\",\n        \"0\",\n        \"1237/1000000000000\",\n        \"123/1000000\",\n        \"3/8\",\n        \"5/7\",\n        \"1\",\n        \"7/5\",\n        \"2\",\n        \"123\",\n        \"999999999999\",\n        \"1000000000000\",\n        \"1000000000001\",\n    ];\n    test_cmp_helper::<Rational>(strings);\n    test_cmp_helper::<BigRational>(strings);\n    test_cmp_helper::<rug::Rational>(strings);\n}\n\n#[test]\nfn cmp_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let ord = x.cmp(&y);\n        assert_eq!(BigRational::from(&x).cmp(&BigRational::from(&y)), ord);\n        assert_eq!(rug::Rational::from(&x).cmp(&rug::Rational::from(&y)), ord);\n        assert_eq!(y.cmp(&x).reverse(), ord);\n        assert_eq!(x == y, x.cmp(&y) == Equal);\n        assert_eq!((-y).cmp(&-x), ord);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!(x.cmp(&x), Equal);\n    });\n\n    rational_triple_gen().test_properties(|(x, y, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).cmp(&Rational::from(&y)), x.cmp(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/cmp_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::test_util::common::test_custom_cmp_helper;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen, rational_triple_gen};\nuse rug;\nuse std::cmp::Ordering::*;\n\n#[test]\nfn test_ord_abs() {\n    let strings = &[\n        \"0\",\n        \"1237/1000000000000\",\n        \"-123/1000000\",\n        \"3/8\",\n        \"-5/7\",\n        \"1\",\n        \"-7/5\",\n        \"2\",\n        \"-123\",\n        \"999999999999\",\n        \"-1000000000000\",\n        \"1000000000001\",\n    ];\n    test_custom_cmp_helper::<Rational, _>(strings, OrdAbs::cmp_abs);\n    test_custom_cmp_helper::<rug::Rational, _>(strings, rug::Rational::cmp_abs);\n}\n\n#[test]\nfn cmp_abs_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let ord = x.cmp_abs(&y);\n        assert_eq!(\n            rug::Rational::from(&x).cmp_abs(&rug::Rational::from(&y)),\n            ord\n        );\n        assert_eq!((&x).abs().cmp(&(&y).abs()), ord);\n        assert_eq!((-x).cmp_abs(&(-y)), ord);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!(x.cmp_abs(&x), Equal);\n        assert_eq!(x.cmp_abs(&-&x), Equal);\n    });\n\n    rational_triple_gen().test_properties(|(x, y, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(\n            Rational::from(&x).cmp_abs(&Rational::from(&y)),\n            x.cmp_abs(&y)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/eq.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::common::test_eq_helper;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen, rational_triple_gen};\nuse num::BigRational;\nuse rug;\n\n#[test]\nfn test_eq() {\n    let strings = &[\n        \"-1000000000001\",\n        \"-1000000000000\",\n        \"-999999999999\",\n        \"-123\",\n        \"-2\",\n        \"-7/5\",\n        \"-1\",\n        \"-5/7\",\n        \"-3/8\",\n        \"-123/1000000\",\n        \"-1237/1000000000000\",\n        \"0\",\n        \"1237/1000000000000\",\n        \"123/1000000\",\n        \"3/8\",\n        \"5/7\",\n        \"1\",\n        \"7/5\",\n        \"2\",\n        \"123\",\n        \"999999999999\",\n        \"1000000000000\",\n        \"1000000000001\",\n    ];\n    test_eq_helper::<Rational>(strings);\n    test_eq_helper::<BigRational>(strings);\n    test_eq_helper::<rug::Rational>(strings);\n}\n\n#[allow(clippy::cmp_owned, clippy::eq_op)]\n#[test]\nfn eq_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let eq = x == y;\n        assert_eq!(BigRational::from(&x) == BigRational::from(&y), eq);\n        assert_eq!(rug::Rational::from(&x) == rug::Rational::from(&y), eq);\n        assert_eq!(y == x, eq);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert_eq!(x, x);\n    });\n\n    rational_triple_gen().test_properties(|(x, y, z)| {\n        if x == y && y == z {\n            assert_eq!(x, z);\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x) == Rational::from(&y), x == y);\n        assert_eq!(Rational::from(&x) == y, x == y);\n        assert_eq!(x == Rational::from(&y), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/eq_abs.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::cmp::Ordering::*;\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{EqAbs, OrdAbs};\nuse malachite_base::test_util::generators::signed_pair_gen;\nuse malachite_nz::platform::SignedLimb;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen, rational_triple_gen};\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs() {\n    let test = |s, t, eq: bool| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Rational::from_str(t).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == (&v).abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"124\", false);\n    test(\"123\", \"122\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"1000000000000\", \"0\", false);\n    test(\"22/7\", \"0\", false);\n    test(\"22/7\", \"22/7\", true);\n    test(\"22/7\", \"23/7\", false);\n\n    test(\"-123\", \"123\", true);\n    test(\"-123\", \"124\", false);\n    test(\"-123\", \"122\", false);\n    test(\"-1000000000000\", \"123\", false);\n    test(\"-123\", \"1000000000000\", false);\n    test(\"-1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"0\", false);\n    test(\"-22/7\", \"0\", false);\n    test(\"-22/7\", \"22/7\", true);\n    test(\"-22/7\", \"23/7\", false);\n\n    test(\"0\", \"-5\", false);\n    test(\"123\", \"-123\", true);\n    test(\"123\", \"-124\", false);\n    test(\"123\", \"-122\", false);\n    test(\"1000000000000\", \"-123\", false);\n    test(\"123\", \"-1000000000000\", false);\n    test(\"1000000000000\", \"-1000000000000\", true);\n    test(\"22/7\", \"-22/7\", true);\n    test(\"22/7\", \"-23/7\", false);\n\n    test(\"-123\", \"-123\", true);\n    test(\"-123\", \"-124\", false);\n    test(\"-123\", \"-122\", false);\n    test(\"-1000000000000\", \"-123\", false);\n    test(\"-123\", \"-1000000000000\", false);\n    test(\"-1000000000000\", \"-1000000000000\", true);\n    test(\"-22/7\", \"-22/7\", true);\n    test(\"-22/7\", \"-23/7\", false);\n}\n\n#[allow(clippy::cmp_owned, clippy::eq_op)]\n#[test]\nfn eq_properties() {\n    rational_pair_gen().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs() == (&y).abs(), eq);\n        assert_eq!(x.cmp_abs(&y) == Equal, eq);\n        assert_eq!(x.eq_abs(&-&y), eq);\n        assert_eq!((-&x).eq_abs(&y), eq);\n        assert_eq!((-x).eq_abs(&-y), eq);\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!(x.eq_abs(&x));\n    });\n\n    rational_triple_gen().test_properties(|(x, y, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x) == Rational::from(&y), x == y);\n        assert_eq!(Rational::from(&x) == y, x == y);\n        assert_eq!(x == Rational::from(&y), x == y);\n    });\n\n    signed_pair_gen::<SignedLimb>().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(x).eq_abs(&Rational::from(y)), x.eq_abs(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/eq_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_integer_integer_triple_gen, rational_integer_pair_gen,\n    rational_rational_integer_triple_gen,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_rational_integer() {\n    let test = |s, t, eq: bool| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == (&v).abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"124\", false);\n    test(\"123\", \"122\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"1000000000000\", \"0\", false);\n    test(\"22/7\", \"0\", false);\n    test(\"22/7\", \"123\", false);\n    test(\"-22/7\", \"123\", false);\n\n    test(\"-123\", \"123\", true);\n    test(\"-123\", \"124\", false);\n    test(\"-123\", \"122\", false);\n    test(\"-1000000000000\", \"123\", false);\n    test(\"-123\", \"1000000000000\", false);\n    test(\"-1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"0\", false);\n\n    test(\"0\", \"-5\", false);\n    test(\"123\", \"-123\", true);\n    test(\"123\", \"-124\", false);\n    test(\"123\", \"-122\", false);\n    test(\"1000000000000\", \"-123\", false);\n    test(\"123\", \"-1000000000000\", false);\n    test(\"1000000000000\", \"-1000000000000\", true);\n    test(\"22/7\", \"-123\", false);\n    test(\"-22/7\", \"-123\", false);\n\n    test(\"-123\", \"-123\", true);\n    test(\"-123\", \"-124\", false);\n    test(\"-123\", \"-122\", false);\n    test(\"-1000000000000\", \"-123\", false);\n    test(\"-123\", \"-1000000000000\", false);\n    test(\"-1000000000000\", \"-1000000000000\", true);\n}\n\n#[test]\nfn eq_abs_integer_properties() {\n    rational_integer_pair_gen().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.eq_abs(&Rational::from(&y)), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs() == (&y).abs(), eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!((-&x).eq_abs(&y), eq);\n        assert_eq!(x.eq_abs(&-&y), eq);\n        assert_eq!((-x).eq_abs(&-y), eq);\n    });\n\n    rational_rational_integer_triple_gen().test_properties(|(x, z, y)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    rational_integer_integer_triple_gen().test_properties(|(y, x, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).eq_abs(&y), x.eq_abs(&y));\n        assert_eq!(x.eq_abs(&Rational::from(&y)), x.eq_abs(&y));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/eq_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::EqAbs;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_natural_natural_triple_gen, rational_natural_pair_gen,\n    rational_rational_natural_triple_gen,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_rational_natural() {\n    let test = |s, t, eq: bool| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"124\", false);\n    test(\"123\", \"122\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"1000000000000\", \"0\", false);\n    test(\"22/7\", \"0\", false);\n    test(\"22/7\", \"123\", false);\n    test(\"-22/7\", \"123\", false);\n\n    test(\"-123\", \"123\", true);\n    test(\"-123\", \"124\", false);\n    test(\"-123\", \"122\", false);\n    test(\"-1000000000000\", \"123\", false);\n    test(\"-123\", \"1000000000000\", false);\n    test(\"-1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"0\", false);\n}\n\n#[test]\nfn eq_abs_natural_properties() {\n    rational_natural_pair_gen().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.eq_abs(&Rational::from(&y)), eq);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs() == y, eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!((-x).eq_abs(&y), eq);\n    });\n\n    rational_rational_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert!(x.eq_abs(&z));\n        }\n    });\n\n    rational_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x.eq_abs(&y) && y.eq_abs(&z) {\n            assert_eq!(x, z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).eq_abs(&y), x == y);\n        assert_eq!(x.eq_abs(&Rational::from(&y)), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/eq_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_primitive_float_pair_gen};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_f32() {\n    let test = |u, v: f32, eq: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"3/2\", 1.5, true);\n    test(\"3/2\", -1.5, true);\n    test(\"3/2\", 2.5, false);\n    test(\"3/2\", -2.5, false);\n    test(\"1000000000000\", 123.0, false);\n    test(\"1000000000000\", -123.0, false);\n    test(\"1\", 0.5, false);\n    test(\"1\", -0.5, false);\n    test(\"1\", f32::INFINITY, false);\n    test(\"1\", f32::NEGATIVE_INFINITY, false);\n    test(\"1\", f32::NAN, false);\n    test(\"-3/2\", 1.5, true);\n    test(\"-3/2\", -1.5, true);\n    test(\"-3/2\", 2.5, false);\n    test(\"-3/2\", -2.5, false);\n    test(\"-1000000000000\", 123.0, false);\n    test(\"-1000000000000\", -123.0, false);\n    test(\"-1\", 0.5, false);\n    test(\"-1\", -0.5, false);\n    test(\"-1\", f32::INFINITY, false);\n    test(\"-1\", f32::NEGATIVE_INFINITY, false);\n    test(\"-1\", f32::NAN, false);\n}\n\n#[test]\nfn test_eq_abs_f64() {\n    let test = |u, v: f64, eq: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"3/2\", 1.5, true);\n    test(\"3/2\", -1.5, true);\n    test(\"3/2\", 2.5, false);\n    test(\"3/2\", -2.5, false);\n    test(\"1000000000000\", 123.0, false);\n    test(\"1000000000000\", -123.0, false);\n    test(\"1\", 0.5, false);\n    test(\"1\", -0.5, false);\n    test(\"1\", f64::INFINITY, false);\n    test(\"1\", f64::NEGATIVE_INFINITY, false);\n    test(\"1\", f64::NAN, false);\n    test(\"-3/2\", 1.5, true);\n    test(\"-3/2\", -1.5, true);\n    test(\"-3/2\", 2.5, false);\n    test(\"-3/2\", -2.5, false);\n    test(\"-1000000000000\", 123.0, false);\n    test(\"-1000000000000\", -123.0, false);\n    test(\"-1\", 0.5, false);\n    test(\"-1\", -0.5, false);\n    test(\"-1\", f64::INFINITY, false);\n    test(\"-1\", f64::NEGATIVE_INFINITY, false);\n    test(\"-1\", f64::NAN, false);\n}\n\nfn eq_abs_primitive_float_properties_helper<\n    T: EqAbs<Rational> + PartialEq<Rational> + PrimitiveFloat,\n>()\nwhere\n    Rational: EqAbs<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    rational_primitive_float_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs() == y.abs(), eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.partial_cmp_abs(&y) == Some(Equal), eq);\n    });\n\n    rational_gen().test_properties(|n| {\n        assert_ne!(n, T::NAN);\n        assert_ne!(n, T::INFINITY);\n        assert_ne!(n, T::NEGATIVE_INFINITY);\n    });\n}\n\n#[test]\nfn eq_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(eq_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/eq_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::{EqAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_pair_gen_var_7, unsigned_pair_gen_var_27};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_signed_pair_gen, rational_unsigned_pair_gen};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_eq_abs_u32() {\n    let test = |u, v: u32, eq: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 123, false);\n    test(\"22/7\", 123, false);\n    test(\"-22/7\", 123, false);\n}\n\n#[test]\nfn test_eq_abs_u64() {\n    let test = |u, v: u64, eq: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v, eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", 1000000000001, false);\n    test(\"-1000000000000000000000000\", 1000000000000, false);\n    test(\"22/7\", 1000000000000, false);\n    test(\"-22/7\", 1000000000000, false);\n}\n\n#[test]\nfn test_eq_abs_i32() {\n    let test = |u, v: i32, eq: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.unsigned_abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 123, false);\n    test(\"22/7\", 123, false);\n    test(\"-22/7\", 123, false);\n}\n\n#[test]\nfn test_eq_abs_i64() {\n    let test = |u, v: i64, eq: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.eq_abs(&v), eq);\n        assert_eq!(u.ne_abs(&v), !eq);\n        assert_eq!((&u).abs() == v.unsigned_abs(), eq);\n        assert_eq!(v.eq_abs(&u), eq);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"123\", -123, true);\n    test(\"123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 5, false);\n    test(\"-1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", 1000000000001, false);\n    test(\"-1000000000000000000000000\", 1000000000000, false);\n    test(\"22/7\", 1000000000000, false);\n    test(\"-22/7\", 1000000000000, false);\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn eq_abs_primitive_int_properties_helper_unsigned<\n    T: EqAbs<Rational> + PartialEq<Rational> + PrimitiveUnsigned,\n>()\nwhere\n    Rational: EqAbs<T> + PartialEq<T> + From<T> + PartialEq<T> + PartialOrdAbs<T>,\n{\n    rational_unsigned_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs().eq_abs(&y), eq);\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(x.partial_cmp_abs(&y) == Some(Equal), eq);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(x).eq_abs(&y), x == y);\n        assert_eq!(x.eq_abs(&Rational::from(y)), x == y);\n    });\n}\n\nfn eq_abs_primitive_int_properties_helper_signed<T: EqAbs<Rational> + PrimitiveSigned>()\nwhere\n    Rational:\n        EqAbs<T> + PartialEq<<T as UnsignedAbs>::Output> + From<T> + TryFrom<T> + PartialOrdAbs<T>,\n{\n    rational_signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let eq = x.eq_abs(&y);\n        assert_eq!(x.ne_abs(&y), !eq);\n        assert_eq!((&x).abs() == y.unsigned_abs(), eq);\n        assert_eq!(\n            <Rational as EqAbs<Rational>>::eq_abs(&x, &Rational::from(y)),\n            eq\n        );\n        assert_eq!(y.eq_abs(&x), eq);\n        assert_eq!(\n            <Rational as EqAbs<Rational>>::eq_abs(&Rational::from(y), &x),\n            eq\n        );\n        assert_eq!(x.partial_cmp_abs(&y) == Some(Equal), eq);\n    });\n\n    signed_pair_gen_var_7::<T>().test_properties(|(x, y)| {\n        assert_eq!(Rational::exact_from(x).eq_abs(&y), x.eq_abs(&y));\n        assert_eq!(x.eq_abs(&Rational::exact_from(y)), x.eq_abs(&y));\n    });\n}\n\n#[test]\nfn eq_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(eq_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(eq_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/hash.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::hash::hash;\nuse malachite_q::test_util::generators::rational_gen;\n\n#[test]\nfn hash_properties() {\n    rational_gen().test_properties(|x| {\n        assert_eq!(hash(&x), hash(&x.clone()));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_abs_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_integer_integer_triple_gen, rational_integer_pair_gen,\n    rational_rational_integer_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_rational_integer() {\n    let test = |s, t, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&(&v).abs()), cmp);\n        assert_eq!(v.partial_cmp_abs(&u).map(Ordering::reverse), cmp);\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", \"0\", Some(Equal), false, false, true, true);\n    test(\"0\", \"5\", Some(Less), true, false, true, false);\n    test(\"123\", \"123\", Some(Equal), false, false, true, true);\n    test(\"123\", \"124\", Some(Less), true, false, true, false);\n    test(\"123\", \"122\", Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        \"123\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\"123\", \"1000000000000\", Some(Less), true, false, true, false);\n    test(\n        \"1000000000000\",\n        \"1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        \"1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        \"0\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n\n    test(\"0\", \"-5\", Some(Less), true, false, true, false);\n    test(\"-123\", \"-123\", Some(Equal), false, false, true, true);\n    test(\"-123\", \"-124\", Some(Less), true, false, true, false);\n    test(\"-123\", \"-122\", Some(Greater), false, true, false, true);\n    test(\n        \"-1000000000000\",\n        \"-123\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-123\",\n        \"-1000000000000\",\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"-1000000000000\",\n        \"-1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        \"-1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        \"0\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n\n    test(\"99/100\", \"1\", Some(Less), true, false, true, false);\n    test(\"101/100\", \"1\", Some(Greater), false, true, false, true);\n    test(\"22/7\", \"3\", Some(Greater), false, true, false, true);\n    test(\"22/7\", \"4\", Some(Less), true, false, true, false);\n    test(\"-99/100\", \"-1\", Some(Less), true, false, true, false);\n    test(\"-101/100\", \"-1\", Some(Greater), false, true, false, true);\n    test(\"-22/7\", \"-3\", Some(Greater), false, true, false, true);\n    test(\"-22/7\", \"-4\", Some(Less), true, false, true, false);\n}\n\n#[test]\nfn partial_cmp_abs_integer_properties() {\n    rational_integer_pair_gen().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp_abs(&y);\n        assert_eq!((&x).abs().partial_cmp(&(&y).abs()), cmp);\n        assert_eq!(x.cmp_abs(&Rational::from(&y)), cmp.unwrap());\n        assert_eq!(y.partial_cmp_abs(&x), cmp.map(Ordering::reverse));\n    });\n\n    rational_rational_integer_triple_gen().test_properties(|(x, z, y)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    rational_integer_integer_triple_gen().test_properties(|(y, x, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).partial_cmp_abs(&y), Some(x.cmp_abs(&y)));\n        assert_eq!(x.partial_cmp_abs(&Rational::from(&y)), Some(x.cmp_abs(&y)));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_abs_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_natural_natural_triple_gen, rational_natural_pair_gen,\n    rational_rational_natural_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_rational_natural() {\n    let test = |s, t, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v), cmp);\n        assert_eq!(v.partial_cmp_abs(&u).map(Ordering::reverse), cmp);\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", \"0\", Some(Equal), false, false, true, true);\n    test(\"0\", \"5\", Some(Less), true, false, true, false);\n    test(\"123\", \"123\", Some(Equal), false, false, true, true);\n    test(\"123\", \"124\", Some(Less), true, false, true, false);\n    test(\"123\", \"122\", Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        \"123\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\"123\", \"1000000000000\", Some(Less), true, false, true, false);\n    test(\n        \"1000000000000\",\n        \"1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        \"1000000000000\",\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        \"0\",\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n\n    test(\"99/100\", \"1\", Some(Less), true, false, true, false);\n    test(\"101/100\", \"1\", Some(Greater), false, true, false, true);\n    test(\"22/7\", \"3\", Some(Greater), false, true, false, true);\n    test(\"22/7\", \"4\", Some(Less), true, false, true, false);\n    test(\"-99/100\", \"1\", Some(Less), true, false, true, false);\n    test(\"-101/100\", \"1\", Some(Greater), false, true, false, true);\n    test(\"-22/7\", \"3\", Some(Greater), false, true, false, true);\n    test(\"-22/7\", \"4\", Some(Less), true, false, true, false);\n}\n\n#[test]\nfn partial_cmp_abs_natural_properties() {\n    rational_natural_pair_gen().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp_abs(&y);\n        assert_eq!((&x).abs().partial_cmp(&y), cmp);\n        assert_eq!(x.cmp_abs(&Rational::from(&y)), cmp.unwrap());\n        assert_eq!(y.partial_cmp_abs(&x), cmp.map(Ordering::reverse));\n    });\n\n    rational_rational_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x.lt_abs(&z));\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x.gt_abs(&z));\n        }\n    });\n\n    rational_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x.lt_abs(&y) && y.lt_abs(&z) {\n            assert!(x < z);\n        } else if x.gt_abs(&y) && y.gt_abs(&z) {\n            assert!(x > z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).partial_cmp_abs(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp_abs(&Rational::from(&y)), Some(x.cmp(&y)));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_abs_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Abs;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_q::Rational;\nuse malachite_q::conversion::from_primitive_float::RationalFromPrimitiveFloatError;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_primitive_float_pair_gen,\n    rational_primitive_float_primitive_float_triple_gen,\n    rational_rational_primitive_float_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_primitive_float() {\n    let test = |u, v: f32, cmp: Option<Ordering>| {\n        let u = Rational::from_str(u).unwrap();\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v.abs()), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp_rev);\n\n        let v = f64::from(v);\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v.abs()), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp_rev);\n    };\n    test(\"2/3\", f32::NAN, None);\n    test(\"2/3\", f32::INFINITY, Some(Less));\n    test(\"2/3\", f32::NEGATIVE_INFINITY, Some(Less));\n    test(\"-2/3\", f32::NAN, None);\n    test(\"-2/3\", f32::INFINITY, Some(Less));\n    test(\"-2/3\", f32::NEGATIVE_INFINITY, Some(Less));\n\n    test(\"0\", 0.0, Some(Equal));\n    test(\"0\", -0.0, Some(Equal));\n    test(\"0\", 5.0, Some(Less));\n    test(\"0\", -5.0, Some(Less));\n    test(\"3/2\", 1.5, Some(Equal));\n    test(\"3/2\", 5.0, Some(Less));\n    test(\"3/2\", -5.0, Some(Less));\n    test(\"-3/2\", 5.0, Some(Less));\n    test(\"-3/2\", -5.0, Some(Less));\n    test(\"-3/2\", -1.5, Some(Equal));\n\n    test(\"1/3\", 0.333, Some(Greater));\n    test(\"1/3\", 0.334, Some(Less));\n    test(\"1/3\", -0.333, Some(Greater));\n    test(\"1/3\", -0.334, Some(Less));\n    test(\"-1/3\", -0.334, Some(Less));\n    test(\"-1/3\", -0.333, Some(Greater));\n    test(\"-1/3\", 0.334, Some(Less));\n    test(\"-1/3\", 0.333, Some(Greater));\n}\n\nfn partial_cmp_abs_primitive_float_properties_helper<T: PartialOrdAbs<Rational> + PrimitiveFloat>()\nwhere\n    Rational:\n        TryFrom<T, Error = RationalFromPrimitiveFloatError> + PartialOrd<T> + PartialOrdAbs<T>,\n{\n    rational_primitive_float_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp_abs = n.partial_cmp_abs(&u);\n        let cmp_abs_rev = cmp_abs.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp_abs(&n), cmp_abs_rev);\n        assert_eq!((&n).abs().partial_cmp(&u.abs()), cmp_abs);\n\n        if u.is_finite() {\n            assert_eq!(n.cmp_abs(&Rational::exact_from(u)), cmp_abs.unwrap());\n        }\n    });\n\n    rational_rational_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Less);\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Greater);\n        }\n    });\n\n    rational_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(u.abs() < v.abs());\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(u.abs() > v.abs());\n        }\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!(x.ge_abs(&T::ZERO));\n        assert!(x.lt_abs(&T::NEGATIVE_INFINITY));\n        assert!(x.lt_abs(&T::INFINITY));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_abs_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_abs_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::{OrdAbs, PartialOrdAbs};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{integer_pair_gen, natural_pair_gen};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_rational_signed_triple_gen, rational_rational_unsigned_triple_gen,\n    rational_signed_pair_gen, rational_signed_signed_triple_gen, rational_unsigned_pair_gen,\n    rational_unsigned_unsigned_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_abs_u32() {\n    let test = |s, v: u32, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n\n    test(\"99/100\", 1, Some(Less), true, false, true, false);\n    test(\"101/100\", 1, Some(Greater), false, true, false, true);\n    test(\"22/7\", 3, Some(Greater), false, true, false, true);\n    test(\"22/7\", 4, Some(Less), true, false, true, false);\n    test(\"-99/100\", 1, Some(Less), true, false, true, false);\n    test(\"-101/100\", 1, Some(Greater), false, true, false, true);\n    test(\"-22/7\", 3, Some(Greater), false, true, false, true);\n    test(\"-22/7\", 4, Some(Less), true, false, true, false);\n}\n\n#[test]\nfn test_partial_cmp_abs_u64() {\n    let test = |u, v: u64, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n\n    test(\"99/100\", 1, Some(Less), true, false, true, false);\n    test(\"101/100\", 1, Some(Greater), false, true, false, true);\n    test(\"22/7\", 3, Some(Greater), false, true, false, true);\n    test(\"22/7\", 4, Some(Less), true, false, true, false);\n    test(\"-99/100\", 1, Some(Less), true, false, true, false);\n    test(\"-101/100\", 1, Some(Greater), false, true, false, true);\n    test(\"-22/7\", 3, Some(Greater), false, true, false, true);\n    test(\"-22/7\", 4, Some(Less), true, false, true, false);\n}\n\n#[test]\nfn test_partial_cmp_abs_i32() {\n    let test = |u, v: i32, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v.abs()), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"0\", -5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", -123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", -123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", -124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", -124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"123\", -122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", -122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n\n    test(\"99/100\", 1, Some(Less), true, false, true, false);\n    test(\"101/100\", 1, Some(Greater), false, true, false, true);\n    test(\"22/7\", 3, Some(Greater), false, true, false, true);\n    test(\"22/7\", 4, Some(Less), true, false, true, false);\n    test(\"-99/100\", -1, Some(Less), true, false, true, false);\n    test(\"-101/100\", -1, Some(Greater), false, true, false, true);\n    test(\"-22/7\", -3, Some(Greater), false, true, false, true);\n    test(\"-22/7\", -4, Some(Less), true, false, true, false);\n}\n\n#[test]\nfn test_partial_cmp_abs_i64() {\n    let test = |u, v: i64, cmp, lt: bool, gt: bool, le: bool, ge: bool| {\n        let u = Rational::from_str(u).unwrap();\n        assert_eq!(u.partial_cmp_abs(&v), cmp);\n        assert_eq!((&u).abs().partial_cmp(&v.abs()), cmp);\n        assert_eq!(v.partial_cmp_abs(&u), cmp.map(Ordering::reverse));\n        assert_eq!(lt, u.lt_abs(&v));\n        assert_eq!(gt, u.gt_abs(&v));\n        assert_eq!(le, u.le_abs(&v));\n        assert_eq!(ge, u.ge_abs(&v));\n        assert_eq!(lt, v.gt_abs(&u));\n        assert_eq!(gt, v.lt_abs(&u));\n        assert_eq!(le, v.ge_abs(&u));\n        assert_eq!(ge, v.le_abs(&u));\n    };\n    test(\"0\", 0, Some(Equal), false, false, true, true);\n    test(\"0\", 5, Some(Less), true, false, true, false);\n    test(\"0\", -5, Some(Less), true, false, true, false);\n    test(\"123\", 123, Some(Equal), false, false, true, true);\n    test(\"123\", -123, Some(Equal), false, false, true, true);\n    test(\"-123\", 123, Some(Equal), false, false, true, true);\n    test(\"-123\", -123, Some(Equal), false, false, true, true);\n    test(\"123\", 124, Some(Less), true, false, true, false);\n    test(\"123\", -124, Some(Less), true, false, true, false);\n    test(\"-123\", 124, Some(Less), true, false, true, false);\n    test(\"-123\", -124, Some(Less), true, false, true, false);\n    test(\"123\", 122, Some(Greater), false, true, false, true);\n    test(\"123\", -122, Some(Greater), false, true, false, true);\n    test(\"-123\", 122, Some(Greater), false, true, false, true);\n    test(\"-123\", -122, Some(Greater), false, true, false, true);\n    test(\n        \"1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        -123,\n        Some(Greater),\n        false,\n        true,\n        false,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        -1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"-1000000000000\",\n        -1000000000000,\n        Some(Equal),\n        false,\n        false,\n        true,\n        true,\n    );\n    test(\n        \"1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"1000000000000\",\n        -1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"-1000000000000\",\n        1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n    test(\n        \"-1000000000000\",\n        -1000000000001,\n        Some(Less),\n        true,\n        false,\n        true,\n        false,\n    );\n\n    test(\"99/100\", 1, Some(Less), true, false, true, false);\n    test(\"101/100\", 1, Some(Greater), false, true, false, true);\n    test(\"22/7\", 3, Some(Greater), false, true, false, true);\n    test(\"22/7\", 4, Some(Less), true, false, true, false);\n    test(\"-99/100\", -1, Some(Less), true, false, true, false);\n    test(\"-101/100\", -1, Some(Greater), false, true, false, true);\n    test(\"-22/7\", -3, Some(Greater), false, true, false, true);\n    test(\"-22/7\", -4, Some(Less), true, false, true, false);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_abs_primitive_int_properties_helper_unsigned<\n    T: PartialOrdAbs<Rational> + PartialOrd<Rational> + PrimitiveUnsigned,\n>()\nwhere\n    Rational: From<T>\n        + for<'a> From<&'a Natural>\n        + PartialOrdAbs<T>\n        + PartialOrd<T>\n        + PartialOrdAbs<Natural>,\n{\n    rational_unsigned_pair_gen::<T>().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp_abs(&y);\n        assert_eq!(Some(x.cmp_abs(&Rational::from(y))), cmp);\n        assert_eq!((&x).abs().partial_cmp(&y), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(y.partial_cmp_abs(&x), cmp_rev);\n        assert_eq!(Some(Rational::from(y).cmp_abs(&x)), cmp_rev);\n    });\n\n    rational_rational_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n.lt_abs(&u) && u.lt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Less);\n        } else if n.gt_abs(&u) && u.gt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Greater);\n        }\n    });\n\n    rational_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u.lt_abs(&n) && n.lt_abs(&v) {\n            assert!(u < v);\n        } else if u.gt_abs(&n) && n.gt_abs(&v) {\n            assert!(u > v);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(\n            PartialOrdAbs::<Natural>::partial_cmp_abs(&Rational::from(&x), &y),\n            Some(x.cmp(&y))\n        );\n        assert_eq!(x.partial_cmp_abs(&Rational::from(&y)), Some(x.cmp(&y)));\n    });\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_abs_primitive_int_properties_helper_signed<\n    T: PartialOrdAbs<Rational> + PartialOrd<rug::Rational> + PrimitiveSigned,\n>()\nwhere\n    Rational: From<T>\n        + for<'a> From<&'a Integer>\n        + PartialOrdAbs<T>\n        + PartialOrd<<T as UnsignedAbs>::Output>,\n    <T as UnsignedAbs>::Output: PartialOrd<Rational>,\n{\n    rational_signed_pair_gen::<T>().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp_abs(&y);\n        assert_eq!(Some(x.cmp_abs(&Rational::from(y))), cmp);\n        assert_eq!((&x).abs().partial_cmp(&y.unsigned_abs()), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(y.partial_cmp_abs(&x), cmp_rev);\n        assert_eq!(Some(Rational::from(y).cmp_abs(&x)), cmp_rev);\n    });\n\n    rational_rational_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n.lt_abs(&i) && i.lt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Less);\n        } else if n.gt_abs(&i) && i.gt_abs(&m) {\n            assert_eq!(n.cmp_abs(&m), Greater);\n        }\n    });\n\n    rational_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i.lt_abs(&n) && n.lt_abs(&j) {\n            assert!(i.lt_abs(&j));\n        } else if i.gt_abs(&n) && n.gt_abs(&j) {\n            assert!(i.gt_abs(&j));\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(\n            PartialOrdAbs::<Integer>::partial_cmp_abs(&Rational::from(&x), &y),\n            Some(x.cmp_abs(&y))\n        );\n        assert_eq!(x.partial_cmp_abs(&Rational::from(&y)), Some(x.cmp_abs(&y)));\n    });\n}\n\n#[test]\nfn partial_cmp_abs_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_abs_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_abs_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_integer_integer_triple_gen, rational_integer_pair_gen,\n    rational_rational_integer_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_integer() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u).map(Ordering::reverse), out);\n    };\n    test(\"0\", \"0\", Some(Equal));\n    test(\"0\", \"5\", Some(Less));\n    test(\"123\", \"123\", Some(Equal));\n    test(\"123\", \"124\", Some(Less));\n    test(\"123\", \"122\", Some(Greater));\n    test(\"1000000000000\", \"123\", Some(Greater));\n    test(\"123\", \"1000000000000\", Some(Less));\n    test(\"1000000000000\", \"1000000000000\", Some(Equal));\n    test(\"-1000000000000\", \"1000000000000\", Some(Less));\n    test(\"-1000000000000\", \"0\", Some(Less));\n\n    test(\"0\", \"-5\", Some(Greater));\n    test(\"-123\", \"-123\", Some(Equal));\n    test(\"-123\", \"-124\", Some(Greater));\n    test(\"-123\", \"-122\", Some(Less));\n    test(\"-1000000000000\", \"-123\", Some(Less));\n    test(\"-123\", \"-1000000000000\", Some(Greater));\n    test(\"-1000000000000\", \"-1000000000000\", Some(Equal));\n    test(\"1000000000000\", \"-1000000000000\", Some(Greater));\n    test(\"1000000000000\", \"0\", Some(Greater));\n\n    test(\"99/100\", \"1\", Some(Less));\n    test(\"101/100\", \"1\", Some(Greater));\n    test(\"22/7\", \"3\", Some(Greater));\n    test(\"22/7\", \"4\", Some(Less));\n    test(\"-99/100\", \"-1\", Some(Greater));\n    test(\"-101/100\", \"-1\", Some(Less));\n    test(\"-22/7\", \"-3\", Some(Less));\n    test(\"-22/7\", \"-4\", Some(Greater));\n}\n\n#[test]\nfn partial_cmp_integer_properties() {\n    rational_integer_pair_gen().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp(&y);\n        assert_eq!(x.cmp(&Rational::from(&y)), cmp.unwrap());\n        assert_eq!(\n            rug::Rational::from(&x).partial_cmp(&rug::Integer::from(&y)),\n            cmp\n        );\n        assert_eq!(y.partial_cmp(&x), cmp.map(Ordering::reverse));\n    });\n\n    rational_rational_integer_triple_gen().test_properties(|(x, z, y)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    rational_integer_integer_triple_gen().test_properties(|(y, x, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Rational::from(&y)), Some(x.cmp(&y)));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_natural_natural_triple_gen, rational_natural_pair_gen,\n    rational_rational_natural_triple_gen,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_natural() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u).map(Ordering::reverse), out);\n    };\n    test(\"0\", \"0\", Some(Equal));\n    test(\"0\", \"5\", Some(Less));\n    test(\"123\", \"123\", Some(Equal));\n    test(\"123\", \"124\", Some(Less));\n    test(\"123\", \"122\", Some(Greater));\n    test(\"1000000000000\", \"123\", Some(Greater));\n    test(\"123\", \"1000000000000\", Some(Less));\n    test(\"1000000000000\", \"1000000000000\", Some(Equal));\n    test(\"-1000000000000\", \"1000000000000\", Some(Less));\n    test(\"-1000000000000\", \"0\", Some(Less));\n\n    test(\"99/100\", \"1\", Some(Less));\n    test(\"101/100\", \"1\", Some(Greater));\n    test(\"22/7\", \"3\", Some(Greater));\n    test(\"22/7\", \"4\", Some(Less));\n    test(\"-99/100\", \"1\", Some(Less));\n    test(\"-101/100\", \"1\", Some(Less));\n    test(\"-22/7\", \"3\", Some(Less));\n    test(\"-22/7\", \"4\", Some(Less));\n}\n\n#[test]\nfn partial_cmp_natural_properties() {\n    rational_natural_pair_gen().test_properties(|(x, y)| {\n        let cmp = x.partial_cmp(&y);\n        assert_eq!(x.cmp(&Rational::from(&y)), cmp.unwrap());\n        assert_eq!(\n            rug::Rational::from(&x).partial_cmp(&rug::Integer::from(&y)),\n            cmp\n        );\n        assert_eq!(y.partial_cmp(&x), cmp.map(Ordering::reverse));\n    });\n\n    rational_rational_natural_triple_gen().test_properties(|(x, z, y)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    rational_natural_natural_triple_gen().test_properties(|(y, x, z)| {\n        if x < y && y < z {\n            assert!(x < z);\n        } else if x > y && y > z {\n            assert!(x > z);\n        }\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Rational::from(&y)), Some(x.cmp(&y)));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_primitive_float_pair_gen,\n    rational_primitive_float_primitive_float_triple_gen,\n    rational_rational_primitive_float_triple_gen,\n};\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_primitive_float() {\n    let test = |u, v: f32, out: Option<Ordering>| {\n        let out_rev = out.map(Ordering::reverse);\n        assert_eq!(Rational::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Rational::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(v.partial_cmp(&Rational::from_str(u).unwrap()), out_rev);\n        assert_eq!(v.partial_cmp(&rug::Rational::from_str(u).unwrap()), out_rev);\n\n        let v = f64::from(v);\n        assert_eq!(Rational::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Rational::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(v.partial_cmp(&Rational::from_str(u).unwrap()), out_rev);\n        assert_eq!(v.partial_cmp(&rug::Rational::from_str(u).unwrap()), out_rev);\n    };\n    test(\"2/3\", f32::NAN, None);\n    test(\"2/3\", f32::INFINITY, Some(Less));\n    test(\"2/3\", f32::NEGATIVE_INFINITY, Some(Greater));\n    test(\"-2/3\", f32::NAN, None);\n    test(\"-2/3\", f32::INFINITY, Some(Less));\n    test(\"-2/3\", f32::NEGATIVE_INFINITY, Some(Greater));\n\n    test(\"0\", 0.0, Some(Equal));\n    test(\"0\", -0.0, Some(Equal));\n    test(\"0\", 5.0, Some(Less));\n    test(\"0\", -5.0, Some(Greater));\n    test(\"3/2\", 1.5, Some(Equal));\n    test(\"3/2\", 5.0, Some(Less));\n    test(\"3/2\", -5.0, Some(Greater));\n    test(\"-3/2\", 5.0, Some(Less));\n    test(\"-3/2\", -5.0, Some(Greater));\n    test(\"-3/2\", -1.5, Some(Equal));\n\n    test(\"1/3\", 0.333, Some(Greater));\n    test(\"1/3\", 0.334, Some(Less));\n    test(\"1/3\", -0.333, Some(Greater));\n    test(\"1/3\", -0.334, Some(Greater));\n    test(\"-1/3\", -0.334, Some(Greater));\n    test(\"-1/3\", -0.333, Some(Less));\n    test(\"-1/3\", 0.334, Some(Less));\n    test(\"-1/3\", 0.333, Some(Less));\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_float_properties_helper<\n    T: PartialOrd<Rational> + PartialOrd<rug::Rational> + PrimitiveFloat,\n>()\nwhere\n    Rational: TryFrom<T> + PartialOrd<T>,\n    rug::Rational: PartialOrd<T>,\n{\n    rational_primitive_float_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp = n.partial_cmp(&u);\n        assert_eq!(rug::Rational::from(&n).partial_cmp(&u), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp(&n), cmp_rev);\n        assert_eq!(u.partial_cmp(&rug::Rational::from(&n)), cmp_rev);\n\n        if u.is_finite() {\n            assert_eq!(n.cmp(&Rational::exact_from(u)), cmp.unwrap());\n        }\n    });\n\n    rational_rational_primitive_float_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > u && u > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    rational_primitive_float_primitive_float_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    rational_gen().test_properties(|x| {\n        assert!(x > T::NEGATIVE_INFINITY);\n        assert!(x < T::INFINITY);\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_cmp_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_cmp_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_rational_signed_triple_gen, rational_rational_unsigned_triple_gen,\n    rational_signed_pair_gen, rational_signed_signed_triple_gen, rational_unsigned_pair_gen,\n    rational_unsigned_unsigned_triple_gen,\n};\nuse rug;\nuse std::cmp::Ordering::{self, *};\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_cmp_u32() {\n    let test = |s, v: u32, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(rug::Rational::from_str(s).unwrap().partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"123\", 123, Some(Equal));\n    test(\"-123\", 123, Some(Less));\n    test(\"123\", 124, Some(Less));\n    test(\"-123\", 124, Some(Less));\n    test(\"123\", 122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n\n    test(\"99/100\", 1, Some(Less));\n    test(\"101/100\", 1, Some(Greater));\n    test(\"22/7\", 3, Some(Greater));\n    test(\"22/7\", 4, Some(Less));\n    test(\"-99/100\", 1, Some(Less));\n    test(\"-101/100\", 1, Some(Less));\n    test(\"-22/7\", 3, Some(Less));\n    test(\"-22/7\", 4, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_u64() {\n    let test = |s, v: u64, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        assert_eq!(u.partial_cmp(&v), out);\n        assert_eq!(rug::Rational::from_str(s).unwrap().partial_cmp(&v), out);\n        assert_eq!(v.partial_cmp(&u), out.map(Ordering::reverse));\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"123\", 123, Some(Equal));\n    test(\"-123\", 123, Some(Less));\n    test(\"123\", 124, Some(Less));\n    test(\"-123\", 124, Some(Less));\n    test(\"123\", 122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n    test(\"1000000000000\", 1000000000000, Some(Equal));\n    test(\"-1000000000000\", 1000000000000, Some(Less));\n    test(\"1000000000000\", 1000000000001, Some(Less));\n    test(\"-1000000000000\", 1000000000001, Some(Less));\n\n    test(\"99/100\", 1, Some(Less));\n    test(\"101/100\", 1, Some(Greater));\n    test(\"22/7\", 3, Some(Greater));\n    test(\"22/7\", 4, Some(Less));\n    test(\"-99/100\", 1, Some(Less));\n    test(\"-101/100\", 1, Some(Less));\n    test(\"-22/7\", 3, Some(Less));\n    test(\"-22/7\", 4, Some(Less));\n}\n\n#[test]\nfn test_partial_cmp_i32() {\n    let test = |u, v: i32, out| {\n        assert_eq!(Rational::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Rational::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Rational::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"0\", -5, Some(Greater));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", -123, Some(Greater));\n    test(\"-123\", 123, Some(Less));\n    test(\"-123\", -123, Some(Equal));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", -124, Some(Greater));\n    test(\"-123\", 124, Some(Less));\n    test(\"-123\", -124, Some(Greater));\n    test(\"123\", 122, Some(Greater));\n    test(\"123\", -122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"-123\", -122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"1000000000000\", -123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n    test(\"-1000000000000\", -123, Some(Less));\n\n    test(\"99/100\", 1, Some(Less));\n    test(\"101/100\", 1, Some(Greater));\n    test(\"22/7\", 3, Some(Greater));\n    test(\"22/7\", 4, Some(Less));\n    test(\"-99/100\", -1, Some(Greater));\n    test(\"-101/100\", -1, Some(Less));\n    test(\"-22/7\", -3, Some(Less));\n    test(\"-22/7\", -4, Some(Greater));\n}\n\n#[test]\nfn test_partial_cmp_i64() {\n    let test = |u, v: i64, out| {\n        assert_eq!(Rational::from_str(u).unwrap().partial_cmp(&v), out);\n        assert_eq!(rug::Rational::from_str(u).unwrap().partial_cmp(&v), out);\n\n        assert_eq!(\n            v.partial_cmp(&Rational::from_str(u).unwrap()),\n            out.map(Ordering::reverse)\n        );\n    };\n    test(\"0\", 0, Some(Equal));\n    test(\"0\", 5, Some(Less));\n    test(\"0\", -5, Some(Greater));\n    test(\"123\", 123, Some(Equal));\n    test(\"123\", -123, Some(Greater));\n    test(\"-123\", 123, Some(Less));\n    test(\"-123\", -123, Some(Equal));\n    test(\"123\", 124, Some(Less));\n    test(\"123\", -124, Some(Greater));\n    test(\"-123\", 124, Some(Less));\n    test(\"-123\", -124, Some(Greater));\n    test(\"123\", 122, Some(Greater));\n    test(\"123\", -122, Some(Greater));\n    test(\"-123\", 122, Some(Less));\n    test(\"-123\", -122, Some(Less));\n    test(\"1000000000000\", 123, Some(Greater));\n    test(\"1000000000000\", -123, Some(Greater));\n    test(\"-1000000000000\", 123, Some(Less));\n    test(\"-1000000000000\", -123, Some(Less));\n    test(\"1000000000000\", 1000000000000, Some(Equal));\n    test(\"1000000000000\", -1000000000000, Some(Greater));\n    test(\"-1000000000000\", 1000000000000, Some(Less));\n    test(\"-1000000000000\", -1000000000000, Some(Equal));\n    test(\"1000000000000\", 1000000000001, Some(Less));\n    test(\"1000000000000\", -1000000000001, Some(Greater));\n    test(\"-1000000000000\", 1000000000001, Some(Less));\n    test(\"-1000000000000\", -1000000000001, Some(Greater));\n\n    test(\"99/100\", 1, Some(Less));\n    test(\"101/100\", 1, Some(Greater));\n    test(\"22/7\", 3, Some(Greater));\n    test(\"22/7\", 4, Some(Less));\n    test(\"-99/100\", -1, Some(Greater));\n    test(\"-101/100\", -1, Some(Less));\n    test(\"-22/7\", -3, Some(Less));\n    test(\"-22/7\", -4, Some(Greater));\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_unsigned<\n    T: PartialOrd<Rational> + PartialOrd<rug::Rational> + PrimitiveUnsigned,\n>()\nwhere\n    Rational: From<T> + PartialOrd<T>,\n    rug::Rational: PartialOrd<T>,\n{\n    rational_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let cmp = n.partial_cmp(&u);\n        assert_eq!(rug::Rational::from(&n).partial_cmp(&u), cmp);\n        assert_eq!(Some(n.cmp(&Rational::from(u))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(u.partial_cmp(&n), cmp_rev);\n        assert_eq!(u.partial_cmp(&rug::Rational::from(&n)), cmp_rev);\n        assert_eq!(Some(Rational::from(u).cmp(&n)), cmp_rev);\n    });\n\n    rational_rational_unsigned_triple_gen::<T>().test_properties(|(n, m, u)| {\n        if n < u && u < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > u && u > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    rational_unsigned_unsigned_triple_gen::<T>().test_properties(|(n, u, v)| {\n        if u < n && n < v {\n            assert!(u < v);\n        } else if u > n && n > v {\n            assert!(u > v);\n        }\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Rational::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn partial_cmp_primitive_int_properties_helper_signed<\n    T: PartialOrd<Rational> + PartialOrd<rug::Rational> + PrimitiveSigned,\n>()\nwhere\n    Rational: From<T> + PartialOrd<T>,\n    rug::Rational: PartialOrd<T>,\n{\n    rational_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let cmp = n.partial_cmp(&i);\n        assert_eq!(rug::Rational::from(&n).partial_cmp(&i), cmp);\n        assert_eq!(Some(n.cmp(&Rational::from(i))), cmp);\n\n        let cmp_rev = cmp.map(Ordering::reverse);\n        assert_eq!(i.partial_cmp(&n), cmp_rev);\n        assert_eq!(i.partial_cmp(&rug::Rational::from(&n)), cmp_rev);\n        assert_eq!(Some(Rational::from(i).cmp(&n)), cmp_rev);\n    });\n\n    rational_rational_signed_triple_gen::<T>().test_properties(|(n, m, i)| {\n        if n < i && i < m {\n            assert_eq!(n.cmp(&m), Less);\n        } else if n > i && i > m {\n            assert_eq!(n.cmp(&m), Greater);\n        }\n    });\n\n    rational_signed_signed_triple_gen::<T>().test_properties(|(n, i, j)| {\n        if i < n && n < j {\n            assert!(i < j);\n        } else if i > n && n > j {\n            assert!(i > j);\n        }\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(x).partial_cmp(&y), Some(x.cmp(&y)));\n        assert_eq!(x.partial_cmp(&Rational::from(y)), Some(x.cmp(&y)));\n    });\n}\n\n#[test]\nfn partial_cmp_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_cmp_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_cmp_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_eq_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_integer_pair_gen;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_rational_partial_eq_integer() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Integer::from_str(t).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(v == u, out);\n        assert_eq!(\n            rug::Rational::from_str(s).unwrap() == rug::Rational::from_str(t).unwrap(),\n            out\n        );\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"0\", \"-5\", false);\n    test(\"123\", \"123\", true);\n    test(\"123\", \"-123\", false);\n    test(\"-123\", \"123\", false);\n    test(\"-123\", \"-123\", true);\n    test(\"123\", \"5\", false);\n    test(\"123\", \"-5\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"1000000000000\", false);\n    test(\"-1000000000000\", \"-1000000000000\", true);\n    test(\"22/7\", \"3\", false);\n    test(\"1/2\", \"2\", false);\n    test(\"-1/2\", \"2\", false);\n    test(\"-1/2\", \"-2\", false);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn partial_eq_integer_properties() {\n    rational_integer_pair_gen().test_properties(|(x, y)| {\n        let eq = x == y;\n        assert_eq!(y == x, eq);\n        assert_eq!(x == Rational::from(&y), eq);\n        assert_eq!(rug::Rational::from(&x) == rug::Integer::from(&y), eq);\n    });\n\n    integer_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x) == y, x == y);\n        assert_eq!(x == Rational::from(&y), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_eq_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_natural_pair_gen;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_rational_partial_eq_natural() {\n    let test = |s, t, out| {\n        let u = Rational::from_str(s).unwrap();\n        let v = Natural::from_str(t).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(v == u, out);\n        assert_eq!(\n            rug::Rational::from_str(s).unwrap() == rug::Rational::from_str(t).unwrap(),\n            out\n        );\n    };\n    test(\"0\", \"0\", true);\n    test(\"0\", \"5\", false);\n    test(\"123\", \"123\", true);\n    test(\"-123\", \"123\", false);\n    test(\"123\", \"5\", false);\n    test(\"1000000000000\", \"123\", false);\n    test(\"123\", \"1000000000000\", false);\n    test(\"1000000000000\", \"1000000000000\", true);\n    test(\"-1000000000000\", \"1000000000000\", false);\n    test(\"22/7\", \"3\", false);\n    test(\"1/2\", \"2\", false);\n    test(\"-1/2\", \"2\", false);\n}\n\n#[allow(clippy::cmp_owned)]\n#[test]\nfn partial_eq_natural_properties() {\n    rational_natural_pair_gen().test_properties(|(x, y)| {\n        let eq = x == y;\n        assert_eq!(y == x, eq);\n        assert_eq!(x == Rational::from(&y), eq);\n        assert_eq!(rug::Rational::from(&x) == rug::Integer::from(&y), eq);\n    });\n\n    natural_pair_gen().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(&x) == y, x == y);\n        assert_eq!(x == Rational::from(&y), x == y);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_eq_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_primitive_float_pair_gen;\nuse rug;\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_primitive_float() {\n    let test = |u, v: f32, out| {\n        assert_eq!(Rational::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Rational::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Rational::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Rational::from_str(u).unwrap(), out);\n\n        let v = f64::from(v);\n        assert_eq!(Rational::from_str(u).unwrap() == v, out);\n        assert_eq!(rug::Rational::from_str(u).unwrap() == v, out);\n\n        assert_eq!(v == Rational::from_str(u).unwrap(), out);\n        assert_eq!(v == rug::Rational::from_str(u).unwrap(), out);\n    };\n    test(\"2/3\", f32::NAN, false);\n    test(\"2/3\", f32::INFINITY, false);\n    test(\"2/3\", f32::NEGATIVE_INFINITY, false);\n    test(\"-2/3\", f32::NAN, false);\n    test(\"-2/3\", f32::INFINITY, false);\n    test(\"-2/3\", f32::NEGATIVE_INFINITY, false);\n\n    test(\"0\", 0.0, true);\n    test(\"0\", -0.0, true);\n    test(\"0\", 5.0, false);\n    test(\"0\", -5.0, false);\n    test(\"3/2\", 1.5, true);\n    test(\"3/2\", 5.0, false);\n    test(\"3/2\", -1.5, false);\n    test(\"-3/2\", 1.5, false);\n    test(\"-3/2\", 5.0, false);\n    test(\"-3/2\", -1.5, true);\n}\n\n#[allow(clippy::cmp_owned, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_float_properties_helper<\n    T: PartialEq<Rational> + PartialEq<rug::Rational> + PrimitiveFloat,\n>()\nwhere\n    Rational: TryFrom<T> + PartialEq<T> + PartialOrd<T>,\n    rug::Rational: PartialEq<T>,\n{\n    rational_primitive_float_pair_gen::<T>().test_properties(|(n, f)| {\n        let eq = n == f;\n        assert_eq!(rug::Rational::from(&n) == f, eq);\n        assert_eq!(f == n, eq);\n        assert_eq!(f == rug::Rational::from(&n), eq);\n        assert_eq!(n.partial_cmp(&f) == Some(Equal), eq);\n        if f.is_finite() {\n            assert_eq!(PartialEq::<Rational>::eq(&n, &Rational::exact_from(f)), eq);\n        }\n    });\n}\n\n#[test]\nfn partial_eq_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(partial_eq_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/comparison/partial_eq_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::test_util::generators::{signed_pair_gen, unsigned_pair_gen_var_27};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_signed_pair_gen, rational_unsigned_pair_gen};\nuse rug;\nuse std::str::FromStr;\n\n#[test]\nfn test_partial_eq_u32() {\n    let test = |s, v: u32, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(rug::Rational::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Rational::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", 5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-1000000000000\", 123, false);\n    test(\"22/7\", 123, false);\n    test(\"-22/7\", 123, false);\n}\n\n#[test]\nfn test_partial_eq_u64() {\n    let test = |s, v: u64, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(rug::Rational::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Rational::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", 5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", 1000000000000, false);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"-1000000000000\", 1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-1000000000000000000000000\", 1000000000000, false);\n    test(\"22/7\", 123, false);\n    test(\"-22/7\", 123, false);\n}\n\n#[test]\nfn test_partial_eq_i32() {\n    let test = |s, v: i32, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(rug::Rational::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Rational::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", -5, false);\n    test(\"1000000000000\", 123, false);\n    test(\"-1000000000000\", -123, false);\n    test(\"22/7\", 123, false);\n    test(\"22/7\", -123, false);\n    test(\"-22/7\", 123, false);\n    test(\"-22/7\", -123, false);\n}\n\n#[test]\nfn test_partial_eq_i64() {\n    let test = |s, v: i64, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        assert_eq!(u == v, out);\n        assert_eq!(rug::Rational::from_str(s).unwrap() == v, out);\n\n        assert_eq!(v == u, out);\n        assert_eq!(v == rug::Rational::from_str(s).unwrap(), out);\n    };\n    test(\"0\", 0, true);\n    test(\"0\", 5, false);\n    test(\"123\", 123, true);\n    test(\"-123\", -123, true);\n    test(\"-123\", 123, false);\n    test(\"123\", 5, false);\n    test(\"-123\", -5, false);\n    test(\"1000000000000\", 1000000000000, true);\n    test(\"-1000000000000\", -1000000000000, true);\n    test(\"1000000000000\", 1000000000001, false);\n    test(\"-1000000000000\", -1000000000001, false);\n    test(\"1000000000000000000000000\", 1000000000000, false);\n    test(\"-1000000000000000000000000\", -1000000000000, false);\n    test(\"22/7\", 123, false);\n    test(\"22/7\", -123, false);\n    test(\"-22/7\", 123, false);\n    test(\"-22/7\", -123, false);\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_int_properties_helper_unsigned<\n    T: PartialEq<Rational> + PartialEq<rug::Rational> + PrimitiveUnsigned,\n>()\nwhere\n    Rational: From<T> + PartialEq<T>,\n    rug::Rational: PartialEq<T>,\n{\n    rational_unsigned_pair_gen::<T>().test_properties(|(n, u)| {\n        let eq = n == u;\n        assert_eq!(rug::Rational::from(&n) == u, eq);\n        assert_eq!(&n == &Rational::from(u), eq);\n\n        assert_eq!(u == n, eq);\n        assert_eq!(u == rug::Rational::from(&n), eq);\n        assert_eq!(&Rational::from(u) == &n, eq);\n    });\n\n    unsigned_pair_gen_var_27::<T>().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(x) == y, x == y);\n        assert_eq!(x == Rational::from(y), x == y);\n    });\n}\n\n// Extra refs necessary for type inference\n#[allow(clippy::cmp_owned, clippy::op_ref, clippy::trait_duplication_in_bounds)]\nfn partial_eq_primitive_int_properties_helper_signed<\n    T: PartialEq<Rational> + PartialEq<rug::Rational> + PrimitiveSigned,\n>()\nwhere\n    Rational: From<T> + PartialEq<T>,\n    rug::Rational: PartialEq<T>,\n{\n    rational_signed_pair_gen::<T>().test_properties(|(n, i)| {\n        let eq = n == i;\n        assert_eq!(rug::Rational::from(&n) == i, eq);\n        assert_eq!(&n == &Rational::from(i), eq);\n\n        assert_eq!(i == n, eq);\n        assert_eq!(i == rug::Rational::from(&n), eq);\n        assert_eq!(&Rational::from(i) == &n, eq);\n    });\n\n    signed_pair_gen::<T>().test_properties(|(x, y)| {\n        assert_eq!(Rational::from(x) == y, x == y);\n        assert_eq!(x == Rational::from(y), x == y);\n    });\n}\n\n#[test]\nfn partial_eq_primitive_int_properties() {\n    apply_fn_to_unsigneds!(partial_eq_primitive_int_properties_helper_unsigned);\n    apply_fn_to_signeds!(partial_eq_primitive_int_properties_helper_signed);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/clone.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::test_util::generators::integer_pair_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_pair_gen};\nuse num::BigRational;\nuse rug;\nuse std::str::FromStr;\n\n#[test]\n#[allow(clippy::redundant_clone)]\nfn test_clone() {\n    let test = |u| {\n        let x = Rational::from_str(u).unwrap().clone();\n        assert_eq!(x.to_string(), u);\n        assert!(x.is_valid());\n\n        let x = BigRational::from_str(u).unwrap().clone();\n        assert_eq!(x.to_string(), u);\n\n        let x = rug::Rational::from_str(u).unwrap().clone();\n        assert_eq!(x.to_string(), u);\n    };\n    test(\"123\");\n    test(\"1000000000000\");\n    test(\"-123\");\n    test(\"-1000000000000\");\n    test(\"22/7\");\n    test(\"-22/7\");\n    test(\"100/101\");\n    test(\"-100/101\");\n}\n\n#[test]\nfn test_clone_from() {\n    let test = |u, v| {\n        let mut x = Rational::from_str(u).unwrap();\n        x.clone_from(&Rational::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n        assert!(x.is_valid());\n\n        let mut x = BigRational::from_str(u).unwrap();\n        x.clone_from(&BigRational::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n\n        let mut x = rug::Rational::from_str(u).unwrap();\n        x.clone_from(&rug::Rational::from_str(v).unwrap());\n        assert_eq!(x.to_string(), v);\n    };\n    test(\"-123\", \"456\");\n    test(\"-123\", \"1000000000000\");\n    test(\"1000000000000\", \"-123\");\n    test(\"1000000000000\", \"2000000000000\");\n    test(\"123\", \"22/7\");\n    test(\"123\", \"-22/7\");\n    test(\"-123\", \"22/7\");\n    test(\"-123\", \"-22/7\");\n}\n\n#[allow(clippy::redundant_clone)]\n#[test]\nfn clone_and_clone_from_properties() {\n    rational_gen().test_properties(|x| {\n        let mut_x = x.clone();\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, x);\n\n        assert_eq!(Rational::from(&BigRational::from(&x).clone()), x);\n        assert_eq!(Rational::from(&rug::Rational::from(&x).clone()), x);\n    });\n\n    rational_pair_gen().test_properties(|(x, y)| {\n        let mut mut_x = x.clone();\n        mut_x.clone_from(&y);\n        assert!(mut_x.is_valid());\n        assert_eq!(mut_x, y);\n\n        let mut num_x = BigRational::from(&x);\n        num_x.clone_from(&BigRational::from(&y));\n        assert_eq!(Rational::from(&num_x), y);\n\n        let mut rug_x = rug::Rational::from(&x);\n        rug_x.clone_from(&rug::Rational::from(&y));\n        assert_eq!(Rational::from(&rug_x), y);\n    });\n\n    integer_pair_gen().test_properties(|(i, j)| {\n        let x = Rational::from(&i);\n        let y = Rational::from(&j);\n\n        let mut mut_i = i.clone();\n        let mut mut_x = x.clone();\n        mut_i.clone_from(&j);\n        mut_x.clone_from(&y);\n        assert_eq!(mut_x, mut_i);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/continued_fraction/convergents.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::iterators::comparison::{is_strictly_ascending, is_strictly_descending};\nuse malachite_base::num::arithmetic::traits::{Abs, Floor, Parity};\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::conversion::traits::Convergents;\nuse malachite_q::test_util::conversion::continued_fraction::convergents::convergents_alt;\nuse malachite_q::test_util::generators::rational_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_convergents() {\n    let test = |x: &str, out: &str| {\n        let x = Rational::from_str(x).unwrap();\n        let convergents = x.clone().convergents().collect_vec();\n        assert!(convergents.iter().all(Rational::is_valid));\n        assert_eq!((&x).convergents().collect_vec(), convergents);\n        assert_eq!(convergents_alt(x).collect_vec(), convergents);\n        assert_eq!(convergents.to_debug_string(), out);\n    };\n    test(\"0\", \"[0]\");\n    test(\"123\", \"[123]\");\n    test(\"-123\", \"[-123]\");\n    test(\"1/2\", \"[0, 1/2]\");\n    test(\"22/7\", \"[3, 22/7]\");\n    test(\"-22/7\", \"[-4, -3, -22/7]\");\n    test(\"99/100\", \"[0, 1, 99/100]\");\n    test(\n        \"936851431250/1397\",\n        \"[670616629, 1341233259/2, 2011849888/3, 3353083147/5, 5364933035/8, 8718016182/13, \\\n        232033353767/346, 936851431250/1397]\",\n    );\n    test(\n        \"6369051672525773/4503599627370496\",\n        \"[1, 3/2, 7/5, 17/12, 41/29, 99/70, 239/169, 577/408, 1393/985, 3363/2378, 8119/5741, \\\n        19601/13860, 47321/33461, 114243/80782, 275807/195025, 665857/470832, 1607521/1136689, \\\n        3880899/2744210, 9369319/6625109, 22619537/15994428, 54608393/38613965, \\\n        77227930/54608393, 131836323/93222358, 209064253/147830751, 549964829/388883860, \\\n        4058818056/2870017771, 4608782885/3258901631, 13276383826/9387821033, \\\n        442729449143/313056995720, 898735282112/635501812473, 6733876423927/4761569683031, \\\n        34568117401747/24443350227628, 75870111227421/53648270138287, \\\n        110438228629168/78091620365915, 186308339856589/131739890504202, \\\n        3091371666334592/2185929868433147, 6369051672525773/4503599627370496]\",\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"[3, 22/7, 333/106, 355/113, 103993/33102, 104348/33215, 208341/66317, 312689/99532, \\\n        833719/265381, 1146408/364913, 4272943/1360120, 5419351/1725033, 80143857/25510582, \\\n        245850922/78256779, 817696623/260280919, 1881244168/598818617, 2698940791/859099536, \\\n        9978066541/3176117225, 32633140414/10387451211, 238410049439/75888275702, \\\n        509453239292/162164002615, 747863288731/238052278317, 1257316528023/400216280932, \\\n        4519812872800/1438701121113, 10296942273623/3277618523158, \\\n        436991388364966/139098679093749, 884279719003555/281474976710656]\",\n    );\n    test(\n        \"6121026514868073/2251799813685248\",\n        \"[2, 3, 8/3, 11/4, 19/7, 87/32, 106/39, 193/71, 1264/465, 1457/536, 2721/1001, \\\n        23225/8544, 25946/9545, 49171/18089, 517656/190435, 566827/208524, 1084483/398959, \\\n        13580623/4996032, 14665106/5394991, 28245729/10391023, 325368125/119696244, \\\n        353613854/130087267, 678981979/249783511, 1032595833/379870778, 12037536142/4428362069, \\\n        61220276543/22521681123, 73257812685/26950043192, 134478089228/49471724315, \\\n        342213991141/125893491822, 476692080369/175365216137, 2248982312617/827354356370, \\\n        4974656705603/1830073928877, 7223639018220/2657428285247, 12198295723823/4487502214124, \\\n        117008300532627/43044948212363, 2001339404778482/736251621824295, \\\n        6121026514868073/2251799813685248]\",\n    );\n}\n\n#[test]\nfn convergents_properties() {\n    rational_gen().test_properties(|x| {\n        let convergents = x.clone().convergents().collect_vec();\n        assert!(convergents.iter().all(Rational::is_valid));\n        assert_eq!(convergents[0], (&x).floor());\n        assert_eq!(*convergents.last().unwrap(), x);\n        assert_eq!((&x).convergents().collect_vec(), convergents);\n        assert_eq!(convergents_alt(x.clone()).collect_vec(), convergents);\n\n        // The denominators of the convergents are strictly increasing, with the single exception\n        // that the first two convergents may both be integers.\n        if let Some(i) = convergents.iter().position(|x| !x.is_integer()) {\n            assert!(i == 1 || i == 2);\n            assert!(is_strictly_ascending(\n                convergents[i - 1..].iter().map(Rational::denominator_ref)\n            ));\n        }\n        assert!(is_strictly_descending(\n            convergents.iter().map(|c| (c - &x).abs())\n        ));\n        for (i, c) in convergents.iter().enumerate() {\n            if i.even() {\n                assert!(*c <= x);\n            } else {\n                assert!(*c >= x);\n            }\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        let convergents = Rational::from(&x).convergents().collect_vec();\n        assert_eq!(convergents, &[x]);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/continued_fraction/from_continued_fraction.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{integer_gen, natural_vec_integer_pair_gen_var_1};\nuse malachite_q::Rational;\nuse malachite_q::conversion::traits::ContinuedFraction;\nuse malachite_q::test_util::conversion::continued_fraction::from_continued_fraction::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_continued_fraction() {\n    let test = |floor: &str, xs: &str, out: &str| {\n        let floor = Integer::from_str(floor).unwrap();\n        let xs: Vec<Natural> = vec_from_str(xs).unwrap();\n        let x = Rational::from_continued_fraction(floor.clone(), xs.iter().cloned());\n        assert!(x.is_valid());\n        assert_eq!(Rational::from_continued_fraction_ref(&floor, xs.iter()), x);\n        assert_eq!(from_continued_fraction_alt(floor, xs), x);\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"[]\", \"0\");\n    test(\"3\", \"[7]\", \"22/7\");\n    test(\"3\", \"[6, 1]\", \"22/7\");\n    test(\"-4\", \"[1, 6]\", \"-22/7\");\n    test(\n        \"3\",\n        \"[7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2]\",\n        \"14885392687/4738167652\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn from_continued_fraction_fail_1() {\n    Rational::from_continued_fraction(Integer::ONE, std::iter::once(Natural::ZERO));\n}\n\n#[test]\n#[should_panic]\nfn from_continued_fraction_fail_2() {\n    Rational::from_continued_fraction(\n        Integer::ONE,\n        vec![Natural::from(3u32), Natural::ZERO, Natural::ONE].into_iter(),\n    );\n}\n\n#[test]\n#[should_panic]\nfn from_continued_fraction_ref_fail_1() {\n    Rational::from_continued_fraction_ref(&Integer::ONE, [Natural::ZERO].iter());\n}\n\n#[test]\n#[should_panic]\nfn from_continued_fraction_ref_fail_2() {\n    Rational::from_continued_fraction_ref(\n        &Integer::ONE,\n        [Natural::from(3u32), Natural::ZERO, Natural::ONE].iter(),\n    );\n}\n\n#[test]\nfn from_continued_fraction_properties() {\n    natural_vec_integer_pair_gen_var_1().test_properties(|(xs, floor)| {\n        let x = Rational::from_continued_fraction(floor.clone(), xs.iter().cloned());\n        assert!(x.is_valid());\n        assert_eq!(Rational::from_continued_fraction_ref(&floor, xs.iter()), x);\n        assert_eq!(from_continued_fraction_alt(floor.clone(), xs.clone()), x);\n        if xs.last() != Some(&Natural::ONE) {\n            let (floor_alt, cf) = (&x).continued_fraction();\n            let xs_alt = cf.collect_vec();\n            assert_eq!(floor_alt, floor);\n            assert_eq!(xs_alt, xs);\n        }\n        if !xs.is_empty() {\n            let mut alt_xs = xs;\n            let last = alt_xs.last_mut().unwrap();\n            if *last > 1u32 {\n                *last -= Natural::ONE;\n                alt_xs.push(Natural::ONE);\n                assert_eq!(\n                    Rational::from_continued_fraction(floor, alt_xs.into_iter()),\n                    x\n                );\n            }\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(\n            Rational::from_continued_fraction_ref(&x, std::iter::empty()),\n            x\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/continued_fraction/to_continued_fraction.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::arithmetic::traits::Floor;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::conversion::traits::ContinuedFraction;\nuse malachite_q::test_util::generators::rational_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_continued_fraction() {\n    let test = |x: &str, out: &str| {\n        let x = Rational::from_str(x).unwrap();\n        let (floor, continued_fraction) = (&x).continued_fraction();\n        let (floor_alt, continued_fraction_alt) = x.continued_fraction();\n        assert_eq!(floor, floor_alt);\n        assert_eq!(continued_fraction, continued_fraction_alt);\n        let continued_fraction = continued_fraction.collect_vec();\n        let s = if continued_fraction.is_empty() {\n            format!(\"[{floor}]\")\n        } else {\n            let s = continued_fraction.to_debug_string();\n            format!(\"[{}; {}]\", floor, &s[1..s.len() - 1])\n        };\n        assert_eq!(s, out);\n    };\n    test(\"0\", \"[0]\");\n    test(\"123\", \"[123]\");\n    test(\"-123\", \"[-123]\");\n    test(\"1/2\", \"[0; 2]\");\n    test(\"22/7\", \"[3; 7]\");\n    test(\"-22/7\", \"[-4; 1, 6]\");\n    test(\"99/100\", \"[0; 1, 99]\");\n    test(\"936851431250/1397\", \"[670616629; 2, 1, 1, 1, 1, 26, 4]\");\n    test(\n        \"6369051672525773/4503599627370496\",\n        \"[1; 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 7, 1, 2, 33, \\\n        2, 7, 5, 2, 1, 1, 16, 2]\",\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3, 3, 2, 1, 3, 3, 7, 2, 1, 1, 3, 2, 42, 2]\",\n    );\n    test(\n        \"6121026514868073/2251799813685248\",\n        \"[2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1, 11, 1, 1, 1, 11, 5, 1, 1, \\\n        2, 1, 4, 2, 1, 1, 9, 17, 3]\",\n    );\n}\n\n#[test]\nfn continued_fraction_properties() {\n    rational_gen().test_properties(|x| {\n        let (floor, continued_fraction) = (&x).continued_fraction();\n        let (floor_alt, continued_fraction_alt) = x.clone().continued_fraction();\n        assert_eq!(floor, floor_alt);\n        assert_eq!(continued_fraction, continued_fraction_alt);\n\n        let continued_fraction = continued_fraction.collect_vec();\n        assert_eq!(floor, (&x).floor());\n        assert_eq!(continued_fraction.is_empty(), x.is_integer());\n        assert!(continued_fraction.iter().all(|n| *n > 0u32));\n        assert_ne!(continued_fraction.last(), Some(&Natural::ONE));\n        assert_eq!(\n            Rational::from_continued_fraction(floor, continued_fraction.into_iter()),\n            x\n        );\n    });\n\n    integer_gen().test_properties(|x| {\n        let (floor, continued_fraction) = Rational::from(&x).continued_fraction();\n        let continued_fraction = continued_fraction.collect_vec();\n        assert_eq!(floor, x);\n        assert!(continued_fraction.is_empty());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/digits/digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::{count_is_at_most, prefix_to_string};\nuse malachite_base::num::arithmetic::traits::{Abs, Pow};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{Digits, IsInteger};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_2;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_natural_pair_gen_var_1, rational_natural_pair_gen_var_2,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_digits() {\n    let test = |x: &str, base: &str, before_out: &str, after_out: &str| {\n        let base = Natural::from_str(base).unwrap();\n        let (before, after) = Rational::from_str(x).unwrap().digits(&base);\n        assert_eq!(before.to_debug_string(), before_out);\n        assert_eq!(prefix_to_string(after, 10), after_out);\n    };\n    test(\"0\", \"3\", \"[]\", \"[]\");\n    test(\"0\", \"10\", \"[]\", \"[]\");\n    test(\"1\", \"3\", \"[1]\", \"[]\");\n    test(\"1\", \"10\", \"[1]\", \"[]\");\n    test(\"1/2\", \"3\", \"[]\", \"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...]\");\n    test(\"1/2\", \"10\", \"[]\", \"[5]\");\n    test(\"1/3\", \"3\", \"[]\", \"[1]\");\n    test(\"1/3\", \"10\", \"[]\", \"[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, ...]\");\n    test(\"7/6\", \"3\", \"[1]\", \"[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...]\");\n    test(\"7/6\", \"10\", \"[1]\", \"[1, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...]\");\n    test(\"22/7\", \"3\", \"[0, 1]\", \"[0, 1, 0, 2, 1, 2, 0, 1, 0, 2, ...]\");\n    test(\"22/7\", \"10\", \"[3]\", \"[1, 4, 2, 8, 5, 7, 1, 4, 2, 8, ...]\");\n    test(\n        \"936851431250/1397\",\n        \"3\",\n        \"[1, 2, 2, 1, 0, 0, 2, 1, 2, 2, 1, 2, 1, 0, 2, 1, 0, 2, 1]\",\n        \"[1, 0, 1, 1, 0, 1, 0, 2, 0, 0, ...]\",\n    );\n    test(\n        \"936851431250/1397\",\n        \"10\",\n        \"[9, 2, 6, 6, 1, 6, 0, 7, 6]\",\n        \"[3, 8, 4, 3, 9, 5, 1, 3, 2, 4, ...]\",\n    );\n    test(\n        \"6369051672525773/4503599627370496\",\n        \"10\",\n        \"[1]\",\n        \"[4, 1, 4, 2, 1, 3, 5, 6, 2, 3, ...]\",\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"10\",\n        \"[3]\",\n        \"[1, 4, 1, 5, 9, 2, 6, 5, 3, 5, ...]\",\n    );\n    test(\n        \"6121026514868073/2251799813685248\",\n        \"10\",\n        \"[2]\",\n        \"[7, 1, 8, 2, 8, 1, 8, 2, 8, 4, ...]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn digits_fail_1() {\n    Rational::ONE.digits(&Natural::ONE);\n}\n\n#[test]\n#[should_panic]\nfn digits_fail_2() {\n    Rational::ONE.digits(&Natural::ZERO);\n}\n\n#[test]\nfn digits_properties() {\n    rational_natural_pair_gen_var_1().test_properties(|(x, base)| {\n        let (before_point, after_point) = x.digits(&base);\n        let (before_point_alt, after_point_alt) = (-&x).digits(&base);\n        assert_eq!(before_point, before_point_alt);\n        assert!(Iterator::eq(after_point.take(10), after_point_alt.take(10)));\n\n        let (before_point, after_point) = x.digits(&base);\n        let approx = Rational::from_digits(\n            &base,\n            before_point,\n            RationalSequence::from_vec(after_point.take(10).collect()),\n        );\n        let abs_x = (&x).abs();\n        assert!(approx <= abs_x);\n        assert!(abs_x - approx < Rational::from(&base).pow(-10i64));\n\n        let after_point = x.digits(&base).1;\n        assert_eq!(count_is_at_most(after_point, 0), x.is_integer());\n    });\n\n    rational_natural_pair_gen_var_2().test_properties(|(x, base)| {\n        let (before_point, after_point) = x.to_digits(&base);\n        let (before_point_alt, after_point_alt) = x.digits(&base);\n        assert_eq!(before_point, before_point_alt);\n        assert!(Iterator::eq(\n            after_point.iter().take(10).cloned(),\n            after_point_alt.take(10)\n        ));\n    });\n\n    natural_pair_gen_var_2().test_properties(|(n, base)| {\n        let (before_point, after_point) = Rational::from(&n).digits(&base);\n        let before_point_alt: Vec<Natural> = n.to_digits_asc(&base);\n        assert_eq!(before_point, before_point_alt);\n        assert_eq!(Iterator::count(after_point), 0);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/digits/from_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::Digits;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_25, natural_vec_natural_pair_gen_var_2,\n};\nuse malachite_q::Rational;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_digits() {\n    let test = |base: &str, before: &str, after_nr: &str, after_r: &str, out: &str| {\n        let base = Natural::from_str(base).unwrap();\n        let before: Vec<Natural> = vec_from_str(before).unwrap();\n        let after_nr: Vec<Natural> = vec_from_str(after_nr).unwrap();\n        let after_r: Vec<Natural> = vec_from_str(after_r).unwrap();\n        let x = Rational::from_digits_ref(\n            &base,\n            &before,\n            &RationalSequence::from_slices(&after_nr, &after_r),\n        );\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(\n            Rational::from_digits(\n                &base,\n                before,\n                RationalSequence::from_vecs(after_nr, after_r)\n            ),\n            x\n        );\n    };\n    test(\"3\", \"[]\", \"[]\", \"[]\", \"0\");\n    test(\"10\", \"[]\", \"[]\", \"[]\", \"0\");\n    test(\"3\", \"[1]\", \"[]\", \"[]\", \"1\");\n    test(\"10\", \"[1]\", \"[]\", \"[]\", \"1\");\n    test(\"3\", \"[]\", \"[]\", \"[1]\", \"1/2\");\n    test(\"10\", \"[]\", \"[5]\", \"[]\", \"1/2\");\n    test(\"3\", \"[]\", \"[1]\", \"[]\", \"1/3\");\n    test(\"10\", \"[]\", \"[]\", \"[3]\", \"1/3\");\n    test(\"3\", \"[1]\", \"[0]\", \"[1]\", \"7/6\");\n    test(\"10\", \"[1]\", \"[1]\", \"[6]\", \"7/6\");\n    test(\"3\", \"[0, 1]\", \"[]\", \"[0, 1, 0, 2, 1, 2]\", \"22/7\");\n    test(\"10\", \"[3]\", \"[]\", \"[1, 4, 2, 8, 5, 7]\", \"22/7\");\n    test(\n        \"3\",\n        \"[1, 2, 2, 1, 0, 0, 2, 1, 2, 2, 1, 2, 1, 0, 2, 1, 0, 2, 1]\",\n        \"[]\",\n        \"[1, 0, 1, 1, 0, 1, 0, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 2, 1, 0, 2, 0, \\\n        2, 0, 0, 1, 1, 2, 2, 2, 1, 2, 2, 0, 0, 2, 0, 2, 2, 0, 0, 2, 1, 2, 2, 1, 1, 1, 0, 2, 0, 2, \\\n        2, 2, 1, 0, 1, 0, 2, 2, 0, 1, 0, 2, 0, 0, 2, 0, 0, 0, 0, 2, 1, 0, 2, 2, 0, 2, 0, 2, 1, 1, \\\n        0, 1, 2, 1, 2, 0, 2, 1, 0, 2, 1, 2, 0, 1, 2, 0, 1, 2, 1, 0, 1, 0, 0, 1, 2, 1, 2, 1, 2, 1, \\\n        2, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 0, 2, 0, 0, 1, 0, 1, 0, 2, 1, 0, 0, 2, 1, 1, 1, 2, 1, 1, \\\n        1, 2, 2, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 2, 0, 0, 2, 1, 0, 0, 1, 2, 2, 2, 2, 0, 2, 0, 1, 2, \\\n        2, 1, 1, 1, 2, 1, 0, 0, 0, 1, 2, 1, 0, 1, 1, 2, 0, 2, 2, 2, 0, 0, 0, 2, 2, 0, 1, 1, 2, 0, \\\n        1, 2, 1, 1, 2, 2, 0, 2, 2, 0, 0, 1, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 2, 1, 2, 1, 1, 1, 0, 0, \\\n        0, 2, 0, 1, 0, 2, 2, 0, 2, 2, 1, 0, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 0, 0, \\\n        2, 1, 2, 1, 2, 2, 2, 0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 2, 0, 2, 1, \\\n        0, 1, 0, 0, 0, 0, 2, 2, 1, 0, 0, 1, 0, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 0, 0, 1, 0, 1, \\\n        0, 0, 2, 1, 0, 1, 2, 0, 1, 0, 0, 2, 1, 2, 0, 1, 0, 1, 2, 2, 0, 0, 2, 2, 1, 1, 0, 1, 2, 0, \\\n        0, 1, 2, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 1, 0, 1, 1, 0, 2, 2, 1, 0, 0, 2, 2, 1, 2, 0, 2, \\\n        0, 0, 2, 0, 1, 1, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1, \\\n        2, 2, 0, 0, 0, 2, 0, 1, 2, 1, 1, 1, 0, 1, 2, 1, 0, 2, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, \\\n        2, 0, 1, 0, 1, 2, 0, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 2, 0, \\\n        2, 1, 1, 1, 0, 1, 0, 2, 1, 1, 2, 1, 1, 2, 1, 0, 2, 0, 2, 1, 2, 0, 2, 0, 2, 0, 2, 1, 2, 2, \\\n        0, 2, 2, 1, 2, 0, 0, 1, 1, 1, 2, 2, 0, 2, 0, 1, 1, 0, 2, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 1, \\\n        2, 1, 2, 1, 0, 2, 2, 2, 2, 1, 1, 2, 1, 1, 0, 2, 1, 2, 0, 0, 0, 1, 1, 1, 1, 2, 0, 0, 2, 2, \\\n        2, 1, 0, 2, 2, 1, 2, 1, 0, 1, 2, 2, 1, 1, 0, 0, 1, 2, 2, 1, 0, 1, 1, 2, 2, 1, 1, 2, 0, 2, \\\n        2, 0, 1, 1, 0, 1, 2, 2, 0, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 0, 2, 1, 0, 0, 0, 2, 2, 1, 1, 2, \\\n        0]\",\n        \"936851431250/1397\",\n    );\n    test(\n        \"10\",\n        \"[9, 2, 6, 6, 1, 6, 0, 7, 6]\",\n        \"[]\",\n        \"[3, 8, 4, 3, 9, 5, 1, 3, 2, 4, 2, 6, 6, 2, 8, 4, 8, 9, 6, 2, 0, 6, 1, 5, 6, 0, 4, 8, 6, \\\n        7, 5, 7, 3, 3, 7, 1, 5, 1, 0, 3, 7, 9]\",\n        \"936851431250/1397\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn from_digits_fail_1() {\n    Rational::from_digits(\n        &Natural::ONE,\n        Vec::new(),\n        RationalSequence::from_vec(Vec::new()),\n    );\n}\n\n#[test]\n#[should_panic]\nfn from_digits_fail_2() {\n    Rational::from_digits(\n        &Natural::ZERO,\n        Vec::new(),\n        RationalSequence::from_vec(Vec::new()),\n    );\n}\n\n#[test]\n#[should_panic]\nfn from_digits_ref_fail_1() {\n    Rational::from_digits_ref(&Natural::ONE, &[], &RationalSequence::from_vec(Vec::new()));\n}\n\n#[test]\n#[should_panic]\nfn from_digits_ref_fail_2() {\n    Rational::from_digits_ref(&Natural::ZERO, &[], &RationalSequence::from_vec(Vec::new()));\n}\n\n#[test]\nfn from_digits_properties() {\n    large_type_gen_var_25().test_properties(|(base, before_point, after_point)| {\n        let x = Rational::from_digits(&base, before_point.clone(), after_point.clone());\n        assert!(x.is_valid());\n        assert_eq!(\n            Rational::from_digits_ref(&base, &before_point, &after_point),\n            x\n        );\n        assert!(x >= 0u32);\n        if before_point.last() != Some(&Natural::ZERO)\n            && after_point.slices_ref().1 != [Natural::ZERO]\n            && after_point.slices_ref().1 != [&base - Natural::ONE]\n            && !(after_point.slices_ref().1.is_empty()\n                && after_point.slices_ref().0.last() == Some(&Natural::ZERO))\n        {\n            assert_eq!(x.into_digits(&base), (before_point, after_point));\n        }\n    });\n\n    natural_vec_natural_pair_gen_var_2().test_properties(|(digits, base)| {\n        assert_eq!(\n            Natural::from_digits_asc(&base, digits.iter().cloned()).unwrap(),\n            Rational::from_digits(\n                &base,\n                digits.to_vec(),\n                RationalSequence::from_vec(Vec::new())\n            )\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/digits/from_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::PowerOf2Digits;\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::vecs::vec_from_str;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    large_type_gen_var_23, natural_vec_unsigned_pair_gen_var_1,\n};\nuse malachite_q::Rational;\n\n#[test]\nfn test_from_power_of_2_digits() {\n    let test = |log_base, before: &str, after_nr: &str, after_r: &str, out: &str| {\n        let before: Vec<Natural> = vec_from_str(before).unwrap();\n        let after_nr: Vec<Natural> = vec_from_str(after_nr).unwrap();\n        let after_r: Vec<Natural> = vec_from_str(after_r).unwrap();\n        let x = Rational::from_power_of_2_digits_ref(\n            log_base,\n            &before,\n            &RationalSequence::from_slices(&after_nr, &after_r),\n        );\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        assert_eq!(\n            Rational::from_power_of_2_digits(\n                log_base,\n                before,\n                RationalSequence::from_vecs(after_nr, after_r)\n            ),\n            x\n        );\n    };\n    test(1, \"[]\", \"[]\", \"[]\", \"0\");\n    test(1, \"[]\", \"[0, 0]\", \"[0]\", \"0\");\n    test(10, \"[]\", \"[]\", \"[]\", \"0\");\n    test(1, \"[1]\", \"[]\", \"[]\", \"1\");\n    test(10, \"[1]\", \"[]\", \"[]\", \"1\");\n    test(1, \"[]\", \"[]\", \"[1]\", \"1\");\n    test(1, \"[]\", \"[1]\", \"[]\", \"1/2\");\n    test(10, \"[]\", \"[512]\", \"[]\", \"1/2\");\n    test(1, \"[]\", \"[]\", \"[0, 1]\", \"1/3\");\n    test(10, \"[]\", \"[]\", \"[341]\", \"1/3\");\n    test(1, \"[1]\", \"[0]\", \"[0, 1]\", \"7/6\");\n    test(10, \"[1]\", \"[170]\", \"[682]\", \"7/6\");\n    test(1, \"[1, 1]\", \"[]\", \"[0, 0, 1]\", \"22/7\");\n    test(10, \"[3]\", \"[]\", \"[146, 292, 585]\", \"22/7\");\n    test(\n        1,\n        \"[1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \\\n        1]\",\n        \"[]\",\n        \"[0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, \\\n        0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, \\\n        1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1]\",\n        \"936851431250/1397\",\n    );\n    test(\n        10,\n        \"[53, 563, 639]\",\n        \"[]\",\n        \"[393, 635, 522, 643, 587, 135, 619]\",\n        \"936851431250/1397\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn from_power_of_2_digits_fail() {\n    Rational::from_power_of_2_digits(0, Vec::new(), RationalSequence::from_vec(Vec::new()));\n}\n\n#[test]\n#[should_panic]\nfn from_power_of_2_digits_ref_fail() {\n    Rational::from_power_of_2_digits_ref(0, &[], &RationalSequence::from_vec(Vec::new()));\n}\n\n#[test]\nfn from_power_of_2_digits_properties() {\n    large_type_gen_var_23().test_properties(|(log_base, before_point, after_point)| {\n        let x =\n            Rational::from_power_of_2_digits(log_base, before_point.clone(), after_point.clone());\n        assert!(x.is_valid());\n        assert_eq!(\n            Rational::from_power_of_2_digits_ref(log_base, &before_point, &after_point),\n            x\n        );\n        assert!(x >= 0u32);\n        if before_point.last() != Some(&Natural::ZERO)\n            && after_point.slices_ref().1 != [Natural::ZERO]\n            && after_point.slices_ref().1 != [Natural::low_mask(log_base)]\n            && !(after_point.slices_ref().1.is_empty()\n                && after_point.slices_ref().0.last() == Some(&Natural::ZERO))\n        {\n            assert_eq!(\n                x.into_power_of_2_digits(log_base),\n                (before_point, after_point)\n            );\n        }\n    });\n\n    natural_vec_unsigned_pair_gen_var_1().test_properties(|(digits, log_base)| {\n        assert_eq!(\n            Natural::from_power_of_2_digits_asc(log_base, digits.iter().cloned()).unwrap(),\n            Rational::from_power_of_2_digits(\n                log_base,\n                digits.to_vec(),\n                RationalSequence::from_vec(Vec::new())\n            )\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/digits/power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::{count_is_at_most, prefix_to_string};\nuse malachite_base::num::arithmetic::traits::{Abs, PowerOf2};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::conversion::traits::{ExactFrom, IsInteger, PowerOf2Digits};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_7;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_unsigned_pair_gen_var_2, rational_unsigned_pair_gen_var_3,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_power_of_2_digits() {\n    let test = |x: &str, log_base: u64, before_out: &str, aftr_out: &str| {\n        let (before, after) = Rational::from_str(x).unwrap().power_of_2_digits(log_base);\n        assert_eq!(before.to_debug_string(), before_out);\n        assert_eq!(prefix_to_string(after, 10), aftr_out);\n    };\n    test(\"0\", 1, \"[]\", \"[]\");\n    test(\"0\", 10, \"[]\", \"[]\");\n    test(\"1\", 1, \"[1]\", \"[]\");\n    test(\"1\", 10, \"[1]\", \"[]\");\n    test(\"1/2\", 1, \"[]\", \"[1]\");\n    test(\"1/2\", 10, \"[]\", \"[512]\");\n    test(\"1/3\", 1, \"[]\", \"[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, ...]\");\n    test(\n        \"1/3\",\n        10,\n        \"[]\",\n        \"[341, 341, 341, 341, 341, 341, 341, 341, 341, 341, ...]\",\n    );\n    test(\"7/6\", 1, \"[1]\", \"[0, 0, 1, 0, 1, 0, 1, 0, 1, 0, ...]\");\n    test(\n        \"7/6\",\n        10,\n        \"[1]\",\n        \"[170, 682, 682, 682, 682, 682, 682, 682, 682, 682, ...]\",\n    );\n    test(\"22/7\", 1, \"[1, 1]\", \"[0, 0, 1, 0, 0, 1, 0, 0, 1, 0, ...]\");\n    test(\n        \"22/7\",\n        10,\n        \"[3]\",\n        \"[146, 292, 585, 146, 292, 585, 146, 292, 585, 146, ...]\",\n    );\n    test(\n        \"936851431250/1397\",\n        1,\n        \"[1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \\\n        1]\",\n        \"[0, 1, 1, 0, 0, 0, 1, 0, 0, 1, ...]\",\n    );\n    test(\n        \"936851431250/1397\",\n        10,\n        \"[53, 563, 639]\",\n        \"[393, 635, 522, 643, 587, 135, 619, 393, 635, 522, ...]\",\n    );\n    test(\n        \"6369051672525773/4503599627370496\",\n        10,\n        \"[1]\",\n        \"[424, 158, 409, 1011, 755, 256]\",\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        10,\n        \"[3]\",\n        \"[144, 1014, 674, 133, 652]\",\n    );\n    test(\n        \"6121026514868073/2251799813685248\",\n        10,\n        \"[2]\",\n        \"[735, 533, 88, 650, 948, 512]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn power_of_2_digits_fail() {\n    Rational::ONE.power_of_2_digits(0);\n}\n\n#[test]\nfn power_of_2_digits_properties() {\n    rational_unsigned_pair_gen_var_3().test_properties(|(x, log_base)| {\n        let (before_point, after_point) = x.power_of_2_digits(log_base);\n        let (before_point_alt, after_point_alt) = (-&x).power_of_2_digits(log_base);\n        assert_eq!(before_point, before_point_alt);\n        assert!(Iterator::eq(after_point.take(10), after_point_alt.take(10)));\n\n        let (before_point, after_point) = x.power_of_2_digits(log_base);\n        let approx = Rational::from_power_of_2_digits(\n            log_base,\n            before_point,\n            RationalSequence::from_vec(after_point.take(10).collect()),\n        );\n        let abs_x = (&x).abs();\n        assert!(approx <= abs_x);\n        assert!(abs_x - approx < Rational::power_of_2(-i64::exact_from(log_base) * 10));\n\n        let after_point = x.power_of_2_digits(log_base).1;\n        assert_eq!(count_is_at_most(after_point, 0), x.is_integer());\n    });\n\n    rational_unsigned_pair_gen_var_2().test_properties(|(x, log_base)| {\n        let (before_point, after_point) = x.to_power_of_2_digits(log_base);\n        let (before_point_alt, after_point_alt) = x.power_of_2_digits(log_base);\n        assert_eq!(before_point, before_point_alt);\n        assert!(Iterator::eq(\n            after_point.iter().take(10).cloned(),\n            after_point_alt.take(10)\n        ));\n    });\n\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, log_base)| {\n        let (before_point, after_point) = Rational::from(&n).power_of_2_digits(log_base);\n        let before_point_alt: Vec<Natural> = n.to_power_of_2_digits_asc(log_base);\n        assert_eq!(before_point, before_point_alt);\n        assert_eq!(Iterator::count(after_point), 0);\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/digits/to_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, Floor, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{Digits, IsInteger};\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_pair_gen_var_2;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_natural_pair_gen_var_2;\nuse std::str::FromStr;\n\n#[test]\nfn test_to_digits() {\n    let test = |x: &str, base: &str, before_out: &str, after_out: &str| {\n        let x = Rational::from_str(x).unwrap();\n        let base = Natural::from_str(base).unwrap();\n        let (before, after) = x.to_digits(&base);\n        let (before_alt, after_alt) = x.into_digits(&base);\n        assert_eq!(before, before_alt);\n        assert_eq!(after, after_alt);\n        assert_eq!(before.to_debug_string(), before_out);\n        assert_eq!(after.to_string(), after_out);\n    };\n    test(\"0\", \"3\", \"[]\", \"[]\");\n    test(\"0\", \"10\", \"[]\", \"[]\");\n    test(\"1\", \"3\", \"[1]\", \"[]\");\n    test(\"1\", \"10\", \"[1]\", \"[]\");\n    test(\"1/2\", \"3\", \"[]\", \"[[1]]\");\n    test(\"1/2\", \"10\", \"[]\", \"[5]\");\n    test(\"1/3\", \"3\", \"[]\", \"[1]\");\n    test(\"1/3\", \"10\", \"[]\", \"[[3]]\");\n    test(\"7/6\", \"3\", \"[1]\", \"[0, [1]]\");\n    test(\"7/6\", \"10\", \"[1]\", \"[1, [6]]\");\n    test(\"22/7\", \"3\", \"[0, 1]\", \"[[0, 1, 0, 2, 1, 2]]\");\n    test(\"22/7\", \"10\", \"[3]\", \"[[1, 4, 2, 8, 5, 7]]\");\n    test(\n        \"936851431250/1397\",\n        \"3\",\n        \"[1, 2, 2, 1, 0, 0, 2, 1, 2, 2, 1, 2, 1, 0, 2, 1, 0, 2, 1]\",\n        \"[[1, 0, 1, 1, 0, 1, 0, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 2, 1, 0, 2, 0, \\\n        2, 0, 0, 1, 1, 2, 2, 2, 1, 2, 2, 0, 0, 2, 0, 2, 2, 0, 0, 2, 1, 2, 2, 1, 1, 1, 0, 2, 0, 2, \\\n        2, 2, 1, 0, 1, 0, 2, 2, 0, 1, 0, 2, 0, 0, 2, 0, 0, 0, 0, 2, 1, 0, 2, 2, 0, 2, 0, 2, 1, 1, \\\n        0, 1, 2, 1, 2, 0, 2, 1, 0, 2, 1, 2, 0, 1, 2, 0, 1, 2, 1, 0, 1, 0, 0, 1, 2, 1, 2, 1, 2, 1, \\\n        2, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 0, 2, 0, 0, 1, 0, 1, 0, 2, 1, 0, 0, 2, 1, 1, 1, 2, 1, 1, \\\n        1, 2, 2, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 2, 0, 0, 2, 1, 0, 0, 1, 2, 2, 2, 2, 0, 2, 0, 1, 2, \\\n        2, 1, 1, 1, 2, 1, 0, 0, 0, 1, 2, 1, 0, 1, 1, 2, 0, 2, 2, 2, 0, 0, 0, 2, 2, 0, 1, 1, 2, 0, \\\n        1, 2, 1, 1, 2, 2, 0, 2, 2, 0, 0, 1, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 2, 1, 2, 1, 1, 1, 0, 0, \\\n        0, 2, 0, 1, 0, 2, 2, 0, 2, 2, 1, 0, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 0, 0, \\\n        2, 1, 2, 1, 2, 2, 2, 0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 2, 0, 2, 1, \\\n        0, 1, 0, 0, 0, 0, 2, 2, 1, 0, 0, 1, 0, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 0, 0, 1, 0, 1, \\\n        0, 0, 2, 1, 0, 1, 2, 0, 1, 0, 0, 2, 1, 2, 0, 1, 0, 1, 2, 2, 0, 0, 2, 2, 1, 1, 0, 1, 2, 0, \\\n        0, 1, 2, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 1, 0, 1, 1, 0, 2, 2, 1, 0, 0, 2, 2, 1, 2, 0, 2, \\\n        0, 0, 2, 0, 1, 1, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1, \\\n        2, 2, 0, 0, 0, 2, 0, 1, 2, 1, 1, 1, 0, 1, 2, 1, 0, 2, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, \\\n        2, 0, 1, 0, 1, 2, 0, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 2, 0, \\\n        2, 1, 1, 1, 0, 1, 0, 2, 1, 1, 2, 1, 1, 2, 1, 0, 2, 0, 2, 1, 2, 0, 2, 0, 2, 0, 2, 1, 2, 2, \\\n        0, 2, 2, 1, 2, 0, 0, 1, 1, 1, 2, 2, 0, 2, 0, 1, 1, 0, 2, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 1, \\\n        2, 1, 2, 1, 0, 2, 2, 2, 2, 1, 1, 2, 1, 1, 0, 2, 1, 2, 0, 0, 0, 1, 1, 1, 1, 2, 0, 0, 2, 2, \\\n        2, 1, 0, 2, 2, 1, 2, 1, 0, 1, 2, 2, 1, 1, 0, 0, 1, 2, 2, 1, 0, 1, 1, 2, 2, 1, 1, 2, 0, 2, \\\n        2, 0, 1, 1, 0, 1, 2, 2, 0, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 0, 2, 1, 0, 0, 0, 2, 2, 1, 1, 2, \\\n        0]]\",\n    );\n    test(\n        \"936851431250/1397\",\n        \"10\",\n        \"[9, 2, 6, 6, 1, 6, 0, 7, 6]\",\n        \"[[3, 8, 4, 3, 9, 5, 1, 3, 2, 4, 2, 6, 6, 2, 8, 4, 8, 9, 6, 2, 0, 6, 1, 5, 6, 0, 4, 8, 6, \\\n        7, 5, 7, 3, 3, 7, 1, 5, 1, 0, 3, 7, 9]]\",\n    );\n    test(\n        \"6369051672525773/4503599627370496\",\n        \"10\",\n        \"[1]\",\n        \"[4, 1, 4, 2, 1, 3, 5, 6, 2, 3, 7, 3, 0, 9, 5, 1, 4, 5, 4, 7, 4, 6, 2, 1, 8, 5, 8, 7, 3, \\\n        8, 8, 2, 8, 4, 5, 0, 4, 4, 1, 3, 6, 0, 4, 7, 3, 6, 3, 2, 8, 1, 2, 5]\",\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        \"10\",\n        \"[3]\",\n        \"[1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 1, 1, 5, 9, 9, 7, 9, 6, 3, 4, 6, 8, 5, 4, \\\n        4, 1, 8, 5, 1, 6, 1, 5, 9, 0, 5, 7, 6, 1, 7, 1, 8, 7, 5]\",\n    );\n    test(\n        \"6121026514868073/2251799813685248\",\n        \"10\",\n        \"[2]\",\n        \"[7, 1, 8, 2, 8, 1, 8, 2, 8, 4, 5, 9, 0, 4, 5, 0, 9, 0, 7, 9, 5, 5, 9, 8, 2, 9, 8, 4, 2, \\\n        7, 6, 4, 8, 8, 4, 2, 3, 3, 4, 7, 4, 7, 3, 1, 4, 4, 5, 3, 1, 2, 5]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn to_digits_fail_1() {\n    Rational::ONE.to_digits(&Natural::ONE);\n}\n\n#[test]\n#[should_panic]\nfn to_digits_fail_2() {\n    Rational::ONE.to_digits(&Natural::ZERO);\n}\n\n#[test]\n#[should_panic]\nfn into_digits_fail_1() {\n    Rational::ONE.into_digits(&Natural::ONE);\n}\n\n#[test]\n#[should_panic]\nfn into_digits_fail_2() {\n    Rational::ONE.into_digits(&Natural::ZERO);\n}\n\n#[test]\nfn to_digits_properties() {\n    rational_natural_pair_gen_var_2().test_properties(|(x, base)| {\n        let (before_point, after_point) = x.to_digits(&base);\n        let (before_point_alt, after_point_alt) = x.clone().into_digits(&base);\n        assert_eq!(before_point, before_point_alt);\n        assert_eq!(after_point, after_point_alt);\n        let (before_point, after_point) = (-&x).into_digits(&base);\n        assert_eq!(before_point, before_point_alt);\n        assert_eq!(after_point, after_point_alt);\n        assert_eq!(\n            Rational::from_digits_ref(&base, &before_point, &after_point),\n            (&x).abs()\n        );\n\n        assert_ne!(after_point.slices_ref().1, &[Natural::ZERO]);\n        assert_ne!(after_point.slices_ref().1, &[&base - Natural::ONE]);\n        assert_eq!(after_point.is_empty(), x.is_integer());\n\n        let before_point_alt: Vec<Natural> = x.abs().floor().unsigned_abs().to_digits_asc(&base);\n        assert_eq!(before_point_alt, before_point);\n    });\n\n    natural_pair_gen_var_2().test_properties(|(n, base)| {\n        assert_eq!(\n            Rational::from(&n).into_digits(&base),\n            (\n                n.to_digits_asc(&base),\n                RationalSequence::from_vec(Vec::new())\n            )\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/digits/to_power_of_2_digits.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, Floor, IsPowerOf2, UnsignedAbs};\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::conversion::traits::{IsInteger, PowerOf2Digits};\nuse malachite_base::num::logic::traits::LowMask;\nuse malachite_base::rational_sequences::RationalSequence;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_unsigned_pair_gen_var_7;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_unsigned_pair_gen_var_2;\nuse std::str::FromStr;\n\n#[test]\nfn test_to_power_of_2_digits() {\n    let test = |x: &str, log_base: u64, before_out: &str, after_out: &str| {\n        let x = Rational::from_str(x).unwrap();\n        let (before, after) = x.to_power_of_2_digits(log_base);\n        let (before_alt, after_alt) = x.into_power_of_2_digits(log_base);\n        assert_eq!(before, before_alt);\n        assert_eq!(after, after_alt);\n        assert_eq!(before.to_debug_string(), before_out);\n        assert_eq!(after.to_string(), after_out);\n    };\n    test(\"0\", 1, \"[]\", \"[]\");\n    test(\"0\", 10, \"[]\", \"[]\");\n    test(\"1\", 1, \"[1]\", \"[]\");\n    test(\"1\", 10, \"[1]\", \"[]\");\n    test(\"1/2\", 1, \"[]\", \"[1]\");\n    test(\"1/2\", 10, \"[]\", \"[512]\");\n    test(\"1/3\", 1, \"[]\", \"[[0, 1]]\");\n    test(\"1/3\", 10, \"[]\", \"[[341]]\");\n    test(\"7/6\", 1, \"[1]\", \"[0, [0, 1]]\");\n    test(\"7/6\", 10, \"[1]\", \"[170, [682]]\");\n    test(\"22/7\", 1, \"[1, 1]\", \"[[0, 0, 1]]\");\n    test(\"22/7\", 10, \"[3]\", \"[[146, 292, 585]]\");\n    test(\n        \"936851431250/1397\",\n        1,\n        \"[1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \\\n        1]\",\n        \"[[0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, \\\n        0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, \\\n        1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1]]\",\n    );\n    test(\n        \"936851431250/1397\",\n        10,\n        \"[53, 563, 639]\",\n        \"[[393, 635, 522, 643, 587, 135, 619]]\",\n    );\n    test(\n        \"6369051672525773/4503599627370496\",\n        10,\n        \"[1]\",\n        \"[424, 158, 409, 1011, 755, 256]\",\n    );\n    test(\n        \"884279719003555/281474976710656\",\n        10,\n        \"[3]\",\n        \"[144, 1014, 674, 133, 652]\",\n    );\n    test(\n        \"6121026514868073/2251799813685248\",\n        10,\n        \"[2]\",\n        \"[735, 533, 88, 650, 948, 512]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn to_power_of_2_digits_fail() {\n    Rational::ONE.to_power_of_2_digits(0);\n}\n\n#[test]\n#[should_panic]\nfn into_power_of_2_digits_fail() {\n    Rational::ONE.into_power_of_2_digits(0);\n}\n\n#[test]\nfn to_power_of_2_digits_properties() {\n    rational_unsigned_pair_gen_var_2().test_properties(|(x, log_base)| {\n        let (before_point, after_point) = x.to_power_of_2_digits(log_base);\n        let (before_point_alt, after_point_alt) = x.clone().into_power_of_2_digits(log_base);\n        assert_eq!(before_point, before_point_alt);\n        assert_eq!(after_point, after_point_alt);\n        let (before_point, after_point) = (-&x).into_power_of_2_digits(log_base);\n        assert_eq!(before_point, before_point_alt);\n        assert_eq!(after_point, after_point_alt);\n        assert_eq!(\n            Rational::from_power_of_2_digits_ref(log_base, &before_point, &after_point),\n            (&x).abs()\n        );\n\n        assert_ne!(after_point.slices_ref().1, &[Natural::ZERO]);\n        assert_ne!(after_point.slices_ref().1, &[Natural::low_mask(log_base)]);\n        assert_eq!(after_point.is_empty(), x.is_integer());\n        assert_eq!(\n            after_point.slices_ref().1.is_empty(),\n            x.denominator_ref().is_power_of_2()\n        );\n\n        let before_point_alt: Vec<Natural> = x\n            .abs()\n            .floor()\n            .unsigned_abs()\n            .to_power_of_2_digits_asc(log_base);\n        assert_eq!(before_point_alt, before_point);\n    });\n\n    natural_unsigned_pair_gen_var_7().test_properties(|(n, log_base)| {\n        assert_eq!(\n            Rational::from(&n).into_power_of_2_digits(log_base),\n            (\n                n.to_power_of_2_digits_asc(log_base),\n                RationalSequence::from_vec(Vec::new())\n            )\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/from_bool.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_q::Rational;\n\n#[test]\nfn test_from_bool() {\n    let test = |b, s| {\n        let n = Rational::from(b);\n        assert!(n.is_valid());\n        assert_eq!(n.to_string(), s);\n    };\n    test(false, \"0\");\n    test(true, \"1\");\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/from_float_simplest.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::conversion::traits::RoundingFrom;\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::primitive_float_gen_var_8;\nuse malachite_q::Rational;\nuse malachite_q::conversion::from_primitive_float::RationalFromPrimitiveFloatError;\nuse malachite_q::test_util::generators::rational_gen_var_7;\n\n#[test]\nfn test_try_from_f32_simplest() {\n    let test = |f: f32, out| {\n        let x = Rational::try_from_float_simplest(f);\n        assert_eq!(x.to_debug_string(), out);\n        if let Ok(x) = x {\n            assert!(x.is_valid());\n        }\n    };\n    test(f32::NAN, \"Err(RationalFromPrimitiveFloatError)\");\n    test(f32::INFINITY, \"Err(RationalFromPrimitiveFloatError)\");\n    test(\n        f32::NEGATIVE_INFINITY,\n        \"Err(RationalFromPrimitiveFloatError)\",\n    );\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(-123.0, \"Ok(-123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(-1.0e9, \"Ok(-1000000000)\");\n    test(4294967295.0, \"Ok(4294967296)\");\n    test(-4294967295.0, \"Ok(-4294967296)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(-4294967296.0, \"Ok(-4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551615.0, \"Ok(-18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551616.0, \"Ok(-18446744073709551616)\");\n    test(1.0e20, \"Ok(100000002004087734272)\");\n    test(-1.0e20, \"Ok(-100000002004087734272)\");\n    test(1.23e20, \"Ok(122999999650278146048)\");\n    test(-1.23e20, \"Ok(-122999999650278146048)\");\n    test(123.1, \"Ok(1231/10)\");\n    test(-123.1, \"Ok(-1231/10)\");\n    test(123.9, \"Ok(1239/10)\");\n    test(-123.9, \"Ok(-1239/10)\");\n    test(123.5, \"Ok(247/2)\");\n    test(-123.5, \"Ok(-247/2)\");\n    test(124.5, \"Ok(249/2)\");\n    test(-124.5, \"Ok(-249/2)\");\n    test(-0.499, \"Ok(-499/1000)\");\n    test(-0.5, \"Ok(-1/2)\");\n    test(0.1, \"Ok(1/10)\");\n    test(\n        f32::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(1/475749230901986627019428656483165045460915542)\",\n    );\n    test(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(-1/475749230901986627019428656483165045460915542)\",\n    );\n    test(\n        f32::MAX_SUBNORMAL,\n        \"Ok(1/85070596800837319010234175901631774785)\",\n    );\n    test(\n        -f32::MAX_SUBNORMAL,\n        \"Ok(-1/85070596800837319010234175901631774785)\",\n    );\n    test(\n        f32::MIN_POSITIVE_NORMAL,\n        \"Ok(1/85070586659632517184362935130987167681)\",\n    );\n    test(\n        -f32::MIN_POSITIVE_NORMAL,\n        \"Ok(-1/85070586659632517184362935130987167681)\",\n    );\n    test(\n        f32::MAX_FINITE,\n        \"Ok(340282346638528859811704183484516925440)\",\n    );\n    test(\n        -f32::MAX_FINITE,\n        \"Ok(-340282346638528859811704183484516925440)\",\n    );\n\n    test(std::f32::consts::SQRT_2, \"Ok(4756/3363)\");\n    test(std::f32::consts::PI, \"Ok(93343/29712)\");\n    test(std::f32::consts::E, \"Ok(2721/1001)\");\n\n    test(0.33333334, \"Ok(1/3)\");\n    test(0.3333333, \"Ok(3195660/9586981)\");\n}\n\n#[test]\nfn test_try_from_f64_simplest() {\n    let test = |f: f64, out| {\n        let x = Rational::try_from_float_simplest(f);\n        assert_eq!(x.to_debug_string(), out);\n        if let Ok(x) = x {\n            assert!(x.is_valid());\n        }\n    };\n    test(f64::NAN, \"Err(RationalFromPrimitiveFloatError)\");\n    test(f64::INFINITY, \"Err(RationalFromPrimitiveFloatError)\");\n    test(\n        f64::NEGATIVE_INFINITY,\n        \"Err(RationalFromPrimitiveFloatError)\",\n    );\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(-123.0, \"Ok(-123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(-1.0e9, \"Ok(-1000000000)\");\n    test(4294967295.0, \"Ok(4294967295)\");\n    test(-4294967295.0, \"Ok(-4294967295)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(-4294967296.0, \"Ok(-4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551615.0, \"Ok(-18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551616.0, \"Ok(-18446744073709551616)\");\n    test(1.0e20, \"Ok(100000000000000000000)\");\n    test(-1.0e20, \"Ok(-100000000000000000000)\");\n    test(1.23e20, \"Ok(123000000000000000000)\");\n    test(-1.23e20, \"Ok(-123000000000000000000)\");\n    test(\n        1.0e100,\n        \"Ok(10000000000000000159028911097599180468360808563945281389781327557747838772170381060813\\\n        469985856815104)\",\n    );\n    test(\n        -1.0e100,\n        \"Ok(-1000000000000000015902891109759918046836080856394528138978132755774783877217038106081\\\n        3469985856815104)\",\n    );\n    test(\n        1.23e100,\n        \"Ok(12300000000000000836686295084537585379506223785413935301425289783235883702867663918638\\\n        982200322686976)\",\n    );\n    test(\n        -1.23e100,\n        \"Ok(-1230000000000000083668629508453758537950622378541393530142528978323588370286766391863\\\n        8982200322686976)\",\n    );\n    test(123.1, \"Ok(1231/10)\");\n    test(-123.1, \"Ok(-1231/10)\");\n    test(123.9, \"Ok(1239/10)\");\n    test(-123.9, \"Ok(-1239/10)\");\n    test(123.5, \"Ok(247/2)\");\n    test(-123.5, \"Ok(-247/2)\");\n    test(124.5, \"Ok(249/2)\");\n    test(-124.5, \"Ok(-249/2)\");\n    test(-0.499, \"Ok(-499/1000)\");\n    test(-0.5, \"Ok(-1/2)\");\n    test(\n        f64::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(1/134934835538207078901663564479278204699704433176094745571267572018286893045330231261\\\n        306922467624749663458051909544541274259872491590528984578008933293825673281011616184377574\\\n        242977938494728810894159845118981830045708004988949795132412068903766106370893873371008239\\\n        179701555609743487001688124218339097337508871805160728996523)\",\n    );\n    test(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(-1/13493483553820707890166356447927820469970443317609474557126757201828689304533023126\\\n        130692246762474966345805190954454127425987249159052898457800893329382567328101161618437757\\\n        424297793849472881089415984511898183004570800498894979513241206890376610637089387337100823\\\n        9179701555609743487001688124218339097337508871805160728996523)\",\n    );\n    test(\n        f64::MAX_SUBNORMAL,\n        \"Ok(1/449423283715579026828334036065257014383474871770369402158895481105061903177076758952\\\n        991447760350212414247530205607522865754608382719974023705572587637923509973673766132988527\\\n        495573581641607121816936686895147170329503865639571478615835487722625286251243883901055723\\\n        06631238281271786009918606677660346752204801)\",\n    );\n    test(\n        -f64::MAX_SUBNORMAL,\n        \"Ok(-1/44942328371557902682833403606525701438347487177036940215889548110506190317707675895\\\n        299144776035021241424753020560752286575460838271997402370557258763792350997367376613298852\\\n        749557358164160712181693668689514717032950386563957147861583548772262528625124388390105572\\\n        306631238281271786009918606677660346752204801)\",\n    );\n    test(\n        f64::MIN_POSITIVE_NORMAL,\n        \"Ok(1/449423283715578927036318559329266431564839219927211067229101097246506353572882385286\\\n        930040496229077692647131520826525095187415228669222594373726590254689108839132120159189741\\\n        421503549517982068519788656012202297150024869750306233834035420571989467252315767391654946\\\n        28061906253051009157224240331719237716377601)\",\n    );\n    test(\n        -f64::MIN_POSITIVE_NORMAL,\n        \"Ok(-1/44942328371557892703631855932926643156483921992721106722910109724650635357288238528\\\n        693004049622907769264713152082652509518741522866922259437372659025468910883913212015918974\\\n        142150354951798206851978865601220229715002486975030623383403542057198946725231576739165494\\\n        628061906253051009157224240331719237716377601)\",\n    );\n    test(\n        f64::MAX_FINITE,\n        \"Ok(17976931348623157081452742373170435679807056752584499659891747680315726078002853876058\\\n        955863276687817154045895351438246423432132688946418276846754670353751698604991057655128207\\\n        624549009038932894407586850845513394230458323690322294816580855933212334827479782620414472\\\n        3168738177180919299881250404026184124858368)\",\n    );\n    test(\n        -f64::MAX_FINITE,\n        \"Ok(-1797693134862315708145274237317043567980705675258449965989174768031572607800285387605\\\n        895586327668781715404589535143824642343213268894641827684675467035375169860499105765512820\\\n        762454900903893289440758685084551339423045832369032229481658085593321233482747978262041447\\\n        23168738177180919299881250404026184124858368)\",\n    );\n\n    test(std::f64::consts::SQRT_2, \"Ok(131836323/93222358)\");\n    test(std::f64::consts::PI, \"Ok(245850922/78256779)\");\n    test(std::f64::consts::E, \"Ok(268876667/98914198)\");\n\n    test(0.3333333333333333, \"Ok(1/3)\");\n    test(0.3333333333333337, \"Ok(279293000147008/837879000441023)\");\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn try_from_float_simplest_properties_helper<\n    T: for<'a> RoundingFrom<&'a Rational> + for<'a> TryFrom<&'a Rational> + PrimitiveFloat,\n>()\nwhere\n    Rational: TryFrom<T, Error = RationalFromPrimitiveFloatError>,\n{\n    primitive_float_gen_var_8::<T>().test_properties(|f| {\n        let q = Rational::try_from_float_simplest(f);\n        if let Ok(q) = q {\n            assert!(q.is_valid());\n            assert_eq!(Rational::try_from_float_simplest(-f), Ok(-&q));\n        }\n    });\n\n    rational_gen_var_7().test_properties(|q| {\n        // This only works for simple `Rational`s, i.e. those `Rational`s q that round to a float x\n        // such that no simpler `Rational` rounds to x. This test will eventually fail, e.g. for\n        // 3571/5778, which is very close to 1/phi. But as long as only the first 10,000 inputs in\n        // each generation mode are tested, it will succeed.\n        assert_eq!(\n            Rational::try_from_float_simplest(T::rounding_from(&q, Nearest).0),\n            Ok(q)\n        );\n    });\n}\n\n#[test]\nfn try_from_float_simplest_properties() {\n    apply_fn_to_primitive_floats!(try_from_float_simplest_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/from_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_integer() {\n    let test = |s| {\n        let u = Integer::from_str(s).unwrap();\n\n        let x = Rational::from(u.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), s);\n\n        let x = Rational::from(&u);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), s);\n    };\n    test(\"0\");\n    test(\"123\");\n    test(\"1000000000000\");\n    test(\"-123\");\n    test(\"-1000000000000\");\n}\n\n#[test]\nfn from_integer_properties() {\n    integer_gen().test_properties(|x| {\n        let rational_x = Rational::from(x.clone());\n        assert!(rational_x.is_valid());\n        assert_eq!(rational_x.to_string(), x.to_string());\n\n        let rational_x_alt = Rational::from(&x);\n        assert!(rational_x_alt.is_valid());\n        assert_eq!(rational_x_alt, rational_x);\n\n        assert_eq!(Integer::try_from(&rational_x).as_ref(), Ok(&x));\n        assert_eq!(Integer::try_from(rational_x), Ok(x));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/from_natural.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_q::Rational;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_natural() {\n    let test = |s| {\n        let u = Natural::from_str(s).unwrap();\n\n        let x = Rational::from(u.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), s);\n\n        let x = Rational::from(&u);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), s);\n    };\n    test(\"0\");\n    test(\"123\");\n    test(\"1000000000000\");\n}\n\n#[test]\nfn from_natural_properties() {\n    natural_gen().test_properties(|x| {\n        let rational_x = Rational::from(x.clone());\n        assert!(rational_x.is_valid());\n        assert_eq!(rational_x.to_string(), x.to_string());\n\n        let rational_x_alt = Rational::from(&x);\n        assert!(rational_x_alt.is_valid());\n        assert_eq!(rational_x_alt, rational_x);\n\n        assert_eq!(Natural::try_from(&rational_x).as_ref(), Ok(&x));\n        assert_eq!(Natural::try_from(rational_x), Ok(x));\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/from_numerator_and_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{CoprimeWith, UnsignedAbs};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{\n    signed_gen, signed_pair_gen_var_6, unsigned_gen, unsigned_pair_gen_var_12,\n    unsigned_unsigned_bool_triple_gen_var_2,\n};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_pair_gen_var_1, natural_gen, natural_natural_bool_triple_gen_var_1,\n    natural_pair_gen_var_5,\n};\nuse malachite_q::Rational;\nuse num::{BigInt, BigRational};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_naturals() {\n    let test = |n, d, out| {\n        let n = Natural::from_str(n).unwrap();\n        let d = Natural::from_str(d).unwrap();\n        let x = Rational::from_naturals(n.clone(), d.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n\n        let x = Rational::from_naturals_ref(&n, &d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"5\", \"0\");\n    test(\"3\", \"6\", \"1/2\");\n    test(\"100\", \"101\", \"100/101\");\n}\n\n#[test]\nfn from_naturals_fail() {\n    assert_panic!(Rational::from_naturals(Natural::ZERO, Natural::ZERO));\n    assert_panic!(Rational::from_naturals(Natural::ONE, Natural::ZERO));\n    assert_panic!(Rational::from_naturals_ref(&Natural::ZERO, &Natural::ZERO));\n    assert_panic!(Rational::from_naturals_ref(&Natural::ONE, &Natural::ZERO));\n}\n\n#[test]\nfn from_naturals_properties() {\n    natural_pair_gen_var_5().test_properties(|(n, d)| {\n        let x = Rational::from_naturals(n.clone(), d.clone());\n        assert!(x.is_valid());\n\n        let x_alt = Rational::from_naturals_ref(&n, &d);\n        assert!(x.is_valid());\n        assert_eq!(x, x_alt);\n\n        if (&n).coprime_with(&d) {\n            assert_eq!(x.into_numerator_and_denominator(), (n, d));\n        }\n    });\n\n    natural_gen()\n        .test_properties(|n| assert_eq!(Rational::from_naturals_ref(&n, &Natural::ONE), n));\n}\n\nfn test_from_unsigneds_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n    Limb: ExactFrom<T>,\n{\n    let test = |n: u8, d: u8, out| {\n        let n = T::from(n);\n        let d = T::from(d);\n        let x = Rational::from_unsigneds(n, d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        if T::WIDTH == Limb::WIDTH {\n            let x_alt = Rational::const_from_unsigneds(Limb::exact_from(n), Limb::exact_from(d));\n            assert!(x_alt.is_valid());\n            assert!(PartialEq::<Rational>::eq(&x_alt, &x));\n        }\n    };\n    test(0, 1, \"0\");\n    test(0, 5, \"0\");\n    test(3, 6, \"1/2\");\n    test(100, 101, \"100/101\");\n}\n\nfn from_unsigneds_fail_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n{\n    assert_panic!(Rational::from_unsigneds(T::ZERO, T::ZERO));\n    assert_panic!(Rational::from_unsigneds(T::ONE, T::ZERO));\n}\n\n#[test]\nfn from_unsigneds_fail() {\n    apply_fn_to_unsigneds!(from_unsigneds_fail_helper);\n}\n\n#[test]\nfn test_from_unsigneds() {\n    apply_fn_to_unsigneds!(test_from_unsigneds_helper);\n}\n\n#[test]\nfn test_const_from_unsigneds() {\n    let test = |n: Limb, d: Limb, out| {\n        let x = Rational::from_unsigneds(n, d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n\n        let x_alt = Rational::const_from_unsigneds(Limb::exact_from(n), Limb::exact_from(d));\n        assert!(x_alt.is_valid());\n        assert_eq!(x_alt.to_string(), out);\n    };\n    test(0, 1, \"0\");\n    test(0, 5, \"0\");\n    test(3, 6, \"1/2\");\n    test(100, 101, \"100/101\");\n    // The following test case has the highest number of steps in the Euclidean GCD algorithm.\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    test(\n        7540113804746346429,\n        12200160415121876738,\n        \"7540113804746346429/12200160415121876738\",\n    );\n    #[cfg(not(feature = \"32_bit_limbs\"))]\n    test(\n        7540113804746346430,\n        12200160415121876738,\n        \"3770056902373173215/6100080207560938369\",\n    );\n}\n\n#[test]\nfn const_from_unsigneds_fail() {\n    assert_panic!(Rational::const_from_unsigneds(0, 0));\n    assert_panic!(Rational::const_from_unsigneds(1, 0));\n}\n\nfn from_unsigneds_properties_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T> + PartialEq<T>,\n    Rational: PartialEq<T>,\n    Limb: ExactFrom<T>,\n{\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(n, d)| {\n        let x = Rational::from_unsigneds(n, d);\n        assert!(x.is_valid());\n        if n.coprime_with(d) {\n            let (n_alt, d_alt) = x.clone().into_numerator_and_denominator();\n            assert_eq!(n_alt, n);\n            assert_eq!(d_alt, d);\n        }\n        if T::WIDTH == Limb::WIDTH {\n            let x_alt = Rational::const_from_unsigneds(Limb::exact_from(n), Limb::exact_from(d));\n            assert!(x_alt.is_valid());\n            assert!(PartialEq::<Rational>::eq(&x_alt, &x));\n        }\n    });\n\n    unsigned_gen::<T>().test_properties(|n| assert_eq!(Rational::from_unsigneds(n, T::ONE), n));\n}\n\n#[test]\nfn from_unsigneds_properties() {\n    apply_fn_to_unsigneds!(from_unsigneds_properties_helper);\n}\n\n#[test]\nfn const_from_unsigneds_properties() {\n    unsigned_pair_gen_var_12::<Limb, Limb>().test_properties(|(n, d)| {\n        let x = Rational::from_unsigneds(n, d);\n        let x_alt = Rational::const_from_unsigneds(n, d);\n        assert!(x_alt.is_valid());\n        assert_eq!(x_alt, x);\n    });\n}\n\n#[test]\nfn test_from_integers() {\n    let test = |s, t, out| {\n        let n = Integer::from_str(s).unwrap();\n        let d = Integer::from_str(t).unwrap();\n        let x = Rational::from_integers(n.clone(), d.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n\n        let x = Rational::from_integers_ref(&n, &d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n\n        assert_eq!(\n            BigRational::new(BigInt::from_str(s).unwrap(), BigInt::from_str(t).unwrap())\n                .to_string(),\n            out\n        );\n        assert_eq!(\n            rug::Rational::from((\n                rug::Integer::from_str(s).unwrap(),\n                rug::Integer::from_str(t).unwrap()\n            ))\n            .to_string(),\n            out\n        );\n    };\n    test(\"0\", \"1\", \"0\");\n    test(\"0\", \"-1\", \"0\");\n    test(\"0\", \"5\", \"0\");\n    test(\"0\", \"-5\", \"0\");\n    test(\"3\", \"6\", \"1/2\");\n    test(\"3\", \"-6\", \"-1/2\");\n    test(\"-3\", \"6\", \"-1/2\");\n    test(\"-3\", \"-6\", \"1/2\");\n    test(\"100\", \"101\", \"100/101\");\n    test(\"100\", \"-101\", \"-100/101\");\n    test(\"-100\", \"101\", \"-100/101\");\n    test(\"-100\", \"-101\", \"100/101\");\n}\n\n#[test]\nfn from_integers_fail() {\n    assert_panic!(Rational::from_integers(Integer::ZERO, Integer::ZERO));\n    assert_panic!(Rational::from_integers(Integer::ONE, Integer::ZERO));\n    assert_panic!(Rational::from_integers_ref(&Integer::ZERO, &Integer::ZERO));\n    assert_panic!(Rational::from_integers_ref(&Integer::ONE, &Integer::ZERO));\n}\n\n#[test]\nfn from_integers_properties() {\n    integer_pair_gen_var_1().test_properties(|(n, d)| {\n        let x = Rational::from_integers(n.clone(), d.clone());\n        assert!(x.is_valid());\n\n        let x_alt = Rational::from_integers_ref(&n, &d);\n        assert!(x.is_valid());\n        assert_eq!(x, x_alt);\n\n        assert_eq!(\n            Rational::from(&BigRational::new(BigInt::from(&n), BigInt::from(&d))),\n            x\n        );\n        assert_eq!(\n            Rational::from(&rug::Rational::from((\n                rug::Integer::from(&n),\n                rug::Integer::from(&d)\n            ))),\n            x\n        );\n\n        if n != 0 {\n            assert_eq!(x >= 0, (n >= 0) == (d >= 0));\n        }\n        if n >= 0 && d > 0 && (n.unsigned_abs_ref()).coprime_with(d.unsigned_abs_ref()) {\n            let (n_2, d_2) = x.into_numerator_and_denominator();\n            assert_eq!((Integer::from(n_2), Integer::from(d_2)), (n, d));\n        }\n    });\n\n    integer_gen()\n        .test_properties(|n| assert_eq!(Rational::from_integers_ref(&n, &Integer::ONE), n));\n}\n\nfn test_from_signeds_helper<T: PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n    SignedLimb: ExactFrom<T>,\n{\n    let test = |n: i8, d: i8, out| {\n        let n = T::from(n);\n        let d = T::from(d);\n        let x = Rational::from_signeds(n, d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n        if T::WIDTH == Limb::WIDTH {\n            let x_alt =\n                Rational::const_from_signeds(SignedLimb::exact_from(n), SignedLimb::exact_from(d));\n            assert!(x_alt.is_valid());\n            assert!(PartialEq::<Rational>::eq(&x_alt, &x));\n        }\n    };\n    test(0, 1, \"0\");\n    test(0, -1, \"0\");\n    test(0, 5, \"0\");\n    test(0, -5, \"0\");\n    test(3, 6, \"1/2\");\n    test(3, -6, \"-1/2\");\n    test(-3, 6, \"-1/2\");\n    test(-3, -6, \"1/2\");\n    test(100, 101, \"100/101\");\n    test(100, -101, \"-100/101\");\n    test(-100, 101, \"-100/101\");\n    test(-100, -101, \"100/101\");\n}\n\n#[test]\nfn test_from_signeds() {\n    apply_fn_to_signeds!(test_from_signeds_helper);\n}\n\nfn from_signeds_fail_helper<T: PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n{\n    assert_panic!(Rational::from_signeds(T::ZERO, T::ZERO));\n    assert_panic!(Rational::from_signeds(T::ONE, T::ZERO));\n}\n\n#[test]\nfn from_signeds_fail() {\n    apply_fn_to_signeds!(from_signeds_fail_helper);\n}\n\n#[test]\nfn const_from_signeds_fail() {\n    assert_panic!(Rational::const_from_signeds(0, 0));\n    assert_panic!(Rational::const_from_signeds(1, 0));\n}\n\nfn from_signeds_properties_helper<T: PrimitiveSigned>()\nwhere\n    Integer: From<T>,\n    rug::Rational: From<(T, T)>,\n    <T as UnsignedAbs>::Output: CoprimeWith,\n    Natural: PartialEq<T>,\n    Rational: PartialEq<T>,\n    SignedLimb: ExactFrom<T>,\n{\n    signed_pair_gen_var_6::<T>().test_properties(|(n, d)| {\n        let x = Rational::from_signeds(n, d);\n        assert!(x.is_valid());\n\n        let x_alt = Rational::from(&rug::Rational::from((n, d)));\n        assert!(PartialEq::<Rational>::eq(&x_alt, &x));\n        if n != T::ZERO {\n            assert_eq!(\n                PartialOrd::<u32>::ge(&x, &0u32),\n                (n >= T::ZERO) == (d >= T::ZERO)\n            );\n        }\n        if n >= T::ZERO && d > T::ZERO && (n.unsigned_abs()).coprime_with(d.unsigned_abs()) {\n            let (n_2, d_2) = x.clone().into_numerator_and_denominator();\n            assert_eq!(n_2, n);\n            assert_eq!(d_2, d);\n        }\n        if T::WIDTH == Limb::WIDTH {\n            let x_alt =\n                Rational::const_from_signeds(SignedLimb::exact_from(n), SignedLimb::exact_from(d));\n            assert!(x_alt.is_valid());\n            assert!(PartialEq::<Rational>::eq(&x_alt, &x));\n        }\n    });\n\n    signed_gen::<T>().test_properties(|n| assert_eq!(Rational::from_signeds(n, T::ONE), n));\n}\n\n#[test]\nfn from_signeds_properties() {\n    apply_fn_to_signeds!(from_signeds_properties_helper);\n}\n\n#[test]\nfn const_from_signeds_properties() {\n    signed_pair_gen_var_6::<SignedLimb>().test_properties(|(n, d)| {\n        let x = Rational::from_signeds(n, d);\n        let x_alt = Rational::const_from_signeds(n, d);\n        assert!(x_alt.is_valid());\n        assert_eq!(x_alt, x);\n    });\n}\n\n#[test]\nfn test_from_sign_and_naturals() {\n    let test = |sign, n, d, out| {\n        let n = Natural::from_str(n).unwrap();\n        let d = Natural::from_str(d).unwrap();\n        let x = Rational::from_sign_and_naturals(sign, n.clone(), d.clone());\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n\n        let x = Rational::from_sign_and_naturals_ref(sign, &n, &d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(false, \"0\", \"1\", \"0\");\n    test(true, \"0\", \"1\", \"0\");\n    test(false, \"0\", \"5\", \"0\");\n    test(true, \"0\", \"5\", \"0\");\n    test(false, \"3\", \"6\", \"-1/2\");\n    test(true, \"3\", \"6\", \"1/2\");\n    test(false, \"100\", \"101\", \"-100/101\");\n    test(true, \"100\", \"101\", \"100/101\");\n}\n\n#[test]\nfn from_sign_and_naturals_properties() {\n    natural_natural_bool_triple_gen_var_1().test_properties(|(n, d, sign)| {\n        let x = Rational::from_sign_and_naturals(sign, n.clone(), d.clone());\n        assert!(x.is_valid());\n\n        let x_alt = Rational::from_sign_and_naturals_ref(sign, &n, &d);\n        assert!(x.is_valid());\n        assert_eq!(x, x_alt);\n\n        if n != 0 {\n            assert_eq!(x >= 0, sign);\n        }\n        if (&n).coprime_with(&d) {\n            assert_eq!(x.into_numerator_and_denominator(), (n, d));\n        }\n    });\n\n    natural_pair_gen_var_5().test_properties(|(n, d)| {\n        assert_eq!(\n            Rational::from_naturals(n.clone(), d.clone()),\n            Rational::from_sign_and_naturals(true, n, d)\n        );\n    });\n\n    natural_gen().test_properties(|n| {\n        assert_eq!(\n            Rational::from_sign_and_naturals_ref(true, &n, &Natural::ONE),\n            n\n        );\n    });\n}\n\nfn test_from_sign_and_unsigneds_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T>,\n{\n    let test = |sign, n: u8, d: u8, out| {\n        let n = T::from(n);\n        let d = T::from(d);\n        let x = Rational::from_sign_and_unsigneds(sign, n, d);\n        assert!(x.is_valid());\n        assert_eq!(x.to_string(), out);\n    };\n    test(false, 0, 1, \"0\");\n    test(true, 0, 1, \"0\");\n    test(false, 0, 5, \"0\");\n    test(true, 0, 5, \"0\");\n    test(false, 3, 6, \"-1/2\");\n    test(true, 3, 6, \"1/2\");\n    test(false, 100, 101, \"-100/101\");\n    test(true, 100, 101, \"100/101\");\n}\n\n#[test]\nfn test_from_sign_and_unsigneds() {\n    apply_fn_to_unsigneds!(test_from_sign_and_unsigneds_helper);\n}\n\nfn from_sign_and_unsigneds_properties_helper<T: PrimitiveUnsigned>()\nwhere\n    Natural: From<T> + PartialEq<T>,\n    Rational: PartialEq<T>,\n{\n    unsigned_unsigned_bool_triple_gen_var_2::<T, T>().test_properties(|(n, d, sign)| {\n        let x = Rational::from_sign_and_unsigneds(sign, n, d);\n        assert!(x.is_valid());\n        if n != T::ZERO {\n            assert_eq!(PartialOrd::<u32>::ge(&x, &0u32), sign);\n        }\n        if n.coprime_with(d) {\n            let (n_alt, d_alt) = x.into_numerator_and_denominator();\n            assert_eq!(n_alt, n);\n            assert_eq!(d_alt, d);\n        }\n    });\n\n    unsigned_pair_gen_var_12::<T, T>().test_properties(|(n, d)| {\n        assert!(PartialEq::<Rational>::eq(\n            &Rational::from_unsigneds(n, d),\n            &Rational::from_sign_and_unsigneds(true, n, d)\n        ));\n    });\n\n    unsigned_gen::<T>()\n        .test_properties(|n| assert_eq!(Rational::from_sign_and_unsigneds(true, n, T::ONE), n));\n}\n\n#[test]\nfn from_sign_and_unsigneds_properties() {\n    apply_fn_to_unsigneds!(from_sign_and_unsigneds_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/from_primitive_float.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::test_util::generators::{primitive_float_gen, primitive_float_gen_var_8};\nuse malachite_q::Rational;\n\n#[test]\nfn test_try_from_f32() {\n    let test = |f: f32, out| {\n        let x = Rational::try_from(f);\n        assert_eq!(x.to_debug_string(), out);\n        if let Ok(x) = x {\n            assert!(x.is_valid());\n        }\n    };\n    test(f32::NAN, \"Err(RationalFromPrimitiveFloatError)\");\n    test(f32::INFINITY, \"Err(RationalFromPrimitiveFloatError)\");\n    test(\n        f32::NEGATIVE_INFINITY,\n        \"Err(RationalFromPrimitiveFloatError)\",\n    );\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(-123.0, \"Ok(-123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(-1.0e9, \"Ok(-1000000000)\");\n    test(4294967295.0, \"Ok(4294967296)\");\n    test(-4294967295.0, \"Ok(-4294967296)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(-4294967296.0, \"Ok(-4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551615.0, \"Ok(-18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551616.0, \"Ok(-18446744073709551616)\");\n    test(1.0e20, \"Ok(100000002004087734272)\");\n    test(-1.0e20, \"Ok(-100000002004087734272)\");\n    test(1.23e20, \"Ok(122999999650278146048)\");\n    test(-1.23e20, \"Ok(-122999999650278146048)\");\n    test(123.1, \"Ok(16134963/131072)\");\n    test(-123.1, \"Ok(-16134963/131072)\");\n    test(123.9, \"Ok(16239821/131072)\");\n    test(-123.9, \"Ok(-16239821/131072)\");\n    test(123.5, \"Ok(247/2)\");\n    test(-123.5, \"Ok(-247/2)\");\n    test(124.5, \"Ok(249/2)\");\n    test(-124.5, \"Ok(-249/2)\");\n    test(-0.499, \"Ok(-8371831/16777216)\");\n    test(-0.5, \"Ok(-1/2)\");\n    test(0.1, \"Ok(13421773/134217728)\");\n    test(\n        f32::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(1/713623846352979940529142984724747568191373312)\",\n    );\n    test(\n        -f32::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(-1/713623846352979940529142984724747568191373312)\",\n    );\n    test(\n        f32::MAX_SUBNORMAL,\n        \"Ok(8388607/713623846352979940529142984724747568191373312)\",\n    );\n    test(\n        -f32::MAX_SUBNORMAL,\n        \"Ok(-8388607/713623846352979940529142984724747568191373312)\",\n    );\n    test(\n        f32::MIN_POSITIVE_NORMAL,\n        \"Ok(1/85070591730234615865843651857942052864)\",\n    );\n    test(\n        -f32::MIN_POSITIVE_NORMAL,\n        \"Ok(-1/85070591730234615865843651857942052864)\",\n    );\n    test(\n        f32::MAX_FINITE,\n        \"Ok(340282346638528859811704183484516925440)\",\n    );\n    test(\n        -f32::MAX_FINITE,\n        \"Ok(-340282346638528859811704183484516925440)\",\n    );\n\n    test(std::f32::consts::SQRT_2, \"Ok(11863283/8388608)\");\n    test(std::f32::consts::PI, \"Ok(13176795/4194304)\");\n    test(std::f32::consts::E, \"Ok(2850325/1048576)\");\n}\n\n#[test]\nfn test_try_from_f64() {\n    let test = |f: f64, out| {\n        let x = Rational::try_from(f);\n        assert_eq!(x.to_debug_string(), out);\n        if let Ok(x) = x {\n            assert!(x.is_valid());\n        }\n    };\n    test(f64::NAN, \"Err(RationalFromPrimitiveFloatError)\");\n    test(f64::INFINITY, \"Err(RationalFromPrimitiveFloatError)\");\n    test(\n        f64::NEGATIVE_INFINITY,\n        \"Err(RationalFromPrimitiveFloatError)\",\n    );\n    test(0.0, \"Ok(0)\");\n    test(-0.0, \"Ok(0)\");\n    test(123.0, \"Ok(123)\");\n    test(-123.0, \"Ok(-123)\");\n    test(1.0e9, \"Ok(1000000000)\");\n    test(-1.0e9, \"Ok(-1000000000)\");\n    test(4294967295.0, \"Ok(4294967295)\");\n    test(-4294967295.0, \"Ok(-4294967295)\");\n    test(4294967296.0, \"Ok(4294967296)\");\n    test(-4294967296.0, \"Ok(-4294967296)\");\n    test(18446744073709551615.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551615.0, \"Ok(-18446744073709551616)\");\n    test(18446744073709551616.0, \"Ok(18446744073709551616)\");\n    test(-18446744073709551616.0, \"Ok(-18446744073709551616)\");\n    test(1.0e20, \"Ok(100000000000000000000)\");\n    test(-1.0e20, \"Ok(-100000000000000000000)\");\n    test(1.23e20, \"Ok(123000000000000000000)\");\n    test(-1.23e20, \"Ok(-123000000000000000000)\");\n    test(\n        1.0e100,\n        \"Ok(10000000000000000159028911097599180468360808563945281389781327557747838772170381060813\\\n        469985856815104)\",\n    );\n    test(\n        -1.0e100,\n        \"Ok(-1000000000000000015902891109759918046836080856394528138978132755774783877217038106081\\\n        3469985856815104)\",\n    );\n    test(\n        1.23e100,\n        \"Ok(12300000000000000836686295084537585379506223785413935301425289783235883702867663918638\\\n        982200322686976)\",\n    );\n    test(\n        -1.23e100,\n        \"Ok(-1230000000000000083668629508453758537950622378541393530142528978323588370286766391863\\\n        8982200322686976)\",\n    );\n    test(123.1, \"Ok(4331196204135219/35184372088832)\");\n    test(-123.1, \"Ok(-4331196204135219/35184372088832)\");\n    test(123.9, \"Ok(4359343701806285/35184372088832)\");\n    test(-123.9, \"Ok(-4359343701806285/35184372088832)\");\n    test(123.5, \"Ok(247/2)\");\n    test(-123.5, \"Ok(-247/2)\");\n    test(124.5, \"Ok(249/2)\");\n    test(-124.5, \"Ok(-249/2)\");\n    test(-0.499, \"Ok(-4494592428115755/9007199254740992)\");\n    test(-0.5, \"Ok(-1/2)\");\n    test(\n        f64::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(1/202402253307310618352495346718917307049556649764142118356901358027430339567995346891\\\n        960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361\\\n        364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358\\\n        769552333414615230502532186327508646006263307707741093494784)\",\n    );\n    test(\n        -f64::MIN_POSITIVE_SUBNORMAL,\n        \"Ok(-1/20240225330731061835249534671891730704955664976414211835690135802743033956799534689\\\n        196038370143712449518707786431681191138980873738579347686701339994073850992151742427656636\\\n        136446690774209321634123976767847274506856200748342469269861810335564915955634081005651235\\\n        8769552333414615230502532186327508646006263307707741093494784)\",\n    );\n    test(\n        f64::MAX_SUBNORMAL,\n        \"Ok(4503599627370495/202402253307310618352495346718917307049556649764142118356901358027430\\\n        339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921\\\n        517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556\\\n        340810056512358769552333414615230502532186327508646006263307707741093494784)\",\n    );\n    test(\n        -f64::MAX_SUBNORMAL,\n        \"Ok(-4503599627370495/20240225330731061835249534671891730704955664976414211835690135802743\\\n        033956799534689196038370143712449518707786431681191138980873738579347686701339994073850992\\\n        151742427656636136446690774209321634123976767847274506856200748342469269861810335564915955\\\n        6340810056512358769552333414615230502532186327508646006263307707741093494784)\",\n    );\n    test(\n        f64::MIN_POSITIVE_NORMAL,\n        \"Ok(1/449423283715578976932326297697256183404494244735576643183575202894331689513752407831\\\n        771193306018840052800284699678483394146974422036041556232118576598685310944419733562163713\\\n        190755549003115235298632707380212514422095376705856157203684782776352068092908376276711465\\\n        74559986811484619929076208839082406056034304)\",\n    );\n    test(\n        -f64::MIN_POSITIVE_NORMAL,\n        \"Ok(-1/44942328371557897693232629769725618340449424473557664318357520289433168951375240783\\\n        177119330601884005280028469967848339414697442203604155623211857659868531094441973356216371\\\n        319075554900311523529863270738021251442209537670585615720368478277635206809290837627671146\\\n        574559986811484619929076208839082406056034304)\",\n    );\n    test(\n        f64::MAX_FINITE,\n        \"Ok(17976931348623157081452742373170435679807056752584499659891747680315726078002853876058\\\n        955863276687817154045895351438246423432132688946418276846754670353751698604991057655128207\\\n        624549009038932894407586850845513394230458323690322294816580855933212334827479782620414472\\\n        3168738177180919299881250404026184124858368)\",\n    );\n    test(\n        -f64::MAX_FINITE,\n        \"Ok(-1797693134862315708145274237317043567980705675258449965989174768031572607800285387605\\\n        895586327668781715404589535143824642343213268894641827684675467035375169860499105765512820\\\n        762454900903893289440758685084551339423045832369032229481658085593321233482747978262041447\\\n        23168738177180919299881250404026184124858368)\",\n    );\n\n    test(\n        std::f64::consts::SQRT_2,\n        \"Ok(6369051672525773/4503599627370496)\",\n    );\n    test(std::f64::consts::PI, \"Ok(884279719003555/281474976710656)\");\n    test(std::f64::consts::E, \"Ok(6121026514868073/2251799813685248)\");\n}\n\n#[test]\nfn test_rational_convertible_from_f32() {\n    let test = |f: f32, out| {\n        assert_eq!(Rational::convertible_from(f), out);\n    };\n    test(0.0, true);\n    test(1.0, true);\n    test(1.5, true);\n    test(0.1, true);\n\n    test(f32::NAN, false);\n    test(f32::INFINITY, false);\n    test(f32::NEGATIVE_INFINITY, false);\n}\n\n#[test]\nfn test_rational_convertible_from_f64() {\n    let test = |f: f64, out| {\n        assert_eq!(Rational::convertible_from(f), out);\n    };\n    test(0.0, true);\n    test(1.0, true);\n    test(1.5, true);\n    test(0.1, true);\n\n    test(f64::NAN, false);\n    test(f64::INFINITY, false);\n    test(f64::NEGATIVE_INFINITY, false);\n}\n\nfn try_from_float_properties_helper<T: ExactFrom<Rational> + PrimitiveFloat>()\nwhere\n    Rational: ConvertibleFrom<T> + TryFrom<T>,\n{\n    primitive_float_gen::<T>().test_properties(|f| {\n        let n = Rational::try_from(f);\n        assert_eq!(n.is_ok(), Rational::convertible_from(f));\n        if let Ok(n) = n {\n            assert!(n.is_valid());\n            assert_eq!(Rational::exact_from(-f), -&n);\n            assert_eq!(\n                NiceFloat(T::exact_from(n)),\n                NiceFloat(f.abs_negative_zero())\n            );\n        }\n    });\n}\n\n#[test]\nfn try_from_float_properties() {\n    apply_fn_to_primitive_floats!(try_from_float_properties_helper);\n\n    primitive_float_gen_var_8::<f32>().test_properties(|f| {\n        assert_eq!(\n            Rational::exact_from(f),\n            Rational::from(&rug::Rational::from_f32(f).unwrap())\n        );\n    });\n\n    primitive_float_gen_var_8::<f64>().test_properties(|f| {\n        assert_eq!(\n            Rational::exact_from(f),\n            Rational::from(&rug::Rational::from_f64(f).unwrap())\n        );\n    });\n}\n\nfn rational_convertible_from_primitive_float_properties_helper<T: PrimitiveFloat>()\nwhere\n    Rational: ConvertibleFrom<T>,\n{\n    primitive_float_gen().test_properties(|f| {\n        assert_eq!(\n            Rational::convertible_from(f),\n            Rational::convertible_from(-f)\n        );\n    });\n}\n\n#[test]\nfn rational_convertible_from_primitive_float_properties() {\n    apply_fn_to_primitive_floats!(rational_convertible_from_primitive_float_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/from_primitive_int.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::test_util::generators::{signed_gen, signed_gen_var_2, unsigned_gen};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::platform::{Limb, SignedLimb};\nuse malachite_q::Rational;\nuse rug;\n\n#[test]\nfn test_from_u32() {\n    let test = |u: u32, out| {\n        let x = Rational::from(u);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(rug::Rational::from(u).to_string(), out);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let x_alt = Rational::const_from_unsigned(u);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(u32::MAX, \"4294967295\");\n}\n\n#[test]\nfn test_from_u64() {\n    let test = |u: u64, out| {\n        let x = Rational::from(u);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(rug::Rational::from(u).to_string(), out);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let x_alt = Rational::const_from_unsigned(u);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(u64::MAX, \"18446744073709551615\");\n}\n\n#[test]\nfn test_from_i32() {\n    let test = |i: i32, out| {\n        let x = Rational::from(i);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(rug::Rational::from(i).to_string(), out);\n        #[cfg(feature = \"32_bit_limbs\")]\n        {\n            let x_alt = Rational::const_from_signed(i);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(-123, \"-123\");\n    test(i32::MIN, \"-2147483648\");\n    test(i32::MAX, \"2147483647\");\n}\n\n#[test]\nfn test_from_i64() {\n    let test = |i: i64, out| {\n        let x = Rational::from(i);\n        assert_eq!(x.to_string(), out);\n        assert!(x.is_valid());\n        assert_eq!(rug::Rational::from(i).to_string(), out);\n        #[cfg(not(feature = \"32_bit_limbs\"))]\n        {\n            let x_alt = Rational::const_from_signed(i);\n            assert!(x_alt.is_valid());\n            assert_eq!(x_alt.to_string(), out);\n        }\n    };\n    test(0, \"0\");\n    test(123, \"123\");\n    test(-123, \"-123\");\n    test(i64::MIN, \"-9223372036854775808\");\n    test(i64::MAX, \"9223372036854775807\");\n}\n\nfn from_unsigned_properties_helper<T: for<'a> TryFrom<&'a Rational> + PrimitiveUnsigned>()\nwhere\n    Rational: From<T>,\n    Natural: From<T>,\n    u128: TryFrom<T>,\n    rug::Integer: From<T>,\n    Limb: ExactFrom<T>,\n{\n    unsigned_gen::<T>().test_properties(|u| {\n        let n = Rational::from(u);\n        assert!(n.is_valid());\n        assert_eq!(T::exact_from(&n), u);\n        let alt_n: Rational = From::from(Natural::from(u));\n        assert_eq!(alt_n, n);\n        let alt_n: Rational = From::from(u128::exact_from(u));\n        assert_eq!(alt_n, n);\n        let alt_n: Rational = From::from(&rug::Rational::from(u));\n        assert_eq!(alt_n, n);\n        if T::WIDTH == Limb::WIDTH {\n            let n_alt = Rational::const_from_unsigned(Limb::exact_from(u));\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n}\n\nfn from_signed_properties_helper<T: for<'a> TryFrom<&'a Rational> + PrimitiveSigned>()\nwhere\n    Rational: From<T>,\n    Natural: TryFrom<T>,\n    i128: TryFrom<T>,\n    rug::Integer: From<T>,\n    SignedLimb: ExactFrom<T>,\n{\n    signed_gen::<T>().test_properties(|i| {\n        let n = Rational::from(i);\n        assert!(n.is_valid());\n        assert_eq!(T::exact_from(&n), i);\n        let alt_n: Rational = From::from(i128::exact_from(i));\n        assert_eq!(alt_n, n);\n        let alt_n: Rational = From::from(&rug::Rational::from(i));\n        assert_eq!(alt_n, n);\n        if T::WIDTH == Limb::WIDTH {\n            let n_alt = Rational::const_from_signed(SignedLimb::exact_from(i));\n            assert!(n_alt.is_valid());\n            assert_eq!(n_alt, n);\n        }\n    });\n\n    signed_gen_var_2::<T>().test_properties(|i| {\n        let n: Rational = From::from(Natural::exact_from(i));\n        assert_eq!(n, Rational::from(i));\n    });\n}\n\n#[test]\nfn from_primitive_int_properties() {\n    apply_fn_to_unsigneds!(from_unsigned_properties_helper);\n    apply_fn_to_signeds!(from_signed_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/integer_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Ceiling, Floor, Parity};\nuse malachite_base::num::basic::traits::{One, OneHalf, Two};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, IsInteger, RoundingFrom,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, rational_rounding_mode_pair_gen_var_2};\nuse std::cmp::Ordering::*;\nuse std::str::FromStr;\n\n#[test]\nfn test_try_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let on = Integer::try_from(u.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n\n        let on = Integer::try_from(&u);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(\"0\", \"Ok(0)\");\n    test(\"123\", \"Ok(123)\");\n    test(\"-123\", \"Ok(-123)\");\n    test(\"1000000000000\", \"Ok(1000000000000)\");\n    test(\"-1000000000000\", \"Ok(-1000000000000)\");\n    test(\"22/7\", \"Err(IntegerFromRationalError)\");\n    test(\"-22/7\", \"Err(IntegerFromRationalError)\");\n}\n\n#[test]\nfn test_exact_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let n = Integer::exact_from(u.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Integer::exact_from(&u);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"123\");\n    test(\"-123\", \"-123\");\n    test(\"1000000000000\", \"1000000000000\");\n    test(\"-1000000000000\", \"-1000000000000\");\n}\n\n#[test]\n#[should_panic]\nfn integer_exact_from_rational_fail() {\n    Integer::exact_from(Rational::from_str(\"22/7\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn integer_exact_from_rational_ref_fail() {\n    Integer::exact_from(&Rational::from_str(\"-22/7\").unwrap());\n}\n\n#[test]\nfn test_convertible_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(Integer::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"-123\", true);\n    test(\"1000000000000\", true);\n    test(\"-1000000000000\", true);\n    test(\"22/7\", false);\n    test(\"-22/7\", false);\n}\n\n#[test]\nfn test_rounding_from_rational() {\n    let test = |s, rm, out, o_out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (n, o) = Integer::rounding_from(u.clone(), rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n\n        let (n, o) = Integer::rounding_from(&u, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n    };\n    test(\"123\", Floor, \"123\", Equal);\n    test(\"123\", Down, \"123\", Equal);\n    test(\"123\", Ceiling, \"123\", Equal);\n    test(\"123\", Up, \"123\", Equal);\n    test(\"123\", Nearest, \"123\", Equal);\n    test(\"123\", Exact, \"123\", Equal);\n\n    test(\"-123\", Floor, \"-123\", Equal);\n    test(\"-123\", Down, \"-123\", Equal);\n    test(\"-123\", Ceiling, \"-123\", Equal);\n    test(\"-123\", Up, \"-123\", Equal);\n    test(\"-123\", Nearest, \"-123\", Equal);\n    test(\"-123\", Exact, \"-123\", Equal);\n\n    test(\"22/7\", Floor, \"3\", Less);\n    test(\"22/7\", Down, \"3\", Less);\n    test(\"22/7\", Ceiling, \"4\", Greater);\n    test(\"22/7\", Up, \"4\", Greater);\n    test(\"22/7\", Nearest, \"3\", Less);\n\n    test(\"-22/7\", Floor, \"-4\", Less);\n    test(\"-22/7\", Down, \"-3\", Greater);\n    test(\"-22/7\", Ceiling, \"-3\", Greater);\n    test(\"-22/7\", Up, \"-4\", Less);\n    test(\"-22/7\", Nearest, \"-3\", Greater);\n\n    test(\"7/2\", Floor, \"3\", Less);\n    test(\"7/2\", Down, \"3\", Less);\n    test(\"7/2\", Ceiling, \"4\", Greater);\n    test(\"7/2\", Up, \"4\", Greater);\n    test(\"7/2\", Nearest, \"4\", Greater);\n\n    test(\"9/2\", Floor, \"4\", Less);\n    test(\"9/2\", Down, \"4\", Less);\n    test(\"9/2\", Ceiling, \"5\", Greater);\n    test(\"9/2\", Up, \"5\", Greater);\n    test(\"9/2\", Nearest, \"4\", Less);\n}\n\n#[test]\n#[should_panic]\nfn integer_rounding_from_rational_fail() {\n    Integer::rounding_from(Rational::from_str(\"22/7\").unwrap(), Exact);\n}\n\n#[test]\n#[should_panic]\nfn integer_rounding_from_rational_ref_fail() {\n    Integer::rounding_from(&Rational::from_str(\"22/7\").unwrap(), Exact);\n}\n\n#[test]\nfn try_from_rational_properties() {\n    rational_gen().test_properties(|x| {\n        let integer_x = Integer::try_from(x.clone());\n        assert!(integer_x.as_ref().map_or(true, Integer::is_valid));\n\n        let integer_x_alt = Integer::try_from(&x);\n        assert!(integer_x_alt.as_ref().map_or(true, Integer::is_valid));\n        assert_eq!(integer_x, integer_x_alt);\n\n        assert_eq!(integer_x.is_ok(), x.is_integer());\n        assert_eq!(integer_x.is_ok(), Integer::convertible_from(&x));\n        if let Ok(n) = integer_x {\n            assert_eq!(n.to_string(), x.to_string());\n            assert_eq!(Integer::exact_from(&x), n);\n            assert_eq!(Rational::from(&n), x);\n            assert_eq!(Rational::from(n), x);\n        }\n    });\n}\n\n#[test]\nfn convertible_from_rational_properties() {\n    rational_gen().test_properties(|x| {\n        let convertible = Integer::convertible_from(&x);\n        assert_eq!(convertible, x.is_integer());\n    });\n}\n\n#[test]\nfn integer_from_rational_properties() {\n    rational_rounding_mode_pair_gen_var_2().test_properties(|(x, rm)| {\n        let no = Integer::rounding_from(&x, rm);\n        assert_eq!(Integer::rounding_from(x.clone(), rm), no);\n        let (n, o) = no;\n        assert!((Rational::from(&n) - &x).lt_abs(&1));\n\n        assert_eq!(n.partial_cmp(&x), Some(o));\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    rational_gen().test_properties(|x| {\n        let floor = Integer::rounding_from(&x, Floor);\n        assert_eq!(floor.0, (&x).floor());\n        assert!(floor.0 <= x);\n        assert!(&floor.0 + Integer::ONE > x);\n\n        let ceiling = Integer::rounding_from(&x, Ceiling);\n        assert_eq!(ceiling.0, (&x).ceiling());\n        assert!(ceiling.0 >= x);\n        assert!(&ceiling.0 - Integer::ONE < x);\n\n        if x >= 0 {\n            assert_eq!(Integer::rounding_from(&x, Down), floor);\n            assert_eq!(Integer::rounding_from(&x, Up), ceiling);\n        } else {\n            assert_eq!(Integer::rounding_from(&x, Down), ceiling);\n            assert_eq!(Integer::rounding_from(&x, Up), floor);\n        }\n\n        let nearest = Integer::rounding_from(&x, Nearest);\n        assert!(nearest == floor || nearest == ceiling);\n        assert!((Rational::from(nearest.0) - x).le_abs(&Rational::ONE_HALF));\n    });\n\n    integer_gen().test_properties(|n| {\n        let x = Rational::from(&n);\n        let no = (n, Equal);\n        assert_eq!(Integer::rounding_from(&x, Floor), no);\n        assert_eq!(Integer::rounding_from(&x, Down), no);\n        assert_eq!(Integer::rounding_from(&x, Ceiling), no);\n        assert_eq!(Integer::rounding_from(&x, Up), no);\n        assert_eq!(Integer::rounding_from(&x, Nearest), no);\n        assert_eq!(Integer::rounding_from(&x, Exact), no);\n\n        let x = Rational::from_integers((no.0 << 1) | Integer::ONE, Integer::TWO);\n        assert!(Integer::rounding_from(x, Nearest).0.even());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/is_integer.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::conversion::traits::IsInteger;\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse std::str::FromStr;\n\n#[test]\nfn test_is_integer() {\n    let test = |n, out| {\n        assert_eq!(Rational::from_str(n).unwrap().is_integer(), out);\n    };\n    test(\"0\", true);\n    test(\"1\", true);\n    test(\"100\", true);\n    test(\"-1\", true);\n    test(\"-100\", true);\n\n    test(\"22/7\", false);\n    test(\"-22/7\", false);\n}\n\n#[test]\nfn is_integer_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_bits_n\", 256);\n    config.insert(\"mean_stripe_n\", 128);\n    rational_gen().test_properties_with_config(&config, |x| {\n        assert_eq!(x.is_integer(), (-&x).is_integer());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/mutate_numerator_or_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_rational_natural_natural_quadruple_gen_var_1, rational_rational_natural_triple_gen,\n    rational_rational_natural_triple_gen_var_1,\n};\nuse std::str::FromStr;\n\n#[test]\nfn test_mutate_numerator() {\n    let mut q = Rational::from_str(\"22/7\").unwrap();\n    let ret = q.mutate_numerator(|x| {\n        *x -= Natural::ONE;\n        true\n    });\n    assert_eq!(q, 3);\n    assert!(ret);\n}\n\n#[test]\nfn test_mutate_denominator() {\n    let mut q = Rational::from_str(\"22/7\").unwrap();\n    let ret = q.mutate_denominator(|x| {\n        *x -= Natural::ONE;\n        true\n    });\n    assert_eq!(q.to_string(), \"11/3\");\n    assert!(ret);\n}\n\n#[test]\n#[should_panic]\nfn mutate_denominator_fail() {\n    let mut q = Rational::from_str(\"22/7\").unwrap();\n    q.mutate_denominator(|x| {\n        *x = Natural::ZERO;\n        true\n    });\n}\n\n#[test]\nfn test_mutate_numerator_and_denominator() {\n    let mut q = Rational::from_str(\"22/7\").unwrap();\n    let ret = q.mutate_numerator_and_denominator(|x, y| {\n        *x -= Natural::ONE;\n        *y -= Natural::ONE;\n        true\n    });\n    assert_eq!(q.to_string(), \"7/2\");\n    assert!(ret);\n}\n\n#[test]\n#[should_panic]\nfn mutate_numerator_and_denominator_fail() {\n    let mut q = Rational::from_str(\"22/7\").unwrap();\n    q.mutate_numerator_and_denominator(|x, y| {\n        *x = Natural::ONE;\n        *y = Natural::ZERO;\n        true\n    });\n}\n\n#[test]\nfn mutate_numerator_properties() {\n    rational_rational_natural_triple_gen().test_properties(|(mut q, out, new_numerator)| {\n        let out_2 = out.clone();\n        let new_numerator_2 = new_numerator.clone();\n        let old_sign = q >= 0;\n        let old_denominator = q.to_denominator();\n        assert_eq!(\n            q.mutate_numerator(|x| {\n                *x = new_numerator;\n                out\n            }),\n            out_2\n        );\n        assert!(q.is_valid());\n        assert_eq!(\n            q,\n            Rational::from_sign_and_naturals(old_sign, new_numerator_2, old_denominator)\n        );\n    });\n}\n\n#[test]\nfn mutate_denominator_properties() {\n    rational_rational_natural_triple_gen_var_1().test_properties(\n        |(mut q, out, new_denominator)| {\n            let out_2 = out.clone();\n            let new_denominator_2 = new_denominator.clone();\n            let old_sign = q >= 0;\n            let old_numerator = q.to_numerator();\n            assert_eq!(\n                q.mutate_denominator(|x| {\n                    *x = new_denominator;\n                    out\n                }),\n                out_2\n            );\n            assert!(q.is_valid());\n            assert_eq!(\n                q,\n                Rational::from_sign_and_naturals(old_sign, old_numerator, new_denominator_2)\n            );\n        },\n    );\n}\n\n#[test]\nfn mutate_numerator_and_denominator_properties() {\n    rational_rational_natural_natural_quadruple_gen_var_1().test_properties(\n        |(mut q, out, new_numerator, new_denominator)| {\n            let out_2 = out.clone();\n            let new_numerator_2 = new_numerator.clone();\n            let new_denominator_2 = new_denominator.clone();\n            let old_sign = q >= 0;\n            assert_eq!(\n                q.mutate_numerator_and_denominator(|x, y| {\n                    *x = new_numerator;\n                    *y = new_denominator;\n                    out\n                }),\n                out_2\n            );\n            assert!(q.is_valid());\n            assert_eq!(\n                q,\n                Rational::from_sign_and_naturals(old_sign, new_numerator_2, new_denominator_2)\n            );\n        },\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/natural_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::assert_panic;\nuse malachite_base::num::arithmetic::traits::{Ceiling, Floor, Parity};\nuse malachite_base::num::basic::traits::{One, OneHalf, Two};\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, IsInteger, RoundingFrom,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::natural_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_3, rational_rounding_mode_pair_gen_var_1,\n};\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_try_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let on = Natural::try_from(u.clone());\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n\n        let on = Natural::try_from(&u);\n        assert_eq!(on.to_debug_string(), out);\n        assert!(on.map_or(true, |n| n.is_valid()));\n    };\n    test(\"0\", \"Ok(0)\");\n    test(\"123\", \"Ok(123)\");\n    test(\"-123\", \"Err(NaturalFromRationalError)\");\n    test(\"1000000000000\", \"Ok(1000000000000)\");\n    test(\"-1000000000000\", \"Err(NaturalFromRationalError)\");\n    test(\"22/7\", \"Err(NaturalFromRationalError)\");\n    test(\"-22/7\", \"Err(NaturalFromRationalError)\");\n}\n\n#[test]\nfn test_exact_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let n = Natural::exact_from(u.clone());\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n\n        let n = Natural::exact_from(&u);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n    };\n    test(\"0\", \"0\");\n    test(\"123\", \"123\");\n    test(\"1000000000000\", \"1000000000000\");\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_rational_fail_1() {\n    Natural::exact_from(Rational::from_str(\"-123\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_rational_fail_2() {\n    Natural::exact_from(Rational::from_str(\"22/7\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_rational_ref_fail_1() {\n    Natural::exact_from(&Rational::from_str(\"-123\").unwrap());\n}\n\n#[test]\n#[should_panic]\nfn natural_exact_from_rational_ref_fail_2() {\n    Natural::exact_from(&Rational::from_str(\"22/7\").unwrap());\n}\n\n#[test]\nfn test_convertible_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(Natural::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"-123\", false);\n    test(\"1000000000000\", true);\n    test(\"-1000000000000\", false);\n    test(\"22/7\", false);\n    test(\"-22/7\", false);\n}\n\n#[test]\nfn test_rounding_from_rational() {\n    let test = |s, rm, out, o_out| {\n        let u = Rational::from_str(s).unwrap();\n\n        let (n, o) = Natural::rounding_from(u.clone(), rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n\n        let (n, o) = Natural::rounding_from(&u, rm);\n        assert_eq!(n.to_string(), out);\n        assert!(n.is_valid());\n        assert_eq!(o, o_out);\n    };\n    test(\"123\", Floor, \"123\", Equal);\n    test(\"123\", Down, \"123\", Equal);\n    test(\"123\", Ceiling, \"123\", Equal);\n    test(\"123\", Up, \"123\", Equal);\n    test(\"123\", Nearest, \"123\", Equal);\n    test(\"123\", Exact, \"123\", Equal);\n\n    test(\"-123\", Down, \"0\", Greater);\n    test(\"-123\", Ceiling, \"0\", Greater);\n    test(\"-123\", Nearest, \"0\", Greater);\n\n    test(\"22/7\", Floor, \"3\", Less);\n    test(\"22/7\", Down, \"3\", Less);\n    test(\"22/7\", Ceiling, \"4\", Greater);\n    test(\"22/7\", Up, \"4\", Greater);\n    test(\"22/7\", Nearest, \"3\", Less);\n\n    test(\"7/2\", Floor, \"3\", Less);\n    test(\"7/2\", Down, \"3\", Less);\n    test(\"7/2\", Ceiling, \"4\", Greater);\n    test(\"7/2\", Up, \"4\", Greater);\n    test(\"7/2\", Nearest, \"4\", Greater);\n\n    test(\"9/2\", Floor, \"4\", Less);\n    test(\"9/2\", Down, \"4\", Less);\n    test(\"9/2\", Ceiling, \"5\", Greater);\n    test(\"9/2\", Up, \"5\", Greater);\n    test(\"9/2\", Nearest, \"4\", Less);\n}\n\n#[test]\nfn natural_rounding_from_rational_fail() {\n    let x = Rational::from_str(\"-123\").unwrap();\n    assert_panic!(Natural::rounding_from(x.clone(), Floor));\n    assert_panic!(Natural::rounding_from(x.clone(), Up));\n    assert_panic!(Natural::rounding_from(x, Exact));\n\n    let x = Rational::from_str(\"22/7\").unwrap();\n    assert_panic!(Natural::rounding_from(x, Exact));\n}\n\n#[test]\nfn natural_rounding_from_rational_ref_fail() {\n    let x = Rational::from_str(\"-123\").unwrap();\n    assert_panic!(Natural::rounding_from(&x, Floor));\n    assert_panic!(Natural::rounding_from(&x, Up));\n    assert_panic!(Natural::rounding_from(&x, Exact));\n\n    let x = Rational::from_str(\"22/7\").unwrap();\n    assert_panic!(Natural::rounding_from(&x, Exact));\n}\n\n#[test]\nfn try_from_rational_properties() {\n    rational_gen().test_properties(|x| {\n        let natural_x = Natural::try_from(x.clone());\n        assert!(natural_x.as_ref().map_or(true, Natural::is_valid));\n\n        let natural_x_alt = Natural::try_from(&x);\n        assert!(natural_x_alt.as_ref().map_or(true, Natural::is_valid));\n        assert_eq!(natural_x, natural_x_alt);\n\n        assert_eq!(natural_x.is_ok(), x >= 0 && x.is_integer());\n        assert_eq!(natural_x.is_ok(), Natural::convertible_from(&x));\n        if let Ok(n) = natural_x {\n            assert_eq!(n.to_string(), x.to_string());\n            assert_eq!(Natural::exact_from(&x), n);\n            assert_eq!(Rational::from(&n), x);\n            assert_eq!(Rational::from(n), x);\n        }\n    });\n}\n\n#[test]\nfn convertible_from_rational_properties() {\n    rational_gen().test_properties(|x| {\n        let convertible = Natural::convertible_from(&x);\n        assert_eq!(convertible, x >= 0 && x.is_integer());\n    });\n}\n\n#[test]\nfn rounding_from_rational_properties() {\n    rational_rounding_mode_pair_gen_var_1().test_properties(|(x, rm)| {\n        let no = Natural::rounding_from(&x, rm);\n        assert_eq!(Natural::rounding_from(x.clone(), rm), no);\n        let (n, o) = no;\n        if x >= 0 {\n            assert_eq!(Integer::rounding_from(&x, rm), (Integer::from(&n), o));\n            assert!((Rational::from(&n) - &x).lt_abs(&1));\n        }\n\n        assert_eq!(n.partial_cmp(&x), Some(o));\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    rational_gen_var_3().test_properties(|x| {\n        let floor = Natural::rounding_from(&x, Floor);\n        assert_eq!(floor.0, (&x).floor());\n        assert!(floor.0 <= x);\n        assert!(&floor.0 + Natural::ONE > x);\n        assert_eq!(Natural::rounding_from(&x, Down), floor);\n\n        let ceiling = Natural::rounding_from(&x, Ceiling);\n        assert_eq!(ceiling.0, (&x).ceiling());\n        assert!(ceiling.0 >= x);\n        if x > 0 {\n            assert!(&ceiling.0 - Natural::ONE < x);\n        }\n        assert_eq!(Natural::rounding_from(&x, Up), ceiling);\n\n        let nearest = Natural::rounding_from(&x, Nearest);\n        assert!(nearest == floor || nearest == ceiling);\n        assert!((Rational::from(nearest.0) - x).le_abs(&Rational::ONE_HALF));\n    });\n\n    natural_gen().test_properties(|n| {\n        let x = Rational::from(&n);\n        let no = (n, Equal);\n        assert_eq!(Natural::rounding_from(&x, Floor), no);\n        assert_eq!(Natural::rounding_from(&x, Down), no);\n        assert_eq!(Natural::rounding_from(&x, Ceiling), no);\n        assert_eq!(Natural::rounding_from(&x, Up), no);\n        assert_eq!(Natural::rounding_from(&x, Nearest), no);\n        assert_eq!(Natural::rounding_from(&x, Exact), no);\n\n        let x = Rational::from_naturals((no.0 << 1) | Natural::ONE, Natural::TWO);\n        assert!(Natural::rounding_from(x, Nearest).0.even());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/primitive_float_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::Parity;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::basic::traits::NegativeInfinity;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::from::UnsignedFromFloatError;\nuse malachite_base::num::conversion::traits::{ConvertibleFrom, ExactFrom, RoundingFrom};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    integer_gen, integer_gen_var_1, integer_rounding_mode_pair_gen_var_1,\n};\nuse malachite_q::Rational;\nuse malachite_q::conversion::primitive_float_from_rational::FloatConversionError;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_4, rational_gen_var_5, rational_gen_var_6,\n    rational_rounding_mode_pair_gen_var_5,\n};\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_f32_rounding_from_rational() {\n    let max = Rational::exact_from(f32::MAX_FINITE);\n    let test = |s: &str, rm: RoundingMode, out, o_out| {\n        let u = Rational::from_str(s).unwrap();\n        let (f, o) = f32::rounding_from(&u, rm);\n        assert_eq!(NiceFloat(f), NiceFloat(out));\n        assert_eq!(o, o_out);\n        let (f, o) = f32::rounding_from(u.clone(), rm);\n        assert_eq!(NiceFloat(f), NiceFloat(out));\n        assert_eq!(o, o_out);\n        if rm == Down && u.lt_abs(&max) && NiceFloat(out) != NiceFloat(-0.0) {\n            assert_eq!(\n                NiceFloat(rug::Rational::from_str(s).unwrap().to_f32()),\n                NiceFloat(out)\n            );\n        }\n    };\n    test(\"3\", Exact, 3.0, Equal);\n    test(\"-3\", Exact, -3.0, Equal);\n    test(\"123\", Exact, 123.0, Equal);\n    test(\"-123\", Exact, -123.0, Equal);\n    test(\"0\", Exact, 0.0, Equal);\n    test(\"1000000000\", Exact, 1.0e9, Equal);\n    test(\"-1000000000\", Exact, -1.0e9, Equal);\n    test(\"16777216\", Exact, 1.6777216e7, Equal);\n    test(\"-16777216\", Exact, -1.6777216e7, Equal);\n    test(\"16777218\", Exact, 1.6777218e7, Equal);\n    test(\"-16777218\", Exact, -1.6777218e7, Equal);\n\n    test(\"16777217\", Floor, 1.6777216e7, Less);\n    test(\"16777217\", Down, 1.6777216e7, Less);\n    test(\"16777217\", Ceiling, 1.6777218e7, Greater);\n    test(\"16777217\", Up, 1.6777218e7, Greater);\n    test(\"16777217\", Nearest, 1.6777216e7, Less);\n\n    test(\"-16777217\", Floor, -1.6777218e7, Less);\n    test(\"-16777217\", Down, -1.6777216e7, Greater);\n    test(\"-16777217\", Ceiling, -1.6777216e7, Greater);\n    test(\"-16777217\", Up, -1.6777218e7, Less);\n    test(\"-16777217\", Nearest, -1.6777216e7, Greater);\n\n    test(\"33554432\", Exact, 3.3554432e7, Equal);\n    test(\"-33554432\", Exact, -3.3554432e7, Equal);\n    test(\"33554436\", Exact, 3.3554436e7, Equal);\n    test(\"-33554436\", Exact, -3.3554436e7, Equal);\n\n    test(\"33554433\", Floor, 3.3554432e7, Less);\n    test(\"33554433\", Down, 3.3554432e7, Less);\n    test(\"33554433\", Ceiling, 3.3554436e7, Greater);\n    test(\"33554433\", Up, 3.3554436e7, Greater);\n    test(\"33554433\", Nearest, 3.3554432e7, Less);\n\n    test(\"-33554433\", Floor, -3.3554436e7, Less);\n    test(\"-33554433\", Down, -3.3554432e7, Greater);\n    test(\"-33554433\", Ceiling, -3.3554432e7, Greater);\n    test(\"-33554433\", Up, -3.3554436e7, Less);\n    test(\"-33554433\", Nearest, -3.3554432e7, Greater);\n\n    test(\"33554434\", Nearest, 3.3554432e7, Less);\n    test(\"-33554434\", Nearest, -3.3554432e7, Greater);\n    test(\"33554435\", Nearest, 3.3554436e7, Greater);\n    test(\"-33554435\", Nearest, -3.3554436e7, Less);\n\n    test(\n        \"340282346638528859811704183484516925439\",\n        Floor,\n        3.4028233e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Down,\n        3.4028233e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Ceiling,\n        3.4028235e38,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Up,\n        3.4028235e38,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Nearest,\n        3.4028235e38,\n        Greater,\n    );\n\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Floor,\n        -3.4028235e38,\n        Less,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Down,\n        -3.4028233e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Ceiling,\n        -3.4028233e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Up,\n        -3.4028235e38,\n        Less,\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Nearest,\n        -3.4028235e38,\n        Less,\n    );\n\n    test(\n        \"340282346638528859811704183484516925440\",\n        Exact,\n        3.4028235e38,\n        Equal,\n    );\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Exact,\n        -3.4028235e38,\n        Equal,\n    );\n\n    test(\n        \"340282346638528859811704183484516925441\",\n        Floor,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Down,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Nearest,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Ceiling,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Up,\n        f32::INFINITY,\n        Greater,\n    );\n\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Floor,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Down,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Nearest,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Ceiling,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Up,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Down,\n        3.4028235e38,\n        Less,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        f32::INFINITY,\n        Greater,\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Up,\n        f32::INFINITY,\n        Greater,\n    );\n\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Down,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        -3.4028235e38,\n        Greater,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Up,\n        f32::NEGATIVE_INFINITY,\n        Less,\n    );\n\n    test(\"1125899873419263\", Floor, 1.12589984e15, Less);\n    test(\"1125899873419263\", Down, 1.12589984e15, Less);\n    test(\"1125899873419263\", Ceiling, 1.1258999e15, Greater);\n    test(\"1125899873419263\", Up, 1.1258999e15, Greater);\n    test(\"1125899873419263\", Nearest, 1.1258999e15, Greater);\n\n    test(\"-1125899873419263\", Floor, -1.1258999e15, Less);\n    test(\"-1125899873419263\", Down, -1.12589984e15, Greater);\n    test(\"-1125899873419263\", Ceiling, -1.12589984e15, Greater);\n    test(\"-1125899873419263\", Up, -1.1258999e15, Less);\n    test(\"-1125899873419263\", Nearest, -1.1258999e15, Less);\n\n    test(\"1/2\", Floor, 0.5, Equal);\n    test(\"1/2\", Down, 0.5, Equal);\n    test(\"1/2\", Ceiling, 0.5, Equal);\n    test(\"1/2\", Up, 0.5, Equal);\n    test(\"1/2\", Nearest, 0.5, Equal);\n    test(\"1/2\", Exact, 0.5, Equal);\n\n    test(\"-1/2\", Floor, -0.5, Equal);\n    test(\"-1/2\", Down, -0.5, Equal);\n    test(\"-1/2\", Ceiling, -0.5, Equal);\n    test(\"-1/2\", Up, -0.5, Equal);\n    test(\"-1/2\", Nearest, -0.5, Equal);\n    test(\"-1/2\", Exact, -0.5, Equal);\n\n    test(\"1/3\", Floor, 0.3333333, Less);\n    test(\"1/3\", Down, 0.3333333, Less);\n    test(\"1/3\", Ceiling, 0.33333334, Greater);\n    test(\"1/3\", Up, 0.33333334, Greater);\n    test(\"1/3\", Nearest, 0.33333334, Greater);\n\n    test(\"-1/3\", Floor, -0.33333334, Less);\n    test(\"-1/3\", Down, -0.3333333, Greater);\n    test(\"-1/3\", Ceiling, -0.3333333, Greater);\n    test(\"-1/3\", Up, -0.33333334, Less);\n    test(\"-1/3\", Nearest, -0.33333334, Less);\n\n    // subnormal\n    test(\n        \"1/10000000000000000000000000000000000000000\",\n        Floor,\n        1.0e-40,\n        Less,\n    );\n    test(\n        \"1/10000000000000000000000000000000000000000\",\n        Down,\n        1.0e-40,\n        Less,\n    );\n    test(\n        \"1/10000000000000000000000000000000000000000\",\n        Ceiling,\n        1.00001e-40,\n        Greater,\n    );\n    test(\n        \"1/10000000000000000000000000000000000000000\",\n        Up,\n        1.00001e-40,\n        Greater,\n    );\n    test(\n        \"1/10000000000000000000000000000000000000000\",\n        Nearest,\n        1.0e-40,\n        Less,\n    );\n\n    test(\n        \"-1/10000000000000000000000000000000000000000\",\n        Floor,\n        -1.00001e-40,\n        Less,\n    );\n    test(\n        \"-1/10000000000000000000000000000000000000000\",\n        Down,\n        -1.0e-40,\n        Greater,\n    );\n    test(\n        \"-1/10000000000000000000000000000000000000000\",\n        Ceiling,\n        -1.0e-40,\n        Greater,\n    );\n    test(\n        \"-1/10000000000000000000000000000000000000000\",\n        Up,\n        -1.00001e-40,\n        Less,\n    );\n    test(\n        \"-1/10000000000000000000000000000000000000000\",\n        Nearest,\n        -1.0e-40,\n        Greater,\n    );\n\n    // less than subnormal\n    test(\n        \"1/100000000000000000000000000000000000000000000000000\",\n        Floor,\n        0.0,\n        Less,\n    );\n    test(\n        \"1/100000000000000000000000000000000000000000000000000\",\n        Down,\n        0.0,\n        Less,\n    );\n    test(\n        \"1/100000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        1.0e-45,\n        Greater,\n    );\n    test(\n        \"1/100000000000000000000000000000000000000000000000000\",\n        Up,\n        1.0e-45,\n        Greater,\n    );\n    test(\n        \"1/100000000000000000000000000000000000000000000000000\",\n        Nearest,\n        0.0,\n        Less,\n    );\n\n    test(\n        \"-1/100000000000000000000000000000000000000000000000000\",\n        Floor,\n        -1.0e-45,\n        Less,\n    );\n    test(\n        \"-1/100000000000000000000000000000000000000000000000000\",\n        Down,\n        -0.0,\n        Greater,\n    );\n    test(\n        \"-1/100000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        -0.0,\n        Greater,\n    );\n    test(\n        \"-1/100000000000000000000000000000000000000000000000000\",\n        Up,\n        -1.0e-45,\n        Less,\n    );\n    test(\n        \"-1/100000000000000000000000000000000000000000000000000\",\n        Nearest,\n        -0.0,\n        Greater,\n    );\n\n    // half of smallest positive\n    test(\n        \"1/1427247692705959881058285969449495136382746624\",\n        Floor,\n        0.0,\n        Less,\n    );\n    test(\n        \"1/1427247692705959881058285969449495136382746624\",\n        Down,\n        0.0,\n        Less,\n    );\n    test(\n        \"1/1427247692705959881058285969449495136382746624\",\n        Ceiling,\n        1.0e-45,\n        Greater,\n    );\n    test(\n        \"1/1427247692705959881058285969449495136382746624\",\n        Up,\n        1.0e-45,\n        Greater,\n    );\n    test(\n        \"1/1427247692705959881058285969449495136382746624\",\n        Nearest,\n        0.0,\n        Less,\n    );\n\n    test(\n        \"-1/1427247692705959881058285969449495136382746624\",\n        Floor,\n        -1.0e-45,\n        Less,\n    );\n    test(\n        \"-1/1427247692705959881058285969449495136382746624\",\n        Down,\n        -0.0,\n        Greater,\n    );\n    test(\n        \"-1/1427247692705959881058285969449495136382746624\",\n        Ceiling,\n        -0.0,\n        Greater,\n    );\n    test(\n        \"-1/1427247692705959881058285969449495136382746624\",\n        Up,\n        -1.0e-45,\n        Less,\n    );\n    test(\n        \"-1/1427247692705959881058285969449495136382746624\",\n        Nearest,\n        -0.0,\n        Greater,\n    );\n\n    // just over half of smallest positive; Nearest rounds up\n    test(\n        \"88819109620612751463292030150471001/126765060022822940149670320537600000000000000000000000\\\n        000000000000000000000000000\",\n        Floor,\n        0.0,\n        Less,\n    );\n    test(\n        \"88819109620612751463292030150471001/126765060022822940149670320537600000000000000000000000\\\n        000000000000000000000000000\",\n        Down,\n        0.0,\n        Less,\n    );\n    test(\n        \"88819109620612751463292030150471001/126765060022822940149670320537600000000000000000000000\\\n        000000000000000000000000000\",\n        Ceiling,\n        1.0e-45,\n        Greater,\n    );\n    test(\n        \"88819109620612751463292030150471001/126765060022822940149670320537600000000000000000000000\\\n        000000000000000000000000000\",\n        Up,\n        1.0e-45,\n        Greater,\n    );\n    test(\n        \"88819109620612751463292030150471001/126765060022822940149670320537600000000000000000000000\\\n        000000000000000000000000000\",\n        Nearest,\n        1.0e-45,\n        Greater,\n    );\n\n    test(\n        \"-88819109620612751463292030150471001/12676506002282294014967032053760000000000000000000000\\\n        0000000000000000000000000000\",\n        Floor,\n        -1.0e-45,\n        Less,\n    );\n    test(\n        \"-88819109620612751463292030150471001/12676506002282294014967032053760000000000000000000000\\\n        0000000000000000000000000000\",\n        Down,\n        -0.0,\n        Greater,\n    );\n    test(\n        \"-88819109620612751463292030150471001/12676506002282294014967032053760000000000000000000000\\\n        0000000000000000000000000000\",\n        Ceiling,\n        -0.0,\n        Greater,\n    );\n    test(\n        \"-88819109620612751463292030150471001/12676506002282294014967032053760000000000000000000000\\\n        0000000000000000000000000000\",\n        Up,\n        -1.0e-45,\n        Less,\n    );\n    test(\n        \"-88819109620612751463292030150471001/12676506002282294014967032053760000000000000000000000\\\n        0000000000000000000000000000\",\n        Nearest,\n        -1.0e-45,\n        Less,\n    );\n\n    // halfway between max subnormal and min normal\n    test(\n        \"16777215/1427247692705959881058285969449495136382746624\",\n        Floor,\n        1.1754942e-38,\n        Less,\n    );\n    test(\n        \"16777215/1427247692705959881058285969449495136382746624\",\n        Down,\n        1.1754942e-38,\n        Less,\n    );\n    test(\n        \"16777215/1427247692705959881058285969449495136382746624\",\n        Ceiling,\n        1.1754944e-38,\n        Greater,\n    );\n    test(\n        \"16777215/1427247692705959881058285969449495136382746624\",\n        Up,\n        1.1754944e-38,\n        Greater,\n    );\n    test(\n        \"16777215/1427247692705959881058285969449495136382746624\",\n        Nearest,\n        1.1754944e-38,\n        Greater,\n    );\n}\n\n#[test]\nfn f32_rounding_from_rational_fail() {\n    assert_panic!(f32::rounding_from(\n        Rational::from_str(\"340282346638528859811704183484516925439\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f32::rounding_from(\n        Rational::from_str(\"340282346638528859811704183484516925441\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f32::rounding_from(\n        Rational::from_str(\"16777217\").unwrap(),\n        Exact\n    ));\n    assert_panic!(f32::rounding_from(\n        Rational::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f32::rounding_from(\n        Rational::from_str(\"1/10\").unwrap(),\n        Exact\n    ));\n}\n\n#[test]\nfn f32_rounding_from_rational_ref_fail() {\n    assert_panic!(f32::rounding_from(\n        &Rational::from_str(\"340282346638528859811704183484516925439\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f32::rounding_from(\n        &Rational::from_str(\"340282346638528859811704183484516925441\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f32::rounding_from(\n        &Rational::from_str(\"16777217\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f32::rounding_from(\n        &Rational::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f32::rounding_from(\n        &Rational::from_str(\"1/10\").unwrap(),\n        Exact\n    ));\n}\n\n#[test]\nfn test_f64_rounding_from_rational() {\n    let test = |s: &str, rm: RoundingMode, out, o_out| {\n        let u = Rational::from_str(s).unwrap();\n        let (f, o) = f64::rounding_from(&u, rm);\n        assert_eq!(NiceFloat(f), NiceFloat(out));\n        assert_eq!(o, o_out);\n        let (f, o) = f64::rounding_from(u, rm);\n        assert_eq!(NiceFloat(f), NiceFloat(out));\n        assert_eq!(o, o_out);\n        if rm == Down {\n            assert_eq!(\n                NiceFloat(rug::Rational::from_str(s).unwrap().to_f64()),\n                NiceFloat(out)\n            );\n        }\n    };\n    test(\"3\", Exact, 3.0, Equal);\n    test(\"-3\", Exact, -3.0, Equal);\n    test(\"123\", Exact, 123.0, Equal);\n    test(\"-123\", Exact, -123.0, Equal);\n    test(\"0\", Exact, 0.0, Equal);\n    test(\"100000000000000000000\", Exact, 1.0e20, Equal);\n    test(\"-100000000000000000000\", Exact, -1.0e20, Equal);\n    test(\"9007199254740992\", Exact, 9.007199254740992e15, Equal);\n    test(\"-9007199254740992\", Exact, -9.007199254740992e15, Equal);\n    test(\"9007199254740994\", Exact, 9.007199254740994e15, Equal);\n    test(\"-9007199254740994\", Exact, -9.007199254740994e15, Equal);\n\n    test(\"9007199254740993\", Floor, 9.007199254740992e15, Less);\n    test(\"9007199254740993\", Down, 9.007199254740992e15, Less);\n    test(\"9007199254740993\", Ceiling, 9.007199254740994e15, Greater);\n    test(\"9007199254740993\", Up, 9.007199254740994e15, Greater);\n    test(\"9007199254740993\", Nearest, 9.007199254740992e15, Less);\n\n    test(\"-9007199254740993\", Floor, -9.007199254740994e15, Less);\n    test(\"-9007199254740993\", Down, -9.007199254740992e15, Greater);\n    test(\"-9007199254740993\", Ceiling, -9.007199254740992e15, Greater);\n    test(\"-9007199254740993\", Up, -9.007199254740994e15, Less);\n    test(\"-9007199254740993\", Nearest, -9.007199254740992e15, Greater);\n\n    test(\"18014398509481984\", Exact, 1.8014398509481984e16, Equal);\n    test(\"-18014398509481984\", Exact, -1.8014398509481984e16, Equal);\n    test(\"18014398509481988\", Exact, 1.8014398509481988e16, Equal);\n    test(\"-18014398509481988\", Exact, -1.8014398509481988e16, Equal);\n\n    test(\"18014398509481985\", Floor, 1.8014398509481984e16, Less);\n    test(\"18014398509481985\", Down, 1.8014398509481984e16, Less);\n    test(\"18014398509481985\", Ceiling, 1.8014398509481988e16, Greater);\n    test(\"18014398509481985\", Up, 1.8014398509481988e16, Greater);\n    test(\"18014398509481985\", Nearest, 1.8014398509481984e16, Less);\n\n    test(\"-18014398509481985\", Floor, -1.8014398509481988e16, Less);\n    test(\"-18014398509481985\", Down, -1.8014398509481984e16, Greater);\n    test(\n        \"-18014398509481985\",\n        Ceiling,\n        -1.8014398509481984e16,\n        Greater,\n    );\n    test(\"-18014398509481985\", Up, -1.8014398509481988e16, Less);\n    test(\n        \"-18014398509481985\",\n        Nearest,\n        -1.8014398509481984e16,\n        Greater,\n    );\n\n    test(\"18014398509481986\", Nearest, 1.8014398509481984e16, Less);\n    test(\n        \"-18014398509481986\",\n        Nearest,\n        -1.8014398509481984e16,\n        Greater,\n    );\n    test(\"18014398509481987\", Nearest, 1.8014398509481988e16, Greater);\n    test(\"-18014398509481987\", Nearest, -1.8014398509481988e16, Less);\n\n    test(\"1/2\", Floor, 0.5, Equal);\n    test(\"1/2\", Down, 0.5, Equal);\n    test(\"1/2\", Ceiling, 0.5, Equal);\n    test(\"1/2\", Up, 0.5, Equal);\n    test(\"1/2\", Nearest, 0.5, Equal);\n    test(\"1/2\", Exact, 0.5, Equal);\n\n    test(\"-1/2\", Floor, -0.5, Equal);\n    test(\"-1/2\", Down, -0.5, Equal);\n    test(\"-1/2\", Ceiling, -0.5, Equal);\n    test(\"-1/2\", Up, -0.5, Equal);\n    test(\"-1/2\", Nearest, -0.5, Equal);\n    test(\"-1/2\", Exact, -0.5, Equal);\n\n    test(\"1/3\", Floor, 0.3333333333333333, Less);\n    test(\"1/3\", Down, 0.3333333333333333, Less);\n    test(\"1/3\", Ceiling, 0.33333333333333337, Greater);\n    test(\"1/3\", Up, 0.33333333333333337, Greater);\n    test(\"1/3\", Nearest, 0.3333333333333333, Less);\n\n    test(\"-1/3\", Floor, -0.33333333333333337, Less);\n    test(\"-1/3\", Down, -0.3333333333333333, Greater);\n    test(\"-1/3\", Ceiling, -0.3333333333333333, Greater);\n    test(\"-1/3\", Up, -0.33333333333333337, Less);\n    test(\"-1/3\", Nearest, -0.3333333333333333, Greater);\n}\n\n#[test]\nfn f64_rounding_from_rational_fail() {\n    assert_panic!(f64::rounding_from(Rational::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap(), Exact)\n    );\n    assert_panic!(f64::rounding_from(Rational::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap(), Exact)\n    );\n    assert_panic!(f64::rounding_from(\n        Rational::from_str(\"9007199254740993\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f64::rounding_from(\n        Rational::from_str(\"1/10\").unwrap(),\n        Exact\n    ));\n}\n\n#[test]\nfn f64_rounding_from_rational_ref_fail() {\n    assert_panic!(\n        f64::rounding_from(&Rational::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap(), Exact)\n    );\n    assert_panic!(\n        f64::rounding_from(&Rational::from_str(\n        \"17976931348623157081452742373170435679807056752584499659891747680315726078002858760589558\\\n        632766878171540458953514382464234321326889464182768467546703537516986049910576552820762454\\\n        900903893289440758685084551339423045832369032229481658085593321233482747978262044472316873\\\n        8177180919299881250404026184124858369\").unwrap(), Exact)\n    );\n    assert_panic!(f64::rounding_from(\n        &Rational::from_str(\"9007199254740993\").unwrap(),\n        Exact,\n    ));\n    assert_panic!(f64::rounding_from(\n        &Rational::from_str(\"1/10\").unwrap(),\n        Exact\n    ));\n}\n\n#[test]\nfn test_f32_try_from_rational() {\n    let test = |s: &str, out: Result<f32, FloatConversionError>| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(f32::try_from(&u).map(NiceFloat), out.map(NiceFloat));\n        assert_eq!(f32::try_from(u.clone()).map(NiceFloat), out.map(NiceFloat));\n        assert_eq!(f32::convertible_from(u), out.is_ok());\n    };\n    test(\"3\", Ok(3.0));\n    test(\"-3\", Ok(-3.0));\n    test(\"123\", Ok(123.0));\n    test(\"-123\", Ok(-123.0));\n    test(\"0\", Ok(0.0));\n    test(\"1000000000\", Ok(1.0e9));\n    test(\"-1000000000\", Ok(-1.0e9));\n    test(\"16777216\", Ok(1.6777216e7));\n    test(\"-16777216\", Ok(-1.6777216e7));\n    test(\"16777218\", Ok(1.6777218e7));\n    test(\"-16777218\", Ok(-1.6777218e7));\n    test(\"16777217\", Err(FloatConversionError::Inexact));\n    test(\"-16777217\", Err(FloatConversionError::Inexact));\n    test(\"33554432\", Ok(3.3554432e7));\n    test(\"-33554432\", Ok(-3.3554432e7));\n    test(\"33554436\", Ok(3.3554436e7));\n    test(\"-33554436\", Ok(-3.3554436e7));\n    test(\"33554433\", Err(FloatConversionError::Inexact));\n    test(\"-33554433\", Err(FloatConversionError::Inexact));\n    test(\"33554434\", Err(FloatConversionError::Inexact));\n    test(\"-33554434\", Err(FloatConversionError::Inexact));\n    test(\"33554435\", Err(FloatConversionError::Inexact));\n    test(\"-33554435\", Err(FloatConversionError::Inexact));\n    test(\n        \"340282346638528859811704183484516925439\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\"340282346638528859811704183484516925440\", Ok(3.4028235e38));\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Ok(-3.4028235e38),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Err(FloatConversionError::Inexact),\n    );\n\n    test(\"1/2\", Ok(0.5));\n    test(\"-1/2\", Ok(-0.5));\n    test(\"1/3\", Err(FloatConversionError::Inexact));\n    test(\"-1/3\", Err(FloatConversionError::Inexact));\n    test(\n        \"1/713623846352979940529142984724747568191373312\",\n        Ok(f32::MIN_POSITIVE_SUBNORMAL),\n    );\n    test(\n        \"-1/713623846352979940529142984724747568191373312\",\n        Ok(-f32::MIN_POSITIVE_SUBNORMAL),\n    );\n    test(\n        \"8388607/713623846352979940529142984724747568191373312\",\n        Ok(f32::MAX_SUBNORMAL),\n    );\n    test(\n        \"-8388607/713623846352979940529142984724747568191373312\",\n        Ok(-f32::MAX_SUBNORMAL),\n    );\n    test(\n        \"1/85070591730234615865843651857942052864\",\n        Ok(f32::MIN_POSITIVE_NORMAL),\n    );\n    test(\n        \"-1/85070591730234615865843651857942052864\",\n        Ok(-f32::MIN_POSITIVE_NORMAL),\n    );\n}\n\n#[test]\nfn test_f64_try_from_rational() {\n    let test = |s: &str, out: Result<f64, FloatConversionError>| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(f64::try_from(&u).map(NiceFloat), out.map(NiceFloat));\n        assert_eq!(f64::try_from(u.clone()).map(NiceFloat), out.map(NiceFloat));\n        assert_eq!(f64::convertible_from(u), out.is_ok());\n    };\n    test(\"3\", Ok(3.0));\n    test(\"-3\", Ok(-3.0));\n    test(\"123\", Ok(123.0));\n    test(\"-123\", Ok(-123.0));\n    test(\"0\", Ok(0.0));\n    test(\"1000000000\", Ok(1.0e9));\n    test(\"-1000000000\", Ok(-1.0e9));\n    test(\"9007199254740992\", Ok(9.007199254740992e15));\n    test(\"-9007199254740992\", Ok(-9.007199254740992e15));\n    test(\"9007199254740994\", Ok(9.007199254740994e15));\n    test(\"-9007199254740994\", Ok(-9.007199254740994e15));\n    test(\"9007199254740993\", Err(FloatConversionError::Inexact));\n    test(\"-9007199254740993\", Err(FloatConversionError::Inexact));\n    test(\"18014398509481984\", Ok(1.8014398509481984e16));\n    test(\"-18014398509481984\", Ok(-1.8014398509481984e16));\n    test(\"18014398509481988\", Ok(1.8014398509481988e16));\n    test(\"-18014398509481988\", Ok(-1.8014398509481988e16));\n    test(\"18014398509481985\", Err(FloatConversionError::Inexact));\n    test(\"-18014398509481985\", Err(FloatConversionError::Inexact));\n    test(\"18014398509481986\", Err(FloatConversionError::Inexact));\n    test(\"-18014398509481986\", Err(FloatConversionError::Inexact));\n    test(\"18014398509481987\", Err(FloatConversionError::Inexact));\n    test(\"-18014398509481987\", Err(FloatConversionError::Inexact));\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        Ok(1.7976931348623157e308),\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n        Ok(-1.7976931348623157e308),\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        Err(FloatConversionError::Inexact),\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        Err(FloatConversionError::Inexact),\n    );\n\n    test(\"1/2\", Ok(0.5));\n    test(\"-1/2\", Ok(-0.5));\n    test(\"1/3\", Err(FloatConversionError::Inexact));\n    test(\"-1/3\", Err(FloatConversionError::Inexact));\n}\n\n#[test]\nfn test_f32_exact_from_rational() {\n    let test = |s: &str, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(NiceFloat(f32::exact_from(&u)), NiceFloat(out));\n        assert_eq!(NiceFloat(f32::exact_from(u)), NiceFloat(out));\n    };\n    test(\"3\", 3.0);\n    test(\"-3\", -3.0);\n    test(\"123\", 123.0);\n    test(\"-123\", -123.0);\n    test(\"0\", 0.0);\n    test(\"1000000000\", 1.0e9);\n    test(\"-1000000000\", -1.0e9);\n    test(\"16777216\", 1.6777216e7);\n    test(\"-16777216\", -1.6777216e7);\n    test(\"16777218\", 1.6777218e7);\n    test(\"-16777218\", -1.6777218e7);\n    test(\"33554432\", 3.3554432e7);\n    test(\"-33554432\", -3.3554432e7);\n    test(\"33554436\", 3.3554436e7);\n    test(\"-33554436\", -3.3554436e7);\n    test(\"340282346638528859811704183484516925440\", 3.4028235e38);\n    test(\"-340282346638528859811704183484516925440\", -3.4028235e38);\n}\n\n#[test]\nfn f32_exact_from_rational_fail() {\n    assert_panic!(f32::exact_from(Rational::from_str(\"16777217\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"-16777217\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"33554433\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"-33554433\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"33554434\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"-33554434\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"33554435\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"-33554435\").unwrap()));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"340282346638528859811704183484516925439\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"-340282346638528859811704183484516925439\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"-340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"-340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n    ));\n    assert_panic!(f32::exact_from(\n        Rational::from_str(\"-10000000000000000000000000000000000000000000000000000\").unwrap(),\n    ));\n    assert_panic!(f32::exact_from(Rational::from_str(\"1/3\").unwrap()));\n    assert_panic!(f32::exact_from(Rational::from_str(\"-1/3\").unwrap()));\n}\n\n#[test]\nfn f32_exact_from_rational_ref_fail() {\n    assert_panic!(f32::exact_from(&Rational::from_str(\"16777217\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"-16777217\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"33554433\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"-33554433\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"33554434\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"-33554434\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"33554435\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"-33554435\").unwrap()));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"340282346638528859811704183484516925439\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"-340282346638528859811704183484516925439\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"-340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"-340282346638528859811704183484516925441\").unwrap()\n    ));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"10000000000000000000000000000000000000000000000000000\").unwrap(),\n    ));\n    assert_panic!(f32::exact_from(\n        &Rational::from_str(\"-10000000000000000000000000000000000000000000000000000\").unwrap(),\n    ));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"1/3\").unwrap()));\n    assert_panic!(f32::exact_from(&Rational::from_str(\"-1/3\").unwrap()));\n}\n\n#[test]\nfn test_f64_exact_from_rational() {\n    let test = |s: &str, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(NiceFloat(f64::exact_from(&u)), NiceFloat(out));\n        assert_eq!(NiceFloat(f64::exact_from(u)), NiceFloat(out));\n    };\n    test(\"3\", 3.0);\n    test(\"-3\", -3.0);\n    test(\"123\", 123.0);\n    test(\"-123\", -123.0);\n    test(\"0\", 0.0);\n    test(\"1000000000\", 1.0e9);\n    test(\"-1000000000\", -1.0e9);\n    test(\"9007199254740992\", 9.007199254740992e15);\n    test(\"-9007199254740992\", -9.007199254740992e15);\n    test(\"9007199254740994\", 9.007199254740994e15);\n    test(\"-9007199254740994\", -9.007199254740994e15);\n    test(\"18014398509481984\", 1.8014398509481984e16);\n    test(\"-18014398509481984\", -1.8014398509481984e16);\n    test(\"18014398509481988\", 1.8014398509481988e16);\n    test(\"-18014398509481988\", -1.8014398509481988e16);\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        1.7976931348623157e308,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n        -1.7976931348623157e308,\n    );\n}\n\n#[test]\nfn f64_exact_from_rational_fail() {\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"18014398509481983\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"-18014398509481983\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"18014398509481985\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"-18014398509481985\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"18014398509481986\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"-18014398509481986\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"18014398509481987\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        Rational::from_str(\"-18014398509481987\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(Rational::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap()));\n    assert_panic!(f64::exact_from(Rational::from_str(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\").unwrap()));\n    assert_panic!(f64::exact_from(Rational::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap()));\n    assert_panic!(f64::exact_from(Rational::from_str(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\").unwrap()));\n    assert_panic!(f64::exact_from(Rational::from_str(\"1/3\").unwrap()));\n    assert_panic!(f64::exact_from(Rational::from_str(\"-1/3\").unwrap()));\n}\n\n#[test]\nfn f64_exact_from_rational_ref_fail() {\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"18014398509481983\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"-18014398509481983\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"18014398509481985\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"-18014398509481985\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"18014398509481986\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"-18014398509481986\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"18014398509481987\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(\n        &Rational::from_str(\"-18014398509481987\").unwrap()\n    ));\n    assert_panic!(f64::exact_from(&Rational::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\").unwrap()));\n    assert_panic!(f64::exact_from(&Rational::from_str(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\").unwrap()));\n    assert_panic!(f64::exact_from(&Rational::from_str(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\").unwrap()));\n    assert_panic!(f64::exact_from(&Rational::from_str(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\").unwrap()));\n    assert_panic!(f64::exact_from(&Rational::from_str(\"1/3\").unwrap()));\n    assert_panic!(f64::exact_from(&Rational::from_str(\"-1/3\").unwrap()));\n}\n\n#[test]\nfn test_f32_convertible_from_rational() {\n    let test = |s: &str, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(f32::convertible_from(&u), out);\n        assert_eq!(f32::convertible_from(u), out);\n    };\n    test(\"3\", true);\n    test(\"-3\", true);\n    test(\"123\", true);\n    test(\"-123\", true);\n    test(\"0\", true);\n    test(\"1000000000\", true);\n    test(\"-1000000000\", true);\n    test(\"16777216\", true);\n    test(\"-16777216\", true);\n    test(\"16777218\", true);\n    test(\"-16777218\", true);\n    test(\"16777217\", false);\n    test(\"-16777217\", false);\n    test(\"33554432\", true);\n    test(\"-33554432\", true);\n    test(\"33554436\", true);\n    test(\"-33554436\", true);\n    test(\"33554433\", false);\n    test(\"-33554433\", false);\n    test(\"33554434\", false);\n    test(\"-33554434\", false);\n    test(\"33554435\", false);\n    test(\"-33554435\", false);\n    test(\"340282346638528859811704183484516925439\", false);\n    test(\"-340282346638528859811704183484516925439\", false);\n    test(\"340282346638528859811704183484516925440\", true);\n    test(\"-340282346638528859811704183484516925440\", true);\n    test(\"340282346638528859811704183484516925441\", false);\n    test(\"-340282346638528859811704183484516925441\", false);\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        false,\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        false,\n    );\n    test(\"1/3\", false);\n    test(\"-1/3\", false);\n}\n\n#[test]\nfn test_f64_convertible_from_rational() {\n    let test = |s: &str, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(f64::convertible_from(&u), out);\n        assert_eq!(f64::convertible_from(u), out);\n    };\n    test(\"3\", true);\n    test(\"-3\", true);\n    test(\"123\", true);\n    test(\"-123\", true);\n    test(\"0\", true);\n    test(\"1000000000\", true);\n    test(\"-1000000000\", true);\n    test(\"9007199254740992\", true);\n    test(\"-9007199254740992\", true);\n    test(\"9007199254740994\", true);\n    test(\"-9007199254740994\", true);\n    test(\"9007199254740993\", false);\n    test(\"-9007199254740993\", false);\n    test(\"18014398509481984\", true);\n    test(\"-18014398509481984\", true);\n    test(\"18014398509481988\", true);\n    test(\"-18014398509481988\", true);\n    test(\"18014398509481985\", false);\n    test(\"-18014398509481985\", false);\n    test(\"18014398509481986\", false);\n    test(\"-18014398509481986\", false);\n    test(\"18014398509481987\", false);\n    test(\"-18014398509481987\", false);\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858367\",\n        false,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858367\",\n        false,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858368\",\n        true,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858368\",\n        true,\n    );\n    test(\n        \"179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558\\\n        6327668781715404589535143824642343213268894641827684675467035375169860499105765512820762454\\\n        9009038932894407586850845513394230458323690322294816580855933212334827479782620414472316873\\\n        8177180919299881250404026184124858369\",\n        false,\n    );\n    test(\n        \"-17976931348623157081452742373170435679807056752584499659891747680315726078002853876058955\\\n        8632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245\\\n        4900903893289440758685084551339423045832369032229481658085593321233482747978262041447231687\\\n        38177180919299881250404026184124858369\",\n        false,\n    );\n\n    test(\"1/3\", false);\n    test(\"-1/3\", false);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn float_rounding_from_rational_properties_helper<\n    T: for<'a> ConvertibleFrom<&'a Integer>\n        + for<'a> ConvertibleFrom<&'a Rational>\n        + PartialOrd<Rational>\n        + PrimitiveFloat\n        + RoundingFrom<Rational>\n        + for<'a> RoundingFrom<&'a Integer>\n        + for<'a> RoundingFrom<&'a Rational>,\n>()\nwhere\n    Rational: TryFrom<T>,\n{\n    rational_rounding_mode_pair_gen_var_5::<T>().test_properties(|(x, rm)| {\n        let (f, o) = T::rounding_from(&x, rm);\n        let neg_f = if x == 0 { T::ZERO } else { -f };\n        let (f_alt, o_alt) = T::rounding_from(-&x, -rm);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(neg_f));\n        assert_eq!(o_alt, o.reverse());\n        let (f_alt, o_alt) = T::rounding_from(&x, rm);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, o);\n\n        assert_eq!(f.partial_cmp(&x), Some(o));\n        match (x >= 0, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    rational_gen_var_4::<T>().test_properties(|n| {\n        let (f, o) = T::rounding_from(&n, Exact);\n        assert_eq!(o, Equal);\n        let (f_alt, o_alt) = T::rounding_from(&n, Floor);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, Equal);\n        let (f_alt, o_alt) = T::rounding_from(&n, Down);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, Equal);\n        let (f_alt, o_alt) = T::rounding_from(&n, Ceiling);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, Equal);\n        let (f_alt, o_alt) = T::rounding_from(&n, Up);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, Equal);\n        let (f_alt, o_alt) = T::rounding_from(&n, Nearest);\n        assert_eq!(NiceFloat(f_alt), NiceFloat(f));\n        assert_eq!(o_alt, Equal);\n\n        assert_eq!(Rational::exact_from(f), n);\n    });\n\n    rational_gen_var_5::<T>().test_properties(|n| {\n        let f_below = T::rounding_from(&n, Floor);\n        assert_eq!(f_below.1, Less);\n        let f_above = (f_below.0.next_higher(), Greater);\n        if f_below.0.is_finite() {\n            assert!(Rational::exact_from(f_below.0) < n);\n        }\n        if f_above.0.is_finite() {\n            assert!(Rational::exact_from(f_above.0) > n);\n        }\n        let (f, o) = T::rounding_from(&n, Ceiling);\n        assert_eq!(NiceFloat(f), NiceFloat(f_above.0));\n        assert_eq!(o, Greater);\n        if n >= 0 {\n            let (f, o) = T::rounding_from(&n, Down);\n            assert_eq!(NiceFloat(f), NiceFloat(f_below.0));\n            assert_eq!(o, Less);\n            let (f, o) = T::rounding_from(&n, Up);\n            assert_eq!(NiceFloat(f), NiceFloat(f_above.0));\n            assert_eq!(o, Greater);\n        } else {\n            let (f, o) = T::rounding_from(&n, Down);\n            assert_eq!(NiceFloat(f), NiceFloat(f_above.0));\n            assert_eq!(o, Greater);\n            let (f, o) = T::rounding_from(&n, Up);\n            assert_eq!(NiceFloat(f), NiceFloat(f_below.0));\n            assert_eq!(o, Less);\n        }\n        let (f, o) = T::rounding_from(&n, Nearest);\n        assert!(\n            (NiceFloat(f), o) == (NiceFloat(f_below.0), f_below.1)\n                || (NiceFloat(f), o) == (NiceFloat(f_above.0), f_above.1)\n        );\n        if f_below.0.is_finite() && f_above.0.is_finite() {\n            let below_diff = &n - Rational::exact_from(f_below.0);\n            let above_diff = Rational::exact_from(f_above.0) - &n;\n            if NiceFloat(f) == NiceFloat(f_below.0) {\n                assert!(below_diff <= above_diff);\n            } else {\n                assert!(below_diff >= above_diff);\n            }\n        }\n    });\n\n    rational_gen_var_6::<T>().test_properties(|n| {\n        let floor = T::rounding_from(&n, Floor);\n        assert_eq!(floor.1, Less);\n        let ceiling = (floor.0.next_higher(), Greater);\n        let nearest = T::rounding_from(&n, Nearest);\n        assert_eq!(\n            (NiceFloat(nearest.0), nearest.1),\n            if floor.0.to_bits().even() {\n                (NiceFloat(floor.0), floor.1)\n            } else {\n                (NiceFloat(ceiling.0), ceiling.1)\n            }\n        );\n    });\n\n    integer_rounding_mode_pair_gen_var_1::<T>().test_properties(|(n, rm)| {\n        let r: Rational = ExactFrom::exact_from(&n);\n        let (f, o) = T::rounding_from(r, rm);\n        let (f_alt, o_alt) = T::rounding_from(&n, rm);\n        assert_eq!(NiceFloat(f), NiceFloat(f_alt));\n        assert_eq!(o, o_alt);\n    });\n}\n\n#[test]\nfn float_rounding_from_rational_properties() {\n    apply_fn_to_primitive_floats!(float_rounding_from_rational_properties_helper);\n\n    let max = Rational::exact_from(f32::MAX_FINITE);\n    rational_gen().test_properties(|x| {\n        if x.lt_abs(&max) {\n            let f = f32::rounding_from(&x, Down).0;\n            if NiceFloat(f) != NiceFloat(-0.0) {\n                assert_eq!(NiceFloat(f), NiceFloat(rug::Rational::from(&x).to_f32()));\n            }\n        }\n        assert_eq!(\n            NiceFloat(f64::rounding_from(&x, Down).0),\n            NiceFloat(rug::Rational::from(&x).to_f64())\n        );\n    });\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn float_try_from_rational_properties_helper<\n    T: TryFrom<Rational, Error = FloatConversionError>\n        + for<'a> TryFrom<&'a Integer>\n        + for<'a> TryFrom<&'a Rational, Error = FloatConversionError>\n        + for<'a> ConvertibleFrom<&'a Rational>\n        + PrimitiveFloat\n        + for<'a> RoundingFrom<&'a Rational>,\n>()\nwhere\n    Natural: TryFrom<T, Error = UnsignedFromFloatError>,\n    Rational: TryFrom<T>,\n{\n    rational_gen().test_properties(|n| {\n        let of = T::try_from(&n);\n        assert_eq!(\n            T::try_from(n.clone()).map(NiceFloat),\n            of.map(|f| NiceFloat(f))\n        );\n        assert_eq!(\n            T::try_from(-&n).map(NiceFloat),\n            of.map(|f| NiceFloat(if n == 0 { T::ZERO } else { -f }))\n        );\n    });\n\n    rational_gen_var_4::<T>().test_properties(|n| {\n        let f = T::exact_from(&n);\n        assert_eq!(NiceFloat(f), NiceFloat(T::rounding_from(&n, Exact).0));\n        assert_eq!(Rational::exact_from(f), n);\n    });\n\n    rational_gen_var_5::<T>().test_properties(|n| {\n        assert!(T::try_from(n).is_err());\n    });\n\n    rational_gen_var_6::<T>().test_properties(|n| {\n        assert!(T::try_from(n).is_err());\n    });\n\n    integer_gen().test_properties(|n| {\n        if let Ok(f) = T::try_from(&n) {\n            let rn: Rational = From::from(&n);\n            assert_eq!(NiceFloat(f), NiceFloat(T::exact_from(rn)));\n        }\n    });\n\n    integer_gen_var_1::<T>().test_properties(|n| {\n        let rn: Rational = From::from(&n);\n        assert_eq!(NiceFloat(T::exact_from(&n)), NiceFloat(T::exact_from(rn)));\n    });\n}\n\n#[test]\nfn float_try_from_rational_properties() {\n    apply_fn_to_primitive_floats!(float_try_from_rational_properties_helper);\n}\n\n#[allow(clippy::trait_duplication_in_bounds)]\nfn float_convertible_from_rational_properties_helper<\n    T: ConvertibleFrom<Rational>\n        + for<'a> ConvertibleFrom<&'a Integer>\n        + for<'a> ConvertibleFrom<&'a Rational>\n        + PrimitiveFloat,\n>()\nwhere\n    Rational: TryFrom<T>,\n{\n    rational_gen().test_properties(|n| {\n        assert_eq!(T::convertible_from(&n), T::convertible_from(-n));\n    });\n\n    rational_gen_var_4::<T>().test_properties(|n| {\n        assert!(T::convertible_from(n));\n    });\n\n    rational_gen_var_5::<T>().test_properties(|n| {\n        assert!(!T::convertible_from(n));\n    });\n\n    rational_gen_var_6::<T>().test_properties(|n| {\n        assert!(!T::convertible_from(n));\n    });\n\n    integer_gen().test_properties(|n| {\n        let rn: Rational = ExactFrom::exact_from(&n);\n        assert_eq!(T::convertible_from(&n), T::convertible_from(&rn));\n    });\n}\n\n#[test]\nfn float_convertible_from_rational_properties() {\n    apply_fn_to_primitive_floats!(float_convertible_from_rational_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/primitive_int_from_rational.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::assert_panic;\nuse malachite_base::num::arithmetic::traits::{Ceiling, Floor};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::basic::signeds::PrimitiveSigned;\nuse malachite_base::num::basic::traits::OneHalf;\nuse malachite_base::num::basic::unsigneds::PrimitiveUnsigned;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{\n    ConvertibleFrom, ExactFrom, IsInteger, RoundingFrom,\n};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::test_util::generators::{signed_gen, unsigned_gen};\nuse malachite_nz::integer::Integer;\nuse malachite_q::Rational;\nuse malachite_q::conversion::primitive_int_from_rational::{\n    SignedFromRationalError, UnsignedFromRationalError,\n};\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_3, rational_rounding_mode_pair_gen_var_3,\n};\nuse std::cmp::Ordering::*;\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_u32_try_from_rational() {\n    let test = |s, out: Result<u32, UnsignedFromRationalError>| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(u32::try_from(&u), out);\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"-123\", Err(UnsignedFromRationalError));\n    test(\"1000000000000\", Err(UnsignedFromRationalError));\n    test(\"-1000000000000\", Err(UnsignedFromRationalError));\n    test(\"22/7\", Err(UnsignedFromRationalError));\n    test(\"-22/7\", Err(UnsignedFromRationalError));\n}\n\n#[test]\nfn test_i32_try_from_rational() {\n    let test = |s, out: Result<i32, SignedFromRationalError>| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(i32::try_from(&u), out);\n    };\n    test(\"0\", Ok(0));\n    test(\"123\", Ok(123));\n    test(\"-123\", Ok(-123));\n    test(\"1000000000000\", Err(SignedFromRationalError));\n    test(\"-1000000000000\", Err(SignedFromRationalError));\n    test(\"22/7\", Err(SignedFromRationalError));\n    test(\"-22/7\", Err(SignedFromRationalError));\n}\n\n#[test]\nfn test_u32_convertible_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(u32::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"-123\", false);\n    test(\"1000000000000\", false);\n    test(\"-1000000000000\", false);\n    test(\"22/7\", false);\n    test(\"-22/7\", false);\n}\n\n#[test]\nfn test_i32_convertible_from_rational() {\n    let test = |s, out| {\n        let u = Rational::from_str(s).unwrap();\n        assert_eq!(i32::convertible_from(&u), out);\n    };\n    test(\"0\", true);\n    test(\"123\", true);\n    test(\"-123\", true);\n    test(\"1000000000000\", false);\n    test(\"-1000000000000\", false);\n    test(\"22/7\", false);\n    test(\"-22/7\", false);\n}\n\n#[test]\nfn test_u32_rounding_from_rational() {\n    let test = |s, rm, out: u32, o_out| {\n        let r = Rational::from_str(s).unwrap();\n        let (u, o) = u32::rounding_from(&r, rm);\n        assert_eq!(u, out);\n        assert_eq!(o, o_out);\n    };\n    test(\"123\", Floor, 123, Equal);\n    test(\"123\", Ceiling, 123, Equal);\n    test(\"123\", Down, 123, Equal);\n    test(\"123\", Up, 123, Equal);\n    test(\"123\", Nearest, 123, Equal);\n    test(\"123\", Exact, 123, Equal);\n\n    test(\"22/7\", Floor, 3, Less);\n    test(\"22/7\", Ceiling, 4, Greater);\n    test(\"22/7\", Down, 3, Less);\n    test(\"22/7\", Up, 4, Greater);\n    test(\"22/7\", Nearest, 3, Less);\n\n    test(\"7/2\", Floor, 3, Less);\n    test(\"7/2\", Ceiling, 4, Greater);\n    test(\"7/2\", Down, 3, Less);\n    test(\"7/2\", Up, 4, Greater);\n    test(\"7/2\", Nearest, 4, Greater);\n\n    test(\"9/2\", Floor, 4, Less);\n    test(\"9/2\", Ceiling, 5, Greater);\n    test(\"9/2\", Down, 4, Less);\n    test(\"9/2\", Up, 5, Greater);\n    test(\"9/2\", Nearest, 4, Less);\n\n    test(\"-123\", Ceiling, 0, Greater);\n    test(\"-123\", Down, 0, Greater);\n    test(\"-123\", Nearest, 0, Greater);\n\n    test(\"1000000000000\", Floor, u32::MAX, Less);\n    test(\"1000000000000\", Down, u32::MAX, Less);\n    test(\"1000000000000\", Nearest, u32::MAX, Less);\n}\n\n#[test]\nfn test_i32_rounding_from_rational() {\n    let test = |s, rm, out: i32, o_out| {\n        let r = Rational::from_str(s).unwrap();\n        let (i, o) = i32::rounding_from(&r, rm);\n        assert_eq!(i, out);\n        assert_eq!(o, o_out);\n    };\n    test(\"123\", Floor, 123, Equal);\n    test(\"123\", Ceiling, 123, Equal);\n    test(\"123\", Down, 123, Equal);\n    test(\"123\", Up, 123, Equal);\n    test(\"123\", Nearest, 123, Equal);\n    test(\"123\", Exact, 123, Equal);\n\n    test(\"22/7\", Floor, 3, Less);\n    test(\"22/7\", Ceiling, 4, Greater);\n    test(\"22/7\", Down, 3, Less);\n    test(\"22/7\", Up, 4, Greater);\n    test(\"22/7\", Nearest, 3, Less);\n\n    test(\"-22/7\", Floor, -4, Less);\n    test(\"-22/7\", Ceiling, -3, Greater);\n    test(\"-22/7\", Down, -3, Greater);\n    test(\"-22/7\", Up, -4, Less);\n    test(\"-22/7\", Nearest, -3, Greater);\n\n    test(\"7/2\", Floor, 3, Less);\n    test(\"7/2\", Ceiling, 4, Greater);\n    test(\"7/2\", Down, 3, Less);\n    test(\"7/2\", Up, 4, Greater);\n    test(\"7/2\", Nearest, 4, Greater);\n\n    test(\"9/2\", Floor, 4, Less);\n    test(\"9/2\", Ceiling, 5, Greater);\n    test(\"9/2\", Down, 4, Less);\n    test(\"9/2\", Up, 5, Greater);\n    test(\"9/2\", Nearest, 4, Less);\n\n    test(\"-1000000000000\", Ceiling, i32::MIN, Greater);\n    test(\"-1000000000000\", Down, i32::MIN, Greater);\n    test(\"-1000000000000\", Nearest, i32::MIN, Greater);\n\n    test(\"1000000000000\", Floor, i32::MAX, Less);\n    test(\"1000000000000\", Down, i32::MAX, Less);\n    test(\"1000000000000\", Nearest, i32::MAX, Less);\n}\n\n#[test]\nfn rounding_from_rational_fail() {\n    let x = Rational::from_str(\"22/7\").unwrap();\n    assert_panic!(u32::rounding_from(&x, Exact));\n\n    let x = Rational::from_str(\"-123\").unwrap();\n    assert_panic!(u32::rounding_from(&x, Floor));\n    assert_panic!(u32::rounding_from(&x, Up));\n    assert_panic!(u32::rounding_from(&x, Exact));\n\n    let x = Rational::from_str(\"1000000000000\").unwrap();\n    assert_panic!(u32::rounding_from(&x, Ceiling));\n    assert_panic!(u32::rounding_from(&x, Up));\n    assert_panic!(u32::rounding_from(&x, Exact));\n\n    let x = Rational::from_str(\"22/7\").unwrap();\n    assert_panic!(i32::rounding_from(&x, Exact));\n\n    let x = Rational::from_str(\"-1000000000000\").unwrap();\n    assert_panic!(i32::rounding_from(&x, Floor));\n    assert_panic!(i32::rounding_from(&x, Up));\n    assert_panic!(i32::rounding_from(&x, Exact));\n\n    let x = Rational::from_str(\"1000000000000\").unwrap();\n    assert_panic!(i32::rounding_from(&x, Ceiling));\n    assert_panic!(i32::rounding_from(&x, Up));\n    assert_panic!(i32::rounding_from(&x, Exact));\n}\n\nfn try_from_rational_properties_helper<\n    T: for<'a> TryFrom<&'a Rational> + for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>()\nwhere\n    Rational: TryFrom<T> + PartialOrd<T>,\n{\n    rational_gen().test_properties(|x| {\n        let p_x = T::try_from(&x);\n        assert_eq!(p_x.is_ok(), x >= T::MIN && x <= T::MAX && x.is_integer());\n        assert_eq!(p_x.is_ok(), T::convertible_from(&x));\n        if let Ok(n) = p_x {\n            assert_eq!(n.to_string(), x.to_string());\n            assert_eq!(T::exact_from(&x), n);\n            assert!(PartialEq::<Rational>::eq(&Rational::exact_from(n), &x));\n        }\n    });\n}\n\n#[test]\nfn try_from_rational_properties() {\n    apply_fn_to_primitive_ints!(try_from_rational_properties_helper);\n}\n\nfn convertible_from_rational_properties_helper<\n    T: for<'a> ConvertibleFrom<&'a Rational> + PrimitiveInt,\n>()\nwhere\n    Rational: PartialOrd<T>,\n{\n    rational_gen().test_properties(|x| {\n        let convertible = T::convertible_from(&x);\n        assert_eq!(convertible, x >= T::MIN && x <= T::MAX && x.is_integer());\n    });\n}\n\n#[test]\nfn convertible_from_rational_properties() {\n    apply_fn_to_primitive_ints!(convertible_from_rational_properties_helper);\n}\n\nfn rounding_from_rational_properties_helper<\n    T: for<'a> ConvertibleFrom<&'a Rational>\n        + PartialEq<Integer>\n        + PartialOrd<Rational>\n        + PrimitiveInt\n        + for<'a> RoundingFrom<&'a Rational>,\n>()\nwhere\n    Rational: From<T> + PartialOrd<T>,\n{\n    rational_rounding_mode_pair_gen_var_3::<T>().test_properties(|(x, rm)| {\n        let (n, o) = T::rounding_from(&x, rm);\n        if x >= T::MIN && x <= T::MAX {\n            assert!((Rational::from(n) - &x).lt_abs(&1));\n        }\n\n        assert_eq!(n.partial_cmp(&x), Some(o));\n        match (x >= T::ZERO, rm) {\n            (_, Floor) | (true, Down) | (false, Up) => {\n                assert_ne!(o, Greater);\n            }\n            (_, Ceiling) | (true, Up) | (false, Down) => {\n                assert_ne!(o, Less);\n            }\n            (_, Exact) => assert_eq!(o, Equal),\n            _ => {}\n        }\n    });\n\n    // TODO use range\n    rational_gen_var_3().test_properties(|x| {\n        if x < T::MIN || x > T::MAX {\n            return;\n        }\n        let floor = T::rounding_from(&x, Floor);\n        assert_eq!(floor.0, (&x).floor());\n        assert!(floor.0 <= x);\n        if floor.0 < T::MAX {\n            assert!(floor.0 + T::ONE > x);\n        }\n        let ceiling = T::rounding_from(&x, Ceiling);\n        assert_eq!(ceiling.0, (&x).ceiling());\n        assert!(ceiling.0 >= x);\n        if ceiling.0 > T::MIN {\n            assert!(ceiling.0 - T::ONE < x);\n        }\n\n        if x >= T::ZERO {\n            assert_eq!(T::rounding_from(&x, Down), floor);\n            assert_eq!(T::rounding_from(&x, Up), ceiling);\n        } else {\n            assert_eq!(T::rounding_from(&x, Down), ceiling);\n            assert_eq!(T::rounding_from(&x, Up), floor);\n        }\n\n        let nearest = T::rounding_from(&x, Nearest);\n        assert!(nearest == floor || nearest == ceiling);\n        assert!((Rational::from(nearest.0) - x).le_abs(&Rational::ONE_HALF));\n    });\n}\n\nfn rounding_from_rational_properties_unsigned_helper<\n    T: PrimitiveUnsigned + for<'a> RoundingFrom<&'a Rational>,\n>()\nwhere\n    Rational: From<T>,\n{\n    unsigned_gen::<T>().test_properties(|n| {\n        let no = (n, Equal);\n        let x = Rational::from(n);\n        assert_eq!(T::rounding_from(&x, Floor), no);\n        assert_eq!(T::rounding_from(&x, Down), no);\n        assert_eq!(T::rounding_from(&x, Ceiling), no);\n        assert_eq!(T::rounding_from(&x, Up), no);\n        assert_eq!(T::rounding_from(&x, Nearest), no);\n        assert_eq!(T::rounding_from(&x, Exact), no);\n    });\n}\n\nfn rounding_from_rational_properties_signed_helper<\n    T: PrimitiveSigned + for<'a> RoundingFrom<&'a Rational>,\n>()\nwhere\n    Rational: From<T>,\n{\n    signed_gen::<T>().test_properties(|n| {\n        let no = (n, Equal);\n        let x = Rational::from(n);\n        assert_eq!(T::rounding_from(&x, Floor), no);\n        assert_eq!(T::rounding_from(&x, Down), no);\n        assert_eq!(T::rounding_from(&x, Ceiling), no);\n        assert_eq!(T::rounding_from(&x, Up), no);\n        assert_eq!(T::rounding_from(&x, Nearest), no);\n        assert_eq!(T::rounding_from(&x, Exact), no);\n    });\n}\n\n#[test]\nfn rounding_from_rational_properties() {\n    apply_fn_to_primitive_ints!(rounding_from_rational_properties_helper);\n    apply_fn_to_unsigneds!(rounding_from_rational_properties_unsigned_helper);\n    apply_fn_to_signeds!(rounding_from_rational_properties_signed_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/sci_mantissa_and_exponent.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::assert_panic;\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::comparison::traits::PartialOrdAbs;\nuse malachite_base::num::conversion::traits::{ExactFrom, SciMantissaAndExponent};\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::rounding_modes::RoundingMode::{self, *};\nuse malachite_base::test_util::generators::{\n    primitive_float_signed_pair_gen_var_1, primitive_float_signed_pair_gen_var_2,\n};\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::{\n    natural_gen_var_2, natural_rounding_mode_pair_gen_var_2,\n};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen_var_1, rational_rounding_mode_pair_gen_var_4,\n};\nuse std::cmp::Ordering::{self, *};\nuse std::panic::catch_unwind;\nuse std::str::FromStr;\n\n#[test]\nfn test_sci_mantissa_and_exponent() {\n    let test = |s: &str, mantissa: f32, exponent: i64| {\n        let n = Rational::from_str(s).unwrap();\n        let (actual_mantissa, actual_exponent) = (&n).sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(actual_mantissa), NiceFloat(mantissa));\n        assert_eq!(actual_exponent, exponent);\n        let (actual_mantissa, actual_exponent) = n.clone().sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(actual_mantissa), NiceFloat(mantissa));\n        assert_eq!(actual_exponent, exponent);\n        assert_eq!(NiceFloat((&n).sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(\n            SciMantissaAndExponent::<f32, i64, Rational>::sci_exponent(&n),\n            exponent\n        );\n        assert_eq!(NiceFloat(n.clone().sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(\n            SciMantissaAndExponent::<f32, i64, Rational>::sci_exponent(n.clone()),\n            exponent\n        );\n\n        let (actual_mantissa, actual_exponent) = (-n).sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(actual_mantissa), NiceFloat(mantissa));\n        assert_eq!(actual_exponent, exponent);\n    };\n    test(\"3\", 1.5, 1);\n    test(\"123\", 1.921875, 6);\n    test(\"1000000000\", 1.8626451, 29);\n\n    test(\"16777216\", 1.0, 24);\n    test(\"16777218\", 1.0000001, 24);\n    test(\"16777217\", 1.0, 24);\n\n    test(\"33554432\", 1.0, 25);\n    test(\"33554436\", 1.0000001, 25);\n    test(\"33554440\", 1.0000002, 25);\n\n    test(\"33554433\", 1.0, 25);\n    test(\"33554434\", 1.0, 25);\n    test(\"33554435\", 1.0000001, 25);\n    test(\"33554437\", 1.0000001, 25);\n    test(\"33554438\", 1.0000002, 25);\n    test(\"33554439\", 1.0000002, 25);\n    test(\"340282346638528859811704183484516925439\", 1.9999999, 127);\n    test(\"340282346638528859811704183484516925440\", 1.9999999, 127);\n    test(\"340282346638528859811704183484516925441\", 1.9999999, 127);\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        1.670478,\n        172,\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        1.8920966,\n        458,\n    );\n\n    test(\"1/3\", 1.3333334, -2);\n    test(\"1/1024\", 1.0, -10);\n    test(\"22/7\", 1.5714285, 1);\n    test(\"936851431250/1397\", 1.2491208, 29);\n}\n\n#[test]\nfn test_sci_mantissa_and_exponent_round() {\n    let test = |n: &str, rm: RoundingMode, out: Option<(f32, i64, Ordering)>| {\n        let r = Rational::from_str(n).unwrap();\n        let actual_out = r.clone().sci_mantissa_and_exponent_round(rm);\n        assert_eq!(\n            actual_out.map(|(m, e, o)| (NiceFloat(m), e, o)),\n            out.map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n        let actual_out = r.sci_mantissa_and_exponent_round_ref(rm);\n        assert_eq!(\n            actual_out.map(|(m, e, o)| (NiceFloat(m), e, o)),\n            out.map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n        let actual_out = (-r).sci_mantissa_and_exponent_round(rm);\n        assert_eq!(\n            actual_out.map(|(m, e, o)| (NiceFloat(m), e, o)),\n            out.map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    };\n    test(\"3\", Floor, Some((1.5, 1, Equal)));\n    test(\"3\", Down, Some((1.5, 1, Equal)));\n    test(\"3\", Ceiling, Some((1.5, 1, Equal)));\n    test(\"3\", Up, Some((1.5, 1, Equal)));\n    test(\"3\", Nearest, Some((1.5, 1, Equal)));\n    test(\"3\", Exact, Some((1.5, 1, Equal)));\n\n    test(\"123\", Floor, Some((1.921875, 6, Equal)));\n    test(\"123\", Down, Some((1.921875, 6, Equal)));\n    test(\"123\", Ceiling, Some((1.921875, 6, Equal)));\n    test(\"123\", Up, Some((1.921875, 6, Equal)));\n    test(\"123\", Nearest, Some((1.921875, 6, Equal)));\n    test(\"123\", Exact, Some((1.921875, 6, Equal)));\n\n    test(\"1000000000\", Floor, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Down, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Ceiling, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Up, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Nearest, Some((1.8626451, 29, Equal)));\n    test(\"1000000000\", Exact, Some((1.8626451, 29, Equal)));\n\n    test(\"16777216\", Floor, Some((1.0, 24, Equal)));\n    test(\"16777216\", Down, Some((1.0, 24, Equal)));\n    test(\"16777216\", Ceiling, Some((1.0, 24, Equal)));\n    test(\"16777216\", Up, Some((1.0, 24, Equal)));\n    test(\"16777216\", Nearest, Some((1.0, 24, Equal)));\n    test(\"16777216\", Exact, Some((1.0, 24, Equal)));\n\n    test(\"16777218\", Floor, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Down, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Ceiling, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Up, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Nearest, Some((1.0000001, 24, Equal)));\n    test(\"16777218\", Exact, Some((1.0000001, 24, Equal)));\n\n    test(\"16777217\", Floor, Some((1.0, 24, Less)));\n    test(\"16777217\", Down, Some((1.0, 24, Less)));\n    test(\"16777217\", Ceiling, Some((1.0000001, 24, Greater)));\n    test(\"16777217\", Up, Some((1.0000001, 24, Greater)));\n    test(\"16777217\", Nearest, Some((1.0, 24, Less)));\n    test(\"16777217\", Exact, None);\n\n    test(\"33554432\", Floor, Some((1.0, 25, Equal)));\n    test(\"33554432\", Down, Some((1.0, 25, Equal)));\n    test(\"33554432\", Ceiling, Some((1.0, 25, Equal)));\n    test(\"33554432\", Up, Some((1.0, 25, Equal)));\n    test(\"33554432\", Nearest, Some((1.0, 25, Equal)));\n    test(\"33554432\", Exact, Some((1.0, 25, Equal)));\n\n    test(\"33554436\", Floor, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Down, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Ceiling, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Up, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Nearest, Some((1.0000001, 25, Equal)));\n    test(\"33554436\", Exact, Some((1.0000001, 25, Equal)));\n\n    test(\"33554440\", Floor, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Down, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Ceiling, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Up, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Nearest, Some((1.0000002, 25, Equal)));\n    test(\"33554440\", Exact, Some((1.0000002, 25, Equal)));\n\n    test(\"33554433\", Floor, Some((1.0, 25, Less)));\n    test(\"33554433\", Down, Some((1.0, 25, Less)));\n    test(\"33554433\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"33554433\", Up, Some((1.0000001, 25, Greater)));\n    test(\"33554433\", Nearest, Some((1.0, 25, Less)));\n    test(\"33554433\", Exact, None);\n\n    test(\"33554434\", Floor, Some((1.0, 25, Less)));\n    test(\"33554434\", Down, Some((1.0, 25, Less)));\n    test(\"33554434\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"33554434\", Up, Some((1.0000001, 25, Greater)));\n    test(\"33554434\", Nearest, Some((1.0, 25, Less)));\n    test(\"33554434\", Exact, None);\n\n    test(\"33554435\", Floor, Some((1.0, 25, Less)));\n    test(\"33554435\", Down, Some((1.0, 25, Less)));\n    test(\"33554435\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"33554435\", Up, Some((1.0000001, 25, Greater)));\n    test(\"33554435\", Nearest, Some((1.0000001, 25, Greater)));\n    test(\"33554435\", Exact, None);\n\n    test(\"33554437\", Floor, Some((1.0000001, 25, Less)));\n    test(\"33554437\", Down, Some((1.0000001, 25, Less)));\n    test(\"33554437\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"33554437\", Up, Some((1.0000002, 25, Greater)));\n    test(\"33554437\", Nearest, Some((1.0000001, 25, Less)));\n    test(\"33554437\", Exact, None);\n\n    test(\"33554438\", Floor, Some((1.0000001, 25, Less)));\n    test(\"33554438\", Down, Some((1.0000001, 25, Less)));\n    test(\"33554438\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"33554438\", Up, Some((1.0000002, 25, Greater)));\n    test(\"33554438\", Nearest, Some((1.0000002, 25, Greater)));\n    test(\"33554438\", Exact, None);\n\n    test(\"33554439\", Floor, Some((1.0000001, 25, Less)));\n    test(\"33554439\", Down, Some((1.0000001, 25, Less)));\n    test(\"33554439\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"33554439\", Up, Some((1.0000002, 25, Greater)));\n    test(\"33554439\", Nearest, Some((1.0000002, 25, Greater)));\n    test(\"33554439\", Exact, None);\n\n    test(\n        \"340282346638528859811704183484516925439\",\n        Floor,\n        Some((1.9999998, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Down,\n        Some((1.9999998, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Ceiling,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Up,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\n        \"340282346638528859811704183484516925439\",\n        Nearest,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\"340282346638528859811704183484516925439\", Exact, None);\n\n    test(\n        \"340282346638528859811704183484516925440\",\n        Floor,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Down,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Ceiling,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Up,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Nearest,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"340282346638528859811704183484516925440\",\n        Exact,\n        Some((1.9999999, 127, Equal)),\n    );\n\n    test(\n        \"340282346638528859811704183484516925441\",\n        Floor,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Down,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Ceiling,\n        Some((1.0, 128, Greater)),\n    );\n\n    test(\n        \"340282346638528859811704183484516925441\",\n        Up,\n        Some((1.0, 128, Greater)),\n    );\n    test(\n        \"340282346638528859811704183484516925441\",\n        Nearest,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\"340282346638528859811704183484516925441\", Exact, None);\n\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        Some((1.6704779, 172, Less)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Down,\n        Some((1.6704779, 172, Less)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Up,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"10000000000000000000000000000000000000000000000000000\",\n        Exact,\n        None,\n    );\n\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Floor,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Down,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Ceiling,\n        Some((1.8920968, 458, Greater)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Up,\n        Some((1.8920968, 458, Greater)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Nearest,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Exact,\n        None,\n    );\n\n    test(\"1/3\", Floor, Some((1.3333333, -2, Less)));\n    test(\"1/3\", Ceiling, Some((1.3333334, -2, Greater)));\n    test(\"1/3\", Down, Some((1.3333333, -2, Less)));\n    test(\"1/3\", Up, Some((1.3333334, -2, Greater)));\n    test(\"1/3\", Nearest, Some((1.3333334, -2, Greater)));\n    test(\"1/3\", Exact, None);\n\n    test(\"1/1024\", Floor, Some((1.0, -10, Equal)));\n    test(\"1/1024\", Ceiling, Some((1.0, -10, Equal)));\n    test(\"1/1024\", Down, Some((1.0, -10, Equal)));\n    test(\"1/1024\", Up, Some((1.0, -10, Equal)));\n    test(\"1/1024\", Nearest, Some((1.0, -10, Equal)));\n    test(\"1/1024\", Exact, Some((1.0, -10, Equal)));\n\n    test(\"22/7\", Floor, Some((1.5714285, 1, Less)));\n    test(\"22/7\", Ceiling, Some((1.5714287, 1, Greater)));\n    test(\"22/7\", Down, Some((1.5714285, 1, Less)));\n    test(\"22/7\", Up, Some((1.5714287, 1, Greater)));\n    test(\"22/7\", Nearest, Some((1.5714285, 1, Less)));\n    test(\"22/7\", Exact, None);\n\n    test(\"936851431250/1397\", Floor, Some((1.2491207, 29, Less)));\n    test(\"936851431250/1397\", Ceiling, Some((1.2491208, 29, Greater)));\n    test(\"936851431250/1397\", Down, Some((1.2491207, 29, Less)));\n    test(\"936851431250/1397\", Up, Some((1.2491208, 29, Greater)));\n    test(\"936851431250/1397\", Nearest, Some((1.2491208, 29, Greater)));\n    test(\"936851431250/1397\", Exact, None);\n\n    test(\n        \"1073741823/1099511627776\",\n        Floor,\n        Some((1.9999999, -11, Less)),\n    );\n    test(\n        \"1073741823/1099511627776\",\n        Ceiling,\n        Some((1.0, -10, Greater)),\n    );\n    test(\n        \"1073741823/1099511627776\",\n        Down,\n        Some((1.9999999, -11, Less)),\n    );\n    test(\"1073741823/1099511627776\", Up, Some((1.0, -10, Greater)));\n    test(\n        \"1073741823/1099511627776\",\n        Nearest,\n        Some((1.0, -10, Greater)),\n    );\n    test(\"1073741823/1099511627776\", Exact, None);\n\n    test(\"-3\", Floor, Some((1.5, 1, Equal)));\n    test(\"-3\", Down, Some((1.5, 1, Equal)));\n    test(\"-3\", Ceiling, Some((1.5, 1, Equal)));\n    test(\"-3\", Up, Some((1.5, 1, Equal)));\n    test(\"-3\", Nearest, Some((1.5, 1, Equal)));\n    test(\"-3\", Exact, Some((1.5, 1, Equal)));\n\n    test(\"-123\", Floor, Some((1.921875, 6, Equal)));\n    test(\"-123\", Down, Some((1.921875, 6, Equal)));\n    test(\"-123\", Ceiling, Some((1.921875, 6, Equal)));\n    test(\"-123\", Up, Some((1.921875, 6, Equal)));\n    test(\"-123\", Nearest, Some((1.921875, 6, Equal)));\n    test(\"-123\", Exact, Some((1.921875, 6, Equal)));\n\n    test(\"-1000000000\", Floor, Some((1.8626451, 29, Equal)));\n    test(\"-1000000000\", Down, Some((1.8626451, 29, Equal)));\n    test(\"-1000000000\", Ceiling, Some((1.8626451, 29, Equal)));\n    test(\"-1000000000\", Up, Some((1.8626451, 29, Equal)));\n    test(\"-1000000000\", Nearest, Some((1.8626451, 29, Equal)));\n    test(\"-1000000000\", Exact, Some((1.8626451, 29, Equal)));\n\n    test(\"-16777216\", Floor, Some((1.0, 24, Equal)));\n    test(\"-16777216\", Down, Some((1.0, 24, Equal)));\n    test(\"-16777216\", Ceiling, Some((1.0, 24, Equal)));\n    test(\"-16777216\", Up, Some((1.0, 24, Equal)));\n    test(\"-16777216\", Nearest, Some((1.0, 24, Equal)));\n    test(\"-16777216\", Exact, Some((1.0, 24, Equal)));\n\n    test(\"-16777218\", Floor, Some((1.0000001, 24, Equal)));\n    test(\"-16777218\", Down, Some((1.0000001, 24, Equal)));\n    test(\"-16777218\", Ceiling, Some((1.0000001, 24, Equal)));\n    test(\"-16777218\", Up, Some((1.0000001, 24, Equal)));\n    test(\"-16777218\", Nearest, Some((1.0000001, 24, Equal)));\n    test(\"-16777218\", Exact, Some((1.0000001, 24, Equal)));\n\n    test(\"-16777217\", Floor, Some((1.0, 24, Less)));\n    test(\"-16777217\", Down, Some((1.0, 24, Less)));\n    test(\"-16777217\", Ceiling, Some((1.0000001, 24, Greater)));\n    test(\"-16777217\", Up, Some((1.0000001, 24, Greater)));\n    test(\"-16777217\", Nearest, Some((1.0, 24, Less)));\n    test(\"-16777217\", Exact, None);\n\n    test(\"-33554432\", Floor, Some((1.0, 25, Equal)));\n    test(\"-33554432\", Down, Some((1.0, 25, Equal)));\n    test(\"-33554432\", Ceiling, Some((1.0, 25, Equal)));\n    test(\"-33554432\", Up, Some((1.0, 25, Equal)));\n    test(\"-33554432\", Nearest, Some((1.0, 25, Equal)));\n    test(\"-33554432\", Exact, Some((1.0, 25, Equal)));\n\n    test(\"-33554436\", Floor, Some((1.0000001, 25, Equal)));\n    test(\"-33554436\", Down, Some((1.0000001, 25, Equal)));\n    test(\"-33554436\", Ceiling, Some((1.0000001, 25, Equal)));\n    test(\"-33554436\", Up, Some((1.0000001, 25, Equal)));\n    test(\"-33554436\", Nearest, Some((1.0000001, 25, Equal)));\n    test(\"-33554436\", Exact, Some((1.0000001, 25, Equal)));\n\n    test(\"-33554440\", Floor, Some((1.0000002, 25, Equal)));\n    test(\"-33554440\", Down, Some((1.0000002, 25, Equal)));\n    test(\"-33554440\", Ceiling, Some((1.0000002, 25, Equal)));\n    test(\"-33554440\", Up, Some((1.0000002, 25, Equal)));\n    test(\"-33554440\", Nearest, Some((1.0000002, 25, Equal)));\n    test(\"-33554440\", Exact, Some((1.0000002, 25, Equal)));\n\n    test(\"-33554433\", Floor, Some((1.0, 25, Less)));\n    test(\"-33554433\", Down, Some((1.0, 25, Less)));\n    test(\"-33554433\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"-33554433\", Up, Some((1.0000001, 25, Greater)));\n    test(\"-33554433\", Nearest, Some((1.0, 25, Less)));\n    test(\"-33554433\", Exact, None);\n\n    test(\"-33554434\", Floor, Some((1.0, 25, Less)));\n    test(\"-33554434\", Down, Some((1.0, 25, Less)));\n    test(\"-33554434\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"-33554434\", Up, Some((1.0000001, 25, Greater)));\n    test(\"-33554434\", Nearest, Some((1.0, 25, Less)));\n    test(\"-33554434\", Exact, None);\n\n    test(\"-33554435\", Floor, Some((1.0, 25, Less)));\n    test(\"-33554435\", Down, Some((1.0, 25, Less)));\n    test(\"-33554435\", Ceiling, Some((1.0000001, 25, Greater)));\n    test(\"-33554435\", Up, Some((1.0000001, 25, Greater)));\n    test(\"-33554435\", Nearest, Some((1.0000001, 25, Greater)));\n    test(\"-33554435\", Exact, None);\n\n    test(\"-33554437\", Floor, Some((1.0000001, 25, Less)));\n    test(\"-33554437\", Down, Some((1.0000001, 25, Less)));\n    test(\"-33554437\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"-33554437\", Up, Some((1.0000002, 25, Greater)));\n    test(\"-33554437\", Nearest, Some((1.0000001, 25, Less)));\n    test(\"-33554437\", Exact, None);\n\n    test(\"-33554438\", Floor, Some((1.0000001, 25, Less)));\n    test(\"-33554438\", Down, Some((1.0000001, 25, Less)));\n    test(\"-33554438\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"-33554438\", Up, Some((1.0000002, 25, Greater)));\n    test(\"-33554438\", Nearest, Some((1.0000002, 25, Greater)));\n    test(\"-33554438\", Exact, None);\n\n    test(\"-33554439\", Floor, Some((1.0000001, 25, Less)));\n    test(\"-33554439\", Down, Some((1.0000001, 25, Less)));\n    test(\"-33554439\", Ceiling, Some((1.0000002, 25, Greater)));\n    test(\"-33554439\", Up, Some((1.0000002, 25, Greater)));\n    test(\"-33554439\", Nearest, Some((1.0000002, 25, Greater)));\n    test(\"-33554439\", Exact, None);\n\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Floor,\n        Some((1.9999998, 127, Less)),\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Down,\n        Some((1.9999998, 127, Less)),\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Ceiling,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Up,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\n        \"-340282346638528859811704183484516925439\",\n        Nearest,\n        Some((1.9999999, 127, Greater)),\n    );\n    test(\"-340282346638528859811704183484516925439\", Exact, None);\n\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Floor,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Down,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Ceiling,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Up,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Nearest,\n        Some((1.9999999, 127, Equal)),\n    );\n    test(\n        \"-340282346638528859811704183484516925440\",\n        Exact,\n        Some((1.9999999, 127, Equal)),\n    );\n\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Floor,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Down,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Ceiling,\n        Some((1.0, 128, Greater)),\n    );\n\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Up,\n        Some((1.0, 128, Greater)),\n    );\n    test(\n        \"-340282346638528859811704183484516925441\",\n        Nearest,\n        Some((1.9999999, 127, Less)),\n    );\n    test(\"-340282346638528859811704183484516925441\", Exact, None);\n\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Floor,\n        Some((1.6704779, 172, Less)),\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Down,\n        Some((1.6704779, 172, Less)),\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Ceiling,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Up,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Nearest,\n        Some((1.670478, 172, Greater)),\n    );\n    test(\n        \"-10000000000000000000000000000000000000000000000000000\",\n        Exact,\n        None,\n    );\n\n    test(\n        \"-14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Floor,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"-14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Down,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"-14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Ceiling,\n        Some((1.8920968, 458, Greater)),\n    );\n    test(\n        \"-14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Up,\n        Some((1.8920968, 458, Greater)),\n    );\n    test(\n        \"-14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Nearest,\n        Some((1.8920966, 458, Less)),\n    );\n    test(\n        \"-14082550970654138785851080671018547544414440081606160064666506533805114137489745015963441\\\n        66687102119468305028824490080062160433429798263165\",\n        Exact,\n        None,\n    );\n\n    test(\"-1/3\", Floor, Some((1.3333333, -2, Less)));\n    test(\"-1/3\", Ceiling, Some((1.3333334, -2, Greater)));\n    test(\"-1/3\", Down, Some((1.3333333, -2, Less)));\n    test(\"-1/3\", Up, Some((1.3333334, -2, Greater)));\n    test(\"-1/3\", Nearest, Some((1.3333334, -2, Greater)));\n    test(\"-1/3\", Exact, None);\n\n    test(\"-1/1024\", Floor, Some((1.0, -10, Equal)));\n    test(\"-1/1024\", Ceiling, Some((1.0, -10, Equal)));\n    test(\"-1/1024\", Down, Some((1.0, -10, Equal)));\n    test(\"-1/1024\", Up, Some((1.0, -10, Equal)));\n    test(\"-1/1024\", Nearest, Some((1.0, -10, Equal)));\n    test(\"-1/1024\", Exact, Some((1.0, -10, Equal)));\n\n    test(\"-22/7\", Floor, Some((1.5714285, 1, Less)));\n    test(\"-22/7\", Ceiling, Some((1.5714287, 1, Greater)));\n    test(\"-22/7\", Down, Some((1.5714285, 1, Less)));\n    test(\"-22/7\", Up, Some((1.5714287, 1, Greater)));\n    test(\"-22/7\", Nearest, Some((1.5714285, 1, Less)));\n    test(\"-22/7\", Exact, None);\n\n    test(\"-936851431250/1397\", Floor, Some((1.2491207, 29, Less)));\n    test(\n        \"-936851431250/1397\",\n        Ceiling,\n        Some((1.2491208, 29, Greater)),\n    );\n    test(\"-936851431250/1397\", Down, Some((1.2491207, 29, Less)));\n    test(\"-936851431250/1397\", Up, Some((1.2491208, 29, Greater)));\n    test(\n        \"-936851431250/1397\",\n        Nearest,\n        Some((1.2491208, 29, Greater)),\n    );\n    test(\"-936851431250/1397\", Exact, None);\n\n    test(\n        \"-1073741823/1099511627776\",\n        Floor,\n        Some((1.9999999, -11, Less)),\n    );\n    test(\n        \"-1073741823/1099511627776\",\n        Ceiling,\n        Some((1.0, -10, Greater)),\n    );\n    test(\n        \"-1073741823/1099511627776\",\n        Down,\n        Some((1.9999999, -11, Less)),\n    );\n    test(\"-1073741823/1099511627776\", Up, Some((1.0, -10, Greater)));\n    test(\n        \"-1073741823/1099511627776\",\n        Nearest,\n        Some((1.0, -10, Greater)),\n    );\n    test(\"-1073741823/1099511627776\", Exact, None);\n}\n\n#[test]\nfn test_from_sci_mantissa_and_exponent() {\n    let test = |mantissa: f32, exponent: i64, out: Option<&str>| {\n        assert_eq!(\n            <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n                mantissa, exponent\n            ),\n            out.map(|s| Rational::from_str(s).unwrap())\n        );\n        assert_eq!(\n            <Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n                mantissa, exponent\n            ),\n            out.map(|s| Rational::from_str(s).unwrap())\n        );\n    };\n    test(1.5, 1, Some(\"3\"));\n    test(1.51, 1, Some(\"6333399/2097152\"));\n    test(1.921875, 6, Some(\"123\"));\n    test(\n        1.670478,\n        172,\n        Some(\"10000000254586612611935772707803116801852191350456320\"),\n    );\n\n    test(2.0, 1, None);\n    test(10.0, 1, None);\n    test(0.5, 1, None);\n}\n\nfn from_sci_mantissa_and_exponent_fail_helper<T: PrimitiveFloat>()\nwhere\n    Rational: SciMantissaAndExponent<T, i64>,\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    assert_panic!(\n        <&Rational as SciMantissaAndExponent<T, i64, _>>::from_sci_mantissa_and_exponent(\n            T::ZERO,\n            0\n        )\n    );\n    assert_panic!(\n        <Rational as SciMantissaAndExponent<T, i64, _>>::from_sci_mantissa_and_exponent(T::ZERO, 0)\n    );\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_fail() {\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_fail_helper);\n}\n\nfn sci_mantissa_and_exponent_properties_helper<T: PrimitiveFloat>()\nwhere\n    Rational: SciMantissaAndExponent<T, i64>,\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n    for<'a> &'a Natural: SciMantissaAndExponent<T, u64, Natural>,\n{\n    rational_gen_var_1().test_properties(|n| {\n        let (mantissa, exponent) = (&n).sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat((&n).sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!((&n).sci_exponent(), exponent);\n        let (mantissa_alt, exponent_alt) = n.clone().sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(mantissa_alt), NiceFloat(mantissa));\n        assert_eq!(exponent_alt, exponent);\n        assert_eq!(NiceFloat(n.clone().sci_mantissa()), NiceFloat(mantissa));\n        assert_eq!(n.clone().sci_exponent(), exponent);\n\n        assert!(mantissa >= T::ONE);\n        assert!(mantissa < T::TWO);\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round(Nearest)\n                .map(|(m, e, _): (T, i64, Ordering)| (NiceFloat(m), e)),\n            Some((NiceFloat(mantissa), exponent))\n        );\n    });\n\n    natural_gen_var_2().test_properties(|x| {\n        let (mantissa_1, exponent_1) = x.sci_mantissa_and_exponent();\n        let (mantissa_2, exponent_2) = (&Rational::from(x)).sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(mantissa_1), NiceFloat(mantissa_2));\n        assert_eq!(i64::exact_from(exponent_1), exponent_2);\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_properties() {\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_properties_helper);\n}\n\nfn sci_mantissa_and_exponent_round_properties_helper<T: PrimitiveFloat>()\nwhere\n    Rational: SciMantissaAndExponent<T, i64>,\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    rational_rounding_mode_pair_gen_var_4().test_properties(|(n, rm)| {\n        let result = n.sci_mantissa_and_exponent_round_ref::<T>(rm);\n        assert_eq!(\n            n.clone()\n                .sci_mantissa_and_exponent_round::<T>(rm)\n                .map(|(m, e, o)| (NiceFloat(m), e, o)),\n            result.map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n        if let Some((mantissa, exponent, o)) = result {\n            assert!(mantissa >= T::ONE);\n            assert!(mantissa < T::TWO);\n            let x = <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(\n                mantissa, exponent,\n            )\n            .unwrap();\n            if rm == Exact {\n                assert_eq!(x.partial_cmp_abs(&n), Some(Equal));\n            }\n            assert_eq!(x.partial_cmp_abs(&n), Some(o));\n            match rm {\n                Floor | Down => assert_ne!(o, Greater),\n                Ceiling | Up => assert_ne!(o, Less),\n                Exact => assert_eq!(o, Equal),\n                _ => {}\n            }\n        }\n    });\n\n    rational_gen_var_1().test_properties(|n| {\n        let (floor_mantissa, floor_exponent, floor_o) =\n            n.sci_mantissa_and_exponent_round_ref::<T>(Floor).unwrap();\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round_ref::<T>(Down).unwrap(),\n            (floor_mantissa, floor_exponent, floor_o)\n        );\n        let (ceiling_mantissa, ceiling_exponent, ceiling_o) =\n            n.sci_mantissa_and_exponent_round_ref::<T>(Ceiling).unwrap();\n        assert_eq!(\n            n.sci_mantissa_and_exponent_round_ref::<T>(Up).unwrap(),\n            (ceiling_mantissa, ceiling_exponent, ceiling_o)\n        );\n        let (nearest_mantissa, nearest_exponent, nearest_o) =\n            n.sci_mantissa_and_exponent_round_ref::<T>(Nearest).unwrap();\n        if let Some((mantissa, exponent, o)) = n.sci_mantissa_and_exponent_round_ref::<T>(Exact) {\n            assert_eq!(o, Equal);\n            assert_eq!(floor_mantissa, mantissa);\n            assert_eq!(ceiling_mantissa, mantissa);\n            assert_eq!(nearest_mantissa, mantissa);\n            assert_eq!(floor_exponent, exponent);\n            assert_eq!(ceiling_exponent, exponent);\n            assert_eq!(nearest_exponent, exponent);\n        } else {\n            assert_eq!(floor_o, Less);\n            assert_eq!(ceiling_o, Greater);\n            assert_ne!(\n                (floor_mantissa, floor_exponent),\n                (ceiling_mantissa, ceiling_exponent)\n            );\n            assert!(\n                (nearest_mantissa, nearest_exponent, nearest_o)\n                    == (floor_mantissa, floor_exponent, floor_o)\n                    || (nearest_mantissa, nearest_exponent, nearest_o)\n                        == (ceiling_mantissa, ceiling_exponent, ceiling_o)\n            );\n            if ceiling_mantissa == T::ONE {\n                assert_eq!(floor_mantissa, T::TWO.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent - 1);\n            } else {\n                assert_eq!(floor_mantissa, ceiling_mantissa.next_lower());\n                assert_eq!(floor_exponent, ceiling_exponent);\n            }\n        }\n    });\n\n    natural_rounding_mode_pair_gen_var_2().test_properties(|(x, rm)| {\n        assert_eq!(\n            x.sci_mantissa_and_exponent_round(rm)\n                .map(|(m, e, o): (T, u64, Ordering)| (NiceFloat(m), i64::exact_from(e), o)),\n            Rational::from(x)\n                .sci_mantissa_and_exponent_round(rm)\n                .map(|(m, e, o)| (NiceFloat(m), e, o))\n        );\n    });\n}\n\n#[test]\nfn sci_mantissa_and_exponent_round_properties() {\n    apply_fn_to_primitive_floats!(sci_mantissa_and_exponent_round_properties_helper);\n}\n\nfn from_sci_mantissa_and_exponent_properties_helper<T: PrimitiveFloat>()\nwhere\n    Rational: SciMantissaAndExponent<T, i64>,\n    for<'a> &'a Rational: SciMantissaAndExponent<T, i64, Rational>,\n{\n    primitive_float_signed_pair_gen_var_1::<T, i64>().test_properties(|(m, e)| {\n        let on =\n            <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e);\n        assert_eq!(\n            <Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e),\n            on\n        );\n        assert_eq!(on.is_some(), m >= T::ONE && m < T::TWO);\n    });\n\n    primitive_float_signed_pair_gen_var_2::<T>().test_properties(|(m, e)| {\n        let x =\n            <&Rational as SciMantissaAndExponent<_, _, _>>::from_sci_mantissa_and_exponent(m, e)\n                .unwrap();\n        assert!(m >= T::ONE && m < T::TWO);\n        let (m_alt, e_alt) = (&x).sci_mantissa_and_exponent();\n        assert_eq!(NiceFloat(m_alt), NiceFloat(m));\n        assert_eq!(e_alt, e);\n    });\n}\n\n#[test]\nfn from_sci_mantissa_and_exponent_properties() {\n    apply_fn_to_primitive_floats!(from_sci_mantissa_and_exponent_properties_helper);\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/serde.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::generators::string_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{rational_gen, string_gen_var_11};\nuse std::str::FromStr;\n\n#[test]\nfn test_serde() {\n    let test = |n, out| {\n        assert_eq!(\n            serde_json::to_string(&Rational::from_str(n).unwrap()).unwrap(),\n            out\n        );\n        assert_eq!(\n            serde_json::from_str::<Rational>(out).unwrap().to_string(),\n            n\n        );\n    };\n    test(\"0\", \"{\\\"s\\\":true,\\\"n\\\":\\\"0x0\\\",\\\"d\\\":\\\"0x1\\\"}\");\n    test(\"100\", \"{\\\"s\\\":true,\\\"n\\\":\\\"0x64\\\",\\\"d\\\":\\\"0x1\\\"}\");\n    test(\n        \"1000000000000\",\n        \"{\\\"s\\\":true,\\\"n\\\":\\\"0xe8d4a51000\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\n        \"1000000000000000000000000\",\n        \"{\\\"s\\\":true,\\\"n\\\":\\\"0xd3c21bcecceda1000000\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\n        \"340282366920938463463374607431768211455\",\n        \"{\\\"s\\\":true,\\\"n\\\":\\\"0xffffffffffffffffffffffffffffffff\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\n        \"340282366920938463463374607431768211456\",\n        \"{\\\"s\\\":true,\\\"n\\\":\\\"0x100000000000000000000000000000000\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\"22/7\", \"{\\\"s\\\":true,\\\"n\\\":\\\"0x16\\\",\\\"d\\\":\\\"0x7\\\"}\");\n    test(\"-100\", \"{\\\"s\\\":false,\\\"n\\\":\\\"0x64\\\",\\\"d\\\":\\\"0x1\\\"}\");\n    test(\n        \"-1000000000000\",\n        \"{\\\"s\\\":false,\\\"n\\\":\\\"0xe8d4a51000\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\n        \"-1000000000000000000000000\",\n        \"{\\\"s\\\":false,\\\"n\\\":\\\"0xd3c21bcecceda1000000\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\n        \"-340282366920938463463374607431768211455\",\n        \"{\\\"s\\\":false,\\\"n\\\":\\\"0xffffffffffffffffffffffffffffffff\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\n        \"-340282366920938463463374607431768211456\",\n        \"{\\\"s\\\":false,\\\"n\\\":\\\"0x100000000000000000000000000000000\\\",\\\"d\\\":\\\"0x1\\\"}\",\n    );\n    test(\"-22/7\", \"{\\\"s\\\":false,\\\"n\\\":\\\"0x16\\\",\\\"d\\\":\\\"0x7\\\"}\");\n}\n\n#[test]\nfn serde_properties() {\n    rational_gen().test_properties(|x| {\n        let s = serde_json::to_string(&x).unwrap();\n        assert_eq!(serde_json::from_str::<Rational>(&s).unwrap(), x);\n        assert!(string_is_subset(&s, \"\\\",-/0123456789:abcdeflnrstux{}\"));\n    });\n\n    string_gen().test_properties(|s| {\n        let _n: Result<Rational, _> = serde_json::from_str(&s);\n    });\n\n    string_gen_var_11().test_properties(|s| {\n        let _n: Rational = serde_json::from_str(&s).unwrap();\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/string/from_sci_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, FloorLogBase};\nuse malachite_base::num::basic::integers::PrimitiveInt;\nuse malachite_base::num::conversion::string::from_sci_string::preprocess_sci_string;\nuse malachite_base::num::conversion::string::options::{FromSciStringOptions, ToSciOptions};\nuse malachite_base::num::conversion::traits::{ExactFrom, FromSciString, ToSci};\nuse malachite_base::test_util::generators::{\n    string_from_sci_string_options_pair_gen_var_2, string_from_sci_string_options_pair_gen_var_3,\n    string_gen_var_14, string_gen_var_15,\n};\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::{\n    rational_gen, rational_gen_var_7, rational_unsigned_pair_gen_var_6,\n};\nuse std::str::FromStr;\n\n#[test]\npub fn test_from_sci_string() {\n    fn test(s: &str, out: Option<&'static str>) {\n        let out = out.map(|s| Rational::from_str(s).unwrap());\n        assert_eq!(Rational::from_sci_string(s), out);\n        assert_eq!(\n            Rational::from_sci_string_with_options(s, FromSciStringOptions::default()),\n            out\n        );\n    }\n    test(\"0\", Some(\"0\"));\n    test(\"00\", Some(\"0\"));\n    test(\"+0\", Some(\"0\"));\n    test(\"-0\", Some(\"0\"));\n    test(\"0.00\", Some(\"0\"));\n    test(\"0e1\", Some(\"0\"));\n    test(\"0e+1\", Some(\"0\"));\n    test(\"0e-1\", Some(\"0\"));\n    test(\"+0e+1\", Some(\"0\"));\n    test(\"-0e+1\", Some(\"0\"));\n    test(\"+0.0e+1\", Some(\"0\"));\n    test(\"-0.0e+1\", Some(\"0\"));\n    test(\".0\", Some(\"0\"));\n    test(\".00\", Some(\"0\"));\n    test(\".00e0\", Some(\"0\"));\n    test(\".00e1\", Some(\"0\"));\n    test(\".00e-1\", Some(\"0\"));\n    test(\"-.0\", Some(\"0\"));\n    test(\"-.00\", Some(\"0\"));\n    test(\"-.00e0\", Some(\"0\"));\n    test(\"-.00e1\", Some(\"0\"));\n    test(\"-.00e-1\", Some(\"0\"));\n    test(\"+.0\", Some(\"0\"));\n    test(\"+.00\", Some(\"0\"));\n    test(\"+.00e0\", Some(\"0\"));\n    test(\"+.00e1\", Some(\"0\"));\n    test(\"+.00e-1\", Some(\"0\"));\n\n    test(\"123\", Some(\"123\"));\n    test(\"00123\", Some(\"123\"));\n    test(\"+123\", Some(\"123\"));\n    test(\"123.00\", Some(\"123\"));\n    test(\"123e0\", Some(\"123\"));\n    test(\"12.3e1\", Some(\"123\"));\n    test(\"1.23e2\", Some(\"123\"));\n    test(\"1.23E2\", Some(\"123\"));\n    test(\"1.23e+2\", Some(\"123\"));\n    test(\"1.23E+2\", Some(\"123\"));\n    test(\".123e3\", Some(\"123\"));\n    test(\"0.123e3\", Some(\"123\"));\n    test(\"+0.123e3\", Some(\"123\"));\n    test(\"0.0123e4\", Some(\"123\"));\n    test(\"1230e-1\", Some(\"123\"));\n    test(\"12300e-2\", Some(\"123\"));\n    test(\"12300E-2\", Some(\"123\"));\n\n    test(\"-123\", Some(\"-123\"));\n    test(\"-00123\", Some(\"-123\"));\n    test(\"-123.00\", Some(\"-123\"));\n    test(\"-123e0\", Some(\"-123\"));\n    test(\"-12.3e1\", Some(\"-123\"));\n    test(\"-1.23e2\", Some(\"-123\"));\n    test(\"-1.23E2\", Some(\"-123\"));\n    test(\"-1.23e+2\", Some(\"-123\"));\n    test(\"-1.23E+2\", Some(\"-123\"));\n    test(\"-.123e3\", Some(\"-123\"));\n    test(\"-0.123e3\", Some(\"-123\"));\n    test(\"-0.0123e4\", Some(\"-123\"));\n    test(\"-1230e-1\", Some(\"-123\"));\n    test(\"-12300e-2\", Some(\"-123\"));\n    test(\"-12300E-2\", Some(\"-123\"));\n\n    test(\"123.4\", Some(\"617/5\"));\n    test(\"123.8\", Some(\"619/5\"));\n    test(\"123.5\", Some(\"247/2\"));\n    test(\"124.5\", Some(\"249/2\"));\n    test(\"127.49\", Some(\"12749/100\"));\n\n    test(\"-123.4\", Some(\"-617/5\"));\n    test(\"-123.8\", Some(\"-619/5\"));\n    test(\"-123.5\", Some(\"-247/2\"));\n    test(\"-124.5\", Some(\"-249/2\"));\n    test(\"-127.49\", Some(\"-12749/100\"));\n    test(\"-127.5\", Some(\"-255/2\"));\n\n    test(\"0.5\", Some(\"1/2\"));\n    test(\n        \"0.3333333333333333\",\n        Some(\"3333333333333333/10000000000000000\"),\n    );\n    test(\"0.25\", Some(\"1/4\"));\n    test(\"0.2\", Some(\"1/5\"));\n    test(\n        \"0.1666666666666667\",\n        Some(\"1666666666666667/10000000000000000\"),\n    );\n    test(\n        \"0.1428571428571429\",\n        Some(\"1428571428571429/10000000000000000\"),\n    );\n    test(\"0.125\", Some(\"1/8\"));\n    test(\n        \"0.1111111111111111\",\n        Some(\"1111111111111111/10000000000000000\"),\n    );\n    test(\"0.1\", Some(\"1/10\"));\n    test(\n        \"0.09090909090909091\",\n        Some(\"9090909090909091/100000000000000000\"),\n    );\n\n    test(\"0.0\", Some(\"0\"));\n    test(\"0.1\", Some(\"1/10\"));\n    test(\"0.2\", Some(\"1/5\"));\n    test(\"0.3\", Some(\"3/10\"));\n    test(\"0.4\", Some(\"2/5\"));\n    test(\"0.5\", Some(\"1/2\"));\n    test(\"0.6\", Some(\"3/5\"));\n    test(\"0.7\", Some(\"7/10\"));\n    test(\"0.8\", Some(\"4/5\"));\n    test(\"0.9\", Some(\"9/10\"));\n\n    test(\"0.00\", Some(\"0\"));\n    test(\"0.10\", Some(\"1/10\"));\n    test(\"0.20\", Some(\"1/5\"));\n    test(\"0.30\", Some(\"3/10\"));\n    test(\"0.40\", Some(\"2/5\"));\n    test(\"0.50\", Some(\"1/2\"));\n    test(\"0.60\", Some(\"3/5\"));\n    test(\"0.70\", Some(\"7/10\"));\n    test(\"0.80\", Some(\"4/5\"));\n    test(\"0.90\", Some(\"9/10\"));\n\n    test(\"123.456456456456\", Some(\"15432057057057/125000000000\"));\n\n    test(\n        \"1.4142135623730951\",\n        Some(\"14142135623730951/10000000000000000\"),\n    );\n    test(\n        \"3.141592653589793\",\n        Some(\"3141592653589793/1000000000000000\"),\n    );\n    test(\"2.718281828459045\", Some(\"543656365691809/200000000000000\"));\n\n    test(\"\", None);\n    test(\"+\", None);\n    test(\"-\", None);\n    test(\"10e\", None);\n    test(\"++1\", None);\n    test(\"1.0.0\", None);\n    test(\"1e++1\", None);\n    test(\"1e0.1\", None);\n    test(\"--.0\", None);\n    test(\"++.0\", None);\n    test(\".+2\", None);\n    test(\".-2\", None);\n    test(\"0.000a\", None);\n    test(\"0.00ae-10\", None);\n    test(\"0e10000000000000000000000000000\", None);\n    test(\"0e-10000000000000000000000000000\", None);\n}\n\n#[test]\npub fn test_from_sci_string_with_options() {\n    fn test(s: &str, options: FromSciStringOptions, out: Option<&str>) {\n        let out = out.map(|s| Rational::from_str(s).unwrap());\n        assert_eq!(Rational::from_sci_string_with_options(s, options), out);\n    }\n    fn test_i<T: PrimitiveInt>(s: &str, options: FromSciStringOptions, out: Option<T>)\n    where\n        Rational: From<T>,\n    {\n        let out = out.map(Rational::from);\n        assert_eq!(Rational::from_sci_string_with_options(s, options), out);\n    }\n    // For tests with the default options, see `test_from_sci_string`\n\n    let mut options = FromSciStringOptions::default();\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(3);\n    test_i(\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(4);\n    test_i(\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(5);\n    test_i(\n        \"11031110441201303134210404233413032443021130230130231310\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(8);\n    test_i(\n        \"3777777777777777777777777777777777777777777\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(16);\n    test_i(\"ffffffffffffffffffffffffffffffff\", options, Some(u128::MAX));\n    options.set_base(32);\n    test_i(\"7vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(u128::MAX));\n    options.set_base(36);\n    test_i(\"f5lxx1zz5pnorynqglhzmsp33\", options, Some(u128::MAX));\n\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(3);\n    test_i(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(4);\n    test_i(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(5);\n    test_i(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-3013030220323124042102424341431241221233040112312340403\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(8);\n    test_i(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(16);\n    test_i(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    test_i(\n        \"-80000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(32);\n    test_i(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    test_i(\"-40000000000000000000000000\", options, Some(i128::MIN));\n    options.set_base(36);\n    test_i(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n    test_i(\"-7ksyyizzkutudzbv8aqztecjk\", options, Some(i128::MIN));\n\n    options.set_base(2);\n    test(\"1e+5\", options, Some(\"32\"));\n    test(\"1e5\", options, Some(\"32\"));\n    options.set_base(3);\n    test(\"1e+5\", options, Some(\"243\"));\n    test(\"1e5\", options, Some(\"243\"));\n    options.set_base(4);\n    test(\"1e+5\", options, Some(\"1024\"));\n    test(\"1e5\", options, Some(\"1024\"));\n    options.set_base(5);\n    test(\"1e+5\", options, Some(\"3125\"));\n    test(\"1e5\", options, Some(\"3125\"));\n    options.set_base(8);\n    test(\"1e+5\", options, Some(\"32768\"));\n    test(\"1e5\", options, Some(\"32768\"));\n    options.set_base(16);\n    test(\"1e+5\", options, Some(\"1048576\"));\n    test(\"1e5\", options, Some(\"485\"));\n    options.set_base(32);\n    test(\"1e+5\", options, Some(\"33554432\"));\n    test(\"1e5\", options, Some(\"1477\"));\n    options.set_base(36);\n    test(\"1e+5\", options, Some(\"60466176\"));\n    test(\"1E+5\", options, Some(\"60466176\"));\n    test(\"1e5\", options, Some(\"1805\"));\n\n    options.set_base(16);\n    test(\"ff\", options, Some(\"255\"));\n    test(\"fF\", options, Some(\"255\"));\n    test(\"Ff\", options, Some(\"255\"));\n    test(\"FF\", options, Some(\"255\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test(\"1.01\", options, Some(\"5/4\"));\n    test(\"1.1\", options, Some(\"3/2\"));\n    test(\"1.11\", options, Some(\"7/4\"));\n    test(\"0.01\", options, Some(\"1/4\"));\n    test(\"0.1\", options, Some(\"1/2\"));\n    test(\"0.11\", options, Some(\"3/4\"));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test(\"1.1\", options, Some(\"4/3\"));\n    test(\"1.11\", options, Some(\"13/9\"));\n    test(\"1.111\", options, Some(\"40/27\"));\n    test(\"1.112\", options, Some(\"41/27\"));\n    test(\"0.1\", options, Some(\"1/3\"));\n    test(\"0.11\", options, Some(\"4/9\"));\n    test(\"0.111\", options, Some(\"13/27\"));\n    test(\"0.112\", options, Some(\"14/27\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test(\"2\", options, None);\n    test(\"102\", options, None);\n    test(\"12e4\", options, None);\n    test(\"12e-4\", options, None);\n    test(\"1.2\", options, None);\n    test(\"0.2\", options, None);\n    test(\"0.002\", options, None);\n\n    options.set_base(2);\n    test(\"-1e+5\", options, Some(\"-32\"));\n    test(\"-1e5\", options, Some(\"-32\"));\n    options.set_base(3);\n    test(\"-1e+5\", options, Some(\"-243\"));\n    test(\"-1e5\", options, Some(\"-243\"));\n    options.set_base(4);\n    test(\"-1e+5\", options, Some(\"-1024\"));\n    test(\"-1e5\", options, Some(\"-1024\"));\n    options.set_base(5);\n    test(\"-1e+5\", options, Some(\"-3125\"));\n    test(\"-1e5\", options, Some(\"-3125\"));\n    options.set_base(8);\n    test(\"-1e+5\", options, Some(\"-32768\"));\n    test(\"-1e5\", options, Some(\"-32768\"));\n    options.set_base(16);\n    test(\"-1e+5\", options, Some(\"-1048576\"));\n    test(\"-1e5\", options, Some(\"-485\"));\n    options.set_base(32);\n    test(\"-1e+5\", options, Some(\"-33554432\"));\n    test(\"-1e5\", options, Some(\"-1477\"));\n    options.set_base(36);\n    test(\"-1e+5\", options, Some(\"-60466176\"));\n    test(\"-1E+5\", options, Some(\"-60466176\"));\n    test(\"-1e5\", options, Some(\"-1805\"));\n\n    options.set_base(16);\n    test(\"-ff\", options, Some(\"-255\"));\n    test(\"-fF\", options, Some(\"-255\"));\n    test(\"-Ff\", options, Some(\"-255\"));\n    test(\"-FF\", options, Some(\"-255\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test(\"-1.01\", options, Some(\"-5/4\"));\n    test(\"-1.1\", options, Some(\"-3/2\"));\n    test(\"-1.11\", options, Some(\"-7/4\"));\n    test(\"-0.01\", options, Some(\"-1/4\"));\n    test(\"-0.1\", options, Some(\"-1/2\"));\n    test(\"-0.11\", options, Some(\"-3/4\"));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test(\"-1.1\", options, Some(\"-4/3\"));\n    test(\"-1.11\", options, Some(\"-13/9\"));\n    test(\"-1.111\", options, Some(\"-40/27\"));\n    test(\"-1.112\", options, Some(\"-41/27\"));\n    test(\"-0.1\", options, Some(\"-1/3\"));\n    test(\"-0.11\", options, Some(\"-4/9\"));\n    test(\"-0.111\", options, Some(\"-13/27\"));\n    test(\"-0.112\", options, Some(\"-14/27\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test(\"-2\", options, None);\n    test(\"-102\", options, None);\n    test(\"-12e4\", options, None);\n    test(\"-12e-4\", options, None);\n    test(\"-1.2\", options, None);\n    test(\"-0.2\", options, None);\n    test(\"-0.002\", options, None);\n\n    test(\"0.1111111111\", options, Some(\"1023/1024\"));\n    options.set_base(3);\n    test(\"0.1111111111\", options, Some(\"29524/59049\"));\n    options.set_base(4);\n    test(\"0.1111111111\", options, Some(\"349525/1048576\"));\n    options.set_base(16);\n    test(\"0.1111111111\", options, Some(\"73300775185/1099511627776\"));\n    options.set_base(32);\n    test(\n        \"0.1111111111\",\n        options,\n        Some(\"36319351833633/1125899906842624\"),\n    );\n    options.set_base(36);\n    test(\n        \"0.1111111111\",\n        options,\n        Some(\"104461669716085/3656158440062976\"),\n    );\n}\n\n#[test]\npub fn test_from_sci_string_simplest() {\n    fn test(s: &str, out: Option<&'static str>) {\n        let out = out.map(|s| Rational::from_str(s).unwrap());\n        assert_eq!(Rational::from_sci_string_simplest(s), out);\n        assert_eq!(\n            Rational::from_sci_string_simplest_with_options(s, FromSciStringOptions::default()),\n            out\n        );\n    }\n    test(\"0\", Some(\"0\"));\n    test(\"00\", Some(\"0\"));\n    test(\"+0\", Some(\"0\"));\n    test(\"-0\", Some(\"0\"));\n    test(\"0.00\", Some(\"0\"));\n    test(\"0e1\", Some(\"0\"));\n    test(\"0e+1\", Some(\"0\"));\n    test(\"0e-1\", Some(\"0\"));\n    test(\"+0e+1\", Some(\"0\"));\n    test(\"-0e+1\", Some(\"0\"));\n    test(\"+0.0e+1\", Some(\"0\"));\n    test(\"-0.0e+1\", Some(\"0\"));\n    test(\".0\", Some(\"0\"));\n    test(\".00\", Some(\"0\"));\n    test(\".00e0\", Some(\"0\"));\n    test(\".00e1\", Some(\"0\"));\n    test(\".00e-1\", Some(\"0\"));\n    test(\"-.0\", Some(\"0\"));\n    test(\"-.00\", Some(\"0\"));\n    test(\"-.00e0\", Some(\"0\"));\n    test(\"-.00e1\", Some(\"0\"));\n    test(\"-.00e-1\", Some(\"0\"));\n    test(\"+.0\", Some(\"0\"));\n    test(\"+.00\", Some(\"0\"));\n    test(\"+.00e0\", Some(\"0\"));\n    test(\"+.00e1\", Some(\"0\"));\n    test(\"+.00e-1\", Some(\"0\"));\n\n    test(\"123\", Some(\"123\"));\n    test(\"00123\", Some(\"123\"));\n    test(\"+123\", Some(\"123\"));\n    test(\"123.00\", Some(\"123\"));\n    test(\"123e0\", Some(\"123\"));\n    test(\"12.3e1\", Some(\"123\"));\n    test(\"1.23e2\", Some(\"123\"));\n    test(\"1.23E2\", Some(\"123\"));\n    test(\"1.23e+2\", Some(\"123\"));\n    test(\"1.23E+2\", Some(\"123\"));\n    test(\".123e3\", Some(\"123\"));\n    test(\"0.123e3\", Some(\"123\"));\n    test(\"+0.123e3\", Some(\"123\"));\n    test(\"0.0123e4\", Some(\"123\"));\n    test(\"1230e-1\", Some(\"123\"));\n    test(\"12300e-2\", Some(\"123\"));\n    test(\"12300E-2\", Some(\"123\"));\n\n    test(\"-123\", Some(\"-123\"));\n    test(\"-00123\", Some(\"-123\"));\n    test(\"-123.00\", Some(\"-123\"));\n    test(\"-123e0\", Some(\"-123\"));\n    test(\"-12.3e1\", Some(\"-123\"));\n    test(\"-1.23e2\", Some(\"-123\"));\n    test(\"-1.23E2\", Some(\"-123\"));\n    test(\"-1.23e+2\", Some(\"-123\"));\n    test(\"-1.23E+2\", Some(\"-123\"));\n    test(\"-.123e3\", Some(\"-123\"));\n    test(\"-0.123e3\", Some(\"-123\"));\n    test(\"-0.0123e4\", Some(\"-123\"));\n    test(\"-1230e-1\", Some(\"-123\"));\n    test(\"-12300e-2\", Some(\"-123\"));\n    test(\"-12300E-2\", Some(\"-123\"));\n\n    test(\"123.4\", Some(\"617/5\"));\n    test(\"123.8\", Some(\"495/4\"));\n    test(\"123.5\", Some(\"247/2\"));\n    test(\"124.5\", Some(\"249/2\"));\n    test(\"127.49\", Some(\"4462/35\"));\n\n    test(\"-123.4\", Some(\"-617/5\"));\n    test(\"-123.8\", Some(\"-495/4\"));\n    test(\"-123.5\", Some(\"-247/2\"));\n    test(\"-124.5\", Some(\"-249/2\"));\n    test(\"-127.49\", Some(\"-4462/35\"));\n    test(\"-127.5\", Some(\"-255/2\"));\n\n    test(\"0.5\", Some(\"1/2\"));\n    test(\"0.3333333333333333\", Some(\"1/3\"));\n    test(\"0.25\", Some(\"1/4\"));\n    test(\"0.2\", Some(\"1/4\"));\n    test(\"0.1666666666666667\", Some(\"1/6\"));\n    test(\"0.1428571428571429\", Some(\"1/7\"));\n    test(\"0.125\", Some(\"1/8\"));\n    test(\"0.1111111111111111\", Some(\"1/9\"));\n    test(\"0.1\", Some(\"1/7\"));\n    test(\"0.09090909090909091\", Some(\"1/11\"));\n\n    test(\"0.0\", Some(\"0\"));\n    test(\"0.1\", Some(\"1/7\"));\n    test(\"0.2\", Some(\"1/4\"));\n    test(\"0.3\", Some(\"1/3\"));\n    test(\"0.4\", Some(\"2/5\"));\n    test(\"0.5\", Some(\"1/2\"));\n    test(\"0.6\", Some(\"3/5\"));\n    test(\"0.7\", Some(\"2/3\"));\n    test(\"0.8\", Some(\"3/4\"));\n    test(\"0.9\", Some(\"6/7\"));\n\n    test(\"0.00\", Some(\"0\"));\n    test(\"0.10\", Some(\"1/10\"));\n    test(\"0.20\", Some(\"1/5\"));\n    test(\"0.30\", Some(\"3/10\"));\n    test(\"0.40\", Some(\"2/5\"));\n    test(\"0.50\", Some(\"1/2\"));\n    test(\"0.60\", Some(\"3/5\"));\n    test(\"0.70\", Some(\"7/10\"));\n    test(\"0.80\", Some(\"4/5\"));\n    test(\"0.90\", Some(\"9/10\"));\n\n    test(\"123.456456456456\", Some(\"41111/333\"));\n\n    test(\"1.4142135623730951\", Some(\"131836323/93222358\"));\n    test(\"3.141592653589793\", Some(\"80143857/25510582\"));\n    test(\"2.718281828459045\", Some(\"212385209/78132152\"));\n\n    test(\"\", None);\n    test(\"+\", None);\n    test(\"-\", None);\n    test(\"10e\", None);\n    test(\"++1\", None);\n    test(\"1.0.0\", None);\n    test(\"1e++1\", None);\n    test(\"1e0.1\", None);\n    test(\"--.0\", None);\n    test(\"++.0\", None);\n    test(\".+2\", None);\n    test(\".-2\", None);\n    test(\"0.000a\", None);\n    test(\"0.00ae-10\", None);\n    test(\"0e10000000000000000000000000000\", None);\n    test(\"0e-10000000000000000000000000000\", None);\n}\n\n#[test]\npub fn test_from_sci_string_simplest_with_options() {\n    fn test(s: &str, options: FromSciStringOptions, out: Option<&str>) {\n        let out = out.map(|s| Rational::from_str(s).unwrap());\n        assert_eq!(\n            Rational::from_sci_string_simplest_with_options(s, options),\n            out\n        );\n    }\n    fn test_i<T: PrimitiveInt>(s: &str, options: FromSciStringOptions, out: Option<T>)\n    where\n        Rational: From<T>,\n    {\n        let out = out.map(Rational::from);\n        assert_eq!(\n            Rational::from_sci_string_simplest_with_options(s, options),\n            out\n        );\n    }\n    // For tests with the default options, see `test_from_sci_string`\n\n    let mut options = FromSciStringOptions::default();\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(3);\n    test_i(\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(4);\n    test_i(\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(5);\n    test_i(\n        \"11031110441201303134210404233413032443021130230130231310\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(8);\n    test_i(\n        \"3777777777777777777777777777777777777777777\",\n        options,\n        Some(u128::MAX),\n    );\n    options.set_base(16);\n    test_i(\"ffffffffffffffffffffffffffffffff\", options, Some(u128::MAX));\n    options.set_base(32);\n    test_i(\"7vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(u128::MAX));\n    options.set_base(36);\n    test_i(\"f5lxx1zz5pnorynqglhzmsp33\", options, Some(u128::MAX));\n\n    options.set_base(2);\n    test_i(\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(3);\n    test_i(\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(4);\n    test_i(\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(5);\n    test_i(\n        \"3013030220323124042102424341431241221233040112312340402\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-3013030220323124042102424341431241221233040112312340403\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(8);\n    test_i(\n        \"1777777777777777777777777777777777777777777\",\n        options,\n        Some(i128::MAX),\n    );\n    test_i(\n        \"-2000000000000000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(16);\n    test_i(\"7fffffffffffffffffffffffffffffff\", options, Some(i128::MAX));\n    test_i(\n        \"-80000000000000000000000000000000\",\n        options,\n        Some(i128::MIN),\n    );\n    options.set_base(32);\n    test_i(\"3vvvvvvvvvvvvvvvvvvvvvvvvv\", options, Some(i128::MAX));\n    test_i(\"-40000000000000000000000000\", options, Some(i128::MIN));\n    options.set_base(36);\n    test_i(\"7ksyyizzkutudzbv8aqztecjj\", options, Some(i128::MAX));\n    test_i(\"-7ksyyizzkutudzbv8aqztecjk\", options, Some(i128::MIN));\n\n    options.set_base(2);\n    test(\"1e+5\", options, Some(\"32\"));\n    test(\"1e5\", options, Some(\"32\"));\n    options.set_base(3);\n    test(\"1e+5\", options, Some(\"243\"));\n    test(\"1e5\", options, Some(\"243\"));\n    options.set_base(4);\n    test(\"1e+5\", options, Some(\"1024\"));\n    test(\"1e5\", options, Some(\"1024\"));\n    options.set_base(5);\n    test(\"1e+5\", options, Some(\"3125\"));\n    test(\"1e5\", options, Some(\"3125\"));\n    options.set_base(8);\n    test(\"1e+5\", options, Some(\"32768\"));\n    test(\"1e5\", options, Some(\"32768\"));\n    options.set_base(16);\n    test(\"1e+5\", options, Some(\"1048576\"));\n    test(\"1e5\", options, Some(\"485\"));\n    options.set_base(32);\n    test(\"1e+5\", options, Some(\"33554432\"));\n    test(\"1e5\", options, Some(\"1477\"));\n    options.set_base(36);\n    test(\"1e+5\", options, Some(\"60466176\"));\n    test(\"1E+5\", options, Some(\"60466176\"));\n    test(\"1e5\", options, Some(\"1805\"));\n\n    options.set_base(16);\n    test(\"ff\", options, Some(\"255\"));\n    test(\"fF\", options, Some(\"255\"));\n    test(\"Ff\", options, Some(\"255\"));\n    test(\"FF\", options, Some(\"255\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test(\"1.01\", options, Some(\"4/3\"));\n    test(\"1.1\", options, Some(\"3/2\"));\n    test(\"1.11\", options, Some(\"5/3\"));\n    test(\"0.01\", options, Some(\"1/3\"));\n    test(\"0.1\", options, Some(\"1/2\"));\n    test(\"0.11\", options, Some(\"2/3\"));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test(\"1.1\", options, Some(\"3/2\"));\n    test(\"1.11\", options, Some(\"3/2\"));\n    test(\"1.111\", options, Some(\"3/2\"));\n    test(\"1.112\", options, Some(\"3/2\"));\n    test(\"0.1\", options, Some(\"1/2\"));\n    test(\"0.11\", options, Some(\"1/2\"));\n    test(\"0.111\", options, Some(\"1/2\"));\n    test(\"0.112\", options, Some(\"1/2\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test(\"2\", options, None);\n    test(\"102\", options, None);\n    test(\"12e4\", options, None);\n    test(\"12e-4\", options, None);\n    test(\"1.2\", options, None);\n    test(\"0.2\", options, None);\n    test(\"0.002\", options, None);\n\n    options.set_base(2);\n    test(\"-1e+5\", options, Some(\"-32\"));\n    test(\"-1e5\", options, Some(\"-32\"));\n    options.set_base(3);\n    test(\"-1e+5\", options, Some(\"-243\"));\n    test(\"-1e5\", options, Some(\"-243\"));\n    options.set_base(4);\n    test(\"-1e+5\", options, Some(\"-1024\"));\n    test(\"-1e5\", options, Some(\"-1024\"));\n    options.set_base(5);\n    test(\"-1e+5\", options, Some(\"-3125\"));\n    test(\"-1e5\", options, Some(\"-3125\"));\n    options.set_base(8);\n    test(\"-1e+5\", options, Some(\"-32768\"));\n    test(\"-1e5\", options, Some(\"-32768\"));\n    options.set_base(16);\n    test(\"-1e+5\", options, Some(\"-1048576\"));\n    test(\"-1e5\", options, Some(\"-485\"));\n    options.set_base(32);\n    test(\"-1e+5\", options, Some(\"-33554432\"));\n    test(\"-1e5\", options, Some(\"-1477\"));\n    options.set_base(36);\n    test(\"-1e+5\", options, Some(\"-60466176\"));\n    test(\"-1E+5\", options, Some(\"-60466176\"));\n    test(\"-1e5\", options, Some(\"-1805\"));\n\n    options.set_base(16);\n    test(\"-ff\", options, Some(\"-255\"));\n    test(\"-fF\", options, Some(\"-255\"));\n    test(\"-Ff\", options, Some(\"-255\"));\n    test(\"-FF\", options, Some(\"-255\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    // 1/2 is 0.1\n    test(\"-1.01\", options, Some(\"-4/3\"));\n    test(\"-1.1\", options, Some(\"-3/2\"));\n    test(\"-1.11\", options, Some(\"-5/3\"));\n    test(\"-0.01\", options, Some(\"-1/3\"));\n    test(\"-0.1\", options, Some(\"-1/2\"));\n    test(\"-0.11\", options, Some(\"-2/3\"));\n    options.set_base(3);\n    // 1/2 is 0.111...\n    test(\"-1.1\", options, Some(\"-3/2\"));\n    test(\"-1.11\", options, Some(\"-3/2\"));\n    test(\"-1.111\", options, Some(\"-3/2\"));\n    test(\"-1.112\", options, Some(\"-3/2\"));\n    test(\"-0.1\", options, Some(\"-1/2\"));\n    test(\"-0.11\", options, Some(\"-1/2\"));\n    test(\"-0.111\", options, Some(\"-1/2\"));\n    test(\"-0.112\", options, Some(\"-1/2\"));\n\n    options = FromSciStringOptions::default();\n    options.set_base(2);\n    test(\"-2\", options, None);\n    test(\"-102\", options, None);\n    test(\"-12e4\", options, None);\n    test(\"-12e-4\", options, None);\n    test(\"-1.2\", options, None);\n    test(\"-0.2\", options, None);\n    test(\"-0.002\", options, None);\n\n    test(\"0.1111111111\", options, Some(\"682/683\"));\n    options.set_base(3);\n    test(\"0.1111111111\", options, Some(\"1/2\"));\n    options.set_base(4);\n    test(\"0.1111111111\", options, Some(\"1/3\"));\n    options.set_base(16);\n    test(\"0.1111111111\", options, Some(\"1/15\"));\n    options.set_base(32);\n    test(\"0.1111111111\", options, Some(\"1/31\"));\n    options.set_base(36);\n    test(\"0.1111111111\", options, Some(\"1/35\"));\n}\n\nfn from_sci_string_helper(s: &str) {\n    if let Some(x) = Rational::from_sci_string(s) {\n        assert!(x.is_valid());\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 2);\n        let mut to_options = ToSciOptions::default();\n        to_options.set_size_complete();\n        let s_alt = x.to_sci_with_options(to_options).to_string();\n        assert_eq!(Rational::from_sci_string(&s_alt).unwrap(), x);\n    }\n}\n\n#[test]\nfn from_sci_string_properties() {\n    string_gen_var_14().test_properties(|s| {\n        from_sci_string_helper(&s);\n    });\n\n    string_gen_var_15().test_properties(|s| {\n        from_sci_string_helper(&s);\n    });\n}\n\nfn from_sci_string_with_options_helper(s: &str, options: FromSciStringOptions) {\n    if let Some(x) = Rational::from_sci_string_with_options(s, options) {\n        assert!(x.is_valid());\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 2);\n        let mut to_options = ToSciOptions::default();\n        to_options.set_base(options.get_base());\n        to_options.set_size_complete();\n        let s_alt = x.to_sci_with_options(to_options).to_string();\n        assert_eq!(\n            Rational::from_sci_string_with_options(&s_alt, options).unwrap(),\n            x\n        );\n    }\n}\n\n#[test]\nfn from_sci_string_with_options_properties() {\n    string_from_sci_string_options_pair_gen_var_2().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper(&s, options);\n    });\n\n    string_from_sci_string_options_pair_gen_var_3().test_properties(|(s, options)| {\n        from_sci_string_with_options_helper(&s, options);\n    });\n\n    let mut options = ToSciOptions::default();\n    options.set_size_complete();\n    rational_gen().test_properties(|x| {\n        if x.fmt_sci_valid(options) {\n            assert_eq!(\n                Rational::from_sci_string(&x.to_sci_with_options(options).to_string()).unwrap(),\n                x\n            );\n        }\n    });\n}\n\nfn string_precision(s: &str, base: u8) -> u64 {\n    let mut options = FromSciStringOptions::default();\n    options.set_base(base);\n    let mut s = preprocess_sci_string(s, options).unwrap().0;\n    if s[0] == b'+' || s[0] == b'-' {\n        s.remove(0);\n    }\n    let mut leading_zeros = 0;\n    for &c in &s {\n        if c != b'0' {\n            break;\n        }\n        leading_zeros += 1;\n    }\n    u64::exact_from(s.len()) - leading_zeros\n}\n\nfn from_sci_string_simplest_helper(s: &str) {\n    let mut from_options = FromSciStringOptions::default();\n    from_options.set_base(10);\n    if let Some(x) = Rational::from_sci_string_simplest(s) {\n        assert!(x.is_valid());\n        if x != 0u32 {\n            let mut options = ToSciOptions::default();\n            let precision = string_precision(s, 10);\n            options.set_precision(precision);\n            let s_alt = x.to_sci_with_options(options).to_string();\n            let x_1 = Rational::from_sci_string_with_options(s, from_options).unwrap();\n            let x_2 = Rational::from_sci_string_with_options(&s_alt, from_options).unwrap();\n            // Usually x_1 == x_2. However...\n            if x_1 != x_2 {\n                let diff_1 = x_1 - &x;\n                let diff_2 = x_2 - &x;\n                assert_eq!(diff_1, -diff_2);\n                let scale = u64::exact_from(\n                    i64::exact_from(precision) - x.abs().floor_log_base(&Rational::from(10)) - 1,\n                );\n                let mut options_2 = ToSciOptions::default();\n                options_2.set_scale(scale);\n                assert_eq!(diff_1.abs().to_sci_with_options(options_2).to_string(), \"0\");\n            }\n        }\n    }\n}\n\n#[test]\nfn from_sci_string_simplest_properties() {\n    string_gen_var_14().test_properties(|s| {\n        from_sci_string_simplest_helper(&s);\n    });\n\n    string_gen_var_15().test_properties(|s| {\n        from_sci_string_simplest_helper(&s);\n    });\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    rational_gen_var_7().test_properties(|q| {\n        assert_eq!(\n            Rational::from_sci_string_simplest(&q.to_sci_with_options(options).to_string())\n                .unwrap(),\n            q\n        );\n    });\n}\n\nfn from_sci_string_simplest_with_options_helper(s: &str, options: FromSciStringOptions) {\n    if let Some(x) = Rational::from_sci_string_simplest_with_options(s, options) {\n        assert!(x.is_valid());\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 2);\n        if x != 0u32 {\n            let base = options.get_base();\n            let mut to_options = ToSciOptions::default();\n            to_options.set_base(base);\n            let precision = string_precision(s, base);\n            to_options.set_precision(precision);\n            let mut from_options = FromSciStringOptions::default();\n            from_options.set_base(base);\n            let s_alt = x.to_sci_with_options(to_options).to_string();\n            let x_1 = Rational::from_sci_string_with_options(s, from_options).unwrap();\n            let x_2 = Rational::from_sci_string_with_options(&s_alt, from_options).unwrap();\n            // Usually x_1 == x_2. However...\n            if x_1 != x_2 {\n                let diff_1 = x_1 - &x;\n                let diff_2 = x_2 - &x;\n                assert_eq!(diff_1, -diff_2);\n                let scale = u64::exact_from(\n                    i64::exact_from(precision) - x.abs().floor_log_base(&Rational::from(base)) - 1,\n                );\n                let mut options_2 = ToSciOptions::default();\n                options_2.set_base(base);\n                options_2.set_scale(scale);\n                assert_eq!(diff_1.abs().to_sci_with_options(options_2).to_string(), \"0\");\n            }\n        }\n    }\n}\n\n#[test]\nfn from_sci_string_simplest_with_options_properties() {\n    string_from_sci_string_options_pair_gen_var_2().test_properties(|(s, options)| {\n        from_sci_string_simplest_with_options_helper(&s, options);\n    });\n\n    string_from_sci_string_options_pair_gen_var_3().test_properties(|(s, options)| {\n        from_sci_string_simplest_with_options_helper(&s, options);\n    });\n\n    // This fails for rationals with sufficiently large numerator and denominator\n    rational_unsigned_pair_gen_var_6().test_properties(|(q, base)| {\n        let mut to_options = ToSciOptions::default();\n        to_options.set_include_trailing_zeros(true);\n        to_options.set_base(base);\n        let mut from_options = FromSciStringOptions::default();\n        from_options.set_base(base);\n        assert_eq!(\n            Rational::from_sci_string_simplest_with_options(\n                &q.to_sci_with_options(to_options).to_string(),\n                from_options\n            )\n            .unwrap(),\n            q\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/string/from_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::test_util::generators::common::GenConfig;\nuse malachite_base::test_util::generators::string_gen;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::string_gen_var_12;\nuse num::BigRational;\nuse std::str::FromStr;\n\n#[test]\nfn test_from_str() {\n    let test_ok = |s, n| {\n        assert_eq!(Rational::from_str(s).unwrap().to_string(), n);\n        assert_eq!(BigRational::from_str(s).unwrap().to_string(), n);\n        assert_eq!(rug::Rational::from_str(s).unwrap().to_string(), n);\n    };\n    test_ok(\"0\", \"0\");\n    test_ok(\"-0\", \"0\");\n    test_ok(\"123456\", \"123456\");\n    test_ok(\"1000000000000000000000000\", \"1000000000000000000000000\");\n    test_ok(\"-123456\", \"-123456\");\n    test_ok(\"-1000000000000000000000000\", \"-1000000000000000000000000\");\n    test_ok(\"01/02\", \"1/2\");\n    test_ok(\"3/21\", \"1/7\");\n\n    let test_err = |s, rug_err| {\n        assert!(Rational::from_str(s).is_err());\n        assert!(BigRational::from_str(s).is_err());\n        let rn = rug::Rational::from_str(s);\n        assert_eq!(rn.is_err() || rn.unwrap() < 0, rug_err);\n    };\n    test_err(\"12A\", true);\n    test_err(\" 10\", false);\n    test_err(\"1.0\", true);\n    test_err(\"$%^\", true);\n    test_err(\"\", true);\n    test_err(\"-\", true);\n    test_err(\"1/0\", true);\n    test_err(\"/1\", true);\n    test_err(\"--0\", true);\n    test_err(\"-+0\", true);\n    test_err(\"+-0\", true);\n    test_err(\"++0\", true);\n    test_err(\"--1\", true);\n    test_err(\"-+1\", true);\n    test_err(\"+-1\", true);\n    test_err(\"++1\", true);\n}\n\n#[allow(unused_must_use)]\n#[test]\nfn from_str_properties() {\n    let mut config = GenConfig::new();\n    config.insert(\"mean_length_n\", 64);\n    string_gen().test_properties_with_config(&config, |s| {\n        Rational::from_str(&s);\n    });\n\n    string_gen_var_12().test_properties(|s| {\n        let n = Rational::from_str(&s).unwrap();\n        assert_eq!(BigRational::from_str(&s).unwrap(), BigRational::from(&n));\n        assert_eq!(\n            rug::Rational::from_str(&s).unwrap(),\n            rug::Rational::from(&n)\n        );\n    });\n\n    integer_gen().test_properties(|x| {\n        let s = x.to_string();\n        assert_eq!(\n            Rational::from_str(&s).unwrap(),\n            Integer::from_str(&s).unwrap()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/string/to_sci.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, FloorLogBase, Pow, PowerOf2, RoundToMultiple};\nuse malachite_base::num::basic::floats::PrimitiveFloat;\nuse malachite_base::num::conversion::string::options::{\n    FromSciStringOptions, SciSizeOptions, ToSciOptions,\n};\nuse malachite_base::num::conversion::traits::{ExactFrom, FromSciString, ToSci};\nuse malachite_base::rounding_modes::RoundingMode::*;\nuse malachite_base::strings::string_is_subset;\nuse malachite_base::test_util::num::conversion::string::from_sci_string::DECIMAL_SCI_STRING_CHARS;\nuse malachite_nz::test_util::generators::{integer_gen, integer_to_sci_options_pair_gen_var_1};\nuse malachite_q::Rational;\nuse malachite_q::conversion::string::to_sci::floor_log_base_of_abs;\nuse malachite_q::test_util::generators::{rational_gen, rational_to_sci_options_pair_gen_var_1};\nuse std::collections::HashMap;\nuse std::str::FromStr;\n\n#[test]\npub fn test_to_sci() {\n    assert_eq!(\n        Rational::power_of_2(1000000u64).to_sci().to_string(),\n        \"9.900656229295898e301029\"\n    );\n    assert_eq!(\n        (-Rational::power_of_2(1000000u64)).to_sci().to_string(),\n        \"-9.900656229295898e301029\"\n    );\n    assert_eq!(\n        Rational::power_of_2(-1000000i64).to_sci().to_string(),\n        \"1.01003405919803e-301030\"\n    );\n    assert_eq!(\n        (-Rational::power_of_2(-1000000i64)).to_sci().to_string(),\n        \"-1.01003405919803e-301030\"\n    );\n\n    fn test(s: &str, out: &str) {\n        let x = Rational::from_str(s).unwrap();\n        assert_eq!(x.to_sci().to_string(), out);\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            out\n        );\n    }\n    test(\"1/2\", \"0.5\");\n    test(\"1/3\", \"0.3333333333333333\");\n    test(\"1/4\", \"0.25\");\n    test(\"1/5\", \"0.2\");\n    test(\"1/6\", \"0.1666666666666667\");\n    test(\"1/7\", \"0.1428571428571429\");\n    test(\"1/8\", \"0.125\");\n    test(\"1/9\", \"0.1111111111111111\");\n    test(\"1/10\", \"0.1\");\n    // Still 16 significant digits\n    test(\"1/11\", \"0.09090909090909091\");\n\n    test(\"1/137\", \"0.007299270072992701\");\n    test(\"22/7\", \"3.142857142857143\");\n    test(\"245850922/78256779\", \"3.141592653589793\");\n    test(\"936851431250/1397\", \"670616629.3843951\");\n    test(\"1/123456789\", \"8.100000073710001e-9\");\n\n    test(\"0\", \"0\");\n    test(\"1\", \"1\");\n    test(\"10\", \"10\");\n    test(\"100\", \"100\");\n    test(\"1000\", \"1000\");\n    test(\"10000\", \"10000\");\n    test(\"100000\", \"100000\");\n    test(\"1000000\", \"1000000\");\n    test(\"10000000\", \"10000000\");\n    test(\"100000000\", \"100000000\");\n    test(\"1000000000\", \"1000000000\");\n    test(\"10000000000\", \"10000000000\");\n    test(\"100000000000\", \"100000000000\");\n    test(\"1000000000000\", \"1000000000000\");\n    test(\"10000000000000\", \"10000000000000\");\n    test(\"100000000000000\", \"100000000000000\");\n    test(\"1000000000000000\", \"1000000000000000\");\n    test(\"10000000000000000\", \"1e16\");\n    test(\"100000000000000000\", \"1e17\");\n    test(\"1/10\", \"0.1\");\n    test(\"1/100\", \"0.01\");\n    test(\"1/1000\", \"0.001\");\n    test(\"1/10000\", \"0.0001\");\n    test(\"1/100000\", \"0.00001\");\n    test(\"1/1000000\", \"1e-6\");\n    test(\"1/10000000\", \"1e-7\");\n    test(\"1/100000000\", \"1e-8\");\n\n    test(\"999999999999999\", \"999999999999999\");\n    test(\"9999999999999999\", \"9999999999999999\");\n    test(\"99999999999999999\", \"1e17\");\n    test(\"999999999999999999\", \"1e18\");\n\n    test(\"-1\", \"-1\");\n    test(\"-10\", \"-10\");\n    test(\"-100\", \"-100\");\n    test(\"-1000\", \"-1000\");\n    test(\"-10000\", \"-10000\");\n    test(\"-100000\", \"-100000\");\n    test(\"-1000000\", \"-1000000\");\n    test(\"-10000000\", \"-10000000\");\n    test(\"-100000000\", \"-100000000\");\n    test(\"-1000000000\", \"-1000000000\");\n    test(\"-10000000000\", \"-10000000000\");\n    test(\"-100000000000\", \"-100000000000\");\n    test(\"-1000000000000\", \"-1000000000000\");\n    test(\"-10000000000000\", \"-10000000000000\");\n    test(\"-100000000000000\", \"-100000000000000\");\n    test(\"-1000000000000000\", \"-1000000000000000\");\n    test(\"-10000000000000000\", \"-1e16\");\n    test(\"-100000000000000000\", \"-1e17\");\n    test(\"-1/10\", \"-0.1\");\n    test(\"-1/100\", \"-0.01\");\n    test(\"-1/1000\", \"-0.001\");\n    test(\"-1/10000\", \"-0.0001\");\n    test(\"-1/100000\", \"-0.00001\");\n    test(\"-1/1000000\", \"-1e-6\");\n    test(\"-1/10000000\", \"-1e-7\");\n    test(\"-1/100000000\", \"-1e-8\");\n}\n\n#[test]\npub fn test_to_sci_with_options() {\n    fn test_i(x: &Rational, options: ToSciOptions, out: &str) {\n        assert_eq!(x.to_sci_with_options(options).to_string(), out);\n    }\n    fn test(s: &str, options: ToSciOptions, out: &str) {\n        test_i(&Rational::from_str(s).unwrap(), options, out);\n    }\n    // For tests with the default options, see `test_to_sci`\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.000000000000000\");\n    test(\"1\", options, \"1.000000000000000\");\n    test(\"10\", options, \"10.00000000000000\");\n    test(\"100\", options, \"100.0000000000000\");\n    test(\"1000\", options, \"1000.000000000000\");\n    test(\"10000\", options, \"10000.00000000000\");\n    test(\"100000\", options, \"100000.0000000000\");\n    test(\"1000000\", options, \"1000000.000000000\");\n    test(\"10000000\", options, \"10000000.00000000\");\n    test(\"100000000\", options, \"100000000.0000000\");\n    test(\"1000000000\", options, \"1000000000.000000\");\n    test(\"10000000000\", options, \"10000000000.00000\");\n    test(\"100000000000\", options, \"100000000000.0000\");\n    test(\"1000000000000\", options, \"1000000000000.000\");\n    test(\"10000000000000\", options, \"10000000000000.00\");\n    test(\"100000000000000\", options, \"100000000000000.0\");\n    test(\"1000000000000000\", options, \"1000000000000000\");\n    test(\"10000000000000000\", options, \"1.000000000000000e16\");\n    test(\"100000000000000000\", options, \"1.000000000000000e17\");\n    test_i(&Rational::from(u64::MAX), options, \"1.844674407370955e19\");\n    test_i(&Rational::from(u128::MAX), options, \"3.402823669209385e38\");\n\n    test(\"999999999999999\", options, \"999999999999999.0\");\n    test(\"9999999999999999\", options, \"9999999999999999\");\n    test(\"99999999999999999\", options, \"1.000000000000000e17\");\n    test(\"999999999999999999\", options, \"1.000000000000000e18\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test_i(&Rational::from(u128::MAX), options, \"1e128\");\n    options.set_base(3);\n    test_i(&Rational::from(u128::MAX), options, \"2.022011021210021e80\");\n    options.set_base(4);\n    test_i(&Rational::from(u128::MAX), options, \"1e64\");\n    options.set_base(5);\n    test_i(&Rational::from(u128::MAX), options, \"1.103111044120131e55\");\n    options.set_base(8);\n    test_i(&Rational::from(u128::MAX), options, \"4e42\");\n    // When base >= 15, there is a mandatory sign after the exponent indicator \"e\", to distinguish\n    // it from the digit \"e\"\n    options.set_base(16);\n    test_i(&Rational::from(u128::MAX), options, \"1e+32\");\n    options.set_base(32);\n    test_i(&Rational::from(u128::MAX), options, \"8e+25\");\n    options.set_base(36);\n    test_i(&Rational::from(u128::MAX), options, \"f.5lxx1zz5pnorynqe+24\");\n\n    // The sign can be forced in other cases too\n    options.set_base(3);\n    options.set_force_exponent_plus_sign(true);\n    test_i(&Rational::from(u128::MAX), options, \"2.022011021210021e+80\");\n\n    // The digits can be uppercase, and so can the exponent indicator\n    options = ToSciOptions::default();\n    options.set_base(36);\n    options.set_uppercase();\n    test_i(&Rational::from(u128::MAX), options, \"F.5LXX1ZZ5PNORYNQe+24\");\n\n    options.set_lowercase();\n    options.set_e_uppercase();\n    test_i(&Rational::from(u128::MAX), options, \"f.5lxx1zz5pnorynqE+24\");\n\n    options.set_uppercase();\n    test_i(&Rational::from(u128::MAX), options, \"F.5LXX1ZZ5PNORYNQE+24\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    options.set_base(2);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        111111111111111111111111111111111111111\",\n    );\n    options.set_base(3);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"202201102121002021012000211012011021221022212021111001022110211020010021100121010\",\n    );\n    options.set_base(4);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"3333333333333333333333333333333333333333333333333333333333333333\",\n    );\n    options.set_base(5);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"11031110441201303134210404233413032443021130230130231310\",\n    );\n    options.set_base(8);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"3777777777777777777777777777777777777777777\",\n    );\n    options.set_base(16);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"ffffffffffffffffffffffffffffffff\",\n    );\n    options.set_base(32);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"7vvvvvvvvvvvvvvvvvvvvvvvvv\",\n    );\n    options.set_base(36);\n    test_i(\n        &Rational::from(u128::MAX),\n        options,\n        \"f5lxx1zz5pnorynqglhzmsp33\",\n    );\n\n    options = ToSciOptions::default();\n    options.set_precision(4);\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.000\");\n    test(\"1\", options, \"1.000\");\n    test(\"10\", options, \"10.00\");\n    test(\"100\", options, \"100.0\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"1.000e4\");\n    test(\"9\", options, \"9.000\");\n    test(\"99\", options, \"99.00\");\n    test(\"999\", options, \"999.0\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"1.000e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_precision(1);\n    options.set_include_trailing_zeros(true); // doesn't matter when precision is 1\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"1e1\");\n    test(\"100\", options, \"1e2\");\n    test(\"1000\", options, \"1e3\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"1e2\");\n    test(\"999\", options, \"1e3\");\n    test(\"9999\", options, \"1e4\");\n    test(\"99999\", options, \"1e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"1e1\");\n    test(\"100\", options, \"1e2\");\n    test(\"1000\", options, \"1e3\");\n    test(\"10000\", options, \"1e4\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"1e2\");\n    test(\"999\", options, \"1e3\");\n    test(\"9999\", options, \"1e4\");\n    test(\"99999\", options, \"1e5\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    options.set_include_trailing_zeros(true);\n    test(\"0\", options, \"0.00\");\n    test(\"1\", options, \"1.00\");\n    test(\"10\", options, \"10.00\");\n    test(\"100\", options, \"100.00\");\n    test(\"1000\", options, \"1000.00\");\n    test(\"10000\", options, \"10000.00\");\n    test(\"9\", options, \"9.00\");\n    test(\"99\", options, \"99.00\");\n    test(\"999\", options, \"999.00\");\n    test(\"9999\", options, \"9999.00\");\n    test(\"99999\", options, \"99999.00\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_scale(0);\n    options.set_include_trailing_zeros(true); // doesn't matter when scale is 0\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"0\", options, \"0\");\n    test(\"1\", options, \"1\");\n    test(\"10\", options, \"10\");\n    test(\"100\", options, \"100\");\n    test(\"1000\", options, \"1000\");\n    test(\"10000\", options, \"10000\");\n    test(\"9\", options, \"9\");\n    test(\"99\", options, \"99\");\n    test(\"999\", options, \"999\");\n    test(\"9999\", options, \"9999\");\n    test(\"99999\", options, \"99999\");\n\n    options = ToSciOptions::default();\n    options.set_precision(2);\n    options.set_rounding_mode(Nearest); // This is the default\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Down);\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Floor);\n    test(\"123\", options, \"1.2e2\");\n    options.set_rounding_mode(Up);\n    test(\"123\", options, \"1.3e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"123\", options, \"1.3e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"135\", options, \"1.4e2\");\n    options.set_rounding_mode(Down);\n    test(\"135\", options, \"1.3e2\");\n    options.set_rounding_mode(Floor);\n    test(\"135\", options, \"1.3e2\");\n    options.set_rounding_mode(Up);\n    test(\"135\", options, \"1.4e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"135\", options, \"1.4e2\");\n\n    options.set_rounding_mode(Exact);\n    test(\"140\", options, \"1.4e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"999\", options, \"1e3\");\n    options.set_rounding_mode(Down);\n    test(\"999\", options, \"9.9e2\");\n    options.set_rounding_mode(Floor);\n    test(\"999\", options, \"9.9e2\");\n    options.set_rounding_mode(Up);\n    test(\"999\", options, \"1e3\");\n    options.set_rounding_mode(Ceiling);\n    test(\"999\", options, \"1e3\");\n\n    let mut options = ToSciOptions::default();\n    options.set_include_trailing_zeros(true);\n    test_i(&Rational::from(i64::MAX), options, \"9.223372036854776e18\");\n    test_i(&Rational::from(i128::MAX), options, \"1.701411834604692e38\");\n    test(\"-1\", options, \"-1.000000000000000\");\n    test(\"-10\", options, \"-10.00000000000000\");\n    test(\"-100\", options, \"-100.0000000000000\");\n    test(\"-1000\", options, \"-1000.000000000000\");\n    test(\"-10000\", options, \"-10000.00000000000\");\n    test(\"-100000\", options, \"-100000.0000000000\");\n    test(\"-1000000\", options, \"-1000000.000000000\");\n    test(\"-10000000\", options, \"-10000000.00000000\");\n    test(\"-100000000\", options, \"-100000000.0000000\");\n    test(\"-1000000000\", options, \"-1000000000.000000\");\n    test(\"-10000000000\", options, \"-10000000000.00000\");\n    test(\"-100000000000\", options, \"-100000000000.0000\");\n    test(\"-1000000000000\", options, \"-1000000000000.000\");\n    test(\"-10000000000000\", options, \"-10000000000000.00\");\n    test(\"-100000000000000\", options, \"-100000000000000.0\");\n    test(\"-1000000000000000\", options, \"-1000000000000000\");\n    test(\"-10000000000000000\", options, \"-1.000000000000000e16\");\n    test(\"-100000000000000000\", options, \"-1.000000000000000e17\");\n    test_i(&Rational::from(i64::MIN), options, \"-9.223372036854776e18\");\n    test_i(&Rational::from(i128::MIN), options, \"-1.701411834604692e38\");\n\n    test(\"-999999999999999\", options, \"-999999999999999.0\");\n    test(\"-9999999999999999\", options, \"-9999999999999999\");\n    test(\"-99999999999999999\", options, \"-1.000000000000000e17\");\n    test(\"-999999999999999999\", options, \"-1.000000000000000e18\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test_i(&Rational::from(i128::MAX), options, \"1e127\");\n    test_i(&Rational::from(i128::MIN), options, \"-1e127\");\n    options.set_base(3);\n    test_i(&Rational::from(i128::MAX), options, \"1.01100201022001e80\");\n    test_i(&Rational::from(i128::MIN), options, \"-1.01100201022001e80\");\n    options.set_base(4);\n    test_i(&Rational::from(i128::MAX), options, \"2e63\");\n    test_i(&Rational::from(i128::MIN), options, \"-2e63\");\n    options.set_base(5);\n    test_i(&Rational::from(i128::MAX), options, \"3.013030220323124e54\");\n    test_i(&Rational::from(i128::MIN), options, \"-3.013030220323124e54\");\n    options.set_base(8);\n    test_i(&Rational::from(i128::MAX), options, \"2e42\");\n    test_i(&Rational::from(i128::MIN), options, \"-2e42\");\n    // When base >= 15, there is a mandatory sign after the exponent indicator \"e\", to distinguish\n    // it from the digit \"e\"\n    options.set_base(16);\n    test_i(&Rational::from(i128::MAX), options, \"8e+31\");\n    test_i(&Rational::from(i128::MIN), options, \"-8e+31\");\n    options.set_base(32);\n    test_i(&Rational::from(i128::MAX), options, \"4e+25\");\n    test_i(&Rational::from(i128::MIN), options, \"-4e+25\");\n    options.set_base(36);\n    test_i(&Rational::from(i128::MAX), options, \"7.ksyyizzkutudzbve+24\");\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-7.ksyyizzkutudzbve+24\",\n    );\n\n    // The sign can be forced in other cases too\n    options.set_base(3);\n    options.set_force_exponent_plus_sign(true);\n    test_i(&Rational::from(i128::MAX), options, \"1.01100201022001e+80\");\n    test_i(&Rational::from(i128::MIN), options, \"-1.01100201022001e+80\");\n\n    // The digits can be uppercase, and so can the exponent indicator\n    options = ToSciOptions::default();\n    options.set_base(36);\n    options.set_uppercase();\n    test_i(&Rational::from(i128::MAX), options, \"7.KSYYIZZKUTUDZBVe+24\");\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-7.KSYYIZZKUTUDZBVe+24\",\n    );\n\n    options.set_lowercase();\n    options.set_e_uppercase();\n    test_i(&Rational::from(i128::MAX), options, \"7.ksyyizzkutudzbvE+24\");\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-7.ksyyizzkutudzbvE+24\",\n    );\n\n    options.set_uppercase();\n    test_i(&Rational::from(i128::MAX), options, \"7.KSYYIZZKUTUDZBVE+24\");\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-7.KSYYIZZKUTUDZBVE+24\",\n    );\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    options.set_base(2);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\\n        11111111111111111111111111111111111111\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\\n        0000000000000000000000000000000000000000\",\n    );\n    options.set_base(3);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"101100201022001010121000102002120122110122221010202000122201220121120010200022001\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-101100201022001010121000102002120122110122221010202000122201220121120010200022002\",\n    );\n    options.set_base(4);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"1333333333333333333333333333333333333333333333333333333333333333\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-2000000000000000000000000000000000000000000000000000000000000000\",\n    );\n    options.set_base(5);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"3013030220323124042102424341431241221233040112312340402\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-3013030220323124042102424341431241221233040112312340403\",\n    );\n    options.set_base(8);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"1777777777777777777777777777777777777777777\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-2000000000000000000000000000000000000000000\",\n    );\n    options.set_base(16);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"7fffffffffffffffffffffffffffffff\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-80000000000000000000000000000000\",\n    );\n    options.set_base(32);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"3vvvvvvvvvvvvvvvvvvvvvvvvv\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-40000000000000000000000000\",\n    );\n    options.set_base(36);\n    test_i(\n        &Rational::from(i128::MAX),\n        options,\n        \"7ksyyizzkutudzbv8aqztecjj\",\n    );\n    test_i(\n        &Rational::from(i128::MIN),\n        options,\n        \"-7ksyyizzkutudzbv8aqztecjk\",\n    );\n\n    options = ToSciOptions::default();\n    options.set_precision(4);\n    options.set_include_trailing_zeros(true);\n    test(\"-1\", options, \"-1.000\");\n    test(\"-10\", options, \"-10.00\");\n    test(\"-100\", options, \"-100.0\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-1.000e4\");\n    test(\"-9\", options, \"-9.000\");\n    test(\"-99\", options, \"-99.00\");\n    test(\"-999\", options, \"-999.0\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-1.000e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-1e4\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-1e5\");\n\n    options = ToSciOptions::default();\n    options.set_precision(1);\n    options.set_include_trailing_zeros(true); // doesn't matter when precision is 1\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-1e1\");\n    test(\"-100\", options, \"-1e2\");\n    test(\"-1000\", options, \"-1e3\");\n    test(\"-10000\", options, \"-1e4\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-1e2\");\n    test(\"-999\", options, \"-1e3\");\n    test(\"-9999\", options, \"-1e4\");\n    test(\"-99999\", options, \"-1e5\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-1e1\");\n    test(\"-100\", options, \"-1e2\");\n    test(\"-1000\", options, \"-1e3\");\n    test(\"-10000\", options, \"-1e4\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-1e2\");\n    test(\"-999\", options, \"-1e3\");\n    test(\"-9999\", options, \"-1e4\");\n    test(\"-99999\", options, \"-1e5\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    options.set_include_trailing_zeros(true);\n    test(\"-1\", options, \"-1.00\");\n    test(\"-10\", options, \"-10.00\");\n    test(\"-100\", options, \"-100.00\");\n    test(\"-1000\", options, \"-1000.00\");\n    test(\"-10000\", options, \"-10000.00\");\n    test(\"-9\", options, \"-9.00\");\n    test(\"-99\", options, \"-99.00\");\n    test(\"-999\", options, \"-999.00\");\n    test(\"-9999\", options, \"-9999.00\");\n    test(\"-99999\", options, \"-99999.00\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-10000\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-99999\");\n\n    options = ToSciOptions::default();\n    options.set_scale(0);\n    options.set_include_trailing_zeros(true); // doesn't matter when scale is 0\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-10000\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-99999\");\n\n    options.set_include_trailing_zeros(false);\n    test(\"-1\", options, \"-1\");\n    test(\"-10\", options, \"-10\");\n    test(\"-100\", options, \"-100\");\n    test(\"-1000\", options, \"-1000\");\n    test(\"-10000\", options, \"-10000\");\n    test(\"-9\", options, \"-9\");\n    test(\"-99\", options, \"-99\");\n    test(\"-999\", options, \"-999\");\n    test(\"-9999\", options, \"-9999\");\n    test(\"-99999\", options, \"-99999\");\n\n    options = ToSciOptions::default();\n    options.set_precision(2);\n    options.set_rounding_mode(Nearest); // This is the default\n    test(\"-123\", options, \"-1.2e2\");\n    options.set_rounding_mode(Down);\n    test(\"-123\", options, \"-1.2e2\");\n    options.set_rounding_mode(Floor);\n    test(\"-123\", options, \"-1.3e2\");\n    options.set_rounding_mode(Up);\n    test(\"-123\", options, \"-1.3e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"-123\", options, \"-1.2e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"-135\", options, \"-1.4e2\");\n    options.set_rounding_mode(Down);\n    test(\"-135\", options, \"-1.3e2\");\n    options.set_rounding_mode(Floor);\n    test(\"-135\", options, \"-1.4e2\");\n    options.set_rounding_mode(Up);\n    test(\"-135\", options, \"-1.4e2\");\n    options.set_rounding_mode(Ceiling);\n    test(\"-135\", options, \"-1.3e2\");\n\n    options.set_rounding_mode(Exact);\n    test(\"-140\", options, \"-1.4e2\");\n\n    options.set_rounding_mode(Nearest);\n    test(\"-999\", options, \"-1e3\");\n    options.set_rounding_mode(Down);\n    test(\"-999\", options, \"-9.9e2\");\n    options.set_rounding_mode(Floor);\n    test(\"-999\", options, \"-1e3\");\n    options.set_rounding_mode(Up);\n    test(\"-999\", options, \"-1e3\");\n    options.set_rounding_mode(Ceiling);\n    test(\"-999\", options, \"-9.9e2\");\n\n    options = ToSciOptions::default();\n    options.set_scale(2);\n    test(\"1/3\", options, \"0.33\");\n    options.set_scale(1);\n    test(\"1/3\", options, \"0.3\");\n    options.set_scale(0);\n    test(\"1/3\", options, \"0\");\n    options.set_scale(4);\n    test(\"1/300\", options, \"0.0033\");\n    options.set_scale(3);\n    test(\"1/300\", options, \"0.003\");\n    options.set_scale(2);\n    test(\"1/300\", options, \"0\");\n    options.set_scale(1);\n    test(\"1/300\", options, \"0\");\n    options.set_rounding_mode(Ceiling);\n    options.set_scale(2);\n    test(\"1/3\", options, \"0.34\");\n    options.set_scale(1);\n    test(\"1/3\", options, \"0.4\");\n    options.set_scale(0);\n    test(\"1/3\", options, \"1\");\n    options.set_scale(4);\n    test(\"1/300\", options, \"0.0034\");\n    options.set_scale(3);\n    test(\"1/300\", options, \"0.004\");\n    options.set_scale(2);\n    test(\"1/300\", options, \"0.01\");\n    options.set_scale(1);\n    test(\"1/300\", options, \"0.1\");\n\n    options = ToSciOptions::default();\n    options.set_base(2);\n    test(\"245850922/78256779\", options, \"11.0010010001\");\n    options.set_base(3);\n    test(\"245850922/78256779\", options, \"10.01021101222201\");\n    options.set_base(4);\n    test(\"245850922/78256779\", options, \"3.021003331222202\");\n    options.set_base(5);\n    test(\"245850922/78256779\", options, \"3.032322143033433\");\n    options.set_base(8);\n    test(\"245850922/78256779\", options, \"3.110375524210264\");\n    options.set_base(16);\n    test(\"245850922/78256779\", options, \"3.243f6a8885a3033\");\n    options.set_base(32);\n    test(\"245850922/78256779\", options, \"3.4gvml245kc1j1qs\");\n    options.set_base(36);\n    test(\"245850922/78256779\", options, \"3.53i5ab8p5fhzpkj\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    test(\"1/2\", options, \"0.5\");\n    test(\"1/4\", options, \"0.25\");\n    test(\"1/5\", options, \"0.2\");\n    test(\"1/8\", options, \"0.125\");\n    test(\"1/10\", options, \"0.1\");\n    options.set_base(2);\n    test(\"1/2\", options, \"0.1\");\n    test(\"1/4\", options, \"0.01\");\n    test(\"1/8\", options, \"0.001\");\n    options.set_base(3);\n    test(\"1/3\", options, \"0.1\");\n    test(\"1/9\", options, \"0.01\");\n    options.set_base(4);\n    test(\"1/2\", options, \"0.2\");\n    test(\"1/4\", options, \"0.1\");\n    test(\"1/8\", options, \"0.02\");\n    options.set_base(5);\n    test(\"1/5\", options, \"0.1\");\n    options.set_base(6);\n    test(\"1/2\", options, \"0.3\");\n    test(\"1/3\", options, \"0.2\");\n    test(\"1/6\", options, \"0.1\");\n    test(\"1/9\", options, \"0.04\");\n    options.set_base(7);\n    test(\"1/7\", options, \"0.1\");\n    options.set_base(8);\n    test(\"1/2\", options, \"0.4\");\n    test(\"1/4\", options, \"0.2\");\n    test(\"1/8\", options, \"0.1\");\n    options.set_base(9);\n    test(\"1/3\", options, \"0.3\");\n    test(\"1/9\", options, \"0.1\");\n\n    options = ToSciOptions::default();\n    options.set_size_complete();\n    test_i(\n        &Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL),\n        options,\n        \"1.401298464324817070923729583289916131280261941876515771757068283889791082685860601486638\\\n        18836212158203125e-45\",\n    );\n    options.set_base(2);\n    test_i(\n        &Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL),\n        options,\n        \"1e-149\",\n    );\n    options.set_base(32);\n    test_i(\n        &Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL),\n        options,\n        \"2e-30\",\n    );\n    options.set_base(36);\n    test_i(\n        &Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL),\n        options,\n        \"1.whin9rvdkphvrmxkdwtoq8t963n428tj1p07aaum2yy14ie-29\",\n    );\n    options.set_uppercase();\n    test_i(\n        &Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL),\n        options,\n        \"1.WHIN9RVDKPHVRMXKDWTOQ8T963N428TJ1P07AAUM2YY14Ie-29\",\n    );\n    options.set_base(10);\n    options.set_neg_exp_threshold(-200);\n    test_i(\n        &Rational::exact_from(f32::MIN_POSITIVE_SUBNORMAL),\n        options,\n        \"0.000000000000000000000000000000000000000000001401298464324817070923729583289916131280261\\\n        94187651577175706828388979108268586060148663818836212158203125\",\n    );\n    options = ToSciOptions::default();\n    test(\"1/1000\", options, \"0.001\");\n    options.set_neg_exp_threshold(-3);\n    test(\"1/1000\", options, \"1e-3\");\n    test(\"1/100\", options, \"0.01\");\n    options.set_neg_exp_threshold(-2);\n    test(\"1/100\", options, \"1e-2\");\n    test(\"1/10\", options, \"0.1\");\n    options.set_neg_exp_threshold(-1);\n    test(\"1/10\", options, \"1e-1\");\n\n    options = ToSciOptions::default();\n    options.set_base(3);\n    options.set_scale(1);\n    // Nearest uses bankers' rounding: 1/2 is equidistant to 0.1 and 0.2 in base 3, so we choose the\n    // even option, 0.2.\n    test(\"1/2\", options, \"0.2\");\n}\n\n#[should_panic]\n#[test]\npub fn to_sci_with_options_fail() {\n    let mut options = ToSciOptions::default();\n    options.set_rounding_mode(Exact);\n    options.set_precision(2);\n    Rational::from(123).to_sci_with_options(options).to_string();\n}\n\n#[test]\nfn to_sci_properties() {\n    let mut powers_of_10 = HashMap::new();\n    let ten = Rational::from(10);\n    let default_p = 16;\n    rational_gen().test_properties(|x| {\n        assert!(x.fmt_sci_valid(ToSciOptions::default()));\n        let s = x.to_sci().to_string();\n        assert_eq!(\n            x.to_sci_with_options(ToSciOptions::default()).to_string(),\n            s\n        );\n        assert!(string_is_subset(&s, DECIMAL_SCI_STRING_CHARS));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains('E'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(!s.contains(\"-.\"));\n        let x_from = Rational::from_sci_string(&s).unwrap();\n        if x == 0u32 {\n            assert_eq!(x_from, 0u32);\n        } else {\n            let log = (&x).abs().floor_log_base(&ten);\n            let pow = powers_of_10\n                .entry(log - default_p + 1)\n                .or_insert_with_key(|&p| (&ten).pow(p));\n            assert_eq!(x.round_to_multiple(&*pow, Nearest).0, x_from);\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(\n            x.to_sci().to_string(),\n            Rational::from(x).to_sci().to_string()\n        );\n    });\n}\n\n#[test]\nfn to_sci_with_options_properties() {\n    let mut powers = HashMap::new();\n    let mut chars = HashMap::new();\n    rational_to_sci_options_pair_gen_var_1().test_properties(|(x, options)| {\n        assert!(x.fmt_sci_valid(options));\n        let s = x.to_sci_with_options(options).to_string();\n        let cs: &mut String = chars.entry(options.get_base()).or_insert_with_key(|&base| {\n            let mut cs = \"+-.0123456789\".to_string();\n            if base > 10 {\n                let limit = usize::from(base - 10);\n                for c in ('a'..='z').take(limit) {\n                    cs.push(c);\n                }\n                for c in ('A'..='Z').take(limit) {\n                    cs.push(c);\n                }\n            }\n            if base < 15 {\n                cs.push('e');\n                cs.push('E');\n            }\n            cs\n        });\n        assert!(string_is_subset(&s, cs));\n        assert!(!s.starts_with('+'));\n        assert!(!s.starts_with('.'));\n        assert!(!s.ends_with('+'));\n        assert!(!s.ends_with('-'));\n        assert!(!s.ends_with('.'));\n        assert!(!s.contains(\"++\"));\n        assert!(!s.contains(\"+-\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"--\"));\n        assert!(!s.contains(\"-+\"));\n        assert!(!s.contains(\"+.\"));\n        assert!(!s.contains(\"-.\"));\n        assert!(s.chars().filter(|&c| c == '.').count() <= 1);\n        assert!(s.chars().filter(|&c| c == '-').count() <= 2);\n        assert!(s.chars().filter(|&c| c == '+').count() <= 1);\n        let mut from_options = FromSciStringOptions::default();\n        from_options.set_base(options.get_base());\n        let x_from = Rational::from_sci_string_with_options(&s, from_options).unwrap();\n        if x == 0u32 {\n            assert_eq!(x_from, 0u32);\n        } else {\n            let base = options.get_base();\n            let q_base = Rational::from(base);\n            let log = floor_log_base_of_abs(&x, &q_base);\n            let (scale, might_round_to_zero) = match options.get_size_options() {\n                SciSizeOptions::Complete => {\n                    let scale = x.length_after_point_in_small_base(base).unwrap();\n                    assert!(i64::exact_from(scale) + log + 1 > 0);\n                    (None, false)\n                }\n                SciSizeOptions::Scale(scale) => {\n                    let scale = i64::exact_from(scale);\n                    (Some(scale), scale + log < 0)\n                }\n                SciSizeOptions::Precision(precision) => {\n                    (Some(i64::exact_from(precision - 1) - log), false)\n                }\n            };\n            if might_round_to_zero && x_from == 0u32 {\n                // Do nothing\n            } else if let Some(neg_scale) = scale.map(|s| -s) {\n                let pow = powers\n                    .entry((base, neg_scale))\n                    .or_insert_with(|| (&q_base).pow(neg_scale));\n                let rounded = (&x).round_to_multiple(&*pow, options.get_rounding_mode()).0;\n                assert_eq!(rounded, x_from);\n            } else {\n                assert_eq!(x_from, x);\n            }\n        }\n    });\n\n    integer_to_sci_options_pair_gen_var_1().test_properties(|(x, options)| {\n        assert_eq!(\n            x.to_sci_with_options(options).to_string(),\n            Rational::from(x).to_sci_with_options(options).to_string()\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/string/to_string.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::strings::ToDebugString;\nuse malachite_base::strings::string_is_subset;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse num::BigRational;\nuse std::str::FromStr;\n\n#[test]\npub fn test_to_string() {\n    fn test(u: &str) {\n        let x = Rational::from_str(u).unwrap();\n        assert_eq!(x.to_string(), u);\n        assert_eq!(x.to_debug_string(), u);\n    }\n    test(\"0\");\n    test(\"2\");\n    test(\"123\");\n    test(\"1000\");\n    test(\"1000000\");\n    test(\"1000000000000000\");\n    test(\"-2\");\n    test(\"-123\");\n    test(\"-1000\");\n    test(\"-1000000\");\n    test(\"-1000000000000000\");\n    test(\"99/100\");\n    test(\"101/100\");\n    test(\"22/7\");\n    test(\"-99/100\");\n    test(\"-101/100\");\n    test(\"-22/7\");\n}\n\n#[test]\nfn to_string_properties() {\n    rational_gen().test_properties(|x| {\n        let s = x.to_string();\n        assert_eq!(x.to_debug_string(), s);\n        assert_eq!(BigRational::from(&x).to_string(), s);\n        assert_eq!(rug::Rational::from(&x).to_string(), s);\n        assert!(string_is_subset(&s, \"-/0123456789\"));\n        if x != 0 {\n            assert!(!s.starts_with('0'));\n        }\n    });\n\n    integer_gen().test_properties(|x| {\n        assert_eq!(Rational::from(&x).to_string(), x.to_string());\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/conversion/to_numerator_or_denominator.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::arithmetic::traits::{Abs, UnsignedAbs};\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::integer::Integer;\nuse malachite_nz::natural::Natural;\nuse malachite_nz::test_util::generators::integer_gen;\nuse malachite_q::Rational;\nuse malachite_q::test_util::generators::rational_gen;\nuse num::{BigRational, Signed};\nuse std::str::FromStr;\n\n#[test]\nfn test_to_numerator() {\n    let test = |s, n| {\n        let q = Rational::from_str(s).unwrap();\n        assert_eq!(q.to_numerator().to_string(), n);\n        assert_eq!(q.clone().into_numerator().to_string(), n);\n        assert_eq!(q.numerator_ref().to_string(), n);\n\n        assert_eq!(\n            BigRational::from_str(s).unwrap().numer().abs().to_string(),\n            n\n        );\n        assert_eq!(\n            rug::Rational::from_str(s)\n                .unwrap()\n                .numer()\n                .clone()\n                .abs()\n                .to_string(),\n            n\n        );\n    };\n    test(\"0\", \"0\");\n    test(\"1/2\", \"1\");\n    test(\"-1/2\", \"1\");\n    test(\"100/101\", \"100\");\n    test(\"-100/101\", \"100\");\n}\n\n#[test]\nfn to_numerator_properties() {\n    rational_gen().test_properties(|q| {\n        let n = q.to_numerator();\n        assert_eq!(q.clone().into_numerator(), n);\n        assert_eq!(*q.numerator_ref(), n);\n        assert_eq!(q.to_numerator_and_denominator().0, n);\n\n        assert_eq!(Integer::from(BigRational::from(&q).numer()).abs(), n);\n        assert_eq!(Integer::from(rug::Rational::from(&q).numer()).abs(), n);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(Rational::from(&n).into_numerator(), n.abs());\n    });\n}\n\n#[test]\nfn test_to_denominator() {\n    let test = |s, d| {\n        let q = Rational::from_str(s).unwrap();\n        assert_eq!(q.to_denominator().to_string(), d);\n        assert_eq!(q.clone().into_denominator().to_string(), d);\n        assert_eq!(q.denominator_ref().to_string(), d);\n\n        assert_eq!(\n            BigRational::from_str(s).unwrap().denom().abs().to_string(),\n            d\n        );\n        assert_eq!(\n            rug::Rational::from_str(s)\n                .unwrap()\n                .denom()\n                .clone()\n                .abs()\n                .to_string(),\n            d\n        );\n    };\n    test(\"0\", \"1\");\n    test(\"1/2\", \"2\");\n    test(\"-1/2\", \"2\");\n    test(\"100/101\", \"101\");\n    test(\"-100/101\", \"101\");\n}\n\n#[test]\nfn to_denominator_properties() {\n    rational_gen().test_properties(|q| {\n        let d = q.to_denominator();\n        assert_eq!(q.clone().into_denominator(), d);\n        assert_eq!(*q.denominator_ref(), d);\n        assert_eq!(q.to_numerator_and_denominator().1, d);\n\n        assert_eq!(Integer::from(BigRational::from(&q).denom()).abs(), d);\n        assert_eq!(Integer::from(rug::Rational::from(&q).denom()).abs(), d);\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(Rational::from(&n).into_denominator(), 1);\n    });\n}\n\n#[test]\nfn test_to_numerator_and_denominator() {\n    let test = |s, nd| {\n        let q = Rational::from_str(s).unwrap();\n        assert_eq!(q.to_numerator_and_denominator().to_debug_string(), nd);\n        assert_eq!(\n            q.clone().into_numerator_and_denominator().to_debug_string(),\n            nd\n        );\n        assert_eq!(q.numerator_and_denominator_ref().to_debug_string(), nd);\n    };\n    test(\"0\", \"(0, 1)\");\n    test(\"1/2\", \"(1, 2)\");\n    test(\"-1/2\", \"(1, 2)\");\n    test(\"100/101\", \"(100, 101)\");\n    test(\"-100/101\", \"(100, 101)\");\n}\n\n#[test]\nfn to_numerator_and_denominator_properties() {\n    rational_gen().test_properties(|q| {\n        let (n, d) = q.to_numerator_and_denominator();\n        assert_eq!(\n            q.clone().into_numerator_and_denominator(),\n            (n.clone(), d.clone())\n        );\n        assert_eq!(q.numerator_and_denominator_ref(), (&n, &d));\n\n        assert_eq!(Rational::from_naturals(n, d), q.abs());\n    });\n\n    integer_gen().test_properties(|n| {\n        assert_eq!(\n            Rational::from(&n).into_numerator_and_denominator(),\n            (n.unsigned_abs(), Natural::ONE)\n        );\n    });\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_negative_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::exhaustive::exhaustive_negative_rationals;\n\n#[test]\nfn test_exhaustive_negative_rationals() {\n    assert_eq!(\n        exhaustive_negative_rationals()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[-1, -1/2, -2, -1/3, -3/2, -2/3, -3, -1/4, -4/3, -3/5, -5/2, -2/5, -5/3, -3/4, -4, -1/5, \\\n        -5/4, -4/7, -7/3, -3/8]\"\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_non_negative_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::exhaustive::exhaustive_non_negative_rationals;\n\n#[test]\nfn test_exhaustive_non_negative_rationals() {\n    assert_eq!(\n        exhaustive_non_negative_rationals()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[0, 1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, 4, 1/5, 5/4, 4/7, \\\n        7/3]\"\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_nonzero_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::exhaustive::exhaustive_nonzero_rationals;\n\n#[test]\nfn test_exhaustive_nonzero_rationals() {\n    assert_eq!(\n        exhaustive_nonzero_rationals()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, 3/2, -3/2, 2/3, -2/3, 3, -3, 1/4, -1/4, 4/3, -4/3, \\\n        3/5, -3/5]\"\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_positive_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::exhaustive::exhaustive_positive_rationals;\n\n#[test]\nfn test_exhaustive_positive_rationals() {\n    assert_eq!(\n        exhaustive_positive_rationals()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, 4, 1/5, 5/4, 4/7, 7/3, \\\n        3/8]\"\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rational_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rational_inclusive_range;\nuse std::str::FromStr;\n\nfn exhaustive_rational_inclusive_range_helper(a: &str, b: &str, values: &str) {\n    let a = Rational::from_str(a).unwrap();\n    let b = Rational::from_str(b).unwrap();\n    let xs = exhaustive_rational_inclusive_range(a, b)\n        .take(50)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_exhaustive_rational_inclusive_range() {\n    exhaustive_rational_inclusive_range_helper(\n        \"0\",\n        \"2\",\n        \"[0, 1/2, 1, 1/3, 2, 3/2, 2/3, 1/6, 4/3, 1/4, 5/3, 1/5, 3/4, 2/5, 5/4, 1/8, 7/4, 3/5, \\\n        4/5, 1/7, 6/5, 5/6, 7/5, 3/8, 8/5, 7/6, 9/5, 2/7, 11/6, 3/7, 4/7, 1/12, 5/7, 5/8, 6/7, \\\n        1/9, 8/7, 7/8, 9/7, 1/10, 10/7, 9/8, 11/7, 2/9, 12/7, 11/8, 13/7, 1/11, 13/8, 4/9]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"1/3\",\n        \"1/2\",\n        \"[1/2, 1/3, 2/5, 3/8, 3/7, 4/9, 4/11, 5/14, 5/11, 5/12, 5/13, 7/15, 6/13, 7/16, 6/17, \\\n        8/21, 7/17, 7/18, 8/17, 7/19, 8/19, 7/20, 9/19, 9/22, 9/20, 10/21, 8/23, 9/25, 9/23, \\\n        11/24, 10/23, 11/28, 11/23, 11/25, 12/25, 10/27, 9/26, 11/27, 11/26, 10/29, 13/27, 13/28, \\\n        11/29, 11/31, 12/29, 11/30, 13/29, 13/33, 14/29, 13/30]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"99/100\",\n        \"101/100\",\n        \"[1, 99/100, 101/100, 101/102, 100/101, 103/102, 102/101, 103/104, 102/103, 105/104, \\\n        104/103, 104/105, 106/105, 105/106, 107/106, 109/110, 106/107, 107/108, 108/107, 108/109, \\\n        109/108, 110/109, 111/110, 112/113, 110/111, 111/112, 112/111, 114/113, 113/112, 113/114, \\\n        115/114, 118/119, 114/115, 115/116, 116/115, 116/117, 117/116, 118/117, 117/118, 120/121, \\\n        119/118, 120/119, 119/120, 121/122, 121/120, 122/121, 123/122, 125/126, 122/123, 123/124]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[3, 11/4, 14/5, 20/7, 17/6, 23/8, 25/8, 30/11, 25/9, 29/10, 26/9, 31/11, 28/9, 31/10, \\\n        32/11, 41/15, 34/11, 35/12, 37/12, 39/14, 36/13, 41/14, 37/13, 45/16, 38/13, 43/14, \\\n        40/13, 43/15, 44/15, 47/16, 46/15, 57/20, 47/15, 49/16, 47/17, 52/19, 48/17, 49/18, \\\n        49/17, 59/20, 50/17, 53/18, 52/17, 53/19, 53/17, 55/18, 54/19, 63/23, 55/19, 61/20]\",\n    );\n\n    exhaustive_rational_inclusive_range_helper(\n        \"-2\",\n        \"0\",\n        \"[0, -1/2, -1, -1/3, -2, -3/2, -2/3, -1/6, -4/3, -1/4, -5/3, -1/5, -3/4, -2/5, -5/4, \\\n        -1/8, -7/4, -3/5, -4/5, -1/7, -6/5, -5/6, -7/5, -3/8, -8/5, -7/6, -9/5, -2/7, -11/6, \\\n        -3/7, -4/7, -1/12, -5/7, -5/8, -6/7, -1/9, -8/7, -7/8, -9/7, -1/10, -10/7, -9/8, -11/7, \\\n        -2/9, -12/7, -11/8, -13/7, -1/11, -13/8, -4/9]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"-1/2\",\n        \"-1/3\",\n        \"[-1/2, -1/3, -2/5, -3/8, -3/7, -4/9, -4/11, -5/14, -5/11, -5/12, -5/13, -7/15, -6/13, \\\n        -7/16, -6/17, -8/21, -7/17, -7/18, -8/17, -7/19, -8/19, -7/20, -9/19, -9/22, -9/20, \\\n        -10/21, -8/23, -9/25, -9/23, -11/24, -10/23, -11/28, -11/23, -11/25, -12/25, -10/27, \\\n        -9/26, -11/27, -11/26, -10/29, -13/27, -13/28, -11/29, -11/31, -12/29, -11/30, -13/29, \\\n        -13/33, -14/29, -13/30]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"-101/100\",\n        \"-99/100\",\n        \"[-1, -99/100, -101/100, -101/102, -100/101, -103/102, -102/101, -103/104, -102/103, \\\n        -105/104, -104/103, -104/105, -106/105, -105/106, -107/106, -109/110, -106/107, -107/108, \\\n        -108/107, -108/109, -109/108, -110/109, -111/110, -112/113, -110/111, -111/112, -112/111, \\\n        -114/113, -113/112, -113/114, -115/114, -118/119, -114/115, -115/116, -116/115, -116/117, \\\n        -117/116, -118/117, -117/118, -120/121, -119/118, -120/119, -119/120, -121/122, -121/120, \\\n        -122/121, -123/122, -125/126, -122/123, -123/124]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"-245850922/78256779\",\n        \"-268876667/98914198\",\n        \"[-3, -11/4, -14/5, -20/7, -17/6, -23/8, -25/8, -30/11, -25/9, -29/10, -26/9, -31/11, \\\n        -28/9, -31/10, -32/11, -41/15, -34/11, -35/12, -37/12, -39/14, -36/13, -41/14, -37/13, \\\n        -45/16, -38/13, -43/14, -40/13, -43/15, -44/15, -47/16, -46/15, -57/20, -47/15, -49/16, \\\n        -47/17, -52/19, -48/17, -49/18, -49/17, -59/20, -50/17, -53/18, -52/17, -53/19, -53/17, \\\n        -55/18, -54/19, -63/23, -55/19, -61/20]\",\n    );\n\n    exhaustive_rational_inclusive_range_helper(\n        \"-2\",\n        \"3\",\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, 3, -1/3, -3/2, 2/3, 5/2, 1/6, -2/3, -1/4, \\\n        4/3, 1/5, -4/3, 3/4, 5/3, -1/6, -5/3, -3/4, 7/3, -1/5, 8/3, 5/4, -5/4, 1/9, 7/4, 2/5, \\\n        -7/4, 5/6, 9/4, -2/5, 11/4, 1/7, 3/5, -5/6, -3/5, -1/7, 4/5, 7/6, -4/5, -1/9, 6/5, -7/6]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"-1/2\",\n        \"1/3\",\n        \"[0, -1/2, 1/3, 1/5, -1/3, 1/4, -1/4, 1/7, -1/5, 1/6, -2/5, -1/7, -1/6, 2/7, -2/7, 1/11, \\\n        -3/7, 1/8, -1/8, 1/10, -3/8, 1/9, -1/9, 1/12, 2/9, -1/10, -2/9, -1/11, -4/9, 3/10, -3/10, \\\n        1/15, 2/11, -1/12, -2/11, 1/13, 3/11, -5/12, -3/11, 1/14, -4/11, -1/13, -5/11, -1/14, \\\n        2/13, 3/14, -2/13, 1/17, 3/13, -3/14]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"-101/100\",\n        \"99/100\",\n        \"[0, 1/2, -1, 1/3, -1/2, -1/3, 2/3, 1/6, -2/3, 1/4, -1/4, -1/6, 3/4, 1/5, -3/4, 1/8, \\\n        -1/5, 5/6, 2/5, 1/7, -2/5, -5/6, 3/5, -1/8, -3/5, -1/7, 4/5, 3/8, -4/5, 2/7, -2/7, 1/12, \\\n        3/7, -3/8, -3/7, 1/9, 4/7, 5/8, -4/7, 1/10, 5/7, -5/8, -5/7, -1/9, 6/7, 7/8, -6/7, 1/11, \\\n        -7/8, 2/9]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\n        \"-245850922/78256779\",\n        \"268876667/98914198\",\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, -3, -1/3, -3/2, 2/3, 5/2, 1/6, -5/2, -2/3, \\\n        4/3, 1/5, -4/3, -1/4, 5/3, -1/6, -5/3, 3/4, 7/3, -1/5, -7/3, -3/4, 8/3, 1/8, -8/3, 5/4, \\\n        -5/4, 5/6, 7/4, 2/5, -7/4, 1/7, 9/4, -2/5, -9/4, -5/6, -11/4, 3/5, -3/5, 1/9, 4/5, 7/6]\",\n    );\n    exhaustive_rational_inclusive_range_helper(\"0\", \"0\", \"[0]\");\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rational_inclusive_range_fail() {\n    exhaustive_rational_inclusive_range(Rational::ONE, Rational::ZERO);\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rational_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::{One, Zero};\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rational_range;\nuse std::str::FromStr;\n\nfn exhaustive_rational_range_helper(a: &str, b: &str, values: &str) {\n    let a = Rational::from_str(a).unwrap();\n    let b = Rational::from_str(b).unwrap();\n    let xs = exhaustive_rational_range(a, b)\n        .take(50)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_exhaustive_rational_range() {\n    exhaustive_rational_range_helper(\n        \"0\",\n        \"2\",\n        \"[0, 1/2, 1, 1/3, 3/2, 2/3, 4/3, 1/6, 5/3, 1/4, 3/4, 5/6, 5/4, 1/5, 7/4, 1/8, 2/5, 7/6, \\\n        3/5, 1/7, 4/5, 11/6, 6/5, 3/8, 7/5, 2/7, 8/5, 5/8, 9/5, 3/7, 4/7, 1/12, 5/7, 7/8, 6/7, \\\n        1/9, 8/7, 9/8, 9/7, 1/10, 10/7, 11/8, 11/7, 2/9, 12/7, 13/8, 13/7, 1/11, 15/8, 4/9]\",\n    );\n    exhaustive_rational_range_helper(\n        \"1/3\",\n        \"1/2\",\n        \"[1/3, 2/5, 3/7, 4/9, 3/8, 4/11, 5/11, 5/14, 5/12, 5/13, 6/13, 7/15, 7/16, 6/17, 7/17, \\\n        8/21, 8/17, 7/18, 7/19, 10/21, 8/19, 7/20, 9/19, 9/22, 9/20, 8/23, 9/23, 9/25, 10/23, \\\n        11/24, 11/23, 11/28, 11/25, 9/26, 12/25, 10/27, 11/26, 11/27, 13/27, 11/30, 13/28, 10/29, \\\n        11/29, 11/31, 12/29, 13/30, 13/29, 13/33, 14/29, 12/31]\",\n    );\n    exhaustive_rational_range_helper(\n        \"99/100\",\n        \"101/100\",\n        \"[1, 99/100, 100/101, 102/103, 102/101, 101/102, 103/102, 104/105, 104/103, 103/104, \\\n        105/104, 105/106, 106/105, 107/106, 106/107, 110/111, 108/107, 107/108, 109/108, 109/110, \\\n        108/109, 111/110, 110/109, 111/112, 112/111, 113/112, 112/113, 114/115, 114/113, 113/114, \\\n        115/114, 118/119, 116/115, 115/116, 117/116, 117/118, 116/117, 119/118, 118/117, 119/120, \\\n        120/119, 121/120, 120/121, 122/123, 122/121, 121/122, 123/122, 125/126, 124/123, 123/124]\",\n    );\n    exhaustive_rational_range_helper(\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[3, 11/4, 14/5, 20/7, 17/6, 23/8, 25/8, 30/11, 25/9, 29/10, 26/9, 31/11, 28/9, 31/10, \\\n        32/11, 41/15, 34/11, 35/12, 37/12, 39/14, 36/13, 41/14, 37/13, 45/16, 38/13, 43/14, \\\n        40/13, 43/15, 44/15, 47/16, 46/15, 57/20, 47/15, 49/16, 47/17, 52/19, 48/17, 49/18, \\\n        49/17, 59/20, 50/17, 53/18, 52/17, 53/19, 53/17, 55/18, 54/19, 63/23, 55/19, 61/20]\",\n    );\n\n    exhaustive_rational_range_helper(\n        \"-2\",\n        \"0\",\n        \"[-1, -1/2, -2, -1/3, -3/2, -2/3, -4/3, -1/6, -5/3, -1/4, -3/4, -5/6, -5/4, -1/5, -7/4, \\\n        -1/8, -2/5, -7/6, -3/5, -1/7, -4/5, -11/6, -6/5, -3/8, -7/5, -2/7, -8/5, -5/8, -9/5, \\\n        -3/7, -4/7, -1/12, -5/7, -7/8, -6/7, -1/9, -8/7, -9/8, -9/7, -1/10, -10/7, -11/8, -11/7, \\\n        -2/9, -12/7, -13/8, -13/7, -1/11, -15/8, -4/9]\",\n    );\n    exhaustive_rational_range_helper(\n        \"-1/2\",\n        \"-1/3\",\n        \"[-1/2, -2/5, -3/7, -4/9, -3/8, -4/11, -5/11, -5/14, -5/12, -5/13, -6/13, -7/15, -7/16, \\\n        -6/17, -7/17, -8/21, -8/17, -7/18, -7/19, -10/21, -8/19, -7/20, -9/19, -9/22, -9/20, \\\n        -8/23, -9/23, -9/25, -10/23, -11/24, -11/23, -11/28, -11/25, -9/26, -12/25, -10/27, \\\n        -11/26, -11/27, -13/27, -11/30, -13/28, -10/29, -11/29, -11/31, -12/29, -13/30, -13/29, \\\n        -13/33, -14/29, -12/31]\",\n    );\n    exhaustive_rational_range_helper(\n        \"-101/100\",\n        \"-99/100\",\n        \"[-1, -101/100, -100/101, -102/103, -102/101, -101/102, -103/102, -104/105, -104/103, \\\n        -103/104, -105/104, -105/106, -106/105, -107/106, -106/107, -110/111, -108/107, -107/108, \\\n        -109/108, -109/110, -108/109, -111/110, -110/109, -111/112, -112/111, -113/112, -112/113, \\\n        -114/115, -114/113, -113/114, -115/114, -118/119, -116/115, -115/116, -117/116, -117/118, \\\n        -116/117, -119/118, -118/117, -119/120, -120/119, -121/120, -120/121, -122/123, -122/121, \\\n        -121/122, -123/122, -125/126, -124/123, -123/124]\",\n    );\n    exhaustive_rational_range_helper(\n        \"-245850922/78256779\",\n        \"-268876667/98914198\",\n        \"[-3, -11/4, -14/5, -20/7, -17/6, -23/8, -25/8, -30/11, -25/9, -29/10, -26/9, -31/11, \\\n        -28/9, -31/10, -32/11, -41/15, -34/11, -35/12, -37/12, -39/14, -36/13, -41/14, -37/13, \\\n        -45/16, -38/13, -43/14, -40/13, -43/15, -44/15, -47/16, -46/15, -57/20, -47/15, -49/16, \\\n        -47/17, -52/19, -48/17, -49/18, -49/17, -59/20, -50/17, -53/18, -52/17, -53/19, -53/17, \\\n        -55/18, -54/19, -63/23, -55/19, -61/20]\",\n    );\n\n    exhaustive_rational_range_helper(\n        \"-2\",\n        \"3\",\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, -3/2, -1/4, 5/2, -1/3, 2/3, 1/7, -2/3, 3/4, \\\n        4/3, 1/5, -4/3, -3/4, 5/3, 1/6, -5/3, 5/4, 7/3, -1/5, 8/3, -5/4, 7/4, 1/9, -7/4, 2/5, \\\n        9/4, -1/6, 11/4, -2/5, 3/5, 1/8, -3/5, 5/6, 4/5, -1/7, -4/5, -5/6, 6/5, -1/9, -6/5, 7/6]\",\n    );\n    exhaustive_rational_range_helper(\n        \"-1/2\",\n        \"1/3\",\n        \"[0, -1/2, -1/3, 1/5, 1/4, -1/5, -1/4, 1/7, -2/5, 1/6, -1/6, 1/8, -1/7, -1/8, 2/7, 1/11, \\\n        -2/7, -3/8, -3/7, 1/9, -1/9, 1/10, 2/9, 1/12, -2/9, -1/10, -4/9, -1/11, 3/10, 2/11, \\\n        -3/10, 1/15, -2/11, -1/12, 3/11, 1/13, -3/11, -5/12, -4/11, 1/14, -5/11, -1/13, 2/13, \\\n        -1/15, -2/13, -1/14, 3/13, 1/17, -3/13, 3/14]\",\n    );\n    exhaustive_rational_range_helper(\n        \"-101/100\",\n        \"99/100\",\n        \"[0, 1/2, -1, 1/3, -1/2, -1/3, 2/3, 1/6, -2/3, 1/4, -1/4, -1/6, 3/4, 1/5, -3/4, 1/8, \\\n        -1/5, 5/6, 2/5, 1/7, -2/5, -5/6, 3/5, -1/8, -3/5, -1/7, 4/5, 3/8, -4/5, 2/7, -2/7, 1/12, \\\n        3/7, -3/8, -3/7, 1/9, 4/7, 5/8, -4/7, 1/10, 5/7, -5/8, -5/7, -1/9, 6/7, 7/8, -6/7, 1/11, \\\n        -7/8, 2/9]\",\n    );\n    exhaustive_rational_range_helper(\n        \"-245850922/78256779\",\n        \"268876667/98914198\",\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, -3, -1/3, -3/2, 2/3, 5/2, 1/6, -5/2, -2/3, \\\n        4/3, 1/5, -4/3, -1/4, 5/3, -1/6, -5/3, 3/4, 7/3, -1/5, -7/3, -3/4, 8/3, 1/8, -8/3, 5/4, \\\n        -5/4, 5/6, 7/4, 2/5, -7/4, 1/7, 9/4, -2/5, -9/4, -5/6, -11/4, 3/5, -3/5, 1/9, 4/5, 7/6]\",\n    );\n    exhaustive_rational_range_helper(\"0\", \"0\", \"[]\");\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rational_range_fail() {\n    exhaustive_rational_range(Rational::ONE, Rational::ZERO);\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rational_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rational_range_to_infinity;\n\nfn exhaustive_rational_range_to_infinity_helper(a: Rational, values: &str) {\n    let xs = exhaustive_rational_range_to_infinity(a)\n        .take(50)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_exhaustive_rational_range_to_infinity() {\n    exhaustive_rational_range_to_infinity_helper(\n        Rational::ZERO,\n        \"[0, 1/2, 1, 1/3, 2, 3/2, 3, 1/4, 4, 5/2, 5, 2/3, 6, 7/2, 7, 1/5, 8, 9/2, 9, 4/3, 10, \\\n        11/2, 11, 3/4, 12, 13/2, 13, 5/3, 14, 15/2, 15, 1/6, 16, 17/2, 17, 7/3, 18, 19/2, 19, \\\n        5/4, 20, 21/2, 21, 8/3, 22, 23/2, 23, 2/5, 24, 25/2]\",\n    );\n    exhaustive_rational_range_to_infinity_helper(\n        Rational::from(5),\n        \"[5, 11/2, 6, 16/3, 7, 13/2, 8, 21/4, 9, 15/2, 10, 17/3, 11, 17/2, 12, 26/5, 13, 19/2, \\\n        14, 19/3, 15, 21/2, 16, 23/4, 17, 23/2, 18, 20/3, 19, 25/2, 20, 31/6, 21, 27/2, 22, 22/3, \\\n        23, 29/2, 24, 25/4, 25, 31/2, 26, 23/3, 27, 33/2, 28, 27/5, 29, 35/2]\",\n    );\n    exhaustive_rational_range_to_infinity_helper(\n        Rational::from(-5),\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, 3, -1/3, -3, -3/2, 4, 1/5, -4, 5/2, 5, 2/3, \\\n        -5, -5/2, 6, -1/4, 7, 7/2, 8, -2/3, 9, -7/2, 10, 1/6, 11, 9/2, 12, 4/3, 13, -9/2, 14, \\\n        3/4, 15, 11/2, 16, -4/3, 17, 13/2, 18, -1/5, 19, 15/2]\",\n    );\n    exhaustive_rational_range_to_infinity_helper(\n        Rational::exact_from(std::f64::consts::PI),\n        \"[4, 7/2, 5, 10/3, 6, 9/2, 7, 13/4, 8, 11/2, 9, 11/3, 10, 13/2, 11, 16/5, 12, 15/2, 13, \\\n        13/3, 14, 17/2, 15, 15/4, 16, 19/2, 17, 14/3, 18, 21/2, 19, 19/6, 20, 23/2, 21, 16/3, 22, \\\n        25/2, 23, 17/4, 24, 27/2, 25, 17/3, 26, 29/2, 27, 17/5, 28, 31/2]\",\n    );\n    exhaustive_rational_range_to_infinity_helper(\n        -Rational::exact_from(std::f64::consts::PI),\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, 3, -1/3, -3, -3/2, 4, 1/5, 5, 5/2, 6, 2/3, \\\n        7, -5/2, 8, -1/4, 9, 7/2, 10, -2/3, 11, 9/2, 12, 1/6, 13, 11/2, 14, 4/3, 15, 13/2, 16, \\\n        3/4, 17, 15/2, 18, -4/3, 19, 17/2, 20, -1/5, 21, 19/2]\",\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rational_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::num::conversion::traits::ExactFrom;\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rational_range_to_negative_infinity;\n\nfn exhaustive_rational_range_to_negative_infinity_helper(a: Rational, values: &str) {\n    let xs = exhaustive_rational_range_to_negative_infinity(a)\n        .take(50)\n        .collect_vec()\n        .to_debug_string();\n    assert_eq!(xs, values);\n}\n\n#[test]\nfn test_exhaustive_rational_range_to_negative_infinity() {\n    exhaustive_rational_range_to_negative_infinity_helper(\n        Rational::ZERO,\n        \"[0, -1/2, -1, -1/3, -2, -3/2, -3, -1/4, -4, -5/2, -5, -2/3, -6, -7/2, -7, -1/5, -8, \\\n        -9/2, -9, -4/3, -10, -11/2, -11, -3/4, -12, -13/2, -13, -5/3, -14, -15/2, -15, -1/6, \\\n        -16, -17/2, -17, -7/3, -18, -19/2, -19, -5/4, -20, -21/2, -21, -8/3, -22, -23/2, -23, \\\n        -2/5, -24, -25/2]\",\n    );\n    exhaustive_rational_range_to_negative_infinity_helper(\n        Rational::from(5),\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, 3, -1/3, -3, -3/2, 4, 1/5, -4, 5/2, 5, 2/3, \\\n        -5, -5/2, -6, -1/4, -7, 7/2, -8, -2/3, -9, -7/2, -10, 1/6, -11, 9/2, -12, 4/3, -13, -9/2, \\\n        -14, 3/4, -15, -11/2, -16, -4/3, -17, -13/2, -18, -1/5, -19, -15/2]\",\n    );\n    exhaustive_rational_range_to_negative_infinity_helper(\n        Rational::from(-5),\n        \"[-5, -11/2, -6, -16/3, -7, -13/2, -8, -21/4, -9, -15/2, -10, -17/3, -11, -17/2, -12, \\\n        -26/5, -13, -19/2, -14, -19/3, -15, -21/2, -16, -23/4, -17, -23/2, -18, -20/3, -19, \\\n        -25/2, -20, -31/6, -21, -27/2, -22, -22/3, -23, -29/2, -24, -25/4, -25, -31/2, -26, \\\n        -23/3, -27, -33/2, -28, -27/5, -29, -35/2]\",\n    );\n    exhaustive_rational_range_to_negative_infinity_helper(\n        Rational::exact_from(std::f64::consts::PI),\n        \"[0, 1/2, 1, 1/3, -1, -1/2, 2, 1/4, -2, 3/2, 3, -1/3, -3, -3/2, -4, 1/5, -5, 5/2, -6, \\\n        2/3, -7, -5/2, -8, -1/4, -9, -7/2, -10, -2/3, -11, -9/2, -12, 1/6, -13, -11/2, -14, 4/3, \\\n        -15, -13/2, -16, 3/4, -17, -15/2, -18, -4/3, -19, -17/2, -20, -1/5, -21, -19/2]\",\n    );\n    exhaustive_rational_range_to_negative_infinity_helper(\n        -Rational::exact_from(std::f64::consts::PI),\n        \"[-4, -7/2, -5, -10/3, -6, -9/2, -7, -13/4, -8, -11/2, -9, -11/3, -10, -13/2, -11, -16/5, \\\n        -12, -15/2, -13, -13/3, -14, -17/2, -15, -15/4, -16, -19/2, -17, -14/3, -18, -21/2, -19, \\\n        -19/6, -20, -23/2, -21, -16/3, -22, -25/2, -23, -17/4, -24, -27/2, -25, -17/3, -26, \\\n        -29/2, -27, -17/5, -28, -31/2]\",\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::strings::ToDebugString;\nuse malachite_q::exhaustive::exhaustive_rationals;\n\n#[test]\nfn test_exhaustive_rationals() {\n    assert_eq!(\n        exhaustive_rationals()\n            .take(20)\n            .collect_vec()\n            .to_debug_string(),\n        \"[0, 1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, 3/2, -3/2, 2/3, -2/3, 3, -3, 1/4, -1/4, 4/3, \\\n        -4/3, 3/5]\"\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rationals_with_denominator_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rationals_with_denominator_inclusive_range;\nuse std::str::FromStr;\n\nfn helper(d: &str, a: &str, b: &str, out: &str) {\n    assert_eq!(\n        exhaustive_rationals_with_denominator_inclusive_range(\n            Natural::from_str(d).unwrap(),\n            Rational::from_str(a).unwrap(),\n            Rational::from_str(b).unwrap()\n        )\n        .collect_vec()\n        .to_debug_string(),\n        out\n    );\n}\n\n#[test]\nfn test_exhaustive_rationals_with_denominator_inclusive_range() {\n    helper(\"1\", \"1\", \"1\", \"[1]\");\n    helper(\"2\", \"1\", \"1\", \"[]\");\n    helper(\"3\", \"1\", \"1\", \"[]\");\n    helper(\"4\", \"1\", \"1\", \"[]\");\n    helper(\"5\", \"1\", \"1\", \"[]\");\n    helper(\"6\", \"1\", \"1\", \"[]\");\n\n    helper(\"1\", \"0\", \"1\", \"[0, 1]\");\n    helper(\"2\", \"0\", \"1\", \"[1/2]\");\n    helper(\"3\", \"0\", \"1\", \"[1/3, 2/3]\");\n    helper(\"4\", \"0\", \"1\", \"[1/4, 3/4]\");\n    helper(\"5\", \"0\", \"1\", \"[1/5, 2/5, 3/5, 4/5]\");\n    helper(\"6\", \"0\", \"1\", \"[1/6, 5/6]\");\n\n    helper(\"1\", \"0\", \"1/2\", \"[0]\");\n    helper(\"2\", \"0\", \"1/2\", \"[1/2]\");\n    helper(\"3\", \"0\", \"1/2\", \"[1/3]\");\n    helper(\"4\", \"0\", \"1/2\", \"[1/4]\");\n    helper(\"5\", \"0\", \"1/2\", \"[1/5, 2/5]\");\n    helper(\"6\", \"0\", \"1/2\", \"[1/6]\");\n\n    helper(\"1\", \"1/3\", \"1/2\", \"[]\");\n    helper(\"2\", \"1/3\", \"1/2\", \"[1/2]\");\n    helper(\"3\", \"1/3\", \"1/2\", \"[1/3]\");\n    helper(\"4\", \"1/3\", \"1/2\", \"[]\");\n    helper(\"5\", \"1/3\", \"1/2\", \"[2/5]\");\n    helper(\"6\", \"1/3\", \"1/2\", \"[]\");\n\n    helper(\"1\", \"-1/2\", \"-1/3\", \"[]\");\n    helper(\"2\", \"-1/2\", \"-1/3\", \"[-1/2]\");\n    helper(\"3\", \"-1/2\", \"-1/3\", \"[-1/3]\");\n    helper(\"4\", \"-1/2\", \"-1/3\", \"[]\");\n    helper(\"5\", \"-1/2\", \"-1/3\", \"[-2/5]\");\n    helper(\"6\", \"-1/2\", \"-1/3\", \"[]\");\n\n    helper(\"1\", \"-1/2\", \"1/3\", \"[0]\");\n    helper(\"2\", \"-1/2\", \"1/3\", \"[-1/2]\");\n    helper(\"3\", \"-1/2\", \"1/3\", \"[1/3, -1/3]\");\n    helper(\"4\", \"-1/2\", \"1/3\", \"[1/4, -1/4]\");\n    helper(\"5\", \"-1/2\", \"1/3\", \"[1/5, -1/5, -2/5]\");\n    helper(\"6\", \"-1/2\", \"1/3\", \"[1/6, -1/6]\");\n\n    // [e, π), roughly\n    helper(\"1\", \"268876667/98914198\", \"245850922/78256779\", \"[3]\");\n    helper(\"2\", \"268876667/98914198\", \"245850922/78256779\", \"[]\");\n    helper(\"3\", \"268876667/98914198\", \"245850922/78256779\", \"[]\");\n    helper(\"4\", \"268876667/98914198\", \"245850922/78256779\", \"[11/4]\");\n    helper(\"5\", \"268876667/98914198\", \"245850922/78256779\", \"[14/5]\");\n    helper(\"6\", \"268876667/98914198\", \"245850922/78256779\", \"[17/6]\");\n    helper(\"7\", \"268876667/98914198\", \"245850922/78256779\", \"[20/7]\");\n    helper(\n        \"8\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[23/8, 25/8]\",\n    );\n    helper(\n        \"9\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[25/9, 26/9, 28/9]\",\n    );\n    helper(\n        \"10\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[29/10, 31/10]\",\n    );\n    helper(\n        \"100\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[273/100, 277/100, 279/100, 281/100, 283/100, 287/100, 289/100, 291/100, 293/100, \\\n        297/100, 299/100, 301/100, 303/100, 307/100, 309/100, 311/100, 313/100]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rationals_with_denominator_inclusive_range_fail_1() {\n    exhaustive_rationals_with_denominator_inclusive_range(\n        Natural::ZERO,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(1u32, 2),\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rationals_with_denominator_inclusive_range_fail_2() {\n    exhaustive_rationals_with_denominator_inclusive_range(\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 2),\n        Rational::from_unsigneds(1u32, 3),\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rationals_with_denominator_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse itertools::Itertools;\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_base::strings::ToDebugString;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rationals_with_denominator_range;\nuse std::str::FromStr;\n\nfn helper(d: &str, a: &str, b: &str, out: &str) {\n    assert_eq!(\n        exhaustive_rationals_with_denominator_range(\n            Natural::from_str(d).unwrap(),\n            Rational::from_str(a).unwrap(),\n            Rational::from_str(b).unwrap()\n        )\n        .collect_vec()\n        .to_debug_string(),\n        out\n    );\n}\n\n#[test]\nfn test_exhaustive_rationals_with_denominator_range() {\n    helper(\"1\", \"0\", \"1\", \"[0]\");\n    helper(\"2\", \"0\", \"1\", \"[1/2]\");\n    helper(\"3\", \"0\", \"1\", \"[1/3, 2/3]\");\n    helper(\"4\", \"0\", \"1\", \"[1/4, 3/4]\");\n    helper(\"5\", \"0\", \"1\", \"[1/5, 2/5, 3/5, 4/5]\");\n    helper(\"6\", \"0\", \"1\", \"[1/6, 5/6]\");\n\n    helper(\"1\", \"0\", \"1/2\", \"[0]\");\n    helper(\"2\", \"0\", \"1/2\", \"[]\");\n    helper(\"3\", \"0\", \"1/2\", \"[1/3]\");\n    helper(\"4\", \"0\", \"1/2\", \"[1/4]\");\n    helper(\"5\", \"0\", \"1/2\", \"[1/5, 2/5]\");\n    helper(\"6\", \"0\", \"1/2\", \"[1/6]\");\n\n    helper(\"1\", \"1/3\", \"1/2\", \"[]\");\n    helper(\"2\", \"1/3\", \"1/2\", \"[]\");\n    helper(\"3\", \"1/3\", \"1/2\", \"[1/3]\");\n    helper(\"4\", \"1/3\", \"1/2\", \"[]\");\n    helper(\"5\", \"1/3\", \"1/2\", \"[2/5]\");\n    helper(\"6\", \"1/3\", \"1/2\", \"[]\");\n\n    helper(\"1\", \"-1/2\", \"-1/3\", \"[]\");\n    helper(\"2\", \"-1/2\", \"-1/3\", \"[-1/2]\");\n    helper(\"3\", \"-1/2\", \"-1/3\", \"[]\");\n    helper(\"4\", \"-1/2\", \"-1/3\", \"[]\");\n    helper(\"5\", \"-1/2\", \"-1/3\", \"[-2/5]\");\n    helper(\"6\", \"-1/2\", \"-1/3\", \"[]\");\n\n    helper(\"1\", \"-1/2\", \"1/3\", \"[0]\");\n    helper(\"2\", \"-1/2\", \"1/3\", \"[-1/2]\");\n    helper(\"3\", \"-1/2\", \"1/3\", \"[-1/3]\");\n    helper(\"4\", \"-1/2\", \"1/3\", \"[1/4, -1/4]\");\n    helper(\"5\", \"-1/2\", \"1/3\", \"[1/5, -1/5, -2/5]\");\n    helper(\"6\", \"-1/2\", \"1/3\", \"[1/6, -1/6]\");\n\n    // [e, π), roughly\n    helper(\"1\", \"268876667/98914198\", \"245850922/78256779\", \"[3]\");\n    helper(\"2\", \"268876667/98914198\", \"245850922/78256779\", \"[]\");\n    helper(\"3\", \"268876667/98914198\", \"245850922/78256779\", \"[]\");\n    helper(\"4\", \"268876667/98914198\", \"245850922/78256779\", \"[11/4]\");\n    helper(\"5\", \"268876667/98914198\", \"245850922/78256779\", \"[14/5]\");\n    helper(\"6\", \"268876667/98914198\", \"245850922/78256779\", \"[17/6]\");\n    helper(\"7\", \"268876667/98914198\", \"245850922/78256779\", \"[20/7]\");\n    helper(\n        \"8\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[23/8, 25/8]\",\n    );\n    helper(\n        \"9\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[25/9, 26/9, 28/9]\",\n    );\n    helper(\n        \"10\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[29/10, 31/10]\",\n    );\n    helper(\n        \"100\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        \"[273/100, 277/100, 279/100, 281/100, 283/100, 287/100, 289/100, 291/100, 293/100, \\\n        297/100, 299/100, 301/100, 303/100, 307/100, 309/100, 311/100, 313/100]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rationals_with_denominator_range_fail_1() {\n    exhaustive_rationals_with_denominator_range(\n        Natural::ZERO,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(1u32, 2),\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rationals_with_denominator_range_fail_2() {\n    exhaustive_rationals_with_denominator_range(\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(1u32, 3),\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rationals_with_denominator_range_fail_3() {\n    exhaustive_rationals_with_denominator_range(\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 2),\n        Rational::from_unsigneds(1u32, 3),\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rationals_with_denominator_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::prefix_to_string;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rationals_with_denominator_range_to_infinity;\nuse std::str::FromStr;\n\nfn helper(d: &str, a: &str, out: &str) {\n    assert_eq!(\n        prefix_to_string(\n            exhaustive_rationals_with_denominator_range_to_infinity(\n                Natural::from_str(d).unwrap(),\n                Rational::from_str(a).unwrap()\n            ),\n            20\n        ),\n        out\n    );\n}\n\n#[test]\nfn test_exhaustive_rationals_with_denominator_range_to_infinity() {\n    helper(\n        \"1\",\n        \"0\",\n        \"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...]\",\n    );\n    helper(\n        \"2\",\n        \"0\",\n        \"[1/2, 3/2, 5/2, 7/2, 9/2, 11/2, 13/2, 15/2, 17/2, 19/2, 21/2, 23/2, 25/2, 27/2, 29/2, \\\n        31/2, 33/2, 35/2, 37/2, 39/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"0\",\n        \"[1/3, 2/3, 4/3, 5/3, 7/3, 8/3, 10/3, 11/3, 13/3, 14/3, 16/3, 17/3, 19/3, 20/3, 22/3, \\\n        23/3, 25/3, 26/3, 28/3, 29/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"0\",\n        \"[1/4, 3/4, 5/4, 7/4, 9/4, 11/4, 13/4, 15/4, 17/4, 19/4, 21/4, 23/4, 25/4, 27/4, 29/4, \\\n        31/4, 33/4, 35/4, 37/4, 39/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"0\",\n        \"[1/5, 2/5, 3/5, 4/5, 6/5, 7/5, 8/5, 9/5, 11/5, 12/5, 13/5, 14/5, 16/5, 17/5, 18/5, 19/5, \\\n        21/5, 22/5, 23/5, 24/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"0\",\n        \"[1/6, 5/6, 7/6, 11/6, 13/6, 17/6, 19/6, 23/6, 25/6, 29/6, 31/6, 35/6, 37/6, 41/6, 43/6, \\\n        47/6, 49/6, 53/6, 55/6, 59/6, ...]\",\n    );\n\n    helper(\n        \"1\",\n        \"1/2\",\n        \"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...]\",\n    );\n    helper(\n        \"2\",\n        \"1/2\",\n        \"[1/2, 3/2, 5/2, 7/2, 9/2, 11/2, 13/2, 15/2, 17/2, 19/2, 21/2, 23/2, 25/2, 27/2, 29/2, \\\n        31/2, 33/2, 35/2, 37/2, 39/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"1/2\",\n        \"[2/3, 4/3, 5/3, 7/3, 8/3, 10/3, 11/3, 13/3, 14/3, 16/3, 17/3, 19/3, 20/3, 22/3, 23/3, \\\n        25/3, 26/3, 28/3, 29/3, 31/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"1/2\",\n        \"[3/4, 5/4, 7/4, 9/4, 11/4, 13/4, 15/4, 17/4, 19/4, 21/4, 23/4, 25/4, 27/4, 29/4, 31/4, \\\n        33/4, 35/4, 37/4, 39/4, 41/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"1/2\",\n        \"[3/5, 4/5, 6/5, 7/5, 8/5, 9/5, 11/5, 12/5, 13/5, 14/5, 16/5, 17/5, 18/5, 19/5, 21/5, \\\n        22/5, 23/5, 24/5, 26/5, 27/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"1/2\",\n        \"[5/6, 7/6, 11/6, 13/6, 17/6, 19/6, 23/6, 25/6, 29/6, 31/6, 35/6, 37/6, 41/6, 43/6, 47/6, \\\n        49/6, 53/6, 55/6, 59/6, 61/6, ...]\",\n    );\n\n    helper(\n        \"1\",\n        \"245850922/78256779\",\n        \"[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ...]\",\n    );\n    helper(\n        \"2\",\n        \"245850922/78256779\",\n        \"[7/2, 9/2, 11/2, 13/2, 15/2, 17/2, 19/2, 21/2, 23/2, 25/2, 27/2, 29/2, 31/2, 33/2, 35/2, \\\n        37/2, 39/2, 41/2, 43/2, 45/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"245850922/78256779\",\n        \"[10/3, 11/3, 13/3, 14/3, 16/3, 17/3, 19/3, 20/3, 22/3, 23/3, 25/3, 26/3, 28/3, 29/3, \\\n        31/3, 32/3, 34/3, 35/3, 37/3, 38/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"245850922/78256779\",\n        \"[13/4, 15/4, 17/4, 19/4, 21/4, 23/4, 25/4, 27/4, 29/4, 31/4, 33/4, 35/4, 37/4, 39/4, \\\n        41/4, 43/4, 45/4, 47/4, 49/4, 51/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"245850922/78256779\",\n        \"[16/5, 17/5, 18/5, 19/5, 21/5, 22/5, 23/5, 24/5, 26/5, 27/5, 28/5, 29/5, 31/5, 32/5, \\\n        33/5, 34/5, 36/5, 37/5, 38/5, 39/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"245850922/78256779\",\n        \"[19/6, 23/6, 25/6, 29/6, 31/6, 35/6, 37/6, 41/6, 43/6, 47/6, 49/6, 53/6, 55/6, 59/6, \\\n        61/6, 65/6, 67/6, 71/6, 73/6, 77/6, ...]\",\n    );\n\n    helper(\n        \"1\",\n        \"-245850922/78256779\",\n        \"[0, 1, -1, 2, -2, 3, -3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ...]\",\n    );\n    helper(\n        \"2\",\n        \"-245850922/78256779\",\n        \"[1/2, -1/2, 3/2, -3/2, 5/2, -5/2, 7/2, 9/2, 11/2, 13/2, 15/2, 17/2, 19/2, 21/2, 23/2, \\\n        25/2, 27/2, 29/2, 31/2, 33/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"-245850922/78256779\",\n        \"[1/3, -1/3, 2/3, -2/3, 4/3, -4/3, 5/3, -5/3, 7/3, -7/3, 8/3, -8/3, 10/3, 11/3, 13/3, \\\n        14/3, 16/3, 17/3, 19/3, 20/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"-245850922/78256779\",\n        \"[1/4, -1/4, 3/4, -3/4, 5/4, -5/4, 7/4, -7/4, 9/4, -9/4, 11/4, -11/4, 13/4, 15/4, 17/4, \\\n        19/4, 21/4, 23/4, 25/4, 27/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"-245850922/78256779\",\n        \"[1/5, -1/5, 2/5, -2/5, 3/5, -3/5, 4/5, -4/5, 6/5, -6/5, 7/5, -7/5, 8/5, -8/5, 9/5, -9/5, \\\n        11/5, -11/5, 12/5, -12/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"-245850922/78256779\",\n        \"[1/6, -1/6, 5/6, -5/6, 7/6, -7/6, 11/6, -11/6, 13/6, -13/6, 17/6, -17/6, 19/6, 23/6, \\\n        25/6, 29/6, 31/6, 35/6, 37/6, 41/6, ...]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rationals_with_denominator_range_to_infinity_fail() {\n    exhaustive_rationals_with_denominator_range_to_infinity(\n        Natural::ZERO,\n        Rational::from_unsigneds(1u32, 3),\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/exhaustive/exhaustive_rationals_with_denominator_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::iterators::prefix_to_string;\nuse malachite_base::num::basic::traits::Zero;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::exhaustive::exhaustive_rationals_with_denominator_range_to_negative_infinity;\nuse std::str::FromStr;\n\nfn helper(d: &str, a: &str, out: &str) {\n    assert_eq!(\n        prefix_to_string(\n            exhaustive_rationals_with_denominator_range_to_negative_infinity(\n                Natural::from_str(d).unwrap(),\n                Rational::from_str(a).unwrap()\n            ),\n            20\n        ),\n        out\n    );\n}\n\n#[test]\nfn test_exhaustive_rationals_with_denominator_range_to_negative_infinity() {\n    helper(\n        \"1\",\n        \"0\",\n        \"[0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, \\\n        -19, ...]\",\n    );\n    helper(\n        \"2\",\n        \"0\",\n        \"[-1/2, -3/2, -5/2, -7/2, -9/2, -11/2, -13/2, -15/2, -17/2, -19/2, -21/2, -23/2, -25/2, \\\n        -27/2, -29/2, -31/2, -33/2, -35/2, -37/2, -39/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"0\",\n        \"[-1/3, -2/3, -4/3, -5/3, -7/3, -8/3, -10/3, -11/3, -13/3, -14/3, -16/3, -17/3, -19/3, \\\n        -20/3, -22/3, -23/3, -25/3, -26/3, -28/3, -29/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"0\",\n        \"[-1/4, -3/4, -5/4, -7/4, -9/4, -11/4, -13/4, -15/4, -17/4, -19/4, -21/4, -23/4, -25/4, \\\n        -27/4, -29/4, -31/4, -33/4, -35/4, -37/4, -39/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"0\",\n        \"[-1/5, -2/5, -3/5, -4/5, -6/5, -7/5, -8/5, -9/5, -11/5, -12/5, -13/5, -14/5, -16/5, \\\n        -17/5, -18/5, -19/5, -21/5, -22/5, -23/5, -24/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"0\",\n        \"[-1/6, -5/6, -7/6, -11/6, -13/6, -17/6, -19/6, -23/6, -25/6, -29/6, -31/6, -35/6, -37/6, \\\n        -41/6, -43/6, -47/6, -49/6, -53/6, -55/6, -59/6, ...]\",\n    );\n\n    helper(\n        \"1\",\n        \"1/2\",\n        \"[0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, \\\n        -19, ...]\",\n    );\n    helper(\n        \"2\",\n        \"1/2\",\n        \"[1/2, -1/2, -3/2, -5/2, -7/2, -9/2, -11/2, -13/2, -15/2, -17/2, -19/2, -21/2, -23/2, \\\n        -25/2, -27/2, -29/2, -31/2, -33/2, -35/2, -37/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"1/2\",\n        \"[1/3, -1/3, -2/3, -4/3, -5/3, -7/3, -8/3, -10/3, -11/3, -13/3, -14/3, -16/3, -17/3, \\\n        -19/3, -20/3, -22/3, -23/3, -25/3, -26/3, -28/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"1/2\",\n        \"[1/4, -1/4, -3/4, -5/4, -7/4, -9/4, -11/4, -13/4, -15/4, -17/4, -19/4, -21/4, -23/4, \\\n        -25/4, -27/4, -29/4, -31/4, -33/4, -35/4, -37/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"1/2\",\n        \"[1/5, -1/5, 2/5, -2/5, -3/5, -4/5, -6/5, -7/5, -8/5, -9/5, -11/5, -12/5, -13/5, -14/5, \\\n        -16/5, -17/5, -18/5, -19/5, -21/5, -22/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"1/2\",\n        \"[1/6, -1/6, -5/6, -7/6, -11/6, -13/6, -17/6, -19/6, -23/6, -25/6, -29/6, -31/6, -35/6, \\\n        -37/6, -41/6, -43/6, -47/6, -49/6, -53/6, -55/6, ...]\",\n    );\n\n    helper(\n        \"1\",\n        \"245850922/78256779\",\n        \"[0, 1, -1, 2, -2, 3, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, ...]\",\n    );\n    helper(\n        \"2\",\n        \"245850922/78256779\",\n        \"[1/2, -1/2, 3/2, -3/2, 5/2, -5/2, -7/2, -9/2, -11/2, -13/2, -15/2, -17/2, -19/2, -21/2, \\\n        -23/2, -25/2, -27/2, -29/2, -31/2, -33/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"245850922/78256779\",\n        \"[1/3, -1/3, 2/3, -2/3, 4/3, -4/3, 5/3, -5/3, 7/3, -7/3, 8/3, -8/3, -10/3, -11/3, -13/3, \\\n        -14/3, -16/3, -17/3, -19/3, -20/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"245850922/78256779\",\n        \"[1/4, -1/4, 3/4, -3/4, 5/4, -5/4, 7/4, -7/4, 9/4, -9/4, 11/4, -11/4, -13/4, -15/4, \\\n        -17/4, -19/4, -21/4, -23/4, -25/4, -27/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"245850922/78256779\",\n        \"[1/5, -1/5, 2/5, -2/5, 3/5, -3/5, 4/5, -4/5, 6/5, -6/5, 7/5, -7/5, 8/5, -8/5, 9/5, -9/5, \\\n        11/5, -11/5, 12/5, -12/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"245850922/78256779\",\n        \"[1/6, -1/6, 5/6, -5/6, 7/6, -7/6, 11/6, -11/6, 13/6, -13/6, 17/6, -17/6, -19/6, -23/6, \\\n        -25/6, -29/6, -31/6, -35/6, -37/6, -41/6, ...]\",\n    );\n\n    helper(\n        \"1\",\n        \"-245850922/78256779\",\n        \"[-4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, \\\n        -22, -23, ...]\",\n    );\n    helper(\n        \"2\",\n        \"-245850922/78256779\",\n        \"[-7/2, -9/2, -11/2, -13/2, -15/2, -17/2, -19/2, -21/2, -23/2, -25/2, -27/2, -29/2, \\\n        -31/2, -33/2, -35/2, -37/2, -39/2, -41/2, -43/2, -45/2, ...]\",\n    );\n    helper(\n        \"3\",\n        \"-245850922/78256779\",\n        \"[-10/3, -11/3, -13/3, -14/3, -16/3, -17/3, -19/3, -20/3, -22/3, -23/3, -25/3, -26/3, \\\n        -28/3, -29/3, -31/3, -32/3, -34/3, -35/3, -37/3, -38/3, ...]\",\n    );\n    helper(\n        \"4\",\n        \"-245850922/78256779\",\n        \"[-13/4, -15/4, -17/4, -19/4, -21/4, -23/4, -25/4, -27/4, -29/4, -31/4, -33/4, -35/4, \\\n        -37/4, -39/4, -41/4, -43/4, -45/4, -47/4, -49/4, -51/4, ...]\",\n    );\n    helper(\n        \"5\",\n        \"-245850922/78256779\",\n        \"[-16/5, -17/5, -18/5, -19/5, -21/5, -22/5, -23/5, -24/5, -26/5, -27/5, -28/5, -29/5, \\\n        -31/5, -32/5, -33/5, -34/5, -36/5, -37/5, -38/5, -39/5, ...]\",\n    );\n    helper(\n        \"6\",\n        \"-245850922/78256779\",\n        \"[-19/6, -23/6, -25/6, -29/6, -31/6, -35/6, -37/6, -41/6, -43/6, -47/6, -49/6, -53/6, \\\n        -55/6, -59/6, -61/6, -65/6, -67/6, -71/6, -73/6, -77/6, ...]\",\n    );\n}\n\n#[test]\n#[should_panic]\nfn exhaustive_rationals_with_denominator_range_to_negative_infinity_fail() {\n    exhaustive_rationals_with_denominator_range_to_negative_infinity(\n        Natural::ZERO,\n        Rational::from_unsigneds(1u32, 3),\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/lib.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\n#![allow(\n    unstable_name_collisions,\n    clippy::bool_assert_comparison,\n    clippy::assertions_on_constants,\n    clippy::cognitive_complexity,\n    clippy::excessive_precision,\n    clippy::many_single_char_names,\n    clippy::range_plus_one,\n    clippy::suspicious_arithmetic_impl,\n    clippy::suspicious_op_assign_impl,\n    clippy::too_many_arguments,\n    clippy::float_cmp,\n    clippy::type_complexity\n)]\n#![warn(\n    clippy::cast_lossless,\n    clippy::explicit_into_iter_loop,\n    clippy::explicit_iter_loop,\n    clippy::filter_map_next,\n    clippy::large_digit_groups,\n    clippy::manual_filter_map,\n    clippy::manual_find_map,\n    clippy::map_flatten,\n    clippy::map_unwrap_or,\n    clippy::match_same_arms,\n    clippy::missing_const_for_fn,\n    clippy::mut_mut,\n    clippy::needless_borrow,\n    clippy::needless_continue,\n    clippy::needless_pass_by_value,\n    clippy::option_if_let_else,\n    clippy::print_stdout,\n    clippy::redundant_closure_for_method_calls,\n    clippy::single_match_else,\n    clippy::trait_duplication_in_bounds,\n    clippy::type_repetition_in_bounds,\n    clippy::uninlined_format_args,\n    clippy::unused_self,\n    clippy::if_not_else,\n    clippy::manual_assert,\n    clippy::range_plus_one,\n    clippy::redundant_else,\n    clippy::semicolon_if_nothing_returned,\n    clippy::cloned_instead_of_copied,\n    clippy::flat_map_option,\n    clippy::unnecessary_wraps,\n    clippy::unnested_or_patterns,\n    clippy::trivially_copy_pass_by_ref\n)]\n\nextern crate itertools;\n#[macro_use]\nextern crate malachite_base;\nextern crate malachite_nz;\nextern crate malachite_q;\nextern crate num;\nextern crate rug;\n\npub mod arithmetic {\n    pub mod abs;\n    pub mod abs_diff;\n    pub mod add;\n    pub mod approximate;\n    pub mod ceiling;\n    pub mod denominators_in_closed_interval;\n    pub mod div;\n    pub mod floor;\n    pub mod is_power_of_2;\n    pub mod log_base;\n    pub mod log_base_2;\n    pub mod log_base_power_of_2;\n    pub mod mod_op;\n    pub mod mul;\n    pub mod neg;\n    pub mod next_power_of_2;\n    pub mod pow;\n    pub mod power_of_2;\n    pub mod reciprocal;\n    pub mod root;\n    pub mod round_to_multiple;\n    pub mod round_to_multiple_of_power_of_2;\n    pub mod shl;\n    pub mod shr;\n    pub mod sign;\n    pub mod simplest_rational_in_interval;\n    pub mod sqrt;\n    pub mod square;\n    pub mod sub;\n}\npub mod basic {\n    pub mod constants;\n    pub mod default;\n    pub mod named;\n    pub mod significant_bits;\n    pub mod size;\n}\npub mod comparison {\n    pub mod cmp;\n    pub mod cmp_abs;\n    pub mod eq;\n    pub mod eq_abs;\n    pub mod eq_abs_integer;\n    pub mod eq_abs_natural;\n    pub mod eq_abs_primitive_float;\n    pub mod eq_abs_primitive_int;\n    pub mod hash;\n    pub mod partial_cmp_abs_integer;\n    pub mod partial_cmp_abs_natural;\n    pub mod partial_cmp_abs_primitive_float;\n    pub mod partial_cmp_abs_primitive_int;\n    pub mod partial_cmp_integer;\n    pub mod partial_cmp_natural;\n    pub mod partial_cmp_primitive_float;\n    pub mod partial_cmp_primitive_int;\n    pub mod partial_eq_integer;\n    pub mod partial_eq_natural;\n    pub mod partial_eq_primitive_float;\n    pub mod partial_eq_primitive_int;\n}\npub mod conversion {\n    pub mod clone;\n    pub mod continued_fraction {\n        pub mod convergents;\n        pub mod from_continued_fraction;\n        pub mod to_continued_fraction;\n    }\n    pub mod digits {\n        #[allow(clippy::module_inception)]\n        pub mod digits;\n        pub mod from_digits;\n        pub mod from_power_of_2_digits;\n        pub mod power_of_2_digits;\n        pub mod to_digits;\n        pub mod to_power_of_2_digits;\n    }\n    pub mod from_bool;\n    pub mod from_float_simplest;\n    pub mod from_integer;\n    pub mod from_natural;\n    pub mod from_numerator_and_denominator;\n    pub mod from_primitive_float;\n    pub mod from_primitive_int;\n    pub mod integer_from_rational;\n    pub mod is_integer;\n    pub mod mutate_numerator_or_denominator;\n    pub mod natural_from_rational;\n    pub mod primitive_float_from_rational;\n    pub mod primitive_int_from_rational;\n    pub mod sci_mantissa_and_exponent;\n    pub mod serde;\n    pub mod string {\n        pub mod from_sci_string;\n        pub mod from_string;\n        pub mod to_sci;\n        pub mod to_string;\n    }\n    pub mod to_numerator_or_denominator;\n}\npub mod exhaustive {\n    pub mod exhaustive_negative_rationals;\n    pub mod exhaustive_non_negative_rationals;\n    pub mod exhaustive_nonzero_rationals;\n    pub mod exhaustive_positive_rationals;\n    pub mod exhaustive_rational_inclusive_range;\n    pub mod exhaustive_rational_range;\n    pub mod exhaustive_rational_range_to_infinity;\n    pub mod exhaustive_rational_range_to_negative_infinity;\n    pub mod exhaustive_rationals;\n    pub mod exhaustive_rationals_with_denominator_inclusive_range;\n    pub mod exhaustive_rationals_with_denominator_range;\n    pub mod exhaustive_rationals_with_denominator_range_to_infinity;\n    pub mod exhaustive_rationals_with_denominator_range_to_negative_infinity;\n}\npub mod random {\n    pub mod random_negative_rationals;\n    pub mod random_non_negative_rationals;\n    pub mod random_nonzero_rationals;\n    pub mod random_positive_rationals;\n    pub mod random_rational_inclusive_range;\n    pub mod random_rational_range;\n    pub mod random_rational_range_to_infinity;\n    pub mod random_rational_range_to_negative_infinity;\n    pub mod random_rational_with_denominator_inclusive_range;\n    pub mod random_rational_with_denominator_range;\n    pub mod random_rational_with_denominator_range_to_infinity;\n    pub mod random_rational_with_denominator_range_to_negative_infinity;\n    pub mod random_rationals;\n    pub mod striped_random_negative_rationals;\n    pub mod striped_random_non_negative_rationals;\n    pub mod striped_random_nonzero_rationals;\n    pub mod striped_random_positive_rationals;\n    pub mod striped_random_rational_range_to_infinity;\n    pub mod striped_random_rational_range_to_negative_infinity;\n    pub mod striped_random_rationals;\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_negative_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::random_negative_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\nfn random_negative_rationals_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_negative_rationals(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_negative_rationals() {\n    // mean bits = 65/64\n    let values = &[\"-1\"; 20];\n    let common_values = &[\n        (\"-1\", 969573),\n        (\"-3\", 7488),\n        (\"-2\", 7484),\n        (\"-1/3\", 7459),\n        (\"-1/2\", 7391),\n        (\"-5\", 75),\n        (\"-6\", 67),\n        (\"-1/7\", 67),\n        (\"-2/3\", 64),\n        (\"-1/5\", 61),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0147365511904034),\n        standard_deviation: NiceFloat(0.21959420511046546),\n        skewness: NiceFloat(-8.77512842724579),\n        excess_kurtosis: NiceFloat(133.15117857730885),\n    };\n    random_negative_rationals_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-1/24\", \"-1/30\", \"-1/2\", \"-2\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\", \"-1\",\n        \"-1/7\", \"-2\", \"-19\", \"-1\", \"-4\", \"-3\", \"-1/2\",\n    ];\n    let common_values = &[\n        (\"-1\", 284707),\n        (\"-2\", 71334),\n        (\"-1/2\", 71222),\n        (\"-3\", 68255),\n        (\"-1/3\", 68142),\n        (\"-5\", 18020),\n        (\"-4\", 17749),\n        (\"-1/5\", 17746),\n        (\"-1/4\", 17705),\n        (\"-1/6\", 17245),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.527473854511467),\n        standard_deviation: NiceFloat(439.80801149679047),\n        skewness: NiceFloat(-309.19213173617015),\n        excess_kurtosis: NiceFloat(131113.5392046833),\n    };\n    random_negative_rationals_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-11/2\",\n        \"-89/27922830575\",\n        \"-46627409/3788983764809694\",\n        \"-8/11316951483471\",\n        \"-11/1005760138411689342464923704482\",\n        \"-948931/42716754\",\n        \"-81013760999253680590984897748479904878392/23\",\n        \"-1/97645164585502\",\n        \"-1558028859598/29\",\n        \"-200127331174844881647/4058622214797175252\",\n        \"-155/1413\",\n        \"-24470495/285805200646849943\",\n        \"-18939240741294741985527157685848850947887212663091378627/3070040\",\n        \"-545942890259/414324415\",\n        \"-4/209925\",\n        \"-128959877500520349/1134718\",\n        \"-2/424578084893903\",\n        \"-1956237739171878131383877\",\n        \"-17054902546906498751130/7\",\n        \"-782845/239707736\",\n    ];\n    let common_values = &[\n        (\"-1\", 1810),\n        (\"-1/2\", 922),\n        (\"-2\", 915),\n        (\"-3\", 809),\n        (\"-1/3\", 776),\n        (\"-1/4\", 470),\n        (\"-4\", 426),\n        (\"-1/5\", 412),\n        (\"-5\", 409),\n        (\"-2/3\", 386),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.2380948358914507e127),\n        standard_deviation: NiceFloat(2.2380948357494794e130),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_rationals_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-515152389601430248907720412245595/443042512729\",\n        \"-103663/41795133908582491293103906323025\",\n        \"-71296091098068019359037078314906341733724/243288956813821163751969634165018193\",\n        \"-5557920650918595/82\",\n        \"-487/32461763914959248855\",\n        \"-38511521798151392412656616617957654586378660839/637134\",\n        \"-2330568192653124764618470467652346596061/2516\",\n        \"-512663303/39317568409\",\n        \"-18536901993439/4959577657266999117207\",\n        \"-628/42485719907732979\",\n        \"-7403291719610544/1075307073896295169983034533112645563410195\",\n        \"-4797445/61\",\n        \"-127/13433407097045810\",\n        \"-30/1953914271219269\",\n        \"-37383453968917/610\",\n        \"-11479816781573453/2848901582\",\n        \"-2509812009985965380927298501595/13645002946929029896\",\n        \"-409735863893015988549887290441890365889795673/6863841\",\n        \"-359602127218795816494928857777/9159832300555\",\n        \"-142029094679916682/85936648268932530864438001\",\n    ];\n    let common_values = &[\n        (\"-1\", 478),\n        (\"-2\", 241),\n        (\"-3\", 218),\n        (\"-1/2\", 218),\n        (\"-1/3\", 204),\n        (\"-1/4\", 115),\n        (\"-1/7\", 106),\n        (\"-2/3\", 106),\n        (\"-4\", 103),\n        (\"-5\", 103),\n    ];\n    let sample_median = (\"-3568/3547\", Some(\"-1942164762009/1930873766009\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-6.065823121451175e234),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_negative_rationals_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_negative_rationals_fail_1() {\n    random_negative_rationals(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_negative_rationals_fail_2() {\n    random_negative_rationals(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_non_negative_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::random_non_negative_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\nfn random_non_negative_rationals_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_non_negative_rationals(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_non_negative_rationals() {\n    // mean bits = 65/64\n    let values = &[\n        \"0\", \"0\", \"0\", \"2\", \"0\", \"0\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"28\", \"1\", \"4\", \"1\",\n        \"1\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 496048),\n        (\"1\", 247640),\n        (\"3\", 62242),\n        (\"2\", 61902),\n        (\"4\", 15714),\n        (\"7\", 15554),\n        (\"6\", 15541),\n        (\"5\", 15493),\n        (\"8\", 4052),\n        (\"11\", 4013),\n    ];\n    let sample_median = (\"2/3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.803726415872939),\n        standard_deviation: NiceFloat(857.0035840628179),\n        skewness: NiceFloat(473.2359523744428),\n        excess_kurtosis: NiceFloat(254290.48263912715),\n    };\n    random_non_negative_rationals_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"1\", \"5/3\", \"0\", \"1\", \"0\", \"1/2\", \"356\", \"0\", \"0\", \"3/2\", \"3/5\", \"14/3\", \"0\", \"1/3\",\n        \"19/3\", \"1/2\", \"0\", \"1\", \"0\", \"10\",\n    ];\n    let common_values = &[\n        (\"0\", 333130),\n        (\"1\", 133186),\n        (\"2\", 44272),\n        (\"3\", 41733),\n        (\"1/2\", 33380),\n        (\"1/3\", 31211),\n        (\"4\", 14811),\n        (\"5\", 14622),\n        (\"6\", 13959),\n        (\"7\", 13895),\n    ];\n    let sample_median = (\"2/3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(13891.174382080539),\n        standard_deviation: NiceFloat(5451707.141191459),\n        skewness: NiceFloat(576.0667309545814),\n        excess_kurtosis: NiceFloat(353958.67367137416),\n    };\n    random_non_negative_rationals_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"7301/34\",\n        \"4183103/1234731190583\",\n        \"54812347098686/6195807891591254727\",\n        \"812739/17841539017\",\n        \"665/908\",\n        \"677/1138982845180\",\n        \"166/22491855393807861245619791028129\",\n        \"270142/5\",\n        \"52040856788711439301087669967/15975369961878544862054\",\n        \"5718607/1953563256716085077\",\n        \"8834633494449605/147372515680891813385292082245912643739605046366\",\n        \"14860658876333535410753934016237/38209564041\",\n        \"256/1033317698721\",\n        \"1675/34808324932084086743491848009\",\n        \"49\",\n        \"42/5\",\n        \"87750175104578/19615\",\n        \"1/4767944\",\n        \"137819495256811446350/41779\",\n        \"2/187\",\n    ];\n    let common_values = &[\n        (\"0\", 30369),\n        (\"1\", 1800),\n        (\"1/2\", 822),\n        (\"2\", 818),\n        (\"1/3\", 705),\n        (\"3\", 699),\n        (\"5\", 399),\n        (\"1/4\", 390),\n        (\"4\", 382),\n        (\"1/5\", 380),\n    ];\n    let sample_median = (\"84579/122161\", Some(\"1013/1463\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0180317983547227e148),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_non_negative_rationals_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1428130618501/11392923974388402817057849552586132522617914732498530\",\n        \"3383508417938165445131453/56779550950694809089378809702538209946934076252940714133449\",\n        \"602900875601911171470306076355/119191771\",\n        \"3/14013585568406836752167657664673\",\n        \"760776403/6462405519227986816335721703034929571679921\",\n        \"3453088342103851715673829426753969982/25626510185\",\n        \"1747398675/3172739\",\n        \"8948691991346583905040602549520967352911/18\",\n        \"16038312634753050980603803559756/9438855467532928850187287\",\n        \"155434788890251/4034446723\",\n        \"950902359766673/235910534939055966292926793\",\n        \"294004238713694270841854/1596165279\",\n        \"1030393/85299778977201964065475016444620\",\n        \"124218250251176079819064/503926103984580328155607497147\",\n        \"277206127786809155854294/47228889692473\",\n        \"3673/301956358739051815786302694193\",\n        \"166239031838/39\",\n        \"3309620973011864735684788/31306944615\",\n        \"138546001637/6539404996772746726586649886838863596921111\",\n        \"417/14077532426874196091229260728580\",\n    ];\n    let common_values = &[\n        (\"0\", 15382),\n        (\"1\", 433),\n        (\"2\", 245),\n        (\"1/2\", 232),\n        (\"1/3\", 213),\n        (\"3\", 198),\n        (\"4\", 118),\n        (\"5\", 114),\n        (\"2/3\", 114),\n        (\"1/5\", 111),\n    ];\n    let sample_median = (\"25421/36471\", Some(\"486/697\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.459352389355579e272),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_non_negative_rationals_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_rationals_fail_1() {\n    random_non_negative_rationals(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_non_negative_rationals_fail_2() {\n    random_non_negative_rationals(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_nonzero_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::random_nonzero_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\nfn random_nonzero_rationals_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_nonzero_rationals(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_nonzero_rationals() {\n    // mean bits = 65/64\n    let values = &[\n        \"-1\", \"-1\", \"1\", \"1\", \"-1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"-1\", \"1\", \"-1\", \"-1\", \"-1\",\n        \"-1\", \"-1\", \"-1\", \"-1\",\n    ];\n    let common_values = &[\n        (\"-1\", 484924),\n        (\"1\", 484658),\n        (\"3\", 3815),\n        (\"1/3\", 3811),\n        (\"-1/3\", 3747),\n        (\"-2\", 3743),\n        (\"1/2\", 3740),\n        (\"-1/2\", 3695),\n        (\"2\", 3664),\n        (\"-3\", 3591),\n    ];\n    let sample_median = (\"-1/7\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.000309218589743558),\n        standard_deviation: NiceFloat(1.0376177116118968),\n        skewness: NiceFloat(0.006166050703241532),\n        excess_kurtosis: NiceFloat(-1.2860190331216774),\n    };\n    random_nonzero_rationals_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-8\", \"-1/7\", \"5\", \"1/3\", \"-1\", \"1/5\", \"1\", \"5\", \"1/26\", \"5/3\", \"1/2\", \"-3\", \"2\", \"-1/10\",\n        \"-13/5\", \"-1/81\", \"-33\", \"-21\", \"-9/13\", \"-1\",\n    ];\n    let common_values = &[\n        (\"1\", 143164),\n        (\"-1\", 142719),\n        (\"-2\", 35933),\n        (\"1/2\", 35874),\n        (\"-1/2\", 35720),\n        (\"2\", 35231),\n        (\"3\", 34254),\n        (\"-1/3\", 34198),\n        (\"-3\", 34081),\n        (\"1/3\", 34031),\n    ];\n    let sample_median = (\"-1/14021\", Some(\"-1/14079\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.22120311344442486),\n        standard_deviation: NiceFloat(759.898347425165),\n        skewness: NiceFloat(85.37622949885149),\n        excess_kurtosis: NiceFloat(197537.4297586209),\n    };\n    random_nonzero_rationals_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-80861953616/9687130509484985\",\n        \"-14557437513/313\",\n        \"100721397389/392237929981\",\n        \"713431423/1285\",\n        \"-3887883364/889\",\n        \"14185/969\",\n        \"12609/11359517108746272468338071\",\n        \"3443/4354945\",\n        \"1/29\",\n        \"5551/892095\",\n        \"10/105173604567\",\n        \"-19537757974145/22970361\",\n        \"260/571\",\n        \"-129425842/844581\",\n        \"-11400586904841764775819697763820861082775967865/619503489\",\n        \"-640859665273/199255145279143029\",\n        \"-15530559035875594619912/1323170930793965328781\",\n        \"-943/46106\",\n        \"-1/113\",\n        \"-58/1217\",\n    ];\n    let common_values = &[\n        (\"1\", 940),\n        (\"-1\", 916),\n        (\"1/2\", 463),\n        (\"-2\", 458),\n        (\"2\", 454),\n        (\"-1/2\", 435),\n        (\"1/3\", 391),\n        (\"-1/3\", 389),\n        (\"3\", 382),\n        (\"-3\", 367),\n    ];\n    let sample_median = (\n        \"-56/1571996361141158873691832735034843333252522256904712087971186761383651552863627257507\\\n        9059423061\",\n        Some(\n            \"-322364/3099957057369745737816290559529344769064121899362905191001555856493272865037\\\n            24517150128896230616971\",\n        ),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.221976926004828e140),\n        standard_deviation: NiceFloat(2.2219769258579568e143),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_rationals_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-48553528129227068854128246488656/36214055281593228106459\",\n        \"-22071489/37044301297\",\n        \"255/542981\",\n        \"9316/1012576106433925497\",\n        \"-1664715/130027\",\n        \"76455368490844554617/2980153660384121645\",\n        \"80116271334543/93897057958828250698\",\n        \"506747611059054706907067367541552559/130\",\n        \"3325802517091555255861282341611/45079787663689587397296114\",\n        \"2619/25010\",\n        \"138524171232037/57\",\n        \"-327554224783124113092/16778017845503481359721357185\",\n        \"8702051241754639477/3724642828701481585672\",\n        \"-1137052310060943639222669/10603652863466943873570746520875421824929696768184798584\",\n        \"-273682512911798198562097/1410\",\n        \"-19469521047938950017/8215425900326016767087299690926901706491788211\",\n        \"-7582001356264120926498825684258819/24285551\",\n        \"-858560112398451899225/359\",\n        \"-649287191321577133137936520213146643215345718495684792790/7529\",\n        \"-32944218852544/20849367593547441115716222574535971210798382851\",\n    ];\n    let common_values = &[\n        (\"-1\", 252),\n        (\"1\", 230),\n        (\"1/2\", 142),\n        (\"2\", 127),\n        (\"3\", 108),\n        (\"-2\", 105),\n        (\"-3\", 102),\n        (\"1/3\", 101),\n        (\"-1/3\", 94),\n        (\"-1/2\", 91),\n    ];\n    let sample_median = (\n        \"-15668175538278751/5533317337571469966334347182083533508129248736899312345519768644568022\\\n        940401012659857427367497110049027936099115261493004685012826642110638291331832674475090998\\\n        50592299336680480845705995316128005975675\",\n        Some(\n            \"-52/545401271867319824074151466637070353812934757165212163414335060581060990607232033\\\n            27440868128671504241123333342761624433358162265204129676361103528857606120262656465655\\\n            47492357491745108315\",\n        ),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.683252966255455e252),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_nonzero_rationals_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_rationals_fail_1() {\n    random_nonzero_rationals(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_nonzero_rationals_fail_2() {\n    random_nonzero_rationals(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_positive_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::random_positive_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\nfn random_positive_rationals_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_positive_rationals(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_positive_rationals() {\n    // mean bits = 65/64\n    let values = &[\"1\"; 20];\n    let common_values = &[\n        (\"1\", 969573),\n        (\"3\", 7488),\n        (\"2\", 7484),\n        (\"1/3\", 7459),\n        (\"1/2\", 7391),\n        (\"5\", 75),\n        (\"6\", 67),\n        (\"1/7\", 67),\n        (\"2/3\", 64),\n        (\"1/5\", 61),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0147365511904034),\n        standard_deviation: NiceFloat(0.21959420511046546),\n        skewness: NiceFloat(8.77512842724579),\n        excess_kurtosis: NiceFloat(133.15117857730885),\n    };\n    random_positive_rationals_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"1/24\", \"1/30\", \"1/2\", \"2\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1/7\", \"2\", \"19\",\n        \"1\", \"4\", \"3\", \"1/2\",\n    ];\n    let common_values = &[\n        (\"1\", 284707),\n        (\"2\", 71334),\n        (\"1/2\", 71222),\n        (\"3\", 68255),\n        (\"1/3\", 68142),\n        (\"5\", 18020),\n        (\"4\", 17749),\n        (\"1/5\", 17746),\n        (\"1/4\", 17705),\n        (\"1/6\", 17245),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.527473854511467),\n        standard_deviation: NiceFloat(439.80801149679047),\n        skewness: NiceFloat(309.19213173617015),\n        excess_kurtosis: NiceFloat(131113.5392046833),\n    };\n    random_positive_rationals_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"11/2\",\n        \"89/27922830575\",\n        \"46627409/3788983764809694\",\n        \"8/11316951483471\",\n        \"11/1005760138411689342464923704482\",\n        \"948931/42716754\",\n        \"81013760999253680590984897748479904878392/23\",\n        \"1/97645164585502\",\n        \"1558028859598/29\",\n        \"200127331174844881647/4058622214797175252\",\n        \"155/1413\",\n        \"24470495/285805200646849943\",\n        \"18939240741294741985527157685848850947887212663091378627/3070040\",\n        \"545942890259/414324415\",\n        \"4/209925\",\n        \"128959877500520349/1134718\",\n        \"2/424578084893903\",\n        \"1956237739171878131383877\",\n        \"17054902546906498751130/7\",\n        \"782845/239707736\",\n    ];\n    let common_values = &[\n        (\"1\", 1810),\n        (\"1/2\", 922),\n        (\"2\", 915),\n        (\"3\", 809),\n        (\"1/3\", 776),\n        (\"1/4\", 470),\n        (\"4\", 426),\n        (\"1/5\", 412),\n        (\"5\", 409),\n        (\"2/3\", 386),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.2380948358914507e127),\n        standard_deviation: NiceFloat(2.2380948357494794e130),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_rationals_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"515152389601430248907720412245595/443042512729\",\n        \"103663/41795133908582491293103906323025\",\n        \"71296091098068019359037078314906341733724/243288956813821163751969634165018193\",\n        \"5557920650918595/82\",\n        \"487/32461763914959248855\",\n        \"38511521798151392412656616617957654586378660839/637134\",\n        \"2330568192653124764618470467652346596061/2516\",\n        \"512663303/39317568409\",\n        \"18536901993439/4959577657266999117207\",\n        \"628/42485719907732979\",\n        \"7403291719610544/1075307073896295169983034533112645563410195\",\n        \"4797445/61\",\n        \"127/13433407097045810\",\n        \"30/1953914271219269\",\n        \"37383453968917/610\",\n        \"11479816781573453/2848901582\",\n        \"2509812009985965380927298501595/13645002946929029896\",\n        \"409735863893015988549887290441890365889795673/6863841\",\n        \"359602127218795816494928857777/9159832300555\",\n        \"142029094679916682/85936648268932530864438001\",\n    ];\n    let common_values = &[\n        (\"1\", 478),\n        (\"2\", 241),\n        (\"3\", 218),\n        (\"1/2\", 218),\n        (\"1/3\", 204),\n        (\"1/4\", 115),\n        (\"1/7\", 106),\n        (\"2/3\", 106),\n        (\"4\", 103),\n        (\"5\", 103),\n    ];\n    let sample_median = (\"1942164762009/1930873766009\", Some(\"3568/3547\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(6.065823121451175e234),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_positive_rationals_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_positive_rationals_fail_1() {\n    random_positive_rationals(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_positive_rationals_fail_2() {\n    random_positive_rationals(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_inclusive_range;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_inclusive_range_helper(\n    a: &str,\n    b: &str,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n    mean_denominator_index_numerator: u64,\n    mean_denominator_index_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_inclusive_range(\n            EXAMPLE_SEED,\n            Rational::from_str(a).unwrap(),\n            Rational::from_str(b).unwrap(),\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n            mean_denominator_index_numerator,\n            mean_denominator_index_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_inclusive_range() {\n    let values = &[\n        \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\",\n        \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\", \"1/3\",\n    ];\n    let common_values = &[(\"1/3\", 1000000)];\n    let sample_median = (\"1/3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.3333333333333333),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_inclusive_range_helper(\n        \"1/3\",\n        \"1/3\",\n        10,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"0\", \"1/2\", \"0\", \"1\", \"0\", \"0\", \"1\", \"0\", \"1/2\", \"1\", \"1/2\", \"1\", \"1/3\", \"0\", \"1/2\", \"1/2\",\n        \"1/3\", \"1\", \"1/6\", \"1\",\n    ];\n    let common_values = &[\n        (\"0\", 262055),\n        (\"1/2\", 249730),\n        (\"1\", 237742),\n        (\"1/3\", 86236),\n        (\"1/4\", 42606),\n        (\"2/3\", 39168),\n        (\"3/4\", 19633),\n        (\"1/5\", 13421),\n        (\"1/6\", 12245),\n        (\"3/5\", 6206),\n    ];\n    let sample_median = (\"1/2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.46651895490175377),\n        standard_deviation: NiceFloat(0.3690116747518855),\n        skewness: NiceFloat(0.18424550073715937),\n        excess_kurtosis: NiceFloat(-1.2512329853066777),\n    };\n    random_rational_inclusive_range_helper(\n        \"0\",\n        \"1\",\n        10,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/2\", \"1/6\", \"0\", \"11/15\", \"1/9\", \"1/24\", \"0\", \"1/6\", \"1\", \"7/10\", \"14/15\", \"4/29\", \"0\",\n        \"3/13\", \"1/3\", \"10/29\", \"17/18\", \"0\", \"1\", \"1/8\",\n    ];\n    let common_values = &[\n        (\"1/2\", 82681),\n        (\"1/3\", 51495),\n        (\"0\", 47408),\n        (\"1/4\", 46547),\n        (\"1/6\", 44587),\n        (\"1\", 43387),\n        (\"1/5\", 26408),\n        (\"1/8\", 24875),\n        (\"2/3\", 23502),\n        (\"3/4\", 21468),\n    ];\n    let sample_median = (\"4/15\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.3574859107909007),\n        standard_deviation: NiceFloat(0.29213805168114404),\n        skewness: NiceFloat(0.7340743758337255),\n        excess_kurtosis: NiceFloat(-0.6079435842676566),\n    };\n    random_rational_inclusive_range_helper(\n        \"0\",\n        \"1\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/2\", \"1/3\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/3\", \"1/2\", \"1/3\", \"1/2\", \"2/5\",\n        \"1/2\", \"1/3\", \"1/3\", \"2/5\", \"1/2\", \"4/9\", \"1/2\",\n    ];\n    let common_values = &[\n        (\"1/2\", 499797),\n        (\"1/3\", 249730),\n        (\"2/5\", 125404),\n        (\"3/7\", 62239),\n        (\"3/8\", 31351),\n        (\"4/9\", 15620),\n        (\"5/11\", 4024),\n        (\"4/11\", 3989),\n        (\"5/12\", 3856),\n        (\"6/13\", 1003),\n    ];\n    let sample_median = (\"7/15\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.43521234958930916),\n        standard_deviation: NiceFloat(0.0706863774046333),\n        skewness: NiceFloat(-0.40352004419103704),\n        excess_kurtosis: NiceFloat(-1.5393678543556049),\n    };\n    random_rational_inclusive_range_helper(\n        \"1/3\",\n        \"1/2\",\n        10,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/3\", \"4/9\", \"1/2\", \"9/19\", \"5/13\", \"13/28\", \"1/2\", \"4/9\", \"1/2\", \"5/14\", \"9/19\", \"14/33\",\n        \"1/2\", \"8/17\", \"2/5\", \"14/33\", \"9/22\", \"1/2\", \"1/2\", \"5/12\",\n    ];\n    let common_values = &[\n        (\"1/2\", 90795),\n        (\"1/3\", 82681),\n        (\"2/5\", 74997),\n        (\"3/7\", 68015),\n        (\"3/8\", 61965),\n        (\"4/9\", 56891),\n        (\"5/12\", 46440),\n        (\"5/14\", 38639),\n        (\"7/15\", 35083),\n        (\"7/16\", 31926),\n    ];\n    let sample_median = (\"5/12\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.4146806356838901),\n        standard_deviation: NiceFloat(0.04970657076728507),\n        skewness: NiceFloat(0.05385178173988354),\n        excess_kurtosis: NiceFloat(-1.0272575619229356),\n    };\n    random_rational_inclusive_range_helper(\n        \"1/3\",\n        \"1/2\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"3\", \"11/4\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"11/4\", \"3\", \"11/4\", \"3\", \"14/5\", \"3\", \"11/4\",\n        \"11/4\", \"14/5\", \"3\", \"25/8\", \"3\",\n    ];\n    let common_values = &[\n        (\"3\", 499797),\n        (\"11/4\", 249730),\n        (\"14/5\", 125404),\n        (\"17/6\", 62239),\n        (\"20/7\", 31351),\n        (\"23/8\", 7872),\n        (\"25/8\", 7748),\n        (\"25/9\", 2675),\n        (\"28/9\", 2671),\n        (\"26/9\", 2667),\n    ];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.8966573835412754),\n        standard_deviation: NiceFloat(0.11355671930910265),\n        skewness: NiceFloat(-0.15916553020077587),\n        excess_kurtosis: NiceFloat(-1.693978851875664),\n    };\n    random_rational_inclusive_range_helper(\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"11/4\", \"25/8\", \"3\", \"52/17\", \"30/11\", \"79/26\", \"3\", \"25/8\", \"3\", \"35/12\", \"50/17\",\n        \"92/31\", \"3\", \"46/15\", \"14/5\", \"91/31\", \"57/20\", \"3\", \"3\", \"29/10\",\n    ];\n    let common_values = &[\n        (\"3\", 90795),\n        (\"11/4\", 82681),\n        (\"14/5\", 74997),\n        (\"17/6\", 68015),\n        (\"20/7\", 61965),\n        (\"25/8\", 28541),\n        (\"23/8\", 28350),\n        (\"29/10\", 23236),\n        (\"31/10\", 23204),\n        (\"37/12\", 19335),\n    ];\n    let sample_median = (\"23/8\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9061506622897797),\n        standard_deviation: NiceFloat(0.12219692502115352),\n        skewness: NiceFloat(0.3585054332079069),\n        excess_kurtosis: NiceFloat(-1.1302487991867385),\n    };\n    random_rational_inclusive_range_helper(\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_inclusive_range_fail_1() {\n    random_rational_inclusive_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        0,\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_inclusive_range_fail_2() {\n    random_rational_inclusive_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        0,\n        0,\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_inclusive_range_fail_3() {\n    random_rational_inclusive_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        1,\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_inclusive_range_fail_4() {\n    random_rational_inclusive_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        1,\n        0,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_inclusive_range_fail_5() {\n    random_rational_inclusive_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 2),\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n        1,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_range;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_range_helper(\n    a: &str,\n    b: &str,\n    mean_numerator_bits_numerator: u64,\n    mean_numerator_bits_denominator: u64,\n    mean_denominator_index_numerator: u64,\n    mean_denominator_index_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_range(\n            EXAMPLE_SEED,\n            Rational::from_str(a).unwrap(),\n            Rational::from_str(b).unwrap(),\n            mean_numerator_bits_numerator,\n            mean_numerator_bits_denominator,\n            mean_denominator_index_numerator,\n            mean_denominator_index_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_range() {\n    let values = &[\n        \"0\", \"1/2\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"1/2\", \"0\", \"1/2\", \"0\", \"1/3\", \"0\", \"1/2\", \"1/2\",\n        \"1/3\", \"0\", \"1/6\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 499797),\n        (\"1/2\", 249730),\n        (\"1/3\", 86236),\n        (\"1/4\", 42606),\n        (\"2/3\", 39168),\n        (\"3/4\", 19633),\n        (\"1/5\", 13421),\n        (\"1/6\", 12245),\n        (\"3/5\", 6206),\n        (\"2/5\", 6141),\n    ];\n    let sample_median = (\"1/12\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.22877695490175154),\n        standard_deviation: NiceFloat(0.2524452096013498),\n        skewness: NiceFloat(0.4918767315871824),\n        excess_kurtosis: NiceFloat(-1.2397727721157625),\n    };\n    random_rational_range_helper(\n        \"0\",\n        \"1\",\n        10,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/2\", \"1/6\", \"0\", \"11/15\", \"1/9\", \"1/24\", \"0\", \"1/6\", \"0\", \"7/10\", \"14/15\", \"4/29\", \"0\",\n        \"3/13\", \"1/3\", \"10/29\", \"17/18\", \"0\", \"0\", \"1/8\",\n    ];\n    let common_values = &[\n        (\"0\", 90795),\n        (\"1/2\", 82681),\n        (\"1/3\", 51495),\n        (\"1/4\", 46547),\n        (\"1/6\", 44587),\n        (\"1/5\", 26408),\n        (\"1/8\", 24875),\n        (\"2/3\", 23502),\n        (\"3/4\", 21468),\n        (\"1/12\", 20489),\n    ];\n    let sample_median = (\"1/4\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.3140989107909008),\n        standard_deviation: NiceFloat(0.26663772734754415),\n        skewness: NiceFloat(0.7462991500757579),\n        excess_kurtosis: NiceFloat(-0.5495263431182642),\n    };\n    random_rational_range_helper(\n        \"0\",\n        \"1\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/3\", \"1/3\", \"1/3\", \"2/5\", \"1/3\", \"1/3\", \"2/5\", \"4/9\", \"1/3\", \"3/7\", \"2/5\", \"1/3\", \"2/5\",\n        \"1/3\", \"1/3\", \"5/13\", \"1/3\", \"1/3\", \"2/5\", \"1/3\",\n    ];\n    let common_values = &[\n        (\"1/3\", 499619),\n        (\"2/5\", 250775),\n        (\"3/7\", 125038),\n        (\"3/8\", 62105),\n        (\"4/9\", 31072),\n        (\"5/11\", 7939),\n        (\"4/11\", 7842),\n        (\"5/12\", 7736),\n        (\"6/13\", 1984),\n        (\"5/14\", 1928),\n    ];\n    let sample_median = (\"5/14\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.3704726750344205),\n        standard_deviation: NiceFloat(0.04006148834460584),\n        skewness: NiceFloat(0.4071245940784675),\n        excess_kurtosis: NiceFloat(-1.377512459092156),\n    };\n    random_rational_range_helper(\n        \"1/3\",\n        \"1/2\",\n        10,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/3\", \"4/9\", \"9/19\", \"5/13\", \"13/28\", \"4/9\", \"5/14\", \"9/19\", \"14/33\", \"8/17\", \"2/5\",\n        \"14/33\", \"9/22\", \"5/12\", \"3/8\", \"5/12\", \"4/9\", \"14/33\", \"3/7\", \"9/23\",\n    ];\n    let common_values = &[\n        (\"1/3\", 90947),\n        (\"2/5\", 82548),\n        (\"3/7\", 74875),\n        (\"3/8\", 68126),\n        (\"4/9\", 62503),\n        (\"5/12\", 51079),\n        (\"5/14\", 42543),\n        (\"7/15\", 38588),\n        (\"7/16\", 35069),\n        (\"7/18\", 28933),\n    ];\n    let sample_median = (\"11/27\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.4061491128373723),\n        standard_deviation: NiceFloat(0.04379766958185411),\n        skewness: NiceFloat(-0.06037812600265093),\n        excess_kurtosis: NiceFloat(-1.1137203231085004),\n    };\n    random_rational_range_helper(\n        \"1/3\",\n        \"1/2\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"3\", \"11/4\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"11/4\", \"3\", \"11/4\", \"3\", \"14/5\", \"3\", \"11/4\",\n        \"11/4\", \"14/5\", \"3\", \"25/8\", \"3\",\n    ];\n    let common_values = &[\n        (\"3\", 499797),\n        (\"11/4\", 249730),\n        (\"14/5\", 125404),\n        (\"17/6\", 62239),\n        (\"20/7\", 31351),\n        (\"23/8\", 7872),\n        (\"25/8\", 7748),\n        (\"25/9\", 2675),\n        (\"28/9\", 2671),\n        (\"26/9\", 2667),\n    ];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.8966573835412754),\n        standard_deviation: NiceFloat(0.11355671930910265),\n        skewness: NiceFloat(-0.15916553020077587),\n        excess_kurtosis: NiceFloat(-1.693978851875664),\n    };\n    random_rational_range_helper(\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        1,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"11/4\", \"25/8\", \"3\", \"52/17\", \"30/11\", \"79/26\", \"3\", \"25/8\", \"3\", \"35/12\", \"50/17\",\n        \"92/31\", \"3\", \"46/15\", \"14/5\", \"91/31\", \"57/20\", \"3\", \"3\", \"29/10\",\n    ];\n    let common_values = &[\n        (\"3\", 90795),\n        (\"11/4\", 82681),\n        (\"14/5\", 74997),\n        (\"17/6\", 68015),\n        (\"20/7\", 61965),\n        (\"25/8\", 28541),\n        (\"23/8\", 28350),\n        (\"29/10\", 23236),\n        (\"31/10\", 23204),\n        (\"37/12\", 19335),\n    ];\n    let sample_median = (\"23/8\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.9061506622897797),\n        standard_deviation: NiceFloat(0.12219692502115352),\n        skewness: NiceFloat(0.3585054332079069),\n        excess_kurtosis: NiceFloat(-1.1302487991867385),\n    };\n    random_rational_range_helper(\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/3\", \"4/9\", \"7/19\", \"5/13\", \"13/28\", \"4/9\", \"5/14\", \"7/19\", \"14/33\", \"8/17\", \"2/5\",\n        \"16/33\", \"9/22\", \"5/12\", \"3/8\", \"5/12\", \"4/9\", \"14/33\", \"3/7\", \"9/23\",\n    ];\n    let common_values = &[\n        (\"1/3\", 90947),\n        (\"2/5\", 82548),\n        (\"3/7\", 74875),\n        (\"3/8\", 68126),\n        (\"4/9\", 62503),\n        (\"5/12\", 51079),\n        (\"5/14\", 42543),\n        (\"7/15\", 38588),\n        (\"7/16\", 35069),\n        (\"7/18\", 28933),\n    ];\n    let sample_median = (\"13/32\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.4056622022625132),\n        standard_deviation: NiceFloat(0.04370473197429072),\n        skewness: NiceFloat(-0.04788831075607498),\n        excess_kurtosis: NiceFloat(-1.1147841677775145),\n    };\n    random_rational_range_helper(\n        \"1/3\",\n        \"1/2\",\n        3,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_fail_1() {\n    random_rational_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        0,\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_fail_2() {\n    random_rational_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        0,\n        0,\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_fail_3() {\n    random_rational_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        1,\n        1,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_fail_4() {\n    random_rational_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        1,\n        0,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_fail_5() {\n    random_rational_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n        1,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_fail_6() {\n    random_rational_range(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 2),\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n        1,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_range_to_infinity;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_range_to_infinity_helper(\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_range_to_infinity(\n            EXAMPLE_SEED,\n            Rational::from_str(a).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_range_to_infinity() {\n    let values = &[\n        \"438/953\",\n        \"4248\",\n        \"6259791/632\",\n        \"99/2\",\n        \"34/87\",\n        \"5/3\",\n        \"3\",\n        \"233500344/25\",\n        \"45/2168\",\n        \"2/3\",\n        \"1\",\n        \"194403055/2031\",\n        \"1799/72\",\n        \"162713/14\",\n        \"1/31\",\n        \"25413015/7691773\",\n        \"243/3260\",\n        \"2/1895\",\n        \"261/252386\",\n        \"3997/36893154\",\n    ];\n    let common_values = &[\n        (\"0\", 8410),\n        (\"1\", 7679),\n        (\"1/2\", 6403),\n        (\"1/3\", 5093),\n        (\"1/6\", 4068),\n        (\"3\", 3591),\n        (\"2\", 3472),\n        (\"3/2\", 2895),\n        (\"1/4\", 2642),\n        (\"2/3\", 2350),\n    ];\n    let sample_median = (\"56059/1740\", Some(\"6303352/195639\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.839214579009629e215),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_range_to_infinity_helper(\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"121396406/953\",\n        \"152\",\n        \"99407/632\",\n        \"99/2\",\n        \"436/87\",\n        \"11/3\",\n        \"451\",\n        \"97/25\",\n        \"764903/2168\",\n        \"14253863309/3\",\n        \"6\",\n        \"19165/2031\",\n        \"3847/72\",\n        \"7065/14\",\n        \"360014815/31\",\n        \"20728497559/7691773\",\n        \"13813/3260\",\n        \"221536/1895\",\n        \"1651717/252386\",\n        \"828014364376645/36893154\",\n    ];\n    let common_values = &[\n        (\"7/2\", 8108),\n        (\"5\", 2819),\n        (\"6\", 2789),\n        (\"7\", 2788),\n        (\"4\", 2727),\n        (\"11/3\", 1331),\n        (\"11\", 1302),\n        (\"14/3\", 1302),\n        (\"15\", 1299),\n        (\"15/4\", 1299),\n    ];\n    let sample_median = (\"5632495/34508\", Some(\"12647038/77483\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.5244840655472015e31),\n        standard_deviation: NiceFloat(1.4418360146531462e34),\n        skewness: NiceFloat(995.0794447771476),\n        excess_kurtosis: NiceFloat(993187.6643660564),\n    };\n    random_rational_range_to_infinity_helper(\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"3983598880556866742/953\",\n        \"-1\",\n        \"48202831/632\",\n        \"99/2\",\n        \"10/87\",\n        \"-8/3\",\n        \"15043\",\n        \"7793790546/25\",\n        \"-7/2168\",\n        \"191126/3\",\n        \"2\",\n        \"1110539913949/2031\",\n        \"416495/72\",\n        \"125991833/14\",\n        \"3039/31\",\n        \"20728497559/7691773\",\n        \"7/3260\",\n        \"16/1895\",\n        \"-1/252386\",\n        \"-149405/36893154\",\n    ];\n    let common_values = &[\n        (\"0\", 7260),\n        (\"-1\", 6845),\n        (\"1\", 6673),\n        (\"-1/2\", 5123),\n        (\"1/2\", 5089),\n        (\"-1/3\", 4054),\n        (\"1/3\", 4037),\n        (\"2\", 3132),\n        (\"3\", 3086),\n        (\"-3\", 3014),\n    ];\n    let sample_median = (\"120/143\", Some(\"167/199\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.8672643518545765e150),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_range_to_infinity_helper(\n        \"-245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_to_infinity_fail_1() {\n    random_rational_range_to_infinity(EXAMPLE_SEED, Rational::from_unsigneds(1u32, 3), 10, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_to_infinity_fail_2() {\n    random_rational_range_to_infinity(EXAMPLE_SEED, Rational::from_unsigneds(1u32, 3), 0, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_to_infinity_fail_3() {\n    random_rational_range_to_infinity(EXAMPLE_SEED, Rational::from_unsigneds(1u32, 3), 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_range_to_negative_infinity;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_range_to_negative_infinity_helper(\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_range_to_negative_infinity(\n            EXAMPLE_SEED,\n            Rational::from_str(a).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_range_to_negative_infinity() {\n    let values = &[\n        \"-438/953\",\n        \"-4248\",\n        \"-6259791/632\",\n        \"-99/2\",\n        \"-34/87\",\n        \"-5/3\",\n        \"-3\",\n        \"-233500344/25\",\n        \"-45/2168\",\n        \"-2/3\",\n        \"-1\",\n        \"-194403055/2031\",\n        \"-1799/72\",\n        \"-162713/14\",\n        \"-1/31\",\n        \"-25413015/7691773\",\n        \"-243/3260\",\n        \"-2/1895\",\n        \"-261/252386\",\n        \"-3997/36893154\",\n    ];\n    let common_values = &[\n        (\"0\", 8410),\n        (\"-1\", 7679),\n        (\"-1/2\", 6403),\n        (\"-1/3\", 5093),\n        (\"-1/6\", 4068),\n        (\"-3\", 3591),\n        (\"-2\", 3472),\n        (\"-3/2\", 2895),\n        (\"-1/4\", 2642),\n        (\"-2/3\", 2350),\n    ];\n    let sample_median = (\"-6303352/195639\", Some(\"-56059/1740\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.839214579009629e215),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_range_to_negative_infinity_helper(\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-2416809961348278/953\",\n        \"-239755416\",\n        \"-786400335/632\",\n        \"-1187/2\",\n        \"-1744034/87\",\n        \"-31427/3\",\n        \"1\",\n        \"-1848/25\",\n        \"-231/2168\",\n        \"-662/3\",\n        \"-30\",\n        \"-31/2031\",\n        \"-23/72\",\n        \"-409/14\",\n        \"1/31\",\n        \"-389574262244759/7691773\",\n        \"-3367126941/3260\",\n        \"-12414/1895\",\n        \"21/252386\",\n        \"-254071517765467099/36893154\",\n    ];\n    let common_values = &[\n        (\"0\", 7287),\n        (\"-1\", 6777),\n        (\"1\", 6695),\n        (\"1/2\", 5313),\n        (\"-1/2\", 5087),\n        (\"-1/3\", 3983),\n        (\"1/3\", 3973),\n        (\"-2\", 3145),\n        (\"2\", 3070),\n        (\"-3\", 3057),\n    ];\n    let sample_median = (\"-5/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.0896126103851687e162),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_range_to_negative_infinity_helper(\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-121396406/953\",\n        \"-152\",\n        \"-99407/632\",\n        \"-99/2\",\n        \"-349/87\",\n        \"-14/3\",\n        \"-451\",\n        \"-109/25\",\n        \"-764903/2168\",\n        \"-14253863309/3\",\n        \"-5\",\n        \"-19165/2031\",\n        \"-3847/72\",\n        \"-7065/14\",\n        \"-360014815/31\",\n        \"-20728497559/7691773\",\n        \"-29701/3260\",\n        \"-10141/1895\",\n        \"-631864475205/252386\",\n        \"-34535611967/36893154\",\n    ];\n    let common_values = &[\n        (\"-7/2\", 8239),\n        (\"-4\", 2880),\n        (\"-5\", 2814),\n        (\"-6\", 2784),\n        (\"-7\", 2757),\n        (\"-13/4\", 1348),\n        (\"-10/3\", 1319),\n        (\"-11\", 1297),\n        (\"-12\", 1287),\n        (\"-9\", 1283),\n    ];\n    let sample_median = (\"-399951/2456\", Some(\"-158474076705/973165216\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.436272253581606e29),\n        standard_deviation: NiceFloat(3.412894005444307e32),\n        skewness: NiceFloat(-733.9934078667648),\n        excess_kurtosis: NiceFloat(587074.6340754497),\n    };\n    random_rational_range_to_negative_infinity_helper(\n        \"-245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_to_negative_infinity_fail_1() {\n    random_rational_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_to_negative_infinity_fail_2() {\n    random_rational_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        0,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_range_to_negative_infinity_fail_3() {\n    random_rational_range_to_negative_infinity(EXAMPLE_SEED, Rational::from_signeds(-1, 3), 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_with_denominator_inclusive_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_with_denominator_inclusive_range;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_with_denominator_inclusive_range_helper(\n    d: &str,\n    a: &str,\n    b: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_with_denominator_inclusive_range(\n            EXAMPLE_SEED,\n            Natural::from_str(d).unwrap(),\n            Rational::from_str(a).unwrap(),\n            Rational::from_str(b).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_with_denominator_inclusive_range() {\n    let values = &[\n        \"0\", \"1\", \"0\", \"1\", \"1\", \"0\", \"0\", \"0\", \"1\", \"1\", \"0\", \"0\", \"1\", \"1\", \"0\", \"1\", \"0\", \"1\",\n        \"1\", \"0\",\n    ];\n    let common_values = &[(\"0\", 523140), (\"1\", 476860)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.47685999999999046),\n        standard_deviation: NiceFloat(0.49946450310787194),\n        skewness: NiceFloat(0.0926592837970364),\n        excess_kurtosis: NiceFloat(-1.9914142571262847),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"1\",\n        \"0\",\n        \"1\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\",\n        \"1\", \"1\",\n    ];\n    let common_values = &[(\"1\", 1000000)];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"1\",\n        \"1\",\n        \"1\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\",\n        \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\",\n    ];\n    let common_values = &[(\"1/2\", 1000000)];\n    let sample_median = (\"1/2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.5),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"2\",\n        \"0\",\n        \"1\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"5/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"5/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\",\n        \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"5/6\", \"1/6\",\n    ];\n    let common_values = &[(\"1/6\", 783614), (\"5/6\", 216386)];\n    let sample_median = (\"1/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.3109239999999932),\n        standard_deviation: NiceFloat(0.2745204048819774),\n        skewness: NiceFloat(1.3775012070185304),\n        excess_kurtosis: NiceFloat(-0.10249042466258196),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"6\",\n        \"0\",\n        \"1\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"41/100\", \"43/100\", \"41/100\", \"41/100\", \"39/100\", \"41/100\", \"49/100\", \"41/100\", \"41/100\",\n        \"39/100\", \"49/100\", \"37/100\", \"37/100\", \"49/100\", \"39/100\", \"37/100\", \"41/100\", \"41/100\",\n        \"43/100\", \"37/100\",\n    ];\n    let common_values = &[\n        (\"37/100\", 167531),\n        (\"47/100\", 167302),\n        (\"49/100\", 166766),\n        (\"41/100\", 166355),\n        (\"43/100\", 166287),\n        (\"39/100\", 165759),\n    ];\n    let sample_median = (\"43/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.42668872000000546),\n        standard_deviation: NiceFloat(0.042331383354523355),\n        skewness: NiceFloat(0.2167262624312793),\n        excess_kurtosis: NiceFloat(-1.345880916970383),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"100\",\n        \"1/3\",\n        \"1/2\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\",\n        \"3\", \"3\",\n    ];\n    let common_values = &[(\"3\", 1000000)];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"1\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\",\n        \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\",\n    ];\n    let common_values = &[(\"17/6\", 1000000)];\n    let sample_median = (\"17/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.8333333333333335),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"6\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"301/100\", \"279/100\", \"313/100\", \"299/100\", \"301/100\", \"273/100\", \"279/100\", \"301/100\",\n        \"297/100\", \"311/100\", \"309/100\", \"301/100\", \"279/100\", \"289/100\", \"279/100\", \"279/100\",\n        \"309/100\", \"293/100\", \"287/100\", \"299/100\",\n    ];\n    let common_values = &[\n        (\"299/100\", 59348),\n        (\"307/100\", 59112),\n        (\"281/100\", 59097),\n        (\"297/100\", 58997),\n        (\"283/100\", 58975),\n        (\"293/100\", 58941),\n        (\"309/100\", 58919),\n        (\"311/100\", 58910),\n        (\"287/100\", 58857),\n        (\"289/100\", 58794),\n    ];\n    let sample_median = (\"293/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.937086759999876),\n        standard_deviation: NiceFloat(0.12202969771309406),\n        skewness: NiceFloat(-0.025551558114942263),\n        excess_kurtosis: NiceFloat(-1.2130746374242132),\n    };\n    random_rational_with_denominator_inclusive_range_helper(\n        \"100\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_inclusive_range_fail_1() {\n    random_rational_with_denominator_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_inclusive_range_fail_2() {\n    random_rational_with_denominator_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        2,\n        3,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_inclusive_range_fail_3() {\n    random_rational_with_denominator_inclusive_range(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 2),\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_with_denominator_range.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_with_denominator_range;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_with_denominator_range_helper(\n    d: &str,\n    a: &str,\n    b: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_with_denominator_range(\n            EXAMPLE_SEED,\n            Natural::from_str(d).unwrap(),\n            Rational::from_str(a).unwrap(),\n            Rational::from_str(b).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_with_denominator_range() {\n    let values = &[\n        \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\",\n        \"0\", \"0\",\n    ];\n    let common_values = &[(\"0\", 1000000)];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_range_helper(\n        \"1\",\n        \"0\",\n        \"1\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\",\n        \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\", \"1/2\",\n    ];\n    let common_values = &[(\"1/2\", 1000000)];\n    let sample_median = (\"1/2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.5),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_range_helper(\n        \"2\",\n        \"0\",\n        \"1\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"5/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"5/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\",\n        \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"1/6\", \"5/6\", \"1/6\",\n    ];\n    let common_values = &[(\"1/6\", 783614), (\"5/6\", 216386)];\n    let sample_median = (\"1/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.3109239999999932),\n        standard_deviation: NiceFloat(0.2745204048819774),\n        skewness: NiceFloat(1.3775012070185304),\n        excess_kurtosis: NiceFloat(-0.10249042466258196),\n    };\n    random_rational_with_denominator_range_helper(\n        \"6\",\n        \"0\",\n        \"1\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"41/100\", \"43/100\", \"41/100\", \"41/100\", \"39/100\", \"41/100\", \"49/100\", \"41/100\", \"41/100\",\n        \"39/100\", \"49/100\", \"37/100\", \"37/100\", \"49/100\", \"39/100\", \"37/100\", \"41/100\", \"41/100\",\n        \"43/100\", \"37/100\",\n    ];\n    let common_values = &[\n        (\"37/100\", 167531),\n        (\"47/100\", 167302),\n        (\"49/100\", 166766),\n        (\"41/100\", 166355),\n        (\"43/100\", 166287),\n        (\"39/100\", 165759),\n    ];\n    let sample_median = (\"43/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.42668872000000546),\n        standard_deviation: NiceFloat(0.042331383354523355),\n        skewness: NiceFloat(0.2167262624312793),\n        excess_kurtosis: NiceFloat(-1.345880916970383),\n    };\n    random_rational_with_denominator_range_helper(\n        \"100\",\n        \"1/3\",\n        \"1/2\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\", \"3\",\n        \"3\", \"3\",\n    ];\n    let common_values = &[(\"3\", 1000000)];\n    let sample_median = (\"3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.0),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_range_helper(\n        \"1\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\",\n        \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\", \"17/6\",\n    ];\n    let common_values = &[(\"17/6\", 1000000)];\n    let sample_median = (\"17/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.8333333333333335),\n        standard_deviation: NiceFloat(0.0),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rational_with_denominator_range_helper(\n        \"6\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"301/100\", \"279/100\", \"313/100\", \"299/100\", \"301/100\", \"273/100\", \"279/100\", \"301/100\",\n        \"297/100\", \"311/100\", \"309/100\", \"301/100\", \"279/100\", \"289/100\", \"279/100\", \"279/100\",\n        \"309/100\", \"293/100\", \"287/100\", \"299/100\",\n    ];\n    let common_values = &[\n        (\"299/100\", 59348),\n        (\"307/100\", 59112),\n        (\"281/100\", 59097),\n        (\"297/100\", 58997),\n        (\"283/100\", 58975),\n        (\"293/100\", 58941),\n        (\"309/100\", 58919),\n        (\"311/100\", 58910),\n        (\"287/100\", 58857),\n        (\"289/100\", 58794),\n    ];\n    let sample_median = (\"293/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.937086759999876),\n        standard_deviation: NiceFloat(0.12202969771309406),\n        skewness: NiceFloat(-0.025551558114942263),\n        excess_kurtosis: NiceFloat(-1.2130746374242132),\n    };\n    random_rational_with_denominator_range_helper(\n        \"100\",\n        \"268876667/98914198\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_fail_1() {\n    random_rational_with_denominator_range(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        10,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_fail_2() {\n    random_rational_with_denominator_range(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(2u32, 3),\n        2,\n        3,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_fail_3() {\n    random_rational_with_denominator_range(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_fail_4() {\n    random_rational_with_denominator_range(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 2),\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_with_denominator_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_with_denominator_range_to_infinity;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_with_denominator_range_to_infinity_helper(\n    d: &str,\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_with_denominator_range_to_infinity(\n            EXAMPLE_SEED,\n            Natural::from_str(d).unwrap(),\n            Rational::from_str(a).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_with_denominator_range_to_infinity() {\n    let values = &[\n        \"2\",\n        \"4\",\n        \"178\",\n        \"1084828126\",\n        \"6\",\n        \"12\",\n        \"56\",\n        \"591\",\n        \"5283\",\n        \"5606382754\",\n        \"3\",\n        \"35\",\n        \"1\",\n        \"1\",\n        \"65728184\",\n        \"6\",\n        \"0\",\n        \"7\",\n        \"110989\",\n        \"774544411777231510\",\n    ];\n    let common_values = &[\n        (\"0\", 90859),\n        (\"1\", 82901),\n        (\"2\", 37557),\n        (\"3\", 37534),\n        (\"6\", 17244),\n        (\"5\", 17221),\n        (\"7\", 17166),\n        (\"4\", 16881),\n        (\"10\", 7792),\n        (\"8\", 7781),\n    ];\n    let sample_median = (\"81\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.520127903486984e34),\n        standard_deviation: NiceFloat(7.329977056427779e37),\n        skewness: NiceFloat(961.5590415384418),\n        excess_kurtosis: NiceFloat(943383.4745426066),\n    };\n    random_rational_with_denominator_range_to_infinity_helper(\n        \"1\",\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"591/2\",\n        \"5283/2\",\n        \"3/2\",\n        \"35/2\",\n        \"1/2\",\n        \"1/2\",\n        \"7/2\",\n        \"110989/2\",\n        \"1/2\",\n        \"5/2\",\n        \"751/2\",\n        \"7943/2\",\n        \"7065/2\",\n        \"8413078495/2\",\n        \"3/2\",\n        \"1/2\",\n        \"1/2\",\n        \"69/2\",\n        \"13/2\",\n        \"7749/2\",\n    ];\n    let common_values = &[\n        (\"1/2\", 167084),\n        (\"3/2\", 75468),\n        (\"7/2\", 34473),\n        (\"5/2\", 34378),\n        (\"11/2\", 15785),\n        (\"13/2\", 15606),\n        (\"15/2\", 15565),\n        (\"9/2\", 15464),\n        (\"29/2\", 7220),\n        (\"27/2\", 7166),\n    ];\n    let sample_median = (\"89/2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0730191792105077e40),\n        standard_deviation: NiceFloat(1.072277458027706e43),\n        skewness: NiceFloat(999.9978064950928),\n        excess_kurtosis: NiceFloat(999994.0749119784),\n    };\n    random_rational_with_denominator_range_to_infinity_helper(\n        \"2\",\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"35/6\",\n        \"1/6\",\n        \"1/6\",\n        \"7/6\",\n        \"110989/6\",\n        \"1/6\",\n        \"5/6\",\n        \"751/6\",\n        \"7943/6\",\n        \"8413078495/6\",\n        \"1/6\",\n        \"1/6\",\n        \"13/6\",\n        \"7/6\",\n        \"744559/6\",\n        \"707/6\",\n        \"751063343911/6\",\n        \"28206975458359/6\",\n        \"971/6\",\n        \"3925/6\",\n    ];\n    let common_values = &[\n        (\"1/6\", 241941),\n        (\"5/6\", 50133),\n        (\"7/6\", 50049),\n        (\"11/6\", 22890),\n        (\"13/6\", 22726),\n        (\"29/6\", 10488),\n        (\"23/6\", 10390),\n        (\"19/6\", 10358),\n        (\"25/6\", 10358),\n        (\"31/6\", 10291),\n    ];\n    let sample_median = (\"67/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.4338034128378777e36),\n        standard_deviation: NiceFloat(2.4305548034225437e39),\n        skewness: NiceFloat(999.9972159387221),\n        excess_kurtosis: NiceFloat(999993.287033733),\n    };\n    random_rational_with_denominator_range_to_infinity_helper(\n        \"6\",\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"509/100\",\n        \"489/100\",\n        \"319/100\",\n        \"591/100\",\n        \"437/100\",\n        \"913/100\",\n        \"449/100\",\n        \"1731/100\",\n        \"359/100\",\n        \"359/100\",\n        \"999/100\",\n        \"501/100\",\n        \"479/100\",\n        \"333/100\",\n        \"499/100\",\n        \"733/100\",\n        \"751/100\",\n        \"40711/100\",\n        \"921/100\",\n        \"5087/100\",\n    ];\n    let common_values = &[\n        (\"473/100\", 6588),\n        (\"417/100\", 6577),\n        (\"423/100\", 6539),\n        (\"369/100\", 6537),\n        (\"457/100\", 6479),\n        (\"433/100\", 6459),\n        (\"409/100\", 6455),\n        (\"339/100\", 6442),\n        (\"359/100\", 6439),\n        (\"449/100\", 6437),\n    ];\n    let sample_median = (\"511/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(45.44256795999996),\n        standard_deviation: NiceFloat(5322.132374334366),\n        skewness: NiceFloat(618.505376716015),\n        excess_kurtosis: NiceFloat(438771.8555941413),\n    };\n    random_rational_with_denominator_range_to_infinity_helper(\n        \"100\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-281/100\",\n        \"-79/100\",\n        \"-11/100\",\n        \"9/100\",\n        \"-1/100\",\n        \"3/100\",\n        \"51933/100\",\n        \"-39/100\",\n        \"3/100\",\n        \"31/100\",\n        \"51/100\",\n        \"-1/100\",\n        \"-29/100\",\n        \"-1/100\",\n        \"-1/100\",\n        \"7749/100\",\n        \"-191/100\",\n        \"1/100\",\n        \"-7/100\",\n        \"119/100\",\n    ];\n    let common_values = &[\n        (\"1/100\", 123814),\n        (\"-1/100\", 123122),\n        (\"-3/100\", 56658),\n        (\"3/100\", 56096),\n        (\"7/100\", 25530),\n        (\"-7/100\", 25528),\n        (\"-13/100\", 11889),\n        (\"11/100\", 11771),\n        (\"-11/100\", 11652),\n        (\"9/100\", 11626),\n    ];\n    let sample_median = (\"1/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.7877073287017464e35),\n        standard_deviation: NiceFloat(1.6780985984051316e38),\n        skewness: NiceFloat(994.171891194563),\n        excess_kurtosis: NiceFloat(991907.5494321428),\n    };\n    random_rational_with_denominator_range_to_infinity_helper(\n        \"100\",\n        \"-245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_to_infinity_fail_1() {\n    random_rational_with_denominator_range_to_infinity(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_to_infinity_fail_2() {\n    random_rational_with_denominator_range_to_infinity(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rational_with_denominator_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::basic::traits::One;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_nz::natural::Natural;\nuse malachite_q::Rational;\nuse malachite_q::random::random_rational_with_denominator_range_to_negative_infinity;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn random_rational_with_denominator_range_to_negative_infinity_helper(\n    d: &str,\n    a: &str,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rational_with_denominator_range_to_negative_infinity(\n            EXAMPLE_SEED,\n            Natural::from_str(d).unwrap(),\n            Rational::from_str(a).unwrap(),\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rational_with_denominator_range_to_negative_infinity() {\n    let values = &[\n        \"-2\",\n        \"-4\",\n        \"-178\",\n        \"-1084828126\",\n        \"-6\",\n        \"-12\",\n        \"-56\",\n        \"-591\",\n        \"-5283\",\n        \"-5606382754\",\n        \"-3\",\n        \"-35\",\n        \"-1\",\n        \"-1\",\n        \"-65728184\",\n        \"-6\",\n        \"0\",\n        \"-7\",\n        \"-110989\",\n        \"-774544411777231510\",\n    ];\n    let common_values = &[\n        (\"0\", 90859),\n        (\"-1\", 82901),\n        (\"-2\", 37557),\n        (\"-3\", 37534),\n        (\"-6\", 17244),\n        (\"-5\", 17221),\n        (\"-7\", 17166),\n        (\"-4\", 16881),\n        (\"-10\", 7792),\n        (\"-8\", 7781),\n    ];\n    let sample_median = (\"-81\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.520127903486984e34),\n        standard_deviation: NiceFloat(7.329977056427779e37),\n        skewness: NiceFloat(-961.5590415384418),\n        excess_kurtosis: NiceFloat(943383.4745426066),\n    };\n    random_rational_with_denominator_range_to_negative_infinity_helper(\n        \"1\",\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-591/2\",\n        \"-5283/2\",\n        \"-3/2\",\n        \"-35/2\",\n        \"-1/2\",\n        \"-1/2\",\n        \"-7/2\",\n        \"-110989/2\",\n        \"-1/2\",\n        \"-5/2\",\n        \"-751/2\",\n        \"-7943/2\",\n        \"-7065/2\",\n        \"-8413078495/2\",\n        \"-3/2\",\n        \"-1/2\",\n        \"-1/2\",\n        \"-69/2\",\n        \"-13/2\",\n        \"-7749/2\",\n    ];\n    let common_values = &[\n        (\"-1/2\", 167084),\n        (\"-3/2\", 75468),\n        (\"-7/2\", 34473),\n        (\"-5/2\", 34378),\n        (\"-11/2\", 15785),\n        (\"-13/2\", 15606),\n        (\"-15/2\", 15565),\n        (\"-9/2\", 15464),\n        (\"-29/2\", 7220),\n        (\"-27/2\", 7166),\n    ];\n    let sample_median = (\"-89/2\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0730191792105077e40),\n        standard_deviation: NiceFloat(1.072277458027706e43),\n        skewness: NiceFloat(-999.9978064950928),\n        excess_kurtosis: NiceFloat(999994.0749119784),\n    };\n    random_rational_with_denominator_range_to_negative_infinity_helper(\n        \"2\",\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-35/6\",\n        \"-1/6\",\n        \"-1/6\",\n        \"-7/6\",\n        \"-110989/6\",\n        \"-1/6\",\n        \"-5/6\",\n        \"-751/6\",\n        \"-7943/6\",\n        \"-8413078495/6\",\n        \"-1/6\",\n        \"-1/6\",\n        \"-13/6\",\n        \"-7/6\",\n        \"-744559/6\",\n        \"-707/6\",\n        \"-751063343911/6\",\n        \"-28206975458359/6\",\n        \"-971/6\",\n        \"-3925/6\",\n    ];\n    let common_values = &[\n        (\"-1/6\", 241941),\n        (\"-5/6\", 50133),\n        (\"-7/6\", 50049),\n        (\"-11/6\", 22890),\n        (\"-13/6\", 22726),\n        (\"-29/6\", 10488),\n        (\"-23/6\", 10390),\n        (\"-19/6\", 10358),\n        (\"-25/6\", 10358),\n        (\"-31/6\", 10291),\n    ];\n    let sample_median = (\"-67/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.4338034128378777e36),\n        standard_deviation: NiceFloat(2.4305548034225437e39),\n        skewness: NiceFloat(-999.9972159387221),\n        excess_kurtosis: NiceFloat(999993.287033733),\n    };\n    random_rational_with_denominator_range_to_negative_infinity_helper(\n        \"6\",\n        \"0\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-99/100\",\n        \"-913/100\",\n        \"-11/100\",\n        \"7/100\",\n        \"1/100\",\n        \"-10973/100\",\n        \"47/100\",\n        \"-39/100\",\n        \"57/100\",\n        \"-3/100\",\n        \"23/100\",\n        \"-10522099/100\",\n        \"-1/100\",\n        \"-29701/100\",\n        \"1/100\",\n        \"1/100\",\n        \"-7743/100\",\n        \"1/100\",\n        \"-7/100\",\n        \"-89199/100\",\n    ];\n    let common_values = &[\n        (\"-1/100\", 123615),\n        (\"1/100\", 123443),\n        (\"3/100\", 56191),\n        (\"-3/100\", 56020),\n        (\"7/100\", 25883),\n        (\"-7/100\", 25543),\n        (\"-9/100\", 11654),\n        (\"11/100\", 11646),\n        (\"13/100\", 11586),\n        (\"9/100\", 11583),\n    ];\n    let sample_median = (\"-1/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-9.380763184802002e48),\n        standard_deviation: NiceFloat(9.380763184802352e51),\n        skewness: NiceFloat(-999.9984999993959),\n        excess_kurtosis: NiceFloat(999995.00000096),\n    };\n    random_rational_with_denominator_range_to_negative_infinity_helper(\n        \"100\",\n        \"245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-509/100\",\n        \"-427/100\",\n        \"-407/100\",\n        \"-343/100\",\n        \"-591/100\",\n        \"-913/100\",\n        \"-321/100\",\n        \"-1731/100\",\n        \"-373/100\",\n        \"-999/100\",\n        \"-361/100\",\n        \"-353/100\",\n        \"-437/100\",\n        \"-733/100\",\n        \"-751/100\",\n        \"-40711/100\",\n        \"-921/100\",\n        \"-5087/100\",\n        \"-919/100\",\n        \"-323/100\",\n    ];\n    let common_values = &[\n        (\"-469/100\", 6500),\n        (\"-497/100\", 6483),\n        (\"-437/100\", 6473),\n        (\"-473/100\", 6460),\n        (\"-387/100\", 6455),\n        (\"-421/100\", 6454),\n        (\"-493/100\", 6454),\n        (\"-379/100\", 6447),\n        (\"-361/100\", 6438),\n        (\"-347/100\", 6432),\n    ];\n    let sample_median = (\"-511/100\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-45.46337932000087),\n        standard_deviation: NiceFloat(5322.134805564187),\n        skewness: NiceFloat(-618.5045180626813),\n        excess_kurtosis: NiceFloat(438771.04416568665),\n    };\n    random_rational_with_denominator_range_to_negative_infinity_helper(\n        \"100\",\n        \"-245850922/78256779\",\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_to_negative_infinity_fail_1() {\n    random_rational_with_denominator_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rational_with_denominator_range_to_negative_infinity_fail_2() {\n    random_rational_with_denominator_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Natural::ONE,\n        Rational::from_signeds(-1i32, 3),\n        2,\n        3,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/random_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::random_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\nfn random_rationals_helper(\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        random_rationals(EXAMPLE_SEED, mean_bits_numerator, mean_bits_denominator),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_random_rationals() {\n    // mean bits = 65/64\n    let values = &[\n        \"0\", \"0\", \"0\", \"2\", \"0\", \"0\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"-28\", \"-1\", \"-4\",\n        \"-1\", \"-1\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 496048),\n        (\"1\", 123950),\n        (\"-1\", 123690),\n        (\"3\", 31184),\n        (\"-2\", 31130),\n        (\"-3\", 31058),\n        (\"2\", 30772),\n        (\"-4\", 7921),\n        (\"-7\", 7828),\n        (\"-6\", 7799),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.5817718650793547),\n        standard_deviation: NiceFloat(857.0389155951154),\n        skewness: NiceFloat(-315.8438705097454),\n        excess_kurtosis: NiceFloat(254264.92899445235),\n    };\n    random_rationals_helper(\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-1\", \"-5/3\", \"0\", \"1\", \"0\", \"1/2\", \"356\", \"0\", \"0\", \"3/2\", \"3/5\", \"-14/3\", \"0\", \"-1/3\",\n        \"-19/3\", \"-1/2\", \"0\", \"-1\", \"0\", \"-10\",\n    ];\n    let common_values = &[\n        (\"0\", 333130),\n        (\"1\", 66630),\n        (\"-1\", 66556),\n        (\"2\", 22206),\n        (\"-2\", 22066),\n        (\"-3\", 20899),\n        (\"3\", 20834),\n        (\"1/2\", 16750),\n        (\"-1/2\", 16630),\n        (\"1/3\", 15616),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3875.4043163058423),\n        standard_deviation: NiceFloat(5451723.46138941),\n        skewness: NiceFloat(-481.96150934322344),\n        excess_kurtosis: NiceFloat(353958.9361419337),\n    };\n    random_rationals_helper(\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-7301/34\",\n        \"-4183103/1234731190583\",\n        \"54812347098686/6195807891591254727\",\n        \"812739/17841539017\",\n        \"-665/908\",\n        \"677/1138982845180\",\n        \"166/22491855393807861245619791028129\",\n        \"270142/5\",\n        \"52040856788711439301087669967/15975369961878544862054\",\n        \"5718607/1953563256716085077\",\n        \"8834633494449605/147372515680891813385292082245912643739605046366\",\n        \"-14860658876333535410753934016237/38209564041\",\n        \"256/1033317698721\",\n        \"-1675/34808324932084086743491848009\",\n        \"-49\",\n        \"-42/5\",\n        \"-87750175104578/19615\",\n        \"-1/4767944\",\n        \"-137819495256811446350/41779\",\n        \"-2/187\",\n    ];\n    let common_values = &[\n        (\"0\", 30369),\n        (\"-1\", 929),\n        (\"1\", 871),\n        (\"1/2\", 423),\n        (\"2\", 410),\n        (\"-2\", 408),\n        (\"-1/2\", 399),\n        (\"3\", 372),\n        (\"1/3\", 368),\n        (\"-1/3\", 337),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.0180317983547227e148),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rationals_helper(\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-1428130618501/11392923974388402817057849552586132522617914732498530\",\n        \"-3383508417938165445131453/56779550950694809089378809702538209946934076252940714133449\",\n        \"602900875601911171470306076355/119191771\",\n        \"3/14013585568406836752167657664673\",\n        \"-760776403/6462405519227986816335721703034929571679921\",\n        \"3453088342103851715673829426753969982/25626510185\",\n        \"1747398675/3172739\",\n        \"8948691991346583905040602549520967352911/18\",\n        \"16038312634753050980603803559756/9438855467532928850187287\",\n        \"155434788890251/4034446723\",\n        \"950902359766673/235910534939055966292926793\",\n        \"-294004238713694270841854/1596165279\",\n        \"1030393/85299778977201964065475016444620\",\n        \"-124218250251176079819064/503926103984580328155607497147\",\n        \"-277206127786809155854294/47228889692473\",\n        \"-3673/301956358739051815786302694193\",\n        \"-166239031838/39\",\n        \"-3309620973011864735684788/31306944615\",\n        \"-138546001637/6539404996772746726586649886838863596921111\",\n        \"-417/14077532426874196091229260728580\",\n    ];\n    let common_values = &[\n        (\"0\", 15382),\n        (\"-1\", 217),\n        (\"1\", 216),\n        (\"-2\", 126),\n        (\"1/2\", 121),\n        (\"2\", 119),\n        (\"-1/3\", 117),\n        (\"-1/2\", 111),\n        (\"-3\", 100),\n        (\"3\", 98),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.459352389355579e272),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    random_rationals_helper(\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn random_rationals_fail_1() {\n    random_rationals(EXAMPLE_SEED, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn random_rationals_fail_2() {\n    random_rationals(EXAMPLE_SEED, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/striped_random_negative_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::striped_random_negative_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\n#[allow(clippy::too_many_arguments)]\nfn striped_random_negative_rationals_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        striped_random_negative_rationals(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_negative_rationals() {\n    // mean bits = 65/64\n    let values = &[\"-1\"; 20];\n    let common_values = &[\n        (\"-1\", 969574),\n        (\"-3\", 7614),\n        (\"-1/3\", 7540),\n        (\"-2\", 7358),\n        (\"-1/2\", 7310),\n        (\"-4\", 98),\n        (\"-7\", 88),\n        (\"-1/7\", 87),\n        (\"-1/4\", 79),\n        (\"-2/3\", 59),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.0148534444805162),\n        standard_deviation: NiceFloat(0.22114620623320444),\n        skewness: NiceFloat(-9.149432588003647),\n        excess_kurtosis: NiceFloat(159.01272255850165),\n    };\n    striped_random_negative_rationals_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-1/16\", \"-1/16\", \"-4/15\", \"-2\", \"-1\", \"-1\", \"-1\", \"-1\", \"-3/2\", \"-1\", \"-1\", \"-2/3\", \"-1\",\n        \"-1/7\", \"-2\", \"-16\", \"-1\", \"-4\", \"-2\", \"-1/2\",\n    ];\n    let common_values = &[\n        (\"-1\", 286322),\n        (\"-2\", 71839),\n        (\"-1/2\", 71792),\n        (\"-1/3\", 65670),\n        (\"-3\", 65630),\n        (\"-1/4\", 27230),\n        (\"-4\", 26986),\n        (\"-7\", 24307),\n        (\"-1/7\", 24217),\n        (\"-2/3\", 16638),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-8.675884348144963),\n        standard_deviation: NiceFloat(452.3475394447746),\n        skewness: NiceFloat(-244.55477994852157),\n        excess_kurtosis: NiceFloat(71058.94920001029),\n    };\n    striped_random_negative_rationals_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-4\",\n        \"-1/268681216\",\n        \"-75493376/9007199120523391\",\n        \"-8/8796094070783\",\n        \"-8/950737950171027935941967741439\",\n        \"-1040391/33554432\",\n        \"-2813000899879757964630563421437095845888\",\n        \"-1/79164837199872\",\n        \"-2199023255551/16\",\n        \"-220784470296873664512/4611685966886694919\",\n        \"-33/256\",\n        \"-16809472/144255925429997319\",\n        \"-6129981798088146185736712229649530847599712363400396804/786431\",\n        \"-1099511578623/1073741761\",\n        \"-2/65791\",\n        \"-18014398509490175/266208\",\n        \"-1/140752654954496\",\n        \"-2417842415927590238812160\",\n        \"-9444732965755934466048/7\",\n        \"-4194303/1073709056\",\n    ];\n    let common_values = &[\n        (\"-1\", 3591),\n        (\"-1/2\", 1841),\n        (\"-2\", 1732),\n        (\"-1/4\", 1579),\n        (\"-4\", 1555),\n        (\"-1/8\", 1495),\n        (\"-8\", 1470),\n        (\"-1/16\", 1391),\n        (\"-16\", 1304),\n        (\"-1/32\", 1231),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-2.394348586566577e127),\n        standard_deviation: NiceFloat(2.3943485865002743e130),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_negative_rationals_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-302231454903657360261120/383\",\n        \"-3/2166395068749415481073467392\",\n        \"-174223242635524708377374895198005052307456/664594824829454142366461086851399679\",\n        \"-4503599627370496/127\",\n        \"-2048/147574233996470517759\",\n        \"-9132155158831519862233019347003870166304109363/209664\",\n        \"-10634473003386642729879378371710812032/31\",\n        \"-536870911/34359738368\",\n        \"-5026338869833/1328165573307087716352\",\n        \"-768/72040001986101247\",\n        \"-18014261070561279/2786912585102768425368689128829376599687168\",\n        \"-133152\",\n        \"-3/545357767376900\",\n        \"-31/2251799813685247\",\n        \"-4398046511135/64\",\n        \"-8796093046784/4194303\",\n        \"-38685626236675332845338112/562949953420767\",\n        \"-4459452226323108777095472045064328031949030396/50331647\",\n        \"-2535298782614042945771878219776/70366596710399\",\n        \"-144115188075855871/154740143727431099539783680\",\n    ];\n    let common_values = &[\n        (\"-1\", 1591),\n        (\"-2\", 794),\n        (\"-1/2\", 762),\n        (\"-8\", 757),\n        (\"-16\", 718),\n        (\"-4\", 691),\n        (\"-1/4\", 691),\n        (\"-1/8\", 689),\n        (\"-1/16\", 659),\n        (\"-32\", 650),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.3341225920157865e234),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_negative_rationals_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_rationals_fail_1() {\n    striped_random_negative_rationals(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_rationals_fail_2() {\n    striped_random_negative_rationals(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_rationals_fail_3() {\n    striped_random_negative_rationals(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_negative_rationals_fail_4() {\n    striped_random_negative_rationals(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/striped_random_non_negative_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::striped_random_non_negative_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\n#[allow(clippy::too_many_arguments)]\nfn striped_random_non_negative_rationals_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        striped_random_non_negative_rationals(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_non_negative_rationals() {\n    // mean bits = 65/64\n    let values = &[\n        \"0\", \"0\", \"0\", \"2\", \"0\", \"0\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"16\", \"1\", \"4\", \"1\",\n        \"1\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 496048),\n        (\"1\", 247664),\n        (\"2\", 62226),\n        (\"3\", 61847),\n        (\"7\", 23467),\n        (\"4\", 23204),\n        (\"8\", 8889),\n        (\"15\", 8801),\n        (\"5\", 7917),\n        (\"6\", 7733),\n    ];\n    let sample_median = (\"2/3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.241369898412524),\n        standard_deviation: NiceFloat(1203.8320236802172),\n        skewness: NiceFloat(650.4921628408604),\n        excess_kurtosis: NiceFloat(487036.59115699964),\n    };\n    striped_random_non_negative_rationals_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"2/3\", \"4/3\", \"0\", \"1\", \"0\", \"1/2\", \"448\", \"0\", \"0\", \"1\", \"5/14\", \"11/3\", \"0\", \"1/3\",\n        \"19/3\", \"1/3\", \"0\", \"1\", \"0\", \"15\",\n    ];\n    let common_values = &[\n        (\"0\", 333130),\n        (\"1\", 134397),\n        (\"2\", 44677),\n        (\"3\", 40161),\n        (\"1/2\", 33752),\n        (\"1/3\", 30003),\n        (\"4\", 22136),\n        (\"7\", 19720),\n        (\"1/4\", 12536),\n        (\"8\", 11373),\n    ];\n    let sample_median = (\"2/3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(12771.729072597298),\n        standard_deviation: NiceFloat(5028817.645526858),\n        skewness: NiceFloat(587.1636750940664),\n        excess_kurtosis: NiceFloat(372144.3890017075),\n    };\n    striped_random_non_negative_rationals_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"8192/127\",\n        \"16776704/4396972769407\",\n        \"8796093005951/648518346332962816\",\n        \"87381/2863267840\",\n        \"1024/2043\",\n        \"51/58408828928\",\n        \"85/13521606402434254795714066382848\",\n        \"270335/7\",\n        \"59421159664630116152453890047/9444741445172838006656\",\n        \"6291455/1154891846623166464\",\n        \"4503599631564799/114177029184456441820717001177155938271778439152\",\n        \"40247906632508999881205124923399/137438953471\",\n        \"73/154619122249\",\n        \"1024/39611663922002864317824761855\",\n        \"32\",\n        \"127/9\",\n        \"2199023247360/287\",\n        \"1/8257539\",\n        \"590156181179127562240/131199\",\n        \"1/85\",\n    ];\n    let common_values = &[\n        (\"0\", 30369),\n        (\"1\", 3494),\n        (\"2\", 1638),\n        (\"1/2\", 1619),\n        (\"4\", 1527),\n        (\"1/4\", 1481),\n        (\"1/8\", 1348),\n        (\"8\", 1328),\n        (\"16\", 1204),\n        (\"1/16\", 1190),\n    ];\n    let sample_median = (\"2/3\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.681561663446933e148),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_non_negative_rationals_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"1464583847936/7981747608676504359847391117664870922673555168908629\",\n        \"2422574005712127994617856/100041309094775311912751523786213765636294062424476459466751\",\n        \"9671406556916483641901054/2047\",\n        \"1/10141204801678261259383949230080\",\n        \"1/10384593719487506031596923529461760\",\n        \"166153499473114484112975882535075839/1073741824\",\n        \"1073758207/2097152\",\n        \"10889035740836205568492768571262465220607/31\",\n        \"16225927683142697268042315648307/15474248646392859802468352\",\n        \"211174952009727/4294836224\",\n        \"1125625028999183/309485009533116616750923776\",\n        \"160551237036734989468671/2146697215\",\n        \"4325375/324527219843164634252394901798911\",\n        \"5666839779310716881032/42255019850195730860877091089\",\n        \"201487684640834221069648/46912675075413\",\n        \"1365/52818778157753880297518486869\",\n        \"17179869184/7\",\n        \"2420212822470693171986431/34359738367\",\n        \"274877382656/11150372599265311570767859136324172163055871\",\n        \"181/10141204802612896292451899146325\",\n    ];\n    let common_values = &[\n        (\"0\", 15382),\n        (\"1\", 1486),\n        (\"1/2\", 807),\n        (\"1/4\", 728),\n        (\"2\", 725),\n        (\"4\", 693),\n        (\"8\", 691),\n        (\"1/16\", 685),\n        (\"1/8\", 655),\n        (\"16\", 628),\n    ];\n    let sample_median = (\n        \"28334198898317382877184/42501298345826806923263\",\n        Some(\"17179869184/25769803775\"),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(5.67251933470839e272),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_non_negative_rationals_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_rationals_fail_1() {\n    striped_random_non_negative_rationals(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_rationals_fail_2() {\n    striped_random_non_negative_rationals(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_rationals_fail_3() {\n    striped_random_non_negative_rationals(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_non_negative_rationals_fail_4() {\n    striped_random_non_negative_rationals(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/striped_random_nonzero_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::striped_random_nonzero_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\n#[allow(clippy::too_many_arguments)]\nfn striped_random_nonzero_rationals_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        striped_random_nonzero_rationals(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_nonzero_rationals() {\n    // mean bits = 65/64\n    let values = &[\n        \"-1\", \"-1\", \"1\", \"1\", \"-1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"1\", \"-1\", \"1\", \"-1\", \"-1\", \"-1\",\n        \"-1\", \"-1\", \"-1\", \"-1\",\n    ];\n    let common_values = &[\n        (\"-1\", 484931),\n        (\"1\", 484658),\n        (\"3\", 3817),\n        (\"1/2\", 3814),\n        (\"-1/2\", 3763),\n        (\"1/3\", 3737),\n        (\"-2\", 3697),\n        (\"-1/3\", 3678),\n        (\"2\", 3660),\n        (\"-3\", 3636),\n    ];\n    let sample_median = (\"-1/7\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(0.00023288528138526625),\n        standard_deviation: NiceFloat(1.037925742275186),\n        skewness: NiceFloat(0.0009392339727778673),\n        excess_kurtosis: NiceFloat(-1.2291100464705937),\n    };\n    striped_random_nonzero_rationals_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-14\", \"-1/7\", \"6\", \"1/3\", \"-1\", \"1/5\", \"1\", \"4\", \"1/31\", \"4/3\", \"1/3\", \"-2\", \"2\", \"-1/15\",\n        \"-2\", \"-1/68\", \"-37\", \"-23\", \"-8/15\", \"-1\",\n    ];\n    let common_values = &[\n        (\"1\", 143643),\n        (\"-1\", 143385),\n        (\"-2\", 36002),\n        (\"1/2\", 35965),\n        (\"-1/2\", 35954),\n        (\"2\", 35814),\n        (\"-3\", 33135),\n        (\"-1/3\", 33023),\n        (\"1/3\", 32961),\n        (\"3\", 32694),\n    ];\n    let sample_median = (\"-1/12767\", Some(\"-1/15422\"));\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-0.06690886383057024),\n        standard_deviation: NiceFloat(743.3873846358883),\n        skewness: NiceFloat(-34.20312291886276),\n        excess_kurtosis: NiceFloat(162779.3378205672),\n    };\n    striped_random_nonzero_rationals_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-68720000000/18006083452797439\",\n        \"-2545165805/29\",\n        \"549754781664/1236950581247\",\n        \"1065353727/2047\",\n        \"-2147745791/513\",\n        \"16128/575\",\n        \"8192/17000482516899619632318463\",\n        \"18431/16778240\",\n        \"1/31\",\n        \"4096/526335\",\n        \"128/1648730570755\",\n        \"-235590160969/299520\",\n        \"256/1015\",\n        \"-134213640/1015807\",\n        \"-2135296358076219148941708516212794237273505792/134217731\",\n        \"-1099511504895/144117387099111422\",\n        \"-18854877723802865238015/1180663678191190081543\",\n        \"-8191/327168\",\n        \"-1/127\",\n        \"-79/4095\",\n    ];\n    let common_values = &[\n        (\"1\", 1790),\n        (\"-1\", 1776),\n        (\"1/2\", 915),\n        (\"2\", 911),\n        (\"-1/2\", 882),\n        (\"-2\", 880),\n        (\"-4\", 815),\n        (\"4\", 804),\n        (\"1/4\", 790),\n        (\"-1/4\", 787),\n    ];\n    let sample_median = (\n        \"-32/1667110261681770706918410051940899342228396408049959135280966429665234272396880613105\\\n        8561778175\",\n        Some(\n            \"-589823/54681270984110515773306643211150111379599332867331476905258877712070223126025\\\n            4978705174476571541504\",\n        ),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-9.989614378172733e139),\n        standard_deviation: NiceFloat(9.989614377590213e142),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_nonzero_rationals_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-70988433612846563009577969778432/37778931862957161709535\",\n        \"-18874367/34359740415\",\n        \"128/1048575\",\n        \"9215/576461851815051263\",\n        \"-67043359/4194303\",\n        \"557501356260338958336/32794196171264010809\",\n        \"68719476735/36028797018963968\",\n        \"2596148429269774428927230031691776\",\n        \"298270729465465682551124201231/2275625072216288986599183\",\n        \"2048/28735\",\n        \"7818749353074/7\",\n        \"-288230376185266175/9671406556917033397649408\",\n        \"4611686147284795328/2361183241443412541439\",\n        \"-1208925819333154214772480/12068402384318877481825725909459066626185514174187044863\",\n        \"-292842132531367112448\",\n        \"-27670116179283804159/5708990770823839524233181656729843468399049728\",\n        \"-10384554102988398124892195902719999/16809983\",\n        \"-1162146002543608594431/256\",\n        \"-784637716922080678562056411478885332466638530662142836736/8191\",\n        \"-35184372080639/11418025097790482669312781854182320779382783943\",\n    ];\n    let common_values = &[\n        (\"-1\", 771),\n        (\"1\", 746),\n        (\"1/2\", 400),\n        (\"-2\", 393),\n        (\"2\", 392),\n        (\"-1/4\", 376),\n        (\"4\", 374),\n        (\"1/4\", 374),\n        (\"-1/2\", 371),\n        (\"1/8\", 364),\n    ];\n    let sample_median = (\n        \"-144115205255725055/979746761720636838570985193498093558267704500484488575872951292219126\\\n        535205986877548162797451588896054171174290755185947242500542102825307421372913188911655327\\\n        9240115862075993700091884987318332951625727\",\n        Some(\n            \"-64/870216902382548101082732198927734427236298632942811591373701982167193271662795024\\\n            74847721902845790124837140768618290655265839460108220779308034391550625260769672349354\\\n            97445986979146629119\",\n        ),\n    );\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.8438486163830216e252),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_nonzero_rationals_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_rationals_fail_1() {\n    striped_random_nonzero_rationals(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_rationals_fail_2() {\n    striped_random_nonzero_rationals(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_rationals_fail_3() {\n    striped_random_nonzero_rationals(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_nonzero_rationals_fail_4() {\n    striped_random_nonzero_rationals(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/striped_random_positive_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::striped_random_positive_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\n#[allow(clippy::too_many_arguments)]\nfn striped_random_positive_rationals_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        striped_random_positive_rationals(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_positive_rationals() {\n    // mean bits = 65/64\n    let values = &[\"1\"; 20];\n    let common_values = &[\n        (\"1\", 969574),\n        (\"3\", 7614),\n        (\"1/3\", 7540),\n        (\"2\", 7358),\n        (\"1/2\", 7310),\n        (\"4\", 98),\n        (\"7\", 88),\n        (\"1/7\", 87),\n        (\"1/4\", 79),\n        (\"2/3\", 59),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.0148534444805162),\n        standard_deviation: NiceFloat(0.22114620623320444),\n        skewness: NiceFloat(9.149432588003647),\n        excess_kurtosis: NiceFloat(159.01272255850165),\n    };\n    striped_random_positive_rationals_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"1/16\", \"1/16\", \"4/15\", \"2\", \"1\", \"1\", \"1\", \"1\", \"3/2\", \"1\", \"1\", \"2/3\", \"1\", \"1/7\", \"2\",\n        \"16\", \"1\", \"4\", \"2\", \"1/2\",\n    ];\n    let common_values = &[\n        (\"1\", 286322),\n        (\"2\", 71839),\n        (\"1/2\", 71792),\n        (\"1/3\", 65670),\n        (\"3\", 65630),\n        (\"1/4\", 27230),\n        (\"4\", 26986),\n        (\"7\", 24307),\n        (\"1/7\", 24217),\n        (\"2/3\", 16638),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(8.675884348144963),\n        standard_deviation: NiceFloat(452.3475394447746),\n        skewness: NiceFloat(244.55477994852157),\n        excess_kurtosis: NiceFloat(71058.94920001029),\n    };\n    striped_random_positive_rationals_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"4\",\n        \"1/268681216\",\n        \"75493376/9007199120523391\",\n        \"8/8796094070783\",\n        \"8/950737950171027935941967741439\",\n        \"1040391/33554432\",\n        \"2813000899879757964630563421437095845888\",\n        \"1/79164837199872\",\n        \"2199023255551/16\",\n        \"220784470296873664512/4611685966886694919\",\n        \"33/256\",\n        \"16809472/144255925429997319\",\n        \"6129981798088146185736712229649530847599712363400396804/786431\",\n        \"1099511578623/1073741761\",\n        \"2/65791\",\n        \"18014398509490175/266208\",\n        \"1/140752654954496\",\n        \"2417842415927590238812160\",\n        \"9444732965755934466048/7\",\n        \"4194303/1073709056\",\n    ];\n    let common_values = &[\n        (\"1\", 3591),\n        (\"1/2\", 1841),\n        (\"2\", 1732),\n        (\"1/4\", 1579),\n        (\"4\", 1555),\n        (\"1/8\", 1495),\n        (\"8\", 1470),\n        (\"1/16\", 1391),\n        (\"16\", 1304),\n        (\"1/32\", 1231),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.394348586566577e127),\n        standard_deviation: NiceFloat(2.3943485865002743e130),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_rationals_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"302231454903657360261120/383\",\n        \"3/2166395068749415481073467392\",\n        \"174223242635524708377374895198005052307456/664594824829454142366461086851399679\",\n        \"4503599627370496/127\",\n        \"2048/147574233996470517759\",\n        \"9132155158831519862233019347003870166304109363/209664\",\n        \"10634473003386642729879378371710812032/31\",\n        \"536870911/34359738368\",\n        \"5026338869833/1328165573307087716352\",\n        \"768/72040001986101247\",\n        \"18014261070561279/2786912585102768425368689128829376599687168\",\n        \"133152\",\n        \"3/545357767376900\",\n        \"31/2251799813685247\",\n        \"4398046511135/64\",\n        \"8796093046784/4194303\",\n        \"38685626236675332845338112/562949953420767\",\n        \"4459452226323108777095472045064328031949030396/50331647\",\n        \"2535298782614042945771878219776/70366596710399\",\n        \"144115188075855871/154740143727431099539783680\",\n    ];\n    let common_values = &[\n        (\"1\", 1591),\n        (\"2\", 794),\n        (\"1/2\", 762),\n        (\"8\", 757),\n        (\"16\", 718),\n        (\"4\", 691),\n        (\"1/4\", 691),\n        (\"1/8\", 689),\n        (\"1/16\", 659),\n        (\"32\", 650),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.3341225920157865e234),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_positive_rationals_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_rationals_fail_1() {\n    striped_random_positive_rationals(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_rationals_fail_2() {\n    striped_random_positive_rationals(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_rationals_fail_3() {\n    striped_random_positive_rationals(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_positive_rationals_fail_4() {\n    striped_random_positive_rationals(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "malachite-q/tests/random/striped_random_rational_range_to_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::f64;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::Rational;\nuse malachite_q::random::striped_random_rational_range_to_infinity;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_rational_range_to_infinity_helper(\n    a: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        striped_random_rational_range_to_infinity(\n            EXAMPLE_SEED,\n            Rational::from_str(a).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_rational_range_to_infinity() {\n    let values = &[\n        \"271/512\",\n        \"6171\",\n        \"566935683071/512\",\n        \"76/3\",\n        \"15/64\",\n        \"255/2\",\n        \"4\",\n        \"48127/16\",\n        \"11/2048\",\n        \"3/2\",\n        \"515\",\n        \"17242800127/1024\",\n        \"1048703/124\",\n        \"234881024/15\",\n        \"128/31\",\n        \"8796218851359/8388544\",\n        \"533112815615/2112\",\n        \"2/2047\",\n        \"56/163839\",\n        \"35840/67108639\",\n    ];\n    let common_values = &[\n        (\"0\", 8352),\n        (\"1\", 7761),\n        (\"1/2\", 6447),\n        (\"1/3\", 4862),\n        (\"1/4\", 4784),\n        (\"1/8\", 3643),\n        (\"2\", 3520),\n        (\"3\", 3478),\n        (\"1/15\", 3148),\n        (\"1/7\", 3059),\n    ];\n    let sample_median = (\"32\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(4.409358732383749e152),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_infinity_helper(\n        \"0\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"67625999/512\",\n        \"255\",\n        \"65535/512\",\n        \"64/3\",\n        \"15359/64\",\n        \"127/2\",\n        \"4\",\n        \"51/16\",\n        \"6447/2048\",\n        \"12884903935/2\",\n        \"16\",\n        \"507907/1024\",\n        \"481238123007/124\",\n        \"240652386176/15\",\n        \"259/31\",\n        \"8796092760095/8388544\",\n        \"137438953471/2112\",\n        \"8127456/2047\",\n        \"4195072/163839\",\n        \"34359685144/67108639\",\n    ];\n    let common_values = &[\n        (\"7/2\", 8188),\n        (\"4\", 5039),\n        (\"7\", 5016),\n        (\"8\", 4043),\n        (\"15\", 3931),\n        (\"13/4\", 3381),\n        (\"16\", 3288),\n        (\"15/4\", 3136),\n        (\"31\", 3076),\n        (\"15/2\", 2959),\n    ];\n    let sample_median = (\"2175/16\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(7.744407957000211e34),\n        standard_deviation: NiceFloat(7.744259426671135e37),\n        skewness: NiceFloat(999.9984995429722),\n        excess_kurtosis: NiceFloat(999994.9993924203),\n    };\n    striped_random_rational_range_to_infinity_helper(\n        \"245850922/78256779\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"4593671619918423055/512\",\n        \"-1\",\n        \"18371/512\",\n        \"4193840/3\",\n        \"262207/64\",\n        \"35/2\",\n        \"512\",\n        \"5/16\",\n        \"15/2048\",\n        \"1/2\",\n        \"3\",\n        \"8796025921535/1024\",\n        \"32383/124\",\n        \"2097152/15\",\n        \"520617983/31\",\n        \"281473298997247/8388544\",\n        \"753727/2112\",\n        \"1/2047\",\n        \"316922321454532762194950488064/163839\",\n        \"140737572241392/67108639\",\n    ];\n    let common_values = &[\n        (\"0\", 7263),\n        (\"-1\", 6723),\n        (\"1\", 6665),\n        (\"1/2\", 5349),\n        (\"-1/2\", 5279),\n        (\"-1/4\", 3876),\n        (\"-1/3\", 3821),\n        (\"1/4\", 3789),\n        (\"1/3\", 3702),\n        (\"3\", 3112),\n    ];\n    let sample_median = (\"1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.9587800502633983e137),\n        standard_deviation: NiceFloat(1.9506593605642805e140),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_infinity_helper(\n        \"-245850922/78256779\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"425/682\",\n        \"5417\",\n        \"915560901293/682\",\n        \"106/3\",\n        \"13/106\",\n        \"213/2\",\n        \"6\",\n        \"43605/26\",\n        \"1/2730\",\n        \"53/2\",\n        \"30042\",\n        \"2022571682517/1354\",\n        \"3413/122\",\n        \"29320310074197/13\",\n        \"10/27\",\n        \"1365/6728362\",\n        \"421/3402\",\n        \"218/1365\",\n        \"10/187029\",\n        \"123120293/47535445\",\n    ];\n    let common_values = &[\n        (\"0\", 8397),\n        (\"1\", 7518),\n        (\"1/6\", 7132),\n        (\"1/2\", 6454),\n        (\"1/3\", 5083),\n        (\"1/10\", 4786),\n        (\"2\", 3565),\n        (\"3\", 3511),\n        (\"1/42\", 3475),\n        (\"1/5\", 3333),\n    ];\n    let sample_median = (\"168/5\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(1.94013873735947e225),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_infinity_helper(\n        \"0\",\n        11,\n        10,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"86693545/682\",\n        \"213\",\n        \"89461/682\",\n        \"86/3\",\n        \"13485/106\",\n        \"85/2\",\n        \"5\",\n        \"85/26\",\n        \"58640620148053/2730\",\n        \"85/2\",\n        \"1791306\",\n        \"3515733/1354\",\n        \"5461/122\",\n        \"5546/13\",\n        \"425022890/27\",\n        \"28644288853/6728362\",\n        \"11605/3402\",\n        \"218278/1365\",\n        \"14316545365/187029\",\n        \"447042218/47535445\",\n    ];\n    let common_values = &[\n        (\"7/2\", 8241),\n        (\"5\", 5118),\n        (\"6\", 5008),\n        (\"10\", 4145),\n        (\"13\", 4037),\n        (\"53/6\", 3903),\n        (\"21\", 3250),\n        (\"26\", 3189),\n        (\"13/3\", 3159),\n        (\"85/6\", 3149),\n    ];\n    let sample_median = (\"170\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.679955500231244e31),\n        standard_deviation: NiceFloat(3.5472081267359855e34),\n        skewness: NiceFloat(997.8746442700499),\n        excess_kurtosis: NiceFloat(997092.4918116309),\n    };\n    striped_random_rational_range_to_infinity_helper(\n        \"245850922/78256779\",\n        11,\n        10,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"3075190078489417385/682\",\n        \"-1\",\n        \"13653/682\",\n        \"2796202/3\",\n        \"174677/106\",\n        \"43/2\",\n        \"938\",\n        \"5/26\",\n        \"611669/2730\",\n        \"5/2\",\n        \"298\",\n        \"1365/1354\",\n        \"240299/122\",\n        \"-2/13\",\n        \"3002582332429654/27\",\n        \"3582613/6728362\",\n        \"1/3402\",\n        \"55923893/1365\",\n        \"22906516820/187029\",\n        \"-3418/47535445\",\n    ];\n    let common_values = &[\n        (\"0\", 7243),\n        (\"1\", 6768),\n        (\"-1\", 6595),\n        (\"-1/2\", 5212),\n        (\"1/6\", 5110),\n        (\"-1/6\", 5064),\n        (\"1/2\", 4972),\n        (\"1/3\", 4057),\n        (\"-1/3\", 4026),\n        (\"-1/10\", 3488),\n    ];\n    let sample_median = (\"5/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(3.188107796101159e165),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_infinity_helper(\n        \"-245850922/78256779\",\n        11,\n        10,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_infinity_fail_1() {\n    striped_random_rational_range_to_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        1,\n        10,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_infinity_fail_2() {\n    striped_random_rational_range_to_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        1,\n        0,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_infinity_fail_3() {\n    striped_random_rational_range_to_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        1,\n        2,\n        3,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_infinity_fail_4() {\n    striped_random_rational_range_to_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        1,\n        0,\n        10,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_infinity_fail_5() {\n    striped_random_rational_range_to_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/striped_random_rational_range_to_negative_infinity.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse core::f64;\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::Rational;\nuse malachite_q::random::striped_random_rational_range_to_negative_infinity;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\nuse std::str::FromStr;\n\nfn striped_random_rational_range_to_negative_infinity_helper(\n    a: &str,\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        striped_random_rational_range_to_negative_infinity(\n            EXAMPLE_SEED,\n            Rational::from_str(a).unwrap(),\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_rational_range_to_negative_infinity() {\n    let values = &[\n        \"-271/512\",\n        \"-6171\",\n        \"-566935683071/512\",\n        \"-76/3\",\n        \"-15/64\",\n        \"-255/2\",\n        \"-4\",\n        \"-48127/16\",\n        \"-11/2048\",\n        \"-3/2\",\n        \"-515\",\n        \"-17242800127/1024\",\n        \"-1048703/124\",\n        \"-234881024/15\",\n        \"-128/31\",\n        \"-8796218851359/8388544\",\n        \"-533112815615/2112\",\n        \"-2/2047\",\n        \"-56/163839\",\n        \"-35840/67108639\",\n    ];\n    let common_values = &[\n        (\"0\", 8352),\n        (\"-1\", 7761),\n        (\"-1/2\", 6447),\n        (\"-1/3\", 4862),\n        (\"-1/4\", 4784),\n        (\"-1/8\", 3643),\n        (\"-2\", 3520),\n        (\"-3\", 3478),\n        (\"-1/15\", 3148),\n        (\"-1/7\", 3059),\n    ];\n    let sample_median = (\"-32\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.409358732383749e152),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_negative_infinity_helper(\n        \"0\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-4503599627887631/512\",\n        \"-135235075\",\n        \"-262115/512\",\n        \"-4198396/3\",\n        \"-7/64\",\n        \"1/2\",\n        \"-37588312048\",\n        \"1/16\",\n        \"-11/2048\",\n        \"-3/2\",\n        \"-1\",\n        \"-63/1024\",\n        \"259/124\",\n        \"-8191/15\",\n        \"-8796093022177/31\",\n        \"-4095/8388544\",\n        \"-1/2112\",\n        \"-8/2047\",\n        \"-67108867/163839\",\n        \"2/67108639\",\n    ];\n    let common_values = &[\n        (\"0\", 7327),\n        (\"-1\", 6761),\n        (\"1\", 6713),\n        (\"1/2\", 5344),\n        (\"-1/2\", 5234),\n        (\"-1/3\", 3833),\n        (\"1/3\", 3826),\n        (\"1/4\", 3810),\n        (\"-1/4\", 3726),\n        (\"3\", 3159),\n    ];\n    let sample_median = (\"-1\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.615673330944999e205),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_negative_infinity_helper(\n        \"245850922/78256779\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-67625999/512\",\n        \"-255\",\n        \"-65535/512\",\n        \"-64/3\",\n        \"-15359/64\",\n        \"-127/2\",\n        \"-4\",\n        \"-51/16\",\n        \"-6447/2048\",\n        \"-12884903935/2\",\n        \"-16\",\n        \"-507907/1024\",\n        \"-481238123007/124\",\n        \"-240652386176/15\",\n        \"-259/31\",\n        \"-8796092760095/8388544\",\n        \"-137438953471/2112\",\n        \"-8127456/2047\",\n        \"-4195072/163839\",\n        \"-34359685144/67108639\",\n    ];\n    let common_values = &[\n        (\"-7/2\", 8188),\n        (\"-4\", 5039),\n        (\"-7\", 5016),\n        (\"-8\", 4043),\n        (\"-15\", 3931),\n        (\"-13/4\", 3381),\n        (\"-16\", 3288),\n        (\"-15/4\", 3136),\n        (\"-31\", 3076),\n        (\"-15/2\", 2959),\n    ];\n    let sample_median = (\"-2175/16\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-7.744407957000211e34),\n        standard_deviation: NiceFloat(7.744259426671135e37),\n        skewness: NiceFloat(-999.9984995429722),\n        excess_kurtosis: NiceFloat(999994.9993924203),\n    };\n    striped_random_rational_range_to_negative_infinity_helper(\n        \"-245850922/78256779\",\n        10,\n        1,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-425/682\",\n        \"-5417\",\n        \"-915560901293/682\",\n        \"-106/3\",\n        \"-13/106\",\n        \"-213/2\",\n        \"-6\",\n        \"-43605/26\",\n        \"-1/2730\",\n        \"-53/2\",\n        \"-30042\",\n        \"-2022571682517/1354\",\n        \"-3413/122\",\n        \"-29320310074197/13\",\n        \"-10/27\",\n        \"-1365/6728362\",\n        \"-421/3402\",\n        \"-218/1365\",\n        \"-10/187029\",\n        \"-123120293/47535445\",\n    ];\n    let common_values = &[\n        (\"0\", 8397),\n        (\"-1\", 7518),\n        (\"-1/6\", 7132),\n        (\"-1/2\", 6454),\n        (\"-1/3\", 5083),\n        (\"-1/10\", 4786),\n        (\"-2\", 3565),\n        (\"-3\", 3511),\n        (\"-1/42\", 3475),\n        (\"-1/5\", 3333),\n    ];\n    let sample_median = (\"-168/5\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.94013873735947e225),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_negative_infinity_helper(\n        \"0\",\n        11,\n        10,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-3735132622739113/682\",\n        \"-223696213\",\n        \"-218453/682\",\n        \"-5416618/3\",\n        \"-5/106\",\n        \"1/2\",\n        \"-57355358890\",\n        \"-25/26\",\n        \"-5960819038131541/2730\",\n        \"-27317/2\",\n        \"-1453\",\n        \"853/1354\",\n        \"-223696213/122\",\n        \"-42/13\",\n        \"1/27\",\n        \"-53/6728362\",\n        \"-43/3402\",\n        \"-693673/1365\",\n        \"-2863311530/187029\",\n        \"21802/47535445\",\n    ];\n    let common_values = &[\n        (\"0\", 7227),\n        (\"1\", 6794),\n        (\"-1\", 6488),\n        (\"1/2\", 5198),\n        (\"1/6\", 5142),\n        (\"-1/2\", 5003),\n        (\"-1/6\", 4997),\n        (\"-1/3\", 4098),\n        (\"1/3\", 3964),\n        (\"1/10\", 3535),\n    ];\n    let sample_median = (\"-5/6\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-4.8115651702518996e170),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rational_range_to_negative_infinity_helper(\n        \"245850922/78256779\",\n        11,\n        10,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n\n    let values = &[\n        \"-86693545/682\",\n        \"-213\",\n        \"-89461/682\",\n        \"-86/3\",\n        \"-13485/106\",\n        \"-85/2\",\n        \"-5\",\n        \"-85/26\",\n        \"-58640620148053/2730\",\n        \"-85/2\",\n        \"-1791306\",\n        \"-3515733/1354\",\n        \"-5461/122\",\n        \"-5546/13\",\n        \"-425022890/27\",\n        \"-28644288853/6728362\",\n        \"-11605/3402\",\n        \"-218278/1365\",\n        \"-14316545365/187029\",\n        \"-447042218/47535445\",\n    ];\n    let common_values = &[\n        (\"-7/2\", 8241),\n        (\"-5\", 5118),\n        (\"-6\", 5008),\n        (\"-10\", 4145),\n        (\"-13\", 4037),\n        (\"-53/6\", 3903),\n        (\"-21\", 3250),\n        (\"-26\", 3189),\n        (\"-13/3\", 3159),\n        (\"-85/6\", 3149),\n    ];\n    let sample_median = (\"-170\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3.679955500231244e31),\n        standard_deviation: NiceFloat(3.5472081267359855e34),\n        skewness: NiceFloat(-997.8746442700499),\n        excess_kurtosis: NiceFloat(997092.4918116309),\n    };\n    striped_random_rational_range_to_negative_infinity_helper(\n        \"-245850922/78256779\",\n        11,\n        10,\n        10,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_negative_infinity_fail_1() {\n    striped_random_rational_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        1,\n        10,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_negative_infinity_fail_2() {\n    striped_random_rational_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        1,\n        0,\n        0,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_negative_infinity_fail_3() {\n    striped_random_rational_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        10,\n        1,\n        2,\n        3,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_negative_infinity_fail_4() {\n    striped_random_rational_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        1,\n        0,\n        10,\n        1,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rational_range_to_negative_infinity_fail_5() {\n    striped_random_rational_range_to_negative_infinity(\n        EXAMPLE_SEED,\n        Rational::from_unsigneds(1u32, 3),\n        2,\n        3,\n        10,\n        1,\n    );\n}\n"
  },
  {
    "path": "malachite-q/tests/random/striped_random_rationals.rs",
    "content": "// Copyright © 2026 Mikhail Hogrefe\n//\n// This file is part of Malachite.\n//\n// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU\n// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version\n// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.\n\nuse malachite_base::num::float::NiceFloat;\nuse malachite_base::random::EXAMPLE_SEED;\nuse malachite_base::test_util::stats::moments::MomentStats;\nuse malachite_q::random::striped_random_rationals;\nuse malachite_q::test_util::random::random_rationals_helper_helper;\n\n#[allow(clippy::too_many_arguments)]\nfn striped_random_rationals_helper(\n    mean_stripe_numerator: u64,\n    mean_stripe_denominator: u64,\n    mean_bits_numerator: u64,\n    mean_bits_denominator: u64,\n    expected_values: &[&str],\n    expected_common_values: &[(&str, usize)],\n    expected_sample_median: (&str, Option<&str>),\n    expected_sample_moment_stats: MomentStats,\n) {\n    random_rationals_helper_helper(\n        striped_random_rationals(\n            EXAMPLE_SEED,\n            mean_stripe_numerator,\n            mean_stripe_denominator,\n            mean_bits_numerator,\n            mean_bits_denominator,\n        ),\n        expected_values,\n        expected_common_values,\n        expected_sample_median,\n        expected_sample_moment_stats,\n    );\n}\n\n#[test]\nfn test_striped_random_rationals() {\n    // mean bits = 65/64\n    let values = &[\n        \"0\", \"0\", \"0\", \"2\", \"0\", \"0\", \"1\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"-16\", \"-1\", \"-4\",\n        \"-1\", \"-1\", \"0\",\n    ];\n    let common_values = &[\n        (\"0\", 496048),\n        (\"1\", 123954),\n        (\"-1\", 123710),\n        (\"-2\", 31233),\n        (\"2\", 30993),\n        (\"3\", 30937),\n        (\"-3\", 30910),\n        (\"7\", 11738),\n        (\"-4\", 11737),\n        (\"-7\", 11729),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-1.06036515396832),\n        standard_deviation: NiceFloat(1203.859766379983),\n        skewness: NiceFloat(-487.1920464463729),\n        excess_kurtosis: NiceFloat(487007.7928991194),\n    };\n    striped_random_rationals_helper(\n        4,\n        1,\n        65,\n        64,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 2\n    let values = &[\n        \"-2/3\", \"-4/3\", \"0\", \"1\", \"0\", \"1/2\", \"448\", \"0\", \"0\", \"1\", \"5/14\", \"-11/3\", \"0\", \"-1/3\",\n        \"-19/3\", \"-1/3\", \"0\", \"-1\", \"0\", \"-15\",\n    ];\n    let common_values = &[\n        (\"0\", 333130),\n        (\"1\", 67324),\n        (\"-1\", 67073),\n        (\"-2\", 22423),\n        (\"2\", 22254),\n        (\"3\", 20160),\n        (\"-3\", 20001),\n        (\"1/2\", 16904),\n        (\"-1/2\", 16848),\n        (\"1/3\", 15068),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-3996.9592018545704),\n        standard_deviation: NiceFloat(5028832.275338866),\n        skewness: NiceFloat(-521.7417186307244),\n        excess_kurtosis: NiceFloat(372144.3645614976),\n    };\n    striped_random_rationals_helper(\n        4,\n        1,\n        2,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 32\n    let values = &[\n        \"-8192/127\",\n        \"-16776704/4396972769407\",\n        \"8796093005951/648518346332962816\",\n        \"87381/2863267840\",\n        \"-1024/2043\",\n        \"51/58408828928\",\n        \"85/13521606402434254795714066382848\",\n        \"270335/7\",\n        \"59421159664630116152453890047/9444741445172838006656\",\n        \"6291455/1154891846623166464\",\n        \"4503599631564799/114177029184456441820717001177155938271778439152\",\n        \"-40247906632508999881205124923399/137438953471\",\n        \"73/154619122249\",\n        \"-1024/39611663922002864317824761855\",\n        \"-32\",\n        \"-127/9\",\n        \"-2199023247360/287\",\n        \"-1/8257539\",\n        \"-590156181179127562240/131199\",\n        \"-1/85\",\n    ];\n    let common_values = &[\n        (\"0\", 30369),\n        (\"1\", 1751),\n        (\"-1\", 1743),\n        (\"2\", 846),\n        (\"1/2\", 820),\n        (\"-1/2\", 799),\n        (\"-2\", 792),\n        (\"-4\", 769),\n        (\"4\", 758),\n        (\"1/4\", 757),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(2.681561663446933e148),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rationals_helper(\n        16,\n        1,\n        32,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n    // mean bits = 64\n    let values = &[\n        \"-1464583847936/7981747608676504359847391117664870922673555168908629\",\n        \"-2422574005712127994617856/100041309094775311912751523786213765636294062424476459466751\",\n        \"9671406556916483641901054/2047\",\n        \"1/10141204801678261259383949230080\",\n        \"-1/10384593719487506031596923529461760\",\n        \"166153499473114484112975882535075839/1073741824\",\n        \"1073758207/2097152\",\n        \"10889035740836205568492768571262465220607/31\",\n        \"16225927683142697268042315648307/15474248646392859802468352\",\n        \"211174952009727/4294836224\",\n        \"1125625028999183/309485009533116616750923776\",\n        \"-160551237036734989468671/2146697215\",\n        \"4325375/324527219843164634252394901798911\",\n        \"-5666839779310716881032/42255019850195730860877091089\",\n        \"-201487684640834221069648/46912675075413\",\n        \"-1365/52818778157753880297518486869\",\n        \"-17179869184/7\",\n        \"-2420212822470693171986431/34359738367\",\n        \"-274877382656/11150372599265311570767859136324172163055871\",\n        \"-181/10141204802612896292451899146325\",\n    ];\n    let common_values = &[\n        (\"0\", 15382),\n        (\"1\", 752),\n        (\"-1\", 734),\n        (\"-1/2\", 405),\n        (\"1/2\", 402),\n        (\"2\", 371),\n        (\"-1/4\", 370),\n        (\"1/16\", 363),\n        (\"-4\", 359),\n        (\"1/4\", 358),\n    ];\n    let sample_median = (\"0\", None);\n    let sample_moment_stats = MomentStats {\n        mean: NiceFloat(-5.67251933470839e272),\n        standard_deviation: NiceFloat(f64::INFINITY),\n        skewness: NiceFloat(f64::NAN),\n        excess_kurtosis: NiceFloat(f64::NAN),\n    };\n    striped_random_rationals_helper(\n        32,\n        1,\n        64,\n        1,\n        values,\n        common_values,\n        sample_median,\n        sample_moment_stats,\n    );\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rationals_fail_1() {\n    striped_random_rationals(EXAMPLE_SEED, 1, 0, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rationals_fail_2() {\n    striped_random_rationals(EXAMPLE_SEED, 2, 3, 4, 1);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rationals_fail_3() {\n    striped_random_rationals(EXAMPLE_SEED, 4, 1, 1, 0);\n}\n\n#[test]\n#[should_panic]\nfn striped_random_rationals_fail_4() {\n    striped_random_rationals(EXAMPLE_SEED, 4, 1, 2, 3);\n}\n"
  },
  {
    "path": "rundoc.sh",
    "content": "#!/bin/bash\nP=$PWD &&\ncd ../../doc_runner &&\ncargo run --release -- $P \"$@\"\n"
  },
  {
    "path": "superfmt.sh",
    "content": "#!/bin/bash\ncargo fmt --all > /dev/null 2>&1 &&\nP=$PWD &&\ncd ../../format_comments &&\ncargo run --release -- $P\n"
  }
]